turbolink-ai 1.2.6 → 1.2.8

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},l=(e,o)=>t(e,n(o)),c=(e,t,n)=>(s(e,"symbol"!=typeof t?t+"":t,n),n),d=(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 u="https://www.allapp.link";const p=({url:e,method:t="POST",headers:n,params:o})=>new Promise((r=>{const i=a({"Content-Type":"application/json;charset=utf-8"},n);W.appKey&&(i.Authorization="Bearer "+W.appKey),fetch(u+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 h(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 m={exports:{}};var y={exports:{}};const w=g(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var v,b,S,x,C,_,I,E,k;function A(){return v||(v=1,y.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=w}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)}},l=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 l.init(t,e)}}),c=i.enc={},d=c.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 l.init(n,t/2)}},u=c.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 l.init(n,t)}},p=c.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 l.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),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*s,d=e.min(4*c,i);if(c){for(var u=0;u<c;u+=s)this._doProcessBlock(r,u);n=r.splice(0,c),o.sigBytes-=d}return new l.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)),y.exports;var e}const O=h(m.exports=(k=A(),S=(b=k).lib,x=S.WordArray,C=S.Hasher,_=b.algo,I=[],E=_.SHA1=C.extend({_doReset:function(){this._hash=new x.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],l=0;l<80;l++){if(l<16)I[l]=0|e[t+l];else{var c=I[l-3]^I[l-8]^I[l-14]^I[l-16];I[l]=c<<1|c>>>31}var d=(o<<5|o>>>27)+a+I[l];d+=l<20?1518500249+(r&i|~r&s):l<40?1859775393+(r^i^s):l<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=C.clone.call(this);return e._hash=this._hash.clone(),e}}),b.SHA1=C._createHelper(E),b.HmacSHA1=C._createHmacHelper(E),k.SHA1)),P="tb_cookie_obj",U="tb_randomId",L="tb_load_url",j="tb_load_source_url",$="tb_ascribe_to_url",B="tb_init_state",R="tb_blackbox";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 D=(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,l){return e=o(e,o(o(function(e,t,n){return e&t|~e&n}(t,r,i),s),l)),o(n(e,a),t)}function i(e,t,r,i,s,a,l){return e=o(e,o(o(function(e,t,n){return e&n|t&~n}(t,r,i),s),l)),o(n(e,a),t)}function s(e,t,r,i,s,a,l){return e=o(e,o(o(function(e,t,n){return e^t^n}(t,r,i),s),l)),o(n(e,a),t)}function a(e,t,r,i,s,a,l){return e=o(e,o(o(function(e,t,n){return t^(e|~n)}(t,r,i),s),l)),o(n(e,a),t)}function l(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 c,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,c=0;c<w.length;c+=16)d=h,u=g,p=m,f=y,h=r(h,g,m,y,w[c+0],7,3614090360),y=r(y,h,g,m,w[c+1],12,3905402710),m=r(m,y,h,g,w[c+2],17,606105819),g=r(g,m,y,h,w[c+3],22,3250441966),h=r(h,g,m,y,w[c+4],7,4118548399),y=r(y,h,g,m,w[c+5],12,1200080426),m=r(m,y,h,g,w[c+6],17,2821735955),g=r(g,m,y,h,w[c+7],22,4249261313),h=r(h,g,m,y,w[c+8],7,1770035416),y=r(y,h,g,m,w[c+9],12,2336552879),m=r(m,y,h,g,w[c+10],17,4294925233),g=r(g,m,y,h,w[c+11],22,2304563134),h=r(h,g,m,y,w[c+12],7,1804603682),y=r(y,h,g,m,w[c+13],12,4254626195),m=r(m,y,h,g,w[c+14],17,2792965006),h=i(h,g=r(g,m,y,h,w[c+15],22,1236535329),m,y,w[c+1],5,4129170786),y=i(y,h,g,m,w[c+6],9,3225465664),m=i(m,y,h,g,w[c+11],14,643717713),g=i(g,m,y,h,w[c+0],20,3921069994),h=i(h,g,m,y,w[c+5],5,3593408605),y=i(y,h,g,m,w[c+10],9,38016083),m=i(m,y,h,g,w[c+15],14,3634488961),g=i(g,m,y,h,w[c+4],20,3889429448),h=i(h,g,m,y,w[c+9],5,568446438),y=i(y,h,g,m,w[c+14],9,3275163606),m=i(m,y,h,g,w[c+3],14,4107603335),g=i(g,m,y,h,w[c+8],20,1163531501),h=i(h,g,m,y,w[c+13],5,2850285829),y=i(y,h,g,m,w[c+2],9,4243563512),m=i(m,y,h,g,w[c+7],14,1735328473),h=s(h,g=i(g,m,y,h,w[c+12],20,2368359562),m,y,w[c+5],4,4294588738),y=s(y,h,g,m,w[c+8],11,2272392833),m=s(m,y,h,g,w[c+11],16,1839030562),g=s(g,m,y,h,w[c+14],23,4259657740),h=s(h,g,m,y,w[c+1],4,2763975236),y=s(y,h,g,m,w[c+4],11,1272893353),m=s(m,y,h,g,w[c+7],16,4139469664),g=s(g,m,y,h,w[c+10],23,3200236656),h=s(h,g,m,y,w[c+13],4,681279174),y=s(y,h,g,m,w[c+0],11,3936430074),m=s(m,y,h,g,w[c+3],16,3572445317),g=s(g,m,y,h,w[c+6],23,76029189),h=s(h,g,m,y,w[c+9],4,3654602809),y=s(y,h,g,m,w[c+12],11,3873151461),m=s(m,y,h,g,w[c+15],16,530742520),h=a(h,g=s(g,m,y,h,w[c+2],23,3299628645),m,y,w[c+0],6,4096336452),y=a(y,h,g,m,w[c+7],10,1126891415),m=a(m,y,h,g,w[c+14],15,2878612391),g=a(g,m,y,h,w[c+5],21,4237533241),h=a(h,g,m,y,w[c+12],6,1700485571),y=a(y,h,g,m,w[c+3],10,2399980690),m=a(m,y,h,g,w[c+10],15,4293915773),g=a(g,m,y,h,w[c+1],21,2240044497),h=a(h,g,m,y,w[c+8],6,1873313359),y=a(y,h,g,m,w[c+15],10,4264355552),m=a(m,y,h,g,w[c+6],15,2734768916),g=a(g,m,y,h,w[c+13],21,1309151649),h=a(h,g,m,y,w[c+4],6,4149444226),y=a(y,h,g,m,w[c+11],10,3174756917),m=a(m,y,h,g,w[c+2],15,718787259),g=a(g,m,y,h,w[c+9],21,3951481745),h=o(h,d),g=o(g,u),m=o(m,p),y=o(y,f);return 32===t?(l(h)+l(g)+l(m)+l(y)).toLowerCase():(l(g)+l(m)).toLowerCase()},H=(e,t)=>d(void 0,null,(function*(){const n=t||function(){};try{const t=new T;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 T(!0);let n=t.get(U);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(U,n)}return n}(32),i=navigator.language,s=K(),a=N(),l=yield p({url:"/ecl/bs/check",params:{bfp:o,language:i,screen_width:s,screen_height:a}}),{code:c,data:d}=l||{};200===c&&d&&(r[e]=d.cookie_id,t.set(P,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},N=()=>{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"}},z={name:"turbolink-ai",version:"1.2.6",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 W={appKey:"",appSecret:"",projectId:""},V="",F="",Y="",J=!0,q="",X=null,G=!1,Z=!1;const Q=e=>new Promise((t=>{re("install").then((n=>{t(n),e&&e(n)}))})),ee=e=>new Promise((t=>{re("open").then((n=>{t(n),e&&e(n)}))})),te=(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:l,backgroundHeight:c=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(!W.appSecret||""===W.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=ie(s);if(v=`${v}&webIframe=1&newSDK=1`,w&&(v=`${v}&jpN=1`),q&&""!==q){v=`${v}&loginUrl=${encodeURIComponent(q)}`}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 x=document.createElement("div");x.style.minHeight="100%",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("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 _=document.createElement("iframe");_.id="turbolinkSdkPopupIframe",_.width=`${p}px`,_.height=`${f}px`,_.style.border="none",_.style.borderRadius=`${h}px`,_.style.overflow="hidden",_.style.position="relative",_.style.zIndex="10",_.src=v;const I=document.createElement("div"),E=document.createElement("img");let k=c;u&&(k=f*(k/i)),I.style.height=`${k}px`,_.onload=()=>{I.style.position="absolute",I.style.fontSize="0px",I.style.zIndex="6",E.id="turbolinkSdkBgImg",l&&""!==l?E.src=l:se(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 A=document.createElement("div"),O=document.createElement("img");A.style.position="absolute",A.style.fontSize="0px",A.style.zIndex="100",A.style.top="-54px",A.style.right="-200px",O.src="https://i1.branchcn.com/web/sdk/img/campClose.png",O.style.width="40px",O.style.height="auto",A.appendChild(O);const P=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",P),window.addEventListener("message",P)),A.addEventListener("click",(()=>{S.remove(),y&&(document.body.style.overflow="auto");const e=m||X;e&&(e({type:"linkCloseListener",params:null}),window.removeEventListener("message",P))})),C.appendChild(I),C.appendChild(_),C.appendChild(A),x.appendChild(C),S.appendChild(x),document.body.appendChild(S),y&&(document.body.style.overflow="hidden"),o(r),n(r)}catch(e){n(e),o(e)}})),ne=()=>sessionStorage.getItem(B),oe=()=>!(null===V||""===V||" "===V||void 0===V),re=(e,t)=>new Promise((n=>{try{const{appKey:o,appSecret:r,projectId:i}=W||{},{customData:s,nativeMsg:a=""}=t||{};if(""===o||!o||""===r||!r||""===i||!i)throw M.NOT_INIT;if(!e||""===e)throw M.EMPTY_EVENT_NAME;H(i,(t=>d(void 0,null,(function*(){var o,l;const c=K(),u=N(),f=(new Date).valueOf(),h=null==f?void 0:f.toString(),g=null==(o=O(`${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 d(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 d(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})(),x=(()=>{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==(l=(()=>{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:l.toString(),_=(null==z?void 0:z.version)||"1.0.0",I=`${c}x${u}`,E=window.location.href,k=navigator.userAgent,A="UTC+"+(0-(new Date).getTimezoneOffset()/60),P=document.referrer,U=(()=>{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 D(o,32)})(),B={web:{browser_name:x,browser_version:C,current_time:f,device_type:w,ip:v||"",language:S,os:m,screen_resolution:I,sdk_version:_,url:E,user_agent:k,time_zone:A,referer:P,canvas:U}};let T=[];s&&s.constructor===Array&&(T=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: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==V?void 0:V.toString(),country:b,language:S,screen_width:c,screen_height:u,ip:v||""},custom_data:T,ext_data:B},M=yield p({url:"/v2/event",params:H}),{code:W,data:F,msg:Y}=M||{};if(200===W&&F){let e="";const t=F.link_data||[];F.blackbox&&""!==F.blackbox&&localStorage.setItem(R,F.blackbox||"");for(let n=0;n<t.length;n++)if("$campaign_reward_url"===t[n].key){e=decodeURIComponent(t[n].value||"");break}if(J&&""!==e)if(ae()){let t=ie(e);if(q&&""!==q){const e=encodeURIComponent(q);t=`${t}&loginUrl=${e}`}oe()||(sessionStorage.setItem($,t),sessionStorage.setItem(j,"1")),localStorage.setItem(L,e),setTimeout((()=>{window.location.href=t}),300)}else te({url:e});F.campaign_url=e,n({code:W,message:Y,data:F})}else n({code:W,message:Y})}))))}catch(e){n(e)}})),ie=e=>{if(!e||""===e)return"";const t=V||"",n=navigator.language,o=F||n||"",r=Math.floor((new Date).getTime()/1e3),i=localStorage.getItem(R),s="1.2.0",a=r%100,l="5CfUxPK7avjguYtG8yAE4ud6n9s774zVVdKwSxPryzaKHSpS4Lgju4M7sLumdLuQWXpHC6peBp2afBwEBbYnENGbZWfkZ6n4s52D3Xye59bfeK4gS9nfjehK".substring(a,a+12),c=`${t}${Y}${o}${r}${i}${s}web${W.appSecret}${l}`,d=D(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:Y},{name:"lg",value:o},{name:"time",value:r},{name:"blackbox",value:i},{name:"version",value:s},{name:"platform",value:"web"},{name:"token",value:d}])},se=e=>d(void 0,null,(function*(){const t="https://i1.branchcn.com/web/sdk/img/campBg.png",n={campaign_id:e,project_id:null==W?void 0:W.projectId},o=yield p({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)})),ae=()=>{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 le{}c(le,"init",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{appKey:t,appSecret:r,projectId:i,uid:s,lang:a,lv:l,loginUrl:c,jump:d=!0,dev:p=!1,clickEventCallback:f}=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&&(u="https://test.allapp.link")})(p),s&&(V=s),a&&(F=a),l&&(Y=l),c&&(q=c),f&&(X=f),J=d,W=e||{};let h=(new T).get(U);if(ne())return n(M.SUCCESS),void o(M.SUCCESS);null==h||" "===h||""===h?Q().then((e=>{n(e),o(e)})):ee().then((e=>{if(n(e),o(e),oe()&&ae()){const e=sessionStorage.getItem($);if(e&&" "!==e){let t=ie(e);if(sessionStorage.removeItem($),sessionStorage.removeItem(j),q&&""!==q){t=`${t}&loginUrl=${encodeURIComponent(q)}`}window.location.replace(t&&t)}}})),sessionStorage.setItem(B,"1")}catch(e){n(e),o(e)}})))),c(le,"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&&(V=t),n&&(Y=n)}else V=e;n(o),t&&t(o)}catch(e){n(r),t&&t(r)}})))),c(le,"install",Q),c(le,"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&&(V=t),r&&(V=r),re("register").then((e=>{if(ae()){const e=localStorage.getItem(L),t=sessionStorage.getItem(j);if(e&&"1"===t&&s){sessionStorage.removeItem(j);const t=ie(e);window.location.replace(t&&t)}}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(le,"open",ee),c(le,"customEvent",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{event:t,customData:r,backCamp:i}=e||{};if(!t||""===t)throw M.EMPTY_EVENT_NAME;re(t,{customData:r}).then((e=>{const t=localStorage.getItem(L),r=ie(t),s=l(a({},e),{campUrl:r});i&&r&&setTimeout((()=>{window.location.replace(r)}),1e3),n(s),o(s)}))}catch(e){n(e),o(e)}})))),c(le,"loadUrl",((e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=M||{},{url:i,newWindow:s=!1}=e||{};try{if(!W.appSecret||""===W.appSecret)throw M.LACK_APPSECRET;if(!i||""===i)throw M.INVALID_URL;let e=ie(i);if(q&&""!==q){e=`${e}&loginUrl=${encodeURIComponent(q)}`}localStorage.setItem(L,i),oe()||sessionStorage.setItem(j,"1"),!0===s||"true"===s?window.open(e,"_blank"):window.location.href=e,o(r),n(r),re("loadUrl")}catch(e){n(e),o(e)}})))),c(le,"webLoadUrl",te),c(le,"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(le,"createCampaignIcon",((e={},t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=M||{};try{const t=a(a({},{url:null,position:4,iconUrl:"",iconWidth:"50px",iconHeight:"50px",iframeWidth:"350px",iframeHeight:"700px",iconOffset:"10px",defaultOpen:!1,iconRotate:!0,left:"20px",top:"20px",right:"20px",bottom:"20px",clickEventCallback:null}),e),{position:i}=t;if([1,2,3,4].includes(i)||(t.position=4),!W.appSecret||""===W.appSecret)throw M.LACK_APPSECRET;if(!t.url||""===t.url)throw M.INVALID_URL;const s=document.querySelectorAll(".turbolinkCampaignIcon"),c=document.querySelectorAll(".turbolinkCampaignIframe");s.forEach((e=>e.remove())),c.forEach((e=>e.remove()));const d=document.createElement("div");switch(d.className="turbolinkCampaignIcon",d.style.position="fixed",d.style.zIndex="9999",t.position){case 1:d.style.left=t.left,d.style.top=t.top;break;case 2:d.style.right=t.right,d.style.top=t.top;break;case 3:d.style.left=t.left,d.style.bottom=t.bottom;break;case 4:d.style.right=t.right,d.style.bottom=t.bottom}const u=document.createElement("div");u.style.width=t.iconWidth,u.style.height=t.iconHeight,u.style.borderRadius="50%",u.style.cursor="pointer",u.style.zIndex="100001",u.style.transition=t.iconRotate?"transform 0.3s ease":"none",u.style.display="flex",u.style.alignItems="center",u.style.justifyContent="center",u.style.color="#000",u.style.fontSize="0";const p=document.createElement("img");p.src=t.iconUrl,p.style.width="100%",p.style.height="100%",p.style.objectFit="contain",u.appendChild(p),d.appendChild(u);const f=document.createElement("div");f.className="turbolinkCampaignIframe",f.style.zIndex="100000",f.style.position="fixed",f.style.width=t.iframeWidth,f.style.height=t.iframeHeight,f.style.backgroundColor="white",f.style.transition="all 0.4s ease, opacity 0.3s ease-in, opacity 0.6s ease-out",f.style.overflow="hidden",f.style.borderRadius="14px",f.style.boxShadow="0px 4px 8px 0px rgba(0, 0, 0, 0.14), 0px 4px 16px 0px rgba(0, 0, 0, 0.14), 0px 8px 24px 0px rgba(0, 0, 0, 0.30)",f.style.opacity=t.defaultOpen?"1":"0";const h=parseInt(t.iframeHeight)+100;switch(t.position){case 1:f.style.left=t.left,f.style.top=t.defaultOpen?parseInt(t.top)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${h}px`;break;case 2:f.style.right=t.right,f.style.top=t.defaultOpen?parseInt(t.top)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${h}px`;break;case 3:f.style.left=t.left,f.style.bottom=t.defaultOpen?parseInt(t.bottom)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${h}px`;break;case 4:f.style.right=t.right,f.style.bottom=t.defaultOpen?parseInt(t.bottom)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${h}px`}const g=document.createElement("iframe");g.style.width="100%",g.style.height="100%",g.style.border="none",f.appendChild(g),document.body.appendChild(f),G=t.defaultOpen,u.style.transform=G&&t.iconRotate?"rotate(180deg)":"rotate(0deg)";const m=e=>{const n=(null==e?void 0:e.data)||{};if(n){const o=(null==n?void 0:n.source)||"";if(o&&"turbolink"===o){const n=t.clickEventCallback||X;n&&n(e.data)}}};(t.clickEventCallback||X)&&(window.removeEventListener("message",m),window.addEventListener("message",m));const y=e=>{if(e&&(G=!G),u.style.transform=G&&t.iconRotate?"rotate(180deg)":"rotate(0deg)",G&&!Z&&!g.src){let e=ie(t.url);if(e=`${e}&webIframe=1&newSDK=1`,q&&""!==q){e=`${e}&loginUrl=${encodeURIComponent(q)}`}g.src=e,Z=!0}switch(t.position){case 1:case 2:f.style.top=G?parseInt(t.top)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${h}px`,f.style.opacity=G?"1":"0";break;case 3:case 4:f.style.bottom=G?parseInt(t.bottom)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${h}px`,f.style.opacity=G?"1":"0"}};u.addEventListener("click",(()=>{y(!0)})),t.defaultOpen&&y(),document.body.appendChild(d);const w={toggle:()=>{y(!0)},show:()=>{G||y(!0)},hide:()=>{G&&y(!0)},destroy:()=>{d.remove(),f.remove(),window.removeEventListener("message",m)}};n(l(a({},r),{controller:w})),o(l(a({},r),{controller:w}))}catch(e){n(e),o(e)}})))),c(le,"removeCampaignIcon",(e=>new Promise((t=>{const n=e||function(){},{SUCCESS:o}=M||{};try{const e=document.querySelectorAll(".turbolinkCampaignIcon"),r=document.querySelectorAll(".turbolinkCampaignIframe");e.forEach((e=>e.remove())),r.forEach((e=>e.remove())),G=!1,Z=!1,t(o),n(o)}catch(e){t(e),n(e)}})))),c(le,"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&&(V=r),i&&(V=i),re("login").then((e=>{if(ae()){const e=localStorage.getItem(L),t=sessionStorage.getItem(j);if(e&&"1"===t&&a){sessionStorage.removeItem(j);const t=ie(e);window.location.replace(t&&t)}}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(le,"logout",(e=>new Promise((t=>{const n=e||function(){};localStorage.removeItem(L),sessionStorage.removeItem(j),V=null;const{SUCCESS:o}=M||{};t(o),n(o),re("logout")})))),c(le,"getInitState",ne),c(le,"getLoginState",oe),c(le,"codeSearch",((e,t)=>new Promise((n=>{const o=t||function(){};try{if(!e||" "===e)throw M.LACK_CODE;re("code_search",{nativeMsg:e}).then((e=>{n(e),o(e)}))}catch(e){n(e),o(e)}}))));export{le 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},l=(e,o)=>t(e,n(o)),c=(e,t,n)=>(s(e,"symbol"!=typeof t?t+"":t,n),n),d=(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 u="https://www.allapp.link";const p=({url:e,method:t="POST",headers:n,params:o})=>new Promise((r=>{const i=a({"Content-Type":"application/json;charset=utf-8"},n);W.appKey&&(i.Authorization="Bearer "+W.appKey),fetch(u+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 h(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 m={exports:{}};var y={exports:{}};const w=g(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var v,b,S,x,C,_,I,E,k;function A(){return v||(v=1,y.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=w}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)}},l=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 l.init(t,e)}}),c=i.enc={},d=c.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 l.init(n,t/2)}},u=c.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 l.init(n,t)}},p=c.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 l.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),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*s,d=e.min(4*c,i);if(c){for(var u=0;u<c;u+=s)this._doProcessBlock(r,u);n=r.splice(0,c),o.sigBytes-=d}return new l.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)),y.exports;var e}const P=h(m.exports=(k=A(),S=(b=k).lib,x=S.WordArray,C=S.Hasher,_=b.algo,I=[],E=_.SHA1=C.extend({_doReset:function(){this._hash=new x.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],l=0;l<80;l++){if(l<16)I[l]=0|e[t+l];else{var c=I[l-3]^I[l-8]^I[l-14]^I[l-16];I[l]=c<<1|c>>>31}var d=(o<<5|o>>>27)+a+I[l];d+=l<20?1518500249+(r&i|~r&s):l<40?1859775393+(r^i^s):l<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=C.clone.call(this);return e._hash=this._hash.clone(),e}}),b.SHA1=C._createHelper(E),b.HmacSHA1=C._createHmacHelper(E),k.SHA1)),O="tb_cookie_obj",U="tb_randomId",L="tb_load_url",j="tb_load_source_url",$="tb_ascribe_to_url",R="tb_init_state",B="tb_blackbox";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 D=(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,l){return e=o(e,o(o(function(e,t,n){return e&t|~e&n}(t,r,i),s),l)),o(n(e,a),t)}function i(e,t,r,i,s,a,l){return e=o(e,o(o(function(e,t,n){return e&n|t&~n}(t,r,i),s),l)),o(n(e,a),t)}function s(e,t,r,i,s,a,l){return e=o(e,o(o(function(e,t,n){return e^t^n}(t,r,i),s),l)),o(n(e,a),t)}function a(e,t,r,i,s,a,l){return e=o(e,o(o(function(e,t,n){return t^(e|~n)}(t,r,i),s),l)),o(n(e,a),t)}function l(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 c,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,c=0;c<w.length;c+=16)d=h,u=g,p=m,f=y,h=r(h,g,m,y,w[c+0],7,3614090360),y=r(y,h,g,m,w[c+1],12,3905402710),m=r(m,y,h,g,w[c+2],17,606105819),g=r(g,m,y,h,w[c+3],22,3250441966),h=r(h,g,m,y,w[c+4],7,4118548399),y=r(y,h,g,m,w[c+5],12,1200080426),m=r(m,y,h,g,w[c+6],17,2821735955),g=r(g,m,y,h,w[c+7],22,4249261313),h=r(h,g,m,y,w[c+8],7,1770035416),y=r(y,h,g,m,w[c+9],12,2336552879),m=r(m,y,h,g,w[c+10],17,4294925233),g=r(g,m,y,h,w[c+11],22,2304563134),h=r(h,g,m,y,w[c+12],7,1804603682),y=r(y,h,g,m,w[c+13],12,4254626195),m=r(m,y,h,g,w[c+14],17,2792965006),h=i(h,g=r(g,m,y,h,w[c+15],22,1236535329),m,y,w[c+1],5,4129170786),y=i(y,h,g,m,w[c+6],9,3225465664),m=i(m,y,h,g,w[c+11],14,643717713),g=i(g,m,y,h,w[c+0],20,3921069994),h=i(h,g,m,y,w[c+5],5,3593408605),y=i(y,h,g,m,w[c+10],9,38016083),m=i(m,y,h,g,w[c+15],14,3634488961),g=i(g,m,y,h,w[c+4],20,3889429448),h=i(h,g,m,y,w[c+9],5,568446438),y=i(y,h,g,m,w[c+14],9,3275163606),m=i(m,y,h,g,w[c+3],14,4107603335),g=i(g,m,y,h,w[c+8],20,1163531501),h=i(h,g,m,y,w[c+13],5,2850285829),y=i(y,h,g,m,w[c+2],9,4243563512),m=i(m,y,h,g,w[c+7],14,1735328473),h=s(h,g=i(g,m,y,h,w[c+12],20,2368359562),m,y,w[c+5],4,4294588738),y=s(y,h,g,m,w[c+8],11,2272392833),m=s(m,y,h,g,w[c+11],16,1839030562),g=s(g,m,y,h,w[c+14],23,4259657740),h=s(h,g,m,y,w[c+1],4,2763975236),y=s(y,h,g,m,w[c+4],11,1272893353),m=s(m,y,h,g,w[c+7],16,4139469664),g=s(g,m,y,h,w[c+10],23,3200236656),h=s(h,g,m,y,w[c+13],4,681279174),y=s(y,h,g,m,w[c+0],11,3936430074),m=s(m,y,h,g,w[c+3],16,3572445317),g=s(g,m,y,h,w[c+6],23,76029189),h=s(h,g,m,y,w[c+9],4,3654602809),y=s(y,h,g,m,w[c+12],11,3873151461),m=s(m,y,h,g,w[c+15],16,530742520),h=a(h,g=s(g,m,y,h,w[c+2],23,3299628645),m,y,w[c+0],6,4096336452),y=a(y,h,g,m,w[c+7],10,1126891415),m=a(m,y,h,g,w[c+14],15,2878612391),g=a(g,m,y,h,w[c+5],21,4237533241),h=a(h,g,m,y,w[c+12],6,1700485571),y=a(y,h,g,m,w[c+3],10,2399980690),m=a(m,y,h,g,w[c+10],15,4293915773),g=a(g,m,y,h,w[c+1],21,2240044497),h=a(h,g,m,y,w[c+8],6,1873313359),y=a(y,h,g,m,w[c+15],10,4264355552),m=a(m,y,h,g,w[c+6],15,2734768916),g=a(g,m,y,h,w[c+13],21,1309151649),h=a(h,g,m,y,w[c+4],6,4149444226),y=a(y,h,g,m,w[c+11],10,3174756917),m=a(m,y,h,g,w[c+2],15,718787259),g=a(g,m,y,h,w[c+9],21,3951481745),h=o(h,d),g=o(g,u),m=o(m,p),y=o(y,f);return 32===t?(l(h)+l(g)+l(m)+l(y)).toLowerCase():(l(g)+l(m)).toLowerCase()},H=(e,t)=>d(void 0,null,(function*(){const n=t||function(){};try{const t=new T;let o=t.get(O);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(U);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(U,n)}return n}(32),i=navigator.language,s=K(),a=N(),l=yield p({url:"/ecl/bs/check",params:{bfp:o,language:i,screen_width:s,screen_height:a}}),{code:c,data:d}=l||{};200===c&&d&&(r[e]=d.cookie_id,t.set(O,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},N=()=>{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"}},z={name:"turbolink-ai",version:"1.2.8",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 W={appKey:"",appSecret:"",projectId:""},V="",F="",Y="",J=!0,q="",X=null,G=!1,Z=!1;const Q=()=>{return"turbolink"===(e="tbSource",new URLSearchParams(window.location.search).get(e));var e},ee=e=>new Promise((t=>{se("install").then((n=>{t(n),e&&e(n)}))})),te=e=>new Promise((t=>{se("open").then((n=>{t(n),e&&e(n)}))})),ne=(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:l,backgroundHeight:c=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(!W.appSecret||""===W.appSecret)throw M.LACK_APPSECRET;if(!s||""===s)throw M.INVALID_URL;m&&"function"==typeof m&&(X=m);const e=new URL(s),t=new URLSearchParams(e.search).get("l");let v=ae(s);if(v=`${v}&webIframe=1&newSDK=1`,w&&(v=`${v}&jpN=1`),q&&""!==q){v=`${v}&loginUrl=${encodeURIComponent(q)}`}const 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 x=document.createElement("div");x.style.minHeight="100%",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("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 _=document.createElement("iframe");_.id="turbolinkSdkPopupIframe",_.width=`${p}px`,_.height=`${f}px`,_.style.border="none",_.style.borderRadius=`${h}px`,_.style.overflow="hidden",_.style.position="relative",_.style.zIndex="10",_.src=v;const I=document.createElement("div"),E=document.createElement("img");let k=c;u&&(k=f*(k/i)),I.style.height=`${k}px`,_.onload=()=>{I.style.position="absolute",I.style.fontSize="0px",I.style.zIndex="6",E.id="turbolinkSdkBgImg",l&&""!==l?E.src=l:le(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 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),X&&(window.removeEventListener("message",oe),window.addEventListener("message",oe)),A.addEventListener("click",(()=>{S.remove(),y&&(document.body.style.overflow="visible"),X&&(X({type:"linkCloseListener",params:null}),window.removeEventListener("message",oe))})),C.appendChild(I),C.appendChild(_),C.appendChild(A),x.appendChild(C),S.appendChild(x),document.body.appendChild(S),y&&(document.body.style.overflow="hidden"),o(r),n(r)}catch(e){n(e),o(e)}})),oe=e=>{const t=(null==e?void 0:e.data)||{};if(t){const n=(null==t?void 0:t.source)||"";n&&"turbolink"===n&&X&&X(e.data)}},re=()=>sessionStorage.getItem(R),ie=()=>!(null===V||""===V||" "===V||void 0===V),se=(e,t)=>new Promise((n=>{try{const{appKey:o,appSecret:r,projectId:i}=W||{},{customData:s,nativeMsg:a=""}=t||{};if(""===o||!o||""===r||!r||""===i||!i)throw M.NOT_INIT;if(!e||""===e)throw M.EMPTY_EVENT_NAME;H(i,(t=>d(void 0,null,(function*(){var o,l;const c=K(),u=N(),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 d(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 d(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})(),x=(()=>{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==(l=(()=>{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:l.toString(),_=(null==z?void 0:z.version)||"1.0.0",I=`${c}x${u}`,E=window.location.href,k=navigator.userAgent,A="UTC+"+(0-(new Date).getTimezoneOffset()/60),O=document.referrer,U=(()=>{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 D(o,32)})(),R={web:{browser_name:x,browser_version:C,current_time:f,device_type:w,ip:v||"",language:S,os:m,screen_resolution:I,sdk_version:_,url:E,user_agent:k,time_zone:A,referer:O,canvas:U}};let T=[];s&&s.constructor===Array&&(T=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: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==V?void 0:V.toString(),country:b,language:S,screen_width:c,screen_height:u,ip:v||""},custom_data:T,ext_data:R},M=yield p({url:"/v2/event",params:H}),{code:W,data:F,msg:Y}=M||{};if(200===W&&F){let e="";const t=F.link_data||[];F.blackbox&&""!==F.blackbox&&localStorage.setItem(B,F.blackbox||"");for(let n=0;n<t.length;n++)if("$campaign_reward_url"===t[n].key){e=decodeURIComponent(t[n].value||"");break}if(J&&""!==e)if(ce()){let t=ae(e);if(q&&""!==q){const e=encodeURIComponent(q);t=`${t}&loginUrl=${e}`}ie()||(sessionStorage.setItem($,t),sessionStorage.setItem(j,"1")),localStorage.setItem(L,e),setTimeout((()=>{window.location.href=t}),300)}else ne({url:e});F.campaign_url=e,n({code:W,message:Y,data:F})}else n({code:W,message:Y})}))))}catch(e){n(e)}})),ae=e=>{if(!e||""===e)return"";const t=V||"",n=navigator.language,o=F||n||"",r=Math.floor((new Date).getTime()/1e3),i=localStorage.getItem(B),s="1.2.0",a=r%100,l="5CfUxPK7avjguYtG8yAE4ud6n9s774zVVdKwSxPryzaKHSpS4Lgju4M7sLumdLuQWXpHC6peBp2afBwEBbYnENGbZWfkZ6n4s52D3Xye59bfeK4gS9nfjehK".substring(a,a+12),c=`${t}${Y}${o}${r}${i}${s}web${W.appSecret}${l}`,d=D(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:Y},{name:"lg",value:o},{name:"time",value:r},{name:"blackbox",value:i},{name:"version",value:s},{name:"platform",value:"web"},{name:"token",value:d}])},le=e=>d(void 0,null,(function*(){const t="https://i1.branchcn.com/web/sdk/img/campBg.png",n={campaign_id:e,project_id:null==W?void 0:W.projectId},o=yield p({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)})),ce=()=>{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 de{}c(de,"init",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{appKey:t,appSecret:r,projectId:i,uid:s,lang:a,lv:l,loginUrl:c,jump:d=!0,dev:p=!1,clickEventCallback:f}=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&&(u="https://test.allapp.link")})(p),s&&(V=s),a&&(F=a),l&&(Y=l),c&&(q=c),f&&"function"==typeof f&&(X=f),J=d,W=e||{};let h=(new T).get(U);if(re())return n(M.SUCCESS),void o(M.SUCCESS);null==h||" "===h||""===h?ee().then((e=>{n(e),o(e)})):te().then((e=>{if(n(e),o(e),ie()&&ce()){const e=sessionStorage.getItem($);if(e&&" "!==e){let t=ae(e);if(sessionStorage.removeItem($),sessionStorage.removeItem(j),q&&""!==q){t=`${t}&loginUrl=${encodeURIComponent(q)}`}window.location.replace(t&&t)}}})),sessionStorage.setItem(R,"1")}catch(e){n(e),o(e)}})))),c(de,"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&&(V=t),n&&(Y=n)}else V=e;n(o),t&&t(o)}catch(e){n(r),t&&t(r)}})))),c(de,"install",ee),c(de,"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&&(V=t),r&&(V=r),se("register").then((e=>{if(ce()){const e=localStorage.getItem(L),t=sessionStorage.getItem(j);if(e&&"1"===t&&s&&Q()){sessionStorage.removeItem(j);const t=ae(e);window.location.replace(t&&t)}}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(de,"open",te),c(de,"customEvent",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{event:t,customData:r,backCamp:i}=e||{};if(!t||""===t)throw M.EMPTY_EVENT_NAME;se(t,{customData:r}).then((e=>{const t=localStorage.getItem(L),r=ae(t),s=a({},e);t&&(s.campUrl=t),ce()&&t&&!0===i&&Q()&&setTimeout((()=>{window.location.replace(r)}),1e3),n(s),o(s)}))}catch(e){n(e),o(e)}})))),c(de,"loadUrl",((e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=M||{},{url:i,newWindow:s=!1}=e||{};try{if(!W.appSecret||""===W.appSecret)throw M.LACK_APPSECRET;if(!i||""===i)throw M.INVALID_URL;let e=ae(i);if(q&&""!==q){e=`${e}&loginUrl=${encodeURIComponent(q)}`}localStorage.setItem(L,i),ie()||sessionStorage.setItem(j,"1"),!0===s||"true"===s?(e=`${e}&nw=1`,window.open(e,"_blank")):window.location.href=e,o(r),n(r),se("loadUrl")}catch(e){n(e),o(e)}})))),c(de,"webLoadUrl",ne),c(de,"closeWebUrl",(e=>new Promise((t=>{const n=e||function(){},{SUCCESS:o}=M||{};try{document.getElementById("turbolinkSdkPopup").remove(),document.body.style.overflow="visible",window.removeEventListener("message",oe),n(o),t(o)}catch(e){t(e),n(e)}})))),c(de,"createCampaignIcon",((e={},t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=M||{};try{const t=a(a({},{url:null,position:4,iconUrl:"",iconWidth:"50px",iconHeight:"50px",iframeWidth:"350px",iframeHeight:"700px",iconOffset:"10px",defaultOpen:!1,iconRotate:!0,left:"20px",top:"20px",right:"20px",bottom:"20px",clickEventCallback:null}),e),{position:i,clickEventCallback:s}=t;if([1,2,3,4].includes(i)||(t.position=4),!W.appSecret||""===W.appSecret)throw M.LACK_APPSECRET;if(!t.url||""===t.url)throw M.INVALID_URL;s&&"function"==typeof s&&(X=s);const c=document.querySelectorAll(".turbolinkCampaignIcon"),d=document.querySelectorAll(".turbolinkCampaignIframe");c.forEach((e=>e.remove())),d.forEach((e=>e.remove()));const u=document.createElement("div");switch(u.className="turbolinkCampaignIcon",u.style.position="fixed",u.style.zIndex="9999",t.position){case 1:u.style.left=t.left,u.style.top=t.top;break;case 2:u.style.right=t.right,u.style.top=t.top;break;case 3:u.style.left=t.left,u.style.bottom=t.bottom;break;case 4:u.style.right=t.right,u.style.bottom=t.bottom}const p=document.createElement("div");p.style.width=t.iconWidth,p.style.height=t.iconHeight,p.style.borderRadius="50%",p.style.cursor="pointer",p.style.zIndex="100001",p.style.transition=t.iconRotate?"transform 0.3s ease":"none",p.style.display="flex",p.style.alignItems="center",p.style.justifyContent="center",p.style.color="#000",p.style.fontSize="0";const f=document.createElement("img");f.src=t.iconUrl,f.style.width="100%",f.style.height="100%",f.style.objectFit="contain",p.appendChild(f),u.appendChild(p);const h=document.createElement("div");h.className="turbolinkCampaignIframe",h.style.zIndex="100000",h.style.position="fixed",h.style.width=t.iframeWidth,h.style.height=t.iframeHeight,h.style.backgroundColor="white",h.style.transition="all 0.4s ease, opacity 0.3s ease-in, opacity 0.6s ease-out",h.style.overflow="hidden",h.style.borderRadius="14px",h.style.boxShadow="0px 4px 8px 0px rgba(0, 0, 0, 0.14), 0px 4px 16px 0px rgba(0, 0, 0, 0.14), 0px 8px 24px 0px rgba(0, 0, 0, 0.30)",h.style.opacity=t.defaultOpen?"1":"0";const g=parseInt(t.iframeHeight)+100;switch(t.position){case 1:h.style.left=t.left,h.style.top=t.defaultOpen?parseInt(t.top)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${g}px`;break;case 2:h.style.right=t.right,h.style.top=t.defaultOpen?parseInt(t.top)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${g}px`;break;case 3:h.style.left=t.left,h.style.bottom=t.defaultOpen?parseInt(t.bottom)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${g}px`;break;case 4:h.style.right=t.right,h.style.bottom=t.defaultOpen?parseInt(t.bottom)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${g}px`}const m=document.createElement("iframe");m.style.width="100%",m.style.height="100%",m.style.border="none",h.appendChild(m),document.body.appendChild(h),G=t.defaultOpen,Z=!1,p.style.transform=G&&t.iconRotate?"rotate(180deg)":"rotate(0deg)",X&&(window.removeEventListener("message",oe),window.addEventListener("message",oe));const y=e=>{if(e&&(G=!G),p.style.transform=G&&t.iconRotate?"rotate(180deg)":"rotate(0deg)",G&&!Z&&!m.src){let e=ae(t.url);if(e=`${e}&webIframe=1&newSDK=1`,q&&""!==q){e=`${e}&loginUrl=${encodeURIComponent(q)}`}m.src=e,Z=!0}switch(t.position){case 1:case 2:h.style.top=G?parseInt(t.top)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${g}px`,h.style.opacity=G?"1":"0";break;case 3:case 4:h.style.bottom=G?parseInt(t.bottom)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${g}px`,h.style.opacity=G?"1":"0"}};p.addEventListener("click",(()=>{y(!0)})),t.defaultOpen&&y(),document.body.appendChild(u);const w={toggle:()=>{y(!0)},show:()=>{G||y(!0)},hide:()=>{G&&y(!0)},destroy:()=>{u.remove(),h.remove(),window.removeEventListener("message",oe)}};n(l(a({},r),{controller:w})),o(l(a({},r),{controller:w}))}catch(e){n(e),o(e)}})))),c(de,"removeCampaignIcon",(e=>new Promise((t=>{const n=e||function(){},{SUCCESS:o}=M||{};try{const e=document.querySelectorAll(".turbolinkCampaignIcon"),r=document.querySelectorAll(".turbolinkCampaignIframe");e.forEach((e=>e.remove())),r.forEach((e=>e.remove())),window.removeEventListener("message",oe),G=!1,Z=!1,t(o),n(o)}catch(e){t(e),n(e)}})))),c(de,"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&&(V=r),i&&(V=i),se("login").then((e=>{if(ce()){const e=localStorage.getItem(L),t=sessionStorage.getItem(j);if(e&&"1"===t&&a&&Q()){sessionStorage.removeItem(j);const t=ae(e);window.location.replace(t&&t)}}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(de,"logout",(e=>new Promise((t=>{const n=e||function(){};localStorage.removeItem(L),sessionStorage.removeItem(j),V=null;const{SUCCESS:o}=M||{};t(o),n(o),se("logout")})))),c(de,"getInitState",re),c(de,"getLoginState",ie),c(de,"codeSearch",((e,t)=>new Promise((n=>{const o=t||function(){};try{if(!e||" "===e)throw M.LACK_CODE;se("code_search",{nativeMsg:e}).then((e=>{n(e),o(e)}))}catch(e){n(e),o(e)}}))));export{de 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},l=(e,o)=>t(e,n(o)),c=(e,t,n)=>(s(e,"symbol"!=typeof t?t+"":t,n),n),d=(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 u="https://www.allapp.link";const p=({url:e,method:t="POST",headers:n,params:o})=>new Promise((r=>{const i=a({"Content-Type":"application/json;charset=utf-8"},n);W.appKey&&(i.Authorization="Bearer "+W.appKey),fetch(u+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 h={exports:{}};var g={exports:{}};const m=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 y,w,v,b,S,x,C,_,I;function E(){return y||(y=1,g.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=m}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)}},l=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 l.init(t,e)}}),c=i.enc={},d=c.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 l.init(n,t/2)}},u=c.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 l.init(n,t)}},p=c.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 l.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),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*s,d=e.min(4*c,i);if(c){for(var u=0;u<c;u+=s)this._doProcessBlock(r,u);n=r.splice(0,c),o.sigBytes-=d}return new l.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)),g.exports;var e}h.exports=(I=E(),v=(w=I).lib,b=v.WordArray,S=v.Hasher,x=w.algo,C=[],_=x.SHA1=S.extend({_doReset:function(){this._hash=new b.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],l=0;l<80;l++){if(l<16)C[l]=0|e[t+l];else{var c=C[l-3]^C[l-8]^C[l-14]^C[l-16];C[l]=c<<1|c>>>31}var d=(o<<5|o>>>27)+a+C[l];d+=l<20?1518500249+(r&i|~r&s):l<40?1859775393+(r^i^s):l<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}}),w.SHA1=S._createHelper(_),w.HmacSHA1=S._createHmacHelper(_),I.SHA1);const k=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(h.exports),A="tb_cookie_obj",P="tb_randomId",O="tb_load_url",U="tb_load_source_url",L="tb_ascribe_to_url",j="tb_init_state",$="tb_blackbox";class R{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,l){return e=o(e,o(o(function(e,t,n){return e&t|~e&n}(t,r,i),s),l)),o(n(e,a),t)}function i(e,t,r,i,s,a,l){return e=o(e,o(o(function(e,t,n){return e&n|t&~n}(t,r,i),s),l)),o(n(e,a),t)}function s(e,t,r,i,s,a,l){return e=o(e,o(o(function(e,t,n){return e^t^n}(t,r,i),s),l)),o(n(e,a),t)}function a(e,t,r,i,s,a,l){return e=o(e,o(o(function(e,t,n){return t^(e|~n)}(t,r,i),s),l)),o(n(e,a),t)}function l(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 c,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,c=0;c<w.length;c+=16)d=h,u=g,p=m,f=y,h=r(h,g,m,y,w[c+0],7,3614090360),y=r(y,h,g,m,w[c+1],12,3905402710),m=r(m,y,h,g,w[c+2],17,606105819),g=r(g,m,y,h,w[c+3],22,3250441966),h=r(h,g,m,y,w[c+4],7,4118548399),y=r(y,h,g,m,w[c+5],12,1200080426),m=r(m,y,h,g,w[c+6],17,2821735955),g=r(g,m,y,h,w[c+7],22,4249261313),h=r(h,g,m,y,w[c+8],7,1770035416),y=r(y,h,g,m,w[c+9],12,2336552879),m=r(m,y,h,g,w[c+10],17,4294925233),g=r(g,m,y,h,w[c+11],22,2304563134),h=r(h,g,m,y,w[c+12],7,1804603682),y=r(y,h,g,m,w[c+13],12,4254626195),m=r(m,y,h,g,w[c+14],17,2792965006),h=i(h,g=r(g,m,y,h,w[c+15],22,1236535329),m,y,w[c+1],5,4129170786),y=i(y,h,g,m,w[c+6],9,3225465664),m=i(m,y,h,g,w[c+11],14,643717713),g=i(g,m,y,h,w[c+0],20,3921069994),h=i(h,g,m,y,w[c+5],5,3593408605),y=i(y,h,g,m,w[c+10],9,38016083),m=i(m,y,h,g,w[c+15],14,3634488961),g=i(g,m,y,h,w[c+4],20,3889429448),h=i(h,g,m,y,w[c+9],5,568446438),y=i(y,h,g,m,w[c+14],9,3275163606),m=i(m,y,h,g,w[c+3],14,4107603335),g=i(g,m,y,h,w[c+8],20,1163531501),h=i(h,g,m,y,w[c+13],5,2850285829),y=i(y,h,g,m,w[c+2],9,4243563512),m=i(m,y,h,g,w[c+7],14,1735328473),h=s(h,g=i(g,m,y,h,w[c+12],20,2368359562),m,y,w[c+5],4,4294588738),y=s(y,h,g,m,w[c+8],11,2272392833),m=s(m,y,h,g,w[c+11],16,1839030562),g=s(g,m,y,h,w[c+14],23,4259657740),h=s(h,g,m,y,w[c+1],4,2763975236),y=s(y,h,g,m,w[c+4],11,1272893353),m=s(m,y,h,g,w[c+7],16,4139469664),g=s(g,m,y,h,w[c+10],23,3200236656),h=s(h,g,m,y,w[c+13],4,681279174),y=s(y,h,g,m,w[c+0],11,3936430074),m=s(m,y,h,g,w[c+3],16,3572445317),g=s(g,m,y,h,w[c+6],23,76029189),h=s(h,g,m,y,w[c+9],4,3654602809),y=s(y,h,g,m,w[c+12],11,3873151461),m=s(m,y,h,g,w[c+15],16,530742520),h=a(h,g=s(g,m,y,h,w[c+2],23,3299628645),m,y,w[c+0],6,4096336452),y=a(y,h,g,m,w[c+7],10,1126891415),m=a(m,y,h,g,w[c+14],15,2878612391),g=a(g,m,y,h,w[c+5],21,4237533241),h=a(h,g,m,y,w[c+12],6,1700485571),y=a(y,h,g,m,w[c+3],10,2399980690),m=a(m,y,h,g,w[c+10],15,4293915773),g=a(g,m,y,h,w[c+1],21,2240044497),h=a(h,g,m,y,w[c+8],6,1873313359),y=a(y,h,g,m,w[c+15],10,4264355552),m=a(m,y,h,g,w[c+6],15,2734768916),g=a(g,m,y,h,w[c+13],21,1309151649),h=a(h,g,m,y,w[c+4],6,4149444226),y=a(y,h,g,m,w[c+11],10,3174756917),m=a(m,y,h,g,w[c+2],15,718787259),g=a(g,m,y,h,w[c+9],21,3951481745),h=o(h,d),g=o(g,u),m=o(m,p),y=o(y,f);return 32===t?(l(h)+l(g)+l(m)+l(y)).toLowerCase():(l(g)+l(m)).toLowerCase()},B=(e,t)=>d(this,null,(function*(){const n=t||function(){};try{const t=new R;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 R(!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=K(),a=N(),l=yield p({url:"/ecl/bs/check",params:{bfp:o,language:i,screen_width:s,screen_height:a}}),{code:c,data:d}=l||{};200===c&&d&&(r[e]=d.cookie_id,t.set(A,JSON.stringify(r))),n(d.cookie_id)}}catch(e){n("1")}}));const D=()=>d(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})),H=()=>d(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},N=()=>{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"}},z={name:"turbolink-ai",version:"1.2.8",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 W={appKey:"",appSecret:"",projectId:""},V="",F="",Y="",J=!0,q="",X=null,G=!1,Z=!1;const Q=()=>"turbolink"===(e=>new URLSearchParams(window.location.search).get(e))("tbSource"),ee=e=>new Promise((t=>{se("install").then((n=>{t(n),e&&e(n)}))})),te=e=>new Promise((t=>{se("open").then((n=>{t(n),e&&e(n)}))})),ne=(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:l,backgroundHeight:c=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(!W.appSecret||""===W.appSecret)throw M.LACK_APPSECRET;if(!s||""===s)throw M.INVALID_URL;m&&"function"==typeof m&&(X=m);const e=new URL(s),t=new URLSearchParams(e.search).get("l");let v=ae(s);if(v=`${v}&webIframe=1&newSDK=1`,w&&(v=`${v}&jpN=1`),q&&""!==q){v=`${v}&loginUrl=${encodeURIComponent(q)}`}const 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 x=document.createElement("div");x.style.minHeight="100%",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("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 _=document.createElement("iframe");_.id="turbolinkSdkPopupIframe",_.width=`${p}px`,_.height=`${f}px`,_.style.border="none",_.style.borderRadius=`${h}px`,_.style.overflow="hidden",_.style.position="relative",_.style.zIndex="10",_.src=v;const I=document.createElement("div"),E=document.createElement("img");let k=c;u&&(k=f*(k/i)),I.style.height=`${k}px`,_.onload=()=>{I.style.position="absolute",I.style.fontSize="0px",I.style.zIndex="6",E.id="turbolinkSdkBgImg",l&&""!==l?E.src=l:le(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 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),X&&(window.removeEventListener("message",oe),window.addEventListener("message",oe)),A.addEventListener("click",(()=>{S.remove(),y&&(document.body.style.overflow="visible"),X&&(X({type:"linkCloseListener",params:null}),window.removeEventListener("message",oe))})),C.appendChild(I),C.appendChild(_),C.appendChild(A),x.appendChild(C),S.appendChild(x),document.body.appendChild(S),y&&(document.body.style.overflow="hidden"),o(r),n(r)}catch(e){n(e),o(e)}})),oe=e=>{const t=(null==e?void 0:e.data)||{};if(t){const n=(null==t?void 0:t.source)||"";n&&"turbolink"===n&&X&&X(e.data)}},re=()=>sessionStorage.getItem(j),ie=()=>!(null===V||""===V||" "===V||void 0===V),se=(e,t)=>new Promise((n=>{try{const{appKey:o,appSecret:r,projectId:i}=W||{},{customData:s,nativeMsg:a=""}=t||{};if(""===o||!o||""===r||!r||""===i||!i)throw M.NOT_INIT;if(!e||""===e)throw M.EMPTY_EVENT_NAME;B(i,(t=>d(this,null,(function*(){var o,l;const c=K(),d=N(),u=(new Date).valueOf(),f=null==u?void 0:u.toString(),h=null==(o=k(`${i}_${f}_${u}_${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 D(),y=yield H(),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"})(),x=null==(l=(()=>{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:l.toString(),C=(null==z?void 0:z.version)||"1.0.0",_=`${c}x${d}`,I=window.location.href,E=navigator.userAgent,A="UTC+"+(0-(new Date).getTimezoneOffset()/60),P=document.referrer,j=(()=>{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)})(),R={web:{browser_name:S,browser_version:x,current_time:u,device_type:y,ip:w||"",language:b,os:g,screen_resolution:_,sdk_version:C,url:I,user_agent:E,time_zone:A,referer:P,canvas:j}};let B=[];s&&s.constructor===Array&&(B=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 M={project:i,request_id:f,timestamp:u,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:c,screen_height:d,ip:w||""},custom_data:B,ext_data:R},W=yield p({url:"/v2/event",params:M}),{code:F,data:Y,msg:X}=W||{};if(200===F&&Y){let e="";const t=Y.link_data||[];Y.blackbox&&""!==Y.blackbox&&localStorage.setItem($,Y.blackbox||"");for(let n=0;n<t.length;n++)if("$campaign_reward_url"===t[n].key){e=decodeURIComponent(t[n].value||"");break}if(J&&""!==e)if(ce()){let t=ae(e);if(q&&""!==q){const e=encodeURIComponent(q);t=`${t}&loginUrl=${e}`}ie()||(sessionStorage.setItem(L,t),sessionStorage.setItem(U,"1")),localStorage.setItem(O,e),setTimeout((()=>{window.location.href=t}),300)}else ne({url:e});Y.campaign_url=e,n({code:F,message:X,data:Y})}else n({code:F,message:X})}))))}catch(e){n(e)}})),ae=e=>{if(!e||""===e)return"";const t=V||"",n=navigator.language,o=F||n||"",r=Math.floor((new Date).getTime()/1e3),i=localStorage.getItem($),s="1.2.0",a=r%100,l="5CfUxPK7avjguYtG8yAE4ud6n9s774zVVdKwSxPryzaKHSpS4Lgju4M7sLumdLuQWXpHC6peBp2afBwEBbYnENGbZWfkZ6n4s52D3Xye59bfeK4gS9nfjehK".substring(a,a+12),c=`${t}${Y}${o}${r}${i}${s}web${W.appSecret}${l}`,d=T(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:Y},{name:"lg",value:o},{name:"time",value:r},{name:"blackbox",value:i},{name:"version",value:s},{name:"platform",value:"web"},{name:"token",value:d}])},le=e=>d(this,null,(function*(){const t="https://i1.branchcn.com/web/sdk/img/campBg.png",n={campaign_id:e,project_id:null==W?void 0:W.projectId},o=yield p({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)})),ce=()=>{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 de{}return c(de,"init",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{appKey:t,appSecret:r,projectId:i,uid:s,lang:a,lv:l,loginUrl:c,jump:d=!0,dev:p=!1,clickEventCallback:f}=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&&(u="https://test.allapp.link")})(p),s&&(V=s),a&&(F=a),l&&(Y=l),c&&(q=c),f&&"function"==typeof f&&(X=f),J=d,W=e||{};let h=(new R).get(P);if(re())return n(M.SUCCESS),void o(M.SUCCESS);null==h||" "===h||""===h?ee().then((e=>{n(e),o(e)})):te().then((e=>{if(n(e),o(e),ie()&&ce()){const e=sessionStorage.getItem(L);if(e&&" "!==e){let t=ae(e);if(sessionStorage.removeItem(L),sessionStorage.removeItem(U),q&&""!==q){t=`${t}&loginUrl=${encodeURIComponent(q)}`}window.location.replace(t&&t)}}})),sessionStorage.setItem(j,"1")}catch(e){n(e),o(e)}})))),c(de,"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&&(V=t),n&&(Y=n)}else V=e;n(o),t&&t(o)}catch(e){n(r),t&&t(r)}})))),c(de,"install",ee),c(de,"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&&(V=t),r&&(V=r),se("register").then((e=>{if(ce()){const e=localStorage.getItem(O),t=sessionStorage.getItem(U);if(e&&"1"===t&&s&&Q()){sessionStorage.removeItem(U);const t=ae(e);window.location.replace(t&&t)}}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(de,"open",te),c(de,"customEvent",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{event:t,customData:r,backCamp:i}=e||{};if(!t||""===t)throw M.EMPTY_EVENT_NAME;se(t,{customData:r}).then((e=>{const t=localStorage.getItem(O),r=ae(t),s=a({},e);t&&(s.campUrl=t),ce()&&t&&!0===i&&Q()&&setTimeout((()=>{window.location.replace(r)}),1e3),n(s),o(s)}))}catch(e){n(e),o(e)}})))),c(de,"loadUrl",((e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=M||{},{url:i,newWindow:s=!1}=e||{};try{if(!W.appSecret||""===W.appSecret)throw M.LACK_APPSECRET;if(!i||""===i)throw M.INVALID_URL;let e=ae(i);if(q&&""!==q){e=`${e}&loginUrl=${encodeURIComponent(q)}`}localStorage.setItem(O,i),ie()||sessionStorage.setItem(U,"1"),!0===s||"true"===s?(e=`${e}&nw=1`,window.open(e,"_blank")):window.location.href=e,o(r),n(r),se("loadUrl")}catch(e){n(e),o(e)}})))),c(de,"webLoadUrl",ne),c(de,"closeWebUrl",(e=>new Promise((t=>{const n=e||function(){},{SUCCESS:o}=M||{};try{document.getElementById("turbolinkSdkPopup").remove(),document.body.style.overflow="visible",window.removeEventListener("message",oe),n(o),t(o)}catch(e){t(e),n(e)}})))),c(de,"createCampaignIcon",((e={},t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=M||{};try{const t=a(a({},{url:null,position:4,iconUrl:"",iconWidth:"50px",iconHeight:"50px",iframeWidth:"350px",iframeHeight:"700px",iconOffset:"10px",defaultOpen:!1,iconRotate:!0,left:"20px",top:"20px",right:"20px",bottom:"20px",clickEventCallback:null}),e),{position:i,clickEventCallback:s}=t;if([1,2,3,4].includes(i)||(t.position=4),!W.appSecret||""===W.appSecret)throw M.LACK_APPSECRET;if(!t.url||""===t.url)throw M.INVALID_URL;s&&"function"==typeof s&&(X=s);const c=document.querySelectorAll(".turbolinkCampaignIcon"),d=document.querySelectorAll(".turbolinkCampaignIframe");c.forEach((e=>e.remove())),d.forEach((e=>e.remove()));const u=document.createElement("div");switch(u.className="turbolinkCampaignIcon",u.style.position="fixed",u.style.zIndex="9999",t.position){case 1:u.style.left=t.left,u.style.top=t.top;break;case 2:u.style.right=t.right,u.style.top=t.top;break;case 3:u.style.left=t.left,u.style.bottom=t.bottom;break;case 4:u.style.right=t.right,u.style.bottom=t.bottom}const p=document.createElement("div");p.style.width=t.iconWidth,p.style.height=t.iconHeight,p.style.borderRadius="50%",p.style.cursor="pointer",p.style.zIndex="100001",p.style.transition=t.iconRotate?"transform 0.3s ease":"none",p.style.display="flex",p.style.alignItems="center",p.style.justifyContent="center",p.style.color="#000",p.style.fontSize="0";const f=document.createElement("img");f.src=t.iconUrl,f.style.width="100%",f.style.height="100%",f.style.objectFit="contain",p.appendChild(f),u.appendChild(p);const h=document.createElement("div");h.className="turbolinkCampaignIframe",h.style.zIndex="100000",h.style.position="fixed",h.style.width=t.iframeWidth,h.style.height=t.iframeHeight,h.style.backgroundColor="white",h.style.transition="all 0.4s ease, opacity 0.3s ease-in, opacity 0.6s ease-out",h.style.overflow="hidden",h.style.borderRadius="14px",h.style.boxShadow="0px 4px 8px 0px rgba(0, 0, 0, 0.14), 0px 4px 16px 0px rgba(0, 0, 0, 0.14), 0px 8px 24px 0px rgba(0, 0, 0, 0.30)",h.style.opacity=t.defaultOpen?"1":"0";const g=parseInt(t.iframeHeight)+100;switch(t.position){case 1:h.style.left=t.left,h.style.top=t.defaultOpen?parseInt(t.top)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${g}px`;break;case 2:h.style.right=t.right,h.style.top=t.defaultOpen?parseInt(t.top)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${g}px`;break;case 3:h.style.left=t.left,h.style.bottom=t.defaultOpen?parseInt(t.bottom)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${g}px`;break;case 4:h.style.right=t.right,h.style.bottom=t.defaultOpen?parseInt(t.bottom)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${g}px`}const m=document.createElement("iframe");m.style.width="100%",m.style.height="100%",m.style.border="none",h.appendChild(m),document.body.appendChild(h),G=t.defaultOpen,Z=!1,p.style.transform=G&&t.iconRotate?"rotate(180deg)":"rotate(0deg)",X&&(window.removeEventListener("message",oe),window.addEventListener("message",oe));const y=e=>{if(e&&(G=!G),p.style.transform=G&&t.iconRotate?"rotate(180deg)":"rotate(0deg)",G&&!Z&&!m.src){let e=ae(t.url);if(e=`${e}&webIframe=1&newSDK=1`,q&&""!==q){e=`${e}&loginUrl=${encodeURIComponent(q)}`}m.src=e,Z=!0}switch(t.position){case 1:case 2:h.style.top=G?parseInt(t.top)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${g}px`,h.style.opacity=G?"1":"0";break;case 3:case 4:h.style.bottom=G?parseInt(t.bottom)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${g}px`,h.style.opacity=G?"1":"0"}};p.addEventListener("click",(()=>{y(!0)})),t.defaultOpen&&y(),document.body.appendChild(u);const w={toggle:()=>{y(!0)},show:()=>{G||y(!0)},hide:()=>{G&&y(!0)},destroy:()=>{u.remove(),h.remove(),window.removeEventListener("message",oe)}};n(l(a({},r),{controller:w})),o(l(a({},r),{controller:w}))}catch(e){n(e),o(e)}})))),c(de,"removeCampaignIcon",(e=>new Promise((t=>{const n=e||function(){},{SUCCESS:o}=M||{};try{const e=document.querySelectorAll(".turbolinkCampaignIcon"),r=document.querySelectorAll(".turbolinkCampaignIframe");e.forEach((e=>e.remove())),r.forEach((e=>e.remove())),window.removeEventListener("message",oe),G=!1,Z=!1,t(o),n(o)}catch(e){t(e),n(e)}})))),c(de,"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&&(V=r),i&&(V=i),se("login").then((e=>{if(ce()){const e=localStorage.getItem(O),t=sessionStorage.getItem(U);if(e&&"1"===t&&a&&Q()){sessionStorage.removeItem(U);const t=ae(e);window.location.replace(t&&t)}}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(de,"logout",(e=>new Promise((t=>{const n=e||function(){};localStorage.removeItem(O),sessionStorage.removeItem(U),V=null;const{SUCCESS:o}=M||{};t(o),n(o),se("logout")})))),c(de,"getInitState",re),c(de,"getLoginState",ie),c(de,"codeSearch",((e,t)=>new Promise((n=>{const o=t||function(){};try{if(!e||" "===e)throw M.LACK_CODE;se("code_search",{nativeMsg:e}).then((e=>{n(e),o(e)}))}catch(e){n(e),o(e)}})))),de}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turbolink-ai",
3
- "version": "1.2.6",
3
+ "version": "1.2.8",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",
@@ -1 +0,0 @@
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},l=(e,o)=>t(e,n(o)),c=(e,t,n)=>(s(e,"symbol"!=typeof t?t+"":t,n),n),d=(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 u="https://www.allapp.link";const p=({url:e,method:t="POST",headers:n,params:o})=>new Promise((r=>{const i=a({"Content-Type":"application/json;charset=utf-8"},n);W.appKey&&(i.Authorization="Bearer "+W.appKey),fetch(u+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 h={exports:{}};var g={exports:{}};const m=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 y,w,v,b,x,S,C,_,I;function E(){return y||(y=1,g.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=m}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)}},l=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 l.init(t,e)}}),c=i.enc={},d=c.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 l.init(n,t/2)}},u=c.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 l.init(n,t)}},p=c.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 l.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),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*s,d=e.min(4*c,i);if(c){for(var u=0;u<c;u+=s)this._doProcessBlock(r,u);n=r.splice(0,c),o.sigBytes-=d}return new l.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)),g.exports;var e}h.exports=(I=E(),v=(w=I).lib,b=v.WordArray,x=v.Hasher,S=w.algo,C=[],_=S.SHA1=x.extend({_doReset:function(){this._hash=new b.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],l=0;l<80;l++){if(l<16)C[l]=0|e[t+l];else{var c=C[l-3]^C[l-8]^C[l-14]^C[l-16];C[l]=c<<1|c>>>31}var d=(o<<5|o>>>27)+a+C[l];d+=l<20?1518500249+(r&i|~r&s):l<40?1859775393+(r^i^s):l<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=x.clone.call(this);return e._hash=this._hash.clone(),e}}),w.SHA1=x._createHelper(_),w.HmacSHA1=x._createHmacHelper(_),I.SHA1);const k=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(h.exports),A="tb_cookie_obj",O="tb_randomId",P="tb_load_url",U="tb_load_source_url",L="tb_ascribe_to_url",j="tb_init_state",$="tb_blackbox";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 B=(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,l){return e=o(e,o(o(function(e,t,n){return e&t|~e&n}(t,r,i),s),l)),o(n(e,a),t)}function i(e,t,r,i,s,a,l){return e=o(e,o(o(function(e,t,n){return e&n|t&~n}(t,r,i),s),l)),o(n(e,a),t)}function s(e,t,r,i,s,a,l){return e=o(e,o(o(function(e,t,n){return e^t^n}(t,r,i),s),l)),o(n(e,a),t)}function a(e,t,r,i,s,a,l){return e=o(e,o(o(function(e,t,n){return t^(e|~n)}(t,r,i),s),l)),o(n(e,a),t)}function l(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 c,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,c=0;c<w.length;c+=16)d=h,u=g,p=m,f=y,h=r(h,g,m,y,w[c+0],7,3614090360),y=r(y,h,g,m,w[c+1],12,3905402710),m=r(m,y,h,g,w[c+2],17,606105819),g=r(g,m,y,h,w[c+3],22,3250441966),h=r(h,g,m,y,w[c+4],7,4118548399),y=r(y,h,g,m,w[c+5],12,1200080426),m=r(m,y,h,g,w[c+6],17,2821735955),g=r(g,m,y,h,w[c+7],22,4249261313),h=r(h,g,m,y,w[c+8],7,1770035416),y=r(y,h,g,m,w[c+9],12,2336552879),m=r(m,y,h,g,w[c+10],17,4294925233),g=r(g,m,y,h,w[c+11],22,2304563134),h=r(h,g,m,y,w[c+12],7,1804603682),y=r(y,h,g,m,w[c+13],12,4254626195),m=r(m,y,h,g,w[c+14],17,2792965006),h=i(h,g=r(g,m,y,h,w[c+15],22,1236535329),m,y,w[c+1],5,4129170786),y=i(y,h,g,m,w[c+6],9,3225465664),m=i(m,y,h,g,w[c+11],14,643717713),g=i(g,m,y,h,w[c+0],20,3921069994),h=i(h,g,m,y,w[c+5],5,3593408605),y=i(y,h,g,m,w[c+10],9,38016083),m=i(m,y,h,g,w[c+15],14,3634488961),g=i(g,m,y,h,w[c+4],20,3889429448),h=i(h,g,m,y,w[c+9],5,568446438),y=i(y,h,g,m,w[c+14],9,3275163606),m=i(m,y,h,g,w[c+3],14,4107603335),g=i(g,m,y,h,w[c+8],20,1163531501),h=i(h,g,m,y,w[c+13],5,2850285829),y=i(y,h,g,m,w[c+2],9,4243563512),m=i(m,y,h,g,w[c+7],14,1735328473),h=s(h,g=i(g,m,y,h,w[c+12],20,2368359562),m,y,w[c+5],4,4294588738),y=s(y,h,g,m,w[c+8],11,2272392833),m=s(m,y,h,g,w[c+11],16,1839030562),g=s(g,m,y,h,w[c+14],23,4259657740),h=s(h,g,m,y,w[c+1],4,2763975236),y=s(y,h,g,m,w[c+4],11,1272893353),m=s(m,y,h,g,w[c+7],16,4139469664),g=s(g,m,y,h,w[c+10],23,3200236656),h=s(h,g,m,y,w[c+13],4,681279174),y=s(y,h,g,m,w[c+0],11,3936430074),m=s(m,y,h,g,w[c+3],16,3572445317),g=s(g,m,y,h,w[c+6],23,76029189),h=s(h,g,m,y,w[c+9],4,3654602809),y=s(y,h,g,m,w[c+12],11,3873151461),m=s(m,y,h,g,w[c+15],16,530742520),h=a(h,g=s(g,m,y,h,w[c+2],23,3299628645),m,y,w[c+0],6,4096336452),y=a(y,h,g,m,w[c+7],10,1126891415),m=a(m,y,h,g,w[c+14],15,2878612391),g=a(g,m,y,h,w[c+5],21,4237533241),h=a(h,g,m,y,w[c+12],6,1700485571),y=a(y,h,g,m,w[c+3],10,2399980690),m=a(m,y,h,g,w[c+10],15,4293915773),g=a(g,m,y,h,w[c+1],21,2240044497),h=a(h,g,m,y,w[c+8],6,1873313359),y=a(y,h,g,m,w[c+15],10,4264355552),m=a(m,y,h,g,w[c+6],15,2734768916),g=a(g,m,y,h,w[c+13],21,1309151649),h=a(h,g,m,y,w[c+4],6,4149444226),y=a(y,h,g,m,w[c+11],10,3174756917),m=a(m,y,h,g,w[c+2],15,718787259),g=a(g,m,y,h,w[c+9],21,3951481745),h=o(h,d),g=o(g,u),m=o(m,p),y=o(y,f);return 32===t?(l(h)+l(g)+l(m)+l(y)).toLowerCase():(l(g)+l(m)).toLowerCase()},R=(e,t)=>d(this,null,(function*(){const n=t||function(){};try{const t=new T;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 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=K(),a=N(),l=yield p({url:"/ecl/bs/check",params:{bfp:o,language:i,screen_width:s,screen_height:a}}),{code:c,data:d}=l||{};200===c&&d&&(r[e]=d.cookie_id,t.set(A,JSON.stringify(r))),n(d.cookie_id)}}catch(e){n("1")}}));const D=()=>d(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})),H=()=>d(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},N=()=>{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"}},z={name:"turbolink-ai",version:"1.2.6",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 W={appKey:"",appSecret:"",projectId:""},V="",F="",Y="",J=!0,q="",X=null,G=!1,Z=!1;const Q=e=>new Promise((t=>{re("install").then((n=>{t(n),e&&e(n)}))})),ee=e=>new Promise((t=>{re("open").then((n=>{t(n),e&&e(n)}))})),te=(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:l,backgroundHeight:c=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(!W.appSecret||""===W.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=ie(s);if(v=`${v}&webIframe=1&newSDK=1`,w&&(v=`${v}&jpN=1`),q&&""!==q){v=`${v}&loginUrl=${encodeURIComponent(q)}`}let b=document.getElementById("turbolinkSdkPopup");b&&b.remove();const x=document.createElement("div");x.id="turbolinkSdkPopup",x.style.position="fixed",x.style.zIndex=g,x.style.left="0",x.style.top="0",x.style.right="0",x.style.bottom="0",x.style.width="100%",x.style.height="100%",x.style.overflowX="hidden",x.style.overflowY="auto",x.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 _=document.createElement("iframe");_.id="turbolinkSdkPopupIframe",_.width=`${p}px`,_.height=`${f}px`,_.style.border="none",_.style.borderRadius=`${h}px`,_.style.overflow="hidden",_.style.position="relative",_.style.zIndex="10",_.src=v;const I=document.createElement("div"),E=document.createElement("img");let k=c;u&&(k=f*(k/i)),I.style.height=`${k}px`,_.onload=()=>{I.style.position="absolute",I.style.fontSize="0px",I.style.zIndex="6",E.id="turbolinkSdkBgImg",l&&""!==l?E.src=l:se(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 A=document.createElement("div"),O=document.createElement("img");A.style.position="absolute",A.style.fontSize="0px",A.style.zIndex="100",A.style.top="-54px",A.style.right="-200px",O.src="https://i1.branchcn.com/web/sdk/img/campClose.png",O.style.width="40px",O.style.height="auto",A.appendChild(O);const P=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",P),window.addEventListener("message",P)),A.addEventListener("click",(()=>{x.remove(),y&&(document.body.style.overflow="auto");const e=m||X;e&&(e({type:"linkCloseListener",params:null}),window.removeEventListener("message",P))})),C.appendChild(I),C.appendChild(_),C.appendChild(A),S.appendChild(C),x.appendChild(S),document.body.appendChild(x),y&&(document.body.style.overflow="hidden"),o(r),n(r)}catch(e){n(e),o(e)}})),ne=()=>sessionStorage.getItem(j),oe=()=>!(null===V||""===V||" "===V||void 0===V),re=(e,t)=>new Promise((n=>{try{const{appKey:o,appSecret:r,projectId:i}=W||{},{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=>d(this,null,(function*(){var o,l;const c=K(),d=N(),u=(new Date).valueOf(),f=null==u?void 0:u.toString(),h=null==(o=k(`${i}_${f}_${u}_${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 D(),y=yield H(),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})(),x=(()=>{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"})(),S=null==(l=(()=>{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:l.toString(),C=(null==z?void 0:z.version)||"1.0.0",_=`${c}x${d}`,I=window.location.href,E=navigator.userAgent,A="UTC+"+(0-(new Date).getTimezoneOffset()/60),O=document.referrer,j=(()=>{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 B(o,32)})(),T={web:{browser_name:x,browser_version:S,current_time:u,device_type:y,ip:w||"",language:b,os:g,screen_resolution:_,sdk_version:C,url:I,user_agent:E,time_zone:A,referer:O,canvas:j}};let R=[];s&&s.constructor===Array&&(R=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 M={project:i,request_id:f,timestamp:u,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:c,screen_height:d,ip:w||""},custom_data:R,ext_data:T},W=yield p({url:"/v2/event",params:M}),{code:F,data:Y,msg:X}=W||{};if(200===F&&Y){let e="";const t=Y.link_data||[];Y.blackbox&&""!==Y.blackbox&&localStorage.setItem($,Y.blackbox||"");for(let n=0;n<t.length;n++)if("$campaign_reward_url"===t[n].key){e=decodeURIComponent(t[n].value||"");break}if(J&&""!==e)if(ae()){let t=ie(e);if(q&&""!==q){const e=encodeURIComponent(q);t=`${t}&loginUrl=${e}`}oe()||(sessionStorage.setItem(L,t),sessionStorage.setItem(U,"1")),localStorage.setItem(P,e),setTimeout((()=>{window.location.href=t}),300)}else te({url:e});Y.campaign_url=e,n({code:F,message:X,data:Y})}else n({code:F,message:X})}))))}catch(e){n(e)}})),ie=e=>{if(!e||""===e)return"";const t=V||"",n=navigator.language,o=F||n||"",r=Math.floor((new Date).getTime()/1e3),i=localStorage.getItem($),s="1.2.0",a=r%100,l="5CfUxPK7avjguYtG8yAE4ud6n9s774zVVdKwSxPryzaKHSpS4Lgju4M7sLumdLuQWXpHC6peBp2afBwEBbYnENGbZWfkZ6n4s52D3Xye59bfeK4gS9nfjehK".substring(a,a+12),c=`${t}${Y}${o}${r}${i}${s}web${W.appSecret}${l}`,d=B(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:Y},{name:"lg",value:o},{name:"time",value:r},{name:"blackbox",value:i},{name:"version",value:s},{name:"platform",value:"web"},{name:"token",value:d}])},se=e=>d(this,null,(function*(){const t="https://i1.branchcn.com/web/sdk/img/campBg.png",n={campaign_id:e,project_id:null==W?void 0:W.projectId},o=yield p({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)})),ae=()=>{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 le{}return c(le,"init",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{appKey:t,appSecret:r,projectId:i,uid:s,lang:a,lv:l,loginUrl:c,jump:d=!0,dev:p=!1,clickEventCallback:f}=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&&(u="https://test.allapp.link")})(p),s&&(V=s),a&&(F=a),l&&(Y=l),c&&(q=c),f&&(X=f),J=d,W=e||{};let h=(new T).get(O);if(ne())return n(M.SUCCESS),void o(M.SUCCESS);null==h||" "===h||""===h?Q().then((e=>{n(e),o(e)})):ee().then((e=>{if(n(e),o(e),oe()&&ae()){const e=sessionStorage.getItem(L);if(e&&" "!==e){let t=ie(e);if(sessionStorage.removeItem(L),sessionStorage.removeItem(U),q&&""!==q){t=`${t}&loginUrl=${encodeURIComponent(q)}`}window.location.replace(t&&t)}}})),sessionStorage.setItem(j,"1")}catch(e){n(e),o(e)}})))),c(le,"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&&(V=t),n&&(Y=n)}else V=e;n(o),t&&t(o)}catch(e){n(r),t&&t(r)}})))),c(le,"install",Q),c(le,"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&&(V=t),r&&(V=r),re("register").then((e=>{if(ae()){const e=localStorage.getItem(P),t=sessionStorage.getItem(U);if(e&&"1"===t&&s){sessionStorage.removeItem(U);const t=ie(e);window.location.replace(t&&t)}}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(le,"open",ee),c(le,"customEvent",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{event:t,customData:r,backCamp:i}=e||{};if(!t||""===t)throw M.EMPTY_EVENT_NAME;re(t,{customData:r}).then((e=>{const t=localStorage.getItem(P),r=ie(t),s=l(a({},e),{campUrl:r});i&&r&&setTimeout((()=>{window.location.replace(r)}),1e3),n(s),o(s)}))}catch(e){n(e),o(e)}})))),c(le,"loadUrl",((e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=M||{},{url:i,newWindow:s=!1}=e||{};try{if(!W.appSecret||""===W.appSecret)throw M.LACK_APPSECRET;if(!i||""===i)throw M.INVALID_URL;let e=ie(i);if(q&&""!==q){e=`${e}&loginUrl=${encodeURIComponent(q)}`}localStorage.setItem(P,i),oe()||sessionStorage.setItem(U,"1"),!0===s||"true"===s?window.open(e,"_blank"):window.location.href=e,o(r),n(r),re("loadUrl")}catch(e){n(e),o(e)}})))),c(le,"webLoadUrl",te),c(le,"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(le,"createCampaignIcon",((e={},t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=M||{};try{const t=a(a({},{url:null,position:4,iconUrl:"",iconWidth:"50px",iconHeight:"50px",iframeWidth:"350px",iframeHeight:"700px",iconOffset:"10px",defaultOpen:!1,iconRotate:!0,left:"20px",top:"20px",right:"20px",bottom:"20px",clickEventCallback:null}),e),{position:i}=t;if([1,2,3,4].includes(i)||(t.position=4),!W.appSecret||""===W.appSecret)throw M.LACK_APPSECRET;if(!t.url||""===t.url)throw M.INVALID_URL;const s=document.querySelectorAll(".turbolinkCampaignIcon"),c=document.querySelectorAll(".turbolinkCampaignIframe");s.forEach((e=>e.remove())),c.forEach((e=>e.remove()));const d=document.createElement("div");switch(d.className="turbolinkCampaignIcon",d.style.position="fixed",d.style.zIndex="9999",t.position){case 1:d.style.left=t.left,d.style.top=t.top;break;case 2:d.style.right=t.right,d.style.top=t.top;break;case 3:d.style.left=t.left,d.style.bottom=t.bottom;break;case 4:d.style.right=t.right,d.style.bottom=t.bottom}const u=document.createElement("div");u.style.width=t.iconWidth,u.style.height=t.iconHeight,u.style.borderRadius="50%",u.style.cursor="pointer",u.style.zIndex="100001",u.style.transition=t.iconRotate?"transform 0.3s ease":"none",u.style.display="flex",u.style.alignItems="center",u.style.justifyContent="center",u.style.color="#000",u.style.fontSize="0";const p=document.createElement("img");p.src=t.iconUrl,p.style.width="100%",p.style.height="100%",p.style.objectFit="contain",u.appendChild(p),d.appendChild(u);const f=document.createElement("div");f.className="turbolinkCampaignIframe",f.style.zIndex="100000",f.style.position="fixed",f.style.width=t.iframeWidth,f.style.height=t.iframeHeight,f.style.backgroundColor="white",f.style.transition="all 0.4s ease, opacity 0.3s ease-in, opacity 0.6s ease-out",f.style.overflow="hidden",f.style.borderRadius="14px",f.style.boxShadow="0px 4px 8px 0px rgba(0, 0, 0, 0.14), 0px 4px 16px 0px rgba(0, 0, 0, 0.14), 0px 8px 24px 0px rgba(0, 0, 0, 0.30)",f.style.opacity=t.defaultOpen?"1":"0";const h=parseInt(t.iframeHeight)+100;switch(t.position){case 1:f.style.left=t.left,f.style.top=t.defaultOpen?parseInt(t.top)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${h}px`;break;case 2:f.style.right=t.right,f.style.top=t.defaultOpen?parseInt(t.top)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${h}px`;break;case 3:f.style.left=t.left,f.style.bottom=t.defaultOpen?parseInt(t.bottom)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${h}px`;break;case 4:f.style.right=t.right,f.style.bottom=t.defaultOpen?parseInt(t.bottom)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${h}px`}const g=document.createElement("iframe");g.style.width="100%",g.style.height="100%",g.style.border="none",f.appendChild(g),document.body.appendChild(f),G=t.defaultOpen,u.style.transform=G&&t.iconRotate?"rotate(180deg)":"rotate(0deg)";const m=e=>{const n=(null==e?void 0:e.data)||{};if(n){const o=(null==n?void 0:n.source)||"";if(o&&"turbolink"===o){const n=t.clickEventCallback||X;n&&n(e.data)}}};(t.clickEventCallback||X)&&(window.removeEventListener("message",m),window.addEventListener("message",m));const y=e=>{if(e&&(G=!G),u.style.transform=G&&t.iconRotate?"rotate(180deg)":"rotate(0deg)",G&&!Z&&!g.src){let e=ie(t.url);if(e=`${e}&webIframe=1&newSDK=1`,q&&""!==q){e=`${e}&loginUrl=${encodeURIComponent(q)}`}g.src=e,Z=!0}switch(t.position){case 1:case 2:f.style.top=G?parseInt(t.top)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${h}px`,f.style.opacity=G?"1":"0";break;case 3:case 4:f.style.bottom=G?parseInt(t.bottom)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${h}px`,f.style.opacity=G?"1":"0"}};u.addEventListener("click",(()=>{y(!0)})),t.defaultOpen&&y(),document.body.appendChild(d);const w={toggle:()=>{y(!0)},show:()=>{G||y(!0)},hide:()=>{G&&y(!0)},destroy:()=>{d.remove(),f.remove(),window.removeEventListener("message",m)}};n(l(a({},r),{controller:w})),o(l(a({},r),{controller:w}))}catch(e){n(e),o(e)}})))),c(le,"removeCampaignIcon",(e=>new Promise((t=>{const n=e||function(){},{SUCCESS:o}=M||{};try{const e=document.querySelectorAll(".turbolinkCampaignIcon"),r=document.querySelectorAll(".turbolinkCampaignIframe");e.forEach((e=>e.remove())),r.forEach((e=>e.remove())),G=!1,Z=!1,t(o),n(o)}catch(e){t(e),n(e)}})))),c(le,"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&&(V=r),i&&(V=i),re("login").then((e=>{if(ae()){const e=localStorage.getItem(P),t=sessionStorage.getItem(U);if(e&&"1"===t&&a){sessionStorage.removeItem(U);const t=ie(e);window.location.replace(t&&t)}}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(le,"logout",(e=>new Promise((t=>{const n=e||function(){};localStorage.removeItem(P),sessionStorage.removeItem(U),V=null;const{SUCCESS:o}=M||{};t(o),n(o),re("logout")})))),c(le,"getInitState",ne),c(le,"getLoginState",oe),c(le,"codeSearch",((e,t)=>new Promise((n=>{const o=t||function(){};try{if(!e||" "===e)throw M.LACK_CODE;re("code_search",{nativeMsg:e}).then((e=>{n(e),o(e)}))}catch(e){n(e),o(e)}})))),le}));