1var ye=Object.defineProperty;var je=(u,j,t)=>j in u?ye(u,j,{enumerable:!0,configurable:!0,writable:!0,value:t}):u[j]=t;var p=(u,j,t)=>je(u,typeof j!="symbol"?j+"":j,t);import{a as b,j as e}from"./vendor.react.xX5OaRB0.js";import{P as o}from"./vendor.commons.Krup8qXf.js";import{u as Ce,c as ce}from"./vendor.redux.Bi9BTFkI.js";import{L as Se}from"./vendor.router.U73PX5Em.js";import{l as we,B as _}from"./vendor.ui-extras.D5KyEMxS.js";import{R as M,b as V,U as Ne,M as Ae,B as z,e as ke}from"./vendor.ui-core.Dao_ArY3.js";import{d as I,v as oe}from"./vendor.utils.DcRJ3SBO.js";import{A as De}from"./ArchiveEntities.DSiXIeto.js";import{z as Ie,p as ee,C as $e,B as Z,g as Te}from"./index.-5-0O7z1.js";import{S as te}from"./infoImg.DSYRDO9b.js";import{g as L,w as le,q as Pe,at as se,f as ie,x as ae,a as Re,B as Ee,aw as ze,ak as Le,T as re}from"./app.ClmmUuYS.js";import{D as Me}from"./DateRangePickerCalendar.C6UMlaFJ.js";import{E as Ue}from"./ExportStats.Bl7xuhiK.js";import{g as qe,d as Be,a as Oe,c as Fe,C as Ve,f as We,R as He}from"./revenue-icon.BOjOHseY.js";import{D as Ke,S as _e}from"./StatusModal.BdtiBPHR.js";import{w as G,u as de}from"./vendor.i18n.DLKhcqJc.js";import{T as Ze}from"./[email protected]_T31-J.js";import{R as Ge}from"./index.shXld68j.js";import{G as ne}from"./GeneralStatisticItem.b4aW8UTq.js";import{L as Je}from"./Layout.B9z3w6v1.js";import{A as Ye}from"./AccountManager.W1YcSplL.js";import{a as Qe}from"./CopyEntities.D19HK0aZ.js";import{S as Xe}from"./checkbox_check_icon.CiTh8aCD.js";import{c as et}from"./checkCurrencyFromRequest.D2Yto29c.js";import{d as tt}from"./adGroupCreate.D4_CD-cz.js";import"./vendor.polyfills.DYhgmCsW.js";import"./vendor.monitoring.BDs9VX6O.js";import"./vendor.export.BsSCz_t6.js";import"./prepareTableHeaders.BscFGWqS.js";import"./trash_red_icon.CJoOY0QI.js";import"./TableStat.DIAGhgE1.js";import"./ConfirmActionModal.jTreZSrI.js";import"./TopNavbar.BZEgptjt.js";const st=(u="week")=>[{key:"day",value:{from:I(),to:I()},selected:u==="day"},{key:"week",value:{from:I().subtract(6,"days"),to:I()},selected:u==="week"},{key:"month",value:{from:I().subtract(30,"days"),to:I()},selected:u==="month"}];class me extends b.Component{constructor(t){super(t);p(this,"setExportData",(t,s)=>{const{dataToExport:r}=this.state;this.setState({dataToExport:{...r,[s]:t}})});p(this,"checkIsExportDataDisabled",t=>((n,i)=>i.every(a=>Object.prototype.hasOwnProperty.call(n,a)&&Array.isArray(n[a])&&n[a].length===0))(t,["spent-per-creative"]));p(this,"getDailyStatisticsData",()=>{this.createSignalAndController();const{creativeId:t}=this.props;if(!oe.isMongoId(t))return null;this.setState({isLoading:!0});const{dates:s}=this.state;let r="1d";s.to.diff(s.from,"days")<2&&(r="1h"),L("/api/owner-statistics/detailed-daily-statistics/creative?id=".concat(t,"\n &groupBy=").concat(r,"&fromDate=").concat(s.from,"&toDate=").concat(s.to),{signal:this.signal}).then(n=>(n.success&&this.setState({dailyStatisticsData:{items:n.data,timePeriod:r},isLoading:!1}),this.setState({isLoading:!1}))).catch(n=>{console.error(n)})});p(this,"handleDateSelect",({startDate:t,endDate:s,isCalendarChange:r})=>{this.setState({dates:{from:t,to:s},periods:this.state.periods.map(n=>({...n,selected:r?!1:n.selected}))})});p(this,"handlePeriodChange",t=>{const{periods:s}=this.state,r=s.map(n=>({...n,selected:n.key===t.key}));this.setState({periods:r,dates:t.value})});p(this,"createSignalAndController",()=>{this.controller&&this.controller.abort(),this.controller=new AbortController,this.signal=this.controller.signal});const{t:s}=t;this.state={dates:{from:I().subtract(6,"days"),to:I()},periods:st("week"),dailyStatisticsData:{items:[],timePeriod:"1d"},dataToExport:{},isLoading:!1},this.controller=new AbortController,this.signal=this.controller.signal}componentDidMount(){this.getDailyStatisticsData()}componentDidUpdate(t,s){(JSON.stringify(s.dates)!==JSON.stringify(this.state.dates)||t.creativeId!==this.props.creativeId)&&this.getDailyStatisticsData()}componentWillUnmount(){this.controller&&this.controller.abort()}render(){const{dates:t,periods:s,isLoading:r,dataToExport:n}=this.state,{isInternal:i,creativeId:a,t:m}=this.props,f=s.map(S=>({...S,name:m("statistics.".concat(S.key),{ns:"Account/Common"})}));return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"creative-statistics",children:[e.jsxs("div",{className:"creative-statistics-header",children:[e.jsxs("div",{className:"creative-statistics-header-datepicker-wrapper",children:[e.jsx(Me,{dates:t,onDatesSelect:this.handleDateSelect,isMaxRange:!0,maxRangePerDays:90,isNewStyle:!0}),e.jsx(qe,{handleChange:this.handlePeriodChange,data:f,isNewStyle:!0})]}),e.jsx("div",{children:e.jsx(Ue,{isLoading:r,url:"".concat(te.CREATIVE,"s/list?").concat(i?"by=creative&id=".concat(a):"by=user"),dataPrepared:n,isBlueExportIcon:!0,disabled:this.checkIsExportDataDisabled(n)})})]}),e.jsx(M,{className:"creative-statistics-wrapper",children:e.jsx(V,{xs:12,className:"creative-statistics-row",children:e.jsx(Ke,{entityId:a,statisticsBy:te.CREATIVE,dates:t,setExportData:S=>this.setExportData(S,"spent-per-creative")})})})]})})}}p(me,"propTypes",{creativeId:o.string.isRequired,isInternal:o.bool.isRequired,selectedCurrency:o.string.isRequired,t:o.func.isRequired,i18n:o.object});const it=G(["Account/Creative","Account/Common"])(me),at={responsive:"adTypes.responsiveAd",image:"adTypes.imageAd",html5:"adTypes.html5Ad",playable:"adTypes.playableAd",text:"adTypes.textAd",pop:"adTypes.popAd",video:"adTypes.videoAd"},rt="/app/react/images/copy_white_icon.YO9B_tot.svg",pe=({data:u})=>{const{isActive:j,status:t,type:s,clickUrl:r,adSizes:n,previewData:i}=u,{t:a}=de(["Account/Creative","Account/Common"]),m=d=>{if(!d)return"";const l=at[String(d).trim().toLowerCase()];return(l?a(l,{ns:"Account/Creative"}):d).toUpperCase()},f=d=>d?{"Not active":a("common.notActive",{ns:"Account/Common"}),"Limit reached":a("common.limitReached",{ns:"Account/Common"}),"Low balance":a("common.lowBalance",{ns:"Account/Common"}),"Pending approval":a("common.pendingApproval",{ns:"Account/Common"}),Rejected:a("common.rejected",{ns:"Account/Common"}),"Wait top up":a("common.waitTopUp",{ns:"Account/Common"}),"Wait top up campaign":a("common.waitTopUpCampaign",{ns:"Account/Common"}),Active:a("common.active",{ns:"Account/Common"}),Stopped:a("common.stopped",{ns:"Account/Common"})}[d]||d:"",S=()=>_.success(a("common.copiedToClipboard",{ns:"Account/Common"}),{autoClose:2e3}),h=b.useMemo(()=>{const d=["image","html5","video","playable"].includes(s)?i.images:n,l=[{title:a("common.status",{ns:"Account/Common"}),content:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"entity-info-item-status".concat(j?" active":"")}),f(t)]})},...s!=="pop"?[{title:d.length===1?a("size",{ns:"Account/Creative"}):a("sizes",{ns:"Account/Creative"}),value:d.length===1||s==="DSP"?i.names[0]:e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("span",{children:a("multiple",{ns:"Account/Creative"})}),e.jsx("span",{id:"ad-sizes",className:"ad-quantity",children:d.length})]}),e.jsx(Ze,{id:"ad-sizes",text:e.jsxs("div",{className:"entity-creative-tooltip-wrapper",style:{textAlign:"start"},children:[e.jsx("b",{className:"entity-creative-tooltip-title mb-1",children:a("sizes",{ns:"Account/Creative"})}),d.map(({width:v,height:x})=>e.jsx(e.Fragment,{children:e.jsxs("p",{children:[v,"x",x]})}))]}),title:a("sizes",{ns:"Account/Creative"}),placement:"bottom",isCustomToolTipDesign:!0,isNarrow:!0,className:"white-smoke-theme"})]}),id:"ad-sizes"}]:[],...s!=="DSP"?[{title:a("adFormat",{ns:"Account/Creative"}),value:m(s)},{title:a("clickUrl",{ns:"Account/Creative"}),value:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"entity-info-item-url",children:e.jsx("p",{id:"link-text",className:"link-text",children:e.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:r})})}),e.jsx(Ne,{className:"entity-creative-tooltip",innerClassName:"inner
1-item text-left",placement:"bottom-start",target:"ad-click-url",children:r})]}),isWide:!0,id:"ad-click-url",AdditionalContent:({isMobile:v=!1})=>e.jsxs("div",{children:[v&&e.jsx("div",{className:"entity-info-item-url",children:e.jsx("p",{id:"link-text",className:"link-text",children:e.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:r})})}),e.jsx(we.CopyToClipboard,{text:r,onCopy:S,children:e.jsx("div",{className:"copy-icon-wrapper",children:e.jsx("img",{src:rt,alt:"copy button",width:"20",height:"20",className:"copy-btn-icon"})})})]})}]:[]];return{desktop:l.reduce((v,x,w)=>(w%4===0?v.push([x]):v[v.length-1].push(x),v),[]),mobile:l}},[j,t,s,r,n,i,a]);return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"entity-info",children:[s!=="DSP"&&e.jsx("hr",{className:"border-line mb-4"}),e.jsx("div",{className:"entity-info-desktop-wrapper",children:h.desktop.map((d,l,v)=>e.jsx("div",{className:"entity-info-desktop-row".concat(v.length-1===l?" left-content":""),children:d.map(({title:x,value:w,content:$,AdditionalContent:T,isWide:g,id:k})=>e.jsxs("div",{className:"entity-info-item".concat(g?" wider":""),id:k,children:[e.jsxs("div",{className:"entity-info-item-text",children:[e.jsx("span",{className:"entity-info-item-title",children:x}),e.jsxs("div",{className:"entity-info-item-value",children:[!$&&w,!!$&&$]})]}),!!T&&e.jsx(T,{})]},x))},"row-infoData-".concat(l)))}),e.jsx("div",{className:"entity-info-mobile-wrapper",children:h.mobile.map(({title:d,value:l,content:v,AdditionalContent:x,isAlignItemsMobileStart:w})=>e.jsxs("div",{className:"entity-info-mobile-item".concat(w?" align-items-start":""),children:[e.jsx("span",{className:"entity-info-mobile-item-title",children:d}),e.jsxs("div",{className:"entity-info-mobile-item-value",children:[!x&&!v&&l,!x&&!!v&&v,!!x&&e.jsx(x,{isMobile:!0,isValueShown:!0})]})]},"".concat(d,"mobile")))})]})})};pe.propTypes={data:o.shape({campaign:o.object,group:o.object,creative:o.object,isActive:o.bool,status:o.string,type:o.string,clickUrl:o.string,adSizes:o.object,previewData:o.object}).isRequired,entityType:o.oneOf(["campaign","group","creative"]).isRequired,isDSPAdvertiser:o.bool,additionalHandlers:o.shape({changeLimit:o.func}),isMobile:o.bool};const nt=le(pe),he=({isModalOpen:u,onClose:j,children:t,adaptive:s=!1})=>e.jsxs(Ae,{isOpen:u,toggle:j,centered:!0,size:"lg",className:"zoom-preview-modal",contentClassName:"zoom-preview-content".concat(s?" adaptive":""),children:[e.jsx("div",{className:"zoom-preview-header",children:e.jsx("div",{children:e.jsx(z,{className:"close",color:"link",onClick:j,children:e.jsx("img",{src:Pe,alt:"close",width:"16",height:"16"})})})}),e.jsx(ke,{children:e.jsx("div",{className:"iframe-wrapper w-100",children:t})})]});he.propTypes={isModalOpen:o.bool.isRequired,onClose:o.func.isRequired,children:o.node.isRequired,adaptive:o.bool};const ue=({children:u=[],previewData:j={},type:t="",changeActiveItemIndex:s=null,clickUrl:r=""})=>{const{t:n}=de("Account/Creative"),[i,a]=b.useState(0),[m,f]=b.useState(!1),[S,h]=b.useState(!1),d=Ce(c=>c.main.device),l=b.useRef(null),v=b.useRef(!0),x=b.useRef(null),w=b.useRef(null),$=b.useRef(null),T=b.useRef(null),{names:g=[],images:k=[],title:D,description1:W,description2:P,displayUrl:U,headline:H,description:E,businessName:K,logo:q,background:B}=j,C=()=>{var y,N;const c=document.querySelectorAll(".slide-wrapper");if(c.length){c.forEach(F=>{F.classList.add("hidden")});const R=(y=l==null?void 0:l.current.getPos())!=null?y:0;(N=c[R])==null||N.classList.remove("hidden")}},A=c=>{[x.current,w.current,$.current,T.current].forEach(N=>{N instanceof HTMLElement&&(N.classList.toggle("disabled",c),N.disabled=c,c?N.setAttribute("disabled","true"):N.removeAttribute("disabled"))})},fe={continuous:!0,auto:v.current?3e3:0,transitionEnd(){A(!1),a(l.current.getPos())},callback(){C()},startSlide:i,speed:2200};b.useEffect(()=>{const c=setTimeout(()=>{C()},1e3);return()=>{clearTimeout(c)}},[]),b.useEffect(()=>{const c=()=>{v.current=!1};let y=null;const N=document.querySelectorAll(".creative-statistics-item");return N.length&&N.forEach(R=>{var F;R.contains((F=l==null?void 0:l.current)==null?void 0:F.containerEl)&&(y=R,y.addEventListener("click",c,{once:!0}))}),()=>{y&&y.removeEventListener("click",c)}},[]);const J=()=>f(!m),O=b.useCallback(()=>{var y;const c=document.querySelector(".slide-wrapper:not(.hidden)");return(y=c==null?void 0:c.querySelector("video"))!=null?y:null},[]);b.useCallback(()=>{const c=O();c&&(c.paused?(c.play(),h(!0)):(c.pause(),h(!1)))},[O]),b.useEffect(()=>{if(t!=="video")return;h(!1);const c=O();c&&c.pause()},[i,t,O]);const Y=g[i]&&g[i].length>12?"".concat(g[i].slice(0,12),"..."):g[i];b.useEffect(()=>{s&&(s(i),C())},[i]);const xe=b.useMemo(()=>{var R;const c=(R=g[i])==null?void 0:R.split("x"),y=c?Number(c[1]):280,N=y>640?640:y;return"".concat(N,"px")},[g,i]),be=()=>{var c,y;switch(t){case"text":return{displayurl:U,description2:P,title:D,description1:W};case"responsive":return{headline:H,description:E,businessName:K,media:{logo:q,background:B}};case"image":return{imageUrl:k[i].src};case"html5":case"playable":return{url:k[i].src};case"video":return{videoUrl:((c=k[i])==null?void 0:c.src)||"",fallbackImageUrl:((y=k[i])==null?void 0:y.fallbackImageUrl)||""};default:return{}}},Q=()=>{var c;A(!0),(c=l.current)==null||c.next()},X=()=>{var c;A(!0),(c=l.current)==null||c.prev()};return e.jsxs("div",{className:"previews-carousel-container",children:[e.jsxs("div",{className:"img-preview-wrapper",children:[e.jsx(Ge,{childCount:u.length,className:"carousel",swipeOptions:fe,ref:l,children:u}),t!=="video"&&e.jsx("div",{className:"zoom-icon-wrapper",onClick:J,children:e.jsx("img",{src:Ie,alt:"zoom",width:"20",height:"20"})})]}),e.jsx("hr",{className:"border-line header-block"}),e.jsxs("div",{className:"swipe-btn-wrapper",children:[e.jsx(z,{innerRef:w,className:i?"swipe-btn":"swipe-btn disabled",color:"primary",disabled:!i,onClick:X,children:e.jsx("div",{children:e.jsx("img",{src:ee,alt:"previous",width:"12",height:"20"})})}),e.jsxs("div",{className:"preview-info",children:[e.jsx("p",{className:"preview-info-banner-size",children:Y}),e.jsxs("p",{className:"preview-info-banner-number",children:[i+1," of ",g.length]})]}),e.jsx(z,{innerRef:T,className:i===g.length-1?"swipe-btn disabled":"swipe-btn",color:"primary",disabled:i===g.length-1,onClick:Q,children:e.jsx("div",{children:e.jsx("img",{src:se,alt:"next",width:"12",height:"20"})})})]}),e.jsx(he,{onClose:J,isModalOpen:m,adaptive:!0,children:t&&g&&g[i]&&["text","responsive","html5","playable","image","video"].includes(t)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"banner-slide-preview-header",children:[e.jsxs("div",{className:"banner-slide-preview-title",children:[e.jsx("span",{className:"banner-slide-preview-title-bold",children:n("adPreview")}),d!=="mobile"&&" / ".concat(i+1," of ").concat(g.length)]}),d!=="mobile"&&e.jsx("div",{className:"banner-slide-preview-sizes",children:e.jsx("div",{className:"swipe-btn-wrapper",children:e.jsx($e,{adSizes:g.map(c=>({width:c.split("x")[0],height:c.split("x")[1]}
1)),currentSize:{width:g[i].split("x")[0],height:g[i].split("x")[1]},selectAdSize:({width:c,height:y})=>a(g.indexOf("".concat(c,"x").concat(y))),minimalistic:!0})})})]}),e.jsx("div",{className:"modal-banner-slide-preview",style:{height:d==="mobile"||t==="video"?"auto":xe,minHeight:t==="video"?"360px":void 0},children:e.jsx(Z,{bannerType:t,data:{clickurl:r,...be()},currentAdSize:{width:g[i].split("x")[0],height:g[i].split("x")[1]},isActive:m,additionalContainerClassName:"w-100 h-100"},g[i])}),d==="mobile"&&e.jsxs("div",{className:"swipe-btn-wrapper",children:[e.jsx(z,{innerRef:x,className:i?"swipe-btn":"swipe-btn disabled",color:"primary",disabled:!i,onClick:X,children:e.jsx("div",{children:e.jsx("img",{src:ee,alt:"previous",width:"12",height:"20"})})}),e.jsxs("div",{className:"preview-info",children:[e.jsx("p",{className:"preview-info-banner-size",children:Y}),e.jsxs("p",{className:"preview-info-banner-number",children:[i+1," of ",g.length]})]}),e.jsx(z,{innerRef:$,className:i===g.length-1?"swipe-btn disabled":"swipe-btn",color:"primary",disabled:i===g.length-1,onClick:Q,children:e.jsx("div",{children:e.jsx("img",{src:se,alt:"next",width:"12",height:"20"})})})]})]})})]})};ue.propTypes={children:o.node.isRequired,previewData:o.object.isRequired,type:o.string.isRequired,changeActiveItemIndex:o.func,clickUrl:o.string};const ct=u=>({device:u.main.device});class ve extends b.Component{constructor(t){super(t);p(this,"getInitialData",()=>{const{t}=this.props;return[{name:t("statistics.today",{ns:"Account/Common",defaultValue:"Today"}),value:0},{name:t("statistics.lastWeek",{ns:"Account/Common",defaultValue:"Last week"}),value:0,diff:0},{name:t("statistics.lastMonth",{ns:"Account/Common",defaultValue:"Last month"}),value:0,diff:0}]});p(this,"getInitialState",()=>{const{t}=this.props,s=this.getInitialData();return[{title:t("statistics.clicks",{ns:"Account/Common",defaultValue:"Clicks"}),titleKey:"Clicks",icon:Oe,activeIcon:Be,data:s},{title:t("statistics.ctr",{ns:"Account/Common",defaultValue:"CTR"}),titleKey:"CTR",icon:Ve,activeIcon:Fe,data:s},{title:t("statistics.spent",{ns:"Account/Common",defaultValue:"Spent"}),titleKey:"Spent",icon:He,activeIcon:We,data:s}]});p(this,"getStatisticsData",async()=>{const{t}=this.props,s=[{days:0,option:t("statistics.today",{ns:"Account/Common",defaultValue:"Today"}),prevPeriod:!1},{days:7,option:t("statistics.lastWeek",{ns:"Account/Common",defaultValue:"Last week"}),prevPeriod:!0},{days:30,option:t("statistics.lastMonth",{ns:"Account/Common",defaultValue:"Last month"}),prevPeriod:!0}];await Promise.all(s.map(({days:r,option:n,prevPeriod:i}
1)=>this.getStatisticsByPeriod(r,n,i)))});p(this,"getStatisticsByPeriod",async(t,s,r)=>{const n="getStatisticsByPeriod-".concat(t);this.createSignalAndController(n),this.setState({isLoading:!0});const{creativeId:i}=this.props,a=ie(I().subtract(t,"days")),m=ie(I());try{const f=await L("/api/creatives/creative-clicks-charge-statistics?id=".concat(i,"&fromDate=").concat(a,"&toDate=").concat(m).concat(r?"&prevPeriod=1":""),{signal:this.signals[n]});if(f.success){const S=(d,l)=>{if(!l)return 0;switch(d){case"Clicks":return l.clicks||0;case"CTR":return ae(l.clicks/l.impressions*100,3)||0;case"Spent":return ae(l.charge,2)||0;default:return null}},h=this.state.data.map(d=>{const l=S(d.titleKey,f.data),v=S(d.titleKey,f.data.previosData),x=d.data.map(w=>w.name===s?{...w,value:l,...r?{diff:this.getDiff(l,v)}:{}}:w);return{...d,data:x}});this.setState({data:h})}}catch(f){console.error(f)}finally{this.setState({isLoading:!1})}});p(this,"createSignalAndController",t=>{this.controllers[t]&&this.controllers[t].abort(),this.controllers[t]=new AbortController,this.signals[t]=this.controllers[t].signal});p(this,"getDiff",(t,s)=>{if(t===s)return"0.00";if(!s)return"+100.00";const r=t/s*100-100;return r>100?"+100.00":r.toFixed(2)});p(this,"setActiveType",t=>this.setState({currentStatisticsDataIdx:t}));this.state={data:[],currentStatisticsDataIdx:0,isLoading:!0,error:""},this.controllers={},this.signals={}}componentDidMount(){this.setState({data:this.getInitialState()}),this.getStatisticsData()}componentDidUpdate(t,s){this.props.creativeId!==t.creativeId&&this.getStatisticsData(),t.t!==this.props.t&&this.setState({data:this.getInitialState()},()=>{this.getStatisticsData()})}componentWillUnmount(){Object.keys(this.controllers).forEach(t=>{this.controllers[t]&&this.controllers[t].abort()})}render(){const{isLoading:t,data:s,currentStatisticsDataIdx:r}=this.state,{device:n,t:i}=this.props,a=s[r];return e.jsxs("div",{className:"creative-item-wrapper h-100",children:[n==="mobile"&&a&&e.jsxs("div",{children:[e.jsx("div",{className:"creative-item-head mb-3",children:e.jsx("p",{className:"block-title",children:i("creativeStatistics",{ns:"Account/Creative",defaultValue:"Creative statistics"})})}),e.jsx(M,{className:"g-0 statistics-banners-wrapper",children:e.jsx("div",{className:"column-head-statistics-mobile",children:s.map((m,f)=>e.jsx("div",{className:"item-type-mobile",children:e.jsxs("button",{className:"button-type-mobile".concat(f===r?" active":""),onClick:()=>this.setActiveType(f),children:[e.jsx("img",{className:"img-type",src:f===r?m.activeIcon:m.icon,width:"23",alt:"".concat(m.title,"-icon")}),e.jsx("p",{className:"block-title",children:m.title})]})},f))})}),e.jsx(ne,{data:a.data,name:a.title,metricKey:a.titleKey,icon:a.icon,isLoading:t,isMobile:!1})]}),n!=="mobile"&&e.jsxs("div",{className:"creative-statistics-item",children:[e.jsx("div",{className:"creative-item-head",children:e.jsx("p",{className:"block-title",children:i("creativeStatistics",{ns:"Account/Creative",defaultValue:"Creative statistics"})})}),e.jsx("hr",{className:"border-line header-block mb-4"}),e.jsx(M,{className:"g-0 statistics-banners-wrapper",children:s.map(m=>e.jsx("div",{className:"column-head-statistics",children:e.jsx(ne,{data:m.data,name:m.title,metricKey:m.titleKey,icon:m.icon,isLoading:t,isMobile:!1})},m.title))})]})]})}}p(ve,"propTypes",{creativeId:o.string.isRequired,isInternal:o.bool.isRequired,selectedCurrency:o.object.isRequired,device:o.string.isRequired,t:o.func.isRequired});const ot=ce(ct)(G(["Account/Creative","Account/Common"])(ve)),lt=u=>({currencies:u.entity.currencies,isDSPAdvertiser:!!u.auth.user.isDSPAdvertiser,device:u.main.device,language:u.language.current});class ge extends b.Component{constructor(t){super(t);p(this,"checkData",()=>{const{id:t}=this.props.match.params,{t:s}=this.props;if(t&&!oe.isMongoId(t))return this.setState({notFoundError:s("creativeNotFound")});this.getCreativeData()});p(this,"fetchCreativeSizes",async()=>{const{type:t}=this.state,s="fetchCreativeSizes";this.createSignalAndController(s),this.setState({isLoading:!0});try{const r=await L("/api/creatives/available-sizes?type=".concat(t.toLowerCase()),{signal:this.signals[s]});return r.success?this.setState({adSizes:r.data}):_.error(r.error)}catch(r){console.error(r)}finally{this.setState({isLoading:!1})}});p(this,"getCreativeData",()=>{const t="getData";this.createSignalAndController(t),this.setState({isLoading:!0});const{id:s}=this.props.match.params;L("/api/creatives/creative-info?id=".concat(s),{signal:this.signals[t]}).then(r=>{if(r.success){const{data:n}=r;return et(n.currency),this.setState({campaign:{name:n.campaignName,id:n.campaignId},adgroup:{name:n.groupName,id:n.groupId,isSmart:n.details.groupBidStrategy==="smart"},name:n.details.title,isActive:n.active,status:tt({...n,isEntityPage:!0},!0),type:n.adType,isInternal:n.isInternal,isArchived:n.isArchived,clickUrl:n.details.clickurl,previewData:this.preparePreviewData(n)})}}).catch(r=>{console.error(r)}).finally(()=>this.setState({isLoading:!1}))});p(this,"preparePreviewData",t=>{const{details:s,imageMediaUrl:r}=t;let n={};switch(t.adType){case"DSP":n={title:s.title,names:s.viewSizes.map(({width:i,height:a})=>"".concat(i,"x").concat(a)),images:s.viewSizes.map(({width:i,height:a})=>({name:"".concat(i,"x").concat(a),width:i,height:a}))};break;
1case"text":n={title:s.title,description1:s.description1,description2:s.description2,displayUrl:s.displayurl};break;case"responsive":n={headline:s.headline,description:s.description1,businessName:s.businessName,logo:"".concat(r).concat(s.logo.imgId),background:"".concat(r).concat(s.background.imgId)};break;case"image":n={images:Object.values(s.images||{}).map(i=>({name:"".concat(i.imgWidth,"x").concat(i.imgHeight," px"),src:"".concat(r).concat(i.imgId),width:i.imgWidth,height:i.imgHeight})),names:Object.values(s.images||{}).map(i=>"".concat(i.imgWidth,"x").concat(i.imgHeight))};break;case"html5":case"playable":n={images:s.viewSizes.map(({width:i,height:a})=>({name:"".concat(i,"x").concat(a),src:"".concat(r).concat(s.html5Directory,"/index.html"),width:i,height:a})),names:s.viewSizes.map(({width:i,height:a})=>"".concat(i,"x").concat(a))};break;case"video":n={images:(s.viewSizes||[]).map(({width:i,height:a})=>{var m,f,S;return{name:"".concat(i,"x").concat(a),src:((m=s.video)==null?void 0:m.url)||"",fallbackImageUrl:((S=(f=s.fallbackImages)==null?void 0:f[Te({width:i,height:a})])==null?void 0:S.url)||"",width:i,height:a}}),names:(s.viewSizes||[]).map(({width:i,height:a})=>"".concat(i,"x").concat(a))};break;default:n={...s};break}return n});p(this,"handleStatusChange",()=>{const t="handleStatusChange";this.createSignalAndController(t),this.setState({isLoading:!0});const{shouldChangeToActive:s}=this.state,{id:r}=this.props.match.params;L("/api/creatives/activate-creative",{method:"POST",body:JSON.stringify({id:r,isActive:s}),signal:this.signals[t]}).then(i=>i.success?this.getCreativeData():(_.error(i.error),this.setState({error:i.error}))).catch(i=>{console.error(i)}).finally(()=>this.setState({isConfirmActionModalOpen:!1,isLoading:!1}))});p(this,"handleConfirmActionModalOpen",({target:t})=>{this.setState({isConfirmActionModalOpen:!0,shouldChangeToActive:t.checked})});p(this,"handleConfirmActionModalClose",()=>this.setState({isConfirmActionModalOpen:!1}));p(this,"handleCopyCreative",()=>{const{history:t,language:s}=this.props,r=re(s);t.push("".concat(r,"/app/adv/adgroups/").concat(this.state.adgroup.id,"/creatives"))});p(this,"chackIsDisabledToRun",()=>{var i;const{currencies:t}=this.props,{type:s,previewData:r}=this.state,n=t.find(a=>a.selected);return s==="image"?!((i=r==null?void 0:r.images)!=null&&i.length):n.actionsDisabled});p(this,"getBannerSrcProp",(t,s)=>t==="image"?{imageUrl:s}:t==="video"?{videoUrl:s}:{url:s});p(this,"createSignalAndController",t=>{this.controllers[t]&&this.controllers[t].abort(),this.controllers[t]=new AbortController,this.signals[t]=this.controllers[t].signal});p(this,"changeCurrentPreviewIndex",t=>this.setState({currentPreviewIndex:t}));this.state={campaign:{id:"",name:""},adgroup:{id:"",name:""},name:"",isActive:!1,status:"",type:"",isInternal:!1,isArchived:null,clickUrl:"",previewData:{headline:"",description:"",businessName:"",logo:"",background:""},isConfirmActionModalOpen:!1,shouldChangeToActive:!1,isLoading:!0,error:"",notFoundError:"",adSizes:[],currentPreviewIndex:0},this.URL="/app/adv/creatives/",this.controllers={},this.signals={}}componentDidMount(){this.checkData()}componentDidUpdate(t,s){const{type:r}=this.state;this.props.match.params.id!==t.match.params.id&&this.checkData(),r&&r!==s.type&&!["dsp","pop","video"].includes(r.toLowerCase())&&this.fetchCreativeSizes()}componentWillUnmount(){Object.keys(this.controllers).forEach(t=>{this.controllers[t]&&this.controllers[t].abort()})}render(){var q,B;const{campaign:t,adgroup:s,name:r,isActive:n,status:i,type:a,clickUrl:m,isInternal:f,isArchived:S,previewData:h,isConfirmActionModalOpen:d,isLoading:l,notFoundError:v,adSizes:x,currentPreviewIndex:w}=this.state,{history:$,match:T,currencies:g,isDSPAdvertiser:k,t:D,language:W}=this.props,P=T.params.id,U=re(W),H=[{url:"/app/adv/dashboard",label:D("common.home",{ns:"Account/Common"})},{url:"/app/adv/campaigns",label:D("common.campaigns",{ns:"Account/Common"})},{url:"/app/adv/campaigns/".concat(t.id),label:t.name||D("campaign")},{url:"/app/adv/adgroups/".concat(s.id),label:s.name||D("adGroup")},{label:r}],E=g.find(C=>C.selected),K=this.chackIsDisabledToRun();return e.jsx(Je,{children:e.jsxs("div",{className:"creative-container",children:[v&&e.jsx("h4",{className:"pt-3",children:v}),!v&&l&&S===null&&e.jsx("div",{className:"loader-container",children:e.jsx(Re,{isAbsolute:!0})}),!v&&!l&&S&&e.jsx("h5",{className:"pt-3",children:D("archivedNotAvailable",{defaultValue:"This page is not available for ar
1chived creatives"})}),!v&&S===!1&&e.jsxs(b.Fragment,{children:[e.jsxs("div",{className:"nav-items-wrapper flex-column align-items-start align-items-lg-center flex-lg-row justify-content-lg-between",children:[e.jsx(Ee,{data:H}),e.jsx(Ye,{isNewStyle:!0})]}),e.jsxs("div",{className:"creative-header",children:[e.jsxs("div",{className:"creative-header-top",children:[e.jsxs("div",{className:"creative-header-title-wrapper",children:[e.jsx(Xe,{disabled:K,isChecked:n,onChange:this.handleConfirmActionModalOpen,isNewStyle:!0}),e.jsx("h1",{className:"creative-header-title",children:r})]}),e.jsx("span",{className:"creative-header-image"})]}),e.jsx(nt,{data:{isActive:n,status:i,adSizes:x,type:a,clickUrl:m,previewData:h}})]}),e.jsxs("div",{className:"creative-statistics",children:[e.jsxs(M,{className:"creative-statistics-row",children:[e.jsx(V,{xs:12,className:"creative-statistics-column col-12 col-md-5",children:e.jsxs("div",{className:"creative-statistics-item".concat(a==="DSP"?" dsp":""),children:[e.jsx("div",{className:"creative-item-head d-flex",children:e.jsxs("div",{className:"actions-container",children:[e.jsxs("div",{className:"action-buttons",children:[e.jsx("div",{className:"modify-link-wrapper",children:e.jsxs(Se,{to:"".concat(U,"/app/adv/add-entity/addcreative/creative/").concat(s.id,"/").concat(P),state:{entityName:s.name,campaign:{name:t.name,id:t.id}},className:"modify-link ".concat(E.actionsDisabled?"disabled-link":""),children:[e.jsx("img",{src:l?ze:Le,alt:"modify",width:"23",height:"23",className:"modify-link-icon"}),e.jsx("span",{className:"modify-link-text",children:D("common.edit",{ns:"Account/Common"})})]})}),e.jsx(Qe,{entities:[{id:P,name:r}],entityType:"creative",onCopyFinish:this.handleCopyCreative,disabled:l||k,titleForDisabled:k?"Unavailable for DSP Creatives":"",id:"CreativePage"})]}),e.jsx("div",{className:"action-buttons",children:e.jsx(De,{entities:[{id:P,name:r}],entityType:"creative",onProcessFinish:()=>$.push("".concat(U,"/app/adv/adgroups/").concat(s.id,"/creatives")),shouldArchive:!0,disabled:l||k,titleForDisabled:k?"Unavailable for DSP Creatives":"",id:"PageCreative"})})]})}),e.jsx("hr",{className:"border-line header-block mb-4"}),e.jsxs("div",{className:"preview-slider-wrapper",children:[a==="DSP"&&e.jsx("div",{className:"empty-preview-container dsp"}),a==="pop"&&e.jsx("div",{className:"empty-preview-container empty-list",children:e.jsx("div",{className:"empty-preview-text",children:D("popPreviewUnavailable")})}),a!=="DSP"&&a!=="pop"&&e.jsxs(e.Fragment,{children:[a==="image"&&!((q=h==null?void 0:h.images)!=null&&q.length)&&e.jsx("div",{className:"empty-preview-container empty-list",children:e.jsx("div",{className:"empty-preview-text",children:D("pleaseUploadCreative",{defaultValue:"Please upload your creative"})})}),(!!((B=h==null?void 0:h.images)!=null&&B.length)||a!=="image")&&e.jsxs(ue,{previewData:["text","responsive"].includes(a)?{...h,names:x.map(({width:C,height:A})=>"".concat(C,"x").concat(A))}:h,type:a,changeActiveItemIndex:this.changeCurrentPreviewIndex,clickUrl:m,children:[["text","responsive"].includes(a)&&m&&x.length>0&&x.map((C,A)=>e.jsx("div",{className:"slide-wrapper",children:e.jsx(Z,{bannerType:a,data:{clickurl:m,...a==="text"?{displayurl:h.displayUrl,description2:h.description2,title:h.title,description1:h.description1}:{headline:h.headline,description:h.description,businessName:h.businessName,media:{logo:h.logo,background:h.background}}},currentAdSize:{width:C.width,height:C.height},isActive:A===w,isPreFetch:A===w+1})},"w".concat(C.width,"h").concat(C.height).concat(A))),["image","html5","playable","video"].includes(a)&&m&&h.images.map((C,A)=>e.jsx("div",{className:"slide-wrapper".concat(a==="video"?" slide-wrapper--video":""),children:e.jsx(Z,{bannerType:a,data:{clickurl:m,fallbackImageUrl:C.fallbackImageUrl,...this.getBannerSrcProp(a,C.src)},currentAdSize:{width:C.width,height:C.height},isActive:A===w,isPreFetch:A===w+1})},C.name))]})]})]})]})}),e.jsx(V,{xs:12,className:"creative-statistics-column col-12 col-md-7",children:e.jsx(ot,{creativeId:P,isInternal:f,selectedCurrency:E})})]}),e.jsx(M,{className:"creative-statistics-row",children:e.jsx(V,{xs:12,className:"creative-statistics-column",children:e.jsx(it,{creativeId:P,isInternal:f,selectedCurrency:E})})})]}),e.jsx(_e,{isOpen:d,onConfirm:this.handleStatusChange,onClose:this.handleConfirmActionModalClose,isLoading:l,entityType:"creative",data:{isActive:n,status:i,adgroup:s,campaign:t}})]})]})})}}p(ge,"propTypes",{match:o.object.isRequired,history:o.object.isRequired,currencies:o.array.isRequired,isDSPAdvertiser:o.bool.isRequired,device:o.string,t:o.func.isRequired,language:o.string.isRequired});const Wt=ce(lt,null)(le(G(["Account/Creative","Account/Common"])(ge)));
1export{Wt as default};
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.