turbolink-ai 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1 +1 @@
1
- var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,s=(t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,a=(e,t)=>{for(var n in t||(t={}))r.call(t,n)&&s(e,n,t[n]);if(o)for(var n of o(t))i.call(t,n)&&s(e,n,t[n]);return e},c=(e,t,n)=>(s(e,"symbol"!=typeof t?t+"":t,n),n),l=(e,t,n)=>new Promise(((o,r)=>{var i=e=>{try{a(n.next(e))}catch(e){r(e)}},s=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,s);a((n=n.apply(e,t)).next())}));let d="https://www.allapp.link";const u=({url:e,method:t="POST",headers:n,params:o})=>new Promise((r=>{const i=a({"Content-Type":"application/json;charset=utf-8"},n);z.appKey&&(i.Authorization="Bearer "+z.appKey),fetch(d+e,{method:t,headers:i,body:JSON.stringify(o)}).then((e=>{if(e.ok)return e.json();throw new Error("Network response was not ok.")})).then((e=>{r(e)})).catch((e=>{r(e)}))}));var p="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function f(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function h(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})})),n}var g={exports:{}};var m={exports:{}};const y=h(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var w,v,b,_,S,C,x,I,E;function A(){return w||(w=1,m.exports=(e=e||function(e,t){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(n=globalThis.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==p&&p.crypto&&(n=p.crypto),!n)try{n=y}catch(e){}var o=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},r=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),i={},s=i.lib={},a=s.Base={extend:function(e){var t=r(this);return e&&t.mixIn(e),(!t.hasOwnProperty("init")||this.init===t.init)&&(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=s.WordArray=a.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||d).stringify(this)},concat:function(e){var t=this.words,n=e.words,o=this.sigBytes,r=e.sigBytes;if(this.clamp(),o%4)for(var i=0;i<r;i++){var s=n[i>>>2]>>>24-i%4*8&255;t[o+i>>>2]|=s<<24-(o+i)%4*8}else for(var a=0;a<r;a+=4)t[o+a>>>2]=n[a>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(o());return new c.init(t,e)}}),l=i.enc={},d=l.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,o=[],r=0;r<n;r++){var i=t[r>>>2]>>>24-r%4*8&255;o.push((i>>>4).toString(16)),o.push((15&i).toString(16))}return o.join("")},parse:function(e){for(var t=e.length,n=[],o=0;o<t;o+=2)n[o>>>3]|=parseInt(e.substr(o,2),16)<<24-o%8*4;return new c.init(n,t/2)}},u=l.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,o=[],r=0;r<n;r++){var i=t[r>>>2]>>>24-r%4*8&255;o.push(String.fromCharCode(i))}return o.join("")},parse:function(e){for(var t=e.length,n=[],o=0;o<t;o++)n[o>>>2]|=(255&e.charCodeAt(o))<<24-o%4*8;return new c.init(n,t)}},f=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},h=s.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=f.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n,o=this._data,r=o.words,i=o.sigBytes,s=this.blockSize,a=i/(4*s),l=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*s,d=e.min(4*l,i);if(l){for(var u=0;u<l;u+=s)this._doProcessBlock(r,u);n=r.splice(0,l),o.sigBytes-=d}return new c.init(n,d)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});s.Hasher=h.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new g.HMAC.init(e,n).finalize(t)}}});var g=i.algo={};return i}(Math),e)),m.exports;var e}const P=f(g.exports=(E=A(),b=(v=E).lib,_=b.WordArray,S=b.Hasher,C=v.algo,x=[],I=C.SHA1=S.extend({_doReset:function(){this._hash=new _.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=this._hash.words,o=n[0],r=n[1],i=n[2],s=n[3],a=n[4],c=0;c<80;c++){if(c<16)x[c]=0|e[t+c];else{var l=x[c-3]^x[c-8]^x[c-14]^x[c-16];x[c]=l<<1|l>>>31}var d=(o<<5|o>>>27)+a+x[c];d+=c<20?1518500249+(r&i|~r&s):c<40?1859775393+(r^i^s):c<60?(r&i|r&s|i&s)-1894007588:(r^i^s)-899497514,a=s,s=i,i=r<<30|r>>>2,r=o,o=d}n[0]=n[0]+o|0,n[1]=n[1]+r|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,o=8*e.sigBytes;return t[o>>>5]|=128<<24-o%32,t[14+(o+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(o+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=S.clone.call(this);return e._hash=this._hash.clone(),e}}),v.SHA1=S._createHelper(I),v.HmacSHA1=S._createHmacHelper(I),E.SHA1)),k="tb_cookie_obj",O="tb_randomId",U="tb_load_url",L="tb_load_source_url",j="tb_ascribe_to_url",B="tb_source_ascribe_to";class T{constructor(e=!0){this.storage=e?localStorage:sessionStorage}set(e,t){this.storage.setItem(e,JSON.stringify(t))}get(e){const t=this.storage.getItem(e);if(t)return JSON.parse(t)}remove(e){return this.storage.removeItem(e)}clear(){this.storage.clear()}}const $=(e,t)=>{function n(e,t){return e<<t|e>>>32-t}function o(e,t){var n,o,r,i,s;return r=2147483648&e,i=2147483648&t,s=(1073741823&e)+(1073741823&t),(n=1073741824&e)&(o=1073741824&t)?2147483648^s^r^i:n|o?1073741824&s?3221225472^s^r^i:1073741824^s^r^i:s^r^i}function r(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e&t|~e&n}(t,r,i),s),c)),o(n(e,a),t)}function i(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e&n|t&~n}(t,r,i),s),c)),o(n(e,a),t)}function s(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e^t^n}(t,r,i),s),c)),o(n(e,a),t)}function a(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return t^(e|~n)}(t,r,i),s),c)),o(n(e,a),t)}function c(e){var t,n="",o="";for(t=0;t<=3;t++)n+=(o="0"+(e>>>8*t&255).toString(16)).substr(o.length-2,2);return n}var l,d,u,p,f,h,g,m,y,w=Array();for(w=function(e){for(var t,n=e.length,o=n+8,r=16*((o-o%64)/64+1),i=Array(r-1),s=0,a=0;a<n;)s=a%4*8,i[t=(a-a%4)/4]=i[t]|e.charCodeAt(a)<<s,a++;return s=a%4*8,i[t=(a-a%4)/4]=i[t]|128<<s,i[r-2]=n<<3,i[r-1]=n>>>29,i}(e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n<e.length;n++){var o=e.charCodeAt(n);o<128?t+=String.fromCharCode(o):o>127&&o<2048?(t+=String.fromCharCode(o>>6|192),t+=String.fromCharCode(63&o|128)):(t+=String.fromCharCode(o>>12|224),t+=String.fromCharCode(o>>6&63|128),t+=String.fromCharCode(63&o|128))}return t}(e)),h=1732584193,g=4023233417,m=2562383102,y=271733878,l=0;l<w.length;l+=16)d=h,u=g,p=m,f=y,h=r(h,g,m,y,w[l+0],7,3614090360),y=r(y,h,g,m,w[l+1],12,3905402710),m=r(m,y,h,g,w[l+2],17,606105819),g=r(g,m,y,h,w[l+3],22,3250441966),h=r(h,g,m,y,w[l+4],7,4118548399),y=r(y,h,g,m,w[l+5],12,1200080426),m=r(m,y,h,g,w[l+6],17,2821735955),g=r(g,m,y,h,w[l+7],22,4249261313),h=r(h,g,m,y,w[l+8],7,1770035416),y=r(y,h,g,m,w[l+9],12,2336552879),m=r(m,y,h,g,w[l+10],17,4294925233),g=r(g,m,y,h,w[l+11],22,2304563134),h=r(h,g,m,y,w[l+12],7,1804603682),y=r(y,h,g,m,w[l+13],12,4254626195),m=r(m,y,h,g,w[l+14],17,2792965006),h=i(h,g=r(g,m,y,h,w[l+15],22,1236535329),m,y,w[l+1],5,4129170786),y=i(y,h,g,m,w[l+6],9,3225465664),m=i(m,y,h,g,w[l+11],14,643717713),g=i(g,m,y,h,w[l+0],20,3921069994),h=i(h,g,m,y,w[l+5],5,3593408605),y=i(y,h,g,m,w[l+10],9,38016083),m=i(m,y,h,g,w[l+15],14,3634488961),g=i(g,m,y,h,w[l+4],20,3889429448),h=i(h,g,m,y,w[l+9],5,568446438),y=i(y,h,g,m,w[l+14],9,3275163606),m=i(m,y,h,g,w[l+3],14,4107603335),g=i(g,m,y,h,w[l+8],20,1163531501),h=i(h,g,m,y,w[l+13],5,2850285829),y=i(y,h,g,m,w[l+2],9,4243563512),m=i(m,y,h,g,w[l+7],14,1735328473),h=s(h,g=i(g,m,y,h,w[l+12],20,2368359562),m,y,w[l+5],4,4294588738),y=s(y,h,g,m,w[l+8],11,2272392833),m=s(m,y,h,g,w[l+11],16,1839030562),g=s(g,m,y,h,w[l+14],23,4259657740),h=s(h,g,m,y,w[l+1],4,2763975236),y=s(y,h,g,m,w[l+4],11,1272893353),m=s(m,y,h,g,w[l+7],16,4139469664),g=s(g,m,y,h,w[l+10],23,3200236656),h=s(h,g,m,y,w[l+13],4,681279174),y=s(y,h,g,m,w[l+0],11,3936430074),m=s(m,y,h,g,w[l+3],16,3572445317),g=s(g,m,y,h,w[l+6],23,76029189),h=s(h,g,m,y,w[l+9],4,3654602809),y=s(y,h,g,m,w[l+12],11,3873151461),m=s(m,y,h,g,w[l+15],16,530742520),h=a(h,g=s(g,m,y,h,w[l+2],23,3299628645),m,y,w[l+0],6,4096336452),y=a(y,h,g,m,w[l+7],10,1126891415),m=a(m,y,h,g,w[l+14],15,2878612391),g=a(g,m,y,h,w[l+5],21,4237533241),h=a(h,g,m,y,w[l+12],6,1700485571),y=a(y,h,g,m,w[l+3],10,2399980690),m=a(m,y,h,g,w[l+10],15,4293915773),g=a(g,m,y,h,w[l+1],21,2240044497),h=a(h,g,m,y,w[l+8],6,1873313359),y=a(y,h,g,m,w[l+15],10,4264355552),m=a(m,y,h,g,w[l+6],15,2734768916),g=a(g,m,y,h,w[l+13],21,1309151649),h=a(h,g,m,y,w[l+4],6,4149444226),y=a(y,h,g,m,w[l+11],10,3174756917),m=a(m,y,h,g,w[l+2],15,718787259),g=a(g,m,y,h,w[l+9],21,3951481745),h=o(h,d),g=o(g,u),m=o(m,p),y=o(y,f);return 32===t?(c(h)+c(g)+c(m)+c(y)).toLowerCase():(c(g)+c(m)).toLowerCase()},R=(e,t)=>l(void 0,null,(function*(){const n=t||function(){};try{const t=new T;let o=t.get(k);const r=o?JSON.parse(o):{},i=r?r[e]:null;if(""!==i&&i)n(i);else{const o=function(e){const t=new T(!0);let n=t.get(O);if(!n||""===n){const o="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";let r="";for(let t=0;t<e;t++){const e=Math.floor(Math.random()*o.length);r+=o.charAt(e)}n=r,t.set(O,n)}return n}(32),i=navigator.language,s=D(),a=K(),c=yield u({url:"/ecl/bs/check",params:{bfp:o,language:i,screen_width:s,screen_height:a}}),{code:l,data:d}=c||{};200===l&&d&&(r[e]=d.cookie_id,t.set(k,JSON.stringify(r))),n(d.cookie_id)}}catch(e){n("1")}}));const D=()=>{let e=0;try{e=window.screen.width}catch(t){e=0}return e},K=()=>{let e=0;try{e=window.screen.height}catch(t){e=0}return e},M={SUCCESS:{code:200,message:"Success"},UNKNOWN:{code:9999,message:"Unknown"},LACK_APPKEY:{code:1001,message:"Missing appKey parameter"},LACK_APPSECRET:{code:1002,message:"Missing appSecret parameter"},LACK_PROJECTID:{code:1003,message:"Missing projectId parameter"},NOT_INIT:{code:1004,message:"Please call the init method first"},EMPTY_EVENT_NAME:{code:1005,message:"Event name cannot be empty"},INVALID_URL:{code:1006,message:"Invalid URL"},LACK_UID:{code:1007,message:"Missing uId parameter"},LACK_CODE:{code:1008,message:"Please enter the code"}},N={name:"turbolink-ai",version:"1.2.0",description:"",main:"dist/index.es.js",module:"dist/index.es.js",type:"module",scripts:{test:'echo "Error: no test specified" && exit 1',build:"vite build"},author:"",license:"MIT",devDependencies:{"@babel/plugin-transform-modules-commonjs":"^7.23.3","crypto-js":"^4.2.0",eslint:"^8.53.0","rollup-plugin-terser":"^7.0.2",vite:"^4.5.0"},dependencies:{"javascript-obfuscator":"^4.1.0"}};let z={appKey:"",appSecret:"",projectId:""},H="",V="",W="",F=!1,Y=!0,J="";let X="";const G=e=>new Promise((t=>{Q("install").then((n=>{t(n),e&&e(n)}))})),Z=e=>new Promise((t=>{Q("open").then((n=>{t(n),e&&e(n)}))})),q=()=>!(null===H||""===H||" "===H||void 0===H),Q=(e,t)=>new Promise((n=>{try{const{appKey:o,appSecret:r,projectId:i}=z||{},{customData:s,nativeMsg:a=""}=t||{};if(""===o||!o||""===r||!r||""===i||!i)throw M.NOT_INIT;if(!e||""===e)throw M.EMPTY_EVENT_NAME;R(i,(t=>l(void 0,null,(function*(){var o,c;const d=D(),p=K(),f=(new Date).valueOf(),h=null==f?void 0:f.toString(),g=null==(o=P(`${i}_${h}_${f}_${r}`))?void 0:o.toString(),m=(()=>{let e="Android";try{const t=navigator.userAgent.toLowerCase();/android/.test(t)?e="Android":/iphone|ipad|ipod/.test(t)?e="iOS":/win/.test(t)?e="Windows":/mac/.test(t)?e="macOS":/linux/.test(t)&&(e="Linux")}catch(t){e="Android"}return e})(),y=yield l(void 0,null,(function*(){const e=navigator.userAgent.toLowerCase();let t="";try{if(/android/.test(e))if(navigator.userAgent.indexOf("(Linux; Android 10; K)")>-1&&navigator.userAgentData){const e=yield navigator.userAgentData.getHighEntropyValues(["platformVersion","model"]);t=e&&e.platformVersion}else t=e.match(/android\s([0-9.]+)/)[1];else/iphone|ipad|ipod/.test(e)?t=e.match(/os\s([\d_]+)/)[1].replace(/_/g,"."):/win/.test(e)?t=e.match(/windows\snt\s([\d.]+)/)[1]:/mac/.test(e)?t=e.match(/os x\s([\d_]+)/)[1].replace(/_/g,"."):/linux/.test(e)&&(t="Unknown")}catch(e){t="Unknown"}return t})),w=yield l(void 0,null,(function*(){const e=navigator.userAgent;let t="Windows";try{if(e.includes("iPhone"))t="iPhone";else if(e.includes("iPad"))t="iPad";else if(e.includes("Android"))if(e.indexOf("(Linux; Android 10; K)")>-1&&navigator.userAgentData){const e=yield navigator.userAgentData.getHighEntropyValues(["platformVersion","model"]);t=e&&e.model||"Windows"}else if(e.includes("Build")){const n=e.match(/Android.*; ?(.*(?= Build))/);n&&n.length>1&&(t=n[1])}else if(e.includes("wv")){const n=e.match(/Android.*; ?(.*(?= wv))/);if(n&&n.length>0){const e=n[0].split(";");e&&e.length>1&&(t=e[1])}}else{const n=e.match(/Android.*; ([^)]+)/);n&&n.length>1&&(t=n[1])}else e.includes("Mac")&&(t="Mac")}catch(e){t="Windows"}return t})),v=yield new Promise((e=>{try{const t=new RTCPeerConnection;t.createDataChannel(""),t.onicecandidate=function(n){if(n.candidate){const o=n.candidate.candidate,r=/(?:[0-9]{1,3}\.){3}[0-9]{1,3}/.exec(o),i=r?r[0]:null;e(i),t.close()}else e()},t.createOffer().then((e=>t.setLocalDescription(e))).catch((()=>{e()}))}catch(t){e()}})),b=(()=>{let e="Unknown";try{e=(navigator.language||navigator.userLanguage).substring(3).toUpperCase()}catch(t){e="Unknown"}return e})(),_=(()=>{let e="Unknown";try{e=(navigator.language||navigator.userLanguage).substring(0,2).toLowerCase()}catch(t){e="Unknown"}return e})(),S=(()=>{const e=navigator.userAgent;return-1!==e.indexOf("Firefox")?"Firefox":-1!==e.indexOf("Opera")||-1!==e.indexOf("OPR")?"Opera":-1!==e.indexOf("Trident")?"IE":-1!==e.indexOf("Edge")?"Edge":-1!==e.indexOf("Chrome")?"Chrome":-1!==e.indexOf("Safari")?"Safari":"unknown"})(),C=null==(c=(()=>{let e=0;try{const t=navigator.userAgent;-1!==t.indexOf("Firefox")?e=parseFloat(null==t?void 0:t.match(/Firefox\/([\d.]+)/)[1])||0:-1!==t.indexOf("Edge")?e=parseFloat(null==t?void 0:t.match(/Edge\/([\d.]+)/)[1])||0:-1!==t.indexOf("Chrome")?e=parseFloat(null==t?void 0:t.match(/Chrome\/([\d.]+)/)[1])||0:-1!==t.indexOf("Safari")?e=parseFloat(null==t?void 0:t.match(/Version\/([\d.]+)/)[1])||0:(-1!==t.indexOf("MSIE")||-1!==t.indexOf("Trident/"))&&(e=parseFloat((null==t?void 0:t.match(/MSIE (\d+[.]\d+)|(?:Trident\/[\d.]+).*rv:([\d.]+)/)[1])||(null==t?void 0:t.match(/rv:([\d.]+)/)))||0)}catch(t){e=0}return e})())?void 0:c.toString(),x=(null==N?void 0:N.version)||"1.0.0",I=`${d}x${p}`,E=window.location.href,A=navigator.userAgent,k="UTC+"+(0-(new Date).getTimezoneOffset()/60),O=document.referrer,R=(()=>{const e=document.createElement("canvas"),t=e.getContext("2d"),n="turbolink <canvas> 1.0";t.textBaseline="top",t.font="14px 'Arial'",t.textBaseline="alphabetic",t.fillStyle="#f60",t.fillRect(125,1,62,20),t.fillStyle="#069",t.fillText(n,2,15),t.fillStyle="rgba(102, 204, 0, 0.7)",t.fillText(n,4,17);const o=e.toDataURL();return $(o,32)})(),M={web:{browser_name:S,browser_version:C,current_time:f,device_type:w,ip:v||"",language:_,os:m,screen_resolution:I,sdk_version:x,url:E,user_agent:A,time_zone:k,referer:O,canvas:R}};let z=[];s&&s.constructor===Array&&(z=s.map((e=>{const t={};return Object.keys(e).forEach((n=>{const o=e[n];t[n]="string"!=typeof o?String(o):o})),t})));const V={project:i,request_id:h,timestamp:f,msg_signature:g,event:e,user_data:{native_msg:a,os:m,os_version:y,device_model:w,device_id:t,user_id:null==H?void 0:H.toString(),country:b,language:_,screen_width:d,screen_height:p,ip:v||""},custom_data:z,ext_data:M},W=yield u({url:"/v2/event",params:V}),{code:F,data:G,msg:Z}=W||{};if(200===F&&G){let e="";const t=G.link_data||[];G.blackbox&&""!==G.blackbox&&(X=G.blackbox||"");for(let n=0;n<t.length;n++)if("$campaign_reward_url"===t[n].key){e=decodeURIComponent(t[n].value||"");break}if(Y&&""!==e){let t=ee(e);if(J&&""!==J){const e=encodeURIComponent(J);t=`${t}&loginUrl=${e}`}q()||(sessionStorage.setItem(j,t),sessionStorage.setItem(B,"1")),(new T).set(U,e),H||sessionStorage.setItem(L,"1"),setTimeout((()=>{window.location.href=t}),150)}n({code:F,message:Z,data:G})}else n({code:F,message:Z})}))))}catch(e){n(e)}})),ee=e=>{if(!e||""===e)return"";const t=H||"",n=navigator.language,o=V||n||"",r=Math.floor((new Date).getTime()/1e3),i="1.2.0",s=r%100,a="5CfUxPK7avjguYtG8yAE4ud6n9s774zVVdKwSxPryzaKHSpS4Lgju4M7sLumdLuQWXpHC6peBp2afBwEBbYnENGbZWfkZ6n4s52D3Xye59bfeK4gS9nfjehK".substring(s,s+12),c=`${t}${W}${o}${r}${X}${i}web${z.appSecret}${a}`,l=$(c,32);return((e,t)=>{const n=new URL(e),o=n.searchParams;return t.forEach((e=>{const{name:t,value:n}=e;o.has(t)?o.set(t,n):o.append(t,n)})),n.origin+n.pathname+"?"+o.toString()})(e,[{name:"user_id",value:t},{name:"lv",value:W},{name:"lg",value:o},{name:"time",value:r},{name:"blackbox",value:X},{name:"version",value:i},{name:"platform",value:"web"},{name:"token",value:l}])},te=e=>l(void 0,null,(function*(){const t="https://i1.branchcn.com/web/sdk/img/campBg.png",n={campaign_id:e,project_id:null==z?void 0:z.projectId},o=yield u({url:"/v2/campaign/sdk-info",params:n}),r=document.getElementById("turbolinkSdkBgImg"),{code:i,data:s}=o||{};if(200===i&&s){const{pc_bg:e}=s||{};r&&(r.src=e&&""!==e?e:t)}else r&&(r.src=t)}));class ne{}c(ne,"init",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{appKey:t,appSecret:r,projectId:i,uid:s,lang:a,lv:c,loginUrl:l,jump:u=!0,dev:p=!1}=e||{};if(!t||""===t)throw M.LACK_APPKEY;if(!r||""===r)throw M.LACK_APPSECRET;if(!i||""===i)throw M.LACK_PROJECTID;p&&(e=>{e&&(d="https://test.allapp.link")})(p),s&&(H=s),a&&(V=a),c&&(W=c),l&&(J=l),Y=u,z=e||{};let f=(new T).get(O);if(F)return n(M.SUCCESS),void o(M.SUCCESS);null==f||" "===f||""===f?G().then((e=>{n(e),o(e)})):Z().then((e=>{if(n(e),o(e),q()){const e=sessionStorage.getItem(j),t=sessionStorage.getItem(B);if(t&&"1"===t){let t=ee(e);if(sessionStorage.removeItem(B),sessionStorage.removeItem(j),sessionStorage.removeItem(L),J&&""!==J){t=`${t}&loginUrl=${encodeURIComponent(J)}`}window.location.replace(t&&t)}}})),F=!0}catch(e){n(e),o(e)}})))),c(ne,"setIdentity",((e,t)=>new Promise((n=>{const{SUCCESS:o,UNKNOWN:r}=M||{};try{if("object"==typeof e&&null!==e){const{uid:t,lv:n}=e||{};t&&(H=t),n&&(W=n)}else H=e;n(o),t&&t(o)}catch(e){n(r),t&&t(r)}})))),c(ne,"install",G),c(ne,"register",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{uid:t,uId:r,lv:i,toActivity:s=!0}=e||{};if(!(t&&""!==t||r&&""!==r))throw M.LACK_UID;t&&(H=t),r&&(H=r),Q("register").then((e=>{const t=(new T).get(U),r=sessionStorage.getItem(L);if(r&&"1"===r&&s){sessionStorage.removeItem(L);const e=ee(t);window.location.replace(e&&e)}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(ne,"open",Z),c(ne,"customEvent",((e,o)=>new Promise((r=>{const i=o||function(){};try{const{event:o,customData:s,backCamp:c}=e||{};if(!o||""===o)throw M.EMPTY_EVENT_NAME;Q(o,{customData:s}).then((e=>{const o=(new T).get(U),s=ee(o),l=((e,o)=>t(e,n(o)))(a({},e),{campUrl:s});c&&s&&setTimeout((()=>{window.location.replace(s)}),1e3),r(l),i(l)}))}catch(e){r(e),i(e)}})))),c(ne,"loadUrl",((e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=M||{},{url:i,newWindow:s=!1}=e||{};try{if(!z.appSecret||""===z.appSecret)throw M.LACK_APPSECRET;if(!i||""===i)throw M.INVALID_URL;let e=ee(i);if(J&&""!==J){e=`${e}&loginUrl=${encodeURIComponent(J)}`}(new T).set(U,i),H||sessionStorage.setItem(L,"1"),!0===s||"true"===s?window.open(e,"_blank"):window.location.href=e,o(r),n(r),Q("loadUrl")}catch(e){n(e),o(e)}})))),c(ne,"webLoadUrl",((e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=M||{},i=650,{url:s,maskColor:a="rgba(0, 0, 0, 0.8)",backgroundImage:c,backgroundHeight:l=738,backgroundWidth:d,bgLinkage:u=!1,width:p=300,height:f=i,radius:h=12,zIndex:g=3e3,clickEventCallback:m,bodyHidden:y=!0,jumpNewWindow:w=!1}=e||{};try{if(!z.appSecret||""===z.appSecret)throw M.LACK_APPSECRET;if(!s||""===s)throw M.INVALID_URL;const e=new URL(s),t=new URLSearchParams(e.search).get("l");let v=ee(s);if(v=`${v}&webIframe=1`,w&&(v=`${v}&jpN=1`),J&&""!==J){v=`${v}&loginUrl=${encodeURIComponent(J)}`}let b=document.getElementById("turbolinkSdkPopup");b&&b.remove();const _=document.createElement("div");_.id="turbolinkSdkPopup",_.style.position="fixed",_.style.zIndex=g,_.style.left="0",_.style.top="0",_.style.right="0",_.style.bottom="0",_.style.width="100%",_.style.height="100%",_.style.overflowX="hidden",_.style.overflowY="auto",_.style.backgroundColor=a;const S=document.createElement("div");S.style.minHeight="100%",S.style.display="-webkit-box",S.style.display="-ms-flexbox",S.style.display="-moz-box",S.style.display="flex",S.style.textAlign="center",S.style.justifyContent="center",S.style.alignItems="center";const C=document.createElement("div");C.style.margin="10vh auto",C.style.border="none",C.style.width=`${p}px`,C.style.height=`${f}px`,C.style.position="relative",C.style.borderRadius=`${h}px`,C.style.display="-webkit-box",C.style.display="-ms-flexbox",C.style.display="-moz-box",C.style.display="flex",C.style.textAlign="center",C.style.justifyContent="center",C.style.alignItems="center";const x=document.createElement("iframe");x.id="turbolinkSdkPopupIframe",x.width=`${p}px`,x.height=`${f}px`,x.style.border="none",x.style.borderRadius=`${h}px`,x.style.overflow="hidden",x.style.position="relative",x.style.zIndex="10",x.src=v;const I=document.createElement("div"),E=document.createElement("img");let A=l;u&&(A=f*(A/i)),I.style.height=`${A}px`,x.onload=()=>{I.style.position="absolute",I.style.fontSize="0px",I.style.zIndex="6",E.id="turbolinkSdkBgImg",c&&""!==c?E.src=c:te(t),E.style.width=d||"auto",E.style.height="100%",E.style.setProperty("max-width","none","important"),E.style.setProperty("max-height","none","important"),I.appendChild(E)};const P=document.createElement("div"),k=document.createElement("img");P.style.position="absolute",P.style.fontSize="0px",P.style.zIndex="100",P.style.top="-54px",P.style.right="-200px",k.src="https://i1.branchcn.com/web/sdk/img/campClose.png",k.style.width="40px",k.style.height="auto",P.appendChild(k);const O=e=>{const t=(null==e?void 0:e.data)||{};if(t){const n=(null==t?void 0:t.source)||"";n&&"turbolink"===n&&m(e.data)}};m&&(window.removeEventListener("message",O),window.addEventListener("message",O)),P.addEventListener("click",(()=>{_.remove(),y&&(document.body.style.overflow="auto"),m&&(m({type:"linkCloseListener",params:null}),window.removeEventListener("message",O))})),C.appendChild(I),C.appendChild(x),C.appendChild(P),S.appendChild(C),_.appendChild(S),document.body.appendChild(_),y&&(document.body.style.overflow="hidden"),o(r),n(r)}catch(e){n(e),o(e)}})))),c(ne,"closeWebUrl",(e=>new Promise((t=>{const n=e||function(){},{SUCCESS:o}=M||{};try{document.getElementById("turbolinkSdkPopup").remove(),n(o),t(o)}catch(e){t(e),n(e)}})))),c(ne,"login",((e,t)=>new Promise((n=>{const o=t||function(){},{uid:r,uId:i,lv:s,toActivity:a=!0}=e||{};try{if(!(r&&""!==r||i&&""!==i))throw M.LACK_UID;r&&(H=r),i&&(H=i),Q("login").then((e=>{const t=(new T).get(U),r=sessionStorage.getItem(L);if(r&&"1"===r&&a){sessionStorage.removeItem(L);const e=ee(t);window.location.replace(e&&e)}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(ne,"logout",(e=>new Promise((t=>{const n=e||function(){};(new T).remove(U),sessionStorage.removeItem(L),H=null;const{SUCCESS:o}=M||{};t(o),n(o),Q("logout")})))),c(ne,"getInitState",(()=>F)),c(ne,"getLoginState",q),c(ne,"codeSearch",((e,t)=>new Promise((n=>{const o=t||function(){};try{if(!e||" "===e)throw M.LACK_CODE;Q("code_search",{nativeMsg:e}).then((e=>{n(e),o(e)}))}catch(e){n(e),o(e)}}))));export{ne as default};
1
+ var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,s=(t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,a=(e,t)=>{for(var n in t||(t={}))r.call(t,n)&&s(e,n,t[n]);if(o)for(var n of o(t))i.call(t,n)&&s(e,n,t[n]);return e},c=(e,t,n)=>(s(e,"symbol"!=typeof t?t+"":t,n),n),l=(e,t,n)=>new Promise(((o,r)=>{var i=e=>{try{a(n.next(e))}catch(e){r(e)}},s=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,s);a((n=n.apply(e,t)).next())}));let d="https://www.allapp.link";const u=({url:e,method:t="POST",headers:n,params:o})=>new Promise((r=>{const i=a({"Content-Type":"application/json;charset=utf-8"},n);H.appKey&&(i.Authorization="Bearer "+H.appKey),fetch(d+e,{method:t,headers:i,body:JSON.stringify(o)}).then((e=>{if(e.ok)return e.json();throw new Error("Network response was not ok.")})).then((e=>{r(e)})).catch((e=>{r(e)}))}));var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function g(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})})),n}var h={exports:{}};var m={exports:{}};const y=g(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var w,v,b,S,_,C,x,I,E;function P(){return w||(w=1,m.exports=(e=e||function(e,t){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(n=globalThis.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==f&&f.crypto&&(n=f.crypto),!n)try{n=y}catch(e){}var o=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},r=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),i={},s=i.lib={},a=s.Base={extend:function(e){var t=r(this);return e&&t.mixIn(e),(!t.hasOwnProperty("init")||this.init===t.init)&&(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=s.WordArray=a.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||d).stringify(this)},concat:function(e){var t=this.words,n=e.words,o=this.sigBytes,r=e.sigBytes;if(this.clamp(),o%4)for(var i=0;i<r;i++){var s=n[i>>>2]>>>24-i%4*8&255;t[o+i>>>2]|=s<<24-(o+i)%4*8}else for(var a=0;a<r;a+=4)t[o+a>>>2]=n[a>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(o());return new c.init(t,e)}}),l=i.enc={},d=l.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,o=[],r=0;r<n;r++){var i=t[r>>>2]>>>24-r%4*8&255;o.push((i>>>4).toString(16)),o.push((15&i).toString(16))}return o.join("")},parse:function(e){for(var t=e.length,n=[],o=0;o<t;o+=2)n[o>>>3]|=parseInt(e.substr(o,2),16)<<24-o%8*4;return new c.init(n,t/2)}},u=l.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,o=[],r=0;r<n;r++){var i=t[r>>>2]>>>24-r%4*8&255;o.push(String.fromCharCode(i))}return o.join("")},parse:function(e){for(var t=e.length,n=[],o=0;o<t;o++)n[o>>>2]|=(255&e.charCodeAt(o))<<24-o%4*8;return new c.init(n,t)}},p=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},g=s.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n,o=this._data,r=o.words,i=o.sigBytes,s=this.blockSize,a=i/(4*s),l=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*s,d=e.min(4*l,i);if(l){for(var u=0;u<l;u+=s)this._doProcessBlock(r,u);n=r.splice(0,l),o.sigBytes-=d}return new c.init(n,d)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});s.Hasher=g.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){g.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new h.HMAC.init(e,n).finalize(t)}}});var h=i.algo={};return i}(Math),e)),m.exports;var e}const k=p(h.exports=(E=P(),b=(v=E).lib,S=b.WordArray,_=b.Hasher,C=v.algo,x=[],I=C.SHA1=_.extend({_doReset:function(){this._hash=new S.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=this._hash.words,o=n[0],r=n[1],i=n[2],s=n[3],a=n[4],c=0;c<80;c++){if(c<16)x[c]=0|e[t+c];else{var l=x[c-3]^x[c-8]^x[c-14]^x[c-16];x[c]=l<<1|l>>>31}var d=(o<<5|o>>>27)+a+x[c];d+=c<20?1518500249+(r&i|~r&s):c<40?1859775393+(r^i^s):c<60?(r&i|r&s|i&s)-1894007588:(r^i^s)-899497514,a=s,s=i,i=r<<30|r>>>2,r=o,o=d}n[0]=n[0]+o|0,n[1]=n[1]+r|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,o=8*e.sigBytes;return t[o>>>5]|=128<<24-o%32,t[14+(o+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(o+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=_.clone.call(this);return e._hash=this._hash.clone(),e}}),v.SHA1=_._createHelper(I),v.HmacSHA1=_._createHmacHelper(I),E.SHA1)),A="tb_cookie_obj",O="tb_randomId",U="tb_load_url",L="tb_load_source_url",j="tb_ascribe_to_url",B="tb_init_state",T="tb_blackbox";class ${constructor(e=!0){this.storage=e?localStorage:sessionStorage}set(e,t){this.storage.setItem(e,JSON.stringify(t))}get(e){const t=this.storage.getItem(e);if(t)return JSON.parse(t)}remove(e){return this.storage.removeItem(e)}clear(){this.storage.clear()}}const R=(e,t)=>{function n(e,t){return e<<t|e>>>32-t}function o(e,t){var n,o,r,i,s;return r=2147483648&e,i=2147483648&t,s=(1073741823&e)+(1073741823&t),(n=1073741824&e)&(o=1073741824&t)?2147483648^s^r^i:n|o?1073741824&s?3221225472^s^r^i:1073741824^s^r^i:s^r^i}function r(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e&t|~e&n}(t,r,i),s),c)),o(n(e,a),t)}function i(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e&n|t&~n}(t,r,i),s),c)),o(n(e,a),t)}function s(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e^t^n}(t,r,i),s),c)),o(n(e,a),t)}function a(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return t^(e|~n)}(t,r,i),s),c)),o(n(e,a),t)}function c(e){var t,n="",o="";for(t=0;t<=3;t++)n+=(o="0"+(e>>>8*t&255).toString(16)).substr(o.length-2,2);return n}var l,d,u,f,p,g,h,m,y,w=Array();for(w=function(e){for(var t,n=e.length,o=n+8,r=16*((o-o%64)/64+1),i=Array(r-1),s=0,a=0;a<n;)s=a%4*8,i[t=(a-a%4)/4]=i[t]|e.charCodeAt(a)<<s,a++;return s=a%4*8,i[t=(a-a%4)/4]=i[t]|128<<s,i[r-2]=n<<3,i[r-1]=n>>>29,i}(e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n<e.length;n++){var o=e.charCodeAt(n);o<128?t+=String.fromCharCode(o):o>127&&o<2048?(t+=String.fromCharCode(o>>6|192),t+=String.fromCharCode(63&o|128)):(t+=String.fromCharCode(o>>12|224),t+=String.fromCharCode(o>>6&63|128),t+=String.fromCharCode(63&o|128))}return t}(e)),g=1732584193,h=4023233417,m=2562383102,y=271733878,l=0;l<w.length;l+=16)d=g,u=h,f=m,p=y,g=r(g,h,m,y,w[l+0],7,3614090360),y=r(y,g,h,m,w[l+1],12,3905402710),m=r(m,y,g,h,w[l+2],17,606105819),h=r(h,m,y,g,w[l+3],22,3250441966),g=r(g,h,m,y,w[l+4],7,4118548399),y=r(y,g,h,m,w[l+5],12,1200080426),m=r(m,y,g,h,w[l+6],17,2821735955),h=r(h,m,y,g,w[l+7],22,4249261313),g=r(g,h,m,y,w[l+8],7,1770035416),y=r(y,g,h,m,w[l+9],12,2336552879),m=r(m,y,g,h,w[l+10],17,4294925233),h=r(h,m,y,g,w[l+11],22,2304563134),g=r(g,h,m,y,w[l+12],7,1804603682),y=r(y,g,h,m,w[l+13],12,4254626195),m=r(m,y,g,h,w[l+14],17,2792965006),g=i(g,h=r(h,m,y,g,w[l+15],22,1236535329),m,y,w[l+1],5,4129170786),y=i(y,g,h,m,w[l+6],9,3225465664),m=i(m,y,g,h,w[l+11],14,643717713),h=i(h,m,y,g,w[l+0],20,3921069994),g=i(g,h,m,y,w[l+5],5,3593408605),y=i(y,g,h,m,w[l+10],9,38016083),m=i(m,y,g,h,w[l+15],14,3634488961),h=i(h,m,y,g,w[l+4],20,3889429448),g=i(g,h,m,y,w[l+9],5,568446438),y=i(y,g,h,m,w[l+14],9,3275163606),m=i(m,y,g,h,w[l+3],14,4107603335),h=i(h,m,y,g,w[l+8],20,1163531501),g=i(g,h,m,y,w[l+13],5,2850285829),y=i(y,g,h,m,w[l+2],9,4243563512),m=i(m,y,g,h,w[l+7],14,1735328473),g=s(g,h=i(h,m,y,g,w[l+12],20,2368359562),m,y,w[l+5],4,4294588738),y=s(y,g,h,m,w[l+8],11,2272392833),m=s(m,y,g,h,w[l+11],16,1839030562),h=s(h,m,y,g,w[l+14],23,4259657740),g=s(g,h,m,y,w[l+1],4,2763975236),y=s(y,g,h,m,w[l+4],11,1272893353),m=s(m,y,g,h,w[l+7],16,4139469664),h=s(h,m,y,g,w[l+10],23,3200236656),g=s(g,h,m,y,w[l+13],4,681279174),y=s(y,g,h,m,w[l+0],11,3936430074),m=s(m,y,g,h,w[l+3],16,3572445317),h=s(h,m,y,g,w[l+6],23,76029189),g=s(g,h,m,y,w[l+9],4,3654602809),y=s(y,g,h,m,w[l+12],11,3873151461),m=s(m,y,g,h,w[l+15],16,530742520),g=a(g,h=s(h,m,y,g,w[l+2],23,3299628645),m,y,w[l+0],6,4096336452),y=a(y,g,h,m,w[l+7],10,1126891415),m=a(m,y,g,h,w[l+14],15,2878612391),h=a(h,m,y,g,w[l+5],21,4237533241),g=a(g,h,m,y,w[l+12],6,1700485571),y=a(y,g,h,m,w[l+3],10,2399980690),m=a(m,y,g,h,w[l+10],15,4293915773),h=a(h,m,y,g,w[l+1],21,2240044497),g=a(g,h,m,y,w[l+8],6,1873313359),y=a(y,g,h,m,w[l+15],10,4264355552),m=a(m,y,g,h,w[l+6],15,2734768916),h=a(h,m,y,g,w[l+13],21,1309151649),g=a(g,h,m,y,w[l+4],6,4149444226),y=a(y,g,h,m,w[l+11],10,3174756917),m=a(m,y,g,h,w[l+2],15,718787259),h=a(h,m,y,g,w[l+9],21,3951481745),g=o(g,d),h=o(h,u),m=o(m,f),y=o(y,p);return 32===t?(c(g)+c(h)+c(m)+c(y)).toLowerCase():(c(h)+c(m)).toLowerCase()},D=(e,t)=>l(void 0,null,(function*(){const n=t||function(){};try{const t=new $;let o=t.get(A);const r=o?JSON.parse(o):{},i=r?r[e]:null;if(""!==i&&i)n(i);else{const o=function(e){const t=new $(!0);let n=t.get(O);if(!n||""===n){const o="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";let r="";for(let t=0;t<e;t++){const e=Math.floor(Math.random()*o.length);r+=o.charAt(e)}n=r,t.set(O,n)}return n}(32),i=navigator.language,s=K(),a=M(),c=yield u({url:"/ecl/bs/check",params:{bfp:o,language:i,screen_width:s,screen_height:a}}),{code:l,data:d}=c||{};200===l&&d&&(r[e]=d.cookie_id,t.set(A,JSON.stringify(r))),n(d.cookie_id)}}catch(e){n("1")}}));const K=()=>{let e=0;try{e=window.screen.width}catch(t){e=0}return e},M=()=>{let e=0;try{e=window.screen.height}catch(t){e=0}return e},N={SUCCESS:{code:200,message:"Success"},UNKNOWN:{code:9999,message:"Unknown"},LACK_APPKEY:{code:1001,message:"Missing appKey parameter"},LACK_APPSECRET:{code:1002,message:"Missing appSecret parameter"},LACK_PROJECTID:{code:1003,message:"Missing projectId parameter"},NOT_INIT:{code:1004,message:"Please call the init method first"},EMPTY_EVENT_NAME:{code:1005,message:"Event name cannot be empty"},INVALID_URL:{code:1006,message:"Invalid URL"},LACK_UID:{code:1007,message:"Missing uId parameter"},LACK_CODE:{code:1008,message:"Please enter the code"}},z={name:"turbolink-ai",version:"1.2.2",description:"",main:"dist/index.es.js",module:"dist/index.es.js",type:"module",scripts:{test:'echo "Error: no test specified" && exit 1',build:"vite build"},author:"",license:"MIT",devDependencies:{"@babel/plugin-transform-modules-commonjs":"^7.23.3","crypto-js":"^4.2.0",eslint:"^8.53.0","rollup-plugin-terser":"^7.0.2",vite:"^4.5.0"},dependencies:{"javascript-obfuscator":"^4.1.0"}};let H={appKey:"",appSecret:"",projectId:""},V="",W="",F="",Y=!0,J="",X=null;const G=e=>new Promise((t=>{te("install").then((n=>{t(n),e&&e(n)}))})),Z=e=>new Promise((t=>{te("open").then((n=>{t(n),e&&e(n)}))})),q=(e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=N||{},i=650,{url:s,maskColor:a="rgba(0, 0, 0, 0.8)",backgroundImage:c,backgroundHeight:l=738,backgroundWidth:d,bgLinkage:u=!1,width:f=300,height:p=i,radius:g=12,zIndex:h=3e3,clickEventCallback:m,bodyHidden:y=!0,jumpNewWindow:w=!1}=e||{};try{if(!H.appSecret||""===H.appSecret)throw N.LACK_APPSECRET;if(!s||""===s)throw N.INVALID_URL;const e=new URL(s),t=new URLSearchParams(e.search).get("l");let v=ne(s);if(v=`${v}&webIframe=1`,w&&(v=`${v}&jpN=1`),J&&""!==J){v=`${v}&loginUrl=${encodeURIComponent(J)}`}let b=document.getElementById("turbolinkSdkPopup");b&&b.remove();const S=document.createElement("div");S.id="turbolinkSdkPopup",S.style.position="fixed",S.style.zIndex=h,S.style.left="0",S.style.top="0",S.style.right="0",S.style.bottom="0",S.style.width="100%",S.style.height="100%",S.style.overflowX="hidden",S.style.overflowY="auto",S.style.backgroundColor=a;const _=document.createElement("div");_.style.minHeight="100%",_.style.display="-webkit-box",_.style.display="-ms-flexbox",_.style.display="-moz-box",_.style.display="flex",_.style.textAlign="center",_.style.justifyContent="center",_.style.alignItems="center";const C=document.createElement("div");C.style.margin="10vh auto",C.style.border="none",C.style.width=`${f}px`,C.style.height=`${p}px`,C.style.position="relative",C.style.borderRadius=`${g}px`,C.style.display="-webkit-box",C.style.display="-ms-flexbox",C.style.display="-moz-box",C.style.display="flex",C.style.textAlign="center",C.style.justifyContent="center",C.style.alignItems="center";const x=document.createElement("iframe");x.id="turbolinkSdkPopupIframe",x.width=`${f}px`,x.height=`${p}px`,x.style.border="none",x.style.borderRadius=`${g}px`,x.style.overflow="hidden",x.style.position="relative",x.style.zIndex="10",x.src=v;const I=document.createElement("div"),E=document.createElement("img");let P=l;u&&(P=p*(P/i)),I.style.height=`${P}px`,x.onload=()=>{I.style.position="absolute",I.style.fontSize="0px",I.style.zIndex="6",E.id="turbolinkSdkBgImg",c&&""!==c?E.src=c:oe(t),E.style.width=d||"auto",E.style.height="100%",E.style.setProperty("max-width","none","important"),E.style.setProperty("max-height","none","important"),I.appendChild(E)};const k=document.createElement("div"),A=document.createElement("img");k.style.position="absolute",k.style.fontSize="0px",k.style.zIndex="100",k.style.top="-54px",k.style.right="-200px",A.src="https://i1.branchcn.com/web/sdk/img/campClose.png",A.style.width="40px",A.style.height="auto",k.appendChild(A);const O=e=>{const t=(null==e?void 0:e.data)||{};if(t){const n=(null==t?void 0:t.source)||"";if(n&&"turbolink"===n){const t=m||X;t&&t(e.data)}}};(m||X)&&(window.removeEventListener("message",O),window.addEventListener("message",O)),k.addEventListener("click",(()=>{S.remove(),y&&(document.body.style.overflow="auto");const e=m||X;e&&(e({type:"linkCloseListener",params:null}),window.removeEventListener("message",O))})),C.appendChild(I),C.appendChild(x),C.appendChild(k),_.appendChild(C),S.appendChild(_),document.body.appendChild(S),y&&(document.body.style.overflow="hidden"),o(r),n(r)}catch(e){n(e),o(e)}})),Q=()=>sessionStorage.getItem(B),ee=()=>!(null===V||""===V||" "===V||void 0===V),te=(e,t)=>new Promise((n=>{try{const{appKey:o,appSecret:r,projectId:i}=H||{},{customData:s,nativeMsg:a=""}=t||{};if(""===o||!o||""===r||!r||""===i||!i)throw N.NOT_INIT;if(!e||""===e)throw N.EMPTY_EVENT_NAME;D(i,(t=>l(void 0,null,(function*(){var o,c;const d=K(),f=M(),p=(new Date).valueOf(),g=null==p?void 0:p.toString(),h=null==(o=k(`${i}_${g}_${p}_${r}`))?void 0:o.toString(),m=(()=>{let e="Android";try{const t=navigator.userAgent.toLowerCase();/android/.test(t)?e="Android":/iphone|ipad|ipod/.test(t)?e="iOS":/win/.test(t)?e="Windows":/mac/.test(t)?e="macOS":/linux/.test(t)&&(e="Linux")}catch(t){e="Android"}return e})(),y=yield l(void 0,null,(function*(){const e=navigator.userAgent.toLowerCase();let t="";try{if(/android/.test(e))if(navigator.userAgent.indexOf("(Linux; Android 10; K)")>-1&&navigator.userAgentData){const e=yield navigator.userAgentData.getHighEntropyValues(["platformVersion","model"]);t=e&&e.platformVersion}else t=e.match(/android\s([0-9.]+)/)[1];else/iphone|ipad|ipod/.test(e)?t=e.match(/os\s([\d_]+)/)[1].replace(/_/g,"."):/win/.test(e)?t=e.match(/windows\snt\s([\d.]+)/)[1]:/mac/.test(e)?t=e.match(/os x\s([\d_]+)/)[1].replace(/_/g,"."):/linux/.test(e)&&(t="Unknown")}catch(e){t="Unknown"}return t})),w=yield l(void 0,null,(function*(){const e=navigator.userAgent;let t="Windows";try{if(e.includes("iPhone"))t="iPhone";else if(e.includes("iPad"))t="iPad";else if(e.includes("Android"))if(e.indexOf("(Linux; Android 10; K)")>-1&&navigator.userAgentData){const e=yield navigator.userAgentData.getHighEntropyValues(["platformVersion","model"]);t=e&&e.model||"Windows"}else if(e.includes("Build")){const n=e.match(/Android.*; ?(.*(?= Build))/);n&&n.length>1&&(t=n[1])}else if(e.includes("wv")){const n=e.match(/Android.*; ?(.*(?= wv))/);if(n&&n.length>0){const e=n[0].split(";");e&&e.length>1&&(t=e[1])}}else{const n=e.match(/Android.*; ([^)]+)/);n&&n.length>1&&(t=n[1])}else e.includes("Mac")&&(t="Mac")}catch(e){t="Windows"}return t})),v=yield new Promise((e=>{try{const t=new RTCPeerConnection;t.createDataChannel(""),t.onicecandidate=function(n){if(n.candidate){const o=n.candidate.candidate,r=/(?:[0-9]{1,3}\.){3}[0-9]{1,3}/.exec(o),i=r?r[0]:null;e(i),t.close()}else e()},t.createOffer().then((e=>t.setLocalDescription(e))).catch((()=>{e()}))}catch(t){e()}})),b=(()=>{let e="Unknown";try{e=(navigator.language||navigator.userLanguage).substring(3).toUpperCase()}catch(t){e="Unknown"}return e})(),S=(()=>{let e="Unknown";try{e=(navigator.language||navigator.userLanguage).substring(0,2).toLowerCase()}catch(t){e="Unknown"}return e})(),_=(()=>{const e=navigator.userAgent;return-1!==e.indexOf("Firefox")?"Firefox":-1!==e.indexOf("Opera")||-1!==e.indexOf("OPR")?"Opera":-1!==e.indexOf("Trident")?"IE":-1!==e.indexOf("Edge")?"Edge":-1!==e.indexOf("Chrome")?"Chrome":-1!==e.indexOf("Safari")?"Safari":"unknown"})(),C=null==(c=(()=>{let e=0;try{const t=navigator.userAgent;-1!==t.indexOf("Firefox")?e=parseFloat(null==t?void 0:t.match(/Firefox\/([\d.]+)/)[1])||0:-1!==t.indexOf("Edge")?e=parseFloat(null==t?void 0:t.match(/Edge\/([\d.]+)/)[1])||0:-1!==t.indexOf("Chrome")?e=parseFloat(null==t?void 0:t.match(/Chrome\/([\d.]+)/)[1])||0:-1!==t.indexOf("Safari")?e=parseFloat(null==t?void 0:t.match(/Version\/([\d.]+)/)[1])||0:(-1!==t.indexOf("MSIE")||-1!==t.indexOf("Trident/"))&&(e=parseFloat((null==t?void 0:t.match(/MSIE (\d+[.]\d+)|(?:Trident\/[\d.]+).*rv:([\d.]+)/)[1])||(null==t?void 0:t.match(/rv:([\d.]+)/)))||0)}catch(t){e=0}return e})())?void 0:c.toString(),x=(null==z?void 0:z.version)||"1.0.0",I=`${d}x${f}`,E=window.location.href,P=navigator.userAgent,A="UTC+"+(0-(new Date).getTimezoneOffset()/60),O=document.referrer,B=(()=>{const e=document.createElement("canvas"),t=e.getContext("2d"),n="turbolink <canvas> 1.0";t.textBaseline="top",t.font="14px 'Arial'",t.textBaseline="alphabetic",t.fillStyle="#f60",t.fillRect(125,1,62,20),t.fillStyle="#069",t.fillText(n,2,15),t.fillStyle="rgba(102, 204, 0, 0.7)",t.fillText(n,4,17);const o=e.toDataURL();return R(o,32)})(),$={web:{browser_name:_,browser_version:C,current_time:p,device_type:w,ip:v||"",language:S,os:m,screen_resolution:I,sdk_version:x,url:E,user_agent:P,time_zone:A,referer:O,canvas:B}};let D=[];s&&s.constructor===Array&&(D=s.map((e=>{const t={};return Object.keys(e).forEach((n=>{const o=e[n];t[n]="string"!=typeof o?String(o):o})),t})));const N={project:i,request_id:g,timestamp:p,msg_signature:h,event:e,user_data:{native_msg:a,os:m,os_version:y,device_model:w,device_id:t,user_id:null==V?void 0:V.toString(),country:b,language:S,screen_width:d,screen_height:f,ip:v||""},custom_data:D,ext_data:$},H=yield u({url:"/v2/event",params:N}),{code:W,data:F,msg:X}=H||{};if(200===W&&F){let e="";const t=F.link_data||[];F.blackbox&&""!==F.blackbox&&localStorage.setItem(T,F.blackbox||"");for(let n=0;n<t.length;n++)if("$campaign_reward_url"===t[n].key){e=decodeURIComponent(t[n].value||"");break}if(Y&&""!==e)if(re()){let t=ne(e);if(J&&""!==J){const e=encodeURIComponent(J);t=`${t}&loginUrl=${e}`}ee()||(sessionStorage.setItem(j,t),sessionStorage.setItem(L,"1")),localStorage.setItem(U,e),setTimeout((()=>{window.location.href=t}),300)}else q({url:e});n({code:W,message:X,data:F})}else n({code:W,message:X})}))))}catch(e){n(e)}})),ne=e=>{if(!e||""===e)return"";const t=V||"",n=navigator.language,o=W||n||"",r=Math.floor((new Date).getTime()/1e3),i=localStorage.getItem(T),s="1.2.0",a=r%100,c="5CfUxPK7avjguYtG8yAE4ud6n9s774zVVdKwSxPryzaKHSpS4Lgju4M7sLumdLuQWXpHC6peBp2afBwEBbYnENGbZWfkZ6n4s52D3Xye59bfeK4gS9nfjehK".substring(a,a+12),l=`${t}${F}${o}${r}${i}${s}web${H.appSecret}${c}`,d=R(l,32);return((e,t)=>{const n=new URL(e),o=n.searchParams;return t.forEach((e=>{const{name:t,value:n}=e;o.has(t)?o.set(t,n):o.append(t,n)})),n.origin+n.pathname+"?"+o.toString()})(e,[{name:"user_id",value:t},{name:"lv",value:F},{name:"lg",value:o},{name:"time",value:r},{name:"blackbox",value:i},{name:"version",value:s},{name:"platform",value:"web"},{name:"token",value:d}])},oe=e=>l(void 0,null,(function*(){const t="https://i1.branchcn.com/web/sdk/img/campBg.png",n={campaign_id:e,project_id:null==H?void 0:H.projectId},o=yield u({url:"/v2/campaign/sdk-info",params:n}),r=document.getElementById("turbolinkSdkBgImg"),{code:i,data:s}=o||{};if(200===i&&s){const{pc_bg:e}=s||{};r&&(r.src=e&&""!==e?e:t)}else r&&(r.src=t)})),re=()=>{const e=navigator.userAgent,t=["Android","iPhone","iPad","iPod","BlackBerry","Windows Phone"];for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return!0;return!1};class ie{}c(ie,"init",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{appKey:t,appSecret:r,projectId:i,uid:s,lang:a,lv:c,loginUrl:l,jump:u=!0,dev:f=!1,clickEventCallback:p}=e||{};if(!t||""===t)throw N.LACK_APPKEY;if(!r||""===r)throw N.LACK_APPSECRET;if(!i||""===i)throw N.LACK_PROJECTID;f&&(e=>{e&&(d="https://test.allapp.link")})(f),s&&(V=s),a&&(W=a),c&&(F=c),l&&(J=l),p&&(X=p),Y=u,H=e||{};let g=(new $).get(O);if(Q())return n(N.SUCCESS),void o(N.SUCCESS);null==g||" "===g||""===g?G().then((e=>{n(e),o(e)})):Z().then((e=>{if(n(e),o(e),ee()&&re()){const e=sessionStorage.getItem(j);if(e&&" "!==e){let t=ne(e);if(sessionStorage.removeItem(j),sessionStorage.removeItem(L),J&&""!==J){t=`${t}&loginUrl=${encodeURIComponent(J)}`}window.location.replace(t&&t)}}})),sessionStorage.setItem(B,"1")}catch(e){n(e),o(e)}})))),c(ie,"setIdentity",((e,t)=>new Promise((n=>{const{SUCCESS:o,UNKNOWN:r}=N||{};try{if("object"==typeof e&&null!==e){const{uid:t,lv:n}=e||{};t&&(V=t),n&&(F=n)}else V=e;n(o),t&&t(o)}catch(e){n(r),t&&t(r)}})))),c(ie,"install",G),c(ie,"register",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{uid:t,uId:r,lv:i,toActivity:s=!0}=e||{};if(!(t&&""!==t||r&&""!==r))throw N.LACK_UID;t&&(V=t),r&&(V=r),te("register").then((e=>{if(re()){const e=localStorage.getItem(U),t=sessionStorage.getItem(L);if(e&&"1"===t&&s){sessionStorage.removeItem(L);const t=ne(e);window.location.replace(t&&t)}}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(ie,"open",Z),c(ie,"customEvent",((e,o)=>new Promise((r=>{const i=o||function(){};try{const{event:o,customData:s,backCamp:c}=e||{};if(!o||""===o)throw N.EMPTY_EVENT_NAME;te(o,{customData:s}).then((e=>{const o=localStorage.getItem(U),s=ne(o),l=((e,o)=>t(e,n(o)))(a({},e),{campUrl:s});c&&s&&setTimeout((()=>{window.location.replace(s)}),1e3),r(l),i(l)}))}catch(e){r(e),i(e)}})))),c(ie,"loadUrl",((e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=N||{},{url:i,newWindow:s=!1}=e||{};try{if(!H.appSecret||""===H.appSecret)throw N.LACK_APPSECRET;if(!i||""===i)throw N.INVALID_URL;let e=ne(i);if(J&&""!==J){e=`${e}&loginUrl=${encodeURIComponent(J)}`}localStorage.setItem(U,i),ee()||sessionStorage.setItem(L,"1"),!0===s||"true"===s?window.open(e,"_blank"):window.location.href=e,o(r),n(r),te("loadUrl")}catch(e){n(e),o(e)}})))),c(ie,"webLoadUrl",q),c(ie,"closeWebUrl",(e=>new Promise((t=>{const n=e||function(){},{SUCCESS:o}=N||{};try{document.getElementById("turbolinkSdkPopup").remove(),n(o),t(o)}catch(e){t(e),n(e)}})))),c(ie,"login",((e,t)=>new Promise((n=>{const o=t||function(){},{uid:r,uId:i,lv:s,toActivity:a=!0}=e||{};try{if(!(r&&""!==r||i&&""!==i))throw N.LACK_UID;r&&(V=r),i&&(V=i),te("login").then((e=>{if(re()){const e=localStorage.getItem(U),t=sessionStorage.getItem(L);if(e&&"1"===t&&a){sessionStorage.removeItem(L);const t=ne(e);window.location.replace(t&&t)}}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(ie,"logout",(e=>new Promise((t=>{const n=e||function(){};localStorage.remove(U),sessionStorage.removeItem(L),V=null;const{SUCCESS:o}=N||{};t(o),n(o),te("logout")})))),c(ie,"getInitState",Q),c(ie,"getLoginState",ee),c(ie,"codeSearch",((e,t)=>new Promise((n=>{const o=t||function(){};try{if(!e||" "===e)throw N.LACK_CODE;te("code_search",{nativeMsg:e}).then((e=>{n(e),o(e)}))}catch(e){n(e),o(e)}}))));export{ie as default};
@@ -0,0 +1 @@
1
+ !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).Turbolink=t()}(this,(function(){"use strict";var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,s=(t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,a=(e,t)=>{for(var n in t||(t={}))r.call(t,n)&&s(e,n,t[n]);if(o)for(var n of o(t))i.call(t,n)&&s(e,n,t[n]);return e},c=(e,t,n)=>(s(e,"symbol"!=typeof t?t+"":t,n),n),l=(e,t,n)=>new Promise(((o,r)=>{var i=e=>{try{a(n.next(e))}catch(e){r(e)}},s=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,s);a((n=n.apply(e,t)).next())}));let d="https://www.allapp.link";const u=({url:e,method:t="POST",headers:n,params:o})=>new Promise((r=>{const i=a({"Content-Type":"application/json;charset=utf-8"},n);H.appKey&&(i.Authorization="Bearer "+H.appKey),fetch(d+e,{method:t,headers:i,body:JSON.stringify(o)}).then((e=>{if(e.ok)return e.json();throw new Error("Network response was not ok.")})).then((e=>{r(e)})).catch((e=>{r(e)}))}));var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var p={exports:{}};var h={exports:{}};const g=function(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})})),n}(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var m,y,w,v,b,S,_,x,C;function I(){return m||(m=1,h.exports=(e=e||function(e,t){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(n=globalThis.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==f&&f.crypto&&(n=f.crypto),!n)try{n=g}catch(e){}var o=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},r=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),i={},s=i.lib={},a=s.Base={extend:function(e){var t=r(this);return e&&t.mixIn(e),(!t.hasOwnProperty("init")||this.init===t.init)&&(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=s.WordArray=a.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||d).stringify(this)},concat:function(e){var t=this.words,n=e.words,o=this.sigBytes,r=e.sigBytes;if(this.clamp(),o%4)for(var i=0;i<r;i++){var s=n[i>>>2]>>>24-i%4*8&255;t[o+i>>>2]|=s<<24-(o+i)%4*8}else for(var a=0;a<r;a+=4)t[o+a>>>2]=n[a>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(o());return new c.init(t,e)}}),l=i.enc={},d=l.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,o=[],r=0;r<n;r++){var i=t[r>>>2]>>>24-r%4*8&255;o.push((i>>>4).toString(16)),o.push((15&i).toString(16))}return o.join("")},parse:function(e){for(var t=e.length,n=[],o=0;o<t;o+=2)n[o>>>3]|=parseInt(e.substr(o,2),16)<<24-o%8*4;return new c.init(n,t/2)}},u=l.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,o=[],r=0;r<n;r++){var i=t[r>>>2]>>>24-r%4*8&255;o.push(String.fromCharCode(i))}return o.join("")},parse:function(e){for(var t=e.length,n=[],o=0;o<t;o++)n[o>>>2]|=(255&e.charCodeAt(o))<<24-o%4*8;return new c.init(n,t)}},p=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},h=s.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n,o=this._data,r=o.words,i=o.sigBytes,s=this.blockSize,a=i/(4*s),l=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*s,d=e.min(4*l,i);if(l){for(var u=0;u<l;u+=s)this._doProcessBlock(r,u);n=r.splice(0,l),o.sigBytes-=d}return new c.init(n,d)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});s.Hasher=h.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new m.HMAC.init(e,n).finalize(t)}}});var m=i.algo={};return i}(Math),e)),h.exports;var e}p.exports=(C=I(),w=(y=C).lib,v=w.WordArray,b=w.Hasher,S=y.algo,_=[],x=S.SHA1=b.extend({_doReset:function(){this._hash=new v.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=this._hash.words,o=n[0],r=n[1],i=n[2],s=n[3],a=n[4],c=0;c<80;c++){if(c<16)_[c]=0|e[t+c];else{var l=_[c-3]^_[c-8]^_[c-14]^_[c-16];_[c]=l<<1|l>>>31}var d=(o<<5|o>>>27)+a+_[c];d+=c<20?1518500249+(r&i|~r&s):c<40?1859775393+(r^i^s):c<60?(r&i|r&s|i&s)-1894007588:(r^i^s)-899497514,a=s,s=i,i=r<<30|r>>>2,r=o,o=d}n[0]=n[0]+o|0,n[1]=n[1]+r|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,o=8*e.sigBytes;return t[o>>>5]|=128<<24-o%32,t[14+(o+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(o+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=b.clone.call(this);return e._hash=this._hash.clone(),e}}),y.SHA1=b._createHelper(x),y.HmacSHA1=b._createHmacHelper(x),C.SHA1);const E=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(p.exports),P="tb_cookie_obj",k="tb_randomId",A="tb_load_url",O="tb_load_source_url",U="tb_ascribe_to_url",L="tb_init_state",j="tb_blackbox";class B{constructor(e=!0){this.storage=e?localStorage:sessionStorage}set(e,t){this.storage.setItem(e,JSON.stringify(t))}get(e){const t=this.storage.getItem(e);if(t)return JSON.parse(t)}remove(e){return this.storage.removeItem(e)}clear(){this.storage.clear()}}const T=(e,t)=>{function n(e,t){return e<<t|e>>>32-t}function o(e,t){var n,o,r,i,s;return r=2147483648&e,i=2147483648&t,s=(1073741823&e)+(1073741823&t),(n=1073741824&e)&(o=1073741824&t)?2147483648^s^r^i:n|o?1073741824&s?3221225472^s^r^i:1073741824^s^r^i:s^r^i}function r(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e&t|~e&n}(t,r,i),s),c)),o(n(e,a),t)}function i(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e&n|t&~n}(t,r,i),s),c)),o(n(e,a),t)}function s(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e^t^n}(t,r,i),s),c)),o(n(e,a),t)}function a(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return t^(e|~n)}(t,r,i),s),c)),o(n(e,a),t)}function c(e){var t,n="",o="";for(t=0;t<=3;t++)n+=(o="0"+(e>>>8*t&255).toString(16)).substr(o.length-2,2);return n}var l,d,u,f,p,h,g,m,y,w=Array();for(w=function(e){for(var t,n=e.length,o=n+8,r=16*((o-o%64)/64+1),i=Array(r-1),s=0,a=0;a<n;)s=a%4*8,i[t=(a-a%4)/4]=i[t]|e.charCodeAt(a)<<s,a++;return s=a%4*8,i[t=(a-a%4)/4]=i[t]|128<<s,i[r-2]=n<<3,i[r-1]=n>>>29,i}(e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n<e.length;n++){var o=e.charCodeAt(n);o<128?t+=String.fromCharCode(o):o>127&&o<2048?(t+=String.fromCharCode(o>>6|192),t+=String.fromCharCode(63&o|128)):(t+=String.fromCharCode(o>>12|224),t+=String.fromCharCode(o>>6&63|128),t+=String.fromCharCode(63&o|128))}return t}(e)),h=1732584193,g=4023233417,m=2562383102,y=271733878,l=0;l<w.length;l+=16)d=h,u=g,f=m,p=y,h=r(h,g,m,y,w[l+0],7,3614090360),y=r(y,h,g,m,w[l+1],12,3905402710),m=r(m,y,h,g,w[l+2],17,606105819),g=r(g,m,y,h,w[l+3],22,3250441966),h=r(h,g,m,y,w[l+4],7,4118548399),y=r(y,h,g,m,w[l+5],12,1200080426),m=r(m,y,h,g,w[l+6],17,2821735955),g=r(g,m,y,h,w[l+7],22,4249261313),h=r(h,g,m,y,w[l+8],7,1770035416),y=r(y,h,g,m,w[l+9],12,2336552879),m=r(m,y,h,g,w[l+10],17,4294925233),g=r(g,m,y,h,w[l+11],22,2304563134),h=r(h,g,m,y,w[l+12],7,1804603682),y=r(y,h,g,m,w[l+13],12,4254626195),m=r(m,y,h,g,w[l+14],17,2792965006),h=i(h,g=r(g,m,y,h,w[l+15],22,1236535329),m,y,w[l+1],5,4129170786),y=i(y,h,g,m,w[l+6],9,3225465664),m=i(m,y,h,g,w[l+11],14,643717713),g=i(g,m,y,h,w[l+0],20,3921069994),h=i(h,g,m,y,w[l+5],5,3593408605),y=i(y,h,g,m,w[l+10],9,38016083),m=i(m,y,h,g,w[l+15],14,3634488961),g=i(g,m,y,h,w[l+4],20,3889429448),h=i(h,g,m,y,w[l+9],5,568446438),y=i(y,h,g,m,w[l+14],9,3275163606),m=i(m,y,h,g,w[l+3],14,4107603335),g=i(g,m,y,h,w[l+8],20,1163531501),h=i(h,g,m,y,w[l+13],5,2850285829),y=i(y,h,g,m,w[l+2],9,4243563512),m=i(m,y,h,g,w[l+7],14,1735328473),h=s(h,g=i(g,m,y,h,w[l+12],20,2368359562),m,y,w[l+5],4,4294588738),y=s(y,h,g,m,w[l+8],11,2272392833),m=s(m,y,h,g,w[l+11],16,1839030562),g=s(g,m,y,h,w[l+14],23,4259657740),h=s(h,g,m,y,w[l+1],4,2763975236),y=s(y,h,g,m,w[l+4],11,1272893353),m=s(m,y,h,g,w[l+7],16,4139469664),g=s(g,m,y,h,w[l+10],23,3200236656),h=s(h,g,m,y,w[l+13],4,681279174),y=s(y,h,g,m,w[l+0],11,3936430074),m=s(m,y,h,g,w[l+3],16,3572445317),g=s(g,m,y,h,w[l+6],23,76029189),h=s(h,g,m,y,w[l+9],4,3654602809),y=s(y,h,g,m,w[l+12],11,3873151461),m=s(m,y,h,g,w[l+15],16,530742520),h=a(h,g=s(g,m,y,h,w[l+2],23,3299628645),m,y,w[l+0],6,4096336452),y=a(y,h,g,m,w[l+7],10,1126891415),m=a(m,y,h,g,w[l+14],15,2878612391),g=a(g,m,y,h,w[l+5],21,4237533241),h=a(h,g,m,y,w[l+12],6,1700485571),y=a(y,h,g,m,w[l+3],10,2399980690),m=a(m,y,h,g,w[l+10],15,4293915773),g=a(g,m,y,h,w[l+1],21,2240044497),h=a(h,g,m,y,w[l+8],6,1873313359),y=a(y,h,g,m,w[l+15],10,4264355552),m=a(m,y,h,g,w[l+6],15,2734768916),g=a(g,m,y,h,w[l+13],21,1309151649),h=a(h,g,m,y,w[l+4],6,4149444226),y=a(y,h,g,m,w[l+11],10,3174756917),m=a(m,y,h,g,w[l+2],15,718787259),g=a(g,m,y,h,w[l+9],21,3951481745),h=o(h,d),g=o(g,u),m=o(m,f),y=o(y,p);return 32===t?(c(h)+c(g)+c(m)+c(y)).toLowerCase():(c(g)+c(m)).toLowerCase()},$=(e,t)=>l(this,null,(function*(){const n=t||function(){};try{const t=new B;let o=t.get(P);const r=o?JSON.parse(o):{},i=r?r[e]:null;if(""!==i&&i)n(i);else{const o=function(e){const t=new B(!0);let n=t.get(k);if(!n||""===n){const o="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";let r="";for(let t=0;t<e;t++){const e=Math.floor(Math.random()*o.length);r+=o.charAt(e)}n=r,t.set(k,n)}return n}(32),i=navigator.language,s=K(),a=M(),c=yield u({url:"/ecl/bs/check",params:{bfp:o,language:i,screen_width:s,screen_height:a}}),{code:l,data:d}=c||{};200===l&&d&&(r[e]=d.cookie_id,t.set(P,JSON.stringify(r))),n(d.cookie_id)}}catch(e){n("1")}}));const R=()=>l(this,null,(function*(){const e=navigator.userAgent.toLowerCase();let t="";try{if(/android/.test(e))if(navigator.userAgent.indexOf("(Linux; Android 10; K)")>-1&&navigator.userAgentData){const e=yield navigator.userAgentData.getHighEntropyValues(["platformVersion","model"]);t=e&&e.platformVersion}else t=e.match(/android\s([0-9.]+)/)[1];else/iphone|ipad|ipod/.test(e)?t=e.match(/os\s([\d_]+)/)[1].replace(/_/g,"."):/win/.test(e)?t=e.match(/windows\snt\s([\d.]+)/)[1]:/mac/.test(e)?t=e.match(/os x\s([\d_]+)/)[1].replace(/_/g,"."):/linux/.test(e)&&(t="Unknown")}catch(e){t="Unknown"}return t})),D=()=>l(this,null,(function*(){const e=navigator.userAgent;let t="Windows";try{if(e.includes("iPhone"))t="iPhone";else if(e.includes("iPad"))t="iPad";else if(e.includes("Android"))if(e.indexOf("(Linux; Android 10; K)")>-1&&navigator.userAgentData){const e=yield navigator.userAgentData.getHighEntropyValues(["platformVersion","model"]);t=e&&e.model||"Windows"}else if(e.includes("Build")){const n=e.match(/Android.*; ?(.*(?= Build))/);n&&n.length>1&&(t=n[1])}else if(e.includes("wv")){const n=e.match(/Android.*; ?(.*(?= wv))/);if(n&&n.length>0){const e=n[0].split(";");e&&e.length>1&&(t=e[1])}}else{const n=e.match(/Android.*; ([^)]+)/);n&&n.length>1&&(t=n[1])}else e.includes("Mac")&&(t="Mac")}catch(e){t="Windows"}return t})),K=()=>{let e=0;try{e=window.screen.width}catch(t){e=0}return e},M=()=>{let e=0;try{e=window.screen.height}catch(t){e=0}return e},N={SUCCESS:{code:200,message:"Success"},UNKNOWN:{code:9999,message:"Unknown"},LACK_APPKEY:{code:1001,message:"Missing appKey parameter"},LACK_APPSECRET:{code:1002,message:"Missing appSecret parameter"},LACK_PROJECTID:{code:1003,message:"Missing projectId parameter"},NOT_INIT:{code:1004,message:"Please call the init method first"},EMPTY_EVENT_NAME:{code:1005,message:"Event name cannot be empty"},INVALID_URL:{code:1006,message:"Invalid URL"},LACK_UID:{code:1007,message:"Missing uId parameter"},LACK_CODE:{code:1008,message:"Please enter the code"}},z={name:"turbolink-ai",version:"1.2.2",description:"",main:"dist/index.es.js",module:"dist/index.es.js",type:"module",scripts:{test:'echo "Error: no test specified" && exit 1',build:"vite build"},author:"",license:"MIT",devDependencies:{"@babel/plugin-transform-modules-commonjs":"^7.23.3","crypto-js":"^4.2.0",eslint:"^8.53.0","rollup-plugin-terser":"^7.0.2",vite:"^4.5.0"},dependencies:{"javascript-obfuscator":"^4.1.0"}};let H={appKey:"",appSecret:"",projectId:""},V="",W="",F="",Y=!0,J="",X=null;const G=e=>new Promise((t=>{te("install").then((n=>{t(n),e&&e(n)}))})),Z=e=>new Promise((t=>{te("open").then((n=>{t(n),e&&e(n)}))})),q=(e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=N||{},i=650,{url:s,maskColor:a="rgba(0, 0, 0, 0.8)",backgroundImage:c,backgroundHeight:l=738,backgroundWidth:d,bgLinkage:u=!1,width:f=300,height:p=i,radius:h=12,zIndex:g=3e3,clickEventCallback:m,bodyHidden:y=!0,jumpNewWindow:w=!1}=e||{};try{if(!H.appSecret||""===H.appSecret)throw N.LACK_APPSECRET;if(!s||""===s)throw N.INVALID_URL;const e=new URL(s),t=new URLSearchParams(e.search).get("l");let v=ne(s);if(v=`${v}&webIframe=1`,w&&(v=`${v}&jpN=1`),J&&""!==J){v=`${v}&loginUrl=${encodeURIComponent(J)}`}let b=document.getElementById("turbolinkSdkPopup");b&&b.remove();const S=document.createElement("div");S.id="turbolinkSdkPopup",S.style.position="fixed",S.style.zIndex=g,S.style.left="0",S.style.top="0",S.style.right="0",S.style.bottom="0",S.style.width="100%",S.style.height="100%",S.style.overflowX="hidden",S.style.overflowY="auto",S.style.backgroundColor=a;const _=document.createElement("div");_.style.minHeight="100%",_.style.display="-webkit-box",_.style.display="-ms-flexbox",_.style.display="-moz-box",_.style.display="flex",_.style.textAlign="center",_.style.justifyContent="center",_.style.alignItems="center";const x=document.createElement("div");x.style.margin="10vh auto",x.style.border="none",x.style.width=`${f}px`,x.style.height=`${p}px`,x.style.position="relative",x.style.borderRadius=`${h}px`,x.style.display="-webkit-box",x.style.display="-ms-flexbox",x.style.display="-moz-box",x.style.display="flex",x.style.textAlign="center",x.style.justifyContent="center",x.style.alignItems="center";const C=document.createElement("iframe");C.id="turbolinkSdkPopupIframe",C.width=`${f}px`,C.height=`${p}px`,C.style.border="none",C.style.borderRadius=`${h}px`,C.style.overflow="hidden",C.style.position="relative",C.style.zIndex="10",C.src=v;const I=document.createElement("div"),E=document.createElement("img");let P=l;u&&(P=p*(P/i)),I.style.height=`${P}px`,C.onload=()=>{I.style.position="absolute",I.style.fontSize="0px",I.style.zIndex="6",E.id="turbolinkSdkBgImg",c&&""!==c?E.src=c:oe(t),E.style.width=d||"auto",E.style.height="100%",E.style.setProperty("max-width","none","important"),E.style.setProperty("max-height","none","important"),I.appendChild(E)};const k=document.createElement("div"),A=document.createElement("img");k.style.position="absolute",k.style.fontSize="0px",k.style.zIndex="100",k.style.top="-54px",k.style.right="-200px",A.src="https://i1.branchcn.com/web/sdk/img/campClose.png",A.style.width="40px",A.style.height="auto",k.appendChild(A);const O=e=>{const t=(null==e?void 0:e.data)||{};if(t){const n=(null==t?void 0:t.source)||"";if(n&&"turbolink"===n){const t=m||X;t&&t(e.data)}}};(m||X)&&(window.removeEventListener("message",O),window.addEventListener("message",O)),k.addEventListener("click",(()=>{S.remove(),y&&(document.body.style.overflow="auto");const e=m||X;e&&(e({type:"linkCloseListener",params:null}),window.removeEventListener("message",O))})),x.appendChild(I),x.appendChild(C),x.appendChild(k),_.appendChild(x),S.appendChild(_),document.body.appendChild(S),y&&(document.body.style.overflow="hidden"),o(r),n(r)}catch(e){n(e),o(e)}})),Q=()=>sessionStorage.getItem(L),ee=()=>!(null===V||""===V||" "===V||void 0===V),te=(e,t)=>new Promise((n=>{try{const{appKey:o,appSecret:r,projectId:i}=H||{},{customData:s,nativeMsg:a=""}=t||{};if(""===o||!o||""===r||!r||""===i||!i)throw N.NOT_INIT;if(!e||""===e)throw N.EMPTY_EVENT_NAME;$(i,(t=>l(this,null,(function*(){var o,c;const l=K(),d=M(),f=(new Date).valueOf(),p=null==f?void 0:f.toString(),h=null==(o=E(`${i}_${p}_${f}_${r}`))?void 0:o.toString(),g=(()=>{let e="Android";try{const t=navigator.userAgent.toLowerCase();/android/.test(t)?e="Android":/iphone|ipad|ipod/.test(t)?e="iOS":/win/.test(t)?e="Windows":/mac/.test(t)?e="macOS":/linux/.test(t)&&(e="Linux")}catch(t){e="Android"}return e})(),m=yield R(),y=yield D(),w=yield new Promise((e=>{try{const t=new RTCPeerConnection;t.createDataChannel(""),t.onicecandidate=function(n){if(n.candidate){const o=n.candidate.candidate,r=/(?:[0-9]{1,3}\.){3}[0-9]{1,3}/.exec(o),i=r?r[0]:null;e(i),t.close()}else e()},t.createOffer().then((e=>t.setLocalDescription(e))).catch((()=>{e()}))}catch(t){e()}})),v=(()=>{let e="Unknown";try{e=(navigator.language||navigator.userLanguage).substring(3).toUpperCase()}catch(t){e="Unknown"}return e})(),b=(()=>{let e="Unknown";try{e=(navigator.language||navigator.userLanguage).substring(0,2).toLowerCase()}catch(t){e="Unknown"}return e})(),S=(()=>{const e=navigator.userAgent;return-1!==e.indexOf("Firefox")?"Firefox":-1!==e.indexOf("Opera")||-1!==e.indexOf("OPR")?"Opera":-1!==e.indexOf("Trident")?"IE":-1!==e.indexOf("Edge")?"Edge":-1!==e.indexOf("Chrome")?"Chrome":-1!==e.indexOf("Safari")?"Safari":"unknown"})(),_=null==(c=(()=>{let e=0;try{const t=navigator.userAgent;-1!==t.indexOf("Firefox")?e=parseFloat(null==t?void 0:t.match(/Firefox\/([\d.]+)/)[1])||0:-1!==t.indexOf("Edge")?e=parseFloat(null==t?void 0:t.match(/Edge\/([\d.]+)/)[1])||0:-1!==t.indexOf("Chrome")?e=parseFloat(null==t?void 0:t.match(/Chrome\/([\d.]+)/)[1])||0:-1!==t.indexOf("Safari")?e=parseFloat(null==t?void 0:t.match(/Version\/([\d.]+)/)[1])||0:(-1!==t.indexOf("MSIE")||-1!==t.indexOf("Trident/"))&&(e=parseFloat((null==t?void 0:t.match(/MSIE (\d+[.]\d+)|(?:Trident\/[\d.]+).*rv:([\d.]+)/)[1])||(null==t?void 0:t.match(/rv:([\d.]+)/)))||0)}catch(t){e=0}return e})())?void 0:c.toString(),x=(null==z?void 0:z.version)||"1.0.0",C=`${l}x${d}`,I=window.location.href,P=navigator.userAgent,k="UTC+"+(0-(new Date).getTimezoneOffset()/60),L=document.referrer,B=(()=>{const e=document.createElement("canvas"),t=e.getContext("2d"),n="turbolink <canvas> 1.0";t.textBaseline="top",t.font="14px 'Arial'",t.textBaseline="alphabetic",t.fillStyle="#f60",t.fillRect(125,1,62,20),t.fillStyle="#069",t.fillText(n,2,15),t.fillStyle="rgba(102, 204, 0, 0.7)",t.fillText(n,4,17);const o=e.toDataURL();return T(o,32)})(),$={web:{browser_name:S,browser_version:_,current_time:f,device_type:y,ip:w||"",language:b,os:g,screen_resolution:C,sdk_version:x,url:I,user_agent:P,time_zone:k,referer:L,canvas:B}};let N=[];s&&s.constructor===Array&&(N=s.map((e=>{const t={};return Object.keys(e).forEach((n=>{const o=e[n];t[n]="string"!=typeof o?String(o):o})),t})));const H={project:i,request_id:p,timestamp:f,msg_signature:h,event:e,user_data:{native_msg:a,os:g,os_version:m,device_model:y,device_id:t,user_id:null==V?void 0:V.toString(),country:v,language:b,screen_width:l,screen_height:d,ip:w||""},custom_data:N,ext_data:$},W=yield u({url:"/v2/event",params:H}),{code:F,data:X,msg:G}=W||{};if(200===F&&X){let e="";const t=X.link_data||[];X.blackbox&&""!==X.blackbox&&localStorage.setItem(j,X.blackbox||"");for(let n=0;n<t.length;n++)if("$campaign_reward_url"===t[n].key){e=decodeURIComponent(t[n].value||"");break}if(Y&&""!==e)if(re()){let t=ne(e);if(J&&""!==J){const e=encodeURIComponent(J);t=`${t}&loginUrl=${e}`}ee()||(sessionStorage.setItem(U,t),sessionStorage.setItem(O,"1")),localStorage.setItem(A,e),setTimeout((()=>{window.location.href=t}),300)}else q({url:e});n({code:F,message:G,data:X})}else n({code:F,message:G})}))))}catch(e){n(e)}})),ne=e=>{if(!e||""===e)return"";const t=V||"",n=navigator.language,o=W||n||"",r=Math.floor((new Date).getTime()/1e3),i=localStorage.getItem(j),s="1.2.0",a=r%100,c="5CfUxPK7avjguYtG8yAE4ud6n9s774zVVdKwSxPryzaKHSpS4Lgju4M7sLumdLuQWXpHC6peBp2afBwEBbYnENGbZWfkZ6n4s52D3Xye59bfeK4gS9nfjehK".substring(a,a+12),l=`${t}${F}${o}${r}${i}${s}web${H.appSecret}${c}`,d=T(l,32);return((e,t)=>{const n=new URL(e),o=n.searchParams;return t.forEach((e=>{const{name:t,value:n}=e;o.has(t)?o.set(t,n):o.append(t,n)})),n.origin+n.pathname+"?"+o.toString()})(e,[{name:"user_id",value:t},{name:"lv",value:F},{name:"lg",value:o},{name:"time",value:r},{name:"blackbox",value:i},{name:"version",value:s},{name:"platform",value:"web"},{name:"token",value:d}])},oe=e=>l(this,null,(function*(){const t="https://i1.branchcn.com/web/sdk/img/campBg.png",n={campaign_id:e,project_id:null==H?void 0:H.projectId},o=yield u({url:"/v2/campaign/sdk-info",params:n}),r=document.getElementById("turbolinkSdkBgImg"),{code:i,data:s}=o||{};if(200===i&&s){const{pc_bg:e}=s||{};r&&(r.src=e&&""!==e?e:t)}else r&&(r.src=t)})),re=()=>{const e=navigator.userAgent,t=["Android","iPhone","iPad","iPod","BlackBerry","Windows Phone"];for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return!0;return!1};class ie{}return c(ie,"init",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{appKey:t,appSecret:r,projectId:i,uid:s,lang:a,lv:c,loginUrl:l,jump:u=!0,dev:f=!1,clickEventCallback:p}=e||{};if(!t||""===t)throw N.LACK_APPKEY;if(!r||""===r)throw N.LACK_APPSECRET;if(!i||""===i)throw N.LACK_PROJECTID;f&&(e=>{e&&(d="https://test.allapp.link")})(f),s&&(V=s),a&&(W=a),c&&(F=c),l&&(J=l),p&&(X=p),Y=u,H=e||{};let h=(new B).get(k);if(Q())return n(N.SUCCESS),void o(N.SUCCESS);null==h||" "===h||""===h?G().then((e=>{n(e),o(e)})):Z().then((e=>{if(n(e),o(e),ee()&&re()){const e=sessionStorage.getItem(U);if(e&&" "!==e){let t=ne(e);if(sessionStorage.removeItem(U),sessionStorage.removeItem(O),J&&""!==J){t=`${t}&loginUrl=${encodeURIComponent(J)}`}window.location.replace(t&&t)}}})),sessionStorage.setItem(L,"1")}catch(e){n(e),o(e)}})))),c(ie,"setIdentity",((e,t)=>new Promise((n=>{const{SUCCESS:o,UNKNOWN:r}=N||{};try{if("object"==typeof e&&null!==e){const{uid:t,lv:n}=e||{};t&&(V=t),n&&(F=n)}else V=e;n(o),t&&t(o)}catch(e){n(r),t&&t(r)}})))),c(ie,"install",G),c(ie,"register",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{uid:t,uId:r,lv:i,toActivity:s=!0}=e||{};if(!(t&&""!==t||r&&""!==r))throw N.LACK_UID;t&&(V=t),r&&(V=r),te("register").then((e=>{if(re()){const e=localStorage.getItem(A),t=sessionStorage.getItem(O);if(e&&"1"===t&&s){sessionStorage.removeItem(O);const t=ne(e);window.location.replace(t&&t)}}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(ie,"open",Z),c(ie,"customEvent",((e,o)=>new Promise((r=>{const i=o||function(){};try{const{event:o,customData:s,backCamp:c}=e||{};if(!o||""===o)throw N.EMPTY_EVENT_NAME;te(o,{customData:s}).then((e=>{const o=localStorage.getItem(A),s=ne(o),l=((e,o)=>t(e,n(o)))(a({},e),{campUrl:s});c&&s&&setTimeout((()=>{window.location.replace(s)}),1e3),r(l),i(l)}))}catch(e){r(e),i(e)}})))),c(ie,"loadUrl",((e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=N||{},{url:i,newWindow:s=!1}=e||{};try{if(!H.appSecret||""===H.appSecret)throw N.LACK_APPSECRET;if(!i||""===i)throw N.INVALID_URL;let e=ne(i);if(J&&""!==J){e=`${e}&loginUrl=${encodeURIComponent(J)}`}localStorage.setItem(A,i),ee()||sessionStorage.setItem(O,"1"),!0===s||"true"===s?window.open(e,"_blank"):window.location.href=e,o(r),n(r),te("loadUrl")}catch(e){n(e),o(e)}})))),c(ie,"webLoadUrl",q),c(ie,"closeWebUrl",(e=>new Promise((t=>{const n=e||function(){},{SUCCESS:o}=N||{};try{document.getElementById("turbolinkSdkPopup").remove(),n(o),t(o)}catch(e){t(e),n(e)}})))),c(ie,"login",((e,t)=>new Promise((n=>{const o=t||function(){},{uid:r,uId:i,lv:s,toActivity:a=!0}=e||{};try{if(!(r&&""!==r||i&&""!==i))throw N.LACK_UID;r&&(V=r),i&&(V=i),te("login").then((e=>{if(re()){const e=localStorage.getItem(A),t=sessionStorage.getItem(O);if(e&&"1"===t&&a){sessionStorage.removeItem(O);const t=ne(e);window.location.replace(t&&t)}}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(ie,"logout",(e=>new Promise((t=>{const n=e||function(){};localStorage.remove(A),sessionStorage.removeItem(O),V=null;const{SUCCESS:o}=N||{};t(o),n(o),te("logout")})))),c(ie,"getInitState",Q),c(ie,"getLoginState",ee),c(ie,"codeSearch",((e,t)=>new Promise((n=>{const o=t||function(){};try{if(!e||" "===e)throw N.LACK_CODE;te("code_search",{nativeMsg:e}).then((e=>{n(e),o(e)}))}catch(e){n(e),o(e)}})))),ie}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turbolink-ai",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",