!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).LandingSDK=t()}(this,function(){"use strict";if("function"!=typeof Object.keys||"function"!=typeof Date.now||"function"!=typeof Array.isArray){var e=function(){},t=function(){};t.landingPageView=e,t.landingPageClick=e;var n=function(){};if(n.init=e,n.track=t,"undefined"!=typeof globalThis)try{globalThis.LandingSDK=n}catch(e){}else"undefined"!=typeof window&&(window.LandingSDK=n);return n}function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}var i,o="_s_token_",a="_d_token_",u="_d_sig_",c="_ping_flag_",d="data-app-id",l="app-id",f="event_id",v=null,p=null,s=null,g=null,y=function(e){var t=e.toString(16);return 1===t.length?"0"+t:t},_=function(){for(var e="",t=0;t<16;t++)e+=y(Math.floor(256*Math.random()));return e},h=function(){if(null!==g)return g;try{return window.localStorage.setItem(c,"1"),window.localStorage.removeItem(c),g=!0,!0}catch(e){return g=!1,!1}},w=function(){if("undefined"==typeof navigator)return"PC";var e=navigator.userAgent||"";return/Android/i.test(e)?"Android":/iPhone|iPad|iPod/i.test(e)?"iOS":"PC"},m=function(e){if(!e)return"";for(var t=e+"device_id_secret_key_v1",n=0,r=0;r0&&void 0!==arguments[0]?arguments[0]:"")||""),n=0;n>>0).toString(16).padStart(8,"0")}(y));return function(t){if(t&&h())try{window.localStorage.setItem(e,t)}catch(e){}}(_),_}catch(e){return""}},S=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=function(){if("undefined"==typeof window)return"";if(h())try{var e=window.localStorage.getItem(a),t=window.localStorage.getItem(u);if(e&&!t){var n=_(),r=m(n);return window.localStorage.setItem(a,n),window.localStorage.setItem(u,r),n}if(e&&t){if(m(e)===t)return e;var i=_(),o=m(i);return window.localStorage.setItem(a,i),window.localStorage.setItem(u,o),i}var c=_(),d=m(c);return window.localStorage.setItem(a,c),window.localStorage.setItem(u,d),c}catch(e){}return s||(s=_()),s}(),n=function(){var e,t,n,r=(t=(e=new Date).getMonth()+1,n=e.getDate(),e.getFullYear()+"-"+(t<10?"0"+t:t)+"-"+(n<10?"0"+n:n));if("undefined"!=typeof window&&h())try{var i=window.localStorage.getItem(o);if(i)try{var a=JSON.parse(i);if(a.date===r&&a.sid)return a.sid}catch(e){}var u=_();return window.localStorage.setItem(o,JSON.stringify({sid:u,date:r})),u}catch(e){}return v&&p===r||(v=_(),p=r),v}(),r="",i="";return{app_id:e.appId||b(),uid:0,channel:e.channel||"",sid:n,client_ts:Math.floor(Date.now()/1e3),device:w(),device_id:e.deviceId||t,user_agent:"undefined"==typeof navigator?"":navigator.userAgent||"",device_brand:r,device_model:i,fp_version:"1.0.0",device_fingerprint:k(),sdk_version:"1.1.0",app_version:""}},A=function(){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")||(window.location.origin?window.location.origin:window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:""));if(!n)return"";var r="/"===n.charAt(n.length-1)?n.slice(0,-1):n,i=e?"/dcserv":"",o=t?"/api/eventTracking/batchReport.json":"/api/eventTracking/report.json";return"".concat(r).concat(i).concat(o)},j=function(){for(var e={},t=0;t>6,128|63&i);else if(i>=55296&&i<=56319&&r+1=56320&&o<=57343){var a=o-56320+(i-55296<<10)+65536;n.push(240|a>>18,128|a>>12&63,128|a>>6&63,128|63&a),r+=1}else n.push(224|i>>12,128|i>>6&63,128|63&i)}else n.push(224|i>>12,128|i>>6&63,128|63&i)}var u=8*n.length;for(n.push(128);n.length%64!=56;)n.push(0);for(var c=0;c<8;c+=1)n.push(u>>>8*c&255);for(var d=function(e,t){return e<>>32-t},l=function(e,t){return((e>>>0)+(t>>>0)&4294967295)>>>0},f=function(e,t,n,r){return l(l(e,t),l(n,r))},v=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],p=new Array(64),s=0;s<64;s+=1)p[s]=Math.floor(4294967296*Math.abs(Math.sin(s+1)))>>>0;for(var g=1732584193,y=4023233417,_=2562383102,h=271733878,w=0;w>>0}for(var S=g,A=y,j=_,I=h,O=0;O<64;O+=1){var P=void 0,T=void 0;O<16?(P=A&j|~A&I,T=O):O<32?(P=I&A|~I&j,T=(5*O+1)%16):O<48?(P=A^j^I,T=(3*O+5)%16):(P=j^(A|~I),T=7*O%16);var q=I;I=j,j=A,A=l(A,d(f(S,P,p[O],m[T]),v[O])),S=q}g=l(g,S),y=l(y,A),_=l(_,j),h=l(h,I)}var x=function(e){for(var t="",n=0;n<4;n+=1)t+=(256+(e>>>8*n&255)).toString(16).slice(1);return t};return""+x(g)+x(y)+x(_)+x(h)},O=function(e){return null===e?"__t:null__":"string"==typeof e?"__t:str__:"+e:"number"==typeof e&&isFinite(e)?"__t:num__:"+String(e):"boolean"==typeof e?"__t:bool__:"+(e?"1":"0"):Array.isArray(e)?"["+e.map(O).join(",")+"]":"object"===r(e)?"{"+Object.keys(e).sort().map(function(t){return t+":"+O(e[t])}).join(",")+"}":"__t:any__:"+String(e)},P=function(e){var t=(e=e||{}).endpoint?e.endpoint:A(e.domain,!0,e.batch)||"",n=function(e){return e=e||{},{sendPayload:function(t,n){if(n){var i,o;if(e.batch?(i=JSON.stringify(t),o="application/json"):(i=function(e){for(var t=Object.keys(e||{}),n=[],i=0;i100?E(e,t,r,"must be int in [0,100]"):{keep:!0,value:o}}if(function(e){return"page_no"===e||"click_position"===e||/_position$/.test(e)}(t)){var a=M(n);return!D(a)||a<1?E(e,t,r,"must be int >= 1"):{keep:!0,value:a}}if("amount"===t||"coin_quantity"===t||"search_result_count"===t||"click_page_x"===t||"click_page_y"===t||"screen_width"===t||"screen_height"===t||"video_duration"===t||"play_duration"===t||"page_load_time"===t){var u=M(n);return!D(u)||u<=0?E(e,t,r,"must be int > 0"):{keep:!0,value:u}}if(x[t]){var c=C(n);if(!c)return E(e,t,r,"must not be empty");var d=c.split(",").map(function(e){return e.trim()}).filter(Boolean).join(",");return d?{keep:!0,value:d}:E(e,t,r,"must not be empty")}if(function(e){return/_key$/.test(e)}(t)){var l=C(n);return!l||l.length>64||!/^[A-Za-z0-9_]+$/.test(l)?E(e,t,r,"must match key rule"):{keep:!0,value:l}}if(function(e){return/_name$/.test(e)}(t)){var f=C(n);return f?{keep:!0,value:f.slice(0,128)}:E(e,t,r,"must not be empty")}if(function(e){return/(^id$|_id$)/.test(e)}(t)){var v=C(n);return v?{keep:!0,value:v.slice(0,128)}:E(e,t,r,"must not be empty")}if(function(e){return"comment_content"===e||"keyword"===e||/_title$/.test(e)||"novel_title"===e||"video_title"===e}(t)){var p=C(n),s="comment_content"===t||"keyword"===t?500:256;return p?{keep:!0,value:p.slice(0,s)}:E(e,t,r,"must not be empty")}if(Object.prototype.hasOwnProperty.call(q,t)){var g=C(n);return q[t][g]?{keep:!0,value:g}:E(e,t,r,"must be in enum whitelist")}return"string"==typeof n?{keep:!0,value:n.trim()}:{keep:!0,value:n}},N=function(e){return null===e?"null":Array.isArray(e)?"array":r(e)},R=function(e,t,n){t=t||{};var i=(n=n||{}).allowExtra,o=void 0!==i&&i,a=t&&"object"===r(t)&&!Array.isArray(t)?t:null;if(!a)throw new TypeError("[sdk][event] "+e+" payload must be an object");for(var u=T[e]||{},c=Object.keys(a),d={},l=0;l