(()=>{"use strict";const e={Api:["https://api.mediacategory.com","https://api.clickon.kr","https://api.doem-0tpdlqj.com"],Tk:["https://tk.mediacategory.com","https://tk.clickon.kr","https://tk.doem-0tpdlqj.com"]};var t;!function(e){e.Aggregate="aggregate",e.Api="api"}(t||(t={}));var r=function(e,t,r,o){return new(r||(r=Promise))(function(n,s){function i(e){try{c(o.next(e))}catch(e){s(e)}}function a(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(i,a)}c((o=o.apply(e,t||[])).next())})};class o{constructor(){this.tryCnt=0}post(o,n,s,i,a=1500){return r(this,void 0,void 0,function*(){try{let r=o===t.Aggregate?e.Tk[this.tryCnt]:e.Api[this.tryCnt];if(!r)return;return new Promise(()=>{window.fetch(r+n,{method:"post",mode:"cors",credentials:"include",cache:"no-cache",headers:{"ENP-Referrer":encodeURIComponent(document.referrer),"Content-Type":"application/json;charset=UTF-8"},signal:this.getTimeoutSignal(a),body:JSON.stringify(s)}).then(e=>200===e.status||201===e.status?e.json():null).then(e=>(e?i(e,!0):i(null,!1),e)).catch(t=>{if(this.tryCnt>=e.Tk.length-1)return i(null,!1),null;this.tryCnt+=1,this.post(o,n,s,i,a)})})}catch(e){i(null,!1)}})}get(e,t=!1,o=1500){return r(this,void 0,void 0,function*(){try{let r={method:"get"};return t&&(r.mode="cors",r.credentials="include",r.headers={"Content-Type":"application/json;charset=UTF-8"},r.signal=this.getTimeoutSignal(o)),new Promise(t=>{window.fetch(e,r).then(e=>200===e.status||201===e.status?e.json():null).then(e=>t(e)).catch(e=>null)})}catch(e){return null}})}getTimeoutSignal(e){e||(e=1500);const t=new AbortController;return setTimeout(()=>{t.abort()},e),t.signal}}class n{callApi(){return e=this,r=void 0,s=function*(){try{(new o).post(t.Api,"/rtb/redirectUrl",{},(e,t)=>{if(t){const t=e;t&&t.status&&(t.redirectUrl_k&&this.callUrlByIframe(t.redirectUrl_k),t.redirectUrl_g&&this.callUrlByIframe(t.redirectUrl_g))}})}catch(e){}},new((n=void 0)||(n=Promise))(function(t,o){function i(e){try{c(s.next(e))}catch(e){o(e)}}function a(e){try{c(s.throw(e))}catch(e){o(e)}}function c(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n(function(e){e(r)})).then(i,a)}c((s=s.apply(e,r||[])).next())});var e,r,n,s}callUrlByIframe(e){const t=document.createElement("iframe");if(t.src=e,t.style.display="none",t.width="0",t.height="0",document.body)document.body.appendChild(t);else{const e=document.getElementsByTagName("html")[0],r=document.createElement("body");e.appendChild(r),r.appendChild(t)}}}class s{constructor(e){this.freqName="_turl_f",this.freqHour=24,this.freqCnt=5,this.adverId=e,this.siteCode=this.getMobScSiteCode()}getMobScSiteCode(){let e=new window.URL(location.href);if(e.searchParams.has("mobsc")){const t=e.searchParams.get("mobsc");return e.searchParams.delete("mobsc"),history.replaceState(null,"",e.href),t}return null}tUrlSetting(){if(this.siteCode&&this.getFrequency()){const e={userId:this.adverId,siteCode:this.siteCode};(new o).post(t.Api,"/adSiteUrlInfo/turl",e,(e,t)=>{if(t){const t=e;if(t.url1){const e=location.href;history.pushState(null,"",e),window.addEventListener("popstate",function(){window.location.href=t.url1}),this.setFrequency()}}})}}setFrequency(){if(localStorage){let e;if(localStorage.getItem(this.freqName)){const t=localStorage.getItem(this.freqName);e=JSON.parse(t),e.cnt+=1}else e={cDate:Date.now(),cnt:1};localStorage.setItem(this.freqName,JSON.stringify(e))}}getFrequency(){if(localStorage){const e=localStorage.getItem(this.freqName);if(e){const t=JSON.parse(e),r=(Date.now()-t.cDate)/1e3/3600,o=t.cnt;if(r>this.freqHour)return localStorage.removeItem(this.freqName),!0;if(o>this.freqCnt)return!1}}return!0}}class i{constructor(){this.storage=window.sessionStorage,this.localStorage=window.localStorage,this._fcTE="_fcTE",this.otherDomain="o",this.refferDomainKey="rd",this.refferDomainArrLength=5,this.rcteRefferDomainList=[{referrerDomain:"mediacategory.com",key:"m"},{referrerDomain:"doubleclick.net",key:"g"},{referrerDomain:"naver.com",key:"n"},{referrerDomain:"t1.daumcdn.net",key:"k"}],this.sessionKey="ENP_MEDIA",this.referrerDomainList=[{referrerDomain:"mediacategory.com",key:"m"},{referrerDomain:"naver.com",key:"n"},{referrerDomain:"t1.daumcdn.net",key:"k"},{referrerDomain:"kn.acrosspf.com",key:"a"},{referrerDomain:"ad.doyouad.com",key:"d"},{referrerDomain:"api.dable.io",key:"t"}]}setSessionKey(){const e=this.getReferrerKey();e&&this.storage.setItem(this.sessionKey,e)}getReferrerKey(){const e=document.referrer,t=this.referrerDomainList;for(let r=0,o=t.length;rthis.refferDomainArrLength?t.slice(0,this.refferDomainArrLength):t}return[]}return[]}catch(e){return this.localStorage.removeItem(this._fcTE),[]}}getFcteRefferDomainKey(){const e=document.referrer,t=window.location.hostname;if(!e)return this.otherDomain;if(e.includes(t))return"";for(let t=0;t{t.k=e,t.i=r,t.r=Date.now()};try{const e=JSON.parse(this.storage.getItem(this.STORAGE_KEY));e?e.k!==r&&n(r,o):n(r,o)}catch(e){n(r,o)}finally{if(t.k){const e=JSON.stringify(t);this.storage.setItem(this.STORAGE_KEY,e),this.setFirstCookie(this.STORAGE_KEY,e)}}}setFirstCookie(e,t){const r=new Date;r.setDate(r.getDate()+this.expiryDay);let o=e+"="+t;o+="; EXPIRES="+r.toUTCString(),o+="; PATH=/",location.host.includes("gmarket.co.kr")?o+="; DOMAIN=.gmarket.co.kr":o+="; DOMAIN="+location.host,document.cookie=o}getAuIdDataFromStorage(){try{return JSON.parse(this.storage.getItem(this.STORAGE_KEY)).k}catch(e){return""}}getIpInfoFromStorage(){try{return JSON.parse(this.storage.getItem(this.STORAGE_KEY)).i}catch(e){return""}}}class c{constructor(e){this.adverId=e}excute(){let e={adverId:this.adverId,identKey:"",identNumber:"",url:location.href,referrer:document.referrer?"null"===document.referrer?"":document.referrer:"",adminId:""};const r=new a,n=r.getAuIdDataFromStorage(),s=r.getIpInfoFromStorage();n&&s&&"undefined"!==n&&"null"!==n&&(e.identKey=n,e.identNumber=s),e.adminId=this.getCafe24AdminId(),e=Object.assign(Object.assign({},e),this.getMobaPvCountParam()),(new o).post(t.Aggregate,"/aggregate/util",e,(e,t)=>{e&&t&&(r.setDataInStorage(e),this.deleteMhhkParam(),this.setReferrer())})}handleNewAuid(e){var t,r;if(!0!==(null===(t=e.parameters)||void 0===t?void 0:t.isNewAuid))return;const o=null===(r=e.parameters)||void 0===r?void 0:r._auid,n=this.adverId;if(-1===["eyecatcher","juvisfood","loloten","missj1","muji_korea","mulawear","swfrance1"].indexOf(n))return;const s=document.createElement("iframe");s.src="https://www.uni1id.com/cookie-check-adver.html?auid="+encodeURIComponent(o)+"&adverId="+encodeURIComponent(n),s.style.display="none",s.width="0",s.height="0",document.body.appendChild(s)}deleteMhhkParam(){let e=new window.URL(location.href);e.searchParams.has("mhhk")&&(e.searchParams.delete("mhhk"),history.replaceState({},"",e.href))}setReferrer(){(new i).setRefferDomain()}getMobaPvCountParam(){try{const e=window.sessionStorage.getItem("enp_moba"),t=e?JSON.parse(e).moba:null,r=window.sessionStorage.getItem("enp_pvCount"),o=Number(r),n=null===r||isNaN(o)?-1:o;return-1!==n&&null!=t?{pvCount:n,moba:t}:{}}catch(e){return{}}}getCafe24AdminId(){var e,t,r;try{const o=null===(r=null===(t=null===(e=window.CAFE24)||void 0===e?void 0:e.SHOP)||void 0===t?void 0:t.getAdminID)||void 0===r?void 0:r.call(t);return"string"==typeof o?o:""}catch(e){return""}}}class l{constructor(){this.referrerDomains=["mediacategory.com","clickon.kr","doem-0tpdlqj.com"],this.localStorageKey="enp_lc",this.sessionStorageKey="enp_lc",this.paramType={mobon:1,organic:2,others:3,complete:9}}getSessionLastClick(){try{const e=window.sessionStorage.getItem(this.sessionStorageKey);return Number(e)}catch(e){return 0}}setSessionLastClick(){try{if(0!==this.getSessionLastClick())return;const e=this.paramCheck();window.sessionStorage.setItem(this.sessionStorageKey,e.toString())}catch(e){return}}setLocalLastClick(){const e=document.referrer;e&&new URL(document.referrer).host!==new URL(location.href).host&&this.referrerDomains.some(t=>e.includes(t))&&window.localStorage.setItem(this.localStorageKey,this.paramType.mobon.toString())}getLocalLastClick(){try{const e=window.localStorage.getItem(this.localStorageKey);return Number(e)}catch(e){return 0}}paramCheck(){const e=new URLSearchParams(window.location.search);if(0===e.size)return this.paramType.organic;const t=Array.from(e.values()),r=["mob","enp"];if(t.some(e=>r.some(t=>e.includes(t))))return this.paramType.mobon;const o=["referral","direct","not set","not-set","notset","none"];return t.some(e=>o.some(t=>e.includes(t)))?this.paramType.organic:this.paramType.others}}class h{constructor(){this.SEND_PATH="/moba/send",this.PARAM_KEY="moba",this.STORAGE_KEY="enp_moba",this.PV_COUNT="enp_pvCount",this.ENP_BANNER_CLICK_TIME="enp_bannerClickTime"}setMobaData(){const e=window.sessionStorage.getItem(this.STORAGE_KEY);let t;if(e){if(this.incrementPvCount(),t=JSON.parse(e),"Y"===t.send)return;this.sendMobaData(t)}else this.firstSetMobaData()}monitorPageStayTime(){const e=window.sessionStorage.getItem(this.STORAGE_KEY),t=JSON.parse(e);if("N"===t.send){const e=Date.now()-Number(t.time);this.sendMobaDataAfterDelay(t,1e4-e)}}sendMobaData(e){(new o).post(t.Aggregate,this.SEND_PATH,{moba:e.moba},()=>{e.send="Y",window.sessionStorage.setItem(this.STORAGE_KEY,JSON.stringify(e))})}sendMobaDataAfterDelay(e,t){setTimeout(()=>{this.sendMobaData(e)},t)}firstSetMobaData(){const e=new URLSearchParams(window.location.search).get(this.PARAM_KEY);if(!e)return;const t={time:Date.now().toString(),moba:e,send:"N"};window.sessionStorage.setItem(this.STORAGE_KEY,JSON.stringify(t)),window.sessionStorage.setItem(this.PV_COUNT,"0"),window.localStorage.setItem(this.ENP_BANNER_CLICK_TIME,Date.now().toString()),this.monitorPageStayTime()}incrementPvCount(){let e=Number(window.sessionStorage.getItem(this.PV_COUNT));e+=1,window.sessionStorage.setItem(this.PV_COUNT,e.toString())}}class m{constructor(e){this.adverId=e}executeCommand(){(new i).setSessionKey(),this.lastClickSetting(),this.mobaService(),this.callAggregate(),this.removeMobaParamFromHistory(),this.callIOrbApi(),this.tUrlSetting(),this.appendAiBannerScript()}callAggregate(){new c(this.adverId).excute()}callIOrbApi(){(new n).callApi()}tUrlSetting(){new s(this.adverId).tUrlSetting()}lastClickSetting(){const e=new l;e.setSessionLastClick(),e.setLocalLastClick()}mobaService(){(new h).setMobaData()}removeMobaParamFromHistory(){const e=new window.URL(window.location.href);e.searchParams.has("moba")&&(e.searchParams.delete("moba"),history.replaceState(null,"",e.href))}appendAiBannerScript(){const e="https://cdn.megadata.co.kr/dist/prod/aiBanner.js";if(document.querySelector(`script[src="${e}"]`))return;const t=document.createElement("script");t.src=e+`?adverId=${this.adverId}`,t.async=!0,document.body.appendChild(t)}}(()=>{const e=e=>{new m(e).executeCommand()},t=document.querySelector('script[src*="cdn.megadata.co.kr/dist/prod/utilKit"]'),r=new URLSearchParams(new window.URL(t.src).search).getAll("adverId");let o="";for(let t=0;t