turbolink-ai 1.2.8 → 1.2.9

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/README.md CHANGED
@@ -2,13 +2,13 @@
2
2
  ![NPM Downloads](https://img.shields.io/npm/dm/turbolink-ai)
3
3
  ![License](https://img.shields.io/npm/l/turbolink-ai)
4
4
 
5
- [Web SDK Integration]: https://help.branchcn.com/docs/web-sdk/webSDKIntegration
6
- [Web SDK Features]:https://help.branchcn.com/docs/web-sdk/webSDKFeatures
5
+ [Web SDK Integration]: https://help.turbolink.cc/developers/web/webSDKIntegration
6
+ [Web SDK Features]:https://help.turbolink.cc/developers/web/webSDKFeatures
7
7
 
8
8
  # Turbolink Web SDK
9
9
 
10
10
  Turbolink Deep Linking/Campaign Web SDK. Please see
11
- [the SDK documentation](https://help.branchcn.com/docs/web-sdk/webSDKIntegration)
11
+ [the SDK documentation](https://help.turbolink.cc/developers/web/webSDKIntegration)
12
12
  for full details.
13
13
 
14
14
  - [Web SDK Integration]
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 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};
1
+ var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,s=(t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,a=(e,t)=>{for(var n in t||(t={}))r.call(t,n)&&s(e,n,t[n]);if(o)for(var n of o(t))i.call(t,n)&&s(e,n,t[n]);return e},c=(e,o)=>t(e,n(o)),l=(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);q.appKey&&(i.Authorization="Bearer "+q.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 m(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function h(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})})),n}var g={exports:{}};var y={exports:{}};const w=h(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var v,b,_,S,x,C,I,E,k;function P(){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)}},c=s.WordArray=a.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||d).stringify(this)},concat:function(e){var t=this.words,n=e.words,o=this.sigBytes,r=e.sigBytes;if(this.clamp(),o%4)for(var i=0;i<r;i++){var s=n[i>>>2]>>>24-i%4*8&255;t[o+i>>>2]|=s<<24-(o+i)%4*8}else for(var a=0;a<r;a+=4)t[o+a>>>2]=n[a>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(o());return new c.init(t,e)}}),l=i.enc={},d=l.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,o=[],r=0;r<n;r++){var i=t[r>>>2]>>>24-r%4*8&255;o.push((i>>>4).toString(16)),o.push((15&i).toString(16))}return o.join("")},parse:function(e){for(var t=e.length,n=[],o=0;o<t;o+=2)n[o>>>3]|=parseInt(e.substr(o,2),16)<<24-o%8*4;return new c.init(n,t/2)}},u=l.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,o=[],r=0;r<n;r++){var i=t[r>>>2]>>>24-r%4*8&255;o.push(String.fromCharCode(i))}return o.join("")},parse:function(e){for(var t=e.length,n=[],o=0;o<t;o++)n[o>>>2]|=(255&e.charCodeAt(o))<<24-o%4*8;return new c.init(n,t)}},p=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},m=s.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n,o=this._data,r=o.words,i=o.sigBytes,s=this.blockSize,a=i/(4*s),l=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*s,d=e.min(4*l,i);if(l){for(var u=0;u<l;u+=s)this._doProcessBlock(r,u);n=r.splice(0,l),o.sigBytes-=d}return new c.init(n,d)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});s.Hasher=m.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){m.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new h.HMAC.init(e,n).finalize(t)}}});var h=i.algo={};return i}(Math),e)),y.exports;var e}const A=m(g.exports=(k=P(),_=(b=k).lib,S=_.WordArray,x=_.Hasher,C=b.algo,I=[],E=C.SHA1=x.extend({_doReset:function(){this._hash=new S.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=this._hash.words,o=n[0],r=n[1],i=n[2],s=n[3],a=n[4],c=0;c<80;c++){if(c<16)I[c]=0|e[t+c];else{var l=I[c-3]^I[c-8]^I[c-14]^I[c-16];I[c]=l<<1|l>>>31}var d=(o<<5|o>>>27)+a+I[c];d+=c<20?1518500249+(r&i|~r&s):c<40?1859775393+(r^i^s):c<60?(r&i|r&s|i&s)-1894007588:(r^i^s)-899497514,a=s,s=i,i=r<<30|r>>>2,r=o,o=d}n[0]=n[0]+o|0,n[1]=n[1]+r|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,o=8*e.sigBytes;return t[o>>>5]|=128<<24-o%32,t[14+(o+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(o+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=x.clone.call(this);return e._hash=this._hash.clone(),e}}),b.SHA1=x._createHelper(E),b.HmacSHA1=x._createHmacHelper(E),k.SHA1)),O="tb_cookie_obj",U="tb_randomId",L="tb_load_url",j="tb_load_source_url",T="tb_ascribe_to_url",$="tl_add_to_cart",R="tb_init_state",B="tb_blackbox";class D{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 H=(e,t)=>{function n(e,t){return e<<t|e>>>32-t}function o(e,t){var n,o,r,i,s;return r=2147483648&e,i=2147483648&t,s=(1073741823&e)+(1073741823&t),(n=1073741824&e)&(o=1073741824&t)?2147483648^s^r^i:n|o?1073741824&s?3221225472^s^r^i:1073741824^s^r^i:s^r^i}function r(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e&t|~e&n}(t,r,i),s),c)),o(n(e,a),t)}function i(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e&n|t&~n}(t,r,i),s),c)),o(n(e,a),t)}function s(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e^t^n}(t,r,i),s),c)),o(n(e,a),t)}function a(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return t^(e|~n)}(t,r,i),s),c)),o(n(e,a),t)}function c(e){var t,n="",o="";for(t=0;t<=3;t++)n+=(o="0"+(e>>>8*t&255).toString(16)).substr(o.length-2,2);return n}var l,d,u,p,f,m,h,g,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)),m=1732584193,h=4023233417,g=2562383102,y=271733878,l=0;l<w.length;l+=16)d=m,u=h,p=g,f=y,m=r(m,h,g,y,w[l+0],7,3614090360),y=r(y,m,h,g,w[l+1],12,3905402710),g=r(g,y,m,h,w[l+2],17,606105819),h=r(h,g,y,m,w[l+3],22,3250441966),m=r(m,h,g,y,w[l+4],7,4118548399),y=r(y,m,h,g,w[l+5],12,1200080426),g=r(g,y,m,h,w[l+6],17,2821735955),h=r(h,g,y,m,w[l+7],22,4249261313),m=r(m,h,g,y,w[l+8],7,1770035416),y=r(y,m,h,g,w[l+9],12,2336552879),g=r(g,y,m,h,w[l+10],17,4294925233),h=r(h,g,y,m,w[l+11],22,2304563134),m=r(m,h,g,y,w[l+12],7,1804603682),y=r(y,m,h,g,w[l+13],12,4254626195),g=r(g,y,m,h,w[l+14],17,2792965006),m=i(m,h=r(h,g,y,m,w[l+15],22,1236535329),g,y,w[l+1],5,4129170786),y=i(y,m,h,g,w[l+6],9,3225465664),g=i(g,y,m,h,w[l+11],14,643717713),h=i(h,g,y,m,w[l+0],20,3921069994),m=i(m,h,g,y,w[l+5],5,3593408605),y=i(y,m,h,g,w[l+10],9,38016083),g=i(g,y,m,h,w[l+15],14,3634488961),h=i(h,g,y,m,w[l+4],20,3889429448),m=i(m,h,g,y,w[l+9],5,568446438),y=i(y,m,h,g,w[l+14],9,3275163606),g=i(g,y,m,h,w[l+3],14,4107603335),h=i(h,g,y,m,w[l+8],20,1163531501),m=i(m,h,g,y,w[l+13],5,2850285829),y=i(y,m,h,g,w[l+2],9,4243563512),g=i(g,y,m,h,w[l+7],14,1735328473),m=s(m,h=i(h,g,y,m,w[l+12],20,2368359562),g,y,w[l+5],4,4294588738),y=s(y,m,h,g,w[l+8],11,2272392833),g=s(g,y,m,h,w[l+11],16,1839030562),h=s(h,g,y,m,w[l+14],23,4259657740),m=s(m,h,g,y,w[l+1],4,2763975236),y=s(y,m,h,g,w[l+4],11,1272893353),g=s(g,y,m,h,w[l+7],16,4139469664),h=s(h,g,y,m,w[l+10],23,3200236656),m=s(m,h,g,y,w[l+13],4,681279174),y=s(y,m,h,g,w[l+0],11,3936430074),g=s(g,y,m,h,w[l+3],16,3572445317),h=s(h,g,y,m,w[l+6],23,76029189),m=s(m,h,g,y,w[l+9],4,3654602809),y=s(y,m,h,g,w[l+12],11,3873151461),g=s(g,y,m,h,w[l+15],16,530742520),m=a(m,h=s(h,g,y,m,w[l+2],23,3299628645),g,y,w[l+0],6,4096336452),y=a(y,m,h,g,w[l+7],10,1126891415),g=a(g,y,m,h,w[l+14],15,2878612391),h=a(h,g,y,m,w[l+5],21,4237533241),m=a(m,h,g,y,w[l+12],6,1700485571),y=a(y,m,h,g,w[l+3],10,2399980690),g=a(g,y,m,h,w[l+10],15,4293915773),h=a(h,g,y,m,w[l+1],21,2240044497),m=a(m,h,g,y,w[l+8],6,1873313359),y=a(y,m,h,g,w[l+15],10,4264355552),g=a(g,y,m,h,w[l+6],15,2734768916),h=a(h,g,y,m,w[l+13],21,1309151649),m=a(m,h,g,y,w[l+4],6,4149444226),y=a(y,m,h,g,w[l+11],10,3174756917),g=a(g,y,m,h,w[l+2],15,718787259),h=a(h,g,y,m,w[l+9],21,3951481745),m=o(m,d),h=o(h,u),g=o(g,p),y=o(y,f);return 32===t?(c(m)+c(h)+c(g)+c(y)).toLowerCase():(c(h)+c(g)).toLowerCase()},K=(e,t)=>d(void 0,null,(function*(){const n=t||function(){};try{const t=new D;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 D(!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=N(),a=M(),c=yield p({url:"/ecl/bs/check",params:{bfp:o,language:i,screen_width:s,screen_height:a}}),{code:l,data:d}=c||{};200===l&&d&&(r[e]=d.cookie_id,t.set(O,JSON.stringify(r))),n(d.cookie_id)}}catch(e){n("1")}}));const N=()=>{let e=0;try{e=window.screen.width}catch(t){e=0}return e},M=()=>{let e=0;try{e=window.screen.height}catch(t){e=0}return e},z={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"}},W={name:"turbolink-ai",version:"1.2.9",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 q={appKey:"",appSecret:"",projectId:""},V="",F="",Y="",J=!0,X="",G=null,Z=!1,Q=!1;const ee=()=>{return"turbolink"===(e="tbSource",new URLSearchParams(window.location.search).get(e));var e},te=e=>new Promise((t=>{ae("install").then((n=>{t(n),e&&e(n)}))})),ne=e=>new Promise((t=>{ae("open").then((n=>{t(n),e&&e(n)}))})),oe=(e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=z||{},i=650,{url:s,maskColor:a="rgba(0, 0, 0, 0.8)",backgroundImage:c,backgroundHeight:l=738,backgroundWidth:d,bgLinkage:u=!1,width:p=300,height:f=i,radius:m=12,zIndex:h=3e3,clickEventCallback:g,bodyHidden:y=!0,jumpNewWindow:w=!1}=e||{};try{if(!q.appSecret||""===q.appSecret)throw z.LACK_APPSECRET;if(!s||""===s)throw z.INVALID_URL;g&&"function"==typeof g&&(G=g);const e=new URL(s),t=new URLSearchParams(e.search).get("l");let v=ce(s);if(v=`${v}&webIframe=1&newSDK=1`,w&&(v=`${v}&jpN=1`),X&&""!==X){v=`${v}&loginUrl=${encodeURIComponent(X)}`}const b=document.getElementById("turbolinkSdkPopup");b&&b.remove();const _=document.createElement("div");_.id="turbolinkSdkPopup",_.style.position="fixed",_.style.zIndex=h,_.style.left="0",_.style.top="0",_.style.right="0",_.style.bottom="0",_.style.width="100%",_.style.height="100%",_.style.overflowX="hidden",_.style.overflowY="auto",_.style.backgroundColor=a;const S=document.createElement("div");S.style.minHeight="100%",S.style.display="-webkit-box",S.style.display="-ms-flexbox",S.style.display="-moz-box",S.style.display="flex",S.style.textAlign="center",S.style.justifyContent="center",S.style.alignItems="center";const x=document.createElement("div");x.style.margin="10vh auto",x.style.border="none",x.style.width=`${p}px`,x.style.height=`${f}px`,x.style.position="relative",x.style.borderRadius=`${m}px`,x.style.display="-webkit-box",x.style.display="-ms-flexbox",x.style.display="-moz-box",x.style.display="flex",x.style.textAlign="center",x.style.justifyContent="center",x.style.alignItems="center";const C=document.createElement("iframe");C.id="turbolinkSdkPopupIframe",C.width=`${p}px`,C.height=`${f}px`,C.style.border="none",C.style.borderRadius=`${m}px`,C.style.overflow="hidden",C.style.position="relative",C.style.zIndex="10",C.src=v;const I=document.createElement("div"),E=document.createElement("img");let k=l;u&&(k=f*(k/i)),I.style.height=`${k}px`,C.onload=()=>{I.style.position="absolute",I.style.fontSize="0px",I.style.zIndex="6",E.id="turbolinkSdkBgImg",c&&""!==c?E.src=c: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 P=document.createElement("div"),A=document.createElement("img");P.style.position="absolute",P.style.fontSize="0px",P.style.zIndex="100",P.style.top="-54px",P.style.right="-200px",A.src="https://i1.branchcn.com/web/sdk/img/campClose.png",A.style.width="40px",A.style.height="auto",P.appendChild(A),G&&(window.removeEventListener("message",re),window.addEventListener("message",re)),P.addEventListener("click",(()=>{_.remove(),y&&(document.body.style.overflow="visible"),G&&(G({type:"linkCloseListener",params:null}),window.removeEventListener("message",re))})),x.appendChild(I),x.appendChild(C),x.appendChild(P),S.appendChild(x),_.appendChild(S),document.body.appendChild(_),y&&(document.body.style.overflow="hidden"),o(r),n(r)}catch(e){n(e),o(e)}})),re=e=>{const t=(null==e?void 0:e.data)||{};if(t){const n=(null==t?void 0:t.source)||"";n&&"turbolink"===n&&G&&G(e.data)}},ie=()=>sessionStorage.getItem(R),se=()=>!(null===V||""===V||" "===V||void 0===V),ae=(e,t)=>new Promise((n=>{try{const{appKey:o,appSecret:r,projectId:i}=q||{},{customData:s,nativeMsg:a="",event_data:c}=t||{};if(""===o||!o||""===r||!r||""===i||!i)throw z.NOT_INIT;if(!e||""===e)throw z.EMPTY_EVENT_NAME;K(i,(t=>d(void 0,null,(function*(){var o,l;const u=N(),f=M(),m=(new Date).valueOf(),h=null==m?void 0:m.toString(),g=null==(o=A(`${i}_${h}_${m}_${r}`))?void 0:o.toString(),y=(()=>{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})(),w=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})),v=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})),b=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()}})),_=(()=>{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(),I=(null==W?void 0:W.version)||"1.0.0",E=`${u}x${f}`,k=window.location.href,P=navigator.userAgent,O="UTC+"+(0-(new Date).getTimezoneOffset()/60),U=document.referrer,R=(()=>{const e=document.createElement("canvas"),t=e.getContext("2d"),n="turbolink <canvas> 1.0";t.textBaseline="top",t.font="14px 'Arial'",t.textBaseline="alphabetic",t.fillStyle="#f60",t.fillRect(125,1,62,20),t.fillStyle="#069",t.fillText(n,2,15),t.fillStyle="rgba(102, 204, 0, 0.7)",t.fillText(n,4,17);const o=e.toDataURL();return H(o,32)})(),D={web:{browser_name:x,browser_version:C,current_time:m,device_type:v,ip:b||"",language:S,os:y,screen_resolution:E,sdk_version:I,url:k,user_agent:P,time_zone:O,referer:U,canvas:R}};let K=[];s&&s.constructor===Array&&(K=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 z={project:i,request_id:h,timestamp:m,msg_signature:g,event:e,user_data:{native_msg:a,os:y,os_version:w,device_model:v,device_id:t,user_id:null==V?void 0:V.toString(),country:_,language:S,screen_width:u,screen_height:f,ip:b||""},custom_data:K,ext_data:D,event_data:{}};if(e===$){const{price:e,currency:t,product_id:n,product_name:o,product_type:r,product_quantity:i}=c||{};z.event_data={price:e||0,currency:t||"",product_id:n||"",product_name:o||"",product_type:r||"",product_quantity:i||1}}const q=yield p({url:"/v2/event",params:z}),{code:F,data:Y,msg:G}=q||{};if(200===F&&Y){let e="";const t=Y.link_data||[];Y.blackbox&&""!==Y.blackbox&&localStorage.setItem(B,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(de()){let t=ce(e);if(X&&""!==X){const e=encodeURIComponent(X);t=`${t}&loginUrl=${e}`}se()||(sessionStorage.setItem(T,t),sessionStorage.setItem(j,"1")),localStorage.setItem(L,e),setTimeout((()=>{window.location.href=t}),300)}else oe({url:e});Y.campaign_url=e,n({code:F,message:G,data:Y})}else n({code:F,message:G})}))))}catch(e){n(e)}})),ce=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,c="5CfUxPK7avjguYtG8yAE4ud6n9s774zVVdKwSxPryzaKHSpS4Lgju4M7sLumdLuQWXpHC6peBp2afBwEBbYnENGbZWfkZ6n4s52D3Xye59bfeK4gS9nfjehK".substring(a,a+12),l=`${t}${Y}${o}${r}${i}${s}web${q.appSecret}${c}`,d=H(l,32);return((e,t)=>{const n=new URL(e),o=n.searchParams;return t.forEach((e=>{const{name:t,value:n}=e;o.has(t)?o.set(t,n):o.append(t,n)})),n.origin+n.pathname+"?"+o.toString()})(e,[{name:"user_id",value:t},{name:"lv",value: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==q?void 0:q.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)})),de=()=>{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 ue{}l(ue,"init",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{appKey:t,appSecret:i,projectId:s,uid:a,lang:c,lv:l,loginUrl:d,jump:p=!0,dev:f=!1,clickEventCallback:m}=e||{};if(!t||""===t)throw z.LACK_APPKEY;if(!i||""===i)throw z.LACK_APPSECRET;if(!s||""===s)throw z.LACK_PROJECTID;f&&(e=>{e&&(u="https://test.allapp.link")})(f),a&&(V=a),c&&(F=c),l&&(Y=l),d&&(X=d),m&&"function"==typeof m&&(G=m),J=p,q=e||{};let h=(new D).get(U);if(ie()){var r=document.referrer;return console.log(r),n(z.SUCCESS),void o(z.SUCCESS)}null==h||" "===h||""===h?te().then((e=>{n(e),o(e)})):ne().then((e=>{if(n(e),o(e),se()&&de()){const e=sessionStorage.getItem(T);if(e&&" "!==e){let t=ce(e);if(sessionStorage.removeItem(T),sessionStorage.removeItem(j),X&&""!==X){t=`${t}&loginUrl=${encodeURIComponent(X)}`}window.location.replace(t&&t)}}})),sessionStorage.setItem(R,"1")}catch(e){n(e),o(e)}})))),l(ue,"setIdentity",((e,t)=>new Promise((n=>{const{SUCCESS:o,UNKNOWN:r}=z||{};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)}})))),l(ue,"install",te),l(ue,"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 z.LACK_UID;t&&(V=t),r&&(V=r),ae("register").then((e=>{if(de()){const e=localStorage.getItem(L),t=sessionStorage.getItem(j);if(e&&"1"===t&&s&&ee()){sessionStorage.removeItem(j);const t=ce(e);window.location.replace(t&&t)}}n(e),o(e)}))}catch(e){n(e),o(e)}})))),l(ue,"open",ne),l(ue,"customEvent",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{event:t,customData:r,backCamp:i}=e||{};if(!t||""===t)throw z.EMPTY_EVENT_NAME;ae(t,{customData:r}).then((e=>{const t=localStorage.getItem(L),r=ce(t),s=a({},e);t&&(s.campUrl=t),de()&&t&&!0===i&&ee()&&setTimeout((()=>{window.location.replace(r)}),1e3),n(s),o(s)}))}catch(e){n(e),o(e)}})))),l(ue,"loadUrl",((e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=z||{},{url:i,newWindow:s=!1}=e||{};try{if(!q.appSecret||""===q.appSecret)throw z.LACK_APPSECRET;if(!i||""===i)throw z.INVALID_URL;let e=ce(i);if(X&&""!==X){e=`${e}&loginUrl=${encodeURIComponent(X)}`}localStorage.setItem(L,i),se()||sessionStorage.setItem(j,"1"),!0===s||"true"===s?(e=`${e}&nw=1`,window.open(e,"_blank")):window.location.href=e,o(r),n(r),ae("loadUrl")}catch(e){n(e),o(e)}})))),l(ue,"webLoadUrl",oe),l(ue,"closeWebUrl",(e=>new Promise((t=>{const n=e||function(){},{SUCCESS:o}=z||{};try{document.getElementById("turbolinkSdkPopup").remove(),document.body.style.overflow="visible",window.removeEventListener("message",re),n(o),t(o)}catch(e){t(e),n(e)}})))),l(ue,"createCampaignIcon",((e={},t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=z||{};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),!q.appSecret||""===q.appSecret)throw z.LACK_APPSECRET;if(!t.url||""===t.url)throw z.INVALID_URL;s&&"function"==typeof s&&(G=s);const l=document.querySelectorAll(".turbolinkCampaignIcon"),d=document.querySelectorAll(".turbolinkCampaignIframe");l.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 m=document.createElement("div");m.className="turbolinkCampaignIframe",m.style.zIndex="100000",m.style.position="fixed",m.style.width=t.iframeWidth,m.style.height=t.iframeHeight,m.style.backgroundColor="white",m.style.transition="all 0.4s ease, opacity 0.3s ease-in, opacity 0.6s ease-out",m.style.overflow="hidden",m.style.borderRadius="14px",m.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)",m.style.opacity=t.defaultOpen?"1":"0";const h=parseInt(t.iframeHeight)+100;switch(t.position){case 1:m.style.left=t.left,m.style.top=t.defaultOpen?parseInt(t.top)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${h}px`;break;case 2:m.style.right=t.right,m.style.top=t.defaultOpen?parseInt(t.top)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${h}px`;break;case 3:m.style.left=t.left,m.style.bottom=t.defaultOpen?parseInt(t.bottom)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${h}px`;break;case 4:m.style.right=t.right,m.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",m.appendChild(g),document.body.appendChild(m),Z=t.defaultOpen,Q=!1,p.style.transform=Z&&t.iconRotate?"rotate(180deg)":"rotate(0deg)",G&&(window.removeEventListener("message",re),window.addEventListener("message",re));const y=e=>{if(e&&(Z=!Z),p.style.transform=Z&&t.iconRotate?"rotate(180deg)":"rotate(0deg)",Z&&!Q&&!g.src){let e=ce(t.url);if(e=`${e}&webIframe=1&newSDK=1`,X&&""!==X){e=`${e}&loginUrl=${encodeURIComponent(X)}`}g.src=e,Q=!0}switch(t.position){case 1:case 2:m.style.top=Z?parseInt(t.top)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${h}px`,m.style.opacity=Z?"1":"0";break;case 3:case 4:m.style.bottom=Z?parseInt(t.bottom)+parseInt(t.iconHeight)+parseInt(t.iconOffset)+"px":`-${h}px`,m.style.opacity=Z?"1":"0"}};p.addEventListener("click",(()=>{y(!0)})),t.defaultOpen&&y(),document.body.appendChild(u);const w={toggle:()=>{y(!0)},show:()=>{Z||y(!0)},hide:()=>{Z&&y(!0)},destroy:()=>{u.remove(),m.remove(),window.removeEventListener("message",re)}};n(c(a({},r),{controller:w})),o(c(a({},r),{controller:w}))}catch(e){n(e),o(e)}})))),l(ue,"removeCampaignIcon",(e=>new Promise((t=>{const n=e||function(){},{SUCCESS:o}=z||{};try{const e=document.querySelectorAll(".turbolinkCampaignIcon"),r=document.querySelectorAll(".turbolinkCampaignIframe");e.forEach((e=>e.remove())),r.forEach((e=>e.remove())),window.removeEventListener("message",re),Z=!1,Q=!1,t(o),n(o)}catch(e){t(e),n(e)}})))),l(ue,"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 z.LACK_UID;r&&(V=r),i&&(V=i),ae("login").then((e=>{if(de()){const e=localStorage.getItem(L),t=sessionStorage.getItem(j);if(e&&"1"===t&&a&&ee()){sessionStorage.removeItem(j);const t=ce(e);window.location.replace(t&&t)}}n(e),o(e)}))}catch(e){n(e),o(e)}})))),l(ue,"logout",(e=>new Promise((t=>{const n=e||function(){};localStorage.removeItem(L),sessionStorage.removeItem(j),V=null;const{SUCCESS:o}=z||{};t(o),n(o),ae("logout")})))),l(ue,"getInitState",ie),l(ue,"getLoginState",se),l(ue,"codeSearch",((e,t)=>new Promise((n=>{const o=t||function(){};try{if(!e||" "===e)throw z.LACK_CODE;ae("code_search",{nativeMsg:e}).then((e=>{n(e),o(e)}))}catch(e){n(e),o(e)}})))),l(ue,"addToCart",((e,t)=>new Promise((n=>{const o=t||function(){},{price:r,product_id:i,product_name:s,product_quantity:a}=e||{};if(null==r||""===r)throw{code:3e3,message:"The price parameter is required"};if("number"!=typeof r)throw{code:3e3,message:"price requires number type"};if(!i)throw{code:3e3,message:"The product_id parameter is required"};if(!s)throw{code:3e3,message:"The product_name parameter is required"};if(null==a||""===a)throw{code:3e3,message:"The product_quantity parameter is required"};if("number"!=typeof a)throw{code:3e3,message:"product_quantity requires number type"};if(!Number.isInteger(a))throw{code:3e3,message:"Product_quantity must be an integer"};try{ae($,{event_data:e}).then((e=>{n(e),t&&t(e)}))}catch(e){n(e),o(e)}}))));export{ue as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turbolink-ai",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
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,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}));