!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_",c="_d_sig_",u="_ping_flag_",d="data-app-id",l="app-id",f="event_id",p=null,v=null,g=null,s=null,y=function(e){var t=e.toString(16);return 1===t.length?"0"+t:t},h=function(){for(var e="",t=0;t<16;t++)e+=y(Math.floor(256*Math.random()));return e},w=function(){if(null!==s)return s;try{return window.localStorage.setItem(u,"1"),window.localStorage.removeItem(u),s=!0,!0}catch(e){return s=!1,!1}},_=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&&w())try{window.localStorage.setItem(e,t)}catch(e){}}(h),h}catch(e){return""}},S=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=function(){if("undefined"==typeof window)return"";if(w())try{var e=window.localStorage.getItem(a),t=window.localStorage.getItem(c);if(e&&!t){var n=h(),r=m(n);return window.localStorage.setItem(a,n),window.localStorage.setItem(c,r),n}if(e&&t){if(m(e)===t)return e;var i=h(),o=m(i);return window.localStorage.setItem(a,i),window.localStorage.setItem(c,o),i}var u=h(),d=m(u);return window.localStorage.setItem(a,u),window.localStorage.setItem(c,d),u}catch(e){}return g||(g=h()),g}(),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&&w())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 c=h();return window.localStorage.setItem(o,JSON.stringify({sid:c,date:r})),c}catch(e){}return p&&v===r||(p=h(),v=r),p}(),r="",i="";return{app_id:e.appId||k(),uid:0,channel:e.channel||"",sid:n,client_ts:Math.floor(Date.now()/1e3),device:_(),device_id:t,user_agent:"undefined"==typeof navigator?"":navigator.userAgent||"",device_brand:r,device_model:i,fp_version:"1.0.0",device_fingerprint:b()}},j=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)},A=function(){for(var e={},t=0;t100?D(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=C(n);return!x(a)||a<1?D(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 c=C(n);return!x(c)||c<=0?D(e,t,r,"must be int > 0"):{keep:!0,value:c}}if(T[t]){var u=q(n);if(!u)return D(e,t,r,"must not be empty");var d=u.split(",").map(function(e){return e.trim()}).filter(Boolean).join(",");return d?{keep:!0,value:d}:D(e,t,r,"must not be empty")}if(function(e){return/_key$/.test(e)}(t)){var l=q(n);return!l||l.length>64||!/^[A-Za-z0-9_]+$/.test(l)?D(e,t,r,"must match key rule"):{keep:!0,value:l}}if(function(e){return/_name$/.test(e)}(t)){var f=q(n);return f?{keep:!0,value:f.slice(0,128)}:D(e,t,r,"must not be empty")}if(function(e){return/(^id$|_id$)/.test(e)}(t)){var p=q(n);return p?{keep:!0,value:p.slice(0,128)}:D(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 v=q(n),g="comment_content"===t||"keyword"===t?500:256;return v?{keep:!0,value:v.slice(0,g)}:D(e,t,r,"must not be empty")}if(Object.prototype.hasOwnProperty.call(P,t)){var s=q(n);return P[t][s]?{keep:!0,value:s}:D(e,t,r,"must be in enum whitelist")}return"string"==typeof n?{keep:!0,value:n.trim()}:{keep:!0,value:n}},M=function(e){return null===e?"null":Array.isArray(e)?"array":r(e)},$=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 c=O[e]||{},u=Object.keys(a),d={},l=0;l