turbolink-ai 1.1.1 → 1.1.3

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,r=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,s=(t,n,r)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r,a=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&s(e,n,t[n]);if(r)for(var n of r(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(((r,o)=>{var i=e=>{try{a(n.next(e))}catch(e){o(e)}},s=e=>{try{a(n.throw(e))}catch(e){o(e)}},a=e=>e.done?r(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:r})=>new Promise((o=>{const i=a({"Content-Type":"application/json;charset=utf-8"},n);R.appKey&&(i.Authorization="Bearer "+R.appKey),fetch(d+e,{method:t,headers:i,body:JSON.stringify(r)}).then((e=>{if(e.ok)return e.json();throw new Error("Network response was not ok.")})).then((e=>{o(e)})).catch((e=>{o(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 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 r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{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,x,C,E,A;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 r=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.")},o=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=o(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,r=this.sigBytes,o=e.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var s=n[i>>>2]>>>24-i%4*8&255;t[r+i>>>2]|=s<<24-(r+i)%4*8}else for(var a=0;a<o;a+=4)t[r+a>>>2]=n[a>>>2];return this.sigBytes+=o,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(r());return new c.init(t,e)}}),l=i.enc={},d=l.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new c.init(n,t/2)}},u=l.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%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,r=this._data,o=r.words,i=r.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(o,u);n=o.splice(0,l),r.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 k=p(g.exports=(A=P(),b=(v=A).lib,_=b.WordArray,S=b.Hasher,x=v.algo,C=[],E=x.SHA1=S.extend({_doReset:function(){this._hash=new _.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],a=n[4],c=0;c<80;c++){if(c<16)C[c]=0|e[t+c];else{var l=C[c-3]^C[c-8]^C[c-14]^C[c-16];C[c]=l<<1|l>>>31}var d=(r<<5|r>>>27)+a+C[c];d+=c<20?1518500249+(o&i|~o&s):c<40?1859775393+(o^i^s):c<60?(o&i|o&s|i&s)-1894007588:(o^i^s)-899497514,a=s,s=i,i=o<<30|o>>>2,o=r,r=d}n[0]=n[0]+r|0,n[1]=n[1]+o|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,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(r+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(E),v.HmacSHA1=S._createHmacHelper(E),A.SHA1)),O="tb_cookie_obj",I="tb_randomId",L="tb_load_url",U="tb_load_source_url";class j{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 r(e,t){var n,r,o,i,s;return o=2147483648&e,i=2147483648&t,s=(1073741823&e)+(1073741823&t),(n=1073741824&e)&(r=1073741824&t)?2147483648^s^o^i:n|r?1073741824&s?3221225472^s^o^i:1073741824^s^o^i:s^o^i}function o(e,t,o,i,s,a,c){return e=r(e,r(r(function(e,t,n){return e&t|~e&n}(t,o,i),s),c)),r(n(e,a),t)}function i(e,t,o,i,s,a,c){return e=r(e,r(r(function(e,t,n){return e&n|t&~n}(t,o,i),s),c)),r(n(e,a),t)}function s(e,t,o,i,s,a,c){return e=r(e,r(r(function(e,t,n){return e^t^n}(t,o,i),s),c)),r(n(e,a),t)}function a(e,t,o,i,s,a,c){return e=r(e,r(r(function(e,t,n){return t^(e|~n)}(t,o,i),s),c)),r(n(e,a),t)}function c(e){var t,n="",r="";for(t=0;t<=3;t++)n+=(r="0"+(e>>>8*t&255).toString(16)).substr(r.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,r=n+8,o=16*((r-r%64)/64+1),i=Array(o-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[o-2]=n<<3,i[o-1]=n>>>29,i}(e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t+=String.fromCharCode(r):r>127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|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=o(h,g,m,y,w[l+0],7,3614090360),y=o(y,h,g,m,w[l+1],12,3905402710),m=o(m,y,h,g,w[l+2],17,606105819),g=o(g,m,y,h,w[l+3],22,3250441966),h=o(h,g,m,y,w[l+4],7,4118548399),y=o(y,h,g,m,w[l+5],12,1200080426),m=o(m,y,h,g,w[l+6],17,2821735955),g=o(g,m,y,h,w[l+7],22,4249261313),h=o(h,g,m,y,w[l+8],7,1770035416),y=o(y,h,g,m,w[l+9],12,2336552879),m=o(m,y,h,g,w[l+10],17,4294925233),g=o(g,m,y,h,w[l+11],22,2304563134),h=o(h,g,m,y,w[l+12],7,1804603682),y=o(y,h,g,m,w[l+13],12,4254626195),m=o(m,y,h,g,w[l+14],17,2792965006),h=i(h,g=o(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=r(h,d),g=r(g,u),m=r(m,f),y=r(y,p);return 32===t?(c(h)+c(g)+c(m)+c(y)).toLowerCase():(c(g)+c(m)).toLowerCase()},B=(e,t)=>l(void 0,null,(function*(){const n=t||function(){};try{const t=new j;let r=t.get(O);const o=r?JSON.parse(r):{},i=o?o[e]:null;if(""!==i&&i)n(i);else{const r=function(e){const t=new j(!0);let n=t.get(I);if(!n||""===n){const r="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";let o="";for(let t=0;t<e;t++){const e=Math.floor(Math.random()*r.length);o+=r.charAt(e)}n=o,t.set(I,n)}return n}(32),i=navigator.language,s=N(),a=$(),c=yield u({url:"/ecl/bs/check",params:{bfp:r,language:i,screen_width:s,screen_height:a}}),{code:l,data:d}=c||{};200===l&&d&&(o[e]=d.cookie_id,t.set(O,JSON.stringify(o))),n(d.cookie_id)}}catch(e){n("1")}}));const N=()=>{let e=0;try{e=window.screen.width}catch(t){e=0}return e},$=()=>{let e=0;try{e=window.screen.height}catch(t){e=0}return e},K={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"}},M={name:"turbolink-ai",version:"1.1.1",description:"",main:"dist/index.es.js",module:"dist/index.es.js",type:"module",types:"index.d.ts",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 R={appKey:"",appSecret:"",projectId:""},D="",z="",H="",V=!1,W=!0,F="";let Y="";const J=e=>new Promise((t=>{G("install").then((n=>{t(n),e&&e(n)}))})),X=e=>new Promise((t=>{G("open").then((n=>{t(n),e&&e(n)}))})),G=(e,t)=>new Promise((n=>{try{const{appKey:r,appSecret:o,projectId:i}=R||{};if(""===r||!r||""===o||!o||""===i||!i)throw K.NOT_INIT;if(!e||""===e)throw K.EMPTY_EVENT_NAME;B(i,(r=>l(void 0,null,(function*(){const s=N(),a=$(),c=(new Date).valueOf(),d=c.toString(),f=k(`${i}_${d}_${c}_${o}`).toString(),p=(()=>{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})(),h=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})),g=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})),m=yield new Promise((e=>{try{const t=new RTCPeerConnection;t.createDataChannel(""),t.onicecandidate=function(n){if(n.candidate){const r=n.candidate.candidate,o=/(?:[0-9]{1,3}\.){3}[0-9]{1,3}/.exec(r),i=o?o[0]:null;e(i),t.close()}else e()},t.createOffer().then((e=>t.setLocalDescription(e))).catch((()=>{e()}))}catch(t){e()}})),y=(()=>{let e="Unknown";try{e=(navigator.language||navigator.userLanguage).substring(3).toUpperCase()}catch(t){e="Unknown"}return e})(),w=(()=>{let e="Unknown";try{e=(navigator.language||navigator.userLanguage).substring(0,2).toLowerCase()}catch(t){e="Unknown"}return e})(),v=(()=>{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"})(),b=(()=>{var e=navigator.userAgent,t=0;return-1!==e.indexOf("Firefox")?t=parseFloat(e.match(/Firefox\/([\d.]+)/)[1]):-1!==e.indexOf("Edge")?t=parseFloat(e.match(/Edge\/([\d.]+)/)[1]):-1!==e.indexOf("Chrome")?t=parseFloat(e.match(/Chrome\/([\d.]+)/)[1]):-1!==e.indexOf("Safari")?t=parseFloat(e.match(/Version\/([\d.]+)/)[1]):(-1!==e.indexOf("MSIE")||-1!==e.indexOf("Trident/"))&&(t=parseFloat(e.match(/MSIE (\d+[.]\d+)|(?:Trident\/[\d.]+).*rv:([\d.]+)/)[1]||e.match(/rv:([\d.]+)/))),t})().toString(),_=(null==M?void 0:M.version)||"1.0.0",S=`${s}x${a}`,x=window.location.href,C=navigator.userAgent,E="UTC+"+(0-(new Date).getTimezoneOffset()/60),A=document.referrer,P=(()=>{const e=document.createElement("canvas"),t=e.getContext("2d");var 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 r=e.toDataURL();return T(r,32)})(),O={web:{browser_name:v,browser_version:b,current_time:c,device_type:g,ip:m||"",language:w,os:p,screen_resolution:S,sdk_version:_,url:x,user_agent:C,time_zone:E,referer:A,canvas:P}};let I=[];t&&t.constructor===Array&&(I=t.map((e=>{const t={};return Object.keys(e).forEach((n=>{const r=e[n];t[n]="string"!=typeof r?String(r):r})),t})));const L={project:i,request_id:d,timestamp:c,msg_signature:f,event:e,user_data:{native_msg:"",os:p,os_version:h,device_model:g,device_id:r,user_id:D.toString(),country:y,language:w,screen_width:s,screen_height:a,ip:m||""},custom_data:I,ext_data:O},U=yield u({url:"/v2/event",params:L}),{code:j,data:B,msg:K}=U||{};if(200===j&&B){let e="";const t=B.link_data||[];B.blackbox&&""!==B.blackbox&&(Y=B.blackbox||"");for(let n=0;n<t.length;n++)if("$campaign_url"===t[n].key){e=decodeURIComponent(t[n].value||"");break}W&&""!==e&&(window.location.href=e),n({code:j,message:K,data:B})}else n({code:j,message:K})}))))}catch(e){n(e)}})),Z=e=>{if(!e||""===e)return"";const t=D||"",n=navigator.language,r=z||n||"",o=Math.floor((new Date).getTime()/1e3),i="1.2.0",s=o%100,a="5CfUxPK7avjguYtG8yAE4ud6n9s774zVVdKwSxPryzaKHSpS4Lgju4M7sLumdLuQWXpHC6peBp2afBwEBbYnENGbZWfkZ6n4s52D3Xye59bfeK4gS9nfjehK".substring(s,s+12),c=`${t}${H}${r}${o}${Y}${i}web${R.appSecret}${a}`,l=T(c,32);return((e,t)=>{const n=new URL(e),r=n.searchParams;return t.forEach((e=>{const{name:t,value:n}=e;r.has(t)?r.set(t,n):r.append(t,n)})),n.origin+n.pathname+"?"+r.toString()})(e,[{name:"user_id",value:t},{name:"lv",value:H},{name:"lg",value:r},{name:"time",value:o},{name:"blackbox",value:Y},{name:"version",value:i},{name:"platform",value:"web"},{name:"token",value:l}])};class q{}c(q,"init",((e,t)=>new Promise((n=>{const r=t||function(){};try{const{appKey:t,appSecret:o,projectId:i,uid:s,lang:a,lv:c,loginUrl:l,jump:u=!0,dev:f=!1}=e||{};if(!t||""===t)throw K.LACK_APPKEY;if(!o||""===o)throw K.LACK_APPSECRET;if(!i||""===i)throw K.LACK_PROJECTID;f&&(e=>{e&&(d="https://test.allapp.link")})(f),s&&(D=s),a&&(z=a),c&&(H=c),l&&(F=l),W=u,R=e||{};let p=(new j).get(I);if(V)return n(K.SUCCESS),void r(K.SUCCESS);null==p||" "===p||""===p?J().then((e=>{n(e),r(e)})):X().then((e=>{n(e),r(e)})),V=!0}catch(e){n(e),r(e)}})))),c(q,"setIdentity",((e,t)=>new Promise((n=>{const{SUCCESS:r,UNKNOWN:o}=K||{};try{if("object"==typeof e&&null!==e){const{uid:t,lv:n}=e||{};t&&(D=t),n&&(H=n)}else D=e;n(r),t&&t(r)}catch(e){n(o),t&&t(o)}})))),c(q,"install",J),c(q,"register",((e,t)=>new Promise((n=>{const r=t||function(){};try{const{uId:t,lv:o}=e||{};t&&(D=t),o&&(H=o),G("register").then((e=>{const t=new j,o=t.get(L),i=t.get(U);if(i&&"1"===i){const e=Z(o);window.location.replace(e&&o),t.remove(U)}n(e),r(e)}))}catch(e){n(e),r(e)}})))),c(q,"open",X),c(q,"customEvent",((e,r)=>new Promise((o=>{const i=r||function(){};try{const{event:r,customData:s,backCamp:c}=e||{};if(!r||""===r)throw K.EMPTY_EVENT_NAME;G(r,s).then((e=>{const r=(new j).get(L),s=Z(r),l=((e,r)=>t(e,n(r)))(a({},e),{campUrl:s});c&&s&&window.location.replace(s),o(l),i(l)}))}catch(e){o(e),i(e)}})))),c(q,"loadUrl",((e,t)=>new Promise((n=>{const r=t||function(){},{SUCCESS:o}=K||{},{url:i,newWindow:s=!1}=e||{};try{if(!R.appSecret||""===R.appSecret)throw K.LACK_APPSECRET;if(!i||""===i)throw K.INVALID_URL;let e=Z(i);if(F&&""!==F){e=`${e}&loginUrl=${encodeURIComponent(F)}`}const t=new j;t.set(L,i),t.set(U,"1"),!0===s||"true"===s?window.open(e,"_blank"):window.location.href=e,r(o),n(o),G("loadUrl")}catch(e){n(e),r(e)}})))),c(q,"webLoadUrl",((e,t)=>new Promise((n=>{const r=t||function(){},{SUCCESS:o}=K||{},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,clickEventCallback:g,bodyHidden:m=!0,jumpNewWindow:y=!1}=e||{};try{if(!R.appSecret||""===R.appSecret)throw K.LACK_APPSECRET;if(!s||""===s)throw K.INVALID_URL;let e=Z(s);if(e=`${e}&webIframe=1`,y&&(e=`${e}&jpN=1`),F&&""!==F){e=`${e}&loginUrl=${encodeURIComponent(F)}`}let t=document.getElementById("turbolinkSdkPopup");t&&t.remove();const w=document.createElement("div");w.id="turbolinkSdkPopup",w.style.position="fixed",w.style.zIndex="3000",w.style.left="0",w.style.top="0",w.style.right="0",w.style.bottom="0",w.style.width="100%",w.style.height="100%",w.style.overflowX="hidden",w.style.overflowY="auto",w.style.backgroundColor=a;const v=document.createElement("div");v.style.minHeight="100%",v.style.display="-webkit-box",v.style.display="-ms-flexbox",v.style.display="-moz-box",v.style.display="flex",v.style.textAlign="center",v.style.justifyContent="center",v.style.alignItems="center";const b=document.createElement("div");b.style.margin="10vh auto",b.style.border="none",b.style.width=`${f}px`,b.style.height=`${p}px`,b.style.position="relative",b.style.borderRadius=`${h}px`,b.style.display="-webkit-box",b.style.display="-ms-flexbox",b.style.display="-moz-box",b.style.display="flex",b.style.textAlign="center",b.style.justifyContent="center",b.style.alignItems="center";const _=document.createElement("iframe");_.id="turbolinkSdkPopupIframe",_.width=`${f}px`,_.height=`${p}px`,_.style.border="none",_.style.borderRadius=`${h}px`,_.style.overflow="hidden",_.style.position="relative",_.style.zIndex="10",_.src=e;const S=document.createElement("div"),x=document.createElement("img");let C=l;u&&(C=p*(C/i)),S.style.height=`${C}px`,_.onload=()=>{setTimeout((()=>{let e="https://i1.branchcn.com/web/sdk/img/campBg.png";c&&""!==c&&(e=c),S.style.position="absolute",S.style.fontSize="0px",S.style.zIndex="6",x.id="turbolinkSdkBgImg",x.src=e,x.style.width=d||"auto",x.style.height="100%",S.appendChild(x)}),0)};const E=document.createElement("div"),A=document.createElement("img");E.style.position="absolute",E.style.fontSize="0px",E.style.zIndex="100",E.style.top="-54px",E.style.right="-200px",A.src="https://i1.branchcn.com/web/sdk/img/campClose.png",A.style.width="40px",A.style.height="auto",E.appendChild(A);const P=e=>{const t=(null==e?void 0:e.data)||{};if(t){const n=(null==t?void 0:t.source)||"";n&&"turbolink"===n&&g(e.data)}};g&&(window.removeEventListener("message",P),window.addEventListener("message",P)),E.addEventListener("click",(()=>{w.remove(),m&&(document.body.style.overflow="auto"),g&&window.removeEventListener("message",P)})),b.appendChild(S),b.appendChild(_),b.appendChild(E),v.appendChild(b),w.appendChild(v),document.body.appendChild(w),m&&(document.body.style.overflow="hidden"),r(o),n(o)}catch(e){n(e),r(e)}})))),c(q,"login",((e,t)=>new Promise((n=>{const r=t||function(){},{uId:o,lv:i}=e||{};try{if(!o||""===o)throw K.LACK_UID;o&&(D=o),G("login").then((e=>{const t=new j,o=t.get(L),i=t.get(U);if(i&&"1"===i){const e=Z(o);window.location.replace(e&&o),t.remove(U)}n(e),r(e)}))}catch(e){n(e),r(e)}})))),c(q,"logout",(e=>new Promise((t=>{const n=e||function(){};(new j).remove(L),D=null;const{SUCCESS:r}=K||{};t(r),n(r),G("logout")})))),c(q,"getInitState",(()=>V)),c(q,"getLoginState",(()=>!(null===D||""===D||" "===D||void 0===D)));export{q as default};
1
+ var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,r=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,s=(t,n,r)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r,a=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&s(e,n,t[n]);if(r)for(var n of r(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(((r,o)=>{var i=e=>{try{a(n.next(e))}catch(e){o(e)}},s=e=>{try{a(n.throw(e))}catch(e){o(e)}},a=e=>e.done?r(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:r})=>new Promise((o=>{const i=a({"Content-Type":"application/json;charset=utf-8"},n);R.appKey&&(i.Authorization="Bearer "+R.appKey),fetch(d+e,{method:t,headers:i,body:JSON.stringify(r)}).then((e=>{if(e.ok)return e.json();throw new Error("Network response was not ok.")})).then((e=>{o(e)})).catch((e=>{o(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 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 r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{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,x,C,E,A;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 r=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.")},o=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=o(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,r=this.sigBytes,o=e.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var s=n[i>>>2]>>>24-i%4*8&255;t[r+i>>>2]|=s<<24-(r+i)%4*8}else for(var a=0;a<o;a+=4)t[r+a>>>2]=n[a>>>2];return this.sigBytes+=o,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(r());return new c.init(t,e)}}),l=i.enc={},d=l.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new c.init(n,t/2)}},u=l.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%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,r=this._data,o=r.words,i=r.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(o,u);n=o.splice(0,l),r.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 k=p(g.exports=(A=P(),b=(v=A).lib,_=b.WordArray,S=b.Hasher,x=v.algo,C=[],E=x.SHA1=S.extend({_doReset:function(){this._hash=new _.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],a=n[4],c=0;c<80;c++){if(c<16)C[c]=0|e[t+c];else{var l=C[c-3]^C[c-8]^C[c-14]^C[c-16];C[c]=l<<1|l>>>31}var d=(r<<5|r>>>27)+a+C[c];d+=c<20?1518500249+(o&i|~o&s):c<40?1859775393+(o^i^s):c<60?(o&i|o&s|i&s)-1894007588:(o^i^s)-899497514,a=s,s=i,i=o<<30|o>>>2,o=r,r=d}n[0]=n[0]+r|0,n[1]=n[1]+o|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,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(r+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(E),v.HmacSHA1=S._createHmacHelper(E),A.SHA1)),O="tb_cookie_obj",I="tb_randomId",L="tb_load_url",U="tb_load_source_url";class j{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 r(e,t){var n,r,o,i,s;return o=2147483648&e,i=2147483648&t,s=(1073741823&e)+(1073741823&t),(n=1073741824&e)&(r=1073741824&t)?2147483648^s^o^i:n|r?1073741824&s?3221225472^s^o^i:1073741824^s^o^i:s^o^i}function o(e,t,o,i,s,a,c){return e=r(e,r(r(function(e,t,n){return e&t|~e&n}(t,o,i),s),c)),r(n(e,a),t)}function i(e,t,o,i,s,a,c){return e=r(e,r(r(function(e,t,n){return e&n|t&~n}(t,o,i),s),c)),r(n(e,a),t)}function s(e,t,o,i,s,a,c){return e=r(e,r(r(function(e,t,n){return e^t^n}(t,o,i),s),c)),r(n(e,a),t)}function a(e,t,o,i,s,a,c){return e=r(e,r(r(function(e,t,n){return t^(e|~n)}(t,o,i),s),c)),r(n(e,a),t)}function c(e){var t,n="",r="";for(t=0;t<=3;t++)n+=(r="0"+(e>>>8*t&255).toString(16)).substr(r.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,r=n+8,o=16*((r-r%64)/64+1),i=Array(o-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[o-2]=n<<3,i[o-1]=n>>>29,i}(e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t+=String.fromCharCode(r):r>127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|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=o(h,g,m,y,w[l+0],7,3614090360),y=o(y,h,g,m,w[l+1],12,3905402710),m=o(m,y,h,g,w[l+2],17,606105819),g=o(g,m,y,h,w[l+3],22,3250441966),h=o(h,g,m,y,w[l+4],7,4118548399),y=o(y,h,g,m,w[l+5],12,1200080426),m=o(m,y,h,g,w[l+6],17,2821735955),g=o(g,m,y,h,w[l+7],22,4249261313),h=o(h,g,m,y,w[l+8],7,1770035416),y=o(y,h,g,m,w[l+9],12,2336552879),m=o(m,y,h,g,w[l+10],17,4294925233),g=o(g,m,y,h,w[l+11],22,2304563134),h=o(h,g,m,y,w[l+12],7,1804603682),y=o(y,h,g,m,w[l+13],12,4254626195),m=o(m,y,h,g,w[l+14],17,2792965006),h=i(h,g=o(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=r(h,d),g=r(g,u),m=r(m,f),y=r(y,p);return 32===t?(c(h)+c(g)+c(m)+c(y)).toLowerCase():(c(g)+c(m)).toLowerCase()},B=(e,t)=>l(void 0,null,(function*(){const n=t||function(){};try{const t=new j;let r=t.get(O);const o=r?JSON.parse(r):{},i=o?o[e]:null;if(""!==i&&i)n(i);else{const r=function(e){const t=new j(!0);let n=t.get(I);if(!n||""===n){const r="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";let o="";for(let t=0;t<e;t++){const e=Math.floor(Math.random()*r.length);o+=r.charAt(e)}n=o,t.set(I,n)}return n}(32),i=navigator.language,s=N(),a=$(),c=yield u({url:"/ecl/bs/check",params:{bfp:r,language:i,screen_width:s,screen_height:a}}),{code:l,data:d}=c||{};200===l&&d&&(o[e]=d.cookie_id,t.set(O,JSON.stringify(o))),n(d.cookie_id)}}catch(e){n("1")}}));const N=()=>{let e=0;try{e=window.screen.width}catch(t){e=0}return e},$=()=>{let e=0;try{e=window.screen.height}catch(t){e=0}return e},K={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"}},M={name:"turbolink-ai",version:"1.1.3",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 R={appKey:"",appSecret:"",projectId:""},D="",z="",H="",V=!1,W=!0,F="";let Y="";const J=e=>new Promise((t=>{G("install").then((n=>{t(n),e&&e(n)}))})),X=e=>new Promise((t=>{G("open").then((n=>{t(n),e&&e(n)}))})),G=(e,t)=>new Promise((n=>{try{const{appKey:r,appSecret:o,projectId:i}=R||{};if(""===r||!r||""===o||!o||""===i||!i)throw K.NOT_INIT;if(!e||""===e)throw K.EMPTY_EVENT_NAME;B(i,(r=>l(void 0,null,(function*(){const s=N(),a=$(),c=(new Date).valueOf(),d=c.toString(),f=k(`${i}_${d}_${c}_${o}`).toString(),p=(()=>{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})(),h=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})),g=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})),m=yield new Promise((e=>{try{const t=new RTCPeerConnection;t.createDataChannel(""),t.onicecandidate=function(n){if(n.candidate){const r=n.candidate.candidate,o=/(?:[0-9]{1,3}\.){3}[0-9]{1,3}/.exec(r),i=o?o[0]:null;e(i),t.close()}else e()},t.createOffer().then((e=>t.setLocalDescription(e))).catch((()=>{e()}))}catch(t){e()}})),y=(()=>{let e="Unknown";try{e=(navigator.language||navigator.userLanguage).substring(3).toUpperCase()}catch(t){e="Unknown"}return e})(),w=(()=>{let e="Unknown";try{e=(navigator.language||navigator.userLanguage).substring(0,2).toLowerCase()}catch(t){e="Unknown"}return e})(),v=(()=>{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"})(),b=(()=>{var e=navigator.userAgent,t=0;return-1!==e.indexOf("Firefox")?t=parseFloat(e.match(/Firefox\/([\d.]+)/)[1]):-1!==e.indexOf("Edge")?t=parseFloat(e.match(/Edge\/([\d.]+)/)[1]):-1!==e.indexOf("Chrome")?t=parseFloat(e.match(/Chrome\/([\d.]+)/)[1]):-1!==e.indexOf("Safari")?t=parseFloat(e.match(/Version\/([\d.]+)/)[1]):(-1!==e.indexOf("MSIE")||-1!==e.indexOf("Trident/"))&&(t=parseFloat(e.match(/MSIE (\d+[.]\d+)|(?:Trident\/[\d.]+).*rv:([\d.]+)/)[1]||e.match(/rv:([\d.]+)/))),t})().toString(),_=(null==M?void 0:M.version)||"1.0.0",S=`${s}x${a}`,x=window.location.href,C=navigator.userAgent,E="UTC+"+(0-(new Date).getTimezoneOffset()/60),A=document.referrer,P=(()=>{const e=document.createElement("canvas"),t=e.getContext("2d");var 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 r=e.toDataURL();return T(r,32)})(),O={web:{browser_name:v,browser_version:b,current_time:c,device_type:g,ip:m||"",language:w,os:p,screen_resolution:S,sdk_version:_,url:x,user_agent:C,time_zone:E,referer:A,canvas:P}};let I=[];t&&t.constructor===Array&&(I=t.map((e=>{const t={};return Object.keys(e).forEach((n=>{const r=e[n];t[n]="string"!=typeof r?String(r):r})),t})));const L={project:i,request_id:d,timestamp:c,msg_signature:f,event:e,user_data:{native_msg:"",os:p,os_version:h,device_model:g,device_id:r,user_id:D.toString(),country:y,language:w,screen_width:s,screen_height:a,ip:m||""},custom_data:I,ext_data:O},U=yield u({url:"/v2/event",params:L}),{code:j,data:B,msg:K}=U||{};if(200===j&&B){let e="";const t=B.link_data||[];B.blackbox&&""!==B.blackbox&&(Y=B.blackbox||"");for(let n=0;n<t.length;n++)if("$campaign_url"===t[n].key){e=decodeURIComponent(t[n].value||"");break}W&&""!==e&&(window.location.href=e),n({code:j,message:K,data:B})}else n({code:j,message:K})}))))}catch(e){n(e)}})),Z=e=>{if(!e||""===e)return"";const t=D||"",n=navigator.language,r=z||n||"",o=Math.floor((new Date).getTime()/1e3),i="1.2.0",s=o%100,a="5CfUxPK7avjguYtG8yAE4ud6n9s774zVVdKwSxPryzaKHSpS4Lgju4M7sLumdLuQWXpHC6peBp2afBwEBbYnENGbZWfkZ6n4s52D3Xye59bfeK4gS9nfjehK".substring(s,s+12),c=`${t}${H}${r}${o}${Y}${i}web${R.appSecret}${a}`,l=T(c,32);return((e,t)=>{const n=new URL(e),r=n.searchParams;return t.forEach((e=>{const{name:t,value:n}=e;r.has(t)?r.set(t,n):r.append(t,n)})),n.origin+n.pathname+"?"+r.toString()})(e,[{name:"user_id",value:t},{name:"lv",value:H},{name:"lg",value:r},{name:"time",value:o},{name:"blackbox",value:Y},{name:"version",value:i},{name:"platform",value:"web"},{name:"token",value:l}])};class q{}c(q,"init",((e,t)=>new Promise((n=>{const r=t||function(){};try{const{appKey:t,appSecret:o,projectId:i,uid:s,lang:a,lv:c,loginUrl:l,jump:u=!0,dev:f=!1}=e||{};if(!t||""===t)throw K.LACK_APPKEY;if(!o||""===o)throw K.LACK_APPSECRET;if(!i||""===i)throw K.LACK_PROJECTID;f&&(e=>{e&&(d="https://test.allapp.link")})(f),s&&(D=s),a&&(z=a),c&&(H=c),l&&(F=l),W=u,R=e||{};let p=(new j).get(I);if(V)return n(K.SUCCESS),void r(K.SUCCESS);null==p||" "===p||""===p?J().then((e=>{n(e),r(e)})):X().then((e=>{n(e),r(e)})),V=!0}catch(e){n(e),r(e)}})))),c(q,"setIdentity",((e,t)=>new Promise((n=>{const{SUCCESS:r,UNKNOWN:o}=K||{};try{if("object"==typeof e&&null!==e){const{uid:t,lv:n}=e||{};t&&(D=t),n&&(H=n)}else D=e;n(r),t&&t(r)}catch(e){n(o),t&&t(o)}})))),c(q,"install",J),c(q,"register",((e,t)=>new Promise((n=>{const r=t||function(){};try{const{uId:t,lv:o}=e||{};t&&(D=t),o&&(H=o),G("register").then((e=>{const t=new j,o=t.get(L),i=t.get(U);if(i&&"1"===i){const e=Z(o);window.location.replace(e&&e),t.remove(U)}n(e),r(e)}))}catch(e){n(e),r(e)}})))),c(q,"open",X),c(q,"customEvent",((e,r)=>new Promise((o=>{const i=r||function(){};try{const{event:r,customData:s,backCamp:c}=e||{};if(!r||""===r)throw K.EMPTY_EVENT_NAME;G(r,s).then((e=>{const r=(new j).get(L),s=Z(r),l=((e,r)=>t(e,n(r)))(a({},e),{campUrl:s});c&&s&&window.location.replace(s),o(l),i(l)}))}catch(e){o(e),i(e)}})))),c(q,"loadUrl",((e,t)=>new Promise((n=>{const r=t||function(){},{SUCCESS:o}=K||{},{url:i,newWindow:s=!1}=e||{};try{if(!R.appSecret||""===R.appSecret)throw K.LACK_APPSECRET;if(!i||""===i)throw K.INVALID_URL;let e=Z(i);if(F&&""!==F){e=`${e}&loginUrl=${encodeURIComponent(F)}`}const t=new j;t.set(L,i),t.set(U,"1"),!0===s||"true"===s?window.open(e,"_blank"):window.location.href=e,r(o),n(o),G("loadUrl")}catch(e){n(e),r(e)}})))),c(q,"webLoadUrl",((e,t)=>new Promise((n=>{const r=t||function(){},{SUCCESS:o}=K||{},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(!R.appSecret||""===R.appSecret)throw K.LACK_APPSECRET;if(!s||""===s)throw K.INVALID_URL;let e=Z(s);if(e=`${e}&webIframe=1`,w&&(e=`${e}&jpN=1`),F&&""!==F){e=`${e}&loginUrl=${encodeURIComponent(F)}`}let t=document.getElementById("turbolinkSdkPopup");t&&t.remove();const v=document.createElement("div");v.id="turbolinkSdkPopup",v.style.position="fixed",v.style.zIndex=g,v.style.left="0",v.style.top="0",v.style.right="0",v.style.bottom="0",v.style.width="100%",v.style.height="100%",v.style.overflowX="hidden",v.style.overflowY="auto",v.style.backgroundColor=a;const b=document.createElement("div");b.style.minHeight="100%",b.style.display="-webkit-box",b.style.display="-ms-flexbox",b.style.display="-moz-box",b.style.display="flex",b.style.textAlign="center",b.style.justifyContent="center",b.style.alignItems="center";const _=document.createElement("div");_.style.margin="10vh auto",_.style.border="none",_.style.width=`${f}px`,_.style.height=`${p}px`,_.style.position="relative",_.style.borderRadius=`${h}px`,_.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 S=document.createElement("iframe");S.id="turbolinkSdkPopupIframe",S.width=`${f}px`,S.height=`${p}px`,S.style.border="none",S.style.borderRadius=`${h}px`,S.style.overflow="hidden",S.style.position="relative",S.style.zIndex="10",S.src=e;const x=document.createElement("div"),C=document.createElement("img");let E=l;u&&(E=p*(E/i)),x.style.height=`${E}px`,S.onload=()=>{setTimeout((()=>{let e="https://i1.branchcn.com/web/sdk/img/campBg.png";c&&""!==c&&(e=c),x.style.position="absolute",x.style.fontSize="0px",x.style.zIndex="6",C.id="turbolinkSdkBgImg",C.src=e,C.style.width=d||"auto",C.style.height="100%",x.appendChild(C)}),0)};const A=document.createElement("div"),P=document.createElement("img");A.style.position="absolute",A.style.fontSize="0px",A.style.zIndex="100",A.style.top="-54px",A.style.right="-200px",P.src="https://i1.branchcn.com/web/sdk/img/campClose.png",P.style.width="40px",P.style.height="auto",A.appendChild(P);const k=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",k),window.addEventListener("message",k)),A.addEventListener("click",(()=>{v.remove(),y&&(document.body.style.overflow="auto"),m&&window.removeEventListener("message",k)})),_.appendChild(x),_.appendChild(S),_.appendChild(A),b.appendChild(_),v.appendChild(b),document.body.appendChild(v),y&&(document.body.style.overflow="hidden"),r(o),n(o)}catch(e){n(e),r(e)}})))),c(q,"login",((e,t)=>new Promise((n=>{const r=t||function(){},{uId:o,lv:i}=e||{};try{if(!o||""===o)throw K.LACK_UID;o&&(D=o),G("login").then((e=>{const t=new j,o=t.get(L),i=t.get(U);if(i&&"1"===i){const e=Z(o);window.location.replace(e&&e),t.remove(U)}n(e),r(e)}))}catch(e){n(e),r(e)}})))),c(q,"logout",(e=>new Promise((t=>{const n=e||function(){};(new j).remove(L),D=null;const{SUCCESS:r}=K||{};t(r),n(r),G("logout")})))),c(q,"getInitState",(()=>V)),c(q,"getLoginState",(()=>!(null===D||""===D||" "===D||void 0===D)));export{q 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);R.appKey&&(i.Authorization="Bearer "+R.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,_,x,S,C;function E(){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=E(),w=(y=C).lib,v=w.WordArray,b=w.Hasher,_=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)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=b.clone.call(this);return e._hash=this._hash.clone(),e}}),y.SHA1=b._createHelper(S),y.HmacSHA1=b._createHmacHelper(S),C.SHA1);const A=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(p.exports),k="tb_cookie_obj",P="tb_randomId",O="tb_load_url",I="tb_load_source_url";class L{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 U=(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()},j=(e,t)=>l(this,null,(function*(){const n=t||function(){};try{const t=new L;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 L(!0);let n=t.get(P);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(P,n)}return n}(32),i=navigator.language,s=N(),a=$(),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 T=()=>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})),B=()=>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})),N=()=>{let e=0;try{e=window.screen.width}catch(t){e=0}return e},$=()=>{let e=0;try{e=window.screen.height}catch(t){e=0}return e},K={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"}},M={name:"turbolink-ai",version:"1.1.3",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 R={appKey:"",appSecret:"",projectId:""},D="",z="",H="",V=!1,W=!0,F="";let Y="";const J=e=>new Promise((t=>{G("install").then((n=>{t(n),e&&e(n)}))})),X=e=>new Promise((t=>{G("open").then((n=>{t(n),e&&e(n)}))})),G=(e,t)=>new Promise((n=>{try{const{appKey:o,appSecret:r,projectId:i}=R||{};if(""===o||!o||""===r||!r||""===i||!i)throw K.NOT_INIT;if(!e||""===e)throw K.EMPTY_EVENT_NAME;j(i,(o=>l(this,null,(function*(){const s=N(),a=$(),c=(new Date).valueOf(),l=c.toString(),d=A(`${i}_${l}_${c}_${r}`).toString(),f=(()=>{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})(),p=yield T(),h=yield B(),g=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()}})),m=(()=>{let e="Unknown";try{e=(navigator.language||navigator.userLanguage).substring(3).toUpperCase()}catch(t){e="Unknown"}return e})(),y=(()=>{let e="Unknown";try{e=(navigator.language||navigator.userLanguage).substring(0,2).toLowerCase()}catch(t){e="Unknown"}return e})(),w=(()=>{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"})(),v=(()=>{var e=navigator.userAgent,t=0;return-1!==e.indexOf("Firefox")?t=parseFloat(e.match(/Firefox\/([\d.]+)/)[1]):-1!==e.indexOf("Edge")?t=parseFloat(e.match(/Edge\/([\d.]+)/)[1]):-1!==e.indexOf("Chrome")?t=parseFloat(e.match(/Chrome\/([\d.]+)/)[1]):-1!==e.indexOf("Safari")?t=parseFloat(e.match(/Version\/([\d.]+)/)[1]):(-1!==e.indexOf("MSIE")||-1!==e.indexOf("Trident/"))&&(t=parseFloat(e.match(/MSIE (\d+[.]\d+)|(?:Trident\/[\d.]+).*rv:([\d.]+)/)[1]||e.match(/rv:([\d.]+)/))),t})().toString(),b=(null==M?void 0:M.version)||"1.0.0",_=`${s}x${a}`,x=window.location.href,S=navigator.userAgent,C="UTC+"+(0-(new Date).getTimezoneOffset()/60),E=document.referrer,k=(()=>{const e=document.createElement("canvas"),t=e.getContext("2d");var 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 U(o,32)})(),P={web:{browser_name:w,browser_version:v,current_time:c,device_type:h,ip:g||"",language:y,os:f,screen_resolution:_,sdk_version:b,url:x,user_agent:S,time_zone:C,referer:E,canvas:k}};let O=[];t&&t.constructor===Array&&(O=t.map((e=>{const t={};return Object.keys(e).forEach((n=>{const o=e[n];t[n]="string"!=typeof o?String(o):o})),t})));const I={project:i,request_id:l,timestamp:c,msg_signature:d,event:e,user_data:{native_msg:"",os:f,os_version:p,device_model:h,device_id:o,user_id:D.toString(),country:m,language:y,screen_width:s,screen_height:a,ip:g||""},custom_data:O,ext_data:P},L=yield u({url:"/v2/event",params:I}),{code:j,data:K,msg:R}=L||{};if(200===j&&K){let e="";const t=K.link_data||[];K.blackbox&&""!==K.blackbox&&(Y=K.blackbox||"");for(let n=0;n<t.length;n++)if("$campaign_url"===t[n].key){e=decodeURIComponent(t[n].value||"");break}W&&""!==e&&(window.location.href=e),n({code:j,message:R,data:K})}else n({code:j,message:R})}))))}catch(e){n(e)}})),Z=e=>{if(!e||""===e)return"";const t=D||"",n=navigator.language,o=z||n||"",r=Math.floor((new Date).getTime()/1e3),i="1.2.0",s=r%100,a="5CfUxPK7avjguYtG8yAE4ud6n9s774zVVdKwSxPryzaKHSpS4Lgju4M7sLumdLuQWXpHC6peBp2afBwEBbYnENGbZWfkZ6n4s52D3Xye59bfeK4gS9nfjehK".substring(s,s+12),c=`${t}${H}${o}${r}${Y}${i}web${R.appSecret}${a}`,l=U(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:H},{name:"lg",value:o},{name:"time",value:r},{name:"blackbox",value:Y},{name:"version",value:i},{name:"platform",value:"web"},{name:"token",value:l}])};class q{}return c(q,"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}=e||{};if(!t||""===t)throw K.LACK_APPKEY;if(!r||""===r)throw K.LACK_APPSECRET;if(!i||""===i)throw K.LACK_PROJECTID;f&&(e=>{e&&(d="https://test.allapp.link")})(f),s&&(D=s),a&&(z=a),c&&(H=c),l&&(F=l),W=u,R=e||{};let p=(new L).get(P);if(V)return n(K.SUCCESS),void o(K.SUCCESS);null==p||" "===p||""===p?J().then((e=>{n(e),o(e)})):X().then((e=>{n(e),o(e)})),V=!0}catch(e){n(e),o(e)}})))),c(q,"setIdentity",((e,t)=>new Promise((n=>{const{SUCCESS:o,UNKNOWN:r}=K||{};try{if("object"==typeof e&&null!==e){const{uid:t,lv:n}=e||{};t&&(D=t),n&&(H=n)}else D=e;n(o),t&&t(o)}catch(e){n(r),t&&t(r)}})))),c(q,"install",J),c(q,"register",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{uId:t,lv:r}=e||{};t&&(D=t),r&&(H=r),G("register").then((e=>{const t=new L,r=t.get(O),i=t.get(I);if(i&&"1"===i){const e=Z(r);window.location.replace(e&&e),t.remove(I)}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(q,"open",X),c(q,"customEvent",((e,o)=>new Promise((r=>{const i=o||function(){};try{const{event:o,customData:s,backCamp:c}=e||{};if(!o||""===o)throw K.EMPTY_EVENT_NAME;G(o,s).then((e=>{const o=(new L).get(O),s=Z(o),l=((e,o)=>t(e,n(o)))(a({},e),{campUrl:s});c&&s&&window.location.replace(s),r(l),i(l)}))}catch(e){r(e),i(e)}})))),c(q,"loadUrl",((e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=K||{},{url:i,newWindow:s=!1}=e||{};try{if(!R.appSecret||""===R.appSecret)throw K.LACK_APPSECRET;if(!i||""===i)throw K.INVALID_URL;let e=Z(i);if(F&&""!==F){e=`${e}&loginUrl=${encodeURIComponent(F)}`}const t=new L;t.set(O,i),t.set(I,"1"),!0===s||"true"===s?window.open(e,"_blank"):window.location.href=e,o(r),n(r),G("loadUrl")}catch(e){n(e),o(e)}})))),c(q,"webLoadUrl",((e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=K||{},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(!R.appSecret||""===R.appSecret)throw K.LACK_APPSECRET;if(!s||""===s)throw K.INVALID_URL;let e=Z(s);if(e=`${e}&webIframe=1`,w&&(e=`${e}&jpN=1`),F&&""!==F){e=`${e}&loginUrl=${encodeURIComponent(F)}`}let t=document.getElementById("turbolinkSdkPopup");t&&t.remove();const v=document.createElement("div");v.id="turbolinkSdkPopup",v.style.position="fixed",v.style.zIndex=g,v.style.left="0",v.style.top="0",v.style.right="0",v.style.bottom="0",v.style.width="100%",v.style.height="100%",v.style.overflowX="hidden",v.style.overflowY="auto",v.style.backgroundColor=a;const b=document.createElement("div");b.style.minHeight="100%",b.style.display="-webkit-box",b.style.display="-ms-flexbox",b.style.display="-moz-box",b.style.display="flex",b.style.textAlign="center",b.style.justifyContent="center",b.style.alignItems="center";const _=document.createElement("div");_.style.margin="10vh auto",_.style.border="none",_.style.width=`${f}px`,_.style.height=`${p}px`,_.style.position="relative",_.style.borderRadius=`${h}px`,_.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("iframe");x.id="turbolinkSdkPopupIframe",x.width=`${f}px`,x.height=`${p}px`,x.style.border="none",x.style.borderRadius=`${h}px`,x.style.overflow="hidden",x.style.position="relative",x.style.zIndex="10",x.src=e;const S=document.createElement("div"),C=document.createElement("img");let E=l;u&&(E=p*(E/i)),S.style.height=`${E}px`,x.onload=()=>{setTimeout((()=>{let e="https://i1.branchcn.com/web/sdk/img/campBg.png";c&&""!==c&&(e=c),S.style.position="absolute",S.style.fontSize="0px",S.style.zIndex="6",C.id="turbolinkSdkBgImg",C.src=e,C.style.width=d||"auto",C.style.height="100%",S.appendChild(C)}),0)};const A=document.createElement("div"),k=document.createElement("img");A.style.position="absolute",A.style.fontSize="0px",A.style.zIndex="100",A.style.top="-54px",A.style.right="-200px",k.src="https://i1.branchcn.com/web/sdk/img/campClose.png",k.style.width="40px",k.style.height="auto",A.appendChild(k);const P=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",P),window.addEventListener("message",P)),A.addEventListener("click",(()=>{v.remove(),y&&(document.body.style.overflow="auto"),m&&window.removeEventListener("message",P)})),_.appendChild(S),_.appendChild(x),_.appendChild(A),b.appendChild(_),v.appendChild(b),document.body.appendChild(v),y&&(document.body.style.overflow="hidden"),o(r),n(r)}catch(e){n(e),o(e)}})))),c(q,"login",((e,t)=>new Promise((n=>{const o=t||function(){},{uId:r,lv:i}=e||{};try{if(!r||""===r)throw K.LACK_UID;r&&(D=r),G("login").then((e=>{const t=new L,r=t.get(O),i=t.get(I);if(i&&"1"===i){const e=Z(r);window.location.replace(e&&e),t.remove(I)}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(q,"logout",(e=>new Promise((t=>{const n=e||function(){};(new L).remove(O),D=null;const{SUCCESS:o}=K||{};t(o),n(o),G("logout")})))),c(q,"getInitState",(()=>V)),c(q,"getLoginState",(()=>!(null===D||""===D||" "===D||void 0===D))),q}));
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "turbolink-ai",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",
7
7
  "type": "module",
8
- "types": "index.d.ts",
9
8
  "scripts": {
10
9
  "test": "echo \"Error: no test specified\" && exit 1",
11
10
  "build": "vite build"
@@ -22,4 +21,4 @@
22
21
  "dependencies": {
23
22
  "javascript-obfuscator": "^4.1.0"
24
23
  }
25
- }
24
+ }
package/index.d.ts DELETED
@@ -1,169 +0,0 @@
1
- // SDK initialization parameter type
2
- export declare interface InitParam {
3
- appKey: string //appKey
4
- appSecret: string //appSecret
5
- projectId: string //projectId
6
- uid?: string | number //userId
7
- jump?: boolean //Whether the report will jump automatically if successful
8
- lang?: string //Set language
9
- lv?: string //Set user level
10
- loginUrl?: string //Login page address
11
- }
12
-
13
- //Set user parameter types
14
- export declare interface SetIdentityParam {
15
- uid?: string | number //userId
16
- lv?: string //Set user level
17
- }
18
-
19
- //Custom event request parameter type
20
- export declare interface CustomEventParam {
21
- event: string //Event name
22
- customData?: CustomDataModel[] //Custom parameters
23
- backCamp?: boolean //Back to the gameplay page (automatic)
24
- }
25
-
26
- //Custom parameter type
27
- export declare interface CustomDataModel {
28
- key: string
29
- value: string
30
- }
31
-
32
-
33
- //Login event request parameter type
34
- export declare interface LoginEventParam {
35
- uId: string | number //userId
36
- lv?: string //Set user level
37
- }
38
-
39
- //Register event request parameter type
40
- export declare interface RegisterEventParam {
41
- uId: string | number //userId
42
- lv?: string //Set user level
43
- }
44
-
45
- //LoadUrl event request parameter type
46
- export declare interface LoadUrlEventParam {
47
- url: string //Url
48
- newWindow?: boolean //Whether to open a new window, default to false
49
- }
50
-
51
-
52
- //webLoadUrl event request parameter type
53
- export declare interface WebLoadUrlEventParam {
54
- url: string // Url
55
- width?: number | string // View width, default: 300px
56
- height?: number | string // View height, default: 650px
57
- radius?: number // View rounded corner, default: 12px
58
- backgroundImage?: string // Background image url
59
- backgroundHeight?: number | string // Background height, default: 738px
60
- backgroundWidth?: number | string // Background height, default: auto
61
- maskColor?: string // Mask Color, default: rgba(0, 0, 0, 0.8)
62
- bgLinkage?: boolean // Background linkage amplification
63
- bodyHidden?: boolean // Do you prohibit page scrolling when the window is opened, default: true
64
- jumpNewWindow?: boolean // Does the page jump within the gameplay allow for a new window to open
65
- clickEventCallback?: (res: WebClickCallParam) => void // Click on the event callback within the activity
66
- }
67
-
68
-
69
- //Click on the event callback within the activity
70
- export declare interface WebClickCallParam {
71
- type: "turbolinkLogin" | "turbolinkTask" | "turbolinkRedirect", //Method Type
72
- params?: string //Parameter: JSON string
73
- }
74
-
75
-
76
- //The type of parameter returned by the callback method
77
- export declare interface CallbackResultModel {
78
- code: Number //Status
79
- message: string //Message
80
- data?: any //Success data
81
- campUrl?: string //Gameplay page address
82
- }
83
-
84
- //Callback method type
85
- export declare type CallbackModel = (result: CallbackResultModel) => void
86
-
87
- /**
88
- * SDK initialization (this method needs to be called before event reporting)
89
- * @param param Initialization parameter type
90
- * @param callback
91
- */
92
- export declare function init<T>(param: InitParam, callback?: CallbackModel): Promise<CallbackResultModel>
93
-
94
-
95
- /**
96
- * Set up user
97
- * @param param
98
- * @param callback
99
- */
100
- export declare function setIdentity<T>(param: string | number | SetIdentityParam, callback?: CallbackModel): Promise<CallbackResultModel>
101
-
102
- /**
103
- * Installation event reporting
104
- * @param callback
105
- */
106
- export declare function install<T>(callback?: CallbackModel): Promise<CallbackResultModel>
107
-
108
- /**
109
- * Register event reporting
110
- * @param param Login event request parameters
111
- * @param callback
112
- */
113
- export declare function register<T>(param: RegisterEventParam, callback?: CallbackModel): Promise<CallbackResultModel>
114
-
115
-
116
- /**
117
- * Open incident reporting
118
- * @param callback
119
- */
120
- export declare function open<T>(callback?: CallbackModel): Promise<CallbackResultModel>
121
-
122
-
123
- /**
124
- * Logout incident reporting
125
- * @param callback
126
- */
127
- export declare function logout<T>(callback?: CallbackModel): Promise<CallbackResultModel>
128
-
129
- /**
130
- * Login event reporting
131
- * @param param Login event request parameters
132
- * @param callback
133
- */
134
- export declare function login<T>(param: LoginEventParam, callback?: CallbackModel): Promise<CallbackResultModel>
135
-
136
- /**
137
- * LoadUrl event reporting
138
- * @param param LoadUrl event request parameters
139
- * @param callback
140
- */
141
- export declare function loadUrl<T>(param: LoadUrlEventParam, callback?: CallbackModel): Promise<CallbackResultModel>
142
-
143
-
144
- /**
145
- * WebLoadUrl event reporting
146
- * @param param
147
- * @param callback
148
- */
149
- export declare function webLoadUrl<T>(param: WebLoadUrlEventParam, callback?: CallbackModel): Promise<CallbackResultModel>
150
-
151
-
152
- /**
153
- * Get initialization status
154
- */
155
- export declare function getInitState(): boolean
156
-
157
-
158
- /**
159
- * Get login status
160
- */
161
- export declare function getLoginState(): boolean
162
-
163
-
164
- /**
165
- * Custom event reporting
166
- * @param param Custom event request parameters
167
- * @param callback
168
- */
169
- export declare function customEvent<T>(param: CustomEventParam, callback?: CallbackModel): Promise<CallbackResultModel>