expf-sigma-node.js 3.4.4 → 3.4.6-0

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/public/sigma.js +3292 -1
package/public/sigma.js CHANGED
@@ -1 +1,3292 @@
1
- var $e=Object.create;var W=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var Ke=Object.getPrototypeOf,ze=Object.prototype.hasOwnProperty;var Qe=(a,e)=>{for(var t in e)W(a,t,{get:e[t],enumerable:!0})},be=(a,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of We(e))!ze.call(a,s)&&s!==t&&W(a,s,{get:()=>e[s],enumerable:!(r=Ve(e,s))||r.enumerable});return a};var K=(a,e,t)=>(t=a!=null?$e(Ke(a)):{},be(e||!a||!a.__esModule?W(t,"default",{value:a,enumerable:!0}):t,a)),Xe=a=>be(W({},"__esModule",{value:!0}),a);var rt={};Qe(rt,{default:()=>tt});module.exports=Xe(rt);var le=K(require("node-fetch"));var he=K(require("ua-parser-js")),R=class{platform=["all","web","spliturl","android","ios"];constructor(){this.user={userId:null,profileId:null,deviceId:null,ip:null,email:null,appVersion:null,geo:{country:null,code:null,state:null,city:null},browser:{version:null,name:null},os:{version:null,name:null},custom:{name:null,value:null},time:null,date:null,deviceCategory:null,featureFlags:[],domain:null,url:null,query:null,pathname:null}}init({userId:e,profileId:t,deviceId:r,ip:s,email:n,appVersion:h,custom:d,deviceCategory:g,os:p,browser:m,geo:C,domain:l,url:B,query:u,pathname:D}){this.user.userId=e,this.user.profileId=t,this.user.deviceId=r,this.user.ip=s,this.user.email=n,this.user.appVersion=h,this.user.custom=d,this.user.time=new Date().getTime()/(1e3*60*60),this.user.date=Math.floor(new Date().getTime()/(1e3*60*60*24)),this.user.deviceCategory=g,this.user.os=p,this.user.browser=m,this.user.geo=C,this.user.domain=l,this.user.url=B,this.user.query=u,this.user.pathname=D}getUserBrowser(e){let{user:t}=this;if(!e)return t.browser={name:null,version:null};let s=new he.default(e).getBrowser();return t.browser={name:s.name||void 0,version:s.version||void 0}}getUserOs(e){let{user:t}=this;if(!e)return t.os={name:null,version:null};let s=new he.default(e).getOS();return t.os={name:s.name||void 0,version:s.version||void 0}}setIp(e){this.user.ip=e}addFlag(e,t){let{user:r}=this;r.featureFlags.find(n=>n.name===e)||r.featureFlags.push({name:e,rule:t})}setGeo(e){!e||typeof e!="object"||Array.isArray(e)||(this.user.geo=e)}clearFlags(){this.user.featureFlags=[]}removeInjectedProperties(){this.user.appVersion=null,this.user.userId=null,this.user.profileId=null,this.user.deviceId=null,this.user.email=null,this.user.custom={name:null,value:null}}setUserId(e){e||(this.user.userId=null),this.user.userId=e}setDeviceId(e){e||(this.user.deviceId=null),this.user.deviceId=e}setProfileId(e){e||(this.user.profileId=null),this.user.profileId=e}setEmail(e){e||(this.user.email=null),this.user.email=e}setAppVersion(e){e||(this.user.appVersion=null),this.user.appVersion=e}setBrowserName(e){!e||(this.user.browser.name=e)}setBrowserVersion(e){!e||(this.user.browser.version=e)}setOsName(e){!e||(this.user.os.name=e)}setOsVersion(e){!e||(this.user.os.version=e)}setGeoCountry(e){this.user.geo.country=e}setGeoCode(e){this.user.geo.code=e}setGeoState(e){this.user.geo.state=e}setGeoCity(e){this.user.geo.city=e}setGeoIp(e){this.user.geo.ip=e}setCustomProperty(e,t){typeof e=="string"&&(this.user.custom={...this.user.custom,[e]:t})}removeUserId(){this.user.userId=null}removeDeviceId(){this.user.deviceId=null}removeProfileId(){this.user.profileId=null}removeEmail(){this.user.email=null}removeAppVersion(){this.user.appVersion=null}removeBrowserName(){this.user.browser.name=null}removeBrowserVersion(){this.user.browser.version=null}removeOsName(){this.user.os.name=null}removeOsVersion(){this.user.os.version=null}removeGeoCountry(){this.user.geo.country=null}removeGeoCode(){this.user.geo.code=null}removeGeoState(){this.user.geo.state=null}removeGeoCity(){this.user.geo.city=null}removeGeoIp(){this.user.geo.ip=null}removeCustomProperty(e){!e||typeof e!="string"||delete this.user.custom[e]}};var He=K(require("node-cache"));var Ge;function G(a){var e,t,r="",s=-1,n;if(a&&a.length)for(n=a.length;(s+=1)<n;)e=a.charCodeAt(s),t=s+1<n?a.charCodeAt(s+1):0,55296<=e&&e<=56319&&56320<=t&&t<=57343&&(e=65536+((e&1023)<<10)+(t&1023),s+=1),e<=127?r+=String.fromCharCode(e):e<=2047?r+=String.fromCharCode(192|e>>>6&31,128|e&63):e<=65535?r+=String.fromCharCode(224|e>>>12&15,128|e>>>6&63,128|e&63):e<=2097151&&(r+=String.fromCharCode(240|e>>>18&7,128|e>>>12&63,128|e>>>6&63,128|e&63));return r}function Ye(a){var e,t,r,s,n,h=[],d;if(e=t=r=s=n=0,a&&a.length)for(d=a.length,a+="";e<d;)r=a.charCodeAt(e),t+=1,r<128?(h[t]=String.fromCharCode(r),e+=1):r>191&&r<224?(s=a.charCodeAt(e+1),h[t]=String.fromCharCode((r&31)<<6|s&63),e+=2):(s=a.charCodeAt(e+1),n=a.charCodeAt(e+2),h[t]=String.fromCharCode((r&15)<<12|(s&63)<<6|n&63),e+=3);return h.join("")}function E(a,e){var t=(a&65535)+(e&65535),r=(a>>16)+(e>>16)+(t>>16);return r<<16|t&65535}function Ze(a,e){return a<<e|a>>>32-e}function fe(a,e){for(var t=e?"0123456789ABCDEF":"0123456789abcdef",r="",s,n=0,h=a.length;n<h;n+=1)s=a.charCodeAt(n),r+=t.charAt(s>>>4&15)+t.charAt(s&15);return r}function _e(a){var e,t=a.length*32,r="";for(e=0;e<t;e+=8)r+=String.fromCharCode(a[e>>5]>>>24-e%32&255);return r}function Se(a){var e,t=a.length*32,r="";for(e=0;e<t;e+=8)r+=String.fromCharCode(a[e>>5]>>>e%32&255);return r}function de(a){var e,t=a.length*8,r=Array(a.length>>2),s=r.length;for(e=0;e<s;e+=1)r[e]=0;for(e=0;e<t;e+=8)r[e>>5]|=(a.charCodeAt(e/8)&255)<<e%32;return r}function ge(a){var e,t=a.length*8,r=Array(a.length>>2),s=r.length;for(e=0;e<s;e+=1)r[e]=0;for(e=0;e<t;e+=8)r[e>>5]|=(a.charCodeAt(e/8)&255)<<24-e%32;return r}function xe(a,e){var t=e.length,r=Array(),s,n,h,d,g,p,m,C;for(p=Array(Math.ceil(a.length/2)),d=p.length,s=0;s<d;s+=1)p[s]=a.charCodeAt(s*2)<<8|a.charCodeAt(s*2+1);for(;p.length>0;){for(g=Array(),h=0,s=0;s<p.length;s+=1)h=(h<<16)+p[s],n=Math.floor(h/t),h-=n*t,(g.length>0||n>0)&&(g[g.length]=n);r[r.length]=h,p=g}for(m="",s=r.length-1;s>=0;s--)m+=e.charAt(r[s]);for(C=Math.ceil(a.length*8/(Math.log(e.length)/Math.log(2))),s=m.length;s<C;s+=1)m=e[0]+m;return m}function Pe(a,e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r="",s=a.length,n,h,d;for(e=e||"=",n=0;n<s;n+=3)for(d=a.charCodeAt(n)<<16|(n+1<s?a.charCodeAt(n+1)<<8:0)|(n+2<s?a.charCodeAt(n+2):0),h=0;h<4;h+=1)n*8+h*6>a.length*8?r+=e:r+=t.charAt(d>>>6*(3-h)&63);return r}Ge={VERSION:"1.0.6",Base64:function(){var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e="=",t=!1,r=!0;this.encode=function(s){var n,h,d,g="";for(e=e||"=",s=r?G(s):s,len=s.length,n=0;n<len;n+=3)for(d=s.charCodeAt(n)<<16|(n+1<len?s.charCodeAt(n+1)<<8:0)|(n+2<len?s.charCodeAt(n+2):0),h=0;h<4;h+=1)n*8+h*6>len*8?g+=e:g+=a.charAt(d>>>6*(3-h)&63);return g},this.decode=function(s){var n,h,d,g,p,m,C,l,B,u,D="",A=[];if(!s)return s;n=u=0,s=s.replace(new RegExp("\\"+e,"gi"),"");do p=a.indexOf(s.charAt(n++)),m=a.indexOf(s.charAt(n++)),C=a.indexOf(s.charAt(n++)),l=a.indexOf(s.charAt(n++)),B=p<<18|m<<12|C<<6|l,h=B>>16&255,d=B>>8&255,g=B&255,u+=1,C===64?A[u]=String.fromCharCode(h):l===64?A[u]=String.fromCharCode(h,d):A[u]=String.fromCharCode(h,d,g);while(n<s.length);return D=A.join(""),D=r?Ye(D):D,D},this.setPad=function(s){return e=s||e,this},this.setTab=function(s){return a=s||a,this},this.setUTF8=function(s){return typeof s=="boolean"&&(r=s),this}},CRC32:function(a){var e=0,t=0,r=0,s,n,h;for(a=G(a),s=["00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 ","79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 ","84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F ","63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD ","A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC ","51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 ","B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 ","06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 ","E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 ","12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 ","D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 ","33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 ","CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 ","9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E ","7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D ","806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 ","60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA ","AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 ","5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 ","B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 ","05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 ","F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA ","11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 ","D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F ","30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E ","C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D"].join(""),e=e^-1,n=0,h=a.length;n<h;n+=1)r=(e^a.charCodeAt(n))&255,t="0x"+s.substr(r*9,8),e=e>>>8^t;return(e^-1)>>>0},MD5:function(a){var e=a&&typeof a.uppercase=="boolean"?a.uppercase:!1,t=a&&typeof a.pad=="string"?a.pad:"=",r=a&&typeof a.utf8=="boolean"?a.utf8:!0;this.hex=function(l){return fe(s(l,r),e)},this.setUpperCase=function(l){return typeof l=="boolean"&&(e=l),this},this.setPad=function(l){return t=l||t,this},this.setUTF8=function(l){return typeof l=="boolean"&&(r=l),this};function s(l){return l=r?G(l):l,Se(h(de(l),l.length*8))}function n(l,B){var u,D,A,y,F;for(l=r?G(l):l,B=r?G(B):B,u=de(l),u.length>16&&(u=h(u,l.length*8)),D=Array(16),A=Array(16),F=0;F<16;F+=1)D[F]=u[F]^909522486,A[F]=u[F]^1549556828;return y=h(D.concat(de(B)),512+B.length*8),Se(h(A.concat(y),512+128))}function h(l,B){var u,D,A,y,F,f=1732584193,i=-271733879,c=-1732584194,o=271733878;for(l[B>>5]|=128<<B%32,l[(B+64>>>9<<4)+14]=B,u=0;u<l.length;u+=16)D=f,A=i,y=c,F=o,f=g(f,i,c,o,l[u+0],7,-680876936),o=g(o,f,i,c,l[u+1],12,-389564586),c=g(c,o,f,i,l[u+2],17,606105819),i=g(i,c,o,f,l[u+3],22,-1044525330),f=g(f,i,c,o,l[u+4],7,-176418897),o=g(o,f,i,c,l[u+5],12,1200080426),c=g(c,o,f,i,l[u+6],17,-1473231341),i=g(i,c,o,f,l[u+7],22,-45705983),f=g(f,i,c,o,l[u+8],7,1770035416),o=g(o,f,i,c,l[u+9],12,-1958414417),c=g(c,o,f,i,l[u+10],17,-42063),i=g(i,c,o,f,l[u+11],22,-1990404162),f=g(f,i,c,o,l[u+12],7,1804603682),o=g(o,f,i,c,l[u+13],12,-40341101),c=g(c,o,f,i,l[u+14],17,-1502002290),i=g(i,c,o,f,l[u+15],22,1236535329),f=p(f,i,c,o,l[u+1],5,-165796510),o=p(o,f,i,c,l[u+6],9,-1069501632),c=p(c,o,f,i,l[u+11],14,643717713),i=p(i,c,o,f,l[u+0],20,-373897302),f=p(f,i,c,o,l[u+5],5,-701558691),o=p(o,f,i,c,l[u+10],9,38016083),c=p(c,o,f,i,l[u+15],14,-660478335),i=p(i,c,o,f,l[u+4],20,-405537848),f=p(f,i,c,o,l[u+9],5,568446438),o=p(o,f,i,c,l[u+14],9,-1019803690),c=p(c,o,f,i,l[u+3],14,-187363961),i=p(i,c,o,f,l[u+8],20,1163531501),f=p(f,i,c,o,l[u+13],5,-1444681467),o=p(o,f,i,c,l[u+2],9,-51403784),c=p(c,o,f,i,l[u+7],14,1735328473),i=p(i,c,o,f,l[u+12],20,-1926607734),f=m(f,i,c,o,l[u+5],4,-378558),o=m(o,f,i,c,l[u+8],11,-2022574463),c=m(c,o,f,i,l[u+11],16,1839030562),i=m(i,c,o,f,l[u+14],23,-35309556),f=m(f,i,c,o,l[u+1],4,-1530992060),o=m(o,f,i,c,l[u+4],11,1272893353),c=m(c,o,f,i,l[u+7],16,-155497632),i=m(i,c,o,f,l[u+10],23,-1094730640),f=m(f,i,c,o,l[u+13],4,681279174),o=m(o,f,i,c,l[u+0],11,-358537222),c=m(c,o,f,i,l[u+3],16,-722521979),i=m(i,c,o,f,l[u+6],23,76029189),f=m(f,i,c,o,l[u+9],4,-640364487),o=m(o,f,i,c,l[u+12],11,-421815835),c=m(c,o,f,i,l[u+15],16,530742520),i=m(i,c,o,f,l[u+2],23,-995338651),f=C(f,i,c,o,l[u+0],6,-198630844),o=C(o,f,i,c,l[u+7],10,1126891415),c=C(c,o,f,i,l[u+14],15,-1416354905),i=C(i,c,o,f,l[u+5],21,-57434055),f=C(f,i,c,o,l[u+12],6,1700485571),o=C(o,f,i,c,l[u+3],10,-1894986606),c=C(c,o,f,i,l[u+10],15,-1051523),i=C(i,c,o,f,l[u+1],21,-2054922799),f=C(f,i,c,o,l[u+8],6,1873313359),o=C(o,f,i,c,l[u+15],10,-30611744),c=C(c,o,f,i,l[u+6],15,-1560198380),i=C(i,c,o,f,l[u+13],21,1309151649),f=C(f,i,c,o,l[u+4],6,-145523070),o=C(o,f,i,c,l[u+11],10,-1120210379),c=C(c,o,f,i,l[u+2],15,718787259),i=C(i,c,o,f,l[u+9],21,-343485551),f=E(f,D),i=E(i,A),c=E(c,y),o=E(o,F);return Array(f,i,c,o)}function d(l,B,u,D,A,y){return E(Ze(E(E(B,l),E(D,y)),A),u)}function g(l,B,u,D,A,y,F){return d(B&u|~B&D,l,B,A,y,F)}function p(l,B,u,D,A,y,F){return d(B&D|u&~D,l,B,A,y,F)}function m(l,B,u,D,A,y,F){return d(B^u^D,l,B,A,y,F)}function C(l,B,u,D,A,y,F){return d(u^(B|~D),l,B,A,y,F)}},SHA256:function(a){var e=a&&typeof a.uppercase=="boolean"?a.uppercase:!1,t=a&&typeof a.pad=="string"?a.pad:"=",r=a&&typeof a.utf8=="boolean"?a.utf8:!0,s;this.hex=function(i){return fe(n(i,r))},this.b64=function(i){return Pe(n(i,r),t)},this.any=function(i,c){return xe(n(i,r),c)},this.raw=function(i){return n(i,r)},this.hex_hmac=function(i,c){return fe(h(i,c))},this.b64_hmac=function(i,c){return Pe(h(i,c),t)},this.any_hmac=function(i,c,o){return xe(h(i,c),o)},this.vm_test=function(){return hex("abc").toLowerCase()==="900150983cd24fb0d6963f7d28e17f72"},this.setUpperCase=function(i){return typeof i=="boolean"&&(e=i),this},this.setPad=function(i){return t=i||t,this},this.setUTF8=function(i){return typeof i=="boolean"&&(r=i),this};function n(i,c){return i=c?G(i):i,_e(f(ge(i),i.length*8))}function h(i,c){i=r?G(i):i,c=r?G(c):c;var o,U=0,S=ge(i),x=Array(16),P=Array(16);for(S.length>16&&(S=f(S,i.length*8));U<16;U+=1)x[U]=S[U]^909522486,P[U]=S[U]^1549556828;return o=f(x.concat(ge(c)),512+c.length*8),_e(f(P.concat(o),512+256))}function d(i,c){return i>>>c|i<<32-c}function g(i,c){return i>>>c}function p(i,c,o){return i&c^~i&o}function m(i,c,o){return i&c^i&o^c&o}function C(i){return d(i,2)^d(i,13)^d(i,22)}function l(i){return d(i,6)^d(i,11)^d(i,25)}function B(i){return d(i,7)^d(i,18)^g(i,3)}function u(i){return d(i,17)^d(i,19)^g(i,10)}function D(i){return d(i,28)^d(i,34)^d(i,39)}function A(i){return d(i,14)^d(i,18)^d(i,41)}function y(i){return d(i,1)^d(i,8)^g(i,7)}function F(i){return d(i,19)^d(i,61)^g(i,6)}s=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998];function f(i,c){var o=[1779033703,-1150833019,1013904242,-1521486534,1359893119,-1694144372,528734635,1541459225],U=new Array(64),S,x,P,M,k,N,H,$,V,_,ce,Ue;for(i[c>>5]|=128<<24-c%32,i[(c+64>>9<<4)+15]=c,V=0;V<i.length;V+=16){for(S=o[0],x=o[1],P=o[2],M=o[3],k=o[4],N=o[5],H=o[6],$=o[7],_=0;_<64;_+=1)_<16?U[_]=i[_+V]:U[_]=E(E(E(u(U[_-2]),U[_-7]),B(U[_-15])),U[_-16]),ce=E(E(E(E($,l(k)),p(k,N,H)),s[_]),U[_]),Ue=E(C(S),m(S,x,P)),$=H,H=N,N=k,k=E(M,ce),M=P,P=x,x=S,S=E(ce,Ue);o[0]=E(S,o[0]),o[1]=E(x,o[1]),o[2]=E(P,o[2]),o[3]=E(M,o[3]),o[4]=E(k,o[4]),o[5]=E(N,o[5]),o[6]=E(H,o[6]),o[7]=E($,o[7])}return o}}};var pe=Ge;var ke="https://api.expf.ru/api/v1",z="sigmaPrivateId",O="sigmaHash",me="sigmaDataFileLastUpdate",v="sigmaDataFile",Q="sigmaExperiments",De="sigmaHoldouts",b="sigmaGeoData",Ce=18446744073709552e3,Be=8540717056e4,Oe=new pe.SHA256,X=new pe.MD5,ot=24*60*60,ut=5*60,Y=3600,Z=600,ee={featureFlag:1,param:2,splitUrl:3,webBuilder:4,holdout:5},I={emptyToken:"Please specify a token",APIRequestErrorConfig:{token:"%token%",userData:"%userData%",detail:"Invalid request to sigma config json",time:new Date().toLocaleString("ru-RU"),cache:!0},APIRequestErrorGeoData:{token:"%token%",userData:"%userData%",detail:"Invalid request to sigma geo data",time:new Date().toLocaleString("ru-RU")},saveLastUpdateError:"Save last update to cache",isNoExperimentInCache:"Experiments not found in cache",badConfig:"Bad config.json"},Le=["equal","not equal","any of","none of"],Te="sigma_group",te={invalidJson:'Sigma warning: Invalid type json "%value%" in config.',invalidType:'Sigma warning: Invalid type "%type%" in config.',emptyHoldoutId:"Sigma warning: Empty holdout id"},je="node.js",re="success",se="failed",Ae=200,Ne=400,w="sigmaForcedExperiments";var Fe=new He.default({stdTTL:Y,checkperiod:Z}),q=class{constructor(e){this.postfix="",e&&(this.postfix="__"+e)}get(e){try{return Fe.get(e+this.postfix)}catch(t){console.log(t)}}set(e,t){try{Fe.set(e+this.postfix,t);return}catch(r){console.log(r)}}remove(e){try{return Fe.del(e+this.postfix)}catch(t){console.log(t)}}parse(e){if(!this.get(e))throw new Error(`${e} not found in cache`);return JSON.parse(this.get(e))}};var Re=K(require("node-cache"));var ye=new Re.default({stdTTL:Y,checkperiod:Z}),J=class{constructor(e){this.postfix="",e&&(this.postfix="__"+e)}get(e){try{return ye.get(e+this.postfix)}catch(t){console.log(t)}}set(e,t){try{return ye.set(e+this.postfix,t)}catch(r){console.log(r)}}keys(){return ye.keys()}parse(e){if(!this.get(e))throw new Error(`${e} not found in cache`);return JSON.parse(String(this.get(e)))}};function ie(a){return!!a}function L(a,e){if(a.length){for(let t in a)if(a[t]==e)return!0}return!1}function T(a,e,t=!0){let r,s=Math.max(a.length,e.length);a=(a+"").split("."),e=(e+"").split(".");for(let n=0;n<s;n++)if(a[n]===void 0&&(a[n]="0"),e[n]===void 0&&(e[n]="0"),r=parseInt(a[n],10)-parseInt(e[n],10),r!==0)return!(r<0);if(t)return!1;if(!t)return!0}function ae(a,e,t,r,s){if(t||(t="="),a===null||typeof a>"u"||!e)return!1;switch(a=String(a),Array.isArray(e)||(e=String(e).toLowerCase().trim()),t.trim()){case"equal":return a.toLowerCase().trim()==e;case"not equal":return a.toLowerCase().trim()!=e;case"greater":return T(a.trim(),e);case"less":return T(e,a.trim());case"greater equal":return T(a.trim(),e,!1);case"less equal":return T(e,a.trim(),!1);case"any of":return e.includes(a);case"none of":return!e.includes(a);case"contains any of":for(let n=0;n<e.length;n++)if(a.includes(e[n]))return!0;return!1;case"contains none of":for(let n=0;n<e.length;n++)if(a.includes(e[n]))return!1;return!0;case"on date":return Math.floor(new Date(e.toString()).getTime()/(1e3*60*60*24))==r;case"after time":return new Date(e.toString()).getTime()/(1e3*60*60)<s;case"before time":return new Date(e.toString()).getTime()/(1e3*60*60)>s;case"starts with":return a.startsWith(e);case"not starts with":return!a.startsWith(e);case"ends with":return a.endsWith(e);case"not ends with":return!a.endsWith(e);case"contains":return a.includes(e);case"not contains":return!a.includes(e);default:return!1}}function ne(a){let e=0,t,r;if(a.length===0)return e;for(t=0;t<a.length;t++)r=a.charCodeAt(t),e=(e<<5)-e+r,e|=0;return e}function j(a,e){if(e==="")return null;switch(a){case"string":return e;case"bool":return e==="true";case"integer":case"number":return parseFloat(e);case"json":try{return JSON.parse(e)}catch(t){return console.error(te.invalidJson.replace("%value%",e),t),null}default:return e}}function oe(){let a="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(let t=0;t<80;t++)a+=e.charAt(Math.floor(Math.random()*e.length));return a}function ue(a,e,t,r){let s="a",n=0;if(Math.abs(a)/100<=parseFloat(e)*100||r){let h=Math.abs(a)%100;for(let d=0;d<t.length;d++)if(n+=t[d].weight*100,h<=n)return s=t[d].name;return s}return!1}function Ee(a,e){if(!Object.keys(a).length)return;if(!e)return a;let t={...a},{feature_flags:r,experiments:s}=t;return t.feature_flags&&(t.feature_flags=qe(r,e)),t.experiments&&(t.experiments=qe(s,e)),t}function qe(a,e){if(!a.length)return[];let t=Array.isArray(e)?[...e]:[e],r="all",s="app",n="ios",h="android";return t.includes(r)||(a=a.filter(d=>{for(let g in t)if(d.platforms&&d.platforms.length){if(t.includes(s)&&(d.platforms.includes(n)||d.platforms.includes(h))||t.includes(n)&&d.platforms.includes(s)||t.includes(h)&&d.platforms.includes(s)||t.some(p=>d.platforms.includes(p.toLowerCase())))return d}else if(!d.platform||d.platform===r||t[g]===s&&(d.platform===h||d.platform===n)||t[g]===n&&d.platform===s||t[g]===h&&d.platform===s||d.platform===t[g].toLowerCase())return d})),a}var Je="3.4.4";var Me=Je;var ve=[["192.168.0.0","192.168.255.255"],["172.0.0.0","172.255.255.255"],["10.0.0.0","10.255.255.255"],["127.0.0.0","127.255.255.255"],["100.64.0.0","100.127.255.255"]];function Ie(a){let e=!1;if(typeof a!="string"||a.split(".").length-1!==3)return e=!0;function r(n){let h=n.split(".");return(parseInt(h[0])<<24)+(parseInt(h[1])<<16)+(parseInt(h[2])<<8)+parseInt(h[3])}let s=r(a);for(let n in ve){let h=r(ve[n][0]),d=r(ve[n][1]);if(s>=h&&s<=d){e=!0;break}}return e}typeof le.default.default<"u"&&le.default.default;var we=class{constructor(e,t,r=10,s={api:"",retries:"",postfix:"",geoCacheTTL:null}){if(!e)throw new Error(I.emptyToken);this.token=e,this.userData=t||{},r<10?this.cacheTTL=10:this.cacheTTL=r,this.api=s.api||ke,this.retries=s.retries||2,this.postfix=s.postfix||"",this.sigmaUserData=new R,this.cache=new q(this.postfix),this.sigmaUserData.init({userId:this.userData.userId||this.userData.userId===0?String(this.userData.userId).trim():null,profileId:this.userData.profileId||this.userData.profileId===0?String(this.userData.profileId).trim():null,deviceId:this.userData.deviceId||this.userData.deviceId===0?String(this.userData.deviceId).trim():null,ip:this.userData.ip||null,email:this.userData.email||null,appVersion:this.userData.appVersion||null,custom:this.userData.custom||{},deviceCategory:this.userData.deviceCategory||null,browser:this.userData.browser||this.sigmaUserData.getUserBrowser(this.userData.ua),os:this.userData.os||this.sigmaUserData.getUserOs(this.userData.ua),geo:this.userData.geo||{},domain:this.userData.domain||null,url:this.userData.url||null,query:this.userData.query||null,pathname:this.userData.pathname||null,ua:this.userData.ua||void 0}),this.makePrivateIdInCache(),this.geoCache=new J(`${this.cache.get(z)}__${this.token}`)}makePrivateIdInCache(){this.cache.get(z)||this.cache.set(z,oe())}async getDataFile(e){let t,r={status:null,statusCode:null,data:null},s=typeof AbortController<"u"?new AbortController:null;try{t=await(0,le.default)(e,{headers:{ip:this.userData.ip||"","X-Real-IP":this.userData.ip||"",token:this.token,"user-id":oe(),"sdk-name":je,"sdk-version":Me},...s&&{signal:s.signal}}),r.status=t.status===Ae?re:se,r.statusCode=t.status,r.data=t.status===Ae?await t.json():null}catch{s&&s.abort(),r.status=se,r.statusCode=Ne,r.data=null}return r}async getConfig(){let e,t=this.cache.get(O),r;if(e=await this.getDataFile(`${this.api}/config.json`),e.status===re){this.userData.platform&&(e.data=Ee(e.data,this.userData.platform)),r=await Oe.hex(JSON.stringify(e.data)),(!t||t!==r)&&(this.cache.set(O,r),this.cache.set(v,JSON.stringify(e.data)),this.checkForceExperiments());return}if(e.status===se&&!this.cache.get(v))throw new Error(I.APIRequestErrorConfig.detail)}async getUserGeoData(){if(this.userData.ip&&Ie(this.userData.ip)){this.geoCache.set(b,JSON.stringify({location:"none"}));return}if(this.userData.ip){let e=await this.getDataFile(`${this.api}/geo`);e.status===re?this.geoCache.set(b,JSON.stringify(e.data)):this.geoCache.set(b,JSON.stringify({location:"none"}))}else this.userData.geo?this.geoCache.set(b,JSON.stringify(this.userData.geo)):this.geoCache.set(b,JSON.stringify({location:"none"}))}recordLastUpdateInCache(){let e=Math.floor(Date.now()/1e3);this.cache.set(me,e)}async saveToCache(){try{await this.getConfig()}catch{if(I.APIRequestErrorConfig.userData=JSON.stringify(this.userData),I.APIRequestErrorConfig.token=this.token,this.cache.get(v))I.APIRequestErrorConfig.cache=!0,console.error(I.APIRequestErrorConfig);else throw I.APIRequestErrorConfig.cache=!1,console.error(I.APIRequestErrorConfig),new Error(JSON.stringify(I.APIRequestErrorConfig))}this.recordLastUpdateInCache()}async saveToGeoCache(){try{await this.getUserGeoData(),this.geoCache.get(b)?this.sigmaUserData.setGeo(this.geoCache.parse(b)):this.sigmaUserData.setGeo("{}")}catch(e){this.geoCache.get(b)||this.geoCache.set(b,JSON.stringify({location:"none"})),I.APIRequestErrorGeoData.token=this.token,I.APIRequestErrorGeoData.userData=JSON.stringify(this.userData),console.error(e,I.APIRequestErrorGeoData)}}hasExpireCache(){let e=Number(this.cache.get(me));return Math.floor(Date.now()/1e3)>e+this.cacheTTL}updateCache(){if(!this.cache.get(v)||this.hasExpireCache())return this.saveToCache()}updateGeoCache(){if(!this.geoCache.get(b))return this.saveToGeoCache()}async getFlags(){await this.updateCache();let e=this.cache.parse(v);if(!!e.feature_flags)return e.feature_flags}async checkFlag(e){if(!e)return null;await this.updateCache(),await this.updateGeoCache();let t=this.cache.parse(v);if(!t.feature_flags)return;let r=null,s=this.getExperimentByFeatureFlag(t,e);if(s){let n=await this.getExperiment(s).then(h=>h.getFeatureValue(e));if(n!==null)return n}for(let n=0;n<t.feature_flags.length;n++)if(t.feature_flags[n].name===e){r=t.feature_flags[n];break}return r?this.findingSpotCondition(r,this.sigmaUserData):null}async getUserFeatureFlagsDetails(){let e=[];await this.updateCache(),await this.updateGeoCache();let t=await this.cache.parse(v);if(t.feature_flags.length>0)for(let r in t.feature_flags){let s=t.feature_flags[r].name,n=await this.checkFlag(s);e.push({name:s,value:n})}return e}getExperimentByFeatureFlag(e,t){for(let r=0;r<e.experiments.length;r++)if(e.experiments[r].feature_flags.length){for(let s in e.experiments[r].feature_flags)if(e.experiments[r].feature_flags[s].name===t)return e.experiments[r].name}return null}getFlag(e){if(!e)return!1;let t=this.sigmaUserData.user.featureFlags,r=null;for(let s in t)if(t[s].name===e){r=t[s].rule.value;break}return r||!1}getUserParamValue(e,t=null,r=!1){if(!e)return!1;let s=this.sigmaUserData.user,n=null;if(e.includes(".")){let h=e.split("."),d=h[0],g=h[1];if(!g)return!1;let p=Object.keys(s).find(C=>C===d);if(!s[p])return!1;let m=Object.entries(s[p]);for(let[C,l]of m)if(C==g){n=l;break}}else for(let[h,d]of Object.entries(s))if(h==e){n=d;break}return n!=null&&(n=String(n)),t&&n&&r?X.hex(n):n}calcUserInGroup(e,t,r,s=!1,n=null,h=[],d){if(!d)return!1;let g=X.hex(String(d)+e),p=ne(g)*Be/Ce,m=null;if(!n&&!h.length||s)return ue(p,t,r,s);{m=X.hex(String(d)+n);let C=ne(m)*Be/Ce;for(let l in h){let B=Math.floor(Math.abs(C/10));if(B>=h[l].lower_bound&&B<=h[l].upper_bound)return ue(p,t,r,s)}}return null}switchSplitById(e){let t=null;switch(e){case"userId":t=this.userData.userId||this.userData.userId===0?String(this.userData.userId).trim():null;break;case"profileId":t=this.userData.profileId||this.userData.profileId===0?String(this.userData.profileId).trim():null;break;case"deviceId":t=this.userData.deviceId||this.userData.deviceId===0?String(this.userData.deviceId).trim():null;break}return t}getSplitById(e){return e?(e.split_by||(e.split_by="userId"),this.switchSplitById(e.split_by)):null}checkTargetConditions(e){if(e.targets&&e.targets.conditions&&e.targets.conditions.length>0){let t=e.targets,r=[];for(let s in t.conditions){let n=this.getUserParamValue(t.conditions[s].name,e.is_private,this.checkConditionSignForHash(t.conditions[s].condition_sign));r.push(ae(n,t.conditions[s].value,t.conditions[s].condition_sign,this.sigmaUserData.user.date,this.sigmaUserData.user.time))}return this.checkConditionsStatement(t.conditional_statement,r)}return!1}checkConditionSignForHash(e){return Le.includes(e)}experimentDefinition(e,t,r){return t||r||e.targets&&e.targets.conditions.length>0&&this.checkTargetConditions(e)||!e.targets||e.targets&&e.targets.conditions.length===0?e:null}async getExperiment(e){if(!e)return null;await this.updateCache(),await this.updateGeoCache();let t=await this.cache.parse(v);if(this.sigmaUserData.setGeo(this.geoCache.parse(b)),!t.experiments)throw new Error(I.isNoExperimentInCache);let r=null,s=null,n=[],h=null,d=null,g=!1,p=null,m=!1;for(let u=0;u<t.experiments.length;u++){let D=t.experiments[u];if(D.name===e&&ie(D.layer_id)&&(s=D.layer_id,n=D.layer_bounds),D.name===e){if(p=this.getSplitById(D),g=L(D.forced_user_list,p),h=this.findUserInForcedGroup(D),r=this.experimentDefinition(D,h,g),D.holdouts&&D.holdouts.length){for(let A of D.holdouts)if(m=await this.getHoldout(A),m)break}break}}let C=`${Te}_${e}`;if(this.cache.get(C)&&this.cache.remove(C),r){if(h||(h=this.calcUserInGroup(r.salt,r.allocation,r.groups,g,s,n,p)),r.type===ee.holdout)return h&&this.cache.set(C,h),h;m||(this.cache.set(C,h),d=r.groups.findIndex(u=>u.name==h))}return{getParamValue:u=>{if(!u||!r||m)return null;let D=this.cache.get(C),A=null;for(let F=0;F<r.params.length;F++)if(r.params[F].name===u){A=r.params[F];break}if(!A)return null;let y=null;for(let F in A.values)A.values[F].group===D&&(y=j(A.type,A.values[F].value));return y},getFeatureValue:u=>{if(!u||!r||m)return null;let D=this.cache.get(C),A=null;for(let f=0;f<r.feature_flags.length;f++)if(r.feature_flags[f].name===u){A=r.feature_flags[f];break}if(!A)return null;let y=null;for(let f=0;f<A.groups.length;f++)if(A.groups[f].group===D){y=A.groups[f];break}if(!y)return null;let F=this.findingSpotCondition(y,!1,r);return j(A.type,F)},groupIndex:d<0?null:d,userInHoldout:m}}async getAllUserExperiments(e=!0){await this.updateCache(),await this.updateGeoCache();let t=this.cache.parse(v);if(!t.experiments.length)return null;let r="";for(let s in t.experiments){if(!e&&t.experiments[s].type===ee.holdout)continue;let n=null,h=[],d=this.getSplitById(t.experiments[s]),g=L(t.experiments[s].forced_user_list,d),p=this.findUserInForcedGroup(t.experiments[s]),m=this.experimentDefinition(t.experiments[s],p,g),C;if(!m||(ie(m.layer_id)&&!p&&(n=m.layer_id,h=m.layer_bounds),p||(p=this.calcUserInGroup(m.salt,m.allocation,m.groups,g,n,h,d)),!p))continue;if(t.experiments[s].holdouts&&t.experiments[s].holdouts.length>0)for(let B of t.experiments[s].holdouts){let u=t.experiments.find(f=>f.name===B);if(!u)break;let D=this.getSplitById(u);if(!D)continue;let A=L(u.forced_user_list,D),y=this.findUserInForcedGroup(u);if(y){C=!0;break}let F=this.experimentDefinition(u,y,A);if(!!F&&(y=this.calcUserInGroup(F.salt,F.allocation,F.groups,A,null,[],D),y)){C=!0;break}}if(C)continue;let l=m.groups.findIndex(B=>B.name==p);r=r.concat(m.name).concat(".").concat(l).concat("|")}return r.length>0?(this.cache.set(Q,r.slice(0,-1)),r.slice(0,-1)):(this.cache.remove(Q),null)}async getHoldout(e){if(!e)return console.log(te.emptyHoldoutId);let t=await this.getExperiment(e);return!!(t&&typeof t=="string")}async getAllUserHoldouts(){await this.updateCache();let e=await this.cache.parse(v);if(!e.experiments.length)return null;let t="";for(let r of e.experiments){if(r.type!==ee.holdout)continue;let s=!1,n=null,h=[],d=this.getSplitById(r),g=L(r.forced_user_list,d),p=this.experimentDefinition(r,s,g);!p||(s=this.calcUserInGroup(p.salt,p.allocation,p.groups,g,n,h,d),s&&(t=t.concat(r.name).concat(".").concat("0").concat("|")))}return t.length>0?(this.cache.set(De,t.slice(0,-1)),t.slice(0,-1)):(this.cache.remove(De),null)}findUserInForcedGroup(e){let t=!1;for(let r in e.groups){let s=e.groups[r].forced_user_list;if(s&&s.length){for(let n in s)if(s[n]===this.getSplitById(e))return t=e.groups[r].name}}return t}findingSpotCondition(e,t=!1,r=null){let s=e.rules,n=null;for(let h in s)s[h].is_default&&(n={id:s[h].id,value:s[h].value,type:e.type});if(!n)throw new Error(I.badConfig);for(let h in s){if(!s[h].conditional_statement&&s.length===1)return this.sigmaUserData.addFlag(e.name,n),!0;for(let p in s){let m=s[p].conditions,C=[];for(let u in m){let D=this.getUserParamValue(m[u].name,r?r.is_private:e.is_private,this.checkConditionSignForHash(m[u].condition_sign));C.push(ae(D,m[u].value,m[u].condition_sign,this.sigmaUserData.user.date,this.sigmaUserData.user.time))}let l=this.checkConditionsStatement(s[p].conditional_statement,C),B=j(e.type,s[p].value);if(l)return t&&t.addFlag(e.name,{id:s[p].id,value:B,type:e.type}),B}let g=j(n.type,n.value);return t&&(n.value=g,t.addFlag(e.name,n)),g}}async getCacheDataFile(){return await this.updateCache(),this.cache.parse(v)}async getCacheHash(){return await this.cache.get(O)}checkConditionsStatement(e,t){let r=!1;return e=="OR"&&t.find(n=>n===!0)===!0&&(r=!0),e=="AND"&&(t.find(n=>n===!1)===!1||(r=!0)),r}clearCacheByKeys(e){for(let t in e)this.cache.remove(e[t])}clearUserProperties(){this.userData.userId=void 0,this.userData.profileId=void 0,this.userData.deviceId=void 0,this.sigmaUserData.removeInjectedProperties(),this.clearCacheByKeys([Q])}overwriteGeoCache(e,t){let r=this.geoCache.parse(b);r[e]=t,this.geoCache.set(b,JSON.stringify(r))}editUserProperties(){return{setUserId:e=>(this.sigmaUserData.setUserId(e),this.userData.userId=e,this.editUserProperties()),setDeviceId:e=>(this.sigmaUserData.setDeviceId(e),this.userData.deviceId=e,this.editUserProperties()),setProfileId:e=>(this.sigmaUserData.setProfileId(e),this.userData.profileId=e,this.editUserProperties()),setEmail:e=>(this.sigmaUserData.setEmail(e),this.editUserProperties()),setAppVersion:e=>(this.sigmaUserData.setAppVersion(e),this.editUserProperties()),setBrowserName:e=>(this.sigmaUserData.setBrowserName(e),this.editUserProperties()),setBrowserVersion:e=>(this.sigmaUserData.setBrowserVersion(e),this.editUserProperties()),setOsName:e=>(this.sigmaUserData.setOsName(e),this.editUserProperties()),setOsVersion:e=>(this.sigmaUserData.setOsVersion(e),this.editUserProperties()),setGeoCountry:e=>(this.sigmaUserData.setGeoCountry(e),this.overwriteGeoCache("country",e),this.editUserProperties()),setGeoCode:e=>(this.sigmaUserData.setGeoCode(e),this.overwriteGeoCache("code",e),this.editUserProperties()),setGeoState:e=>(this.sigmaUserData.setGeoState(e),this.overwriteGeoCache("state",e),this.editUserProperties()),setGeoCity:e=>(this.sigmaUserData.setGeoCity(e),this.overwriteGeoCache("city",e),this.editUserProperties()),setGeoIp:e=>(this.sigmaUserData.setGeoIp(e),this.overwriteGeoCache("ip",e),this.editUserProperties()),setCustomProperty:(e,t)=>(this.sigmaUserData.setCustomProperty(e,t),this.editUserProperties()),removeUserId:()=>(this.sigmaUserData.removeUserId(),this.userData.userId=void 0,this.editUserProperties()),removeDeviceId:()=>(this.sigmaUserData.removeDeviceId(),this.userData.deviceId=void 0,this.editUserProperties()),removeProfileId:()=>(this.sigmaUserData.removeProfileId(),this.userData.profileId=void 0,this.editUserProperties()),removeAppVersion:()=>(this.sigmaUserData.removeAppVersion(),this.editUserProperties()),removeBrowserName:()=>(this.sigmaUserData.removeBrowserName(),this.editUserProperties()),removeBrowserVersion:()=>(this.sigmaUserData.removeBrowserVersion(),this.editUserProperties()),removeEmail:()=>(this.sigmaUserData.removeEmail(),this.editUserProperties()),removeOsName:()=>(this.sigmaUserData.removeOsName(),this.editUserProperties()),removeOsVersion:()=>(this.sigmaUserData.removeOsVersion(),this.editUserProperties()),removeGeoCountry:()=>(this.sigmaUserData.removeGeoCountry(),this.overwriteGeoCache("country",null),this.editUserProperties()),removeGeoCode:()=>(this.sigmaUserData.removeGeoCode(),this.overwriteGeoCache("code",null),this.editUserProperties()),removeGeoState:()=>(this.sigmaUserData.removeGeoState(),this.overwriteGeoCache("state",null),this.editUserProperties()),removeGeoCity:()=>(this.sigmaUserData.removeGeoCity(),this.overwriteGeoCache("city",null),this.editUserProperties()),removeGeoIp:()=>(this.sigmaUserData.removeGeoIp(),this.overwriteGeoCache("ip",null),this.editUserProperties()),removeCustomProperty:e=>(this.sigmaUserData.removeCustomProperty(e),this.editUserProperties())}}async includeForceUser(e,t=null){!e||(await this.updateCache(),this.setForceUser(e,t))}setForceUser(e,t){let r=this.cache.parse(v);if(!r.experiments)return;let s=r.experiments.find(h=>h.name===e);if(!s)return;if(!Object.keys(this.userData).includes(s.split_by)){console.warn(`Sigma warn: ${s.split_by} is missing in userData`);return}let n=Object.keys(this.userData).find(h=>h===s.split_by);if(typeof t=="number"&&t>=0){let h=s.groups[t];if(!h){console.warn(`Sigma warn: Experiment ${e} has not group with index ${t}`);return}this.clearForcedList(s,n),this.userData[n]&&!h.forced_user_list.includes(String(this.userData[n]))&&h.forced_user_list.push(String(this.userData[n]))}else t||(this.clearForcedList(s,n),this.userData[n]&&!s.forced_user_list.includes(String(this.userData[n]))&&s.forced_user_list.push(String(this.userData[n])));if(!this.cache.get(w))this.cache.set(w,JSON.stringify([{experimentId:e,groupIndex:t}]));else{let h=this.cache.parse(w),d=h.find(g=>g.experimentId===e);d?typeof t=="number"&&t>=0&&d?(d.groupIndex=t,this.cache.set(w,JSON.stringify(h))):!t&&d&&(d.groupIndex=t,this.cache.set(w,JSON.stringify(h))):(h.push({experimentId:e,groupIndex:t}),this.cache.set(w,JSON.stringify(h)))}this.cache.set(v,JSON.stringify(r))}clearForcedList(e,t){e.forced_user_list.includes(String(this.userData[t]))&&(e.forced_user_list=e.forced_user_list.filter(r=>String(r)!==String(this.userData[t])));for(let r of e.groups)r.forced_user_list.includes(String(this.userData[t]))&&(r.forced_user_list=r.forced_user_list.filter(s=>String(s)!==String(this.userData[t])))}async excludeForceUser(e){if(!e||!this.cache.get(v)||!this.cache.get(w))return;let t=this.cache.parse(v);if(!t||!t.experiments)return;let r=t.experiments.find(n=>n.name===e);if(!r){console.warn(`Sigma warn: Experiment ${e} not found`);return}if(!Object.keys(this.userData).includes(r.split_by)){console.warn(`Sigma warn: ${r.split_by} is missing in userData`);return}let s=this.cache.parse(w);!s.find(n=>n.experimentId===e)||(s=s.filter(n=>n.experimentId!==e),s.length>0?this.cache.set(w,JSON.stringify(s)):this.cache.remove(w),this.cache.set(O,""),await this.saveToCache())}async excludeForceUserAll(){!this.cache.get(v)||!this.cache.get(w)||(this.cache.remove(w),this.cache.set(O,""),await this.saveToCache())}checkForceExperiments(){if(!this.cache.get(w))return;let e=JSON.parse(this.cache.get(w));for(let t of e)this.setForceUser(t.experimentId,t.groupIndex)}},tt=we;0&&(module.exports={});
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+
28
+ // node_modules/ua-parser-js/src/ua-parser.js
29
+ var require_ua_parser = __commonJS({
30
+ "node_modules/ua-parser-js/src/ua-parser.js"(exports, module2) {
31
+ (function(window2, undefined2) {
32
+ "use strict";
33
+ var LIBVERSION = "1.0.35", EMPTY = "", UNKNOWN = "?", FUNC_TYPE = "function", UNDEF_TYPE = "undefined", OBJ_TYPE = "object", STR_TYPE = "string", MAJOR = "major", MODEL = "model", NAME = "name", TYPE = "type", VENDOR = "vendor", VERSION = "version", ARCHITECTURE = "architecture", CONSOLE = "console", MOBILE = "mobile", TABLET = "tablet", SMARTTV = "smarttv", WEARABLE = "wearable", EMBEDDED = "embedded", UA_MAX_LENGTH = 350;
34
+ var AMAZON = "Amazon", APPLE = "Apple", ASUS = "ASUS", BLACKBERRY = "BlackBerry", BROWSER = "Browser", CHROME = "Chrome", EDGE = "Edge", FIREFOX = "Firefox", GOOGLE = "Google", HUAWEI = "Huawei", LG = "LG", MICROSOFT = "Microsoft", MOTOROLA = "Motorola", OPERA = "Opera", SAMSUNG = "Samsung", SHARP = "Sharp", SONY = "Sony", VIERA = "Viera", XIAOMI = "Xiaomi", ZEBRA = "Zebra", FACEBOOK = "Facebook", CHROMIUM_OS = "Chromium OS", MAC_OS = "Mac OS";
35
+ var extend = function(regexes2, extensions) {
36
+ var mergedRegexes = {};
37
+ for (var i in regexes2) {
38
+ if (extensions[i] && extensions[i].length % 2 === 0) {
39
+ mergedRegexes[i] = extensions[i].concat(regexes2[i]);
40
+ } else {
41
+ mergedRegexes[i] = regexes2[i];
42
+ }
43
+ }
44
+ return mergedRegexes;
45
+ }, enumerize = function(arr) {
46
+ var enums = {};
47
+ for (var i = 0; i < arr.length; i++) {
48
+ enums[arr[i].toUpperCase()] = arr[i];
49
+ }
50
+ return enums;
51
+ }, has = function(str1, str2) {
52
+ return typeof str1 === STR_TYPE ? lowerize(str2).indexOf(lowerize(str1)) !== -1 : false;
53
+ }, lowerize = function(str) {
54
+ return str.toLowerCase();
55
+ }, majorize = function(version2) {
56
+ return typeof version2 === STR_TYPE ? version2.replace(/[^\d\.]/g, EMPTY).split(".")[0] : undefined2;
57
+ }, trim = function(str, len2) {
58
+ if (typeof str === STR_TYPE) {
59
+ str = str.replace(/^\s\s*/, EMPTY);
60
+ return typeof len2 === UNDEF_TYPE ? str : str.substring(0, UA_MAX_LENGTH);
61
+ }
62
+ };
63
+ var rgxMapper = function(ua, arrays) {
64
+ var i = 0, j, k, p, q, matches, match;
65
+ while (i < arrays.length && !matches) {
66
+ var regex = arrays[i], props = arrays[i + 1];
67
+ j = k = 0;
68
+ while (j < regex.length && !matches) {
69
+ if (!regex[j]) {
70
+ break;
71
+ }
72
+ matches = regex[j++].exec(ua);
73
+ if (!!matches) {
74
+ for (p = 0; p < props.length; p++) {
75
+ match = matches[++k];
76
+ q = props[p];
77
+ if (typeof q === OBJ_TYPE && q.length > 0) {
78
+ if (q.length === 2) {
79
+ if (typeof q[1] == FUNC_TYPE) {
80
+ this[q[0]] = q[1].call(this, match);
81
+ } else {
82
+ this[q[0]] = q[1];
83
+ }
84
+ } else if (q.length === 3) {
85
+ if (typeof q[1] === FUNC_TYPE && !(q[1].exec && q[1].test)) {
86
+ this[q[0]] = match ? q[1].call(this, match, q[2]) : undefined2;
87
+ } else {
88
+ this[q[0]] = match ? match.replace(q[1], q[2]) : undefined2;
89
+ }
90
+ } else if (q.length === 4) {
91
+ this[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined2;
92
+ }
93
+ } else {
94
+ this[q] = match ? match : undefined2;
95
+ }
96
+ }
97
+ }
98
+ }
99
+ i += 2;
100
+ }
101
+ }, strMapper = function(str, map) {
102
+ for (var i in map) {
103
+ if (typeof map[i] === OBJ_TYPE && map[i].length > 0) {
104
+ for (var j = 0; j < map[i].length; j++) {
105
+ if (has(map[i][j], str)) {
106
+ return i === UNKNOWN ? undefined2 : i;
107
+ }
108
+ }
109
+ } else if (has(map[i], str)) {
110
+ return i === UNKNOWN ? undefined2 : i;
111
+ }
112
+ }
113
+ return str;
114
+ };
115
+ var oldSafariMap = {
116
+ "1.0": "/8",
117
+ "1.2": "/1",
118
+ "1.3": "/3",
119
+ "2.0": "/412",
120
+ "2.0.2": "/416",
121
+ "2.0.3": "/417",
122
+ "2.0.4": "/419",
123
+ "?": "/"
124
+ }, windowsVersionMap = {
125
+ "ME": "4.90",
126
+ "NT 3.11": "NT3.51",
127
+ "NT 4.0": "NT4.0",
128
+ "2000": "NT 5.0",
129
+ "XP": ["NT 5.1", "NT 5.2"],
130
+ "Vista": "NT 6.0",
131
+ "7": "NT 6.1",
132
+ "8": "NT 6.2",
133
+ "8.1": "NT 6.3",
134
+ "10": ["NT 6.4", "NT 10.0"],
135
+ "RT": "ARM"
136
+ };
137
+ var regexes = {
138
+ browser: [
139
+ [
140
+ /\b(?:crmo|crios)\/([\w\.]+)/i
141
+ ],
142
+ [VERSION, [NAME, "Chrome"]],
143
+ [
144
+ /edg(?:e|ios|a)?\/([\w\.]+)/i
145
+ ],
146
+ [VERSION, [NAME, "Edge"]],
147
+ [
148
+ /(opera mini)\/([-\w\.]+)/i,
149
+ /(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,
150
+ /(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i
151
+ ],
152
+ [NAME, VERSION],
153
+ [
154
+ /opios[\/ ]+([\w\.]+)/i
155
+ ],
156
+ [VERSION, [NAME, OPERA + " Mini"]],
157
+ [
158
+ /\bopr\/([\w\.]+)/i
159
+ ],
160
+ [VERSION, [NAME, OPERA]],
161
+ [
162
+ /(kindle)\/([\w\.]+)/i,
163
+ /(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,
164
+ /(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,
165
+ /(ba?idubrowser)[\/ ]?([\w\.]+)/i,
166
+ /(?:ms|\()(ie) ([\w\.]+)/i,
167
+ /(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,
168
+ /(heytap|ovi)browser\/([\d\.]+)/i,
169
+ /(weibo)__([\d\.]+)/i
170
+ ],
171
+ [NAME, VERSION],
172
+ [
173
+ /(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i
174
+ ],
175
+ [VERSION, [NAME, "UC" + BROWSER]],
176
+ [
177
+ /microm.+\bqbcore\/([\w\.]+)/i,
178
+ /\bqbcore\/([\w\.]+).+microm/i
179
+ ],
180
+ [VERSION, [NAME, "WeChat(Win) Desktop"]],
181
+ [
182
+ /micromessenger\/([\w\.]+)/i
183
+ ],
184
+ [VERSION, [NAME, "WeChat"]],
185
+ [
186
+ /konqueror\/([\w\.]+)/i
187
+ ],
188
+ [VERSION, [NAME, "Konqueror"]],
189
+ [
190
+ /trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i
191
+ ],
192
+ [VERSION, [NAME, "IE"]],
193
+ [
194
+ /ya(?:search)?browser\/([\w\.]+)/i
195
+ ],
196
+ [VERSION, [NAME, "Yandex"]],
197
+ [
198
+ /(avast|avg)\/([\w\.]+)/i
199
+ ],
200
+ [[NAME, /(.+)/, "$1 Secure " + BROWSER], VERSION],
201
+ [
202
+ /\bfocus\/([\w\.]+)/i
203
+ ],
204
+ [VERSION, [NAME, FIREFOX + " Focus"]],
205
+ [
206
+ /\bopt\/([\w\.]+)/i
207
+ ],
208
+ [VERSION, [NAME, OPERA + " Touch"]],
209
+ [
210
+ /coc_coc\w+\/([\w\.]+)/i
211
+ ],
212
+ [VERSION, [NAME, "Coc Coc"]],
213
+ [
214
+ /dolfin\/([\w\.]+)/i
215
+ ],
216
+ [VERSION, [NAME, "Dolphin"]],
217
+ [
218
+ /coast\/([\w\.]+)/i
219
+ ],
220
+ [VERSION, [NAME, OPERA + " Coast"]],
221
+ [
222
+ /miuibrowser\/([\w\.]+)/i
223
+ ],
224
+ [VERSION, [NAME, "MIUI " + BROWSER]],
225
+ [
226
+ /fxios\/([-\w\.]+)/i
227
+ ],
228
+ [VERSION, [NAME, FIREFOX]],
229
+ [
230
+ /\bqihu|(qi?ho?o?|360)browser/i
231
+ ],
232
+ [[NAME, "360 " + BROWSER]],
233
+ [
234
+ /(oculus|samsung|sailfish|huawei)browser\/([\w\.]+)/i
235
+ ],
236
+ [[NAME, /(.+)/, "$1 " + BROWSER], VERSION],
237
+ [
238
+ /(comodo_dragon)\/([\w\.]+)/i
239
+ ],
240
+ [[NAME, /_/g, " "], VERSION],
241
+ [
242
+ /(electron)\/([\w\.]+) safari/i,
243
+ /(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,
244
+ /m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i
245
+ ],
246
+ [NAME, VERSION],
247
+ [
248
+ /(metasr)[\/ ]?([\w\.]+)/i,
249
+ /(lbbrowser)/i,
250
+ /\[(linkedin)app\]/i
251
+ ],
252
+ [NAME],
253
+ [
254
+ /((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i
255
+ ],
256
+ [[NAME, FACEBOOK], VERSION],
257
+ [
258
+ /(kakao(?:talk|story))[\/ ]([\w\.]+)/i,
259
+ /(naver)\(.*?(\d+\.[\w\.]+).*\)/i,
260
+ /safari (line)\/([\w\.]+)/i,
261
+ /\b(line)\/([\w\.]+)\/iab/i,
262
+ /(chromium|instagram)[\/ ]([-\w\.]+)/i
263
+ ],
264
+ [NAME, VERSION],
265
+ [
266
+ /\bgsa\/([\w\.]+) .*safari\//i
267
+ ],
268
+ [VERSION, [NAME, "GSA"]],
269
+ [
270
+ /musical_ly(?:.+app_?version\/|_)([\w\.]+)/i
271
+ ],
272
+ [VERSION, [NAME, "TikTok"]],
273
+ [
274
+ /headlesschrome(?:\/([\w\.]+)| )/i
275
+ ],
276
+ [VERSION, [NAME, CHROME + " Headless"]],
277
+ [
278
+ / wv\).+(chrome)\/([\w\.]+)/i
279
+ ],
280
+ [[NAME, CHROME + " WebView"], VERSION],
281
+ [
282
+ /droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i
283
+ ],
284
+ [VERSION, [NAME, "Android " + BROWSER]],
285
+ [
286
+ /(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i
287
+ ],
288
+ [NAME, VERSION],
289
+ [
290
+ /version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i
291
+ ],
292
+ [VERSION, [NAME, "Mobile Safari"]],
293
+ [
294
+ /version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i
295
+ ],
296
+ [VERSION, NAME],
297
+ [
298
+ /webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i
299
+ ],
300
+ [NAME, [VERSION, strMapper, oldSafariMap]],
301
+ [
302
+ /(webkit|khtml)\/([\w\.]+)/i
303
+ ],
304
+ [NAME, VERSION],
305
+ [
306
+ /(navigator|netscape\d?)\/([-\w\.]+)/i
307
+ ],
308
+ [[NAME, "Netscape"], VERSION],
309
+ [
310
+ /mobile vr; rv:([\w\.]+)\).+firefox/i
311
+ ],
312
+ [VERSION, [NAME, FIREFOX + " Reality"]],
313
+ [
314
+ /ekiohf.+(flow)\/([\w\.]+)/i,
315
+ /(swiftfox)/i,
316
+ /(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,
317
+ /(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,
318
+ /(firefox)\/([\w\.]+)/i,
319
+ /(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,
320
+ /(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,
321
+ /(links) \(([\w\.]+)/i,
322
+ /panasonic;(viera)/i
323
+ ],
324
+ [NAME, VERSION],
325
+ [
326
+ /(cobalt)\/([\w\.]+)/i
327
+ ],
328
+ [NAME, [VERSION, /master.|lts./, ""]]
329
+ ],
330
+ cpu: [
331
+ [
332
+ /(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i
333
+ ],
334
+ [[ARCHITECTURE, "amd64"]],
335
+ [
336
+ /(ia32(?=;))/i
337
+ ],
338
+ [[ARCHITECTURE, lowerize]],
339
+ [
340
+ /((?:i[346]|x)86)[;\)]/i
341
+ ],
342
+ [[ARCHITECTURE, "ia32"]],
343
+ [
344
+ /\b(aarch64|arm(v?8e?l?|_?64))\b/i
345
+ ],
346
+ [[ARCHITECTURE, "arm64"]],
347
+ [
348
+ /\b(arm(?:v[67])?ht?n?[fl]p?)\b/i
349
+ ],
350
+ [[ARCHITECTURE, "armhf"]],
351
+ [
352
+ /windows (ce|mobile); ppc;/i
353
+ ],
354
+ [[ARCHITECTURE, "arm"]],
355
+ [
356
+ /((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i
357
+ ],
358
+ [[ARCHITECTURE, /ower/, EMPTY, lowerize]],
359
+ [
360
+ /(sun4\w)[;\)]/i
361
+ ],
362
+ [[ARCHITECTURE, "sparc"]],
363
+ [
364
+ /((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i
365
+ ],
366
+ [[ARCHITECTURE, lowerize]]
367
+ ],
368
+ device: [
369
+ [
370
+ /\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i
371
+ ],
372
+ [MODEL, [VENDOR, SAMSUNG], [TYPE, TABLET]],
373
+ [
374
+ /\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,
375
+ /samsung[- ]([-\w]+)/i,
376
+ /sec-(sgh\w+)/i
377
+ ],
378
+ [MODEL, [VENDOR, SAMSUNG], [TYPE, MOBILE]],
379
+ [
380
+ /(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i
381
+ ],
382
+ [MODEL, [VENDOR, APPLE], [TYPE, MOBILE]],
383
+ [
384
+ /\((ipad);[-\w\),; ]+apple/i,
385
+ /applecoremedia\/[\w\.]+ \((ipad)/i,
386
+ /\b(ipad)\d\d?,\d\d?[;\]].+ios/i
387
+ ],
388
+ [MODEL, [VENDOR, APPLE], [TYPE, TABLET]],
389
+ [
390
+ /(macintosh);/i
391
+ ],
392
+ [MODEL, [VENDOR, APPLE]],
393
+ [
394
+ /\b(sh-?[altvz]?\d\d[a-ekm]?)/i
395
+ ],
396
+ [MODEL, [VENDOR, SHARP], [TYPE, MOBILE]],
397
+ [
398
+ /\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i
399
+ ],
400
+ [MODEL, [VENDOR, HUAWEI], [TYPE, TABLET]],
401
+ [
402
+ /(?:huawei|honor)([-\w ]+)[;\)]/i,
403
+ /\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i
404
+ ],
405
+ [MODEL, [VENDOR, HUAWEI], [TYPE, MOBILE]],
406
+ [
407
+ /\b(poco[\w ]+)(?: bui|\))/i,
408
+ /\b; (\w+) build\/hm\1/i,
409
+ /\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,
410
+ /\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,
411
+ /\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i
412
+ ],
413
+ [[MODEL, /_/g, " "], [VENDOR, XIAOMI], [TYPE, MOBILE]],
414
+ [
415
+ /\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i
416
+ ],
417
+ [[MODEL, /_/g, " "], [VENDOR, XIAOMI], [TYPE, TABLET]],
418
+ [
419
+ /; (\w+) bui.+ oppo/i,
420
+ /\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i
421
+ ],
422
+ [MODEL, [VENDOR, "OPPO"], [TYPE, MOBILE]],
423
+ [
424
+ /vivo (\w+)(?: bui|\))/i,
425
+ /\b(v[12]\d{3}\w?[at])(?: bui|;)/i
426
+ ],
427
+ [MODEL, [VENDOR, "Vivo"], [TYPE, MOBILE]],
428
+ [
429
+ /\b(rmx[12]\d{3})(?: bui|;|\))/i
430
+ ],
431
+ [MODEL, [VENDOR, "Realme"], [TYPE, MOBILE]],
432
+ [
433
+ /\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,
434
+ /\bmot(?:orola)?[- ](\w*)/i,
435
+ /((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i
436
+ ],
437
+ [MODEL, [VENDOR, MOTOROLA], [TYPE, MOBILE]],
438
+ [
439
+ /\b(mz60\d|xoom[2 ]{0,2}) build\//i
440
+ ],
441
+ [MODEL, [VENDOR, MOTOROLA], [TYPE, TABLET]],
442
+ [
443
+ /((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i
444
+ ],
445
+ [MODEL, [VENDOR, LG], [TYPE, TABLET]],
446
+ [
447
+ /(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,
448
+ /\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,
449
+ /\blg-?([\d\w]+) bui/i
450
+ ],
451
+ [MODEL, [VENDOR, LG], [TYPE, MOBILE]],
452
+ [
453
+ /(ideatab[-\w ]+)/i,
454
+ /lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i
455
+ ],
456
+ [MODEL, [VENDOR, "Lenovo"], [TYPE, TABLET]],
457
+ [
458
+ /(?:maemo|nokia).*(n900|lumia \d+)/i,
459
+ /nokia[-_ ]?([-\w\.]*)/i
460
+ ],
461
+ [[MODEL, /_/g, " "], [VENDOR, "Nokia"], [TYPE, MOBILE]],
462
+ [
463
+ /(pixel c)\b/i
464
+ ],
465
+ [MODEL, [VENDOR, GOOGLE], [TYPE, TABLET]],
466
+ [
467
+ /droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i
468
+ ],
469
+ [MODEL, [VENDOR, GOOGLE], [TYPE, MOBILE]],
470
+ [
471
+ /droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i
472
+ ],
473
+ [MODEL, [VENDOR, SONY], [TYPE, MOBILE]],
474
+ [
475
+ /sony tablet [ps]/i,
476
+ /\b(?:sony)?sgp\w+(?: bui|\))/i
477
+ ],
478
+ [[MODEL, "Xperia Tablet"], [VENDOR, SONY], [TYPE, TABLET]],
479
+ [
480
+ / (kb2005|in20[12]5|be20[12][59])\b/i,
481
+ /(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i
482
+ ],
483
+ [MODEL, [VENDOR, "OnePlus"], [TYPE, MOBILE]],
484
+ [
485
+ /(alexa)webm/i,
486
+ /(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i,
487
+ /(kf[a-z]+)( bui|\)).+silk\//i
488
+ ],
489
+ [MODEL, [VENDOR, AMAZON], [TYPE, TABLET]],
490
+ [
491
+ /((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i
492
+ ],
493
+ [[MODEL, /(.+)/g, "Fire Phone $1"], [VENDOR, AMAZON], [TYPE, MOBILE]],
494
+ [
495
+ /(playbook);[-\w\),; ]+(rim)/i
496
+ ],
497
+ [MODEL, VENDOR, [TYPE, TABLET]],
498
+ [
499
+ /\b((?:bb[a-f]|st[hv])100-\d)/i,
500
+ /\(bb10; (\w+)/i
501
+ ],
502
+ [MODEL, [VENDOR, BLACKBERRY], [TYPE, MOBILE]],
503
+ [
504
+ /(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i
505
+ ],
506
+ [MODEL, [VENDOR, ASUS], [TYPE, TABLET]],
507
+ [
508
+ / (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i
509
+ ],
510
+ [MODEL, [VENDOR, ASUS], [TYPE, MOBILE]],
511
+ [
512
+ /(nexus 9)/i
513
+ ],
514
+ [MODEL, [VENDOR, "HTC"], [TYPE, TABLET]],
515
+ [
516
+ /(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,
517
+ /(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,
518
+ /(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i
519
+ ],
520
+ [VENDOR, [MODEL, /_/g, " "], [TYPE, MOBILE]],
521
+ [
522
+ /droid.+; ([ab][1-7]-?[0178a]\d\d?)/i
523
+ ],
524
+ [MODEL, [VENDOR, "Acer"], [TYPE, TABLET]],
525
+ [
526
+ /droid.+; (m[1-5] note) bui/i,
527
+ /\bmz-([-\w]{2,})/i
528
+ ],
529
+ [MODEL, [VENDOR, "Meizu"], [TYPE, MOBILE]],
530
+ [
531
+ /(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i,
532
+ /(hp) ([\w ]+\w)/i,
533
+ /(asus)-?(\w+)/i,
534
+ /(microsoft); (lumia[\w ]+)/i,
535
+ /(lenovo)[-_ ]?([-\w]+)/i,
536
+ /(jolla)/i,
537
+ /(oppo) ?([\w ]+) bui/i
538
+ ],
539
+ [VENDOR, MODEL, [TYPE, MOBILE]],
540
+ [
541
+ /(kobo)\s(ereader|touch)/i,
542
+ /(archos) (gamepad2?)/i,
543
+ /(hp).+(touchpad(?!.+tablet)|tablet)/i,
544
+ /(kindle)\/([\w\.]+)/i,
545
+ /(nook)[\w ]+build\/(\w+)/i,
546
+ /(dell) (strea[kpr\d ]*[\dko])/i,
547
+ /(le[- ]+pan)[- ]+(\w{1,9}) bui/i,
548
+ /(trinity)[- ]*(t\d{3}) bui/i,
549
+ /(gigaset)[- ]+(q\w{1,9}) bui/i,
550
+ /(vodafone) ([\w ]+)(?:\)| bui)/i
551
+ ],
552
+ [VENDOR, MODEL, [TYPE, TABLET]],
553
+ [
554
+ /(surface duo)/i
555
+ ],
556
+ [MODEL, [VENDOR, MICROSOFT], [TYPE, TABLET]],
557
+ [
558
+ /droid [\d\.]+; (fp\du?)(?: b|\))/i
559
+ ],
560
+ [MODEL, [VENDOR, "Fairphone"], [TYPE, MOBILE]],
561
+ [
562
+ /(u304aa)/i
563
+ ],
564
+ [MODEL, [VENDOR, "AT&T"], [TYPE, MOBILE]],
565
+ [
566
+ /\bsie-(\w*)/i
567
+ ],
568
+ [MODEL, [VENDOR, "Siemens"], [TYPE, MOBILE]],
569
+ [
570
+ /\b(rct\w+) b/i
571
+ ],
572
+ [MODEL, [VENDOR, "RCA"], [TYPE, TABLET]],
573
+ [
574
+ /\b(venue[\d ]{2,7}) b/i
575
+ ],
576
+ [MODEL, [VENDOR, "Dell"], [TYPE, TABLET]],
577
+ [
578
+ /\b(q(?:mv|ta)\w+) b/i
579
+ ],
580
+ [MODEL, [VENDOR, "Verizon"], [TYPE, TABLET]],
581
+ [
582
+ /\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i
583
+ ],
584
+ [MODEL, [VENDOR, "Barnes & Noble"], [TYPE, TABLET]],
585
+ [
586
+ /\b(tm\d{3}\w+) b/i
587
+ ],
588
+ [MODEL, [VENDOR, "NuVision"], [TYPE, TABLET]],
589
+ [
590
+ /\b(k88) b/i
591
+ ],
592
+ [MODEL, [VENDOR, "ZTE"], [TYPE, TABLET]],
593
+ [
594
+ /\b(nx\d{3}j) b/i
595
+ ],
596
+ [MODEL, [VENDOR, "ZTE"], [TYPE, MOBILE]],
597
+ [
598
+ /\b(gen\d{3}) b.+49h/i
599
+ ],
600
+ [MODEL, [VENDOR, "Swiss"], [TYPE, MOBILE]],
601
+ [
602
+ /\b(zur\d{3}) b/i
603
+ ],
604
+ [MODEL, [VENDOR, "Swiss"], [TYPE, TABLET]],
605
+ [
606
+ /\b((zeki)?tb.*\b) b/i
607
+ ],
608
+ [MODEL, [VENDOR, "Zeki"], [TYPE, TABLET]],
609
+ [
610
+ /\b([yr]\d{2}) b/i,
611
+ /\b(dragon[- ]+touch |dt)(\w{5}) b/i
612
+ ],
613
+ [[VENDOR, "Dragon Touch"], MODEL, [TYPE, TABLET]],
614
+ [
615
+ /\b(ns-?\w{0,9}) b/i
616
+ ],
617
+ [MODEL, [VENDOR, "Insignia"], [TYPE, TABLET]],
618
+ [
619
+ /\b((nxa|next)-?\w{0,9}) b/i
620
+ ],
621
+ [MODEL, [VENDOR, "NextBook"], [TYPE, TABLET]],
622
+ [
623
+ /\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i
624
+ ],
625
+ [[VENDOR, "Voice"], MODEL, [TYPE, MOBILE]],
626
+ [
627
+ /\b(lvtel\-)?(v1[12]) b/i
628
+ ],
629
+ [[VENDOR, "LvTel"], MODEL, [TYPE, MOBILE]],
630
+ [
631
+ /\b(ph-1) /i
632
+ ],
633
+ [MODEL, [VENDOR, "Essential"], [TYPE, MOBILE]],
634
+ [
635
+ /\b(v(100md|700na|7011|917g).*\b) b/i
636
+ ],
637
+ [MODEL, [VENDOR, "Envizen"], [TYPE, TABLET]],
638
+ [
639
+ /\b(trio[-\w\. ]+) b/i
640
+ ],
641
+ [MODEL, [VENDOR, "MachSpeed"], [TYPE, TABLET]],
642
+ [
643
+ /\btu_(1491) b/i
644
+ ],
645
+ [MODEL, [VENDOR, "Rotor"], [TYPE, TABLET]],
646
+ [
647
+ /(shield[\w ]+) b/i
648
+ ],
649
+ [MODEL, [VENDOR, "Nvidia"], [TYPE, TABLET]],
650
+ [
651
+ /(sprint) (\w+)/i
652
+ ],
653
+ [VENDOR, MODEL, [TYPE, MOBILE]],
654
+ [
655
+ /(kin\.[onetw]{3})/i
656
+ ],
657
+ [[MODEL, /\./g, " "], [VENDOR, MICROSOFT], [TYPE, MOBILE]],
658
+ [
659
+ /droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i
660
+ ],
661
+ [MODEL, [VENDOR, ZEBRA], [TYPE, TABLET]],
662
+ [
663
+ /droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i
664
+ ],
665
+ [MODEL, [VENDOR, ZEBRA], [TYPE, MOBILE]],
666
+ [
667
+ /smart-tv.+(samsung)/i
668
+ ],
669
+ [VENDOR, [TYPE, SMARTTV]],
670
+ [
671
+ /hbbtv.+maple;(\d+)/i
672
+ ],
673
+ [[MODEL, /^/, "SmartTV"], [VENDOR, SAMSUNG], [TYPE, SMARTTV]],
674
+ [
675
+ /(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i
676
+ ],
677
+ [[VENDOR, LG], [TYPE, SMARTTV]],
678
+ [
679
+ /(apple) ?tv/i
680
+ ],
681
+ [VENDOR, [MODEL, APPLE + " TV"], [TYPE, SMARTTV]],
682
+ [
683
+ /crkey/i
684
+ ],
685
+ [[MODEL, CHROME + "cast"], [VENDOR, GOOGLE], [TYPE, SMARTTV]],
686
+ [
687
+ /droid.+aft(\w)( bui|\))/i
688
+ ],
689
+ [MODEL, [VENDOR, AMAZON], [TYPE, SMARTTV]],
690
+ [
691
+ /\(dtv[\);].+(aquos)/i,
692
+ /(aquos-tv[\w ]+)\)/i
693
+ ],
694
+ [MODEL, [VENDOR, SHARP], [TYPE, SMARTTV]],
695
+ [
696
+ /(bravia[\w ]+)( bui|\))/i
697
+ ],
698
+ [MODEL, [VENDOR, SONY], [TYPE, SMARTTV]],
699
+ [
700
+ /(mitv-\w{5}) bui/i
701
+ ],
702
+ [MODEL, [VENDOR, XIAOMI], [TYPE, SMARTTV]],
703
+ [
704
+ /Hbbtv.*(technisat) (.*);/i
705
+ ],
706
+ [VENDOR, MODEL, [TYPE, SMARTTV]],
707
+ [
708
+ /\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,
709
+ /hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i
710
+ ],
711
+ [[VENDOR, trim], [MODEL, trim], [TYPE, SMARTTV]],
712
+ [
713
+ /\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i
714
+ ],
715
+ [[TYPE, SMARTTV]],
716
+ [
717
+ /(ouya)/i,
718
+ /(nintendo) ([wids3utch]+)/i
719
+ ],
720
+ [VENDOR, MODEL, [TYPE, CONSOLE]],
721
+ [
722
+ /droid.+; (shield) bui/i
723
+ ],
724
+ [MODEL, [VENDOR, "Nvidia"], [TYPE, CONSOLE]],
725
+ [
726
+ /(playstation [345portablevi]+)/i
727
+ ],
728
+ [MODEL, [VENDOR, SONY], [TYPE, CONSOLE]],
729
+ [
730
+ /\b(xbox(?: one)?(?!; xbox))[\); ]/i
731
+ ],
732
+ [MODEL, [VENDOR, MICROSOFT], [TYPE, CONSOLE]],
733
+ [
734
+ /((pebble))app/i
735
+ ],
736
+ [VENDOR, MODEL, [TYPE, WEARABLE]],
737
+ [
738
+ /(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i
739
+ ],
740
+ [MODEL, [VENDOR, APPLE], [TYPE, WEARABLE]],
741
+ [
742
+ /droid.+; (glass) \d/i
743
+ ],
744
+ [MODEL, [VENDOR, GOOGLE], [TYPE, WEARABLE]],
745
+ [
746
+ /droid.+; (wt63?0{2,3})\)/i
747
+ ],
748
+ [MODEL, [VENDOR, ZEBRA], [TYPE, WEARABLE]],
749
+ [
750
+ /(quest( 2| pro)?)/i
751
+ ],
752
+ [MODEL, [VENDOR, FACEBOOK], [TYPE, WEARABLE]],
753
+ [
754
+ /(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i
755
+ ],
756
+ [VENDOR, [TYPE, EMBEDDED]],
757
+ [
758
+ /(aeobc)\b/i
759
+ ],
760
+ [MODEL, [VENDOR, AMAZON], [TYPE, EMBEDDED]],
761
+ [
762
+ /droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i
763
+ ],
764
+ [MODEL, [TYPE, MOBILE]],
765
+ [
766
+ /droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i
767
+ ],
768
+ [MODEL, [TYPE, TABLET]],
769
+ [
770
+ /\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i
771
+ ],
772
+ [[TYPE, TABLET]],
773
+ [
774
+ /(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i
775
+ ],
776
+ [[TYPE, MOBILE]],
777
+ [
778
+ /(android[-\w\. ]{0,9});.+buil/i
779
+ ],
780
+ [MODEL, [VENDOR, "Generic"]]
781
+ ],
782
+ engine: [
783
+ [
784
+ /windows.+ edge\/([\w\.]+)/i
785
+ ],
786
+ [VERSION, [NAME, EDGE + "HTML"]],
787
+ [
788
+ /webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i
789
+ ],
790
+ [VERSION, [NAME, "Blink"]],
791
+ [
792
+ /(presto)\/([\w\.]+)/i,
793
+ /(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,
794
+ /ekioh(flow)\/([\w\.]+)/i,
795
+ /(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,
796
+ /(icab)[\/ ]([23]\.[\d\.]+)/i,
797
+ /\b(libweb)/i
798
+ ],
799
+ [NAME, VERSION],
800
+ [
801
+ /rv\:([\w\.]{1,9})\b.+(gecko)/i
802
+ ],
803
+ [VERSION, NAME]
804
+ ],
805
+ os: [
806
+ [
807
+ /microsoft (windows) (vista|xp)/i
808
+ ],
809
+ [NAME, VERSION],
810
+ [
811
+ /(windows) nt 6\.2; (arm)/i,
812
+ /(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i,
813
+ /(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i
814
+ ],
815
+ [NAME, [VERSION, strMapper, windowsVersionMap]],
816
+ [
817
+ /(win(?=3|9|n)|win 9x )([nt\d\.]+)/i
818
+ ],
819
+ [[NAME, "Windows"], [VERSION, strMapper, windowsVersionMap]],
820
+ [
821
+ /ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,
822
+ /ios;fbsv\/([\d\.]+)/i,
823
+ /cfnetwork\/.+darwin/i
824
+ ],
825
+ [[VERSION, /_/g, "."], [NAME, "iOS"]],
826
+ [
827
+ /(mac os x) ?([\w\. ]*)/i,
828
+ /(macintosh|mac_powerpc\b)(?!.+haiku)/i
829
+ ],
830
+ [[NAME, MAC_OS], [VERSION, /_/g, "."]],
831
+ [
832
+ /droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i
833
+ ],
834
+ [VERSION, NAME],
835
+ [
836
+ /(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,
837
+ /(blackberry)\w*\/([\w\.]*)/i,
838
+ /(tizen|kaios)[\/ ]([\w\.]+)/i,
839
+ /\((series40);/i
840
+ ],
841
+ [NAME, VERSION],
842
+ [
843
+ /\(bb(10);/i
844
+ ],
845
+ [VERSION, [NAME, BLACKBERRY]],
846
+ [
847
+ /(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i
848
+ ],
849
+ [VERSION, [NAME, "Symbian"]],
850
+ [
851
+ /mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i
852
+ ],
853
+ [VERSION, [NAME, FIREFOX + " OS"]],
854
+ [
855
+ /web0s;.+rt(tv)/i,
856
+ /\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i
857
+ ],
858
+ [VERSION, [NAME, "webOS"]],
859
+ [
860
+ /watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i
861
+ ],
862
+ [VERSION, [NAME, "watchOS"]],
863
+ [
864
+ /crkey\/([\d\.]+)/i
865
+ ],
866
+ [VERSION, [NAME, CHROME + "cast"]],
867
+ [
868
+ /(cros) [\w]+(?:\)| ([\w\.]+)\b)/i
869
+ ],
870
+ [[NAME, CHROMIUM_OS], VERSION],
871
+ [
872
+ /panasonic;(viera)/i,
873
+ /(netrange)mmh/i,
874
+ /(nettv)\/(\d+\.[\w\.]+)/i,
875
+ /(nintendo|playstation) ([wids345portablevuch]+)/i,
876
+ /(xbox); +xbox ([^\);]+)/i,
877
+ /\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,
878
+ /(mint)[\/\(\) ]?(\w*)/i,
879
+ /(mageia|vectorlinux)[; ]/i,
880
+ /([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,
881
+ /(hurd|linux) ?([\w\.]*)/i,
882
+ /(gnu) ?([\w\.]*)/i,
883
+ /\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,
884
+ /(haiku) (\w+)/i
885
+ ],
886
+ [NAME, VERSION],
887
+ [
888
+ /(sunos) ?([\w\.\d]*)/i
889
+ ],
890
+ [[NAME, "Solaris"], VERSION],
891
+ [
892
+ /((?:open)?solaris)[-\/ ]?([\w\.]*)/i,
893
+ /(aix) ((\d)(?=\.|\)| )[\w\.])*/i,
894
+ /\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,
895
+ /(unix) ?([\w\.]*)/i
896
+ ],
897
+ [NAME, VERSION]
898
+ ]
899
+ };
900
+ var UAParser2 = function(ua, extensions) {
901
+ if (typeof ua === OBJ_TYPE) {
902
+ extensions = ua;
903
+ ua = undefined2;
904
+ }
905
+ if (!(this instanceof UAParser2)) {
906
+ return new UAParser2(ua, extensions).getResult();
907
+ }
908
+ var _navigator = typeof window2 !== UNDEF_TYPE && window2.navigator ? window2.navigator : undefined2;
909
+ var _ua = ua || (_navigator && _navigator.userAgent ? _navigator.userAgent : EMPTY);
910
+ var _uach = _navigator && _navigator.userAgentData ? _navigator.userAgentData : undefined2;
911
+ var _rgxmap = extensions ? extend(regexes, extensions) : regexes;
912
+ var _isSelfNav = _navigator && _navigator.userAgent == _ua;
913
+ this.getBrowser = function() {
914
+ var _browser = {};
915
+ _browser[NAME] = undefined2;
916
+ _browser[VERSION] = undefined2;
917
+ rgxMapper.call(_browser, _ua, _rgxmap.browser);
918
+ _browser[MAJOR] = majorize(_browser[VERSION]);
919
+ if (_isSelfNav && _navigator && _navigator.brave && typeof _navigator.brave.isBrave == FUNC_TYPE) {
920
+ _browser[NAME] = "Brave";
921
+ }
922
+ return _browser;
923
+ };
924
+ this.getCPU = function() {
925
+ var _cpu = {};
926
+ _cpu[ARCHITECTURE] = undefined2;
927
+ rgxMapper.call(_cpu, _ua, _rgxmap.cpu);
928
+ return _cpu;
929
+ };
930
+ this.getDevice = function() {
931
+ var _device = {};
932
+ _device[VENDOR] = undefined2;
933
+ _device[MODEL] = undefined2;
934
+ _device[TYPE] = undefined2;
935
+ rgxMapper.call(_device, _ua, _rgxmap.device);
936
+ if (_isSelfNav && !_device[TYPE] && _uach && _uach.mobile) {
937
+ _device[TYPE] = MOBILE;
938
+ }
939
+ if (_isSelfNav && _device[MODEL] == "Macintosh" && _navigator && typeof _navigator.standalone !== UNDEF_TYPE && _navigator.maxTouchPoints && _navigator.maxTouchPoints > 2) {
940
+ _device[MODEL] = "iPad";
941
+ _device[TYPE] = TABLET;
942
+ }
943
+ return _device;
944
+ };
945
+ this.getEngine = function() {
946
+ var _engine = {};
947
+ _engine[NAME] = undefined2;
948
+ _engine[VERSION] = undefined2;
949
+ rgxMapper.call(_engine, _ua, _rgxmap.engine);
950
+ return _engine;
951
+ };
952
+ this.getOS = function() {
953
+ var _os = {};
954
+ _os[NAME] = undefined2;
955
+ _os[VERSION] = undefined2;
956
+ rgxMapper.call(_os, _ua, _rgxmap.os);
957
+ if (_isSelfNav && !_os[NAME] && _uach && _uach.platform != "Unknown") {
958
+ _os[NAME] = _uach.platform.replace(/chrome os/i, CHROMIUM_OS).replace(/macos/i, MAC_OS);
959
+ }
960
+ return _os;
961
+ };
962
+ this.getResult = function() {
963
+ return {
964
+ ua: this.getUA(),
965
+ browser: this.getBrowser(),
966
+ engine: this.getEngine(),
967
+ os: this.getOS(),
968
+ device: this.getDevice(),
969
+ cpu: this.getCPU()
970
+ };
971
+ };
972
+ this.getUA = function() {
973
+ return _ua;
974
+ };
975
+ this.setUA = function(ua2) {
976
+ _ua = typeof ua2 === STR_TYPE && ua2.length > UA_MAX_LENGTH ? trim(ua2, UA_MAX_LENGTH) : ua2;
977
+ return this;
978
+ };
979
+ this.setUA(_ua);
980
+ return this;
981
+ };
982
+ UAParser2.VERSION = LIBVERSION;
983
+ UAParser2.BROWSER = enumerize([NAME, VERSION, MAJOR]);
984
+ UAParser2.CPU = enumerize([ARCHITECTURE]);
985
+ UAParser2.DEVICE = enumerize([MODEL, VENDOR, TYPE, CONSOLE, MOBILE, SMARTTV, TABLET, WEARABLE, EMBEDDED]);
986
+ UAParser2.ENGINE = UAParser2.OS = enumerize([NAME, VERSION]);
987
+ if (typeof exports !== UNDEF_TYPE) {
988
+ if (typeof module2 !== UNDEF_TYPE && module2.exports) {
989
+ exports = module2.exports = UAParser2;
990
+ }
991
+ exports.UAParser = UAParser2;
992
+ } else {
993
+ if (typeof define === FUNC_TYPE && define.amd) {
994
+ define(function() {
995
+ return UAParser2;
996
+ });
997
+ } else if (typeof window2 !== UNDEF_TYPE) {
998
+ window2.UAParser = UAParser2;
999
+ }
1000
+ }
1001
+ var $ = typeof window2 !== UNDEF_TYPE && (window2.jQuery || window2.Zepto);
1002
+ if ($ && !$.ua) {
1003
+ var parser = new UAParser2();
1004
+ $.ua = parser.getResult();
1005
+ $.ua.get = function() {
1006
+ return parser.getUA();
1007
+ };
1008
+ $.ua.set = function(ua) {
1009
+ parser.setUA(ua);
1010
+ var result = parser.getResult();
1011
+ for (var prop in result) {
1012
+ $.ua[prop] = result[prop];
1013
+ }
1014
+ };
1015
+ }
1016
+ })(typeof window === "object" ? window : exports);
1017
+ }
1018
+ });
1019
+
1020
+ // src/sigma.js
1021
+ var sigma_exports = {};
1022
+ __export(sigma_exports, {
1023
+ default: () => sigma_default
1024
+ });
1025
+ module.exports = __toCommonJS(sigma_exports);
1026
+ var import_node_fetch = __toESM(require("node-fetch"));
1027
+
1028
+ // src/modules/sigmaUserData.js
1029
+ var UAParser = require_ua_parser();
1030
+ var SigmaUserData = class {
1031
+ platform = ["all", "web", "spliturl", "android", "ios"];
1032
+ constructor() {
1033
+ this.user = {
1034
+ userId: null,
1035
+ profileId: null,
1036
+ deviceId: null,
1037
+ ip: null,
1038
+ email: null,
1039
+ appVersion: null,
1040
+ geo: {
1041
+ country: null,
1042
+ code: null,
1043
+ state: null,
1044
+ city: null
1045
+ },
1046
+ browser: {
1047
+ version: null,
1048
+ name: null
1049
+ },
1050
+ os: {
1051
+ version: null,
1052
+ name: null
1053
+ },
1054
+ custom: {
1055
+ name: null,
1056
+ value: null
1057
+ },
1058
+ time: null,
1059
+ date: null,
1060
+ deviceCategory: null,
1061
+ featureFlags: [],
1062
+ domain: null,
1063
+ url: null,
1064
+ query: null,
1065
+ pathname: null
1066
+ };
1067
+ }
1068
+ init({
1069
+ userId,
1070
+ profileId,
1071
+ deviceId,
1072
+ ip,
1073
+ email,
1074
+ appVersion,
1075
+ custom,
1076
+ deviceCategory,
1077
+ os,
1078
+ browser,
1079
+ geo,
1080
+ domain,
1081
+ url,
1082
+ query,
1083
+ pathname
1084
+ }) {
1085
+ this.user.userId = userId;
1086
+ this.user.profileId = profileId;
1087
+ this.user.deviceId = deviceId;
1088
+ this.user.ip = ip;
1089
+ this.user.email = email;
1090
+ this.user.appVersion = appVersion;
1091
+ this.user.custom = custom;
1092
+ this.user.time = new Date().getTime() / (1e3 * 60 * 60);
1093
+ this.user.date = Math.floor(new Date().getTime() / (1e3 * 60 * 60 * 24));
1094
+ this.user.deviceCategory = deviceCategory;
1095
+ this.user.os = os;
1096
+ this.user.browser = browser;
1097
+ this.user.geo = geo;
1098
+ this.user.domain = domain;
1099
+ this.user.url = url;
1100
+ this.user.query = query;
1101
+ this.user.pathname = pathname;
1102
+ }
1103
+ getUserBrowser(ua) {
1104
+ const { user } = this;
1105
+ if (!ua) {
1106
+ return user.browser = {
1107
+ name: null,
1108
+ version: null
1109
+ };
1110
+ }
1111
+ const userAgentParser = new UAParser(ua);
1112
+ const browser = userAgentParser.getBrowser();
1113
+ return user.browser = {
1114
+ name: browser.name || void 0,
1115
+ version: browser.version || void 0
1116
+ };
1117
+ }
1118
+ getUserOs(ua) {
1119
+ const { user } = this;
1120
+ if (!ua) {
1121
+ return user.os = {
1122
+ name: null,
1123
+ version: null
1124
+ };
1125
+ }
1126
+ const userAgentParser = new UAParser(ua);
1127
+ const os = userAgentParser.getOS();
1128
+ return user.os = {
1129
+ name: os.name || void 0,
1130
+ version: os.version || void 0
1131
+ };
1132
+ }
1133
+ setIp(ip) {
1134
+ this.user.ip = ip;
1135
+ }
1136
+ addFlag(flagName, flagRule) {
1137
+ const { user } = this;
1138
+ const userHasFlag = user.featureFlags.find((item) => item.name === flagName);
1139
+ if (!userHasFlag) {
1140
+ user.featureFlags.push({
1141
+ name: flagName,
1142
+ rule: flagRule
1143
+ });
1144
+ }
1145
+ }
1146
+ setGeo(data) {
1147
+ if (!data || typeof data !== "object" || Array.isArray(data))
1148
+ return;
1149
+ this.user.geo = data;
1150
+ }
1151
+ clearFlags() {
1152
+ this.user.featureFlags = [];
1153
+ }
1154
+ removeInjectedProperties() {
1155
+ this.user.appVersion = null;
1156
+ this.user.userId = null;
1157
+ this.user.profileId = null;
1158
+ this.user.deviceId = null;
1159
+ this.user.email = null;
1160
+ this.user.custom = { name: null, value: null };
1161
+ }
1162
+ setUserId(userId) {
1163
+ if (!userId)
1164
+ this.user.userId = null;
1165
+ this.user.userId = userId;
1166
+ }
1167
+ setDeviceId(deviceId) {
1168
+ if (!deviceId)
1169
+ this.user.deviceId = null;
1170
+ this.user.deviceId = deviceId;
1171
+ }
1172
+ setProfileId(profileId) {
1173
+ if (!profileId)
1174
+ this.user.profileId = null;
1175
+ this.user.profileId = profileId;
1176
+ }
1177
+ setEmail(email) {
1178
+ if (!email)
1179
+ this.user.email = null;
1180
+ this.user.email = email;
1181
+ }
1182
+ setAppVersion(appVersion) {
1183
+ if (!appVersion)
1184
+ this.user.appVersion = null;
1185
+ this.user.appVersion = appVersion;
1186
+ }
1187
+ setBrowserName(browserName) {
1188
+ if (!browserName)
1189
+ return;
1190
+ this.user.browser.name = browserName;
1191
+ }
1192
+ setBrowserVersion(browserVersion) {
1193
+ if (!browserVersion)
1194
+ return;
1195
+ this.user.browser.version = browserVersion;
1196
+ }
1197
+ setOsName(osName) {
1198
+ if (!osName)
1199
+ return;
1200
+ this.user.os.name = osName;
1201
+ }
1202
+ setOsVersion(osVersion) {
1203
+ if (!osVersion)
1204
+ return;
1205
+ this.user.os.version = osVersion;
1206
+ }
1207
+ setGeoCountry(country) {
1208
+ this.user.geo.country = country;
1209
+ }
1210
+ setGeoCode(code) {
1211
+ this.user.geo.code = code;
1212
+ }
1213
+ setGeoState(state) {
1214
+ this.user.geo.state = state;
1215
+ }
1216
+ setGeoCity(city) {
1217
+ this.user.geo.city = city;
1218
+ }
1219
+ setGeoIp(ip) {
1220
+ this.user.geo.ip = ip;
1221
+ }
1222
+ setCustomProperty(key, value) {
1223
+ if (typeof key !== "string")
1224
+ return;
1225
+ this.user.custom = { ...this.user.custom, [key]: value };
1226
+ }
1227
+ removeUserId() {
1228
+ this.user.userId = null;
1229
+ }
1230
+ removeDeviceId() {
1231
+ this.user.deviceId = null;
1232
+ }
1233
+ removeProfileId() {
1234
+ this.user.profileId = null;
1235
+ }
1236
+ removeEmail() {
1237
+ this.user.email = null;
1238
+ }
1239
+ removeAppVersion() {
1240
+ this.user.appVersion = null;
1241
+ }
1242
+ removeBrowserName() {
1243
+ this.user.browser.name = null;
1244
+ }
1245
+ removeBrowserVersion() {
1246
+ this.user.browser.version = null;
1247
+ }
1248
+ removeOsName() {
1249
+ this.user.os.name = null;
1250
+ }
1251
+ removeOsVersion() {
1252
+ this.user.os.version = null;
1253
+ }
1254
+ removeGeoCountry() {
1255
+ this.user.geo.country = null;
1256
+ }
1257
+ removeGeoCode() {
1258
+ this.user.geo.code = null;
1259
+ }
1260
+ removeGeoState() {
1261
+ this.user.geo.state = null;
1262
+ }
1263
+ removeGeoCity() {
1264
+ this.user.geo.city = null;
1265
+ }
1266
+ removeGeoIp() {
1267
+ this.user.geo.ip = null;
1268
+ }
1269
+ removeCustomProperty(key) {
1270
+ if (!key || typeof key !== "string")
1271
+ return;
1272
+ delete this.user.custom[key];
1273
+ }
1274
+ };
1275
+
1276
+ // src/modules/sigmaCache.js
1277
+ var import_node_cache = __toESM(require("node-cache"));
1278
+
1279
+ // src/modules/sigmaHashes.js
1280
+ var Hashes;
1281
+ function utf8Encode(str) {
1282
+ var x, y, output = "", i = -1, l;
1283
+ if (str && str.length) {
1284
+ l = str.length;
1285
+ while ((i += 1) < l) {
1286
+ x = str.charCodeAt(i);
1287
+ y = i + 1 < l ? str.charCodeAt(i + 1) : 0;
1288
+ if (55296 <= x && x <= 56319 && 56320 <= y && y <= 57343) {
1289
+ x = 65536 + ((x & 1023) << 10) + (y & 1023);
1290
+ i += 1;
1291
+ }
1292
+ if (x <= 127) {
1293
+ output += String.fromCharCode(x);
1294
+ } else if (x <= 2047) {
1295
+ output += String.fromCharCode(
1296
+ 192 | x >>> 6 & 31,
1297
+ 128 | x & 63
1298
+ );
1299
+ } else if (x <= 65535) {
1300
+ output += String.fromCharCode(
1301
+ 224 | x >>> 12 & 15,
1302
+ 128 | x >>> 6 & 63,
1303
+ 128 | x & 63
1304
+ );
1305
+ } else if (x <= 2097151) {
1306
+ output += String.fromCharCode(
1307
+ 240 | x >>> 18 & 7,
1308
+ 128 | x >>> 12 & 63,
1309
+ 128 | x >>> 6 & 63,
1310
+ 128 | x & 63
1311
+ );
1312
+ }
1313
+ }
1314
+ }
1315
+ return output;
1316
+ }
1317
+ function utf8Decode(str) {
1318
+ var i, ac, c1, c2, c3, arr = [], l;
1319
+ i = ac = c1 = c2 = c3 = 0;
1320
+ if (str && str.length) {
1321
+ l = str.length;
1322
+ str += "";
1323
+ while (i < l) {
1324
+ c1 = str.charCodeAt(i);
1325
+ ac += 1;
1326
+ if (c1 < 128) {
1327
+ arr[ac] = String.fromCharCode(c1);
1328
+ i += 1;
1329
+ } else if (c1 > 191 && c1 < 224) {
1330
+ c2 = str.charCodeAt(i + 1);
1331
+ arr[ac] = String.fromCharCode((c1 & 31) << 6 | c2 & 63);
1332
+ i += 2;
1333
+ } else {
1334
+ c2 = str.charCodeAt(i + 1);
1335
+ c3 = str.charCodeAt(i + 2);
1336
+ arr[ac] = String.fromCharCode(
1337
+ (c1 & 15) << 12 | (c2 & 63) << 6 | c3 & 63
1338
+ );
1339
+ i += 3;
1340
+ }
1341
+ }
1342
+ }
1343
+ return arr.join("");
1344
+ }
1345
+ function safe_add(x, y) {
1346
+ var lsw = (x & 65535) + (y & 65535), msw = (x >> 16) + (y >> 16) + (lsw >> 16);
1347
+ return msw << 16 | lsw & 65535;
1348
+ }
1349
+ function bit_rol(num, cnt) {
1350
+ return num << cnt | num >>> 32 - cnt;
1351
+ }
1352
+ function rstr2hex(input, hexcase) {
1353
+ var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef", output = "", x, i = 0, l = input.length;
1354
+ for (; i < l; i += 1) {
1355
+ x = input.charCodeAt(i);
1356
+ output += hex_tab.charAt(x >>> 4 & 15) + hex_tab.charAt(x & 15);
1357
+ }
1358
+ return output;
1359
+ }
1360
+ function binb2rstr(input) {
1361
+ var i, l = input.length * 32, output = "";
1362
+ for (i = 0; i < l; i += 8) {
1363
+ output += String.fromCharCode(input[i >> 5] >>> 24 - i % 32 & 255);
1364
+ }
1365
+ return output;
1366
+ }
1367
+ function binl2rstr(input) {
1368
+ var i, l = input.length * 32, output = "";
1369
+ for (i = 0; i < l; i += 8) {
1370
+ output += String.fromCharCode(input[i >> 5] >>> i % 32 & 255);
1371
+ }
1372
+ return output;
1373
+ }
1374
+ function rstr2binl(input) {
1375
+ var i, l = input.length * 8, output = Array(input.length >> 2), lo = output.length;
1376
+ for (i = 0; i < lo; i += 1) {
1377
+ output[i] = 0;
1378
+ }
1379
+ for (i = 0; i < l; i += 8) {
1380
+ output[i >> 5] |= (input.charCodeAt(i / 8) & 255) << i % 32;
1381
+ }
1382
+ return output;
1383
+ }
1384
+ function rstr2binb(input) {
1385
+ var i, l = input.length * 8, output = Array(input.length >> 2), lo = output.length;
1386
+ for (i = 0; i < lo; i += 1) {
1387
+ output[i] = 0;
1388
+ }
1389
+ for (i = 0; i < l; i += 8) {
1390
+ output[i >> 5] |= (input.charCodeAt(i / 8) & 255) << 24 - i % 32;
1391
+ }
1392
+ return output;
1393
+ }
1394
+ function rstr2any(input, encoding) {
1395
+ var divisor = encoding.length, remainders = Array(), i, q, x, ld, quotient, dividend, output, full_length;
1396
+ dividend = Array(Math.ceil(input.length / 2));
1397
+ ld = dividend.length;
1398
+ for (i = 0; i < ld; i += 1) {
1399
+ dividend[i] = input.charCodeAt(i * 2) << 8 | input.charCodeAt(i * 2 + 1);
1400
+ }
1401
+ while (dividend.length > 0) {
1402
+ quotient = Array();
1403
+ x = 0;
1404
+ for (i = 0; i < dividend.length; i += 1) {
1405
+ x = (x << 16) + dividend[i];
1406
+ q = Math.floor(x / divisor);
1407
+ x -= q * divisor;
1408
+ if (quotient.length > 0 || q > 0) {
1409
+ quotient[quotient.length] = q;
1410
+ }
1411
+ }
1412
+ remainders[remainders.length] = x;
1413
+ dividend = quotient;
1414
+ }
1415
+ output = "";
1416
+ for (i = remainders.length - 1; i >= 0; i--) {
1417
+ output += encoding.charAt(remainders[i]);
1418
+ }
1419
+ full_length = Math.ceil(
1420
+ input.length * 8 / (Math.log(encoding.length) / Math.log(2))
1421
+ );
1422
+ for (i = output.length; i < full_length; i += 1) {
1423
+ output = encoding[0] + output;
1424
+ }
1425
+ return output;
1426
+ }
1427
+ function rstr2b64(input, b64pad) {
1428
+ var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", output = "", len2 = input.length, i, j, triplet;
1429
+ b64pad = b64pad || "=";
1430
+ for (i = 0; i < len2; i += 3) {
1431
+ triplet = input.charCodeAt(i) << 16 | (i + 1 < len2 ? input.charCodeAt(i + 1) << 8 : 0) | (i + 2 < len2 ? input.charCodeAt(i + 2) : 0);
1432
+ for (j = 0; j < 4; j += 1) {
1433
+ if (i * 8 + j * 6 > input.length * 8) {
1434
+ output += b64pad;
1435
+ } else {
1436
+ output += tab.charAt(triplet >>> 6 * (3 - j) & 63);
1437
+ }
1438
+ }
1439
+ }
1440
+ return output;
1441
+ }
1442
+ Hashes = {
1443
+ VERSION: "1.0.6",
1444
+ Base64: function() {
1445
+ var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", pad = "=", url = false, utf8 = true;
1446
+ this.encode = function(input) {
1447
+ var i, j, triplet, output = "";
1448
+ pad = pad || "=";
1449
+ input = utf8 ? utf8Encode(input) : input;
1450
+ len = input.length;
1451
+ for (i = 0; i < len; i += 3) {
1452
+ triplet = input.charCodeAt(i) << 16 | (i + 1 < len ? input.charCodeAt(i + 1) << 8 : 0) | (i + 2 < len ? input.charCodeAt(i + 2) : 0);
1453
+ for (j = 0; j < 4; j += 1) {
1454
+ if (i * 8 + j * 6 > len * 8) {
1455
+ output += pad;
1456
+ } else {
1457
+ output += tab.charAt(triplet >>> 6 * (3 - j) & 63);
1458
+ }
1459
+ }
1460
+ }
1461
+ return output;
1462
+ };
1463
+ this.decode = function(input) {
1464
+ var i, o1, o2, o3, h1, h2, h3, h4, bits, ac, dec = "", arr = [];
1465
+ if (!input) {
1466
+ return input;
1467
+ }
1468
+ i = ac = 0;
1469
+ input = input.replace(new RegExp("\\" + pad, "gi"), "");
1470
+ do {
1471
+ h1 = tab.indexOf(input.charAt(i++));
1472
+ h2 = tab.indexOf(input.charAt(i++));
1473
+ h3 = tab.indexOf(input.charAt(i++));
1474
+ h4 = tab.indexOf(input.charAt(i++));
1475
+ bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
1476
+ o1 = bits >> 16 & 255;
1477
+ o2 = bits >> 8 & 255;
1478
+ o3 = bits & 255;
1479
+ ac += 1;
1480
+ if (h3 === 64) {
1481
+ arr[ac] = String.fromCharCode(o1);
1482
+ } else if (h4 === 64) {
1483
+ arr[ac] = String.fromCharCode(o1, o2);
1484
+ } else {
1485
+ arr[ac] = String.fromCharCode(o1, o2, o3);
1486
+ }
1487
+ } while (i < input.length);
1488
+ dec = arr.join("");
1489
+ dec = utf8 ? utf8Decode(dec) : dec;
1490
+ return dec;
1491
+ };
1492
+ this.setPad = function(str) {
1493
+ pad = str || pad;
1494
+ return this;
1495
+ };
1496
+ this.setTab = function(str) {
1497
+ tab = str || tab;
1498
+ return this;
1499
+ };
1500
+ this.setUTF8 = function(bool) {
1501
+ if (typeof bool === "boolean") {
1502
+ utf8 = bool;
1503
+ }
1504
+ return this;
1505
+ };
1506
+ },
1507
+ CRC32: function(str) {
1508
+ var crc = 0, x = 0, y = 0, table, i, iTop;
1509
+ str = utf8Encode(str);
1510
+ table = [
1511
+ "00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 ",
1512
+ "79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 ",
1513
+ "84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F ",
1514
+ "63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD ",
1515
+ "A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC ",
1516
+ "51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 ",
1517
+ "B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 ",
1518
+ "06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 ",
1519
+ "E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 ",
1520
+ "12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 ",
1521
+ "D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 ",
1522
+ "33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 ",
1523
+ "CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 ",
1524
+ "9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E ",
1525
+ "7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D ",
1526
+ "806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 ",
1527
+ "60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA ",
1528
+ "AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 ",
1529
+ "5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 ",
1530
+ "B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 ",
1531
+ "05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 ",
1532
+ "F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA ",
1533
+ "11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 ",
1534
+ "D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F ",
1535
+ "30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E ",
1536
+ "C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D"
1537
+ ].join("");
1538
+ crc = crc ^ -1;
1539
+ for (i = 0, iTop = str.length; i < iTop; i += 1) {
1540
+ y = (crc ^ str.charCodeAt(i)) & 255;
1541
+ x = "0x" + table.substr(y * 9, 8);
1542
+ crc = crc >>> 8 ^ x;
1543
+ }
1544
+ return (crc ^ -1) >>> 0;
1545
+ },
1546
+ MD5: function(options) {
1547
+ var hexcase = options && typeof options.uppercase === "boolean" ? options.uppercase : false, b64pad = options && typeof options.pad === "string" ? options.pad : "=", utf8 = options && typeof options.utf8 === "boolean" ? options.utf8 : true;
1548
+ this.hex = function(s) {
1549
+ return rstr2hex(rstr(s, utf8), hexcase);
1550
+ };
1551
+ this.setUpperCase = function(a) {
1552
+ if (typeof a === "boolean") {
1553
+ hexcase = a;
1554
+ }
1555
+ return this;
1556
+ };
1557
+ this.setPad = function(a) {
1558
+ b64pad = a || b64pad;
1559
+ return this;
1560
+ };
1561
+ this.setUTF8 = function(a) {
1562
+ if (typeof a === "boolean") {
1563
+ utf8 = a;
1564
+ }
1565
+ return this;
1566
+ };
1567
+ function rstr(s) {
1568
+ s = utf8 ? utf8Encode(s) : s;
1569
+ return binl2rstr(binl(rstr2binl(s), s.length * 8));
1570
+ }
1571
+ function rstr_hmac(key, data) {
1572
+ var bkey, ipad, opad, hash, i;
1573
+ key = utf8 ? utf8Encode(key) : key;
1574
+ data = utf8 ? utf8Encode(data) : data;
1575
+ bkey = rstr2binl(key);
1576
+ if (bkey.length > 16) {
1577
+ bkey = binl(bkey, key.length * 8);
1578
+ }
1579
+ ipad = Array(16), opad = Array(16);
1580
+ for (i = 0; i < 16; i += 1) {
1581
+ ipad[i] = bkey[i] ^ 909522486;
1582
+ opad[i] = bkey[i] ^ 1549556828;
1583
+ }
1584
+ hash = binl(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
1585
+ return binl2rstr(binl(opad.concat(hash), 512 + 128));
1586
+ }
1587
+ function binl(x, len2) {
1588
+ var i, olda, oldb, oldc, oldd, a = 1732584193, b = -271733879, c = -1732584194, d = 271733878;
1589
+ x[len2 >> 5] |= 128 << len2 % 32;
1590
+ x[(len2 + 64 >>> 9 << 4) + 14] = len2;
1591
+ for (i = 0; i < x.length; i += 16) {
1592
+ olda = a;
1593
+ oldb = b;
1594
+ oldc = c;
1595
+ oldd = d;
1596
+ a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
1597
+ d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
1598
+ c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
1599
+ b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
1600
+ a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
1601
+ d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
1602
+ c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
1603
+ b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
1604
+ a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
1605
+ d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
1606
+ c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
1607
+ b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
1608
+ a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
1609
+ d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
1610
+ c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
1611
+ b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
1612
+ a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
1613
+ d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
1614
+ c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
1615
+ b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
1616
+ a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
1617
+ d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
1618
+ c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
1619
+ b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
1620
+ a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
1621
+ d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
1622
+ c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
1623
+ b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
1624
+ a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
1625
+ d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
1626
+ c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
1627
+ b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
1628
+ a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
1629
+ d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
1630
+ c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
1631
+ b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
1632
+ a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
1633
+ d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
1634
+ c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
1635
+ b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
1636
+ a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
1637
+ d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
1638
+ c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
1639
+ b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
1640
+ a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
1641
+ d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
1642
+ c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
1643
+ b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
1644
+ a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
1645
+ d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
1646
+ c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
1647
+ b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
1648
+ a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
1649
+ d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
1650
+ c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
1651
+ b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
1652
+ a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
1653
+ d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
1654
+ c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
1655
+ b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
1656
+ a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
1657
+ d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
1658
+ c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
1659
+ b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
1660
+ a = safe_add(a, olda);
1661
+ b = safe_add(b, oldb);
1662
+ c = safe_add(c, oldc);
1663
+ d = safe_add(d, oldd);
1664
+ }
1665
+ return Array(a, b, c, d);
1666
+ }
1667
+ function md5_cmn(q, a, b, x, s, t) {
1668
+ return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
1669
+ }
1670
+ function md5_ff(a, b, c, d, x, s, t) {
1671
+ return md5_cmn(b & c | ~b & d, a, b, x, s, t);
1672
+ }
1673
+ function md5_gg(a, b, c, d, x, s, t) {
1674
+ return md5_cmn(b & d | c & ~d, a, b, x, s, t);
1675
+ }
1676
+ function md5_hh(a, b, c, d, x, s, t) {
1677
+ return md5_cmn(b ^ c ^ d, a, b, x, s, t);
1678
+ }
1679
+ function md5_ii(a, b, c, d, x, s, t) {
1680
+ return md5_cmn(c ^ (b | ~d), a, b, x, s, t);
1681
+ }
1682
+ },
1683
+ SHA256: function(options) {
1684
+ var hexcase = options && typeof options.uppercase === "boolean" ? options.uppercase : false, b64pad = options && typeof options.pad === "string" ? options.pad : "=", utf8 = options && typeof options.utf8 === "boolean" ? options.utf8 : true, sha256_K;
1685
+ this.hex = function(s) {
1686
+ return rstr2hex(rstr(s, utf8));
1687
+ };
1688
+ this.b64 = function(s) {
1689
+ return rstr2b64(rstr(s, utf8), b64pad);
1690
+ };
1691
+ this.any = function(s, e) {
1692
+ return rstr2any(rstr(s, utf8), e);
1693
+ };
1694
+ this.raw = function(s) {
1695
+ return rstr(s, utf8);
1696
+ };
1697
+ this.hex_hmac = function(k, d) {
1698
+ return rstr2hex(rstr_hmac(k, d));
1699
+ };
1700
+ this.b64_hmac = function(k, d) {
1701
+ return rstr2b64(rstr_hmac(k, d), b64pad);
1702
+ };
1703
+ this.any_hmac = function(k, d, e) {
1704
+ return rstr2any(rstr_hmac(k, d), e);
1705
+ };
1706
+ this.vm_test = function() {
1707
+ return hex("abc").toLowerCase() === "900150983cd24fb0d6963f7d28e17f72";
1708
+ };
1709
+ this.setUpperCase = function(a) {
1710
+ if (typeof a === "boolean") {
1711
+ hexcase = a;
1712
+ }
1713
+ return this;
1714
+ };
1715
+ this.setPad = function(a) {
1716
+ b64pad = a || b64pad;
1717
+ return this;
1718
+ };
1719
+ this.setUTF8 = function(a) {
1720
+ if (typeof a === "boolean") {
1721
+ utf8 = a;
1722
+ }
1723
+ return this;
1724
+ };
1725
+ function rstr(s, utf82) {
1726
+ s = utf82 ? utf8Encode(s) : s;
1727
+ return binb2rstr(binb(rstr2binb(s), s.length * 8));
1728
+ }
1729
+ function rstr_hmac(key, data) {
1730
+ key = utf8 ? utf8Encode(key) : key;
1731
+ data = utf8 ? utf8Encode(data) : data;
1732
+ var hash, i = 0, bkey = rstr2binb(key), ipad = Array(16), opad = Array(16);
1733
+ if (bkey.length > 16) {
1734
+ bkey = binb(bkey, key.length * 8);
1735
+ }
1736
+ for (; i < 16; i += 1) {
1737
+ ipad[i] = bkey[i] ^ 909522486;
1738
+ opad[i] = bkey[i] ^ 1549556828;
1739
+ }
1740
+ hash = binb(ipad.concat(rstr2binb(data)), 512 + data.length * 8);
1741
+ return binb2rstr(binb(opad.concat(hash), 512 + 256));
1742
+ }
1743
+ function sha256_S(X, n) {
1744
+ return X >>> n | X << 32 - n;
1745
+ }
1746
+ function sha256_R(X, n) {
1747
+ return X >>> n;
1748
+ }
1749
+ function sha256_Ch(x, y, z) {
1750
+ return x & y ^ ~x & z;
1751
+ }
1752
+ function sha256_Maj(x, y, z) {
1753
+ return x & y ^ x & z ^ y & z;
1754
+ }
1755
+ function sha256_Sigma0256(x) {
1756
+ return sha256_S(x, 2) ^ sha256_S(x, 13) ^ sha256_S(x, 22);
1757
+ }
1758
+ function sha256_Sigma1256(x) {
1759
+ return sha256_S(x, 6) ^ sha256_S(x, 11) ^ sha256_S(x, 25);
1760
+ }
1761
+ function sha256_Gamma0256(x) {
1762
+ return sha256_S(x, 7) ^ sha256_S(x, 18) ^ sha256_R(x, 3);
1763
+ }
1764
+ function sha256_Gamma1256(x) {
1765
+ return sha256_S(x, 17) ^ sha256_S(x, 19) ^ sha256_R(x, 10);
1766
+ }
1767
+ function sha256_Sigma0512(x) {
1768
+ return sha256_S(x, 28) ^ sha256_S(x, 34) ^ sha256_S(x, 39);
1769
+ }
1770
+ function sha256_Sigma1512(x) {
1771
+ return sha256_S(x, 14) ^ sha256_S(x, 18) ^ sha256_S(x, 41);
1772
+ }
1773
+ function sha256_Gamma0512(x) {
1774
+ return sha256_S(x, 1) ^ sha256_S(x, 8) ^ sha256_R(x, 7);
1775
+ }
1776
+ function sha256_Gamma1512(x) {
1777
+ return sha256_S(x, 19) ^ sha256_S(x, 61) ^ sha256_R(x, 6);
1778
+ }
1779
+ sha256_K = [
1780
+ 1116352408,
1781
+ 1899447441,
1782
+ -1245643825,
1783
+ -373957723,
1784
+ 961987163,
1785
+ 1508970993,
1786
+ -1841331548,
1787
+ -1424204075,
1788
+ -670586216,
1789
+ 310598401,
1790
+ 607225278,
1791
+ 1426881987,
1792
+ 1925078388,
1793
+ -2132889090,
1794
+ -1680079193,
1795
+ -1046744716,
1796
+ -459576895,
1797
+ -272742522,
1798
+ 264347078,
1799
+ 604807628,
1800
+ 770255983,
1801
+ 1249150122,
1802
+ 1555081692,
1803
+ 1996064986,
1804
+ -1740746414,
1805
+ -1473132947,
1806
+ -1341970488,
1807
+ -1084653625,
1808
+ -958395405,
1809
+ -710438585,
1810
+ 113926993,
1811
+ 338241895,
1812
+ 666307205,
1813
+ 773529912,
1814
+ 1294757372,
1815
+ 1396182291,
1816
+ 1695183700,
1817
+ 1986661051,
1818
+ -2117940946,
1819
+ -1838011259,
1820
+ -1564481375,
1821
+ -1474664885,
1822
+ -1035236496,
1823
+ -949202525,
1824
+ -778901479,
1825
+ -694614492,
1826
+ -200395387,
1827
+ 275423344,
1828
+ 430227734,
1829
+ 506948616,
1830
+ 659060556,
1831
+ 883997877,
1832
+ 958139571,
1833
+ 1322822218,
1834
+ 1537002063,
1835
+ 1747873779,
1836
+ 1955562222,
1837
+ 2024104815,
1838
+ -2067236844,
1839
+ -1933114872,
1840
+ -1866530822,
1841
+ -1538233109,
1842
+ -1090935817,
1843
+ -965641998
1844
+ ];
1845
+ function binb(m, l) {
1846
+ var HASH = [
1847
+ 1779033703,
1848
+ -1150833019,
1849
+ 1013904242,
1850
+ -1521486534,
1851
+ 1359893119,
1852
+ -1694144372,
1853
+ 528734635,
1854
+ 1541459225
1855
+ ];
1856
+ var W = new Array(64);
1857
+ var a, b, c, d, e, f, g, h;
1858
+ var i, j, T1, T2;
1859
+ m[l >> 5] |= 128 << 24 - l % 32;
1860
+ m[(l + 64 >> 9 << 4) + 15] = l;
1861
+ for (i = 0; i < m.length; i += 16) {
1862
+ a = HASH[0];
1863
+ b = HASH[1];
1864
+ c = HASH[2];
1865
+ d = HASH[3];
1866
+ e = HASH[4];
1867
+ f = HASH[5];
1868
+ g = HASH[6];
1869
+ h = HASH[7];
1870
+ for (j = 0; j < 64; j += 1) {
1871
+ if (j < 16) {
1872
+ W[j] = m[j + i];
1873
+ } else {
1874
+ W[j] = safe_add(
1875
+ safe_add(
1876
+ safe_add(sha256_Gamma1256(W[j - 2]), W[j - 7]),
1877
+ sha256_Gamma0256(W[j - 15])
1878
+ ),
1879
+ W[j - 16]
1880
+ );
1881
+ }
1882
+ T1 = safe_add(
1883
+ safe_add(
1884
+ safe_add(safe_add(h, sha256_Sigma1256(e)), sha256_Ch(e, f, g)),
1885
+ sha256_K[j]
1886
+ ),
1887
+ W[j]
1888
+ );
1889
+ T2 = safe_add(sha256_Sigma0256(a), sha256_Maj(a, b, c));
1890
+ h = g;
1891
+ g = f;
1892
+ f = e;
1893
+ e = safe_add(d, T1);
1894
+ d = c;
1895
+ c = b;
1896
+ b = a;
1897
+ a = safe_add(T1, T2);
1898
+ }
1899
+ HASH[0] = safe_add(a, HASH[0]);
1900
+ HASH[1] = safe_add(b, HASH[1]);
1901
+ HASH[2] = safe_add(c, HASH[2]);
1902
+ HASH[3] = safe_add(d, HASH[3]);
1903
+ HASH[4] = safe_add(e, HASH[4]);
1904
+ HASH[5] = safe_add(f, HASH[5]);
1905
+ HASH[6] = safe_add(g, HASH[6]);
1906
+ HASH[7] = safe_add(h, HASH[7]);
1907
+ }
1908
+ return HASH;
1909
+ }
1910
+ }
1911
+ };
1912
+ var sigmaHashes_default = Hashes;
1913
+
1914
+ // src/helpers/constants.js
1915
+ var defaultApi = "https://api.expf.ru/api/v1";
1916
+ var sigmaPrivateId = "sigmaPrivateId";
1917
+ var sigmaHash = "sigmaHash";
1918
+ var sigmaDataFileLastUpdate = "sigmaDataFileLastUpdate";
1919
+ var sigmaDataFile = "sigmaDataFile";
1920
+ var sigmaExperiments = "sigmaExperiments";
1921
+ var sigmaHoldouts = "sigmaHoldouts";
1922
+ var sigmaGeoData = "sigmaGeoData";
1923
+ var max_decimal_64 = 18446744073709552e3;
1924
+ var zeta = 8540717056e4;
1925
+ var SHA256 = new sigmaHashes_default.SHA256();
1926
+ var MD5 = new sigmaHashes_default.MD5();
1927
+ var secondsIn24Hours = 24 * 60 * 60;
1928
+ var defaultGeoCacheTTL = 5 * 60;
1929
+ var cacheStandardTimeToLive = 3600;
1930
+ var cacheCheckPeriod = 600;
1931
+ var experimentType = {
1932
+ featureFlag: 1,
1933
+ param: 2,
1934
+ splitUrl: 3,
1935
+ webBuilder: 4,
1936
+ holdout: 5
1937
+ };
1938
+ var errorMessages = {
1939
+ emptyToken: "Please specify a token",
1940
+ APIRequestErrorConfig: {
1941
+ token: "%token%",
1942
+ userData: "%userData%",
1943
+ detail: "Invalid request to sigma config json",
1944
+ time: new Date().toLocaleString("ru-RU"),
1945
+ cache: true
1946
+ },
1947
+ APIRequestErrorGeoData: {
1948
+ token: "%token%",
1949
+ userData: "%userData%",
1950
+ detail: "Invalid request to sigma geo data",
1951
+ time: new Date().toLocaleString("ru-RU")
1952
+ },
1953
+ saveLastUpdateError: "Save last update to cache",
1954
+ isNoExperimentInCache: "Experiments not found in cache",
1955
+ badConfig: "Bad config.json"
1956
+ };
1957
+ var signsForHash = ["equal", "not equal", "any of", "none of"];
1958
+ var prefixGroup = "sigma_group";
1959
+ var warnings = {
1960
+ invalidJson: 'Sigma warning: Invalid type json "%value%" in config.',
1961
+ invalidType: 'Sigma warning: Invalid type "%type%" in config.',
1962
+ emptyHoldoutId: "Sigma warning: Empty holdout id"
1963
+ };
1964
+ var sdkName = "node.js";
1965
+ var statusSuccess = "success";
1966
+ var statusFailed = "failed";
1967
+ var status200 = 200;
1968
+ var status400 = 400;
1969
+ var sigmaForcedExperiments = "sigmaForcedExperiments";
1970
+
1971
+ // src/modules/sigmaCache.js
1972
+ var sigmaCache = new import_node_cache.default({
1973
+ stdTTL: cacheStandardTimeToLive,
1974
+ checkperiod: cacheCheckPeriod
1975
+ });
1976
+ var SigmaCache = class {
1977
+ constructor(postfix) {
1978
+ this.postfix = "";
1979
+ if (postfix)
1980
+ this.postfix = "__" + postfix;
1981
+ }
1982
+ get(key) {
1983
+ try {
1984
+ return sigmaCache.get(key + this.postfix);
1985
+ } catch (e) {
1986
+ console.log(e);
1987
+ }
1988
+ }
1989
+ set(key, value) {
1990
+ try {
1991
+ sigmaCache.set(key + this.postfix, value);
1992
+ return;
1993
+ } catch (e) {
1994
+ console.log(e);
1995
+ }
1996
+ }
1997
+ remove(key) {
1998
+ try {
1999
+ return sigmaCache.del(key + this.postfix);
2000
+ } catch (e) {
2001
+ console.log(e);
2002
+ }
2003
+ }
2004
+ parse(data) {
2005
+ if (!this.get(data)) {
2006
+ throw new Error(`${data} not found in cache`);
2007
+ }
2008
+ return JSON.parse(this.get(data));
2009
+ }
2010
+ };
2011
+
2012
+ // src/modules/sigmaGeoCache.js
2013
+ var import_node_cache2 = __toESM(require("node-cache"));
2014
+ var sigmaGeoCache = new import_node_cache2.default({
2015
+ stdTTL: cacheStandardTimeToLive,
2016
+ checkperiod: cacheCheckPeriod
2017
+ });
2018
+ var SigmaGeoCache = class {
2019
+ constructor(postfix) {
2020
+ this.postfix = "";
2021
+ if (postfix)
2022
+ this.postfix = "__" + postfix;
2023
+ }
2024
+ get(key) {
2025
+ try {
2026
+ return sigmaGeoCache.get(key + this.postfix);
2027
+ } catch (e) {
2028
+ console.log(e);
2029
+ }
2030
+ }
2031
+ set(key, value) {
2032
+ try {
2033
+ return sigmaGeoCache.set(key + this.postfix, value);
2034
+ } catch (e) {
2035
+ console.log(e);
2036
+ }
2037
+ }
2038
+ keys() {
2039
+ return sigmaGeoCache.keys();
2040
+ }
2041
+ parse(data) {
2042
+ if (!this.get(data)) {
2043
+ throw new Error(`${data} not found in cache`);
2044
+ }
2045
+ return JSON.parse(String(this.get(data)));
2046
+ }
2047
+ };
2048
+
2049
+ // src/helpers/checkBoolValue.js
2050
+ function checkBoolValue(value) {
2051
+ if (value)
2052
+ return true;
2053
+ return false;
2054
+ }
2055
+
2056
+ // src/helpers/checkForcedList.js
2057
+ function checkForcedList(usersList, data) {
2058
+ if (usersList.length) {
2059
+ for (let id in usersList) {
2060
+ if (usersList[id] == data) {
2061
+ return true;
2062
+ }
2063
+ }
2064
+ }
2065
+ return false;
2066
+ }
2067
+
2068
+ // src/helpers/compareVersions.js
2069
+ function compareVersions(versionA, versionB, strict = true) {
2070
+ let resultCompare;
2071
+ const versionsLength = Math.max(versionA.length, versionB.length);
2072
+ versionA = (versionA + "").split(".");
2073
+ versionB = (versionB + "").split(".");
2074
+ for (let i = 0; i < versionsLength; i++) {
2075
+ if (versionA[i] === void 0) {
2076
+ versionA[i] = "0";
2077
+ }
2078
+ if (versionB[i] === void 0) {
2079
+ versionB[i] = "0";
2080
+ }
2081
+ resultCompare = parseInt(versionA[i], 10) - parseInt(versionB[i], 10);
2082
+ if (resultCompare !== 0) {
2083
+ return resultCompare < 0 ? false : true;
2084
+ }
2085
+ }
2086
+ if (strict) {
2087
+ return false;
2088
+ }
2089
+ if (!strict) {
2090
+ return true;
2091
+ }
2092
+ }
2093
+
2094
+ // src/helpers/conditionOperation.js
2095
+ function conditionOperation(userValue, conditionValues, operation, date, time) {
2096
+ !operation ? operation = "=" : operation;
2097
+ if (userValue === null || typeof userValue === "undefined" || !conditionValues)
2098
+ return false;
2099
+ userValue = String(userValue);
2100
+ if (!Array.isArray(conditionValues))
2101
+ conditionValues = String(conditionValues).toLowerCase().trim();
2102
+ switch (operation.trim()) {
2103
+ case "equal":
2104
+ return userValue.toLowerCase().trim() == conditionValues;
2105
+ case "not equal":
2106
+ return userValue.toLowerCase().trim() != conditionValues;
2107
+ case "greater":
2108
+ return compareVersions(userValue.trim(), conditionValues);
2109
+ case "less":
2110
+ return compareVersions(conditionValues, userValue.trim());
2111
+ case "greater equal":
2112
+ return compareVersions(userValue.trim(), conditionValues, false);
2113
+ case "less equal":
2114
+ return compareVersions(conditionValues, userValue.trim(), false);
2115
+ case "any of":
2116
+ return conditionValues.includes(userValue);
2117
+ case "none of":
2118
+ return !conditionValues.includes(userValue);
2119
+ case "contains any of":
2120
+ for (let i = 0; i < conditionValues.length; i++) {
2121
+ if (userValue.includes(conditionValues[i])) {
2122
+ return true;
2123
+ }
2124
+ }
2125
+ return false;
2126
+ case "contains none of":
2127
+ for (let i = 0; i < conditionValues.length; i++) {
2128
+ if (userValue.includes(conditionValues[i])) {
2129
+ return false;
2130
+ }
2131
+ }
2132
+ return true;
2133
+ case "on date":
2134
+ return Math.floor(new Date(conditionValues.toString()).getTime() / (1e3 * 60 * 60 * 24)) == date;
2135
+ case "after time":
2136
+ return new Date(conditionValues.toString()).getTime() / (1e3 * 60 * 60) < time;
2137
+ case "before time":
2138
+ return new Date(conditionValues.toString()).getTime() / (1e3 * 60 * 60) > time;
2139
+ case "starts with":
2140
+ return userValue.startsWith(conditionValues);
2141
+ case "not starts with":
2142
+ return !userValue.startsWith(conditionValues);
2143
+ case "ends with":
2144
+ return userValue.endsWith(conditionValues);
2145
+ case "not ends with":
2146
+ return !userValue.endsWith(conditionValues);
2147
+ case "contains":
2148
+ return userValue.includes(conditionValues);
2149
+ case "not contains":
2150
+ return !userValue.includes(conditionValues);
2151
+ default:
2152
+ return false;
2153
+ }
2154
+ }
2155
+
2156
+ // src/helpers/digestHash.js
2157
+ function digestHash(string) {
2158
+ let hash = 0, i, chr;
2159
+ if (string.length === 0)
2160
+ return hash;
2161
+ for (i = 0; i < string.length; i++) {
2162
+ chr = string.charCodeAt(i);
2163
+ hash = (hash << 5) - hash + chr;
2164
+ hash |= 0;
2165
+ }
2166
+ return hash;
2167
+ }
2168
+
2169
+ // src/helpers/doTypeConversion.js
2170
+ function doTypeConversion(type, value) {
2171
+ if (value === "")
2172
+ return null;
2173
+ switch (type) {
2174
+ case "string":
2175
+ return value;
2176
+ case "bool":
2177
+ return value === "true" ? true : false;
2178
+ case "integer":
2179
+ case "number":
2180
+ return parseFloat(value);
2181
+ case "json":
2182
+ try {
2183
+ return JSON.parse(value);
2184
+ } catch (e) {
2185
+ console.error(warnings.invalidJson.replace("%value%", value), e);
2186
+ return null;
2187
+ }
2188
+ default:
2189
+ return value;
2190
+ }
2191
+ }
2192
+
2193
+ // src/helpers/generateRandomId.js
2194
+ function generateRandomId() {
2195
+ let text = "";
2196
+ let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
2197
+ for (let i = 0; i < 80; i++)
2198
+ text += possible.charAt(Math.floor(Math.random() * possible.length));
2199
+ return text;
2200
+ }
2201
+
2202
+ // src/helpers/getUserGroup.js
2203
+ function getUserGroup(salt, exposureRate, controlBucket, forcedExp) {
2204
+ let userInGroup = "a";
2205
+ let currentDiapason = 0;
2206
+ if (Math.abs(salt) / 100 <= parseFloat(exposureRate) * 100 || forcedExp) {
2207
+ let bucket = Math.abs(salt) % 100;
2208
+ for (let i = 0; i < controlBucket.length; i++) {
2209
+ currentDiapason += controlBucket[i].weight * 100;
2210
+ if (bucket <= currentDiapason) {
2211
+ return userInGroup = controlBucket[i].name;
2212
+ }
2213
+ }
2214
+ return userInGroup;
2215
+ }
2216
+ return false;
2217
+ }
2218
+
2219
+ // src/helpers/filterByPlatform.js
2220
+ function filterByPlatform(config, platformName) {
2221
+ if (!Object.keys(config).length)
2222
+ return;
2223
+ if (!platformName)
2224
+ return config;
2225
+ let filteredConfig = { ...config };
2226
+ const { feature_flags, experiments } = filteredConfig;
2227
+ if (filteredConfig.feature_flags)
2228
+ filteredConfig.feature_flags = generateFilteredList(feature_flags, platformName);
2229
+ if (filteredConfig.experiments)
2230
+ filteredConfig.experiments = generateFilteredList(experiments, platformName);
2231
+ return filteredConfig;
2232
+ }
2233
+ function generateFilteredList(array, name) {
2234
+ if (!array.length)
2235
+ return [];
2236
+ const userPlatforms = Array.isArray(name) ? [...name] : [name];
2237
+ const platformALL = "all";
2238
+ const platformAPP = "app";
2239
+ const platformIos = "ios";
2240
+ const platformAndroid = "android";
2241
+ if (userPlatforms.includes(platformALL))
2242
+ return array;
2243
+ array = array.filter((item) => {
2244
+ for (const index in userPlatforms) {
2245
+ if (item.platforms && item.platforms.length) {
2246
+ if (userPlatforms.includes(platformAPP) && (item.platforms.includes(platformIos) || item.platforms.includes(platformAndroid)) || userPlatforms.includes(platformIos) && item.platforms.includes(platformAPP) || userPlatforms.includes(platformAndroid) && item.platforms.includes(platformAPP) || userPlatforms.some((userPlatform) => item.platforms.includes(userPlatform.toLowerCase())))
2247
+ return item;
2248
+ } else {
2249
+ if (!item.platform || item.platform === platformALL || userPlatforms[index] === platformAPP && (item.platform === platformAndroid || item.platform === platformIos) || userPlatforms[index] === platformIos && item.platform === platformAPP || userPlatforms[index] === platformAndroid && item.platform === platformAPP || item.platform === userPlatforms[index].toLowerCase())
2250
+ return item;
2251
+ }
2252
+ }
2253
+ });
2254
+ return array;
2255
+ }
2256
+
2257
+ // package.json
2258
+ var version = "3.4.6-0";
2259
+
2260
+ // src/helpers/sdkVersion.js
2261
+ var sdkVersion = version;
2262
+
2263
+ // src/helpers/isLocalOrIPv6.js
2264
+ var blackListLocalIps = [
2265
+ ["192.168.0.0", "192.168.255.255"],
2266
+ ["172.0.0.0", "172.255.255.255"],
2267
+ ["10.0.0.0", "10.255.255.255"],
2268
+ ["127.0.0.0", "127.255.255.255"],
2269
+ ["100.64.0.0", "100.127.255.255"]
2270
+ ];
2271
+ function isLocalOrIPv6(ip) {
2272
+ let isLocalIpOrIPv6 = false;
2273
+ if (typeof ip !== "string")
2274
+ return isLocalIpOrIPv6 = true;
2275
+ const dotCount = ip.split(".").length - 1;
2276
+ if (dotCount !== 3)
2277
+ return isLocalIpOrIPv6 = true;
2278
+ function ipToNumber(ip2) {
2279
+ const parts = ip2.split(".");
2280
+ return (parseInt(parts[0]) << 24) + (parseInt(parts[1]) << 16) + (parseInt(parts[2]) << 8) + parseInt(parts[3]);
2281
+ }
2282
+ const ipNumber = ipToNumber(ip);
2283
+ for (const i in blackListLocalIps) {
2284
+ const startRange = ipToNumber(blackListLocalIps[i][0]);
2285
+ const endRange = ipToNumber(blackListLocalIps[i][1]);
2286
+ if (ipNumber >= startRange && ipNumber <= endRange) {
2287
+ isLocalIpOrIPv6 = true;
2288
+ break;
2289
+ }
2290
+ }
2291
+ return isLocalIpOrIPv6;
2292
+ }
2293
+
2294
+ // src/sigma.js
2295
+ if (typeof import_node_fetch.default.default !== "undefined")
2296
+ import_node_fetch.default.default;
2297
+ var Sigma = class {
2298
+ constructor(token, userData, cacheTTL = 10, options = {
2299
+ api: "",
2300
+ retries: "",
2301
+ postfix: "",
2302
+ geoCacheTTL: null
2303
+ }) {
2304
+ if (!token) {
2305
+ throw new Error(errorMessages.emptyToken);
2306
+ }
2307
+ this.token = token;
2308
+ this.userData = userData || {};
2309
+ cacheTTL < 10 ? this.cacheTTL = 10 : this.cacheTTL = cacheTTL;
2310
+ this.api = options.api || defaultApi;
2311
+ this.retries = options.retries || 2;
2312
+ this.postfix = options.postfix || "";
2313
+ this.sigmaUserData = new SigmaUserData();
2314
+ this.cache = new SigmaCache(this.postfix);
2315
+ this.sigmaUserData.init({
2316
+ userId: this.userData.userId || this.userData.userId === 0 ? String(this.userData.userId).trim() : null,
2317
+ profileId: this.userData.profileId || this.userData.profileId === 0 ? String(this.userData.profileId).trim() : null,
2318
+ deviceId: this.userData.deviceId || this.userData.deviceId === 0 ? String(this.userData.deviceId).trim() : null,
2319
+ ip: this.userData.ip || null,
2320
+ email: this.userData.email || null,
2321
+ appVersion: this.userData.appVersion || null,
2322
+ custom: this.userData.custom || {},
2323
+ deviceCategory: this.userData.deviceCategory || null,
2324
+ browser: this.userData.browser || this.sigmaUserData.getUserBrowser(this.userData.ua),
2325
+ os: this.userData.os || this.sigmaUserData.getUserOs(this.userData.ua),
2326
+ geo: this.userData.geo || {},
2327
+ domain: this.userData.domain || null,
2328
+ url: this.userData.url || null,
2329
+ query: this.userData.query || null,
2330
+ pathname: this.userData.pathname || null,
2331
+ ua: this.userData.ua || void 0
2332
+ });
2333
+ this.makePrivateIdInCache();
2334
+ this.geoCache = new SigmaGeoCache(`${this.cache.get(sigmaPrivateId)}__${this.token}`);
2335
+ }
2336
+ makePrivateIdInCache() {
2337
+ if (!this.cache.get(sigmaPrivateId)) {
2338
+ this.cache.set(sigmaPrivateId, generateRandomId());
2339
+ }
2340
+ }
2341
+ async getDataFile(url) {
2342
+ let data;
2343
+ let sigmaData = {
2344
+ status: null,
2345
+ statusCode: null,
2346
+ data: null
2347
+ };
2348
+ const controller = typeof AbortController !== "undefined" ? new AbortController() : null;
2349
+ try {
2350
+ data = await (0, import_node_fetch.default)(url, {
2351
+ headers: {
2352
+ ip: this.userData.ip || "",
2353
+ "X-Real-IP": this.userData.ip || "",
2354
+ token: this.token,
2355
+ "user-id": generateRandomId(),
2356
+ "sdk-name": sdkName,
2357
+ "sdk-version": sdkVersion
2358
+ },
2359
+ ...controller && { signal: controller.signal }
2360
+ });
2361
+ sigmaData.status = data.status === status200 ? statusSuccess : statusFailed;
2362
+ sigmaData.statusCode = data.status;
2363
+ sigmaData.data = data.status === status200 ? await data.json() : null;
2364
+ } catch {
2365
+ if (controller)
2366
+ controller.abort();
2367
+ sigmaData.status = statusFailed;
2368
+ sigmaData.statusCode = status400;
2369
+ sigmaData.data = null;
2370
+ }
2371
+ return sigmaData;
2372
+ }
2373
+ async getConfig() {
2374
+ let data;
2375
+ const localStorageHash = this.cache.get(sigmaHash);
2376
+ let hash;
2377
+ data = await this.getDataFile(`${this.api}/config.json`);
2378
+ if (data.status === statusSuccess) {
2379
+ if (this.userData.platform) {
2380
+ data.data = filterByPlatform(data.data, this.userData.platform);
2381
+ }
2382
+ hash = await SHA256.hex(JSON.stringify(data.data));
2383
+ if (!localStorageHash || localStorageHash !== hash) {
2384
+ this.cache.set(sigmaHash, hash);
2385
+ this.cache.set(sigmaDataFile, JSON.stringify(data.data));
2386
+ this.checkForceExperiments();
2387
+ }
2388
+ return;
2389
+ }
2390
+ if (data.status === statusFailed) {
2391
+ if (!this.cache.get(sigmaDataFile)) {
2392
+ throw new Error(errorMessages.APIRequestErrorConfig.detail);
2393
+ }
2394
+ }
2395
+ return;
2396
+ }
2397
+ async getUserGeoData() {
2398
+ if (this.userData.ip && isLocalOrIPv6(this.userData.ip)) {
2399
+ this.geoCache.set(sigmaGeoData, JSON.stringify({ location: "none" }));
2400
+ return;
2401
+ }
2402
+ if (this.userData.ip) {
2403
+ const userGeoData = await this.getDataFile(`${this.api}/geo`);
2404
+ if (userGeoData.status === statusSuccess) {
2405
+ this.geoCache.set(sigmaGeoData, JSON.stringify(userGeoData.data));
2406
+ } else {
2407
+ this.geoCache.set(sigmaGeoData, JSON.stringify({ location: "none" }));
2408
+ }
2409
+ } else if (this.userData.geo) {
2410
+ this.geoCache.set(sigmaGeoData, JSON.stringify(this.userData.geo));
2411
+ } else {
2412
+ this.geoCache.set(sigmaGeoData, JSON.stringify({ location: "none" }));
2413
+ }
2414
+ }
2415
+ recordLastUpdateInCache() {
2416
+ const timeRecord = Math.floor(Date.now() / 1e3);
2417
+ this.cache.set(sigmaDataFileLastUpdate, timeRecord);
2418
+ }
2419
+ async saveToCache() {
2420
+ try {
2421
+ await this.getConfig();
2422
+ } catch {
2423
+ errorMessages.APIRequestErrorConfig.userData = JSON.stringify(this.userData);
2424
+ errorMessages.APIRequestErrorConfig.token = this.token;
2425
+ if (!this.cache.get(sigmaDataFile)) {
2426
+ errorMessages.APIRequestErrorConfig.cache = false;
2427
+ console.error(errorMessages.APIRequestErrorConfig);
2428
+ throw new Error(JSON.stringify(errorMessages.APIRequestErrorConfig));
2429
+ } else {
2430
+ errorMessages.APIRequestErrorConfig.cache = true;
2431
+ console.error(errorMessages.APIRequestErrorConfig);
2432
+ }
2433
+ }
2434
+ this.recordLastUpdateInCache();
2435
+ }
2436
+ async saveToGeoCache() {
2437
+ try {
2438
+ await this.getUserGeoData();
2439
+ this.geoCache.get(sigmaGeoData) ? this.sigmaUserData.setGeo(this.geoCache.parse(sigmaGeoData)) : this.sigmaUserData.setGeo("{}");
2440
+ } catch (error) {
2441
+ if (!this.geoCache.get(sigmaGeoData)) {
2442
+ this.geoCache.set(sigmaGeoData, JSON.stringify({ location: "none" }));
2443
+ }
2444
+ errorMessages.APIRequestErrorGeoData.token = this.token;
2445
+ errorMessages.APIRequestErrorGeoData.userData = JSON.stringify(this.userData);
2446
+ console.error(error, errorMessages.APIRequestErrorGeoData);
2447
+ }
2448
+ }
2449
+ hasExpireCache() {
2450
+ const lastUpdate = Number(this.cache.get(sigmaDataFileLastUpdate));
2451
+ const currentTime = Math.floor(Date.now() / 1e3);
2452
+ if (currentTime > lastUpdate + this.cacheTTL) {
2453
+ return true;
2454
+ }
2455
+ return false;
2456
+ }
2457
+ updateCache() {
2458
+ if (!this.cache.get(sigmaDataFile) || this.hasExpireCache()) {
2459
+ return this.saveToCache();
2460
+ }
2461
+ }
2462
+ updateGeoCache() {
2463
+ if (!this.geoCache.get(sigmaGeoData)) {
2464
+ return this.saveToGeoCache();
2465
+ }
2466
+ }
2467
+ async getFlags() {
2468
+ await this.updateCache();
2469
+ const flags = this.cache.parse(sigmaDataFile);
2470
+ if (!flags.feature_flags)
2471
+ return;
2472
+ return flags.feature_flags;
2473
+ }
2474
+ async checkFlag(flagName) {
2475
+ if (!flagName)
2476
+ return null;
2477
+ await this.updateCache();
2478
+ await this.updateGeoCache();
2479
+ const cacheKey = this.cache.parse(sigmaDataFile);
2480
+ if (!cacheKey.feature_flags)
2481
+ return;
2482
+ let flag = null;
2483
+ const expName = this.getExperimentByFeatureFlag(cacheKey, flagName);
2484
+ if (expName) {
2485
+ const experimentByFlag = await this.getExperiment(expName).then((res) => res.getFeatureValue(flagName));
2486
+ if (experimentByFlag !== null)
2487
+ return experimentByFlag;
2488
+ }
2489
+ for (let i = 0; i < cacheKey.feature_flags.length; i++) {
2490
+ if (cacheKey.feature_flags[i]["name"] === flagName) {
2491
+ flag = cacheKey.feature_flags[i];
2492
+ break;
2493
+ }
2494
+ }
2495
+ if (!flag)
2496
+ return null;
2497
+ return this.findingSpotCondition(flag, this.sigmaUserData);
2498
+ }
2499
+ async getUserFeatureFlagsDetails() {
2500
+ const featureFlags = [];
2501
+ await this.updateCache();
2502
+ await this.updateGeoCache();
2503
+ const sigmaDataLs = await this.cache.parse(sigmaDataFile);
2504
+ if (sigmaDataLs.feature_flags.length > 0) {
2505
+ for (const flag in sigmaDataLs.feature_flags) {
2506
+ const ffName = sigmaDataLs.feature_flags[flag].name;
2507
+ const ffValue = await this.checkFlag(ffName);
2508
+ featureFlags.push({
2509
+ name: ffName,
2510
+ value: ffValue
2511
+ });
2512
+ }
2513
+ }
2514
+ return featureFlags;
2515
+ }
2516
+ getExperimentByFeatureFlag(cache, flagName) {
2517
+ for (let i = 0; i < cache.experiments.length; i++) {
2518
+ if (cache.experiments[i].feature_flags.length) {
2519
+ for (let j in cache.experiments[i].feature_flags) {
2520
+ if (cache.experiments[i].feature_flags[j].name === flagName) {
2521
+ return cache.experiments[i].name;
2522
+ }
2523
+ }
2524
+ }
2525
+ }
2526
+ return null;
2527
+ }
2528
+ getFlag(key) {
2529
+ if (!key) {
2530
+ return false;
2531
+ }
2532
+ const userFlags = this.sigmaUserData.user.featureFlags;
2533
+ let flagValue = null;
2534
+ for (let i in userFlags) {
2535
+ if (userFlags[i]["name"] === key) {
2536
+ flagValue = userFlags[i]["rule"].value;
2537
+ break;
2538
+ }
2539
+ }
2540
+ if (!flagValue) {
2541
+ return false;
2542
+ }
2543
+ return flagValue;
2544
+ }
2545
+ getUserParamValue(paramKey, privateFlag = null, isConditionSignForHash = false) {
2546
+ if (!paramKey)
2547
+ return false;
2548
+ const user = this.sigmaUserData.user;
2549
+ let defaultValue = null;
2550
+ if (paramKey.includes(".")) {
2551
+ const paramsArray = paramKey.split(".");
2552
+ const parent = paramsArray[0];
2553
+ const child = paramsArray[1];
2554
+ if (!child)
2555
+ return false;
2556
+ const isSetParentInUserData = Object.keys(user).find((i) => i === parent);
2557
+ if (!user[isSetParentInUserData])
2558
+ return false;
2559
+ const userObject = Object.entries(user[isSetParentInUserData]);
2560
+ for (let [userParamKey, userParamValue] of userObject) {
2561
+ if (userParamKey == child) {
2562
+ defaultValue = userParamValue;
2563
+ break;
2564
+ }
2565
+ }
2566
+ } else {
2567
+ for (let [key, value] of Object.entries(user)) {
2568
+ if (key == paramKey) {
2569
+ defaultValue = value;
2570
+ break;
2571
+ }
2572
+ }
2573
+ }
2574
+ if (defaultValue != null)
2575
+ defaultValue = String(defaultValue);
2576
+ if (privateFlag && defaultValue && isConditionSignForHash) {
2577
+ return MD5.hex(defaultValue);
2578
+ }
2579
+ return defaultValue;
2580
+ }
2581
+ calcUserInGroup(salt, exposureRate, controlBucketPerc, forcedExp = false, layer = null, layerBounds = [], splitBy) {
2582
+ if (!splitBy)
2583
+ return false;
2584
+ const md5R = MD5.hex(String(splitBy) + salt);
2585
+ const R = digestHash(md5R) * zeta / max_decimal_64;
2586
+ let md5L = null;
2587
+ if (!layer && !layerBounds.length || forcedExp) {
2588
+ return getUserGroup(R, exposureRate, controlBucketPerc, forcedExp);
2589
+ } else {
2590
+ md5L = MD5.hex(String(splitBy) + layer);
2591
+ const L = digestHash(md5L) * zeta / max_decimal_64;
2592
+ for (let i in layerBounds) {
2593
+ const bucket = Math.floor(Math.abs(L / 10));
2594
+ const bucketIsInLayer = bucket >= layerBounds[i].lower_bound && bucket <= layerBounds[i].upper_bound;
2595
+ if (bucketIsInLayer) {
2596
+ return getUserGroup(R, exposureRate, controlBucketPerc, forcedExp);
2597
+ }
2598
+ }
2599
+ }
2600
+ return null;
2601
+ }
2602
+ switchSplitById(splitBy) {
2603
+ let id = null;
2604
+ switch (splitBy) {
2605
+ case "userId":
2606
+ id = this.userData.userId || this.userData.userId === 0 ? String(this.userData.userId).trim() : null;
2607
+ break;
2608
+ case "profileId":
2609
+ id = this.userData.profileId || this.userData.profileId === 0 ? String(this.userData.profileId).trim() : null;
2610
+ break;
2611
+ case "deviceId":
2612
+ id = this.userData.deviceId || this.userData.deviceId === 0 ? String(this.userData.deviceId).trim() : null;
2613
+ break;
2614
+ }
2615
+ return id;
2616
+ }
2617
+ getSplitById(experiment) {
2618
+ if (!experiment)
2619
+ return null;
2620
+ if (!experiment.split_by) {
2621
+ experiment.split_by = "userId";
2622
+ }
2623
+ return this.switchSplitById(experiment.split_by);
2624
+ }
2625
+ checkTargetConditions(experiment) {
2626
+ if (experiment.targets && experiment.targets.conditions && experiment.targets.conditions.length > 0) {
2627
+ const targets = experiment.targets;
2628
+ let results = [];
2629
+ for (let index in targets.conditions) {
2630
+ const userValue = this.getUserParamValue(
2631
+ targets.conditions[index].name,
2632
+ experiment.is_private,
2633
+ this.checkConditionSignForHash(targets.conditions[index].condition_sign)
2634
+ );
2635
+ results.push(
2636
+ conditionOperation(
2637
+ userValue,
2638
+ targets.conditions[index].value,
2639
+ targets.conditions[index].condition_sign,
2640
+ this.sigmaUserData.user.date,
2641
+ this.sigmaUserData.user.time
2642
+ )
2643
+ );
2644
+ }
2645
+ return this.checkConditionsStatement(targets.conditional_statement, results);
2646
+ }
2647
+ return false;
2648
+ }
2649
+ checkConditionSignForHash(condition) {
2650
+ return signsForHash.includes(condition);
2651
+ }
2652
+ experimentDefinition(experiment, forcedUserInGroup, forcedUser) {
2653
+ if (forcedUserInGroup || forcedUser) {
2654
+ return experiment;
2655
+ } else if (experiment.targets && experiment.targets.conditions.length > 0 && this.checkTargetConditions(experiment)) {
2656
+ return experiment;
2657
+ } else if (!experiment.targets || experiment.targets && experiment.targets.conditions.length === 0) {
2658
+ return experiment;
2659
+ }
2660
+ return null;
2661
+ }
2662
+ async getExperiment(experimentName) {
2663
+ if (!experimentName)
2664
+ return null;
2665
+ await this.updateCache();
2666
+ await this.updateGeoCache();
2667
+ const sigmaDataLs = await this.cache.parse(sigmaDataFile);
2668
+ this.sigmaUserData.setGeo(this.geoCache.parse(sigmaGeoData));
2669
+ if (!sigmaDataLs.experiments)
2670
+ throw new Error(errorMessages.isNoExperimentInCache);
2671
+ let experiment = null;
2672
+ let layer = null;
2673
+ let bounds = [];
2674
+ let groupName = null;
2675
+ let groupIndex = null;
2676
+ let forcedUser = false;
2677
+ let splitById = null;
2678
+ let userInHoldout = false;
2679
+ for (let i = 0; i < sigmaDataLs.experiments.length; i++) {
2680
+ const experimentIndex = sigmaDataLs.experiments[i];
2681
+ if (experimentIndex["name"] === experimentName && checkBoolValue(experimentIndex["layer_id"])) {
2682
+ layer = experimentIndex["layer_id"];
2683
+ bounds = experimentIndex["layer_bounds"];
2684
+ }
2685
+ if (experimentIndex["name"] === experimentName) {
2686
+ splitById = this.getSplitById(experimentIndex);
2687
+ forcedUser = checkForcedList(experimentIndex.forced_user_list, splitById);
2688
+ groupName = this.findUserInForcedGroup(experimentIndex);
2689
+ experiment = this.experimentDefinition(experimentIndex, groupName, forcedUser);
2690
+ if (experimentIndex.holdouts && experimentIndex.holdouts.length) {
2691
+ for (const holdoutName of experimentIndex.holdouts) {
2692
+ userInHoldout = await this.getHoldout(holdoutName);
2693
+ if (userInHoldout)
2694
+ break;
2695
+ }
2696
+ }
2697
+ break;
2698
+ }
2699
+ }
2700
+ const localStorageGroupName = `${prefixGroup}_${experimentName}`;
2701
+ if (this.cache.get(localStorageGroupName))
2702
+ this.cache.remove(localStorageGroupName);
2703
+ if (experiment) {
2704
+ if (!groupName) {
2705
+ groupName = this.calcUserInGroup(
2706
+ experiment.salt,
2707
+ experiment.allocation,
2708
+ experiment.groups,
2709
+ forcedUser,
2710
+ layer,
2711
+ bounds,
2712
+ splitById
2713
+ );
2714
+ }
2715
+ if (experiment.type === experimentType.holdout) {
2716
+ if (groupName)
2717
+ this.cache.set(localStorageGroupName, groupName);
2718
+ return groupName;
2719
+ }
2720
+ if (!userInHoldout) {
2721
+ this.cache.set(localStorageGroupName, groupName);
2722
+ groupIndex = experiment.groups.findIndex((i) => i.name == groupName);
2723
+ }
2724
+ }
2725
+ const getParamValue = (paramName) => {
2726
+ if (!paramName || !experiment || userInHoldout) {
2727
+ return null;
2728
+ }
2729
+ const groupName2 = this.cache.get(localStorageGroupName);
2730
+ let params = null;
2731
+ for (let i = 0; i < experiment.params.length; i++) {
2732
+ if (experiment.params[i]["name"] === paramName) {
2733
+ params = experiment.params[i];
2734
+ break;
2735
+ }
2736
+ }
2737
+ if (!params) {
2738
+ return null;
2739
+ }
2740
+ let paramValue = null;
2741
+ for (let item in params.values) {
2742
+ if (params.values[item].group === groupName2) {
2743
+ paramValue = doTypeConversion(params.type, params.values[item].value);
2744
+ }
2745
+ }
2746
+ return paramValue;
2747
+ };
2748
+ const getFeatureValue = (flagName) => {
2749
+ if (!flagName || !experiment || userInHoldout) {
2750
+ return null;
2751
+ }
2752
+ const groupName2 = this.cache.get(localStorageGroupName);
2753
+ let flagExperiment = null;
2754
+ for (let i = 0; i < experiment.feature_flags.length; i++) {
2755
+ if (experiment.feature_flags[i]["name"] === flagName) {
2756
+ flagExperiment = experiment.feature_flags[i];
2757
+ break;
2758
+ }
2759
+ }
2760
+ if (!flagExperiment)
2761
+ return null;
2762
+ let flag = null;
2763
+ for (let i = 0; i < flagExperiment.groups.length; i++) {
2764
+ if (flagExperiment.groups[i]["group"] === groupName2) {
2765
+ flag = flagExperiment.groups[i];
2766
+ break;
2767
+ }
2768
+ }
2769
+ if (!flag)
2770
+ return null;
2771
+ let flagExperimentFeatureValue = this.findingSpotCondition(flag, false, experiment);
2772
+ return doTypeConversion(flagExperiment.type, flagExperimentFeatureValue);
2773
+ };
2774
+ return {
2775
+ getParamValue,
2776
+ getFeatureValue,
2777
+ groupIndex: groupIndex < 0 ? null : groupIndex,
2778
+ userInHoldout
2779
+ };
2780
+ }
2781
+ async getAllUserExperiments(estimateHoldouts = true) {
2782
+ await this.updateCache();
2783
+ await this.updateGeoCache();
2784
+ const sigmaDataLs = this.cache.parse(sigmaDataFile);
2785
+ if (!sigmaDataLs.experiments.length)
2786
+ return null;
2787
+ let result = "";
2788
+ for (let i in sigmaDataLs.experiments) {
2789
+ if (!estimateHoldouts && sigmaDataLs.experiments[i].type === experimentType.holdout)
2790
+ continue;
2791
+ let layer = null;
2792
+ let bounds = [];
2793
+ let splitById = this.getSplitById(sigmaDataLs.experiments[i]);
2794
+ let forcedUser = checkForcedList(sigmaDataLs.experiments[i].forced_user_list, splitById);
2795
+ let userInGroupExperiment = this.findUserInForcedGroup(sigmaDataLs.experiments[i]);
2796
+ let experiment = this.experimentDefinition(sigmaDataLs.experiments[i], userInGroupExperiment, forcedUser);
2797
+ let userInHoldout;
2798
+ if (!experiment)
2799
+ continue;
2800
+ if (checkBoolValue(experiment["layer_id"]) && !userInGroupExperiment) {
2801
+ layer = experiment["layer_id"];
2802
+ bounds = experiment["layer_bounds"];
2803
+ }
2804
+ if (!userInGroupExperiment) {
2805
+ userInGroupExperiment = this.calcUserInGroup(
2806
+ experiment.salt,
2807
+ experiment.allocation,
2808
+ experiment.groups,
2809
+ forcedUser,
2810
+ layer,
2811
+ bounds,
2812
+ splitById
2813
+ );
2814
+ }
2815
+ if (!userInGroupExperiment)
2816
+ continue;
2817
+ if (sigmaDataLs.experiments[i].holdouts && sigmaDataLs.experiments[i].holdouts.length > 0) {
2818
+ for (const holdout of sigmaDataLs.experiments[i].holdouts) {
2819
+ const foundingExperimentHoldout = sigmaDataLs.experiments.find((exp) => exp.name === holdout);
2820
+ if (!foundingExperimentHoldout)
2821
+ break;
2822
+ const splitByHoldoutId = this.getSplitById(foundingExperimentHoldout);
2823
+ if (!splitByHoldoutId)
2824
+ continue;
2825
+ const holdoutForcedUser = checkForcedList(foundingExperimentHoldout.forced_user_list, splitByHoldoutId);
2826
+ let userInGroupHoldout = this.findUserInForcedGroup(foundingExperimentHoldout);
2827
+ if (userInGroupHoldout) {
2828
+ userInHoldout = true;
2829
+ break;
2830
+ }
2831
+ const experimentByHoldout = this.experimentDefinition(foundingExperimentHoldout, userInGroupHoldout, holdoutForcedUser);
2832
+ if (!experimentByHoldout)
2833
+ continue;
2834
+ userInGroupHoldout = this.calcUserInGroup(
2835
+ experimentByHoldout.salt,
2836
+ experimentByHoldout.allocation,
2837
+ experimentByHoldout.groups,
2838
+ holdoutForcedUser,
2839
+ null,
2840
+ [],
2841
+ splitByHoldoutId
2842
+ );
2843
+ if (userInGroupHoldout) {
2844
+ userInHoldout = true;
2845
+ break;
2846
+ }
2847
+ }
2848
+ }
2849
+ if (userInHoldout)
2850
+ continue;
2851
+ const groupIndex = experiment.groups.findIndex((i2) => i2.name == userInGroupExperiment);
2852
+ result = result.concat(experiment.name).concat(".").concat(groupIndex).concat("|");
2853
+ }
2854
+ if (result.length > 0) {
2855
+ this.cache.set(sigmaExperiments, result.slice(0, -1));
2856
+ return result.slice(0, -1);
2857
+ } else {
2858
+ this.cache.remove(sigmaExperiments);
2859
+ }
2860
+ return null;
2861
+ }
2862
+ async getHoldout(name) {
2863
+ if (!name)
2864
+ return console.log(warnings.emptyHoldoutId);
2865
+ const holdoutGroup = await this.getExperiment(name);
2866
+ if (holdoutGroup && typeof holdoutGroup === "string")
2867
+ return true;
2868
+ return false;
2869
+ }
2870
+ async getAllUserHoldouts() {
2871
+ await this.updateCache();
2872
+ const sigmaDataLs = await this.cache.parse(sigmaDataFile);
2873
+ if (!sigmaDataLs.experiments.length)
2874
+ return null;
2875
+ let result = "";
2876
+ for (const holdout of sigmaDataLs.experiments) {
2877
+ if (holdout.type !== experimentType.holdout)
2878
+ continue;
2879
+ let userInGroupExperiment = false;
2880
+ const layer = null;
2881
+ const bounds = [];
2882
+ const splitById = this.getSplitById(holdout);
2883
+ const forcedUser = checkForcedList(holdout.forced_user_list, splitById);
2884
+ const experiment = this.experimentDefinition(holdout, userInGroupExperiment, forcedUser);
2885
+ if (!experiment)
2886
+ continue;
2887
+ userInGroupExperiment = this.calcUserInGroup(
2888
+ experiment.salt,
2889
+ experiment.allocation,
2890
+ experiment.groups,
2891
+ forcedUser,
2892
+ layer,
2893
+ bounds,
2894
+ splitById
2895
+ );
2896
+ if (!userInGroupExperiment)
2897
+ continue;
2898
+ result = result.concat(holdout.name).concat(".").concat("0").concat("|");
2899
+ }
2900
+ if (result.length > 0) {
2901
+ this.cache.set(sigmaHoldouts, result.slice(0, -1));
2902
+ return result.slice(0, -1);
2903
+ } else {
2904
+ this.cache.remove(sigmaHoldouts);
2905
+ }
2906
+ return null;
2907
+ }
2908
+ findUserInForcedGroup(experiment) {
2909
+ let groupName = false;
2910
+ for (const groupItem in experiment.groups) {
2911
+ const forcedList = experiment.groups[groupItem].forced_user_list;
2912
+ if (forcedList && forcedList.length) {
2913
+ for (const item in forcedList) {
2914
+ if (forcedList[item] === this.getSplitById(experiment)) {
2915
+ return groupName = experiment.groups[groupItem].name;
2916
+ }
2917
+ }
2918
+ }
2919
+ }
2920
+ return groupName;
2921
+ }
2922
+ findingSpotCondition(flag, saveToUser = false, exp = null) {
2923
+ let flagRules = flag.rules;
2924
+ let flagDefaultResult = null;
2925
+ for (let defaultRule in flagRules) {
2926
+ if (flagRules[defaultRule].is_default) {
2927
+ flagDefaultResult = {
2928
+ id: flagRules[defaultRule].id,
2929
+ value: flagRules[defaultRule].value,
2930
+ type: flag.type
2931
+ };
2932
+ }
2933
+ }
2934
+ if (!flagDefaultResult) {
2935
+ throw new Error(errorMessages.badConfig);
2936
+ }
2937
+ for (let flagIndex in flagRules) {
2938
+ const statement = flagRules[flagIndex].conditional_statement;
2939
+ if (!statement && flagRules.length === 1) {
2940
+ this.sigmaUserData.addFlag(flag.name, flagDefaultResult);
2941
+ return true;
2942
+ }
2943
+ for (let rule in flagRules) {
2944
+ const conditions = flagRules[rule].conditions;
2945
+ let results = [];
2946
+ for (let i in conditions) {
2947
+ let userValue = this.getUserParamValue(
2948
+ conditions[i].name,
2949
+ exp ? exp.is_private : flag.is_private,
2950
+ this.checkConditionSignForHash(conditions[i].condition_sign)
2951
+ );
2952
+ results.push(
2953
+ conditionOperation(
2954
+ userValue,
2955
+ conditions[i].value,
2956
+ conditions[i].condition_sign,
2957
+ this.sigmaUserData.user.date,
2958
+ this.sigmaUserData.user.time
2959
+ )
2960
+ );
2961
+ }
2962
+ let isSuccessRule = this.checkConditionsStatement(flagRules[rule].conditional_statement, results);
2963
+ let ruleValue = doTypeConversion(flag.type, flagRules[rule].value);
2964
+ if (isSuccessRule) {
2965
+ if (saveToUser) {
2966
+ saveToUser.addFlag(flag.name, {
2967
+ id: flagRules[rule].id,
2968
+ value: ruleValue,
2969
+ type: flag.type
2970
+ });
2971
+ }
2972
+ return ruleValue;
2973
+ }
2974
+ }
2975
+ let defaultValue = doTypeConversion(flagDefaultResult.type, flagDefaultResult.value);
2976
+ if (saveToUser) {
2977
+ flagDefaultResult.value = defaultValue;
2978
+ saveToUser.addFlag(flag.name, flagDefaultResult);
2979
+ }
2980
+ return defaultValue;
2981
+ }
2982
+ }
2983
+ async getCacheDataFile() {
2984
+ await this.updateCache();
2985
+ return this.cache.parse(sigmaDataFile);
2986
+ }
2987
+ async getCacheHash() {
2988
+ const data = await this.cache.get(sigmaHash);
2989
+ return data;
2990
+ }
2991
+ checkConditionsStatement(ruleStatement, items) {
2992
+ let isSuccessRule = false;
2993
+ if (ruleStatement == "OR") {
2994
+ const findingItem = items.find((item) => item === true);
2995
+ findingItem === true ? isSuccessRule = true : isSuccessRule;
2996
+ }
2997
+ if (ruleStatement == "AND") {
2998
+ const findingItem = items.find((item) => item === false);
2999
+ findingItem === false ? isSuccessRule : isSuccessRule = true;
3000
+ }
3001
+ return isSuccessRule;
3002
+ }
3003
+ clearCacheByKeys(keys) {
3004
+ for (const key in keys) {
3005
+ this.cache.remove(keys[key]);
3006
+ }
3007
+ }
3008
+ clearUserProperties() {
3009
+ this.userData.userId = void 0;
3010
+ this.userData.profileId = void 0;
3011
+ this.userData.deviceId = void 0;
3012
+ this.sigmaUserData.removeInjectedProperties();
3013
+ this.clearCacheByKeys([sigmaExperiments]);
3014
+ }
3015
+ overwriteGeoCache(key, value) {
3016
+ const geoCache = this.geoCache.parse(sigmaGeoData);
3017
+ geoCache[key] = value;
3018
+ this.geoCache.set(sigmaGeoData, JSON.stringify(geoCache));
3019
+ }
3020
+ editUserProperties() {
3021
+ return {
3022
+ setUserId: (userId) => {
3023
+ this.sigmaUserData.setUserId(userId);
3024
+ this.userData.userId = userId;
3025
+ return this.editUserProperties();
3026
+ },
3027
+ setDeviceId: (deviceId) => {
3028
+ this.sigmaUserData.setDeviceId(deviceId);
3029
+ this.userData.deviceId = deviceId;
3030
+ return this.editUserProperties();
3031
+ },
3032
+ setProfileId: (profileId) => {
3033
+ this.sigmaUserData.setProfileId(profileId);
3034
+ this.userData.profileId = profileId;
3035
+ return this.editUserProperties();
3036
+ },
3037
+ setEmail: (email) => {
3038
+ this.sigmaUserData.setEmail(email);
3039
+ return this.editUserProperties();
3040
+ },
3041
+ setAppVersion: (appVersion) => {
3042
+ this.sigmaUserData.setAppVersion(appVersion);
3043
+ return this.editUserProperties();
3044
+ },
3045
+ setBrowserName: (browserName) => {
3046
+ this.sigmaUserData.setBrowserName(browserName);
3047
+ return this.editUserProperties();
3048
+ },
3049
+ setBrowserVersion: (browserVersion) => {
3050
+ this.sigmaUserData.setBrowserVersion(browserVersion);
3051
+ return this.editUserProperties();
3052
+ },
3053
+ setOsName: (osName) => {
3054
+ this.sigmaUserData.setOsName(osName);
3055
+ return this.editUserProperties();
3056
+ },
3057
+ setOsVersion: (osVersion) => {
3058
+ this.sigmaUserData.setOsVersion(osVersion);
3059
+ return this.editUserProperties();
3060
+ },
3061
+ setGeoCountry: (country) => {
3062
+ this.sigmaUserData.setGeoCountry(country);
3063
+ this.overwriteGeoCache("country", country);
3064
+ return this.editUserProperties();
3065
+ },
3066
+ setGeoCode: (code) => {
3067
+ this.sigmaUserData.setGeoCode(code);
3068
+ this.overwriteGeoCache("code", code);
3069
+ return this.editUserProperties();
3070
+ },
3071
+ setGeoState: (state) => {
3072
+ this.sigmaUserData.setGeoState(state);
3073
+ this.overwriteGeoCache("state", state);
3074
+ return this.editUserProperties();
3075
+ },
3076
+ setGeoCity: (city) => {
3077
+ this.sigmaUserData.setGeoCity(city);
3078
+ this.overwriteGeoCache("city", city);
3079
+ return this.editUserProperties();
3080
+ },
3081
+ setGeoIp: (ip) => {
3082
+ this.sigmaUserData.setGeoIp(ip);
3083
+ this.overwriteGeoCache("ip", ip);
3084
+ return this.editUserProperties();
3085
+ },
3086
+ setCustomProperty: (key, value) => {
3087
+ this.sigmaUserData.setCustomProperty(key, value);
3088
+ return this.editUserProperties();
3089
+ },
3090
+ removeUserId: () => {
3091
+ this.sigmaUserData.removeUserId();
3092
+ this.userData.userId = void 0;
3093
+ return this.editUserProperties();
3094
+ },
3095
+ removeDeviceId: () => {
3096
+ this.sigmaUserData.removeDeviceId();
3097
+ this.userData.deviceId = void 0;
3098
+ return this.editUserProperties();
3099
+ },
3100
+ removeProfileId: () => {
3101
+ this.sigmaUserData.removeProfileId();
3102
+ this.userData.profileId = void 0;
3103
+ return this.editUserProperties();
3104
+ },
3105
+ removeAppVersion: () => {
3106
+ this.sigmaUserData.removeAppVersion();
3107
+ return this.editUserProperties();
3108
+ },
3109
+ removeBrowserName: () => {
3110
+ this.sigmaUserData.removeBrowserName();
3111
+ return this.editUserProperties();
3112
+ },
3113
+ removeBrowserVersion: () => {
3114
+ this.sigmaUserData.removeBrowserVersion();
3115
+ return this.editUserProperties();
3116
+ },
3117
+ removeEmail: () => {
3118
+ this.sigmaUserData.removeEmail();
3119
+ return this.editUserProperties();
3120
+ },
3121
+ removeOsName: () => {
3122
+ this.sigmaUserData.removeOsName();
3123
+ return this.editUserProperties();
3124
+ },
3125
+ removeOsVersion: () => {
3126
+ this.sigmaUserData.removeOsVersion();
3127
+ return this.editUserProperties();
3128
+ },
3129
+ removeGeoCountry: () => {
3130
+ this.sigmaUserData.removeGeoCountry();
3131
+ this.overwriteGeoCache("country", null);
3132
+ return this.editUserProperties();
3133
+ },
3134
+ removeGeoCode: () => {
3135
+ this.sigmaUserData.removeGeoCode();
3136
+ this.overwriteGeoCache("code", null);
3137
+ return this.editUserProperties();
3138
+ },
3139
+ removeGeoState: () => {
3140
+ this.sigmaUserData.removeGeoState();
3141
+ this.overwriteGeoCache("state", null);
3142
+ return this.editUserProperties();
3143
+ },
3144
+ removeGeoCity: () => {
3145
+ this.sigmaUserData.removeGeoCity();
3146
+ this.overwriteGeoCache("city", null);
3147
+ return this.editUserProperties();
3148
+ },
3149
+ removeGeoIp: () => {
3150
+ this.sigmaUserData.removeGeoIp();
3151
+ this.overwriteGeoCache("ip", null);
3152
+ return this.editUserProperties();
3153
+ },
3154
+ removeCustomProperty: (key) => {
3155
+ this.sigmaUserData.removeCustomProperty(key);
3156
+ return this.editUserProperties();
3157
+ }
3158
+ };
3159
+ }
3160
+ async includeForceUser(experimentId, groupIndex = null) {
3161
+ if (!experimentId) {
3162
+ console.warn(`Sigma warn: ExperimentId requires parameter`);
3163
+ return;
3164
+ }
3165
+ await this.updateCache();
3166
+ this.setForceUser(experimentId, groupIndex);
3167
+ }
3168
+ setForceUser(experimentId, groupIndex) {
3169
+ const sigmaDataLs = this.cache.parse(sigmaDataFile);
3170
+ if (!sigmaDataLs.experiments) {
3171
+ console.warn(`Sigma warn: Experiments not found in cache`);
3172
+ return;
3173
+ }
3174
+ const experiment = sigmaDataLs.experiments.find((exp) => exp.name === experimentId);
3175
+ if (!experiment) {
3176
+ console.warn(`Sigma warn: Experiment "${experimentId}" not found`);
3177
+ return;
3178
+ }
3179
+ if (!Object.keys(this.userData).includes(experiment.split_by)) {
3180
+ console.warn(`Sigma warn: "${experiment.split_by}" is missing in userData`);
3181
+ return;
3182
+ }
3183
+ const splitById = Object.keys(this.userData).find((id) => id === experiment.split_by);
3184
+ if (typeof groupIndex === "number" && groupIndex >= 0) {
3185
+ const groupInExperiment = experiment.groups[groupIndex];
3186
+ if (!groupInExperiment) {
3187
+ console.warn(`Sigma warn: Experiment "${experimentId}" has not group with index ${groupIndex}`);
3188
+ return;
3189
+ }
3190
+ this.clearForcedList(experiment, splitById);
3191
+ if (this.userData[splitById] && !groupInExperiment.forced_user_list.includes(String(this.userData[splitById]))) {
3192
+ groupInExperiment.forced_user_list.push(String(this.userData[splitById]));
3193
+ }
3194
+ } else if (!groupIndex) {
3195
+ this.clearForcedList(experiment, splitById);
3196
+ if (this.userData[splitById] && !experiment.forced_user_list.includes(String(this.userData[splitById]))) {
3197
+ experiment.forced_user_list.push(String(this.userData[splitById]));
3198
+ }
3199
+ }
3200
+ if (!this.cache.get(sigmaForcedExperiments)) {
3201
+ this.cache.set(sigmaForcedExperiments, JSON.stringify([{ experimentId, groupIndex }]));
3202
+ } else {
3203
+ const forcedExperiments = this.cache.parse(sigmaForcedExperiments);
3204
+ const foundingForcedExperiment = forcedExperiments.find((el) => el.experimentId === experimentId);
3205
+ if (!foundingForcedExperiment) {
3206
+ forcedExperiments.push({ experimentId, groupIndex });
3207
+ this.cache.set(sigmaForcedExperiments, JSON.stringify(forcedExperiments));
3208
+ } else if (typeof groupIndex === "number" && groupIndex >= 0 && foundingForcedExperiment) {
3209
+ foundingForcedExperiment.groupIndex = groupIndex;
3210
+ this.cache.set(sigmaForcedExperiments, JSON.stringify(forcedExperiments));
3211
+ } else if (!groupIndex && foundingForcedExperiment) {
3212
+ foundingForcedExperiment.groupIndex = groupIndex;
3213
+ this.cache.set(sigmaForcedExperiments, JSON.stringify(forcedExperiments));
3214
+ }
3215
+ }
3216
+ this.cache.set(sigmaDataFile, JSON.stringify(sigmaDataLs));
3217
+ }
3218
+ clearForcedList(experiment, splitById) {
3219
+ if (experiment.forced_user_list.includes(String(this.userData[splitById]))) {
3220
+ experiment.forced_user_list = experiment.forced_user_list.filter((el) => String(el) !== String(this.userData[splitById]));
3221
+ }
3222
+ for (const group of experiment.groups) {
3223
+ if (group.forced_user_list.includes(String(this.userData[splitById]))) {
3224
+ group.forced_user_list = group.forced_user_list.filter((el) => String(el) !== String(this.userData[splitById]));
3225
+ }
3226
+ }
3227
+ }
3228
+ async excludeForceUser(experimentId) {
3229
+ if (!experimentId) {
3230
+ console.warn(`Sigma warn: ExperimentId requires parameter`);
3231
+ return;
3232
+ }
3233
+ if (!this.cache.get(sigmaForcedExperiments)) {
3234
+ console.warn(`Sigma warn: No included experiments to exclude`);
3235
+ return;
3236
+ }
3237
+ if (!this.cache.get(sigmaDataFile))
3238
+ return;
3239
+ const sigmaDataLs = this.cache.parse(sigmaDataFile);
3240
+ if (!sigmaDataLs || !sigmaDataLs.experiments) {
3241
+ console.warn(`Sigma warn: Experiments not found in cache`);
3242
+ return;
3243
+ }
3244
+ let experiment = sigmaDataLs.experiments.find((exp) => exp.name === experimentId);
3245
+ if (!experiment) {
3246
+ console.warn(`Sigma warn: Experiment "${experimentId}" not found`);
3247
+ return;
3248
+ }
3249
+ if (!Object.keys(this.userData).includes(experiment.split_by)) {
3250
+ console.warn(`Sigma warn: ${experiment.split_by} is missing in userData`);
3251
+ return;
3252
+ }
3253
+ let forcedExperiments = this.cache.parse(sigmaForcedExperiments);
3254
+ if (!forcedExperiments.find((el) => el.experimentId === experimentId)) {
3255
+ console.warn(`Sigma warn: Experiment "${experimentId}" not found to exclude`);
3256
+ return;
3257
+ }
3258
+ forcedExperiments = forcedExperiments.filter((el) => el.experimentId !== experimentId);
3259
+ if (forcedExperiments.length > 0) {
3260
+ this.cache.set(sigmaForcedExperiments, JSON.stringify(forcedExperiments));
3261
+ } else {
3262
+ this.cache.remove(sigmaForcedExperiments);
3263
+ }
3264
+ this.cache.set(sigmaHash, "");
3265
+ await this.saveToCache();
3266
+ }
3267
+ async excludeForceUserAll() {
3268
+ if (!this.cache.get(sigmaForcedExperiments)) {
3269
+ console.warn(`Sigma warn: No included experiments to exclude`);
3270
+ return;
3271
+ }
3272
+ if (!this.cache.get(sigmaDataFile)) {
3273
+ console.warn(`Sigma warn: Experiments not found in cache`);
3274
+ return;
3275
+ }
3276
+ this.cache.remove(sigmaForcedExperiments);
3277
+ this.cache.set(sigmaHash, "");
3278
+ await this.saveToCache();
3279
+ }
3280
+ checkForceExperiments() {
3281
+ if (!this.cache.get(sigmaForcedExperiments))
3282
+ return;
3283
+ const forcedExperiments = JSON.parse(this.cache.get(sigmaForcedExperiments));
3284
+ for (const forceExperiment of forcedExperiments) {
3285
+ this.setForceUser(forceExperiment.experimentId, forceExperiment.groupIndex);
3286
+ }
3287
+ return;
3288
+ }
3289
+ };
3290
+ var sigma_default = Sigma;
3291
+ // Annotate the CommonJS export names for ESM import in node:
3292
+ 0 && (module.exports = {});