@frontegg/js 7.70.0 → 7.72.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.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see frontegg.production.min.js.LICENSE.txt */
2
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Frontegg=e():t.Frontegg=e()}(window,(()=>(()=>{var t={3952:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createConditionEvaluator=void 0;const n=a(2904),s=a(9475);e.createConditionEvaluator=function(t){const e=(0,s.useSanitizer)(t.condition.op);if(!e)return()=>!1;const{isSanitized:a,sanitizedValue:i}=e(t.condition.value);if(!a||void 0===i)return()=>!1;const o=(0,n.useOperation)(t.condition.op,i);return e=>{const a=e[t.condition.attribute];if(void 0===a||!o)return!1;const{isValid:n}=o(a);return t.condition.negate?!n:n}}},9838:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(3952),e),s(a(963),e)},963:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},3998:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.evaluateFeatureFlag=void 0;const n=a(9243);e.evaluateFeatureFlag=function(t,e){if(!t.on)return{treatment:t.offTreatment};const a=function(t,e){var a;return null===(a=t.rules)||void 0===a?void 0:a.find((t=>(0,n.createRuleEvaluator)({rule:t})(e)===n.RuleEvaluationResultEnum.Treatable))}(t,e);return a?{treatment:a.treatment}:{treatment:t.defaultTreatment}}},2152:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(3998),e)},5875:(t,e,a)=>{"use strict";e.Me=e.a_=void 0;a(2152),a(3856),a(9243),a(2752);var n=a(7254);Object.defineProperty(e,"a_",{enumerable:!0,get:function(){return n.evaluateIsEntitledToFeature}}),Object.defineProperty(e,"Me",{enumerable:!0,get:function(){return n.evaluateIsEntitledToPermissions}})},6849:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),e.BooleanOperationsMapper=void 0;const i=a(2752),o=a(6715);s(a(6715),e),s(a(4965),e),e.BooleanOperationsMapper={[i.OperationEnum.Is]:t=>(0,o.useIsOperation)(t)}},6715:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useIsOperation=void 0,e.useIsOperation=function(t){return e=>({isValid:e===t.boolean})}},4965:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BooleanSanitizersMapper=e.singleBooleanSanitizer=void 0;const n=a(2752);e.singleBooleanSanitizer=t=>{const e=void 0!==t.boolean&&(t=>"boolean"==typeof t)(t.boolean)?{boolean:t.boolean}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.BooleanSanitizersMapper={[n.OperationEnum.Is]:e.singleBooleanSanitizer}},2904:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useOperation=void 0;const n=a(5018),s=a(3922),i=a(3147),o=a(6849),r={...n.StringOperationsMapper,...s.NumericOperationsMapper,...i.DateOperationsMapper,...o.BooleanOperationsMapper};e.useOperation=function(t,e){const a=r[t];return a?a(e):void 0}},9475:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useSanitizer=void 0;const n=a(6849),s=a(1016),i=a(6891),o=a(3922),r={...s.StringSanitizersMapper,...o.NumericSanitizersMapper,...i.DateSanitizersMapper,...n.BooleanSanitizersMapper};e.useSanitizer=function(t){return r[t]}},3147:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),e.DateOperationsMapper=void 0;const i=a(2752),o=a(1641);s(a(1641),e),s(a(1626),e),e.DateOperationsMapper={[i.OperationEnum.On]:t=>(0,o.useDateOnOperation)(t),[i.OperationEnum.OnOrAfter]:t=>(0,o.useDateOnOrAfterOperation)(t),[i.OperationEnum.OnOrBefore]:t=>(0,o.useDateOnOrBeforeOperation)(t),[i.OperationEnum.BetweenDate]:t=>(0,o.useDateBetweenOperation)(t)}},1641:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useDateBetweenOperation=e.useDateOnOrBeforeOperation=e.useDateOnOrAfterOperation=e.useDateOnOperation=void 0,e.useDateOnOperation=function(t){return e=>({isValid:e.getTime()===t.date.getTime()})},e.useDateOnOrAfterOperation=function(t){return e=>({isValid:e.getTime()>=t.date.getTime()})},e.useDateOnOrBeforeOperation=function(t){return e=>({isValid:e.getTime()<=t.date.getTime()})},e.useDateBetweenOperation=function(t){return e=>({isValid:e.getTime()>=t.start.getTime()&&e.getTime()<=t.end.getTime()})}},6891:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DateSanitizersMapper=e.sanitizeDateRange=e.sanitizeSingleDate=e.isValidDate=e.sanitizeDateValue=void 0;const n=a(2752);e.sanitizeDateValue=t=>new Date(t),e.isValidDate=t=>t instanceof Date&&!isNaN(t),e.sanitizeSingleDate=t=>{const a=t.date?(0,e.sanitizeDateValue)(t.date):void 0,n=a&&(0,e.isValidDate)(a)?{date:a}:void 0;return{isSanitized:!!n,sanitizedValue:n}},e.sanitizeDateRange=t=>{const a=t.start?(0,e.sanitizeDateValue)(t.start):void 0,n=t.end?(0,e.sanitizeDateValue)(t.end):void 0,s=a&&n&&(0,e.isValidDate)(a)&&(0,e.isValidDate)(n)?{start:a,end:n}:void 0;return{isSanitized:!!s,sanitizedValue:s}},e.DateSanitizersMapper={[n.OperationEnum.On]:e.sanitizeSingleDate,[n.OperationEnum.OnOrAfter]:e.sanitizeSingleDate,[n.OperationEnum.OnOrBefore]:e.sanitizeSingleDate,[n.OperationEnum.BetweenDate]:e.sanitizeDateRange}},1626:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},3922:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),e.NumericOperationsMapper=void 0;const i=a(2752),o=a(9194);e.NumericOperationsMapper={[i.OperationEnum.Equal]:t=>(0,o.useEqualsOperation)(t),[i.OperationEnum.GreaterThan]:t=>(0,o.useGreaterThanOperation)(t),[i.OperationEnum.GreaterThanEqual]:t=>(0,o.useGreaterThanEqualOperation)(t),[i.OperationEnum.LesserThan]:t=>(0,o.useLesserThanOperation)(t),[i.OperationEnum.LesserThanEqual]:t=>(0,o.useLesserThanEqualOperation)(t),[i.OperationEnum.BetweenNumeric]:t=>(0,o.useBetweenNumericOperation)(t)},s(a(9194),e),s(a(5168),e),s(a(7695),e)},9194:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useBetweenNumericOperation=e.useLesserThanEqualOperation=e.useLesserThanOperation=e.useGreaterThanEqualOperation=e.useGreaterThanOperation=e.useEqualsOperation=void 0,e.useEqualsOperation=function(t){return e=>({isValid:e===t.number})},e.useGreaterThanOperation=function(t){return e=>({isValid:e>t.number})},e.useGreaterThanEqualOperation=function(t){return e=>({isValid:e>=t.number})},e.useLesserThanOperation=function(t){return e=>({isValid:e<t.number})},e.useLesserThanEqualOperation=function(t){return e=>({isValid:e<=t.number})},e.useBetweenNumericOperation=function(t){return e=>({isValid:e>=t.start&&e<=t.end})}},5168:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.NumericSanitizersMapper=e.sanitizeNumericRange=e.sanitizeSingleNumber=void 0;const n=a(2752),s=t=>"number"==typeof t;e.sanitizeSingleNumber=t=>{const e=void 0!==t.number&&s(t.number)?{number:t.number}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.sanitizeNumericRange=t=>{const e=void 0!==t.start&&void 0!==t.end&&s(t.start)&&s(t.end)?{start:t.start,end:t.end}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.NumericSanitizersMapper={[n.OperationEnum.Equal]:e.sanitizeSingleNumber,[n.OperationEnum.GreaterThan]:e.sanitizeSingleNumber,[n.OperationEnum.GreaterThanEqual]:e.sanitizeSingleNumber,[n.OperationEnum.LesserThan]:e.sanitizeSingleNumber,[n.OperationEnum.LesserThanEqual]:e.sanitizeSingleNumber,[n.OperationEnum.BetweenNumeric]:e.sanitizeNumericRange}},7695:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},5018:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),e.StringOperationsMapper=void 0;const i=a(2752),o=a(5154);s(a(5154),e),s(a(4503),e),e.StringOperationsMapper={[i.OperationEnum.StartsWith]:t=>(0,o.useStartsWithOperation)(t),[i.OperationEnum.EndsWith]:t=>(0,o.useEndsWithOperation)(t),[i.OperationEnum.Contains]:t=>(0,o.useContainsOperation)(t),[i.OperationEnum.InList]:t=>(0,o.useInListOperation)(t),[i.OperationEnum.Matches]:t=>(0,o.useMatchesOperation)(t)}},5154:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useMatchesOperation=e.useInListOperation=e.useContainsOperation=e.useEndsWithOperation=e.useStartsWithOperation=void 0,e.useStartsWithOperation=function(t){return e=>({isValid:t.list.some((t=>e.startsWith(t)))})},e.useEndsWithOperation=function(t){return e=>({isValid:t.list.some((t=>e.endsWith(t)))})},e.useContainsOperation=function(t){return e=>({isValid:t.list.some((t=>e.includes(t)))})},e.useInListOperation=function(t){return e=>({isValid:t.list.includes(e)})},e.useMatchesOperation=function(t){return e=>{let a;try{a=new RegExp(t.string)}catch(t){return{isValid:!1}}return{isValid:a.test(e)}}}},1016:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StringSanitizersMapper=e.sanitizeListString=e.sanitizeSingleString=void 0;const n=a(2752),s=t=>"string"==typeof t;e.sanitizeSingleString=t=>{const e=void 0!==t.string&&s(t.string)?{string:t.string}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.sanitizeListString=t=>{const e=void 0!==t.list&&t.list.every((t=>s(t)))?{list:t.list}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.StringSanitizersMapper={[n.OperationEnum.Matches]:e.sanitizeSingleString,[n.OperationEnum.Contains]:e.sanitizeListString,[n.OperationEnum.StartsWith]:e.sanitizeListString,[n.OperationEnum.EndsWith]:e.sanitizeListString,[n.OperationEnum.InList]:e.sanitizeListString}},4503:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},2752:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(7158),e)},7158:(t,e)=>{"use strict";var a;Object.defineProperty(e,"__esModule",{value:!0}),e.OperationEnum=void 0,(a=e.OperationEnum||(e.OperationEnum={})).InList="in_list",a.StartsWith="starts_with",a.EndsWith="ends_with",a.Contains="contains",a.Matches="matches",a.Equal="equal",a.GreaterThan="greater_than",a.GreaterThanEqual="greater_than_equal",a.LesserThan="lower_than",a.LesserThanEqual="lower_than_equal",a.BetweenNumeric="between_numeric",a.Is="is",a.On="on",a.BetweenDate="between_date",a.OnOrAfter="on_or_after",a.OnOrBefore="on_or_before"},3856:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(6334),e)},6334:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.evaluatePlan=void 0;const n=a(9243);e.evaluatePlan=function(t,e){const a=function(t,e){var a;return null===(a=t.rules)||void 0===a?void 0:a.find((t=>(0,n.createRuleEvaluator)({rule:t})(e)===n.RuleEvaluationResultEnum.Treatable))}(t,e);return a?{treatment:a.treatment}:{treatment:t.defaultTreatment}}},9243:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(5546),e),s(a(4874),e)},4874:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createRuleEvaluator=void 0;const n=a(5546),s=a(9838);e.createRuleEvaluator=function(t){return e=>t.rule.conditions.every((t=>(0,s.createConditionEvaluator)({condition:t})(e)))?n.RuleEvaluationResultEnum.Treatable:n.RuleEvaluationResultEnum.Insufficient}},5546:(t,e)=>{"use strict";var a,n;Object.defineProperty(e,"__esModule",{value:!0}),e.RuleEvaluationResultEnum=e.TreatmentEnum=e.ConditionLogicEnum=void 0,(e.ConditionLogicEnum||(e.ConditionLogicEnum={})).And="and",(n=e.TreatmentEnum||(e.TreatmentEnum={})).True="true",n.False="false",(a=e.RuleEvaluationResultEnum||(e.RuleEvaluationResultEnum={})).Treatable="treatable",a.Insufficient="insufficient"},7254:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(7416),e),s(a(3817),e),s(a(395),e),s(a(6816),e)},1711:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.directEntitlementEvalutor=void 0;const n=a(395);e.directEntitlementEvalutor=function(t,e,a={}){const s=e.features[t];let i=!1;return s&&null!==s.expireTime&&(i=s.expireTime!==n.NO_EXPIRATION_TIME&&s.expireTime<Date.now(),!i)?{isEntitled:!0}:{isEntitled:!1,justification:i?n.NotEntitledJustification.BUNDLE_EXPIRED:n.NotEntitledJustification.MISSING_FEATURE}}},1343:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.featureFlagEvaluator=void 0;const n=a(395),s=a(2152),i=a(8552),o=a(9243);e.featureFlagEvaluator=function(t,e,a={}){const r=e.features[t];if(r&&r.featureFlag){const t=(0,i.prepareAttributes)(a),{treatment:e}=(0,s.evaluateFeatureFlag)(r.featureFlag,t);if(e===o.TreatmentEnum.True)return{isEntitled:!0}}return{isEntitled:!1,justification:n.NotEntitledJustification.MISSING_FEATURE}}},2031:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getIsEntitledEvaluators=void 0;const n=a(1711),s=a(1343),i=a(3155);e.getIsEntitledEvaluators=function(){return[n.directEntitlementEvalutor,s.featureFlagEvaluator,i.planTargetingRulesEvalutor]}},3155:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.planTargetingRulesEvalutor=void 0;const n=a(395),s=a(8552),i=a(9243),o=a(3856);e.planTargetingRulesEvalutor=function(t,e,a={}){const r=e.features[t];if(r&&r.planIds&&r.planIds.length>0){const t=(0,s.prepareAttributes)(a),n=e.plans;for(const e of r.planIds){const a=n[e];if(a){const{treatment:e}=(0,o.evaluatePlan)(a,t);if(e===i.TreatmentEnum.True)return{isEntitled:!0}}}}return{isEntitled:!1,justification:n.NotEntitledJustification.MISSING_FEATURE}}},7416:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(9398),e)},9398:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.evaluateIsEntitledToFeature=void 0;const n=a(395),s=a(6816),i=a(2031);e.evaluateIsEntitledToFeature=function(t,e,a={}){if(!e)return{isEntitled:!1,justification:n.NotEntitledJustification.MISSING_FEATURE};const o=[];for(const n of(0,i.getIsEntitledEvaluators)())if(o.push(n(t,e,a)),!(0,s.shouldContinue)(o))break;return(0,s.getResult)(o)}},3817:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(1474),e)},1474:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.evaluateIsEntitledToPermissions=void 0;const n=a(9398),s=a(395),i=a(6816),o=a(7943);e.evaluateIsEntitledToPermissions=function(t,e,a){if(!e)return{isEntitled:!1,justification:s.NotEntitledJustification.MISSING_PERMISSION};if(!(0,o.checkPermission)(e.permissions,t))return{isEntitled:!1,justification:s.NotEntitledJustification.MISSING_PERMISSION};const r=function(t,e){return Object.keys(e.features).filter((a=>e.features[a].linkedPermissions.includes(t)))}(t,e);if(!r.length)return{isEntitled:!0};const l=[];for(const t of r)if(l.push((0,n.evaluateIsEntitledToFeature)(t,e,a)),!(0,i.shouldContinue)(l))break;return(0,i.getResult)(l)}},395:(t,e)=>{"use strict";var a;Object.defineProperty(e,"__esModule",{value:!0}),e.NO_EXPIRATION_TIME=e.NotEntitledJustification=void 0,(a=e.NotEntitledJustification||(e.NotEntitledJustification={})).MISSING_FEATURE="MISSING_FEATURE",a.MISSING_PERMISSION="MISSING_PERMISSION",a.BUNDLE_EXPIRED="BUNDLE_EXPIRED",e.NO_EXPIRATION_TIME=-1},8552:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.modifyObjectKeysWithPrefix=e.defaultFronteggAttributesMapper=e.prepareAttributes=void 0;const n=a(1857);function s(t){return{email:t.email,emailVerified:t.email_verified,tenantId:t.tenantId,userId:t.id}}function i(t,e){return Object.keys(t).reduce(((a,n)=>(a[`${e}${n}`]=t[n],a)),{})}e.prepareAttributes=function(t={},e){const{custom:a={},jwt:o={}}=t,r=(0,n.flatten)(o);return{...a,...i(e?e(o):s(o),"frontegg."),...i(r,"jwt.")}},e.defaultFronteggAttributesMapper=s,e.modifyObjectKeysWithPrefix=i},8843:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.shouldContinue=e.getResult=void 0;const n=a(395);e.getResult=function(t){let e=!1;for(const a of t){if(a.isEntitled)return a;a.justification===n.NotEntitledJustification.BUNDLE_EXPIRED&&(e=!0)}return{isEntitled:!1,justification:e?n.NotEntitledJustification.BUNDLE_EXPIRED:n.NotEntitledJustification.MISSING_FEATURE}},e.shouldContinue=function(t){return t.every((({isEntitled:t})=>!t))}},1857:(t,e)=>{"use strict";function a(t){return t}Object.defineProperty(e,"__esModule",{value:!0}),e.flatten=void 0,e.flatten=function(t,e){const n=(null==(e=e||{})?void 0:e.delimiter)||".",s=null==e?void 0:e.maxDepth,i=(null==e?void 0:e.transformKey)||a,o={};return function t(a,r,l){l=l||1,Object.keys(a).forEach((function(c){const u=a[c],d=(null==e?void 0:e.safe)&&Array.isArray(u),g=Object.prototype.toString.call(u),p=(h=u)&&h.constructor&&"function"==typeof h.constructor.isBuffer&&h.constructor.isBuffer(h);var h;const y="[object Object]"===g||"[object Array]"===g,S=r?r+n+i(c):i(c);if(!d&&!p&&y&&Object.keys(u).length&&(!(null==e?void 0:e.maxDepth)||s&&l<s))return t(u,S,l+1);o[S]=u}))}(t),o}},6816:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(7943),e),s(a(8552),e),s(a(8843),e)},7943:(t,e)=>{"use strict";function a(t){return new RegExp("^"+t.replace(/\./g,"\\.").replace(/\*/g,".*")+"$","gs")}Object.defineProperty(e,"__esModule",{value:!0}),e.createPermissionCheckRegex=e.checkPermission=void 0,e.checkPermission=function(t,e){return Object.keys(t).some((t=>a(t).test(e)))},e.createPermissionCheckRegex=a},2743:t=>{"use strict";var e=function(t){return function(t){return!!t&&"object"==typeof t}(t)&&!function(t){var e=Object.prototype.toString.call(t);return"[object RegExp]"===e||"[object Date]"===e||function(t){return t.$$typeof===a}(t)}(t)},a="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(t,e){return!1!==e.clone&&e.isMergeableObject(t)?r((a=t,Array.isArray(a)?[]:{}),t,e):t;var a}function s(t,e,a){return t.concat(e).map((function(t){return n(t,a)}))}function i(t){return Object.keys(t).concat(function(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter((function(e){return t.propertyIsEnumerable(e)})):[]}(t))}function o(t,e){try{return e in t}catch(t){return!1}}function r(t,a,l){(l=l||{}).arrayMerge=l.arrayMerge||s,l.isMergeableObject=l.isMergeableObject||e,l.cloneUnlessOtherwiseSpecified=n;var c=Array.isArray(a);return c===Array.isArray(t)?c?l.arrayMerge(t,a,l):function(t,e,a){var s={};return a.isMergeableObject(t)&&i(t).forEach((function(e){s[e]=n(t[e],a)})),i(e).forEach((function(i){(function(t,e){return o(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))})(t,i)||(o(t,i)&&a.isMergeableObject(e[i])?s[i]=function(t,e){if(!e.customMerge)return r;var a=e.customMerge(t);return"function"==typeof a?a:r}(i,a)(t[i],e[i],a):s[i]=n(e[i],a))})),s}(t,a,l):n(a,l)}r.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce((function(t,a){return r(t,a,e)}),{})};var l=r;t.exports=l},8792:t=>{"use strict";t.exports=function t(e,a){if(e===a)return!0;if(e&&a&&"object"==typeof e&&"object"==typeof a){if(e.constructor!==a.constructor)return!1;var n,s,i;if(Array.isArray(e)){if((n=e.length)!=a.length)return!1;for(s=n;0!=s--;)if(!t(e[s],a[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===a.source&&e.flags===a.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===a.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===a.toString();if((n=(i=Object.keys(e)).length)!==Object.keys(a).length)return!1;for(s=n;0!=s--;)if(!Object.prototype.hasOwnProperty.call(a,i[s]))return!1;for(s=n;0!=s--;){var o=i[s];if(!t(e[o],a[o]))return!1}return!0}return e!=e&&a!=a}},5302:(t,e,a)=>{const n=a(9537);function s(t,e,a){return"function"==typeof a.join?a.join(t):t[0]+e+t[1]}function i(t,e,a){return"function"!=typeof a.isValid||a.isValid(t,e)}function o(t){return n(t)||Array.isArray(t)||"function"==typeof t}t.exports=function(t,e,a){if(n(a)||(a={default:a}),!o(t))return void 0!==a.default?a.default:t;"number"==typeof e&&(e=String(e));const r=Array.isArray(e),l="string"==typeof e,c=a.separator||".",u=a.joinChar||("string"==typeof c?c:".");if(!l&&!r)return t;if(l&&e in t)return i(e,t,a)?t[e]:a.default;let d=r?e:function(t,e,a){return"function"==typeof a.split?a.split(t):t.split(e)}(e,c,a),g=d.length,p=0;do{let e=d[p];for("number"==typeof e&&(e=String(e));e&&"\\"===e.slice(-1);)e=s([e.slice(0,-1),d[++p]||""],u,a);if(e in t){if(!i(e,t,a))return a.default;t=t[e]}else{let n=!1,o=p+1;for(;o<g;)if(e=s([e,d[o++]],u,a),n=e in t){if(!i(e,t,a))return a.default;t=t[e],p=o-1;break}if(!n)return a.default}}while(++p<g&&o(t));return p===g?t:a.default}},2685:(t,e,a)=>{"use strict";var n=a(9537);function s(t){return!0===n(t)&&"[object Object]"===Object.prototype.toString.call(t)}t.exports=function(t){var e,a;return!1!==s(t)&&"function"==typeof(e=t.constructor)&&!1!==s(a=e.prototype)&&!1!==a.hasOwnProperty("isPrototypeOf")}},5858:t=>{"use strict";t.exports=function(t){return"object"==typeof t?null===t:"function"!=typeof t}},9537:t=>{"use strict";t.exports=function(t){return null!=t&&"object"==typeof t&&!1===Array.isArray(t)}},1098:(t,e,a)=>{"use strict";const{deleteProperty:n}=Reflect,s=a(5858),i=a(2685),o=t=>"object"==typeof t&&null!==t||"function"==typeof t,r=t=>{if(!s(t))throw new TypeError("Object keys must be strings or symbols");if((t=>"__proto__"===t||"constructor"===t||"prototype"===t)(t))throw new Error(`Cannot set unsafe key: "${t}"`)},l=(t,e)=>e&&"function"==typeof e.split?e.split(t):"symbol"==typeof t?[t]:Array.isArray(t)?t:((t,e,a)=>{const n=(t=>Array.isArray(t)?t.flat().map(String).join(","):t)(e?((t,e)=>{if("string"!=typeof t||!e)return t;let a=t+";";return void 0!==e.arrays&&(a+=`arrays=${e.arrays};`),void 0!==e.separator&&(a+=`separator=${e.separator};`),void 0!==e.split&&(a+=`split=${e.split};`),void 0!==e.merge&&(a+=`merge=${e.merge};`),void 0!==e.preservePaths&&(a+=`preservePaths=${e.preservePaths};`),a})(t,e):t);r(n);const s=u.cache.get(n)||a();return u.cache.set(n,s),s})(t,e,(()=>((t,e={})=>{const a=e.separator||".",n="/"!==a&&e.preservePaths;if("string"==typeof t&&!1!==n&&/\//.test(t))return[t];const s=[];let i="";const o=t=>{let e;""!==t.trim()&&Number.isInteger(e=Number(t))?s.push(e):s.push(t)};for(let e=0;e<t.length;e++){const n=t[e];"\\"!==n?n!==a?i+=n:(o(i),i=""):i+=t[++e]}return i&&o(i),s})(t,e))),c=(t,e,a,s)=>{if(r(e),void 0===a)n(t,e);else if(s&&s.merge){const n="function"===s.merge?s.merge:Object.assign;n&&i(t[e])&&i(a)?t[e]=n(t[e],a):t[e]=a}else t[e]=a;return t},u=(t,e,a,n)=>{if(!e||!o(t))return t;const s=l(e,n);let i=t;for(let t=0;t<s.length;t++){const e=s[t],l=s[t+1];if(r(e),void 0===l){c(i,e,a,n);break}"number"!=typeof l||Array.isArray(i[e])?(o(i[e])||(i[e]={}),i=i[e]):i=i[e]=[]}return t};u.split=l,u.cache=new Map,u.clear=()=>{u.cache=new Map},t.exports=u},7048:(t,e,a)=>{var n=a(4319).default;function s(){"use strict";t.exports=s=function(){return e},t.exports.__esModule=!0,t.exports.default=t.exports;var e={},a=Object.prototype,i=a.hasOwnProperty,o=Object.defineProperty||function(t,e,a){t[e]=a.value},r="function"==typeof Symbol?Symbol:{},l=r.iterator||"@@iterator",c=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";function d(t,e,a){return Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{d({},"")}catch(t){d=function(t,e,a){return t[e]=a}}function g(t,e,a,n){var s=e&&e.prototype instanceof y?e:y,i=Object.create(s.prototype),r=new k(n||[]);return o(i,"_invoke",{value:E(t,a,r)}),i}function p(t,e,a){try{return{type:"normal",arg:t.call(e,a)}}catch(t){return{type:"throw",arg:t}}}e.wrap=g;var h={};function y(){}function S(){}function v(){}var f={};d(f,l,(function(){return this}));var m=Object.getPrototypeOf,b=m&&m(m(_([])));b&&b!==a&&i.call(b,l)&&(f=b);var A=v.prototype=y.prototype=Object.create(f);function w(t){["next","throw","return"].forEach((function(e){d(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function a(s,o,r,l){var c=p(t[s],t,o);if("throw"!==c.type){var u=c.arg,d=u.value;return d&&"object"==n(d)&&i.call(d,"__await")?e.resolve(d.__await).then((function(t){a("next",t,r,l)}),(function(t){a("throw",t,r,l)})):e.resolve(d).then((function(t){u.value=t,r(u)}),(function(t){return a("throw",t,r,l)}))}l(c.arg)}var s;o(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,s){a(t,n,e,s)}))}return s=s?s.then(i,i):i()}})}function E(t,e,a){var n="suspendedStart";return function(s,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===s)throw i;return{value:void 0,done:!0}}for(a.method=s,a.arg=i;;){var o=a.delegate;if(o){var r=I(o,a);if(r){if(r===h)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===n)throw n="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);n="executing";var l=p(t,e,a);if("normal"===l.type){if(n=a.done?"completed":"suspendedYield",l.arg===h)continue;return{value:l.arg,done:a.done}}"throw"===l.type&&(n="completed",a.method="throw",a.arg=l.arg)}}}function I(t,e){var a=e.method,n=t.iterator[a];if(void 0===n)return e.delegate=null,"throw"===a&&t.iterator.return&&(e.method="return",e.arg=void 0,I(t,e),"throw"===e.method)||"return"!==a&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+a+"' method")),h;var s=p(n,t.iterator,e.arg);if("throw"===s.type)return e.method="throw",e.arg=s.arg,e.delegate=null,h;var i=s.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function _(t){if(t){var e=t[l];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,n=function e(){for(;++a<t.length;)if(i.call(t,a))return e.value=t[a],e.done=!1,e;return e.value=void 0,e.done=!0,e};return n.next=n}}return{next:R}}function R(){return{value:void 0,done:!0}}return S.prototype=v,o(A,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:S,configurable:!0}),S.displayName=d(v,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===S||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,d(t,u,"GeneratorFunction")),t.prototype=Object.create(A),t},e.awrap=function(t){return{__await:t}},w(T.prototype),d(T.prototype,c,(function(){return this})),e.AsyncIterator=T,e.async=function(t,a,n,s,i){void 0===i&&(i=Promise);var o=new T(g(t,a,n,s),i);return e.isGeneratorFunction(a)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},w(A),d(A,u,"Generator"),d(A,l,(function(){return this})),d(A,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),a=[];for(var n in e)a.push(n);return a.reverse(),function t(){for(;a.length;){var n=a.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=_,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(P),!t)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function a(a,n){return o.type="throw",o.arg=t,e.next=a,n&&(e.method="next",e.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var s=this.tryEntries[n],o=s.completion;if("root"===s.tryLoc)return a("end");if(s.tryLoc<=this.prev){var r=i.call(s,"catchLoc"),l=i.call(s,"finallyLoc");if(r&&l){if(this.prev<s.catchLoc)return a(s.catchLoc,!0);if(this.prev<s.finallyLoc)return a(s.finallyLoc)}else if(r){if(this.prev<s.catchLoc)return a(s.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return a(s.finallyLoc)}}}},abrupt:function(t,e){for(var a=this.tryEntries.length-1;a>=0;--a){var n=this.tryEntries[a];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var s=n;break}}s&&("break"===t||"continue"===t)&&s.tryLoc<=e&&e<=s.finallyLoc&&(s=null);var o=s?s.completion:{};return o.type=t,o.arg=e,s?(this.method="next",this.next=s.finallyLoc,h):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var a=this.tryEntries[e];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),P(a),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var a=this.tryEntries[e];if(a.tryLoc===t){var n=a.completion;if("throw"===n.type){var s=n.arg;P(a)}return s}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,a){return this.delegate={iterator:_(t),resultName:e,nextLoc:a},"next"===this.method&&(this.arg=void 0),h}},e}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports},4319:t=>{function e(a){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(a)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},5799:(t,e,a)=>{var n=a(7048)();t.exports=n;try{regeneratorRuntime=n}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}}},e={};function a(n){var s=e[n];if(void 0!==s)return s.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,a),i.exports}a.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return a.d(e,{a:e}),e},a.d=(t,e)=>{for(var n in e)a.o(e,n)&&!a.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),a.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";a.r(n),a.d(n,{AdminPortal:()=>lg,AdminPortalRenderer:()=>dg,AppHolder:()=>c,CheckoutDialog:()=>cg,FronteggApp:()=>og,HostedLogin:()=>rg,LoginBoxRenderer:()=>hg,createElement:()=>Zd,defaultTheme:()=>gg,formatName:()=>Qd,getOverriddenMetadata:()=>ig,getThemeAdminByName:()=>ug,getThemeByName:()=>pg,initialize:()=>bg,mockFlagsList:()=>ng,restoreSearchParams:()=>eg,waitThemeSetter:()=>tg});var t={};a.r(t),a.d(t,{ApplicationAccessType:()=>Ja,AuthStrategyEnum:()=>N,ContextHolder:()=>U,DirectoryApi:()=>ca,FRONTEGG_SEPARATE_TABS_BY_TENANT:()=>ae,FeatureFlags:()=>Zt,FeatureFlagsApi:()=>te,FetchClient:()=>Gt,FronteggApiError:()=>W,FronteggContext:()=>L,FronteggFrameworks:()=>xt,GENERIC_ERROR_CODE:()=>Nt,GENERIC_ERROR_MESSAGE:()=>Dt,GetUsersFilterPreset:()=>ja,GroupManagedByEnum:()=>$a,GroupRelations:()=>xa,ISubscriptionCancellationPolicy:()=>G,ISubscriptionStatus:()=>x,InsightCode:()=>Ha,LOAD_AUTHORIZATION_FF:()=>Yt,MFAStrategyEnum:()=>Jt,MachineToMachineAuthStrategy:()=>M,NotEntitledJustification:()=>Va,PaginationOrderEnum:()=>$t,PaymentMethodType:()=>$,PermissionAssignmentTypeEnum:()=>ka,ProviderType:()=>j,RecommendationActionKey:()=>za,RecommendationCode:()=>Wa,RecommendationSeverity:()=>Ka,RequestSource:()=>Ft,RestrictionType:()=>zt,ScimConnectionSource:()=>Fa,SecondaryAuthStrategy:()=>Kt,SecurityCategory:()=>qa,SignUpStrategyEnum:()=>F,SocialLoginProviders:()=>D,SortByEnum:()=>Ga,SubAccountAccessTypeEnum:()=>_a,TenantSortByEnum:()=>Oa,TenantType:()=>Pa,UserManagedByEnum:()=>Ia,WebAuthnDeviceType:()=>qt,api:()=>Ya,createApiClient:()=>Xa,default:()=>Qa,fetch:()=>jt,fronteggAuthApiRoutesRegex:()=>Ra,fronteggEntitlementsV2Url:()=>Ma,fronteggHeaders:()=>Mt,fronteggRefreshTokenUrl:()=>Ua,fronteggSilentRefreshTokenUrl:()=>Ca,fronteggTenantsUrl:()=>Da,fronteggTenantsV3Url:()=>Na,fronteggUsersUrl:()=>La,getCurrentUserTenantsFunction:()=>ce,getTabTenantFromSessionStorage:()=>le,providersArray:()=>Ba,removeTabTenantFromSessionStorage:()=>re,setTabTenantInSessionStorage:()=>oe});var e={};a.r(e),a.d(e,{ACR_VALUE:()=>un,AMR_ADDITIONAL_VALUE:()=>gn,AMR_MFA_VALUE:()=>dn,AcceptInvitationStep:()=>an,ActivateAccountStep:()=>jn,AdminPortalPages:()=>qn,AdminPortalPagesForEvents:()=>Kn,AllAccountsStateKeys:()=>xo,ApiStateKeys:()=>Ms,AuthStrategyEnum:()=>N,AuthenticationTypes:()=>zn,DEFAULT_RETRY_CONFIG:()=>Tn,FRONTEGG_AFTER_AUTH_REDIRECT_URL:()=>An,ForgotPasswordStep:()=>zs,FronteggNativeModule:()=>S,GTMEventAction:()=>Jn,GroupRelations:()=>si,GroupsStateKeys:()=>ni,HOSTED_LOGIN_VERIFIER_KEY:()=>wn,ImpersonateStep:()=>ui,LoginActionTypes:()=>fn,LoginFlow:()=>Sn,LoginStep:()=>yn,MFAStep:()=>Yn,MachineToMachineAuthStrategy:()=>M,PasswordRotationStep:()=>Xs,PaymentMethodType:()=>nc,PaymentProvider:()=>oc,QuickLoginStrategy:()=>vn,REQUEST_NAME:()=>Wn,ResetPhoneNumberStep:()=>ir,RolesStateKeys:()=>hr,SHOULD_STEP_UP_KEY:()=>pn,SSOStateKeys:()=>so,STEP_UP_MAX_AGE_PARAM_NAME:()=>hn,SamlVendors:()=>io,SecurityCenterStateKeys:()=>Ur,SignUpStage:()=>Jr,SubscriptionCancellationPolicy:()=>lc,SubscriptionStatus:()=>rc,TENANT_ID_PARAM_KEY:()=>ns,TeamStateKeys:()=>ws,UserVerifiedOriginTypes:()=>Hn,authStrategyLoginStepMap:()=>mn,base64ToFormData:()=>Pi,base64urlDecode:()=>Oi,base64urlEncode:()=>Ii,buildAuditsActions:()=>Jc,buildAuthActions:()=>Jl,buildConnectivityActions:()=>ac,buildSubscriptionsActions:()=>xc,buildVendorActions:()=>jc,createAuditsState:()=>qc,createAuthState:()=>ql,createConnectivityState:()=>Xl,createFronteggStore:()=>Td,createProxy:()=>en,createRandomString:()=>Ji,createStore:()=>Ed,createSubscriptionsState:()=>Fc,createVendorState:()=>Gc,deepClone:()=>Un,deepResetState:()=>Cn,defaultFronteggRoutes:()=>bn,delay:()=>En,errorHandler:()=>Nn,errorTraceId:()=>kn,generateCodeChallenge:()=>qi,generateCodeChallengeNative:()=>Ki,generateCodeChallengePureJs:()=>zi,getBaseNameWithoutSlashSuffix:()=>cs,getEntitlements:()=>ao,getFeatureEntitlements:()=>eo,getMfaStepForEnrolledUsers:()=>is,getMfaStepForNotEnrolledUsers:()=>os,getNumberOfMfaDevices:()=>ss,getPathAndSearchParamsFromUrl:()=>es,getPermissionEntitlements:()=>to,getRedirectUrl:()=>Zn,getSearchParam:()=>as,getSearchParamsFromUrl:()=>ts,getUri:()=>ms,hmac:()=>Hi,isAbsoluteUrl:()=>Qn,isAuthRoute:()=>As,isEmailPayload:()=>ls,isEntitlementsDeeplyEqual:()=>no,isError:()=>Dn,isFronteggApiError:()=>Ln,isMfaRequired:()=>Ss,isOauthCallbackRoute:()=>rs,isProxy:()=>Rn,isResetPasswordRequired:()=>vs,isSteppedUp:()=>ds,mapMetaDataObjectToActions:()=>fs,omitProps:()=>_n,prepareIdentifiersForSignup:()=>bs,publicKeyCredentialToJSON:()=>ki,readFileAsText:()=>_i,redirectByStepUpUrl:()=>ps,reportGTMEvent:()=>Xn,retry:()=>In,retryIfNeeded:()=>On,setAfterAuthRedirectUrlForStepUp:()=>gs,sha256:()=>Wi,shouldShowPasswordRotationPromptFunc:()=>us,snapshot:()=>k,subscribe:()=>P,withRetryConfig:()=>Pn});var s={};function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function r(t,e){for(var a=0;a<e.length;a++){var n=e[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(s=n.key,i=void 0,i=function(t){if("object"!==o(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var a=e.call(t,"string");if("object"!==o(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(s),"symbol"===o(i)?i:String(i)),n)}var s,i}function l(t,e,a){return e&&r(t.prototype,e),a&&r(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t}a.r(s),a.d(s,{AccountDetailsPageTabs:()=>Fd,AccountPageFields:()=>_d,DomainRestrictionsTabFields:()=>Md,GeneralSettingsTabFields:()=>Dd,InviteUserModalFields:()=>kd,IpRestrictionsTabFields:()=>Nd,Metadata:()=>Xd,PrivacyPageFields:()=>Pd,ProfilePageFields:()=>Od,SecurityPageTabs:()=>Cd,SessionManagementTabFields:()=>Ld,SignupFields:()=>Id,SubscriptionsPageFields:()=>Ud,UsersTableColumns:()=>Rd,alpha:()=>Wd,fieldAppearance:()=>xd,tabAppearance:()=>$d});var c=function(){function t(){i(this,t)}return l(t,null,[{key:"setInstance",value:function(e,a){t._apps[e]=a}},{key:"getInstance",value:function(e){var a=t._apps[e];if(!a)throw Error("[".concat(e,"] FronteggApp not found"));return a}}]),t}();function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,n=new Array(e);a<e;a++)n[a]=t[a];return n}function d(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=a){var n,s,i,o,r=[],l=!0,c=!1;try{if(i=(a=a.call(t)).next,0===e){if(Object(a)!==a)return;l=!1}else for(;!(l=(n=i.call(a)).done)&&(r.push(n.value),r.length!==e);l=!0);}catch(t){c=!0,s=t}finally{try{if(!l&&null!=a.return&&(o=a.return(),Object(o)!==o))return}finally{if(c)throw s}}return r}}(t,e)||function(t,e){if(t){if("string"==typeof t)return u(t,e);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?u(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(t,e,a,n,s,i,o){try{var r=t[i](o),l=r.value}catch(t){return void a(t)}r.done?e(l):Promise.resolve(l).then(n,s)}function p(t){return function(){var e=this,a=arguments;return new Promise((function(n,s){var i=t.apply(e,a);function o(t){g(i,n,s,o,r,"next",t)}function r(t){g(i,n,s,o,r,"throw",t)}o(void 0)}))}}c._apps={};var h=a(5799),y=a.n(h);const S=new class{constructor(){this.loginWithSSO=t=>{if(this.isIOSNativeBridgeAvailable()){var e,a,n;null==(e=window.webkit)||null==(a=e.messageHandlers)||null==(n=a.FronteggNativeBridge)||n.postMessage(JSON.stringify({action:"loginWithSSO",payload:t}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithSSO(t)}},this.loginWithSocialLogin=t=>{if(this.isIOSNativeBridgeAvailable()){var e,a,n;null==(e=window.webkit)||null==(a=e.messageHandlers)||null==(n=a.FronteggNativeBridge)||n.postMessage(JSON.stringify({action:"loginWithSocialLogin",payload:t}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithSocialLogin(t)}},this.loginWithSocialLoginProvider=t=>{if(this.isIOSNativeBridgeAvailable()){var e,a,n;null==(e=window.webkit)||null==(a=e.messageHandlers)||null==(n=a.FronteggNativeBridge)||n.postMessage(JSON.stringify({action:"loginWithSocialLoginProvider",payload:t}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithSocialLoginProvider(t)}},this.loginWithCustomSocialLoginProvider=t=>{if(this.isIOSNativeBridgeAvailable()){var e,a,n;null==(e=window.webkit)||null==(a=e.messageHandlers)||null==(n=a.FronteggNativeBridge)||n.postMessage(JSON.stringify({action:"loginWithCustomSocialLoginProvider",payload:t}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithCustomSocialLoginProvider(t)}},this.suggestSavePassword=(t,e)=>{if(this.isIOSNativeBridgeAvailable()){var a,n,s;null==(a=window.webkit)||null==(n=a.messageHandlers)||null==(s=n.FronteggNativeBridge)||s.postMessage(JSON.stringify({action:"suggestSavePassword",payload:JSON.stringify({email:t,password:e})}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var i;null==(i=window.FronteggNativeBridge)||i.suggestSavePassword(t,e)}},this.promptSocialLoginConsent=()=>{var t,e;return null!=(t=null==(e=window.FronteggNativeBridgeFunctions)?void 0:e.shouldPromptSocialLoginConsent)&&t}}isIOSNativeBridgeAvailable(){var t,e;return null!=(null==(t=window.webkit)||null==(e=t.messageHandlers)?void 0:e.FronteggNativeBridge)}isAndroidNativeBridgeAvailable(){return null!=window.FronteggNativeBridge}isSocialLoginAvailable(){return this.isAvailable("loginWithSocialLogin")}isSocialLoginProviderAvailable(){return this.isAvailable("loginWithSocialLoginProvider")}isCustomSocialLoginProviderAvailable(){return this.isAvailable("loginWithCustomSocialLoginProvider")}isLoginWithSSOAvailable(){return this.isAvailable("loginWithSSO")}isSuggestSavePasswordAvailable(){return this.isAvailable("suggestSavePassword")}isAvailable(t){var e,a;return!(!this.isIOSNativeBridgeAvailable()&&!this.isAndroidNativeBridgeAvailable())&&null!=(e=null==(a=window.FronteggNativeBridgeFunctions)?void 0:a[t])&&e}};function v(){return v=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},v.apply(this,arguments)}function f(t,e){if(null==t)return{};var a,n,s={},i=Object.keys(t);for(n=0;n<i.length;n++)a=i[n],e.indexOf(a)>=0||(s[a]=t[a]);return s}Symbol();const m=Symbol(),b=Object.getPrototypeOf,A=new WeakMap,w=(t,e=!0)=>{A.set(t,e)},T=t=>"object"==typeof t&&null!==t,E=new WeakMap,I=new WeakSet;const[O]=function(t=Object.is,e=(t,e)=>new Proxy(t,e),a=t=>T(t)&&!I.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer),n=t=>{switch(t.status){case"fulfilled":return t.value;case"rejected":throw t.reason;default:throw t}},s=new WeakMap,i=(t,e,a=n)=>{const o=s.get(t);if((null==o?void 0:o[0])===e)return o[1];const r=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return w(r,!0),s.set(t,[e,r]),Reflect.ownKeys(t).forEach((e=>{if(Object.getOwnPropertyDescriptor(r,e))return;const n=Reflect.get(t,e),{enumerable:s}=Reflect.getOwnPropertyDescriptor(t,e),o={value:n,enumerable:s,configurable:!0};if(I.has(n))w(n,!1);else if(n instanceof Promise)delete o.value,o.get=()=>a(n);else if(E.has(n)){const[t,e]=E.get(n);o.value=i(t,e(),a)}Object.defineProperty(r,e,o)})),Object.preventExtensions(r)},o=new WeakMap,r=[1,1],l=n=>{if(!T(n))throw new Error("object required");const s=o.get(n);if(s)return s;let c=r[0];const u=new Set,d=(t,e=++r[0])=>{c!==e&&(c=e,u.forEach((a=>a(t,e))))};let g=r[1];const p=t=>(e,a)=>{const n=[...e];n[1]=[t,...n[1]],d(n,a)},h=new Map,y=t=>{const e=h.get(t);var a;e&&(h.delete(t),null==(a=e[1])||a.call(e))},S=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n)),v=e(S,{deleteProperty(t,e){const a=Reflect.get(t,e);y(e);const n=Reflect.deleteProperty(t,e);return n&&d(["delete",[e],a]),n},set(e,n,s,i){const r=Reflect.has(e,n),c=Reflect.get(e,n,i);if(r&&(t(c,s)||o.has(s)&&t(c,o.get(s))))return!0;var g;y(n),T(s)&&(s=(t=>t&&(A.has(t)?A.get(t):b(t)===Object.prototype||b(t)===Array.prototype))(g=s)&&g[m]||s);let S=s;if(s instanceof Promise)s.then((t=>{s.status="fulfilled",s.value=t,d(["resolve",[n],t])})).catch((t=>{s.status="rejected",s.reason=t,d(["reject",[n],t])}));else{!E.has(s)&&a(s)&&(S=l(s));const t=!I.has(S)&&E.get(S);t&&((t,e)=>{if(u.size){const a=e[3](p(t));h.set(t,[e,a])}else h.set(t,[e])})(n,t)}return Reflect.set(e,n,S,i),d(["set",[n],s,c]),!0}});o.set(n,v);const f=[S,(t=++r[1])=>(g===t||u.size||(g=t,h.forEach((([e])=>{const a=e[1](t);a>c&&(c=a)}))),c),i,t=>(u.add(t),1===u.size&&h.forEach((([t,e],a)=>{const n=t[3](p(a));h.set(a,[t,n])})),()=>{u.delete(t),0===u.size&&h.forEach((([t,e],a)=>{e&&(e(),h.set(a,[t]))}))})];return E.set(v,f),Reflect.ownKeys(n).forEach((t=>{const e=Object.getOwnPropertyDescriptor(n,t);"value"in e&&(v[t]=n[t],delete e.value,delete e.writable),Object.defineProperty(S,t,e)})),v}){return[l,E,I,t,e,a,n,s,i,o,r]}();function P(t,e,a){const n=E.get(t);let s;const i=[],o=n[3];let r=!1;const l=o((t=>{i.push(t),a?e(i.splice(0)):s||(s=Promise.resolve().then((()=>{s=void 0,r&&e(i.splice(0))})))}));return r=!0,()=>{r=!1,l()}}function k(t,e){const a=E.get(t),[n,s,i]=a;return i(n,s(),e)}const _=["enabled","name"],R=Symbol();class U{constructor(){this.context=null,this.accessToken=null,this.user=null,this.requestSource=null,this.onRedirectTo=t=>window.location.href=t,this.logout=()=>window.location.href="/account/logout",this.entitlementsOptions=null,this.appName=null,this.sessionContext=void 0,this.basename=null,this.cdnUrl=null,this.assetsUrl=null,this.setContext=t=>{this.context=t},this.setAccessToken=t=>{this.accessToken=t},this.setUser=t=>{this.user=t},this.setRequestSource=t=>{this.requestSource=t},this.setOnRedirectTo=t=>{this.onRedirectTo=t},this.setLogout=t=>{this.logout=t},this.setEntitlementsOptions=t=>{this.entitlementsOptions=t},this.setSessionContext=t=>{this.sessionContext=t},this.setAppName=t=>{this.appName=t},this.getContext=()=>{var t;return null!=(t=this.context)?t:{baseUrl:window.location.href,tokenResolver:()=>"my-authentication-token",logLevel:"error"}},this.getAccessToken=()=>this.accessToken,this.getRequestSource=()=>this.requestSource,this.getUser=()=>this.user,this.shouldLoadEntitlements=()=>{var t;return(null==(t=this.entitlementsOptions)?void 0:t.enabled)||!1},this.isSessionPerTenantEnabled=()=>{var t;return(null==(t=this.sessionContext)?void 0:t.enableSessionPerTenant)||!1},this.shouldSkipUserLoad=()=>{var t;return(null==(t=this.sessionContext)?void 0:t.skipUserLoading)||!1},this.getAppName=()=>this.appName,this.setCdnUrl=t=>{this.cdnUrl=t},this.getCdnUrl=()=>this.cdnUrl,this.setAssetsUrl=t=>{this.assetsUrl=t},this.getAssetsUrl=()=>this.assetsUrl}static default(){return U.getInstance(C)}static for(t){return U.getInstance(t)}static getInstance(t="default"){return U._apps||(U._apps={}),U._apps[t]||(U._apps[t]=new U),U._apps[t]}static createInstance(t="default"){return U._apps[t]=new U,U._apps[t].appName=t,U._apps[t]}static setContext(t,e="default"){U.for(e).context=t}static setAccessToken(t,e=C){U.for(e).accessToken=t}static setUser(t,e="default"){U.for(e).user=t}static setRequestSource(t,e="default"){U.for(e).requestSource=t}static setOnRedirectTo(t,e="default"){U.for(e).onRedirectTo=t}static setLogout(t,e,a="default"){const n=U.for(a);n.logout=a=>{a?t(a):n.onRedirectTo(e,void 0)}}static setEntitlementsOptions(t,e="default"){U.for(e).entitlementsOptions=t}static setSessionContext(t,e="default"){U.for(e).sessionContext=t}static setAppName(t){U.for(t).appName=t}static getContext(t="default"){var e;return null!=(e=U.for(t).context)?e:{baseUrl:window.location.href,tokenResolver:()=>"my-authentication-token",logLevel:"error"}}static getAccessToken(t="default"){return U.for(t).accessToken}static getRequestSource(t="default"){return U.for(t).requestSource}static getBasename(t="default"){return U.for(t).basename}getBasename(){return this.basename}static setBasename(t,e=C){U.for(e).basename=t}setBasename(t){this.basename=t}static getUser(t="default"){return U.for(t).user}static onRedirectTo(t,e,a="default"){return U.for(a).onRedirectTo(t,e)}static logout(t,e="default"){return U.for(e).logout(t)}static shouldLoadEntitlements(t="default"){var e;return(null==(e=U.for(t).entitlementsOptions)?void 0:e.enabled)||!1}static isSessionPerTenantEnabled(t="default"){var e;return(null==(e=U.for(t).sessionContext)?void 0:e.enableSessionPerTenant)||!1}static getAppName(t="default"){return U.for(t).appName}}U._apps=void 0;const C="default",L={getContext:()=>U.getContext(C),getAccessToken:()=>U.getAccessToken(C),setAccessToken:t=>U.setAccessToken(t,C),getUser:()=>U.getUser(C),setUser:t=>U.setUser(t,C),onRedirectTo:(t,e)=>U.onRedirectTo(t,e,C),setOnRedirectTo:t=>U.setOnRedirectTo(t,C),logout:t=>U.logout(t,C),getRequestSource:()=>U.getRequestSource(C),setRequestSource:t=>U.setRequestSource(t,C),isSessionPerTenantEnabled:()=>U.isSessionPerTenantEnabled(C),shouldLoadEntitlements:()=>U.shouldLoadEntitlements(C),getAppName:()=>U.getAppName(C),setEntitlementsOptions:t=>U.setEntitlementsOptions(t,C),setSessionContext:t=>U.setSessionContext(t,C),getBasename:()=>U.getBasename(C),setBasename:t=>U.setBasename(t,C)};let D,N,M,F,x,$,G,j,B,V;!function(t){t.Microsoft="microsoft",t.Facebook="facebook",t.Google="google",t.Github="github",t.Slack="slack",t.Apple="apple",t.Linkedin="linkedin"}(D||(D={})),function(t){t.EmailAndPassword="EmailAndPassword",t.MagicLink="MagicLink",t.Code="Code",t.NoLocalAuthentication="NoLocalAuthentication",t.SmsCode="SmsCode"}(N||(N={})),function(t){t.ClientCredentials="ClientCredentials",t.AccessToken="AccessToken"}(M||(M={})),function(t){t.Email="email",t.PhoneNumber="phoneNumber"}(F||(F={})),function(t){t.ACTIVE="active",t.CANCELED="canceled",t.INCOMPLETE="incomplete",t.EXPIRED="expired",t.TRIALING="trialing",t.TRIAL_ENDED="trialEnded"}(x||(x={})),function(t){t.UNKNWON="unknown",t.CARD="card"}($||($={})),function(t){t.AT_PERIOD_END="atPeriodEnd"}(G||(G={})),function(t){t.Stripe="Stripe"}(j||(j={})),function(t){t.CHANGE_TO_DEFAULT="change_to_default",t.RETAIN_TRIAL="retain_trial"}(B||(B={})),function(t){t.CREATE="create_customer"}(V||(V={}));class W extends Error{constructor(t,e,a,n,s){super(t),this._statusCode=void 0,this._traceId=void 0,this._errorCode=void 0,this._errorContext=void 0,this._statusCode=e,this._traceId=a,this._errorCode=n,this._errorContext=s}get statusCode(){return this._statusCode}get traceId(){return this._traceId}get errorCode(){return this._errorCode}get errorContext(){return this._errorContext}}const H={v1:{strategies:"/identity/resources/configurations/v1/sign-up/strategies"}},z={v1:"/identity/resources/users/webauthn/v1/devices"},K={v1:"/identity/resources/auth/v1",v2:"/identity/resources/auth/v2"},q={v1:"/identity/resources/users/v1",v2:"/identity/resources/users/v2",v3:"/identity/resources/users/v3",roles:{v3:"/identity/resources/users/v3/roles"},groups:{v3:"/identity/resources/users/v3/groups"},tenants:{me:{v1:"/identity/resources/users/v1/me/tenants",v3:"/identity/resources/users/v3/me/tenants"}},apiTokens:{v1:"/identity/resources/users/api-tokens/v1"},accessTokens:{v1:"/identity/resources/users/access-tokens/v1"},sessions:{v1:"/identity/resources/users/sessions/v1",currentUser:{v1:"/identity/resources/users/sessions/v1/me"},configurations:{v1:"/identity/resources/configurations/sessions/v1"}},invitation:{resendAll:{v1:"/identity/resources/users/v1/invitation/reset/all"}},passwords:{resetBreachedPasswords:{v1:"/identity/resources/users/v1/passwords/breached/reset/bulk"}},authorization:{v1:"/identity/resources/users/v1/me/authorization"},temporary:{v1:"/identity/resources/users/temporary/v1",configuration:{v1:"/identity/resources/users/temporary/v1/configuration"}}},J={v1:"/identity/resources/configurations/v1"},Y={emailDomain:{v1:"/identity/resources/configurations/restrictions/v1/email-domain"},ip:{v1:"/identity/resources/configurations/v1/restrictions/ip"}},X={v1:"/identity/resources/sso/v1",v2:"/identity/resources/sso/v2",custom:{v1:"/identity/resources/sso/custom/v1"}},Q={v1:"/identity/resources/permissions/v1"},Z={apiTokens:{v1:"/identity/resources/tenants/api-tokens/v1",v2:"/identity/resources/tenants/api-tokens/v2"},accessTokens:{v1:"/identity/resources/tenants/access-tokens/v1"},invites:{user:{v1:"/identity/resources/tenants/invites/v1/user"},verify:{v1:"/identity/resources/tenants/invites/v1/verify"},configuration:{v1:"/identity/resources/tenants/invites/v1/configuration"}},users:{v1:"/identity/resources/tenants/users/v1"}},tt={v1:"/identity/resources/roles/v1",v2:"/identity/resources/roles/v2"},et={v1:"/identity/resources/sub-tenants/users/v1",v2:"/identity/resources/sub-tenants/users/v2"},at={v1:"/identity/resources/impersonation/v1"},nt={v1:"/identity/resources/applications/v1"},st={v1:"/identity/resources/groups/v1",configurations:{v1:"/identity/resources/groups/v1/config"},getByIds:{v1:"/identity/resources/groups/v1/bulkGet"}},it={v1:"/identity/resources/users/phone-numbers/v1"},ot={v1:"/team/resources/sso/v1",v2:"/team/resources/sso/v2"},rt={v1:"/team/resources/members/v1"},lt={v1:"/team/resources/roles/v1"},ct={v1:"/team/resources/stats/v1"},ut={v1:"/team/resources/profile"},dt={v1:"/tenants/resources/account-settings/v1"},gt={v1:"/tenants/resources/hierarchy/v1",tree:{v1:"/tenants/resources/hierarchy/v1/tree"},parents:{v1:"/tenants/resources/hierarchy/v1/parents"},v2:"/tenants/resources/hierarchy/v2",metadata:{v2:"/tenants/resources/hierarchy/v2/metadata"}},pt={v1:"/tenants/resources/sub-tenants/v1"},ht={v1:"/integrations/resources/configurations/v1",v2:"/integrations/resources/configurations/v2"},yt={subscriptions:{v1:"/subscriptions/resources/billing/subscriptions/v1"},plans:{v1:"/subscriptions/resources/billing/plans/v1"},invoices:{v1:"/subscriptions/resources/billing/invoices/v1"},paymentMethods:{v1:"/subscriptions/resources/billing/payment-methods/v1"},summaries:{v1:"/subscriptions/resources/billing/summaries/v1"},tenantConfiguration:{v1:"/subscriptions/resources/billing/tenant-configurations/v1"},configurations:{vendorPublicConfigurations:{v1:"/subscriptions/resources/billing/configurations/vendor-public-configurations/v1"}},paymentProviders:{stripe:{customers:{v1:"/subscriptions/resources/billing/payment-providers/stripe/customers/v1"},publicConfigurations:{v1:"/subscriptions/resources/billing/payment-providers/stripe/public-configurations/v1"},subscriptions:{v1:"/subscriptions/resources/billing/payment-providers/stripe/subscriptions/v1"},setupIntents:{v1:"/subscriptions/resources/billing/payment-providers/stripe/setup-intents/v1"}}}},St={v1:"/subscriptions/resources/payment-providers/v1"},vt={v1:"/subscriptions/resources/subscriptions/v1"},ft={v1:"/reports/resources/reports/v1",v2:"/reports/resources/reports/v2"},mt={v1:"/reports/engine/resources/triggers/v1"},bt="/notification",At="/audits",wt={v1:"/event/resources/configurations/v1"},Tt="/webhook",Et="/oauth",It="/flags",Ot="/directory/resources/v1/configurations/scim2",Pt="/directory/resources/scim/temp",kt="/entitlements/api/v2/user-entitlements",_t={v1:"/security-center/resources/recommendations/v1"},Rt={v1:"/security-center/resources/insights/v1"},Ut="/applications/resources/applications/v1",Ct={v1:"/applications/resources/applications/tenant-assignments/v1"},Lt="http://localhost:3037/resources/velo/v1",Dt="We're facing some difficulties, Please try again",Nt="ER-ADMIN-PORTAL-GENERIC-ERROR",Mt={frameWork:"x-frontegg-framework",fronteggSdkVersion:"x-frontegg-sdk",contentType:"Content-Type",source:"frontegg-source",scopedTenant:"frontegg-scoped-tenant"};let Ft,xt,$t;!function(t){t.AdminPortal="admin-portal",t.LoginBox="login-box"}(Ft||(Ft={})),function(t){t.Nextjs="nextjs",t.React="react",t.Angular="angular",t.Vuejs="vuejs",t.Flutter="flutter",t.Ios="ios",t.Android="android",t.Vanillajs="vanillajs"}(xt||(xt={})),function(t){t.ASC="ASC",t.DESC="DESC"}($t||($t={}));class Gt{constructor(t){this.appName=void 0,this.getFronteggContext=()=>U.for(this.appName),this.prepareUrl=async(t,e)=>{const a=this.getFronteggContext().getContext(),n=this.getContextBaseUrl(t),s=await this.buildQueryParams(a,e);let i=t.startsWith("http")?t:`${n}${t}`;const o=Object.keys(s).length>0;return s&&o&&(i+=`?${new URLSearchParams(s)}`),i},this.buildQueryParams=async(t,e)=>{e||(e={});const a=await this.getAdditionalQueryParams(t);for(const t of a)e[t.key]=t.value;const n=Object.keys(e);for(const t of n){const a=e[t];e[t]="object"==typeof a?JSON.stringify(a):a}return e},this.getAdditionalQueryParams=async t=>{let e=[];return t.additionalQueryParamsResolver&&(e=await t.additionalQueryParamsResolver()),e},this.getAdditionalHeaders=async t=>{let e=[];if(t.additionalHeadersResolver&&(e=await t.additionalHeadersResolver()),t.tenantResolver){const a=await t.tenantResolver();null!=a&&a.tenant&&e.push({key:"frontegg-login-alias",value:a.tenant})}return t.appId&&e.push({key:"frontegg-requested-application-id",value:t.appId}),e},this.buildRequestHeaders=async t=>{var e;const a=this.getFronteggContext(),n=a.getContext(),s=Gt.getMetadataHeaders(n),i=await(null!=(e=null==n?void 0:n.tokenResolver)?e:a.getAccessToken)(),o=a.getRequestSource(),r=Gt.getScopedTenant();t&&(s[Mt.contentType]=t),o&&(s[Mt.source]=o),i&&(s.Authorization=`Bearer ${i}`),r&&(s[Mt.scopedTenant]=r);for(const t of await this.getAdditionalHeaders(n))s[`${t.key}`]=`${t.value}`;return s},this.getResponseTraceId=t=>{var e,a;return null==t||null==(e=t.headers)||null==(a=e.get)?void 0:a.call(e,"frontegg-trace-id")},this.sendRequest=async t=>{var e,a,n;const s=this.getFronteggContext().getContext(),i=await this.buildRequestHeaders(t.contentType),o=await this.prepareUrl(t.url,t.params),r=s.beforeRequestInterceptor,l={body:t.body?"application/json"===t.contentType?JSON.stringify(t.body):t.body:null,method:null!=(e=t.method)?e:"GET",headers:v({},i,t.headers),credentials:null!=(a=null!=(n=t.credentials)?n:s.requestCredentials)?a:"same-origin"},c=r?r(l,o):l,u=await fetch(o,c);if(302===u.status)return window.location.href=await u.text(),new Promise((()=>{}));if(!u.ok){var d,g,p,h,y;if(413===u.status)throw new W("Error request is too large",u.status,this.getResponseTraceId(u),void 0);let t,e,a,n=!0;try{t=await u.text(),t=JSON.parse(t)}catch(t){n=!1}throw null!=(d=t)&&d.errorCode&&(e=t.errorCode),null!=(g=t)&&g.context&&"object"==typeof t.context&&(a=t.context),t.errors?t=t.errors.join(", "):"string"!=typeof t&&(t=`Error ${u.status} - ${u.statusText}`),u.status>=400&&u.status<500&&["warn"].includes(null!=(p=s.logLevel)?p:"")?console.warn(t):500===u.status&&["warn","error"].includes(null!=(h=s.logLevel)?h:"")&&console.error(t),new W(n?t:Dt,u.status,this.getResponseTraceId(u),null!=(y=e)?y:Nt,a)}if("stream"===t.responseType)return u.body;if(t.responseType&&"json"!==t.responseType){if("blob"===t.responseType){const{outputFileName:e}=t.params;return await u.blob().then((t=>URL.createObjectURL(t))).then((t=>{const a=document.createElement("a");a.href=t,a.setAttribute("download",e||"output"),a.click()}))}return await u.text()}try{return await u.json()}catch(t){return{}}},this.get=async(t,e,a)=>this.sendRequest(v({url:t,method:"GET",contentType:"application/json",params:e},a)),this.post=async(t,e,a)=>this.sendRequest(v({url:t,method:"POST",contentType:"application/json",body:e},a)),this.patch=async(t,e,a)=>this.sendRequest(v({url:t,method:"PATCH",contentType:"application/json",body:e},a)),this.put=async(t,e,a)=>this.sendRequest(v({url:t,method:"PUT",contentType:"application/json",body:e},a)),this.delete=async(t,e,a)=>this.sendRequest(v({url:t,method:"DELETE",contentType:"application/json",body:e},a)),this.postDownload=async(t,e,a,n)=>this.sendRequest(v({url:t,method:"POST",contentType:"application/json",responseType:"blob",body:e,params:a},n)),this.extractHeadersFromOptions=(t={})=>v({},t.jwt?{Authorization:t.jwt}:{}),this.getBaseUrl=(t,e,a=!0)=>Gt.getBaseUrl(t,e,a),this.getContextBaseUrl=(t,e=!0)=>{const a=this.getFronteggContext().getContext();return this.getBaseUrl(a,t,e)},this.getMetadataHeaders=t=>Gt.getMetadataHeaders(t),this.getContextMetadataHeaders=()=>{const t=this.getFronteggContext().getContext();return Gt.getMetadataHeaders(t)},this.appName=t}}Gt.getBaseUrl=(t,e,a=!0)=>{let n;n="function"==typeof t.baseUrl?t.baseUrl(e):t.baseUrl;const s=t.urlPrefix||"frontegg",i="frontegg"===s&&!a;return n.endsWith("/")||(n+="/"),n.endsWith(s)||i||(n+=s),n},Gt.getMetadataHeaders=t=>{var e,a;const n={};return null!=t&&null!=(e=t.metadataHeaders)&&e.fronteggSdkVersion&&(n[Mt.fronteggSdkVersion]=t.metadataHeaders.fronteggSdkVersion),null!=t&&null!=(a=t.metadataHeaders)&&a.framework&&(n[Mt.frameWork]=t.metadataHeaders.framework),n},Gt.getScopedTenant=()=>new URLSearchParams(window.location.search).get("tenantId")||null;const jt=new Gt("default");class Bt extends Error{constructor(t){super(t)}}const Vt="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){const e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Bt("'atob' failed: The string to be decoded is not correctly encoded.");let a="";for(let t,n,s=0,i=0;n=e.charAt(i++);~n&&(t=s%4?64*t+n:n,s++%4)?a+=String.fromCharCode(255&t>>(-2*s&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};class Wt extends Error{constructor(t){super(t)}}const Ht=(t,e={})=>{const a=e.header?0:1;try{return JSON.parse((t=>{let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("Illegal base64url string!")}try{return function(t){return decodeURIComponent(Vt(t).replace(/(.)/g,((t,e)=>{let a=e.charCodeAt(0).toString(16).toUpperCase();return a.length<2&&(a="0"+a),"%"+a})))}(e)}catch(t){return Vt(e)}})(t.split(".")[a]))}catch(t){throw new Wt("Invalid token specified: "+t.message)}};let zt,Kt,qt,Jt;!function(t){t.ALLOW="ALLOW",t.BLOCK="BLOCK"}(zt||(zt={})),function(t){t.WebAuthnPlatform="WebAuthnPlatform",t.WebAuthnCrossPlatform="WebAuthnCrossPlatform",t.SmsCode="SmsCode",t.SmsCodeV2="SmsCodeV2",t.Passkeys="Passkeys"}(Kt||(Kt={})),function(t){t.Platform="Platform",t.CrossPlatform="CrossPlatform"}(qt||(qt={})),function(t){t.AuthenticatorApp="AuthenticatorApp",t.WebAuthnPlatform="WebAuthnPlatform",t.WebAuthnCrossPlatform="WebAuthnCrossPlatform",t.SMS="SMS",t.EmailCode="EmailCode"}(Jt||(Jt={}));const Yt="admin_portal_should_load_authorization";class Xt{constructor(t){this.appName=void 0,this.fetchClient=void 0,this.get=async(t,e,a)=>this.fetchClient.get(t,e,a),this.post=async(t,e,a)=>this.fetchClient.post(t,e,a),this.patch=async(t,e,a)=>this.fetchClient.patch(t,e,a),this.put=async(t,e,a)=>this.fetchClient.put(t,e,a),this.delete=async(t,e,a)=>this.fetchClient.delete(t,e,a),this.postDownload=async(t,e,a,n)=>this.fetchClient.postDownload(t,e,a,n),this.extractHeadersFromOptions=(t={})=>this.fetchClient.extractHeadersFromOptions(t),this.appName=t,this.fetchClient=new Gt(t)}}const Qt={flags:{}};class Zt{constructor(){var t;this._flags={},this._flags=null!=(t=Qt.flags)?t:{}}static getInstance(t="default"){return this._instances[t]}static set(t,e="default"){const a=new Zt;return a.set(t),Zt._instances[e]=a,a}static getFeatureFlags(t,e){const a=this.getInstance(e);return t.map((t=>"on"===(null==a?void 0:a._flags[t])))}get flags(){var t;return null!=(t=this.flags)?t:{}}set(t){var e;this._flags=v({},null!=(e=null==Qt?void 0:Qt.flags)?e:{},null!=t?t:{})}}Zt._instances={};class te extends Xt{constructor(t){super(t),this.loadFeatureFlags=async()=>this.get(It)}}const ee=new te("default"),ae="FRONTEGG_SEPARATE_TABS_BY_TENANT",ne="admin_portal_use_current_user_tenants_v1_endpoint";class se extends Xt{constructor(t){super(t),this.GetUserJwt=async t=>this.post(`${q.v3}/me/token`,t),this.getUsersV2=async(t,e)=>this.get(q.v2,t,{headers:this.extractHeadersFromOptions(e)}),this.getUsersV3=async(t,e)=>this.get(q.v3,t,{headers:this.extractHeadersFromOptions(e)}),this.getUsersRoles=async(t,e)=>this.get(q.roles.v3,v({},t,{ids:t.ids.join(",")}),{headers:this.extractHeadersFromOptions(e)}),this.getUsersGroups=async(t,e)=>this.get(q.groups.v3,v({},t,{ids:t.ids.join(",")}),{headers:this.extractHeadersFromOptions(e)}),this.getCurrentUserTenantsV3=async t=>this.get(q.tenants.me.v3,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getCurrentUserTenantsV1=async t=>this.get(q.tenants.me.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.sendResetBreachedPasswordEmails=async()=>this.post(q.passwords.resetBreachedPasswords.v1),this.updateUserProfileV2=async t=>this.put(`${q.v2}/me`,t),this.unlockMe=async t=>this.post(`${q.v3}/me/unlock`,t)}}const ie=new se("default");function oe(t){t&&sessionStorage.setItem(ae,t)}function re(){sessionStorage.removeItem(ae)}function le(t){return U.for(t).isSessionPerTenantEnabled()?sessionStorage.getItem(ae):null}function ce(t){if(U.for(t).shouldSkipUserLoad())return async()=>({tenants:[],activeTenant:{}});const e=new se(t),[a]=Zt.getFeatureFlags([ne],t);return U.for(t).isSessionPerTenantEnabled()||a?e.getCurrentUserTenantsV1:e.getCurrentUserTenantsV3}class ue extends Xt{constructor(t){super(t),this.switchTenant=async t=>(U.for(this.appName).isSessionPerTenantEnabled()&&oe(t.tenantId),this.put(`${q.v1}/tenant`,t)),this.getTenants=async()=>this.get(`${q.v2}/me/tenants`),this.getSubTenants=async t=>this.get(gt.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getSubTenantsAsTree=async t=>this.get(gt.tree.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getParentTenants=async t=>this.get(gt.parents.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getParentTenantsById=async(t,e)=>this.get(`${gt.parents.v1}/${t}`,void 0,{headers:this.extractHeadersFromOptions(e)}),this.getTenantsUsersCount=async(t,e)=>this.post(`${Z.users.v1}/count`,t,{headers:this.extractHeadersFromOptions(e)}),this.searchSubTenants=async(t,e)=>this.get(gt.v2,t,{headers:this.extractHeadersFromOptions(e)}),this.getHierarchyMetadata=async(t,e)=>this.get(gt.metadata.v2,v({},t,{_tenantIds:t._tenantIds.join(",")}),{headers:this.extractHeadersFromOptions(e)})}}const de=new ue("default");class ge extends Xt{constructor(t){super(t),this.loadEntitlementsV2=async()=>this.get(kt)}}const pe=new ge("default");class he extends Xt{constructor(t){super(t),this.getGlobalSecurityPolicy=async()=>this.get(J.v1),this.getMfaPolicy=async()=>this.get(`${J.v1}/mfa-policy`),this.getVendorMfaPolicy=async()=>this.get(`${J.v1}/mfa-policy/vendor`),this.saveMfaPolicy=async t=>t.id?this.patch(`${J.v1}/mfa-policy`,t):this.post(`${J.v1}/mfa-policy`,t),this.getLockoutPolicy=async()=>this.get(`${J.v1}/lockout-policy`),this.getVendorLockoutPolicy=async()=>this.get(`${J.v1}/lockout-policy/vendor`),this.saveLockoutPolicy=async t=>t.id?this.patch(`${J.v1}/lockout-policy`,t):this.post(`${J.v1}/lockout-policy`,t),this.getCaptchaPolicy=async()=>{try{return await this.get(`${J.v1}/captcha-policy/public`)}catch{return null}},this.getPasswordHistoryPolicy=async()=>this.get(`${J.v1}/password-history-policy`),this.getVendorPasswordHistoryPolicy=async()=>this.get(`${J.v1}/password-history-policy/vendor`),this.savePasswordHistoryPolicy=async t=>t.id?this.patch(`${J.v1}/password-history-policy`,t):this.post(`${J.v1}/password-history-policy`,t),this.getPasswordRotationPolicy=async()=>{try{return await this.get(`${J.v1}/password-rotation`)}catch(t){return{}}},this.getVendorPasswordRotationPolicy=async()=>{try{return await this.get(`${J.v1}/password-rotation/vendor`)}catch(t){return{}}},this.savePasswordRotationPolicy=async t=>this.post(`${J.v1}/password-rotation`,t),this.getPasswordConfigPolicy=async()=>this.get(`${J.v1}/password`),this.getDomainRestrictions=async()=>this.get(`${Y.emailDomain.v1}`),this.getDomainRestrictionsConfig=async()=>this.get(`${Y.emailDomain.v1}/config`),this.createDomainRestriction=async t=>this.post(`${Y.emailDomain.v1}`,t),this.updateDomainRestrictionConfig=async t=>this.post(`${Y.emailDomain.v1}/config`,t),this.deleteDomainRestriction=async t=>this.delete(`${Y.emailDomain.v1}/${t}`),this.getIPRestrictions=async t=>this.get(`${Y.ip.v1}`,t),this.getIPRestrictionsConfig=async()=>this.get(`${Y.ip.v1}/config`),this.createIPRestriction=async t=>this.post(`${Y.ip.v1}`,t),this.bulkCreateIPRestriction=async t=>this.post(`${Y.ip.v1}/bulk`,t),this.updateIPRestrictionConfig=async t=>this.post(`${Y.ip.v1}/config`,t),this.deleteIPRestriction=async t=>this.delete(`${Y.ip.v1}/${t}`),this.testCurrentIp=async()=>this.post(`${Y.ip.v1}/verify`),this.testCurrentIpInAllowList=async()=>this.post(`${Y.ip.v1}/verify/allow`)}}const ye=new he("default"),Se=["type"],ve=["type"],fe=["type"];class me extends Xt{constructor(t){super(t),this.tenantsApi=new ue(this.appName),this.entitlementsApi=new ge(this.appName),this.securityPolicy=new he(this.appName),this.generateLoginResponse=async t=>{if(!t.accessToken)return t;const e=U.for(this.appName);e.setAccessToken(t.accessToken);const a=await this.getMeAndEntitlements(),n=v({},t,t.accessToken?Ht(t.accessToken):{},a);return e.setUser(n),n},this.generateLoginResponseV2=async t=>{if(!t.accessToken)return{user:t};const e=U.for(this.appName);e.setAccessToken(t.accessToken);const[a,n]=await Promise.all([this.getMeAndEntitlements(),this.tenantsApi.getTenants()]),s=v({},t,t.accessToken?Ht(t.accessToken):{},a);return e.setUser(s),{user:s,tenants:n}},this.generateLoginResponseV3=async t=>{const{accessToken:e}=t;if(!e)return{user:t};const a=U.for(this.appName);a.setAccessToken(e);const[n,s]=await Promise.all([this.getMeAndEntitlements(),ce(this.appName)()]),i=v({},t,e?Ht(e):{},n);return a.isSessionPerTenantEnabled()&&oe(i.tenantId),a.setUser(i),{user:i,tenants:s.tenants,activeTenant:s.activeTenant}},this.generateLoginResponseFromOAuthResponse=async t=>{const e=U.for(this.appName);e.setAccessToken(t.id_token);const a=await this.getMeAndEntitlements(),n=t.id_token?Ht(t.id_token):{},s=v({mfaRequired:!1,accessToken:t.id_token,refreshToken:t.refresh_token},n,a,{expiresIn:t.expires_in||300});return e.setUser(s),s},this.generateLoginResponseFromOAuthResponseV2=async t=>{const e=U.for(this.appName);e.setAccessToken(t.id_token);const[a,n]=await Promise.all([this.getMeAndEntitlements(),ce(this.appName)()]),s=t.id_token?Ht(t.id_token):{},i=v({mfaRequired:!1,accessToken:t.id_token,refreshToken:t.refresh_token},s,a,{expiresIn:t.expires_in||300});return e.isSessionPerTenantEnabled()&&oe(i.tenantId),e.setUser(i),{user:i,tenants:n.tenants,activeTenant:n.activeTenant}},this.preLogin=async t=>{try{const{address:e}=await this.post(`${K.v1}/user/saml/prelogin`,t);return e}catch{return null}},this.preLoginWithIdpType=async t=>this.post(`${K.v1}/user/saml/prelogin`,t),this.postLogin=async t=>{const e=await this.post(`${K.v1}/user/saml/postlogin`,t);return this.generateLoginResponse(e)},this.oidcPostLogin=async t=>{const e=await this.post(`${K.v1}/user/oidc/postlogin`,t);return this.generateLoginResponse(e)},this.login=async t=>{const e=await this.post(`${K.v1}/user`,t);return this.generateLoginResponse(e)},this.loginv2=async t=>{const e=await this.post(`${K.v1}/user`,t);return this.generateLoginResponseV3(e)},this.loginWithMfa=async t=>{const e=await this.post(`${K.v1}/user/mfa/verify`,t);return this.generateLoginResponse(e)},this.loginWithMfaV2=async t=>{const e=await this.post(`${K.v1}/user/mfa/verify`,t);return this.generateLoginResponseV3(e)},this.activateAccount=async t=>this.post(`${q.v1}/activate`,t),this.activateAccountV2=async t=>{const e=await this.post(`${q.v1}/activate`,t);return this.generateLoginResponseV3(e)},this.activateAccountWithOTC=async t=>{const e=await this.post(`${q.v1}/activate/code`,t);return this.generateLoginResponseV3(e)},this.getActivateAccountStrategy=async t=>this.get(`${q.v1}/activate/strategy`,t),this.resendActivationEmail=async t=>this.post(`${q.v1}/activate/reset`,t),this.resendInvitationEmail=async t=>this.post(`${q.v1}/invitation/reset`,t),this.acceptInvitation=async t=>this.post(`${q.v1}/invitation/accept`,t),this.acceptInvitationWithOTC=async t=>this.post(`${q.v1}/invitation/accept/code`,t),this.refreshToken=async()=>{const t=le(this.appName),e=await this.post(`${K.v1}/user/token/refresh`,{tenantId:t});return this.generateLoginResponse(e)},this.refreshTokenV2=async()=>{const t=le(this.appName),e=await this.post(`${K.v1}/user/token/refresh`,{tenantId:t});return this.generateLoginResponseV2(e)},this.refreshTokenV3=async()=>{const t=le(this.appName),e=await this.post(`${K.v1}/user/token/refresh`,{tenantId:t});return this.generateLoginResponseV3(e)},this.logout=async()=>this.post(`${K.v1}/logout`),this.OAuthLogout=async t=>this.get(`${Et}/logout`,t),this.forgotPassword=async t=>this.post(`${q.v1}/passwords/reset`,t),this.resetPassword=async t=>this.post(`${q.v1}/passwords/reset/verify`,t),this.loadPasswordConfig=async t=>this.get(`${q.v1}/passwords/config`,t),this.getSignUpStrategies=async()=>this.get(`${H.v1.strategies}`),this.recoverMfaToken=async t=>this.post(`${K.v1}/user/mfa/recover`,t),this.enrollMfa=async()=>this.post(`${q.v1}/mfa/enroll`),this.preEnrollMFAAuthenticatorApp=async()=>this.post(`${q.v1}/mfa/authenticator/enroll`),this.enrollMFAAuthenticatorApp=async t=>this.post(`${q.v1}/mfa/authenticator/enroll/verify`,t),this.preEnrollMFASMS=async t=>this.post(`${q.v1}/mfa/sms/enroll`,t),this.enrollMFASMS=async t=>this.post(`${q.v1}/mfa/sms/enroll/verify`,t),this.preEnrollMFAWebAuthn=async()=>this.post(`${q.v1}/mfa/webauthn/enroll`),this.enrollMFAWebAuthn=async t=>this.post(`${q.v1}/mfa/webauthn/enroll/verify`,t),this.verifyMfa=async t=>this.post(`${q.v1}/mfa/enroll/verify`,t),this.disableMfa=async t=>this.post(`${q.v1}/mfa/disable`,t),this.disableMFAAuthenticatorApp=async(t,e)=>this.post(`${q.v1}/mfa/authenticator/${t}/disable/verify`,e),this.preDisableMFASMS=async t=>this.post(`${q.v1}/mfa/sms/${t}/disable`),this.disableMFASMS=async(t,e)=>this.post(`${q.v1}/mfa/sms/${t}/disable/verify`,e),this.preDisableMFAWebAuthn=async t=>this.post(`${q.v1}/mfa/webauthn/${t}/disable`),this.disableMFAWebAuthn=async(t,e)=>this.post(`${q.v1}/mfa/webauthn/${t}/disable/verify`,e),this.getMFADevices=async()=>this.get(`${q.v1}/mfa/devices`),this.preEnrollMFAAuthenticatorAppForLogin=async t=>this.post(`${K.v1}/user/mfa/authenticator/enroll`,t),this.enrollMFAAuthenticatorAppForLogin=async t=>this.post(`${K.v1}/user/mfa/authenticator/enroll/verify`,t),this.enrollMFAAuthenticatorAppForLoginV2=async t=>{const e=await this.post(`${K.v1}/user/mfa/authenticator/enroll/verify`,t);return this.generateLoginResponseV3(e)},this.verifyMFAAuthenticatorAppForLogin=async(t,e)=>this.post(`${K.v1}/user/mfa/authenticator/${t}/verify`,e),this.preVerifyMFAEmailCode=async t=>this.post(`${K.v1}/user/mfa/emailcode`,t),this.verifyMFAEmailCode=async t=>this.post(`${K.v1}/user/mfa/emailcode/verify`,t),this.verifyMFAEmailCodeV2=async t=>{const e=await this.post(`${K.v1}/user/mfa/emailcode/verify`,t);return this.generateLoginResponseV3(e)},this.preEnrollMFASMSForLogin=async t=>this.post(`${K.v1}/user/mfa/sms/enroll`,t),this.enrollMFASMSForLogin=async t=>this.post(`${K.v1}/user/mfa/sms/enroll/verify`,t),this.enrollMFASMSForLoginV2=async t=>{const e=await this.post(`${K.v1}/user/mfa/sms/enroll/verify`,t);return this.generateLoginResponseV3(e)},this.preVerifyMFASMSForLogin=async(t,e)=>this.post(`${K.v1}/user/mfa/sms/${t}`,e),this.verifyMFASMSForLogin=async(t,e)=>this.post(`${K.v1}/user/mfa/sms/${t}/verify`,e),this.verifyMFASMSForLoginV2=async(t,e)=>{const a=await this.post(`${K.v1}/user/mfa/sms/${t}/verify`,e);return this.generateLoginResponseV3(a)},this.preEnrollMFAWebAuthnForLogin=async t=>this.post(`${K.v1}/user/mfa/webauthn/enroll`,t),this.enrollMFAWebAuthnForLogin=async t=>this.post(`${K.v1}/user/mfa/webauthn/enroll/verify`,t),this.enrollMFAWebAuthnForLoginV2=async t=>{const e=await this.post(`${K.v1}/user/mfa/webauthn/enroll/verify`,t);return this.generateLoginResponseV3(e)},this.preVerifyMFAWebAuthnForLogin=async(t,e)=>this.post(`${K.v1}/user/mfa/webauthn/${t}`,e),this.verifyMFAWebAuthnForLogin=async(t,e)=>this.post(`${K.v1}/user/mfa/webauthn/${t}/verify`,e),this.verifyMFAWebAuthnForLoginV2=async(t,e)=>{const a=await this.post(`${K.v1}/user/mfa/webauthn/${t}/verify`,e);return this.generateLoginResponseV3(a)},this.getSamlConfiguration=async()=>this.get(`${ot.v1}/saml/configurations`),this.updateSamlConfiguration=async t=>this.post(`${ot.v1}/saml/configurations`,t),this.getSamlVendorConfiguration=async()=>this.get(`${ot.v1}/saml/configurations/vendor-config`),this.updateSamlVendorMetadata=async t=>this.put(`${ot.v1}/saml/configurations/metadata`,t),this.validateSamlDomain=async()=>this.put(`${ot.v1}/saml/validations/domain`),this.getSamlRoles=async()=>this.get(`${ot.v1}/saml/configurations/roles/default`),this.getSamlRolesGroups=async()=>this.get(`${ot.v2}/saml/configurations/groups`),this.updateSamlRoles=async({roleIds:t})=>this.post(`${ot.v1}/saml/configurations/roles/default`,{roleIds:t}),this.createSamlGroup=async({roleIds:t,group:e})=>this.post(`${ot.v2}/saml/configurations/groups`,{group:e,roleIds:t}),this.updateSamlGroup=async({roleIds:t,group:e,id:a})=>this.patch(`${ot.v2}/saml/configurations/groups/${a}`,{group:e,roleIds:t}),this.deleteSamlGroup=async({id:t})=>this.delete(`${ot.v2}/saml/configurations/groups/${t}`),this.getOidcConfiguration=async()=>this.get(`${ot.v1}/oidc/configurations`),this.getSSOPublicConfiguration=async()=>this.get(`${ot.v2}/configurations/public`),this.getSocialLoginProviders=async()=>this.get(X.v1),this.getSocialLoginProvidersV2=async()=>this.get(X.v2),this.getSocialLoginProvidersV2ForAuthenticatedUser=async()=>this.get(`${X.v2}/authenticated`),this.getCustomSocialLoginProvidersV1=async()=>this.get(X.custom.v1),this.loginViaSocialLogin=async t=>{const e={};return t.code&&(e.code=t.code),t.idToken&&(e.id_token=t.idToken),t.redirectUri&&(e.redirectUri=t.redirectUri),t.codeVerifier&&(e.code_verifier=t.codeVerifier),t.codeVerifierPkce&&(e.code_verifier_pkce=t.codeVerifierPkce),t.state&&(e.state=t.state),this.post(`${K.v1}/user/sso/${t.provider}/postlogin`,{metadata:t.metadata,invitationToken:t.invitationToken},{params:e})},this.getVendorConfig=async()=>this.get(`${J.v1}/public`),this.signUpUser=async t=>{const{shouldActivate:e,authResponse:a,userId:n,tenantId:s,activationToken:i}=await this.post(`${q.v1}/signUp`,t),o={shouldActivate:e,userId:n,tenantId:s};if(!e&&a){const{user:t,tenants:e,activeTenant:n}=await this.generateLoginResponseV3(a);return v({},o,{user:t,tenants:e,activeTenant:n})}return v({},o,{activationToken:i})},this.signUpUserWithPhoneNumber=async t=>{const{shouldActivate:e,authResponse:a,userId:n,tenantId:s,activationToken:i}=await this.post(`${q.v1}/signUp/phoneNumber`,t),o={shouldActivate:e,userId:n,tenantId:s};if(!e&&a){const{user:t,tenants:e,activeTenant:n}=await this.generateLoginResponseV3(a);return v({},o,{user:t,tenants:e,activeTenant:n})}return v({},o,{activationToken:i})},this.getCurrentUserSessions=async()=>this.get(q.sessions.currentUser.v1),this.getCurrentUserSession=async()=>this.get(`${q.sessions.currentUser.v1}/current`),this.revokeSessionsForUser=async t=>this.post(`${q.sessions.v1}/revoke`,{userId:t}),this.getSessionConfigurations=async()=>this.get(q.sessions.configurations.v1),this.createOrUpdateSessionConfigrations=async t=>{await this.post(q.sessions.configurations.v1,t)},this.deleteSessionForUser=async t=>{await this.delete(`${q.sessions.currentUser.v1}/${t}`)},this.deleteAllSessionsForUser=async()=>{await this.delete(`${q.sessions.currentUser.v1}/all`)},this.getUserAccessTokensData=async()=>this.get(q.accessTokens.v1),this.getTenantAccessTokensData=async()=>this.get(Z.accessTokens.v1),this.deleteTenantAccessToken=async({id:t})=>{await this.delete(`${Z.accessTokens.v1}/${t}`)},this.deleteUserAccessToken=async({id:t})=>{await this.delete(`${q.accessTokens.v1}/${t}`)},this.createUserAccessToken=async t=>this.post(q.accessTokens.v1,t),this.createTenantAccessToken=async t=>this.post(Z.accessTokens.v1,t),this.getUserApiTokensData=async()=>this.get(q.apiTokens.v1),this.getTenantApiTokensData=async()=>this.get(Z.apiTokens.v1),this.updateUserApiTokensData=async t=>this.post(q.apiTokens.v1,t),this.updateTenantApiTokensData=async t=>this.post(Z.apiTokens.v2,t),this.deleteTenantApiToken=async({tokenId:t})=>{await this.delete(`${Z.apiTokens.v1}/${t}`)},this.deleteUserApiToken=async({tokenId:t})=>{await this.delete(`${q.apiTokens.v1}/${t}`)},this.getUserById=async({userId:t})=>this.get(`${q.v1}/${t}`),this.checkIfAllowToRememberMfaDevice=async t=>this.get(`${J.v1}/mfa-policy/allow-remember-device`,{mfaToken:t}),this.passwordlessPreLogin=async t=>{let{type:e}=t,a=f(t,Se);return this.post(`${K.v1}/passwordless/${e.toLocaleLowerCase()}/prelogin`,a)},this.passwordlessPostLoginV2=async t=>{let{type:e}=t,a=f(t,ve);const n=await this.post(`${K.v1}/passwordless/${e.toLocaleLowerCase()}/postlogin`,a);return this.generateLoginResponseV3(n)},this.passwordlessPostLogin=async t=>{let{type:e}=t,a=f(t,fe);return this.post(`${K.v1}/passwordless/${e.toLocaleLowerCase()}/postlogin`,a)},this.verifyInviteToken=async({token:t})=>this.post(Z.invites.verify.v1,{token:t}),this.getSSOConfigurations=async()=>this.get(`${ot.v1}/configurations`),this.createSSOConfiguration=async t=>this.post(`${ot.v1}/configurations`,t),this.updateSSOConfiguration=async(t,e)=>this.patch(`${ot.v1}/configurations/${t}`,e),this.deleteSSOConfiguration=async t=>{await this.delete(`${ot.v1}/configurations/${t}`)},this.createSSOConfigurationByMetadata=async t=>this.post(`${ot.v1}/configurations/metadata`,t),this.updateSSOConfigurationByMetadata=async(t,e)=>this.put(`${ot.v1}/configurations/${t}/metadata`,e),this.createSSOConfigurationByMetadataUrl=async t=>this.post(`${ot.v1}/configurations/metadata-url`,t),this.updateSSOConfigurationByMetadataUrl=async(t,e)=>this.put(`${ot.v1}/configurations/${t}/metadata-url`,e),this.createSSODomain=async(t,e)=>this.post(`${ot.v1}/configurations/${t}/domains`,e),this.deleteSSODomain=async(t,e)=>this.delete(`${ot.v1}/configurations/${t}/domains/${e}`),this.validateSSODomain=async(t,e)=>this.put(`${ot.v1}/configurations/${t}/domains/${e}/validate`),this.validateSSODomainV2=async(t,e)=>this.put(`${ot.v2}/configurations/${t}/domains/${e}/validate`),this.getSSODefaultRoles=async t=>this.get(`${ot.v1}/configurations/${t}/roles`),this.setSSODefaultRoles=async(t,e)=>this.put(`${ot.v1}/configurations/${t}/roles`,e),this.createSSOGroup=async(t,e)=>this.post(`${ot.v1}/configurations/${t}/groups`,e),this.updateSSOGroup=async(t,{roleIds:e,group:a,id:n})=>this.patch(`${ot.v1}/configurations/${t}/groups/${n}`,{group:a,roleIds:e}),this.deleteSSOGroup=async(t,e)=>this.delete(`${ot.v1}/configurations/${t}/groups/${e}`),this.getSSOGroups=async t=>this.get(`${ot.v1}/configurations/${t}/groups`),this.preLoginV2=async t=>this.post(`${K.v2}/user/sso/prelogin`,t),this.oidcPostLoginV2=async t=>{const e=await this.post(`${K.v2}/user/oidc/postlogin`,t);return this.generateLoginResponse(e)},this.exchangeOAuthTokensV2=async t=>{const e=await this.post(`${Et}/token`,t);return this.generateLoginResponseFromOAuthResponseV2(e)},this.silentOAuthRefreshTokenV2=async()=>{const t=le(this.appName),e=await this.post(`${Et}/authorize/silent`,{tenantId:t});return this.generateLoginResponseFromOAuthResponseV2(e)},this.exchangeOAuthTokens=async t=>{const e=await this.post(`${Et}/token`,t);return this.generateLoginResponseFromOAuthResponse(e)},this.silentOAuthRefreshToken=async()=>{const t=le(this.appName),e=await this.post(`${Et}/authorize/silent`,{tenantId:t});return this.generateLoginResponseFromOAuthResponse(e)},this.resetPhoneNumber=async t=>this.post(`${q.v1}/phone/reset`,t),this.verifyResetPhoneNumber=async t=>this.post(`${q.v1}/phone/reset/verify`,t),this.changePhoneNumberWithVerification=async t=>this.post(`${q.v1}/phone`,t),this.verifyChangePhoneNumber=async t=>this.post(`${q.v1}/phone/verify`,t),this.changePhoneNumber=async t=>this.put(`${q.v1}/phone/change`,t),this.webAuthnPreLogin=async t=>this.post(`${K.v1}/webauthn/prelogin`,t),this.webAuthnPostLogin=async t=>this.post(`${K.v1}/webauthn/postlogin`,t),this.webAuthnPostLoginV2=async t=>{const e=await this.post(`${K.v1}/webauthn/postlogin`,t);return this.generateLoginResponseV3(e)},this.webAuthnCreateNewDeviceSession=async()=>this.post(z.v1),this.getWebAuthnDevices=async()=>this.get(z.v1),this.deleteWebAuthnDevice=async t=>this.delete(`${z.v1}/${t}`),this.verifyNewDeviceSession=async t=>this.post(`${z.v1}/verify`,t),this.getVendorPublicAuthStrategiesConfig=async()=>this.get(`${J.v1}/auth/strategies/public`),this.getPublicAuthStrategiesConfigForAuthenticatedUser=async()=>this.get(`${J.v1}/auth/strategies`),this.getMFAStrategiesConfig=async()=>this.get(`${J.v1}/mfa/strategies`),this.getUserAuthorization=async()=>this.get(`${q.authorization.v1}`),this.getMeV2=async()=>this.get(`${q.v2}/me`),this.noThrowLoadEntitlements=async()=>{try{return await this.entitlementsApi.loadEntitlementsV2()}catch(t){}},this.getMeAndEntitlements=async()=>{if(U.for(this.appName).shouldSkipUserLoad())return{roles:[],permissions:[],groups:[],tenants:[]};const t=[{action:this.getMeV2,shouldLoad:!0},{action:this.noThrowLoadEntitlements,shouldLoad:this.shouldLoadEntitlements()},{action:this.getUserAuthorization,shouldLoad:this.shouldLoadMeAuthorization()}].map((t=>async function({shouldLoad:t,action:e}){if(t)return await e()}(t))),[e,a,n]=await Promise.all(t),s=le(this.appName);return s&&(e.tenantId=s),v({},e,null!=n?n:{},{entitlements:a})},this.generateStepupSession=async t=>{const e=await this.post(`${K.v1}/user/step-up/generate`,t);return e.accessToken?this.generateLoginResponseV3(e):e},this.getGlobalSecurityPolicy=this.securityPolicy.getGlobalSecurityPolicy.bind(this.securityPolicy),this.getMfaPolicy=this.securityPolicy.getMfaPolicy.bind(this.securityPolicy),this.getVendorMfaPolicy=this.securityPolicy.getVendorMfaPolicy.bind(this.securityPolicy),this.saveMfaPolicy=this.securityPolicy.saveMfaPolicy.bind(this.securityPolicy),this.getLockoutPolicy=this.securityPolicy.getLockoutPolicy.bind(this.securityPolicy),this.getVendorLockoutPolicy=this.securityPolicy.getVendorLockoutPolicy.bind(this.securityPolicy),this.saveLockoutPolicy=this.securityPolicy.saveLockoutPolicy.bind(this.securityPolicy),this.getCaptchaPolicy=this.securityPolicy.getCaptchaPolicy.bind(this.securityPolicy),this.getPasswordHistoryPolicy=this.securityPolicy.getPasswordHistoryPolicy.bind(this.securityPolicy),this.getVendorPasswordHistoryPolicy=this.securityPolicy.getVendorPasswordHistoryPolicy.bind(this.securityPolicy),this.savePasswordHistoryPolicy=this.securityPolicy.savePasswordHistoryPolicy.bind(this.securityPolicy),this.getPasswordConfigPolicy=this.securityPolicy.getPasswordConfigPolicy.bind(this.securityPolicy),this.getDomainRestrictions=this.securityPolicy.getDomainRestrictions.bind(this.securityPolicy),this.getDomainRestrictionsConfig=this.securityPolicy.getDomainRestrictionsConfig.bind(this.securityPolicy),this.createDomainRestriction=this.securityPolicy.createDomainRestriction.bind(this.securityPolicy),this.updateDomainRestrictionConfig=this.securityPolicy.updateDomainRestrictionConfig.bind(this.securityPolicy),this.deleteDomainRestriction=this.securityPolicy.deleteDomainRestriction.bind(this.securityPolicy),this.getIPRestrictions=this.securityPolicy.getIPRestrictions.bind(this.securityPolicy),this.getIPRestrictionsConfig=this.securityPolicy.getIPRestrictionsConfig.bind(this.securityPolicy),this.createIPRestriction=this.securityPolicy.createIPRestriction.bind(this.securityPolicy),this.bulkCreateIPRestriction=this.securityPolicy.bulkCreateIPRestriction.bind(this.securityPolicy),this.updateIPRestrictionConfig=this.securityPolicy.updateIPRestrictionConfig.bind(this.securityPolicy),this.deleteIPRestriction=this.securityPolicy.deleteIPRestriction.bind(this.securityPolicy),this.testCurrentIp=this.securityPolicy.testCurrentIp.bind(this.securityPolicy),this.testCurrentIpInAllowList=this.securityPolicy.testCurrentIpInAllowList.bind(this.securityPolicy)}shouldLoadEntitlements(){return U.for(this.appName).shouldLoadEntitlements()}shouldLoadMeAuthorization(){const[t]=Zt.getFeatureFlags([Yt],this.appName);return t}}const be=new me("default");class Ae extends Xt{constructor(t){super(t),this.getProfile=async t=>this.get(`${q.v2}/me`,null!=t?t:{addRoles:!0}),this.updateProfile=async t=>this.put(`${q.v2}/me`,t),this.updateProfileImage=async t=>this.put(`${ut.v1}/me/image/v1`,t,{responseType:"plain",contentType:void 0}),this.changePassword=async t=>this.post(`${q.v1}/passwords/change`,t),this.loadUsers=async t=>{var e,a,n,s,i,o;const r=(t.filter||[]).reduce(((t,e)=>v({},t,{[e.id]:e.value})),{}),l=null!=(e=t.sort)&&e.length?{sortBy:null!=(a=null==(n=t.sort)||null==(s=n[0])?void 0:s.id)?a:"name",sortDirection:null!=(i=t.sort)&&null!=(o=i[0])&&o.desc?"desc":"asc"}:null;return this.get(rt.v1,v({pageOffset:t.pageOffset,pageSize:t.pageSize},r,l))},this.addUser=async t=>this.post(q.v2,v({},t,{provider:"local"})),this.deleteUser=async t=>this.delete(`${rt.v1}/${t.userId}`),this.updateUser=async t=>this.put(rt.v1,t),this.updateUserExpirationTime=async t=>{const{userId:e,expirationInSeconds:a}=t;return this.put(`${q.temporary.v1}/${e}`,{expirationInSeconds:a})},this.setPermanentUser=async t=>this.delete(`${q.temporary.v1}/${t}`),this.getTemporaryUserConfiguration=async()=>this.get(q.temporary.configuration.v1),this.createInviteUserLink=async t=>this.post(Z.invites.user.v1,v({},t)),this.updateInviteUserLink=async t=>this.patch(Z.invites.user.v1,v({},t)),this.deleteInviteUserLink=async()=>this.delete(Z.invites.user.v1),this.getInviteUserLink=async()=>this.get(Z.invites.user.v1),this.getInviteLinkConfiguration=async()=>this.get(Z.invites.configuration.v1),this.loadAvailableRoles=async()=>this.get(lt.v1),this.loadAvailablePermissions=async()=>this.get(Q.v1),this.loadStats=async()=>this.get(`${ct.v1}/members`),this.resendActivationLink=async t=>this.post(`${rt.v1}/${t.userId}/resendActivationEmail`,{}),this.resendInvitationLink=async t=>this.post(q.v2,v({},t,{provider:"local"})),this.resendInvitationLinkToAllTenants=async t=>this.post(q.invitation.resendAll.v1,v({},t)),this.disableUser=async t=>this.post(`${Z.users.v1}/${t}/disable`),this.enableUser=async t=>this.post(`${Z.users.v1}/${t}/enable`)}}const we=new Ae("default");class Te extends Xt{constructor(t){super(t),this.getMetadata=async t=>{var e,a;const n=await this.get("/metadata",t);if(null!=n&&null!=(e=n.rows)&&e[0])return null==n||null==(a=n.rows)?void 0:a[0];throw new Error(`metadata not found: ${t.entityName}`)},this.getAdminBoxMetadata=async()=>this.get("/metadata/admin-box"),this.updateAdminBoxMetadata=async t=>this.post("/metadata/admin-box",t),this.getIpMetadata=async t=>{const e=await this.get(`/metadata/ip/${t}`);if(e)return e;throw new Error("ip metadata not found")},this.getCurrentUserIpMetadata=async()=>{const t=await this.get("/metadata/ipme");if(t)return t;throw new Error("ip metadata not found")},this.getNotificationsMetadata=async()=>this.getMetadata({entityName:"notifications"}),this.getSamlMetadata=async()=>this.getMetadata({entityName:"saml"}),this.getAuditsMetadata=async()=>this.getMetadata({entityName:"audits"}),this.getIpAdressMetadata=async t=>this.getIpMetadata(t)}}const Ee=new Te("default"),Ie=["dataFilters"],Oe=["templateId","dataFilters"],Pe=["dataFilters"];class ke extends Xt{constructor(t){super(t),this.getReports=async t=>this.get(`${ft.v2}/tenant-reports`,t),this.getReport=async t=>this.get(`${ft.v2}/${t.id}/tenant-reports`),this.renderReport=async t=>{let{dataFilters:e}=t,a=f(t,Ie);return{html:await this.get(`${mt.v1}/preview-report`,v({},a,{dataFilters:btoa(JSON.stringify(e||{})),responseType:"html"}),{responseType:"plain"})}},this.scheduleReport=async t=>{let{templateId:e,dataFilters:a}=t,n=f(t,Oe);return this.post(`${ft.v2}/${e}/tenant-reports`,v({},n,{dataFilters:btoa(JSON.stringify(a||{}))}))},this.downloadReport=async t=>{let{dataFilters:e}=t,a=f(t,Pe);const n=await this.get(`${mt.v1}/preview-report`,v({},a,{dataFilters:btoa(JSON.stringify(e||{}))}),{responseType:"blob"});let s="text/html",i="html";"pdf"===a.responseType?(s="application/pdf",i="pdf"):"image"===a.responseType&&(s="image/jpeg",i="jpg");const o=new Blob([n],{type:s}),r=URL.createObjectURL(o),l=document.createElement("a");l.href=r,l.setAttribute("download",`report_${a.name||""}.${i}`),l.click(),setTimeout(l.remove.bind(l))},this.sendReport=async t=>this.post(`${mt.v1}/tenant-reports`,t)}}const _e=new ke("default"),Re=["eventKey"],Ue=["eventKey"];class Ce extends Xt{constructor(t){super(t),this.getSlackConfiguration=()=>this.get(`${ht.v1}/slack`),this.getSlackScope=()=>this.get(`${ht.v1}/slack/applications`),this.getSlackChannels=()=>this.get(`${ht.v1}/slack/channels`),this.postSlackConfiguration=t=>t.id?this.patch(`${ht.v1}/slack/subscription/${t.id}`,t):this.post(`${ht.v1}/slack/subscriptions`,t),this.deleteSlackConfiguration=t=>this.delete(`${ht.v1}/slack/subscriptions/${t.id}`),this.postSlackCode=t=>this.post(`${ht.v1}/slack/applications/registrations`,{code:t}),this.getEmailConfiguration=()=>this.get(`${ht.v1}/emails`),this.postEmailConfiguration=t=>{let{eventKey:e}=t,a=f(t,Re);return this.post(`${ht.v1}/emails/${e}`,a)},this.patchEmailConfiguration=({eventKey:t,enabled:e})=>this.patch(`${ht.v1}/emails/${t}`,{enabled:e}),this.deleteEmailSubscriptions=(t,e)=>this.delete(`${ht.v1}/emails/${t}/subscriptions/${e}`),this.putEmailSubscriptions=(t,e,a)=>this.put(`${ht.v1}/emails/${e}/subscriptions/${t}`,a),this.deleteEmailConfiguration=t=>this.delete(`${ht.v1}/emails/${t}`),this.getSMSConfiguration=()=>this.get(`${ht.v2}/sms`),this.postSMSConfiguration=t=>{let{eventKey:e}=t,a=f(t,Ue);return this.post(`${ht.v2}/sms/${e}`,a)},this.patchSMSConfiguration=({eventKey:t,enabled:e})=>this.patch(`${ht.v2}/sms/${t}`,{enabled:e}),this.deleteSMSSubscriptions=(t,e)=>this.delete(`${ht.v2}/sms/${t}/subscriptions/${e}`),this.putSMSSubscriptions=(t,e,a)=>this.put(`${ht.v2}/sms/${e}/subscriptions/${t}`,a),this.deleteSMSConfiguration=t=>this.delete(`${ht.v2}/sms/${t}`),this.getWebhooksConfigurations=()=>this.get(Tt),this.postWebhooksConfiguration=t=>t._id?this.patch(`${Tt}/${t._id}`,t):this.post(`${Tt}/custom`,t),this.deleteWebhooksConfiguration=t=>this.delete(`${Tt}/${t}`),this.getWebhookLog=(t,e=0,a=10)=>{const n=new URLSearchParams({id:t,offset:`${e}`,limit:`${a}`});return this.get(`${Tt}/logs/?${n.toString()}`)},this.postWebhookTest=t=>this.post(`${Tt}/test`,t),this.postWebhookRetry=t=>this.post(`${Tt}/logs/${t}/retries`),this.getCategories=()=>this.get(`${wt.v1}/categories`),this.getChannelMaps=t=>this.get(wt.v1,{channels:t})}}const Le=new Ce("default");class De extends Xt{constructor(t){super(t),this.getNotifications=async t=>this.get(bt,{params:t}),this.updateNotificationStatus=async t=>this.put(`${bt}/status`,{params:t}),this.updateNotificationIsPinned=async t=>{const{notificationId:e,pinStatus:a}=t;return this.put(`${bt}/${a}`,{notificationId:e})},this.markAllAsRead=async()=>this.post(`${bt}/status/mark-all-read`)}}const Ne=new De("default"),Me=["endpoint","headerProps"];class Fe extends Xt{constructor(t){super(t),this.getAudits=async t=>this.get(At,t),this.getAuditsStats=async t=>this.get(`${At}/stats`,t),this.exportAudits=async t=>{const{endpoint:e,headerProps:a}=t,n=f(t,Me);return this.postDownload(`${At}/export/${e}`,{properties:a},n)}}}const xe=new Fe("default");class $e extends Xt{constructor(t){super(t),this.updateSettings=async(t,e)=>this.put(dt.v1,t,{headers:this.extractHeadersFromOptions(e)}),this.getSettings=async t=>this.get(dt.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getPublicSettings=async()=>this.get(`${dt.v1}/public`)}}const Ge=new $e("default"),je=["roleId"],Be=["roleId"],Ve=["permissionId"];class We extends Xt{constructor(t){super(t),this.getRoles=async()=>this.get(tt.v1),this.addRole=async t=>this.post(tt.v1,t),this.deleteRole=async({roleId:t})=>this.delete(`${tt.v1}/${t}`),this.updateRole=async t=>{let{roleId:e}=t,a=f(t,je);return this.patch(`${tt.v1}/${e}`,a)},this.attachPermissionsToRole=async t=>{let{roleId:e}=t,a=f(t,Be);return this.put(`${tt.v1}/${e}/permissions`,a)},this.getPermissions=async()=>this.get(Q.v1),this.attachPermissionToRoles=async t=>{let{permissionId:e}=t,a=f(t,Ve);return this.put(`${Q.v1}/${e}/roles`,a)},this.getPermissionCategories=async()=>this.get(`${Q.v1}/categories`),this.addRoleV2=async t=>this.post(tt.v2,t)}}const He=new We("default");class ze extends Xt{constructor(...t){super(...t),this.getSubscriptionInvoices=async()=>this.get(yt.invoices.v1),this.getSubscriptionInvoice=async t=>this.get(`${yt.invoices.v1}/${t}`),this.getSubscriptionInvoicePdf=async(t,e)=>this.get(`${yt.invoices.v1}/${t}/pdf`,{outputFileName:e},{responseType:"blob"})}}class Ke extends Xt{constructor(...t){super(...t),this.getManagedSubscription=async t=>this.get(`${vt.v1}/${t}`),this.getManagedSubscriptions=async()=>this.get(vt.v1),this.cancelManagedSubscription=async t=>this.put(`${vt.v1}/${t}/cancellations/`,{}),this.renewManagedSubscription=async t=>this.put(`${vt.v1}/${t}/renewals/`,{}),this.updateManagedSubscription=async(t,{paymentMethodId:e,planId:a})=>this.put(`${vt.v1}/${t}`,{paymentMethodId:e,planId:a})}}const qe=["email"];class Je extends Xt{constructor(...t){super(...t),this.getPaymentMethods=async()=>this.get(yt.paymentMethods.v1),this.getPaymentMethod=async t=>this.get(`${yt.paymentMethods.v1}/${t}`),this.updatePaymentMethodBillingDetails=async(t,e)=>{let{email:a}=e,n=f(e,qe);return this.patch(`${yt.paymentMethods.v1}/${t}/billing-details`,{email:a,address:n})}}}class Ye extends Xt{constructor(...t){super(...t),this.getPaymentProviders=async()=>this.get(St.v1)}}class Xe extends Xt{constructor(...t){super(...t),this.getSubscriptionPlans=async()=>this.get(yt.plans.v1),this.getSubscriptionPlan=async t=>this.get(`${yt.plans.v1}/${t}`)}}class Qe extends Xt{constructor(...t){super(...t),this.getSubscriptions=async()=>this.get(yt.subscriptions.v1),this.getSubscription=async t=>this.get(`${yt.subscriptions.v1}/${t}`),this.cancelSubscription=async t=>this.put(`${yt.subscriptions.v1}/${t}/cancellations/`,{}),this.renewSubscription=async t=>this.put(`${yt.subscriptions.v1}/${t}/renewals/`,{}),this.updateSubscription=async(t,{paymentMethodId:e,planId:a})=>this.put(`${yt.subscriptions.v1}/${t}`,{paymentMethodId:e,planId:a})}}class Ze extends Xt{constructor(...t){super(...t),this.getSubscriptionSummaries=async t=>this.get(`${yt.summaries.v1}/${t}`)}}class ta extends Xt{constructor(...t){super(...t),this.getTenantConfiguration=async t=>this.get(`${yt.tenantConfiguration.v1}/${t}`),this.createTenantConfiguration=async t=>this.post(yt.tenantConfiguration.v1,t)}}class ea extends Xt{constructor(...t){super(...t),this.getVendorPublicConfigurations=async()=>this.get(yt.configurations.vendorPublicConfigurations.v1)}}class aa extends Xt{constructor(...t){super(...t),this.createSubscription=async t=>this.post(yt.paymentProviders.stripe.subscriptions.v1,t),this.getStripeCustomer=async t=>this.get(`${yt.paymentProviders.stripe.customers.v1}/${t}`),this.createStripeCustomer=async t=>this.post(yt.paymentProviders.stripe.customers.v1,t),this.getStripePaymentProviderConfiguration=async()=>this.get(yt.paymentProviders.stripe.publicConfigurations.v1),this.createStripePaymentMethodSetupIntentSecret=async t=>this.post(yt.paymentProviders.stripe.setupIntents.v1,t)}}class na extends Xt{constructor(t){super(t),this.invoicesApi=new ze(this.appName),this.managedSubscriptionApi=new Ke(this.appName),this.paymentMethodsApi=new Je(this.appName),this.paymentProvidersApi=new Ye(this.appName),this.plansApi=new Xe(this.appName),this.subscriptionApi=new Qe(this.appName),this.summariesApi=new Ze(this.appName),this.subscriptionTenantConfigApi=new ta(this.appName),this.vendorPublicConfigApi=new ea(this.appName),this.stripeProviderApi=new aa(this.appName),this.getSubscriptionInvoices=this.invoicesApi.getSubscriptionInvoices.bind(this.invoicesApi),this.getSubscriptionInvoice=this.invoicesApi.getSubscriptionInvoice.bind(this.invoicesApi),this.getSubscriptionInvoicePdf=this.invoicesApi.getSubscriptionInvoicePdf.bind(this.invoicesApi),this.getManagedSubscription=this.managedSubscriptionApi.getManagedSubscription.bind(this.managedSubscriptionApi),this.getManagedSubscriptions=this.managedSubscriptionApi.getManagedSubscriptions.bind(this.managedSubscriptionApi),this.cancelManagedSubscription=this.managedSubscriptionApi.cancelManagedSubscription.bind(this.managedSubscriptionApi),this.renewManagedSubscription=this.managedSubscriptionApi.renewManagedSubscription.bind(this.managedSubscriptionApi),this.updateManagedSubscription=this.managedSubscriptionApi.updateManagedSubscription.bind(this.managedSubscriptionApi),this.getPaymentMethods=this.paymentMethodsApi.getPaymentMethods.bind(this.paymentMethodsApi),this.getPaymentMethod=this.paymentMethodsApi.getPaymentMethod.bind(this.paymentMethodsApi),this.updatePaymentMethodBillingDetails=this.paymentMethodsApi.updatePaymentMethodBillingDetails.bind(this.paymentMethodsApi),this.getPaymentProviders=this.paymentProvidersApi.getPaymentProviders.bind(this.paymentProvidersApi),this.getSubscriptionPlans=this.plansApi.getSubscriptionPlans.bind(this.plansApi),this.getSubscriptionPlan=this.plansApi.getSubscriptionPlan.bind(this.plansApi),this.getSubscriptions=this.subscriptionApi.getSubscriptions.bind(this.subscriptionApi),this.getSubscription=this.subscriptionApi.getSubscription.bind(this.subscriptionApi),this.cancelSubscription=this.subscriptionApi.cancelSubscription.bind(this.subscriptionApi),this.renewSubscription=this.subscriptionApi.renewSubscription.bind(this.subscriptionApi),this.updateSubscription=this.subscriptionApi.updateSubscription.bind(this.subscriptionApi),this.getSubscriptionSummaries=this.summariesApi.getSubscriptionSummaries.bind(this.summariesApi),this.getTenantConfiguration=this.subscriptionTenantConfigApi.getTenantConfiguration.bind(this.subscriptionTenantConfigApi),this.createTenantConfiguration=this.subscriptionTenantConfigApi.createTenantConfiguration.bind(this.subscriptionTenantConfigApi),this.getVendorPublicConfigurations=this.vendorPublicConfigApi.getVendorPublicConfigurations.bind(this.vendorPublicConfigApi),this.createSubscription=this.stripeProviderApi.createSubscription.bind(this.stripeProviderApi),this.getStripeCustomer=this.stripeProviderApi.getStripeCustomer.bind(this.stripeProviderApi),this.createStripeCustomer=this.stripeProviderApi.createStripeCustomer.bind(this.stripeProviderApi),this.getStripePaymentProviderConfiguration=this.stripeProviderApi.getStripePaymentProviderConfiguration.bind(this.stripeProviderApi),this.createStripePaymentMethodSetupIntentSecret=this.stripeProviderApi.createStripePaymentMethodSetupIntentSecret.bind(this.stripeProviderApi)}}const sa=new na("default");class ia extends Xt{constructor(t){super(t),this.getVendorPublicInfo=async()=>this.get("/vendors/public")}}const oa=new ia("default");class ra extends Xt{constructor(t){super(t),this.loadAllUsers=async t=>this.get(et.v1,t),this.addUserToTenantAndSubTenants=async t=>this.post(et.v1,t),this.removeUserFromTenantAndSubTenants=async(t,e)=>this.delete(et.v1,t,{headers:this.extractHeadersFromOptions(e)}),this.addUserRolesForSubTenants=async(t,e,a)=>this.post(`${et.v1}/${t}/roles`,e,{headers:this.extractHeadersFromOptions(a)}),this.removeUserRolesFromSubTenants=async(t,e,a)=>this.delete(`${et.v1}/${t}/roles`,e,{headers:this.extractHeadersFromOptions(a)}),this.setUserRolesForSubTenants=async(t,e,a)=>this.patch(`${et.v1}/${t}/roles`,e,{headers:this.extractHeadersFromOptions(a)}),this.createSubTenant=async(t,e)=>this.post(pt.v1,t,{headers:this.extractHeadersFromOptions(e)}),this.deleteSubTenant=async(t,e)=>this.delete(`${pt.v1}/${t}`,void 0,{headers:this.extractHeadersFromOptions(e)}),this.updateSubTenant=async({tenantId:t},e,a)=>this.patch(`${pt.v1}/${t}`,e,{headers:this.extractHeadersFromOptions(a)}),this.updateSubTenantManagement=async({tenantId:t},e,a)=>this.put(`${pt.v1}/${t}/management`,e,{headers:this.extractHeadersFromOptions(a)}),this.updateSubAccountAccess=async(t,e,a)=>this.put(`${et.v1}/${t}/access`,e,{headers:this.extractHeadersFromOptions(a)}),this.addUsersToSubTenant=async(t,e)=>this.post(`${et.v2}/`,t,{headers:this.extractHeadersFromOptions(e)})}updateSubTenantHierarchySettings({tenantId:t},e,a){return this.put(`${pt.v1}/${t}/hierarchy-settings`,e,{headers:this.extractHeadersFromOptions(a)})}}const la=new ra("default");class ca extends Xt{constructor(t){super(t),this.getConfigs=async()=>this.get(`${Ot}`),this.updateConfiguration=async(t,e)=>this.patch(`${Ot}/${t}`,e),this.createConfiguration=async t=>this.post(`${Ot}`,t),this.deleteConfiguration=async(t,e)=>this.delete(`${Ot}/${t}`,{deleteAll:e}),this.countConfigurationUsers=async t=>this.get(`${Pt}/${t}/Users/count`)}}const ua=new ca("default");class da extends Xt{constructor(t){super(t),this.impersonate=async t=>this.post(`${at.v1}`,t)}}const ga=new da("default"),pa=["groupId"];class ha extends Xt{constructor(t){super(t),this.getGroupById=async({groupId:t},e)=>this.get(`${st.v1}/${t}`,v({},e)),this.getGroups=async t=>this.get(`${st.v1}`,v({},t)),this.getGroupsByIds=async(t,e)=>this.post(`${st.getByIds.v1}`,t,{params:e}),this.createGroup=async t=>this.post(`${st.v1}`,t),this.updateGroup=async t=>{let{groupId:e}=t,a=f(t,pa);return this.patch(`${st.v1}/${e}`,a)},this.deleteGroup=async t=>this.delete(`${st.v1}/${t}`),this.addRolesToGroup=async(t,e)=>this.post(`${st.v1}/${t}/roles`,e),this.deleteRolesFromGroup=async(t,e)=>this.delete(`${st.v1}/${t}/roles`,e),this.addUsersToGroup=async(t,e)=>this.post(`${st.v1}/${t}/users`,e),this.deleteUsersFromGroup=async(t,e)=>this.delete(`${st.v1}/${t}/users`,e),this.getGroupConfiguration=async()=>this.get(`${st.configurations.v1}`),this.updateGroupConfiguration=async t=>this.post(`${st.configurations.v1}`,t)}}const ya=new ha("default");class Sa extends Xt{constructor(t){super(t),this.getRecommendations=async()=>this.get(_t.v1),this.getInsights=async()=>this.get(Rt.v1)}}const va=new Sa("default");class fa extends Xt{constructor(t){super(t),this.getUserPhoneNumbers=async t=>this.get(`${it.v1}`,t),this.getUserOwnPhoneNumbers=async()=>this.get(`${it.v1}/me`),this.createPhoneNumber=async t=>this.post(`${it.v1}`,t),this.deletePhoneNumber=async t=>this.delete(`${it.v1}/${t}`),this.preVerifyPhoneNumber=async t=>this.post(`${it.v1}/preverify`,t),this.verifyPhoneNumber=async t=>this.post(`${it.v1}/verify`,t),this.verifyDeletePhoneNumber=async(t,e)=>this.post(`${it.v1}/${t}/delete/verify`,e)}}const ma=new fa("default");class ba extends Xt{constructor(t){super(t),this.getUserApplicationsId=async({userId:t})=>this.get(`${nt.v1}/${t}/apps`),this.getUsersApplicationsId=async({userIds:t})=>this.get(`${nt.v1}/users-apps`,{userIds:t.join(",")}),this.getTenantsApplications=async()=>this.get(Ct.v1),this.getApplicationsData=async({appIds:t,includeFreeAccess:e=!0})=>this.get(Ut,{ids:t.join(","),_includeFreeAccess:e}),this.assignUserToApplications=async t=>this.post(`${nt.v1}/apps-user`,t),this.unassignUserFromApplications=async t=>this.delete(`${nt.v1}/user-apps`,t),this.getUsersOfApplications=async({appIds:t})=>this.get(`${nt.v1}/apps-users`,{appIds:t.join(",")})}}const Aa=new ba("default"),wa={"x-frontegg-api-key":"my-frontegg-api-key","frontegg-vendor-id":"04ae2174-d8d9-4a90-8bab-2548e210a508","frontegg-tenant-id":"02e6ab6f-8b25-48e4-b06d-2c53745ce213","frontegg-user-id":"e5c397a1-7120-4753-9216-e5d7f35d1f2d"};class Ta extends Xt{constructor(t){super(t),this.getAgentsConfig=async()=>this.get(`${Lt}/config`,void 0,{headers:wa}),this.getConversations=async()=>this.get(`${Lt}/conversations`,void 0,{headers:wa}),this.getConversationById=async t=>this.get(`${Lt}/conversation/${t.id}`,void 0,{headers:wa}),this.createConversation=async t=>this.post(`${Lt}/conversations`,{message:t.message,stream:t.stream},{responseType:!1===t.stream?"json":"stream",headers:wa}),this.sendMessage=async t=>this.post(`${Lt}/conversation/${t.conversationId}/messages`,{message:t.message,stream:t.stream},{responseType:!1===t.stream?"json":"stream",headers:wa}),this.sendApiResponse=async t=>this.post(`${Lt}/conversation/${t.conversationId}/response/${t.callId}`,{data:t.data,status:t.status,stream:t.stream},{responseType:!1===t.stream?"json":"stream",headers:wa}),this.getConversationResource=async t=>this.get(`${Lt}/conversation/${t.conversationId}/resource/${t.resourceId}`,void 0,{headers:wa})}}const Ea=new Ta("default");let Ia,Oa,Pa,ka,_a;!function(t){t.FRONTEGG="frontegg",t.SCIM2="scim2"}(Ia||(Ia={})),function(t){t.createdAt="createdAt",t.name="name",t.tenantId="tenantId"}(Oa||(Oa={})),function(t){t.CUSTOMER="customer",t.SPAM="spam",t.TEST="test",t.RESELLER="reseller",t.HEADQUARTER="headquarter"}(Pa||(Pa={})),function(t){t.NEVER="NEVER",t.ALWAYS="ALWAYS",t.ASSIGNABLE="ASSIGNABLE"}(ka||(ka={})),function(t){t.DEFAULT_OFF="defaultOff",t.DEFAULT_ON="defaultOn",t.ALWAYS_ON="alwaysOn"}(_a||(_a={}));const Ra=[/^(.*)\/logout$/g,"/logout",/^\/identity\/resources\/auth\/v[0-9]*\/user\/[^\/]*\/postlogin$/g,/^\/identity\/resources\/impersonation\/v[0-9]$/g,/^\/identity\/resources\/auth\/v[0-9]*\/passwordless\/[^\/]*\/postlogin$/g,/^\/identity\/resources\/auth\/v[0-9]*\/webauthn\/postlogin$/g,/^\/identity\/resources\/auth\/v[0-9]*\/user$/g,/^\/identity\/resources\/auth\/v[0-9]*\/user\/token\/refresh$/g,/^\/identity\/resources\/users\/v[0-9]*\/signUp$/g,/^\/identity\/resources\/users\/v[0-9]*\/activate$/g,/^\/identity\/resources\/users\/v[0-9]*\/invitation\/accept$/g,/^\/identity\/resources\/auth\/v[0-9]*\/user\/mfa\/verify$/g,/^\/identity\/resources\/auth\/v[0-9]*\/user\/mfa\/[^\/]*\/[^\/]*\/verify$/g,/^\/oauth\/token$/g,/^\/oauth\/authorize\/silent$/g],Ua=`${K.v1}/user/token/refresh`,Ca=`${Et}/authorize/silent`,La=`${q.v2}/me`,Da=`${q.v2}/me/tenants`,Na=`${q.v3}/me/tenants`,Ma=kt;let Fa,xa,$a,Ga,ja;!function(t){t.FRONTEGG="frontegg",t.OKTA="okta",t.AZURE_AD="azure-ad",t.OTHER="other"}(Fa||(Fa={})),function(t){t.roles="roles",t.users="users",t.rolesAndUsers="rolesAndUsers"}(xa||(xa={})),function(t){t.FRONTEGG="frontegg",t.SCIM2="scim2"}($a||($a={})),function(t){t.createdAt="createdAt",t.name="name",t.email="email",t.id="id",t.verified="verified",t.isLocked="isLocked",t.provider="provider",t.tenantId="tenantId"}(Ga||(Ga={})),function(t){t.MFA_UNENROLLED="mfa-unenrolled",t.BREACHED_PASSWORDS="breached-passwords",t.INACTIVE="inactive"}(ja||(ja={}));const Ba=["local","saml","google","github","facebook","microsoft","scim2","slack"];let Va,Wa,Ha,za,Ka,qa,Ja;!function(t){t.MISSING_PERMISSION="MISSING_PERMISSION",t.MISSING_FEATURE="MISSING_FEATURE",t.BUNDLE_EXPIRED="BUNDLE_EXPIRED"}(Va||(Va={})),function(t){t.FORCE_MFA="FORCE_MFA",t.BREACHED_PASSWORDS_EXIST="BREACHED_PASSWORDS_EXIST",t.ENABLE_USER_LOCKOUT="ENABLE_USER_LOCKOUT",t.STRENGTHEN_USER_LOCKOUT="STRENGTHEN_USER_LOCKOUT",t.ENABLE_PASSWORD_HISTORY="ENABLE_PASSWORD_HISTORY",t.STRENGTHEN_PASSWORD_HISTORY="STRENGTHEN_PASSWORD_HISTORY",t.ENABLE_FORCE_RELOGIN="ENABLE_FORCE_RELOGIN",t.SET_FORCE_RELOGIN="SET_FORCE_RELOGIN",t.ENABLE_SESSION_CONCURRENCY="ENABLE_SESSION_CONCURRENCY",t.SET_SESSION_CONCURRENCY="SET_SESSION_CONCURRENCY",t.ENABLE_IDLE_SESSION="ENABLE_IDLE_SESSION",t.SET_IDLE_SESSION="SET_IDLE_SESSION",t.ENABLE_IP_RESTRICTIONS="ENABLE_IP_RESTRICTIONS",t.CHANGE_IP_TO_ALLOWLIST="CHANGE_IP_TO_ALLOWLIST",t.ENABLE_DOMAIN_RESTRICTIONS="ENABLE_DOMAIN_RESTRICTIONS",t.CHANGE_DOMAIN_TO_ALLOWLIST="CHANGE_DOMAIN_TO_ALLOWLIST",t.CONFIGURE_SSO="CONFIGURE_SSO"}(Wa||(Wa={})),function(t){t.MFA_FORCED="MFA_FORCED",t.PARTIALLY_FORCED_MFA="PARTIALLY_FORCED_MFA",t.PARTIAL_MFA_USAGE="PARTIAL_MFA_USAGE",t.FULL_MFA_USAGE="FULL_MFA_USAGE",t.BREACHED_PASSWORD_USERS_EXIST="BREACHED_PASSWORD_USERS_EXIST",t.IMPROVE_LOCKOUT_POLICY="IMPROVE_LOCKOUT_POLICY",t.IMPROVE_PASSWORD_HISTORY_POLICY="IMPROVE_PASSWORD_HISTORY_POLICY",t.NO_SESSION_SETTINGS="NO_SESSION_SETTINGS",t.PARTIAL_SESSION_SETTINGS="PARTIAL_SESSION_SETTINGS",t.FULL_SESSION_SETTINGS="FULL_SESSION_SETTINGS",t.NO_IP_RESTRICTIONS="NO_IP_RESTRICTIONS",t.IP_ALLOWLIST="IP_ALLOWLIST",t.IP_DENYLIST="IP_DENYLIST",t.NO_DOMAIN_RESTRICTIONS="NO_DOMAIN_RESTRICTIONS",t.DOMAIN_ALLOWLIST="DOMAIN_ALLOWLIST",t.DOMAIN_DENYLIST="DOMAIN_DENYLIST",t.FULL_PASSWORD_SETTINGS="FULL_PASSWORD_SETTINGS"}(Ha||(Ha={})),function(t){t.SEND_RESET_BREACHED_PASSWORD_EMAIL="SEND_RESET_BREACHED_PASSWORD_EMAIL",t.ADJUST_FORCE_RELOGIN="ADJUST_FORCE_RELOGIN",t.ADJUST_MAX_CONCURRENT_SESSIONS="ADJUST_MAX_CONCURRENT_SESSIONS",t.ADJUST_IDLE_TIMEOUT="ADJUST_IDLE_TIMEOUT"}(za||(za={})),function(t){t.SEVERE="SEVERE",t.WARNING="WARNING",t.INFO="INFO"}(Ka||(Ka={})),function(t){t.MFA="MFA",t.SESSIONS="SESSIONS",t.PASSWORD="PASSWORD",t.INACTIVITY="INACTIVITY",t.IP="IP",t.DOMAIN="DOMAIN",t.SSO="SSO"}(qa||(qa={})),function(t){t.FREE_ACCESS="FREE_ACCESS",t.MANAGED_ACCESS="MANAGED_ACCESS"}(Ja||(Ja={}));const Ya={auth:be,securityPolicy:ye,teams:we,metadata:Ee,reports:_e,connectivity:Le,notifications:Ne,audits:xe,tenants:de,accountSettings:Ge,roles:He,subscriptions:sa,vendor:oa,subTenants:la,featureFlags:ee,directory:ua,impersonate:ga,groups:ya,users:ie,entitlements:pe,securityCenter:va,userPhoneNumbers:ma,applications:Aa,velo:Ea},Xa=t=>({auth:new me(t),securityPolicy:new he(t),teams:new Ae(t),metadata:new Te(t),reports:new ke(t),connectivity:new Ce(t),notifications:new De(t),audits:new Fe(t),tenants:new ue(t),accountSettings:new $e(t),roles:new We(t),subscriptions:new na(t),vendor:new ia(t),subTenants:new ra(t),featureFlags:new te(t),directory:new ca(t),impersonate:new da(t),groups:new ha(t),users:new se(t),entitlements:new ge(t),securityCenter:new Sa(t),userPhoneNumbers:new fa(t),applications:new ba(t),velo:new Ta(t)}),Qa={fetch:jt,FetchClient:Gt,ContextHolder:U,FronteggContext:L,api:Ya,createApiClient:Xa,FronteggApiError:W,AuthStrategyEnum:N,MachineToMachineAuthStrategy:M,SocialLoginProviders:D,ISubscriptionCancellationPolicy:G,ISubscriptionStatus:x,PaymentMethodType:$,ProviderType:j};var Za=a(2743),tn=a.n(Za);const en=(t,e)=>{const a=tn()(t,v({},e));return function(t={}){return O(t)}(v({__isProxy:!0},a))};let an;!function(t){t.validate="validate",t.invalid="invalid",t.pending="pending",t.success="success",t.failed="failed"}(an||(an={}));const nn={step:an.validate},sn=t=>en(nn,t);var on=a(5302),rn=a.n(on),ln=a(1098),cn=a.n(ln);const un="http://schemas.openid.net/pape/policies/2007/06/multi-factor",dn="mfa",gn=["otp","sms","hwk"],pn="SHOULD_STEP_UP",hn="maxAge";let yn,Sn,vn,fn;!function(t){t.preLogin="preLogin",t.magicLinkPreLoginSuccess="magicLinkPreLoginSuccess",t.loginWithSmsOtc="loginWithSmsOtc",t.loginWithQuickSmsOtc="loginWithQuickSmsOtc",t.loginWithOtc="loginWithOtc",t.loginWithPassword="loginWithPassword",t.loginWithTwoFactor="loginWithTwoFactor",t.redirectToSSO="redirectToSSO",t.loginWithSSOFailed="loginWithSSOFailed",t.success="success",t.forceTwoFactor="forceTwoFactor",t.recoverTwoFactor="recoverTwoFactor",t.promptPasskeys="promptPasskeys",t.breachedPassword="breachedPassword",t.breachedPasswordSuccess="breachedPasswordSuccess",t.passwordRotationExpired="passwordRotationExpired",t.passwordRotationNotification="passwordRotationNotification",t.magicLinkPostLoginSuccess="magicLinkPostLoginSuccess"}(yn||(yn={})),function(t){t.Login="login",t.RegisterQuickLogin="registerQuickLogin"}(Sn||(Sn={})),function(t){t.Internal="internal",t.UsbKey="usb-key",t.Android="android",t.Sms="sms"}(vn||(vn={})),function(t){t["social-login"]="social-login",t["custom-social-login"]="custom-social-login",t.direct="direct"}(fn||(fn={}));const mn={[N.Code]:yn.loginWithOtc,[N.EmailAndPassword]:yn.loginWithPassword,[N.MagicLink]:yn.magicLinkPreLoginSuccess,[N.SmsCode]:yn.loginWithSmsOtc},bn={authenticatedUrl:"/",loginUrl:"/account/login",stepUpUrl:"/account/step-up",logoutUrl:"/account/logout",activateUrl:"/account/activate",impersonationUrl:"/account/impersonate",acceptInvitationUrl:"/account/invitation/accept",forgetPasswordUrl:"/account/forget-password",resetPhoneNumberUrl:"/account/reset-phone-number",resetPasswordUrl:"/account/reset-password",socialLoginCallbackUrl:"/account/social/success",signUpUrl:"/account/sign-up",oidcRedirectUrl:"/account/oidc/callback",samlCallbackUrl:"/account/saml/callback",magicLinkCallbackUrl:"/account/login/magic-link",hostedLoginRedirectUrl:"/oauth/callback",openAppUrl:"/account/redirect",unlockAccountUrl:"/account/unlock",activateWithOTCUrl:"/account/activate/code",acceptInvitationWithOTCUrl:"/account/invitation/code",mfaMobileAuthenticator:"/account/mfa-mobile-authenticator"},An="FRONTEGG_AFTER_AUTH_REDIRECT_URL",wn="HOSTED_LOGIN_VERIFIER_KEY",Tn={retryCount:3},En=(t=500)=>new Promise((e=>{setTimeout(e,t)})),In=async(t,e,a,n)=>{let s=0;for(;s<e-1;)try{const i=await t();if(!n||null!==i)return i;if(s++,s>=e)return i;await new Promise((t=>setTimeout(t,a)))}catch(t){if(s++,s>=e)throw t;await new Promise((t=>setTimeout(t,a)))}return await t()},On=async(t,e)=>e?In(t,e.retryCount,e.delay||500,e.shouldRetryWhenNull):t(),Pn=t=>v({},t,{retryConfig:Tn}),kn=t=>(null==t?void 0:t.traceId)||void 0;function _n(t,e){const a=v({},t);return e.forEach((t=>{delete a[t]})),a}function Rn(t){if(null!=t)return function(t){const e=typeof t;return(null==t?void 0:t.constructor)==={}.constructor||"undefined"===e||null===t||"boolean"===e||"number"===e||"string"===e||t instanceof Date||t instanceof RegExp||t instanceof Blob||t instanceof File||t instanceof FileList||t instanceof ArrayBuffer||t instanceof ImageData||t instanceof ImageBitmap||t instanceof Array||t instanceof Map||t instanceof Set}(t)&&void 0!==t.__isProxy}const Un=t=>JSON.parse(JSON.stringify(t)),Cn=(t,e,a)=>{const n=Un(a),s=rn()(t,e);for(const a in s)"__isProxy"!==a&&(a in n?cn()(t,[...e,a],n[a]):cn()(t,[...e,a],void 0))},Ln=t=>Boolean(null==t?void 0:t.statusCode),Dn=t=>t instanceof Error||(null==t?void 0:t.message)&&(null==t?void 0:t.stack)&&"Error"===(null==t?void 0:t.name),Nn=(t,e)=>t?Ln(t)?(console.error(t.message),t):(Dn(t)?console.error(t.message):"string"==typeof t&&console.error(t),null!=e?e:new W(Dt,500,null,Nt)):e,Mn=(t,e,a)=>{const n=e=>{Object.assign(t.auth.acceptInvitationState,e)};return{setAcceptInvitationState:n,resetAcceptInvitationState:()=>{Cn(t,["auth","acceptInvitationState"],nn)},acceptInvitation:async t=>{if(t.token&&t.userId)try{n({error:void 0,step:an.pending}),await e.auth.acceptInvitation(t),n({step:an.success})}catch(t){n({step:an.failed,error:Nn(t)})}else n({error:void 0,step:an.invalid})},acceptInvitationWithOTC:async t=>{if(t.token&&t.userId&&t.code)try{n({error:void 0,step:an.pending}),await e.auth.acceptInvitationWithOTC(t),n({step:an.success})}catch(t){n({step:an.validate,error:Nn(t)})}else n({error:void 0,step:an.invalid})}}},Fn={loading:!1},xn=t=>en(Fn,t),$n=["activeTenant","tenants"],Gn=(t,e,a)=>{const n=e=>{Object.assign(t.auth.accountSettingsState,e)};return{setAccountSettingsState:n,resetAccountSettingsState:()=>{Cn(t,["auth","accountSettingsState"],Fn)},saveAccountSettings:async s=>{try{var i;n({loading:!0});const{address:o,timezone:r,dateFormat:l,timeFormat:c,currency:u,logo:d}=t.auth.accountSettingsState,g=await e.accountSettings.updateSettings(v({address:o,timezone:r,dateFormat:l,timeFormat:c,currency:u,logo:d},s));(({newSettingValues:e})=>{const n=t.auth.tenantsState,{activeTenant:s,tenants:i}=n,o=f(n,$n),r=i.map((t=>t.id!==(null==s?void 0:s.id)?t:v({},t,e))),l=v({},s,e);a.setTenantsState(v({},o,{tenants:r,activeTenant:l}))})({newSettingValues:g}),n(v({},g,{loading:!1})),null==(i=s.callback)||i.call(s,g)}catch(t){var o;n({loading:!1,error:Nn(t)}),null==(o=s.callback)||o.call(s,null,t)}},loadAccountSettings:async t=>{n({loading:!(null!=t&&t.silentLoading),error:null});try{const a=await On((()=>e.accountSettings.getSettings()),null==t?void 0:t.retryConfig);n(v({},a,{loading:!1}))}catch(t){n({loading:!1,error:Nn(t)})}}}};let jn;!function(t){t.activating="activating",t.success="success",t.resend="resend",t.activatingForm="activatingForm"}(jn||(jn={}));const Bn={step:jn.activating,loading:!1,submitting:!1,resentEmail:!1,activationStrategy:{loading:!1}},Vn=t=>en(Bn,t);let Wn,Hn,zn,Kn;!function(t){t.LOAD_FEATURE_FLAGS="LOAD_FEATURE_FLAGS,",t.LOAD_ADMIN_BOX_METADATA="LOAD_ADMIN_BOX_METADATA,",t.LOAD_SSO_PUBLIC_CONFIGURATION="LOAD_SSO_PUBLIC_CONFIGURATION,",t.LOAD_PUBLIC_AUTH_STRATEGIES_POLICY="LOAD_PUBLIC_AUTH_STRATEGIES_POLICY,",t.LOAD_ALLOW_SIGNUPS="LOAD_ALLOW_SIGNUPS,",t.LOAD_CUSTOM_LOGIN_ROUTES="LOAD_CUSTOM_LOGIN_ROUTES",t.LOAD_PASSWORD_CONFIGURATION="LOAD_PASSWORD_CONFIGURATION"}(Wn||(Wn={})),function(t){t.SOCIAL_LOGIN="SOCIAL_LOGIN",t.PASSWORDLESS="PASSWORDLESS",t.ACTIVATION_LINK="ACTIVATION_LINK"}(Hn||(Hn={})),function(t){t.SOCIAL_LOGIN="SOCIAL_LOGIN",t.PASSWORD="PASSWORD",t.PHONE_NUMBER="PHONE_NUMBER"}(zn||(zn={})),function(t){t.profile="profile",t.privacy="privacy",t.personalApiTokens="personalApiTokens",t.account="account",t.users="users",t.groups="groups",t.security="security",t.sso="sso",t.audits="audits",t.webhooks="webhooks",t.apiTokens="apiTokens",t.roles="roles",t.subscriptions="subscription",t.allAccounts="allAccounts"}(Kn||(Kn={}));const qn={profile:Kn.profile,privacy:Kn.privacy,personalApiTokens:Kn.personalApiTokens,account:Kn.account,users:Kn.users,groups:Kn.groups,security:Kn.security,sso:Kn.sso,audits:Kn.audits,webhooks:Kn.webhooks,apiTokens:Kn.apiTokens,roles:Kn.roles,subscriptions:Kn.subscriptions,allAccounts:Kn.allAccounts};let Jn,Yn;function Xn(t,e){var a,n;null==(a=(n=window).onFronteggEvent)||a.call(n,t,e)}!function(t){t.SIGNUP_COMPLETED="signup_completed",t.USER_VERIFIED="user_verified"}(Jn||(Jn={})),function(t){t.verify="verify",t.recoveryCode="recoveryCode",t.authenticatorApp="authenticatorApp",t.smsSetPhoneNumber="smsSetPhoneNumber",t.smsVerifyCode="smsVerifyCode",t.emailVerifyCode="emailVerifyCode",t.noMFAEnrolledStepUp="noMFAEnrolledStepUp"}(Yn||(Yn={}));const Qn=t=>{try{return new URL(t),!0}catch(t){return!1}},Zn=({authenticatedUrl:t,enforceRedirectToSameSite:e,allowedRedirectOrigins:a,includeQueryParam:n})=>{let s=t;const i=new URL(window.location.href).searchParams.get("redirectUrl");return i?e&&Qn(i)?((t,e)=>{const a=new URL(window.location.href),n=new URL(t),s=n.origin===a.origin;return e.includes(n.origin)||s})(i,a)?s=i:console.warn("The redirect url param is not valid, the origin is a different site"):s=i:n&&(s+=window.location.search),s},ts=t=>{const{searchParams:e}=new URL(t),a=e.toString();if(a)return`?${a}`},es=(t,e=!1)=>{const{pathname:a,href:n}=new URL(t);if(e)return n;const s=ts(t);return s?a+s:a},as=t=>{const e=new URLSearchParams(window.location.search).get(t);return null!=e?e:void 0},ns="tenantId",ss=t=>{const e=+Boolean(t.webauthn.length),a=+Boolean(t.phones.length),n=+Boolean(t.authenticators.length),s=+Boolean(t.emails.length);return{numberOfWebAuthnDevices:e,numberOfPhoneDevices:a,numberOfAuthenticators:n,numberOfEmails:s,totalDevices:e+a+n+s}},is=t=>{const{numberOfPhoneDevices:e,numberOfAuthenticators:a,numberOfEmails:n,totalDevices:s}=ss(t);if(1===s){if(a)return Yn.authenticatorApp;if(e)return Yn.smsVerifyCode;if(n)return Yn.emailVerifyCode}return Yn.verify},os=t=>{if(1===t.length){const[e]=t;if(e===Jt.AuthenticatorApp)return Yn.authenticatorApp;if(e===Jt.SMS)return Yn.smsSetPhoneNumber;if(e===Jt.EmailCode)return Yn.emailVerifyCode}return Yn.verify},rs=t=>"/oauth/callback"===t;function ls(t){return"email"in t}const cs=t=>{const e=U.for(t.root.appName).getBasename();return null!=e&&e.endsWith("/")?e.slice(0,-1):e},us=t=>void 0!==t.passwordExpiresIn&&void 0!==t.notificationPeriod&&t.passwordExpiresIn<=t.notificationPeriod,ds=(t,{maxAge:e}={})=>{if(!t)return!1;const{amr:a=[],acr:n="",auth_time:s}=t;if(e&&s&&!(Date.now()/1e3-s<=e))return!1;const i=n===un,o=-1!==a.indexOf(dn),r=void 0!==gn.find((t=>a.indexOf(t)));return i&&o&&r};function gs(){const t=window.location.pathname+window.location.search;window.localStorage.setItem(An,t)}const ps=(t,e,a)=>{gs();const n=new URLSearchParams(window.location.search);a&&n.set(hn,a.toString()),e(`${t}${n?`?${n}`:""}`,{refresh:!1})},hs=["phoneNumber","email"],ys=["authenticatedUrl"],Ss=(t,e)=>{const a=U.for(e);return t.mfaRequired&&t.mfaToken?(a.setAccessToken(null),a.setUser(null),!0):(a.setAccessToken(t.accessToken),a.setUser(t),!1)},vs=(t,e)=>{const a=U.for(e);return t.resetPasswordToken?(a.setAccessToken(null),!0):(a.setAccessToken(t.accessToken),a.setUser(t),!1)},fs=(t,e=[])=>Object.entries(t).reduce(((t,[a,n])=>"object"==typeof n?[...t,...fs(n,[...e,a])]:[...t,{type:[...e,a].join("/"),payload:n}]),[]),ms=t=>{var e;if("path"===t)return(null!=(e=window)?e:document).location.pathname;{var a;const t=((null!=(a=window)?a:document).location.hash||"#").substring(1);return-1!==t.indexOf("?")?t.substring(0,t.indexOf("?")):t}},bs=t=>{const{phoneNumber:e,email:a}=t,n=f(t,hs);return null!=a&&a.length&&Object.assign(n,{email:a}),null!=e&&e.length&&Object.assign(n,{phoneNumber:e}),n},As=(t,e)=>{const a=f(v({},bn,e),ys);return Object.values(a).includes(t)};let ws;!function(t){t.USERS="USERS",t.STATS="STATS",t.UPDATE_USER="UPDATE_USER",t.DELETE_USER="DELETE_USER",t.RESEND_ACTIVATE_LINK="RESEND_ACTIVATE_LINK",t.RESEND_INVITATION_LINK="RESEND_INVITATION_LINK",t.ROLES_AND_PERMISSIONS="ROLES_AND_PERMISSIONS",t.CREATE_TOKEN_LINK="CREATE_TOKEN_LINK",t.GET_TOKEN_LINK="GET_TOKEN_LINK",t.UPDATE_TOKEN_LINK="UPDATE_TOKEN_LINK",t.DELETE_TOKEN_LINK="DELETE_TOKEN_LINK",t.CONFIG_TOKEN_LINK="CONFIG_TOKEN_LINK",t.CONFIG_TEMPORARY_USERS="CONFIG_TEMPORARY_USERS",t.UPDATE_USER_EXPIRATION_TIME="UPDATE_USER_EXPIRATION_TIME"}(ws||(ws={}));const Ts=["user"],Es=["callback","events"],Is=["user"],Os=["callback","events"],Ps=["user"],ks=["callback"],_s=["callback"],Rs=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.activateAccountState,e)},i=()=>{Cn(t,["auth","activateAccountState"],Bn)},o=e=>{Object.assign(t.auth.activateAccountState.activationStrategy,e)},r=async({loginResponse:e,events:a,onRedirectTo:o,routes:r})=>{const{user:l}=e,c=f(e,Ts);if(l.redirectLocation)window.location.href=l.redirectLocation;else if(Ss(l,t.root.appName)){s({step:jn.success});const t=await n.getMfaRequiredState(l);n.setAuthState(t),await En(1e3),o(r.loginUrl,{preserveQueryParams:!0})}else{var u;s({step:jn.success});const t={email:l.email,origin:Hn.ACTIVATION_LINK,id:l.id,tenantId:l.tenantId,name:l.name,createdAt:new Date};null==a||null==(u=a.userVerified)||u.call(a,t),Xn(Jn.USER_VERIFIED,t),n.afterAuthenticationStateUpdate(v({user:l},c),{isAuthenticated:!0}),await En(5e3),await n.afterAuthNavigation(),i()}};return{setActivateState:s,resetActivateState:i,setActivateStrategyState:o,activateAccount:async a=>{const{callback:n,events:i}=a,o=f(a,Es);s({loading:!0,submitting:!0});try{const a=U.for(t.root.appName).onRedirectTo,l=t.auth.routes,c=await e.auth.activateAccountV2(o),{user:u}=c,d=f(c,Is);s({submitting:!1}),await r({loginResponse:v({user:u},d),events:i,onRedirectTo:a,routes:l}),null==n||n(!0)}catch(t){s({loading:!1,error:Nn(t)})}},preActivateAccount:async a=>{const{userId:i,token:r}=a;s({loading:!0,step:jn.activating});try{t.auth.isAuthenticated&&await n.silentLogout();const a=await e.auth.getActivateAccountStrategy({userId:i,token:r});o({strategy:a,loading:!1,error:void 0}),a.shouldSetPassword&&s({loading:!1,step:jn.activatingForm})}catch(t){s({loading:!1,error:Nn(t)})}},getActivateAccountStrategy:async t=>{const{callback:a}=t,n=f(t,ks);o({loading:!0});try{const t=await e.auth.getActivateAccountStrategy(n);o({strategy:t,loading:!1,error:void 0}),null==a||a(t)}catch(t){o({loading:!1,error:Nn(t)})}},resendActivationEmail:async t=>{const{callback:a}=t,i=f(t,_s);n.setTeamLoader({key:ws.RESEND_ACTIVATE_LINK,value:i.email}),s({loading:!0});try{await e.auth.resendActivationEmail(i),s({loading:!1,error:void 0,resentEmail:!0}),null==a||a(!0)}catch(t){s({loading:!1,error:Nn(t)}),null==a||a(null,t)}finally{n.setTeamLoader({key:ws.RESEND_ACTIVATE_LINK,value:!1})}},activateAccountWithCode:async a=>{const{callback:n,events:i}=a,o=f(a,Os);s({loading:!0,submitting:!0});try{const a=U.for(t.root.appName).onRedirectTo,l=t.auth.routes,c=await e.auth.activateAccountWithOTC(o),{user:u}=c,d=f(c,Ps);s({submitting:!1}),await r({loginResponse:v({user:u},d),events:i,onRedirectTo:a,routes:l}),null==n||n(!0)}catch(t){s({submitting:!1,loading:!1,error:Nn(t),step:jn.activating})}}}},Us={loading:!1,error:void 0,unlockAccountSuccess:!1},Cs=t=>en(Us,t),Ls=(t,e,a)=>{const n=e=>{Object.assign(t.auth.unlockAccountState,e)};return{setUnlockAccountState:n,resetUnlockAccountState:()=>{Cn(t,["auth","activateAccountState"],Us)},unlockAccount:async a=>{const{token:s}=a,i=U.for(t.root.appName).onRedirectTo,o=t.auth.routes;n({loading:!0});try{await e.users.unlockMe({token:s}),n({loading:!1,error:void 0,unlockAccountSuccess:!0}),await En(5e3),i(o.loginUrl)}catch(t){n({loading:!1,error:Nn(t)})}}}},Ds={apiTokenType:null,searchValue:"",showAddTokenDialog:!1,createdByUserIdColumn:"show",deleteTokenDialog:{open:!1,clientId:""},successDialog:{open:!1,secret:"",clientId:""},loaders:{},apiTokensDataTenant:[],apiTokensDataUser:[],roles:[],permissions:[],errors:{}},Ns=t=>en(Ds,t);let Ms;!function(t){t.LOAD_API_TOKENS="LOAD_API_TOKENS",t.ADD_API_TOKEN="ADD_API_TOKEN",t.DELETE_API_TOKEN="DELETE_API_TOKEN"}(Ms||(Ms={}));const Fs=(t,e,a)=>{const n=e=>{Object.assign(t.auth.apiTokensState,{loaders:v({},t.auth.apiTokensState.loaders,{[e.key]:e.value})})},s=e=>{Object.assign(t.auth.apiTokensState,{errors:v({},t.auth.apiTokensState.errors,{[e.key]:e.value}),loaders:v({},t.auth.apiTokensState.loaders,{[e.key]:!1})})},i=e=>{Object.assign(t.auth.apiTokensState,e)};return{setApiTokensLoader:n,setApiTokensError:s,setApiTokensState:i,resetApiTokensState:()=>{Cn(t,["auth","apiTokensState"],Ds)},loadApiTokens:async t=>{null!=t&&t.silentLoading||n({key:Ms.LOAD_API_TOKENS,value:!0});try{var a;const[s=[],o=[]]=await Promise.all([e.auth.getUserApiTokensData(),e.auth.getTenantApiTokensData()]);i({apiTokensDataUser:s,apiTokensDataTenant:o}),n({key:Ms.LOAD_API_TOKENS,value:!1}),null==t||null==(a=t.callback)||a.call(t,!0)}catch(e){var o;s({key:Ms.LOAD_API_TOKENS,value:Nn(e)}),n({key:Ms.LOAD_API_TOKENS,value:!1}),null==t||null==(o=t.callback)||o.call(t,null,e)}},loadUserApiTokens:async t=>{null!=t&&t.silentLoading||n({key:Ms.LOAD_API_TOKENS,value:!0});try{var a,o;const[s=[],r]=await Promise.all([On((()=>e.auth.getUserApiTokensData()),null==t?void 0:t.retryConfig),On((()=>e.auth.getUserAccessTokensData()),null==t?void 0:t.retryConfig)]),l=(null!=(a=r.accessTokens)?a:[]).map((t=>v({},t,{type:M.AccessToken}))).concat(s.map((t=>v({},t,{type:M.ClientCredentials})))).sort(((t,e)=>new Date(e.createdAt)-new Date(t.createdAt)));i({apiTokensDataUser:null!=l?l:[]}),n({key:Ms.LOAD_API_TOKENS,value:!1}),null==t||null==(o=t.callback)||o.call(t,!0)}catch(e){var r;s({key:Ms.LOAD_API_TOKENS,value:Nn(e)}),n({key:Ms.LOAD_API_TOKENS,value:!1}),null==t||null==(r=t.callback)||r.call(t,null,e)}},loadTenantApiTokens:async t=>{null!=t&&t.silentLoading||n({key:Ms.LOAD_API_TOKENS,value:!0});try{var a,o;const[s=[],r]=await Promise.all([On((()=>e.auth.getTenantApiTokensData()),null==t?void 0:t.retryConfig),On((()=>e.auth.getTenantAccessTokensData()),null==t?void 0:t.retryConfig)]),l=(null!=(a=null==r?void 0:r.accessTokens)?a:[]).map((t=>v({},t,{type:M.AccessToken}))).concat(s.map((t=>v({},t,{type:M.ClientCredentials})))).sort(((t,e)=>new Date(e.createdAt)-new Date(t.createdAt)));i({apiTokensDataTenant:null!=l?l:[]}),n({key:Ms.LOAD_API_TOKENS,value:!1}),null==t||null==(o=t.callback)||o.call(t,!0)}catch(e){var r;s({key:Ms.LOAD_API_TOKENS,value:Nn(e)}),n({key:Ms.LOAD_API_TOKENS,value:!1}),null==t||null==(r=t.callback)||r.call(t,null,e)}},addTenantApiToken:async a=>{const{description:o,roleIds:r,expires:l,callback:c}=a,u=Ms.ADD_API_TOKEN;n({key:u,value:!0});try{const{policy:a}=t.auth.securityPolicyState.publicPolicy,n=(null==a?void 0:a.machineToMachineAuthStrategy)===M.AccessToken;let s,u=null;l&&(u=1440*l),s=n?await e.auth.createTenantAccessToken({description:o,expiresInMinutes:u,roleIds:r}):await e.auth.updateTenantApiTokensData({description:o,roleIds:r,expiresInMinutes:u}),i({showAddTokenDialog:!1}),await En(200);const d=n?M.AccessToken:M.ClientCredentials;t.auth.apiTokensState.apiTokensDataTenant.unshift(v({},s,{type:d})),t.auth.apiTokensState.successDialog={open:!0,secret:s.secret,clientId:n?void 0:s.clientId},null==c||c(null)}catch(t){s({key:u,value:Nn(t)}),null==c||c(null,t)}finally{n({key:u,value:!1})}},addUserApiToken:async a=>{const{description:o,expires:r,callback:l}=a,c=Ms.ADD_API_TOKEN;n({key:c,value:!0});try{const{policy:a}=t.auth.securityPolicyState.publicPolicy,n=(null==a?void 0:a.machineToMachineAuthStrategy)===M.AccessToken;let s,c=null;r&&(c=1440*r),s=n?await e.auth.createUserAccessToken({description:o,expiresInMinutes:c}):await e.auth.updateUserApiTokensData({description:o,expiresInMinutes:c}),i({showAddTokenDialog:!1}),await En(200);const u=n?M.AccessToken:M.ClientCredentials;t.auth.apiTokensState.apiTokensDataUser.unshift(v({},s,{type:u})),t.auth.apiTokensState.successDialog={open:!0,secret:s.secret,clientId:n?void 0:s.clientId},null==l||l(null)}catch(t){s({key:c,value:Nn(t)}),null==l||l(null,t)}finally{n({key:c,value:!1})}},deleteUserApiToken:async a=>{const o=Ms.DELETE_API_TOKEN;n({key:o,value:!0});try{const n=t.auth.apiTokensState.apiTokensDataUser;n.some((t=>t.id===a))?(await e.auth.deleteUserAccessToken({id:a}),i({apiTokensDataUser:n.filter((t=>t.id!==a)),deleteTokenDialog:{open:!1,id:a}})):(await e.auth.deleteUserApiToken({tokenId:a}),i({apiTokensDataUser:n.filter((t=>t.clientId!==a)),deleteTokenDialog:{open:!1,clientId:a}}))}catch(t){s({key:o,value:Nn(t)})}finally{n({key:o,value:!1})}},deleteTenantApiToken:async a=>{const o=Ms.DELETE_API_TOKEN;n({key:o,value:!0});try{const n=t.auth.apiTokensState.apiTokensDataTenant;n.some((t=>t.id===a))?(await e.auth.deleteTenantAccessToken({id:a}),i({apiTokensDataTenant:n.filter((t=>t.id!==a)),deleteTokenDialog:{open:!1,id:a}})):(await e.auth.deleteTenantApiToken({tokenId:a}),i({apiTokensDataTenant:n.filter((t=>t.clientId!==a)),deleteTokenDialog:{open:!1,id:a}}))}catch(t){s({key:o,value:Nn(t)})}finally{n({key:o,value:!1})}}}},xs={loading:!0,fetching:!0,error:null,userApplications:[],accountApplications:[]},$s=t=>en(xs,t),Gs=t=>{var e;return null!=(e=t.map((({appIds:t})=>t)).reduce(((t,e)=>(null==e||e.forEach((e=>{t&&!t.includes(e)&&t.push(e)})),t)),[]))?e:[]},js=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.applicationsState,e)},i=async({userIds:t,retryConfig:a})=>{try{const n=await On((()=>e.applications.getUsersApplicationsId({userIds:t})),a),s=Gs(n),i=await On((()=>e.applications.getApplicationsData({appIds:s})),a);return t.reduce(((t,e)=>{var a,s,o;const r=null==(a=n.find((t=>t.userId==e)))?void 0:a.appIds;return t[e]=[...i.filter((t=>t.accessType===Ja.FREE_ACCESS)),...null!=(s=null==r||null==(o=r.map((t=>i.find((e=>t===e.id)))))?void 0:o.filter((t=>!!t)))?s:[]],t}),{})}catch(t){s({error:Nn(t)})}},o="Assignment action failed. Try again or contact support.";return{setApplicationsState:s,resetApplicationsState:()=>{Cn(t,["auth","applicationsState"],xs)},loadUserApplications:async a=>{s({loading:!0,fetching:!0});try{var n,i;const o=null!=(n=null==(i=t.auth.user)?void 0:i.id)?n:"",r=null==a?void 0:a.retryConfig,l=await On((()=>e.applications.getUserApplicationsId({userId:o})),r),c=await On((()=>e.applications.getApplicationsData({appIds:l})),r);s({userApplications:c,fetching:!1,loading:!1})}catch(t){s({loading:!1,fetching:!1,error:Nn(t)})}},loadAccountApplications:async t=>{const a=null==t?void 0:t.retryConfig;s({loading:!0,fetching:!0});try{const t=await On((()=>e.applications.getTenantsApplications()),a),n=Gs(t),i=await On((()=>e.applications.getApplicationsData({appIds:n})),a),o=await On((()=>e.applications.getUsersOfApplications({appIds:n})),a),r=i.map((t=>{var e;return v({},t,{userIds:null==(e=o.find((e=>e.appId===t.id)))?void 0:e.userIds})}));s({accountApplications:r,fetching:!1,loading:!1})}catch(t){s({loading:!1,fetching:!1,error:Nn(t)})}},loadMultipleUsersApplications:i,assignUserToApps:async n=>{const{userId:i,appIds:r,callback:l}=n;try{var c,u,d,g,p,h,y,S,f;const n=null!=(c=null==(u=t.auth)||null==(d=u.user)?void 0:d.tenantId)?c:"";await e.applications.assignUserToApplications({userId:i,appIds:r,tenantId:n});const s=null==(g=t.auth)||null==(p=g.applicationsState)?void 0:p.accountApplications,o=null!=(h=null==(y=t.auth)||null==(S=y.teamState)?void 0:S.users)?h:[],m=null!=(f=null==s?void 0:s.filter((t=>r.includes(t.id))))?f:[];null!=m&&m.length&&a.setTeamState({users:o.map((t=>{var e;return t.id===i?v({},t,{applications:[...null!=(e=t.applications)?e:[],...m]}):t}))}),null==l||l(!0)}catch(t){s({error:Nn(t,o)}),null==l||l(!1)}},unassignUserFromApps:async n=>{const{userId:i,appIds:r,callback:l}=n;try{var c,u,d,g,p,h,y;const n=null!=(c=null==(u=t.auth)||null==(d=u.user)?void 0:d.tenantId)?c:"";await e.applications.unassignUserFromApplications({userId:i,appIds:r,tenantId:n});const s=null!=(g=null==(p=t.auth)||null==(h=p.teamState)?void 0:h.users)?g:[],o=null==(y=s.find((t=>t.id===i)))?void 0:y.applications;null!=o&&o.length&&r.length&&a.setTeamState({users:s.map((t=>t.id===i?v({},t,{applications:o.filter((t=>!r.includes(t.id)))}):t))}),null==l||l(!0)}catch(t){s({error:Nn(t,o)}),null==l||l(!1)}},assignNewUserToApps:async({appIds:a,user:s})=>{var i,o,r;const[l]=await n.getFeatureFlags(["multi-apps-admin-portal"]);if(!l)return;const c=null==(i=t.auth)||null==(o=i.applicationsState)?void 0:o.accountApplications,u=null!=(r=null==c?void 0:c.filter((t=>t.accessType===Ja.FREE_ACCESS)))?r:[];if(null!=a&&a.length){var d,g,p;const n=null!=(d=null==(g=t.auth)||null==(p=g.user)?void 0:p.tenantId)?d:"";return await e.applications.assignUserToApplications({userId:s.id,appIds:a,tenantId:n}),a.map((t=>{var e;return null!=(e=null==c?void 0:c.find((e=>e.id===t)))?e:[]})).concat(u)}return u},mapUsersWithApplicationData:async({shouldLoadApps:t,users:e,retryConfig:n})=>{const[s]=await a.getFeatureFlags(["multi-apps-admin-portal"]);if(!s||!t)return e;const o=e.map((t=>t.id)),r=await i({userIds:o,retryConfig:n});return r?e.map((t=>null!=r&&r[t.id]?v({},t,{applications:r[t.id]}):t)):e}}},Bs={loading:!0,error:null},Vs=t=>en(Bs,t),Ws=["callback"],Hs=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.customLoginState,e)},i=async()=>{var e,a,n,s,i;return t.auth.isAuthenticated?null!=(s=null==(i=t.auth.tenantsState.activeTenant)?void 0:i.hasCustomLogin)&&s:!!(null==(e=await(null==(a=U.for(t.root.appName).getContext())||null==(n=a.tenantResolver)?void 0:n.call(a)))?void 0:e.tenant)};return{setCustomLoginState:s,resetCustomLoginState:()=>{Cn(t,["auth","customLoginState"],Bs)},loadTenantMetadata:async()=>{s({loading:!0});try{const t=await e.metadata.getAdminBoxMetadata();s({tenantMetadata:t,loading:!1})}catch(t){s({loading:!1,error:Nn(t)})}},updateTenantMetadata:async t=>{const{callback:a}=t,n=f(t,Ws);try{s({error:null,saving:!0});const t=fs(n);if(0===t.length)throw new Error("No changes to update");await e.metadata.updateAdminBoxMetadata({actions:t});const i=await e.metadata.getAdminBoxMetadata();s({tenantMetadata:i,saving:!1}),null==a||a(!0)}catch(t){s({error:Nn(t,"No changes to update"),saving:!1}),null==a||a(null,t)}},customLoginEnabled:i,loadCustomLoginRoutes:async a=>{try{var o,r,l;if(!await i())return void(null==a||null==(l=a.callback)||l.call(a,!0));const u=t.auth.isAuthenticated,{getSettings:d,getPublicSettings:g}=e.accountSettings,{applicationUrl:p}=await On(u?d:g,null==a?void 0:a.retryConfig);var c;if(!p)return void(null==a||null==(c=a.callback)||c.call(a,!0));const h=t.auth.routes,y=null!=(o=ts(p))?o:"";n.setAuthState({routes:v({},h,{customLoginAuthenticatedUrl:p,customLoginUrl:h.loginUrl+y})}),s({customLoginSearchParams:null!=y?y:void 0}),null==a||null==(r=a.callback)||r.call(a,!0)}catch(t){var u;null==a||null==(u=a.callback)||u.call(a,null,t)}}}};let zs;!function(t){t.forgotPassword="forgotPassword",t.success="success"}(zs||(zs={}));const Ks={step:zs.forgotPassword,loading:!1,email:"",passwordConfig:null},qs=t=>en(Ks,t),Js=["callback"],Ys=(t,e,a)=>{const n=e=>{Object.assign(t.auth.forgotPasswordState,e)};return{setForgotPasswordState:n,resetForgotPasswordState:()=>{Cn(t,["auth","forgotPasswordState"],Ks)},forgotPassword:async t=>{n({loading:!0});try{var a;await e.auth.forgotPassword(t),n({loading:!1,error:void 0,step:zs.success}),null==(a=t.callback)||a.call(t,!0)}catch(e){var s;n({loading:!1,error:Nn(e,"Unknown error occurred")}),null==(s=t.callback)||s.call(t,!1,e)}},resetPassword:async t=>{const{callback:a}=t,s=f(t,Js);n({loading:!0});try{await e.auth.resetPassword(s),n({loading:!1,error:void 0,step:zs.success}),null==a||a(!0)}catch(t){n({loading:!1,error:Nn(t)}),null==a||a(!1,t)}},loadPasswordConfig:async t=>{n({loading:!0});try{const a=await e.auth.loadPasswordConfig(t);n({loading:!1,passwordConfig:a})}catch(t){n({loading:!1,error:Nn(t)})}}}};let Xs;!function(t){t.success="success",t.notification="notification"}(Xs||(Xs={}));const Qs={step:Xs.notification},Zs=t=>en(Qs,t),ti=(t,e,a)=>({setStep:e=>{var a;a={step:e},Object.assign(t.auth.passwordRotationState,a)}}),ei={loaders:{},errors:{},groups:[],groupsConfiguration:{}},ai=t=>en(ei,t);let ni,si;!function(t){t.CREATE_GROUP="CREATE_GROUP",t.GET_GROUP="GET_GROUP",t.GET_GROUPS="GET_GROUPS",t.DELETE_GROUP="DELETE_GROUP",t.UPDATE_GROUP="UPDATE_GROUP",t.ADD_USERS_TO_GROUP="ADD_USERS_TO_GROUP",t.DELETE_USERS_FROM_GROUP="DELETE_USERS_FROM_GROUP",t.ADD_ROLES_TO_GROUP="ADD_ROLES_TO_GROUP",t.DELETE_ROLES_FROM_GROUP="DELETE_ROLES_FROM_GROUP",t.GET_GROUP_CONFIGURATION="GET_GROUP_CONFIGURATION",t.UPDATE_GROUP_CONFIGURATION="UPDATE_GROUP_CONFIGURATION",t.GET_TEAM_USERS="GET_TEAM_USERS"}(ni||(ni={})),function(t){t.roles="roles",t.users="users",t.rolesAndUsers="rolesAndUsers"}(si||(si={}));const ii=["roleIds","userIds"],oi=(t,e,a)=>{const n=e=>{Object.assign(t.auth.groupsState,{loaders:v({},t.auth.groupsState.loaders,{[e.key]:e.value})})},s=e=>{Object.assign(t.auth.groupsState,{errors:v({},t.auth.groupsState.errors,{[e.key]:e.value}),loaders:v({},t.auth.groupsState.loaders,{[e.key]:!1})})},i=e=>{Object.assign(t.auth.groupsState,e)},o=async a=>{const o=ni.GET_GROUPS,r=t.auth.groupsState;n({key:o,value:!0});try{const{groups:t}=await On((()=>e.groups.getGroups({_groupsRelations:si.rolesAndUsers})),null==a?void 0:a.retryConfig);i(v({groups:t},r.selectedGroup&&{selectedGroup:t.find((t=>{var e;return t.id===(null==(e=r.selectedGroup)?void 0:e.id)}))}))}catch(t){s({key:o,value:Nn(t)})}finally{n({key:o,value:!1})}},r=async t=>{const a=ni.ADD_ROLES_TO_GROUP;n({key:a,value:!0});try{var i;await e.groups.addRolesToGroup(t.groupId,{roleIds:t.roleIds}),await o(),null==t||null==(i=t.callback)||i.call(t,!0)}catch(e){var r;s({key:a,value:Nn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},l=async t=>{const a=ni.ADD_USERS_TO_GROUP;n({key:a,value:!0});try{var i;await e.groups.addUsersToGroup(t.groupId,{userIds:t.userIds}),await o(),null==t||null==(i=t.callback)||i.call(t,!0)}catch(e){var r;null==t||null==(r=t.callback)||r.call(t,!1),s({key:a,value:Nn(e)})}finally{n({key:a,value:!1})}},c=async t=>{const a=ni.GET_GROUP_CONFIGURATION;n({key:a,value:!0});try{const a=await On((()=>e.groups.getGroupConfiguration()),null==t?void 0:t.retryConfig);i({groupsConfiguration:a})}catch(t){s({key:a,value:Nn(t)})}finally{n({key:a,value:!1})}};return{setUsersGroupsLoader:n,setUsersGroupsError:s,setGroupsState:i,resetUsersGroupsState:()=>{Cn(t,["auth","groupsState"],ei)},loadGroups:o,getGroupById:async t=>{const a=ni.GET_GROUP;n({key:a,value:!0});try{const a=await e.groups.getGroupById({groupId:t.groupId},{_groupsRelations:si.rolesAndUsers});i({selectedGroup:a})}catch(t){s({key:a,value:Nn(t)})}finally{n({key:a,value:!1})}},createGroup:async t=>{const a=ni.CREATE_GROUP,{roleIds:i,userIds:c}=t,u=f(t,ii);n({key:a,value:!0});try{var d;const a=await e.groups.createGroup(v({name:u.name},!!u.description&&{description:u.description},{color:u.color}));null!=c&&c.length&&l({groupId:a.id,userIds:c}),null!=i&&i.length&&r({groupId:a.id,roleIds:i}),await o(),null==t||null==(d=t.callback)||d.call(t,!0)}catch(e){var g;s({key:a,value:Nn(e)}),null==t||null==(g=t.callback)||g.call(t,!1)}finally{n({key:a,value:!1})}},updateGroup:async t=>{const a=ni.UPDATE_GROUP;n({key:a,value:!0});try{var i;await e.groups.updateGroup(t),await o(),null==t||null==(i=t.callback)||i.call(t,!0)}catch(e){var r;s({key:a,value:Nn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},deleteGroup:async t=>{const a=ni.DELETE_GROUP;n({key:a,value:!0});try{var i;await e.groups.deleteGroup(t.groupId),await o(),null==t||null==(i=t.callback)||i.call(t,!0)}catch(e){var r;s({key:a,value:Nn(e)}),null==t||null==(r=t.callback)||r.call(t,!1,e)}finally{n({key:a,value:!1})}},addRolesToGroup:r,deleteRolesFromGroup:async t=>{const a=ni.DELETE_ROLES_FROM_GROUP;n({key:a,value:!0});try{var i;await e.groups.deleteRolesFromGroup(t.groupId,{roleIds:t.roleIds}),await o(),null==t||null==(i=t.callback)||i.call(t,!0)}catch(e){var r;s({key:a,value:Nn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},addUsersToGroup:l,deleteUsersFromGroup:async t=>{const a=ni.DELETE_USERS_FROM_GROUP;n({key:a,value:!0});try{var i;await e.groups.deleteUsersFromGroup(t.groupId,{userIds:t.userIds}),await o(),null==t||null==(i=t.callback)||i.call(t,!0)}catch(e){var r;s({key:a,value:Nn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},getGroupConfiguration:c,updateGroupConfiguration:async t=>{const a=ni.UPDATE_GROUP_CONFIGURATION;n({key:a,value:!0});try{await e.groups.updateGroupConfiguration(t),await c()}catch(t){s({key:a,value:Nn(t)})}finally{n({key:a,value:!1})}},getTeamUsers:async t=>{const a=ni.GET_TEAM_USERS;n({key:a,value:!0});try{const{items:a}=await e.users.getUsersV2({_filter:t.filter,_offset:t.pageOffset,_limit:t.pageSize,_includeSubTenants:!1});i({teamUsers:a})}catch(t){s({key:a,value:Nn(t)})}finally{n({key:a,value:!1})}}}},ri={addGroupDialogState:{loading:!1,open:!1},editGroupDialogState:{loading:!1,open:!1},deleteGroupDialogState:{loading:!1,open:!1},addMembersToGroupDialogState:{loading:!1,open:!1,userIds:[]},deleteMemberFromGroupDialogState:{loading:!1,open:!1}},li=t=>en(ri,t),ci=(t,e,a)=>({setGroupsDialogsState:e=>{Object.assign(t.auth.groupsDialogsState,e)},resetGroupsDialogsState:()=>{Cn(t,["auth","groupsDialogsState"],ri)},openAddGroupDialog:()=>{t.auth.groupsDialogsState.addGroupDialogState.open=!0},closeAddGroupDialog:()=>{Object.assign(t.auth.groupsDialogsState.addGroupDialogState,{open:!1,group:void 0})},openAddMembersToGroupDialog:()=>{t.auth.groupsDialogsState.addMembersToGroupDialogState.open=!0},closeAddMembersToGroupDialog:()=>{Object.assign(t.auth.groupsDialogsState.addMembersToGroupDialogState,{open:!1,userIds:[]})},openEditGroupDialog:e=>{Object.assign(t.auth.groupsDialogsState.editGroupDialogState,v({},e,{open:!0}))},closeEditGroupDialog:()=>{Object.assign(t.auth.groupsDialogsState.editGroupDialogState,{open:!1,loading:!1,group:void 0})},openDeleteGroupDialog:e=>{Object.assign(t.auth.groupsDialogsState.deleteGroupDialogState,v({},e,{open:!0}))},closeDeleteGroupDialog:()=>{Object.assign(t.auth.groupsDialogsState.deleteGroupDialogState,{open:!1,loading:!1,group:void 0})},openDeleteMemberFromGroupDialog:e=>{Object.assign(t.auth.groupsDialogsState.deleteMemberFromGroupDialogState,e)},closeDeleteMemberFromGroupDialog:()=>{Object.assign(t.auth.groupsDialogsState.deleteMemberFromGroupDialogState,{open:!1,userId:void 0,email:void 0})}});let ui;!function(t){t.impersonating="impersonating",t.success="success"}(ui||(ui={}));const di={step:ui.impersonating,loading:!1},gi=t=>en(di,t),pi=["callback","events"],hi=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.impersonateState,e)},i=()=>{Cn(t,["auth","impersonateState"],di)};return{setImpersonateState:s,resetImpersonateState:i,impersonate:async t=>{const{callback:a}=t,o=f(t,pi);s({loading:!0});try{await e.impersonate.impersonate(o),s({step:ui.success}),await En(1e3),await n.afterAuthNavigation({preventRedirectUrlOriginCleaning:!0}),i(),null==a||a(!0)}catch(t){s({loading:!1,error:Nn(t)})}}}},yi={flow:Sn.Login,step:yn.preLogin,loading:!1,email:"",tenants:[]},Si=t=>en(yi,t),vi=(t,e,a)=>{const n=a;const s=async(e,a={})=>{const{customLoginAuthenticatedUrl:n,forceStepUpUrl:s,shouldStepUpDuringLogin:i,preventRedirectUrlOriginCleaning:o=!1}=a,r=t.auth.onRedirectTo;let l;if(s)l=s;else{var c;if(i){const t=window.localStorage.getItem(An);t&&!Qn(t)&&(l=t)}l||(l=await async function({customLoginAuthenticatedUrl:e,preventRedirectUrlOriginCleaning:a}){const{routes:n,includeQueryParam:s=!1,enforceRedirectToSameSite:i=!1,allowedRedirectOrigins:o=[]}=t.auth,r=window.localStorage.getItem(An);if(e&&!r)return es(e,a);const{authenticatedUrl:l,loginUrl:c,logoutUrl:u,socialLoginCallbackUrl:d,activateUrl:g,activateWithOTCUrl:p}=n;let h=r;h&&![c,u,d,g,p].includes(h)||(h=l);const y=Zn({authenticatedUrl:h,includeQueryParam:s,enforceRedirectToSameSite:i,allowedRedirectOrigins:o});return a?y:(S=y).startsWith(null==(v=window)?void 0:v.location.origin)?S.replace(null==(f=window)?void 0:f.location.origin,""):S;var S,v,f}({customLoginAuthenticatedUrl:n,preventRedirectUrlOriginCleaning:o})),null==(c=window)||c.localStorage.removeItem(An)}await En(200),await e(),r(l,{refresh:l.startsWith("http")})};return{afterAuthNavigationUtil:s,afterAuthNavigation:async e=>{var a,i;const{customLoginAuthenticatedUrl:o,stepUpUrl:r}=t.auth.routes,l=null==(a=window)?void 0:a.localStorage.getItem(pn),c=t.auth.user;var u;if(l&&(null==(u=window)||u.localStorage.removeItem(pn)),r&&l&&!ds(c))return s(n.resetLoginState,{forceStepUpUrl:r});let d=o;var g;return o||(await n.loadCustomLoginRoutes(),d=null==(g=t.auth.routes)?void 0:g.customLoginAuthenticatedUrl),s(n.resetLoginState,{customLoginAuthenticatedUrl:d,shouldStepUpDuringLogin:!!l,preventRedirectUrlOriginCleaning:null!=(i=null==e?void 0:e.preventRedirectUrlOriginCleaning)&&i})},afterStepUpAuthNavigation:async()=>s(n.resetStepUpState),afterAuthenticationStateUpdate:function({user:e,tenants:a=[],activeTenant:s},i={}){const o=t.auth.tenantsState;n.setAuthState(v({user:e,tenantsState:v({},o,{tenants:a,activeTenant:s,loading:!1})},i))}}},fi=["callback"],mi=["callback"],bi=["callback"],Ai=["callback","deviceId"],wi=["callback","deviceId"],Ti="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",Ei=new Uint8Array(256);for(let t=0;t<64;t++)Ei[Ti.charCodeAt(t)]=t;const Ii=t=>{const e=new Uint8Array(t),a=e.length;let n,s="";for(n=0;n<a;n+=3)s+=Ti[e[n]>>2],s+=Ti[(3&e[n])<<4|e[n+1]>>4],s+=Ti[(15&e[n+1])<<2|e[n+2]>>6],s+=Ti[63&e[n+2]];return a%3==2?s=s.substring(0,s.length-1):a%3==1&&(s=s.substring(0,s.length-2)),s},Oi=t=>{const e=.75*t.length,a=t.length;let n,s,i,o,r,l=0;const c=new Uint8Array(e);for(n=0;n<a;n+=4)s=Ei[t.charCodeAt(n)],i=Ei[t.charCodeAt(n+1)],o=Ei[t.charCodeAt(n+2)],r=Ei[t.charCodeAt(n+3)],c[l++]=s<<2|i>>4,c[l++]=(15&i)<<4|o>>2,c[l++]=(3&o)<<6|63&r;return c.buffer};function Pi(t,e="file"){const a=t.match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/);if(null==a)return null;const n=`image/${a[1]}`,s=((t,e)=>{const a=atob(t),n=[];for(let t=0;t<a.length;t+=512){const e=a.slice(t,t+512),s=new Array(e.length);for(let t=0;t<e.length;t++)s[t]=e.charCodeAt(t);n.push(new Uint8Array(s))}return new Blob(n,{type:e})})(a[2],n),i=new FormData;return i.append(e,new File([s],e,{type:n})),i}const ki=t=>{if(t instanceof Array){const e=[];for(const a of t)e.push(ki(a));return e}if(t instanceof ArrayBuffer)return Ii(t);if(t instanceof Object){const e={};for(const a in t)e[a]=ki(t[a]);return e}return t},_i=t=>new Promise(((e,a)=>{const n=new FileReader;n.readAsText(t),n.onload=()=>e(n.result),n.onerror=a})),Ri=["callback","deviceId"],Ui=["callback","deviceId"],Ci="input is invalid type",Li="undefined"!=typeof ArrayBuffer,Di="0123456789abcdef".split(""),Ni=[-2147483648,8388608,32768,128],Mi=[24,16,8,0],Fi=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],xi=["hex","array","digest","arrayBuffer"],$i=[];Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),Li&&!ArrayBuffer.isView&&(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});const Gi=function(t){return function(e){const a=new Bi(!0).update(e);return null==a?void 0:a[t]()}},ji=function(t){return function(e,a){const n=new Vi(e,!0).update(a);return null==n?void 0:n[t]()}};class Bi{constructor(t=!1){this.blocks=void 0,this.h0=void 0,this.h1=void 0,this.h2=void 0,this.h3=void 0,this.h4=void 0,this.h5=void 0,this.h6=void 0,this.h7=void 0,this.block=void 0,this.start=void 0,this.bytes=void 0,this.hBytes=void 0,this.finalized=void 0,this.hashed=void 0,this.first=void 0,this.lastByteIndex=void 0,this.sharedMemory=!1,this.toString=()=>this.hex(),this.array=()=>Bi.prototype.digest(),t?($i[0]=$i[16]=$i[1]=$i[2]=$i[3]=$i[4]=$i[5]=$i[6]=$i[7]=$i[8]=$i[9]=$i[10]=$i[11]=$i[12]=$i[13]=$i[14]=$i[15]=0,this.blocks=$i):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225,this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.sharedMemory=t}update(t){if(this.finalized)return;let e;const a=typeof t;if("string"!==a){if("object"!==a)throw new Error(Ci);if(null===t)throw new Error(Ci);if(Li&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||Li&&ArrayBuffer.isView(t)))throw new Error(Ci);e=!0}let n,s,i=0;const o=t.length,r=this.blocks;for(;i<o;){if(this.hashed&&(this.hashed=!1,r[0]=this.block,r[16]=r[1]=r[2]=r[3]=r[4]=r[5]=r[6]=r[7]=r[8]=r[9]=r[10]=r[11]=r[12]=r[13]=r[14]=r[15]=0),e)for(s=this.start;i<o&&s<64;++i)r[s>>2]|=t[i]<<Mi[3&s++];else for(s=this.start;i<o&&s<64;++i)n=t.charCodeAt(i),n<128?r[s>>2]|=n<<Mi[3&s++]:n<2048?(r[s>>2]|=(192|n>>6)<<Mi[3&s++],r[s>>2]|=(128|63&n)<<Mi[3&s++]):n<55296||n>=57344?(r[s>>2]|=(224|n>>12)<<Mi[3&s++],r[s>>2]|=(128|n>>6&63)<<Mi[3&s++],r[s>>2]|=(128|63&n)<<Mi[3&s++]):(n=65536+((1023&n)<<10|1023&t.charCodeAt(++i)),r[s>>2]|=(240|n>>18)<<Mi[3&s++],r[s>>2]|=(128|n>>12&63)<<Mi[3&s++],r[s>>2]|=(128|n>>6&63)<<Mi[3&s++],r[s>>2]|=(128|63&n)<<Mi[3&s++]);this.lastByteIndex=s,this.bytes+=s-this.start,s>=64?(this.block=r[16],this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}finalize(){if(this.finalized)return;this.finalized=!0;const t=this.blocks,e=this.lastByteIndex;t[16]=this.block,t[e>>2]|=Ni[3&e],this.block=t[16],e>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}hash(){let t,e,a,n,s,i,o,r,l,c,u,d=this.h0,g=this.h1,p=this.h2,h=this.h3,y=this.h4,S=this.h5,v=this.h6,f=this.h7;const m=this.blocks;for(t=16;t<64;++t)s=m[t-15],e=(s>>>7|s<<25)^(s>>>18|s<<14)^s>>>3,s=m[t-2],a=(s>>>17|s<<15)^(s>>>19|s<<13)^s>>>10,m[t]=m[t-16]+e+m[t-7]+a|0;for(u=g&p,t=0;t<64;t+=4)this.first?(r=704751109,s=m[0]-210244248,f=s-1521486534|0,h=s+143694565|0,this.first=!1):(e=(d>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),a=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7),r=d&g,n=r^d&p^u,o=y&S^~y&v,s=f+a+o+Fi[t]+m[t],i=e+n,f=h+s|0,h=s+i|0),e=(h>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10),a=(f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7),l=h&d,n=l^h&g^r,o=f&y^~f&S,s=v+a+o+Fi[t+1]+m[t+1],i=e+n,v=p+s|0,p=s+i|0,e=(p>>>2|p<<30)^(p>>>13|p<<19)^(p>>>22|p<<10),a=(v>>>6|v<<26)^(v>>>11|v<<21)^(v>>>25|v<<7),c=p&h,n=c^p&d^l,o=v&f^~v&y,s=S+a+o+Fi[t+2]+m[t+2],i=e+n,S=g+s|0,g=s+i|0,e=(g>>>2|g<<30)^(g>>>13|g<<19)^(g>>>22|g<<10),a=(S>>>6|S<<26)^(S>>>11|S<<21)^(S>>>25|S<<7),u=g&p,n=u^g&h^c,o=S&v^~S&f,s=y+a+o+Fi[t+3]+m[t+3],i=e+n,y=d+s|0,d=s+i|0;this.h0=this.h0+d|0,this.h1=this.h1+g|0,this.h2=this.h2+p|0,this.h3=this.h3+h|0,this.h4=this.h4+y|0,this.h5=this.h5+S|0,this.h6=this.h6+v|0,this.h7=this.h7+f|0}hex(){this.finalize();const t=this.h0,e=this.h1,a=this.h2,n=this.h3,s=this.h4,i=this.h5,o=this.h6,r=this.h7;let l=Di[t>>28&15]+Di[t>>24&15]+Di[t>>20&15]+Di[t>>16&15]+Di[t>>12&15]+Di[t>>8&15]+Di[t>>4&15]+Di[15&t]+Di[e>>28&15]+Di[e>>24&15]+Di[e>>20&15]+Di[e>>16&15]+Di[e>>12&15]+Di[e>>8&15]+Di[e>>4&15]+Di[15&e]+Di[a>>28&15]+Di[a>>24&15]+Di[a>>20&15]+Di[a>>16&15]+Di[a>>12&15]+Di[a>>8&15]+Di[a>>4&15]+Di[15&a]+Di[n>>28&15]+Di[n>>24&15]+Di[n>>20&15]+Di[n>>16&15]+Di[n>>12&15]+Di[n>>8&15]+Di[n>>4&15]+Di[15&n]+Di[s>>28&15]+Di[s>>24&15]+Di[s>>20&15]+Di[s>>16&15]+Di[s>>12&15]+Di[s>>8&15]+Di[s>>4&15]+Di[15&s]+Di[i>>28&15]+Di[i>>24&15]+Di[i>>20&15]+Di[i>>16&15]+Di[i>>12&15]+Di[i>>8&15]+Di[i>>4&15]+Di[15&i]+Di[o>>28&15]+Di[o>>24&15]+Di[o>>20&15]+Di[o>>16&15]+Di[o>>12&15]+Di[o>>8&15]+Di[o>>4&15]+Di[15&o];return l+=Di[r>>28&15]+Di[r>>24&15]+Di[r>>20&15]+Di[r>>16&15]+Di[r>>12&15]+Di[r>>8&15]+Di[r>>4&15]+Di[15&r],l}digest(){this.finalize();const t=this.h0,e=this.h1,a=this.h2,n=this.h3,s=this.h4,i=this.h5,o=this.h6,r=this.h7,l=[t>>24&255,t>>16&255,t>>8&255,255&t,e>>24&255,e>>16&255,e>>8&255,255&e,a>>24&255,a>>16&255,a>>8&255,255&a,n>>24&255,n>>16&255,n>>8&255,255&n,s>>24&255,s>>16&255,s>>8&255,255&s,i>>24&255,i>>16&255,i>>8&255,255&i,o>>24&255,o>>16&255,o>>8&255,255&o];return l.push(r>>24&255,r>>16&255,r>>8&255,255&r),l}arrayBuffer(){this.finalize();const t=new ArrayBuffer(32),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),e.setUint32(28,this.h7),t}}class Vi extends Bi{constructor(t,e=!1){let a;super(e),this.inner=void 0,this.oKeyPad=void 0;const n=typeof t;if("string"===n){const e=[],n=t.length;let s,i=0;for(a=0;a<n;++a)s=t.charCodeAt(a),s<128?e[i++]=s:s<2048?(e[i++]=192|s>>6,e[i++]=128|63&s):s<55296||s>=57344?(e[i++]=224|s>>12,e[i++]=128|s>>6&63,e[i++]=128|63&s):(s=65536+((1023&s)<<10|1023&t.charCodeAt(++a)),e[i++]=240|s>>18,e[i++]=128|s>>12&63,e[i++]=128|s>>6&63,e[i++]=128|63&s);t=e}else{if("object"!==n)throw new Error(Ci);if(null===t)throw new Error(Ci);if(Li&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||Li&&ArrayBuffer.isView(t)))throw new Error(Ci)}var s;t.length>64&&(t=null==(s=new Bi(!0).update(t))?void 0:s.array());const i=[],o=[];for(a=0;a<64;++a){const e=t[a]||0;i[a]=92^e,o[a]=54^e}Bi.call(this,e),this.update(o),this.oKeyPad=i,this.inner=!0,this.sharedMemory=e}finalize(){if(super.finalize(),this.inner){this.inner=!1;const t=this.array();Bi.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(t),Bi.prototype.finalize.call(this)}}}const Wi=function(){const t=Gi("hex");t.create=function(){return new Bi},t.update=function(e){return t.create().update(e)};for(let e=0;e<xi.length;++e){const a=xi[e];t[a]=Gi(a)}return t}(),Hi=function(){const t=ji("hex");t.create=function(t){return new Vi(t)},t.update=function(e,a){return t.create(e).update(a)};for(let e=0;e<xi.length;++e){const a=xi[e];t[a]=ji(a)}return t}();async function zi(t){const e=Wi.digest((new TextEncoder).encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}async function Ki(t){const e=await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}async function qi(t){var e,a;return null!=(e=window.crypto)&&null!=(a=e.subtle)&&a.digest?Ki(t):(console.warn("Generating CodeChallenge in non-secure domain:",window.location.origin),zi(t))}function Ji(t=16){let e="";for(let a=0;a<t;a++)e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random()));return e}var Yi=a(8792),Xi=a.n(Yi),Qi=a(5875);const Zi=(t="default")=>{if(!U.for(t).shouldLoadEntitlements())throw new Error("You must first enable entitlements via Frontegg options to use this function")},to=(t,e,a,n,s="default")=>(Zi(s),(0,Qi.Me)(e,t,a)),eo=(t,e,a,n,s="default")=>(Zi(s),(0,Qi.a_)(e,t,a)),ao=(t,e,a,n,s="default")=>"permissionKey"in e?to(t,e.permissionKey,a,n,s):eo(t,e.featureKey,a,n,s);function no(t,e){return Xi()(t,e)}let so,io;!function(t){t.LOAD_SSO_CONFIGURATIONS="LOAD_SSO_CONFIGURATIONS",t.SAVE_SSO_CONFIGURATION="SAVE_SSO_CONFIGURATION",t.UPDATE_SSO_CONFIGURATION="UPDATE_SSO_CONFIGURATION",t.SAVE_SSO_CONFIGURATION_BY_METADATA="SAVE_SSO_CONFIGURATION_BY_METADATA",t.UPDATE_SSO_CONFIGURATION_BY_METADATA="UPDATE_SSO_CONFIGURATION",t.DELETE_SSO_CONFIGURATION="DELETE_SSO_CONFIGURATION",t.SAVE_SSO_DOMAIN="SAVE_SSO_DOMAIN",t.DELETE_SSO_DOMAIN="DELETE_SSO_DOMAIN",t.VALIDATE_SSO_DOMAIN="VALIDATE_SSO_DOMAIN",t.UPDATE_SSO_DEFAULT_ROLES="UPDATE_SSO_DEFAULT_ROLES",t.DELETE_SSO_GROUPS="DELETE_SSO_GROUPS",t.SAVE_SSO_GROUPS="SAVE_SSO_GROUPS",t.GET_SSO_AUTHORIZATION_ROLES="GET_SSO_AUTHORIZATION_ROLES"}(so||(so={})),function(t){t.Saml="saml",t.Okta="okta",t.Azure="azure",t.Google="google",t.Oidc="oidc"}(io||(io={}));const oo=["callback","error"],ro=["callback"],lo=["callback"],co=["callback"],uo=["callback"],go=["callback","events"],po=["callback"],ho=["callback"],yo=["user"],So=["callback"],vo=["callback"],fo=["callback"],mo=["callback"],bo=["callback"],Ao=["callback"],wo=(t,e,a)=>{const n=a,s=U.for(t.root.appName),i=e=>{var a;const{routes:n,loginState:s}=t.auth,i=null!=(a=localStorage.getItem("register-quick-login"))?a:s.quickLoginToRegister;return i&&"true"!==localStorage.getItem(`${e.id}-${i}`)&&!window.location.pathname.endsWith(n.logoutUrl)},o=async()=>{t.auth.hostedLoginBox?await(async()=>{const a=t.auth.user;if(null==a||!a.refreshToken)return s.setAccessToken(null),s.setUser(null),void n.setAuthState({user:null,isAuthenticated:!1});try{const t={grant_type:"refresh_token",refresh_token:null==a?void 0:a.refreshToken},s=await e.auth.exchangeOAuthTokensV2(t),i=await r(s.user);n.afterAuthenticationStateUpdate(v({},s,{user:i}),{isAuthenticated:!0})}catch(t){s.setAccessToken(null),s.setUser(null),n.setAuthState({user:null,isAuthenticated:!1})}})():await(async()=>{try{const{routes:s,loginState:o,onRedirectTo:c}=t.auth,{user:u,tenants:d=[],activeTenant:g}=await e.auth.refreshTokenV3();if(Ss(u,t.root.appName)){const t=await n.getMfaRequiredState(u);n.setAuthState(t),c(s.loginUrl,{preserveQueryParams:!0})}else{var a;u.id&&localStorage.setItem("userId",u.id);const t=null!=(a=localStorage.getItem("register-quick-login"))?a:o.quickLoginToRegister,e=i(u),s=await r(u);n.afterAuthenticationStateUpdate({user:s,tenants:d,activeTenant:g},{loginState:v({},o,{quickLoginToRegister:t,flow:e?Sn.RegisterQuickLogin:Sn.Login}),isAuthenticated:!0}),await l(e)}}catch(t){s.setAccessToken(null),s.setUser(null),n.setAuthState({user:void 0,isAuthenticated:!1})}})()},r=async e=>{var a;const n=null==(a=t.auth.user)?void 0:a.entitlements;return no(n,null==e?void 0:e.entitlements)?v({},e,{entitlements:n}):e},l=async e=>{var a;const s=new URL(null==(a=window)?void 0:a.location.href),{routes:i,loginState:o,onRedirectTo:r}=t.auth,l=s.searchParams.get("invitationToken"),c=[i.socialLoginCallbackUrl,i.oidcRedirectUrl,i.samlCallbackUrl,i.magicLinkCallbackUrl];l||c.push(i.loginUrl,i.signUpUrl),e?r(i.loginUrl):c.some((t=>t&&window.location.pathname.endsWith(t)))&&(o.isNewUser&&i.signUpSuccessUrl&&i.socialLoginCallbackUrl===window.location.pathname?r(i.signUpSuccessUrl,{refresh:i.signUpSuccessUrl.startsWith("http")}):await n.afterAuthNavigation())},c=async t=>{try{var a;const{isActive:s}=await On(e.auth.getSSOPublicConfiguration,null==t?void 0:t.retryConfig);n.setAuthState({isSSOAuth:s}),null==t||null==(a=t.callback)||a.call(t,{isSSOAuth:s})}catch(e){var s;n.setAuthState({isSSOAuth:!1}),null==t||null==(s=t.callback)||s.call(t,null,e)}},u=async t=>{let a;try{var s;const n=await On(e.metadata.getSamlMetadata,null==t?void 0:t.retryConfig);a=null==n||null==(s=n.configuration)?void 0:s.acsUrl}catch(t){console.error(t)}n.setAuthState({ssoACS:a})},d=e=>{Object.assign(t.auth.loginState,e)},g=t=>Pn({callback:(e,a)=>{!a||a.statusCode<500||n.setErrorByRequestName({requestName:t,traceId:kn(a)})}}),p=async e=>{let{callback:a,error:s}=e,i=f(e,oo);const o=t.auth.securityPolicyState.publicPolicy.policy;if(null==o||!o.authStrategy)return n.setLoginState({step:yn.loginWithPassword,loading:!1}),void(null==a||a());(null==o?void 0:o.authStrategy)===N.EmailAndPassword?(n.setLoginState({step:yn.loginWithPassword,loading:!1}),null==a||a()):[N.MagicLink,N.Code,N.SmsCode].includes(null==o?void 0:o.authStrategy)?await n.passwordlessPreLogin(v({},i,{type:null==o?void 0:o.authStrategy,callback:a})):(n.setLoginState({step:yn.loginWithPassword,loading:!1,error:Nn(s)}),null==a||a())},h=async t=>{const{user:e,tenants:a=[],activeTenant:s}=t,i={step:Yn.recoveryCode,loading:!1,error:void 0,saving:!1};null!=e&&e.recoveryCode&&(i.recoveryCode=e.recoveryCode),n.setMfaState(i),n.setUser(e),n.setTenantsState({tenants:a,activeTenant:s,loading:!1}),e.id&&localStorage.setItem("userId",e.id)};return v({setLoginState:d,resetLoginState:()=>{Cn(t,["auth","loginState"],yi)},requestAuthorize:async t=>{const e=[],a=[];e.push(o()),t&&(n.setAuthState({isLoading:!0}),e.push(n.loadSocialLoginsConfigurationV2(Pn())),e.push(n.loadAllowSignUps(g(Wn.LOAD_ALLOW_SIGNUPS))),e.push(n.loadPublicAuthStrategiesPolicy(g(Wn.LOAD_PUBLIC_AUTH_STRATEGIES_POLICY))),e.push(n.loadSignUpStrategies()),e.push(c(g(Wn.LOAD_SSO_PUBLIC_CONFIGURATION))),e.push(n.loadVendorPublicInfo(Pn())),e.push(u(Pn())),a.push(n.loadCustomLoginRoutes(g(Wn.LOAD_CUSTOM_LOGIN_ROUTES)))),await Promise.all(e),a.length>0&&await Promise.all(a),n.setAuthState({isLoading:!1})},requestAuthorizeSSR:async e=>{const a=[];a.push(n.loadSocialLoginsConfigurationV2(Pn())),a.push(n.loadAllowSignUps(g(Wn.LOAD_ALLOW_SIGNUPS))),a.push(c(g(Wn.LOAD_SSO_PUBLIC_CONFIGURATION))),a.push(n.loadSignUpStrategies()),a.push(n.loadVendorPublicInfo(Pn())),a.push(u()),a.push((async({accessToken:e,user:a})=>{if(!e)return void n.setAuthState({user:void 0,isAuthenticated:!1});const{onRedirectTo:s,routes:i}=t.auth;if(Ss(a,t.root.appName)){const t=await n.getMfaRequiredState(a,Tn,!0);n.setAuthState(t),s(i.loginUrl,{preserveQueryParams:!0})}})(e)),a.push(n.loadCustomLoginRoutes(g(Wn.LOAD_CUSTOM_LOGIN_ROUTES))),await Promise.all(a)},preLogin:async a=>{const{email:n,recaptchaToken:s,invitationToken:i,callback:o}=a;d({loading:!0});try{const a=t.auth.onRedirectTo,r=as(ns),l=await e.auth.preLoginV2({email:n,tenantId:r}),{address:c,idpType:u}=null!=l?l:{};if(c){let e=c;if(u===io.Oidc&&!e.includes("redirect_uri")){const{oidcRedirectUrl:a}=t.auth.routes;e+=`&redirect_uri=${window.location.origin}${a}`}S.isLoginWithSSOAvailable()?(S.loginWithSSO(n),d({loading:!1}),null==o||o()):(d({step:yn.redirectToSSO,loading:!1,ssoRedirectUrl:e}),setTimeout((()=>{a(e,{refresh:!0})}),2e3))}else await p({email:n,recaptchaToken:s,callback:o,invitationToken:i})}catch(t){await p({email:n,recaptchaToken:s,callback:o,invitationToken:i,error:t})}},postLogin:async a=>{const{onRedirectTo:s,routes:i}=t.auth;d({loading:!0});try{const t=await e.auth.postLogin(a);n.setAuthState({user:t.accessToken?t:void 0,isAuthenticated:!!t.accessToken}),await n.afterAuthNavigation()}catch(t){setTimeout((()=>{s(i.authenticatedUrl)}),1e3),d({step:yn.loginWithSSOFailed,loading:!1})}},login:async a=>{const{email:i,password:o,recaptchaToken:r,invitationToken:l,callback:c}=a;d({loading:!0});try{const{user:a,tenants:s=[],activeTenant:u}=await e.auth.loginv2({email:i,password:o,recaptchaToken:r,invitationToken:l}),{onRedirectTo:g,routes:p}=t.auth;if(Ss(a,t.root.appName)){const t=await n.getMfaRequiredState(a,Tn,!0,i);n.setAuthState(t),g(p.loginUrl,{preserveQueryParams:!0})}else{const[e,o]=await n.getFeatureFlags(["security-center-show-login-flows","password-rotation"]);if(o&&vs(a,t.root.appName))d({step:yn.passwordRotationExpired,loading:!1,resetPasswordToken:a.resetPasswordToken,userId:a.userId});else{const r=t.auth.loginState,l=!!a.accessToken;if(a.id&&localStorage.setItem("userId",a.id),n.afterAuthenticationStateUpdate({user:a,tenants:s,activeTenant:u},{loginState:{flow:r.flow,quickLoginToRegister:r.quickLoginToRegister,email:i,loading:!1,error:void 0,mfaToken:a.mfaToken,step:r.flow===Sn.Login?yn.success:r.step,tenants:s,tenantsLoading:!0,isBreachedPassword:a.isBreachedPassword},isAuthenticated:l}),r.flow===Sn.Login)if(e&&a.isBreachedPassword&&!l)d({step:yn.breachedPassword,loading:!1});else if(l){const t=us(a);o&&t?d({step:yn.passwordRotationNotification,loading:!1}):await n.__shouldShowPromptPasskeys()?(d({step:yn.promptPasskeys,loading:!1}),g(p.loginUrl,{preserveQueryParams:!0})):await n.afterAuthNavigation()}}}S.isSuggestSavePasswordAvailable()&&S.suggestSavePassword(i,o),localStorage.removeItem("register-quick-login"),null==c||c(!0)}catch(t){s.setAccessToken(null),s.setUser(null),null==c||c(!1,t),d({email:i,error:Nn(t),loading:!1})}},logout:async a=>{const i=t.auth.hostedLoginBox;n.setAuthState({isLoading:!0});try{i?await e.auth.OAuthLogout():await e.auth.logout()}catch{}s.isSessionPerTenantEnabled()&&re(),n.resetAuthState(),await n.requestAuthorize(!0),null==a||a()},silentLogout:async t=>{var a;try{await e.auth.logout()}catch{}s.isSessionPerTenantEnabled()&&re(),setTimeout((()=>{var e;return null==t||null==(e=t.callback)?void 0:e.call(t,!0)}),null!=(a=null==t?void 0:t.callbackTimeout)?a:500)},recoverMfa:async t=>{d({loading:!0});try{var a;await e.auth.recoverMfaToken(t),d({loading:!1,error:void 0,step:yn.preLogin}),n.setAuthState({user:void 0,isAuthenticated:!1}),null==(a=t.callback)||a.call(t,!0)}catch(e){var s;d({error:Nn(e),loading:!1}),null==(s=t.callback)||s.call(t,!1,e)}},quickSmsPasswordlessPreLogin:async t=>{const{callback:a}=t,n=f(t,ro);try{d({loading:!0});const t=await e.auth.passwordlessPreLogin(v({},n,{type:N.SmsCode}));d({step:yn.loginWithQuickSmsOtc,loading:!1,phoneNumber:null==t?void 0:t.phoneNumber,error:void 0}),null==a||a(!0)}catch(t){d({error:Nn(t),loading:!1}),null==a||a(!1,t)}},changePhoneNumberWithVerification:async t=>{const{callback:a}=t,n=f(t,lo);try{d({loading:!0});const t=await e.auth.changePhoneNumberWithVerification(n);d({phoneNumber:n.phoneNumber,loading:!1,changePhoneId:t.changePhoneId,step:yn.loginWithQuickSmsOtc,error:void 0}),null==a||a(!0)}catch(t){d({error:Nn(t),loading:!1})}},verifyChangePhoneNumber:async t=>{const{callback:a}=t,n=f(t,co);try{d({loading:!0}),await e.auth.verifyChangePhoneNumber(n),d({loading:!1}),null==a||a(!0)}catch(t){d({error:Nn(t),loading:!1})}},passwordlessPreLogin:async t=>{const{callback:a}=t,n=f(t,uo);try{let t;d({loading:!0}),ls(n)&&(t=n.email);const s=await e.auth.passwordlessPreLogin(n),i=mn[n.type];d({step:i,loading:!1,phoneNumber:null==s?void 0:s.phoneNumber,email:t,error:void 0}),null==a||a()}catch(t){d({error:Nn(t),loading:!1}),null==a||a(null,t)}},passwordlessPostLogin:async a=>{const{callback:s,events:i}=a,o=f(a,go);try{d({loading:!0});const{user:l,tenants:c=[],activeTenant:u}=await e.auth.passwordlessPostLoginV2(o),{routes:g,onRedirectTo:p}=t.auth;if(Ss(l,t.root.appName)){const t=await n.getMfaRequiredState(l);n.setAuthState(t),p(g.loginUrl,{preserveQueryParams:!0})}else{const e=t.auth.loginState;if(l.emailVerified){var r;const t={email:l.email,origin:Hn.PASSWORDLESS,id:l.id,tenantId:l.tenantId,createdAt:new Date,name:l.name};null==i||null==(r=i.userVerified)||r.call(i,t),Xn(Jn.USER_VERIFIED,t)}l.id&&localStorage.setItem("userId",l.id),n.afterAuthenticationStateUpdate({user:l,tenants:c,activeTenant:u}),d({error:void 0}),n.setAuthState({isLoading:!1}),e.flow===Sn.Login?await n.__shouldShowPromptPasskeys()?(n.setLoginState({step:yn.promptPasskeys,loading:!1}),p(g.loginUrl,{preserveQueryParams:!0})):(n.setAuthState({isAuthenticated:!0}),a.type===N.MagicLink&&(n.setLoginState({step:yn.magicLinkPostLoginSuccess,loading:!1}),await En(5e3)),await n.afterAuthNavigation()):p(g.loginUrl,{preserveQueryParams:!0}),localStorage.removeItem("register-quick-login"),null==s||s(!0)}}catch(t){d({error:Nn(t,"Failed to authenticate")}),null==s||s(null,t)}finally{d({loading:!1})}},verifyInviteToken:async t=>{try{d({loading:!0});const{name:a}=await e.auth.verifyInviteToken(t);d({inviteTokenTenantName:a})}catch(t){d({inviteTokenError:Nn(t,"We couldn't verify your invitation")})}finally{d({loading:!1})}},webAuthnPrelogin:async t=>{const{callback:a}=t,s=f(t,po);try{var i;n.setPasskeysState({loading:!0}),d({loading:!0});const{options:t}=await e.auth.webAuthnPreLogin(s);t.challenge=Oi(t.challenge),t.allowCredentials=null==(i=t.allowCredentials)?void 0:i.map((t=>v({},t,{id:Oi(t.id)}))),d({error:void 0}),null==a||a(t)}catch(t){d({error:Nn(t)}),null==a||a(null)}finally{n.setPasskeysState({loading:!1}),d({loading:!1})}},webAuthnPostLogin:async a=>{const{callback:s}=a,i=f(a,ho);try{var o;n.setPasskeysState({loading:!0}),d({loading:!0});const a=ki(i.publicKey),r=await e.auth.webAuthnPostLoginV2(v({},a,{response:v({},a.response,{userHandle:null!=(o=a.response.userHandle)?o:void 0}),recaptchaToken:i.recaptchaToken,invitationToken:i.invitationToken})),{user:l}=r,c=f(r,yo);if(Ss(l,t.root.appName)){const{routes:e,onRedirectTo:a}=t.auth,s=await n.getMfaRequiredState(l);n.setAuthState(s),a(e.loginUrl,{preserveQueryParams:!0})}else l.id&&localStorage.setItem("userId",l.id),n.afterAuthenticationStateUpdate(v({user:l},c),{isAuthenticated:!0}),d({error:void 0}),await n.afterAuthNavigation(),null==s||s(!0)}catch(t){d({error:Nn(t)}),null==s||s(null)}finally{n.setPasskeysState({loading:!1}),d({loading:!1})}},webAuthnCreateNewDeviceSession:async t=>{const{callback:a}=t;try{d({loading:!0});const{options:t}=await e.auth.webAuthnCreateNewDeviceSession();t.user.id=Oi(t.user.id),t.challenge=Oi(t.challenge),t.excludeCredentials=[],null==a||a(t)}catch(t){d({error:Nn(t)}),null==a||a(null)}finally{d({loading:!1})}},webAuthnVerifyNewDeviceSession:async t=>{const{callback:a}=t,n=f(t,So);try{d({loading:!0});const t=ki(n.publicKey),s="platform"===(null==t?void 0:t.authenticatorAttachment)?qt.Platform:qt.CrossPlatform;await e.auth.verifyNewDeviceSession({id:t.id,response:t.response,deviceType:s}),null==a||a(!0)}catch(t){d({error:Nn(t)}),null==a||a(null)}finally{d({loading:!1})}},getUserIP:async t=>{const{callback:a}=t;try{n.setAuthState({userIpData:{loading:!0}});const{ip:t,country_code:s}=await e.metadata.getCurrentUserIpMetadata();n.setAuthState({userIpData:{ip:t,countryCode:s,loading:!1}}),n.setAuthState({userIp:t}),null==a||a({ip:t,countryCode:s})}catch(t){n.setAuthState({userIpData:{loading:!1}}),null==a||a(!1)}},preEnrollMFAWebAuthnForLogin:async t=>{const{callback:a}=t,n=f(t,vo);d({loading:!0});try{var s;const t=await e.auth.preEnrollMFAWebAuthnForLogin(n),i=v({},t.options,{challenge:Oi(t.options.challenge),user:v({},t.options.user,{id:Oi(t.options.user.id)}),excludeCredentials:null==(s=t.options.excludeCredentials)?void 0:s.map((t=>v({},t,{id:Oi(t.id)})))});d({loading:!1}),null==a||a({options:i,webauthnToken:t.webauthnToken})}catch(t){d({loading:!1,error:Nn(t)}),null==a||a(null)}},enrollMFAWebAuthnForLogin:async t=>{const{callback:a}=t,n=f(t,fo);d({loading:!0});try{const t=ki(n.publicKey),s=await e.auth.enrollMFAWebAuthnForLoginV2(v({},n,{options:t}));await h(s),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Nn(t)}),null==a||a(null)}},enrollMFAAuthenticatorAppForLogin:async t=>{const{callback:a}=t,n=f(t,mo);d({loading:!0});try{const t=await e.auth.enrollMFAAuthenticatorAppForLoginV2(n);await h(t),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Nn(t)}),null==a||a(null)}},preEnrollMFASMSForLogin:async t=>{const{callback:a}=t,s=f(t,bo);d({loading:!0});try{const t=await e.auth.preEnrollMFASMSForLogin(s);n.setMfaState({otcToken:t.otcToken,step:Yn.smsVerifyCode,phoneNumber:t.phoneNumber}),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Nn(t)}),null==a||a(null)}},enrollMFASMSForLogin:async t=>{const{callback:a}=t,n=f(t,Ao);d({loading:!0});try{const t=await e.auth.enrollMFASMSForLoginV2(n);await h(t),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Nn(t)}),null==a||a(null)}},handleEnrollMFAResponse:h,resetBreachedPassword:async t=>{d({loading:!0});try{await e.auth.forgotPassword(t),d({loading:!1,error:void 0,step:yn.breachedPasswordSuccess}),n.setAuthState({isAuthenticated:!1})}catch(t){d({loading:!1,error:Nn(t)})}},refreshTokenForSocialLogins:async()=>{t.auth.hostedLoginBox?await(async()=>{const{user:a}=t.auth;if(null==a||!a.refreshToken)return s.setAccessToken(null),s.setUser(null),void n.setAuthState({user:null,isAuthenticated:!1});try{const t={grant_type:"refresh_token",refresh_token:null==a?void 0:a.refreshToken},s=await e.auth.exchangeOAuthTokensV2(t),i=await r(s.user);n.afterAuthenticationStateUpdate(v({},s,{user:i}),{isAuthenticated:!0})}catch(t){s.setAccessToken(null),s.setUser(null),n.setAuthState({user:null,isAuthenticated:!1})}})():await(async()=>{try{const{routes:s,loginState:o,onRedirectTo:c}=t.auth,{user:u,tenants:d=[],activeTenant:g}=await e.auth.refreshTokenV3();if(Ss(u,t.root.appName)){const t=await n.getMfaRequiredState(u);n.setAuthState(t),c(s.loginUrl,{preserveQueryParams:!0})}else{const t=await r(u);if(await n.__shouldShowPromptPasskeys())n.setLoginState({step:yn.promptPasskeys,loading:!1}),n.afterAuthenticationStateUpdate({user:t,tenants:d,activeTenant:g},{isLoading:!1}),c(s.loginUrl,{preserveQueryParams:!0});else{var a;u.id&&localStorage.setItem("userId",u.id);const e=null!=(a=localStorage.getItem("register-quick-login"))?a:o.quickLoginToRegister,s=i(u);n.afterAuthenticationStateUpdate({user:t,tenants:d,activeTenant:g},{loginState:v({},o,{quickLoginToRegister:e,flow:s?Sn.RegisterQuickLogin:Sn.Login}),isAuthenticated:!0}),await l(s)}}}catch(t){s.setAccessToken(null),s.setUser(null),n.setAuthState({user:void 0,isAuthenticated:!1})}})()},__refreshToken:o},((t,e,a)=>{const n=a,s=async()=>{const t=await e.auth.silentOAuthRefreshTokenV2();if(null==t||!t.user)throw new Error("couldn't refresh user token with oauth service");await n.afterAuthenticationStateUpdate(t,{isAuthenticated:!0,isLoading:!1})},i=async a=>{var s;const{routes:i,onRedirectTo:o}=t.auth,{context:r,urlStrategy:l}=t.root;if(ms(l)===i.hostedLoginRedirectUrl)return void console.debug("Calling loginWithRedirect while in hostedLoginCallback route");n.setAuthState({isLoading:!0});const c=Ji(),u=Ji(),d=await qi(u);localStorage.setItem(wn,u);const g=cs(t);let p=`${window.location.origin}${"path"===l?"":"#"}${null!=g?g:""}${i.hostedLoginRedirectUrl}`;await n.loadCustomLoginRoutes();const h=null==(s=t.auth.customLoginState)?void 0:s.customLoginSearchParams;h&&(p.endsWith("/")&&(p=p.slice(0,-1)),p+=h);const y=`${e.fetch.getBaseUrl(r,"/oauth/authorize")}/oauth/authorize`,S=v({response_type:"code",client_id:r.appId||r.clientId||"INVALID-CLIENT-ID",scope:"openid email profile",redirect_uri:p,code_challenge:d,code_challenge_method:"S256",nonce:c},a);if(r.tenantResolver){var f;const t=await(null==(f=r.tenantResolver)?void 0:f.call(r));null!=t&&t.tenant&&(S.organization=t.tenant)}const m=as(ns);m&&(S.tenantId=m),o(`${y}?${new URLSearchParams(S).toString()}`,{refresh:!0})};return{requestHostedLoginAuthorize:async e=>{var a;null==(a=localStorage)||a.removeItem(pn);const n=t.auth.disableSilentRefresh;if("login"===(null==e?void 0:e.prompt))return await i(e);try{if(n)throw new Error("silent refresh is disabled");return await s()}catch(t){return await i(e)}},requestHostedLoginAuthorizeV2:async e=>{var a,o;const{shouldRedirectToLogin:r,firstTime:l,loginDirectAction:c}=null!=e?e:{};let{additionalParams:u}=null!=e?e:{};if(null==(a=localStorage)||a.removeItem(pn),l){const e=t.root.urlStrategy,a=ms(e);if(n.setAuthState({isLoading:!0}),rs(a))return}const d=t.auth.disableSilentRefresh;if(c&&(u=u||{},u.login_direct_action=btoa(JSON.stringify(c))),"login"===(null==(o=u)?void 0:o.prompt))return await i(u);try{if(d)throw new Error("silent refresh is disabled");return await s()}catch(t){return r?await i(u):void n.setAuthState({isLoading:!1})}},__requestHostedLoginAuthorize:i,__requestHostedLoginSilentAuthorize:s,handleHostedLoginCallback:async a=>{var s;const i=localStorage.getItem(wn)||"INVALID-CODE-VERIFIER",o=t.auth.routes,r=t.root.urlStrategy,l=cs(t);let c=`${window.location.origin}${"path"===r?"":"#"}${null!=l?l:""}${o.hostedLoginRedirectUrl}`;await n.loadCustomLoginRoutes();const u=null==(s=t.auth.customLoginState)?void 0:s.customLoginSearchParams;u&&(c.endsWith("/")&&(c=c.slice(0,-1)),c+=u);const d={code:a.code,redirect_uri:c,code_verifier:i,grant_type:"authorization_code"};try{const t=await e.auth.exchangeOAuthTokensV2(d);n.afterAuthenticationStateUpdate(t,{isAuthenticated:!0,isLoading:!1})}catch(t){n.setAuthState({isLoading:!1}),console.error("Failed to exchangeOAuthTokens",t)}finally{const e=t.auth.user,a=window.localStorage.getItem(pn);window.localStorage.removeItem(pn),a&&ds(e)?await n.afterStepUpAuthNavigation():await n.afterAuthNavigation()}}}})(t,e,a),vi(t,0,a),function(t,e,a){const n=a,s=async()=>await n.afterStepUpAuthNavigation(),i=async(e,a)=>{const s=t.auth.loginState,i=t.auth.mfaState.step,[o,r]=await n.getFeatureFlags(["security-center-show-login-flows","password-rotation"]);if(s.flow===Sn.Login){if(o&&s.isBreachedPassword&&!e)return void n.setLoginState({step:yn.breachedPassword,loading:!1});if(r&&vs(a,t.root.appName))return void n.setLoginState({step:yn.passwordRotationExpired,loading:!1,resetPasswordToken:a.resetPasswordToken,userId:a.userId});if(r&&us(a))return void n.setLoginState({step:yn.passwordRotationNotification,loading:!1});const l=await n.__shouldShowPromptPasskeys();i===Yn.smsVerifyCode&&l?n.setLoginState({step:yn.promptPasskeys,loading:!1}):await n.afterAuthNavigation()}};return{postHandleVerifyMFAResponseForStepUp:s,postHandleVerifyMFAResponseForLogin:i,handleVerifyMFAResponse:async(t,e=!1)=>{const{user:a,tenants:o,activeTenant:r}=t;n.setUser(a),n.setTenantsState({tenants:o,activeTenant:r,loading:!1}),a.id&&localStorage.setItem("userId",a.id);const l=!!a.accessToken;return n.setAuthState({isAuthenticated:l}),e?await s():await i(l,a)},getFeatureFlags:async e=>{const a=t.root.appName;return Zt.getFeatureFlags(e,a)}}}(t,0,a),((t,e)=>({getMfaRequiredState:async(a,n,s=!1,i)=>{var o,r,l;let c=yn.loginWithTwoFactor;const u={step:Yn.verify,loading:!1,saving:!1},d=t.auth.loginState;let g,p;try{const t=await On((()=>e.auth.checkIfAllowToRememberMfaDevice(a.mfaToken)),n);g=t.isAllowedToRemember,p=t.mfaDeviceExpiration}catch(t){if(!s)throw t}!("mfaEnrolled"in a)||a.mfaEnrolled||(null==(o=a.mfaDevices)||null==(r=o.emails)?void 0:r.length)?Object.assign(u,{mfaDevices:a.mfaDevices,mfaToken:a.mfaToken,step:is(a.mfaDevices)}):(Object.assign(u,{step:os(a.mfaStrategies),qrCode:a.qrCode,recoveryCode:a.recoveryCode,loading:!1,mfaToken:a.mfaToken,mfaStrategies:a.mfaStrategies}),c=yn.forceTwoFactor);let h={};const y=localStorage.getItem("register-quick-login");return y&&(h={quickLoginToRegister:y,flow:Sn.RegisterQuickLogin}),{user:void 0,isAuthenticated:!1,mfaState:u,loginState:v({},d,h,{mfaToken:a.mfaToken,mfaRequired:a.mfaRequired,loading:!1,error:void 0,step:c,tenantsLoading:!0,email:null!=(l=a.userEmail)?l:i,tenants:[],allowRememberMfaDevice:g,mfaDeviceExpiration:p,isBreachedPassword:a.isBreachedPassword})}}}))(t,e),((t,e,a)=>{const n=a,s=async(a,s,i)=>{let{callback:o}=a,r=f(a,fi);s({loading:!0,error:void 0});try{const{user:a,tenants:l=[],activeTenant:c}=await e.auth.loginWithMfaV2(r),u=!!a.accessToken,d=await async function(e,a,n){const s=t.auth.loginState;let i={};if(!n){const t=s.flow===Sn.Login?yn.success:s.step;i={loginState:{flow:s.flow,quickLoginToRegister:s.quickLoginToRegister,loading:!1,step:t,error:void 0,tenants:e}}}return v({},i,{isAuthenticated:a})}(l,u,i);return await n.afterAuthenticationStateUpdate({user:a,tenants:l,activeTenant:c},d),a.id&&localStorage.setItem("userId",a.id),s({loading:!1,error:void 0}),i?await async function(t){await n.afterStepUpAuthNavigation(),null==t||t(!0)}(o):await async function(e,a,s){const i=t.auth.loginState;if(i.flow!==Sn.Login)return;const[o,r]=await n.getFeatureFlags(["security-center-show-login-flows","password-rotation"]);if(o&&i.isBreachedPassword&&!e)return n.setLoginState({step:yn.breachedPassword,loading:!1}),void(null==s||s(!0));if(r&&vs(a,t.root.appName))return n.setLoginState({step:yn.passwordRotationExpired,loading:!1,resetPasswordToken:a.resetPasswordToken,userId:a.userId}),void(null==s||s(!0));const l=us(a);if(r&&l)return n.setLoginState({step:yn.passwordRotationNotification,loading:!1}),void(null==s||s(!0));await n.__shouldShowPromptPasskeys()?n.setLoginState({step:yn.promptPasskeys,loading:!1}):await n.afterAuthNavigation(),null==s||s(!0)}(u,a,o)}catch(t){s({loading:!1,error:Nn(t)}),null==o||o(!1,t)}};return{mfaWithAuthenticator:s,loginWithMfa:async t=>await s(t,n.setLoginState,!1)}})(t,e,a),((t,e,a)=>{const n=a,s=async(t,a)=>{var s;let{callback:i}=t,o=f(t,mi);(a=null!=(s=a)?s:n.setLoginState)({loading:!0,error:void 0});try{const t=await e.auth.preVerifyMFAEmailCode(o);n.setMfaState({otcToken:t.otcToken,step:Yn.emailVerifyCode}),a({loading:!1,error:void 0}),null==i||i(!0)}catch(t){a({error:Nn(t)}),null==i||i(null)}},i=async(t,a)=>{var s;let{callback:i}=t,o=f(t,bi);(a=null!=(s=a)?s:n.setLoginState)({loading:!0});try{const t=await e.auth.verifyMFAEmailCodeV2(o);await n.handleVerifyMFAResponse(t),a({loading:!1,error:void 0}),null==i||i(!0)}catch(t){a({loading:!1,error:Nn(t)}),null==i||i(null)}};return{preVerifyMFAEmailCode:s,verifyMFAEmailCode:i,preVerifyMFAEmailCodeForLogin:async t=>await s(t,n.setLoginState),verifyMFAEmailCodeForLogin:async t=>await i(t,n.setLoginState)}})(0,e,a),((t,e,a)=>{const n=a,s=async(t,a)=>{let{callback:s,deviceId:i}=t,o=f(t,Ai);a({loading:!1,error:void 0});try{const t=await e.auth.preVerifyMFASMSForLogin(i,o);n.setMfaState({otcToken:t.otcToken,step:Yn.smsVerifyCode,phoneNumber:t.phoneNumber}),a({loading:!1,error:void 0}),null==s||s(!0)}catch(t){a({loading:!1,error:Nn(t)}),null==s||s(null)}},i=async(t,a,s=!1)=>{let{callback:i,deviceId:o}=t,r=f(t,wi);a({loading:!0});try{const t=await e.auth.verifyMFASMSForLoginV2(o,r);await n.handleVerifyMFAResponse(t,s),a({loading:!1,error:void 0}),null==i||i(!0)}catch(t){a({loading:!1,error:Nn(t)}),null==i||i(null)}};return{preVerifyMFASMS:s,verifyMFASMS:i,preVerifyMFASMSForLogin:async t=>await s(t,n.setLoginState),verifyMFASMSForLogin:async t=>await i(t,n.setLoginState,!1)}})(0,e,a),((t,e,a)=>{const n=a,s=async(t,a)=>{let{callback:n,deviceId:s}=t,i=f(t,Ri);a({loading:!0});try{var o;const t=await e.auth.preVerifyMFAWebAuthnForLogin(s,i),r=v({},t.options,{challenge:Oi(t.options.challenge),allowCredentials:null==(o=t.options.allowCredentials)?void 0:o.map((t=>v({},t,{id:Oi(t.id)})))});a({loading:!1,error:void 0}),null==n||n({options:r,webauthnToken:t.webauthnToken})}catch(t){a({loading:!1,error:Nn(t)}),null==n||n(null)}},i=async(t,a,s)=>{let{callback:i,deviceId:o}=t,r=f(t,Ui);a({loading:!0});try{const t=ki(r.publicKey),l=await e.auth.verifyMFAWebAuthnForLoginV2(o,v({},r,{options:t}));await n.handleVerifyMFAResponse(l,s),a({loading:!1,error:void 0}),null==i||i(!0)}catch(t){a({loading:!1,error:Nn(t)}),null==i||i(null)}};return{preVerifyMFAWebAuthn:s,verifyMFAWebAuthn:i,preVerifyMFAWebAuthnForLogin:async t=>await s(t,n.setLoginState),verifyMFAWebAuthnForLogin:async t=>await i(t,n.setLoginState,!1)}})(0,e,a))},To={step:Yn.verify,loading:!1,saving:!1},Eo=t=>en(To,t),Io=["callback"],Oo=["callback"],Po=["user"],ko=["deviceId"],_o=["deviceId"],Ro=["callback"],Uo=["callback"],Co=["deviceId","callback"],Lo=(t,e,a)=>{const n=a;async function s(e){const a=t.auth.mfaState.step;return{step:e.recoveryCode?Yn.recoveryCode:a,loading:!1,saving:!1,error:void 0,recoveryCode:null==e?void 0:e.recoveryCode}}const i=e=>{Object.assign(t.auth.mfaState,e)};return{setMfaState:i,resetMfaState:()=>{Cn(t,["auth","mfaState"],To)},getMFADevices:async()=>{i({loading:!0});try{const t=await e.auth.getMFADevices();i({loading:!1,error:void 0,mfaDevices:t})}catch(t){i({loading:!1,error:Nn(t)})}},getMFAStrategies:async t=>{i({loading:!0});try{const a=(await On((()=>e.auth.getMFAStrategiesConfig()),null==t?void 0:t.retryConfig)).strategies.filter((({isActive:t})=>t)).map((({strategy:t})=>t));i({loading:!1,error:void 0,mfaStrategies:a})}catch(t){i({loading:!1,error:Nn(t)})}},enrollMfa:async()=>{i({saving:!0});try{const{qrCode:t}=await e.auth.enrollMfa();i({saving:!1,error:void 0,qrCode:t})}catch(t){i({saving:!1,error:Nn(t)})}},verifyMfa:async a=>{const{callback:o}=a,r=f(a,Io);i({saving:!0});try{const a=t.auth.user,l=await e.auth.verifyMfa(r),c=await e.auth.getMFADevices(),u=await s(l);i(v({},u,{mfaDevices:c})),n.setUser(v({},a,{mfaEnrolled:!0})),null==o||o(u.recoveryCode)}catch(t){i({saving:!1,error:Nn(t)}),null==o||o(null,t)}},verifyMfaAfterForce:async t=>{const{callback:a}=t,s=f(t,Oo);i({loading:!0});try{const t=await e.auth.loginWithMfaV2(s),{user:o}=t,r=f(t,Po),l={step:Yn.recoveryCode,loading:!1,saving:!1,error:void 0};null!=o&&o.recoveryCode&&(l.recoveryCode=o.recoveryCode),i(l),await n.afterAuthenticationStateUpdate(v({user:o},r)),null==a||a(l.recoveryCode)}catch(t){i({loading:!1,error:Nn(t)}),null==a||a(null,t)}},disableMfa:async t=>{i({saving:!0});try{var a;await e.auth.disableMfa(t);const n=await e.auth.getMFADevices();i({saving:!1,error:void 0,mfaDevices:n}),null==(a=t.callback)||a.call(t,!0)}catch(e){var n;i({saving:!1,error:Nn(e)}),null==(n=t.callback)||n.call(t,!1,e)}},preDisableMfaSms:async t=>{const{deviceId:a}=t,n=f(t,ko);i({saving:!0});try{var s;const t=await e.auth.preDisableMFASMS(a);i({saving:!1,error:void 0,otcToken:t.otcToken,phoneNumber:t.phoneNumber}),null==(s=n.callback)||s.call(n,!0)}catch(t){var o;i({saving:!1,error:Nn(t)}),null==(o=n.callback)||o.call(n,!1,t)}},disableMfaSms:async t=>{const{deviceId:a}=t,n=f(t,_o);i({saving:!0});try{var s;await e.auth.disableMFASMS(a,n);const t=await e.auth.getMFADevices();i({saving:!1,error:void 0,mfaDevices:t}),null==(s=n.callback)||s.call(n,!0)}catch(t){var o;i({saving:!1,error:Nn(t)}),null==(o=n.callback)||o.call(n,!1,t)}},preEnrollMfaSms:async t=>{i({saving:!0});try{var a;const n=await e.auth.preEnrollMFASMS(t);i({saving:!1,error:void 0,otcToken:n.otcToken,phoneNumber:n.phoneNumber}),null==(a=t.callback)||a.call(t,!0)}catch(e){var n;i({saving:!1,error:Nn(e)}),null==(n=t.callback)||n.call(t,!1,e)}},enrollMfaSms:async t=>{const{callback:a}=t,n=f(t,Ro);i({saving:!0});try{const t=await e.auth.enrollMFASMS(n),o=await e.auth.getMFADevices(),r=await s(t);i(v({},r,{mfaDevices:o})),null==a||a(r.recoveryCode)}catch(t){i({saving:!1,error:Nn(t)}),null==a||a(null,t)}},preEnrollMfaWebAuthn:async t=>{i({saving:!0});try{var a,n;const s=await e.auth.preEnrollMFAWebAuthn(),o=v({},s.options,{challenge:Oi(s.options.challenge),user:v({},s.options.user,{id:Oi(s.options.user.id)}),excludeCredentials:null==(a=s.options.excludeCredentials)?void 0:a.map((t=>v({},t,{id:Oi(t.id)})))});i({saving:!1}),null==(n=t.callback)||n.call(t,{options:o,webauthnToken:s.webauthnToken})}catch(e){var s;i({saving:!1,error:Nn(e)}),null==(s=t.callback)||s.call(t,null,e)}},enrollMfaWebAuthn:async t=>{const{callback:a}=t,n=f(t,Uo);i({saving:!0});try{const t=ki(n.publicKey),o=await e.auth.enrollMFAWebAuthn(v({},n,{options:t})),r=await e.auth.getMFADevices(),l=await s(o);i(v({},l,{mfaDevices:r})),null==a||a(l.recoveryCode)}catch(t){i({saving:!1,error:Nn(t)}),null==a||a(null,t)}},preDisableMfaWebAuthn:async t=>{const{deviceId:a,callback:n}=t;i({saving:!0});try{var s;const t=await e.auth.preDisableMFAWebAuthn(a),o=v({},t.options,{challenge:Oi(t.options.challenge),allowCredentials:null==(s=t.options.allowCredentials)?void 0:s.map((t=>v({},t,{id:Oi(t.id)})))});i({saving:!1}),null==n||n({options:o,webauthnToken:t.webauthnToken})}catch(t){i({saving:!1,error:Nn(t)}),null==n||n(null,t)}},disableMfaWebAuthn:async t=>{const{deviceId:a,callback:n}=t,s=f(t,Co);i({saving:!0});try{const t=ki(s.publicKey);await e.auth.disableMFAWebAuthn(a,v({},s,{options:t}));const o=await e.auth.getMFADevices();i({saving:!1,error:void 0,mfaDevices:o}),null==n||n(!0)}catch(t){i({saving:!1,error:Nn(t)}),null==n||n(!1,t)}},__getMfaStateAfterEnroll:s}},Do={loaders:{},errors:{},accounts:{tenantId:"",children:[]},accountsQueryParams:{_limit:50,_offset:0,_filter:"",_subTenantId:""},searchAccountsData:[],rootAccount:{tenantId:""},selectedAccount:{tenantId:"",userJwt:{accessToken:"",expiresIn:0,expires:""},users:[],usersQueryParams:{_offset:0,_limit:10,_order:$t.DESC,_sortBy:Ga.name},usersPageOffset:0,accountSettings:{}}},No=t=>en(Do,t),Mo={createSubAccountDialog:{loading:!1,open:!1,error:!1,jwt:"",canSelectParentAccount:!1},updateSubAccountDialog:{accountId:"",accountName:"",loading:!1,open:!1,error:!1,jwt:""},disableSubAccountManagementDialog:{accountId:"",accountName:"",loading:!1,open:!1,error:!1},enableSubAccountManagementDialog:{accountId:"",accountName:"",loading:!1,open:!1,error:!1},updateSubAccountHierarchySettingsDialog:{accountId:"",accountName:"",subAccountAccessType:_a.DEFAULT_OFF,loading:!1,open:!1,error:!1},deleteSubAccountDialog:{accountId:"",accountName:"",isParentAccount:!1,loading:!1,open:!1,error:!1,jwt:""},addUsersToAccountDialog:{loading:!1,open:!1,accountName:"",accountId:"",permissionToGiveAccessToSubAccounts:!1,jwt:""},deleteUserFromAccountDialog:{userId:"",userName:"",accountId:"",loading:!1,open:!1,jwt:""},editUserRolesDialog:{loading:!1,open:!1,jwt:"",accountId:"",userId:"",userName:"",userRoles:[]}},Fo=t=>en(Mo,t);let xo;!function(t){t.GET_ACCOUNTS="GET_ACCOUNTS",t.SEARCH_ACCOUNTS="SEARCH_ACCOUNTS",t.SET_ROOT_ACCOUNT_DATA="SET_ROOT_ACCOUNT_DATA",t.SET_SELECTED_SUB_ACCOUNT_DATA="SET_SELECTED_SUB_ACCOUNT_DATA",t.LOAD_NUMBER_OF_USERS_FOR_ACCOUNT="LOAD_NUMBER_OF_USERS_FOR_ACCOUNT",t.UPDATE_SUB_ACCOUNT_ACCESS_FOR_USER="UPDATE_SUB_ACCOUNT_ACCESS_FOR_USER",t.CREATE_SUB_ACCOUNT="CREATE_SUB_ACCOUNT",t.UPDATE_SUB_ACCOUNT="UPDATE_SUB_ACCOUNT",t.DELETE_SUB_ACCOUNT="DELETE_SUB_ACCOUNT",t.GET_ACCOUNT_USERS="GET_ACCOUNT_USERS",t.ADD_USERS_TO_ACCOUNT="ADD_USERS_TO_ACCOUNT",t.DELETE_USERS_FROM_ACCOUNT="DELETE_USERS_FROM_ACCOUNT",t.SET_USER_ROLES_FOR_SUB_ACCOUNT="SET_USER_ROLES_FOR_SUB_ACCOUNT",t.UPDATE_SUB_ACCOUNT_SETTINGS="UPDATE_SUB_ACCOUNT_SETTINGS",t.UPDATE_SUB_ACCOUNT_MANAGEMENT="UPDATE_SUB_ACCOUNT_MANAGEMENT",t.UPDATE_SUB_ACCOUNT_HIERARCHY_SETTINGS="UPDATE_SUB_ACCOUNT_HIERARCHY_SETTINGS",t.GET_USER_JWT="GET_USER_JWT",t.GET_TEAM_USERS="GET_TEAM_USERS"}(xo||(xo={}));const $o=({items:t},e)=>t.map((t=>{var a,n;return{name:t.name,tenantId:t.tenantId,numberOfUsers:null!=(a=null==(n=e.find((e=>e.tenantId===t.tenantId)))?void 0:n.totalUsers)?a:0,createdAt:t.createdAt,metadata:t.metadata,isReseller:t.isReseller,subAccountAccessType:t.subAccountAccessType}}));function Go(t,e,a){var n,s,i;return t.tenantId===e?v({},t,{children:[...null!=(i=null==t?void 0:t.children)?i:[],...a].filter(((t,e,a)=>e===a.findIndex((e=>e.tenantId===t.tenantId))))}):v({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>Go(t,e,a))))?n:[]})}function jo(t,e){var a;return v({},t,{children:null!=(a=t.children)&&a.length?t.children.filter((t=>t.tenantId!==e)).map((t=>jo(t,e))):[]})}const Bo=(t,e,a)=>{var n,s;return t.tenantId===e?v({},t,{subAccountAccessType:a}):v({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>Bo(t,e,a))))?n:[]})},Vo=(t,e,a)=>{var n,s;return t.tenantId===e?v({},t,{name:a}):v({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>Vo(t,e,a))))?n:[]})},Wo=(t,e,a)=>{var n,s;return t?t.tenantId===e?v({},t,{isReseller:a}):v({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>Wo(t,e,a))))?n:[]}):{}},Ho=(t,e,a)=>{const n=e=>{Object.assign(t.auth.allAccountsState,{loaders:v({},t.auth.allAccountsState.loaders,{[e.key]:e.value})})},s=e=>{Object.assign(t.auth.allAccountsState,{errors:v({},t.auth.allAccountsState.errors,{[e.key]:e.value}),loaders:v({},t.auth.allAccountsState.loaders,{[e.key]:!1})})},i=e=>{Object.assign(t.auth.allAccountsState,e)},o=e=>{Object.assign(t.auth.allAccountsState.selectedAccount,e)},r=()=>t.auth.allAccountsState,l=async t=>{var a,i,l,c,u,d,g,p;const{jwt:h,_tenantId:y,_email:S}=t,f=xo.GET_ACCOUNT_USERS;n({key:f,value:!0});const m=r(),b=null!=(a=null!=(i=null==t?void 0:t._offset)?i:null==m||null==(l=m.selectedAccount)||null==(c=l.usersQueryParams)?void 0:c._offset)?a:0,A=null!=(u=null!=(d=null==t?void 0:t._limit)?d:null==m||null==(g=m.selectedAccount)||null==(p=g.usersQueryParams)?void 0:p._limit)?u:10,w=v({_offset:b,_limit:A,_tenantId:y,_includeSubTenants:!1},!!S&&{_email:S});try{const{items:t,_metadata:{totalItems:a,totalPages:n}}=await e.users.getUsersV3(w,{jwt:h}),s={totalUsersItems:a,totalUsersPages:n,usersQueryParams:v({_offset:null!=b?b:0,_limit:null!=A?A:10},!!S&&{_email:S})};if(t.length){const a=t.map((t=>t.id)),n=await e.roles.getRoles(),i=await e.users.getUsersRoles({ids:a},{jwt:h}),r=t.map((t=>{var e,a;const s=null==i||null==(e=i.find((e=>e.userId===t.id)))?void 0:e.roleIds;return v({},t,{roles:null!=(a=null==s?void 0:s.map((t=>{var e;return null!=(e=null==n?void 0:n.find((e=>e.id===t)))?e:[]})))?a:[]})}));o(v({users:r},s))}else o(v({users:[]},s))}catch(t){s({key:f,value:Nn(t)})}finally{n({key:f,value:!1})}};return{setAllAccountsLoader:n,setAllAccountsError:s,setAllAccountsState:i,setSelectedAccountState:o,resetAllAccountsState:()=>{Cn(t,["auth","allAccountsState"],Do)},clearSelectedAccount:()=>{Cn(t,["auth","allAccountsState","selectedAccount"],Do.selectedAccount)},loadAccounts:async t=>{const a=xo.GET_ACCOUNTS;n({key:a,value:!0});const{accountsQueryParams:l}=r(),{jwt:c,_limit:u,_offset:d}=t,g={_offset:null!=d?d:l._offset,_limit:null!=u?u:l._limit,_subTenantId:null==t?void 0:t._subTenantId};try{if(c){var p;const{selectedAccount:a}=r(),{items:n,_links:s}=await e.tenants.searchSubTenants(g,{jwt:c}),i=await e.tenants.getTenantsUsersCount({tenantIds:n.map((t=>t.tenantId))},{jwt:c}),l=$o({items:n},i),u=Go(a.accounts?a.accounts:a,null!=(p=null==t?void 0:t._subTenantId)?p:"",l.map((t=>({name:t.name,tenantId:t.tenantId,numberOfUsers:t.numberOfUsers,createdAt:t.createdAt,metadata:t.metadata,children:[],loadMoreLink:null==s?void 0:s.next,isReseller:t.isReseller}))));o({accounts:u})}else{var h;const{accounts:a}=r(),{items:n,_links:s}=await e.tenants.searchSubTenants(g),o=await e.tenants.getTenantsUsersCount({tenantIds:n.map((t=>t.tenantId))}),l=$o({items:n},o),c=Go(a,null!=(h=null==t?void 0:t._subTenantId)?h:"",l.map((t=>({name:t.name,tenantId:t.tenantId,numberOfUsers:t.numberOfUsers,createdAt:t.createdAt,metadata:t.metadata,children:[],loadMoreLink:null==s?void 0:s.next,isReseller:t.isReseller}))));i({accounts:c})}}catch(t){s({key:a,value:Nn(t)})}finally{n({key:a,value:!1})}},searchAccounts:async t=>{const{jwt:a}=t,o=xo.SEARCH_ACCOUNTS;n({key:o,value:!0});const{rootAccount:l}=r();try{if(null!=t&&t._subTenantId){var c;const{items:n}=await e.tenants.searchSubTenants({_offset:0,_limit:50,_filter:null!=(c=null==t?void 0:t._filter)?c:"",_subTenantId:t._subTenantId},{jwt:a});i({searchAccountsData:[...n,{name:l.name,tenantId:l.tenantId}]})}}catch(t){s({key:o,value:Nn(t)})}finally{n({key:o,value:!1})}},updateSubAccountAccessForUser:async t=>{const a=xo.UPDATE_SUB_ACCOUNT_ACCESS_FOR_USER;n({key:a,value:!0});const{selectedAccount:i}=r(),{userId:l,allowAccess:c,jwt:u,callback:d}=t;try{var g;await e.subTenants.updateSubAccountAccess(l,{allowAccess:c},{jwt:u}),o({users:null==i||null==(g=i.users)?void 0:g.map((t=>t.id===l?v({},t,{subAccountAccessAllowed:c}):t))}),null==d||d(!0)}catch(t){s({key:a,value:Nn(t)}),null==d||d(!1)}finally{n({key:a,value:!1})}},createSubAccount:async t=>{const a=xo.CREATE_SUB_ACCOUNT;n({key:a,value:!0});const{name:l,parentTenantId:c,tenantId:u,jwt:d,callback:g}=t;try{if(d){const{accounts:t,selectedAccount:a}=r(),n=await e.subTenants.createSubTenant({name:l,parentTenantId:c,tenantId:u},{jwt:d}),s=Go(t,null!=c?c:"",[{name:n.name,tenantId:n.tenantId,numberOfUsers:0,createdAt:new Date}]),g=Go(v({name:"",tenantId:""},null==a?void 0:a.accounts),null!=c?c:"",[{name:n.name,tenantId:n.tenantId,numberOfUsers:0,createdAt:new Date}]);i({accounts:s}),o({accounts:g})}else{const{accounts:t}=r(),a=await e.subTenants.createSubTenant({name:l,tenantId:u,parentTenantId:c}),n=Go(t,null!=c?c:"",[{name:a.name,tenantId:a.tenantId,numberOfUsers:0,createdAt:new Date}]);i({accounts:n})}null==g||g(!0)}catch(t){s({key:a,value:Nn(t)}),null==g||g(!1)}finally{n({key:a,value:!1})}},updateSubAccount:async t=>{},deleteSubAccount:async t=>{const a=xo.DELETE_SUB_ACCOUNT;n({key:a,value:!0});const{jwt:l,tenantId:c,callback:u}=t;try{if(l){const{selectedAccount:t,accounts:a}=r();await e.subTenants.deleteSubTenant(c,{jwt:l});const n=jo(a,c),s=jo(t.accounts,c);i({accounts:n}),o({accounts:s})}else{const{accounts:t}=r();await e.subTenants.deleteSubTenant(c);const a=jo(t,c);i({accounts:a})}null==u||u(!0)}catch(t){s({key:a,value:Nn(t)}),null==u||u(!1)}finally{n({key:a,value:!1})}},updateSubAccountSettings:async t=>{const a=xo.UPDATE_SUB_ACCOUNT_HIERARCHY_SETTINGS;n({key:a,value:!0});const{jwt:l,name:c,callback:u,tenantId:d}=t;try{if(l){const{selectedAccount:t,accounts:a}=r();await e.subTenants.updateSubTenant({tenantId:d},{name:c},{jwt:l});const n=Vo(t.accounts,d,c);o({name:c,accounts:n});const s=Vo(a,d,c);i({accounts:s})}else{const{accounts:t}=r();await e.subTenants.updateSubTenant({tenantId:d},{name:c});const a=Vo(t,d,c);i({accounts:a})}null==u||u(!0)}catch(t){s({key:a,value:Nn(t)}),null==u||u(!1)}finally{n({key:a,value:!1})}},updateSubAccountManagement:async r=>{const l=xo.UPDATE_SUB_ACCOUNT_MANAGEMENT;a.setAllAccountsLoader({key:l,value:!0});const{jwt:c,isReseller:u,callback:d,tenantId:g,shouldUpdateSelectedAccount:p}=r,h=!!c;try{if(p){const{selectedAccount:a,accounts:n}=t.auth.allAccountsState;await e.subTenants.updateSubTenantManagement({tenantId:g},{isReseller:u},c?{jwt:c}:void 0);const s=Wo(a.accounts,g,null!=u&&u);o({accounts:s}),h||o({isReseller:u});const r=Wo(n,g,null!=u&&u);i({accounts:r})}else{const{accounts:a}=t.auth.allAccountsState;e.subTenants.updateSubTenantManagement({tenantId:g},{isReseller:u},c?{jwt:c}:void 0);const n=Wo(a,g,null!=u&&u);i({accounts:n})}null==d||d(!0)}catch(t){s({key:l,value:Nn(t)}),null==d||d(!1)}finally{n({key:l,value:!1})}},updateSubAccountHierarchySettings:async t=>{const a=xo.UPDATE_SUB_ACCOUNT_HIERARCHY_SETTINGS;n({key:a,value:!0});const{jwt:l,callback:c,tenantId:u,subAccountAccessType:d}=t;if(d)try{if(l){const{selectedAccount:t,accounts:a}=r();await e.subTenants.updateSubTenantHierarchySettings({tenantId:u},{subAccountAccessType:d},{jwt:l});const n=Bo(t.accounts,u,d);o({subAccountAccessType:d,accounts:n});const s=Bo(a,u,d);i({accounts:s})}else{const{accounts:t}=r();await e.subTenants.updateSubTenantHierarchySettings({tenantId:u},{subAccountAccessType:d});const a=Bo(t,u,d);i({accounts:a})}null==c||c(!0)}catch(t){s({key:a,value:Nn(t)}),null==c||c(!1)}finally{n({key:a,value:!1})}},addUsersToAccount:async t=>{const{users:a,tenantId:i,jwt:o,callback:r,allowSubAccountAccess:c=!1,roleIds:u}=t,d=xo.ADD_USERS_TO_ACCOUNT;try{n({key:d,value:!0}),await e.subTenants.addUsersToSubTenant({users:a,tenantId:i,allowSubAccountAccess:c,roleIds:u},{jwt:o}),await l({jwt:o,_tenantId:i}),null==r||r(!0)}catch(t){s({key:d,value:Nn(t)}),null==r||r(!1)}finally{n({key:d,value:!1})}},getAccountUsers:l,deleteUsersFromAccount:async t=>{const a=xo.DELETE_USERS_FROM_ACCOUNT;n({key:a,value:!0});const{userId:i,subTenants:o,jwt:r,callback:c}=t;try{await e.subTenants.removeUserFromTenantAndSubTenants({userId:i,subTenants:o},{jwt:r}),await l({jwt:r,_tenantId:o[0].tenantId}),null==c||c(!0)}catch(t){s({key:a,value:Nn(t)}),null==c||c(!1)}finally{n({key:a,value:!1})}},setUserRolesForSubAccount:async t=>{const{userId:a,subTenantsRoles:i,jwt:o,callback:c}=t,u=xo.SET_USER_ROLES_FOR_SUB_ACCOUNT;try{n({key:u,value:!0});const{selectedAccount:t}=r();await e.subTenants.setUserRolesForSubTenants(a,{subTenantsRoles:i},{jwt:o}),await l({jwt:o,_tenantId:t.tenantId}),null==c||c(!0)}catch(t){s({key:u,value:Nn(t)}),null==c||c(!1)}finally{n({key:u,value:!1})}},getUserJwtForSubAccount:async t=>{const{tenantId:a,callback:i}=t,r=xo.GET_USER_JWT;try{n({key:r,value:!0});const t=await e.users.GetUserJwt({tenantId:a});o({userJwt:t,accessPermission:!0}),null==i||i(!0)}catch(t){s({key:r,value:Nn(t)}),o({accessPermission:!1}),null==i||i(!1)}finally{n({key:r,value:!1})}},setRootAccountData:async()=>{const a=xo.SET_ROOT_ACCOUNT_DATA;n({key:a,value:!0});const{activeTenant:o}=t.auth.tenantsState,{accounts:l}=r();if(o)try{var c;const t=await e.tenants.getTenantsUsersCount({tenantIds:[null==o?void 0:o.tenantId]}),a={name:null==o?void 0:o.name,tenantId:null==o?void 0:o.tenantId,numberOfUsers:null==(c=t[0])?void 0:c.totalUsers,createdAt:null==o?void 0:o.createdAt};i({rootAccount:a,accounts:v({},l,a)})}catch(t){s({key:a,value:Nn(t)})}finally{n({key:a,value:!1})}},setSelectedSubAccountData:async t=>{const{jwt:a}=t,i=xo.SET_SELECTED_SUB_ACCOUNT_DATA;try{var r,c,u,d,g,p,h;n({key:i,value:!0});const t=await e.accountSettings.getSettings({jwt:a}),[s,y,S]=await Promise.all([e.tenants.getTenantsUsersCount({tenantIds:[null!=(r=null==t?void 0:t.tenantId)?r:""]},{jwt:a}),e.tenants.getParentTenants({jwt:a}),e.tenants.getHierarchyMetadata({_tenantIds:[null!=(c=null==t?void 0:t.tenantId)?c:""]},{jwt:a})]);o({tenantId:null!=(u=t.tenantId)?u:"",name:t.name,numberOfUsersObject:s[0],parentsAccounts:y,numberOfSubAccounts:null==(d=S[0])?void 0:d.totalSubTenants,accountSettings:t,accounts:{name:t.name,tenantId:null!=(g=t.tenantId)?g:"",numberOfUsers:null==(p=s[0])?void 0:p.totalUsers,createdAt:void 0,children:[]}}),await l({jwt:a,_tenantId:null!=(h=null==t?void 0:t.tenantId)?h:""})}catch(t){s({key:i,value:Nn(t)})}finally{n({key:i,value:!1})}},loadNumberOfUsersForSelectedSubAccount:async t=>{const{tenantId:a,jwt:i}=t,r=xo.LOAD_NUMBER_OF_USERS_FOR_ACCOUNT;try{n({key:r,value:!0});const t=await e.tenants.getTenantsUsersCount({tenantIds:[a]},{jwt:i});o({numberOfUsersObject:t[0]})}catch(t){s({key:r,value:Nn(t)})}finally{n({key:r,value:!1})}}}},zo=(t,e,a)=>({setAllAccountDialogsState:e=>{Object.assign(t.auth.allAccountsDialogsState,e)},resetAllAccountDialogsState:()=>{Cn(t,["auth","allAccountsDialogsState"],Mo)},openCreateSubAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.createSubAccountDialog,v({},e,{open:!0}))},closeCreateSubAccountDialog:()=>{Cn(t,["auth","allAccountsDialogsState","createSubAccountDialog"],Mo.createSubAccountDialog)},openUpdateSubAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.updateSubAccountDialog,v({},e,{open:!0}))},closeUpdateSubAccountDialog:()=>{Cn(t,["auth","allAccountsDialogsState","updateSubAccountDialog"],Mo.updateSubAccountDialog)},openEnableSubAccountManagementDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.enableSubAccountManagementDialog,v({},e,{open:!0}))},closeEnableSubAccountManagementDialog:()=>{Cn(t,["auth","allAccountsDialogsState","enableSubAccountManagementDialog"],Mo.enableSubAccountManagementDialog)},openUpdateSubAccountHierarchySettingsDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.updateSubAccountHierarchySettingsDialog,v({},e,{open:!0}))},closeUpdateSubAccountHierarchySettingsDialog:()=>{Cn(t,["auth","allAccountsDialogsState","updateSubAccountHierarchySettingsDialog"],Mo.updateSubAccountHierarchySettingsDialog)},openDisableSubAccountManagementDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.disableSubAccountManagementDialog,v({},e,{open:!0}))},closeDisableSubAccountManagementDialog:()=>{Cn(t,["auth","allAccountsDialogsState","disableSubAccountManagementDialog"],Mo.disableSubAccountManagementDialog)},openDeleteSubAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.deleteSubAccountDialog,v({},e,{open:!0}))},closeDeleteSubAccountDialog:()=>{Cn(t,["auth","allAccountsDialogsState","deleteSubAccountDialog"],Mo.deleteSubAccountDialog)},openAddUsersToAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.addUsersToAccountDialog,v({},e,{open:!0}))},closeAddUsersToAccountDialog:()=>{Cn(t,["auth","allAccountsDialogsState","addUsersToAccountDialog"],Mo.addUsersToAccountDialog)},openDeleteUserFromAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.deleteUserFromAccountDialog,v({},e,{open:!0}))},closeDeleteUserFromAccountDialog:()=>{Cn(t,["auth","allAccountsDialogsState","deleteUserFromAccountDialog"],Mo.deleteUserFromAccountDialog)},openEditUserRolesDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.editUserRolesDialog,v({},e,{open:!0}))},closeEditUserRolesDialog:()=>{Cn(t,["auth","allAccountsDialogsState","editUserRolesDialog"],Mo.editUserRolesDialog)}}),Ko={devices:[],loading:!1,error:null},qo=t=>en(Ko,t),Jo=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.passkeysState,e)};return{setPasskeysState:s,resetPasskeysState:()=>{Cn(t,["auth","passkeysState"],Ko)},loadWebAuthnDevices:async()=>{s({loading:!0});try{const{devices:t}=await e.auth.getWebAuthnDevices();s({devices:t,loading:!1})}catch(t){s({loading:!1,error:Nn(t,null)})}},deleteWebAuthnDevice:async a=>{const{callback:n,deviceId:i}=a;s({loading:!0});try{await e.auth.deleteWebAuthnDevice(i);const a=t.auth.passkeysState.devices.filter((t=>t.id!==i));s({devices:a,loading:!1}),null==n||n(!0)}catch(t){s({loading:!1,error:Nn(t,null)}),null==n||n(null,t)}},__shouldShowPromptPasskeys:async function(){const{publicAuthStrategyPolicy:a}=t.auth.securityPolicyState,{policy:i}=a,o=await async function(t){var e;return!(null==t||null==(e=t.secondaryAuthStrategies)||!e.some((({isActive:t,strategy:e})=>t&&e===Kt.Passkeys)))}(i),r="Passkeys"===localStorage.getItem("preferred-login-method"),l="true"===localStorage.getItem("dont-show-again-prompt-passkeys"),[c]=await n.getFeatureFlags(["show-passkeys-new"]);if(!c||!o||r||l)return!1;{const{devices:t}=await e.auth.getWebAuthnDevices();return s({devices:null!=t?t:[]}),0===(null!=t&&t.length?t.length:0)}}}},Yo={loading:!1,error:null},Xo=t=>en(Yo,t),Qo=["callback","profilePictureUrl"],Zo=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.profileState,e)};return{setProfileState:s,resetProfileState:()=>{Cn(t,["auth","profileState"],Yo)},loadProfile:async()=>{s({loading:!0});try{const a=await In(e.teams.getProfile,3,2e3),i=t.auth.user;n.setUser(v({},i,a)),s({profile:a,loading:!1})}catch(t){s({loading:!1,error:Nn(t)})}},saveProfile:async a=>{const{callback:i,profilePictureUrl:o}=a,r=f(a,Qo);s({saving:!0,error:null,loading:!0});try{var l;const a=null!=(l=t.auth.profileState.profile)?l:{};let s=a.profilePictureUrl;if(o!==a.profilePictureUrl&&o&&(o||"").match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/)){const t=Pi(o,"image");if(t){s=await e.teams.updateProfileImage(t);const a=Date.now().toString(),n=new URL(s);n.searchParams.set("t",a),s=n.href}}const c=v({},a,r,{profilePictureUrl:s}),u=await e.users.updateUserProfileV2(c),d=t.auth.user;n.setUser(v({},d,u)),n.setProfileState({profile:u,saving:!1,loading:!1}),null==i||i(c)}catch(t){s({saving:!1,error:Nn(t),loading:!1}),null==i||i(null,t)}},changePassword:async t=>{s({loading:!0});try{var a;await e.teams.changePassword(t),s({loading:!1,error:void 0}),null==(a=t.callback)||a.call(t,!0)}catch(e){var n;s({loading:!1,error:Nn(e)}),null==(n=t.callback)||n.call(t,null,e)}}}},tr={loading:!1},er=t=>en(tr,t),ar=["callback"],nr=["id"],sr=(t,e,a)=>{const n=e=>{Object.assign(t.auth.provisioningState,e)},s=async(t,a)=>{const{count:n}=await On((()=>e.directory.countConfigurationUsers(t.id)),a);return v({},t,{count:n})};return{setProvisioningState:n,resetProvisioningState:()=>{Cn(t,["auth","provisioningState"],tr)},__loadCountForConnection:s,loadProvisionConnections:async t=>{n({loading:!0,error:null});try{const a=null==t?void 0:t.retryConfig,i=await On((()=>e.directory.getConfigs()),a),o=await Promise.all(i.map((t=>s(t,a))));n({connections:o,loading:!1})}catch(t){n({error:Nn(t),loading:!1})}},createProvisionConnection:async t=>{const{callback:a}=t,i=f(t,ar);n({loading:!0,error:null});try{const t=await e.directory.createConfiguration(i),o=await e.directory.getConfigs(),r=await Promise.all(o.map((t=>s(t))));n({connections:r,loading:!1}),null==a||a(t)}catch(t){n({error:Nn(t),loading:!1})}},deleteProvisionConnection:async t=>{const{id:a,callback:i}=t;n({loading:!0,error:null});try{await e.directory.deleteConfiguration(a,t.deleteAll);const o=await e.directory.getConfigs(),r=await Promise.all(o.map((t=>s(t))));n({connections:r,loading:!1}),null==i||i(!0)}catch(t){n({error:Nn(t),loading:!1}),null==i||i(!1,t)}},updateProvisionConnection:async t=>{const{id:a}=t,i=f(t,nr);n({loading:!0,error:null});try{await e.directory.updateConfiguration(a,i);const t=await e.directory.getConfigs(),o=await Promise.all(t.map((t=>s(t))));n({connections:o,loading:!1})}catch(t){n({error:Nn(t),loading:!1})}}}};let ir;!function(t){t.ResetPhoneNumber="ResetPhoneNumber",t.VerifyResetPhoneNumber="VerifyResetPhoneNumber",t.ChangePhoneNumber="ChangePhoneNumber"}(ir||(ir={}));const or={step:ir.ResetPhoneNumber,loading:!1},rr=t=>en(or,t),lr=["callback"],cr=["callback"],ur=["callback"],dr=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.resetPhoneNumberState,e)};return{setResetPhoneNumberState:s,resetResetPhoneNumberState:()=>{Cn(t,["auth","resetPhoneNumberState"],or)},resetPhoneNumber:async t=>{const{callback:a}=t,i=f(t,lr);s({loading:!0});try{const t=await e.auth.resetPhoneNumber(i);s({loading:!1,error:void 0,resetPhoneNumberToken:t.resetPhoneNumberToken,step:ir.VerifyResetPhoneNumber}),n.setLoginState({email:i.email})}catch(t){s({loading:!1,error:Nn(t)}),null==a||a(null,t)}},verifyResetPhoneNumber:async t=>{const{callback:a}=t,n=f(t,cr);s({loading:!0});try{const t=await e.auth.verifyResetPhoneNumber(n);s({loading:!1,error:void 0,changePhoneNumberToken:t.changePhoneNumberToken,step:ir.ChangePhoneNumber}),null==a||a(!0)}catch(t){s({loading:!1,error:Nn(t)}),null==a||a(null,t)}},changePhoneNumber:async a=>{const{callback:i}=a,o=f(a,ur);s({loading:!0});try{const{onRedirectTo:a,routes:r}=t.auth;await e.auth.changePhoneNumber({phoneNumber:o.phoneNumber,changePhoneNumberToken:o.changePhoneNumberToken}),n.setLoginState({step:yn.loginWithSmsOtc}),await n.passwordlessPreLogin({type:N.SmsCode,email:o.email,recaptchaToken:o.recaptchaToken}),a(r.loginUrl),s({loading:!1}),null==i||i(!0)}catch(t){s({loading:!1,error:Nn(t)}),null==i||i(null,t)}}}},gr={loaders:{},errors:{},roles:[],permissions:[],permissionCategories:[]},pr=t=>en(gr,t);let hr;!function(t){t.EDIT_ROLE_DIALOG="editRoleDialog",t.DELETE_ROLE_DIALOG="deleteRoleDialog",t.LOAD_ROLES="loadRoles",t.ADD_ROLE="addRole",t.MANAGE_PERMISSIONS="managePermissions"}(hr||(hr={}));const yr=["callback"],Sr=["callback"],vr=["callback"],fr=["callback"],mr=["callback"],br=["callback"],Ar=(t,e,a)=>{const n=e=>{Object.assign(t.auth.rolesState,e)},s=e=>{Object.assign(t.auth.rolesState,{loaders:v({},t.auth.rolesState.loaders,{[e.key]:e.value})})},i=e=>{Object.assign(t.auth.rolesState,{errors:v({},t.auth.rolesState.errors,{[e.key]:e.value}),loaders:v({},t.auth.rolesState.loaders,{[e.key]:!1})})},o=async a=>{var o;const r=hr.LOAD_ROLES;s({key:r,value:!(null!=(o=null==a?void 0:a.silentLoading)&&o)});try{const s=null==a?void 0:a.retryConfig,[i,o,r]=await Promise.all([On((()=>e.roles.getRoles()),s),On((()=>e.roles.getPermissions()),s),On((()=>e.roles.getPermissionCategories()),s)]),{selectedRole:l}=t.auth.rolesState,c=null==i?void 0:i.find((({id:t})=>(null==l?void 0:l.id)===t));n({roles:i,permissions:o,permissionCategories:r,selectedRole:c})}catch(t){i({key:r,value:Nn(t)})}finally{s({key:r,value:!1})}},r=async t=>{const{callback:a}=t,r=f(t,mr),l=hr.MANAGE_PERMISSIONS;s({key:l,value:!0});try{const t=await e.roles.attachPermissionsToRole(r);await o({silentLoading:!0}),n({saving:!1}),null==a||a(t)}catch(t){i({key:l,value:Nn(t)}),null==a||a(null,t)}finally{s({key:l,value:!1})}};return{setRolesState:n,setRolesStateLoader:s,setRolesStateError:i,resetRolesState:()=>{Cn(t,["auth","rolesState"],gr)},loadRolesAndPermissions:o,addRole:async t=>{const{callback:a}=t,n=f(t,yr),r=hr.ADD_ROLE;s({key:r,value:!0});try{const t=await e.roles.addRole(n);await o({silentLoading:!0}),null==a||a(t)}catch(t){i({key:r,value:Nn(t)}),null==a||a(null,t)}finally{s({key:r,value:!1})}},addRoleV2:async t=>{const{callback:a}=t,n=f(t,Sr),r=hr.ADD_ROLE;s({key:r,value:!0});try{const t=await e.roles.addRoleV2(n);await o({silentLoading:!0}),null==a||a(t)}catch(t){i({key:r,value:Nn(t)}),null==a||a(null,t)}finally{s({key:r,value:!1})}},updateRole:async t=>{const{callback:a}=t,r=f(t,vr),l=hr.EDIT_ROLE_DIALOG;s({key:l,value:!0});try{const t=await e.roles.updateRole(r);await o({silentLoading:!0}),n({saving:!1}),null==a||a(t)}catch(t){i({key:l,value:Nn(t)}),null==a||a(null,t)}finally{s({key:l,value:!1})}},deleteRole:async t=>{const{callback:a}=t,r=f(t,fr),l=hr.DELETE_ROLE_DIALOG;s({key:l,value:!0});try{await e.roles.deleteRole(r),await o({silentLoading:!0}),n({saving:!1}),null==a||a(!0)}catch(t){i({key:l,value:Nn(t)}),null==a||a(!1,t)}finally{s({key:l,value:!1})}},attachPermissionsToRole:r,attachPermissionToRoles:async t=>{const{callback:e}=t,a=f(t,br),n=hr.MANAGE_PERMISSIONS;s({key:n,value:!0});try{await Promise.all(a.roleIds.map((t=>r({roleId:t,permissionIds:[a.permissionId]})))),await o({silentLoading:!0}),null==e||e(!0)}catch(t){i({key:n,value:Nn(t)}),null==e||e(null,t)}finally{s({key:n,value:!1})}}}},wr={ipRestrictions:{loading:!1,pagination:{_offset:0,_limit:4,_filter:zt.ALLOW},totalPages:1,userIpValid:!1},emailDomainRestrictions:{loading:!1}},Tr=t=>en(wr,t),Er=["callback"],Ir=["callback"],Or=["callback"],Pr=["callback"],kr=(t,e,a)=>{const n=a,s=t=>{var e,a,n;return{_filter:null!=(e=null==t?void 0:t._filter)?e:zt.ALLOW,_limit:null!=(a=null==t?void 0:t._limit)?a:10,_offset:null!=(n=null==t?void 0:t._offset)?n:0}},i=t=>async(...e)=>{const[a]=await n.getFeatureFlags(["security-center-admin-portal-major-version"]);await t(...e),a&&(await n.loadRecommendations(Pn()),await n.loadInsights(Pn()))},o=e=>{Object.assign(t.auth.restrictionsState.ipRestrictions,e)},r=e=>{Object.assign(t.auth.restrictionsState.emailDomainRestrictions,e)},l=async()=>{try{const{valid:t}=await e.auth.testCurrentIpInAllowList();o({userIpValid:t})}catch(t){o({error:Nn(t)})}},c=i((async()=>{o({loading:!0,error:null});try{const a=t.auth.restrictionsState.ipRestrictions,n=await e.auth.getIPRestrictionsConfig(),i=s({_filter:n.strategy,_limit:a.pagination._limit,_offset:a.pagination._offset}),{items:r,_metadata:{totalPages:l}}=await e.auth.getIPRestrictions(i);o({data:{restrictions:r,config:n},totalPages:l,pagination:i,loading:!1})}catch(t){o({error:Nn(t),loading:!1})}})),u=i((async a=>{const{callback:n}=a,i=f(a,Er);o({saving:!0,error:null});try{var r,c;await e.auth.createIPRestriction(i);const a=t.auth.restrictionsState.ipRestrictions,u=s(a.pagination),{items:d,_metadata:{totalPages:g}}=await e.auth.getIPRestrictions(u),p=d;await l(),o({data:{config:null!=(r=null==(c=a.data)?void 0:c.config)?r:{isActive:!1,strategy:zt.ALLOW},restrictions:p},pagination:u,totalPages:g,saving:!1}),null==n||n(!0)}catch(t){o({saving:!1,error:Nn(t)}),null==n||n(null,t)}})),d=i((async a=>{const{callback:n}=a,i=f(a,Ir);o({saving:!0,error:null});try{await e.auth.updateIPRestrictionConfig(i);const a=t.auth.restrictionsState.ipRestrictions,r=await e.auth.getIPRestrictionsConfig(),c=s(v({},a.pagination,{_filter:r.strategy})),{items:u,_metadata:{totalPages:d}}=await e.auth.getIPRestrictions(c),g=u;await l(),o({data:{config:r,restrictions:g},pagination:c,totalPages:d,saving:!1}),null==n||n(!0)}catch(t){o({saving:!1,error:Nn(t)}),null==n||n(null,t)}})),g=i((async a=>{const{id:n,callback:i}=a;o({saving:!0,error:null});try{var r;await e.auth.deleteIPRestriction(n);const a=t.auth.restrictionsState.ipRestrictions,c=s(a.pagination),{items:u,_metadata:{totalPages:d}}=await e.auth.getIPRestrictions(c),g=u;await l(),o({data:{config:(null==(r=a.data)?void 0:r.config)||{isActive:!1,strategy:zt.ALLOW},restrictions:g},pagination:c,totalPages:d,saving:!1}),null==i||i(!0)}catch(t){o({saving:!1,error:Nn(t)}),null==i||i(null,t)}})),p=i(l),h=i((async a=>{const{callback:n}=a;o({saving:!0,error:null});try{var i,r;const a=null!=(i=(null==(r=t.auth.userIpData)?void 0:r.ip)||t.auth.userIp)?i:"";await Promise.all([e.auth.createIPRestriction({ip:a,isActive:!0,description:"My IP",strategy:zt.ALLOW}),e.auth.updateIPRestrictionConfig({isActive:!0})]);const l=t.auth.restrictionsState.ipRestrictions,c=s(l.pagination),{items:u,_metadata:{totalPages:d}}=await e.auth.getIPRestrictions(c),g=u;o({data:{config:{isActive:!0,strategy:zt.ALLOW},restrictions:g},userIpValid:!0,pagination:c,totalPages:d,saving:!1}),null==n||n(!0)}catch(t){o({saving:!1,error:t}),null==n||n(!1,t)}})),y=i((async()=>{r({loading:!0,error:null});try{const t=await e.auth.getDomainRestrictionsConfig(),a=(await e.auth.getDomainRestrictions()).items.filter((e=>e.type===t.listType));r({data:{restrictions:a,config:t},loading:!1})}catch(t){r({error:Nn(t),loading:!1})}})),S=i((async a=>{const{callback:n}=a,s=f(a,Or);r({saving:!0,error:null});const i=t.auth.restrictionsState.emailDomainRestrictions;try{var o;await e.auth.createDomainRestriction(s);const t=(await e.auth.getDomainRestrictions()).items.filter((t=>{var e;return t.type===(null==(e=i.data)?void 0:e.config.listType)}));r({data:{config:(null==(o=i.data)?void 0:o.config)||{active:!1,blockPublicDomains:!1,listType:s.type},restrictions:t},saving:!1}),null==n||n(!0)}catch(t){r({saving:!1,error:Nn(t)}),null==n||n(null,t)}})),m=i((async t=>{const{callback:a}=t,n=f(t,Pr);r({saving:!0,error:null});try{const t=await e.auth.updateDomainRestrictionConfig(n),s=(await e.auth.getDomainRestrictions()).items.filter((e=>e.type===t.listType));r({data:{config:t,restrictions:s},saving:!1}),null==a||a(!0)}catch(t){r({saving:!1,error:Nn(t)}),null==a||a(null,t)}})),b=i((async a=>{const{id:n}=a;r({saving:!0,error:null});const s=t.auth.restrictionsState.emailDomainRestrictions;try{var i;await e.auth.deleteDomainRestriction(n);const t=(await e.auth.getDomainRestrictions()).items.filter((t=>{var e;return t.type===(null==(e=s.data)?void 0:e.config.listType)}));r({data:{config:(null==(i=s.data)?void 0:i.config)||{active:!1,blockPublicDomains:!1,listType:zt.ALLOW},restrictions:t},saving:!1})}catch(t){r({saving:!1,error:Nn(t)})}}));return{setRestrictionsState:e=>{Object.assign(t.auth.restrictionsState,e)},setIpRestrictionsState:o,setEmailDomainRestrictionsState:r,__securityCenterSagaWrapper:i,loadIpRestrictions:c,saveIpRestriction:u,saveIpRestrictionsConfig:d,deleteIpRestriction:g,checkIfUserIpValid:p,addCurrentUserIpAndActivate:h,loadEmailDomainRestrictions:y,saveEmailDomainRestriction:S,saveEmailDomainRestrictionsConfig:m,deleteEmailDomainRestriction:b}},_r={loaders:{},errors:{},recommendations:void 0,insights:void 0,hasSecurityChanges:!1,score:0,breachedPasswordUsersTable:{users:[],usersPageOffset:0,totalUsersItems:0,totalUsersPages:0,queryParams:{_offset:0,_limit:10}},unenrolledMfaUsersTable:{users:[],usersPageOffset:0,totalUsersItems:0,totalUsersPages:0,queryParams:{_offset:0,_limit:10}},inactiveUsersTable:{users:[],usersPageOffset:0,totalUsersItems:0,totalUsersPages:0,queryParams:{_offset:0,_limit:10,_maxInactiveSeconds:7776e3}}},Rr=t=>en(_r,t);let Ur;!function(t){t.RECOMMENDATIONS="recommendations",t.INSIGHTS="insights",t.SEND_BULK_RESET_BREACHED_PASSWORD_EMAILS="sendBulkResetBreachedPasswordEmails",t.SEND_BREACHED_PASSWORD_EMAIL="sendBreachedPasswordEmail",t.BREACHED_PASSWORD_USERS_TABLE="breachedPasswordUsersTable",t.UNENROLLED_MFA_USERS_TABLE="unenrolledMfaUsersTable",t.INACTIVE_USERS_TABLE="inactiveUsersTable"}(Ur||(Ur={}));const Cr=["callback"],Lr=(t,e,a)=>{const n=a,s=async t=>{var a,s,l,c;const{key:u,tableState:d,updateStateKey:g,_offset:p,_limit:h,_preset:y,_email:S,_maxInactiveSeconds:f}=t;r({key:u,value:!1}),o({key:u,value:!0});const m=null!=(a=null!=p?p:null==d||null==(s=d.queryParams)?void 0:s._offset)?a:0,b=null!=(l=null!=h?h:null==d||null==(c=d.queryParams)?void 0:c._limit)?l:10,A=v({_offset:m,_limit:b,_includeSubTenants:!1,_preset:y,_maxInactiveSeconds:f},!!S&&{_email:S});try{const{items:t,_metadata:{totalItems:a,totalPages:s}}=await e.users.getUsersV3(A),o={totalUsersItems:a,totalUsersPages:s,usersPageOffset:m,queryParams:v({_offset:m,_limit:b,_maxInactiveSeconds:f},!!S&&{_email:S})};if(t.length){const a=await(async t=>{const a=t.map((t=>t.id)),n=await e.roles.getRoles(),s=await e.users.getUsersRoles({ids:a});return t.map((t=>{var e,a;const i=null==s||null==(e=s.find((e=>e.userId===t.id)))?void 0:e.roleIds;return v({},t,{roles:null!=(a=null==i?void 0:i.map((t=>{var e;return null!=(e=null==n?void 0:n.find((e=>e.id===t)))?e:[]})))?a:[]})}))})(t);n.setSecurityCenterState({[g]:v({users:a},o)})}else i({[g]:v({users:[]},o)})}catch(t){r({key:u,value:Nn(t)})}finally{o({key:u,value:!1})}},i=e=>{Object.assign(t.auth.securityCenterState,e)},o=e=>{Object.assign(t.auth.securityCenterState,{loaders:v({},t.auth.securityCenterState.loaders,{[e.key]:e.value})})},r=e=>{Object.assign(t.auth.securityCenterState,{errors:v({},t.auth.securityCenterState.errors,{[e.key]:e.value}),loaders:v({},t.auth.securityCenterState.loaders,{[e.key]:!1})})};return{setSecurityCenterState:i,resetSecurityCenterState:()=>{Cn(t,["auth","securityCenterState"],_r)},setSecurityCenterStateLoader:o,setSecurityCenterStateError:r,loadRecommendations:async t=>{const a=Ur.RECOMMENDATIONS;o({key:a,value:!0});try{var n;const{recommendations:a,scoring:s}=await On((()=>e.securityCenter.getRecommendations()),null==t?void 0:t.retryConfig);i({recommendations:a.items,score:null!=(n=null==s?void 0:s.score)?n:0})}catch(t){r({key:a,value:Nn(t)})}finally{o({key:a,value:!1})}},loadInsights:async t=>{const a=Ur.INSIGHTS;o({key:a,value:!0});try{const{insights:a}=await await On((()=>e.securityCenter.getInsights()),null==t?void 0:t.retryConfig);i({insights:a.items})}catch(t){r({key:a,value:Nn(t)})}finally{o({key:a,value:!1})}},sendResetBreachedPasswordEmail:async t=>{const{callback:a}=t,n=f(t,Cr),s=Ur.SEND_BREACHED_PASSWORD_EMAIL;r({key:s,value:!1}),o({key:s,value:!0});try{await e.auth.forgotPassword(n),null==a||a(!0)}catch(t){r({key:s,value:Nn(t)}),null==a||a(!1,t)}finally{o({key:s,value:!1})}},sendBulkResetBreachedPasswordEmails:async t=>{const{callback:a}=t,n=Ur.SEND_BULK_RESET_BREACHED_PASSWORD_EMAILS;r({key:n,value:!1}),o({key:n,value:!0});try{await e.users.sendResetBreachedPasswordEmails(),null==a||a(!0)}catch(t){r({key:n,value:Nn(t)}),null==a||a(!1)}finally{o({key:n,value:!1})}},loadBreachedPasswordUsers:async e=>{var a;const n=Ur.BREACHED_PASSWORD_USERS_TABLE,i=null==(a=t.auth.securityCenterState)?void 0:a.breachedPasswordUsersTable;await s(v({key:n,updateStateKey:"breachedPasswordUsersTable",_preset:ja.BREACHED_PASSWORDS,tableState:i},e))},loadUnenrolledMfaUsers:async e=>{var a;const n=Ur.UNENROLLED_MFA_USERS_TABLE,i=null==(a=t.auth.securityCenterState)?void 0:a.unenrolledMfaUsersTable;await s(v({key:n,updateStateKey:"unenrolledMfaUsersTable",_preset:ja.MFA_UNENROLLED,tableState:i},e))},loadInactiveUsers:async e=>{var a;const n=Ur.INACTIVE_USERS_TABLE,i=null==(a=t.auth.securityCenterState)?void 0:a.inactiveUsersTable;await s(v({key:n,updateStateKey:"inactiveUsersTable",_preset:ja.INACTIVE,tableState:i},e))},markSecurityCenterStateAsChanged:(t=!0)=>{i({hasSecurityChanges:t})}}},Dr={globalPolicy:{loading:!0},publicPolicy:{loading:!1},vendorMfaPolicy:{loading:!0},mfaPolicy:{loading:!0},vendorLockoutPolicy:{loading:!0},lockoutPolicy:{loading:!0},captchaPolicy:{loading:!0},passwordHistoryPolicy:{loading:!0},passwordPolicy:{loading:!0},vendorPasswordHistoryPolicy:{loading:!0},publicAuthStrategyPolicy:{loading:!0},passwordRotationPolicy:{loading:!0}},Nr=t=>en(Dr,t);function Mr(t,e){const a=null!=e,n=null!=t;if(a||n)return a?n?Math.min(t,e):e:t}const Fr=["callback"],xr=["callback"],$r=["callback"],Gr=["callback"],jr=(t,e,a)=>{const n=a,s=async(t,e)=>{var a,s;if(!await n.customLoginEnabled())return t;const o=await i(e);return null!=o&&null!=(a=o.mainAuthStrategies)&&null!=(s=a[0])&&s.strategy?v({},t,{authStrategy:o.mainAuthStrategies[0].strategy}):t},i=async a=>{let n;return n=t.auth.isAuthenticated?await On(e.auth.getPublicAuthStrategiesConfigForAuthenticatedUser,a):await On(e.auth.getVendorPublicAuthStrategiesConfig,a),n},o=e=>{Object.assign(t.auth.securityPolicyState.globalPolicy,e)},r=e=>{Object.assign(t.auth.securityPolicyState.publicPolicy,e)},l=e=>{Object.assign(t.auth.securityPolicyState.mfaPolicy,e)},c=e=>{Object.assign(t.auth.securityPolicyState.vendorMfaPolicy,e)},u=e=>{Object.assign(t.auth.securityPolicyState.lockoutPolicy,e)},d=e=>{Object.assign(t.auth.securityPolicyState.vendorLockoutPolicy,e)},g=e=>{Object.assign(t.auth.securityPolicyState.captchaPolicy,e)},p=e=>{Object.assign(t.auth.securityPolicyState.passwordHistoryPolicy,e)},h=e=>{Object.assign(t.auth.securityPolicyState.vendorPasswordHistoryPolicy,e)},y=e=>{Object.assign(t.auth.securityPolicyState.passwordRotationPolicy,e)},S=e=>{Object.assign(t.auth.securityPolicyState.passwordPolicy,e)},m=e=>{Object.assign(t.auth.securityPolicyState.publicAuthStrategyPolicy,e)},b=async t=>{o({loading:!0,error:null});try{const a=await On((()=>e.auth.getGlobalSecurityPolicy()),null==t?void 0:t.retryConfig);o({policy:a,loading:!1})}catch(t){o({error:Nn(t),loading:!1})}},A=async t=>{l({loading:!0,error:null});try{const a=await On((()=>e.auth.getMfaPolicy()),null==t?void 0:t.retryConfig);l({policy:a,loading:!1})}catch(t){l({error:Nn(t),loading:!1})}},w=async t=>{l({loading:!0,error:null});try{const a=await On((()=>e.auth.getVendorMfaPolicy()),null==t?void 0:t.retryConfig);c({policy:a,loading:!1})}catch(t){c({error:Nn(t),loading:!1})}},T=async t=>{u({loading:!0,error:null});try{const a=await On((()=>e.auth.getLockoutPolicy()),null==t?void 0:t.retryConfig);u({policy:a,loading:!1})}catch(t){u({error:Nn(t),loading:!1})}},E=async t=>{d({loading:!0,error:null});try{const a=await On((()=>e.auth.getVendorLockoutPolicy()),null==t?void 0:t.retryConfig);d({policy:a,loading:!1})}catch(t){d({error:Nn(t),loading:!1})}},I=async t=>{u({loading:!0,error:null});try{const a=await On((()=>e.auth.getCaptchaPolicy()),null==t?void 0:t.retryConfig);g({policy:a,loading:!1})}catch(t){g({error:Nn(t),loading:!1})}},O=async t=>{h({loading:!0,error:null});try{const a=await On((()=>e.auth.getVendorPasswordHistoryPolicy()),null==t?void 0:t.retryConfig);h({policy:a,loading:!1})}catch(t){h({error:Nn(t),loading:!1})}},P=async e=>{m({loading:!0,error:null});try{var a,s,o;const l=await i(null==e?void 0:e.retryConfig);await(async e=>{var a,s;const i=await n.customLoginEnabled();if(!e||!i)return;const{policy:o}=null!=(a=null==(s=t.auth.securityPolicyState)?void 0:s.publicPolicy)?a:{policy:null};r({policy:v({},o,{authStrategy:e}),loading:!1})})(null==l||null==(a=l.mainAuthStrategies)||null==(s=a[0])?void 0:s.strategy),m({policy:l,loading:!1}),null==e||null==(o=e.callback)||o.call(e,l)}catch(t){var l;m({error:Nn(t),loading:!1}),null==e||null==(l=e.callback)||l.call(e,null,t)}};return{setSecurityPolicyState:e=>{Object.assign(t.auth.securityPolicyState,e)},setSecurityPolicyGlobalState:o,setSecurityPolicyPublicState:r,setSecurityPolicyMfaState:l,setSecurityPolicyVendorMfaState:c,setSecurityPolicyLockoutState:u,setSecurityPolicyVendorLockoutState:d,setSecurityPolicyCaptchaState:g,setSecurityPolicyPasswordHistoryState:p,setSecurityPolicyVendorPasswordHistoryState:h,setSecurityPolicyPasswordRotationState:y,resetSecurityPolicyState:()=>{Cn(t,["auth","securityPolicyState"],Dr)},setSecurityPolicyPasswordState:S,setSecurityPolicyAuthStrategyPublicState:m,loadSecurityPolicy:async t=>{const e={retryConfig:null==t?void 0:t.retryConfig};await Promise.all([b(),A(),w(e),T(e),E(e),O(),I(e),P(e)])},loadGlobalSecurityPolicy:b,loadPublicSecurityPolicy:async t=>{r({loading:!0,error:null});try{const a=await e.auth.getVendorConfig(),n=await s(a,null==t?void 0:t.retryConfig);r({policy:n,loading:!1})}catch(t){r({error:Nn(t),loading:!1})}},loadVendorPasswordConfig:async t=>{S({loading:!0,error:null});try{var a;const n=await On((()=>e.auth.getPasswordConfigPolicy()),null==t?void 0:t.retryConfig);S({policy:n,loading:!1}),null==t||null==(a=t.callback)||a.call(t,n)}catch(e){var n;S({error:Nn(e),loading:!1}),null==t||null==(n=t.callback)||n.call(t,null,e)}},loadSecurityPolicyMfa:A,loadSecurityPolicyVendorMfa:w,loadSecurityPolicyLockout:T,loadSecurityPolicyVendorLockout:E,loadSecurityPolicyCaptcha:I,loadSecurityPolicyPasswordHistory:async()=>{p({loading:!0,error:null});try{const t=await e.auth.getPasswordHistoryPolicy();p({policy:t,loading:!1})}catch(t){p({error:Nn(t),loading:!1})}},loadSecurityPolicyVendorPasswordHistory:O,loadSecurityPolicyPasswordRotation:async()=>{y({loading:!0,error:null});try{const t=await e.securityPolicy.getPasswordRotationPolicy(),a=await e.securityPolicy.getVendorPasswordRotationPolicy(),n={passwordRotationVendorConfig:a};t&&(null!=a&&a.isActive?n.passwordRotationTenantConfig=null!=t&&t.isActive?v({},t,{rotationPeriod:Mr(a.rotationPeriod,t.rotationPeriod)}):a:n.passwordRotationTenantConfig=t),y({policy:v({},n),loading:!1})}catch(t){y({error:Nn(t),loading:!1})}},loadPublicAuthStrategiesPolicy:P,saveSecurityPolicyMfa:async t=>{const{callback:a}=t,n=f(t,Fr);l({saving:!0,error:null});try{const t=await e.auth.securityPolicy.saveMfaPolicy(n);l({policy:t,saving:!1}),null==a||a(t)}catch(t){l({saving:!1,error:Nn(t)}),null==a||a(null,t)}},saveSecurityPolicyLockout:async t=>{const{callback:a}=t,n=f(t,xr);u({saving:!0,error:null});try{const t=await e.auth.saveLockoutPolicy(n);u({policy:t,saving:!1}),null==a||a(t)}catch(t){u({saving:!1,error:Nn(t)}),null==a||a(null,t)}},saveSecurityPolicyPasswordHistory:async t=>{const{callback:a}=t,n=f(t,$r);p({saving:!0,error:null});try{const t=await e.auth.savePasswordHistoryPolicy(n);p({policy:t,saving:!1}),null==a||a(t)}catch(t){p({saving:!1,error:Nn(t)}),null==a||a(null,t)}},saveSecurityPolicyPasswordRotation:async t=>{const{callback:a}=t,n=f(t,Gr);y({saving:!0,error:null});try{await e.securityPolicy.savePasswordRotationPolicy(n.passwordRotationTenantConfig||{}),y({policy:n,saving:!1}),null==a||a(n)}catch(t){y({saving:!1,error:Nn(t)}),null==a||a(null,t)}},__getSecurityPolicyPublicStateWithCustomLogin:s}},Br={loading:!1,configurations:{}},Vr=t=>en(Br,t),Wr=["callback"],Hr=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.sessionsPolicyState,e)};return{setSessionsPolicyState:s,resetSessionsPolicyState:()=>{Cn(t,["auth","sessionsPolicyState"],Br)},loadSessionsPolicy:async()=>{s({loading:!0,error:null});try{const t=await e.auth.getSessionConfigurations();s({configurations:t,loading:!1})}catch(t){n.setSessionsState({error:t,loading:!1})}},createOrUpdateSessionsPolicy:async t=>{const{callback:a}=t,i=f(t,Wr);try{s({loading:!0,error:null}),await e.auth.createOrUpdateSessionConfigrations(i),await n.loadSessionsPolicy(),null==a||a(!0)}catch(t){s({error:t,loading:!1})}}}},zr={loading:!1,sessions:[]},Kr=t=>en(zr,t),qr=(t,e,a)=>{const n=e=>{Object.assign(t.auth.sessionsState,e)},s=async t=>{n({loading:!0,error:null});try{const a=await On((()=>e.auth.getCurrentUserSessions()),null==t?void 0:t.retryConfig);n({sessions:a,loading:!1})}catch(t){n({error:Nn(t),loading:!1})}};return{setSessionsState:n,resetSessionsState:()=>{Cn(t,["auth","sessionsState"],zr)},loadUserSessions:s,loadCurrentUserSession:async()=>{n({loading:!0,error:null});try{const t=await e.auth.getCurrentUserSession();n({currentSession:t,loading:!1})}catch(t){n({error:Nn(t),loading:!1})}},deleteUserSession:async t=>{const{id:a}=t;n({loading:!0,error:null});try{await e.auth.deleteSessionForUser(a),await s()}catch(t){n({error:Nn(t),loading:!1})}},deleteAllUserSessions:async()=>{n({loading:!0,error:null});try{await e.auth.deleteAllSessionsForUser(),await s()}catch(t){n({error:Nn(t),loading:!1})}},revokeUserSessions:async t=>{const{callback:a,userId:s}=t;n({loading:!0,error:null});try{await e.auth.revokeSessionsForUser(s),n({loading:!1}),null==a||a(!0)}catch(t){n({error:Nn(t),loading:!1}),null==a||a(!1)}}}};let Jr;!function(t){t.SignUp="SignUp",t.SignUpSuccess="SignUpSuccess",t.VerifyPhone="VerifyPhone"}(Jr||(Jr={}));const Yr={loading:!1,allowSignUps:!1,allowNotVerifiedUsersLogin:!1,firstLoad:!0,stage:Jr.SignUp,strategies:{[F.Email]:{enabled:!0,required:!0},[F.PhoneNumber]:{enabled:!1,required:!1}}},Xr=t=>en(Yr,t),Qr=["events","url"],Zr=["events","url"],tl=(t,e,a)=>{const n=a,s=U.for(t.root.appName),i=e=>{Object.assign(t.auth.signUpState,e)},o=()=>{Cn(t,["auth","signUpState"],Yr)},r=(t,e,a,n,s,i=zn.PASSWORD)=>{var o;const{email:r,name:l,companyName:c,phoneNumber:u,url:d}=t,g={email:r,name:l,companyName:c,url:d,phoneNumber:u||void 0,authenticationType:i,id:e,tenantId:a,createdAt:new Date,activationToken:n};null==s||null==(o=s.signUpComplete)||o.call(s,g),Xn(Jn.SIGNUP_COMPLETED,g)},l=async a=>{const{events:o}=a,l=f(a,Qr);if(i({loading:!0}),!l.phoneNumber)throw new Error("Phone number is required for phone number signup");try{var c,u,d;const{routes:a,onRedirectTo:s}=t.auth,{tenantId:i,userId:g,activationToken:p}=await e.auth.signUpUserWithPhoneNumber(bs(l));l.invitationToken||r(l,g,i,p,o,zn.PHONE_NUMBER);const{enabled:h,siteKey:y}=null!=(c=t.auth.securityPolicyState.captchaPolicy.policy)?c:{},S=h&&y?await(null==(u=window.grecaptcha)||null==(d=u.execute)?void 0:d.call(u,{action:"login"})):"";n.passwordlessPreLogin({recaptchaToken:S,phoneNumber:l.phoneNumber,type:N.SmsCode,callback:(t,e)=>{if(!t&&e)throw e;s(a.loginUrl),n.setLoginState({step:yn.loginWithSmsOtc,phoneNumber:l.phoneNumber})}})}catch(t){s.setAccessToken(null),s.setUser(null),i({error:Nn(t)})}finally{i({loading:!1})}};return{setSignUpState:i,resetSignUpState:o,resetSignUpStateSoft:()=>{const{allowSignUps:e,allowNotVerifiedUsersLogin:a}=t.auth.signUpState;o(),i({allowSignUps:e,allowNotVerifiedUsersLogin:a})},signUpUser:async a=>{const{events:o}=a,c=f(a,Zr);i({loading:!0});const u=t.auth.signUpState.strategies.phoneNumber;if(null!=u&&u.required&&null!=u&&u.enabled&&c.phoneNumber)return l(a);try{const{routes:a,onRedirectTo:s}=t.auth,{shouldActivate:l,user:u,tenantId:d,userId:g,tenants:p=[],activeTenant:h,activationToken:y}=await e.auth.signUpUser(bs(c));if(c.invitationToken||r(c,g,d,y,o),!l&&u&&Ss(u,t.root.appName)){const t=await n.getMfaRequiredState(u,Tn,!0,c.email);n.setAuthState(t),s(a.loginUrl)}else if(l&&y){const t=new URLSearchParams({userId:g||"",token:y||""}),e=`${a.activateWithOTCUrl}?${t.toString()}`;i({loading:!1,shouldActivate:l,stage:Jr.SignUpSuccess}),s(e)}else{const e=t.auth.tenantsState;i({loading:!1,shouldActivate:l,stage:Jr.SignUpSuccess}),n.setAuthState({user:u,isAuthenticated:!(null==u||!u.accessToken),tenantsState:v({},e,{tenants:p,activeTenant:h})})}}catch(t){s.setAccessToken(null),s.setUser(null),i({error:Nn(t)})}finally{i({loading:!1})}},signUpUserWithPhoneNumber:l,loadAllowSignUps:async t=>{i({loading:!0});try{var a;const s=await On(e.auth.getVendorConfig,null==t?void 0:t.retryConfig),o=await n.__getSecurityPolicyPublicStateWithCustomLogin(s,null==t?void 0:t.retryConfig),{allowSignups:r,allowNotVerifiedUsersLogin:l}=s;i({loading:!1,allowSignUps:r,allowNotVerifiedUsersLogin:l,firstLoad:!1}),n.setSecurityPolicyPublicState({policy:o,loading:!1}),null==t||null==(a=t.callback)||a.call(t,o||s)}catch(e){var s;i({loading:!1,error:Nn(e),firstLoad:!1}),null==t||null==(s=t.callback)||s.call(t,null,e)}},loadSignUpStrategies:async()=>{try{const t=await e.auth.getSignUpStrategies();i({strategies:t.reduce(((t,{isActive:e,strategy:a,isRequired:n})=>(t[a]={enabled:e,required:n},t)),{})})}catch(t){}}}},el={loading:!1,error:null,phoneNumbers:void 0},al=t=>en(el,t),nl=["callback"],sl=["callback"],il=["callback"],ol=["callback","phoneId"],rl=["callback","phoneId"],ll=["callback"],cl=(t,e,a)=>{const n=e=>{Object.assign(t.auth.smsState,e)},s=async()=>{n({loading:!0});const t={_limit:10,_offset:0};try{const{items:a}=await e.userPhoneNumbers.getUserPhoneNumbers(t);n({phoneNumbers:a})}catch(t){n({error:Nn(t)})}finally{n({loading:!1})}},i=async()=>{n({loading:!0});try{const t=await e.userPhoneNumbers.getUserOwnPhoneNumbers();n({phoneNumbers:t})}catch(t){n({error:Nn(t)})}finally{n({loading:!1})}};return{setSmsState:n,resetSmsState:()=>{Cn(t,["auth","smsState"],el)},loadPhoneNumbers:s,loadUserOwnPhoneNumbers:i,setUpPhoneNumber:async t=>{const{callback:a}=t,i=f(t,sl);try{const{otcToken:t}=await e.userPhoneNumbers.createPhoneNumber(i);n({otcToken:t}),await s(),null==a||a(!0)}catch(t){n({error:Nn(t)}),null==a||a(!1,t)}},setUpOwnPhoneNumber:async t=>{const{callback:a}=t,s=f(t,nl);try{const{otcToken:t}=await e.userPhoneNumbers.createPhoneNumber(s);n({otcToken:t}),await i(),null==a||a(!0)}catch(t){n({error:Nn(t)}),null==a||a(!1,t)}},verifyPhoneNumber:async t=>{const{callback:a}=t,i=f(t,il);n({loading:!0});try{await e.userPhoneNumbers.verifyPhoneNumber(i),await s(),null==a||a(!0)}catch(t){n({error:Nn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},deletePhoneNumber:async t=>{const{callback:a,phoneId:s}=t;f(t,ol),n({loading:!0});try{const{otcToken:t}=await e.userPhoneNumbers.deletePhoneNumber(s);n({otcToken:t}),null==a||a(!0)}catch(t){n({error:Nn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},verifyDeletePhoneNumber:async t=>{const{callback:a,phoneId:i}=t,o=f(t,rl);n({loading:!0});try{await e.userPhoneNumbers.verifyDeletePhoneNumber(i,o),await s(),null==a||a(!0)}catch(t){n({error:Nn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},preVerifyPhoneNumber:async t=>{const{callback:a}=t,s=f(t,ll);n({loading:!0});try{const{otcToken:t}=await e.userPhoneNumbers.preVerifyPhoneNumber(s);n({otcToken:t}),null==a||a(!0)}catch(t){n({error:Nn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}}}},ul={firstLoad:!0,loading:!1,error:""},dl=t=>en(ul,t),gl=["authorizationUrl"],pl=["events","url"],hl=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.socialLoginState,e)};return{setSocialLoginsState:s,resetSocialLoginsState:()=>{Cn(t,["auth","socialLoginState"],ul)},setSocialLoginError:t=>{s({error:t.error,loading:!1,firstLoad:!1})},loadSocialLoginsConfiguration:async()=>{try{s({loading:!0});const t=await e.auth.getSocialLoginProviders();s({socialLoginsConfig:t,loading:!1,firstLoad:!1})}catch(t){s({error:Nn(t),loading:!1,firstLoad:!1})}},loadSocialLoginsConfigurationV2:async a=>{try{var n;const i=t.root.context;s({loading:!0});const o=await(async a=>{let n;return n=t.auth.isAuthenticated?await On(e.auth.getSocialLoginProvidersV2ForAuthenticatedUser,a):await On(e.auth.getSocialLoginProvidersV2,a),n})(null==a?void 0:a.retryConfig),{providers:r}=await On(e.auth.getCustomSocialLoginProvidersV1,null==a?void 0:a.retryConfig),l={socialLoginsConfigV2:o.map((t=>{let{authorizationUrl:a}=t,n=f(t,gl);const s=e.fetch.getBaseUrl(i,null!=a?a:"");return v({},n,{authorizationUrl:a?`${s}${a}`:null})})),customSocialLoginsConfig:r,loading:!1,firstLoad:!1};s(l),null==a||null==(n=a.callback)||n.call(a,l)}catch(t){var i;null==a||null==(i=a.callback)||i.call(a,null,t),s({error:Nn(t),loading:!1,firstLoad:!1})}},loginViaSocialLogin:async t=>{const{events:a,url:i}=t,o=f(t,pl);try{s({loading:!0});const{email:t,isNewUser:c,userId:u,tenantId:d,name:g}=await e.auth.loginViaSocialLogin(o);if(c){var r,l;const e={email:t,url:i,createdAt:new Date,id:u,tenantId:d},n=v({},e,{socialProvider:o.provider,authenticationType:zn.SOCIAL_LOGIN});null==a||null==(r=a.signUpComplete)||r.call(a,n),Xn(Jn.SIGNUP_COMPLETED,n);const s=v({},e,{origin:Hn.SOCIAL_LOGIN,name:g});null==a||null==(l=a.userVerified)||l.call(a,s),Xn(Jn.USER_VERIFIED,s)}u&&localStorage.setItem("userId",u),n.setLoginState({email:t,isNewUser:c}),n.refreshTokenForSocialLogins(),localStorage.removeItem("register-quick-login"),s({loading:!1})}catch(t){s({loading:!1,error:Nn(t,"Failed to authenticate"),firstLoad:!1})}}}},yl={firstLoad:!0,loading:!0,saving:!1,errors:{},loaders:{},ssoConfigurations:[]},Sl=t=>en(yl,t),vl=["callback","samlVendor"],fl=["callback"],ml=["callback","ssoConfigId"],bl=["callback","ssoConfigId"],Al=["callback","ssoConfigId"],wl=(t,e,a)=>v({},((t,e,a)=>{const n=a,s=async()=>{try{const t=await e.auth.getSamlRoles(),a=await e.auth.getSamlRolesGroups();i({authorizationRoles:t.roleIds,rolesGroups:a,error:void 0})}catch(t){i({error:Nn(t)})}},i=e=>{Object.assign(t.auth.ssoState,e)};return{setSSOState:i,resetSSOState:()=>{Cn(t,["auth","ssoState"],yl)},setSSOLoader:e=>{Object.assign(t.auth.ssoState,{loaders:v({},t.auth.ssoState.loaders,{[e.key]:e.value})})},setSSOError:e=>{Object.assign(t.auth.ssoState,{errors:v({},t.auth.ssoState.errors,{[e.key]:e.value}),loaders:v({},t.auth.ssoState.loaders,{[e.key]:!1})})},loadSSOConfigurations:async()=>{try{var t,a;i({loading:!0});const n=await e.auth.getSamlConfiguration(),s=await e.auth.getOidcConfiguration(),o=await e.metadata.getSamlMetadata();n.acsUrl=null==o||null==(t=o.configuration)?void 0:t.acsUrl,n.spEntityId=null==o||null==(a=o.configuration)?void 0:a.spEntityId,n.isSamlActive=null==o?void 0:o.isActive,i({samlConfiguration:n,oidcConfiguration:s,loading:!1,firstLoad:!1})}catch(t){i({error:Nn(t),loading:!1})}},saveSSOConfigurations:async a=>{const{callback:n,samlVendor:s}=a,o=f(a,vl),r=t.auth.ssoState.samlConfiguration,l=v({},r,o);let c="saving";(null==l?void 0:l.enabled)!==(null==r?void 0:r.enabled)&&(c="loading");try{if(null==l||!l.domain)return void i({samlConfiguration:v({},r,l)});if(i({error:void 0,[c]:!0}),a.type===io.Saml){var u,d;const t=await e.metadata.getSamlMetadata();l.acsUrl=null==t||null==(u=t.configuration)?void 0:u.acsUrl,l.spEntityId=null==t||null==(d=t.configuration)?void 0:d.spEntityId}const t=_n(l,["validated","generatedVerification","createdAt","updatedAt"]);(null==r?void 0:r.domain)!==(null==t?void 0:t.domain)&&(t.ssoEndpoint="",t.publicCertificate="",t.signRequest=!1),t.type=null==s?void 0:s.toLowerCase();const o=await e.auth.updateSamlConfiguration(t);o.isSamlActive=null==r?void 0:r.isSamlActive,i({samlConfiguration:o,error:void 0,[c]:!1}),null==n||n(!0)}catch(t){i({samlConfiguration:r,error:Nn(t),[c]:!1}),null==n||n(null,t)}},saveSSOConfigurationsFile:async a=>{const n=t.auth.ssoState.samlConfiguration,s="saving";i({error:void 0,[s]:!0});try{const t=await _i(a[0]),o=await e.auth.updateSamlVendorMetadata({metadata:t});o.isSamlActive=null==n?void 0:n.isSamlActive,i({samlConfiguration:o,error:void 0,[s]:!1})}catch(t){i({samlConfiguration:n,error:Nn(t),[s]:!1})}},saveSSOConfigurationsFileWithCallback:async a=>{const{configFile:n,callback:s}=a,o=t.auth.ssoState.samlConfiguration,r="saving";i({error:void 0,[r]:!0});try{const t=await _i(n),a=await e.auth.updateSamlVendorMetadata({metadata:t});a.isSamlActive=null==o?void 0:o.isSamlActive,i({samlConfiguration:a,error:void 0,[r]:!1}),null==s||s(!0)}catch(t){i({samlConfiguration:o,error:Nn(t),[r]:!1}),null==s||s(null,t)}},validateSSODomain:async a=>{const{callback:n}=null!=a?a:{},s=t.auth.ssoState.samlConfiguration;if(!s){const t=new Error("IllegalState: samlConfiguration is not defined");return console.error(t),void(null==n||n(null,t))}try{i({error:void 0,saving:!0}),await e.auth.validateSamlDomain(),i({samlConfiguration:v({},s,{validated:!0}),error:void 0,saving:!1}),null==n||n(!0)}catch(t){i({samlConfiguration:v({},s,{validated:!1}),error:Nn(t),saving:!1}),null==n||n(null,t)}},loadSSOAuthorizationRoles:async()=>{try{const t=await e.auth.getSamlRoles(),a=await e.auth.getSamlRolesGroups();i({authorizationRoles:t.roleIds,rolesGroups:a,error:void 0})}catch(t){i({error:Nn(t)})}},updateSSOAuthorizationRoles:async t=>{const{callback:a,authorizationRoles:n,groups:o}=t;try{i({error:void 0,saving:!0}),await e.auth.updateSamlRoles({roleIds:n}),o&&await(async t=>{try{await Promise.all(t.map((t=>e.auth.updateSamlGroup({id:t.id,roleIds:t.roleIds,group:t.group}))))}catch(t){i({error:Nn(t)})}})(o),await s(),i({error:void 0,saving:!1}),null==a||a(!0)}catch(t){i({error:Nn(t),saving:!1}),null==a||a(null,t)}},deleteSamlGroup:async t=>{const{id:a,callback:n}=t;try{i({error:void 0,saving:!0}),await e.auth.deleteSamlGroup({id:a}),await s(),i({error:void 0,saving:!1}),null==n||n(!0)}catch(t){i({error:Nn(t),saving:!1}),null==n||n(null,t)}},createSamlGroup:async t=>{const{group:a,roleIds:n,callback:o}=t;try{i({error:void 0,saving:!0}),await e.auth.createSamlGroup({group:a,roleIds:n}),await s(),i({error:void 0,saving:!1}),null==o||o(!0)}catch(t){i({error:Nn(t),saving:!1}),null==o||o(null,t)}},oidcPostlogin:async t=>{const a={code:t.code,redirectUri:t.redirectUri,RelayState:t.state};try{i({loading:!0}),await e.auth.oidcPostLoginV2(a),await n.__refreshToken(),i({loading:!1})}catch(t){i({loading:!1,error:Nn(t,"Failed to authenticate"),firstLoad:!1})}}}})(t,e,a),((t,e,a)=>{const n=a,s=async t=>{try{return await On((()=>e.auth.getOidcConfiguration()),t)}catch(t){return null}},i=async t=>{try{return await On((()=>e.metadata.getSamlMetadata()),t)}catch(t){return null}},o=async(t,e,a)=>{n.setSSOLoader({key:t,value:!0});try{await a()}catch(a){n.setSSOError({key:t,value:Nn(a)}),null==e||e(null,a)}finally{n.setSSOLoader({key:t,value:!1})}};return{loadSSOConfigurationsV2:async t=>{await o(so.LOAD_SSO_CONFIGURATIONS,void 0,(async()=>{const[a,o]=await Promise.all([s(null==t?void 0:t.retryConfig),i(null==t?void 0:t.retryConfig)]),r=await On((()=>e.auth.getSSOConfigurations()),null==t?void 0:t.retryConfig);n.setSSOState({ssoConfigurations:r,oidcConfiguration:a,samlMetadata:o})}))},saveSSOConfigurationV2:async a=>{const{callback:s}=a,i=f(a,fl),r=t.auth.ssoState.ssoConfigurations;await o(so.SAVE_SSO_CONFIGURATION,s,(async()=>{var t;const a=await e.auth.createSSOConfiguration(v({},i,{enabled:null!=(t=i.enabled)&&t}));n.setSSOState({ssoConfigurations:[...r,a]}),null==s||s(a)}))},updateSSOConfiguration:async a=>{const{callback:s,ssoConfigId:i}=a,r=f(a,ml),l=t.auth.ssoState.ssoConfigurations;await o(so.UPDATE_SSO_CONFIGURATION,s,(async()=>{const t=await e.auth.updateSSOConfiguration(i,r),a=l.map((e=>e.id===i?t:e));n.setSSOState({ssoConfigurations:a}),null==s||s(t)}))},deleteSSOConfiguration:async a=>{const{ssoConfigId:s,callback:i}=a,r=t.auth.ssoState.ssoConfigurations;await o(so.DELETE_SSO_CONFIGURATION,i,(async()=>{await e.auth.deleteSSOConfiguration(s),n.setSSOState({ssoConfigurations:r.filter((({id:t})=>t!==s))}),null==i||i(!0)}))},saveSSODomain:async a=>{const{callback:s,ssoConfigId:i}=a,r=f(a,bl),l=t.auth.ssoState.ssoConfigurations;await o(so.SAVE_SSO_DOMAIN,s,(async()=>{const t=await e.auth.createSSODomain(i,r),a=l.map((e=>e.id===i?v({},e,{domains:[...e.domains,t]}):e));n.setSSOState({ssoConfigurations:a}),null==s||s(t)}))},deleteSSODomain:async a=>{const{ssoConfigId:s,domainId:i,callback:r}=a,l=t.auth.ssoState.ssoConfigurations;await o(so.DELETE_SSO_DOMAIN,r,(async()=>{await e.auth.deleteSSODomain(s,i);const t=l.map((t=>t.id===s?v({},t,{domains:t.domains.filter((({id:t})=>t!==i))}):t));n.setSSOState({ssoConfigurations:t}),null==r||r(!0)}))},validateSSODomainV2:async a=>{const{callback:s,domainId:i,ssoConfigId:r}=a;await o(so.VALIDATE_SSO_DOMAIN,s,(async()=>{const a=t.auth.ssoState.ssoConfigurations;await e.auth.validateSSODomainV2(r,i);const o=a.map((t=>t.id===r?v({},t,{domains:t.domains.map((t=>t.id===i?v({},t,{validated:!0}):t))}):t));n.setSSOState({ssoConfigurations:o}),null==s||s(!0)}))},setSSOGroups:async a=>{const{groupsToAdd:s,groupsToDelete:i,ssoConfigId:r,callback:l}=a;await o(so.SAVE_SSO_GROUPS,l,(async()=>{const a=t.auth.ssoState.ssoConfigurations;await Promise.all(i.map((t=>e.auth.deleteSSOGroup(r,t)))),await Promise.all(s.map((t=>e.auth.createSSOGroup(r,t))));const o=await e.auth.getSSOGroups(r),c=a.map((t=>t.id===r?v({},t,{groups:o}):t));n.setSSOState({ssoConfigurations:c}),null==l||l(!0)}))},updateSSOGroups:async t=>{const{ssoConfigId:a,changedGroups:n,callback:s}=t;await o(so.SAVE_SSO_GROUPS,s,(async()=>{await Promise.all(n.map((t=>e.auth.updateSSOGroup(a,t)))),null==s||s(!0)}))},setSSODefaultRoles:async a=>{const{callback:s,ssoConfigId:i,roleIds:r}=a;await o(so.UPDATE_SSO_DEFAULT_ROLES,s,(async()=>{const a=t.auth.ssoState.ssoConfigurations;await e.auth.setSSODefaultRoles(i,{roleIds:r});const o=a.map((t=>t.id===i?v({},t,{roleIds:r}):t));n.setSSOState({ssoConfigurations:o}),null==s||s(!0)}))},saveSSOConfigurationByMetadata:async a=>{const{configFile:s,callback:i}=a;await o(so.SAVE_SSO_CONFIGURATION_BY_METADATA,i,(async()=>{const a=t.auth.ssoState.ssoConfigurations,o=await _i(s),r=await e.auth.createSSOConfigurationByMetadata({metadata:o});n.setSSOState({ssoConfigurations:[...a,r]}),null==i||i(r)}))},updateSSOConfigurationByMetadata:async a=>{const{callback:s,ssoConfigId:i,configFile:r}=a;await o(so.UPDATE_SSO_CONFIGURATION_BY_METADATA,s,(async()=>{const a=t.auth.ssoState.ssoConfigurations,o=await _i(r),l=await e.auth.updateSSOConfigurationByMetadata(i,{metadata:o}),c=a.map((t=>t.id===i?l:t));n.setSSOState({ssoConfigurations:c}),null==s||s(l)}))},saveSSOConfigurationByUrl:async a=>{const{metadataUrl:s,configMetadata:i,ssoConfigId:r,callback:l}=a;await o(so.SAVE_SSO_CONFIGURATION_BY_METADATA,l,(async()=>{const a=t.auth.ssoState.ssoConfigurations,o={url:s,configMetadata:i};let c,u;r?(c=await e.auth.updateSSOConfigurationByMetadataUrl(r,o),u=a.map((t=>t.id===r?c:t))):(c=await e.auth.createSSOConfigurationByMetadataUrl(o),u=[c,...a]),n.setSSOState({ssoConfigurations:u}),null==l||l(c)}))},saveSSOConfigurationByData:async a=>{const{callback:s,ssoConfigId:i}=a,r=f(a,Al),l=t.auth.ssoState.ssoConfigurations;await o(so.SAVE_SSO_CONFIGURATION,s,(async()=>{let t,a;i?(t=await e.auth.updateSSOConfiguration(i,r),a=l.map((e=>e.id===i?t:e))):(t=await e.auth.createSSOConfiguration(r),a=[t,...l]),n.setSSOState({ssoConfigurations:a}),null==s||s(t)}))}}})(t,e,a)),Tl={loading:!1,mfaDevices:void 0,mfaToken:""},El=t=>en(Tl,t),Il=(t,e,a)=>{const n=a;return v({setStepUpState:e=>{Object.assign(t.auth.stepUpState,e)},resetStepUpState:()=>{Cn(t,["auth","stepUpState"],Tl)},stepUpWithAuthenticator:async t=>{await n.mfaWithAuthenticator(t,n.setStepUpState,!0)},preVerifyMFASMSForStepUp:async t=>{await n.preVerifyMFASMS(t,n.setStepUpState)},verifyMFASMSForStepUp:async t=>{await n.verifyMFASMS(t,n.setStepUpState,!0)},preVerifyMFAWebAuthnForStepUp:async t=>{await n.preVerifyMFAWebAuthn(t,n.setStepUpState)},verifyMFAWebAuthnForStepUp:async t=>{await n.verifyMFAWebAuthn(t,n.setStepUpState,!0)},preVerifyMFAEmailCodeForStepUp:async t=>{await n.preVerifyMFAEmailCode(t,n.setStepUpState)},verifyMFAEmailCodeForStepUp:async t=>{await n.verifyMFAEmailCode(t,n.setStepUpState)}},((t,e,a)=>{const n=a;return{generateStepUpSession:async a=>{const{maxAge:s,callback:i}=a;n.setStepUpState({mfaDevices:void 0,mfaToken:""});try{const t=await e.auth.generateStepupSession({maxAge:s});t.hasOwnProperty("user")?await(async t=>{await n.afterAuthenticationStateUpdate(t),await n.afterStepUpAuthNavigation()})(t):await(async({mfaToken:t,mfaDevices:e})=>{n.setStepUpState({mfaDevices:e,mfaToken:t});const a=await is(e);n.setMfaState({step:a})})(t),null==i||i(!0)}catch(e){null==i||i(!1),await(async e=>{if((t=>"MFA is not enrolled"===(null==t?void 0:t.message))(e))return void n.setMfaState({step:Yn.noMFAEnrolledStepUp});window.localStorage.setItem(pn,"true");const a=t.auth.routes;U.for(t.root.appName).onRedirectTo(a.logoutUrl,{preserveQueryParams:!0})})(e)}}}})(t,e,a),((t,e,a)=>{const n=a;return{stepUpHostedLogin:async e=>{var a,s;const i={acr_values:un},{maxAge:o}=e||{};void 0!==o&&(i.max_age=o.toString());const r=null==(a=t.auth.tenantsState)||null==(s=a.activeTenant)?void 0:s.alias;r&&(i.organization=r),gs(),window.localStorage.setItem(pn,"true"),await n.__requestHostedLoginAuthorize(i)}}})(t,0,a))},Ol={loaders:{},pageOffset:0,pageSize:20,errors:{},users:[],allUsers:[],roles:[],permissions:[],totalPages:0,shouldShowSubTenantUsersIfReseller:!1,allUsersQueryParams:{_filter:null,_offset:0,_limit:20,_order:"DESC",_sortBy:"name"},addUserDialogState:{loading:!1,open:!1},deleteUserDialogState:{loading:!1,open:!1},lockUserDialogState:{loading:!1,open:!1},enableUserDialogState:{loading:!1,open:!1},disableUserDialogState:{loading:!1,open:!1}},Pl=t=>en(Ol,t),kl=["callback","appIds"],_l=["roles"],Rl=["callback","profileImage"],Ul=["callback"],Cl=["callback"],Ll=["callback"],Dl=["callback","userId"],Nl=["callback"],Ml=["callback"],Fl=["callback"],xl=["callback"],$l=["callback"],Gl=["callback"],jl=(t,e,a)=>{const n=e=>{Object.assign(t.auth.teamState,e)};return v({setTeamLoader:e=>{Object.assign(t.auth.teamState,{loaders:v({},t.auth.teamState.loaders,{[e.key]:e.value})})},setTeamError:e=>{Object.assign(t.auth.teamState,{errors:v({},t.auth.teamState.errors,{[e.key]:e.value}),loaders:v({},t.auth.teamState.loaders,{[e.key]:!1})})},setTeamState:n,resetTeamState:()=>{Cn(t,["auth","teamState"],Ol)},openAddUserDialog:t=>{n({addUserDialogState:v({open:!0,loading:!1,error:!1},t)})},closeAddUserDialog:e=>{var a,s;null==(a=(s=t.auth.teamState.addUserDialogState).onClose)||a.call(s,e),n({addUserDialogState:{loading:!1,error:!1,open:!1}})},openDeleteUserDialog:t=>{n({deleteUserDialogState:v({open:!0,loading:!1,error:!1},t)})},closeDeleteUserDialog:e=>{var a,s;null==(a=(s=t.auth.teamState.deleteUserDialogState).onClose)||a.call(s,e),n({deleteUserDialogState:{loading:!1,error:!1,open:!1}})},lockUser:async t=>{}},((t,e,a)=>{const n=a,s=async t=>{try{const{groups:a}=await On((()=>e.groups.getGroups({_groupsRelations:xa.roles})),t);return a}catch(t){return[]}},i=async t=>{n.setTeamLoader({key:ws.ROLES_AND_PERMISSIONS,value:!0});try{var a;const s=null==t?void 0:t.retryConfig,[{items:i},{items:o}]=await Promise.all([On((()=>e.teams.loadAvailableRoles()),s),On((()=>e.teams.loadAvailablePermissions()),s)]);n.setTeamState({roles:i,permissions:o}),null==t||null==(a=t.callback)||a.call(t,{roles:i,permissions:o})}catch(e){var s;null==t||null==(s=t.callback)||s.call(t,null,e),n.setTeamError({key:ws.ROLES_AND_PERMISSIONS,value:Nn(e)})}finally{n.setTeamLoader({key:ws.ROLES_AND_PERMISSIONS,value:!1})}};return{loadRoles:i,loadUsers:async a=>{var s,o,r,l;const{silentLoading:c,callback:u}=a,d=t.auth.teamState,g=null!=(s=a.pageSize)?s:d.pageSize,p=null!=(o=a.pageOffset)?o:d.pageOffset,h=null!=(r=a.filter)?r:d.filter,y=null!=(l=a.sort)?l:d.sort;n.setTeamLoader({key:ws.USERS,value:!c}),n.setTeamState({pageSize:g,pageOffset:p,filter:h,sort:y});try{const[{items:t,totalPages:a,totalItems:s}]=await Promise.all([e.teams.loadUsers({pageSize:g,pageOffset:p,filter:h,sort:y}),i()]);n.setTeamState({users:t,totalPages:a,totalItems:s}),null==u||u(t)}catch(t){n.setTeamError({key:ws.USERS,value:Nn(t)}),n.setTeamState({totalPages:0,users:[]}),null==u||u(null,t)}n.setTeamLoader({key:ws.USERS,value:!1})},loadUsersV2:async o=>{var r,l,c,u,d;const{silentLoading:g,callback:p,shouldLoadRoles:h=!0,shouldLoadApps:y,retryConfig:S}=o,f=t.auth.teamState,m=null!=(r=o.pageSize)?r:f.pageSize,b=null!=(l=o.pageOffset)?l:f.pageOffset,A=null!=(c=o.filter)?c:f.filterV2,w=null!=(u=o.sort)?u:f.sortV2,T=null!=(d=null==o?void 0:o.shouldShowSubTenantUsersIfReseller)?d:null==f?void 0:f.shouldShowSubTenantUsersIfReseller;n.setTeamLoader({key:ws.USERS,value:!g}),n.setTeamState({pageSize:m,pageOffset:b,filterV2:A,sortV2:w});try{const[{items:t,_metadata:{totalPages:n,totalItems:r}},{items:l},{items:c},u]=await Promise.all([On((()=>e.users.getUsersV2(v({},(null==A?void 0:A.length)&&{_filter:A},w&&{_sortBy:w},o.order&&{_order:o.order},{_offset:b,_limit:m,_includeSubTenants:T}))),S),On((()=>e.teams.loadAvailableRoles()),S),On((()=>e.teams.loadAvailablePermissions()),S),s(S),h?i({retryConfig:S}):void 0]),d=t.map((t=>{var e;return v({},t,{groups:null==t||null==(e=t.groups)?void 0:e.map((t=>u.filter((e=>e.id===t.id)))).flat()})})).map((t=>v({},t,{roleIds:t.roles.map((t=>t.id))}))),g=await a.mapUsersWithApplicationData({shouldLoadApps:y,users:d,retryConfig:S});a.setTeamState({users:g,totalPages:n,totalItems:r,roles:l,permissions:c}),null==p||p(t)}catch(t){console.error("Failed to load users",t),n.setTeamError({key:ws.USERS,value:Nn(t)}),n.setTeamState({totalPages:0,users:[]}),null==p||p(null,t)}n.setTeamLoader({key:ws.USERS,value:!1})},addUser:async s=>{const{callback:i,appIds:o}=s,r=f(s,kl),l=t.auth.teamState;n.setTeamState({addUserDialogState:v({},l.addUserDialogState,{loading:!0})});try{var c;const t=await e.teams.addUser(r),{roles:s}=t,u=v({},f(t,_l),{roleIds:null!=(c=null==s?void 0:s.map((t=>t.id)))?c:[]}),d=await a.assignNewUserToApps({appIds:o,user:u});d&&(u.applications=d),null==i||i(u),n.setTeamState({users:[u,...l.users],addUserDialogState:{open:!1,loading:!1}})}catch(t){console.error("Failed to add user",t),n.setTeamState({addUserDialogState:v({},l.addUserDialogState,{loading:!1,error:Nn(t)})}),null==i||i(null,t)}},addUsersBulk:async a=>{const{callback:s}=a,i=t.auth.teamState;n.setTeamState({addUserDialogState:v({},i.addUserDialogState,{loading:!0})});const o=[],r=[],l=a.emails.map((t=>v({email:t,roleIds:a.roleIds},a.expirationInSeconds&&{expirationInSeconds:a.expirationInSeconds})));n.setTeamState({addUserDialogState:{open:!0,loading:!0}});for(let t=0;t<l.length;t++){const a=l.at(t);try{await e.teams.addUser(a),o.push(a.email)}catch(t){r.push(a.email)}}const c={pageOffset:0,pageSize:10,filter:"",silentLoading:a.emails.length>0};await n.loadUsersV2(c),n.setTeamState({addUserDialogState:{loading:!1}}),null==s||s({unallowedEmails:r,allowedEmails:o})},updateUser:async a=>{const{callback:s}=a,i=f(a,Rl),{id:o}=i,r=t.auth.teamState,l=r.users.find((t=>t.id===i.id));if(void 0!==l){n.setTeamLoader({key:ws.UPDATE_USER,value:o||""}),n.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!0})}),n.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!0}),users:r.users.map((t=>t.id===i.id?v({},t,i):t))});try{var c;l.roleIds.length>0&&0===(null==(c=i.roleIds)?void 0:c.length)&&(i.roleIds=[""]);const{item:t}=await e.teams.updateUser(i);null==s||s(t),n.setTeamState({users:r.users.map((e=>e.id===t.id?v({},e,t,{groups:e.groups,createdAt:e.createdAt,customData:e.customData,lastLogin:e.lastLogin}):e))}),n.setTeamLoader({key:ws.UPDATE_USER,value:!1})}catch(t){n.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!1,error:Nn(t)}),users:r.users.map((t=>t.id===i.id?v({},t,l):t))}),n.setTeamLoader({key:ws.UPDATE_USER,value:!1}),null==s||s(null,t)}}else null==s||s(null,"User not in state")},deleteUser:async a=>{const{callback:s}=a,i=f(a,Ul),o=t.auth.teamState;n.setTeamState({deleteUserDialogState:v({},o.deleteUserDialogState,{loading:!0})});try{await e.teams.deleteUser(i),null==s||s(!0),n.setTeamState({users:o.users.filter((t=>t.id!==i.userId)),deleteUserDialogState:{open:!1,loading:!1}})}catch(t){n.setTeamState({deleteUserDialogState:v({},o.deleteUserDialogState,{loading:!1,error:Nn(t)})}),null==s||s(null,t)}},enableUser:async a=>{const{callback:s,userId:i}=a,o=t.auth.teamState;n.setTeamState({enableUserDialogState:v({},o.enableUserDialogState,{loading:!0})});try{await e.teams.enableUser(i),null==s||s(!0),n.setTeamState({users:o.users.map((t=>t.id===i?v({},t,{isDisabled:!1}):t)),enableUserDialogState:{open:!1,loading:!1}})}catch(t){n.setTeamState({enableUserDialogState:v({},o.enableUserDialogState,{loading:!1,error:Nn(t)})}),null==s||s(null,t)}},disableUser:async a=>{const{callback:s,userId:i}=a,o=t.auth.teamState;n.setTeamState({disableUserDialogState:v({},o.disableUserDialogState,{loading:!0})});try{await e.teams.disableUser(i),null==s||s(!0),n.setTeamState({users:o.users.map((t=>t.id===i?v({},t,{isDisabled:!0}):t)),disableUserDialogState:{open:!1,loading:!1}})}catch(t){n.setTeamState({disableUserDialogState:v({},o.disableUserDialogState,{loading:!1,error:Nn(t)})}),null==s||s(null,t)}},getTemporaryUsersConfig:async t=>{n.setTeamError({key:ws.CONFIG_TEMPORARY_USERS,value:!1});try{const a=await On((()=>e.teams.getTemporaryUserConfiguration()),null==t?void 0:t.retryConfig);n.setTeamState({temporaryUsersConfig:a})}catch(t){n.setTeamError({key:ws.CONFIG_TEMPORARY_USERS,value:Nn(t)})}},updateUserExpirationTime:async a=>{const{callback:s}=a,i=f(a,Cl),o=t.auth.teamState;n.setTeamLoader({key:ws.UPDATE_USER_EXPIRATION_TIME,value:!0});try{const t=await e.teams.updateUserExpirationTime(i);n.setTeamState({users:o.users.map((e=>e.id===i.userId?v({},e,{temporaryExpirationDate:new Date(t.temporaryExpirationDate)}):e))}),null==s||s(!0)}catch(t){n.setTeamError({key:ws.UPDATE_USER_EXPIRATION_TIME,value:Nn(t)}),null==s||s(null,t)}finally{n.setTeamLoader({key:ws.UPDATE_USER_EXPIRATION_TIME,value:!1})}},setUserAsPermanent:async a=>{const{callback:s}=a,i=f(a,Ll),o=t.auth.teamState;n.setTeamLoader({key:ws.UPDATE_USER_EXPIRATION_TIME,value:!0});try{await e.teams.setPermanentUser(i.userId),n.setTeamState({users:o.users.map((t=>t.id===i.userId?v({},t,{temporaryExpirationDate:void 0}):t))}),null==s||s(!0)}catch(t){n.setTeamError({key:ws.UPDATE_USER_EXPIRATION_TIME,value:Nn(t)}),null==s||s(null,t)}finally{n.setTeamLoader({key:ws.UPDATE_USER_EXPIRATION_TIME,value:!1})}}}})(t,e,a),((t,e,a)=>{const n=a;return{loadAllSubTenantsUsers:async a=>{var s,i,o,r,l;const{silentLoading:c,callback:u}=a,d=t.auth.teamState.allUsersQueryParams,g={_limit:(null!=(s=a._limit)?s:d._limit)||20,_offset:(null!=(i=a._offset)?i:d._offset)||0,_filter:(null!=(o=a._filter)?o:d._filter)||"",_sortBy:(null!=(r=a._sortBy)?r:d._sortBy)||"name",_order:(null!=(l=a._order)?l:d._order)||"DESC"};n.setTeamLoader({key:ws.USERS,value:!c}),n.setTeamState({allUsersQueryParams:g,pageOffset:g._offset});try{const[{items:t,_metadata:{totalPages:a,totalItems:s}},{items:i},{items:o}]=await Promise.all([e.subTenants.loadAllUsers(v({},g)),e.teams.loadAvailableRoles(),e.teams.loadAvailablePermissions()]);n.setTeamState({allUsers:t,totalPages:a,totalItems:s,roles:i,permissions:o}),null==u||u(t)}catch(t){n.setTeamError({key:ws.USERS,value:Nn(t)}),n.setTeamState({totalPages:0,users:[]}),null==u||u(null,t)}n.setTeamLoader({key:ws.USERS,value:!1})},setUserRolesForSubTenants:async a=>{const{callback:s,userId:i}=a,o=f(a,Dl),r=t.auth.teamState;n.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!0})});try{await e.subTenants.setUserRolesForSubTenants(i,o);const t=r.allUsers.find((t=>t.id===i));let a=[];t&&(a=t.tenants.map((t=>{var e;return v({},t,{roles:(null==(e=o.subTenantsRoles.find((e=>e.tenantId===t.tenantId)))?void 0:e.roleIds.map((t=>r.roles.find((({id:e})=>t===e)))).filter((t=>t)))||t.roles})}))),n.setTeamState({allUsers:[...r.allUsers.filter((t=>t.id!==i)),...t?[v({},t,{tenants:a})]:[]],addUserDialogState:{open:!1,loading:!1}}),null==s||s(!0)}catch(t){n.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!1,error:Nn(t)})}),null==s||s(null,t)}},deleteUserFromSubTenants:async a=>{const{callback:s}=a,i=f(a,Nl),o=t.auth.teamState;n.setTeamState({deleteUserDialogState:v({},o.deleteUserDialogState,{loading:!0})});try{await e.subTenants.removeUserFromTenantAndSubTenants(i),null==s||s(!0),n.setTeamState({allUsers:o.allUsers.filter((t=>t.id!==i.userId&&t.tenants.length===i.subTenants.length)),deleteUserDialogState:{open:!1,loading:!1}})}catch(t){n.setTeamState({deleteUserDialogState:v({},o.deleteUserDialogState,{loading:!1,error:Nn(t)})}),null==s||s(null,t)}},addUserToSubTenants:async a=>{const{callback:s}=a,i=f(a,Ml),o=t.auth.teamState;n.setTeamState({addUserDialogState:v({},o.addUserDialogState,{loading:!0})});try{await e.subTenants.addUserToTenantAndSubTenants(i);const{items:t,_metadata:{totalPages:a,totalItems:o}}=await e.subTenants.loadAllUsers({_limit:20,_offset:0,_filter:"",_sortBy:"name",_order:"DESC"});n.setTeamState({allUsers:t,totalPages:a,totalItems:o,addUserDialogState:{open:!1,loading:!1}}),null==s||s(null)}catch(t){n.setTeamState({addUserDialogState:v({},o.addUserDialogState,{loading:!1,error:Nn(t)})}),null==s||s(null,t)}}}})(t,e,a),((t,e,a)=>{const n=a,s=async(t,e,a,s)=>{n.setTeamLoader({key:t,value:e});try{await s()}catch(e){n.setTeamError({key:t,value:Nn(e)}),null==a||a(null,e)}finally{n.setTeamLoader({key:t,value:!1})}};return{resendActivationLink:async t=>{const{callback:a}=t,n=f(t,Fl);await s(ws.RESEND_ACTIVATE_LINK,n.userId,a,(async()=>{await e.teams.resendActivationLink(n),null==a||a(!0)}))},resendInvitationLink:async t=>{const{callback:a}=t,n=f(t,xl);await s(ws.RESEND_INVITATION_LINK,n.email,a,(async()=>{await e.teams.resendInvitationLink(n),null==a||a(!0)}))},resendInvitationEmail:async t=>{const{callback:a}=t,n=f(t,$l);await s(ws.RESEND_INVITATION_LINK,a,n.email,(async()=>{await e.auth.resendInvitationEmail(n),null==a||a(!0)}))},resendInvitationLinkToAllSubTenants:async t=>{const{callback:a}=t,n=f(t,Gl);await s(ws.RESEND_INVITATION_LINK,n.email,a,(async()=>{await e.teams.resendInvitationLinkToAllTenants(n),null==a||a(!0)}))}}})(0,e,a),((t,e,a)=>{const n=a;return{getInvitationLink:async a=>{n.setTeamError({key:ws.GET_TOKEN_LINK,value:!1});try{const s=null==a?void 0:a.retryConfig;await(async t=>{n.setTeamError({key:ws.CONFIG_TOKEN_LINK,value:!1});try{const a=await On((()=>e.teams.getInviteLinkConfiguration()),t);n.setTeamState({inviteTokenState:v({},a)})}catch(t){n.setTeamError({key:ws.CONFIG_TOKEN_LINK,value:Nn(t)})}})(s);const i=await On((()=>e.teams.getInviteUserLink()),s),{inviteTokenState:o}=t.auth.teamState;n.setTeamState({inviteTokenState:v({},o,i)})}catch(t){n.setTeamError({key:ws.GET_TOKEN_LINK,value:Nn(t)})}},createInvitationLink:async a=>{const{callback:s}=a;n.setTeamError({key:ws.CREATE_TOKEN_LINK,value:!1});const{inviteTokenState:i}=t.auth.teamState;try{const t=await e.teams.createInviteUserLink({expiresInMinutes:43200});n.setTeamState({inviteTokenState:v({},i,t)}),null==s||s(t.token)}catch(t){null==s||s(null,t),n.setTeamError({key:ws.CREATE_TOKEN_LINK,value:Nn(t)})}},updateInvitationLink:async a=>{const{callback:s,expiresInMinutes:i,shouldSendEmail:o}=a;n.setTeamError({key:ws.UPDATE_TOKEN_LINK,value:!1});try{const{inviteTokenState:a}=t.auth.teamState,r=await e.teams.updateInviteUserLink({expiresInMinutes:i,shouldSendEmail:o});n.setTeamState({inviteTokenState:v({},a,r)}),null==s||s(!0)}catch(t){null==s||s(null,t),n.setTeamError({key:ws.UPDATE_TOKEN_LINK,value:Nn(t)})}},deleteInvitationLink:async t=>{const{callback:a}=null!=t?t:{};n.setTeamError({key:ws.DELETE_TOKEN_LINK,value:!1});try{await e.teams.deleteInviteUserLink(),n.setTeamState({inviteTokenState:void 0}),null==a||a(!0)}catch(t){n.setTeamError({key:ws.DELETE_TOKEN_LINK,value:Nn(t)}),null==a||a(!1,t)}}}})(t,e,a))},Bl={tenants:[],subTenants:[],switchingTenant:!1,loading:!0,tenantTree:null},Vl=t=>en(Bl,t),Wl=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.tenantsState,e)};return{setTenantsState:s,resetTenantsState:()=>{Cn(t,["auth","tenantsState"],Bl)},switchTenant:async a=>{const{tenantId:s,silentReload:i,callback:o}=a;i?n.setTenantsState({switchingTenant:!0}):n.setAuthState({isLoading:!0});try{await e.tenants.switchTenant({tenantId:s}),i&&n.resetAuthState({isLoading:!1,isAuthenticated:!0,user:t.auth.user}),await n.__refreshToken(),(null==o?void 0:o(!0))||(i?n.setTenantsState({switchingTenant:!1}):n.setAuthState({isLoading:!1}))}catch(t){i?n.setTenantsState({switchingTenant:!1}):n.setAuthState({isLoading:!1}),null==o||o(!1,t)}},loadTenants:async e=>{s({loading:!0});try{var a;const n=ce(t.root.appName),i=await n();s({tenants:i.tenants,activeTenant:i.activeTenant,loading:!1}),null==e||null==(a=e.callback)||a.call(e,[])}catch(t){var n;null==e||null==(n=e.callback)||n.call(e,[],t),s({loading:!1})}},loadSubTenants:async t=>{s({loading:!0});try{var a;const n=await retryIfNeeded((()=>e.tenants.getSubTenants()),null==t?void 0:t.retryConfig);s({subTenants:n,loading:!1}),null==t||null==(a=t.callback)||a.call(t,!0)}catch(e){var n;s({loading:!1}),null==t||null==(n=t.callback)||n.call(t,null,e)}},loadSubTenantsTree:async t=>{s({loading:!0});try{var a;const n=await e.tenants.getSubTenantsAsTree();s({tenantTree:n,loading:!1}),null==t||null==(a=t.callback)||a.call(t,!0)}catch(e){var n;s({loading:!1}),null==t||null==(n=t.callback)||n.call(t,null,e)}}}},Hl=(t,e,a)=>{const n=e=>{t.auth.user&&(t.auth.user.entitlements=e)},s=e=>{var a;no(null==(a=t.auth.user)?void 0:a.entitlements,e)||n(e)};return{setEntitlements:n,handleFetchedEntitlements:s,loadEntitlements:async t=>{const a=null==t?void 0:t.callback;try{const t=await e.entitlements.loadEntitlementsV2();s(t),null==a||a(!0)}catch(t){null==a||a(!1)}}}},zl=["routes"],Kl=["requestName"],ql=t=>{const e=null!=t?t:{},{routes:a}=e,n=f(e,zl);return en(v({routes:v({},bn,a),onRedirectTo:()=>{},isAuthenticated:!1,isLoading:!0,isSSOAuth:!1,user:null,error:void 0,errorByRequest:{},userIp:void 0,userIpData:{loading:!1}},n,{acceptInvitationState:sn(null==n?void 0:n.acceptInvitationState),accountSettingsState:xn(null==n?void 0:n.accountSettingsState),activateAccountState:Vn(null==n?void 0:n.activateAccountState),unlockAccountState:Cs(null==n?void 0:n.unlockAccountState),apiTokensState:Ns(null==n?void 0:n.apiTokensState),applicationsState:$s(null==n?void 0:n.applicationsState),customLoginState:Vs(null==n?void 0:n.customLoginState),forgotPasswordState:qs(null==n?void 0:n.forgotPasswordState),passwordRotationState:Zs(null==n?void 0:n.passwordRotationState),groupsState:ai(null==n?void 0:n.groupsState),groupsDialogsState:li(null==n?void 0:n.groupsDialogsState),impersonateState:gi(null==n?void 0:n.impersonateState),loginState:Si(null==n?void 0:n.loginState),mfaState:Eo(null==n?void 0:n.mfaState),allAccountsState:No(null==n?void 0:n.allAccountsState),allAccountsDialogsState:Fo(null==n?void 0:n.allAccountsDialogsState),passkeysState:qo(null==n?void 0:n.passkeysState),profileState:Xo(null==n?void 0:n.profileState),provisioningState:er(null==n?void 0:n.provisioningState),resetPhoneNumberState:rr(null==n?void 0:n.resetPhoneNumberState),rolesState:pr(null==n?void 0:n.rolesState),restrictionsState:Tr(null==n?void 0:n.restrictionsState),securityCenterState:Rr(null==n?void 0:n.securityCenterState),securityPolicyState:Nr(null==n?void 0:n.securityPolicyState),sessionsPolicyState:Vr(null==n?void 0:n.sessionsPolicyState),sessionsState:Kr(null==n?void 0:n.sessionsState),signUpState:Xr(null==n?void 0:n.signUpState),smsState:al(null==n?void 0:n.smsState),socialLoginState:dl(null==n?void 0:n.socialLoginState),ssoState:Sl(null==n?void 0:n.ssoState),stepUpState:El(null==n?void 0:n.stepUpState),teamState:Pl(null==n?void 0:n.teamState),tenantsState:Vl(null==n?void 0:n.tenantsState)}))},Jl=(t,e,a,n)=>{const s=e=>{Object.keys(e).forEach((a=>{const n=a;Rn(t.auth[n])?Object.assign(t.auth[n],e[n]):t.auth[n]=e[n]}))},i={acceptInvitationActions:Mn(t,e),accountSettingsActions:Gn(t,e,a),activateAccountActions:Rs(t,e,a),unlockAccountActions:Ls(t,e),apiTokensActions:Fs(t,e),applicationsActions:js(t,e,a),customLoginActions:Hs(t,e,a),entitlementsActions:Hl(t,e),forgotPasswordActions:Ys(t,e),passwordRotationActions:ti(t),groupsActions:oi(t,e),groupsDialogsActions:ci(t),impersonateActions:hi(t,e,a),loginActions:wo(t,e,a),mfaActions:Lo(t,e,a),allAccountsActions:Ho(t,e,a),allAccountsDialogActions:zo(t),passkeysActions:Jo(t,e,a),profileActions:Zo(t,e,a),provisioningActions:sr(t,e),resetPhoneNumberActions:dr(t,e,a),rolesActions:Ar(t,e),restrictionsActions:kr(t,e,a),securityCenterActions:Lr(t,e,a),securityPolicyActions:jr(t,e,a),sessionsPolicyActions:Hr(t,e,a),sessionsActions:qr(t,e),signUpActions:tl(t,e,a),smsActions:cl(t,e),socialLoginActions:hl(t,e,a),ssoActions:wl(t,e,a),stepUpActions:Il(t,e,a),teamActions:jl(t,e,a),tenantsActions:Wl(t,e,a)};return[v({setAuthState:s,setErrorByRequestName:e=>{let{requestName:a}=e,n=f(e,Kl);t.auth.errorByRequest=v({},t.auth.errorByRequest,{[a]:v({},n,{isError:!0})})},setState:s,resetAuthState:(e={})=>{Cn(t,["auth"],v({},n,e))},setUser:t=>{s({user:t})}},Object.values(i).reduce(((t,e)=>v({},t,e)),{})),i]},Yl={isLoading:!1,isSaving:!1,list:[],processIds:[],slackChannels:{isLoading:!1}},Xl=t=>en(Yl,t),Ql=["email","slack","sms","webhook"],Zl={sms:{title:"connectivity.sms",events:t=>(null==t?void 0:t.length)||0,isActive:t=>{var e;return null!=(e=null==t?void 0:t.some((({enabled:t})=>t)))&&e},image:"sms"},email:{title:"common.email",events:t=>(null==t?void 0:t.length)||0,isActive:t=>{var e;return null!=(e=null==t?void 0:t.some((({enabled:t})=>t)))&&e},image:"email"},slack:{title:"connectivity.slack",events:t=>{var e;return(null==t||null==(e=t.slackSubscriptions)?void 0:e.length)||0},isActive:t=>!(null==t||!t.slackSubscriptions.some((({isActive:t})=>t))),image:"slack"},webhook:{title:"connectivity.webhook",events:t=>(null==t?void 0:t.length)||0,isActive:t=>{var e;return null!=(e=null==t?void 0:t.some((({isActive:t})=>t)))&&e},image:"webhook"}},tc=["id"],ec=["id","enabled"],ac=(t,e,a)=>{const n={slack:e.connectivity.getSlackConfiguration,email:e.connectivity.getEmailConfiguration,sms:e.connectivity.getSMSConfiguration,webhook:e.connectivity.getWebhooksConfigurations,categories:e.connectivity.getCategories,channelMap:e.connectivity.getChannelMaps},s=["categories","channelMap"],i={slack:e.connectivity.postSlackConfiguration,email:e.connectivity.postEmailConfiguration,sms:e.connectivity.postSMSConfiguration,webhook:e.connectivity.postWebhooksConfiguration},o=e=>{Object.assign(t.connectivity,e)},r=e=>{var a;const n=null!=(a=t.connectivity.retryResult)?a:{};t.connectivity.retryResult=v({},n,e)},l=()=>{Cn(t,["connectivity"],Yl)},c=async(t,e,a)=>{try{return await On((()=>n[t](e)),a)}catch(t){return}},u=async()=>{try{o({slackChannels:{isLoading:!0}});const t=await e.connectivity.getSlackChannels();o({error:void 0,slackChannels:{isLoading:!1,data:t}})}catch(t){o({error:void 0,slackChannels:{isLoading:!1}})}},d=async t=>{const e=null!=t?t:Ql;o({isLoading:!0});try{const t=await Promise.all([...e.map((t=>c(t,void 0,Tn))),c("categories",void 0,Tn),(async()=>(await Promise.all(e.map((t=>c("channelMap",t,Tn))))).reduce(((t,a,n)=>v({},t,{[`${e[n]}`]:a})),{}))()]),a=await c("webhook",void 0,Tn),n=t.reduce(((a,n,i)=>e[i]?t[t.length-1][e[i]].length?v({},a,{[`${e[i]}`]:n,list:[...a.list,{id:i,key:e[i],events:Zl[e[i]].events(n),active:Zl[e[i]].isActive(n),platform:Zl[e[i]].title,image:Zl[e[i]].image}]}):a:v({},a,{[`${s[i-e.length]}`]:n})),{list:[],webhook:a});o(v({},n,{error:void 0,isSaving:!1,isLoading:!1}))}catch(t){o({isLoading:!1,error:Nn(t)})}},g=async(e,a)=>{const{list:n}=t.connectivity,s=n.find((({key:t})=>t===e));if(!s)return;const i=Zl[e].isActive(a);i!==s.active&&o({list:n.map((t=>t.key===e?v({},t,{active:i}):t))})},p=async a=>{const{platform:n,data:s,callback:r}=a,l=t.connectivity.processIds;try{if(o({isSaving:!0,processIds:"webhook"===n?[s._id,...l]:l}),"slack"===n?await(async a=>{var n;const s=null==(n=t.connectivity.slack)?void 0:n.slackSubscriptions;if(!s)return;const{slackSubscriptions:o}=a;await Promise.all([...o.reduce(((t,e)=>{var a,n;return!e.id&&e.slackEvents&&null!=(a=e.slackEvents[0].channelIds)&&a.length||(null==s?void 0:s.find((t=>{let{id:a}=t,n=f(t,tc);return a===e.id&&JSON.stringify(v({id:a},n))!==JSON.stringify(e)})))&&e.slackEvents&&null!=(n=e.slackEvents[0].channelIds)&&n.length?[...t,e]:t}),[]).map((t=>i.slack(t))),...o.reduce(((t,e)=>e.id&&!e.slackEvents[0].channelIds.length?[...t,e]:t),[]).map((t=>e.connectivity.deleteSlackConfiguration(t)))])})(s):["sms","email"].includes(n)?await(async(a,n)=>{const s=t.connectivity.processIds,i=t.connectivity[n];if(!i)return;let r=[];try{r=await Promise.all([...a.reduce(((t,e)=>!i.find((({eventKey:t})=>t===e.eventKey))&&e.subscriptions[0].recipients.filter((t=>t)).length?[...t,e]:t),[]).map((t=>"email"===n?e.connectivity.postEmailConfiguration(t):e.connectivity.postSMSConfiguration(t))),...a.reduce(((t,e)=>{const a=i.find((({eventKey:t})=>t===e.eventKey));return a&&JSON.stringify(a)!==JSON.stringify(e)?[...t,e]:t}),[]).map((t=>{const{subscriptions:a,eventKey:s}=t,i=a[0],{id:o="",enabled:r}=i,l=f(i,ec);return Promise.all(["email"===n?e.connectivity.patchEmailConfiguration({eventKey:s,enabled:r}):e.connectivity.patchSMSConfiguration({eventKey:s,enabled:r}),"email"===n?e.connectivity.putEmailSubscriptions(o,s,v({},l,{enabled:r})):e.connectivity.putSMSSubscriptions(o,s,v({},l,{enabled:r}))])})),...a.reduce(((t,e)=>{const a=i.find((({eventKey:t})=>t===e.eventKey));return a&&a.subscriptions[0].recipients.length&&!e.subscriptions[0].recipients.filter((t=>!!t)).length?[...t,e]:t}),[]).map((({eventKey:t,subscriptions:a})=>"email"===n?e.connectivity.deleteEmailSubscriptions(t,a[0].id||""):e.connectivity.deleteSMSSubscriptions(t,a[0].id||"")))])}catch{}if(r.length){const t=await c(n);o({error:void 0,isSaving:!1,[`${n}`]:t,processIds:t.id?s.filter((e=>e!==t.id)):s}),await g(n,t)}else o({error:void 0,isSaving:!1,[`${n}`]:i,processIds:s})})(s,n):await i[n](s),!["sms","email"].includes(n)){const t=await c(n);"webhook"===n&&(t.id=s._id),o({error:void 0,isSaving:!1,[`${n}`]:t,processIds:t.id?l.filter((e=>e!==t.id)):l}),await g(n,t),null==r||r(!0)}}catch(t){o({error:Nn(t),isSaving:!1,isLoading:!1})}},h=async t=>{try{await e.connectivity.postSlackCode(t)}catch{}o({error:void 0,isSaving:!1})},y=async()=>{const a=t.connectivity.slackChannels;try{o({slackChannels:v({},a,{isLoadingScope:!0})});const{clientId:t}=await e.connectivity.getSlackScope();o({slackChannels:{error:void 0,clientId:t,isLoadingScope:!1,isLoading:!1}})}catch{o({slackChannels:{error:void 0,isLoadingScope:!1,isLoading:!1}})}},S=async a=>{const{callback:n,webhookId:s}=a,i=t.connectivity.processIds;try{o({isSaving:!0}),await e.connectivity.deleteWebhooksConfiguration(s)}catch(t){null==n||n(null,Nn(t))}const r=await c("webhook");r&&o({error:void 0,isSaving:!1,webhook:r,processIds:r.id?i.filter((t=>t!==r.id)):i}),null==n||n(!0)},m=async t=>{try{o({isTesting:!0});const{statusCode:a,body:n}=await e.connectivity.postWebhookTest(t);if([201,200].includes(a)){const t=JSON.stringify(n,null,2);o({isTesting:!1,testResult:{status:"success",message:t}})}else o({isTesting:!1,testResult:{status:"failed"}})}catch(t){o({isTesting:!1,testResult:{status:"failed",message:Nn(t)}})}},b=async t=>{try{const{statusCode:a}=await e.connectivity.postWebhookRetry(t);r({[t]:{isProcess:!1,success:202===a}})}catch(e){r({[t]:{isProcess:!1,success:!1}})}},A=async a=>{const{id:n,limit:s,offset:i}=a,r=t.connectivity.webhookLogs;try{o({webhookLogs:v({},r,{isLoading:!0})});const t=await e.connectivity.getWebhookLog(n,i,s);o({error:void 0,webhookLogs:v({isLoading:!1},t)})}catch(t){o({error:void 0,webhookLogs:{isLoading:!1}})}};return{setConnectivityState:o,initData:l,resetConnectivityState:l,loadSlackActions:u,loadSlackChannels:u,loadDataAction:d,loadConnectivityChannels:d,postDataAction:p,postChannelData:p,postCodeAction:h,postSlackCode:h,loadScope:y,loadSlackPermissions:y,deleteWebhookConfigAction:S,deleteWebhookConfig:S,postWebhookTestAction:m,postWebhookTest:m,postWebhookRetryAction:b,postWebhookRetry:b,loadWebhookLogsAction:A,loadWebhookLogs:A,cleanWebhookTestData:()=>{o({testResult:void 0})},cleanWebhookLogsData:async()=>{o({webhookLogs:void 0})},cleanWebhookTestMessage:async t=>{var e;o({testResult:{status:null==(e=t.testResult)?void 0:e.status,message:void 0}})},cleanError:async()=>{o({error:void 0})},cleanSlackData:async()=>{o({slackChannels:{isLoading:!1}})}}};let nc;!function(t){t.UNKNWON="unknown",t.CARD="card"}(nc||(nc={}));const sc={loading:!1,error:null,fetching:!0,config:null},ic=t=>en(sc,t);let oc,rc,lc;!function(t){t.STRIPE="Stripe"}(oc||(oc={})),function(t){t.ACTIVE="ACTIVE",t.CANCELED="CANCELED",t.INCOMPLETE="INCOMPLETE",t.EXPIRED="EXPIRED",t.TRIALING="TRIALING"}(rc||(rc={})),function(t){t.AT_PERIOD_END="atPeriodEnd"}(lc||(lc={}));const cc=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.config,e)},s=e=>{Object.assign(t.subscriptions.config,{error:e,loading:!1,fetching:!1})};return{setPaymentConfigState:n,resetPaymentConfigState:()=>{Cn(t,["subscriptions","config"],sc)},loadPaymentConfiguration:async()=>{n({loading:!0});try{var t;(null!=(t=await e.subscriptions.getPaymentProviders())?t:[]).find((t=>"1"===t.status&&t.providerType===j.Stripe))?await(async()=>{n({loading:!0});try{const t=await e.subscriptions.getStripePaymentProviderConfiguration(),a={paymentProvider:oc.STRIPE,apiKey:t.publishableKey};n({config:a}),n({loading:!1,fetching:!1})}catch(t){s(Nn(t))}})():s(Nn("Payment provider not configured"))}catch(t){s(Nn(t))}}}},uc={loading:!1,error:null,fetching:!0},dc=t=>en(uc,t);function gc({policy:t}){return{policy:lc.AT_PERIOD_END}}function pc(t){switch(t){case x.ACTIVE:return rc.ACTIVE;case x.INCOMPLETE:return rc.INCOMPLETE;case x.CANCELED:return rc.CANCELED;case x.EXPIRED:return rc.EXPIRED;case x.TRIALING:return rc.TRIALING;default:return rc.EXPIRED}}const hc=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.subscriptions.billing.information,e)},i=t=>{s({error:t,loading:!1,fetching:!1})},o=async(a,o)=>{s({loading:!0});try{var r,l;const i=await e.subscriptions.getSubscriptionSummaries(a),{currentPlanId:c,externallyManaged:u}=i;let d,g=null;u?d=await e.subscriptions.getSubscriptionPlan(c):([,d]=await Promise.all([n.loadSubscription(),e.subscriptions.getSubscriptionPlan(c)]),g=t.subscriptions.billing.subscription.subscription||null),s(v({loading:!1,fetching:!1,summary:i},g?{subscription:{id:g.id,externalId:g.externalId,startDate:g.startDate,currentPeriodStart:g.currentPeriodStart,currentPeriodEnd:g.currentPeriodEnd,status:o?rc.ACTIVE:pc(g.status),cancellation:g.cancellation&&gc(g.cancellation),trialEnd:g.trialEnd?g.trialEnd:null}}:{},d?{plan:{id:d.id,name:d.name,description:d.description,price:(null==(r=d.price)?void 0:r.amount)||0,currency:(null==(l=d.price)?void 0:l.currency)||"usd",recurringInterval:"month",slug:d.slug}}:{}))}catch(t){i(Nn(t))}};return{setBillingInformationState:s,resetBillingInformationState:()=>{Cn(t,["subscriptions","billing","information"],uc)},loadSummaries:o,loadBillingInformation:async e=>{var a,n;const s=null==(a=t.subscriptions.config.config)?void 0:a.paymentProvider,r=null==(n=t.auth.user)?void 0:n.tenantId;s&&r?await o(r,e):i(new W(s?"Not authorized":"Internal feature failure",500,null))}}},yc={loading:!1,error:null,fetching:!0,invoices:[],invoiceDownload:{loading:!1,error:null}},Sc=t=>en(yc,t),vc=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.billing.invoices,e)},s=e=>{Object.assign(t.subscriptions.billing.invoices.invoiceDownload,e)},i=async()=>{n({loading:!0});try{const t=(await e.subscriptions.getSubscriptionInvoices()).map((t=>({id:t.id,externalId:t.externalId,subscriptionId:t.subscriptionId,paymentDate:new Date(Date.parse(t.paymentDate)),totalAmount:+((t.totalAmount||0)/100).toFixed(2),currency:t.currency||"usd",paid:t.paid||!1,receiptNumber:t.receiptNumber})));n({loading:!1,fetching:!1,invoices:t})}catch(e){t=Nn(e),n({error:t,loading:!1,fetching:!1})}var t},o=async t=>{s({loading:!0,error:null});try{await e.subscriptions.getSubscriptionInvoicePdf(t.invoiceId,t.filename),s({loading:!1,error:null})}catch(t){s({loading:!1,error:Nn(t,null)})}};return{setBillingInvoiceState:n,resetBillingInvoiceState:()=>{Cn(t,["subscriptions","billing","invoices"],yc)},loadInvoices:i,loadBillingInvoices:i,downloadInvoice:o,downloadBillingInvoice:o}},fc={loading:!1,error:null,fetching:!0},mc=t=>en(fc,t),bc=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.billing.paymentMethod,e)},s=t=>{n({loading:t})},i=t=>{n({error:t,loading:!1,fetching:!1})},o=async()=>{s(!0);try{const t=(await e.subscriptions.getPaymentMethods())[0];n({paymentMethod:t,loading:!1,fetching:!1})}catch(t){i(Nn(t))}};return{setBillingPaymentMethodState:n,resetBillingPaymentMethodState:()=>{Cn(t,["subscriptions","billing","paymentMethod"],fc)},loadPaymentMethod:o,submitPaymentMethod:async()=>{s(!0)},submitPaymentMethodError:async t=>{i(t)},submitPaymentMethodSuccess:async()=>await o(),updatePaymentMethodBillingDetails:async t=>{s(!0);const{id:a,email:n,address:r,callback:l}=t;try{await e.subscriptions.updatePaymentMethodBillingDetails(a,v({email:n},r)),await o(),null==l||l(!0)}catch(t){i(Nn(t)),null==l||l(!1,t)}finally{s(!1)}}}},Ac={loading:!1,error:null,fetching:!0,cancellation:{loading:!1,error:null},renewal:{loading:!1,error:null}},wc=t=>en(Ac,t),Tc=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.subscriptions.billing.subscription,e)},i=t=>{s({error:t,loading:!1,fetching:!1})},o=e=>{Object.assign(t.subscriptions.billing.subscription.cancellation,{loading:e})},r=e=>{Object.assign(t.subscriptions.billing.subscription.cancellation,{error:e})},l=e=>{Object.assign(t.subscriptions.billing.subscription.renewal,{loading:e})},c=e=>{Object.assign(t.subscriptions.billing.subscription.renewal,{error:e})},u=async()=>{s({loading:!0});try{const[t]=await e.subscriptions.getManagedSubscriptions();s({subscription:t,fetching:!1,loading:!1,error:null})}catch(t){i(Nn(t))}};return{setBillingSubscriptionState:s,resetBillingSubscriptionState:()=>{Cn(t,["subscriptions","billing","subscription"],Ac)},setCancellationLoading:o,setCancellationError:r,setRenewalLoading:l,setRenewalError:c,loadSubscription:u,loadSubscriptionTenant:async()=>{var e;const a=null==(e=t.auth.user)?void 0:e.tenantId;a?await n.loadSummaries(a):i(new W("TenantId is not defined",500,null))},cancelSubscription:async()=>{const{subscription:a}=t.subscriptions.billing.subscription;if(!a)return void r(new W("Subscription not found",500,null));if(null!=a&&a.externallyManaged)return void r(new W("Billing is externally managed",500,null));const{id:n,cancellation:s,status:i}=a||{};if(!s&&i===x.ACTIVE)try{o(!0),await e.subscriptions.cancelManagedSubscription(n),await u(),o(!1)}catch(t){r(Nn(t))}},renewSubscription:async()=>{const{subscription:a}=t.subscriptions.billing.subscription;if(!a)return void c(new W("Subscription not found",500,null));if(null!=a&&a.externallyManaged)return void c(new W("Billing is externally managed",500,null));const{id:n,cancellation:s}=a||{};if((null==s?void 0:s.policy)===G.AT_PERIOD_END)try{l(!0),await e.subscriptions.renewManagedSubscription(n),await u(),l(!1)}catch(t){c(Nn(t))}}}},Ec=t=>en({information:dc(null==t?void 0:t.information),invoices:Sc(null==t?void 0:t.invoices),paymentMethod:mc(null==t?void 0:t.paymentMethod),subscription:wc(null==t?void 0:t.subscription)}),Ic={loading:!1,error:null,fetching:!0,plans:[]},Oc=t=>en(Ic,t),Pc=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.plans,e)};return{setPlansState:n,resetPlansState:()=>{Cn(t,["subscriptions","plans"],Ic)},loadPlans:async()=>{n({loading:!0});try{const t=(await e.subscriptions.getSubscriptionPlans()).map((t=>{var e,a;return{id:t.id,name:t.name,description:t.description,price:(null==(e=t.price)?void 0:e.amount)||0,currency:(null==(a=t.price)?void 0:a.currency)||"usd",recurringInterval:"month",slug:t.slug}}));n({fetching:!1,loading:!1,plans:t})}catch(e){t=Nn(e),n({loading:!1,fetching:!1,error:t})}var t}}},kc={fetching:!0,loading:!1,error:null,confirmed:!1},_c=t=>en(kc,t),Rc=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.subscriptions.checkout,e)};return{setCheckoutState:s,resetCheckoutState:()=>{Cn(t,["subscriptions","checkout"],kc)},loadCheckout:()=>{s({fetching:!1,loading:!1,error:null,confirmed:!1})},resetCheckout:()=>{s({loading:!1,error:null,confirmed:!1})},submitCheckout:()=>{s({loading:!0,error:null})},confirmCheckout:async a=>{const{paymentMethodId:i,planId:o}=a,r=t.subscriptions.billing.subscription.subscription,l=t.subscriptions.billing.information.summary,c=(null==r?void 0:r.status)===x.TRIALING,u=!(null==l||!l.paymentMethodId);if(r){if(s({loading:!0,error:null}),c&&u)return s({loading:!1,error:null,confirmed:!0}),void n.setBillingSubscriptionState({subscription:v({},r,{status:x.ACTIVE})});try{await e.subscriptions.updateManagedSubscription(r.id,{paymentMethodId:i,planId:o}),await Promise.all([n.loadBillingInformation(),n.loadPaymentMethod(),n.loadInvoices()]),s({loading:!1,error:null,confirmed:!0})}catch(t){s({loading:!1,error:Nn(t)})}}else s({loading:!1,error:new W("Subscription not found",500,null)})},errorCheckout:t=>{s({loading:!1,error:t})}}},Uc={loading:!1,error:null,cardSetupIntentSecret:null},Cc=t=>en(Uc,t),Lc=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.stripe,e)};return{createCardSetupIntentSecret:async a=>{n({loading:!0,error:null,cardSetupIntentSecret:null});try{const t={};a&&(t.paymentMethodId=a);const{setupIntentSecret:s}=await e.subscriptions.createStripePaymentMethodSetupIntentSecret(t);n({cardSetupIntentSecret:s,loading:!1})}catch(e){s=Nn(e),Object.assign(t.subscriptions.stripe,{error:s,loading:!1,fetching:!1})}var s},setStripeState:n,resetStripeState:()=>{Cn(t,["subscriptions","stripe"],Uc)}}},Dc={loading:!1,fetching:!0,vendorPublicConfig:null},Nc=t=>en(Dc,t),Mc=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.vendorPublicConfig,e)},s=e=>{Object.assign(t.subscriptions.vendorPublicConfig,{error:e,loading:!1,fetching:!1})},i=e=>{Object.assign(t.subscriptions.vendorPublicConfig,{error:null,loading:e})};return{setVendorPublicConfigState:n,resetVendorPublicConfigState:()=>{Cn(t,["subscriptions","vendorPublicConfig"],Dc)},setVendorPublicConfigError:s,setVendorPublicConfigLoading:i,loadVendorPublicConfiguration:async()=>{i(!0);try{const t=await e.subscriptions.getVendorPublicConfigurations();n({fetching:!1,loading:!1,vendorPublicConfig:t})}catch(t){s(Nn(t))}}}},Fc=t=>en({config:ic(null==t?void 0:t.config),billing:Ec(null==t?void 0:t.billing),plans:Oc(null==t?void 0:t.plans),checkout:_c(null==t?void 0:t.checkout),stripe:Cc(null==t?void 0:t.stripe),vendorPublicConfig:Nc(null==t?void 0:t.vendorPublicConfig)}),xc=(t,e,a)=>{const n=cc(t,e),[s,i]=((t,e,a)=>{const n=hc(t,e,a),s=bc(t,e),i=vc(t,e),o=Tc(t,e,a);return[v({},n,s,i,o),{information:n,invoices:i,paymentMethod:s,subscription:o}]})(t,e,a),o=Pc(t,e),r=Rc(t,e,a),l=Lc(t,e),c=Mc(t,e);return[v({},n,s,o,r,l,c),{config:n,billing:i,plans:o,checkout:r,stripe:l,vendorPublicConfig:c}]},$c={loading:!1},Gc=t=>en($c,t),jc=(t,e,a)=>{const n=e=>{Object.assign(t.vendor,e)},s=async t=>{n({loading:!0});try{var a;const s=await On((()=>e.vendor.getVendorPublicInfo()),null==t?void 0:t.retryConfig);s.whiteLabelMode=null!=(a=s.whiteLabelMode)&&a,n(v({},s,{loading:!1}))}catch(t){n({loading:!1}),console.error("failed to getVendorPublicInfo - ",t)}};return{setVendorState:n,resetVendorState:()=>{Cn(t,["vendor"],$c)},loadVendorPublicInfo:s,loadVendorPublicConfiguration:s}},Bc={loading:!0,pageOffset:0,pageSize:20,logs:[],sort:[],filter:[],totalPages:0,isDownloadingCsv:!1},Vc=t=>en(Bc,t),Wc=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auditLogs.auditLogsState,e)};return{setAuditLogsState:s,resetAuditLogsState:()=>{Cn(t,["auditLogs","auditLogsState"],Bc)},exportAuditsCsv:async()=>{const a=t.auditLogs.auditLogsState,{columns:n}=t.auditLogs.auditsMetadataState;try{const t=a.filter,i=a.sort.reduce(((t,e)=>v({},t,{sortBy:e.id,sortDirection:e.desc?"desc":"asc"})),{}),o=t.reduce(((t,e)=>v({},t,{[e.id]:e.value})),{});s({isDownloadingCsv:!0});const r="audits.csv";await e.audits.exportAudits(v({endpoint:"csv/v2",headerProps:n,offset:0,outputFileName:r},i,o))}catch(t){console.error("failed to export audits - ",t)}s({isDownloadingCsv:!1})},loadAuditLogs:async a=>{s({loading:!(null!=a&&a.silentLoading),error:null});const i=t.auditLogs.auditLogsState,o=null==a?void 0:a.retryConfig,{columns:r}=t.auditLogs.auditsMetadataState;try{var l,c,u,d,g;const t=null!=(l=a.pageSize)?l:i.pageSize,p=null!=(c=a.pageOffset)?c:i.pageOffset,h=null!=(u=a.filter)?u:i.filter,y=null!=(d=a.sort)?d:i.sort;s({pageSize:t,pageOffset:p,filter:h,sort:y});const S=y.reduce(((t,e)=>v({},t,{sortBy:e.id,sortDirection:e.desc?"desc":"asc"})),{}),f=h.reduce(((t,e)=>v({},t,{[e.id]:e.value})),{});r||await n.loadAuditsMetadata({retryConfig:o});const{data:m,total:b}=await On((()=>e.audits.getAudits(v({offset:p,count:t},S,f))),o);s({loading:!1,logs:null!=m?m:[],totalPages:+Math.ceil(b/t)}),null==a||null==(g=a.callback)||g.call(a,!0)}catch(t){var p;s({loading:!1,error:Nn(t)}),null==a||null==(p=a.callback)||p.call(a,null,t)}}}},Hc={loading:!0},zc=t=>en(Hc,t),Kc=(t,e,a)=>{const n=e=>{Object.assign(t.auditLogs.auditsMetadataState,e)};return{setAuditsMetadataState:n,resetAuditsMetadataState:()=>{Cn(t,["auditLogs","auditsMetadataState"],Hc)},loadAuditsMetadata:async t=>{n({loading:!0,error:null});try{const{properties:a}=await On((()=>e.metadata.getAuditsMetadata()),null==t?void 0:t.retryConfig);n({columns:a,loading:!1})}catch(t){n({error:t,loading:!1})}}}},qc=t=>({auditLogsState:Vc(null==t?void 0:t.auditLogsState),auditsMetadataState:zc(null==t?void 0:t.auditsMetadataState)}),Jc=(t,e,a)=>v({},Wc(t,e,a),Kc(t,e)),Yc={total:0,offset:0,filter:"",sortBy:"createdAt",context:null,filters:[],rowsData:[],lastUpdated:new Date,isLoading:!0,isFetchMore:!1,totalToday:0,currentPage:0,headerProps:[],sortDirection:"desc",severeThisWeek:0,predefinedFilters:[],isDownloadingCsv:!1,virtualScroll:!1},Xc=(t,e)=>Object.keys(t).reduce(((a,n)=>{const s=n;return e.includes(n)?v({},a,{[n]:t[s]}):v({},a,{[n]:()=>{console.debug(`Action ${String(n)} was called`)}})}),{}),Qc={clientId:"CLIENT_ID_16806d3d-8fc3-4450-be97-abdaf66b723e",secret:"SECRET_16806d3d-8fc3-4450-be97-abdaf66b723e",createdAt:"createdAt",description:"Demo API Token (preview only)"},Zc=v({},Qc,{roleIds:[],tenantId:"my-tenant-id",createdByUserId:"createdByUserId"}),tu=[{id:"a040dcf6-b907-4e83-9970-6bd23c88fd40",key:"ReadOnly",name:"Read Only",description:null,isDefault:!1,createdAt:new Date,updatedAt:new Date,permissions:["8d71b676-754c-4600-afe7-ca5add1e6809","04dbcc11-61db-40a9-9577-9b73e50d1d03"],vendorId:"vendorId"},{id:"b43b2c4b-e056-4eec-8c55-d200a475bbc0",key:"Admin",name:"Admin",description:null,isDefault:!0,createdAt:new Date,updatedAt:new Date,permissions:["8d71b676-754c-4600-afe7-ca5add1e6809","04dbcc11-61db-40a9-9577-9b73e50d1d03","16647407-ed6f-4ca6-83a0-86225d921959","f403c6b9-1abe-4ec7-9971-aa032255fc25","a43e059d-d731-44b1-94bb-fb6b16c62210"],vendorId:"vendorId"},{id:"1234",key:"Support",name:"Support",description:null,isDefault:!0,createdAt:new Date,updatedAt:new Date,permissions:["8d71b676-754c-4600-afe7-ca5add1e6809","04dbcc11-61db-40a9-9577-9b73e50d1d03","f26b00f8-ffe0-4739-b15c-7db15c27ea26","a9c803b0-ebfa-49b9-9607-f0d3a390ee61"],tenantId:"tenantId",vendorId:"vendorId"}],eu={sub:"",tenants:[],id:"testId",name:"Demo User Name",email:"demo-user@frontegg.com",mfaEnrolled:!0,profilePictureUrl:"https://www.gravatar.com/avatar/42b2ad2bad6fc9b9db5086dfcf8072ac?d=https://ui-avatars.com/api/fe/128/random?t=1617261890875?t=1617261917434",roles:[{id:"roleId",key:"admin",isDefault:!1,name:"Admin",description:null,permissions:["8d71b676-754c-4600-afe7-ca5add1e6809","04dbcc11-61db-40a9-9577-9b73e50d1d03"],tenantId:"tenantId",vendorId:"vendorId",createdAt:new Date,updatedAt:new Date}],permissions:[{id:"8d71b676-754c-4600-afe7-ca5add1e6809",key:"fe.*",name:"General Admin",description:"description",categoryId:"category",fePermission:!0,createdAt:new Date,updatedAt:new Date,roleIds:[]}],tenantId:"my-tenant-id",tenantIds:["my-tenant-id"],activatedForTenant:!0,metadata:JSON.stringify({phoneNumber:"+972-54123456",jobTitle:"Developer",address:{city:"Tel Aviv",country:"Israel"}}),verified:!1},au=v({},eu,{accessToken:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1MTY5YmY0Zi02YmI5LTQ5NGMtOGNkZS05MDc4NDQ0NWY4MDciLCJuYW1lIjoiRHVtbXkgVXNlciIsImVtYWlsIjoiZHVtbXlAZnJvbnRlZ2cuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsIm1ldGFkYXRhIjp7fSwicm9sZXMiOlsiYWRtaW4iXSwicGVybWlzc2lvbnMiOlsiZmUuKiJdLCJ0ZW5hbnRJZCI6Im15LXRlbmFudC1pZCIsInRlbmFudElkcyI6WyJteS10ZW5hbnQtaWQiXSwicHJvZmlsZVBpY3R1cmVVcmwiOiJodHRwczovL3d3dy5ncmF2YXRhci5jb20vYXZhdGFyLzQyYjJhZDJiYWQ2ZmM5YjlkYjUwODZkZmNmODA3MmFjP2Q9aHR0cHM6Ly91aS1hdmF0YXJzLmNvbS9hcGkvZmUvMTI4L3JhbmRvbT90PTE2MTcyNjE4OTA4NzU_dD0xNjE3MjYxOTE3NDM0IiwidHlwZSI6InVzZXJUb2tlbiIsImlhdCI6MTYxNzkwNjMyNCwiZXhwIjoxNjE3OTkyNzI0LCJpc3MiOiJmcm9udGVnZyJ9.paaXLkpWEWbQmUtoK2P8IwXCxK4WJp7XhXonvzF8g1I",expiresIn:86400,mfaRequired:!1,refreshToken:"refresh-token-dummy-de39dc9c-9d22-4852-b7f5-c3c0aa613b58",type:"userToken",iat:1617906324,exp:1617992724,iss:"frontegg",email_verified:!0}),nu={loading:!1,error:void 0,saving:!0,profile:eu},su={id:"id",enforceMFAType:"DontForce",createdAt:new Date,updatedAt:new Date,allowOverrideEnforcePasswordHistory:!0,allowOverridePasswordComplexity:!1,allowOverridePasswordExpiration:!1,allowSignups:!0,apiTokensEnabled:!0,cookieSameSite:"cookieSameSite",defaultRefreshTokenExpiration:0,defaultTokenExpiration:1,publicKey:"publicKey"},iu={allowSignups:!0,allowNotVerifiedUsersLogin:!1,apiTokensEnabled:!0,forcePermissions:!1,authStrategy:N.EmailAndPassword,machineToMachineAuthStrategy:M.ClientCredentials},ou={id:"id",enforceMFAType:"DontForce",createdAt:new Date,updatedAt:new Date},ru={id:"id",enabled:!0,maxAttempts:1,createdAt:new Date,updatedAt:new Date},lu={id:"id",enabled:!0,historySize:1,createdAt:new Date,updatedAt:new Date},cu={enabled:!0,domain:"domain",validated:!0,generatedVerification:"generatedVerification",ssoEndpoint:"ssoEndpoint",publicCertificate:"publicCertificate",signRequest:!0,createdAt:new Date,updatedAt:new Date,acsUrl:void 0,spEntityId:void 0,oidcClientId:void 0,oidcSecret:void 0,type:void 0},uu={id:"id",createdAt:"createdAt",updatedAt:"updatedAt",properties:[],vendorId:"vendorId",entityName:"saml",isActive:!0,configuration:{acsUrl:"acsUrl",spEntityId:"spEntityId"}},du=[{id:"id",description:"description",key:"key",name:"name",permissions:[],permissionLevel:1}],gu={firstLoad:!1,loading:!1,error:void 0,saving:!1,samlConfiguration:cu,roles:du,authorizationRoles:[],errors:{},loaders:{},ssoConfigurations:[]},pu=[{description:"string",fePermission:!0,id:"id",key:"key",name:"name",roleIds:[],createdAt:new Date,updatedAt:new Date,categoryId:"categoryId"}],hu={id:"id2",email:"demo-user2@frontegg.com",name:"Demo User Name2",phone:void 0,profileImage:void 0,profileImageUrl:void 0,tenantId:"tenantId",vendorId:"vendorId",roleIds:[],activatedForTenant:!0,verified:!1,createdAt:(new Date).toISOString(),customData:void 0,lastLogin:void 0,mfaEnabled:void 0,roles:[tu[0]],groups:[{id:"id2",name:"Developers",color:"#03A9F4",roles:[tu[0]],managedBy:$a.FRONTEGG}]},yu={id:hu.id,email:hu.email,name:hu.name,phoneNumber:void 0,profileImage:void 0,tenantId:"tenantId",activatedForTenant:!0,createdAt:new Date(2022,4,1),verified:!0,lastLogin:new Date(2022,5,25),mfaEnrolled:!1,roles:[tu[1]],tenantIds:[],metadata:"",sub:"",tenants:[]},Su={id:"id",email:"demo-user@frontegg.com",name:"Demo User Name",phone:void 0,profileImage:void 0,profileImageUrl:void 0,tenantId:"tenantId",vendorId:"vendorId",roleIds:[],activatedForTenant:!0,createdAt:new Date(2022,4,1).toISOString(),verified:!0,customData:void 0,lastLogin:new Date(2022,5,25).toISOString(),mfaEnabled:void 0,roles:[tu[1]],groups:[{id:"id1",name:"Designers",color:"#E1F5E2",roles:[tu[0]],managedBy:$a.FRONTEGG}]},vu={id:Su.id,email:Su.email,name:Su.name,phoneNumber:void 0,profileImage:void 0,tenantId:"tenantId",activatedForTenant:!0,createdAt:new Date(2022,4,1),verified:!0,lastLogin:new Date(2022,5,25),mfaEnrolled:!1,roles:[tu[1]],tenantIds:[],metadata:"",sub:"",tenants:[]},fu={metadata:"",mfaEnrolled:!1,provider:"",sub:"",tenantIds:[],tenants:[],verified:!1,id:"id",email:"email",name:"name",tenantId:"tenantId",createdAt:new Date},mu=[Su,hu],bu=[vu,yu],Au=[fu],wu=[{id:"my-tenant-id",isReseller:!1,name:"Frontegg demo",deletedAt:null,metadata:void 0,tenantId:"my-tenant-id",vendorId:"vendorId",createdAt:new Date,updatedAt:new Date,address:void 0,timezone:void 0,dateFormat:void 0,timeFormat:void 0,currency:void 0,logo:void 0}],Tu=[{id:"laptop",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Safari/605.1.15",createdAt:new Date,ipAddress:"190.194.88.251",current:!0},{id:"iphone",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_2_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Mobile/15E148 Safari/604.1",createdAt:new Date(Date.now()-1e4),ipAddress:"191.49.203.21"},{id:"tablet",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; SGP771 Build/32.2.A.0.253; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.98 Safari/537.36",createdAt:new Date(Date.now()-3e4),ipAddress:"130.19.196.136"},{id:"anotherlaptop",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Safari/605.1.15",createdAt:new Date(Date.now()-1002232300),ipAddress:"2.228.163.92"}],Eu={isActive:!0,strategy:zt.ALLOW},Iu=[{updatedAt:new Date,createdAt:new Date,id:"1",ip:"255.255.255.255",isActive:!0,strategy:zt.ALLOW,description:"My IP"},{updatedAt:new Date,createdAt:new Date,id:"2",ip:"255.255.255.254",isActive:!0,strategy:zt.ALLOW,description:"IP 2"},{updatedAt:new Date,createdAt:new Date,id:"3",ip:"255.255.255.253",isActive:!0,strategy:zt.BLOCK,description:"IP 3"},{updatedAt:new Date,createdAt:new Date,id:"4",ip:"255.255.255.253",isActive:!0,strategy:zt.BLOCK,description:"IP 4"}],Ou=t=>{const e=[];return Array.from({length:t}).forEach(((t,a)=>{e.push(v({},Su,{name:"Demo User",id:`id${a}`,profilePictureUrl:null,createdAt:new Date}))})),e},Pu=t=>({id:"b43b2c4b-e056-4eec-8c55-d200a475bbc0"+t,key:t,name:t,description:null,isDefault:!0,createdAt:new Date,updatedAt:new Date,permissions:[],tenantId:"tenantId",vendorId:"vendorId"}),ku=[{id:"id1",name:"Designers",color:"#E1F5E2",description:"The whole design team",users:Ou(6),roles:[Pu("Editor")],metadata:'{"lastTermsCheck":"2022-08-16T10:31:11.270Z"}',managedBy:$a.FRONTEGG},{id:"id2",name:"Developers",color:"#03A9F4",description:"All frontend and backend developers",users:Ou(44),roles:[Pu("Editor")],managedBy:$a.FRONTEGG},{id:"id3",name:"Product",color:"#E1583E",description:"PMs and team leads",users:Ou(8),roles:[Pu("Viewer")],managedBy:$a.FRONTEGG},{id:"id4",name:"Management",color:"#9AE0FF",description:"Executives",users:Ou(5),roles:[Pu("Admin")],managedBy:$a.FRONTEGG},{id:"id5",name:"Sales",color:"#ED8E7C",users:Ou(21),description:"BDR, AE, and inside sales",roles:[Pu("Viewer")],managedBy:$a.FRONTEGG},{id:"id6",name:"Support",color:"#A79D7B",users:Ou(23),description:"Dev success and customer success",roles:[Pu("Admin")],managedBy:$a.FRONTEGG},{id:"id7",name:"Marketing",color:"#2CA744",users:Ou(10),description:"The marketing department",roles:[Pu("Viewer")],managedBy:$a.FRONTEGG},{id:"id8",name:"HR",color:"#EAE1C2",users:Ou(4),description:"Human resources",roles:[Pu("Viewer")],managedBy:$a.FRONTEGG},{id:"id9",name:"Finance",color:"#5587C0",users:Ou(3),roles:[Pu("Viewer")],managedBy:$a.FRONTEGG},{id:"id10",name:"Operations",color:"#B1CAE7",users:Ou(8),roles:[Pu("Editor")],managedBy:$a.FRONTEGG},{id:"id11",name:"Legal",color:"#2CA744",users:Ou(4),roles:[Pu("Viewer")],managedBy:$a.FRONTEGG}],_u={scoring:{score:79},recommendations:{items:[{code:Wa.FORCE_MFA,severity:Ka.WARNING,category:qa.MFA},{code:Wa.ENABLE_FORCE_RELOGIN,severity:Ka.WARNING,category:qa.SESSIONS}]}},Ru={insights:{items:[{category:qa.MFA,code:Ha.PARTIALLY_FORCED_MFA,metadata:{totalUsers:2,mfa:{enrolledUsersCount:1}}},{category:qa.SESSIONS,code:Ha.PARTIAL_SESSION_SETTINGS,metadata:{totalUsers:2,sessions:{idleTimeoutRecommendation:1800}}},{category:qa.PASSWORD,code:Ha.IMPROVE_PASSWORD_HISTORY_POLICY,metadata:{password:{userLockoutRecommendation:5,historyRecommendations:5}}},{category:qa.DOMAIN,code:Ha.NO_IP_RESTRICTIONS,metadata:{restrictions:{ipsCount:1,domainsCount:1}}}]}},Uu={users:bu,totalUsersItems:2,totalUsersPages:1,usersPageOffset:0},Cu={users:[bu[0]],totalUsersItems:1,totalUsersPages:1,usersPageOffset:0,queryParams:{_maxInactiveSeconds:7776e3}},Lu={users:[bu[1]],totalUsersItems:1,totalUsersPages:1,usersPageOffset:0};ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date;var Du,Nu=new Uint8Array(16);function Mu(){if(!Du&&!(Du="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Du(Nu)}const Fu=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var xu=[],$u=0;$u<256;++$u)xu.push(($u+256).toString(16).substr(1));const Gu=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(xu[t[e+0]]+xu[t[e+1]]+xu[t[e+2]]+xu[t[e+3]]+"-"+xu[t[e+4]]+xu[t[e+5]]+"-"+xu[t[e+6]]+xu[t[e+7]]+"-"+xu[t[e+8]]+xu[t[e+9]]+"-"+xu[t[e+10]]+xu[t[e+11]]+xu[t[e+12]]+xu[t[e+13]]+xu[t[e+14]]+xu[t[e+15]]).toLowerCase();if(!function(t){return"string"==typeof t&&Fu.test(t)}(a))throw TypeError("Stringified UUID is invalid");return a},ju=function(t,e,a){var n=(t=t||{}).random||(t.rng||Mu)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){a=a||0;for(var s=0;s<16;++s)e[a+s]=n[s];return e}return Gu(n)},Bu=["callback"],Vu=["callback"],Wu=["callback","profilePictureUrl"],Hu=["callback"],zu=["callback"],Ku=["callback"],qu=["callback"],Ju=["callback"],Yu=["callback"],Xu=["callback"],Qu=["callback"],Zu=["callback","samlVendor"],td=["callback"],ed=["callback"],ad=["callback","profileImage"],nd=["callback"],sd=["callback"],id=["callback"],od=["callback"],rd=["callback"],ld=["callback"],cd=["callback"],ud=["callback"],dd=["requestName"],gd=t=>"createdAt"!==t.id,pd={total:20,data:Array.from(Array(5).keys()).map((t=>v({ip:"198.143.51.1",user:"Demo User Name",email:"demo-user@frontegg.com"},(()=>{switch(Math.floor(6*Math.random())){case 0:return{action:"Updated profile",description:"User updated profile details",severity:"Info"};case 1:return{action:"User logged in",severity:"Info",description:"User logged in to the product"};case 2:return{action:"User failed to login",severity:"High",description:"User failed to login with password"};case 3:return{action:"Added user",severity:"Info",description:"Added user david+535@frontegg.com to tenant"};case 4:return{action:"Assigned roles",severity:"Info",description:"Assigned 0 roles for user"};case 5:return{action:"Removed user david+108@frontegg.com from account",severity:"Info",description:"Removed access from the account for user david+108@frontegg.com"}}})(),{json:{key1:"value1",key2:"value2",key3:"value3",key4:"value4"},tenantId:"my-tenant-id",vendorId:"my-vendor-id",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36",createdAt:`2022-04-07 10:${50-t}:40.201`})))},hd={properties:[{showInTable:!0,name:"createdAt",displayName:"Time",type:"Timestamp",sortable:!0,filterable:!0,showInMoreInfo:"Always",chosen:!1,selected:!1,isPredefined:!1},{showInTable:!0,name:"email",displayName:"User",type:"Email",filterable:!0,sortable:!0,isPredefined:!0,chosen:!1,selected:!1},{showInTable:!0,name:"action",displayName:"Action",type:"AlphaNumeric",sortable:!0,filterable:!0,showInMoreInfo:"Always",chosen:!1,selected:!1,isPredefined:!0},{showInTable:!0,name:"description",type:"AlphaNumeric",sortable:!1,filterable:!1,displayName:"Description",isPredefined:!0,chosen:!1,selected:!1},{showInTable:!0,name:"ip",displayName:"IP Address",type:"IpAddress",sortable:!0,filterable:!0,showInMoreInfo:"Always",chosen:!1,selected:!1,isPredefined:!0},{showInTable:!1,name:"severity",displayName:"Severity",type:"Severity",sortable:!0,filterable:!0,showInMoreInfo:"Always",chosen:!1,selected:!1,isPredefined:!0},{showInTable:!1,name:"userAgent",displayName:"User Agent",type:"AlphaNumeric",filterable:!0,sortable:!0,isPredefined:!0,chosen:!1,selected:!1},{showInTable:!1,name:"json",type:"Json",sortable:!0,filterable:!0,displayName:"Json Data",showInMoreInfo:"Always",isPredefined:!1}]},yd=(t,e,a)=>{const n=((t,e,a)=>{const n=Wc(t,e,a),s=Xc(n,["setAuditLogsState","resetAuditLogsState"]);return s.loadAuditLogs=async e=>{s.setAuditLogsState({loading:!e.silentLoading,error:null});const n=t.auditLogs.auditLogsState,{columns:i}=t.auditLogs.auditsMetadataState;try{var o,r,l,c,u;const t=null!=(o=e.pageSize)?o:n.pageSize,d=null!=(r=e.pageOffset)?r:n.pageOffset,g=null!=(l=e.filter)?l:n.filter,p=null!=(c=e.sort)?c:n.sort;s.setAuditLogsState({pageSize:t,pageOffset:d,filter:g,sort:p}),i||await a.loadAuditsMetadata();const{data:h,total:y}=((t,e)=>{const{data:a}=pd;let n=a.filter((t=>e=>t.filter(gd).every((t=>e[t.id].includes(t.value))))(t));if(e.length){const{id:t,desc:a=!1}=e[0];n=n.sort(((t,e)=>(a,n)=>a[t]>n[t]?e?-1:1:n[t]>a[t]?e?1:-1:0)(t,a))}return{data:n,total:n.length}})(g,p);s.setAuditLogsState({loading:!1,logs:null!=h?h:[],totalPages:+Math.ceil(y/t)}),null==e||null==(u=e.callback)||u.call(e,!0)}catch(t){var d;s.setAuditLogsState({loading:!1,error:Nn(t)}),null==e||null==(d=e.callback)||d.call(e,null,t)}},s})(t,e,a),s=((t,e)=>{const a=Kc(t,e),n=Xc(a,["setAuditsMetadataState","resetAuditsMetadataState"]);return n.loadAuditsMetadata=async()=>{n.setAuditsMetadataState({loading:!0,error:null});try{const{properties:t}=hd;n.setAuditsMetadataState({columns:t,loading:!1})}catch(t){n.setAuditsMetadataState({error:t,loading:!1})}},n})(t,e);return v({},n,s)},Sd={id:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",externalId:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",startDate:"2021-09-20T08:08:51.000Z",status:x.ACTIVE,externallyManaged:!1,cancellation:null,currentPeriodStart:"2021-09-20T08:08:51.000Z",currentPeriodEnd:"2021-10-20T08:08:51.000Z",plan:{slug:"test"}},vd=[{id:"prod_J60fUEvI7qV1eL",externalId:"prod_J60fUEvI7qV1eL",name:"Premium",description:"",price:{id:"price_1IToe8Ewsu4qiqnndAV76J69",externalId:"price_1IToe8Ewsu4qiqnndAV76J69",currency:"usd",amount:1e4},slug:"premium"},{id:"prod_J60duauCpXfcur",externalId:"prod_J60duauCpXfcur",name:"Free",description:"Totally free plan. Nothing to pay.",price:{id:"price_1ITocfEwsu4qiqnnnBHDx9fQ",externalId:"price_1ITocfEwsu4qiqnnnBHDx9fQ",currency:"usd",amount:0},slug:"free"}],fd=[{id:"in_1JbhYWEwsu4qiqnnrUh6hsHa",externalId:"in_1JbhYWEwsu4qiqnnrUh6hsHa",subscriptionId:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",paymentDate:"2021-09-20T08:08:51.000Z",totalAmount:1e4,currency:"usd",paid:!0,receiptNumber:""},{id:"in_1JbhYWEwsu4qiqnnrUh6hsHa",externalId:"in_1JbhYWEwsu4qiqnnrUh6hsHa",subscriptionId:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",paymentDate:"2021-08-20T08:08:51.000Z",totalAmount:1e4,currency:"usd",paid:!0,receiptNumber:""}],md=[{id:"id",externalId:"externalId",type:$.CARD,isDefault:!0,last4:"4242",expMonth:11,expYear:25,brand:"visa",billingDetails:{name:"Dummy",email:"dummy@email.com"}}],bd={allowPlanDowngrade:!0,allowPlanCancellation:!0},Ad=(t,e,a)=>{const n=((t,e)=>{const a=cc(t,e),n=Xc(a,["setPaymentConfigState","resetPaymentConfigState"]);return n.loadPaymentConfiguration=async()=>{n.setPaymentConfigState({loading:!0}),await En(500),n.setPaymentConfigState({loading:!1,fetching:!1,config:{paymentProvider:oc.STRIPE,apiKey:""}})},n})(t,e),[s,i]=((t,e,a)=>{const n=((t,e,a)=>{const n=hc(t,e,a),s=Xc(n,["setBillingInformationState","resetBillingInformationState"]);return s.loadBillingInformation=async()=>{var t,e;s.setBillingInformationState({loading:!0}),await En(500),s.setBillingInformationState({loading:!1,fetching:!1,summary:{subscriptionId:Sd.id,paymentMethodId:"mockPaymentMethodId",tenantConfigurationId:"mockTenantConfigurationId",providerType:j.Stripe,externallyManaged:!1,currentPlanId:vd[0].id,defaultPlanId:vd[0].id},plan:v({},vd[0],{price:null==(t=vd[0].price)?void 0:t.amount,currency:null==(e=vd[0].price)?void 0:e.currency,recurringInterval:"month"})})},s})(t,e,a),s=((t,e)=>{const a=bc(t,e),n=Xc(a,["setBillingPaymentMethodState","resetBillingPaymentMethodState"]);return n.loadPaymentMethod=async()=>{n.setBillingPaymentMethodState({loading:!0}),await En(500),n.setBillingPaymentMethodState({paymentMethod:md[0],loading:!1,fetching:!1})},n})(t,e),i=((t,e)=>{const a=vc(t,e),n=Xc(a,["setBillingInvoiceState","resetBillingInvoiceState"]);return n.loadBillingInvoices=async()=>{n.setBillingInvoiceState({loading:!0}),await En(500),n.setBillingInvoiceState({loading:!1,fetching:!1,invoices:fd.map((t=>v({},t,{selectedPlan:"Premium",paymentDate:new Date(Date.parse(t.paymentDate)),totalAmount:+((t.totalAmount||0)/100).toFixed(2)})))})},n.loadInvoices=n.loadBillingInvoices,n})(t,e),o=((t,e,a)=>{const n=Tc(t,e,a),s=Xc(n,["setBillingSubscriptionState","resetBillingSubscriptionState","setCancellationLoading","setCancellationError","setRenewalLoading","setRenewalError"]);return s.loadSubscription=async()=>{s.setBillingSubscriptionState({loading:!0}),await En(500),s.setBillingSubscriptionState({subscription:Sd,fetching:!1,loading:!1,error:null})},s})(t,e,a);return[v({},n,s,i,o),{information:n,invoices:i,paymentMethod:s,subscription:o}]})(t,e,a),o=((t,e)=>{const a=Pc(t,e),n=Xc(a,["setPlansState","resetPlansState"]);return n.loadPlans=async()=>{n.setPlansState({loading:!0}),await En(500),n.setPlansState({fetching:!1,loading:!1,plans:vd.map((t=>{var e,a;return v({},t,{price:(null==(e=t.price)?void 0:e.amount)||0,currency:(null==(a=t.price)?void 0:a.currency)||"usd",recurringInterval:"month"})}))})},n})(t,e),r=((t,e,a)=>{const n=Rc(t,e,a);return Xc(n,["setCheckoutState","resetCheckoutState","errorCheckout","resetCheckout"])})(t,e,a),l=((t,e)=>{const a=Lc(t,e);return Xc(a,[])})(t,e),c=((t,e)=>{const a=Mc(t,e),n=Xc(a,["setVendorPublicConfigState","resetVendorPublicConfigState","setVendorPublicConfigError","setVendorPublicConfigLoading"]);return n.loadVendorPublicConfiguration=async()=>{n.setVendorPublicConfigLoading(!0),await En(),n.setVendorPublicConfigState({fetching:!1,loading:!1,vendorPublicConfig:bd})},n})(t,e);return[v({},n,s,o,r,l,c),{config:n,billing:i,plans:o,checkout:r,stripe:l,vendorPublicConfig:c}]},wd=(t,e,a,n)=>{const{authActions:s,authStateActions:i}=((t,e,a,n)=>{const s=((t,e)=>{const a=Mn(t,e);return Xc(a,["setAcceptInvitationState","resetAcceptInvitationState"])})(t,e),i=((t,e,a)=>{const n=Gn(t,e,a),s=Xc(n,["setAccountSettingsState","resetAccountSettingsState"]);return s.saveAccountSettings=async e=>{var a;s.setAccountSettingsState({loading:!0}),await En();const n=t.auth.accountSettingsState,{address:i,timezone:o,dateFormat:r,timeFormat:l,currency:c,logo:u}=n,d=v({address:i,timezone:o,dateFormat:r,timeFormat:l,currency:c,logo:u},e);s.setAccountSettingsState(v({},d,{loading:!1})),null==(a=e.callback)||a.call(e,d)},s.loadAccountSettings=async t=>{s.setAccountSettingsState({loading:!(null!=t&&t.silentLoading),error:null}),await En(),s.setAccountSettingsState(v({address:"Tel-aviv",timezone:"Asia/Jerusalem",dateFormat:"DD/MM/YYYY",timeFormat:"HH:mm",currency:"USD",loading:!1},t))},s})(t,e,a),o=((t,e)=>{const a=Ls(t,e);return Xc(a,["setUnlockAccountState","resetUnlockAccountState"])})(t,e),r=((t,e,a)=>{const n=Rs(t,e,a);return Xc(n,["setActivateState","resetActivateState","setActivateStrategyState"])})(t,e,a),l=((t,e,a)=>{const n=Ho(t,e,a);return Xc(n,["setAllAccountsLoader","setAllAccountsError","setAllAccountsState","setSelectedAccountState","resetAllAccountsState","clearSelectedAccount"])})(t,e,a),c=zo(t),u=((t,e)=>{const a=Fs(t,e),n=Xc(a,["setApiTokensState","resetApiTokensState","setApiTokensLoader","setApiTokensError"]);return n.addTenantApiToken=async e=>{const{description:a,roleIds:s,callback:i}=e;n.setApiTokensLoader({key:Ms.ADD_API_TOKEN,value:!0});const{apiTokensDataTenant:o}=t.auth.apiTokensState,r=v({},Zc,{description:a,roleIds:s,clientId:`CLIENT_ID_${ju()}`});n.setApiTokensState({showAddTokenDialog:!1}),await En(200),n.setApiTokensState({apiTokensDataTenant:[...o,r],successDialog:{open:!0,secret:r.secret,clientId:r.clientId}}),await En(200),n.setApiTokensLoader({key:Ms.ADD_API_TOKEN,value:!1}),null==i||i(null)},n.deleteTenantApiToken=async t=>{n.setApiTokensLoader({key:Ms.DELETE_API_TOKEN,value:!0}),await En(200);const e=[Zc];n.setApiTokensState({apiTokensDataTenant:e.filter((e=>e.clientId!==t)),deleteTokenDialog:{open:!1,clientId:t}}),n.setApiTokensLoader({key:Ms.DELETE_API_TOKEN,value:!1})},n.loadApiTokens=async t=>{var e;null!=t&&t.silentLoading||n.setApiTokensLoader({key:Ms.LOAD_API_TOKENS,value:!0});const a=[Qc],s=[Zc];n.setApiTokensState({apiTokensDataUser:a,apiTokensDataTenant:s}),await En(200),n.setApiTokensLoader({key:Ms.LOAD_API_TOKENS,value:!1}),null==t||null==(e=t.callback)||e.call(t,!0)},n.loadUserApiTokens=async t=>{var e;null!=t&&t.silentLoading||n.setApiTokensLoader({key:Ms.LOAD_API_TOKENS,value:!0});const a=[Qc];n.setApiTokensState({apiTokensDataUser:a}),await En(200),n.setApiTokensLoader({key:Ms.LOAD_API_TOKENS,value:!1}),null==t||null==(e=t.callback)||e.call(t,!0)},n.loadTenantApiTokens=async t=>{var e;null!=t&&t.silentLoading||n.setApiTokensLoader({key:Ms.LOAD_API_TOKENS,value:!0});const a=[Zc];n.setApiTokensState({apiTokensDataTenant:a}),await En(200),n.setApiTokensLoader({key:Ms.LOAD_API_TOKENS,value:!1}),null==t||null==(e=t.callback)||e.call(t,!0)},n})(t,e),d=((t,e,a)=>{const n=js(t,e,a);return Xc(n,["setApplicationsState","resetApplicationsState"])})(t,e,a),g=((t,e,a)=>{const n=Hs(t,e,a),s=Xc(n,["setCustomLoginState","resetCustomLoginState"]);return s.loadTenantMetadata=async()=>{s.setCustomLoginState({loading:!0}),await En(),s.setCustomLoginState({loading:!1})},s.updateTenantMetadata=async t=>{const{callback:e}=t;s.setCustomLoginState({loading:!0,error:null}),await En(),s.setCustomLoginState({loading:!1,error:null}),null==e||e(!0)},s})(t,e,a),p=((t,e)=>{const a=Hl(t,e);return Xc(a,["setEntitlements","handleFetchedEntitlements"])})(t,e),h=((t,e)=>{const a=Ys(t,e),n=Xc(a,["setForgotPasswordState","resetForgotPasswordState"]);return n.loadPasswordConfig=async t=>{n.setForgotPasswordState({loading:!0});try{n.setForgotPasswordState({loading:!1,passwordConfig:{allowPassphrases:!0,maxLength:128,minLength:6,minPhraseLength:6,minOptionalTestsToPass:1}})}catch(t){n.setForgotPasswordState({loading:!1,error:Nn(t)})}},n})(t,e),y=(t=>{const e=ti(t),a=Xc(e,["setStep"]);return a.setStep(Xs.success),a})(t),S=((t,e)=>{const a=oi(t,e),n=Xc(a,["setGroupsState","resetUsersGroupsState","setUsersGroupsLoader","setUsersGroupsError"]);return n.loadGroups=async()=>{const t=ni.GET_GROUPS;n.setUsersGroupsLoader({key:t,value:!0});const e=ku;n.setGroupsState({groups:e}),n.setUsersGroupsLoader({key:t,value:!1})},n.createGroup=async e=>{var a;const s=ni.CREATE_GROUP,{groups:i}=t.auth.groupsState;n.setUsersGroupsLoader({key:s,value:!0}),await En(500),n.setGroupsState({groups:[v({},e,{id:`${e.name}ID`,managedBy:$a.FRONTEGG}),...null!=i?i:[]]}),null==e||null==(a=e.callback)||a.call(e,!0),n.setUsersGroupsLoader({key:s,value:!1})},n.updateGroup=async e=>{var a,s,i,o,r;const l=ni.UPDATE_GROUP,c=t.auth.groupsState;n.setUsersGroupsLoader({key:l,value:!0}),await En(500),n.setGroupsState({groups:null==c||null==(a=c.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},e,{id:e.groupId,name:null!=(a=null==e?void 0:e.name)?a:"",managedBy:$a.FRONTEGG}):t})),selectedGroup:v({},null==c?void 0:c.selectedGroup,{name:null!=(s=null==e?void 0:e.name)?s:"",color:null!=(i=null==e?void 0:e.color)?i:"",description:null!=(o=null==e?void 0:e.description)?o:""})}),null==e||null==(r=e.callback)||r.call(e,!0),n.setUsersGroupsLoader({key:l,value:!1})},n.deleteGroup=async e=>{var a,s;const i=ni.DELETE_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await En(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.filter((t=>t.id!==e.groupId))}),null==e||null==(s=e.callback)||s.call(e,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.addRolesToGroup=async e=>{var a,s;const i=ni.ADD_ROLES_TO_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await En(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},t,{roles:[...null!=(a=null==t?void 0:t.roles)?a:[],...e.roleIds.map((t=>({id:t,name:t})))]}):t}))}),null==e||null==(s=e.callback)||s.call(e,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.deleteRolesFromGroup=async e=>{var a,s;const i=ni.DELETE_ROLES_FROM_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await En(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},t,{roles:null==t||null==(a=t.roles)?void 0:a.filter((t=>!e.roleIds.includes(t.id)))}):t}))}),null==e||null==(s=e.callback)||s.call(e,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.addUsersToGroup=async e=>{var a,s;const i=ni.ADD_USERS_TO_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await En(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},t,{users:[...null!=(a=null==t?void 0:t.users)?a:[],...e.userIds.map((t=>({id:t,name:t})))]}):t}))}),null==e||null==(s=e.callback)||s.call(e,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.deleteUsersFromGroup=async e=>{var a,s;const i=ni.DELETE_USERS_FROM_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await En(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},t,{users:null==t||null==(a=t.users)?void 0:a.filter((t=>!e.userIds.includes(t.id)))}):t}))}),null==e||null==(s=e.callback)||s.call(e,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.getGroupConfiguration=async()=>{const e=ni.GET_GROUP_CONFIGURATION,{groupsConfiguration:a}=t.auth.groupsState;n.setUsersGroupsLoader({key:e,value:!0}),a&&n.setGroupsState({groupsConfiguration:v({},a)}),n.setUsersGroupsLoader({key:e,value:!1})},n.updateGroupConfiguration=async e=>{const a=ni.UPDATE_GROUP_CONFIGURATION,{groupsConfiguration:s}=t.auth.groupsState;n.setUsersGroupsLoader({key:a,value:!0}),s&&n.setGroupsState({groupsConfiguration:v({},s,e)}),n.setUsersGroupsLoader({key:a,value:!1})},n})(t,e),m=ci(t),b=((t,e,a)=>{const n=hi(t,e,a);return Xc(n,["setImpersonateState","resetImpersonateState"])})(t,e,a),A=((t,e,a)=>{const n=a,s=wo(t,e,n),i=Xc(s,["setLoginState","resetLoginState","afterAuthNavigation"]);return i.requestAuthorize=async t=>{t&&n.setAuthState({isLoading:!0});const e=au;await n.loadTenants(),n.setAuthState({user:e,isAuthenticated:!0,isLoading:!1})},i.getUserIP=async t=>{const{callback:e}=t;try{const{ip:t}=Iu[0];await n.setAuthState({userIpData:{ip:t},userIp:t}),null==e||e(!0,t)}catch(t){null==e||e(!1,t)}},i})(t,e,a),w=((t,e,a)=>{const n=a,s=Lo(t,e,n),i=Xc(s,["setMfaState","resetMfaState"]);return i.enrollMfa=async()=>{i.setMfaState({saving:!0}),i.setMfaState({saving:!1,error:void 0,qrCode:"test"})},i.verifyMfa=async e=>{const{callback:a}=e,{mfaDevices:s={webauthn:[],phones:[],authenticators:[],emails:[]}}=(f(e,Bu),t.auth.mfaState);i.setMfaState({saving:!0}),await En();const o={token:"token",recoveryCode:"recoveryCode"},r={step:Yn.recoveryCode,loading:!1,error:void 0,saving:!1,mfaDevices:v({},s,{authenticators:[{id:"authenticator-id"}]})};null!=o&&o.recoveryCode&&(r.recoveryCode=o.recoveryCode),i.setMfaState(r),n.setUser(v({},au,{mfaEnrolled:!0})),null==a||a(r.recoveryCode)},i.disableMfa=async e=>{var a;const{mfaDevices:s={webauthn:[],phones:[],authenticators:[],emails:[]}}=t.auth.mfaState;i.setMfaState({saving:!0}),await En(),i.setMfaState({saving:!1,error:void 0,mfaDevices:v({},s,{authenticators:[]})}),n.setUser(v({},au)),null==(a=e.callback)||a.call(e,!0)},i.verifyMfaAfterForce=async t=>{const{callback:e}=t,a=f(t,Vu);i.setMfaState({loading:!0}),await En();const s=v({},a,{recoveryCode:"recoveryCode"}),o={step:Yn.recoveryCode,loading:!1,error:void 0,saving:!1};null!=s&&s.recoveryCode&&(o.recoveryCode=s.recoveryCode),i.setMfaState(o),await En(),n.setUser(v({},au,{mfaEnrolled:!0})),null==e||e(o.recoveryCode)},i.preDisableMfaSms=async t=>{i.setMfaState({saving:!0});try{var e;i.setMfaState({saving:!1,error:void 0,otcToken:"otc-token",phoneNumber:"+972504589346"}),null==(e=t.callback)||e.call(t,!0)}catch(e){var a;i.setMfaState({saving:!1,error:Nn(e)}),null==(a=t.callback)||a.call(t,!1,e)}},i.disableMfaSms=async e=>{var a;const{mfaDevices:s={webauthn:[],phones:[],authenticators:[],emails:[]}}=t.auth.mfaState;i.setMfaState({saving:!0}),await En(),i.setMfaState({loading:!1,error:void 0,mfaDevices:v({},s,{phones:[]})}),n.setUser(v({},au)),null==(a=e.callback)||a.call(e,!0)},i.preEnrollMfaSms=async t=>{var e;i.setMfaState({saving:!0}),await En(),i.setMfaState({saving:!1,error:void 0,otcToken:"otc-token",phoneNumber:"+972504589346"}),null==(e=t.callback)||e.call(t,!0)},i.enrollMfaSms=async e=>{const{callback:a}=e,{mfaDevices:s={webauthn:[],phones:[],authenticators:[],emails:[]}}=t.auth.mfaState;i.setMfaState({saving:!0}),await En();const o={token:"token",recoveryCode:"recoveryCode"},r={step:Yn.recoveryCode,loading:!1,error:void 0,saving:!1,mfaDevices:v({},s,{phones:[{id:"phone-id",phoneNumber:"+972504589346"}]})};null!=o&&o.recoveryCode&&(r.recoveryCode=o.recoveryCode),i.setMfaState(r),n.setUser(v({},au,{mfaEnrolled:!0})),null==a||a(r.recoveryCode)},i})(t,e,a),T=((t,e,a)=>{const n=Jo(t,e,a);return Xc(n,["setPasskeysState","resetPasskeysState"])})(t,e,a),E=((t,e,a)=>{const n=Zo(t,e,a),s=Xc(n,["setProfileState","resetProfileState"]);return s.loadProfile=async()=>{s.setProfileState({loading:!0}),await En(),a.setUser(v({},au,eu)),s.setProfileState({loading:!1,profile:eu})},s.saveProfile=async t=>{const{callback:e,profilePictureUrl:n}=t,i=f(t,Wu);s.setProfileState({saving:!0,error:null});const o=nu;let r=o.profile.profilePictureUrl;n!==o.profile.profilePictureUrl&&n&&(n||"").match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/)&&(r=n);const l=v({},o.profile,i,{profilePictureUrl:r}),c=au;await En(),a.setUser(v({},c,l)),s.setProfileState({loading:!1,error:null,saving:!1,profile:l}),null==e||e(l)},s.changePassword=async t=>{var e;s.setProfileState({loading:!0}),await En(),s.setProfileState({loading:!1,error:void 0}),null==(e=t.callback)||e.call(t,!0)},s})(t,e,a),I=((t,e)=>{const a=sr(t,e);return Xc(a,["setProvisioningState","resetProvisioningState"])})(t,e),O=((t,e,a)=>{const n=dr(t,e,a);return Xc(n,["setResetPhoneNumberState","resetResetPhoneNumberState"])})(t,e,a),P=((t,e,a)=>{const n=kr(t,e,a),s=Xc(n,["setRestrictionsState","setIpRestrictionsState","setEmailDomainRestrictionsState"]);return s.loadIpRestrictions=async()=>{s.setIpRestrictionsState({loading:!0,error:null}),s.setIpRestrictionsState({data:{restrictions:Iu.filter((t=>t.strategy===Eu.strategy)),config:Eu},totalPages:1,pagination:{_filter:zt.ALLOW,_limit:50,_offset:0},loading:!1})},s.loadEmailDomainRestrictions=async()=>{s.setEmailDomainRestrictionsState({loading:!0,error:null}),s.setEmailDomainRestrictionsState({loading:!1,data:{restrictions:[{domain:"mock.com",id:"1",type:zt.ALLOW}],config:{active:!0,listType:zt.ALLOW,blockPublicDomains:!1}}})},s.saveIpRestriction=async e=>{var a,n,i;const{callback:o}=e,r=f(e,Hu);s.setIpRestrictionsState({saving:!0,error:null});const l=t.auth.restrictionsState.ipRestrictions,c=l.data.restrictions.filter((t=>t.ip!==r.ip));s.setIpRestrictionsState({data:{config:null!=(a=null==(n=l.data)?void 0:n.config)?a:{isActive:!1,strategy:zt.ALLOW},restrictions:[...c,v({},r,{createdAt:new Date,updatedAt:new Date,id:ju(),isActive:null==(i=r.isActive)||i,strategy:l.data.config.strategy})]},totalPages:1,pagination:{_filter:zt.ALLOW,_limit:50,_offset:0},saving:!1}),null==o||o(!0)},s.saveIpRestrictionsConfig=async e=>{var a,n,i;const{callback:o}=e,r=f(e,zu),l=t.auth.restrictionsState.ipRestrictions;s.setIpRestrictionsState({saving:!0,error:null}),s.setIpRestrictionsState({data:{config:v({},null==(a=l.data)?void 0:a.config,r),restrictions:null!=(n=null==(i=l.data)?void 0:i.restrictions)?n:[]},pagination:{_filter:zt.ALLOW,_limit:50,_offset:0},totalPages:1,saving:!1}),s.setIpRestrictionsState({saving:!1,error:null}),null==o||o(!0)},s.deleteIpRestriction=async e=>{var a;const{callback:n,id:i}=e;s.setIpRestrictionsState({saving:!0,error:null});const o=t.auth.restrictionsState.ipRestrictions;s.setIpRestrictionsState({data:{config:(null==(a=o.data)?void 0:a.config)||{isActive:!1,strategy:zt.ALLOW},restrictions:o.data.restrictions.filter((t=>t.id!==i))},pagination:{_filter:zt.ALLOW,_limit:50,_offset:0},totalPages:1,saving:!1,error:null}),null==n||n(!0)},s.checkIfUserIpValid=async()=>{s.setIpRestrictionsState({loading:!0,error:null});try{const e=t.auth.restrictionsState.ipRestrictions,a=Iu[0].ip,n=!!e.data.restrictions.find((t=>t.isActive&&t.ip===a));s.setIpRestrictionsState({userIpValid:n,loading:!1})}catch(t){s.setIpRestrictionsState({error:Nn(t),loading:!1})}},s.saveEmailDomainRestriction=async e=>{var a,n;const{callback:i}=e,o=f(e,Ku),r=t.auth.restrictionsState.emailDomainRestrictions;s.setEmailDomainRestrictionsState({saving:!0,error:null}),await En(),null==i||i(!0),s.setEmailDomainRestrictionsState({data:{config:(null==(a=r.data)?void 0:a.config)||{active:!1,blockPublicDomains:!1,listType:o.type},restrictions:[...(null==(n=r.data)?void 0:n.restrictions)||[],v({},o,{id:Date.now().toString()})]},saving:!1})},s.saveEmailDomainRestrictionsConfig=async e=>{var a;const{callback:n}=e,i=f(e,qu),o=t.auth.restrictionsState.emailDomainRestrictions;s.setEmailDomainRestrictionsState({saving:!0,error:null}),await En(),null==n||n(!0),s.setEmailDomainRestrictionsState({data:{config:{active:i.active,blockPublicDomains:i.blockPublicDomains||!1,listType:i.type||zt.ALLOW},restrictions:[...(null==(a=o.data)?void 0:a.restrictions)||[]]},saving:!1})},s.deleteEmailDomainRestriction=async e=>{var a,n;const{id:i}=e,o=t.auth.restrictionsState.emailDomainRestrictions;s.setEmailDomainRestrictionsState({saving:!0,error:null}),await En(),s.setEmailDomainRestrictionsState({data:{config:(null==(a=o.data)?void 0:a.config)||{active:!1,blockPublicDomains:!1,listType:zt.ALLOW},restrictions:((null==(n=o.data)?void 0:n.restrictions)||[]).filter((t=>t.id===i))},saving:!1})},s})(t,e,a),k=((t,e)=>{const a=Ar(t,e),n=Xc(a,["setRolesState","setRolesStateError","setRolesStateLoader","resetRolesState"]);return n.loadRolesAndPermissions=async t=>{var e;const a=hr.LOAD_ROLES;n.setRolesStateLoader({key:a,value:!(null!=(e=null==t?void 0:t.silentLoading)&&e)});try{n.setRolesState({roles:tu})}catch(t){n.setRolesStateError({key:a,value:Nn(t)})}finally{n.setRolesStateLoader({key:a,value:!1})}},n})(t,e),_=((t,e,a)=>{const n=Lr(t,e,a),s=Xc(n,["setSecurityCenterState","setSecurityCenterStateError","setSecurityCenterStateLoader","resetSecurityCenterState"]);return s.loadRecommendations=async()=>{const t=Ur.RECOMMENDATIONS;s.setSecurityCenterStateLoader({key:t,value:!0}),await En(),s.setSecurityCenterState({recommendations:_u.recommendations.items,score:_u.scoring.score}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadInsights=async()=>{const t=Ur.INSIGHTS;s.setSecurityCenterStateLoader({key:t,value:!0}),await En(),s.setSecurityCenterState({insights:Ru.insights.items}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadBreachedPasswordUsers=async()=>{const t=Ur.BREACHED_PASSWORD_USERS_TABLE;s.setSecurityCenterStateLoader({key:t,value:!0}),await En(),s.setSecurityCenterState({breachedPasswordUsersTable:Uu}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadUnenrolledMfaUsers=async()=>{const t=Ur.UNENROLLED_MFA_USERS_TABLE;s.setSecurityCenterStateLoader({key:t,value:!0}),await En(),s.setSecurityCenterState({unenrolledMfaUsersTable:Lu}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadInactiveUsers=async()=>{const t=Ur.INACTIVE_USERS_TABLE;s.setSecurityCenterStateLoader({key:t,value:!0}),await En(),s.setSecurityCenterState({inactiveUsersTable:Cu}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.sendResetBreachedPasswordEmail=async t=>{const{callback:e}=t,a=Ur.SEND_BREACHED_PASSWORD_EMAIL;s.setSecurityCenterStateLoader({key:a,value:!0}),await En(),null==e||e(!0),s.setSecurityCenterStateLoader({key:a,value:!1})},s})(t,e,a),R=((t,e,a)=>{const n=jr(t,e,a),s=Xc(n,["setSecurityPolicyState","setSecurityPolicyGlobalState","setSecurityPolicyPublicState","setSecurityPolicyMfaState","setSecurityPolicyVendorMfaState","setSecurityPolicyLockoutState","setSecurityPolicyVendorLockoutState","setSecurityPolicyCaptchaState","setSecurityPolicyPasswordHistoryState","setSecurityPolicyVendorPasswordHistoryState","resetSecurityPolicyState","setSecurityPolicyPasswordState","setSecurityPolicyAuthStrategyPublicState"]);return s.loadSecurityPolicy=async()=>{s.setSecurityPolicyGlobalState({loading:!0,error:null}),await Promise.all([s.loadSecurityPolicyMfa(),s.loadSecurityPolicyVendorMfa(),s.loadSecurityPolicyLockout(),s.loadSecurityPolicyVendorLockout(),s.loadSecurityPolicyPasswordHistory(),s.loadSecurityPolicyVendorPasswordHistory(),s.loadSecurityPolicyCaptcha()]),await En(),s.setSecurityPolicyGlobalState({policy:su,loading:!1})},s.loadPublicSecurityPolicy=async()=>{s.setSecurityPolicyPublicState({loading:!0,error:null});try{s.setSecurityPolicyPublicState({policy:iu,loading:!1})}catch(t){s.setSecurityPolicyPublicState({error:Nn(t),loading:!1})}},s.saveSecurityPolicyMfa=async t=>{var e;const{callback:a}=t,n=f(t,Ju);s.setSecurityPolicyMfaState({saving:!0,error:null});const i=v({},ru,{id:null!=(e=n.id)?e:ru.id,enforceMFAType:n.enforceMFAType});await En(),s.setSecurityPolicyMfaState({policy:i,saving:!1}),null==a||a(i)},s.loadSecurityPolicyMfa=async()=>{s.setSecurityPolicyMfaState({loading:!0,error:null}),await En(),s.setSecurityPolicyMfaState({policy:ou,loading:!1})},s.loadSecurityPolicyVendorMfa=async()=>{s.setSecurityPolicyVendorMfaState({loading:!0,error:null}),await En(),s.setSecurityPolicyVendorMfaState({policy:ou,loading:!1})},s.saveSecurityPolicyLockout=async t=>{const{callback:e}=t,a=f(t,Yu);s.setSecurityPolicyLockoutState({saving:!0,error:null}),await En();const n=v({},ru,a,{id:a.id?a.id:ru.id});null==e||e(n),s.setSecurityPolicyLockoutState({policy:n,saving:!1})},s.loadSecurityPolicyLockout=async()=>{s.setSecurityPolicyLockoutState({loading:!0,error:null}),await En(),s.setSecurityPolicyLockoutState({policy:ru,loading:!1})},s.loadSecurityPolicyVendorLockout=async()=>{s.setSecurityPolicyVendorLockoutState({loading:!0,error:null}),await En(),s.setSecurityPolicyVendorLockoutState({policy:ru,loading:!1})},s.loadSecurityPolicyCaptcha=async()=>{s.setSecurityPolicyLockoutState({loading:!0,error:null}),await En(),s.setSecurityPolicyLockoutState({policy:ru,loading:!1})},s.saveSecurityPolicyPasswordHistory=async t=>{const{callback:e}=t,a=f(t,Xu);s.setSecurityPolicyPasswordHistoryState({saving:!0,error:null}),await En();const n=v({},lu,a,{id:a.id?a.id:lu.id});null==e||e(n),s.setSecurityPolicyPasswordHistoryState({policy:n,saving:!1})},s.loadSecurityPolicyPasswordHistory=async()=>{s.setSecurityPolicyPasswordHistoryState({loading:!0,error:null}),await En(),s.setSecurityPolicyPasswordHistoryState({policy:lu,loading:!1})},s.loadSecurityPolicyVendorPasswordHistory=async()=>{s.setSecurityPolicyVendorPasswordHistoryState({loading:!0,error:null}),await En(),s.setSecurityPolicyVendorPasswordHistoryState({policy:lu,loading:!1})},s})(t,e,a),U=((t,e)=>{const a=qr(t,e),n=Xc(a,["setSessionsState","resetSessionsState"]);return n.loadUserSessions=async()=>{n.setSessionsState({loading:!0,error:null}),n.setSessionsState({sessions:Tu,loading:!1})},n.deleteUserSession=async e=>{const{id:a}=e;n.setSessionsState({loading:!0,error:null});const s=t.auth.sessionsState.sessions.filter((t=>t.id!==a));n.setSessionsState({sessions:s,loading:!1})},n.deleteAllUserSessions=async()=>{n.setSessionsState({loading:!0,error:null});const t=Tu.filter((t=>t.current));n.setSessionsState({sessions:t,loading:!1})},n})(t,e),C=((t,e,a)=>{const n=Hr(t,e,a),s=Xc(n,["setSessionsPolicyState","resetSessionsPolicyState"]);return s.loadSessionsPolicy=async()=>{s.setSessionsPolicyState({loading:!0,error:null});const e=t.auth.sessionsPolicyState;s.setSessionsPolicyState(v({},e,{loading:!1}))},s.createOrUpdateSessionsPolicy=async t=>{const{callback:e}=t,a=f(t,Qu);s.setSessionsPolicyState({loading:!0,error:null}),null==e||e(!0),s.setSessionsPolicyState({configurations:a,loading:!1})},s})(t,e,a),L=((t,e,a)=>{const n=tl(t,e,a);return Xc(n,["setSignUpState","resetSignUpState","resetSignUpStateSoft"])})(t,e,a),D=((t,e)=>{const a=cl(t,e);return Xc(a,["setSmsState","resetSmsState"])})(t,e),N=((t,e,a)=>{const n=hl(t,e,a);return Xc(n,["setSocialLoginsState","resetSocialLoginsState","setSocialLoginError"])})(t,e,a),M=((t,e,a)=>{const n=wl(t,e,a),s=Xc(n,["setSSOState","resetSSOState"]);return s.loadSSOConfigurations=async()=>{s.setSSOState({loading:!0}),await En(),s.setSSOState({samlConfiguration:cu,loading:!1,firstLoad:!1})},s.saveSSOConfigurations=async t=>{var e,a;const{callback:n,samlVendor:i}=t,o=f(t,Zu),r=gu.samlConfiguration,l=v({},r,o);let c="saving";if((null==l?void 0:l.enabled)!==r.enabled&&(c="loading"),null==l||!l.domain)return void s.setSSOState({samlConfiguration:v({},r,l)});s.setSSOState({error:void 0,[c]:!0}),await En(),l.acsUrl=null==uu||null==(e=uu.configuration)?void 0:e.acsUrl,l.spEntityId=null==uu||null==(a=uu.configuration)?void 0:a.spEntityId;const u=_n(l,["validated","generatedVerification","createdAt","updatedAt"]);(null==r?void 0:r.domain)!==(null==u?void 0:u.domain)&&(u.ssoEndpoint="",u.publicCertificate="",u.signRequest=!1),u.type=null==i?void 0:i.toLowerCase(),await En(),s.setSSOState({samlConfiguration:u,error:void 0,[c]:!1}),null==n||n(!0)},s.saveSSOConfigurationsFile=async e=>{const a="saving";s.setSSOState({error:void 0,[a]:!0});const n=v({},t.auth.ssoState.samlConfiguration,{enabled:!0},e[0]);s.setSSOState({samlConfiguration:n,error:void 0,[a]:!1})},s.validateSSODomain=async t=>{const{callback:e}=null!=t?t:{},a=gu.samlConfiguration;s.setSSOState({error:void 0,saving:!0}),await En(),s.setSSOState({samlConfiguration:v({},a,{validated:!0}),error:void 0,saving:!1}),null==e||e(!0)},s.loadSSOAuthorizationRoles=async()=>{await En(),s.setSSOState({authorizationRoles:["1","2","3"],error:void 0})},s.updateSSOAuthorizationRoles=async t=>{const{callback:e,authorizationRoles:a}=t;s.setSSOState({error:void 0,saving:!0}),await En(),s.setSSOState({authorizationRoles:a,error:void 0,saving:!1}),null==e||e(!0)},s})(t,e,a),F=((t,e,a)=>{const n=Il(t,e,a);return Xc(n,["setStepUpState","resetStepUpState"])})(t,e,a),x=((t,e,a)=>{const n=jl(t,e,a),s=Xc(n,["setTeamState","resetTeamState","setTeamLoader","setTeamError","openAddUserDialog","closeAddUserDialog","openDeleteUserDialog","closeDeleteUserDialog"]);return s.loadUsersV2=async e=>{var a,n,i,o;const{silentLoading:r,callback:l}=e,c=t.auth.teamState,u=null!=(a=e.pageSize)?a:c.pageSize,d=null!=(n=e.pageOffset)?n:c.pageOffset,g=null!=(i=e.filter)?i:c.filterV2,p=null!=(o=e.sort)?o:c.sortV2;s.setTeamLoader({key:ws.USERS,value:!r}),s.setTeamState({pageSize:u,pageOffset:d,filterV2:g,sortV2:p}),await En(),s.setTeamState({users:mu,totalPages:2,totalItems:10,roles:du,permissions:pu}),s.setTeamLoader({key:ws.USERS,value:!1}),null==l||l(mu)},s.loadAllSubTenantsUsers=async e=>{var a,n,i,o,r;const{silentLoading:l,callback:c}=e,u=t.auth.teamState,d=null!=(a=e._limit)?a:u.allUsersQueryParams._limit,g=null!=(n=e._offset)?n:u.allUsersQueryParams._offset,p=null!=(i=e._filter)?i:u.allUsersQueryParams._filter,h=null!=(o=e._sortBy)?o:u.allUsersQueryParams._sortBy,y=null!=(r=e._order)?r:u.allUsersQueryParams._order;s.setTeamLoader({key:ws.USERS,value:!l}),s.setTeamState({allUsersQueryParams:{_limit:d,_offset:g,_filter:p,_sortBy:h,_order:y}}),await En(),s.setTeamState({allUsers:Au,totalPages:2,totalItems:10,roles:du,permissions:pu}),s.setTeamLoader({key:ws.USERS,value:!1}),null==c||c(Au)},s.loadRoles=async t=>{var e;s.setTeamLoader({key:ws.ROLES_AND_PERMISSIONS,value:!0}),await En(),s.setTeamState({roles:du,permissions:pu}),s.setTeamLoader({key:ws.ROLES_AND_PERMISSIONS,value:!0}),null==t||null==(e=t.callback)||e.call(t,{roles:du,permissions:pu})},s.addUser=async e=>{const{callback:a}=e,n=f(e,td),i=t.auth.teamState;s.setTeamState({addUserDialogState:v({},i.addUserDialogState,{loading:!0})}),await En();const o=new Date,r=v({},Su,{groups:[]},n,{id:`${ju()}`,temporaryExpirationDate:n.expirationInSeconds?new Date(o.setSeconds(o.getSeconds()+n.expirationInSeconds)):void 0});null==a||a(r),s.setTeamState({users:[r,...i.users],addUserDialogState:{open:!1,loading:!1}})},s.addUserToSubTenants=async e=>{const{callback:a}=e,n=f(e,ed),i=t.auth.teamState;s.setTeamState({addUserDialogState:v({},i.addUserDialogState,{loading:!0})}),await En();const o=v({},Su,n,{id:`${ju()}`});s.setTeamState({users:[o,...i.users],addUserDialogState:{open:!1,loading:!1}}),null==a||a(null)},s.updateUser=async e=>{var a;const{callback:n}=e,i=f(e,ad),{id:o}=i,r=t.auth.teamState,l=r.users.find((t=>t.id===i.id));s.setTeamLoader({key:ws.UPDATE_USER,value:o||""}),s.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!0})}),s.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!0}),users:r.users.map((t=>t.id===i.id?v({},t,i):t))}),l.roleIds.length>0&&0===(null==(a=i.roleIds)?void 0:a.length)&&(i.roleIds=[""]),await En();const c=v({},l,i);null==n||n(c),s.setTeamState({users:r.users.map((t=>t.id===c.id?v({},t,c,{createdAt:t.createdAt,customData:t.customData,lastLogin:t.lastLogin}):t))}),s.setTeamLoader({key:ws.UPDATE_USER,value:!1})},s.deleteUser=async e=>{const{callback:a}=e,n=f(e,nd),i=t.auth.teamState;s.setTeamState({deleteUserDialogState:v({},i.deleteUserDialogState,{loading:!0})}),await En(),null==a||a(!0),s.setTeamState({users:i.users.filter((t=>t.id!==n.userId)),deleteUserDialogState:{open:!1,loading:!1}})},s.updateUserExpirationTime=async e=>{const{callback:a}=e,n=f(e,sd),i=t.auth.teamState;s.setTeamLoader({key:ws.UPDATE_USER_EXPIRATION_TIME,value:!0});const o=new Date;s.setTeamState({users:i.users.map((t=>t.id===n.userId?v({},t,{temporaryExpirationDate:n.expirationInSeconds?new Date(o.setSeconds(o.getSeconds()+n.expirationInSeconds)):void 0}):t))}),await En(),null==a||a(!0),s.setTeamLoader({key:ws.UPDATE_USER_EXPIRATION_TIME,value:!1})},s.setUserAsPermanent=async e=>{const{callback:a}=e,n=f(e,id),i=t.auth.teamState;s.setTeamLoader({key:ws.UPDATE_USER_EXPIRATION_TIME,value:!0}),s.setTeamState({users:i.users.map((t=>t.id===n.userId?v({},t,{temporaryExpirationDate:void 0}):t))}),await En(),null==a||a(!0),s.setTeamLoader({key:ws.UPDATE_USER_EXPIRATION_TIME,value:!1})},s.deleteUserFromSubTenants=async e=>{const{callback:a}=e,n=f(e,od),i=t.auth.teamState;s.setTeamState({deleteUserDialogState:v({},i.deleteUserDialogState,{loading:!0})}),await En(),null==a||a(!0),s.setTeamState({allUsers:i.allUsers.filter((t=>t.id!==n.userId)),deleteUserDialogState:{open:!1,loading:!1}})},s.resendActivationLink=async t=>{const{callback:e}=t,a=f(t,rd);s.setTeamLoader({key:ws.RESEND_ACTIVATE_LINK,value:a.userId}),await En(),null==e||e(!0),s.setTeamLoader({key:ws.RESEND_ACTIVATE_LINK,value:!1})},s.resendInvitationLink=async t=>{const{callback:e}=t,a=f(t,ld);s.setTeamLoader({key:ws.RESEND_INVITATION_LINK,value:a.email}),await En(),null==e||e(!0),s.setTeamLoader({key:ws.RESEND_INVITATION_LINK,value:!1})},s.resendInvitationEmail=async t=>{const{callback:e}=t,a=f(t,cd);s.setTeamLoader({key:ws.RESEND_INVITATION_LINK,value:a.email}),await En(),null==e||e(!0),s.setTeamLoader({key:ws.RESEND_INVITATION_LINK,value:!1})},s.resendInvitationLinkToAllSubTenants=async t=>{const{callback:e}=t,a=f(t,ud);s.setTeamLoader({key:ws.RESEND_INVITATION_LINK,value:a.email}),await En(),null==e||e(!0),s.setTeamLoader({key:ws.RESEND_INVITATION_LINK,value:!1})},s})(t,e,a),$=((t,e,a)=>{const n=Wl(t,e,a),s=Xc(n,["setTenantsState","resetTenantsState"]);return s.loadTenants=async()=>{s.setTenantsState({loading:!0}),s.setTenantsState({tenants:wu,activeTenant:wu[0],loading:!1})},s})(t,e,a),G={acceptInvitationActions:s,accountSettingsActions:i,unlockAccountActions:o,activateAccountActions:r,allAccountsActions:l,allAccountsDialogActions:c,apiTokensActions:u,applicationsActions:d,customLoginActions:g,entitlementsActions:p,forgotPasswordActions:h,passwordRotationActions:y,groupsActions:S,groupsDialogsActions:m,impersonateActions:b,loginActions:A,mfaActions:w,passkeysActions:T,profileActions:E,provisioningActions:I,resetPhoneNumberActions:O,restrictionsActions:P,rolesActions:k,securityCenterActions:_,securityPolicyActions:R,sessionsActions:U,sessionsPolicyActions:C,signUpActions:L,smsActions:D,socialLoginActions:N,ssoActions:M,stepUpActions:F,teamActions:x,tenantsActions:$},j=e=>{Object.keys(e).forEach((a=>{const n=a;Rn(t.auth[n])?Object.assign(t.auth[n],e[n]):t.auth[n]=e[n]}))};return{authActions:v({setState:j,setAuthState:j,setErrorByRequestName:e=>{let{requestName:a}=e,n=f(e,dd);t.auth.errorByRequest=v({},t.auth.errorByRequest,{[a]:v({},n,{isError:!0})})},resetAuthState:()=>{Cn(t,["auth"],n)},setUser:t=>{j({user:t})}},s,i,r,o,l,c,u,d,g,p,h,y,S,m,b,A,w,T,E,I,O,P,k,_,R,U,C,L,D,N,M,F,x,$),authStateActions:G}})(t,e,a,n),o=((t,e,a)=>{const n=ac(t,e,a);return Xc(n,["setConnectivityState","resetConnectivityState","initData","resetConnectivityState","cleanWebhookTestData","cleanWebhookLogsData","cleanWebhookTestMessage","cleanError","cleanSlackData"])})(t,e,a),[r,l]=Ad(t,e,a),c=((t,e,a)=>{const n=jc(t,e,a),s=Xc(n,["setVendorState","resetVendorState"]);return s.loadVendorPublicInfo=async()=>{try{s.setVendorState({whiteLabelMode:!1}),await En()}catch(t){console.error("failed to getVendorPublicInfo - ",t)}},s.loadVendorPublicConfiguration=s.loadVendorPublicInfo,s})(t,e,a);return{authActions:s,authStateActions:i,connectivityActions:o,subscriptionsActions:r,subscriptionsStateActions:l,vendorActions:c,auditsActions:yd(t,e,a)}},Td=(t,e,a=!1,n,s,i=!1,o="path")=>Ed({name:t.appName,context:t.context,storeHolder:e,previewMode:a,builderMode:i,urlStrategy:o,initialState:{root:v({},t),auth:v({},null==s?void 0:s.auth,n),connectivity:v({},null==s?void 0:s.connectivity),subscriptions:v({},null==s?void 0:s.subscriptions),vendor:v({},null==s?void 0:s.vendor),auditLogs:v({},null==s?void 0:s.auditLogs),audits:v({},null==s?void 0:s.audits)}}),Ed=t=>{var e,a,n,s,i,o,r;const{storeHolder:l}=t;let c=l;if("undefined"==typeof window&&null==l)throw Error("createFronteggStore(initState, storeHolder) failed, storeHolder must not be null in Server-Side rendering");if(c||(c=window),c.store)return c.store;const u=t.name||"default",{context:d,previewMode:g=!1,builderMode:p=!1,urlStrategy:h="path"}=t,y=U.for(u);g||p||y.setContext(d),void 0===d.requestCredentials&&(d.requestCredentials="include");const S=ql(null==(e=t.initialState)?void 0:e.auth),m=Xl(null==(a=t.initialState)?void 0:a.connectivity),b=Fc(null==(n=t.initialState)?void 0:n.subscriptions),A=Gc(null==(s=t.initialState)?void 0:s.vendor),w=qc(null==(i=t.initialState)?void 0:i.auditLogs),T=(E=null==(o=t.initialState)?void 0:o.audits,en(Yc,E));var E;const I=null==(r=t.initialState)?void 0:r.auth;I&&Object.keys(I).forEach((t=>{cn()(S,t,I[t],{merge:!0})}));const O=JSON.parse(JSON.stringify(S)),C=en({root:{appName:u,context:d,urlStrategy:h,previewMode:g},auth:S,connectivity:m,subscriptions:b,vendor:A,auditLogs:w,audits:T});"undefined"!=typeof window&&window.localStorage&&"true"===window.localStorage.DEBUG_FRONTEGG_STORE&&function(t,e){"string"==typeof e&&(e={name:e});const a=e||{},{enabled:n,name:s=""}=a,i=f(a,_);let o;try{o=n&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!o)return;let r=!1;const l=o.connect(v({name:s},i));P(t,(e=>{const a=e.filter((([t,e])=>e[0]!==R)).map((([t,e])=>`${t}:${e.map(String).join(".")}`)).join(", ");if(a)if(r)r=!1;else{const e=Object.assign({},k(t));delete e[R],l.send({type:a,updatedAt:(new Date).toLocaleString()},e)}})),l.subscribe((e=>{var a,n;if("ACTION"===e.type&&e.payload)try{Object.assign(t,JSON.parse(e.payload))}catch(t){console.error("please dispatch a serializable value that JSON.parse() and proxy() support\n",t)}if("DISPATCH"===e.type&&e.state){var s,i;if("JUMP_TO_ACTION"===(null==(s=e.payload)?void 0:s.type)||"JUMP_TO_STATE"===(null==(i=e.payload)?void 0:i.type)){r=!0;const a=JSON.parse(e.state);Object.assign(t,a)}t[R]=e}else if("DISPATCH"===e.type&&"COMMIT"===(null==(a=e.payload)?void 0:a.type))l.init(k(t));else if("DISPATCH"===e.type&&"IMPORT_STATE"===(null==(n=e.payload)?void 0:n.type)){var o,c;const a=null==(o=e.payload.nextLiftedState)?void 0:o.actionsById,n=(null==(c=e.payload.nextLiftedState)?void 0:c.computedStates)||[];r=!0,n.forEach((({state:e},n)=>{const s=a[n]||"No action found";Object.assign(t,e),0===n?l.init(k(t)):l.send(s,k(t))}))}}));l.init(k(t))}(C,{name:`${u} Store`,enabled:!0});const L={},D={};y.setContext(t.context),y.setAppName(u);const N=v({},Xa(u),{fetch:new Gt(u)});if(t.previewMode||t.builderMode){const{authActions:e,authStateActions:a,connectivityActions:n,subscriptionsActions:s,subscriptionsStateActions:i,vendorActions:o,auditsActions:r}=wd(C,N,D,O);L.auth=a,L.connectivity=n,L.subscriptions=i,L.vendor=o,L.auditLogs=r,L.audits={},Object.assign(D,v({},e,n,s,o,r));const l={dispatch:t=>{setTimeout((()=>{const[a,...i]=t.type.split("/"),r=i.join("/");"auth"===a&&"function"==typeof e[r]?e[r](t.payload):"connectivity"===a&&"function"==typeof n[r]?n[r](t.payload):"subscriptions"===a&&"function"==typeof s[r]?s[r](t.payload):"vendor"===a&&"function"==typeof o[r]&&o[r](t.payload)}))},getState:()=>C,subscribe:t=>P(C,t),subscribeStateChanged:t=>P(C,(()=>t(C))),store:C,actions:D,stateActions:L};return t.previewMode&&l.dispatch({type:"auth/requestAuthorize",payload:!0}),c&&(c.store=l),l}{const[t,e]=Jl(C,N,D,O),a=ac(C,N,D),[n,s]=xc(C,N,D),i=jc(C,N,D),o=Jc(C,N,D),r=((t,e)=>{const a=()=>{t.audits.isLoading=!1},n=e=>{var a;t.audits.error=null!=(a=t.audits.error)?a:{},Object.assign(t.audits.error,{[e.name]:e.error})},s=e=>{t.audits.filters=e,t.audits.currentPage=0,t.audits.offset=0,t.audits.isLoading=!0},i=async()=>{const{sortBy:a,sortDirection:s}=t.audits;try{i=await e.audits.getAuditsStats({sortBy:a,sortDirection:s,count:20}),t.audits.error=void 0,t.audits.totalToday=i.totalToday,t.audits.severeThisWeek=i.severeThisWeek}catch(t){const e={name:"stats",error:t};console.error("failed to load stats - ",t),n(e)}var i},o=async()=>{try{a=await e.metadata.getAuditsMetadata(),t.audits.error={},t.audits.headerProps=a.properties,t.audits.themeAudits=a.theme?a.theme.styles:{}}catch(t){const e={name:"metadata",error:t};console.error("failed to load metadata - ",t),n(e)}var a},r=t=>t.reduce(((t,e)=>(t[e.key]=e.value,t)),{}),l=async s=>{const{filters:i,sortBy:o,sortDirection:l,filter:c,offset:u,virtualScroll:d}=t.audits,{appendMode:g=d,onlyOneLoad:p=!0,offset:h=0}=s||{},{rowsData:y}=g?t.audits:{rowsData:[]};try{const n=r(i),{data:s,total:g}=await e.audits.getAudits(v({},d&&{paginationMode:"virtual"},{sortDirection:l,sortBy:o,filter:c},n,{offset:d?y.length+h||y.length+u:h||u,count:20}));(e=>{t.audits.error={},t.audits.rowsData=e.rowsData,t.audits.lastUpdated=new Date,t.audits.total=e.total})({rowsData:[...y,...s],total:g}),p&&a()}catch(t){const e={name:"audits",error:t};console.error("failed to load audits - ",t),n(e)}};return{initData:async()=>{t.audits.isLoading=!0,await Promise.all([i(),o(),l({onlyOneLoad:!1})]),a()},loadAudits:l,removeFilter:async e=>{const{filters:a}=t.audits,n=a.findIndex((t=>t.key===e.key));if(n<0)return;const i=[...a.slice(0,n),...a.slice(n+1)];s(i)},filterData:async e=>{const{filters:a}=t.audits;let n=a.findIndex((t=>t.key===e.key));n<0&&(n=a.length);const i=[...a.slice(0,n),e,...a.slice(n+1)];s(i)},exportCSV:async()=>{const{filters:a,sortBy:n,sortDirection:s,filter:i,headerProps:o=[]}=t.audits,l=r(a);t.audits.isDownloadingCsv=!0;try{await e.audits.exportAudits(v({endpoint:"csv/v2",headerProps:o,sortDirection:s,sortBy:n,filter:i},l,{offset:0,outputFileName:"audits.csv"}))}catch(t){console.error("failed to export audits - ",t)}finally{t.audits.isDownloadingCsv=!1}}}})(C,N);return L.auth=e,L.connectivity=a,L.subscriptions=s,L.vendor=i,L.auditLogs=o,L.audits=r,Object.assign(D,v({},t,a,n,i,o)),{dispatch:e=>{const[s,...o]=e.type.split("/"),r=o.join("/");"auth"===s&&"function"==typeof t[r]?t[r](e.payload):"connectivity"===s&&"function"==typeof a[r]?a[r](e.payload):"subscriptions"===s&&"function"==typeof n[r]?n[r](e.payload):"vendor"===s&&"function"==typeof i[r]&&i[r](e.payload)},getState:()=>C,subscribe:t=>P(C,t),subscribeStateChanged:t=>P(C,(()=>t(C))),store:C,actions:D,stateActions:L}}};let Id,Od,Pd,kd,_d,Rd,Ud,Cd,Ld,Dd,Nd,Md,Fd;!function(t){t.phoneNumber="phoneNumber"}(Id||(Id={})),function(t){t.Name="name",t.PhoneNumber="phoneNumber",t.Address="address",t.JobTitle="jobTitle"}(Od||(Od={})),function(t){t.LoginSessions="loginSessions",t.Mfa="mfa"}(Pd||(Pd={})),function(t){t.Name="name",t.PhoneNumber="phoneNumber"}(kd||(kd={})),function(t){t.CompanyName="companyName",t.Address="address",t.Website="website",t.Timezone="timezone",t.Currency="currency"}(_d||(_d={})),function(t){t.User="user",t.Applications="applications",t.Groups="groups",t.Roles="roles",t.JoinedAt="joinedAt",t.LastSeen="lastSeen",t.ManagedBy="managedBy"}(Rd||(Rd={})),function(t){t.Invoices="invoices"}(Ud||(Ud={})),function(t){t.SessionManagement="sessionManagement",t.GeneralSettings="generalSettings",t.IpRestrictions="ipRestrictions",t.DomainRestrictions="domainRestrictions"}(Cd||(Cd={})),function(t){t.IdleSessionTimeout="idleSessionTimeout",t.ForceReLogin="forceReLogin",t.MaximumConcurrentSessions="maximumConcurrentSessions"}(Ld||(Ld={})),function(t){t.Mfa="mfa",t.UserLockout="userLockout",t.PasswordHistory="passwordHistory"}(Dd||(Dd={})),function(t){t.IpAddressRestrictions="ipAddressRestrictions"}(Nd||(Nd={})),function(t){t.RestrictSignupByEmailDomain="restrictSignupByEmailDomain"}(Md||(Md={})),function(t){t.Settings="settings",t.CustomLogin="customLogin"}(Fd||(Fd={}));const xd={hidden:"hidden",viewOnly:"viewOnly",edit:"edit"},$d={hidden:"hidden",edit:"edit"};function Gd(t,e=0,a=1){return Math.min(Math.max(e,t),a)}function jd(t){if(t.type)return t;if("#"===t.charAt(0))return jd(function(t){t=t.substr(1);const e=new RegExp(`.{1,${t.length>=6?2:1}}`,"g");let a=t.match(e);return a&&1===a[0].length&&(a=a.map((t=>t+t))),a?`rgb${4===a.length?"a":""}(${a.map(((t,e)=>e<3?parseInt(t,16):Math.round(parseInt(t,16)/255*1e3)/1e3)).join(", ")})`:""}(t));const e=t.indexOf("("),a=t.substring(0,e);if(-1===["rgb","rgba","hsl","hsla","color"].indexOf(a))throw new Error("MUI: Unsupported `%s` color.\nThe following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color(). "+t);const n=t.substring(e+1,t.length-1);let s,i;if("color"===a){if(i=n.split(" "),s=i.shift(),4===i.length&&"/"===i[3].charAt(0)&&(i[3]=i[3].substr(1)),-1===["srgb","display-p3","a98-rgb","prophoto-rgb","rec-2020"].indexOf(s))throw new Error("MUI: unsupported `%s` color space.\nThe following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020."+s)}else i=n.split(",");return{type:a,values:i.map((t=>parseFloat(t))),colorSpace:s}}function Bd(t){const{type:e,colorSpace:a}=t;let{values:n}=t;return-1!==e.indexOf("rgb")?n=n.map(((t,e)=>e<3?parseInt(t,10):t)):-1!==e.indexOf("hsl")&&(n[1]=`${n[1]}%`,n[2]=`${n[2]}%`),n=-1!==e.indexOf("color")?`${a} ${n.join(" ")}`:`${n.join(", ")}`,`${e}(${n})`}function Vd(t){if(0===t.indexOf("#"))return t;const{values:e}=jd(t);return`#${e.map(((t,e)=>function(t){const e=t.toString(16);return 1===e.length?`0${e}`:e}(3===e?Math.round(255*t):t))).join("")}`}function Wd(t,e){return t=jd(t),e=Gd(e),"rgb"!==t.type&&"hsl"!==t.type||(t.type+="a"),"color"===t.type?t.values[3]=`/${e}`:t.values[3]=e,Bd(t)}function Hd(t,e){if(t=jd(t),e=Gd(e),-1!==t.type.indexOf("hsl"))t.values[2]*=1-e;else if(-1!==t.type.indexOf("rgb")||-1!==t.type.indexOf("color"))for(let a=0;a<3;a+=1)t.values[a]*=1-e;return Bd(t)}function zd(t,e){if(t=jd(t),e=Gd(e),-1!==t.type.indexOf("hsl"))t.values[2]+=(100-t.values[2])*e;else if(-1!==t.type.indexOf("rgb"))for(let a=0;a<3;a+=1)t.values[a]+=(255-t.values[a])*e;else if(-1!==t.type.indexOf("color"))for(let a=0;a<3;a+=1)t.values[a]+=(1-t.values[a])*e;return Bd(t)}const Kd=t=>{if(t)return{main:t,light:Vd(zd(t,.4)),dark:Vd(Hd(t,.15)),hover:Vd(Hd(t,.15)),active:Vd(Hd(t,.2))}},qd=t=>{if(t)return{main:t,light:zd(t,.7),dark:Hd(t,.2)}},Jd=(t,e)=>{var a,n,s,i,o,r,l,c,u,d,g,p;return null!=t&&t.palette&&"string"==typeof(null==t||null==(a=t.palette)?void 0:a.primary)?v({},e,{palette:{primary:v({},Kd(null==t||null==(n=t.palette)?void 0:n.primary),{contrastText:null!=(s=null==t||null==(i=t.palette)?void 0:i.primaryText)?s:"#000000"}),secondary:v({},Kd(null==t||null==(o=t.palette)?void 0:o.secondary),{contrastText:null!=(r=null==t||null==(l=t.palette)?void 0:l.secondaryText)?r:"#000000"}),danger:v({},Kd(null==t||null==(c=t.palette)?void 0:c.error),{contrastText:"#FFF"}),success:v({},qd(null==t||null==(u=t.palette)?void 0:u.success),{contrastText:"#FFF"}),error:v({},qd(null==t||null==(d=t.palette)?void 0:d.error),{contrastText:"#FFF"}),warning:v({},qd(null==t||null==(g=t.palette)?void 0:g.warning),{contrastText:"#FFF"}),info:v({},qd(null==t||null==(p=t.palette)?void 0:p.info),{contrastText:"#FFF"})}}):{}},Yd={theme:{},themeV2:{},localizations:{},navigation:{usage:{visibility:"hidden",permissions:["fe.usage.read"],featureFlag:"fe-usage-page"},webhooks:{visibility:"hidden",permissions:["fe.connectivity.read.webhooks"]},roles:{visibility:"hidden",permissions:["fe.secure.read.roles"]},users:{visibility:"always",permissions:["fe.secure.read.users"],inviteDialog:{phoneNumberField:"optional"}},personalApiTokens:{visibility:"hidden",permissions:["fe.secure.read.userApiTokens"]},apiTokens:{visibility:"hidden",permissions:["fe.secure.read.tenantApiTokens"]},profile:{visibility:"always"},privacy:{visibility:"always"},account:{visibility:"always",permissions:["fe.secure.read.accountSettings"]},security:{visibility:"always",permissions:["fe.secure.read.securityPolicy"]},sso:{visibility:"hidden",permissions:["fe.secure.read.samlConfiguration"]},provisioning:{visibility:"hidden",permissions:["fe.secure.read.provisioningConfiguration"]},audits:{visibility:"always",permissions:["fe.secure.read.audits"]},subscriptions:{visibility:"hidden",permissions:["fe.subscriptions.*"]},allAccounts:{visibility:"byPermissions",permissions:["fe.account-hierarchy.read.subAccount"]},groups:{visibility:"hidden",permissions:["fe.secure.read.groups"]}}};class Xd{constructor(){this._theme=Yd.theme,this._themeV2=Yd.themeV2,this._navigation=Yd.navigation,this._localizations=Yd.localizations,this._integrations=Yd.integrations}static getInstance(t="default"){return this._instances[t]}static set(t,e="default"){const a=new Xd;return a.set(t),Xd._instances[e]=a,a}get theme(){var t;return null!=(t=this._theme)?t:{}}get themeV2(){var t;return null!=(t=this._themeV2)?t:{}}get navigation(){var t;return null!=(t=this._navigation)?t:{}}get localizations(){var t;return null!=(t=this._localizations)?t:{}}get integrations(){var t;return null!=(t=this._integrations)?t:{}}set(t){try{var e,a,n,s,i,o,r,l,c;this._navigation=tn().all([null!=(e=Yd.navigation)?e:{},null!=(a=null==t?void 0:t.navigation)?a:{}]),this._theme=tn().all([null!=(n=Yd.theme)?n:{},Jd(null==t?void 0:t.theme,Yd.theme)]),this._themeV2=tn().all([null!=(s=Yd.themeV2)?s:{},null!=(i=null==t?void 0:t.themeV2)?i:{}]),this._localizations=tn().all([null!=(o=Yd.localizations)?o:{},null!=(r=null==t?void 0:t.localizations)?r:{}]),this._integrations=tn().all([null!=(l=Yd.integrations)?l:{},null!=(c=null==t?void 0:t.integrations)?c:{}])}catch(t){this._navigation=Yd.navigation,this._theme=Yd.theme,this._themeV2=Yd.themeV2,this._localizations=Yd.localizations,this._integrations=Yd.integrations}}}Xd._instances={};var Qd=function(t){return t.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map((function(t){return t.toLowerCase()})).join("")},Zd=function(t,e){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=document.createElement(e);return Object.keys(a).forEach((function(t){return n.setAttribute(t,a[t])})),t.appendChild(n),n},tg=function(t){return new Promise((function(e,a){var n=4e3,s=setInterval((function(){return null!=t.themeSetter?(clearInterval(s),void e(!0)):n<0?(a("Failed to load Renderer with themeSetter"),void clearInterval(s)):void(n-=50)}),50)}))},eg=function(t){var e=t.toString();if(e){var a=new URL(window.location.href);a.search=e,window.history.pushState(null,"",a.toString())}};const ag="7.70.0";var ng={admin_portal_ip_restrictions:"on",admin_portal_domain_restrictions:"on","new-mfa-pages":"on","show-passkeys-new":"on","groups-admin-box-new":"on","msp-all-accounts-new":"on","temporary-users":"on"},sg=function(t){var e,a=Xd.getInstance(t),n=null==a||null==(e=a.integrations)?void 0:e.gtm;null==n||n.filter((function(t){var e=t.id;return t.enabled&&/^GTM-[a-zA-Z0-9]+$/.test(e)})).forEach((function(t){var e=t.id,a=document.createElement("script");a.innerHTML="\n (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n })(window,document,'script','dataLayer','".concat(e,"');\n "),document.body.appendChild(a)}))},ig=function(){var t=p(y().mark((function t(e,a,n){var s,i,o,r;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=null==(s=e.metadataOverrides)?void 0:s.url){t.next=3;break}return t.abrupt("return",e);case 3:return t.prev=3,t.next=6,On((function(){return a.sendRequest({url:i,method:"GET",credentials:"omit"})}),n);case 6:if(!(o=t.sent)){t.next=10;break}return r=tn()(e,o),t.abrupt("return",r);case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(3),console.error("Failed to get metadata overrides",t.t0);case 15:return t.abrupt("return",e);case 16:case"end":return t.stop()}}),t,null,[[3,12]])})));return function(e,a,n){return t.apply(this,arguments)}}(),og=function(){function a(t,e){var n,s,o,r=this,l=arguments.length>2&&void 0!==arguments[2]&&arguments[2],u=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i(this,a),this.name=void 0,this.iframeRendering=void 0,this.options=void 0,this.loading=!0,this.cdnUrl="https://assets.frontegg.com/admin-box/".concat(ag),this.assetsUrl="https://adminBox.frontegg.com/admin-box/".concat(ag),this.customElementName="",this.adminPortalEl=void 0,this.adminPortalRenderer=void 0,this.loginBoxEl=void 0,this.checkoutDialogEl=void 0,this.checkoutDialogRenderer=void 0,this.adminPortalContainer=void 0,this.loginBoxContainer=void 0,this.checkoutDialogContainer=void 0,this.loginBoxRenderer=void 0,this.store=void 0,this.loadingListeners=[],this.fetchClient=void 0,this.apiClient=void 0,this.updateLocalizations=void 0,this.loadAdminBoxMetadata=p(y().mark((function t(){var e,a,n,s,i;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r.options.metadata){t.next=21;break}return t.prev=1,t.next=4,On((function(){return r.fetchClient.get("/metadata",{entityName:"adminBox"})}),Tn);case 4:return s=t.sent,i=null!=(e=null==s||null==(a=s.rows)||null==(n=a[0])?void 0:n.configuration)?e:{},t.prev=6,t.next=9,ig(i,r.fetchClient,Tn);case 9:r.options.metadata=t.sent,t.next=15;break;case 12:t.prev=12,t.t0=t.catch(6),console.error("failed to get admin portal overridden metadata",t.t0);case 15:t.next=21;break;case 17:t.prev=17,t.t1=t.catch(1),console.error("failed to get admin portal metadata",t.t1),r.dispatchErrorByRequestName(t.t1,Wn.LOAD_ADMIN_BOX_METADATA);case 21:Xd.set(r.options.metadata,r.name);case 22:case"end":return t.stop()}}),t,null,[[1,17],[6,12]])}))),this.requestAuthorize=p(y().mark((function t(){var e,a,n;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=null==(e=r.options.authOptions)||null==(a=e.hostedLoginOptions)?void 0:a.loadUserOnFirstLoad,r.options.builderMode||"nextjs"===r.options.framework||(r.options.hostedLoginBox&&!r.options.customLoginBox?n&&r.store.dispatch({type:"auth/requestHostedLoginAuthorizeV2",payload:{shouldRedirectToLogin:!1,firstTime:!0}}):r.store.dispatch({type:"auth/requestAuthorize",payload:!0}));case 2:case"end":return t.stop()}}),t)}))),this.loadFeatureFlags=p(y().mark((function t(){var e;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!r.options.previewMode&&!r.options.builderMode){t.next=4;break}Zt.set(ng,r.name),t.next=16;break;case 4:return t.prev=4,t.next=7,On((function(){return r.apiClient.featureFlags.loadFeatureFlags()}),Tn);case 7:e=t.sent,r.options.overrideFeatureFlags&&Object.assign(e,r.options.overrideFeatureFlags),Zt.set(e,r.name),t.next=16;break;case 12:t.prev=12,t.t0=t.catch(4),console.error("failed to get admin portal feature flags",t.t0),r.dispatchErrorByRequestName(t.t0,Wn.LOAD_FEATURE_FLAGS);case 16:case"end":return t.stop()}}),t,null,[[4,12]])}))),this.setFeatureFlagsForPreview=function(t){Zt.set(Object.assign({},ng,t),r.name)},this.queryFeatureFlags=function(t){return Zt.getFeatureFlags(t,r.name)},this.updateLocalizationsSetter=function(t){r.updateLocalizations=t},this.getEntitlementsFromStore=function(){var t;return null==(t=r.store.getState().auth.user)?void 0:t.entitlements},this.getUserFromStore=function(){return r.store.getState().auth.user},this.getEntitlementsQueryData=function(t){var e=r.getUserFromStore();return{entitlements:r.getEntitlementsFromStore(),attributes:{custom:t,jwt:e}}},this.renderUsersTable=function(){var t=p(y().mark((function t(e,a,n){var s;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.loadScript("FronteggAdminPortal");case 2:return s=t.sent,t.abrupt("return",s.renderUsersTable(e,{injector:r,options:r.options,container:e,props:a,themeOptions:n.themeOptions}));case 4:case"end":return t.stop()}}),t)})));return function(e,a,n){return t.apply(this,arguments)}}(),this.renderInviteUserDialog=function(){var t=p(y().mark((function t(e,a,n){var s;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.loadScript("FronteggAdminPortal");case 2:return s=t.sent,t.abrupt("return",s.renderInviteUserDialog(e,{injector:r,options:r.options,container:e,props:a,themeOptions:n.themeOptions}));case 4:case"end":return t.stop()}}),t)})));return function(e,a,n){return t.apply(this,arguments)}}(),this.renderChangePasswordForm=function(){var t=p(y().mark((function t(e,a,n){var s;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.loadScript("FronteggAdminPortal");case 2:return s=t.sent,t.abrupt("return",s.renderChangePasswordForm(e,{injector:r,options:r.options,props:a,themeOptions:n.themeOptions}));case 4:case"end":return t.stop()}}),t)})));return function(e,a,n){return t.apply(this,arguments)}}(),this.renderProfilePage=function(){var t=p(y().mark((function t(e,a,n){var s;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.loadScript("FronteggAdminPortal");case 2:return s=t.sent,t.abrupt("return",s.renderProfilePage(e,{injector:r,options:r.options,props:a,themeOptions:n.themeOptions,localizations:n.localizations}));case 4:case"end":return t.stop()}}),t)})));return function(e,a,n){return t.apply(this,arguments)}}(),this.getUsersTableStore=function(){var t=p(y().mark((function t(e){var a;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.loadScript("FronteggAdminPortal");case 2:return a=t.sent,t.abrupt("return",a.useUsersTableStore(e));case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),this.getInviteUserDialogStore=function(){var t=p(y().mark((function t(e){var a;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.loadScript("FronteggAdminPortal");case 2:return a=t.sent,t.abrupt("return",a.useInviteUserDialogStore(e));case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();var d=Qd(e),g="frontegg-app-".concat(d);this.iframeRendering=l,this.name=d,this.options=Object.assign({},t,{contextOptions:Object.assign({requestCredentials:"include"},t.contextOptions)}),this.fetchClient=new Gt(this.name),this.apiClient=Xa(this.name),this.options.cdnUrl&&(this.cdnUrl=this.options.cdnUrl),this.options.assetsUrl&&(this.assetsUrl=this.options.assetsUrl),U.for(this.name).setCdnUrl(this.cdnUrl),U.for(this.name).setAssetsUrl(this.assetsUrl),this.customElementName=g;var h,S,v=this.options.authOptions?Object.assign({},this.options.authOptions,{hostedLoginBox:this.options.hostedLoginBox}):{hostedLoginBox:this.options.hostedLoginBox};if(v.onRedirectTo=t.onRedirectTo,v.disableSilentRefresh=null==(n=this.options.authOptions)?void 0:n.disableSilentRefresh,this.options.store){if(this.store=this.options.store,!u&&this.options.store.getState().root.appName!==e)throw Error("Mismatch in store names")}else this.store=Ed({context:this.options.contextOptions,name:this.name,builderMode:this.options.builderMode,previewMode:this.options.previewMode,storeHolder:this,urlStrategy:this.options.urlStrategy,initialState:{auth:Object.assign({},v,null!=(h=this.options.authOptions)?h:{}),auditLogs:Object.assign({},null!=(S=this.options.auditsOptions)?S:{})}});c.setInstance(d,this);var f=U.for(d);f.setAppName(d),this.setEntitlementsOptions(t.entitlementsOptions),this.setSessionContext({enableSessionPerTenant:null==(s=t.authOptions)?void 0:s.enableSessionPerTenant,skipUserLoading:null==(o=t.authOptions)?void 0:o.skipUserLoading});var m=t.basename;m&&f.setBasename(m)}var n,o,r,u;return l(a,[{key:"setEntitlementsOptions",value:function(t){U.for(this.name).setEntitlementsOptions(Object.assign({},t))}},{key:"setSessionContext",value:function(t){U.for(this.name).setSessionContext(Object.assign({},t))}},{key:"dispatchErrorByRequestName",value:function(t,e){(null==t?void 0:t.statusCode)<500||this.store.dispatch({type:"auth/setErrorByRequestName",payload:{requestName:e,traceId:kn(t)}})}},{key:"initContainers",value:(u=p(y().mark((function t(e){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.adminPortalEl=e.adminPortalEl,this.loginBoxEl=e.loginBoxEl,this.checkoutDialogEl=e.checkoutDialogEl,this.adminPortalContainer=e.adminPortalContainer,this.loginBoxContainer=e.loginBoxContainer,this.checkoutDialogContainer=e.checkoutDialogContainer;try{"nextjs"!==this.options.framework&&document.body.classList.add("frontegg-loading")}catch(t){console.error("Failed to add frontegg-loading to body classList")}return t.next=9,Promise.all([this.loadFeatureFlags(),this.loadAdminBoxMetadata(),this.requestAuthorize()]);case 9:this.options.previewMode||this.options.customLoginBox||(this.loadLoginBox(),sg(this.name)),this.options.lazyLoadAdminPortal||this.loadScript("FronteggAdminPortal");case 11:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"updateMetadata",value:function(t){var e;Xd.set(t,this.name),null!=t&&t.localizations&&(null==(e=this.updateLocalizations)||e.call(this,t.localizations))}},{key:"addOnLoadedListener",value:function(t){this.loading?this.loadingListeners.push(t):t()}},{key:"ready",value:function(t){this.loading?t():this.addOnLoadedListener(t)}},{key:"loginWithRedirect",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.store.dispatch({type:"auth/setState",payload:{isLoading:!0}}),this.store.dispatch({type:"auth/requestHostedLoginAuthorize",payload:t})}},{key:"loginWithRedirectV2",value:function(t){this.store.dispatch({type:"auth/requestHostedLoginAuthorizeV2",payload:t})}},{key:"logout",value:function(t){this.store.dispatch({type:"auth/setState",payload:{isLoading:!0}}),this.store.dispatch({type:"auth/logout",payload:t})}},{key:"loadScript",value:function(a){var n=this;return new Promise((function(i,o){var r=window;if(r[a])i(r[a]);else{var l=document.createElement("script");l.src="".concat(n.cdnUrl,"/").concat({FronteggLoginBox:"login-box/index.js",FronteggAdminPortal:"admin-portal/index.js"}[a]),l.setAttribute("id","".concat(a,"Script")),l.setAttribute("cdn-url",n.cdnUrl),l.onload=function(){r["".concat(a,"Init")]?i(r["".concat(a,"Init")]({FronteggRestApi:t,FronteggTypes:s,FronteggReduxStore:e})):i(r[a])},l.onerror=function(t){console.log("Profile page error",t),o(t)},document.body.append(l)}}))}},{key:"loadLoginBox",value:(r=p(y().mark((function t(){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.loadScript("FronteggLoginBox");case 2:t.sent.render(this.loginBoxEl,{injector:this,options:this.options}),this.loading=!1,this.loadingListeners.forEach((function(t){try{t()}catch(t){console.error("Failed to call loadLoginBoxListener",t)}})),this.loadingListeners=[];case 7:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"showAdminPortal",value:(o=p(y().mark((function t(e){var a,n,s,i,o;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=(null!=e?e:{isMultiApp:!1}).isMultiApp,n=this.queryFeatureFlags(["multi-apps-admin-portal"]),s=d(n,1),i=s[0],U.for(this.name).setRequestSource(Ft.AdminPortal),t.next=5,this.loadScript("FronteggAdminPortal");case 5:o=t.sent,this.adminPortalRenderer=o.render(this.adminPortalEl,{injector:this,options:Object.assign({isMultiApp:i&&a},this.options)});case 7:case"end":return t.stop()}}),t,this)}))),function(t){return o.apply(this,arguments)})},{key:"openHostedAdminPortal",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.options.contextOptions.baseUrl,a="".concat(e,"/oauth/portal");t?window.open(a,"_blank"):window.location.href=a}},{key:"hideAdminPortal",value:function(){try{var t,e=new URLSearchParams(window.location.search);null==(t=this.adminPortalRenderer)||t.unmount(),eg(e),U.for(this.name).setRequestSource(null)}catch(t){console.error("Failed to unmount admin portal",t)}}},{key:"showCheckoutDialog",value:(n=p(y().mark((function t(e){var a;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.loadScript("FronteggAdminPortal");case 2:a=t.sent,this.checkoutDialogRenderer=a.renderCheckoutDialog(this.checkoutDialogEl,Object.assign({injector:this},e,{options:this.options}));case 4:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"hideCheckoutDialog",value:function(){try{var t;null==(t=this.checkoutDialogRenderer)||t.unmount()}catch(t){console.error("Failed to unmount checkout dialog",t)}}},{key:"getFeatureEntitlements",value:function(t,e){var a=this.getEntitlementsQueryData(e),n=a.entitlements,s=a.attributes;return eo(n,t,s)}},{key:"getPermissionEntitlements",value:function(t,e){var a=this.getEntitlementsQueryData(e),n=a.entitlements,s=a.attributes;return to(n,t,s)}},{key:"getEntitlements",value:function(t,e){return"permissionKey"in t?this.getPermissionEntitlements(t.permissionKey,e):this.getFeatureEntitlements(t.featureKey,e)}},{key:"loadEntitlements",value:function(t){this.store.dispatch({type:"auth/loadEntitlements",payload:{callback:t}})}},{key:"stepUp",value:function(t){var e=this.store.getState(),a=(null==e?void 0:e.auth)||{},n=a.hostedLoginBox,s=a.routes.stepUpUrl;n?this.store.dispatch({type:"auth/stepUpHostedLogin",payload:t}):ps(s,e.auth.onRedirectTo,null==t?void 0:t.maxAge)}},{key:"isSteppedUp",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=((null==(t=this.store.getState())?void 0:t.auth)||{}).user;return ds(a,e)}},{key:"switchTenant",value:function(t){this.store.dispatch({type:"auth/switchTenant",payload:t})}},{key:"close",value:function(){this.hideAdminPortal(),this.hideCheckoutDialog()}}]),a}(),rg=function(){function t(){i(this,t)}return l(t,null,[{key:"setAuthentication",value:function(t,e,a){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"default",s=c.getInstance(n),i=U.for(n);t&&e?(i.setAccessToken(e),i.setUser(Object.assign({},a,{accessToken:e})),s.store.actions.setAuthState({isLoading:!1,isAuthenticated:t,user:a}),s.store.actions.loadTenants()):(i.setAccessToken(null),i.setUser(null),s.store.actions.setAuthState({isLoading:!1,isAuthenticated:!1,user:null}))}}]),t}(),lg=function(){function t(){i(this,t)}return l(t,null,[{key:"show",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";c.getInstance(t).showAdminPortal()}},{key:"showMultiApp",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";c.getInstance(t).showAdminPortal({isMultiApp:!0})}},{key:"openHosted",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";c.getInstance(e).openHostedAdminPortal(t)}},{key:"hide",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";c.getInstance(t).hideAdminPortal()}}]),t}(),cg=function(){function t(){i(this,t)}return l(t,null,[{key:"show",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";c.getInstance(e).showCheckoutDialog(t)}},{key:"hide",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";c.getInstance(t).hideCheckoutDialog()}}]),t}(),ug=function(t){var e;return null!=(e=window.FronteggAdminPortal.adminPortalStaticThemesDefaults[t])?e:void 0},dg=function(){function t(e,a,n,s){var o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];i(this,t),this.app=void 0,this.options=void 0,this.store=void 0,this.setRoute=function(){},this.themeSetter=void 0,this.themeOptions={};var r={baseUrl:"preview"};if(n){if(this.store=n,!o&&n.getState().root.appName!==e)throw Error("Mismatch in store names")}else this.store=Td({context:r,appName:e},this,!0,void 0,void 0,!0);this.options=Object.assign({themeOptions:a,iframeRendering:!0,metadata:{},previewMode:!0,builderMode:!0,store:this.store,contextOptions:r},s),this.app=new og(this.options,e,!0),Xd.set({},e)}var e;return l(t,[{key:"render",value:(e=p(y().mark((function t(e){var a,n,s,i,o=this;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(a=e.querySelector("#root"))||((a=e.ownerDocument.createElement("div")).setAttribute("id","root"),e.appendChild(a)),this.app.adminPortalContainer=e,this.app.adminPortalEl=a,n=function(t){o.themeSetter=t},s=function(t){o.setRoute=t},t.next=8,this.app.loadScript("FronteggAdminPortal");case 8:return i=t.sent,this.app.adminPortalRenderer=i.renderPage(a,{options:this.options,injector:this.app,setThemeSetter:n,setStaticRouteSetter:s}),this.app.loading=!1,t.next=13,tg(this);case 13:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"setStaticRoute",value:function(t){var e;null==(e=this.setRoute)||e.call(this,t)}},{key:"unmount",value:function(){try{var t;null==(t=this.app.adminPortalRenderer)||t.unmount()}catch(t){console.error("Failed to unmount admin Portal renderer",t)}}},{key:"setTheme",value:function(t){var e;this.themeOptions=t,this.themeSetter||console.warn("this.themeSetter is not defined yet"),null==(e=this.themeSetter)||e.call(this,this.themeOptions)}}]),t}(),gg="modern",pg=function(t){var e,a=window.FronteggAdminPortal.themes;return null!=(e=a[t])?e:a[gg]},hg=function(){function t(e,a,n,s){var o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];i(this,t),this.app=void 0,this.options=void 0,this.store=void 0,this.themeSetter=void 0,this.setRoute=function(){},this.themeOptions={};var r={baseUrl:"preview"};if(n){if(this.store=n,!o&&n.getState().root.appName!==e)throw Error("Mismatch in store names")}else this.store=Td({context:r,appName:e},this,!0,void 0,void 0,!0);this.options=Object.assign({themeOptions:a,iframeRendering:!0,metadata:{},previewMode:!0,builderMode:!0,store:this.store,contextOptions:r,onRedirectTo:function(){console.debug("path")}},s),this.app=new og(this.options,e,!0,o),Xd.set({},e)}var e;return l(t,[{key:"render",value:(e=p(y().mark((function t(e){var a,n,s,i,o=this;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(a=e.querySelector("#root"))||((a=e.ownerDocument.createElement("div")).setAttribute("id","root"),e.appendChild(a)),this.app.loginBoxContainer=e,this.app.loginBoxEl=a,n=function(t){o.themeSetter=t},s=function(t){o.setRoute=t},t.next=8,this.app.loadScript("FronteggLoginBox");case 8:return i=t.sent,this.app.loginBoxRenderer=i.renderPage(a,{options:this.options,injector:this.app,setThemeSetter:n,setStaticRouteSetter:s,staticRoute:"/account/login"}),t.next=12,tg(this);case 12:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"unmount",value:function(){try{var t;null==(t=this.app.loginBoxRenderer)||t.unmount()}catch(t){console.error("Failed to unmount login box renderer",t)}}},{key:"setTheme",value:function(t){var e;this.themeOptions=t,this.themeSetter||console.warn("this.themeSetter is not defined yet"),null==(e=this.themeSetter)||e.call(this,this.themeOptions)}},{key:"setStaticRoute",value:function(t){var e;this.setRoute||console.warn("this.setRoute is not defined yet"),null==(e=this.setRoute)||e.call(this,t)}},{key:"setStore",value:function(t){this.store.dispatch({type:"auth/setState",payload:t})}}]),t}();function yg(t,e){return yg=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},yg(t,e)}function Sg(t){return Sg=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Sg(t)}function vg(t,e,a){return vg=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,a){var n=[null];n.push.apply(n,e);var s=new(Function.bind.apply(t,n));return a&&yg(s,a.prototype),s},vg.apply(null,arguments)}function fg(t){var e="function"==typeof Map?new Map:void 0;return fg=function(t){if(null===t||(a=t,-1===Function.toString.call(a).indexOf("[native code]")))return t;var a;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return vg(t,arguments,Sg(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),yg(n,t)},fg(t)}function mg(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var a,n=Sg(t);if(e){var s=Sg(this).constructor;a=Reflect.construct(n,arguments,s)}else a=n.apply(this,arguments);return function(t,e){if(e&&("object"===o(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,a)}}var bg=function(t){var e=new og(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default");if("undefined"!=typeof document){var a;if(!t.contextOptions.baseUrl){var n=new Error('Edit <FronteggProvider/> options { ContextOptions: { baseUrl: "" } } in order to connect your application');throw document.body.innerHTML="",alert(n.message),n}if(!customElements.get("frontegg-app")){var s=function(e){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&yg(t,e)}(n,e);var a=mg(n);function n(){var t;i(this,n);for(var e=arguments.length,s=new Array(e),o=0;o<e;o++)s[o]=arguments[o];return(t=a.call.apply(a,[this].concat(s))).app=null,t}return l(n,[{key:"connectedCallback",value:function(){this.updateContent()}},{key:"attributeChangedCallback",value:function(t,e,a){if("app-name"===t){if(null===e)return;if(e===a)return;this.innerHTML="",null===a?this.remove():this.updateContent()}console.debug("attributeChangedCallback",t,e,a)}},{key:"updateContent",value:function(){var e,a=null!=(e=this.getAttribute("app-name"))?e:"default",n=c.getInstance(a);if(null===n)throw Error("FronteggApp not found for appName: '".concat(a,"'"));this.setAttribute("id","frontegg-app-".concat(n.name));var s=Zd(this,"div",{id:"frontegg-admin-portal-container-".concat(n.name)}),i=Zd(this,"div",{id:"frontegg-login-box-container-".concat(n.name)}),o=Zd(this,"div",{id:"frontegg-checkout-dialog-container-".concat(n.name)}),r=s.attachShadow({mode:"open"}),l=t.iframeRendering?i:i.attachShadow({mode:"open"}),u=o.attachShadow({mode:"open"}),d=Zd(r,"div",{id:"frontegg-admin-portal-".concat(n.name),class:"frontegg-root-content"}),g=Zd(l,"div",{id:"frontegg-login-box-".concat(n.name),class:"frontegg-root-content"}),p=Zd(u,"div",{id:"frontegg-checkout-dialog-".concat(n.name),class:"frontegg-root-content"});n.initContainers({adminPortalEl:d,loginBoxEl:g,adminPortalContainer:s,loginBoxContainer:i,checkoutDialogContainer:o,checkoutDialogEl:p})}}],[{key:"observedAttributes",get:function(){return["app-name"]}}]),n}(fg(HTMLElement));customElements.define("frontegg-app",s)}null==(a=document.querySelector('frontegg-app[app-name="'.concat(e.name,'"]')))||a.remove();var o=document.createElement("frontegg-app");o.setAttribute("app-name",e.name),document.body.appendChild(o)}return e}})(),n})()));
2
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Frontegg=e():t.Frontegg=e()}(window,(()=>(()=>{var t={3952:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createConditionEvaluator=void 0;const n=a(2904),s=a(9475);e.createConditionEvaluator=function(t){const e=(0,s.useSanitizer)(t.condition.op);if(!e)return()=>!1;const{isSanitized:a,sanitizedValue:i}=e(t.condition.value);if(!a||void 0===i)return()=>!1;const o=(0,n.useOperation)(t.condition.op,i);return e=>{const a=e[t.condition.attribute];if(void 0===a||!o)return!1;const{isValid:n}=o(a);return t.condition.negate?!n:n}}},9838:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(3952),e),s(a(963),e)},963:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},3998:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.evaluateFeatureFlag=void 0;const n=a(9243);e.evaluateFeatureFlag=function(t,e){if(!t.on)return{treatment:t.offTreatment};const a=function(t,e){var a;return null===(a=t.rules)||void 0===a?void 0:a.find((t=>(0,n.createRuleEvaluator)({rule:t})(e)===n.RuleEvaluationResultEnum.Treatable))}(t,e);return a?{treatment:a.treatment}:{treatment:t.defaultTreatment}}},2152:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(3998),e)},5875:(t,e,a)=>{"use strict";e.Me=e.a_=void 0;a(2152),a(3856),a(9243),a(2752);var n=a(7254);Object.defineProperty(e,"a_",{enumerable:!0,get:function(){return n.evaluateIsEntitledToFeature}}),Object.defineProperty(e,"Me",{enumerable:!0,get:function(){return n.evaluateIsEntitledToPermissions}})},6849:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),e.BooleanOperationsMapper=void 0;const i=a(2752),o=a(6715);s(a(6715),e),s(a(4965),e),e.BooleanOperationsMapper={[i.OperationEnum.Is]:t=>(0,o.useIsOperation)(t)}},6715:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useIsOperation=void 0,e.useIsOperation=function(t){return e=>({isValid:e===t.boolean})}},4965:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.BooleanSanitizersMapper=e.singleBooleanSanitizer=void 0;const n=a(2752);e.singleBooleanSanitizer=t=>{const e=void 0!==t.boolean&&(t=>"boolean"==typeof t)(t.boolean)?{boolean:t.boolean}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.BooleanSanitizersMapper={[n.OperationEnum.Is]:e.singleBooleanSanitizer}},2904:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useOperation=void 0;const n=a(5018),s=a(3922),i=a(3147),o=a(6849),r={...n.StringOperationsMapper,...s.NumericOperationsMapper,...i.DateOperationsMapper,...o.BooleanOperationsMapper};e.useOperation=function(t,e){const a=r[t];return a?a(e):void 0}},9475:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useSanitizer=void 0;const n=a(6849),s=a(1016),i=a(6891),o=a(3922),r={...s.StringSanitizersMapper,...o.NumericSanitizersMapper,...i.DateSanitizersMapper,...n.BooleanSanitizersMapper};e.useSanitizer=function(t){return r[t]}},3147:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),e.DateOperationsMapper=void 0;const i=a(2752),o=a(1641);s(a(1641),e),s(a(1626),e),e.DateOperationsMapper={[i.OperationEnum.On]:t=>(0,o.useDateOnOperation)(t),[i.OperationEnum.OnOrAfter]:t=>(0,o.useDateOnOrAfterOperation)(t),[i.OperationEnum.OnOrBefore]:t=>(0,o.useDateOnOrBeforeOperation)(t),[i.OperationEnum.BetweenDate]:t=>(0,o.useDateBetweenOperation)(t)}},1641:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useDateBetweenOperation=e.useDateOnOrBeforeOperation=e.useDateOnOrAfterOperation=e.useDateOnOperation=void 0,e.useDateOnOperation=function(t){return e=>({isValid:e.getTime()===t.date.getTime()})},e.useDateOnOrAfterOperation=function(t){return e=>({isValid:e.getTime()>=t.date.getTime()})},e.useDateOnOrBeforeOperation=function(t){return e=>({isValid:e.getTime()<=t.date.getTime()})},e.useDateBetweenOperation=function(t){return e=>({isValid:e.getTime()>=t.start.getTime()&&e.getTime()<=t.end.getTime()})}},6891:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DateSanitizersMapper=e.sanitizeDateRange=e.sanitizeSingleDate=e.isValidDate=e.sanitizeDateValue=void 0;const n=a(2752);e.sanitizeDateValue=t=>new Date(t),e.isValidDate=t=>t instanceof Date&&!isNaN(t),e.sanitizeSingleDate=t=>{const a=t.date?(0,e.sanitizeDateValue)(t.date):void 0,n=a&&(0,e.isValidDate)(a)?{date:a}:void 0;return{isSanitized:!!n,sanitizedValue:n}},e.sanitizeDateRange=t=>{const a=t.start?(0,e.sanitizeDateValue)(t.start):void 0,n=t.end?(0,e.sanitizeDateValue)(t.end):void 0,s=a&&n&&(0,e.isValidDate)(a)&&(0,e.isValidDate)(n)?{start:a,end:n}:void 0;return{isSanitized:!!s,sanitizedValue:s}},e.DateSanitizersMapper={[n.OperationEnum.On]:e.sanitizeSingleDate,[n.OperationEnum.OnOrAfter]:e.sanitizeSingleDate,[n.OperationEnum.OnOrBefore]:e.sanitizeSingleDate,[n.OperationEnum.BetweenDate]:e.sanitizeDateRange}},1626:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},3922:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),e.NumericOperationsMapper=void 0;const i=a(2752),o=a(9194);e.NumericOperationsMapper={[i.OperationEnum.Equal]:t=>(0,o.useEqualsOperation)(t),[i.OperationEnum.GreaterThan]:t=>(0,o.useGreaterThanOperation)(t),[i.OperationEnum.GreaterThanEqual]:t=>(0,o.useGreaterThanEqualOperation)(t),[i.OperationEnum.LesserThan]:t=>(0,o.useLesserThanOperation)(t),[i.OperationEnum.LesserThanEqual]:t=>(0,o.useLesserThanEqualOperation)(t),[i.OperationEnum.BetweenNumeric]:t=>(0,o.useBetweenNumericOperation)(t)},s(a(9194),e),s(a(5168),e),s(a(7695),e)},9194:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useBetweenNumericOperation=e.useLesserThanEqualOperation=e.useLesserThanOperation=e.useGreaterThanEqualOperation=e.useGreaterThanOperation=e.useEqualsOperation=void 0,e.useEqualsOperation=function(t){return e=>({isValid:e===t.number})},e.useGreaterThanOperation=function(t){return e=>({isValid:e>t.number})},e.useGreaterThanEqualOperation=function(t){return e=>({isValid:e>=t.number})},e.useLesserThanOperation=function(t){return e=>({isValid:e<t.number})},e.useLesserThanEqualOperation=function(t){return e=>({isValid:e<=t.number})},e.useBetweenNumericOperation=function(t){return e=>({isValid:e>=t.start&&e<=t.end})}},5168:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.NumericSanitizersMapper=e.sanitizeNumericRange=e.sanitizeSingleNumber=void 0;const n=a(2752),s=t=>"number"==typeof t;e.sanitizeSingleNumber=t=>{const e=void 0!==t.number&&s(t.number)?{number:t.number}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.sanitizeNumericRange=t=>{const e=void 0!==t.start&&void 0!==t.end&&s(t.start)&&s(t.end)?{start:t.start,end:t.end}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.NumericSanitizersMapper={[n.OperationEnum.Equal]:e.sanitizeSingleNumber,[n.OperationEnum.GreaterThan]:e.sanitizeSingleNumber,[n.OperationEnum.GreaterThanEqual]:e.sanitizeSingleNumber,[n.OperationEnum.LesserThan]:e.sanitizeSingleNumber,[n.OperationEnum.LesserThanEqual]:e.sanitizeSingleNumber,[n.OperationEnum.BetweenNumeric]:e.sanitizeNumericRange}},7695:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},5018:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),e.StringOperationsMapper=void 0;const i=a(2752),o=a(5154);s(a(5154),e),s(a(4503),e),e.StringOperationsMapper={[i.OperationEnum.StartsWith]:t=>(0,o.useStartsWithOperation)(t),[i.OperationEnum.EndsWith]:t=>(0,o.useEndsWithOperation)(t),[i.OperationEnum.Contains]:t=>(0,o.useContainsOperation)(t),[i.OperationEnum.InList]:t=>(0,o.useInListOperation)(t),[i.OperationEnum.Matches]:t=>(0,o.useMatchesOperation)(t)}},5154:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.useMatchesOperation=e.useInListOperation=e.useContainsOperation=e.useEndsWithOperation=e.useStartsWithOperation=void 0,e.useStartsWithOperation=function(t){return e=>({isValid:t.list.some((t=>e.startsWith(t)))})},e.useEndsWithOperation=function(t){return e=>({isValid:t.list.some((t=>e.endsWith(t)))})},e.useContainsOperation=function(t){return e=>({isValid:t.list.some((t=>e.includes(t)))})},e.useInListOperation=function(t){return e=>({isValid:t.list.includes(e)})},e.useMatchesOperation=function(t){return e=>{let a;try{a=new RegExp(t.string)}catch(t){return{isValid:!1}}return{isValid:a.test(e)}}}},1016:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StringSanitizersMapper=e.sanitizeListString=e.sanitizeSingleString=void 0;const n=a(2752),s=t=>"string"==typeof t;e.sanitizeSingleString=t=>{const e=void 0!==t.string&&s(t.string)?{string:t.string}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.sanitizeListString=t=>{const e=void 0!==t.list&&t.list.every((t=>s(t)))?{list:t.list}:void 0;return{isSanitized:!!e,sanitizedValue:e}},e.StringSanitizersMapper={[n.OperationEnum.Matches]:e.sanitizeSingleString,[n.OperationEnum.Contains]:e.sanitizeListString,[n.OperationEnum.StartsWith]:e.sanitizeListString,[n.OperationEnum.EndsWith]:e.sanitizeListString,[n.OperationEnum.InList]:e.sanitizeListString}},4503:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},2752:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(7158),e)},7158:(t,e)=>{"use strict";var a;Object.defineProperty(e,"__esModule",{value:!0}),e.OperationEnum=void 0,(a=e.OperationEnum||(e.OperationEnum={})).InList="in_list",a.StartsWith="starts_with",a.EndsWith="ends_with",a.Contains="contains",a.Matches="matches",a.Equal="equal",a.GreaterThan="greater_than",a.GreaterThanEqual="greater_than_equal",a.LesserThan="lower_than",a.LesserThanEqual="lower_than_equal",a.BetweenNumeric="between_numeric",a.Is="is",a.On="on",a.BetweenDate="between_date",a.OnOrAfter="on_or_after",a.OnOrBefore="on_or_before"},3856:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(6334),e)},6334:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.evaluatePlan=void 0;const n=a(9243);e.evaluatePlan=function(t,e){const a=function(t,e){var a;return null===(a=t.rules)||void 0===a?void 0:a.find((t=>(0,n.createRuleEvaluator)({rule:t})(e)===n.RuleEvaluationResultEnum.Treatable))}(t,e);return a?{treatment:a.treatment}:{treatment:t.defaultTreatment}}},9243:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(5546),e),s(a(4874),e)},4874:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createRuleEvaluator=void 0;const n=a(5546),s=a(9838);e.createRuleEvaluator=function(t){return e=>t.rule.conditions.every((t=>(0,s.createConditionEvaluator)({condition:t})(e)))?n.RuleEvaluationResultEnum.Treatable:n.RuleEvaluationResultEnum.Insufficient}},5546:(t,e)=>{"use strict";var a,n;Object.defineProperty(e,"__esModule",{value:!0}),e.RuleEvaluationResultEnum=e.TreatmentEnum=e.ConditionLogicEnum=void 0,(e.ConditionLogicEnum||(e.ConditionLogicEnum={})).And="and",(n=e.TreatmentEnum||(e.TreatmentEnum={})).True="true",n.False="false",(a=e.RuleEvaluationResultEnum||(e.RuleEvaluationResultEnum={})).Treatable="treatable",a.Insufficient="insufficient"},7254:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(7416),e),s(a(3817),e),s(a(395),e),s(a(6816),e)},1711:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.directEntitlementEvalutor=void 0;const n=a(395);e.directEntitlementEvalutor=function(t,e,a={}){const s=e.features[t];let i=!1;return s&&null!==s.expireTime&&(i=s.expireTime!==n.NO_EXPIRATION_TIME&&s.expireTime<Date.now(),!i)?{isEntitled:!0}:{isEntitled:!1,justification:i?n.NotEntitledJustification.BUNDLE_EXPIRED:n.NotEntitledJustification.MISSING_FEATURE}}},1343:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.featureFlagEvaluator=void 0;const n=a(395),s=a(2152),i=a(8552),o=a(9243);e.featureFlagEvaluator=function(t,e,a={}){const r=e.features[t];if(r&&r.featureFlag){const t=(0,i.prepareAttributes)(a),{treatment:e}=(0,s.evaluateFeatureFlag)(r.featureFlag,t);if(e===o.TreatmentEnum.True)return{isEntitled:!0}}return{isEntitled:!1,justification:n.NotEntitledJustification.MISSING_FEATURE}}},2031:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getIsEntitledEvaluators=void 0;const n=a(1711),s=a(1343),i=a(3155);e.getIsEntitledEvaluators=function(){return[n.directEntitlementEvalutor,s.featureFlagEvaluator,i.planTargetingRulesEvalutor]}},3155:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.planTargetingRulesEvalutor=void 0;const n=a(395),s=a(8552),i=a(9243),o=a(3856);e.planTargetingRulesEvalutor=function(t,e,a={}){const r=e.features[t];if(r&&r.planIds&&r.planIds.length>0){const t=(0,s.prepareAttributes)(a),n=e.plans;for(const e of r.planIds){const a=n[e];if(a){const{treatment:e}=(0,o.evaluatePlan)(a,t);if(e===i.TreatmentEnum.True)return{isEntitled:!0}}}}return{isEntitled:!1,justification:n.NotEntitledJustification.MISSING_FEATURE}}},7416:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(9398),e)},9398:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.evaluateIsEntitledToFeature=void 0;const n=a(395),s=a(6816),i=a(2031);e.evaluateIsEntitledToFeature=function(t,e,a={}){if(!e)return{isEntitled:!1,justification:n.NotEntitledJustification.MISSING_FEATURE};const o=[];for(const n of(0,i.getIsEntitledEvaluators)())if(o.push(n(t,e,a)),!(0,s.shouldContinue)(o))break;return(0,s.getResult)(o)}},3817:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(1474),e)},1474:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.evaluateIsEntitledToPermissions=void 0;const n=a(9398),s=a(395),i=a(6816),o=a(7943);e.evaluateIsEntitledToPermissions=function(t,e,a){if(!e)return{isEntitled:!1,justification:s.NotEntitledJustification.MISSING_PERMISSION};if(!(0,o.checkPermission)(e.permissions,t))return{isEntitled:!1,justification:s.NotEntitledJustification.MISSING_PERMISSION};const r=function(t,e){return Object.keys(e.features).filter((a=>e.features[a].linkedPermissions.includes(t)))}(t,e);if(!r.length)return{isEntitled:!0};const l=[];for(const t of r)if(l.push((0,n.evaluateIsEntitledToFeature)(t,e,a)),!(0,i.shouldContinue)(l))break;return(0,i.getResult)(l)}},395:(t,e)=>{"use strict";var a;Object.defineProperty(e,"__esModule",{value:!0}),e.NO_EXPIRATION_TIME=e.NotEntitledJustification=void 0,(a=e.NotEntitledJustification||(e.NotEntitledJustification={})).MISSING_FEATURE="MISSING_FEATURE",a.MISSING_PERMISSION="MISSING_PERMISSION",a.BUNDLE_EXPIRED="BUNDLE_EXPIRED",e.NO_EXPIRATION_TIME=-1},8552:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.modifyObjectKeysWithPrefix=e.defaultFronteggAttributesMapper=e.prepareAttributes=void 0;const n=a(1857);function s(t){return{email:t.email,emailVerified:t.email_verified,tenantId:t.tenantId,userId:t.id}}function i(t,e){return Object.keys(t).reduce(((a,n)=>(a[`${e}${n}`]=t[n],a)),{})}e.prepareAttributes=function(t={},e){const{custom:a={},jwt:o={}}=t,r=(0,n.flatten)(o);return{...a,...i(e?e(o):s(o),"frontegg."),...i(r,"jwt.")}},e.defaultFronteggAttributesMapper=s,e.modifyObjectKeysWithPrefix=i},8843:(t,e,a)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.shouldContinue=e.getResult=void 0;const n=a(395);e.getResult=function(t){let e=!1;for(const a of t){if(a.isEntitled)return a;a.justification===n.NotEntitledJustification.BUNDLE_EXPIRED&&(e=!0)}return{isEntitled:!1,justification:e?n.NotEntitledJustification.BUNDLE_EXPIRED:n.NotEntitledJustification.MISSING_FEATURE}},e.shouldContinue=function(t){return t.every((({isEntitled:t})=>!t))}},1857:(t,e)=>{"use strict";function a(t){return t}Object.defineProperty(e,"__esModule",{value:!0}),e.flatten=void 0,e.flatten=function(t,e){const n=(null==(e=e||{})?void 0:e.delimiter)||".",s=null==e?void 0:e.maxDepth,i=(null==e?void 0:e.transformKey)||a,o={};return function t(a,r,l){l=l||1,Object.keys(a).forEach((function(c){const u=a[c],d=(null==e?void 0:e.safe)&&Array.isArray(u),g=Object.prototype.toString.call(u),p=(h=u)&&h.constructor&&"function"==typeof h.constructor.isBuffer&&h.constructor.isBuffer(h);var h;const y="[object Object]"===g||"[object Array]"===g,S=r?r+n+i(c):i(c);if(!d&&!p&&y&&Object.keys(u).length&&(!(null==e?void 0:e.maxDepth)||s&&l<s))return t(u,S,l+1);o[S]=u}))}(t),o}},6816:function(t,e,a){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(e,a);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,s)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__exportStar||function(t,e){for(var a in t)"default"===a||Object.prototype.hasOwnProperty.call(e,a)||n(e,t,a)};Object.defineProperty(e,"__esModule",{value:!0}),s(a(7943),e),s(a(8552),e),s(a(8843),e)},7943:(t,e)=>{"use strict";function a(t){return new RegExp("^"+t.replace(/\./g,"\\.").replace(/\*/g,".*")+"$","gs")}Object.defineProperty(e,"__esModule",{value:!0}),e.createPermissionCheckRegex=e.checkPermission=void 0,e.checkPermission=function(t,e){return Object.keys(t).some((t=>a(t).test(e)))},e.createPermissionCheckRegex=a},2743:t=>{"use strict";var e=function(t){return function(t){return!!t&&"object"==typeof t}(t)&&!function(t){var e=Object.prototype.toString.call(t);return"[object RegExp]"===e||"[object Date]"===e||function(t){return t.$$typeof===a}(t)}(t)},a="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(t,e){return!1!==e.clone&&e.isMergeableObject(t)?r((a=t,Array.isArray(a)?[]:{}),t,e):t;var a}function s(t,e,a){return t.concat(e).map((function(t){return n(t,a)}))}function i(t){return Object.keys(t).concat(function(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter((function(e){return t.propertyIsEnumerable(e)})):[]}(t))}function o(t,e){try{return e in t}catch(t){return!1}}function r(t,a,l){(l=l||{}).arrayMerge=l.arrayMerge||s,l.isMergeableObject=l.isMergeableObject||e,l.cloneUnlessOtherwiseSpecified=n;var c=Array.isArray(a);return c===Array.isArray(t)?c?l.arrayMerge(t,a,l):function(t,e,a){var s={};return a.isMergeableObject(t)&&i(t).forEach((function(e){s[e]=n(t[e],a)})),i(e).forEach((function(i){(function(t,e){return o(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))})(t,i)||(o(t,i)&&a.isMergeableObject(e[i])?s[i]=function(t,e){if(!e.customMerge)return r;var a=e.customMerge(t);return"function"==typeof a?a:r}(i,a)(t[i],e[i],a):s[i]=n(e[i],a))})),s}(t,a,l):n(a,l)}r.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce((function(t,a){return r(t,a,e)}),{})};var l=r;t.exports=l},8792:t=>{"use strict";t.exports=function t(e,a){if(e===a)return!0;if(e&&a&&"object"==typeof e&&"object"==typeof a){if(e.constructor!==a.constructor)return!1;var n,s,i;if(Array.isArray(e)){if((n=e.length)!=a.length)return!1;for(s=n;0!=s--;)if(!t(e[s],a[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===a.source&&e.flags===a.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===a.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===a.toString();if((n=(i=Object.keys(e)).length)!==Object.keys(a).length)return!1;for(s=n;0!=s--;)if(!Object.prototype.hasOwnProperty.call(a,i[s]))return!1;for(s=n;0!=s--;){var o=i[s];if(!t(e[o],a[o]))return!1}return!0}return e!=e&&a!=a}},5302:(t,e,a)=>{const n=a(9537);function s(t,e,a){return"function"==typeof a.join?a.join(t):t[0]+e+t[1]}function i(t,e,a){return"function"!=typeof a.isValid||a.isValid(t,e)}function o(t){return n(t)||Array.isArray(t)||"function"==typeof t}t.exports=function(t,e,a){if(n(a)||(a={default:a}),!o(t))return void 0!==a.default?a.default:t;"number"==typeof e&&(e=String(e));const r=Array.isArray(e),l="string"==typeof e,c=a.separator||".",u=a.joinChar||("string"==typeof c?c:".");if(!l&&!r)return t;if(l&&e in t)return i(e,t,a)?t[e]:a.default;let d=r?e:function(t,e,a){return"function"==typeof a.split?a.split(t):t.split(e)}(e,c,a),g=d.length,p=0;do{let e=d[p];for("number"==typeof e&&(e=String(e));e&&"\\"===e.slice(-1);)e=s([e.slice(0,-1),d[++p]||""],u,a);if(e in t){if(!i(e,t,a))return a.default;t=t[e]}else{let n=!1,o=p+1;for(;o<g;)if(e=s([e,d[o++]],u,a),n=e in t){if(!i(e,t,a))return a.default;t=t[e],p=o-1;break}if(!n)return a.default}}while(++p<g&&o(t));return p===g?t:a.default}},2685:(t,e,a)=>{"use strict";var n=a(9537);function s(t){return!0===n(t)&&"[object Object]"===Object.prototype.toString.call(t)}t.exports=function(t){var e,a;return!1!==s(t)&&"function"==typeof(e=t.constructor)&&!1!==s(a=e.prototype)&&!1!==a.hasOwnProperty("isPrototypeOf")}},5858:t=>{"use strict";t.exports=function(t){return"object"==typeof t?null===t:"function"!=typeof t}},9537:t=>{"use strict";t.exports=function(t){return null!=t&&"object"==typeof t&&!1===Array.isArray(t)}},1098:(t,e,a)=>{"use strict";const{deleteProperty:n}=Reflect,s=a(5858),i=a(2685),o=t=>"object"==typeof t&&null!==t||"function"==typeof t,r=t=>{if(!s(t))throw new TypeError("Object keys must be strings or symbols");if((t=>"__proto__"===t||"constructor"===t||"prototype"===t)(t))throw new Error(`Cannot set unsafe key: "${t}"`)},l=(t,e)=>e&&"function"==typeof e.split?e.split(t):"symbol"==typeof t?[t]:Array.isArray(t)?t:((t,e,a)=>{const n=(t=>Array.isArray(t)?t.flat().map(String).join(","):t)(e?((t,e)=>{if("string"!=typeof t||!e)return t;let a=t+";";return void 0!==e.arrays&&(a+=`arrays=${e.arrays};`),void 0!==e.separator&&(a+=`separator=${e.separator};`),void 0!==e.split&&(a+=`split=${e.split};`),void 0!==e.merge&&(a+=`merge=${e.merge};`),void 0!==e.preservePaths&&(a+=`preservePaths=${e.preservePaths};`),a})(t,e):t);r(n);const s=u.cache.get(n)||a();return u.cache.set(n,s),s})(t,e,(()=>((t,e={})=>{const a=e.separator||".",n="/"!==a&&e.preservePaths;if("string"==typeof t&&!1!==n&&/\//.test(t))return[t];const s=[];let i="";const o=t=>{let e;""!==t.trim()&&Number.isInteger(e=Number(t))?s.push(e):s.push(t)};for(let e=0;e<t.length;e++){const n=t[e];"\\"!==n?n!==a?i+=n:(o(i),i=""):i+=t[++e]}return i&&o(i),s})(t,e))),c=(t,e,a,s)=>{if(r(e),void 0===a)n(t,e);else if(s&&s.merge){const n="function"===s.merge?s.merge:Object.assign;n&&i(t[e])&&i(a)?t[e]=n(t[e],a):t[e]=a}else t[e]=a;return t},u=(t,e,a,n)=>{if(!e||!o(t))return t;const s=l(e,n);let i=t;for(let t=0;t<s.length;t++){const e=s[t],l=s[t+1];if(r(e),void 0===l){c(i,e,a,n);break}"number"!=typeof l||Array.isArray(i[e])?(o(i[e])||(i[e]={}),i=i[e]):i=i[e]=[]}return t};u.split=l,u.cache=new Map,u.clear=()=>{u.cache=new Map},t.exports=u},7048:(t,e,a)=>{var n=a(4319).default;function s(){"use strict";t.exports=s=function(){return e},t.exports.__esModule=!0,t.exports.default=t.exports;var e={},a=Object.prototype,i=a.hasOwnProperty,o=Object.defineProperty||function(t,e,a){t[e]=a.value},r="function"==typeof Symbol?Symbol:{},l=r.iterator||"@@iterator",c=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";function d(t,e,a){return Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{d({},"")}catch(t){d=function(t,e,a){return t[e]=a}}function g(t,e,a,n){var s=e&&e.prototype instanceof y?e:y,i=Object.create(s.prototype),r=new k(n||[]);return o(i,"_invoke",{value:E(t,a,r)}),i}function p(t,e,a){try{return{type:"normal",arg:t.call(e,a)}}catch(t){return{type:"throw",arg:t}}}e.wrap=g;var h={};function y(){}function S(){}function v(){}var f={};d(f,l,(function(){return this}));var m=Object.getPrototypeOf,b=m&&m(m(_([])));b&&b!==a&&i.call(b,l)&&(f=b);var A=v.prototype=y.prototype=Object.create(f);function w(t){["next","throw","return"].forEach((function(e){d(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function a(s,o,r,l){var c=p(t[s],t,o);if("throw"!==c.type){var u=c.arg,d=u.value;return d&&"object"==n(d)&&i.call(d,"__await")?e.resolve(d.__await).then((function(t){a("next",t,r,l)}),(function(t){a("throw",t,r,l)})):e.resolve(d).then((function(t){u.value=t,r(u)}),(function(t){return a("throw",t,r,l)}))}l(c.arg)}var s;o(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,s){a(t,n,e,s)}))}return s=s?s.then(i,i):i()}})}function E(t,e,a){var n="suspendedStart";return function(s,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===s)throw i;return{value:void 0,done:!0}}for(a.method=s,a.arg=i;;){var o=a.delegate;if(o){var r=I(o,a);if(r){if(r===h)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===n)throw n="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);n="executing";var l=p(t,e,a);if("normal"===l.type){if(n=a.done?"completed":"suspendedYield",l.arg===h)continue;return{value:l.arg,done:a.done}}"throw"===l.type&&(n="completed",a.method="throw",a.arg=l.arg)}}}function I(t,e){var a=e.method,n=t.iterator[a];if(void 0===n)return e.delegate=null,"throw"===a&&t.iterator.return&&(e.method="return",e.arg=void 0,I(t,e),"throw"===e.method)||"return"!==a&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+a+"' method")),h;var s=p(n,t.iterator,e.arg);if("throw"===s.type)return e.method="throw",e.arg=s.arg,e.delegate=null,h;var i=s.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function _(t){if(t){var e=t[l];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,n=function e(){for(;++a<t.length;)if(i.call(t,a))return e.value=t[a],e.done=!1,e;return e.value=void 0,e.done=!0,e};return n.next=n}}return{next:R}}function R(){return{value:void 0,done:!0}}return S.prototype=v,o(A,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:S,configurable:!0}),S.displayName=d(v,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===S||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,d(t,u,"GeneratorFunction")),t.prototype=Object.create(A),t},e.awrap=function(t){return{__await:t}},w(T.prototype),d(T.prototype,c,(function(){return this})),e.AsyncIterator=T,e.async=function(t,a,n,s,i){void 0===i&&(i=Promise);var o=new T(g(t,a,n,s),i);return e.isGeneratorFunction(a)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},w(A),d(A,u,"Generator"),d(A,l,(function(){return this})),d(A,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),a=[];for(var n in e)a.push(n);return a.reverse(),function t(){for(;a.length;){var n=a.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=_,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(P),!t)for(var e in this)"t"===e.charAt(0)&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function a(a,n){return o.type="throw",o.arg=t,e.next=a,n&&(e.method="next",e.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var s=this.tryEntries[n],o=s.completion;if("root"===s.tryLoc)return a("end");if(s.tryLoc<=this.prev){var r=i.call(s,"catchLoc"),l=i.call(s,"finallyLoc");if(r&&l){if(this.prev<s.catchLoc)return a(s.catchLoc,!0);if(this.prev<s.finallyLoc)return a(s.finallyLoc)}else if(r){if(this.prev<s.catchLoc)return a(s.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return a(s.finallyLoc)}}}},abrupt:function(t,e){for(var a=this.tryEntries.length-1;a>=0;--a){var n=this.tryEntries[a];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var s=n;break}}s&&("break"===t||"continue"===t)&&s.tryLoc<=e&&e<=s.finallyLoc&&(s=null);var o=s?s.completion:{};return o.type=t,o.arg=e,s?(this.method="next",this.next=s.finallyLoc,h):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var a=this.tryEntries[e];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),P(a),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var a=this.tryEntries[e];if(a.tryLoc===t){var n=a.completion;if("throw"===n.type){var s=n.arg;P(a)}return s}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,a){return this.delegate={iterator:_(t),resultName:e,nextLoc:a},"next"===this.method&&(this.arg=void 0),h}},e}t.exports=s,t.exports.__esModule=!0,t.exports.default=t.exports},4319:t=>{function e(a){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(a)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},5799:(t,e,a)=>{var n=a(7048)();t.exports=n;try{regeneratorRuntime=n}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}}},e={};function a(n){var s=e[n];if(void 0!==s)return s.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,a),i.exports}a.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return a.d(e,{a:e}),e},a.d=(t,e)=>{for(var n in e)a.o(e,n)&&!a.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),a.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";a.r(n),a.d(n,{AdminPortal:()=>lg,AdminPortalRenderer:()=>dg,AppHolder:()=>c,CheckoutDialog:()=>cg,FronteggApp:()=>og,HostedLogin:()=>rg,LoginBoxRenderer:()=>hg,createElement:()=>Zd,defaultTheme:()=>gg,formatName:()=>Qd,getOverriddenMetadata:()=>ig,getThemeAdminByName:()=>ug,getThemeByName:()=>pg,initialize:()=>bg,mockFlagsList:()=>ng,restoreSearchParams:()=>eg,waitThemeSetter:()=>tg});var t={};a.r(t),a.d(t,{ApplicationAccessType:()=>Ja,AuthStrategyEnum:()=>N,ContextHolder:()=>U,DirectoryApi:()=>ca,FRONTEGG_SEPARATE_TABS_BY_TENANT:()=>ae,FeatureFlags:()=>Zt,FeatureFlagsApi:()=>te,FetchClient:()=>Gt,FronteggApiError:()=>W,FronteggContext:()=>L,FronteggFrameworks:()=>xt,GENERIC_ERROR_CODE:()=>Nt,GENERIC_ERROR_MESSAGE:()=>Dt,GetUsersFilterPreset:()=>ja,GroupManagedByEnum:()=>$a,GroupRelations:()=>xa,ISubscriptionCancellationPolicy:()=>G,ISubscriptionStatus:()=>x,InsightCode:()=>Ha,LOAD_AUTHORIZATION_FF:()=>Yt,MFAStrategyEnum:()=>Jt,MachineToMachineAuthStrategy:()=>M,NotEntitledJustification:()=>Va,PaginationOrderEnum:()=>$t,PaymentMethodType:()=>$,PermissionAssignmentTypeEnum:()=>ka,ProviderType:()=>j,RecommendationActionKey:()=>za,RecommendationCode:()=>Wa,RecommendationSeverity:()=>Ka,RequestSource:()=>Ft,RestrictionType:()=>zt,ScimConnectionSource:()=>Fa,SecondaryAuthStrategy:()=>Kt,SecurityCategory:()=>qa,SignUpStrategyEnum:()=>F,SocialLoginProviders:()=>D,SortByEnum:()=>Ga,SubAccountAccessTypeEnum:()=>_a,TenantSortByEnum:()=>Oa,TenantType:()=>Pa,UserManagedByEnum:()=>Ia,WebAuthnDeviceType:()=>qt,api:()=>Ya,createApiClient:()=>Xa,default:()=>Qa,fetch:()=>jt,fronteggAuthApiRoutesRegex:()=>Ra,fronteggEntitlementsV2Url:()=>Ma,fronteggHeaders:()=>Mt,fronteggRefreshTokenUrl:()=>Ua,fronteggSilentRefreshTokenUrl:()=>Ca,fronteggTenantsUrl:()=>Da,fronteggTenantsV3Url:()=>Na,fronteggUsersUrl:()=>La,getCurrentUserTenantsFunction:()=>ce,getTabTenantFromSessionStorage:()=>le,providersArray:()=>Ba,removeTabTenantFromSessionStorage:()=>re,setTabTenantInSessionStorage:()=>oe});var e={};a.r(e),a.d(e,{ACR_VALUE:()=>un,AMR_ADDITIONAL_VALUE:()=>gn,AMR_MFA_VALUE:()=>dn,AcceptInvitationStep:()=>an,ActivateAccountStep:()=>jn,AdminPortalPages:()=>qn,AdminPortalPagesForEvents:()=>Kn,AllAccountsStateKeys:()=>xo,ApiStateKeys:()=>Ms,AuthStrategyEnum:()=>N,AuthenticationTypes:()=>zn,DEFAULT_RETRY_CONFIG:()=>Tn,FRONTEGG_AFTER_AUTH_REDIRECT_URL:()=>An,ForgotPasswordStep:()=>zs,FronteggNativeModule:()=>S,GTMEventAction:()=>Jn,GroupRelations:()=>si,GroupsStateKeys:()=>ni,HOSTED_LOGIN_VERIFIER_KEY:()=>wn,ImpersonateStep:()=>ui,LoginActionTypes:()=>fn,LoginFlow:()=>Sn,LoginStep:()=>yn,MFAStep:()=>Yn,MachineToMachineAuthStrategy:()=>M,PasswordRotationStep:()=>Xs,PaymentMethodType:()=>nc,PaymentProvider:()=>oc,QuickLoginStrategy:()=>vn,REQUEST_NAME:()=>Wn,ResetPhoneNumberStep:()=>ir,RolesStateKeys:()=>hr,SHOULD_STEP_UP_KEY:()=>pn,SSOStateKeys:()=>so,STEP_UP_MAX_AGE_PARAM_NAME:()=>hn,SamlVendors:()=>io,SecurityCenterStateKeys:()=>Ur,SignUpStage:()=>Jr,SubscriptionCancellationPolicy:()=>lc,SubscriptionStatus:()=>rc,TENANT_ID_PARAM_KEY:()=>ns,TeamStateKeys:()=>ws,UserVerifiedOriginTypes:()=>Hn,authStrategyLoginStepMap:()=>mn,base64ToFormData:()=>Pi,base64urlDecode:()=>Oi,base64urlEncode:()=>Ii,buildAuditsActions:()=>Jc,buildAuthActions:()=>Jl,buildConnectivityActions:()=>ac,buildSubscriptionsActions:()=>xc,buildVendorActions:()=>jc,createAuditsState:()=>qc,createAuthState:()=>ql,createConnectivityState:()=>Xl,createFronteggStore:()=>Td,createProxy:()=>en,createRandomString:()=>Ji,createStore:()=>Ed,createSubscriptionsState:()=>Fc,createVendorState:()=>Gc,deepClone:()=>Un,deepResetState:()=>Cn,defaultFronteggRoutes:()=>bn,delay:()=>En,errorHandler:()=>Nn,errorTraceId:()=>kn,generateCodeChallenge:()=>qi,generateCodeChallengeNative:()=>Ki,generateCodeChallengePureJs:()=>zi,getBaseNameWithoutSlashSuffix:()=>cs,getEntitlements:()=>ao,getFeatureEntitlements:()=>eo,getMfaStepForEnrolledUsers:()=>is,getMfaStepForNotEnrolledUsers:()=>os,getNumberOfMfaDevices:()=>ss,getPathAndSearchParamsFromUrl:()=>es,getPermissionEntitlements:()=>to,getRedirectUrl:()=>Zn,getSearchParam:()=>as,getSearchParamsFromUrl:()=>ts,getUri:()=>ms,hmac:()=>Hi,isAbsoluteUrl:()=>Qn,isAuthRoute:()=>As,isEmailPayload:()=>ls,isEntitlementsDeeplyEqual:()=>no,isError:()=>Dn,isFronteggApiError:()=>Ln,isMfaRequired:()=>Ss,isOauthCallbackRoute:()=>rs,isProxy:()=>Rn,isResetPasswordRequired:()=>vs,isSteppedUp:()=>ds,mapMetaDataObjectToActions:()=>fs,omitProps:()=>_n,prepareIdentifiersForSignup:()=>bs,publicKeyCredentialToJSON:()=>ki,readFileAsText:()=>_i,redirectByStepUpUrl:()=>ps,reportGTMEvent:()=>Xn,retry:()=>In,retryIfNeeded:()=>On,setAfterAuthRedirectUrlForStepUp:()=>gs,sha256:()=>Wi,shouldShowPasswordRotationPromptFunc:()=>us,snapshot:()=>k,subscribe:()=>P,withRetryConfig:()=>Pn});var s={};function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function r(t,e){for(var a=0;a<e.length;a++){var n=e[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(s=n.key,i=void 0,i=function(t){if("object"!==o(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var a=e.call(t,"string");if("object"!==o(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(s),"symbol"===o(i)?i:String(i)),n)}var s,i}function l(t,e,a){return e&&r(t.prototype,e),a&&r(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t}a.r(s),a.d(s,{AccountDetailsPageTabs:()=>Fd,AccountPageFields:()=>_d,DomainRestrictionsTabFields:()=>Md,GeneralSettingsTabFields:()=>Dd,InviteUserModalFields:()=>kd,IpRestrictionsTabFields:()=>Nd,Metadata:()=>Xd,PrivacyPageFields:()=>Pd,ProfilePageFields:()=>Od,SecurityPageTabs:()=>Cd,SessionManagementTabFields:()=>Ld,SignupFields:()=>Id,SubscriptionsPageFields:()=>Ud,UsersTableColumns:()=>Rd,alpha:()=>Wd,fieldAppearance:()=>xd,tabAppearance:()=>$d});var c=function(){function t(){i(this,t)}return l(t,null,[{key:"setInstance",value:function(e,a){t._apps[e]=a}},{key:"getInstance",value:function(e){var a=t._apps[e];if(!a)throw Error("[".concat(e,"] FronteggApp not found"));return a}}]),t}();function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,n=new Array(e);a<e;a++)n[a]=t[a];return n}function d(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=a){var n,s,i,o,r=[],l=!0,c=!1;try{if(i=(a=a.call(t)).next,0===e){if(Object(a)!==a)return;l=!1}else for(;!(l=(n=i.call(a)).done)&&(r.push(n.value),r.length!==e);l=!0);}catch(t){c=!0,s=t}finally{try{if(!l&&null!=a.return&&(o=a.return(),Object(o)!==o))return}finally{if(c)throw s}}return r}}(t,e)||function(t,e){if(t){if("string"==typeof t)return u(t,e);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?u(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(t,e,a,n,s,i,o){try{var r=t[i](o),l=r.value}catch(t){return void a(t)}r.done?e(l):Promise.resolve(l).then(n,s)}function p(t){return function(){var e=this,a=arguments;return new Promise((function(n,s){var i=t.apply(e,a);function o(t){g(i,n,s,o,r,"next",t)}function r(t){g(i,n,s,o,r,"throw",t)}o(void 0)}))}}c._apps={};var h=a(5799),y=a.n(h);const S=new class{constructor(){this.loginWithSSO=t=>{if(this.isIOSNativeBridgeAvailable()){var e,a,n;null==(e=window.webkit)||null==(a=e.messageHandlers)||null==(n=a.FronteggNativeBridge)||n.postMessage(JSON.stringify({action:"loginWithSSO",payload:t}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithSSO(t)}},this.loginWithSocialLogin=t=>{if(this.isIOSNativeBridgeAvailable()){var e,a,n;null==(e=window.webkit)||null==(a=e.messageHandlers)||null==(n=a.FronteggNativeBridge)||n.postMessage(JSON.stringify({action:"loginWithSocialLogin",payload:t}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithSocialLogin(t)}},this.loginWithSocialLoginProvider=t=>{if(this.isIOSNativeBridgeAvailable()){var e,a,n;null==(e=window.webkit)||null==(a=e.messageHandlers)||null==(n=a.FronteggNativeBridge)||n.postMessage(JSON.stringify({action:"loginWithSocialLoginProvider",payload:t}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithSocialLoginProvider(t)}},this.loginWithCustomSocialLoginProvider=t=>{if(this.isIOSNativeBridgeAvailable()){var e,a,n;null==(e=window.webkit)||null==(a=e.messageHandlers)||null==(n=a.FronteggNativeBridge)||n.postMessage(JSON.stringify({action:"loginWithCustomSocialLoginProvider",payload:t}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var s;null==(s=window.FronteggNativeBridge)||s.loginWithCustomSocialLoginProvider(t)}},this.suggestSavePassword=(t,e)=>{if(this.isIOSNativeBridgeAvailable()){var a,n,s;null==(a=window.webkit)||null==(n=a.messageHandlers)||null==(s=n.FronteggNativeBridge)||s.postMessage(JSON.stringify({action:"suggestSavePassword",payload:JSON.stringify({email:t,password:e})}))}else{if(!this.isAndroidNativeBridgeAvailable())throw new Error("FronteggNativeBridge is not available");var i;null==(i=window.FronteggNativeBridge)||i.suggestSavePassword(t,e)}},this.promptSocialLoginConsent=()=>{var t,e;return null!=(t=null==(e=window.FronteggNativeBridgeFunctions)?void 0:e.shouldPromptSocialLoginConsent)&&t}}isIOSNativeBridgeAvailable(){var t,e;return null!=(null==(t=window.webkit)||null==(e=t.messageHandlers)?void 0:e.FronteggNativeBridge)}isAndroidNativeBridgeAvailable(){return null!=window.FronteggNativeBridge}isSocialLoginAvailable(){return this.isAvailable("loginWithSocialLogin")}isSocialLoginProviderAvailable(){return this.isAvailable("loginWithSocialLoginProvider")}isCustomSocialLoginProviderAvailable(){return this.isAvailable("loginWithCustomSocialLoginProvider")}isLoginWithSSOAvailable(){return this.isAvailable("loginWithSSO")}isSuggestSavePasswordAvailable(){return this.isAvailable("suggestSavePassword")}isAvailable(t){var e,a;return!(!this.isIOSNativeBridgeAvailable()&&!this.isAndroidNativeBridgeAvailable())&&null!=(e=null==(a=window.FronteggNativeBridgeFunctions)?void 0:a[t])&&e}};function v(){return v=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},v.apply(this,arguments)}function f(t,e){if(null==t)return{};var a,n,s={},i=Object.keys(t);for(n=0;n<i.length;n++)a=i[n],e.indexOf(a)>=0||(s[a]=t[a]);return s}Symbol();const m=Symbol(),b=Object.getPrototypeOf,A=new WeakMap,w=(t,e=!0)=>{A.set(t,e)},T=t=>"object"==typeof t&&null!==t,E=new WeakMap,I=new WeakSet;const[O]=function(t=Object.is,e=(t,e)=>new Proxy(t,e),a=t=>T(t)&&!I.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer),n=t=>{switch(t.status){case"fulfilled":return t.value;case"rejected":throw t.reason;default:throw t}},s=new WeakMap,i=(t,e,a=n)=>{const o=s.get(t);if((null==o?void 0:o[0])===e)return o[1];const r=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return w(r,!0),s.set(t,[e,r]),Reflect.ownKeys(t).forEach((e=>{if(Object.getOwnPropertyDescriptor(r,e))return;const n=Reflect.get(t,e),{enumerable:s}=Reflect.getOwnPropertyDescriptor(t,e),o={value:n,enumerable:s,configurable:!0};if(I.has(n))w(n,!1);else if(n instanceof Promise)delete o.value,o.get=()=>a(n);else if(E.has(n)){const[t,e]=E.get(n);o.value=i(t,e(),a)}Object.defineProperty(r,e,o)})),Object.preventExtensions(r)},o=new WeakMap,r=[1,1],l=n=>{if(!T(n))throw new Error("object required");const s=o.get(n);if(s)return s;let c=r[0];const u=new Set,d=(t,e=++r[0])=>{c!==e&&(c=e,u.forEach((a=>a(t,e))))};let g=r[1];const p=t=>(e,a)=>{const n=[...e];n[1]=[t,...n[1]],d(n,a)},h=new Map,y=t=>{const e=h.get(t);var a;e&&(h.delete(t),null==(a=e[1])||a.call(e))},S=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n)),v=e(S,{deleteProperty(t,e){const a=Reflect.get(t,e);y(e);const n=Reflect.deleteProperty(t,e);return n&&d(["delete",[e],a]),n},set(e,n,s,i){const r=Reflect.has(e,n),c=Reflect.get(e,n,i);if(r&&(t(c,s)||o.has(s)&&t(c,o.get(s))))return!0;var g;y(n),T(s)&&(s=(t=>t&&(A.has(t)?A.get(t):b(t)===Object.prototype||b(t)===Array.prototype))(g=s)&&g[m]||s);let S=s;if(s instanceof Promise)s.then((t=>{s.status="fulfilled",s.value=t,d(["resolve",[n],t])})).catch((t=>{s.status="rejected",s.reason=t,d(["reject",[n],t])}));else{!E.has(s)&&a(s)&&(S=l(s));const t=!I.has(S)&&E.get(S);t&&((t,e)=>{if(u.size){const a=e[3](p(t));h.set(t,[e,a])}else h.set(t,[e])})(n,t)}return Reflect.set(e,n,S,i),d(["set",[n],s,c]),!0}});o.set(n,v);const f=[S,(t=++r[1])=>(g===t||u.size||(g=t,h.forEach((([e])=>{const a=e[1](t);a>c&&(c=a)}))),c),i,t=>(u.add(t),1===u.size&&h.forEach((([t,e],a)=>{const n=t[3](p(a));h.set(a,[t,n])})),()=>{u.delete(t),0===u.size&&h.forEach((([t,e],a)=>{e&&(e(),h.set(a,[t]))}))})];return E.set(v,f),Reflect.ownKeys(n).forEach((t=>{const e=Object.getOwnPropertyDescriptor(n,t);"value"in e&&(v[t]=n[t],delete e.value,delete e.writable),Object.defineProperty(S,t,e)})),v}){return[l,E,I,t,e,a,n,s,i,o,r]}();function P(t,e,a){const n=E.get(t);let s;const i=[],o=n[3];let r=!1;const l=o((t=>{i.push(t),a?e(i.splice(0)):s||(s=Promise.resolve().then((()=>{s=void 0,r&&e(i.splice(0))})))}));return r=!0,()=>{r=!1,l()}}function k(t,e){const a=E.get(t),[n,s,i]=a;return i(n,s(),e)}const _=["enabled","name"],R=Symbol();class U{constructor(){this.context=null,this.accessToken=null,this.user=null,this.requestSource=null,this.onRedirectTo=t=>window.location.href=t,this.logout=()=>window.location.href="/account/logout",this.entitlementsOptions=null,this.appName=null,this.sessionContext=void 0,this.basename=null,this.cdnUrl=null,this.assetsUrl=null,this.setContext=t=>{this.context=t},this.setAccessToken=t=>{this.accessToken=t},this.setUser=t=>{this.user=t},this.setRequestSource=t=>{this.requestSource=t},this.setOnRedirectTo=t=>{this.onRedirectTo=t},this.setLogout=t=>{this.logout=t},this.setEntitlementsOptions=t=>{this.entitlementsOptions=t},this.setSessionContext=t=>{this.sessionContext=t},this.setAppName=t=>{this.appName=t},this.getContext=()=>{var t;return null!=(t=this.context)?t:{baseUrl:window.location.href,tokenResolver:()=>"my-authentication-token",logLevel:"error"}},this.getAccessToken=()=>this.accessToken,this.getRequestSource=()=>this.requestSource,this.getUser=()=>this.user,this.shouldLoadEntitlements=()=>{var t;return(null==(t=this.entitlementsOptions)?void 0:t.enabled)||!1},this.isSessionPerTenantEnabled=()=>{var t;return(null==(t=this.sessionContext)?void 0:t.enableSessionPerTenant)||!1},this.shouldSkipUserLoad=()=>{var t;return(null==(t=this.sessionContext)?void 0:t.skipUserLoading)||!1},this.getAppName=()=>this.appName,this.setCdnUrl=t=>{this.cdnUrl=t},this.getCdnUrl=()=>this.cdnUrl,this.setAssetsUrl=t=>{this.assetsUrl=t},this.getAssetsUrl=()=>this.assetsUrl}static default(){return U.getInstance(C)}static for(t){return U.getInstance(t)}static getInstance(t="default"){return U._apps||(U._apps={}),U._apps[t]||(U._apps[t]=new U),U._apps[t]}static createInstance(t="default"){return U._apps[t]=new U,U._apps[t].appName=t,U._apps[t]}static setContext(t,e="default"){U.for(e).context=t}static setAccessToken(t,e=C){U.for(e).accessToken=t}static setUser(t,e="default"){U.for(e).user=t}static setRequestSource(t,e="default"){U.for(e).requestSource=t}static setOnRedirectTo(t,e="default"){U.for(e).onRedirectTo=t}static setLogout(t,e,a="default"){const n=U.for(a);n.logout=a=>{a?t(a):n.onRedirectTo(e,void 0)}}static setEntitlementsOptions(t,e="default"){U.for(e).entitlementsOptions=t}static setSessionContext(t,e="default"){U.for(e).sessionContext=t}static setAppName(t){U.for(t).appName=t}static getContext(t="default"){var e;return null!=(e=U.for(t).context)?e:{baseUrl:window.location.href,tokenResolver:()=>"my-authentication-token",logLevel:"error"}}static getAccessToken(t="default"){return U.for(t).accessToken}static getRequestSource(t="default"){return U.for(t).requestSource}static getBasename(t="default"){return U.for(t).basename}getBasename(){return this.basename}static setBasename(t,e=C){U.for(e).basename=t}setBasename(t){this.basename=t}static getUser(t="default"){return U.for(t).user}static onRedirectTo(t,e,a="default"){return U.for(a).onRedirectTo(t,e)}static logout(t,e="default"){return U.for(e).logout(t)}static shouldLoadEntitlements(t="default"){var e;return(null==(e=U.for(t).entitlementsOptions)?void 0:e.enabled)||!1}static isSessionPerTenantEnabled(t="default"){var e;return(null==(e=U.for(t).sessionContext)?void 0:e.enableSessionPerTenant)||!1}static getAppName(t="default"){return U.for(t).appName}}U._apps=void 0;const C="default",L={getContext:()=>U.getContext(C),getAccessToken:()=>U.getAccessToken(C),setAccessToken:t=>U.setAccessToken(t,C),getUser:()=>U.getUser(C),setUser:t=>U.setUser(t,C),onRedirectTo:(t,e)=>U.onRedirectTo(t,e,C),setOnRedirectTo:t=>U.setOnRedirectTo(t,C),logout:t=>U.logout(t,C),getRequestSource:()=>U.getRequestSource(C),setRequestSource:t=>U.setRequestSource(t,C),isSessionPerTenantEnabled:()=>U.isSessionPerTenantEnabled(C),shouldLoadEntitlements:()=>U.shouldLoadEntitlements(C),getAppName:()=>U.getAppName(C),setEntitlementsOptions:t=>U.setEntitlementsOptions(t,C),setSessionContext:t=>U.setSessionContext(t,C),getBasename:()=>U.getBasename(C),setBasename:t=>U.setBasename(t,C)};let D,N,M,F,x,$,G,j,B,V;!function(t){t.Microsoft="microsoft",t.Facebook="facebook",t.Google="google",t.Github="github",t.Slack="slack",t.Apple="apple",t.Linkedin="linkedin"}(D||(D={})),function(t){t.EmailAndPassword="EmailAndPassword",t.MagicLink="MagicLink",t.Code="Code",t.NoLocalAuthentication="NoLocalAuthentication",t.SmsCode="SmsCode"}(N||(N={})),function(t){t.ClientCredentials="ClientCredentials",t.AccessToken="AccessToken"}(M||(M={})),function(t){t.Email="email",t.PhoneNumber="phoneNumber"}(F||(F={})),function(t){t.ACTIVE="active",t.CANCELED="canceled",t.INCOMPLETE="incomplete",t.EXPIRED="expired",t.TRIALING="trialing",t.TRIAL_ENDED="trialEnded"}(x||(x={})),function(t){t.UNKNWON="unknown",t.CARD="card"}($||($={})),function(t){t.AT_PERIOD_END="atPeriodEnd"}(G||(G={})),function(t){t.Stripe="Stripe"}(j||(j={})),function(t){t.CHANGE_TO_DEFAULT="change_to_default",t.RETAIN_TRIAL="retain_trial"}(B||(B={})),function(t){t.CREATE="create_customer"}(V||(V={}));class W extends Error{constructor(t,e,a,n,s){super(t),this._statusCode=void 0,this._traceId=void 0,this._errorCode=void 0,this._errorContext=void 0,this._statusCode=e,this._traceId=a,this._errorCode=n,this._errorContext=s}get statusCode(){return this._statusCode}get traceId(){return this._traceId}get errorCode(){return this._errorCode}get errorContext(){return this._errorContext}}const H={v1:{strategies:"/identity/resources/configurations/v1/sign-up/strategies"}},z={v1:"/identity/resources/users/webauthn/v1/devices"},K={v1:"/identity/resources/auth/v1",v2:"/identity/resources/auth/v2"},q={v1:"/identity/resources/users/v1",v2:"/identity/resources/users/v2",v3:"/identity/resources/users/v3",roles:{v3:"/identity/resources/users/v3/roles"},groups:{v3:"/identity/resources/users/v3/groups"},tenants:{me:{v1:"/identity/resources/users/v1/me/tenants",v3:"/identity/resources/users/v3/me/tenants"}},apiTokens:{v1:"/identity/resources/users/api-tokens/v1"},accessTokens:{v1:"/identity/resources/users/access-tokens/v1"},sessions:{v1:"/identity/resources/users/sessions/v1",currentUser:{v1:"/identity/resources/users/sessions/v1/me"},configurations:{v1:"/identity/resources/configurations/sessions/v1"}},invitation:{resendAll:{v1:"/identity/resources/users/v1/invitation/reset/all"}},passwords:{resetBreachedPasswords:{v1:"/identity/resources/users/v1/passwords/breached/reset/bulk"}},authorization:{v1:"/identity/resources/users/v1/me/authorization"},temporary:{v1:"/identity/resources/users/temporary/v1",configuration:{v1:"/identity/resources/users/temporary/v1/configuration"}}},J={v1:"/identity/resources/configurations/v1"},Y={emailDomain:{v1:"/identity/resources/configurations/restrictions/v1/email-domain"},ip:{v1:"/identity/resources/configurations/v1/restrictions/ip"}},X={v1:"/identity/resources/sso/v1",v2:"/identity/resources/sso/v2",custom:{v1:"/identity/resources/sso/custom/v1"}},Q={v1:"/identity/resources/permissions/v1"},Z={apiTokens:{v1:"/identity/resources/tenants/api-tokens/v1",v2:"/identity/resources/tenants/api-tokens/v2"},accessTokens:{v1:"/identity/resources/tenants/access-tokens/v1"},invites:{user:{v1:"/identity/resources/tenants/invites/v1/user"},verify:{v1:"/identity/resources/tenants/invites/v1/verify"},configuration:{v1:"/identity/resources/tenants/invites/v1/configuration"}},users:{v1:"/identity/resources/tenants/users/v1"}},tt={v1:"/identity/resources/roles/v1",v2:"/identity/resources/roles/v2"},et={v1:"/identity/resources/sub-tenants/users/v1",v2:"/identity/resources/sub-tenants/users/v2"},at={v1:"/identity/resources/impersonation/v1"},nt={v1:"/identity/resources/applications/v1"},st={v1:"/identity/resources/groups/v1",configurations:{v1:"/identity/resources/groups/v1/config"},getByIds:{v1:"/identity/resources/groups/v1/bulkGet"}},it={v1:"/identity/resources/users/phone-numbers/v1"},ot={v1:"/team/resources/sso/v1",v2:"/team/resources/sso/v2"},rt={v1:"/team/resources/members/v1"},lt={v1:"/team/resources/roles/v1"},ct={v1:"/team/resources/stats/v1"},ut={v1:"/team/resources/profile"},dt={v1:"/tenants/resources/account-settings/v1"},gt={v1:"/tenants/resources/hierarchy/v1",tree:{v1:"/tenants/resources/hierarchy/v1/tree"},parents:{v1:"/tenants/resources/hierarchy/v1/parents"},v2:"/tenants/resources/hierarchy/v2",metadata:{v2:"/tenants/resources/hierarchy/v2/metadata"}},pt={v1:"/tenants/resources/sub-tenants/v1"},ht={v1:"/integrations/resources/configurations/v1",v2:"/integrations/resources/configurations/v2"},yt={subscriptions:{v1:"/subscriptions/resources/billing/subscriptions/v1"},plans:{v1:"/subscriptions/resources/billing/plans/v1"},invoices:{v1:"/subscriptions/resources/billing/invoices/v1"},paymentMethods:{v1:"/subscriptions/resources/billing/payment-methods/v1"},summaries:{v1:"/subscriptions/resources/billing/summaries/v1"},tenantConfiguration:{v1:"/subscriptions/resources/billing/tenant-configurations/v1"},configurations:{vendorPublicConfigurations:{v1:"/subscriptions/resources/billing/configurations/vendor-public-configurations/v1"}},paymentProviders:{stripe:{customers:{v1:"/subscriptions/resources/billing/payment-providers/stripe/customers/v1"},publicConfigurations:{v1:"/subscriptions/resources/billing/payment-providers/stripe/public-configurations/v1"},subscriptions:{v1:"/subscriptions/resources/billing/payment-providers/stripe/subscriptions/v1"},setupIntents:{v1:"/subscriptions/resources/billing/payment-providers/stripe/setup-intents/v1"}}}},St={v1:"/subscriptions/resources/payment-providers/v1"},vt={v1:"/subscriptions/resources/subscriptions/v1"},ft={v1:"/reports/resources/reports/v1",v2:"/reports/resources/reports/v2"},mt={v1:"/reports/engine/resources/triggers/v1"},bt="/notification",At="/audits",wt={v1:"/event/resources/configurations/v1"},Tt="/webhook",Et="/oauth",It="/flags",Ot="/directory/resources/v1/configurations/scim2",Pt="/directory/resources/scim/temp",kt="/entitlements/api/v2/user-entitlements",_t={v1:"/security-center/resources/recommendations/v1"},Rt={v1:"/security-center/resources/insights/v1"},Ut="/applications/resources/applications/v1",Ct={v1:"/applications/resources/applications/tenant-assignments/v1"},Lt="http://localhost:3037/resources/velo/v1",Dt="We're facing some difficulties, Please try again",Nt="ER-ADMIN-PORTAL-GENERIC-ERROR",Mt={frameWork:"x-frontegg-framework",fronteggSdkVersion:"x-frontegg-sdk",contentType:"Content-Type",source:"frontegg-source",scopedTenant:"frontegg-scoped-tenant"};let Ft,xt,$t;!function(t){t.AdminPortal="admin-portal",t.LoginBox="login-box"}(Ft||(Ft={})),function(t){t.Nextjs="nextjs",t.React="react",t.Angular="angular",t.Vuejs="vuejs",t.Flutter="flutter",t.Ios="ios",t.Android="android",t.Vanillajs="vanillajs"}(xt||(xt={})),function(t){t.ASC="ASC",t.DESC="DESC"}($t||($t={}));class Gt{constructor(t){this.appName=void 0,this.getFronteggContext=()=>U.for(this.appName),this.prepareUrl=async(t,e)=>{const a=this.getFronteggContext().getContext(),n=this.getContextBaseUrl(t),s=await this.buildQueryParams(a,e);let i=t.startsWith("http")?t:`${n}${t}`;const o=Object.keys(s).length>0;return s&&o&&(i+=`?${new URLSearchParams(s)}`),i},this.buildQueryParams=async(t,e)=>{e||(e={});const a=await this.getAdditionalQueryParams(t);for(const t of a)e[t.key]=t.value;const n=Object.keys(e);for(const t of n){const a=e[t];e[t]="object"==typeof a?JSON.stringify(a):a}return e},this.getAdditionalQueryParams=async t=>{let e=[];return t.additionalQueryParamsResolver&&(e=await t.additionalQueryParamsResolver()),e},this.getAdditionalHeaders=async t=>{let e=[];if(t.additionalHeadersResolver&&(e=await t.additionalHeadersResolver()),t.tenantResolver){const a=await t.tenantResolver();null!=a&&a.tenant&&e.push({key:"frontegg-login-alias",value:a.tenant})}return t.appId&&e.push({key:"frontegg-requested-application-id",value:t.appId}),e},this.buildRequestHeaders=async t=>{var e;const a=this.getFronteggContext(),n=a.getContext(),s=Gt.getMetadataHeaders(n),i=await(null!=(e=null==n?void 0:n.tokenResolver)?e:a.getAccessToken)(),o=a.getRequestSource(),r=Gt.getScopedTenant();t&&(s[Mt.contentType]=t),o&&(s[Mt.source]=o),i&&(s.Authorization=`Bearer ${i}`),r&&(s[Mt.scopedTenant]=r);for(const t of await this.getAdditionalHeaders(n))s[`${t.key}`]=`${t.value}`;return s},this.getResponseTraceId=t=>{var e,a;return null==t||null==(e=t.headers)||null==(a=e.get)?void 0:a.call(e,"frontegg-trace-id")},this.sendRequest=async t=>{var e,a,n;const s=this.getFronteggContext().getContext(),i=await this.buildRequestHeaders(t.contentType),o=await this.prepareUrl(t.url,t.params),r=s.beforeRequestInterceptor,l={body:t.body?"application/json"===t.contentType?JSON.stringify(t.body):t.body:null,method:null!=(e=t.method)?e:"GET",headers:v({},i,t.headers),credentials:null!=(a=null!=(n=t.credentials)?n:s.requestCredentials)?a:"same-origin"},c=r?r(l,o):l,u=await fetch(o,c);if(302===u.status)return window.location.href=await u.text(),new Promise((()=>{}));if(!u.ok){var d,g,p,h,y;if(413===u.status)throw new W("Error request is too large",u.status,this.getResponseTraceId(u),void 0);let t,e,a,n=!0;try{t=await u.text(),t=JSON.parse(t)}catch(t){n=!1}throw null!=(d=t)&&d.errorCode&&(e=t.errorCode),null!=(g=t)&&g.context&&"object"==typeof t.context&&(a=t.context),t.errors?t=t.errors.join(", "):"string"!=typeof t&&(t=`Error ${u.status} - ${u.statusText}`),u.status>=400&&u.status<500&&["warn"].includes(null!=(p=s.logLevel)?p:"")?console.warn(t):500===u.status&&["warn","error"].includes(null!=(h=s.logLevel)?h:"")&&console.error(t),new W(n?t:Dt,u.status,this.getResponseTraceId(u),null!=(y=e)?y:Nt,a)}if("stream"===t.responseType)return u.body;if(t.responseType&&"json"!==t.responseType){if("blob"===t.responseType){const{outputFileName:e}=t.params;return await u.blob().then((t=>URL.createObjectURL(t))).then((t=>{const a=document.createElement("a");a.href=t,a.setAttribute("download",e||"output"),a.click()}))}return await u.text()}try{return await u.json()}catch(t){return{}}},this.get=async(t,e,a)=>this.sendRequest(v({url:t,method:"GET",contentType:"application/json",params:e},a)),this.post=async(t,e,a)=>this.sendRequest(v({url:t,method:"POST",contentType:"application/json",body:e},a)),this.patch=async(t,e,a)=>this.sendRequest(v({url:t,method:"PATCH",contentType:"application/json",body:e},a)),this.put=async(t,e,a)=>this.sendRequest(v({url:t,method:"PUT",contentType:"application/json",body:e},a)),this.delete=async(t,e,a)=>this.sendRequest(v({url:t,method:"DELETE",contentType:"application/json",body:e},a)),this.postDownload=async(t,e,a,n)=>this.sendRequest(v({url:t,method:"POST",contentType:"application/json",responseType:"blob",body:e,params:a},n)),this.extractHeadersFromOptions=(t={})=>v({},t.jwt?{Authorization:t.jwt}:{}),this.getBaseUrl=(t,e,a=!0)=>Gt.getBaseUrl(t,e,a),this.getContextBaseUrl=(t,e=!0)=>{const a=this.getFronteggContext().getContext();return this.getBaseUrl(a,t,e)},this.getMetadataHeaders=t=>Gt.getMetadataHeaders(t),this.getContextMetadataHeaders=()=>{const t=this.getFronteggContext().getContext();return Gt.getMetadataHeaders(t)},this.appName=t}}Gt.getBaseUrl=(t,e,a=!0)=>{let n;n="function"==typeof t.baseUrl?t.baseUrl(e):t.baseUrl;const s=t.urlPrefix||"frontegg",i="frontegg"===s&&!a;return n.endsWith("/")||(n+="/"),n.endsWith(s)||i||(n+=s),n},Gt.getMetadataHeaders=t=>{var e,a;const n={};return null!=t&&null!=(e=t.metadataHeaders)&&e.fronteggSdkVersion&&(n[Mt.fronteggSdkVersion]=t.metadataHeaders.fronteggSdkVersion),null!=t&&null!=(a=t.metadataHeaders)&&a.framework&&(n[Mt.frameWork]=t.metadataHeaders.framework),n},Gt.getScopedTenant=()=>new URLSearchParams(window.location.search).get("tenantId")||null;const jt=new Gt("default");class Bt extends Error{constructor(t){super(t)}}const Vt="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){const e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Bt("'atob' failed: The string to be decoded is not correctly encoded.");let a="";for(let t,n,s=0,i=0;n=e.charAt(i++);~n&&(t=s%4?64*t+n:n,s++%4)?a+=String.fromCharCode(255&t>>(-2*s&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};class Wt extends Error{constructor(t){super(t)}}const Ht=(t,e={})=>{const a=e.header?0:1;try{return JSON.parse((t=>{let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("Illegal base64url string!")}try{return function(t){return decodeURIComponent(Vt(t).replace(/(.)/g,((t,e)=>{let a=e.charCodeAt(0).toString(16).toUpperCase();return a.length<2&&(a="0"+a),"%"+a})))}(e)}catch(t){return Vt(e)}})(t.split(".")[a]))}catch(t){throw new Wt("Invalid token specified: "+t.message)}};let zt,Kt,qt,Jt;!function(t){t.ALLOW="ALLOW",t.BLOCK="BLOCK"}(zt||(zt={})),function(t){t.WebAuthnPlatform="WebAuthnPlatform",t.WebAuthnCrossPlatform="WebAuthnCrossPlatform",t.SmsCode="SmsCode",t.SmsCodeV2="SmsCodeV2",t.Passkeys="Passkeys"}(Kt||(Kt={})),function(t){t.Platform="Platform",t.CrossPlatform="CrossPlatform"}(qt||(qt={})),function(t){t.AuthenticatorApp="AuthenticatorApp",t.WebAuthnPlatform="WebAuthnPlatform",t.WebAuthnCrossPlatform="WebAuthnCrossPlatform",t.SMS="SMS",t.EmailCode="EmailCode"}(Jt||(Jt={}));const Yt="admin_portal_should_load_authorization";class Xt{constructor(t){this.appName=void 0,this.fetchClient=void 0,this.get=async(t,e,a)=>this.fetchClient.get(t,e,a),this.post=async(t,e,a)=>this.fetchClient.post(t,e,a),this.patch=async(t,e,a)=>this.fetchClient.patch(t,e,a),this.put=async(t,e,a)=>this.fetchClient.put(t,e,a),this.delete=async(t,e,a)=>this.fetchClient.delete(t,e,a),this.postDownload=async(t,e,a,n)=>this.fetchClient.postDownload(t,e,a,n),this.extractHeadersFromOptions=(t={})=>this.fetchClient.extractHeadersFromOptions(t),this.appName=t,this.fetchClient=new Gt(t)}}const Qt={flags:{}};class Zt{constructor(){var t;this._flags={},this._flags=null!=(t=Qt.flags)?t:{}}static getInstance(t="default"){return this._instances[t]}static set(t,e="default"){const a=new Zt;return a.set(t),Zt._instances[e]=a,a}static getFeatureFlags(t,e){const a=this.getInstance(e);return t.map((t=>"on"===(null==a?void 0:a._flags[t])))}get flags(){var t;return null!=(t=this.flags)?t:{}}set(t){var e;this._flags=v({},null!=(e=null==Qt?void 0:Qt.flags)?e:{},null!=t?t:{})}}Zt._instances={};class te extends Xt{constructor(t){super(t),this.loadFeatureFlags=async()=>this.get(It)}}const ee=new te("default"),ae="FRONTEGG_SEPARATE_TABS_BY_TENANT",ne="admin_portal_use_current_user_tenants_v1_endpoint";class se extends Xt{constructor(t){super(t),this.GetUserJwt=async t=>this.post(`${q.v3}/me/token`,t),this.getUsersV2=async(t,e)=>this.get(q.v2,t,{headers:this.extractHeadersFromOptions(e)}),this.getUsersV3=async(t,e)=>this.get(q.v3,t,{headers:this.extractHeadersFromOptions(e)}),this.getUsersRoles=async(t,e)=>this.get(q.roles.v3,v({},t,{ids:t.ids.join(",")}),{headers:this.extractHeadersFromOptions(e)}),this.getUsersGroups=async(t,e)=>this.get(q.groups.v3,v({},t,{ids:t.ids.join(",")}),{headers:this.extractHeadersFromOptions(e)}),this.getCurrentUserTenantsV3=async t=>this.get(q.tenants.me.v3,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getCurrentUserTenantsV1=async t=>this.get(q.tenants.me.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.sendResetBreachedPasswordEmails=async()=>this.post(q.passwords.resetBreachedPasswords.v1),this.updateUserProfileV2=async t=>this.put(`${q.v2}/me`,t),this.unlockMe=async t=>this.post(`${q.v3}/me/unlock`,t)}}const ie=new se("default");function oe(t){t&&sessionStorage.setItem(ae,t)}function re(){sessionStorage.removeItem(ae)}function le(t){return U.for(t).isSessionPerTenantEnabled()?sessionStorage.getItem(ae):null}function ce(t){if(U.for(t).shouldSkipUserLoad())return async()=>({tenants:[],activeTenant:{}});const e=new se(t),[a]=Zt.getFeatureFlags([ne],t);return U.for(t).isSessionPerTenantEnabled()||a?e.getCurrentUserTenantsV1:e.getCurrentUserTenantsV3}class ue extends Xt{constructor(t){super(t),this.switchTenant=async t=>(U.for(this.appName).isSessionPerTenantEnabled()&&oe(t.tenantId),this.put(`${q.v1}/tenant`,t)),this.getTenants=async()=>this.get(`${q.v2}/me/tenants`),this.getSubTenants=async t=>this.get(gt.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getSubTenantsAsTree=async t=>this.get(gt.tree.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getParentTenants=async t=>this.get(gt.parents.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getParentTenantsById=async(t,e)=>this.get(`${gt.parents.v1}/${t}`,void 0,{headers:this.extractHeadersFromOptions(e)}),this.getTenantsUsersCount=async(t,e)=>this.post(`${Z.users.v1}/count`,t,{headers:this.extractHeadersFromOptions(e)}),this.searchSubTenants=async(t,e)=>this.get(gt.v2,t,{headers:this.extractHeadersFromOptions(e)}),this.getHierarchyMetadata=async(t,e)=>this.get(gt.metadata.v2,v({},t,{_tenantIds:t._tenantIds.join(",")}),{headers:this.extractHeadersFromOptions(e)})}}const de=new ue("default");class ge extends Xt{constructor(t){super(t),this.loadEntitlementsV2=async()=>this.get(kt)}}const pe=new ge("default");class he extends Xt{constructor(t){super(t),this.getGlobalSecurityPolicy=async()=>this.get(J.v1),this.getMfaPolicy=async()=>this.get(`${J.v1}/mfa-policy`),this.getVendorMfaPolicy=async()=>this.get(`${J.v1}/mfa-policy/vendor`),this.saveMfaPolicy=async t=>t.id?this.patch(`${J.v1}/mfa-policy`,t):this.post(`${J.v1}/mfa-policy`,t),this.getLockoutPolicy=async()=>this.get(`${J.v1}/lockout-policy`),this.getVendorLockoutPolicy=async()=>this.get(`${J.v1}/lockout-policy/vendor`),this.saveLockoutPolicy=async t=>t.id?this.patch(`${J.v1}/lockout-policy`,t):this.post(`${J.v1}/lockout-policy`,t),this.getCaptchaPolicy=async()=>{try{return await this.get(`${J.v1}/captcha-policy/public`)}catch{return null}},this.getPasswordHistoryPolicy=async()=>this.get(`${J.v1}/password-history-policy`),this.getVendorPasswordHistoryPolicy=async()=>this.get(`${J.v1}/password-history-policy/vendor`),this.savePasswordHistoryPolicy=async t=>t.id?this.patch(`${J.v1}/password-history-policy`,t):this.post(`${J.v1}/password-history-policy`,t),this.getPasswordRotationPolicy=async()=>{try{return await this.get(`${J.v1}/password-rotation`)}catch(t){return{}}},this.getVendorPasswordRotationPolicy=async()=>{try{return await this.get(`${J.v1}/password-rotation/vendor`)}catch(t){return{}}},this.savePasswordRotationPolicy=async t=>this.post(`${J.v1}/password-rotation`,t),this.getPasswordConfigPolicy=async()=>this.get(`${J.v1}/password`),this.getDomainRestrictions=async()=>this.get(`${Y.emailDomain.v1}`),this.getDomainRestrictionsConfig=async()=>this.get(`${Y.emailDomain.v1}/config`),this.createDomainRestriction=async t=>this.post(`${Y.emailDomain.v1}`,t),this.updateDomainRestrictionConfig=async t=>this.post(`${Y.emailDomain.v1}/config`,t),this.deleteDomainRestriction=async t=>this.delete(`${Y.emailDomain.v1}/${t}`),this.getIPRestrictions=async t=>this.get(`${Y.ip.v1}`,t),this.getIPRestrictionsConfig=async()=>this.get(`${Y.ip.v1}/config`),this.createIPRestriction=async t=>this.post(`${Y.ip.v1}`,t),this.bulkCreateIPRestriction=async t=>this.post(`${Y.ip.v1}/bulk`,t),this.updateIPRestrictionConfig=async t=>this.post(`${Y.ip.v1}/config`,t),this.deleteIPRestriction=async t=>this.delete(`${Y.ip.v1}/${t}`),this.testCurrentIp=async()=>this.post(`${Y.ip.v1}/verify`),this.testCurrentIpInAllowList=async()=>this.post(`${Y.ip.v1}/verify/allow`)}}const ye=new he("default"),Se=["type"],ve=["type"],fe=["type"];class me extends Xt{constructor(t){super(t),this.tenantsApi=new ue(this.appName),this.entitlementsApi=new ge(this.appName),this.securityPolicy=new he(this.appName),this.generateLoginResponse=async t=>{if(!t.accessToken)return t;const e=U.for(this.appName);e.setAccessToken(t.accessToken);const a=await this.getMeAndEntitlements(),n=v({},t,t.accessToken?Ht(t.accessToken):{},a);return e.setUser(n),n},this.generateLoginResponseV2=async t=>{if(!t.accessToken)return{user:t};const e=U.for(this.appName);e.setAccessToken(t.accessToken);const[a,n]=await Promise.all([this.getMeAndEntitlements(),this.tenantsApi.getTenants()]),s=v({},t,t.accessToken?Ht(t.accessToken):{},a);return e.setUser(s),{user:s,tenants:n}},this.generateLoginResponseV3=async t=>{const{accessToken:e}=t;if(!e)return{user:t};const a=U.for(this.appName);a.setAccessToken(e);const[n,s]=await Promise.all([this.getMeAndEntitlements(),ce(this.appName)()]),i=v({},t,e?Ht(e):{},n);return a.isSessionPerTenantEnabled()&&oe(i.tenantId),a.setUser(i),{user:i,tenants:s.tenants,activeTenant:s.activeTenant}},this.generateLoginResponseFromOAuthResponse=async t=>{const e=U.for(this.appName);e.setAccessToken(t.id_token);const a=await this.getMeAndEntitlements(),n=t.id_token?Ht(t.id_token):{},s=v({mfaRequired:!1,accessToken:t.id_token,refreshToken:t.refresh_token},n,a,{expiresIn:t.expires_in||300});return e.setUser(s),s},this.generateLoginResponseFromOAuthResponseV2=async t=>{const e=U.for(this.appName);e.setAccessToken(t.id_token);const[a,n]=await Promise.all([this.getMeAndEntitlements(),ce(this.appName)()]),s=t.id_token?Ht(t.id_token):{},i=v({mfaRequired:!1,accessToken:t.id_token,refreshToken:t.refresh_token},s,a,{expiresIn:t.expires_in||300});return e.isSessionPerTenantEnabled()&&oe(i.tenantId),e.setUser(i),{user:i,tenants:n.tenants,activeTenant:n.activeTenant}},this.preLogin=async t=>{try{const{address:e}=await this.post(`${K.v1}/user/saml/prelogin`,t);return e}catch{return null}},this.preLoginWithIdpType=async t=>this.post(`${K.v1}/user/saml/prelogin`,t),this.postLogin=async t=>{const e=await this.post(`${K.v1}/user/saml/postlogin`,t);return this.generateLoginResponse(e)},this.oidcPostLogin=async t=>{const e=await this.post(`${K.v1}/user/oidc/postlogin`,t);return this.generateLoginResponse(e)},this.login=async t=>{const e=await this.post(`${K.v1}/user`,t);return this.generateLoginResponse(e)},this.loginv2=async t=>{const e=await this.post(`${K.v1}/user`,t);return this.generateLoginResponseV3(e)},this.loginWithMfa=async t=>{const e=await this.post(`${K.v1}/user/mfa/verify`,t);return this.generateLoginResponse(e)},this.loginWithMfaV2=async t=>{const e=await this.post(`${K.v1}/user/mfa/verify`,t);return this.generateLoginResponseV3(e)},this.activateAccount=async t=>this.post(`${q.v1}/activate`,t),this.activateAccountV2=async t=>{const e=await this.post(`${q.v1}/activate`,t);return this.generateLoginResponseV3(e)},this.activateAccountWithOTC=async t=>{const e=await this.post(`${q.v1}/activate/code`,t);return this.generateLoginResponseV3(e)},this.getActivateAccountStrategy=async t=>this.get(`${q.v1}/activate/strategy`,t),this.resendActivationEmail=async t=>this.post(`${q.v1}/activate/reset`,t),this.resendInvitationEmail=async t=>this.post(`${q.v1}/invitation/reset`,t),this.acceptInvitation=async t=>this.post(`${q.v1}/invitation/accept`,t),this.acceptInvitationWithOTC=async t=>this.post(`${q.v1}/invitation/accept/code`,t),this.refreshToken=async()=>{const t=le(this.appName),e=await this.post(`${K.v1}/user/token/refresh`,{tenantId:t});return this.generateLoginResponse(e)},this.refreshTokenV2=async()=>{const t=le(this.appName),e=await this.post(`${K.v1}/user/token/refresh`,{tenantId:t});return this.generateLoginResponseV2(e)},this.refreshTokenV3=async()=>{const t=le(this.appName),e=await this.post(`${K.v1}/user/token/refresh`,{tenantId:t});return this.generateLoginResponseV3(e)},this.logout=async()=>this.post(`${K.v1}/logout`),this.OAuthLogout=async t=>this.get(`${Et}/logout`,t),this.forgotPassword=async t=>this.post(`${q.v1}/passwords/reset`,t),this.resetPassword=async t=>this.post(`${q.v1}/passwords/reset/verify`,t),this.loadPasswordConfig=async t=>this.get(`${q.v1}/passwords/config`,t),this.getSignUpStrategies=async()=>this.get(`${H.v1.strategies}`),this.recoverMfaToken=async t=>this.post(`${K.v1}/user/mfa/recover`,t),this.enrollMfa=async()=>this.post(`${q.v1}/mfa/enroll`),this.preEnrollMFAAuthenticatorApp=async()=>this.post(`${q.v1}/mfa/authenticator/enroll`),this.enrollMFAAuthenticatorApp=async t=>this.post(`${q.v1}/mfa/authenticator/enroll/verify`,t),this.preEnrollMFASMS=async t=>this.post(`${q.v1}/mfa/sms/enroll`,t),this.enrollMFASMS=async t=>this.post(`${q.v1}/mfa/sms/enroll/verify`,t),this.preEnrollMFAWebAuthn=async()=>this.post(`${q.v1}/mfa/webauthn/enroll`),this.enrollMFAWebAuthn=async t=>this.post(`${q.v1}/mfa/webauthn/enroll/verify`,t),this.verifyMfa=async t=>this.post(`${q.v1}/mfa/enroll/verify`,t),this.disableMfa=async t=>this.post(`${q.v1}/mfa/disable`,t),this.disableMFAAuthenticatorApp=async(t,e)=>this.post(`${q.v1}/mfa/authenticator/${t}/disable/verify`,e),this.preDisableMFASMS=async t=>this.post(`${q.v1}/mfa/sms/${t}/disable`),this.disableMFASMS=async(t,e)=>this.post(`${q.v1}/mfa/sms/${t}/disable/verify`,e),this.preDisableMFAWebAuthn=async t=>this.post(`${q.v1}/mfa/webauthn/${t}/disable`),this.disableMFAWebAuthn=async(t,e)=>this.post(`${q.v1}/mfa/webauthn/${t}/disable/verify`,e),this.getMFADevices=async()=>this.get(`${q.v1}/mfa/devices`),this.preEnrollMFAAuthenticatorAppForLogin=async t=>this.post(`${K.v1}/user/mfa/authenticator/enroll`,t),this.enrollMFAAuthenticatorAppForLogin=async t=>this.post(`${K.v1}/user/mfa/authenticator/enroll/verify`,t),this.enrollMFAAuthenticatorAppForLoginV2=async t=>{const e=await this.post(`${K.v1}/user/mfa/authenticator/enroll/verify`,t);return this.generateLoginResponseV3(e)},this.verifyMFAAuthenticatorAppForLogin=async(t,e)=>this.post(`${K.v1}/user/mfa/authenticator/${t}/verify`,e),this.preVerifyMFAEmailCode=async t=>this.post(`${K.v1}/user/mfa/emailcode`,t),this.verifyMFAEmailCode=async t=>this.post(`${K.v1}/user/mfa/emailcode/verify`,t),this.verifyMFAEmailCodeV2=async t=>{const e=await this.post(`${K.v1}/user/mfa/emailcode/verify`,t);return this.generateLoginResponseV3(e)},this.preEnrollMFASMSForLogin=async t=>this.post(`${K.v1}/user/mfa/sms/enroll`,t),this.enrollMFASMSForLogin=async t=>this.post(`${K.v1}/user/mfa/sms/enroll/verify`,t),this.enrollMFASMSForLoginV2=async t=>{const e=await this.post(`${K.v1}/user/mfa/sms/enroll/verify`,t);return this.generateLoginResponseV3(e)},this.preVerifyMFASMSForLogin=async(t,e)=>this.post(`${K.v1}/user/mfa/sms/${t}`,e),this.verifyMFASMSForLogin=async(t,e)=>this.post(`${K.v1}/user/mfa/sms/${t}/verify`,e),this.verifyMFASMSForLoginV2=async(t,e)=>{const a=await this.post(`${K.v1}/user/mfa/sms/${t}/verify`,e);return this.generateLoginResponseV3(a)},this.preEnrollMFAWebAuthnForLogin=async t=>this.post(`${K.v1}/user/mfa/webauthn/enroll`,t),this.enrollMFAWebAuthnForLogin=async t=>this.post(`${K.v1}/user/mfa/webauthn/enroll/verify`,t),this.enrollMFAWebAuthnForLoginV2=async t=>{const e=await this.post(`${K.v1}/user/mfa/webauthn/enroll/verify`,t);return this.generateLoginResponseV3(e)},this.preVerifyMFAWebAuthnForLogin=async(t,e)=>this.post(`${K.v1}/user/mfa/webauthn/${t}`,e),this.verifyMFAWebAuthnForLogin=async(t,e)=>this.post(`${K.v1}/user/mfa/webauthn/${t}/verify`,e),this.verifyMFAWebAuthnForLoginV2=async(t,e)=>{const a=await this.post(`${K.v1}/user/mfa/webauthn/${t}/verify`,e);return this.generateLoginResponseV3(a)},this.getSamlConfiguration=async()=>this.get(`${ot.v1}/saml/configurations`),this.updateSamlConfiguration=async t=>this.post(`${ot.v1}/saml/configurations`,t),this.getSamlVendorConfiguration=async()=>this.get(`${ot.v1}/saml/configurations/vendor-config`),this.updateSamlVendorMetadata=async t=>this.put(`${ot.v1}/saml/configurations/metadata`,t),this.validateSamlDomain=async()=>this.put(`${ot.v1}/saml/validations/domain`),this.getSamlRoles=async()=>this.get(`${ot.v1}/saml/configurations/roles/default`),this.getSamlRolesGroups=async()=>this.get(`${ot.v2}/saml/configurations/groups`),this.updateSamlRoles=async({roleIds:t})=>this.post(`${ot.v1}/saml/configurations/roles/default`,{roleIds:t}),this.createSamlGroup=async({roleIds:t,group:e})=>this.post(`${ot.v2}/saml/configurations/groups`,{group:e,roleIds:t}),this.updateSamlGroup=async({roleIds:t,group:e,id:a})=>this.patch(`${ot.v2}/saml/configurations/groups/${a}`,{group:e,roleIds:t}),this.deleteSamlGroup=async({id:t})=>this.delete(`${ot.v2}/saml/configurations/groups/${t}`),this.getOidcConfiguration=async()=>this.get(`${ot.v1}/oidc/configurations`),this.getSSOPublicConfiguration=async()=>this.get(`${ot.v2}/configurations/public`),this.getSocialLoginProviders=async()=>this.get(X.v1),this.getSocialLoginProvidersV2=async()=>this.get(X.v2),this.getSocialLoginProvidersV2ForAuthenticatedUser=async()=>this.get(`${X.v2}/authenticated`),this.getCustomSocialLoginProvidersV1=async()=>this.get(X.custom.v1),this.loginViaSocialLogin=async t=>{const e={};return t.code&&(e.code=t.code),t.idToken&&(e.id_token=t.idToken),t.redirectUri&&(e.redirectUri=t.redirectUri),t.codeVerifier&&(e.code_verifier=t.codeVerifier),t.codeVerifierPkce&&(e.code_verifier_pkce=t.codeVerifierPkce),t.state&&(e.state=t.state),this.post(`${K.v1}/user/sso/${t.provider}/postlogin`,{metadata:t.metadata,invitationToken:t.invitationToken},{params:e})},this.getVendorConfig=async()=>this.get(`${J.v1}/public`),this.signUpUser=async t=>{const{shouldActivate:e,authResponse:a,userId:n,tenantId:s,activationToken:i}=await this.post(`${q.v1}/signUp`,t),o={shouldActivate:e,userId:n,tenantId:s};if(!e&&a){const{user:t,tenants:e,activeTenant:n}=await this.generateLoginResponseV3(a);return v({},o,{user:t,tenants:e,activeTenant:n})}return v({},o,{activationToken:i})},this.signUpUserWithPhoneNumber=async t=>{const{shouldActivate:e,authResponse:a,userId:n,tenantId:s,activationToken:i}=await this.post(`${q.v1}/signUp/phoneNumber`,t),o={shouldActivate:e,userId:n,tenantId:s};if(!e&&a){const{user:t,tenants:e,activeTenant:n}=await this.generateLoginResponseV3(a);return v({},o,{user:t,tenants:e,activeTenant:n})}return v({},o,{activationToken:i})},this.getCurrentUserSessions=async()=>this.get(q.sessions.currentUser.v1),this.getCurrentUserSession=async()=>this.get(`${q.sessions.currentUser.v1}/current`),this.revokeSessionsForUser=async t=>this.post(`${q.sessions.v1}/revoke`,{userId:t}),this.getSessionConfigurations=async()=>this.get(q.sessions.configurations.v1),this.createOrUpdateSessionConfigrations=async t=>{await this.post(q.sessions.configurations.v1,t)},this.deleteSessionForUser=async t=>{await this.delete(`${q.sessions.currentUser.v1}/${t}`)},this.deleteAllSessionsForUser=async()=>{await this.delete(`${q.sessions.currentUser.v1}/all`)},this.getUserAccessTokensData=async()=>this.get(q.accessTokens.v1),this.getTenantAccessTokensData=async()=>this.get(Z.accessTokens.v1),this.deleteTenantAccessToken=async({id:t})=>{await this.delete(`${Z.accessTokens.v1}/${t}`)},this.deleteUserAccessToken=async({id:t})=>{await this.delete(`${q.accessTokens.v1}/${t}`)},this.createUserAccessToken=async t=>this.post(q.accessTokens.v1,t),this.createTenantAccessToken=async t=>this.post(Z.accessTokens.v1,t),this.getUserApiTokensData=async()=>this.get(q.apiTokens.v1),this.getTenantApiTokensData=async()=>this.get(Z.apiTokens.v1),this.updateUserApiTokensData=async t=>this.post(q.apiTokens.v1,t),this.updateTenantApiTokensData=async t=>this.post(Z.apiTokens.v2,t),this.deleteTenantApiToken=async({tokenId:t})=>{await this.delete(`${Z.apiTokens.v1}/${t}`)},this.deleteUserApiToken=async({tokenId:t})=>{await this.delete(`${q.apiTokens.v1}/${t}`)},this.getUserById=async({userId:t})=>this.get(`${q.v1}/${t}`),this.checkIfAllowToRememberMfaDevice=async t=>this.get(`${J.v1}/mfa-policy/allow-remember-device`,{mfaToken:t}),this.passwordlessPreLogin=async t=>{let{type:e}=t,a=f(t,Se);return this.post(`${K.v1}/passwordless/${e.toLocaleLowerCase()}/prelogin`,a)},this.passwordlessPostLoginV2=async t=>{let{type:e}=t,a=f(t,ve);const n=await this.post(`${K.v1}/passwordless/${e.toLocaleLowerCase()}/postlogin`,a);return this.generateLoginResponseV3(n)},this.passwordlessPostLogin=async t=>{let{type:e}=t,a=f(t,fe);return this.post(`${K.v1}/passwordless/${e.toLocaleLowerCase()}/postlogin`,a)},this.verifyInviteToken=async({token:t})=>this.post(Z.invites.verify.v1,{token:t}),this.getSSOConfigurations=async()=>this.get(`${ot.v1}/configurations`),this.createSSOConfiguration=async t=>this.post(`${ot.v1}/configurations`,t),this.updateSSOConfiguration=async(t,e)=>this.patch(`${ot.v1}/configurations/${t}`,e),this.deleteSSOConfiguration=async t=>{await this.delete(`${ot.v1}/configurations/${t}`)},this.createSSOConfigurationByMetadata=async t=>this.post(`${ot.v1}/configurations/metadata`,t),this.updateSSOConfigurationByMetadata=async(t,e)=>this.put(`${ot.v1}/configurations/${t}/metadata`,e),this.createSSOConfigurationByMetadataUrl=async t=>this.post(`${ot.v1}/configurations/metadata-url`,t),this.updateSSOConfigurationByMetadataUrl=async(t,e)=>this.put(`${ot.v1}/configurations/${t}/metadata-url`,e),this.createSSODomain=async(t,e)=>this.post(`${ot.v1}/configurations/${t}/domains`,e),this.deleteSSODomain=async(t,e)=>this.delete(`${ot.v1}/configurations/${t}/domains/${e}`),this.validateSSODomain=async(t,e)=>this.put(`${ot.v1}/configurations/${t}/domains/${e}/validate`),this.validateSSODomainV2=async(t,e)=>this.put(`${ot.v2}/configurations/${t}/domains/${e}/validate`),this.getSSODefaultRoles=async t=>this.get(`${ot.v1}/configurations/${t}/roles`),this.setSSODefaultRoles=async(t,e)=>this.put(`${ot.v1}/configurations/${t}/roles`,e),this.createSSOGroup=async(t,e)=>this.post(`${ot.v1}/configurations/${t}/groups`,e),this.updateSSOGroup=async(t,{roleIds:e,group:a,id:n})=>this.patch(`${ot.v1}/configurations/${t}/groups/${n}`,{group:a,roleIds:e}),this.deleteSSOGroup=async(t,e)=>this.delete(`${ot.v1}/configurations/${t}/groups/${e}`),this.getSSOGroups=async t=>this.get(`${ot.v1}/configurations/${t}/groups`),this.preLoginV2=async t=>this.post(`${K.v2}/user/sso/prelogin`,t),this.oidcPostLoginV2=async t=>{const e=await this.post(`${K.v2}/user/oidc/postlogin`,t);return this.generateLoginResponse(e)},this.exchangeOAuthTokensV2=async t=>{const e=await this.post(`${Et}/token`,t);return this.generateLoginResponseFromOAuthResponseV2(e)},this.silentOAuthRefreshTokenV2=async()=>{const t=le(this.appName),e=await this.post(`${Et}/authorize/silent`,{tenantId:t});return this.generateLoginResponseFromOAuthResponseV2(e)},this.exchangeOAuthTokens=async t=>{const e=await this.post(`${Et}/token`,t);return this.generateLoginResponseFromOAuthResponse(e)},this.silentOAuthRefreshToken=async()=>{const t=le(this.appName),e=await this.post(`${Et}/authorize/silent`,{tenantId:t});return this.generateLoginResponseFromOAuthResponse(e)},this.resetPhoneNumber=async t=>this.post(`${q.v1}/phone/reset`,t),this.verifyResetPhoneNumber=async t=>this.post(`${q.v1}/phone/reset/verify`,t),this.changePhoneNumberWithVerification=async t=>this.post(`${q.v1}/phone`,t),this.verifyChangePhoneNumber=async t=>this.post(`${q.v1}/phone/verify`,t),this.changePhoneNumber=async t=>this.put(`${q.v1}/phone/change`,t),this.webAuthnPreLogin=async t=>this.post(`${K.v1}/webauthn/prelogin`,t),this.webAuthnPostLogin=async t=>this.post(`${K.v1}/webauthn/postlogin`,t),this.webAuthnPostLoginV2=async t=>{const e=await this.post(`${K.v1}/webauthn/postlogin`,t);return this.generateLoginResponseV3(e)},this.webAuthnCreateNewDeviceSession=async()=>this.post(z.v1),this.getWebAuthnDevices=async()=>this.get(z.v1),this.deleteWebAuthnDevice=async t=>this.delete(`${z.v1}/${t}`),this.verifyNewDeviceSession=async t=>this.post(`${z.v1}/verify`,t),this.getVendorPublicAuthStrategiesConfig=async()=>this.get(`${J.v1}/auth/strategies/public`),this.getPublicAuthStrategiesConfigForAuthenticatedUser=async()=>this.get(`${J.v1}/auth/strategies`),this.getMFAStrategiesConfig=async()=>this.get(`${J.v1}/mfa/strategies`),this.getUserAuthorization=async()=>this.get(`${q.authorization.v1}`),this.getMeV2=async()=>this.get(`${q.v2}/me`),this.noThrowLoadEntitlements=async()=>{try{return await this.entitlementsApi.loadEntitlementsV2()}catch(t){}},this.getMeAndEntitlements=async()=>{if(U.for(this.appName).shouldSkipUserLoad())return{roles:[],permissions:[],groups:[],tenants:[]};const t=[{action:this.getMeV2,shouldLoad:!0},{action:this.noThrowLoadEntitlements,shouldLoad:this.shouldLoadEntitlements()},{action:this.getUserAuthorization,shouldLoad:this.shouldLoadMeAuthorization()}].map((t=>async function({shouldLoad:t,action:e}){if(t)return await e()}(t))),[e,a,n]=await Promise.all(t),s=le(this.appName);return s&&(e.tenantId=s),v({},e,null!=n?n:{},{entitlements:a})},this.generateStepupSession=async t=>{const e=await this.post(`${K.v1}/user/step-up/generate`,t);return e.accessToken?this.generateLoginResponseV3(e):e},this.getGlobalSecurityPolicy=this.securityPolicy.getGlobalSecurityPolicy.bind(this.securityPolicy),this.getMfaPolicy=this.securityPolicy.getMfaPolicy.bind(this.securityPolicy),this.getVendorMfaPolicy=this.securityPolicy.getVendorMfaPolicy.bind(this.securityPolicy),this.saveMfaPolicy=this.securityPolicy.saveMfaPolicy.bind(this.securityPolicy),this.getLockoutPolicy=this.securityPolicy.getLockoutPolicy.bind(this.securityPolicy),this.getVendorLockoutPolicy=this.securityPolicy.getVendorLockoutPolicy.bind(this.securityPolicy),this.saveLockoutPolicy=this.securityPolicy.saveLockoutPolicy.bind(this.securityPolicy),this.getCaptchaPolicy=this.securityPolicy.getCaptchaPolicy.bind(this.securityPolicy),this.getPasswordHistoryPolicy=this.securityPolicy.getPasswordHistoryPolicy.bind(this.securityPolicy),this.getVendorPasswordHistoryPolicy=this.securityPolicy.getVendorPasswordHistoryPolicy.bind(this.securityPolicy),this.savePasswordHistoryPolicy=this.securityPolicy.savePasswordHistoryPolicy.bind(this.securityPolicy),this.getPasswordConfigPolicy=this.securityPolicy.getPasswordConfigPolicy.bind(this.securityPolicy),this.getDomainRestrictions=this.securityPolicy.getDomainRestrictions.bind(this.securityPolicy),this.getDomainRestrictionsConfig=this.securityPolicy.getDomainRestrictionsConfig.bind(this.securityPolicy),this.createDomainRestriction=this.securityPolicy.createDomainRestriction.bind(this.securityPolicy),this.updateDomainRestrictionConfig=this.securityPolicy.updateDomainRestrictionConfig.bind(this.securityPolicy),this.deleteDomainRestriction=this.securityPolicy.deleteDomainRestriction.bind(this.securityPolicy),this.getIPRestrictions=this.securityPolicy.getIPRestrictions.bind(this.securityPolicy),this.getIPRestrictionsConfig=this.securityPolicy.getIPRestrictionsConfig.bind(this.securityPolicy),this.createIPRestriction=this.securityPolicy.createIPRestriction.bind(this.securityPolicy),this.bulkCreateIPRestriction=this.securityPolicy.bulkCreateIPRestriction.bind(this.securityPolicy),this.updateIPRestrictionConfig=this.securityPolicy.updateIPRestrictionConfig.bind(this.securityPolicy),this.deleteIPRestriction=this.securityPolicy.deleteIPRestriction.bind(this.securityPolicy),this.testCurrentIp=this.securityPolicy.testCurrentIp.bind(this.securityPolicy),this.testCurrentIpInAllowList=this.securityPolicy.testCurrentIpInAllowList.bind(this.securityPolicy)}shouldLoadEntitlements(){return U.for(this.appName).shouldLoadEntitlements()}shouldLoadMeAuthorization(){const[t]=Zt.getFeatureFlags([Yt],this.appName);return t}}const be=new me("default");class Ae extends Xt{constructor(t){super(t),this.getProfile=async t=>this.get(`${q.v2}/me`,null!=t?t:{addRoles:!0}),this.updateProfile=async t=>this.put(`${q.v2}/me`,t),this.updateProfileImage=async t=>this.put(`${ut.v1}/me/image/v1`,t,{responseType:"plain",contentType:void 0}),this.changePassword=async t=>this.post(`${q.v1}/passwords/change`,t),this.loadUsers=async t=>{var e,a,n,s,i,o;const r=(t.filter||[]).reduce(((t,e)=>v({},t,{[e.id]:e.value})),{}),l=null!=(e=t.sort)&&e.length?{sortBy:null!=(a=null==(n=t.sort)||null==(s=n[0])?void 0:s.id)?a:"name",sortDirection:null!=(i=t.sort)&&null!=(o=i[0])&&o.desc?"desc":"asc"}:null;return this.get(rt.v1,v({pageOffset:t.pageOffset,pageSize:t.pageSize},r,l))},this.addUser=async t=>this.post(q.v2,v({},t,{provider:"local"})),this.deleteUser=async t=>this.delete(`${rt.v1}/${t.userId}`),this.updateUser=async t=>this.put(rt.v1,t),this.updateUserExpirationTime=async t=>{const{userId:e,expirationInSeconds:a}=t;return this.put(`${q.temporary.v1}/${e}`,{expirationInSeconds:a})},this.setPermanentUser=async t=>this.delete(`${q.temporary.v1}/${t}`),this.getTemporaryUserConfiguration=async()=>this.get(q.temporary.configuration.v1),this.createInviteUserLink=async t=>this.post(Z.invites.user.v1,v({},t)),this.updateInviteUserLink=async t=>this.patch(Z.invites.user.v1,v({},t)),this.deleteInviteUserLink=async()=>this.delete(Z.invites.user.v1),this.getInviteUserLink=async()=>this.get(Z.invites.user.v1),this.getInviteLinkConfiguration=async()=>this.get(Z.invites.configuration.v1),this.loadAvailableRoles=async()=>this.get(lt.v1),this.loadAvailablePermissions=async()=>this.get(Q.v1),this.loadStats=async()=>this.get(`${ct.v1}/members`),this.resendActivationLink=async t=>this.post(`${rt.v1}/${t.userId}/resendActivationEmail`,{}),this.resendInvitationLink=async t=>this.post(q.v2,v({},t,{provider:"local"})),this.resendInvitationLinkToAllTenants=async t=>this.post(q.invitation.resendAll.v1,v({},t)),this.disableUser=async t=>this.post(`${Z.users.v1}/${t}/disable`),this.enableUser=async t=>this.post(`${Z.users.v1}/${t}/enable`)}}const we=new Ae("default");class Te extends Xt{constructor(t){super(t),this.getMetadata=async t=>{var e,a;const n=await this.get("/metadata",t);if(null!=n&&null!=(e=n.rows)&&e[0])return null==n||null==(a=n.rows)?void 0:a[0];throw new Error(`metadata not found: ${t.entityName}`)},this.getAdminBoxMetadata=async()=>this.get("/metadata/admin-box"),this.updateAdminBoxMetadata=async t=>this.post("/metadata/admin-box",t),this.getIpMetadata=async t=>{const e=await this.get(`/metadata/ip/${t}`);if(e)return e;throw new Error("ip metadata not found")},this.getCurrentUserIpMetadata=async()=>{const t=await this.get("/metadata/ipme");if(t)return t;throw new Error("ip metadata not found")},this.getNotificationsMetadata=async()=>this.getMetadata({entityName:"notifications"}),this.getSamlMetadata=async()=>this.getMetadata({entityName:"saml"}),this.getAuditsMetadata=async()=>this.getMetadata({entityName:"audits"}),this.getIpAdressMetadata=async t=>this.getIpMetadata(t)}}const Ee=new Te("default"),Ie=["dataFilters"],Oe=["templateId","dataFilters"],Pe=["dataFilters"];class ke extends Xt{constructor(t){super(t),this.getReports=async t=>this.get(`${ft.v2}/tenant-reports`,t),this.getReport=async t=>this.get(`${ft.v2}/${t.id}/tenant-reports`),this.renderReport=async t=>{let{dataFilters:e}=t,a=f(t,Ie);return{html:await this.get(`${mt.v1}/preview-report`,v({},a,{dataFilters:btoa(JSON.stringify(e||{})),responseType:"html"}),{responseType:"plain"})}},this.scheduleReport=async t=>{let{templateId:e,dataFilters:a}=t,n=f(t,Oe);return this.post(`${ft.v2}/${e}/tenant-reports`,v({},n,{dataFilters:btoa(JSON.stringify(a||{}))}))},this.downloadReport=async t=>{let{dataFilters:e}=t,a=f(t,Pe);const n=await this.get(`${mt.v1}/preview-report`,v({},a,{dataFilters:btoa(JSON.stringify(e||{}))}),{responseType:"blob"});let s="text/html",i="html";"pdf"===a.responseType?(s="application/pdf",i="pdf"):"image"===a.responseType&&(s="image/jpeg",i="jpg");const o=new Blob([n],{type:s}),r=URL.createObjectURL(o),l=document.createElement("a");l.href=r,l.setAttribute("download",`report_${a.name||""}.${i}`),l.click(),setTimeout(l.remove.bind(l))},this.sendReport=async t=>this.post(`${mt.v1}/tenant-reports`,t)}}const _e=new ke("default"),Re=["eventKey"],Ue=["eventKey"];class Ce extends Xt{constructor(t){super(t),this.getSlackConfiguration=()=>this.get(`${ht.v1}/slack`),this.getSlackScope=()=>this.get(`${ht.v1}/slack/applications`),this.getSlackChannels=()=>this.get(`${ht.v1}/slack/channels`),this.postSlackConfiguration=t=>t.id?this.patch(`${ht.v1}/slack/subscription/${t.id}`,t):this.post(`${ht.v1}/slack/subscriptions`,t),this.deleteSlackConfiguration=t=>this.delete(`${ht.v1}/slack/subscriptions/${t.id}`),this.postSlackCode=t=>this.post(`${ht.v1}/slack/applications/registrations`,{code:t}),this.getEmailConfiguration=()=>this.get(`${ht.v1}/emails`),this.postEmailConfiguration=t=>{let{eventKey:e}=t,a=f(t,Re);return this.post(`${ht.v1}/emails/${e}`,a)},this.patchEmailConfiguration=({eventKey:t,enabled:e})=>this.patch(`${ht.v1}/emails/${t}`,{enabled:e}),this.deleteEmailSubscriptions=(t,e)=>this.delete(`${ht.v1}/emails/${t}/subscriptions/${e}`),this.putEmailSubscriptions=(t,e,a)=>this.put(`${ht.v1}/emails/${e}/subscriptions/${t}`,a),this.deleteEmailConfiguration=t=>this.delete(`${ht.v1}/emails/${t}`),this.getSMSConfiguration=()=>this.get(`${ht.v2}/sms`),this.postSMSConfiguration=t=>{let{eventKey:e}=t,a=f(t,Ue);return this.post(`${ht.v2}/sms/${e}`,a)},this.patchSMSConfiguration=({eventKey:t,enabled:e})=>this.patch(`${ht.v2}/sms/${t}`,{enabled:e}),this.deleteSMSSubscriptions=(t,e)=>this.delete(`${ht.v2}/sms/${t}/subscriptions/${e}`),this.putSMSSubscriptions=(t,e,a)=>this.put(`${ht.v2}/sms/${e}/subscriptions/${t}`,a),this.deleteSMSConfiguration=t=>this.delete(`${ht.v2}/sms/${t}`),this.getWebhooksConfigurations=()=>this.get(Tt),this.postWebhooksConfiguration=t=>t._id?this.patch(`${Tt}/${t._id}`,t):this.post(`${Tt}/custom`,t),this.deleteWebhooksConfiguration=t=>this.delete(`${Tt}/${t}`),this.getWebhookLog=(t,e=0,a=10)=>{const n=new URLSearchParams({id:t,offset:`${e}`,limit:`${a}`});return this.get(`${Tt}/logs/?${n.toString()}`)},this.postWebhookTest=t=>this.post(`${Tt}/test`,t),this.postWebhookRetry=t=>this.post(`${Tt}/logs/${t}/retries`),this.getCategories=()=>this.get(`${wt.v1}/categories`),this.getChannelMaps=t=>this.get(wt.v1,{channels:t})}}const Le=new Ce("default");class De extends Xt{constructor(t){super(t),this.getNotifications=async t=>this.get(bt,{params:t}),this.updateNotificationStatus=async t=>this.put(`${bt}/status`,{params:t}),this.updateNotificationIsPinned=async t=>{const{notificationId:e,pinStatus:a}=t;return this.put(`${bt}/${a}`,{notificationId:e})},this.markAllAsRead=async()=>this.post(`${bt}/status/mark-all-read`)}}const Ne=new De("default"),Me=["endpoint","headerProps"];class Fe extends Xt{constructor(t){super(t),this.getAudits=async t=>this.get(At,t),this.getAuditsStats=async t=>this.get(`${At}/stats`,t),this.exportAudits=async t=>{const{endpoint:e,headerProps:a}=t,n=f(t,Me);return this.postDownload(`${At}/export/${e}`,{properties:a},n)}}}const xe=new Fe("default");class $e extends Xt{constructor(t){super(t),this.updateSettings=async(t,e)=>this.put(dt.v1,t,{headers:this.extractHeadersFromOptions(e)}),this.getSettings=async t=>this.get(dt.v1,void 0,{headers:this.extractHeadersFromOptions(t)}),this.getPublicSettings=async()=>this.get(`${dt.v1}/public`)}}const Ge=new $e("default"),je=["roleId"],Be=["roleId"],Ve=["permissionId"];class We extends Xt{constructor(t){super(t),this.getRoles=async()=>this.get(tt.v1),this.addRole=async t=>this.post(tt.v1,t),this.deleteRole=async({roleId:t})=>this.delete(`${tt.v1}/${t}`),this.updateRole=async t=>{let{roleId:e}=t,a=f(t,je);return this.patch(`${tt.v1}/${e}`,a)},this.attachPermissionsToRole=async t=>{let{roleId:e}=t,a=f(t,Be);return this.put(`${tt.v1}/${e}/permissions`,a)},this.getPermissions=async()=>this.get(Q.v1),this.attachPermissionToRoles=async t=>{let{permissionId:e}=t,a=f(t,Ve);return this.put(`${Q.v1}/${e}/roles`,a)},this.getPermissionCategories=async()=>this.get(`${Q.v1}/categories`),this.addRoleV2=async t=>this.post(tt.v2,t)}}const He=new We("default");class ze extends Xt{constructor(...t){super(...t),this.getSubscriptionInvoices=async()=>this.get(yt.invoices.v1),this.getSubscriptionInvoice=async t=>this.get(`${yt.invoices.v1}/${t}`),this.getSubscriptionInvoicePdf=async(t,e)=>this.get(`${yt.invoices.v1}/${t}/pdf`,{outputFileName:e},{responseType:"blob"})}}class Ke extends Xt{constructor(...t){super(...t),this.getManagedSubscription=async t=>this.get(`${vt.v1}/${t}`),this.getManagedSubscriptions=async()=>this.get(vt.v1),this.cancelManagedSubscription=async t=>this.put(`${vt.v1}/${t}/cancellations/`,{}),this.renewManagedSubscription=async t=>this.put(`${vt.v1}/${t}/renewals/`,{}),this.updateManagedSubscription=async(t,{paymentMethodId:e,planId:a})=>this.put(`${vt.v1}/${t}`,{paymentMethodId:e,planId:a})}}const qe=["email"];class Je extends Xt{constructor(...t){super(...t),this.getPaymentMethods=async()=>this.get(yt.paymentMethods.v1),this.getPaymentMethod=async t=>this.get(`${yt.paymentMethods.v1}/${t}`),this.updatePaymentMethodBillingDetails=async(t,e)=>{let{email:a}=e,n=f(e,qe);return this.patch(`${yt.paymentMethods.v1}/${t}/billing-details`,{email:a,address:n})}}}class Ye extends Xt{constructor(...t){super(...t),this.getPaymentProviders=async()=>this.get(St.v1)}}class Xe extends Xt{constructor(...t){super(...t),this.getSubscriptionPlans=async()=>this.get(yt.plans.v1),this.getSubscriptionPlan=async t=>this.get(`${yt.plans.v1}/${t}`)}}class Qe extends Xt{constructor(...t){super(...t),this.getSubscriptions=async()=>this.get(yt.subscriptions.v1),this.getSubscription=async t=>this.get(`${yt.subscriptions.v1}/${t}`),this.cancelSubscription=async t=>this.put(`${yt.subscriptions.v1}/${t}/cancellations/`,{}),this.renewSubscription=async t=>this.put(`${yt.subscriptions.v1}/${t}/renewals/`,{}),this.updateSubscription=async(t,{paymentMethodId:e,planId:a})=>this.put(`${yt.subscriptions.v1}/${t}`,{paymentMethodId:e,planId:a})}}class Ze extends Xt{constructor(...t){super(...t),this.getSubscriptionSummaries=async t=>this.get(`${yt.summaries.v1}/${t}`)}}class ta extends Xt{constructor(...t){super(...t),this.getTenantConfiguration=async t=>this.get(`${yt.tenantConfiguration.v1}/${t}`),this.createTenantConfiguration=async t=>this.post(yt.tenantConfiguration.v1,t)}}class ea extends Xt{constructor(...t){super(...t),this.getVendorPublicConfigurations=async()=>this.get(yt.configurations.vendorPublicConfigurations.v1)}}class aa extends Xt{constructor(...t){super(...t),this.createSubscription=async t=>this.post(yt.paymentProviders.stripe.subscriptions.v1,t),this.getStripeCustomer=async t=>this.get(`${yt.paymentProviders.stripe.customers.v1}/${t}`),this.createStripeCustomer=async t=>this.post(yt.paymentProviders.stripe.customers.v1,t),this.getStripePaymentProviderConfiguration=async()=>this.get(yt.paymentProviders.stripe.publicConfigurations.v1),this.createStripePaymentMethodSetupIntentSecret=async t=>this.post(yt.paymentProviders.stripe.setupIntents.v1,t)}}class na extends Xt{constructor(t){super(t),this.invoicesApi=new ze(this.appName),this.managedSubscriptionApi=new Ke(this.appName),this.paymentMethodsApi=new Je(this.appName),this.paymentProvidersApi=new Ye(this.appName),this.plansApi=new Xe(this.appName),this.subscriptionApi=new Qe(this.appName),this.summariesApi=new Ze(this.appName),this.subscriptionTenantConfigApi=new ta(this.appName),this.vendorPublicConfigApi=new ea(this.appName),this.stripeProviderApi=new aa(this.appName),this.getSubscriptionInvoices=this.invoicesApi.getSubscriptionInvoices.bind(this.invoicesApi),this.getSubscriptionInvoice=this.invoicesApi.getSubscriptionInvoice.bind(this.invoicesApi),this.getSubscriptionInvoicePdf=this.invoicesApi.getSubscriptionInvoicePdf.bind(this.invoicesApi),this.getManagedSubscription=this.managedSubscriptionApi.getManagedSubscription.bind(this.managedSubscriptionApi),this.getManagedSubscriptions=this.managedSubscriptionApi.getManagedSubscriptions.bind(this.managedSubscriptionApi),this.cancelManagedSubscription=this.managedSubscriptionApi.cancelManagedSubscription.bind(this.managedSubscriptionApi),this.renewManagedSubscription=this.managedSubscriptionApi.renewManagedSubscription.bind(this.managedSubscriptionApi),this.updateManagedSubscription=this.managedSubscriptionApi.updateManagedSubscription.bind(this.managedSubscriptionApi),this.getPaymentMethods=this.paymentMethodsApi.getPaymentMethods.bind(this.paymentMethodsApi),this.getPaymentMethod=this.paymentMethodsApi.getPaymentMethod.bind(this.paymentMethodsApi),this.updatePaymentMethodBillingDetails=this.paymentMethodsApi.updatePaymentMethodBillingDetails.bind(this.paymentMethodsApi),this.getPaymentProviders=this.paymentProvidersApi.getPaymentProviders.bind(this.paymentProvidersApi),this.getSubscriptionPlans=this.plansApi.getSubscriptionPlans.bind(this.plansApi),this.getSubscriptionPlan=this.plansApi.getSubscriptionPlan.bind(this.plansApi),this.getSubscriptions=this.subscriptionApi.getSubscriptions.bind(this.subscriptionApi),this.getSubscription=this.subscriptionApi.getSubscription.bind(this.subscriptionApi),this.cancelSubscription=this.subscriptionApi.cancelSubscription.bind(this.subscriptionApi),this.renewSubscription=this.subscriptionApi.renewSubscription.bind(this.subscriptionApi),this.updateSubscription=this.subscriptionApi.updateSubscription.bind(this.subscriptionApi),this.getSubscriptionSummaries=this.summariesApi.getSubscriptionSummaries.bind(this.summariesApi),this.getTenantConfiguration=this.subscriptionTenantConfigApi.getTenantConfiguration.bind(this.subscriptionTenantConfigApi),this.createTenantConfiguration=this.subscriptionTenantConfigApi.createTenantConfiguration.bind(this.subscriptionTenantConfigApi),this.getVendorPublicConfigurations=this.vendorPublicConfigApi.getVendorPublicConfigurations.bind(this.vendorPublicConfigApi),this.createSubscription=this.stripeProviderApi.createSubscription.bind(this.stripeProviderApi),this.getStripeCustomer=this.stripeProviderApi.getStripeCustomer.bind(this.stripeProviderApi),this.createStripeCustomer=this.stripeProviderApi.createStripeCustomer.bind(this.stripeProviderApi),this.getStripePaymentProviderConfiguration=this.stripeProviderApi.getStripePaymentProviderConfiguration.bind(this.stripeProviderApi),this.createStripePaymentMethodSetupIntentSecret=this.stripeProviderApi.createStripePaymentMethodSetupIntentSecret.bind(this.stripeProviderApi)}}const sa=new na("default");class ia extends Xt{constructor(t){super(t),this.getVendorPublicInfo=async()=>this.get("/vendors/public")}}const oa=new ia("default");class ra extends Xt{constructor(t){super(t),this.loadAllUsers=async t=>this.get(et.v1,t),this.addUserToTenantAndSubTenants=async t=>this.post(et.v1,t),this.removeUserFromTenantAndSubTenants=async(t,e)=>this.delete(et.v1,t,{headers:this.extractHeadersFromOptions(e)}),this.addUserRolesForSubTenants=async(t,e,a)=>this.post(`${et.v1}/${t}/roles`,e,{headers:this.extractHeadersFromOptions(a)}),this.removeUserRolesFromSubTenants=async(t,e,a)=>this.delete(`${et.v1}/${t}/roles`,e,{headers:this.extractHeadersFromOptions(a)}),this.setUserRolesForSubTenants=async(t,e,a)=>this.patch(`${et.v1}/${t}/roles`,e,{headers:this.extractHeadersFromOptions(a)}),this.createSubTenant=async(t,e)=>this.post(pt.v1,t,{headers:this.extractHeadersFromOptions(e)}),this.deleteSubTenant=async(t,e)=>this.delete(`${pt.v1}/${t}`,void 0,{headers:this.extractHeadersFromOptions(e)}),this.updateSubTenant=async({tenantId:t},e,a)=>this.patch(`${pt.v1}/${t}`,e,{headers:this.extractHeadersFromOptions(a)}),this.updateSubTenantManagement=async({tenantId:t},e,a)=>this.put(`${pt.v1}/${t}/management`,e,{headers:this.extractHeadersFromOptions(a)}),this.updateSubAccountAccess=async(t,e,a)=>this.put(`${et.v1}/${t}/access`,e,{headers:this.extractHeadersFromOptions(a)}),this.addUsersToSubTenant=async(t,e)=>this.post(`${et.v2}/`,t,{headers:this.extractHeadersFromOptions(e)})}updateSubTenantHierarchySettings({tenantId:t},e,a){return this.put(`${pt.v1}/${t}/hierarchy-settings`,e,{headers:this.extractHeadersFromOptions(a)})}}const la=new ra("default");class ca extends Xt{constructor(t){super(t),this.getConfigs=async()=>this.get(`${Ot}`),this.updateConfiguration=async(t,e)=>this.patch(`${Ot}/${t}`,e),this.createConfiguration=async t=>this.post(`${Ot}`,t),this.deleteConfiguration=async(t,e)=>this.delete(`${Ot}/${t}`,{deleteAll:e}),this.countConfigurationUsers=async t=>this.get(`${Pt}/${t}/Users/count`)}}const ua=new ca("default");class da extends Xt{constructor(t){super(t),this.impersonate=async t=>this.post(`${at.v1}`,t)}}const ga=new da("default"),pa=["groupId"];class ha extends Xt{constructor(t){super(t),this.getGroupById=async({groupId:t},e)=>this.get(`${st.v1}/${t}`,v({},e)),this.getGroups=async t=>this.get(`${st.v1}`,v({},t)),this.getGroupsByIds=async(t,e)=>this.post(`${st.getByIds.v1}`,t,{params:e}),this.createGroup=async t=>this.post(`${st.v1}`,t),this.updateGroup=async t=>{let{groupId:e}=t,a=f(t,pa);return this.patch(`${st.v1}/${e}`,a)},this.deleteGroup=async t=>this.delete(`${st.v1}/${t}`),this.addRolesToGroup=async(t,e)=>this.post(`${st.v1}/${t}/roles`,e),this.deleteRolesFromGroup=async(t,e)=>this.delete(`${st.v1}/${t}/roles`,e),this.addUsersToGroup=async(t,e)=>this.post(`${st.v1}/${t}/users`,e),this.deleteUsersFromGroup=async(t,e)=>this.delete(`${st.v1}/${t}/users`,e),this.getGroupConfiguration=async()=>this.get(`${st.configurations.v1}`),this.updateGroupConfiguration=async t=>this.post(`${st.configurations.v1}`,t)}}const ya=new ha("default");class Sa extends Xt{constructor(t){super(t),this.getRecommendations=async()=>this.get(_t.v1),this.getInsights=async()=>this.get(Rt.v1)}}const va=new Sa("default");class fa extends Xt{constructor(t){super(t),this.getUserPhoneNumbers=async t=>this.get(`${it.v1}`,t),this.getUserOwnPhoneNumbers=async()=>this.get(`${it.v1}/me`),this.createPhoneNumber=async t=>this.post(`${it.v1}`,t),this.deletePhoneNumber=async t=>this.delete(`${it.v1}/${t}`),this.preVerifyPhoneNumber=async t=>this.post(`${it.v1}/preverify`,t),this.verifyPhoneNumber=async t=>this.post(`${it.v1}/verify`,t),this.verifyDeletePhoneNumber=async(t,e)=>this.post(`${it.v1}/${t}/delete/verify`,e)}}const ma=new fa("default");class ba extends Xt{constructor(t){super(t),this.getUserApplicationsId=async({userId:t})=>this.get(`${nt.v1}/${t}/apps`),this.getUsersApplicationsId=async({userIds:t})=>this.get(`${nt.v1}/users-apps`,{userIds:t.join(",")}),this.getTenantsApplications=async()=>this.get(Ct.v1),this.getApplicationsData=async({appIds:t,includeFreeAccess:e=!0})=>this.get(Ut,{ids:t.join(","),_includeFreeAccess:e}),this.assignUserToApplications=async t=>this.post(`${nt.v1}/apps-user`,t),this.unassignUserFromApplications=async t=>this.delete(`${nt.v1}/user-apps`,t),this.getUsersOfApplications=async({appIds:t})=>this.get(`${nt.v1}/apps-users`,{appIds:t.join(",")})}}const Aa=new ba("default"),wa={"x-frontegg-api-key":"my-frontegg-api-key","frontegg-vendor-id":"04ae2174-d8d9-4a90-8bab-2548e210a508","frontegg-tenant-id":"02e6ab6f-8b25-48e4-b06d-2c53745ce213","frontegg-user-id":"e5c397a1-7120-4753-9216-e5d7f35d1f2d"};class Ta extends Xt{constructor(t){super(t),this.getAgentsConfig=async()=>this.get(`${Lt}/config`,void 0,{headers:wa}),this.getConversations=async()=>this.get(`${Lt}/conversations`,void 0,{headers:wa}),this.getConversationById=async t=>this.get(`${Lt}/conversation/${t.id}`,void 0,{headers:wa}),this.createConversation=async t=>this.post(`${Lt}/conversations`,{message:t.message,stream:t.stream},{responseType:!1===t.stream?"json":"stream",headers:wa}),this.sendMessage=async t=>this.post(`${Lt}/conversation/${t.conversationId}/messages`,{message:t.message,stream:t.stream},{responseType:!1===t.stream?"json":"stream",headers:wa}),this.sendApiResponse=async t=>this.post(`${Lt}/conversation/${t.conversationId}/response/${t.callId}`,{data:t.data,status:t.status,stream:t.stream},{responseType:!1===t.stream?"json":"stream",headers:wa}),this.getConversationResource=async t=>this.get(`${Lt}/conversation/${t.conversationId}/resource/${t.resourceId}`,void 0,{headers:wa})}}const Ea=new Ta("default");let Ia,Oa,Pa,ka,_a;!function(t){t.FRONTEGG="frontegg",t.SCIM2="scim2"}(Ia||(Ia={})),function(t){t.createdAt="createdAt",t.name="name",t.tenantId="tenantId"}(Oa||(Oa={})),function(t){t.CUSTOMER="customer",t.SPAM="spam",t.TEST="test",t.RESELLER="reseller",t.HEADQUARTER="headquarter"}(Pa||(Pa={})),function(t){t.NEVER="NEVER",t.ALWAYS="ALWAYS",t.ASSIGNABLE="ASSIGNABLE"}(ka||(ka={})),function(t){t.DEFAULT_OFF="defaultOff",t.DEFAULT_ON="defaultOn",t.ALWAYS_ON="alwaysOn"}(_a||(_a={}));const Ra=[/^(.*)\/logout$/g,"/logout",/^\/identity\/resources\/auth\/v[0-9]*\/user\/[^\/]*\/postlogin$/g,/^\/identity\/resources\/impersonation\/v[0-9]$/g,/^\/identity\/resources\/auth\/v[0-9]*\/passwordless\/[^\/]*\/postlogin$/g,/^\/identity\/resources\/auth\/v[0-9]*\/webauthn\/postlogin$/g,/^\/identity\/resources\/auth\/v[0-9]*\/user$/g,/^\/identity\/resources\/auth\/v[0-9]*\/user\/token\/refresh$/g,/^\/identity\/resources\/users\/v[0-9]*\/signUp$/g,/^\/identity\/resources\/users\/v[0-9]*\/activate$/g,/^\/identity\/resources\/users\/v[0-9]*\/invitation\/accept$/g,/^\/identity\/resources\/auth\/v[0-9]*\/user\/mfa\/verify$/g,/^\/identity\/resources\/auth\/v[0-9]*\/user\/mfa\/[^\/]*\/[^\/]*\/verify$/g,/^\/oauth\/token$/g,/^\/oauth\/authorize\/silent$/g],Ua=`${K.v1}/user/token/refresh`,Ca=`${Et}/authorize/silent`,La=`${q.v2}/me`,Da=`${q.v2}/me/tenants`,Na=`${q.v3}/me/tenants`,Ma=kt;let Fa,xa,$a,Ga,ja;!function(t){t.FRONTEGG="frontegg",t.OKTA="okta",t.AZURE_AD="azure-ad",t.OTHER="other"}(Fa||(Fa={})),function(t){t.roles="roles",t.users="users",t.rolesAndUsers="rolesAndUsers"}(xa||(xa={})),function(t){t.FRONTEGG="frontegg",t.SCIM2="scim2"}($a||($a={})),function(t){t.createdAt="createdAt",t.name="name",t.email="email",t.id="id",t.verified="verified",t.isLocked="isLocked",t.provider="provider",t.tenantId="tenantId"}(Ga||(Ga={})),function(t){t.MFA_UNENROLLED="mfa-unenrolled",t.BREACHED_PASSWORDS="breached-passwords",t.INACTIVE="inactive"}(ja||(ja={}));const Ba=["local","saml","google","github","facebook","microsoft","scim2","slack"];let Va,Wa,Ha,za,Ka,qa,Ja;!function(t){t.MISSING_PERMISSION="MISSING_PERMISSION",t.MISSING_FEATURE="MISSING_FEATURE",t.BUNDLE_EXPIRED="BUNDLE_EXPIRED"}(Va||(Va={})),function(t){t.FORCE_MFA="FORCE_MFA",t.BREACHED_PASSWORDS_EXIST="BREACHED_PASSWORDS_EXIST",t.ENABLE_USER_LOCKOUT="ENABLE_USER_LOCKOUT",t.STRENGTHEN_USER_LOCKOUT="STRENGTHEN_USER_LOCKOUT",t.ENABLE_PASSWORD_HISTORY="ENABLE_PASSWORD_HISTORY",t.STRENGTHEN_PASSWORD_HISTORY="STRENGTHEN_PASSWORD_HISTORY",t.ENABLE_FORCE_RELOGIN="ENABLE_FORCE_RELOGIN",t.SET_FORCE_RELOGIN="SET_FORCE_RELOGIN",t.ENABLE_SESSION_CONCURRENCY="ENABLE_SESSION_CONCURRENCY",t.SET_SESSION_CONCURRENCY="SET_SESSION_CONCURRENCY",t.ENABLE_IDLE_SESSION="ENABLE_IDLE_SESSION",t.SET_IDLE_SESSION="SET_IDLE_SESSION",t.ENABLE_IP_RESTRICTIONS="ENABLE_IP_RESTRICTIONS",t.CHANGE_IP_TO_ALLOWLIST="CHANGE_IP_TO_ALLOWLIST",t.ENABLE_DOMAIN_RESTRICTIONS="ENABLE_DOMAIN_RESTRICTIONS",t.CHANGE_DOMAIN_TO_ALLOWLIST="CHANGE_DOMAIN_TO_ALLOWLIST",t.CONFIGURE_SSO="CONFIGURE_SSO"}(Wa||(Wa={})),function(t){t.MFA_FORCED="MFA_FORCED",t.PARTIALLY_FORCED_MFA="PARTIALLY_FORCED_MFA",t.PARTIAL_MFA_USAGE="PARTIAL_MFA_USAGE",t.FULL_MFA_USAGE="FULL_MFA_USAGE",t.BREACHED_PASSWORD_USERS_EXIST="BREACHED_PASSWORD_USERS_EXIST",t.IMPROVE_LOCKOUT_POLICY="IMPROVE_LOCKOUT_POLICY",t.IMPROVE_PASSWORD_HISTORY_POLICY="IMPROVE_PASSWORD_HISTORY_POLICY",t.NO_SESSION_SETTINGS="NO_SESSION_SETTINGS",t.PARTIAL_SESSION_SETTINGS="PARTIAL_SESSION_SETTINGS",t.FULL_SESSION_SETTINGS="FULL_SESSION_SETTINGS",t.NO_IP_RESTRICTIONS="NO_IP_RESTRICTIONS",t.IP_ALLOWLIST="IP_ALLOWLIST",t.IP_DENYLIST="IP_DENYLIST",t.NO_DOMAIN_RESTRICTIONS="NO_DOMAIN_RESTRICTIONS",t.DOMAIN_ALLOWLIST="DOMAIN_ALLOWLIST",t.DOMAIN_DENYLIST="DOMAIN_DENYLIST",t.FULL_PASSWORD_SETTINGS="FULL_PASSWORD_SETTINGS"}(Ha||(Ha={})),function(t){t.SEND_RESET_BREACHED_PASSWORD_EMAIL="SEND_RESET_BREACHED_PASSWORD_EMAIL",t.ADJUST_FORCE_RELOGIN="ADJUST_FORCE_RELOGIN",t.ADJUST_MAX_CONCURRENT_SESSIONS="ADJUST_MAX_CONCURRENT_SESSIONS",t.ADJUST_IDLE_TIMEOUT="ADJUST_IDLE_TIMEOUT"}(za||(za={})),function(t){t.SEVERE="SEVERE",t.WARNING="WARNING",t.INFO="INFO"}(Ka||(Ka={})),function(t){t.MFA="MFA",t.SESSIONS="SESSIONS",t.PASSWORD="PASSWORD",t.INACTIVITY="INACTIVITY",t.IP="IP",t.DOMAIN="DOMAIN",t.SSO="SSO"}(qa||(qa={})),function(t){t.FREE_ACCESS="FREE_ACCESS",t.MANAGED_ACCESS="MANAGED_ACCESS"}(Ja||(Ja={}));const Ya={auth:be,securityPolicy:ye,teams:we,metadata:Ee,reports:_e,connectivity:Le,notifications:Ne,audits:xe,tenants:de,accountSettings:Ge,roles:He,subscriptions:sa,vendor:oa,subTenants:la,featureFlags:ee,directory:ua,impersonate:ga,groups:ya,users:ie,entitlements:pe,securityCenter:va,userPhoneNumbers:ma,applications:Aa,velo:Ea},Xa=t=>({auth:new me(t),securityPolicy:new he(t),teams:new Ae(t),metadata:new Te(t),reports:new ke(t),connectivity:new Ce(t),notifications:new De(t),audits:new Fe(t),tenants:new ue(t),accountSettings:new $e(t),roles:new We(t),subscriptions:new na(t),vendor:new ia(t),subTenants:new ra(t),featureFlags:new te(t),directory:new ca(t),impersonate:new da(t),groups:new ha(t),users:new se(t),entitlements:new ge(t),securityCenter:new Sa(t),userPhoneNumbers:new fa(t),applications:new ba(t),velo:new Ta(t)}),Qa={fetch:jt,FetchClient:Gt,ContextHolder:U,FronteggContext:L,api:Ya,createApiClient:Xa,FronteggApiError:W,AuthStrategyEnum:N,MachineToMachineAuthStrategy:M,SocialLoginProviders:D,ISubscriptionCancellationPolicy:G,ISubscriptionStatus:x,PaymentMethodType:$,ProviderType:j};var Za=a(2743),tn=a.n(Za);const en=(t,e)=>{const a=tn()(t,v({},e));return function(t={}){return O(t)}(v({__isProxy:!0},a))};let an;!function(t){t.validate="validate",t.invalid="invalid",t.pending="pending",t.success="success",t.failed="failed"}(an||(an={}));const nn={step:an.validate},sn=t=>en(nn,t);var on=a(5302),rn=a.n(on),ln=a(1098),cn=a.n(ln);const un="http://schemas.openid.net/pape/policies/2007/06/multi-factor",dn="mfa",gn=["otp","sms","hwk"],pn="SHOULD_STEP_UP",hn="maxAge";let yn,Sn,vn,fn;!function(t){t.preLogin="preLogin",t.magicLinkPreLoginSuccess="magicLinkPreLoginSuccess",t.loginWithSmsOtc="loginWithSmsOtc",t.loginWithQuickSmsOtc="loginWithQuickSmsOtc",t.loginWithOtc="loginWithOtc",t.loginWithPassword="loginWithPassword",t.loginWithTwoFactor="loginWithTwoFactor",t.redirectToSSO="redirectToSSO",t.loginWithSSOFailed="loginWithSSOFailed",t.success="success",t.forceTwoFactor="forceTwoFactor",t.recoverTwoFactor="recoverTwoFactor",t.promptPasskeys="promptPasskeys",t.breachedPassword="breachedPassword",t.breachedPasswordSuccess="breachedPasswordSuccess",t.passwordRotationExpired="passwordRotationExpired",t.passwordRotationNotification="passwordRotationNotification",t.magicLinkPostLoginSuccess="magicLinkPostLoginSuccess"}(yn||(yn={})),function(t){t.Login="login",t.RegisterQuickLogin="registerQuickLogin"}(Sn||(Sn={})),function(t){t.Internal="internal",t.UsbKey="usb-key",t.Android="android",t.Sms="sms"}(vn||(vn={})),function(t){t["social-login"]="social-login",t["custom-social-login"]="custom-social-login",t.direct="direct"}(fn||(fn={}));const mn={[N.Code]:yn.loginWithOtc,[N.EmailAndPassword]:yn.loginWithPassword,[N.MagicLink]:yn.magicLinkPreLoginSuccess,[N.SmsCode]:yn.loginWithSmsOtc},bn={authenticatedUrl:"/",loginUrl:"/account/login",stepUpUrl:"/account/step-up",logoutUrl:"/account/logout",activateUrl:"/account/activate",impersonationUrl:"/account/impersonate",acceptInvitationUrl:"/account/invitation/accept",forgetPasswordUrl:"/account/forget-password",resetPhoneNumberUrl:"/account/reset-phone-number",resetPasswordUrl:"/account/reset-password",socialLoginCallbackUrl:"/account/social/success",signUpUrl:"/account/sign-up",oidcRedirectUrl:"/account/oidc/callback",samlCallbackUrl:"/account/saml/callback",magicLinkCallbackUrl:"/account/login/magic-link",hostedLoginRedirectUrl:"/oauth/callback",openAppUrl:"/account/redirect",unlockAccountUrl:"/account/unlock",activateWithOTCUrl:"/account/activate/code",acceptInvitationWithOTCUrl:"/account/invitation/code",mfaMobileAuthenticator:"/account/mfa-mobile-authenticator"},An="FRONTEGG_AFTER_AUTH_REDIRECT_URL",wn="HOSTED_LOGIN_VERIFIER_KEY",Tn={retryCount:3},En=(t=500)=>new Promise((e=>{setTimeout(e,t)})),In=async(t,e,a,n)=>{let s=0;for(;s<e-1;)try{const i=await t();if(!n||null!==i)return i;if(s++,s>=e)return i;await new Promise((t=>setTimeout(t,a)))}catch(t){if(s++,s>=e)throw t;await new Promise((t=>setTimeout(t,a)))}return await t()},On=async(t,e)=>e?In(t,e.retryCount,e.delay||500,e.shouldRetryWhenNull):t(),Pn=t=>v({},t,{retryConfig:Tn}),kn=t=>(null==t?void 0:t.traceId)||void 0;function _n(t,e){const a=v({},t);return e.forEach((t=>{delete a[t]})),a}function Rn(t){if(null!=t)return function(t){const e=typeof t;return(null==t?void 0:t.constructor)==={}.constructor||"undefined"===e||null===t||"boolean"===e||"number"===e||"string"===e||t instanceof Date||t instanceof RegExp||t instanceof Blob||t instanceof File||t instanceof FileList||t instanceof ArrayBuffer||t instanceof ImageData||t instanceof ImageBitmap||t instanceof Array||t instanceof Map||t instanceof Set}(t)&&void 0!==t.__isProxy}const Un=t=>JSON.parse(JSON.stringify(t)),Cn=(t,e,a)=>{const n=Un(a),s=rn()(t,e);for(const a in s)"__isProxy"!==a&&(a in n?cn()(t,[...e,a],n[a]):cn()(t,[...e,a],void 0))},Ln=t=>Boolean(null==t?void 0:t.statusCode),Dn=t=>t instanceof Error||(null==t?void 0:t.message)&&(null==t?void 0:t.stack)&&"Error"===(null==t?void 0:t.name),Nn=(t,e)=>t?Ln(t)?(console.error(t.message),t):(Dn(t)?console.error(t.message):"string"==typeof t&&console.error(t),null!=e?e:new W(Dt,500,null,Nt)):e,Mn=(t,e,a)=>{const n=e=>{Object.assign(t.auth.acceptInvitationState,e)};return{setAcceptInvitationState:n,resetAcceptInvitationState:()=>{Cn(t,["auth","acceptInvitationState"],nn)},acceptInvitation:async t=>{if(t.token&&t.userId)try{n({error:void 0,step:an.pending}),await e.auth.acceptInvitation(t),n({step:an.success})}catch(t){n({step:an.failed,error:Nn(t)})}else n({error:void 0,step:an.invalid})},acceptInvitationWithOTC:async t=>{if(t.token&&t.userId&&t.code)try{n({error:void 0,step:an.pending}),await e.auth.acceptInvitationWithOTC(t),n({step:an.success})}catch(t){n({step:an.validate,error:Nn(t)})}else n({error:void 0,step:an.invalid})}}},Fn={loading:!1},xn=t=>en(Fn,t),$n=["activeTenant","tenants"],Gn=(t,e,a)=>{const n=e=>{Object.assign(t.auth.accountSettingsState,e)};return{setAccountSettingsState:n,resetAccountSettingsState:()=>{Cn(t,["auth","accountSettingsState"],Fn)},saveAccountSettings:async s=>{try{var i;n({loading:!0});const{address:o,timezone:r,dateFormat:l,timeFormat:c,currency:u,logo:d}=t.auth.accountSettingsState,g=await e.accountSettings.updateSettings(v({address:o,timezone:r,dateFormat:l,timeFormat:c,currency:u,logo:d},s));(({newSettingValues:e})=>{const n=t.auth.tenantsState,{activeTenant:s,tenants:i}=n,o=f(n,$n),r=i.map((t=>t.id!==(null==s?void 0:s.id)?t:v({},t,e))),l=v({},s,e);a.setTenantsState(v({},o,{tenants:r,activeTenant:l}))})({newSettingValues:g}),n(v({},g,{loading:!1})),null==(i=s.callback)||i.call(s,g)}catch(t){var o;n({loading:!1,error:Nn(t)}),null==(o=s.callback)||o.call(s,null,t)}},loadAccountSettings:async t=>{n({loading:!(null!=t&&t.silentLoading),error:null});try{const a=await On((()=>e.accountSettings.getSettings()),null==t?void 0:t.retryConfig);n(v({},a,{loading:!1}))}catch(t){n({loading:!1,error:Nn(t)})}}}};let jn;!function(t){t.activating="activating",t.success="success",t.resend="resend",t.activatingForm="activatingForm"}(jn||(jn={}));const Bn={step:jn.activating,loading:!1,submitting:!1,resentEmail:!1,activationStrategy:{loading:!1}},Vn=t=>en(Bn,t);let Wn,Hn,zn,Kn;!function(t){t.LOAD_FEATURE_FLAGS="LOAD_FEATURE_FLAGS,",t.LOAD_ADMIN_BOX_METADATA="LOAD_ADMIN_BOX_METADATA,",t.LOAD_SSO_PUBLIC_CONFIGURATION="LOAD_SSO_PUBLIC_CONFIGURATION,",t.LOAD_PUBLIC_AUTH_STRATEGIES_POLICY="LOAD_PUBLIC_AUTH_STRATEGIES_POLICY,",t.LOAD_ALLOW_SIGNUPS="LOAD_ALLOW_SIGNUPS,",t.LOAD_CUSTOM_LOGIN_ROUTES="LOAD_CUSTOM_LOGIN_ROUTES",t.LOAD_PASSWORD_CONFIGURATION="LOAD_PASSWORD_CONFIGURATION"}(Wn||(Wn={})),function(t){t.SOCIAL_LOGIN="SOCIAL_LOGIN",t.PASSWORDLESS="PASSWORDLESS",t.ACTIVATION_LINK="ACTIVATION_LINK"}(Hn||(Hn={})),function(t){t.SOCIAL_LOGIN="SOCIAL_LOGIN",t.PASSWORD="PASSWORD",t.PHONE_NUMBER="PHONE_NUMBER"}(zn||(zn={})),function(t){t.profile="profile",t.privacy="privacy",t.personalApiTokens="personalApiTokens",t.account="account",t.users="users",t.groups="groups",t.security="security",t.sso="sso",t.audits="audits",t.webhooks="webhooks",t.apiTokens="apiTokens",t.roles="roles",t.subscriptions="subscription",t.allAccounts="allAccounts"}(Kn||(Kn={}));const qn={profile:Kn.profile,privacy:Kn.privacy,personalApiTokens:Kn.personalApiTokens,account:Kn.account,users:Kn.users,groups:Kn.groups,security:Kn.security,sso:Kn.sso,audits:Kn.audits,webhooks:Kn.webhooks,apiTokens:Kn.apiTokens,roles:Kn.roles,subscriptions:Kn.subscriptions,allAccounts:Kn.allAccounts};let Jn,Yn;function Xn(t,e){var a,n;null==(a=(n=window).onFronteggEvent)||a.call(n,t,e)}!function(t){t.SIGNUP_COMPLETED="signup_completed",t.USER_VERIFIED="user_verified"}(Jn||(Jn={})),function(t){t.verify="verify",t.recoveryCode="recoveryCode",t.authenticatorApp="authenticatorApp",t.smsSetPhoneNumber="smsSetPhoneNumber",t.smsVerifyCode="smsVerifyCode",t.emailVerifyCode="emailVerifyCode",t.noMFAEnrolledStepUp="noMFAEnrolledStepUp"}(Yn||(Yn={}));const Qn=t=>{try{return new URL(t),!0}catch(t){return!1}},Zn=({authenticatedUrl:t,enforceRedirectToSameSite:e,allowedRedirectOrigins:a,includeQueryParam:n})=>{let s=t;const i=new URL(window.location.href).searchParams.get("redirectUrl");return i?e&&Qn(i)?((t,e)=>{const a=new URL(window.location.href),n=new URL(t),s=n.origin===a.origin;return e.includes(n.origin)||s})(i,a)?s=i:console.warn("The redirect url param is not valid, the origin is a different site"):s=i:n&&(s+=window.location.search),s},ts=t=>{const{searchParams:e}=new URL(t),a=e.toString();if(a)return`?${a}`},es=(t,e=!1)=>{const{pathname:a,href:n}=new URL(t);if(e)return n;const s=ts(t);return s?a+s:a},as=t=>{const e=new URLSearchParams(window.location.search).get(t);return null!=e?e:void 0},ns="tenantId",ss=t=>{const e=+Boolean(t.webauthn.length),a=+Boolean(t.phones.length),n=+Boolean(t.authenticators.length),s=+Boolean(t.emails.length);return{numberOfWebAuthnDevices:e,numberOfPhoneDevices:a,numberOfAuthenticators:n,numberOfEmails:s,totalDevices:e+a+n+s}},is=t=>{const{numberOfPhoneDevices:e,numberOfAuthenticators:a,numberOfEmails:n,totalDevices:s}=ss(t);if(1===s){if(a)return Yn.authenticatorApp;if(e)return Yn.smsVerifyCode;if(n)return Yn.emailVerifyCode}return Yn.verify},os=t=>{if(1===t.length){const[e]=t;if(e===Jt.AuthenticatorApp)return Yn.authenticatorApp;if(e===Jt.SMS)return Yn.smsSetPhoneNumber;if(e===Jt.EmailCode)return Yn.emailVerifyCode}return Yn.verify},rs=t=>"/oauth/callback"===t;function ls(t){return"email"in t}const cs=t=>{const e=U.for(t.root.appName).getBasename();return null!=e&&e.endsWith("/")?e.slice(0,-1):e},us=t=>void 0!==t.passwordExpiresIn&&void 0!==t.notificationPeriod&&t.passwordExpiresIn<=t.notificationPeriod,ds=(t,{maxAge:e}={})=>{if(!t)return!1;const{amr:a=[],acr:n="",auth_time:s}=t;if(e&&s&&!(Date.now()/1e3-s<=e))return!1;const i=n===un,o=-1!==a.indexOf(dn),r=void 0!==gn.find((t=>a.indexOf(t)));return i&&o&&r};function gs(){const t=window.location.pathname+window.location.search;window.localStorage.setItem(An,t)}const ps=(t,e,a)=>{gs();const n=new URLSearchParams(window.location.search);a&&n.set(hn,a.toString()),e(`${t}${n?`?${n}`:""}`,{refresh:!1})},hs=["phoneNumber","email"],ys=["authenticatedUrl"],Ss=(t,e)=>{const a=U.for(e);return t.mfaRequired&&t.mfaToken?(a.setAccessToken(null),a.setUser(null),!0):(a.setAccessToken(t.accessToken),a.setUser(t),!1)},vs=(t,e)=>{const a=U.for(e);return t.resetPasswordToken?(a.setAccessToken(null),!0):(a.setAccessToken(t.accessToken),a.setUser(t),!1)},fs=(t,e=[])=>Object.entries(t).reduce(((t,[a,n])=>"object"==typeof n?[...t,...fs(n,[...e,a])]:[...t,{type:[...e,a].join("/"),payload:n}]),[]),ms=t=>{var e;if("path"===t)return(null!=(e=window)?e:document).location.pathname;{var a;const t=((null!=(a=window)?a:document).location.hash||"#").substring(1);return-1!==t.indexOf("?")?t.substring(0,t.indexOf("?")):t}},bs=t=>{const{phoneNumber:e,email:a}=t,n=f(t,hs);return null!=a&&a.length&&Object.assign(n,{email:a}),null!=e&&e.length&&Object.assign(n,{phoneNumber:e}),n},As=(t,e)=>{const a=f(v({},bn,e),ys);return Object.values(a).includes(t)};let ws;!function(t){t.USERS="USERS",t.STATS="STATS",t.UPDATE_USER="UPDATE_USER",t.DELETE_USER="DELETE_USER",t.RESEND_ACTIVATE_LINK="RESEND_ACTIVATE_LINK",t.RESEND_INVITATION_LINK="RESEND_INVITATION_LINK",t.ROLES_AND_PERMISSIONS="ROLES_AND_PERMISSIONS",t.CREATE_TOKEN_LINK="CREATE_TOKEN_LINK",t.GET_TOKEN_LINK="GET_TOKEN_LINK",t.UPDATE_TOKEN_LINK="UPDATE_TOKEN_LINK",t.DELETE_TOKEN_LINK="DELETE_TOKEN_LINK",t.CONFIG_TOKEN_LINK="CONFIG_TOKEN_LINK",t.CONFIG_TEMPORARY_USERS="CONFIG_TEMPORARY_USERS",t.UPDATE_USER_EXPIRATION_TIME="UPDATE_USER_EXPIRATION_TIME"}(ws||(ws={}));const Ts=["user"],Es=["callback","events"],Is=["user"],Os=["callback","events"],Ps=["user"],ks=["callback"],_s=["callback"],Rs=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.activateAccountState,e)},i=()=>{Cn(t,["auth","activateAccountState"],Bn)},o=e=>{Object.assign(t.auth.activateAccountState.activationStrategy,e)},r=async({loginResponse:e,events:a,onRedirectTo:o,routes:r})=>{const{user:l}=e,c=f(e,Ts);if(l.redirectLocation)window.location.href=l.redirectLocation;else if(Ss(l,t.root.appName)){s({step:jn.success});const t=await n.getMfaRequiredState(l);n.setAuthState(t),await En(1e3),o(r.loginUrl,{preserveQueryParams:!0})}else{var u;s({step:jn.success});const t={email:l.email,origin:Hn.ACTIVATION_LINK,id:l.id,tenantId:l.tenantId,name:l.name,createdAt:new Date};null==a||null==(u=a.userVerified)||u.call(a,t),Xn(Jn.USER_VERIFIED,t),n.afterAuthenticationStateUpdate(v({user:l},c),{isAuthenticated:!0}),await En(5e3),await n.afterAuthNavigation(),i()}};return{setActivateState:s,resetActivateState:i,setActivateStrategyState:o,activateAccount:async a=>{const{callback:n,events:i}=a,o=f(a,Es);s({loading:!0,submitting:!0});try{const a=U.for(t.root.appName).onRedirectTo,l=t.auth.routes,c=await e.auth.activateAccountV2(o),{user:u}=c,d=f(c,Is);s({submitting:!1}),await r({loginResponse:v({user:u},d),events:i,onRedirectTo:a,routes:l}),null==n||n(!0)}catch(t){s({loading:!1,error:Nn(t)})}},preActivateAccount:async a=>{const{userId:i,token:r}=a;s({loading:!0,step:jn.activating});try{t.auth.isAuthenticated&&await n.silentLogout();const a=await e.auth.getActivateAccountStrategy({userId:i,token:r});o({strategy:a,loading:!1,error:void 0}),a.shouldSetPassword&&s({loading:!1,step:jn.activatingForm})}catch(t){s({loading:!1,error:Nn(t)})}},getActivateAccountStrategy:async t=>{const{callback:a}=t,n=f(t,ks);o({loading:!0});try{const t=await e.auth.getActivateAccountStrategy(n);o({strategy:t,loading:!1,error:void 0}),null==a||a(t)}catch(t){o({loading:!1,error:Nn(t)})}},resendActivationEmail:async t=>{const{callback:a}=t,i=f(t,_s);n.setTeamLoader({key:ws.RESEND_ACTIVATE_LINK,value:i.email}),s({loading:!0});try{await e.auth.resendActivationEmail(i),s({loading:!1,error:void 0,resentEmail:!0}),null==a||a(!0)}catch(t){s({loading:!1,error:Nn(t)}),null==a||a(null,t)}finally{n.setTeamLoader({key:ws.RESEND_ACTIVATE_LINK,value:!1})}},activateAccountWithCode:async a=>{const{callback:n,events:i}=a,o=f(a,Os);s({loading:!0,submitting:!0});try{const a=U.for(t.root.appName).onRedirectTo,l=t.auth.routes,c=await e.auth.activateAccountWithOTC(o),{user:u}=c,d=f(c,Ps);s({submitting:!1}),await r({loginResponse:v({user:u},d),events:i,onRedirectTo:a,routes:l}),null==n||n(!0)}catch(t){s({submitting:!1,loading:!1,error:Nn(t),step:jn.activating})}}}},Us={loading:!1,error:void 0,unlockAccountSuccess:!1},Cs=t=>en(Us,t),Ls=(t,e,a)=>{const n=e=>{Object.assign(t.auth.unlockAccountState,e)};return{setUnlockAccountState:n,resetUnlockAccountState:()=>{Cn(t,["auth","activateAccountState"],Us)},unlockAccount:async a=>{const{token:s}=a,i=U.for(t.root.appName).onRedirectTo,o=t.auth.routes;n({loading:!0});try{await e.users.unlockMe({token:s}),n({loading:!1,error:void 0,unlockAccountSuccess:!0}),await En(5e3),i(o.loginUrl)}catch(t){n({loading:!1,error:Nn(t)})}}}},Ds={apiTokenType:null,searchValue:"",showAddTokenDialog:!1,createdByUserIdColumn:"show",deleteTokenDialog:{open:!1,clientId:""},successDialog:{open:!1,secret:"",clientId:""},loaders:{},apiTokensDataTenant:[],apiTokensDataUser:[],roles:[],permissions:[],errors:{}},Ns=t=>en(Ds,t);let Ms;!function(t){t.LOAD_API_TOKENS="LOAD_API_TOKENS",t.ADD_API_TOKEN="ADD_API_TOKEN",t.DELETE_API_TOKEN="DELETE_API_TOKEN"}(Ms||(Ms={}));const Fs=(t,e,a)=>{const n=e=>{Object.assign(t.auth.apiTokensState,{loaders:v({},t.auth.apiTokensState.loaders,{[e.key]:e.value})})},s=e=>{Object.assign(t.auth.apiTokensState,{errors:v({},t.auth.apiTokensState.errors,{[e.key]:e.value}),loaders:v({},t.auth.apiTokensState.loaders,{[e.key]:!1})})},i=e=>{Object.assign(t.auth.apiTokensState,e)};return{setApiTokensLoader:n,setApiTokensError:s,setApiTokensState:i,resetApiTokensState:()=>{Cn(t,["auth","apiTokensState"],Ds)},loadApiTokens:async t=>{null!=t&&t.silentLoading||n({key:Ms.LOAD_API_TOKENS,value:!0});try{var a;const[s=[],o=[]]=await Promise.all([e.auth.getUserApiTokensData(),e.auth.getTenantApiTokensData()]);i({apiTokensDataUser:s,apiTokensDataTenant:o}),n({key:Ms.LOAD_API_TOKENS,value:!1}),null==t||null==(a=t.callback)||a.call(t,!0)}catch(e){var o;s({key:Ms.LOAD_API_TOKENS,value:Nn(e)}),n({key:Ms.LOAD_API_TOKENS,value:!1}),null==t||null==(o=t.callback)||o.call(t,null,e)}},loadUserApiTokens:async t=>{null!=t&&t.silentLoading||n({key:Ms.LOAD_API_TOKENS,value:!0});try{var a,o;const[s=[],r]=await Promise.all([On((()=>e.auth.getUserApiTokensData()),null==t?void 0:t.retryConfig),On((()=>e.auth.getUserAccessTokensData()),null==t?void 0:t.retryConfig)]),l=(null!=(a=r.accessTokens)?a:[]).map((t=>v({},t,{type:M.AccessToken}))).concat(s.map((t=>v({},t,{type:M.ClientCredentials})))).sort(((t,e)=>new Date(e.createdAt)-new Date(t.createdAt)));i({apiTokensDataUser:null!=l?l:[]}),n({key:Ms.LOAD_API_TOKENS,value:!1}),null==t||null==(o=t.callback)||o.call(t,!0)}catch(e){var r;s({key:Ms.LOAD_API_TOKENS,value:Nn(e)}),n({key:Ms.LOAD_API_TOKENS,value:!1}),null==t||null==(r=t.callback)||r.call(t,null,e)}},loadTenantApiTokens:async t=>{null!=t&&t.silentLoading||n({key:Ms.LOAD_API_TOKENS,value:!0});try{var a,o;const[s=[],r]=await Promise.all([On((()=>e.auth.getTenantApiTokensData()),null==t?void 0:t.retryConfig),On((()=>e.auth.getTenantAccessTokensData()),null==t?void 0:t.retryConfig)]),l=(null!=(a=null==r?void 0:r.accessTokens)?a:[]).map((t=>v({},t,{type:M.AccessToken}))).concat(s.map((t=>v({},t,{type:M.ClientCredentials})))).sort(((t,e)=>new Date(e.createdAt)-new Date(t.createdAt)));i({apiTokensDataTenant:null!=l?l:[]}),n({key:Ms.LOAD_API_TOKENS,value:!1}),null==t||null==(o=t.callback)||o.call(t,!0)}catch(e){var r;s({key:Ms.LOAD_API_TOKENS,value:Nn(e)}),n({key:Ms.LOAD_API_TOKENS,value:!1}),null==t||null==(r=t.callback)||r.call(t,null,e)}},addTenantApiToken:async a=>{const{description:o,roleIds:r,expires:l,callback:c}=a,u=Ms.ADD_API_TOKEN;n({key:u,value:!0});try{const{policy:a}=t.auth.securityPolicyState.publicPolicy,n=(null==a?void 0:a.machineToMachineAuthStrategy)===M.AccessToken;let s,u=null;l&&(u=1440*l),s=n?await e.auth.createTenantAccessToken({description:o,expiresInMinutes:u,roleIds:r}):await e.auth.updateTenantApiTokensData({description:o,roleIds:r,expiresInMinutes:u}),i({showAddTokenDialog:!1}),await En(200);const d=n?M.AccessToken:M.ClientCredentials;t.auth.apiTokensState.apiTokensDataTenant.unshift(v({},s,{type:d})),t.auth.apiTokensState.successDialog={open:!0,secret:s.secret,clientId:n?void 0:s.clientId},null==c||c(null)}catch(t){s({key:u,value:Nn(t)}),null==c||c(null,t)}finally{n({key:u,value:!1})}},addUserApiToken:async a=>{const{description:o,expires:r,callback:l}=a,c=Ms.ADD_API_TOKEN;n({key:c,value:!0});try{const{policy:a}=t.auth.securityPolicyState.publicPolicy,n=(null==a?void 0:a.machineToMachineAuthStrategy)===M.AccessToken;let s,c=null;r&&(c=1440*r),s=n?await e.auth.createUserAccessToken({description:o,expiresInMinutes:c}):await e.auth.updateUserApiTokensData({description:o,expiresInMinutes:c}),i({showAddTokenDialog:!1}),await En(200);const u=n?M.AccessToken:M.ClientCredentials;t.auth.apiTokensState.apiTokensDataUser.unshift(v({},s,{type:u})),t.auth.apiTokensState.successDialog={open:!0,secret:s.secret,clientId:n?void 0:s.clientId},null==l||l(null)}catch(t){s({key:c,value:Nn(t)}),null==l||l(null,t)}finally{n({key:c,value:!1})}},deleteUserApiToken:async a=>{const o=Ms.DELETE_API_TOKEN;n({key:o,value:!0});try{const n=t.auth.apiTokensState.apiTokensDataUser;n.some((t=>t.id===a))?(await e.auth.deleteUserAccessToken({id:a}),i({apiTokensDataUser:n.filter((t=>t.id!==a)),deleteTokenDialog:{open:!1,id:a}})):(await e.auth.deleteUserApiToken({tokenId:a}),i({apiTokensDataUser:n.filter((t=>t.clientId!==a)),deleteTokenDialog:{open:!1,clientId:a}}))}catch(t){s({key:o,value:Nn(t)})}finally{n({key:o,value:!1})}},deleteTenantApiToken:async a=>{const o=Ms.DELETE_API_TOKEN;n({key:o,value:!0});try{const n=t.auth.apiTokensState.apiTokensDataTenant;n.some((t=>t.id===a))?(await e.auth.deleteTenantAccessToken({id:a}),i({apiTokensDataTenant:n.filter((t=>t.id!==a)),deleteTokenDialog:{open:!1,id:a}})):(await e.auth.deleteTenantApiToken({tokenId:a}),i({apiTokensDataTenant:n.filter((t=>t.clientId!==a)),deleteTokenDialog:{open:!1,id:a}}))}catch(t){s({key:o,value:Nn(t)})}finally{n({key:o,value:!1})}}}},xs={loading:!0,fetching:!0,error:null,userApplications:[],accountApplications:[]},$s=t=>en(xs,t),Gs=t=>{var e;return null!=(e=t.map((({appIds:t})=>t)).reduce(((t,e)=>(null==e||e.forEach((e=>{t&&!t.includes(e)&&t.push(e)})),t)),[]))?e:[]},js=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.applicationsState,e)},i=async({userIds:t,retryConfig:a})=>{try{const n=await On((()=>e.applications.getUsersApplicationsId({userIds:t})),a),s=Gs(n),i=await On((()=>e.applications.getApplicationsData({appIds:s})),a);return t.reduce(((t,e)=>{var a,s,o;const r=null==(a=n.find((t=>t.userId==e)))?void 0:a.appIds;return t[e]=[...i.filter((t=>t.accessType===Ja.FREE_ACCESS)),...null!=(s=null==r||null==(o=r.map((t=>i.find((e=>t===e.id)))))?void 0:o.filter((t=>!!t)))?s:[]],t}),{})}catch(t){s({error:Nn(t)})}},o="Assignment action failed. Try again or contact support.";return{setApplicationsState:s,resetApplicationsState:()=>{Cn(t,["auth","applicationsState"],xs)},loadUserApplications:async a=>{s({loading:!0,fetching:!0});try{var n,i;const o=null!=(n=null==(i=t.auth.user)?void 0:i.id)?n:"",r=null==a?void 0:a.retryConfig,l=await On((()=>e.applications.getUserApplicationsId({userId:o})),r),c=await On((()=>e.applications.getApplicationsData({appIds:l})),r);s({userApplications:c,fetching:!1,loading:!1})}catch(t){s({loading:!1,fetching:!1,error:Nn(t)})}},loadAccountApplications:async t=>{const a=null==t?void 0:t.retryConfig;s({loading:!0,fetching:!0});try{const t=await On((()=>e.applications.getTenantsApplications()),a),n=Gs(t),i=await On((()=>e.applications.getApplicationsData({appIds:n})),a),o=await On((()=>e.applications.getUsersOfApplications({appIds:n})),a),r=i.map((t=>{var e;return v({},t,{userIds:null==(e=o.find((e=>e.appId===t.id)))?void 0:e.userIds})}));s({accountApplications:r,fetching:!1,loading:!1})}catch(t){s({loading:!1,fetching:!1,error:Nn(t)})}},loadMultipleUsersApplications:i,assignUserToApps:async n=>{const{userId:i,appIds:r,callback:l}=n;try{var c,u,d,g,p,h,y,S,f;const n=null!=(c=null==(u=t.auth)||null==(d=u.user)?void 0:d.tenantId)?c:"";await e.applications.assignUserToApplications({userId:i,appIds:r,tenantId:n});const s=null==(g=t.auth)||null==(p=g.applicationsState)?void 0:p.accountApplications,o=null!=(h=null==(y=t.auth)||null==(S=y.teamState)?void 0:S.users)?h:[],m=null!=(f=null==s?void 0:s.filter((t=>r.includes(t.id))))?f:[];null!=m&&m.length&&a.setTeamState({users:o.map((t=>{var e;return t.id===i?v({},t,{applications:[...null!=(e=t.applications)?e:[],...m]}):t}))}),null==l||l(!0)}catch(t){s({error:Nn(t,o)}),null==l||l(!1)}},unassignUserFromApps:async n=>{const{userId:i,appIds:r,callback:l}=n;try{var c,u,d,g,p,h,y;const n=null!=(c=null==(u=t.auth)||null==(d=u.user)?void 0:d.tenantId)?c:"";await e.applications.unassignUserFromApplications({userId:i,appIds:r,tenantId:n});const s=null!=(g=null==(p=t.auth)||null==(h=p.teamState)?void 0:h.users)?g:[],o=null==(y=s.find((t=>t.id===i)))?void 0:y.applications;null!=o&&o.length&&r.length&&a.setTeamState({users:s.map((t=>t.id===i?v({},t,{applications:o.filter((t=>!r.includes(t.id)))}):t))}),null==l||l(!0)}catch(t){s({error:Nn(t,o)}),null==l||l(!1)}},assignNewUserToApps:async({appIds:a,user:s})=>{var i,o,r;const[l]=await n.getFeatureFlags(["multi-apps-admin-portal"]);if(!l)return;const c=null==(i=t.auth)||null==(o=i.applicationsState)?void 0:o.accountApplications,u=null!=(r=null==c?void 0:c.filter((t=>t.accessType===Ja.FREE_ACCESS)))?r:[];if(null!=a&&a.length){var d,g,p;const n=null!=(d=null==(g=t.auth)||null==(p=g.user)?void 0:p.tenantId)?d:"";return await e.applications.assignUserToApplications({userId:s.id,appIds:a,tenantId:n}),a.map((t=>{var e;return null!=(e=null==c?void 0:c.find((e=>e.id===t)))?e:[]})).concat(u)}return u},mapUsersWithApplicationData:async({shouldLoadApps:t,users:e,retryConfig:n})=>{const[s]=await a.getFeatureFlags(["multi-apps-admin-portal"]);if(!s||!t)return e;const o=e.map((t=>t.id)),r=await i({userIds:o,retryConfig:n});return r?e.map((t=>null!=r&&r[t.id]?v({},t,{applications:r[t.id]}):t)):e}}},Bs={loading:!0,error:null},Vs=t=>en(Bs,t),Ws=["callback"],Hs=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.customLoginState,e)},i=async()=>{var e,a,n,s,i;return t.auth.isAuthenticated?null!=(s=null==(i=t.auth.tenantsState.activeTenant)?void 0:i.hasCustomLogin)&&s:!!(null==(e=await(null==(a=U.for(t.root.appName).getContext())||null==(n=a.tenantResolver)?void 0:n.call(a)))?void 0:e.tenant)};return{setCustomLoginState:s,resetCustomLoginState:()=>{Cn(t,["auth","customLoginState"],Bs)},loadTenantMetadata:async()=>{s({loading:!0});try{const t=await e.metadata.getAdminBoxMetadata();s({tenantMetadata:t,loading:!1})}catch(t){s({loading:!1,error:Nn(t)})}},updateTenantMetadata:async t=>{const{callback:a}=t,n=f(t,Ws);try{s({error:null,saving:!0});const t=fs(n);if(0===t.length)throw new Error("No changes to update");await e.metadata.updateAdminBoxMetadata({actions:t});const i=await e.metadata.getAdminBoxMetadata();s({tenantMetadata:i,saving:!1}),null==a||a(!0)}catch(t){s({error:Nn(t,"No changes to update"),saving:!1}),null==a||a(null,t)}},customLoginEnabled:i,loadCustomLoginRoutes:async a=>{try{var o,r,l;if(!await i())return void(null==a||null==(l=a.callback)||l.call(a,!0));const u=t.auth.isAuthenticated,{getSettings:d,getPublicSettings:g}=e.accountSettings,{applicationUrl:p}=await On(u?d:g,null==a?void 0:a.retryConfig);var c;if(!p)return void(null==a||null==(c=a.callback)||c.call(a,!0));const h=t.auth.routes,y=null!=(o=ts(p))?o:"";n.setAuthState({routes:v({},h,{customLoginAuthenticatedUrl:p,customLoginUrl:h.loginUrl+y})}),s({customLoginSearchParams:null!=y?y:void 0}),null==a||null==(r=a.callback)||r.call(a,!0)}catch(t){var u;null==a||null==(u=a.callback)||u.call(a,null,t)}}}};let zs;!function(t){t.forgotPassword="forgotPassword",t.success="success"}(zs||(zs={}));const Ks={step:zs.forgotPassword,loading:!1,email:"",passwordConfig:null},qs=t=>en(Ks,t),Js=["callback"],Ys=(t,e,a)=>{const n=e=>{Object.assign(t.auth.forgotPasswordState,e)};return{setForgotPasswordState:n,resetForgotPasswordState:()=>{Cn(t,["auth","forgotPasswordState"],Ks)},forgotPassword:async t=>{n({loading:!0});try{var a;await e.auth.forgotPassword(t),n({loading:!1,error:void 0,step:zs.success}),null==(a=t.callback)||a.call(t,!0)}catch(e){var s;n({loading:!1,error:Nn(e,"Unknown error occurred")}),null==(s=t.callback)||s.call(t,!1,e)}},resetPassword:async t=>{const{callback:a}=t,s=f(t,Js);n({loading:!0});try{await e.auth.resetPassword(s),n({loading:!1,error:void 0,step:zs.success}),null==a||a(!0)}catch(t){n({loading:!1,error:Nn(t)}),null==a||a(!1,t)}},loadPasswordConfig:async t=>{n({loading:!0});try{const a=await e.auth.loadPasswordConfig(t);n({loading:!1,passwordConfig:a})}catch(t){n({loading:!1,error:Nn(t)})}}}};let Xs;!function(t){t.success="success",t.notification="notification"}(Xs||(Xs={}));const Qs={step:Xs.notification},Zs=t=>en(Qs,t),ti=(t,e,a)=>({setStep:e=>{var a;a={step:e},Object.assign(t.auth.passwordRotationState,a)}}),ei={loaders:{},errors:{},groups:[],groupsConfiguration:{}},ai=t=>en(ei,t);let ni,si;!function(t){t.CREATE_GROUP="CREATE_GROUP",t.GET_GROUP="GET_GROUP",t.GET_GROUPS="GET_GROUPS",t.DELETE_GROUP="DELETE_GROUP",t.UPDATE_GROUP="UPDATE_GROUP",t.ADD_USERS_TO_GROUP="ADD_USERS_TO_GROUP",t.DELETE_USERS_FROM_GROUP="DELETE_USERS_FROM_GROUP",t.ADD_ROLES_TO_GROUP="ADD_ROLES_TO_GROUP",t.DELETE_ROLES_FROM_GROUP="DELETE_ROLES_FROM_GROUP",t.GET_GROUP_CONFIGURATION="GET_GROUP_CONFIGURATION",t.UPDATE_GROUP_CONFIGURATION="UPDATE_GROUP_CONFIGURATION",t.GET_TEAM_USERS="GET_TEAM_USERS"}(ni||(ni={})),function(t){t.roles="roles",t.users="users",t.rolesAndUsers="rolesAndUsers"}(si||(si={}));const ii=["roleIds","userIds"],oi=(t,e,a)=>{const n=e=>{Object.assign(t.auth.groupsState,{loaders:v({},t.auth.groupsState.loaders,{[e.key]:e.value})})},s=e=>{Object.assign(t.auth.groupsState,{errors:v({},t.auth.groupsState.errors,{[e.key]:e.value}),loaders:v({},t.auth.groupsState.loaders,{[e.key]:!1})})},i=e=>{Object.assign(t.auth.groupsState,e)},o=async a=>{const o=ni.GET_GROUPS,r=t.auth.groupsState;n({key:o,value:!0});try{const{groups:t}=await On((()=>e.groups.getGroups({_groupsRelations:si.rolesAndUsers})),null==a?void 0:a.retryConfig);i(v({groups:t},r.selectedGroup&&{selectedGroup:t.find((t=>{var e;return t.id===(null==(e=r.selectedGroup)?void 0:e.id)}))}))}catch(t){s({key:o,value:Nn(t)})}finally{n({key:o,value:!1})}},r=async t=>{const a=ni.ADD_ROLES_TO_GROUP;n({key:a,value:!0});try{var i;await e.groups.addRolesToGroup(t.groupId,{roleIds:t.roleIds}),await o(),null==t||null==(i=t.callback)||i.call(t,!0)}catch(e){var r;s({key:a,value:Nn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},l=async t=>{const a=ni.ADD_USERS_TO_GROUP;n({key:a,value:!0});try{var i;await e.groups.addUsersToGroup(t.groupId,{userIds:t.userIds}),await o(),null==t||null==(i=t.callback)||i.call(t,!0)}catch(e){var r;null==t||null==(r=t.callback)||r.call(t,!1),s({key:a,value:Nn(e)})}finally{n({key:a,value:!1})}},c=async t=>{const a=ni.GET_GROUP_CONFIGURATION;n({key:a,value:!0});try{const a=await On((()=>e.groups.getGroupConfiguration()),null==t?void 0:t.retryConfig);i({groupsConfiguration:a})}catch(t){s({key:a,value:Nn(t)})}finally{n({key:a,value:!1})}};return{setUsersGroupsLoader:n,setUsersGroupsError:s,setGroupsState:i,resetUsersGroupsState:()=>{Cn(t,["auth","groupsState"],ei)},loadGroups:o,getGroupById:async t=>{const a=ni.GET_GROUP;n({key:a,value:!0});try{const a=await e.groups.getGroupById({groupId:t.groupId},{_groupsRelations:si.rolesAndUsers});i({selectedGroup:a})}catch(t){s({key:a,value:Nn(t)})}finally{n({key:a,value:!1})}},createGroup:async t=>{const a=ni.CREATE_GROUP,{roleIds:i,userIds:c}=t,u=f(t,ii);n({key:a,value:!0});try{var d;const a=await e.groups.createGroup(v({name:u.name},!!u.description&&{description:u.description},{color:u.color}));null!=c&&c.length&&l({groupId:a.id,userIds:c}),null!=i&&i.length&&r({groupId:a.id,roleIds:i}),await o(),null==t||null==(d=t.callback)||d.call(t,!0)}catch(e){var g;s({key:a,value:Nn(e)}),null==t||null==(g=t.callback)||g.call(t,!1)}finally{n({key:a,value:!1})}},updateGroup:async t=>{const a=ni.UPDATE_GROUP;n({key:a,value:!0});try{var i;await e.groups.updateGroup(t),await o(),null==t||null==(i=t.callback)||i.call(t,!0)}catch(e){var r;s({key:a,value:Nn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},deleteGroup:async t=>{const a=ni.DELETE_GROUP;n({key:a,value:!0});try{var i;await e.groups.deleteGroup(t.groupId),await o(),null==t||null==(i=t.callback)||i.call(t,!0)}catch(e){var r;s({key:a,value:Nn(e)}),null==t||null==(r=t.callback)||r.call(t,!1,e)}finally{n({key:a,value:!1})}},addRolesToGroup:r,deleteRolesFromGroup:async t=>{const a=ni.DELETE_ROLES_FROM_GROUP;n({key:a,value:!0});try{var i;await e.groups.deleteRolesFromGroup(t.groupId,{roleIds:t.roleIds}),await o(),null==t||null==(i=t.callback)||i.call(t,!0)}catch(e){var r;s({key:a,value:Nn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},addUsersToGroup:l,deleteUsersFromGroup:async t=>{const a=ni.DELETE_USERS_FROM_GROUP;n({key:a,value:!0});try{var i;await e.groups.deleteUsersFromGroup(t.groupId,{userIds:t.userIds}),await o(),null==t||null==(i=t.callback)||i.call(t,!0)}catch(e){var r;s({key:a,value:Nn(e)}),null==t||null==(r=t.callback)||r.call(t,!1)}finally{n({key:a,value:!1})}},getGroupConfiguration:c,updateGroupConfiguration:async t=>{const a=ni.UPDATE_GROUP_CONFIGURATION;n({key:a,value:!0});try{await e.groups.updateGroupConfiguration(t),await c()}catch(t){s({key:a,value:Nn(t)})}finally{n({key:a,value:!1})}},getTeamUsers:async t=>{const a=ni.GET_TEAM_USERS;n({key:a,value:!0});try{const{items:a}=await e.users.getUsersV2({_filter:t.filter,_offset:t.pageOffset,_limit:t.pageSize,_includeSubTenants:!1});i({teamUsers:a})}catch(t){s({key:a,value:Nn(t)})}finally{n({key:a,value:!1})}}}},ri={addGroupDialogState:{loading:!1,open:!1},editGroupDialogState:{loading:!1,open:!1},deleteGroupDialogState:{loading:!1,open:!1},addMembersToGroupDialogState:{loading:!1,open:!1,userIds:[]},deleteMemberFromGroupDialogState:{loading:!1,open:!1}},li=t=>en(ri,t),ci=(t,e,a)=>({setGroupsDialogsState:e=>{Object.assign(t.auth.groupsDialogsState,e)},resetGroupsDialogsState:()=>{Cn(t,["auth","groupsDialogsState"],ri)},openAddGroupDialog:()=>{t.auth.groupsDialogsState.addGroupDialogState.open=!0},closeAddGroupDialog:()=>{Object.assign(t.auth.groupsDialogsState.addGroupDialogState,{open:!1,group:void 0})},openAddMembersToGroupDialog:()=>{t.auth.groupsDialogsState.addMembersToGroupDialogState.open=!0},closeAddMembersToGroupDialog:()=>{Object.assign(t.auth.groupsDialogsState.addMembersToGroupDialogState,{open:!1,userIds:[]})},openEditGroupDialog:e=>{Object.assign(t.auth.groupsDialogsState.editGroupDialogState,v({},e,{open:!0}))},closeEditGroupDialog:()=>{Object.assign(t.auth.groupsDialogsState.editGroupDialogState,{open:!1,loading:!1,group:void 0})},openDeleteGroupDialog:e=>{Object.assign(t.auth.groupsDialogsState.deleteGroupDialogState,v({},e,{open:!0}))},closeDeleteGroupDialog:()=>{Object.assign(t.auth.groupsDialogsState.deleteGroupDialogState,{open:!1,loading:!1,group:void 0})},openDeleteMemberFromGroupDialog:e=>{Object.assign(t.auth.groupsDialogsState.deleteMemberFromGroupDialogState,e)},closeDeleteMemberFromGroupDialog:()=>{Object.assign(t.auth.groupsDialogsState.deleteMemberFromGroupDialogState,{open:!1,userId:void 0,email:void 0})}});let ui;!function(t){t.impersonating="impersonating",t.success="success"}(ui||(ui={}));const di={step:ui.impersonating,loading:!1},gi=t=>en(di,t),pi=["callback","events"],hi=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.impersonateState,e)},i=()=>{Cn(t,["auth","impersonateState"],di)};return{setImpersonateState:s,resetImpersonateState:i,impersonate:async t=>{const{callback:a}=t,o=f(t,pi);s({loading:!0});try{await e.impersonate.impersonate(o),s({step:ui.success}),await En(1e3),await n.afterAuthNavigation({preventRedirectUrlOriginCleaning:!0}),i(),null==a||a(!0)}catch(t){s({loading:!1,error:Nn(t)})}}}},yi={flow:Sn.Login,step:yn.preLogin,loading:!1,email:"",tenants:[]},Si=t=>en(yi,t),vi=(t,e,a)=>{const n=a;const s=async(e,a={})=>{const{customLoginAuthenticatedUrl:n,forceStepUpUrl:s,shouldStepUpDuringLogin:i,preventRedirectUrlOriginCleaning:o=!1}=a,r=t.auth.onRedirectTo;let l;if(s)l=s;else{var c;if(i){const t=window.localStorage.getItem(An);t&&!Qn(t)&&(l=t)}l||(l=await async function({customLoginAuthenticatedUrl:e,preventRedirectUrlOriginCleaning:a}){const{routes:n,includeQueryParam:s=!1,enforceRedirectToSameSite:i=!1,allowedRedirectOrigins:o=[]}=t.auth,r=window.localStorage.getItem(An);if(e&&!r)return es(e,a);const{authenticatedUrl:l,loginUrl:c,logoutUrl:u,socialLoginCallbackUrl:d,activateUrl:g,activateWithOTCUrl:p}=n;let h=r;h&&![c,u,d,g,p].includes(h)||(h=l);const y=Zn({authenticatedUrl:h,includeQueryParam:s,enforceRedirectToSameSite:i,allowedRedirectOrigins:o});return a?y:(S=y).startsWith(null==(v=window)?void 0:v.location.origin)?S.replace(null==(f=window)?void 0:f.location.origin,""):S;var S,v,f}({customLoginAuthenticatedUrl:n,preventRedirectUrlOriginCleaning:o})),null==(c=window)||c.localStorage.removeItem(An)}await En(200),await e(),r(l,{refresh:l.startsWith("http")})};return{afterAuthNavigationUtil:s,afterAuthNavigation:async e=>{var a,i;const{customLoginAuthenticatedUrl:o,stepUpUrl:r}=t.auth.routes,l=null==(a=window)?void 0:a.localStorage.getItem(pn),c=t.auth.user;var u;if(l&&(null==(u=window)||u.localStorage.removeItem(pn)),r&&l&&!ds(c))return s(n.resetLoginState,{forceStepUpUrl:r});let d=o;var g;return o||(await n.loadCustomLoginRoutes(),d=null==(g=t.auth.routes)?void 0:g.customLoginAuthenticatedUrl),s(n.resetLoginState,{customLoginAuthenticatedUrl:d,shouldStepUpDuringLogin:!!l,preventRedirectUrlOriginCleaning:null!=(i=null==e?void 0:e.preventRedirectUrlOriginCleaning)&&i})},afterStepUpAuthNavigation:async()=>s(n.resetStepUpState),afterAuthenticationStateUpdate:function({user:e,tenants:a=[],activeTenant:s},i={}){const o=t.auth.tenantsState;n.setAuthState(v({user:e,tenantsState:v({},o,{tenants:a,activeTenant:s,loading:!1})},i))}}},fi=["callback"],mi=["callback"],bi=["callback"],Ai=["callback","deviceId"],wi=["callback","deviceId"],Ti="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",Ei=new Uint8Array(256);for(let t=0;t<64;t++)Ei[Ti.charCodeAt(t)]=t;const Ii=t=>{const e=new Uint8Array(t),a=e.length;let n,s="";for(n=0;n<a;n+=3)s+=Ti[e[n]>>2],s+=Ti[(3&e[n])<<4|e[n+1]>>4],s+=Ti[(15&e[n+1])<<2|e[n+2]>>6],s+=Ti[63&e[n+2]];return a%3==2?s=s.substring(0,s.length-1):a%3==1&&(s=s.substring(0,s.length-2)),s},Oi=t=>{const e=.75*t.length,a=t.length;let n,s,i,o,r,l=0;const c=new Uint8Array(e);for(n=0;n<a;n+=4)s=Ei[t.charCodeAt(n)],i=Ei[t.charCodeAt(n+1)],o=Ei[t.charCodeAt(n+2)],r=Ei[t.charCodeAt(n+3)],c[l++]=s<<2|i>>4,c[l++]=(15&i)<<4|o>>2,c[l++]=(3&o)<<6|63&r;return c.buffer};function Pi(t,e="file"){const a=t.match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/);if(null==a)return null;const n=`image/${a[1]}`,s=((t,e)=>{const a=atob(t),n=[];for(let t=0;t<a.length;t+=512){const e=a.slice(t,t+512),s=new Array(e.length);for(let t=0;t<e.length;t++)s[t]=e.charCodeAt(t);n.push(new Uint8Array(s))}return new Blob(n,{type:e})})(a[2],n),i=new FormData;return i.append(e,new File([s],e,{type:n})),i}const ki=t=>{if(t instanceof Array){const e=[];for(const a of t)e.push(ki(a));return e}if(t instanceof ArrayBuffer)return Ii(t);if(t instanceof Object){const e={};for(const a in t)e[a]=ki(t[a]);return e}return t},_i=t=>new Promise(((e,a)=>{const n=new FileReader;n.readAsText(t),n.onload=()=>e(n.result),n.onerror=a})),Ri=["callback","deviceId"],Ui=["callback","deviceId"],Ci="input is invalid type",Li="undefined"!=typeof ArrayBuffer,Di="0123456789abcdef".split(""),Ni=[-2147483648,8388608,32768,128],Mi=[24,16,8,0],Fi=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],xi=["hex","array","digest","arrayBuffer"],$i=[];Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),Li&&!ArrayBuffer.isView&&(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});const Gi=function(t){return function(e){const a=new Bi(!0).update(e);return null==a?void 0:a[t]()}},ji=function(t){return function(e,a){const n=new Vi(e,!0).update(a);return null==n?void 0:n[t]()}};class Bi{constructor(t=!1){this.blocks=void 0,this.h0=void 0,this.h1=void 0,this.h2=void 0,this.h3=void 0,this.h4=void 0,this.h5=void 0,this.h6=void 0,this.h7=void 0,this.block=void 0,this.start=void 0,this.bytes=void 0,this.hBytes=void 0,this.finalized=void 0,this.hashed=void 0,this.first=void 0,this.lastByteIndex=void 0,this.sharedMemory=!1,this.toString=()=>this.hex(),this.array=()=>Bi.prototype.digest(),t?($i[0]=$i[16]=$i[1]=$i[2]=$i[3]=$i[4]=$i[5]=$i[6]=$i[7]=$i[8]=$i[9]=$i[10]=$i[11]=$i[12]=$i[13]=$i[14]=$i[15]=0,this.blocks=$i):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225,this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.sharedMemory=t}update(t){if(this.finalized)return;let e;const a=typeof t;if("string"!==a){if("object"!==a)throw new Error(Ci);if(null===t)throw new Error(Ci);if(Li&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||Li&&ArrayBuffer.isView(t)))throw new Error(Ci);e=!0}let n,s,i=0;const o=t.length,r=this.blocks;for(;i<o;){if(this.hashed&&(this.hashed=!1,r[0]=this.block,r[16]=r[1]=r[2]=r[3]=r[4]=r[5]=r[6]=r[7]=r[8]=r[9]=r[10]=r[11]=r[12]=r[13]=r[14]=r[15]=0),e)for(s=this.start;i<o&&s<64;++i)r[s>>2]|=t[i]<<Mi[3&s++];else for(s=this.start;i<o&&s<64;++i)n=t.charCodeAt(i),n<128?r[s>>2]|=n<<Mi[3&s++]:n<2048?(r[s>>2]|=(192|n>>6)<<Mi[3&s++],r[s>>2]|=(128|63&n)<<Mi[3&s++]):n<55296||n>=57344?(r[s>>2]|=(224|n>>12)<<Mi[3&s++],r[s>>2]|=(128|n>>6&63)<<Mi[3&s++],r[s>>2]|=(128|63&n)<<Mi[3&s++]):(n=65536+((1023&n)<<10|1023&t.charCodeAt(++i)),r[s>>2]|=(240|n>>18)<<Mi[3&s++],r[s>>2]|=(128|n>>12&63)<<Mi[3&s++],r[s>>2]|=(128|n>>6&63)<<Mi[3&s++],r[s>>2]|=(128|63&n)<<Mi[3&s++]);this.lastByteIndex=s,this.bytes+=s-this.start,s>=64?(this.block=r[16],this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}finalize(){if(this.finalized)return;this.finalized=!0;const t=this.blocks,e=this.lastByteIndex;t[16]=this.block,t[e>>2]|=Ni[3&e],this.block=t[16],e>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}hash(){let t,e,a,n,s,i,o,r,l,c,u,d=this.h0,g=this.h1,p=this.h2,h=this.h3,y=this.h4,S=this.h5,v=this.h6,f=this.h7;const m=this.blocks;for(t=16;t<64;++t)s=m[t-15],e=(s>>>7|s<<25)^(s>>>18|s<<14)^s>>>3,s=m[t-2],a=(s>>>17|s<<15)^(s>>>19|s<<13)^s>>>10,m[t]=m[t-16]+e+m[t-7]+a|0;for(u=g&p,t=0;t<64;t+=4)this.first?(r=704751109,s=m[0]-210244248,f=s-1521486534|0,h=s+143694565|0,this.first=!1):(e=(d>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),a=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7),r=d&g,n=r^d&p^u,o=y&S^~y&v,s=f+a+o+Fi[t]+m[t],i=e+n,f=h+s|0,h=s+i|0),e=(h>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10),a=(f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7),l=h&d,n=l^h&g^r,o=f&y^~f&S,s=v+a+o+Fi[t+1]+m[t+1],i=e+n,v=p+s|0,p=s+i|0,e=(p>>>2|p<<30)^(p>>>13|p<<19)^(p>>>22|p<<10),a=(v>>>6|v<<26)^(v>>>11|v<<21)^(v>>>25|v<<7),c=p&h,n=c^p&d^l,o=v&f^~v&y,s=S+a+o+Fi[t+2]+m[t+2],i=e+n,S=g+s|0,g=s+i|0,e=(g>>>2|g<<30)^(g>>>13|g<<19)^(g>>>22|g<<10),a=(S>>>6|S<<26)^(S>>>11|S<<21)^(S>>>25|S<<7),u=g&p,n=u^g&h^c,o=S&v^~S&f,s=y+a+o+Fi[t+3]+m[t+3],i=e+n,y=d+s|0,d=s+i|0;this.h0=this.h0+d|0,this.h1=this.h1+g|0,this.h2=this.h2+p|0,this.h3=this.h3+h|0,this.h4=this.h4+y|0,this.h5=this.h5+S|0,this.h6=this.h6+v|0,this.h7=this.h7+f|0}hex(){this.finalize();const t=this.h0,e=this.h1,a=this.h2,n=this.h3,s=this.h4,i=this.h5,o=this.h6,r=this.h7;let l=Di[t>>28&15]+Di[t>>24&15]+Di[t>>20&15]+Di[t>>16&15]+Di[t>>12&15]+Di[t>>8&15]+Di[t>>4&15]+Di[15&t]+Di[e>>28&15]+Di[e>>24&15]+Di[e>>20&15]+Di[e>>16&15]+Di[e>>12&15]+Di[e>>8&15]+Di[e>>4&15]+Di[15&e]+Di[a>>28&15]+Di[a>>24&15]+Di[a>>20&15]+Di[a>>16&15]+Di[a>>12&15]+Di[a>>8&15]+Di[a>>4&15]+Di[15&a]+Di[n>>28&15]+Di[n>>24&15]+Di[n>>20&15]+Di[n>>16&15]+Di[n>>12&15]+Di[n>>8&15]+Di[n>>4&15]+Di[15&n]+Di[s>>28&15]+Di[s>>24&15]+Di[s>>20&15]+Di[s>>16&15]+Di[s>>12&15]+Di[s>>8&15]+Di[s>>4&15]+Di[15&s]+Di[i>>28&15]+Di[i>>24&15]+Di[i>>20&15]+Di[i>>16&15]+Di[i>>12&15]+Di[i>>8&15]+Di[i>>4&15]+Di[15&i]+Di[o>>28&15]+Di[o>>24&15]+Di[o>>20&15]+Di[o>>16&15]+Di[o>>12&15]+Di[o>>8&15]+Di[o>>4&15]+Di[15&o];return l+=Di[r>>28&15]+Di[r>>24&15]+Di[r>>20&15]+Di[r>>16&15]+Di[r>>12&15]+Di[r>>8&15]+Di[r>>4&15]+Di[15&r],l}digest(){this.finalize();const t=this.h0,e=this.h1,a=this.h2,n=this.h3,s=this.h4,i=this.h5,o=this.h6,r=this.h7,l=[t>>24&255,t>>16&255,t>>8&255,255&t,e>>24&255,e>>16&255,e>>8&255,255&e,a>>24&255,a>>16&255,a>>8&255,255&a,n>>24&255,n>>16&255,n>>8&255,255&n,s>>24&255,s>>16&255,s>>8&255,255&s,i>>24&255,i>>16&255,i>>8&255,255&i,o>>24&255,o>>16&255,o>>8&255,255&o];return l.push(r>>24&255,r>>16&255,r>>8&255,255&r),l}arrayBuffer(){this.finalize();const t=new ArrayBuffer(32),e=new DataView(t);return e.setUint32(0,this.h0),e.setUint32(4,this.h1),e.setUint32(8,this.h2),e.setUint32(12,this.h3),e.setUint32(16,this.h4),e.setUint32(20,this.h5),e.setUint32(24,this.h6),e.setUint32(28,this.h7),t}}class Vi extends Bi{constructor(t,e=!1){let a;super(e),this.inner=void 0,this.oKeyPad=void 0;const n=typeof t;if("string"===n){const e=[],n=t.length;let s,i=0;for(a=0;a<n;++a)s=t.charCodeAt(a),s<128?e[i++]=s:s<2048?(e[i++]=192|s>>6,e[i++]=128|63&s):s<55296||s>=57344?(e[i++]=224|s>>12,e[i++]=128|s>>6&63,e[i++]=128|63&s):(s=65536+((1023&s)<<10|1023&t.charCodeAt(++a)),e[i++]=240|s>>18,e[i++]=128|s>>12&63,e[i++]=128|s>>6&63,e[i++]=128|63&s);t=e}else{if("object"!==n)throw new Error(Ci);if(null===t)throw new Error(Ci);if(Li&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||Li&&ArrayBuffer.isView(t)))throw new Error(Ci)}var s;t.length>64&&(t=null==(s=new Bi(!0).update(t))?void 0:s.array());const i=[],o=[];for(a=0;a<64;++a){const e=t[a]||0;i[a]=92^e,o[a]=54^e}Bi.call(this,e),this.update(o),this.oKeyPad=i,this.inner=!0,this.sharedMemory=e}finalize(){if(super.finalize(),this.inner){this.inner=!1;const t=this.array();Bi.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(t),Bi.prototype.finalize.call(this)}}}const Wi=function(){const t=Gi("hex");t.create=function(){return new Bi},t.update=function(e){return t.create().update(e)};for(let e=0;e<xi.length;++e){const a=xi[e];t[a]=Gi(a)}return t}(),Hi=function(){const t=ji("hex");t.create=function(t){return new Vi(t)},t.update=function(e,a){return t.create(e).update(a)};for(let e=0;e<xi.length;++e){const a=xi[e];t[a]=ji(a)}return t}();async function zi(t){const e=Wi.digest((new TextEncoder).encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}async function Ki(t){const e=await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}async function qi(t){var e,a;return null!=(e=window.crypto)&&null!=(a=e.subtle)&&a.digest?Ki(t):(console.warn("Generating CodeChallenge in non-secure domain:",window.location.origin),zi(t))}function Ji(t=16){let e="";for(let a=0;a<t;a++)e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random()));return e}var Yi=a(8792),Xi=a.n(Yi),Qi=a(5875);const Zi=(t="default")=>{if(!U.for(t).shouldLoadEntitlements())throw new Error("You must first enable entitlements via Frontegg options to use this function")},to=(t,e,a,n,s="default")=>(Zi(s),(0,Qi.Me)(e,t,a)),eo=(t,e,a,n,s="default")=>(Zi(s),(0,Qi.a_)(e,t,a)),ao=(t,e,a,n,s="default")=>"permissionKey"in e?to(t,e.permissionKey,a,n,s):eo(t,e.featureKey,a,n,s);function no(t,e){return Xi()(t,e)}let so,io;!function(t){t.LOAD_SSO_CONFIGURATIONS="LOAD_SSO_CONFIGURATIONS",t.SAVE_SSO_CONFIGURATION="SAVE_SSO_CONFIGURATION",t.UPDATE_SSO_CONFIGURATION="UPDATE_SSO_CONFIGURATION",t.SAVE_SSO_CONFIGURATION_BY_METADATA="SAVE_SSO_CONFIGURATION_BY_METADATA",t.UPDATE_SSO_CONFIGURATION_BY_METADATA="UPDATE_SSO_CONFIGURATION",t.DELETE_SSO_CONFIGURATION="DELETE_SSO_CONFIGURATION",t.SAVE_SSO_DOMAIN="SAVE_SSO_DOMAIN",t.DELETE_SSO_DOMAIN="DELETE_SSO_DOMAIN",t.VALIDATE_SSO_DOMAIN="VALIDATE_SSO_DOMAIN",t.UPDATE_SSO_DEFAULT_ROLES="UPDATE_SSO_DEFAULT_ROLES",t.DELETE_SSO_GROUPS="DELETE_SSO_GROUPS",t.SAVE_SSO_GROUPS="SAVE_SSO_GROUPS",t.GET_SSO_AUTHORIZATION_ROLES="GET_SSO_AUTHORIZATION_ROLES"}(so||(so={})),function(t){t.Saml="saml",t.Okta="okta",t.Azure="azure",t.Google="google",t.Oidc="oidc"}(io||(io={}));const oo=["callback","error"],ro=["callback"],lo=["callback"],co=["callback"],uo=["callback"],go=["callback","events"],po=["callback"],ho=["callback"],yo=["user"],So=["callback"],vo=["callback"],fo=["callback"],mo=["callback"],bo=["callback"],Ao=["callback"],wo=(t,e,a)=>{const n=a,s=U.for(t.root.appName),i=e=>{var a;const{routes:n,loginState:s}=t.auth,i=null!=(a=localStorage.getItem("register-quick-login"))?a:s.quickLoginToRegister;return i&&"true"!==localStorage.getItem(`${e.id}-${i}`)&&!window.location.pathname.endsWith(n.logoutUrl)},o=async()=>{t.auth.hostedLoginBox?await(async()=>{const a=t.auth.user;if(null==a||!a.refreshToken)return s.setAccessToken(null),s.setUser(null),void n.setAuthState({user:null,isAuthenticated:!1});try{const t={grant_type:"refresh_token",refresh_token:null==a?void 0:a.refreshToken},s=await e.auth.exchangeOAuthTokensV2(t),i=await r(s.user);n.afterAuthenticationStateUpdate(v({},s,{user:i}),{isAuthenticated:!0})}catch(t){s.setAccessToken(null),s.setUser(null),n.setAuthState({user:null,isAuthenticated:!1})}})():await(async()=>{try{const{routes:s,loginState:o,onRedirectTo:c}=t.auth,{user:u,tenants:d=[],activeTenant:g}=await e.auth.refreshTokenV3();if(Ss(u,t.root.appName)){const t=await n.getMfaRequiredState(u);n.setAuthState(t),c(s.loginUrl,{preserveQueryParams:!0})}else{var a;u.id&&localStorage.setItem("userId",u.id);const t=null!=(a=localStorage.getItem("register-quick-login"))?a:o.quickLoginToRegister,e=i(u),s=await r(u);n.afterAuthenticationStateUpdate({user:s,tenants:d,activeTenant:g},{loginState:v({},o,{quickLoginToRegister:t,flow:e?Sn.RegisterQuickLogin:Sn.Login}),isAuthenticated:!0}),await l(e)}}catch(t){s.setAccessToken(null),s.setUser(null),n.setAuthState({user:void 0,isAuthenticated:!1})}})()},r=async e=>{var a;const n=null==(a=t.auth.user)?void 0:a.entitlements;return no(n,null==e?void 0:e.entitlements)?v({},e,{entitlements:n}):e},l=async e=>{var a;const s=new URL(null==(a=window)?void 0:a.location.href),{routes:i,loginState:o,onRedirectTo:r}=t.auth,l=s.searchParams.get("invitationToken"),c=[i.socialLoginCallbackUrl,i.oidcRedirectUrl,i.samlCallbackUrl,i.magicLinkCallbackUrl];l||c.push(i.loginUrl,i.signUpUrl),e?r(i.loginUrl):c.some((t=>t&&window.location.pathname.endsWith(t)))&&(o.isNewUser&&i.signUpSuccessUrl&&i.socialLoginCallbackUrl===window.location.pathname?r(i.signUpSuccessUrl,{refresh:i.signUpSuccessUrl.startsWith("http")}):await n.afterAuthNavigation())},c=async t=>{try{var a;const{isActive:s}=await On(e.auth.getSSOPublicConfiguration,null==t?void 0:t.retryConfig);n.setAuthState({isSSOAuth:s}),null==t||null==(a=t.callback)||a.call(t,{isSSOAuth:s})}catch(e){var s;n.setAuthState({isSSOAuth:!1}),null==t||null==(s=t.callback)||s.call(t,null,e)}},u=async t=>{let a;try{var s;const n=await On(e.metadata.getSamlMetadata,null==t?void 0:t.retryConfig);a=null==n||null==(s=n.configuration)?void 0:s.acsUrl}catch(t){console.error(t)}n.setAuthState({ssoACS:a})},d=e=>{Object.assign(t.auth.loginState,e)},g=t=>Pn({callback:(e,a)=>{!a||a.statusCode<500||n.setErrorByRequestName({requestName:t,traceId:kn(a)})}}),p=async e=>{let{callback:a,error:s}=e,i=f(e,oo);const o=t.auth.securityPolicyState.publicPolicy.policy;if(null==o||!o.authStrategy)return n.setLoginState({step:yn.loginWithPassword,loading:!1}),void(null==a||a());(null==o?void 0:o.authStrategy)===N.EmailAndPassword?(n.setLoginState({step:yn.loginWithPassword,loading:!1}),null==a||a()):[N.MagicLink,N.Code,N.SmsCode].includes(null==o?void 0:o.authStrategy)?await n.passwordlessPreLogin(v({},i,{type:null==o?void 0:o.authStrategy,callback:a})):(n.setLoginState({step:yn.loginWithPassword,loading:!1,error:Nn(s)}),null==a||a())},h=async t=>{const{user:e,tenants:a=[],activeTenant:s}=t,i={step:Yn.recoveryCode,loading:!1,error:void 0,saving:!1};null!=e&&e.recoveryCode&&(i.recoveryCode=e.recoveryCode),n.setMfaState(i),n.setUser(e),n.setTenantsState({tenants:a,activeTenant:s,loading:!1}),e.id&&localStorage.setItem("userId",e.id)};return v({setLoginState:d,resetLoginState:()=>{Cn(t,["auth","loginState"],yi)},requestAuthorize:async t=>{const e=[],a=[];e.push(o()),t&&(n.setAuthState({isLoading:!0}),e.push(n.loadSocialLoginsConfigurationV2(Pn())),e.push(n.loadAllowSignUps(g(Wn.LOAD_ALLOW_SIGNUPS))),e.push(n.loadPublicAuthStrategiesPolicy(g(Wn.LOAD_PUBLIC_AUTH_STRATEGIES_POLICY))),e.push(n.loadSignUpStrategies()),e.push(c(g(Wn.LOAD_SSO_PUBLIC_CONFIGURATION))),e.push(n.loadVendorPublicInfo(Pn())),e.push(u(Pn())),a.push(n.loadCustomLoginRoutes(g(Wn.LOAD_CUSTOM_LOGIN_ROUTES)))),await Promise.all(e),a.length>0&&await Promise.all(a),n.setAuthState({isLoading:!1})},requestAuthorizeSSR:async e=>{const a=[];a.push(n.loadSocialLoginsConfigurationV2(Pn())),a.push(n.loadAllowSignUps(g(Wn.LOAD_ALLOW_SIGNUPS))),a.push(c(g(Wn.LOAD_SSO_PUBLIC_CONFIGURATION))),a.push(n.loadSignUpStrategies()),a.push(n.loadVendorPublicInfo(Pn())),a.push(u()),a.push((async({accessToken:e,user:a})=>{if(!e)return void n.setAuthState({user:void 0,isAuthenticated:!1});const{onRedirectTo:s,routes:i}=t.auth;if(Ss(a,t.root.appName)){const t=await n.getMfaRequiredState(a,Tn,!0);n.setAuthState(t),s(i.loginUrl,{preserveQueryParams:!0})}})(e)),a.push(n.loadCustomLoginRoutes(g(Wn.LOAD_CUSTOM_LOGIN_ROUTES))),await Promise.all(a)},preLogin:async a=>{const{email:n,recaptchaToken:s,invitationToken:i,callback:o}=a;d({loading:!0});try{const a=t.auth.onRedirectTo,r=as(ns),l=await e.auth.preLoginV2({email:n,tenantId:r}),{address:c,idpType:u}=null!=l?l:{};if(c){let e=c;if(u===io.Oidc&&!e.includes("redirect_uri")){const{oidcRedirectUrl:a}=t.auth.routes;e+=`&redirect_uri=${window.location.origin}${a}`}S.isLoginWithSSOAvailable()?(S.loginWithSSO(n),d({loading:!1}),null==o||o()):(d({step:yn.redirectToSSO,loading:!1,ssoRedirectUrl:e}),setTimeout((()=>{a(e,{refresh:!0})}),2e3))}else await p({email:n,recaptchaToken:s,callback:o,invitationToken:i})}catch(t){await p({email:n,recaptchaToken:s,callback:o,invitationToken:i,error:t})}},postLogin:async a=>{const{onRedirectTo:s,routes:i}=t.auth;d({loading:!0});try{const t=await e.auth.postLogin(a);n.setAuthState({user:t.accessToken?t:void 0,isAuthenticated:!!t.accessToken}),await n.afterAuthNavigation()}catch(t){setTimeout((()=>{s(i.authenticatedUrl)}),1e3),d({step:yn.loginWithSSOFailed,loading:!1})}},login:async a=>{const{email:i,password:o,recaptchaToken:r,invitationToken:l,callback:c}=a;d({loading:!0});try{const{user:a,tenants:s=[],activeTenant:u}=await e.auth.loginv2({email:i,password:o,recaptchaToken:r,invitationToken:l}),{onRedirectTo:g,routes:p}=t.auth;if(Ss(a,t.root.appName)){const t=await n.getMfaRequiredState(a,Tn,!0,i);n.setAuthState(t),g(p.loginUrl,{preserveQueryParams:!0})}else{const[e,o]=await n.getFeatureFlags(["security-center-show-login-flows","password-rotation"]);if(o&&vs(a,t.root.appName))d({step:yn.passwordRotationExpired,loading:!1,resetPasswordToken:a.resetPasswordToken,userId:a.userId});else{const r=t.auth.loginState,l=!!a.accessToken;if(a.id&&localStorage.setItem("userId",a.id),n.afterAuthenticationStateUpdate({user:a,tenants:s,activeTenant:u},{loginState:{flow:r.flow,quickLoginToRegister:r.quickLoginToRegister,email:i,loading:!1,error:void 0,mfaToken:a.mfaToken,step:r.flow===Sn.Login?yn.success:r.step,tenants:s,tenantsLoading:!0,isBreachedPassword:a.isBreachedPassword},isAuthenticated:l}),r.flow===Sn.Login)if(e&&a.isBreachedPassword&&!l)d({step:yn.breachedPassword,loading:!1});else if(l){const t=us(a);o&&t?d({step:yn.passwordRotationNotification,loading:!1}):await n.__shouldShowPromptPasskeys()?(d({step:yn.promptPasskeys,loading:!1}),g(p.loginUrl,{preserveQueryParams:!0})):await n.afterAuthNavigation()}}}S.isSuggestSavePasswordAvailable()&&S.suggestSavePassword(i,o),localStorage.removeItem("register-quick-login"),null==c||c(!0)}catch(t){s.setAccessToken(null),s.setUser(null),null==c||c(!1,t),d({email:i,error:Nn(t),loading:!1})}},logout:async a=>{const i=t.auth.hostedLoginBox;n.setAuthState({isLoading:!0});try{i?await e.auth.OAuthLogout():await e.auth.logout()}catch{}s.isSessionPerTenantEnabled()&&re(),n.resetAuthState(),await n.requestAuthorize(!0),null==a||a()},silentLogout:async t=>{var a;try{await e.auth.logout()}catch{}s.isSessionPerTenantEnabled()&&re(),setTimeout((()=>{var e;return null==t||null==(e=t.callback)?void 0:e.call(t,!0)}),null!=(a=null==t?void 0:t.callbackTimeout)?a:500)},recoverMfa:async t=>{d({loading:!0});try{var a;await e.auth.recoverMfaToken(t),d({loading:!1,error:void 0,step:yn.preLogin}),n.setAuthState({user:void 0,isAuthenticated:!1}),null==(a=t.callback)||a.call(t,!0)}catch(e){var s;d({error:Nn(e),loading:!1}),null==(s=t.callback)||s.call(t,!1,e)}},quickSmsPasswordlessPreLogin:async t=>{const{callback:a}=t,n=f(t,ro);try{d({loading:!0});const t=await e.auth.passwordlessPreLogin(v({},n,{type:N.SmsCode}));d({step:yn.loginWithQuickSmsOtc,loading:!1,phoneNumber:null==t?void 0:t.phoneNumber,error:void 0}),null==a||a(!0)}catch(t){d({error:Nn(t),loading:!1}),null==a||a(!1,t)}},changePhoneNumberWithVerification:async t=>{const{callback:a}=t,n=f(t,lo);try{d({loading:!0});const t=await e.auth.changePhoneNumberWithVerification(n);d({phoneNumber:n.phoneNumber,loading:!1,changePhoneId:t.changePhoneId,step:yn.loginWithQuickSmsOtc,error:void 0}),null==a||a(!0)}catch(t){d({error:Nn(t),loading:!1})}},verifyChangePhoneNumber:async t=>{const{callback:a}=t,n=f(t,co);try{d({loading:!0}),await e.auth.verifyChangePhoneNumber(n),d({loading:!1}),null==a||a(!0)}catch(t){d({error:Nn(t),loading:!1})}},passwordlessPreLogin:async t=>{const{callback:a}=t,n=f(t,uo);try{let t;d({loading:!0}),ls(n)&&(t=n.email);const s=await e.auth.passwordlessPreLogin(n),i=mn[n.type];d({step:i,loading:!1,phoneNumber:null==s?void 0:s.phoneNumber,email:t,error:void 0}),null==a||a()}catch(t){d({error:Nn(t),loading:!1}),null==a||a(null,t)}},passwordlessPostLogin:async a=>{const{callback:s,events:i}=a,o=f(a,go);try{d({loading:!0});const{user:l,tenants:c=[],activeTenant:u}=await e.auth.passwordlessPostLoginV2(o),{routes:g,onRedirectTo:p}=t.auth;if(Ss(l,t.root.appName)){const t=await n.getMfaRequiredState(l);n.setAuthState(t),p(g.loginUrl,{preserveQueryParams:!0})}else{const e=t.auth.loginState;if(l.emailVerified){var r;const t={email:l.email,origin:Hn.PASSWORDLESS,id:l.id,tenantId:l.tenantId,createdAt:new Date,name:l.name};null==i||null==(r=i.userVerified)||r.call(i,t),Xn(Jn.USER_VERIFIED,t)}l.id&&localStorage.setItem("userId",l.id),n.afterAuthenticationStateUpdate({user:l,tenants:c,activeTenant:u}),d({error:void 0}),n.setAuthState({isLoading:!1}),e.flow===Sn.Login?await n.__shouldShowPromptPasskeys()?(n.setLoginState({step:yn.promptPasskeys,loading:!1}),p(g.loginUrl,{preserveQueryParams:!0})):(n.setAuthState({isAuthenticated:!0}),a.type===N.MagicLink&&(n.setLoginState({step:yn.magicLinkPostLoginSuccess,loading:!1}),await En(5e3)),await n.afterAuthNavigation()):p(g.loginUrl,{preserveQueryParams:!0}),localStorage.removeItem("register-quick-login"),null==s||s(!0)}}catch(t){d({error:Nn(t,"Failed to authenticate")}),null==s||s(null,t)}finally{d({loading:!1})}},verifyInviteToken:async t=>{try{d({loading:!0});const{name:a}=await e.auth.verifyInviteToken(t);d({inviteTokenTenantName:a})}catch(t){d({inviteTokenError:Nn(t,"We couldn't verify your invitation")})}finally{d({loading:!1})}},webAuthnPrelogin:async t=>{const{callback:a}=t,s=f(t,po);try{var i;n.setPasskeysState({loading:!0}),d({loading:!0});const{options:t}=await e.auth.webAuthnPreLogin(s);t.challenge=Oi(t.challenge),t.allowCredentials=null==(i=t.allowCredentials)?void 0:i.map((t=>v({},t,{id:Oi(t.id)}))),d({error:void 0}),null==a||a(t)}catch(t){d({error:Nn(t)}),null==a||a(null)}finally{n.setPasskeysState({loading:!1}),d({loading:!1})}},webAuthnPostLogin:async a=>{const{callback:s}=a,i=f(a,ho);try{var o;n.setPasskeysState({loading:!0}),d({loading:!0});const a=ki(i.publicKey),r=await e.auth.webAuthnPostLoginV2(v({},a,{response:v({},a.response,{userHandle:null!=(o=a.response.userHandle)?o:void 0}),recaptchaToken:i.recaptchaToken,invitationToken:i.invitationToken})),{user:l}=r,c=f(r,yo);if(Ss(l,t.root.appName)){const{routes:e,onRedirectTo:a}=t.auth,s=await n.getMfaRequiredState(l);n.setAuthState(s),a(e.loginUrl,{preserveQueryParams:!0})}else l.id&&localStorage.setItem("userId",l.id),n.afterAuthenticationStateUpdate(v({user:l},c),{isAuthenticated:!0}),d({error:void 0}),await n.afterAuthNavigation(),null==s||s(!0)}catch(t){d({error:Nn(t)}),null==s||s(null)}finally{n.setPasskeysState({loading:!1}),d({loading:!1})}},webAuthnCreateNewDeviceSession:async t=>{const{callback:a}=t;try{d({loading:!0});const{options:t}=await e.auth.webAuthnCreateNewDeviceSession();t.user.id=Oi(t.user.id),t.challenge=Oi(t.challenge),t.excludeCredentials=[],null==a||a(t)}catch(t){d({error:Nn(t)}),null==a||a(null)}finally{d({loading:!1})}},webAuthnVerifyNewDeviceSession:async t=>{const{callback:a}=t,n=f(t,So);try{d({loading:!0});const t=ki(n.publicKey),s="platform"===(null==t?void 0:t.authenticatorAttachment)?qt.Platform:qt.CrossPlatform;await e.auth.verifyNewDeviceSession({id:t.id,response:t.response,deviceType:s}),null==a||a(!0)}catch(t){d({error:Nn(t)}),null==a||a(null)}finally{d({loading:!1})}},getUserIP:async t=>{const{callback:a}=t;try{n.setAuthState({userIpData:{loading:!0}});const{ip:t,country_code:s}=await e.metadata.getCurrentUserIpMetadata();n.setAuthState({userIpData:{ip:t,countryCode:s,loading:!1}}),n.setAuthState({userIp:t}),null==a||a({ip:t,countryCode:s})}catch(t){n.setAuthState({userIpData:{loading:!1}}),null==a||a(!1)}},preEnrollMFAWebAuthnForLogin:async t=>{const{callback:a}=t,n=f(t,vo);d({loading:!0});try{var s;const t=await e.auth.preEnrollMFAWebAuthnForLogin(n),i=v({},t.options,{challenge:Oi(t.options.challenge),user:v({},t.options.user,{id:Oi(t.options.user.id)}),excludeCredentials:null==(s=t.options.excludeCredentials)?void 0:s.map((t=>v({},t,{id:Oi(t.id)})))});d({loading:!1}),null==a||a({options:i,webauthnToken:t.webauthnToken})}catch(t){d({loading:!1,error:Nn(t)}),null==a||a(null)}},enrollMFAWebAuthnForLogin:async t=>{const{callback:a}=t,n=f(t,fo);d({loading:!0});try{const t=ki(n.publicKey),s=await e.auth.enrollMFAWebAuthnForLoginV2(v({},n,{options:t}));await h(s),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Nn(t)}),null==a||a(null)}},enrollMFAAuthenticatorAppForLogin:async t=>{const{callback:a}=t,n=f(t,mo);d({loading:!0});try{const t=await e.auth.enrollMFAAuthenticatorAppForLoginV2(n);await h(t),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Nn(t)}),null==a||a(null)}},preEnrollMFASMSForLogin:async t=>{const{callback:a}=t,s=f(t,bo);d({loading:!0});try{const t=await e.auth.preEnrollMFASMSForLogin(s);n.setMfaState({otcToken:t.otcToken,step:Yn.smsVerifyCode,phoneNumber:t.phoneNumber}),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Nn(t)}),null==a||a(null)}},enrollMFASMSForLogin:async t=>{const{callback:a}=t,n=f(t,Ao);d({loading:!0});try{const t=await e.auth.enrollMFASMSForLoginV2(n);await h(t),d({loading:!1}),null==a||a(!0)}catch(t){d({loading:!1,error:Nn(t)}),null==a||a(null)}},handleEnrollMFAResponse:h,resetBreachedPassword:async t=>{d({loading:!0});try{await e.auth.forgotPassword(t),d({loading:!1,error:void 0,step:yn.breachedPasswordSuccess}),n.setAuthState({isAuthenticated:!1})}catch(t){d({loading:!1,error:Nn(t)})}},refreshTokenForSocialLogins:async()=>{t.auth.hostedLoginBox?await(async()=>{const{user:a}=t.auth;if(null==a||!a.refreshToken)return s.setAccessToken(null),s.setUser(null),void n.setAuthState({user:null,isAuthenticated:!1});try{const t={grant_type:"refresh_token",refresh_token:null==a?void 0:a.refreshToken},s=await e.auth.exchangeOAuthTokensV2(t),i=await r(s.user);n.afterAuthenticationStateUpdate(v({},s,{user:i}),{isAuthenticated:!0})}catch(t){s.setAccessToken(null),s.setUser(null),n.setAuthState({user:null,isAuthenticated:!1})}})():await(async()=>{try{const{routes:s,loginState:o,onRedirectTo:c}=t.auth,{user:u,tenants:d=[],activeTenant:g}=await e.auth.refreshTokenV3();if(Ss(u,t.root.appName)){const t=await n.getMfaRequiredState(u);n.setAuthState(t),c(s.loginUrl,{preserveQueryParams:!0})}else{const t=await r(u);if(await n.__shouldShowPromptPasskeys())n.setLoginState({step:yn.promptPasskeys,loading:!1}),n.afterAuthenticationStateUpdate({user:t,tenants:d,activeTenant:g},{isLoading:!1}),c(s.loginUrl,{preserveQueryParams:!0});else{var a;u.id&&localStorage.setItem("userId",u.id);const e=null!=(a=localStorage.getItem("register-quick-login"))?a:o.quickLoginToRegister,s=i(u);n.afterAuthenticationStateUpdate({user:t,tenants:d,activeTenant:g},{loginState:v({},o,{quickLoginToRegister:e,flow:s?Sn.RegisterQuickLogin:Sn.Login}),isAuthenticated:!0}),await l(s)}}}catch(t){s.setAccessToken(null),s.setUser(null),n.setAuthState({user:void 0,isAuthenticated:!1})}})()},__refreshToken:o},((t,e,a)=>{const n=a,s=async()=>{const t=await e.auth.silentOAuthRefreshTokenV2();if(null==t||!t.user)throw new Error("couldn't refresh user token with oauth service");await n.afterAuthenticationStateUpdate(t,{isAuthenticated:!0,isLoading:!1})},i=async a=>{var s;const{routes:i,onRedirectTo:o}=t.auth,{context:r,urlStrategy:l}=t.root;if(ms(l)===i.hostedLoginRedirectUrl)return void console.debug("Calling loginWithRedirect while in hostedLoginCallback route");n.setAuthState({isLoading:!0});const c=Ji(),u=Ji(),d=await qi(u);localStorage.setItem(wn,u);const g=cs(t);let p=`${window.location.origin}${"path"===l?"":"#"}${null!=g?g:""}${i.hostedLoginRedirectUrl}`;await n.loadCustomLoginRoutes();const h=null==(s=t.auth.customLoginState)?void 0:s.customLoginSearchParams;h&&(p.endsWith("/")&&(p=p.slice(0,-1)),p+=h);const y=`${e.fetch.getBaseUrl(r,"/oauth/authorize")}/oauth/authorize`,S=v({response_type:"code",client_id:r.appId||r.clientId||"INVALID-CLIENT-ID",scope:"openid email profile",redirect_uri:p,code_challenge:d,code_challenge_method:"S256",nonce:c},a);if(r.tenantResolver){var f;const t=await(null==(f=r.tenantResolver)?void 0:f.call(r));null!=t&&t.tenant&&(S.organization=t.tenant)}const m=as(ns);m&&(S.tenantId=m),o(`${y}?${new URLSearchParams(S).toString()}`,{refresh:!0})};return{requestHostedLoginAuthorize:async e=>{var a;null==(a=localStorage)||a.removeItem(pn);const n=t.auth.disableSilentRefresh;if("login"===(null==e?void 0:e.prompt))return await i(e);try{if(n)throw new Error("silent refresh is disabled");return await s()}catch(t){return await i(e)}},requestHostedLoginAuthorizeV2:async e=>{var a,o;const{shouldRedirectToLogin:r,firstTime:l,loginDirectAction:c}=null!=e?e:{};let{additionalParams:u}=null!=e?e:{};if(null==(a=localStorage)||a.removeItem(pn),l){const e=t.root.urlStrategy,a=ms(e);if(n.setAuthState({isLoading:!0}),rs(a))return}const d=t.auth.disableSilentRefresh;if(c&&(u=u||{},u.login_direct_action=btoa(JSON.stringify(c))),"login"===(null==(o=u)?void 0:o.prompt))return await i(u);try{if(d)throw new Error("silent refresh is disabled");return await s()}catch(t){return r?await i(u):void n.setAuthState({isLoading:!1})}},__requestHostedLoginAuthorize:i,__requestHostedLoginSilentAuthorize:s,handleHostedLoginCallback:async a=>{var s;const i=localStorage.getItem(wn)||"INVALID-CODE-VERIFIER",o=t.auth.routes,r=t.root.urlStrategy,l=cs(t);let c=`${window.location.origin}${"path"===r?"":"#"}${null!=l?l:""}${o.hostedLoginRedirectUrl}`;await n.loadCustomLoginRoutes();const u=null==(s=t.auth.customLoginState)?void 0:s.customLoginSearchParams;u&&(c.endsWith("/")&&(c=c.slice(0,-1)),c+=u);const d={code:a.code,redirect_uri:c,code_verifier:i,grant_type:"authorization_code"};try{const t=await e.auth.exchangeOAuthTokensV2(d);n.afterAuthenticationStateUpdate(t,{isAuthenticated:!0,isLoading:!1})}catch(t){n.setAuthState({isLoading:!1}),console.error("Failed to exchangeOAuthTokens",t)}finally{const e=t.auth.user,a=window.localStorage.getItem(pn);window.localStorage.removeItem(pn),a&&ds(e)?await n.afterStepUpAuthNavigation():await n.afterAuthNavigation()}}}})(t,e,a),vi(t,0,a),function(t,e,a){const n=a,s=async()=>await n.afterStepUpAuthNavigation(),i=async(e,a)=>{const s=t.auth.loginState,i=t.auth.mfaState.step,[o,r]=await n.getFeatureFlags(["security-center-show-login-flows","password-rotation"]);if(s.flow===Sn.Login){if(o&&s.isBreachedPassword&&!e)return void n.setLoginState({step:yn.breachedPassword,loading:!1});if(r&&vs(a,t.root.appName))return void n.setLoginState({step:yn.passwordRotationExpired,loading:!1,resetPasswordToken:a.resetPasswordToken,userId:a.userId});if(r&&us(a))return void n.setLoginState({step:yn.passwordRotationNotification,loading:!1});const l=await n.__shouldShowPromptPasskeys();i===Yn.smsVerifyCode&&l?n.setLoginState({step:yn.promptPasskeys,loading:!1}):await n.afterAuthNavigation()}};return{postHandleVerifyMFAResponseForStepUp:s,postHandleVerifyMFAResponseForLogin:i,handleVerifyMFAResponse:async(t,e=!1)=>{const{user:a,tenants:o,activeTenant:r}=t;n.setUser(a),n.setTenantsState({tenants:o,activeTenant:r,loading:!1}),a.id&&localStorage.setItem("userId",a.id);const l=!!a.accessToken;return n.setAuthState({isAuthenticated:l}),e?await s():await i(l,a)},getFeatureFlags:async e=>{const a=t.root.appName;return Zt.getFeatureFlags(e,a)}}}(t,0,a),((t,e)=>({getMfaRequiredState:async(a,n,s=!1,i)=>{var o,r,l;let c=yn.loginWithTwoFactor;const u={step:Yn.verify,loading:!1,saving:!1},d=t.auth.loginState;let g,p;try{const t=await On((()=>e.auth.checkIfAllowToRememberMfaDevice(a.mfaToken)),n);g=t.isAllowedToRemember,p=t.mfaDeviceExpiration}catch(t){if(!s)throw t}!("mfaEnrolled"in a)||a.mfaEnrolled||(null==(o=a.mfaDevices)||null==(r=o.emails)?void 0:r.length)?Object.assign(u,{mfaDevices:a.mfaDevices,mfaToken:a.mfaToken,step:is(a.mfaDevices)}):(Object.assign(u,{step:os(a.mfaStrategies),qrCode:a.qrCode,recoveryCode:a.recoveryCode,loading:!1,mfaToken:a.mfaToken,mfaStrategies:a.mfaStrategies}),c=yn.forceTwoFactor);let h={};const y=localStorage.getItem("register-quick-login");return y&&(h={quickLoginToRegister:y,flow:Sn.RegisterQuickLogin}),{user:void 0,isAuthenticated:!1,mfaState:u,loginState:v({},d,h,{mfaToken:a.mfaToken,mfaRequired:a.mfaRequired,loading:!1,error:void 0,step:c,tenantsLoading:!0,email:null!=(l=a.userEmail)?l:i,tenants:[],allowRememberMfaDevice:g,mfaDeviceExpiration:p,isBreachedPassword:a.isBreachedPassword})}}}))(t,e),((t,e,a)=>{const n=a,s=async(a,s,i)=>{let{callback:o}=a,r=f(a,fi);s({loading:!0,error:void 0});try{const{user:a,tenants:l=[],activeTenant:c}=await e.auth.loginWithMfaV2(r),u=!!a.accessToken,d=await async function(e,a,n){const s=t.auth.loginState;let i={};if(!n){const t=s.flow===Sn.Login?yn.success:s.step;i={loginState:{flow:s.flow,quickLoginToRegister:s.quickLoginToRegister,loading:!1,step:t,error:void 0,tenants:e}}}return v({},i,{isAuthenticated:a})}(l,u,i);return await n.afterAuthenticationStateUpdate({user:a,tenants:l,activeTenant:c},d),a.id&&localStorage.setItem("userId",a.id),s({loading:!1,error:void 0}),i?await async function(t){await n.afterStepUpAuthNavigation(),null==t||t(!0)}(o):await async function(e,a,s){const i=t.auth.loginState;if(i.flow!==Sn.Login)return;const[o,r]=await n.getFeatureFlags(["security-center-show-login-flows","password-rotation"]);if(o&&i.isBreachedPassword&&!e)return n.setLoginState({step:yn.breachedPassword,loading:!1}),void(null==s||s(!0));if(r&&vs(a,t.root.appName))return n.setLoginState({step:yn.passwordRotationExpired,loading:!1,resetPasswordToken:a.resetPasswordToken,userId:a.userId}),void(null==s||s(!0));const l=us(a);if(r&&l)return n.setLoginState({step:yn.passwordRotationNotification,loading:!1}),void(null==s||s(!0));await n.__shouldShowPromptPasskeys()?n.setLoginState({step:yn.promptPasskeys,loading:!1}):await n.afterAuthNavigation(),null==s||s(!0)}(u,a,o)}catch(t){s({loading:!1,error:Nn(t)}),null==o||o(!1,t)}};return{mfaWithAuthenticator:s,loginWithMfa:async t=>await s(t,n.setLoginState,!1)}})(t,e,a),((t,e,a)=>{const n=a,s=async(t,a)=>{var s;let{callback:i}=t,o=f(t,mi);(a=null!=(s=a)?s:n.setLoginState)({loading:!0,error:void 0});try{const t=await e.auth.preVerifyMFAEmailCode(o);n.setMfaState({otcToken:t.otcToken,step:Yn.emailVerifyCode}),a({loading:!1,error:void 0}),null==i||i(!0)}catch(t){a({error:Nn(t)}),null==i||i(null)}},i=async(t,a)=>{var s;let{callback:i}=t,o=f(t,bi);(a=null!=(s=a)?s:n.setLoginState)({loading:!0});try{const t=await e.auth.verifyMFAEmailCodeV2(o);await n.handleVerifyMFAResponse(t),a({loading:!1,error:void 0}),null==i||i(!0)}catch(t){a({loading:!1,error:Nn(t)}),null==i||i(null)}};return{preVerifyMFAEmailCode:s,verifyMFAEmailCode:i,preVerifyMFAEmailCodeForLogin:async t=>await s(t,n.setLoginState),verifyMFAEmailCodeForLogin:async t=>await i(t,n.setLoginState)}})(0,e,a),((t,e,a)=>{const n=a,s=async(t,a)=>{let{callback:s,deviceId:i}=t,o=f(t,Ai);a({loading:!1,error:void 0});try{const t=await e.auth.preVerifyMFASMSForLogin(i,o);n.setMfaState({otcToken:t.otcToken,step:Yn.smsVerifyCode,phoneNumber:t.phoneNumber}),a({loading:!1,error:void 0}),null==s||s(!0)}catch(t){a({loading:!1,error:Nn(t)}),null==s||s(null)}},i=async(t,a,s=!1)=>{let{callback:i,deviceId:o}=t,r=f(t,wi);a({loading:!0});try{const t=await e.auth.verifyMFASMSForLoginV2(o,r);await n.handleVerifyMFAResponse(t,s),a({loading:!1,error:void 0}),null==i||i(!0)}catch(t){a({loading:!1,error:Nn(t)}),null==i||i(null)}};return{preVerifyMFASMS:s,verifyMFASMS:i,preVerifyMFASMSForLogin:async t=>await s(t,n.setLoginState),verifyMFASMSForLogin:async t=>await i(t,n.setLoginState,!1)}})(0,e,a),((t,e,a)=>{const n=a,s=async(t,a)=>{let{callback:n,deviceId:s}=t,i=f(t,Ri);a({loading:!0});try{var o;const t=await e.auth.preVerifyMFAWebAuthnForLogin(s,i),r=v({},t.options,{challenge:Oi(t.options.challenge),allowCredentials:null==(o=t.options.allowCredentials)?void 0:o.map((t=>v({},t,{id:Oi(t.id)})))});a({loading:!1,error:void 0}),null==n||n({options:r,webauthnToken:t.webauthnToken})}catch(t){a({loading:!1,error:Nn(t)}),null==n||n(null)}},i=async(t,a,s)=>{let{callback:i,deviceId:o}=t,r=f(t,Ui);a({loading:!0});try{const t=ki(r.publicKey),l=await e.auth.verifyMFAWebAuthnForLoginV2(o,v({},r,{options:t}));await n.handleVerifyMFAResponse(l,s),a({loading:!1,error:void 0}),null==i||i(!0)}catch(t){a({loading:!1,error:Nn(t)}),null==i||i(null)}};return{preVerifyMFAWebAuthn:s,verifyMFAWebAuthn:i,preVerifyMFAWebAuthnForLogin:async t=>await s(t,n.setLoginState),verifyMFAWebAuthnForLogin:async t=>await i(t,n.setLoginState,!1)}})(0,e,a))},To={step:Yn.verify,loading:!1,saving:!1},Eo=t=>en(To,t),Io=["callback"],Oo=["callback"],Po=["user"],ko=["deviceId"],_o=["deviceId"],Ro=["callback"],Uo=["callback"],Co=["deviceId","callback"],Lo=(t,e,a)=>{const n=a;async function s(e){const a=t.auth.mfaState.step;return{step:e.recoveryCode?Yn.recoveryCode:a,loading:!1,saving:!1,error:void 0,recoveryCode:null==e?void 0:e.recoveryCode}}const i=e=>{Object.assign(t.auth.mfaState,e)};return{setMfaState:i,resetMfaState:()=>{Cn(t,["auth","mfaState"],To)},getMFADevices:async()=>{i({loading:!0});try{const t=await e.auth.getMFADevices();i({loading:!1,error:void 0,mfaDevices:t})}catch(t){i({loading:!1,error:Nn(t)})}},getMFAStrategies:async t=>{i({loading:!0});try{const a=(await On((()=>e.auth.getMFAStrategiesConfig()),null==t?void 0:t.retryConfig)).strategies.filter((({isActive:t})=>t)).map((({strategy:t})=>t));i({loading:!1,error:void 0,mfaStrategies:a})}catch(t){i({loading:!1,error:Nn(t)})}},enrollMfa:async()=>{i({saving:!0});try{const{qrCode:t}=await e.auth.enrollMfa();i({saving:!1,error:void 0,qrCode:t})}catch(t){i({saving:!1,error:Nn(t)})}},verifyMfa:async a=>{const{callback:o}=a,r=f(a,Io);i({saving:!0});try{const a=t.auth.user,l=await e.auth.verifyMfa(r),c=await e.auth.getMFADevices(),u=await s(l);i(v({},u,{mfaDevices:c})),n.setUser(v({},a,{mfaEnrolled:!0})),null==o||o(u.recoveryCode)}catch(t){i({saving:!1,error:Nn(t)}),null==o||o(null,t)}},verifyMfaAfterForce:async t=>{const{callback:a}=t,s=f(t,Oo);i({loading:!0});try{const t=await e.auth.loginWithMfaV2(s),{user:o}=t,r=f(t,Po),l={step:Yn.recoveryCode,loading:!1,saving:!1,error:void 0};null!=o&&o.recoveryCode&&(l.recoveryCode=o.recoveryCode),i(l),await n.afterAuthenticationStateUpdate(v({user:o},r)),null==a||a(l.recoveryCode)}catch(t){i({loading:!1,error:Nn(t)}),null==a||a(null,t)}},disableMfa:async t=>{i({saving:!0});try{var a;await e.auth.disableMfa(t);const n=await e.auth.getMFADevices();i({saving:!1,error:void 0,mfaDevices:n}),null==(a=t.callback)||a.call(t,!0)}catch(e){var n;i({saving:!1,error:Nn(e)}),null==(n=t.callback)||n.call(t,!1,e)}},preDisableMfaSms:async t=>{const{deviceId:a}=t,n=f(t,ko);i({saving:!0});try{var s;const t=await e.auth.preDisableMFASMS(a);i({saving:!1,error:void 0,otcToken:t.otcToken,phoneNumber:t.phoneNumber}),null==(s=n.callback)||s.call(n,!0)}catch(t){var o;i({saving:!1,error:Nn(t)}),null==(o=n.callback)||o.call(n,!1,t)}},disableMfaSms:async t=>{const{deviceId:a}=t,n=f(t,_o);i({saving:!0});try{var s;await e.auth.disableMFASMS(a,n);const t=await e.auth.getMFADevices();i({saving:!1,error:void 0,mfaDevices:t}),null==(s=n.callback)||s.call(n,!0)}catch(t){var o;i({saving:!1,error:Nn(t)}),null==(o=n.callback)||o.call(n,!1,t)}},preEnrollMfaSms:async t=>{i({saving:!0});try{var a;const n=await e.auth.preEnrollMFASMS(t);i({saving:!1,error:void 0,otcToken:n.otcToken,phoneNumber:n.phoneNumber}),null==(a=t.callback)||a.call(t,!0)}catch(e){var n;i({saving:!1,error:Nn(e)}),null==(n=t.callback)||n.call(t,!1,e)}},enrollMfaSms:async t=>{const{callback:a}=t,n=f(t,Ro);i({saving:!0});try{const t=await e.auth.enrollMFASMS(n),o=await e.auth.getMFADevices(),r=await s(t);i(v({},r,{mfaDevices:o})),null==a||a(r.recoveryCode)}catch(t){i({saving:!1,error:Nn(t)}),null==a||a(null,t)}},preEnrollMfaWebAuthn:async t=>{i({saving:!0});try{var a,n;const s=await e.auth.preEnrollMFAWebAuthn(),o=v({},s.options,{challenge:Oi(s.options.challenge),user:v({},s.options.user,{id:Oi(s.options.user.id)}),excludeCredentials:null==(a=s.options.excludeCredentials)?void 0:a.map((t=>v({},t,{id:Oi(t.id)})))});i({saving:!1}),null==(n=t.callback)||n.call(t,{options:o,webauthnToken:s.webauthnToken})}catch(e){var s;i({saving:!1,error:Nn(e)}),null==(s=t.callback)||s.call(t,null,e)}},enrollMfaWebAuthn:async t=>{const{callback:a}=t,n=f(t,Uo);i({saving:!0});try{const t=ki(n.publicKey),o=await e.auth.enrollMFAWebAuthn(v({},n,{options:t})),r=await e.auth.getMFADevices(),l=await s(o);i(v({},l,{mfaDevices:r})),null==a||a(l.recoveryCode)}catch(t){i({saving:!1,error:Nn(t)}),null==a||a(null,t)}},preDisableMfaWebAuthn:async t=>{const{deviceId:a,callback:n}=t;i({saving:!0});try{var s;const t=await e.auth.preDisableMFAWebAuthn(a),o=v({},t.options,{challenge:Oi(t.options.challenge),allowCredentials:null==(s=t.options.allowCredentials)?void 0:s.map((t=>v({},t,{id:Oi(t.id)})))});i({saving:!1}),null==n||n({options:o,webauthnToken:t.webauthnToken})}catch(t){i({saving:!1,error:Nn(t)}),null==n||n(null,t)}},disableMfaWebAuthn:async t=>{const{deviceId:a,callback:n}=t,s=f(t,Co);i({saving:!0});try{const t=ki(s.publicKey);await e.auth.disableMFAWebAuthn(a,v({},s,{options:t}));const o=await e.auth.getMFADevices();i({saving:!1,error:void 0,mfaDevices:o}),null==n||n(!0)}catch(t){i({saving:!1,error:Nn(t)}),null==n||n(!1,t)}},__getMfaStateAfterEnroll:s}},Do={loaders:{},errors:{},accounts:{tenantId:"",children:[]},accountsQueryParams:{_limit:50,_offset:0,_filter:"",_subTenantId:""},searchAccountsData:[],rootAccount:{tenantId:""},selectedAccount:{tenantId:"",userJwt:{accessToken:"",expiresIn:0,expires:""},users:[],usersQueryParams:{_offset:0,_limit:10,_order:$t.DESC,_sortBy:Ga.name},usersPageOffset:0,accountSettings:{}}},No=t=>en(Do,t),Mo={createSubAccountDialog:{loading:!1,open:!1,error:!1,jwt:"",canSelectParentAccount:!1},updateSubAccountDialog:{accountId:"",accountName:"",loading:!1,open:!1,error:!1,jwt:""},disableSubAccountManagementDialog:{accountId:"",accountName:"",loading:!1,open:!1,error:!1},enableSubAccountManagementDialog:{accountId:"",accountName:"",loading:!1,open:!1,error:!1},updateSubAccountHierarchySettingsDialog:{accountId:"",accountName:"",subAccountAccessType:_a.DEFAULT_OFF,loading:!1,open:!1,error:!1},deleteSubAccountDialog:{accountId:"",accountName:"",isParentAccount:!1,loading:!1,open:!1,error:!1,jwt:""},addUsersToAccountDialog:{loading:!1,open:!1,accountName:"",accountId:"",permissionToGiveAccessToSubAccounts:!1,jwt:""},deleteUserFromAccountDialog:{userId:"",userName:"",accountId:"",loading:!1,open:!1,jwt:""},editUserRolesDialog:{loading:!1,open:!1,jwt:"",accountId:"",userId:"",userName:"",userRoles:[]}},Fo=t=>en(Mo,t);let xo;!function(t){t.GET_ACCOUNTS="GET_ACCOUNTS",t.SEARCH_ACCOUNTS="SEARCH_ACCOUNTS",t.SET_ROOT_ACCOUNT_DATA="SET_ROOT_ACCOUNT_DATA",t.SET_SELECTED_SUB_ACCOUNT_DATA="SET_SELECTED_SUB_ACCOUNT_DATA",t.LOAD_NUMBER_OF_USERS_FOR_ACCOUNT="LOAD_NUMBER_OF_USERS_FOR_ACCOUNT",t.UPDATE_SUB_ACCOUNT_ACCESS_FOR_USER="UPDATE_SUB_ACCOUNT_ACCESS_FOR_USER",t.CREATE_SUB_ACCOUNT="CREATE_SUB_ACCOUNT",t.UPDATE_SUB_ACCOUNT="UPDATE_SUB_ACCOUNT",t.DELETE_SUB_ACCOUNT="DELETE_SUB_ACCOUNT",t.GET_ACCOUNT_USERS="GET_ACCOUNT_USERS",t.ADD_USERS_TO_ACCOUNT="ADD_USERS_TO_ACCOUNT",t.DELETE_USERS_FROM_ACCOUNT="DELETE_USERS_FROM_ACCOUNT",t.SET_USER_ROLES_FOR_SUB_ACCOUNT="SET_USER_ROLES_FOR_SUB_ACCOUNT",t.UPDATE_SUB_ACCOUNT_SETTINGS="UPDATE_SUB_ACCOUNT_SETTINGS",t.UPDATE_SUB_ACCOUNT_MANAGEMENT="UPDATE_SUB_ACCOUNT_MANAGEMENT",t.UPDATE_SUB_ACCOUNT_HIERARCHY_SETTINGS="UPDATE_SUB_ACCOUNT_HIERARCHY_SETTINGS",t.GET_USER_JWT="GET_USER_JWT",t.GET_TEAM_USERS="GET_TEAM_USERS"}(xo||(xo={}));const $o=({items:t},e)=>t.map((t=>{var a,n;return{name:t.name,tenantId:t.tenantId,numberOfUsers:null!=(a=null==(n=e.find((e=>e.tenantId===t.tenantId)))?void 0:n.totalUsers)?a:0,createdAt:t.createdAt,metadata:t.metadata,isReseller:t.isReseller,subAccountAccessType:t.subAccountAccessType}}));function Go(t,e,a){var n,s,i;return t.tenantId===e?v({},t,{children:[...null!=(i=null==t?void 0:t.children)?i:[],...a].filter(((t,e,a)=>e===a.findIndex((e=>e.tenantId===t.tenantId))))}):v({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>Go(t,e,a))))?n:[]})}function jo(t,e){var a;return v({},t,{children:null!=(a=t.children)&&a.length?t.children.filter((t=>t.tenantId!==e)).map((t=>jo(t,e))):[]})}const Bo=(t,e,a)=>{var n,s;return t.tenantId===e?v({},t,{subAccountAccessType:a}):v({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>Bo(t,e,a))))?n:[]})},Vo=(t,e,a)=>{var n,s;return t.tenantId===e?v({},t,{name:a}):v({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>Vo(t,e,a))))?n:[]})},Wo=(t,e,a)=>{var n,s;return t?t.tenantId===e?v({},t,{isReseller:a}):v({},t,{children:null!=(n=null==t||null==(s=t.children)?void 0:s.map((t=>Wo(t,e,a))))?n:[]}):{}},Ho=(t,e,a)=>{const n=e=>{Object.assign(t.auth.allAccountsState,{loaders:v({},t.auth.allAccountsState.loaders,{[e.key]:e.value})})},s=e=>{Object.assign(t.auth.allAccountsState,{errors:v({},t.auth.allAccountsState.errors,{[e.key]:e.value}),loaders:v({},t.auth.allAccountsState.loaders,{[e.key]:!1})})},i=e=>{Object.assign(t.auth.allAccountsState,e)},o=e=>{Object.assign(t.auth.allAccountsState.selectedAccount,e)},r=()=>t.auth.allAccountsState,l=async t=>{var a,i,l,c,u,d,g,p;const{jwt:h,_tenantId:y,_email:S}=t,f=xo.GET_ACCOUNT_USERS;n({key:f,value:!0});const m=r(),b=null!=(a=null!=(i=null==t?void 0:t._offset)?i:null==m||null==(l=m.selectedAccount)||null==(c=l.usersQueryParams)?void 0:c._offset)?a:0,A=null!=(u=null!=(d=null==t?void 0:t._limit)?d:null==m||null==(g=m.selectedAccount)||null==(p=g.usersQueryParams)?void 0:p._limit)?u:10,w=v({_offset:b,_limit:A,_tenantId:y,_includeSubTenants:!1},!!S&&{_email:S});try{const{items:t,_metadata:{totalItems:a,totalPages:n}}=await e.users.getUsersV3(w,{jwt:h}),s={totalUsersItems:a,totalUsersPages:n,usersQueryParams:v({_offset:null!=b?b:0,_limit:null!=A?A:10},!!S&&{_email:S})};if(t.length){const a=t.map((t=>t.id)),n=await e.roles.getRoles(),i=await e.users.getUsersRoles({ids:a},{jwt:h}),r=t.map((t=>{var e,a;const s=null==i||null==(e=i.find((e=>e.userId===t.id)))?void 0:e.roleIds;return v({},t,{roles:null!=(a=null==s?void 0:s.map((t=>{var e;return null!=(e=null==n?void 0:n.find((e=>e.id===t)))?e:[]})))?a:[]})}));o(v({users:r},s))}else o(v({users:[]},s))}catch(t){s({key:f,value:Nn(t)})}finally{n({key:f,value:!1})}};return{setAllAccountsLoader:n,setAllAccountsError:s,setAllAccountsState:i,setSelectedAccountState:o,resetAllAccountsState:()=>{Cn(t,["auth","allAccountsState"],Do)},clearSelectedAccount:()=>{Cn(t,["auth","allAccountsState","selectedAccount"],Do.selectedAccount)},loadAccounts:async t=>{const a=xo.GET_ACCOUNTS;n({key:a,value:!0});const{accountsQueryParams:l}=r(),{jwt:c,_limit:u,_offset:d}=t,g={_offset:null!=d?d:l._offset,_limit:null!=u?u:l._limit,_subTenantId:null==t?void 0:t._subTenantId};try{if(c){var p;const{selectedAccount:a}=r(),{items:n,_links:s}=await e.tenants.searchSubTenants(g,{jwt:c}),i=await e.tenants.getTenantsUsersCount({tenantIds:n.map((t=>t.tenantId))},{jwt:c}),l=$o({items:n},i),u=Go(a.accounts?a.accounts:a,null!=(p=null==t?void 0:t._subTenantId)?p:"",l.map((t=>({name:t.name,tenantId:t.tenantId,numberOfUsers:t.numberOfUsers,createdAt:t.createdAt,metadata:t.metadata,children:[],loadMoreLink:null==s?void 0:s.next,isReseller:t.isReseller}))));o({accounts:u})}else{var h;const{accounts:a}=r(),{items:n,_links:s}=await e.tenants.searchSubTenants(g),o=await e.tenants.getTenantsUsersCount({tenantIds:n.map((t=>t.tenantId))}),l=$o({items:n},o),c=Go(a,null!=(h=null==t?void 0:t._subTenantId)?h:"",l.map((t=>({name:t.name,tenantId:t.tenantId,numberOfUsers:t.numberOfUsers,createdAt:t.createdAt,metadata:t.metadata,children:[],loadMoreLink:null==s?void 0:s.next,isReseller:t.isReseller}))));i({accounts:c})}}catch(t){s({key:a,value:Nn(t)})}finally{n({key:a,value:!1})}},searchAccounts:async t=>{const{jwt:a}=t,o=xo.SEARCH_ACCOUNTS;n({key:o,value:!0});const{rootAccount:l}=r();try{if(null!=t&&t._subTenantId){var c;const{items:n}=await e.tenants.searchSubTenants({_offset:0,_limit:50,_filter:null!=(c=null==t?void 0:t._filter)?c:"",_subTenantId:t._subTenantId},{jwt:a});i({searchAccountsData:[...n,{name:l.name,tenantId:l.tenantId}]})}}catch(t){s({key:o,value:Nn(t)})}finally{n({key:o,value:!1})}},updateSubAccountAccessForUser:async t=>{const a=xo.UPDATE_SUB_ACCOUNT_ACCESS_FOR_USER;n({key:a,value:!0});const{selectedAccount:i}=r(),{userId:l,allowAccess:c,jwt:u,callback:d}=t;try{var g;await e.subTenants.updateSubAccountAccess(l,{allowAccess:c},{jwt:u}),o({users:null==i||null==(g=i.users)?void 0:g.map((t=>t.id===l?v({},t,{subAccountAccessAllowed:c}):t))}),null==d||d(!0)}catch(t){s({key:a,value:Nn(t)}),null==d||d(!1)}finally{n({key:a,value:!1})}},createSubAccount:async t=>{const a=xo.CREATE_SUB_ACCOUNT;n({key:a,value:!0});const{name:l,parentTenantId:c,tenantId:u,jwt:d,callback:g}=t;try{if(d){const{accounts:t,selectedAccount:a}=r(),n=await e.subTenants.createSubTenant({name:l,parentTenantId:c,tenantId:u},{jwt:d}),s=Go(t,null!=c?c:"",[{name:n.name,tenantId:n.tenantId,numberOfUsers:0,createdAt:new Date}]),g=Go(v({name:"",tenantId:""},null==a?void 0:a.accounts),null!=c?c:"",[{name:n.name,tenantId:n.tenantId,numberOfUsers:0,createdAt:new Date}]);i({accounts:s}),o({accounts:g})}else{const{accounts:t}=r(),a=await e.subTenants.createSubTenant({name:l,tenantId:u,parentTenantId:c}),n=Go(t,null!=c?c:"",[{name:a.name,tenantId:a.tenantId,numberOfUsers:0,createdAt:new Date}]);i({accounts:n})}null==g||g(!0)}catch(t){s({key:a,value:Nn(t)}),null==g||g(!1)}finally{n({key:a,value:!1})}},updateSubAccount:async t=>{},deleteSubAccount:async t=>{const a=xo.DELETE_SUB_ACCOUNT;n({key:a,value:!0});const{jwt:l,tenantId:c,callback:u}=t;try{if(l){const{selectedAccount:t,accounts:a}=r();await e.subTenants.deleteSubTenant(c,{jwt:l});const n=jo(a,c),s=jo(t.accounts,c);i({accounts:n}),o({accounts:s})}else{const{accounts:t}=r();await e.subTenants.deleteSubTenant(c);const a=jo(t,c);i({accounts:a})}null==u||u(!0)}catch(t){s({key:a,value:Nn(t)}),null==u||u(!1)}finally{n({key:a,value:!1})}},updateSubAccountSettings:async t=>{const a=xo.UPDATE_SUB_ACCOUNT_HIERARCHY_SETTINGS;n({key:a,value:!0});const{jwt:l,name:c,callback:u,tenantId:d}=t;try{if(l){const{selectedAccount:t,accounts:a}=r();await e.subTenants.updateSubTenant({tenantId:d},{name:c},{jwt:l});const n=Vo(t.accounts,d,c);o({name:c,accounts:n});const s=Vo(a,d,c);i({accounts:s})}else{const{accounts:t}=r();await e.subTenants.updateSubTenant({tenantId:d},{name:c});const a=Vo(t,d,c);i({accounts:a})}null==u||u(!0)}catch(t){s({key:a,value:Nn(t)}),null==u||u(!1)}finally{n({key:a,value:!1})}},updateSubAccountManagement:async r=>{const l=xo.UPDATE_SUB_ACCOUNT_MANAGEMENT;a.setAllAccountsLoader({key:l,value:!0});const{jwt:c,isReseller:u,callback:d,tenantId:g,shouldUpdateSelectedAccount:p}=r,h=!!c;try{if(p){const{selectedAccount:a,accounts:n}=t.auth.allAccountsState;await e.subTenants.updateSubTenantManagement({tenantId:g},{isReseller:u},c?{jwt:c}:void 0);const s=Wo(a.accounts,g,null!=u&&u);o({accounts:s}),h||o({isReseller:u});const r=Wo(n,g,null!=u&&u);i({accounts:r})}else{const{accounts:a}=t.auth.allAccountsState;e.subTenants.updateSubTenantManagement({tenantId:g},{isReseller:u},c?{jwt:c}:void 0);const n=Wo(a,g,null!=u&&u);i({accounts:n})}null==d||d(!0)}catch(t){s({key:l,value:Nn(t)}),null==d||d(!1)}finally{n({key:l,value:!1})}},updateSubAccountHierarchySettings:async t=>{const a=xo.UPDATE_SUB_ACCOUNT_HIERARCHY_SETTINGS;n({key:a,value:!0});const{jwt:l,callback:c,tenantId:u,subAccountAccessType:d}=t;if(d)try{if(l){const{selectedAccount:t,accounts:a}=r();await e.subTenants.updateSubTenantHierarchySettings({tenantId:u},{subAccountAccessType:d},{jwt:l});const n=Bo(t.accounts,u,d);o({subAccountAccessType:d,accounts:n});const s=Bo(a,u,d);i({accounts:s})}else{const{accounts:t}=r();await e.subTenants.updateSubTenantHierarchySettings({tenantId:u},{subAccountAccessType:d});const a=Bo(t,u,d);i({accounts:a})}null==c||c(!0)}catch(t){s({key:a,value:Nn(t)}),null==c||c(!1)}finally{n({key:a,value:!1})}},addUsersToAccount:async t=>{const{users:a,tenantId:i,jwt:o,callback:r,allowSubAccountAccess:c=!1,roleIds:u}=t,d=xo.ADD_USERS_TO_ACCOUNT;try{n({key:d,value:!0}),await e.subTenants.addUsersToSubTenant({users:a,tenantId:i,allowSubAccountAccess:c,roleIds:u},{jwt:o}),await l({jwt:o,_tenantId:i}),null==r||r(!0)}catch(t){s({key:d,value:Nn(t)}),null==r||r(!1)}finally{n({key:d,value:!1})}},getAccountUsers:l,deleteUsersFromAccount:async t=>{const a=xo.DELETE_USERS_FROM_ACCOUNT;n({key:a,value:!0});const{userId:i,subTenants:o,jwt:r,callback:c}=t;try{await e.subTenants.removeUserFromTenantAndSubTenants({userId:i,subTenants:o},{jwt:r}),await l({jwt:r,_tenantId:o[0].tenantId}),null==c||c(!0)}catch(t){s({key:a,value:Nn(t)}),null==c||c(!1)}finally{n({key:a,value:!1})}},setUserRolesForSubAccount:async t=>{const{userId:a,subTenantsRoles:i,jwt:o,callback:c}=t,u=xo.SET_USER_ROLES_FOR_SUB_ACCOUNT;try{n({key:u,value:!0});const{selectedAccount:t}=r();await e.subTenants.setUserRolesForSubTenants(a,{subTenantsRoles:i},{jwt:o}),await l({jwt:o,_tenantId:t.tenantId}),null==c||c(!0)}catch(t){s({key:u,value:Nn(t)}),null==c||c(!1)}finally{n({key:u,value:!1})}},getUserJwtForSubAccount:async t=>{const{tenantId:a,callback:i}=t,r=xo.GET_USER_JWT;try{n({key:r,value:!0});const t=await e.users.GetUserJwt({tenantId:a});o({userJwt:t,accessPermission:!0}),null==i||i(!0)}catch(t){s({key:r,value:Nn(t)}),o({accessPermission:!1}),null==i||i(!1)}finally{n({key:r,value:!1})}},setRootAccountData:async()=>{const a=xo.SET_ROOT_ACCOUNT_DATA;n({key:a,value:!0});const{activeTenant:o}=t.auth.tenantsState,{accounts:l}=r();if(o)try{var c;const t=await e.tenants.getTenantsUsersCount({tenantIds:[null==o?void 0:o.tenantId]}),a={name:null==o?void 0:o.name,tenantId:null==o?void 0:o.tenantId,numberOfUsers:null==(c=t[0])?void 0:c.totalUsers,createdAt:null==o?void 0:o.createdAt};i({rootAccount:a,accounts:v({},l,a)})}catch(t){s({key:a,value:Nn(t)})}finally{n({key:a,value:!1})}},setSelectedSubAccountData:async t=>{const{jwt:a}=t,i=xo.SET_SELECTED_SUB_ACCOUNT_DATA;try{var r,c,u,d,g,p,h;n({key:i,value:!0});const t=await e.accountSettings.getSettings({jwt:a}),[s,y,S]=await Promise.all([e.tenants.getTenantsUsersCount({tenantIds:[null!=(r=null==t?void 0:t.tenantId)?r:""]},{jwt:a}),e.tenants.getParentTenants({jwt:a}),e.tenants.getHierarchyMetadata({_tenantIds:[null!=(c=null==t?void 0:t.tenantId)?c:""]},{jwt:a})]);o({tenantId:null!=(u=t.tenantId)?u:"",name:t.name,numberOfUsersObject:s[0],parentsAccounts:y,numberOfSubAccounts:null==(d=S[0])?void 0:d.totalSubTenants,accountSettings:t,accounts:{name:t.name,tenantId:null!=(g=t.tenantId)?g:"",numberOfUsers:null==(p=s[0])?void 0:p.totalUsers,createdAt:void 0,children:[]}}),await l({jwt:a,_tenantId:null!=(h=null==t?void 0:t.tenantId)?h:""})}catch(t){s({key:i,value:Nn(t)})}finally{n({key:i,value:!1})}},loadNumberOfUsersForSelectedSubAccount:async t=>{const{tenantId:a,jwt:i}=t,r=xo.LOAD_NUMBER_OF_USERS_FOR_ACCOUNT;try{n({key:r,value:!0});const t=await e.tenants.getTenantsUsersCount({tenantIds:[a]},{jwt:i});o({numberOfUsersObject:t[0]})}catch(t){s({key:r,value:Nn(t)})}finally{n({key:r,value:!1})}}}},zo=(t,e,a)=>({setAllAccountDialogsState:e=>{Object.assign(t.auth.allAccountsDialogsState,e)},resetAllAccountDialogsState:()=>{Cn(t,["auth","allAccountsDialogsState"],Mo)},openCreateSubAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.createSubAccountDialog,v({},e,{open:!0}))},closeCreateSubAccountDialog:()=>{Cn(t,["auth","allAccountsDialogsState","createSubAccountDialog"],Mo.createSubAccountDialog)},openUpdateSubAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.updateSubAccountDialog,v({},e,{open:!0}))},closeUpdateSubAccountDialog:()=>{Cn(t,["auth","allAccountsDialogsState","updateSubAccountDialog"],Mo.updateSubAccountDialog)},openEnableSubAccountManagementDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.enableSubAccountManagementDialog,v({},e,{open:!0}))},closeEnableSubAccountManagementDialog:()=>{Cn(t,["auth","allAccountsDialogsState","enableSubAccountManagementDialog"],Mo.enableSubAccountManagementDialog)},openUpdateSubAccountHierarchySettingsDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.updateSubAccountHierarchySettingsDialog,v({},e,{open:!0}))},closeUpdateSubAccountHierarchySettingsDialog:()=>{Cn(t,["auth","allAccountsDialogsState","updateSubAccountHierarchySettingsDialog"],Mo.updateSubAccountHierarchySettingsDialog)},openDisableSubAccountManagementDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.disableSubAccountManagementDialog,v({},e,{open:!0}))},closeDisableSubAccountManagementDialog:()=>{Cn(t,["auth","allAccountsDialogsState","disableSubAccountManagementDialog"],Mo.disableSubAccountManagementDialog)},openDeleteSubAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.deleteSubAccountDialog,v({},e,{open:!0}))},closeDeleteSubAccountDialog:()=>{Cn(t,["auth","allAccountsDialogsState","deleteSubAccountDialog"],Mo.deleteSubAccountDialog)},openAddUsersToAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.addUsersToAccountDialog,v({},e,{open:!0}))},closeAddUsersToAccountDialog:()=>{Cn(t,["auth","allAccountsDialogsState","addUsersToAccountDialog"],Mo.addUsersToAccountDialog)},openDeleteUserFromAccountDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.deleteUserFromAccountDialog,v({},e,{open:!0}))},closeDeleteUserFromAccountDialog:()=>{Cn(t,["auth","allAccountsDialogsState","deleteUserFromAccountDialog"],Mo.deleteUserFromAccountDialog)},openEditUserRolesDialog:e=>{Object.assign(t.auth.allAccountsDialogsState.editUserRolesDialog,v({},e,{open:!0}))},closeEditUserRolesDialog:()=>{Cn(t,["auth","allAccountsDialogsState","editUserRolesDialog"],Mo.editUserRolesDialog)}}),Ko={devices:[],loading:!1,error:null},qo=t=>en(Ko,t),Jo=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.passkeysState,e)};return{setPasskeysState:s,resetPasskeysState:()=>{Cn(t,["auth","passkeysState"],Ko)},loadWebAuthnDevices:async()=>{s({loading:!0});try{const{devices:t}=await e.auth.getWebAuthnDevices();s({devices:t,loading:!1})}catch(t){s({loading:!1,error:Nn(t,null)})}},deleteWebAuthnDevice:async a=>{const{callback:n,deviceId:i}=a;s({loading:!0});try{await e.auth.deleteWebAuthnDevice(i);const a=t.auth.passkeysState.devices.filter((t=>t.id!==i));s({devices:a,loading:!1}),null==n||n(!0)}catch(t){s({loading:!1,error:Nn(t,null)}),null==n||n(null,t)}},__shouldShowPromptPasskeys:async function(){const{publicAuthStrategyPolicy:a}=t.auth.securityPolicyState,{policy:i}=a,o=await async function(t){var e;return!(null==t||null==(e=t.secondaryAuthStrategies)||!e.some((({isActive:t,strategy:e})=>t&&e===Kt.Passkeys)))}(i),r="Passkeys"===localStorage.getItem("preferred-login-method"),l="true"===localStorage.getItem("dont-show-again-prompt-passkeys"),[c]=await n.getFeatureFlags(["show-passkeys-new"]);if(!c||!o||r||l)return!1;{const{devices:t}=await e.auth.getWebAuthnDevices();return s({devices:null!=t?t:[]}),0===(null!=t&&t.length?t.length:0)}}}},Yo={loading:!1,error:null},Xo=t=>en(Yo,t),Qo=["callback","profilePictureUrl"],Zo=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.profileState,e)};return{setProfileState:s,resetProfileState:()=>{Cn(t,["auth","profileState"],Yo)},loadProfile:async()=>{s({loading:!0});try{const a=await In(e.teams.getProfile,3,2e3),i=t.auth.user;n.setUser(v({},i,a)),s({profile:a,loading:!1})}catch(t){s({loading:!1,error:Nn(t)})}},saveProfile:async a=>{const{callback:i,profilePictureUrl:o}=a,r=f(a,Qo);s({saving:!0,error:null,loading:!0});try{var l;const a=null!=(l=t.auth.profileState.profile)?l:{};let s=a.profilePictureUrl;if(o!==a.profilePictureUrl&&o&&(o||"").match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/)){const t=Pi(o,"image");if(t){s=await e.teams.updateProfileImage(t);const a=Date.now().toString(),n=new URL(s);n.searchParams.set("t",a),s=n.href}}const c=v({},a,r,{profilePictureUrl:s}),u=await e.users.updateUserProfileV2(c),d=t.auth.user;n.setUser(v({},d,u)),n.setProfileState({profile:u,saving:!1,loading:!1}),null==i||i(c)}catch(t){s({saving:!1,error:Nn(t),loading:!1}),null==i||i(null,t)}},changePassword:async t=>{s({loading:!0});try{var a;await e.teams.changePassword(t),s({loading:!1,error:void 0}),null==(a=t.callback)||a.call(t,!0)}catch(e){var n;s({loading:!1,error:Nn(e)}),null==(n=t.callback)||n.call(t,null,e)}}}},tr={loading:!1},er=t=>en(tr,t),ar=["callback"],nr=["id"],sr=(t,e,a)=>{const n=e=>{Object.assign(t.auth.provisioningState,e)},s=async(t,a)=>{const{count:n}=await On((()=>e.directory.countConfigurationUsers(t.id)),a);return v({},t,{count:n})};return{setProvisioningState:n,resetProvisioningState:()=>{Cn(t,["auth","provisioningState"],tr)},__loadCountForConnection:s,loadProvisionConnections:async t=>{n({loading:!0,error:null});try{const a=null==t?void 0:t.retryConfig,i=await On((()=>e.directory.getConfigs()),a),o=await Promise.all(i.map((t=>s(t,a))));n({connections:o,loading:!1})}catch(t){n({error:Nn(t),loading:!1})}},createProvisionConnection:async t=>{const{callback:a}=t,i=f(t,ar);n({loading:!0,error:null});try{const t=await e.directory.createConfiguration(i),o=await e.directory.getConfigs(),r=await Promise.all(o.map((t=>s(t))));n({connections:r,loading:!1}),null==a||a(t)}catch(t){n({error:Nn(t),loading:!1})}},deleteProvisionConnection:async t=>{const{id:a,callback:i}=t;n({loading:!0,error:null});try{await e.directory.deleteConfiguration(a,t.deleteAll);const o=await e.directory.getConfigs(),r=await Promise.all(o.map((t=>s(t))));n({connections:r,loading:!1}),null==i||i(!0)}catch(t){n({error:Nn(t),loading:!1}),null==i||i(!1,t)}},updateProvisionConnection:async t=>{const{id:a}=t,i=f(t,nr);n({loading:!0,error:null});try{await e.directory.updateConfiguration(a,i);const t=await e.directory.getConfigs(),o=await Promise.all(t.map((t=>s(t))));n({connections:o,loading:!1})}catch(t){n({error:Nn(t),loading:!1})}}}};let ir;!function(t){t.ResetPhoneNumber="ResetPhoneNumber",t.VerifyResetPhoneNumber="VerifyResetPhoneNumber",t.ChangePhoneNumber="ChangePhoneNumber"}(ir||(ir={}));const or={step:ir.ResetPhoneNumber,loading:!1},rr=t=>en(or,t),lr=["callback"],cr=["callback"],ur=["callback"],dr=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.resetPhoneNumberState,e)};return{setResetPhoneNumberState:s,resetResetPhoneNumberState:()=>{Cn(t,["auth","resetPhoneNumberState"],or)},resetPhoneNumber:async t=>{const{callback:a}=t,i=f(t,lr);s({loading:!0});try{const t=await e.auth.resetPhoneNumber(i);s({loading:!1,error:void 0,resetPhoneNumberToken:t.resetPhoneNumberToken,step:ir.VerifyResetPhoneNumber}),n.setLoginState({email:i.email})}catch(t){s({loading:!1,error:Nn(t)}),null==a||a(null,t)}},verifyResetPhoneNumber:async t=>{const{callback:a}=t,n=f(t,cr);s({loading:!0});try{const t=await e.auth.verifyResetPhoneNumber(n);s({loading:!1,error:void 0,changePhoneNumberToken:t.changePhoneNumberToken,step:ir.ChangePhoneNumber}),null==a||a(!0)}catch(t){s({loading:!1,error:Nn(t)}),null==a||a(null,t)}},changePhoneNumber:async a=>{const{callback:i}=a,o=f(a,ur);s({loading:!0});try{const{onRedirectTo:a,routes:r}=t.auth;await e.auth.changePhoneNumber({phoneNumber:o.phoneNumber,changePhoneNumberToken:o.changePhoneNumberToken}),n.setLoginState({step:yn.loginWithSmsOtc}),await n.passwordlessPreLogin({type:N.SmsCode,email:o.email,recaptchaToken:o.recaptchaToken}),a(r.loginUrl),s({loading:!1}),null==i||i(!0)}catch(t){s({loading:!1,error:Nn(t)}),null==i||i(null,t)}}}},gr={loaders:{},errors:{},roles:[],permissions:[],permissionCategories:[]},pr=t=>en(gr,t);let hr;!function(t){t.EDIT_ROLE_DIALOG="editRoleDialog",t.DELETE_ROLE_DIALOG="deleteRoleDialog",t.LOAD_ROLES="loadRoles",t.ADD_ROLE="addRole",t.MANAGE_PERMISSIONS="managePermissions"}(hr||(hr={}));const yr=["callback"],Sr=["callback"],vr=["callback"],fr=["callback"],mr=["callback"],br=["callback"],Ar=(t,e,a)=>{const n=e=>{Object.assign(t.auth.rolesState,e)},s=e=>{Object.assign(t.auth.rolesState,{loaders:v({},t.auth.rolesState.loaders,{[e.key]:e.value})})},i=e=>{Object.assign(t.auth.rolesState,{errors:v({},t.auth.rolesState.errors,{[e.key]:e.value}),loaders:v({},t.auth.rolesState.loaders,{[e.key]:!1})})},o=async a=>{var o;const r=hr.LOAD_ROLES;s({key:r,value:!(null!=(o=null==a?void 0:a.silentLoading)&&o)});try{const s=null==a?void 0:a.retryConfig,[i,o,r]=await Promise.all([On((()=>e.roles.getRoles()),s),On((()=>e.roles.getPermissions()),s),On((()=>e.roles.getPermissionCategories()),s)]),{selectedRole:l}=t.auth.rolesState,c=null==i?void 0:i.find((({id:t})=>(null==l?void 0:l.id)===t));n({roles:i,permissions:o,permissionCategories:r,selectedRole:c})}catch(t){i({key:r,value:Nn(t)})}finally{s({key:r,value:!1})}},r=async t=>{const{callback:a}=t,r=f(t,mr),l=hr.MANAGE_PERMISSIONS;s({key:l,value:!0});try{const t=await e.roles.attachPermissionsToRole(r);await o({silentLoading:!0}),n({saving:!1}),null==a||a(t)}catch(t){i({key:l,value:Nn(t)}),null==a||a(null,t)}finally{s({key:l,value:!1})}};return{setRolesState:n,setRolesStateLoader:s,setRolesStateError:i,resetRolesState:()=>{Cn(t,["auth","rolesState"],gr)},loadRolesAndPermissions:o,addRole:async t=>{const{callback:a}=t,n=f(t,yr),r=hr.ADD_ROLE;s({key:r,value:!0});try{const t=await e.roles.addRole(n);await o({silentLoading:!0}),null==a||a(t)}catch(t){i({key:r,value:Nn(t)}),null==a||a(null,t)}finally{s({key:r,value:!1})}},addRoleV2:async t=>{const{callback:a}=t,n=f(t,Sr),r=hr.ADD_ROLE;s({key:r,value:!0});try{const t=await e.roles.addRoleV2(n);await o({silentLoading:!0}),null==a||a(t)}catch(t){i({key:r,value:Nn(t)}),null==a||a(null,t)}finally{s({key:r,value:!1})}},updateRole:async t=>{const{callback:a}=t,r=f(t,vr),l=hr.EDIT_ROLE_DIALOG;s({key:l,value:!0});try{const t=await e.roles.updateRole(r);await o({silentLoading:!0}),n({saving:!1}),null==a||a(t)}catch(t){i({key:l,value:Nn(t)}),null==a||a(null,t)}finally{s({key:l,value:!1})}},deleteRole:async t=>{const{callback:a}=t,r=f(t,fr),l=hr.DELETE_ROLE_DIALOG;s({key:l,value:!0});try{await e.roles.deleteRole(r),await o({silentLoading:!0}),n({saving:!1}),null==a||a(!0)}catch(t){i({key:l,value:Nn(t)}),null==a||a(!1,t)}finally{s({key:l,value:!1})}},attachPermissionsToRole:r,attachPermissionToRoles:async t=>{const{callback:e}=t,a=f(t,br),n=hr.MANAGE_PERMISSIONS;s({key:n,value:!0});try{await Promise.all(a.roleIds.map((t=>r({roleId:t,permissionIds:[a.permissionId]})))),await o({silentLoading:!0}),null==e||e(!0)}catch(t){i({key:n,value:Nn(t)}),null==e||e(null,t)}finally{s({key:n,value:!1})}}}},wr={ipRestrictions:{loading:!1,pagination:{_offset:0,_limit:4,_filter:zt.ALLOW},totalPages:1,userIpValid:!1},emailDomainRestrictions:{loading:!1}},Tr=t=>en(wr,t),Er=["callback"],Ir=["callback"],Or=["callback"],Pr=["callback"],kr=(t,e,a)=>{const n=a,s=t=>{var e,a,n;return{_filter:null!=(e=null==t?void 0:t._filter)?e:zt.ALLOW,_limit:null!=(a=null==t?void 0:t._limit)?a:10,_offset:null!=(n=null==t?void 0:t._offset)?n:0}},i=t=>async(...e)=>{const[a]=await n.getFeatureFlags(["security-center-admin-portal-major-version"]);await t(...e),a&&(await n.loadRecommendations(Pn()),await n.loadInsights(Pn()))},o=e=>{Object.assign(t.auth.restrictionsState.ipRestrictions,e)},r=e=>{Object.assign(t.auth.restrictionsState.emailDomainRestrictions,e)},l=async()=>{try{const{valid:t}=await e.auth.testCurrentIpInAllowList();o({userIpValid:t})}catch(t){o({error:Nn(t)})}},c=i((async()=>{o({loading:!0,error:null});try{const a=t.auth.restrictionsState.ipRestrictions,n=await e.auth.getIPRestrictionsConfig(),i=s({_filter:n.strategy,_limit:a.pagination._limit,_offset:a.pagination._offset}),{items:r,_metadata:{totalPages:l}}=await e.auth.getIPRestrictions(i);o({data:{restrictions:r,config:n},totalPages:l,pagination:i,loading:!1})}catch(t){o({error:Nn(t),loading:!1})}})),u=i((async a=>{const{callback:n}=a,i=f(a,Er);o({saving:!0,error:null});try{var r,c;await e.auth.createIPRestriction(i);const a=t.auth.restrictionsState.ipRestrictions,u=s(a.pagination),{items:d,_metadata:{totalPages:g}}=await e.auth.getIPRestrictions(u),p=d;await l(),o({data:{config:null!=(r=null==(c=a.data)?void 0:c.config)?r:{isActive:!1,strategy:zt.ALLOW},restrictions:p},pagination:u,totalPages:g,saving:!1}),null==n||n(!0)}catch(t){o({saving:!1,error:Nn(t)}),null==n||n(null,t)}})),d=i((async a=>{const{callback:n}=a,i=f(a,Ir);o({saving:!0,error:null});try{await e.auth.updateIPRestrictionConfig(i);const a=t.auth.restrictionsState.ipRestrictions,r=await e.auth.getIPRestrictionsConfig(),c=s(v({},a.pagination,{_filter:r.strategy})),{items:u,_metadata:{totalPages:d}}=await e.auth.getIPRestrictions(c),g=u;await l(),o({data:{config:r,restrictions:g},pagination:c,totalPages:d,saving:!1}),null==n||n(!0)}catch(t){o({saving:!1,error:Nn(t)}),null==n||n(null,t)}})),g=i((async a=>{const{id:n,callback:i}=a;o({saving:!0,error:null});try{var r;await e.auth.deleteIPRestriction(n);const a=t.auth.restrictionsState.ipRestrictions,c=s(a.pagination),{items:u,_metadata:{totalPages:d}}=await e.auth.getIPRestrictions(c),g=u;await l(),o({data:{config:(null==(r=a.data)?void 0:r.config)||{isActive:!1,strategy:zt.ALLOW},restrictions:g},pagination:c,totalPages:d,saving:!1}),null==i||i(!0)}catch(t){o({saving:!1,error:Nn(t)}),null==i||i(null,t)}})),p=i(l),h=i((async a=>{const{callback:n}=a;o({saving:!0,error:null});try{var i,r;const a=null!=(i=(null==(r=t.auth.userIpData)?void 0:r.ip)||t.auth.userIp)?i:"";await Promise.all([e.auth.createIPRestriction({ip:a,isActive:!0,description:"My IP",strategy:zt.ALLOW}),e.auth.updateIPRestrictionConfig({isActive:!0})]);const l=t.auth.restrictionsState.ipRestrictions,c=s(l.pagination),{items:u,_metadata:{totalPages:d}}=await e.auth.getIPRestrictions(c),g=u;o({data:{config:{isActive:!0,strategy:zt.ALLOW},restrictions:g},userIpValid:!0,pagination:c,totalPages:d,saving:!1}),null==n||n(!0)}catch(t){o({saving:!1,error:t}),null==n||n(!1,t)}})),y=i((async()=>{r({loading:!0,error:null});try{const t=await e.auth.getDomainRestrictionsConfig(),a=(await e.auth.getDomainRestrictions()).items.filter((e=>e.type===t.listType));r({data:{restrictions:a,config:t},loading:!1})}catch(t){r({error:Nn(t),loading:!1})}})),S=i((async a=>{const{callback:n}=a,s=f(a,Or);r({saving:!0,error:null});const i=t.auth.restrictionsState.emailDomainRestrictions;try{var o;await e.auth.createDomainRestriction(s);const t=(await e.auth.getDomainRestrictions()).items.filter((t=>{var e;return t.type===(null==(e=i.data)?void 0:e.config.listType)}));r({data:{config:(null==(o=i.data)?void 0:o.config)||{active:!1,blockPublicDomains:!1,listType:s.type},restrictions:t},saving:!1}),null==n||n(!0)}catch(t){r({saving:!1,error:Nn(t)}),null==n||n(null,t)}})),m=i((async t=>{const{callback:a}=t,n=f(t,Pr);r({saving:!0,error:null});try{const t=await e.auth.updateDomainRestrictionConfig(n),s=(await e.auth.getDomainRestrictions()).items.filter((e=>e.type===t.listType));r({data:{config:t,restrictions:s},saving:!1}),null==a||a(!0)}catch(t){r({saving:!1,error:Nn(t)}),null==a||a(null,t)}})),b=i((async a=>{const{id:n}=a;r({saving:!0,error:null});const s=t.auth.restrictionsState.emailDomainRestrictions;try{var i;await e.auth.deleteDomainRestriction(n);const t=(await e.auth.getDomainRestrictions()).items.filter((t=>{var e;return t.type===(null==(e=s.data)?void 0:e.config.listType)}));r({data:{config:(null==(i=s.data)?void 0:i.config)||{active:!1,blockPublicDomains:!1,listType:zt.ALLOW},restrictions:t},saving:!1})}catch(t){r({saving:!1,error:Nn(t)})}}));return{setRestrictionsState:e=>{Object.assign(t.auth.restrictionsState,e)},setIpRestrictionsState:o,setEmailDomainRestrictionsState:r,__securityCenterSagaWrapper:i,loadIpRestrictions:c,saveIpRestriction:u,saveIpRestrictionsConfig:d,deleteIpRestriction:g,checkIfUserIpValid:p,addCurrentUserIpAndActivate:h,loadEmailDomainRestrictions:y,saveEmailDomainRestriction:S,saveEmailDomainRestrictionsConfig:m,deleteEmailDomainRestriction:b}},_r={loaders:{},errors:{},recommendations:void 0,insights:void 0,hasSecurityChanges:!1,score:0,breachedPasswordUsersTable:{users:[],usersPageOffset:0,totalUsersItems:0,totalUsersPages:0,queryParams:{_offset:0,_limit:10}},unenrolledMfaUsersTable:{users:[],usersPageOffset:0,totalUsersItems:0,totalUsersPages:0,queryParams:{_offset:0,_limit:10}},inactiveUsersTable:{users:[],usersPageOffset:0,totalUsersItems:0,totalUsersPages:0,queryParams:{_offset:0,_limit:10,_maxInactiveSeconds:7776e3}}},Rr=t=>en(_r,t);let Ur;!function(t){t.RECOMMENDATIONS="recommendations",t.INSIGHTS="insights",t.SEND_BULK_RESET_BREACHED_PASSWORD_EMAILS="sendBulkResetBreachedPasswordEmails",t.SEND_BREACHED_PASSWORD_EMAIL="sendBreachedPasswordEmail",t.BREACHED_PASSWORD_USERS_TABLE="breachedPasswordUsersTable",t.UNENROLLED_MFA_USERS_TABLE="unenrolledMfaUsersTable",t.INACTIVE_USERS_TABLE="inactiveUsersTable"}(Ur||(Ur={}));const Cr=["callback"],Lr=(t,e,a)=>{const n=a,s=async t=>{var a,s,l,c;const{key:u,tableState:d,updateStateKey:g,_offset:p,_limit:h,_preset:y,_email:S,_maxInactiveSeconds:f}=t;r({key:u,value:!1}),o({key:u,value:!0});const m=null!=(a=null!=p?p:null==d||null==(s=d.queryParams)?void 0:s._offset)?a:0,b=null!=(l=null!=h?h:null==d||null==(c=d.queryParams)?void 0:c._limit)?l:10,A=v({_offset:m,_limit:b,_includeSubTenants:!1,_preset:y,_maxInactiveSeconds:f},!!S&&{_email:S});try{const{items:t,_metadata:{totalItems:a,totalPages:s}}=await e.users.getUsersV3(A),o={totalUsersItems:a,totalUsersPages:s,usersPageOffset:m,queryParams:v({_offset:m,_limit:b,_maxInactiveSeconds:f},!!S&&{_email:S})};if(t.length){const a=await(async t=>{const a=t.map((t=>t.id)),n=await e.roles.getRoles(),s=await e.users.getUsersRoles({ids:a});return t.map((t=>{var e,a;const i=null==s||null==(e=s.find((e=>e.userId===t.id)))?void 0:e.roleIds;return v({},t,{roles:null!=(a=null==i?void 0:i.map((t=>{var e;return null!=(e=null==n?void 0:n.find((e=>e.id===t)))?e:[]})))?a:[]})}))})(t);n.setSecurityCenterState({[g]:v({users:a},o)})}else i({[g]:v({users:[]},o)})}catch(t){r({key:u,value:Nn(t)})}finally{o({key:u,value:!1})}},i=e=>{Object.assign(t.auth.securityCenterState,e)},o=e=>{Object.assign(t.auth.securityCenterState,{loaders:v({},t.auth.securityCenterState.loaders,{[e.key]:e.value})})},r=e=>{Object.assign(t.auth.securityCenterState,{errors:v({},t.auth.securityCenterState.errors,{[e.key]:e.value}),loaders:v({},t.auth.securityCenterState.loaders,{[e.key]:!1})})};return{setSecurityCenterState:i,resetSecurityCenterState:()=>{Cn(t,["auth","securityCenterState"],_r)},setSecurityCenterStateLoader:o,setSecurityCenterStateError:r,loadRecommendations:async t=>{const a=Ur.RECOMMENDATIONS;o({key:a,value:!0});try{var n;const{recommendations:a,scoring:s}=await On((()=>e.securityCenter.getRecommendations()),null==t?void 0:t.retryConfig);i({recommendations:a.items,score:null!=(n=null==s?void 0:s.score)?n:0})}catch(t){r({key:a,value:Nn(t)})}finally{o({key:a,value:!1})}},loadInsights:async t=>{const a=Ur.INSIGHTS;o({key:a,value:!0});try{const{insights:a}=await await On((()=>e.securityCenter.getInsights()),null==t?void 0:t.retryConfig);i({insights:a.items})}catch(t){r({key:a,value:Nn(t)})}finally{o({key:a,value:!1})}},sendResetBreachedPasswordEmail:async t=>{const{callback:a}=t,n=f(t,Cr),s=Ur.SEND_BREACHED_PASSWORD_EMAIL;r({key:s,value:!1}),o({key:s,value:!0});try{await e.auth.forgotPassword(n),null==a||a(!0)}catch(t){r({key:s,value:Nn(t)}),null==a||a(!1,t)}finally{o({key:s,value:!1})}},sendBulkResetBreachedPasswordEmails:async t=>{const{callback:a}=t,n=Ur.SEND_BULK_RESET_BREACHED_PASSWORD_EMAILS;r({key:n,value:!1}),o({key:n,value:!0});try{await e.users.sendResetBreachedPasswordEmails(),null==a||a(!0)}catch(t){r({key:n,value:Nn(t)}),null==a||a(!1)}finally{o({key:n,value:!1})}},loadBreachedPasswordUsers:async e=>{var a;const n=Ur.BREACHED_PASSWORD_USERS_TABLE,i=null==(a=t.auth.securityCenterState)?void 0:a.breachedPasswordUsersTable;await s(v({key:n,updateStateKey:"breachedPasswordUsersTable",_preset:ja.BREACHED_PASSWORDS,tableState:i},e))},loadUnenrolledMfaUsers:async e=>{var a;const n=Ur.UNENROLLED_MFA_USERS_TABLE,i=null==(a=t.auth.securityCenterState)?void 0:a.unenrolledMfaUsersTable;await s(v({key:n,updateStateKey:"unenrolledMfaUsersTable",_preset:ja.MFA_UNENROLLED,tableState:i},e))},loadInactiveUsers:async e=>{var a;const n=Ur.INACTIVE_USERS_TABLE,i=null==(a=t.auth.securityCenterState)?void 0:a.inactiveUsersTable;await s(v({key:n,updateStateKey:"inactiveUsersTable",_preset:ja.INACTIVE,tableState:i},e))},markSecurityCenterStateAsChanged:(t=!0)=>{i({hasSecurityChanges:t})}}},Dr={globalPolicy:{loading:!0},publicPolicy:{loading:!1},vendorMfaPolicy:{loading:!0},mfaPolicy:{loading:!0},vendorLockoutPolicy:{loading:!0},lockoutPolicy:{loading:!0},captchaPolicy:{loading:!0},passwordHistoryPolicy:{loading:!0},passwordPolicy:{loading:!0},vendorPasswordHistoryPolicy:{loading:!0},publicAuthStrategyPolicy:{loading:!0},passwordRotationPolicy:{loading:!0}},Nr=t=>en(Dr,t);function Mr(t,e){const a=null!=e,n=null!=t;if(a||n)return a?n?Math.min(t,e):e:t}const Fr=["callback"],xr=["callback"],$r=["callback"],Gr=["callback"],jr=(t,e,a)=>{const n=a,s=async(t,e)=>{var a,s;if(!await n.customLoginEnabled())return t;const o=await i(e);return null!=o&&null!=(a=o.mainAuthStrategies)&&null!=(s=a[0])&&s.strategy?v({},t,{authStrategy:o.mainAuthStrategies[0].strategy}):t},i=async a=>{let n;return n=t.auth.isAuthenticated?await On(e.auth.getPublicAuthStrategiesConfigForAuthenticatedUser,a):await On(e.auth.getVendorPublicAuthStrategiesConfig,a),n},o=e=>{Object.assign(t.auth.securityPolicyState.globalPolicy,e)},r=e=>{Object.assign(t.auth.securityPolicyState.publicPolicy,e)},l=e=>{Object.assign(t.auth.securityPolicyState.mfaPolicy,e)},c=e=>{Object.assign(t.auth.securityPolicyState.vendorMfaPolicy,e)},u=e=>{Object.assign(t.auth.securityPolicyState.lockoutPolicy,e)},d=e=>{Object.assign(t.auth.securityPolicyState.vendorLockoutPolicy,e)},g=e=>{Object.assign(t.auth.securityPolicyState.captchaPolicy,e)},p=e=>{Object.assign(t.auth.securityPolicyState.passwordHistoryPolicy,e)},h=e=>{Object.assign(t.auth.securityPolicyState.vendorPasswordHistoryPolicy,e)},y=e=>{Object.assign(t.auth.securityPolicyState.passwordRotationPolicy,e)},S=e=>{Object.assign(t.auth.securityPolicyState.passwordPolicy,e)},m=e=>{Object.assign(t.auth.securityPolicyState.publicAuthStrategyPolicy,e)},b=async t=>{o({loading:!0,error:null});try{const a=await On((()=>e.auth.getGlobalSecurityPolicy()),null==t?void 0:t.retryConfig);o({policy:a,loading:!1})}catch(t){o({error:Nn(t),loading:!1})}},A=async t=>{l({loading:!0,error:null});try{const a=await On((()=>e.auth.getMfaPolicy()),null==t?void 0:t.retryConfig);l({policy:a,loading:!1})}catch(t){l({error:Nn(t),loading:!1})}},w=async t=>{l({loading:!0,error:null});try{const a=await On((()=>e.auth.getVendorMfaPolicy()),null==t?void 0:t.retryConfig);c({policy:a,loading:!1})}catch(t){c({error:Nn(t),loading:!1})}},T=async t=>{u({loading:!0,error:null});try{const a=await On((()=>e.auth.getLockoutPolicy()),null==t?void 0:t.retryConfig);u({policy:a,loading:!1})}catch(t){u({error:Nn(t),loading:!1})}},E=async t=>{d({loading:!0,error:null});try{const a=await On((()=>e.auth.getVendorLockoutPolicy()),null==t?void 0:t.retryConfig);d({policy:a,loading:!1})}catch(t){d({error:Nn(t),loading:!1})}},I=async t=>{u({loading:!0,error:null});try{const a=await On((()=>e.auth.getCaptchaPolicy()),null==t?void 0:t.retryConfig);g({policy:a,loading:!1})}catch(t){g({error:Nn(t),loading:!1})}},O=async t=>{h({loading:!0,error:null});try{const a=await On((()=>e.auth.getVendorPasswordHistoryPolicy()),null==t?void 0:t.retryConfig);h({policy:a,loading:!1})}catch(t){h({error:Nn(t),loading:!1})}},P=async e=>{m({loading:!0,error:null});try{var a,s,o;const l=await i(null==e?void 0:e.retryConfig);await(async e=>{var a,s;const i=await n.customLoginEnabled();if(!e||!i)return;const{policy:o}=null!=(a=null==(s=t.auth.securityPolicyState)?void 0:s.publicPolicy)?a:{policy:null};r({policy:v({},o,{authStrategy:e}),loading:!1})})(null==l||null==(a=l.mainAuthStrategies)||null==(s=a[0])?void 0:s.strategy),m({policy:l,loading:!1}),null==e||null==(o=e.callback)||o.call(e,l)}catch(t){var l;m({error:Nn(t),loading:!1}),null==e||null==(l=e.callback)||l.call(e,null,t)}};return{setSecurityPolicyState:e=>{Object.assign(t.auth.securityPolicyState,e)},setSecurityPolicyGlobalState:o,setSecurityPolicyPublicState:r,setSecurityPolicyMfaState:l,setSecurityPolicyVendorMfaState:c,setSecurityPolicyLockoutState:u,setSecurityPolicyVendorLockoutState:d,setSecurityPolicyCaptchaState:g,setSecurityPolicyPasswordHistoryState:p,setSecurityPolicyVendorPasswordHistoryState:h,setSecurityPolicyPasswordRotationState:y,resetSecurityPolicyState:()=>{Cn(t,["auth","securityPolicyState"],Dr)},setSecurityPolicyPasswordState:S,setSecurityPolicyAuthStrategyPublicState:m,loadSecurityPolicy:async t=>{const e={retryConfig:null==t?void 0:t.retryConfig};await Promise.all([b(),A(),w(e),T(e),E(e),O(),I(e),P(e)])},loadGlobalSecurityPolicy:b,loadPublicSecurityPolicy:async t=>{r({loading:!0,error:null});try{const a=await e.auth.getVendorConfig(),n=await s(a,null==t?void 0:t.retryConfig);r({policy:n,loading:!1})}catch(t){r({error:Nn(t),loading:!1})}},loadVendorPasswordConfig:async t=>{S({loading:!0,error:null});try{var a;const n=await On((()=>e.auth.getPasswordConfigPolicy()),null==t?void 0:t.retryConfig);S({policy:n,loading:!1}),null==t||null==(a=t.callback)||a.call(t,n)}catch(e){var n;S({error:Nn(e),loading:!1}),null==t||null==(n=t.callback)||n.call(t,null,e)}},loadSecurityPolicyMfa:A,loadSecurityPolicyVendorMfa:w,loadSecurityPolicyLockout:T,loadSecurityPolicyVendorLockout:E,loadSecurityPolicyCaptcha:I,loadSecurityPolicyPasswordHistory:async()=>{p({loading:!0,error:null});try{const t=await e.auth.getPasswordHistoryPolicy();p({policy:t,loading:!1})}catch(t){p({error:Nn(t),loading:!1})}},loadSecurityPolicyVendorPasswordHistory:O,loadSecurityPolicyPasswordRotation:async()=>{y({loading:!0,error:null});try{const t=await e.securityPolicy.getPasswordRotationPolicy(),a=await e.securityPolicy.getVendorPasswordRotationPolicy(),n={passwordRotationVendorConfig:a};t&&(null!=a&&a.isActive?n.passwordRotationTenantConfig=null!=t&&t.isActive?v({},t,{rotationPeriod:Mr(a.rotationPeriod,t.rotationPeriod)}):a:n.passwordRotationTenantConfig=t),y({policy:v({},n),loading:!1})}catch(t){y({error:Nn(t),loading:!1})}},loadPublicAuthStrategiesPolicy:P,saveSecurityPolicyMfa:async t=>{const{callback:a}=t,n=f(t,Fr);l({saving:!0,error:null});try{const t=await e.auth.securityPolicy.saveMfaPolicy(n);l({policy:t,saving:!1}),null==a||a(t)}catch(t){l({saving:!1,error:Nn(t)}),null==a||a(null,t)}},saveSecurityPolicyLockout:async t=>{const{callback:a}=t,n=f(t,xr);u({saving:!0,error:null});try{const t=await e.auth.saveLockoutPolicy(n);u({policy:t,saving:!1}),null==a||a(t)}catch(t){u({saving:!1,error:Nn(t)}),null==a||a(null,t)}},saveSecurityPolicyPasswordHistory:async t=>{const{callback:a}=t,n=f(t,$r);p({saving:!0,error:null});try{const t=await e.auth.savePasswordHistoryPolicy(n);p({policy:t,saving:!1}),null==a||a(t)}catch(t){p({saving:!1,error:Nn(t)}),null==a||a(null,t)}},saveSecurityPolicyPasswordRotation:async t=>{const{callback:a}=t,n=f(t,Gr);y({saving:!0,error:null});try{await e.securityPolicy.savePasswordRotationPolicy(n.passwordRotationTenantConfig||{}),y({policy:n,saving:!1}),null==a||a(n)}catch(t){y({saving:!1,error:Nn(t)}),null==a||a(null,t)}},__getSecurityPolicyPublicStateWithCustomLogin:s}},Br={loading:!1,configurations:{}},Vr=t=>en(Br,t),Wr=["callback"],Hr=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.sessionsPolicyState,e)};return{setSessionsPolicyState:s,resetSessionsPolicyState:()=>{Cn(t,["auth","sessionsPolicyState"],Br)},loadSessionsPolicy:async()=>{s({loading:!0,error:null});try{const t=await e.auth.getSessionConfigurations();s({configurations:t,loading:!1})}catch(t){n.setSessionsState({error:t,loading:!1})}},createOrUpdateSessionsPolicy:async t=>{const{callback:a}=t,i=f(t,Wr);try{s({loading:!0,error:null}),await e.auth.createOrUpdateSessionConfigrations(i),await n.loadSessionsPolicy(),null==a||a(!0)}catch(t){s({error:t,loading:!1})}}}},zr={loading:!1,sessions:[]},Kr=t=>en(zr,t),qr=(t,e,a)=>{const n=e=>{Object.assign(t.auth.sessionsState,e)},s=async t=>{n({loading:!0,error:null});try{const a=await On((()=>e.auth.getCurrentUserSessions()),null==t?void 0:t.retryConfig);n({sessions:a,loading:!1})}catch(t){n({error:Nn(t),loading:!1})}};return{setSessionsState:n,resetSessionsState:()=>{Cn(t,["auth","sessionsState"],zr)},loadUserSessions:s,loadCurrentUserSession:async()=>{n({loading:!0,error:null});try{const t=await e.auth.getCurrentUserSession();n({currentSession:t,loading:!1})}catch(t){n({error:Nn(t),loading:!1})}},deleteUserSession:async t=>{const{id:a}=t;n({loading:!0,error:null});try{await e.auth.deleteSessionForUser(a),await s()}catch(t){n({error:Nn(t),loading:!1})}},deleteAllUserSessions:async()=>{n({loading:!0,error:null});try{await e.auth.deleteAllSessionsForUser(),await s()}catch(t){n({error:Nn(t),loading:!1})}},revokeUserSessions:async t=>{const{callback:a,userId:s}=t;n({loading:!0,error:null});try{await e.auth.revokeSessionsForUser(s),n({loading:!1}),null==a||a(!0)}catch(t){n({error:Nn(t),loading:!1}),null==a||a(!1)}}}};let Jr;!function(t){t.SignUp="SignUp",t.SignUpSuccess="SignUpSuccess",t.VerifyPhone="VerifyPhone"}(Jr||(Jr={}));const Yr={loading:!1,allowSignUps:!1,allowNotVerifiedUsersLogin:!1,firstLoad:!0,stage:Jr.SignUp,strategies:{[F.Email]:{enabled:!0,required:!0},[F.PhoneNumber]:{enabled:!1,required:!1}}},Xr=t=>en(Yr,t),Qr=["events","url"],Zr=["events","url"],tl=(t,e,a)=>{const n=a,s=U.for(t.root.appName),i=e=>{Object.assign(t.auth.signUpState,e)},o=()=>{Cn(t,["auth","signUpState"],Yr)},r=(t,e,a,n,s,i=zn.PASSWORD)=>{var o;const{email:r,name:l,companyName:c,phoneNumber:u,url:d}=t,g={email:r,name:l,companyName:c,url:d,phoneNumber:u||void 0,authenticationType:i,id:e,tenantId:a,createdAt:new Date,activationToken:n};null==s||null==(o=s.signUpComplete)||o.call(s,g),Xn(Jn.SIGNUP_COMPLETED,g)},l=async a=>{const{events:o}=a,l=f(a,Qr);if(i({loading:!0}),!l.phoneNumber)throw new Error("Phone number is required for phone number signup");try{var c,u,d;const{routes:a,onRedirectTo:s}=t.auth,{tenantId:i,userId:g,activationToken:p}=await e.auth.signUpUserWithPhoneNumber(bs(l));l.invitationToken||r(l,g,i,p,o,zn.PHONE_NUMBER);const{enabled:h,siteKey:y}=null!=(c=t.auth.securityPolicyState.captchaPolicy.policy)?c:{},S=h&&y?await(null==(u=window.grecaptcha)||null==(d=u.execute)?void 0:d.call(u,{action:"login"})):"";n.passwordlessPreLogin({recaptchaToken:S,phoneNumber:l.phoneNumber,type:N.SmsCode,callback:(t,e)=>{if(!t&&e)throw e;s(a.loginUrl),n.setLoginState({step:yn.loginWithSmsOtc,phoneNumber:l.phoneNumber})}})}catch(t){s.setAccessToken(null),s.setUser(null),i({error:Nn(t)})}finally{i({loading:!1})}};return{setSignUpState:i,resetSignUpState:o,resetSignUpStateSoft:()=>{const{allowSignUps:e,allowNotVerifiedUsersLogin:a}=t.auth.signUpState;o(),i({allowSignUps:e,allowNotVerifiedUsersLogin:a})},signUpUser:async a=>{const{events:o}=a,c=f(a,Zr);i({loading:!0});const u=t.auth.signUpState.strategies.phoneNumber;if(null!=u&&u.required&&null!=u&&u.enabled&&c.phoneNumber)return l(a);try{const{routes:a,onRedirectTo:s}=t.auth,{shouldActivate:l,user:u,tenantId:d,userId:g,tenants:p=[],activeTenant:h,activationToken:y}=await e.auth.signUpUser(bs(c));if(c.invitationToken||r(c,g,d,y,o),!l&&u&&Ss(u,t.root.appName)){const t=await n.getMfaRequiredState(u,Tn,!0,c.email);n.setAuthState(t),s(a.loginUrl)}else if(l&&y){const t=new URLSearchParams({userId:g||"",token:y||""}),e=`${a.activateWithOTCUrl}?${t.toString()}`;i({loading:!1,shouldActivate:l,stage:Jr.SignUpSuccess}),s(e)}else{const e=t.auth.tenantsState;i({loading:!1,shouldActivate:l,stage:Jr.SignUpSuccess}),n.setAuthState({user:u,isAuthenticated:!(null==u||!u.accessToken),tenantsState:v({},e,{tenants:p,activeTenant:h})})}}catch(t){s.setAccessToken(null),s.setUser(null),i({error:Nn(t)})}finally{i({loading:!1})}},signUpUserWithPhoneNumber:l,loadAllowSignUps:async t=>{i({loading:!0});try{var a;const s=await On(e.auth.getVendorConfig,null==t?void 0:t.retryConfig),o=await n.__getSecurityPolicyPublicStateWithCustomLogin(s,null==t?void 0:t.retryConfig),{allowSignups:r,allowNotVerifiedUsersLogin:l}=s;i({loading:!1,allowSignUps:r,allowNotVerifiedUsersLogin:l,firstLoad:!1}),n.setSecurityPolicyPublicState({policy:o,loading:!1}),null==t||null==(a=t.callback)||a.call(t,o||s)}catch(e){var s;i({loading:!1,error:Nn(e),firstLoad:!1}),null==t||null==(s=t.callback)||s.call(t,null,e)}},loadSignUpStrategies:async()=>{try{const t=await e.auth.getSignUpStrategies();i({strategies:t.reduce(((t,{isActive:e,strategy:a,isRequired:n})=>(t[a]={enabled:e,required:n},t)),{})})}catch(t){}}}},el={loading:!1,error:null,phoneNumbers:void 0},al=t=>en(el,t),nl=["callback"],sl=["callback"],il=["callback"],ol=["callback","phoneId"],rl=["callback","phoneId"],ll=["callback"],cl=(t,e,a)=>{const n=e=>{Object.assign(t.auth.smsState,e)},s=async()=>{n({loading:!0});const t={_limit:10,_offset:0};try{const{items:a}=await e.userPhoneNumbers.getUserPhoneNumbers(t);n({phoneNumbers:a})}catch(t){n({error:Nn(t)})}finally{n({loading:!1})}},i=async()=>{n({loading:!0});try{const t=await e.userPhoneNumbers.getUserOwnPhoneNumbers();n({phoneNumbers:t})}catch(t){n({error:Nn(t)})}finally{n({loading:!1})}};return{setSmsState:n,resetSmsState:()=>{Cn(t,["auth","smsState"],el)},loadPhoneNumbers:s,loadUserOwnPhoneNumbers:i,setUpPhoneNumber:async t=>{const{callback:a}=t,i=f(t,sl);try{const{otcToken:t}=await e.userPhoneNumbers.createPhoneNumber(i);n({otcToken:t}),await s(),null==a||a(!0)}catch(t){n({error:Nn(t)}),null==a||a(!1,t)}},setUpOwnPhoneNumber:async t=>{const{callback:a}=t,s=f(t,nl);try{const{otcToken:t}=await e.userPhoneNumbers.createPhoneNumber(s);n({otcToken:t}),await i(),null==a||a(!0)}catch(t){n({error:Nn(t)}),null==a||a(!1,t)}},verifyPhoneNumber:async t=>{const{callback:a}=t,i=f(t,il);n({loading:!0});try{await e.userPhoneNumbers.verifyPhoneNumber(i),await s(),null==a||a(!0)}catch(t){n({error:Nn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},deletePhoneNumber:async t=>{const{callback:a,phoneId:s}=t;f(t,ol),n({loading:!0});try{const{otcToken:t}=await e.userPhoneNumbers.deletePhoneNumber(s);n({otcToken:t}),null==a||a(!0)}catch(t){n({error:Nn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},verifyDeletePhoneNumber:async t=>{const{callback:a,phoneId:i}=t,o=f(t,rl);n({loading:!0});try{await e.userPhoneNumbers.verifyDeletePhoneNumber(i,o),await s(),null==a||a(!0)}catch(t){n({error:Nn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}},preVerifyPhoneNumber:async t=>{const{callback:a}=t,s=f(t,ll);n({loading:!0});try{const{otcToken:t}=await e.userPhoneNumbers.preVerifyPhoneNumber(s);n({otcToken:t}),null==a||a(!0)}catch(t){n({error:Nn(t)}),null==a||a(!1,t)}finally{n({loading:!1})}}}},ul={firstLoad:!0,loading:!1,error:""},dl=t=>en(ul,t),gl=["authorizationUrl"],pl=["events","url"],hl=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.socialLoginState,e)};return{setSocialLoginsState:s,resetSocialLoginsState:()=>{Cn(t,["auth","socialLoginState"],ul)},setSocialLoginError:t=>{s({error:t.error,loading:!1,firstLoad:!1})},loadSocialLoginsConfiguration:async()=>{try{s({loading:!0});const t=await e.auth.getSocialLoginProviders();s({socialLoginsConfig:t,loading:!1,firstLoad:!1})}catch(t){s({error:Nn(t),loading:!1,firstLoad:!1})}},loadSocialLoginsConfigurationV2:async a=>{try{var n;const i=t.root.context;s({loading:!0});const o=await(async a=>{let n;return n=t.auth.isAuthenticated?await On(e.auth.getSocialLoginProvidersV2ForAuthenticatedUser,a):await On(e.auth.getSocialLoginProvidersV2,a),n})(null==a?void 0:a.retryConfig),{providers:r}=await On(e.auth.getCustomSocialLoginProvidersV1,null==a?void 0:a.retryConfig),l={socialLoginsConfigV2:o.map((t=>{let{authorizationUrl:a}=t,n=f(t,gl);const s=e.fetch.getBaseUrl(i,null!=a?a:"");return v({},n,{authorizationUrl:a?`${s}${a}`:null})})),customSocialLoginsConfig:r,loading:!1,firstLoad:!1};s(l),null==a||null==(n=a.callback)||n.call(a,l)}catch(t){var i;null==a||null==(i=a.callback)||i.call(a,null,t),s({error:Nn(t),loading:!1,firstLoad:!1})}},loginViaSocialLogin:async t=>{const{events:a,url:i}=t,o=f(t,pl);try{s({loading:!0});const{email:t,isNewUser:c,userId:u,tenantId:d,name:g}=await e.auth.loginViaSocialLogin(o);if(c){var r,l;const e={email:t,url:i,createdAt:new Date,id:u,tenantId:d},n=v({},e,{socialProvider:o.provider,authenticationType:zn.SOCIAL_LOGIN});null==a||null==(r=a.signUpComplete)||r.call(a,n),Xn(Jn.SIGNUP_COMPLETED,n);const s=v({},e,{origin:Hn.SOCIAL_LOGIN,name:g});null==a||null==(l=a.userVerified)||l.call(a,s),Xn(Jn.USER_VERIFIED,s)}u&&localStorage.setItem("userId",u),n.setLoginState({email:t,isNewUser:c}),n.refreshTokenForSocialLogins(),localStorage.removeItem("register-quick-login"),s({loading:!1})}catch(t){s({loading:!1,error:Nn(t,"Failed to authenticate"),firstLoad:!1})}}}},yl={firstLoad:!0,loading:!0,saving:!1,errors:{},loaders:{},ssoConfigurations:[]},Sl=t=>en(yl,t),vl=["callback","samlVendor"],fl=["callback"],ml=["callback","ssoConfigId"],bl=["callback","ssoConfigId"],Al=["callback","ssoConfigId"],wl=(t,e,a)=>v({},((t,e,a)=>{const n=a,s=async()=>{try{const t=await e.auth.getSamlRoles(),a=await e.auth.getSamlRolesGroups();i({authorizationRoles:t.roleIds,rolesGroups:a,error:void 0})}catch(t){i({error:Nn(t)})}},i=e=>{Object.assign(t.auth.ssoState,e)};return{setSSOState:i,resetSSOState:()=>{Cn(t,["auth","ssoState"],yl)},setSSOLoader:e=>{Object.assign(t.auth.ssoState,{loaders:v({},t.auth.ssoState.loaders,{[e.key]:e.value})})},setSSOError:e=>{Object.assign(t.auth.ssoState,{errors:v({},t.auth.ssoState.errors,{[e.key]:e.value}),loaders:v({},t.auth.ssoState.loaders,{[e.key]:!1})})},loadSSOConfigurations:async()=>{try{var t,a;i({loading:!0});const n=await e.auth.getSamlConfiguration(),s=await e.auth.getOidcConfiguration(),o=await e.metadata.getSamlMetadata();n.acsUrl=null==o||null==(t=o.configuration)?void 0:t.acsUrl,n.spEntityId=null==o||null==(a=o.configuration)?void 0:a.spEntityId,n.isSamlActive=null==o?void 0:o.isActive,i({samlConfiguration:n,oidcConfiguration:s,loading:!1,firstLoad:!1})}catch(t){i({error:Nn(t),loading:!1})}},saveSSOConfigurations:async a=>{const{callback:n,samlVendor:s}=a,o=f(a,vl),r=t.auth.ssoState.samlConfiguration,l=v({},r,o);let c="saving";(null==l?void 0:l.enabled)!==(null==r?void 0:r.enabled)&&(c="loading");try{if(null==l||!l.domain)return void i({samlConfiguration:v({},r,l)});if(i({error:void 0,[c]:!0}),a.type===io.Saml){var u,d;const t=await e.metadata.getSamlMetadata();l.acsUrl=null==t||null==(u=t.configuration)?void 0:u.acsUrl,l.spEntityId=null==t||null==(d=t.configuration)?void 0:d.spEntityId}const t=_n(l,["validated","generatedVerification","createdAt","updatedAt"]);(null==r?void 0:r.domain)!==(null==t?void 0:t.domain)&&(t.ssoEndpoint="",t.publicCertificate="",t.signRequest=!1),t.type=null==s?void 0:s.toLowerCase();const o=await e.auth.updateSamlConfiguration(t);o.isSamlActive=null==r?void 0:r.isSamlActive,i({samlConfiguration:o,error:void 0,[c]:!1}),null==n||n(!0)}catch(t){i({samlConfiguration:r,error:Nn(t),[c]:!1}),null==n||n(null,t)}},saveSSOConfigurationsFile:async a=>{const n=t.auth.ssoState.samlConfiguration,s="saving";i({error:void 0,[s]:!0});try{const t=await _i(a[0]),o=await e.auth.updateSamlVendorMetadata({metadata:t});o.isSamlActive=null==n?void 0:n.isSamlActive,i({samlConfiguration:o,error:void 0,[s]:!1})}catch(t){i({samlConfiguration:n,error:Nn(t),[s]:!1})}},saveSSOConfigurationsFileWithCallback:async a=>{const{configFile:n,callback:s}=a,o=t.auth.ssoState.samlConfiguration,r="saving";i({error:void 0,[r]:!0});try{const t=await _i(n),a=await e.auth.updateSamlVendorMetadata({metadata:t});a.isSamlActive=null==o?void 0:o.isSamlActive,i({samlConfiguration:a,error:void 0,[r]:!1}),null==s||s(!0)}catch(t){i({samlConfiguration:o,error:Nn(t),[r]:!1}),null==s||s(null,t)}},validateSSODomain:async a=>{const{callback:n}=null!=a?a:{},s=t.auth.ssoState.samlConfiguration;if(!s){const t=new Error("IllegalState: samlConfiguration is not defined");return console.error(t),void(null==n||n(null,t))}try{i({error:void 0,saving:!0}),await e.auth.validateSamlDomain(),i({samlConfiguration:v({},s,{validated:!0}),error:void 0,saving:!1}),null==n||n(!0)}catch(t){i({samlConfiguration:v({},s,{validated:!1}),error:Nn(t),saving:!1}),null==n||n(null,t)}},loadSSOAuthorizationRoles:async()=>{try{const t=await e.auth.getSamlRoles(),a=await e.auth.getSamlRolesGroups();i({authorizationRoles:t.roleIds,rolesGroups:a,error:void 0})}catch(t){i({error:Nn(t)})}},updateSSOAuthorizationRoles:async t=>{const{callback:a,authorizationRoles:n,groups:o}=t;try{i({error:void 0,saving:!0}),await e.auth.updateSamlRoles({roleIds:n}),o&&await(async t=>{try{await Promise.all(t.map((t=>e.auth.updateSamlGroup({id:t.id,roleIds:t.roleIds,group:t.group}))))}catch(t){i({error:Nn(t)})}})(o),await s(),i({error:void 0,saving:!1}),null==a||a(!0)}catch(t){i({error:Nn(t),saving:!1}),null==a||a(null,t)}},deleteSamlGroup:async t=>{const{id:a,callback:n}=t;try{i({error:void 0,saving:!0}),await e.auth.deleteSamlGroup({id:a}),await s(),i({error:void 0,saving:!1}),null==n||n(!0)}catch(t){i({error:Nn(t),saving:!1}),null==n||n(null,t)}},createSamlGroup:async t=>{const{group:a,roleIds:n,callback:o}=t;try{i({error:void 0,saving:!0}),await e.auth.createSamlGroup({group:a,roleIds:n}),await s(),i({error:void 0,saving:!1}),null==o||o(!0)}catch(t){i({error:Nn(t),saving:!1}),null==o||o(null,t)}},oidcPostlogin:async t=>{const a={code:t.code,redirectUri:t.redirectUri,RelayState:t.state};try{i({loading:!0}),await e.auth.oidcPostLoginV2(a),await n.__refreshToken(),i({loading:!1})}catch(t){i({loading:!1,error:Nn(t,"Failed to authenticate"),firstLoad:!1})}}}})(t,e,a),((t,e,a)=>{const n=a,s=async t=>{try{return await On((()=>e.auth.getOidcConfiguration()),t)}catch(t){return null}},i=async t=>{try{return await On((()=>e.metadata.getSamlMetadata()),t)}catch(t){return null}},o=async(t,e,a)=>{n.setSSOLoader({key:t,value:!0});try{await a()}catch(a){n.setSSOError({key:t,value:Nn(a)}),null==e||e(null,a)}finally{n.setSSOLoader({key:t,value:!1})}};return{loadSSOConfigurationsV2:async t=>{await o(so.LOAD_SSO_CONFIGURATIONS,void 0,(async()=>{const[a,o]=await Promise.all([s(null==t?void 0:t.retryConfig),i(null==t?void 0:t.retryConfig)]),r=await On((()=>e.auth.getSSOConfigurations()),null==t?void 0:t.retryConfig);n.setSSOState({ssoConfigurations:r,oidcConfiguration:a,samlMetadata:o})}))},saveSSOConfigurationV2:async a=>{const{callback:s}=a,i=f(a,fl),r=t.auth.ssoState.ssoConfigurations;await o(so.SAVE_SSO_CONFIGURATION,s,(async()=>{var t;const a=await e.auth.createSSOConfiguration(v({},i,{enabled:null!=(t=i.enabled)&&t}));n.setSSOState({ssoConfigurations:[...r,a]}),null==s||s(a)}))},updateSSOConfiguration:async a=>{const{callback:s,ssoConfigId:i}=a,r=f(a,ml),l=t.auth.ssoState.ssoConfigurations;await o(so.UPDATE_SSO_CONFIGURATION,s,(async()=>{const t=await e.auth.updateSSOConfiguration(i,r),a=l.map((e=>e.id===i?t:e));n.setSSOState({ssoConfigurations:a}),null==s||s(t)}))},deleteSSOConfiguration:async a=>{const{ssoConfigId:s,callback:i}=a,r=t.auth.ssoState.ssoConfigurations;await o(so.DELETE_SSO_CONFIGURATION,i,(async()=>{await e.auth.deleteSSOConfiguration(s),n.setSSOState({ssoConfigurations:r.filter((({id:t})=>t!==s))}),null==i||i(!0)}))},saveSSODomain:async a=>{const{callback:s,ssoConfigId:i}=a,r=f(a,bl),l=t.auth.ssoState.ssoConfigurations;await o(so.SAVE_SSO_DOMAIN,s,(async()=>{const t=await e.auth.createSSODomain(i,r),a=l.map((e=>e.id===i?v({},e,{domains:[...e.domains,t]}):e));n.setSSOState({ssoConfigurations:a}),null==s||s(t)}))},deleteSSODomain:async a=>{const{ssoConfigId:s,domainId:i,callback:r}=a,l=t.auth.ssoState.ssoConfigurations;await o(so.DELETE_SSO_DOMAIN,r,(async()=>{await e.auth.deleteSSODomain(s,i);const t=l.map((t=>t.id===s?v({},t,{domains:t.domains.filter((({id:t})=>t!==i))}):t));n.setSSOState({ssoConfigurations:t}),null==r||r(!0)}))},validateSSODomainV2:async a=>{const{callback:s,domainId:i,ssoConfigId:r}=a;await o(so.VALIDATE_SSO_DOMAIN,s,(async()=>{const a=t.auth.ssoState.ssoConfigurations;await e.auth.validateSSODomainV2(r,i);const o=a.map((t=>t.id===r?v({},t,{domains:t.domains.map((t=>t.id===i?v({},t,{validated:!0}):t))}):t));n.setSSOState({ssoConfigurations:o}),null==s||s(!0)}))},setSSOGroups:async a=>{const{groupsToAdd:s,groupsToDelete:i,ssoConfigId:r,callback:l}=a;await o(so.SAVE_SSO_GROUPS,l,(async()=>{const a=t.auth.ssoState.ssoConfigurations;await Promise.all(i.map((t=>e.auth.deleteSSOGroup(r,t)))),await Promise.all(s.map((t=>e.auth.createSSOGroup(r,t))));const o=await e.auth.getSSOGroups(r),c=a.map((t=>t.id===r?v({},t,{groups:o}):t));n.setSSOState({ssoConfigurations:c}),null==l||l(!0)}))},updateSSOGroups:async t=>{const{ssoConfigId:a,changedGroups:n,callback:s}=t;await o(so.SAVE_SSO_GROUPS,s,(async()=>{await Promise.all(n.map((t=>e.auth.updateSSOGroup(a,t)))),null==s||s(!0)}))},setSSODefaultRoles:async a=>{const{callback:s,ssoConfigId:i,roleIds:r}=a;await o(so.UPDATE_SSO_DEFAULT_ROLES,s,(async()=>{const a=t.auth.ssoState.ssoConfigurations;await e.auth.setSSODefaultRoles(i,{roleIds:r});const o=a.map((t=>t.id===i?v({},t,{roleIds:r}):t));n.setSSOState({ssoConfigurations:o}),null==s||s(!0)}))},saveSSOConfigurationByMetadata:async a=>{const{configFile:s,callback:i}=a;await o(so.SAVE_SSO_CONFIGURATION_BY_METADATA,i,(async()=>{const a=t.auth.ssoState.ssoConfigurations,o=await _i(s),r=await e.auth.createSSOConfigurationByMetadata({metadata:o});n.setSSOState({ssoConfigurations:[...a,r]}),null==i||i(r)}))},updateSSOConfigurationByMetadata:async a=>{const{callback:s,ssoConfigId:i,configFile:r}=a;await o(so.UPDATE_SSO_CONFIGURATION_BY_METADATA,s,(async()=>{const a=t.auth.ssoState.ssoConfigurations,o=await _i(r),l=await e.auth.updateSSOConfigurationByMetadata(i,{metadata:o}),c=a.map((t=>t.id===i?l:t));n.setSSOState({ssoConfigurations:c}),null==s||s(l)}))},saveSSOConfigurationByUrl:async a=>{const{metadataUrl:s,configMetadata:i,ssoConfigId:r,callback:l}=a;await o(so.SAVE_SSO_CONFIGURATION_BY_METADATA,l,(async()=>{const a=t.auth.ssoState.ssoConfigurations,o={url:s,configMetadata:i};let c,u;r?(c=await e.auth.updateSSOConfigurationByMetadataUrl(r,o),u=a.map((t=>t.id===r?c:t))):(c=await e.auth.createSSOConfigurationByMetadataUrl(o),u=[c,...a]),n.setSSOState({ssoConfigurations:u}),null==l||l(c)}))},saveSSOConfigurationByData:async a=>{const{callback:s,ssoConfigId:i}=a,r=f(a,Al),l=t.auth.ssoState.ssoConfigurations;await o(so.SAVE_SSO_CONFIGURATION,s,(async()=>{let t,a;i?(t=await e.auth.updateSSOConfiguration(i,r),a=l.map((e=>e.id===i?t:e))):(t=await e.auth.createSSOConfiguration(r),a=[t,...l]),n.setSSOState({ssoConfigurations:a}),null==s||s(t)}))}}})(t,e,a)),Tl={loading:!1,mfaDevices:void 0,mfaToken:""},El=t=>en(Tl,t),Il=(t,e,a)=>{const n=a;return v({setStepUpState:e=>{Object.assign(t.auth.stepUpState,e)},resetStepUpState:()=>{Cn(t,["auth","stepUpState"],Tl)},stepUpWithAuthenticator:async t=>{await n.mfaWithAuthenticator(t,n.setStepUpState,!0)},preVerifyMFASMSForStepUp:async t=>{await n.preVerifyMFASMS(t,n.setStepUpState)},verifyMFASMSForStepUp:async t=>{await n.verifyMFASMS(t,n.setStepUpState,!0)},preVerifyMFAWebAuthnForStepUp:async t=>{await n.preVerifyMFAWebAuthn(t,n.setStepUpState)},verifyMFAWebAuthnForStepUp:async t=>{await n.verifyMFAWebAuthn(t,n.setStepUpState,!0)},preVerifyMFAEmailCodeForStepUp:async t=>{await n.preVerifyMFAEmailCode(t,n.setStepUpState)},verifyMFAEmailCodeForStepUp:async t=>{await n.verifyMFAEmailCode(t,n.setStepUpState)}},((t,e,a)=>{const n=a;return{generateStepUpSession:async a=>{const{maxAge:s,callback:i}=a;n.setStepUpState({mfaDevices:void 0,mfaToken:""});try{const t=await e.auth.generateStepupSession({maxAge:s});t.hasOwnProperty("user")?await(async t=>{await n.afterAuthenticationStateUpdate(t),await n.afterStepUpAuthNavigation()})(t):await(async({mfaToken:t,mfaDevices:e})=>{n.setStepUpState({mfaDevices:e,mfaToken:t});const a=await is(e);n.setMfaState({step:a})})(t),null==i||i(!0)}catch(e){null==i||i(!1),await(async e=>{if((t=>"MFA is not enrolled"===(null==t?void 0:t.message))(e))return void n.setMfaState({step:Yn.noMFAEnrolledStepUp});window.localStorage.setItem(pn,"true");const a=t.auth.routes;U.for(t.root.appName).onRedirectTo(a.logoutUrl,{preserveQueryParams:!0})})(e)}}}})(t,e,a),((t,e,a)=>{const n=a;return{stepUpHostedLogin:async e=>{var a,s;const i={acr_values:un},{maxAge:o}=e||{};void 0!==o&&(i.max_age=o.toString());const r=null==(a=t.auth.tenantsState)||null==(s=a.activeTenant)?void 0:s.alias;r&&(i.organization=r),gs(),window.localStorage.setItem(pn,"true"),await n.__requestHostedLoginAuthorize(i)}}})(t,0,a))},Ol={loaders:{},pageOffset:0,pageSize:20,errors:{},users:[],allUsers:[],roles:[],permissions:[],totalPages:0,shouldShowSubTenantUsersIfReseller:!1,allUsersQueryParams:{_filter:null,_offset:0,_limit:20,_order:"DESC",_sortBy:"name"},addUserDialogState:{loading:!1,open:!1},deleteUserDialogState:{loading:!1,open:!1},lockUserDialogState:{loading:!1,open:!1},enableUserDialogState:{loading:!1,open:!1},disableUserDialogState:{loading:!1,open:!1}},Pl=t=>en(Ol,t),kl=["callback","appIds"],_l=["roles"],Rl=["callback","profileImage"],Ul=["callback"],Cl=["callback"],Ll=["callback"],Dl=["callback","userId"],Nl=["callback"],Ml=["callback"],Fl=["callback"],xl=["callback"],$l=["callback"],Gl=["callback"],jl=(t,e,a)=>{const n=e=>{Object.assign(t.auth.teamState,e)};return v({setTeamLoader:e=>{Object.assign(t.auth.teamState,{loaders:v({},t.auth.teamState.loaders,{[e.key]:e.value})})},setTeamError:e=>{Object.assign(t.auth.teamState,{errors:v({},t.auth.teamState.errors,{[e.key]:e.value}),loaders:v({},t.auth.teamState.loaders,{[e.key]:!1})})},setTeamState:n,resetTeamState:()=>{Cn(t,["auth","teamState"],Ol)},openAddUserDialog:t=>{n({addUserDialogState:v({open:!0,loading:!1,error:!1},t)})},closeAddUserDialog:e=>{var a,s;null==(a=(s=t.auth.teamState.addUserDialogState).onClose)||a.call(s,e),n({addUserDialogState:{loading:!1,error:!1,open:!1}})},openDeleteUserDialog:t=>{n({deleteUserDialogState:v({open:!0,loading:!1,error:!1},t)})},closeDeleteUserDialog:e=>{var a,s;null==(a=(s=t.auth.teamState.deleteUserDialogState).onClose)||a.call(s,e),n({deleteUserDialogState:{loading:!1,error:!1,open:!1}})},lockUser:async t=>{}},((t,e,a)=>{const n=a,s=async t=>{try{const{groups:a}=await On((()=>e.groups.getGroups({_groupsRelations:xa.roles})),t);return a}catch(t){return[]}},i=async t=>{n.setTeamLoader({key:ws.ROLES_AND_PERMISSIONS,value:!0});try{var a;const s=null==t?void 0:t.retryConfig,[{items:i},{items:o}]=await Promise.all([On((()=>e.teams.loadAvailableRoles()),s),On((()=>e.teams.loadAvailablePermissions()),s)]);n.setTeamState({roles:i,permissions:o}),null==t||null==(a=t.callback)||a.call(t,{roles:i,permissions:o})}catch(e){var s;null==t||null==(s=t.callback)||s.call(t,null,e),n.setTeamError({key:ws.ROLES_AND_PERMISSIONS,value:Nn(e)})}finally{n.setTeamLoader({key:ws.ROLES_AND_PERMISSIONS,value:!1})}};return{loadRoles:i,loadUsers:async a=>{var s,o,r,l;const{silentLoading:c,callback:u}=a,d=t.auth.teamState,g=null!=(s=a.pageSize)?s:d.pageSize,p=null!=(o=a.pageOffset)?o:d.pageOffset,h=null!=(r=a.filter)?r:d.filter,y=null!=(l=a.sort)?l:d.sort;n.setTeamLoader({key:ws.USERS,value:!c}),n.setTeamState({pageSize:g,pageOffset:p,filter:h,sort:y});try{const[{items:t,totalPages:a,totalItems:s}]=await Promise.all([e.teams.loadUsers({pageSize:g,pageOffset:p,filter:h,sort:y}),i()]);n.setTeamState({users:t,totalPages:a,totalItems:s}),null==u||u(t)}catch(t){n.setTeamError({key:ws.USERS,value:Nn(t)}),n.setTeamState({totalPages:0,users:[]}),null==u||u(null,t)}n.setTeamLoader({key:ws.USERS,value:!1})},loadUsersV2:async o=>{var r,l,c,u,d;const{silentLoading:g,callback:p,shouldLoadRoles:h=!0,shouldLoadApps:y,retryConfig:S}=o,f=t.auth.teamState,m=null!=(r=o.pageSize)?r:f.pageSize,b=null!=(l=o.pageOffset)?l:f.pageOffset,A=null!=(c=o.filter)?c:f.filterV2,w=null!=(u=o.sort)?u:f.sortV2,T=null!=(d=null==o?void 0:o.shouldShowSubTenantUsersIfReseller)?d:null==f?void 0:f.shouldShowSubTenantUsersIfReseller;n.setTeamLoader({key:ws.USERS,value:!g}),n.setTeamState({pageSize:m,pageOffset:b,filterV2:A,sortV2:w});try{const[{items:t,_metadata:{totalPages:n,totalItems:r}},{items:l},{items:c},u]=await Promise.all([On((()=>e.users.getUsersV2(v({},(null==A?void 0:A.length)&&{_filter:A},w&&{_sortBy:w},o.order&&{_order:o.order},{_offset:b,_limit:m,_includeSubTenants:T}))),S),On((()=>e.teams.loadAvailableRoles()),S),On((()=>e.teams.loadAvailablePermissions()),S),s(S),h?i({retryConfig:S}):void 0]),d=t.map((t=>{var e;return v({},t,{groups:null==t||null==(e=t.groups)?void 0:e.map((t=>u.filter((e=>e.id===t.id)))).flat()})})).map((t=>v({},t,{roleIds:t.roles.map((t=>t.id))}))),g=await a.mapUsersWithApplicationData({shouldLoadApps:y,users:d,retryConfig:S});a.setTeamState({users:g,totalPages:n,totalItems:r,roles:l,permissions:c}),null==p||p(t)}catch(t){console.error("Failed to load users",t),n.setTeamError({key:ws.USERS,value:Nn(t)}),n.setTeamState({totalPages:0,users:[]}),null==p||p(null,t)}n.setTeamLoader({key:ws.USERS,value:!1})},addUser:async s=>{const{callback:i,appIds:o}=s,r=f(s,kl),l=t.auth.teamState;n.setTeamState({addUserDialogState:v({},l.addUserDialogState,{loading:!0})});try{var c;const t=await e.teams.addUser(r),{roles:s}=t,u=v({},f(t,_l),{roleIds:null!=(c=null==s?void 0:s.map((t=>t.id)))?c:[]}),d=await a.assignNewUserToApps({appIds:o,user:u});d&&(u.applications=d),null==i||i(u),n.setTeamState({users:[u,...l.users],addUserDialogState:{open:!1,loading:!1}})}catch(t){console.error("Failed to add user",t),n.setTeamState({addUserDialogState:v({},l.addUserDialogState,{loading:!1,error:Nn(t)})}),null==i||i(null,t)}},addUsersBulk:async a=>{const{callback:s}=a,i=t.auth.teamState;n.setTeamState({addUserDialogState:v({},i.addUserDialogState,{loading:!0})});const o=[],r=[],l=a.emails.map((t=>v({email:t,roleIds:a.roleIds},a.expirationInSeconds&&{expirationInSeconds:a.expirationInSeconds})));n.setTeamState({addUserDialogState:{open:!0,loading:!0}});for(let t=0;t<l.length;t++){const a=l.at(t);try{await e.teams.addUser(a),o.push(a.email)}catch(t){r.push(a.email)}}const c={pageOffset:0,pageSize:10,filter:"",silentLoading:a.emails.length>0};await n.loadUsersV2(c),n.setTeamState({addUserDialogState:{loading:!1}}),null==s||s({unallowedEmails:r,allowedEmails:o})},updateUser:async a=>{const{callback:s}=a,i=f(a,Rl),{id:o}=i,r=t.auth.teamState,l=r.users.find((t=>t.id===i.id));if(void 0!==l){n.setTeamLoader({key:ws.UPDATE_USER,value:o||""}),n.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!0})}),n.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!0}),users:r.users.map((t=>t.id===i.id?v({},t,i):t))});try{var c;l.roleIds.length>0&&0===(null==(c=i.roleIds)?void 0:c.length)&&(i.roleIds=[""]);const{item:t}=await e.teams.updateUser(i);null==s||s(t),n.setTeamState({users:r.users.map((e=>e.id===t.id?v({},e,t,{groups:e.groups,createdAt:e.createdAt,customData:e.customData,lastLogin:e.lastLogin}):e))}),n.setTeamLoader({key:ws.UPDATE_USER,value:!1})}catch(t){n.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!1,error:Nn(t)}),users:r.users.map((t=>t.id===i.id?v({},t,l):t))}),n.setTeamLoader({key:ws.UPDATE_USER,value:!1}),null==s||s(null,t)}}else null==s||s(null,"User not in state")},deleteUser:async a=>{const{callback:s}=a,i=f(a,Ul),o=t.auth.teamState;n.setTeamState({deleteUserDialogState:v({},o.deleteUserDialogState,{loading:!0})});try{await e.teams.deleteUser(i),null==s||s(!0),n.setTeamState({users:o.users.filter((t=>t.id!==i.userId)),deleteUserDialogState:{open:!1,loading:!1}})}catch(t){n.setTeamState({deleteUserDialogState:v({},o.deleteUserDialogState,{loading:!1,error:Nn(t)})}),null==s||s(null,t)}},enableUser:async a=>{const{callback:s,userId:i}=a,o=t.auth.teamState;n.setTeamState({enableUserDialogState:v({},o.enableUserDialogState,{loading:!0})});try{await e.teams.enableUser(i),null==s||s(!0),n.setTeamState({users:o.users.map((t=>t.id===i?v({},t,{isDisabled:!1}):t)),enableUserDialogState:{open:!1,loading:!1}})}catch(t){n.setTeamState({enableUserDialogState:v({},o.enableUserDialogState,{loading:!1,error:Nn(t)})}),null==s||s(null,t)}},disableUser:async a=>{const{callback:s,userId:i}=a,o=t.auth.teamState;n.setTeamState({disableUserDialogState:v({},o.disableUserDialogState,{loading:!0})});try{await e.teams.disableUser(i),null==s||s(!0),n.setTeamState({users:o.users.map((t=>t.id===i?v({},t,{isDisabled:!0}):t)),disableUserDialogState:{open:!1,loading:!1}})}catch(t){n.setTeamState({disableUserDialogState:v({},o.disableUserDialogState,{loading:!1,error:Nn(t)})}),null==s||s(null,t)}},getTemporaryUsersConfig:async t=>{n.setTeamError({key:ws.CONFIG_TEMPORARY_USERS,value:!1});try{const a=await On((()=>e.teams.getTemporaryUserConfiguration()),null==t?void 0:t.retryConfig);n.setTeamState({temporaryUsersConfig:a})}catch(t){n.setTeamError({key:ws.CONFIG_TEMPORARY_USERS,value:Nn(t)})}},updateUserExpirationTime:async a=>{const{callback:s}=a,i=f(a,Cl),o=t.auth.teamState;n.setTeamLoader({key:ws.UPDATE_USER_EXPIRATION_TIME,value:!0});try{const t=await e.teams.updateUserExpirationTime(i);n.setTeamState({users:o.users.map((e=>e.id===i.userId?v({},e,{temporaryExpirationDate:new Date(t.temporaryExpirationDate)}):e))}),null==s||s(!0)}catch(t){n.setTeamError({key:ws.UPDATE_USER_EXPIRATION_TIME,value:Nn(t)}),null==s||s(null,t)}finally{n.setTeamLoader({key:ws.UPDATE_USER_EXPIRATION_TIME,value:!1})}},setUserAsPermanent:async a=>{const{callback:s}=a,i=f(a,Ll),o=t.auth.teamState;n.setTeamLoader({key:ws.UPDATE_USER_EXPIRATION_TIME,value:!0});try{await e.teams.setPermanentUser(i.userId),n.setTeamState({users:o.users.map((t=>t.id===i.userId?v({},t,{temporaryExpirationDate:void 0}):t))}),null==s||s(!0)}catch(t){n.setTeamError({key:ws.UPDATE_USER_EXPIRATION_TIME,value:Nn(t)}),null==s||s(null,t)}finally{n.setTeamLoader({key:ws.UPDATE_USER_EXPIRATION_TIME,value:!1})}}}})(t,e,a),((t,e,a)=>{const n=a;return{loadAllSubTenantsUsers:async a=>{var s,i,o,r,l;const{silentLoading:c,callback:u}=a,d=t.auth.teamState.allUsersQueryParams,g={_limit:(null!=(s=a._limit)?s:d._limit)||20,_offset:(null!=(i=a._offset)?i:d._offset)||0,_filter:(null!=(o=a._filter)?o:d._filter)||"",_sortBy:(null!=(r=a._sortBy)?r:d._sortBy)||"name",_order:(null!=(l=a._order)?l:d._order)||"DESC"};n.setTeamLoader({key:ws.USERS,value:!c}),n.setTeamState({allUsersQueryParams:g,pageOffset:g._offset});try{const[{items:t,_metadata:{totalPages:a,totalItems:s}},{items:i},{items:o}]=await Promise.all([e.subTenants.loadAllUsers(v({},g)),e.teams.loadAvailableRoles(),e.teams.loadAvailablePermissions()]);n.setTeamState({allUsers:t,totalPages:a,totalItems:s,roles:i,permissions:o}),null==u||u(t)}catch(t){n.setTeamError({key:ws.USERS,value:Nn(t)}),n.setTeamState({totalPages:0,users:[]}),null==u||u(null,t)}n.setTeamLoader({key:ws.USERS,value:!1})},setUserRolesForSubTenants:async a=>{const{callback:s,userId:i}=a,o=f(a,Dl),r=t.auth.teamState;n.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!0})});try{await e.subTenants.setUserRolesForSubTenants(i,o);const t=r.allUsers.find((t=>t.id===i));let a=[];t&&(a=t.tenants.map((t=>{var e;return v({},t,{roles:(null==(e=o.subTenantsRoles.find((e=>e.tenantId===t.tenantId)))?void 0:e.roleIds.map((t=>r.roles.find((({id:e})=>t===e)))).filter((t=>t)))||t.roles})}))),n.setTeamState({allUsers:[...r.allUsers.filter((t=>t.id!==i)),...t?[v({},t,{tenants:a})]:[]],addUserDialogState:{open:!1,loading:!1}}),null==s||s(!0)}catch(t){n.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!1,error:Nn(t)})}),null==s||s(null,t)}},deleteUserFromSubTenants:async a=>{const{callback:s}=a,i=f(a,Nl),o=t.auth.teamState;n.setTeamState({deleteUserDialogState:v({},o.deleteUserDialogState,{loading:!0})});try{await e.subTenants.removeUserFromTenantAndSubTenants(i),null==s||s(!0),n.setTeamState({allUsers:o.allUsers.filter((t=>t.id!==i.userId&&t.tenants.length===i.subTenants.length)),deleteUserDialogState:{open:!1,loading:!1}})}catch(t){n.setTeamState({deleteUserDialogState:v({},o.deleteUserDialogState,{loading:!1,error:Nn(t)})}),null==s||s(null,t)}},addUserToSubTenants:async a=>{const{callback:s}=a,i=f(a,Ml),o=t.auth.teamState;n.setTeamState({addUserDialogState:v({},o.addUserDialogState,{loading:!0})});try{await e.subTenants.addUserToTenantAndSubTenants(i);const{items:t,_metadata:{totalPages:a,totalItems:o}}=await e.subTenants.loadAllUsers({_limit:20,_offset:0,_filter:"",_sortBy:"name",_order:"DESC"});n.setTeamState({allUsers:t,totalPages:a,totalItems:o,addUserDialogState:{open:!1,loading:!1}}),null==s||s(null)}catch(t){n.setTeamState({addUserDialogState:v({},o.addUserDialogState,{loading:!1,error:Nn(t)})}),null==s||s(null,t)}}}})(t,e,a),((t,e,a)=>{const n=a,s=async(t,e,a,s)=>{n.setTeamLoader({key:t,value:e});try{await s()}catch(e){n.setTeamError({key:t,value:Nn(e)}),null==a||a(null,e)}finally{n.setTeamLoader({key:t,value:!1})}};return{resendActivationLink:async t=>{const{callback:a}=t,n=f(t,Fl);await s(ws.RESEND_ACTIVATE_LINK,n.userId,a,(async()=>{await e.teams.resendActivationLink(n),null==a||a(!0)}))},resendInvitationLink:async t=>{const{callback:a}=t,n=f(t,xl);await s(ws.RESEND_INVITATION_LINK,n.email,a,(async()=>{await e.teams.resendInvitationLink(n),null==a||a(!0)}))},resendInvitationEmail:async t=>{const{callback:a}=t,n=f(t,$l);await s(ws.RESEND_INVITATION_LINK,a,n.email,(async()=>{await e.auth.resendInvitationEmail(n),null==a||a(!0)}))},resendInvitationLinkToAllSubTenants:async t=>{const{callback:a}=t,n=f(t,Gl);await s(ws.RESEND_INVITATION_LINK,n.email,a,(async()=>{await e.teams.resendInvitationLinkToAllTenants(n),null==a||a(!0)}))}}})(0,e,a),((t,e,a)=>{const n=a;return{getInvitationLink:async a=>{n.setTeamError({key:ws.GET_TOKEN_LINK,value:!1});try{const s=null==a?void 0:a.retryConfig;await(async t=>{n.setTeamError({key:ws.CONFIG_TOKEN_LINK,value:!1});try{const a=await On((()=>e.teams.getInviteLinkConfiguration()),t);n.setTeamState({inviteTokenState:v({},a)})}catch(t){n.setTeamError({key:ws.CONFIG_TOKEN_LINK,value:Nn(t)})}})(s);const i=await On((()=>e.teams.getInviteUserLink()),s),{inviteTokenState:o}=t.auth.teamState;n.setTeamState({inviteTokenState:v({},o,i)})}catch(t){n.setTeamError({key:ws.GET_TOKEN_LINK,value:Nn(t)})}},createInvitationLink:async a=>{const{callback:s}=a;n.setTeamError({key:ws.CREATE_TOKEN_LINK,value:!1});const{inviteTokenState:i}=t.auth.teamState;try{const t=await e.teams.createInviteUserLink({expiresInMinutes:43200});n.setTeamState({inviteTokenState:v({},i,t)}),null==s||s(t.token)}catch(t){null==s||s(null,t),n.setTeamError({key:ws.CREATE_TOKEN_LINK,value:Nn(t)})}},updateInvitationLink:async a=>{const{callback:s,expiresInMinutes:i,shouldSendEmail:o}=a;n.setTeamError({key:ws.UPDATE_TOKEN_LINK,value:!1});try{const{inviteTokenState:a}=t.auth.teamState,r=await e.teams.updateInviteUserLink({expiresInMinutes:i,shouldSendEmail:o});n.setTeamState({inviteTokenState:v({},a,r)}),null==s||s(!0)}catch(t){null==s||s(null,t),n.setTeamError({key:ws.UPDATE_TOKEN_LINK,value:Nn(t)})}},deleteInvitationLink:async t=>{const{callback:a}=null!=t?t:{};n.setTeamError({key:ws.DELETE_TOKEN_LINK,value:!1});try{await e.teams.deleteInviteUserLink(),n.setTeamState({inviteTokenState:void 0}),null==a||a(!0)}catch(t){n.setTeamError({key:ws.DELETE_TOKEN_LINK,value:Nn(t)}),null==a||a(!1,t)}}}})(t,e,a))},Bl={tenants:[],subTenants:[],switchingTenant:!1,loading:!0,tenantTree:null},Vl=t=>en(Bl,t),Wl=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auth.tenantsState,e)};return{setTenantsState:s,resetTenantsState:()=>{Cn(t,["auth","tenantsState"],Bl)},switchTenant:async a=>{const{tenantId:s,silentReload:i,callback:o}=a;i?n.setTenantsState({switchingTenant:!0}):n.setAuthState({isLoading:!0});try{await e.tenants.switchTenant({tenantId:s}),i&&n.resetAuthState({isLoading:!1,isAuthenticated:!0,user:t.auth.user}),await n.__refreshToken(),(null==o?void 0:o(!0))||(i?n.setTenantsState({switchingTenant:!1}):n.setAuthState({isLoading:!1}))}catch(t){i?n.setTenantsState({switchingTenant:!1}):n.setAuthState({isLoading:!1}),null==o||o(!1,t)}},loadTenants:async e=>{s({loading:!0});try{var a;const n=ce(t.root.appName),i=await n();s({tenants:i.tenants,activeTenant:i.activeTenant,loading:!1}),null==e||null==(a=e.callback)||a.call(e,[])}catch(t){var n;null==e||null==(n=e.callback)||n.call(e,[],t),s({loading:!1})}},loadSubTenants:async t=>{s({loading:!0});try{var a;const n=await retryIfNeeded((()=>e.tenants.getSubTenants()),null==t?void 0:t.retryConfig);s({subTenants:n,loading:!1}),null==t||null==(a=t.callback)||a.call(t,!0)}catch(e){var n;s({loading:!1}),null==t||null==(n=t.callback)||n.call(t,null,e)}},loadSubTenantsTree:async t=>{s({loading:!0});try{var a;const n=await e.tenants.getSubTenantsAsTree();s({tenantTree:n,loading:!1}),null==t||null==(a=t.callback)||a.call(t,!0)}catch(e){var n;s({loading:!1}),null==t||null==(n=t.callback)||n.call(t,null,e)}}}},Hl=(t,e,a)=>{const n=e=>{t.auth.user&&(t.auth.user.entitlements=e)},s=e=>{var a;no(null==(a=t.auth.user)?void 0:a.entitlements,e)||n(e)};return{setEntitlements:n,handleFetchedEntitlements:s,loadEntitlements:async t=>{const a=null==t?void 0:t.callback;try{const t=await e.entitlements.loadEntitlementsV2();s(t),null==a||a(!0)}catch(t){null==a||a(!1)}}}},zl=["routes"],Kl=["requestName"],ql=t=>{const e=null!=t?t:{},{routes:a}=e,n=f(e,zl);return en(v({routes:v({},bn,a),onRedirectTo:()=>{},isAuthenticated:!1,isLoading:!0,isSSOAuth:!1,user:null,error:void 0,errorByRequest:{},userIp:void 0,userIpData:{loading:!1}},n,{acceptInvitationState:sn(null==n?void 0:n.acceptInvitationState),accountSettingsState:xn(null==n?void 0:n.accountSettingsState),activateAccountState:Vn(null==n?void 0:n.activateAccountState),unlockAccountState:Cs(null==n?void 0:n.unlockAccountState),apiTokensState:Ns(null==n?void 0:n.apiTokensState),applicationsState:$s(null==n?void 0:n.applicationsState),customLoginState:Vs(null==n?void 0:n.customLoginState),forgotPasswordState:qs(null==n?void 0:n.forgotPasswordState),passwordRotationState:Zs(null==n?void 0:n.passwordRotationState),groupsState:ai(null==n?void 0:n.groupsState),groupsDialogsState:li(null==n?void 0:n.groupsDialogsState),impersonateState:gi(null==n?void 0:n.impersonateState),loginState:Si(null==n?void 0:n.loginState),mfaState:Eo(null==n?void 0:n.mfaState),allAccountsState:No(null==n?void 0:n.allAccountsState),allAccountsDialogsState:Fo(null==n?void 0:n.allAccountsDialogsState),passkeysState:qo(null==n?void 0:n.passkeysState),profileState:Xo(null==n?void 0:n.profileState),provisioningState:er(null==n?void 0:n.provisioningState),resetPhoneNumberState:rr(null==n?void 0:n.resetPhoneNumberState),rolesState:pr(null==n?void 0:n.rolesState),restrictionsState:Tr(null==n?void 0:n.restrictionsState),securityCenterState:Rr(null==n?void 0:n.securityCenterState),securityPolicyState:Nr(null==n?void 0:n.securityPolicyState),sessionsPolicyState:Vr(null==n?void 0:n.sessionsPolicyState),sessionsState:Kr(null==n?void 0:n.sessionsState),signUpState:Xr(null==n?void 0:n.signUpState),smsState:al(null==n?void 0:n.smsState),socialLoginState:dl(null==n?void 0:n.socialLoginState),ssoState:Sl(null==n?void 0:n.ssoState),stepUpState:El(null==n?void 0:n.stepUpState),teamState:Pl(null==n?void 0:n.teamState),tenantsState:Vl(null==n?void 0:n.tenantsState)}))},Jl=(t,e,a,n)=>{const s=e=>{Object.keys(e).forEach((a=>{const n=a;Rn(t.auth[n])?Object.assign(t.auth[n],e[n]):t.auth[n]=e[n]}))},i={acceptInvitationActions:Mn(t,e),accountSettingsActions:Gn(t,e,a),activateAccountActions:Rs(t,e,a),unlockAccountActions:Ls(t,e),apiTokensActions:Fs(t,e),applicationsActions:js(t,e,a),customLoginActions:Hs(t,e,a),entitlementsActions:Hl(t,e),forgotPasswordActions:Ys(t,e),passwordRotationActions:ti(t),groupsActions:oi(t,e),groupsDialogsActions:ci(t),impersonateActions:hi(t,e,a),loginActions:wo(t,e,a),mfaActions:Lo(t,e,a),allAccountsActions:Ho(t,e,a),allAccountsDialogActions:zo(t),passkeysActions:Jo(t,e,a),profileActions:Zo(t,e,a),provisioningActions:sr(t,e),resetPhoneNumberActions:dr(t,e,a),rolesActions:Ar(t,e),restrictionsActions:kr(t,e,a),securityCenterActions:Lr(t,e,a),securityPolicyActions:jr(t,e,a),sessionsPolicyActions:Hr(t,e,a),sessionsActions:qr(t,e),signUpActions:tl(t,e,a),smsActions:cl(t,e),socialLoginActions:hl(t,e,a),ssoActions:wl(t,e,a),stepUpActions:Il(t,e,a),teamActions:jl(t,e,a),tenantsActions:Wl(t,e,a)};return[v({setAuthState:s,setErrorByRequestName:e=>{let{requestName:a}=e,n=f(e,Kl);t.auth.errorByRequest=v({},t.auth.errorByRequest,{[a]:v({},n,{isError:!0})})},setState:s,resetAuthState:(e={})=>{Cn(t,["auth"],v({},n,e))},setUser:t=>{s({user:t})}},Object.values(i).reduce(((t,e)=>v({},t,e)),{})),i]},Yl={isLoading:!1,isSaving:!1,list:[],processIds:[],slackChannels:{isLoading:!1}},Xl=t=>en(Yl,t),Ql=["email","slack","sms","webhook"],Zl={sms:{title:"connectivity.sms",events:t=>(null==t?void 0:t.length)||0,isActive:t=>{var e;return null!=(e=null==t?void 0:t.some((({enabled:t})=>t)))&&e},image:"sms"},email:{title:"common.email",events:t=>(null==t?void 0:t.length)||0,isActive:t=>{var e;return null!=(e=null==t?void 0:t.some((({enabled:t})=>t)))&&e},image:"email"},slack:{title:"connectivity.slack",events:t=>{var e;return(null==t||null==(e=t.slackSubscriptions)?void 0:e.length)||0},isActive:t=>!(null==t||!t.slackSubscriptions.some((({isActive:t})=>t))),image:"slack"},webhook:{title:"connectivity.webhook",events:t=>(null==t?void 0:t.length)||0,isActive:t=>{var e;return null!=(e=null==t?void 0:t.some((({isActive:t})=>t)))&&e},image:"webhook"}},tc=["id"],ec=["id","enabled"],ac=(t,e,a)=>{const n={slack:e.connectivity.getSlackConfiguration,email:e.connectivity.getEmailConfiguration,sms:e.connectivity.getSMSConfiguration,webhook:e.connectivity.getWebhooksConfigurations,categories:e.connectivity.getCategories,channelMap:e.connectivity.getChannelMaps},s=["categories","channelMap"],i={slack:e.connectivity.postSlackConfiguration,email:e.connectivity.postEmailConfiguration,sms:e.connectivity.postSMSConfiguration,webhook:e.connectivity.postWebhooksConfiguration},o=e=>{Object.assign(t.connectivity,e)},r=e=>{var a;const n=null!=(a=t.connectivity.retryResult)?a:{};t.connectivity.retryResult=v({},n,e)},l=()=>{Cn(t,["connectivity"],Yl)},c=async(t,e,a)=>{try{return await On((()=>n[t](e)),a)}catch(t){return}},u=async()=>{try{o({slackChannels:{isLoading:!0}});const t=await e.connectivity.getSlackChannels();o({error:void 0,slackChannels:{isLoading:!1,data:t}})}catch(t){o({error:void 0,slackChannels:{isLoading:!1}})}},d=async t=>{const e=null!=t?t:Ql;o({isLoading:!0});try{const t=await Promise.all([...e.map((t=>c(t,void 0,Tn))),c("categories",void 0,Tn),(async()=>(await Promise.all(e.map((t=>c("channelMap",t,Tn))))).reduce(((t,a,n)=>v({},t,{[`${e[n]}`]:a})),{}))()]),a=await c("webhook",void 0,Tn),n=t.reduce(((a,n,i)=>e[i]?t[t.length-1][e[i]].length?v({},a,{[`${e[i]}`]:n,list:[...a.list,{id:i,key:e[i],events:Zl[e[i]].events(n),active:Zl[e[i]].isActive(n),platform:Zl[e[i]].title,image:Zl[e[i]].image}]}):a:v({},a,{[`${s[i-e.length]}`]:n})),{list:[],webhook:a});o(v({},n,{error:void 0,isSaving:!1,isLoading:!1}))}catch(t){o({isLoading:!1,error:Nn(t)})}},g=async(e,a)=>{const{list:n}=t.connectivity,s=n.find((({key:t})=>t===e));if(!s)return;const i=Zl[e].isActive(a);i!==s.active&&o({list:n.map((t=>t.key===e?v({},t,{active:i}):t))})},p=async a=>{const{platform:n,data:s,callback:r}=a,l=t.connectivity.processIds;try{if(o({isSaving:!0,processIds:"webhook"===n?[s._id,...l]:l}),"slack"===n?await(async a=>{var n;const s=null==(n=t.connectivity.slack)?void 0:n.slackSubscriptions;if(!s)return;const{slackSubscriptions:o}=a;await Promise.all([...o.reduce(((t,e)=>{var a,n;return!e.id&&e.slackEvents&&null!=(a=e.slackEvents[0].channelIds)&&a.length||(null==s?void 0:s.find((t=>{let{id:a}=t,n=f(t,tc);return a===e.id&&JSON.stringify(v({id:a},n))!==JSON.stringify(e)})))&&e.slackEvents&&null!=(n=e.slackEvents[0].channelIds)&&n.length?[...t,e]:t}),[]).map((t=>i.slack(t))),...o.reduce(((t,e)=>e.id&&!e.slackEvents[0].channelIds.length?[...t,e]:t),[]).map((t=>e.connectivity.deleteSlackConfiguration(t)))])})(s):["sms","email"].includes(n)?await(async(a,n)=>{const s=t.connectivity.processIds,i=t.connectivity[n];if(!i)return;let r=[];try{r=await Promise.all([...a.reduce(((t,e)=>!i.find((({eventKey:t})=>t===e.eventKey))&&e.subscriptions[0].recipients.filter((t=>t)).length?[...t,e]:t),[]).map((t=>"email"===n?e.connectivity.postEmailConfiguration(t):e.connectivity.postSMSConfiguration(t))),...a.reduce(((t,e)=>{const a=i.find((({eventKey:t})=>t===e.eventKey));return a&&JSON.stringify(a)!==JSON.stringify(e)?[...t,e]:t}),[]).map((t=>{const{subscriptions:a,eventKey:s}=t,i=a[0],{id:o="",enabled:r}=i,l=f(i,ec);return Promise.all(["email"===n?e.connectivity.patchEmailConfiguration({eventKey:s,enabled:r}):e.connectivity.patchSMSConfiguration({eventKey:s,enabled:r}),"email"===n?e.connectivity.putEmailSubscriptions(o,s,v({},l,{enabled:r})):e.connectivity.putSMSSubscriptions(o,s,v({},l,{enabled:r}))])})),...a.reduce(((t,e)=>{const a=i.find((({eventKey:t})=>t===e.eventKey));return a&&a.subscriptions[0].recipients.length&&!e.subscriptions[0].recipients.filter((t=>!!t)).length?[...t,e]:t}),[]).map((({eventKey:t,subscriptions:a})=>"email"===n?e.connectivity.deleteEmailSubscriptions(t,a[0].id||""):e.connectivity.deleteSMSSubscriptions(t,a[0].id||"")))])}catch{}if(r.length){const t=await c(n);o({error:void 0,isSaving:!1,[`${n}`]:t,processIds:t.id?s.filter((e=>e!==t.id)):s}),await g(n,t)}else o({error:void 0,isSaving:!1,[`${n}`]:i,processIds:s})})(s,n):await i[n](s),!["sms","email"].includes(n)){const t=await c(n);"webhook"===n&&(t.id=s._id),o({error:void 0,isSaving:!1,[`${n}`]:t,processIds:t.id?l.filter((e=>e!==t.id)):l}),await g(n,t),null==r||r(!0)}}catch(t){o({error:Nn(t),isSaving:!1,isLoading:!1})}},h=async t=>{try{await e.connectivity.postSlackCode(t)}catch{}o({error:void 0,isSaving:!1})},y=async()=>{const a=t.connectivity.slackChannels;try{o({slackChannels:v({},a,{isLoadingScope:!0})});const{clientId:t}=await e.connectivity.getSlackScope();o({slackChannels:{error:void 0,clientId:t,isLoadingScope:!1,isLoading:!1}})}catch{o({slackChannels:{error:void 0,isLoadingScope:!1,isLoading:!1}})}},S=async a=>{const{callback:n,webhookId:s}=a,i=t.connectivity.processIds;try{o({isSaving:!0}),await e.connectivity.deleteWebhooksConfiguration(s)}catch(t){null==n||n(null,Nn(t))}const r=await c("webhook");r&&o({error:void 0,isSaving:!1,webhook:r,processIds:r.id?i.filter((t=>t!==r.id)):i}),null==n||n(!0)},m=async t=>{try{o({isTesting:!0});const{statusCode:a,body:n}=await e.connectivity.postWebhookTest(t);if([201,200].includes(a)){const t=JSON.stringify(n,null,2);o({isTesting:!1,testResult:{status:"success",message:t}})}else o({isTesting:!1,testResult:{status:"failed"}})}catch(t){o({isTesting:!1,testResult:{status:"failed",message:Nn(t)}})}},b=async t=>{try{const{statusCode:a}=await e.connectivity.postWebhookRetry(t);r({[t]:{isProcess:!1,success:202===a}})}catch(e){r({[t]:{isProcess:!1,success:!1}})}},A=async a=>{const{id:n,limit:s,offset:i}=a,r=t.connectivity.webhookLogs;try{o({webhookLogs:v({},r,{isLoading:!0})});const t=await e.connectivity.getWebhookLog(n,i,s);o({error:void 0,webhookLogs:v({isLoading:!1},t)})}catch(t){o({error:void 0,webhookLogs:{isLoading:!1}})}};return{setConnectivityState:o,initData:l,resetConnectivityState:l,loadSlackActions:u,loadSlackChannels:u,loadDataAction:d,loadConnectivityChannels:d,postDataAction:p,postChannelData:p,postCodeAction:h,postSlackCode:h,loadScope:y,loadSlackPermissions:y,deleteWebhookConfigAction:S,deleteWebhookConfig:S,postWebhookTestAction:m,postWebhookTest:m,postWebhookRetryAction:b,postWebhookRetry:b,loadWebhookLogsAction:A,loadWebhookLogs:A,cleanWebhookTestData:()=>{o({testResult:void 0})},cleanWebhookLogsData:async()=>{o({webhookLogs:void 0})},cleanWebhookTestMessage:async t=>{var e;o({testResult:{status:null==(e=t.testResult)?void 0:e.status,message:void 0}})},cleanError:async()=>{o({error:void 0})},cleanSlackData:async()=>{o({slackChannels:{isLoading:!1}})}}};let nc;!function(t){t.UNKNWON="unknown",t.CARD="card"}(nc||(nc={}));const sc={loading:!1,error:null,fetching:!0,config:null},ic=t=>en(sc,t);let oc,rc,lc;!function(t){t.STRIPE="Stripe"}(oc||(oc={})),function(t){t.ACTIVE="ACTIVE",t.CANCELED="CANCELED",t.INCOMPLETE="INCOMPLETE",t.EXPIRED="EXPIRED",t.TRIALING="TRIALING"}(rc||(rc={})),function(t){t.AT_PERIOD_END="atPeriodEnd"}(lc||(lc={}));const cc=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.config,e)},s=e=>{Object.assign(t.subscriptions.config,{error:e,loading:!1,fetching:!1})};return{setPaymentConfigState:n,resetPaymentConfigState:()=>{Cn(t,["subscriptions","config"],sc)},loadPaymentConfiguration:async()=>{n({loading:!0});try{var t;(null!=(t=await e.subscriptions.getPaymentProviders())?t:[]).find((t=>"1"===t.status&&t.providerType===j.Stripe))?await(async()=>{n({loading:!0});try{const t=await e.subscriptions.getStripePaymentProviderConfiguration(),a={paymentProvider:oc.STRIPE,apiKey:t.publishableKey};n({config:a}),n({loading:!1,fetching:!1})}catch(t){s(Nn(t))}})():s(Nn("Payment provider not configured"))}catch(t){s(Nn(t))}}}},uc={loading:!1,error:null,fetching:!0},dc=t=>en(uc,t);function gc({policy:t}){return{policy:lc.AT_PERIOD_END}}function pc(t){switch(t){case x.ACTIVE:return rc.ACTIVE;case x.INCOMPLETE:return rc.INCOMPLETE;case x.CANCELED:return rc.CANCELED;case x.EXPIRED:return rc.EXPIRED;case x.TRIALING:return rc.TRIALING;default:return rc.EXPIRED}}const hc=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.subscriptions.billing.information,e)},i=t=>{s({error:t,loading:!1,fetching:!1})},o=async(a,o)=>{s({loading:!0});try{var r,l;const i=await e.subscriptions.getSubscriptionSummaries(a),{currentPlanId:c,externallyManaged:u}=i;let d,g=null;u?d=await e.subscriptions.getSubscriptionPlan(c):([,d]=await Promise.all([n.loadSubscription(),e.subscriptions.getSubscriptionPlan(c)]),g=t.subscriptions.billing.subscription.subscription||null),s(v({loading:!1,fetching:!1,summary:i},g?{subscription:{id:g.id,externalId:g.externalId,startDate:g.startDate,currentPeriodStart:g.currentPeriodStart,currentPeriodEnd:g.currentPeriodEnd,status:o?rc.ACTIVE:pc(g.status),cancellation:g.cancellation&&gc(g.cancellation),trialEnd:g.trialEnd?g.trialEnd:null}}:{},d?{plan:{id:d.id,name:d.name,description:d.description,price:(null==(r=d.price)?void 0:r.amount)||0,currency:(null==(l=d.price)?void 0:l.currency)||"usd",recurringInterval:"month",slug:d.slug}}:{}))}catch(t){i(Nn(t))}};return{setBillingInformationState:s,resetBillingInformationState:()=>{Cn(t,["subscriptions","billing","information"],uc)},loadSummaries:o,loadBillingInformation:async e=>{var a,n;const s=null==(a=t.subscriptions.config.config)?void 0:a.paymentProvider,r=null==(n=t.auth.user)?void 0:n.tenantId;s&&r?await o(r,e):i(new W(s?"Not authorized":"Internal feature failure",500,null))}}},yc={loading:!1,error:null,fetching:!0,invoices:[],invoiceDownload:{loading:!1,error:null}},Sc=t=>en(yc,t),vc=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.billing.invoices,e)},s=e=>{Object.assign(t.subscriptions.billing.invoices.invoiceDownload,e)},i=async()=>{n({loading:!0});try{const t=(await e.subscriptions.getSubscriptionInvoices()).map((t=>({id:t.id,externalId:t.externalId,subscriptionId:t.subscriptionId,paymentDate:new Date(Date.parse(t.paymentDate)),totalAmount:+((t.totalAmount||0)/100).toFixed(2),currency:t.currency||"usd",paid:t.paid||!1,receiptNumber:t.receiptNumber})));n({loading:!1,fetching:!1,invoices:t})}catch(e){t=Nn(e),n({error:t,loading:!1,fetching:!1})}var t},o=async t=>{s({loading:!0,error:null});try{await e.subscriptions.getSubscriptionInvoicePdf(t.invoiceId,t.filename),s({loading:!1,error:null})}catch(t){s({loading:!1,error:Nn(t,null)})}};return{setBillingInvoiceState:n,resetBillingInvoiceState:()=>{Cn(t,["subscriptions","billing","invoices"],yc)},loadInvoices:i,loadBillingInvoices:i,downloadInvoice:o,downloadBillingInvoice:o}},fc={loading:!1,error:null,fetching:!0},mc=t=>en(fc,t),bc=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.billing.paymentMethod,e)},s=t=>{n({loading:t})},i=t=>{n({error:t,loading:!1,fetching:!1})},o=async()=>{s(!0);try{const t=(await e.subscriptions.getPaymentMethods())[0];n({paymentMethod:t,loading:!1,fetching:!1})}catch(t){i(Nn(t))}};return{setBillingPaymentMethodState:n,resetBillingPaymentMethodState:()=>{Cn(t,["subscriptions","billing","paymentMethod"],fc)},loadPaymentMethod:o,submitPaymentMethod:async()=>{s(!0)},submitPaymentMethodError:async t=>{i(t)},submitPaymentMethodSuccess:async()=>await o(),updatePaymentMethodBillingDetails:async t=>{s(!0);const{id:a,email:n,address:r,callback:l}=t;try{await e.subscriptions.updatePaymentMethodBillingDetails(a,v({email:n},r)),await o(),null==l||l(!0)}catch(t){i(Nn(t)),null==l||l(!1,t)}finally{s(!1)}}}},Ac={loading:!1,error:null,fetching:!0,cancellation:{loading:!1,error:null},renewal:{loading:!1,error:null}},wc=t=>en(Ac,t),Tc=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.subscriptions.billing.subscription,e)},i=t=>{s({error:t,loading:!1,fetching:!1})},o=e=>{Object.assign(t.subscriptions.billing.subscription.cancellation,{loading:e})},r=e=>{Object.assign(t.subscriptions.billing.subscription.cancellation,{error:e})},l=e=>{Object.assign(t.subscriptions.billing.subscription.renewal,{loading:e})},c=e=>{Object.assign(t.subscriptions.billing.subscription.renewal,{error:e})},u=async()=>{s({loading:!0});try{const[t]=await e.subscriptions.getManagedSubscriptions();s({subscription:t,fetching:!1,loading:!1,error:null})}catch(t){i(Nn(t))}};return{setBillingSubscriptionState:s,resetBillingSubscriptionState:()=>{Cn(t,["subscriptions","billing","subscription"],Ac)},setCancellationLoading:o,setCancellationError:r,setRenewalLoading:l,setRenewalError:c,loadSubscription:u,loadSubscriptionTenant:async()=>{var e;const a=null==(e=t.auth.user)?void 0:e.tenantId;a?await n.loadSummaries(a):i(new W("TenantId is not defined",500,null))},cancelSubscription:async()=>{const{subscription:a}=t.subscriptions.billing.subscription;if(!a)return void r(new W("Subscription not found",500,null));if(null!=a&&a.externallyManaged)return void r(new W("Billing is externally managed",500,null));const{id:n,cancellation:s,status:i}=a||{};if(!s&&i===x.ACTIVE)try{o(!0),await e.subscriptions.cancelManagedSubscription(n),await u(),o(!1)}catch(t){r(Nn(t))}},renewSubscription:async()=>{const{subscription:a}=t.subscriptions.billing.subscription;if(!a)return void c(new W("Subscription not found",500,null));if(null!=a&&a.externallyManaged)return void c(new W("Billing is externally managed",500,null));const{id:n,cancellation:s}=a||{};if((null==s?void 0:s.policy)===G.AT_PERIOD_END)try{l(!0),await e.subscriptions.renewManagedSubscription(n),await u(),l(!1)}catch(t){c(Nn(t))}}}},Ec=t=>en({information:dc(null==t?void 0:t.information),invoices:Sc(null==t?void 0:t.invoices),paymentMethod:mc(null==t?void 0:t.paymentMethod),subscription:wc(null==t?void 0:t.subscription)}),Ic={loading:!1,error:null,fetching:!0,plans:[]},Oc=t=>en(Ic,t),Pc=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.plans,e)};return{setPlansState:n,resetPlansState:()=>{Cn(t,["subscriptions","plans"],Ic)},loadPlans:async()=>{n({loading:!0});try{const t=(await e.subscriptions.getSubscriptionPlans()).map((t=>{var e,a;return{id:t.id,name:t.name,description:t.description,price:(null==(e=t.price)?void 0:e.amount)||0,currency:(null==(a=t.price)?void 0:a.currency)||"usd",recurringInterval:"month",slug:t.slug}}));n({fetching:!1,loading:!1,plans:t})}catch(e){t=Nn(e),n({loading:!1,fetching:!1,error:t})}var t}}},kc={fetching:!0,loading:!1,error:null,confirmed:!1},_c=t=>en(kc,t),Rc=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.subscriptions.checkout,e)};return{setCheckoutState:s,resetCheckoutState:()=>{Cn(t,["subscriptions","checkout"],kc)},loadCheckout:()=>{s({fetching:!1,loading:!1,error:null,confirmed:!1})},resetCheckout:()=>{s({loading:!1,error:null,confirmed:!1})},submitCheckout:()=>{s({loading:!0,error:null})},confirmCheckout:async a=>{const{paymentMethodId:i,planId:o}=a,r=t.subscriptions.billing.subscription.subscription,l=t.subscriptions.billing.information.summary,c=(null==r?void 0:r.status)===x.TRIALING,u=!(null==l||!l.paymentMethodId);if(r){if(s({loading:!0,error:null}),c&&u)return s({loading:!1,error:null,confirmed:!0}),void n.setBillingSubscriptionState({subscription:v({},r,{status:x.ACTIVE})});try{await e.subscriptions.updateManagedSubscription(r.id,{paymentMethodId:i,planId:o}),await Promise.all([n.loadBillingInformation(),n.loadPaymentMethod(),n.loadInvoices()]),s({loading:!1,error:null,confirmed:!0})}catch(t){s({loading:!1,error:Nn(t)})}}else s({loading:!1,error:new W("Subscription not found",500,null)})},errorCheckout:t=>{s({loading:!1,error:t})}}},Uc={loading:!1,error:null,cardSetupIntentSecret:null},Cc=t=>en(Uc,t),Lc=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.stripe,e)};return{createCardSetupIntentSecret:async a=>{n({loading:!0,error:null,cardSetupIntentSecret:null});try{const t={};a&&(t.paymentMethodId=a);const{setupIntentSecret:s}=await e.subscriptions.createStripePaymentMethodSetupIntentSecret(t);n({cardSetupIntentSecret:s,loading:!1})}catch(e){s=Nn(e),Object.assign(t.subscriptions.stripe,{error:s,loading:!1,fetching:!1})}var s},setStripeState:n,resetStripeState:()=>{Cn(t,["subscriptions","stripe"],Uc)}}},Dc={loading:!1,fetching:!0,vendorPublicConfig:null},Nc=t=>en(Dc,t),Mc=(t,e,a)=>{const n=e=>{Object.assign(t.subscriptions.vendorPublicConfig,e)},s=e=>{Object.assign(t.subscriptions.vendorPublicConfig,{error:e,loading:!1,fetching:!1})},i=e=>{Object.assign(t.subscriptions.vendorPublicConfig,{error:null,loading:e})};return{setVendorPublicConfigState:n,resetVendorPublicConfigState:()=>{Cn(t,["subscriptions","vendorPublicConfig"],Dc)},setVendorPublicConfigError:s,setVendorPublicConfigLoading:i,loadVendorPublicConfiguration:async()=>{i(!0);try{const t=await e.subscriptions.getVendorPublicConfigurations();n({fetching:!1,loading:!1,vendorPublicConfig:t})}catch(t){s(Nn(t))}}}},Fc=t=>en({config:ic(null==t?void 0:t.config),billing:Ec(null==t?void 0:t.billing),plans:Oc(null==t?void 0:t.plans),checkout:_c(null==t?void 0:t.checkout),stripe:Cc(null==t?void 0:t.stripe),vendorPublicConfig:Nc(null==t?void 0:t.vendorPublicConfig)}),xc=(t,e,a)=>{const n=cc(t,e),[s,i]=((t,e,a)=>{const n=hc(t,e,a),s=bc(t,e),i=vc(t,e),o=Tc(t,e,a);return[v({},n,s,i,o),{information:n,invoices:i,paymentMethod:s,subscription:o}]})(t,e,a),o=Pc(t,e),r=Rc(t,e,a),l=Lc(t,e),c=Mc(t,e);return[v({},n,s,o,r,l,c),{config:n,billing:i,plans:o,checkout:r,stripe:l,vendorPublicConfig:c}]},$c={loading:!1},Gc=t=>en($c,t),jc=(t,e,a)=>{const n=e=>{Object.assign(t.vendor,e)},s=async t=>{n({loading:!0});try{var a;const s=await On((()=>e.vendor.getVendorPublicInfo()),null==t?void 0:t.retryConfig);s.whiteLabelMode=null!=(a=s.whiteLabelMode)&&a,n(v({},s,{loading:!1}))}catch(t){n({loading:!1}),console.error("failed to getVendorPublicInfo - ",t)}};return{setVendorState:n,resetVendorState:()=>{Cn(t,["vendor"],$c)},loadVendorPublicInfo:s,loadVendorPublicConfiguration:s}},Bc={loading:!0,pageOffset:0,pageSize:20,logs:[],sort:[],filter:[],totalPages:0,isDownloadingCsv:!1},Vc=t=>en(Bc,t),Wc=(t,e,a)=>{const n=a,s=e=>{Object.assign(t.auditLogs.auditLogsState,e)};return{setAuditLogsState:s,resetAuditLogsState:()=>{Cn(t,["auditLogs","auditLogsState"],Bc)},exportAuditsCsv:async()=>{const a=t.auditLogs.auditLogsState,{columns:n}=t.auditLogs.auditsMetadataState;try{const t=a.filter,i=a.sort.reduce(((t,e)=>v({},t,{sortBy:e.id,sortDirection:e.desc?"desc":"asc"})),{}),o=t.reduce(((t,e)=>v({},t,{[e.id]:e.value})),{});s({isDownloadingCsv:!0});const r="audits.csv";await e.audits.exportAudits(v({endpoint:"csv/v2",headerProps:n,offset:0,outputFileName:r},i,o))}catch(t){console.error("failed to export audits - ",t)}s({isDownloadingCsv:!1})},loadAuditLogs:async a=>{s({loading:!(null!=a&&a.silentLoading),error:null});const i=t.auditLogs.auditLogsState,o=null==a?void 0:a.retryConfig,{columns:r}=t.auditLogs.auditsMetadataState;try{var l,c,u,d,g;const t=null!=(l=a.pageSize)?l:i.pageSize,p=null!=(c=a.pageOffset)?c:i.pageOffset,h=null!=(u=a.filter)?u:i.filter,y=null!=(d=a.sort)?d:i.sort;s({pageSize:t,pageOffset:p,filter:h,sort:y});const S=y.reduce(((t,e)=>v({},t,{sortBy:e.id,sortDirection:e.desc?"desc":"asc"})),{}),f=h.reduce(((t,e)=>v({},t,{[e.id]:e.value})),{});r||await n.loadAuditsMetadata({retryConfig:o});const{data:m,total:b}=await On((()=>e.audits.getAudits(v({offset:p,count:t},S,f))),o);s({loading:!1,logs:null!=m?m:[],totalPages:+Math.ceil(b/t)}),null==a||null==(g=a.callback)||g.call(a,!0)}catch(t){var p;s({loading:!1,error:Nn(t)}),null==a||null==(p=a.callback)||p.call(a,null,t)}}}},Hc={loading:!0},zc=t=>en(Hc,t),Kc=(t,e,a)=>{const n=e=>{Object.assign(t.auditLogs.auditsMetadataState,e)};return{setAuditsMetadataState:n,resetAuditsMetadataState:()=>{Cn(t,["auditLogs","auditsMetadataState"],Hc)},loadAuditsMetadata:async t=>{n({loading:!0,error:null});try{const{properties:a}=await On((()=>e.metadata.getAuditsMetadata()),null==t?void 0:t.retryConfig);n({columns:a,loading:!1})}catch(t){n({error:t,loading:!1})}}}},qc=t=>({auditLogsState:Vc(null==t?void 0:t.auditLogsState),auditsMetadataState:zc(null==t?void 0:t.auditsMetadataState)}),Jc=(t,e,a)=>v({},Wc(t,e,a),Kc(t,e)),Yc={total:0,offset:0,filter:"",sortBy:"createdAt",context:null,filters:[],rowsData:[],lastUpdated:new Date,isLoading:!0,isFetchMore:!1,totalToday:0,currentPage:0,headerProps:[],sortDirection:"desc",severeThisWeek:0,predefinedFilters:[],isDownloadingCsv:!1,virtualScroll:!1},Xc=(t,e)=>Object.keys(t).reduce(((a,n)=>{const s=n;return e.includes(n)?v({},a,{[n]:t[s]}):v({},a,{[n]:()=>{console.debug(`Action ${String(n)} was called`)}})}),{}),Qc={clientId:"CLIENT_ID_16806d3d-8fc3-4450-be97-abdaf66b723e",secret:"SECRET_16806d3d-8fc3-4450-be97-abdaf66b723e",createdAt:"createdAt",description:"Demo API Token (preview only)"},Zc=v({},Qc,{roleIds:[],tenantId:"my-tenant-id",createdByUserId:"createdByUserId"}),tu=[{id:"a040dcf6-b907-4e83-9970-6bd23c88fd40",key:"ReadOnly",name:"Read Only",description:null,isDefault:!1,createdAt:new Date,updatedAt:new Date,permissions:["8d71b676-754c-4600-afe7-ca5add1e6809","04dbcc11-61db-40a9-9577-9b73e50d1d03"],vendorId:"vendorId"},{id:"b43b2c4b-e056-4eec-8c55-d200a475bbc0",key:"Admin",name:"Admin",description:null,isDefault:!0,createdAt:new Date,updatedAt:new Date,permissions:["8d71b676-754c-4600-afe7-ca5add1e6809","04dbcc11-61db-40a9-9577-9b73e50d1d03","16647407-ed6f-4ca6-83a0-86225d921959","f403c6b9-1abe-4ec7-9971-aa032255fc25","a43e059d-d731-44b1-94bb-fb6b16c62210"],vendorId:"vendorId"},{id:"1234",key:"Support",name:"Support",description:null,isDefault:!0,createdAt:new Date,updatedAt:new Date,permissions:["8d71b676-754c-4600-afe7-ca5add1e6809","04dbcc11-61db-40a9-9577-9b73e50d1d03","f26b00f8-ffe0-4739-b15c-7db15c27ea26","a9c803b0-ebfa-49b9-9607-f0d3a390ee61"],tenantId:"tenantId",vendorId:"vendorId"}],eu={sub:"",tenants:[],id:"testId",name:"Demo User Name",email:"demo-user@frontegg.com",mfaEnrolled:!0,profilePictureUrl:"https://www.gravatar.com/avatar/42b2ad2bad6fc9b9db5086dfcf8072ac?d=https://ui-avatars.com/api/fe/128/random?t=1617261890875?t=1617261917434",roles:[{id:"roleId",key:"admin",isDefault:!1,name:"Admin",description:null,permissions:["8d71b676-754c-4600-afe7-ca5add1e6809","04dbcc11-61db-40a9-9577-9b73e50d1d03"],tenantId:"tenantId",vendorId:"vendorId",createdAt:new Date,updatedAt:new Date}],permissions:[{id:"8d71b676-754c-4600-afe7-ca5add1e6809",key:"fe.*",name:"General Admin",description:"description",categoryId:"category",fePermission:!0,createdAt:new Date,updatedAt:new Date,roleIds:[]}],tenantId:"my-tenant-id",tenantIds:["my-tenant-id"],activatedForTenant:!0,metadata:JSON.stringify({phoneNumber:"+972-54123456",jobTitle:"Developer",address:{city:"Tel Aviv",country:"Israel"}}),verified:!1},au=v({},eu,{accessToken:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1MTY5YmY0Zi02YmI5LTQ5NGMtOGNkZS05MDc4NDQ0NWY4MDciLCJuYW1lIjoiRHVtbXkgVXNlciIsImVtYWlsIjoiZHVtbXlAZnJvbnRlZ2cuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsIm1ldGFkYXRhIjp7fSwicm9sZXMiOlsiYWRtaW4iXSwicGVybWlzc2lvbnMiOlsiZmUuKiJdLCJ0ZW5hbnRJZCI6Im15LXRlbmFudC1pZCIsInRlbmFudElkcyI6WyJteS10ZW5hbnQtaWQiXSwicHJvZmlsZVBpY3R1cmVVcmwiOiJodHRwczovL3d3dy5ncmF2YXRhci5jb20vYXZhdGFyLzQyYjJhZDJiYWQ2ZmM5YjlkYjUwODZkZmNmODA3MmFjP2Q9aHR0cHM6Ly91aS1hdmF0YXJzLmNvbS9hcGkvZmUvMTI4L3JhbmRvbT90PTE2MTcyNjE4OTA4NzU_dD0xNjE3MjYxOTE3NDM0IiwidHlwZSI6InVzZXJUb2tlbiIsImlhdCI6MTYxNzkwNjMyNCwiZXhwIjoxNjE3OTkyNzI0LCJpc3MiOiJmcm9udGVnZyJ9.paaXLkpWEWbQmUtoK2P8IwXCxK4WJp7XhXonvzF8g1I",expiresIn:86400,mfaRequired:!1,refreshToken:"refresh-token-dummy-de39dc9c-9d22-4852-b7f5-c3c0aa613b58",type:"userToken",iat:1617906324,exp:1617992724,iss:"frontegg",email_verified:!0}),nu={loading:!1,error:void 0,saving:!0,profile:eu},su={id:"id",enforceMFAType:"DontForce",createdAt:new Date,updatedAt:new Date,allowOverrideEnforcePasswordHistory:!0,allowOverridePasswordComplexity:!1,allowOverridePasswordExpiration:!1,allowSignups:!0,apiTokensEnabled:!0,cookieSameSite:"cookieSameSite",defaultRefreshTokenExpiration:0,defaultTokenExpiration:1,publicKey:"publicKey"},iu={allowSignups:!0,allowNotVerifiedUsersLogin:!1,apiTokensEnabled:!0,forcePermissions:!1,authStrategy:N.EmailAndPassword,machineToMachineAuthStrategy:M.ClientCredentials},ou={id:"id",enforceMFAType:"DontForce",createdAt:new Date,updatedAt:new Date},ru={id:"id",enabled:!0,maxAttempts:1,createdAt:new Date,updatedAt:new Date},lu={id:"id",enabled:!0,historySize:1,createdAt:new Date,updatedAt:new Date},cu={enabled:!0,domain:"domain",validated:!0,generatedVerification:"generatedVerification",ssoEndpoint:"ssoEndpoint",publicCertificate:"publicCertificate",signRequest:!0,createdAt:new Date,updatedAt:new Date,acsUrl:void 0,spEntityId:void 0,oidcClientId:void 0,oidcSecret:void 0,type:void 0},uu={id:"id",createdAt:"createdAt",updatedAt:"updatedAt",properties:[],vendorId:"vendorId",entityName:"saml",isActive:!0,configuration:{acsUrl:"acsUrl",spEntityId:"spEntityId"}},du=[{id:"id",description:"description",key:"key",name:"name",permissions:[],permissionLevel:1}],gu={firstLoad:!1,loading:!1,error:void 0,saving:!1,samlConfiguration:cu,roles:du,authorizationRoles:[],errors:{},loaders:{},ssoConfigurations:[]},pu=[{description:"string",fePermission:!0,id:"id",key:"key",name:"name",roleIds:[],createdAt:new Date,updatedAt:new Date,categoryId:"categoryId"}],hu={id:"id2",email:"demo-user2@frontegg.com",name:"Demo User Name2",phone:void 0,profileImage:void 0,profileImageUrl:void 0,tenantId:"tenantId",vendorId:"vendorId",roleIds:[],activatedForTenant:!0,verified:!1,createdAt:(new Date).toISOString(),customData:void 0,lastLogin:void 0,mfaEnabled:void 0,roles:[tu[0]],groups:[{id:"id2",name:"Developers",color:"#03A9F4",roles:[tu[0]],managedBy:$a.FRONTEGG}]},yu={id:hu.id,email:hu.email,name:hu.name,phoneNumber:void 0,profileImage:void 0,tenantId:"tenantId",activatedForTenant:!0,createdAt:new Date(2022,4,1),verified:!0,lastLogin:new Date(2022,5,25),mfaEnrolled:!1,roles:[tu[1]],tenantIds:[],metadata:"",sub:"",tenants:[]},Su={id:"id",email:"demo-user@frontegg.com",name:"Demo User Name",phone:void 0,profileImage:void 0,profileImageUrl:void 0,tenantId:"tenantId",vendorId:"vendorId",roleIds:[],activatedForTenant:!0,createdAt:new Date(2022,4,1).toISOString(),verified:!0,customData:void 0,lastLogin:new Date(2022,5,25).toISOString(),mfaEnabled:void 0,roles:[tu[1]],groups:[{id:"id1",name:"Designers",color:"#E1F5E2",roles:[tu[0]],managedBy:$a.FRONTEGG}]},vu={id:Su.id,email:Su.email,name:Su.name,phoneNumber:void 0,profileImage:void 0,tenantId:"tenantId",activatedForTenant:!0,createdAt:new Date(2022,4,1),verified:!0,lastLogin:new Date(2022,5,25),mfaEnrolled:!1,roles:[tu[1]],tenantIds:[],metadata:"",sub:"",tenants:[]},fu={metadata:"",mfaEnrolled:!1,provider:"",sub:"",tenantIds:[],tenants:[],verified:!1,id:"id",email:"email",name:"name",tenantId:"tenantId",createdAt:new Date},mu=[Su,hu],bu=[vu,yu],Au=[fu],wu=[{id:"my-tenant-id",isReseller:!1,name:"Frontegg demo",deletedAt:null,metadata:void 0,tenantId:"my-tenant-id",vendorId:"vendorId",createdAt:new Date,updatedAt:new Date,address:void 0,timezone:void 0,dateFormat:void 0,timeFormat:void 0,currency:void 0,logo:void 0}],Tu=[{id:"laptop",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Safari/605.1.15",createdAt:new Date,ipAddress:"190.194.88.251",current:!0},{id:"iphone",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_2_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Mobile/15E148 Safari/604.1",createdAt:new Date(Date.now()-1e4),ipAddress:"191.49.203.21"},{id:"tablet",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; SGP771 Build/32.2.A.0.253; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.98 Safari/537.36",createdAt:new Date(Date.now()-3e4),ipAddress:"130.19.196.136"},{id:"anotherlaptop",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Safari/605.1.15",createdAt:new Date(Date.now()-1002232300),ipAddress:"2.228.163.92"}],Eu={isActive:!0,strategy:zt.ALLOW},Iu=[{updatedAt:new Date,createdAt:new Date,id:"1",ip:"255.255.255.255",isActive:!0,strategy:zt.ALLOW,description:"My IP"},{updatedAt:new Date,createdAt:new Date,id:"2",ip:"255.255.255.254",isActive:!0,strategy:zt.ALLOW,description:"IP 2"},{updatedAt:new Date,createdAt:new Date,id:"3",ip:"255.255.255.253",isActive:!0,strategy:zt.BLOCK,description:"IP 3"},{updatedAt:new Date,createdAt:new Date,id:"4",ip:"255.255.255.253",isActive:!0,strategy:zt.BLOCK,description:"IP 4"}],Ou=t=>{const e=[];return Array.from({length:t}).forEach(((t,a)=>{e.push(v({},Su,{name:"Demo User",id:`id${a}`,profilePictureUrl:null,createdAt:new Date}))})),e},Pu=t=>({id:"b43b2c4b-e056-4eec-8c55-d200a475bbc0"+t,key:t,name:t,description:null,isDefault:!0,createdAt:new Date,updatedAt:new Date,permissions:[],tenantId:"tenantId",vendorId:"vendorId"}),ku=[{id:"id1",name:"Designers",color:"#E1F5E2",description:"The whole design team",users:Ou(6),roles:[Pu("Editor")],metadata:'{"lastTermsCheck":"2022-08-16T10:31:11.270Z"}',managedBy:$a.FRONTEGG},{id:"id2",name:"Developers",color:"#03A9F4",description:"All frontend and backend developers",users:Ou(44),roles:[Pu("Editor")],managedBy:$a.FRONTEGG},{id:"id3",name:"Product",color:"#E1583E",description:"PMs and team leads",users:Ou(8),roles:[Pu("Viewer")],managedBy:$a.FRONTEGG},{id:"id4",name:"Management",color:"#9AE0FF",description:"Executives",users:Ou(5),roles:[Pu("Admin")],managedBy:$a.FRONTEGG},{id:"id5",name:"Sales",color:"#ED8E7C",users:Ou(21),description:"BDR, AE, and inside sales",roles:[Pu("Viewer")],managedBy:$a.FRONTEGG},{id:"id6",name:"Support",color:"#A79D7B",users:Ou(23),description:"Dev success and customer success",roles:[Pu("Admin")],managedBy:$a.FRONTEGG},{id:"id7",name:"Marketing",color:"#2CA744",users:Ou(10),description:"The marketing department",roles:[Pu("Viewer")],managedBy:$a.FRONTEGG},{id:"id8",name:"HR",color:"#EAE1C2",users:Ou(4),description:"Human resources",roles:[Pu("Viewer")],managedBy:$a.FRONTEGG},{id:"id9",name:"Finance",color:"#5587C0",users:Ou(3),roles:[Pu("Viewer")],managedBy:$a.FRONTEGG},{id:"id10",name:"Operations",color:"#B1CAE7",users:Ou(8),roles:[Pu("Editor")],managedBy:$a.FRONTEGG},{id:"id11",name:"Legal",color:"#2CA744",users:Ou(4),roles:[Pu("Viewer")],managedBy:$a.FRONTEGG}],_u={scoring:{score:79},recommendations:{items:[{code:Wa.FORCE_MFA,severity:Ka.WARNING,category:qa.MFA},{code:Wa.ENABLE_FORCE_RELOGIN,severity:Ka.WARNING,category:qa.SESSIONS}]}},Ru={insights:{items:[{category:qa.MFA,code:Ha.PARTIALLY_FORCED_MFA,metadata:{totalUsers:2,mfa:{enrolledUsersCount:1}}},{category:qa.SESSIONS,code:Ha.PARTIAL_SESSION_SETTINGS,metadata:{totalUsers:2,sessions:{idleTimeoutRecommendation:1800}}},{category:qa.PASSWORD,code:Ha.IMPROVE_PASSWORD_HISTORY_POLICY,metadata:{password:{userLockoutRecommendation:5,historyRecommendations:5}}},{category:qa.DOMAIN,code:Ha.NO_IP_RESTRICTIONS,metadata:{restrictions:{ipsCount:1,domainsCount:1}}}]}},Uu={users:bu,totalUsersItems:2,totalUsersPages:1,usersPageOffset:0},Cu={users:[bu[0]],totalUsersItems:1,totalUsersPages:1,usersPageOffset:0,queryParams:{_maxInactiveSeconds:7776e3}},Lu={users:[bu[1]],totalUsersItems:1,totalUsersPages:1,usersPageOffset:0};ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,ka.ASSIGNABLE,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date,new Date;var Du,Nu=new Uint8Array(16);function Mu(){if(!Du&&!(Du="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Du(Nu)}const Fu=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var xu=[],$u=0;$u<256;++$u)xu.push(($u+256).toString(16).substr(1));const Gu=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=(xu[t[e+0]]+xu[t[e+1]]+xu[t[e+2]]+xu[t[e+3]]+"-"+xu[t[e+4]]+xu[t[e+5]]+"-"+xu[t[e+6]]+xu[t[e+7]]+"-"+xu[t[e+8]]+xu[t[e+9]]+"-"+xu[t[e+10]]+xu[t[e+11]]+xu[t[e+12]]+xu[t[e+13]]+xu[t[e+14]]+xu[t[e+15]]).toLowerCase();if(!function(t){return"string"==typeof t&&Fu.test(t)}(a))throw TypeError("Stringified UUID is invalid");return a},ju=function(t,e,a){var n=(t=t||{}).random||(t.rng||Mu)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){a=a||0;for(var s=0;s<16;++s)e[a+s]=n[s];return e}return Gu(n)},Bu=["callback"],Vu=["callback"],Wu=["callback","profilePictureUrl"],Hu=["callback"],zu=["callback"],Ku=["callback"],qu=["callback"],Ju=["callback"],Yu=["callback"],Xu=["callback"],Qu=["callback"],Zu=["callback","samlVendor"],td=["callback"],ed=["callback"],ad=["callback","profileImage"],nd=["callback"],sd=["callback"],id=["callback"],od=["callback"],rd=["callback"],ld=["callback"],cd=["callback"],ud=["callback"],dd=["requestName"],gd=t=>"createdAt"!==t.id,pd={total:20,data:Array.from(Array(5).keys()).map((t=>v({ip:"198.143.51.1",user:"Demo User Name",email:"demo-user@frontegg.com"},(()=>{switch(Math.floor(6*Math.random())){case 0:return{action:"Updated profile",description:"User updated profile details",severity:"Info"};case 1:return{action:"User logged in",severity:"Info",description:"User logged in to the product"};case 2:return{action:"User failed to login",severity:"High",description:"User failed to login with password"};case 3:return{action:"Added user",severity:"Info",description:"Added user david+535@frontegg.com to tenant"};case 4:return{action:"Assigned roles",severity:"Info",description:"Assigned 0 roles for user"};case 5:return{action:"Removed user david+108@frontegg.com from account",severity:"Info",description:"Removed access from the account for user david+108@frontegg.com"}}})(),{json:{key1:"value1",key2:"value2",key3:"value3",key4:"value4"},tenantId:"my-tenant-id",vendorId:"my-vendor-id",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36",createdAt:`2022-04-07 10:${50-t}:40.201`})))},hd={properties:[{showInTable:!0,name:"createdAt",displayName:"Time",type:"Timestamp",sortable:!0,filterable:!0,showInMoreInfo:"Always",chosen:!1,selected:!1,isPredefined:!1},{showInTable:!0,name:"email",displayName:"User",type:"Email",filterable:!0,sortable:!0,isPredefined:!0,chosen:!1,selected:!1},{showInTable:!0,name:"action",displayName:"Action",type:"AlphaNumeric",sortable:!0,filterable:!0,showInMoreInfo:"Always",chosen:!1,selected:!1,isPredefined:!0},{showInTable:!0,name:"description",type:"AlphaNumeric",sortable:!1,filterable:!1,displayName:"Description",isPredefined:!0,chosen:!1,selected:!1},{showInTable:!0,name:"ip",displayName:"IP Address",type:"IpAddress",sortable:!0,filterable:!0,showInMoreInfo:"Always",chosen:!1,selected:!1,isPredefined:!0},{showInTable:!1,name:"severity",displayName:"Severity",type:"Severity",sortable:!0,filterable:!0,showInMoreInfo:"Always",chosen:!1,selected:!1,isPredefined:!0},{showInTable:!1,name:"userAgent",displayName:"User Agent",type:"AlphaNumeric",filterable:!0,sortable:!0,isPredefined:!0,chosen:!1,selected:!1},{showInTable:!1,name:"json",type:"Json",sortable:!0,filterable:!0,displayName:"Json Data",showInMoreInfo:"Always",isPredefined:!1}]},yd=(t,e,a)=>{const n=((t,e,a)=>{const n=Wc(t,e,a),s=Xc(n,["setAuditLogsState","resetAuditLogsState"]);return s.loadAuditLogs=async e=>{s.setAuditLogsState({loading:!e.silentLoading,error:null});const n=t.auditLogs.auditLogsState,{columns:i}=t.auditLogs.auditsMetadataState;try{var o,r,l,c,u;const t=null!=(o=e.pageSize)?o:n.pageSize,d=null!=(r=e.pageOffset)?r:n.pageOffset,g=null!=(l=e.filter)?l:n.filter,p=null!=(c=e.sort)?c:n.sort;s.setAuditLogsState({pageSize:t,pageOffset:d,filter:g,sort:p}),i||await a.loadAuditsMetadata();const{data:h,total:y}=((t,e)=>{const{data:a}=pd;let n=a.filter((t=>e=>t.filter(gd).every((t=>e[t.id].includes(t.value))))(t));if(e.length){const{id:t,desc:a=!1}=e[0];n=n.sort(((t,e)=>(a,n)=>a[t]>n[t]?e?-1:1:n[t]>a[t]?e?1:-1:0)(t,a))}return{data:n,total:n.length}})(g,p);s.setAuditLogsState({loading:!1,logs:null!=h?h:[],totalPages:+Math.ceil(y/t)}),null==e||null==(u=e.callback)||u.call(e,!0)}catch(t){var d;s.setAuditLogsState({loading:!1,error:Nn(t)}),null==e||null==(d=e.callback)||d.call(e,null,t)}},s})(t,e,a),s=((t,e)=>{const a=Kc(t,e),n=Xc(a,["setAuditsMetadataState","resetAuditsMetadataState"]);return n.loadAuditsMetadata=async()=>{n.setAuditsMetadataState({loading:!0,error:null});try{const{properties:t}=hd;n.setAuditsMetadataState({columns:t,loading:!1})}catch(t){n.setAuditsMetadataState({error:t,loading:!1})}},n})(t,e);return v({},n,s)},Sd={id:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",externalId:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",startDate:"2021-09-20T08:08:51.000Z",status:x.ACTIVE,externallyManaged:!1,cancellation:null,currentPeriodStart:"2021-09-20T08:08:51.000Z",currentPeriodEnd:"2021-10-20T08:08:51.000Z",plan:{slug:"test"}},vd=[{id:"prod_J60fUEvI7qV1eL",externalId:"prod_J60fUEvI7qV1eL",name:"Premium",description:"",price:{id:"price_1IToe8Ewsu4qiqnndAV76J69",externalId:"price_1IToe8Ewsu4qiqnndAV76J69",currency:"usd",amount:1e4},slug:"premium"},{id:"prod_J60duauCpXfcur",externalId:"prod_J60duauCpXfcur",name:"Free",description:"Totally free plan. Nothing to pay.",price:{id:"price_1ITocfEwsu4qiqnnnBHDx9fQ",externalId:"price_1ITocfEwsu4qiqnnnBHDx9fQ",currency:"usd",amount:0},slug:"free"}],fd=[{id:"in_1JbhYWEwsu4qiqnnrUh6hsHa",externalId:"in_1JbhYWEwsu4qiqnnrUh6hsHa",subscriptionId:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",paymentDate:"2021-09-20T08:08:51.000Z",totalAmount:1e4,currency:"usd",paid:!0,receiptNumber:""},{id:"in_1JbhYWEwsu4qiqnnrUh6hsHa",externalId:"in_1JbhYWEwsu4qiqnnrUh6hsHa",subscriptionId:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",paymentDate:"2021-08-20T08:08:51.000Z",totalAmount:1e4,currency:"usd",paid:!0,receiptNumber:""}],md=[{id:"id",externalId:"externalId",type:$.CARD,isDefault:!0,last4:"4242",expMonth:11,expYear:25,brand:"visa",billingDetails:{name:"Dummy",email:"dummy@email.com"}}],bd={allowPlanDowngrade:!0,allowPlanCancellation:!0},Ad=(t,e,a)=>{const n=((t,e)=>{const a=cc(t,e),n=Xc(a,["setPaymentConfigState","resetPaymentConfigState"]);return n.loadPaymentConfiguration=async()=>{n.setPaymentConfigState({loading:!0}),await En(500),n.setPaymentConfigState({loading:!1,fetching:!1,config:{paymentProvider:oc.STRIPE,apiKey:""}})},n})(t,e),[s,i]=((t,e,a)=>{const n=((t,e,a)=>{const n=hc(t,e,a),s=Xc(n,["setBillingInformationState","resetBillingInformationState"]);return s.loadBillingInformation=async()=>{var t,e;s.setBillingInformationState({loading:!0}),await En(500),s.setBillingInformationState({loading:!1,fetching:!1,summary:{subscriptionId:Sd.id,paymentMethodId:"mockPaymentMethodId",tenantConfigurationId:"mockTenantConfigurationId",providerType:j.Stripe,externallyManaged:!1,currentPlanId:vd[0].id,defaultPlanId:vd[0].id},plan:v({},vd[0],{price:null==(t=vd[0].price)?void 0:t.amount,currency:null==(e=vd[0].price)?void 0:e.currency,recurringInterval:"month"})})},s})(t,e,a),s=((t,e)=>{const a=bc(t,e),n=Xc(a,["setBillingPaymentMethodState","resetBillingPaymentMethodState"]);return n.loadPaymentMethod=async()=>{n.setBillingPaymentMethodState({loading:!0}),await En(500),n.setBillingPaymentMethodState({paymentMethod:md[0],loading:!1,fetching:!1})},n})(t,e),i=((t,e)=>{const a=vc(t,e),n=Xc(a,["setBillingInvoiceState","resetBillingInvoiceState"]);return n.loadBillingInvoices=async()=>{n.setBillingInvoiceState({loading:!0}),await En(500),n.setBillingInvoiceState({loading:!1,fetching:!1,invoices:fd.map((t=>v({},t,{selectedPlan:"Premium",paymentDate:new Date(Date.parse(t.paymentDate)),totalAmount:+((t.totalAmount||0)/100).toFixed(2)})))})},n.loadInvoices=n.loadBillingInvoices,n})(t,e),o=((t,e,a)=>{const n=Tc(t,e,a),s=Xc(n,["setBillingSubscriptionState","resetBillingSubscriptionState","setCancellationLoading","setCancellationError","setRenewalLoading","setRenewalError"]);return s.loadSubscription=async()=>{s.setBillingSubscriptionState({loading:!0}),await En(500),s.setBillingSubscriptionState({subscription:Sd,fetching:!1,loading:!1,error:null})},s})(t,e,a);return[v({},n,s,i,o),{information:n,invoices:i,paymentMethod:s,subscription:o}]})(t,e,a),o=((t,e)=>{const a=Pc(t,e),n=Xc(a,["setPlansState","resetPlansState"]);return n.loadPlans=async()=>{n.setPlansState({loading:!0}),await En(500),n.setPlansState({fetching:!1,loading:!1,plans:vd.map((t=>{var e,a;return v({},t,{price:(null==(e=t.price)?void 0:e.amount)||0,currency:(null==(a=t.price)?void 0:a.currency)||"usd",recurringInterval:"month"})}))})},n})(t,e),r=((t,e,a)=>{const n=Rc(t,e,a);return Xc(n,["setCheckoutState","resetCheckoutState","errorCheckout","resetCheckout"])})(t,e,a),l=((t,e)=>{const a=Lc(t,e);return Xc(a,[])})(t,e),c=((t,e)=>{const a=Mc(t,e),n=Xc(a,["setVendorPublicConfigState","resetVendorPublicConfigState","setVendorPublicConfigError","setVendorPublicConfigLoading"]);return n.loadVendorPublicConfiguration=async()=>{n.setVendorPublicConfigLoading(!0),await En(),n.setVendorPublicConfigState({fetching:!1,loading:!1,vendorPublicConfig:bd})},n})(t,e);return[v({},n,s,o,r,l,c),{config:n,billing:i,plans:o,checkout:r,stripe:l,vendorPublicConfig:c}]},wd=(t,e,a,n)=>{const{authActions:s,authStateActions:i}=((t,e,a,n)=>{const s=((t,e)=>{const a=Mn(t,e);return Xc(a,["setAcceptInvitationState","resetAcceptInvitationState"])})(t,e),i=((t,e,a)=>{const n=Gn(t,e,a),s=Xc(n,["setAccountSettingsState","resetAccountSettingsState"]);return s.saveAccountSettings=async e=>{var a;s.setAccountSettingsState({loading:!0}),await En();const n=t.auth.accountSettingsState,{address:i,timezone:o,dateFormat:r,timeFormat:l,currency:c,logo:u}=n,d=v({address:i,timezone:o,dateFormat:r,timeFormat:l,currency:c,logo:u},e);s.setAccountSettingsState(v({},d,{loading:!1})),null==(a=e.callback)||a.call(e,d)},s.loadAccountSettings=async t=>{s.setAccountSettingsState({loading:!(null!=t&&t.silentLoading),error:null}),await En(),s.setAccountSettingsState(v({address:"Tel-aviv",timezone:"Asia/Jerusalem",dateFormat:"DD/MM/YYYY",timeFormat:"HH:mm",currency:"USD",loading:!1},t))},s})(t,e,a),o=((t,e)=>{const a=Ls(t,e);return Xc(a,["setUnlockAccountState","resetUnlockAccountState"])})(t,e),r=((t,e,a)=>{const n=Rs(t,e,a);return Xc(n,["setActivateState","resetActivateState","setActivateStrategyState"])})(t,e,a),l=((t,e,a)=>{const n=Ho(t,e,a);return Xc(n,["setAllAccountsLoader","setAllAccountsError","setAllAccountsState","setSelectedAccountState","resetAllAccountsState","clearSelectedAccount"])})(t,e,a),c=zo(t),u=((t,e)=>{const a=Fs(t,e),n=Xc(a,["setApiTokensState","resetApiTokensState","setApiTokensLoader","setApiTokensError"]);return n.addTenantApiToken=async e=>{const{description:a,roleIds:s,callback:i}=e;n.setApiTokensLoader({key:Ms.ADD_API_TOKEN,value:!0});const{apiTokensDataTenant:o}=t.auth.apiTokensState,r=v({},Zc,{description:a,roleIds:s,clientId:`CLIENT_ID_${ju()}`});n.setApiTokensState({showAddTokenDialog:!1}),await En(200),n.setApiTokensState({apiTokensDataTenant:[...o,r],successDialog:{open:!0,secret:r.secret,clientId:r.clientId}}),await En(200),n.setApiTokensLoader({key:Ms.ADD_API_TOKEN,value:!1}),null==i||i(null)},n.deleteTenantApiToken=async t=>{n.setApiTokensLoader({key:Ms.DELETE_API_TOKEN,value:!0}),await En(200);const e=[Zc];n.setApiTokensState({apiTokensDataTenant:e.filter((e=>e.clientId!==t)),deleteTokenDialog:{open:!1,clientId:t}}),n.setApiTokensLoader({key:Ms.DELETE_API_TOKEN,value:!1})},n.loadApiTokens=async t=>{var e;null!=t&&t.silentLoading||n.setApiTokensLoader({key:Ms.LOAD_API_TOKENS,value:!0});const a=[Qc],s=[Zc];n.setApiTokensState({apiTokensDataUser:a,apiTokensDataTenant:s}),await En(200),n.setApiTokensLoader({key:Ms.LOAD_API_TOKENS,value:!1}),null==t||null==(e=t.callback)||e.call(t,!0)},n.loadUserApiTokens=async t=>{var e;null!=t&&t.silentLoading||n.setApiTokensLoader({key:Ms.LOAD_API_TOKENS,value:!0});const a=[Qc];n.setApiTokensState({apiTokensDataUser:a}),await En(200),n.setApiTokensLoader({key:Ms.LOAD_API_TOKENS,value:!1}),null==t||null==(e=t.callback)||e.call(t,!0)},n.loadTenantApiTokens=async t=>{var e;null!=t&&t.silentLoading||n.setApiTokensLoader({key:Ms.LOAD_API_TOKENS,value:!0});const a=[Zc];n.setApiTokensState({apiTokensDataTenant:a}),await En(200),n.setApiTokensLoader({key:Ms.LOAD_API_TOKENS,value:!1}),null==t||null==(e=t.callback)||e.call(t,!0)},n})(t,e),d=((t,e,a)=>{const n=js(t,e,a);return Xc(n,["setApplicationsState","resetApplicationsState"])})(t,e,a),g=((t,e,a)=>{const n=Hs(t,e,a),s=Xc(n,["setCustomLoginState","resetCustomLoginState"]);return s.loadTenantMetadata=async()=>{s.setCustomLoginState({loading:!0}),await En(),s.setCustomLoginState({loading:!1})},s.updateTenantMetadata=async t=>{const{callback:e}=t;s.setCustomLoginState({loading:!0,error:null}),await En(),s.setCustomLoginState({loading:!1,error:null}),null==e||e(!0)},s})(t,e,a),p=((t,e)=>{const a=Hl(t,e);return Xc(a,["setEntitlements","handleFetchedEntitlements"])})(t,e),h=((t,e)=>{const a=Ys(t,e),n=Xc(a,["setForgotPasswordState","resetForgotPasswordState"]);return n.loadPasswordConfig=async t=>{n.setForgotPasswordState({loading:!0});try{n.setForgotPasswordState({loading:!1,passwordConfig:{allowPassphrases:!0,maxLength:128,minLength:6,minPhraseLength:6,minOptionalTestsToPass:1}})}catch(t){n.setForgotPasswordState({loading:!1,error:Nn(t)})}},n})(t,e),y=(t=>{const e=ti(t),a=Xc(e,["setStep"]);return a.setStep(Xs.success),a})(t),S=((t,e)=>{const a=oi(t,e),n=Xc(a,["setGroupsState","resetUsersGroupsState","setUsersGroupsLoader","setUsersGroupsError"]);return n.loadGroups=async()=>{const t=ni.GET_GROUPS;n.setUsersGroupsLoader({key:t,value:!0});const e=ku;n.setGroupsState({groups:e}),n.setUsersGroupsLoader({key:t,value:!1})},n.createGroup=async e=>{var a;const s=ni.CREATE_GROUP,{groups:i}=t.auth.groupsState;n.setUsersGroupsLoader({key:s,value:!0}),await En(500),n.setGroupsState({groups:[v({},e,{id:`${e.name}ID`,managedBy:$a.FRONTEGG}),...null!=i?i:[]]}),null==e||null==(a=e.callback)||a.call(e,!0),n.setUsersGroupsLoader({key:s,value:!1})},n.updateGroup=async e=>{var a,s,i,o,r;const l=ni.UPDATE_GROUP,c=t.auth.groupsState;n.setUsersGroupsLoader({key:l,value:!0}),await En(500),n.setGroupsState({groups:null==c||null==(a=c.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},e,{id:e.groupId,name:null!=(a=null==e?void 0:e.name)?a:"",managedBy:$a.FRONTEGG}):t})),selectedGroup:v({},null==c?void 0:c.selectedGroup,{name:null!=(s=null==e?void 0:e.name)?s:"",color:null!=(i=null==e?void 0:e.color)?i:"",description:null!=(o=null==e?void 0:e.description)?o:""})}),null==e||null==(r=e.callback)||r.call(e,!0),n.setUsersGroupsLoader({key:l,value:!1})},n.deleteGroup=async e=>{var a,s;const i=ni.DELETE_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await En(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.filter((t=>t.id!==e.groupId))}),null==e||null==(s=e.callback)||s.call(e,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.addRolesToGroup=async e=>{var a,s;const i=ni.ADD_ROLES_TO_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await En(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},t,{roles:[...null!=(a=null==t?void 0:t.roles)?a:[],...e.roleIds.map((t=>({id:t,name:t})))]}):t}))}),null==e||null==(s=e.callback)||s.call(e,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.deleteRolesFromGroup=async e=>{var a,s;const i=ni.DELETE_ROLES_FROM_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await En(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},t,{roles:null==t||null==(a=t.roles)?void 0:a.filter((t=>!e.roleIds.includes(t.id)))}):t}))}),null==e||null==(s=e.callback)||s.call(e,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.addUsersToGroup=async e=>{var a,s;const i=ni.ADD_USERS_TO_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await En(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},t,{users:[...null!=(a=null==t?void 0:t.users)?a:[],...e.userIds.map((t=>({id:t,name:t})))]}):t}))}),null==e||null==(s=e.callback)||s.call(e,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.deleteUsersFromGroup=async e=>{var a,s;const i=ni.DELETE_USERS_FROM_GROUP,o=t.auth.groupsState;n.setUsersGroupsLoader({key:i,value:!0}),await En(500),n.setGroupsState({groups:null==o||null==(a=o.groups)?void 0:a.map((t=>{var a;return t.id===e.groupId?v({},t,{users:null==t||null==(a=t.users)?void 0:a.filter((t=>!e.userIds.includes(t.id)))}):t}))}),null==e||null==(s=e.callback)||s.call(e,!0),n.setUsersGroupsLoader({key:i,value:!1})},n.getGroupConfiguration=async()=>{const e=ni.GET_GROUP_CONFIGURATION,{groupsConfiguration:a}=t.auth.groupsState;n.setUsersGroupsLoader({key:e,value:!0}),a&&n.setGroupsState({groupsConfiguration:v({},a)}),n.setUsersGroupsLoader({key:e,value:!1})},n.updateGroupConfiguration=async e=>{const a=ni.UPDATE_GROUP_CONFIGURATION,{groupsConfiguration:s}=t.auth.groupsState;n.setUsersGroupsLoader({key:a,value:!0}),s&&n.setGroupsState({groupsConfiguration:v({},s,e)}),n.setUsersGroupsLoader({key:a,value:!1})},n})(t,e),m=ci(t),b=((t,e,a)=>{const n=hi(t,e,a);return Xc(n,["setImpersonateState","resetImpersonateState"])})(t,e,a),A=((t,e,a)=>{const n=a,s=wo(t,e,n),i=Xc(s,["setLoginState","resetLoginState","afterAuthNavigation"]);return i.requestAuthorize=async t=>{t&&n.setAuthState({isLoading:!0});const e=au;await n.loadTenants(),n.setAuthState({user:e,isAuthenticated:!0,isLoading:!1})},i.getUserIP=async t=>{const{callback:e}=t;try{const{ip:t}=Iu[0];await n.setAuthState({userIpData:{ip:t},userIp:t}),null==e||e(!0,t)}catch(t){null==e||e(!1,t)}},i})(t,e,a),w=((t,e,a)=>{const n=a,s=Lo(t,e,n),i=Xc(s,["setMfaState","resetMfaState"]);return i.enrollMfa=async()=>{i.setMfaState({saving:!0}),i.setMfaState({saving:!1,error:void 0,qrCode:"test"})},i.verifyMfa=async e=>{const{callback:a}=e,{mfaDevices:s={webauthn:[],phones:[],authenticators:[],emails:[]}}=(f(e,Bu),t.auth.mfaState);i.setMfaState({saving:!0}),await En();const o={token:"token",recoveryCode:"recoveryCode"},r={step:Yn.recoveryCode,loading:!1,error:void 0,saving:!1,mfaDevices:v({},s,{authenticators:[{id:"authenticator-id"}]})};null!=o&&o.recoveryCode&&(r.recoveryCode=o.recoveryCode),i.setMfaState(r),n.setUser(v({},au,{mfaEnrolled:!0})),null==a||a(r.recoveryCode)},i.disableMfa=async e=>{var a;const{mfaDevices:s={webauthn:[],phones:[],authenticators:[],emails:[]}}=t.auth.mfaState;i.setMfaState({saving:!0}),await En(),i.setMfaState({saving:!1,error:void 0,mfaDevices:v({},s,{authenticators:[]})}),n.setUser(v({},au)),null==(a=e.callback)||a.call(e,!0)},i.verifyMfaAfterForce=async t=>{const{callback:e}=t,a=f(t,Vu);i.setMfaState({loading:!0}),await En();const s=v({},a,{recoveryCode:"recoveryCode"}),o={step:Yn.recoveryCode,loading:!1,error:void 0,saving:!1};null!=s&&s.recoveryCode&&(o.recoveryCode=s.recoveryCode),i.setMfaState(o),await En(),n.setUser(v({},au,{mfaEnrolled:!0})),null==e||e(o.recoveryCode)},i.preDisableMfaSms=async t=>{i.setMfaState({saving:!0});try{var e;i.setMfaState({saving:!1,error:void 0,otcToken:"otc-token",phoneNumber:"+972504589346"}),null==(e=t.callback)||e.call(t,!0)}catch(e){var a;i.setMfaState({saving:!1,error:Nn(e)}),null==(a=t.callback)||a.call(t,!1,e)}},i.disableMfaSms=async e=>{var a;const{mfaDevices:s={webauthn:[],phones:[],authenticators:[],emails:[]}}=t.auth.mfaState;i.setMfaState({saving:!0}),await En(),i.setMfaState({loading:!1,error:void 0,mfaDevices:v({},s,{phones:[]})}),n.setUser(v({},au)),null==(a=e.callback)||a.call(e,!0)},i.preEnrollMfaSms=async t=>{var e;i.setMfaState({saving:!0}),await En(),i.setMfaState({saving:!1,error:void 0,otcToken:"otc-token",phoneNumber:"+972504589346"}),null==(e=t.callback)||e.call(t,!0)},i.enrollMfaSms=async e=>{const{callback:a}=e,{mfaDevices:s={webauthn:[],phones:[],authenticators:[],emails:[]}}=t.auth.mfaState;i.setMfaState({saving:!0}),await En();const o={token:"token",recoveryCode:"recoveryCode"},r={step:Yn.recoveryCode,loading:!1,error:void 0,saving:!1,mfaDevices:v({},s,{phones:[{id:"phone-id",phoneNumber:"+972504589346"}]})};null!=o&&o.recoveryCode&&(r.recoveryCode=o.recoveryCode),i.setMfaState(r),n.setUser(v({},au,{mfaEnrolled:!0})),null==a||a(r.recoveryCode)},i})(t,e,a),T=((t,e,a)=>{const n=Jo(t,e,a);return Xc(n,["setPasskeysState","resetPasskeysState"])})(t,e,a),E=((t,e,a)=>{const n=Zo(t,e,a),s=Xc(n,["setProfileState","resetProfileState"]);return s.loadProfile=async()=>{s.setProfileState({loading:!0}),await En(),a.setUser(v({},au,eu)),s.setProfileState({loading:!1,profile:eu})},s.saveProfile=async t=>{const{callback:e,profilePictureUrl:n}=t,i=f(t,Wu);s.setProfileState({saving:!0,error:null});const o=nu;let r=o.profile.profilePictureUrl;n!==o.profile.profilePictureUrl&&n&&(n||"").match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/)&&(r=n);const l=v({},o.profile,i,{profilePictureUrl:r}),c=au;await En(),a.setUser(v({},c,l)),s.setProfileState({loading:!1,error:null,saving:!1,profile:l}),null==e||e(l)},s.changePassword=async t=>{var e;s.setProfileState({loading:!0}),await En(),s.setProfileState({loading:!1,error:void 0}),null==(e=t.callback)||e.call(t,!0)},s})(t,e,a),I=((t,e)=>{const a=sr(t,e);return Xc(a,["setProvisioningState","resetProvisioningState"])})(t,e),O=((t,e,a)=>{const n=dr(t,e,a);return Xc(n,["setResetPhoneNumberState","resetResetPhoneNumberState"])})(t,e,a),P=((t,e,a)=>{const n=kr(t,e,a),s=Xc(n,["setRestrictionsState","setIpRestrictionsState","setEmailDomainRestrictionsState"]);return s.loadIpRestrictions=async()=>{s.setIpRestrictionsState({loading:!0,error:null}),s.setIpRestrictionsState({data:{restrictions:Iu.filter((t=>t.strategy===Eu.strategy)),config:Eu},totalPages:1,pagination:{_filter:zt.ALLOW,_limit:50,_offset:0},loading:!1})},s.loadEmailDomainRestrictions=async()=>{s.setEmailDomainRestrictionsState({loading:!0,error:null}),s.setEmailDomainRestrictionsState({loading:!1,data:{restrictions:[{domain:"mock.com",id:"1",type:zt.ALLOW}],config:{active:!0,listType:zt.ALLOW,blockPublicDomains:!1}}})},s.saveIpRestriction=async e=>{var a,n,i;const{callback:o}=e,r=f(e,Hu);s.setIpRestrictionsState({saving:!0,error:null});const l=t.auth.restrictionsState.ipRestrictions,c=l.data.restrictions.filter((t=>t.ip!==r.ip));s.setIpRestrictionsState({data:{config:null!=(a=null==(n=l.data)?void 0:n.config)?a:{isActive:!1,strategy:zt.ALLOW},restrictions:[...c,v({},r,{createdAt:new Date,updatedAt:new Date,id:ju(),isActive:null==(i=r.isActive)||i,strategy:l.data.config.strategy})]},totalPages:1,pagination:{_filter:zt.ALLOW,_limit:50,_offset:0},saving:!1}),null==o||o(!0)},s.saveIpRestrictionsConfig=async e=>{var a,n,i;const{callback:o}=e,r=f(e,zu),l=t.auth.restrictionsState.ipRestrictions;s.setIpRestrictionsState({saving:!0,error:null}),s.setIpRestrictionsState({data:{config:v({},null==(a=l.data)?void 0:a.config,r),restrictions:null!=(n=null==(i=l.data)?void 0:i.restrictions)?n:[]},pagination:{_filter:zt.ALLOW,_limit:50,_offset:0},totalPages:1,saving:!1}),s.setIpRestrictionsState({saving:!1,error:null}),null==o||o(!0)},s.deleteIpRestriction=async e=>{var a;const{callback:n,id:i}=e;s.setIpRestrictionsState({saving:!0,error:null});const o=t.auth.restrictionsState.ipRestrictions;s.setIpRestrictionsState({data:{config:(null==(a=o.data)?void 0:a.config)||{isActive:!1,strategy:zt.ALLOW},restrictions:o.data.restrictions.filter((t=>t.id!==i))},pagination:{_filter:zt.ALLOW,_limit:50,_offset:0},totalPages:1,saving:!1,error:null}),null==n||n(!0)},s.checkIfUserIpValid=async()=>{s.setIpRestrictionsState({loading:!0,error:null});try{const e=t.auth.restrictionsState.ipRestrictions,a=Iu[0].ip,n=!!e.data.restrictions.find((t=>t.isActive&&t.ip===a));s.setIpRestrictionsState({userIpValid:n,loading:!1})}catch(t){s.setIpRestrictionsState({error:Nn(t),loading:!1})}},s.saveEmailDomainRestriction=async e=>{var a,n;const{callback:i}=e,o=f(e,Ku),r=t.auth.restrictionsState.emailDomainRestrictions;s.setEmailDomainRestrictionsState({saving:!0,error:null}),await En(),null==i||i(!0),s.setEmailDomainRestrictionsState({data:{config:(null==(a=r.data)?void 0:a.config)||{active:!1,blockPublicDomains:!1,listType:o.type},restrictions:[...(null==(n=r.data)?void 0:n.restrictions)||[],v({},o,{id:Date.now().toString()})]},saving:!1})},s.saveEmailDomainRestrictionsConfig=async e=>{var a;const{callback:n}=e,i=f(e,qu),o=t.auth.restrictionsState.emailDomainRestrictions;s.setEmailDomainRestrictionsState({saving:!0,error:null}),await En(),null==n||n(!0),s.setEmailDomainRestrictionsState({data:{config:{active:i.active,blockPublicDomains:i.blockPublicDomains||!1,listType:i.type||zt.ALLOW},restrictions:[...(null==(a=o.data)?void 0:a.restrictions)||[]]},saving:!1})},s.deleteEmailDomainRestriction=async e=>{var a,n;const{id:i}=e,o=t.auth.restrictionsState.emailDomainRestrictions;s.setEmailDomainRestrictionsState({saving:!0,error:null}),await En(),s.setEmailDomainRestrictionsState({data:{config:(null==(a=o.data)?void 0:a.config)||{active:!1,blockPublicDomains:!1,listType:zt.ALLOW},restrictions:((null==(n=o.data)?void 0:n.restrictions)||[]).filter((t=>t.id===i))},saving:!1})},s})(t,e,a),k=((t,e)=>{const a=Ar(t,e),n=Xc(a,["setRolesState","setRolesStateError","setRolesStateLoader","resetRolesState"]);return n.loadRolesAndPermissions=async t=>{var e;const a=hr.LOAD_ROLES;n.setRolesStateLoader({key:a,value:!(null!=(e=null==t?void 0:t.silentLoading)&&e)});try{n.setRolesState({roles:tu})}catch(t){n.setRolesStateError({key:a,value:Nn(t)})}finally{n.setRolesStateLoader({key:a,value:!1})}},n})(t,e),_=((t,e,a)=>{const n=Lr(t,e,a),s=Xc(n,["setSecurityCenterState","setSecurityCenterStateError","setSecurityCenterStateLoader","resetSecurityCenterState"]);return s.loadRecommendations=async()=>{const t=Ur.RECOMMENDATIONS;s.setSecurityCenterStateLoader({key:t,value:!0}),await En(),s.setSecurityCenterState({recommendations:_u.recommendations.items,score:_u.scoring.score}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadInsights=async()=>{const t=Ur.INSIGHTS;s.setSecurityCenterStateLoader({key:t,value:!0}),await En(),s.setSecurityCenterState({insights:Ru.insights.items}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadBreachedPasswordUsers=async()=>{const t=Ur.BREACHED_PASSWORD_USERS_TABLE;s.setSecurityCenterStateLoader({key:t,value:!0}),await En(),s.setSecurityCenterState({breachedPasswordUsersTable:Uu}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadUnenrolledMfaUsers=async()=>{const t=Ur.UNENROLLED_MFA_USERS_TABLE;s.setSecurityCenterStateLoader({key:t,value:!0}),await En(),s.setSecurityCenterState({unenrolledMfaUsersTable:Lu}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.loadInactiveUsers=async()=>{const t=Ur.INACTIVE_USERS_TABLE;s.setSecurityCenterStateLoader({key:t,value:!0}),await En(),s.setSecurityCenterState({inactiveUsersTable:Cu}),s.setSecurityCenterStateLoader({key:t,value:!1})},s.sendResetBreachedPasswordEmail=async t=>{const{callback:e}=t,a=Ur.SEND_BREACHED_PASSWORD_EMAIL;s.setSecurityCenterStateLoader({key:a,value:!0}),await En(),null==e||e(!0),s.setSecurityCenterStateLoader({key:a,value:!1})},s})(t,e,a),R=((t,e,a)=>{const n=jr(t,e,a),s=Xc(n,["setSecurityPolicyState","setSecurityPolicyGlobalState","setSecurityPolicyPublicState","setSecurityPolicyMfaState","setSecurityPolicyVendorMfaState","setSecurityPolicyLockoutState","setSecurityPolicyVendorLockoutState","setSecurityPolicyCaptchaState","setSecurityPolicyPasswordHistoryState","setSecurityPolicyVendorPasswordHistoryState","resetSecurityPolicyState","setSecurityPolicyPasswordState","setSecurityPolicyAuthStrategyPublicState"]);return s.loadSecurityPolicy=async()=>{s.setSecurityPolicyGlobalState({loading:!0,error:null}),await Promise.all([s.loadSecurityPolicyMfa(),s.loadSecurityPolicyVendorMfa(),s.loadSecurityPolicyLockout(),s.loadSecurityPolicyVendorLockout(),s.loadSecurityPolicyPasswordHistory(),s.loadSecurityPolicyVendorPasswordHistory(),s.loadSecurityPolicyCaptcha()]),await En(),s.setSecurityPolicyGlobalState({policy:su,loading:!1})},s.loadPublicSecurityPolicy=async()=>{s.setSecurityPolicyPublicState({loading:!0,error:null});try{s.setSecurityPolicyPublicState({policy:iu,loading:!1})}catch(t){s.setSecurityPolicyPublicState({error:Nn(t),loading:!1})}},s.saveSecurityPolicyMfa=async t=>{var e;const{callback:a}=t,n=f(t,Ju);s.setSecurityPolicyMfaState({saving:!0,error:null});const i=v({},ru,{id:null!=(e=n.id)?e:ru.id,enforceMFAType:n.enforceMFAType});await En(),s.setSecurityPolicyMfaState({policy:i,saving:!1}),null==a||a(i)},s.loadSecurityPolicyMfa=async()=>{s.setSecurityPolicyMfaState({loading:!0,error:null}),await En(),s.setSecurityPolicyMfaState({policy:ou,loading:!1})},s.loadSecurityPolicyVendorMfa=async()=>{s.setSecurityPolicyVendorMfaState({loading:!0,error:null}),await En(),s.setSecurityPolicyVendorMfaState({policy:ou,loading:!1})},s.saveSecurityPolicyLockout=async t=>{const{callback:e}=t,a=f(t,Yu);s.setSecurityPolicyLockoutState({saving:!0,error:null}),await En();const n=v({},ru,a,{id:a.id?a.id:ru.id});null==e||e(n),s.setSecurityPolicyLockoutState({policy:n,saving:!1})},s.loadSecurityPolicyLockout=async()=>{s.setSecurityPolicyLockoutState({loading:!0,error:null}),await En(),s.setSecurityPolicyLockoutState({policy:ru,loading:!1})},s.loadSecurityPolicyVendorLockout=async()=>{s.setSecurityPolicyVendorLockoutState({loading:!0,error:null}),await En(),s.setSecurityPolicyVendorLockoutState({policy:ru,loading:!1})},s.loadSecurityPolicyCaptcha=async()=>{s.setSecurityPolicyLockoutState({loading:!0,error:null}),await En(),s.setSecurityPolicyLockoutState({policy:ru,loading:!1})},s.saveSecurityPolicyPasswordHistory=async t=>{const{callback:e}=t,a=f(t,Xu);s.setSecurityPolicyPasswordHistoryState({saving:!0,error:null}),await En();const n=v({},lu,a,{id:a.id?a.id:lu.id});null==e||e(n),s.setSecurityPolicyPasswordHistoryState({policy:n,saving:!1})},s.loadSecurityPolicyPasswordHistory=async()=>{s.setSecurityPolicyPasswordHistoryState({loading:!0,error:null}),await En(),s.setSecurityPolicyPasswordHistoryState({policy:lu,loading:!1})},s.loadSecurityPolicyVendorPasswordHistory=async()=>{s.setSecurityPolicyVendorPasswordHistoryState({loading:!0,error:null}),await En(),s.setSecurityPolicyVendorPasswordHistoryState({policy:lu,loading:!1})},s})(t,e,a),U=((t,e)=>{const a=qr(t,e),n=Xc(a,["setSessionsState","resetSessionsState"]);return n.loadUserSessions=async()=>{n.setSessionsState({loading:!0,error:null}),n.setSessionsState({sessions:Tu,loading:!1})},n.deleteUserSession=async e=>{const{id:a}=e;n.setSessionsState({loading:!0,error:null});const s=t.auth.sessionsState.sessions.filter((t=>t.id!==a));n.setSessionsState({sessions:s,loading:!1})},n.deleteAllUserSessions=async()=>{n.setSessionsState({loading:!0,error:null});const t=Tu.filter((t=>t.current));n.setSessionsState({sessions:t,loading:!1})},n})(t,e),C=((t,e,a)=>{const n=Hr(t,e,a),s=Xc(n,["setSessionsPolicyState","resetSessionsPolicyState"]);return s.loadSessionsPolicy=async()=>{s.setSessionsPolicyState({loading:!0,error:null});const e=t.auth.sessionsPolicyState;s.setSessionsPolicyState(v({},e,{loading:!1}))},s.createOrUpdateSessionsPolicy=async t=>{const{callback:e}=t,a=f(t,Qu);s.setSessionsPolicyState({loading:!0,error:null}),null==e||e(!0),s.setSessionsPolicyState({configurations:a,loading:!1})},s})(t,e,a),L=((t,e,a)=>{const n=tl(t,e,a);return Xc(n,["setSignUpState","resetSignUpState","resetSignUpStateSoft"])})(t,e,a),D=((t,e)=>{const a=cl(t,e);return Xc(a,["setSmsState","resetSmsState"])})(t,e),N=((t,e,a)=>{const n=hl(t,e,a);return Xc(n,["setSocialLoginsState","resetSocialLoginsState","setSocialLoginError"])})(t,e,a),M=((t,e,a)=>{const n=wl(t,e,a),s=Xc(n,["setSSOState","resetSSOState"]);return s.loadSSOConfigurations=async()=>{s.setSSOState({loading:!0}),await En(),s.setSSOState({samlConfiguration:cu,loading:!1,firstLoad:!1})},s.saveSSOConfigurations=async t=>{var e,a;const{callback:n,samlVendor:i}=t,o=f(t,Zu),r=gu.samlConfiguration,l=v({},r,o);let c="saving";if((null==l?void 0:l.enabled)!==r.enabled&&(c="loading"),null==l||!l.domain)return void s.setSSOState({samlConfiguration:v({},r,l)});s.setSSOState({error:void 0,[c]:!0}),await En(),l.acsUrl=null==uu||null==(e=uu.configuration)?void 0:e.acsUrl,l.spEntityId=null==uu||null==(a=uu.configuration)?void 0:a.spEntityId;const u=_n(l,["validated","generatedVerification","createdAt","updatedAt"]);(null==r?void 0:r.domain)!==(null==u?void 0:u.domain)&&(u.ssoEndpoint="",u.publicCertificate="",u.signRequest=!1),u.type=null==i?void 0:i.toLowerCase(),await En(),s.setSSOState({samlConfiguration:u,error:void 0,[c]:!1}),null==n||n(!0)},s.saveSSOConfigurationsFile=async e=>{const a="saving";s.setSSOState({error:void 0,[a]:!0});const n=v({},t.auth.ssoState.samlConfiguration,{enabled:!0},e[0]);s.setSSOState({samlConfiguration:n,error:void 0,[a]:!1})},s.validateSSODomain=async t=>{const{callback:e}=null!=t?t:{},a=gu.samlConfiguration;s.setSSOState({error:void 0,saving:!0}),await En(),s.setSSOState({samlConfiguration:v({},a,{validated:!0}),error:void 0,saving:!1}),null==e||e(!0)},s.loadSSOAuthorizationRoles=async()=>{await En(),s.setSSOState({authorizationRoles:["1","2","3"],error:void 0})},s.updateSSOAuthorizationRoles=async t=>{const{callback:e,authorizationRoles:a}=t;s.setSSOState({error:void 0,saving:!0}),await En(),s.setSSOState({authorizationRoles:a,error:void 0,saving:!1}),null==e||e(!0)},s})(t,e,a),F=((t,e,a)=>{const n=Il(t,e,a);return Xc(n,["setStepUpState","resetStepUpState"])})(t,e,a),x=((t,e,a)=>{const n=jl(t,e,a),s=Xc(n,["setTeamState","resetTeamState","setTeamLoader","setTeamError","openAddUserDialog","closeAddUserDialog","openDeleteUserDialog","closeDeleteUserDialog"]);return s.loadUsersV2=async e=>{var a,n,i,o;const{silentLoading:r,callback:l}=e,c=t.auth.teamState,u=null!=(a=e.pageSize)?a:c.pageSize,d=null!=(n=e.pageOffset)?n:c.pageOffset,g=null!=(i=e.filter)?i:c.filterV2,p=null!=(o=e.sort)?o:c.sortV2;s.setTeamLoader({key:ws.USERS,value:!r}),s.setTeamState({pageSize:u,pageOffset:d,filterV2:g,sortV2:p}),await En(),s.setTeamState({users:mu,totalPages:2,totalItems:10,roles:du,permissions:pu}),s.setTeamLoader({key:ws.USERS,value:!1}),null==l||l(mu)},s.loadAllSubTenantsUsers=async e=>{var a,n,i,o,r;const{silentLoading:l,callback:c}=e,u=t.auth.teamState,d=null!=(a=e._limit)?a:u.allUsersQueryParams._limit,g=null!=(n=e._offset)?n:u.allUsersQueryParams._offset,p=null!=(i=e._filter)?i:u.allUsersQueryParams._filter,h=null!=(o=e._sortBy)?o:u.allUsersQueryParams._sortBy,y=null!=(r=e._order)?r:u.allUsersQueryParams._order;s.setTeamLoader({key:ws.USERS,value:!l}),s.setTeamState({allUsersQueryParams:{_limit:d,_offset:g,_filter:p,_sortBy:h,_order:y}}),await En(),s.setTeamState({allUsers:Au,totalPages:2,totalItems:10,roles:du,permissions:pu}),s.setTeamLoader({key:ws.USERS,value:!1}),null==c||c(Au)},s.loadRoles=async t=>{var e;s.setTeamLoader({key:ws.ROLES_AND_PERMISSIONS,value:!0}),await En(),s.setTeamState({roles:du,permissions:pu}),s.setTeamLoader({key:ws.ROLES_AND_PERMISSIONS,value:!0}),null==t||null==(e=t.callback)||e.call(t,{roles:du,permissions:pu})},s.addUser=async e=>{const{callback:a}=e,n=f(e,td),i=t.auth.teamState;s.setTeamState({addUserDialogState:v({},i.addUserDialogState,{loading:!0})}),await En();const o=new Date,r=v({},Su,{groups:[]},n,{id:`${ju()}`,temporaryExpirationDate:n.expirationInSeconds?new Date(o.setSeconds(o.getSeconds()+n.expirationInSeconds)):void 0});null==a||a(r),s.setTeamState({users:[r,...i.users],addUserDialogState:{open:!1,loading:!1}})},s.addUserToSubTenants=async e=>{const{callback:a}=e,n=f(e,ed),i=t.auth.teamState;s.setTeamState({addUserDialogState:v({},i.addUserDialogState,{loading:!0})}),await En();const o=v({},Su,n,{id:`${ju()}`});s.setTeamState({users:[o,...i.users],addUserDialogState:{open:!1,loading:!1}}),null==a||a(null)},s.updateUser=async e=>{var a;const{callback:n}=e,i=f(e,ad),{id:o}=i,r=t.auth.teamState,l=r.users.find((t=>t.id===i.id));s.setTeamLoader({key:ws.UPDATE_USER,value:o||""}),s.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!0})}),s.setTeamState({addUserDialogState:v({},r.addUserDialogState,{loading:!0}),users:r.users.map((t=>t.id===i.id?v({},t,i):t))}),l.roleIds.length>0&&0===(null==(a=i.roleIds)?void 0:a.length)&&(i.roleIds=[""]),await En();const c=v({},l,i);null==n||n(c),s.setTeamState({users:r.users.map((t=>t.id===c.id?v({},t,c,{createdAt:t.createdAt,customData:t.customData,lastLogin:t.lastLogin}):t))}),s.setTeamLoader({key:ws.UPDATE_USER,value:!1})},s.deleteUser=async e=>{const{callback:a}=e,n=f(e,nd),i=t.auth.teamState;s.setTeamState({deleteUserDialogState:v({},i.deleteUserDialogState,{loading:!0})}),await En(),null==a||a(!0),s.setTeamState({users:i.users.filter((t=>t.id!==n.userId)),deleteUserDialogState:{open:!1,loading:!1}})},s.updateUserExpirationTime=async e=>{const{callback:a}=e,n=f(e,sd),i=t.auth.teamState;s.setTeamLoader({key:ws.UPDATE_USER_EXPIRATION_TIME,value:!0});const o=new Date;s.setTeamState({users:i.users.map((t=>t.id===n.userId?v({},t,{temporaryExpirationDate:n.expirationInSeconds?new Date(o.setSeconds(o.getSeconds()+n.expirationInSeconds)):void 0}):t))}),await En(),null==a||a(!0),s.setTeamLoader({key:ws.UPDATE_USER_EXPIRATION_TIME,value:!1})},s.setUserAsPermanent=async e=>{const{callback:a}=e,n=f(e,id),i=t.auth.teamState;s.setTeamLoader({key:ws.UPDATE_USER_EXPIRATION_TIME,value:!0}),s.setTeamState({users:i.users.map((t=>t.id===n.userId?v({},t,{temporaryExpirationDate:void 0}):t))}),await En(),null==a||a(!0),s.setTeamLoader({key:ws.UPDATE_USER_EXPIRATION_TIME,value:!1})},s.deleteUserFromSubTenants=async e=>{const{callback:a}=e,n=f(e,od),i=t.auth.teamState;s.setTeamState({deleteUserDialogState:v({},i.deleteUserDialogState,{loading:!0})}),await En(),null==a||a(!0),s.setTeamState({allUsers:i.allUsers.filter((t=>t.id!==n.userId)),deleteUserDialogState:{open:!1,loading:!1}})},s.resendActivationLink=async t=>{const{callback:e}=t,a=f(t,rd);s.setTeamLoader({key:ws.RESEND_ACTIVATE_LINK,value:a.userId}),await En(),null==e||e(!0),s.setTeamLoader({key:ws.RESEND_ACTIVATE_LINK,value:!1})},s.resendInvitationLink=async t=>{const{callback:e}=t,a=f(t,ld);s.setTeamLoader({key:ws.RESEND_INVITATION_LINK,value:a.email}),await En(),null==e||e(!0),s.setTeamLoader({key:ws.RESEND_INVITATION_LINK,value:!1})},s.resendInvitationEmail=async t=>{const{callback:e}=t,a=f(t,cd);s.setTeamLoader({key:ws.RESEND_INVITATION_LINK,value:a.email}),await En(),null==e||e(!0),s.setTeamLoader({key:ws.RESEND_INVITATION_LINK,value:!1})},s.resendInvitationLinkToAllSubTenants=async t=>{const{callback:e}=t,a=f(t,ud);s.setTeamLoader({key:ws.RESEND_INVITATION_LINK,value:a.email}),await En(),null==e||e(!0),s.setTeamLoader({key:ws.RESEND_INVITATION_LINK,value:!1})},s})(t,e,a),$=((t,e,a)=>{const n=Wl(t,e,a),s=Xc(n,["setTenantsState","resetTenantsState"]);return s.loadTenants=async()=>{s.setTenantsState({loading:!0}),s.setTenantsState({tenants:wu,activeTenant:wu[0],loading:!1})},s})(t,e,a),G={acceptInvitationActions:s,accountSettingsActions:i,unlockAccountActions:o,activateAccountActions:r,allAccountsActions:l,allAccountsDialogActions:c,apiTokensActions:u,applicationsActions:d,customLoginActions:g,entitlementsActions:p,forgotPasswordActions:h,passwordRotationActions:y,groupsActions:S,groupsDialogsActions:m,impersonateActions:b,loginActions:A,mfaActions:w,passkeysActions:T,profileActions:E,provisioningActions:I,resetPhoneNumberActions:O,restrictionsActions:P,rolesActions:k,securityCenterActions:_,securityPolicyActions:R,sessionsActions:U,sessionsPolicyActions:C,signUpActions:L,smsActions:D,socialLoginActions:N,ssoActions:M,stepUpActions:F,teamActions:x,tenantsActions:$},j=e=>{Object.keys(e).forEach((a=>{const n=a;Rn(t.auth[n])?Object.assign(t.auth[n],e[n]):t.auth[n]=e[n]}))};return{authActions:v({setState:j,setAuthState:j,setErrorByRequestName:e=>{let{requestName:a}=e,n=f(e,dd);t.auth.errorByRequest=v({},t.auth.errorByRequest,{[a]:v({},n,{isError:!0})})},resetAuthState:()=>{Cn(t,["auth"],n)},setUser:t=>{j({user:t})}},s,i,r,o,l,c,u,d,g,p,h,y,S,m,b,A,w,T,E,I,O,P,k,_,R,U,C,L,D,N,M,F,x,$),authStateActions:G}})(t,e,a,n),o=((t,e,a)=>{const n=ac(t,e,a);return Xc(n,["setConnectivityState","resetConnectivityState","initData","resetConnectivityState","cleanWebhookTestData","cleanWebhookLogsData","cleanWebhookTestMessage","cleanError","cleanSlackData"])})(t,e,a),[r,l]=Ad(t,e,a),c=((t,e,a)=>{const n=jc(t,e,a),s=Xc(n,["setVendorState","resetVendorState"]);return s.loadVendorPublicInfo=async()=>{try{s.setVendorState({whiteLabelMode:!1}),await En()}catch(t){console.error("failed to getVendorPublicInfo - ",t)}},s.loadVendorPublicConfiguration=s.loadVendorPublicInfo,s})(t,e,a);return{authActions:s,authStateActions:i,connectivityActions:o,subscriptionsActions:r,subscriptionsStateActions:l,vendorActions:c,auditsActions:yd(t,e,a)}},Td=(t,e,a=!1,n,s,i=!1,o="path")=>Ed({name:t.appName,context:t.context,storeHolder:e,previewMode:a,builderMode:i,urlStrategy:o,initialState:{root:v({},t),auth:v({},null==s?void 0:s.auth,n),connectivity:v({},null==s?void 0:s.connectivity),subscriptions:v({},null==s?void 0:s.subscriptions),vendor:v({},null==s?void 0:s.vendor),auditLogs:v({},null==s?void 0:s.auditLogs),audits:v({},null==s?void 0:s.audits)}}),Ed=t=>{var e,a,n,s,i,o,r;const{storeHolder:l}=t;let c=l;if("undefined"==typeof window&&null==l)throw Error("createFronteggStore(initState, storeHolder) failed, storeHolder must not be null in Server-Side rendering");if(c||(c=window),c.store)return c.store;const u=t.name||"default",{context:d,previewMode:g=!1,builderMode:p=!1,urlStrategy:h="path"}=t,y=U.for(u);g||p||y.setContext(d),void 0===d.requestCredentials&&(d.requestCredentials="include");const S=ql(null==(e=t.initialState)?void 0:e.auth),m=Xl(null==(a=t.initialState)?void 0:a.connectivity),b=Fc(null==(n=t.initialState)?void 0:n.subscriptions),A=Gc(null==(s=t.initialState)?void 0:s.vendor),w=qc(null==(i=t.initialState)?void 0:i.auditLogs),T=(E=null==(o=t.initialState)?void 0:o.audits,en(Yc,E));var E;const I=null==(r=t.initialState)?void 0:r.auth;I&&Object.keys(I).forEach((t=>{cn()(S,t,I[t],{merge:!0})}));const O=JSON.parse(JSON.stringify(S)),C=en({root:{appName:u,context:d,urlStrategy:h,previewMode:g},auth:S,connectivity:m,subscriptions:b,vendor:A,auditLogs:w,audits:T});"undefined"!=typeof window&&window.localStorage&&"true"===window.localStorage.DEBUG_FRONTEGG_STORE&&function(t,e){"string"==typeof e&&(e={name:e});const a=e||{},{enabled:n,name:s=""}=a,i=f(a,_);let o;try{o=n&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!o)return;let r=!1;const l=o.connect(v({name:s},i));P(t,(e=>{const a=e.filter((([t,e])=>e[0]!==R)).map((([t,e])=>`${t}:${e.map(String).join(".")}`)).join(", ");if(a)if(r)r=!1;else{const e=Object.assign({},k(t));delete e[R],l.send({type:a,updatedAt:(new Date).toLocaleString()},e)}})),l.subscribe((e=>{var a,n;if("ACTION"===e.type&&e.payload)try{Object.assign(t,JSON.parse(e.payload))}catch(t){console.error("please dispatch a serializable value that JSON.parse() and proxy() support\n",t)}if("DISPATCH"===e.type&&e.state){var s,i;if("JUMP_TO_ACTION"===(null==(s=e.payload)?void 0:s.type)||"JUMP_TO_STATE"===(null==(i=e.payload)?void 0:i.type)){r=!0;const a=JSON.parse(e.state);Object.assign(t,a)}t[R]=e}else if("DISPATCH"===e.type&&"COMMIT"===(null==(a=e.payload)?void 0:a.type))l.init(k(t));else if("DISPATCH"===e.type&&"IMPORT_STATE"===(null==(n=e.payload)?void 0:n.type)){var o,c;const a=null==(o=e.payload.nextLiftedState)?void 0:o.actionsById,n=(null==(c=e.payload.nextLiftedState)?void 0:c.computedStates)||[];r=!0,n.forEach((({state:e},n)=>{const s=a[n]||"No action found";Object.assign(t,e),0===n?l.init(k(t)):l.send(s,k(t))}))}}));l.init(k(t))}(C,{name:`${u} Store`,enabled:!0});const L={},D={};y.setContext(t.context),y.setAppName(u);const N=v({},Xa(u),{fetch:new Gt(u)});if(t.previewMode||t.builderMode){const{authActions:e,authStateActions:a,connectivityActions:n,subscriptionsActions:s,subscriptionsStateActions:i,vendorActions:o,auditsActions:r}=wd(C,N,D,O);L.auth=a,L.connectivity=n,L.subscriptions=i,L.vendor=o,L.auditLogs=r,L.audits={},Object.assign(D,v({},e,n,s,o,r));const l={dispatch:t=>{setTimeout((()=>{const[a,...i]=t.type.split("/"),r=i.join("/");"auth"===a&&"function"==typeof e[r]?e[r](t.payload):"connectivity"===a&&"function"==typeof n[r]?n[r](t.payload):"subscriptions"===a&&"function"==typeof s[r]?s[r](t.payload):"vendor"===a&&"function"==typeof o[r]&&o[r](t.payload)}))},getState:()=>C,subscribe:t=>P(C,t),subscribeStateChanged:t=>P(C,(()=>t(C))),store:C,actions:D,stateActions:L};return t.previewMode&&l.dispatch({type:"auth/requestAuthorize",payload:!0}),c&&(c.store=l),l}{const[t,e]=Jl(C,N,D,O),a=ac(C,N,D),[n,s]=xc(C,N,D),i=jc(C,N,D),o=Jc(C,N,D),r=((t,e)=>{const a=()=>{t.audits.isLoading=!1},n=e=>{var a;t.audits.error=null!=(a=t.audits.error)?a:{},Object.assign(t.audits.error,{[e.name]:e.error})},s=e=>{t.audits.filters=e,t.audits.currentPage=0,t.audits.offset=0,t.audits.isLoading=!0},i=async()=>{const{sortBy:a,sortDirection:s}=t.audits;try{i=await e.audits.getAuditsStats({sortBy:a,sortDirection:s,count:20}),t.audits.error=void 0,t.audits.totalToday=i.totalToday,t.audits.severeThisWeek=i.severeThisWeek}catch(t){const e={name:"stats",error:t};console.error("failed to load stats - ",t),n(e)}var i},o=async()=>{try{a=await e.metadata.getAuditsMetadata(),t.audits.error={},t.audits.headerProps=a.properties,t.audits.themeAudits=a.theme?a.theme.styles:{}}catch(t){const e={name:"metadata",error:t};console.error("failed to load metadata - ",t),n(e)}var a},r=t=>t.reduce(((t,e)=>(t[e.key]=e.value,t)),{}),l=async s=>{const{filters:i,sortBy:o,sortDirection:l,filter:c,offset:u,virtualScroll:d}=t.audits,{appendMode:g=d,onlyOneLoad:p=!0,offset:h=0}=s||{},{rowsData:y}=g?t.audits:{rowsData:[]};try{const n=r(i),{data:s,total:g}=await e.audits.getAudits(v({},d&&{paginationMode:"virtual"},{sortDirection:l,sortBy:o,filter:c},n,{offset:d?y.length+h||y.length+u:h||u,count:20}));(e=>{t.audits.error={},t.audits.rowsData=e.rowsData,t.audits.lastUpdated=new Date,t.audits.total=e.total})({rowsData:[...y,...s],total:g}),p&&a()}catch(t){const e={name:"audits",error:t};console.error("failed to load audits - ",t),n(e)}};return{initData:async()=>{t.audits.isLoading=!0,await Promise.all([i(),o(),l({onlyOneLoad:!1})]),a()},loadAudits:l,removeFilter:async e=>{const{filters:a}=t.audits,n=a.findIndex((t=>t.key===e.key));if(n<0)return;const i=[...a.slice(0,n),...a.slice(n+1)];s(i)},filterData:async e=>{const{filters:a}=t.audits;let n=a.findIndex((t=>t.key===e.key));n<0&&(n=a.length);const i=[...a.slice(0,n),e,...a.slice(n+1)];s(i)},exportCSV:async()=>{const{filters:a,sortBy:n,sortDirection:s,filter:i,headerProps:o=[]}=t.audits,l=r(a);t.audits.isDownloadingCsv=!0;try{await e.audits.exportAudits(v({endpoint:"csv/v2",headerProps:o,sortDirection:s,sortBy:n,filter:i},l,{offset:0,outputFileName:"audits.csv"}))}catch(t){console.error("failed to export audits - ",t)}finally{t.audits.isDownloadingCsv=!1}}}})(C,N);return L.auth=e,L.connectivity=a,L.subscriptions=s,L.vendor=i,L.auditLogs=o,L.audits=r,Object.assign(D,v({},t,a,n,i,o)),{dispatch:e=>{const[s,...o]=e.type.split("/"),r=o.join("/");"auth"===s&&"function"==typeof t[r]?t[r](e.payload):"connectivity"===s&&"function"==typeof a[r]?a[r](e.payload):"subscriptions"===s&&"function"==typeof n[r]?n[r](e.payload):"vendor"===s&&"function"==typeof i[r]&&i[r](e.payload)},getState:()=>C,subscribe:t=>P(C,t),subscribeStateChanged:t=>P(C,(()=>t(C))),store:C,actions:D,stateActions:L}}};let Id,Od,Pd,kd,_d,Rd,Ud,Cd,Ld,Dd,Nd,Md,Fd;!function(t){t.phoneNumber="phoneNumber"}(Id||(Id={})),function(t){t.Name="name",t.PhoneNumber="phoneNumber",t.Address="address",t.JobTitle="jobTitle"}(Od||(Od={})),function(t){t.LoginSessions="loginSessions",t.Mfa="mfa"}(Pd||(Pd={})),function(t){t.Name="name",t.PhoneNumber="phoneNumber"}(kd||(kd={})),function(t){t.CompanyName="companyName",t.Address="address",t.Website="website",t.Timezone="timezone",t.Currency="currency"}(_d||(_d={})),function(t){t.User="user",t.Applications="applications",t.Groups="groups",t.Roles="roles",t.JoinedAt="joinedAt",t.LastSeen="lastSeen",t.ManagedBy="managedBy"}(Rd||(Rd={})),function(t){t.Invoices="invoices"}(Ud||(Ud={})),function(t){t.SessionManagement="sessionManagement",t.GeneralSettings="generalSettings",t.IpRestrictions="ipRestrictions",t.DomainRestrictions="domainRestrictions"}(Cd||(Cd={})),function(t){t.IdleSessionTimeout="idleSessionTimeout",t.ForceReLogin="forceReLogin",t.MaximumConcurrentSessions="maximumConcurrentSessions"}(Ld||(Ld={})),function(t){t.Mfa="mfa",t.UserLockout="userLockout",t.PasswordHistory="passwordHistory"}(Dd||(Dd={})),function(t){t.IpAddressRestrictions="ipAddressRestrictions"}(Nd||(Nd={})),function(t){t.RestrictSignupByEmailDomain="restrictSignupByEmailDomain"}(Md||(Md={})),function(t){t.Settings="settings",t.CustomLogin="customLogin"}(Fd||(Fd={}));const xd={hidden:"hidden",viewOnly:"viewOnly",edit:"edit"},$d={hidden:"hidden",edit:"edit"};function Gd(t,e=0,a=1){return Math.min(Math.max(e,t),a)}function jd(t){if(t.type)return t;if("#"===t.charAt(0))return jd(function(t){t=t.substr(1);const e=new RegExp(`.{1,${t.length>=6?2:1}}`,"g");let a=t.match(e);return a&&1===a[0].length&&(a=a.map((t=>t+t))),a?`rgb${4===a.length?"a":""}(${a.map(((t,e)=>e<3?parseInt(t,16):Math.round(parseInt(t,16)/255*1e3)/1e3)).join(", ")})`:""}(t));const e=t.indexOf("("),a=t.substring(0,e);if(-1===["rgb","rgba","hsl","hsla","color"].indexOf(a))throw new Error("MUI: Unsupported `%s` color.\nThe following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color(). "+t);const n=t.substring(e+1,t.length-1);let s,i;if("color"===a){if(i=n.split(" "),s=i.shift(),4===i.length&&"/"===i[3].charAt(0)&&(i[3]=i[3].substr(1)),-1===["srgb","display-p3","a98-rgb","prophoto-rgb","rec-2020"].indexOf(s))throw new Error("MUI: unsupported `%s` color space.\nThe following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020."+s)}else i=n.split(",");return{type:a,values:i.map((t=>parseFloat(t))),colorSpace:s}}function Bd(t){const{type:e,colorSpace:a}=t;let{values:n}=t;return-1!==e.indexOf("rgb")?n=n.map(((t,e)=>e<3?parseInt(t,10):t)):-1!==e.indexOf("hsl")&&(n[1]=`${n[1]}%`,n[2]=`${n[2]}%`),n=-1!==e.indexOf("color")?`${a} ${n.join(" ")}`:`${n.join(", ")}`,`${e}(${n})`}function Vd(t){if(0===t.indexOf("#"))return t;const{values:e}=jd(t);return`#${e.map(((t,e)=>function(t){const e=t.toString(16);return 1===e.length?`0${e}`:e}(3===e?Math.round(255*t):t))).join("")}`}function Wd(t,e){return t=jd(t),e=Gd(e),"rgb"!==t.type&&"hsl"!==t.type||(t.type+="a"),"color"===t.type?t.values[3]=`/${e}`:t.values[3]=e,Bd(t)}function Hd(t,e){if(t=jd(t),e=Gd(e),-1!==t.type.indexOf("hsl"))t.values[2]*=1-e;else if(-1!==t.type.indexOf("rgb")||-1!==t.type.indexOf("color"))for(let a=0;a<3;a+=1)t.values[a]*=1-e;return Bd(t)}function zd(t,e){if(t=jd(t),e=Gd(e),-1!==t.type.indexOf("hsl"))t.values[2]+=(100-t.values[2])*e;else if(-1!==t.type.indexOf("rgb"))for(let a=0;a<3;a+=1)t.values[a]+=(255-t.values[a])*e;else if(-1!==t.type.indexOf("color"))for(let a=0;a<3;a+=1)t.values[a]+=(1-t.values[a])*e;return Bd(t)}const Kd=t=>{if(t)return{main:t,light:Vd(zd(t,.4)),dark:Vd(Hd(t,.15)),hover:Vd(Hd(t,.15)),active:Vd(Hd(t,.2))}},qd=t=>{if(t)return{main:t,light:zd(t,.7),dark:Hd(t,.2)}},Jd=(t,e)=>{var a,n,s,i,o,r,l,c,u,d,g,p;return null!=t&&t.palette&&"string"==typeof(null==t||null==(a=t.palette)?void 0:a.primary)?v({},e,{palette:{primary:v({},Kd(null==t||null==(n=t.palette)?void 0:n.primary),{contrastText:null!=(s=null==t||null==(i=t.palette)?void 0:i.primaryText)?s:"#000000"}),secondary:v({},Kd(null==t||null==(o=t.palette)?void 0:o.secondary),{contrastText:null!=(r=null==t||null==(l=t.palette)?void 0:l.secondaryText)?r:"#000000"}),danger:v({},Kd(null==t||null==(c=t.palette)?void 0:c.error),{contrastText:"#FFF"}),success:v({},qd(null==t||null==(u=t.palette)?void 0:u.success),{contrastText:"#FFF"}),error:v({},qd(null==t||null==(d=t.palette)?void 0:d.error),{contrastText:"#FFF"}),warning:v({},qd(null==t||null==(g=t.palette)?void 0:g.warning),{contrastText:"#FFF"}),info:v({},qd(null==t||null==(p=t.palette)?void 0:p.info),{contrastText:"#FFF"})}}):{}},Yd={theme:{},themeV2:{},localizations:{},navigation:{usage:{visibility:"hidden",permissions:["fe.usage.read"],featureFlag:"fe-usage-page"},webhooks:{visibility:"hidden",permissions:["fe.connectivity.read.webhooks"]},roles:{visibility:"hidden",permissions:["fe.secure.read.roles"]},users:{visibility:"always",permissions:["fe.secure.read.users"],inviteDialog:{phoneNumberField:"optional"}},personalApiTokens:{visibility:"hidden",permissions:["fe.secure.read.userApiTokens"]},apiTokens:{visibility:"hidden",permissions:["fe.secure.read.tenantApiTokens"]},profile:{visibility:"always"},privacy:{visibility:"always"},account:{visibility:"always",permissions:["fe.secure.read.accountSettings"]},security:{visibility:"always",permissions:["fe.secure.read.securityPolicy"]},sso:{visibility:"hidden",permissions:["fe.secure.read.samlConfiguration"]},provisioning:{visibility:"hidden",permissions:["fe.secure.read.provisioningConfiguration"]},audits:{visibility:"always",permissions:["fe.secure.read.audits"]},subscriptions:{visibility:"hidden",permissions:["fe.subscriptions.*"]},allAccounts:{visibility:"byPermissions",permissions:["fe.account-hierarchy.read.subAccount"]},groups:{visibility:"hidden",permissions:["fe.secure.read.groups"]}}};class Xd{constructor(){this._theme=Yd.theme,this._themeV2=Yd.themeV2,this._navigation=Yd.navigation,this._localizations=Yd.localizations,this._integrations=Yd.integrations}static getInstance(t="default"){return this._instances[t]}static set(t,e="default"){const a=new Xd;return a.set(t),Xd._instances[e]=a,a}get theme(){var t;return null!=(t=this._theme)?t:{}}get themeV2(){var t;return null!=(t=this._themeV2)?t:{}}get navigation(){var t;return null!=(t=this._navigation)?t:{}}get localizations(){var t;return null!=(t=this._localizations)?t:{}}get integrations(){var t;return null!=(t=this._integrations)?t:{}}set(t){try{var e,a,n,s,i,o,r,l,c;this._navigation=tn().all([null!=(e=Yd.navigation)?e:{},null!=(a=null==t?void 0:t.navigation)?a:{}]),this._theme=tn().all([null!=(n=Yd.theme)?n:{},Jd(null==t?void 0:t.theme,Yd.theme)]),this._themeV2=tn().all([null!=(s=Yd.themeV2)?s:{},null!=(i=null==t?void 0:t.themeV2)?i:{}]),this._localizations=tn().all([null!=(o=Yd.localizations)?o:{},null!=(r=null==t?void 0:t.localizations)?r:{}]),this._integrations=tn().all([null!=(l=Yd.integrations)?l:{},null!=(c=null==t?void 0:t.integrations)?c:{}])}catch(t){this._navigation=Yd.navigation,this._theme=Yd.theme,this._themeV2=Yd.themeV2,this._localizations=Yd.localizations,this._integrations=Yd.integrations}}}Xd._instances={};var Qd=function(t){return t.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map((function(t){return t.toLowerCase()})).join("")},Zd=function(t,e){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=document.createElement(e);return Object.keys(a).forEach((function(t){return n.setAttribute(t,a[t])})),t.appendChild(n),n},tg=function(t){return new Promise((function(e,a){var n=4e3,s=setInterval((function(){return null!=t.themeSetter?(clearInterval(s),void e(!0)):n<0?(a("Failed to load Renderer with themeSetter"),void clearInterval(s)):void(n-=50)}),50)}))},eg=function(t){var e=t.toString();if(e){var a=new URL(window.location.href);a.search=e,window.history.pushState(null,"",a.toString())}};const ag="7.72.0";var ng={admin_portal_ip_restrictions:"on",admin_portal_domain_restrictions:"on","new-mfa-pages":"on","show-passkeys-new":"on","groups-admin-box-new":"on","msp-all-accounts-new":"on","temporary-users":"on"},sg=function(t){var e,a=Xd.getInstance(t),n=null==a||null==(e=a.integrations)?void 0:e.gtm;null==n||n.filter((function(t){var e=t.id;return t.enabled&&/^GTM-[a-zA-Z0-9]+$/.test(e)})).forEach((function(t){var e=t.id,a=document.createElement("script");a.innerHTML="\n (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n })(window,document,'script','dataLayer','".concat(e,"');\n "),document.body.appendChild(a)}))},ig=function(){var t=p(y().mark((function t(e,a,n){var s,i,o,r;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=null==(s=e.metadataOverrides)?void 0:s.url){t.next=3;break}return t.abrupt("return",e);case 3:return t.prev=3,t.next=6,On((function(){return a.sendRequest({url:i,method:"GET",credentials:"omit"})}),n);case 6:if(!(o=t.sent)){t.next=10;break}return r=tn()(e,o),t.abrupt("return",r);case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(3),console.error("Failed to get metadata overrides",t.t0);case 15:return t.abrupt("return",e);case 16:case"end":return t.stop()}}),t,null,[[3,12]])})));return function(e,a,n){return t.apply(this,arguments)}}(),og=function(){function a(t,e){var n,s,o,r=this,l=arguments.length>2&&void 0!==arguments[2]&&arguments[2],u=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i(this,a),this.name=void 0,this.iframeRendering=void 0,this.options=void 0,this.loading=!0,this.cdnUrl="https://assets.frontegg.com/admin-box/".concat(ag),this.assetsUrl="https://adminBox.frontegg.com/admin-box/".concat(ag),this.customElementName="",this.adminPortalEl=void 0,this.adminPortalRenderer=void 0,this.loginBoxEl=void 0,this.checkoutDialogEl=void 0,this.checkoutDialogRenderer=void 0,this.adminPortalContainer=void 0,this.loginBoxContainer=void 0,this.checkoutDialogContainer=void 0,this.loginBoxRenderer=void 0,this.store=void 0,this.loadingListeners=[],this.fetchClient=void 0,this.apiClient=void 0,this.updateLocalizations=void 0,this.loadAdminBoxMetadata=p(y().mark((function t(){var e,a,n,s,i;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r.options.metadata){t.next=21;break}return t.prev=1,t.next=4,On((function(){return r.fetchClient.get("/metadata",{entityName:"adminBox"})}),Tn);case 4:return s=t.sent,i=null!=(e=null==s||null==(a=s.rows)||null==(n=a[0])?void 0:n.configuration)?e:{},t.prev=6,t.next=9,ig(i,r.fetchClient,Tn);case 9:r.options.metadata=t.sent,t.next=15;break;case 12:t.prev=12,t.t0=t.catch(6),console.error("failed to get admin portal overridden metadata",t.t0);case 15:t.next=21;break;case 17:t.prev=17,t.t1=t.catch(1),console.error("failed to get admin portal metadata",t.t1),r.dispatchErrorByRequestName(t.t1,Wn.LOAD_ADMIN_BOX_METADATA);case 21:Xd.set(r.options.metadata,r.name);case 22:case"end":return t.stop()}}),t,null,[[1,17],[6,12]])}))),this.requestAuthorize=p(y().mark((function t(){var e,a,n;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=null==(e=r.options.authOptions)||null==(a=e.hostedLoginOptions)?void 0:a.loadUserOnFirstLoad,r.options.builderMode||"nextjs"===r.options.framework||(r.options.hostedLoginBox&&!r.options.customLoginBox?n&&r.store.dispatch({type:"auth/requestHostedLoginAuthorizeV2",payload:{shouldRedirectToLogin:!1,firstTime:!0}}):r.store.dispatch({type:"auth/requestAuthorize",payload:!0}));case 2:case"end":return t.stop()}}),t)}))),this.loadFeatureFlags=p(y().mark((function t(){var e;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!r.options.previewMode&&!r.options.builderMode){t.next=4;break}Zt.set(ng,r.name),t.next=16;break;case 4:return t.prev=4,t.next=7,On((function(){return r.apiClient.featureFlags.loadFeatureFlags()}),Tn);case 7:e=t.sent,r.options.overrideFeatureFlags&&Object.assign(e,r.options.overrideFeatureFlags),Zt.set(e,r.name),t.next=16;break;case 12:t.prev=12,t.t0=t.catch(4),console.error("failed to get admin portal feature flags",t.t0),r.dispatchErrorByRequestName(t.t0,Wn.LOAD_FEATURE_FLAGS);case 16:case"end":return t.stop()}}),t,null,[[4,12]])}))),this.setFeatureFlagsForPreview=function(t){Zt.set(Object.assign({},ng,t),r.name)},this.queryFeatureFlags=function(t){return Zt.getFeatureFlags(t,r.name)},this.updateLocalizationsSetter=function(t){r.updateLocalizations=t},this.getEntitlementsFromStore=function(){var t;return null==(t=r.store.getState().auth.user)?void 0:t.entitlements},this.getUserFromStore=function(){return r.store.getState().auth.user},this.getEntitlementsQueryData=function(t){var e=r.getUserFromStore();return{entitlements:r.getEntitlementsFromStore(),attributes:{custom:t,jwt:e}}},this.renderUsersTable=function(){var t=p(y().mark((function t(e,a,n){var s;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.loadScript("FronteggAdminPortal");case 2:return s=t.sent,t.abrupt("return",s.renderUsersTable(e,{injector:r,options:r.options,container:e,props:a,themeOptions:n.themeOptions}));case 4:case"end":return t.stop()}}),t)})));return function(e,a,n){return t.apply(this,arguments)}}(),this.renderInviteUserDialog=function(){var t=p(y().mark((function t(e,a,n){var s;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.loadScript("FronteggAdminPortal");case 2:return s=t.sent,t.abrupt("return",s.renderInviteUserDialog(e,{injector:r,options:r.options,container:e,props:a,themeOptions:n.themeOptions}));case 4:case"end":return t.stop()}}),t)})));return function(e,a,n){return t.apply(this,arguments)}}(),this.renderChangePasswordForm=function(){var t=p(y().mark((function t(e,a,n){var s;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.loadScript("FronteggAdminPortal");case 2:return s=t.sent,t.abrupt("return",s.renderChangePasswordForm(e,{injector:r,options:r.options,props:a,themeOptions:n.themeOptions}));case 4:case"end":return t.stop()}}),t)})));return function(e,a,n){return t.apply(this,arguments)}}(),this.renderProfilePage=function(){var t=p(y().mark((function t(e,a,n){var s;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.loadScript("FronteggAdminPortal");case 2:return s=t.sent,t.abrupt("return",s.renderProfilePage(e,{injector:r,options:r.options,props:a,themeOptions:n.themeOptions,localizations:n.localizations}));case 4:case"end":return t.stop()}}),t)})));return function(e,a,n){return t.apply(this,arguments)}}(),this.getUsersTableStore=function(){var t=p(y().mark((function t(e){var a;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.loadScript("FronteggAdminPortal");case 2:return a=t.sent,t.abrupt("return",a.useUsersTableStore(e));case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),this.getInviteUserDialogStore=function(){var t=p(y().mark((function t(e){var a;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.loadScript("FronteggAdminPortal");case 2:return a=t.sent,t.abrupt("return",a.useInviteUserDialogStore(e));case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();var d=Qd(e),g="frontegg-app-".concat(d);this.iframeRendering=l,this.name=d,this.options=Object.assign({},t,{contextOptions:Object.assign({requestCredentials:"include"},t.contextOptions)}),this.fetchClient=new Gt(this.name),this.apiClient=Xa(this.name),this.options.cdnUrl&&(this.cdnUrl=this.options.cdnUrl),this.options.assetsUrl&&(this.assetsUrl=this.options.assetsUrl),U.for(this.name).setCdnUrl(this.cdnUrl),U.for(this.name).setAssetsUrl(this.assetsUrl),this.customElementName=g;var h,S,v=this.options.authOptions?Object.assign({},this.options.authOptions,{hostedLoginBox:this.options.hostedLoginBox}):{hostedLoginBox:this.options.hostedLoginBox};if(v.onRedirectTo=t.onRedirectTo,v.disableSilentRefresh=null==(n=this.options.authOptions)?void 0:n.disableSilentRefresh,this.options.store){if(this.store=this.options.store,!u&&this.options.store.getState().root.appName!==e)throw Error("Mismatch in store names")}else this.store=Ed({context:this.options.contextOptions,name:this.name,builderMode:this.options.builderMode,previewMode:this.options.previewMode,storeHolder:this,urlStrategy:this.options.urlStrategy,initialState:{auth:Object.assign({},v,null!=(h=this.options.authOptions)?h:{}),auditLogs:Object.assign({},null!=(S=this.options.auditsOptions)?S:{})}});c.setInstance(d,this);var f=U.for(d);f.setAppName(d),this.setEntitlementsOptions(t.entitlementsOptions),this.setSessionContext({enableSessionPerTenant:null==(s=t.authOptions)?void 0:s.enableSessionPerTenant,skipUserLoading:null==(o=t.authOptions)?void 0:o.skipUserLoading});var m=t.basename;m&&f.setBasename(m)}var n,o,r,u;return l(a,[{key:"setEntitlementsOptions",value:function(t){U.for(this.name).setEntitlementsOptions(Object.assign({},t))}},{key:"setSessionContext",value:function(t){U.for(this.name).setSessionContext(Object.assign({},t))}},{key:"dispatchErrorByRequestName",value:function(t,e){(null==t?void 0:t.statusCode)<500||this.store.dispatch({type:"auth/setErrorByRequestName",payload:{requestName:e,traceId:kn(t)}})}},{key:"initContainers",value:(u=p(y().mark((function t(e){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.adminPortalEl=e.adminPortalEl,this.loginBoxEl=e.loginBoxEl,this.checkoutDialogEl=e.checkoutDialogEl,this.adminPortalContainer=e.adminPortalContainer,this.loginBoxContainer=e.loginBoxContainer,this.checkoutDialogContainer=e.checkoutDialogContainer;try{"nextjs"!==this.options.framework&&document.body.classList.add("frontegg-loading")}catch(t){console.error("Failed to add frontegg-loading to body classList")}return t.next=9,Promise.all([this.loadFeatureFlags(),this.loadAdminBoxMetadata(),this.requestAuthorize()]);case 9:this.options.previewMode||this.options.customLoginBox||(this.loadLoginBox(),sg(this.name)),this.options.lazyLoadAdminPortal||this.loadScript("FronteggAdminPortal");case 11:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"updateMetadata",value:function(t){var e;Xd.set(t,this.name),null!=t&&t.localizations&&(null==(e=this.updateLocalizations)||e.call(this,t.localizations))}},{key:"addOnLoadedListener",value:function(t){this.loading?this.loadingListeners.push(t):t()}},{key:"ready",value:function(t){this.loading?t():this.addOnLoadedListener(t)}},{key:"loginWithRedirect",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.store.dispatch({type:"auth/setState",payload:{isLoading:!0}}),this.store.dispatch({type:"auth/requestHostedLoginAuthorize",payload:t})}},{key:"loginWithRedirectV2",value:function(t){this.store.dispatch({type:"auth/requestHostedLoginAuthorizeV2",payload:t})}},{key:"logout",value:function(t){this.store.dispatch({type:"auth/setState",payload:{isLoading:!0}}),this.store.dispatch({type:"auth/logout",payload:t})}},{key:"loadScript",value:function(a){var n=this;return new Promise((function(i,o){var r=window;if(r[a])i(r[a]);else{var l=document.createElement("script");l.src="".concat(n.cdnUrl,"/").concat({FronteggLoginBox:"login-box/index.js",FronteggAdminPortal:"admin-portal/index.js"}[a]),l.setAttribute("id","".concat(a,"Script")),l.setAttribute("cdn-url",n.cdnUrl),l.onload=function(){r["".concat(a,"Init")]?i(r["".concat(a,"Init")]({FronteggRestApi:t,FronteggTypes:s,FronteggReduxStore:e})):i(r[a])},l.onerror=function(t){console.log("Profile page error",t),o(t)},document.body.append(l)}}))}},{key:"loadLoginBox",value:(r=p(y().mark((function t(){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.loadScript("FronteggLoginBox");case 2:t.sent.render(this.loginBoxEl,{injector:this,options:this.options}),this.loading=!1,this.loadingListeners.forEach((function(t){try{t()}catch(t){console.error("Failed to call loadLoginBoxListener",t)}})),this.loadingListeners=[];case 7:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"showAdminPortal",value:(o=p(y().mark((function t(e){var a,n,s,i,o;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=(null!=e?e:{isMultiApp:!1}).isMultiApp,n=this.queryFeatureFlags(["multi-apps-admin-portal"]),s=d(n,1),i=s[0],U.for(this.name).setRequestSource(Ft.AdminPortal),t.next=5,this.loadScript("FronteggAdminPortal");case 5:o=t.sent,this.adminPortalRenderer=o.render(this.adminPortalEl,{injector:this,options:Object.assign({isMultiApp:i&&a},this.options)});case 7:case"end":return t.stop()}}),t,this)}))),function(t){return o.apply(this,arguments)})},{key:"openHostedAdminPortal",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.options.contextOptions.baseUrl,a="".concat(e,"/oauth/portal");t?window.open(a,"_blank"):window.location.href=a}},{key:"hideAdminPortal",value:function(){try{var t,e=new URLSearchParams(window.location.search);null==(t=this.adminPortalRenderer)||t.unmount(),eg(e),U.for(this.name).setRequestSource(null)}catch(t){console.error("Failed to unmount admin portal",t)}}},{key:"showCheckoutDialog",value:(n=p(y().mark((function t(e){var a;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.loadScript("FronteggAdminPortal");case 2:a=t.sent,this.checkoutDialogRenderer=a.renderCheckoutDialog(this.checkoutDialogEl,Object.assign({injector:this},e,{options:this.options}));case 4:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"hideCheckoutDialog",value:function(){try{var t;null==(t=this.checkoutDialogRenderer)||t.unmount()}catch(t){console.error("Failed to unmount checkout dialog",t)}}},{key:"getFeatureEntitlements",value:function(t,e){var a=this.getEntitlementsQueryData(e),n=a.entitlements,s=a.attributes;return eo(n,t,s)}},{key:"getPermissionEntitlements",value:function(t,e){var a=this.getEntitlementsQueryData(e),n=a.entitlements,s=a.attributes;return to(n,t,s)}},{key:"getEntitlements",value:function(t,e){return"permissionKey"in t?this.getPermissionEntitlements(t.permissionKey,e):this.getFeatureEntitlements(t.featureKey,e)}},{key:"loadEntitlements",value:function(t){this.store.dispatch({type:"auth/loadEntitlements",payload:{callback:t}})}},{key:"stepUp",value:function(t){var e=this.store.getState(),a=(null==e?void 0:e.auth)||{},n=a.hostedLoginBox,s=a.routes.stepUpUrl;n?this.store.dispatch({type:"auth/stepUpHostedLogin",payload:t}):ps(s,e.auth.onRedirectTo,null==t?void 0:t.maxAge)}},{key:"isSteppedUp",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=((null==(t=this.store.getState())?void 0:t.auth)||{}).user;return ds(a,e)}},{key:"switchTenant",value:function(t){this.store.dispatch({type:"auth/switchTenant",payload:t})}},{key:"close",value:function(){this.hideAdminPortal(),this.hideCheckoutDialog()}}]),a}(),rg=function(){function t(){i(this,t)}return l(t,null,[{key:"setAuthentication",value:function(t,e,a){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"default",s=c.getInstance(n),i=U.for(n);t&&e?(i.setAccessToken(e),i.setUser(Object.assign({},a,{accessToken:e})),s.store.actions.setAuthState({isLoading:!1,isAuthenticated:t,user:a}),s.store.actions.loadTenants()):(i.setAccessToken(null),i.setUser(null),s.store.actions.setAuthState({isLoading:!1,isAuthenticated:!1,user:null}))}}]),t}(),lg=function(){function t(){i(this,t)}return l(t,null,[{key:"show",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";c.getInstance(t).showAdminPortal()}},{key:"showMultiApp",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";c.getInstance(t).showAdminPortal({isMultiApp:!0})}},{key:"openHosted",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";c.getInstance(e).openHostedAdminPortal(t)}},{key:"hide",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";c.getInstance(t).hideAdminPortal()}}]),t}(),cg=function(){function t(){i(this,t)}return l(t,null,[{key:"show",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";c.getInstance(e).showCheckoutDialog(t)}},{key:"hide",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";c.getInstance(t).hideCheckoutDialog()}}]),t}(),ug=function(t){var e;return null!=(e=window.FronteggAdminPortal.adminPortalStaticThemesDefaults[t])?e:void 0},dg=function(){function t(e,a,n,s){var o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];i(this,t),this.app=void 0,this.options=void 0,this.store=void 0,this.setRoute=function(){},this.themeSetter=void 0,this.themeOptions={};var r={baseUrl:"preview"};if(n){if(this.store=n,!o&&n.getState().root.appName!==e)throw Error("Mismatch in store names")}else this.store=Td({context:r,appName:e},this,!0,void 0,void 0,!0);this.options=Object.assign({themeOptions:a,iframeRendering:!0,metadata:{},previewMode:!0,builderMode:!0,store:this.store,contextOptions:r},s),this.app=new og(this.options,e,!0),Xd.set({},e)}var e;return l(t,[{key:"render",value:(e=p(y().mark((function t(e){var a,n,s,i,o=this;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(a=e.querySelector("#root"))||((a=e.ownerDocument.createElement("div")).setAttribute("id","root"),e.appendChild(a)),this.app.adminPortalContainer=e,this.app.adminPortalEl=a,n=function(t){o.themeSetter=t},s=function(t){o.setRoute=t},t.next=8,this.app.loadScript("FronteggAdminPortal");case 8:return i=t.sent,this.app.adminPortalRenderer=i.renderPage(a,{options:this.options,injector:this.app,setThemeSetter:n,setStaticRouteSetter:s}),this.app.loading=!1,t.next=13,tg(this);case 13:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"setStaticRoute",value:function(t){var e;null==(e=this.setRoute)||e.call(this,t)}},{key:"unmount",value:function(){try{var t;null==(t=this.app.adminPortalRenderer)||t.unmount()}catch(t){console.error("Failed to unmount admin Portal renderer",t)}}},{key:"setTheme",value:function(t){var e;this.themeOptions=t,this.themeSetter||console.warn("this.themeSetter is not defined yet"),null==(e=this.themeSetter)||e.call(this,this.themeOptions)}}]),t}(),gg="modern",pg=function(t){var e,a=window.FronteggAdminPortal.themes;return null!=(e=a[t])?e:a[gg]},hg=function(){function t(e,a,n,s){var o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];i(this,t),this.app=void 0,this.options=void 0,this.store=void 0,this.themeSetter=void 0,this.setRoute=function(){},this.themeOptions={};var r={baseUrl:"preview"};if(n){if(this.store=n,!o&&n.getState().root.appName!==e)throw Error("Mismatch in store names")}else this.store=Td({context:r,appName:e},this,!0,void 0,void 0,!0);this.options=Object.assign({themeOptions:a,iframeRendering:!0,metadata:{},previewMode:!0,builderMode:!0,store:this.store,contextOptions:r,onRedirectTo:function(){console.debug("path")}},s),this.app=new og(this.options,e,!0,o),Xd.set({},e)}var e;return l(t,[{key:"render",value:(e=p(y().mark((function t(e){var a,n,s,i,o=this;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(a=e.querySelector("#root"))||((a=e.ownerDocument.createElement("div")).setAttribute("id","root"),e.appendChild(a)),this.app.loginBoxContainer=e,this.app.loginBoxEl=a,n=function(t){o.themeSetter=t},s=function(t){o.setRoute=t},t.next=8,this.app.loadScript("FronteggLoginBox");case 8:return i=t.sent,this.app.loginBoxRenderer=i.renderPage(a,{options:this.options,injector:this.app,setThemeSetter:n,setStaticRouteSetter:s,staticRoute:"/account/login"}),t.next=12,tg(this);case 12:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"unmount",value:function(){try{var t;null==(t=this.app.loginBoxRenderer)||t.unmount()}catch(t){console.error("Failed to unmount login box renderer",t)}}},{key:"setTheme",value:function(t){var e;this.themeOptions=t,this.themeSetter||console.warn("this.themeSetter is not defined yet"),null==(e=this.themeSetter)||e.call(this,this.themeOptions)}},{key:"setStaticRoute",value:function(t){var e;this.setRoute||console.warn("this.setRoute is not defined yet"),null==(e=this.setRoute)||e.call(this,t)}},{key:"setStore",value:function(t){this.store.dispatch({type:"auth/setState",payload:t})}}]),t}();function yg(t,e){return yg=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},yg(t,e)}function Sg(t){return Sg=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Sg(t)}function vg(t,e,a){return vg=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,a){var n=[null];n.push.apply(n,e);var s=new(Function.bind.apply(t,n));return a&&yg(s,a.prototype),s},vg.apply(null,arguments)}function fg(t){var e="function"==typeof Map?new Map:void 0;return fg=function(t){if(null===t||(a=t,-1===Function.toString.call(a).indexOf("[native code]")))return t;var a;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return vg(t,arguments,Sg(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),yg(n,t)},fg(t)}function mg(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var a,n=Sg(t);if(e){var s=Sg(this).constructor;a=Reflect.construct(n,arguments,s)}else a=n.apply(this,arguments);return function(t,e){if(e&&("object"===o(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,a)}}var bg=function(t){var e=new og(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default");if("undefined"!=typeof document){var a;if(!t.contextOptions.baseUrl){var n=new Error('Edit <FronteggProvider/> options { ContextOptions: { baseUrl: "" } } in order to connect your application');throw document.body.innerHTML="",alert(n.message),n}if(!customElements.get("frontegg-app")){var s=function(e){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&yg(t,e)}(n,e);var a=mg(n);function n(){var t;i(this,n);for(var e=arguments.length,s=new Array(e),o=0;o<e;o++)s[o]=arguments[o];return(t=a.call.apply(a,[this].concat(s))).app=null,t}return l(n,[{key:"connectedCallback",value:function(){this.updateContent()}},{key:"attributeChangedCallback",value:function(t,e,a){if("app-name"===t){if(null===e)return;if(e===a)return;this.innerHTML="",null===a?this.remove():this.updateContent()}console.debug("attributeChangedCallback",t,e,a)}},{key:"updateContent",value:function(){var e,a=null!=(e=this.getAttribute("app-name"))?e:"default",n=c.getInstance(a);if(null===n)throw Error("FronteggApp not found for appName: '".concat(a,"'"));this.setAttribute("id","frontegg-app-".concat(n.name));var s=Zd(this,"div",{id:"frontegg-admin-portal-container-".concat(n.name)}),i=Zd(this,"div",{id:"frontegg-login-box-container-".concat(n.name)}),o=Zd(this,"div",{id:"frontegg-checkout-dialog-container-".concat(n.name)}),r=s.attachShadow({mode:"open"}),l=t.iframeRendering?i:i.attachShadow({mode:"open"}),u=o.attachShadow({mode:"open"}),d=Zd(r,"div",{id:"frontegg-admin-portal-".concat(n.name),class:"frontegg-root-content"}),g=Zd(l,"div",{id:"frontegg-login-box-".concat(n.name),class:"frontegg-root-content"}),p=Zd(u,"div",{id:"frontegg-checkout-dialog-".concat(n.name),class:"frontegg-root-content"});n.initContainers({adminPortalEl:d,loginBoxEl:g,adminPortalContainer:s,loginBoxContainer:i,checkoutDialogContainer:o,checkoutDialogEl:p})}}],[{key:"observedAttributes",get:function(){return["app-name"]}}]),n}(fg(HTMLElement));customElements.define("frontegg-app",s)}null==(a=document.querySelector('frontegg-app[app-name="'.concat(e.name,'"]')))||a.remove();var o=document.createElement("frontegg-app");o.setAttribute("app-name",e.name),document.body.appendChild(o)}return e}})(),n})()));