"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _regeneratorRuntime(){_regeneratorRuntime=function(){return a};var a={},t=Object.prototype,u=t.hasOwnProperty,s=Object.defineProperty||function(t,e,n){t[e]=n.value},e="function"==typeof Symbol?Symbol:{},o=e.iterator||"@@iterator",n=e.asyncIterator||"@@asyncIterator",r=e.toStringTag||"@@toStringTag";function i(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{i({},"")}catch(t){i=function(t,e,n){return t[e]=n}}function c(t,e,n,o){var r,i,a,c,e=e&&e.prototype instanceof p?e:p,e=Object.create(e.prototype),o=new x(o||[]);return s(e,"_invoke",{value:(r=t,i=n,a=o,c="suspendedStart",function(t,e){if("executing"===c)throw new Error("Generator is already running");if("completed"===c){if("throw"===t)throw e;return I()}for(a.method=t,a.arg=e;;){var n=a.delegate;if(n){n=function t(e,n){var o=n.method,r=e.iterator[o];if(void 0===r)return n.delegate=null,"throw"===o&&e.iterator.return&&(n.method="return",n.arg=void 0,t(e,n),"throw"===n.method)||"return"!==o&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+o+"' method")),l;o=d(r,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,l;r=o.arg;return r?r.done?(n[e.resultName]=r.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=void 0),n.delegate=null,l):r:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,l)}(n,a);if(n){if(n===l)continue;return n}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===c)throw c="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);c="executing";n=d(r,i,a);if("normal"===n.type){if(c=a.done?"completed":"suspendedYield",n.arg===l)continue;return{value:n.arg,done:a.done}}"throw"===n.type&&(c="completed",a.method="throw",a.arg=n.arg)}})}),e}function d(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}a.wrap=c;var l={};function p(){}function f(){}function h(){}var e={},y=(i(e,o,function(){return this}),Object.getPrototypeOf),y=y&&y(y(S([]))),v=(y&&y!==t&&u.call(y,o)&&(e=y),h.prototype=p.prototype=Object.create(e));function w(t){["next","throw","return"].forEach(function(e){i(t,e,function(t){return this._invoke(e,t)})})}function g(a,c){var e;s(this,"_invoke",{value:function(n,o){function t(){return new c(function(t,e){!function e(t,n,o,r){var i,t=d(a[t],a,n);if("throw"!==t.type)return(n=(i=t.arg).value)&&"object"==_typeof(n)&&u.call(n,"__await")?c.resolve(n.__await).then(function(t){e("next",t,o,r)},function(t){e("throw",t,o,r)}):c.resolve(n).then(function(t){i.value=t,o(i)},function(t){return e("throw",t,o,r)});r(t.arg)}(n,o,t,e)})}return e=e?e.then(t,t):t()}})}function m(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function b(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(m,this),this.reset(!0)}function S(e){if(e){var n,t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return n=-1,(t=function t(){for(;++n<e.length;)if(u.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t}).next=t}return{next:I}}function I(){return{value:void 0,done:!0}}return s(v,"constructor",{value:f.prototype=h,configurable:!0}),s(h,"constructor",{value:f,configurable:!0}),f.displayName=i(h,r,"GeneratorFunction"),a.isGeneratorFunction=function(t){t="function"==typeof t&&t.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},a.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,i(t,r,"GeneratorFunction")),t.prototype=Object.create(v),t},a.awrap=function(t){return{__await:t}},w(g.prototype),i(g.prototype,n,function(){return this}),a.AsyncIterator=g,a.async=function(t,e,n,o,r){void 0===r&&(r=Promise);var i=new g(c(t,e,n,o),r);return a.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},w(v),i(v,r,"Generator"),i(v,o,function(){return this}),i(v,"toString",function(){return"[object Generator]"}),a.keys=function(t){var e,n=Object(t),o=[];for(e in n)o.push(e);return o.reverse(),function t(){for(;o.length;){var e=o.pop();if(e in n)return t.value=e,t.done=!1,t}return t.done=!0,t}},a.values=S,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!t)for(var e in this)"t"===e.charAt(0)&&u.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var o=this;function t(t,e){return i.type="throw",i.arg=n,o.next=t,e&&(o.method="next",o.arg=void 0),!!e}for(var e=this.tryEntries.length-1;0<=e;--e){var r=this.tryEntries[e],i=r.completion;if("root"===r.tryLoc)return t("end");if(r.tryLoc<=this.prev){var a=u.call(r,"catchLoc"),c=u.call(r,"finallyLoc");if(a&&c){if(this.prev<r.catchLoc)return t(r.catchLoc,!0);if(this.prev<r.finallyLoc)return t(r.finallyLoc)}else if(a){if(this.prev<r.catchLoc)return t(r.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<r.finallyLoc)return t(r.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;0<=n;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&u.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var r=o;break}}var i=(r=r&&("break"===t||"continue"===t)&&r.tryLoc<=e&&e<=r.finallyLoc?null:r)?r.completion:{};return i.type=t,i.arg=e,r?(this.method="next",this.next=r.finallyLoc,l):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),b(n),l}},catch:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var n,o,r=this.tryEntries[e];if(r.tryLoc===t)return"throw"===(n=r.completion).type&&(o=n.arg,b(r)),o}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:S(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},a}function asyncGeneratorStep(t,e,n,o,r,i,a){try{var c=t[i](a),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(o,r)}function _asyncToGenerator(c){return function(){var t=this,a=arguments;return new Promise(function(e,n){var o=c.apply(t,a);function r(t){asyncGeneratorStep(o,e,n,r,i,"next",t)}function i(t){asyncGeneratorStep(o,e,n,r,i,"throw",t)}r(void 0)})}}function ownKeys(e,t){var n,o=Object.keys(e);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,n)),o}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(n),!0).forEach(function(t){_defineProperty(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function _defineProperty(t,e,n){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _toPropertyKey(t){t=_toPrimitive(t,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){var n;if(t)return"string"==typeof t?_arrayLikeToArray(t,e):"Map"===(n="Object"===(n=Object.prototype.toString.call(t).slice(8,-1))&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(t,e):void 0}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=new Array(e);n<e;n++)o[n]=t[n];return o}function _iterableToArrayLimit(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var o,r,i,a,c=[],u=!0,s=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(o=i.call(n)).done)&&(c.push(o.value),c.length!==e);u=!0);}catch(t){s=!0,r=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw r}}return c}}function _arrayWithHoles(t){if(Array.isArray(t))return t}var isDev=/^(192|0|127|localhost|dev-)/.test(location.hostname)?"1":/^(test-)/.test(location.hostname)?"4":/^(pre-)/.test(location.hostname)?"2":"3",baseURL="1"===isDev?"http://dev-api.novelmanga.com":"2"===isDev?"https://pre-api.novelmanga.com":"4"===isDev?"https://test-api.novelmanga.com":"https://api.novelmanga.com",maxIpList=[218,226,150,255],randomIp=function(){return Array(4).fill(0).map(function(t,e){return Math.floor(Math.random()*maxIpList[e])+(0===e?1:0)}).join(".")},userAgent=window.navigator.userAgent||"",Tools={ip:"",pixelId:null,hasPoint:null,deviceType:"",parseNavigator:{},rawTextFirst:null,rawTextSecond:null,copyData:"",uuidList:[],storeData:{packageName:window.dataInfo.packageName},defaultData:{content_category:"book",contentCategory:"book",content_ids:[window.dataInfo.bookId],content_type:"product",contentType:"product",contentIds:[window.dataInfo.bookId],eventTime:getUtcTime(),contents:[{productId:window.dataInfo.bookId,quantity:1,value:"0.00",currency:"USD"}]},getIp:function(){var i=this;return new Promise(function(e,t){var n=+new Date,o=0,r=setInterval(function(){1e3<(o=+new Date-n)&&($(".bottom-box").show(),clearInterval(r))},100);$.ajax({type:"get",url:"".concat(baseURL,"/nc-user-service/web2app/get/ipAddress"),success:function(t){t=t.data;o<1e3&&($(".bottom-box").show(),clearInterval(r)),i.ip=t,e(t)},error:function(){i.ip=randomIp(),e(i.ip)}})})},createEventId:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})},parse:function(t){t=null==(t=decodeURIComponent(t).match(/\?([^/?#:]+)#?/))?void 0:t[1];return t?t.split("&").reduce(function(t,e){var e=_slicedToArray(e.split("="),2),n=e[0],e=e[1],e=void 0===e?"":e;return void 0!==t[n]?t[n]=[].concat(t[n],e):t[n]=e,t},{}):{}},pushPixelLogToService:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:1,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=this.parse(window.location.href),o=n.fbcid||getCookie("_fbc")||"fb.1.".concat(+new Date,".").concat(n.fbclid),r=n.fbpid||getCookie("_fbp"),n=null!=(n=n.adid)?n:"",e={pixelId:window.dataInfo.pixelId,adid:n,ipType:e,channel:window.dataInfo.channel,deviceType:this.deviceType,metaEventType:t,uuidList:this.uuidList,eventJson:{eventName:1==t?"ViewContent":2==t?"SubmitApplication":"StartTrial",eventTime:getUtcTime(),eventSourceUrl:window.location.href,eventId:window.eventId,userData:{clientIpAddress:this.ip,clientUserAgent:window.navigator.userAgent,fbc:o,fbp:r},customData:_objectSpread({},this.defaultData),actionSource:"website"}};3==t&&(t="web2app","deerfiction"===window.dataInfo.channel&&(t="webZapp"),e.link="".concat(window.dataInfo.appDeepLink).concat(window.dataInfo.bookId,"&actionSource=").concat(t,"&eventSourceUrl=").concat(encodeURIComponent(window.location.href),"&fbc=").concat(o,"&fbp=").concat(r,"&adid=").concat(n)),this.paramsObj=e,$.ajax({type:"post",data:JSON.stringify(e),dataType:"json",contentType:"application/json",url:"".concat(baseURL,"/nc-user-service/web2app/report/event"),success:function(){},error:function(){}})},init:function(){var o=this;return _asyncToGenerator(_regeneratorRuntime().mark(function t(){var e,n;return _regeneratorRuntime().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=window.navigator.userAgent||"",n=/android/i.test(e),/iphone|ipad|ipod/i.test(e),o.deviceType=n?1:2,$.ajaxSettings.headers={"x-app-info":"2.7.0/".concat(window.dataInfo.channel,"/").concat(n?"android":"ios"),device:o.createEventId()},window.eventId=o.createEventId(),o.pixelId=window.dataInfo.pixelId,window.pixelId=window.dataInfo.pixelId,window.addEventListener("scroll",scrollHandler,!0),$(".bottom-box").on("click",function(){o.open()}),t.next=12,o.getIp();case 12:o.getUserAgent(),o.pushPixelLogToService();case 14:case"end":return t.stop()}},t)}))()},open:function(){var t=0,e=(this.ip||(t=1,this.ip=randomIp(),this.getUserAgent()),this.parse(window.location.href)),n=e.fbcid||getCookie("_fbc")||"fb.1.".concat(+new Date,".").concat(e.fbclid),o=e.fbpid||getCookie("_fbp"),r=null!=(r=e.adid)?r:"",i="web2app",i=("deerfiction"===window.dataInfo.channel&&(i="webZapp"),"".concat(window.dataInfo.appDeepLink).concat(window.dataInfo.bookId,"&actionSource=").concat(i,"&eventSourceUrl=").concat(encodeURIComponent(window.location.href),"&fbc=").concat(n,"&fbp=").concat(o,"&adid=").concat(r)),n={uuidList:this.uuidList,pixelId:this.pixelId,adid:r,ipType:t,channel:window.dataInfo.channel,deviceType:this.deviceType,eventJson:{eventName:"StartTrial",eventTime:getUtcTime(),eventSourceUrl:window.location.href,eventId:window.eventId,userData:{clientIpAddress:this.ip,clientUserAgent:window.navigator.userAgent,fbc:e.fbcid||getCookie("_fbc"),fbp:e.fbpid||getCookie("_fbp")},customData:_objectSpread({},this.defaultData),actionSource:"website"},rawTextFirst:this.rawTextFirst,rawTextSecond:this.rawTextSecond,metaEventType:3,link:i};this.copyData=encrypt(JSON.stringify(n),window.dataInfo.packageName);try{window.eventId=this.createEventId(),window.fbq&&window.fbq("track","StartTrial",window.defaultData,{eventId:window.eventId}),this.pushPixelLogToService(3,t)}catch(t){console.log(t,"error")}copyTextToClipboard(this.copyData);this.jumpToApp(i,window.dataInfo.storeUrl)},jumpToApp:function(t,e){window.dataInfo.isJumpToStoreUrl?window.location.href=e:(window.location.href=t,window.setTimeout(function(){var t=window.document.hidden||window.document.mozHidden||window.document.msHidden||window.document.webkitHidden;void 0!==t&&0!=t||(window.location.href=e)},3e3))},getUserAgent:function(){var t=window.navigator,e=new UAParser(t.userAgent),e=(this.parseNavigator=e.getResult(),t.language),t=window.devicePixelRatio,n=e.split("-"),n=(3===n.length&&n.splice(1,1),e=n[0].toUpperCase(),"deviceModel=".concat(this.parseNavigator.device.model||"","&devicePixelRadio=").concat(t.toFixed(2),"&ip=").concat(this.ip,"&language=").concat(e,"&osVersion=").concat(this.parseNavigator.os.name," ").concat(this.parseNavigator.os.version)),t="devicePixelRadio=".concat(t.toFixed(2),"&ip=").concat(this.ip,"&language=").concat(e,"&osVersion=").concat(this.parseNavigator.os.name," ").concat(this.parseNavigator.os.version);this.rawTextFirst=n,this.rawTextSecond=t,this.uuidList=[encrypt(n,window.dataInfo.packageName),encrypt(t,window.dataInfo.packageName)]}};function getKey(t){return(t+"0000000000000000").substring(0,16)}function getCookie(t){var t=new RegExp("(^| )"+t+"=([^;]*)(;|$)");return(t=document.cookie.match(t))?unescape(t[2]):""}function encrypt(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"com.novel.manga",n=void 0;return n=CryptoJS.enc.Utf8.parse(getKey(e)),CryptoJS.AES.encrypt(t,n,{iv:CryptoJS.enc.Utf8.parse("5873087691895047"),mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}).ciphertext.toString(CryptoJS.enc.Hex)}function decrypt(t){var e=CryptoJS.enc.Utf8.parse(getKey(1<arguments.length&&void 0!==arguments[1]?arguments[1]:"com.novel.manga")),n=CryptoJS.enc.Utf8.parse("5873087691895047");return CryptoJS.AES.decrypt(CryptoJS.format.Hex.parse(t),e,{iv:n,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8)}function getUtcTime(){var t=new Date,e=t.getUTCFullYear().toString().padStart(4,"0"),n=(t.getUTCMonth()+1).toString().padStart(2,"0"),o=t.getUTCDate().toString().padStart(2,"0"),r=t.getUTCHours().toString().padStart(2,"0"),i=t.getUTCMinutes().toString().padStart(2,"0"),t=t.getUTCSeconds().toString().padStart(2,"0"),e="".concat(e,"/").concat(n,"/").concat(o," ").concat(r,":").concat(i,":").concat(t);return+new Date(e)/1e3}function scrollHandler(){var t=document.documentElement.scrollTop||window.pageYOffset||document.body.scrollTop;if(document.querySelector("#pageContainer")&&document.querySelector("#pageContainer").scrollHeight-(window.innerHeight+t)<80&&!Tools.hasPoint)try{window.eventId=Tools.createEventId(),window.fbq&&window.fbq("track","SubmitApplication",window.defaultData,{eventId:window.eventId}),Tools.pushPixelLogToService(2),Tools.hasPoint=!0}catch(t){}}function copyTextToClipboard(t){var e=(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).target,e=void 0===e?document.body:e,n=document.createElement("textarea"),o=document.activeElement,r=(n.value=t,n.setAttribute("readonly",""),n.style.contain="strict",n.style.position="absolute",n.style.left="-9999px",n.style.fontSize="12pt",document.getSelection()),i=0<r.rangeCount&&r.getRangeAt(0),e=(e.append(n),n.select(),n.selectionStart=0,n.selectionEnd=t.length,!1);try{e=document.execCommand("copy")}catch(t){}return n.remove(),i&&(r.removeAllRanges(),r.addRange(i)),o&&o.focus(),e}function loadScript(o,r){return new Promise(function(t,e){try{var n=document.createElement("script");n.type="text/javascript",n.async=r||!0,n.src=o,n.onload=function(){t()},n.onerror=function(t){throw t},document.head.appendChild(n)}catch(t){e(t)}})}Tools.init();