1import{a as Ie,b as Ve}from"./chunk-RG46C4BP.js";import{a as be,b as we,c as ke,d as Se}from"./chunk-M5FOBINP.js";import{a as De,c as Ae,d as Te,e as Ee}from"./chunk-E4BHRWIY.js";import{a as J}from"./chunk-2TNMJ2S5.js";import{a as H,b as ze}from"./chunk-5YWEEUWV.js";import{a as B,b as Me}from"./chunk-UMORUNDS.js";import"./chunk-WJ576XGC.js";import"./chunk-YYZEZ74T.js";import"./chunk-JDED4XNO.js";import{a as Y}from"./chunk-3HHUCJK3.js";import{a as Pe,b as Le,c as Ue,d as Re,e as $e,f as Be,g as He,h as qe,i as je,j as Ne,k as Oe,l as X}from"./chunk-EHSKWIZA.js";import{a as xe}from"./chunk-YYE73QRH.js";import{a as Fe}from"./chunk-QVMGNSYF.js";import{a as Z}from"./chunk-AGDQ7L3Q.js";import"./chunk-HJZ2PBAO.js";import"./chunk-YLCLC2RY.js";import"./chunk-7V6F2WZN.js";import{a as ve,b as ge}from"./chunk-I4JZRJUG.js";import"./chunk-5CH6MUXM.js";import"./chunk-SYYTKOT6.js";import{d as Ce}from"./chunk-76G25NHC.js";import"./chunk-VO2GOVB3.js";import{a as ye}from"./chunk-5XJN6G4E.js";import{a as W}from"./chunk-UAJ3LDZG.js";import"./chunk-46OECEEY.js";import"./chunk-S3OUMWH4.js";import"./chunk-FHSHMNFM.js";import{a as $}from"./chunk-Z52QV2AD.js";import"./chunk-UEHAY5FE.js";import"./chunk-4XCQO5GC.js";import"./chunk-TQGNAWKW.js";import{a as R}from"./chunk-IQ4DJ3PK.js";import{a as N}from"./chunk-N2DDWHMI.js";import{a as j}from"./chunk-RDCV7OYL.js";import"./chunk-3DJX6TII.js";import{g as _e,m as fe}from"./chunk-QRHPXOKA.js";import"./chunk-HKSRDAI3.js";import"./chunk-BR7SVKEQ.js";import{f as U}from"./chunk-WLTVU3TA.js";import"./chunk-FBPQG6MS.js";import"./chunk-HYC3WGKD.js";import"./chunk-2PPFUFFT.js";import{a as Q,b as G}from"./chunk-7OXH5EWV.js";import{p as he}from"./chunk-FTXGPRFJ.js";import{a as O,d as z}from"./chunk-BRRFPLOY.js";import"./chunk-HGFVTFKX.js";import{Ac as P,Fa as V,Fc as D,Gc as T,Hc as K,Ib as p,Jb as se,Kb as w,Pb as h,Pc as re,Rb as M,Sb as k,Tb as S,U as ae,Ub as n,V as q,Vb as a,Wb as f,Wc as ce,Xb as E,Yb as I,_b as b,bc as v,dc as d,ea as _,f as ie,g as ne,gb as l,jd as de,ma as oe,na as y,oa as x,qc as r,rc as A,sb as F,sc as C,sd as me,ud as pe,vd as ue,ya as le,yb as u,yd as L}from"./chunk-EL2YAQZX.js";import"./chunk-EQDQRRRY.js";var Xe=(t,s)=>s.title;function et(t,s){if(t&1&&(n(0,"div")(1,"app-section-title",5),r(2),a(),f(3,"app-metric-list",6),a()),t&2){let e=s.$implicit,i=d();w("lg:col-span-2",e.kind==="source"),l(2),A(e.title),l(),p("headerLabel",e.headerLeft)("columns",i.columns)("rows",e.rows)}}function tt(t,s){if(t&1){let e=b();n(0,"div",4)(1,"button",7),v("click",function(){y(e);let o=d();return x(o.openUpgradeDialog())}),n(2,"mat-icon"),r(3,"bolt"),a(),r(4," Upgrade to unlock "),a()()}}var Qe=127397,it={Desktop:"desktop_windows",Mobile:"smartphone",Tablet:"tablet_mac",Bot:"smart_toy"},We=(()=>{class t{constructor(){this.isPro=!1,this.days=30,this.loading=!1,this.loaded=!1,this.sections=[],this.columns=[{key:"views",header:"Views",format:"number",tone:"muted",width:"w-16"},{key:"unlocks",header:"Unlocks",format:"number",tone:"strong",width:"w-16"},{key:"conversion",header:"Conv.",format:"percent",tone:"positive",width:"w-16"}],this.service=_(j),this.dialog=_(U),this.events=_(R),this.placeholderSections=this.buildSections({referrers:this.fakeRows(["youtube.com","google.com","Direct","tiktok.com"]),countries:this.fakeRows(["US","GB","DE","CA"]),devices:this.fakeRows(["Mobile","Desktop","Tablet"])})}get displaySections(){return this.isPro?this.sections:this.placeholderSections}ngOnChanges(){this.load()}load(){if(!this.isPro){this.loaded=!0;return}this.loading=!0,this.service.getConversionBreakdown(this.days).subscribe({next:e=>{this.sections=this.buildSections(e),this.loading=!1,this.loaded=!0},error:()=>{this.loading=!1,this.loaded=!0}})}buildSections(e){return[{kind:"source",title:"By source",headerLeft:"Source",rows:e.referrers.map(i=>this.toRow(i,"source"))},{kind:"country",title:"By country",headerLeft:"Country",rows:e.countries.map(i=>this.toRow(i,"country"))},{kind:"device",title:"By device",headerLeft:"Device",rows:e.devices.map(i=>this.toRow(i,"device"))}]}toRow(e,i){let o={key:e.value,label:e.value,values:{views:e.views,unlocks:e.unlocks,conversion:e.conversion},bar:e.views};return i==="device"?o.icon={matIcon:it[e.value]??"devices"}:i==="country"&&this.isCountryCode(e.value)?(o.icon={flag:this.countryFlag(e.value)},o.label=this.countryName(e.value)):i==="source"&&e.value.includes(".")&&(o.icon={favicon:e.value.includes("rekonise")?"/assets/images/logo.svg":`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e.value)}&sz=64`}),o}openUpgradeDialog(){this.events.upgradeEntryClickedEvent({entry:"analytics_hub",trigger:"conversions_locked"}),this.dialog.open($,{backdropClass:"dialog-backdrop",panelClass:"custom-dialog",maxWidth:"800px",data:{source:"analytics_hub",trigger:"conversions_locked",subtitle:"See which sources, countries and devices actually convert to unlocks, not just which ones click. Conversion analytics are part of Pro. Cancel anytime."}})}isCountryCode(e){return/^[A-Za-z]{2}$/.test(e)}countryFlag(e){let i=e.toUpperCase();
1return String.fromCodePoint(i.charCodeAt(0)+Qe,i.charCodeAt(1)+Qe)}countryName(e){try{return new Intl.DisplayNames(["en"],{type:"region"}).of(e.toUpperCase())||e.toUpperCase()}catch{return e.toUpperCase()}}fakeRows(e){return e.map((i,o)=>{let c=1200-o*260,m=.42-o*.07;return{value:i,views:c,unlocks:Math.round(c*m),conversion:m}})}static{this.\u0275fac=function(i){return new(i||t)}}static{this.\u0275cmp=F({type:t,selectors:[["app-analytics-conversions"]],inputs:{isPro:"isPro",days:"days"},features:[oe],decls:6,vars:5,consts:[[1,"max-w-7xl"],[1,"relative"],[1,"grid","grid-cols-1","gap-x-10","gap-y-9","lg:grid-cols-2"],[3,"lg:col-span-2"],[1,"absolute","inset-0","flex","items-center","justify-center"],[1,"mb-3"],[3,"headerLabel","columns","rows"],["mat-stroked-button","",3,"click"]],template:function(i,o){i&1&&(n(0,"div",0)(1,"div",1)(2,"div",2),k(3,et,4,6,"div",3,Xe),a(),u(5,tt,5,0,"div",4),a()()),i&2&&(l(2),w("blur-sm",!o.isPro)("opacity-50",o.loading),l(),S(o.displaySections),l(2),h(o.isPro?-1:5))},dependencies:[L,z,O,G,Q,Y,J],encapsulation:2})}}return t})();var ee=()=>[1,2,3,4,5],nt=()=>[1,2,3,4,5,6,7],at=()=>[1,2,3,4],ot=(t,s)=>s.label,lt=(t,s)=>s.device;function st(t,s){t&1&&(n(0,"div",1),f(1,"app-module-title",9),a()),t&2&&(l(),p("titleRoute",void 0))}function rt(t,s){t&1&&f(0,"div",13)}function ct(t,s){t&1&&f(0,"div",15)}function dt(t,s){t&1&&(n(0,"app-card")(1,"div",17),f(2,"div",18),n(3,"div",19),f(4,"div",20)(5,"div",21),a()()())}function mt(t,s){t&1&&(n(0,"div",2)(1,"app-card",10)(2,"div",11)(3,"div",12),k(4,rt,1,0,"div",13,M),a(),n(6,"div",14),k(7,ct,1,0,"div",15,M),a()()(),n(9,"div",16),k(10,dt,6,0,"app-card",null,M),a()()),t&2&&(l(4),S(P(0,ee)),l(3),S(P(1,nt)),l(3),S(P(2,ee)))}function pt(t,s){if(t&1){let e=b();n(0,"app-stats-cards",43),v("itemClicked",function(o){y(e);let c=d(2);return x(c.onChartStatCardClick(o))}),a()}if(t&2){let e=d(2);p("items",e.chartStatsItems)}}function ut(t,s){t&1&&(n(0,"div",25),r(1," No data for this period "),a())}function ht(t,s){t&1&&(n(0,"th",44),r(1,"Date"),a())}function _t(t,s){if(t&1&&(n(0,"td",45),r(1),D(2,"date"),a()),t&2){let e=s.$implicit;l(),C(" ",T(2,1,(e==null?null:e.date)*1e3)," ")}}function ft(t,s){t&1&&(n(0,"th",46),r(1,"Unlocks"),a())}function Ct(t,s){if(t&1&&(n(0,"td",47)(1,"small",48),r(2),a(),r(3),D(4,"number"),a()),t&2){let e=s.$implicit;l(),p("ngClass",e.unlocks===0?"text-muted":"text-primary"),l(),C(" +",e.unlocks," "),l(),C(" ",T(4,3,e==null?null:e.total_unlocks)," ")}}function vt(t,s){t&1&&(n(0,"th",46),r(1,"Views"),a())}function gt(t,s){if(t&1&&(n(0,"td",47)(1,"small",48),r(2),a(),r(3),D(4,"number"),a()),t&2){let e=s.$implicit;l(),p("ngClass",e.views===0?"text-muted":"text-primary"),l(),C(" +",e.views," "),l(),C(" ",T(4,3,e==null?null:e.total_views)," ")}}function yt(t,s){t&1&&(n(0,"th",49),r(1,"Actions completed"),a())}function xt(t,s){if(t&1&&(n(0,"td",50)(1,"small",48),r(2),a(),r(3),D(4,"number"),a()),t&2){let e=s.$implicit;l(),p("ngClass",e.actions_completed===0?"text-muted":"text-primary"),l(),C(" +",e.actions_completed," "),l(),C(" ",T(4,3,e==null?null:e.total_actions_completed)," ")}}function bt(t,s){t&1&&(n(0,"th",51),r(1,"Emails captured"),a())}function wt(t,s){if(t&1&&(n(0,"td",52)(1,"small",48),r(2),a(),r(3),D(4,"number"),a()),t&2){let e=s.$implicit;l(),p("ngClass",e.emails_captured===0?"text-muted":"text-primary"),l(),C(" +",e.emails_captured," "),l(),C(" ",T(4,3,e==null?null:e.total_emails_captured)," ")}}function kt(t,s){t&1&&(n(0,"th",51),r(1,"Conversion rate"),a())}function St(t,s){if(t&1&&(n(0,"td",52),r(1),D(2,"percent"),a()),t&2){let e=s.$implicit;l(),C(" ",e.views>0?K(2,1,e.unlocks/e.views,"1.0-1"):"0%"," ")}}function Dt(t,s){t&1&&f(0,"tr",53)}function At(t,s){t&1&&f(0,"tr",54)}function Tt(t,s){if(t&1){let e=b();n(0,"div")(1,"app-filterable-analytics",22),v("seriesVisibilityChange",function(o){y(e);let c=d();return x(c.onSeriesVisibilityChange(o))}),u(2,pt,1,1,"app-stats-cards",23),n(3,"div",24),u(4,ut,2,0,"div",25),n(5,"table",26),E(6,27),u(7,ht,2,0,"th",28)(8,_t,3,3,"td",29),I(),E(9,30),u(10,ft,2,0,"th",31)(11,Ct,5,5,"td",32),I(),E(12,33),u(13,vt,2,0,"th",31)(14,gt,5,5,"td",32),I(),E(15,34),u(16,yt,2,0,"th",35)(17,xt,5,5,"td",36),I(),E(18,37),u(19,bt,2,0,"th",38)(20,wt,5,5,"td",39),I(),E(21,40),u(22,kt,2,0,"th",38)(23,St,3,4,"td",39),I(),u(24,Dt,1,0,"tr",41)(25,At,1,0,"tr",42),a()()()()}if(t&2){let e=d();l(),p("queryParams$",e.chartQueryParams$)("data",e.chartData)("hiddenSeries",e.hiddenSeries)("showFilters",!1)("showTableToggle",!0)("loading",e.isLoadingChart),l(),h(e.chartStatsItems?2:-1),l(2),h(e.hasChartData?-1:4),l(),p("dataSource",e.dataSource)("hidden",!e.hasChartData),l(19),p("matHeaderRowDef",e.displayedColumns)("matHeaderRowDefSticky",!0),l(),p("matRowDefColumns",e.displayedColumns)}}function Et(t,s){if(t&1&&(n(0,"div",64),r(1),D(2,"percent"),a()),t&2){let e=d().$implicit;l(),C(" \u2212",K(2,1,e.dropoff,"1.0-0")," vs previous ")}}function It(t,s){t&1&&(n(0,"div",65)(1,"mat-icon",66),r(2,"chevron_right"),a()())}function Vt(t,s){if(t&1&&(n(0,"div",57)(1,"div",58)(2,"span",59),r(3),a(),n(4,"span",60),r(5),a()(),n(6,"div",61),r(7),D(8,"number"),a(),n(9,"div",62),f(10,"div",63),a(),u(11,Et,3,4,"div",64),a(),u(12,It,3,0,"div",65)),t&2){let e=s.$implicit,i=s.$index,o=s.$count;l(3),A(e.label),l(2),C("",e.pct,"%"),l(2),A(T(8,7,e.count)),l(3),se("width",e.pct,"%"),l(),h(e.dropoff!==null&&e.dropoff>.001?11:-1),l(),h(i!==o-1?12:-1)}}function Ft(t,s){if(t&1&&(n(0,"div",3)(1,"app-section-title",55),r(2,"Funnel"),a(),n(3,"div",56),k(4,Vt,13,9,null,null,ot),a()()),t&2){let e=d();l(4),S(e.accountFunnel)}}function Mt(t,s){t&1&&(n(0,"div",69),f(1,"div",71),n(2,"div",19),f(3,"div",72),a()())}function Pt(t,s){t&1&&(n(0,"div",69),f(1,"div",73),n(2,"div",74),f(3,"div",75)(4,"div",76),a()())}function Lt(t,s){t&1&&(n(0,"div",3)(1,"app-section-title",55),r(2,"Quick Insights"),a(),n(3,"app-card",67)(4,"div",68),k(5,Mt,4,0,"div",69,M),a()()(),n(7,"div",70)(8,"app-section-title",55),r(9,"Top Links"),a(),n(10,"app-card",67)(11,"div",68),k(12,Pt,5,0,"div",69,M),a()()()),t&2&&(l(5),S(P(0,at)),l(7),S(P(1,ee)))}function Ut(t,s){if(t&1&&(n(0,"span",84),r(1),a()),t&2){let e=d(3);l(),A(e.getCountryFlag(e.quickInsights.topCountry.country))}}function Rt(t,s){t&1&&(n(0,"mat-icon",85),r(1,"public"),a())}function $t(t,s){if(t&1){let e=b();n(0,"div",82),v("click",function(){y(e);let o=d(2);return x(o.navigateToAudience())}),n(1,"span",83),u(2,Ut,2,1,"span",84)(3,Rt,2,0,"mat-icon",85),a(),n(4,"span",86)(5,"span",87),r(6),a(),n(7,"span",88),r(8),a()()()}if(t&2){let e=d(2);l(2),h(e.isValidCountryCode(e.quickInsights.topCountry.country)?2:3),l(4),C("",e.quickInsights.topCountry.percentage,"%"),l(2),C(" of traffic from ",e.getCountryName(e.quickInsights.topCountry.country),"")}}function Bt(t,s){if(t&1){let e=b();n(0,"div",82),v("click",function(){y(e);let o=d(2);return x(o.navigateToAudience())}),n(1,"span",83)(2,"mat-icon",85),r(3,"link"),a()(),n(4,"span",86)(5,"span",87),r(6),a(),n(7,"span",88),r(8," of traffic from "),a(),n(9,"span",87),r(10),a()()()}if(t&2){let e=d(2);l(6),C("",e.quickInsights.topReferrer.percentage,"%"),l(4),A(e.quickInsights.topReferrer.referrer)}}function Ht(t,s){if(t&1&&(n(0,"span")(1,"span",90),r(2),a(),n(3,"span",88),r(4),a()()),t&2){let e=s.$implicit;l(2),C("",e.percentage,"%"),l(2),C(" ",e.device,"")}}function qt(t,s){if(t&1){let e=b();n(0,"div",82),v("click",function(){y(e);let o=d(2);return x(o.navigateToAudience())}),n(1,"span",83)(2,"mat-icon",85),r(3,"devices"),a()(),n(4,"span",89),k(5,Ht,5,2,"span",null,lt),a()()}if(t&2){let e=d(2);l(5),S(e.quickInsights.devices.slice(0,3))}}function jt(t,s){if(t&1){let e=b();n(0,"div",82),v("click",function(){y(e);let o=d(2);return x(o.navigateToLink(o.quickInsights.topLink.slug))}),n(1,"span",83)(2,"mat-icon",85),r(3,"trending_up"),a()(),n(4,"span",86)(5,"span",88),r(6,"Top performer: "),a(),n(7,"span",87),r(8),a(),n(9,"span",88),r(10),D(11,"number"),a()()()}if(t&2){let e=d(2);l(8),A(e.quickInsights.topLink.title),l(2),C(" (",T(11,2,e.quickInsights.topLink.count)," clicks)")}}function Nt(t,s){if(t&1){let e=b();n(0,"div",81)(1,"button",91),v("click",function(){y(e);let o=d(2);return x(o.openUpgradeDialog())}),n(2,"mat-icon"),r(3,"bolt"),a(),r(4," Upgrade to unlock "),a()()}}function Ot(t,s){if(t&1){let e=b();n(0,"div",81)(1,"button",91),v("click",function(){y(e);let o=d(3);return x(o.openUpgradeDialog())}),n(2,"mat-icon"),r(3,"bolt"),a(),r(4," Upgrade to unlock "),a()()}}function zt(t,s){if(t&1){let e=b();n(0,"div")(1,"app-section-title",55),r(2,"Top Links"),a(),n(3,"div",78)(4,"div")(5,"app-metric-list",92),v("rowClicked",function(o){y(e);let c=d(2);return x(c.navigateToLink(o.data.slug))}),a()(),u(6,Ot,5,0,"div",81),a()()}if(t&2){let e=d(2);l(4),w("blur-sm",!e.isPro()),l(),p("columns",e.linkColumns)("rows",e.topLinksRows)("clickable",!0),l(),h(e.isPro()?-1:6)}}function Qt(t,s){if(t&1&&(n(0,"div",77)(1,"div")(2,"app-section-title",55),r(3,"Quick Insights"),a(),n(4,"div",78)(5,"div",79),u(6,$t,9,3,"div",80)(7,Bt,11,2,"div",80)(8,qt,7,0,"div",80)(9,jt,12,4,"div",80),a(),u(10,Nt,5,0,"div",81),a()(),u(11,zt,7,6,"div"),a()),t&2){let e=d();w("animate-pulse",e.isLoadingInsights),p("@fadeSlideInDelay1",void 0),l(),w("lg:col-span-2",e.topLinksRows.length===0),l(4),w("blur-sm",!e.isPro()),l(),h(e.quickInsights.topCountry?6:-1),l(),h(e.quickInsights.topReferrer?7:-1),l(),h(e.quickInsights.devices.length>0?8:-1),l(),h(e.quickInsights.topLink?9:-1),l(),h(e.isPro()?-1:10),l(),h(e.topLinksRows.length>0?11:-1)}}function Gt(t,s){t&1&&(n(0,"div",3)(1,"app-section-title",55),r(2,"Quick Insights"),a(),n(3,"app-card",93)(4,"div",94)(
15,"mat-icon",95),r(6,"hourglass_empty"),a(),n(7,"p",96),r(8," Nothing to see here yet. Check back later to see your insights. "),a()()()()),t&2&&p("@fadeSlideInDelay1",void 0)}function Wt(t,s){if(t&1){let e=b();n(0,"div",81)(1,"button",91),v("click",function(){y(e);let o=d(2);return x(o.openUpgradeDialog())}),n(2,"mat-icon"),r(3,"bolt"),a(),r(4," Upgrade to unlock "),a()()}}function Zt(t,s){if(t&1&&(n(0,"div",3)(1,"app-section-title",55),r(2,"Top Actions"),a(),n(3,"div",78)(4,"div"),f(5,"app-metric-list",97),a(),u(6,Wt,5,0,"div",81),a()()),t&2){let e=d();w("animate-pulse",e.isLoadingTopActions),p("@fadeSlideInDelay3",void 0),l(4),w("blur-sm",!e.isPro()),l(),p("columns",e.actionColumns)("rows",e.topActionsRows),l(),h(e.isPro()?-1:6)}}var Ze=127397,Ye=(()=>{class t{set days(e){e!=null&&(this._days=e,this.initialized&&this.applyDays(e))}constructor(){this.authService=_(N),this.dialog=_(U),this.embedded=!1,this.openAudience=new le,this.isPro=V(!1),this.isLoadingInsights=!0,this.hasLoadedOnce=!1,this.currentFilterDays=H,this._days=H,this.initialized=!1,this.isLoadingTopActions=!1,this.accountFunnel=[],this.topLinksRows=[],this.topActionsRows=[],this.linkColumns=[{key:"views",header:"Views",format:"number",tone:"muted",width:"w-20"}],this.actionColumns=[{key:"completions",header:"Completions",format:"number",tone:"muted",width:"w-24"}],this.isLoadingChart=!1,this.hasChartData=!1,this.chartStatsItems=[],this.hiddenSeries=[],this.allColumns=["date","total_unlocks","total_actions_completed","total_views","conversion_rate","total_emails_captured"],this.displayedColumns=[...this.allColumns],this.chartQueryParams$=new ne({page:0,pageSize:H}),this.columnMapping={Unlocks:"total_unlocks","Actions completed":"total_actions_completed",Views:"total_views","Emails captured":"total_emails_captured","Conversion rate":"conversion_rate"},this.title=_(W),this.socialUnlocksService=_(j),this.trafficAudienceService=_(Ie),this.actionChips=_(Fe),this.router=_(_e),this.cdr=_(re),this.events=_(R),this.sanitizer=_(he),this.destroy$=new ie,this.title.set("Analytics"),this.actionChips.clearState();let e=this.authService.isProUser();this.isPro.set(e),e||(this.displayedColumns=this.allColumns.filter(i=>i!=="total_actions_completed"))}ngOnInit(){this.loadChartData(),this.applyDays(this._days),this.initialized=!0}applyDays(e){this.currentFilterDays=e,this.chartQueryParams$.next({page:0,pageSize:e}),this.loadInsights(e),this.loadTopActions(e)}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}openUpgradeDialog(e="analytics_overlay_locked",i){this.events.upgradeEntryClickedEvent({entry:"dashboard_analytics",trigger:e,context:i}),this.dialog.open($,{backdropClass:"dialog-backdrop",panelClass:"custom-dialog",maxWidth:"800px",data:{source:"dashboard_analytics",trigger:e,context:i,subtitle:"Unlock powerful insights. Get access to extended analytics with a Pro subscription. Cancel anytime."}})}loadInsights(e){this.isLoadingInsights=!0,this.trafficAudienceService.quickInsights(e).pipe(q(this.destroy$)).subscribe({next:i=>{this.quickInsights=i,this.topLinksRows=(i?.topLinks??[]).map(o=>({key:o.slug,label:o.title,icon:o.coverImageUrl?{imageUrl:o.coverImageUrl}:void 0,values:{views:o.count},bar:o.count,data:{slug:o.slug}})),this.isLoadingInsights=!1,this.hasLoadedOnce=!0,this.cdr.markForCheck()},error:i=>{console.error("Error loading insights:",i),this.isLoadingInsights=!1,this.cdr.markForCheck()}})}loadTopActions(e){this.isLoadingTopActions=!0,this.socialUnlocksService.getTopActions(e,5).pipe(q(this.destroy$)).subscribe({next:i=>{this.topActionsRows=i.map(o=>{let c=o.actionType,m=ge[c],g;return typeof m=="string"?g={imageUrl:m}:m&&(g={svgHtml:this.sanitizer.bypassSecurityTrustHtml(Ce(m).html.join(""))}),{key:`${o.actionType}:${o.actionValue}`,label:ve[c]||`Action ${o.actionType}`,sublabel:o.actionValueTitle||o.actionValue,icon:g,values:{completions:o.completions},bar:o.completions}}),this.isLoadingTopActions=!1,this.cdr.markForCheck()},error:i=>{console.error("Error loading top actions:",i),this.isLoadingTopActions=!1,this.cdr.markForCheck()}})}isValidCountryCode(e){return!!e&&e.length===2&&/^[A-Za-z]{2}$/.test(e)}getCountryFlag(e){if(!this.isValidCountryCode(e))return"";let i=e.toUpperCase(),o=i.charCodeAt(0),c=i.charCodeAt(1);return String.fromCodePoint(o+Ze,c+Ze)}getCountryName(e){if(!e)return"Unknown";try{return new Intl.DisplayNames(["en"],{type:"region"}).of(e.toUpperCase())||e}catch{return e}}navigateToAudience(){if(this.embedded){this.openAudience.emit();return}this.router.navigate(["/dashboard/analytics"])}navigateToLink(e){this.router.navigate(["/dashboard/analytics/link",e])}loadChartData(){this.chartQueryParams$.pipe(q(this.destroy$),ae(e=>(this.isLoadingChart=!0,this.cdr.markForCheck(),this.socialUnlocksService.getAnalytics(e)))).subscribe(e=>{this.onAnalyticsFetch(e),this.onTotalStatsChange(e),this.updateChartVisibility(),this.isLoadingChart=!1,this.cdr.markForCheck()})}onAnalyticsFetch(e){if(e.items.length<=0){this.hasChartData=!1;let c=this.chartQueryParams$.value.pageSize??H,m=this.generateDateCategories(c),g=new Array(c).fill(0);this.chartData={series:[{name:"Unlocks",data:g},{name:"Actions completed",data:g},{name:"Views",data:g},{name:"Conversion rate",data:g},{name:"Emails captured",data:g}],categories:m},this.dataSource=new X([]);return}this.dataSource=new X([...e.items].reverse());let i=[{name:"Unlocks",data:e.items.map(c=>c.unlocks)},{name:"Actions completed",data:e.items.map(c=>c.actions_completed)},{name:"Views",data:e.items.map(c=>c.views)},{name:"Conversion rate",data:e.items.map(c=>c.views>0?Math.round(c.unlocks/c.views*100):0)},{name:"Emails captured",data:e.items.map(c=>c.emails_captured)}],o=e.items.map(c=>c.date*1e3);this.chartData={series:i,categories:o},this.hasChartData=!0}
1generateDateCategories(e){let i=[],o=new Date;o.setHours(0,0,0,0);for(let c=e-1;c>=0;c--){let m=new Date(o);m.setDate(m.getDate()-c),i.push(m.getTime())}return i}onTotalStatsChange(e){this.buildAccountFunnel(e);let i=new Map(this.chartStatsItems?.map(o=>[o.label,o.disabled])??[]);this.chartStatsItems=[{label:"Unlocks",value:e.totals.unlocks,type:B.Number,color:"#4ade80",change:e.changes.unlocks,disabled:i.get("Unlocks")},{label:"Actions completed",value:e.totals.actionsCompleted,type:B.Number,color:"#a78bfa",change:e.changes.actionsCompleted,disabled:this.isPro()?i.get("Actions completed"):!0,locked:!this.isPro()},{label:"Views",value:e.totals.views,type:B.Number,color:"#60a5fa",change:e.changes.views,disabled:i.get("Views")},{label:"Conversion rate",value:e.totals.conversionRate,type:B.Percentage,color:"#f472b6",change:e.changes.conversionRate,disabled:i.get("Conversion rate")??!0},{label:"Emails captured",value:e.totals.emailsCaptured,type:B.Number,color:"#f97316",change:e.changes.emailsCaptured,disabled:i.get("Emails captured")??e.totals.emailsCaptured===0}]}buildAccountFunnel(e){let i=e.totals.views,o=m=>i>0?Math.min(100,Math.round(m/i*100)):0,c=[{label:"Views",count:i,pct:100,dropoff:null}];this.isPro()&&c.push({label:"Actions completed",count:e.totals.actionsCompleted,pct:o(e.totals.actionsCompleted),dropoff:null}),c.push({label:"Unlocks",count:e.totals.unlocks,pct:o(e.totals.unlocks),dropoff:null});for(let m=1;m<c.length;m++){let g=c[m-1].count,te=c[m].count;c[m].dropoff=g>0&&te<g?(g-te)/g:null}this.accountFunnel=c}onChartStatCardClick(e){if(e.locked){this.openUpgradeDialog("actions_metric_locked",{metric:e.label});return}e.disabled=!e.disabled,this.updateChartVisibility()}onSeriesVisibilityChange(e){let i=this.chartStatsItems.find(o=>o.label===e.name);i&&!i.locked&&(i.disabled=!e.visible,this.updateChartVisibility())}updateChartVisibility(){this.hiddenSeries=this.chartStatsItems.filter(i=>i.disabled).map(i=>i.label);let e=this.hiddenSeries.map(i=>this.columnMapping[i]).filter(Boolean);this.displayedColumns=this.allColumns.filter(i=>!e.includes(i))}static{this.\u0275fac=function(i){return new(i||t)}}static{this.\u0275cmp=F({type:t,selectors:[["app-dashboard-analytics"]],inputs:{embedded:"embedded",days:"days"},outputs:{openAudience:"openAudience"},decls:17,vars:5,consts:[[1,"max-w-7xl","pb-40"],[1,"mt-2"],[1,"animate-pulse"],[1,"mt-8"],[1,"mt-8","grid","grid-cols-1","gap-8","lg:grid-cols-2",3,"animate-pulse"],[1,"mt-8",3,"animate-pulse"],[1,"mt-8","flex","items-center","gap-1.5","text-[11px]","text-white/30"],[1,"!h-3.5","!w-3.5","!text-[14px]","!leading-none"],["type","button",1,"underline","underline-offset-2","transition-colors","hover:text-white/60",3,"click"],["icon","bar_chart","title","Analytics",3,"titleRoute"],[1,"!px-0","!py-4"],[1,"h-[330px]","px-4","flex","flex-col","justify-between"],[1,"flex-1","flex","flex-col","justify-between","py-4"],[1,"h-px","bg-white/5","w-full"],[1,"flex","justify-between","mt-2"],[1,"h-3","bg-white/10","rounded","w-10"],[1,"mt-4","grid","grid-cols-1","sm:grid-cols-2","lg:grid-cols-4","gap-4"],[1,"flex","items-center","gap-3"],[1,"w-2","h-8","bg-white/10","rounded-full"],[1,"flex-1"],[1,"h-3","bg-white/10","rounded","w-20","mb-2"],[1,"h-6","bg-white/10","rounded","w-16"],[3,"seriesVisibilityChange","queryParams$","data","hiddenSeries","showFilters","showTableToggle","loading"],["stats","",3,"items"],["table","",1,"overflow-x-auto","max-h-[500px]","overflow-y-scroll"],[1,"flex","items-center","justify-center","h-32","text-muted"],["mat-table","",1,"w-full","analytics-table",3,"dataSource","hidden"],["matColumnDef","date"],["mat-header-cell","",4,"matHeaderCellDef"],["mat-cell","",4,"matCellDef"],["matColumnDef","total_unlocks"],["mat-header-cell","","class","!w-28",4,"matHeaderCellDef"],["mat-cell","","class","!w-28",4,"matCellDef"],["matColumnDef","total_views"],["matColumnDef","total_actions_completed"],["mat-header-cell","","class","!w-40",4,"matHeaderCellDef"],["mat-cell","","class","!w-40",4,"matCellDef"],["matColumnDef","total_emails_captured"],["mat-header-cell","","class","!w-36",4,"matHeaderCellDef"],["mat-cell","","class","!w-36",4,"matCellDef"],["matColumnDef","conversion_rate"],["mat-header-row","",4,"matHeaderRowDef","matHeaderRowDefSticky"],["mat-row","","class","cursor-pointer hover:bg-[#2b2b2b]",4,"matRowDef","matRowDefColumns"],["stats","",3,"itemClicked","items"],["mat-header-cell",""],["mat-cell",""],["mat-header-cell","",1,"!w-28"],["mat-cell","",1,"!w-28"],[3,"ngClass"],["mat-header-cell","",1,"!w-40"],["mat-cell","",1,"!w-40"],["mat-header-cell","",1,"!w-36"],["mat-cell","",1,"!w-36"],["mat-header-row",""],["mat-row","",1,"curs
1or-pointer","hover:bg-[#2b2b2b]"],[1,"mb-3"],[1,"flex","flex-col","items-stretch","gap-2","sm:flex-row","sm:gap-3"],[1,"flex-1","rounded-xl","border","border-white/[0.06]","bg-white/[0.02]","p-3"],[1,"flex","items-baseline","justify-between","gap-2"],[1,"truncate","text-xs","font-medium","text-white/50"],[1,"shrink-0","text-[11px]","text-white/40"],[1,"mt-1","text-2xl","font-semibold","text-white"],[1,"mt-2","h-1","w-full","overflow-hidden","rounded-full","bg-white/[0.06]"],[1,"h-full","rounded-full","bg-primary/70","transition-[width]","duration-500"],[1,"mt-1.5","text-[11px]","text-red-400/70"],[1,"flex","shrink-0","items-center","justify-center","text-white/20"],[1,"!h-5","!w-5","!text-[20px]","!leading-none","rotate-90","sm:rotate-0"],[1,"!py-2","animate-pulse"],[1,"flex","flex-col","divide-y","divide-[#333]"],[1,"flex","items-center","gap-3","py-2.5"],[1,"mt-6"],[1,"w-7","h-7","bg-white/10","rounded"],[1,"h-4","bg-white/10","rounded","w-48"],[1,"w-7","h-5","bg-white/10","rounded"],[1,"flex-1","flex","items-center","justify-between","gap-4"],[1,"h-4","bg-white/10","rounded","w-40"],[1,"h-4","bg-white/10","rounded","w-16"],[1,"mt-8","grid","grid-cols-1","gap-8","lg:grid-cols-2"],[1,"relative"],[1,"flex","flex-col"],[1,"group","flex","items-center","gap-2","rounded-lg","px-2","py-2","cursor-pointer","transition-colors","hover:bg-white/[0.03]"],[1,"absolute","inset-0","flex","items-center","justify-center"],[1,"group","flex","items-center","gap-2","rounded-lg","px-2","py-2","cursor-pointer","transition-colors","hover:bg-white/[0.03]",3,"click"],[1,"flex","w-7","flex-shrink-0","items-center","justify-center"],[1,"text-[15px]","leading-none"],[1,"!h-4","!w-4","!text-[16px]","!leading-none","text-white/35"],[1,"min-w-0","flex-grow","truncate","text-[13px]","text-white/85"],[1,"font-medium"],[1,"text-white/40"],[1,"flex","min-w-0","flex-grow","gap-4","truncate","text-[13px]"],[1,"font-medium","text-white/85"],["mat-stroked-button","",3,"click"],["headerLabel","Link",3,"rowClicked","columns","rows","clickable"],[1,"!py-6"],[1,"text-center"],[1,"text-muted","!w-8","!h-8","!text-[32px]","mb-2"],[1,"text-muted"],["headerLabel","Action",3,"columns","rows"]],template:function(i,o){i&1&&(n(0,"div",0),u(1,st,2,1,"div",1)(2,mt,12,3,"div",2)(3,Tt,26,13,"div")(4,Ft,6,0,"div",3)(5,Lt,14,2)(6,Qt,12,13,"div",4)(7,Gt,9,1,"div",3)(8,Zt,7,8,"div",5),n(9,"div",6)(10,"mat-icon",7),r(11,"schedule"),a(),n(12,"span"),r(13," These figures update once a day. "),n(14,"button",8),v("click",function(){return o.navigateToAudience()}),r(15," Audience "),a(),r(16," shows live traffic. "),a()()()),i&2&&(l(),h(o.embedded?-1:1),l(),h(o.chartData?3:2),l(2),h(o.accountFunnel.length>0?4:-1),l(),h(o.isLoadingInsights&&!o.hasLoadedOnce?5:o.quickInsights&&o.quickInsights.totalTraffic>0?6:o.hasLoadedOnce&&!o.isLoadingInsights?7:-1),l(3),h(o.topActionsRows.length>0?8:-1))},dependencies:[L,de,pe,ue,me,fe,Z,Me,G,Q,z,O,Oe,Pe,Ue,He,Re,Le,qe,$e,Be,je,Ne,ye,ze,J,Y],encapsulation:2,data:{animation:[De,Ae,Te,Ee]},changeDetection:0})}}return t})();function Yt(t,s){if(t&1&&(n(0,"div",11),f(1,"app-dashboard-traffic-audience",12),a()),t&2){let e=d();l(),p("isPro",e.isPro())("days",e.days())("showDateFilter",!1)("active",e.selectedIndex()===1)}}function Jt(t,s){if(t&1&&(n(0,"div",11),f(1,"app-analytics-conversions",13),a()),t&2){let e=d();l(),p("isPro",e.isPro())("days",e.days())}}var on=(()=>{class t{onDateSelect(e){let i=this.dateFilters.find(o=>o.filterValue===e);i&&this.onDateClick(i)}constructor(){this.auth=_(N),this.title=_(W),this.dialog=_(U),this.events=_(R),this.isPro=V(!1),this.selectedIndex=V(0),this.dateFilters=[{name:"24 hours",filterValue:1},{name:"7 days",filterValue:7},{name:"30 days",filterValue:30},{name:"6 months",filterValue:180},{name:"1 year",filterValue:365}],this.selectedDate=V(this.dateFilters[2]),this.days=ce(()=>this.selectedDate().filterValue),this.dateOptions=this.dateFilters.map(i=>({value:i.filterValue,label:i.name})),this.title.set("Analytics");let e=this.auth.isProUser();this.isPro.set(e),this.selectedDate.set(e?this.dateFilters[2]:this.dateFilters[1])}onDateClick(e){if(!this.isPro()&&e.filterValue>=30){this.events.upgradeEntryClickedEvent({entry:"analytics_hub",trigger:"analytics_filter_locked",context:{requested_filter_days:e.filterValue}}),this.dialog.open($,{backdropClass:"dialog-backdrop",panelClass:"custom-dialog",maxWidth:"800px",data:{source:"analytics_hub",trigger:"analytics_filter_locked",subtitle:"Unlock powerful insights. Get access to extended analytics with a Pro subscription. Cancel anytime."}});return}this.selectedDate.set(e)}static{this.\u0275fac=function(i){return new(i||t)}}static{this.\u0275cmp=F({type:t,selectors:[["app-analytics-hub"]],decls:12,vars:7,consts:[[1,"max-w-7xl"],[1,"mt-2","flex","flex-col","gap-4","sm:flex-row","sm:items-center","sm:justify-between"],["icon","bar_chart","title","Analytics",3,"titleRoute"],[1,"shrink-0","self-start","sm:self-auto",3,"valueChange","options","value"],["animationDuration","200ms",1,"analytics-hub-tabs","mt-1",3,"selectedIndexChange","selectedIndex","mat-stretch-tabs"],["label","Overview"],[1,"pt-4"],[3,"openAudience","embedded","days"],["label","Audience"],["matTabContent",""],["label","Conversions"],[1,"pt-4","pb-40"],[3,"isPro","days","showDateFilter","active"],[3,"isPro","days"]],template:function(i,o){i&1&&(n(0,"div",0)(1,"div",1),f(2,"app-module-title",2),n(3,"app-segmented-control",3),v("valueChange",function(m){return o.onDateSelect(m)}),a()(),n(4,"mat-tab-group",4),v("selectedIndexChange",function(m){return o.selectedIndex.set(m)}),n(5,"mat-tab",5)(6,"div",6)(7,"app-dashboard-analytics",7),v("openAudience",function(){return o.selectedIndex.set(1)}),a()()(),n(8,"mat-tab",8),u(9,Yt,2,4,"ng-template",9),a(),n(10,"mat-tab",10),u(11,Jt,2,2,"ng-template",9),a()()()),i&2&&(l(2),p("titleRoute",void 0),l(),p("options",o.dateOptions)("value",o.selectedDate(
1).filterValue),l(),p("selectedIndex",o.selectedIndex())("mat-stretch-tabs",!1),l(3),p("embedded",!0)("days",o.days()))},dependencies:[L,Se,be,we,ke,Z,xe,Ye,Ve,We],encapsulation:2})}}return t})();export{on as AnalyticsHubComponent};
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.