UNPKG

rox-config-fetcher

Version:

CloudBees Feature Management ROX JS SDK flag config fetcher

99 lines (87 loc) 94.6 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var e = require('axios'); var t = require('url'); var r = require('events'); var n = require('https'); var i = require('http'); var o = require('util'); var s = require('crypto'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var e__default = /*#__PURE__*/_interopDefaultLegacy(e); var t__default = /*#__PURE__*/_interopDefaultLegacy(t); var r__default = /*#__PURE__*/_interopDefaultLegacy(r); var n__default = /*#__PURE__*/_interopDefaultLegacy(n); var i__default = /*#__PURE__*/_interopDefaultLegacy(i); var o__default = /*#__PURE__*/_interopDefaultLegacy(o); var s__default = /*#__PURE__*/_interopDefaultLegacy(s); /****************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (g && (g = 0, op[0] && (_ = 0)), _) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { var e = new Error(message); return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; }; function a(e,t){return t.forEach(function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach(function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}});}});}),Object.freeze(e)}var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function c(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var l,d={exports:{}};l=e=>(()=>{var t=[,(e,t,r)=>{r.r(t),r.d(t,{FlagsSetter:()=>n.default});var n=r(2);},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var n=r(3);class i{constructor(e,t){this.flagRepo=e,this.experimentsRepo=t;}prepareFlagsWithExperiments(){const e=this.experimentsRepo.experiments||[];n.default.debug(`Set experiments ${JSON.stringify(e)}`);const t=[];e.forEach(e=>{e&&e.flags.forEach(r=>{if(!r)return;const n=this.flagRepo.flagWithName(r.name);n&&(t.push(n),this.connectExperimentToFlag(n,e.deploymentConfiguration.condition));});}),this.flagRepo.flags.forEach(e=>{t.some(t=>t===e)||this.connectExperimentToFlag(e,void 0);});}setAddedFlag(e){const t=this.experimentsRepo.experimentForFlag(e);t&&this.connectExperimentToFlag(e,t.deploymentConfiguration.condition);}connectExperimentToFlag(e,t){e.condition=t;}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});const n={debug:0,info:1,warn:2,error:3};let i="error",o=new class{constructor(){this.debug=(e,...t)=>{n[i]<=n.debug&&console&&console.log(e,...t);},this.info=(e,...t)=>{n[i]<=n.info&&console&&console.info(e,...t);},this.warn=(e,...t)=>{n[i]<=n.warn&&console&&console.warn(e,...t);},this.error=(e,...t)=>{console&&console.error(e,...t);},this.setVerboseMode=e=>{"verbose"===e?(i="debug",this.debug("Active verbose mode")):i="error";},this.setLogger=e=>{o=e;};}};const s=o;},(e,t,r)=>{r.r(t),r.d(t,{CustomProperties:()=>n.default,Experiments:()=>i.default,Flags:()=>o.default,TargetGroups:()=>s.default});var n=r(5),i=r(6),o=r(7),s=r(8);},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});const n=new class{constructor(){this.store=new Map;}has(e){return this.store.has(e.name)}get(e){return this.store.get(e)}set(e){this.store.set(e.name,e);}setIfNotExists(e){this.has(e)||this.set(e);}clear(){this.store.clear();}get items(){return Array.from(this.store.values())}};},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});const n=new class{constructor(){this.map={};}setExperiments(e){this.map={},(e=e||[]).forEach(function(e){this.map[e.identifier]=e;},this);}experimentWithName(e){return this.map[e]}get experiments(){return Object.keys(this.map).map(e=>this.map[e])}experimentForFlagName(e){return this.experiments.find(t=>t.flags&&t.flags.some(t=>t.name===e))}experimentForFlag(e){return this.experimentForFlagName(e.name)}},i=n;},(e,t,r)=>{r.r(t),r.d(t,{RoxFlagRepository:()=>o,default:()=>s});var n=r(2),i=r(6);class o{constructor(){this.map={};}addFlag(e,t){t.name=e,this.map[e]=t,new n.default(this,i.default).setAddedFlag(t);}flagWithName(e){return this.map[e]}get flags(){return Object.keys(this.map).map(e=>this.map[e])}get items(){return this.flags}}const s=new o;},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});const n=new class{constructor(){this.map={};}addTargetGroup(e){this.map[e.identifier]=e;}setTargetGroups(e){this.map={},(e=e||[]).forEach(function(e){this.map[e.identifier]=e;},this);}targetGroupWithName(e){return this.map[e]}get targetGroups(){return Object.keys(this.map).map(e=>this.map[e])}};},(e,t,r)=>{r.r(t),r.d(t,{ConfigurationParser:()=>i.default,RoxxParser:()=>n.default});var n=r(10),i=r(23);},(e,t,r)=>{r.r(t),r.d(t,{default:()=>u});var n=r(11),i=r(3),o=r(13),s=r(20),a=r(21);class u{constructor(e){this._tokenizer=new n.RoxxTokenizer,this._cache=e||{};}_argsArrayForOperator(e,t){const r=[],n=e.length;for(let e=0;e<n;e++){const e=t.pop();r.push(e);}return r}_modifyArgsHook({operator:e,args:t,context:r,callContext:n}){let i=t;return r&&o.operatorsWithContext.includes(e)&&(i=[...t,r]),n?[...i,n]:i}compileExpression(e){let t=this._cache[e];return t||(t=this._tokenizer.tokenize(e).reverse(),this._cache[e]=t),t}evaluateExpression(e,t={},r={},u){var c;const l=[],d=this.compileExpression(e);let h;const f=d.length;try{for(let e=0;e<f;e++){const s=d[e];if(s.type==n.RoxxTokenTypeRand)l.push(s.value);else {if(s.type!=n.RoxxTokenTypeRator){l.push(void 0);break}{const e=o[s.value];let n=this._argsArrayForOperator(e,l);n=this._modifyArgsHook({operator:e,args:n,context:r,callContext:t});const a=e.apply(this,n);l.push(a);const c=`${s.value}(${JSON.stringify(n)}) => ${a}`;u&&u.push(c),i.default.debug(`Roxx: ${c}`);}}}h=l.pop();}catch(t){const r=`Uh oh! An error occurred during Roxx evaluation. ${e}`;t.isUserError?s.default.invoke(t.trigger,t):null===(c=a.default.getErrorReporter())||void 0===c||c.error(r,t),i.default.error(r,t),h=!1;}finally{return h}}}},(e,t,r)=>{r.r(t),r.d(t,{RoxxTokenTypeRand:()=>l,RoxxTokenTypeRator:()=>c,RoxxTokenizer:()=>d});var n=r(12),i=r(13);const o=Object.keys(i),s="\\RO_Q",a='"',u='{}[]():, \t\r\n"',c="operator",l="operand";class d{constructor(){this.tokenArray=[],this.arrayAccumulator=void 0,this.dictionaryAccumulator=void 0,this.dictKey=void 0;}_stringToRoxx(e){return o.includes(e)?{type:c,value:e}:"true"==e?{type:l,value:!0}:"false"==e?{type:l,value:!1}:"undefined"==e?{type:l,value:void 0}:'"'==e.charAt(0)&&'"'==e.charAt(e.length-1)?{type:l,value:e.substr(1,e.length-2)}:isNaN(e)?{type:"UNKNOWN"}:{type:l,value:+e}}push(e){this.dictionaryAccumulator&&!this.dictKey?this.dictKey=e.value:this.dictionaryAccumulator&&this.dictKey?(this.dictionaryAccumulator[this.dictKey]=e.value,this.dictKey=void 0):this.arrayAccumulator?this.arrayAccumulator.push(e.value):this.tokenArray.push(e);}tokenize(e){this.tokenArray=[],this.arrayAccumulator=void 0,this.dictionaryAccumulator=void 0;let t=u;const r=e.replace('\\"',s),i=new n.default(r,t,!0);let o,c;for(;i.hasMoreTokens();)switch(c=o,o=i.nextTokenWithDelimiters(t),o){case"{":this.dictionaryAccumulator={};break;case"}":this.tokenArray.push({type:l,value:this.dictionaryAccumulator}),this.dictionaryAccumulator=void 0;break;case"[":this.arrayAccumulator=[];break;case"]":this.tokenArray.push({type:l,value:this.arrayAccumulator}),this.arrayAccumulator=void 0;break;case a:c==a&&this.push({type:l,value:""}),t=t==a?u:a;break;default:t==a?this.push({type:l,value:o.replace(s,'\\"')}):-1==u.indexOf(o)&&this.push(this._stringToRoxx(o));}return this.tokenArray}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});class n{constructor(e,t,r){this._string=e,this._delimiters=t,this._returnDelim=r,this._position=0;}countTokens(){let e=0,t=!1;for(let r=this._position,n=this._string.length;r<n;r++)-1!=this._delimiters.indexOf(this._string.charAt(r))?(this._returnDelim&&e++,t&&(e++,t=!1)):t=!0;return t&&e++,e}hasMoreElements(){return this.hasMoreTokens()}hasMoreTokens(){if(!this._delimiters)return !1;const e=this._string.length;if(this._position<e){if(this._returnDelim)return !0;for(let t=this._position;t<e;t++)if(-1==this._delimiters.indexOf(this._string.charAt(t)))return !0}return !1}nextElement(){return this.nextToken()}nextToken(){if(!this._delimiters)return;let e=this._position;const t=this._string.length;if(e<t){if(this._returnDelim){if(-1!=this._delimiters.indexOf(this._string.charAt(this._position)))return this._string.charAt(this._position++);for(this._position++;this._position<t;this._position++)if(-1!=this._delimiters.indexOf(this._string.charAt(this._position)))return this._string.substr(e,this._position-e);return this._string.substr(e)}for(;e<t&&-1!=this._delimiters.indexOf(this._string.charAt(this._position));)e++;if(this._position=e,e<t){for(this._position++;this._position<t;this._position++)if(-1!=this._delimiters.indexOf(this._string.charAt(this._position)))return this._string.substr(e,this._position-e);return this._string.substr(e)}}}nextTokenWithDelimiters(e){return this._delimiters=e,this.nextToken()}}},(e,t,r)=>{r.r(t),r.d(t,{and:()=>m,b64d:()=>G,concat:()=>J,eq:()=>_,flagValue:()=>$,gt:()=>O,gte:()=>A,ifThen:()=>P,inArray:()=>z,isInPercentage:()=>M,isInPercentageRange:()=>L,isInTargetGroup:()=>B,isTargetGroupPaired:()=>H,isUndefined:()=>g,lt:()=>S,lte:()=>w,match:()=>C,md5:()=>K,mergeSeed:()=>j,ne:()=>b,not:()=>x,now:()=>y,numeq:()=>R,numne:()=>N,operatorsWithContext:()=>q,or:()=>v,property:()=>V,semverEq:()=>F,semverGt:()=>D,semverGte:()=>k,semverLt:()=>T,semverLte:()=>I,semverNe:()=>U,tsToNum:()=>E});var n=r(8),i=r(5),o=r(7),s=r(6),a=r(10),u=r(14),c=r.n(u),l=r(18),d=r(19),h=r(20);function f(e,t,r={zeroExtend:!0,lexicographical:!0}){const n=r&&r.lexicographical,i=r&&r.zeroExtend;let o=e.split("."),s=t.split(".");function a(e){return (n?/[0-9A-Za-z_-]+$/:/^\d+$/).test(e)}if(!o.every(a)||!s.every(a))return NaN;if(i){for(;o.length<s.length;)o.push("0");for(;s.length<o.length;)s.push("0");}n||(o=o.map(Number),s=s.map(Number));for(let e=0;e<o.length;++e){if(s.length==e)return 1;if(o[e]!=s[e])return o[e]>s[e]?1:-1}return o.length!=s.length?-1:0}const p=e=>{let t=c()(e,{asBytes:!0});return t=(255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24)>>>0,t/(Math.pow(2,32)-1)},g=e=>void 0===e,y=()=>Date.now(),m=(e,t)=>e&&t,v=(e,t)=>e||t,b=(e,t)=>(!g(e)&&e)!==(!g(t)&&t),_=(e,t)=>(!g(e)&&e)===(!g(t)&&t),x=e=>!e,P=(e,t,r)=>e?t:r,S=(e,t)=>!(g(e)||g(t)||"number"!=typeof e&&(e=Number(e),isNaN(e))||"number"!=typeof t&&(t=Number(t),isNaN(t))||!(e<t)),w=(e,t)=>!(g(e)||g(t)||"number"!=typeof e&&(e=Number(e),isNaN(e))||"number"!=typeof t&&(t=Number(t),isNaN(t))||!(e<=t)),E=e=>{if(!g(e))return e instanceof Date?e.getTime()/1e3:void 0},O=(e,t)=>!(g(e)||g(t)||"number"!=typeof e&&(e=Number(e),isNaN(e))||"number"!=typeof t&&(t=Number(t),isNaN(t))||!(e>t)),N=(e,t)=>!(g(e)||g(t)||"number"!=typeof e&&(e=Number(e),isNaN(e))||"number"!=typeof t&&(t=Number(t),isNaN(t))||e===t),R=(e,t)=>!(g(e)||g(t)||"number"!=typeof e&&(e=Number(e),isNaN(e))||"number"!=typeof t&&(t=Number(t),isNaN(t))||e!==t),A=(e,t)=>!(g(e)||g(t)||"number"!=typeof e&&(e=Number(e),isNaN(e))||"number"!=typeof t&&(t=Number(t),isNaN(t))||!(e>=t)),C=(e,t,r)=>{const n=e;return !!new RegExp(t,r).exec(n)},T=(e,t)=>!g(e)&&!g(t)&&"string"==typeof e&&"string"==typeof t&&f(e,t,{zeroExtend:!0})<0,I=(e,t)=>!g(e)&&!g(t)&&"string"==typeof e&&"string"==typeof t&&f(e,t,{zeroExtend:!0})<=0,D=(e,t)=>!g(e)&&!g(t)&&"string"==typeof e&&"string"==typeof t&&f(e,t,{zeroExtend:!0})>0,k=(e,t)=>!g(e)&&!g(t)&&"string"==typeof e&&"string"==typeof t&&f(e,t,{zeroExtend:!0})>=0,F=(e,t)=>!g(e)&&!g(t)&&"string"==typeof e&&"string"==typeof t&&0==f(e,t),U=(e,t)=>!g(e)&&!g(t)&&"string"==typeof e&&"string"==typeof t&&0!=f(e,t),j=(e,t)=>e+"."+t,M=(e,t)=>p(t)<=e,L=(e,t,r)=>{const n=p(r);return n>=e&&n<=t},$=(e,t={},r={})=>{const n=o.default.flagWithName(e);if(n){const e=Object.assign({},r);return n.getInternalValue(e,t),e.isPeek||e.result.isOverride||e.result.isFreezed||n._flagImpression(e.result.value,e.result.usedContext),e.result.value}const i=s.default.experimentForFlagName(e);return i&&i.deploymentConfiguration&&(new a.default).evaluateExpression(i.deploymentConfiguration.condition,r,t)||"false"},B=(e,t={},r={})=>{const i=n.default.targetGroupWithName(e);return !!i&&(new a.default).evaluateExpression(i.condition,r,t)},H=()=>!1,V=(e,t={})=>{const r=i.default.get(e);if(r)return r.getValue(t);{const r=d.DynamicPropertiesHandler&&(0, d.DynamicPropertiesHandler)();let n;if(r)if(r._isUserDefined)try{n=r(e,t);}catch(e){throw e.isUserError=!0,e.trigger=h.ExceptionTrigger.DYNAMIC_PROPERTIES_RULE,e}else n=r(e,t);return n}},z=(e,t)=>!!t&&t.includes(e),K=e=>{if("string"==typeof e)return c()(e)},J=(e,t)=>{if("string"==typeof e&&"string"==typeof t)return `${e}${t}`},G=e=>{if("string"==typeof e)return decodeURIComponent((0, l.decode)(e))},q=[B,$,V];},(e,t,r)=>{!function(){var t=r(15),n=r(16).utf8,i=r(17),o=r(16).bin,s=function(e,r){e.constructor==String?e=r&&"binary"===r.encoding?o.stringToBytes(e):n.stringToBytes(e):i(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var a=t.bytesToWords(e),u=8*e.length,c=1732584193,l=-271733879,d=-1732584194,h=271733878,f=0;f<a.length;f++)a[f]=16711935&(a[f]<<8|a[f]>>>24)|4278255360&(a[f]<<24|a[f]>>>8);a[u>>>5]|=128<<u%32,a[14+(u+64>>>9<<4)]=u;var p=s._ff,g=s._gg,y=s._hh,m=s._ii;for(f=0;f<a.length;f+=16){var v=c,b=l,_=d,x=h;c=p(c,l,d,h,a[f+0],7,-680876936),h=p(h,c,l,d,a[f+1],12,-389564586),d=p(d,h,c,l,a[f+2],17,606105819),l=p(l,d,h,c,a[f+3],22,-1044525330),c=p(c,l,d,h,a[f+4],7,-176418897),h=p(h,c,l,d,a[f+5],12,1200080426),d=p(d,h,c,l,a[f+6],17,-1473231341),l=p(l,d,h,c,a[f+7],22,-45705983),c=p(c,l,d,h,a[f+8],7,1770035416),h=p(h,c,l,d,a[f+9],12,-1958414417),d=p(d,h,c,l,a[f+10],17,-42063),l=p(l,d,h,c,a[f+11],22,-1990404162),c=p(c,l,d,h,a[f+12],7,1804603682),h=p(h,c,l,d,a[f+13],12,-40341101),d=p(d,h,c,l,a[f+14],17,-1502002290),c=g(c,l=p(l,d,h,c,a[f+15],22,1236535329),d,h,a[f+1],5,-165796510),h=g(h,c,l,d,a[f+6],9,-1069501632),d=g(d,h,c,l,a[f+11],14,643717713),l=g(l,d,h,c,a[f+0],20,-373897302),c=g(c,l,d,h,a[f+5],5,-701558691),h=g(h,c,l,d,a[f+10],9,38016083),d=g(d,h,c,l,a[f+15],14,-660478335),l=g(l,d,h,c,a[f+4],20,-405537848),c=g(c,l,d,h,a[f+9],5,568446438),h=g(h,c,l,d,a[f+14],9,-1019803690),d=g(d,h,c,l,a[f+3],14,-187363961),l=g(l,d,h,c,a[f+8],20,1163531501),c=g(c,l,d,h,a[f+13],5,-1444681467),h=g(h,c,l,d,a[f+2],9,-51403784),d=g(d,h,c,l,a[f+7],14,1735328473),c=y(c,l=g(l,d,h,c,a[f+12],20,-1926607734),d,h,a[f+5],4,-378558),h=y(h,c,l,d,a[f+8],11,-2022574463),d=y(d,h,c,l,a[f+11],16,1839030562),l=y(l,d,h,c,a[f+14],23,-35309556),c=y(c,l,d,h,a[f+1],4,-1530992060),h=y(h,c,l,d,a[f+4],11,1272893353),d=y(d,h,c,l,a[f+7],16,-155497632),l=y(l,d,h,c,a[f+10],23,-1094730640),c=y(c,l,d,h,a[f+13],4,681279174),h=y(h,c,l,d,a[f+0],11,-358537222),d=y(d,h,c,l,a[f+3],16,-722521979),l=y(l,d,h,c,a[f+6],23,76029189),c=y(c,l,d,h,a[f+9],4,-640364487),h=y(h,c,l,d,a[f+12],11,-421815835),d=y(d,h,c,l,a[f+15],16,530742520),c=m(c,l=y(l,d,h,c,a[f+2],23,-995338651),d,h,a[f+0],6,-198630844),h=m(h,c,l,d,a[f+7],10,1126891415),d=m(d,h,c,l,a[f+14],15,-1416354905),l=m(l,d,h,c,a[f+5],21,-57434055),c=m(c,l,d,h,a[f+12],6,1700485571),h=m(h,c,l,d,a[f+3],10,-1894986606),d=m(d,h,c,l,a[f+10],15,-1051523),l=m(l,d,h,c,a[f+1],21,-2054922799),c=m(c,l,d,h,a[f+8],6,1873313359),h=m(h,c,l,d,a[f+15],10,-30611744),d=m(d,h,c,l,a[f+6],15,-1560198380),l=m(l,d,h,c,a[f+13],21,1309151649),c=m(c,l,d,h,a[f+4],6,-145523070),h=m(h,c,l,d,a[f+11],10,-1120210379),d=m(d,h,c,l,a[f+2],15,718787259),l=m(l,d,h,c,a[f+9],21,-343485551),c=c+v>>>0,l=l+b>>>0,d=d+_>>>0,h=h+x>>>0;}return t.endian([c,l,d,h])};s._ff=function(e,t,r,n,i,o,s){var a=e+(t&r|~t&n)+(i>>>0)+s;return (a<<o|a>>>32-o)+t},s._gg=function(e,t,r,n,i,o,s){var a=e+(t&n|r&~n)+(i>>>0)+s;return (a<<o|a>>>32-o)+t},s._hh=function(e,t,r,n,i,o,s){var a=e+(t^r^n)+(i>>>0)+s;return (a<<o|a>>>32-o)+t},s._ii=function(e,t,r,n,i,o,s){var a=e+(r^(t|~n))+(i>>>0)+s;return (a<<o|a>>>32-o)+t},s._blocksize=16,s._digestsize=16,e.exports=function(e,r){if(null==e)throw new Error("Illegal argument "+e);var n=t.wordsToBytes(s(e,r));return r&&r.asBytes?n:r&&r.asString?o.bytesToString(n):t.bytesToHex(n)};}();},e=>{var t,r;t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&r.rotl(e,8)|4278255360&r.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=r.endian(e[t]);return e},randomBytes:function(e){for(var t=[];e>0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],r=0,n=0;r<e.length;r++,n+=8)t[n>>>5]|=e[r]<<24-n%32;return t},wordsToBytes:function(e){for(var t=[],r=0;r<32*e.length;r+=8)t.push(e[r>>>5]>>>24-r%32&255);return t},bytesToHex:function(e){for(var t=[],r=0;r<e.length;r++)t.push((e[r]>>>4).toString(16)),t.push((15&e[r]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],r=0;r<e.length;r+=2)t.push(parseInt(e.substr(r,2),16));return t},bytesToBase64:function(e){for(var r=[],n=0;n<e.length;n+=3)for(var i=e[n]<<16|e[n+1]<<8|e[n+2],o=0;o<4;o++)8*n+6*o<=8*e.length?r.push(t.charAt(i>>>6*(3-o)&63)):r.push("=");return r.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var r=[],n=0,i=0;n<e.length;i=++n%4)0!=i&&r.push((t.indexOf(e.charAt(n-1))&Math.pow(2,-2*i+8)-1)<<2*i|t.indexOf(e.charAt(n))>>>6-2*i);return r}},e.exports=r;},e=>{var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],r=0;r<e.length;r++)t.push(255&e.charCodeAt(r));return t},bytesToString:function(e){for(var t=[],r=0;r<e.length;r++)t.push(String.fromCharCode(e[r]));return t.join("")}}};e.exports=t;},e=>{function t(e){return !!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)} /*! * Determine if an object is a Buffer * * @author Feross Aboukhadijeh <https://feross.org> * @license MIT */ e.exports=function(e){return null!=e&&(t(e)||function(e){return "function"==typeof e.readFloatLE&&"function"==typeof e.slice&&t(e.slice(0,0))}(e)||!!e._isBuffer)};},(e,t,r)=>{r.r(t),r.d(t,{Base64:()=>$,VERSION:()=>i,atob:()=>A,atobPolyfill:()=>R,btoa:()=>y,btoaPolyfill:()=>g,btou:()=>N,decode:()=>k,encode:()=>S,encodeURI:()=>w,encodeURL:()=>w,extendBuiltins:()=>L,extendString:()=>j,extendUint8Array:()=>M,fromBase64:()=>k,fromUint8Array:()=>v,isValid:()=>F,toBase64:()=>S,toUint8Array:()=>T,utob:()=>x,version:()=>n});const n="3.7.8",i=n,o="function"==typeof Buffer,s="function"==typeof TextDecoder?new TextDecoder:void 0,a="function"==typeof TextEncoder?new TextEncoder:void 0,u=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),c=(e=>{let t={};return e.forEach((e,r)=>t[e]=r),t})(u),l=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,d=String.fromCharCode.bind(String),h="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),f=e=>e.replace(/=/g,"").replace(/[+\/]/g,e=>"+"==e?"-":"_"),p=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),g=e=>{let t,r,n,i,o="";const s=e.length%3;for(let s=0;s<e.length;){if((r=e.charCodeAt(s++))>255||(n=e.charCodeAt(s++))>255||(i=e.charCodeAt(s++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|i,o+=u[t>>18&63]+u[t>>12&63]+u[t>>6&63]+u[63&t];}return s?o.slice(0,s-3)+"===".substring(s):o},y="function"==typeof btoa?e=>btoa(e):o?e=>Buffer.from(e,"binary").toString("base64"):g,m=o?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let r=0,n=e.length;r<n;r+=4096)t.push(d.apply(null,e.subarray(r,r+4096)));return y(t.join(""))},v=(e,t=!1)=>t?f(m(e)):m(e),b=e=>{if(e.length<2)return (t=e.charCodeAt(0))<128?e:t<2048?d(192|t>>>6)+d(128|63&t):d(224|t>>>12&15)+d(128|t>>>6&63)+d(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return d(240|t>>>18&7)+d(128|t>>>12&63)+d(128|t>>>6&63)+d(128|63&t)},_=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,x=e=>e.replace(_,b),P=o?e=>Buffer.from(e,"utf8").toString("base64"):a?e=>m(a.encode(e)):e=>y(x(e)),S=(e,t=!1)=>t?f(P(e)):P(e),w=e=>S(e,!0),E=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,O=e=>{switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return d((t>>>10)+55296)+d(56320+(1023&t));case 3:return d((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return d((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},N=e=>e.replace(E,O),R=e=>{if(e=e.replace(/\s+/g,""),!l.test(e))throw new TypeError("malformed base64.");let t,r,n;e+="==".slice(2-(3&e.length));let i=[];for(let o=0;o<e.length;)t=c[e.charAt(o++)]<<18|c[e.charAt(o++)]<<12|(r=c[e.charAt(o++)])<<6|(n=c[e.charAt(o++)]),64===r?i.push(d(t>>16&255)):64===n?i.push(d(t>>16&255,t>>8&255)):i.push(d(t>>16&255,t>>8&255,255&t));return i.join("")},A="function"==typeof atob?e=>atob(p(e)):o?e=>Buffer.from(e,"base64").toString("binary"):R,C=o?e=>h(Buffer.from(e,"base64")):e=>h(A(e).split("").map(e=>e.charCodeAt(0))),T=e=>C(D(e)),I=o?e=>Buffer.from(e,"base64").toString("utf8"):s?e=>s.decode(C(e)):e=>N(A(e)),D=e=>p(e.replace(/[-_]/g,e=>"-"==e?"+":"/")),k=e=>I(D(e)),F=e=>{if("string"!=typeof e)return !1;const t=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return !/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},U=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),j=function(){const e=(e,t)=>Object.defineProperty(String.prototype,e,U(t));e("fromBase64",function(){return k(this)}),e("toBase64",function(e){return S(this,e)}),e("toBase64URI",function(){return S(this,!0)}),e("toBase64URL",function(){return S(this,!0)}),e("toUint8Array",function(){return T(this)});},M=function(){const e=(e,t)=>Object.defineProperty(Uint8Array.prototype,e,U(t));e("toBase64",function(e){return v(this,e)}),e("toBase64URI",function(){return v(this,!0)}),e("toBase64URL",function(){return v(this,!0)});},L=()=>{j(),M();},$={version:n,VERSION:i,atob:A,atobPolyfill:R,btoa:y,btoaPolyfill:g,fromBase64:k,toBase64:S,encode:S,encodeURI:w,encodeURL:w,utob:x,btou:N,decode:k,isValid:F,fromUint8Array:v,toUint8Array:T,extendString:j,extendUint8Array:M,extendBuiltins:L};},(e,t,r)=>{r.r(t),r.d(t,{DynamicPropertiesHandler:()=>a,defaultDynamicPropertyHandler:()=>o,setDynamicPropertyHandler:()=>s});const n=(e,t)=>t?t[e]:void 0;let i=n;function o(){return n}function s(e){i=e,e&&(i._isUserDefined=!0);}function a(){return i}},(e,t,r)=>{r.r(t),r.d(t,{ExceptionTrigger:()=>i,default:()=>o});var n=r(3);const i={DYNAMIC_PROPERTIES_RULE:"DYNAMIC_PROPERTIES_RULE",CONFIGURATION_FETCHED_HANDLER:"CONFIGURATION_FETCHED_HANDLER",IMPRESSION_HANDLER:"IMPRESSION_HANDLER",CUSTOM_PROPERTY_GENERATOR:"CUSTOM_PROPERTY_GENERATOR"},o=new class{invoke(e,t){if(this.userUnhandledErrorHandler)try{this.userUnhandledErrorHandler(e,t);}catch(e){n.default.error("User Unhandled Error Handler itself threw an exception. original exception:"+t,e);}else n.default.error("User Unhandled Error Occured, no fallback handler was set, exception ignored.",t);}setHandler(e){e instanceof Function?this.userUnhandledErrorHandler=e:n.default.warn("UserspaceUnhandledErrorHandler must be a function. default will be used.");}};},(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var n,i=r(22);!function(e){e.RolloutEu="eu",e.Platform="platform";}(n||(n={}));const o="x-api.rollout.io";let s=new i.default;const a=e=>{let t=o;e==n.RolloutEu&&(t=`eu-${o}`);const r={API_HOST:t,CD_API_ENDPOINT:`https://${t}/device/get_configuration`,CD_S3_ENDPOINT:"https://conf.rollout.io/",SS_API_ENDPOINT:`https://${t}/device/update_state_store/`,SS_S3_ENDPOINT:"https://statestore.rollout.io/",CLIENT_DATA_CACHE_KEY:"client_data",NOTIFICATIONS_ENDPOINT:"https://push.rollout.io/sse",ANALYTICS_ENDPOINT:"https://analytic.rollout.io",ERROR_REPORTER:void 0};return e==n.Platform&&(r.API_HOST="api.cloudbees.io",r.CD_API_ENDPOINT="https://api.cloudbees.io/device/get_configuration",r.CD_S3_ENDPOINT="https://rox-conf.cloudbees.io/",r.SS_API_ENDPOINT="https://api.cloudbees.io/device/update_state_store/",r.SS_S3_ENDPOINT="https://rox-state.cloudbees.io/",r.ANALYTICS_ENDPOINT="https://fm-analytics.cloudbees.io",r.NOTIFICATIONS_ENDPOINT="https://sdk-notification-service.cloudbees.io/sse"),r};let u=Object.assign({},a());const c={get:e=>u[e],set:(e,t)=>{u[e]=t;},setActive:function(e){u=Object.assign({},e);},setProxy:function(e){s=new i.default(e);},getProxy:()=>s,setHosting:function(e){e===n.RolloutEu&&(u=Object.assign({},a("eu-"))),e===n.Platform&&(u=Object.assign({},a(e)));},setSelfManagedMode:function(e){u=Object.assign({},a(),(({analyticsURL:e,serverURL:t,pushUpdateURL:r,configurationURL:n,stateURL:i})=>({CD_API_ENDPOINT:`${t}/device/get_configuration`,SS_API_ENDPOINT:`${t}/device/update_state_store/`,CLIENT_DATA_CACHE_KEY:"client_data",ANALYTICS_ENDPOINT:e,NOTIFICATIONS_ENDPOINT:`${r}/sse`,CD_S3_ENDPOINT:n,SS_S3_ENDPOINT:i,ERROR_REPORTER:void 0}))(e));},setErrorReporter:function(e){u.ERROR_REPORTER=e;},getErrorReporter:()=>u.ERROR_REPORTER};},(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});var n=r(18);const i="roxTargetUrl",o="roxAuth";class s{constructor(e){this._proxyUrl="",this._proxyAuthHeader="",this._proxySettings=!1,e&&(this._proxySettings=Object.assign({},e),this._proxyUrl=`${this._proxySettings.protocol}://${this._proxySettings.host}${this._proxySettings.port?`:${this._proxySettings.port}`:""}`,this._proxySettings.auth&&this._proxySettings.auth.username&&this._proxySettings.auth.password&&(this._proxyAuthHeader=`Basic ${(0, n.encode)(`${this._proxySettings.auth.username}:${this._proxySettings.auth.password}`)}`,this._proxyAuthHeaderEncoded=encodeURIComponent(this._proxyAuthHeader)));}applyProxyToRequest(e){if(this._proxySettings){e.options=e.options?Object.assign({},e.options):{};const t=e.options;t.params=t.params||{},t.params[i]=e.url,this._proxyAuthHeader&&(t.params[o]=this._proxyAuthHeader),e.url=this._proxyUrl;}}applyProxyToSseRequest(e){this._proxySettings&&(e.url=`${this._proxyUrl}?${i}=${encodeURIComponent(e.url)}`,this._proxyAuthHeaderEncoded&&(e.url=`${e.url}&${o}=${this._proxyAuthHeaderEncoded}`));}get proxyUrl(){return this._proxyUrl}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var n=r(24),i=r(27);const o="data",s="application",a="experiments",u="targetGroups",c="signed_date";class l{constructor(e,t,r=!0){if(!e||"object"!=typeof e)throw new Error(`ConfigurationParser should be constructed with JSON object. Received ${e}`);if(!t||"string"!=typeof t)throw new Error(`ConfigurationParser should be constructed with app key string. Received ${t}`);this._json=e,this._appKey=t,this._validateAppKey=r;}parse(){const e=this._extractInnerJson(this._json);return this._validateAppKey&&e[s]!==this._appKey?null:(this._parseExperiments(e[a]),this._parseTargetGroups(e[u]),this._signedDate=new Date(this._json[c]),this)}experiments(){return this._experiments||[]}targetGroups(){return this._targetGroups||[]}signedDate(){return this._signedDate}_extractInnerJson(e){return JSON.parse(e[o])}_parseExperiments(e){this._experiments=new n.default(e).parse();}_parseTargetGroups(e){this._targetGroups=new i.default(e).parse();}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>p});var n=r(25),i=r(26);const o="deploymentConfiguration",s="condition",a="archived",u="sticky",c="_id",l="name",d="featureFlags",h="labels",f="stickinessProperty";class p{constructor(e){this._json=e;}parse(){if(!this._json||!this._json.length)return [];const e=[];return this._json.forEach(t=>{if(!(t&&t[o]&&t[c]&&t[l]&&t[d]))return;const r=t[o];if(!r[s])return;const p=t[h]||[],g=new n.default(r[s]);e.push(new i.default(t[c],t[l],!!t[a],!!t[u],g,t[d],p,t[f]));}),e}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});class n{constructor(e){this.condition=e;}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});class n{constructor(e,t,r,n,i,o,s,a){this.identifier=e,this.name=t,this.archived=r,this.sticky=n,this.deploymentConfiguration=i,this.flags=o,this.labels=s,this.stickinessProperty=a;}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});var n=r(28);const i="_id",o="condition";class s{constructor(e){this._json=e;}parse(){if(!this._json||!this._json.length)return [];const e=[];return this._json.forEach(t=>{t&&t[i]&&t[o]&&e.push(new n.default(t[i],t[o]));}),e}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});class n{constructor(e,t){this.identifier=e,this.condition=t;}}},(e,t,r)=>{r.r(t),r.d(t,{CallContextTypes:()=>u.callContextTypes,CustomProperty:()=>n.default,DeploymentConfiguration:()=>o.default,DeviceProperty:()=>i.default,Experiment:()=>s.default,FlagTypes:()=>u.FlagTypes,RoxStringBase:()=>u.default,TargetGroup:()=>a.default});var n=r(30),i=r(31),o=r(25),s=r(26),a=r(28),u=r(32);},(e,t,r)=>{r.r(t),r.d(t,{default:()=>o});var n=r(20);const i="Semver";class o{constructor(e,t,r){t===i&&(this._isSemver=!0,t=String),function(e){if(void 0===e||""===e)throw new Error("Custom property must be initialized with a name.")}(e),this._name=e,"function"==typeof r?(function(e){if(e.length>1)throw new Error("Dynamic value of a custom property should be a function with maximum 1 argument")}(r),r.isDynamic=!0,this._value=r):(function(e,t){if(t&&t.constructor!==e&&t.constructor!==Function)throw new Error(`Custom property initialized with an invalid type / value combination. (Type: ${e}, Value: ${t})`)}(t,r),this._value=()=>r),this._type=t;}get type(){return this.externalType}get externalType(){return this._isSemver?i:this._type.name==Date.name?o.dateTypeName:this._type.name}get name(){return this._name}getValue(e={}){if(this._value&&this._value.isDynamic)try{return this._value(e)}catch(e){throw e.isUserError=!0,e.trigger=n.ExceptionTrigger.CUSTOM_PROPERTY_GENERATOR,e}return this._value(e)}static get dateTypeName(){return "DateTime"}static get semverTypeName(){return i}get value(){return this._value()}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var n=r(30);class i extends n.default{get name(){return `rox.${super.name}`}}},(e,t,r)=>{r.r(t),r.d(t,{FlagTypes:()=>o,callContextTypes:()=>i,default:()=>s});var n=r(33);const i={frozenOrCalc:"frozenValueOrOneTimeEval",oneTimeCalc:"oneTimeEval",default:"useFrozen"},o={boolean:"boolean",number:"number",string:"string"};class s{constructor(e,t,r){this._type=r;const n=this._validateDefault(e);if(Array.isArray(t))this._validateOptions(t),this._options=t.map(e=>e.toString());else {if(null!=t)throw new Error("RoxStringBase wrong variations type");this._options=[];}-1===this._options.indexOf(n)&&this._options.push(n),this._value=this._defaultValue=n,this._frozen=!1,this._freezable=!0;}_validateDefault(e){if(typeof e!==this._type)throw new Error(`RoxStringBase default value must be of ${this._type} type. Received '${e}'`);return e.toString()}_validateOptions(e){const t=new Error(`RoxStringBase options must be a non-empty array of ${this._type}. Received '${e}'`);if(!e.every(e=>typeof e===this._type))throw t}get defaultValue(){return this._defaultValue}get overridenValue(){if(this.overrider.hasOverride(this.name))return this.overrider.getOverride(this.name)}get overrider(){throw new Error("Not implemented")}getInternalValue(e,t){throw Error("not implemented")}get externalType(){switch(this._type){case o.boolean:return Boolean.name;case o.number:return Number.name;case o.string:default:return String.name}}set name(e){this._name=e;}get name(){return this._name}_getNameDetails(){if(!this.name)return;const e=this.name.split(".");return {name:e.pop(),namespace:e.join(".")||"default"}}dump(){const e={type:i.frozenOrCalc};return this.getInternalValue(e),{name:this.name,type:this._type,nameDetails:this._getNameDetails(),options:[...this._options],defaultValue:this.defaultValue,originalValue:this._originalValue(),overridingValue:this.overridenValue,value:e.result.value}}getActiveValue(e,t){throw new Error("Not implemented")}_originalValue(){const e={type:i.frozenOrCalc};return this.getActiveValue(e),e.result.value}_flagImpression(e,t){(0, n.invokeImpression)(e,this,t);}static _normalizeString(e){return e}static _normalizeNumber(e){return Number(e)}static _normalizeBoolean(e){return "boolean"==typeof e?e:"true"===e}}},(e,t,r)=>{r.r(t),r.d(t,{invokeImpression:()=>l,setAnalytics:()=>h,setHandler:()=>d});var n=r(3),i=r(34),o=r(6),s=r(5),a=r(20);let u=null,c=null;function l(e,t,r){const l=o.default.experimentForFlag(t);try{if(c&&(0,i.isEnabled)("rox.internal.analytics")){const n=l&&l.stickinessProperty;let i=n&&s.default.get(n);i=i||s.default.get("rox.distinct_id");const o=i?i.getValue(r):"";c.track({flag:t.name,value:e,distinctId:o,type:"IMPRESSION",time:(new Date).getTime()});}}catch(e){n.default.error("Failed to send analytics",e);}if("function"!=typeof u)return;const d=!!l;try{u({name:t.name,value:e,targeting:d},r);}catch(e){a.default.invoke(a.ExceptionTrigger.IMPRESSION_HANDLER,e);}}function d(e){u=e;}function h(e){c=e;}},(e,t,r)=>{r.r(t),r.d(t,{getNumber:()=>c,isEnabled:()=>a,setDefaultsMode:()=>l,value:()=>u});var n=r(10),i=r(6);let o=!1;const s={"rox.internal.pushUpdates":"true","rox.internal.considerThrottleInPush":"false","rox.internal.throttleFetchInSeconds":"0","rox.internal.analytics":"true"};function a(e){const t=u(e);return "boolean"==typeof t?t:"true"===t}function u(e){if(o&&Object.prototype.hasOwnProperty.call(s,e))return s[e];const t=i.default.experimentForFlagName(e);return t&&t.deploymentConfiguration?(new n.default).evaluateExpression(t.deploymentConfiguration.condition):""}function c(e){const t=u(e);return parseInt(t)||0}function l(e){o=e;}},(e,t,r)=>{r.r(t),r.d(t,{Actions:()=>n,Manager:()=>i});var n=r(36),i=r(37);},(e,t,r)=>{r.r(t),r.d(t,{getMergedContext:()=>i,getMergedContextWithGlobal:()=>o});var n=r(37);function i(e,t){return e?Object.assign({},e,t):Object.assign({},t)}function o(e){const t=n.getContext();return e?Object.assign({},t,e):Object.assign({},t)}},(e,t,r)=>{r.r(t),r.d(t,{getContext:()=>i,setContext:()=>o});let n={};function i(){return n}function o(e){n=e;}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});class n{constructor(e,t){this.cache=e,this._uuid=t,this.distinct_id=this.generateDistinctId(),this.app_release="0.0",this.distinctIdSetExplicitly=!1;}setPlatform(e){this.platform=e;}setRealPlatform(e){this.realPlatform=e;}setDistinctId(e){this.distinctIdSetExplicitly=!0,this.distinct_id=e;}setAppRelease(e){this.app_release=e;}uuid(){return this._uuid()}generateDistinctId(){let e=this.cache.get("distinctId");return e||(e=this.uuid(),this.cache.set("distinctId",e)),e}}},(e,t,r)=>{r.r(t),r.d(t,{Client:()=>R,createRoxClient:()=>C});var n=r(40),i=r(41),o=r(49),s=r(3),a=r(5),u=r(6),c=r(7),l=r(8),d=r(50),h=r(21),f=r(30),p=r(10),g=r(33),y=r(20),m=r(51),v=r(52),b=r(34),_=r(19),x=r(53),P=r.n(x),S=r(47),w=r(67),E=r(70),O=r(71);let N={ClassRegister:o.default};class R{constructor(e=5e3){this.classRegisterer=new N.ClassRegister,this.sendStateDebounceNoCheck=P()(()=>{this._sendState();},e,{maxWait:e,leading:!1,trailing:!0}),this.sendStateDebounced=()=>{this.appKey&&this.sendStateDebounceNoCheck();},this.onConfigurationFetched=this.onConfigurationFetched.bind(this);}get dynamicApi(){return this._dynamicApi}get appKey(){return this.app_key}setKey(e,t){const r=/^[a-f\d]{24}$/i.test(e),n=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e);if(!r&&!n)throw Error("invalid rollout apikey");this.app_key=e,n&&(h.default.setHosting("platform"),t.disableSignatureVerification=!0);}setup(e){var t;try{this.handleOptions(e),N.DeviceProperties=N.DeviceProperties.create?N.DeviceProperties.create(N):N.DeviceProperties,this.app_release&&N.DeviceProperties.setAppRelease(this.app_release),this.distinct_id&&N.DeviceProperties.setDistinctId(this.distinct_id),this.platform&&N.DeviceProperties.setPlatform(this.platform),this.deviceProperties=N.DeviceProperties,this.deviceProperties.setRealPlatform(this.realPlatform),this.selfManagedMode&&h.default.setErrorReporter(new n.BugsnagReporter(this.appKey,N.DeviceProperties,this.networkOptions,this.networkApi)),this.configurationFetcher=new i.default(this.appKey,this.deviceProperties,this.devModeSecret,N,this.embeddedConfiguration,{roxyUrl:this.roxyUrl,selfManagedMode:this.selfManagedMode,disableSignatureVerification:this.disableSignatureVerification},this.networkOptions,this.networkApi),this.roxyUrl||(this.stateSender=new w.default(this.appKey,this.deviceProperties,this.devModeSecret,this.networkOptions,{selfManagedMode:this.selfManagedMode},this.disableSignatureVerification,this.networkApi),this.disableNetwork||(0,g.setAnalytics)(new m.default(this.appKey,Object.assign({},this.analyticsOptions),N.DeviceProperties,this.networkOptions,this.networkApi))),N.getDefaultCustomProperties(this.deviceProperties,this.appKey).map(a.default.setIfNotExists.bind(a.default));}catch(e){const r="Uh oh! An error occurred during setup.";s.default.error(r,e),null===(t=h.default.getErrorReporter())||void 0===t||t.error(r,e);}return Promise.resolve(this)}handleOptions(e){const t=N.DefaultSetupOptions.platform,r=Object.assign({},N.DefaultSetupOptions,e);if(r.selfManaged&&"object"==typeof r.selfManaged){if(!r.selfManaged.analyticsURL)throw new Error("analyticsURL is required on self managed mode");if(!r.selfManaged.serverURL)throw new Error("serverURL is required on self managed mode");e.selfManaged.configurationURL&&(r.selfManaged.configurationURL=e.selfManaged.configurationURL.endsWith("/")?e.selfManaged.configurationURL:`${e.selfManaged.configurationURL}/`),e.selfManaged.stateURL&&(r.selfManaged.stateURL=e.selfManaged.stateURL.endsWith("/")?e.selfManaged.stateURL:`${e.selfManaged.stateURL}/`),h.default.setSelfManagedMode(r.selfManaged),(0, b.setDefaultsMode)(!0),this.selfManagedMode=!0;}r.configuration&&r.configuration.disableNetwork&&(this.disableNetwork=!0),this.embeddedConfiguration=r.embedded,this.fetchIntervalInSec=r.fetchIntervalInSec,this.disablePushUpdateListener=!!(this.disableNetwork||this.selfManagedMode&&!r.selfManaged.pushUpdateURL)||r.disablePushUpdateListener,this.configurationFetchedHandler=r.configurationFetchedHandler,this.impressionHandler=r.impressionHandler,this.dynamicPropertyRuleHandler=r.dynamicPropertyRuleHandler,this.app_release=r.version,this.distinct_id=r.distinctId,this.devModeSecret=r.devModeSecret,this.platform=r.platform,this.fetchFunction=r.fetchFunction,this.networkApi=r.networkApi,this.networkApi?s.default.debug("network: using custom"):this.fetchFunction?(s.default.debug("network: using fetch"),this.networkApi=new E.FetchNetwork(this.fetchFunction)):(s.default.debug("network: using axios"),this.networkApi=new O.AxiosNetwork),this.realPlatform=t,this.roxyUrl=r.roxy,this.networkOptions={httpAgent:r.httpAgent,httpsAgent:r.httpsAgent},this.disableSignatureVerification=r.disableSignatureVerification||!1,this.analyticsOptions=r.analytics,this.eventSourceImpl=r.eventSourceImpl,(0, g.setHandler)(this.impressionHandler),e.logger&&s.default.setLogger(e.logger),this.dynamicPropertyRuleHandler&&(0, _.setDynamicPropertyHandler)(this.dynamicPropertyRuleHandler);}fetchPeriodically(){if(!this.app_key)return s.default.warn("no app key"),Promise.reject();if(this.fetchIntervalInSec<=0)return Promise.resolve();this.fetchIntervalInSec<30&&(this.fetchIntervalInSec=30);const e=this._fetch({useCache:!1});return this.configurationFetcher.dispatchPeriodically({handler:this.onConfigurationFetched,periodTimeInSec:this.fetchIntervalInSec}),e}fetchCacheOnly(){return this._fetch({useCache:!0,skipNetwork:!0})}fetchWithCacheAndProceed(){return this._fetch({useCache:!0})}fetch(){return this._fetch({useCache:!1})}_fetchFromPush(){return this._fetch({useCache:!1,source:"push"})}sendState(){this._sendState();}_sendState(){this.sendStateDebounceNoCheck.cancel(),this.app_key&&(this.disableNetwork?s.default.debug("send state - disabled network"):this.stateSender&&this.stateSender.send());}_fetch(e={}){if(this.app_key){if(this.configurationFetcher)return this.disableNetwork&&(s.default.debug("fetch - disabling network"),e.skipNetwork=!0),this.configurationFetcher.dispatch({handler:this.onConfigurationFetched,options:e})}else s.default.warn("no app key");}register(e,t){void 0===t&&"object"==typeof e&&null!==e&&(t=e,e=""),s.default.debug(`Registering container '${e}' = ${JSON.stringify(t)}`),this.classRegisterer.handleContainer(e,t),this.sendStateDebounced();}setSemverCustomProperty(e,t){this.setCustomProperty(e,f.default.semverTypeName,t);}setCustomProperty(e,t,r){const n=new f.default(e,t,r),i=!a.default.has(n);a.default.set(n),i&&this.sendStateDebounced();}unfreeze(e,t){c.default.flags.filter(t=>{if(!t.name||"string"!=typeof e)return !0;const r=t.name.split(".");return 1===r.length&&""===e||r.slice(0,r.length-1).join(".")===e}).forEach(e=>{e.unfreeze(t);});}get metadata(){const e=new p.default,t=l.default.targetGroups.map(t=>({name:t.name,isEnabled:e.evaluateExpression(t.condition)})),r=u.default.experiments.map(t=>{return {name:t.name,isEnabled:(r=e.evaluateExpression(t.deploymentConfiguration.condition),"true"===r)};var r;}),n=c.default.flags.map(e=>({name:e.name,value:e._peek()}));return {targetGroups:t,experiments:r,flags:n}}onConfigurationFetched(e){try{e.fetcherStatus!==S.FetcherStatus.ERROR_FETCH_FAILED&&this.startOrStopPushUpdatesListener();}catch(e){s.default.warn(`Cound not start or stop push notification listener. exception: ${e}`);}if(this.configurationFetchedHandler instanceof Function)try{return this.configurationFetchedHandler(e)}catch(e){y.default.invoke(y.ExceptionTrigger.CONFIGURATION_FETCHED_HANDLER,e);}}startOrStopPushUpdatesListener(){!this.disablePushUpdateListener&&(0, b.isEnabled)("rox.internal.pushUpdates")?this.app_key&&(this.pushUpdatesListener||(this.pushUpdatesListener=new v.default(h.default.get("NOTIFICATIONS_ENDPOINT"),this.app_key,this.eventSourceImpl,this.networkOptions),this.pushUpdatesListener.on("changed",()=>{this._fetchFromPush();}))):this.pushUpdatesListener&&(this.pushUpdatesListener.stop(),this.pushUpdatesListener=null);}setUserspaceUnhandledErrorHandler(e){y.default.setHandler(e);}get cacheURL(){if(!this.configurationFetcher||!this.configurationFetcher.cacheURL)throw new Error("Rox was not initialized. Please call setup() before calling cacheURL()");return this.configurationFetcher.cacheURL}}const A=new R;function C(e={}){return N=Object.assign({},N,e),A._dynamicApi=new d.default(e.EntitiesProvider,c.default,A),A}},(e,t,r)=>{r.r(t),r.d(t,{BugsnagReporter:()=>o});var n=r(3),i=r(21);class o{constructor(e,t,r,n){const i=t.getProperties(),{distinct_id:o,app_release:s,platform:a,api_version:u,lib_version:c}=i,l=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);}return r}(i,["distinct_id","app_release","platform","api_version","lib_version"]);this.device=l,this.header={apiKey:"abbf3bd9c6e80eb1e8c0566c35b08748",notifier:{name:"Rollout JavaScript SDK",version:c,url:"undefined"!=typeof window&&window.location&&window.location.href||void 0}},this.networkOptions=r,this.networkSender=n,this.user={distinct_id:o,app_release:s,app_key:e,platform:a},this.app={api_version:u,lib_version:c};}error(e,t){return this._notify("error",e,t)}_notify(e,t,r){const n={payloadVersion:4,exceptions:[],app:this.app,user:this.user,device:this.device,metaData:{data:{message:t,exception:r.toString()}},severity:e};return r instanceof Error?(n.exceptions.push({errorClass:r.name,message:t+"\n"+r.message,stacktrace:r.stack||""}),n.groupingHash=r.fileName):n.exceptions.push({errorClass:"Error",message:t,stacktrace:[]}),this._send([n])}_send(e){const t=Object.assign({events:e},this.header);n.default.debug("Sending bugsnag error report.");const r={url:"https://notify.bugsnag.com",data:t,options:this.networkOptions};i.default.getProxy().applyProxyToRequest(r);try{this.networkSender.post(r.url,r.data,r.options).then(()=>{n.default.debug("Successfully sent error report.");}).catch(e=>{n.default.debug("Failed to send error report",e);});}catch(e){n.default.debug("Failed to send error report.",e);}}}},(e,t,r)=>{r.r(t),r.d(t,{default:()=>m});var n=r(42),i=r(45),o=r(23),s=r(2),a=r(34),u=r(21),c=r(8),l=r(6),d=r(7),h=r(3),f=r(47),p=r(48);const g=u.default.get("CLIENT_DATA_CACHE_KEY");let y=!1;const m=class{constructor(e,t,r,n,i,o,s,a){this.cache=n.RoxCache,this.crypto=n.RoxCrypto,this.embdeddedJSON=this.fetchFromEmbedded(i),this.appKey=e,this.deviceProperties=t,this.devModeSecret=r,this.options=o||{},this.networkOptions=s,this.networkSender=a,this.lastResponse=null;}runHandler(e,t){var r;if(t.errorDetails&&(null===(r=u.default.getErrorReporter())||void 0===r||r.error("Configuration fetcher returned with "+t.fetcherStatus,t.errorDetails)),e instanceof Function)try{e(t);}catch(e){}}dispatch({handler:e,options:t}){try{h.default.debug("dispatch();");const r=[];if(t.useCache){if(this.embdeddedJSON)if(this.verifyPayload(this.embdeddedJSON)){const e=this.parsePayload(this.embdeddedJSON);e&&r.push({payload:this.embdeddedJSON,parser:e,status:f.FetcherStatus.APPLIED_FROM_EMBEDDED});}else h.default.error("The embdeddedJSON was corrupted or its authenticity cannot be securely verified. skipping embedded");const e=this.fetchFromCache();if(e)if(this.verifyPayload(e)){const t=this.parsePayload(e);t&&r.push({payload:e,parser:t,status:f.FetcherStatus.APPLIED_FROM_CACHE});}else h.default.error("The cachedPayload was corrupted or its authenticity cannot be securely verified. skipping cache");}if(r.length>0){const t=r.reduce((e,t)=>e&&e.parser.signedDate()>t.parser.signedDate()?e:t,null);(!this.lastApplied||this.lastApplied.signedDate()<t.parser.signedDate())&&(this.lastResponse=t.payload,this.apply(t.parser,t.status,!1,e,t.payload));}if(t.skipNetwork)return;return this.shouldSkipFetch(t.source)?void h.default.debug("Skipping fetch - kill switch"):this._dispatch({handler:e,storeInCache:!0})}catch(e){h.default.error("Unexpected error in dispatch",e);}}shouldSkipFetch(e){const t="push"===e,r=(0, a.getNumber)("rox.internal.throttleFetchInSeconds");if(r>0&&(!t||(0, a.isEnabled)("rox.internal.considerThrottleInPush"))){const e=+Date.now();if(this.lastFetchTryTime&&e<this.lastFetchTryTime+1e3*r)return !0;this.lastFetchTryTime=e;}return !1}dispatchPeriodically({handler:e,periodTimeInSec:t}){if(y)return h.default.debug("Dispatch Periodically alre