PageSourceSearch

https://www.linkclicks.com/static/js/9614.26e54124.chunk.js

js linkclicks.com collected 2026-09-24 13:59:47 UTC 377,276 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunklink_clicks_react_hook_reactstrap_js=globalThis.webpackChunklink_clicks_react_hook_reactstrap_js||[]).push([[9614],{41(e,s,t){t.d(s,{l:()=>a});const a=(e,s)=>{const t="pinterest_ads"===e?null===s||void 0===s?void 0:s.cooldown_until:null,a=t?new Date(t).getTime()-Date.now():0,n="pinterest_ads"===e&&a>0;return{cooldownActive:n,cooldownMinutesRemaining:n?Math.max(1,Math.ceil(a/6e4)):0}}},1093(e,s,t){t.d(s,{A:()=>c});var a=t(48738),n=t.n(a),i=t(9950),l=t(44089),r=t(44414);const o=i.forwardRef((e,s)=>{let{bsPrefix:t,className:a,striped:i,bordered:o,borderless:c,hover:d,size:m,variant:h,responsive:u,...x}=e;const p=(0,l.oU)(t,"table"),v=n()(a,p,h&&`${p}-${h}`,m&&`${p}-${m}`,i&&`${p}-${"string"===typeof i?`striped-${i}`:"striped"}`,o&&`${p}-bordered`,c&&`${p}-borderless`,d&&`${p}-hover`),f=(0,r.jsx)("table",{...x,className:v,ref:s});if(u){let e=`${p}-responsive`;return"string"===typeof u&&(e=`${e}-${u}`),(0,r.jsx)("div",{className:e,children:f})}return f});o.displayName="Table";const c=o},15291(e,s,t){t.r(s),t.d(s,{default:()=>ta});var a=t(9950),n=t(82569),i=(t(67629),t(42074)),l=t(99233),r=t(22347),o=t(70893),c=t(49533),d=t(7517),m=t(69422),h=t(25607),u=t(39476),x=t(32870),p=t(5637),v=t(49782),f=t(97937),g=t(41041),b=t(38003),j=t(7819),y=t(77907),N=t(6244),_=t(63890),w=t(62227);const k=e=>Boolean(e)&&(e.is_active||!e.disconnected_at);const S=e=>{var s;let{isDev:t,accessContext:a}=e;return Boolean(t||(null===a||void 0===a?void 0:a.actor_is_staff)||(null===a||void 0===a||null===(s=a.actor_feature_flags)||void 0===s?void 0:s.is_dev_user))};var C=t(99327),A=t(95252),P=t(58410),z=t(88240),T=t(25536),F=t(63565),E=t(20405),L=t(23554),D=t(44414);const $={shopify:{label:"Shopify",logo:T,color:"#96bf48"},woocommerce:{label:"WooCommerce",logo:E,color:"#7952b3",devOnly:!0},wix:{label:"Wix",logo:L,color:"#0c6efc",devOnly:!0}},I=e=>{let{isDarkMode:s,onError:t,error:n}=e;const[i,l]=(0,a.useState)(""),[r,o]=(0,a.useState)(!1);return(0,D.jsxs)(v.A,{onSubmit:e=>{e.preventDefault(),o(!0),t(null),(0,z.oK)(i).catch(e=>{t(e.message),o(!1)})},children:[(0,D.jsx)(F.A,{provider:"shopify"}),(0,D.jsx)("p",{className:"small mb-3 "+(s?"text-white-50":"text-muted"),children:"Enter your store domain and you'll be sent to Shopify to authorise the connection."}),(0,D.jsxs)(v.A.Group,{className:"mb-3",children:[(0,D.jsx)(v.A.Label,{className:"small fw-medium",children:"Store domain"}),(0,D.jsx)(v.A.Control,{type:"text",size:"sm",autoFocus:!0,placeholder:"mystore.myshopify.com (or just \u201cmystore\u201d)",value:i,onChange:e=>l(e.target.value)})]}),n&&(0,D.jsx)("div",{className:"text-danger small mb-2",children:n}),(0,D.jsx)(f.A,{type:"submit",variant:"success",size:"sm",disabled:r,children:r?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(A.A,{animation:"border",size:"sm",className:"me-2"}),"Connecting\u2026"]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("i",{className:"feather icon-link me-2"}),"Connect Shopify Store"]})})]})},R=e=>{let{isDarkMode:s,onError:t,error:n,onConnected:i}=e;const[l,r]=(0,a.useState)("manual"),[o,c]=(0,a.useState)({storeUrl:"",consumerKey:"",consumerSecret:""}),[d,m]=(0,a.useState)(""),[h,u]=(0,a.useState)(!1);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(P.A,{variant:"tabs",className:"mb-3",activeKey:l,onSelect:e=>{r(e),t(null)},children:[(0,D.jsx)(P.A.Item,{children:(0,D.jsxs)(P.A.Link,{eventKey:"manual",className:"small",children:[(0,D.jsx)("i",{className:"feather icon-key me-1"}),"Manual (API keys)"]})}),(0,D.jsx)(P.A.Item,{children:(0,D.jsxs)(P.A.Link,{eventKey:"oauth",className:"small",children:[(0,D.jsx)("i",{className:"feather icon-link me-1"}),"Auto-connect"]})})]}),"manual"===l?(0,D.jsxs)(v.A,{onSubmit:e=>{e.preventDefault(),u(!0),t(null),(0,z.$7)(o).then(()=>i("woocommerce")).catch(e=>t(e.message)).finally(()=>u(!1))},children:[(0,D.jsxs)("p",{className:"small mb-3 "+(s?"text-white-50":"text-muted"),children:["Generate REST API keys in your store under ",(0,D.jsx)("strong",{children:"WooCommerce \u2192 Settings \u2192 Advanced \u2192 REST API"}),"."]}),(0,D.jsxs)(v.A.Group,{className:"mb-2",children:[(0,D.jsx)(v.A.Label,{className:"small fw-medium",children:"Store URL"}),(0,D.jsx)(v.A.Control,{type:"url",size:"sm",autoFocus:!0,placeholder:"https://yourstore.com",value:o.storeUrl,onChange:e=>c(s=>({...s,storeUrl:e.target.value})),required:!0})]}),(0,D.jsxs)(v.A.Group,{className:"mb-2",children:[(0,D.jsx)(v.A.Label,{className:"small fw-medium",children:"Consumer Key"}),(0,D.jsx)(v.A.Control,{type:"text",size:"sm",placeholder:"ck_xxxxxxxxxxxx",value:o.consumerKey,onChange:e=>c(s=>({...s,consumerKey:e.target.value})),required:!0})]}),(0,D.jsxs)(v.A.Group,{className:"mb-3",children:[(0,D.jsx)(v.A.Label,{className:"small fw-medium",children:"Consumer Secret"}),(0,D.jsx)(v.A.Control,{type:"password",size:"sm",placeholder:"cs_xxxxxxxxxxxx",value:o.consumerSecret,onChange:e=>c(s=>({...s,consumerSecret:e.target.value})),required:!0})]}),n&&(0,D.jsx)("div",{className:"text-danger small mb-2",children:n}),(0,D.jsx)(f.A,{type:"submit",variant:"primary",size:"sm",disabled:h,children:h?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(A.A,{animation:"border",size:"sm",className:"me-2"}),"Connecting\u2026"]}):"Connect Store"})]}):(0,D.jsxs)(v.A,{onSubmit:e=>{e.preventDefault(),u(!0),t(null),(0,z.uE)(d).catch(e=>{t(e.message),u(!1)})},children:[(0,D.jsx)("p",{className:"small mb-3 "+(s?"text-white-50":"text-muted"),children:"Enter your store URL and you'll be redirected to authorise the connection from your WooCommerce admin \u2014 no API keys to copy."}),(0,D.jsxs)(v.A.Group,{className:"mb-3",children:[(0,D.jsx)(v.A.Label,{className:"small fw-medium",children:"Store URL"}),(0,D.jsx)(v.A.Control,{type:"url",size:"sm",autoFocus:!0,placeholder:"https://yourstore.com",value:d,onChange:e=>m(e.target.value),required:!0})]}),n&&(0,D.jsx)("div",{className:"text-danger small mb-2",children:n}),(0,D.jsx)(f.A,{type:"submit",variant:"primary",size:"sm",disabled:h,children:h?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(A.A,{animation:"border",size:"sm",className:"me-2"}),"Redirecting\u2026"]}):"Authorise \u2192"})]})]})},M=e=>{let{show:s,provider:t=null,onHide:n,onConnected:i,isDarkMode:l=!1,betaPass:r=!1}=e;const[o,c]=(0,a.useState)(t),[d,m]=(0,a.useState)(null);(0,a.useEffect)(()=>{s&&(c(t),m(null))},[s,t]);const h=(0,a.useCallback)(e=>{if(m(null),"wix"===e)return c("wix"),void(0,z.ai)().catch(e=>{m(e.message),c(null)});c(e)},[]),u=o?$[o]:null;return(0,D.jsxs)(p.A,{show:s,onHide:n,centered:!0,children:[(0,D.jsx)(p.A.Header,{closeButton:!0,className:l?"bg-dark text-white border-secondary":"",children:(0,D.jsxs)(p.A.Title,{className:"fs-6 d-flex align-items-center gap-2",children:[u&&(0,D.jsx)("img",{src:u.logo,alt:"",style:{width:22,height:22,objectFit:"contain"}}),u?`Connect ${u.label}`:"Connect an e-commerce store"]})}),(0,D.jsxs)(p.A.Body,{className:l?"bg-dark text-white":"",children:[!
1o&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("p",{className:"small mb-3 "+(l?"text-white-50":"text-muted"),children:"Choose your store platform. We'll import recent orders and match them to your ad clicks automatically."}),d&&(0,D.jsx)("div",{className:"text-danger small mb-2",children:d}),(0,D.jsx)("div",{className:"d-flex flex-column gap-2",children:Object.entries($).filter(e=>{let[,s]=e;return!s.devOnly||r}).map(e=>{let[s,t]=e;return(0,D.jsxs)("button",{type:"button",className:"btn text-start d-flex align-items-center gap-3 "+(l?"btn-outline-light":"btn-outline-secondary"),onClick:()=>h(s),children:[(0,D.jsx)("img",{src:t.logo,alt:"",style:{width:28,height:28,objectFit:"contain"}}),(0,D.jsx)("span",{className:"fw-semibold",children:t.label}),(0,D.jsx)("i",{className:"feather icon-chevron-right ms-auto"})]},s)})})]}),"shopify"===o&&(0,D.jsx)(I,{isDarkMode:l,error:d,onError:m}),"woocommerce"===o&&(0,D.jsx)(R,{isDarkMode:l,error:d,onError:m,onConnected:e=>{i(e),n()}}),"wix"===o&&(0,D.jsxs)("div",{className:"text-center py-4",children:[(0,D.jsx)(A.A,{animation:"border",size:"sm",className:"me-2"}),(0,D.jsx)("span",{className:l?"text-white-50":"text-muted",children:"Redirecting to Wix\u2026"})]})]}),o&&!t&&"wix"!==o&&(0,D.jsx)(p.A.Footer,{className:l?"bg-dark border-secondary":"",children:(0,D.jsxs)(f.A,{variant:"link",size:"sm",className:"text-muted p-0",onClick:()=>{c(null),m(null)},children:[(0,D.jsx)("i",{className:"feather icon-chevron-left me-1"}),"Choose a different platform"]})})]})};var B=t(28429),W=t(74283),O=t(29246),U=t(53766),H=t(50099),K=t(69146),q=t(58098),G=t(30542),V=t(28762),Q=t(42578),Y=t(49639),X=t(41);const J=e=>{let{platform:s,platformState:t=null,onConnect:a,isDarkMode:n=!1}=e;const{cooldownActive:i,cooldownMinutesRemaining:l}=(0,X.l)(s,t),r=(0,Q.Yo)(t),o="connecting"===r||"connected"===r,c=n?"1px solid rgba(255,255,255,0.08)":"1px solid rgba(0,0,0,0.07)";return(0,D.jsxs)("div",{className:"connect-drawer-row d-flex align-items-center gap-3",style:{padding:"0.85rem 0.25rem",borderBottom:c},children:[(0,D.jsx)("div",{style:{flexShrink:0,lineHeight:1},children:Q.aQ[s]}),(0,D.jsxs)("div",{style:{minWidth:0,flex:1},children:[(0,D.jsx)("div",{className:"fw-semibold",style:{fontSize:"0.92rem"},children:Q.zI[s]}),(0,D.jsx)("div",{className:"small text-truncate "+(n?"text-white-50":"text-muted"),style:{fontSize:"0.78rem"},children:Q.FW[s]})]}),(0,D.jsx)("div",{style:{flexShrink:0},children:i?(0,D.jsxs)(f.A,{variant:"secondary",size:"sm",disabled:!0,children:[(0,D.jsx)("i",{className:"fas fa-clock me-1"}),"Rate limited \u2014 ",l,"m"]}):o?(0,D.jsxs)(f.A,{variant:"outline-warning",size:"sm",disabled:!0,children:[(0,D.jsx)(A.A,{animation:"border",size:"sm",className:"me-2"}),"Connecting\u2026"]}):(0,D.jsxs)(f.A,{variant:"primary",size:"sm",onClick:()=>a(s),children:["Connect ",(0,D.jsx)("i",{className:"feather icon-link ms-1"})]})})]})},Z=e=>{let{show:s,onHide:t,platforms:a,platformStates:n,onConnect:i,isDarkMode:l=!1}=e;return(0,D.jsxs)(Y.A,{show:s,onHide:t,placement:"end",backdrop:!0,className:"am-drawer",style:{width:"500px"},children:[(0,D.jsx)(Y.A.Header,{closeButton:!0,children:(0,D.jsxs)(Y.A.Title,{children:[(0,D.jsx)("i",{className:"feather icon-link me-2"}),"Connect a Platform"]})}),(0,D.jsx)(Y.A.Body,{children:0===a.length?(0,D.jsxs)("div",{className:"d-flex flex-column align-items-center justify-content-center text-center pt-5 "+(l?"text-white-50":"text-muted"),children:[(0,D.jsx)("i",{className:"feather icon-check-circle",style:{fontSize:32,marginBottom:12,color:"#22c55e"}}),(0,D.jsx)("div",{style:{fontSize:"0.9rem"},children:"All platforms are connected."})]}):a.map(e=>(0,D.jsx)(J,{platform:e,platformState:n[e],onConnect:i,isDarkMode:l},e))})]})},ee=Object.keys(Q.zI),se={display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(320px, 1fr))",gap:"1.25rem",alignItems:"stretch"},te=e=>{let{isDarkMode:s}=e;return(0,D.jsxs)("div",{className:"d-flex flex-column align-items-center justify-content-center text-center pb-5 "+(s?"text-white-50":"text-muted"),children:[(0,D.jsx)("i",{className:"feather icon-link",style:{fontSize:36,marginBottom:14,opacity:.4}}),(0,D.jsx)("div",{className:"fw-semibold mb-1",style:{fontSize:"1rem"},children:"No platforms connected yet"}),(0,D.jsx)("div",{style:{fontSize:"0.82rem"},children:"Connect your ad platforms below to start syncing campaign performance data."})]})},ae={"authorization_error.DEVELOPER_TOKEN_NOT_APPROVED":"Google hasn't approved this app for non-test accounts yet \u2014 only test accounts can be listed until Basic API access is granted","authorization_error.USER_PERMISSION_DENIED":"your Google login doesn't have permission on this account","authorization_error.CUSTOMER_NOT_ENABLED":"the account is cancelled or not enabled","authentication_error.CUSTOMER_NOT_FOUND":"the account no longer exists",hierarchy_truncated:"the account tree was too large to read completely"},ne=e=>{var s;let{isDarkMode:t=!1,onRequestAiOpen:i=null}=e;const r=(0,B.zy)(),o=(0,B.Zp)(),c=(0,n.wA)(),{platformUpdate:d}=(0,a.useContext)(H.P),{accountSelection:m,user:h,termsVersion:u,isLoggedIn:x}=(0,a.useContext)(l.A),v=(0,n.d4)(e=>{var s;return null===(s=e.performance)||void 0===s?void 0:s.dataDateRange}),[g,j]=(0,a.useState)(()=>{const e=localStorage.getItem("platformStates"),s=(0,G.nX)();if(e)try{const t=JSON.parse(e);return Object.keys(s).reduce((e,a)=>(e[a]={...s[a],...t[a]},e),{})}catch{}return s}),[_,w]=(0,a.useState)([]),[k,S]=(0,a.useState)([]),[P,z]=(0,a.useState)(!1),[T,F]=(0,a.useState)(null),[E,L]=(0,a.useState)(!1),[$,I]=(0,a.useState)(!1),[R,M]=(0,a.useState)(!1),[Y,X]=(0,a.useState)(""),[J,ne]=(0,a.useState)(""),[ie,le]=(0,a.useState)(!1),[re,oe]=(0,a.useState)(!1),[ce,de]=(0,a.useState)([]),me=(0,a.useRef)({}),he=(0,a.useRef)(null),ue=(0,a.useRef)(null),xe=(0,a.useRef)(!1),pe=((e,s,t,a,n)=>{if(!h)return!1;const i=Boolean(null===h||void 0===h||null===(e=h.access_context)||void 0===e?void 0:e.is_cross_workspace),l=i?null!==(s=h.actor_terms_accepted_at)&&void 0!==s?s:null:null!==(t=h.actor_terms_accepted_at)&&void 0!==t?t:h.terms_accepted_at,r=i?null!==(a=h.actor_terms_version)&&void 0!==a?a:null:null!==(n=h.actor_terms_version)&&void 0!==n?n:h.terms_version;return!!l&&(r||"")===(u||"")})(),ve=(e,s)=>{const t=s||(null===h||void 0===h?void 0:h.provider)||"";return(e||[]).map(e=>({...e,ad_platform:e.ad_platform||e.adPlatform||t}))};(0,a.useEffect)(()=>
1{if(!re||xe.current)return;!ee.some(e=>"imported"===(0,Q.Yo)(g[e]))&&i&&(xe.current=!0,i())},[re,g,i]),(0,a.useEffect)(()=>{localStorage.setItem("platformStates",JSON.stringify(g))},[g]),(0,a.useEffect)(()=>{const e=setInterval(()=>{j(e=>{var s;const t=null===e||void 0===e||null===(s=e.pinterest_ads)||void 0===s?void 0:s.cooldown_until;if(!t)return e;const a=new Date(t).getTime();return Number.isFinite(a)&&a<=Date.now()?{...e,pinterest_ads:{...e.pinterest_ads,cooldown_until:null}}:e})},15e3);return()=>clearInterval(e)},[]),(0,a.useEffect)(()=>{var e;if(null===(e=r.state)||void 0===e||!e.forceAccountModal)return;const s=r.state.provider||"",t=ve(r.state.accounts||[],s);t.forEach(e=>{me.current[e.account_id]=e.account_name}),pe?(w(t),X(s),z(!0),L(!1)):F({accounts:t,provider:s}),window.setTimeout(()=>{o("",{replace:!0,state:{}})},0)},[r.state,o,pe]),(0,a.useEffect)(()=>{if(!re)return;const e=W.A.parse(r.search),s=e.code||null,t=e.state||null,a=e.provider||null,n="authorize_conversions"===t;if(e.returnTo?ue.current=e.returnTo:n&&(ue.current="/insights"),s&&t&&a){if(he.current===s)return;if(he.current=s,L(!1),le(!0),"authorize"===t||n)j(e=>({...e,[a]:{...e[a],status:"connecting"}})),(0,y.Ku)(`${U.eN}/${a}/oauth/`,{code:s,state:t}).then(e=>{var s;const t=(null===e||void 0===e?void 0:e.data)||{},n=Array.isArray(null===t||void 0===t?void 0:t.accounts)?t.accounts:Array.isArray(null===t||void 0===t||null===(s=t.data)||void 0===s?void 0:s.accounts)?t.data.accounts:Array.isArray(t)?t:[];if(Array.isArray(n)){var i;const e=ve(n,a);e.forEach(e=>{me.current[e.account_id]=e.account_name}),w(e),S(Array.isArray(null===t||void 0===t?void 0:t.account_warnings)?t.account_warnings:[]),X(a||(null===(i=e[0])||void 0===i?void 0:i.ad_platform)||"");const s=Boolean(null===t||void 0===t?void 0:t.identity_only),l=Array.isArray(null===t||void 0===t?void 0:t.missing_scopes)?t.missing_scopes:[];de(s?l:[]),z(!0),L(!1),j(e=>({...e,[a]:{...e[a],status:"connected"}})),o("",{replace:!0})}else(0,N.UW)("Failed to retrieve accounts. Please try again.")}).catch(e=>{var s,t;const n=null===e||void 0===e||null===(s=e.response)||void 0===s?void 0:s.status,i=null===e||void 0===e||null===(t=e.response)||void 0===t?void 0:t.data;if("pinterest_ads"===a&&429===n){const e=Math.max(Number(null===i||void 0===i?void 0:i.retry_after)||0,900),s=new Date(Date.now()+1e3*e).toISOString();return j(e=>({...e,pinterest_ads:{...e.pinterest_ads,status:"initial",cooldown_until:s}})),void(0,N.UW)(`Pinterest rate limit hit. Please wait ~${Math.ceil(e/60)} minutes.`,{detail:null,modalTitle:"Pinterest rate limit",platformName:"Pinterest Ads",showMoreLink:!1})}const l="string"===typeof(null===i||void 0===i?void 0:i.message)&&i.message.trim()?i.message:"";(0,N.UW)(`Error retrieving accounts: ${l||(null===e||void 0===e?void 0:e.message)||"Request failed"}`,{detail:i||(null===e||void 0===e?void 0:e.message),platformName:Q.zI[a]||""})}).finally(()=>{le(!1)});else if(m){var i;const e=null===(i=g[a])||void 0===i?void 0:i.status;if("imported"===e||"importing"===e)return le(!1),void o("",{replace:!0});const s=ve(JSON.parse(m),a);var l;if(Array.isArray(s))s.forEach(e=>{me.current[e.account_id]=e.account_name}),w(s),X(a||(null===(l=s[0])||void 0===l?void 0:l.ad_platform)||""),de([]),z(!0),L(!1);le(!1),o("",{replace:!0})}else j(e=>({...e,[a]:{...e[a],status:"connecting"}})),(0,y.Ku)(`${U.eN}/${a}/oauth/`,{code:s,state:t}).then(e=>{var s,t;const n=(null===e||void 0===e?void 0:e.data)||{},i=Array.isArray(null===n||void 0===n?void 0:n.accounts)?n.accounts:Array.isArray(null===n||void 0===n||null===(s=n.data)||void 0===s?void 0:s.accounts)?n.data.accounts:Array.isArray(n)?n:[],l=ve(i,a);l.forEach(e=>{me.current[e.account_id]=e.account_name}),w(l),X(a||(null===(t=l[0])||void 0===t?void 0:t.ad_platform)||"");const r=Boolean(null===n||void 0===n?void 0:n.identity_only),c=Array.isArray(null===n||void 0===n?void 0:n.missing_scopes)?n.missing_scopes:[];de(r?c:[]),z(!0),L(!1),j(e=>({...e,[a]:{...e[a],status:"connected"}})),o("",{replace:!0})}).catch(e=>{var s;const t=null===e||void 0===e||null===(s=e.response)||void 0===s?void 0:s.data,n="string"===typeof(null===t||void 0===t?void 0:t.message)&&t.message.trim()?t.message:"";(0,N.UW)(`Error retrieving accounts: ${n||(null===e||void 0===e?void 0:e.message)||"Request failed"}`,{detail:t||(null===e||void 0===e?void 0:e.message),platformName:Q.zI[a]||""}),j(e=>({...e,[a]:{...e[a],status:"initial"}}))}).finally(()=>{le(!1)})}},[r,o,re,m,g]),(0,a.useEffect)(()=>
1{if(!pe||!T)return;const{accounts:e,provider:s}=T;if(Array.isArray(e)){var t,a;const n=s||(null===(t=e[0])||void 0===t?void 0:t.ad_platform)||(null===(a=e[0])||void 0===a?void 0:a.adPlatform)||(null===h||void 0===h?void 0:h.provider)||"",i=e.map(e=>({...e,ad_platform:e.ad_platform||e.adPlatform||n}));w(i),X(n),z(!0),L(!1)}F(null)},[pe,T]),(0,a.useEffect)(()=>{if(re&&!P&&m&&!E)try{const i=ve(JSON.parse(m));if(Array.isArray(i)&&i.length>0){var e,s,t;const a=(null===(e=i[0])||void 0===e?void 0:e.ad_platform)||(null===(s=r.state)||void 0===s?void 0:s.provider)||(null===h||void 0===h?void 0:h.provider)||"",n=null===(t=g[a])||void 0===t?void 0:t.status;if("imported"===n||"importing"===n)return;i.forEach(e=>{me.current[e.account_id]=e.account_name}),w(i),X(a),pe?(z(!0),L(!1)):F({accounts:i,provider:a})}else if(Array.isArray(i)&&0===i.length){var a;const e=(null===(a=r.state)||void 0===a?void 0:a.provider)||(null===h||void 0===h?void 0:h.provider)||"";if(e){var n;const s=null===(n=g[e])||void 0===n?void 0:n.status;"imported"!==s&&"importing"!==s&&(w([]),X(e),pe?(z(!0),L(!1)):F({accounts:[],provider:e}))}}}catch{}},[m,pe,P,E,re]),(0,a.useEffect)(()=>{var e;if(null===d||void 0===d||!d.ad_platform)return;const s=localStorage.getItem("platformStates"),t=s?JSON.parse(s):{...g},a="importing"===(null===(e=t[d.ad_platform])||void 0===e?void 0:e.status),n=!d.is_importing,i={...t,[d.ad_platform]:{...t[d.ad_platform],status:d.is_importing?"importing":"imported",status_text:d.status_text||"Importing...",progress:d.progress||0,...d.is_importing?{}:{last_checked_at:d.import_end_date_time||(new Date).toISOString()}}};if(localStorage.setItem("platformStates",JSON.stringify(i)),j(i),a&&n){const e=new Date,s=e=>e.toISOString().split("T")[0],t=(null===v||void 0===v?void 0:v.startDate)||s(new Date(e.getTime()-2592e6)),a=(null===v||void 0===v?void 0:v.endDate)||s(e);c((0,q.fetchAdsManagerData)({startDate:t,endDate:a,forceInitial:!0}))}},[d,c,v]),(0,a.useEffect)(()=>{(async()=>{try{const e=await(0,K.e)();if(null!==e&&void 0!==e&&e.platformStates)return j(e.platformStates),localStorage.setItem("platformStates",JSON.stringify(e.platformStates)),void oe(!0)}catch{}const e=(0,G.nX)();j(e),localStorage.setItem("platformStates",JSON.stringify(e)),oe(!0)})()},[]),(0,a.useEffect)(()=>{const e=()=>{j(e=>{const s={...e};return Object.keys(s).forEach(e=>{"connecting"===s[e].status&&(s[e]={...s[e],status:"initial"})}),s})},s={};return Object.keys(g).forEach(e=>{"connecting"===g[e].status&&(s[e]=setTimeout(()=>{j(s=>({...s,[e]:{...s[e],status:"initial"}}))},8e3))}),window.addEventListener("popstate",e),()=>{window.removeEventListener("popstate",e),Object.values(s).forEach(e=>clearTimeout(e))}},[g]);const fe=(0,a.useMemo)(()=>(0,G.$U)(g),[g]),ge=(0,b.A)("platform_connections",fe.length),be=e=>{var s;if((0,G.Qu)({platformStates:g,platform:e,limit:ge.limit}))return void(0,C.dX)({reason:"platform_connection_limit",limit:ge.limit});const t="pinterest_ads"===e?null===(s=g[e])||void 0===s?void 0:s.cooldown_until:null;if(t&&new Date(t).getTime()>Date.now())return void(0,N.UW)("Pinterest rate limit hit. Please wait about 15 minutes and try again.",{detail:null,modalTitle:"Pinterest rate limit",platformName:"Pinterest Ads",showMoreLink:!1});j(s=>({...s,[e]:{...s[e],status:"connecting"}}));(x?(0,y.qQ)(`${U.eN}/${e}/enable/`):O.A.get(`${U.eN}/${e}/login/`)).then(s=>{const{authorization_url:t}=s.data;t?window.location.href=t:((0,N.UW)(`Failed to initiate authentication for ${e}`),j(s=>({...s,[e]:{...s[e],status:"initial"}})))}).catch(s=>{(0,N.UW)(`Authentication error: ${s.message}`),j(s=>({...s,[e]:{...s[e],status:"initial"}}))})},je=e=>{j(s=>({...s,[e]:{...s[e],status:"initial"}}))},ye=null===h||void 0===h?void 0:h.access_context,Ne=Boolean((null===ye||void 0===ye?void 0:ye.actor_is_staff)||(null===ye||void 0===ye||null===(s=ye.actor_feature_flags)||void 0===s?void 0:s.is_dev_user)),[_e,we]=(0,a.useState)(null),ke=e=>{we(e),(0,y.Ku)(`${U.eN}/ad_accounts/reimport/`,{ad_platform:e}).then(s=>{var t;s.status>=200&&s.status<300?(0,N.LG)(`Import started for ${e.replace("_ads","")}.`):(0,N.UW)((null===s||void 0===s||null===(t=s.data)||void 0===t?void 0:t.error)||"Could not start the import.")}).catch(e=>{var s,t;(0,N.UW)((null===e||void 0===e||null===(s=e.response)||void 0===s||null===(t=s.data)||void 0===t?void 0:t.error)||"Could not start the import.")}).finally(()=>we(null))},Se=e=>{X(e),I(!0)},Ce=()=>{var e;if(Y&&"connected"===(null===(e=g[Y])||void 0===e?void 0:e.status)&&j(e=>({...e,[Y]:{...e[Y],status:"initial"}})),L(!0),z(!1),ne(""),de([]),ue.current){const e=ue.current;ue.current=null,o(e,{replace:!0})}},Ae=ee.some(e=>(0,G.r7)(g,e)),Pe=[...ee].sort((e,s)=>Q.zI[e].localeCompare(Q.zI[s])),ze=Pe.filter(e=>(0,G.r7)(g,e)),Te=Pe.filter(e=>!(0,G.r7)(g,e));return(0,D.jsxs)(D.Fragment,{children:[ie&&(0,D.jsx)("div",{className:"d-flex justify-content-center align-items-center",style:{position:"fixed",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(0,0,0,0.9)",zIndex:9999},children:(0,D.jsx)(A.A,{animation:"border",variant:"primary"})}),Ae?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"d-flex align-items-center justify-content-between mb-3 flex-wrap gap-2",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"fw-semibold",style:{fontSize:"1rem"},children:"Connected Platforms"}),(0,D.jsxs)("div",{className:"small "+(t?"text-white-50":"text-muted"),children:[ze.length," of ",ee.length," platforms connected"]})]}),(0,D.jsxs)(f.A,{variant:"primary",onClick:()=>M(!0),disabled:0===Te.length,children:[(0,D.jsx)("i",{className:"feather icon-plus me-1"}),"Connect Ad Account"]})]}),(0,D.jsx)("div",{style:se,children:ze.map(e=>(0,D.jsx)(Q.Ay,{platform:e,platformState:g[e],onEnable:be,onDisable:Se,onResetConnecting:je,onReimport:Ne?ke:null,isReimporting:_e===e,isDarkMode:t},e))})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(te,{isDarkMode:t}),(0,D.jsx)("div",{style:se,children:Pe.map(e=>(0,D.jsx)(Q.Ay,{platform:e,platformState:g[e],onEnable:be,onDisable:Se,onResetConnecting:je,onReimport:Ne?ke:null,isReimporting:_e===e,isDarkMode:t},e))})]}),(0,D.jsx)(Z,{show:R,onHide:()=>M(!1),platforms:Te,platformStates:g,onConnect:be,isDarkMode:t}),(0,D.jsx)(p.A,{show:P,onHide:Ce,centered:!0,scrollable:!0,"data-bs-theme":t?"dark":"light",children:_.length>0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(p.A.Header,{closeButton:!0,children:(0,D.jsxs)(p.A.Title,{className:"d-flex align-items-center gap-2",children:[(0,D.jsx)("span",{style:{fontSize:"1.5rem",lineHeight:1},children:Q.aQ[Y]}),(0,D.jsx)("i",{className:"fas fa-arrow-right",style:{opacity:.4}}),(0,D.jsxs)("span",{children:["Connect ",Q.zI[Y]," Account"]})]})}),(0,D.jsxs)(p.A.Body,{children:[(0,D.jsx)("div",{className:"d-flex flex-column gap-2",children:(()=>{const e=e=>{var s;return null!==(s=e.is_manager)&&void 0!==s?s:"manager"===e.account_type},s=(e,s)=>(e.account_name||"").localeCompare(s.account_name||"",void 0,{sensitivity:"base",numeric:!0})||String(e.account_number||"").localeCompare(String(s.account_number||"")),t=_.filter(s=>!e(s)).sort(s),a=_.filter(e).sort(s),n={flexShrink:0,opacity:.7,width:18,textAlign:"center"},i=s=>{var t;const a=e(s),i=(null!==(t=s.selectable)&&void 0!==t?t:!a)&&J===s.account_id,l=(s.status||"").toUpperCase();let r=null;s.is_test?r="Test account":l&&"ENABLED"!==l&&(r="CLOSED"===l?"Closed":s.status);const o=[a?"Manager account \xb7 can't hold campaigns":null,r].filter(
1Boolean).join(" \xb7 ");return a?(0,D.jsxs)("div",{className:"d-flex align-items-center text-start w-100 px-3 py-2 text-muted",style:{border:"1px solid transparent",opacity:.85},title:"Campaigns can't run in a manager account \u2014 connect one of its ad accounts instead",children:[(0,D.jsx)("span",{style:{width:20,flexShrink:0}}),(0,D.jsx)("i",{className:"feather icon-folder me-2",style:n}),(0,D.jsxs)("div",{className:"d-flex flex-column",style:{minWidth:0,flex:1},children:[(0,D.jsx)("span",{className:"fw-medium",children:s.account_name||"Manager account"}),(0,D.jsx)("span",{className:"small",children:o})]}),(0,D.jsx)("div",{className:"ms-3",style:{whiteSpace:"nowrap"},children:s.account_number||""})]},s.account_id):(0,D.jsxs)(f.A,{variant:i?"primary":"outline-secondary",className:"d-flex align-items-center text-start w-100 px-3 py-3",style:{borderRadius:12},onClick:()=>ne(s.account_id),children:[(0,D.jsx)("span",{className:"d-flex align-items-center justify-content-center",style:{width:20,flexShrink:0},children:i&&(0,D.jsx)("i",{className:"feather icon-check","aria-label":"Selected"})}),(0,D.jsx)("i",{className:"feather icon-credit-card me-2",style:n}),(0,D.jsxs)("div",{className:"d-flex flex-column",style:{minWidth:0,flex:1},children:[(0,D.jsx)("span",{className:"fw-medium",style:i?{color:"#fff"}:void 0,children:s.account_name||"Ad account"}),o&&(0,D.jsx)("span",{className:"small"+(i?"":" text-muted"),children:o})]}),(0,D.jsx)("div",{className:"ms-3"+(i?"":" text-muted"),style:{whiteSpace:"nowrap"},children:s.account_number||""})]},s.account_id)};return(0,D.jsxs)(D.Fragment,{children:[t.map(i),a.length>0&&(0,D.jsx)("div",{className:"small text-muted text-uppercase px-3 mt-2",style:{letterSpacing:"0.04em"},children:"Manager accounts"}),a.map(i)]})})()}),k.length>0&&(()=>{const e=new Map;return k.forEach(s=>{const t=ae[null===(a=s)||void 0===a?void 0:a.error_code]||(null!==a&&void 0!==a&&a.error_code?`it couldn't be read (${a.error_code})`:"it couldn't be read");var a;e.has(t)||e.set(t,[]),s.customer_id&&e.get(t).push(s.customer_id)}),(0,D.jsxs)("div",{className:"alert alert-warning mt-3 mb-0 small",role:"alert",children:[(0,D.jsxs)("div",{className:"fw-medium mb-1",children:[1===k.length?"1 account couldn't be listed":`${k.length} accounts couldn't be listed`," ","\u2014 any ad accounts beneath them are missing from this list."]}),(0,D.jsx)("ul",{className:"mb-0 ps-3",children:[...e.entries()].map(e=>{let[s,t]=e;return(0,D.jsxs)("li",{children:[t.length>0&&(0,D.jsxs)(D.Fragment,{children:[t.join(", "),": "]}),s]},s)})})]})})()]}),(0,D.jsxs)(p.A.Footer,{className:"d-flex align-items-center gap-2",children:[(0,D.jsx)(f.A,{variant:"secondary",onClick:Ce,children:"Close"}),(0,D.jsx)("div",{className:"ms-auto",children:(0,D.jsx)(f.A,{variant:"success",onClick:()=>{var e;const s=me.current[J],t=_.find(e=>e.account_id===J),a=Y||(null===t||void 0===t?void 0:t.ad_platform)||(null===t||void 0===t?void 0:t.adPlatform)||(null===(e=_.find(e=>e.ad_platform||e.adPlatform))||void 0===e?void 0:e.ad_platform)||(null===h||void 0===h?void 0:h.provider)||"";a?J&&s?(0,y.Ku)(`${U.eN}/ad_accounts/`,{account_id:J,account_name:s,ad_platform:a,organization_name:(null===t||void 0===t?void 0:t.organization_name)||null,currency:(null===t||void 0===t?void 0:t.currency_code)||(null===t||void 0===t?void 0:t.currency)||null}).then(e=>{var n,i,l,r,o,c,d;L(!0),z(!1),(0,V.ZM)(`adacct:${a}:${J}`,"ad_account_connected",{platform:a});const m=(null===(n=e.data)||void 0===n?void 0:n.account)||{},h={has_payment_method:null!==(i=null!==(l=null===m||void 0===m?void 0:m.has_payment_method)&&void 0!==l?l:null===t||void 0===t?void 0:t.has_payment_method)&&void 0!==i&&i,is_prepay_account:null!==(r=null!==(o=null===m||void 0===m?void 0:m.is_prepay_account)&&void 0!==o?o:null===t||void 0===t?void 0:t.is_prepay_account)&&void 0!==r&&r,has_prepay_credit:null!==(c=null!==(d=null===m||void 0===m?void 0:m.has_prepay_credit)&&void 0!==d?d:null===t||void 0===t?void 0:t.has_prepay_credit)&&void 0!==c&&c};j(e=>{const n={...e,[a]:{status:"importing",account_name:s,organization_name:m.organization_name||(null===t||void 0===t?void 0:t.organization_name)||"",currency:m.currency||(null===t||void 0===t?void 0:t.currency_code)||(null===t||void 0===t?void 0:t.currency)||"",progress:0,status_text:"Importing...",...h}};try{localStorage.setItem("platformStates",JSON.stringify(n))}catch{}return n})}).catch(e=>{null!==e&&void 0!==e&&e.isPlanLimit||null!==e&&void 0!==e&&e.isTrialPaywall||(0,N.UW)(`Error starting account import: ${e.message}`)}).finally(()=>{const e=ue.current||"";ue.current=null;o(e,{replace:!0,...(e?{state:{platformConnect:a}}:void 0)||{}})}):(0,N.UW)("Error: Account selection is incomplete"):(0,N.UW)("Error: Platform not selected. Please close and reopen the modal.")},disabled:!J,children:"Authorize"})})]})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(p.A.Header,{children:(0,D.jsxs)(p.A.Title,{className:"d-flex align-items-center gap-2",children:[(0,D.jsx)("span",{className:"d-inline-flex align-items-center justify-content-center",style:{width:40,height:40,borderRadius:"50%",background:t?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.04)",fontSize:"1.2rem"},children:Q.aQ[Y]}),(0,D.jsx)("span",{children:ce.length>0?"Permissions Required":"No Advertising Access"})]})}),(0,D.jsx)(p.A.Body,{children:ce.length>0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("p",{children:["You're signed in, but you didn't grant ",Q.zI[Y]," ","the permissions we need to manage ad accounts."]}),(0,D.jsxs)("p",{children:["On the next screen, please ",(0,D.jsx)("strong",{children:"check every box"})," on the"," ",Q.zI[Y]," consent page so we can read your advertising accounts. If you don't have an advertising account yet, you can register for one instead."]})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("p",{children:["Your ",Q.zI[Y]," login doesn't have access to any advertising accounts."]}),(0,D.jsxs)("p",{children:["If you meant to manage ads, make sure you checked every box on the"," ",Q.zI[Y]," consent page and try connecting again. Otherwise, register for an account or contact your business administrator:"]})]})}),(0,D.jsxs)(p.A.Footer,{className:"d-flex align-items-center gap-2",children:[ce.length>0?(0,D.jsx)(f.A,{variant:"primary",onClick:()=>{z(!1),de([]),be(Y)},children:"Reconnect & grant permissions"}):(0,D.jsxs)(f.A,{variant:"primary",href:Q.pu[Y],target:"_blank",rel:"noopener noreferrer",children:["Register for ",Q.zI[Y]]}),(0,D.jsx)("div",{className:"ms-auto",children:(0,D.jsx)(f.A,{variant:"secondary",onClick:Ce,children:"Close"})})]})]})}),(0,D.jsxs)(p.A,{show:$,onHide:()=>I(!1),centered:!0,"data-bs-theme":t?"dark":"light",children:[(0,D.jsx)(p.A.Header,{closeButton:!0,children:(0,D.jsxs)(p.A.Title,{className:"d-flex align-items-center gap-2",children:[(0,D.jsx)("i",{className:"feather icon-alert-triangle text-warning"}),"Disconnect ",Q.zI[Y]]})}),(0,D.jsxs)(p.A.Body,{children:[(0,D.jsxs)("p",{className:"d-flex align-items-center gap-2 mb-2",children:["Are you sure you want to disconnect",(0,D.jsx)("span",{style:{fontSize:"1.1rem",lineHeight:1},children:Q.aQ[Y]}),(0,D.jsx)("strong",{children:Q.zI[Y]}),"?"]}),(0,D.jsx)("p",{className:t?"text-white-50":"text-muted",children:"Your historical data will be retained. You can reconnect at any time."})]}),(0,D.jsxs)(p.A.Footer,{className:"gap-2",children:[(0,D.jsx)(f.A,{variant:"secondary",onClick:()=>I(!1),children:"Cancel"}),(0,D.jsx)(f.A,{variant:"danger",onClick:()=>{(0,y.tX)(`${U.eN}/${Y}/disable/`).then(e=>{if(e.status>=200&&e.status<300){c((0,q.resetAdsManagerData)());const e=new Date,s=e=>e.toISOString().split("T")[0],t=(null===v||void 0===v?void 0:v.startDate)||s(new Date(e.getTime()-2592e6)),a=(null===v||void 0===v?void 0:v.endDate)||s(e);j(e=>({...e,[Y]:(0,G.KD)()}));const n=Date.now();localStorage.setItem("homeDashboardForceRefreshAt",String(n)),window.dispatchEvent(new CustomEvent("homeDashboard:forceRefresh",{detail:{at:n,reason:"platform_deactivated",platform:Y}})),I(!1),(0,N.LG)(`${Q.zI[Y]} has been disabled successfully.`),c((0,q.fetchAdsManagerData)({startDate:t,endDate:a,forceInitial:!0}))}else(0,N.UW)(`Error disabling ${Q.zI[Y]}. Please try again.`)}
1).catch(e=>{(0,N.UW)(`Error disabling ${Q.zI[Y]}: ${e.message}`)})},children:"Disconnect"})]})]})]})};var ie=t(5216),le=t(86781),re=t(68459),oe=(t(21090),t(66187));const ce=function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"USD";const t=parseFloat(e);return Number.isNaN(t)?"\u2014":new Intl.NumberFormat(void 0,{style:"currency",currency:s,maximumFractionDigits:t>=1e3?0:2}).format(t)},de=e=>{let{label:s,value:t,sub:a,isDarkMode:n}=e;return(0,D.jsx)(ie.A,{className:"h-100 shadow-sm "+(n?"bg-dark border-secondary":""),children:(0,D.jsxs)(ie.A.Body,{className:"py-3",children:[(0,D.jsx)("div",{className:"small mb-1 "+(n?"text-white-50":"text-muted"),children:s}),(0,D.jsx)("div",{className:"fs-4 fw-bold "+(n?"text-white":""),children:t}),a&&(0,D.jsx)("div",{className:"small "+(n?"text-white-50":"text-muted"),children:a})]})})},me={shopify:{label:"Shopify",icon:"feather icon-shopping-bag",logo:T,color:"#96bf48",tab:"shopify"},woocommerce:{label:"WooCommerce",icon:"feather icon-shopping-cart",logo:E,color:"#7952b3",tab:"woocommerce"},wix:{label:"Wix",icon:"feather icon-layout",logo:L,color:"#0c6efc",tab:"wix"}},he=e=>{let{meta:s,count:t,connected:a,loading:n,busy:i,onNavigate:l,onConnect:r,isDarkMode:o}=e;return(0,D.jsx)(ie.A,{className:"h-100 shadow-sm "+(o?"bg-dark border-secondary":""),children:(0,D.jsxs)(ie.A.Body,{className:"d-flex flex-column",children:[(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2 mb-3",children:[(0,D.jsx)("div",{className:"d-flex align-items-center justify-content-center rounded",style:{width:40,height:40,background:`${s.color}22`,flexShrink:0},children:s.logo?(0,D.jsx)("img",{src:s.logo,alt:s.label,style:{width:32,height:32,objectFit:"contain"}}):(0,D.jsx)("i",{className:s.icon,style:{fontSize:"1.25rem",color:s.color}})}),(0,D.jsxs)("div",{className:"flex-grow-1 min-w-0",children:[(0,D.jsx)("div",{className:"fw-semibold "+(o?"text-white":""),children:s.label}),n?(0,D.jsx)(A.A,{animation:"border",size:"sm",className:"mt-1"}):(0,D.jsx)("div",{className:"small",children:a?(0,D.jsxs)("span",{className:"text-success",children:[(0,D.jsx)("i",{className:"feather icon-check-circle me-1"}),null!=t?`${t} connected`:"Connected"]}):(0,D.jsx)("span",{className:o?"text-white-50":"text-muted",children:"Not connected"})})]})]}),(0,D.jsx)("div",{className:"mt-auto",children:(0,D.jsxs)(f.A,{variant:a?"outline-primary":"outline-secondary",size:"sm",className:"w-100",disabled:i,onClick:()=>a?l(s.tab):r(s.tab),children:[i&&(0,D.jsx)(A.A,{animation:"border",size:"sm",className:"me-2"}),a?`Manage ${s.label}`:`Connect ${s.label}`]})})]})})},ue=e=>{let{connections:s,onNavigate:t,isDarkMode:a}=e;return(0,D.jsxs)(ie.A,{className:"shadow-sm mb-4 "+(a?"bg-dark border-secondary":""),children:[(0,D.jsx)(ie.A.Header,{className:"fw-semibold small "+(a?"bg-transparent border-secondary text-white":""),children:"Connected stores"}),(0,D.jsx)(ie.A.Body,{className:"p-0",children:s.map((e,s)=>{const n=me[e.provider];return n?(0,D.jsxs)("div",{className:`d-flex align-items-center gap-3 px-3 py-2 ${s>0?"border-top":""} ${a?"border-secondary":""}`,children:[(0,D.jsx)("div",{className:"d-flex align-items-center justify-content-center rounded flex-shrink-0",style:{width:32,height:32,background:`${n.color}22`},children:n.logo?(0,D.jsx)("img",{src:n.logo,alt:n.label,style:{width:24,height:24,objectFit:"contain"}}):(0,D.jsx)("i",{className:n.icon,style:{color:n.color}})}),(0,D.jsxs)("div",{className:"flex-grow-1 min-w-0",children:[(0,D.jsx)("div",{className:"small fw-semibold text-truncate "+(a?"text-white":""),children:(i=e.store_url,String(i||"").replace(/^https?:\/\//i,"").replace(/\/+$/,"")||n.label)}),(0,D.jsx)("div",{className:"small "+(a?"text-white-50":"text-muted"),children:n.label})]}),(0,D.jsx)(f.A,{variant:"outline-primary",size:"sm",className:"flex-shrink-0",onClick:()=>t(n.tab),children:"Manage"})]},e.id):null;var i})})]})},xe=e=>{var s,t,n,i,l,r,o,c,d,m,h,u,x;let{onTabChange:p,onConnect:f,connections:g=[],connectionsLoading:b=!1,isDarkMode:j=!1}=e;const[y,N]=(0,a.useState)(null),[_,S]=(0,a.useState)(!1),[C,P]=(0,a.useState)(null),[T,F]=(0,a.useState)(!1),[E,L]=(0,a.useState)(30),$=(0,a.useMemo)(()=>g.filter(k),[g]),I=(0,a.useMemo)(()=>{const e={shopify:0,woocommerce:0,wix:0};return $.forEach(s=>
1{null!=e[s.provider]&&(e[s.provider]+=1)}),Object.fromEntries(Object.entries(e).map(e=>{let[s,t]=e;return[s,{count:t,connected:t>0}]}))},[$]),R=Object.values(I).filter(e=>null===e||void 0===e?void 0:e.connected).length;(0,a.useEffect)(()=>{if(!R)return void P(null);let e=!1;return F(!0),w.xo.getOverview({days:E}).then(s=>{var t;e||P(null!==(t=null===s||void 0===s?void 0:s.data)&&void 0!==t?t:null)}).catch(()=>{e||P(null)}).finally(()=>{e||F(!1)}),()=>{e=!0}},[E,R]);const M=(0,a.useCallback)(e=>{N(null),"wix"===e?(S(!0),(0,z.ai)().catch(e=>{N(e.message||"Failed to start Wix OAuth"),S(!1)})):f(e)},[f]),B=null!==(s=null===C||void 0===C||null===(t=C.currencies)||void 0===t?void 0:t[0])&&void 0!==s?s:null,W=Boolean(B),O=j?"#6d80f5":"#4f46e5",U=j?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.06)",H=j?"rgba(255,255,255,0.55)":"rgba(0,0,0,0.55)",K={labels:(null!==(n=null===C||void 0===C?void 0:C.trend)&&void 0!==n?n:[]).map(e=>e.date),datasets:[{label:`Net revenue (${(null===C||void 0===C?void 0:C.dominant_currency)||"USD"})`,data:(null!==(i=null===C||void 0===C?void 0:C.trend)&&void 0!==i?i:[]).map(e=>parseFloat(e.revenue)-parseFloat(e.refunded)),borderColor:O,backgroundColor:`${O}22`,borderWidth:2,pointRadius:0,pointHoverRadius:4,pointHoverBackgroundColor:O,fill:!0,tension:.3}]},q={responsive:!0,maintainAspectRatio:!1,interaction:{mode:"index",intersect:!1},plugins:{legend:{display:!1},tooltip:{callbacks:{label:e=>` ${ce(e.parsed.y,(null===C||void 0===C?void 0:C.dominant_currency)||"USD")}`}}},scales:{x:{grid:{display:!1},ticks:{color:H,maxTicksLimit:8,font:{size:11}}},y:{grid:{color:U},border:{display:!1},ticks:{color:H,font:{size:11},callback:e=>ce(e,(null===C||void 0===C?void 0:C.dominant_currency)||"USD")}}}};return(0,D.jsxs)("div",{className:"p-3",children:[(0,D.jsxs)("div",{className:"d-flex flex-wrap align-items-start justify-content-between gap-2 mb-4",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h5",{className:"mb-1 fw-bold "+(j?"text-white":""),children:"E-Commerce Partners"}),(0,D.jsx)("p",{className:"small mb-0 "+(j?"text-white-50":"text-muted"),children:"Connect your store to capture purchase events, attribute them to ad clicks, and measure real ROAS."})]}),R>0&&(0,D.jsxs)(v.A.Select,{size:"sm",value:E,onChange:e=>L(Number(e.target.value)),style:{width:"auto"},children:[(0,D.jsx)("option",{value:7,children:"Last 7 days"}),(0,D.jsx)("option",{value:30,children:"Last 30 days"}),(0,D.jsx)("option",{value:90,children:"Last 90 days"})]})]}),y&&(0,D.jsx)("div",{className:"alert alert-warning small py-2",children:y}),R>0&&(0,D.jsxs)(D.Fragment,{children:[T&&!C&&(0,D.jsx)("div",{className:"text-center py-4",children:(0,D.jsx)(A.A,{animation:"border",size:"sm"})}),W&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(le.A,{xs:2,md:3,lg:6,className:"g-3 mb-3",children:[(0,D.jsx)(re.A,{children:(0,D.jsx)(de,{label:"Net revenue",value:ce(B.net_revenue,B.currency),sub:`${ce(B.gross_revenue,B.currency)} gross`,isDarkMode:j})}),(0,D.jsx)(re.A,{children:(0,D.jsx)(de,{label:"Orders",value:B.orders.toLocaleString(),sub:`${B.refunds} refund${1===B.refunds?"":"s"}`,isDarkMode:j})}),(0,D.jsx)(re.A,{children:(0,D.jsx)(de,{label:"Avg order value",value:ce(B.aov,B.currency),isDarkMode:j})}),(0,D.jsx)(re.A,{children:(0,D.jsx)(de,{label:"Refund rate",value:`${(100*B.refund_rate).toFixed(1)}%`,isDarkMode:j})}),(0,D.jsx)(re.A,{children:(0,D.jsx)(de,{label:"Attribution rate",value:`${(100*(null!==(l=null===C||void 0===C?void 0:C.attribution_rate)&&void 0!==l?l:0)).toFixed(0)}%`,sub:`${null!==(r=null===C||void 0===C?void 0:C.attributed_purchases)&&void 0!==r?r:0} of ${null!==(o=null===C||void 0===C?void 0:C.total_purchases)&&void 0!==o?o:0} orders matched to ads`,isDarkMode:j})}),(0,D.jsx)(re.A,{children:(0,D.jsx)(de,{label:"Cart abandonment",value:`${(100*(null!==(c=null===C||void 0===C?void 0:C.abandonment_rate)&&void 0!==c?c:0)).toFixed(0)}%`,sub:(null!==(d=null===C||void 0===C?void 0:C.abandoned_checkouts)&&void 0!==d?d:0)>0?`${ce(C.recoverable_value,B.currency)} left in ${C.abandoned_checkouts} cart${1===C.abandoned_checkouts?"":"s"}`:"No abandoned carts",isDarkMode:j})})]}),(null!==(m=null===C||void 0===C||null===(h=C.currencies)||void 0===h?void 0:h.length)&&void 0!==m?m:0)>1&&(0,D.jsxs)("div",{className:"small mb-3 "+(j?"text-white-50":"text-muted"),children:[(0,D.jsx)("i",{className:"feather icon-info me-1"}),"Totals shown in ",B.currency,". Also received:"," ",C.currencies.slice(1).map(e=>`${ce(e.gross_revenue,e.currency)} (${e.currency})`).join(", "),". Currencies are never summed together."]}),(null!==(u=null===C||void 0===C||null===(x=C.trend)||void 0===x?void 0:x.length)&&void 0!==u?u:0)>1&&(0,D.jsxs)(ie.A,{className:"shadow-sm mb-4 "+(j?"bg-dark border-secondary":""),children:[(0,D.jsxs)(ie.A.Header,{className:"fw-semibold small "+(j?"bg-transparent border-secondary text-white":""),children:["Daily net revenue (",null===C||void 0===C?void 0:C.dominant_currency,")"]}),(0,D.jsx)(ie.A.Body,{children:(0,D.jsx)("div",{style:{height:220},children:(0,D.jsx)(oe.Line,{data:K,options:q})})})]})]}),!T&&!W&&(0,D.jsx)("div",{className:"small mb-4 "+(j?"text-white-50":"text-muted"),children:"No orders received yet in this period \u2014 stats will appear when your store sends its first events."})]}),!b&&R>0&&(0,D.jsxs)("div",{className:"rounded-3 p-3 mb-4 d-flex align-items-center gap-3 bg-success bg-opacity-10",children:[(0,D.jsx)("i",{className:"feather icon-check-circle text-success",style:{fontSize:"1.4rem",flexShrink:0}}),(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"fw-semibold "+(j?"text-white":""),children:[R," platform",1!==R?"s":""," connected"]}),(0,D.jsx)("div",{className:"small text-success",children:"Purchase events are being captured and matched to ad clicks."})]})]}
1),!b&&0===R&&(0,D.jsx)(le.A,{xs:1,md:3,className:"g-3 mb-4",children:Object.entries(me).map(e=>{var s,t,a,n;let[i,l]=e;return(0,D.jsx)(re.A,{children:(0,D.jsx)(he,{meta:l,count:null!==(s=null===(t=I[i])||void 0===t?void 0:t.count)&&void 0!==s?s:null,connected:null!==(a=null===(n=I[i])||void 0===n?void 0:n.connected)&&void 0!==a&&a,loading:b,busy:"wix"===i&&_,onNavigate:p,onConnect:M,isDarkMode:j})},i)})}),!b&&R>0&&(0,D.jsx)(ue,{connections:$,onNavigate:p,isDarkMode:j}),(0,D.jsx)(ie.A,{className:"shadow-sm "+(j?"bg-dark border-secondary":""),children:(0,D.jsxs)(ie.A.Body,{children:[(0,D.jsx)("h6",{className:"fw-semibold mb-3 "+(j?"text-white":""),children:"How attribution works"}),(0,D.jsx)("div",{className:"d-flex flex-column gap-3",children:[{icon:"feather icon-mouse-pointer",color:"#d55500",title:"Ad click captured",body:"When someone clicks your ad, LinkClicks records the click with session and IP data."},{icon:"feather icon-shopping-cart",color:"#96bf48",title:"Purchase event received",body:"When your connected store fires a purchase webhook, the order is normalised and stored."},{icon:"feather icon-link",color:"#0c6efc",title:"Attribution matched",body:"Orders are matched back to ad clicks by session ID or IP within your attribution window."}].map((e,s)=>(0,D.jsxs)("div",{className:"d-flex gap-3",children:[(0,D.jsx)("div",{className:"d-flex align-items-center justify-content-center rounded-circle flex-shrink-0",style:{width:36,height:36,background:`${e.color}22`},children:(0,D.jsx)("i",{className:e.icon,style:{color:e.color,fontSize:"0.9rem"}})}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"fw-semibold small "+(j?"text-white":""),children:e.title}),(0,D.jsx)("div",{className:"small "+(j?"text-white-50":"text-muted"),children:e.body})]})]},s))})]})})]})};var pe=t(4342);function ve(e){let{pageSize:s=25,auto:t=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const[n,i]=(0,a.useState)([]),[l,r]=(0,a.useState)(0),[o,c]=(0,a.useState)(1),[d,m]=(0,a.useState)(Boolean(t)),[h,u]=(0,a.useState)(null),x=(0,a.useRef)(0),p=(0,a.useCallback)(t=>{const a=++x.current;return m(!0),u(null),e(t,s).then(e=>{var s;if(a!==x.current)return;const n=null!==(s=null===e||void 0===e?void 0:e.data)&&void 0!==s?s:{};i(Array.isArray(n.results)?n.results:[]),r(Number.isFinite(n.count)?n.count:0),c(n.page||t)}).catch(e=>{a===x.current&&(u(e),i([]),r(0))}).finally(()=>{a===x.current&&m(!1)})},[e,s]);(0,a.useEffect)(()=>{t&&p(1)},[p,t]);const v=Math.max(1,Math.ceil(l/s));return{results:n,count:l,page:o,pageSize:s,totalPages:v,loading:d,error:h,hasNext:o<v,hasPrev:o>1,next:()=>o<v&&p(o+1),prev:()=>o>1&&p(o-1),goTo:e=>p(Math.min(Math.max(1,e),v)),reload:()=>p(o)}}const fe=function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"USD";const t=parseFloat(e);return Number.isNaN(t)?"\u2014":new Intl.NumberFormat(void 0,{style:"currency",currency:s}).format(t)},ge=e=>{if(!e)return"\u2014";try{return new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}catch{return e}},be=[{value:"total_revenue",label:"Lifetime value"},{value:"order_count",label:"Order count"},{value:"last_seen",label:"Most recent"},{value:"first_seen",label:"Newest customer"}],je=e=>{let{isDarkMode:s=!1}=e;const[t,n]=(0,a.useState)("total_revenue"),[i,l]=(0,a.useState)({repeatCustomers:0,repeatRate:0}),r=ve((0,a.useCallback)((e,s)=>w.xo.getCustomers({page:e,pageSize:s,sort:t}).then(e=>{var s,t,a;const n=null!==(s=null===e||void 0===e?void 0:e.data)&&void 0!==s?s:{};return l({repeatCustomers:null!==(t=n.repeat_customers)&&void 0!==t?t:0,repeatRate:null!==(a=n.repeat_rate)&&void 0!==a?a:0}),e}),[t]),{pageSize:25});return(0,D.jsxs)("div",{className:"p-3",children:[(0,D.jsxs)("div",{className:"d-flex flex-wrap align-items-start justify-content-between gap-2 mb-4",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h5",{className:"mb-1 fw-bold "+(s?"text-white":""),children:"Customers"}),(0,D.jsx)("p",{className:"small mb-0 "+(s?"text-white-50":"text-muted"),children:"Lifetime value and repeat-purchase behaviour across every connected store."})]}),(0,D.jsx)(v.A.Select,{size:"sm",value:t,onChange:e=>n(e.target.value),style:{width:"auto"},children:be.map(e=>(0,D.jsxs)("option",{value:e.value,children:["Sort: ",e.label]},e.value))})]}),r.count>0&&(0,D.jsxs)("div",{className:"small mb-3 "+(s?"text-white-50":"text-muted"),children:[r.count.toLocaleStr
1ing()," customers \xb7 ",i.repeatCustomers.toLocaleString()," repeat (",(100*i.repeatRate).toFixed(0),"% repeat rate)"]}),(0,D.jsx)(ie.A,{className:"shadow-sm "+(s?"bg-dark border-secondary":""),children:(0,D.jsxs)(ie.A.Body,{className:"p-0",children:[r.loading&&!r.results.length&&(0,D.jsx)("div",{className:"text-center py-5",children:(0,D.jsx)(A.A,{animation:"border",size:"sm"})}),!r.loading&&!r.results.length&&(0,D.jsxs)("div",{className:"text-center py-5 "+(s?"text-white-50":"text-muted"),children:[(0,D.jsx)("i",{className:"feather icon-users mb-3",style:{fontSize:"2rem",display:"block"}}),(0,D.jsx)("div",{className:"small",style:{maxWidth:420,margin:"0 auto"},children:"No customers yet. Customer profiles are built automatically as orders from your connected stores are matched to ad clicks."})]}),r.results.length>0&&(0,D.jsx)("div",{className:"table-responsive",children:(0,D.jsxs)("table",{className:"table table-sm mb-0 "+(s?"table-dark":""),children:[(0,D.jsx)("thead",{children:(0,D.jsxs)("tr",{className:s?"text-white-50":"text-muted",style:{fontSize:"0.75rem"},children:[(0,D.jsx)("th",{className:"fw-medium",children:"Customer"}),(0,D.jsx)("th",{className:"fw-medium text-end",children:"Orders"}),(0,D.jsx)("th",{className:"fw-medium text-end",children:"Lifetime value"}),(0,D.jsx)("th",{className:"fw-medium",children:"First order"}),(0,D.jsx)("th",{className:"fw-medium",children:"Latest order"})]})}),(0,D.jsx)("tbody",{style:{fontSize:"0.8rem"},children:r.results.map(e=>(0,D.jsxs)("tr",{children:[(0,D.jsxs)("td",{children:[(0,D.jsx)("span",{className:s?"text-white":"",children:e.label}),e.is_repeat&&(0,D.jsx)(pe.A,{bg:"info",className:"bg-opacity-75 ms-2",children:"Repeat"})]}),(0,D.jsx)("td",{className:"text-end",children:e.order_count}),(0,D.jsx)("td",{className:"text-end fw-semibold",children:fe(e.total_revenue,e.currency)}),(0,D.jsx)("td",{className:s?"text-white-50":"text-muted",children:ge(e.first_seen_at)}),(0,D.jsx)("td",{className:s?"text-white-50":"text-muted",children:ge(e.last_seen_at)})]},e.id))})]})}),r.totalPages>1&&(0,D.jsxs)("div",{className:"d-flex align-items-center justify-content-between px-3 py-2 border-top "+(s?"border-secondary":""),children:[(0,D.jsxs)("span",{className:"small "+(s?"text-white-50":"text-muted"),children:["Page ",r.page," of ",r.totalPages]}),(0,D.jsxs)("div",{className:"d-flex gap-2",children:[(0,D.jsxs)(f.A,{variant:s?"outline-light":"outline-secondary",size:"sm",disabled:!r.hasPrev||r.loading,onClick:r.prev,children:[(0,D.jsx)("i",{className:"feather icon-chevron-left"})," Prev"]}),(0,D.jsxs)(f.A,{variant:s?"outline-light":"outline-secondary",size:"sm",disabled:!r.hasNext||r.loading,onClick:r.next,children:["Next ",(0,D.jsx)("i",{className:"feather icon-chevron-right"})]})]})]})]})})]})};var ye=t(1093);const Ne=function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"USD";const t=parseFloat(e);if(Number.isNaN(t))return"\u2014";try{return new Intl.NumberFormat(void 0,{style:"currency",currency:s}).format(t)}catch{return`${t.toFixed(2)} ${s}`}},_e=e=>{var s,t,n,i;let{product:l,days:r,show:o,onHide:c,isDarkMode:d=!1}=e;const[m,h]=(0,a.useState)({loading:!1,data:null,error:null}),u=(0,a.useRef)(0),x=(0,a.useCallback)((e,s)=>{const t=u.current+1;u.current=t,h({loading:!0,data:null,error:null}),w.xo.getAdProductBreakdown({productId:e,days:s,groupBy:"ad"}).then(e=>{var s;u.current===t&&h({loading:!1,data:null!==(s=null===e||void 0===e?void 0:e.data)&&void 0!==s?s:null,error:null})}).catch(()=>{u.current===t&&h({loading:!1,data:null,error:"Could not load ad breakdown."})})},[]);(0,a.useEffect)(()=>{o&&null!==l&&void 0!==l&&l.external_product_id&&x(l.external_product_id,r)},[o,l,r,x]);const p=null!==(s=null===(t=m.data)||void 0===t?void 0:t.results)&&void 0!==s?s:[],v=parseFloat(null!==(n=null===(i=m.data)||void 0===i?void 0:i.untagged_credit)&&void 0!==n?n:"0"),g=(null===l||void 0===l?void 0:l.currency)||"USD";return(0,D.jsxs)(Y.A,{show:o,onHide:c,placement:"end",className:"am-drawer",style:{width:"min(600px, 100vw)"},children:[(0,D.jsx)(Y.A.Header,{closeButton:!0,className:d?"border-secondary":"",children:(0,D.jsxs)(Y.A.Title,{className:"h6 mb-0",children:[(0,D.jsx)("i",{className:"feather icon-package me-2"}),(null===l||void 0===l?void 0:l.title)||(null===l||void 0===l?void 0:l.external_product_id)||"Product"]})}),(0,D.jsxs)(Y.A.Body,{children:[l&&(0,D.jsxs)("div",{className:"d-flex flex-wrap align-items-center gap-4 mb-4",children:[l.image_url&&(0,D.jsx)("img",{src:l.image_url,alt:"",style:{width:64,height:64,objectFit:"cover",borderRadius:8}}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"small "+(d?"text-white-50":"text-muted"),children:"Net revenue"}),(0,D.jsx)("div",{className:"fs-5 fw-bold",children:Ne(l.net_revenue,g)})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"small "+(d?"text-white-50":"text-muted"),children:"From ads"}),(0,D.jsx)("div",{className:"fs-5 fw-bold",children:Ne(l.ad_revenue,g)})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"small "+(d?"text-white-50":"text-muted"),children:"Units"}),(0,D.jsx)("div",{className:"fs-5 fw-bold",children:l.units})]})]}),(0,D.jsx)("div",{className:"small fw-semibold mb-2 "+(d?"text-white-50":"text-muted"),children:"Ads that drove this product"}),m.loading&&(0,D.jsx)("div",{className:"text-center py-4",children:(0,D.jsx)(A.A,{animation:"border",size:"sm"})}),m.error&&(0,D.jsxs)("div",{className:"text-center py-4",children:[(0,D.jsx)("div",{className:"small text-danger mb-2",children:m.error}),(0,D.jsx)(f.A,{variant:"outline-secondary",size:"sm",onClick:()=>x(null===l||void 0===l?void 0:l.external_product_id,r),children:"Try again"})]}),!m.loading&&!m.error&&!p.length&&(0,D.jsx)("div",{className:"small py-3 "+(d?"text-white-50":"text-muted"),children:"No ad-attributed sales for this product in the selected period."}),!!p.length&&(0,D.jsx)("div",{className:"table-responsive",children:(0,D.jsxs)(ye.A,{size:"sm",variant:d?"dar
1k":void 0,children:[(0,D.jsx)("thead",{children:(0,D.jsxs)("tr",{style:{fontSize:"0.75rem"},children:[(0,D.jsx)("th",{children:"Ad"}),(0,D.jsx)("th",{className:"text-end",children:"Units"}),(0,D.jsx)("th",{className:"text-end",children:"Credit"})]})}),(0,D.jsx)("tbody",{style:{fontSize:"0.8rem"},children:p.map(e=>(0,D.jsxs)("tr",{children:[(0,D.jsxs)("td",{children:[(0,D.jsx)("div",{className:"text-truncate",style:{maxWidth:280},children:e.name||e.entity_id}),(0,D.jsx)("div",{className:"small "+(d?"text-white-50":"text-muted"),children:e.ad_platform})]}),(0,D.jsx)("td",{className:"text-end",children:e.units}),(0,D.jsx)("td",{className:"text-end",children:Ne(e.attributed_credit,g)})]},`${e.ad_platform}-${e.entity_id}`))})]})}),v>0&&(0,D.jsxs)("div",{className:"small mt-3 "+(d?"text-white-50":"text-muted"),children:[(0,D.jsx)("i",{className:"feather icon-info me-1"}),Ne(m.data.untagged_credit,g)," of attributed revenue could not be traced to a specific ad. Ad tracking only applies to clicks after an ad is tagged, so this shrinks over time."]})]})]})},we=function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"USD";const t=parseFloat(e);if(Number.isNaN(t))return"\u2014";try{return new Intl.NumberFormat(void 0,{style:"currency",currency:s,maximumFractionDigits:t>=1e3?0:2}).format(t)}catch{return`${t.toFixed(2)} ${s}`}},ke=e=>{const s=parseFloat(e);return Number.isNaN(s)?"\u2014":String(s)},Se=e=>{let{share:s,isDarkMode:t}=e;const a=Math.round(100*(s||0));return(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2",children:[(0,D.jsx)("div",{style:{flex:1,height:6,borderRadius:3,overflow:"hidden",minWidth:60,background:t?"#475569":"#cbd5e1"},children:(0,D.jsx)("div",{style:{width:`${a}%`,height:"100%",background:t?"#6d80f5":"#4f46e5"}})}),(0,D.jsxs)("span",{className:"small",style:{minWidth:34,textAlign:"right"},children:[a,"%"]})]})},Ce=e=>{let{isDarkMode:s=!1}=e;const[t,n]=(0,a.useState)(30),[i,l]=(0,a.useState)(""),[r,o]=(0,a.useState)(""),[c,d]=(0,a.useState)(null),m=(0,a.useCallback)((e,s)=>w.xo.getProductPerformance({days:t,search:r,page:e,pageSize:s}),[t,r]),{results:h,count:u,page:x,totalPages:p,loading:g,error:b,hasNext:j,hasPrev:y,next:N,prev:_}=ve(m,{pageSize:25});return(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"d-flex flex-wrap align-items-center gap-2 mb-3",children:[(0,D.jsxs)(v.A,{className:"d-flex gap-2",onSubmit:e=>{e.preventDefault(),o(i.trim())},children:[(0,D.jsx)(v.A.Control,{size:"sm",type:"search",placeholder:"Search products",value:i,onChange:e=>l(e.target.value),style:{maxWidth:220}}),(0,D.jsx)(f.A,{size:"sm",variant:"outline-secondary",type:"submit",children:"Search"})]}),(0,D.jsx)("div",{className:"ms-auto",children:(0,D.jsxs)(v.A.Select,{size:"sm",value:t,onChange:e=>n(Number(e.target.value)),style:{width:130},children:[(0,D.jsx)("option",{value:7,children:"Last 7 days"}),(0,D.jsx)("option",{value:30,children:"Last 30 days"}),(0,D.jsx)("option",{value:90,children:"Last 90 days"})]})})]}),(0,D.jsx)(ie.A,{className:"shadow-sm "+(s?"bg-dark border-secondary":""),children:(0,D.jsxs)(ie.A.Body,{className:"p-0",children:[g&&!h.length&&(0,D.jsx)("div",{className:"p-3",children:[...Array(4)].map((e,s)=>
1(0,D.jsx)("div",{className:"placeholder-glow mb-2",children:(0,D.jsx)("span",{className:"placeholder col-12 rounded",style:{height:32}})},s))}),b&&(0,D.jsx)("div",{className:"text-center py-5 small text-danger",children:"Could not load product performance."}),!g&&!b&&!h.length&&(0,D.jsxs)("div",{className:"text-center py-5 "+(s?"text-white-50":"text-muted"),children:[(0,D.jsx)("i",{className:"feather icon-package mb-3",style:{fontSize:"2rem",display:"block"}}),(0,D.jsx)("div",{className:"small",children:"No product sales in this period"})]}),!!h.length&&(0,D.jsx)("div",{className:"table-responsive",children:(0,D.jsxs)("table",{className:"table table-sm mb-0 "+(s?"table-dark":""),children:[(0,D.jsx)("thead",{children:(0,D.jsxs)("tr",{className:s?"text-white-50":"text-muted",style:{fontSize:"0.75rem"},children:[(0,D.jsx)("th",{className:"fw-medium",children:"Product"}),(0,D.jsx)("th",{className:"fw-medium text-end",children:"Units"}),(0,D.jsx)("th",{className:"fw-medium text-end",children:"Net revenue"}),(0,D.jsx)("th",{className:"fw-medium text-end",children:"From ads"}),(0,D.jsx)("th",{className:"fw-medium text-end",children:"Organic"}),(0,D.jsx)("th",{className:"fw-medium",style:{minWidth:120},children:"Ad share"}),(0,D.jsx)("th",{className:"fw-medium text-end",title:"This product's share of the attribution model's revenue credit \u2014 not the same as revenue from ad-touched orders",children:"Credit"})]})}),(0,D.jsx)("tbody",{style:{fontSize:"0.8rem"},children:h.map(e=>(0,D.jsxs)("tr",{onClick:()=>d(e),style:{cursor:"pointer"},title:"See which ads sold this product",children:[(0,D.jsx)("td",{children:(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2",children:[e.image_url&&(0,D.jsx)("img",{src:e.image_url,alt:"",style:{width:28,height:28,objectFit:"cover",borderRadius:4}}),(0,D.jsxs)("div",{className:"min-w-0",children:[(0,D.jsx)("div",{className:"text-truncate",style:{maxWidth:260},children:e.title||e.external_product_id}),e.sku&&(0,D.jsx)("div",{className:"small "+(s?"text-white-50":"text-muted"),children:e.sku})]})]})}),(0,D.jsx)("td",{className:"text-end",children:ke(e.units)}),(0,D.jsx)("td",{className:"text-end",children:we(e.net_revenue,e.currency)}),(0,D.jsx)("td",{className:"text-end",children:we(e.ad_revenue,e.currency)}),(0,D.jsx)("td",{className:"text-end",children:we(e.organic_revenue,e.currency)}),(0,D.jsx)("td",{children:(0,D.jsx)(Se,{share:e.ad_share,isDarkMode:s})}),(0,D.jsx)("td",{className:"text-end",children:we(e.attributed_credit,e.currency)})]},`${e.external_product_id}-${e.external_variant_id}`))})]})}),p>1&&(0,D.jsxs)("div",{className:"d-flex align-items-center justify-content-between px-3 py-2 border-top "+(s?"border-secondary":""),children:[(0,D.jsxs)("span",{className:"small "+(s?"text-white-50":"text-muted"),children:[u," products \xb7 page ",x," of ",p]}),(0,D.jsxs)("div",{className:"d-flex gap-2",children:[(0,D.jsxs)(f.A,{variant:s?"outline-light":"outline-secondary",size:"sm",disabled:!y||g,onClick:_,children:[(0,D.jsx)("i",{className:"feather icon-chevron-left"})," Prev"]}),(0,D.jsxs)(f.A,{variant:s?"outline-light":"outline-secondary",size:"sm",disabled:!j||g,onClick:N,children:["Next ",(0,D.jsx)("i",{className:"feather icon-chevron-right"})]})]})]})]})}),(0,D.jsxs)("div",{className:"small mt-2 "+(s?"text-white-50":"text-muted"),children:[(0,D.jsx)("strong",{children:"From ads"})," is the full revenue of orders an ad touched."," ",(0,D.jsx)("strong",{children:"Credit"})," is this product's share of the last-touch attribution model, which splits an order across every ad that contributed. They differ when a customer clicked more than one ad."]}),(0,D.jsx)(_e,{product:c,days:t,show:Boolean(c),onHide:()=>d(null),isDarkMode:s})]})};function Ae(e){let{onConnectionChange:s,onEventsChange:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=(0,a.useContext)(H.P),i=null===n||void 0===n?void 0:n.subscribe,l=(0,a.useRef)(null);(0,a.useEffect)(()=>()=>clearTimeout(l.current),[]),(0,a.useEffect)(()=>{if(!i)return;const a=()=>{t&&(clearTimeout(l.current),l.current=setTimeout(t,600))};return i("ecommerce_update",t=>{var n,i;if((null===t||void 0===t?void 0:t.platform)!==e)return;const l=null===t||void 0===t?void 0:t.status;"auth_error"===l||"store_unavailable"===l?((0,N.UW)((null===t||void 0===t?void 0:t.message)||"Your store connection needs attention. Please reconnect.",{showMoreLink:!1}),s&&s()):"reconnected"===l?((0,N.LG)((null===t||void 0===t?void 0:t.message)||"Store connection restored."),s&&s()):"event_received"===l?a():"completed"===l&&"backfill"===(null===t||void 0===t||null===(n=t.extra)||void 0===n?void 0:n.kind)?((0,N.LG)((null===t||void 0===t?void 0:t.message)||"Store import finished."),a()):"failed"===l&&"backfill"===(null===t||void 0===t||null===(i=t.extra)||void 0===i?void 0:i.kind)&&(0,N.UW)((null===t||void 0===t?void 0:t.message)||"Store import failed. Please try again.",{showMoreLink:!1})})},[i,e,s,t])}const Pe=e=>{if(!e)return"\u2014";
1try{return new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}},ze=function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"USD";if(null==e||""===e)return"\u2014";const t=parseFloat(e);if(Number.isNaN(t))return"\u2014";try{return new Intl.NumberFormat(void 0,{style:"currency",currency:s}).format(t)}catch{return`${t.toFixed(2)} ${s}`}},Te=e=>{const s=parseFloat(e);return Number.isNaN(s)?"\u2014":(Number.isInteger(s),String(s))},Fe=e=>{let{title:s,children:t,isDarkMode:a}=e;return(0,D.jsxs)("div",{className:"mb-4",children:[(0,D.jsx)("div",{className:"small fw-semibold mb-2 "+(a?"text-white-50":"text-muted"),children:s}),t]})},Ee=e=>{let{label:s,value:t,bold:a=!1,isDarkMode:n}=e;return(0,D.jsxs)("div",{className:"d-flex justify-content-between small "+(a?"fw-bold":""),children:[(0,D.jsx)("span",{className:a||n?"":"text-muted",children:s}),(0,D.jsx)("span",{children:t})]})},Le=e=>{var s,t,n;let{eventId:i,show:l,onHide:r,isDarkMode:o=!1}=e;const[c,d]=(0,a.useState)({loading:!1,order:null,error:null}),m=(0,a.useRef)(0),h=(0,a.useCallback)(e=>{const s=m.current+1;m.current=s,d({loading:!0,order:null,error:null}),w.xo.getOrderDetail(e).then(e=>{var t;m.current===s&&d({loading:!1,order:null!==(t=null===e||void 0===e?void 0:e.data)&&void 0!==t?t:null,error:null})}).catch(()=>{m.current===s&&d({loading:!1,order:null,error:"Could not load this order."})})},[]);(0,a.useEffect)(()=>{l&&i&&h(i)},[l,i,h]);const u=c.order,x=(null===u||void 0===u?void 0:u.currency)||"USD",p=((null===u||void 0===u?void 0:u.lines)||[]).some(e=>e.is_approximate),v=parseFloat(null!==(s=null===u||void 0===u||null===(t=u.totals)||void 0===t?void 0:t.residual)&&void 0!==s?s:"0");return(0,D.jsxs)(Y.A,{show:l,onHide:r,placement:"end",className:"am-drawer",style:{width:"min(640px, 100vw)"},children:[(0,D.jsx)(Y.A.Header,{closeButton:!0,className:o?"border-secondary":"",children:(0,D.jsxs)(Y.A.Title,{className:"h6 mb-0",children:[(0,D.jsx)("i",{className:"feather icon-shopping-bag me-2"}),u?`Order ${u.external_id}`:"Order"]})}),(0,D.jsxs)(Y.A.Body,{children:[c.loading&&(0,D.jsx)("div",{className:"text-center py-5",children:(0,D.jsx)(A.A,{animation:"border",size:"sm"})}),c.error&&(0,D.jsxs)("div",{className:"text-center py-5",children:[(0,D.jsx)("div",{className:"small text-danger mb-2",children:c.error}),(0,D.jsx)(f.A,{variant:"outline-secondary",size:"sm",onClick:()=>h(i),children:"Try again"})]}),u&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(Fe,{title:"Summary",isDarkMode:o,children:[(0,D.jsxs)("div",{className:"d-flex flex-wrap gap-4",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"small "+(o?"text-white-50":"text-muted"),children:"Total"}),(0,D.jsx)("div",{className:"fs-5 fw-bold",children:ze(u.value,x)})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"small "+(o?"text-white-50":"text-muted"),children:"Date"}),(0,D.jsx)("div",{children:Pe(u.event_time)})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"small "+(o?"text-white-50":"text-muted"),children:"Type"}),(0,D.jsxs)("div",{children:[(0,D.jsx)(pe.A,{bg:"refund"===u.event_type?"warning":"success",children:u.event_type}),u.external_status&&(0,D.jsx)("span",{className:"ms-2 small "+(o?"text-white-50":"text-muted"),children:u.external_status})]})]})]}),(null===(n=u.connection)||void 0===n?void 0:n.store_url)&&(0,D.jsxs)("div",{className:"mt-3",children:[(0,D.jsx)("div",{className:"small "+(o?"text-white-50":"text-muted"),children:"Store"}),(0,D.jsx)("div",{style:{wordBreak:"break-all"},children:u.connection.store_url})]})]}),(0,D.jsx)(Fe,{title:"Items",isDarkMode:o,children:0===u.lines.length?(0,D.jsx)("div",{className:"small "+(o?"text-white-50":"text-muted"),children:"No line items recorded for this order."}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"table-responsive",children:(0,D.jsxs)(ye.A,{size:"sm",variant:o?"dark":void 0,className:"mb-2",children:[(0,D.jsx)("thead",{children:(0,D.jsxs)("tr",{style:{fontSize:"0.75rem"},children:[(0,D.jsx)("th",{children:"Product"}),(0,D.jsx)("th",{className:"text-end",children:"Qty"}),(0,D.jsx)("th",{className:"text-end",children:"Price"}),(0,D.jsx)("th",{className:"text-end",children:"Total"})]})}),(0,D.jsx)("tbody",{style:{fontSize:"0.8rem"},children:u.lines.map(e=>(0,D.jsxs)("tr",{children:[(0,D.jsx)("td",{children:(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2",children:[e.image_url&&(0,D.jsx)("img",{src:e.image_url,alt:"",style:{width:32,height:32,objectFit:"cover",borderRadius:4}}),(0,D.jsxs)("div",{className:"min-w-0",children:[(0,D.jsx)("div",{className:"text-truncate",children:e.title||"\u2014"}),e.sku&&(0,D.jsx)("div",{className:"small "+(o?"text-white-50":"text-muted"),children:e.sku})]})]})}),(0,D.jsx)("td",{className:"text-end",children:Te(e.quantity)}),(0,D.jsx)("td",{className:"text-end",children:ze(e.unit_price,x)}),(0,D.jsxs)("td",{className:"text-end",children:[ze(e.line_total,x),parseFloat(e.line_discount)>0&&(0,D.jsxs)("div",{className:"small text-success",children:["\u2212",ze(e.line_discount,x)]})]})]},e.line_index))})]})}),(0,D.jsx)("div",{className:"d-flex justify-content-end",children:(0,D.jsxs)("div",{style:{minWidth:240},children:[(0,D.jsx)(Ee,{label:"Items",value:ze(u.totals.line_total_sum,x),isDarkMode:o}),parseFloat(u.totals.tax_sum)>0&&(0,D.jsx)(Ee,{label:"Tax",value:ze(u.totals.tax_sum,x),isDarkMode:o}),0!==v&&(0,D.jsx)(Ee,{label:"Shipping & adjustments",value:ze(u.totals.residual,x),isDarkMode:o}),(0,D.jsx)(Ee,{label:"Order total",value:ze(u.value,x),bold:!0,isDarkMode:o})]})}),p&&(0,D.jsxs)("div",{className:"small mt-2 "+(o?"text-white-50":"text-muted"),children:[(0,D.jsx)("i",{className:"feather icon-info me-1"}),"Some line totals are estimated \u2014 this order was imported before itemised data was captured, so discounts are not reflected."]})]})}),(0,D.jsxs)(Fe,{title:"Attribution",isDarkMode:o,children:[!u.attribution.has_attribution&&u.attribution.resolved_click?(0,D.jsxs)("div",{className:"small "+(o?"text-white-50":"text-muted"),children:[(0,D.jsxs)("div",{children:[u.attribution.resolved_click.ad_platform,u.attribution.resolved_click.ad_id?` \xb7 ad ${u.attribution.resolved_click.ad_id}`:""]}),(0,D.jsxs)("div",{className:"mt-1",children:[(0,D.jsx)("i",{className:"feather icon-info me-1"}),"No revenue credited \u2014 this checkout was not completed."]})]}):null,u.attribution.has_attribution||u.attribution.resolved_click?null:(0,D.jsx)("div",{className:"small "+(o?"text-white-50":"text-muted"),children:"This order was not matched to an ad click."}),u.attribution.has_attribution&&Object.entries(u.attribution.models).map(e=>{let[s,t]=e;return(0,D.jsxs)("div",{className:"mb-2",children:[(0,D.jsx)("div",{className:"small fw-semibold",children:Ie[s]||s}),t.map((e,t)=>(0,D.jsxs)("div",{className:"small "+(o?"text-white-50":"text-muted"),children:[e.ad_platform,e.ad_id?` \xb7 ad ${e.ad_id}`:""," \xb7 ",ze(e.revenue_credit,x),e.total_touches>1&&` (touch ${e.touch_position} of ${e.total_touches})`]},`${s}-${t}`))]},s)})]}),(u.landing_url||u.utm_source)&&(0,D.jsxs)(Fe,{title:"Source",isDarkMode:o,children:[u.utm_source&&(0,D.jsxs)("div",{className:"small",children:[(0,D.jsx)("span",{className:o?"text-white-50":"text-muted",children:"Campaign: "}),u.utm_source,u.utm_campaign?` / ${u.utm_campaign}`:""]}),u.landing_url&&(0,D.jsxs)("div",{className:"small text-break",children:[(0,D.jsx)("span",{className:o?"text-white-50":"text-muted",children:"Landed on: "}),u.landing_url]})]})]})]})]})},De=e=>{if(!e)return"\u2014";
1try{return new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}},$e=function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"USD";if(null==e)return"\u2014";const t=parseFloat(e);return Number.isNaN(t)?"\u2014":new Intl.NumberFormat(void 0,{style:"currency",currency:s}).format(t)},Ie={last_touch:"Last touch",first_touch:"First touch",linear:"Linear",time_decay:"Time decay",position_based:"Position based"},Re=e=>{let{events:s=[],loading:t=!1,isDarkMode:n=!1,pagination:i=null}=e;const[l,r]=(0,a.useState)(null);return t&&!s.length?(0,D.jsx)("div",{className:"p-3",children:[...Array(4)].map((e,s)=>(0,D.jsx)("div",{className:"placeholder-glow mb-2",children:(0,D.jsx)("span",{className:"placeholder col-12 rounded",style:{height:32}})},s))}):s.length?(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"table-responsive",children:(0,D.jsxs)("table",{className:"table table-sm mb-0 "+(n?"table-dark":""),children:[(0,D.jsx)("thead",{children:(0,D.jsxs)("tr",{className:n?"text-white-50":"text-muted",style:{fontSize:"0.75rem"},children:[(0,D.jsx)("th",{className:"fw-medium",children:"Date"}),(0,D.jsx)("th",{className:"fw-medium",children:"Event"}),(0,D.jsx)("th",{className:"fw-medium",children:"Order ID"}),(0,D.jsx)("th",{className:"fw-medium text-end",children:"Value"}),(0,D.jsx)("th",{className:"fw-medium text-center",children:"Attribution"})]})}),(0,D.jsx)("tbody",{style:{fontSize:"0.8rem"},children:s.map((e,s)=>{var t,i;const l=e.has_attribution||e.attributed||"matched"===e.attribution_status,o=e.id||e.idempotency_key||s,c=Boolean(e.id);return(0,D.jsx)(a.Fragment,{children:(0,D.jsxs)("tr",{onClick:c?()=>r(e.id):void 0,style:c?{cursor:"pointer"}:void 0,title:c?"View order detail":void 0,children:[(0,D.jsx)("td",{className:n?"text-white-50":"text-muted",children:De(e.event_time||e.occurred_at||e.created_at)}),(0,D.jsxs)("td",{children:[(0,D.jsx)("span",{className:`badge ${"purchase"===e.event_type?"bg-success":"abandoned"===e.checkout_status?"bg-warning text-dark":"converted"===e.checkout_status?"bg-success bg-opacity-50":"bg-secondary"} bg-opacity-75`,children:"checkout_started"===e.event_type&&e.checkout_status?`checkout ${e.checkout_status}`:e.event_type||"\u2014"}),"abandoned"===e.checkout_status&&e.recovery_url&&(0,D.jsx)("a",{href:e.recovery_url,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),className:"ms-2 small",title:"Open the shopper's saved cart",children:(0,D.jsx)("i",{className:"feather icon-external-link"})})]}),(0,D.jsx)("td",{className:n?"text-white-50":"text-muted",children:e.external_id||e.order_id||e.platform_order_id||"\u2014"}),(0,D.jsx)("td",{className:"text-end",children:null!=e.value||null!=e.revenue||null!=e.total_price?$e(null!==(t=null!==(i=e.value)&&void 0!==i?i:e.revenue)&&void 0!==t?t:e.total_price,e.currency||"USD"):"\u2014"}),(0,D.jsxs)("td",{className:"text-center",children:[l&&(0,D.jsxs)("span",{className:"badge bg-success bg-opacity-75",children:[(0,D.jsx)("i",{className:"feather icon-check me-1"}),e.attributed_platform?e.attributed_platform:"Matched"]}),!l&&e.resolved_click_platform&&(0,D.jsxs)("span",{className:"badge "+(n?"bg-secondary":"bg-light text-muted"),title:"Ad click resolved. No revenue is credited \u2014 the checkout was not completed.",children:[e.resolved_click_platform,(0,D.jsx)("span",{className:"ms-1 opacity-75",children:"\xb7 no credit"})]}),!l&&!e.resolved_click_platform&&(0,D.jsx)("span",{className:"badge "+(n?"bg-secondary":"bg-light text-muted"),children:"Unmatched"})]})]})},o)})})]})}),(0,D.jsx)(Le,{eventId:l,show:Boolean(l),onHide:()=>r(null),isDarkMode:n}),i&&i.totalPages>1&&(0,D.jsxs)("div",{className:"d-flex align-items-center justify-content-between px-3 py-2 border-top "+(n?"border-secondary":""),children:[(0,D.jsxs)("span",{className:"small "+(n?"text-white-50":"text-muted"),children:[i.count," events \xb7 page ",i.page," of ",i.totalPages]}),(0,D.jsxs)("div",{className:"d-flex gap-2",children:[(0,D.jsxs)(f.A,{variant:n?"outline-light":"outline-secondary",size:"sm",disabled:!i.hasPrev||t,onClick:i.prev,children:[(0,D.jsx)("i",{className:"feather icon-chevron-left"})," Prev"]}),(0,D.jsxs)(f.A,{variant:n?"outline-light":"outline-secondary",size:"sm",disabled:!i.hasNext||t,onClick:i.next,children:["Next ",(0,D.jsx)("i",{className:"feather icon-chevron-right"})]})]})]})]}):(0,D.jsxs)("div",{className:"text-center py-5 "+(n?"text-white-50":"text-muted"),children:[(0,D.jsx)("i",{className:"feather icon-inbox mb-3",style:{fontSize:"2rem",display:"block"}}),(0,D.jsx)("div",{className:"small",children:"No events yet"})]})},Me=e=>{const s=(e||"").trim();return s?s.includes("Response(")||s.includes("headers=")||s.length>240?"Order syncing hit a problem with Shopify. Reconnect if this persists.":s:"This store has been unreachable. Reconnect to resume order tracking."},Be=e=>{if(!e)return null;
1try{return new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}},We=[{value:7,label:"Last 7 days"},{value:30,label:"Last 30 days"},{value:90,label:"Last 90 days"},{value:0,label:"All time"}],Oe=e=>{let{isDarkMode:s=!1,onConnect:t,onConnectionsChanged:n}=e;const[i,l]=(0,a.useState)([]),[r,o]=(0,a.useState)(!0),[c,d]=(0,a.useState)(null),[m,h]=(0,a.useState)(!1),[u,x]=(0,a.useState)(null),[g,b]=(0,a.useState)(""),[j,y]=(0,a.useState)(null),[N,_]=(0,a.useState)(null),[k,S]=(0,a.useState)(null),[C,P]=(0,a.useState)(!1),[E,L]=(0,a.useState)(null),[$,I]=(0,a.useState)(30),[R,M]=(0,a.useState)(""),B=(0,a.useCallback)(()=>{o(!0),d(null),w.LQ.getStores().then(e=>{var s,t,a;const n=null!==(s=null!==(t=null===e||void 0===e||null===(a=e.data)||void 0===a?void 0:a.results)&&void 0!==t?t:null===e||void 0===e?void 0:e.data)&&void 0!==s?s:[];l(Array.isArray(n)?n:[])}).catch(()=>d("Failed to load Shopify stores")).finally(()=>o(!1))},[]),W=i.length>0,O=ve((0,a.useCallback)((e,s)=>w.xo.getEvents({provider:"shopify",page:e,pageSize:s,days:$||void 0,type:R||void 0}),[$,R]),{pageSize:25,auto:W});(0,a.useEffect)(()=>{B()},[B]),Ae("shopify",{onConnectionChange:B,onEventsChange:O.reload});const U=e=>{const s="string"===typeof e?e:g;h(!0),x(null),(0,z.oK)(s).catch(e=>{x(e.message),h(!1)})},H=e=>{e.connection_id&&w.xo.reconnect(e.connection_id).catch(()=>{}),e.shop_domain&&(b(e.shop_domain),U(e.shop_domain))};return r?(0,D.jsxs)("div",{className:"d-flex align-items-center justify-content-center p-5",children:[(0,D.jsx)(A.A,{animation:"border",size:"sm",className:"me-2"}),(0,D.jsx)("span",{className:s?"text-white-50":"text-muted",children:"Loading Shopify stores\u2026"})]}):(0,D.jsxs)("div",{className:"p-3",children:[!W&&(0,D.jsx)(F.A,{provider:"shopify"}),(0,D.jsxs)("div",{className:"d-flex align-items-center gap-3 mb-4",children:[(0,D.jsx)("img",{src:T,alt:"Shopify",style:{width:48,height:48,borderRadius:8,flexShrink:0,objectFit:"contain"}}),(0,D.jsxs)("div",{children:[(0,D.jsx)("h5",{className:"mb-0 fw-bold "+(s?"text-white":""),children:"Shopify"}),(0,D.jsx)("div",{className:"small "+(s?"text-white-50":"text-muted"),children:"Connect your Shopify store to capture purchase events via webhooks."})]})]}),c&&(0,D.jsx)("div",{className:"alert alert-warning small py-2 mb-3",children:c}),!W&&(0,D.jsx)(ie.A,{className:"shadow-sm mb-4 "+(s?"bg-dark border-secondary":""),children:(0,D.jsxs)(ie.A.Body,{className:"text-center py-5",children:[(0,D.jsx)("i",{className:"feather icon-shopping-bag mb-3",style:{fontSize:"2.5rem",color:"#96bf48",display:"block"}}),(0,D.jsx)("h6",{className:"mb-2 "+(s?"text-white":""),children:"No Shopify store connected"}),(0,D.jsx)("p",{className:"small mb-4 "+(s?"text-white-50":"text-muted"),style:{maxWidth:380,margin:"0 auto 1rem"},children:"Click below to authorise Link Clicks to receive purchase webhooks from your Shopify store."}),(0,D.jsx)(v.A.Control,{type:"text",size:"sm",placeholder:"mystore.myshopify.com (or just \u201cmystore\u201d)",value:g,onChange:e=>b(e.target.value),onKeyDown:e=>{"Enter"===e.key&&U()},className:"mb-3 mx-auto",style:{maxWidth:320}}),u&&(0,D.jsx)("div",{className:"text-danger small mb-3",children:u}),(0,D.jsx)(f.A,{variant:"success",disabled:m,onClick:()=>U(),children:m?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(A.A,{animation:"border",size:"sm",className:"me-2"}),"Connecting\u2026"]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("i",{className:"feather icon-link me-2"}),"Connect Shopify Store"]})})]})}),W&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"d-flex align-items-center justify-content-between mb-3",children:[(0,D.jsxs)("h6",{className:"mb-0 fw-semibold "+(s?"text-white":""),children:["Connected stores ",(0,D.jsx)(pe.A,{bg:"success",className:"ms-1",children:i.length})]}),(0,D.jsxs)(f.A,{variant:"outline-success",size:"sm",onClick:()=>t?t("shopify"):null,children:[(0,D.jsx)("i",{className:"feather icon-plus me-1"}),"Add store"]})]}),u&&(0,D.jsx)("div",{className:"alert alert-danger small py-2 mb-3",children:u}),(0,D.jsx)("div",{className:"d-flex flex-column gap-3 mb-4",children:i.map(e=>(0,D.jsx)(ie.A,{className:"shadow-sm "+(s?"bg-dark border-secondary":""),children:(0,D.jsx)(ie.A.Body,{children:(0,D.jsxs)("div",{className:"d-flex flex-wrap align-items-start gap-2",children:[(0,D.jsxs)("div",{className:"flex-grow-1 min-w-0",children:[(0,D.jsx)("div",{className:"fw-semibold "+(s?"text-white":""),children:e.shop_name||e.shop_domain||`Store ${e.id}`}),e.shop_domain&&(0,D.jsxs)("div",{className:"small "+(s?"text-white-50":"text-muted"),children:[(0,D.jsx)("i",{className:"feather icon-globe me-1"}),e.shop_domain]}),(0,D.jsx)("div",{className:"d-flex flex-wrap gap-2 mt-2",children:(0,D.jsx)(pe.A,{bg:e.unavailable_at?"danger":!1!==e.is_active?"success":"secondary",className:"bg-opacity-75",children:e.unavailable_at?"Unavailable":!1!==e.is_active?"Active":"Needs reconnect"})}),e.needs_reauth&&!e.unavailable_at&&!1!==e.is_active&&(0,D.jsxs)("div",{className:"alert alert-warning small py-2 mt-2 mb-0 d-flex flex-wrap align-items-center gap-2",children:[(0,D.jsxs)("div",{className:"flex-grow-1",children:[(0,D.jsx)("i",{className:"feather icon-shield me-2"}),"New features need additional permissions on this store."]}),(0,D.jsxs)(f.A,{size:"sm",variant:"warning",onClick:()=>H(e),children:[(0,D.jsx)("i",{className:"feather icon-shield me-1"}),"Grant permissions"]})]}),e.review_limited&&(0,D.jsxs)("div",{className:"alert alert-info small py-2 mt-2 mb-0 d-flex gap-2 align-items-start",role:"status",children:[(0,D.jsx)("i",{className:"feather icon-clock mt-1","aria-hidden":"true"}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"fw-semibold",children:"Shopify integration is in review"}),"Your orders are not syncing yet \u2014 neither new sales nor past ones \u2014 because Shopify has not yet approved our access to order data. Everything else on your store keeps working, and your orders will import automatically once approval is granted."]})]}),(e.last_error||e.unavailable_at||!1===e.is_active)&&(0,D.jsxs)("div",{className:"alert alert-danger small py-2 mt-2 mb-0 d-flex flex-wrap align-items-center gap-2",children:[(0,D.jsxs)("div",{className:"flex-grow-1",children:[(0,D.jsx)("i",{className:"feather icon-alert-circle me-2"}),Me(e.last_error)]}),(0,D.jsxs)(f.A,{size:"sm",variant:"danger",onClick:()=>H(e),children:[(0,D.jsx)("i",{className:"feather icon-refresh-cw me-1"}),"Reconnect"]})]}),e.last_webhook_received_at&&(0,D.jsxs)("div",{className:"small mt-1 "+(s?"text-white-50":"text-muted"),children:["Last webhook: ",Be(e.last_webhook_received_at)]})]}),(0,D.jsxs)("div",{className:"d-flex flex-wrap gap-2",children:[N===e.id&&(0,D.jsxs)("span",{className:"small text-success align-self-center",children:[(0,D.jsx)("i",{className:"feather icon-check me-1"}),"Backfill queued"]}),(0,D.jsx)(f.A,{variant:"outline-secondary",size:"sm",disabled:j===e.id,onClick:()=>{return s=e.id,y(s),_(null),void w.LQ.backfillStore(s).then(()=>{_(s),setTimeout(()=>
1_(null),4e3),[2e3,6e3,15e3,3e4].forEach(e=>{setTimeout(()=>O.reload(),e)})}).catch(()=>{}).finally(()=>y(null));var s},title:"Re-import historical orders",children:j===e.id?(0,D.jsx)(A.A,{animation:"border",size:"sm"}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("i",{className:"feather icon-refresh-cw me-1"}),"Backfill"]})}),(0,D.jsxs)(f.A,{variant:"outline-danger",size:"sm",onClick:()=>S(e),children:[(0,D.jsx)("i",{className:"feather icon-trash-2 me-1"}),"Disconnect"]})]})]})})},e.id))}),(0,D.jsxs)(ie.A,{className:"shadow-sm "+(s?"bg-dark border-secondary":""),children:[(0,D.jsxs)(ie.A.Header,{className:"d-flex flex-wrap align-items-center justify-content-between gap-2 "+(s?"bg-transparent border-secondary":""),children:[(0,D.jsxs)("span",{className:"fw-semibold small "+(s?"text-white":""),children:[(0,D.jsx)("i",{className:"feather icon-target me-2"}),"Recent events"]}),(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2",children:[(0,D.jsxs)(v.A.Select,{size:"sm",value:R,onChange:e=>M(e.target.value),style:{width:"auto"},children:[(0,D.jsx)("option",{value:"",children:"All events"}),(0,D.jsx)("option",{value:"purchase",children:"Purchases"}),(0,D.jsx)("option",{value:"refund",children:"Refunds"})]}),(0,D.jsx)(v.A.Select,{size:"sm",value:$,onChange:e=>I(Number(e.target.value)),style:{width:"auto"},children:We.map(e=>(0,D.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,D.jsx)(f.A,{variant:"link",size:"sm",className:"p-0 text-muted",onClick:O.reload,disabled:O.loading,title:"Refresh events",children:(0,D.jsx)("i",{className:"feather icon-refresh-cw"+(O.loading?" fa-spin":"")})})]})]}),(0,D.jsx)(ie.A.Body,{className:"p-0",children:(0,D.jsx)(Re,{events:O.results,loading:O.loading,isDarkMode:s,pagination:O})})]})]}),(0,D.jsxs)(p.A,{show:Boolean(k),onHide:()=>{S(null),L(null)},centered:!0,size:"sm",children:[(0,D.jsx)(p.A.Header,{closeButton:!0,children:(0,D.jsx)(p.A.Title,{className:"fs-6",children:"Disconnect store?"})}),(0,D.jsxs)(p.A.Body,{className:"small",children:[(0,D.jsxs)("p",{children:["This will disconnect ",(0,D.jsx)("strong",{children:(null===k||void 0===k?void 0:k.shop_name)||(null===k||void 0===k?void 0:k.shop_domain)||"the store"})," and stop receiving new webhooks. Historical events will be preserved."]}),E&&(0,D.jsx)("div",{className:"text-danger",children:E})]}),(0,D.jsxs)(p.A.Footer,{children:[(0,D.jsx)(f.A,{variant:"secondary",size:"sm",onClick:()=>{S(null),L(null)},children:"Cancel"}),(0,D.jsx)(f.A,{variant:"danger",size:"sm",disabled:C,onClick:()=>{k&&(P(!0),L(null),w.LQ.disconnectStore(k.id).then(()=>{S(null),B(),n&&n()}).catch(e=>{var s,t;const a=(null===e||void 0===e||null===(s=e.response)||void 0===s||null===(t=s.data)||void 0===t?void 0:t.detail)||"Failed to disconnect store";L(a)}).finally(()=>P(!1)))},children:C?(0,D.jsx)(A.A,{animation:"border",size:"sm"}):"Disconnect"})]})]})]})},Ue=e=>{if(!e)return null;try{return new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}},He=e=>{let{isDarkMode:s=!1,onConnectionsChanged:t}=e;const[n,i]=(0,a.useState)(null),[l,r]=(0,a.useState)(!0),[o,c]=(0,a.useState)(null),[d,m]=(0,a.useState)(!1),[h,u]=(0,a.useState)(null),[x,v]=(0,a.useState)(!1),[g,b]=(0,a.useState)(!1),[j,y]=(0,a.useState)(!1),[N,_]=(0,a.useState)(!1),[k,S]=(0,a.useState)(null),C=(0,a.useCallback)(()=>{r(!0),c(null),w.LF.getStatus().then(e=>{var s;return i(null!==(s=null===e||void 0===e?void 0:e.data)&&void 0!==s?s:{})}).catch(()=>c("Failed to load Wix status")).finally(()=>r(!1))},[]),P=ve((0,a.useCallback)((e,s)=>w.xo.getEvents({provider:"wix",page:e,pageSize:s}),[]),{pageSize:25,auto:Boolean(null===n||void 0===n?void 0:n.connected)});(0,a.useEffect)(()=>{C()},[C]),Ae("wix",{onConnectionChange:C,onEventsChange:P.reload});const z=()=>{m(!0),u(null),w.LF.getAuthUrl().then(e=>{var s,t,a;const n=null!==(s=null===e||void 0===e||null===(t=e.data)||void 0===t?void 0:t.auth_url)&&void 0!==s?s:null===e||void 0===e||null===(a=e.data)||void 0===a?void 0:a.url;n?window.location.href=n:(u("No auth URL returned from server."),m(!1))}).catch(e=>{var s,t,a,n;const i=(null===e||void 0===e||null===(s=e.response)||void 0===s||null===(t=s.data)||void 0===t?void 0:t.detail)||(null===e||void 0===e||null===(a=e.response)||void 0===a||null===(n=a.data)||void 0===n?void 0:n.error)||"Failed to start Wix OAuth";u(i),m(!1)})},T=()=>{null!==n&&void 0!==n&&n.connection_id&&w.xo.reconnect(n.connection_id).catch(()=>{}),z()};if(l)return(0,D.jsxs)("div",{className:"d-flex align-items-center justify-content-center p-5",children:[(0,D.jsx)(A.A,{animation:"border",size:"sm",className:"me-2"}),(0,D.jsx)("span",{className:s?"text-white-50":"text-muted",children:"Loading Wix status\u2026"})]});const F=Boolean(null===n||void 0===n?void 0:n.connected),E=Boolean(null===n||void 0===n?void 0:n.site_id)&&(!1===(null===n||void 0===n?void 0:n.is_active)||Boolean(null===n||void 0===n?void 0:n.unavailable_at)||Boolean(null===n||void 0===n?void 0:n.last_error));return(0,D.jsxs)("div",{className:"p-3",children:[(0,D.jsxs)("div",{className:"d-flex align-items-center gap-3 mb-4",children:[(0,D.jsx)("img",{src:L,alt:"Wix",style:{width:48,height:48,borderRadius:8,flexShrink:0,objectFit:"contain"}}),(0,D.jsxs)("div",{children:[(0,D.jsx)("h5",{className:"mb-0 fw-bold "+(s?"text-white":""),children:"Wix"}),(0,D.jsx)("div",{className:"small "+(s?"text-white-50":"text-muted"),children:"Connect your Wix site to capture purchase events via the Wix eCommerce API."})]})]}),o&&(0,D.jsx)("div",{className:"alert alert-warning small py-2 mb-3",children:o}),!F&&!E&&(0,D.jsx)(ie.A,{className:"shadow-sm mb-4 "+(s?"bg-dark border-secondary":""),children:(0,D.jsxs)(ie.A.Body,{className:"text-center py-5",children:[(0,D.jsx)("img",{src:L,alt:"Wix",style:{width:56,height:56,borderRadius:12,display:"block",margin:"0 auto 0.75rem"}}),(0,D.jsx)("h6",{className:"mb-2 "+(s?"text-white":""),children:"No Wix site connected"}),(0,D.jsx)("p",{className:"small mb-4 "+(s?"text-white-50":"text-muted"),style:{maxWidth:380,margin:"0 auto 1rem"},children:"Authorise via the Wix App Market to receive purchase webhooks and track order attribution."}),h&&(0,D.jsx)("div",{className:"text-danger small mb-3",children:h}),(0,D.jsx)(f.A,{variant:"primary",disabled:d,onClick:z,children:d?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(A.A,{animation:"border",size:"sm",className:"me-2"}),"Connecting\u2026"]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("i",{className:"feather icon-link me-2"}),"Connect Wix Site"]})})]})}),!F&&E&&(0,D.jsx)(ie.A,{className:"shadow-sm mb-4 "+(s?"bg-dark border-secondary":""),children:(0,D.jsx)(ie.A.Body,{children:(0,D.jsxs)("div",{className:"d-flex flex-wrap align-items-start gap-2",children:[(0,D.jsxs)("div",{className:"flex-grow-1 min-w-0",children:[(0,D.jsx)("div",{className:"fw-semibold "+(s?"text-white":""),children:n.site_id||"Wix Site"}),(0,D.jsx)("div",{className:"d-flex flex-wrap gap-2 mt-2",children:(0,D.jsx)(pe.A,{bg:"danger",className:"bg-opacity-75",children:"Needs reconnect"})}),(0,D.jsxs)("div",{className:"alert alert-danger small py-2 mt-2 mb-0",children:[(0,D.jsx)("i",{className:"feather icon-alert-circle me-2"}),n.last_error||"Wix has been unreachable. Reconnect to resume order tracking."]})]}),(0,D.jsx)("div",{className:"d-flex flex-wrap gap-2",children:(0,D.jsx)(f.A,{variant:"danger",size:"sm",disabled:d,onClick:T,children:d?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(A.A,{animation:"border",size:"sm",className:"me-2"}),"Reconnecting\u2026"]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("i",{className:"feather icon-refresh-cw me-1"}),"Reconnect"]})})})]})})}),F&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ie.A,{className:"shadow-sm mb-4 "+(s?"bg-dark border-secondary":""),children:(0,D.jsx)(ie.A.Body,{children:(0,D.jsxs)("div",{className:"d-flex flex-wrap align-items-start gap-2",children:[(0,D.jsxs)("div",{className:"flex-grow-1 min-w-0",children:[(0,D.jsx)("div",{className:"fw-semibold "+(s?"text-white":""),children:n.site_name||n.site_id||"Wix Site"}),n.site_id&&(0,D.jsxs)("div",{className:"small "+(s?"text-white-50":"text-muted"),children:["Site ID: ",n.site_id]}),(0,D.jsx)("div",{className:"d-flex flex-wrap gap-2 mt-2",children:(0,D.jsx)(pe.A,{bg:"success",className:"bg-opacity-75",children:"Connected"})}),n.last_error&&(0,D.jsxs)("div",{className:"alert alert-danger small py-2 mt-2 mb-0 d-flex flex-wrap align-items-center gap-2",children:[(0,D.jsxs)("div",{className:"flex-grow-1",children:[(0,D.jsx)("i",{className:"feather icon-alert-circle me-2"}),n.last_error]}),(0,D.jsxs)(f.A,{size:"sm",variant:"danger",onClick:T,disabled:d,children:[(0,D.jsx)("i",{className:"feather icon-refresh-cw me-1"}),"Reconnect"]})]}),n.connected_at&&(0,D.jsxs)("div",{className:"small mt-1 "+(s?"text-white-50":"text-muted"),children:["Connected: ",Ue(n.connected_at)]})]}),(0,D.jsxs)("div",{className:"d-flex flex-wrap gap-2",children:[g&&(0,D.jsxs)("span",{className:"small text-success align-self-center",children:[(0,D.jsx)("i",{className:"feather icon-check me-1"}),"Backfill queued"]}),(0,D.jsx)(f.A,{variant:"outline-secondary",size:"sm",disabled:x,onClick:()=>{v(!0),b(!1),w.LF.backfill().then(()=>{b(!0),setTimeout(()=>b(!1),4e3)}
1).catch(()=>{}).finally(()=>v(!1))},title:"Re-import historical orders",children:x?(0,D.jsx)(A.A,{animation:"border",size:"sm"}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("i",{className:"feather icon-refresh-cw me-1"}),"Backfill"]})}),(0,D.jsxs)(f.A,{variant:"outline-danger",size:"sm",onClick:()=>y(!0),children:[(0,D.jsx)("i",{className:"feather icon-trash-2 me-1"}),"Disconnect"]})]})]})})}),(0,D.jsxs)(ie.A,{className:"shadow-sm "+(s?"bg-dark border-secondary":""),children:[(0,D.jsxs)(ie.A.Header,{className:"d-flex align-items-center justify-content-between "+(s?"bg-transparent border-secondary":""),children:[(0,D.jsxs)("span",{className:"fw-semibold small "+(s?"text-white":""),children:[(0,D.jsx)("i",{className:"feather icon-target me-2"}),"Recent events"]}),(0,D.jsx)(f.A,{variant:"link",size:"sm",className:"p-0 text-muted",onClick:P.reload,disabled:P.loading,title:"Refresh events",children:(0,D.jsx)("i",{className:"feather icon-refresh-cw"+(P.loading?" fa-spin":"")})})]}),(0,D.jsx)(ie.A.Body,{className:"p-0",children:(0,D.jsx)(Re,{events:P.results,loading:P.loading,isDarkMode:s,pagination:P})})]})]}),(0,D.jsxs)(p.A,{show:j,onHide:()=>{y(!1),S(null)},centered:!0,size:"sm",children:[(0,D.jsx)(p.A.Header,{closeButton:!0,children:(0,D.jsx)(p.A.Title,{className:"fs-6",children:"Disconnect Wix?"})}),(0,D.jsxs)(p.A.Body,{className:"small",children:[(0,D.jsx)("p",{children:"This will stop receiving Wix purchase webhooks. Historical events will be preserved."}),k&&(0,D.jsx)("div",{className:"text-danger",children:k})]}),(0,D.jsxs)(p.A.Footer,{children:[(0,D.jsx)(f.A,{variant:"secondary",size:"sm",onClick:()=>{y(!1),S(null)},children:"Cancel"}),(0,D.jsx)(f.A,{variant:"danger",size:"sm",disabled:N,onClick:()=>{_(!0),S(null),w.LF.disconnect().then(()=>{y(!1),C(),t&&t()}).catch(e=>{var s,t;const a=(null===e||void 0===e||null===(s=e.response)||void 0===s||null===(t=s.data)||void 0===t?void 0:t.detail)||"Failed to disconnect Wix";S(a)}).finally(()=>_(!1))},children:N?(0,D.jsx)(A.A,{animation:"border",size:"sm"}):"Disconnect"})]})]})]})},Ke=e=>{let{code:s,title:t,titleIcon:a=null,itemId:n,copiedItem:i,copyToClipboard:l}=e;return(0,D.jsxs)("div",{className:"rounded overflow-hidden border w-100",children:[(0,D.jsxs)("div",{className:"d-flex justify-content-between align-items-center px-3 py-2 bg-secondary",children:[(0,D.jsxs)("span",{className:"small fw-medium text-white d-inline-flex align-items-center gap-2",children:[(0,D.jsx)("i",{className:"fas fa-code",style:{fontSize:"1rem"}}),a&&(0,D.jsx)("span",{className:"d-inline-flex align-items-center",children:a}),(0,D.jsx)("span",{children:t})]}),(0,D.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[i===n&&(0,D.jsx)("span",{className:"copy-toast",children:"Copied!"}),(0,D.jsxs)("button",{type:"button",onClick:()=>l(s,n),className:"btn btn-sm btn-outline-light",children:[(0,D.jsx)("i",{className:"feather icon-copy me-1"}),"Copy"]})]})]}),(0,D.jsx)("pre",{className:"p-0 m-0 overflow-auto w-100",style:{fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',fontSize:"0.875rem",backgroundColor:"inherit"},children:(0,D.jsx)("code",{className:"d-block p-4",children:s})})]})},qe="#7952b3",Ge=e=>{if(!e)return null;try{return new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}},Ve=e=>{let{connectionId:s,show:t,onHide:n,isDarkMode:i}=e;const[l,r]=(0,a.useState)(null),[o,c]=(0,a.useState)(!1),[d,m]=(0,a.useState)(null);(0,a.useEffect)(()=>{t&&s&&(c(!0),w.Xf.getSnippet(s).then(e=>{var s;return r(null!==(s=null===e||void 0===e?void 0:e.data)&&void 0!==s?s:null)}).catch(()=>r(null)).finally(()=>c(!1)))},[t,s]);const h=(e,s)=>{navigator.clipboard.writeText(e).then(()=>{m(s),setTimeout(()=>m(null),2e3)})};return(0,D.jsxs)(p.A,{show:t,onHide:n,size:"lg",centered:!0,children:[(0,D.jsx)(p.A.Header,{closeButton:!0,className:i?"bg-dark text-white border-secondary":"",children:(0,D.jsxs)(p.A.Title,{className:"fs-6",children:[(0,D.jsx)("i",{className:"fas fa-code me-2",style:{color:qe}}),"WooCommerce Pixel Snippet"]})}),(0,D.jsxs)(p.A.Body,{className:i?"bg-dark":"",children:[o&&(0,D.jsxs)("div",{className:"text-center py-4",children:[(0,D.jsx)(A.A,{animation:"border",size:"sm",className:"me-2"}),(0,D.jsx)("span",{className:i?"text-white-50":"text-muted",children:"Loading snippet\u2026"})]}),!o&&!l&&(0,D.jsx)("div",{className:"text-center py-4 small "+(i?"text-white-50":"text-muted"),children:"No snippet available"}),!o&&l&&(0,D.jsxs)("div",{className:"d-flex flex-column gap-3",children:[(0,D.jsx)("p",{className:"small mb-0 "+(i?"text-white-50":"text-muted"),children:"Add this snippet to your WooCommerce theme to enable purchase event tracking."}),l.php_snippet&&(0,D.jsx)(Ke,{code:l.php_snippet,title:"PHP \u2014 add to functions.php or mu-plugin",itemId:"wc-php",copiedItem:d,copyToClipboard:h}),l.js_snippet&&(0,D.jsx)(Ke,{code:l.js_snippet,title:"JS \u2014 paste before </head>",itemId:"wc-js",copiedItem:d,copyToClipboard:h})]})]}),(0,D.jsx)(p.A.Footer,{className:i?"bg-dark border-secondary":"",children:(0,D.jsx)(f.A,{variant:"secondary",size:"sm",onClick:n,children:"Close"})})]})},Qe=e=>{var s;
1let{connection:t,onDisconnect:n,isDarkMode:i}=e;const[l,r]=(0,a.useState)(!1),[o,c]=(0,a.useState)(!1),[d,m]=(0,a.useState)(!1),[h,u]=(0,a.useState)(!1),[x,p]=(0,a.useState)(!1),v=!!t.unavailable_at||!1===t.is_active,g=null!==(s=t.ecommerce_connection_id)&&void 0!==s?s:t.id,b=ve((0,a.useCallback)((e,s)=>w.xo.getEvents({provider:"woocommerce",connectionId:g,page:e,pageSize:s}),[g]),{pageSize:25,auto:h});return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ie.A,{className:"shadow-sm "+(i?"bg-dark border-secondary":""),children:(0,D.jsxs)(ie.A.Body,{children:[(0,D.jsxs)("div",{className:"d-flex flex-wrap align-items-start gap-2",children:[(0,D.jsxs)("div",{className:"flex-grow-1 min-w-0",children:[(0,D.jsx)("div",{className:"fw-semibold "+(i?"text-white":""),children:t.site_name||t.store_url}),t.site_name&&t.store_url&&(0,D.jsxs)("div",{className:"small "+(i?"text-white-50":"text-muted"),children:[(0,D.jsx)("i",{className:"feather icon-globe me-1"}),t.store_url]}),(0,D.jsx)("div",{className:"d-flex flex-wrap gap-2 mt-2",children:(0,D.jsx)(pe.A,{bg:v?"danger":"success",className:"bg-opacity-75",children:v?!1===t.is_active?"Needs reconnect":"Unavailable":"Active"})}),(t.last_error||v)&&(0,D.jsxs)("div",{className:"alert alert-danger small py-2 mt-2 mb-0 d-flex flex-wrap align-items-center gap-2",children:[(0,D.jsxs)("div",{className:"flex-grow-1",children:[(0,D.jsx)("i",{className:"feather icon-alert-circle me-2"}),t.last_error||"This store has been unreachable."]}),(0,D.jsx)(f.A,{size:"sm",variant:"danger",onClick:()=>{p(!0),w.xo.reconnect(g).then(e=>{var s;const t=null===e||void 0===e||null===(s=e.data)||void 0===s?void 0:s.next_step;"oauth"===(null===t||void 0===t?void 0:t.flow)&&t.oauth_url?window.location.href=t.oauth_url:window.scrollTo({top:0,behavior:"smooth"})}).catch(()=>(0,N.UW)("Reconnect failed","Please try again or contact support.")).finally(()=>p(!1))},disabled:x,children:x?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(A.A,{size:"sm",animation:"border",className:"me-1"}),"Reconnecting\u2026"]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("i",{className:"feather icon-refresh-cw me-1"}),"Reconnect"]})})]}),t.created_at&&(0,D.jsxs)("div",{className:"small mt-1 "+(i?"text-white-50":"text-muted"),children:["Connected: ",Ge(t.created_at)]})]}),(0,D.jsxs)("div",{className:"d-flex flex-wrap gap-2",children:[o&&(0,D.jsxs)("span",{className:"small text-success align-self-center",children:[(0,D.jsx)("i",{className:"feather icon-check me-1"}),"Backfill queued"]}),(0,D.jsxs)(f.A,{variant:"outline-secondary",size:"sm",onClick:()=>m(!0),title:"View tracking snippet",children:[(0,D.jsx)("i",{className:"fas fa-code me-1"}),"Snippet"]}),(0,D.jsx)(f.A,{variant:"outline-secondary",size:"sm",disabled:l,onClick:()=>{r(!0),w.Xf.backfillConnection(t.id).then(()=>{c(!0),setTimeout(()=>c(!1),4e3)}).catch(()=>{}).finally(()=>r(!1))},title:"Re-import historical orders",children:l?(0,D.jsx)(A.A,{animation:"border",size:"sm"}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("i",{className:"feather icon-refresh-cw me-1"}),"Backfill"]})}),(0,D.jsxs)(f.A,{variant:"outline-primary",size:"sm",onClick:()=>u(e=>!e),children:[(0,D.jsx)("i",{className:`feather ${h?"icon-chevron-up":"icon-list"} me-1`}),"Events"]}),(0,D.jsxs)(f.A,{variant:"outline-danger",size:"sm",onClick:()=>n(t),children:[(0,D.jsx)("i",{className:"feather icon-trash-2 me-1"}),"Disconnect"]})]})]}),h&&(0,D.jsx)("div",{className:"mt-3 border-top pt-3",children:(0,D.jsx)(Re,{events:b.results,loading:b.loading,isDarkMode:i,pagination:b})})]})}),(0,D.jsx)(Ve,{connectionId:t.id,show:d,onHide:()=>m(!1),isDarkMode:i})]})},Ye=e=>{let{isDarkMode:s=!1,onConnect:t,onConnectionsChanged:n}=e;const[i,l]=(0,a.useState)([]),[r,o]=(0,a.useState)(!0),[c,d]=(0,a.useState)(null),[m,h]=(0,a.useState)(null),[u,x]=(0,a.useState)(!1),[v,g]=(0,a.useState)(null),b=(0,a.useCallback)(()=>{o(!0),d(null),w.Xf.getConnections().then(e=>{var s,t,a;const n=null!==(s=null!==(t=null===e||void 0===e||null===(a=e.data)||void 0===a?void 0:a.results)&&void 0!==t?t:null===e||void 0===e?void 0:e.data)&&void 0!==s?s:[];l(Array.isArray(n)?n:[])}).catch(()=>d("Failed to load WooCommerce connections")).finally(()=>o(!1))},[]);(0,a.useEffect)(()=>{b()},[b]),Ae("woocommerce",{onConnectionChange:b});return r?(0,D.jsxs)("div",{className:"d-flex align-items-center justify-content-center p-5",children:[(0,D.jsx)(A.A,{animation:"border",size:"sm",className:"me-2"}),(0,D.jsx)("span",{className:s?"text-white-50":"text-muted",children:"Loading WooCommerce connections\u2026"})]}):(0,D.jsxs)("div",{className:"p-3",children:[(0,D.jsxs)("div",{className:"d-flex align-items-center gap-3 mb-4",children:[(0,D.jsx)("img",{src:E,alt:"WooCommerce",style:{width:48,height:48,borderRadius:8,flexShrink:0,objectFit:"contain"}}),(0,D.jsxs)("div",{children:[(0,D.jsx)("h5",{className:"mb-0 fw-bold "+(s?"text-white":""),children:"WooCommerce"}),(0,D.jsx)("div",{className:"small "+(s?"text-white-50":"text-muted"),children:"Connect one or more WooCommerce stores to capture purchase webhooks."})]})]}),c&&(0,D.jsx)("div",{className:"alert alert-warning small py-2 mb-3",children:c}),i.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"d-flex align-items-center justify-content-between mb-3",children:[(0,D.jsxs)("h6",{className:"mb-0 fw-semibold "+(s?"text-white":""),children:["Connected stores ",(0,D.jsx)(pe.A,{bg:"success",className:"ms-1",children:i.length})]}),t&&(0,D.jsxs)(f.A,{variant:"outline-primary",size:"sm",onClick:()=>t("woocommerce"),children:[(0,D.jsx)("i",{className:"feather icon-plus me-1"}),"Add store"]})]}),(0,D.jsx)("div",{className:"d-flex flex-column gap-3",children:i.map(e=>(0,D.jsx)(Qe,{connection:e,onDisconnect:h,isDarkMode:s},e.id))})]}),!r&&0===i.length&&(0,D.jsx)(ie.A,{className:"shadow-sm "+(s?"bg-dark border-secondary":""),children:(0,D.jsxs)(ie.A.Body,{className:"text-center py-5",children:[(0,D.jsx)("i",{className:"feather icon-shopping-cart mb-3",style:{fontSize:"2.5rem",color:qe,display:"block"}}),(0,D.jsx)("h6",{className:"mb-2 "+(s?"text-white":""),children:"No WooCommerce store connected"}),(0,D.jsx)("p",{className:"small mb-4 "+(s?"text-white-50":"text-muted"),style:{maxWidth:380,margin:"0 auto 1rem"},children:"Connect with your store's REST API keys, or authorise automatically from your WooCommerce admin."}),t&&(0,D.jsxs)(f.A,{variant:"primary",onClick:()=>t("woocommerce"),children:[(0,D.jsx)("i",{className:"feather icon-link me-2"}),"Connect WooCommerce Store"]})]})}),(0,D.jsxs)(p.A,{show:Boolean(m),onHide:()=>{h(null),g(null)},centered:!0,size:"sm",children:[(0,D.jsx)(p.A.Header,{closeButton:!0,children:(0,D.jsx)(p.A.Title,{className:"fs-6",children:"Disconnect store?"})}),(0,D.jsxs)(p.A.Body,{className:"small",children:[(0,D.jsxs)("p",{children:["This will disconnect ",(0,D.jsx)("strong",{children:(null===m||void 0===m?void 0:m.site_name)||(null===m||void 0===m?void 0:m.store_url)||"the store"})," and stop receiving new webhooks. Historical events will be preserved."]}),v&&(0,D.jsx)("div",{className:"text-danger",children:v})]}),(0,D.jsxs)(p.A.Footer,{children:[(0,D.jsx)(f.A,{variant:"secondary",size:"sm",onClick:()=>{h(null),g(null)},children:"Cancel"}),(0,D.jsx)(f.A,{variant:"danger",size:"sm",disabled:u,onClick:()=>{m&&(x(!0),g(null),w.Xf.disconnectConnection(m.id).then(()=>{h(null),b(),n&&n()}).catch(e=>{var s,t;const a=(null===e||void 0===e||null===(s=e.response)||void 0===s||null===(t=s.data)||void 0===t?void 0:t.detail)||"Failed to disconnect";g(a)}).finally(()=>x(!1)))},children:u?(0,D.jsx)(A.A,{animation:"border",size:"sm"}):"Disconnect"})]})]})]})},Xe=e=>{let{activeTab:s,onTabChange:t,onConnect:a,onConnectionsChanged:n,connections:i,connectionsLoading:l,isDarkMode:r}=e;const o={isDarkMode:r,onConnect:a,onConnectionsChanged:n};return"shopify"===s?(0,D.jsx)(Oe,{...o}):"wix"===s?(0,D.jsx)(He,{isDarkMode:r,onConnectionsChanged:n}):"woocommerce"===s?(0,D.jsx)(Ye,{...o}):"products"===s?(0,D.jsx)(Ce,{isDarkMode:r}):"customers"===s?(0,D.jsx)(je,{isDarkMode:r}):(0,D.jsx)(xe,{onTabChange:t,onConnect:a,connections:i,connectionsLoading:l,isDarkMode:r})};Xe.defaultProps={activeTab:"overview",connections:[],connectionsLoading:!1,isDarkMode:!1};const Je=Xe,Ze={getSites(e){const s=e?`?provider=${encodeURIComponent(e)}`:"";return(0,y.qQ)(`/sites/${s}`)},disconnectSite:e=>(0,y.tX)(`/sites/${e}/`)},es={healthy:{variant:"success",label:"Healthy"},stale:{variant:"warning",label:"Stale"},pending:{variant:"secondary",label:"Pending"},disconnected:{variant:"danger",label:"Disconnected"}},ss={wordpress:{label:"WordPress",icon:"feather icon-code"},wix:{label:"Wix",icon:"feather icon-layout"}},ts=e=>ss[e]||{label:e||"Website",icon:"feather icon-globe"},as=e=>{let{isDarkMode:s}=e;const t=s?"text-white-50":"text-muted",[n,i]=(0,a.useState)([]),[l,r]=(0,a.useState)(!0),[o,c]=(0,a.useState)(""),[d,m]=(0,a.useState)(null),h=(0,a.useCallback)(async()=>{r(!0),c("");try{const e=await Ze.getSites();i(Array.isArray(e.data)?e.data:[])}catch{c("Could not load your connected sites.")}finally{r(!1)}},[]);(0,a.useEffect)(()=>{h()}
1,[h]);const u=()=>(0,D.jsxs)("div",{className:`small ${t} mt-3`,style:{maxWidth:640},children:[(0,D.jsx)("p",{className:"mb-1 fw-semibold",children:"Connect a website"}),(0,D.jsxs)("p",{className:"mb-2",children:[(0,D.jsx)("strong",{children:"WordPress"})," \u2014 install the ",(0,D.jsx)("strong",{children:"LinkClicks Universal Pixel"})," plugin (Plugins \u2192 Add New), then ",(0,D.jsx)("em",{children:"Settings \u2192 LinkClicks \u2192 Connect"})," and approve here. Running WooCommerce? Click ",(0,D.jsx)("strong",{children:"Enable order tracking"})," to sync purchases too."]}),(0,D.jsxs)("p",{className:"mb-2",children:[(0,D.jsx)("strong",{children:"Wix"})," \u2014 add the LinkClicks app from the Wix App Market, or use"," ",(0,D.jsx)("em",{children:"Connections \u2192 E-Commerce \u2192 Connect"}),". The pixel installs itself; if the site has a Wix Stores shop, order tracking turns on automatically."]}),(0,D.jsxs)("p",{className:"mb-0",children:["Anything else \u2014 copy the Universal Pixel snippet from"," ",(0,D.jsx)("em",{children:"Connections \u2192 Universal Pixel"})," onto every page."]})]});return l?(0,D.jsxs)("div",{className:"p-4 text-center",children:[(0,D.jsx)(A.A,{animation:"border",size:"sm"})," ",(0,D.jsx)("span",{className:"ms-2",children:"Loading connected sites\u2026"})]}):(0,D.jsxs)("div",{className:"p-3",children:[(0,D.jsxs)("div",{className:"d-flex align-items-center justify-content-between mb-3",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h5",{className:"mb-1",children:"Connected Websites"}),(0,D.jsx)("p",{className:`small ${t} mb-0`,children:"Sites running the Universal Pixel, with or without a store."})]}),(0,D.jsxs)(f.A,{variant:"outline-secondary",size:"sm",onClick:h,children:[(0,D.jsx)("i",{className:"feather icon-refresh-cw me-1"})," Refresh"]})]}),o&&(0,D.jsx)("div",{className:"alert alert-danger py-2 small",role:"alert",children:o}),0===n.length?(0,D.jsxs)("div",{className:"text-center py-4",children:[(0,D.jsx)("div",{className:"d-inline-flex align-items-center justify-content-center mb-3",style:{width:56,height:56,borderRadius:"50%",background:s?"rgba(59,130,246,0.12)":"rgba(59,130,246,0.09)"},children:(0,D.jsx)("i",{className:"feather icon-globe",style:{color:s?"#f97316":"#3b82f6",fontSize:"1.5rem"}})}),(0,D.jsx)("h6",{className:"mb-2",children:"No websites connected yet"}),u()]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"table-responsive",children:(0,D.jsxs)("table",{className:"table table-sm align-middle",children:[(0,D.jsx)("thead",{children:(0,D.jsxs)("tr",{className:`small ${t}`,children:[(0,D.jsx)("th",{children:"Site"}),(0,D.jsx)("th",{children:"Platform"}),(0,D.jsx)("th",{children:"Status"}),(0,D.jsx)("th",{children:"Order tracking"}),(0,D.jsx)("th",{children:"Version"}),(0,D.jsx)("th",{children:"Last check-in"}),(0,D.jsx)("th",{className:"text-end",children:"Actions"})]})}),(0,D.jsx)("tbody",{children:n.map(e=>{const s=es[e.health]||es.pending,a=ts(e.provider);return(0,D.jsxs)("tr",{children:[(0,D.jsx)("td",{style:{wordBreak:"break-all"},children:e.site_url}),(0,D.jsxs)("td",{className:"small",children:[(0,D.jsx)("i",{className:`${a.icon} me-1`}),a.label]}),(0,D.jsx)("td",{children:(0,D.jsx)(pe.A,{bg:s.variant,children:s.label})}),(0,D.jsx)("td",{children:e.order_tracking_connected?(0,D.jsxs)(pe.A,{bg:"success",children:[(0,D.jsx)("i",{className:"feather icon-shopping-cart me-1"}),"On"]}):(0,D.jsx)("span",{className:`small ${t}`,children:"Off"})}),(0,D.jsx)("td",{className:"small",children:e.plugin_version||e.platform_version||"\u2014"}),(0,D.jsx)("td",{className:"small",children:e.last_verified_at?new Date(e.last_verified_at).toLocaleString():"\u2014"}),(0,D.jsx)("td",{className:"text-end",children:(0,D.jsx)(f.A,{variant:"outline-danger",size:"sm",onClick:()=>(async e=>{const{label:s}=ts(e.provider);if(window.confirm(`Disconnect this ${s} site? The pixel will stop tracking on its next check-in.`)){m(e.id);try{await Ze.disconnectSite(e.id),i(s=>s.filter(s=>s.id!==e.id))}catch{c("Could not disconnect that site. Please try again.")}finally{m(null)}}})(e),disabled:d===e.id,children:d===e.id?"Disconnecting\u2026":"Disconnect"})})]},e.id)})})]})}
1),u()]})]})};as.defaultProps={isDarkMode:!1};const ns=as,is=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"YOUR_PIXEL_KEY";return`\x3c!-- LinkClicks Universal Pixel --\x3e\n<script data-cfasync="false">window.lk=window.lk||function(){(window.lk.q=window.lk.q||[]).push(arguments)};<\/script>\n<script async data-cfasync="false" src="${"https://pixel.linkclicks.com".replace(/\/$/,"")}/pixel/${e}.js"><\/script>\n\x3c!-- End LinkClicks Universal Pixel --\x3e`},ls=is,rs=e=>{let{pixelKey:s,onEmailInstructions:t,onScanComplete:n,onViewFullResults:i}=e;const[l,r]=(0,a.useState)(!1),[o,c]=(0,a.useState)(null),[d,m]=(0,a.useState)(""),[h,u]=(0,a.useState)(null),[x,p]=(0,a.useState)(!1);return(0,D.jsxs)("div",{className:"p-3",children:[(0,D.jsx)("div",{className:"alert alert-info",style:{backgroundColor:"rgba(13, 71, 161, 0.18)",borderColor:"rgba(30, 136, 229, 0.35)",color:"inherit"},role:"alert",children:(0,D.jsxs)("div",{className:"d-flex align-items-start gap-2",children:[(0,D.jsx)("i",{className:"feather icon-info text-info mt-1"}),(0,D.jsxs)("div",{className:"flex-grow-1",children:[(0,D.jsx)("h6",{className:"alert-heading",children:"Installation"}),(0,D.jsx)("p",{className:"small mb-0",children:"Add this code to the <head> section of every page on your website"}),l&&(0,D.jsxs)("div",{className:"mt-3 small",children:[(0,D.jsx)("div",{className:"fw-semibold mb-1",children:"Universal Pixel Full Instructions"}),(0,D.jsx)("p",{className:"mb-2",style:{opacity:.9},children:"Use this checklist for first-time installation."}),(0,D.jsxs)("ol",{className:"ps-3 mb-0",style:{opacity:.9},children:[(0,D.jsx)("li",{children:"Copy the Universal Pixel Code below."}),(0,D.jsx)("li",{children:"Open your website template or global header settings."}),(0,D.jsx)("li",{children:"Paste the code inside the <head> section on all pages."}),(0,D.jsx)("li",{children:"Publish/deploy your site changes."}),(0,D.jsx)("li",{children:"Visit your website once to confirm page-view tracking starts."}),(0,D.jsx)("li",{children:"For conversions like purchases or signups, add separate event snippets in the Events tab."})]})]})]}),(0,D.jsxs)("div",{className:"d-flex gap-2 flex-shrink-0 align-items-center",style:{whiteSpace:"nowrap"},children:[(0,D.jsx)("button",{type:"button",className:"btn btn-sm btn-outline-secondary",onClick:()=>r(e=>!e),children:l?"Hide instructions":"Full Instructions"}),t&&(0,D.jsxs)("button",{type:"button",className:"btn btn-sm btn-outline-primary",onClick:()=>t("base","",s),children:[(0,D.jsx)("i",{className:"feather icon-mail me-1"}),"Email instructions"]})]})]})}),(0,D.jsx)(Ke,{code:ls(s),title:"Universal Pixel Code",itemId:`pixel-${s}`,copiedItem:o,copyToClipboard:async(e,s)=>{try{await navigator.clipboard.writeText(e),c(s),setTimeout(()=>c(null),2e3)}catch{}}}),(0,D.jsxs)("div",{className:"border rounded p-3 mt-4",children:[(0,D.jsxs)("div",{className:"mb-3",children:[(0,D.jsx)("h6",{className:"mb-1",children:"Test Pixel Installation"}),(0,D.jsx)("p",{className:"text-muted small mb-0",children:"Check a live website for the universal pixel, confirm the expected key is present, and inspect any mismatch or load issues."})]}),(0,D.jsxs)("div",{className:"row g-2 align-items-end",children:[(0,D.jsxs)("div",{className:"col-md-8",children:[(0,D.jsx)(v.A.Label,{className:"small text-muted mb-1",children:"URL to test"}),(0,D.jsx)(v.A.Control,{type:"url",placeholder:"https://yourwebsite.com/page-to-test",value:d,onChange:e=>m(e.target.value),disabled:x})]}),(0,D.jsx)("div",{className:"col-md-4",children:(0,D.jsx)("button",{type:"button",className:"btn btn-primary w-100 btn-sm",onClick:()=>(async e=>{if(e&&e.startsWith("http")){p(!0),u(null);try{var t;const l=await(0,y.Ku)("/conversions/test/pixel-installation/",{url:e,pixel_key:s});if(null!==(t=l.data)&&void 0!==t&&t.success){const e={success:!0,message:l.data.message,details:l.data.details};u(e),n&&n(e)}else{var a,i;const e={success:!1,message:(null===(a=l.data)||void 0===a?void 0:a.message)||"Pixel not detected",details:(null===(i=l.data)||void 0===i?void 0:i.details)||{}};u(e),n&&n(e)}}catch(o){let e="Failed to test pixel installation",s={};var l,r;o.response?(e=(null===(l=o.response.data)||void 0===l?void 0:l.message)||e,s=(null===(r=o.response.data)||void 0===r?void 0:r.details)||{}):o.request&&(e="Network error - unable to reach testing service",s={issues:["Connection timeout or network error"],suggestions:["Check your internet connection and try again"]});const t={success:!1,message:e,details:s};u(t),n&&n(t)}finally{p(!1)}}else u({success:!1,message:"Please enter a valid URL starting with http:// or https://"})})(d),disabled:x||!d.trim(),children:x?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Testing..."]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("i",{className:"feather icon-search me-2"}),"Test URL"]})})})]}),(0,D.jsx)("div",{className:"alert mt-3 mb-0",style:{backgroundColor:"rgba(13, 71, 161, 0.18)",borderColor:"rgba(30, 136, 229, 0.35)",color:"inherit"},role:"alert",children:(0,D.jsxs)("div",{className:"small mb-0",children:[(0,D.jsx)("strong",{children:"Recommended flow:"}
1)," install the base code, load the page, trigger one or two real actions, then run the URL test to confirm the correct pixel key is detected."]})}),(()=>{var e,s;if(!h)return null;const t=h.details||{},a=t.server_diagnostics||{},n=t.page_analysis||{},l=t.headless_tests||[],r=n.trackers_found||[],o=a.response_time_ms?a.response_time_ms<500?"#22c55e":a.response_time_ms<2e3?"#f59e0b":"#ef4444":"#94a3b8",c={borderTop:"1px solid rgba(148,163,184,0.15)",fontSize:"0.78rem",padding:"4px 0",display:"flex",gap:8,alignItems:"flex-start"},d={flexShrink:0,width:130,color:"#94a3b8"};return(0,D.jsxs)("div",{className:"rounded p-3 mt-3 border "+(h.success?"border-success":"border-danger"),style:{background:h.success?"rgba(34,197,94,0.04)":"rgba(239,68,68,0.04)"},children:[(0,D.jsxs)("div",{className:"d-flex align-items-start gap-2 mb-2",children:[(0,D.jsx)("i",{className:`feather ${h.success?"icon-check-circle":"icon-x-circle"} mt-1`,style:{color:h.success?"#22c55e":"#ef4444",fontSize:"1rem",flexShrink:0}}),(0,D.jsxs)("div",{className:"flex-grow-1",children:[(0,D.jsx)("div",{className:"fw-semibold",style:{fontSize:"0.88rem"},children:h.message}),(0,D.jsxs)("div",{className:"text-muted d-flex align-items-center gap-2 flex-wrap",style:{fontSize:"0.74rem"},children:[t.last_checked&&new Date(t.last_checked).toLocaleString(),void 0!==t.recent_events_24h&&(0,D.jsxs)("span",{className:"badge bg-secondary",children:[t.recent_events_24h," events / 24h"]})]})]})]}),(n.title||n.favicon_url)&&(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2 py-1 mb-1",style:{borderTop:"1px solid rgba(148,163,184,0.15)"},children:[n.favicon_url&&(0,D.jsx)("img",{src:n.favicon_url,alt:"",width:16,height:16,style:{borderRadius:3,objectFit:"contain",flexShrink:0},onError:e=>{e.currentTarget.style.display="none"}}),(0,D.jsx)("span",{className:"fw-medium",style:{fontSize:"0.82rem"},children:n.title||"\u2014"})]}),l.length>0&&(0,D.jsxs)("div",{className:"d-flex flex-wrap gap-2 py-1",style:{borderTop:"1px solid rgba(148,163,184,0.15)",fontSize:"0.76rem"},children:[(0,D.jsx)("span",{className:"text-muted",style:{flexShrink:0},children:"Browser tests:"}),l.map((e,s)=>(0,D.jsxs)("span",{style:{color:e.events_found>0?"#22c55e":"#ef4444"},children:[(0,D.jsx)("i",{className:`feather ${e.events_found>0?"icon-check-circle":"icon-x-circle"} me-1`,style:{fontSize:"0.75rem"}}),e.ua_type," ",e.events_found>0?`(${e.events_found} event)`:"(no event)"]},s))]}),a.server_ip&&(0,D.jsxs)("div",{style:c,children:[(0,D.jsx)("span",{style:d,children:"Server"}),(0,D.jsxs)("span",{children:[a.server_ip,(a.geo_city||a.geo_country)&&(0,D.jsxs)("span",{className:"text-muted ms-2",children:[(u=a.geo_country,u?u.toUpperCase().replace(/./g,e=>String.fromCodePoint(e.charCodeAt(0)+127397)):"")," ",[a.geo_city,a.geo_country].filter(Boolean).join(", ")]}),a.server_software&&(0,D.jsxs)("span",{className:"text-muted ms-2",children:["\xb7 ",a.server_software]}),a.cdn_provider&&(0,D.jsxs)("span",{className:"text-muted ms-2",children:["\xb7 ",a.cdn_provider]})]})]}),null!=a.response_time_ms&&(0,D.jsxs)("div",{style:c,children:[(0,D.jsx)("span",{style:d,children:"Performance"}),(0,D.jsxs)("span",{children:[(0,D.jsx)("span",{style:{color:o},children:(m=a.response_time_ms,m<1e3?`${m}ms`:`${(m/1e3).toFixed(1)}s`)}),void 0!==a.https&&(0,D.jsx)("span",{className:"ms-2",children:a.https?"\ud83d\udd12 HTTPS":"\u26a0\ufe0f HTTP"}),a.compression&&"none"!==a.compression&&(0,D.jsxs)("span",{className:"text-muted ms-2",children:["\xb7 ",a.compression]})]})]}),r.length>0&&(0,D.jsxs)("div",{style:c,children:[(0,D.jsx)("span",{style:d,children:"Trackers found"}),(0,D.jsx)("div",{className:"d-flex flex-wrap gap-1",children:r.map(e=>(0,D.jsx)("span",{className:"badge rounded-pill bg-secondary",style:{fontSize:"0.68rem",fontWeight:400},children:e},e))})]}),!h.success&&(null===(e=t.issues)||void 0===e?void 0:e.length)>0&&(0,D.jsxs)("div",{className:"mt-2 small",children:[(0,D.jsx)("div",{className:"fw-semibold mb-1",style:{color:"#ef4444"},children:"Issues detected"}),(0,D.jsx)("ul",{className:"mb-1 ps-3",children:t.issues.map((e,s)=>(0,D.jsx)("li",{children:e},s))})]}),!h.success&&(null===(s=t.suggestions)||void 0===s?void 0:s.length)>0&&(0,D.jsxs)("div",{className:"small",children:[(0,D.jsx)("div",{className:"fw-semibold mb-1",children:"Suggestions"}),(0,D.jsx)("ul",{className:"mb-0 ps-3",children:t.suggestions.map((e,s)=>(0,D.jsx)("li",{children:e},s))})]}),(0,D.jsx)("div",{className:"mt-2 text-muted",style:{fontSize:"0.73rem"},children:i?(0,D.jsxs)("button",{type:"button",className:"btn btn-link p-0 border-0 text-muted",style:{fontSize:"0.73rem",textDecoration:"underline",verticalAlign:"baseline"},onClick:i,children:["Full scan details are on the ",(0,D.jsx)("strong",{children:"Test Pixel"})," tab."]}):(0,D.jsxs)(D.Fragment,{children:["Full scan details are on the ",(0,D.jsx)("strong",{children:"Test Pixel"})," tab."]})})]});var m,u})(),(0,D.jsx)("div",{className:"mt-3 d-flex align-items-start justify-content-between gap-3 flex-wrap",children:(0,D.jsxs)("small",{style:{opacity:.7},children:[(0,D.jsx)("i",{className:"feather icon-info me-1"}),"You can run the same installation check here immediately after copying the code, or use the Test Pixel tab for the full health view."]})})]})]})};var os=t(89007);const cs=[{id:"ecommerce",name:"E-Commerce",description:"Online retail and product sales",icon:"feather icon-shopping-cart",events:["purchase","add_to_cart","view_content","add_to_wishlist","search","initiate_checkout","add_payment_info"]},{id:"saas-subscriptions",name:"SaaS / Subscriptions",description:"Recurring revenue funnels and trial-to-paid journeys",icon:"feather icon-refresh-cw",events:["start_trial","complete_registration","subscribe","lead","view_content"]},{id:"app-publisher",name:"App Publisher",description:"Mobile app acquisition and post-install c
1onversion flows",icon:"feather icon-smartphone",events:["app_install","complete_registration","start_trial","subscribe","purchase","view_content"]},{id:"lead-gen",name:"Lead Gen",description:"Lead capture and form submissions",icon:"feather icon-users",events:["lead","contact","complete_registration","view_content","search"]},{id:"finance",name:"Finance",description:"Financial services and investment journeys",icon:"feather icon-trending-up",events:["lead","contact","add_payment_info","complete_registration","view_content"]},{id:"real-estate",name:"Real Estate",description:"Property discovery and agent inquiries",icon:"feather icon-home",events:["schedule","lead","view_content","contact","find_location"]},{id:"education",name:"Education",description:"Course signups and program applications",icon:"feather icon-book-open",events:["lead","complete_registration","submit_application","download","view_content"]},{id:"healthcare-beauty",name:"Healthcare & Beauty",description:"Appointment bookings and wellness conversions",icon:"feather icon-heart",events:["schedule","contact","find_location","lead","view_content"]},{id:"travel",name:"Travel",description:"Travel discovery and booking funnels",icon:"feather icon-map-pin",events:["search","view_content","initiate_checkout","purchase","contact","find_location"]}],ds=(cs.map(e=>({id:e.id,label:e.name,icon:e.icon,events:[...e.events]})),[...cs.map(e=>({id:e.id,name:e.name,description:e.description,icon:e.icon,events:[...e.events]})),{id:"all",name:"All Events",description:"Choose your own events",events:["add_payment_info","app_install","add_to_cart","add_to_wishlist","application_approval","click_button","complete_registration","contact","customize_product","download","find_location","initiate_checkout","lead","place_an_order","purchase","schedule","search","start_trial","submit_application","subscribe","view_content"]}]),ms=e=>{let{show:s,onHide:t,eventToDelete:a,onConfirmDelete:n,pixelName:i,isRemoving:l=!1}=e;const r=i||"this pixel";return(0,D.jsxs)(p.A,{show:s,onHide:t,centered:!0,children:[(0,D.jsxs)("div",{className:"modal-header",children:[(0,D.jsxs)("h5",{className:"modal-title",children:[(0,D.jsx)("i",{className:"feather icon-trash text-danger me-2"}),"Remove Conversion Event"]}),(0,D.jsx)("button",{type:"button",className:"btn-close","aria-label":"Close",onClick:t})]}),(0,D.jsx)(p.A.Body,{children:(0,D.jsxs)("div",{className:"text-center py-3",children:[(0,D.jsx)("div",{className:"mb-3",children:(0,D.jsx)("i",{className:"feather icon-alert-triangle text-warning",style:{fontSize:"3rem"}})}),(0,D.jsxs)("h5",{children:['Remove "',null===a||void 0===a?void 0:a.name,'" from ',r,"?"]}),(0,D.jsxs)("p",{className:"text-muted mb-4",children:["This removes the event from ",r,". It will no longer appear in this pixel's configuration or code snippets."]}),(0,D.jsxs)("div",{className:"delete-event-info-box border rounded p-3 mb-3 text-start",children:[(0,D.jsxs)("div",{className:"d-flex align-items-start gap-2 mb-2",children:[(0,D.jsx)("i",{className:"feather icon-check-circle text-success mt-1 flex-shrink-0"}),(0,D.jsxs)("span",{className:"small text-body",children:[(0,D.jsx)("strong",{children:"Tracking continues."})," If this event is already firing on your website, it will still be received and recorded \u2014 removing it here does not break any live tracking."]})]}),(0,D.jsxs)("div",{className:"d-flex align-items-start gap-2 mb-2",children:[(0,D.jsx)("i",{className:"feather icon-check-circle text-success mt-1 flex-shrink-0"}),(0,D.jsxs)("span",{className:"small text-body",children:[(0,D.jsx)("strong",{children:"Data is retained."})," All historical data for this event under this pixel is kept on the server as long as your pixel exists. Deleting the pixel would remove the data."]})]}),(0,D.jsxs)("div",{className:"d-flex align-items-start gap-2",children:[(0,D.jsx)("i",{className:"feather icon-info text-muted mt-1 flex-shrink-0"}),(0,D.jsxs)("span",{className:"small text-muted",children:["Conversion events in the UI are for ",(0,D.jsx)("strong",{children:"configuring and generating tracking codes"}),". You can re-add this event to this pixel at any time."]})]})]})]})}),(0,D.jsxs)(p.A.Footer,{className:"border-top",children:[(0,D.jsx)(f.A,{variant:"outline-secondary",onClick:t,children:"Cancel"}),(0,D.jsx)(f.A,{variant:"danger",onClick:n,disabled:l,children:l?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Removing..."]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("i",{className:"feather icon-trash me-2"}),"Remove Event"]})})]})]})};var hs=t(11219),us=t(2352);const xs={pixel_created:{icon:"feather icon-plus-circle",color:"#6c757d",bg:"rgba(108,117,125,0.12)"},name_updated:{icon:"feather icon-edit-2",color:"#4680ff",bg:"rgba(70,128,255,0.12)"},event_added:{icon:"feather icon-plus",color:"#2dcc71",bg:"rgba(45,204,113,0.12)"},event_updated:{icon:"feather icon-edit",color:"#2dcc71",bg:"rgba(45,204,113,0.12)"},event_deleted:{icon:"feather icon-trash-2",color:"#e74c3c",bg:"rgba(231,76,60,0.12)"},platform_connected:{icon:"feather icon-link",color:"#17a2b8",bg:"rgba(23,162,184,0.12)"},platform_updated:{icon:"feather icon-settings",color:"#17a2b8",bg:"rgba(23,162,184,0.12)"},platform_removed:{icon:"feather icon-link-2",color:"#e74c3c",bg:"rgba(231,76,60,0.12)"},status_changed:{icon:"feather icon-toggle-right",color:"#f39c12",bg:"rgba(243,156,18,0.12)"},settings_updated:{icon:"feather icon-sliders",color:"#9b59b6",bg:"rgba(155,89,182,0.12)"}},ps=(0,D.jsxs)("div",{className:"p-4 text-center",children:[(0,D.jsx)("i",{className:"feather icon-clock",style:{fontSize:32,opacity:.3}}),(0,D.jsx)("p",{className:"text-muted small mt-2 mb-0",children:"No changes recorded yet."}),(0,D.jsx)("p",{className:"text-muted small",children:"Actions like renaming the pixel, adding events, or connecting a platform will appear here."})]}),vs=e=>{let{pixelKey:s}=e;const[t,n]=(0,a.useState)(!0),[i,l]=(0,a.useState)([]),[r,o]=(0,a.useState)(null);return(0,a.useEffect)(()=>{s&&(n(!0),o(null),(0,y.qQ)(`/conversions/pixels/${s}/changelog/`).then(e=>l(e.data.changelog||[])).catch(()=>o("Could not load change history.")).finally(()=>n(!1)))},[s]),t?(0,D.jsxs)("div",{className:"text-center py-5",children:[(0,D.jsx)("div",{className:"spinner-border text-primary mb-3",role:"status","aria-hidden":"true"}),(0,D.jsx)("p",{className:"text-muted small",children:"Loading change history\u2026"})]}):r?(0,D.jsx)("div",{className:"p-4 text-center text-muted small",children:r}):(0,D.jsxs)("div",{className:"p-3",children:[i.length>0&&(0,D.jsx)("h6",{className:"mb-3",children:"Pixel Change History"}
1),(0,D.jsx)(us.A,{entries:i,actionMeta:xs,timeAgo:hs.fF,emptyState:ps})]})};var fs=t(73501),gs=t(95942),bs=t(65513);const js="/conversions/domains/",ys=e=>{let{text:s}=e;const[t,n]=(0,a.useState)(!1);return(0,D.jsx)(f.A,{variant:"outline-secondary",size:"sm",onClick:()=>{navigator.clipboard.writeText(s).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},style:{whiteSpace:"nowrap"},children:t?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("i",{className:"feather icon-check me-1"}),"Copied"]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("i",{className:"feather icon-copy me-1"}),"Copy"]})})},Ns=e=>e?new Date(e).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"\u2014",_s=e=>{let{show:s,existingDomain:t,ownedDomains:n,pixelKey:i,onHide:l,onSaved:r,onVerified:o}=e;const[c,d]=(0,a.useState)(1),[m,h]=(0,a.useState)("dns"),[u,x]=(0,a.useState)(""),[p,g]=(0,a.useState)(null),[b,j]=(0,a.useState)(!1),[_,w]=(0,a.useState)(""),[k,S]=(0,a.useState)(!1),[C,z]=(0,a.useState)(null),[T,F]=(0,a.useState)(null);(0,a.useEffect)(()=>{s&&(t?(g(t),d(2),z("verified"===t.status?"verified":null),F(null)):(d(1),h("dns"),x(""),g(null),z(null),F(null)))},[s,t]);const E=async()=>{if(!p)return;const e=Date.now();try{S(!0),z(null),F(null);const s=(await(0,y.Ku)(`${js}${p.id}/verify/`,{pixel_key:i})).data,t=Date.now()-e;"verified"===s.status?((0,N.LG)(`${s.domain} verified successfully!`),g(s),z("verified"),F(t),o(s)):z("failed")}catch{z("failed")}finally{S(!1)}},L=p?`linkclicks-verify=${p.verification_token}`:"";return(0,D.jsxs)(Y.A,{show:s,onHide:l,placement:"end",backdrop:!0,className:"am-drawer",style:{width:"500px"},children:[(0,D.jsx)(Y.A.Header,{closeButton:!0,children:(0,D.jsxs)(Y.A.Title,{children:[(0,D.jsx)("i",{className:"feather icon-globe me-2"}),1===c?"Add Domain":"verified"===C?"Domain Verified":"Verify Domain"]})}),(0,D.jsxs)(Y.A.Body,{children:[1===c&&(0,D.jsxs)(D.Fragment,{children:[n.length>0&&(0,D.jsxs)(P.A,{variant:"tabs",activeKey:m,onSelect:e=>h(e),className:"mb-3",children:[(0,D.jsx)(P.A.Item,{children:(0,D.jsx)(P.A.Link,{eventKey:"dns",children:"Verify via DNS"})}),(0,D.jsx)(P.A.Item,{children:(0,D.jsx)(P.A.Link,{eventKey:"owned",children:"Add owned domain"})})]}),"dns"===m&&(0,D.jsxs)(v.A,{onSubmit:async e=>{e.preventDefault();const s=u.trim().toLowerCase();if(s)try{j(!0);const e=(await(0,y.Ku)(js,{domain:s})).data;g(e),r(e),d(2)}catch(o){var t,a,n,i,l;const e=(null===o||void 0===o||null===(t=o.response)||void 0===t||null===(a=t.data)||void 0===a||null===(n=a.domain)||void 0===n?void 0:n[0])||(null===o||void 0===o||null===(i=o.response)||void 0===i||null===(l=i.data)||void 0===l?void 0:l.detail)||"Failed to add domain";(0,N.UW)(e)}finally{j(!1)}},children:[(0,D.jsx)("p",{className:"text-muted mb-4",children:"Enter the domain where your pixel is installed. You will then be shown a DNS TXT record to add to your domain to prove ownership."}),(0,D.jsxs)(v.A.Group,{className:"mb-3",children:[(0,D.jsx)(v.A.Label,{children:"Domain"}),(0,D.jsx)(v.A.Control,{type:"text",placeholder:"e.g. example.com",value:u,onChange:e=>x(e.target.value),required:!0,autoFocus:!0,disabled:b}),(0,D.jsx)(v.A.Text,{className:"text-muted",children:"Enter the bare domain without https:// or www."})]}),(0,D.jsx)(f.A,{type:"submit",variant:"primary",disabled:b||!u.trim(),children:b?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(A.A,{animation:"border",size:"sm",className:"me-2"}),"Adding\u2026"]}):"Continue"})]}),"owned"===m&&(0,D.jsxs)("div",{children:[(0,D.jsx)("p",{className:"text-muted mb-3",children:"Add a domain you registered through us \u2014 we already know you own it, so no DNS record is needed."}),(0,D.jsx)("div",{className:"d-flex flex-column gap-2",children:n.map(e=>(0,D.jsxs)(f.A,{variant:"outline-primary",className:"d-flex align-items-center justify-content-between",onClick:()=>(async e=>{w(e);try{const s=(await(0,y.Ku)(`${js}add-owned/`,{domain:e,pixel_key:i})).data;r(s),g(s),z("verified"),F(null),d(2),(0,N.LG)(`${s.domain} added`)}catch(a){var s,t;(0,N.UW)((null===a||void 0===a||null===(s=a.response)||void 0===s||null===(t=s.data)||void 0===t?void 0:t.detail)||"Failed to add domain")}finally{w("")}})(e),disabled:!!_,children:[(0,D.jsxs)("span",{children:[(0,D.jsx)("i",{className:"feather icon-globe me-2"}),e]}),_===e?(0,D.jsx)(A.A,{animation:"border",size:"sm"}):(0,D.jsx)("i",{className:"feather icon-plus"})]},e))})]})]}),2===c&&p&&(0,D.jsxs)(D.Fragment,{children:[k&&(0,D.jsxs)("div",{className:"dns-check-anim",children:[(0,D.jsxs)("div",{className:"dns-check-anim__rings",children:[(0,D.jsx)("div",{className:"dns-check-anim__ring dns-check-anim__ring--1"}),(0,D.jsx)("div",{className:"dns-check-anim__ring dns-check-anim__ring--2"}),(0,D.jsx)("div",{className:"dns-check-anim__ring dns-check-anim__ring--3"}),(0,D.jsx)("div",{className:"dns-check-anim__icon",children:(0,D.jsx)("i",{className:"feather icon-shield"})})]}),(0,D.jsx)("p",{className:"dns-check-anim__label",children:"Scanning DNS records\u2026"}),(0,D.jsxs)("p",{className:"dns-check-anim__sub text-muted",children:["Querying TXT records for ",(0,D.jsx)("strong",{children:p.domain})]})]}),!k&&"verified"===C&&(0,D.jsxs)("div",{className:"dns-result dns-result--verified",children:[(0,D.jsxs)("div",{className:"dns-result__icon-wrap",children:[(0,D.jsx)("div",{className:"dns-result__glow"}),(0,D.jsxs)("div",{className:"dns-result__icon",children:[(0,D.jsx)("i",{className:"feather icon-shield"}),(0,D.jsx)("div",{className:"dns-result__check",children:(0,D.jsx)("i",{className:"feather icon-check"})})]})]}),(0,D.jsx)("h5",{className:"dns-result__title",children:"Domain Verified"}),(0,D.jsxs)("p",{className:"dns-result__desc",children:[(0,D.jsx)("strong",{children:p.domain})," is verified and trusted by LinkClicks."]}),(0,D.jsxs)("div",{className:"dns-verify-meta",children:[p.verified_at&&(0,D.jsxs)("div",{className:"dns-verify-meta__row",children:[(0,D.jsxs)("span",{className:"dns-verify-meta__label",children:[(0,D.jsx)("i",{className:"feather icon-check-circle"}),"Verified"]}),(0,D.jsx)("span",{className:"dns-verify-meta__value",children:Ns(p.verified_at)})]}),(0,D.jsxs)("div",{className:"dns-verify-meta__row",children:[(0,D.jsxs)("span",{className:"dns-verify-meta__label",children:[(0,D.jsx)("i",{className:"feather icon-calendar"}),"Domain added"]}),(0,D.jsx)("span",{className:"dns-verify-meta__value",children:Ns(p.created_at)})]}),p.last_checked_at&&(0,D.jsxs)("div",{className:"dns-verify-meta__row",children:[(0,D.jsxs)("span",{className:"dns-verify-meta__label",children:[(0,D.jsx)("i",{className:"feather icon-clock"}),"Last checked"]}),(0,D.jsx)("span",{className:"dns-verify-meta__value",children:Ns(p.last_checked_at)})]}),null!=T&&(0,D.jsxs)("div",{className:"dns-verify-meta__row",children:[(0,D.jsxs)("span",{className:"dns-verify-meta__label",children:[(0,D.jsx)("i",{className:"feather icon-zap"}),"Check completed in"]}),(0,D.jsx)("span",{className:"dns-verify-meta__value",children:($=T,null==$?"\u2014":$<1e3?`${$}ms`:`${($/1e3).toFixed(1)}s`)})]})]}),(0,D.jsx)("p",{className:"dns-result__sub text-muted small",children:"Your pixel events are cryptographically linked to this domain. We can now confirm that tracked events originate from your property."}),(0,D.jsxs)(f.A,{variant:"primary",className:"mt-1",onClick:l,children:[(0,D.jsx)("i",{className:"feather icon-check me-2"}),"Done"]})]}),!k&&"failed"===C&&(0,D.jsxs)("div",{className:"dns-result dns-result--pending",children:[(0,D.jsx)("div",{className:"dns-result__icon-wrap",children:(0,D.jsx)("div",{className:"dns-result__icon",children:(0,D.jsx)("i",{className:"feather icon-clock"})})}),(0,D.jsx)("h5",{className:"dns-result__title",children:"Record Not Found Yet"}),(0,D.jsxs)("p",{className:"dns-result__desc",children:["The TXT record wasn't detected on"," ",(0,D.jsx)("strong",{children:p.domain}),". This is usually just a propagation delay."]}),(0,D.jsx)("div",{className:"dns-info-callout alert small mb-4",role:"alert",children:(0,D.jsxs)("div",{className:"d-flex align-items-start gap-2",children:[(0,D.jsx)("i",{className:"feather icon-info mt-1"}),(0,D.jsx)("div",{children:"DNS changes can take a few minutes to a few hours to propagate. Wait 10\u201315 minutes then try again."})]})}),(0,D.jsxs)("div",{className:"d-flex gap-2 justify-content-center flex-wrap",children:[(0,D.jsxs)(f.A,{variant:"primary",onClick:E,children:[(0,D.jsx)("i",{className:"feather icon-refresh-cw me-2"}),"Try Again"]}),(0,D.jsx)(f.A,{variant:"outline-secondary",onClick:()=>
1z(null),children:"Back to Instructions"})]})]}),!k&&!C&&(0,D.jsxs)("div",{children:[(0,D.jsxs)("p",{className:"text-muted mb-4",children:["Add the following DNS TXT record to"," ",(0,D.jsx)("strong",{children:p.domain})," through your domain registrar or DNS provider, then click ",(0,D.jsx)("strong",{children:"Check DNS"}),"."]}),(0,D.jsxs)("div",{className:"border rounded p-3 mb-4",children:[(0,D.jsxs)("div",{className:"mb-3",children:[(0,D.jsx)("div",{className:"text-muted small fw-semibold mb-1",children:"Record Type"}),(0,D.jsx)("div",{className:"d-flex align-items-center gap-2",children:(0,D.jsx)("code",{className:"flex-grow-1",children:"TXT"})})]}),(0,D.jsxs)("div",{className:"mb-3",children:[(0,D.jsx)("div",{className:"text-muted small fw-semibold mb-1",children:"Name / Host"}),(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2",children:[(0,D.jsx)("code",{className:"flex-grow-1",children:"@ (root domain)"}),(0,D.jsx)(ys,{text:"@"})]})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"text-muted small fw-semibold mb-1",children:"Value"}),(0,D.jsxs)("div",{className:"d-flex align-items-start gap-2",children:[(0,D.jsx)("code",{className:"flex-grow-1 d-block p-2 rounded dns-record-value",style:{wordBreak:"break-all",fontSize:"0.85rem"},children:L}),(0,D.jsx)(ys,{text:L})]})]})]}),(0,D.jsx)("div",{className:"dns-info-callout alert small mb-4",role:"alert",children:(0,D.jsxs)("div",{className:"d-flex align-items-start gap-2",children:[(0,D.jsx)("i",{className:"feather icon-info mt-1"}),(0,D.jsxs)("div",{children:[(0,D.jsx)("strong",{children:"DNS changes can take a few minutes to a few hours to propagate."})," ","If the check fails, wait 10\u201315 minutes and try again."]})]})}),(0,D.jsxs)("div",{className:"d-flex gap-2",children:[(0,D.jsxs)(f.A,{variant:"primary",onClick:E,children:[(0,D.jsx)("i",{className:"feather icon-check-circle me-2"}),"Check DNS"]}),(0,D.jsx)(f.A,{variant:"outline-secondary",onClick:l,children:"Close"})]})]})]})]})]});var $};_s.defaultProps={ownedDomains:[],pixelKey:null};const ws=_s,ks="/conversions/domains/",Ss=e=>{let{pixelKey:s,onPixelChanged:t}=e;const[n,i]=(0,a.useState)([]),[l,r]=(0,a.useState)(!0),[o,c]=(0,a.useState)(!1),[d,m]=(0,a.useState)(null),[h,u]=(0,a.useState)(null),[x,v]=(0,a.useState)([]),g=(0,a.useCallback)(async()=>{try{r(!0);const e=await(0,y.qQ)(ks);i(e.data||[])}catch{(0,N.UW)("Failed to load verified domains")}finally{r(!1)}},[]),b=(0,a.useCallback)(async()=>{try{var e,s,t;const a=await(0,y.qQ)("/domains/"),n=null!==(e=null!==(s=null===(t=a.data)||void 0===t?void 0:t.results)&&void 0!==s?s:a.data)&&void 0!==e?e:[];v(n.filter(e=>"active"===e.status).map(e=>e.domain_name).filter(Boolean))}catch{v([])}},[]);(0,a.useEffect)(()=>{g(),b()},[g,b]);const j=new Set(n.map(e=>(e.domain||"").toLowerCase())),_=x.filter(e=>!j.has(e.toLowerCase()));return(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"d-flex align-items-center justify-content-between mb-3 gap-2 flex-wrap",children:[(0,D.jsx)("p",{className:"text-muted small mb-0",children:"Confirm the domains you own \u2014 verify one with a DNS TXT record, or add a domain you registered through us."}),(0,D.jsxs)(f.A,{variant:"primary",size:"sm",className:"flex-shrink-0",onClick:()=>c(!0),children:[(0,D.jsx)("i",{className:"feather icon-plus me-2"}),"Add Domain"]})]}),l?(0,D.jsxs)("div",{className:"py-3 text-center",children:[(0,D.jsx)(A.A,{animation:"border",size:"sm",className:"me-2"}),"Loading domains\u2026"]}):(0,D.jsx)("div",{className:"d-flex flex-column gap-2",children:n.map(e=>{return(0,D.jsxs)("div",{className:"border rounded p-3 d-flex align-items-center justify-content-between flex-wrap gap-2",children:[(0,D.jsxs)("div",{className:"d-flex align-items-center gap-3",children:[(0,D.jsx)("i",{className:"feather icon-globe text-muted",style:{fontSize:"1.1rem"}}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"fw-semibold",children:e.domain}),(0,D.jsxs)("div",{className:"text-muted small",children:["Added ",new Date(e.created_at).toLocaleDateString(),e.verified_at&&` \xb7 Verified ${new Date(e.verified_at).toLocaleDateString()}`]})]})]}),(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2",children:["verified"!==e.status&&(s=e.status,"verified"===s?(0,D.jsx)(pe.A,{bg:"success",children:"Verified"}
1):"pending"===s?(0,D.jsx)(pe.A,{bg:"warning",text:"dark",children:"Pending"}):(0,D.jsx)(pe.A,{bg:"danger",children:"Failed"})),"verified"===e.status?(0,D.jsxs)(f.A,{variant:"success",size:"sm",onClick:()=>c(e),children:[(0,D.jsx)("i",{className:"feather icon-shield me-1"}),"Verified"]}):(0,D.jsx)(f.A,{variant:"outline-primary",size:"sm",onClick:()=>c(e),children:"pending"===e.status?"Continue Setup":"Retry"}),(0,D.jsx)(f.A,{variant:"outline-danger",size:"sm",disabled:d===e.id,onClick:()=>u({id:e.id,domain:e.domain}),children:d===e.id?(0,D.jsx)(A.A,{animation:"border",size:"sm"}):(0,D.jsx)("i",{className:"feather icon-trash-2"})})]})]},e.id);var s})}),(0,D.jsx)(ws,{show:!!o,existingDomain:"object"===typeof o?o:null,ownedDomains:_,pixelKey:s,onHide:()=>c(!1),onSaved:e=>{i(s=>s.find(s=>s.id===e.id)?s.map(s=>s.id===e.id?e:s):[e,...s]),"verified"===(null===e||void 0===e?void 0:e.status)&&t&&t()},onVerified:e=>{(e=>{i(s=>s.map(s=>s.id===e.id?e:s)),"verified"===(null===e||void 0===e?void 0:e.status)&&t&&t()})(e)}}),(0,D.jsxs)(p.A,{show:!!h,onHide:()=>u(null),centered:!0,children:[(0,D.jsx)(p.A.Header,{closeButton:!0,children:(0,D.jsx)(p.A.Title,{children:"Remove Domain"})}),(0,D.jsxs)(p.A.Body,{children:["Remove ",(0,D.jsx)("strong",{children:null===h||void 0===h?void 0:h.domain})," from your verified domains?"," ","You will need to re-verify it if you add it again."]}),(0,D.jsxs)(p.A.Footer,{children:[(0,D.jsx)(f.A,{variant:"outline-secondary",onClick:()=>u(null),children:"Cancel"}),(0,D.jsx)(f.A,{variant:"danger",onClick:async()=>{if(!h)return;const{id:e,domain:s}=h;u(null);try{m(e),await(0,y.tX)(`${ks}${e}/`),(0,N.LG)(`${s} removed`),i(s=>s.filter(s=>s.id!==e))}catch{(0,N.UW)("Failed to remove domain")}finally{m(null)}},children:"Remove"})]})]})]})};Ss.defaultProps={pixelKey:null,onPixelChanged:null};const Cs=Ss,As=e=>{let{platform:s,accounts:t,boundAccount:n,onSelect:i,disabled:l}=e;const[r,o]=(0,a.useState)(!1),c=t||[];if(c.length<2)return null;const d=c.find(e=>e.is_selected)||null,m=n||d,h=m?m.account_name||m.account_id||"Unnamed account":"No account selected",u=async e=>{if(!r){o(!0);try{await i(s,e)}finally{o(!1)}}};return(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2 mb-3 flex-wrap",children:[(0,D.jsx)("span",{className:"small text-muted",style:{whiteSpace:"nowrap"},children:"Ad account:"}),(0,D.jsxs)(x.A,{children:[(0,D.jsx)(x.A.Toggle,{variant:"outline-secondary",size:"sm",disabled:l||r,id:`ad-account-${s}`,style:{fontSize:"0.75rem",maxWidth:260,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r?"Saving\u2026":h}),(0,D.jsxs)(x.A.Menu,{className:"pixel-switcher-menu",style:{maxHeight:320,overflowY:"auto"},children:[c.map(e=>(0,D.jsx)(x.A.Item,{active:Boolean(n)&&n.authorization_id===e.authorization_id,onClick:()=>u(e.authorization_id),children:(0,D.jsxs)("div",{className:"d-flex flex-column",children:[(0,D.jsx)("span",{children:e.account_name||e.account_id||"Unnamed account"}),e.account_name&&e.account_id&&(0,D.jsx)("span",{className:"text-muted",style:{fontSize:"0.7rem"},children:e.account_id})]})},e.authorization_id)),n&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(x.A.Divider,{}),(0,D.jsx)(x.A.Item,{onClick:()=>u(null),children:(0,D.jsx)("span",{className:"small",children:"Use my selected account"})})]})]})]}),!n&&m&&(0,D.jsx)("span",{className:"small text-muted",style:{fontSize:"0.7rem"},children:"(following your selected account)"})]})};As.defaultProps={accounts:[],boundAccount:null,disabled:!1};const Ps=As;var zs=t(55596);t(24798);const Ts={purchase:"Purchase",appinstall:"AppInstall",addtocart:"AddToCart",initiatecheckout:"InitiateCheckout",addpaymentinfo:"AddPaymentInfo",viewcontent:"ViewContent",search:"Search",addtowishlist:"AddToWishlist",lead:"Lead",completeregistration:"CompleteRegistration",signup:"SignUp",subscribe:"Subscribe",contact:"Contact",submitapplication:"SubmitApplication",pageview:"PageView",viewitem:"ViewItem",clickbutton:"ClickButton",download:"Download",share:"Share",customconversion:"CustomConversion"},Fs={purchase:"PURCHASE",appinstall:"APP_INSTALL",addtocart:"ADD_TO_CART",lead:"LEAD",signup:"SIGNUP",completeregistration:"SIGNUP",subscribe:"SUBSCRIBE",pageview:"PAGE_VIEW",viewcontent:"PAGE_VIEW",viewitem:"PAGE_VIEW",contact:"CONTACT",submitapplication:"SUBMIT_LEAD_FORM",download:"DOWNLOAD"};function Es(e){return e&&"string"===typeof e?e.toLowerCase().trim().replace(/[^a-z0-9]/g,""):""}function Ls(e){if(!e)return"";const s=Es(e);return Ts[s]?Ts[s]:e.trim()}function Ds(e){if(!e)return"DEFAULT";const s=Es(e);if(Fs[s])return Fs[s];const t=s;return t.includes("purchase")||t.includes("order")||t.includes("buy")?"PURCHASE":t.includes("app")&&t.includes("install")?"APP_INSTALL":t.includes("lead")?"LEAD":t.includes("signup")||t.includes("register")?"SIGNUP":t.includes("page")||t.includes("view")?"PAGE_VIEW":t.includes("cart")?"ADD_TO_CART":"DEFAULT"}
1function $s(e,s){if(!e||!Array.isArray(s))return null;const t=Es(e);return s.find(e=>Es(e.name)===t)||null}t(56211),t(57227);var Is=t(46304),Rs=t(64),Ms=t(8086),Bs=t(99065),Ws=t(76562),Os=t(17949),Us=t(52029),Hs=t(94602);t(20664);const Ks=(e,s)=>Math.floor(Math.random()*(s-e+1))+e,qs=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const s=String((arguments.length>1&&void 0!==arguments[1]?arguments[1]:"")||"").trim();if(!s)return"";const t=(e||[]).find(e=>String((null===e||void 0===e?void 0:e.id)||"").trim()===s),a=String((null===t||void 0===t?void 0:t.name)||"").trim();return a&&a!==s?a:s},Gs=e=>String(e||"").toLowerCase().replace(/[^a-z0-9]/g,""),Vs=e=>e?String(e.event_name||e.event_key||e.id||e.name||"").trim():"",Qs=e=>String(e||"").split(/\s+/).map(e=>e.trim()).filter(Boolean).filter(e=>/^[a-zA-Z0-9_-]+$/.test(e)).join(" "),Ys={brand:{label:"Brand",description:"The product or business brand tied to this conversion. Useful when you want reporting grouped around the brand being promoted."},content_category:{label:"Category",description:"The category the item belongs to, such as shoes, software, or subscriptions. Helps platforms understand what type of product or service was involved."},content_id:{label:"Item ID",description:"The unique ID for the product, service, or offer that was viewed or purchased. This is commonly used for catalog matching and attribution."},content_name:{label:"Item Name",description:"A readable name for the product, plan, or offer. This makes reporting easier to understand for non-technical users."},content_type:{label:"Item Type",description:"A broad type such as product, service, or package. Ad platforms can use this to better classify the conversion event."},currency:{label:"Currency",description:"The currency code for the conversion value, such as USD or EUR. Needed when you send revenue or price information."},description:{label:"Description",description:"Extra context about the item or action. This is optional, but it can make debugging and internal reporting clearer."},event_id:{label:"Event Reference",description:"A unique ID for this specific event occurrence. Helps prevent duplicates and makes troubleshooting easier."},price:{label:"Unit Price",description:"The price of a single item before totals are calculated. Useful when you want line-item level pricing details."},num_items:{label:"Quantity",description:"How many items were included in the conversion. Helpful for basket size and order analysis."},search_string:{label:"Search Query",description:"The term the user searched for before converting. Useful for search-driven reporting and optimization."},status:{label:"Status",description:"The outcome or state of the conversion, such as pending, approved, or completed."},value:{label:"Order Value",description:"The total value of the conversion. This is one of the most important fields for revenue reporting and optimization."},email:{label:"Email Address",description:"The customer email used for identity matching. Platforms typically expect this to be normalized and hashed before sending."},phone:{label:"Phone Number",description:"The customer phone number for identity matching. This can improve match rates when available and properly formatted."},external_id:{label:"Customer ID",description:"Your internal customer or lead identifier. Helpful for matching conversions back to the same person across systems."}},Xs=e=>{var s;return null!==(s=Ys[e])&&void 0!==s&&s.label?Ys[e].label:String(e||"").split("_").filter(Boolean).map(e=>{const s=e.toLowerCase();return"id"===s?"ID":"url"===s?"URL":s.charAt(0).toUpperCase()+s.slice(1)}).join(" ")},Js=e=>{let{param:s,index:t,paramType:a,selectedEvent:n,updateMainEventParameter:i,getParameterFieldMeta:l}=e;
1const r=l(null===s||void 0===s?void 0:s.name),o=`${"eventParams"===a?"event":"user"}-param-${n}-${t}`,c=`${o}-tooltip`;return(0,D.jsx)("div",{className:"eventParams"===a?"col-12 col-sm-6 col-lg-6":"col-12 col-md-6 col-lg-6",children:(0,D.jsx)(v.A.Group,{children:(0,D.jsxs)("div",{className:"checkbox d-inline-flex align-items-center gap-2 checkbox-fill checkbox-primary",children:[(0,D.jsx)(v.A.Control,{type:"checkbox",id:o,checked:Boolean(null===s||void 0===s?void 0:s.checked),onChange:e=>i(n,a,t,e.target.checked)}),(0,D.jsx)(v.A.Label,{htmlFor:o,className:"cr small mb-0",children:r.label}),(0,D.jsx)(fs.A,{placement:"top",overlay:(0,D.jsx)(gs.A,{id:c,children:(0,D.jsxs)("div",{className:"text-start",children:[(0,D.jsx)("div",{className:"fw-semibold mb-1",children:r.label}),(0,D.jsx)("div",{children:r.description})]})}),children:(0,D.jsx)("button",{type:"button","aria-label":`About ${r.label}`,className:"btn btn-link text-muted d-inline-flex align-items-center justify-content-center p-0 border-0 shadow-none",style:{cursor:"help",lineHeight:1,textDecoration:"none"},onClick:e=>{e.preventDefault(),e.stopPropagation()},children:(0,D.jsx)("i",{className:"feather icon-info",style:{fontSize:"0.78rem"}})})})]})})})},Zs=function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e=>(null===e||void 0===e?void 0:e.name)||(null===e||void 0===e?void 0:e.id)||"";const a=e&&e.trim()?e.trim():"LinkClicks Universal Pixel",n=new Set(s.map(e=>(t(e)||"").trim()).filter(Boolean));if(!n.has(a))return a;let i=2;for(;n.has(`${a} ${i}`);)i+=1;return`${a} ${i}`},et=e=>((null===e||void 0===e?void 0:e.name)||(null===e||void 0===e?void 0:e.pixel_name)||(null===e||void 0===e?void 0:e.id)||"").replace(/\s*\(.*\)$/,""),st=(e,s)=>{var t,a,n;const i=null===e||void 0===e||null===(t=e.response)||void 0===t?void 0:t.data;return i&&(i.detail||(null===(a=i.error)||void 0===a?void 0:a.error_user_msg)||(null===(n=i.error)||void 0===n?void 0:n.message)||i.error)||s},tt=e=>{let{pixelKey:s}=e;const[t,n]=(0,a.useState)(!0),[i,l]=(0,a.useState)(null),[r,o]=(0,a.useState)(!1),[c,d]=(0,a.useState)(null),[m,h]=(0,a.useState)([]),[u,x]=(0,a.useState)([]),[p,v]=(0,a.useState)(!1),f=(0,a.useCallback)(()=>{s&&(n(!0),l(null),(0,y.qQ)(`/conversions/pixels/${s}/origins/?window=30`).then(e=>{h(e.data.allowed_origins||[]),x(e.data.origins||[]),v(Boolean(e.data.enforcing))}).catch(()=>l("Could not load domain settings.")).finally(()=>n(!1)))},[s]);(0,a.useEffect)(()=>{f()},[f]);const g=async e=>{o(!0),d(null);try{await(0,y.patchWithToken)(`/conversions/pixels/${s}/`,{allowed_origins:e}),h(e),f()}catch{d("Could not save changes. Please try again.")}finally{o(!1)}};return t?(0,D.jsxs)("div",{className:"text-center py-5",children:[(0,D.jsx)("div",{className:"spinner-border text-primary mb-3",role:"status","aria-hidden":"true"}),(0,D.jsx)("p",{className:"text-muted small",children:"Loading domain settings..."})]}):i?(0,D.jsx)("div",{className:"p-4 text-center text-muted small",children:i}):(0,D.jsxs)("div",{className:"p-3",children:[(0,D.jsx)(Cs,{pixelKey:s,onPixelChanged:f}),(0,D.jsx)("hr",{className:"my-4"}),m.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("h6",{className:"mb-2",children:"Allowed Domains"}),(0,D.jsx)("p",{className:"text-muted small mb-3",children:"Only let these domains send events to this pixel \u2014 this stops someone pasting your snippet onto their own site. Approve domains from the observed list below. Leave empty to allow any domain (the default)."})]}),(0,D.jsxs)("div",{className:`alert ${p?"alert-success":"alert-warning"} d-flex align-items-center gap-2 small`,role:"alert",children:[(0,D.jsx)("i",{className:"feather "+(p?"icon-shield":"icon-alert-triangle")}),p?"Enforcement is ON for this account \u2014 traffic from domains not on this list is blocked.":"Enforcement is currently OFF account-wide \u2014 domains not on this list are only logged, never blocked."]}),c&&(0,D.jsx)("div",{className:"alert alert-danger small",children:c}),(0,D.jsxs)("div",{className:"mb-4",children:[0===m.length?(0,D.jsx)("div",{className:"text-muted small",children:"No domains configured \u2014 this pixel currently accepts events from anywhere."}):(0,D.jsx)("div",{className:"d-flex flex-wrap gap-2",children:m.map(e=>(0,D.jsxs)("span",{className:"badge bg-light text-dark border d-flex align-items-center gap-2",style:{fontSize:"0.85rem",padding:"6px 10px",fontWeight:500},children:[e,(0,D.jsx)("button",{type:"button",className:"btn btn-sm p-0 border-0 text-muted",onClick:()=>(e=>{g(m.filter(s=>s!==e))})(e),disabled:r,"aria-label":`Remove ${e}`,style:{lineHeight:1},children:(0,D.jsx)("i",{className:"feather icon-x",style:{fontSize:"0.8rem"}})})]},e))}),(0,D.jsxs)("div",{className:"text-muted small mt-1",children:["Allowing a domain al
1so allows its subdomains (e.g."," ",(0,D.jsx)("code",{style:{color:"inherit",background:"none",padding:0},children:"example.com"})," allows"," ",(0,D.jsx)("code",{style:{color:"inherit",background:"none",padding:0},children:"shop.example.com"}),")."]})]}),(0,D.jsxs)("h6",{className:"mb-2",children:["Observed Domains ",(0,D.jsx)("span",{className:"text-muted fw-normal",children:"(last 30 days)"})]}),0===u.length?(0,D.jsx)("div",{className:"text-muted small",children:"No events recorded yet in this window."}):(0,D.jsx)("div",{className:"table-responsive",children:(0,D.jsxs)("table",{className:"table table-sm align-middle",children:[(0,D.jsx)("thead",{children:(0,D.jsxs)("tr",{children:[(0,D.jsx)("th",{children:"Domain"}),(0,D.jsx)("th",{className:"text-end",children:"Events"}),(0,D.jsx)("th",{className:"text-end",children:"Status"}),(0,D.jsx)("th",{})]})}),(0,D.jsx)("tbody",{children:u.map(e=>(0,D.jsxs)("tr",{children:[(0,D.jsx)("td",{children:e.host}),(0,D.jsx)("td",{className:"text-end",children:Number(e.events||0).toLocaleString()}),(0,D.jsx)("td",{className:"text-end",children:e.allowed?(0,D.jsx)("span",{className:"badge bg-success-subtle text-success",children:"Allowed"}):(0,D.jsx)("span",{className:"badge bg-danger-subtle text-danger",children:p?"Blocked":"Would block"})}),(0,D.jsx)("td",{className:"text-end",children:!e.allowed&&(0,D.jsx)("button",{type:"button",className:"btn btn-sm btn-outline-primary",onClick:()=>{return s=e.host,void(m.includes(s)||g([...m,s]));var s},disabled:r,children:"Allow"})})]},e.host))})]})})]})},at=e=>{let{pixelKey:s,platformMappings:t,autoPlatformConnect:n,onBadgeUpdate:i,conversionEvents:l}=e;const{getEventsForPixel:r}=(0,g.qU)(),o=s?zs.Q9.get(s):null,c=o&&Date.now()-o.ts<zs.ju,d=t||{},m=d.meta||{},h=d.google||{},u=d.tiktok||{},x=d.linkedin||{},j=d.pinterest||{},N=d.snapchat||{},[_,w]=(0,a.useState)({}),[k,S]=(0,a.useState)(()=>{const e={};return Object.entries(d).forEach(s=>{let[t,a]=s;a&&a.ad_account&&(e[t]=a.ad_account)}),e}),[A,P]=(0,a.useState)(!c),z=(e=>{if("meta_ads"===n)return!0;const s=null===(e=(0,G.KP)("meta_ads"))||void 0===e?void 0:e.status;return"imported"===s||"importing"===s})(),[T,F]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.metaPixels)&&void 0!==e?e:[]}),[E,L]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.confirmedId)&&void 0!==e?e:m.pixel_id||null}),[$,I]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.selectedId)&&void 0!==e?e:m.pixel_id||""}),[R,M]=(0,a.useState)(()=>{var e,s;return null!==(e=null===o||void 0===o?void 0:o.metaEnabled)&&void 0!==e?e:Boolean(null!==(s=m.enabled)&&void 0!==s?s:m.pixel_id)}),[B,W]=(0,a.useState)(""),[O,H]=(0,a.useState)(!1),[K,q]=(0,a.useState)(!1),[V,Q]=(0,a.useState)(null),[Y,X]=(0,a.useState)(!c),[J,Z]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.googleMappedActions)&&void 0!==e?e:h.conversion_actions||{}}),[ee,se]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.googleEnabled)&&void 0!==e?e:Boolean(h.enabled)}),[te,ae]=(0,a.useState)(!1),[ne,ie]=(0,a.useState)(null),[le,re]=(0,a.useState)(!1),[oe,ce]=(0,a.useState)(""),[de,me]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.googleActions)&&void 0!==e?e:[]}),[he,ue]=(0,a.useState)(!1),[xe,pe]=(0,a.useState)(null),[ve,fe]=(0,a.useState)(!1),[ge,be]=(0,a.useState)(!1),je=(e=>{if("google_ads"===n)return!0;const s=null===(e=(0,G.KP)("google_ads"))||void 0===e?void 0:e.status;return"imported"===s||"importing"===s||"connected"===s})(),ye=(_.google||[]).find(e=>e.is_selected)||null,Ne=je&&!ee,_e=(e=>{const s=null===(e=(0,G.KP)("tiktok_ads"))||void 0===e?void 0:e.status;return"imported"===s||"importing"===s||"connected"===s})(),[we,ke]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.tiktokEnabled)&&void 0!==e?e:Boolean(u.enabled)}),[Se,Ce]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.tiktokOnly)&&void 0!==e?e:Boolean(u.tiktok_only)}),[Ae,Pe]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.tiktokPixelCode)&&void 0!==e?e:u.pixel_code||""}),[ze,Te]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.tiktokPixels)&&void 0!==e?e:[]}),[Fe,Ee]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.tiktokSelectedId)&&void 0!==e?e:u.pixel_code||""}),[Le,De]=(0,a.useState)(!1),[$e,Ie]=(0,a.useState)(!1),[Re,Me]=(0,a.useState)(!1),[Be,We]=(0,a.useState)(""),[Oe,Ue]=(0,a.useState)(null),He=(e=>{const s=null===(e=(0,G.KP)("linkedin_ads"))||void 0===e?void 0:e.status;return"imported"===s||"importing"===s||"connected"===s})(),[Ke,qe]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.linkedinEnabled)&&void 0!==e?e:Boolean(x.enabled)}),[Ge,Ve]=(0,a.useState)(()=>{var e,s;return null!==(e=null===o||void 0===o?void 0:o.linkedinForwarding)&&void 0!==e?e:Boolean(null!==(s=x.forward)&&void 0!==s?s:x.enabled)}),[Qe,Ye]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.linkedinPixelCode)&&void 0!==e?e:x.pixel_code||""}),[Xe,Je]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.linkedinMappedActions)&&void 0!==e?e:x.conversion_actions||{}}),[Ze,es]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.linkedinPixels)&&void 0!==e?e:[]}),[ss,ts]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.linkedinSelectedId)&&void 0!==e?e:x.pixel_code||""}),[as,ns]=(0,a.useState)(!1),[is,ls]=(0,a.useState)(!1),[rs,os]=(0,a.useState)(!1),[cs,ds]=(0,a.useState)(""),[ms,hs]=(0,a.useState)(null),us=(e=>{const s=null===(e=(0,G.KP)("pinterest_ads"))||void 0===e?void 0:e.status;return"imported"===s||"importing"===s||"connected"===s})(),[xs,ps]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.pinterestEnabled)&&void 0!==e?e:Boolean(j.enabled)}),[vs,fs]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.pinterestPixelCode)&&void 0!==e?e:j.pixel_code||""}),[gs,js]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.pinterestPixels)&&void 0!==e?e:[]}),[ys,Ns]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.pinterestSelectedId)&&void 0!==e?e:j.pixel_code||""}),[_s,ws]=(0,a.useState)(!1),[ks,Ss]=(0,a.useState)(!1),[Cs,As]=(0,a.useState)(!1),[Ts,Fs]=(0,a.useState)(""),[Es,Hs]=(0,a.useState)(null),Qs=(e=>{const s=null===(e=(0,G.KP)("snapchat_ads"))||void 0===e?void 0:e.status;return"imported"===s||"importing"===s||"connected"===s})(),[Ys,Xs]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.snapchatEnabled)&&void 0!==e?e:Boolean(N.enabled)}),[Js,tt]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.snapchatPixelCode)&&void 0!==e?e:N.pixel_code||""}),[at,nt]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.snapchatPixels)&&void 0!==e?e:[]}),[it,lt]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.snapchatSelectedId)&&void 0!==e?e:N.pixel_code||""}),[rt,ot]=(0,a.useState)(!1),[ct,dt]=(0,a.useState)(!1),[mt,ht]=(0,a.useState)(!1),[ut,xt]=(0,a.useState)(null),[pt,vt]=(0,a.useState)(()=>{var e;return null!==(e=null===o||void 0===o?void 0:o.snapchatOrgId)&&void 0!==e?e:N.organization_id||N.organizationId||N.organization||N.business_id||""}),[ft,gt]=(0,a.useState)(!1),[bt,jt]=(0,a.useState)({open:!1,platform:"",enable:!1,onConfirm:null,message:""}),[yt,Nt]=(0,a.useState)(!1),[_t,wt]=(0,a.useState)({open:!1,platform:"",label:"",onConfirm:null}),[kt,St]=(0,a.useState)(!1),[Ct,At]=(0,a.useState)({open:!1,platform:"",platformKey:"",pixelLabel:"",enableForwarding:!0,onConfirm:null}),[Pt,zt]=(0,a.useState)(""),[Tt,Ft]=(0,a.useState)(!1),[Et,Lt]=(0,a.useState)(0),[Dt,$t]=(0,a.useState)(0),It=(0,a.useRef)(0),Rt=(0,a.useMemo)(()=>[`Connecting to ${Ct.platform||"your ad platform"}...`,"Configuring pixel...","Configuring conversion events...","Verifying pixel to conversion event connections...","Finalizing pixel setup..."],[Ct.platform]);(0,a.useEffect)(()=>{const e=Math.max(0,Math.min(100,Number(Dt)||0));Lt(e<20?0:e<40?1:e<60?2:e<80?3:4),It.current=e},[Dt]);const Mt=(0,a.useRef)(!1),Bt=(0,a.useRef)(!1),Wt=(0,a.useRef)(!1);(0,a.useEffect)(()=>
1{if(!n||Mt.current)return;Mt.current=!0;const e=(0,Us.D5)(n),s=(0,Us.ow)(n);"google_ads"!==s?"linkedin_ads"!==s?(zt(""),At({open:!0,platform:e,platformKey:s,pixelLabel:e,enableForwarding:!0,onConfirm:ua(s)})):Wt.current=!0:Bt.current=!0},[n]),(0,a.useEffect)(()=>{Bt.current&&!Y&&je&&(Bt.current=!1,oa(!0))},[Y,je]),(0,a.useEffect)(()=>{Wt.current&&!as&&He&&(Wt.current=!1,zt(""),At({open:!0,platform:"LinkedIn Ads",platformKey:"linkedin",pixelLabel:"LinkedIn Events",enableForwarding:!1,onConfirm:ua("linkedin")}))},[as,He]);const Ot=pt?"Open Snapchat pixel settings in your organization workspace.":"Open Snapchat Ads Manager pixel settings.",[Ut,Ht]=(0,a.useState)(null),{limit:Kt}=(0,b.A)("platform_connections",0),qt=e=>{(0,G.Qu)({platformStates:(0,G.D2)(),platform:e,limit:Kt})?(0,C.dX)({reason:"platform_connection_limit",limit:Kt}):(Ht(e),(0,y.qQ)(`${U.eN}/${e}/enable/?from=conversions`).then(e=>{const{authorization_url:s}=e.data;s?window.location.href=s:Ht(null)}).catch(()=>Ht(null)))},Gt=e=>{let{platformKey:s,platformLabel:t}=e;const a=(0,G.KP)(s),n="imported"===(null===a||void 0===a?void 0:a.status)||"importing"===(null===a||void 0===a?void 0:a.status)||"connected"===(null===a||void 0===a?void 0:a.status);return(0,D.jsx)("div",{className:"d-flex flex-column align-items-start gap-2",children:n?(0,D.jsxs)("div",{className:"alert alert-warning mb-0 small",children:[(0,D.jsx)("i",{className:"feather icon-alert-circle me-2"}),t," is authorized but no account is selected."," ",(0,D.jsx)("a",{href:"/connections",className:"alert-link",children:"Go to Connections"})," to select one."]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(f.A,{variant:"secondary",size:"sm",disabled:Ut===s,onClick:()=>qt(s),children:Ut===s?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Connecting\u2026"]}):(0,D.jsxs)(D.Fragment,{children:["Enable ",t]})}),(0,D.jsxs)("div",{className:"small text-muted mt-1",children:["Connect ",t," account to send conversion events."]})]})})},Vt=()=>{ht(!0);try{const e=pt?`https://business.snapchat.com/organization/${pt}/events-manager/pixel`:"https://ads.snapchat.com/events-manager";window.open(e,"_blank","noopener")}finally{ht(!1)}},Qt=(0,a.useCallback)(async e=>{if(e){ue(!0),pe(null);try{const s=await(0,y.qQ)(`/conversions/platform-actions/?ad_platform=google_ads&account_id=${encodeURIComponent(e)}`);me(s.data||[])}catch(a){var s,t;pe((null===a||void 0===a||null===(s=a.response)||void 0===s||null===(t=s.data)||void 0===t?void 0:t.detail)||"Failed to load Google conversion actions")}finally{ue(!1)}}},[]),Yt=(0,a.useCallback)(e=>{var s,t;e&&(F(e.metaPixels||[]),L(null!==(s=e.confirmedId)&&void 0!==s?s:null),I(null!==(t=e.selectedId)&&void 0!==t?t:""),M(Boolean(e.metaEnabled)),se(Boolean(e.googleEnabled)),Z(e.googleMappedActions||{}),me(e.googleActions||[]),ke(Boolean(e.tiktokEnabled)),Ce(Boolean(e.tiktokOnly)),Pe(e.tiktokPixelCode||""),Te(e.tiktokPixels||[]),Ee(e.tiktokSelectedId||""),qe(Boolean(e.linkedinEnabled)),Ve(Boolean(e.linkedinForwarding)),Ye(e.linkedinPixelCode||""),Je(e.linkedinMappedActions||{}),es(e.linkedinPixels||[]),ts(e.linkedinSelectedId||""),ps(Boolean(e.pinterestEnabled)),fs(e.pinterestPixelCode||""),js(e.pinterestPixels||[]),Ns(e.pinterestSelectedId||""),Xs(Boolean(e.snapchatEnabled)),tt(e.snapchatPixelCode||""),nt(e.snapchatPixels||[]),lt(e.snapchatSelectedId||""),vt(e.snapchatOrgId||""),P(!1),X(!1),De(!1),ns(!1),ws(!1),ot(!1))},[]),Xt=(0,a.useCallback)(async()=>{if(!s)return P(!1),void X(!1);const e=zs.Q9.get(s);if(e&&Date.now()-e.ts<zs.ju)return void Yt(e);const t=async e=>{let{endpoint:s,savedId:t,setPixels:a,setSelectedId:n,setLoading:i,setError:l,setConnected:r,suppressSavedPlaceholder:o,fallbackError:c}=e;i(!0),null===l||void 0===l||l(null);try{var d;const e=await(0,y.qQ)(s),i=(null===(d=e.data)||void 0===d?void 0:d.pixels)||e.data||[];a(i);const l=i.some(e=>e.id===t);!t||l||o||a([{id:t,name:t},...i]),n(t||""),null===r||void 0===r||r(!0)}catch(u){var m,h;null===l||void 0===l||l((null===u||void 0===u||null===(m=u.response)||void 0===m||null===(h=m.data)||void 0===h?void 0:h.detail)||c||"Failed to load pixels"),null===r||void 0===r||r(!1)}finally{i(!1)}};Zt.current=null,P(!0),X(!0),ce(""),me([]),Q(null);try{var a,n,i,l,r,o,c,d,m,h,u,x,p,v,f;const e=await(0,y.qQ)(`/conversions/pixels/${s}/platform_mappings/`);w((null===(a=e.data)||void 0===a?void 0:a.available_accounts)||{});const N=(null===(n=e.data)||void 0===n?void 0:n.platform_mappings)||{};S(Object.fromEntries(Object.entries(N).filter(e=>{let[,s]=e;return s&&s.ad_account}).map(e=>{let[s,t]=e;return[s,t.ad_account]})));const _=(null===(i=e.data)||void 0===i||null===(l=i.platform_mappings)||void 0===l?void 0:l.meta)||{},k=_.pixel_id||"",C=_.enabled;try{var g,b;const e=await(0,y.qQ)("/meta_ads/pixels/"),s=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map(e=>{const s=e.id||e.pixel_id||e.pixelId||e.code||"",t=e.name||e.pixel_name||e.pixelName||s;return s?{id:s,name:t}:null}
1).filter(Boolean)}((null===(g=e.data)||void 0===g?void 0:g.pixels)||e.data||[]),t=s.some(e=>e.id===k),a=k&&!t?[{id:k,name:k},...s]:s;F(a),I(k||(null===(b=a[0])||void 0===b?void 0:b.id)||"")}catch(j){console.error(j),Q("Failed to load Meta pixels.")}L(k||null),M(Boolean(null!==C&&void 0!==C?C:k));const A=(null===(r=e.data)||void 0===r||null===(o=r.platform_mappings)||void 0===o?void 0:o.google)||{},P=Boolean(A.enabled);se(P),P?(Z(A.conversion_actions||{}),A.customer_id?Qt(A.customer_id):X(!1)):(Z({}),X(!1));const z=(null===(c=e.data)||void 0===c||null===(d=c.platform_mappings)||void 0===d?void 0:d.tiktok)||{};ke(Boolean(z.enabled)),Ce(Boolean(z.tiktok_only)),Pe(z.pixel_code||""),Ee(z.pixel_code||"");const T=(null===(m=e.data)||void 0===m||null===(h=m.platform_mappings)||void 0===h?void 0:h.linkedin)||{};qe(Boolean(T.enabled)),Ve(Boolean(null!==(u=T.forward)&&void 0!==u?u:T.enabled)),Ye(T.pixel_code||""),Je(T.conversion_actions||{}),ts(T.pixel_code||"");const E=(null===(x=e.data)||void 0===x||null===(p=x.platform_mappings)||void 0===p?void 0:p.pinterest)||{};ps(Boolean(E.enabled)),fs(E.pixel_code||""),Ns(E.pixel_code||"");const D=(null===(v=e.data)||void 0===v||null===(f=v.platform_mappings)||void 0===f?void 0:f.snapchat)||{};Xs(Boolean(D.enabled)),tt(D.pixel_code||""),lt(D.pixel_code||"");const $=D.organization_id||D.organizationId||D.organization||D.business_id||"";$&&vt($),await Promise.all([t({endpoint:"/tiktok_ads/pixels/",savedId:z.pixel_code,setPixels:Te,setSelectedId:Ee,setLoading:De,setError:Ue,fallbackError:"Failed to load TikTok pixels for your selected account."}),t({endpoint:"/linkedin_ads/pixels/",savedId:T.pixel_code,setPixels:es,setSelectedId:ts,setLoading:ns,setError:hs,suppressSavedPlaceholder:"auto-connected"===T.pixel_code,fallbackError:"Failed to load LinkedIn conversion tags for your selected account."}),t({endpoint:"/pinterest_ads/pixels/",savedId:E.pixel_code,setPixels:js,setSelectedId:Ns,setLoading:ws,setError:Hs,fallbackError:"Failed to load Pinterest conversion tags for your selected account."}),t({endpoint:"/snapchat_ads/pixels/",savedId:D.pixel_code,setPixels:nt,setSelectedId:lt,setLoading:ot,setError:xt,fallbackError:"Failed to load Snapchat pixels for your selected account."})])}catch(N){ie("Failed to load platform mappings")}finally{P(!1),X(!1),Zt.current=s}},[s,Qt,Yt]),Jt=(0,a.useRef)({}),Zt=(0,a.useRef)(null);(0,a.useEffect)(()=>{Jt.current={metaPixels:T,confirmedId:E,selectedId:$,metaEnabled:R,googleEnabled:ee,googleMappedActions:J,googleActions:de,tiktokEnabled:we,tiktokOnly:Se,tiktokPixelCode:Ae,tiktokPixels:ze,tiktokSelectedId:Fe,linkedinEnabled:Ke,linkedinForwarding:Ge,linkedinPixelCode:Qe,linkedinMappedActions:Xe,linkedinPixels:Ze,linkedinSelectedId:ss,pinterestEnabled:xs,pinterestPixelCode:vs,pinterestPixels:gs,pinterestSelectedId:ys,snapchatEnabled:Ys,snapchatPixelCode:Js,snapchatPixels:at,snapchatSelectedId:it,snapchatOrgId:pt}}),(0,a.useEffect)(()=>{!s||A||Y||Le||as||_s||rt||Zt.current===s&&zs.Q9.set(s,{...Jt.current,ts:Date.now()})},[s,A,Y,Le,as,_s,rt,T,E,$,R,ee,J,de,we,Se,Ae,ze,Fe,Ke,Ge,Qe,Xe,Ze,ss,xs,vs,gs,ys,Ys,Js,at,it,pt]),(0,a.useEffect)(()=>{Xt()},[Xt]),(0,a.useEffect)(()=>{if(A||Y||Le||as||_s||rt)return;const e=[Ne,z&&!E,He&&!Ke,us&&!vs,Qs&&!Js,_e&&!Ae].filter(Boolean).length;null===i||void 0===i||i(e)},[A,Y,Le,as,_s,rt,Ne,z,E,He,Ke,us,vs,Qs,Js,_e,Ae,i]);const ea=(0,a.useMemo)(()=>{if(!s)return[];const e=r(s)||[],t=new Set(e.map(e=>e.event_key||e.id).filter(Boolean));return(l||[]).filter(e=>t.has(e.event_key||e.id))},[s,l,r]),sa=(0,a.useCallback)(async()=>{if(s&&Ke)try{var e,t,a,n;const[i,l]=await Promise.all([(0,y.qQ)("/linkedin_ads/pixels/"),(0,y.qQ)(`/conversions/pixels/${s}/platform_mappings/`)]),r=(null===(e=i.data)||void 0===e?void 0:e.pixels)||i.data||[];es(Array.isArray(r)?r:[]);const o=(null===(t=l.data)||void 0===t||null===(a=t.platform_mappings)||void 0===a?void 0:a.linkedin)||{};Je(o.conversion_actions||{}),Ve(Boolean(null!==(n=o.forward)&&void 0!==n?n:o.enabled)),qe(Boolean(o.enabled))}catch(i){console.warn("LinkedIn card refresh failed",i)}},[s,Ke]);(0,a.useEffect)(()=>
1{if(!Ke)return;const e=setTimeout(()=>{sa()},1500);return()=>clearTimeout(e)},[Ke,ea.length,sa]);const ta=(0,a.useCallback)(e=>{const s={};return ea.forEach(t=>{const a=Vs(t);if(!a)return;const n=String((null===e||void 0===e?void 0:e[a])||"").trim();n&&(s[a]=n)}),s},[ea]),aa=(0,a.useCallback)(()=>{var e;return E||$||(null===(e=T[0])||void 0===e?void 0:e.id)||""},[E,$,T]),na=(0,a.useCallback)(async e=>{if(e)try{await(0,y.Ku)("/meta_ads/pixels/assign/",{pixel_id:e})}catch(a){var s,t;const e=String((null===a||void 0===a||null===(s=a.response)||void 0===s||null===(t=s.data)||void 0===t?void 0:t.detail)||(null===a||void 0===a?void 0:a.message)||"").toLowerCase();if(e.includes("unable to resolve meta business id"))return;if(e.includes("already")&&(e.includes("shared")||e.includes("assigned")))return;throw a}},[]),ia=async(e,t)=>{if(Q(null),!s)return void Q("No pixel selected.");const a=t||aa();if(a){H(!0);try{var n,i,l;await na(a);const t=(null===(n=(await(0,y.patchWithToken)(`/conversions/pixels/${s}/platform_mappings/`,{platform:"meta",meta_pixel_id:a,enabled:void 0!==e?e:R||!0})).data)||void 0===n||null===(i=n.platform_mappings)||void 0===i?void 0:i.meta)||{},r=t.pixel_id||a;L(r),I(r);const o=t.enabled;M(Boolean(null===(l=null!==o&&void 0!==o?o:R)||void 0===l||l))}catch(c){var r,o;Q((null===c||void 0===c||null===(r=c.response)||void 0===r||null===(o=r.data)||void 0===o?void 0:o.detail)||"Failed to save. Please try again.")}finally{H(!1)}}else Q("No Meta Pixel found to connect.")},la=(0,a.useCallback)(async e=>{if(!s)return;const t=aa();if(t)return void await ia(e,t);const a=(B||"").trim();if(!a)throw new Error("Enter a Meta Pixel name to create one.");q(!0);try{var n,i,l,r,o,c;const s=await(0,y.Ku)("/meta_ads/pixels/create/",{name:a}),t=(null===(n=s.data)||void 0===n?void 0:n.id)||(null===(i=s.data)||void 0===i?void 0:i.pixel_id)||(null===(l=s.data)||void 0===l?void 0:l.pixelId),d=(null===(r=s.data)||void 0===r?void 0:r.name)||(null===(o=s.data)||void 0===o?void 0:o.pixel_name)||(null===(c=s.data)||void 0===c?void 0:c.pixelName)||a;if(!t)throw new Error("Missing pixel id from Meta response");F(e=>e.some(e=>e.id===t)?e:[...e,{id:t,name:d}]),I(t),W(""),await ia(e,t)}finally{q(!1)}},[s,aa,B,ia]),ra=async()=>{if(!s)return{success:!1,error:"No pixel selected"};const e=r(s).map(e=>e.event_key||e.id).filter(Boolean),t=(l||[]).filter(s=>e.includes(s.event_key||s.id));if(0===t.length)return ce("No events to sync for this pixel."),{success:!0,matched:0,created:0,message:"No events to sync"};ie(null),ce("Syncing Google conversion actions..."),re(!0);try{var a,n;const e=await(0,y.Ku)("/conversions/google/sync_conversion_actions/",{}),l=(null===(a=e.data)||void 0===a?void 0:a.account_id)||(null===(n=e.data)||void 0===n?void 0:n.customer_id);if(!l)throw new Error("No Google Ads customer ID found. Please ensure Google Ads is connected.");const r=(await(0,y.qQ)(`/conversions/platform-actions/?ad_platform=google_ads&account_id=${encodeURIComponent(l)}`)).data||[];me(r);const v=r.filter(e=>{const s=e.status;return"REMOVED"!==s&&"removed"!==s}),f=[],j=[],N=[];for(const s of t){const e=s.name||s.event_name,t=Ls(e);let a=$s(e,v);if(!a){const s=e.toLowerCase().replace(/[^a-z0-9]/g,"");a=v.find(e=>{const t=(e.name||"").toLowerCase().replace(/[^a-z0-9]/g,"");if(t.startsWith(s)){const e=t.substring(s.length);return/^\d{8}$/.test(e)}return!1})}if(a)f.push({event:s,action:a,eventName:t});else{const a=r.find(s=>{const t=s.status;return("REMOVED"===t||"removed"===t)&&$s(e,[s])});a?(N.push({eventName:t,actionName:a.name}),j.push({...s,_hasRemovedDuplicate:!0,_removedName:a.name})):j.push(s)}}let _=0,w=[];if(j.length>0){const e=N.length>0?`Matched ${f.length} events. Creating ${j.length} new conversion actions (${N.length} replacing REMOVED actions)...`:`Matched ${f.length} events. Creating ${j.length} new conversion actions...`;ce(e);try{const e=j.map(e=>{const s=e.name||e.event_name;let t=s;if(e._hasRemovedDuplicate){t=`${s} ${(new Date).toISOString().slice(0,10).replace(/-/g,"")}`}return{name:t,originalEvent:e}}).filter(e=>{let{name:s}=e;const t=r.some(e=>{const t=(e.name||"").trim(),a=s.trim();return t.toLowerCase()===a.toLowerCase()});return t&&console.warn(`[Auto-Sync] Skipping creation of "${s}
1" - already exists in Google Ads`),!t}).map(e=>{let{name:s}=e;return function(e){const s=Ls(e.name||e.event_name);return{event_name:s,category:e.category||Ds(s),default_value:e.default_value||e.value||0,currency:e.currency||"USD"}}({name:s})});if(0===e.length)ce("All conversion actions already exist. No new actions created.");else{var i,o,c,d,m;const t=await(0,y.Ku)(`/conversions/pixels/${s}/google/create_conversion_actions/`,{events:e});_=(null===(i=t.data)||void 0===i||null===(o=i.created)||void 0===o?void 0:o.length)||0;const a=(null===(c=t.data)||void 0===c||null===(d=c.platform_mappings)||void 0===d||null===(m=d.google)||void 0===m?void 0:m.conversion_actions)||{};Z(a)}}catch(g){var h,u;w.push((null===g||void 0===g||null===(h=g.response)||void 0===h||null===(u=h.data)||void 0===u?void 0:u.detail)||"Failed to create some conversion actions")}}else try{var x,p;const e=(null===(x=(await(0,y.qQ)(`/conversions/pixels/${s}/platform_mappings/`)).data)||void 0===x||null===(p=x.platform_mappings)||void 0===p?void 0:p.google)||{};Z(e.conversion_actions||{})}catch(b){console.warn("Failed to refresh Google mappings:",b)}if(_>0)try{const e=await(0,y.qQ)(`/conversions/platform-actions/?ad_platform=google_ads&account_id=${encodeURIComponent(l)}`);me(e.data||[])}catch(b){console.warn("Failed to refresh Google actions:",b)}const k=t.length,S=f.length+_;if(w.length>0)ce(`Synced ${S}/${k} events. ${w.length} error(s) occurred.`),ie(w.join("; "));else if(N.length>0){const e=N.map(e=>e.eventName).join(", ");ce(`Successfully synced ${k} event(s): ${f.length} matched, ${_} created (${N.length} replaced REMOVED actions: ${e}).`)}else ce(`Successfully synced ${k} event(s): ${f.length} matched, ${_} created.`);return{success:0===w.length,matched:f.length,created:_,total:k,errors:w,replacedRemoved:N.length}}catch(b){var v,f;const e=(null===b||void 0===b||null===(v=b.response)||void 0===v||null===(f=v.data)||void 0===f?void 0:f.detail)||(null===b||void 0===b?void 0:b.message)||"Failed to sync Google conversion actions";return ie(e),ce(""),{success:!1,error:e}}finally{re(!1)}},oa=async e=>{if(s){ie(null),ae(!0);try{var t,a;const n=(null===(t=(await(0,y.patchWithToken)(`/conversions/pixels/${s}/platform_mappings/`,{platform:"google",enabled:e})).data)||void 0===t||null===(a=t.platform_mappings)||void 0===a?void 0:a.google)||{};if(e){if(Z(n.conversion_actions||{}),se(Boolean(n.enabled)),n.customer_id){Qt(n.customer_id);try{await ra()}catch(l){console.error("Auto-sync error:",l)}}}else Z({}),se(!1),me([]),ce("")}catch(r){var n,i;ie((null===r||void 0===r||null===(n=r.response)||void 0===n||null===(i=n.data)||void 0===i?void 0:i.detail)||"Failed to update Google forwarding")}finally{ae(!1)}}},ca=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!s)return;const{forwardNonClickEvents:a=Ge}=t;if(e)await async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!s)return{success:!1,error:"No pixel selected"};if(0===ea.length)return ds("No events to sync for this pixel."),{success:!0,matched:0,created:0,total:0};hs(null),ds("Syncing LinkedIn conversion events..."),os(!0);try{var t,a,n,i;const o=await(0,y.qQ)("/linkedin_ads/pixels/"),c=(null===(t=o.data)||void 0===t?void 0:t.pixels)||o.data||[],d=Array.isArray(c)?c:[];es(d);const m=new Map(d.map(e=>[Gs((null===e||void 0===e?void 0:e.name)||(null===e||void 0===e?void 0:e.id)),String((null===e||void 0===e?void 0:e.id)||"")])),h={},u=[];ea.forEach(e=>{const s=Vs(e);if(!s)return;const t=String(e.name||e.event_name||s).trim(),a=m.get(Gs(t));a?h[s]=a:u.push({mappingKey:s,eventName:t})});let x=0;for(const e of u){var l,r;const s=await(0,y.Ku)("/linkedin_ads/pixels/create/",{name:e.eventName}),t=String((null===(l=s.data)||void 0===l?void 0:l.id)||"").trim(),a=String((null===(r=s.data)||void 0===r?void 0:r.name)||e.eventName).trim();t&&(x+=1,h[e.mappingKey]=t,m.set(Gs(a),t),d.push({id:t,name:a}))}const p=ta(h),v=(null===(a=(await(0,y.patchWithToken)(`/conversions/pixels/${s}/platform_mappings/`,{platform:"linkedin",enabled:!0,forward:Boolean(e),pixel_code:"auto-connected",conversion_actions:p})).data)||void 0===a||null===(n=a.platform_mappings)||void 0===n?void 0:n.linkedin)||{};qe(Boolean(v.enabled)),Ve(Boolean(null!==(i=v.forward)&&void 0!==i?i:v.enabled)),Ye(v.pixel_code||"auto-connected"),Je(v.conversion_actions||p),es(d);const f=Object.keys(p).length-x;return ds(`Successfully synced ${Object.keys(p).length}/${ea.length} events: ${f} matched, ${x} created.`),{success:!0,matched:f,created:x,total:ea.length}}catch(d){var o,c;const e=(null===d||void 0===d||null===(o=d.response)||void 0===o||null===(c=o.data)||void 0===c?void 0:c.detail)||(null===d||void 0===d?void 0:d.message)||"Failed to sync LinkedIn conversion events";return hs(e),ds(""),{success:!1,error:e}}finally{os(!1)}}(a);else{hs(null),ls(!0);try{await(0,y.patchWithToken)(`/conversions/pixels/${s}/platform_mappings/`,{platform:"linkedin",enabled:!1,forward:!1,pixel_code:"",conversion_actions:{}}),qe(!1),Ve(!1),Ye(""),Je({}),ds("")}catch(l){var n,i;hs((null===l||void 0===l||null===(n=l.response)||void 0===n||null===(i=n.data)||void 0===i?void 0:i.detail)||"Failed to disable LinkedIn forwarding")}finally{ls(!1)}}},da=async e=>{if(s){Ue(null),Ie(!0);try{var t,a;const n=(null===(t=(await(0,y.patchWithToken)(`/conversions/pixels/${s}/platform_mappings/`,{platform:"tiktok",...e})).data)||void 0===t||null===(a=t.platform_mappings)||void 0===a?void 0:a.tiktok)||{};ke(Boolean(n.enabled)),Ce(Boolean(n.tiktok_only)),Pe(n.pixel_code||""),Ee(n.pixel_code||"")}catch(l){var n,i;Ue((null===l||void 0===l||null===(n=l.response)||void 0===n||null===(i=n.data)||void 0===i?void 0:i.detail)||"Failed to update TikTok forwarding")}finally{Ie(!1)}}},ma=async()=>
1{if(s){Ue(null),Me(!0);try{const e=(Be||"LinkClicks Universal Pixel").trim(),s=Zs(e,ze),t=await(0,y.Ku)("/tiktok_ads/pixels/create/",{name:s}),a={id:t.data.id,name:t.data.name};Te(e=>[...e,a]),Ee(a.id),We(""),await da({enabled:!0,tiktok_only:Se,pixel_code:a.id})}catch(e){Ue(st(e,"Failed to create pixel."))}finally{Me(!1)}}},ha=async()=>{if(s){Hs(null),As(!0);try{const e=(Ts||"LinkClicks Tag").trim(),s=Zs(e,gs),t=await(0,y.Ku)("/pinterest_ads/pixels/create/",{name:s}),a={id:t.data.id,name:t.data.name};js(e=>[...e,a]),Ns(a.id),Fs(""),await pa("pinterest",{enabled:!0,pixel_code:a.id},{setSavingState:Ss,setErrorState:Hs,setEnabledState:ps,setPixelCodeState:fs,setSelectedIdState:Ns,fallbackError:"Failed to link Pinterest tag."})}catch(e){Hs(st(e,"Failed to create Pinterest tag."))}finally{As(!1)}}},ua=e=>{switch(e){case"meta":return e=>la(e);case"tiktok":return e=>da({enabled:e,tiktok_only:Se,pixel_code:Fe});case"linkedin":return e=>ca(!0,{forwardNonClickEvents:e});case"pinterest":return e=>pa("pinterest",{enabled:e,pixel_code:ys},{setSavingState:Ss,setErrorState:Hs,setEnabledState:ps,setPixelCodeState:fs,setSelectedIdState:Ns,fallbackError:"Failed to link Pinterest tag."});case"snapchat":return e=>pa("snapchat",{enabled:e,pixel_code:it},{setSavingState:dt,setErrorState:xt,setEnabledState:Xs,setPixelCodeState:tt,setSelectedIdState:lt,fallbackError:"Failed to link Snapchat pixel."});default:return Ct.onConfirm}},xa=(0,a.useCallback)(async(e,t)=>{if(s)try{var a,n,i;const l=(null===(a=(await(0,y.patchWithToken)(`/conversions/pixels/${s}/platform_mappings/`,{platform:e,authorization_id:t})).data)||void 0===a||null===(n=a.platform_mappings)||void 0===n||null===(i=n[e])||void 0===i?void 0:i.ad_account)||null;S(s=>({...s,[e]:l})),(0,zs.ag)(s)}catch(l){console.error("Failed to bind ad account",l),Q("Could not change the ad account. Please try again.")}},[s]),pa=async function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!s)return;const{setSavingState:n,setErrorState:i,setEnabledState:l,setPixelCodeState:r,setSelectedIdState:o,setMappingsState:c,fallbackError:d}=a;null===i||void 0===i||i(null),null===n||void 0===n||n(!0);try{var m,h;const a=(null===(m=(await(0,y.patchWithToken)(`/conversions/pixels/${s}/platform_mappings/`,{platform:e,...t})).data)||void 0===m||null===(h=m.platform_mappings)||void 0===h?void 0:h[e])||{};null===l||void 0===l||l(Boolean(a.enabled));const n=a.pixel_code||"";null===r||void 0===r||r(n),null===o||void 0===o||o(n),null===c||void 0===c||c(a.conversion_actions||{})}catch(p){var u,x;null===i||void 0===i||i((null===p||void 0===p||null===(u=p.response)||void 0===u||null===(x=u.data)||void 0===x?void 0:x.detail)||d||"Failed to update forwarding")}finally{null===n||void 0===n||n(!1)}};if(A)return(0,D.jsxs)("div",{className:"text-center py-5",children:[(0,D.jsx)("div",{className:"spinner-border text-primary mb-3",role:"status","aria-hidden":"true"}),(0,D.jsx)("p",{className:"text-muted",children:"Loading platform connections..."})]});const va=()=>{At({open:!1,platform:"",platformKey:"",pixelLabel:"",enableForwarding:!0,onConfirm:null}),zt(""),Ft(!1),Lt(0),$t(0)},fa=Ct.platformKey||(0,Us.ow)(Ct.platform),ga=aa(),ba=Boolean(ga),ja="meta"===fa,ya=ja&&!ba,Na=ja?ya?"Create and Connect Meta Pixel":"Connect Existing Meta Pixel":`Connect ${Ct.platform}`,_a=ya?"Create and Connect":"Connect",wa=qs(gs,vs),ka=qs(at,Js),Sa=qs(ze,Ae),Ca=new Set(Object.values(Xe||{}).map(e=>String(e||"").trim()).filter(Boolean)),Aa=(Ze||[]).filter(e=>null===e||void 0===e?void 0:e.id).map(e=>{const s=String(e.id);return{id:s,name:String(e.name||e.id||"").trim()||s,mapped:Ca.has(s)}}),Pa=(()=>{switch(fa){case"meta":return O||K;case"tiktok":return $e||Re;case"linkedin":return is||rs;case"pinterest":return ks||Cs;case"snapchat":return ct;default:return!1}})()||Tt;return(0,D.jsxs)("div",{className:"p-3 platforms-tab",children:[(0,D.jsx)("h5",{className:"mb-1",children:"Ad Platform Connections"}),(0,D.jsx)("p",{className:"text-muted small mb-4",children:"Link this pixel to your ad platforms so conversion events are automatically forwarded via server-side API."}),(0,D.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(320px, 1fr))",gap:"16px"},children:[(0,D.jsxs)("div",{className:"card shadow-sm p-3 h-100",style:Ne?{border:"2px s
1olid #dc3545",boxShadow:"0 0 0 3px rgba(220,53,69,0.25)",position:"relative"}:{border:"1px solid var(--bs-border-color, #dee2e6)",position:"relative"},children:[Ne&&(0,D.jsx)("span",{className:"label pcoded-badge bg-danger",style:{position:"absolute",top:8,right:8,fontSize:"0.75rem",lineHeight:"1.1",padding:"2px 8px",borderRadius:"4px",color:"#fff"},children:"!"}),(0,D.jsxs)("div",{className:"d-flex align-items-center gap-3 mb-3",children:[(0,D.jsx)("div",{style:{width:36,height:36,background:"#fff",borderRadius:"50%",border:"1px solid #dee2e6",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,D.jsx)("img",{src:Rs.A,alt:"Google",style:{width:32,height:32,objectFit:"contain"}})}),(0,D.jsxs)("div",{className:"flex-grow-1",children:[(0,D.jsx)("h6",{className:"mb-0",children:"Google Ads"}),(0,D.jsx)("small",{className:"text-muted",children:"Server-side Offline Conversions (auto-mapped)"})]})]}),je&&ye&&(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2 mb-3 flex-wrap",children:[(0,D.jsx)("span",{className:"small text-muted",style:{whiteSpace:"nowrap"},children:"Ad account:"}),(0,D.jsx)("span",{className:"small",style:{fontWeight:500},children:ye.account_name||ye.account_id}),(0,D.jsx)("span",{className:"small text-muted",style:{fontSize:"0.7rem"},children:"(from Connections \u2192 Advertising)"})]}),je?Y?(0,D.jsxs)("div",{className:"text-center py-3",children:[(0,D.jsx)("div",{className:"spinner-border spinner-border-sm text-primary",role:"status"}),(0,D.jsx)("div",{className:"small text-muted mt-2",children:"Loading Google mapping\u2026"})]}):(0,D.jsxs)(D.Fragment,{children:[ne&&(0,D.jsx)("div",{className:"platform-error small py-2 px-3 mb-3 rounded",children:ne}),(0,D.jsx)("div",{className:"d-flex flex-wrap gap-2 align-items-center mt-2",children:ee?(0,D.jsx)(f.A,{variant:"success",size:"sm",disabled:te||le,onClick:()=>wt({open:!0,platform:"Google Ads",label:"Google Ads Events",onConfirm:async()=>{await oa(!1)}}),children:te||le?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Syncing\u2026"]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("i",{className:"feather icon-check me-1"}),"Events Connected"]})}):(0,D.jsx)(f.A,{variant:"secondary",size:"sm",disabled:te||le,onClick:()=>oa(!0),children:te||le?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Syncing\u2026"]}):"Connect Events"})}),oe&&(0,D.jsx)("div",{className:"small text-success mt-1",children:oe}),ee&&(0,D.jsxs)("div",{className:"small text-muted mt-1",children:[(0,D.jsx)("i",{className:"feather icon-link me-1"}),"Connected: ",(0,D.jsx)("code",{children:"auto-connected"}),(0,D.jsxs)("button",{className:"btn btn-link btn-sm p-0 ms-2 text-decoration-none",onClick:()=>fe(!ve),style:{fontSize:"0.75rem"},children:["Google actions ",ve?"\u25bc":"\u25b6"]})]}),ve&&(0,D.jsxs)(D.Fragment,{children:[he&&(0,D.jsx)("div",{className:"small text-muted mt-2",children:"Loading Google conversion actions\u2026"}),xe&&(0,D.jsx)("div",{className:"platform-error small py-2 px-3 mb-0 mt-2 rounded",children:xe}),!he&&!xe&&0===de.filter(e=>"REMOVED"!==e.status&&"removed"!==e.status).length&&(0,D.jsxs)("div",{className:"small text-muted mt-2",children:[(0,D.jsx)("i",{className:"feather icon-info me-1"}),"No enabled Google conversion actions found."]}),!he&&!xe&&de.filter(e=>"REMOVED"!==e.status&&"removed"!==e.status).length>0&&(0,D.jsxs)("div",{className:"alert alert-info small py-2 mb-0 mt-3",children:[(0,D.jsx)("i",{className:"feather icon-database me-1"}),"Available Google conversion actions (",de.filter(e=>"REMOVED"!==e.status&&"removed"!==e.status).length,"):",(0,D.jsx)("ul",{className:"mb-0 mt-2 small ps-3",children:de.filter(e=>"REMOVED"!==e.status&&"removed"!==e.status).map(e=>(0,D.jsx)("li",{children:e.name},e.id||e.resource_name))})]})]})]}):(0,D.jsx)(Gt,{platformKey:"google_ads",platformLabel:"Google Ads"})]}),(0,D.jsxs)("div",{className:"card shadow-sm p-3 h-100",style:He&&!Ke?{border:"2px s
1olid #dc3545",boxShadow:"0 0 0 3px rgba(220,53,69,0.25)",position:"relative"}:{border:"1px solid var(--bs-border-color, #dee2e6)",position:"relative"},children:[He&&!Ke&&(0,D.jsx)("span",{className:"label pcoded-badge bg-danger",style:{position:"absolute",top:8,right:8,fontSize:"0.75rem",lineHeight:"1.1",padding:"2px 8px",borderRadius:"4px",color:"#fff"},children:"!"}),(0,D.jsxs)("div",{className:"d-flex align-items-center gap-3 mb-3",children:[(0,D.jsx)("div",{style:{width:36,height:36,background:"#fff",borderRadius:"50%",border:"1px solid #dee2e6",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,D.jsx)("img",{src:Ms,alt:"LinkedIn",style:{width:32,height:32,objectFit:"contain"}})}),(0,D.jsxs)("div",{className:"flex-grow-1",children:[(0,D.jsx)("h6",{className:"mb-0",children:"LinkedIn Ads"}),(0,D.jsx)("small",{className:"text-muted",children:"Server-side Conversions API"})]})]}),He&&(0,D.jsx)(Ps,{platform:"linkedin",accounts:_.linkedin,boundAccount:k.linkedin,onSelect:xa}),He?(0,D.jsxs)(D.Fragment,{children:[ms&&(0,D.jsx)("div",{className:"platform-error small py-2 px-3 mb-3 rounded",children:ms}),(0,D.jsx)("div",{className:"d-flex flex-wrap gap-2 align-items-center mt-2",children:Ke?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(f.A,{variant:"success",size:"sm",disabled:is||rs,onClick:()=>wt({open:!0,platform:"LinkedIn Ads",label:"LinkedIn Events",onConfirm:async()=>{await ca(!1)}}),children:is||rs?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Syncing\u2026"]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("i",{className:"feather icon-check me-1"}),"Events Connected"]})}),(0,D.jsx)(f.A,{variant:Ge?"success":"secondary",size:"sm",disabled:is||rs,onClick:()=>jt({open:!0,platform:"LinkedIn Ads",enable:!Ge,onConfirm:()=>(async e=>{if(s){hs(null),ls(!0);try{var t,a,n;const i=(null===(t=(await(0,y.patchWithToken)(`/conversions/pixels/${s}/platform_mappings/`,{platform:"linkedin",enabled:!0,forward:Boolean(e),pixel_code:Qe||"auto-connected",conversion_actions:ta(Xe)})).data)||void 0===t||null===(a=t.platform_mappings)||void 0===a?void 0:a.linkedin)||{};qe(Boolean(i.enabled)),Ve(Boolean(null!==(n=i.forward)&&void 0!==n?n:i.enabled))}catch(r){var i,l;hs((null===r||void 0===r||null===(i=r.response)||void 0===i||null===(l=i.data)||void 0===l?void 0:l.detail)||"Failed to update LinkedIn forwarding preference")}finally{ls(!1)}}})(!Ge),message:Ge?"Pause forwarding of non-ad-click events to LinkedIn.":"Enable forwarding of all conversions to LinkedIn, including those not from a LinkedIn ad click."}),children:is||rs?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Saving\u2026"]}):Ge?"Forwarding Events":"Enable Forwarding"})]}):(0,D.jsx)(f.A,{variant:"secondary",size:"sm",disabled:is||rs||as,onClick:()=>{zt(""),At({open:!0,platform:"LinkedIn Ads",platformKey:"linkedin",pixelLabel:"LinkedIn Events",enableForwarding:!1,onConfirm:ua("linkedin")})},children:is||rs?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Syncing\u2026"]}):"Connect Events"})}),cs&&(0,D.jsx)("div",{className:"small text-success mt-1",children:cs}),Ke&&(0,D.jsxs)("div",{className:"small text-muted mt-2",children:[(0,D.jsx)("i",{className:"feather icon-link me-1"}),"Connected: ",(0,D.jsx)("code",{children:"auto-connected"}),(0,D.jsxs)("button",{className:"btn btn-link btn-sm p-0 ms-2 text-decoration-none",onClick:()=>be(!ge),style:{fontSize:"0.75rem"},children:["LinkedIn events ",ge?"\u25bc":"\u25b6"]})]}),Ke&&ge&&(0,D.jsxs)(D.Fragment,{children:[as&&(0,D.jsx)("div",{className:"small text-muted mt-2",children:"Loading LinkedIn conversion events..."}),!as&&0===Aa.length&&(0,D.jsxs)("div",{className:"small text-muted mt-2",children:[(0,D.jsx)("i",{className:"feather icon-info me-1"}),"No LinkedIn conversion events found."]}),!as&&Aa.length>0&&(0,D.jsxs)("div",{className:"alert alert-info small py-2 mb-0 mt-3",children:[(0,D.jsx)("i",{className:"feather icon-database me-1"}),"Available LinkedIn conversion events (",Aa.length,"):",(0,D.jsx)("ul",{className:"mb-0 mt-2 small ps-3",children:Aa.map(e=>(0,D.jsxs)("li",{children:[e.name,e.mapped?(0,D.jsx)("span",{className:"text-success ms-1",children:"(mapped)"}):""]},e.id))})]})]})]}):(0,D.jsx)(Gt,{platformKey:"linkedin_ads",platformLabel:"LinkedIn Ads"})]}),(0,D.jsxs)("div",{className:"card shadow-sm p-3 h-100",style:z&&!E?{border:"2px s
1olid #dc3545",boxShadow:"0 0 0 3px rgba(220,53,69,0.25)",position:"relative"}:{border:"1px solid var(--bs-border-color, #dee2e6)",position:"relative"},children:[z&&!E&&(0,D.jsx)("span",{className:"label pcoded-badge bg-danger",style:{position:"absolute",top:8,right:8,fontSize:"0.75rem",lineHeight:"1.1",padding:"2px 8px",borderRadius:"4px",color:"#fff"},children:"!"}),(0,D.jsxs)("div",{className:"d-flex align-items-center gap-3 mb-3",children:[(0,D.jsx)("div",{style:{width:36,height:36,background:"#fff",borderRadius:"50%",border:"1px solid #dee2e6",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,D.jsx)("img",{src:Is,alt:"Meta",style:{width:32,height:32,objectFit:"contain"}})}),(0,D.jsxs)("div",{className:"flex-grow-1",children:[(0,D.jsx)("h6",{className:"mb-0",children:"Meta (Facebook / Instagram)"}),(0,D.jsx)("small",{className:"text-muted",children:"Server-side Conversions API"})]})]}),z&&(0,D.jsx)(Ps,{platform:"meta",accounts:_.meta,boundAccount:k.meta,onSelect:xa}),z?(0,D.jsxs)(D.Fragment,{children:[!E&&(0,D.jsx)("div",{className:"mb-3",children:(0,D.jsx)(f.A,{variant:"secondary",size:"sm",disabled:O||K,onClick:()=>{zt(""),ba?(I(ga),W("")):W(e=>e||Zs("LinkClicks Universal Pixel",T,et)),At({open:!0,platform:"Meta (Facebook / Instagram)",platformKey:"meta",pixelLabel:"Meta Pixel",enableForwarding:!0,onConfirm:ua("meta")})},children:"Connect Meta Pixel"})}),V&&(0,D.jsx)("div",{className:"platform-error small py-2 px-3 mb-3 rounded",children:V}),(0,D.jsxs)("div",{className:"d-flex flex-wrap gap-2 align-items-center mt-2",children:[E&&$===E&&(0,D.jsx)(f.A,{variant:"success",size:"sm",disabled:O,onClick:()=>wt({open:!0,platform:"Meta",label:"Meta Pixel",onConfirm:async()=>{H(!0);try{await(0,y.patchWithToken)(`/conversions/pixels/${s}/platform_mappings/`,{platform:"meta",meta_pixel_id:"",enabled:!1}),L(null),I(""),M(!1)}finally{H(!1)}}}),children:O?(0,D.jsx)("span",{className:"spinner-border spinner-border-sm",role:"status","aria-hidden":"true"}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("i",{className:"feather icon-check me-1"}),"Pixel Connected"]})}),E&&(0,D.jsx)(f.A,{variant:R?"success":"secondary",size:"sm",disabled:O||K,onClick:()=>jt({open:!0,platform:"Meta",enable:!R,onConfirm:()=>(async e=>{if(!s)return;const t=aa();if(t){Q(null),H(!0);try{var a,n;const i=(null===(a=(await(0,y.patchWithToken)(`/conversions/pixels/${s}/platform_mappings/`,{platform:"meta",meta_pixel_id:t,enabled:e})).data)||void 0===a||null===(n=a.platform_mappings)||void 0===n?void 0:n.meta)||{};M(Boolean(i.enabled)),i.pixel_id&&L(i.pixel_id),i.pixel_id&&I(i.pixel_id)}catch(r){var i,l;Q((null===r||void 0===r||null===(i=r.response)||void 0===i||null===(l=i.data)||void 0===l?void 0:l.detail)||"Failed to update Meta forwarding")}finally{H(!1)}}})(!R),message:R?"Pause forwarding of non-ad-click events to Meta.":"Enable forwarding of all conversions to Meta, including those not from a Meta ad click."}),children:O||K?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Saving\u2026"]}):R?"Forwarding Events":"Enable Forwarding"})]})]}):(0,D.jsx)(Gt,{platformKey:"meta_ads",platformLabel:"Meta Ads"})]}),(0,D.jsxs)("div",{className:"card shadow-sm p-3 h-100",style:us&&!vs?{border:"2px solid #dc3545",boxShadow:"0 0 0 3px rgba(220,53,69,0.25)",position:"relative"}:{border:"1px solid var(--bs-border-color, #dee2e6)",position:"relative"},children:[us&&!vs&&(0,D.jsx)("span",{className:"label pcoded-badge bg-danger",style:{position:"absolute",top:8,right:8,fontSize:"0.75rem",lineHeight:"1.1",padding:"2px 8px",borderRadius:"4px",color:"#fff"},children:"!"}),(0,D.jsxs)("div",{className:"d-flex align-items-center gap-3 mb-3",children:[(0,D.jsx)("div",{style:{width:36,height:36,background:"#fff",borderRadius:"50%",border:"1px solid #dee2e6",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,D.jsx)("img",{src:Bs.A,alt:"Pinterest",style:{width:32,height:32,objectFit:"contain"}})}),(0,D.jsxs)("div",{className:"flex-grow-1",children:[(0,D.jsx)("h6",{className:"mb-0",children:"Pinterest Ads"}),(0,D.jsx)("small",{className:"text-muted",children:"Server-side Conversions API"})]})]}),us&&(0,D.jsx)(Ps,{platform:"pinterest",accounts:_.pinterest,boundAccount:k.pinterest,onSelect:xa}),us?(0,D.jsxs)(D.Fragment,{children:[Es&&(0,D.jsx)("div",{className:"platform-error small py-2 px-3 mb-3 rounded",children:Es}),!vs&&(0,D.jsx)(v.A.Group,{className:"mt-2 mb-3",children:_s?(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2 text-muted small py-2",children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm",role:"status","aria-hidden":"true"}),"Loading conversion tags\u2026"]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(v.A.Control,{as:"select",value:ys,onChange:e=>{const s=e.target.value;Ns(s),"new"===s?Fs(e=>e||"LinkClicks Tag"):(Fs(""),s&&(zt(""),At({open:!0,platform:"Pinterest Ads",platformKey:"pinterest",pixelLabel:"Pinterest Conversion Tag",enableForwarding:!0,onConfirm:ua("pinterest")})))},disabled:ks||Cs,children:[(0,D.jsx)("option",{value:"",disabled:!0,children:"Connect Pinterest Tag"}),0===gs.length&&(0,D.jsx)("option",{disabled:!0,children:"No conversion tags found"}),gs.map(e=>(0,D.jsx)("option",{value:e.id,children:e.name&&e.name!==e.id?e.name:e.id},e.id)),(0,D.jsx)("option",{value:"new",children:"+ Create new Pinterest Tag"})]}),"new"===ys&&(0,D.jsxs)("div",{className:"d-flex gap-2 mt-2",children:[(0,D.jsx)(v.A.Control,{type:"text",placeholder:"Tag name, e.g. LinkClicks Tag",value:Ts,onChange:e=>Fs(e.target.value),disabled:Cs,autoFocus:!0}),(0,D.jsx)(f.A,{variant:"primary",size:"sm",className:"text-nowrap",disabled:Cs||!Ts.trim(),onClick:ha,children:Cs?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Creating\u2026"]}):"Create & Link Pinterest Tag"})]}),vs&&"new"!==ys&&(0,D.jsxs)("div",{className:"mt-1 small text-muted",children:["Active tag: ",(0,D.jsx)("code",{children:wa||vs}),ys===vs&&(0,D.jsxs)("span",{className:"ms-2 text-success",children:[(0,D.jsx)("i",{className:"feather icon-check me-1"}),"Saved"]})]})]})}),vs&&(0,D.jsxs)("div",{className:"d-flex flex-wrap gap-2 align-items-center mt-2",children:[(0,D.jsx)(f.A,{variant:"success",size:"sm",className:"text-nowrap",disabled:ks,onClick:()=>wt({open:!0,platform:"Pinterest Ads",label:"Pinterest Conversion Tag",onConfirm:async()=>{Ss(!0);try{await(0,y.patchWithToken)(`/conversions/pixels/${s}/platform_mappings/`,{platform:"pinterest",pixel_code:"",enabled:!1}),fs(""),Ns(""),ps(!1)}finally{Ss(!1)}}}),children:ks?(0,D.jsx)("span",{className:"spinner-border spinner-border-sm",role:"status","aria-hidden":"true"}):"Pixel Connected"}),(0,D.jsx)(f.A,{variant:xs?"success":"secondary",size:"sm",disabled:ks,onClick:()=>jt({open:!0,platform:"Pinterest Ads",enable:!xs,onConfirm:()=>pa("pinterest",{enabled:!xs,pixel_code:vs},{setSavingState:Ss,setErrorState:Hs,setEnabledState:ps,setPixelCodeState:fs,setSelectedIdState:Ns,fallbackError:"Failed to update Pinterest forwarding."}),message:xs?"Pause forwarding of non-ad-click events to Pinterest.":"Enable forwarding of all conversions to Pinterest, including those not from a Pinterest ad click."}),children:ks?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Saving\u2026"]}):xs?"Forwarding Events":"Enable Forwarding"})]}),vs&&(0,D.jsxs)("div",{className:"small text-muted mt-2",children:[(0,D.jsx)("i",{className:"feather icon-link me-1"}),"Connected tag: ",(0,D.jsx)("code",{children:wa||vs})]})]}):(0,D.jsx)(Gt,{platformKey:"pinterest_ads",platformLabel:"Pinterest Ads"})]}),(0,D.jsxs)("div",{className:"card shadow-sm p-3 h-100",style:Qs&&!Js?{border:"2px s
1olid #dc3545",boxShadow:"0 0 0 3px rgba(220,53,69,0.25)",position:"relative"}:{border:"1px solid var(--bs-border-color, #dee2e6)",position:"relative"},children:[Qs&&!Js&&(0,D.jsx)("span",{className:"label pcoded-badge bg-danger",style:{position:"absolute",top:8,right:8,fontSize:"0.75rem",lineHeight:"1.1",padding:"2px 8px",borderRadius:"4px",color:"#fff"},children:"!"}),(0,D.jsxs)("div",{className:"d-flex align-items-center gap-3 mb-3",children:[(0,D.jsx)("div",{style:{width:36,height:36,background:"#fff",borderRadius:"50%",border:"1px solid #dee2e6",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,D.jsx)("img",{src:Ws,alt:"Snapchat",style:{width:32,height:32,objectFit:"contain"}})}),(0,D.jsxs)("div",{className:"flex-grow-1",children:[(0,D.jsx)("h6",{className:"mb-0",children:"Snapchat Ads"}),(0,D.jsx)("small",{className:"text-muted",children:"Server-side Conversions API"})]})]}),Qs&&(0,D.jsx)(Ps,{platform:"snapchat",accounts:_.snapchat,boundAccount:k.snapchat,onSelect:xa}),Qs?(0,D.jsxs)(D.Fragment,{children:[ut&&(0,D.jsx)("div",{className:"platform-error small py-2 px-3 mb-3 rounded",children:ut}),!Js&&(0,D.jsx)(v.A.Group,{className:"mt-2 mb-3",children:rt?(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2 text-muted small py-2",children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm",role:"status","aria-hidden":"true"}),"Loading pixels\u2026"]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(v.A.Control,{as:"select",value:it,onChange:e=>{const s=e.target.value;lt(s),"new"===s?gt(!0):(gt(!1),s&&(zt(""),At({open:!0,platform:"Snapchat Ads",platformKey:"snapchat",pixelLabel:"Snapchat Pixel",enableForwarding:!0,onConfirm:ua("snapchat")})))},disabled:ct,children:[(0,D.jsx)("option",{value:"",disabled:!0,children:"Connect Snapchat Pixel"}),0===at.length&&(0,D.jsx)("option",{disabled:!0,children:"No pixels found"}),at.map(e=>(0,D.jsx)("option",{value:e.id,children:e.name&&e.name!==e.id?e.name:e.id},e.id)),(0,D.jsx)("option",{value:"new",children:"+ Create new Snapchat Pixel"})]}),"new"===it&&(0,D.jsx)("div",{className:"mt-2 text-muted small",children:"Creation must be done in Snapchat Ads Manager."}),Js&&"new"!==it&&(0,D.jsxs)("div",{className:"mt-1 small text-muted",children:["Active pixel: ",(0,D.jsx)("code",{children:ka||Js}),it===Js&&(0,D.jsxs)("span",{className:"ms-2 text-success",children:[(0,D.jsx)("i",{className:"feather icon-check me-1"}),"Saved"]})]})]})}),Js&&(0,D.jsxs)("div",{className:"d-flex flex-wrap gap-2 align-items-center mt-2",children:[(0,D.jsx)(f.A,{variant:"success",size:"sm",className:"text-nowrap",disabled:ct,onClick:()=>wt({open:!0,platform:"Snapchat Ads",label:"Snapchat Pixel",onConfirm:async()=>{dt(!0);try{await(0,y.patchWithToken)(`/conversions/pixels/${s}/platform_mappings/`,{platform:"snapchat",pixel_code:"",enabled:!1}),tt(""),lt(""),Xs(!1)}finally{dt(!1)}}}),children:ct?(0,D.jsx)("span",{className:"spinner-border spinner-border-sm",role:"status","aria-hidden":"true"}):"Pixel Connected"}),(0,D.jsx)(f.A,{variant:Ys?"success":"secondary",size:"sm",disabled:ct,onClick:()=>jt({open:!0,platform:"Snapchat Ads",enable:!Ys,onConfirm:()=>pa("snapchat",{enabled:!Ys,pixel_code:Js},{setSavingState:dt,setErrorState:xt,setEnabledState:Xs,setPixelCodeState:tt,setSelectedIdState:lt,fallbackError:"Failed to update Snapchat forwarding."}),message:Ys?"Pause forwarding of non-ad-click events to Snapchat.":"Enable forwarding of all conversions to Snapchat, including those not from a Snapchat ad click."}),children:ct?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Saving\u2026"]}):Ys?"Forwarding Events":"Enable Forwarding"})]}),Js&&(0,D.jsxs)("div",{className:"small text-muted mt-1",children:[(0,D.jsx)("i",{className:"feather icon-link me-1"}),"Connected pixel: ",(0,D.jsx)("code",{children:ka||Js})]}),(0,D.jsxs)(p.A,{show:ft,onHide:()=>gt(!1),centered:!0,children:[(0,D.jsxs)("div",{className:"modal-header",children:[(0,D.jsx)("h6",{className:"modal-title",children:"Create Snapchat Pixel in Ads Manager"}),(0,D.jsx)("button",{type:"button",className:"btn-close","aria-label":"Close",onClick:()=>gt(!1)})]}),(0,D.jsxs)(p.A.Body,{className:"text-light",children:[(0,D.jsx)("p",{className:"mb-2",children:"Snapchat requires pixel creation directly in Ads Manager under Business Settings."}),(0,D.jsx)("p",{className:"mb-0",children:"Once created, come back here and select it from the list to link it."})]}),(0,D.jsxs)(p.A.Footer,{children:[(0,D.jsx)(f.A,{variant:"outline-secondary",size:"sm",onClick:()=>gt(!1),children:"Close"}),(0,D.jsx)(f.A,{variant:"primary",size:"sm",onClick:Vt,disabled:mt,title:Ot,children:mt?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Opening\u2026"]}):"Open Snapchat Pixel Settings"})]})]})]}):(()=>{const e=(0,G.KP)("snapchat_ads");return"imported"===(null===e||void 0===e?void 0:e.status)||"importing"===(null===e||void 0===e?void 0:e.status)||"connected"===(null===e||void 0===e?void 0:e.status)?(0,D.jsxs)("div",{className:"alert alert-warning mb-0 small",children:[(0,D.jsx)("i",{className:"feather icon-alert-circle me-2"}),"Snapchat Ads is authorized but no account is selected."," ",(0,D.jsx)("a",{href:"/connections",className:"alert-link",children:"Go to Connections"})," to select one."]}):(0,D.jsxs)("div",{className:"d-flex flex-column align-items-start gap-2",children:[(0,D.jsx)(f.A,{variant:"secondary",size:"sm",disabled:"snapchat_ads"===Ut,onClick:()=>qt("snapchat_ads"),children:"snapchat_ads"===Ut?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Connecting\u2026"]}):"Enable Snapchat Ads"}),(0,D.jsx)("div",{className:"small text-muted mt-1",children:"Connect Snapchat Ads account to send conversion events."})]})})()]}),(0,D.jsxs)("div",{className:"card shadow-sm p-3 h-100",style:_e&&!Ae?{border:"2px s
1olid #dc3545",boxShadow:"0 0 0 3px rgba(220,53,69,0.25)",position:"relative"}:{border:"1px solid var(--bs-border-color, #dee2e6)",position:"relative"},children:[_e&&!Ae&&(0,D.jsx)("span",{className:"label pcoded-badge bg-danger",style:{position:"absolute",top:8,right:8,fontSize:"0.75rem",lineHeight:"1.1",padding:"2px 8px",borderRadius:"4px",color:"#fff"},children:"!"}),(0,D.jsxs)("div",{className:"d-flex align-items-center gap-3 mb-3",children:[(0,D.jsx)("div",{style:{width:36,height:36,background:"#fff",borderRadius:"50%",border:"1px solid #dee2e6",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,D.jsx)("img",{src:Os,alt:"TikTok",style:{width:32,height:32,objectFit:"contain"}})}),(0,D.jsxs)("div",{className:"flex-grow-1",children:[(0,D.jsx)("h6",{className:"mb-0",children:"TikTok Ads"}),(0,D.jsx)("small",{className:"text-muted",children:"Server-side Events API"})]})]}),_e&&(0,D.jsx)(Ps,{platform:"tiktok",accounts:_.tiktok,boundAccount:k.tiktok,onSelect:xa}),_e?(0,D.jsxs)(D.Fragment,{children:[Oe&&(0,D.jsx)("div",{className:"platform-error small py-2 px-3 mb-3 rounded",children:Oe}),!Ae&&(0,D.jsx)(v.A.Group,{className:"mt-2 mb-3",children:Le?(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2 text-muted small py-2",children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm",role:"status","aria-hidden":"true"}),"Loading pixels\u2026"]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(v.A.Control,{as:"select",value:Fe,onChange:e=>{const s=e.target.value;Ee(s),"new"===s?We(e=>e||"LinkClicks Universal Pixel"):(We(""),s&&(zt(""),At({open:!0,platform:"TikTok Ads",platformKey:"tiktok",pixelLabel:"TikTok Pixel",enableForwarding:!0,onConfirm:ua("tiktok")})))},disabled:$e||Re,children:[(0,D.jsx)("option",{value:"",disabled:!0,children:"Connect TikTok Pixel"}),0===ze.length&&(0,D.jsx)("option",{disabled:!0,children:"No pixels found"}),ze.map(e=>(0,D.jsx)("option",{value:e.id,children:e.name&&e.name!==e.id?e.name:e.id},e.id)),(0,D.jsx)("option",{value:"new",children:"+ Create new TikTok Pixel"})]}),"new"===Fe&&(0,D.jsxs)("div",{className:"d-flex gap-2 mt-2",children:[(0,D.jsx)(v.A.Control,{type:"text",placeholder:"Pixel name, e.g. LinkClicks Universal Pixel",value:Be,onChange:e=>We(e.target.value),disabled:Re,autoFocus:!0}),(0,D.jsx)(f.A,{variant:"primary",size:"sm",className:"text-nowrap",disabled:Re||!Be.trim(),onClick:ma,children:Re?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Creating\u2026"]}):"Create & Link TikTok Pixel"})]}),Ae&&"new"!==Fe&&(0,D.jsxs)("div",{className:"mt-1 small text-muted",children:["Active pixel: ",(0,D.jsx)("code",{children:Sa||Ae}),Fe===Ae&&(0,D.jsxs)("span",{className:"ms-2 text-success",children:[(0,D.jsx)("i",{className:"feather icon-check me-1"}),"Saved"]})]})]})}),Ae&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"d-flex flex-wrap gap-2 align-items-center mt-2 mb-1",children:[(0,D.jsx)(f.A,{variant:"success",size:"sm",className:"text-nowrap",disabled:$e,onClick:()=>wt({open:!0,platform:"TikTok Ads",label:"TikTok Pixel",onConfirm:async()=>{Ie(!0);try{await(0,y.patchWithToken)(`/conversions/pixels/${s}/platform_mappings/`,{platform:"tiktok",pixel_code:"",enabled:!1}),Pe(""),Ee(""),ke(!1)}finally{Ie(!1)}}}),children:$e?(0,D.jsx)("span",{className:"spinner-border spinner-border-sm",role:"status","aria-hidden":"true"}):"Pixel Connected"}),(0,D.jsx)(f.A,{variant:we?"success":"secondary",size:"sm",disabled:$e,onClick:()=>jt({open:!0,platform:"TikTok Ads",enable:!we,onConfirm:()=>da({enabled:!we,tiktok_only:Se,pixel_code:Ae}),message:we?"Pause forwarding of non-ad-click events to TikTok.":"Enable forwarding of all conversions to TikTok, including those not from a TikTok ad click."}),children:$e?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Saving\u2026"]}):we?"Forwarding Events":"Enable Forwarding"})]}),(0,D.jsxs)("div",{className:"small text-muted mt-1",children:[(0,D.jsx)("i",{className:"feather icon-link me-1"}),"Connected pixel: ",(0,D.jsx)("code",{children:Sa||Ae})]})]})]}):(0,D.jsx)(Gt,{platformKey:"tiktok_ads",platformLabel:"TikTok Ads"})]})]}),(0,D.jsxs)(p.A,{show:bt.open,onHide:()=>jt({open:!1,platform:"",enable:!1,onConfirm:null,message:""}),centered:!0,children:[(0,D.jsx)(p.A.Header,{closeButton:!0,children:(0,D.jsx)(p.A.Title,{children:bt.enable?"Enable forwarding":"Pause forwarding"})}),(0,D.jsxs)(p.A.Body,{children:[(0,D.jsx)("p",{className:"mb-2",children:bt.message}),bt.enable?(0,D.jsxs)("p",{className:"mb-0 text-muted small",children:["When your pixel is connected, conversions from ",bt.platform," ad clicks are already forwarded automatically.",(0,D.jsx)("strong",{children:" Enable Forwarding"})," also sends events without a matching click ID \u2014 such as organic visits, direct traffic, or referrals \u2014 giving your campaigns a more complete view of assisted conversions."]}):(0,D.jsxs)("p",{className:"mb-0 text-muted small",children:["Only conversions with a matching ",bt.platform," click ID will continue to be sent. Events from organic, direct, or other channels will no longer be forwarded."]})]}),(0,D.jsxs)(p.A.Footer,{children:[(0,D.jsx)(f.A,{variant:"secondary",onClick:()=>jt({open:!1,platform:"",enable:!1,onConfirm:null,message:""}),disabled:yt,children:"Cancel"}),(0,D.jsx)(f.A,{variant:bt.enable?"primary":"outline-secondary",onClick:async()=>
1{if(null!==bt&&void 0!==bt&&bt.onConfirm){Nt(!0);try{await bt.onConfirm(),jt({open:!1,platform:"",enable:!1,onConfirm:null,message:""})}finally{Nt(!1)}}else jt(e=>({...e,open:!1}))},disabled:yt,children:yt?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Saving\u2026"]}):bt.enable?"Enable Forwarding":"Pause Forwarding"})]})]}),(0,D.jsxs)(p.A,{show:Ct.open,onHide:va,centered:!0,children:[(0,D.jsx)(p.A.Header,{closeButton:!0,children:(0,D.jsx)(p.A.Title,{children:Na})}),(0,D.jsxs)(p.A.Body,{children:[(0,D.jsx)("p",{className:"mb-3",children:ya?(0,D.jsxs)(D.Fragment,{children:["We will create a new ",(0,D.jsx)("strong",{children:"Meta Pixel"})," and connect it to your selected ad account, then start forwarding conversion events in real time."]}):(0,D.jsxs)(D.Fragment,{children:["Once connected, conversion events from your website will be forwarded to ",(0,D.jsx)("strong",{children:Ct.platform})," in real time via their server-side API \u2014 as long as your Universal Pixel is installed on your site."]})}),(0,D.jsxs)("p",{className:"mb-3 text-muted small",children:["Events from ",Ct.platform," ad clicks are always forwarded automatically. You can also choose to forward events from other traffic sources below."]}),Tt?(0,D.jsxs)("div",{className:"mt-3",children:[(0,D.jsx)(bs.A,{animated:!0,striped:!0,now:Math.max(0,Math.min(100,Number(Dt)||0)),variant:"primary",style:{height:"20px"},label:`${Math.round(Dt)}%`}),(0,D.jsx)("div",{className:"d-flex flex-column gap-2 align-items-start mt-3",children:Rt.map((e,s)=>{const t=s===Et,a=s<Et;return(0,D.jsxs)("div",{className:"d-flex align-items-center w-100",style:{opacity:a?.65:t?1:.5},children:[t?(0,D.jsx)("span",{className:"spinner-border spinner-border-sm text-primary me-2",role:"status","aria-hidden":"true"}):(0,D.jsx)("i",{className:a?"feather icon-check-circle text-success me-2":"feather icon-circle text-muted me-2","aria-hidden":"true"}),(0,D.jsx)("span",{className:"small text-muted",children:e})]},e)})}),(0,D.jsx)("p",{className:"text-muted small mt-3 mb-0",children:"We\u2019re handling the heavy lifting to link your pixel and conversion events."})]}):(0,D.jsxs)(D.Fragment,{children:[(()=>{const e=Ct.pixelLabel||(0,Us.D5)(Ct.platform)||"Pixel";switch(fa){case"meta":return(0,D.jsxs)(v.A.Group,{className:"mb-3",children:[(0,D.jsx)(v.A.Label,{className:"small fw-medium text-muted",children:e}),ba?(0,D.jsxs)("div",{className:"small text-muted",children:["Existing Meta Pixel detected. Click ",(0,D.jsx)("strong",{children:"Connect"})," to link it and enable forwarding options."]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(v.A.Control,{type:"text",placeholder:"Pixel name, e.g. LinkClicks Universal Pixel",value:B,onChange:e=>W(e.target.value),disabled:K,autoFocus:!0}),(0,D.jsx)("div",{className:"small text-muted mt-2",children:"No Meta Pixel was found. We will create one with this name and connect it."})]})]});case"tiktok":return(0,D.jsxs)(v.A.Group,{className:"mb-3",children:[(0,D.jsx)(v.A.Label,{className:"small fw-medium text-muted",children:e}),Le?(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2 text-muted small py-2",children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm",role:"status","aria-hidden":"true"}),"Loading pixels\u2026"]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(v.A.Control,{as:"select",value:Fe,onChange:e=>{const s=e.target.value;Ee(s),We("new"===s?e=>e||"LinkClicks Universal Pixel":"")},disabled:$e||Re,children:[(0,D.jsx)("option",{value:"",disabled:!0,children:"Connect TikTok Pixel"}),0===ze.length&&(0,D.jsx)("option",{disabled:!0,children:"No pixels found"}),ze.map(e=>(0,D.jsx)("option",{value:e.id,children:e.name&&e.name!==e.id?e.name:e.id},e.id)),(0,D.jsx)("option",{value:"new",children:"+ Create new TikTok Pixel"})]}),"new"===Fe&&(0,D.jsxs)("div",{className:"d-flex gap-2 mt-2",children:[(0,D.jsx)(v.A.Control,{type:"text",placeholder:"Pixel name, e.g. LinkClicks Universal Pixel",value:Be,onChange:e=>We(e.target.value),disabled:Re,autoFocus:!0}),(0,D.jsx)(f.A,{variant:"primary",size:"sm",className:"text-nowrap",disabled:Re||!Be.trim(),onClick:ma,children:Re?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Creating\u2026"]}):"Create & Link"})]})]})]});case"linkedin":return(0,D.jsxs)(v.A.Group,{className:"mb-3",children:[(0,D.jsx)(v.A.Label,{className:"small fw-medium text-muted",children:e}),(0,D.jsx)("div",{className:"small text-muted",children:"Connect will automatically match and create LinkedIn conversion events for all events attached to this pixel."})]});case"pinterest":return(0,D.jsxs)(v.A.Group,{className:"mb-3",children:[(0,D.jsx)(v.A.Label,{className:"small fw-medium text-muted",children:e}),_s?(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2 text-muted small py-2",children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm",role:"status","aria-hidden":"true"}),"Loading conversion tags\u2026"]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(v.A.Control,{as:"select",value:ys,onChange:e=>{const s=e.target.value;Ns(s),Fs("new"===s?e=>e||"LinkClicks Tag":"")},disabled:ks||Cs,children:[(0,D.jsx)("option",{value:"",disabled:!0,children:"Connect Pinterest Tag"}),0===gs.length&&(0,D.jsx)("option",{disabled:!0,children:"No conversion tags found"}),gs.map(e=>(0,D.jsx)("option",{value:e.id,children:e.name&&e.name!==e.id?e.name:e.id},e.id)),(0,D.jsx)("option",{value:"new",children:"+ Create new Pinterest Tag"})]}),"new"===ys&&(0,D.jsxs)("div",{className:"d-flex gap-2 mt-2",children:[(0,D.jsx)(v.A.Control,{type:"text",placeholder:"Tag name, e.g. LinkClicks Tag",value:Ts,onChange:e=>Fs(e.target.value),disabled:Cs,autoFocus:!0}),(0,D.jsx)(f.A,{variant:"primary",size:"sm",className:"text-nowrap",disabled:Cs||!Ts.trim(),onClick:ha,children:Cs?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Creating\u2026"]}):"Create & Link"})]})]})]});case"snapchat":return(0,D.jsxs)(v.A.Group,{className:"mb-3",children:[(0,D.jsx)(v.A.Label,{className:"small fw-medium text-muted",children:e}),rt?(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2 text-muted small py-2",children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm",role:"status","aria-hidden":"true"}),"Loading pixels\u2026"]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(v.A.Control,{as:"select",value:it,onChange:e=>{const s=e.target.value;lt(s),gt("new"===s)},disabled:ct,children:[(0,D.jsx)("option",{value:"",disabled:!0,children:"Connect Snapchat Pixel"}),0===at.length&&(0,D.jsx)("option",{disabled:!0,children:"No pixels found"}),at.map(e=>(0,D.jsx)("option",{value:e.id,children:e.name&&e.name!==e.id?e.name:e.id},e.id)),(0,D.jsx)("option",{value:"new",children:"+ Create new Snapchat Pixel"})]}),"new"===it&&(0,D.jsxs)("div",{className:"mt-2 text-muted small",children:["Creation must be done in Snapchat Ads Manager.",(0,D.jsx)("div",{className:"mt-2",children:(0,D.jsx)(f.A,{variant:"outline-primary",size:"sm",onClick:Vt,disabled:mt,children:mt?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Opening\u2026"]}):"Open Snapchat Pixel Settings"})})]})]})]});default:return null}}
1)(),Pt&&(0,D.jsx)("div",{className:"py-2 px-3 small rounded",style:{background:"#5c1a1a",color:"#f8d7da",border:"1px solid #842029"},children:Pt}),"google_ads"!==Ct.platformKey&&(0,D.jsx)(v.A.Check,{type:"checkbox",id:"connectForwardingCheck",className:"mt-2",label:(0,D.jsxs)("span",{children:["Also forward events ",(0,D.jsx)("strong",{children:"not"})," tied to a ",Ct.platform," ad click ",(0,D.jsx)("span",{className:"text-muted",children:"(organic, direct, email, etc.)"})]}),checked:Ct.enableForwarding,onChange:()=>At(e=>({...e,enableForwarding:!e.enableForwarding}))})]})]}),(0,D.jsxs)(p.A.Footer,{children:[(0,D.jsx)(f.A,{variant:"secondary",onClick:va,disabled:Tt,children:"Cancel"}),(0,D.jsx)(f.A,{variant:"primary",disabled:Pa,onClick:async()=>{switch(zt(""),fa){case"meta":if(!ba&&!(B||"").trim())return void zt("Enter a Meta Pixel name to create one.");break;case"tiktok":if(!Fe||"new"===Fe)return void zt("Select or create a TikTok Pixel first.");break;case"linkedin":default:break;case"pinterest":if(!ys||"new"===ys)return void zt("Select or create a Pinterest tag first.");break;case"snapchat":if(!it||"new"===it)return void zt("Select a Snapchat pixel.")}const{onConfirm:e,enableForwarding:s}=Ct;Ft(!0),Lt(0),$t(0);let t=null,a=!1;const n=()=>{t&&(clearTimeout(t),t=null)},i=()=>{n(),t=setTimeout(()=>{$t(e=>{const s=Math.max(0,Math.min(100,Number(e)||0)),t=a?99:92;return s>=t?s:Math.min(s+1,t)}),i()},Ks(125,175))};try{i();const t=(()=>{switch(fa){case"meta":return la(s);case"tiktok":return da({enabled:s,tiktok_only:Se,pixel_code:Fe});case"linkedin":return ca(!0,{forwardNonClickEvents:s});case"pinterest":return pa("pinterest",{enabled:s,pixel_code:ys},{setSavingState:Ss,setErrorState:Hs,setEnabledState:ps,setPixelCodeState:fs,setSelectedIdState:Ns,fallbackError:"Failed to link Pinterest tag."});case"snapchat":return pa("snapchat",{enabled:s,pixel_code:it},{setSavingState:dt,setErrorState:xt,setEnabledState:Xs,setPixelCodeState:tt,setSelectedIdState:lt,fallbackError:"Failed to link Snapchat pixel."});default:return e?e(s):Promise.resolve()}})();await t,a=!0,await new Promise(e=>{const s=()=>{It.current>=99?e():setTimeout(s,80)};s()}),await new Promise(e=>setTimeout(e,Ks(500,900))),n(),$t(100),await new Promise(e=>setTimeout(e,Ks(260,420))),va()}catch(o){var l,r;zt((null===o||void 0===o||null===(l=o.response)||void 0===l||null===(r=l.data)||void 0===r?void 0:r.detail)||(null===o||void 0===o?void 0:o.message)||"Failed to connect. Please try again.")}finally{n(),Ft(!1)}},children:Pa?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),Tt?"Linking\u2026":"Saving\u2026"]}):_a})]})]}),(0,D.jsxs)(p.A,{show:_t.open,onHide:()=>wt({open:!1,platform:"",label:"",onConfirm:null}),centered:!0,children:[(0,D.jsx)(p.A.Header,{closeButton:!0,children:(0,D.jsxs)(p.A.Title,{children:["Disconnect ",_t.label||_t.platform,"?"]})}),(0,D.jsxs)(p.A.Body,{children:[(0,D.jsxs)("p",{className:"mb-2",children:["Are you sure you want to disconnect your ",_t.label||_t.platform,"?"]}),(0,D.jsxs)("p",{className:"mb-0 text-muted small",children:["We\u2019ll stop sending conversion events to ",_t.platform,". This will affect your ad performance reporting and campaign attribution. You can reconnect at any time."]})]}),(0,D.jsxs)(p.A.Footer,{children:[(0,D.jsx)(f.A,{variant:"secondary",onClick:()=>wt({open:!1,platform:"",label:"",onConfirm:null}),disabled:kt,children:"Cancel"}),(0,D.jsx)(f.A,{variant:"danger",onClick:async()=>{if(null!==_t&&void 0!==_t&&_t.onConfirm){St(!0);try{await _t.onConfirm(),wt({open:!1,platform:"",label:"",onConfirm:null})}catch{}finally{St(!1)}}else wt(e=>({...e,open:!1}))},disabled:kt,children:kt?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Disconnecting\u2026"]}):"Disconnect"})]})]})]})},nt=e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(String(e||"")),it=e=>{var s,t,i,l,r,o,c;let{pixelKey:d,conversionEvents:m,onEmailInstructions:h}=e;const x=(0,n.wA)(),{getEventsForPixel:p,fetchForPixel:v,removeDefinition:b}=(0,g.qU)(),{mainEventParameters:j,updateEventParameter:N,clearEventParam
1s:_}=(0,g.Xw)(),{loadConversionEvents:w,loading:k,error:S}=(0,g.bF)(),[C]=(0,a.useState)({}),[A,P]=(0,a.useState)(null),[z,T]=(0,a.useState)(!1),[F,E]=(0,a.useState)(!1),[L,$]=(0,a.useState)(!1),[I,R]=(0,a.useState)(!1),[M,B]=(0,a.useState)(!1),[W,O]=(0,a.useState)(""),[U,H]=(0,a.useState)(null),K=(0,a.useRef)(null),q=(0,a.useRef)(d),G=(0,a.useMemo)(()=>d?p(d):[],[d,p]),V=(0,a.useMemo)(()=>G.map(e=>e.event_key||e.id).filter(Boolean),[G]),Q=(0,a.useMemo)(()=>{if(!m)return[];const e=new Set(V);return 0===e.size?[]:m.filter(s=>e.has(s.event_key||s.id))},[m,V]),Y=(0,a.useMemo)(()=>{if(!m)return[];const e=new Set(V);return m.filter(s=>!e.has(s.event_key||s.id))},[m,V]),X=Array.isArray(m)&&m.length>0,J=(0,a.useMemo)(()=>{const e=new Set(V);return ds.map(s=>{const t=s.events.filter(s=>!e.has(s));return{...s,toAdd:t,missingCount:t.length,allAdded:X&&0===t.length}})},[V,X]),Z=(0,a.useMemo)(()=>(null===m||void 0===m?void 0:m.find(e=>e.id===A||e.event_key===A))||null,[m,A]),ee=(null===Z||void 0===Z?void 0:Z.name)||A||"";(0,a.useEffect)(()=>{!A&&Q.length>0&&P(Q[0].event_key||Q[0].id)},[Q,A]),(0,a.useEffect)(()=>{q.current!==d&&(q.current=d,P(null),T(!1))},[d]),(0,a.useEffect)(()=>{d&&v(d,!1)},[d]);const se=(0,a.useRef)(!1);(0,a.useEffect)(()=>{se.current||(se.current=!0,w())},[w]),(0,a.useEffect)(()=>{if(!I)return;const e=e=>{K.current&&!K.current.contains(e.target)&&R(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[I]);const te=(0,a.useCallback)(e=>{let s=e;if(nt(e)){const t=null===m||void 0===m?void 0:m.find(s=>s.event_uuid===e);null!==t&&void 0!==t&&t.event_key&&(s=t.event_key)}const t=(e=>{const s=[{name:"email",checked:!0},{name:"phone",checked:!0},{name:"external_id",checked:!1}],t={purchase:{eventParams:[{name:"brand",checked:!0},{name:"content_category",checked:!0},{name:"content_id",checked:!0},{name:"content_name",checked:!0},{name:"content_type",checked:!0},{name:"currency",checked:!0},{name:"description",checked:!1},{name:"event_id",checked:!0},{name:"price",checked:!0},{name:"num_items",checked:!0},{name:"search_string",checked:!1},{name:"status",checked:!1},{name:"value",checked:!0}],userParams:[...s]},app_install:{eventParams:[{name:"brand",checked:!1},{name:"content_category",checked:!1},{name:"content_id",checked:!0},{name:"content_name",checked:!0},{name:"content_type",checked:!0},{name:"currency",checked:!1},{name:"description",checked:!1},{name:"event_id",checked:!0},{name:"price",checked:!1},{name:"num_items",checked:!1},{name:"search_string",checked:!1},{name:"status",checked:!1},{name:"value",checked:!1}],userParams:[...s]},add_to_cart:{eventParams:[{name:"brand",checked:!1},{name:"content_category",checked:!0},{name:"content_id",checked:!0},{name:"content_name",checked:!0},{name:"content_type",checked:!0},{name:"currency",checked:!0},{name:"description",checked:!1},{name:"event_id",checked:!0},{name:"price",checked:!1},{name:"num_items",checked:!0},{name:"search_string",checked:!1},{name:"status",checked:!1},{name:"value",checked:!0}],userParams:[...s]},add_to_wishlist:{eventParams:[{name:"brand",checked:!1},{name:"content_category",checked:!0},{name:"content_id",checked:!0},{name:"content_name",checked:!0},{name:"content_type",checked:!0},{name:"currency",checked:!0},{name:"description",checked:!1},{name:"event_id",checked:!0},{name:"price",checked:!1},{name:"num_items",checked:!1},{name:"search_string",checked:!1},{name:"status",checked:!1},{name:"value",checked:!0}],userParams:[...s]}
1,lead:{eventParams:[{name:"brand",checked:!1},{name:"content_category",checked:!0},{name:"content_id",checked:!1},{name:"content_name",checked:!0},{name:"content_type",checked:!1},{name:"currency",checked:!0},{name:"description",checked:!1},{name:"event_id",checked:!0},{name:"price",checked:!1},{name:"num_items",checked:!1},{name:"search_string",checked:!1},{name:"status",checked:!1},{name:"value",checked:!0}],userParams:[...s]},view_content:{eventParams:[{name:"brand",checked:!1},{name:"content_category",checked:!0},{name:"content_id",checked:!0},{name:"content_name",checked:!0},{name:"content_type",checked:!0},{name:"currency",checked:!1},{name:"description",checked:!1},{name:"event_id",checked:!0},{name:"price",checked:!1},{name:"num_items",checked:!1},{name:"search_string",checked:!1},{name:"status",checked:!1},{name:"value",checked:!1}],userParams:[...s]},search:{eventParams:[{name:"brand",checked:!1},{name:"content_category",checked:!1},{name:"content_id",checked:!1},{name:"content_name",checked:!1},{name:"content_type",checked:!1},{name:"currency",checked:!1},{name:"description",checked:!1},{name:"event_id",checked:!1},{name:"price",checked:!1},{name:"num_items",checked:!1},{name:"search_string",checked:!0},{name:"status",checked:!1},{name:"value",checked:!1}],userParams:[{name:"email",checked:!1},{name:"phone",checked:!0},{name:"external_id",checked:!1}]}}[e]||{eventParams:[{name:"brand",checked:!1},{name:"content_category",checked:!0},{name:"content_id",checked:!0},{name:"content_name",checked:!0},{name:"content_type",checked:!0},{name:"currency",checked:!0},{name:"description",checked:!1},{name:"event_id",checked:!0},{name:"price",checked:!1},{name:"num_items",checked:!1},{name:"search_string",checked:!1},{name:"status",checked:!1},{name:"value",checked:!0}],userParams:[...s]};return{eventParams:t.eventParams.map(e=>({...e})),userParams:t.userParams.map(e=>({...e}))}})(s),a=j[s];if(!a)return t;if("search"===s&&a.eventParams){if(!a.eventParams.some(e=>"search_string"===e.name&&e.checked))return t}return{eventParams:t.eventParams.map((e,s)=>{var t;return{...e,checked:null!=(null===(t=a.eventParams)||void 0===t?void 0:t[s])?a.eventParams[s].checked:e.checked}}),userParams:t.userParams.map((e,s)=>{var t;return{...e,checked:null!=(null===(t=a.userParams)||void 0===t?void 0:t[s])?a.userParams[s].checked:e.checked}})}},[j,m]),ae=(0,a.useCallback)(async(e,s,t,a)=>{let n=e,i=e;if(nt(e)){const s=null===m||void 0===m?void 0:m.find(s=>s.event_uuid===e);null!==s&&void 0!==s&&s.event_key&&(n=s.event_key)}else{const s=null===m||void 0===m?void 0:m.find(s=>s.event_key===e);null!==s&&void 0!==s&&s.event_uuid&&(i=s.event_uuid)}N(n,s,t,a);try{const e=te(n);
1if(e){const n=(e.eventParams||[]).map((e,n)=>({name:e.name,enabled:"eventParams"===s&&n===t?a:e.checked})),l=(e.userParams||[]).map((e,n)=>({name:e.name,enabled:"userParams"===s&&n===t?a:e.checked}));await x((0,u.k7)({eventId:i,eventParams:n,userParams:l}))}}catch{N(n,s,t,!a)}},[m,N,te,x]),ne=(0,a.useCallback)(e=>{_(e)},[_]),ie=(0,a.useCallback)(e=>{const s=null===m||void 0===m?void 0:m.find(s=>s.id===e||s.event_key===e);if(null!==s&&void 0!==s&&s.icon)return Qs(s.icon)||"feather icon-activity";const t=os.n[(null===s||void 0===s?void 0:s.event_key)||e];return null!==t&&void 0!==t&&t.icon&&Qs(t.icon)||"feather icon-activity"},[m]),oe=(0,a.useCallback)(e=>{const s=Ys[e]||{};return{label:s.label||Xs(e),description:s.description||"Optional context passed with this event to improve reporting and ad-platform matching."}},[]),ce=(0,a.useCallback)(async(e,s)=>{try{await navigator.clipboard.writeText(e),H(s),setTimeout(()=>H(null),2e3)}catch{}},[]),de=(0,a.useCallback)(e=>{var s,t;let a=e;if(nt(e)){const s=null===m||void 0===m?void 0:m.find(s=>s.event_uuid===e);null!==s&&void 0!==s&&s.event_key&&(a=s.event_key)}const n=te(e);if(!n)return"";const i={},l={};null===(s=n.eventParams)||void 0===s||s.forEach(e=>{e.checked&&(i[e.name]=`'${e.name.toUpperCase()}_VALUE'`)}),null===(t=n.userParams)||void 0===t||t.forEach(e=>{e.checked&&(l[e.name]=`'${e.name.toUpperCase()}_VALUE'`)});let r=`<script>\n  // Track ${a} conversion event\n  lk('t', '${a}'`;return(Object.keys(i).length>0||Object.keys(l).length>0)&&(r+=", {\n",Object.keys(i).length>0&&(r+="    // Event parameters\n",Object.entries(i).forEach(e=>{let[s,t]=e;r+=`    ${s}: ${t},\n`})),Object.keys(l).length>0&&(r+="    // User parameters\n",Object.entries(l).forEach(e=>{let[s,t]=e;r+=`    ${s}: ${t},\n`})),r=r.slice(0,-2)+"\n",r+="  }"),r+=");\n<\/script>",r},[m,te]),me=(0,a.useCallback)(async e=>{const s=null===m||void 0===m?void 0:m.find(s=>s.id===e||s.event_key===e);if(s&&d){P(e),R(!1);try{var t;const a=[{name:s.name,event_key:s.event_key||s.id,standard_type:s.standard_type||"custom",description:s.description||"",icon:s.icon||"",enabled:!0,event_params:[],user_params:[]}];await(0,y.Ku)("/conversions/events/bulk_upsert/",a);((null===(t=await(0,y.qQ)(`/conversions/pixels/${d}/events/`))||void 0===t?void 0:t.data)||[]).some(s=>s.event_key===e||s.id===e)||await(0,y.Ku)(`/conversions/pixels/${d}/events/bulk_create/`,a),await v(d,!0),w(),P(e)}catch(a){console.error("Failed to add event to pixel:",a)}}},[m,d,v,w]),he=(0,a.useCallback)(async()=>{if(!W.trim())return;const e=`custom_${W.toLowerCase().replace(/[^a-z0-9]/g,"_")}`,s=[{name:W.trim(),event_key:e,standard_type:"custom",description:`Custom event: ${W.trim()}`,enabled:!0,event_params:[],user_params:[]}];try{await(0,y.Ku)("/conversions/events/bulk_upsert/",s),d&&(await(0,y.Ku)(`/conversions/pixels/${d}/events/bulk_create/`,s),await v(d,!0)),w(),P(e),O(""),B(!1),R(!1)}catch(t){console.error("Failed to create custom event:",t)}},[W,d,v,w]),ue=(0,a.useCallback)(async()=>{if(d&&A){$(!0);try{const e=((await(0,y.qQ)(`/conversions/pixels/${d}/events/`)).data||[]).find(e=>e.event_key===A||e.id===A||e.name===A);if(null===e||void 0===e||!e.id)return b(d,A),null===ne||void 0===ne||ne(A),P(V.filter(e=>e!==A)[0]||null),void E(!1);await(0,y.tX)(`/conversions/pixels/${d}/events/${e.id}/`);try{await(0,y.tX)(`/conversions/events/${e.event_key||A}/`)}catch{}b(d,A),null===ne||void 0===ne||ne(A),P(V.filter(e=>e!==A)[0]||null),E(!1),w(),v(d,!0)}catch(t){var e,s;console.error("Failed to remove event from pixel:",t),alert(`Failed to remove event from pixel: ${(null===(e=t.response)||void 0===e||null===(s=e.data)||void 0===s?void 0:s.detail)||t.message||"Unknown error"}`)}finally{$(!1)}}},[A,d,b,V,ne,w,v]),xe=(0,D.jsx)("div",{className:"d-flex align-items-center gap-2",children:(0,D.jsxs)("div",{className:"position-relative",ref:K,children:[(0,D.jsxs)("button",{type:"button",className:"btn btn-outline-primary btn-sm d-flex align-items-center gap-1",style:{flexShrink:0},onClick:()=>R(e=>!e),children:[(0,D.jsx)("i",{className:"feather icon-plus",style:{fontSize:"0.75rem"}}),"Add Event"]}),I&&(0,D.jsx)("div",{className:"dropdown-menu show position-absolute conversions-event-selector",style:{to
1p:"100%",left:0,right:"auto",zIndex:1050},children:(0,D.jsxs)("div",{className:"conversions-event-selector__grid",children:[(0,D.jsxs)("div",{className:"conversions-event-selector__column conversions-event-selector__column--events",children:[(0,D.jsxs)("div",{className:"conversions-event-selector__column-header",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h6",{className:"conversions-event-selector__title mb-1",children:"Events"}),(0,D.jsx)("p",{className:"conversions-event-selector__helper mb-0",children:"Add a single standard or custom event."})]}),(0,D.jsx)("span",{className:"conversions-event-selector__meta",children:Y.length})]}),(0,D.jsx)("div",{className:"conversions-event-selector__list",children:Y.length>0?Y.map(e=>(0,D.jsx)("button",{type:"button",className:"conversions-event-selector__item",onClick:()=>me(e.event_key||e.id),children:(0,D.jsxs)("span",{className:"conversions-event-selector__item-main",children:[(0,D.jsx)("i",{className:`${ie(e.event_key||e.id)} conversions-event-selector__item-icon`}),(0,D.jsx)("span",{className:"conversions-event-selector__item-text",children:e.name})]})},e.event_key||e.id)):(0,D.jsxs)("div",{className:"conversions-event-selector__empty-state",children:[k&&"Loading available events\u2026",!k&&S&&(0,D.jsxs)(D.Fragment,{children:["Could not load the event catalog."," ",(0,D.jsx)("button",{type:"button",className:"btn btn-link btn-sm p-0 align-baseline",onClick:()=>w(),children:"Retry"})]}),!k&&!S&&X&&"Every available event is already attached to this pixel.",!k&&!S&&!X&&"No events available yet."]})}),(0,D.jsx)("div",{className:"conversions-event-selector__footer",children:M?(0,D.jsxs)("div",{className:"conversions-event-selector__custom-form",children:[(0,D.jsx)("label",{className:"form-label small text-muted mb-1",children:"Event Name"}),(0,D.jsx)("input",{type:"text",className:"form-control form-control-sm mb-2",placeholder:"Enter custom event name...",value:W,onChange:e=>O(e.target.value),onKeyDown:e=>{"Enter"===e.key&&W.trim()?he():"Escape"===e.key&&(B(!1),O(""))},autoFocus:!0,maxLength:50}),(0,D.jsxs)("div",{className:"d-flex gap-2",children:[(0,D.jsx)("button",{type:"button",className:"btn btn-primary btn-sm flex-grow-1",onClick:he,disabled:!W.trim(),style:{fontSize:"0.75rem"},children:"Create"}),(0,D.jsx)("button",{type:"button",className:"btn btn-outline-secondary btn-sm",onClick:()=>{B(!1),O("")},style:{fontSize:"0.75rem"},children:"Cancel"})]})]}):(0,D.jsxs)("button",{type:"button",className:"conversions-event-selector__custom-trigger",onClick:()=>B(!0),children:[(0,D.jsx)("i",{className:"feather icon-plus conversions-event-selector__item-icon"}),(0,D.jsx)("span",{children:"Create Custom Event"})]})})]}),(0,D.jsxs)("div",{className:"conversions-event-selector__column conversions-event-selector__column--templates",children:[(0,D.jsxs)("div",{className:"conversions-event-selector__column-header",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h6",{className:"conversions-event-selector__title mb-1",children:"Templates"}),(0,D.jsx)("p",{className:"conversions-event-selector__helper mb-0",children:"Batch-add a curated event set."})]}),(0,D.jsx)("span",{className:"conversions-event-selector__meta",children:J.length})]}),(0,D.jsx)("div",{className:"conversions-event-selector__list",children:J.map(e=>(0,D.jsxs)("button",{type:"button",className:"conversions-event-selector__template",disabled:e.allAdded,onClick:()=>{e.toAdd.forEach(e=>me(e)),R(!1)},children:[(0,D.jsxs)("div",{className:"conversions-event-selector__template-head",children:[(0,D.jsxs)("span",{className:"conversions-event-selector__item-main",children:[(0,D.jsx)("i",{className:`${e.icon} conversions-event-selector__item-icon`}),(0,D.jsx)("span",{className:"conversions-event-selector__item-text",children:e.name||e.label})]}),e.allAdded?(0,D.jsx)("span",{className:"badge bg-success ms-2",children:"All added"}):(0,D.jsx)("span",{className:"badge bg-secondary ms-2",children:e.missingCount})]}),(0,D.jsx)("div",{className:"conversions-event-selector__template-copy",children:e.description||"Curated event bundle"})]},e.id))})]})]})})]})});return(0,D.jsx)("div",{children:A&&Z?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{className:"alert alert-info mb-3",style:{backgroundColor:"rgba(13, 71, 161, 0.18)",borderColor:"rgba(30, 136, 229, 0.35)",color:"inherit"},role:"alert",children:(0,D.jsxs)("div",{className:"d-flex align-items-start gap-2",children:[(0,D.jsx)("i",{className:"feather icon-info text-info mt-1"}),(0,D.jsxs)("div",{className:"flex-grow-1",children:[(0,D.jsxs)("div",{className:"d-flex justify-content-between align-items-start gap-3 flex-nowrap",children:[(0,D.jsxs)("div",{className:"flex-grow-1",style:{minWidth:0},children:[(0,D.jsx)("h6",{className:"alert-heading",children:"Installation"}),(0,D.jsxs)("p",{className:"small mb-0",children:["This snippet must execute when"," ",null===(s=Z.name)||void 0===s?void 0:s.toLowerCase()," happens."," ",(0,D.jsx)("span",{className:"fw-bold",children:"Page views are tracked by the main Universal Pixel code only. Other 
1conversion events require their own specialized snippets that run exactly when those events happen on your website."})]})]}),(0,D.jsxs)("div",{className:"d-flex gap-2 flex-shrink-0 align-items-center",style:{whiteSpace:"nowrap"},children:[h&&(0,D.jsxs)("button",{type:"button",className:"btn btn-sm btn-outline-primary",style:{whiteSpace:"nowrap"},onClick:()=>h("event",Z.name||"Conversion Event",d),children:[(0,D.jsx)("i",{className:"feather icon-mail me-1"}),"Email instructions"]}),(0,D.jsx)("button",{type:"button",className:"btn btn-sm btn-outline-secondary",style:{whiteSpace:"nowrap"},onClick:()=>T(e=>!e),children:z?"Hide instructions":"Full Instructions"})]})]}),z&&(0,D.jsxs)("div",{className:"mt-3 small",children:[(0,D.jsx)("div",{className:"fw-semibold mb-1",children:"Universal Pixel Event Installation checklist"}),(0,D.jsx)("p",{className:"text-muted mb-2",children:"Follow these steps in order if this is your first time setting up tracking."}),(0,D.jsxs)("ol",{className:"mb-2 ps-3 text-muted",children:[(0,D.jsx)("li",{children:"Install your universal pixel base code on every page of your website."}),(0,D.jsx)("li",{children:"Remember: page views are already tracked by the main universal pixel script."}),(0,D.jsx)("li",{children:"Add this event snippet where this specific event completes (example: form success page)."}),(0,D.jsx)("li",{children:"Make sure the snippet executes at event time, not only on page load."}),(0,D.jsx)("li",{children:"Publish your website changes, then refresh the page and trigger one test event."}),(0,D.jsx)("li",{children:"Open the dashboard test tool and confirm the event appears before adding more custom fields."})]}),(0,D.jsx)("p",{className:"mb-0 text-muted",children:"Start simple first. Once events are arriving correctly, you can add optional parameters later."})]})]})]})}),(0,D.jsx)("div",{className:"card shadow-sm mb-3",children:(0,D.jsxs)("div",{className:"card-body",children:[(!m||0===m.length)&&(0,D.jsxs)("div",{className:"d-flex flex-wrap align-items-center gap-2",children:[(0,D.jsx)("div",{className:"text-muted small",children:"No events yet. Add events to your workspace first."}),xe]}),m&&m.length>0&&(0,D.jsxs)("div",{className:"d-flex flex-wrap align-items-center gap-2 mb-2",children:[Q.map(e=>{const s=e.event_key||e.id,t=A===s;return(0,D.jsxs)("button",{type:"button",className:`btn btn-sm ${t?"btn-primary":"btn-outline-secondary"} px-3 py-2`,onClick:async()=>{if(P(s),d)try{var t;if(!((null===(t=await(0,y.qQ)(`/conversions/pixels/${d}/events/`))||void 0===t?void 0:t.data)||[]).some(e=>e.event_key===s||e.id===s)){const t=te(s),a=[{name:e.name,event_key:s,standard_type:e.standard_type||"standard",description:e.description||"",enabled:!0,event_params:((null===t||void 0===t?void 0:t.eventParams)||[]).map(e=>({name:e.name,enabled:e.checked})),user_params:((null===t||void 0===t?void 0:t.userParams)||[]).map(e=>({name:e.name,enabled:e.checked}))}];await(0,y.Ku)(`/conversions/pixels/${d}/events/bulk_create/`,a),v(d,!0)}}catch(a){console.error("Failed to verify/create pixel event definition:",a)}},children:[(0,D.jsxs)("span",{className:"d-inline-flex align-items-center gap-2 fw-semibold",children:[(0,D.jsx)("i",{className:`${ie(s)} ${t?"":"text-muted"}`,style:{width:16}}),e.name||s]}),e.category&&(0,D.jsx)("span",{className:"text-muted ms-2",style:{fontSize:"0.8rem"},children:e.category})]},s)}),xe]})]})}),(0,D.jsxs)(le.A,{children:[(0,D.jsx)(re.A,{lg:5,children:(0,D.jsxs)("div",{className:"mb-4",children:[(0,D.jsxs)("div",{className:"border rounded p-3 mb-3",children:[(0,D.jsxs)("div",{className:"d-flex align-items-center justify-content-between mb-3",children:[(0,D.jsxs)("h6",{className:"mb-0 d-flex align-items-center gap-2",children:[A&&(0,D.jsx)("i",{className:ie(A)}),(0,D.jsx)("span",{children:ee?`${ee} Parameters`:"Event Parameters"})]}),"event"===(null===(t=C[A])||void 0===t?void 0:t.section)&&(0,D.jsxs)("div",{className:"small ms-3",children:["pending"===C[A].status&&(0,D.jsx)("span",{className:"text-muted",children:"Pending save\u2026"}),"saving"===C[A].status&&(0,D.jsx)("span",{className:"text-info",children:"Saving\u2026"}),"saved"===C[A].status&&(0,D.jsx)("span",{className:"text-success",children:"Saved"}),"error"===C[A].status&&(0,D.jsx)("span",{className:"text-danger",children:"Save failed"})]}),(0,D.jsx)(f.A,{variant:"outline-danger",size:"sm",onClick:()=>E(!0),disabled:!A||!d,children:(0,D.jsx)("i",{className:"feather icon-trash","aria-label":"Remove from pixel"})})]}),(0,D.jsx)("div",{className:"row g-2",children:(null===(i=te(A))||void 0===i||null===(l=i.eventParam
1s)||void 0===l?void 0:l.map((e,s)=>(0,D.jsx)(Js,{param:e,index:s,paramType:"eventParams",selectedEvent:A,updateMainEventParameter:ae,getParameterFieldMeta:oe},`event-${(null===e||void 0===e?void 0:e.name)||s}`)))||[]})]}),(0,D.jsxs)("div",{className:"border rounded p-3",children:[(0,D.jsxs)("div",{className:"d-flex align-items-center justify-content-between mb-3",children:[(0,D.jsx)("h6",{className:"mb-0",children:"User Parameters"}),"user"===(null===(r=C[A])||void 0===r?void 0:r.section)&&(0,D.jsxs)("div",{className:"small ms-3",children:["pending"===C[A].status&&(0,D.jsx)("span",{className:"text-muted",children:"Pending save\u2026"}),"saving"===C[A].status&&(0,D.jsx)("span",{className:"text-info",children:"Saving\u2026"}),"saved"===C[A].status&&(0,D.jsx)("span",{className:"text-success",children:"Saved"}),"error"===C[A].status&&(0,D.jsx)("span",{className:"text-danger",children:"Save failed"})]})]}),(0,D.jsx)("div",{className:"row g-2",children:(null===(o=te(A))||void 0===o||null===(c=o.userParams)||void 0===c?void 0:c.map((e,s)=>(0,D.jsx)(Js,{param:e,index:s,paramType:"userParams",selectedEvent:A,updateMainEventParameter:ae,getParameterFieldMeta:oe},`user-${(null===e||void 0===e?void 0:e.name)||s}`)))||[]})]})]})}),(0,D.jsx)(re.A,{lg:7,children:(0,D.jsx)(Ke,{code:de(A),title:`${ee} Event Code`,itemId:`event-${A}`,copiedItem:U,copyToClipboard:ce})})]}),(0,D.jsx)(ms,{show:F,onHide:()=>E(!1),eventToDelete:Z,pixelName:d,onConfirmDelete:ue,isRemoving:L})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("div",{style:{marginTop:"10px",marginLeft:"10px"},children:xe}),(0,D.jsxs)("div",{className:"text-center py-5",children:[(0,D.jsx)("i",{className:"feather icon-target d-block text-muted mb-3",style:{fontSize:"2.5rem"}}),(0,D.jsx)("h6",{className:"mb-1",children:"No conversion event selected"}),(0,D.jsxs)("p",{className:"text-muted small mb-4",children:['Use the selector above to choose an event, or click "Add Event" to set one up.',(0,D.jsx)("br",{}),"Select an event to configure its parameters and get the installation code."]})]})]})})},lt=e=>null==e?"#94a3b8":e<500?"#22c55e":e<2e3?"#f59e0b":"#ef4444",rt=e=>null==e||""===e?"\u2014":e,ot=e=>{let{title:s,icon:t,children:n,defaultOpen:i=!0,isDark:l}=e;const[r,o]=(0,a.useState)(i),c=l?"rgba(63,63,70,0.72)":"rgba(148,163,184,0.18)";return(0,D.jsxs)("div",{style:{borderTop:`1px solid ${c}`,paddingTop:"1rem",marginTop:"1rem"},children:[(0,D.jsxs)("button",{type:"button",onClick:()=>o(e=>!e),style:{background:"none",border:"none",padding:0,cursor:"pointer",display:"flex",alignItems:"center",gap:6,width:"100%",marginBottom:r?"0.85rem":0,color:l?"#71717a":"#94a3b8"},children:[t&&(0,D.jsx)("i",{className:`feather ${t}`,style:{fontSize:"0.8rem"}}),(0,D.jsx)("span",{style:{fontSize:"0.72rem",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.07em"},children:s}),(0,D.jsx)("i",{className:"feather icon-chevron-"+(r?"up":"down"),style:{fontSize:"0.75rem",marginLeft:"auto"}})]}),r&&n]})},ct=e=>{let{label:s,children:t,mono:a,subtle:n}=e;return(0,D.jsxs)("div",{className:"d-flex align-items-start justify-content-between gap-3 mb-2",children:[(0,D.jsx)("span",{style:{fontSize:"0.81rem",color:n?"#71717a":"#94a3b8",whiteSpace:"nowrap",flexShrink:0,minWidth:130},children:s}),(0,D.jsx)("span",{style:{fontSize:"0.83rem",fontWeight:500,textAlign:"right",fontFamily:a?"monospace":void 0,wordBreak:"break-all"},children:t})]})},dt=e=>{let{color:s,bg:t,border:a,children:n}=e;return(0,D.jsx)("span",{style:{fontSize:"0.75rem",fontWeight:600,padding:"0.2em 0.6em",borderRadius:4,color:s,backgroundColor:t,border:`1px solid ${a}`},children:n})},mt=e=>{let{val:s}=e;return null==s?(0,D.jsx)("span",{style:{color:"#94a3b8"},children:"\u2014"}):s?(0,D.jsxs)("span",{style:{color:"#22c55e"},children:[(0,D.jsx)("i",{className:"feather icon-check me-1"}),"Yes"]}):(0,D.jsxs)("span",{style:{color:"#ef4444"},children:[(0,D.jsx)("i",{className:"feather icon-x me-1"}),"No"]})},ht=e=>{let{val:s}=e;return null==s?(0,D.jsx)("span",{style:{color:"#94a3b8"},children:"\u2014"}):s?(0,D.jsxs)("span",{style:{color:"#22c55e"},children:[(0,D.jsx)("i",{className:"feather icon-check-circle me-1"}),"Present"]}):(0,D.jsx)("span",{style:{color:"#94a3b8"},children:"Not set"})},ut=e=>{var s,t,a,n,i,l,r,o,c,d,m,h,u,x,p,v,f,g,b,y,N;let{show:_,onHide:w,scan:k,pixelName:S}=e;const C=(()=>{try{return"dark"===(0,j.j1)()}catch{var e;return"undefined"!==typeof document&&(null===(e=document.body)||void 0===e?void 0:e.classList.contains("datta-dark"))}})(),A={width:"min(92vw, 600px)",...C?{backgroundColor:"#111111",color:"#e5e7eb",borderLeft:"1px solid rgba(63,63,70,0.7)"}:{}},P=C?{backgroundColor:"#111111",color:"#e5e7eb",borderBottom:"1px solid rgba(63,63,70,0.7)"}:{},z={overflowY:"auto",padding:"1.25rem",...C?{backgroundColor:"#111111",color:"#e5e7eb"}:{}},T=C?"#a1a1aa":"#6c757d",F={...C?{backgroundColor:"#18181b",border:"1px solid rgba(63,63,70,0.72)",borderRadius:8}:{backgroundColor:"#f8f9fa",border:"1px solid rgba(0,0,0,0.08)",borderRadius:8}},E=e=>({display:"inline-flex",alignItems:"center",fontSize:"0.75rem",fontWeight:500,padding:"0.2em 0.6em",borderRadius:4,marginRight:4,marginBottom:4,backgroundColor:C?"rgba(255,255,255,0.07)":"#e9ecef",color:e||(C?"#d1d5db":"#495057"),border:C?"1px solid rgba(63,63,70,0.6)":"1px solid rgba(0,0,0,0.08)"}),L=(null===k||void 0===k?void 0:k.full_result)||{},$=L.server_diagnostics||{},I=L.page_analysis||{},R=L.headless_tests||[];return(0,D.jsxs)(Y.A,{show:_,onHide:w,placement:"end",scroll:!1,backdrop:!0,style:A,children:[(0,D.jsx)(Y.A.Header,{closeButton:!0,style:P,children:(0,D.jsxs)(Y.A.Title,{className:C?"text-light":"text-muted",style:{fontSize:"0.95rem",fontWeight:600},children:[(0,D.jsx)("i",{className:"feather icon-search me-2",style:{color:T}}
1),"Scan Detail",S&&(0,D.jsxs)("span",{className:"ms-2",style:{fontSize:"0.8rem",fontWeight:400,color:T},children:["\u2014 ",S]})]})}),(0,D.jsx)(Y.A.Body,{style:z,children:k?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"d-flex align-items-start justify-content-between mb-4",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{style:{fontSize:"0.75rem",color:T,marginBottom:4,textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:600},children:"Scanned"}),(0,D.jsx)("div",{style:{fontSize:"1rem",fontWeight:600},children:k.scanned_at?new Date(k.scanned_at).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}):"\u2014"}),k.url&&(0,D.jsx)("div",{style:{fontSize:"0.78rem",color:T,marginTop:4,fontFamily:"monospace",wordBreak:"break-all"},children:k.url})]}),(0,D.jsxs)("span",{style:{flexShrink:0,marginLeft:12,fontSize:"0.85rem",fontWeight:600,padding:"0.4em 0.9em",borderRadius:6,backgroundColor:k.success?"rgba(34,197,94,0.15)":"rgba(239,68,68,0.15)",color:k.success?"#22c55e":"#ef4444",border:"1px solid "+(k.success?"rgba(34,197,94,0.3)":"rgba(239,68,68,0.3)")},children:[(0,D.jsx)("i",{className:`feather ${k.success?"icon-check-circle":"icon-x-circle"} me-1`}),k.success?"Pass":"Fail"]})]}),(0,D.jsx)("div",{className:"d-flex gap-2 flex-wrap mb-1",children:[{label:"Status",value:null!==(s=$.status_code)&&void 0!==s?s:k.status_code,color:200===(null!==(t=$.status_code)&&void 0!==t?t:k.status_code)?"#22c55e":"#f59e0b"},{label:"Response",value:(e=>{const s=null!==(e=$.response_time_ms)&&void 0!==e?e:k.response_time_ms;return null!=s?s<1e3?`${s}ms`:`${(s/1e3).toFixed(1)}s`:"\u2014"})(),color:lt(null!==(a=$.response_time_ms)&&void 0!==a?a:k.response_time_ms)},{label:"Page Size",value:null!=$.page_size_bytes?$.page_size_bytes>=1024?`${($.page_size_bytes/1024).toFixed(1)} KB`:`${$.page_size_bytes} B`:"\u2014",color:null},{label:"HTTPS",value:null==(null!==(n=$.https)&&void 0!==n?n:k.https)?"\u2014":(null!==(i=$.https)&&void 0!==i?i:k.https)?"Yes":"No",color:(null!==(l=$.https)&&void 0!==l?l:k.https)?"#22c55e":"#f59e0b"}].map(e=>{let{label:s,value:t,color:a}=e;return(0,D.jsxs)("div",{style:{...F,padding:"0.65rem 0.85rem",flex:1,minWidth:80},children:[(0,D.jsx)("div",{style:{fontSize:"0.68rem",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:T,marginBottom:5},children:s}),(0,D.jsx)("div",{style:{fontSize:"1.1rem",fontWeight:700,color:a||void 0},children:t})]},s)})}),(()=>{const e=$.security_headers||{},s=[];if(e.csp_blocks_inline_scripts&&s.push("this site's CSP blocks inline script execution"),e.csp_blocks_pixel_cdn&&s.push("this site's CSP blocks third-party CDN scripts"),e.csp_blocks_pixel_beacon&&s.push("this site's CSP blocks beacon requests"),0===s.length||k.success)return null;const t=(e.csp_blocked_directives||[]).join(", ");return(0,D.jsx)("div",{style:{marginTop:"1rem",padding:"0.85rem 1rem",borderRadius:8,backgroundColor:"rgba(239,68,68,0.1)",border:"1px solid rgba(239,68,68,0.35)"},children:(0,D.jsxs)("div",{className:"d-flex align-items-start gap-2",children:[(0,D.jsx)("i",{className:"feather icon-shield",style:{color:"#ef4444",flexShrink:0,marginTop:2}}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{style:{fontSize:"0.85rem",fontWeight:700,color:"#ef4444",marginBottom:6},children:"Content Security Policy is blocking the pixel"}),(0,D.jsx)("ul",{style:{margin:0,paddingLeft:"1.1rem",fontSize:"0.8rem",color:C?"#fca5a5":"#7f1d1d"},children:s.map((e,s)=>(0,D.jsx)("li",{children:e},s))}),t&&(0,D.jsxs)("div",{style:{fontSize:"0.75rem",color:T,marginTop:6},children:["Affected: ",(0,D.jsx)("code",{style:{fontFamily:"monospace"},children:t})]})]})]})})})(),((null===(r=L.issues)||void 0===r?void 0:r.length)>0||(null===(o=L.suggestions)||void 0===o?void 0:o.length)>0)&&(0,D.jsxs)(ot,{title:"Issues & Suggestions",icon:"icon-alert-triangle",isDark:C,children:[null===(c=L.issues)||void 0===c?void 0:c.map((e,s)=>(0,D.jsxs)("div",{className:"d-flex align-items-start gap-2 mb-2",style:{fontSize:"0.82rem"},children:[(0,D.jsx)("i",{className:"feather icon-alert-circle mt
1-1",style:{color:"#f59e0b",flexShrink:0}}),(0,D.jsx)("span",{children:e})]},s)),null===(d=L.suggestions)||void 0===d?void 0:d.map((e,s)=>(0,D.jsxs)("div",{className:"d-flex align-items-start gap-2 mb-2",style:{fontSize:"0.82rem"},children:[(0,D.jsx)("i",{className:"feather icon-info mt-1",style:{color:"#3b82f6",flexShrink:0}}),(0,D.jsx)("span",{style:{color:T},children:e})]},s))]}),R.length>0&&(0,D.jsxs)(ot,{title:`Browser Test Runs (${R.length})`,icon:"icon-monitor",isDark:C,children:[R.map((e,s)=>(0,D.jsxs)("div",{className:"d-flex align-items-center justify-content-between mb-2",children:[(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2",children:[(0,D.jsx)("i",{className:"feather "+(200===e.nav_status||e.events_found>0?"icon-check-circle":"icon-x-circle"),style:{color:200===e.nav_status||e.events_found>0?"#22c55e":"#ef4444",fontSize:"0.85rem"}}),(0,D.jsx)("span",{style:{fontSize:"0.83rem"},children:e.ua_type})]}),(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2",children:[null!=e.nav_status&&(0,D.jsxs)(dt,{color:200===e.nav_status?"#22c55e":"#f59e0b",bg:200===e.nav_status?"rgba(34,197,94,0.1)":"rgba(245,158,11,0.1)",border:200===e.nav_status?"rgba(34,197,94,0.25)":"rgba(245,158,11,0.25)",children:["HTTP ","timeout_networkidle"===e.nav_status?"Timeout":e.nav_status]}),(0,D.jsx)("span",{style:{fontSize:"0.79rem",color:T},children:null!=e.events_found?`${e.events_found} event${1!==e.events_found?"s":""}`:""}),e.error&&(0,D.jsx)("span",{style:{fontSize:"0.75rem",color:"#ef4444"},title:e.error,children:(0,D.jsx)("i",{className:"feather icon-alert-circle"})})]})]},s)),null!=L.recent_events_24h&&(0,D.jsxs)("div",{style:{fontSize:"0.78rem",color:T,marginTop:4},children:[(0,D.jsx)("i",{className:"feather icon-activity me-1"}),L.recent_events_24h," real event",1!==L.recent_events_24h?"s":""," in last 24 h (excluding test events)"]})]}),(I.title||I.meta_description||I.og_title||I.favicon_url)&&(0,D.jsxs)(ot,{title:"Page Identity",icon:"icon-file-text",isDark:C,children:[I.title&&(0,D.jsx)(ct,{label:"Title",children:I.title}),I.meta_description&&(0,D.jsx)(ct,{label:"Meta Description",children:(0,D.jsx)("span",{style:{color:T},children:I.meta_description})}),I.og_title&&(0,D.jsx)(ct,{label:"OG Title",children:I.og_title}),I.og_description&&(0,D.jsx)(ct,{label:"OG Description",children:(0,D.jsx)("span",{style:{color:T},children:I.og_description})}),I.og_image&&(0,D.jsx)(ct,{label:"OG Image",children:(0,D.jsx)("span",{style:{color:T,fontFamily:"monospace",fontSize:"0.78rem"},children:I.og_image})}),I.canonical&&(0,D.jsx)(ct,{label:"Canonical",mono:!0,children:I.canonical}),I.robots_meta&&(0,D.jsx)(ct,{label:"Robots",children:I.robots_meta})]}),(0,D.jsxs)(ot,{title:"Server Intelligence",icon:"icon-server",isDark:C,children:[(0,D.jsx)(ct,{label:"IP Address",mono:!0,children:rt(null!==(m=$.server_ip)&&void 0!==m?m:k.server_ip)}),$.ptr_record&&(0,D.jsx)(ct,{label:"Reverse DNS",mono:!0,children:$.ptr_record}),(0,D.jsx)(ct,{label:"HTTP Status",children:(0,D.jsx)("span",{style:{color:200===(null!==(h=$.status_code)&&void 0!==h?h:k.status_code)?"#22c55e":"#f59e0b"},children:rt(null!==(u=$.status_code)&&void 0!==u?u:k.status_code)})}),(0,D.jsx)(ct,{label:"Server Software",children:rt(null!==(x=$.server_software)&&void 0!==x?x:k.server_software)}),$.powered_by&&(0,D.jsx)(ct,{label:"Powered By",children:$.powered_by}),(0,D.jsx)(ct,{label:"OS",children:rt(null!==(p=$.os_hint)&&void 0!==p?p:k.os_hint)}),(0,D.jsx)(ct,{label:"CDN / WAF",children:rt(null!==(v=$.cdn_provider)&&void 0!==v?v:k.cdn_provider)||"None detected"}),Array.isArray($.tech_stack)&&$.tech_stack.length>0&&(0,D.jsx)(ct,{label:"Technology Stack",children:(0,D.jsx)("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"flex-end"},children:$.tech_stack.map(e=>(0,D.jsx)("span",{style:E(),children:e},e))})}),$.geo_country&&(0,D.jsxs)(ct,{label:"Geo Country",children:[(M=$.geo_country,M?M.toUpperCase().replace(/./g,e=>String.fromCodePoint(e.charCodeAt(0)+127397)):"")," ",$.geo_country]}),$.geo_city&&(0,D.jsx)(ct,{label:"Geo City",children:[$.geo_city,$.geo_region].filter(
1Boolean).join(", ")})]}),(0,D.jsxs)(ot,{title:"Performance",icon:"icon-zap",isDark:C,children:[null!=$.response_time_ms&&(0,D.jsx)(ct,{label:"Response Time",children:(0,D.jsxs)("span",{style:{color:lt($.response_time_ms)},children:[$.response_time_ms<1e3?`${$.response_time_ms}ms`:`${($.response_time_ms/1e3).toFixed(2)}s`,$.response_time_ms<500?" \xb7 Fast":$.response_time_ms<2e3?" \xb7 OK":" \xb7 Slow"]})}),null!=$.page_size_bytes&&(0,D.jsx)(ct,{label:"Page Size",children:$.page_size_bytes>=1048576?`${($.page_size_bytes/1048576).toFixed(2)} MB`:`${($.page_size_bytes/1024).toFixed(1)} KB`}),$.compression&&(0,D.jsx)(ct,{label:"Compression",children:(0,D.jsx)("span",{style:{color:"none"!==$.compression?"#22c55e":T},children:"none"!==$.compression?`\u2713 ${$.compression}`:"None"})}),null!=$.script_count&&(0,D.jsx)(ct,{label:"Script Tags",children:$.script_count}),null!=$.cookies_set&&(0,D.jsx)(ct,{label:"Cookies Set",children:$.cookies_set}),(0,D.jsx)(ct,{label:"HTTPS",children:(0,D.jsx)(mt,{val:null!==(f=$.https)&&void 0!==f?f:k.https})}),null!=$.redirect_count&&(0,D.jsx)(ct,{label:`Redirects (${$.redirect_count})`,children:0===$.redirect_count?"None":$.redirect_count}),Array.isArray($.redirect_chain)&&$.redirect_chain.length>1&&(0,D.jsx)(ct,{label:"Redirect Chain",children:(0,D.jsx)("div",{style:{textAlign:"right"},children:$.redirect_chain.map((e,s)=>(0,D.jsxs)("div",{style:{fontSize:"0.75rem",fontFamily:"monospace",color:T,marginBottom:2},children:[s>0&&(0,D.jsx)("i",{className:"feather icon-corner-down-right me-1",style:{fontSize:"0.7rem"}}),e.replace(/^https?:\/\//,"")]},s))})})]}),(0,D.jsx)(ot,{title:"Security Audit",icon:"icon-shield",isDark:C,children:$.security_headers?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ct,{label:"HSTS",children:(0,D.jsx)(ht,{val:$.security_headers.strict_transport_security})}),(0,D.jsxs)("div",{style:{marginBottom:"0.75rem"},children:[(0,D.jsxs)("div",{className:"d-flex align-items-start justify-content-between gap-3",children:[(0,D.jsx)("span",{style:{fontSize:"0.81rem",color:"#94a3b8",whiteSpace:"nowrap",flexShrink:0,minWidth:130},children:"Content-Security-Policy"}),(0,D.jsx)("span",{style:{fontSize:"0.83rem",fontWeight:500,textAlign:"right"},children:$.security_headers.content_security_policy?(0,D.jsxs)("span",{style:{color:$.security_headers.csp_may_block_pixel?"#ef4444":"#22c55e"},children:[(0,D.jsx)("i",{className:`feather ${$.security_headers.csp_may_block_pixel?"icon-alert-circle":"icon-check-circle"} me-1`}),$.security_headers.csp_may_block_pixel?"Present \u2014 blocking pixel":"Present"]}):(0,D.jsx)("span",{style:{color:T},children:"Not set"})})]}),$.security_headers.content_security_policy&&(0,D.jsxs)("div",{style:{marginTop:8,marginLeft:130,fontSize:"0.78rem"},children:[[["csp_blocks_inline_scripts","\u26a0\ufe0f Site CSP blocks inline scripts","Add 'unsafe-inline' to script-src or script-src-elem, or use a nonce on the pixel's <script> tag. Most sites don't need this."],["csp_blocks_pixel_cdn","\u26a0\ufe0f Site CSP blocks third-party CDN scripts","Add pixel.linkclicks.com to script-src. Most sites install without this change."],["csp_blocks_pixel_beacon","\u26a0\ufe0f Site CSP blocks beacon requests","Add api.linkclicks.com to connect-src."]].map(e=>{let[s,t,a]=e;return $.security_headers[s]?(0,D.jsxs)("div",{style:{marginBottom:6},children:[(0,D.jsx)("div",{style:{color:"#fbbf24",fontWeight:600},children:t}),(0,D.jsxs)("div",{style:{color:T,marginTop:2},children:["Fix: ",a]})]},s):null}),$.security_headers.csp_value&&(0,D.jsxs)("details",{style:{marginTop:6},children:[(0,D.jsx)("summary",{style:{cursor:"pointer",color:T,userSelect:"none"},children:"View CSP header"}),(0,D.jsx)("div",{style:{marginTop:4,fontFamily:"monospace",fontSize:"0.7rem",wordBreak:"break-all",color:T},children:$.security_headers.csp_value})]})]})]}),(0,D.jsx)(ct,{label:"X-Frame-Options",children:(0,D.jsx)(ht,{val:$.security_headers.x_frame_options})}),(0,D.jsx)(ct,{label:"X-Content-Type-Options",children:(0,D.jsx)(ht,{val:$.security_headers.x_content_type_options})}),(0,D.jsx)(ct,{label:"Referrer-Policy",children:(0,D.jsx)(ht,{val:$.security_headers.referrer_policy})}),(0,D.jsx)(ct,{label:"Permissions-Policy",children:(0,D.jsx)(ht,{val:$.security_headers.permissions_policy})})]}):(0,D.jsx)("span",{style:{color:T,fontSize:"0.82rem"},children:"No security header data"})}),(0,D.jsxs)(ot,{title:"SEO",icon:"icon-search",isDark:C,defaultOpen:!1,children:[(0,D.jsxs)("div",{className:"d-flex align-items-start justify-content-between gap-3 mb-2",children:[(0,D.jsx)("span",{style:{fontSize:"0.81rem",color:"#94a3b8",whiteSpace:"nowrap",flexShrink:0,minWidth:130},children:"Open Graph"}),(0,D.jsx)("div",{style:{fontSize:"0.83rem",fontWeight:500,textAlign:"right"},children:I.og_title||I.og_description||I.og_image||I.has_open_graph?(0,D.jsxs)(D.Fragment,{children:[(()=>{const e=I.og_title&&I.og_image;return(0,D.jsxs)("span",{style:{color:e?"#22c55e":"#f59e0b"},children:[(0,D.jsx)("i",{className:`feather ${e?"icon-check-circle":"icon-alert-circle"} me-1`}),e?"Complete":"Partial"]})})(),(0,D.jsx)("div",{style:{marginTop:6,textAlign:"left"},children:[["og:title",I.og_title],["og:description",I.og_description||I.og_desc],["og:image",I.og_image]].map(e=>{let[s,t]=e;return(0,D.jsx)("div",{style:{fontSize:"0.76rem",marginBottom:3},children:t?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("i",{className:"feather icon-check me-1",style:{color:"#22c55e"}}),(0,D.jsx)("code",{style:{fontFamily:"monospace"},children:s})," ",(0,D.jsx)("span",{style:{color:T},children:"string"===typeof t&&t.length>40?t.slice(0,40)+"\u2026":t})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("i",{className:"feather icon-x me-1",style:{color:"#94a3b8"}}),(0,D.jsx)("code",{style:{fontFamily:"monospace",color:"#94a3b8"},children:s})," ",(0,D.jsx)("span",{style:{color:T},children:"missing"})]})},s)})})]}):(0,D.jsx)("span",{style:{color:T},children:"Not set \u2014 add og:title, og:description, og:image for social previews"})})]}),(0,D.jsx)(ct,{label:"Twitter / X Card",children:(0,D.jsx)(ht,{val:I.has_twitter_card})}),(0,D.jsx)(ct,{label:"Schema.org / JSON-LD",children:I.has_schema_org?(0,D.jsxs)("span",{style:{color:"#22c55e"},children:[(0,D.jsx)("i",{className:"feather icon-check-circle me-1"}),"Present"]}):(0,D.jsx)("span",{style:{color:T},children:"Add structured data (application/ld+json) to improve search appearance"})}),(0,D.jsx)(ct,{label:"Robots",children:I.robots_meta||"Not set (defaults to index, follow)"})]}),(0,D.jsxs)(ot,{title:`Trackers Detected (${Array.isArray(I.trackers_found)?I.trackers_found.length:null!==(g=k.trackers_count)&&void 0!==g?g:0})`,icon:"icon-radio",isDark:C,defaultOpen:!1,children:[Array.isArray(I.trackers_found)&&I.trackers_found.length>0?(0,D.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:I.trackers_found.map(e=>(0,D.jsxs)("span",{style:E(),children:[(0,D.jsx)("i",{className:"feather icon-radio me-1",style:{fontSize:"0.7rem"}}),e]},e))}):(0,D.jsx)("span",{style:{color:T,fontSize:"0.82rem"},children:"No third-party trackers detected"}),Array.isArray(I.lc_pixel_keys_found)&&I.lc_pixel_keys_found.length>0&&(0,D.jsxs)("div",{style:{marginTop:10},children:[(0,D.jsx)("div",{style:{fontSize:"0.72rem",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:T,marginBottom:6},children:"LinkClicks Pixel Keys on Page"}),I.lc_pixel_keys_found.map(e=>(0,D.jsx)("div",{style:{fontSize:"0.78rem",fontFamily:"monospace",color:T,marginBottom:3},children:e},e))]})]}),L.components_analysis&&(0,D.jsxs)(ot,{title:"Pixel Detection",icon:"icon-code",isDark:C,defaultOpen:!1,children:[(0,D.jsx)(ct,{label:"Detection Score",children:(0,D.jsxs)("span",{style:{color:L.detection_score>=80?"#22c55e":L.detection_score>=50?"#f59e0b":"#ef4444",fontWeight:700},children:[null!==(b=L.detection_score)&&void 0!==b?b:"\u2014"," / 100"]})}),(0,D.jsxs)(ct,{label:"Components",children:[null!==(y=L.components_analysis.found)&&void 0!==y?y:"\u2014"," / ",null!==(N=L.components_analysis.total)&&void 0!==N?N:"\u2014"," found"]}
1),(0,D.jsx)(ct,{label:"Method",children:(0,D.jsx)("span",{style:{color:T,fontSize:"0.79rem"},children:L.installation_method||"\u2014"})}),L.detection_source&&(0,D.jsx)(ct,{label:"Source",children:L.detection_source}),Array.isArray(L.components_analysis.components)&&L.components_analysis.components.length>0&&(0,D.jsx)("div",{style:{marginTop:8},children:L.components_analysis.components.map((e,s)=>(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2 mb-1",style:{fontSize:"0.79rem"},children:[(0,D.jsx)("i",{className:"feather "+("found"===e.status?"icon-check-circle":e.required?"icon-x-circle":"icon-minus-circle"),style:{color:"found"===e.status?"#22c55e":e.required?"#ef4444":"#94a3b8",flexShrink:0}}),(0,D.jsx)("span",{style:{color:"found"===e.status?void 0:T},children:e.name}),e.required&&"found"!==e.status&&(0,D.jsx)("span",{style:{fontSize:"0.68rem",color:"#ef4444",marginLeft:"auto"},children:"REQUIRED"})]},s))})]}),$.response_headers&&Object.keys($.response_headers).length>0&&(0,D.jsx)(ot,{title:"Response Headers",icon:"icon-list",isDark:C,defaultOpen:!1,children:Object.entries($.response_headers).map(e=>{let[s,t]=e;return(0,D.jsxs)("div",{className:"d-flex align-items-start gap-2 mb-2",children:[(0,D.jsx)("span",{style:{fontSize:"0.76rem",fontFamily:"monospace",color:T,whiteSpace:"nowrap",minWidth:140},children:s}),(0,D.jsx)("span",{style:{fontSize:"0.76rem",fontFamily:"monospace",wordBreak:"break-all",textAlign:"right"},children:t})]},s)})})]}):(0,D.jsxs)("div",{className:"text-center py-5",style:{color:T,fontSize:"0.88rem"},children:[(0,D.jsx)("i",{className:"feather icon-search",style:{fontSize:"2rem",display:"block",marginBottom:12,opacity:.3}}),"No scan selected."]})})]});var M},xt=["firing","customEvents","platformConnected","domainVerified","passthrough","enrichment","tested"],pt=e=>{let{label:s,value:t,mono:a}=e;return(0,D.jsxs)("div",{className:"d-flex gap-2 py-1 align-items-start",style:{borderTop:"1px solid rgba(148,163,184,0.1)",fontSize:"0.78rem"},children:[(0,D.jsx)("span",{className:"text-muted flex-shrink-0",style:{width:170},children:s}),(0,D.jsx)("span",{className:"fw-medium"+(a?" font-monospace":""),style:{wordBreak:"break-all"},children:t})]})};pt.defaultProps={value:"\u2014",mono:!1};const vt={strict_transport_security:{label:"Strict-Transport-Security (HSTS)",what:"Forces browsers to always use HTTPS, preventing SSL-stripping and man-in-the-middle attacks.",nginx:'add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;',apache:'Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"'},content_security_policy:{label:"Content-Security-Policy",what:"Controls which resources the browser can load. Blocks XSS and data-injection attacks. Start with report-only mode to avoid breaking your site.",nginx:"add_header Content-Security-Policy \"default-src 'self'; script-src 'self' 'unsafe-inline' https://pixel.linkclicks.com\" always;",apache:"Header always set Content-Security-Policy \"default-src 'self'\""},x_frame_options:{label:"X-Frame-Options",what:"Prevents your page from being embedded in an iframe on other domains, blocking clickjacking attacks.",nginx:'add_header X-Frame-Options "SAMEORIGIN" always;',apache:'Header always set X-Frame-Options "SAMEORIGIN"'},x_content_type_options:{label:"X-Content-Type-Options",what:"Stops browsers from guessing (sniffing) the content type of responses, blocking certain injection attacks.",nginx:'add_header X-Content-Type-Options "nosniff" always;',apache:'Header always set X-Content-Type-Options "nosniff"'},referrer_policy:{label:"Referrer-Policy",what:"Limits how much referrer URL information is sent with requests, protecting user privacy across sites.",nginx:'add_header Referrer-Policy "strict-origin-when-cross-origin" always;',apache:'Header always set Referrer-Policy "strict-origin-when-cross-origin"'},permissions_policy:{label:"Permissions-Policy",what:"Restricts which browser APIs (camera, microphone, geolocation) the page is allowed to use.",nginx:'add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;',apache:'Header always set Permissions-Policy "camera=(), microphone=(), geolocation=()"'}},ft=e=>{let{headerKey:s,present:t}=e;const[n,i]=(0,a.useState)(!1),l=vt[s]||{label:s};return(0,D.jsxs)("div",{style:{borderTop:"1px solid rgba(148,163,184,0.1)",fontSize:"0.78rem"},children:[(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2 py-1",children:[(0,D.jsx)("i",{className:"feather "+(t?"icon-check-circle":"icon-minus-circle"),style:{color:t?"#22c55e":"#94a3b8",fontSize:"0.8rem",flexShrink:0}}),(0,D.jsx)("span",{children:l.label}),(0,D.jsx)("span",{className:"ms-auto text-muted",children:t?"Present":"Not set"}),!t&&(0,D.jsx)("button",{type:"button",onClick:()=>i(e=>!e),style:{background:"none",border:"none",padding:"0 0 0 6px",cursor:"pointer",color:"#94a3b8",lineHeight:1},children:(0,D.jsx)("i",{className:"feather "+(n?"icon-chevron-up":"icon-chevron-down"),style:{fontSize:"0.72rem"}})})]}),!t&&n&&l.what&&(0,D.jsxs)("div",{className:"ms-4 mb-2 p-2 rounded",style:{background:"rgba(0,0,0,0.04)",fontSize:"0.74rem"},children:[(0,D.jsx)("div",{className:"text-muted mb-2",children:l.what}),l.nginx&&(0,D.jsxs)("div",{className:"mb-1",children:[(0,D.jsx)("span",{className:"text-muted",style:{fontSize:"0.68rem",textTransform:"uppercase",letterSpacing:"0.06em"},children:"nginx"}),(0,D.jsx)("div",{className:"font-monospace mt-1 p-1 rounded",style:{fontSize:"0.67rem",background:"rgba(0,0,0,0.06)",wordBreak:"break-all"},children:l.nginx})]}),l.apache&&(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{className:"text-muted",style:{fontSize:"0.68rem",textTransform:"uppercase",letterSpacing:"0.06em"},children:"apache"}),(0,D.jsx)("div",{className:"font-monospace mt-1 p-1 rounded",style:{fontSize:"0.67rem",background:"rgba(0,0,0,0.06)",wordBreak:"break-all"},children:l.apache})]})]})]})};ft.defaultProps={present:!1};const gt=e=>{let{children:s}=e;return(0,D.jsx)("div",{className:"text-uppercase fw-semibold mt-3 mb-1",style:{fontSize:"0.68rem",letterSpacing:"0.08em",color:"#94a3b8"},children:s})},bt=e=>{var s;let{pixelKey:t,pixel:n,initialTestResult:i,onNavigateToPlatforms:l,onNavigateToDomains:r}=e;const[o,c]=(0,a.useState)(""),[d,m]=(0,a.useState)(i||null),[h,u]=(0,a.useState)(!1),[x,p]=(0,a.useState)([]),[f,g]=(0,a.useState)(null),b=(0,a.useCallback)(async()=>
1{if(t)try{const e=await(0,y.qQ)(`/conversions/pixels/${t}/scan-history/?limit=50`);p(e.data||[])}catch{}},[t]);(0,a.useEffect)(()=>{b()},[b]);const j=(0,a.useRef)(i);i&&i!==j.current&&!d&&(j.current=i,m(i));const N=(0,a.useMemo)(()=>(0,Hs.m8)(),[]),_=n||{},w=(0,a.useMemo)(()=>(0,Hs.a$)(_,N),[_,N]),k=(null===n||void 0===n||null===(s=n.recent_events)||void 0===s?void 0:s[0])||null,S=(0,a.useMemo)(()=>{const e=xt.map(e=>((e,s,t,a)=>{const n=(0,Hs.$t)(e,s),i=Hs.gT[n]||Hs.gT.muted,l=(null===a||void 0===a?void 0:a.received_at)||(null===t||void 0===t?void 0:t.last_seen_at)||null;switch(s){case"firing":return{icon:"zap",label:"Firing",tone:n,color:i,statusLabel:e.firing?"Active":"No events",description:e.firing?"warning"===n?`Latest event was ${l?(0,hs.fF)(l):"a while ago"}. Slower than expected.${e.hasLocalhostEvents?" Recent hits appear to be from localhost \u2014 publish to a live URL to track real visitors.":""}`:"danger"===n?`Latest event was ${l?(0,hs.fF)(l):"unknown"}. May have stopped.${e.hasLocalhostEvents?" Recent hits appear to be from localhost \u2014 publish to a live URL to track real visitors.":""}`:`Recent activity detected ${l?(0,hs.fF)(l):""}.${e.hasLocalhostEvents?" Heads up: recent hits are from localhost \u2014 expected during development but won't count as production traffic.":""}`:"No events have been received for this pixel yet."};case"customEvents":return{icon:"activity",label:"Custom Events",tone:n,color:i,statusLabel:e.customEvents?"Tracking":"Page View only",description:e.customEvents?"Conversion events beyond page views have been tracked for this pixel.":"Only page views recorded so far. Add more conversion events."};case"platformConnected":return{icon:"share-2",label:"Platforms",tone:n,color:i,isActionable:"danger"===n,actionLabel:"danger"===n?"Open platforms":"",statusLabel:e.authorizedPlatformCount>0?`${e.configuredPlatformCount}/${e.authorizedPlatformCount} connected`:"No platforms",description:0===e.authorizedPlatformCount?"No authorized ad platforms found for this workspace yet.":"danger"===n?`Connected: ${(0,Hs.nl)(e.configuredPlatformLabels)}. Missing: ${(0,Hs.nl)(e.missingPlatformLabels)}.`:`All authorized platforms connected: ${(0,Hs.nl)(e.configuredPlatformLabels)}.`};case"domainVerified":{const s=(null===t||void 0===t?void 0:t.verification_status)||"unverified";return{icon:"globe",label:"Domain",tone:n,color:i,isActionable:!e.domainVerified,actionTarget:"settings-domains",actionLabel:e.domainVerified?"":"Verify domain",statusLabel:e.domainVerified?"Verified":"pending"===s?"Pending":"Unverified",description:e.domainVerified?"The domain tied to this pixel has been verified.":"pending"===s?"Domain verification is pending.":"No verified domain yet."}}case"passthrough":return{icon:"corner-right-up",label:"Pass-through",tone:n,color:i,statusLabel:e.passthroughPossibleCount>0?`${e.passthroughReadyCount}/${e.passthroughPossibleCount} enabled`:"Not available",description:0===e.passthroughPossibleCount?"No connected platforms currently support forwarding mode.":"danger"===n?`Forwarding enabled for ${(0,Hs.nl)(e.passthroughReadyLabels)}. Still off for ${(0,Hs.nl)(e.passthroughMissingLabels)}.`:`Forwarding enabled for all supported platforms: ${(0,Hs.nl)(e.passthroughReadyLabels)}.`};case"enrichment":return{icon:"user-check",label:"Enriched",tone:n,color:i,statusLabel:e.enrichment?"Enabled":"Not enabled",description:e.enrichment?"Customer enrichment is enabled for this pixel.":"Enrichment not enabled \u2014 event payloads may have less user context."};default:return{icon:"check-square",label:"Tested",tone:n,color:i,statusLabel:e.tested?"Passed":"No test",description:e.tested?"A successful installation test has been recorded for this pixel.":"No successful test recorded yet. Run a test below to confirm setup end-to-e
1nd."}}})(w,e,_,k)),s=e=>"danger"===e?0:"warning"===e?1:"success"===e?2:3;return e.sort((e,t)=>s(e.tone)-s(t.tone))},[w,_,k]),C=(0,a.useCallback)(async()=>{if(o&&o.startsWith("http")){u(!0),m(null);try{var e;const n=await(0,y.Ku)("/conversions/test/pixel-installation/",{url:o,pixel_key:t});var s,a;if(null!==(e=n.data)&&void 0!==e&&e.success)m({success:!0,message:n.data.message,details:n.data.details});else m({success:!1,message:(null===(s=n.data)||void 0===s?void 0:s.message)||"Pixel not detected",details:(null===(a=n.data)||void 0===a?void 0:a.details)||{}})}catch(l){let e="Failed to test pixel installation",s={};var n,i;if(l.response)e=(null===(n=l.response.data)||void 0===n?void 0:n.message)||e,s=(null===(i=l.response.data)||void 0===i?void 0:i.details)||{};else l.request&&(e="Network error \u2014 unable to reach testing service",s={issues:["Connection timeout or network error"],suggestions:["Check your internet connection and try again"]});m({success:!1,message:e,details:s})}finally{u(!1),b()}}else m({success:!1,message:"Please enter a valid URL starting with http:// or https://"})},[o,t,b]);return(0,D.jsx)("div",{className:"p-3",children:(0,D.jsxs)("div",{className:"row g-3",children:[(0,D.jsx)("div",{className:"col-12 col-xl-7",children:(0,D.jsxs)("div",{className:"border rounded p-3 h-100",children:[(0,D.jsx)("h6",{className:"mb-1",children:"Test Pixel Installation"}),(0,D.jsx)("p",{className:"text-muted small mb-3",children:"Check a live website for the universal pixel, confirm the expected key is present, and inspect any mismatch or load issues."}),(0,D.jsxs)("div",{className:"row g-2 align-items-end",children:[(0,D.jsxs)("div",{className:"col-md-8",children:[(0,D.jsx)(v.A.Label,{className:"small text-muted mb-1",children:"URL to test"}),(0,D.jsx)(v.A.Control,{type:"url",placeholder:"https://yourwebsite.com/page-to-test",value:o,onChange:e=>c(e.target.value),disabled:h,onKeyDown:e=>{"Enter"===e.key&&o.trim()&&C()}})]}),(0,D.jsx)("div",{className:"col-md-4",children:(0,D.jsx)("button",{type:"button",className:"btn btn-primary w-100 btn-sm",onClick:C,disabled:h||!o.trim(),children:h?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("span",{className:"spinner-border spinner-border-sm me-2",role:"status","aria-hidden":"true"}),"Testing\u2026"]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("i",{className:"feather icon-search me-2"}),"Test URL"]})})})]}),(0,D.jsx)("div",{className:"alert mt-3 mb-0",style:{backgroundColor:"rgba(13, 71, 161, 0.18)",borderColor:"rgba(30, 136, 229, 0.35)",color:"inherit"},role:"alert",children:(0,D.jsxs)("div",{className:"small mb-0",children:[(0,D.jsx)("strong",{children:"Recommended flow:"})," install the base code, load the page, trigger one or two real actions, then run the URL test to confirm the correct pixel key is detected."]})}),d&&((e,s,t,a,n)=>{const i=d.details||{},l=i.server_diagnostics||{},r=l.security_headers||{},o=i.page_analysis||{},c=i.headless_tests||[],m=o.trackers_found||[],h=l.tech_stack||[],u=l.response_time_ms?l.response_time_ms<500?"#22c55e":l.response_time_ms<2e3?"#f59e0b":"#ef4444":"#94a3b8",x={"Facebook Pixel":"#1877f2","Google Analytics (GA4)":"#4285f4","Google Tag Manager":"#34a853","TikTok Pixel":"#69c9d0","Snapchat Pixel":"#fffc00","Pinterest Tag":"#e60023","Twitter/X Pixel":"#1da1f2","LinkedIn Insight":"#0077b5","Microsoft Clarity":"#00a4ef",Hotjar:"#ff3c00",HubSpot:"#ff7a59",Klaviyo:"#0e7a43",Segment:"#52bd95",Heap:"#ff5b5b",Fullstory:"#005fff","Microsoft Ads":"#00a1f1","Reddit Pixel":"#ff4500",Criteo:"#e07e05",Mixpanel:"#7856ff",Intercom:"#1f8ded",Drift:"#ff5a14",Zendesk:"#03363d",Outbrain:"#ff6000",Taboola:"#1f54ae"};return(0,D.jsxs)("div",{className:"rounded p-3 mt-3 border "+(d.success?"border-success":"border-danger"),style:{background:d.success?"rgba(34,197,94,0.04)":"rgba(239,68,68,0.04)"},children:[(0,D.jsxs)("div",{className:"d-flex align-items-start gap-2 mb-2",children:[(0,D.jsx)("i",{className:`feather ${d.success?"icon-check-circle":"icon-x-circle"} mt-1`,style:{color:d.success?"#22c55e":"#ef4444",fontSize:"1.1rem",flexShrink:0}}),(0,D.jsxs)("div",{className:"flex-grow-1",children:[(0,D.jsx)("div",{className:"fw-semibold",style:{fontSize:"0.9rem"},children:d.message}),(0,D.jsxs)("div",{className:"text-muted d-flex align-items-center gap-2 flex-wrap",style:{fontSize:"0.76rem"}
1,children:[i.last_checked&&new Date(i.last_checked).toLocaleString(),(null===(e=i.debug_info)||void 0===e?void 0:e.test_id)&&(0,D.jsxs)("span",{className:"font-monospace",style:{fontSize:"0.70rem",opacity:.7},children:["test:",i.debug_info.test_id]})]})]}),void 0!==i.recent_events_24h&&(0,D.jsxs)("span",{className:"badge bg-secondary flex-shrink-0 ms-auto",children:[i.recent_events_24h," events / 24h"]})]}),(o.title||o.favicon_url)&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(gt,{children:"Page Identity"}),(0,D.jsxs)("div",{className:"d-flex align-items-start gap-2 mb-1",children:[o.favicon_url&&(0,D.jsx)("img",{src:o.favicon_url,alt:"",width:24,height:24,style:{borderRadius:4,border:"1px solid rgba(148,163,184,0.2)",objectFit:"contain",flexShrink:0,marginTop:2},onError:e=>{e.currentTarget.style.display="none"}}),(0,D.jsxs)("div",{style:{minWidth:0,flex:1},children:[o.title&&(0,D.jsx)("div",{className:"fw-semibold",style:{fontSize:"0.88rem"},children:o.title}),(o.meta_description||o.og_description)&&(0,D.jsx)("div",{className:"text-muted",style:{fontSize:"0.76rem",marginTop:2},children:o.meta_description||o.og_description})]}),o.og_image&&(0,D.jsx)("img",{src:o.og_image,alt:"og",style:{width:72,height:48,objectFit:"cover",borderRadius:4,border:"1px solid rgba(148,163,184,0.2)",flexShrink:0},onError:e=>{e.currentTarget.style.display="none"}})]}),o.canonical&&(0,D.jsx)(pt,{label:"Canonical URL",value:o.canonical,mono:!0})]}),c.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(gt,{children:["Browser Test Runs (",c.length,")"]}),c.map((e,s)=>(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2 py-1",style:{borderTop:"1px solid rgba(148,163,184,0.1)",fontSize:"0.78rem"},children:[(0,D.jsx)("i",{className:"feather "+(e.events_found>0?"icon-check-circle":"error"===e.nav_status?"icon-x-circle":"icon-clock"),style:{color:e.events_found>0?"#22c55e":"error"===e.nav_status?"#ef4444":"#f59e0b",fontSize:"0.8rem",flexShrink:0}}),(0,D.jsx)("span",{className:"fw-medium",style:{flex:1},children:e.ua_type}),(0,D.jsxs)("span",{className:"text-end text-muted",children:[null!=e.nav_status&&"error"!==e.nav_status&&"timeout_networkidle"!==e.nav_status?`HTTP ${e.nav_status}`:e.nav_status||"\u2014"," \xb7 ",e.events_found>0?(0,D.jsxs)("span",{style:{color:"#22c55e"},children:[e.events_found," event",1!==e.events_found?"s":""]}):(0,D.jsx)("span",{style:{color:"#ef4444"},children:"no event"})]})]},s))]}),(m.length>0||(null===(s=o.lc_pixel_keys_found)||void 0===s?void 0:s.length)>0)&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(gt,{children:["Third-Party Trackers Found (",m.length,")"]}),(0,D.jsx)("div",{className:"d-flex flex-wrap gap-1 mb-1",children:m.length>0?m.map(e=>{const s=x[e]||"#6b7280";return(0,D.jsx)("span",{className:"badge rounded-pill",style:{fontSize:"0.72rem",background:`${s}20`,color:s,border:`1px solid ${s}50`},children:e},e)}):(0,D.jsx)("span",{className:"text-muted",style:{fontSize:"0.78rem"},children:"None detected"})}),(null===(t=o.lc_pixel_keys_found)||void 0===t?void 0:t.length)>0&&(0,D.jsxs)("div",{className:"text-muted mt-1",style:{fontSize:"0.75rem"},children:["Other pixel keys detected: ",o.lc_pixel_keys_found.join(", ")]})]}),null!=l.status_code&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(gt,{children:"Server Intelligence"}),l.server_ip&&(0,D.jsx)(pt,{label:"IP Address",mono:!0,value:(0,D.jsxs)("span",{children:[l.server_ip,(l.geo_city||l.geo_country)&&(0,D.jsxs)("span",{className:"ms-2 text-muted",style:{fontFamily:"inherit"},children:[(v=l.geo_country,v?v.toUpperCase().replace(/./g,e=>String.fromCodePoint(e.charCodeAt(0)+127397)):"")," ",[l.geo_city,l.geo_country].filter(Boolean).join(", ")]})]})}),l.ptr_record&&(0,D.jsx)(pt,{label:"Reverse DNS",value:l.ptr_record,mono:!0}),(0,D.jsx)(pt,{label:"HTTP Status",value:`${l.status_code}${200===l.status_code?" OK":""}`}),(0,D.jsx)(pt,{label:"Server Software",value:l.server_software||"Unknown"}),l.powered_by&&(0,D.jsx)(pt,{label:"Powered By",value:l.powered_by}),l.os_hint&&(0,D.jsx)(pt,{label:"Operating System",value:l.os_hint}),(0,D.jsx)(pt,{label:"CDN / WAF",value:l.cdn_provider||"None detected"}),h.length>0&&(0,D.jsxs)("div",{className:"d-flex gap-2 py-1 align-items-center",style:{borderTop:"1px solid rgba(148,163,184,0.1)",fontSize:"0.78rem"},children:[(0,D.jsx)("span",{className:"text-muted flex-shrink-0",style:{width:170},children:"Technology Stack"}),(0,D.jsx)("div",{className:"d-flex flex-wrap gap-1",children:h.map(e=>(0,D.jsx)("span",{className:"badge rounded-pill bg-secondary",style:{fontSize:"0.68rem"},children:e},e))})]})]}),null!=l.response_time_ms&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(gt,{children:"Performance"}),(0,D.jsx)(pt,{label:"Response Time",value:(0,D.jsxs)("span",{style:{color:u},children:[l.response_time_ms," ms"," \xb7 ",l.response_time_ms<500?"Fast":l.response_time_ms<2e3?"Moderate":"Slow"]})}),null!=l.page_size_bytes&&(0,D.jsx)(pt,{label:"Page Size",value:(p=l.page_size_bytes,p>1048576?`${(p/1048576).toFixed(1)} MB`:p>1024?`${(p/1024).toFixed(1)} KB`:`${p} B`)}),(0,D.jsx)(pt,{label:"Compression",value:l.compression&&"none"!==l.compression?`\u2705 ${l.compression}`:"\u26a0\ufe0f None"}),null!=l.script_count&&(0,D.jsx)(pt,{label:"Script Tags",value:`${l.script_count}`}),null!=l.cookies_set&&(0,D.jsx)(pt,{label:"Cookies Set",value:`${l.cookies_set}`}),(0,D.jsx)(pt,{label:"HTTPS",value:l.https?"\u2705 Secure":"\u26a0\ufe0f Not secure"}),null!=l.redirect_count&&(0,D.jsx)(pt,{label:`Redirects (${l.redirect_count})`,value:0===l.redirect_count?"None":(l.redirect_chain||[]).join(" \u2192 ")})]}),Object.keys(r).length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(gt,{children:"Security Audit"}),(0,D.jsx)(ft,{headerKey:"strict_transport_security",present:r.strict_transport_security}),r.content_security_policy&&r.csp_may_block_pixel?(0,D.jsx)("div",{style:{borderTop:"1px solid rgba(148,163,184,0.1)",fontSize:"0.78rem"},children:(0,D.jsxs)("div",{className:"d-flex align-items-center gap-2 py-1",children:[(0,D.jsx)("i",{className:"feather icon-alert-circle",style:{color:"#f59e0b",fontSize:"0.8rem",flexShrink:0}}),(0,D.jsx)("span",{children:"Content-Security-Policy"}),(0,D.jsx)("span",{className:"ms-auto",style:{color:"#f59e0b",fontWeight:600},children:"Present \u2014 blocking pixel"})]})}
1):(0,D.jsx)(ft,{headerKey:"content_security_policy",present:r.content_security_policy}),(0,D.jsx)(ft,{headerKey:"x_frame_options",present:r.x_frame_options}),(0,D.jsx)(ft,{headerKey:"x_content_type_options",present:r.x_content_type_options}),(0,D.jsx)(ft,{headerKey:"referrer_policy",present:r.referrer_policy}),(0,D.jsx)(ft,{headerKey:"permissions_policy",present:r.permissions_policy}),r.content_security_policy&&(0,D.jsxs)("div",{className:"mt-1 ms-0",style:{fontSize:"0.78rem"},children:[[[r.csp_blocks_inline_scripts,"\u26a0\ufe0f Site CSP blocks inline scripts","Add 'unsafe-inline' to script-src or script-src-elem, or use a nonce on the pixel's <script> tag. Most sites don't need this."],[r.csp_blocks_pixel_cdn,"\u26a0\ufe0f Site CSP blocks third-party CDN scripts","Add pixel.linkclicks.com to script-src. Most sites install without this change."],[r.csp_blocks_pixel_beacon,"\u26a0\ufe0f Site CSP blocks beacon requests","Add api.linkclicks.com to connect-src."]].map((e,s)=>{let[t,a,n]=e;return t?(0,D.jsxs)("div",{className:"d-flex align-items-start gap-1 mt-1",style:{color:"#f59e0b"},children:[(0,D.jsx)("i",{className:"feather icon-alert-triangle mt-1",style:{flexShrink:0,fontSize:"0.8rem"}}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{style:{fontWeight:600},children:a}),(0,D.jsxs)("div",{className:"text-muted",style:{fontSize:"0.74rem"},children:["Fix: ",n]})]})]},s):null}),r.csp_value&&(0,D.jsx)("div",{className:"mt-1 font-monospace p-2 rounded",style:{background:"rgba(0,0,0,0.05)",wordBreak:"break-all",fontSize:"0.68rem",color:"#94a3b8"},children:r.csp_value})]})]}),Object.keys(o).length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(gt,{children:"SEO"}),o.meta_description?(0,D.jsx)(pt,{label:"Meta Description",value:o.meta_description}):(0,D.jsx)(pt,{label:"Meta Description",value:(0,D.jsx)("span",{style:{color:"#f59e0b"},children:'Missing \u2014 add a <meta name="description"> tag'})}),(0,D.jsx)(pt,{label:"Robots",value:o.robots_meta&&"not set"!==o.robots_meta?o.robots_meta.includes("noindex")||o.robots_meta.includes("nofollow")?(0,D.jsxs)("span",{style:{color:"#f59e0b"},children:[o.robots_meta," \u2014 may reduce crawlability"]}):o.robots_meta:(0,D.jsx)("span",{className:"text-muted",children:"Not set (defaults to index, follow)"})}),o.canonical&&(0,D.jsx)(pt,{label:"Canonical",value:o.canonical,mono:!0}),[{key:"has_open_graph",label:"Open Graph",hint:"Add og:title, og:description, og:image for rich social link previews."},{key:"has_twitter_card",label:"Twitter / X Card",hint:'Add <meta name="twitter:card" content="summary_large_image"> for X link cards.'},{key:"has_schema_org",label:"Schema.org / JSON-LD",hint:"Add structured data (application/ld+json) to improve search result appearance."}].map(e=>{let{key:s,label:t,hint:a}=e;return(0,D.jsxs)("div",{className:"d-flex gap-2 py-1 align-items-start",style:{borderTop:"1px solid rgba(148,163,184,0.1)",fontSize:"0.78rem"},children:[(0,D.jsx)("i",{className:`feather ${o[s]?"icon-check-circle":"icon-alert-circle"} mt-1`,style:{color:o[s]?"#22c55e":"#f59e0b",fontSize:"0.8rem",flexShrink:0}}),(0,D.jsx)("span",{className:"text-muted flex-shrink-0",style:{width:162},children:t}),o[s]?(0,D.jsx)("span",{className:"fw-medium",style:{color:"#22c55e"},children:"Present"}):(0,D.jsx)("span",{className:"text-muted",children:a})]},s)})]}),l.response_headers&&Object.keys(l.response_headers).length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(gt,{children:"Response Headers"}),(0,D.jsxs)("details",{children:[(0,D.jsxs)("summary",{className:"text-muted",style:{cursor:"pointer",fontSize:"0.78rem"},children:["Show ",Object.keys(l.response_headers).length," headers"]}),(0,D.jsx)("div",{className:"mt-1",children:Object.entries(l.response_headers).map(e=>{let[s,t]=e;return(0,D.jsx)(pt,{label:s,value:t,mono:!0},s)})})]})]}),(null===(a=i.issues)||void 0===a?void 0:a.length)>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(gt,{children:"Issues Detected"}),(0,D.jsx)("ul",{className:"mb-0 small ps-3",children:i.issues.map((e,s)=>(0,D.jsx)("li",{children:e},s))})]}),(null===(n=i.suggestions)||void 0===n?void 0:n.length)>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(gt,{children:"Suggestions"}),(0,D.jsx)("ul",{className:"mb-0 small ps-3",children:i.suggestions.map((e,s)=>(0,D.jsx)("li",{children:e},s))})]})]});var p,v})(),(0,D.jsx)("div",{className:"mt-3",children:(0,D.jsxs)("small",{className:"text-muted",children:[(0,D.jsx)("i",{className:"feather icon-info me-1"}),"Launches real browser sessions (Desktop Chrome, Mobile Safari, Android Chrome) against your URL, confirms the pixel fires live events, and reports server location, CDN, security headers, SEO and tracker diagnostics."]})})]})}),(0,D.jsx)("div",{className:"col-12 col-xl-5",children:(0,D.jsx)("div",{className:"border rounded p-3 h-100",children:w?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"d-flex justify-content-between align-items-start gap-3 mb-3",children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h6",{className:"mb-1",children:"Pixel Health Snapshot"}),(0,D.jsx)("div",{className:"small text-muted",children:(null===n||void 0===n?void 0:n.name)||"Selected pixel"})]}),(0,D.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:"0.78rem",fontWeight:600,flexShrink:0,backgroundColor:`${w.color}22`,color:w.color,padding:"4px 9px",borderRadius:20},children:[w.scoreDisplay,"/",w.maxScore," ",w.label]})]}),(0,D.jsx)("div",{className:"d-flex flex-column gap-2",children:S.map(e=>(0,D.jsxs)("div",{className:"d-flex align-items-start gap-3 py-2",style:{borderTop:"1px solid rgba(148, 163, 
1184, 0.16)",...e.isActionable&&("settings-domains"===e.actionTarget?r:l)?{cursor:"pointer"}:{}},role:e.isActionable&&("settings-domains"===e.actionTarget?r:l)?"button":void 0,tabIndex:e.isActionable&&("settings-domains"===e.actionTarget?r:l)?0:void 0,onClick:e.isActionable?()=>{const s="settings-domains"===e.actionTarget?r:l;s&&s()}:void 0,onKeyDown:e.isActionable?s=>{if("Enter"===s.key||" "===s.key){s.preventDefault();const t="settings-domains"===e.actionTarget?r:l;t&&t()}}:void 0,children:[(0,D.jsx)("span",{style:{width:28,height:28,borderRadius:"50%",flexShrink:0,marginTop:2,backgroundColor:`${e.color}18`,color:e.color,display:"inline-flex",alignItems:"center",justifyContent:"center"},children:(0,D.jsx)("i",{className:`feather icon-${e.icon}`,style:{fontSize:"0.85rem"}})}),(0,D.jsxs)("div",{style:{minWidth:0,flex:1},children:[(0,D.jsxs)("div",{className:"fw-semibold d-flex align-items-center gap-2 flex-wrap",children:[(0,D.jsx)("span",{children:e.label}),(0,D.jsx)("span",{style:{color:e.color,fontSize:"0.74rem"},children:e.statusLabel}),e.isActionable&&e.actionLabel&&("settings-domains"===e.actionTarget?r:l)&&(0,D.jsxs)("span",{style:{color:e.color,fontSize:"0.7rem",fontWeight:600},children:[e.actionLabel," ",(0,D.jsx)("i",{className:"feather icon-arrow-right ms-1"})]})]}),(0,D.jsx)("div",{className:"small text-muted",children:e.description})]})]},e.label))}),(0,D.jsxs)("div",{className:"mt-3 pt-2 small text-muted",style:{borderTop:"1px solid rgba(148, 163, 184, 0.16)"},children:[k?(0,D.jsxs)("div",{children:[(0,D.jsx)("strong",{children:"Latest activity:"})," ",k.event_name," \xb7 ",(0,hs.fF)(k.received_at)]}):(0,D.jsxs)("div",{children:[(0,D.jsx)("strong",{children:"Latest activity:"})," No events received yet"]}),(0,D.jsxs)("div",{className:"mt-1",children:[(0,D.jsx)("strong",{children:"Domain status:"})," ","verified"===(null===n||void 0===n?void 0:n.verification_status)?"Verified":(null===n||void 0===n?void 0:n.verification_status)||"Unverified"]})]})]}):(0,D.jsx)("div",{className:"small text-muted",children:"No pixel health data available yet."})})}),x.length>0&&(()=>{const e=x.some((e,s)=>{const t=x[s+1];return t&&(t.server_software&&e.server_software&&e.server_software!==t.server_software||void 0!==t.https&&void 0!==e.https&&e.https!==t.https||void 0!==t.cdn_provider&&e.cdn_provider!==t.cdn_provider)});return(0,D.jsx)("div",{className:"col-12",children:(0,D.jsxs)("div",{className:"border rounded p-3",children:[(0,D.jsxs)("div",{className:"d-flex align-items-center justify-content-between mb-3",children:[(0,D.jsxs)("div",{style:{fontSize:"0.85rem",fontWeight:500},children:[(0,D.jsx)("i",{className:"feather icon-clock me-2",style:{color:"#94a3b8"}}),"Scan History",e&&(0,D.jsxs)("span",{className:"ms-2",style:{fontSize:"0.72rem",color:"#f59e0b"},children:[(0,D.jsx)("i",{className:"feather icon-alert-circle me-1"}),"Changes detected"]})]}),(0,D.jsxs)("span",{className:"text-muted",style:{fontSize:"0.76rem"},children:[x.length," scan",1!==x.length?"s":""," \xb7 newest first"]})]}),(0,D.jsx)("div",{style:{overflowX:"auto"},children:(0,D.jsxs)("table",{className:"table table-sm table-hover mb-0",style:{fontSize:"0.79rem"},children:[(0,D.jsx)("thead",{children:(0,D.jsxs)("tr",{style:{color:"#94a3b8"},children:[(0,D.jsx)("th",{style:{fontWeight:500,border:"none",paddingLeft:0,whiteSpace:"nowrap"},children:"When"}),(0,D.jsx)("th",{style:{fontWeight:500,border:"none",whiteSpace:"nowrap"},children:"Result"}),(0,D.jsx)("th",{style:{fontWeight:500,border:"none",whiteSpace:"nowrap"},children:"Status"}),(0,D.jsx)("th",{style:{fontWeight:500,border:"none",whiteSpace:"nowrap"},children:"Response"}),(0,D.jsx)("th",{style:{fontWeight:500,border:"none",whiteSpace:"nowrap"},children:"Server"}),(0,D.jsx)("th",{style:{fontWeight:500,border:"none",whiteSpace:"nowrap"},children:"CDN"}),(0,D.jsx)("th",{style:{fontWeight:500,border:"none",whiteSpace:"nowrap"},children:"URL"}),(0,D.jsx)("th",{style:{border:"none"}})]})}),(0,D.jsx)("tbody",{children:x.map((e,s)=>{var t;const a=x[s+1],n=a&&a.server_software&&e.server_software&&e.server_softw
1are!==a.server_software,i=a&&void 0!==a.cdn_provider&&e.cdn_provider!==a.cdn_provider,l=e.response_time_ms,r=null==l?"#94a3b8":l<500?"#22c55e":l<2e3?"#f59e0b":"#ef4444";return(0,D.jsxs)("tr",{style:{cursor:"pointer",verticalAlign:"middle"},onClick:()=>g(e),role:"button",tabIndex:0,onKeyDown:s=>"Enter"===s.key&&g(e),children:[(0,D.jsx)("td",{style:{paddingLeft:0,whiteSpace:"nowrap",color:"#94a3b8"},children:e.scanned_at?new Date(e.scanned_at).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"\u2014"}),(0,D.jsx)("td",{children:(0,D.jsxs)("span",{style:{color:e.success?"#22c55e":"#ef4444"},children:[(0,D.jsx)("i",{className:`feather ${e.success?"icon-check-circle":"icon-x-circle"} me-1`}),e.success?"Pass":"Fail"]})}),(0,D.jsx)("td",{style:{color:200===e.status_code?"#22c55e":"#f59e0b"},children:null!==(t=e.status_code)&&void 0!==t?t:"\u2014"}),(0,D.jsx)("td",{style:{color:r},children:null!=l?l<1e3?`${l}ms`:`${(l/1e3).toFixed(1)}s`:"\u2014"}),(0,D.jsx)("td",{children:n?(0,D.jsxs)("span",{title:`Changed from: ${a.server_software}`,children:[(0,D.jsx)("i",{className:"feather icon-alert-circle me-1",style:{color:"#f59e0b"}}),(0,D.jsx)("span",{style:{color:"#f59e0b"},children:e.server_software||"\u2014"})]}):(0,D.jsx)("span",{style:{color:"#94a3b8"},children:e.server_software||"\u2014"})}),(0,D.jsx)("td",{children:i?(0,D.jsxs)("span",{style:{color:"#f59e0b"},title:`Changed from: ${a.cdn_provider||"none"}`,children:[(0,D.jsx)("i",{className:"feather icon-alert-circle me-1"}),e.cdn_provider||"none"]}):(0,D.jsx)("span",{style:{color:"#94a3b8"},children:e.cdn_provider||"\u2014"})}),(0,D.jsx)("td",{style:{maxWidth:160},children:e.url?(0,D.jsx)("span",{style:{color:"#94a3b8",display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:160},title:e.url,children:e.url.replace(/^https?:\/\//,"").split("?")[0]}):"\u2014"}),(0,D.jsx)("td",{style:{color:"#94a3b8",paddingRight:0,width:24},children:(0,D.jsx)("i",{className:"feather icon-chevron-right",style:{fontSize:"0.85rem"}})})]},s)})})]})})]})})})(),(0,D.jsx)(ut,{show:!!f,onHide:()=>g(null),scan:f,pixelName:null===n||void 0===n?void 0:n.name})]})})};var jt=t(63780);const yt="block",Nt="observe",_t="off",wt={[yt]:{label:"Block",hint:"Do not send these to the ad platforms.",color:"#e74c3c"},[Nt]:{label:"Watch",hint:"Keep sending, but count how many this would hold.",color:"#f39c12"},[_t]:{label:"Off",hint:"Ignore this signal entirely.",color:"#6c757d"}},kt={non_human:{title:"Not a real person",blurb:"Automated traffic. Reporting it as a conversion teaches the ad platform to buy more of it."},attribution:{title:"Credit for the sale looks wrong",blurb:"The purchase is real, but the click being credited for it probably is not."},context:{title:"Nobody saw the page",blurb:"The page loaded, but not in front of a human who could have decided to buy."},event_sanity:{title:"The conversion itself looks wrong",blurb:"Faults in the event payload rather than doubts about who produced it."},consent:{title:"The visitor refused ad tracking",blurb:"Read from your own consent banner \u2014 we never ask anyone anything. Google accepts the refusal directly and still counts the conversion; the other five accept no such instruction, so respecting it there means not sending."}},St=[{key:"recommended",label:"Recommended",blurb:"Our default. Right for almost everyone."},{key:"strict",label:"Strict",blurb:"Block every optional signal, not just the watched ones."},{key:"custom",label:"Custom",blurb:"Your own choices, rule by rule."}],Ct=(e,s,t)=>e.locked?yt:Object.prototype.hasOwnProperty.call(t,e.id)?t[e.id]:"strict"===s?yt:e.default,At=e=>{let{counts:s,mode:t,locked:a}=e;if(!s)return null;const n=s.held||0,i=s.observed||0,l=s.excluded||0;return a||l&&!n&&!i?l?(0,D.jsxs)("span",{className:"text-muted small",children:[l.toLocaleString()," events kept out in the last 30 days"]}):null:t===Nt?i?(0,D.jsxs)("span",{className:"small",style:{color:wt[Nt].color},children:[i.toLocaleString()," sends would be held \u2014 you are still sending these"]}):(0,D.jsx)("span",{className:"text-muted small",children:"Nothing matched in the last 30 days"}):t===yt?n?(0,D.jsxs)("span",{className:"text-muted small",children:[n.toLocaleStr
1ing()," sends held in the last 30 days"]}):(0,D.jsx)("span",{className:"text-muted small",children:"Nothing held in the last 30 days"}):(0,D.jsx)("span",{className:"text-muted small",children:"Not counted while off"})},Pt={meta:"Meta",snapchat:"Snapchat"},zt={GREAT:"#2ecc71",GOOD:"#27ae60",OKAY:"#f39c12",BAD:"#e74c3c"},Tt=e=>{let{readback:s}=e;const t=Object.entries((null===s||void 0===s?void 0:s.platforms)||{}).filter(e=>{let[,s]=e;return null===s||void 0===s?void 0:s.length});return t.length?(0,D.jsxs)("div",{className:"mb-4",children:[(0,D.jsxs)("div",{className:"d-flex justify-content-between align-items-baseline mb-1",children:[(0,D.jsx)("h6",{className:"mb-0",children:"How the platforms rate your data"}),s.captured_on&&(0,D.jsxs)("span",{className:"text-muted small",children:["as of ",s.captured_on]})]}),(0,D.jsx)("p",{className:"text-muted small mb-2",children:"Read back from each platform, in their words. Only Meta and Snapchat publish this. \u201cAPI\u201d or \u201cweb\u201d is the data we send from our servers; \u201cSDK\u201d is your site\u2019s own tag for that platform."}),t.map(e=>{let[s,t]=e;return(0,D.jsxs)("div",{className:"mb-2",children:[(0,D.jsx)("div",{className:"fw-semibold small mb-1",children:Pt[s]||s}),t.map(e=>{var s;const t=(null===(s=e.details)||void 0===s?void 0:s.recommendations)||[];return(0,D.jsxs)("div",{className:"py-2 border-bottom",children:[(0,D.jsxs)("div",{className:"d-flex justify-content-between align-items-center gap-3",children:[(0,D.jsxs)("div",{className:"small",children:[(0,D.jsx)("span",{className:"fw-semibold",children:e.event_name||e.metric}),e.source&&(0,D.jsx)("span",{className:"badge bg-light text-secondary ms-2",children:e.source})]}),null!==e.composite_score&&void 0!==e.composite_score&&(0,D.jsxs)("span",{className:"small text-muted",children:["Match quality ",(0,D.jsx)("span",{className:"fw-semibold",children:e.composite_score})," / 10"]}),e.grade&&(0,D.jsx)("span",{className:"small fw-semibold",style:{color:zt[e.grade]||void 0},children:e.grade})]}),t.length>0&&(0,D.jsx)("ul",{className:"text-muted small mb-0 mt-1 ps-3",children:t.slice(0,3).map((e,s)=>(0,D.jsx)("li",{children:e.description||e.title},e.recommendation_code||s))})]},`${e.metric}-${e.source}-${e.event_name}`)})]},s)})]}):null},Ft=e=>{let{signal:s,value:t,disabled:a,onChange:n}=e;return(0,D.jsx)("div",{className:"btn-group btn-group-sm",role:"group","aria-label":`${s.label} handling`,children:[yt,Nt,_t].map(e=>{const s=t===e;return(0,D.jsx)("button",{type:"button",disabled:a,title:wt[e].hint,"aria-pressed":s,onClick:()=>n(e),className:"btn "+(s?"btn-primary":"btn-outline-secondary"),style:s?{backgroundColor:wt[e].color,borderColor:wt[e].color}:void 0,children:wt[e].label},e)})})},Et=e=>{let{pixelKey:s,pixel:t,onSaved:n}=e;const{requireSubscription:i}=(0,jt.A)(),[l,r]=(0,a.useState)(null),[o,c]=(0,a.useState)(null),[d,m]=(0,a.useState)(null),[h,u]=(0,a.useState)(!0),[x,p]=(0,a.useState)(null),[v,f]=(0,a.useState)(!1),g=(null===t||void 0===t?void 0:t.settings)&&t.settings.capi_cleaning||{},[b,j]=(0,a.useState)(g.profile||"recommended"),[_,w]=(0,a.useState)(g.overrides||{}),[k,S]=(0,a.useState)({profile:g.profile||"recommended",overrides:g.overrides||{}});(0,a.useEffect)(()=>{let e=!1;return u(!0),p(null),(0,y.qQ)("/conversions/capi-signals/").then(s=>{e||r(s.data)}).catch(()=>{e||p("Could not load the forwarding rules.")}).finally(()=>{e||u(!1)}),()=>{e=!0}},[]),(0,a.useEffect)(()=>{let e=!1;if(c(null),s)return(0,y.qQ)(`/conversions/pixels/${s}/forwarding-quality/impact/?window=30`).then(s=>{e||c(s.data)}).catch(()=>{e||c(null)}),()=>{e=!0}},[s]),(0,a.useEffect)(()=>{let e=!1;if(m(null),s)return(0,y.qQ)(`/conversions/pixels/${s}/event-quality/`).then(s=>{e||m(s.data)}).catch(()=>{e||m(null)}),()=>{e=!0}},[s]),(0,a.useEffect)(()=>{const e=(null===t||void 0===t?void 0:t.settings)&&t.settings.capi_cleaning||{};j(e.profile||"recommended"),w(e.overrides||{}),S({profile:e.profile||"recommended",overrides:e.overrides||{}})},[s,t]);const C=(0,a.useMemo)(()=>b!==k.profile||JSON.stringify(_)!==JSON.stringify(k.overrides),[b,_,k]),A=(0,a.useCallback)((e,s)=>{w(t=>
1({...t,[e.id]:s})),j("custom")},[]),P=(0,a.useCallback)(e=>{j(e),"custom"!==e&&w({})},[]),z=(0,a.useCallback)(async()=>{if(i(void 0,{message:"Subscribe to tune how your conversions are cleaned."})){f(!0);try{await(0,y.patchWithToken)(`/conversions/pixels/${s}/`,{settings:{capi_cleaning:{profile:b,overrides:_}}}),S({profile:b,overrides:_}),(0,N.LG)("Forwarding quality rules saved."),n&&n()}catch(o){var e,t,a,l,r;const s=(null===o||void 0===o||null===(e=o.response)||void 0===e||null===(t=e.data)||void 0===t||null===(a=t.settings)||void 0===a?void 0:a.capi_cleaning)||(null===o||void 0===o||null===(l=o.response)||void 0===l||null===(r=l.data)||void 0===r?void 0:r.detail);(0,N.UW)(s||"Could not save those rules.")}finally{f(!1)}}},[i,s,b,_,n]),T=(0,a.useMemo)(()=>{if(!l)return[];const e={};return l.signals.forEach(s=>{(e[s.group]=e[s.group]||[]).push(s)}),["non_human","attribution","context","event_sanity","consent"].filter(s=>e[s]).map(s=>({key:s,signals:e[s]}))},[l]);return h?(0,D.jsxs)("div",{className:"text-center py-5",children:[(0,D.jsx)("div",{className:"spinner-border text-primary mb-3",role:"status","aria-hidden":"true"}),(0,D.jsx)("p",{className:"text-muted small",children:"Loading forwarding rules\u2026"})]}):x?(0,D.jsx)("div",{className:"p-4 text-center text-muted small",children:x}):(0,D.jsxs)("div",{className:"p-3",children:[(0,D.jsxs)("div",{className:"mb-4",children:[(0,D.jsx)("h5",{className:"mb-1",children:"Forwarding quality"}),(0,D.jsx)("p",{className:"text-muted small mb-0",children:"Conversions we are not confident in are held back rather than sent to your ad platforms. Ad platforms bid using what you report, so a bot counted as a sale teaches them to buy more bots. Held conversions are kept, not deleted."}),(null===o||void 0===o?void 0:o.through)&&(0,D.jsxs)("p",{className:"text-muted small mb-0 mt-1",children:["Counts cover the 30 days up to ",o.through,". A rule set to Watch keeps sending and reports what it would have held, so you can see the cost of switching it on before you do. A \u201csend\u201d is one conversion going to one platform, so a conversion going to two platforms counts twice."]})]}),(0,D.jsx)("div",{className:"row g-2 mb-4",children:St.map(e=>(0,D.jsx)("div",{className:"col-md-4",children:(0,D.jsxs)("button",{type:"button",onClick:()=>P(e.key),className:"btn w-100 text-start p-3 "+(b===e.key?"btn-primary":"btn-outline-secondary"),children:[(0,D.jsx)("div",{className:"fw-bold",children:e.label}),(0,D.jsx)("div",{className:"small",style:{opacity:.85},children:e.blurb})]})},e.key))}),(0,D.jsx)(Tt,{readback:d}),T.map(e=>{let{key:s,signals:t}=e;const a=t.filter(e=>Ct(e,b,_)===yt).length,n=kt[s]||{title:s,blurb:""};return(0,D.jsxs)("div",{className:"mb-4",children:[(0,D.jsxs)("div",{className:"d-flex justify-content-between align-items-baseline mb-1",children:[(0,D.jsx)("h6",{className:"mb-0",children:n.title}),(0,D.jsxs)("span",{className:"text-muted small",children:[a," of ",t.length," blocking"]})]}),(0,D.jsx)("p",{className:"text-muted small mb-2",children:n.blurb}),t.map(e=>{var s,t;const a=Ct(e,b,_);return(0,D.jsxs)("div",{className:"d-flex justify-content-between align-items-center gap-3 py-2 border-bottom",children:[(0,D.jsxs)("div",{className:"flex-grow-1",children:[(0,D.jsxs)("div",{className:"fw-semibold small",children:[e.label,e.locked&&(0,D.jsx)("span",{className:"badge bg-light text-secondary ms-2",title:"This one cannot be turned off.",children:"Always on"})]}),(0,D.jsx)("div",{className:"text-muted small",children:e.description}),(null===(s=e.native_platforms)||void 0===s?void 0:s.length)>0&&a===yt&&(0,D.jsxs)("div",{className:"text-muted small fst-italic",children:["Does not hold ",e.native_platforms.join(", ")," \u2014 sent the refusal instead."]}),o&&(0,D.jsx)("div",{className:"mt-1",children:(0,D.jsx)(At,{counts:null===(t=o.signals)||void 0===t?void 0:t[e.id],mode:a,locked:e.locked})})]}),(0,D.jsx)(Ft,{signal:e,value:a,disabled:e.locked||v,onChange:s=>A(e,s)})]},e.id)})]},s)}),(0,D.jsxs)("div",{className:"d-flex align-items-center gap-3",children:[(0,D.jsx)("button",{type:"button",className:"btn btn-primary",disabled:!C||v,onClick:z,children:v?"Saving\u2026":"Save changes"}),C&&(0,D.jsx)("span",{className:"text-muted small",children:"You have unsaved changes."})]})]})};
1var Lt=t(2365),Dt=t(83131),$t=t(96718),It=t(71295);const Rt=t.p+"static/media/connections.5b8e5c6d1b0aeda8a015.mp4",Mt=t.p+"static/media/connections-poster.09acdbaa41749f09eb2b.jpg";var Bt=t(59123);const Wt=[{q:"How many pixels do I need to install?",a:"One. The LinkClicks universal pixel is a single install that forwards events to Meta, Google, TikTok, Pinterest, Snapchat and LinkedIn at the same time. You do not add a separate pixel per ad platform, and you do not reinstall anything when you add a new platform later."},{q:"What happens if I do not install a pixel at all?",a:"Without a pixel there is no attribution, which means no ad platform can tell you which ad actually produced a sale. You can still see clicks and impressions, but you cannot connect them to revenue \u2014 so you are optimising on activity rather than outcomes."},{q:"Why is click-through rate misleading on its own?",a:"Click-through rate only measures what happens before someone reaches your site. An ad can earn a high CTR and still lose money if those visitors never buy, while a lower-CTR ad quietly drives most of your revenue. Without conversion tracking the losing ad looks like the winner, so budget follows the wrong creative."},{q:"Can I use the universal pixel if I am not running ads?",a:"Yes. The pixel works as standalone website analytics: traffic sources, referrers, locations, landing pages and full funnel events from page view through to purchase. It also feeds bot and ad-fraud detection and traffic-quality reporting. Plenty of sites install it purely for the analytics and turn ad platforms on later."},{q:"Does one pixel slow my site down more than several?",a:"No \u2014 it is the opposite. A single universal pixel replaces six separate platform tags, so the browser loads one script instead of several and there is no duplicate page-load overhead or duplicated event firing."},{q:"What are server-side conversions?",a:"Conversions sent from our servers straight to each ad platform\u2019s conversion API, rather than from your visitor\u2019s browser. Browser calls are dropped by ad blockers, cookie limits and privacy defaults, so a share of your real conversions never arrives. Server-side forwarding closes that gap: LinkClicks sends to Meta, Google, TikTok, Pinterest, Snapchat and LinkedIn from its own servers, using the identifiers your pixel already captured."},{q:"What gets held back before it reaches my ad platforms?",a:"Bot and crawler traffic, our own uptime monitors, and conversions whose ad credit looks hijacked are all held by default. Bots and internal traffic are locked on and cannot be switched off \u2014 they are not a conversion for anybody. Everything else is yours to steer: each quality rule can be set to Block, Watch or Off, per pixel. Nothing is deleted, so a hold is recorded with the reason behind it and stays reversible."},{q:"Do you send my customers\u2019 personal information to ad platforms?",a:"Never in plain text. Email addresses and phone numbers are normalised and hashed with SHA-256 before they leave our servers \u2014 the ad platform matches that hash against its own hashed records, so neither side ever sees the other\u2019s raw data. Addresses and demographics are not forwarded at all, and where your store hands us an already-hashed email we pass it through rather than hashing it twice."}],Ot=()=>{const e=()=>(0,$t.Y)({redirectPath:`${window.location.pathname}${window.location.search||""}`});return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(Lt.A,{title:"Universal Pixel & Server-Side Conversions API (CAPI) | LinkClicks",description:"Server-side conversions to all six ad platforms from one pixel, with bot, scraper and ad-fraud traffic held back before it reaches them.",canonical:"/connections",ogImage:"/images/og/1200_630_connections.png",ogImageAlt:"LinkClicks universal pixel connecting six ad platforms and your store"}),(0,D.jsxs)("div",{className:"cs-landing conn-landing",children:[(0,D.jsxs)("div",{className:"cs-hero",children:[(0,D.jsx)(Bt.A,{className:"cs-hero__video",src:Rt,poster:Mt}
1),(0,D.jsx)("div",{className:"cs-hero__overlay"}),(0,D.jsx)("div",{className:"cs-hero__glow"}),(0,D.jsxs)("div",{className:"cs-hero__content",children:[(0,D.jsx)("div",{className:"cs-hero__eyebrow",children:"Connections"}),(0,D.jsxs)("h1",{className:"cs-hero__headline",children:["One pixel.",(0,D.jsx)("br",{}),"Every platform.",(0,D.jsx)("br",{}),"Total clarity."]}),(0,D.jsx)("p",{className:"cs-hero__sub",children:"Install one universal pixel, once, and track conversions across every ad platform you run \u2014 instead of adding a separate Meta, Google, TikTok, Pinterest, Snapchat and LinkedIn tag and then reconciling six conflicting attribution reports. Without a pixel there is no attribution at all: you can see which ad got the click, but not which ad earned the sale. And you don't need to be running ads to use it \u2014 it works on its own as website analytics, bot and ad-fraud detection, and traffic-quality reporting."}),(0,D.jsxs)("div",{className:"cs-hero__tools",children:[(0,D.jsxs)("button",{type:"button",className:"cs-hero__tool-btn",onClick:e,children:[(0,D.jsx)("span",{className:"cs-hero__tool-icon",children:(0,D.jsx)("i",{className:"feather icon-activity"})}),(0,D.jsx)("span",{className:"cs-hero__tool-label",children:"Get Started"})]}),(0,D.jsxs)("button",{type:"button",className:"cs-hero__tool-btn",onClick:e,children:[(0,D.jsx)("span",{className:"cs-hero__tool-icon",children:(0,D.jsx)("i",{className:"feather icon-wifi"})}),(0,D.jsx)("span",{className:"cs-hero__tool-label",children:"Connect Ad Platforms"})]}),(0,D.jsxs)("button",{type:"button",className:"cs-hero__tool-btn",onClick:e,children:[(0,D.jsx)("span",{className:"cs-hero__tool-icon",children:(0,D.jsx)("i",{className:"feather icon-shopping-cart"})}),(0,D.jsx)("span",{className:"cs-hero__tool-label",children:"E-Commerce Integrations"})]})]}),(0,D.jsx)(It.A,{label:"Single pixel tracking for",alt:e=>`Forward universal pixel events to ${e} from LinkClicks`})]}),(0,D.jsx)("div",{className:"cs-hero__scroll-hint",children:(0,D.jsx)("i",{className:"feather icon-chevron-down"})})]}),(0,D.jsxs)("div",{className:"cs-features conn-features",children:[(0,D.jsxs)("div",{className:"cs-feat-row",children:[(0,D.jsx)("div",{className:"cs-feat-row__art",children:(0,D.jsxs)("div",{className:"conn-art conn-art--pixel",children:[(0,D.jsx)("div",{className:"conn-art__glow"}),(0,D.jsx)("div",{className:"conn-art__hub",children:(0,D.jsx)("i",{className:"feather icon-activity"})}),(0,D.jsx)("div",{className:"conn-art__grid",children:["Meta","Google","TikTok","Pinterest","Snapchat","LinkedIn"].map(e=>(0,D.jsxs)("div",{className:"conn-art__platform-chip",children:[(0,D.jsx)("div",{className:"conn-art__platform-dot"}),(0,D.jsx)("span",{children:e})]},e))}),(0,D.jsx)("div",{className:"conn-art__pulse"}),(0,D.jsx)("div",{className:"conn-art__pulse conn-art__pulse--2"})]})}),(0,D.jsxs)("div",{className:"cs-feat-row__copy",children:[(0,D.jsxs)("p",{className:"cs-feat-row__kicker",children:[(0,D.jsx)("i",{className:"feather icon-activity"}),"Universal Pixel"]}),(0,D.jsx)("h2",{className:"cs-feat-row__headline",children:"One install. Tracks everything."}),(0,D.jsx)("p",{className:"cs-feat-row__sub",children:"Our universal pixel replaces the mess of installing separate Meta, Google, TikTok, Pinterest, Snapchat, and LinkedIn pixels. Install it once and it automatically forwards events to every connected ad platform simultaneously \u2014 ensuring consistent, accurate attribution no matter where your ads run."}),(0,D.jsxs)("ul",{className:"conn-feat-list",children:[(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}),"Single pixel, all platforms"]}),(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}),"No duplicate page-load overhead"]}),(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}),"Unified event schema across platforms"]})]}),(0,D.jsx)("button",{type:"button",className:"cs-feat-row__cta btn btn-primary",onClick:e,children:"Install the Pixel"})]})]}),(0,D.jsxs)("div",{className:"cs-feat-row cs-feat-row--flip",children:[(0,D.jsx)("div",{className:"cs-feat-row__art",children:(0,D.jsxs)("div",{className:"conn-art conn-art--capi",children:[(0,D.jsxs)("div",{className:"conn-art__gate-head",children:[(0,D.jsx)("i",{className:"feather icon-server"}),(0,D.jsx)("span",{children:"Server-side forwarding"})]}),(0,D.jsxs)("div",{className:"conn-art__node",children:[(0,D.jsx)("i",{className:"feather icon-monitor"}),(0,D.jsx)("span",{children:"Visitor converts on your site"})]}),(0,D.jsx)("div",{className:"conn-art__flow-down",children:(0,D.jsx)("i",{className:"feather icon-arrow-down"})}),(0,D.jsxs)("div",{className:"conn-art__node conn-art__node--server",children:[(0,D.jsx)("i",{className:"feather icon-server"}),(0,D.jsx)("span",{children:"LinkClicks servers"})]}),(0,D.jsx)("div",{className:"conn-art__flow-down",children:(0,D.jsx)("i",{className:"feather icon-arrow-down"})}),(0,D.jsx)("div",{className:"conn-art__api-grid",children:["Meta CAPI","Google Ads","TikTok Events","Pinterest","Snapchat","LinkedIn"].map(e=>(0,D.jsx)("div",{className:"conn-art__api-chip",children:e},e))})]})}),(0,D.jsxs)("div",{className:"cs-feat-row__copy",children:[(0,D.jsxs)("p",{className:"cs-feat-row__kicker",children:[(0,D.jsx)("i",{className:"feather icon-server"}),"Server-Side Conversions"]}),(0,D.jsx)("h2",{className:"cs-feat-row__headline",children:"Sent from our servers. Not the browser."}),(0,D.jsx)("p",{className:"cs-feat-row__sub",children:"The browser is the weakest link in measurement. Ad blockers, cookie limits and privacy defaults quietly drop conversion events before they ever reach an ad platform. LinkClicks forwards server-to-server instead \u2014 straight into Meta's Conversions API, Google Ads, TikTok Events API, Pinterest, Snapchat and LinkedIn \u2014 so the sale still registers when the browser call never made it."}),(0,D.jsxs)("ul",{className:"conn-feat-list",children:[(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}
1),"All six platforms' conversion APIs, from one pixel"]}),(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}),"Email and phone sent only as SHA-256 hashes, never plaintext"]}),(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}),"A shared event ID so Meta counts a conversion once, not twice"]})]}),(0,D.jsx)("button",{type:"button",className:"cs-feat-row__cta btn btn-primary",onClick:e,children:"Set Up Forwarding"})]})]}),(0,D.jsxs)("div",{className:"cs-feat-row",children:[(0,D.jsx)("div",{className:"cs-feat-row__art",children:(0,D.jsxs)("div",{className:"conn-art conn-art--clean",children:[(0,D.jsxs)("div",{className:"conn-art__gate-head",children:[(0,D.jsx)("i",{className:"feather icon-filter"}),(0,D.jsx)("span",{children:"Forwarding Quality"})]}),[{rule:"Bot & crawler traffic",state:"Always on",mod:"locked"},{rule:"Our own uptime monitors",state:"Always on",mod:"locked"},{rule:"Suspicious traffic",state:"Blocked",mod:"block"},{rule:"Hijacked ad credit",state:"Blocked",mod:"block"},{rule:"Impossible timestamps",state:"Blocked",mod:"block"},{rule:"Hidden or unfocused tab",state:"Watching",mod:"watch"}].map(e=>(0,D.jsxs)("div",{className:"conn-art__rule",children:[(0,D.jsx)("span",{className:"conn-art__rule-label",children:e.rule}),(0,D.jsx)("span",{className:`conn-art__rule-badge conn-art__rule-badge--${e.mod}`,children:e.state})]},e.rule))]})}),(0,D.jsxs)("div",{className:"cs-feat-row__copy",children:[(0,D.jsxs)("p",{className:"cs-feat-row__kicker",children:[(0,D.jsx)("i",{className:"feather icon-filter"}),"Conversion Cleaning"]}),(0,D.jsx)("h2",{className:"cs-feat-row__headline",children:"Bad traffic never reaches your ad platforms."}),(0,D.jsx)("p",{className:"cs-feat-row__sub",children:"Most tools filter bots out of your reports and forward them to the ad platforms anyway. We stop them before they leave. Bot and crawler traffic, our own uptime monitors, and conversions whose ad credit looks hijacked are held at the gate \u2014 because a bidder optimises toward whatever you tell it converted, and a fake conversion teaches it to go and buy more of the same."}),(0,D.jsxs)("ul",{className:"conn-feat-list",children:[(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}),"Bots and crawlers blocked \u2014 a rule that cannot be switched off"]}),(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}),"Two independent bot checks, plus hijacked-credit detection"]}),(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}),"Set every other rule to Block, Watch or Off, per pixel"]})]}),(0,D.jsx)("button",{type:"button",className:"cs-feat-row__cta btn btn-primary",onClick:e,children:"See Forwarding Quality"})]})]}),(0,D.jsxs)("div",{className:"cs-feat-row cs-feat-row--flip",children:[(0,D.jsx)("div",{className:"cs-feat-row__art",children:(0,D.jsx)("div",{className:"conn-art conn-art--dashboard",children:(0,D.jsxs)("div",{className:"conn-art__screen",children:[(0,D.jsx)("div",{className:"conn-art__bar-row",children:[60,85,45,72,90,55,78].map((e,s)=>(0,D.jsx)("div",{className:"conn-art__bar",style:{height:`${e}%`}},s))}),(0,D.jsx)("div",{className:"conn-art__stat-row",children:["ROAS","CPC","CTR","Conv."].map(e=>(0,D.jsxs)("div",{className:"conn-art__stat",children:[(0,D.jsx)("span",{className:"conn-art__stat-label",children:e}),(0,D.jsx)("span",{className:"conn-art__stat-val"})]},e))})]})})}),(0,D.jsxs)("div",{className:"cs-feat-row__copy",children:[(0,D.jsxs)("p",{className:"cs-feat-row__kicker",children:[(0,D.jsx)("i",{className:"feather icon-wifi"}),"Ad Platform Connections"]}),(0,D.jsx)("h2",{className:"cs-feat-row__headline",children:"Six platforms. One dashboard."}),(0,D.jsx)("p",{className:"cs-feat-row__sub",children:"Connect Meta, Google, TikTok, Pinterest, Snapchat, and LinkedIn in minutes. We pull spend, impression, click, and conversion data into a single consolidated view \u2014 then layer in your own pixel events and sales data to calculate true ROAS across every channel, automatically."}),(0,D.jsxs)("ul",{className:"conn-feat-list",children:[(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}),"Amalgamated cross-platform reporting"]}),(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}),"Connected to your event & sales data"]}),(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}
1),"True ROAS, not platform-siloed numbers"]})]}),(0,D.jsx)("button",{type:"button",className:"cs-feat-row__cta btn btn-primary",onClick:e,children:"Connect Your Platforms"})]})]}),(0,D.jsxs)("div",{className:"cs-feat-row",children:[(0,D.jsx)("div",{className:"cs-feat-row__art",children:(0,D.jsxs)("div",{className:"conn-art conn-art--growth",children:[(0,D.jsx)("div",{className:"conn-art__line-chart",children:(0,D.jsxs)("svg",{viewBox:"0 0 200 100",preserveAspectRatio:"none","aria-hidden":"true",children:[(0,D.jsx)("defs",{children:(0,D.jsxs)("linearGradient",{id:"conn-grad",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,D.jsx)("stop",{offset:"0%",stopColor:"#7c3aed",stopOpacity:"0.4"}),(0,D.jsx)("stop",{offset:"100%",stopColor:"#7c3aed",stopOpacity:"0"})]})}),(0,D.jsx)("path",{d:"M0 90 C30 85 40 70 70 55 S120 25 200 10",stroke:"#7c3aed",strokeWidth:"2.5",fill:"none"}),(0,D.jsx)("path",{d:"M0 90 C30 85 40 70 70 55 S120 25 200 10 L200 100 L0 100 Z",fill:"url(#conn-grad)"})]})}),(0,D.jsxs)("div",{className:"conn-art__milestones",children:[(0,D.jsx)("span",{className:"conn-art__milestone",children:"1 platform"}),(0,D.jsx)("span",{className:"conn-art__milestone conn-art__milestone--mid",children:"3 platforms"}),(0,D.jsx)("span",{className:"conn-art__milestone conn-art__milestone--end",children:"All 6 + pixel"})]})]})}),(0,D.jsxs)("div",{className:"cs-feat-row__copy",children:[(0,D.jsxs)("p",{className:"cs-feat-row__kicker",children:[(0,D.jsx)("i",{className:"feather icon-trending-up"}),"Built to Scale"]}),(0,D.jsx)("h2",{className:"cs-feat-row__headline",children:"Grows with your ad strategy."}),(0,D.jsx)("p",{className:"cs-feat-row__sub",children:"Start with a single platform and add more as your campaigns expand. Your universal pixel keeps working across every new platform you connect \u2014 nothing to reinstall or reconfigure. Whether you run on one channel today or all six tomorrow, attribution stays consistent and reporting stays unified."}),(0,D.jsxs)("ul",{className:"conn-feat-list",children:[(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}),"Add platforms without touching your pixel"]}),(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}),"Historical data stays intact as you scale"]}),(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}),"No extra setup per platform"]})]}),(0,D.jsx)("button",{type:"button",className:"cs-feat-row__cta btn btn-primary",onClick:e,children:"Start for Free"})]})]}),(0,D.jsxs)("div",{className:"cs-feat-row cs-feat-row--flip",children:[(0,D.jsx)("div",{className:"cs-feat-row__art",children:(0,D.jsxs)("div",{className:"conn-art conn-art--ecommerce",children:[(0,D.jsxs)("div",{className:"conn-art__store-cards",children:[(0,D.jsxs)("div",{className:"conn-art__store-card conn-art__store-card--shopify",children:[(0,D.jsx)("i",{className:"feather icon-shopping-cart"}),(0,D.jsx)("span",{children:"Shopify"})]}),(0,D.jsxs)("div",{className:"conn-art__store-card conn-art__store-card--wix",children:[(0,D.jsx)("i",{className:"feather icon-layout"}),(0,D.jsx)("span",{children:"Wix"})]}),(0,D.jsxs)("div",{className:"conn-art__store-card conn-art__store-card--woo",children:[(0,D.jsx)("i",{className:"feather icon-shopping-cart"}),(0,D.jsx)("span",{children:"WooCommerce"})]}),(0,D.jsxs)("div",{className:"conn-art__store-card conn-art__store-card--more",children:[(0,D.jsx)("i",{className:"feather icon-plus"}),(0,D.jsx)("span",{children:"More soon"})]})]}),(0,D.jsxs)("div",{className:"conn-art__flow-arrow",children:[(0,D.jsx)("i",{className:"feather icon-arrow-right"}),(0,D.jsx)("span",{children:"Sales data"}),(0,D.jsx)("i",{className:"feather icon-arrow-right"}),(0,D.jsx)("span",{children:"ROAS"})]})]})}),(0,D.jsxs)("div",{className:"cs-feat-row__copy",children:[(0,D.jsxs)("p",{className:"cs-feat-row__kicker",children:[(0,D.jsx)("i",{className:"feather icon-shopping-cart"}),"E-Commerce Integrations"]}),(0,D.jsx)("h2",{className:"cs-feat-row__headline",children:"Connect your store. Close the loop."}),(0,D.jsx)("p",{className:"cs-feat-row__sub",children:"Integrate Shopify, Wix, or WooCommerce to send real order and revenue data directly into your attribution pipeline. No manual CSV imports or guessing which ad drove which sale. Your actual revenue connects to your pixel events so every platform sees the same ground truth and you get real ROAS without the spreadsheets."}),(0,D.jsxs)("ul",{className:"conn-feat-list",children:[(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}),"Shopify, Wix & WooCommerce supported"]}),(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}),"Order & revenue data feeds attribution"]}),(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}),"More integrations coming soon"]})]}),(0,D.jsx)("button",{type:"button",className:"cs-feat-row__cta btn btn-primary",onClick:e,children:"Connect Your Store"})]})]}),(0,D.jsxs)("div",{className:"cs-feat-row",children:[(0,D.jsx)("div",{className:"cs-feat-row__art",children:(0,D.jsx)("div",{className:"conn-art conn-art--dashboard",children:(0,D.jsxs)("div",{className:"conn-art__screen",children:[(0,D.jsx)("div",{className:"conn-art__stat-row",children:["Visitors","Sources","Bots blocked","Uptime"].map(e=>(0,D.jsxs)("div",{className:"conn-art__stat",children:[(0,D.jsx)("span",{className:"conn-art__stat-label",children:e}),(0,D.jsx)("span",{className:"conn-art__stat-val"})]},e))}),(0,D.jsx)("div",{className:"conn-art__bar-row",children:[70,45,88,52,64,39,81].map((e,s)=>(0,D.jsx)("div",{className:"conn-art__bar",style:{height:`${e}%`}},s))})]})})}),(0,D.jsxs)("div",{className:"cs-feat-row__copy",children:[(0,D.jsxs)("p",{className:"cs-feat-row__kicker",children:[(0,D.jsx)("i",{className:"feather icon-bar-chart-2"}),"No Ads Required"]}),(0,D.jsx)("h2",{className:"cs-feat-row__headline",children:"You don't need to be running ads to use it."}),(0,D.jsx)("p",{className:"cs-feat-row__sub",children:"The universal pixel is worth installing on its own. It gives you website analytics \u2014 visitors, traffic sources, referrers, locations, landing pages, and the full funnel from page view to purchase \u2014 plus bot detection, ad-fraud signals, and traffic-quality reporting that tells you how much of your traffic is actually human."}),(0,D.jsx)("p",{className:"cs-feat-row__sub",children:"Install it now and the data starts accumulating. When you do start advertising, the attribution is already in place and you have a baseline to measure against, instead of starting from zero on day one of your first campaign."}),(0,D.jsxs)("ul",{className:"conn-feat-list",children:[(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}
1),"Full website analytics with no ad account needed"]}),(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}),"Bot & ad-fraud detection on every event"]}),(0,D.jsxs)("li",{children:[(0,D.jsx)("i",{className:"feather icon-check"}),"Historical baseline ready before your first campaign"]})]}),(0,D.jsx)("button",{type:"button",className:"cs-feat-row__cta btn btn-primary",onClick:e,children:"Install the Universal Pixel"})]})]})]}),(0,D.jsx)(Dt.A,{eyebrow:"Universal pixel FAQ",headline:"Questions about pixels and attribution",items:Wt})]})]})},Ut="connections-active-tab-v2",Ht="connections-pixel-tab-v2",Kt="connections-selected-pixel-key-v2",qt="createPixel",Gt="connections-side-rail-state-v1",Vt=m.J;let Qt=!1;const Yt=[{key:"advertising",label:"Advertising",icon:"feather icon-wifi"},{key:"ecommerce",label:"E-Commerce",icon:"feather icon-shopping-bag"},{key:"websites",label:"Websites",icon:"feather icon-globe",betaFlag:"beta_connections_websites"},{key:"pixel",label:"Universal Pixel",icon:"feather icon-activity"}],Xt=[{key:"shopify",label:"Shopify",icon:"feather icon-shopping-bag"},{key:"wix",label:"Wix",icon:"feather icon-layout",devOnly:!0},{key:"woocommerce",label:"WooCommerce",icon:"feather icon-shopping-cart",devOnly:!0}],Jt=["overview",...Xt.map(e=>e.key),"products","customers"],Zt=[{key:"code",label:"Code",icon:"fas fa-code"},{key:"events",label:"Events",icon:"feather icon-target"},{key:"test-pixel",label:"Pixel Health",icon:"feather icon-activity"},{key:"platforms",label:"Platforms",icon:"feather icon-share-2"},{key:"quality",label:"Forwarding Quality",icon:"feather icon-filter"},{key:"domains",label:"Domains",icon:"feather icon-globe"},{key:"changelog",label:"Change Log",icon:"feather icon-clock"}],ea=["Creating your Universal Pixel\u2026","Configuring visitor tracking\u2026","Enabling conversion events\u2026","Tracking leads & form fills\u2026","Connecting revenue signals\u2026","Almost ready\u2026"],sa=e=>{let{activeTab:s,activeSubTab:t,isDarkMode:a}=e;const n=a?"text-white-50":"text-muted";if("advertising"===s)return(0,D.jsxs)("div",{style:{padding:"4px 0"},children:[(0,D.jsx)("p",{className:"fw-semibold mb-2",style:{fontSize:"0.88rem"},children:"Connecting Ad Platforms"}),(0,D.jsx)("p",{className:`small ${n} mb-2`,children:"Each platform uses OAuth, you'll be redirected to authorize access, then returned here."}),(0,D.jsx)("p",{className:`small ${n} mb-2`,children:"After connecting, your first import may take a few minutes depending on account size."}),(0,D.jsx)("p",{className:`small ${n}`,children:"Campaign performance data syncs automatically on a regular schedule."})]});if("ecommerce"===s)return(0,D.jsxs)("div",{style:{padding:"4px 0"},children:[(0,D.jsx)("p",{className:"fw-semibold mb-2",style:{fontSize:"0.88rem"},children:"E-Commerce Integrations"}),(0,D.jsx)("p",{className:`small ${n} mb-2`,children:"Connect your store to track purchases, add-to-carts, and checkout events in Insights."}),(0,D.jsx)("p",{className:`small ${n}`,children:"Supported platforms: Shopify, WooCommerce, Wix. More coming soon."})]});if("websites"===s)return(0,D.jsxs)("div",{style:{padding:"4px 0"},children:[(0,D.jsx)("p",{className:"fw-semibold mb-2",style:{fontSize:"0.88rem"},children:"WordPress Sites"}),(0,D.jsx)("p",{className:`small ${n} mb-2`,children:"Install the LinkClicks plugin on your WordPress site, then connect it here in one click \u2014 no code to copy."}),(0,D.jsx)("p",{className:`small ${n}`,children:"Each connected site runs the Universal Pixel and reports a health signal."})]});if("pixel"===s){if("code"===t)return(0,D.jsx)("div",{className:`small ${n}`,children:"Install the base Universal Pixel snippet on every page."});if("events"===t)return(0,D.jsx)("div",{className:`small ${n}`,children:"Add event snippets for purchase, lead, add-to-cart, and custom events."});if("test-pixel"===t)return(0,D.jsx)("div",{className:`small ${n}`,children:"Validate your installation and inspect live pixel health signals."});if("platforms"===t)return(0,D.jsx)("div",{className:`small ${n}`,children:"Map the Universal Pixel to connected ad platforms for forwarding."});if("changelog"===t)return(0,D.jsx)("div",{className:`small ${n}`,children:"Review the history of pixel changes, connections, and updates."})}return null};sa.defaultProps={isDarkMode:!1};const ta=()=>{var e;const s=(0,n.wA)(),[t,m]=(0,i.ok)(),{user:A,isLoggedIn:P}=(0,a.useContext)(l.A),z=null===A||void 0===A?void 0:A.access_context,T=(null===z||void 0===z?void 0:z.actor_feature_flags)||{},F=S({isDev:false,accessContext:z}),E=(0,a.useMemo)(()=>Yt.filter(e=>!e.betaFlag||F||T[e.betaFlag]),[F,T]),L=(null===(e=E[0])||void 0===e?void 0:e.key)||"advertising",[$,I]=(0,a.useState)(()=>{try{const e=localStorage.getItem(Ut);if(e&&E.some(s=>s.key===e))return e}catch{}return L}),[R,B]=(0,a.useState)(()=>{try{return localStorage.getItem("connections-ecommerce-tab-v1")||"overview"}catch{return"overview"}}),[W,O]=(0,a.useState)(()=>(()=>{try{const e=JSON.parse(localStorage.getItem(Gt)||"{}");return!e||"object"!==typeof e||Array.isArray(e)?{}:e}catch{return{}}})());(0,a.useEffect)(()=>{try{localStorage.setItem(Gt,JSON.stringify(W))}catch{}},[W]),(0,o.A)("connections",$);
1const[U,H]=(0,a.useState)(()=>{try{const e=localStorage.getItem(Ht);return Zt.some(s=>s.key===e)?e:"code"}catch{return"code"}}),[K,q]=(0,a.useState)(()=>{try{return localStorage.getItem(Kt)||null}catch{return null}}),[G,V]=(0,a.useState)(null),[Q,Y]=(0,a.useState)(null),[X,J]=(0,a.useState)(!1),[Z,ee]=(0,a.useState)(null),[se,te]=(0,a.useState)(0),ae=(0,a.useRef)(!1),[ie,le]=(0,a.useState)({show:!1,name:"",submitting:!1,error:null}),[re,oe]=(0,a.useState)(null),[ce,de]=(0,a.useState)(!1),{pixels:me,loading:he,error:ue,initialized:xe,fetchPixels:pe,forceRefreshPixels:ve,updatePixelNameOptimistic:fe}=(0,g.xE)(),{events:ge}=(0,g.bF)(),be=(0,a.useMemo)(()=>(me||[]).filter(e=>"website"===(e.kind||"website")),[me]),je=be.length,{atLimit:ye,limit:Ne}=(0,b.A)("pixels",je),_e=(0,n.d4)(h.Tx),we="dark"===(0,j.j1)(),ke="1"===t.get(qt),[Se,Ce]=(0,a.useState)(()=>"undefined"!==typeof window&&window.innerWidth<992),[Ae]=(0,a.useState)(!0),[Pe,ze]=(0,a.useState)("60vh"),Te=(0,a.useCallback)(()=>{if("undefined"===typeof window)return;if(!Ye.current)return;const e=Ye.current.getBoundingClientRect(),s=window.innerHeight-e.top;s>80&&ze(`${s}px`)},[]),{connections:Fe,connectedProviders:Ee,loaded:Le,reload:De}=function(){const[e,s]=(0,a.useState)([]),[t,n]=(0,a.useState)(!0),[i,l]=(0,a.useState)(!1),r=(0,a.useCallback)(()=>(n(!0),w.xo.getConnections({includeInactive:!0}).then(e=>{var t,a,n;const i=null!==(t=null!==(a=null===e||void 0===e||null===(n=e.data)||void 0===n?void 0:n.connections)&&void 0!==a?a:null===e||void 0===e?void 0:e.data)&&void 0!==t?t:[];s(Array.isArray(i)?i:[])}).catch(()=>s([])).finally(()=>{n(!1),l(!0)})),[]);(0,a.useEffect)(()=>{r()},[r]);const o=(0,a.useMemo)(()=>new Set(e.filter(k).map(e=>e.provider).filter(Boolean)),[e]);return{connections:e,connectedProviders:o,loading:t,loaded:i,reload:r}}(),$e=(0,a.useMemo)(()=>{const e=((e,s)=>{let{connectedProviders:t,betaPass:a}=s;return e.filter(e=>t.has(e.key)&&(!e.devOnly||a))})(Xt,{connectedProviders:Ee,betaPass:F});return e.length?[{key:"overview",label:"Overview",icon:"feather icon-eye"},...e,{key:"products",label:"Products",icon:"feather icon-package"},{key:"customers",label:"Customers",icon:"feather icon-users"}]:[{key:"overview",label:"Overview",icon:"feather icon-eye"}]},[Ee,F]),Ie=Ee.size>0,[Re,Me]=(0,a.useState)({show:!1,provider:null}),{atLimit:Be,limit:We}=function(e){var s;const{user:t}=(0,a.useContext)(l.A),n=null===t||void 0===t||null===(s=t.access_context)||void 0===s?void 0:s.workspace;return(0,a.useMemo)(()=>{const s=(e||[]).filter(k).length,t=(0,_.RL)((null===n||void 0===n?void 0:n.plan)||"free","ecommerce_stores",null===n||void 0===n?void 0:n.plan_limits);return{used:s,limit:t,atLimit:null!=t&&s>=t}},[e,n])}(Fe),Oe=(0,a.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;Be?(0,C.dX)({reason:"ecommerce_store_limit",limit:We}):Me({show:!0,provider:e})},[Be,We]),Ue=(0,a.useCallback)(e=>{Promise.resolve(De()).then(()=>{e&&B(e)}),(0,N.LG)("Store connected! Importing your recent orders now.")},[De]),He=(0,a.useMemo)(()=>"ecommerce"===$?$e:"pixel"===$&&be.length>0?Zt:[],[$,be,$e]),Ke="ecommerce"===$?R:"pixel"===$?U:null,[qe,Ge]=(0,a.useState)([]),[Ve,Qe]=(0,a.useState)(()=>{if("undefined"===typeof window||"undefined"===typeof document)return"#e5e6eb";try{return window.getComputedStyle(document.body).backgroundColor}catch{return"#e5e6eb"}}),Ye=(0,a.useRef)(null),Xe=(0,a.useRef)(null),Ze=(0,a.useRef)(null);(0,a.useEffect)(()=>{if("undefined"===typeof document)return;const e=document.body,s=()=>{try{Qe(window.getComputedStyle(e).backgroundColor)}catch{Qe(e.classList.contains("datta-dark")?"#0f1012":"#e5e6eb")}};s();const t=new MutationObserver(e=>{for(const t of e)"class"===t.attributeName&&s()});return t.observe(e,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]),(0,a.useEffect)(()=>{if("undefined"===typeof window)return;const e=()=>Ce(window.innerWidth<992);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),(0,a.useEffect)(()=>{if("undefined"===typeof window)return;const e=()=>window.requestAnimationFrame(Te);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[Se,Te]),(0,a.useLayoutEffect)(()=>
1{if("undefined"===typeof window)return;const e=window.requestAnimationFrame(Te);return()=>window.cancelAnimationFrame(e)},[$,U,R,X,ke,he,null===me||void 0===me?void 0:me.length,Te]),(0,a.useLayoutEffect)(()=>{if("undefined"===typeof window)return;const e=()=>{const e=Xe.current;if(!e)return;const s=Array.from(e.querySelectorAll('[data-measure-tab="true"]'));if(!s.length)return void Ge(He.length?[He]:[]);const t=s.map(e=>Math.round(e.getBoundingClientRect().top));Ge((0,d.t)(He,t,Ke))};e();const s=()=>window.requestAnimationFrame(e);return window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[Ke,Se,He]),(0,a.useEffect)(()=>{if("undefined"===typeof window)return;if(Qt)return;const e=window.setTimeout(()=>{Qt=!0},Vt);return()=>window.clearTimeout(e)},[]),(0,a.useEffect)(()=>{E.some(e=>e.key===$)||I(L)},[$,L,E]),(0,a.useEffect)(()=>{"ecommerce"===$&&Le&&!$e.some(e=>e.key===R)&&B("overview"),"pixel"!==$||Zt.some(e=>e.key===U)||H("code")},[$,R,U,$e,Le]),(0,a.useEffect)(()=>{const e=t.get("tab");if(!e)return;if(E.some(s=>s.key===e)?I(e):Jt.includes(e)?(I("ecommerce"),B(e)):Zt.some(s=>s.key===e)&&(I("pixel"),H(e)),"1"===t.get("connected")){const e=t.get("store");(0,N.LG)(e?`${e} connected! Importing your recent orders now \u2014 they'll appear in the events list shortly.`:"Store connected! Importing your recent orders now.")}const s=new URLSearchParams(t);s.delete("tab"),s.delete("connected"),s.delete("store"),m(s,{replace:!0})},[t,m,E]),(0,a.useEffect)(()=>{if("undefined"===typeof window)return;if(!("pixel"===$&&xe&&!be.length&&"1"===t.get(qt))||ae.current||X)return;ae.current=!0;const e=new URLSearchParams(t);e.delete(qt),m(e,{replace:!0}),ss()},[$,be,X,t,m,xe]),(0,a.useEffect)(()=>{P&&"function"===typeof pe&&pe()},[P]),(0,a.useEffect)(()=>{P&&"pixel"===$&&(xe||he||ue||"function"===typeof pe&&pe())},[P,$,xe,he,ue,pe]),(0,a.useEffect)(()=>{be.length&&(K&&be.some(e=>e.pixel_key===K)||q(be[0].pixel_key))},[be,K]),(0,a.useEffect)(()=>{oe(null)},[K]);const es=async e=>{var s;let t=null;try{var a,n;const s=await(0,y.Ku)("/conversions/pixels/",{name:e,description:"",website:""});t=(null===(a=s.data)||void 0===a?void 0:a.pixel)||(null===(n=s.data)||void 0===n?void 0:n.data)||s.data||null}catch(u){var i,l,r;if(null!==u&&void 0!==u&&u.isPlanLimit||null!==u&&void 0!==u&&u.isTrialPaywall){var o;if(null!==u&&void 0!==u&&u.isPlanLimit&&(null===(o=u.planLimitData)||void 0===o||!o.upgrade_plan))throw u;return null}const e=null===u||void 0===u||null===(i=u.response)||void 0===i?void 0:i.status,s=(null===u||void 0===u||null===(l=u.response)||void 0===l||null===(r=l.data)||void 0===r?void 0:r.detail)||"";if(400!==e||!String(s).includes("already has a Universal Pixel"))throw u;{var c,d;const e=await(0,y.qQ)("/conversions/pixels/");t=(Array.isArray(e.data)?e.data[0]:null===(c=e.data)||void 0===c||null===(d=c.results)||void 0===d?void 0:d[0])||null}}try{var m,h;const e=await(0,y.qQ)("/conversions/pixels/"),s=Array.isArray(e.data)?e.data:(null===(m=e.data)||void 0===m?void 0:m.results)||[];t=null!==(h=t)&&void 0!==h&&h.pixel_key&&s.find(e=>String(null===e||void 0===e?void 0:e.pixel_key)===String(t.pixel_key))||t}catch{}return"function"===typeof ve&&await ve(),null!==(s=t)&&void 0!==s&&s.pixel_key&&(q(t.pixel_key),I("pixel"),H("code")),t},ss=async()=>{if(X)return;J(!0),ee(null);const e=Date.now();try{const s=await es("LinkClicks Universal Pixel");if(!s)return;const t=Date.now()-e;t<8400&&await new Promise(e=>window.setTimeout(e,8400-t)),s&&!s.pixel_key&&ee("Pixel was not created. Please try again.")}catch(a){var s,t;console.error("Failed to create universal pixel:",a),ee((null===a||void 0===a?void 0:a.isPlanLimit)&&a.message||(null===a||void 0===a||null===(s=a.response)||void 0===s||null===(t=s.data)||void 0===t?void 0:t.detail)||"Failed to create your Universal Pixel. Please try again.")}finally{J(!1)}},ts=async()=>{const e=(ie.name||"").trim();if(e){le(e=>({...e,submitting:!0,error:null}));try{const s=await es(e);le({show:!1,name:"",submitting:!1,error:null}),null!==s&&void 0!==s&&s.pixel_key&&(0,N.LG)("Pixel created")}catch(s){le(e=>{var t,a;return{...e,submitting:!1,error:(null===s||void 0===s?void 0:s.isPlanLimit)&&s.message||(null===s||void 0===s||null===(t=s.response)||void 0===t||null===(a=t.data)||void 0===a?void 0:a.detail)||"Failed to create pixel. Please try again."}})}}else le(e=>({...e,error:"Please enter a name."}))},as=async()=>{const e=(re||"").trim(),s=be.find(e=>e.pixel_key===K);if(s&&e&&e!==s.name){de(!0);try{await fe(K,e,s.name),oe(null)}catch(t){console.error("Failed to rename pixel:",t),(0,N.UW)("Could not rename the pixel. Please try again.")}finally{de(!1)}}else oe(null)};(0,a.useEffect)(()=>
1{if(!X)return void te(0);const e=window.setInterval(()=>te(e=>(e+1)%ea.length),1400);return()=>window.clearInterval(e)},[X]),(0,a.useEffect)(()=>{try{K?localStorage.setItem(Kt,K):localStorage.removeItem(Kt)}catch{}},[K]),(0,a.useEffect)(()=>{try{localStorage.setItem(Ut,$)}catch{}},[$]),(0,a.useEffect)(()=>{try{localStorage.setItem(Ht,U)}catch{}},[U]),(0,a.useEffect)(()=>{try{localStorage.setItem("connections-ecommerce-tab-v1",R)}catch{}},[R]),(0,a.useEffect)(()=>{"pixel"===$&&"platforms"===U&&s((0,u.pF)(Q))},[$,U,Q,s]);const is=qe.length?qe:[He],ls=is.slice(0,-1),os=is[is.length-1]||[],cs=be.length>0,ds=be.find(e=>e.pixel_key===K)||null,ms=()=>(0,D.jsxs)("div",{style:{minHeight:"calc(100vh - 180px)",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:[(0,D.jsx)("style",{children:"\n        @keyframes pxRing { 0% { transform: scale(0.65); opacity: 0.72; } 100% { transform: scale(2.55); opacity: 0; } }\n        @keyframes pxPulse { 0%,100% { transform: scale(1); opacity: 0.88; } 50% { transform: scale(1.09); opacity: 1; } }\n        @keyframes pxShimmer { 0% { background-position: -300% 0; } 100% { background-position: 300% 0; } }\n        @keyframes pxFadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }\n        @keyframes pxDot { 0%,80%,100% { transform: scale(0.55); opacity: 0.25; } 40% { transform: scale(1); opacity: 1; } }\n        @keyframes pxOrbit { from { transform: rotate(0deg) translateX(56px) rotate(0deg); } to { transform: rotate(360deg) translateX(56px) rotate(-360deg); } }\n        @keyframes pxStepFade { 0% { opacity: 0; transform: translateY(7px); } 15% { opacity: 1; transform: translateY(0); } 80% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-7px); } }\n        @keyframes pxProgress { 0% { width: 6%; } 25% { width: 42%; } 55% { width: 68%; } 80% { width: 86%; } 100% { width: 96%; } }\n      "}),(0,D.jsxs)("div",{style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:112,height:112,marginBottom:36},children:[[0,1,2].map(e=>(0,D.jsx)("div",{style:{position:"absolute",inset:0,borderRadius:"50%",border:"1.5px solid "+(we?`rgba(34,197,94,${.58-.14*e})`:`rgba(25,135,84,${.52-.13*e})`),animation:"pxRing 2.2s ease-out infinite",animationDelay:.73*e+"s"}},e)),[{icon:"icon-users",color:"#4285f4"},{icon:"icon-bar-chart-2",color:"#8b5cf6"},{icon:"icon-shopping-cart",color:"#f97316"},{icon:"icon-dollar-sign",color:"#22c55e"}].map((e,s)=>{let{icon:t,color:a}=e;return(0,D.jsx)("div",{style:{position:"absolute",width:26,height:26,borderRadius:"50%",background:we?"rgba(255,255,255,0.08)":"rgba(255,255,255,0.95)",border:`1.5px solid ${a}66`,boxShadow:`0 0 8px ${a}33`,display:"flex",alignItems:"center",justifyContent:"center",animation:"pxOrbit 6s linear infinite",animationDelay:-1.5*s+"s"},children:(0,D.jsx)("i",{className:`feather ${t}`,style:{fontSize:"0.62rem",color:a}})},s)}),(0,D.jsx)("div",{style:{width:72,height:72,borderRadius:"50%",position:"relative",zIndex:2,background:we?"rgba(34,197,94,0.13)":"rgba(25,135,84,0.09)",border:"1.5px solid "+(we?"rgba(34,197,94,0.38)":"rgba(25,135,84,0.32)"),display:"flex",alignItems:"center",justifyContent:"center",animation:"pxPulse 2.2s ease-in-out infinite",boxShadow:we?"0 0 36px rgba(34,197,94,0.22)":"0 0 36px rgba(25,135,84,0.16)"},children:(0,D.jsx)("i",{className:"feather icon-cpu",style:{color:we?"#22c55e":"#198754",fontSize:"1.9rem"}})})]}),(0,D.jsx)("div",{style:{display:"flex",gap:8,marginBottom:28,animation:"pxFadeUp 0.5s ease 0.2s both",flexWrap:"wrap",justifyContent:"center",maxWidth:560},children:[{w:108,h:66,label:"Visitors"},{w:88,h:66,label:"Events"},{w:138,h:66,label:"Conversions"},{w:96,h:66,label:"Revenue"},{w:82,h:66,label:"Leads"}].map((e,s)=>(0,D.jsxs)("div",{style:{textAlign:"center"},children:[(0,D.jsx)("div",{style:{width:e.w,height:e.h,borderRadius:10,background:we?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.04)",border:"1px solid "+(we?"rgba(34,197,94,0.1)":"rgba(25,135,84,0.1)"),overflow:"hidden",position:"relative",marginBottom:5},children:(0,D.jsx)("div",{style:{position:"absolute",inset:0,background:`linear-gradient(90deg, transparent 0%, ${we?"rgba(34,197,94,0.09)":"rgba(255,255,255,0.75)"} 50%, transparent 100%)`,backgroundSize:"300% 100%",animation:"pxShimmer 1.9s ease-in-out infinite",animationDelay:.2*s+"s"}})}),(0,D.jsx)("div",{style:{fontSize:"0.63rem",color:we?"rgba(255,255,255,0.22)":"rgba(0,0,0,0.28)",letterSpacing:"0.05em",textTransform:"uppercase"},children:e.label})]},s))}),(0,D.jsx)("div",{style:{height:26,marginBottom:10,display:"flex",alignItems:"center",justifyContent:"center",minWidth:300},children:(0,D.jsx)("p",{style:{margin:0,fontSize:"0.92rem",fontWeight:500,color:we?"rgba(255,255,255,0.78)":"rgba(0,0,0,0.68)",animation:"pxStepFade 1.4s ease forwards"},children:ea[se]},se)}),(0,D.jsx)("div",{style:{width:224,height:3,borderRadius:2,background:we?"rgba(255,255,255,0.07)":"rgba(0,0,0,0.07)",overflow:"hidden",marginBottom:20},children:(0,D.jsx)("div",{style:{height:"100%",background:we?"#22c55e":"#198754",borderRadius:2,animation:`pxProgress ${1.4*ea.length}s ease-out forwards`}})}),(0,D.jsx)("div",{style:{display:"flex",gap:7,animation:"pxFadeUp 0.5s ease 0.35s both"},children:[0,1,2].map(e=>(0,D.jsx)("div",{style:{width:7,height:7,borderRadius:"50%",background:we?"#22c55e":"#198754",animation:"pxDot 1.3s ease-in-out infinite",animationDelay:.22*e+"s"}},e))})]}),hs=e=>{"ecommerce"!==$?"pixel"===$&&H(e):B(e)},us=e=>{const s=Ke===e.key,t="pixel"===$;return(0,D.jsx)("button",{type:"button",role:"tab","aria-selected":s,onClick:()=>hs(e.key),className:"react-tabs__tab tabs-page__content-tab"+(s?" react-tabs__tab--selected":""),children:(0,D.jsxs)("span",{className:"tab-title-wrapper",style:{gap:"6px",display:"inline-flex",alignItems:"center"},children:[e.icon&&(0,D.jsx)("i",{className:e.icon,style:{fontSize:"0.95rem"}}),(0,D.jsx)("span",{children:e.label}),t&&!s&&"platforms"===e.key&&(Q>0||null===Q&&_e>0)&&(0,D.jsx)("span",{className:"pcoded-badge bg-danger",style:{fontSize:"0.72rem",lineHeight:"1.15",padding:"1px 6px",borderRadius:"4px",color:"#fff"},children:"!"})]})},e.key)};return P?X||ke?(0,D.jsx)("div",{className:"container-fluid tabs-p
1age",style:{"--tabs-page-bg":Ve,"--tabs-content-height":Pe},children:ms()}):(0,D.jsxs)("div",{className:"container-fluid tabs-page",style:{"--tabs-page-bg":Ve,"--tabs-content-height":Pe},children:[(0,D.jsx)("div",{className:"tabs-page__nav-shell d-flex align-items-center justify-content-between gap-3 ps-0 pt-0 pb-3 flex-wrap",children:(0,D.jsx)("div",{className:"tabs-page__nav-scroll d-flex align-items-center gap-1",ref:Ze,children:E.map(e=>{const s=$===e.key;return(0,D.jsxs)("button",{type:"button",onClick:()=>{return s=e.key,void I(s);var s},className:"btn btn-sm tabs-page__nav-button "+(s?"btn-primary":"btn-outline-secondary"),style:{fontWeight:s?"600":"400",gap:Ae?"6px":"0px"},children:[e.icon&&(0,D.jsx)("i",{className:e.icon,style:{fontSize:"0.85rem"}}),Ae&&(0,D.jsx)("span",{children:e.label})]},e.key)})})}),(0,D.jsxs)("div",{className:"tabs-page__content mt-2",ref:Ye,children:[(0,D.jsx)("div",{ref:Xe,"aria-hidden":"true",style:{position:"absolute",visibility:"hidden",pointerEvents:"none",inset:0,height:0,overflow:"hidden"},children:(0,D.jsx)("div",{className:"react-tabs__tab-list tabs-page__tab-list",style:{flexWrap:"wrap",width:"100%"},children:He.map(e=>{const s=Ke===e.key;return(0,D.jsx)("button",{type:"button","data-measure-tab":"true",tabIndex:-1,"aria-hidden":"true",className:"react-tabs__tab tabs-page__content-tab"+(s?" react-tabs__tab--selected":""),children:(0,D.jsxs)("span",{className:"tab-title-wrapper",style:{gap:"6px",display:"inline-flex",alignItems:"center"},children:[e.icon&&(0,D.jsx)("i",{className:e.icon,style:{fontSize:"0.95rem"}}),(0,D.jsx)("span",{children:e.label})]})},e.key)})})}),(0,D.jsxs)("div",{className:"d-flex align-items-end",style:{gap:"6px"},children:[(0,D.jsxs)("div",{className:"custom-tabs mb-0",role:"tablist","aria-label":"Connections content tabs",children:[ls.map((e,s)=>(0,D.jsx)("div",{className:"react-tabs__tab-list tabs-page__tab-list",style:{flexWrap:"nowrap",width:"auto"},children:e.map(us)},`upper-row-${s}`)),(0,D.jsx)("div",{className:"react-tabs__tab-list tabs-page__tab-list",style:{flexWrap:"nowrap",width:"auto"},children:os.map(us)})]}),"ecommerce"===$&&Ie&&(0,D.jsxs)("button",{type:"button",className:"btn btn-sm btn-outline-primary mb-2",style:{whiteSpace:"nowrap"},onClick:()=>Oe(null),children:[(0,D.jsx)("i",{className:"feather icon-plus me-1"}),"Connect Ecommerce Shop"]}),"pixel"===$&&cs&&(0,D.jsxs)(x.A,{className:"mb-2 ms-auto me-3",children:[(0,D.jsxs)(x.A.Toggle,{variant:"outline-secondary",size:"sm",id:"pixel-switcher",style:{maxWidth:260,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",paddingRight:"1.5rem"},children:[(0,D.jsx)("i",{className:"feather icon-activity me-1"}),(null===ds||void 0===ds?void 0:ds.name)||(null===ds||void 0===ds?void 0:ds.pixel_key)||"Select pixel"]}),(0,D.jsxs)(x.A.Menu,{className:"pixel-switcher-menu",align:"end",style:{maxHeight:360,overflowY:"auto"},children:[(0,D.jsxs)(x.A.Item,{onClick:()=>{ye?(0,C.dX)({reason:"pixels",limit:Ne}):le({show:!0,name:`Universal Pixel ${je+1}`,submitting:!1,error:null})},children:[(0,D.jsx)("i",{className:"feather icon-plus me-2"}),"Add New Pixel"]}),(0,D.jsx)(x.A.Divider,{}),be.map(e=>(0,D.jsx)(x.A.Item,{active:e.pixel_key===K,onClick:()=>q(e.pixel_key),children:e.name||e.pixel_key},e.pixel_key))]})]})]}),(0,D.jsxs)("div",{className:"tabs-page__pane tab-pane fade show active",role:"tabpanel",style:{display:"flex"},children:[(0,D.jsxs)("div",{className:"tabs-page__pane-content",style:{paddingRight:"20px"},children:["advertising"===$&&(0,D.jsx)(ne,{isDarkMode:we,onRequestAiOpen:()=>{}}),"ecommerce"===$&&(0,D.jsx)(Je,{activeTab:R,onTabChange:B,onConnect:Oe,onConnectionsChanged:De,connections:Fe,connectionsLoading:!Le,isDarkMode:we}),"websites"===$&&(0,D.jsx)(ns,{isDarkMode:we}),"pixel"===$&&!cs&&(0,D.jsx)("div",{className:"d-flex align-items-center justify-content-center",style:{minHeight:"40vh"},children:he||!xe&&!ue?ms():!xe&&ue?(0,D.jsxs)("div",{className:"text-center",style:{maxWidth:420,width:"100%"},children:[(0,D.jsx)("div",{className:"d-inline-flex align-items-center justify-content-center mb-3",style:{width:56,height:56,borderRadius:"50%",background:we?"rgba(239,68,68,0.12)":"rgba(239,68,68,0.09)"},children:(0,D.jsx)("i",{className:"feather icon-wifi-off",style:{color:"#ef4444",fontSize:"1.5rem"}})}),(0,D.jsx)("h5",{className:"mb-2",children:"Couldn\u2019t load your pixels"}),(0,D.jsx)("p",{className:`small ${we?"text-white-50":"text-muted"}
1 mb-4`,children:"Something went wrong loading your Universal Pixel. This is usually temporary."}),(0,D.jsxs)("button",{type:"button",className:"btn btn-primary",onClick:()=>ve&&ve(),children:[(0,D.jsx)("i",{className:"feather icon-refresh-cw me-2"}),"Retry"]})]}):(0,D.jsxs)("div",{className:"text-center",style:{maxWidth:420,width:"100%"},children:[(0,D.jsx)("div",{className:"d-inline-flex align-items-center justify-content-center mb-3",style:{width:56,height:56,borderRadius:"50%",background:we?"rgba(59,130,246,0.12)":"rgba(59,130,246,0.09)"},children:(0,D.jsx)("i",{className:"feather icon-activity",style:{color:we?"#f97316":"#3b82f6",fontSize:"1.5rem"}})}),(0,D.jsx)("h5",{className:"mb-2",children:"Create Your Universal Pixel"}),(0,D.jsx)("p",{className:`small ${we?"text-white-50":"text-muted"} mb-4`,children:"Generate your tracking pixel to measure conversions, build audiences, and forward events to your connected ad platforms."}),Z&&(0,D.jsxs)("div",{className:"alert alert-danger small text-start",role:"alert",children:[(0,D.jsx)("i",{className:"feather icon-alert-circle me-2"}),Z]}),(0,D.jsxs)("button",{type:"button",className:"btn btn-primary",onClick:ss,disabled:X,children:[(0,D.jsx)("i",{className:"feather icon-plus me-2"}),"Create Universal Pixel"]})]})}),"pixel"===$&&cs&&"code"===U&&(0,D.jsx)(rs,{pixelKey:K,onEmailInstructions:()=>{},onScanComplete:V,onViewFullResults:()=>hs("test-pixel")}),"pixel"===$&&cs&&"events"===U&&(0,D.jsx)(it,{onEmailInstructions:()=>{},pixelKey:K,conversionEvents:ge}),"pixel"===$&&cs&&"test-pixel"===U&&(0,D.jsx)(bt,{pixelKey:K,pixel:ds,initialTestResult:G,onNavigateToPlatforms:()=>hs("platforms"),onNavigateToDomains:()=>hs("domains")}),"pixel"===$&&cs&&"platforms"===U&&(0,D.jsx)(at,{pixelKey:K,platformMappings:(null===ds||void 0===ds?void 0:ds.platform_mappings)||{},autoPlatformConnect:null,onBadgeUpdate:Y,conversionEvents:ge},K),"pixel"===$&&cs&&"quality"===U&&(0,D.jsx)(Et,{pixelKey:K,pixel:ds},K),"pixel"===$&&cs&&"domains"===U&&(0,D.jsx)(tt,{pixelKey:K}),"pixel"===$&&cs&&"changelog"===U&&(0,D.jsx)(vs,{pixelKey:K})]}),(0,D.jsx)(r.A,{defaultOpen:Boolean(W.isOpen),defaultPanel:W.activePanel||"ai",onStateChange:e=>{let{isOpen:s,activePanel:t}=e;return O({isOpen:s,activePanel:t})},panels:[{key:"ai",icon:"feather icon-cpu",label:"AI",content:(0,D.jsx)(c.A,{isEmbedded:!0,context:"advertising"===$?"connections-advertising":"ecommerce"===$?"connections-ecommerce":"connections-pixel",contextLabel:"Connections"})},{key:"info",icon:"feather icon-info",label:"INFO",content:(0,D.jsx)(sa,{activeTab:$,activeSubTab:Ke,isDarkMode:we})},{key:"pixel",icon:"feather icon-activity",label:"PIXEL",content:(0,D.jsx)("div",{className:"small text-muted",children:K?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{className:"fw-semibold mb-1 text-body d-flex align-items-center justify-content-between",children:[(0,D.jsx)("span",{children:"Pixel Name"}),null===re&&(0,D.jsx)("button",{type:"button",className:"btn btn-link btn-sm p-0",title:"Rename pixel",onClick:()=>oe((null===ds||void 0===ds?void 0:ds.name)||""),children:(0,D.jsx)("i",{className:"feather icon-edit-2"})})]}),null===re?(0,D.jsx)("div",{className:"text-body mb-3",children:(null===ds||void 0===ds?void 0:ds.name)||"\u2014"}):(0,D.jsxs)("div",{className:"mb-3",children:[(0,D.jsx)("input",{type:"text",className:"form-control form-control-sm mb-2",value:re,maxLength:150,autoFocus:!0,disabled:ce,onChange:e=>oe(e.target.value),onKeyDown:e=>{"Enter"===e.key&&as(),"Escape"===e.key&&oe(null)}}),(0,D.jsxs)("div",{className:"d-flex gap-2",children:[(0,D.jsx)("button",{type:"button",className:"btn btn-primary btn-sm",disabled:ce||!re.trim(),onClick:as,children:ce?"Saving\u2026":"Save"}),(0,D.jsx)("button",{type:"button",className:"btn btn-outline-secondary btn-sm",disabled:ce,onClick:()=>oe(null),children:"Cancel"})]})]}),(0,D.jsx)("div",{className:"fw-semibold mb-1 text-body",children:"Universal Pixel Key"}),(0,D.jsx)("div",{className:"font-monospace",style:{wordBreak:"break-all"},children:K})]}):"No pixel selected yet."})}]})]})]}),(0,D.jsx)(M,{show:Re.show,provider:Re.provider,onHide:()=>Me({show:!1,provider:null}),onConnected:Ue,isDarkMode:we,betaPass:F}),(0,D.jsxs)(p.A,{show:ie.show,onHide:()=>{ie.submitting||le({show:!1,name:"",submitting:!1,error:null})},centered:!0,children:[(0,D.jsx)(p.A.Header,{closeButton:!0,children:(0,D.jsx)(p.A.Title,{children:"Add New Pixel"})}),(0,D.jsx)(p.A.Body,{children:(0,D.jsxs)(v.A.Group,{children:[(0,D.jsx)(v.A.Label,{children:"Pixel name"}),(0,D.jsx)(v.A.Control,{type:"text",value:ie.name,maxLength:150,autoFocus:!0,disabled:ie.submitting,onChange:e=>le(s=>({...s,name:e.target.value})),onKeyDown:e=>{"Enter"===e.key&&ts()}}),ie.error&&(0,D.jsx)("div",{className:"text-danger small mt-2",children:ie.error})]})}),(0,D.jsxs)(p.A.Footer,{children:[(0,D.jsx)(f.A,{variant:"outline-secondary",disabled:ie.submitting,onClick:()=>le({show:!1,name:"",submitting:!1,error:null}),children:"Cancel"}),(0,D.jsx)(f.A,{variant:"primary",disabled:ie.submitting||!ie.name.trim(),onClick:ts,children:ie.submitting?"Creating\u2026":"Create Pixel"})]})]})]}):(0,D.jsx)(Ot,{})}},20405(e,s,t){e.exports=t.p+"static/media/woo_logo_round_1024.951d99c8eca7bd4d7dbe.png"},23554(e,s,t){e.exports=t.p+"static/media/wix_round_1024.80fca658d70ad4d1c2d9.png"},25536(e,s,t){e.exports=t.p+"static/media/shopify_round_1024.8a05793f0d4de957e24b.png"},38003(e,s,t){t.d(s,{A:()=>l});var a=t(9950),n=t(99233),i=t(63890);function l(e,s){var t;const{user:l}=(0,a.useContext)(n.A),r=null===l||void 0===l||null===(t=l.access_context)||void 0===t?void 0:t.workspace;return(0,a.useMemo)(()=>{const t=(null===r||void 0===r?void 0:r.plan)||"free",a=(0,i.RL)(t,e,null===r||void 0===r?void 0:r.plan_limits),n=Number(s)||0;return{used:n,limit:a,atLimit:null!=a&&n>=a,plan:t}},[e,s,r])}},42578(e,s,t){t.d(s,{Ay:()=>v,FW:()=>h,Yo:()=>c.Yo,aQ:()=>x,pu:()=>u,zI:()=>m});t(9950);var a=t(97937),n=t(5216),i=t(65513),l=t(95252),r=t(42074),o=t(41),c=t(30542),d=t(44414);const m={google_ads:"Google Ads",linkedin_ads:"LinkedIn Ads",meta_ads:"Meta Ads",pinterest_ads:"Pinterest Ads",snapchat_ads:"Snapchat Ads",tiktok_ads:"TikTok Ads"},h={google_ads:"Search, Display, YouTube & Performance Max campaigns",linkedin_ads:"B2B audiences, sponsored content & lead gen forms",meta_ads:"Facebook, Instagram, Messenger & Audience Network",pinterest_ads:"Visual discovery & shopping campaigns",snapchat_ads:"Reach Gen Z and millennial audiences at scale",tiktok_ads:"Short
1-form video campaigns for broad reach"},u={google_ads:"https://ads.google.com?ref=www.linkclicks.com",linkedin_ads:"https://business.linkedin.com/marketing-solutions?ref=www.linkclicks.com",meta_ads:"https://business.meta.com?ref=www.linkclicks.com",pinterest_ads:"https://ads.pinterest.com?ref=www.linkclicks.com",snapchat_ads:"https://forbusiness.snapchat.com?ref=www.linkclicks.com",tiktok_ads:"https://ads.tiktok.com?ref=www.linkclicks.com"},x={google_ads:(0,d.jsxs)("span",{className:"d-inline-flex align-items-center gap-1",children:[(0,d.jsx)("i",{className:"fab fa-google text-c-red f-24"}),(0,d.jsx)("i",{className:"fab fa-youtube text-c-red f-24"})]}),linkedin_ads:(0,d.jsx)("i",{className:"fab fa-linkedin f-24",style:{color:"#134bce"}}),meta_ads:(0,d.jsxs)("span",{className:"d-inline-flex align-items-center gap-1",children:[(0,d.jsx)("i",{className:"fab fa-meta f-24",style:{color:"#134bce"}}),(0,d.jsx)("i",{className:"fab fa-facebook-f f-24",style:{color:"#134bce"}}),(0,d.jsx)("i",{className:"fab fa-instagram text-c-purple f-24"}),(0,d.jsx)("i",{className:"fab fa-facebook-messenger f-24",style:{color:"#134bce"}})]}),pinterest_ads:(0,d.jsx)("i",{className:"fab fa-pinterest text-c-red f-24"}),snapchat_ads:(0,d.jsx)("i",{className:"fab fa-snapchat f-24",style:{color:"yellow",textShadow:"-1px 0 black, 0 1px black, 1px 0 black, 0 
1-1px black"}}),tiktok_ads:(0,d.jsx)("i",{className:"fab fa-tiktok f-24",style:{color:"black",textShadow:"-1.2px -1.2px 0 #28ffff, 1.2px 1.2px 0 #ff0050"}})},p=e=>{let{status:s,isDarkMode:t}=e;return"reconnect_required"===s?(0,d.jsxs)("span",{className:"badge bg-danger",style:{fontSize:"0.7rem"},children:[(0,d.jsx)("i",{className:"feather icon-alert-triangle me-1"}),"Reconnect required"]}):"imported"===s?(0,d.jsxs)("span",{className:"badge bg-success",style:{fontSize:"0.7rem"},children:[(0,d.jsx)("i",{className:"feather icon-check-circle me-1"}),"Connected"]}):"importing"===s?(0,d.jsxs)("span",{className:"badge bg-primary",style:{fontSize:"0.7rem"},children:[(0,d.jsx)("i",{className:"feather icon-refresh-cw me-1"}),"Importing"]}):"connecting"===s||"connected"===s?(0,d.jsxs)("span",{className:"badge bg-warning text-dark",style:{fontSize:"0.7rem"},children:[(0,d.jsx)("i",{className:"feather icon-loader me-1"}),"Connecting"]}):(0,d.jsx)("span",{className:"badge "+(t?"bg-secondary":"bg-light text-muted border"),style:{fontSize:"0.7rem"},children:"Not connected"})},v=e=>{var s,t;let{platform:v,platformState:f=null,onEnable:g,onDisable:b,onResetConnecting:j,onReimport:y=null,isReimporting:N=!1,isDarkMode:_=!1}=e;const w=(0,c.Yo)(f),{cooldownActive:k,cooldownMinutesRemaining:S}=(0,o.l)(v,f),C="imported"===w,A="importing"===w,P="reconnect_required"===w,z=P?{borderLeft:"4px solid #dc3545",boxShadow:_?"0 0 0 1px rgba(220,53,69,0.16)":"0 0 0 1px rgba(220,53,69,0.10)"}:C?{borderLeft:"4px solid #22c55e",boxShadow:_?"0 0 0 1px rgba(34,197,94,0.12)":"0 0 0 1px rgba(34,197,94,0.08)"}:A?{borderLeft:"3px solid #0d6efd"}:{},T=_?"1px solid rgba(255,255,255,0.08)":"1px solid rgba(0,0,0,0.07)";return(0,d.jsx)(n.A,{className:"connections-platform-card mb-0 h-100 "+(_?"border-secondary":""),style:{borderRadius:12,...z,minHeight:230},children:(0,d.jsxs)(n.A.Body,{className:"d-flex flex-column",style:{gap:10,padding:"1.1rem 1.25rem"},children:[(0,d.jsx)("div",{className:"d-flex align-items-start justify-content-between gap-2",children:(0,d.jsxs)("div",{style:{minWidth:0,flex:1},children:[(0,d.jsxs)("div",{className:"d-flex align-items-center justify-content-between gap-2",style:{marginBottom:2},children:[(0,d.jsx)("div",{className:"fw-semibold",style:{fontSize:"0.97rem",lineHeight:1.25},children:m[v]}),(0,d.jsx)("div",{className:"d-flex align-items-center gap-2",style:{flexShrink:0},children:(0,d.jsx)(p,{status:w,isDarkMode:_})})]}),(0,d.jsxs)("div",{className:"d-flex align-items-center gap-2",style:{marginTop:6},children:[(0,d.jsx)("div",{style:{flexShrink:0,lineHeight:1},children:x[v]}),(0,d.jsx)("div",{className:"small "+(_?"text-white-50":"text-muted"),style:{fontSize:"0.75rem",marginTop:1},children:h[v]})]})]})}),(0,d.jsxs)("div",{style:{flex:1},children:[P&&(0,d.jsxs)("div",{className:"glassy-panel",style:{marginTop:4,borderLeft:"3px solid #dc3545"},children:[(0,d.jsxs)("div",{className:"fw-medium",style:{fontSize:"0.82rem",color:"#dc3545"},children:[(0,d.jsx)("i",{className:"feather icon-alert-triangle me-1"}),"missing_scopes"===f.reconnect_reason?"Missing permissions":"Connection revoked"]}),(0,d.jsx)("div",{className:"small "+(_?"text-white-50":"text-muted"),style:{fontSize:"0.78rem",marginTop:2},children:"missing_scopes"===f.reconnect_reason?"This connection is missing a permission we need. Reconnect and grant it to resume.":"Data sync is paused. Your campaigns and history are safe \u2014 reconnect to resume."})]}),(C||P)&&(0,d.jsxs)("div",{className:"glassy-panel glassy-panel--prominent",style:{marginTop:4},children:[f.organization_name&&(0,d.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"baseline",marginBottom:2},children:[(0,d.jsx)("span",{className:"fw-medium",style:{minWidth:90,flexShrink:0,fontSize:"0.82rem"},children:"Organization"}),(0,d.jsx)("span",{style:{fontSize:"0.82rem"},children:f.organization_name})]}),(0,d.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"baseline",marginBottom:2},children:[(0,d.jsx)("span",{className:"fw-medium",style:{minWidth:90,flexShrink:0,fontSize:"0.82rem"},children:"Account"}),(0,d.jsx)("span",{style:{fontSize:"0.82rem"},children:f.account_name||"\u2014"})]}),f.currency&&(0,d.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"baseline",marginBottom:2},children:[(0,d.jsx)("span",{className:"fw-medium",style:{minWidth:90,flexShrink:0,fontSize:"0.82rem"},children:"Currency"}),(0,d.jsx)("span",{style:{fontSize:"0.82rem"},children:f.currency})]}),(0,d.jsxs)("div",{style:{opacity:.7,fontSize:"0.74rem",marginTop:4},children:[(0,d.jsx)("i",{className:"feather icon-refresh-cw me-1",style:{color:"#22c55e"}}),f.last_checked_at?`Last checked ${new Date(f.last_checked_at).toLocaleStr
1ing(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`:"Data synced automatically"]})]}),A&&(0,d.jsxs)("div",{style:{marginTop:4},children:[(0,d.jsxs)("div",{className:"small mb-2 d-flex align-items-center "+(_?"text-white-50":"text-muted"),children:[(0,d.jsx)(l.A,{animation:"border",size:"sm",className:"me-2"}),f.status_text||"Importing..."]}),(0,d.jsx)(i.A,{animated:!0,striped:!0,now:null!==(s=f.progress)&&void 0!==s?s:0,variant:"primary",style:{height:8,borderRadius:4}}),(0,d.jsxs)("div",{className:"small mt-1 "+(_?"text-white-50":"text-muted"),style:{fontSize:"0.73rem"},children:[Math.round(null!==(t=f.progress)&&void 0!==t?t:0),"% complete \u2014 first import may take a few minutes"]})]}),("connecting"===w||"connected"===w)&&(0,d.jsxs)("div",{className:"small mt-2 d-flex align-items-center "+(_?"text-white-50":"text-muted"),children:[(0,d.jsx)(l.A,{animation:"border",size:"sm",className:"me-2"}),"Waiting for authorization..."]}),"initial"===w&&!k&&(0,d.jsxs)("div",{className:"small mt-2 "+(_?"text-white-50":"text-muted"),style:{fontSize:"0.8rem"},children:[(0,d.jsx)("i",{className:"feather icon-info me-1"}),"Connect to sync campaigns, ad sets & performance data."]}),k&&(0,d.jsxs)("div",{className:"small mt-2 text-warning",style:{fontSize:"0.8rem"},children:[(0,d.jsx)("i",{className:"fas fa-clock me-1"}),"Pinterest rate limit \u2014 retry in ~",S," min",1!==S?"s":"","."]})]}),(0,d.jsx)("div",{className:"d-flex align-items-center justify-content-between",style:{paddingTop:10,borderTop:T},children:P?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(a.A,{variant:"outline-secondary",size:"sm",onClick:()=>b(v),children:[(0,d.jsx)("i",{className:"feather icon-x me-1"}),"Disconnect"]}),(0,d.jsxs)(a.A,{variant:"danger",size:"sm",onClick:()=>g(v),children:[(0,d.jsx)("i",{className:"feather icon-refresh-cw me-1"}),"Reconnect"]})]}):C?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(a.A,{variant:"outline-secondary",size:"sm",onClick:()=>b(v),children:[(0,d.jsx)("i",{className:"feather icon-x me-1"}),"Disconnect"]}),y&&(0,d.jsx)(a.A,{variant:"outline-secondary",size:"sm",onClick:()=>y(v),disabled:N,title:"Dev only \u2014 re-run this platform's import now",children:N?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l.A,{animation:"border",size:"sm",className:"me-1"}),"Starting\u2026"]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("i",{className:"feather icon-download-cloud me-1"}),"Re-import"]})}),(0,d.jsxs)(r.N_,{to:"/ads-manager",className:"btn btn-sm btn-outline-primary",children:["View Ads ",(0,d.jsx)("i",{className:"feather icon-arrow-right ms-1"})]})]}):A?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{}),(0,d.jsx)(a.A,{variant:"outline-secondary",size:"sm",onClick:()=>b(v),children:"Cancel"})]}):k?(0,d.jsxs)(a.A,{variant:"secondary",size:"sm",disabled:!0,children:[(0,d.jsx)("i",{className:"fas fa-clock me-1"}),"Rate limited \u2014 ",S,"m"]}):"connecting"===w||"connected"===w?(0,d.jsx)(a.A,{variant:"outline-warning",size:"sm",onClick:()=>j(v),children:"Cancel"}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("a",{href:u[v],target:"_blank",rel:"noopener noreferrer",className:"small "+(_?"text-white-50":"text-muted"),style:{fontSize:"0.76rem"},children:"No account? Register"}),(0,d.jsxs)(a.A,{variant:"primary",size:"sm",onClick:()=>g(v),children:["Connect ",(0,d.jsx)("i",{className:"feather icon-link ms-1"})]})]})})]})})}},58410(e,s,t){t.d(s,{A:()=>j});var a=t(48738),n=t.n(a),i=t(9950),l=t(83529),r=t(3882),o=t(44089),c=t(34296),d=t(22063),m=t(44414);const h=i.forwardRef((e,s)=>{let{className:t,bsPrefix:a,as:i="div",...l}=e;return a=(0,o.oU)(a,"nav-item"),(0,m.jsx)(i,{ref:s,className:n()(t,a),...l})});h.displayName="NavItem";const u=h;var x=t(13763),p=t(6005),v=t(1932);const f=i.forwardRef((e,s)=>{let{bsPrefix:t,className:a,as:i=x.A,active:l,eventKey:r,disabled:c=!1,...d}=e;t=(0,o.oU)(t,"nav-link");const[h,u]=(0,p.M)({key:(0,v.u)(r,d.href),active:l,disabled:c,...d});return(0,m.jsx)(i,{...d,...h,ref:s,disabled:c,className:n()(a,t,c&&"disabled",u.isActive&&"active")})});f.displayName="NavLink";const g=f,b=i.forwardRef((e,s)=>{const{as:t="div",bsPrefix:a,variant:h,fill:u=!1,justify:x=!1,navbar:p,navbarScroll:v,className:f,activeKey:g,...b}=(0,l.Zw)(e,{activeKey:"onSelect"}),j=(0,o.oU)(a,"nav");let y,N,_=!1;const w=(0,i.useContext)(c.A),k=(0,i.useContext)(d.A);return w?(y=w.bsPrefix,_=null==p||p):k&&({cardHeaderBsPrefix:N}=k),(0,m.jsx)(r.A,{as:t,ref:s,activeKey:g,className:n()(f,{[j]:!_,[`${y}-nav`]:_,[`${y}-nav-scroll`]:_&&v,[`${N}-${h}`]:!!N,[`${j}-${h}`]:!!h,[`${j}-fill`]:u,[`${j}-justified`]:x}),...b})});b.displayName="Nav";const j=Object.assign(b,{Item:u,Link:g})},63565(e,s,t){t.d(s,{A:()=>o});var a=t(9950),n=t(29246),i=t(53766),l=t(44414);const r=e=>{let{provider:s,className:t}=e;const[r,o]=(0,a.useState)(null);return(0,a.useEffect)(()=>{let e=!1;return n.A.get(`${i.eN}/ecommerce/integration-status/`).then(t=>{var a;e||o((null===(a=t.data)||void 0===a?void 0:a[s])||null)}
1).catch(()=>{}),()=>{e=!0}},[s]),null!==r&&void 0!==r&&r.in_review?(0,l.jsxs)("div",{className:`alert alert-info d-flex gap-2 align-items-start ${t}`,role:"status",children:[(0,l.jsx)("i",{className:"feather icon-info mt-1","aria-hidden":"true"}),(0,l.jsxs)("div",{className:"small",children:[(0,l.jsx)("div",{className:"fw-semibold",children:"Shopify integration is in review"}),"You can connect your store now, but your orders won't sync until Shopify approves our access to order data \u2014 that approval is pending. Syncing starts automatically once it's granted, with nothing for you to do."]})]}):null};r.defaultProps={provider:"shopify",className:"mb-3"};const o=r},63780(e,s,t){t.d(s,{A:()=>d});var a=t(9950),n=t(99233),i=t(96718),l=t(50212),r=t(45502),o=t(43525);const c=()=>"undefined"===typeof window?"/":`${window.location.pathname}${window.location.search}`;function d(){const{user:e,isLoggedIn:s}=(0,a.useContext)(n.A)||{},t=Boolean(s&&e),d=(0,r.NX)(e,s),m=(0,a.useCallback)((e,s)=>{if(t)return!0;const a=s||c();return(0,o.pj)(a),(0,i.Y)({message:e,redirectPath:a}),!1},[t]),h=(0,a.useCallback)(function(e){let{message:s,redirectPath:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return!!m(s,t)&&(!!d||((0,o.pj)(t||c()),(0,l.QM)({reason:r.Wh,body:e}),!1))},[d,m]),u=(0,a.useCallback)(function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return h(s.body,{message:e,redirectPath:s.redirectPath})},[h]);return(0,a.useMemo)(()=>({isLoggedIn:t,hasAppAccess:d,canPersist:t,requireLogin:m,requireSubscription:h,requireAccess:u}),[t,d,m,h,u])}},65513(e,s,t){t.d(s,{A:()=>h});var a=t(48738),n=t.n(a),i=t(9950),l=t(44089),r=t(22890),o=t(44414);function c(e,s,t){const a=(e-s)/(t-s)*100;return Math.round(1e3*a)/1e3}function d(e,s){let{min:t,now:a,max:i,label:l,visuallyHidden:r,striped:d,animated:m,className:h,style:u,variant:x,bsPrefix:p,...v}=e;return(0,o.jsx)("div",{ref:s,...v,role:"progressbar",className:n()(h,`${p}-bar`,{[`bg-${x}`]:x,[`${p}-bar-animated`]:m,[`${p}-bar-striped`]:m||d}),style:{width:`${c(a,t,i)}%`,...u},"aria-valuenow":a,"aria-valuemin":t,"aria-valuemax":i,children:r?(0,o.jsx)("span",{className:"visually-hidden",children:l}):l})}const m=i.forwardRef((e,s)=>{let{isChild:t=!1,...a}=e;const c={min:0,max:100,animated:!1,visuallyHidden:!1,striped:!1,...a};if(c.bsPrefix=(0,l.oU)(c.bsPrefix,"progress"),t)return d(c,s);const{min:m,now:h,max:u,label:x,visuallyHidden:p,striped:v,animated:f,bsPrefix:g,variant:b,className:j,children:y,...N}=c;return(0,o.jsx)("div",{ref:s,...N,className:n()(j,g),children:y?(0,r.Tj)(y,e=>(0,i.cloneElement)(e,{isChild:!0})):d({min:m,now:h,max:u,label:x,visuallyHidden:p,striped:v,animated:f,bsPrefix:g,variant:b},s)})});m.displayName="ProgressBar";const h=m}}]);

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.