@frontegg/js 7.0.0-alpha.3 → 7.0.0-alpha.4

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(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Frontegg=t():e.Frontegg=t()}(window,(()=>(()=>{var e={6987:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createConditionEvaluator=void 0;const a=n(3651),o=n(9082);t.createConditionEvaluator=function(e){const t=(0,o.useSanitizer)(e.condition.op);if(!t)return()=>!1;const{isSanitized:n,sanitizedValue:i}=t(e.condition.value);if(!n||void 0===i)return()=>!1;const s=(0,a.useOperation)(e.condition.op,i);return t=>{const n=t[e.condition.attribute];if(void 0===n||!s)return!1;const{isValid:a}=s(n);return e.condition.negate?!a:a}}},2898:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(6987),t),o(n(7371),t)},7371:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},3840:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateFeatureFlag=void 0;const a=n(2380);t.evaluateFeatureFlag=function(e,t){if(!e.on)return{treatment:e.offTreatment};const n=function(e,t){var n;return null===(n=e.rules)||void 0===n?void 0:n.find((e=>(0,a.createRuleEvaluator)({rule:e})(t)===a.RuleEvaluationResultEnum.Treatable))}(e,t);return n?{treatment:n.treatment}:{treatment:e.defaultTreatment}}},6095:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(3840),t)},9314:(e,t,n)=>{"use strict";t.wJ=t.tE=void 0;n(6095),n(521),n(2380),n(2379);var a=n(5535);Object.defineProperty(t,"tE",{enumerable:!0,get:function(){return a.evaluateIsEntitledToFeature}}),Object.defineProperty(t,"wJ",{enumerable:!0,get:function(){return a.evaluateIsEntitledToPermissions}})},195:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanOperationsMapper=void 0;const i=n(2379),s=n(6610);o(n(6610),t),o(n(7226),t),t.BooleanOperationsMapper={[i.OperationEnum.Is]:e=>(0,s.useIsOperation)(e)}},6610:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useIsOperation=void 0,t.useIsOperation=function(e){return t=>({isValid:t===e.boolean})}},7226:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSanitizersMapper=t.singleBooleanSanitizer=void 0;const a=n(2379);t.singleBooleanSanitizer=e=>{const t=void 0!==e.boolean&&(e=>"boolean"==typeof e)(e.boolean)?{boolean:e.boolean}:void 0;return{isSanitized:!!t,sanitizedValue:t}},t.BooleanSanitizersMapper={[a.OperationEnum.Is]:t.singleBooleanSanitizer}},3651:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useOperation=void 0;const a=n(5943),o=n(1610),i=n(9004),s=n(195),r={...a.StringOperationsMapper,...o.NumericOperationsMapper,...i.DateOperationsMapper,...s.BooleanOperationsMapper};t.useOperation=function(e,t){const n=r[e];return n?n(t):void 0}},9082:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useSanitizer=void 0;const a=n(195),o=n(2903),i=n(6886),s=n(1610),r={...o.StringSanitizersMapper,...s.NumericSanitizersMapper,...i.DateSanitizersMapper,...a.BooleanSanitizersMapper};t.useSanitizer=function(e){return r[e]}},9004:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.DateOperationsMapper=void 0;const i=n(2379),s=n(4569);o(n(4569),t),o(n(5931),t),t.DateOperationsMapper={[i.OperationEnum.On]:e=>(0,s.useDateOnOperation)(e),[i.OperationEnum.OnOrAfter]:e=>(0,s.useDateOnOrAfterOperation)(e),[i.OperationEnum.OnOrBefore]:e=>(0,s.useDateOnOrBeforeOperation)(e),[i.OperationEnum.BetweenDate]:e=>(0,s.useDateBetweenOperation)(e)}},4569:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useDateBetweenOperation=t.useDateOnOrBeforeOperation=t.useDateOnOrAfterOperation=t.useDateOnOperation=void 0,t.useDateOnOperation=function(e){return t=>({isValid:t.getTime()===e.date.getTime()})},t.useDateOnOrAfterOperation=function(e){return t=>({isValid:t.getTime()>=e.date.getTime()})},t.useDateOnOrBeforeOperation=function(e){return t=>({isValid:t.getTime()<=e.date.getTime()})},t.useDateBetweenOperation=function(e){return t=>({isValid:t.getTime()>=e.start.getTime()&&t.getTime()<=e.end.getTime()})}},6886:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateSanitizersMapper=t.sanitizeDateRange=t.sanitizeSingleDate=t.isValidDate=t.sanitizeDateValue=void 0;const a=n(2379);t.sanitizeDateValue=e=>new Date(e),t.isValidDate=e=>e instanceof Date&&!isNaN(e),t.sanitizeSingleDate=e=>{const n=e.date?(0,t.sanitizeDateValue)(e.date):void 0,a=n&&(0,t.isValidDate)(n)?{date:n}:void 0;return{isSanitized:!!a,sanitizedValue:a}},t.sanitizeDateRange=e=>{const n=e.start?(0,t.sanitizeDateValue)(e.start):void 0,a=e.end?(0,t.sanitizeDateValue)(e.end):void 0,o=n&&a&&(0,t.isValidDate)(n)&&(0,t.isValidDate)(a)?{start:n,end:a}:void 0;return{isSanitized:!!o,sanitizedValue:o}},t.DateSanitizersMapper={[a.OperationEnum.On]:t.sanitizeSingleDate,[a.OperationEnum.OnOrAfter]:t.sanitizeSingleDate,[a.OperationEnum.OnOrBefore]:t.sanitizeSingleDate,[a.OperationEnum.BetweenDate]:t.sanitizeDateRange}},5931:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},1610:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.NumericOperationsMapper=void 0;const i=n(2379),s=n(9217);t.NumericOperationsMapper={[i.OperationEnum.Equal]:e=>(0,s.useEqualsOperation)(e),[i.OperationEnum.GreaterThan]:e=>(0,s.useGreaterThanOperation)(e),[i.OperationEnum.GreaterThanEqual]:e=>(0,s.useGreaterThanEqualOperation)(e),[i.OperationEnum.LesserThan]:e=>(0,s.useLesserThanOperation)(e),[i.OperationEnum.LesserThanEqual]:e=>(0,s.useLesserThanEqualOperation)(e),[i.OperationEnum.BetweenNumeric]:e=>(0,s.useBetweenNumericOperation)(e)},o(n(9217),t),o(n(9326),t),o(n(1764),t)},9217:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useBetweenNumericOperation=t.useLesserThanEqualOperation=t.useLesserThanOperation=t.useGreaterThanEqualOperation=t.useGreaterThanOperation=t.useEqualsOperation=void 0,t.useEqualsOperation=function(e){return t=>({isValid:t===e.number})},t.useGreaterThanOperation=function(e){return t=>({isValid:t>e.number})},t.useGreaterThanEqualOperation=function(e){return t=>({isValid:t>=e.number})},t.useLesserThanOperation=function(e){return t=>({isValid:t<e.number})},t.useLesserThanEqualOperation=function(e){return t=>({isValid:t<=e.number})},t.useBetweenNumericOperation=function(e){return t=>({isValid:t>=e.start&&t<=e.end})}},9326:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NumericSanitizersMapper=t.sanitizeNumericRange=t.sanitizeSingleNumber=void 0;const a=n(2379),o=e=>"number"==typeof e;t.sanitizeSingleNumber=e=>{const t=void 0!==e.number&&o(e.number)?{number:e.number}:void 0;return{isSanitized:!!t,sanitizedValue:t}},t.sanitizeNumericRange=e=>{const t=void 0!==e.start&&void 0!==e.end&&o(e.start)&&o(e.end)?{start:e.start,end:e.end}:void 0;return{isSanitized:!!t,sanitizedValue:t}},t.NumericSanitizersMapper={[a.OperationEnum.Equal]:t.sanitizeSingleNumber,[a.OperationEnum.GreaterThan]:t.sanitizeSingleNumber,[a.OperationEnum.GreaterThanEqual]:t.sanitizeSingleNumber,[a.OperationEnum.LesserThan]:t.sanitizeSingleNumber,[a.OperationEnum.LesserThanEqual]:t.sanitizeSingleNumber,[a.OperationEnum.BetweenNumeric]:t.sanitizeNumericRange}},1764:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},5943:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.StringOperationsMapper=void 0;const i=n(2379),s=n(2431);o(n(2431),t),o(n(2097),t),t.StringOperationsMapper={[i.OperationEnum.StartsWith]:e=>(0,s.useStartsWithOperation)(e),[i.OperationEnum.EndsWith]:e=>(0,s.useEndsWithOperation)(e),[i.OperationEnum.Contains]:e=>(0,s.useContainsOperation)(e),[i.OperationEnum.InList]:e=>(0,s.useInListOperation)(e),[i.OperationEnum.Matches]:e=>(0,s.useMatchesOperation)(e)}},2431:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useMatchesOperation=t.useInListOperation=t.useContainsOperation=t.useEndsWithOperation=t.useStartsWithOperation=void 0,t.useStartsWithOperation=function(e){return t=>({isValid:e.list.some((e=>t.startsWith(e)))})},t.useEndsWithOperation=function(e){return t=>({isValid:e.list.some((e=>t.endsWith(e)))})},t.useContainsOperation=function(e){return t=>({isValid:e.list.some((e=>t.includes(e)))})},t.useInListOperation=function(e){return t=>({isValid:e.list.includes(t)})},t.useMatchesOperation=function(e){return t=>{let n;try{n=new RegExp(e.string)}catch(e){return{isValid:!1}}return{isValid:n.test(t)}}}},2903:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringSanitizersMapper=t.sanitizeListString=t.sanitizeSingleString=void 0;const a=n(2379),o=e=>"string"==typeof e;t.sanitizeSingleString=e=>{const t=void 0!==e.string&&o(e.string)?{string:e.string}:void 0;return{isSanitized:!!t,sanitizedValue:t}},t.sanitizeListString=e=>{const t=void 0!==e.list&&e.list.every((e=>o(e)))?{list:e.list}:void 0;return{isSanitized:!!t,sanitizedValue:t}},t.StringSanitizersMapper={[a.OperationEnum.Matches]:t.sanitizeSingleString,[a.OperationEnum.Contains]:t.sanitizeListString,[a.OperationEnum.StartsWith]:t.sanitizeListString,[a.OperationEnum.EndsWith]:t.sanitizeListString,[a.OperationEnum.InList]:t.sanitizeListString}},2097:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2379:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(3982),t)},3982:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.OperationEnum=void 0,(n=t.OperationEnum||(t.OperationEnum={})).InList="in_list",n.StartsWith="starts_with",n.EndsWith="ends_with",n.Contains="contains",n.Matches="matches",n.Equal="equal",n.GreaterThan="greater_than",n.GreaterThanEqual="greater_than_equal",n.LesserThan="lower_than",n.LesserThanEqual="lower_than_equal",n.BetweenNumeric="between_numeric",n.Is="is",n.On="on",n.BetweenDate="between_date",n.OnOrAfter="on_or_after",n.OnOrBefore="on_or_before"},521:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(3603),t)},3603:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.evaluatePlan=void 0;const a=n(2380);t.evaluatePlan=function(e,t){const n=function(e,t){var n;return null===(n=e.rules)||void 0===n?void 0:n.find((e=>(0,a.createRuleEvaluator)({rule:e})(t)===a.RuleEvaluationResultEnum.Treatable))}(e,t);return n?{treatment:n.treatment}:{treatment:e.defaultTreatment}}},2380:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(2930),t),o(n(1304),t)},1304:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createRuleEvaluator=void 0;const a=n(2930),o=n(2898);t.createRuleEvaluator=function(e){return t=>e.rule.conditions.every((e=>(0,o.createConditionEvaluator)({condition:e})(t)))?a.RuleEvaluationResultEnum.Treatable:a.RuleEvaluationResultEnum.Insufficient}},2930:(e,t)=>{"use strict";var n,a;Object.defineProperty(t,"__esModule",{value:!0}),t.RuleEvaluationResultEnum=t.TreatmentEnum=t.ConditionLogicEnum=void 0,(t.ConditionLogicEnum||(t.ConditionLogicEnum={})).And="and",(a=t.TreatmentEnum||(t.TreatmentEnum={})).True="true",a.False="false",(n=t.RuleEvaluationResultEnum||(t.RuleEvaluationResultEnum={})).Treatable="treatable",n.Insufficient="insufficient"},5535:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(3779),t),o(n(1038),t),o(n(5113),t),o(n(4848),t)},5640:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.directEntitlementEvalutor=void 0;const a=n(5113);t.directEntitlementEvalutor=function(e,t,n={}){const o=t.features[e];let i=!1;return o&&null!==o.expireTime&&(i=o.expireTime!==a.NO_EXPIRATION_TIME&&o.expireTime<Date.now(),!i)?{isEntitled:!0}:{isEntitled:!1,justification:i?a.NotEntitledJustification.BUNDLE_EXPIRED:a.NotEntitledJustification.MISSING_FEATURE}}},9838:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.featureFlagEvaluator=void 0;const a=n(5113),o=n(6095),i=n(4668),s=n(2380);t.featureFlagEvaluator=function(e,t,n={}){const r=t.features[e];if(r&&r.featureFlag){const e=(0,i.prepareAttributes)(n),{treatment:t}=(0,o.evaluateFeatureFlag)(r.featureFlag,e);if(t===s.TreatmentEnum.True)return{isEntitled:!0}}return{isEntitled:!1,justification:a.NotEntitledJustification.MISSING_FEATURE}}},4529:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getIsEntitledEvaluators=void 0;const a=n(5640),o=n(9838),i=n(3751);t.getIsEntitledEvaluators=function(){return[a.directEntitlementEvalutor,o.featureFlagEvaluator,i.planTargetingRulesEvalutor]}},3751:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.planTargetingRulesEvalutor=void 0;const a=n(5113),o=n(4668),i=n(2380),s=n(521);t.planTargetingRulesEvalutor=function(e,t,n={}){const r=t.features[e];if(r&&r.planIds&&r.planIds.length>0){const e=(0,o.prepareAttributes)(n),a=t.plans;for(const t of r.planIds){const n=a[t];if(n){const{treatment:t}=(0,s.evaluatePlan)(n,e);if(t===i.TreatmentEnum.True)return{isEntitled:!0}}}}return{isEntitled:!1,justification:a.NotEntitledJustification.MISSING_FEATURE}}},3779:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(7850),t)},7850:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateIsEntitledToFeature=void 0;const a=n(5113),o=n(4848),i=n(4529);t.evaluateIsEntitledToFeature=function(e,t,n={}){if(!t)return{isEntitled:!1,justification:a.NotEntitledJustification.MISSING_FEATURE};const s=[];for(const a of(0,i.getIsEntitledEvaluators)())if(s.push(a(e,t,n)),!(0,o.shouldContinue)(s))break;return(0,o.getResult)(s)}},1038:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(519),t)},519:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateIsEntitledToPermissions=void 0;const a=n(7850),o=n(5113),i=n(4848),s=n(4852);t.evaluateIsEntitledToPermissions=function(e,t,n){if(!t)return{isEntitled:!1,justification:o.NotEntitledJustification.MISSING_PERMISSION};if(!(0,s.checkPermission)(t.permissions,e))return{isEntitled:!1,justification:o.NotEntitledJustification.MISSING_PERMISSION};const r=function(e,t){return Object.keys(t.features).filter((n=>t.features[n].linkedPermissions.includes(e)))}(e,t);if(!r.length)return{isEntitled:!0};const l=[];for(const e of r)if(l.push((0,a.evaluateIsEntitledToFeature)(e,t,n)),!(0,i.shouldContinue)(l))break;return(0,i.getResult)(l)}},5113:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.NO_EXPIRATION_TIME=t.NotEntitledJustification=void 0,(n=t.NotEntitledJustification||(t.NotEntitledJustification={})).MISSING_FEATURE="MISSING_FEATURE",n.MISSING_PERMISSION="MISSING_PERMISSION",n.BUNDLE_EXPIRED="BUNDLE_EXPIRED",t.NO_EXPIRATION_TIME=-1},4668:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.modifyObjectKeysWithPrefix=t.defaultFronteggAttributesMapper=t.prepareAttributes=void 0;const a=n(193);function o(e){return{email:e.email,emailVerified:e.email_verified,tenantId:e.tenantId,userId:e.id}}function i(e,t){return Object.keys(e).reduce(((n,a)=>(n[`${t}${a}`]=e[a],n)),{})}t.prepareAttributes=function(e={},t){const{custom:n={},jwt:s={}}=e,r=(0,a.flatten)(s);return{...n,...i(t?t(s):o(s),"frontegg."),...i(r,"jwt.")}},t.defaultFronteggAttributesMapper=o,t.modifyObjectKeysWithPrefix=i},1882:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shouldContinue=t.getResult=void 0;const a=n(5113);t.getResult=function(e){let t=!1;for(const n of e){if(n.isEntitled)return n;n.justification===a.NotEntitledJustification.BUNDLE_EXPIRED&&(t=!0)}return{isEntitled:!1,justification:t?a.NotEntitledJustification.BUNDLE_EXPIRED:a.NotEntitledJustification.MISSING_FEATURE}},t.shouldContinue=function(e){return e.every((({isEntitled:e})=>!e))}},193:(e,t)=>{"use strict";function n(e){return e}Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0,t.flatten=function(e,t){const a=(null==(t=t||{})?void 0:t.delimiter)||".",o=null==t?void 0:t.maxDepth,i=(null==t?void 0:t.transformKey)||n,s={};return function e(n,r,l){l=l||1,Object.keys(n).forEach((function(c){const u=n[c],d=(null==t?void 0:t.safe)&&Array.isArray(u),g=Object.prototype.toString.call(u),p=(y=u)&&y.constructor&&"function"==typeof y.constructor.isBuffer&&y.constructor.isBuffer(y);var y;const f="[object Object]"===g||"[object Array]"===g,S=r?r+a+i(c):i(c);if(!d&&!p&&f&&Object.keys(u).length&&(!(null==t?void 0:t.maxDepth)||o&&l<o))return e(u,S,l+1);s[S]=u}))}(e),s}},4848:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(4852),t),o(n(4668),t),o(n(1882),t)},4852:(e,t)=>{"use strict";function n(e){return new RegExp("^"+e.replace(/\./g,"\\.").replace(/\*/g,".*")+"$","gs")}Object.defineProperty(t,"__esModule",{value:!0}),t.createPermissionCheckRegex=t.checkPermission=void 0,t.checkPermission=function(e,t){return Object.keys(e).some((e=>n(e).test(t)))},t.createPermissionCheckRegex=n},9714:e=>{"use strict";var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===n}(e)}(e)},n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function a(e,t){return!1!==t.clone&&t.isMergeableObject(e)?r((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function o(e,t,n){return e.concat(t).map((function(e){return a(e,n)}))}function i(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return e.propertyIsEnumerable(t)})):[]}(e))}function s(e,t){try{return t in e}catch(e){return!1}}function r(e,n,l){(l=l||{}).arrayMerge=l.arrayMerge||o,l.isMergeableObject=l.isMergeableObject||t,l.cloneUnlessOtherwiseSpecified=a;var c=Array.isArray(n);return c===Array.isArray(e)?c?l.arrayMerge(e,n,l):function(e,t,n){var o={};return n.isMergeableObject(e)&&i(e).forEach((function(t){o[t]=a(e[t],n)})),i(t).forEach((function(i){(function(e,t){return s(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,i)||(s(e,i)&&n.isMergeableObject(t[i])?o[i]=function(e,t){if(!t.customMerge)return r;var n=t.customMerge(e);return"function"==typeof n?n:r}(i,n)(e[i],t[i],n):o[i]=a(t[i],n))})),o}(e,n,l):a(n,l)}r.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,n){return r(e,n,t)}),{})};var l=r;e.exports=l},9378:e=>{"use strict";e.exports=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var a,o,i;if(Array.isArray(t)){if((a=t.length)!=n.length)return!1;for(o=a;0!=o--;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((a=(i=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(o=a;0!=o--;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=a;0!=o--;){var s=i[o];if(!e(t[s],n[s]))return!1}return!0}return t!=t&&n!=n}},5690:(e,t,n)=>{"use strict";var a=n(8558);function o(e){return!0===a(e)&&"[object Object]"===Object.prototype.toString.call(e)}e.exports=function(e){var t,n;return!1!==o(e)&&"function"==typeof(t=e.constructor)&&!1!==o(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf")}},50:e=>{"use strict";e.exports=function(e){return"object"==typeof e?null===e:"function"!=typeof e}},8558:e=>{"use strict";e.exports=function(e){return null!=e&&"object"==typeof e&&!1===Array.isArray(e)}},262:(e,t,n)=>{"use strict";const{deleteProperty:a}=Reflect,o=n(50),i=n(5690),s=e=>"object"==typeof e&&null!==e||"function"==typeof e,r=e=>{if(!o(e))throw new TypeError("Object keys must be strings or symbols");if((e=>"__proto__"===e||"constructor"===e||"prototype"===e)(e))throw new Error(`Cannot set unsafe key: "${e}"`)},l=(e,t)=>t&&"function"==typeof t.split?t.split(e):"symbol"==typeof e?[e]:Array.isArray(e)?e:((e,t,n)=>{const a=(e=>Array.isArray(e)?e.flat().map(String).join(","):e)(t?((e,t)=>{if("string"!=typeof e||!t)return e;let n=e+";";return void 0!==t.arrays&&(n+=`arrays=${t.arrays};`),void 0!==t.separator&&(n+=`separator=${t.separator};`),void 0!==t.split&&(n+=`split=${t.split};`),void 0!==t.merge&&(n+=`merge=${t.merge};`),void 0!==t.preservePaths&&(n+=`preservePaths=${t.preservePaths};`),n})(e,t):e);r(a);const o=u.cache.get(a)||n();return u.cache.set(a,o),o})(e,t,(()=>((e,t={})=>{const n=t.separator||".",a="/"!==n&&t.preservePaths;if("string"==typeof e&&!1!==a&&/\//.test(e))return[e];const o=[];let i="";const s=e=>{let t;""!==e.trim()&&Number.isInteger(t=Number(e))?o.push(t):o.push(e)};for(let t=0;t<e.length;t++){const a=e[t];"\\"!==a?a!==n?i+=a:(s(i),i=""):i+=e[++t]}return i&&s(i),o})(e,t))),c=(e,t,n,o)=>{if(r(t),void 0===n)a(e,t);else if(o&&o.merge){const a="function"===o.merge?o.merge:Object.assign;a&&i(e[t])&&i(n)?e[t]=a(e[t],n):e[t]=n}else e[t]=n;return e},u=(e,t,n,a)=>{if(!t||!s(e))return e;const o=l(t,a);let i=e;for(let e=0;e<o.length;e++){const t=o[e],l=o[e+1];if(r(t),void 0===l){c(i,t,n,a);break}"number"!=typeof l||Array.isArray(i[t])?(s(i[t])||(i[t]={}),i=i[t]):i=i[t]=[]}return e};u.split=l,u.cache=new Map,u.clear=()=>{u.cache=new Map},e.exports=u},7609:(e,t,n)=>{var a=n(7425).default;function o(){"use strict";e.exports=o=function(){return t},e.exports.__esModule=!0,e.exports.default=e.exports;var t={},n=Object.prototype,i=n.hasOwnProperty,s=Object.defineProperty||function(e,t,n){e[t]=n.value},r="function"==typeof Symbol?Symbol:{},l=r.iterator||"@@iterator",c=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";function d(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{d({},"")}catch(e){d=function(e,t,n){return e[t]=n}}function g(e,t,n,a){var o=t&&t.prototype instanceof f?t:f,i=Object.create(o.prototype),r=new _(a||[]);return s(i,"_invoke",{value:E(e,n,r)}),i}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=g;var y={};function f(){}function S(){}function h(){}var v={};d(v,l,(function(){return this}));var m=Object.getPrototypeOf,b=m&&m(m(P([])));b&&b!==n&&i.call(b,l)&&(v=b);var A=h.prototype=f.prototype=Object.create(v);function w(e){["next","throw","return"].forEach((function(t){d(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,t){function n(o,s,r,l){var c=p(e[o],e,s);if("throw"!==c.type){var u=c.arg,d=u.value;return d&&"object"==a(d)&&i.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,r,l)}),(function(e){n("throw",e,r,l)})):t.resolve(d).then((function(e){u.value=e,r(u)}),(function(e){return n("throw",e,r,l)}))}l(c.arg)}var o;s(this,"_invoke",{value:function(e,a){function i(){return new t((function(t,o){n(e,a,t,o)}))}return o=o?o.then(i,i):i()}})}function E(e,t,n){var a="suspendedStart";return function(o,i){if("executing"===a)throw new Error("Generator is already running");if("completed"===a){if("throw"===o)throw i;return{value:void 0,done:!0}}for(n.method=o,n.arg=i;;){var s=n.delegate;if(s){var r=I(s,n);if(r){if(r===y)continue;return r}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===a)throw a="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a="executing";var l=p(e,t,n);if("normal"===l.type){if(a=n.done?"completed":"suspendedYield",l.arg===y)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(a="completed",n.method="throw",n.arg=l.arg)}}}function I(e,t){var n=t.method,a=e.iterator[n];if(void 0===a)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,I(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var o=p(a,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,y;var i=o.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,y):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,y)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function P(e){if(e){var t=e[l];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n<e.length;)if(i.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:U}}function U(){return{value:void 0,done:!0}}return S.prototype=h,s(A,"constructor",{value:h,configurable:!0}),s(h,"constructor",{value:S,configurable:!0}),S.displayName=d(h,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===S||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,d(e,u,"GeneratorFunction")),e.prototype=Object.create(A),e},t.awrap=function(e){return{__await:e}},w(T.prototype),d(T.prototype,c,(function(){return this})),t.AsyncIterator=T,t.async=function(e,n,a,o,i){void 0===i&&(i=Promise);var s=new T(g(e,n,a,o),i);return t.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},w(A),d(A,u,"Generator"),d(A,l,(function(){return this})),d(A,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var a in t)n.push(a);return n.reverse(),function e(){for(;n.length;){var a=n.pop();if(a in t)return e.value=a,e.done=!1,e}return e.done=!0,e}},t.values=P,_.prototype={constructor:_,reset:function(e){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(O),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(n,a){return s.type="throw",s.arg=e,t.next=n,a&&(t.method="next",t.arg=void 0),!!a}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var r=i.call(o,"catchLoc"),l=i.call(o,"finallyLoc");if(r&&l){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(r){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&i.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=e,s.arg=t,o?(this.method="next",this.next=o.finallyLoc,y):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),O(n),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var a=n.completion;if("throw"===a.type){var o=a.arg;O(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:P(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),y}},t}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports},7425:e=>{function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},2841:(e,t,n)=>{var a=n(7609)();e.exports=a;try{regeneratorRuntime=a}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=a:Function("r","regeneratorRuntime = r")(a)}}},t={};function n(a){var o=t[a];if(void 0!==o)return o.exports;var i=t[a]={exports:{}};return e[a].call(i.exports,i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{"use strict";n.r(a),n.d(a,{AdminPortal:()=>Oh,AdminPortalRenderer:()=>Uh,AppHolder:()=>R,CheckoutDialog:()=>_h,FronteggApp:()=>Ih,HostedLogin:()=>kh,LoginBoxRenderer:()=>Rh,createElement:()=>ih,defaultTheme:()=>Lh,formatName:()=>oh,getThemeAdminByName:()=>Ph,getThemeByName:()=>Dh,initialize:()=>Vh,mockFlagsList:()=>Eh,restoreSearchParams:()=>rh,waitThemeSetter:()=>sh});var e={};n.r(e),n.d(e,{getVersion:()=>Y,proxy:()=>J,ref:()=>Z,snapshot:()=>Q,subscribe:()=>X,unstable_buildProxyFunction:()=>ee});var t={};n.r(t),n.d(t,{Delete:()=>it,Get:()=>tt,Patch:()=>at,Post:()=>nt,PostDownload:()=>st,Put:()=>ot,extractHeadersFromOptions:()=>rt,getBaseUrl:()=>Xe,getMetadataHeaders:()=>Qe,getScopedTenant:()=>Ze});var o={};n.r(o),n.d(o,{FeatureFlags:()=>ut,loadFeatureFlags:()=>dt});var i={};n.r(i),n.d(i,{GetUserJwt:()=>gt,getCurrentUserTenantsV1:()=>vt,getCurrentUserTenantsV3:()=>ht,getUsersGroups:()=>St,getUsersRoles:()=>ft,getUsersV2:()=>pt,getUsersV3:()=>yt,sendResetBreachedPasswordEmails:()=>mt,updateUserProfileV2:()=>bt});var s={};n.r(s),n.d(s,{getHierarchyMetadata:()=>Rt,getParentTenants:()=>Pt,getParentTenantsById:()=>Ut,getSubTenants:()=>Ot,getSubTenantsAsTree:()=>_t,getTenants:()=>kt,getTenantsUsersCount:()=>Lt,searchSubTenants:()=>Dt,switchTenant:()=>It});var r={};n.r(r),n.d(r,{loadEntitlementsV2:()=>vn});var l={};n.r(l),n.d(l,{AuthStrategyEnum:()=>rn,MachineToMachineAuthStrategy:()=>ln,OAuthLogout:()=>Jn,SocialLoginProviders:()=>sn,acceptInvitation:()=>Wn,activateAccount:()=>jn,activateAccountV2:()=>Gn,bulkCreateIPRestriction:()=>en,changePhoneNumber:()=>ei,changePhoneNumberWithVerification:()=>Qo,checkIfAllowToRememberMfaDevice:()=>Ao,createDomainRestriction:()=>qt,createIPRestriction:()=>Zt,createOrUpdateSessionConfigrations:()=>oo,createSSOConfiguration:()=>Oo,createSSOConfigurationByMetadata:()=>Uo,createSSOConfigurationByMetadataUrl:()=>Do,createSSODomain:()=>Co,createSSOGroup:()=>Go,createSamlGroup:()=>Va,createTenantAccessToken:()=>po,createUserAccessToken:()=>go,deleteAllSessionsForUser:()=>so,deleteDomainRestriction:()=>Yt,deleteIPRestriction:()=>nn,deleteSSOConfiguration:()=>Po,deleteSSODomain:()=>No,deleteSSOGroup:()=>Vo,deleteSamlGroup:()=>Wa,deleteSessionForUser:()=>io,deleteTenantAccessToken:()=>co,deleteTenantApiToken:()=>vo,deleteUserAccessToken:()=>uo,deleteUserApiToken:()=>mo,deleteWebAuthnDevice:()=>si,disableMFAAuthenticatorApp:()=>ca,disableMFASMS:()=>da,disableMFAWebAuthn:()=>pa,disableMfa:()=>la,enrollMFAAuthenticatorApp:()=>na,enrollMFAAuthenticatorAppForLogin:()=>Sa,enrollMFAAuthenticatorAppForLoginV2:()=>ha,enrollMFASMS:()=>oa,enrollMFASMSForLogin:()=>Ta,enrollMFASMSForLoginV2:()=>Ea,enrollMFAWebAuthn:()=>sa,enrollMFAWebAuthnForLogin:()=>Pa,enrollMFAWebAuthnForLoginV2:()=>Ua,enrollMfa:()=>ea,exchangeOAuthTokens:()=>qo,exchangeOAuthTokensV2:()=>Ko,forgotPassword:()=>Yn,generateLoginResponse:()=>En,generateLoginResponseFromOAuthResponse:()=>Pn,generateLoginResponseFromOAuthResponseV2:()=>Un,generateLoginResponseV2:()=>In,generateLoginResponseV3:()=>_n,generateStepupSession:()=>fi,getActivateAccountStrategy:()=>xn,getCaptchaPolicy:()=>xt,getCurrentUserSession:()=>to,getCurrentUserSessions:()=>eo,getCurrentUserTenantsFunction:()=>Et,getCustomSocialLoginProvidersV1:()=>Ya,getDomainRestrictions:()=>Kt,getDomainRestrictionsConfig:()=>Ht,getGlobalSecurityPolicy:()=>Ct,getIPRestrictions:()=>Xt,getIPRestrictionsConfig:()=>Qt,getLockoutPolicy:()=>$t,getMFADevices:()=>ya,getMFAStrategiesConfig:()=>ui,getMeAndEntitlements:()=>yi,getMeV2:()=>gi,getMfaPolicy:()=>Nt,getOidcConfiguration:()=>za,getPasswordConfigPolicy:()=>zt,getPasswordHistoryPolicy:()=>Vt,getPublicAuthStrategiesConfigForAuthenticatedUser:()=>ci,getSSOConfigurations:()=>ko,getSSODefaultRoles:()=>$o,getSSOGroups:()=>Bo,getSSOPublicConfiguration:()=>Ka,getSamlConfiguration:()=>Ca,getSamlRoles:()=>ja,getSamlRolesGroups:()=>Ga,getSamlVendorConfiguration:()=>Ma,getSessionConfigurations:()=>ao,getSocialLoginProviders:()=>Ha,getSocialLoginProvidersV2:()=>qa,getSocialLoginProvidersV2ForAuthenticatedUser:()=>Ja,getTabTenantFromSessionStorage:()=>Tt,getTenantAccessTokensData:()=>lo,getTenantApiTokensData:()=>fo,getUserAccessTokensData:()=>ro,getUserApiTokensData:()=>yo,getUserAuthorization:()=>di,getUserById:()=>bo,getVendorConfig:()=>Qa,getVendorLockoutPolicy:()=>jt,getVendorMfaPolicy:()=>Mt,getVendorPasswordHistoryPolicy:()=>Bt,getVendorPublicAuthStrategiesConfig:()=>li,getWebAuthnDevices:()=>ii,loadPasswordConfig:()=>Qn,login:()=>Nn,loginViaSocialLogin:()=>Xa,loginWithMfa:()=>Fn,loginWithMfaV2:()=>$n,loginv2:()=>Mn,logout:()=>qn,oidcPostLogin:()=>Cn,oidcPostLoginV2:()=>zo,passwordlessPostLogin:()=>Eo,passwordlessPostLoginV2:()=>To,passwordlessPreLogin:()=>wo,postLogin:()=>Rn,preDisableMFASMS:()=>ua,preDisableMFAWebAuthn:()=>ga,preEnrollMFAAuthenticatorApp:()=>ta,preEnrollMFAAuthenticatorAppForLogin:()=>fa,preEnrollMFASMS:()=>aa,preEnrollMFASMSForLogin:()=>wa,preEnrollMFAWebAuthn:()=>ia,preEnrollMFAWebAuthnForLogin:()=>_a,preLogin:()=>Ln,preLoginV2:()=>Wo,preLoginWithIdpType:()=>Dn,preVerifyMFAEmailCode:()=>ma,preVerifyMFASMSForLogin:()=>Ia,preVerifyMFAWebAuthnForLogin:()=>La,recoverMfaToken:()=>Zn,refreshToken:()=>zn,refreshTokenV2:()=>Kn,refreshTokenV3:()=>Hn,removeTabTenantFromSessionStorage:()=>wt,resendActivationEmail:()=>Vn,resendInvitationEmail:()=>Bn,resetPassword:()=>Xn,resetPhoneNumber:()=>Yo,revokeSessionsForUser:()=>no,saveLockoutPolicy:()=>Gt,saveMfaPolicy:()=>Ft,savePasswordHistoryPolicy:()=>Wt,setSSODefaultRoles:()=>jo,setTabTenantInSessionStorage:()=>At,signUpUser:()=>Za,silentOAuthRefreshToken:()=>Jo,silentOAuthRefreshTokenV2:()=>Ho,testCurrentIp:()=>an,testCurrentIpInAllowList:()=>on,updateDomainRestrictionConfig:()=>Jt,updateIPRestrictionConfig:()=>tn,updateSSOConfiguration:()=>_o,updateSSOConfigurationByMetadata:()=>Lo,updateSSOConfigurationByMetadataUrl:()=>Ro,updateSSOGroup:()=>xo,updateSamlConfiguration:()=>Na,updateSamlGroup:()=>Ba,updateSamlRoles:()=>xa,updateSamlVendorMetadata:()=>Fa,updateTenantApiTokensData:()=>ho,updateUserApiTokensData:()=>So,validateSSODomain:()=>Mo,validateSSODomainV2:()=>Fo,validateSamlDomain:()=>$a,verifyChangePhoneNumber:()=>Zo,verifyInviteToken:()=>Io,verifyMFAAuthenticatorAppForLogin:()=>va,verifyMFAEmailCode:()=>ba,verifyMFAEmailCodeV2:()=>Aa,verifyMFASMSForLogin:()=>ka,verifyMFASMSForLoginV2:()=>Oa,verifyMFAWebAuthnForLogin:()=>Da,verifyMFAWebAuthnForLoginV2:()=>Ra,verifyMfa:()=>ra,verifyNewDeviceSession:()=>ri,verifyResetPhoneNumber:()=>Xo,webAuthnCreateNewDeviceSession:()=>oi,webAuthnPostLogin:()=>ni,webAuthnPostLoginV2:()=>ai,webAuthnPreLogin:()=>ti});var c={};n.r(c),n.d(c,{addUser:()=>Ai,changePassword:()=>mi,createInviteUserLink:()=>Oi,deleteInviteUserLink:()=>Pi,deleteUser:()=>wi,getInviteLinkConfiguration:()=>Li,getInviteUserLink:()=>Ui,getProfile:()=>Si,getTemporaryUserConfiguration:()=>ki,loadAvailablePermissions:()=>Ri,loadAvailableRoles:()=>Di,loadStats:()=>Ci,loadUsers:()=>bi,resendActivationLink:()=>Ni,resendInvitationLink:()=>Mi,resendInvitationLinkToAllTenants:()=>Fi,setPermanentUser:()=>Ii,updateInviteUserLink:()=>_i,updateProfile:()=>hi,updateProfileImage:()=>vi,updateUser:()=>Ti,updateUserExpirationTime:()=>Ei});var u={};n.r(u),n.d(u,{getAdminBoxMetadata:()=>ji,getAuditsMetadata:()=>Wi,getCurrentUserIpMetadata:()=>xi,getIpAdressMetadata:()=>zi,getNotificationsMetadata:()=>Vi,getSamlMetadata:()=>Bi,updateAdminBoxMetadata:()=>Gi});var d={};n.r(d),n.d(d,{downloadReport:()=>Zi,getReport:()=>Yi,getReports:()=>Ji,renderReport:()=>Xi,scheduleReport:()=>Qi,sendReport:()=>es});var g={};n.r(g),n.d(g,{getNotifications:()=>ts,markAllAsRead:()=>os,updateNotificationIsPinned:()=>as,updateNotificationStatus:()=>ns});var p={};n.r(p),n.d(p,{exportAudits:()=>ls,getAudits:()=>ss,getAuditsStats:()=>rs});var y={};n.r(y),n.d(y,{deleteEmailConfiguration:()=>ws,deleteEmailSubscriptions:()=>bs,deleteSMSConfiguration:()=>_s,deleteSMSSubscriptions:()=>ks,deleteSlackConfiguration:()=>fs,deleteWebhooksConfiguration:()=>Ls,getCategories:()=>Ns,getChannelMaps:()=>Ms,getEmailConfiguration:()=>hs,getSMSConfiguration:()=>Ts,getSlackChannels:()=>ps,getSlackConfiguration:()=>ds,getSlackScope:()=>gs,getWebhookLog:()=>Ds,getWebhooksConfigurations:()=>Ps,patchEmailConfiguration:()=>ms,patchSMSConfiguration:()=>Is,postEmailConfiguration:()=>vs,postSMSConfiguration:()=>Es,postSlackCode:()=>Ss,postSlackConfiguration:()=>ys,postWebhookRetry:()=>Cs,postWebhookTest:()=>Rs,postWebhooksConfiguration:()=>Us,putEmailSubscriptions:()=>As,putSMSSubscriptions:()=>Os});var f={};n.r(f),n.d(f,{getPublicSettings:()=>js,getSettings:()=>$s,updateSettings:()=>Fs});var S={};n.r(S),n.d(S,{addRole:()=>Ws,addRoleV2:()=>Xs,attachPermissionToRoles:()=>Js,attachPermissionsToRole:()=>Hs,deleteRole:()=>zs,getPermissionCategories:()=>Ys,getPermissions:()=>qs,getRoles:()=>Bs,updateRole:()=>Ks});var h={};n.r(h),n.d(h,{ISubscriptionCancellationPolicy:()=>Pr,ISubscriptionStatus:()=>Or,PaymentMethodType:()=>_r,ProviderType:()=>Ur,TenantCreatedAction:()=>Dr,TrialEndAction:()=>Lr,cancelManagedSubscription:()=>ir,cancelSubscription:()=>er,createStripeCustomer:()=>mr,createStripePaymentMethodSetupIntentSecret:()=>Ar,createSubscription:()=>hr,createTenantConfiguration:()=>Er,getManagedSubscription:()=>ar,getManagedSubscriptions:()=>or,getPaymentMethod:()=>fr,getPaymentMethods:()=>yr,getPaymentProviders:()=>Ir,getStripeCustomer:()=>vr,getStripePaymentProviderConfiguration:()=>br,getSubscription:()=>Zs,getSubscriptionInvoice:()=>dr,getSubscriptionInvoicePdf:()=>gr,getSubscriptionInvoices:()=>ur,getSubscriptionPlan:()=>cr,getSubscriptionPlans:()=>lr,getSubscriptionSummaries:()=>wr,getSubscriptions:()=>Qs,getTenantConfiguration:()=>Tr,getVendorPublicConfigurations:()=>kr,renewManagedSubscription:()=>sr,renewSubscription:()=>tr,updateManagedSubscription:()=>rr,updatePaymentMethodBillingDetails:()=>Sr,updateSubscription:()=>nr});var v={};n.r(v),n.d(v,{assignUserToApplications:()=>Fr,getApplicationsData:()=>Mr,getTenantsApplications:()=>Nr,getUserApplicationsId:()=>Rr,getUsersApplicationsId:()=>Cr,getUsersOfApplications:()=>jr,unassignUserFromApplications:()=>$r});var m={};n.r(m),n.d(m,{getVendorPublicInfo:()=>Gr});var b={};n.r(b),n.d(b,{addUserRolesForSubTenants:()=>Wr,addUserToTenantAndSubTenants:()=>Vr,addUsersToSubTenant:()=>Qr,createSubTenant:()=>Hr,deleteSubTenant:()=>qr,loadAllUsers:()=>xr,removeUserFromTenantAndSubTenants:()=>Br,removeUserRolesFromSubTenants:()=>zr,setUserRolesForSubTenants:()=>Kr,updateSubAccountAccess:()=>Xr,updateSubTenant:()=>Jr,updateSubTenantManagement:()=>Yr});var A={};n.r(A),n.d(A,{countConfigurationUsers:()=>al,createConfiguration:()=>tl,deleteConfiguration:()=>nl,getConfigs:()=>Zr,updateConfiguration:()=>el});var w={};n.r(w),n.d(w,{impersonate:()=>ol});var T={};n.r(T),n.d(T,{addRolesToGroup:()=>gl,addUsersToGroup:()=>yl,createGroup:()=>cl,deleteGroup:()=>dl,deleteRolesFromGroup:()=>pl,deleteUsersFromGroup:()=>fl,getGroupById:()=>sl,getGroupConfiguration:()=>Sl,getGroups:()=>rl,getGroupsByIds:()=>ll,updateGroup:()=>ul,updateGroupConfiguration:()=>hl});var E={};n.r(E),n.d(E,{getInsights:()=>ml,getRecommendations:()=>vl});var I={};n.r(I),n.d(I,{createPhoneNumber:()=>Al,deletePhoneNumber:()=>wl,getUserPhoneNumbers:()=>bl,preVerifyPhoneNumber:()=>Tl,verifyDeletePhoneNumber:()=>Il,verifyPhoneNumber:()=>El});var k={};n.r(k),n.d(k,{ADMIN_PORTAL_ENTITLEMENTS_FF:()=>bn,ApplicationAccessType:()=>ql,AuthStrategyEnum:()=>rn,ContextHolder:()=>ne,FeatureFlags:()=>ut,FronteggApiError:()=>ce,FronteggContext:()=>ae,FronteggFrameworks:()=>re,GetUsersFilterPreset:()=>xl,GroupManagedByEnum:()=>jl,GroupRelations:()=>$l,ISubscriptionCancellationPolicy:()=>Pr,ISubscriptionStatus:()=>Or,InsightCode:()=>Wl,LOAD_AUTHORIZATION_FF:()=>hn,MFAStrategyEnum:()=>Sn,MachineToMachineAuthStrategy:()=>ln,NotEntitledJustification:()=>mn,PaginationOrderEnum:()=>le,PaymentMethodType:()=>_r,PermissionAssignmentTypeEnum:()=>Pl,ProviderType:()=>Ur,RecommendationActionKey:()=>zl,RecommendationCode:()=>Bl,RecommendationSeverity:()=>Kl,RequestSource:()=>se,RestrictionType:()=>pn,ScimConnectionSource:()=>Fl,SecondaryAuthStrategy:()=>yn,SecurityCategory:()=>Hl,SocialLoginProviders:()=>sn,SortByEnum:()=>Gl,TenantSortByEnum:()=>Ol,TenantType:()=>_l,UserManagedByEnum:()=>kl,WebAuthnDeviceType:()=>fn,api:()=>Jl,countConfigurationUsers:()=>al,createConfiguration:()=>tl,default:()=>Yl,deleteConfiguration:()=>nl,fetch:()=>t,fronteggAuthApiRoutesRegex:()=>Ul,fronteggEntitlementsV2Url:()=>Ml,fronteggHeaders:()=>ie,fronteggRefreshTokenUrl:()=>Ll,fronteggSilentRefreshTokenUrl:()=>Dl,fronteggTenantsUrl:()=>Cl,fronteggTenantsV3Url:()=>Nl,fronteggUsersUrl:()=>Rl,getConfigs:()=>Zr,getCurrentUserTenantsFunction:()=>Et,getTabTenantFromSessionStorage:()=>Tt,loadFeatureFlags:()=>dt,providersArray:()=>Vl,setTabTenantInSessionStorage:()=>At,updateConfiguration:()=>el});var O={};n.r(O),n.d(O,{AccountDetailsPageTabs:()=>bh,AccountPageFields:()=>gh,DomainRestrictionsTabFields:()=>mh,GeneralSettingsTabFields:()=>hh,InviteUserModalFields:()=>dh,IpRestrictionsTabFields:()=>vh,Metadata:()=>ah,PrivacyPageFields:()=>uh,ProfilePageFields:()=>ch,SecurityPageTabs:()=>fh,SessionManagementTabFields:()=>Sh,SignupFields:()=>lh,SubscriptionsPageFields:()=>yh,UsersTableColumns:()=>ph,alpha:()=>YS,fieldAppearance:()=>Ah,tabAppearance:()=>wh});var _={};function P(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function U(e){return U="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},U(e)}function L(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,(o=a.key,i=void 0,i=function(e,t){if("object"!==U(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,t);if("object"!==U(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(o,"string"),"symbol"===U(i)?i:String(i)),a)}var o,i}function D(e,t,n){return t&&L(e.prototype,t),n&&L(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}n.r(_),n.d(_,{ACR_VALUE:()=>lu,AMR_ADDITIONAL_VALUE:()=>uu,AMR_MFA_VALUE:()=>cu,AcceptInvitationStep:()=>nc,ActivateAccountStep:()=>ac,AdminPortalPages:()=>Rc,AdminPortalPagesForEvents:()=>Dc,AllAccountsStateKeys:()=>wc,ApiStateKeys:()=>oc,AuthStrategyEnum:()=>rn,AuthenticationTypes:()=>Lc,FRONTEGG_AFTER_AUTH_REDIRECT_URL:()=>pu,ForgotPasswordStep:()=>pc,FronteggNativeModule:()=>$d,GTMEventAction:()=>Hc,GroupRelations:()=>fc,GroupsStateKeys:()=>yc,HOSTED_LOGIN_VERIFIER_KEY:()=>yu,ImpersonateStep:()=>Sc,LoginActionTypes:()=>bc,LoginFlow:()=>vc,LoginStep:()=>hc,MFAStep:()=>Ac,MachineToMachineAuthStrategy:()=>ln,PaymentMethodType:()=>wy,PaymentProvider:()=>Iy,QuickLoginStrategy:()=>mc,ResetPhoneNumberStep:()=>Tc,RolesStateKeys:()=>Ec,SHOULD_STEP_UP_KEY:()=>du,SSOStateKeys:()=>Oc,STEP_UP_MAX_AGE_PARAM_NAME:()=>gu,SamlVendors:()=>_c,SecurityCenterStateKeys:()=>Ic,SignUpStage:()=>kc,SubscriptionCancellationPolicy:()=>Oy,SubscriptionStatus:()=>ky,TENANT_ID_PARAM_KEY:()=>nu,TeamStateKeys:()=>Pc,UserVeirifedOriginTypes:()=>Uc,authStrategyLoginStepMap:()=>Jc,base64ToFormData:()=>Sd,base64urlDecode:()=>fd,base64urlEncode:()=>yd,buildAuditsActions:()=>ff,buildAuthActions:()=>yy,buildConnectivityActions:()=>Ay,buildSubscriptionsActions:()=>af,buildVendorActions:()=>rf,createAuditsState:()=>yf,createAuthState:()=>py,createConnectivityState:()=>Sy,createFronteggStore:()=>WS,createRandomString:()=>Fd,createStore:()=>zS,createSubscriptionsState:()=>nf,createVendorState:()=>sf,deepClone:()=>Xl,defaultFronteggRoutes:()=>Yc,delay:()=>Ql,errorHandler:()=>Gc,extractPhoneNumber:()=>Tu,generateCodeChallenge:()=>Md,generateCodeChallengeNative:()=>Nd,generateCodeChallengePureJs:()=>Cd,getEntitlements:()=>dc,getFeatureEntitlements:()=>uc,getMfaStepForEnrolledUsers:()=>ou,getMfaStepForNotEnrolledUsers:()=>iu,getNumberOfMfaDevices:()=>au,getPathAndSearchParamsFromUrl:()=>eu,getPermissionEntitlements:()=>cc,getRedirectUrl:()=>Qc,getSearchParam:()=>tu,getSearchParamsFromUrl:()=>Zc,getUri:()=>wu,isAbsoluteUrl:()=>Xc,isAuthRoute:()=>Eu,isEmailPayload:()=>ru,isEntitlementsDeeplyEqual:()=>gc,isError:()=>jc,isMfaRequired:()=>bu,isOauthCallbackRoute:()=>su,isProxy:()=>tc,isSteppedUp:()=>fu,mapMetaDataObjectToActions:()=>Au,omitProps:()=>ec,publicKeyCredentialToJSON:()=>hd,readFileAsText:()=>vd,redirectByStepUpUrl:()=>hu,reportGTMEvent:()=>qc,retry:()=>Zl,setAfterAuthRedirectUrlForStepUp:()=>Su,snapshot:()=>Q,subscribe:()=>X});var R=function(){function e(){P(this,e)}return D(e,null,[{key:"setInstance",value:function(t,n){e._apps[t]=n}},{key:"getInstance",value:function(t){var n=e._apps[t];if(!n)throw Error("[".concat(t,"] FronteggApp not found"));return n}}]),e}();function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}function N(e,t,n,a,o,i,s){try{var r=e[i](s),l=r.value}catch(e){return void n(e)}r.done?t(l):Promise.resolve(l).then(a,o)}function M(e){return function(){var t=this,n=arguments;return new Promise((function(a,o){var i=e.apply(t,n);function s(e){N(i,a,o,s,r,"next",e)}function r(e){N(i,a,o,s,r,"throw",e)}s(void 0)}))}}R._apps={};var F=n(2841),$=n.n(F);function j(){return j=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},j.apply(this,arguments)}Symbol();const G=Symbol(),x=Object.getPrototypeOf,V=new WeakMap,B=(e,t=!0)=>{V.set(e,t)},W=e=>"object"==typeof e&&null!==e,z=new WeakMap,K=new WeakSet,H=(e=Object.is,t=((e,t)=>new Proxy(e,t)),n=(e=>W(e)&&!K.has(e)&&(Array.isArray(e)||!(Symbol.iterator in e))&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof Error)&&!(e instanceof Number)&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof RegExp)&&!(e instanceof ArrayBuffer)),a=(e=>{switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e}}),o=new WeakMap,i=((e,t,n=a)=>{const s=o.get(e);if((null==s?void 0:s[0])===t)return s[1];const r=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return B(r,!0),o.set(e,[t,r]),Reflect.ownKeys(e).forEach((t=>{if(Object.getOwnPropertyDescriptor(r,t))return;const a=Reflect.get(e,t),{enumerable:o}=Reflect.getOwnPropertyDescriptor(e,t),s={value:a,enumerable:o,configurable:!0};if(K.has(a))B(a,!1);else if(a instanceof Promise)delete s.value,s.get=()=>n(a);else if(z.has(a)){const[e,t]=z.get(a);s.value=i(e,t(),n)}Object.defineProperty(r,t,s)})),Object.preventExtensions(r)}),s=new WeakMap,r=[1,1],l=(a=>{if(!W(a))throw new Error("object required");const o=s.get(a);if(o)return o;let c=r[0];const u=new Set,d=(e,t=++r[0])=>{c!==t&&(c=t,u.forEach((n=>n(e,t))))};let g=r[1];const p=e=>(t,n)=>{const a=[...t];a[1]=[e,...a[1]],d(a,n)},y=new Map,f=e=>{var t;const n=y.get(e);n&&(y.delete(e),null==(t=n[1])||t.call(n))},S=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a)),h=t(S,{deleteProperty(e,t){const n=Reflect.get(e,t);f(t);const a=Reflect.deleteProperty(e,t);return a&&d(["delete",[t],n]),a},set(t,a,o,i){const r=Reflect.has(t,a),c=Reflect.get(t,a,i);if(r&&(e(c,o)||s.has(o)&&e(c,s.get(o))))return!0;var g;f(a),W(o)&&(o=(e=>e&&(V.has(e)?V.get(e):x(e)===Object.prototype||x(e)===Array.prototype))(g=o)&&g[G]||null||o);let S=o;if(o instanceof Promise)o.then((e=>{o.status="fulfilled",o.value=e,d(["resolve",[a],e])})).catch((e=>{o.status="rejected",o.reason=e,d(["reject",[a],e])}));else{!z.has(o)&&n(o)&&(S=l(o));const e=!K.has(S)&&z.get(S);e&&((e,t)=>{if(y.has(e))throw new Error("prop listener already exists");if(u.size){const n=t[3](p(e));y.set(e,[t,n])}else y.set(e,[t])})(a,e)}return Reflect.set(t,a,S,i),d(["set",[a],o,c]),!0}});s.set(a,h);const v=[S,(e=++r[1])=>(g===e||u.size||(g=e,y.forEach((([t])=>{const n=t[1](e);n>c&&(c=n)}))),c),i,e=>(u.add(e),1===u.size&&y.forEach((([e,t],n)=>{if(t)throw new Error("remove already exists");const a=e[3](p(n));y.set(n,[e,a])})),()=>{u.delete(e),0===u.size&&y.forEach((([e,t],n)=>{t&&(t(),y.set(n,[e]))}))})];return z.set(h,v),Reflect.ownKeys(a).forEach((e=>{const t=Object.getOwnPropertyDescriptor(a,e);"value"in t&&(h[e]=a[e],delete t.value,delete t.writable),Object.defineProperty(S,e,t)})),h}))=>[l,z,K,e,t,n,a,o,i,s,r],[q]=H();function J(e={}){return q(e)}function Y(e){const t=z.get(e);return null==t?void 0:t[1]()}function X(e,t,n){const a=z.get(e);let o;a||console.warn("Please use proxy object");const i=[],s=a[3];let r=!1;const l=s((e=>{i.push(e),n?t(i.splice(0)):o||(o=Promise.resolve().then((()=>{o=void 0,r&&t(i.splice(0))})))}));return r=!0,()=>{r=!1,l()}}function Q(e,t){const n=z.get(e);n||console.warn("Please use proxy object");const[a,o,i]=n;return i(a,o(),t)}function Z(e){return K.add(e),e}const ee=H,te=Symbol();class ne{constructor(){this.context=null,this.accessToken=null,this.user=null,this.requestSource=null,this.onRedirectTo=e=>window.location.href=e,this.logout=()=>window.location.href="/account/logout",this.entitlementsOptions=null,this.appName=null,this.sessionContext=void 0}static getInstance(){return ne.instance||(ne.instance=new ne),ne.instance}static setContext(e){ne.getInstance().context=e}static setAccessToken(e){ne.getInstance().accessToken=e}static setUser(e){ne.getInstance().user=e}static setRequestSource(e){ne.getInstance().requestSource=e}static setOnRedirectTo(e){ne.getInstance().onRedirectTo=e}static setLogout(e,t){ne.getInstance().logout=n=>{n?e(n):ne.onRedirectTo(t)}}static setEntitlementsOptions(e){ne.getInstance().entitlementsOptions=e}static setSessionContext(e){ne.getInstance().sessionContext=e}static setAppName(e){ne.getInstance().appName=e}static getContext(){var e;return null!=(e=ne.getInstance().context)?e:{baseUrl:window.location.href,tokenResolver:()=>"my-authentication-token",logLevel:"error"}}static getAccessToken(){return ne.getInstance().accessToken}static getRequestSource(){return ne.getInstance().requestSource}static getUser(){return ne.getInstance().user}static onRedirectTo(e,t){return ne.getInstance().onRedirectTo(e,t)}static logout(e){return ne.getInstance().logout(e)}static shouldLoadEntitlements(){var e;return(null==(e=ne.getInstance().entitlementsOptions)?void 0:e.enabled)||!1}static isSessionPerTenantEnabled(){var e;return(null==(e=ne.getInstance().sessionContext)?void 0:e.enableSessionPerTenant)||!1}static getAppName(){return ne.getInstance().appName}}ne.instance=void 0;const ae={getContext:()=>ne.getContext(),getAccessToken:()=>ne.getAccessToken(),getUser:()=>ne.getUser(),onRedirectTo:(e,t)=>ne.onRedirectTo(e,t),logout:e=>ne.logout(e)};function oe(e,t){if(null==e)return{};var n,a,o={},i=Object.keys(e);for(a=0;a<i.length;a++)n=i[a],t.indexOf(n)>=0||(o[n]=e[n]);return o}const ie={frameWork:"x-frontegg-framework",fronteggSdkVersion:"x-frontegg-sdk",contentType:"Content-Type",source:"frontegg-source",scopedTenant:"frontegg-scoped-tenant"};let se,re,le;!function(e){e.AdminPortal="admin-portal",e.LoginBox="login-box"}(se||(se={})),function(e){e.Nextjs="nextjs",e.React="react",e.Angular="angular",e.Vuejs="vuejs",e.Flutter="flutter",e.Ios="ios",e.Android="android",e.Vanillajs="vanillajs"}(re||(re={})),function(e){e.ASC="ASC",e.DESC="DESC"}(le||(le={}));class ce extends Error{constructor(e,t){super(e),this._statusCode=void 0,this._statusCode=t}get statusCode(){return this._statusCode}}const ue={v1:"/identity/resources/users/webauthn/v1/devices"},de={v1:"/identity/resources/auth/v1",v2:"/identity/resources/auth/v2"},ge={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"}}},pe={v1:"/identity/resources/configurations/v1"},ye={emailDomain:{v1:"/identity/resources/configurations/restrictions/v1/email-domain"},ip:{v1:"/identity/resources/configurations/v1/restrictions/ip"}},fe={v1:"/identity/resources/sso/v1",v2:"/identity/resources/sso/v2",custom:{v1:"/identity/resources/sso/custom/v1"}},Se={v1:"/identity/resources/permissions/v1"},he={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"}},ve={v1:"/identity/resources/roles/v1",v2:"/identity/resources/roles/v2"},me={v1:"/identity/resources/sub-tenants/users/v1",v2:"/identity/resources/sub-tenants/users/v2"},be={v1:"/identity/resources/impersonation/v1"},Ae={v1:"/identity/resources/applications/v1"},we={v1:"/identity/resources/groups/v1",configurations:{v1:"/identity/resources/groups/v1/config"},getByIds:{v1:"/identity/resources/groups/v1/bulkGet"}},Te={v1:"/identity/resources/users/phone-numbers/v1"},Ee={v1:"/team/resources/sso/v1",v2:"/team/resources/sso/v2"},Ie={v1:"/team/resources/members/v1"},ke={v1:"/team/resources/roles/v1"},Oe={v1:"/team/resources/stats/v1"},_e={v1:"/team/resources/profile"},Pe={v1:"/tenants/resources/account-settings/v1"},Ue={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"}},Le={v1:"/tenants/resources/sub-tenants/v1"},De={v1:"/integrations/resources/configurations/v1",v2:"/integrations/resources/configurations/v2"},Re={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"}}}},Ce={v1:"/subscriptions/resources/payment-providers/v1"},Ne={v1:"/subscriptions/resources/subscriptions/v1"},Me={v1:"/reports/resources/reports/v1",v2:"/reports/resources/reports/v2"},Fe={v1:"/reports/engine/resources/triggers/v1"},$e="/notification",je="/audits",Ge={v1:"/event/resources/configurations/v1"},xe="/webhook",Ve="/oauth",Be="/flags",We="/directory/resources/v1/configurations/scim2",ze="/directory/resources/scim/temp",Ke="/entitlements/api/v2/user-entitlements",He={v1:"/security-center/resources/recommendations/v1"},qe={v1:"/security-center/resources/insights/v1"},Je="/applications/resources/applications/v1",Ye={v1:"/applications/resources/applications/tenant-assignments/v1"};function Xe(e,t,n=!0){let a;a="function"==typeof e.baseUrl?e.baseUrl(t):e.baseUrl;const o=e.urlPrefix||"frontegg",i="frontegg"===o&&!n;return a.endsWith("/")||(a+="/"),a.endsWith(o)||i||(a+=o),a}function Qe(e){var t,n;const a={};return null!=e&&null!=(t=e.metadataHeaders)&&t.fronteggSdkVersion&&(a[ie.fronteggSdkVersion]=e.metadataHeaders.fronteggSdkVersion),null!=e&&null!=(n=e.metadataHeaders)&&n.framework&&(a[ie.frameWork]=e.metadataHeaders.framework),a}function Ze(){return new URLSearchParams(window.location.search).get("tenantId")||null}const et=async e=>{var t,n,a;const o=ne.getContext(),i=await async function(e,t){var n;const a=Qe(e),o=await(null!=(n=null==e?void 0:e.tokenResolver)?n:ne.getAccessToken)(),i=ne.getRequestSource(),s=Ze();t&&(a[ie.contentType]=t),i&&(a[ie.source]=i),o&&(a.Authorization=`Bearer ${o}`),s&&(a[ie.scopedTenant]=s);for(const t of await async function(e){let t=[];if(e.additionalHeadersResolver&&(t=await e.additionalHeadersResolver()),e.tenantResolver){const n=await e.tenantResolver();null!=n&&n.tenant&&t.push({key:"frontegg-login-alias",value:n.tenant})}return e.appId&&t.push({key:"frontegg-requested-application-id",value:e.appId}),t}(e))a[`${t.key}`]=`${t.value}`;return a}(o,e.contentType),s=await async function(e,t,n){const a=Xe(e,t),o=await async function(e,t){t||(t={});const n=await async function(e){let t=[];return e.additionalQueryParamsResolver&&(t=await e.additionalQueryParamsResolver()),t}(e);for(const e of n)t[e.key]=e.value;const a=Object.keys(t);for(const e of a){const n=t[e];t[e]="object"==typeof n?JSON.stringify(n):n}return t}(e,n);let i=t.startsWith("http")?t:`${a}${t}`;const s=Object.keys(o).length>0;return o&&s&&(i+=`?${new URLSearchParams(o)}`),i}(o,e.url,e.params),r=await fetch(s,{body:e.body?"application/json"===e.contentType?JSON.stringify(e.body):e.body:null,method:null!=(t=e.method)?t:"GET",headers:j({},i,e.headers),credentials:null!=(n=null!=(a=e.credentials)?a:o.requestCredentials)?n:"same-origin"});if(302===r.status)return window.location.href=await r.text(),new Promise((()=>{}));if(!r.ok){var l,c;if(413===r.status)throw new ce("Error request is too large",r.status);let e,t=!0;try{e=await r.text(),e=JSON.parse(e)}catch(e){t=!1}throw e.errors?e=e.errors.join(", "):"string"!=typeof e&&(e=`Error ${r.status} - ${r.statusText}`),r.status>=400&&r.status<500&&["warn"].includes(null!=(l=o.logLevel)?l:"")?console.warn(e):500===r.status&&["warn","error"].includes(null!=(c=o.logLevel)?c:"")&&console.error(e),new ce(t?e:"We're facing some difficulties, Please try again",r.status)}if(e.responseType&&"json"!==e.responseType){if("blob"===e.responseType){const{outputFileName:t}=e.params;return await r.blob().then((e=>URL.createObjectURL(e))).then((e=>{const n=document.createElement("a");n.href=e,n.setAttribute("download",t||"output"),n.click()}))}return await r.text()}try{return await r.json()}catch(e){return{}}},tt=async(e,t,n)=>et(j({url:e,method:"GET",contentType:"application/json",params:t},n)),nt=async(e,t,n)=>et(j({url:e,method:"POST",contentType:"application/json",body:t},n)),at=async(e,t,n)=>et(j({url:e,method:"PATCH",contentType:"application/json",body:t},n)),ot=async(e,t,n)=>et(j({url:e,method:"PUT",contentType:"application/json",body:t},n)),it=async(e,t,n)=>et(j({url:e,method:"DELETE",contentType:"application/json",body:t},n)),st=async(e,t,n,a)=>et(j({url:e,method:"POST",contentType:"application/json",responseType:"blob",body:t,params:n},a)),rt=(e={})=>j({},e.jwt?{Authorization:e.jwt}:{}),lt="FRONTEGG_SEPARATE_TABS_BY_TENANT",ct={flags:{}};class ut{constructor(){var e;this._flags={},this._flags=null!=(e=ct.flags)?e:{}}static getInstance(e="default"){return this._instances[e]}static set(e,t="default"){const n=new ut;return n.set(e),ut._instances[t]=n,n}static getFeatureFlags(e,t){const n=this.getInstance(t);return e.map((e=>"on"===(null==n?void 0:n._flags[e])))}get flags(){var e;return null!=(e=this.flags)?e:{}}set(e){var t;this._flags=j({},null!=(t=null==ct?void 0:ct.flags)?t:{},null!=e?e:{})}}async function dt(){return tt(Be)}async function gt(e){return nt(`${ge.v3}/me/token`,e)}async function pt(e,t){return tt(ge.v2,e,{headers:rt(t)})}async function yt(e,t){return tt(ge.v3,e,{headers:rt(t)})}async function ft(e,t){return tt(ge.roles.v3,j({},e,{ids:e.ids.join(",")}),{headers:rt(t)})}async function St(e,t){return tt(ge.groups.v3,j({},e,{ids:e.ids.join(",")}),{headers:rt(t)})}async function ht(e){return tt(ge.tenants.me.v3,void 0,{headers:rt(e)})}async function vt(e){return tt(ge.tenants.me.v1,void 0,{headers:rt(e)})}async function mt(){return nt(ge.passwords.resetBreachedPasswords.v1)}async function bt(e){return ot(`${ge.v2}/me`,e)}function At(e){e&&sessionStorage.setItem(lt,e)}function wt(){sessionStorage.removeItem(lt)}function Tt(){return ne.isSessionPerTenantEnabled()?sessionStorage.getItem(lt):null}function Et(){const[e]=ut.getFeatureFlags(["admin_portal_use_current_user_tenants_v1_endpoint"],ne.getAppName()||"");return ne.isSessionPerTenantEnabled()||e?vt:ht}async function It(e){return ne.isSessionPerTenantEnabled()&&At(e.tenantId),ot(`${ge.v1}/tenant`,e)}async function kt(){return tt(`${ge.v2}/me/tenants`)}async function Ot(e){return tt(Ue.v1,void 0,{headers:rt(e)})}async function _t(e){return tt(Ue.tree.v1,void 0,{headers:rt(e)})}async function Pt(e){return tt(Ue.parents.v1,void 0,{headers:rt(e)})}async function Ut(e,t){return tt(`${Ue.parents.v1}/${e}`,void 0,{headers:rt(t)})}async function Lt(e,t){return nt(`${he.users.v1}/count`,e,{headers:rt(t)})}async function Dt(e,t){return tt(Ue.v2,e,{headers:rt(t)})}async function Rt(e,t){return tt(Ue.metadata.v2,j({},e,{_tenantIds:e._tenantIds.join(",")}),{headers:rt(t)})}async function Ct(){return tt(pe.v1)}async function Nt(){return tt(`${pe.v1}/mfa-policy`)}async function Mt(){return tt(`${pe.v1}/mfa-policy/vendor`)}async function Ft(e){return e.id?at(`${pe.v1}/mfa-policy`,e):nt(`${pe.v1}/mfa-policy`,e)}async function $t(){return tt(`${pe.v1}/lockout-policy`)}async function jt(){return tt(`${pe.v1}/lockout-policy/vendor`)}async function Gt(e){return e.id?at(`${pe.v1}/lockout-policy`,e):nt(`${pe.v1}/lockout-policy`,e)}async function xt(){try{return await tt(`${pe.v1}/captcha-policy/public`)}catch{return null}}async function Vt(){return tt(`${pe.v1}/password-history-policy`)}async function Bt(){return tt(`${pe.v1}/password-history-policy/vendor`)}async function Wt(e){return e.id?at(`${pe.v1}/password-history-policy`,e):nt(`${pe.v1}/password-history-policy`,e)}async function zt(){return tt(`${pe.v1}/password`)}async function Kt(){return tt(`${ye.emailDomain.v1}`)}async function Ht(){return tt(`${ye.emailDomain.v1}/config`)}async function qt(e){return nt(`${ye.emailDomain.v1}`,e)}async function Jt(e){return nt(`${ye.emailDomain.v1}/config`,e)}async function Yt(e){return it(`${ye.emailDomain.v1}/${e}`)}async function Xt(e){return tt(`${ye.ip.v1}`,e)}async function Qt(){return tt(`${ye.ip.v1}/config`)}async function Zt(e){return nt(`${ye.ip.v1}`,e)}async function en(e){return nt(`${ye.ip.v1}/bulk`,e)}async function tn(e){return nt(`${ye.ip.v1}/config`,e)}async function nn(e){return it(`${ye.ip.v1}/${e}`)}async function an(){return nt(`${ye.ip.v1}/verify`)}async function on(){return nt(`${ye.ip.v1}/verify/allow`)}let sn,rn,ln;ut._instances={},function(e){e.Microsoft="microsoft",e.Facebook="facebook",e.Google="google",e.Github="github",e.Slack="slack",e.Apple="apple",e.Linkedin="linkedin"}(sn||(sn={})),function(e){e.EmailAndPassword="EmailAndPassword",e.MagicLink="MagicLink",e.Code="Code",e.NoLocalAuthentication="NoLocalAuthentication",e.SmsCode="SmsCode"}(rn||(rn={})),function(e){e.ClientCredentials="ClientCredentials",e.AccessToken="AccessToken"}(ln||(ln={}));class cn extends Error{constructor(e){super(e)}}const un="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){const t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new cn("'atob' failed: The string to be decoded is not correctly encoded.");let n="";for(let e,a,o=0,i=0;a=t.charAt(i++);~a&&(e=o%4?64*e+a:a,o++%4)?n+=String.fromCharCode(255&e>>(-2*o&6)):0)a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a);return n};class dn extends Error{constructor(e){super(e)}}const gn=(e,t={})=>{const n=t.header?0:1;try{return JSON.parse((e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("Illegal base64url string!")}try{return function(e){return decodeURIComponent(un(e).replace(/(.)/g,((e,t)=>{let n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return un(t)}})(e.split(".")[n]))}catch(e){throw new dn("Invalid token specified: "+e.message)}};let pn,yn,fn,Sn;!function(e){e.ALLOW="ALLOW",e.BLOCK="BLOCK"}(pn||(pn={})),function(e){e.WebAuthnPlatform="WebAuthnPlatform",e.WebAuthnCrossPlatform="WebAuthnCrossPlatform",e.SmsCode="SmsCode",e.SmsCodeV2="SmsCodeV2",e.Passkeys="Passkeys"}(yn||(yn={})),function(e){e.Platform="Platform",e.CrossPlatform="CrossPlatform"}(fn||(fn={})),function(e){e.AuthenticatorApp="AuthenticatorApp",e.WebAuthnPlatform="WebAuthnPlatform",e.WebAuthnCrossPlatform="WebAuthnCrossPlatform",e.SMS="SMS",e.EmailCode="EmailCode"}(Sn||(Sn={}));const hn="admin_portal_should_load_authorization";async function vn(){return tt(Ke)}let mn;!function(e){e.MISSING_PERMISSION="MISSING_PERMISSION",e.MISSING_FEATURE="MISSING_FEATURE",e.BUNDLE_EXPIRED="BUNDLE_EXPIRED"}(mn||(mn={}));const bn="admin_portal_entitlements",An=["type"],wn=["type"],Tn=["type"];async function En(e){if(!e.accessToken)return e;ne.setAccessToken(e.accessToken);const t=await yi(),n=j({},e,e.accessToken?gn(e.accessToken):{},t);return ne.setUser(n),n}async function In(e){if(!e.accessToken)return{user:e};ne.setAccessToken(e.accessToken);const[t,n]=await Promise.all([yi(),kt()]),a=j({},e,e.accessToken?gn(e.accessToken):{},t);return ne.setUser(a),{user:a,tenants:n}}function kn(){if(!ne.shouldLoadEntitlements())return!1;const[e]=ut.getFeatureFlags([bn],ne.getAppName()||"");return e}function On(){const[e]=ut.getFeatureFlags([hn],ne.getAppName()||"");return e}async function _n(e){const{accessToken:t}=e;if(!t)return{user:e};ne.setAccessToken(t);const[n,a]=await Promise.all([yi(),Et()()]),o=j({},e,t?gn(t):{},n);return ne.isSessionPerTenantEnabled()&&At(o.tenantId),ne.setUser(o),{user:o,tenants:a.tenants,activeTenant:a.activeTenant}}async function Pn(e){ne.setAccessToken(e.id_token);const t=await yi(),n=e.id_token?gn(e.id_token):{},a=j({mfaRequired:!1,accessToken:e.id_token,refreshToken:e.refresh_token},n,t,{expiresIn:e.expires_in||300});return ne.setUser(a),a}async function Un(e){ne.setAccessToken(e.id_token);const[t,n]=await Promise.all([yi(),Et()()]),a=e.id_token?gn(e.id_token):{},o=j({mfaRequired:!1,accessToken:e.id_token,refreshToken:e.refresh_token},a,t,{expiresIn:e.expires_in||300});return ne.isSessionPerTenantEnabled()&&At(o.tenantId),ne.setUser(o),{user:o,tenants:n.tenants,activeTenant:n.activeTenant}}async function Ln(e){try{const{address:t}=await nt(`${de.v1}/user/saml/prelogin`,e);return t}catch{return null}}async function Dn(e){return nt(`${de.v1}/user/saml/prelogin`,e)}async function Rn(e){return En(await nt(`${de.v1}/user/saml/postlogin`,e))}async function Cn(e){return En(await nt(`${de.v1}/user/oidc/postlogin`,e))}async function Nn(e){return En(await nt(`${de.v1}/user`,e))}async function Mn(e){return _n(await nt(`${de.v1}/user`,e))}async function Fn(e){return En(await nt(`${de.v1}/user/mfa/verify`,e))}async function $n(e){return _n(await nt(`${de.v1}/user/mfa/verify`,e))}async function jn(e){return nt(`${ge.v1}/activate`,e)}async function Gn(e){return _n(await nt(`${ge.v1}/activate`,e))}async function xn(e){return tt(`${ge.v1}/activate/strategy`,e)}async function Vn(e){return nt(`${ge.v1}/activate/reset`,e)}async function Bn(e){return nt(`${ge.v1}/invitation/reset`,e)}async function Wn(e){return nt(`${ge.v1}/invitation/accept`,e)}async function zn(){const e=Tt();return En(await nt(`${de.v1}/user/token/refresh`,{tenantId:e}))}async function Kn(){const e=Tt();return In(await nt(`${de.v1}/user/token/refresh`,{tenantId:e}))}async function Hn(){const e=Tt();return _n(await nt(`${de.v1}/user/token/refresh`,{tenantId:e}))}async function qn(){return nt(`${de.v1}/logout`)}async function Jn(e){return tt(`${Ve}/logout`,e)}async function Yn(e){return nt(`${ge.v1}/passwords/reset`,e)}async function Xn(e){return nt(`${ge.v1}/passwords/reset/verify`,e)}async function Qn(e){return tt(`${ge.v1}/passwords/config`,e)}async function Zn(e){return nt(`${de.v1}/user/mfa/recover`,e)}async function ea(){return nt(`${ge.v1}/mfa/enroll`)}async function ta(){return nt(`${ge.v1}/mfa/authenticator/enroll`)}async function na(e){return nt(`${ge.v1}/mfa/authenticator/enroll/verify`,e)}async function aa(e){return nt(`${ge.v1}/mfa/sms/enroll`,e)}async function oa(e){return nt(`${ge.v1}/mfa/sms/enroll/verify`,e)}async function ia(){return nt(`${ge.v1}/mfa/webauthn/enroll`)}async function sa(e){return nt(`${ge.v1}/mfa/webauthn/enroll/verify`,e)}async function ra(e){return nt(`${ge.v1}/mfa/enroll/verify`,e)}async function la(e){return nt(`${ge.v1}/mfa/disable`,e)}async function ca(e,t){return nt(`${ge.v1}/mfa/authenticator/${e}/disable/verify`,t)}async function ua(e){return nt(`${ge.v1}/mfa/sms/${e}/disable`)}async function da(e,t){return nt(`${ge.v1}/mfa/sms/${e}/disable/verify`,t)}async function ga(e){return nt(`${ge.v1}/mfa/webauthn/${e}/disable`)}async function pa(e,t){return nt(`${ge.v1}/mfa/webauthn/${e}/disable/verify`,t)}async function ya(){return tt(`${ge.v1}/mfa/devices`)}async function fa(e){return nt(`${de.v1}/user/mfa/authenticator/enroll`,e)}async function Sa(e){return nt(`${de.v1}/user/mfa/authenticator/enroll/verify`,e)}async function ha(e){return _n(await nt(`${de.v1}/user/mfa/authenticator/enroll/verify`,e))}async function va(e,t){return nt(`${de.v1}/user/mfa/authenticator/${e}/verify`,t)}async function ma(e){return nt(`${de.v1}/user/mfa/emailcode`,e)}async function ba(e){return nt(`${de.v1}/user/mfa/emailcode/verify`,e)}async function Aa(e){return _n(await nt(`${de.v1}/user/mfa/emailcode/verify`,e))}async function wa(e){return nt(`${de.v1}/user/mfa/sms/enroll`,e)}async function Ta(e){return nt(`${de.v1}/user/mfa/sms/enroll/verify`,e)}async function Ea(e){return _n(await nt(`${de.v1}/user/mfa/sms/enroll/verify`,e))}async function Ia(e,t){return nt(`${de.v1}/user/mfa/sms/${e}`,t)}async function ka(e,t){return nt(`${de.v1}/user/mfa/sms/${e}/verify`,t)}async function Oa(e,t){return _n(await nt(`${de.v1}/user/mfa/sms/${e}/verify`,t))}async function _a(e){return nt(`${de.v1}/user/mfa/webauthn/enroll`,e)}async function Pa(e){return nt(`${de.v1}/user/mfa/webauthn/enroll/verify`,e)}async function Ua(e){return _n(await nt(`${de.v1}/user/mfa/webauthn/enroll/verify`,e))}async function La(e,t){return nt(`${de.v1}/user/mfa/webauthn/${e}`,t)}async function Da(e,t){return nt(`${de.v1}/user/mfa/webauthn/${e}/verify`,t)}async function Ra(e,t){return _n(await nt(`${de.v1}/user/mfa/webauthn/${e}/verify`,t))}async function Ca(){return tt(`${Ee.v1}/saml/configurations`)}async function Na(e){return nt(`${Ee.v1}/saml/configurations`,e)}async function Ma(){return tt(`${Ee.v1}/saml/configurations/vendor-config`)}async function Fa(e){return ot(`${Ee.v1}/saml/configurations/metadata`,e)}async function $a(){return ot(`${Ee.v1}/saml/validations/domain`)}async function ja(){return tt(`${Ee.v1}/saml/configurations/roles/default`)}async function Ga(){return tt(`${Ee.v2}/saml/configurations/groups`)}async function xa({roleIds:e}){return nt(`${Ee.v1}/saml/configurations/roles/default`,{roleIds:e})}async function Va({roleIds:e,group:t}){return nt(`${Ee.v2}/saml/configurations/groups`,{group:t,roleIds:e})}async function Ba({roleIds:e,group:t,id:n}){return at(`${Ee.v2}/saml/configurations/groups/${n}`,{group:t,roleIds:e})}async function Wa({id:e}){return it(`${Ee.v2}/saml/configurations/groups/${e}`)}async function za(){return tt(`${Ee.v1}/oidc/configurations`)}async function Ka(){return tt(`${Ee.v2}/configurations/public`)}async function Ha(){return tt(fe.v1)}async function qa(){return tt(fe.v2)}async function Ja(){return tt(`${fe.v2}/authenticated`)}async function Ya(){return tt(fe.custom.v1)}async function Xa({provider:e,code:t,idToken:n,redirectUri:a,codeVerifier:o,metadata:i,invitationToken:s,state:r}){const l={};return t&&(l.code=t),n&&(l.id_token=n),a&&(l.redirectUri=a),o&&(l.code_verifier=o),r&&(l.state=r),nt(`${de.v1}/user/sso/${e}/postlogin`,{metadata:i,invitationToken:s},{params:l})}async function Qa(){return tt(`${pe.v1}/public`)}async function Za(e){const{shouldActivate:t,authResponse:n,userId:a,tenantId:o}=await nt(`${ge.v1}/signUp`,e),i={shouldActivate:t,userId:a,tenantId:o};if(!t&&n){const{user:e,tenants:t,activeTenant:a}=await _n(n);return j({},i,{user:e,tenants:t,activeTenant:a})}return i}async function eo(){return tt(ge.sessions.currentUser.v1)}async function to(){return tt(`${ge.sessions.currentUser.v1}/current`)}async function no(e){return nt(`${ge.sessions.v1}/revoke`,{userId:e})}async function ao(){return tt(ge.sessions.configurations.v1)}async function oo(e){await nt(ge.sessions.configurations.v1,e)}async function io(e){await it(`${ge.sessions.currentUser.v1}/${e}`)}async function so(){await it(`${ge.sessions.currentUser.v1}/all`)}async function ro(){return tt(ge.accessTokens.v1)}async function lo(){return tt(he.accessTokens.v1)}async function co({id:e}){return it(`${he.accessTokens.v1}/${e}`)}async function uo({id:e}){return it(`${ge.accessTokens.v1}/${e}`)}async function go(e){return nt(ge.accessTokens.v1,e)}async function po(e){return nt(he.accessTokens.v1,e)}async function yo(){return tt(ge.apiTokens.v1)}async function fo(){return tt(he.apiTokens.v1)}async function So(e){return nt(ge.apiTokens.v1,e)}async function ho(e){return nt(he.apiTokens.v2,e)}async function vo({tokenId:e}){return it(`${he.apiTokens.v1}/${e}`)}async function mo({tokenId:e}){return it(`${ge.apiTokens.v1}/${e}`)}async function bo({userId:e}){return tt(`${ge.v1}/${e}`)}async function Ao(e){return tt(`${pe.v1}/mfa-policy/allow-remember-device`,{mfaToken:e})}async function wo(e){let{type:t}=e,n=oe(e,An);return nt(`${de.v1}/passwordless/${t.toLocaleLowerCase()}/prelogin`,n)}async function To(e){let{type:t}=e,n=oe(e,wn);return _n(await nt(`${de.v1}/passwordless/${t.toLocaleLowerCase()}/postlogin`,n))}async function Eo(e){let{type:t}=e,n=oe(e,Tn);return nt(`${de.v1}/passwordless/${t.toLocaleLowerCase()}/postlogin`,n)}async function Io({token:e}){return nt(he.invites.verify.v1,{token:e})}async function ko(){return tt(`${Ee.v1}/configurations`)}async function Oo(e){return nt(`${Ee.v1}/configurations`,e)}async function _o(e,t){return at(`${Ee.v1}/configurations/${e}`,t)}async function Po(e){return it(`${Ee.v1}/configurations/${e}`)}async function Uo(e){return nt(`${Ee.v1}/configurations/metadata`,e)}async function Lo(e,t){return ot(`${Ee.v1}/configurations/${e}/metadata`,t)}async function Do(e){return nt(`${Ee.v1}/configurations/metadata-url`,e)}async function Ro(e,t){return ot(`${Ee.v1}/configurations/${e}/metadata-url`,t)}async function Co(e,t){return nt(`${Ee.v1}/configurations/${e}/domains`,t)}async function No(e,t){return it(`${Ee.v1}/configurations/${e}/domains/${t}`)}async function Mo(e,t){return ot(`${Ee.v1}/configurations/${e}/domains/${t}/validate`)}async function Fo(e,t){return ot(`${Ee.v2}/configurations/${e}/domains/${t}/validate`)}async function $o(e){return tt(`${Ee.v1}/configurations/${e}/roles`)}async function jo(e,t){return ot(`${Ee.v1}/configurations/${e}/roles`,t)}async function Go(e,t){return nt(`${Ee.v1}/configurations/${e}/groups`,t)}async function xo(e,{roleIds:t,group:n,id:a}){return at(`${Ee.v1}/configurations/${e}/groups/${a}`,{group:n,roleIds:t})}async function Vo(e,t){return it(`${Ee.v1}/configurations/${e}/groups/${t}`)}async function Bo(e){return tt(`${Ee.v1}/configurations/${e}/groups`)}async function Wo(e){return nt(`${de.v2}/user/sso/prelogin`,e)}async function zo(e){return En(await nt(`${de.v2}/user/oidc/postlogin`,e))}async function Ko(e){return Un(await nt(`${Ve}/token`,e))}async function Ho(){const e=Tt();return Un(await nt(`${Ve}/authorize/silent`,{tenantId:e}))}async function qo(e){return Pn(await nt(`${Ve}/token`,e))}async function Jo(){const e=Tt();return Pn(await nt(`${Ve}/authorize/silent`,{tenantId:e}))}async function Yo(e){return nt(`${ge.v1}/phone/reset`,e)}async function Xo(e){return nt(`${ge.v1}/phone/reset/verify`,e)}async function Qo(e){return nt(`${ge.v1}/phone`,e)}async function Zo(e){return nt(`${ge.v1}/phone/verify`,e)}async function ei(e){return ot(`${ge.v1}/phone/change`,e)}async function ti(e){return nt(`${de.v1}/webauthn/prelogin`,e)}async function ni(e){return nt(`${de.v1}/webauthn/postlogin`,e)}async function ai(e){return _n(await nt(`${de.v1}/webauthn/postlogin`,e))}async function oi(){return nt(ue.v1)}async function ii(){return tt(ue.v1)}async function si(e){return it(`${ue.v1}/${e}`)}async function ri(e){return nt(`${ue.v1}/verify`,e)}async function li(){return tt(`${pe.v1}/auth/strategies/public`)}async function ci(){return tt(`${pe.v1}/auth/strategies`)}async function ui(){return tt(`${pe.v1}/mfa/strategies`)}async function di(){return tt(`${ge.authorization.v1}`)}async function gi(){return tt(`${ge.v2}/me`)}const pi=async()=>{try{return await vn()}catch(e){}};async function yi(){const e=[{action:gi,shouldLoad:!0},{action:pi,shouldLoad:kn()},{action:di,shouldLoad:On()}].map((e=>async function({shouldLoad:e,action:t}){if(e)return await t()}(e))),[t,n,a]=await Promise.all(e),o=Tt();return o&&(t.tenantId=o),j({},t,null!=a?a:{},{entitlements:n})}async function fi(e){const t=await nt(`${de.v1}/user/step-up/generate`,e);return t.accessToken?_n(t):t}async function Si(e){return tt(`${ge.v2}/me`,null!=e?e:{addRoles:!0})}async function hi(e){return ot(`${ge.v2}/me`,e)}async function vi(e){return ot(`${_e.v1}/me/image/v1`,e,{responseType:"plain",contentType:void 0})}async function mi(e){return nt(`${ge.v1}/passwords/change`,e)}async function bi(e){var t,n,a,o,i,s;const r=(e.filter||[]).reduce(((e,t)=>j({},e,{[t.id]:t.value})),{}),l=null!=(t=e.sort)&&t.length?{sortBy:null!=(n=null==(a=e.sort)||null==(o=a[0])?void 0:o.id)?n:"name",sortDirection:null!=(i=e.sort)&&null!=(s=i[0])&&s.desc?"desc":"asc"}:null;return tt(Ie.v1,j({pageOffset:e.pageOffset,pageSize:e.pageSize},r,l))}async function Ai(e){return nt(ge.v2,j({},e,{provider:"local"}))}async function wi(e){return it(`${Ie.v1}/${e.userId}`)}async function Ti(e){return ot(Ie.v1,e)}async function Ei(e){const{userId:t,expirationInSeconds:n}=e;return ot(`${ge.temporary.v1}/${t}`,{expirationInSeconds:n})}async function Ii(e){return it(`${ge.temporary.v1}/${e}`)}async function ki(){return tt(ge.temporary.configuration.v1)}async function Oi(e){return nt(he.invites.user.v1,j({},e))}async function _i(e){return at(he.invites.user.v1,j({},e))}async function Pi(){return it(he.invites.user.v1)}async function Ui(){return tt(he.invites.user.v1)}async function Li(){return tt(he.invites.configuration.v1)}async function Di(){return tt(ke.v1)}async function Ri(){return tt(Se.v1)}async function Ci(){return tt(`${Oe.v1}/members`)}async function Ni(e){return nt(`${Ie.v1}/${e.userId}/resendActivationEmail`,{})}async function Mi(e){return nt(ge.v2,j({},e,{provider:"local"}))}async function Fi(e){return nt(ge.invitation.resendAll.v1,j({},e))}async function $i(e){var t,n;const a=await tt("/metadata",e);if(null!=a&&null!=(t=a.rows)&&t[0])return null==a||null==(n=a.rows)?void 0:n[0];throw new Error(`metadata not found: ${e.entityName}`)}async function ji(){return tt("/metadata/admin-box")}async function Gi(e){return nt("/metadata/admin-box",e)}async function xi(){const e=await tt("/metadata/ipme");if(e)return e;throw new Error("ip metadata not found")}const Vi=async()=>$i({entityName:"notifications"}),Bi=async()=>$i({entityName:"saml"}),Wi=async()=>$i({entityName:"audits"}),zi=async e=>async function(e){const t=await tt(`/metadata/ip/${e}`);if(t)return t;throw new Error("ip metadata not found")}(e),Ki=["dataFilters"],Hi=["templateId","dataFilters"],qi=["dataFilters"];async function Ji(e){return tt(`${Me.v2}/tenant-reports`,e)}async function Yi(e){return tt(`${Me.v2}/${e.id}/tenant-reports`)}async function Xi(e){let{dataFilters:t}=e,n=oe(e,Ki);return{html:await tt(`${Fe.v1}/preview-report`,j({},n,{dataFilters:btoa(JSON.stringify(t||{})),responseType:"html"}),{responseType:"plain"})}}async function Qi(e){let{templateId:t,dataFilters:n}=e,a=oe(e,Hi);return nt(`${Me.v2}/${t}/tenant-reports`,j({},a,{dataFilters:btoa(JSON.stringify(n||{}))}))}async function Zi(e){let{dataFilters:t}=e,n=oe(e,qi);const a=await tt(`${Fe.v1}/preview-report`,j({},n,{dataFilters:btoa(JSON.stringify(t||{}))}),{responseType:"blob"});let o="text/html",i="html";"pdf"===n.responseType?(o="application/pdf",i="pdf"):"image"===n.responseType&&(o="image/jpeg",i="jpg");const s=new Blob([a],{type:o}),r=URL.createObjectURL(s),l=document.createElement("a");l.href=r,l.setAttribute("download",`report_${n.name||""}.${i}`),l.click(),setTimeout(l.remove.bind(l))}async function es(e){return nt(`${Fe.v1}/tenant-reports`,e)}async function ts(e){return tt($e,{params:e})}async function ns(e){return ot(`${$e}/status`,{params:e})}async function as(e){const{notificationId:t,pinStatus:n}=e;return ot(`${$e}/${n}`,{notificationId:t})}async function os(){return nt(`${$e}/status/mark-all-read`)}const is=["endpoint","headerProps"];async function ss(e){return tt(je,e)}async function rs(e){return tt(`${je}/stats`,e)}async function ls(e){const{endpoint:t,headerProps:n}=e,a=oe(e,is);return st(`${je}/export/${t}`,{properties:n},a)}const cs=["eventKey"],us=["eventKey"],ds=()=>tt(`${De.v1}/slack`),gs=()=>tt(`${De.v1}/slack/applications`),ps=()=>tt(`${De.v1}/slack/channels`),ys=e=>e.id?at(`${De.v1}/slack/subscription/${e.id}`,e):nt(`${De.v1}/slack/subscriptions`,e),fs=e=>it(`${De.v1}/slack/subscriptions/${e.id}`),Ss=e=>nt(`${De.v1}/slack/applications/registrations`,{code:e}),hs=()=>tt(`${De.v1}/emails`),vs=e=>{let{eventKey:t}=e,n=oe(e,cs);return nt(`${De.v1}/emails/${t}`,n)},ms=({eventKey:e,enabled:t})=>at(`${De.v1}/emails/${e}`,{enabled:t}),bs=(e,t)=>it(`${De.v1}/emails/${e}/subscriptions/${t}`),As=(e,t,n)=>ot(`${De.v1}/emails/${t}/subscriptions/${e}`,n),ws=e=>it(`${De.v1}/emails/${e}`),Ts=()=>tt(`${De.v2}/sms`),Es=e=>{let{eventKey:t}=e,n=oe(e,us);return nt(`${De.v2}/sms/${t}`,n)},Is=({eventKey:e,enabled:t})=>at(`${De.v2}/sms/${e}`,{enabled:t}),ks=(e,t)=>it(`${De.v2}/sms/${e}/subscriptions/${t}`),Os=(e,t,n)=>ot(`${De.v2}/sms/${t}/subscriptions/${e}`,n),_s=e=>it(`${De.v2}/sms/${e}`),Ps=()=>tt(xe),Us=e=>e._id?at(`${xe}/${e._id}`,e):nt(`${xe}/custom`,e),Ls=e=>it(`${xe}/${e}`),Ds=(e,t=0,n=10)=>{const a=new URLSearchParams({id:e,offset:`${t}`,limit:`${n}`});return tt(`${xe}/logs/?${a.toString()}`)},Rs=e=>nt(`${xe}/test`,e),Cs=e=>nt(`${xe}/logs/${e}/retries`),Ns=()=>tt(`${Ge.v1}/categories`),Ms=e=>tt(Ge.v1,{channels:e});async function Fs(e,t){return ot(Pe.v1,e,{headers:rt(t)})}async function $s(e){return tt(Pe.v1,void 0,{headers:rt(e)})}async function js(){return tt(`${Pe.v1}/public`)}const Gs=["roleId"],xs=["roleId"],Vs=["permissionId"];async function Bs(){return tt(ve.v1)}async function Ws(e){return nt(ve.v1,e)}async function zs({roleId:e}){return it(`${ve.v1}/${e}`)}async function Ks(e){let{roleId:t}=e,n=oe(e,Gs);return at(`${ve.v1}/${t}`,n)}async function Hs(e){let{roleId:t}=e,n=oe(e,xs);return ot(`${ve.v1}/${t}/permissions`,n)}async function qs(){return tt(Se.v1)}async function Js(e){let{permissionId:t}=e,n=oe(e,Vs);return ot(`${Se.v1}/${t}/roles`,n)}async function Ys(){return tt(`${Se.v1}/categories`)}async function Xs(e){return nt(ve.v2,e)}async function Qs(){return tt(Re.subscriptions.v1)}async function Zs(e){return tt(`${Re.subscriptions.v1}/${e}`)}async function er(e){return ot(`${Re.subscriptions.v1}/${e}/cancellations/`,{})}async function tr(e){return ot(`${Re.subscriptions.v1}/${e}/renewals/`,{})}async function nr(e,{paymentMethodId:t,planId:n}){return ot(`${Re.subscriptions.v1}/${e}`,{paymentMethodId:t,planId:n})}async function ar(e){return tt(`${Ne.v1}/${e}`)}async function or(){return tt(`${Ne.v1}`)}async function ir(e){return ot(`${Ne.v1}/${e}/cancellations/`,{})}async function sr(e){return ot(`${Ne.v1}/${e}/renewals/`,{})}async function rr(e,{paymentMethodId:t,planId:n}){return ot(`${Ne.v1}/${e}`,{paymentMethodId:t,planId:n})}async function lr(){return tt(Re.plans.v1)}async function cr(e){return tt(`${Re.plans.v1}/${e}`)}async function ur(){return tt(Re.invoices.v1)}async function dr(e){return tt(`${Re.invoices.v1}/${e}`)}async function gr(e,t){return tt(`${Re.invoices.v1}/${e}/pdf`,{outputFileName:t},{responseType:"blob"})}const pr=["email"];async function yr(){return tt(Re.paymentMethods.v1)}async function fr(e){return tt(`${Re.paymentMethods.v1}/${e}`)}async function Sr(e,t){let{email:n}=t,a=oe(t,pr);return at(`${Re.paymentMethods.v1}/${e}/billing-details`,{email:n,address:a})}async function hr(e){return nt(Re.paymentProviders.stripe.subscriptions.v1,e)}async function vr(e){return tt(`${Re.paymentProviders.stripe.customers.v1}/${e}`)}async function mr(e){return nt(`${Re.paymentProviders.stripe.customers.v1}`,e)}async function br(){return tt(`${Re.paymentProviders.stripe.publicConfigurations.v1}`)}async function Ar(e){return nt(`${Re.paymentProviders.stripe.setupIntents.v1}`,e)}async function wr(e){return tt(`${Re.summaries.v1}/${e}`)}async function Tr(e){return tt(`${Re.tenantConfiguration.v1}/${e}`)}async function Er(e){return nt(`${Re.tenantConfiguration.v1}`,e)}async function Ir(){return tt(Ce.v1)}async function kr(){return tt(`${Re.configurations.vendorPublicConfigurations.v1}`)}let Or,_r,Pr,Ur,Lr,Dr;async function Rr({userId:e}){return tt(`${Ae.v1}/${e}/apps`)}async function Cr({userIds:e}){return tt(`${Ae.v1}/users-apps`,{userIds:e.join(",")})}async function Nr(){return tt(Ye.v1)}async function Mr({appIds:e,includeFreeAccess:t=!0}){return tt(Je,{ids:e.join(","),_includeFreeAccess:t})}async function Fr(e){return nt(`${Ae.v1}/apps-user`,e)}async function $r(e){return it(`${Ae.v1}/user-apps`,e)}async function jr({appIds:e}){return tt(`${Ae.v1}/apps-users`,{appIds:e.join(",")})}async function Gr(){return tt("/vendors/public")}async function xr(e){return tt(me.v1,e)}async function Vr(e){return nt(me.v1,e)}async function Br(e,t){return it(me.v1,e,{headers:rt(t)})}async function Wr(e,t,n){return nt(`${me.v1}/${e}/roles`,t,{headers:rt(n)})}async function zr(e,t,n){return it(`${me.v1}/${e}/roles`,t,{headers:rt(n)})}async function Kr(e,t,n){return at(`${me.v1}/${e}/roles`,t,{headers:rt(n)})}async function Hr(e,t){return nt(Le.v1,e,{headers:rt(t)})}async function qr(e,t){return it(`${Le.v1}/${e}`,void 0,{headers:rt(t)})}async function Jr({tenantId:e},t,n){return at(`${Le.v1}/${e}`,t,{headers:rt(n)})}async function Yr({tenantId:e},t,n){return ot(`${Le.v1}/${e}/management`,t,{headers:rt(n)})}async function Xr(e,t,n){return ot(`${me.v1}/${e}/access`,t,{headers:rt(n)})}async function Qr(e,t){return nt(`${me.v2}/`,e,{headers:rt(t)})}async function Zr(){return tt(`${We}`)}async function el(e,t){return at(`${We}/${e}`,t)}async function tl(e){return nt(`${We}`,e)}async function nl(e){return it(`${We}/${e}`)}async function al(e){return tt(`${ze}/${e}/Users/count`)}async function ol(e){return nt(`${be.v1}`,e)}!function(e){e.ACTIVE="active",e.CANCELED="canceled",e.INCOMPLETE="incomplete",e.EXPIRED="expired",e.TRIALING="trialing",e.TRIAL_ENDED="trialEnded"}(Or||(Or={})),function(e){e.UNKNWON="unknown",e.CARD="card"}(_r||(_r={})),function(e){e.AT_PERIOD_END="atPeriodEnd"}(Pr||(Pr={})),function(e){e.Stripe="Stripe"}(Ur||(Ur={})),function(e){e.CHANGE_TO_DEFAULT="change_to_default",e.RETAIN_TRIAL="retain_trial"}(Lr||(Lr={})),function(e){e.CREATE="create_customer"}(Dr||(Dr={}));const il=["groupId"];async function sl({groupId:e},t){return tt(`${we.v1}/${e}`,j({},t))}async function rl(e){return tt(`${we.v1}`,j({},e))}async function ll(e,t){return nt(`${we.getByIds.v1}`,e,{params:t})}async function cl(e){return nt(`${we.v1}`,e)}async function ul(e){let{groupId:t}=e,n=oe(e,il);return at(`${we.v1}/${t}`,n)}async function dl(e){return it(`${we.v1}/${e}`)}async function gl(e,t){return nt(`${we.v1}/${e}/roles`,t)}async function pl(e,t){return it(`${we.v1}/${e}/roles`,t)}async function yl(e,t){return nt(`${we.v1}/${e}/users`,t)}async function fl(e,t){return it(`${we.v1}/${e}/users`,t)}async function Sl(){return tt(`${we.configurations.v1}`)}async function hl(e){return nt(`${we.configurations.v1}`,e)}async function vl(){return tt(He.v1)}async function ml(){return tt(qe.v1)}async function bl(e){return tt(`${Te.v1}`,e)}async function Al(e){return nt(`${Te.v1}`,e)}async function wl(e){return it(`${Te.v1}/${e}`)}async function Tl(e){return nt(`${Te.v1}/preverify`,e)}async function El(e){return nt(`${Te.v1}/verify`,e)}async function Il(e,t){return nt(`${Te.v1}/${e}/delete/verify`,t)}let kl,Ol,_l,Pl;!function(e){e.FRONTEGG="frontegg",e.SCIM2="scim2"}(kl||(kl={})),function(e){e.createdAt="createdAt",e.name="name",e.tenantId="tenantId"}(Ol||(Ol={})),function(e){e.CUSTOMER="customer",e.SPAM="spam",e.TEST="test",e.RESELLER="reseller",e.HEADQUARTER="headquarter"}(_l||(_l={})),function(e){e.NEVER="NEVER",e.ALWAYS="ALWAYS",e.ASSIGNABLE="ASSIGNABLE"}(Pl||(Pl={}));const Ul=[/^(.*)\/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]*$/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],Ll=`${de.v1}/user/token/refresh`,Dl=`${Ve}/authorize/silent`,Rl=`${ge.v2}/me`,Cl=`${ge.v2}/me/tenants`,Nl=`${ge.v3}/me/tenants`,Ml=Ke;let Fl,$l,jl,Gl,xl;!function(e){e.FRONTEGG="frontegg",e.OKTA="okta",e.AZURE_AD="azure-ad",e.OTHER="other"}(Fl||(Fl={})),function(e){e.roles="roles",e.users="users",e.rolesAndUsers="rolesAndUsers"}($l||($l={})),function(e){e.FRONTEGG="frontegg",e.SCIM2="scim2"}(jl||(jl={})),function(e){e.createdAt="createdAt",e.name="name",e.email="email",e.id="id",e.verified="verified",e.isLocked="isLocked",e.provider="provider",e.tenantId="tenantId"}(Gl||(Gl={})),function(e){e.MFA_UNENROLLED="mfa-unenrolled",e.BREACHED_PASSWORDS="breached-passwords",e.INACTIVE="inactive"}(xl||(xl={}));const Vl=["local","saml","google","github","facebook","microsoft","scim2","slack"];let Bl,Wl,zl,Kl,Hl,ql;!function(e){e.FORCE_MFA="FORCE_MFA",e.BREACHED_PASSWORDS_EXIST="BREACHED_PASSWORDS_EXIST",e.ENABLE_USER_LOCKOUT="ENABLE_USER_LOCKOUT",e.STRENGTHEN_USER_LOCKOUT="STRENGTHEN_USER_LOCKOUT",e.ENABLE_PASSWORD_HISTORY="ENABLE_PASSWORD_HISTORY",e.STRENGTHEN_PASSWORD_HISTORY="STRENGTHEN_PASSWORD_HISTORY",e.ENABLE_FORCE_RELOGIN="ENABLE_FORCE_RELOGIN",e.SET_FORCE_RELOGIN="SET_FORCE_RELOGIN",e.ENABLE_SESSION_CONCURRENCY="ENABLE_SESSION_CONCURRENCY",e.SET_SESSION_CONCURRENCY="SET_SESSION_CONCURRENCY",e.ENABLE_IDLE_SESSION="ENABLE_IDLE_SESSION",e.SET_IDLE_SESSION="SET_IDLE_SESSION",e.ENABLE_IP_RESTRICTIONS="ENABLE_IP_RESTRICTIONS",e.CHANGE_IP_TO_ALLOWLIST="CHANGE_IP_TO_ALLOWLIST",e.ENABLE_DOMAIN_RESTRICTIONS="ENABLE_DOMAIN_RESTRICTIONS",e.CHANGE_DOMAIN_TO_ALLOWLIST="CHANGE_DOMAIN_TO_ALLOWLIST",e.CONFIGURE_SSO="CONFIGURE_SSO"}(Bl||(Bl={})),function(e){e.MFA_FORCED="MFA_FORCED",e.PARTIALLY_FORCED_MFA="PARTIALLY_FORCED_MFA",e.PARTIAL_MFA_USAGE="PARTIAL_MFA_USAGE",e.FULL_MFA_USAGE="FULL_MFA_USAGE",e.BREACHED_PASSWORD_USERS_EXIST="BREACHED_PASSWORD_USERS_EXIST",e.IMPROVE_LOCKOUT_POLICY="IMPROVE_LOCKOUT_POLICY",e.IMPROVE_PASSWORD_HISTORY_POLICY="IMPROVE_PASSWORD_HISTORY_POLICY",e.NO_SESSION_SETTINGS="NO_SESSION_SETTINGS",e.PARTIAL_SESSION_SETTINGS="PARTIAL_SESSION_SETTINGS",e.FULL_SESSION_SETTINGS="FULL_SESSION_SETTINGS",e.NO_IP_RESTRICTIONS="NO_IP_RESTRICTIONS",e.IP_ALLOWLIST="IP_ALLOWLIST",e.IP_DENYLIST="IP_DENYLIST",e.NO_DOMAIN_RESTRICTIONS="NO_DOMAIN_RESTRICTIONS",e.DOMAIN_ALLOWLIST="DOMAIN_ALLOWLIST",e.DOMAIN_DENYLIST="DOMAIN_DENYLIST",e.FULL_PASSWORD_SETTINGS="FULL_PASSWORD_SETTINGS"}(Wl||(Wl={})),function(e){e.SEND_RESET_BREACHED_PASSWORD_EMAIL="SEND_RESET_BREACHED_PASSWORD_EMAIL",e.ADJUST_FORCE_RELOGIN="ADJUST_FORCE_RELOGIN",e.ADJUST_MAX_CONCURRENT_SESSIONS="ADJUST_MAX_CONCURRENT_SESSIONS",e.ADJUST_IDLE_TIMEOUT="ADJUST_IDLE_TIMEOUT"}(zl||(zl={})),function(e){e.SEVERE="SEVERE",e.WARNING="WARNING",e.INFO="INFO"}(Kl||(Kl={})),function(e){e.MFA="MFA",e.SESSIONS="SESSIONS",e.PASSWORD="PASSWORD",e.INACTIVITY="INACTIVITY",e.IP="IP",e.DOMAIN="DOMAIN",e.SSO="SSO"}(Hl||(Hl={})),function(e){e.FREE_ACCESS="FREE_ACCESS",e.MANAGED_ACCESS="MANAGED_ACCESS"}(ql||(ql={}));const Jl={auth:l,teams:c,metadata:u,reports:d,connectivity:y,notifications:g,audits:p,tenants:s,accountSettings:f,roles:S,subscriptions:h,vendor:m,subTenants:b,featureFlags:o,directory:A,impersonate:w,groups:T,users:i,entitlements:r,securityCenter:E,userPhoneNumbers:I,applications:v},Yl={fetch:t,ContextHolder:ne,FronteggContext:ae,api:Jl,FronteggApiError:ce,AuthStrategyEnum:rn,MachineToMachineAuthStrategy:ln,SocialLoginProviders:sn,ISubscriptionCancellationPolicy:Pr,ISubscriptionStatus:Or,PaymentMethodType:_r,ProviderType:Ur},Xl=e=>JSON.parse(JSON.stringify(e)),Ql=(e=500)=>new Promise((t=>{setTimeout(t,e)})),Zl=async(e,t,n)=>{let a=0;for(;a<t-1;)try{return await e()}catch(e){if(a++,a>=t)throw e;await new Promise((e=>setTimeout(e,n)))}return await e()};function ec(e,t){const n=j({},e);return t.forEach((e=>{delete n[e]})),n}function tc(e){if(null==e)return;return function(e){const t=typeof e;return(null==e?void 0:e.constructor)==={}.constructor||"undefined"===t||null===e||"boolean"===t||"number"===t||"string"===t||e instanceof Date||e instanceof RegExp||e instanceof Blob||e instanceof File||e instanceof FileList||e instanceof ArrayBuffer||e instanceof ImageData||e instanceof ImageBitmap||e instanceof Array||e instanceof Map||e instanceof Set}(e)&&void 0!==e.__isProxy}let nc,ac,oc;!function(e){e.validate="validate",e.invalid="invalid",e.pending="pending",e.success="success",e.failed="failed"}(nc||(nc={})),function(e){e.activating="activating",e.success="success",e.resend="resend",e.activatingForm="activatingForm"}(ac||(ac={})),function(e){e.LOAD_API_TOKENS="LOAD_API_TOKENS",e.ADD_API_TOKEN="ADD_API_TOKEN",e.DELETE_API_TOKEN="DELETE_API_TOKEN"}(oc||(oc={}));var ic=n(9378),sc=n.n(ic),rc=n(9314);const lc=()=>{if(!ne.shouldLoadEntitlements())throw new Error("You must first enable entitlements via Frontegg options to use this function")},cc=(e,t,n,a)=>(lc(),(0,rc.wJ)(t,e,n)),uc=(e,t,n,a)=>(lc(),(0,rc.tE)(t,e,n)),dc=(e,t,n,a)=>"permissionKey"in t?cc(e,t.permissionKey,n):uc(e,t.featureKey,n);function gc(e,t){return sc()(e,t)}let pc,yc,fc,Sc,hc,vc,mc,bc,Ac,wc,Tc,Ec,Ic,kc,Oc,_c,Pc,Uc,Lc,Dc;!function(e){e.forgotPassword="forgotPassword",e.success="success"}(pc||(pc={})),function(e){e.CREATE_GROUP="CREATE_GROUP",e.GET_GROUP="GET_GROUP",e.GET_GROUPS="GET_GROUPS",e.DELETE_GROUP="DELETE_GROUP",e.UPDATE_GROUP="UPDATE_GROUP",e.ADD_USERS_TO_GROUP="ADD_USERS_TO_GROUP",e.DELETE_USERS_FROM_GROUP="DELETE_USERS_FROM_GROUP",e.ADD_ROLES_TO_GROUP="ADD_ROLES_TO_GROUP",e.DELETE_ROLES_FROM_GROUP="DELETE_ROLES_FROM_GROUP",e.GET_GROUP_CONFIGURATION="GET_GROUP_CONFIGURATION",e.UPDATE_GROUP_CONFIGURATION="UPDATE_GROUP_CONFIGURATION",e.GET_TEAM_USERS="GET_TEAM_USERS"}(yc||(yc={})),function(e){e.roles="roles",e.users="users",e.rolesAndUsers="rolesAndUsers"}(fc||(fc={})),function(e){e.impersonating="impersonating",e.success="success"}(Sc||(Sc={})),function(e){e.preLogin="preLogin",e.magicLinkPreLoginSuccess="magicLinkPreLoginSuccess",e.loginWithSmsOtc="loginWithSmsOtc",e.loginWithQuickSmsOtc="loginWithQuickSmsOtc",e.loginWithOtc="loginWithOtc",e.loginWithPassword="loginWithPassword",e.loginWithTwoFactor="loginWithTwoFactor",e.redirectToSSO="redirectToSSO",e.loginWithSSOFailed="loginWithSSOFailed",e.success="success",e.forceTwoFactor="forceTwoFactor",e.recoverTwoFactor="recoverTwoFactor",e.promptPasskeys="promptPasskeys",e.breachedPassword="breachedPassword",e.breachedPasswordSuccess="breachedPasswordSuccess"}(hc||(hc={})),function(e){e.Login="login",e.RegisterQuickLogin="registerQuickLogin"}(vc||(vc={})),function(e){e.Internal="internal",e.UsbKey="usb-key",e.Android="android",e.Sms="sms"}(mc||(mc={})),function(e){e["social-login"]="social-login",e["custom-social-login"]="custom-social-login",e.direct="direct"}(bc||(bc={})),function(e){e.verify="verify",e.recoveryCode="recoveryCode",e.authenticatorApp="authenticatorApp",e.smsSetPhoneNumber="smsSetPhoneNumber",e.smsVerifyCode="smsVerifyCode",e.emailVerifyCode="emailVerifyCode",e.noMFAEnrolledStepUp="noMFAEnrolledStepUp"}(Ac||(Ac={})),function(e){e.GET_ACCOUNTS="GET_ACCOUNTS",e.SEARCH_ACCOUNTS="SEARCH_ACCOUNTS",e.SET_ROOT_ACCOUNT_DATA="SET_ROOT_ACCOUNT_DATA",e.SET_SELECTED_SUB_ACCOUNT_DATA="SET_SELECTED_SUB_ACCOUNT_DATA",e.LOAD_NUMBER_OF_USERS_FOR_ACCOUNT="LOAD_NUMBER_OF_USERS_FOR_ACCOUNT",e.UPDATE_SUB_ACCOUNT_ACCESS_FOR_USER="UPDATE_SUB_ACCOUNT_ACCESS_FOR_USER",e.CREATE_SUB_ACCOUNT="CREATE_SUB_ACCOUNT",e.UPDATE_SUB_ACCOUNT="UPDATE_SUB_ACCOUNT",e.DELETE_SUB_ACCOUNT="DELETE_SUB_ACCOUNT",e.GET_ACCOUNT_USERS="GET_ACCOUNT_USERS",e.ADD_USERS_TO_ACCOUNT="ADD_USERS_TO_ACCOUNT",e.DELETE_USERS_FROM_ACCOUNT="DELETE_USERS_FROM_ACCOUNT",e.SET_USER_ROLES_FOR_SUB_ACCOUNT="SET_USER_ROLES_FOR_SUB_ACCOUNT",e.UPDATE_SUB_ACCOUNT_SETTINGS="UPDATE_SUB_ACCOUNT_SETTINGS",e.UPDATE_SUB_ACCOUNT_MANAGEMENT="UPDATE_SUB_ACCOUNT_MANAGEMENT",e.GET_USER_JWT="GET_USER_JWT",e.GET_TEAM_USERS="GET_TEAM_USERS"}(wc||(wc={})),function(e){e.ResetPhoneNumber="ResetPhoneNumber",e.VerifyResetPhoneNumber="VerifyResetPhoneNumber",e.ChangePhoneNumber="ChangePhoneNumber"}(Tc||(Tc={})),function(e){e.EDIT_ROLE_DIALOG="editRoleDialog",e.DELETE_ROLE_DIALOG="deleteRoleDialog",e.LOAD_ROLES="loadRoles",e.ADD_ROLE="addRole",e.MANAGE_PERMISSIONS="managePermissions"}(Ec||(Ec={})),function(e){e.RECOMMENDATIONS="recommendations",e.INSIGHTS="insights",e.SEND_BULK_RESET_BREACHED_PASSWORD_EMAILS="sendBulkResetBreachedPasswordEmails",e.SEND_BREACHED_PASSWORD_EMAIL="sendBreachedPasswordEmail",e.BREACHED_PASSWORD_USERS_TABLE="breachedPasswordUsersTable",e.UNENROLLED_MFA_USERS_TABLE="unenrolledMfaUsersTable",e.INACTIVE_USERS_TABLE="inactiveUsersTable"}(Ic||(Ic={})),function(e){e.SignUp="SignUp",e.SignUpSuccess="SignUpSuccess"}(kc||(kc={})),function(e){e.LOAD_SSO_CONFIGURATIONS="LOAD_SSO_CONFIGURATIONS",e.SAVE_SSO_CONFIGURATION="SAVE_SSO_CONFIGURATION",e.UPDATE_SSO_CONFIGURATION="UPDATE_SSO_CONFIGURATION",e.SAVE_SSO_CONFIGURATION_BY_METADATA="SAVE_SSO_CONFIGURATION_BY_METADATA",e.UPDATE_SSO_CONFIGURATION_BY_METADATA="UPDATE_SSO_CONFIGURATION",e.DELETE_SSO_CONFIGURATION="DELETE_SSO_CONFIGURATION",e.SAVE_SSO_DOMAIN="SAVE_SSO_DOMAIN",e.DELETE_SSO_DOMAIN="DELETE_SSO_DOMAIN",e.VALIDATE_SSO_DOMAIN="VALIDATE_SSO_DOMAIN",e.UPDATE_SSO_DEFAULT_ROLES="UPDATE_SSO_DEFAULT_ROLES",e.DELETE_SSO_GROUPS="DELETE_SSO_GROUPS",e.SAVE_SSO_GROUPS="SAVE_SSO_GROUPS",e.GET_SSO_AUTHORIZATION_ROLES="GET_SSO_AUTHORIZATION_ROLES"}(Oc||(Oc={})),function(e){e.Saml="saml",e.Okta="okta",e.Azure="azure",e.Google="google",e.Oidc="oidc"}(_c||(_c={})),function(e){e.USERS="USERS",e.STATS="STATS",e.UPDATE_USER="UPDATE_USER",e.DELETE_USER="DELETE_USER",e.RESEND_ACTIVATE_LINK="RESEND_ACTIVATE_LINK",e.RESEND_INVITATION_LINK="RESEND_INVITATION_LINK",e.ROLES_AND_PERMISSIONS="ROLES_AND_PERMISSIONS",e.CREATE_TOKEN_LINK="CREATE_TOKEN_LINK",e.GET_TOKEN_LINK="GET_TOKEN_LINK",e.UPDATE_TOKEN_LINK="UPDATE_TOKEN_LINK",e.DELETE_TOKEN_LINK="DELETE_TOKEN_LINK",e.CONFIG_TOKEN_LINK="CONFIG_TOKEN_LINK",e.CONFIG_TEMPORARY_USERS="CONFIG_TEMPORARY_USERS",e.UPDATE_USER_EXPIRATION_TIME="UPDATE_USER_EXPIRATION_TIME"}(Pc||(Pc={})),function(e){e.SOCIAL_LOGIN="SOCIAL_LOGIN",e.PASSWORDLESS="PASSWORDLESS",e.ACTIVATION_LINK="ACTIVATION_LINK"}(Uc||(Uc={})),function(e){e.SOCIAL_LOGIN="SOCIAL_LOGIN",e.PASSWORD="PASSWORD"}(Lc||(Lc={})),function(e){e.profile="profile",e.privacy="privacy",e.personalApiTokens="personalApiTokens",e.account="account",e.users="users",e.groups="groups",e.security="security",e.sso="sso",e.audits="audits",e.webhooks="webhooks",e.apiTokens="apiTokens",e.roles="roles",e.subscriptions="subscription",e.allAccounts="allAccounts"}(Dc||(Dc={}));const Rc={profile:Dc.profile,privacy:Dc.privacy,personalApiTokens:Dc.personalApiTokens,account:Dc.account,users:Dc.users,groups:Dc.groups,security:Dc.security,sso:Dc.sso,audits:Dc.audits,webhooks:Dc.webhooks,apiTokens:Dc.apiTokens,roles:Dc.roles,subscriptions:Dc.subscriptions,allAccounts:Dc.allAccounts};var Cc=n(9714),Nc=n.n(Cc);const Mc=(e,t)=>{const n=Nc()(e,j({},t));return J(j({__isProxy:!0},n))},Fc={step:nc.validate},$c=e=>Mc(Fc,e),jc=e=>e instanceof Error||(null==e?void 0:e.message)&&(null==e?void 0:e.stack)&&"Error"===(null==e?void 0:e.name),Gc=(e,t)=>e?(e=>Boolean(null==e?void 0:e.statusCode))(e)?e.message:(jc(e)?console.error(e.message):"string"==typeof e&&console.error(e),null!=t?t:"We're facing some difficulties, Please try again"):t,xc=(e,t,n)=>{const a=t=>(Object.assign(e.auth.acceptInvitationState,t),Q(e.auth.acceptInvitationState));return{setAcceptInvitationState:a,resetAcceptInvitationState:()=>{e.auth.acceptInvitationState=Xl(Fc)},acceptInvitation:async e=>{if(e.token&&e.userId)try{a({error:void 0,step:nc.pending}),await t.auth.acceptInvitation(e),a({step:nc.success})}catch(e){a({step:nc.failed,error:Gc(e)})}else a({error:void 0,step:nc.invalid})}}},Vc={loading:!1},Bc=e=>Mc(Vc,e),Wc=(e,t,n)=>{const a=t=>(Object.assign(e.auth.accountSettingsState,t),Q(e.auth.accountSettingsState));return{setAccountSettingsState:a,resetAccountSettingsState:()=>{e.auth.accountSettingsState=Xl(Vc)},saveAccountSettings:async n=>{try{var o;a({loading:!0});const{address:i,timezone:s,dateFormat:r,timeFormat:l,currency:c,logo:u}=e.auth.accountSettingsState,d=await t.accountSettings.updateSettings(j({address:i,timezone:s,dateFormat:r,timeFormat:l,currency:c,logo:u},n));a(j({},d,{loading:!1})),null==(o=n.callback)||o.call(n,d)}catch(e){var i;a({loading:!1,error:Gc(e)}),null==(i=n.callback)||i.call(n,null,e)}},loadAccountSettings:async e=>{a({loading:!(null!=e&&e.silentLoading),error:null});try{const e=await t.accountSettings.getSettings();a(j({},e,{loading:!1}))}catch(e){a({loading:!1,error:Gc(e)})}}}},zc={step:ac.activating,loading:!1,resentEmail:!1,activationStrategy:{loading:!1}},Kc=e=>Mc(zc,e);let Hc;function qc(e,t){var n,a;null==(n=(a=window).onFronteggEvent)||n.call(a,e,t)}!function(e){e.SIGNUP_COMPLETED="signup_completed",e.USER_VERIFIED="user_verified"}(Hc||(Hc={}));const Jc={[rn.Code]:hc.loginWithOtc,[rn.EmailAndPassword]:hc.loginWithPassword,[rn.MagicLink]:hc.magicLinkPreLoginSuccess,[rn.SmsCode]:hc.loginWithSmsOtc},Yc={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"},Xc=e=>{try{return new URL(e),!0}catch(e){return!1}},Qc=({authenticatedUrl:e,enforceRedirectToSameSite:t,allowedRedirectOrigins:n,includeQueryParam:a})=>{let o=e;const i=new URL(window.location.href).searchParams.get("redirectUrl");return i?t&&Xc(i)?((e,t)=>{const n=new URL(window.location.href),a=new URL(e),o=a.origin===n.origin;return t.includes(a.origin)||o})(i,n)?o=i:console.warn("The redirect url param is not valid, the origin is a different site"):o=i:a&&(o+=window.location.search),o},Zc=e=>{const{searchParams:t}=new URL(e),n=t.toString();if(n)return`?${n}`},eu=e=>{const{pathname:t}=new URL(e),n=Zc(e);return n?t+n:t},tu=e=>{const t=new URLSearchParams(window.location.search).get(e);return null!=t?t:void 0},nu="tenantId",au=e=>{const t=+Boolean(e.webauthn.length),n=+Boolean(e.phones.length),a=+Boolean(e.authenticators.length),o=+Boolean(e.emails.length);return{numberOfWebAuthnDevices:t,numberOfPhoneDevices:n,numberOfAuthenticators:a,numberOfEmails:o,totalDevices:t+n+a+o}},ou=e=>{const{numberOfPhoneDevices:t,numberOfAuthenticators:n,numberOfEmails:a,totalDevices:o}=au(e);if(1===o){if(n)return Ac.authenticatorApp;if(t)return Ac.smsVerifyCode;if(a)return Ac.emailVerifyCode}return Ac.verify},iu=e=>{if(1===e.length){const[t]=e;if(t===Sn.AuthenticatorApp)return Ac.authenticatorApp;if(t===Sn.SMS)return Ac.smsSetPhoneNumber;if(t===Sn.EmailCode)return Ac.emailVerifyCode}return Ac.verify},su=e=>"/oauth/callback"===e;function ru(e){return"email"in e}const lu="http://schemas.openid.net/pape/policies/2007/06/multi-factor",cu="mfa",uu=["otp","sms","hwk"],du="SHOULD_STEP_UP",gu="maxAge",pu="FRONTEGG_AFTER_AUTH_REDIRECT_URL",yu="HOSTED_LOGIN_VERIFIER_KEY",fu=(e,{maxAge:t}={})=>{if(!e)return!1;const{amr:n=[],acr:a="",auth_time:o}=e;if(t&&o&&!(Date.now()/1e3-o<=t))return!1;const i=a===lu,s=-1!==n.indexOf(cu),r=void 0!==uu.find((e=>n.indexOf(e)));return i&&s&&r};function Su(){const e=window.location.pathname+window.location.search;window.localStorage.setItem(pu,e)}const hu=(e,t,n)=>{Su();const a=new URLSearchParams(window.location.search);n&&a.set(gu,n.toString()),t(`${e}${a?`?${a}`:""}`,{refresh:!1})},vu=["phoneNumber"],mu=["authenticatedUrl"],bu=e=>e.mfaRequired&&e.mfaToken?(ne.setAccessToken(null),ne.setUser(null),!0):(ne.setAccessToken(e.accessToken),ne.setUser(e),!1),Au=(e,t=[])=>Object.entries(e).reduce(((e,[n,a])=>"object"==typeof a?[...e,...Au(a,[...t,n])]:[...e,{type:[...t,n].join("/"),payload:a}]),[]),wu=e=>{var t;if("path"===e)return(null!=(t=window)?t:document).location.pathname;{var n;const e=((null!=(n=window)?n:document).location.hash||"#").substring(1);return-1!==e.indexOf("?")?e.substring(0,e.indexOf("?")):e}},Tu=e=>oe(e,vu),Eu=(e,t)=>{const n=oe(j({},Yc,t),mu);return Object.values(n).includes(e)},Iu=["callback","events"],ku=["user"],Ou=["callback"],_u=["callback"],Pu=(e,t,n)=>{const a=n,o=t=>(Object.assign(e.auth.activateAccountState,t),Q(e.auth.activateAccountState)),i=()=>{e.auth.activateAccountState=Xl(zc)},s=t=>{Object.assign(e.auth.activateAccountState.activationStrategy,t)};return{setActivateState:o,resetActivateState:i,setActivateStrategyState:s,activateAccount:async n=>{const{callback:s,events:r}=n,l=oe(n,Iu);o({loading:!0});try{const n=ne.onRedirectTo,u=e.auth.routes,d=await t.auth.activateAccountV2(l),{user:g}=d,p=oe(d,ku);if(g.redirectLocation)return void(window.location.href=g.redirectLocation);if(bu(g)){o({step:ac.success});const e=await a.getMfaRequiredState(g);a.setAuthState(e),await Ql(1e3),n(u.loginUrl,{preserveQueryParams:!0})}else{var c;o({step:ac.success});const e={email:g.email,origin:Uc.ACTIVATION_LINK,id:g.id,tenantId:g.tenantId,name:g.name,createdAt:new Date};null==r||null==(c=r.userVerified)||c.call(r,e),qc(Hc.USER_VERIFIED,e),await a.__afterAuthenticationStateUpdate(j({user:g},p),{isAuthenticated:!0}),await Ql(1e3),await a.afterAuthNavigation(),i()}null==s||s(!0)}catch(e){o({loading:!1,error:Gc(e)})}},preActivateAccount:async n=>{const{userId:i,token:r}=n;o({loading:!0,step:ac.activating});try{e.auth.isAuthenticated&&await a.silentLogout();const n=await t.auth.getActivateAccountStrategy({userId:i,token:r});s({strategy:n,loading:!1,error:void 0}),n.shouldSetPassword&&o({loading:!1,step:ac.activatingForm})}catch(e){o({loading:!1,error:Gc(e)})}},getActivateAccountStrategy:async e=>{const{callback:n}=e,a=oe(e,Ou);s({loading:!0});try{const e=await t.auth.getActivateAccountStrategy(a);s({strategy:e,loading:!1,error:void 0}),null==n||n(e)}catch(e){s({loading:!1,error:Gc(e)})}},resendActivationEmail:async e=>{const{callback:n}=e,i=oe(e,_u);a.setTeamLoader({key:Pc.RESEND_ACTIVATE_LINK,value:i.email}),o({loading:!0});try{await t.auth.resendActivationEmail(i),o({loading:!1,error:void 0,resentEmail:!0}),null==n||n(!0)}catch(e){o({loading:!1,error:Gc(e)}),null==n||n(null,e)}finally{a.setTeamLoader({key:Pc.RESEND_ACTIVATE_LINK,value:!1})}}}},Uu={apiTokenType:null,searchValue:"",showAddTokenDialog:!1,createdByUserIdColumn:"show",deleteTokenDialog:{open:!1,clientId:""},successDialog:{open:!1,secret:"",clientId:""},loaders:{},apiTokensDataTenant:[],apiTokensDataUser:[],roles:[],permissions:[],errors:{}},Lu=e=>Mc(Uu,e),Du=(e,t,n)=>{const a=t=>{Object.assign(e.auth.apiTokensState,{loaders:j({},e.auth.apiTokensState.loaders,{[t.key]:t.value})})},o=t=>{Object.assign(e.auth.apiTokensState,{errors:j({},e.auth.apiTokensState.errors,{[t.key]:t.value}),loaders:j({},e.auth.apiTokensState.loaders,{[t.key]:!1})})},i=t=>{Object.assign(e.auth.apiTokensState,t)};return{setApiTokensLoader:a,setApiTokensError:o,setApiTokensState:i,resetApiTokensState:()=>{e.auth.apiTokensState=Xl(Uu)},loadApiTokens:async e=>{null!=e&&e.silentLoading||a({key:oc.LOAD_API_TOKENS,value:!0});try{var n;const[o=[],s=[]]=await Promise.all([t.auth.getUserApiTokensData(),t.auth.getTenantApiTokensData()]);i({apiTokensDataUser:o,apiTokensDataTenant:s}),a({key:oc.LOAD_API_TOKENS,value:!1}),null==e||null==(n=e.callback)||n.call(e,!0)}catch(t){var s;o({key:oc.LOAD_API_TOKENS,value:Gc(t)}),a({key:oc.LOAD_API_TOKENS,value:!1}),null==e||null==(s=e.callback)||s.call(e,null,t)}},loadUserApiTokens:async e=>{null!=e&&e.silentLoading||a({key:oc.LOAD_API_TOKENS,value:!0});try{var n,s;const[o=[],r]=await Promise.all([t.auth.getUserApiTokensData(),t.auth.getUserAccessTokensData()]),l=(null!=(n=r.accessTokens)?n:[]).map((e=>j({},e,{type:ln.AccessToken}))).concat(o.map((e=>j({},e,{type:ln.ClientCredentials})))).sort(((e,t)=>new Date(t.createdAt)-new Date(e.createdAt)));i({apiTokensDataUser:null!=l?l:[]}),a({key:oc.LOAD_API_TOKENS,value:!1}),null==e||null==(s=e.callback)||s.call(e,!0)}catch(t){var r;o({key:oc.LOAD_API_TOKENS,value:Gc(t)}),a({key:oc.LOAD_API_TOKENS,value:!1}),null==e||null==(r=e.callback)||r.call(e,null,t)}},loadTenantApiTokens:async e=>{null!=e&&e.silentLoading||a({key:oc.LOAD_API_TOKENS,value:!0});try{var n,s;const[o=[],r]=await Promise.all([t.auth.getTenantApiTokensData(),t.auth.getTenantAccessTokensData()]),l=(null!=(n=null==r?void 0:r.accessTokens)?n:[]).map((e=>j({},e,{type:ln.AccessToken}))).concat(o.map((e=>j({},e,{type:ln.ClientCredentials})))).sort(((e,t)=>new Date(t.createdAt)-new Date(e.createdAt)));i({apiTokensDataTenant:null!=l?l:[]}),a({key:oc.LOAD_API_TOKENS,value:!1}),null==e||null==(s=e.callback)||s.call(e,!0)}catch(t){var r;o({key:oc.LOAD_API_TOKENS,value:Gc(t)}),a({key:oc.LOAD_API_TOKENS,value:!1}),null==e||null==(r=e.callback)||r.call(e,null,t)}},addTenantApiToken:async n=>{const{description:s,roleIds:r,expires:l,callback:c}=n,u=oc.ADD_API_TOKEN;a({key:u,value:!0});try{const{policy:n}=e.auth.securityPolicyState.publicPolicy,o=(null==n?void 0:n.machineToMachineAuthStrategy)===ln.AccessToken;let d,g=null;l&&(g=1440*l),d=o?await t.auth.createTenantAccessToken({description:s,expiresInMinutes:g,roleIds:r}):await t.auth.updateTenantApiTokensData({description:s,roleIds:r,expiresInMinutes:g}),i({showAddTokenDialog:!1}),await Ql(200);const p=o?ln.AccessToken:ln.ClientCredentials;e.auth.apiTokensState.apiTokensDataTenant.unshift(j({},d,{type:p})),e.auth.apiTokensState.successDialog={open:!0,secret:d.secret,clientId:o?void 0:d.clientId},null==c||c(null)}catch(e){o({key:u,value:Gc(e)}),null==c||c(null,e)}finally{a({key:u,value:!1})}},addUserApiToken:async n=>{const{description:s,expires:r,callback:l}=n,c=oc.ADD_API_TOKEN;a({key:c,value:!0});try{const{policy:n}=e.auth.securityPolicyState.publicPolicy,o=(null==n?void 0:n.machineToMachineAuthStrategy)===ln.AccessToken;let u,d=null;r&&(d=1440*r),u=o?await t.auth.createUserAccessToken({description:s,expiresInMinutes:d}):await t.auth.updateUserApiTokensData({description:s,expiresInMinutes:d}),i({showAddTokenDialog:!1}),await Ql(200);const g=o?ln.AccessToken:ln.ClientCredentials;e.auth.apiTokensState.apiTokensDataUser.unshift(j({},u,{type:g})),e.auth.apiTokensState.successDialog={open:!0,secret:u.secret,clientId:o?void 0:u.clientId},null==l||l(null)}catch(e){o({key:c,value:Gc(e)}),null==l||l(null,e)}finally{a({key:c,value:!1})}},deleteUserApiToken:async n=>{const s=oc.DELETE_API_TOKEN;a({key:s,value:!0});try{const o=e.auth.apiTokensState.apiTokensDataUser;o.some((e=>e.id===n))?(await t.auth.deleteUserAccessToken({id:n}),i({apiTokensDataUser:o.filter((e=>e.id!==n)),deleteTokenDialog:{open:!1,id:n}})):(await t.auth.deleteUserApiToken({tokenId:n}),i({apiTokensDataUser:o.filter((e=>e.clientId!==n)),deleteTokenDialog:{open:!1,clientId:n}}))}catch(e){o({key:s,value:Gc(e)})}finally{a({key:s,value:!1})}},deleteTenantApiToken:async n=>{const s=oc.DELETE_API_TOKEN;a({key:s,value:!0});try{const o=e.auth.apiTokensState.apiTokensDataTenant;o.some((e=>e.id===n))?(await t.auth.deleteTenantAccessToken({id:n}),i({apiTokensDataTenant:o.filter((e=>e.id!==n)),deleteTokenDialog:{open:!1,id:n}})):(await t.auth.deleteTenantApiToken({tokenId:n}),i({apiTokensDataTenant:o.filter((e=>e.clientId!==n)),deleteTokenDialog:{open:!1,id:n}}))}catch(e){o({key:s,value:Gc(e)})}finally{a({key:s,value:!1})}}}},Ru={loading:!0,fetching:!0,error:null,userApplications:[],accountApplications:[]},Cu=e=>Mc(Ru,e),Nu=e=>{var t;return null!=(t=e.map((({appIds:e})=>e)).reduce(((e,t)=>(null==t||t.forEach((t=>{e&&!e.includes(t)&&e.push(t)})),e)),[]))?t:[]},Mu=(e,t,n)=>{const a=t=>{Object.assign(e.auth.applicationsState,t)},o=async({userIds:e})=>{try{const n=await t.applications.getUsersApplicationsId({userIds:e}),a=Nu(n),o=await t.applications.getApplicationsData({appIds:a});return e.reduce(((e,t)=>{var a,i,s;const r=null==(a=n.find((e=>e.userId==t)))?void 0:a.appIds;return e[t]=[...o.filter((e=>e.accessType===ql.FREE_ACCESS)),...null!=(i=null==r||null==(s=r.map((e=>o.find((t=>e===t.id)))))?void 0:s.filter((e=>!!e)))?i:[]],e}),{})}catch(e){a({error:Gc(e)})}},i="Assignment action failed. Try again or contact support.";return{setApplicationsState:a,resetApplicationsState:()=>{e.auth.applicationsState=Xl(Ru)},loadUserApplications:async()=>{a({loading:!0,fetching:!0});try{var n,o;const i=null!=(n=null==(o=e.auth.user)?void 0:o.id)?n:"",s=await t.applications.getUserApplicationsId({userId:i}),r=await t.applications.getApplicationsData({appIds:s});a({userApplications:r,fetching:!1,loading:!1})}catch(e){a({loading:!1,fetching:!1,error:Gc(e)})}},loadAccountApplications:async()=>{a({loading:!0,fetching:!0});try{const e=await t.applications.getTenantsApplications(),n=Nu(e),o=await t.applications.getApplicationsData({appIds:n}),i=await t.applications.getUsersOfApplications({appIds:n}),s=o.map((e=>{var t;return j({},e,{userIds:null==(t=i.find((t=>t.appId===e.id)))?void 0:t.userIds})}));a({accountApplications:s,fetching:!1,loading:!1})}catch(e){a({loading:!1,fetching:!1,error:Gc(e)})}},loadMultipleUsersApplications:o,assignUserToApps:async o=>{const{userId:s,appIds:r,callback:l}=o;try{var c,u,d,g,p,y,f,S,h;const a=null!=(c=null==(u=e.auth)||null==(d=u.user)?void 0:d.tenantId)?c:"";await t.applications.assignUserToApplications({userId:s,appIds:r,tenantId:a});const o=null==(g=e.auth)||null==(p=g.applicationsState)?void 0:p.accountApplications,i=null!=(y=null==(f=e.auth)||null==(S=f.teamState)?void 0:S.users)?y:[],v=null!=(h=null==o?void 0:o.filter((e=>r.includes(e.id))))?h:[];null!=v&&v.length&&n.setTeamState({users:i.map((e=>{var t;return e.id===s?j({},e,{applications:[...null!=(t=e.applications)?t:[],...v]}):e}))}),null==l||l(!0)}catch(e){a({error:Gc(e,i)}),null==l||l(!1)}},unassignUserFromApps:async o=>{const{userId:s,appIds:r,callback:l}=o;try{var c,u,d,g,p,y,f;const a=null!=(c=null==(u=e.auth)||null==(d=u.user)?void 0:d.tenantId)?c:"";await t.applications.unassignUserFromApplications({userId:s,appIds:r,tenantId:a});const o=null!=(g=null==(p=e.auth)||null==(y=p.teamState)?void 0:y.users)?g:[],i=null==(f=o.find((e=>e.id===s)))?void 0:f.applications;null!=i&&i.length&&r.length&&n.setTeamState({users:o.map((e=>e.id===s?j({},e,{applications:i.filter((e=>!r.includes(e.id)))}):e))}),null==l||l(!0)}catch(e){a({error:Gc(e,i)}),null==l||l(!1)}},assignNewUserToApps:async({appIds:a,user:o})=>{var i,s,r;const[l]=n.__getFeatureFlags(["multi-apps-admin-portal"]);if(!l)return;const c=null==(i=e.auth)||null==(s=i.applicationsState)?void 0:s.accountApplications,u=null!=(r=null==c?void 0:c.filter((e=>e.accessType===ql.FREE_ACCESS)))?r:[];if(null!=a&&a.length){var d,g,p;const n=null!=(d=null==(g=e.auth)||null==(p=g.user)?void 0:p.tenantId)?d:"";return await t.applications.assignUserToApplications({userId:o.id,appIds:a,tenantId:n}),a.map((e=>{var t;return null!=(t=null==c?void 0:c.find((t=>t.id===e)))?t:[]})).concat(u)}return u},mapUsersWithApplicationData:async({shouldLoadApps:e,users:t})=>{const[a]=n.__getFeatureFlags(["multi-apps-admin-portal"]);if(!a||!e)return t;const i=t.map((e=>e.id)),s=await o({userIds:i});return s?t.map((e=>null!=s&&s[e.id]?j({},e,{applications:s[e.id]}):e)):t}}},Fu={loading:!0,error:null},$u=e=>Mc(Fu,e),ju=["callback"],Gu=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auth.customLoginState,t)},i=async()=>{var t,n,a,o,i;return e.auth.isAuthenticated?null!=(o=null==(i=e.auth.tenantsState.activeTenant)?void 0:i.hasCustomLogin)&&o:!!(null==(t=await(null==(n=ne.getContext())||null==(a=n.tenantResolver)?void 0:a.call(n)))?void 0:t.tenant)};return{setCustomLoginState:o,resetCustomLoginState:()=>{e.auth.customLoginState=Xl(Fu)},loadTenantMetadata:async()=>{o({loading:!0});try{const e=await t.metadata.getAdminBoxMetadata();o({tenantMetadata:e,loading:!1})}catch(e){o({loading:!1,error:Gc(e)})}},updateTenantMetadata:async e=>{const{callback:n}=e,a=oe(e,ju);try{o({error:null,saving:!0});const e=Au(a);if(0===e.length)throw new Error("No changes to update");await t.metadata.updateAdminBoxMetadata({actions:e});const i=await t.metadata.getAdminBoxMetadata();o({tenantMetadata:i,saving:!1}),null==n||n(!0)}catch(e){o({error:Gc(e,"No changes to update"),saving:!1}),null==n||n(null,e)}},customLoginEnabled:i,loadCustomLoginRoutes:async()=>{try{var n;if(!await i())return;const s=e.auth.isAuthenticated,{getSettings:r,getPublicSettings:l}=t.accountSettings,{applicationUrl:c}=await(s?r():l());if(!c)return;const u=e.auth.routes,d=null!=(n=Zc(c))?n:"";a.setAuthState({routes:j({},u,{customLoginAuthenticatedUrl:c,customLoginUrl:u.loginUrl+d})}),o({customLoginSearchParams:null!=d?d:void 0})}catch{}}}},xu={step:pc.forgotPassword,loading:!1,email:"",passwordConfig:null},Vu=e=>Mc(xu,e),Bu=["callback"],Wu=(e,t,n)=>{const a=t=>{Object.assign(e.auth.forgotPasswordState,t)};return{setForgotPasswordState:a,resetForgotPasswordState:()=>{e.auth.forgotPasswordState=Xl(xu)},forgotPassword:async e=>{a({loading:!0});try{var n;await t.auth.forgotPassword(e),a({loading:!1,error:void 0,step:pc.success}),null==(n=e.callback)||n.call(e,!0)}catch(t){var o;a({loading:!1,error:Gc(t,"Unknown error occurred")}),null==(o=e.callback)||o.call(e,!1,t)}},resetPassword:async e=>{const{callback:n}=e,o=oe(e,Bu);a({loading:!0});try{await t.auth.resetPassword(o),a({loading:!1,error:void 0,step:pc.success}),null==n||n(!0)}catch(e){a({loading:!1,error:Gc(e)}),null==n||n(!1,e)}},loadPasswordConfig:async e=>{a({loading:!0});try{const n=await t.auth.loadPasswordConfig(e);a({loading:!1,passwordConfig:n})}catch(e){a({loading:!1,error:Gc(e)})}}}},zu={loaders:{},errors:{},groups:[],groupsConfiguration:{}},Ku=e=>Mc(zu,e),Hu=["roleIds","userIds"],qu=(e,t,n)=>{const a=t=>{Object.assign(e.auth.groupsState,{loaders:j({},e.auth.groupsState.loaders,{[t.key]:t.value})})},o=t=>{Object.assign(e.auth.groupsState,{errors:j({},e.auth.groupsState.errors,{[t.key]:t.value}),loaders:j({},e.auth.groupsState.loaders,{[t.key]:!1})})},i=t=>{Object.assign(e.auth.groupsState,t)},s=async()=>{const n=yc.GET_GROUPS,s=e.auth.groupsState;a({key:n,value:!0});try{const{groups:e}=await t.groups.getGroups({_groupsRelations:fc.rolesAndUsers});i(j({groups:e},s.selectedGroup&&{selectedGroup:e.find((e=>{var t;return e.id===(null==(t=s.selectedGroup)?void 0:t.id)}))}))}catch(e){o({key:n,value:Gc(e)})}finally{a({key:n,value:!1})}},r=async e=>{const n=yc.ADD_ROLES_TO_GROUP;a({key:n,value:!0});try{var i;await t.groups.addRolesToGroup(e.groupId,{roleIds:e.roleIds}),await s(),null==e||null==(i=e.callback)||i.call(e,!0)}catch(t){var r;o({key:n,value:Gc(t)}),null==e||null==(r=e.callback)||r.call(e,!1)}finally{a({key:n,value:!1})}},l=async e=>{const n=yc.ADD_USERS_TO_GROUP;a({key:n,value:!0});try{var i;await t.groups.addUsersToGroup(e.groupId,{userIds:e.userIds}),await s(),null==e||null==(i=e.callback)||i.call(e,!0)}catch(t){var r;null==e||null==(r=e.callback)||r.call(e,!1),o({key:n,value:Gc(t)})}finally{a({key:n,value:!1})}},c=async()=>{const e=yc.GET_GROUP_CONFIGURATION;a({key:e,value:!0});try{const n=await t.groups.getGroupConfiguration();i({groupsConfiguration:n})}catch(t){o({key:e,value:Gc(t)})}finally{a({key:e,value:!1})}};return{setUsersGroupsLoader:a,setUsersGroupsError:o,setGroupsState:i,resetUsersGroupsState:()=>{e.auth.groupsState=Xl(zu)},loadGroups:s,getGroupById:async e=>{const n=yc.GET_GROUP;a({key:n,value:!0});try{const o=await t.groups.getGroupById({groupId:e.groupId},{_groupsRelations:fc.rolesAndUsers});i({selectedGroup:o})}catch(e){o({key:n,value:Gc(e)})}finally{a({key:n,value:!1})}},createGroup:async e=>{const n=yc.CREATE_GROUP,{roleIds:i,userIds:c}=e,u=oe(e,Hu);a({key:n,value:!0});try{var d;const o=await t.groups.createGroup(j({name:u.name},!!u.description&&{description:u.description},{color:u.color}));null!=c&&c.length&&l({groupId:o.id,userIds:c}),null!=i&&i.length&&r({groupId:o.id,roleIds:i}),await s(),null==e||null==(d=e.callback)||d.call(e,!0)}catch(t){var g;o({key:n,value:Gc(t)}),null==e||null==(g=e.callback)||g.call(e,!1)}finally{a({key:n,value:!1})}},updateGroup:async e=>{const n=yc.UPDATE_GROUP;a({key:n,value:!0});try{var i;await t.groups.updateGroup(e),await s(),null==e||null==(i=e.callback)||i.call(e,!0)}catch(t){var r;o({key:n,value:Gc(t)}),null==e||null==(r=e.callback)||r.call(e,!1)}finally{a({key:n,value:!1})}},deleteGroup:async e=>{const n=yc.DELETE_GROUP;a({key:n,value:!0});try{var i;await t.groups.deleteGroup(e.groupId),await s(),null==e||null==(i=e.callback)||i.call(e,!0)}catch(t){var r;o({key:n,value:Gc(t)}),null==e||null==(r=e.callback)||r.call(e,!1,t)}finally{a({key:n,value:!1})}},addRolesToGroup:r,deleteRolesFromGroup:async e=>{const n=yc.DELETE_ROLES_FROM_GROUP;a({key:n,value:!0});try{var i;await t.groups.deleteRolesFromGroup(e.groupId,{roleIds:e.roleIds}),await s(),null==e||null==(i=e.callback)||i.call(e,!0)}catch(t){var r;o({key:n,value:Gc(t)}),null==e||null==(r=e.callback)||r.call(e,!1)}finally{a({key:n,value:!1})}},addUsersToGroup:l,deleteUsersFromGroup:async e=>{const n=yc.DELETE_USERS_FROM_GROUP;a({key:n,value:!0});try{var i;await t.groups.deleteUsersFromGroup(e.groupId,{userIds:e.userIds}),await s(),null==e||null==(i=e.callback)||i.call(e,!0)}catch(t){var r;o({key:n,value:Gc(t)}),null==e||null==(r=e.callback)||r.call(e,!1)}finally{a({key:n,value:!1})}},getGroupConfiguration:c,updateGroupConfiguration:async e=>{const n=yc.UPDATE_GROUP_CONFIGURATION;a({key:n,value:!0});try{await t.groups.updateGroupConfiguration(e),await c()}catch(e){o({key:n,value:Gc(e)})}finally{a({key:n,value:!1})}},getTeamUsers:async e=>{const n=yc.GET_TEAM_USERS;a({key:n,value:!0});try{const{items:o}=await t.users.getUsersV2({_filter:e.filter,_offset:e.pageOffset,_limit:e.pageSize,_includeSubTenants:!1});i({teamUsers:o})}catch(e){o({key:n,value:Gc(e)})}finally{a({key:n,value:!1})}}}},Ju={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}},Yu=e=>Mc(Ju,e),Xu=(e,t,n)=>({setGroupsDialogsState:t=>{Object.assign(e.auth.groupsDialogsState,t)},resetGroupsDialogsState:()=>{e.auth.groupsDialogsState=Xl(Ju)},openAddGroupDialog:()=>{e.auth.groupsDialogsState.addGroupDialogState.open=!0},closeAddGroupDialog:()=>{Object.assign(e.auth.groupsDialogsState.addGroupDialogState,{open:!1,group:void 0})},openAddMembersToGroupDialog:()=>{e.auth.groupsDialogsState.addMembersToGroupDialogState.open=!0},closeAddMembersToGroupDialog:()=>{Object.assign(e.auth.groupsDialogsState.addMembersToGroupDialogState,{open:!1,userIds:[]})},openEditGroupDialog:t=>{Object.assign(e.auth.groupsDialogsState.editGroupDialogState,j({},t,{open:!0}))},closeEditGroupDialog:()=>{Object.assign(e.auth.groupsDialogsState.editGroupDialogState,{open:!1,loading:!1,group:void 0})},openDeleteGroupDialog:t=>{Object.assign(e.auth.groupsDialogsState.deleteGroupDialogState,j({},t,{open:!0}))},closeDeleteGroupDialog:()=>{Object.assign(e.auth.groupsDialogsState.deleteGroupDialogState,{open:!1,loading:!1,group:void 0})},openDeleteMemberFromGroupDialog:t=>{Object.assign(e.auth.groupsDialogsState.deleteMemberFromGroupDialogState,t)},closeDeleteMemberFromGroupDialog:()=>{Object.assign(e.auth.groupsDialogsState.deleteMemberFromGroupDialogState,{open:!1,userId:void 0,email:void 0})}}),Qu={step:Sc.impersonating,loading:!1},Zu=e=>Mc(Qu,e),ed=["callback","events"],td=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auth.impersonateState,t)},i=()=>{e.auth.impersonateState=Xl(Qu)};return{setImpersonateState:o,resetImpersonateState:i,impersonate:async e=>{const{callback:n}=e,s=oe(e,ed);o({loading:!0});try{await t.impersonate.impersonate(s),o({step:Sc.success}),await Ql(1e3),await a.afterAuthNavigation({preventRedirectUrlOriginCleaning:!0}),i(),null==n||n(!0)}catch(e){o({loading:!1,error:Gc(e)})}}}},nd={flow:vc.Login,step:hc.preLogin,loading:!1,email:"",tenants:[]},ad=e=>Mc(nd,e),od=(e,t,n)=>{const a=n;const o=async(t,n={})=>{const{customLoginAuthenticatedUrl:a,forceStepUpUrl:o,shouldStepUpDuringLogin:i,preventRedirectUrlOriginCleaning:s=!1}=n,r=e.auth.onRedirectTo;let l;if(o)l=o;else{var c;if(i){const e=window.localStorage.getItem(pu);e&&!Xc(e)&&(l=e)}l||(l=await async function({customLoginAuthenticatedUrl:t,preventRedirectUrlOriginCleaning:n}){const{routes:a,includeQueryParam:o=!1,enforceRedirectToSameSite:i=!1,allowedRedirectOrigins:s=[]}=e.auth;if(t)return eu(t);const{authenticatedUrl:r,loginUrl:l,logoutUrl:c,socialLoginCallbackUrl:u,activateUrl:d}=a;let g=window.localStorage.getItem(pu);g&&![l,c,u,d].includes(g)||(g=r);const p=Qc({authenticatedUrl:g,includeQueryParam:o,enforceRedirectToSameSite:i,allowedRedirectOrigins:s});return n?p:(y=p).startsWith(null==(f=window)?void 0:f.location.origin)?y.replace(null==(S=window)?void 0:S.location.origin,""):y;var y,f,S}({customLoginAuthenticatedUrl:a,preventRedirectUrlOriginCleaning:s})),null==(c=window)||c.localStorage.removeItem(pu)}await Ql(200),await t(),r(l,{refresh:l.startsWith("http")})};return{afterAuthNavigationUtil:o,afterAuthNavigation:async t=>{var n,i;const{customLoginAuthenticatedUrl:s,stepUpUrl:r}=e.auth.routes,l=null==(n=window)?void 0:n.localStorage.getItem(du),c=e.auth.user;var u;if(l&&(null==(u=window)||u.localStorage.removeItem(du)),r&&l&&!fu(c))return o(a.resetLoginState,{forceStepUpUrl:r});let d=s;var g;return s||(await a.loadCustomLoginRoutes(),d=null==(g=e.auth.routes)?void 0:g.customLoginAuthenticatedUrl),o(a.resetLoginState,{customLoginAuthenticatedUrl:d,shouldStepUpDuringLogin:!!l,preventRedirectUrlOriginCleaning:null!=(i=null==t?void 0:t.preventRedirectUrlOriginCleaning)&&i})},afterStepUpAuthNavigation:async()=>o(a.resetStepUpState),__afterAuthenticationStateUpdate:async function({user:t,tenants:n=[],activeTenant:o},i={}){const s=e.auth.tenantsState;a.setAuthState(j({user:t,tenantsState:j({},s,{tenants:n,activeTenant:o,loading:!1})},i))}}},id={step:Ac.verify,loading:!1,saving:!1},sd=e=>Mc(id,e),rd=["callback"],ld=["callback"],cd=["callback"],ud=["callback","deviceId"],dd=["callback","deviceId"],gd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",pd=new Uint8Array(256);for(let e=0;e<gd.length;e++)pd[gd.charCodeAt(e)]=e;const yd=e=>{const t=new Uint8Array(e),n=t.length;let a,o="";for(a=0;a<n;a+=3)o+=gd[t[a]>>2],o+=gd[(3&t[a])<<4|t[a+1]>>4],o+=gd[(15&t[a+1])<<2|t[a+2]>>6],o+=gd[63&t[a+2]];return n%3==2?o=o.substring(0,o.length-1):n%3==1&&(o=o.substring(0,o.length-2)),o},fd=e=>{const t=.75*e.length,n=e.length;let a,o,i,s,r,l=0;const c=new Uint8Array(t);for(a=0;a<n;a+=4)o=pd[e.charCodeAt(a)],i=pd[e.charCodeAt(a+1)],s=pd[e.charCodeAt(a+2)],r=pd[e.charCodeAt(a+3)],c[l++]=o<<2|i>>4,c[l++]=(15&i)<<4|s>>2,c[l++]=(3&s)<<6|63&r;return c.buffer};function Sd(e,t="file"){const n=e.match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/);if(null==n)return null;const a=`image/${n[1]}`,o=((e,t)=>{const n=atob(e),a=[];for(let e=0;e<n.length;e+=512){const t=n.slice(e,e+512),o=new Array(t.length);for(let e=0;e<t.length;e++)o[e]=t.charCodeAt(e);a.push(new Uint8Array(o))}return new Blob(a,{type:t})})(n[2],a),i=new FormData;return i.append(t,new File([o],t,{type:a})),i}const hd=e=>{if(e instanceof Array){const t=[];for(const n of e)t.push(hd(n));return t}if(e instanceof ArrayBuffer)return yd(e);if(e instanceof Object){const t={};for(const n in e)t[n]=hd(e[n]);return t}return e},vd=e=>new Promise(((t,n)=>{const a=new FileReader;a.readAsText(e),a.onload=()=>t(a.result),a.onerror=n})),md=["callback","deviceId"],bd=["callback","deviceId"],Ad="input is invalid type",wd="undefined"!=typeof ArrayBuffer,Td="0123456789abcdef".split(""),Ed=[-2147483648,8388608,32768,128],Id=[24,16,8,0],kd=[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],Od=["hex","array","digest","arrayBuffer"],_d=[];Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),wd&&!ArrayBuffer.isView&&(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});const Pd=function(e){return function(t){const n=new Ld(!0).update(t);return null==n?void 0:n[e]()}},Ud=function(e){return function(t,n){const a=new Dd(t,!0).update(n);return null==a?void 0:a[e]()}};class Ld{constructor(e=!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=()=>Ld.prototype.digest(),e?(_d[0]=_d[16]=_d[1]=_d[2]=_d[3]=_d[4]=_d[5]=_d[6]=_d[7]=_d[8]=_d[9]=_d[10]=_d[11]=_d[12]=_d[13]=_d[14]=_d[15]=0,this.blocks=_d):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=e}update(e){if(this.finalized)return;let t;const n=typeof e;if("string"!==n){if("object"!==n)throw new Error(Ad);if(null===e)throw new Error(Ad);if(wd&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||wd&&ArrayBuffer.isView(e)))throw new Error(Ad);t=!0}let a,o,i=0;const s=e.length,r=this.blocks;for(;i<s;){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),t)for(o=this.start;i<s&&o<64;++i)r[o>>2]|=e[i]<<Id[3&o++];else for(o=this.start;i<s&&o<64;++i)a=e.charCodeAt(i),a<128?r[o>>2]|=a<<Id[3&o++]:a<2048?(r[o>>2]|=(192|a>>6)<<Id[3&o++],r[o>>2]|=(128|63&a)<<Id[3&o++]):a<55296||a>=57344?(r[o>>2]|=(224|a>>12)<<Id[3&o++],r[o>>2]|=(128|a>>6&63)<<Id[3&o++],r[o>>2]|=(128|63&a)<<Id[3&o++]):(a=65536+((1023&a)<<10|1023&e.charCodeAt(++i)),r[o>>2]|=(240|a>>18)<<Id[3&o++],r[o>>2]|=(128|a>>12&63)<<Id[3&o++],r[o>>2]|=(128|a>>6&63)<<Id[3&o++],r[o>>2]|=(128|63&a)<<Id[3&o++]);this.lastByteIndex=o,this.bytes+=o-this.start,o>=64?(this.block=r[16],this.start=o-64,this.hash(),this.hashed=!0):this.start=o}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 e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>2]|=Ed[3&t],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}hash(){let e,t,n,a,o,i,s,r,l,c,u,d=this.h0,g=this.h1,p=this.h2,y=this.h3,f=this.h4,S=this.h5,h=this.h6,v=this.h7;const m=this.blocks;for(e=16;e<64;++e)o=m[e-15],t=(o>>>7|o<<25)^(o>>>18|o<<14)^o>>>3,o=m[e-2],n=(o>>>17|o<<15)^(o>>>19|o<<13)^o>>>10,m[e]=m[e-16]+t+m[e-7]+n<<0;for(u=g&p,e=0;e<64;e+=4)this.first?(r=704751109,o=m[0]-210244248,v=o-1521486534<<0,y=o+143694565<<0,this.first=!1):(t=(d>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),n=(f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7),r=d&g,a=r^d&p^u,s=f&S^~f&h,o=v+n+s+kd[e]+m[e],i=t+a,v=y+o<<0,y=o+i<<0),t=(y>>>2|y<<30)^(y>>>13|y<<19)^(y>>>22|y<<10),n=(v>>>6|v<<26)^(v>>>11|v<<21)^(v>>>25|v<<7),l=y&d,a=l^y&g^r,s=v&f^~v&S,o=h+n+s+kd[e+1]+m[e+1],i=t+a,h=p+o<<0,p=o+i<<0,t=(p>>>2|p<<30)^(p>>>13|p<<19)^(p>>>22|p<<10),n=(h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7),c=p&y,a=c^p&d^l,s=h&v^~h&f,o=S+n+s+kd[e+2]+m[e+2],i=t+a,S=g+o<<0,g=o+i<<0,t=(g>>>2|g<<30)^(g>>>13|g<<19)^(g>>>22|g<<10),n=(S>>>6|S<<26)^(S>>>11|S<<21)^(S>>>25|S<<7),u=g&p,a=u^g&y^c,s=S&h^~S&v,o=f+n+s+kd[e+3]+m[e+3],i=t+a,f=d+o<<0,d=o+i<<0;this.h0=this.h0+d<<0,this.h1=this.h1+g<<0,this.h2=this.h2+p<<0,this.h3=this.h3+y<<0,this.h4=this.h4+f<<0,this.h5=this.h5+S<<0,this.h6=this.h6+h<<0,this.h7=this.h7+v<<0}hex(){this.finalize();const e=this.h0,t=this.h1,n=this.h2,a=this.h3,o=this.h4,i=this.h5,s=this.h6,r=this.h7;let l=Td[e>>28&15]+Td[e>>24&15]+Td[e>>20&15]+Td[e>>16&15]+Td[e>>12&15]+Td[e>>8&15]+Td[e>>4&15]+Td[15&e]+Td[t>>28&15]+Td[t>>24&15]+Td[t>>20&15]+Td[t>>16&15]+Td[t>>12&15]+Td[t>>8&15]+Td[t>>4&15]+Td[15&t]+Td[n>>28&15]+Td[n>>24&15]+Td[n>>20&15]+Td[n>>16&15]+Td[n>>12&15]+Td[n>>8&15]+Td[n>>4&15]+Td[15&n]+Td[a>>28&15]+Td[a>>24&15]+Td[a>>20&15]+Td[a>>16&15]+Td[a>>12&15]+Td[a>>8&15]+Td[a>>4&15]+Td[15&a]+Td[o>>28&15]+Td[o>>24&15]+Td[o>>20&15]+Td[o>>16&15]+Td[o>>12&15]+Td[o>>8&15]+Td[o>>4&15]+Td[15&o]+Td[i>>28&15]+Td[i>>24&15]+Td[i>>20&15]+Td[i>>16&15]+Td[i>>12&15]+Td[i>>8&15]+Td[i>>4&15]+Td[15&i]+Td[s>>28&15]+Td[s>>24&15]+Td[s>>20&15]+Td[s>>16&15]+Td[s>>12&15]+Td[s>>8&15]+Td[s>>4&15]+Td[15&s];return l+=Td[r>>28&15]+Td[r>>24&15]+Td[r>>20&15]+Td[r>>16&15]+Td[r>>12&15]+Td[r>>8&15]+Td[r>>4&15]+Td[15&r],l}digest(){this.finalize();const e=this.h0,t=this.h1,n=this.h2,a=this.h3,o=this.h4,i=this.h5,s=this.h6,r=this.h7,l=[e>>24&255,e>>16&255,e>>8&255,255&e,t>>24&255,t>>16&255,t>>8&255,255&t,n>>24&255,n>>16&255,n>>8&255,255&n,a>>24&255,a>>16&255,a>>8&255,255&a,o>>24&255,o>>16&255,o>>8&255,255&o,i>>24&255,i>>16&255,i>>8&255,255&i,s>>24&255,s>>16&255,s>>8&255,255&s];return l.push(r>>24&255,r>>16&255,r>>8&255,255&r),l}arrayBuffer(){this.finalize();const e=new ArrayBuffer(32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),t.setUint32(28,this.h7),e}}class Dd extends Ld{constructor(e,t=!1){let n;super(t),this.inner=void 0,this.oKeyPad=void 0;const a=typeof e;if("string"===a){const t=[],a=e.length;let o,i=0;for(n=0;n<a;++n)o=e.charCodeAt(n),o<128?t[i++]=o:o<2048?(t[i++]=192|o>>6,t[i++]=128|63&o):o<55296||o>=57344?(t[i++]=224|o>>12,t[i++]=128|o>>6&63,t[i++]=128|63&o):(o=65536+((1023&o)<<10|1023&e.charCodeAt(++n)),t[i++]=240|o>>18,t[i++]=128|o>>12&63,t[i++]=128|o>>6&63,t[i++]=128|63&o);e=t}else{if("object"!==a)throw new Error(Ad);if(null===e)throw new Error(Ad);if(wd&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||wd&&ArrayBuffer.isView(e)))throw new Error(Ad)}var o;e.length>64&&(e=null==(o=new Ld(!0).update(e))?void 0:o.array());const i=[],s=[];for(n=0;n<64;++n){const t=e[n]||0;i[n]=92^t,s[n]=54^t}Ld.call(this,t),this.update(s),this.oKeyPad=i,this.inner=!0,this.sharedMemory=t}finalize(){if(super.finalize(),this.inner){this.inner=!1;const e=this.array();Ld.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(e),Ld.prototype.finalize.call(this)}}}const Rd=function(){const e=Pd("hex");e.create=function(){return new Ld},e.update=function(t){return e.create().update(t)};for(let t=0;t<Od.length;++t){const n=Od[t];e[n]=Pd(n)}return e}();async function Cd(e){const t=Rd.digest((new TextEncoder).encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}async function Nd(e){const t=await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}async function Md(e){var t,n;return null!=(t=window.crypto)&&null!=(n=t.subtle)&&n.digest?Nd(e):(console.warn("Generating CodeChallenge in non-secure domain:",window.location.origin),Cd(e))}function Fd(e=16){let t="";const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(let a=0;a<e;a++)t+=n.charAt(Math.floor(Math.random()*n.length));return t}!function(){const e=Ud("hex");e.create=function(e){return new Dd(e)},e.update=function(t,n){return e.create(t).update(n)};for(let t=0;t<Od.length;++t){const n=Od[t];e[n]=Ud(n)}}();const $d=new class{constructor(){this.loginWithSSO=e=>{if(this.isWebkitAvailable()){var t,n,a;null==(t=window.webkit)||null==(n=t.messageHandlers)||null==(a=n.FronteggNativeBridge)||a.postMessage(JSON.stringify({action:"loginWithSSO",payload:e}))}else{if(!this.isJsInterfaceAvailable())throw new Error("FronteggNativeBridge is not available");var o;null==(o=window.FronteggNativeBridge)||o.loginWithSSO(e)}},this.loginWithSocialLogin=e=>{if(this.isWebkitAvailable()){var t,n,a;null==(t=window.webkit)||null==(n=t.messageHandlers)||null==(a=n.FronteggNativeBridge)||a.postMessage(JSON.stringify({action:"loginWithSocialLogin",payload:e}))}else{if(!this.isJsInterfaceAvailable())throw new Error("FronteggNativeBridge is not available");var o;null==(o=window.FronteggNativeBridge)||o.loginWithSocialLogin(e)}},this.promptSocialLoginConsent=()=>{var e,t;return null!=(e=null==(t=window.FronteggNativeBridgeFunctions)?void 0:t.shouldPromptSocialLoginConsent)&&e}}isWebkitAvailable(){var e,t;return null!=(null==(e=window.webkit)||null==(t=e.messageHandlers)?void 0:t.FronteggNativeBridge)}isJsInterfaceAvailable(){return null!=window.FronteggNativeBridge}isSocialLoginAvailable(){return this.isAvailable("loginWithSocialLogin")}isLoginWithSSOAvailable(){return this.isAvailable("loginWithSSO")}isAvailable(e){var t,n;return!(!this.isWebkitAvailable()&&!this.isJsInterfaceAvailable())&&null!=(t=null==(n=window.FronteggNativeBridgeFunctions)?void 0:n[e])&&t}},jd=["callback"],Gd=["callback"],xd=["callback"],Vd=["callback"],Bd=["callback"],Wd=["callback","events"],zd=["callback"],Kd=["callback"],Hd=["user"],qd=["callback"],Jd=["callback"],Yd=["callback"],Xd=["callback"],Qd=["callback"],Zd=["callback"],eg=(e,t,n)=>{const a=n,o=t=>{var n;const{routes:a,loginState:o}=e.auth,i=null!=(n=localStorage.getItem("register-quick-login"))?n:o.quickLoginToRegister;return i&&"true"!==localStorage.getItem(`${t.id}-${i}`)&&!window.location.pathname.endsWith(a.logoutUrl)},i=async()=>{e.auth.hostedLoginBox?await(async()=>{const n=e.auth.user;if(null==n||!n.refreshToken)return ne.setAccessToken(null),ne.setUser(null),void a.setAuthState({user:null,isAuthenticated:!1});try{const e={grant_type:"refresh_token",refresh_token:null==n?void 0:n.refreshToken},o=await t.auth.exchangeOAuthTokensV2(e),i=await s(o.user);await a.__afterAuthenticationStateUpdate(j({},o,{user:i}),{isAuthenticated:!0})}catch(e){ne.setAccessToken(null),ne.setUser(null),a.setAuthState({user:null,isAuthenticated:!1})}})():await(async()=>{try{const{routes:i,loginState:l,onRedirectTo:c}=e.auth,{user:u,tenants:d=[],activeTenant:g}=await t.auth.refreshTokenV3();if(bu(u)){const e=await a.getMfaRequiredState(u);a.setAuthState(e),c(i.loginUrl,{preserveQueryParams:!0})}else{var n;u.id&&localStorage.setItem("userId",u.id);const e=null!=(n=localStorage.getItem("register-quick-login"))?n:l.quickLoginToRegister,t=o(u),i=await s(u);a.__afterAuthenticationStateUpdate({user:i,tenants:d,activeTenant:g},{loginState:j({},l,{quickLoginToRegister:e,flow:t?vc.RegisterQuickLogin:vc.Login}),isAuthenticated:!0}),await r(t)}}catch(e){ne.setAccessToken(null),ne.setUser(null),a.setAuthState({user:void 0,isAuthenticated:!1})}})()},s=async t=>{var n;const a=null==(n=e.auth.user)?void 0:n.entitlements;return gc(a,null==t?void 0:t.entitlements)?j({},t,{entitlements:a}):t},r=async t=>{var n;const o=new URL(null==(n=window)?void 0:n.location.href),{routes:i,loginState:s,onRedirectTo:r}=e.auth,l=o.searchParams.get("invitationToken"),c=[i.socialLoginCallbackUrl,i.oidcRedirectUrl,i.samlCallbackUrl];l||c.push(i.loginUrl,i.signUpUrl),t?r(i.loginUrl):c.some((e=>e&&window.location.pathname.endsWith(e)))&&(s.isNewUser&&i.signUpSuccessUrl&&i.socialLoginCallbackUrl===window.location.pathname?r(i.signUpSuccessUrl,{refresh:i.signUpSuccessUrl.startsWith("http")}):await a.afterAuthNavigation())},l=async()=>{try{const{isActive:e}=await t.auth.getSSOPublicConfiguration();a.setAuthState({isSSOAuth:e})}catch(e){a.setAuthState({isSSOAuth:!1})}},c=async()=>{let e;try{var n;const a=await t.metadata.getSamlMetadata();e=null==a||null==(n=a.configuration)?void 0:n.acsUrl}catch(e){console.error(e)}a.setAuthState({ssoACS:e})},u=t=>{Object.assign(e.auth.loginState,t)},d=async t=>{let{callback:n}=t,o=oe(t,jd);const i=e.auth.securityPolicyState.publicPolicy.policy;if(null==i||!i.authStrategy)return a.setLoginState({step:hc.loginWithPassword,loading:!1}),void(null==n||n());(null==i?void 0:i.authStrategy)===rn.EmailAndPassword?(a.setLoginState({step:hc.loginWithPassword,loading:!1}),null==n||n()):[rn.MagicLink,rn.Code,rn.SmsCode].includes(null==i?void 0:i.authStrategy)?await a.passwordlessPreLogin(j({},o,{type:null==i?void 0:i.authStrategy,callback:n})):(a.setLoginState({step:hc.loginWithPassword,loading:!1}),null==n||n())},g=async e=>{const{user:t,tenants:n=[],activeTenant:o}=e,i={step:Ac.recoveryCode,loading:!1,error:void 0,saving:!1};null!=t&&t.recoveryCode&&(i.recoveryCode=t.recoveryCode),a.setMfaState(i),a.setUser(t),a.setTenantsState({tenants:n,activeTenant:o,loading:!1}),t.id&&localStorage.setItem("userId",t.id)};return j({setLoginState:u,resetLoginState:()=>{e.auth.loginState=Xl(nd)},requestAuthorize:async e=>{const t=[],n=[];t.push(i()),e&&(a.setAuthState({isLoading:!0}),t.push(a.loadSocialLoginsConfigurationV2()),t.push(a.loadAllowSignUps()),t.push(a.loadPublicAuthStrategiesPolicy()),t.push(l()),t.push(a.loadVendorPublicInfo()),t.push(c()),n.push(a.loadCustomLoginRoutes())),await Promise.all(t),n.length>0&&await Promise.all(n),a.setAuthState({isLoading:!1})},requestAuthorizeSSR:async t=>{const n=[];n.push(a.loadSocialLoginsConfigurationV2()),n.push(a.loadAllowSignUps()),n.push(l()),n.push(a.loadVendorPublicInfo()),n.push(c()),n.push((async({accessToken:t,user:n})=>{if(!t)return void a.setAuthState({user:void 0,isAuthenticated:!1});const{onRedirectTo:o,routes:i}=e.auth;if(bu(n)){const e=await a.getMfaRequiredState(n);a.setAuthState(e),o(i.loginUrl,{preserveQueryParams:!0})}})(t)),n.push(a.loadCustomLoginRoutes()),await Promise.all(n)},preLogin:async n=>{const{email:a,recaptchaToken:o,invitationToken:i,callback:s}=n;u({loading:!0});try{const n=e.auth.onRedirectTo,r=tu(nu),l=await t.auth.preLoginV2({email:a,tenantId:r}),{address:c,idpType:g}=null!=l?l:{};if(c){let t=c;if(g===_c.Oidc&&!t.includes("redirect_uri")){const{oidcRedirectUrl:n}=e.auth.routes;t+=`&redirect_uri=${window.location.origin}${n}`}$d.isLoginWithSSOAvailable()?($d.loginWithSSO(a),u({loading:!1}),null==s||s()):(u({step:hc.redirectToSSO,loading:!1,ssoRedirectUrl:t}),setTimeout((()=>{n(t,{refresh:!0})}),2e3))}else await d({email:a,recaptchaToken:o,callback:s,invitationToken:i})}catch(e){await d({email:a,recaptchaToken:o,callback:s,invitationToken:i})}},postLogin:async n=>{const{onRedirectTo:o,routes:i}=e.auth;u({loading:!0});try{const e=await t.auth.postLogin(n);a.setAuthState({user:e.accessToken?e:void 0,isAuthenticated:!!e.accessToken}),await a.afterAuthNavigation()}catch(e){setTimeout((()=>{o(i.authenticatedUrl)}),1e3),u({step:hc.loginWithSSOFailed,loading:!1})}},login:async n=>{const{email:o,password:i,recaptchaToken:s,invitationToken:r,callback:l}=n;u({loading:!0});try{const{user:n,tenants:c=[],activeTenant:d}=await t.auth.loginv2({email:o,password:i,recaptchaToken:s,invitationToken:r}),{onRedirectTo:g,routes:p}=e.auth;if(bu(n)){const e=await a.getMfaRequiredState(n);a.setAuthState(e),g(p.loginUrl,{preserveQueryParams:!0})}else{const t=e.auth.loginState,i=!!n.accessToken;n.id&&localStorage.setItem("userId",n.id),await a.__afterAuthenticationStateUpdate({user:n,tenants:c,activeTenant:d},{loginState:{flow:t.flow,quickLoginToRegister:t.quickLoginToRegister,email:o,loading:!1,error:void 0,mfaToken:n.mfaToken,step:t.flow===vc.Login?hc.success:t.step,tenants:c,tenantsLoading:!0,isBreachedPassword:n.isBreachedPassword},isAuthenticated:i});const[s]=await a.__getFeatureFlags(["security-center-show-login-flows"]);t.flow===vc.Login&&(s&&n.isBreachedPassword&&!i?u({step:hc.breachedPassword,loading:!1}):i&&(await a.__shouldShowPromptPasskeys()?(u({step:hc.promptPasskeys,loading:!1}),g(p.loginUrl,{preserveQueryParams:!0})):await a.afterAuthNavigation()))}localStorage.removeItem("register-quick-login"),null==l||l(!0)}catch(e){ne.setAccessToken(null),ne.setUser(null),null==l||l(!1,e),u({email:o,error:Gc(e),loading:!1})}},logout:async n=>{const o=e.auth.hostedLoginBox;a.setAuthState({isLoading:!0});try{o?await t.auth.OAuthLogout():await t.auth.logout()}catch{}ne.isSessionPerTenantEnabled()&&wt(),a.resetAuthState(),await a.requestAuthorize(!0),null==n||n()},silentLogout:async e=>{var n;try{await t.auth.logout()}catch{}ne.isSessionPerTenantEnabled()&&wt(),setTimeout((()=>{var t;return null==e||null==(t=e.callback)?void 0:t.call(e,!0)}),null!=(n=null==e?void 0:e.callbackTimeout)?n:500)},recoverMfa:async e=>{u({loading:!0});try{var n;await t.auth.recoverMfaToken(e),u({loading:!1,error:void 0,step:hc.preLogin}),a.setAuthState({user:void 0,isAuthenticated:!1}),null==(n=e.callback)||n.call(e,!0)}catch(t){var o;u({error:Gc(t),loading:!1}),null==(o=e.callback)||o.call(e,!1,t)}},quickSmsPasswordlessPreLogin:async e=>{const{callback:n}=e,a=oe(e,Gd);try{u({loading:!0});const e=await t.auth.passwordlessPreLogin(j({},a,{type:rn.SmsCode}));u({step:hc.loginWithQuickSmsOtc,loading:!1,phoneNumber:null==e?void 0:e.phoneNumber,error:void 0}),null==n||n(!0)}catch(e){u({error:Gc(e),loading:!1}),null==n||n(e)}},changePhoneNumberWithVerification:async e=>{const{callback:n}=e,a=oe(e,xd);try{u({loading:!0});const e=await t.auth.changePhoneNumberWithVerification(a);u({phoneNumber:a.phoneNumber,loading:!1,changePhoneId:e.changePhoneId,step:hc.loginWithQuickSmsOtc,error:void 0}),null==n||n(!0)}catch(e){u({error:Gc(e),loading:!1})}},verifyChangePhoneNumber:async e=>{const{callback:n}=e,a=oe(e,Vd);try{u({loading:!0}),await t.auth.verifyChangePhoneNumber(a),u({loading:!1}),null==n||n(!0)}catch(e){u({error:Gc(e),loading:!1})}},passwordlessPreLogin:async e=>{const{callback:n}=e,a=oe(e,Bd);try{let e;u({loading:!0}),ru(a)&&(e=a.email);const o=await t.auth.passwordlessPreLogin(a),i=Jc[a.type];u({step:i,loading:!1,phoneNumber:null==o?void 0:o.phoneNumber,email:e,error:void 0}),null==n||n()}catch(e){u({error:Gc(e),loading:!1}),null==n||n(e)}},passwordlessPostLogin:async n=>{const{callback:o,events:i}=n,s=oe(n,Wd);try{u({loading:!0});const{user:n,tenants:l=[],activeTenant:c}=await t.auth.passwordlessPostLoginV2(s),{routes:d,onRedirectTo:g}=e.auth;if(bu(n)){const e=await a.getMfaRequiredState(n);a.setAuthState(e),g(d.loginUrl,{preserveQueryParams:!0})}else{const t=e.auth.loginState;if(n.emailVerified){var r;const e={email:n.email,origin:Uc.PASSWORDLESS,id:n.id,tenantId:n.tenantId,createdAt:new Date,name:n.name};null==i||null==(r=i.userVerified)||r.call(i,e),qc(Hc.USER_VERIFIED,e)}n.id&&localStorage.setItem("userId",n.id),await a.__afterAuthenticationStateUpdate({user:n,tenants:l,activeTenant:c}),u({error:void 0}),a.setAuthState({isLoading:!1}),t.flow===vc.Login?await a.__shouldShowPromptPasskeys()?(a.setLoginState({step:hc.promptPasskeys,loading:!1}),g(d.loginUrl,{preserveQueryParams:!0})):(a.setAuthState({isAuthenticated:!0}),await a.afterAuthNavigation()):g(d.loginUrl,{preserveQueryParams:!0}),localStorage.removeItem("register-quick-login"),null==o||o(!0)}}catch(e){u({error:Gc(e,"Failed to authenticate")}),null==o||o(null,e)}finally{u({loading:!1})}},verifyInviteToken:async e=>{try{u({loading:!0});const{name:n}=await t.auth.verifyInviteToken(e);u({inviteTokenTenantName:n})}catch(e){u({inviteTokenError:Gc(e,"We couldn't verify your invitation")})}finally{u({loading:!1})}},webAuthnPrelogin:async e=>{const{callback:n}=e,o=oe(e,zd);try{var i;a.setPasskeysState({loading:!0}),u({loading:!0});const{options:e}=await t.auth.webAuthnPreLogin(o);e.challenge=fd(e.challenge),e.allowCredentials=null==(i=e.allowCredentials)?void 0:i.map((e=>j({},e,{id:fd(e.id)}))),u({error:void 0}),null==n||n(e)}catch(e){u({error:Gc(e)}),null==n||n(null)}finally{a.setPasskeysState({loading:!1}),u({loading:!1})}},webAuthnPostLogin:async n=>{const{callback:o}=n,i=oe(n,Kd);try{var s;a.setPasskeysState({loading:!0}),u({loading:!0});const n=hd(i.publicKey),r=await t.auth.webAuthnPostLoginV2(j({},n,{response:j({},n.response,{userHandle:null!=(s=n.response.userHandle)?s:void 0}),recaptchaToken:i.recaptchaToken,invitationToken:i.invitationToken})),{user:l}=r,c=oe(r,Hd);if(bu(l)){const{routes:t,onRedirectTo:n}=e.auth,o=await a.getMfaRequiredState(l);a.setAuthState(o),n(t.loginUrl,{preserveQueryParams:!0})}else l.id&&localStorage.setItem("userId",l.id),await a.__afterAuthenticationStateUpdate(j({user:l},c),{isAuthenticated:!0}),u({error:void 0}),await a.afterAuthNavigation(),null==o||o(!0)}catch(e){u({error:Gc(e)}),null==o||o(null)}finally{a.setPasskeysState({loading:!1}),u({loading:!1})}},webAuthnCreateNewDeviceSession:async e=>{const{callback:n}=e;try{u({loading:!0});const{options:e}=await t.auth.webAuthnCreateNewDeviceSession();e.user.id=fd(e.user.id),e.challenge=fd(e.challenge),e.excludeCredentials=[],null==n||n(e)}catch(e){u({error:Gc(e)}),null==n||n(null)}finally{u({loading:!1})}},webAuthnVerifyNewDeviceSession:async e=>{const{callback:n}=e,a=oe(e,qd);try{u({loading:!0});const e=hd(a.publicKey),o="platform"===(null==e?void 0:e.authenticatorAttachment)?fn.Platform:fn.CrossPlatform;await t.auth.verifyNewDeviceSession({id:e.id,response:e.response,deviceType:o}),null==n||n(!0)}catch(e){u({error:Gc(e)}),null==n||n(null)}finally{u({loading:!1})}},getUserIP:async e=>{const{callback:n}=e;try{const{ip:e}=await t.metadata.getCurrentUserIpMetadata();a.setAuthState({userIp:e}),null==n||n(!0)}catch(e){null==n||n(!1)}},preEnrollMFAWebAuthnForLogin:async e=>{const{callback:n}=e,a=oe(e,Jd);u({loading:!0});try{var o;const e=await t.auth.preEnrollMFAWebAuthnForLogin(a),i=j({},e.options,{challenge:fd(e.options.challenge),user:j({},e.options.user,{id:fd(e.options.user.id)}),excludeCredentials:null==(o=e.options.excludeCredentials)?void 0:o.map((e=>j({},e,{id:fd(e.id)})))});u({loading:!1}),null==n||n({options:i,webauthnToken:e.webauthnToken})}catch(e){u({loading:!1,error:Gc(e)}),null==n||n(null)}},enrollMFAWebAuthnForLogin:async e=>{const{callback:n}=e,a=oe(e,Yd);u({loading:!0});try{const e=hd(a.publicKey),o=await t.auth.enrollMFAWebAuthnForLoginV2(j({},a,{options:e}));await g(o),u({loading:!1}),null==n||n(!0)}catch(e){u({loading:!1,error:Gc(e)}),null==n||n(null)}},enrollMFAAuthenticatorAppForLogin:async e=>{const{callback:n}=e,a=oe(e,Xd);u({loading:!0});try{const e=await t.auth.enrollMFAAuthenticatorAppForLoginV2(a);await g(e),u({loading:!1}),null==n||n(!0)}catch(e){u({loading:!1,error:Gc(e)}),null==n||n(null)}},preEnrollMFASMSForLogin:async e=>{const{callback:n}=e,o=oe(e,Qd);u({loading:!0});try{const e=await t.auth.preEnrollMFASMSForLogin(o);a.setMfaState({otcToken:e.otcToken,step:Ac.smsVerifyCode,phoneNumber:e.phoneNumber}),u({loading:!1}),null==n||n(!0)}catch(e){u({loading:!1,error:Gc(e)}),null==n||n(null)}},enrollMFASMSForLogin:async e=>{const{callback:n}=e,a=oe(e,Zd);u({loading:!0});try{const e=await t.auth.enrollMFASMSForLoginV2(a);await g(e),u({loading:!1}),null==n||n(!0)}catch(e){u({loading:!1,error:Gc(e)}),null==n||n(null)}},handleEnrollMFAResponse:g,resetBreachedPassword:async e=>{u({loading:!0});try{await t.auth.forgotPassword(e),u({loading:!1,error:void 0,step:hc.breachedPasswordSuccess}),a.setAuthState({isAuthenticated:!1})}catch(e){u({loading:!1,error:Gc(e)})}},refreshTokenForSocialLogins:async()=>{e.auth.hostedLoginBox?await(async()=>{const{user:n}=e.auth;if(null==n||!n.refreshToken)return ne.setAccessToken(null),ne.setUser(null),void a.setAuthState({user:null,isAuthenticated:!1});try{const e={grant_type:"refresh_token",refresh_token:null==n?void 0:n.refreshToken},o=await t.auth.exchangeOAuthTokensV2(e),i=await s(o.user);await a.__afterAuthenticationStateUpdate(j({},o,{user:i}),{isAuthenticated:!0})}catch(e){ne.setAccessToken(null),ne.setUser(null),a.setAuthState({user:null,isAuthenticated:!1})}})():await(async()=>{try{const{routes:i,loginState:l,onRedirectTo:c}=e.auth,{user:u,tenants:d=[],activeTenant:g}=await t.auth.refreshTokenV3();if(bu(u)){const e=await a.getMfaRequiredState(u);a.setAuthState(e),c(i.loginUrl,{preserveQueryParams:!0})}else{const e=await s(u);if(await a.__shouldShowPromptPasskeys())a.setLoginState({step:hc.promptPasskeys,loading:!1}),await a.__afterAuthenticationStateUpdate({user:e,tenants:d,activeTenant:g},{isLoading:!1}),c(i.loginUrl,{preserveQueryParams:!0});else{var n;u.id&&localStorage.setItem("userId",u.id);const t=null!=(n=localStorage.getItem("register-quick-login"))?n:l.quickLoginToRegister,i=o(u);await a.__afterAuthenticationStateUpdate({user:e,tenants:d,activeTenant:g},{loginState:j({},l,{quickLoginToRegister:t,flow:i?vc.RegisterQuickLogin:vc.Login}),isAuthenticated:!0}),await r(i)}}}catch(e){ne.setAccessToken(null),ne.setUser(null),a.setAuthState({user:void 0,isAuthenticated:!1})}})()},__refreshToken:i},((e,t,n)=>{const a=n,o=async()=>{const e=await t.auth.silentOAuthRefreshTokenV2();if(null==e||!e.user)throw new Error("couldn't refresh user token with oauth service");await a.__afterAuthenticationStateUpdate(e,{isAuthenticated:!0,isLoading:!1})},i=async n=>{var o;const{routes:i,onRedirectTo:s}=e.auth,{context:r,urlStrategy:l}=e.root;if(wu(l)===i.hostedLoginRedirectUrl)return void console.debug("Calling loginWithRedirect while in hostedLoginCallback route");a.setAuthState({isLoading:!0});const c=Fd(),u=Fd(),d=await Md(u);localStorage.setItem(yu,u);let g=`${window.location.origin}${"path"===l?"":"#"}${i.hostedLoginRedirectUrl}`;await a.loadCustomLoginRoutes();const p=null==(o=e.auth.customLoginState)?void 0:o.customLoginSearchParams;p&&(g.endsWith("/")&&(g=g.slice(0,-1)),g+=p);const y=`${t.fetch.getBaseUrl(r,"/oauth/authorize")}/oauth/authorize`,f=j({response_type:"code",client_id:r.clientId||"INVALID-CLIENT-ID",scope:"openid email profile",redirect_uri:g,code_challenge:d,code_challenge_method:"S256",nonce:c},n);if(r.tenantResolver){var S;const e=await(null==(S=r.tenantResolver)?void 0:S.call(r));null!=e&&e.tenant&&(f.organization=e.tenant)}const h=tu(nu);h&&(f.tenantId=h),s(`${y}?${new URLSearchParams(f).toString()}`,{refresh:!0})};return{requestHostedLoginAuthorize:async t=>{var n;null==(n=localStorage)||n.removeItem(du);const a=e.auth.disableSilentRefresh;if("login"===(null==t?void 0:t.prompt))return await i(t);try{if(a)throw new Error("silent refresh is disabled");return await o()}catch(e){return await i(t)}},requestHostedLoginAuthorizeV2:async t=>{var n,s;const{shouldRedirectToLogin:r,firstTime:l,loginDirectAction:c}=null!=t?t:{};let{additionalParams:u}=null!=t?t:{};if(null==(n=localStorage)||n.removeItem(du),l){const t=e.root.urlStrategy,n=wu(t);if(a.setAuthState({isLoading:!0}),su(n))return}const d=e.auth.disableSilentRefresh;if(c&&(u=u||{},u.login_direct_action=btoa(JSON.stringify(c))),"login"===(null==(s=u)?void 0:s.prompt))return await i(u);try{if(d)throw new Error("silent refresh is disabled");return await o()}catch(e){return r?await i(u):void a.setAuthState({isLoading:!1})}},__requestHostedLoginAuthorize:i,__requestHostedLoginSilentAuthorize:o,handleHostedLoginCallback:async n=>{var o;const i=localStorage.getItem(yu)||"INVALID-CODE-VERIFIER",s=e.auth.routes,r=e.root.urlStrategy;let l=`${window.location.origin}${"path"===r?"":"#"}${s.hostedLoginRedirectUrl}`;await a.loadCustomLoginRoutes();const c=null==(o=e.auth.customLoginState)?void 0:o.customLoginSearchParams;c&&(l.endsWith("/")&&(l=l.slice(0,-1)),l+=c);const u={code:n.code,redirect_uri:l,code_verifier:i,grant_type:"authorization_code"};try{const n=await t.auth.exchangeOAuthTokensV2(u);await a.__afterAuthenticationStateUpdate(n,{isAuthenticated:!0,isLoading:!1})}catch(e){a.setAuthState({isLoading:!1}),console.error("Failed to exchangeOAuthTokens",e)}finally{const t=e.auth.user,n=window.localStorage.getItem(du);window.localStorage.removeItem(du),n&&fu(t)?await a.afterStepUpAuthNavigation():await a.afterAuthNavigation()}}}})(e,t,n),od(e,0,n),function(e,t,n){const a=n,o=async t=>{const n=e.root.appName;return ut.getFeatureFlags(t,n)},i=async()=>await a.afterStepUpAuthNavigation(),s=async t=>{const n=e.auth.loginState,i=e.auth.mfaState.step,[s]=await o(["security-center-show-login-flows"]);if(n.flow===vc.Login)if(s&&n.isBreachedPassword&&!t)a.setLoginState({step:hc.breachedPassword,loading:!1});else{const e=await a.__shouldShowPromptPasskeys();i===Ac.smsVerifyCode&&e?a.setLoginState({step:hc.promptPasskeys,loading:!1}):await a.afterAuthNavigation()}};return{postHandleVerifyMFAResponseForStepUp:i,postHandleVerifyMFAResponseForLogin:s,handleVerifyMFAResponse:async(e,t=!1)=>{const{user:n,tenants:o,activeTenant:r}=e;a.setUser(n),a.setTenantsState({tenants:o,activeTenant:r,loading:!1}),n.id&&localStorage.setItem("userId",n.id);const l=!!n.accessToken;return a.setAuthState({isAuthenticated:l}),t?await i():await s(l)},__getFeatureFlags:o}}(e,0,n),((e,t,n)=>({getMfaRequiredState:async n=>{let a=hc.loginWithTwoFactor;const o=Xl(id),i=e.auth.loginState,{isAllowedToRemember:s,mfaDeviceExpiration:r}=await t.auth.checkIfAllowToRememberMfaDevice(n.mfaToken);!n.hasOwnProperty("mfaEnrolled")||n.mfaEnrolled?Object.assign(o,{mfaDevices:n.mfaDevices,step:ou(n.mfaDevices)}):(Object.assign(o,{step:iu(n.mfaStrategies),qrCode:n.qrCode,recoveryCode:n.recoveryCode,loading:!1,mfaToken:n.mfaToken,mfaStrategies:n.mfaStrategies}),a=hc.forceTwoFactor);let l={};const c=localStorage.getItem("register-quick-login");return c&&(l={quickLoginToRegister:c,flow:vc.RegisterQuickLogin}),{user:void 0,isAuthenticated:!1,mfaState:o,loginState:j({},i,l,{mfaToken:n.mfaToken,mfaRequired:n.mfaRequired,loading:!1,error:void 0,step:a,tenantsLoading:!0,email:n.userEmail,tenants:[],allowRememberMfaDevice:s,mfaDeviceExpiration:r,isBreachedPassword:n.isBreachedPassword})}}}))(e,t),((e,t,n)=>{const a=n,o=async(n,o,i)=>{let{callback:s}=n,r=oe(n,rd);o({loading:!0,error:void 0});try{const{user:n,tenants:l=[],activeTenant:c}=await t.auth.loginWithMfaV2(r),u=!!n.accessToken,d=await async function(t,n,a){const o=e.auth.loginState;let i={};if(!a){const e=o.flow===vc.Login?hc.success:o.step;i={loginState:{flow:o.flow,quickLoginToRegister:o.quickLoginToRegister,loading:!1,step:e,error:void 0,tenants:t}}}return j({},i,{isAuthenticated:n})}(l,u,i);return await a.__afterAuthenticationStateUpdate({user:n,tenants:l,activeTenant:c},d),n.id&&localStorage.setItem("userId",n.id),o({loading:!1,error:void 0}),i?await async function(e){await a.afterStepUpAuthNavigation(),null==e||e(!0)}(s):await async function(t,n){const o=e.auth.loginState;if(o.flow!==vc.Login)return;const[i]=await a.__getFeatureFlags(["security-center-show-login-flows"]);i&&o.isBreachedPassword&&!t?a.setLoginState({step:hc.breachedPassword,loading:!1}):await a.__shouldShowPromptPasskeys()?a.setLoginState({step:hc.promptPasskeys,loading:!1}):await a.afterAuthNavigation(),null==n||n(!0)}(u,s)}catch(e){o({loading:!1,error:Gc(e)}),null==s||s(!1,e)}};return{mfaWithAuthenticator:o,loginWithMfa:async e=>await o(e,a.setLoginState,!1)}})(e,t,n),((e,t,n)=>{const a=n,o=async(e,n)=>{var o;let{callback:i}=e,s=oe(e,ld);(n=null!=(o=n)?o:a.setLoginState)({loading:!0,error:void 0});try{const e=await t.auth.preVerifyMFAEmailCode(s);a.setMfaState({otcToken:e.otcToken,step:Ac.emailVerifyCode}),n({loading:!1,error:void 0}),null==i||i(!0)}catch(e){n({error:Gc(e)}),null==i||i(null)}},i=async(e,n)=>{var o;let{callback:i}=e,s=oe(e,cd);(n=null!=(o=n)?o:a.setLoginState)({loading:!0});try{const e=await t.auth.verifyMFAEmailCodeV2(s);await a.handleVerifyMFAResponse(e),n({loading:!1,error:void 0}),null==i||i(!0)}catch(e){n({loading:!1,error:Gc(e)}),null==i||i(null)}};return{preVerifyMFAEmailCode:o,verifyMFAEmailCode:i,preVerifyMFAEmailCodeForLogin:async e=>await o(e,a.setLoginState),verifyMFAEmailCodeForLogin:async e=>await i(e,a.setLoginState)}})(0,t,n),((e,t,n)=>{const a=n,o=async(e,n)=>{let{callback:o,deviceId:i}=e,s=oe(e,ud);n({loading:!1,error:void 0});try{const e=await t.auth.preVerifyMFASMSForLogin(i,s);a.setMfaState({otcToken:e.otcToken,step:Ac.smsVerifyCode,phoneNumber:e.phoneNumber}),n({loading:!1,error:void 0}),null==o||o(!0)}catch(e){n({loading:!1,error:Gc(e)}),null==o||o(null)}},i=async(e,n,o=!1)=>{let{callback:i,deviceId:s}=e,r=oe(e,dd);n({loading:!0});try{const e=await t.auth.verifyMFASMSForLoginV2(s,r);await a.handleVerifyMFAResponse(e,o),n({loading:!1,error:void 0}),null==i||i(!0)}catch(e){n({loading:!1,error:Gc(e)}),null==i||i(null)}};return{preVerifyMFASMS:o,verifyMFASMS:i,preVerifyMFASMSForLogin:async e=>await o(e,a.setLoginState),verifyMFASMSForLogin:async e=>await i(e,a.setLoginState,!1)}})(0,t,n),((e,t,n)=>{const a=n,o=async(e,n)=>{let{callback:a,deviceId:o}=e,i=oe(e,md);n({loading:!0});try{var s;const e=await t.auth.preVerifyMFAWebAuthnForLogin(o,i),r=j({},e.options,{challenge:fd(e.options.challenge),allowCredentials:null==(s=e.options.allowCredentials)?void 0:s.map((e=>j({},e,{id:fd(e.id)})))});n({loading:!1,error:void 0}),null==a||a({options:r,webauthnToken:e.webauthnToken})}catch(e){n({loading:!1,error:Gc(e)}),null==a||a(null)}},i=async(e,n,o)=>{let{callback:i,deviceId:s}=e,r=oe(e,bd);n({loading:!0});try{const e=hd(r.publicKey),l=await t.auth.verifyMFAWebAuthnForLoginV2(s,j({},r,{options:e}));await a.handleVerifyMFAResponse(l,o),n({loading:!1,error:void 0}),null==i||i(!0)}catch(e){n({loading:!1,error:Gc(e)}),null==i||i(null)}};return{preVerifyMFAWebAuthn:o,verifyMFAWebAuthn:i,preVerifyMFAWebAuthnForLogin:async e=>await o(e,a.setLoginState),verifyMFAWebAuthnForLogin:async e=>await i(e,a.setLoginState,!1)}})(0,t,n))},tg=["callback"],ng=["callback"],ag=["user"],og=["deviceId"],ig=["deviceId"],sg=["callback"],rg=["callback"],lg=["deviceId","callback"],cg=(e,t,n)=>{const a=n;async function o(t){const n=e.auth.mfaState.step;return{step:t.recoveryCode?Ac.recoveryCode:n,loading:!1,saving:!1,error:void 0,recoveryCode:null==t?void 0:t.recoveryCode}}const i=t=>{Object.assign(e.auth.mfaState,t)};return{setMfaState:i,resetMfaState:()=>{e.auth.mfaState=Xl(id)},getMFADevices:async()=>{i({loading:!0});try{const e=await t.auth.getMFADevices();i({loading:!1,error:void 0,mfaDevices:e})}catch(e){i({loading:!1,error:Gc(e)})}},getMFAStrategies:async()=>{i({loading:!0});try{const e=(await t.auth.getMFAStrategiesConfig()).strategies.filter((({isActive:e})=>e)).map((({strategy:e})=>e));i({loading:!1,error:void 0,mfaStrategies:e})}catch(e){i({loading:!1,error:Gc(e)})}},enrollMfa:async()=>{i({saving:!0});try{const{qrCode:e}=await t.auth.enrollMfa();i({saving:!1,error:void 0,qrCode:e})}catch(e){i({saving:!1,error:Gc(e)})}},verifyMfa:async n=>{const{callback:s}=n,r=oe(n,tg);i({saving:!0});try{const n=e.auth.user,l=await t.auth.verifyMfa(r),c=await t.auth.getMFADevices(),u=await o(l);i(j({},u,{mfaDevices:c})),a.setUser(j({},n,{mfaEnrolled:!0})),null==s||s(u.recoveryCode)}catch(e){i({saving:!1,error:Gc(e)}),null==s||s(null,e)}},verifyMfaAfterForce:async e=>{const{callback:n}=e,o=oe(e,ng);i({loading:!0});try{const e=await t.auth.loginWithMfaV2(o),{user:s}=e,r=oe(e,ag),l={step:Ac.recoveryCode,loading:!1,saving:!1,error:void 0};null!=s&&s.recoveryCode&&(l.recoveryCode=s.recoveryCode),i(l),await a.__afterAuthenticationStateUpdate(j({user:s},r)),null==n||n(l.recoveryCode)}catch(e){i({loading:!1,error:Gc(e)}),null==n||n(null,e)}},disableMfa:async e=>{i({saving:!0});try{var n;await t.auth.disableMfa(e);const a=await t.auth.getMFADevices();i({saving:!1,error:void 0,mfaDevices:a}),null==(n=e.callback)||n.call(e,!0)}catch(t){var a;i({saving:!1,error:Gc(t)}),null==(a=e.callback)||a.call(e,!1,t)}},preDisableMfaSms:async e=>{const{deviceId:n}=e,a=oe(e,og);i({saving:!0});try{var o;const e=await t.auth.preDisableMFASMS(n);i({saving:!1,error:void 0,otcToken:e.otcToken,phoneNumber:e.phoneNumber}),null==(o=a.callback)||o.call(a,!0)}catch(e){var s;i({saving:!1,error:Gc(e)}),null==(s=a.callback)||s.call(a,!1,e)}},disableMfaSms:async e=>{const{deviceId:n}=e,a=oe(e,ig);i({saving:!0});try{var o;await t.auth.disableMFASMS(n,a);const e=await t.auth.getMFADevices();i({saving:!1,error:void 0,mfaDevices:e}),null==(o=a.callback)||o.call(a,!0)}catch(e){var s;i({saving:!1,error:Gc(e)}),null==(s=a.callback)||s.call(a,!1,e)}},preEnrollMfaSms:async e=>{i({saving:!0});try{var n;const a=await t.auth.preEnrollMFASMS(e);i({saving:!1,error:void 0,otcToken:a.otcToken,phoneNumber:a.phoneNumber}),null==(n=e.callback)||n.call(e,!0)}catch(t){var a;i({saving:!1,error:Gc(t)}),null==(a=e.callback)||a.call(e,!1,t)}},enrollMfaSms:async e=>{const{callback:n}=e,a=oe(e,sg);i({saving:!0});try{const e=await t.auth.enrollMFASMS(a),s=await t.auth.getMFADevices(),r=await o(e);i(j({},r,{mfaDevices:s})),null==n||n(r.recoveryCode)}catch(e){i({saving:!1,error:Gc(e)}),null==n||n(null,e)}},preEnrollMfaWebAuthn:async e=>{i({saving:!0});try{var n,a;const o=await t.auth.preEnrollMFAWebAuthn(),s=j({},o.options,{challenge:fd(o.options.challenge),user:j({},o.options.user,{id:fd(o.options.user.id)}),excludeCredentials:null==(n=o.options.excludeCredentials)?void 0:n.map((e=>j({},e,{id:fd(e.id)})))});i({saving:!1}),null==(a=e.callback)||a.call(e,{options:s,webauthnToken:o.webauthnToken})}catch(t){var o;i({saving:!1,error:Gc(t)}),null==(o=e.callback)||o.call(e,null,t)}},enrollMfaWebAuthn:async e=>{const{callback:n}=e,a=oe(e,rg);i({saving:!0});try{const e=hd(a.publicKey),s=await t.auth.enrollMFAWebAuthn(j({},a,{options:e})),r=await t.auth.getMFADevices(),l=await o(s);i(j({},l,{mfaDevices:r})),null==n||n(l.recoveryCode)}catch(e){i({saving:!1,error:Gc(e)}),null==n||n(null,e)}},preDisableMfaWebAuthn:async e=>{const{deviceId:n,callback:a}=e;i({saving:!0});try{var o;const e=await t.auth.preDisableMFAWebAuthn(n),s=j({},e.options,{challenge:fd(e.options.challenge),allowCredentials:null==(o=e.options.allowCredentials)?void 0:o.map((e=>j({},e,{id:fd(e.id)})))});i({saving:!1}),null==a||a({options:s,webauthnToken:e.webauthnToken})}catch(e){i({saving:!1,error:Gc(e)}),null==a||a(null,e)}},disableMfaWebAuthn:async e=>{const{deviceId:n,callback:a}=e,o=oe(e,lg);i({saving:!0});try{const e=hd(o.publicKey);await t.auth.disableMFAWebAuthn(n,j({},o,{options:e}));const s=await t.auth.getMFADevices();i({saving:!1,error:void 0,mfaDevices:s}),null==a||a(!0)}catch(e){i({saving:!1,error:Gc(e)}),null==a||a(!1,e)}},__getMfaStateAfterEnroll:o}},ug={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:le.DESC,_sortBy:Gl.name},usersPageOffset:0,accountSettings:{}}},dg=e=>Mc(ug,e),gg=({items:e},t)=>e.map((e=>{var n,a;return{name:e.name,tenantId:e.tenantId,numberOfUsers:null!=(n=null==(a=t.find((t=>t.tenantId===e.tenantId)))?void 0:a.totalUsers)?n:0,createdAt:e.createdAt,metadata:e.metadata,isReseller:e.isReseller}}));function pg(e,t,n){var a,o;if(e.tenantId===t){var i;const t=[...null!=(i=null==e?void 0:e.children)?i:[],...n].filter(((e,t,n)=>t===n.findIndex((t=>t.tenantId===e.tenantId))));return j({},e,{children:t})}return j({},e,{children:null!=(a=null==e||null==(o=e.children)?void 0:o.map((e=>pg(e,t,n))))?a:[]})}function yg(e,t){var n;return j({},e,{children:null!=(n=e.children)&&n.length?e.children.filter((e=>e.tenantId!==t)).map((e=>yg(e,t))):[]})}const fg=(e,t,n)=>{var a,o;return e.tenantId===t?j({},e,{name:n}):j({},e,{children:null!=(a=null==e||null==(o=e.children)?void 0:o.map((e=>fg(e,t,n))))?a:[]})},Sg=(e,t,n)=>{var a,o;return e?e.tenantId===t?j({},e,{isReseller:n}):j({},e,{children:null!=(a=null==e||null==(o=e.children)?void 0:o.map((e=>Sg(e,t,n))))?a:[]}):{}},hg=(e,t,n)=>{const a=t=>{Object.assign(e.auth.allAccountsState,{loaders:j({},e.auth.allAccountsState.loaders,{[t.key]:t.value})})},o=t=>{Object.assign(e.auth.allAccountsState,{errors:j({},e.auth.allAccountsState.errors,{[t.key]:t.value}),loaders:j({},e.auth.allAccountsState.loaders,{[t.key]:!1})})},i=t=>{Object.assign(e.auth.allAccountsState,t)},s=t=>{Object.assign(e.auth.allAccountsState.selectedAccount,t)},r=()=>e.auth.allAccountsState,l=async e=>{var n,i,l,c,u,d,g,p;const{jwt:y,_tenantId:f,_email:S}=e,h=wc.GET_ACCOUNT_USERS;a({key:h,value:!0});const v=r(),m=null!=(n=null!=(i=null==e?void 0:e._offset)?i:null==v||null==(l=v.selectedAccount)||null==(c=l.usersQueryParams)?void 0:c._offset)?n:0,b=null!=(u=null!=(d=null==e?void 0:e._limit)?d:null==v||null==(g=v.selectedAccount)||null==(p=g.usersQueryParams)?void 0:p._limit)?u:10,A=j({_offset:m,_limit:b,_tenantId:f,_includeSubTenants:!1},!!S&&{_email:S});try{const{items:e,_metadata:{totalItems:n,totalPages:o}}=await t.users.getUsersV3(A,{jwt:y}),i={totalUsersItems:n,totalUsersPages:o,usersQueryParams:j({_offset:null!=m?m:0,_limit:null!=b?b:10},!!S&&{_email:S})};if(e.length){const n=e.map((e=>e.id)),a=await t.roles.getRoles(),o=await t.users.getUsersRoles({ids:n},{jwt:y}),r=e.map((e=>{var t,n;const i=null==o||null==(t=o.find((t=>t.userId===e.id)))?void 0:t.roleIds;return j({},e,{roles:null!=(n=null==i?void 0:i.map((e=>{var t;return null!=(t=null==a?void 0:a.find((t=>t.id===e)))?t:[]})))?n:[]})}));s(j({users:r},i))}else s(j({users:[]},i))}catch(e){o({key:h,value:Gc(e)})}finally{a({key:h,value:!1})}};return{setAllAccountsLoader:a,setAllAccountsError:o,setAllAccountsState:i,setSelectedAccountState:s,resetAllAccountsState:()=>{e.auth.allAccountsState=Xl(ug)},clearSelectedAccount:()=>{e.auth.allAccountsState.selectedAccount=Xl(ug.selectedAccount)},loadAccounts:async e=>{const n=wc.GET_ACCOUNTS;a({key:n,value:!0});const{accountsQueryParams:l}=r(),{jwt:c,_limit:u,_offset:d}=e,g={_offset:null!=d?d:l._offset,_limit:null!=u?u:l._limit,_subTenantId:null==e?void 0:e._subTenantId};try{if(c){var p;const{selectedAccount:n}=r(),{items:a,_links:o}=await t.tenants.searchSubTenants(g,{jwt:c}),i=await t.tenants.getTenantsUsersCount({tenantIds:a.map((e=>e.tenantId))},{jwt:c}),l=gg({items:a},i),u=pg(n.accounts?n.accounts:n,null!=(p=null==e?void 0:e._subTenantId)?p:"",l.map((e=>({name:e.name,tenantId:e.tenantId,numberOfUsers:e.numberOfUsers,createdAt:e.createdAt,metadata:e.metadata,children:[],loadMoreLink:null==o?void 0:o.next,isReseller:e.isReseller}))));s({accounts:u})}else{var y;const{accounts:n}=r(),{items:a,_links:o}=await t.tenants.searchSubTenants(g),s=await t.tenants.getTenantsUsersCount({tenantIds:a.map((e=>e.tenantId))}),l=gg({items:a},s),c=pg(n,null!=(y=null==e?void 0:e._subTenantId)?y:"",l.map((e=>({name:e.name,tenantId:e.tenantId,numberOfUsers:e.numberOfUsers,createdAt:e.createdAt,metadata:e.metadata,children:[],loadMoreLink:null==o?void 0:o.next,isReseller:e.isReseller}))));i({accounts:c})}}catch(e){o({key:n,value:Gc(e)})}finally{a({key:n,value:!1})}},searchAccounts:async e=>{const{jwt:n}=e,s=wc.SEARCH_ACCOUNTS;a({key:s,value:!0});const{rootAccount:l}=r();try{if(null!=e&&e._subTenantId){var c;const{items:a}=await t.tenants.searchSubTenants({_offset:0,_limit:50,_filter:null!=(c=null==e?void 0:e._filter)?c:"",_subTenantId:e._subTenantId},{jwt:n});i({searchAccountsData:[...a,{name:l.name,tenantId:l.tenantId}]})}}catch(e){o({key:s,value:Gc(e)})}finally{a({key:s,value:!1})}},updateSubAccountAccessForUser:async e=>{const n=wc.UPDATE_SUB_ACCOUNT_ACCESS_FOR_USER;a({key:n,value:!0});const{selectedAccount:i}=r(),{userId:l,allowAccess:c,jwt:u,callback:d}=e;try{var g;await t.subTenants.updateSubAccountAccess(l,{allowAccess:c},{jwt:u}),s({users:null==i||null==(g=i.users)?void 0:g.map((e=>e.id===l?j({},e,{subAccountAccessAllowed:c}):e))}),null==d||d(!0)}catch(e){o({key:n,value:Gc(e)}),null==d||d(!1)}finally{a({key:n,value:!1})}},createSubAccount:async e=>{const n=wc.CREATE_SUB_ACCOUNT;a({key:n,value:!0});const{name:l,parentTenantId:c,tenantId:u,jwt:d,callback:g}=e;try{if(d){const{accounts:e,selectedAccount:n}=r(),a=await t.subTenants.createSubTenant({name:l,parentTenantId:c,tenantId:u},{jwt:d}),o=pg(e,null!=c?c:"",[{name:a.name,tenantId:a.tenantId,numberOfUsers:0,createdAt:new Date}]),g=pg(j({name:"",tenantId:""},null==n?void 0:n.accounts),null!=c?c:"",[{name:a.name,tenantId:a.tenantId,numberOfUsers:0,createdAt:new Date}]);i({accounts:o}),s({accounts:g})}else{const{accounts:e}=r(),n=await t.subTenants.createSubTenant({name:l,tenantId:u,parentTenantId:c}),a=pg(e,null!=c?c:"",[{name:n.name,tenantId:n.tenantId,numberOfUsers:0,createdAt:new Date}]);i({accounts:a})}null==g||g(!0)}catch(e){o({key:n,value:Gc(e)}),null==g||g(!1)}finally{a({key:n,value:!1})}},updateSubAccount:async e=>{},deleteSubAccount:async e=>{const n=wc.DELETE_SUB_ACCOUNT;a({key:n,value:!0});const{jwt:l,tenantId:c,callback:u}=e;try{if(l){const{selectedAccount:e,accounts:n}=r();await t.subTenants.deleteSubTenant(c,{jwt:l});const a=yg(n,c),o=yg(e.accounts,c);i({accounts:a}),s({accounts:o})}else{const{accounts:e}=r();await t.subTenants.deleteSubTenant(c);const n=yg(e,c);i({accounts:n})}null==u||u(!0)}catch(e){o({key:n,value:Gc(e)}),null==u||u(!1)}finally{a({key:n,value:!1})}},updateSubAccountSettings:async e=>{const n=wc.UPDATE_SUB_ACCOUNT_SETTINGS;a({key:n,value:!0});const{jwt:l,name:c,callback:u,tenantId:d}=e;try{if(l){const{selectedAccount:e,accounts:n}=r();await t.subTenants.updateSubTenant({tenantId:d},{name:c},{jwt:l});const a=fg(e.accounts,d,c);s({name:c,accounts:a});const o=fg(n,d,c);i({accounts:o})}else{const{accounts:e}=r();await t.subTenants.updateSubTenant({tenantId:d},{name:c});const n=fg(e,d,c);i({accounts:n})}null==u||u(!0)}catch(e){o({key:n,value:Gc(e)}),null==u||u(!1)}finally{a({key:n,value:!1})}},updateSubAccountManagement:async r=>{const l=wc.UPDATE_SUB_ACCOUNT_MANAGEMENT;n.setAllAccountsLoader({key:l,value:!0});const{jwt:c,isReseller:u,callback:d,tenantId:g,shouldUpdateSelectedAccount:p}=r,y=!!c;try{if(p){const{selectedAccount:n,accounts:a}=e.auth.allAccountsState;await t.subTenants.updateSubTenantManagement({tenantId:g},{isReseller:u},c?{jwt:c}:void 0);const o=Sg(n.accounts,g,null!=u&&u);s({accounts:o}),y||s({isReseller:u});const r=Sg(a,g,null!=u&&u);i({accounts:r})}else{const{accounts:n}=e.auth.allAccountsState;t.subTenants.updateSubTenantManagement({tenantId:g},{isReseller:u},c?{jwt:c}:void 0);const a=Sg(n,g,null!=u&&u);i({accounts:a})}null==d||d(!0)}catch(e){o({key:l,value:Gc(e)}),null==d||d(!1)}finally{a({key:l,value:!1})}},addUsersToAccount:async e=>{const{users:n,tenantId:i,jwt:s,callback:r,allowSubAccountAccess:c=!1,roleIds:u}=e,d=wc.ADD_USERS_TO_ACCOUNT;try{a({key:d,value:!0}),await t.subTenants.addUsersToSubTenant({users:n,tenantId:i,allowSubAccountAccess:c,roleIds:u},{jwt:s}),await l({jwt:s,_tenantId:i}),null==r||r(!0)}catch(e){o({key:d,value:Gc(e)}),null==r||r(!1)}finally{a({key:d,value:!1})}},getAccountUsers:l,deleteUsersFromAccount:async e=>{const n=wc.DELETE_USERS_FROM_ACCOUNT;a({key:n,value:!0});const{userId:i,subTenants:s,jwt:r,callback:c}=e;try{await t.subTenants.removeUserFromTenantAndSubTenants({userId:i,subTenants:s},{jwt:r}),await l({jwt:r,_tenantId:s[0].tenantId}),null==c||c(!0)}catch(e){o({key:n,value:Gc(e)}),null==c||c(!1)}finally{a({key:n,value:!1})}},setUserRolesForSubAccount:async e=>{const{userId:n,subTenantsRoles:i,jwt:s,callback:c}=e,u=wc.SET_USER_ROLES_FOR_SUB_ACCOUNT;try{a({key:u,value:!0});const{selectedAccount:e}=r();await t.subTenants.setUserRolesForSubTenants(n,{subTenantsRoles:i},{jwt:s}),await l({jwt:s,_tenantId:e.tenantId}),null==c||c(!0)}catch(e){o({key:u,value:Gc(e)}),null==c||c(!1)}finally{a({key:u,value:!1})}},getUserJwtForSubAccount:async e=>{const{tenantId:n,callback:i}=e,r=wc.GET_USER_JWT;try{a({key:r,value:!0});const e=await t.users.GetUserJwt({tenantId:n});s({userJwt:e,accessPermission:!0}),null==i||i(!0)}catch(e){o({key:r,value:Gc(e)}),s({accessPermission:!1}),null==i||i(!1)}finally{a({key:r,value:!1})}},setRootAccountData:async()=>{const n=wc.SET_ROOT_ACCOUNT_DATA;a({key:n,value:!0});const{activeTenant:s}=e.auth.tenantsState,{accounts:l}=r();if(s)try{var c;const e=await t.tenants.getTenantsUsersCount({tenantIds:[null==s?void 0:s.tenantId]}),o={name:null==s?void 0:s.name,tenantId:null==s?void 0:s.tenantId,numberOfUsers:null==(c=e[0])?void 0:c.totalUsers,createdAt:null==s?void 0:s.createdAt};i({rootAccount:o,accounts:j({},l,o)})}catch(e){o({key:n,value:Gc(e)})}finally{a({key:n,value:!1})}},setSelectedSubAccountData:async e=>{const{jwt:n}=e,i=wc.SET_SELECTED_SUB_ACCOUNT_DATA;try{var r,c,u,d,g,p,y;a({key:i,value:!0});const e=await t.accountSettings.getSettings({jwt:n}),[o,f,S]=await Promise.all([t.tenants.getTenantsUsersCount({tenantIds:[null!=(r=null==e?void 0:e.tenantId)?r:""]},{jwt:n}),t.tenants.getParentTenants({jwt:n}),t.tenants.getHierarchyMetadata({_tenantIds:[null!=(c=null==e?void 0:e.tenantId)?c:""]},{jwt:n})]);s({tenantId:null!=(u=e.tenantId)?u:"",name:e.name,numberOfUsersObject:o[0],parentsAccounts:f,numberOfSubAccounts:null==(d=S[0])?void 0:d.totalSubTenants,accountSettings:e,accounts:{name:e.name,tenantId:null!=(g=e.tenantId)?g:"",numberOfUsers:null==(p=o[0])?void 0:p.totalUsers,createdAt:void 0,children:[]}}),await l({jwt:n,_tenantId:null!=(y=null==e?void 0:e.tenantId)?y:""})}catch(e){o({key:i,value:Gc(e)})}finally{a({key:i,value:!1})}},loadNumberOfUsersForSelectedSubAccount:async e=>{const{tenantId:n,jwt:i}=e,r=wc.LOAD_NUMBER_OF_USERS_FOR_ACCOUNT;try{a({key:r,value:!0});const e=await t.tenants.getTenantsUsersCount({tenantIds:[n]},{jwt:i});s({numberOfUsersObject:e[0]})}catch(e){o({key:r,value:Gc(e)})}finally{a({key:r,value:!1})}}}},vg={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},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:[]}},mg=e=>Mc(vg,e),bg=(e,t,n)=>{const a=Xl(vg);return{setAllAccountDialogsState:t=>{Object.assign(e.auth.allAccountsDialogsState,t)},resetAllAccountDialogsState:()=>{e.auth.allAccountsDialogsState=Xl(vg)},openCreateSubAccountDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.createSubAccountDialog,j({},t,{open:!0}))},closeCreateSubAccountDialog:()=>{e.auth.allAccountsDialogsState.createSubAccountDialog=a.createSubAccountDialog},openUpdateSubAccountDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.updateSubAccountDialog,j({},t,{open:!0}))},closeUpdateSubAccountDialog:()=>{e.auth.allAccountsDialogsState.updateSubAccountDialog=a.updateSubAccountDialog},openEnableSubAccountManagementDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.enableSubAccountManagementDialog,j({},t,{open:!0}))},closeEnableSubAccountManagementDialog:()=>{e.auth.allAccountsDialogsState.enableSubAccountManagementDialog=a.enableSubAccountManagementDialog},openDisableSubAccountManagementDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.disableSubAccountManagementDialog,j({},t,{open:!0}))},closeDisableSubAccountManagementDialog:()=>{e.auth.allAccountsDialogsState.disableSubAccountManagementDialog=a.disableSubAccountManagementDialog},openDeleteSubAccountDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.deleteSubAccountDialog,j({},t,{open:!0}))},closeDeleteSubAccountDialog:()=>{e.auth.allAccountsDialogsState.deleteSubAccountDialog=a.deleteSubAccountDialog},openAddUsersToAccountDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.addUsersToAccountDialog,j({},t,{open:!0}))},closeAddUsersToAccountDialog:()=>{e.auth.allAccountsDialogsState.addUsersToAccountDialog=a.addUsersToAccountDialog},openDeleteUserFromAccountDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.deleteUserFromAccountDialog,j({},t,{open:!0}))},closeDeleteUserFromAccountDialog:()=>{e.auth.allAccountsDialogsState.deleteUserFromAccountDialog=a.deleteUserFromAccountDialog},openEditUserRolesDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.editUserRolesDialog,j({},t,{open:!0}))},closeEditUserRolesDialog:()=>{e.auth.allAccountsDialogsState.editUserRolesDialog=a.editUserRolesDialog}}},Ag={devices:[],loading:!1,error:null},wg=e=>Mc(Ag,e),Tg=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auth.passkeysState,t)};return{setPasskeysState:o,resetPasskeysState:()=>{e.auth.passkeysState=Xl(Ag)},loadWebAuthnDevices:async()=>{o({loading:!0});try{const{devices:e}=await t.auth.getWebAuthnDevices();o({devices:e,loading:!1})}catch(e){o({loading:!1,error:Gc(e,null)})}},deleteWebAuthnDevice:async n=>{const{callback:a,deviceId:i}=n;o({loading:!0});try{await t.auth.deleteWebAuthnDevice(i);const n=e.auth.passkeysState.devices.filter((e=>e.id!==i));o({devices:n,loading:!1}),null==a||a(!0)}catch(e){o({loading:!1,error:Gc(e,null)}),null==a||a(null,e)}},__shouldShowPromptPasskeys:async function(){const{publicAuthStrategyPolicy:n}=e.auth.securityPolicyState,{policy:i}=n,s=await async function(e){var t;return!(null==e||null==(t=e.secondaryAuthStrategies)||!t.some((({isActive:e,strategy:t})=>e&&t===yn.Passkeys)))}(i),r="Passkeys"===localStorage.getItem("preferred-login-method"),l="true"===localStorage.getItem("dont-show-again-prompt-passkeys"),[c]=await a.__getFeatureFlags(["show-passkeys-new"]);if(!c||!s||r||l)return!1;{const{devices:e}=await t.auth.getWebAuthnDevices();return o({devices:null!=e?e:[]}),0===(null!=e&&e.length?e.length:0)}}}},Eg={loading:!1,error:null},Ig=e=>Mc(Eg,e),kg=["callback","profilePictureUrl"],Og=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auth.profileState,t)};return{setProfileState:o,resetProfileState:()=>{e.auth.profileState=Xl(Eg)},loadProfile:async()=>{o({loading:!0});try{const n=await Zl(t.teams.getProfile,3,2e3),i=e.auth.user;a.setUser(j({},i,n)),o({profile:n,loading:!1})}catch(e){o({loading:!1,error:Gc(e)})}},saveProfile:async n=>{const{callback:i,profilePictureUrl:s}=n,r=oe(n,kg);o({saving:!0,error:null,loading:!0});try{var l;const n=null!=(l=e.auth.profileState.profile)?l:{};let o=n.profilePictureUrl;if(s!==n.profilePictureUrl&&s&&(s||"").match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/)){const e=Sd(s,"image");if(e){o=await t.teams.updateProfileImage(e);const n=Date.now().toString(),a=new URL(o);a.searchParams.set("t",n),o=a.href}}const c=j({},n,r,{profilePictureUrl:o}),u=await t.users.updateUserProfileV2(c),d=e.auth.user;a.setUser(j({},d,u)),a.setProfileState({profile:u,saving:!1,loading:!1}),null==i||i(c)}catch(e){o({saving:!1,error:Gc(e),loading:!1}),null==i||i(null,e)}},changePassword:async e=>{o({loading:!0});try{var n;await t.teams.changePassword(e),o({loading:!1,error:void 0}),null==(n=e.callback)||n.call(e,!0)}catch(t){var a;o({loading:!1,error:Gc(t)}),null==(a=e.callback)||a.call(e,null,t)}}}},_g={loading:!1},Pg=e=>Mc(_g,e),Ug=["callback"],Lg=["id"],Dg=(e,t,n)=>{const a=t=>{Object.assign(e.auth.provisioningState,t)},o=async e=>{const{count:n}=await t.directory.countConfigurationUsers(e.id);return j({},e,{count:n})};return{setProvisioningState:a,resetProvisioningState:()=>{e.auth.provisioningState=Xl(_g)},__loadCountForConnection:o,loadProvisionConnections:async()=>{a({loading:!0,error:null});try{const e=await t.directory.getConfigs(),n=await Promise.all(e.map((e=>o(e))));a({connections:n,loading:!1})}catch(e){a({error:Gc(e),loading:!1})}},createProvisionConnection:async e=>{const{callback:n}=e,i=oe(e,Ug);a({loading:!0,error:null});try{const e=await t.directory.createConfiguration(i),s=await t.directory.getConfigs(),r=await Promise.all(s.map((e=>o(e))));a({connections:r,loading:!1}),null==n||n(e)}catch(e){a({error:Gc(e),loading:!1})}},deleteProvisionConnection:async e=>{const{id:n,callback:i}=e;a({loading:!0,error:null});try{await t.directory.deleteConfiguration(n);const e=await t.directory.getConfigs(),s=await Promise.all(e.map((e=>o(e))));a({connections:s,loading:!1}),null==i||i(!0)}catch(e){a({error:Gc(e),loading:!1}),null==i||i(!1,e)}},updateProvisionConnection:async e=>{const{id:n}=e,i=oe(e,Lg);a({loading:!0,error:null});try{await t.directory.updateConfiguration(n,i);const e=await t.directory.getConfigs(),s=await Promise.all(e.map((e=>o(e))));a({connections:s,loading:!1})}catch(e){a({error:Gc(e),loading:!1})}}}},Rg={step:Tc.ResetPhoneNumber,loading:!1},Cg=e=>Mc(Rg,e),Ng=["callback"],Mg=["callback"],Fg=["callback"],$g=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auth.resetPhoneNumberState,t)};return{setResetPhoneNumberState:o,resetResetPhoneNumberState:()=>{e.auth.resetPhoneNumberState=Xl(Rg)},resetPhoneNumber:async e=>{const{callback:n}=e,i=oe(e,Ng);o({loading:!0});try{const e=await t.auth.resetPhoneNumber(i);o({loading:!1,error:void 0,resetPhoneNumberToken:e.resetPhoneNumberToken,step:Tc.VerifyResetPhoneNumber}),a.setLoginState({email:i.email})}catch(e){o({loading:!1,error:Gc(e)}),null==n||n(null,e)}},verifyResetPhoneNumber:async e=>{const{callback:n}=e,a=oe(e,Mg);o({loading:!0});try{const e=await t.auth.verifyResetPhoneNumber(a);o({loading:!1,error:void 0,changePhoneNumberToken:e.changePhoneNumberToken,step:Tc.ChangePhoneNumber}),null==n||n(!0)}catch(e){o({loading:!1,error:Gc(e)}),null==n||n(null,e)}},changePhoneNumber:async n=>{const{callback:i}=n,s=oe(n,Fg);o({loading:!0});try{const{onRedirectTo:n,routes:r}=e.auth;await t.auth.changePhoneNumber({phoneNumber:s.phoneNumber,changePhoneNumberToken:s.changePhoneNumberToken}),a.setLoginState({step:hc.loginWithSmsOtc}),await a.passwordlessPreLogin({type:rn.SmsCode,email:s.email,recaptchaToken:s.recaptchaToken}),n(r.loginUrl),o({loading:!1}),null==i||i(!0)}catch(e){o({loading:!1,error:Gc(e)}),null==i||i(null,e)}}}},jg={loaders:{},errors:{},roles:[],permissions:[],permissionCategories:[]},Gg=e=>Mc(jg,e),xg=["callback"],Vg=["callback"],Bg=["callback"],Wg=["callback"],zg=["callback"],Kg=["callback"],Hg=(e,t,n)=>{const a=t=>{Object.assign(e.auth.rolesState,t)},o=t=>{Object.assign(e.auth.rolesState,{loaders:j({},e.auth.rolesState.loaders,{[t.key]:t.value})})},i=t=>{Object.assign(e.auth.rolesState,{errors:j({},e.auth.rolesState.errors,{[t.key]:t.value}),loaders:j({},e.auth.rolesState.loaders,{[t.key]:!1})})},s=async n=>{var s;const r=Ec.LOAD_ROLES;o({key:r,value:!(null!=(s=null==n?void 0:n.silentLoading)&&s)});try{const[n,i,s]=await Promise.all([t.roles.getRoles(),t.roles.getPermissions(),t.roles.getPermissionCategories()]),{selectedRole:l}=e.auth.rolesState,c=null==n?void 0:n.find((({id:e})=>(null==l?void 0:l.id)===e));a({roles:n,permissions:i,permissionCategories:s,selectedRole:c})}catch(e){i({key:r,value:Gc(e)})}finally{o({key:r,value:!1})}},r=async e=>{const{callback:n}=e,r=oe(e,zg),l=Ec.MANAGE_PERMISSIONS;o({key:l,value:!0});try{const e=await t.roles.attachPermissionsToRole(r);await s({silentLoading:!0}),a({saving:!1}),null==n||n(e)}catch(e){i({key:l,value:Gc(e)}),null==n||n(null,e)}finally{o({key:l,value:!1})}};return{setRolesState:a,setRolesStateLoader:o,setRolesStateError:i,resetRolesState:()=>{e.auth.rolesState=Xl(jg)},loadRolesAndPermissions:s,addRole:async e=>{const{callback:n}=e,a=oe(e,xg),r=Ec.ADD_ROLE;o({key:r,value:!0});try{const e=await t.roles.addRole(a);await s({silentLoading:!0}),null==n||n(e)}catch(e){i({key:r,value:Gc(e)}),null==n||n(null,e)}finally{o({key:r,value:!1})}},addRoleV2:async e=>{const{callback:n}=e,a=oe(e,Vg),r=Ec.ADD_ROLE;o({key:r,value:!0});try{const e=await t.roles.addRoleV2(a);await s({silentLoading:!0}),null==n||n(e)}catch(e){i({key:r,value:Gc(e)}),null==n||n(null,e)}finally{o({key:r,value:!1})}},updateRole:async e=>{const{callback:n}=e,r=oe(e,Bg),l=Ec.EDIT_ROLE_DIALOG;o({key:l,value:!0});try{const e=await t.roles.updateRole(r);await s({silentLoading:!0}),a({saving:!1}),null==n||n(e)}catch(e){i({key:l,value:Gc(e)}),null==n||n(null,e)}finally{o({key:l,value:!1})}},deleteRole:async e=>{const{callback:n}=e,r=oe(e,Wg),l=Ec.DELETE_ROLE_DIALOG;o({key:l,value:!0});try{await t.roles.deleteRole(r),await s({silentLoading:!0}),a({saving:!1}),null==n||n(!0)}catch(e){i({key:l,value:Gc(e)}),null==n||n(!1,e)}finally{o({key:l,value:!1})}},attachPermissionsToRole:r,attachPermissionToRoles:async e=>{const{callback:t}=e,n=oe(e,Kg),a=Ec.MANAGE_PERMISSIONS;o({key:a,value:!0});try{await Promise.all(n.roleIds.map((e=>r({roleId:e,permissionIds:[n.permissionId]})))),await s({silentLoading:!0}),null==t||t(!0)}catch(e){i({key:a,value:Gc(e)}),null==t||t(null,e)}finally{o({key:a,value:!1})}}}},qg={ipRestrictions:{loading:!1,pagination:{_offset:0,_limit:4,_filter:pn.ALLOW},totalPages:1,userIpValid:!1},emailDomainRestrictions:{loading:!0}},Jg=e=>Mc(qg,e),Yg=["callback"],Xg=["callback"],Qg=["callback"],Zg=["callback"],ep=(e,t,n)=>{const a=n,o=e=>{var t,n,a;return{_filter:null!=(t=null==e?void 0:e._filter)?t:pn.ALLOW,_limit:null!=(n=null==e?void 0:e._limit)?n:10,_offset:null!=(a=null==e?void 0:e._offset)?a:0}},i=e=>async(...t)=>{const[n]=await a.__getFeatureFlags(["security-center-admin-portal-major-version"]);await e(...t),n&&(await a.loadRecommendations(),await a.loadInsights())},s=t=>{Object.assign(e.auth.restrictionsState.ipRestrictions,t)},r=t=>{Object.assign(e.auth.restrictionsState.emailDomainRestrictions,t)},l=async()=>{try{const{valid:e}=await t.auth.testCurrentIpInAllowList();s({userIpValid:e})}catch(e){s({error:Gc(e)})}},c=i((async()=>{s({loading:!0,error:null});try{const n=e.auth.restrictionsState.ipRestrictions,a=await t.auth.getIPRestrictionsConfig(),i=o({_filter:a.strategy,_limit:n.pagination._limit,_offset:n.pagination._offset}),{items:r,_metadata:{totalPages:l}}=await t.auth.getIPRestrictions(i);s({data:{restrictions:r,config:a},totalPages:l,pagination:i,loading:!1})}catch(e){s({error:Gc(e),loading:!1})}})),u=i((async n=>{const{callback:a}=n,i=oe(n,Yg);s({saving:!0,error:null});try{var r,c;await t.auth.createIPRestriction(i);const n=e.auth.restrictionsState.ipRestrictions,u=o(n.pagination),{items:d,_metadata:{totalPages:g}}=await t.auth.getIPRestrictions(u),p=d;await l(),s({data:{config:null!=(r=null==(c=n.data)?void 0:c.config)?r:{isActive:!1,strategy:pn.ALLOW},restrictions:p},pagination:u,totalPages:g,saving:!1}),null==a||a(!0)}catch(e){s({saving:!1,error:Gc(e)}),null==a||a(null,e)}})),d=i((async n=>{const{callback:a}=n,i=oe(n,Xg);s({saving:!0,error:null});try{await t.auth.updateIPRestrictionConfig(i);const n=e.auth.restrictionsState.ipRestrictions,r=await t.auth.getIPRestrictionsConfig(),c=o(j({},n.pagination,{_filter:r.strategy})),{items:u,_metadata:{totalPages:d}}=await t.auth.getIPRestrictions(c),g=u;await l(),s({data:{config:r,restrictions:g},pagination:c,totalPages:d,saving:!1}),null==a||a(!0)}catch(e){s({saving:!1,error:Gc(e)}),null==a||a(null,e)}})),g=i((async n=>{const{id:a,callback:i}=n;s({saving:!0,error:null});try{var r;await t.auth.deleteIPRestriction(a);const n=e.auth.restrictionsState.ipRestrictions,c=o(n.pagination),{items:u,_metadata:{totalPages:d}}=await t.auth.getIPRestrictions(c),g=u;await l(),s({data:{config:(null==(r=n.data)?void 0:r.config)||{isActive:!1,strategy:pn.ALLOW},restrictions:g},pagination:c,totalPages:d,saving:!1}),null==i||i(!0)}catch(e){s({saving:!1,error:Gc(e)}),null==i||i(null,e)}})),p=i(l),y=i((async n=>{const{callback:a}=n;s({saving:!0,error:null});try{var i;const n=null!=(i=e.auth.userIp)?i:"";await Promise.all([t.auth.createIPRestriction({ip:n,isActive:!0,description:"My IP",strategy:pn.ALLOW}),t.auth.updateIPRestrictionConfig({isActive:!0})]);const r=e.auth.restrictionsState.ipRestrictions,l=o(r.pagination),{items:c,_metadata:{totalPages:u}}=await t.auth.getIPRestrictions(l),d=c;s({data:{config:{isActive:!0,strategy:pn.ALLOW},restrictions:d},userIpValid:!0,pagination:l,totalPages:u,saving:!1}),null==a||a(!0)}catch(e){s({saving:!1,error:e}),null==a||a(!1,e)}})),f=i((async()=>{r({loading:!0,error:null});try{const e=await t.auth.getDomainRestrictionsConfig(),n=(await t.auth.getDomainRestrictions()).items.filter((t=>t.type===e.listType));r({data:{restrictions:n,config:e},loading:!1})}catch(e){r({error:Gc(e),loading:!1})}})),S=i((async n=>{const{callback:a}=n,o=oe(n,Qg);r({saving:!0,error:null});const i=e.auth.restrictionsState.emailDomainRestrictions;try{var s;await t.auth.createDomainRestriction(o);const e=(await t.auth.getDomainRestrictions()).items.filter((e=>{var t;return e.type===(null==(t=i.data)?void 0:t.config.listType)}));r({data:{config:(null==(s=i.data)?void 0:s.config)||{active:!1,blockPublicDomains:!1,listType:o.type},restrictions:e},saving:!1}),null==a||a(!0)}catch(e){r({saving:!1,error:Gc(e)}),null==a||a(null,e)}})),h=i((async e=>{const{callback:n}=e,a=oe(e,Zg);r({saving:!0,error:null});try{const e=await t.auth.updateDomainRestrictionConfig(a),o=(await t.auth.getDomainRestrictions()).items.filter((t=>t.type===e.listType));r({data:{config:e,restrictions:o},saving:!1}),null==n||n(!0)}catch(e){r({saving:!1,error:Gc(e)}),null==n||n(null,e)}})),v=i((async n=>{const{id:a}=n;r({saving:!0,error:null});const o=e.auth.restrictionsState.emailDomainRestrictions;try{var i;await t.auth.deleteDomainRestriction(a);const e=(await t.auth.getDomainRestrictions()).items.filter((e=>{var t;return e.type===(null==(t=o.data)?void 0:t.config.listType)}));r({data:{config:(null==(i=o.data)?void 0:i.config)||{active:!1,blockPublicDomains:!1,listType:pn.ALLOW},restrictions:e},saving:!1})}catch(e){r({saving:!1,error:Gc(e)})}}));return{setRestrictionsState:t=>{Object.assign(e.auth.restrictionsState,t)},setIpRestrictionsState:s,setEmailDomainRestrictionsState:r,__securityCenterSagaWrapper:i,loadIpRestrictions:c,saveIpRestriction:u,saveIpRestrictionsConfig:d,deleteIpRestriction:g,checkIfUserIpValid:p,addCurrentUserIpAndActivate:y,loadEmailDomainRestrictions:f,saveEmailDomainRestriction:S,saveEmailDomainRestrictionsConfig:h,deleteEmailDomainRestriction:v}},tp={loaders:{},errors:{},recommendations:void 0,insights:void 0,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}}},np=e=>Mc(tp,e),ap=["callback"],op=(e,t,n)=>{const a=n,o=async e=>{var n,o,l,c;const{key:u,tableState:d,updateStateKey:g,_offset:p,_limit:y,_preset:f,_email:S,_maxInactiveSeconds:h}=e;r({key:u,value:!1}),s({key:u,value:!0});const v=null!=(n=null!=p?p:null==d||null==(o=d.queryParams)?void 0:o._offset)?n:0,m=null!=(l=null!=y?y:null==d||null==(c=d.queryParams)?void 0:c._limit)?l:10,b=j({_offset:v,_limit:m,_includeSubTenants:!1,_preset:f,_maxInactiveSeconds:h},!!S&&{_email:S});try{const{items:e,_metadata:{totalItems:n,totalPages:o}}=await t.users.getUsersV3(b),r={totalUsersItems:n,totalUsersPages:o,usersPageOffset:v,queryParams:j({_offset:v,_limit:m,_maxInactiveSeconds:h},!!S&&{_email:S})};if(e.length){const n=await(async e=>{const n=e.map((e=>e.id)),a=await t.roles.getRoles(),o=await t.users.getUsersRoles({ids:n});return e.map((e=>{var t,n;const i=null==o||null==(t=o.find((t=>t.userId===e.id)))?void 0:t.roleIds;return j({},e,{roles:null!=(n=null==i?void 0:i.map((e=>{var t;return null!=(t=null==a?void 0:a.find((t=>t.id===e)))?t:[]})))?n:[]})}))})(e);a.setSecurityCenterState({[g]:j({users:n},r)})}else i({[g]:j({users:[]},r)})}catch(e){r({key:u,value:Gc(e)})}finally{s({key:u,value:!1})}},i=t=>{Object.assign(e.auth.securityCenterState,t)},s=t=>{Object.assign(e.auth.securityCenterState,{loaders:j({},e.auth.securityCenterState.loaders,{[t.key]:t.value})})},r=t=>{Object.assign(e.auth.securityCenterState,{errors:j({},e.auth.securityCenterState.errors,{[t.key]:t.value}),loaders:j({},e.auth.securityCenterState.loaders,{[t.key]:!1})})};return{setSecurityCenterState:i,resetSecurityCenterState:()=>{e.auth.securityCenterState=Xl(tp)},setSecurityCenterStateLoader:s,setSecurityCenterStateError:r,loadRecommendations:async()=>{const e=Ic.RECOMMENDATIONS;s({key:e,value:!0});try{var n;const{recommendations:a,scoring:o}=await t.securityCenter.getRecommendations();i({recommendations:a.items,score:null!=(n=null==o?void 0:o.score)?n:0})}catch(t){r({key:e,value:Gc(t)})}finally{s({key:e,value:!1})}},loadInsights:async()=>{const e=Ic.INSIGHTS;s({key:e,value:!0});try{const{insights:n}=await t.securityCenter.getInsights();i({insights:n.items})}catch(t){r({key:e,value:Gc(t)})}finally{s({key:e,value:!1})}},sendResetBreachedPasswordEmail:async e=>{const{callback:n}=e,a=oe(e,ap),o=Ic.SEND_BREACHED_PASSWORD_EMAIL;r({key:o,value:!1}),s({key:o,value:!0});try{await t.auth.forgotPassword(a),null==n||n(!0)}catch(e){r({key:o,value:Gc(e)}),null==n||n(!1,e)}finally{s({key:o,value:!1})}},sendBulkResetBreachedPasswordEmails:async e=>{const{callback:n}=e,a=Ic.SEND_BULK_RESET_BREACHED_PASSWORD_EMAILS;r({key:a,value:!1}),s({key:a,value:!0});try{await t.users.sendResetBreachedPasswordEmails(),null==n||n(!0)}catch(e){r({key:a,value:Gc(e)}),null==n||n(!1)}finally{s({key:a,value:!1})}},loadBreachedPasswordUsers:async t=>{var n;const a=Ic.BREACHED_PASSWORD_USERS_TABLE,i=null==(n=e.auth.securityCenterState)?void 0:n.breachedPasswordUsersTable;await o(j({key:a,updateStateKey:"breachedPasswordUsersTable",_preset:xl.BREACHED_PASSWORDS,tableState:i},t))},loadUnenrolledMfaUsers:async t=>{var n;const a=Ic.UNENROLLED_MFA_USERS_TABLE,i=null==(n=e.auth.securityCenterState)?void 0:n.unenrolledMfaUsersTable;await o(j({key:a,updateStateKey:"unenrolledMfaUsersTable",_preset:xl.MFA_UNENROLLED,tableState:i},t))},loadInactiveUsers:async t=>{var n;const a=Ic.INACTIVE_USERS_TABLE,i=null==(n=e.auth.securityCenterState)?void 0:n.inactiveUsersTable;await o(j({key:a,updateStateKey:"inactiveUsersTable",_preset:xl.INACTIVE,tableState:i},t))}}},ip={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}},sp=e=>Mc(ip,e),rp=["callback"],lp=["callback"],cp=["callback"],up=(e,t,n)=>{const a=n,o=async e=>{var t,n;if(!await a.customLoginEnabled())return e;const o=await i();return null!=o&&null!=(t=o.mainAuthStrategies)&&null!=(n=t[0])&&n.strategy?j({},e,{authStrategy:o.mainAuthStrategies[0].strategy}):e},i=async()=>{let n;return n=e.auth.isAuthenticated?await t.auth.getPublicAuthStrategiesConfigForAuthenticatedUser():await t.auth.getVendorPublicAuthStrategiesConfig(),n},s=t=>{Object.assign(e.auth.securityPolicyState.globalPolicy,t)},r=t=>{Object.assign(e.auth.securityPolicyState.publicPolicy,t)},l=t=>{Object.assign(e.auth.securityPolicyState.mfaPolicy,t)},c=t=>{Object.assign(e.auth.securityPolicyState.vendorMfaPolicy,t)},u=t=>{Object.assign(e.auth.securityPolicyState.lockoutPolicy,t)},d=t=>{Object.assign(e.auth.securityPolicyState.vendorLockoutPolicy,t)},g=t=>{Object.assign(e.auth.securityPolicyState.captchaPolicy,t)},p=t=>{Object.assign(e.auth.securityPolicyState.passwordHistoryPolicy,t)},y=t=>{Object.assign(e.auth.securityPolicyState.vendorPasswordHistoryPolicy,t)},f=t=>{Object.assign(e.auth.securityPolicyState.passwordPolicy,t)},S=t=>{Object.assign(e.auth.securityPolicyState.publicAuthStrategyPolicy,t)},h=async()=>{s({loading:!0,error:null});try{const e=await t.auth.getGlobalSecurityPolicy();s({policy:e,loading:!1})}catch(e){s({error:Gc(e),loading:!1})}},v=async()=>{l({loading:!0,error:null});try{const e=await t.auth.getMfaPolicy();l({policy:e,loading:!1})}catch(e){l({error:Gc(e),loading:!1})}},m=async()=>{l({loading:!0,error:null});try{const e=await t.auth.getVendorMfaPolicy();c({policy:e,loading:!1})}catch(e){c({error:Gc(e),loading:!1})}},b=async()=>{u({loading:!0,error:null});try{const e=await t.auth.getLockoutPolicy();u({policy:e,loading:!1})}catch(e){u({error:Gc(e),loading:!1})}},A=async()=>{d({loading:!0,error:null});try{const e=await t.auth.getVendorLockoutPolicy();d({policy:e,loading:!1})}catch(e){d({error:Gc(e),loading:!1})}},w=async()=>{u({loading:!0,error:null});try{const e=await t.auth.getCaptchaPolicy();g({policy:e,loading:!1})}catch(e){g({error:Gc(e),loading:!1})}},T=async()=>{y({loading:!0,error:null});try{const e=await t.auth.getVendorPasswordHistoryPolicy();y({policy:e,loading:!1})}catch(e){y({error:Gc(e),loading:!1})}},E=async()=>{S({loading:!0,error:null});try{var t,n;const o=await i();await(async t=>{var n,o;const i=await a.customLoginEnabled();if(!t||!i)return;const{policy:s}=null!=(n=null==(o=e.auth.securityPolicyState)?void 0:o.publicPolicy)?n:{policy:null};r({policy:j({},s,{authStrategy:t}),loading:!1})})(null==o||null==(t=o.mainAuthStrategies)||null==(n=t[0])?void 0:n.strategy),S({policy:o,loading:!1})}catch(e){S({error:Gc(e),loading:!1})}};return{setSecurityPolicyState:t=>{Object.assign(e.auth.securityPolicyState,t)},setSecurityPolicyGlobalState:s,setSecurityPolicyPublicState:r,setSecurityPolicyMfaState:l,setSecurityPolicyVendorMfaState:c,setSecurityPolicyLockoutState:u,setSecurityPolicyVendorLockoutState:d,setSecurityPolicyCaptchaState:g,setSecurityPolicyPasswordHistoryState:p,setSecurityPolicyVendorPasswordHistoryState:y,resetSecurityPolicyState:()=>{e.auth.securityPolicyState=Xl(ip)},setSecurityPolicyPasswordState:f,setSecurityPolicyAuthStrategyPublicState:S,loadSecurityPolicy:async()=>{await Promise.all([h(),v(),m(),b(),A(),T(),w(),E()])},loadGlobalSecurityPolicy:h,loadPublicSecurityPolicy:async()=>{r({loading:!0,error:null});try{const e=await t.auth.getVendorConfig(),n=await o(e);r({policy:n,loading:!1})}catch(e){r({error:Gc(e),loading:!1})}},loadVendorPasswordConfig:async()=>{f({loading:!0,error:null});try{const e=await t.auth.getPasswordConfigPolicy();f({policy:e,loading:!1})}catch(e){f({error:Gc(e),loading:!1})}},loadSecurityPolicyMfa:v,loadSecurityPolicyVendorMfa:m,loadSecurityPolicyLockout:b,loadSecurityPolicyVendorLockout:A,loadSecurityPolicyCaptcha:w,loadSecurityPolicyPasswordHistory:async()=>{p({loading:!0,error:null});try{const e=await t.auth.getPasswordHistoryPolicy();p({policy:e,loading:!1})}catch(e){p({error:Gc(e),loading:!1})}},loadSecurityPolicyVendorPasswordHistory:T,loadPublicAuthStrategiesPolicy:E,saveSecurityPolicyMfa:async e=>{const{callback:n}=e,a=oe(e,rp);l({saving:!0,error:null});try{const e=await t.auth.saveMfaPolicy(a);l({policy:e,saving:!1}),null==n||n(e)}catch(e){l({saving:!1,error:Gc(e)}),null==n||n(null,e)}},saveSecurityPolicyLockout:async e=>{const{callback:n}=e,a=oe(e,lp);u({saving:!0,error:null});try{const e=await t.auth.saveLockoutPolicy(a);u({policy:e,saving:!1}),null==n||n(e)}catch(e){u({saving:!1,error:Gc(e)}),null==n||n(null,e)}},saveSecurityPolicyPasswordHistory:async e=>{const{callback:n}=e,a=oe(e,cp);p({saving:!0,error:null});try{const e=await t.auth.savePasswordHistoryPolicy(a);p({policy:e,saving:!1}),null==n||n(e)}catch(e){p({saving:!1,error:Gc(e)}),null==n||n(null,e)}},__getSecurityPolicyPublicStateWithCustomLogin:o}},dp={loading:!1,configurations:{}},gp=e=>Mc(dp,e),pp=["callback"],yp=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auth.sessionsPolicyState,t)};return{setSessionsPolicyState:o,resetSessionsPolicyState:()=>{e.auth.sessionsPolicyState=Xl(dp)},loadSessionsPolicy:async()=>{o({loading:!0,error:null});try{const e=await t.auth.getSessionConfigurations();o({configurations:e,loading:!1})}catch(e){a.setSessionsState({error:e,loading:!1})}},createOrUpdateSessionsPolicy:async e=>{const{callback:n}=e,i=oe(e,pp);try{o({loading:!0,error:null}),await t.auth.createOrUpdateSessionConfigrations(i),await a.loadSessionsPolicy(),null==n||n(!0)}catch(e){o({error:e,loading:!1})}}}},fp={loading:!1,sessions:[]},Sp=e=>Mc(fp,e),hp=(e,t,n)=>{const a=t=>{Object.assign(e.auth.sessionsState,t)},o=async()=>{a({loading:!0,error:null});try{const e=await t.auth.getCurrentUserSessions();a({sessions:e,loading:!1})}catch(e){a({error:Gc(e),loading:!1})}};return{setSessionsState:a,resetSessionsState:()=>{e.auth.sessionsState=Xl(fp)},loadUserSessions:o,loadCurrentUserSession:async()=>{a({loading:!0,error:null});try{const e=await t.auth.getCurrentUserSession();a({currentSession:e,loading:!1})}catch(e){a({error:Gc(e),loading:!1})}},deleteUserSession:async e=>{const{id:n}=e;a({loading:!0,error:null});try{await t.auth.deleteSessionForUser(n),await o()}catch(e){a({error:Gc(e),loading:!1})}},deleteAllUserSessions:async()=>{a({loading:!0,error:null});try{await t.auth.deleteAllSessionsForUser(),await o()}catch(e){a({error:Gc(e),loading:!1})}},revokeUserSessions:async e=>{const{callback:n,userId:o}=e;a({loading:!0,error:null});try{await t.auth.revokeSessionsForUser(o),a({loading:!1}),null==n||n(!0)}catch(e){a({error:Gc(e),loading:!1}),null==n||n(!1)}}}},vp={loading:!1,allowSignUps:!1,allowNotVerifiedUsersLogin:!1,firstLoad:!0,stage:kc.SignUp},mp=e=>Mc(vp,e),bp=["events","url"],Ap=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auth.signUpState,t)},i=()=>{e.auth.signUpState=Xl(vp)};return{setSignUpState:o,resetSignUpState:i,resetSignUpStateSoft:()=>{const{allowSignUps:t,allowNotVerifiedUsersLogin:n}=e.auth.signUpState;i(),o({allowSignUps:t,allowNotVerifiedUsersLogin:n})},signUpUser:async n=>{const{events:i,url:s}=n,r=oe(n,bp);o({loading:!0});try{const{routes:n,onRedirectTo:c}=e.auth,{shouldActivate:u,user:d,tenantId:g,userId:p,tenants:y=[],activeTenant:f}=await t.auth.signUpUser(Tu(r));if(!r.invitationToken){var l;const{email:e,name:t,companyName:n,phoneNumber:a}=r,o={email:e,name:t,companyName:n,url:s,phoneNumber:a||void 0,authenticationType:Lc.PASSWORD,id:p,tenantId:g,createdAt:new Date};null==i||null==(l=i.signUpComplete)||l.call(i,o),qc(Hc.SIGNUP_COMPLETED,o)}if(!u&&d&&bu(d)){const e=await a.getMfaRequiredState(d);a.setAuthState(e),c(n.loginUrl)}else{const t=e.auth.tenantsState;o({loading:!1,shouldActivate:u,stage:kc.SignUpSuccess}),a.setAuthState({user:d,isAuthenticated:!(null==d||!d.accessToken),tenantsState:j({},t,{tenants:y,activeTenant:f})})}}catch(e){ne.setAccessToken(null),ne.setUser(null),o({error:Gc(e)})}finally{o({loading:!1})}},loadAllowSignUps:async()=>{o({loading:!0});try{const e=await t.auth.getVendorConfig(),n=await a.__getSecurityPolicyPublicStateWithCustomLogin(e),{allowSignups:i,allowNotVerifiedUsersLogin:s}=e;o({loading:!1,allowSignUps:i,allowNotVerifiedUsersLogin:s,firstLoad:!1}),a.setSecurityPolicyPublicState({policy:n,loading:!1})}catch(e){o({loading:!1,error:Gc(e),firstLoad:!1})}}}},wp={loading:!1,error:null,phoneNumbers:void 0},Tp=e=>Mc(wp,e),Ep=["callback"],Ip=["callback"],kp=["callback","phoneId"],Op=["callback","phoneId"],_p=["callback"],Pp=(e,t,n)=>{const a=t=>{Object.assign(e.auth.smsState,t)},o=async()=>{a({loading:!0});const e={_limit:10,_offset:0};try{const{items:n}=await t.userPhoneNumbers.getUserPhoneNumbers(e);a({phoneNumbers:n})}catch(e){a({error:Gc(e)})}finally{a({loading:!1})}};return{setSmsState:a,resetSmsState:()=>{e.auth.smsState=Xl(wp)},loadPhoneNumbers:o,setUpPhoneNumber:async e=>{const{callback:n}=e,i=oe(e,Ep);a({loading:!0});try{const{otcToken:e}=await t.userPhoneNumbers.createPhoneNumber(i);a({otcToken:e}),await o(),null==n||n(!0)}catch(e){a({error:Gc(e)}),null==n||n(!1,e)}finally{a({loading:!1})}},verifyPhoneNumber:async e=>{const{callback:n}=e,i=oe(e,Ip);a({loading:!0});try{await t.userPhoneNumbers.verifyPhoneNumber(i),await o(),null==n||n(!0)}catch(e){a({error:Gc(e)}),null==n||n(!1,e)}finally{a({loading:!1})}},deletePhoneNumber:async e=>{const{callback:n,phoneId:o}=e;oe(e,kp),a({loading:!0});try{const{otcToken:e}=await t.userPhoneNumbers.deletePhoneNumber(o);a({otcToken:e}),null==n||n(!0)}catch(e){a({error:Gc(e)}),null==n||n(!1,e)}finally{a({loading:!1})}},verifyDeletePhoneNumber:async e=>{const{callback:n,phoneId:i}=e,s=oe(e,Op);a({loading:!0});try{await t.userPhoneNumbers.verifyDeletePhoneNumber(i,s),await o(),null==n||n(!0)}catch(e){a({error:Gc(e)}),null==n||n(!1,e)}finally{a({loading:!1})}},preVerifyPhoneNumber:async e=>{const{callback:n}=e,o=oe(e,_p);a({loading:!0});try{const{otcToken:e}=await t.userPhoneNumbers.preVerifyPhoneNumber(o);a({otcToken:e}),null==n||n(!0)}catch(e){a({error:Gc(e)}),null==n||n(!1,e)}finally{a({loading:!1})}}}},Up={firstLoad:!0,loading:!1,error:""},Lp=e=>Mc(Up,e),Dp=["authorizationUrl"],Rp=["events","url"],Cp=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auth.socialLoginState,t)};return{setSocialLoginsState:o,resetSocialLoginsState:()=>{e.auth.socialLoginState=Xl(Up)},setSocialLoginError:e=>{o({error:e.error,loading:!1,firstLoad:!1})},loadSocialLoginsConfiguration:async()=>{try{o({loading:!0});const e=await t.auth.getSocialLoginProviders();o({socialLoginsConfig:e,loading:!1,firstLoad:!1})}catch(e){o({error:Gc(e),loading:!1,firstLoad:!1})}},loadSocialLoginsConfigurationV2:async n=>{try{var a;const i=e.root.context;o({loading:!0});const s=await(async()=>{let n;return n=e.auth.isAuthenticated?await t.auth.getSocialLoginProvidersV2ForAuthenticatedUser():await t.auth.getSocialLoginProvidersV2(),n})(),{providers:r}=await t.auth.getCustomSocialLoginProvidersV1(),l={socialLoginsConfigV2:s.map((e=>{let{authorizationUrl:n}=e,a=oe(e,Dp);const o=t.fetch.getBaseUrl(i,null!=n?n:"");return j({},a,{authorizationUrl:n?`${o}${n}`:null})})),customSocialLoginsConfig:r,loading:!1,firstLoad:!1};o(l),null==n||null==(a=n.callback)||a.call(n,l)}catch(e){var i;null==n||null==(i=n.callback)||i.call(n,null,e),o({error:Gc(e),loading:!1,firstLoad:!1})}},loginViaSocialLogin:async e=>{const{events:n,url:i}=e,s=oe(e,Rp);try{o({loading:!0});const{email:e,isNewUser:c,userId:u,tenantId:d,name:g}=await t.auth.loginViaSocialLogin(s);if(c){var r,l;const t={email:e,url:i,createdAt:new Date,id:u,tenantId:d},a=j({},t,{socialProvider:s.provider,authenticationType:Lc.SOCIAL_LOGIN});null==n||null==(r=n.signUpComplete)||r.call(n,a),qc(Hc.SIGNUP_COMPLETED,a);const o=j({},t,{origin:Uc.SOCIAL_LOGIN,name:g});null==n||null==(l=n.userVerified)||l.call(n,o),qc(Hc.USER_VERIFIED,o)}u&&localStorage.setItem("userId",u),a.setLoginState({email:e,isNewUser:c}),a.refreshTokenForSocialLogins(),localStorage.removeItem("register-quick-login"),o({loading:!1})}catch(e){o({loading:!1,error:Gc(e,"Failed to authenticate"),firstLoad:!1})}}}},Np={firstLoad:!0,loading:!0,saving:!1,errors:{},loaders:{},ssoConfigurations:[]},Mp=e=>Mc(Np,e),Fp=["callback","samlVendor"],$p=["callback"],jp=["callback","ssoConfigId"],Gp=["callback","ssoConfigId"],xp=["callback","ssoConfigId"],Vp=(e,t,n)=>j({},((e,t,n)=>{const a=n,o=async()=>{try{const e=await t.auth.getSamlRoles(),n=await t.auth.getSamlRolesGroups();i({authorizationRoles:e.roleIds,rolesGroups:n,error:void 0})}catch(e){i({error:Gc(e)})}},i=t=>{Object.assign(e.auth.ssoState,t)};return{setSSOState:i,resetSSOState:()=>{e.auth.ssoState=Xl(Np)},setSSOLoader:t=>{Object.assign(e.auth.ssoState,{loaders:j({},e.auth.ssoState.loaders,{[t.key]:t.value})})},setSSOError:t=>{Object.assign(e.auth.ssoState,{errors:j({},e.auth.ssoState.errors,{[t.key]:t.value}),loaders:j({},e.auth.ssoState.loaders,{[t.key]:!1})})},loadSSOConfigurations:async()=>{try{var e,n;i({loading:!0});const a=await t.auth.getSamlConfiguration(),o=await t.auth.getOidcConfiguration(),s=await t.metadata.getSamlMetadata();a.acsUrl=null==s||null==(e=s.configuration)?void 0:e.acsUrl,a.spEntityId=null==s||null==(n=s.configuration)?void 0:n.spEntityId,a.isSamlActive=null==s?void 0:s.isActive,i({samlConfiguration:a,oidcConfiguration:o,loading:!1,firstLoad:!1})}catch(e){i({error:Gc(e),loading:!1})}},saveSSOConfigurations:async n=>{const{callback:a,samlVendor:o}=n,s=oe(n,Fp),r=e.auth.ssoState.samlConfiguration,l=j({},r,s);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:j({},r,l)});if(i({error:void 0,[c]:!0}),n.type===_c.Saml){var u,d;const e=await t.metadata.getSamlMetadata();l.acsUrl=null==e||null==(u=e.configuration)?void 0:u.acsUrl,l.spEntityId=null==e||null==(d=e.configuration)?void 0:d.spEntityId}const e=ec(l,["validated","generatedVerification","createdAt","updatedAt"]);(null==r?void 0:r.domain)!==(null==e?void 0:e.domain)&&(e.ssoEndpoint="",e.publicCertificate="",e.signRequest=!1),e.type=null==o?void 0:o.toLowerCase();const s=await t.auth.updateSamlConfiguration(e);s.isSamlActive=null==r?void 0:r.isSamlActive,i({samlConfiguration:s,error:void 0,[c]:!1}),null==a||a(!0)}catch(e){i({samlConfiguration:r,error:Gc(e),[c]:!1}),null==a||a(null,e)}},saveSSOConfigurationsFile:async n=>{const a=e.auth.ssoState.samlConfiguration,o="saving";i({error:void 0,[o]:!0});try{const e=await vd(n[0]),s=await t.auth.updateSamlVendorMetadata({metadata:e});s.isSamlActive=null==a?void 0:a.isSamlActive,i({samlConfiguration:s,error:void 0,[o]:!1})}catch(e){i({samlConfiguration:a,error:Gc(e),[o]:!1})}},saveSSOConfigurationsFileWithCallback:async n=>{const{configFile:a,callback:o}=n,s=e.auth.ssoState.samlConfiguration,r="saving";i({error:void 0,[r]:!0});try{const e=await vd(a),n=await t.auth.updateSamlVendorMetadata({metadata:e});n.isSamlActive=null==s?void 0:s.isSamlActive,i({samlConfiguration:n,error:void 0,[r]:!1}),null==o||o(!0)}catch(e){i({samlConfiguration:s,error:Gc(e),[r]:!1}),null==o||o(null,e)}},validateSSODomain:async n=>{const{callback:a}=null!=n?n:{},o=e.auth.ssoState.samlConfiguration;if(!o){const e=new Error("IllegalState: samlConfiguration is not defined");return console.error(e),void(null==a||a(null,e))}try{i({error:void 0,saving:!0}),await t.auth.validateSamlDomain(),i({samlConfiguration:j({},o,{validated:!0}),error:void 0,saving:!1}),null==a||a(!0)}catch(e){i({samlConfiguration:j({},o,{validated:!1}),error:Gc(e),saving:!1}),null==a||a(null,e)}},loadSSOAuthorizationRoles:async()=>{try{const e=await t.auth.getSamlRoles(),n=await t.auth.getSamlRolesGroups();i({authorizationRoles:e.roleIds,rolesGroups:n,error:void 0})}catch(e){i({error:Gc(e)})}},updateSSOAuthorizationRoles:async e=>{const{callback:n,authorizationRoles:a,groups:s}=e;try{i({error:void 0,saving:!0}),await t.auth.updateSamlRoles({roleIds:a}),s&&await(async e=>{try{await Promise.all(e.map((e=>t.auth.updateSamlGroup({id:e.id,roleIds:e.roleIds,group:e.group}))))}catch(e){i({error:Gc(e)})}})(s),await o(),i({error:void 0,saving:!1}),null==n||n(!0)}catch(e){i({error:Gc(e),saving:!1}),null==n||n(null,e)}},deleteSamlGroup:async e=>{const{id:n,callback:a}=e;try{i({error:void 0,saving:!0}),await t.auth.deleteSamlGroup({id:n}),await o(),i({error:void 0,saving:!1}),null==a||a(!0)}catch(e){i({error:Gc(e),saving:!1}),null==a||a(null,e)}},createSamlGroup:async e=>{const{group:n,roleIds:a,callback:s}=e;try{i({error:void 0,saving:!0}),await t.auth.createSamlGroup({group:n,roleIds:a}),await o(),i({error:void 0,saving:!1}),null==s||s(!0)}catch(e){i({error:Gc(e),saving:!1}),null==s||s(null,e)}},oidcPostlogin:async e=>{const n={code:e.code,redirectUri:e.redirectUri,RelayState:e.state};try{i({loading:!0}),await t.auth.oidcPostLoginV2(n),await a.__refreshToken(),i({loading:!1})}catch(e){i({loading:!1,error:Gc(e,"Failed to authenticate"),firstLoad:!1})}}}})(e,t,n),((e,t,n)=>{const a=n,o=async()=>{try{return await t.auth.getOidcConfiguration()}catch(e){return null}},i=async()=>{try{return await t.metadata.getSamlMetadata()}catch(e){return null}},s=async(e,t,n)=>{a.setSSOLoader({key:e,value:!0});try{await n()}catch(n){a.setSSOError({key:e,value:Gc(n)}),null==t||t(null,n)}finally{a.setSSOLoader({key:e,value:!1})}};return{loadSSOConfigurationsV2:async()=>{await s(Oc.LOAD_SSO_CONFIGURATIONS,void 0,(async()=>{const[e,n]=await Promise.all([o(),i()]),s=await t.auth.getSSOConfigurations();a.setSSOState({ssoConfigurations:s,oidcConfiguration:e,samlMetadata:n})}))},saveSSOConfigurationV2:async n=>{const{callback:o}=n,i=oe(n,$p),r=e.auth.ssoState.ssoConfigurations;await s(Oc.SAVE_SSO_CONFIGURATION,o,(async()=>{var e;const n=await t.auth.createSSOConfiguration(j({},i,{enabled:null!=(e=i.enabled)&&e}));a.setSSOState({ssoConfigurations:[...r,n]}),null==o||o(n)}))},updateSSOConfiguration:async n=>{const{callback:o,ssoConfigId:i}=n,r=oe(n,jp),l=e.auth.ssoState.ssoConfigurations;await s(Oc.UPDATE_SSO_CONFIGURATION,o,(async()=>{const e=await t.auth.updateSSOConfiguration(i,r),n=l.map((t=>t.id===i?e:t));a.setSSOState({ssoConfigurations:n}),null==o||o(e)}))},deleteSSOConfiguration:async n=>{const{ssoConfigId:o,callback:i}=n,r=e.auth.ssoState.ssoConfigurations;await s(Oc.DELETE_SSO_CONFIGURATION,i,(async()=>{await t.auth.deleteSSOConfiguration(o),a.setSSOState({ssoConfigurations:r.filter((({id:e})=>e!==o))}),null==i||i(!0)}))},saveSSODomain:async n=>{const{callback:o,ssoConfigId:i}=n,r=oe(n,Gp),l=e.auth.ssoState.ssoConfigurations;await s(Oc.SAVE_SSO_DOMAIN,o,(async()=>{const e=await t.auth.createSSODomain(i,r),n=l.map((t=>t.id===i?j({},t,{domains:[...t.domains,e]}):t));a.setSSOState({ssoConfigurations:n}),null==o||o(e)}))},deleteSSODomain:async n=>{const{ssoConfigId:o,domainId:i,callback:r}=n,l=e.auth.ssoState.ssoConfigurations;await s(Oc.DELETE_SSO_DOMAIN,r,(async()=>{await t.auth.deleteSSODomain(o,i);const e=l.map((e=>e.id===o?j({},e,{domains:e.domains.filter((({id:e})=>e!==i))}):e));a.setSSOState({ssoConfigurations:e}),null==r||r(!0)}))},validateSSODomainV2:async n=>{const{callback:o,domainId:i,ssoConfigId:r}=n;await s(Oc.VALIDATE_SSO_DOMAIN,o,(async()=>{const n=e.auth.ssoState.ssoConfigurations;await t.auth.validateSSODomainV2(r,i);const s=n.map((e=>e.id===r?j({},e,{domains:e.domains.map((e=>e.id===i?j({},e,{validated:!0}):e))}):e));a.setSSOState({ssoConfigurations:s}),null==o||o(!0)}))},setSSOGroups:async n=>{const{groupsToAdd:o,groupsToDelete:i,ssoConfigId:r,callback:l}=n;await s(Oc.SAVE_SSO_GROUPS,l,(async()=>{const n=e.auth.ssoState.ssoConfigurations;await Promise.all(i.map((e=>t.auth.deleteSSOGroup(r,e)))),await Promise.all(o.map((e=>t.auth.createSSOGroup(r,e))));const s=await t.auth.getSSOGroups(r),c=n.map((e=>e.id===r?j({},e,{groups:s}):e));a.setSSOState({ssoConfigurations:c}),null==l||l(!0)}))},updateSSOGroups:async e=>{const{ssoConfigId:n,changedGroups:a,callback:o}=e;await s(Oc.SAVE_SSO_GROUPS,o,(async()=>{await Promise.all(a.map((e=>t.auth.updateSSOGroup(n,e)))),null==o||o(!0)}))},setSSODefaultRoles:async n=>{const{callback:o,ssoConfigId:i,roleIds:r}=n;await s(Oc.UPDATE_SSO_DEFAULT_ROLES,o,(async()=>{const n=e.auth.ssoState.ssoConfigurations;await t.auth.setSSODefaultRoles(i,{roleIds:r});const s=n.map((e=>e.id===i?j({},e,{roleIds:r}):e));a.setSSOState({ssoConfigurations:s}),null==o||o(!0)}))},saveSSOConfigurationByMetadata:async n=>{const{configFile:o,callback:i}=n;await s(Oc.SAVE_SSO_CONFIGURATION_BY_METADATA,i,(async()=>{const n=e.auth.ssoState.ssoConfigurations,s=await vd(o),r=await t.auth.createSSOConfigurationByMetadata({metadata:s});a.setSSOState({ssoConfigurations:[...n,r]}),null==i||i(r)}))},updateSSOConfigurationByMetadata:async n=>{const{callback:o,ssoConfigId:i,configFile:r}=n;await s(Oc.UPDATE_SSO_CONFIGURATION_BY_METADATA,o,(async()=>{const n=e.auth.ssoState.ssoConfigurations,s=await vd(r),l=await t.auth.updateSSOConfigurationByMetadata(i,{metadata:s}),c=n.map((e=>e.id===i?l:e));a.setSSOState({ssoConfigurations:c}),null==o||o(l)}))},saveSSOConfigurationByUrl:async n=>{const{metadataUrl:o,configMetadata:i,ssoConfigId:r,callback:l}=n;await s(Oc.SAVE_SSO_CONFIGURATION_BY_METADATA,l,(async()=>{const n=e.auth.ssoState.ssoConfigurations,s={url:o,configMetadata:i};let c,u;r?(c=await t.auth.updateSSOConfigurationByMetadataUrl(r,s),u=n.map((e=>e.id===r?c:e))):(c=await t.auth.createSSOConfigurationByMetadataUrl(s),u=[c,...n]),a.setSSOState({ssoConfigurations:u}),null==l||l(c)}))},saveSSOConfigurationByData:async n=>{const{callback:o,ssoConfigId:i}=n,r=oe(n,xp),l=e.auth.ssoState.ssoConfigurations;await s(Oc.SAVE_SSO_CONFIGURATION,o,(async()=>{let e,n;i?(e=await t.auth.updateSSOConfiguration(i,r),n=l.map((t=>t.id===i?e:t))):(e=await t.auth.createSSOConfiguration(r),n=[e,...l]),a.setSSOState({ssoConfigurations:n}),null==o||o(e)}))}}})(e,t,n)),Bp={loading:!1,mfaDevices:void 0,mfaToken:""},Wp=e=>Mc(Bp,e),zp=(e,t,n)=>{const a=n;return j({setStepUpState:t=>{Object.assign(e.auth.stepUpState,t)},resetStepUpState:()=>{e.auth.stepUpState=Xl(Bp)},stepUpWithAuthenticator:async e=>{await a.mfaWithAuthenticator(e,a.setStepUpState,!0)},preVerifyMFASMSForStepUp:async e=>{await a.preVerifyMFASMS(e,a.setStepUpState)},verifyMFASMSForStepUp:async e=>{await a.verifyMFASMS(e,a.setStepUpState,!0)},preVerifyMFAWebAuthnForStepUp:async e=>{await a.preVerifyMFAWebAuthn(e,a.setStepUpState)},verifyMFAWebAuthnForStepUp:async e=>{await a.verifyMFAWebAuthn(e,a.setStepUpState,!0)},preVerifyMFAEmailCodeForStepUp:async e=>{await a.preVerifyMFAEmailCode(e,a.setStepUpState)},verifyMFAEmailCodeForStepUp:async e=>{await a.verifyMFAEmailCode(e,a.setStepUpState)}},((e,t,n)=>{const a=n;return{generateStepUpSession:async n=>{const{maxAge:o,callback:i}=n;a.setStepUpState({mfaDevices:void 0,mfaToken:""});try{const e=await t.auth.generateStepupSession({maxAge:o});e.hasOwnProperty("user")?await(async e=>{await a.__afterAuthenticationStateUpdate(e),await a.afterStepUpAuthNavigation()})(e):await(async({mfaToken:e,mfaDevices:t})=>{a.setStepUpState({mfaDevices:t,mfaToken:e});const n=await ou(t);a.setMfaState({step:n})})(e),null==i||i(!0)}catch(t){null==i||i(!1),await(async t=>{if((e=>"MFA is not enrolled"===(null==e?void 0:e.message))(t))return void a.setMfaState({step:Ac.noMFAEnrolledStepUp});window.localStorage.setItem(du,"true");const n=e.auth.routes;ne.onRedirectTo(n.logoutUrl,{preserveQueryParams:!0})})(t)}}}})(e,t,n),((e,t,n)=>{const a=n;return{stepUpHostedLogin:async t=>{var n,o;const i={acr_values:lu},{maxAge:s}=t||{};void 0!==s&&(i.max_age=s.toString());const r=null==(n=e.auth.tenantsState)||null==(o=n.activeTenant)?void 0:o.alias;r&&(i.organization=r),Su(),window.localStorage.setItem(du,"true"),await a.__requestHostedLoginAuthorize(i)}}})(e,0,n))},Kp={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}},Hp=e=>Mc(Kp,e),qp=["callback","appIds"],Jp=["roles"],Yp=["callback","profileImage"],Xp=["callback"],Qp=["callback"],Zp=["callback"],ey=["callback","userId"],ty=["callback"],ny=["callback"],ay=["callback"],oy=["callback"],iy=["callback"],sy=["callback"],ry=(e,t,n)=>{const a=t=>{Object.assign(e.auth.teamState,t)};return j({setTeamLoader:t=>{Object.assign(e.auth.teamState,{loaders:j({},e.auth.teamState.loaders,{[t.key]:t.value})})},setTeamError:t=>{Object.assign(e.auth.teamState,{errors:j({},e.auth.teamState.errors,{[t.key]:t.value}),loaders:j({},e.auth.teamState.loaders,{[t.key]:!1})})},setTeamState:a,resetTeamState:()=>{e.auth.teamState=Xl(Kp)},openAddUserDialog:e=>{a({addUserDialogState:j({open:!0,loading:!1,error:!1},e)})},closeAddUserDialog:t=>{var n,o;null==(n=(o=e.auth.teamState.addUserDialogState).onClose)||n.call(o,t),a({addUserDialogState:{loading:!1,error:!1,open:!1}})},openDeleteUserDialog:e=>{a({deleteUserDialogState:j({open:!0,loading:!1,error:!1},e)})},closeDeleteUserDialog:t=>{var n,o;null==(n=(o=e.auth.teamState.deleteUserDialogState).onClose)||n.call(o,t),a({deleteUserDialogState:{loading:!1,error:!1,open:!1}})},lockUser:async e=>{}},((e,t,n)=>{const a=n,o=async()=>{try{const{groups:e}=await t.groups.getGroups({_groupsRelations:$l.roles});return e}catch(e){return[]}},i=async e=>{a.setTeamLoader({key:Pc.ROLES_AND_PERMISSIONS,value:!0});try{var n;const[{items:o},{items:i}]=await Promise.all([t.teams.loadAvailableRoles(),t.teams.loadAvailablePermissions()]);a.setTeamState({roles:o,permissions:i}),null==e||null==(n=e.callback)||n.call(e,{roles:o,permissions:i})}catch(t){var o;null==e||null==(o=e.callback)||o.call(e,null,t),a.setTeamError({key:Pc.ROLES_AND_PERMISSIONS,value:Gc(t)})}finally{a.setTeamLoader({key:Pc.ROLES_AND_PERMISSIONS,value:!1})}};return{loadRoles:i,loadUsers:async n=>{var o,s,r,l;const{silentLoading:c,callback:u}=n,d=e.auth.teamState,g=null!=(o=n.pageSize)?o:d.pageSize,p=null!=(s=n.pageOffset)?s:d.pageOffset,y=null!=(r=n.filter)?r:d.filter,f=null!=(l=n.sort)?l:d.sort;a.setTeamLoader({key:Pc.USERS,value:!c}),a.setTeamState({pageSize:g,pageOffset:p,filter:y,sort:f});try{const[{items:e,totalPages:n,totalItems:o}]=await Promise.all([t.teams.loadUsers({pageSize:g,pageOffset:p,filter:y,sort:f}),i()]);a.setTeamState({users:e,totalPages:n,totalItems:o}),null==u||u(e)}catch(e){a.setTeamError({key:Pc.USERS,value:Gc(e)}),a.setTeamState({totalPages:0,users:[]}),null==u||u(null,e)}a.setTeamLoader({key:Pc.USERS,value:!1})},loadUsersV2:async s=>{var r,l,c,u,d;const{silentLoading:g,callback:p,shouldLoadRoles:y=!0,shouldLoadApps:f}=s,S=e.auth.teamState,h=null!=(r=s.pageSize)?r:S.pageSize,v=null!=(l=s.pageOffset)?l:S.pageOffset,m=null!=(c=s.filter)?c:S.filterV2,b=null!=(u=s.sort)?u:S.sortV2,A=null!=(d=null==s?void 0:s.shouldShowSubTenantUsersIfReseller)?d:null==S?void 0:S.shouldShowSubTenantUsersIfReseller;a.setTeamLoader({key:Pc.USERS,value:!g}),a.setTeamState({pageSize:h,pageOffset:v,filterV2:m,sortV2:b});try{const[{items:e,_metadata:{totalPages:a,totalItems:r}},{items:l},{items:c},u]=await Promise.all([t.users.getUsersV2(j({},(null==m?void 0:m.length)&&{_filter:m},b&&{_sortBy:b},s.order&&{_order:s.order},{_offset:v,_limit:h,_includeSubTenants:A})),t.teams.loadAvailableRoles(),t.teams.loadAvailablePermissions(),o(),y?i():void 0]),d=e.map((e=>{var t;return j({},e,{groups:null==e||null==(t=e.groups)?void 0:t.map((e=>u.filter((t=>t.id===e.id)))).flat()})})).map((e=>j({},e,{roleIds:e.roles.map((e=>e.id))}))),g=await n.mapUsersWithApplicationData({shouldLoadApps:f,users:d});n.setTeamState({users:g,totalPages:a,totalItems:r,roles:l,permissions:c}),null==p||p(e)}catch(e){a.setTeamError({key:Pc.USERS,value:Gc(e)}),a.setTeamState({totalPages:0,users:[]}),null==p||p(null,e)}a.setTeamLoader({key:Pc.USERS,value:!1})},addUser:async o=>{const{callback:i,appIds:s}=o,r=oe(o,qp),l=e.auth.teamState;a.setTeamState({addUserDialogState:j({},l.addUserDialogState,{loading:!0})});try{var c;const e=await t.teams.addUser(r),{roles:o}=e,u=j({},oe(e,Jp),{roleIds:null!=(c=null==o?void 0:o.map((e=>e.id)))?c:[]}),d=await n.assignNewUserToApps({appIds:s,user:u});d&&(u.applications=d),null==i||i(u),a.setTeamState({users:[u,...l.users],addUserDialogState:{open:!1,loading:!1}})}catch(e){a.setTeamState({addUserDialogState:j({},l.addUserDialogState,{loading:!1,error:Gc(e)})}),null==i||i(null,e)}},addUsersBulk:async n=>{const{callback:o}=n,i=e.auth.teamState;a.setTeamState({addUserDialogState:j({},i.addUserDialogState,{loading:!0})});const s=[],r=[],l=n.emails.map((e=>j({email:e,roleIds:n.roleIds},n.expirationInSeconds&&{expirationInSeconds:n.expirationInSeconds})));a.setTeamState({addUserDialogState:{open:!0,loading:!0}});for(let e=0;e<l.length;e++){const n=l.at(e);try{await t.teams.addUser(n),s.push(n.email)}catch(e){r.push(n.email)}}const c={pageOffset:0,pageSize:10,filter:"",silentLoading:n.emails.length>0};await a.loadUsersV2(c),a.setTeamState({addUserDialogState:{loading:!1}}),null==o||o({unallowedEmails:r,allowedEmails:s})},updateUser:async n=>{const{callback:o}=n,i=oe(n,Yp),{id:s}=i,r=e.auth.teamState,l=r.users.find((e=>e.id===i.id));if(void 0!==l){a.setTeamLoader({key:Pc.UPDATE_USER,value:s||""}),a.setTeamState({addUserDialogState:j({},r.addUserDialogState,{loading:!0})}),a.setTeamState({addUserDialogState:j({},r.addUserDialogState,{loading:!0}),users:r.users.map((e=>e.id===i.id?j({},e,i):e))});try{var c;l.roleIds.length>0&&0===(null==(c=i.roleIds)?void 0:c.length)&&(i.roleIds=[""]);const{item:e}=await t.teams.updateUser(i);null==o||o(e),a.setTeamState({users:r.users.map((t=>t.id===e.id?j({},t,e,{groups:t.groups,createdAt:t.createdAt,customData:t.customData,lastLogin:t.lastLogin}):t))}),a.setTeamLoader({key:Pc.UPDATE_USER,value:!1})}catch(e){a.setTeamState({addUserDialogState:j({},r.addUserDialogState,{loading:!1,error:Gc(e)}),users:r.users.map((e=>e.id===i.id?j({},e,l):e))}),a.setTeamLoader({key:Pc.UPDATE_USER,value:!1}),null==o||o(null,e)}}else null==o||o(null,"User not in state")},deleteUser:async n=>{const{callback:o}=n,i=oe(n,Xp),s=e.auth.teamState;a.setTeamState({deleteUserDialogState:j({},s.deleteUserDialogState,{loading:!0})});try{await t.teams.deleteUser(i),null==o||o(!0),a.setTeamState({users:s.users.filter((e=>e.id!==i.userId)),deleteUserDialogState:{open:!1,loading:!1}})}catch(e){a.setTeamState({deleteUserDialogState:j({},s.deleteUserDialogState,{loading:!1,error:Gc(e)})}),null==o||o(null,e)}},getTemporaryUsersConfig:async()=>{a.setTeamError({key:Pc.CONFIG_TEMPORARY_USERS,value:!1});try{const e=await t.teams.getTemporaryUserConfiguration();a.setTeamState({temporaryUsersConfig:e})}catch(e){a.setTeamError({key:Pc.CONFIG_TEMPORARY_USERS,value:Gc(e)})}},updateUserExpirationTime:async n=>{const{callback:o}=n,i=oe(n,Qp),s=e.auth.teamState;a.setTeamLoader({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:!0});try{const e=await t.teams.updateUserExpirationTime(i);a.setTeamState({users:s.users.map((t=>t.id===i.userId?j({},t,{temporaryExpirationDate:new Date(e.temporaryExpirationDate)}):t))}),null==o||o(!0)}catch(e){a.setTeamError({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:Gc(e)}),null==o||o(null,e)}finally{a.setTeamLoader({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:!1})}},setUserAsPermanent:async n=>{const{callback:o}=n,i=oe(n,Zp),s=e.auth.teamState;a.setTeamLoader({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:!0});try{await t.teams.setPermanentUser(i.userId),a.setTeamState({users:s.users.map((e=>e.id===i.userId?j({},e,{temporaryExpirationDate:void 0}):e))}),null==o||o(!0)}catch(e){a.setTeamError({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:Gc(e)}),null==o||o(null,e)}finally{a.setTeamLoader({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:!1})}}}})(e,t,n),((e,t,n)=>{const a=n;return{loadAllSubTenantsUsers:async n=>{var o,i,s,r,l;const{silentLoading:c,callback:u}=n,d=e.auth.teamState.allUsersQueryParams,g={_limit:(null!=(o=n._limit)?o:d._limit)||20,_offset:(null!=(i=n._offset)?i:d._offset)||0,_filter:(null!=(s=n._filter)?s:d._filter)||"",_sortBy:(null!=(r=n._sortBy)?r:d._sortBy)||"name",_order:(null!=(l=n._order)?l:d._order)||"DESC"};a.setTeamLoader({key:Pc.USERS,value:!c}),a.setTeamState({allUsersQueryParams:g});try{const[{items:e,_metadata:{totalPages:n,totalItems:o}},{items:i},{items:s}]=await Promise.all([t.subTenants.loadAllUsers(j({},g)),t.teams.loadAvailableRoles(),t.teams.loadAvailablePermissions()]);a.setTeamState({allUsers:e,totalPages:n,totalItems:o,roles:i,permissions:s}),null==u||u(e)}catch(e){a.setTeamError({key:Pc.USERS,value:Gc(e)}),a.setTeamState({totalPages:0,users:[]}),null==u||u(null,e)}a.setTeamLoader({key:Pc.USERS,value:!1})},setUserRolesForSubTenants:async n=>{const{callback:o,userId:i}=n,s=oe(n,ey),r=e.auth.teamState;a.setTeamState({addUserDialogState:j({},r.addUserDialogState,{loading:!0})});try{await t.subTenants.setUserRolesForSubTenants(i,s);const e=r.allUsers.find((e=>e.id===i));let n=[];e&&(n=e.tenants.map((e=>{var t;return j({},e,{roles:(null==(t=s.subTenantsRoles.find((t=>t.tenantId===e.tenantId)))?void 0:t.roleIds.map((e=>r.roles.find((({id:t})=>e===t)))).filter((e=>e)))||e.roles})}))),a.setTeamState({allUsers:[...r.allUsers.filter((e=>e.id!==i)),...e?[j({},e,{tenants:n})]:[]],addUserDialogState:{open:!1,loading:!1}}),null==o||o(!0)}catch(e){a.setTeamState({addUserDialogState:j({},r.addUserDialogState,{loading:!1,error:Gc(e)})}),null==o||o(null,e)}},deleteUserFromSubTenants:async n=>{const{callback:o}=n,i=oe(n,ty),s=e.auth.teamState;a.setTeamState({deleteUserDialogState:j({},s.deleteUserDialogState,{loading:!0})});try{await t.subTenants.removeUserFromTenantAndSubTenants(i),null==o||o(!0),a.setTeamState({allUsers:s.allUsers.filter((e=>e.id!==i.userId&&e.tenants.length===i.subTenants.length)),deleteUserDialogState:{open:!1,loading:!1}})}catch(e){a.setTeamState({deleteUserDialogState:j({},s.deleteUserDialogState,{loading:!1,error:Gc(e)})}),null==o||o(null,e)}},addUserToSubTenants:async n=>{const{callback:o}=n,i=oe(n,ny),s=e.auth.teamState;a.setTeamState({addUserDialogState:j({},s.addUserDialogState,{loading:!0})});try{await t.subTenants.addUserToTenantAndSubTenants(i);const{items:e,_metadata:{totalPages:n,totalItems:s}}=await t.subTenants.loadAllUsers({_limit:20,_offset:0,_filter:"",_sortBy:"name",_order:"DESC"});a.setTeamState({allUsers:e,totalPages:n,totalItems:s,addUserDialogState:{open:!1,loading:!1}}),null==o||o(null)}catch(e){a.setTeamState({addUserDialogState:j({},s.addUserDialogState,{loading:!1,error:Gc(e)})}),null==o||o(null,e)}}}})(e,t,n),((e,t,n)=>{const a=n,o=async(e,t,n,o)=>{a.setTeamLoader({key:e,value:t});try{await o()}catch(t){a.setTeamError({key:e,value:Gc(t)}),null==n||n(null,t)}finally{a.setTeamLoader({key:e,value:!1})}};return{resendActivationLink:async e=>{const{callback:n}=e,a=oe(e,ay);await o(Pc.RESEND_ACTIVATE_LINK,a.userId,n,(async()=>{await t.teams.resendActivationLink(a),null==n||n(!0)}))},resendInvitationLink:async e=>{const{callback:n}=e,a=oe(e,oy);await o(Pc.RESEND_INVITATION_LINK,a.email,n,(async()=>{await t.teams.resendInvitationLink(a),null==n||n(!0)}))},resendInvitationEmail:async e=>{const{callback:n}=e,a=oe(e,iy);await o(Pc.RESEND_INVITATION_LINK,n,a.email,(async()=>{await t.auth.resendInvitationEmail(a),null==n||n(!0)}))},resendInvitationLinkToAllSubTenants:async e=>{const{callback:n}=e,a=oe(e,sy);await o(Pc.RESEND_INVITATION_LINK,a.email,n,(async()=>{await t.teams.resendInvitationLinkToAllTenants(a),null==n||n(!0)}))}}})(0,t,n),((e,t,n)=>{const a=n;return{getInvitationLink:async()=>{a.setTeamError({key:Pc.GET_TOKEN_LINK,value:!1});try{await(async()=>{a.setTeamError({key:Pc.CONFIG_TOKEN_LINK,value:!1});try{const e=await t.teams.getInviteLinkConfiguration();a.setTeamState({inviteTokenState:j({},e)})}catch(e){a.setTeamError({key:Pc.CONFIG_TOKEN_LINK,value:Gc(e)})}})();const n=await t.teams.getInviteUserLink(),{inviteTokenState:o}=e.auth.teamState;a.setTeamState({inviteTokenState:j({},o,n)})}catch(e){a.setTeamError({key:Pc.GET_TOKEN_LINK,value:Gc(e)})}},createInvitationLink:async n=>{const{callback:o}=n;a.setTeamError({key:Pc.CREATE_TOKEN_LINK,value:!1});const{inviteTokenState:i}=e.auth.teamState;try{const e=await t.teams.createInviteUserLink({expiresInMinutes:43200});a.setTeamState({inviteTokenState:j({},i,e)}),null==o||o(e.token)}catch(e){null==o||o(null,e),a.setTeamError({key:Pc.CREATE_TOKEN_LINK,value:Gc(e)})}},updateInvitationLink:async n=>{const{callback:o,expiresInMinutes:i,shouldSendEmail:s}=n;a.setTeamError({key:Pc.UPDATE_TOKEN_LINK,value:!1});try{const{inviteTokenState:n}=e.auth.teamState,r=await t.teams.updateInviteUserLink({expiresInMinutes:i,shouldSendEmail:s});a.setTeamState({inviteTokenState:j({},n,r)}),null==o||o(!0)}catch(e){null==o||o(null,e),a.setTeamError({key:Pc.UPDATE_TOKEN_LINK,value:Gc(e)})}},deleteInvitationLink:async e=>{const{callback:n}=null!=e?e:{};a.setTeamError({key:Pc.DELETE_TOKEN_LINK,value:!1});try{await t.teams.deleteInviteUserLink(),a.setTeamState({inviteTokenState:void 0}),null==n||n(!0)}catch(e){a.setTeamError({key:Pc.DELETE_TOKEN_LINK,value:Gc(e)}),null==n||n(!1,e)}}}})(e,t,n))},ly={tenants:[],subTenants:[],loading:!0,tenantTree:null},cy=e=>Mc(ly,e),uy=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auth.tenantsState,t)};return{setTenantsState:o,resetTenantsState:()=>{e.auth.tenantsState=Xl(ly)},switchTenant:async e=>{const{tenantId:n,callback:o}=e;a.setAuthState({isLoading:!0});try{await t.tenants.switchTenant({tenantId:n}),await a.__refreshToken(),(null==o?void 0:o(!0))||a.setAuthState({isLoading:!1})}catch(e){a.setAuthState({isLoading:!1}),null==o||o(!1,e)}},loadTenants:async e=>{o({loading:!0});try{var t;const n=Et(),a=await n();o({tenants:a.tenants,activeTenant:a.activeTenant,loading:!1}),null==e||null==(t=e.callback)||t.call(e,[])}catch(t){var n;null==e||null==(n=e.callback)||n.call(e,[],t),o({loading:!1})}},loadSubTenants:async e=>{o({loading:!0});try{var n;const a=await t.tenants.getSubTenants();o({subTenants:a,loading:!1}),null==e||null==(n=e.callback)||n.call(e,!0)}catch(t){var a;o({loading:!1}),null==e||null==(a=e.callback)||a.call(e,null,t)}},loadSubTenantsTree:async e=>{o({loading:!0});try{var n;const a=await t.tenants.getSubTenantsAsTree();o({tenantTree:a,loading:!1}),null==e||null==(n=e.callback)||n.call(e,!0)}catch(t){var a;o({loading:!1}),null==e||null==(a=e.callback)||a.call(e,null,t)}}}},dy=(e,t,n)=>{const a=t=>{e.auth.user&&(e.auth.user.entitlements=t)},o=t=>{var n;gc(null==(n=e.auth.user)?void 0:n.entitlements,t)||a(t)};return{setEntitlements:a,handleFetchedEntitlements:o,loadEntitlements:async e=>{const n=null==e?void 0:e.callback;try{const e=await t.entitlements.loadEntitlementsV2();o(e),null==n||n(!0)}catch(e){null==n||n(!1)}}}},gy=["routes"],py=e=>{const t=null!=e?e:{},{routes:n}=t,a=oe(t,gy);return Mc(j({routes:j({},Yc,n),onRedirectTo:()=>{},isAuthenticated:!1,isLoading:!0,isSSOAuth:!1,user:null,error:void 0,userIp:void 0},a,{acceptInvitationState:$c(null==a?void 0:a.acceptInvitationState),accountSettingsState:Bc(null==a?void 0:a.accountSettingsState),activateAccountState:Kc(null==a?void 0:a.activateAccountState),apiTokensState:Lu(null==a?void 0:a.apiTokensState),applicationsState:Cu(null==a?void 0:a.applicationsState),customLoginState:$u(null==a?void 0:a.customLoginState),forgotPasswordState:Vu(null==a?void 0:a.forgotPasswordState),groupsState:Ku(null==a?void 0:a.groupsState),groupsDialogsState:Yu(null==a?void 0:a.groupsDialogsState),impersonateState:Zu(null==a?void 0:a.impersonateState),loginState:ad(null==a?void 0:a.loginState),mfaState:sd(null==a?void 0:a.mfaState),allAccountsState:dg(null==a?void 0:a.allAccountsState),allAccountsDialogsState:mg(null==a?void 0:a.allAccountsDialogsState),passkeysState:wg(null==a?void 0:a.passkeysState),profileState:Ig(null==a?void 0:a.profileState),provisioningState:Pg(null==a?void 0:a.provisioningState),resetPhoneNumberState:Cg(null==a?void 0:a.resetPhoneNumberState),rolesState:Gg(null==a?void 0:a.rolesState),restrictionsState:Jg(null==a?void 0:a.restrictionsState),securityCenterState:np(null==a?void 0:a.securityCenterState),securityPolicyState:sp(null==a?void 0:a.securityPolicyState),sessionsPolicyState:gp(null==a?void 0:a.sessionsPolicyState),sessionsState:Sp(null==a?void 0:a.sessionsState),signUpState:mp(null==a?void 0:a.signUpState),smsState:Tp(null==a?void 0:a.smsState),socialLoginState:Lp(null==a?void 0:a.socialLoginState),ssoState:Mp(null==a?void 0:a.ssoState),stepUpState:Wp(null==a?void 0:a.stepUpState),teamState:Hp(null==a?void 0:a.teamState),tenantsState:cy(null==a?void 0:a.tenantsState)}))},yy=(e,t,n,a)=>{const o=t=>{Object.keys(t).forEach((n=>{tc(e.auth[n])?Object.assign(e.auth[n],t[n]):e.auth[n]=t[n]}))},i={acceptInvitationActions:xc(e,t),accountSettingsActions:Wc(e,t),activateAccountActions:Pu(e,t,n),apiTokensActions:Du(e,t),applicationsActions:Mu(e,t,n),customLoginActions:Gu(e,t,n),entitlementsActions:dy(e,t),forgotPasswordActions:Wu(e,t),groupsActions:qu(e,t),groupsDialogsActions:Xu(e),impersonateActions:td(e,t,n),loginActions:eg(e,t,n),mfaActions:cg(e,t,n),allAccountsActions:hg(e,t,n),allAccountsDialogActions:bg(e),passkeysActions:Tg(e,t,n),profileActions:Og(e,t,n),provisioningActions:Dg(e,t),resetPhoneNumberActions:$g(e,t,n),rolesActions:Hg(e,t),restrictionsActions:ep(e,t,n),securityCenterActions:op(e,t,n),securityPolicyActions:up(e,t,n),sessionsPolicyActions:yp(e,t,n),sessionsActions:hp(e,t),signUpActions:Ap(e,t,n),smsActions:Pp(e,t),socialLoginActions:Cp(e,t,n),ssoActions:Vp(e,t,n),stepUpActions:zp(e,t,n),teamActions:ry(e,t,n),tenantsActions:uy(e,t,n)};return[j({setAuthState:o,setState:o,resetAuthState:()=>{o(a)},setUser:e=>{o({user:e})}},Object.values(i).reduce(((e,t)=>j({},e,t)),{})),i]},fy={isLoading:!1,isSaving:!1,list:[],processIds:[],slackChannels:{isLoading:!1}},Sy=e=>Mc(fy,e),hy=["email","slack","sms","webhook"],vy={sms:{title:"connectivity.sms",events:e=>(null==e?void 0:e.length)||0,isActive:e=>{var t;return null!=(t=null==e?void 0:e.some((({enabled:e})=>e)))&&t},image:"sms"},email:{title:"common.email",events:e=>(null==e?void 0:e.length)||0,isActive:e=>{var t;return null!=(t=null==e?void 0:e.some((({enabled:e})=>e)))&&t},image:"email"},slack:{title:"connectivity.slack",events:e=>{var t;return(null==e||null==(t=e.slackSubscriptions)?void 0:t.length)||0},isActive:e=>!(null==e||!e.slackSubscriptions.some((({isActive:e})=>e))),image:"slack"},webhook:{title:"connectivity.webhook",events:e=>(null==e?void 0:e.length)||0,isActive:e=>{var t;return null!=(t=null==e?void 0:e.some((({isActive:e})=>e)))&&t},image:"webhook"}},my=["id"],by=["id","enabled"],Ay=(e,t,n)=>{const a={slack:t.connectivity.getSlackConfiguration,email:t.connectivity.getEmailConfiguration,sms:t.connectivity.getSMSConfiguration,webhook:t.connectivity.getWebhooksConfigurations,categories:t.connectivity.getCategories,channelMap:t.connectivity.getChannelMaps},o=["categories","channelMap"],i={slack:t.connectivity.postSlackConfiguration,email:t.connectivity.postEmailConfiguration,sms:t.connectivity.postSMSConfiguration,webhook:t.connectivity.postWebhooksConfiguration},s=t=>{Object.assign(e.connectivity,t)},r=t=>{var n;const a=null!=(n=e.connectivity.retryResult)?n:{};e.connectivity.retryResult=j({},a,t)},l=()=>{e.connectivity=Xl(fy)},c=async(e,t)=>{try{return await a[e](t)}catch(e){return}},u=async()=>{try{s({slackChannels:{isLoading:!0}});const e=await t.connectivity.getSlackChannels();s({error:void 0,slackChannels:{isLoading:!1,data:e}})}catch(e){s({error:void 0,slackChannels:{isLoading:!1}})}},d=async e=>{const t=null!=e?e:hy;s({isLoading:!0});try{const e=await Promise.all([...t.map((e=>c(e))),c("categories"),(async()=>(await Promise.all(t.map((e=>c("channelMap",e))))).reduce(((e,n,a)=>j({},e,{[`${t[a]}`]:n})),{}))()]),n=await c("webhook"),a=e.reduce(((n,a,i)=>t[i]?e[e.length-1][t[i]].length?j({},n,{[`${t[i]}`]:a,list:[...n.list,{id:i,key:t[i],events:vy[t[i]].events(a),active:vy[t[i]].isActive(a),platform:vy[t[i]].title,image:vy[t[i]].image}]}):n:j({},n,{[`${o[i-t.length]}`]:a})),{list:[],webhook:n});s(j({},a,{error:void 0,isSaving:!1,isLoading:!1}))}catch(e){s({isLoading:!1,error:Gc(e)})}},g=async(t,n)=>{const{list:a}=e.connectivity,o=a.find((({key:e})=>e===t));if(!o)return;const i=vy[t].isActive(n);i!==o.active&&s({list:a.map((e=>e.key===t?j({},e,{active:i}):e))})},p=async n=>{const{platform:a,data:o,callback:r}=n,l=e.connectivity.processIds;try{if(s({isSaving:!0,processIds:"webhook"===a?[o._id,...l]:l}),"slack"===a?await(async n=>{var a;const o=null==(a=e.connectivity.slack)?void 0:a.slackSubscriptions;if(!o)return;const{slackSubscriptions:s}=n;await Promise.all([...s.reduce(((e,t)=>{var n,a;return!t.id&&t.slackEvents&&null!=(n=t.slackEvents[0].channelIds)&&n.length||(null==o?void 0:o.find((e=>{let{id:n}=e,a=oe(e,my);return n===t.id&&JSON.stringify(j({id:n},a))!==JSON.stringify(t)})))&&t.slackEvents&&null!=(a=t.slackEvents[0].channelIds)&&a.length?[...e,t]:e}),[]).map((e=>i.slack(e))),...s.reduce(((e,t)=>t.id&&!t.slackEvents[0].channelIds.length?[...e,t]:e),[]).map((e=>t.connectivity.deleteSlackConfiguration(e)))])})(o):["sms","email"].includes(a)?await(async(n,a)=>{const o=e.connectivity.processIds,i=e.connectivity[a];if(!i)return;let r=[];try{r=await Promise.all([...n.reduce(((e,t)=>!i.find((({eventKey:e})=>e===t.eventKey))&&t.subscriptions[0].recipients.filter((e=>e)).length?[...e,t]:e),[]).map((e=>"email"===a?t.connectivity.postEmailConfiguration(e):t.connectivity.postSMSConfiguration(e))),...n.reduce(((e,t)=>{const n=i.find((({eventKey:e})=>e===t.eventKey));return n&&JSON.stringify(n)!==JSON.stringify(t)?[...e,t]:e}),[]).map((e=>{const{subscriptions:n,eventKey:o}=e,i=n[0],{id:s="",enabled:r}=i,l=oe(i,by);return Promise.all(["email"===a?t.connectivity.patchEmailConfiguration({eventKey:o,enabled:r}):t.connectivity.patchSMSConfiguration({eventKey:o,enabled:r}),"email"===a?t.connectivity.putEmailSubscriptions(s,o,j({},l,{enabled:r})):t.connectivity.putSMSSubscriptions(s,o,j({},l,{enabled:r}))])})),...n.reduce(((e,t)=>{const n=i.find((({eventKey:e})=>e===t.eventKey));return n&&n.subscriptions[0].recipients.length&&!t.subscriptions[0].recipients.filter((e=>!!e)).length?[...e,t]:e}),[]).map((({eventKey:e,subscriptions:n})=>"email"===a?t.connectivity.deleteEmailSubscriptions(e,n[0].id||""):t.connectivity.deleteSMSSubscriptions(e,n[0].id||"")))])}catch{}if(r.length){const e=await c(a);s({error:void 0,isSaving:!1,[`${a}`]:e,processIds:e.id?o.filter((t=>t!==e.id)):o}),await g(a,e)}else s({error:void 0,isSaving:!1,[`${a}`]:i,processIds:o})})(o,a):await i[a](o),!["sms","email"].includes(a)){const e=await c(a);"webhook"===a&&(e.id=o._id),s({error:void 0,isSaving:!1,[`${a}`]:e,processIds:e.id?l.filter((t=>t!==e.id)):l}),await g(a,e),null==r||r(!0)}}catch(e){s({error:Gc(e),isSaving:!1,isLoading:!1})}},y=async e=>{try{await t.connectivity.postSlackCode(e)}catch{}s({error:void 0,isSaving:!1})},f=async()=>{const n=e.connectivity.slackChannels;try{s({slackChannels:j({},n,{isLoadingScope:!0})});const{clientId:e}=await t.connectivity.getSlackScope();s({slackChannels:{error:void 0,clientId:e,isLoadingScope:!1,isLoading:!1}})}catch{s({slackChannels:{error:void 0,isLoadingScope:!1,isLoading:!1}})}},S=async n=>{const{callback:a,webhookId:o}=n,i=e.connectivity.processIds;try{s({isSaving:!0}),await t.connectivity.deleteWebhooksConfiguration(o)}catch(e){null==a||a(null,Gc(e))}const r=await c("webhook");r&&s({error:void 0,isSaving:!1,webhook:r,processIds:r.id?i.filter((e=>e!==r.id)):i}),null==a||a(!0)},h=async e=>{try{s({isTesting:!0});const{statusCode:n,body:a}=await t.connectivity.postWebhookTest(e);if([201,200].includes(n)){const e=JSON.stringify(a,null,2);s({isTesting:!1,testResult:{status:"success",message:e}})}else s({isTesting:!1,testResult:{status:"failed"}})}catch(e){s({isTesting:!1,testResult:{status:"failed",message:Gc(e)}})}},v=async e=>{try{const{statusCode:n}=await t.connectivity.postWebhookRetry(e);r({[e]:{isProcess:!1,success:202===n}})}catch(t){r({[e]:{isProcess:!1,success:!1}})}},m=async n=>{const{id:a,limit:o,offset:i}=n,r=e.connectivity.webhookLogs;try{s({webhookLogs:j({},r,{isLoading:!0})});const e=await t.connectivity.getWebhookLog(a,i,o);s({error:void 0,webhookLogs:j({isLoading:!1},e)})}catch(e){s({error:void 0,webhookLogs:{isLoading:!1}})}};return{setConnectivityState:s,initData:l,resetConnectivityState:l,loadSlackActions:u,loadSlackChannels:u,loadDataAction:d,loadConnectivityChannels:d,postDataAction:p,postChannelData:p,postCodeAction:y,postSlackCode:y,loadScope:f,loadSlackPermissions:f,deleteWebhookConfigAction:S,deleteWebhookConfig:S,postWebhookTestAction:h,postWebhookTest:h,postWebhookRetryAction:v,postWebhookRetry:v,loadWebhookLogsAction:m,loadWebhookLogs:m,cleanWebhookTestData:()=>{s({testResult:void 0})},cleanWebhookLogsData:async()=>{s({webhookLogs:void 0})},cleanWebhookTestMessage:async e=>{var t;s({testResult:{status:null==(t=e.testResult)?void 0:t.status,message:void 0}})},cleanError:async()=>{s({error:void 0})},cleanSlackData:async()=>{s({slackChannels:{isLoading:!1}})}}};let wy;!function(e){e.UNKNWON="unknown",e.CARD="card"}(wy||(wy={}));const Ty={loading:!1,error:null,fetching:!0,config:null},Ey=e=>Mc(Ty,e);let Iy,ky,Oy;!function(e){e.STRIPE="Stripe"}(Iy||(Iy={})),function(e){e.ACTIVE="ACTIVE",e.CANCELED="CANCELED",e.INCOMPLETE="INCOMPLETE",e.EXPIRED="EXPIRED",e.TRIALING="TRIALING"}(ky||(ky={})),function(e){e.AT_PERIOD_END="atPeriodEnd"}(Oy||(Oy={}));const _y=(e,t,n)=>{const a=t=>{Object.assign(e.subscriptions.config,t)},o=t=>{Object.assign(e.subscriptions.config,{error:t,loading:!1,fetching:!1})};return{setPaymentConfigState:a,resetPaymentConfigState:()=>{e.subscriptions.config=Xl(Ty)},loadPaymentConfiguration:async()=>{a({loading:!0});try{var e;(null!=(e=await t.subscriptions.getPaymentProviders())?e:[]).find((e=>"1"===e.status&&e.providerType===Ur.Stripe))?await(async()=>{a({loading:!0});try{const e=await t.subscriptions.getStripePaymentProviderConfiguration(),n={paymentProvider:Iy.STRIPE,apiKey:e.publishableKey};a({config:n}),a({loading:!1,fetching:!1})}catch(e){o(Gc(e))}})():o(Gc("Payment provider not configured"))}catch(e){o(Gc(e))}}}},Py={loading:!1,error:null,fetching:!0},Uy=e=>Mc(Py,e);function Ly({policy:e}){return{policy:Oy.AT_PERIOD_END}}function Dy(e){switch(e){case Or.ACTIVE:return ky.ACTIVE;case Or.INCOMPLETE:return ky.INCOMPLETE;case Or.CANCELED:return ky.CANCELED;case Or.EXPIRED:return ky.EXPIRED;case Or.TRIALING:return ky.TRIALING;default:return ky.EXPIRED}}const Ry=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.subscriptions.billing.information,t)},i=e=>{o({error:e,loading:!1,fetching:!1})},s=async(n,s)=>{o({loading:!0});try{var r,l;const i=await t.subscriptions.getSubscriptionSummaries(n),{currentPlanId:c,externallyManaged:u}=i;let d,g=null;u?d=await t.subscriptions.getSubscriptionPlan(c):([,d]=await Promise.all([a.loadSubscription(),t.subscriptions.getSubscriptionPlan(c)]),g=e.subscriptions.billing.subscription.subscription||null),o(j({loading:!1,fetching:!1,summary:i},g?{subscription:{id:g.id,externalId:g.externalId,startDate:g.startDate,currentPeriodStart:g.currentPeriodStart,currentPeriodEnd:g.currentPeriodEnd,status:s?ky.ACTIVE:Dy(g.status),cancellation:g.cancellation&&Ly(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(e){i(Gc(e))}};return{setBillingInformationState:o,resetBillingInformationState:()=>{e.subscriptions.billing.information=Xl(Py)},loadSummaries:s,loadBillingInformation:async t=>{var n,a;const o=null==(n=e.subscriptions.config.config)?void 0:n.paymentProvider,r=null==(a=e.auth.user)?void 0:a.tenantId;o&&r?await s(r,t):i(o?"Not authorized":"Internal feature failure")}}},Cy={loading:!1,error:null,fetching:!0,invoices:[],invoiceDownload:{loading:!1,error:null}},Ny=e=>Mc(Cy,e),My=(e,t,n)=>{const a=t=>{Object.assign(e.subscriptions.billing.invoices,t)},o=t=>{Object.assign(e.subscriptions.billing.invoices.invoiceDownload,t)},i=async()=>{a({loading:!0});try{const e=(await t.subscriptions.getSubscriptionInvoices()).map((e=>({id:e.id,externalId:e.externalId,subscriptionId:e.subscriptionId,paymentDate:new Date(Date.parse(e.paymentDate)),totalAmount:+((e.totalAmount||0)/100).toFixed(2),currency:e.currency||"usd",paid:e.paid||!1,receiptNumber:e.receiptNumber})));a({loading:!1,fetching:!1,invoices:e})}catch(t){e=Gc(t),a({error:e,loading:!1,fetching:!1})}var e},s=async e=>{o({loading:!0,error:null});try{await t.subscriptions.getSubscriptionInvoicePdf(e.invoiceId,e.filename),o({loading:!1,error:null})}catch(e){o({loading:!1,error:Gc(e,null)})}};return{setBillingInvoiceState:a,resetBillingInvoiceState:()=>{e.subscriptions.billing.invoices=Xl(Cy)},loadInvoices:i,loadBillingInvoices:i,downloadInvoice:s,downloadBillingInvoice:s}},Fy={loading:!1,error:null,fetching:!0},$y=e=>Mc(Fy,e),jy=(e,t,n)=>{const a=t=>{Object.assign(e.subscriptions.billing.paymentMethod,t)},o=e=>{a({loading:e})},i=e=>{a({error:e,loading:!1,fetching:!1})},s=async()=>{o(!0);try{const e=(await t.subscriptions.getPaymentMethods())[0];a({paymentMethod:e,loading:!1,fetching:!1})}catch(e){i(Gc(e))}};return{setBillingPaymentMethodState:a,resetBillingPaymentMethodState:()=>{e.subscriptions.billing.paymentMethod=Xl(Fy)},loadPaymentMethod:s,submitPaymentMethod:async()=>{o(!0)},submitPaymentMethodError:async e=>{i(e)},submitPaymentMethodSuccess:async()=>await s(),updatePaymentMethodBillingDetails:async e=>{o(!0);const{id:n,email:a,address:r,callback:l}=e;try{await t.subscriptions.updatePaymentMethodBillingDetails(n,j({email:a},r)),await s(),null==l||l(!0)}catch(e){i(Gc(e)),null==l||l(!1,e)}finally{o(!1)}}}},Gy={loading:!1,error:null,fetching:!0,cancellation:{loading:!1,error:null},renewal:{loading:!1,error:null}},xy=e=>Mc(Gy,e),Vy=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.subscriptions.billing.subscription,t)},i=e=>{o({error:e,loading:!1,fetching:!1})},s=t=>{Object.assign(e.subscriptions.billing.subscription.cancellation,{loading:t})},r=t=>{Object.assign(e.subscriptions.billing.subscription.cancellation,{error:t})},l=t=>{Object.assign(e.subscriptions.billing.subscription.renewal,{loading:t})},c=t=>{Object.assign(e.subscriptions.billing.subscription.renewal,{error:t})},u=async()=>{o({loading:!0});try{const[e]=await t.subscriptions.getManagedSubscriptions();o({subscription:e,fetching:!1,loading:!1,error:null})}catch(e){i(Gc(e))}};return{setBillingSubscriptionState:o,resetBillingSubscriptionState:()=>{e.subscriptions.billing.subscription=Xl(Gy)},setCancellationLoading:s,setCancellationError:r,setRenewalLoading:l,setRenewalError:c,loadSubscription:u,loadSubscriptionTenant:async()=>{var t;const n=null==(t=e.auth.user)?void 0:t.tenantId;n?await a.loadSummaries(n):i("TenantId is not defined")},cancelSubscription:async()=>{const{subscription:n}=e.subscriptions.billing.subscription;if(!n)return void r("Subscription not found.");if(null!=n&&n.externallyManaged)return void r("Billing is externally managed.");const{id:a,cancellation:o,status:i}=n||{};if(!o&&i===Or.ACTIVE)try{s(!0),await t.subscriptions.cancelManagedSubscription(a),await u(),s(!1)}catch(e){r(Gc(e))}},renewSubscription:async()=>{const{subscription:n}=e.subscriptions.billing.subscription;if(!n)return void c("Subscription not found.");if(null!=n&&n.externallyManaged)return void c("Billing is externally managed");const{id:a,cancellation:o}=n||{};if((null==o?void 0:o.policy)===Pr.AT_PERIOD_END)try{l(!0),await t.subscriptions.renewManagedSubscription(a),await u(),l(!1)}catch(e){c(Gc(e))}}}},By=e=>Mc({information:Uy(null==e?void 0:e.information),invoices:Ny(null==e?void 0:e.invoices),paymentMethod:$y(null==e?void 0:e.paymentMethod),subscription:xy(null==e?void 0:e.subscription)}),Wy={loading:!1,error:null,fetching:!0,plans:[]},zy=e=>Mc(Wy,e),Ky=(e,t,n)=>{const a=t=>{Object.assign(e.subscriptions.plans,t)};return{setPlansState:a,resetPlansState:()=>{e.subscriptions.plans=Xl(Wy)},loadPlans:async()=>{a({loading:!0});try{const e=(await t.subscriptions.getSubscriptionPlans()).map((e=>{var t,n;return{id:e.id,name:e.name,description:e.description,price:(null==(t=e.price)?void 0:t.amount)||0,currency:(null==(n=e.price)?void 0:n.currency)||"usd",recurringInterval:"month",slug:e.slug}}));a({fetching:!1,loading:!1,plans:e})}catch(t){e=Gc(t),a({loading:!1,fetching:!1,error:e})}var e}}},Hy={fetching:!0,loading:!1,error:null,confirmed:!1},qy=e=>Mc(Hy,e),Jy=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.subscriptions.checkout,t)};return{setCheckoutState:o,resetCheckoutState:()=>{e.subscriptions.checkout=Xl(Hy)},loadCheckout:()=>{o({fetching:!1,loading:!1,error:null,confirmed:!1})},resetCheckout:()=>{o({loading:!1,error:null,confirmed:!1})},submitCheckout:()=>{o({loading:!0,error:null})},confirmCheckout:async n=>{const{paymentMethodId:i,planId:s}=n,r=e.subscriptions.billing.subscription.subscription,l=e.subscriptions.billing.information.summary,c=(null==r?void 0:r.status)===Or.TRIALING,u=!(null==l||!l.paymentMethodId);if(r){if(o({loading:!0,error:null}),c&&u)return o({loading:!1,error:null,confirmed:!0}),void a.setBillingSubscriptionState({subscription:j({},r,{status:Or.ACTIVE})});try{await t.subscriptions.updateManagedSubscription(r.id,{paymentMethodId:i,planId:s}),await Promise.all([a.loadBillingInformation(),a.loadPaymentMethod(),a.loadInvoices()]),o({loading:!1,error:null,confirmed:!0})}catch(e){o({loading:!1,error:Gc(e)})}}else o({loading:!1,error:"Subscription not found"})},errorCheckout:e=>{o({loading:!1,error:e})}}},Yy={loading:!1,error:null,cardSetupIntentSecret:null},Xy=e=>Mc(Yy,e),Qy=(e,t,n)=>{const a=t=>{Object.assign(e.subscriptions.stripe,t)};return{createCardSetupIntentSecret:async n=>{a({loading:!0,error:null,cardSetupIntentSecret:null});try{const e={};n&&(e.paymentMethodId=n);const{setupIntentSecret:o}=await t.subscriptions.createStripePaymentMethodSetupIntentSecret(e);a({cardSetupIntentSecret:o,loading:!1})}catch(t){o=Gc(t),Object.assign(e.subscriptions.stripe,{error:o,loading:!1,fetching:!1})}var o}}},Zy={loading:!1,fetching:!0,vendorPublicConfig:null},ef=e=>Mc(Zy,e),tf=(e,t,n)=>{const a=t=>{Object.assign(e.subscriptions.vendorPublicConfig,t)},o=t=>{Object.assign(e.subscriptions.vendorPublicConfig,{error:t,loading:!1,fetching:!1})},i=t=>{Object.assign(e.subscriptions.vendorPublicConfig,{error:null,loading:t})};return{setVendorPublicConfigState:a,resetVendorPublicConfigState:()=>{e.subscriptions.vendorPublicConfig=Xl(Zy)},setVendorPublicConfigError:o,setVendorPublicConfigLoading:i,loadVendorPublicConfiguration:async()=>{i(!0);try{const e=await t.subscriptions.getVendorPublicConfigurations();a({fetching:!1,loading:!1,vendorPublicConfig:e})}catch(e){o(Gc(e))}}}},nf=e=>Mc({config:Ey(null==e?void 0:e.config),billing:By(null==e?void 0:e.billing),plans:zy(null==e?void 0:e.plans),checkout:qy(null==e?void 0:e.checkout),stripe:Xy(null==e?void 0:e.stripe),vendorPublicConfig:ef(null==e?void 0:e.vendorPublicConfig)}),af=(e,t,n)=>{const a=_y(e,t),[o,i]=((e,t,n)=>{const a=Ry(e,t,n),o=jy(e,t),i=My(e,t),s=Vy(e,t,n);return[j({},a,o,i,s),{information:a,invoices:i,paymentMethod:o,subscription:s}]})(e,t,n),s=Ky(e,t),r=Jy(e,t,n),l=Qy(e,t),c=tf(e,t);return[j({},a,o,s,r,l,c),{config:a,billing:i,plans:s,checkout:r,stripe:l,vendorPublicConfig:c}]},of={loading:!1},sf=e=>Mc(of,e),rf=(e,t,n)=>{const a=t=>{Object.assign(e.vendor,t)},o=async()=>{a({loading:!0});try{var e;const n=await t.vendor.getVendorPublicInfo();n.whiteLabelMode=null!=(e=n.whiteLabelMode)&&e,a(j({},n,{loading:!1}))}catch(e){a({loading:!1}),console.error("failed to getVendorPublicInfo - ",e)}};return{setVendorState:a,resetVendorState:()=>{e.vendor=Xl(of)},loadVendorPublicInfo:o,loadVendorPublicConfiguration:o}},lf={loading:!0,pageOffset:0,pageSize:20,logs:[],sort:[],filter:[],totalPages:0,isDownloadingCsv:!1},cf=e=>Mc(lf,e),uf=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auditLogs.auditLogsState,t)};return{setAuditLogsState:o,resetAuditLogsState:()=>{e.auditLogs.auditLogsState=Xl(lf)},exportAuditsCsv:async()=>{const n=e.auditLogs.auditLogsState,{columns:a}=e.auditLogs.auditsMetadataState;try{const e=n.filter,i=n.sort.reduce(((e,t)=>j({},e,{sortBy:t.id,sortDirection:t.desc?"desc":"asc"})),{}),s=e.reduce(((e,t)=>j({},e,{[t.id]:t.value})),{});o({isDownloadingCsv:!0});const r="audits.csv";await t.audits.exportAudits(j({endpoint:"csv/v2",headerProps:a,offset:0,outputFileName:r},i,s))}catch(e){console.error("failed to export audits - ",e)}o({isDownloadingCsv:!1})},loadAuditLogs:async n=>{o({loading:!(null!=n&&n.silentLoading),error:null});const i=e.auditLogs.auditLogsState,{columns:s}=e.auditLogs.auditsMetadataState;try{var r,l,c,u,d;const e=null!=(r=n.pageSize)?r:i.pageSize,g=null!=(l=n.pageOffset)?l:i.pageOffset,p=null!=(c=n.filter)?c:i.filter,y=null!=(u=n.sort)?u:i.sort;o({pageSize:e,pageOffset:g,filter:p,sort:y});const f=y.reduce(((e,t)=>j({},e,{sortBy:t.id,sortDirection:t.desc?"desc":"asc"})),{}),S=p.reduce(((e,t)=>j({},e,{[t.id]:t.value})),{});s||await a.loadAuditsMetadata();const{data:h,total:v}=await t.audits.getAudits(j({offset:g,count:e},f,S));o({loading:!1,logs:null!=h?h:[],totalPages:+Math.ceil(v/e)}),null==n||null==(d=n.callback)||d.call(n,!0)}catch(e){var g;o({loading:!1,error:Gc(e)}),null==n||null==(g=n.callback)||g.call(n,null,e)}}}},df={loading:!0},gf=e=>Mc(df,e),pf=(e,t,n)=>{const a=t=>{Object.assign(e.auditLogs.auditsMetadataState,t)};return{setAuditsMetadataState:a,resetAuditsMetadataState:()=>{e.auditLogs.auditsMetadataState=Xl(df)},loadAuditsMetadata:async()=>{a({loading:!0,error:null});try{const{properties:e}=await t.metadata.getAuditsMetadata();a({columns:e,loading:!1})}catch(e){a({error:e,loading:!1})}}}},yf=e=>({auditLogsState:cf(null==e?void 0:e.auditLogsState),auditsMetadataState:gf(null==e?void 0:e.auditsMetadataState)}),ff=(e,t,n)=>j({},uf(e,t,n),pf(e,t));var Sf=n(262),hf=n.n(Sf);const vf={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},mf=(e,t)=>Object.keys(e).reduce(((n,a)=>t.includes(a)?j({},n,{[a]:e[a]}):j({},n,{[a]:()=>{console.debug(`Action ${String(a)} was called`)}})),{}),bf={clientId:"CLIENT_ID_16806d3d-8fc3-4450-be97-abdaf66b723e",secret:"SECRET_16806d3d-8fc3-4450-be97-abdaf66b723e",createdAt:"createdAt",description:"Demo API Token (preview only)"},Af=j({},bf,{roleIds:[],tenantId:"my-tenant-id",createdByUserId:"createdByUserId"}),wf=[{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"}],Tf={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},Ef=j({},Tf,{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}),If={loading:!1,error:void 0,saving:!0,profile:Tf},kf={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"},Of={allowSignups:!0,allowNotVerifiedUsersLogin:!1,apiTokensEnabled:!0,forcePermissions:!1,authStrategy:rn.EmailAndPassword,machineToMachineAuthStrategy:ln.ClientCredentials},_f={id:"id",enforceMFAType:"DontForce",createdAt:new Date,updatedAt:new Date},Pf={id:"id",enabled:!0,maxAttempts:1,createdAt:new Date,updatedAt:new Date},Uf={id:"id",enabled:!0,historySize:1,createdAt:new Date,updatedAt:new Date},Lf={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},Df={id:"id",createdAt:"createdAt",updatedAt:"updatedAt",properties:[],vendorId:"vendorId",entityName:"saml",isActive:!0,configuration:{acsUrl:"acsUrl",spEntityId:"spEntityId"}},Rf=[{id:"id",description:"description",key:"key",name:"name",permissions:[],permissionLevel:1}],Cf={firstLoad:!1,loading:!1,error:void 0,saving:!1,samlConfiguration:Lf,roles:Rf,authorizationRoles:[],errors:{},loaders:{},ssoConfigurations:[]},Nf=[{description:"string",fePermission:!0,id:"id",key:"key",name:"name",roleIds:[],createdAt:new Date,updatedAt:new Date,categoryId:"categoryId"}],Mf={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:[wf[0]],groups:[{id:"id2",name:"Developers",color:"#03A9F4",roles:[wf[0]],managedBy:jl.FRONTEGG}]},Ff={id:Mf.id,email:Mf.email,name:Mf.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:[wf[1]],tenantIds:[],metadata:"",sub:"",tenants:[]},$f={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:[wf[1]],groups:[{id:"id1",name:"Designers",color:"#E1F5E2",roles:[wf[0]],managedBy:jl.FRONTEGG}]},jf={id:$f.id,email:$f.email,name:$f.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:[wf[1]],tenantIds:[],metadata:"",sub:"",tenants:[]},Gf={metadata:"",mfaEnrolled:!1,provider:"",sub:"",tenantIds:[],tenants:[],verified:!1,id:"id",email:"email",name:"name",tenantId:"tenantId",createdAt:new Date},xf=[$f,Mf],Vf=[jf,Ff],Bf=[Gf],Wf=[{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}],zf=[{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"}],Kf={isActive:!0,strategy:pn.ALLOW},Hf=[{updatedAt:new Date,createdAt:new Date,id:"1",ip:"255.255.255.255",isActive:!0,strategy:pn.ALLOW,description:"My IP"},{updatedAt:new Date,createdAt:new Date,id:"2",ip:"255.255.255.254",isActive:!0,strategy:pn.ALLOW,description:"IP 2"},{updatedAt:new Date,createdAt:new Date,id:"3",ip:"255.255.255.253",isActive:!0,strategy:pn.BLOCK,description:"IP 3"},{updatedAt:new Date,createdAt:new Date,id:"4",ip:"255.255.255.253",isActive:!0,strategy:pn.BLOCK,description:"IP 4"}],qf=e=>{const t=[];return Array.from({length:e}).forEach(((e,n)=>{t.push(j({},$f,{name:"Demo User",id:`id${n}`,profilePictureUrl:null,createdAt:new Date}))})),t},Jf=e=>({id:"b43b2c4b-e056-4eec-8c55-d200a475bbc0"+e,key:e,name:e,description:null,isDefault:!0,createdAt:new Date,updatedAt:new Date,permissions:[],tenantId:"tenantId",vendorId:"vendorId"}),Yf=[{id:"id1",name:"Designers",color:"#E1F5E2",description:"The whole design team",users:qf(6),roles:[Jf("Editor")],metadata:'{"lastTermsCheck":"2022-08-16T10:31:11.270Z"}',managedBy:jl.FRONTEGG},{id:"id2",name:"Developers",color:"#03A9F4",description:"All frontend and backend developers",users:qf(44),roles:[Jf("Editor")],managedBy:jl.FRONTEGG},{id:"id3",name:"Product",color:"#E1583E",description:"PMs and team leads",users:qf(8),roles:[Jf("Viewer")],managedBy:jl.FRONTEGG},{id:"id4",name:"Management",color:"#9AE0FF",description:"Executives",users:qf(5),roles:[Jf("Admin")],managedBy:jl.FRONTEGG},{id:"id5",name:"Sales",color:"#ED8E7C",users:qf(21),description:"BDR, AE, and inside sales",roles:[Jf("Viewer")],managedBy:jl.FRONTEGG},{id:"id6",name:"Support",color:"#A79D7B",users:qf(23),description:"Dev success and customer success",roles:[Jf("Admin")],managedBy:jl.FRONTEGG},{id:"id7",name:"Marketing",color:"#2CA744",users:qf(10),description:"The marketing department",roles:[Jf("Viewer")],managedBy:jl.FRONTEGG},{id:"id8",name:"HR",color:"#EAE1C2",users:qf(4),description:"Human resources",roles:[Jf("Viewer")],managedBy:jl.FRONTEGG},{id:"id9",name:"Finance",color:"#5587C0",users:qf(3),roles:[Jf("Viewer")],managedBy:jl.FRONTEGG},{id:"id10",name:"Operations",color:"#B1CAE7",users:qf(8),roles:[Jf("Editor")],managedBy:jl.FRONTEGG},{id:"id11",name:"Legal",color:"#2CA744",users:qf(4),roles:[Jf("Viewer")],managedBy:jl.FRONTEGG}],Xf={scoring:{score:79},recommendations:{items:[{code:Bl.FORCE_MFA,severity:Kl.WARNING,category:Hl.MFA},{code:Bl.ENABLE_FORCE_RELOGIN,severity:Kl.WARNING,category:Hl.SESSIONS}]}},Qf={insights:{items:[{category:Hl.MFA,code:Wl.PARTIALLY_FORCED_MFA,metadata:{totalUsers:2,mfa:{enrolledUsersCount:1}}},{category:Hl.SESSIONS,code:Wl.PARTIAL_SESSION_SETTINGS,metadata:{totalUsers:2,sessions:{idleTimeoutRecommendation:1800}}},{category:Hl.PASSWORD,code:Wl.IMPROVE_PASSWORD_HISTORY_POLICY,metadata:{password:{userLockoutRecommendation:5,historyRecommendations:5}}},{category:Hl.DOMAIN,code:Wl.NO_IP_RESTRICTIONS,metadata:{restrictions:{ipsCount:1,domainsCount:1}}}]}},Zf={users:Vf,totalUsersItems:2,totalUsersPages:1,usersPageOffset:0},eS={users:[Vf[0]],totalUsersItems:1,totalUsersPages:1,usersPageOffset:0,queryParams:{_maxInactiveSeconds:7776e3}},tS={users:[Vf[1]],totalUsersItems:1,totalUsersPages:1,usersPageOffset:0};Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.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 nS,aS=new Uint8Array(16);function oS(){if(!nS&&!(nS="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 nS(aS)}const iS=/^(?:[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,sS=function(e){return"string"==typeof e&&iS.test(e)};for(var rS=[],lS=0;lS<256;++lS)rS.push((lS+256).toString(16).substr(1));const cS=function(e,t,n){var a=(e=e||{}).random||(e.rng||oS)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=a[o];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(rS[e[t+0]]+rS[e[t+1]]+rS[e[t+2]]+rS[e[t+3]]+"-"+rS[e[t+4]]+rS[e[t+5]]+"-"+rS[e[t+6]]+rS[e[t+7]]+"-"+rS[e[t+8]]+rS[e[t+9]]+"-"+rS[e[t+10]]+rS[e[t+11]]+rS[e[t+12]]+rS[e[t+13]]+rS[e[t+14]]+rS[e[t+15]]).toLowerCase();if(!sS(n))throw TypeError("Stringified UUID is invalid");return n}(a)},uS=["callback"],dS=["callback"],gS=["callback","profilePictureUrl"],pS=["callback"],yS=["callback"],fS=["callback"],SS=["callback"],hS=["callback"],vS=["callback"],mS=["callback"],bS=["callback"],AS=["callback","samlVendor"],wS=["callback"],TS=["callback"],ES=["callback","profileImage"],IS=["callback"],kS=["callback"],OS=["callback"],_S=["callback"],PS=["callback"],US=["callback"],LS=["callback"],DS=["callback"],RS=e=>"createdAt"!==e.id,CS={total:20,data:Array.from(Array(5).keys()).map((e=>j({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-e}:40.201`})))},NS={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}]},MS=(e,t,n)=>{const a=((e,t,n)=>{const a=uf(e,t,n),o=mf(a,["setAuditLogsState","resetAuditLogsState"]);return o.loadAuditLogs=async t=>{o.setAuditLogsState({loading:!t.silentLoading,error:null});const a=e.auditLogs.auditLogsState,{columns:i}=e.auditLogs.auditsMetadataState;try{var s,r,l,c,u;const e=null!=(s=t.pageSize)?s:a.pageSize,d=null!=(r=t.pageOffset)?r:a.pageOffset,g=null!=(l=t.filter)?l:a.filter,p=null!=(c=t.sort)?c:a.sort;o.setAuditLogsState({pageSize:e,pageOffset:d,filter:g,sort:p}),i||await n.loadAuditsMetadata();const{data:y,total:f}=((e,t)=>{const{data:n}=CS;let a=n.filter((e=>t=>e.filter(RS).every((e=>t[e.id].includes(e.value))))(e));if(t.length){const{id:e,desc:n=!1}=t[0];a=a.sort(((e,t)=>(n,a)=>n[e]>a[e]?t?-1:1:a[e]>n[e]?t?1:-1:0)(e,n))}return{data:a,total:a.length}})(g,p);o.setAuditLogsState({loading:!1,logs:null!=y?y:[],totalPages:+Math.ceil(f/e)}),null==t||null==(u=t.callback)||u.call(t,!0)}catch(e){var d;o.setAuditLogsState({loading:!1,error:Gc(e)}),null==t||null==(d=t.callback)||d.call(t,null,e)}},o})(e,t,n),o=((e,t,n)=>{const a=pf(e,t),o=mf(a,["setAuditsMetadataState","resetAuditsMetadataState"]);return o.loadAuditsMetadata=async()=>{o.setAuditsMetadataState({loading:!0,error:null});try{const{properties:e}=NS;o.setAuditsMetadataState({columns:e,loading:!1})}catch(e){o.setAuditsMetadataState({error:e,loading:!1})}},o})(e,t);return j({},a,o)},FS={id:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",externalId:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",startDate:"2021-09-20T08:08:51.000Z",status:Or.ACTIVE,externallyManaged:!1,cancellation:null,currentPeriodStart:"2021-09-20T08:08:51.000Z",currentPeriodEnd:"2021-10-20T08:08:51.000Z",plan:{slug:"test"}},$S=[{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"}],jS=[{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:""}],GS=[{id:"id",externalId:"externalId",type:_r.CARD,isDefault:!0,last4:"4242",expMonth:11,expYear:25,brand:"visa",billingDetails:{name:"Dummy",email:"dummy@email.com"}}],xS={allowPlanDowngrade:!0,allowPlanCancellation:!0},VS=(e,t,n)=>{const a=((e,t,n)=>{const a=_y(e,t),o=mf(a,["setPaymentConfigState","resetPaymentConfigState"]);return o.loadPaymentConfiguration=async()=>{o.setPaymentConfigState({loading:!0}),await Ql(500),o.setPaymentConfigState({loading:!1,fetching:!1,config:{paymentProvider:Iy.STRIPE,apiKey:""}})},o})(e,t),[o,i]=((e,t,n)=>{const a=((e,t,n)=>{const a=Ry(e,t,n),o=mf(a,["setBillingInformationState","resetBillingInformationState"]);return o.loadBillingInformation=async()=>{var e,t;o.setBillingInformationState({loading:!0}),await Ql(500),o.setBillingInformationState({loading:!1,fetching:!1,summary:{subscriptionId:FS.id,paymentMethodId:"mockPaymentMethodId",tenantConfigurationId:"mockTenantConfigurationId",providerType:Ur.Stripe,externallyManaged:!1,currentPlanId:$S[0].id,defaultPlanId:$S[0].id},plan:j({},$S[0],{price:null==(e=$S[0].price)?void 0:e.amount,currency:null==(t=$S[0].price)?void 0:t.currency,recurringInterval:"month"})})},o})(e,t,n),o=((e,t,n)=>{const a=jy(e,t),o=mf(a,["setBillingPaymentMethodState","resetBillingPaymentMethodState"]);return o.loadPaymentMethod=async()=>{o.setBillingPaymentMethodState({loading:!0}),await Ql(500),o.setBillingPaymentMethodState({paymentMethod:GS[0],loading:!1,fetching:!1})},o})(e,t),i=((e,t,n)=>{const a=My(e,t),o=mf(a,["setBillingInvoiceState","resetBillingInvoiceState"]);return o.loadBillingInvoices=async()=>{o.setBillingInvoiceState({loading:!0}),await Ql(500),o.setBillingInvoiceState({loading:!1,fetching:!1,invoices:jS.map((e=>j({},e,{selectedPlan:"Premium",paymentDate:new Date(Date.parse(e.paymentDate)),totalAmount:+((e.totalAmount||0)/100).toFixed(2)})))})},o.loadInvoices=o.loadBillingInvoices,o})(e,t),s=((e,t,n)=>{const a=Vy(e,t,n),o=mf(a,["setBillingSubscriptionState","resetBillingSubscriptionState","setCancellationLoading","setCancellationError","setRenewalLoading","setRenewalError"]);return o.loadSubscription=async()=>{o.setBillingSubscriptionState({loading:!0}),await Ql(500),o.setBillingSubscriptionState({subscription:FS,fetching:!1,loading:!1,error:null})},o})(e,t,n);return[j({},a,o,i,s),{information:a,invoices:i,paymentMethod:o,subscription:s}]})(e,t,n),s=((e,t,n)=>{const a=Ky(e,t),o=mf(a,["setPlansState","resetPlansState"]);return o.loadPlans=async()=>{o.setPlansState({loading:!0}),await Ql(500),o.setPlansState({fetching:!1,loading:!1,plans:$S.map((e=>{var t,n;return j({},e,{price:(null==(t=e.price)?void 0:t.amount)||0,currency:(null==(n=e.price)?void 0:n.currency)||"usd",recurringInterval:"month"})}))})},o})(e,t),r=((e,t,n)=>{const a=Jy(e,t,n);return mf(a,["setCheckoutState","resetCheckoutState","errorCheckout","resetCheckout"])})(e,t,n),l=((e,t,n)=>{const a=Qy(e,t);return mf(a,[])})(e,t),c=((e,t,n)=>{const a=tf(e,t),o=mf(a,["setVendorPublicConfigState","resetVendorPublicConfigState","setVendorPublicConfigError","setVendorPublicConfigLoading"]);return o.loadVendorPublicConfiguration=async()=>{o.setVendorPublicConfigLoading(!0),await Ql(),o.setVendorPublicConfigState({fetching:!1,loading:!1,vendorPublicConfig:xS})},o})(e,t);return[j({},a,o,s,r,l,c),{config:a,billing:i,plans:s,checkout:r,stripe:l,vendorPublicConfig:c}]},BS=(e,t,n)=>{const{authActions:a,authStateActions:o}=((e,t,n)=>{const a=((e,t,n)=>{const a=xc(e,t);return mf(a,["setAcceptInvitationState","resetAcceptInvitationState"])})(e,t),o=((e,t,n)=>{const a=Wc(e,t),o=mf(a,["setAccountSettingsState","resetAccountSettingsState"]);return o.saveAccountSettings=async t=>{var n;o.setAccountSettingsState({loading:!0}),await Ql();const a=e.auth.accountSettingsState,{address:i,timezone:s,dateFormat:r,timeFormat:l,currency:c,logo:u}=a,d=j({address:i,timezone:s,dateFormat:r,timeFormat:l,currency:c,logo:u},t);o.setAccountSettingsState(j({},d,{loading:!1})),null==(n=t.callback)||n.call(t,d)},o.loadAccountSettings=async e=>{o.setAccountSettingsState({loading:!(null!=e&&e.silentLoading),error:null}),await Ql(),o.setAccountSettingsState(j({address:"Tel-aviv",timezone:"Asia/Jerusalem",dateFormat:"DD/MM/YYYY",timeFormat:"HH:mm",currency:"USD",loading:!1},e))},o})(e,t),i=((e,t,n)=>{const a=Pu(e,t,n);return mf(a,["setActivateState","resetActivateState","setActivateStrategyState"])})(e,t,n),s=((e,t,n)=>{const a=hg(e,t,n);return mf(a,["setAllAccountsLoader","setAllAccountsError","setAllAccountsState","setSelectedAccountState","resetAllAccountsState","clearSelectedAccount"])})(e,t,n),r=bg(e),l=((e,t,n)=>{const a=Du(e,t),o=mf(a,["setApiTokensState","resetApiTokensState","setApiTokensLoader","setApiTokensError"]);return o.addTenantApiToken=async t=>{const{description:n,roleIds:a,callback:i}=t;o.setApiTokensLoader({key:oc.ADD_API_TOKEN,value:!0});const{apiTokensDataTenant:s}=e.auth.apiTokensState,r=j({},Af,{description:n,roleIds:a,clientId:`CLIENT_ID_${cS()}`});o.setApiTokensState({showAddTokenDialog:!1}),await Ql(200),o.setApiTokensState({apiTokensDataTenant:[...s,r],successDialog:{open:!0,secret:r.secret,clientId:r.clientId}}),await Ql(200),o.setApiTokensLoader({key:oc.ADD_API_TOKEN,value:!1}),null==i||i(null)},o.deleteTenantApiToken=async e=>{o.setApiTokensLoader({key:oc.DELETE_API_TOKEN,value:!0}),await Ql(200);const t=[Af];o.setApiTokensState({apiTokensDataTenant:t.filter((t=>t.clientId!==e)),deleteTokenDialog:{open:!1,clientId:e}}),o.setApiTokensLoader({key:oc.DELETE_API_TOKEN,value:!1})},o.loadApiTokens=async e=>{var t;null!=e&&e.silentLoading||o.setApiTokensLoader({key:oc.LOAD_API_TOKENS,value:!0});const n=[bf],a=[Af];o.setApiTokensState({apiTokensDataUser:n,apiTokensDataTenant:a}),await Ql(200),o.setApiTokensLoader({key:oc.LOAD_API_TOKENS,value:!1}),null==e||null==(t=e.callback)||t.call(e,!0)},o.loadUserApiTokens=async e=>{var t;null!=e&&e.silentLoading||o.setApiTokensLoader({key:oc.LOAD_API_TOKENS,value:!0});const n=[bf];o.setApiTokensState({apiTokensDataUser:n}),await Ql(200),o.setApiTokensLoader({key:oc.LOAD_API_TOKENS,value:!1}),null==e||null==(t=e.callback)||t.call(e,!0)},o.loadTenantApiTokens=async e=>{var t;null!=e&&e.silentLoading||o.setApiTokensLoader({key:oc.LOAD_API_TOKENS,value:!0});const n=[Af];o.setApiTokensState({apiTokensDataTenant:n}),await Ql(200),o.setApiTokensLoader({key:oc.LOAD_API_TOKENS,value:!1}),null==e||null==(t=e.callback)||t.call(e,!0)},o})(e,t),c=((e,t,n)=>{const a=Mu(e,t,n);return mf(a,["setApplicationsState","resetApplicationsState"])})(e,t,n),u=((e,t,n)=>{const a=Gu(e,t,n),o=mf(a,["setCustomLoginState","resetCustomLoginState"]);return o.loadTenantMetadata=async()=>{o.setCustomLoginState({loading:!0}),await Ql(),o.setCustomLoginState({loading:!1})},o.updateTenantMetadata=async e=>{const{callback:t}=e;o.setCustomLoginState({loading:!0,error:null}),await Ql(),o.setCustomLoginState({loading:!1,error:null}),null==t||t(!0)},o})(e,t,n),d=((e,t,n)=>{const a=dy(e,t);return mf(a,["setEntitlements","handleFetchedEntitlements"])})(e,t),g=((e,t,n)=>{const a=Wu(e,t),o=mf(a,["setForgotPasswordState","resetForgotPasswordState"]);return o.loadPasswordConfig=async e=>{o.setForgotPasswordState({loading:!0});try{o.setForgotPasswordState({loading:!1,passwordConfig:{allowPassphrases:!0,maxLength:128,minLength:6,minPhraseLength:6,minOptionalTestsToPass:1}})}catch(e){o.setForgotPasswordState({loading:!1,error:Gc(e)})}},o})(e,t),p=((e,t,n)=>{const a=qu(e,t),o=mf(a,["setGroupsState","resetUsersGroupsState","setUsersGroupsLoader","setUsersGroupsError"]);return o.loadGroups=async()=>{const e=yc.GET_GROUPS;o.setUsersGroupsLoader({key:e,value:!0});const t=Yf;o.setGroupsState({groups:t}),o.setUsersGroupsLoader({key:e,value:!1})},o.createGroup=async t=>{var n;const a=yc.CREATE_GROUP,{groups:i}=e.auth.groupsState;o.setUsersGroupsLoader({key:a,value:!0}),await Ql(500),o.setGroupsState({groups:[j({},t,{id:`${t.name}ID`,managedBy:jl.FRONTEGG}),...null!=i?i:[]]}),null==t||null==(n=t.callback)||n.call(t,!0),o.setUsersGroupsLoader({key:a,value:!1})},o.updateGroup=async t=>{var n,a,i,s,r;const l=yc.UPDATE_GROUP,c=e.auth.groupsState;o.setUsersGroupsLoader({key:l,value:!0}),await Ql(500),o.setGroupsState({groups:null==c||null==(n=c.groups)?void 0:n.map((e=>{var n;return e.id===t.groupId?j({},t,{id:t.groupId,name:null!=(n=null==t?void 0:t.name)?n:"",managedBy:jl.FRONTEGG}):e})),selectedGroup:j({},null==c?void 0:c.selectedGroup,{name:null!=(a=null==t?void 0:t.name)?a:"",color:null!=(i=null==t?void 0:t.color)?i:"",description:null!=(s=null==t?void 0:t.description)?s:""})}),null==t||null==(r=t.callback)||r.call(t,!0),o.setUsersGroupsLoader({key:l,value:!1})},o.deleteGroup=async t=>{var n,a;const i=yc.DELETE_GROUP,s=e.auth.groupsState;o.setUsersGroupsLoader({key:i,value:!0}),await Ql(500),o.setGroupsState({groups:null==s||null==(n=s.groups)?void 0:n.filter((e=>e.id!==t.groupId))}),null==t||null==(a=t.callback)||a.call(t,!0),o.setUsersGroupsLoader({key:i,value:!1})},o.addRolesToGroup=async t=>{var n,a;const i=yc.ADD_ROLES_TO_GROUP,s=e.auth.groupsState;o.setUsersGroupsLoader({key:i,value:!0}),await Ql(500),o.setGroupsState({groups:null==s||null==(n=s.groups)?void 0:n.map((e=>{var n;return e.id===t.groupId?j({},e,{roles:[...null!=(n=null==e?void 0:e.roles)?n:[],...t.roleIds.map((e=>({id:e,name:e})))]}):e}))}),null==t||null==(a=t.callback)||a.call(t,!0),o.setUsersGroupsLoader({key:i,value:!1})},o.deleteRolesFromGroup=async t=>{var n,a;const i=yc.DELETE_ROLES_FROM_GROUP,s=e.auth.groupsState;o.setUsersGroupsLoader({key:i,value:!0}),await Ql(500),o.setGroupsState({groups:null==s||null==(n=s.groups)?void 0:n.map((e=>{var n;return e.id===t.groupId?j({},e,{roles:null==e||null==(n=e.roles)?void 0:n.filter((e=>!t.roleIds.includes(e.id)))}):e}))}),null==t||null==(a=t.callback)||a.call(t,!0),o.setUsersGroupsLoader({key:i,value:!1})},o.addUsersToGroup=async t=>{var n,a;const i=yc.ADD_USERS_TO_GROUP,s=e.auth.groupsState;o.setUsersGroupsLoader({key:i,value:!0}),await Ql(500),o.setGroupsState({groups:null==s||null==(n=s.groups)?void 0:n.map((e=>{var n;return e.id===t.groupId?j({},e,{users:[...null!=(n=null==e?void 0:e.users)?n:[],...t.userIds.map((e=>({id:e,name:e})))]}):e}))}),null==t||null==(a=t.callback)||a.call(t,!0),o.setUsersGroupsLoader({key:i,value:!1})},o.deleteUsersFromGroup=async t=>{var n,a;const i=yc.DELETE_USERS_FROM_GROUP,s=e.auth.groupsState;o.setUsersGroupsLoader({key:i,value:!0}),await Ql(500),o.setGroupsState({groups:null==s||null==(n=s.groups)?void 0:n.map((e=>{var n;return e.id===t.groupId?j({},e,{users:null==e||null==(n=e.users)?void 0:n.filter((e=>!t.userIds.includes(e.id)))}):e}))}),null==t||null==(a=t.callback)||a.call(t,!0),o.setUsersGroupsLoader({key:i,value:!1})},o.getGroupConfiguration=async()=>{const t=yc.GET_GROUP_CONFIGURATION,{groupsConfiguration:n}=e.auth.groupsState;o.setUsersGroupsLoader({key:t,value:!0}),n&&o.setGroupsState({groupsConfiguration:j({},n)}),o.setUsersGroupsLoader({key:t,value:!1})},o.updateGroupConfiguration=async t=>{const n=yc.UPDATE_GROUP_CONFIGURATION,{groupsConfiguration:a}=e.auth.groupsState;o.setUsersGroupsLoader({key:n,value:!0}),a&&o.setGroupsState({groupsConfiguration:j({},a,t)}),o.setUsersGroupsLoader({key:n,value:!1})},o})(e,t),y=Xu(e),f=((e,t,n)=>{const a=td(e,t,n);return mf(a,["setImpersonateState","resetImpersonateState"])})(e,t,n),S=((e,t,n)=>{const a=n,o=eg(e,t,a),i=mf(o,["setLoginState","resetLoginState","afterAuthNavigation"]);return i.requestAuthorize=async e=>{e&&a.setAuthState({isLoading:!0});const t=Ef;await a.loadTenants(),a.setAuthState({user:t,isAuthenticated:!0,isLoading:!1})},i.getUserIP=async e=>{const{callback:t}=e;try{const{ip:e}=Hf[0];await a.setAuthState({userIp:e}),null==t||t(!0,e)}catch(e){null==t||t(!1,e)}},i})(e,t,n),h=((e,t,n)=>{const a=n,o=cg(e,t,a),i=mf(o,["setMfaState","resetMfaState"]);return i.enrollMfa=async()=>{i.setMfaState({saving:!0}),i.setMfaState({saving:!1,error:void 0,qrCode:"test"})},i.verifyMfa=async t=>{const{callback:n}=t,{mfaDevices:o={webauthn:[],phones:[],authenticators:[],emails:[]}}=(oe(t,uS),e.auth.mfaState);i.setMfaState({saving:!0}),await Ql();const s={token:"token",recoveryCode:"recoveryCode"},r={step:Ac.recoveryCode,loading:!1,error:void 0,saving:!1,mfaDevices:j({},o,{authenticators:[{id:"authenticator-id"}]})};null!=s&&s.recoveryCode&&(r.recoveryCode=s.recoveryCode),i.setMfaState(r),a.setUser(j({},Ef,{mfaEnrolled:!0})),null==n||n(r.recoveryCode)},i.disableMfa=async t=>{var n;const{mfaDevices:o={webauthn:[],phones:[],authenticators:[],emails:[]}}=e.auth.mfaState;i.setMfaState({saving:!0}),await Ql(),i.setMfaState({saving:!1,error:void 0,mfaDevices:j({},o,{authenticators:[]})}),a.setUser(j({},Ef)),null==(n=t.callback)||n.call(t,!0)},i.verifyMfaAfterForce=async e=>{const{callback:t}=e,n=oe(e,dS);i.setMfaState({loading:!0}),await Ql();const o=j({},n,{recoveryCode:"recoveryCode"}),s={step:Ac.recoveryCode,loading:!1,error:void 0,saving:!1};null!=o&&o.recoveryCode&&(s.recoveryCode=o.recoveryCode),i.setMfaState(s),await Ql(),a.setUser(j({},Ef,{mfaEnrolled:!0})),null==t||t(s.recoveryCode)},i.preDisableMfaSms=async e=>{i.setMfaState({saving:!0});try{var t;i.setMfaState({saving:!1,error:void 0,otcToken:"otc-token",phoneNumber:"+972504589346"}),null==(t=e.callback)||t.call(e,!0)}catch(t){var n;i.setMfaState({saving:!1,error:Gc(t)}),null==(n=e.callback)||n.call(e,!1,t)}},i.disableMfaSms=async t=>{var n;const{mfaDevices:o={webauthn:[],phones:[],authenticators:[],emails:[]}}=e.auth.mfaState;i.setMfaState({saving:!0}),await Ql(),i.setMfaState({loading:!1,error:void 0,mfaDevices:j({},o,{phones:[]})}),a.setUser(j({},Ef)),null==(n=t.callback)||n.call(t,!0)},i.preEnrollMfaSms=async e=>{var t;i.setMfaState({saving:!0}),await Ql(),i.setMfaState({saving:!1,error:void 0,otcToken:"otc-token",phoneNumber:"+972504589346"}),null==(t=e.callback)||t.call(e,!0)},i.enrollMfaSms=async t=>{const{callback:n}=t,{mfaDevices:o={webauthn:[],phones:[],authenticators:[],emails:[]}}=e.auth.mfaState;i.setMfaState({saving:!0}),await Ql();const s={token:"token",recoveryCode:"recoveryCode"},r={step:Ac.recoveryCode,loading:!1,error:void 0,saving:!1,mfaDevices:j({},o,{phones:[{id:"phone-id",phoneNumber:"+972504589346"}]})};null!=s&&s.recoveryCode&&(r.recoveryCode=s.recoveryCode),i.setMfaState(r),a.setUser(j({},Ef,{mfaEnrolled:!0})),null==n||n(r.recoveryCode)},i})(e,t,n),v=((e,t,n)=>{const a=Tg(e,t,n);return mf(a,["setPasskeysState","resetPasskeysState"])})(e,t,n),m=((e,t,n)=>{const a=Og(e,t,n),o=mf(a,["setProfileState","resetProfileState"]);return o.loadProfile=async()=>{o.setProfileState({loading:!0}),await Ql(),n.setUser(j({},Ef,Tf)),o.setProfileState({loading:!1,profile:Tf})},o.saveProfile=async e=>{const{callback:t,profilePictureUrl:a}=e,i=oe(e,gS);o.setProfileState({saving:!0,error:null});const s=If;let r=s.profile.profilePictureUrl;a!==s.profile.profilePictureUrl&&a&&(a||"").match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/)&&(r=a);const l=j({},s.profile,i,{profilePictureUrl:r}),c=Ef;await Ql(),n.setUser(j({},c,l)),o.setProfileState({loading:!1,error:null,saving:!1,profile:l}),null==t||t(l)},o.changePassword=async e=>{var t;o.setProfileState({loading:!0}),await Ql(),o.setProfileState({loading:!1,error:void 0}),null==(t=e.callback)||t.call(e,!0)},o})(e,t,n),b=((e,t,n)=>{const a=Dg(e,t);return mf(a,["setProvisioningState","resetProvisioningState"])})(e,t),A=((e,t,n)=>{const a=$g(e,t,n);return mf(a,["setResetPhoneNumberState","resetResetPhoneNumberState"])})(e,t,n),w=((e,t,n)=>{const a=ep(e,t,n),o=mf(a,["setRestrictionsState","setIpRestrictionsState","setEmailDomainRestrictionsState"]);return o.loadIpRestrictions=async()=>{o.setIpRestrictionsState({loading:!0,error:null}),o.setIpRestrictionsState({data:{restrictions:Hf.filter((e=>e.strategy===Kf.strategy)),config:Kf},totalPages:1,pagination:{_filter:pn.ALLOW,_limit:50,_offset:0},loading:!1})},o.loadEmailDomainRestrictions=async()=>{o.setEmailDomainRestrictionsState({loading:!0,error:null}),o.setEmailDomainRestrictionsState({loading:!1,data:{restrictions:[{domain:"mock.com",id:"1",type:pn.ALLOW}],config:{active:!0,listType:pn.ALLOW,blockPublicDomains:!1}}})},o.saveIpRestriction=async t=>{var n,a,i;const{callback:s}=t,r=oe(t,pS);o.setIpRestrictionsState({saving:!0,error:null});const l=e.auth.restrictionsState.ipRestrictions,c=l.data.restrictions.filter((e=>e.ip!==r.ip));o.setIpRestrictionsState({data:{config:null!=(n=null==(a=l.data)?void 0:a.config)?n:{isActive:!1,strategy:pn.ALLOW},restrictions:[...c,j({},r,{createdAt:new Date,updatedAt:new Date,id:cS(),isActive:null==(i=r.isActive)||i,strategy:l.data.config.strategy})]},totalPages:1,pagination:{_filter:pn.ALLOW,_limit:50,_offset:0},saving:!1}),null==s||s(!0)},o.saveIpRestrictionsConfig=async t=>{var n,a,i;const{callback:s}=t,r=oe(t,yS),l=e.auth.restrictionsState.ipRestrictions;o.setIpRestrictionsState({saving:!0,error:null}),o.setIpRestrictionsState({data:{config:j({},null==(n=l.data)?void 0:n.config,r),restrictions:null!=(a=null==(i=l.data)?void 0:i.restrictions)?a:[]},pagination:{_filter:pn.ALLOW,_limit:50,_offset:0},totalPages:1,saving:!1}),o.setIpRestrictionsState({saving:!1,error:null}),null==s||s(!0)},o.deleteIpRestriction=async t=>{var n;const{callback:a,id:i}=t;o.setIpRestrictionsState({saving:!0,error:null});const s=e.auth.restrictionsState.ipRestrictions;o.setIpRestrictionsState({data:{config:(null==(n=s.data)?void 0:n.config)||{isActive:!1,strategy:pn.ALLOW},restrictions:s.data.restrictions.filter((e=>e.id!==i))},pagination:{_filter:pn.ALLOW,_limit:50,_offset:0},totalPages:1,saving:!1,error:null}),null==a||a(!0)},o.checkIfUserIpValid=async()=>{o.setIpRestrictionsState({loading:!0,error:null});try{const t=e.auth.restrictionsState.ipRestrictions,n=Hf[0].ip,a=!!t.data.restrictions.find((e=>e.isActive&&e.ip===n));o.setIpRestrictionsState({userIpValid:a,loading:!1})}catch(e){o.setIpRestrictionsState({error:Gc(e),loading:!1})}},o.saveEmailDomainRestriction=async t=>{var n,a;const{callback:i}=t,s=oe(t,fS),r=e.auth.restrictionsState.emailDomainRestrictions;o.setEmailDomainRestrictionsState({saving:!0,error:null}),await Ql(),null==i||i(!0),o.setEmailDomainRestrictionsState({data:{config:(null==(n=r.data)?void 0:n.config)||{active:!1,blockPublicDomains:!1,listType:s.type},restrictions:[...(null==(a=r.data)?void 0:a.restrictions)||[],j({},s,{id:Date.now().toString()})]},saving:!1})},o.saveEmailDomainRestrictionsConfig=async t=>{var n;const{callback:a}=t,i=oe(t,SS),s=e.auth.restrictionsState.emailDomainRestrictions;o.setEmailDomainRestrictionsState({saving:!0,error:null}),await Ql(),null==a||a(!0),o.setEmailDomainRestrictionsState({data:{config:{active:i.active,blockPublicDomains:i.blockPublicDomains||!1,listType:i.type||pn.ALLOW},restrictions:[...(null==(n=s.data)?void 0:n.restrictions)||[]]},saving:!1})},o.deleteEmailDomainRestriction=async t=>{var n,a;const{id:i}=t,s=e.auth.restrictionsState.emailDomainRestrictions;o.setEmailDomainRestrictionsState({saving:!0,error:null}),await Ql(),o.setEmailDomainRestrictionsState({data:{config:(null==(n=s.data)?void 0:n.config)||{active:!1,blockPublicDomains:!1,listType:pn.ALLOW},restrictions:((null==(a=s.data)?void 0:a.restrictions)||[]).filter((e=>e.id===i))},saving:!1})},o})(e,t,n),T=((e,t,n)=>{const a=Hg(e,t),o=mf(a,["setRolesState","setRolesStateError","setRolesStateLoader","resetRolesState"]);return o.loadRolesAndPermissions=async e=>{var t;const n=Ec.LOAD_ROLES;o.setRolesStateLoader({key:n,value:!(null!=(t=null==e?void 0:e.silentLoading)&&t)});try{o.setRolesState({roles:wf})}catch(e){o.setRolesStateError({key:n,value:Gc(e)})}finally{o.setRolesStateLoader({key:n,value:!1})}},o})(e,t),E=((e,t,n)=>{const a=op(e,t,n),o=mf(a,["setSecurityCenterState","setSecurityCenterStateError","setSecurityCenterStateLoader","resetSecurityCenterState"]);return o.loadRecommendations=async()=>{const e=Ic.RECOMMENDATIONS;o.setSecurityCenterStateLoader({key:e,value:!0}),await Ql(),o.setSecurityCenterState({recommendations:Xf.recommendations.items,score:Xf.scoring.score}),o.setSecurityCenterStateLoader({key:e,value:!1})},o.loadInsights=async()=>{const e=Ic.INSIGHTS;o.setSecurityCenterStateLoader({key:e,value:!0}),await Ql(),o.setSecurityCenterState({insights:Qf.insights.items}),o.setSecurityCenterStateLoader({key:e,value:!1})},o.loadBreachedPasswordUsers=async()=>{const e=Ic.BREACHED_PASSWORD_USERS_TABLE;o.setSecurityCenterStateLoader({key:e,value:!0}),await Ql(),o.setSecurityCenterState({breachedPasswordUsersTable:Zf}),o.setSecurityCenterStateLoader({key:e,value:!1})},o.loadUnenrolledMfaUsers=async()=>{const e=Ic.UNENROLLED_MFA_USERS_TABLE;o.setSecurityCenterStateLoader({key:e,value:!0}),await Ql(),o.setSecurityCenterState({unenrolledMfaUsersTable:tS}),o.setSecurityCenterStateLoader({key:e,value:!1})},o.loadInactiveUsers=async()=>{const e=Ic.INACTIVE_USERS_TABLE;o.setSecurityCenterStateLoader({key:e,value:!0}),await Ql(),o.setSecurityCenterState({inactiveUsersTable:eS}),o.setSecurityCenterStateLoader({key:e,value:!1})},o.sendResetBreachedPasswordEmail=async e=>{const{callback:t}=e,n=Ic.SEND_BREACHED_PASSWORD_EMAIL;o.setSecurityCenterStateLoader({key:n,value:!0}),await Ql(),null==t||t(!0),o.setSecurityCenterStateLoader({key:n,value:!1})},o})(e,t,n),I=((e,t,n)=>{const a=up(e,t,n),o=mf(a,["setSecurityPolicyState","setSecurityPolicyGlobalState","setSecurityPolicyPublicState","setSecurityPolicyMfaState","setSecurityPolicyVendorMfaState","setSecurityPolicyLockoutState","setSecurityPolicyVendorLockoutState","setSecurityPolicyCaptchaState","setSecurityPolicyPasswordHistoryState","setSecurityPolicyVendorPasswordHistoryState","resetSecurityPolicyState","setSecurityPolicyPasswordState","setSecurityPolicyAuthStrategyPublicState"]);return o.loadSecurityPolicy=async()=>{o.setSecurityPolicyGlobalState({loading:!0,error:null}),await Promise.all([o.loadSecurityPolicyMfa(),o.loadSecurityPolicyVendorMfa(),o.loadSecurityPolicyLockout(),o.loadSecurityPolicyVendorLockout(),o.loadSecurityPolicyPasswordHistory(),o.loadSecurityPolicyVendorPasswordHistory(),o.loadSecurityPolicyCaptcha()]),await Ql(),o.setSecurityPolicyGlobalState({policy:kf,loading:!1})},o.loadPublicSecurityPolicy=async()=>{o.setSecurityPolicyPublicState({loading:!0,error:null});try{o.setSecurityPolicyPublicState({policy:Of,loading:!1})}catch(e){o.setSecurityPolicyPublicState({error:Gc(e),loading:!1})}},o.saveSecurityPolicyMfa=async e=>{var t;const{callback:n}=e,a=oe(e,hS);o.setSecurityPolicyMfaState({saving:!0,error:null});const i=j({},Pf,{id:null!=(t=a.id)?t:Pf.id,enforceMFAType:a.enforceMFAType});await Ql(),o.setSecurityPolicyMfaState({policy:i,saving:!1}),null==n||n(i)},o.loadSecurityPolicyMfa=async()=>{o.setSecurityPolicyMfaState({loading:!0,error:null}),await Ql(),o.setSecurityPolicyMfaState({policy:_f,loading:!1})},o.loadSecurityPolicyVendorMfa=async()=>{o.setSecurityPolicyVendorMfaState({loading:!0,error:null}),await Ql(),o.setSecurityPolicyVendorMfaState({policy:_f,loading:!1})},o.saveSecurityPolicyLockout=async e=>{const{callback:t}=e,n=oe(e,vS);o.setSecurityPolicyLockoutState({saving:!0,error:null}),await Ql();const a=j({},Pf,n,{id:n.id?n.id:Pf.id});null==t||t(a),o.setSecurityPolicyLockoutState({policy:a,saving:!1})},o.loadSecurityPolicyLockout=async()=>{o.setSecurityPolicyLockoutState({loading:!0,error:null}),await Ql(),o.setSecurityPolicyLockoutState({policy:Pf,loading:!1})},o.loadSecurityPolicyVendorLockout=async()=>{o.setSecurityPolicyVendorLockoutState({loading:!0,error:null}),await Ql(),o.setSecurityPolicyVendorLockoutState({policy:Pf,loading:!1})},o.loadSecurityPolicyCaptcha=async()=>{o.setSecurityPolicyLockoutState({loading:!0,error:null}),await Ql(),o.setSecurityPolicyLockoutState({policy:Pf,loading:!1})},o.saveSecurityPolicyPasswordHistory=async e=>{const{callback:t}=e,n=oe(e,mS);o.setSecurityPolicyPasswordHistoryState({saving:!0,error:null}),await Ql();const a=j({},Uf,n,{id:n.id?n.id:Uf.id});null==t||t(a),o.setSecurityPolicyPasswordHistoryState({policy:a,saving:!1})},o.loadSecurityPolicyPasswordHistory=async()=>{o.setSecurityPolicyPasswordHistoryState({loading:!0,error:null}),await Ql(),o.setSecurityPolicyPasswordHistoryState({policy:Uf,loading:!1})},o.loadSecurityPolicyVendorPasswordHistory=async()=>{o.setSecurityPolicyVendorPasswordHistoryState({loading:!0,error:null}),await Ql(),o.setSecurityPolicyVendorPasswordHistoryState({policy:Uf,loading:!1})},o})(e,t,n),k=((e,t,n)=>{const a=hp(e,t),o=mf(a,["setSessionsState","resetSessionsState"]);return o.loadUserSessions=async()=>{o.setSessionsState({loading:!0,error:null}),o.setSessionsState({sessions:zf,loading:!1})},o.deleteUserSession=async t=>{const{id:n}=t;o.setSessionsState({loading:!0,error:null});const a=e.auth.sessionsState.sessions.filter((e=>e.id!==n));o.setSessionsState({sessions:a,loading:!1})},o.deleteAllUserSessions=async()=>{o.setSessionsState({loading:!0,error:null});const e=zf.filter((e=>e.current));o.setSessionsState({sessions:e,loading:!1})},o})(e,t),O=((e,t,n)=>{const a=yp(e,t,n),o=mf(a,["setSessionsPolicyState","resetSessionsPolicyState"]);return o.loadSessionsPolicy=async()=>{o.setSessionsPolicyState({loading:!0,error:null});const t=e.auth.sessionsPolicyState;o.setSessionsPolicyState(j({},t,{loading:!1}))},o.createOrUpdateSessionsPolicy=async e=>{const{callback:t}=e,n=oe(e,bS);o.setSessionsPolicyState({loading:!0,error:null}),null==t||t(!0),o.setSessionsPolicyState({configurations:n,loading:!1})},o})(e,t,n),_=((e,t,n)=>{const a=Ap(e,t,n);return mf(a,["setSignUpState","resetSignUpState","resetSignUpStateSoft"])})(e,t,n),P=((e,t,n)=>{const a=Pp(e,t);return mf(a,["setSmsState","resetSmsState"])})(e,t),U=((e,t,n)=>{const a=Cp(e,t,n);return mf(a,["setSocialLoginsState","resetSocialLoginsState","setSocialLoginError"])})(e,t,n),L=((e,t,n)=>{const a=Vp(e,t,n),o=mf(a,["setSSOState","resetSSOState"]);return o.loadSSOConfigurations=async()=>{o.setSSOState({loading:!0}),await Ql(),o.setSSOState({samlConfiguration:Lf,loading:!1,firstLoad:!1})},o.saveSSOConfigurations=async e=>{var t,n;const{callback:a,samlVendor:i}=e,s=oe(e,AS),r=Cf.samlConfiguration,l=j({},r,s);let c="saving";if((null==l?void 0:l.enabled)!==r.enabled&&(c="loading"),null==l||!l.domain)return void o.setSSOState({samlConfiguration:j({},r,l)});o.setSSOState({error:void 0,[c]:!0}),await Ql(),l.acsUrl=null==Df||null==(t=Df.configuration)?void 0:t.acsUrl,l.spEntityId=null==Df||null==(n=Df.configuration)?void 0:n.spEntityId;const u=ec(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 Ql(),o.setSSOState({samlConfiguration:u,error:void 0,[c]:!1}),null==a||a(!0)},o.saveSSOConfigurationsFile=async t=>{const n="saving";o.setSSOState({error:void 0,[n]:!0});const a=j({},e.auth.ssoState.samlConfiguration,{enabled:!0},t[0]);o.setSSOState({samlConfiguration:a,error:void 0,[n]:!1})},o.validateSSODomain=async e=>{const{callback:t}=null!=e?e:{},n=Cf.samlConfiguration;o.setSSOState({error:void 0,saving:!0}),await Ql(),o.setSSOState({samlConfiguration:j({},n,{validated:!0}),error:void 0,saving:!1}),null==t||t(!0)},o.loadSSOAuthorizationRoles=async()=>{await Ql(),o.setSSOState({authorizationRoles:["1","2","3"],error:void 0})},o.updateSSOAuthorizationRoles=async e=>{const{callback:t,authorizationRoles:n}=e;o.setSSOState({error:void 0,saving:!0}),await Ql(),o.setSSOState({authorizationRoles:n,error:void 0,saving:!1}),null==t||t(!0)},o})(e,t,n),D=((e,t,n)=>{const a=zp(e,t,n);return mf(a,["setStepUpState","resetStepUpState"])})(e,t,n),R=((e,t,n)=>{const a=ry(e,t,n),o=mf(a,["setTeamState","resetTeamState","setTeamLoader","setTeamError","openAddUserDialog","closeAddUserDialog","openDeleteUserDialog","closeDeleteUserDialog"]);return o.loadUsersV2=async t=>{var n,a,i,s;const{silentLoading:r,callback:l}=t,c=e.auth.teamState,u=null!=(n=t.pageSize)?n:c.pageSize,d=null!=(a=t.pageOffset)?a:c.pageOffset,g=null!=(i=t.filter)?i:c.filterV2,p=null!=(s=t.sort)?s:c.sortV2;o.setTeamLoader({key:Pc.USERS,value:!r}),o.setTeamState({pageSize:u,pageOffset:d,filterV2:g,sortV2:p}),await Ql(),o.setTeamState({users:xf,totalPages:2,totalItems:10,roles:Rf,permissions:Nf}),o.setTeamLoader({key:Pc.USERS,value:!1}),null==l||l(xf)},o.loadAllSubTenantsUsers=async t=>{var n,a,i,s,r;const{silentLoading:l,callback:c}=t,u=e.auth.teamState,d=null!=(n=t._limit)?n:u.allUsersQueryParams._limit,g=null!=(a=t._offset)?a:u.allUsersQueryParams._offset,p=null!=(i=t._filter)?i:u.allUsersQueryParams._filter,y=null!=(s=t._sortBy)?s:u.allUsersQueryParams._sortBy,f=null!=(r=t._order)?r:u.allUsersQueryParams._order;o.setTeamLoader({key:Pc.USERS,value:!l}),o.setTeamState({allUsersQueryParams:{_limit:d,_offset:g,_filter:p,_sortBy:y,_order:f}}),await Ql(),o.setTeamState({allUsers:Bf,totalPages:2,totalItems:10,roles:Rf,permissions:Nf}),o.setTeamLoader({key:Pc.USERS,value:!1}),null==c||c(Bf)},o.loadRoles=async e=>{var t;o.setTeamLoader({key:Pc.ROLES_AND_PERMISSIONS,value:!0}),await Ql(),o.setTeamState({roles:Rf,permissions:Nf}),o.setTeamLoader({key:Pc.ROLES_AND_PERMISSIONS,value:!0}),null==e||null==(t=e.callback)||t.call(e,{roles:Rf,permissions:Nf})},o.addUser=async t=>{const{callback:n}=t,a=oe(t,wS),i=e.auth.teamState;o.setTeamState({addUserDialogState:j({},i.addUserDialogState,{loading:!0})}),await Ql();const s=new Date,r=j({},$f,{groups:[]},a,{id:`${cS()}`,temporaryExpirationDate:a.expirationInSeconds?new Date(s.setSeconds(s.getSeconds()+a.expirationInSeconds)):void 0});null==n||n(r),o.setTeamState({users:[r,...i.users],addUserDialogState:{open:!1,loading:!1}})},o.addUserToSubTenants=async t=>{const{callback:n}=t,a=oe(t,TS),i=e.auth.teamState;o.setTeamState({addUserDialogState:j({},i.addUserDialogState,{loading:!0})}),await Ql();const s=j({},$f,a,{id:`${cS()}`});o.setTeamState({users:[s,...i.users],addUserDialogState:{open:!1,loading:!1}}),null==n||n(null)},o.updateUser=async t=>{var n;const{callback:a}=t,i=oe(t,ES),{id:s}=i,r=e.auth.teamState,l=r.users.find((e=>e.id===i.id));o.setTeamLoader({key:Pc.UPDATE_USER,value:s||""}),o.setTeamState({addUserDialogState:j({},r.addUserDialogState,{loading:!0})}),o.setTeamState({addUserDialogState:j({},r.addUserDialogState,{loading:!0}),users:r.users.map((e=>e.id===i.id?j({},e,i):e))}),l.roleIds.length>0&&0===(null==(n=i.roleIds)?void 0:n.length)&&(i.roleIds=[""]),await Ql();const c=j({},l,i);null==a||a(c),o.setTeamState({users:r.users.map((e=>e.id===c.id?j({},e,c,{createdAt:e.createdAt,customData:e.customData,lastLogin:e.lastLogin}):e))}),o.setTeamLoader({key:Pc.UPDATE_USER,value:!1})},o.deleteUser=async t=>{const{callback:n}=t,a=oe(t,IS),i=e.auth.teamState;o.setTeamState({deleteUserDialogState:j({},i.deleteUserDialogState,{loading:!0})}),await Ql(),null==n||n(!0),o.setTeamState({users:i.users.filter((e=>e.id!==a.userId)),deleteUserDialogState:{open:!1,loading:!1}})},o.updateUserExpirationTime=async t=>{const{callback:n}=t,a=oe(t,kS),i=e.auth.teamState;o.setTeamLoader({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:!0});const s=new Date;o.setTeamState({users:i.users.map((e=>e.id===a.userId?j({},e,{temporaryExpirationDate:a.expirationInSeconds?new Date(s.setSeconds(s.getSeconds()+a.expirationInSeconds)):void 0}):e))}),await Ql(),null==n||n(!0),o.setTeamLoader({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:!1})},o.setUserAsPermanent=async t=>{const{callback:n}=t,a=oe(t,OS),i=e.auth.teamState;o.setTeamLoader({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:!0}),o.setTeamState({users:i.users.map((e=>e.id===a.userId?j({},e,{temporaryExpirationDate:void 0}):e))}),await Ql(),null==n||n(!0),o.setTeamLoader({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:!1})},o.deleteUserFromSubTenants=async t=>{const{callback:n}=t,a=oe(t,_S),i=e.auth.teamState;o.setTeamState({deleteUserDialogState:j({},i.deleteUserDialogState,{loading:!0})}),await Ql(),null==n||n(!0),o.setTeamState({allUsers:i.allUsers.filter((e=>e.id!==a.userId)),deleteUserDialogState:{open:!1,loading:!1}})},o.resendActivationLink=async e=>{const{callback:t}=e,n=oe(e,PS);o.setTeamLoader({key:Pc.RESEND_ACTIVATE_LINK,value:n.userId}),await Ql(),null==t||t(!0),o.setTeamLoader({key:Pc.RESEND_ACTIVATE_LINK,value:!1})},o.resendInvitationLink=async e=>{const{callback:t}=e,n=oe(e,US);o.setTeamLoader({key:Pc.RESEND_INVITATION_LINK,value:n.email}),await Ql(),null==t||t(!0),o.setTeamLoader({key:Pc.RESEND_INVITATION_LINK,value:!1})},o.resendInvitationEmail=async e=>{const{callback:t}=e,n=oe(e,LS);o.setTeamLoader({key:Pc.RESEND_INVITATION_LINK,value:n.email}),await Ql(),null==t||t(!0),o.setTeamLoader({key:Pc.RESEND_INVITATION_LINK,value:!1})},o.resendInvitationLinkToAllSubTenants=async e=>{const{callback:t}=e,n=oe(e,DS);o.setTeamLoader({key:Pc.RESEND_INVITATION_LINK,value:n.email}),await Ql(),null==t||t(!0),o.setTeamLoader({key:Pc.RESEND_INVITATION_LINK,value:!1})},o})(e,t,n),C=((e,t,n)=>{const a=uy(e,t,n),o=mf(a,["setTenantsState","resetTenantsState"]);return o.loadTenants=async()=>{o.setTenantsState({loading:!0}),o.setTenantsState({tenants:Wf,activeTenant:Wf[0],loading:!1})},o})(e,t,n),N={acceptInvitationActions:a,accountSettingsActions:o,activateAccountActions:i,allAccountsActions:s,allAccountsDialogActions:r,apiTokensActions:l,applicationsActions:c,customLoginActions:u,entitlementsActions:d,forgotPasswordActions:g,groupsActions:p,groupsDialogsActions:y,impersonateActions:f,loginActions:S,mfaActions:h,passkeysActions:v,profileActions:m,provisioningActions:b,resetPhoneNumberActions:A,restrictionsActions:w,rolesActions:T,securityCenterActions:E,securityPolicyActions:I,sessionsActions:k,sessionsPolicyActions:O,signUpActions:_,smsActions:P,socialLoginActions:U,ssoActions:L,stepUpActions:D,teamActions:R,tenantsActions:C},M=t=>{Object.keys(t).forEach((n=>{tc(e.auth[n])?Object.assign(e.auth[n],t[n]):e.auth[n]=t[n]}))};return{authActions:j({setState:M,setAuthState:M,resetAuthState:()=>{},setUser:e=>{M({user:e})}},a,o,i,s,r,l,c,u,d,g,p,y,f,S,h,v,m,b,A,w,T,E,I,k,O,_,P,U,L,D,R,C),authStateActions:N}})(e,t,n),i=((e,t,n)=>{const a=Ay(e,t,n);return mf(a,["setConnectivityState","resetConnectivityState","initData","resetConnectivityState","cleanWebhookTestData","cleanWebhookLogsData","cleanWebhookTestMessage","cleanError","cleanSlackData"])})(e,t,n),[s,r]=VS(e,t,n),l=((e,t,n)=>{const a=rf(e,t,n),o=mf(a,["setVendorState","resetVendorState"]);return o.loadVendorPublicInfo=async()=>{try{o.setVendorState({whiteLabelMode:!1}),await Ql()}catch(e){console.error("failed to getVendorPublicInfo - ",e)}},o.loadVendorPublicConfiguration=o.loadVendorPublicInfo,o})(e,t,n);return{authActions:a,authStateActions:o,connectivityActions:i,subscriptionsActions:s,subscriptionsStateActions:r,vendorActions:l,auditsActions:MS(e,t,n)}},WS=(e,t,n=!1,a,o,i=!1,s="path")=>zS({name:e.appName,context:e.context,storeHolder:t,previewMode:n,builderMode:i,urlStrategy:s,initialState:{root:j({},e),auth:j({},null==o?void 0:o.auth,a),connectivity:j({},null==o?void 0:o.connectivity),subscriptions:j({},null==o?void 0:o.subscriptions),vendor:j({},null==o?void 0:o.vendor),auditLogs:j({},null==o?void 0:o.auditLogs),audits:j({},null==o?void 0:o.audits)}}),zS=e=>{var n,a,o,i,s,r,l;const{storeHolder:c}=e;let u=c;if("undefined"==typeof window&&null==c)throw Error("createFronteggStore(initState, storeHolder) failed, storeHolder must not be null in Server-Side rendering");if(u||(u=window),u.store)return u.store;const{context:d,previewMode:g=!1,builderMode:p=!1,urlStrategy:y="path"}=e;g||p||ne.setContext(d),void 0===d.requestCredentials&&(d.requestCredentials="include");const f=e.name||"Default",S=py(null==(n=e.initialState)?void 0:n.auth),h=Sy(null==(a=e.initialState)?void 0:a.connectivity),v=nf(null==(o=e.initialState)?void 0:o.subscriptions),m=sf(null==(i=e.initialState)?void 0:i.vendor),b=yf(null==(s=e.initialState)?void 0:s.auditLogs),A=(w=null==(r=e.initialState)?void 0:r.audits,Mc(vf,w));var w;const T=null==(l=e.initialState)?void 0:l.auth;T&&Object.keys(T).forEach((e=>{hf()(S,e,T[e],{merge:!0})}));const E=Xl(S),I=Mc({root:{appName:f,context:d,urlStrategy:y,previewMode:g},auth:S,connectivity:h,subscriptions:v,vendor:m,auditLogs:b,audits:A});!function(e,t){"string"==typeof t&&(console.warn("string name option is deprecated, use { name }. https://github.com/pmndrs/valtio/pull/400"),t={name:t});const{enabled:n,name:a="",...o}=t||{};let i;try{i=(null==n||n)&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!i)return void(n&&console.warn("[Warning] Please install/enable Redux devtools extension"));let s=!1;const r=i.connect({name:a,...o});X(e,(t=>{const n=t.filter((([e,t])=>t[0]!==te)).map((([e,t])=>`${e}:${t.map(String).join(".")}`)).join(", ");if(n)if(s)s=!1;else{const t=Object.assign({},Q(e));delete t[te],r.send({type:n,updatedAt:(new Date).toLocaleString()},t)}})),r.subscribe((t=>{var n,a,o,i,l,c;if("ACTION"===t.type&&t.payload)try{Object.assign(e,JSON.parse(t.payload))}catch(e){console.error("please dispatch a serializable value that JSON.parse() and proxy() support\n",e)}if("DISPATCH"===t.type&&t.state){if("JUMP_TO_ACTION"===(null==(n=t.payload)?void 0:n.type)||"JUMP_TO_STATE"===(null==(a=t.payload)?void 0:a.type)){s=!0;const n=JSON.parse(t.state);Object.assign(e,n)}e[te]=t}else if("DISPATCH"===t.type&&"COMMIT"===(null==(o=t.payload)?void 0:o.type))r.init(Q(e));else if("DISPATCH"===t.type&&"IMPORT_STATE"===(null==(i=t.payload)?void 0:i.type)){const n=null==(l=t.payload.nextLiftedState)?void 0:l.actionsById,a=(null==(c=t.payload.nextLiftedState)?void 0:c.computedStates)||[];s=!0,a.forEach((({state:t},a)=>{const o=n[a]||"No action found";Object.assign(e,t),0===a?r.init(Q(e)):r.send(o,Q(e))}))}}));r.init(Q(e))}(I,{name:`${f} Store`,enabled:!0});const k={},O={};ne.setContext(e.context),ne.setAppName(f);const _=j({},Jl,{fetch:t});if(e.previewMode||e.builderMode){const{authActions:t,authStateActions:n,connectivityActions:a,subscriptionsActions:o,subscriptionsStateActions:i,vendorActions:s,auditsActions:r}=BS(I,_,O);k.auth=n,k.connectivity=a,k.subscriptions=i,k.vendor=s,k.auditLogs=r,k.audits={},Object.assign(O,j({},t,a,o,s,r));const l={dispatch:e=>{setTimeout((()=>{const[n,...i]=e.type.split("/"),r=i.join("/");"auth"===n&&"function"==typeof t[r]?t[r](e.payload):"connectivity"===n&&"function"==typeof a[r]?a[r](e.payload):"subscriptions"===n&&"function"==typeof o[r]?o[r](e.payload):"vendor"===n&&"function"==typeof s[r]&&s[r](e.payload)}))},getState:()=>I,subscribe:e=>X(I,e),store:I,actions:O,stateActions:k};return e.previewMode&&l.dispatch({type:"auth/requestAuthorize",payload:!0}),l}{const[e,t]=yy(I,_,O,E),n=Ay(I,_,O),[a,o]=af(I,_,O),i=rf(I,_,O),s=ff(I,_,O),r=((e,t,n)=>{const a=()=>{e.audits.isLoading=!1},o=t=>{var n;e.audits.error=null!=(n=e.audits.error)?n:{},Object.assign(e.audits.error,{[t.name]:t.error})},i=t=>{e.audits.filters=t,e.audits.currentPage=0,e.audits.offset=0,e.audits.isLoading=!0},s=async()=>{const{sortBy:n,sortDirection:a}=e.audits;try{i=await t.audits.getAuditsStats({sortBy:n,sortDirection:a,count:20}),e.audits.error=void 0,e.audits.totalToday=i.totalToday,e.audits.severeThisWeek=i.severeThisWeek}catch(e){const t={name:"stats",error:e};console.error("failed to load stats - ",e),o(t)}var i},r=async()=>{try{n=await t.metadata.getAuditsMetadata(),e.audits.error={},e.audits.headerProps=n.properties,e.audits.themeAudits=n.theme?n.theme.styles:{}}catch(e){const t={name:"metadata",error:e};console.error("failed to load metadata - ",e),o(t)}var n},l=e=>e.reduce(((e,t)=>(e[t.key]=t.value,e)),{}),c=async n=>{const{filters:i,sortBy:s,sortDirection:r,filter:c,offset:u,virtualScroll:d}=e.audits,{appendMode:g=d,onlyOneLoad:p=!0,offset:y=0}=n||{},{rowsData:f}=g?e.audits:{rowsData:[]};try{const n=l(i),{data:o,total:g}=await t.audits.getAudits(j({},d&&{paginationMode:"virtual"},{sortDirection:r,sortBy:s,filter:c},n,{offset:d?f.length+y||f.length+u:y||u,count:20}));(t=>{e.audits.error={},e.audits.rowsData=t.rowsData,e.audits.lastUpdated=new Date,e.audits.total=t.total})({rowsData:[...f,...o],total:g}),p&&a()}catch(e){const t={name:"audits",error:e};console.error("failed to load audits - ",e),o(t)}};return{initData:async()=>{e.audits.isLoading=!0,await Promise.all([s(),r(),c({onlyOneLoad:!1})]),a()},loadAudits:c,removeFilter:async t=>{const{filters:n}=e.audits,a=n.findIndex((e=>e.key===t.key));if(a<0)return;const o=[...n.slice(0,a),...n.slice(a+1)];i(o)},filterData:async t=>{const{filters:n}=e.audits;let a=n.findIndex((e=>e.key===t.key));a<0&&(a=n.length);const o=[...n.slice(0,a),t,...n.slice(a+1)];i(o)},exportCSV:async()=>{const{filters:n,sortBy:a,sortDirection:o,filter:i,headerProps:s=[]}=e.audits,r=l(n);e.audits.isDownloadingCsv=!0;try{await t.audits.exportAudits(j({endpoint:"csv/v2",headerProps:s,sortDirection:o,sortBy:a,filter:i},r,{offset:0,outputFileName:"audits.csv"}))}catch(e){console.error("failed to export audits - ",e)}finally{e.audits.isDownloadingCsv=!1}}}})(I,_);return k.auth=t,k.connectivity=n,k.subscriptions=o,k.vendor=i,k.auditLogs=s,k.audits=r,Object.assign(O,j({},e,n,a,i,s)),{dispatch:t=>{const[o,...s]=t.type.split("/"),r=s.join("/");"auth"===o&&"function"==typeof e[r]?e[r](t.payload):"connectivity"===o&&"function"==typeof n[r]?n[r](t.payload):"subscriptions"===o&&"function"==typeof a[r]?a[r](t.payload):"vendor"===o&&"function"==typeof i[r]&&i[r](t.payload)},getState:()=>I,subscribe:e=>X(I,e),store:I,actions:O,stateActions:k}}};function KS(e,t=0,n=1){return Math.min(Math.max(t,e),n)}function HS(e){if(e.type)return e;if("#"===e.charAt(0))return HS(function(e){e=e.substr(1);const t=new RegExp(`.{1,${e.length>=6?2:1}}`,"g");let n=e.match(t);return n&&1===n[0].length&&(n=n.map((e=>e+e))),n?`rgb${4===n.length?"a":""}(${n.map(((e,t)=>t<3?parseInt(e,16):Math.round(parseInt(e,16)/255*1e3)/1e3)).join(", ")})`:""}(e));const t=e.indexOf("("),n=e.substring(0,t);if(-1===["rgb","rgba","hsl","hsla","color"].indexOf(n))throw new Error("MUI: Unsupported `%s` color.\nThe following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color(). "+e);const a=e.substring(t+1,e.length-1);let o,i;if("color"===n){if(i=a.split(" "),o=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(o))throw new Error("MUI: unsupported `%s` color space.\nThe following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020."+o)}else i=a.split(",");return{type:n,values:i.map((e=>parseFloat(e))),colorSpace:o}}function qS(e){const{type:t,colorSpace:n}=e;let{values:a}=e;return-1!==t.indexOf("rgb")?a=a.map(((e,t)=>t<3?parseInt(e,10):e)):-1!==t.indexOf("hsl")&&(a[1]=`${a[1]}%`,a[2]=`${a[2]}%`),a=-1!==t.indexOf("color")?`${n} ${a.join(" ")}`:`${a.join(", ")}`,`${t}(${a})`}function JS(e){if(0===e.indexOf("#"))return e;const{values:t}=HS(e);return`#${t.map(((e,t)=>function(e){const t=e.toString(16);return 1===t.length?`0${t}`:t}(3===t?Math.round(255*e):e))).join("")}`}function YS(e,t){return e=HS(e),t=KS(t),"rgb"!==e.type&&"hsl"!==e.type||(e.type+="a"),"color"===e.type?e.values[3]=`/${t}`:e.values[3]=t,qS(e)}function XS(e,t){if(e=HS(e),t=KS(t),-1!==e.type.indexOf("hsl"))e.values[2]*=1-t;else if(-1!==e.type.indexOf("rgb")||-1!==e.type.indexOf("color"))for(let n=0;n<3;n+=1)e.values[n]*=1-t;return qS(e)}function QS(e,t){if(e=HS(e),t=KS(t),-1!==e.type.indexOf("hsl"))e.values[2]+=(100-e.values[2])*t;else if(-1!==e.type.indexOf("rgb"))for(let n=0;n<3;n+=1)e.values[n]+=(255-e.values[n])*t;else if(-1!==e.type.indexOf("color"))for(let n=0;n<3;n+=1)e.values[n]+=(1-e.values[n])*t;return qS(e)}const ZS=e=>{if(e)return{main:e,light:JS(QS(e,.4)),dark:JS(XS(e,.15)),hover:JS(XS(e,.15)),active:JS(XS(e,.2))}},eh=e=>{if(e)return{main:e,light:QS(e,.7),dark:XS(e,.2)}},th=(e,t)=>{var n,a,o,i,s,r,l,c,u,d,g,p;return null!=e&&e.palette&&"string"==typeof(null==e||null==(n=e.palette)?void 0:n.primary)?j({},t,{palette:{primary:j({},ZS(null==e||null==(a=e.palette)?void 0:a.primary),{contrastText:null!=(o=null==e||null==(i=e.palette)?void 0:i.primaryText)?o:"#000000"}),secondary:j({},ZS(null==e||null==(s=e.palette)?void 0:s.secondary),{contrastText:null!=(r=null==e||null==(l=e.palette)?void 0:l.secondaryText)?r:"#000000"}),danger:j({},ZS(null==e||null==(c=e.palette)?void 0:c.error),{contrastText:"#FFF"}),success:j({},eh(null==e||null==(u=e.palette)?void 0:u.success),{contrastText:"#FFF"}),error:j({},eh(null==e||null==(d=e.palette)?void 0:d.error),{contrastText:"#FFF"}),warning:j({},eh(null==e||null==(g=e.palette)?void 0:g.warning),{contrastText:"#FFF"}),info:j({},eh(null==e||null==(p=e.palette)?void 0:p.info),{contrastText:"#FFF"})}}):{}},nh={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",permissions:["fe.secure.read.securityPolicy"]},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 ah{constructor(){this._theme=nh.theme,this._themeV2=nh.themeV2,this._navigation=nh.navigation,this._localizations=nh.localizations,this._integrations=nh.integrations}static getInstance(e="default"){return this._instances[e]}static set(e,t="default"){const n=new ah;return n.set(e),ah._instances[t]=n,n}get theme(){var e;return null!=(e=this._theme)?e:{}}get themeV2(){var e;return null!=(e=this._themeV2)?e:{}}get navigation(){var e;return null!=(e=this._navigation)?e:{}}get localizations(){var e;return null!=(e=this._localizations)?e:{}}get integrations(){var e;return null!=(e=this._integrations)?e:{}}set(e){try{var t,n,a,o,i,s,r,l,c;this._navigation=Nc().all([null!=(t=nh.navigation)?t:{},null!=(n=null==e?void 0:e.navigation)?n:{}]),this._theme=Nc().all([null!=(a=nh.theme)?a:{},th(null==e?void 0:e.theme,nh.theme)]),this._themeV2=Nc().all([null!=(o=nh.themeV2)?o:{},null!=(i=null==e?void 0:e.themeV2)?i:{}]),this._localizations=Nc().all([null!=(s=nh.localizations)?s:{},null!=(r=null==e?void 0:e.localizations)?r:{}]),this._integrations=Nc().all([null!=(l=nh.integrations)?l:{},null!=(c=null==e?void 0:e.integrations)?c:{}])}catch(e){this._navigation=nh.navigation,this._theme=nh.theme,this._themeV2=nh.themeV2,this._localizations=nh.localizations,this._integrations=nh.integrations}}}ah._instances={};var oh=function(e){return e.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map((function(e){return e.toLowerCase()})).join("")},ih=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=document.createElement(t);return Object.keys(n).forEach((function(e){return a.setAttribute(e,n[e])})),e.appendChild(a),a},sh=function(e){return new Promise((function(t,n){var a=4e3,o=setInterval((function(){return null!=e.themeSetter?(clearInterval(o),void t(!0)):a<0?(n("Failed to load Renderer with themeSetter"),void clearInterval(o)):void(a-=50)}),50)}))},rh=function(e){var t=e.toString();if(t){var n=new URL(window.location.href);n.search=t,window.history.pushState(null,"",n.toString())}};let lh,ch,uh,dh,gh,ph,yh,fh,Sh,hh,vh,mh,bh;!function(e){e.phoneNumber="phoneNumber"}(lh||(lh={})),function(e){e.Name="name",e.PhoneNumber="phoneNumber",e.Address="address",e.JobTitle="jobTitle"}(ch||(ch={})),function(e){e.LoginSessions="loginSessions",e.Mfa="mfa"}(uh||(uh={})),function(e){e.Name="name",e.PhoneNumber="phoneNumber"}(dh||(dh={})),function(e){e.CompanyName="companyName",e.Address="address",e.Website="website",e.Timezone="timezone",e.Currency="currency"}(gh||(gh={})),function(e){e.User="user",e.Applications="applications",e.Groups="groups",e.Roles="roles",e.JoinedAt="joinedAt",e.LastSeen="lastSeen",e.ManagedBy="managedBy"}(ph||(ph={})),function(e){e.Invoices="invoices"}(yh||(yh={})),function(e){e.SessionManagement="sessionManagement",e.GeneralSettings="generalSettings",e.IpRestrictions="ipRestrictions",e.DomainRestrictions="domainRestrictions"}(fh||(fh={})),function(e){e.IdleSessionTimeout="idleSessionTimeout",e.ForceReLogin="forceReLogin",e.MaximumConcurrentSessions="maximumConcurrentSessions"}(Sh||(Sh={})),function(e){e.Mfa="mfa",e.UserLockout="userLockout",e.PasswordHistory="passwordHistory"}(hh||(hh={})),function(e){e.IpAddressRestrictions="ipAddressRestrictions"}(vh||(vh={})),function(e){e.RestrictSignupByEmailDomain="restrictSignupByEmailDomain"}(mh||(mh={})),function(e){e.Settings="settings",e.CustomLogin="customLogin"}(bh||(bh={}));const Ah={hidden:"hidden",viewOnly:"viewOnly",edit:"edit"},wh={hidden:"hidden",edit:"edit"},Th="7.0.0-alpha.3";var Eh={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"},Ih=function(){function t(e,n){var a,o,i=this,s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];P(this,t),this.name=void 0,this.iframeRendering=void 0,this.options=void 0,this.loading=!0,this.cdnUrl="https://assets.frontegg.com/admin-box/".concat(Th),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.updateLocalizations=void 0,this.loadAdminBoxMetadata=M($().mark((function e(){var t,n,a,o,s,r,l,c,u,d,g,p;return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=tt,i.options.metadata){e.next=25;break}return e.prev=2,e.next=5,t("/metadata",{entityName:"adminBox"});case 5:if(u=e.sent,d=null==u||null==(n=u.rows)||null==(a=n[0])||null==(o=a.configuration)||null==(s=o.metadataOverrides)?void 0:s.url,g=null!=(r=null==u||null==(l=u.rows)||null==(c=l[0])?void 0:c.configuration)?r:{},!d){e.next=19;break}return e.prev=9,e.next=12,t(d,{},{credentials:"same-origin"});case 12:(p=e.sent)&&(g=Nc()(g,p)),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(9),console.error("Failed to get metadata overrides",e.t0);case 19:i.options.metadata=g,e.next=25;break;case 22:e.prev=22,e.t1=e.catch(2),console.error("failed to get admin portal metadata",e.t1);case 25:ah.set(i.options.metadata,i.name);case 26:case"end":return e.stop()}}),e,null,[[2,22],[9,16]])}))),this.requestAuthorize=M($().mark((function e(){var t,n,a;return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=null==(t=i.options.authOptions)||null==(n=t.hostedLoginOptions)?void 0:n.loadUserOnFirstLoad,i.options.builderMode||"nextjs"===i.options.framework||(i.options.hostedLoginBox&&!i.options.customLoginBox?a&&i.store.dispatch({type:"auth/requestHostedLoginAuthorizeV2",payload:{shouldRedirectToLogin:!1,firstTime:!0}}):i.store.dispatch({type:"auth/requestAuthorize",payload:!0}));case 2:case"end":return e.stop()}}),e)}))),this.loadFeatureFlags=M($().mark((function e(){var t;return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!i.options.previewMode&&!i.options.builderMode){e.next=4;break}ut.set(Eh,i.name),e.next=15;break;case 4:return e.prev=4,e.next=7,dt();case 7:t=e.sent,i.options.overrideFeatureFlags&&Object.assign(t,i.options.overrideFeatureFlags),ut.set(t,i.name),e.next=15;break;case 12:e.prev=12,e.t0=e.catch(4),console.error("failed to get admin portal feature flags",e.t0);case 15:case"end":return e.stop()}}),e,null,[[4,12]])}))),this.setFeatureFlagsForPreview=function(e){ut.set(Object.assign({},Eh,e),i.name)},this.queryFeatureFlags=function(e){return ut.getFeatureFlags(e,i.name)},this.updateLocalizationsSetter=function(e){i.updateLocalizations=e},this.getEntitlementsFromStore=function(){var e;return null==(e=i.store.getState().auth.user)?void 0:e.entitlements},this.getUserFromStore=function(){return i.store.getState().auth.user},this.getEntitlementsQueryData=function(e){var t=i.getUserFromStore();return{entitlements:i.getEntitlementsFromStore(),attributes:{custom:e,jwt:t}}};var l=oh(n),c="frontegg-app-".concat(l);this.iframeRendering=s,this.name=l,this.options=Object.assign({},e,{contextOptions:Object.assign({requestCredentials:"include"},e.contextOptions)}),this.options.cdnUrl&&(this.cdnUrl=this.options.cdnUrl),this.customElementName=c;var u,d,g=this.options.authOptions?Object.assign({},this.options.authOptions,{hostedLoginBox:this.options.hostedLoginBox}):{hostedLoginBox:this.options.hostedLoginBox};if(g.onRedirectTo=e.onRedirectTo,g.disableSilentRefresh=null==(a=this.options.authOptions)?void 0:a.disableSilentRefresh,this.options.store){if(this.store=this.options.store,!r&&this.options.store.getState().root.appName!==n)throw Error("Mismatch in store names")}else this.store=zS({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({},g,null!=(u=this.options.authOptions)?u:{}),auditLogs:Object.assign({},null!=(d=this.options.auditsOptions)?d:{})}});R.setInstance(l,this),this.setEntitlementsOptions(e.entitlementsOptions),this.setSessionContext({enableSessionPerTenant:null==(o=e.authOptions)?void 0:o.enableSessionPerTenant}),ne.setAppName(l)}var n,a,o,i;return D(t,[{key:"setEntitlementsOptions",value:function(e){ne.setEntitlementsOptions(Object.assign({},e))}},{key:"setSessionContext",value:function(e){ne.setSessionContext(Object.assign({},e))}},{key:"initContainers",value:(i=M($().mark((function e(t){return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.adminPortalEl=t.adminPortalEl,this.loginBoxEl=t.loginBoxEl,this.checkoutDialogEl=t.checkoutDialogEl,this.adminPortalContainer=t.adminPortalContainer,this.loginBoxContainer=t.loginBoxContainer,this.checkoutDialogContainer=t.checkoutDialogContainer;try{"nextjs"!==this.options.framework&&document.body.classList.add("frontegg-loading")}catch(e){console.error("Failed to add frontegg-loading to body classList")}return e.next=9,this.loadFeatureFlags();case 9:return e.next=11,Promise.all([this.loadAdminBoxMetadata(),this.requestAuthorize()]);case 11:this.options.previewMode||this.options.customLoginBox||(this.loadLoginBox(),n=this.name,a=void 0,void 0,i=void 0,null==(i=null==(o=ah.getInstance(n))||null==(a=o.integrations)?void 0:a.gtm)||i.filter((function(e){var t=e.id;return e.enabled&&/^GTM-[a-zA-Z0-9]+$/.test(t)})).forEach((function(e){var t=e.id,n=document.createElement("script");n.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(t,"');\n "),document.body.appendChild(n)}))),this.options.lazyLoadAdminPortal||this.loadScript("FronteggAdminPortal");case 13:case"end":return e.stop()}var n,a,o,i}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"updateMetadata",value:function(e){var t;ah.set(e,this.name),null!=e&&e.localizations&&(null==(t=this.updateLocalizations)||t.call(this,e.localizations))}},{key:"addOnLoadedListener",value:function(e){this.loading?this.loadingListeners.push(e):e()}},{key:"ready",value:function(e){this.loading?e():this.addOnLoadedListener(e)}},{key:"loginWithRedirect",value:function(){this.store.dispatch({type:"auth/setState",payload:{isLoading:!0}}),this.store.dispatch({type:"auth/requestHostedLoginAuthorize"})}},{key:"logout",value:function(){this.store.dispatch({type:"auth/setState",payload:{isLoading:!0}}),this.store.dispatch({type:"auth/logout"})}},{key:"loadScript",value:function(t){var n=this;return new Promise((function(a,o){if(window[t])a(window[t]);else{var i=document.createElement("script");i.src="".concat(n.cdnUrl,"/").concat({FronteggLoginBox:"login-box/index.js",FronteggAdminPortal:"admin-portal/index.js"}[t]),i.setAttribute("id","".concat(t,"Script")),i.setAttribute("cdn-url",n.cdnUrl),i.onload=function(){window["".concat(t,"Init")]?a(window["".concat(t,"Init")]({FronteggRestApi:k,FronteggTypes:O,FronteggReduxStore:_,ValtioVanilla:e})):a(window[t])},i.onerror=function(e){console.log("Profile page error",e),o(e)},document.body.append(i)}}))}},{key:"loadLoginBox",value:(o=M($().mark((function e(){return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.loadScript("FronteggLoginBox");case 2:e.sent.render(this.loginBoxEl,{injector:this,options:this.options}),this.loading=!1,this.loadingListeners.forEach((function(e){try{e()}catch(e){console.error("Failed to call loadLoginBoxListener",e)}})),this.loadingListeners=[];case 7:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"showAdminPortal",value:(a=M($().mark((function e(t){var n,a,o,i,s;return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=(null!=t?t:{isMultiApp:!1}).isMultiApp,a=this.queryFeatureFlags(["multi-apps-admin-portal"]),l=1,o=function(e){if(Array.isArray(e))return e}(r=a)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var a,o,i,s,r=[],l=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(a=i.call(n)).done)&&(r.push(a.value),r.length!==t);l=!0);}catch(e){c=!0,o=e}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw o}}return r}}(r,l)||function(e,t){if(e){if("string"==typeof e)return C(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?C(e,t):void 0}}(r,l)||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.")}(),i=o[0],ne.setRequestSource(se.AdminPortal),e.next=5,this.loadScript("FronteggAdminPortal");case 5:s=e.sent,this.adminPortalRenderer=s.render(this.adminPortalEl,{injector:this,options:Object.assign({isMultiApp:i&&n},this.options)});case 7:case"end":return e.stop()}var r,l}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"openHostedAdminPortal",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this.options.contextOptions.baseUrl,n="".concat(t,"/oauth/portal");e?window.open(n,"_blank"):window.location.href=n}},{key:"hideAdminPortal",value:function(){try{var e,t=new URLSearchParams(window.location.search);null==(e=this.adminPortalRenderer)||e.unmount(),rh(t),ne.setRequestSource(null)}catch(e){console.error("Failed to unmount admin portal",e)}}},{key:"showCheckoutDialog",value:(n=M($().mark((function e(t){var n;return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.loadScript("FronteggAdminPortal");case 2:n=e.sent,this.checkoutDialogRenderer=n.renderCheckoutDialog(this.checkoutDialogEl,Object.assign({injector:this},t,{options:this.options}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"hideCheckoutDialog",value:function(){try{var e;null==(e=this.checkoutDialogRenderer)||e.unmount()}catch(e){console.error("Failed to unmount checkout dialog",e)}}},{key:"getFeatureEntitlements",value:function(e,t){var n=this.getEntitlementsQueryData(t),a=n.entitlements,o=n.attributes;return uc(a,e,o)}},{key:"getPermissionEntitlements",value:function(e,t){var n=this.getEntitlementsQueryData(t),a=n.entitlements,o=n.attributes;return cc(a,e,o)}},{key:"getEntitlements",value:function(e,t){return"permissionKey"in e?this.getPermissionEntitlements(e.permissionKey,t):this.getFeatureEntitlements(e.featureKey,t)}},{key:"loadEntitlements",value:function(e){this.store.dispatch({type:"auth/loadEntitlements",payload:{callback:e}})}},{key:"stepUp",value:function(e){var t=this.store.getState(),n=(null==t?void 0:t.auth)||{},a=n.hostedLoginBox,o=n.routes.stepUpUrl;a?this.store.dispatch({type:"auth/stepUpHostedLogin",payload:e}):hu(o,t.auth.onRedirectTo,null==e?void 0:e.maxAge)}},{key:"isSteppedUp",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=(null==(e=this.store.getState())?void 0:e.auth)||{},a=n.user;return fu(a,t)}},{key:"switchTenant",value:function(e){this.store.dispatch({type:"auth/switchTenant",payload:e})}},{key:"close",value:function(){this.hideAdminPortal(),this.hideCheckoutDialog()}}]),t}(),kh=function(){function e(){P(this,e)}return D(e,null,[{key:"setAuthentication",value:function(e,t,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"default",o=R.getInstance(a);e&&t?(ne.setAccessToken(t),ne.setUser(Object.assign({},n,{accessToken:t})),o.store.actions.setAuthState({isLoading:!1,isAuthenticated:e,user:n}),o.store.actions.loadTenants()):(ne.setAccessToken(null),ne.setUser(null),o.store.actions.setAuthState({isLoading:!1,isAuthenticated:!1,user:null}))}}]),e}(),Oh=function(){function e(){P(this,e)}return D(e,null,[{key:"show",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";R.getInstance(e).showAdminPortal()}},{key:"showMultiApp",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";R.getInstance(e).showAdminPortal({isMultiApp:!0})}},{key:"openHosted",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";R.getInstance(t).openHostedAdminPortal(e)}},{key:"hide",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";R.getInstance(e).hideAdminPortal()}}]),e}(),_h=function(){function e(){P(this,e)}return D(e,null,[{key:"show",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";R.getInstance(t).showCheckoutDialog(e)}},{key:"hide",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";R.getInstance(e).hideCheckoutDialog()}}]),e}(),Ph=function(e){var t;return null!=(t=window.FronteggAdminPortal.adminPortalStaticThemesDefaults[e])?t:void 0},Uh=function(){function e(t,n,a,o){var i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];P(this,e),this.app=void 0,this.options=void 0,this.store=void 0,this.setRoute=function(){},this.themeSetter=void 0,this.themeOptions={};var s={baseUrl:"preview"};if(a){if(this.store=a,!i&&a.getState().root.appName!==t)throw Error("Mismatch in store names")}else this.store=WS({context:s,appName:t},this,!0,void 0,void 0,!0);this.options=Object.assign({themeOptions:n,iframeRendering:!0,metadata:{},previewMode:!0,builderMode:!0,store:this.store,contextOptions:s},o),this.app=new Ih(this.options,t,!0),ah.set({},t)}var t;return D(e,[{key:"render",value:(t=M($().mark((function e(t){var n,a,o,i,s=this;return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=t.querySelector("#root"))||((n=t.ownerDocument.createElement("div")).setAttribute("id","root"),t.appendChild(n)),this.app.adminPortalContainer=t,this.app.adminPortalEl=n,a=function(e){s.themeSetter=e},o=function(e){s.setRoute=e},e.next=8,this.app.loadScript("FronteggAdminPortal");case 8:return i=e.sent,this.app.adminPortalRenderer=i.renderPage(n,{options:this.options,injector:this.app,setThemeSetter:a,setStaticRouteSetter:o}),this.app.loading=!1,e.next=13,sh(this);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"setStaticRoute",value:function(e){var t;null==(t=this.setRoute)||t.call(this,e)}},{key:"unmount",value:function(){try{var e;null==(e=this.app.adminPortalRenderer)||e.unmount()}catch(e){console.error("Failed to unmount admin Portal renderer",e)}}},{key:"setTheme",value:function(e){var t;this.themeOptions=e,this.themeSetter||console.warn("this.themeSetter is not defined yet"),null==(t=this.themeSetter)||t.call(this,this.themeOptions)}}]),e}(),Lh="modern",Dh=function(e){var t,n=window.FronteggAdminPortal.themes;return null!=(t=n[e])?t:n[Lh]},Rh=function(){function e(t,n,a,o){var i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];P(this,e),this.app=void 0,this.options=void 0,this.store=void 0,this.themeSetter=void 0,this.setRoute=function(){},this.themeOptions={};var s={baseUrl:"preview"};if(a){if(this.store=a,!i&&a.getState().root.appName!==t)throw Error("Mismatch in store names")}else this.store=WS({context:s,appName:t},this,!0,void 0,void 0,!0);this.options=Object.assign({themeOptions:n,iframeRendering:!0,metadata:{},previewMode:!0,builderMode:!0,store:this.store,contextOptions:s,onRedirectTo:function(){console.debug("path")}},o),this.app=new Ih(this.options,t,!0,i),ah.set({},t)}var t;return D(e,[{key:"render",value:(t=M($().mark((function e(t){var n,a,o,i,s=this;return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=t.querySelector("#root"))||((n=t.ownerDocument.createElement("div")).setAttribute("id","root"),t.appendChild(n)),this.app.loginBoxContainer=t,this.app.loginBoxEl=n,a=function(e){s.themeSetter=e},o=function(e){s.setRoute=e},e.next=8,this.app.loadScript("FronteggLoginBox");case 8:return i=e.sent,this.app.loginBoxRenderer=i.renderPage(n,{options:this.options,injector:this.app,setThemeSetter:a,setStaticRouteSetter:o,staticRoute:"/account/login"}),e.next=12,sh(this);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"unmount",value:function(){try{var e;null==(e=this.app.loginBoxRenderer)||e.unmount()}catch(e){console.error("Failed to unmount login box renderer",e)}}},{key:"setTheme",value:function(e){var t;this.themeOptions=e,this.themeSetter||console.warn("this.themeSetter is not defined yet"),null==(t=this.themeSetter)||t.call(this,this.themeOptions)}},{key:"setStaticRoute",value:function(e){var t;this.setRoute||console.warn("this.setRoute is not defined yet"),null==(t=this.setRoute)||t.call(this,e)}},{key:"setStore",value:function(e){this.store.dispatch({type:"auth/setState",payload:e})}}]),e}();function Ch(e,t){return Ch=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ch(e,t)}function Nh(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ch(e,t)}function Mh(e,t){if(t&&("object"===U(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function Fh(e){return Fh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Fh(e)}function $h(){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(e){return!1}}function jh(e,t,n){return jh=$h()?Reflect.construct.bind():function(e,t,n){var a=[null];a.push.apply(a,t);var o=new(Function.bind.apply(e,a));return n&&Ch(o,n.prototype),o},jh.apply(null,arguments)}function Gh(e){var t="function"==typeof Map?new Map:void 0;return Gh=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,a)}function a(){return jh(e,arguments,Fh(this).constructor)}return a.prototype=Object.create(e.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),Ch(a,e)},Gh(e)}function xh(e){var t=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(e){return!1}}();return function(){var n,a=Fh(e);if(t){var o=Fh(this).constructor;n=Reflect.construct(a,arguments,o)}else n=a.apply(this,arguments);return Mh(this,n)}}var Vh=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default",n=new Ih(e,t);if("undefined"!=typeof document){var a;if(!e.contextOptions.baseUrl){var o=new Error('Edit <FronteggProvider/> options { ContextOptions: { baseUrl: "" } } in order to connect your application');throw document.body.innerHTML="",alert(o.message),o}if(!customElements.get("frontegg-app")){var i=function(e){Nh(n,e);var t=xh(n);function n(){var e;P(this,n);for(var a=arguments.length,o=new Array(a),i=0;i<a;i++)o[i]=arguments[i];return(e=t.call.apply(t,[this].concat(o))).app=null,e}return D(n,[{key:"connectedCallback",value:function(){this.updateContent()}},{key:"attributeChangedCallback",value:function(e,t,n){if("app-name"===e){if(null===t)return;if(t===n)return;this.innerHTML="",null===n?this.remove():this.updateContent()}console.debug("attributeChangedCallback",e,t,n)}},{key:"updateContent",value:function(){var e,t=null!=(e=this.getAttribute("app-name"))?e:"default",n=R.getInstance(t);if(null===n)throw Error("FronteggApp not found for appName: '".concat(t,"'"));this.setAttribute("id","frontegg-app-".concat(n.name));var a=ih(this,"div",{id:"frontegg-admin-portal-container-".concat(n.name)}),o=ih(this,"div",{id:"frontegg-login-box-container-".concat(n.name)}),i=ih(this,"div",{id:"frontegg-checkout-dialog-container-".concat(n.name)}),s=a.attachShadow({mode:"open"}),r=o.attachShadow({mode:"open"}),l=i.attachShadow({mode:"open"}),c=ih(s,"div",{id:"frontegg-admin-portal-".concat(n.name),class:"frontegg-root-content"}),u=ih(r,"div",{id:"frontegg-login-box-".concat(n.name),class:"frontegg-root-content"}),d=ih(l,"div",{id:"frontegg-checkout-dialog-".concat(n.name),class:"frontegg-root-content"});n.initContainers({adminPortalEl:c,loginBoxEl:u,adminPortalContainer:a,loginBoxContainer:o,checkoutDialogContainer:i,checkoutDialogEl:d})}}],[{key:"observedAttributes",get:function(){return["app-name"]}}]),n}(Gh(HTMLElement));customElements.define("frontegg-app",i)}null==(a=document.querySelector('frontegg-app[app-name="'.concat(n.name,'"]')))||a.remove();var s=document.createElement("frontegg-app");s.setAttribute("app-name",n.name),document.body.appendChild(s)}return n}})(),a})()));
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Frontegg=t():e.Frontegg=t()}(window,(()=>(()=>{var e={6987:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createConditionEvaluator=void 0;const a=n(3651),o=n(9082);t.createConditionEvaluator=function(e){const t=(0,o.useSanitizer)(e.condition.op);if(!t)return()=>!1;const{isSanitized:n,sanitizedValue:i}=t(e.condition.value);if(!n||void 0===i)return()=>!1;const s=(0,a.useOperation)(e.condition.op,i);return t=>{const n=t[e.condition.attribute];if(void 0===n||!s)return!1;const{isValid:a}=s(n);return e.condition.negate?!a:a}}},2898:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(6987),t),o(n(7371),t)},7371:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},3840:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateFeatureFlag=void 0;const a=n(2380);t.evaluateFeatureFlag=function(e,t){if(!e.on)return{treatment:e.offTreatment};const n=function(e,t){var n;return null===(n=e.rules)||void 0===n?void 0:n.find((e=>(0,a.createRuleEvaluator)({rule:e})(t)===a.RuleEvaluationResultEnum.Treatable))}(e,t);return n?{treatment:n.treatment}:{treatment:e.defaultTreatment}}},6095:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(3840),t)},9314:(e,t,n)=>{"use strict";t.wJ=t.tE=void 0;n(6095),n(521),n(2380),n(2379);var a=n(5535);Object.defineProperty(t,"tE",{enumerable:!0,get:function(){return a.evaluateIsEntitledToFeature}}),Object.defineProperty(t,"wJ",{enumerable:!0,get:function(){return a.evaluateIsEntitledToPermissions}})},195:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanOperationsMapper=void 0;const i=n(2379),s=n(6610);o(n(6610),t),o(n(7226),t),t.BooleanOperationsMapper={[i.OperationEnum.Is]:e=>(0,s.useIsOperation)(e)}},6610:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useIsOperation=void 0,t.useIsOperation=function(e){return t=>({isValid:t===e.boolean})}},7226:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSanitizersMapper=t.singleBooleanSanitizer=void 0;const a=n(2379);t.singleBooleanSanitizer=e=>{const t=void 0!==e.boolean&&(e=>"boolean"==typeof e)(e.boolean)?{boolean:e.boolean}:void 0;return{isSanitized:!!t,sanitizedValue:t}},t.BooleanSanitizersMapper={[a.OperationEnum.Is]:t.singleBooleanSanitizer}},3651:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useOperation=void 0;const a=n(5943),o=n(1610),i=n(9004),s=n(195),r={...a.StringOperationsMapper,...o.NumericOperationsMapper,...i.DateOperationsMapper,...s.BooleanOperationsMapper};t.useOperation=function(e,t){const n=r[e];return n?n(t):void 0}},9082:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useSanitizer=void 0;const a=n(195),o=n(2903),i=n(6886),s=n(1610),r={...o.StringSanitizersMapper,...s.NumericSanitizersMapper,...i.DateSanitizersMapper,...a.BooleanSanitizersMapper};t.useSanitizer=function(e){return r[e]}},9004:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.DateOperationsMapper=void 0;const i=n(2379),s=n(4569);o(n(4569),t),o(n(5931),t),t.DateOperationsMapper={[i.OperationEnum.On]:e=>(0,s.useDateOnOperation)(e),[i.OperationEnum.OnOrAfter]:e=>(0,s.useDateOnOrAfterOperation)(e),[i.OperationEnum.OnOrBefore]:e=>(0,s.useDateOnOrBeforeOperation)(e),[i.OperationEnum.BetweenDate]:e=>(0,s.useDateBetweenOperation)(e)}},4569:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useDateBetweenOperation=t.useDateOnOrBeforeOperation=t.useDateOnOrAfterOperation=t.useDateOnOperation=void 0,t.useDateOnOperation=function(e){return t=>({isValid:t.getTime()===e.date.getTime()})},t.useDateOnOrAfterOperation=function(e){return t=>({isValid:t.getTime()>=e.date.getTime()})},t.useDateOnOrBeforeOperation=function(e){return t=>({isValid:t.getTime()<=e.date.getTime()})},t.useDateBetweenOperation=function(e){return t=>({isValid:t.getTime()>=e.start.getTime()&&t.getTime()<=e.end.getTime()})}},6886:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateSanitizersMapper=t.sanitizeDateRange=t.sanitizeSingleDate=t.isValidDate=t.sanitizeDateValue=void 0;const a=n(2379);t.sanitizeDateValue=e=>new Date(e),t.isValidDate=e=>e instanceof Date&&!isNaN(e),t.sanitizeSingleDate=e=>{const n=e.date?(0,t.sanitizeDateValue)(e.date):void 0,a=n&&(0,t.isValidDate)(n)?{date:n}:void 0;return{isSanitized:!!a,sanitizedValue:a}},t.sanitizeDateRange=e=>{const n=e.start?(0,t.sanitizeDateValue)(e.start):void 0,a=e.end?(0,t.sanitizeDateValue)(e.end):void 0,o=n&&a&&(0,t.isValidDate)(n)&&(0,t.isValidDate)(a)?{start:n,end:a}:void 0;return{isSanitized:!!o,sanitizedValue:o}},t.DateSanitizersMapper={[a.OperationEnum.On]:t.sanitizeSingleDate,[a.OperationEnum.OnOrAfter]:t.sanitizeSingleDate,[a.OperationEnum.OnOrBefore]:t.sanitizeSingleDate,[a.OperationEnum.BetweenDate]:t.sanitizeDateRange}},5931:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},1610:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.NumericOperationsMapper=void 0;const i=n(2379),s=n(9217);t.NumericOperationsMapper={[i.OperationEnum.Equal]:e=>(0,s.useEqualsOperation)(e),[i.OperationEnum.GreaterThan]:e=>(0,s.useGreaterThanOperation)(e),[i.OperationEnum.GreaterThanEqual]:e=>(0,s.useGreaterThanEqualOperation)(e),[i.OperationEnum.LesserThan]:e=>(0,s.useLesserThanOperation)(e),[i.OperationEnum.LesserThanEqual]:e=>(0,s.useLesserThanEqualOperation)(e),[i.OperationEnum.BetweenNumeric]:e=>(0,s.useBetweenNumericOperation)(e)},o(n(9217),t),o(n(9326),t),o(n(1764),t)},9217:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useBetweenNumericOperation=t.useLesserThanEqualOperation=t.useLesserThanOperation=t.useGreaterThanEqualOperation=t.useGreaterThanOperation=t.useEqualsOperation=void 0,t.useEqualsOperation=function(e){return t=>({isValid:t===e.number})},t.useGreaterThanOperation=function(e){return t=>({isValid:t>e.number})},t.useGreaterThanEqualOperation=function(e){return t=>({isValid:t>=e.number})},t.useLesserThanOperation=function(e){return t=>({isValid:t<e.number})},t.useLesserThanEqualOperation=function(e){return t=>({isValid:t<=e.number})},t.useBetweenNumericOperation=function(e){return t=>({isValid:t>=e.start&&t<=e.end})}},9326:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NumericSanitizersMapper=t.sanitizeNumericRange=t.sanitizeSingleNumber=void 0;const a=n(2379),o=e=>"number"==typeof e;t.sanitizeSingleNumber=e=>{const t=void 0!==e.number&&o(e.number)?{number:e.number}:void 0;return{isSanitized:!!t,sanitizedValue:t}},t.sanitizeNumericRange=e=>{const t=void 0!==e.start&&void 0!==e.end&&o(e.start)&&o(e.end)?{start:e.start,end:e.end}:void 0;return{isSanitized:!!t,sanitizedValue:t}},t.NumericSanitizersMapper={[a.OperationEnum.Equal]:t.sanitizeSingleNumber,[a.OperationEnum.GreaterThan]:t.sanitizeSingleNumber,[a.OperationEnum.GreaterThanEqual]:t.sanitizeSingleNumber,[a.OperationEnum.LesserThan]:t.sanitizeSingleNumber,[a.OperationEnum.LesserThanEqual]:t.sanitizeSingleNumber,[a.OperationEnum.BetweenNumeric]:t.sanitizeNumericRange}},1764:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},5943:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.StringOperationsMapper=void 0;const i=n(2379),s=n(2431);o(n(2431),t),o(n(2097),t),t.StringOperationsMapper={[i.OperationEnum.StartsWith]:e=>(0,s.useStartsWithOperation)(e),[i.OperationEnum.EndsWith]:e=>(0,s.useEndsWithOperation)(e),[i.OperationEnum.Contains]:e=>(0,s.useContainsOperation)(e),[i.OperationEnum.InList]:e=>(0,s.useInListOperation)(e),[i.OperationEnum.Matches]:e=>(0,s.useMatchesOperation)(e)}},2431:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useMatchesOperation=t.useInListOperation=t.useContainsOperation=t.useEndsWithOperation=t.useStartsWithOperation=void 0,t.useStartsWithOperation=function(e){return t=>({isValid:e.list.some((e=>t.startsWith(e)))})},t.useEndsWithOperation=function(e){return t=>({isValid:e.list.some((e=>t.endsWith(e)))})},t.useContainsOperation=function(e){return t=>({isValid:e.list.some((e=>t.includes(e)))})},t.useInListOperation=function(e){return t=>({isValid:e.list.includes(t)})},t.useMatchesOperation=function(e){return t=>{let n;try{n=new RegExp(e.string)}catch(e){return{isValid:!1}}return{isValid:n.test(t)}}}},2903:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringSanitizersMapper=t.sanitizeListString=t.sanitizeSingleString=void 0;const a=n(2379),o=e=>"string"==typeof e;t.sanitizeSingleString=e=>{const t=void 0!==e.string&&o(e.string)?{string:e.string}:void 0;return{isSanitized:!!t,sanitizedValue:t}},t.sanitizeListString=e=>{const t=void 0!==e.list&&e.list.every((e=>o(e)))?{list:e.list}:void 0;return{isSanitized:!!t,sanitizedValue:t}},t.StringSanitizersMapper={[a.OperationEnum.Matches]:t.sanitizeSingleString,[a.OperationEnum.Contains]:t.sanitizeListString,[a.OperationEnum.StartsWith]:t.sanitizeListString,[a.OperationEnum.EndsWith]:t.sanitizeListString,[a.OperationEnum.InList]:t.sanitizeListString}},2097:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2379:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(3982),t)},3982:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.OperationEnum=void 0,(n=t.OperationEnum||(t.OperationEnum={})).InList="in_list",n.StartsWith="starts_with",n.EndsWith="ends_with",n.Contains="contains",n.Matches="matches",n.Equal="equal",n.GreaterThan="greater_than",n.GreaterThanEqual="greater_than_equal",n.LesserThan="lower_than",n.LesserThanEqual="lower_than_equal",n.BetweenNumeric="between_numeric",n.Is="is",n.On="on",n.BetweenDate="between_date",n.OnOrAfter="on_or_after",n.OnOrBefore="on_or_before"},521:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(3603),t)},3603:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.evaluatePlan=void 0;const a=n(2380);t.evaluatePlan=function(e,t){const n=function(e,t){var n;return null===(n=e.rules)||void 0===n?void 0:n.find((e=>(0,a.createRuleEvaluator)({rule:e})(t)===a.RuleEvaluationResultEnum.Treatable))}(e,t);return n?{treatment:n.treatment}:{treatment:e.defaultTreatment}}},2380:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(2930),t),o(n(1304),t)},1304:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createRuleEvaluator=void 0;const a=n(2930),o=n(2898);t.createRuleEvaluator=function(e){return t=>e.rule.conditions.every((e=>(0,o.createConditionEvaluator)({condition:e})(t)))?a.RuleEvaluationResultEnum.Treatable:a.RuleEvaluationResultEnum.Insufficient}},2930:(e,t)=>{"use strict";var n,a;Object.defineProperty(t,"__esModule",{value:!0}),t.RuleEvaluationResultEnum=t.TreatmentEnum=t.ConditionLogicEnum=void 0,(t.ConditionLogicEnum||(t.ConditionLogicEnum={})).And="and",(a=t.TreatmentEnum||(t.TreatmentEnum={})).True="true",a.False="false",(n=t.RuleEvaluationResultEnum||(t.RuleEvaluationResultEnum={})).Treatable="treatable",n.Insufficient="insufficient"},5535:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(3779),t),o(n(1038),t),o(n(5113),t),o(n(4848),t)},5640:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.directEntitlementEvalutor=void 0;const a=n(5113);t.directEntitlementEvalutor=function(e,t,n={}){const o=t.features[e];let i=!1;return o&&null!==o.expireTime&&(i=o.expireTime!==a.NO_EXPIRATION_TIME&&o.expireTime<Date.now(),!i)?{isEntitled:!0}:{isEntitled:!1,justification:i?a.NotEntitledJustification.BUNDLE_EXPIRED:a.NotEntitledJustification.MISSING_FEATURE}}},9838:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.featureFlagEvaluator=void 0;const a=n(5113),o=n(6095),i=n(4668),s=n(2380);t.featureFlagEvaluator=function(e,t,n={}){const r=t.features[e];if(r&&r.featureFlag){const e=(0,i.prepareAttributes)(n),{treatment:t}=(0,o.evaluateFeatureFlag)(r.featureFlag,e);if(t===s.TreatmentEnum.True)return{isEntitled:!0}}return{isEntitled:!1,justification:a.NotEntitledJustification.MISSING_FEATURE}}},4529:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getIsEntitledEvaluators=void 0;const a=n(5640),o=n(9838),i=n(3751);t.getIsEntitledEvaluators=function(){return[a.directEntitlementEvalutor,o.featureFlagEvaluator,i.planTargetingRulesEvalutor]}},3751:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.planTargetingRulesEvalutor=void 0;const a=n(5113),o=n(4668),i=n(2380),s=n(521);t.planTargetingRulesEvalutor=function(e,t,n={}){const r=t.features[e];if(r&&r.planIds&&r.planIds.length>0){const e=(0,o.prepareAttributes)(n),a=t.plans;for(const t of r.planIds){const n=a[t];if(n){const{treatment:t}=(0,s.evaluatePlan)(n,e);if(t===i.TreatmentEnum.True)return{isEntitled:!0}}}}return{isEntitled:!1,justification:a.NotEntitledJustification.MISSING_FEATURE}}},3779:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(7850),t)},7850:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateIsEntitledToFeature=void 0;const a=n(5113),o=n(4848),i=n(4529);t.evaluateIsEntitledToFeature=function(e,t,n={}){if(!t)return{isEntitled:!1,justification:a.NotEntitledJustification.MISSING_FEATURE};const s=[];for(const a of(0,i.getIsEntitledEvaluators)())if(s.push(a(e,t,n)),!(0,o.shouldContinue)(s))break;return(0,o.getResult)(s)}},1038:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(519),t)},519:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateIsEntitledToPermissions=void 0;const a=n(7850),o=n(5113),i=n(4848),s=n(4852);t.evaluateIsEntitledToPermissions=function(e,t,n){if(!t)return{isEntitled:!1,justification:o.NotEntitledJustification.MISSING_PERMISSION};if(!(0,s.checkPermission)(t.permissions,e))return{isEntitled:!1,justification:o.NotEntitledJustification.MISSING_PERMISSION};const r=function(e,t){return Object.keys(t.features).filter((n=>t.features[n].linkedPermissions.includes(e)))}(e,t);if(!r.length)return{isEntitled:!0};const l=[];for(const e of r)if(l.push((0,a.evaluateIsEntitledToFeature)(e,t,n)),!(0,i.shouldContinue)(l))break;return(0,i.getResult)(l)}},5113:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.NO_EXPIRATION_TIME=t.NotEntitledJustification=void 0,(n=t.NotEntitledJustification||(t.NotEntitledJustification={})).MISSING_FEATURE="MISSING_FEATURE",n.MISSING_PERMISSION="MISSING_PERMISSION",n.BUNDLE_EXPIRED="BUNDLE_EXPIRED",t.NO_EXPIRATION_TIME=-1},4668:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.modifyObjectKeysWithPrefix=t.defaultFronteggAttributesMapper=t.prepareAttributes=void 0;const a=n(193);function o(e){return{email:e.email,emailVerified:e.email_verified,tenantId:e.tenantId,userId:e.id}}function i(e,t){return Object.keys(e).reduce(((n,a)=>(n[`${t}${a}`]=e[a],n)),{})}t.prepareAttributes=function(e={},t){const{custom:n={},jwt:s={}}=e,r=(0,a.flatten)(s);return{...n,...i(t?t(s):o(s),"frontegg."),...i(r,"jwt.")}},t.defaultFronteggAttributesMapper=o,t.modifyObjectKeysWithPrefix=i},1882:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shouldContinue=t.getResult=void 0;const a=n(5113);t.getResult=function(e){let t=!1;for(const n of e){if(n.isEntitled)return n;n.justification===a.NotEntitledJustification.BUNDLE_EXPIRED&&(t=!0)}return{isEntitled:!1,justification:t?a.NotEntitledJustification.BUNDLE_EXPIRED:a.NotEntitledJustification.MISSING_FEATURE}},t.shouldContinue=function(e){return e.every((({isEntitled:e})=>!e))}},193:(e,t)=>{"use strict";function n(e){return e}Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0,t.flatten=function(e,t){const a=(null==(t=t||{})?void 0:t.delimiter)||".",o=null==t?void 0:t.maxDepth,i=(null==t?void 0:t.transformKey)||n,s={};return function e(n,r,l){l=l||1,Object.keys(n).forEach((function(c){const u=n[c],d=(null==t?void 0:t.safe)&&Array.isArray(u),g=Object.prototype.toString.call(u),p=(y=u)&&y.constructor&&"function"==typeof y.constructor.isBuffer&&y.constructor.isBuffer(y);var y;const f="[object Object]"===g||"[object Array]"===g,S=r?r+a+i(c):i(c);if(!d&&!p&&f&&Object.keys(u).length&&(!(null==t?void 0:t.maxDepth)||o&&l<o))return e(u,S,l+1);s[S]=u}))}(e),s}},4848:function(e,t,n){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,o)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(4852),t),o(n(4668),t),o(n(1882),t)},4852:(e,t)=>{"use strict";function n(e){return new RegExp("^"+e.replace(/\./g,"\\.").replace(/\*/g,".*")+"$","gs")}Object.defineProperty(t,"__esModule",{value:!0}),t.createPermissionCheckRegex=t.checkPermission=void 0,t.checkPermission=function(e,t){return Object.keys(e).some((e=>n(e).test(t)))},t.createPermissionCheckRegex=n},9714:e=>{"use strict";var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===n}(e)}(e)},n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function a(e,t){return!1!==t.clone&&t.isMergeableObject(e)?r((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function o(e,t,n){return e.concat(t).map((function(e){return a(e,n)}))}function i(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return e.propertyIsEnumerable(t)})):[]}(e))}function s(e,t){try{return t in e}catch(e){return!1}}function r(e,n,l){(l=l||{}).arrayMerge=l.arrayMerge||o,l.isMergeableObject=l.isMergeableObject||t,l.cloneUnlessOtherwiseSpecified=a;var c=Array.isArray(n);return c===Array.isArray(e)?c?l.arrayMerge(e,n,l):function(e,t,n){var o={};return n.isMergeableObject(e)&&i(e).forEach((function(t){o[t]=a(e[t],n)})),i(t).forEach((function(i){(function(e,t){return s(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,i)||(s(e,i)&&n.isMergeableObject(t[i])?o[i]=function(e,t){if(!t.customMerge)return r;var n=t.customMerge(e);return"function"==typeof n?n:r}(i,n)(e[i],t[i],n):o[i]=a(t[i],n))})),o}(e,n,l):a(n,l)}r.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,n){return r(e,n,t)}),{})};var l=r;e.exports=l},9378:e=>{"use strict";e.exports=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var a,o,i;if(Array.isArray(t)){if((a=t.length)!=n.length)return!1;for(o=a;0!=o--;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((a=(i=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(o=a;0!=o--;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=a;0!=o--;){var s=i[o];if(!e(t[s],n[s]))return!1}return!0}return t!=t&&n!=n}},5690:(e,t,n)=>{"use strict";var a=n(8558);function o(e){return!0===a(e)&&"[object Object]"===Object.prototype.toString.call(e)}e.exports=function(e){var t,n;return!1!==o(e)&&"function"==typeof(t=e.constructor)&&!1!==o(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf")}},50:e=>{"use strict";e.exports=function(e){return"object"==typeof e?null===e:"function"!=typeof e}},8558:e=>{"use strict";e.exports=function(e){return null!=e&&"object"==typeof e&&!1===Array.isArray(e)}},262:(e,t,n)=>{"use strict";const{deleteProperty:a}=Reflect,o=n(50),i=n(5690),s=e=>"object"==typeof e&&null!==e||"function"==typeof e,r=e=>{if(!o(e))throw new TypeError("Object keys must be strings or symbols");if((e=>"__proto__"===e||"constructor"===e||"prototype"===e)(e))throw new Error(`Cannot set unsafe key: "${e}"`)},l=(e,t)=>t&&"function"==typeof t.split?t.split(e):"symbol"==typeof e?[e]:Array.isArray(e)?e:((e,t,n)=>{const a=(e=>Array.isArray(e)?e.flat().map(String).join(","):e)(t?((e,t)=>{if("string"!=typeof e||!t)return e;let n=e+";";return void 0!==t.arrays&&(n+=`arrays=${t.arrays};`),void 0!==t.separator&&(n+=`separator=${t.separator};`),void 0!==t.split&&(n+=`split=${t.split};`),void 0!==t.merge&&(n+=`merge=${t.merge};`),void 0!==t.preservePaths&&(n+=`preservePaths=${t.preservePaths};`),n})(e,t):e);r(a);const o=u.cache.get(a)||n();return u.cache.set(a,o),o})(e,t,(()=>((e,t={})=>{const n=t.separator||".",a="/"!==n&&t.preservePaths;if("string"==typeof e&&!1!==a&&/\//.test(e))return[e];const o=[];let i="";const s=e=>{let t;""!==e.trim()&&Number.isInteger(t=Number(e))?o.push(t):o.push(e)};for(let t=0;t<e.length;t++){const a=e[t];"\\"!==a?a!==n?i+=a:(s(i),i=""):i+=e[++t]}return i&&s(i),o})(e,t))),c=(e,t,n,o)=>{if(r(t),void 0===n)a(e,t);else if(o&&o.merge){const a="function"===o.merge?o.merge:Object.assign;a&&i(e[t])&&i(n)?e[t]=a(e[t],n):e[t]=n}else e[t]=n;return e},u=(e,t,n,a)=>{if(!t||!s(e))return e;const o=l(t,a);let i=e;for(let e=0;e<o.length;e++){const t=o[e],l=o[e+1];if(r(t),void 0===l){c(i,t,n,a);break}"number"!=typeof l||Array.isArray(i[t])?(s(i[t])||(i[t]={}),i=i[t]):i=i[t]=[]}return e};u.split=l,u.cache=new Map,u.clear=()=>{u.cache=new Map},e.exports=u},7609:(e,t,n)=>{var a=n(7425).default;function o(){"use strict";e.exports=o=function(){return t},e.exports.__esModule=!0,e.exports.default=e.exports;var t={},n=Object.prototype,i=n.hasOwnProperty,s=Object.defineProperty||function(e,t,n){e[t]=n.value},r="function"==typeof Symbol?Symbol:{},l=r.iterator||"@@iterator",c=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";function d(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{d({},"")}catch(e){d=function(e,t,n){return e[t]=n}}function g(e,t,n,a){var o=t&&t.prototype instanceof f?t:f,i=Object.create(o.prototype),r=new _(a||[]);return s(i,"_invoke",{value:E(e,n,r)}),i}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=g;var y={};function f(){}function S(){}function h(){}var v={};d(v,l,(function(){return this}));var m=Object.getPrototypeOf,b=m&&m(m(P([])));b&&b!==n&&i.call(b,l)&&(v=b);var A=h.prototype=f.prototype=Object.create(v);function w(e){["next","throw","return"].forEach((function(t){d(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,t){function n(o,s,r,l){var c=p(e[o],e,s);if("throw"!==c.type){var u=c.arg,d=u.value;return d&&"object"==a(d)&&i.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,r,l)}),(function(e){n("throw",e,r,l)})):t.resolve(d).then((function(e){u.value=e,r(u)}),(function(e){return n("throw",e,r,l)}))}l(c.arg)}var o;s(this,"_invoke",{value:function(e,a){function i(){return new t((function(t,o){n(e,a,t,o)}))}return o=o?o.then(i,i):i()}})}function E(e,t,n){var a="suspendedStart";return function(o,i){if("executing"===a)throw new Error("Generator is already running");if("completed"===a){if("throw"===o)throw i;return{value:void 0,done:!0}}for(n.method=o,n.arg=i;;){var s=n.delegate;if(s){var r=I(s,n);if(r){if(r===y)continue;return r}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===a)throw a="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a="executing";var l=p(e,t,n);if("normal"===l.type){if(a=n.done?"completed":"suspendedYield",l.arg===y)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(a="completed",n.method="throw",n.arg=l.arg)}}}function I(e,t){var n=t.method,a=e.iterator[n];if(void 0===a)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,I(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var o=p(a,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,y;var i=o.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,y):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,y)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function P(e){if(e){var t=e[l];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n<e.length;)if(i.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:U}}function U(){return{value:void 0,done:!0}}return S.prototype=h,s(A,"constructor",{value:h,configurable:!0}),s(h,"constructor",{value:S,configurable:!0}),S.displayName=d(h,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===S||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,d(e,u,"GeneratorFunction")),e.prototype=Object.create(A),e},t.awrap=function(e){return{__await:e}},w(T.prototype),d(T.prototype,c,(function(){return this})),t.AsyncIterator=T,t.async=function(e,n,a,o,i){void 0===i&&(i=Promise);var s=new T(g(e,n,a,o),i);return t.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},w(A),d(A,u,"Generator"),d(A,l,(function(){return this})),d(A,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var a in t)n.push(a);return n.reverse(),function e(){for(;n.length;){var a=n.pop();if(a in t)return e.value=a,e.done=!1,e}return e.done=!0,e}},t.values=P,_.prototype={constructor:_,reset:function(e){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(O),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(n,a){return s.type="throw",s.arg=e,t.next=n,a&&(t.method="next",t.arg=void 0),!!a}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var r=i.call(o,"catchLoc"),l=i.call(o,"finallyLoc");if(r&&l){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(r){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&i.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=e,s.arg=t,o?(this.method="next",this.next=o.finallyLoc,y):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),O(n),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var a=n.completion;if("throw"===a.type){var o=a.arg;O(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:P(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),y}},t}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports},7425:e=>{function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},2841:(e,t,n)=>{var a=n(7609)();e.exports=a;try{regeneratorRuntime=a}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=a:Function("r","regeneratorRuntime = r")(a)}}},t={};function n(a){var o=t[a];if(void 0!==o)return o.exports;var i=t[a]={exports:{}};return e[a].call(i.exports,i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{"use strict";n.r(a),n.d(a,{AdminPortal:()=>Oh,AdminPortalRenderer:()=>Uh,AppHolder:()=>R,CheckoutDialog:()=>_h,FronteggApp:()=>Ih,HostedLogin:()=>kh,LoginBoxRenderer:()=>Rh,createElement:()=>ih,defaultTheme:()=>Lh,formatName:()=>oh,getThemeAdminByName:()=>Ph,getThemeByName:()=>Dh,initialize:()=>Vh,mockFlagsList:()=>Eh,restoreSearchParams:()=>rh,waitThemeSetter:()=>sh});var e={};n.r(e),n.d(e,{getVersion:()=>Y,proxy:()=>J,ref:()=>Z,snapshot:()=>Q,subscribe:()=>X,unstable_buildProxyFunction:()=>ee});var t={};n.r(t),n.d(t,{Delete:()=>it,Get:()=>tt,Patch:()=>at,Post:()=>nt,PostDownload:()=>st,Put:()=>ot,extractHeadersFromOptions:()=>rt,getBaseUrl:()=>Xe,getMetadataHeaders:()=>Qe,getScopedTenant:()=>Ze});var o={};n.r(o),n.d(o,{FeatureFlags:()=>ut,loadFeatureFlags:()=>dt});var i={};n.r(i),n.d(i,{GetUserJwt:()=>gt,getCurrentUserTenantsV1:()=>vt,getCurrentUserTenantsV3:()=>ht,getUsersGroups:()=>St,getUsersRoles:()=>ft,getUsersV2:()=>pt,getUsersV3:()=>yt,sendResetBreachedPasswordEmails:()=>mt,updateUserProfileV2:()=>bt});var s={};n.r(s),n.d(s,{getHierarchyMetadata:()=>Rt,getParentTenants:()=>Pt,getParentTenantsById:()=>Ut,getSubTenants:()=>Ot,getSubTenantsAsTree:()=>_t,getTenants:()=>kt,getTenantsUsersCount:()=>Lt,searchSubTenants:()=>Dt,switchTenant:()=>It});var r={};n.r(r),n.d(r,{loadEntitlementsV2:()=>vn});var l={};n.r(l),n.d(l,{AuthStrategyEnum:()=>rn,MachineToMachineAuthStrategy:()=>ln,OAuthLogout:()=>Jn,SocialLoginProviders:()=>sn,acceptInvitation:()=>Wn,activateAccount:()=>jn,activateAccountV2:()=>Gn,bulkCreateIPRestriction:()=>en,changePhoneNumber:()=>ei,changePhoneNumberWithVerification:()=>Qo,checkIfAllowToRememberMfaDevice:()=>Ao,createDomainRestriction:()=>qt,createIPRestriction:()=>Zt,createOrUpdateSessionConfigrations:()=>oo,createSSOConfiguration:()=>Oo,createSSOConfigurationByMetadata:()=>Uo,createSSOConfigurationByMetadataUrl:()=>Do,createSSODomain:()=>Co,createSSOGroup:()=>Go,createSamlGroup:()=>Va,createTenantAccessToken:()=>po,createUserAccessToken:()=>go,deleteAllSessionsForUser:()=>so,deleteDomainRestriction:()=>Yt,deleteIPRestriction:()=>nn,deleteSSOConfiguration:()=>Po,deleteSSODomain:()=>No,deleteSSOGroup:()=>Vo,deleteSamlGroup:()=>Wa,deleteSessionForUser:()=>io,deleteTenantAccessToken:()=>co,deleteTenantApiToken:()=>vo,deleteUserAccessToken:()=>uo,deleteUserApiToken:()=>mo,deleteWebAuthnDevice:()=>si,disableMFAAuthenticatorApp:()=>ca,disableMFASMS:()=>da,disableMFAWebAuthn:()=>pa,disableMfa:()=>la,enrollMFAAuthenticatorApp:()=>na,enrollMFAAuthenticatorAppForLogin:()=>Sa,enrollMFAAuthenticatorAppForLoginV2:()=>ha,enrollMFASMS:()=>oa,enrollMFASMSForLogin:()=>Ta,enrollMFASMSForLoginV2:()=>Ea,enrollMFAWebAuthn:()=>sa,enrollMFAWebAuthnForLogin:()=>Pa,enrollMFAWebAuthnForLoginV2:()=>Ua,enrollMfa:()=>ea,exchangeOAuthTokens:()=>qo,exchangeOAuthTokensV2:()=>Ko,forgotPassword:()=>Yn,generateLoginResponse:()=>En,generateLoginResponseFromOAuthResponse:()=>Pn,generateLoginResponseFromOAuthResponseV2:()=>Un,generateLoginResponseV2:()=>In,generateLoginResponseV3:()=>_n,generateStepupSession:()=>fi,getActivateAccountStrategy:()=>xn,getCaptchaPolicy:()=>xt,getCurrentUserSession:()=>to,getCurrentUserSessions:()=>eo,getCurrentUserTenantsFunction:()=>Et,getCustomSocialLoginProvidersV1:()=>Ya,getDomainRestrictions:()=>Kt,getDomainRestrictionsConfig:()=>Ht,getGlobalSecurityPolicy:()=>Ct,getIPRestrictions:()=>Xt,getIPRestrictionsConfig:()=>Qt,getLockoutPolicy:()=>$t,getMFADevices:()=>ya,getMFAStrategiesConfig:()=>ui,getMeAndEntitlements:()=>yi,getMeV2:()=>gi,getMfaPolicy:()=>Nt,getOidcConfiguration:()=>za,getPasswordConfigPolicy:()=>zt,getPasswordHistoryPolicy:()=>Vt,getPublicAuthStrategiesConfigForAuthenticatedUser:()=>ci,getSSOConfigurations:()=>ko,getSSODefaultRoles:()=>$o,getSSOGroups:()=>Bo,getSSOPublicConfiguration:()=>Ka,getSamlConfiguration:()=>Ca,getSamlRoles:()=>ja,getSamlRolesGroups:()=>Ga,getSamlVendorConfiguration:()=>Ma,getSessionConfigurations:()=>ao,getSocialLoginProviders:()=>Ha,getSocialLoginProvidersV2:()=>qa,getSocialLoginProvidersV2ForAuthenticatedUser:()=>Ja,getTabTenantFromSessionStorage:()=>Tt,getTenantAccessTokensData:()=>lo,getTenantApiTokensData:()=>fo,getUserAccessTokensData:()=>ro,getUserApiTokensData:()=>yo,getUserAuthorization:()=>di,getUserById:()=>bo,getVendorConfig:()=>Qa,getVendorLockoutPolicy:()=>jt,getVendorMfaPolicy:()=>Mt,getVendorPasswordHistoryPolicy:()=>Bt,getVendorPublicAuthStrategiesConfig:()=>li,getWebAuthnDevices:()=>ii,loadPasswordConfig:()=>Qn,login:()=>Nn,loginViaSocialLogin:()=>Xa,loginWithMfa:()=>Fn,loginWithMfaV2:()=>$n,loginv2:()=>Mn,logout:()=>qn,oidcPostLogin:()=>Cn,oidcPostLoginV2:()=>zo,passwordlessPostLogin:()=>Eo,passwordlessPostLoginV2:()=>To,passwordlessPreLogin:()=>wo,postLogin:()=>Rn,preDisableMFASMS:()=>ua,preDisableMFAWebAuthn:()=>ga,preEnrollMFAAuthenticatorApp:()=>ta,preEnrollMFAAuthenticatorAppForLogin:()=>fa,preEnrollMFASMS:()=>aa,preEnrollMFASMSForLogin:()=>wa,preEnrollMFAWebAuthn:()=>ia,preEnrollMFAWebAuthnForLogin:()=>_a,preLogin:()=>Ln,preLoginV2:()=>Wo,preLoginWithIdpType:()=>Dn,preVerifyMFAEmailCode:()=>ma,preVerifyMFASMSForLogin:()=>Ia,preVerifyMFAWebAuthnForLogin:()=>La,recoverMfaToken:()=>Zn,refreshToken:()=>zn,refreshTokenV2:()=>Kn,refreshTokenV3:()=>Hn,removeTabTenantFromSessionStorage:()=>wt,resendActivationEmail:()=>Vn,resendInvitationEmail:()=>Bn,resetPassword:()=>Xn,resetPhoneNumber:()=>Yo,revokeSessionsForUser:()=>no,saveLockoutPolicy:()=>Gt,saveMfaPolicy:()=>Ft,savePasswordHistoryPolicy:()=>Wt,setSSODefaultRoles:()=>jo,setTabTenantInSessionStorage:()=>At,signUpUser:()=>Za,silentOAuthRefreshToken:()=>Jo,silentOAuthRefreshTokenV2:()=>Ho,testCurrentIp:()=>an,testCurrentIpInAllowList:()=>on,updateDomainRestrictionConfig:()=>Jt,updateIPRestrictionConfig:()=>tn,updateSSOConfiguration:()=>_o,updateSSOConfigurationByMetadata:()=>Lo,updateSSOConfigurationByMetadataUrl:()=>Ro,updateSSOGroup:()=>xo,updateSamlConfiguration:()=>Na,updateSamlGroup:()=>Ba,updateSamlRoles:()=>xa,updateSamlVendorMetadata:()=>Fa,updateTenantApiTokensData:()=>ho,updateUserApiTokensData:()=>So,validateSSODomain:()=>Mo,validateSSODomainV2:()=>Fo,validateSamlDomain:()=>$a,verifyChangePhoneNumber:()=>Zo,verifyInviteToken:()=>Io,verifyMFAAuthenticatorAppForLogin:()=>va,verifyMFAEmailCode:()=>ba,verifyMFAEmailCodeV2:()=>Aa,verifyMFASMSForLogin:()=>ka,verifyMFASMSForLoginV2:()=>Oa,verifyMFAWebAuthnForLogin:()=>Da,verifyMFAWebAuthnForLoginV2:()=>Ra,verifyMfa:()=>ra,verifyNewDeviceSession:()=>ri,verifyResetPhoneNumber:()=>Xo,webAuthnCreateNewDeviceSession:()=>oi,webAuthnPostLogin:()=>ni,webAuthnPostLoginV2:()=>ai,webAuthnPreLogin:()=>ti});var c={};n.r(c),n.d(c,{addUser:()=>Ai,changePassword:()=>mi,createInviteUserLink:()=>Oi,deleteInviteUserLink:()=>Pi,deleteUser:()=>wi,getInviteLinkConfiguration:()=>Li,getInviteUserLink:()=>Ui,getProfile:()=>Si,getTemporaryUserConfiguration:()=>ki,loadAvailablePermissions:()=>Ri,loadAvailableRoles:()=>Di,loadStats:()=>Ci,loadUsers:()=>bi,resendActivationLink:()=>Ni,resendInvitationLink:()=>Mi,resendInvitationLinkToAllTenants:()=>Fi,setPermanentUser:()=>Ii,updateInviteUserLink:()=>_i,updateProfile:()=>hi,updateProfileImage:()=>vi,updateUser:()=>Ti,updateUserExpirationTime:()=>Ei});var u={};n.r(u),n.d(u,{getAdminBoxMetadata:()=>ji,getAuditsMetadata:()=>Wi,getCurrentUserIpMetadata:()=>xi,getIpAdressMetadata:()=>zi,getNotificationsMetadata:()=>Vi,getSamlMetadata:()=>Bi,updateAdminBoxMetadata:()=>Gi});var d={};n.r(d),n.d(d,{downloadReport:()=>Zi,getReport:()=>Yi,getReports:()=>Ji,renderReport:()=>Xi,scheduleReport:()=>Qi,sendReport:()=>es});var g={};n.r(g),n.d(g,{getNotifications:()=>ts,markAllAsRead:()=>os,updateNotificationIsPinned:()=>as,updateNotificationStatus:()=>ns});var p={};n.r(p),n.d(p,{exportAudits:()=>ls,getAudits:()=>ss,getAuditsStats:()=>rs});var y={};n.r(y),n.d(y,{deleteEmailConfiguration:()=>ws,deleteEmailSubscriptions:()=>bs,deleteSMSConfiguration:()=>_s,deleteSMSSubscriptions:()=>ks,deleteSlackConfiguration:()=>fs,deleteWebhooksConfiguration:()=>Ls,getCategories:()=>Ns,getChannelMaps:()=>Ms,getEmailConfiguration:()=>hs,getSMSConfiguration:()=>Ts,getSlackChannels:()=>ps,getSlackConfiguration:()=>ds,getSlackScope:()=>gs,getWebhookLog:()=>Ds,getWebhooksConfigurations:()=>Ps,patchEmailConfiguration:()=>ms,patchSMSConfiguration:()=>Is,postEmailConfiguration:()=>vs,postSMSConfiguration:()=>Es,postSlackCode:()=>Ss,postSlackConfiguration:()=>ys,postWebhookRetry:()=>Cs,postWebhookTest:()=>Rs,postWebhooksConfiguration:()=>Us,putEmailSubscriptions:()=>As,putSMSSubscriptions:()=>Os});var f={};n.r(f),n.d(f,{getPublicSettings:()=>js,getSettings:()=>$s,updateSettings:()=>Fs});var S={};n.r(S),n.d(S,{addRole:()=>Ws,addRoleV2:()=>Xs,attachPermissionToRoles:()=>Js,attachPermissionsToRole:()=>Hs,deleteRole:()=>zs,getPermissionCategories:()=>Ys,getPermissions:()=>qs,getRoles:()=>Bs,updateRole:()=>Ks});var h={};n.r(h),n.d(h,{ISubscriptionCancellationPolicy:()=>Pr,ISubscriptionStatus:()=>Or,PaymentMethodType:()=>_r,ProviderType:()=>Ur,TenantCreatedAction:()=>Dr,TrialEndAction:()=>Lr,cancelManagedSubscription:()=>ir,cancelSubscription:()=>er,createStripeCustomer:()=>mr,createStripePaymentMethodSetupIntentSecret:()=>Ar,createSubscription:()=>hr,createTenantConfiguration:()=>Er,getManagedSubscription:()=>ar,getManagedSubscriptions:()=>or,getPaymentMethod:()=>fr,getPaymentMethods:()=>yr,getPaymentProviders:()=>Ir,getStripeCustomer:()=>vr,getStripePaymentProviderConfiguration:()=>br,getSubscription:()=>Zs,getSubscriptionInvoice:()=>dr,getSubscriptionInvoicePdf:()=>gr,getSubscriptionInvoices:()=>ur,getSubscriptionPlan:()=>cr,getSubscriptionPlans:()=>lr,getSubscriptionSummaries:()=>wr,getSubscriptions:()=>Qs,getTenantConfiguration:()=>Tr,getVendorPublicConfigurations:()=>kr,renewManagedSubscription:()=>sr,renewSubscription:()=>tr,updateManagedSubscription:()=>rr,updatePaymentMethodBillingDetails:()=>Sr,updateSubscription:()=>nr});var v={};n.r(v),n.d(v,{assignUserToApplications:()=>Fr,getApplicationsData:()=>Mr,getTenantsApplications:()=>Nr,getUserApplicationsId:()=>Rr,getUsersApplicationsId:()=>Cr,getUsersOfApplications:()=>jr,unassignUserFromApplications:()=>$r});var m={};n.r(m),n.d(m,{getVendorPublicInfo:()=>Gr});var b={};n.r(b),n.d(b,{addUserRolesForSubTenants:()=>Wr,addUserToTenantAndSubTenants:()=>Vr,addUsersToSubTenant:()=>Qr,createSubTenant:()=>Hr,deleteSubTenant:()=>qr,loadAllUsers:()=>xr,removeUserFromTenantAndSubTenants:()=>Br,removeUserRolesFromSubTenants:()=>zr,setUserRolesForSubTenants:()=>Kr,updateSubAccountAccess:()=>Xr,updateSubTenant:()=>Jr,updateSubTenantManagement:()=>Yr});var A={};n.r(A),n.d(A,{countConfigurationUsers:()=>al,createConfiguration:()=>tl,deleteConfiguration:()=>nl,getConfigs:()=>Zr,updateConfiguration:()=>el});var w={};n.r(w),n.d(w,{impersonate:()=>ol});var T={};n.r(T),n.d(T,{addRolesToGroup:()=>gl,addUsersToGroup:()=>yl,createGroup:()=>cl,deleteGroup:()=>dl,deleteRolesFromGroup:()=>pl,deleteUsersFromGroup:()=>fl,getGroupById:()=>sl,getGroupConfiguration:()=>Sl,getGroups:()=>rl,getGroupsByIds:()=>ll,updateGroup:()=>ul,updateGroupConfiguration:()=>hl});var E={};n.r(E),n.d(E,{getInsights:()=>ml,getRecommendations:()=>vl});var I={};n.r(I),n.d(I,{createPhoneNumber:()=>Al,deletePhoneNumber:()=>wl,getUserPhoneNumbers:()=>bl,preVerifyPhoneNumber:()=>Tl,verifyDeletePhoneNumber:()=>Il,verifyPhoneNumber:()=>El});var k={};n.r(k),n.d(k,{ADMIN_PORTAL_ENTITLEMENTS_FF:()=>bn,ApplicationAccessType:()=>ql,AuthStrategyEnum:()=>rn,ContextHolder:()=>ne,FeatureFlags:()=>ut,FronteggApiError:()=>ce,FronteggContext:()=>ae,FronteggFrameworks:()=>re,GetUsersFilterPreset:()=>xl,GroupManagedByEnum:()=>jl,GroupRelations:()=>$l,ISubscriptionCancellationPolicy:()=>Pr,ISubscriptionStatus:()=>Or,InsightCode:()=>Wl,LOAD_AUTHORIZATION_FF:()=>hn,MFAStrategyEnum:()=>Sn,MachineToMachineAuthStrategy:()=>ln,NotEntitledJustification:()=>mn,PaginationOrderEnum:()=>le,PaymentMethodType:()=>_r,PermissionAssignmentTypeEnum:()=>Pl,ProviderType:()=>Ur,RecommendationActionKey:()=>zl,RecommendationCode:()=>Bl,RecommendationSeverity:()=>Kl,RequestSource:()=>se,RestrictionType:()=>pn,ScimConnectionSource:()=>Fl,SecondaryAuthStrategy:()=>yn,SecurityCategory:()=>Hl,SocialLoginProviders:()=>sn,SortByEnum:()=>Gl,TenantSortByEnum:()=>Ol,TenantType:()=>_l,UserManagedByEnum:()=>kl,WebAuthnDeviceType:()=>fn,api:()=>Jl,countConfigurationUsers:()=>al,createConfiguration:()=>tl,default:()=>Yl,deleteConfiguration:()=>nl,fetch:()=>t,fronteggAuthApiRoutesRegex:()=>Ul,fronteggEntitlementsV2Url:()=>Ml,fronteggHeaders:()=>ie,fronteggRefreshTokenUrl:()=>Ll,fronteggSilentRefreshTokenUrl:()=>Dl,fronteggTenantsUrl:()=>Cl,fronteggTenantsV3Url:()=>Nl,fronteggUsersUrl:()=>Rl,getConfigs:()=>Zr,getCurrentUserTenantsFunction:()=>Et,getTabTenantFromSessionStorage:()=>Tt,loadFeatureFlags:()=>dt,providersArray:()=>Vl,setTabTenantInSessionStorage:()=>At,updateConfiguration:()=>el});var O={};n.r(O),n.d(O,{AccountDetailsPageTabs:()=>bh,AccountPageFields:()=>gh,DomainRestrictionsTabFields:()=>mh,GeneralSettingsTabFields:()=>hh,InviteUserModalFields:()=>dh,IpRestrictionsTabFields:()=>vh,Metadata:()=>ah,PrivacyPageFields:()=>uh,ProfilePageFields:()=>ch,SecurityPageTabs:()=>fh,SessionManagementTabFields:()=>Sh,SignupFields:()=>lh,SubscriptionsPageFields:()=>yh,UsersTableColumns:()=>ph,alpha:()=>YS,fieldAppearance:()=>Ah,tabAppearance:()=>wh});var _={};function P(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function U(e){return U="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},U(e)}function L(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,(o=a.key,i=void 0,i=function(e,t){if("object"!==U(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,t);if("object"!==U(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(o,"string"),"symbol"===U(i)?i:String(i)),a)}var o,i}function D(e,t,n){return t&&L(e.prototype,t),n&&L(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}n.r(_),n.d(_,{ACR_VALUE:()=>lu,AMR_ADDITIONAL_VALUE:()=>uu,AMR_MFA_VALUE:()=>cu,AcceptInvitationStep:()=>nc,ActivateAccountStep:()=>ac,AdminPortalPages:()=>Rc,AdminPortalPagesForEvents:()=>Dc,AllAccountsStateKeys:()=>wc,ApiStateKeys:()=>oc,AuthStrategyEnum:()=>rn,AuthenticationTypes:()=>Lc,FRONTEGG_AFTER_AUTH_REDIRECT_URL:()=>pu,ForgotPasswordStep:()=>pc,FronteggNativeModule:()=>$d,GTMEventAction:()=>Hc,GroupRelations:()=>fc,GroupsStateKeys:()=>yc,HOSTED_LOGIN_VERIFIER_KEY:()=>yu,ImpersonateStep:()=>Sc,LoginActionTypes:()=>bc,LoginFlow:()=>vc,LoginStep:()=>hc,MFAStep:()=>Ac,MachineToMachineAuthStrategy:()=>ln,PaymentMethodType:()=>wy,PaymentProvider:()=>Iy,QuickLoginStrategy:()=>mc,ResetPhoneNumberStep:()=>Tc,RolesStateKeys:()=>Ec,SHOULD_STEP_UP_KEY:()=>du,SSOStateKeys:()=>Oc,STEP_UP_MAX_AGE_PARAM_NAME:()=>gu,SamlVendors:()=>_c,SecurityCenterStateKeys:()=>Ic,SignUpStage:()=>kc,SubscriptionCancellationPolicy:()=>Oy,SubscriptionStatus:()=>ky,TENANT_ID_PARAM_KEY:()=>nu,TeamStateKeys:()=>Pc,UserVeirifedOriginTypes:()=>Uc,authStrategyLoginStepMap:()=>Jc,base64ToFormData:()=>Sd,base64urlDecode:()=>fd,base64urlEncode:()=>yd,buildAuditsActions:()=>ff,buildAuthActions:()=>yy,buildConnectivityActions:()=>Ay,buildSubscriptionsActions:()=>af,buildVendorActions:()=>rf,createAuditsState:()=>yf,createAuthState:()=>py,createConnectivityState:()=>Sy,createFronteggStore:()=>WS,createRandomString:()=>Fd,createStore:()=>zS,createSubscriptionsState:()=>nf,createVendorState:()=>sf,deepClone:()=>Xl,defaultFronteggRoutes:()=>Yc,delay:()=>Ql,errorHandler:()=>Gc,extractPhoneNumber:()=>Tu,generateCodeChallenge:()=>Md,generateCodeChallengeNative:()=>Nd,generateCodeChallengePureJs:()=>Cd,getEntitlements:()=>dc,getFeatureEntitlements:()=>uc,getMfaStepForEnrolledUsers:()=>ou,getMfaStepForNotEnrolledUsers:()=>iu,getNumberOfMfaDevices:()=>au,getPathAndSearchParamsFromUrl:()=>eu,getPermissionEntitlements:()=>cc,getRedirectUrl:()=>Qc,getSearchParam:()=>tu,getSearchParamsFromUrl:()=>Zc,getUri:()=>wu,isAbsoluteUrl:()=>Xc,isAuthRoute:()=>Eu,isEmailPayload:()=>ru,isEntitlementsDeeplyEqual:()=>gc,isError:()=>jc,isMfaRequired:()=>bu,isOauthCallbackRoute:()=>su,isProxy:()=>tc,isSteppedUp:()=>fu,mapMetaDataObjectToActions:()=>Au,omitProps:()=>ec,publicKeyCredentialToJSON:()=>hd,readFileAsText:()=>vd,redirectByStepUpUrl:()=>hu,reportGTMEvent:()=>qc,retry:()=>Zl,setAfterAuthRedirectUrlForStepUp:()=>Su,snapshot:()=>Q,subscribe:()=>X});var R=function(){function e(){P(this,e)}return D(e,null,[{key:"setInstance",value:function(t,n){e._apps[t]=n}},{key:"getInstance",value:function(t){var n=e._apps[t];if(!n)throw Error("[".concat(t,"] FronteggApp not found"));return n}}]),e}();function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}function N(e,t,n,a,o,i,s){try{var r=e[i](s),l=r.value}catch(e){return void n(e)}r.done?t(l):Promise.resolve(l).then(a,o)}function M(e){return function(){var t=this,n=arguments;return new Promise((function(a,o){var i=e.apply(t,n);function s(e){N(i,a,o,s,r,"next",e)}function r(e){N(i,a,o,s,r,"throw",e)}s(void 0)}))}}R._apps={};var F=n(2841),$=n.n(F);function j(){return j=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},j.apply(this,arguments)}Symbol();const G=Symbol(),x=Object.getPrototypeOf,V=new WeakMap,B=(e,t=!0)=>{V.set(e,t)},W=e=>"object"==typeof e&&null!==e,z=new WeakMap,K=new WeakSet,H=(e=Object.is,t=((e,t)=>new Proxy(e,t)),n=(e=>W(e)&&!K.has(e)&&(Array.isArray(e)||!(Symbol.iterator in e))&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof Error)&&!(e instanceof Number)&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof RegExp)&&!(e instanceof ArrayBuffer)),a=(e=>{switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e}}),o=new WeakMap,i=((e,t,n=a)=>{const s=o.get(e);if((null==s?void 0:s[0])===t)return s[1];const r=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return B(r,!0),o.set(e,[t,r]),Reflect.ownKeys(e).forEach((t=>{if(Object.getOwnPropertyDescriptor(r,t))return;const a=Reflect.get(e,t),{enumerable:o}=Reflect.getOwnPropertyDescriptor(e,t),s={value:a,enumerable:o,configurable:!0};if(K.has(a))B(a,!1);else if(a instanceof Promise)delete s.value,s.get=()=>n(a);else if(z.has(a)){const[e,t]=z.get(a);s.value=i(e,t(),n)}Object.defineProperty(r,t,s)})),Object.preventExtensions(r)}),s=new WeakMap,r=[1,1],l=(a=>{if(!W(a))throw new Error("object required");const o=s.get(a);if(o)return o;let c=r[0];const u=new Set,d=(e,t=++r[0])=>{c!==t&&(c=t,u.forEach((n=>n(e,t))))};let g=r[1];const p=e=>(t,n)=>{const a=[...t];a[1]=[e,...a[1]],d(a,n)},y=new Map,f=e=>{var t;const n=y.get(e);n&&(y.delete(e),null==(t=n[1])||t.call(n))},S=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a)),h=t(S,{deleteProperty(e,t){const n=Reflect.get(e,t);f(t);const a=Reflect.deleteProperty(e,t);return a&&d(["delete",[t],n]),a},set(t,a,o,i){const r=Reflect.has(t,a),c=Reflect.get(t,a,i);if(r&&(e(c,o)||s.has(o)&&e(c,s.get(o))))return!0;var g;f(a),W(o)&&(o=(e=>e&&(V.has(e)?V.get(e):x(e)===Object.prototype||x(e)===Array.prototype))(g=o)&&g[G]||null||o);let S=o;if(o instanceof Promise)o.then((e=>{o.status="fulfilled",o.value=e,d(["resolve",[a],e])})).catch((e=>{o.status="rejected",o.reason=e,d(["reject",[a],e])}));else{!z.has(o)&&n(o)&&(S=l(o));const e=!K.has(S)&&z.get(S);e&&((e,t)=>{if(y.has(e))throw new Error("prop listener already exists");if(u.size){const n=t[3](p(e));y.set(e,[t,n])}else y.set(e,[t])})(a,e)}return Reflect.set(t,a,S,i),d(["set",[a],o,c]),!0}});s.set(a,h);const v=[S,(e=++r[1])=>(g===e||u.size||(g=e,y.forEach((([t])=>{const n=t[1](e);n>c&&(c=n)}))),c),i,e=>(u.add(e),1===u.size&&y.forEach((([e,t],n)=>{if(t)throw new Error("remove already exists");const a=e[3](p(n));y.set(n,[e,a])})),()=>{u.delete(e),0===u.size&&y.forEach((([e,t],n)=>{t&&(t(),y.set(n,[e]))}))})];return z.set(h,v),Reflect.ownKeys(a).forEach((e=>{const t=Object.getOwnPropertyDescriptor(a,e);"value"in t&&(h[e]=a[e],delete t.value,delete t.writable),Object.defineProperty(S,e,t)})),h}))=>[l,z,K,e,t,n,a,o,i,s,r],[q]=H();function J(e={}){return q(e)}function Y(e){const t=z.get(e);return null==t?void 0:t[1]()}function X(e,t,n){const a=z.get(e);let o;a||console.warn("Please use proxy object");const i=[],s=a[3];let r=!1;const l=s((e=>{i.push(e),n?t(i.splice(0)):o||(o=Promise.resolve().then((()=>{o=void 0,r&&t(i.splice(0))})))}));return r=!0,()=>{r=!1,l()}}function Q(e,t){const n=z.get(e);n||console.warn("Please use proxy object");const[a,o,i]=n;return i(a,o(),t)}function Z(e){return K.add(e),e}const ee=H,te=Symbol();class ne{constructor(){this.context=null,this.accessToken=null,this.user=null,this.requestSource=null,this.onRedirectTo=e=>window.location.href=e,this.logout=()=>window.location.href="/account/logout",this.entitlementsOptions=null,this.appName=null,this.sessionContext=void 0}static getInstance(){return ne.instance||(ne.instance=new ne),ne.instance}static setContext(e){ne.getInstance().context=e}static setAccessToken(e){ne.getInstance().accessToken=e}static setUser(e){ne.getInstance().user=e}static setRequestSource(e){ne.getInstance().requestSource=e}static setOnRedirectTo(e){ne.getInstance().onRedirectTo=e}static setLogout(e,t){ne.getInstance().logout=n=>{n?e(n):ne.onRedirectTo(t)}}static setEntitlementsOptions(e){ne.getInstance().entitlementsOptions=e}static setSessionContext(e){ne.getInstance().sessionContext=e}static setAppName(e){ne.getInstance().appName=e}static getContext(){var e;return null!=(e=ne.getInstance().context)?e:{baseUrl:window.location.href,tokenResolver:()=>"my-authentication-token",logLevel:"error"}}static getAccessToken(){return ne.getInstance().accessToken}static getRequestSource(){return ne.getInstance().requestSource}static getUser(){return ne.getInstance().user}static onRedirectTo(e,t){return ne.getInstance().onRedirectTo(e,t)}static logout(e){return ne.getInstance().logout(e)}static shouldLoadEntitlements(){var e;return(null==(e=ne.getInstance().entitlementsOptions)?void 0:e.enabled)||!1}static isSessionPerTenantEnabled(){var e;return(null==(e=ne.getInstance().sessionContext)?void 0:e.enableSessionPerTenant)||!1}static getAppName(){return ne.getInstance().appName}}ne.instance=void 0;const ae={getContext:()=>ne.getContext(),getAccessToken:()=>ne.getAccessToken(),getUser:()=>ne.getUser(),onRedirectTo:(e,t)=>ne.onRedirectTo(e,t),logout:e=>ne.logout(e)};function oe(e,t){if(null==e)return{};var n,a,o={},i=Object.keys(e);for(a=0;a<i.length;a++)n=i[a],t.indexOf(n)>=0||(o[n]=e[n]);return o}const ie={frameWork:"x-frontegg-framework",fronteggSdkVersion:"x-frontegg-sdk",contentType:"Content-Type",source:"frontegg-source",scopedTenant:"frontegg-scoped-tenant"};let se,re,le;!function(e){e.AdminPortal="admin-portal",e.LoginBox="login-box"}(se||(se={})),function(e){e.Nextjs="nextjs",e.React="react",e.Angular="angular",e.Vuejs="vuejs",e.Flutter="flutter",e.Ios="ios",e.Android="android",e.Vanillajs="vanillajs"}(re||(re={})),function(e){e.ASC="ASC",e.DESC="DESC"}(le||(le={}));class ce extends Error{constructor(e,t){super(e),this._statusCode=void 0,this._statusCode=t}get statusCode(){return this._statusCode}}const ue={v1:"/identity/resources/users/webauthn/v1/devices"},de={v1:"/identity/resources/auth/v1",v2:"/identity/resources/auth/v2"},ge={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"}}},pe={v1:"/identity/resources/configurations/v1"},ye={emailDomain:{v1:"/identity/resources/configurations/restrictions/v1/email-domain"},ip:{v1:"/identity/resources/configurations/v1/restrictions/ip"}},fe={v1:"/identity/resources/sso/v1",v2:"/identity/resources/sso/v2",custom:{v1:"/identity/resources/sso/custom/v1"}},Se={v1:"/identity/resources/permissions/v1"},he={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"}},ve={v1:"/identity/resources/roles/v1",v2:"/identity/resources/roles/v2"},me={v1:"/identity/resources/sub-tenants/users/v1",v2:"/identity/resources/sub-tenants/users/v2"},be={v1:"/identity/resources/impersonation/v1"},Ae={v1:"/identity/resources/applications/v1"},we={v1:"/identity/resources/groups/v1",configurations:{v1:"/identity/resources/groups/v1/config"},getByIds:{v1:"/identity/resources/groups/v1/bulkGet"}},Te={v1:"/identity/resources/users/phone-numbers/v1"},Ee={v1:"/team/resources/sso/v1",v2:"/team/resources/sso/v2"},Ie={v1:"/team/resources/members/v1"},ke={v1:"/team/resources/roles/v1"},Oe={v1:"/team/resources/stats/v1"},_e={v1:"/team/resources/profile"},Pe={v1:"/tenants/resources/account-settings/v1"},Ue={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"}},Le={v1:"/tenants/resources/sub-tenants/v1"},De={v1:"/integrations/resources/configurations/v1",v2:"/integrations/resources/configurations/v2"},Re={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"}}}},Ce={v1:"/subscriptions/resources/payment-providers/v1"},Ne={v1:"/subscriptions/resources/subscriptions/v1"},Me={v1:"/reports/resources/reports/v1",v2:"/reports/resources/reports/v2"},Fe={v1:"/reports/engine/resources/triggers/v1"},$e="/notification",je="/audits",Ge={v1:"/event/resources/configurations/v1"},xe="/webhook",Ve="/oauth",Be="/flags",We="/directory/resources/v1/configurations/scim2",ze="/directory/resources/scim/temp",Ke="/entitlements/api/v2/user-entitlements",He={v1:"/security-center/resources/recommendations/v1"},qe={v1:"/security-center/resources/insights/v1"},Je="/applications/resources/applications/v1",Ye={v1:"/applications/resources/applications/tenant-assignments/v1"};function Xe(e,t,n=!0){let a;a="function"==typeof e.baseUrl?e.baseUrl(t):e.baseUrl;const o=e.urlPrefix||"frontegg",i="frontegg"===o&&!n;return a.endsWith("/")||(a+="/"),a.endsWith(o)||i||(a+=o),a}function Qe(e){var t,n;const a={};return null!=e&&null!=(t=e.metadataHeaders)&&t.fronteggSdkVersion&&(a[ie.fronteggSdkVersion]=e.metadataHeaders.fronteggSdkVersion),null!=e&&null!=(n=e.metadataHeaders)&&n.framework&&(a[ie.frameWork]=e.metadataHeaders.framework),a}function Ze(){return new URLSearchParams(window.location.search).get("tenantId")||null}const et=async e=>{var t,n,a;const o=ne.getContext(),i=await async function(e,t){var n;const a=Qe(e),o=await(null!=(n=null==e?void 0:e.tokenResolver)?n:ne.getAccessToken)(),i=ne.getRequestSource(),s=Ze();t&&(a[ie.contentType]=t),i&&(a[ie.source]=i),o&&(a.Authorization=`Bearer ${o}`),s&&(a[ie.scopedTenant]=s);for(const t of await async function(e){let t=[];if(e.additionalHeadersResolver&&(t=await e.additionalHeadersResolver()),e.tenantResolver){const n=await e.tenantResolver();null!=n&&n.tenant&&t.push({key:"frontegg-login-alias",value:n.tenant})}return e.appId&&t.push({key:"frontegg-requested-application-id",value:e.appId}),t}(e))a[`${t.key}`]=`${t.value}`;return a}(o,e.contentType),s=await async function(e,t,n){const a=Xe(e,t),o=await async function(e,t){t||(t={});const n=await async function(e){let t=[];return e.additionalQueryParamsResolver&&(t=await e.additionalQueryParamsResolver()),t}(e);for(const e of n)t[e.key]=e.value;const a=Object.keys(t);for(const e of a){const n=t[e];t[e]="object"==typeof n?JSON.stringify(n):n}return t}(e,n);let i=t.startsWith("http")?t:`${a}${t}`;const s=Object.keys(o).length>0;return o&&s&&(i+=`?${new URLSearchParams(o)}`),i}(o,e.url,e.params),r=await fetch(s,{body:e.body?"application/json"===e.contentType?JSON.stringify(e.body):e.body:null,method:null!=(t=e.method)?t:"GET",headers:j({},i,e.headers),credentials:null!=(n=null!=(a=e.credentials)?a:o.requestCredentials)?n:"same-origin"});if(302===r.status)return window.location.href=await r.text(),new Promise((()=>{}));if(!r.ok){var l,c;if(413===r.status)throw new ce("Error request is too large",r.status);let e,t=!0;try{e=await r.text(),e=JSON.parse(e)}catch(e){t=!1}throw e.errors?e=e.errors.join(", "):"string"!=typeof e&&(e=`Error ${r.status} - ${r.statusText}`),r.status>=400&&r.status<500&&["warn"].includes(null!=(l=o.logLevel)?l:"")?console.warn(e):500===r.status&&["warn","error"].includes(null!=(c=o.logLevel)?c:"")&&console.error(e),new ce(t?e:"We're facing some difficulties, Please try again",r.status)}if(e.responseType&&"json"!==e.responseType){if("blob"===e.responseType){const{outputFileName:t}=e.params;return await r.blob().then((e=>URL.createObjectURL(e))).then((e=>{const n=document.createElement("a");n.href=e,n.setAttribute("download",t||"output"),n.click()}))}return await r.text()}try{return await r.json()}catch(e){return{}}},tt=async(e,t,n)=>et(j({url:e,method:"GET",contentType:"application/json",params:t},n)),nt=async(e,t,n)=>et(j({url:e,method:"POST",contentType:"application/json",body:t},n)),at=async(e,t,n)=>et(j({url:e,method:"PATCH",contentType:"application/json",body:t},n)),ot=async(e,t,n)=>et(j({url:e,method:"PUT",contentType:"application/json",body:t},n)),it=async(e,t,n)=>et(j({url:e,method:"DELETE",contentType:"application/json",body:t},n)),st=async(e,t,n,a)=>et(j({url:e,method:"POST",contentType:"application/json",responseType:"blob",body:t,params:n},a)),rt=(e={})=>j({},e.jwt?{Authorization:e.jwt}:{}),lt="FRONTEGG_SEPARATE_TABS_BY_TENANT",ct={flags:{}};class ut{constructor(){var e;this._flags={},this._flags=null!=(e=ct.flags)?e:{}}static getInstance(e="default"){return this._instances[e]}static set(e,t="default"){const n=new ut;return n.set(e),ut._instances[t]=n,n}static getFeatureFlags(e,t){const n=this.getInstance(t);return e.map((e=>"on"===(null==n?void 0:n._flags[e])))}get flags(){var e;return null!=(e=this.flags)?e:{}}set(e){var t;this._flags=j({},null!=(t=null==ct?void 0:ct.flags)?t:{},null!=e?e:{})}}async function dt(){return tt(Be)}async function gt(e){return nt(`${ge.v3}/me/token`,e)}async function pt(e,t){return tt(ge.v2,e,{headers:rt(t)})}async function yt(e,t){return tt(ge.v3,e,{headers:rt(t)})}async function ft(e,t){return tt(ge.roles.v3,j({},e,{ids:e.ids.join(",")}),{headers:rt(t)})}async function St(e,t){return tt(ge.groups.v3,j({},e,{ids:e.ids.join(",")}),{headers:rt(t)})}async function ht(e){return tt(ge.tenants.me.v3,void 0,{headers:rt(e)})}async function vt(e){return tt(ge.tenants.me.v1,void 0,{headers:rt(e)})}async function mt(){return nt(ge.passwords.resetBreachedPasswords.v1)}async function bt(e){return ot(`${ge.v2}/me`,e)}function At(e){e&&sessionStorage.setItem(lt,e)}function wt(){sessionStorage.removeItem(lt)}function Tt(){return ne.isSessionPerTenantEnabled()?sessionStorage.getItem(lt):null}function Et(){const[e]=ut.getFeatureFlags(["admin_portal_use_current_user_tenants_v1_endpoint"],ne.getAppName()||"");return ne.isSessionPerTenantEnabled()||e?vt:ht}async function It(e){return ne.isSessionPerTenantEnabled()&&At(e.tenantId),ot(`${ge.v1}/tenant`,e)}async function kt(){return tt(`${ge.v2}/me/tenants`)}async function Ot(e){return tt(Ue.v1,void 0,{headers:rt(e)})}async function _t(e){return tt(Ue.tree.v1,void 0,{headers:rt(e)})}async function Pt(e){return tt(Ue.parents.v1,void 0,{headers:rt(e)})}async function Ut(e,t){return tt(`${Ue.parents.v1}/${e}`,void 0,{headers:rt(t)})}async function Lt(e,t){return nt(`${he.users.v1}/count`,e,{headers:rt(t)})}async function Dt(e,t){return tt(Ue.v2,e,{headers:rt(t)})}async function Rt(e,t){return tt(Ue.metadata.v2,j({},e,{_tenantIds:e._tenantIds.join(",")}),{headers:rt(t)})}async function Ct(){return tt(pe.v1)}async function Nt(){return tt(`${pe.v1}/mfa-policy`)}async function Mt(){return tt(`${pe.v1}/mfa-policy/vendor`)}async function Ft(e){return e.id?at(`${pe.v1}/mfa-policy`,e):nt(`${pe.v1}/mfa-policy`,e)}async function $t(){return tt(`${pe.v1}/lockout-policy`)}async function jt(){return tt(`${pe.v1}/lockout-policy/vendor`)}async function Gt(e){return e.id?at(`${pe.v1}/lockout-policy`,e):nt(`${pe.v1}/lockout-policy`,e)}async function xt(){try{return await tt(`${pe.v1}/captcha-policy/public`)}catch{return null}}async function Vt(){return tt(`${pe.v1}/password-history-policy`)}async function Bt(){return tt(`${pe.v1}/password-history-policy/vendor`)}async function Wt(e){return e.id?at(`${pe.v1}/password-history-policy`,e):nt(`${pe.v1}/password-history-policy`,e)}async function zt(){return tt(`${pe.v1}/password`)}async function Kt(){return tt(`${ye.emailDomain.v1}`)}async function Ht(){return tt(`${ye.emailDomain.v1}/config`)}async function qt(e){return nt(`${ye.emailDomain.v1}`,e)}async function Jt(e){return nt(`${ye.emailDomain.v1}/config`,e)}async function Yt(e){return it(`${ye.emailDomain.v1}/${e}`)}async function Xt(e){return tt(`${ye.ip.v1}`,e)}async function Qt(){return tt(`${ye.ip.v1}/config`)}async function Zt(e){return nt(`${ye.ip.v1}`,e)}async function en(e){return nt(`${ye.ip.v1}/bulk`,e)}async function tn(e){return nt(`${ye.ip.v1}/config`,e)}async function nn(e){return it(`${ye.ip.v1}/${e}`)}async function an(){return nt(`${ye.ip.v1}/verify`)}async function on(){return nt(`${ye.ip.v1}/verify/allow`)}let sn,rn,ln;ut._instances={},function(e){e.Microsoft="microsoft",e.Facebook="facebook",e.Google="google",e.Github="github",e.Slack="slack",e.Apple="apple",e.Linkedin="linkedin"}(sn||(sn={})),function(e){e.EmailAndPassword="EmailAndPassword",e.MagicLink="MagicLink",e.Code="Code",e.NoLocalAuthentication="NoLocalAuthentication",e.SmsCode="SmsCode"}(rn||(rn={})),function(e){e.ClientCredentials="ClientCredentials",e.AccessToken="AccessToken"}(ln||(ln={}));class cn extends Error{constructor(e){super(e)}}const un="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){const t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new cn("'atob' failed: The string to be decoded is not correctly encoded.");let n="";for(let e,a,o=0,i=0;a=t.charAt(i++);~a&&(e=o%4?64*e+a:a,o++%4)?n+=String.fromCharCode(255&e>>(-2*o&6)):0)a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a);return n};class dn extends Error{constructor(e){super(e)}}const gn=(e,t={})=>{const n=t.header?0:1;try{return JSON.parse((e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("Illegal base64url string!")}try{return function(e){return decodeURIComponent(un(e).replace(/(.)/g,((e,t)=>{let n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return un(t)}})(e.split(".")[n]))}catch(e){throw new dn("Invalid token specified: "+e.message)}};let pn,yn,fn,Sn;!function(e){e.ALLOW="ALLOW",e.BLOCK="BLOCK"}(pn||(pn={})),function(e){e.WebAuthnPlatform="WebAuthnPlatform",e.WebAuthnCrossPlatform="WebAuthnCrossPlatform",e.SmsCode="SmsCode",e.SmsCodeV2="SmsCodeV2",e.Passkeys="Passkeys"}(yn||(yn={})),function(e){e.Platform="Platform",e.CrossPlatform="CrossPlatform"}(fn||(fn={})),function(e){e.AuthenticatorApp="AuthenticatorApp",e.WebAuthnPlatform="WebAuthnPlatform",e.WebAuthnCrossPlatform="WebAuthnCrossPlatform",e.SMS="SMS",e.EmailCode="EmailCode"}(Sn||(Sn={}));const hn="admin_portal_should_load_authorization";async function vn(){return tt(Ke)}let mn;!function(e){e.MISSING_PERMISSION="MISSING_PERMISSION",e.MISSING_FEATURE="MISSING_FEATURE",e.BUNDLE_EXPIRED="BUNDLE_EXPIRED"}(mn||(mn={}));const bn="admin_portal_entitlements",An=["type"],wn=["type"],Tn=["type"];async function En(e){if(!e.accessToken)return e;ne.setAccessToken(e.accessToken);const t=await yi(),n=j({},e,e.accessToken?gn(e.accessToken):{},t);return ne.setUser(n),n}async function In(e){if(!e.accessToken)return{user:e};ne.setAccessToken(e.accessToken);const[t,n]=await Promise.all([yi(),kt()]),a=j({},e,e.accessToken?gn(e.accessToken):{},t);return ne.setUser(a),{user:a,tenants:n}}function kn(){if(!ne.shouldLoadEntitlements())return!1;const[e]=ut.getFeatureFlags([bn],ne.getAppName()||"");return e}function On(){const[e]=ut.getFeatureFlags([hn],ne.getAppName()||"");return e}async function _n(e){const{accessToken:t}=e;if(!t)return{user:e};ne.setAccessToken(t);const[n,a]=await Promise.all([yi(),Et()()]),o=j({},e,t?gn(t):{},n);return ne.isSessionPerTenantEnabled()&&At(o.tenantId),ne.setUser(o),{user:o,tenants:a.tenants,activeTenant:a.activeTenant}}async function Pn(e){ne.setAccessToken(e.id_token);const t=await yi(),n=e.id_token?gn(e.id_token):{},a=j({mfaRequired:!1,accessToken:e.id_token,refreshToken:e.refresh_token},n,t,{expiresIn:e.expires_in||300});return ne.setUser(a),a}async function Un(e){ne.setAccessToken(e.id_token);const[t,n]=await Promise.all([yi(),Et()()]),a=e.id_token?gn(e.id_token):{},o=j({mfaRequired:!1,accessToken:e.id_token,refreshToken:e.refresh_token},a,t,{expiresIn:e.expires_in||300});return ne.isSessionPerTenantEnabled()&&At(o.tenantId),ne.setUser(o),{user:o,tenants:n.tenants,activeTenant:n.activeTenant}}async function Ln(e){try{const{address:t}=await nt(`${de.v1}/user/saml/prelogin`,e);return t}catch{return null}}async function Dn(e){return nt(`${de.v1}/user/saml/prelogin`,e)}async function Rn(e){return En(await nt(`${de.v1}/user/saml/postlogin`,e))}async function Cn(e){return En(await nt(`${de.v1}/user/oidc/postlogin`,e))}async function Nn(e){return En(await nt(`${de.v1}/user`,e))}async function Mn(e){return _n(await nt(`${de.v1}/user`,e))}async function Fn(e){return En(await nt(`${de.v1}/user/mfa/verify`,e))}async function $n(e){return _n(await nt(`${de.v1}/user/mfa/verify`,e))}async function jn(e){return nt(`${ge.v1}/activate`,e)}async function Gn(e){return _n(await nt(`${ge.v1}/activate`,e))}async function xn(e){return tt(`${ge.v1}/activate/strategy`,e)}async function Vn(e){return nt(`${ge.v1}/activate/reset`,e)}async function Bn(e){return nt(`${ge.v1}/invitation/reset`,e)}async function Wn(e){return nt(`${ge.v1}/invitation/accept`,e)}async function zn(){const e=Tt();return En(await nt(`${de.v1}/user/token/refresh`,{tenantId:e}))}async function Kn(){const e=Tt();return In(await nt(`${de.v1}/user/token/refresh`,{tenantId:e}))}async function Hn(){const e=Tt();return _n(await nt(`${de.v1}/user/token/refresh`,{tenantId:e}))}async function qn(){return nt(`${de.v1}/logout`)}async function Jn(e){return tt(`${Ve}/logout`,e)}async function Yn(e){return nt(`${ge.v1}/passwords/reset`,e)}async function Xn(e){return nt(`${ge.v1}/passwords/reset/verify`,e)}async function Qn(e){return tt(`${ge.v1}/passwords/config`,e)}async function Zn(e){return nt(`${de.v1}/user/mfa/recover`,e)}async function ea(){return nt(`${ge.v1}/mfa/enroll`)}async function ta(){return nt(`${ge.v1}/mfa/authenticator/enroll`)}async function na(e){return nt(`${ge.v1}/mfa/authenticator/enroll/verify`,e)}async function aa(e){return nt(`${ge.v1}/mfa/sms/enroll`,e)}async function oa(e){return nt(`${ge.v1}/mfa/sms/enroll/verify`,e)}async function ia(){return nt(`${ge.v1}/mfa/webauthn/enroll`)}async function sa(e){return nt(`${ge.v1}/mfa/webauthn/enroll/verify`,e)}async function ra(e){return nt(`${ge.v1}/mfa/enroll/verify`,e)}async function la(e){return nt(`${ge.v1}/mfa/disable`,e)}async function ca(e,t){return nt(`${ge.v1}/mfa/authenticator/${e}/disable/verify`,t)}async function ua(e){return nt(`${ge.v1}/mfa/sms/${e}/disable`)}async function da(e,t){return nt(`${ge.v1}/mfa/sms/${e}/disable/verify`,t)}async function ga(e){return nt(`${ge.v1}/mfa/webauthn/${e}/disable`)}async function pa(e,t){return nt(`${ge.v1}/mfa/webauthn/${e}/disable/verify`,t)}async function ya(){return tt(`${ge.v1}/mfa/devices`)}async function fa(e){return nt(`${de.v1}/user/mfa/authenticator/enroll`,e)}async function Sa(e){return nt(`${de.v1}/user/mfa/authenticator/enroll/verify`,e)}async function ha(e){return _n(await nt(`${de.v1}/user/mfa/authenticator/enroll/verify`,e))}async function va(e,t){return nt(`${de.v1}/user/mfa/authenticator/${e}/verify`,t)}async function ma(e){return nt(`${de.v1}/user/mfa/emailcode`,e)}async function ba(e){return nt(`${de.v1}/user/mfa/emailcode/verify`,e)}async function Aa(e){return _n(await nt(`${de.v1}/user/mfa/emailcode/verify`,e))}async function wa(e){return nt(`${de.v1}/user/mfa/sms/enroll`,e)}async function Ta(e){return nt(`${de.v1}/user/mfa/sms/enroll/verify`,e)}async function Ea(e){return _n(await nt(`${de.v1}/user/mfa/sms/enroll/verify`,e))}async function Ia(e,t){return nt(`${de.v1}/user/mfa/sms/${e}`,t)}async function ka(e,t){return nt(`${de.v1}/user/mfa/sms/${e}/verify`,t)}async function Oa(e,t){return _n(await nt(`${de.v1}/user/mfa/sms/${e}/verify`,t))}async function _a(e){return nt(`${de.v1}/user/mfa/webauthn/enroll`,e)}async function Pa(e){return nt(`${de.v1}/user/mfa/webauthn/enroll/verify`,e)}async function Ua(e){return _n(await nt(`${de.v1}/user/mfa/webauthn/enroll/verify`,e))}async function La(e,t){return nt(`${de.v1}/user/mfa/webauthn/${e}`,t)}async function Da(e,t){return nt(`${de.v1}/user/mfa/webauthn/${e}/verify`,t)}async function Ra(e,t){return _n(await nt(`${de.v1}/user/mfa/webauthn/${e}/verify`,t))}async function Ca(){return tt(`${Ee.v1}/saml/configurations`)}async function Na(e){return nt(`${Ee.v1}/saml/configurations`,e)}async function Ma(){return tt(`${Ee.v1}/saml/configurations/vendor-config`)}async function Fa(e){return ot(`${Ee.v1}/saml/configurations/metadata`,e)}async function $a(){return ot(`${Ee.v1}/saml/validations/domain`)}async function ja(){return tt(`${Ee.v1}/saml/configurations/roles/default`)}async function Ga(){return tt(`${Ee.v2}/saml/configurations/groups`)}async function xa({roleIds:e}){return nt(`${Ee.v1}/saml/configurations/roles/default`,{roleIds:e})}async function Va({roleIds:e,group:t}){return nt(`${Ee.v2}/saml/configurations/groups`,{group:t,roleIds:e})}async function Ba({roleIds:e,group:t,id:n}){return at(`${Ee.v2}/saml/configurations/groups/${n}`,{group:t,roleIds:e})}async function Wa({id:e}){return it(`${Ee.v2}/saml/configurations/groups/${e}`)}async function za(){return tt(`${Ee.v1}/oidc/configurations`)}async function Ka(){return tt(`${Ee.v2}/configurations/public`)}async function Ha(){return tt(fe.v1)}async function qa(){return tt(fe.v2)}async function Ja(){return tt(`${fe.v2}/authenticated`)}async function Ya(){return tt(fe.custom.v1)}async function Xa({provider:e,code:t,idToken:n,redirectUri:a,codeVerifier:o,metadata:i,invitationToken:s,state:r}){const l={};return t&&(l.code=t),n&&(l.id_token=n),a&&(l.redirectUri=a),o&&(l.code_verifier=o),r&&(l.state=r),nt(`${de.v1}/user/sso/${e}/postlogin`,{metadata:i,invitationToken:s},{params:l})}async function Qa(){return tt(`${pe.v1}/public`)}async function Za(e){const{shouldActivate:t,authResponse:n,userId:a,tenantId:o}=await nt(`${ge.v1}/signUp`,e),i={shouldActivate:t,userId:a,tenantId:o};if(!t&&n){const{user:e,tenants:t,activeTenant:a}=await _n(n);return j({},i,{user:e,tenants:t,activeTenant:a})}return i}async function eo(){return tt(ge.sessions.currentUser.v1)}async function to(){return tt(`${ge.sessions.currentUser.v1}/current`)}async function no(e){return nt(`${ge.sessions.v1}/revoke`,{userId:e})}async function ao(){return tt(ge.sessions.configurations.v1)}async function oo(e){await nt(ge.sessions.configurations.v1,e)}async function io(e){await it(`${ge.sessions.currentUser.v1}/${e}`)}async function so(){await it(`${ge.sessions.currentUser.v1}/all`)}async function ro(){return tt(ge.accessTokens.v1)}async function lo(){return tt(he.accessTokens.v1)}async function co({id:e}){return it(`${he.accessTokens.v1}/${e}`)}async function uo({id:e}){return it(`${ge.accessTokens.v1}/${e}`)}async function go(e){return nt(ge.accessTokens.v1,e)}async function po(e){return nt(he.accessTokens.v1,e)}async function yo(){return tt(ge.apiTokens.v1)}async function fo(){return tt(he.apiTokens.v1)}async function So(e){return nt(ge.apiTokens.v1,e)}async function ho(e){return nt(he.apiTokens.v2,e)}async function vo({tokenId:e}){return it(`${he.apiTokens.v1}/${e}`)}async function mo({tokenId:e}){return it(`${ge.apiTokens.v1}/${e}`)}async function bo({userId:e}){return tt(`${ge.v1}/${e}`)}async function Ao(e){return tt(`${pe.v1}/mfa-policy/allow-remember-device`,{mfaToken:e})}async function wo(e){let{type:t}=e,n=oe(e,An);return nt(`${de.v1}/passwordless/${t.toLocaleLowerCase()}/prelogin`,n)}async function To(e){let{type:t}=e,n=oe(e,wn);return _n(await nt(`${de.v1}/passwordless/${t.toLocaleLowerCase()}/postlogin`,n))}async function Eo(e){let{type:t}=e,n=oe(e,Tn);return nt(`${de.v1}/passwordless/${t.toLocaleLowerCase()}/postlogin`,n)}async function Io({token:e}){return nt(he.invites.verify.v1,{token:e})}async function ko(){return tt(`${Ee.v1}/configurations`)}async function Oo(e){return nt(`${Ee.v1}/configurations`,e)}async function _o(e,t){return at(`${Ee.v1}/configurations/${e}`,t)}async function Po(e){return it(`${Ee.v1}/configurations/${e}`)}async function Uo(e){return nt(`${Ee.v1}/configurations/metadata`,e)}async function Lo(e,t){return ot(`${Ee.v1}/configurations/${e}/metadata`,t)}async function Do(e){return nt(`${Ee.v1}/configurations/metadata-url`,e)}async function Ro(e,t){return ot(`${Ee.v1}/configurations/${e}/metadata-url`,t)}async function Co(e,t){return nt(`${Ee.v1}/configurations/${e}/domains`,t)}async function No(e,t){return it(`${Ee.v1}/configurations/${e}/domains/${t}`)}async function Mo(e,t){return ot(`${Ee.v1}/configurations/${e}/domains/${t}/validate`)}async function Fo(e,t){return ot(`${Ee.v2}/configurations/${e}/domains/${t}/validate`)}async function $o(e){return tt(`${Ee.v1}/configurations/${e}/roles`)}async function jo(e,t){return ot(`${Ee.v1}/configurations/${e}/roles`,t)}async function Go(e,t){return nt(`${Ee.v1}/configurations/${e}/groups`,t)}async function xo(e,{roleIds:t,group:n,id:a}){return at(`${Ee.v1}/configurations/${e}/groups/${a}`,{group:n,roleIds:t})}async function Vo(e,t){return it(`${Ee.v1}/configurations/${e}/groups/${t}`)}async function Bo(e){return tt(`${Ee.v1}/configurations/${e}/groups`)}async function Wo(e){return nt(`${de.v2}/user/sso/prelogin`,e)}async function zo(e){return En(await nt(`${de.v2}/user/oidc/postlogin`,e))}async function Ko(e){return Un(await nt(`${Ve}/token`,e))}async function Ho(){const e=Tt();return Un(await nt(`${Ve}/authorize/silent`,{tenantId:e}))}async function qo(e){return Pn(await nt(`${Ve}/token`,e))}async function Jo(){const e=Tt();return Pn(await nt(`${Ve}/authorize/silent`,{tenantId:e}))}async function Yo(e){return nt(`${ge.v1}/phone/reset`,e)}async function Xo(e){return nt(`${ge.v1}/phone/reset/verify`,e)}async function Qo(e){return nt(`${ge.v1}/phone`,e)}async function Zo(e){return nt(`${ge.v1}/phone/verify`,e)}async function ei(e){return ot(`${ge.v1}/phone/change`,e)}async function ti(e){return nt(`${de.v1}/webauthn/prelogin`,e)}async function ni(e){return nt(`${de.v1}/webauthn/postlogin`,e)}async function ai(e){return _n(await nt(`${de.v1}/webauthn/postlogin`,e))}async function oi(){return nt(ue.v1)}async function ii(){return tt(ue.v1)}async function si(e){return it(`${ue.v1}/${e}`)}async function ri(e){return nt(`${ue.v1}/verify`,e)}async function li(){return tt(`${pe.v1}/auth/strategies/public`)}async function ci(){return tt(`${pe.v1}/auth/strategies`)}async function ui(){return tt(`${pe.v1}/mfa/strategies`)}async function di(){return tt(`${ge.authorization.v1}`)}async function gi(){return tt(`${ge.v2}/me`)}const pi=async()=>{try{return await vn()}catch(e){}};async function yi(){const e=[{action:gi,shouldLoad:!0},{action:pi,shouldLoad:kn()},{action:di,shouldLoad:On()}].map((e=>async function({shouldLoad:e,action:t}){if(e)return await t()}(e))),[t,n,a]=await Promise.all(e),o=Tt();return o&&(t.tenantId=o),j({},t,null!=a?a:{},{entitlements:n})}async function fi(e){const t=await nt(`${de.v1}/user/step-up/generate`,e);return t.accessToken?_n(t):t}async function Si(e){return tt(`${ge.v2}/me`,null!=e?e:{addRoles:!0})}async function hi(e){return ot(`${ge.v2}/me`,e)}async function vi(e){return ot(`${_e.v1}/me/image/v1`,e,{responseType:"plain",contentType:void 0})}async function mi(e){return nt(`${ge.v1}/passwords/change`,e)}async function bi(e){var t,n,a,o,i,s;const r=(e.filter||[]).reduce(((e,t)=>j({},e,{[t.id]:t.value})),{}),l=null!=(t=e.sort)&&t.length?{sortBy:null!=(n=null==(a=e.sort)||null==(o=a[0])?void 0:o.id)?n:"name",sortDirection:null!=(i=e.sort)&&null!=(s=i[0])&&s.desc?"desc":"asc"}:null;return tt(Ie.v1,j({pageOffset:e.pageOffset,pageSize:e.pageSize},r,l))}async function Ai(e){return nt(ge.v2,j({},e,{provider:"local"}))}async function wi(e){return it(`${Ie.v1}/${e.userId}`)}async function Ti(e){return ot(Ie.v1,e)}async function Ei(e){const{userId:t,expirationInSeconds:n}=e;return ot(`${ge.temporary.v1}/${t}`,{expirationInSeconds:n})}async function Ii(e){return it(`${ge.temporary.v1}/${e}`)}async function ki(){return tt(ge.temporary.configuration.v1)}async function Oi(e){return nt(he.invites.user.v1,j({},e))}async function _i(e){return at(he.invites.user.v1,j({},e))}async function Pi(){return it(he.invites.user.v1)}async function Ui(){return tt(he.invites.user.v1)}async function Li(){return tt(he.invites.configuration.v1)}async function Di(){return tt(ke.v1)}async function Ri(){return tt(Se.v1)}async function Ci(){return tt(`${Oe.v1}/members`)}async function Ni(e){return nt(`${Ie.v1}/${e.userId}/resendActivationEmail`,{})}async function Mi(e){return nt(ge.v2,j({},e,{provider:"local"}))}async function Fi(e){return nt(ge.invitation.resendAll.v1,j({},e))}async function $i(e){var t,n;const a=await tt("/metadata",e);if(null!=a&&null!=(t=a.rows)&&t[0])return null==a||null==(n=a.rows)?void 0:n[0];throw new Error(`metadata not found: ${e.entityName}`)}async function ji(){return tt("/metadata/admin-box")}async function Gi(e){return nt("/metadata/admin-box",e)}async function xi(){const e=await tt("/metadata/ipme");if(e)return e;throw new Error("ip metadata not found")}const Vi=async()=>$i({entityName:"notifications"}),Bi=async()=>$i({entityName:"saml"}),Wi=async()=>$i({entityName:"audits"}),zi=async e=>async function(e){const t=await tt(`/metadata/ip/${e}`);if(t)return t;throw new Error("ip metadata not found")}(e),Ki=["dataFilters"],Hi=["templateId","dataFilters"],qi=["dataFilters"];async function Ji(e){return tt(`${Me.v2}/tenant-reports`,e)}async function Yi(e){return tt(`${Me.v2}/${e.id}/tenant-reports`)}async function Xi(e){let{dataFilters:t}=e,n=oe(e,Ki);return{html:await tt(`${Fe.v1}/preview-report`,j({},n,{dataFilters:btoa(JSON.stringify(t||{})),responseType:"html"}),{responseType:"plain"})}}async function Qi(e){let{templateId:t,dataFilters:n}=e,a=oe(e,Hi);return nt(`${Me.v2}/${t}/tenant-reports`,j({},a,{dataFilters:btoa(JSON.stringify(n||{}))}))}async function Zi(e){let{dataFilters:t}=e,n=oe(e,qi);const a=await tt(`${Fe.v1}/preview-report`,j({},n,{dataFilters:btoa(JSON.stringify(t||{}))}),{responseType:"blob"});let o="text/html",i="html";"pdf"===n.responseType?(o="application/pdf",i="pdf"):"image"===n.responseType&&(o="image/jpeg",i="jpg");const s=new Blob([a],{type:o}),r=URL.createObjectURL(s),l=document.createElement("a");l.href=r,l.setAttribute("download",`report_${n.name||""}.${i}`),l.click(),setTimeout(l.remove.bind(l))}async function es(e){return nt(`${Fe.v1}/tenant-reports`,e)}async function ts(e){return tt($e,{params:e})}async function ns(e){return ot(`${$e}/status`,{params:e})}async function as(e){const{notificationId:t,pinStatus:n}=e;return ot(`${$e}/${n}`,{notificationId:t})}async function os(){return nt(`${$e}/status/mark-all-read`)}const is=["endpoint","headerProps"];async function ss(e){return tt(je,e)}async function rs(e){return tt(`${je}/stats`,e)}async function ls(e){const{endpoint:t,headerProps:n}=e,a=oe(e,is);return st(`${je}/export/${t}`,{properties:n},a)}const cs=["eventKey"],us=["eventKey"],ds=()=>tt(`${De.v1}/slack`),gs=()=>tt(`${De.v1}/slack/applications`),ps=()=>tt(`${De.v1}/slack/channels`),ys=e=>e.id?at(`${De.v1}/slack/subscription/${e.id}`,e):nt(`${De.v1}/slack/subscriptions`,e),fs=e=>it(`${De.v1}/slack/subscriptions/${e.id}`),Ss=e=>nt(`${De.v1}/slack/applications/registrations`,{code:e}),hs=()=>tt(`${De.v1}/emails`),vs=e=>{let{eventKey:t}=e,n=oe(e,cs);return nt(`${De.v1}/emails/${t}`,n)},ms=({eventKey:e,enabled:t})=>at(`${De.v1}/emails/${e}`,{enabled:t}),bs=(e,t)=>it(`${De.v1}/emails/${e}/subscriptions/${t}`),As=(e,t,n)=>ot(`${De.v1}/emails/${t}/subscriptions/${e}`,n),ws=e=>it(`${De.v1}/emails/${e}`),Ts=()=>tt(`${De.v2}/sms`),Es=e=>{let{eventKey:t}=e,n=oe(e,us);return nt(`${De.v2}/sms/${t}`,n)},Is=({eventKey:e,enabled:t})=>at(`${De.v2}/sms/${e}`,{enabled:t}),ks=(e,t)=>it(`${De.v2}/sms/${e}/subscriptions/${t}`),Os=(e,t,n)=>ot(`${De.v2}/sms/${t}/subscriptions/${e}`,n),_s=e=>it(`${De.v2}/sms/${e}`),Ps=()=>tt(xe),Us=e=>e._id?at(`${xe}/${e._id}`,e):nt(`${xe}/custom`,e),Ls=e=>it(`${xe}/${e}`),Ds=(e,t=0,n=10)=>{const a=new URLSearchParams({id:e,offset:`${t}`,limit:`${n}`});return tt(`${xe}/logs/?${a.toString()}`)},Rs=e=>nt(`${xe}/test`,e),Cs=e=>nt(`${xe}/logs/${e}/retries`),Ns=()=>tt(`${Ge.v1}/categories`),Ms=e=>tt(Ge.v1,{channels:e});async function Fs(e,t){return ot(Pe.v1,e,{headers:rt(t)})}async function $s(e){return tt(Pe.v1,void 0,{headers:rt(e)})}async function js(){return tt(`${Pe.v1}/public`)}const Gs=["roleId"],xs=["roleId"],Vs=["permissionId"];async function Bs(){return tt(ve.v1)}async function Ws(e){return nt(ve.v1,e)}async function zs({roleId:e}){return it(`${ve.v1}/${e}`)}async function Ks(e){let{roleId:t}=e,n=oe(e,Gs);return at(`${ve.v1}/${t}`,n)}async function Hs(e){let{roleId:t}=e,n=oe(e,xs);return ot(`${ve.v1}/${t}/permissions`,n)}async function qs(){return tt(Se.v1)}async function Js(e){let{permissionId:t}=e,n=oe(e,Vs);return ot(`${Se.v1}/${t}/roles`,n)}async function Ys(){return tt(`${Se.v1}/categories`)}async function Xs(e){return nt(ve.v2,e)}async function Qs(){return tt(Re.subscriptions.v1)}async function Zs(e){return tt(`${Re.subscriptions.v1}/${e}`)}async function er(e){return ot(`${Re.subscriptions.v1}/${e}/cancellations/`,{})}async function tr(e){return ot(`${Re.subscriptions.v1}/${e}/renewals/`,{})}async function nr(e,{paymentMethodId:t,planId:n}){return ot(`${Re.subscriptions.v1}/${e}`,{paymentMethodId:t,planId:n})}async function ar(e){return tt(`${Ne.v1}/${e}`)}async function or(){return tt(`${Ne.v1}`)}async function ir(e){return ot(`${Ne.v1}/${e}/cancellations/`,{})}async function sr(e){return ot(`${Ne.v1}/${e}/renewals/`,{})}async function rr(e,{paymentMethodId:t,planId:n}){return ot(`${Ne.v1}/${e}`,{paymentMethodId:t,planId:n})}async function lr(){return tt(Re.plans.v1)}async function cr(e){return tt(`${Re.plans.v1}/${e}`)}async function ur(){return tt(Re.invoices.v1)}async function dr(e){return tt(`${Re.invoices.v1}/${e}`)}async function gr(e,t){return tt(`${Re.invoices.v1}/${e}/pdf`,{outputFileName:t},{responseType:"blob"})}const pr=["email"];async function yr(){return tt(Re.paymentMethods.v1)}async function fr(e){return tt(`${Re.paymentMethods.v1}/${e}`)}async function Sr(e,t){let{email:n}=t,a=oe(t,pr);return at(`${Re.paymentMethods.v1}/${e}/billing-details`,{email:n,address:a})}async function hr(e){return nt(Re.paymentProviders.stripe.subscriptions.v1,e)}async function vr(e){return tt(`${Re.paymentProviders.stripe.customers.v1}/${e}`)}async function mr(e){return nt(`${Re.paymentProviders.stripe.customers.v1}`,e)}async function br(){return tt(`${Re.paymentProviders.stripe.publicConfigurations.v1}`)}async function Ar(e){return nt(`${Re.paymentProviders.stripe.setupIntents.v1}`,e)}async function wr(e){return tt(`${Re.summaries.v1}/${e}`)}async function Tr(e){return tt(`${Re.tenantConfiguration.v1}/${e}`)}async function Er(e){return nt(`${Re.tenantConfiguration.v1}`,e)}async function Ir(){return tt(Ce.v1)}async function kr(){return tt(`${Re.configurations.vendorPublicConfigurations.v1}`)}let Or,_r,Pr,Ur,Lr,Dr;async function Rr({userId:e}){return tt(`${Ae.v1}/${e}/apps`)}async function Cr({userIds:e}){return tt(`${Ae.v1}/users-apps`,{userIds:e.join(",")})}async function Nr(){return tt(Ye.v1)}async function Mr({appIds:e,includeFreeAccess:t=!0}){return tt(Je,{ids:e.join(","),_includeFreeAccess:t})}async function Fr(e){return nt(`${Ae.v1}/apps-user`,e)}async function $r(e){return it(`${Ae.v1}/user-apps`,e)}async function jr({appIds:e}){return tt(`${Ae.v1}/apps-users`,{appIds:e.join(",")})}async function Gr(){return tt("/vendors/public")}async function xr(e){return tt(me.v1,e)}async function Vr(e){return nt(me.v1,e)}async function Br(e,t){return it(me.v1,e,{headers:rt(t)})}async function Wr(e,t,n){return nt(`${me.v1}/${e}/roles`,t,{headers:rt(n)})}async function zr(e,t,n){return it(`${me.v1}/${e}/roles`,t,{headers:rt(n)})}async function Kr(e,t,n){return at(`${me.v1}/${e}/roles`,t,{headers:rt(n)})}async function Hr(e,t){return nt(Le.v1,e,{headers:rt(t)})}async function qr(e,t){return it(`${Le.v1}/${e}`,void 0,{headers:rt(t)})}async function Jr({tenantId:e},t,n){return at(`${Le.v1}/${e}`,t,{headers:rt(n)})}async function Yr({tenantId:e},t,n){return ot(`${Le.v1}/${e}/management`,t,{headers:rt(n)})}async function Xr(e,t,n){return ot(`${me.v1}/${e}/access`,t,{headers:rt(n)})}async function Qr(e,t){return nt(`${me.v2}/`,e,{headers:rt(t)})}async function Zr(){return tt(`${We}`)}async function el(e,t){return at(`${We}/${e}`,t)}async function tl(e){return nt(`${We}`,e)}async function nl(e){return it(`${We}/${e}`)}async function al(e){return tt(`${ze}/${e}/Users/count`)}async function ol(e){return nt(`${be.v1}`,e)}!function(e){e.ACTIVE="active",e.CANCELED="canceled",e.INCOMPLETE="incomplete",e.EXPIRED="expired",e.TRIALING="trialing",e.TRIAL_ENDED="trialEnded"}(Or||(Or={})),function(e){e.UNKNWON="unknown",e.CARD="card"}(_r||(_r={})),function(e){e.AT_PERIOD_END="atPeriodEnd"}(Pr||(Pr={})),function(e){e.Stripe="Stripe"}(Ur||(Ur={})),function(e){e.CHANGE_TO_DEFAULT="change_to_default",e.RETAIN_TRIAL="retain_trial"}(Lr||(Lr={})),function(e){e.CREATE="create_customer"}(Dr||(Dr={}));const il=["groupId"];async function sl({groupId:e},t){return tt(`${we.v1}/${e}`,j({},t))}async function rl(e){return tt(`${we.v1}`,j({},e))}async function ll(e,t){return nt(`${we.getByIds.v1}`,e,{params:t})}async function cl(e){return nt(`${we.v1}`,e)}async function ul(e){let{groupId:t}=e,n=oe(e,il);return at(`${we.v1}/${t}`,n)}async function dl(e){return it(`${we.v1}/${e}`)}async function gl(e,t){return nt(`${we.v1}/${e}/roles`,t)}async function pl(e,t){return it(`${we.v1}/${e}/roles`,t)}async function yl(e,t){return nt(`${we.v1}/${e}/users`,t)}async function fl(e,t){return it(`${we.v1}/${e}/users`,t)}async function Sl(){return tt(`${we.configurations.v1}`)}async function hl(e){return nt(`${we.configurations.v1}`,e)}async function vl(){return tt(He.v1)}async function ml(){return tt(qe.v1)}async function bl(e){return tt(`${Te.v1}`,e)}async function Al(e){return nt(`${Te.v1}`,e)}async function wl(e){return it(`${Te.v1}/${e}`)}async function Tl(e){return nt(`${Te.v1}/preverify`,e)}async function El(e){return nt(`${Te.v1}/verify`,e)}async function Il(e,t){return nt(`${Te.v1}/${e}/delete/verify`,t)}let kl,Ol,_l,Pl;!function(e){e.FRONTEGG="frontegg",e.SCIM2="scim2"}(kl||(kl={})),function(e){e.createdAt="createdAt",e.name="name",e.tenantId="tenantId"}(Ol||(Ol={})),function(e){e.CUSTOMER="customer",e.SPAM="spam",e.TEST="test",e.RESELLER="reseller",e.HEADQUARTER="headquarter"}(_l||(_l={})),function(e){e.NEVER="NEVER",e.ALWAYS="ALWAYS",e.ASSIGNABLE="ASSIGNABLE"}(Pl||(Pl={}));const Ul=[/^(.*)\/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]*$/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],Ll=`${de.v1}/user/token/refresh`,Dl=`${Ve}/authorize/silent`,Rl=`${ge.v2}/me`,Cl=`${ge.v2}/me/tenants`,Nl=`${ge.v3}/me/tenants`,Ml=Ke;let Fl,$l,jl,Gl,xl;!function(e){e.FRONTEGG="frontegg",e.OKTA="okta",e.AZURE_AD="azure-ad",e.OTHER="other"}(Fl||(Fl={})),function(e){e.roles="roles",e.users="users",e.rolesAndUsers="rolesAndUsers"}($l||($l={})),function(e){e.FRONTEGG="frontegg",e.SCIM2="scim2"}(jl||(jl={})),function(e){e.createdAt="createdAt",e.name="name",e.email="email",e.id="id",e.verified="verified",e.isLocked="isLocked",e.provider="provider",e.tenantId="tenantId"}(Gl||(Gl={})),function(e){e.MFA_UNENROLLED="mfa-unenrolled",e.BREACHED_PASSWORDS="breached-passwords",e.INACTIVE="inactive"}(xl||(xl={}));const Vl=["local","saml","google","github","facebook","microsoft","scim2","slack"];let Bl,Wl,zl,Kl,Hl,ql;!function(e){e.FORCE_MFA="FORCE_MFA",e.BREACHED_PASSWORDS_EXIST="BREACHED_PASSWORDS_EXIST",e.ENABLE_USER_LOCKOUT="ENABLE_USER_LOCKOUT",e.STRENGTHEN_USER_LOCKOUT="STRENGTHEN_USER_LOCKOUT",e.ENABLE_PASSWORD_HISTORY="ENABLE_PASSWORD_HISTORY",e.STRENGTHEN_PASSWORD_HISTORY="STRENGTHEN_PASSWORD_HISTORY",e.ENABLE_FORCE_RELOGIN="ENABLE_FORCE_RELOGIN",e.SET_FORCE_RELOGIN="SET_FORCE_RELOGIN",e.ENABLE_SESSION_CONCURRENCY="ENABLE_SESSION_CONCURRENCY",e.SET_SESSION_CONCURRENCY="SET_SESSION_CONCURRENCY",e.ENABLE_IDLE_SESSION="ENABLE_IDLE_SESSION",e.SET_IDLE_SESSION="SET_IDLE_SESSION",e.ENABLE_IP_RESTRICTIONS="ENABLE_IP_RESTRICTIONS",e.CHANGE_IP_TO_ALLOWLIST="CHANGE_IP_TO_ALLOWLIST",e.ENABLE_DOMAIN_RESTRICTIONS="ENABLE_DOMAIN_RESTRICTIONS",e.CHANGE_DOMAIN_TO_ALLOWLIST="CHANGE_DOMAIN_TO_ALLOWLIST",e.CONFIGURE_SSO="CONFIGURE_SSO"}(Bl||(Bl={})),function(e){e.MFA_FORCED="MFA_FORCED",e.PARTIALLY_FORCED_MFA="PARTIALLY_FORCED_MFA",e.PARTIAL_MFA_USAGE="PARTIAL_MFA_USAGE",e.FULL_MFA_USAGE="FULL_MFA_USAGE",e.BREACHED_PASSWORD_USERS_EXIST="BREACHED_PASSWORD_USERS_EXIST",e.IMPROVE_LOCKOUT_POLICY="IMPROVE_LOCKOUT_POLICY",e.IMPROVE_PASSWORD_HISTORY_POLICY="IMPROVE_PASSWORD_HISTORY_POLICY",e.NO_SESSION_SETTINGS="NO_SESSION_SETTINGS",e.PARTIAL_SESSION_SETTINGS="PARTIAL_SESSION_SETTINGS",e.FULL_SESSION_SETTINGS="FULL_SESSION_SETTINGS",e.NO_IP_RESTRICTIONS="NO_IP_RESTRICTIONS",e.IP_ALLOWLIST="IP_ALLOWLIST",e.IP_DENYLIST="IP_DENYLIST",e.NO_DOMAIN_RESTRICTIONS="NO_DOMAIN_RESTRICTIONS",e.DOMAIN_ALLOWLIST="DOMAIN_ALLOWLIST",e.DOMAIN_DENYLIST="DOMAIN_DENYLIST",e.FULL_PASSWORD_SETTINGS="FULL_PASSWORD_SETTINGS"}(Wl||(Wl={})),function(e){e.SEND_RESET_BREACHED_PASSWORD_EMAIL="SEND_RESET_BREACHED_PASSWORD_EMAIL",e.ADJUST_FORCE_RELOGIN="ADJUST_FORCE_RELOGIN",e.ADJUST_MAX_CONCURRENT_SESSIONS="ADJUST_MAX_CONCURRENT_SESSIONS",e.ADJUST_IDLE_TIMEOUT="ADJUST_IDLE_TIMEOUT"}(zl||(zl={})),function(e){e.SEVERE="SEVERE",e.WARNING="WARNING",e.INFO="INFO"}(Kl||(Kl={})),function(e){e.MFA="MFA",e.SESSIONS="SESSIONS",e.PASSWORD="PASSWORD",e.INACTIVITY="INACTIVITY",e.IP="IP",e.DOMAIN="DOMAIN",e.SSO="SSO"}(Hl||(Hl={})),function(e){e.FREE_ACCESS="FREE_ACCESS",e.MANAGED_ACCESS="MANAGED_ACCESS"}(ql||(ql={}));const Jl={auth:l,teams:c,metadata:u,reports:d,connectivity:y,notifications:g,audits:p,tenants:s,accountSettings:f,roles:S,subscriptions:h,vendor:m,subTenants:b,featureFlags:o,directory:A,impersonate:w,groups:T,users:i,entitlements:r,securityCenter:E,userPhoneNumbers:I,applications:v},Yl={fetch:t,ContextHolder:ne,FronteggContext:ae,api:Jl,FronteggApiError:ce,AuthStrategyEnum:rn,MachineToMachineAuthStrategy:ln,SocialLoginProviders:sn,ISubscriptionCancellationPolicy:Pr,ISubscriptionStatus:Or,PaymentMethodType:_r,ProviderType:Ur},Xl=e=>JSON.parse(JSON.stringify(e)),Ql=(e=500)=>new Promise((t=>{setTimeout(t,e)})),Zl=async(e,t,n)=>{let a=0;for(;a<t-1;)try{return await e()}catch(e){if(a++,a>=t)throw e;await new Promise((e=>setTimeout(e,n)))}return await e()};function ec(e,t){const n=j({},e);return t.forEach((e=>{delete n[e]})),n}function tc(e){if(null==e)return;return function(e){const t=typeof e;return(null==e?void 0:e.constructor)==={}.constructor||"undefined"===t||null===e||"boolean"===t||"number"===t||"string"===t||e instanceof Date||e instanceof RegExp||e instanceof Blob||e instanceof File||e instanceof FileList||e instanceof ArrayBuffer||e instanceof ImageData||e instanceof ImageBitmap||e instanceof Array||e instanceof Map||e instanceof Set}(e)&&void 0!==e.__isProxy}let nc,ac,oc;!function(e){e.validate="validate",e.invalid="invalid",e.pending="pending",e.success="success",e.failed="failed"}(nc||(nc={})),function(e){e.activating="activating",e.success="success",e.resend="resend",e.activatingForm="activatingForm"}(ac||(ac={})),function(e){e.LOAD_API_TOKENS="LOAD_API_TOKENS",e.ADD_API_TOKEN="ADD_API_TOKEN",e.DELETE_API_TOKEN="DELETE_API_TOKEN"}(oc||(oc={}));var ic=n(9378),sc=n.n(ic),rc=n(9314);const lc=()=>{if(!ne.shouldLoadEntitlements())throw new Error("You must first enable entitlements via Frontegg options to use this function")},cc=(e,t,n,a)=>(lc(),(0,rc.wJ)(t,e,n)),uc=(e,t,n,a)=>(lc(),(0,rc.tE)(t,e,n)),dc=(e,t,n,a)=>"permissionKey"in t?cc(e,t.permissionKey,n):uc(e,t.featureKey,n);function gc(e,t){return sc()(e,t)}let pc,yc,fc,Sc,hc,vc,mc,bc,Ac,wc,Tc,Ec,Ic,kc,Oc,_c,Pc,Uc,Lc,Dc;!function(e){e.forgotPassword="forgotPassword",e.success="success"}(pc||(pc={})),function(e){e.CREATE_GROUP="CREATE_GROUP",e.GET_GROUP="GET_GROUP",e.GET_GROUPS="GET_GROUPS",e.DELETE_GROUP="DELETE_GROUP",e.UPDATE_GROUP="UPDATE_GROUP",e.ADD_USERS_TO_GROUP="ADD_USERS_TO_GROUP",e.DELETE_USERS_FROM_GROUP="DELETE_USERS_FROM_GROUP",e.ADD_ROLES_TO_GROUP="ADD_ROLES_TO_GROUP",e.DELETE_ROLES_FROM_GROUP="DELETE_ROLES_FROM_GROUP",e.GET_GROUP_CONFIGURATION="GET_GROUP_CONFIGURATION",e.UPDATE_GROUP_CONFIGURATION="UPDATE_GROUP_CONFIGURATION",e.GET_TEAM_USERS="GET_TEAM_USERS"}(yc||(yc={})),function(e){e.roles="roles",e.users="users",e.rolesAndUsers="rolesAndUsers"}(fc||(fc={})),function(e){e.impersonating="impersonating",e.success="success"}(Sc||(Sc={})),function(e){e.preLogin="preLogin",e.magicLinkPreLoginSuccess="magicLinkPreLoginSuccess",e.loginWithSmsOtc="loginWithSmsOtc",e.loginWithQuickSmsOtc="loginWithQuickSmsOtc",e.loginWithOtc="loginWithOtc",e.loginWithPassword="loginWithPassword",e.loginWithTwoFactor="loginWithTwoFactor",e.redirectToSSO="redirectToSSO",e.loginWithSSOFailed="loginWithSSOFailed",e.success="success",e.forceTwoFactor="forceTwoFactor",e.recoverTwoFactor="recoverTwoFactor",e.promptPasskeys="promptPasskeys",e.breachedPassword="breachedPassword",e.breachedPasswordSuccess="breachedPasswordSuccess"}(hc||(hc={})),function(e){e.Login="login",e.RegisterQuickLogin="registerQuickLogin"}(vc||(vc={})),function(e){e.Internal="internal",e.UsbKey="usb-key",e.Android="android",e.Sms="sms"}(mc||(mc={})),function(e){e["social-login"]="social-login",e["custom-social-login"]="custom-social-login",e.direct="direct"}(bc||(bc={})),function(e){e.verify="verify",e.recoveryCode="recoveryCode",e.authenticatorApp="authenticatorApp",e.smsSetPhoneNumber="smsSetPhoneNumber",e.smsVerifyCode="smsVerifyCode",e.emailVerifyCode="emailVerifyCode",e.noMFAEnrolledStepUp="noMFAEnrolledStepUp"}(Ac||(Ac={})),function(e){e.GET_ACCOUNTS="GET_ACCOUNTS",e.SEARCH_ACCOUNTS="SEARCH_ACCOUNTS",e.SET_ROOT_ACCOUNT_DATA="SET_ROOT_ACCOUNT_DATA",e.SET_SELECTED_SUB_ACCOUNT_DATA="SET_SELECTED_SUB_ACCOUNT_DATA",e.LOAD_NUMBER_OF_USERS_FOR_ACCOUNT="LOAD_NUMBER_OF_USERS_FOR_ACCOUNT",e.UPDATE_SUB_ACCOUNT_ACCESS_FOR_USER="UPDATE_SUB_ACCOUNT_ACCESS_FOR_USER",e.CREATE_SUB_ACCOUNT="CREATE_SUB_ACCOUNT",e.UPDATE_SUB_ACCOUNT="UPDATE_SUB_ACCOUNT",e.DELETE_SUB_ACCOUNT="DELETE_SUB_ACCOUNT",e.GET_ACCOUNT_USERS="GET_ACCOUNT_USERS",e.ADD_USERS_TO_ACCOUNT="ADD_USERS_TO_ACCOUNT",e.DELETE_USERS_FROM_ACCOUNT="DELETE_USERS_FROM_ACCOUNT",e.SET_USER_ROLES_FOR_SUB_ACCOUNT="SET_USER_ROLES_FOR_SUB_ACCOUNT",e.UPDATE_SUB_ACCOUNT_SETTINGS="UPDATE_SUB_ACCOUNT_SETTINGS",e.UPDATE_SUB_ACCOUNT_MANAGEMENT="UPDATE_SUB_ACCOUNT_MANAGEMENT",e.GET_USER_JWT="GET_USER_JWT",e.GET_TEAM_USERS="GET_TEAM_USERS"}(wc||(wc={})),function(e){e.ResetPhoneNumber="ResetPhoneNumber",e.VerifyResetPhoneNumber="VerifyResetPhoneNumber",e.ChangePhoneNumber="ChangePhoneNumber"}(Tc||(Tc={})),function(e){e.EDIT_ROLE_DIALOG="editRoleDialog",e.DELETE_ROLE_DIALOG="deleteRoleDialog",e.LOAD_ROLES="loadRoles",e.ADD_ROLE="addRole",e.MANAGE_PERMISSIONS="managePermissions"}(Ec||(Ec={})),function(e){e.RECOMMENDATIONS="recommendations",e.INSIGHTS="insights",e.SEND_BULK_RESET_BREACHED_PASSWORD_EMAILS="sendBulkResetBreachedPasswordEmails",e.SEND_BREACHED_PASSWORD_EMAIL="sendBreachedPasswordEmail",e.BREACHED_PASSWORD_USERS_TABLE="breachedPasswordUsersTable",e.UNENROLLED_MFA_USERS_TABLE="unenrolledMfaUsersTable",e.INACTIVE_USERS_TABLE="inactiveUsersTable"}(Ic||(Ic={})),function(e){e.SignUp="SignUp",e.SignUpSuccess="SignUpSuccess"}(kc||(kc={})),function(e){e.LOAD_SSO_CONFIGURATIONS="LOAD_SSO_CONFIGURATIONS",e.SAVE_SSO_CONFIGURATION="SAVE_SSO_CONFIGURATION",e.UPDATE_SSO_CONFIGURATION="UPDATE_SSO_CONFIGURATION",e.SAVE_SSO_CONFIGURATION_BY_METADATA="SAVE_SSO_CONFIGURATION_BY_METADATA",e.UPDATE_SSO_CONFIGURATION_BY_METADATA="UPDATE_SSO_CONFIGURATION",e.DELETE_SSO_CONFIGURATION="DELETE_SSO_CONFIGURATION",e.SAVE_SSO_DOMAIN="SAVE_SSO_DOMAIN",e.DELETE_SSO_DOMAIN="DELETE_SSO_DOMAIN",e.VALIDATE_SSO_DOMAIN="VALIDATE_SSO_DOMAIN",e.UPDATE_SSO_DEFAULT_ROLES="UPDATE_SSO_DEFAULT_ROLES",e.DELETE_SSO_GROUPS="DELETE_SSO_GROUPS",e.SAVE_SSO_GROUPS="SAVE_SSO_GROUPS",e.GET_SSO_AUTHORIZATION_ROLES="GET_SSO_AUTHORIZATION_ROLES"}(Oc||(Oc={})),function(e){e.Saml="saml",e.Okta="okta",e.Azure="azure",e.Google="google",e.Oidc="oidc"}(_c||(_c={})),function(e){e.USERS="USERS",e.STATS="STATS",e.UPDATE_USER="UPDATE_USER",e.DELETE_USER="DELETE_USER",e.RESEND_ACTIVATE_LINK="RESEND_ACTIVATE_LINK",e.RESEND_INVITATION_LINK="RESEND_INVITATION_LINK",e.ROLES_AND_PERMISSIONS="ROLES_AND_PERMISSIONS",e.CREATE_TOKEN_LINK="CREATE_TOKEN_LINK",e.GET_TOKEN_LINK="GET_TOKEN_LINK",e.UPDATE_TOKEN_LINK="UPDATE_TOKEN_LINK",e.DELETE_TOKEN_LINK="DELETE_TOKEN_LINK",e.CONFIG_TOKEN_LINK="CONFIG_TOKEN_LINK",e.CONFIG_TEMPORARY_USERS="CONFIG_TEMPORARY_USERS",e.UPDATE_USER_EXPIRATION_TIME="UPDATE_USER_EXPIRATION_TIME"}(Pc||(Pc={})),function(e){e.SOCIAL_LOGIN="SOCIAL_LOGIN",e.PASSWORDLESS="PASSWORDLESS",e.ACTIVATION_LINK="ACTIVATION_LINK"}(Uc||(Uc={})),function(e){e.SOCIAL_LOGIN="SOCIAL_LOGIN",e.PASSWORD="PASSWORD"}(Lc||(Lc={})),function(e){e.profile="profile",e.privacy="privacy",e.personalApiTokens="personalApiTokens",e.account="account",e.users="users",e.groups="groups",e.security="security",e.sso="sso",e.audits="audits",e.webhooks="webhooks",e.apiTokens="apiTokens",e.roles="roles",e.subscriptions="subscription",e.allAccounts="allAccounts"}(Dc||(Dc={}));const Rc={profile:Dc.profile,privacy:Dc.privacy,personalApiTokens:Dc.personalApiTokens,account:Dc.account,users:Dc.users,groups:Dc.groups,security:Dc.security,sso:Dc.sso,audits:Dc.audits,webhooks:Dc.webhooks,apiTokens:Dc.apiTokens,roles:Dc.roles,subscriptions:Dc.subscriptions,allAccounts:Dc.allAccounts};var Cc=n(9714),Nc=n.n(Cc);const Mc=(e,t)=>{const n=Nc()(e,j({},t));return J(j({__isProxy:!0},n))},Fc={step:nc.validate},$c=e=>Mc(Fc,e),jc=e=>e instanceof Error||(null==e?void 0:e.message)&&(null==e?void 0:e.stack)&&"Error"===(null==e?void 0:e.name),Gc=(e,t)=>e?(e=>Boolean(null==e?void 0:e.statusCode))(e)?e.message:(jc(e)?console.error(e.message):"string"==typeof e&&console.error(e),null!=t?t:"We're facing some difficulties, Please try again"):t,xc=(e,t,n)=>{const a=t=>(Object.assign(e.auth.acceptInvitationState,t),Q(e.auth.acceptInvitationState));return{setAcceptInvitationState:a,resetAcceptInvitationState:()=>{e.auth.acceptInvitationState=Xl(Fc)},acceptInvitation:async e=>{if(e.token&&e.userId)try{a({error:void 0,step:nc.pending}),await t.auth.acceptInvitation(e),a({step:nc.success})}catch(e){a({step:nc.failed,error:Gc(e)})}else a({error:void 0,step:nc.invalid})}}},Vc={loading:!1},Bc=e=>Mc(Vc,e),Wc=(e,t,n)=>{const a=t=>(Object.assign(e.auth.accountSettingsState,t),Q(e.auth.accountSettingsState));return{setAccountSettingsState:a,resetAccountSettingsState:()=>{e.auth.accountSettingsState=Xl(Vc)},saveAccountSettings:async n=>{try{var o;a({loading:!0});const{address:i,timezone:s,dateFormat:r,timeFormat:l,currency:c,logo:u}=e.auth.accountSettingsState,d=await t.accountSettings.updateSettings(j({address:i,timezone:s,dateFormat:r,timeFormat:l,currency:c,logo:u},n));a(j({},d,{loading:!1})),null==(o=n.callback)||o.call(n,d)}catch(e){var i;a({loading:!1,error:Gc(e)}),null==(i=n.callback)||i.call(n,null,e)}},loadAccountSettings:async e=>{a({loading:!(null!=e&&e.silentLoading),error:null});try{const e=await t.accountSettings.getSettings();a(j({},e,{loading:!1}))}catch(e){a({loading:!1,error:Gc(e)})}}}},zc={step:ac.activating,loading:!1,resentEmail:!1,activationStrategy:{loading:!1}},Kc=e=>Mc(zc,e);let Hc;function qc(e,t){var n,a;null==(n=(a=window).onFronteggEvent)||n.call(a,e,t)}!function(e){e.SIGNUP_COMPLETED="signup_completed",e.USER_VERIFIED="user_verified"}(Hc||(Hc={}));const Jc={[rn.Code]:hc.loginWithOtc,[rn.EmailAndPassword]:hc.loginWithPassword,[rn.MagicLink]:hc.magicLinkPreLoginSuccess,[rn.SmsCode]:hc.loginWithSmsOtc},Yc={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"},Xc=e=>{try{return new URL(e),!0}catch(e){return!1}},Qc=({authenticatedUrl:e,enforceRedirectToSameSite:t,allowedRedirectOrigins:n,includeQueryParam:a})=>{let o=e;const i=new URL(window.location.href).searchParams.get("redirectUrl");return i?t&&Xc(i)?((e,t)=>{const n=new URL(window.location.href),a=new URL(e),o=a.origin===n.origin;return t.includes(a.origin)||o})(i,n)?o=i:console.warn("The redirect url param is not valid, the origin is a different site"):o=i:a&&(o+=window.location.search),o},Zc=e=>{const{searchParams:t}=new URL(e),n=t.toString();if(n)return`?${n}`},eu=e=>{const{pathname:t}=new URL(e),n=Zc(e);return n?t+n:t},tu=e=>{const t=new URLSearchParams(window.location.search).get(e);return null!=t?t:void 0},nu="tenantId",au=e=>{const t=+Boolean(e.webauthn.length),n=+Boolean(e.phones.length),a=+Boolean(e.authenticators.length),o=+Boolean(e.emails.length);return{numberOfWebAuthnDevices:t,numberOfPhoneDevices:n,numberOfAuthenticators:a,numberOfEmails:o,totalDevices:t+n+a+o}},ou=e=>{const{numberOfPhoneDevices:t,numberOfAuthenticators:n,numberOfEmails:a,totalDevices:o}=au(e);if(1===o){if(n)return Ac.authenticatorApp;if(t)return Ac.smsVerifyCode;if(a)return Ac.emailVerifyCode}return Ac.verify},iu=e=>{if(1===e.length){const[t]=e;if(t===Sn.AuthenticatorApp)return Ac.authenticatorApp;if(t===Sn.SMS)return Ac.smsSetPhoneNumber;if(t===Sn.EmailCode)return Ac.emailVerifyCode}return Ac.verify},su=e=>"/oauth/callback"===e;function ru(e){return"email"in e}const lu="http://schemas.openid.net/pape/policies/2007/06/multi-factor",cu="mfa",uu=["otp","sms","hwk"],du="SHOULD_STEP_UP",gu="maxAge",pu="FRONTEGG_AFTER_AUTH_REDIRECT_URL",yu="HOSTED_LOGIN_VERIFIER_KEY",fu=(e,{maxAge:t}={})=>{if(!e)return!1;const{amr:n=[],acr:a="",auth_time:o}=e;if(t&&o&&!(Date.now()/1e3-o<=t))return!1;const i=a===lu,s=-1!==n.indexOf(cu),r=void 0!==uu.find((e=>n.indexOf(e)));return i&&s&&r};function Su(){const e=window.location.pathname+window.location.search;window.localStorage.setItem(pu,e)}const hu=(e,t,n)=>{Su();const a=new URLSearchParams(window.location.search);n&&a.set(gu,n.toString()),t(`${e}${a?`?${a}`:""}`,{refresh:!1})},vu=["phoneNumber"],mu=["authenticatedUrl"],bu=e=>e.mfaRequired&&e.mfaToken?(ne.setAccessToken(null),ne.setUser(null),!0):(ne.setAccessToken(e.accessToken),ne.setUser(e),!1),Au=(e,t=[])=>Object.entries(e).reduce(((e,[n,a])=>"object"==typeof a?[...e,...Au(a,[...t,n])]:[...e,{type:[...t,n].join("/"),payload:a}]),[]),wu=e=>{var t;if("path"===e)return(null!=(t=window)?t:document).location.pathname;{var n;const e=((null!=(n=window)?n:document).location.hash||"#").substring(1);return-1!==e.indexOf("?")?e.substring(0,e.indexOf("?")):e}},Tu=e=>oe(e,vu),Eu=(e,t)=>{const n=oe(j({},Yc,t),mu);return Object.values(n).includes(e)},Iu=["callback","events"],ku=["user"],Ou=["callback"],_u=["callback"],Pu=(e,t,n)=>{const a=n,o=t=>(Object.assign(e.auth.activateAccountState,t),Q(e.auth.activateAccountState)),i=()=>{e.auth.activateAccountState=Xl(zc)},s=t=>{Object.assign(e.auth.activateAccountState.activationStrategy,t)};return{setActivateState:o,resetActivateState:i,setActivateStrategyState:s,activateAccount:async n=>{const{callback:s,events:r}=n,l=oe(n,Iu);o({loading:!0});try{const n=ne.onRedirectTo,u=e.auth.routes,d=await t.auth.activateAccountV2(l),{user:g}=d,p=oe(d,ku);if(g.redirectLocation)return void(window.location.href=g.redirectLocation);if(bu(g)){o({step:ac.success});const e=await a.getMfaRequiredState(g);a.setAuthState(e),await Ql(1e3),n(u.loginUrl,{preserveQueryParams:!0})}else{var c;o({step:ac.success});const e={email:g.email,origin:Uc.ACTIVATION_LINK,id:g.id,tenantId:g.tenantId,name:g.name,createdAt:new Date};null==r||null==(c=r.userVerified)||c.call(r,e),qc(Hc.USER_VERIFIED,e),await a.__afterAuthenticationStateUpdate(j({user:g},p),{isAuthenticated:!0}),await Ql(1e3),await a.afterAuthNavigation(),i()}null==s||s(!0)}catch(e){o({loading:!1,error:Gc(e)})}},preActivateAccount:async n=>{const{userId:i,token:r}=n;o({loading:!0,step:ac.activating});try{e.auth.isAuthenticated&&await a.silentLogout();const n=await t.auth.getActivateAccountStrategy({userId:i,token:r});s({strategy:n,loading:!1,error:void 0}),n.shouldSetPassword&&o({loading:!1,step:ac.activatingForm})}catch(e){o({loading:!1,error:Gc(e)})}},getActivateAccountStrategy:async e=>{const{callback:n}=e,a=oe(e,Ou);s({loading:!0});try{const e=await t.auth.getActivateAccountStrategy(a);s({strategy:e,loading:!1,error:void 0}),null==n||n(e)}catch(e){s({loading:!1,error:Gc(e)})}},resendActivationEmail:async e=>{const{callback:n}=e,i=oe(e,_u);a.setTeamLoader({key:Pc.RESEND_ACTIVATE_LINK,value:i.email}),o({loading:!0});try{await t.auth.resendActivationEmail(i),o({loading:!1,error:void 0,resentEmail:!0}),null==n||n(!0)}catch(e){o({loading:!1,error:Gc(e)}),null==n||n(null,e)}finally{a.setTeamLoader({key:Pc.RESEND_ACTIVATE_LINK,value:!1})}}}},Uu={apiTokenType:null,searchValue:"",showAddTokenDialog:!1,createdByUserIdColumn:"show",deleteTokenDialog:{open:!1,clientId:""},successDialog:{open:!1,secret:"",clientId:""},loaders:{},apiTokensDataTenant:[],apiTokensDataUser:[],roles:[],permissions:[],errors:{}},Lu=e=>Mc(Uu,e),Du=(e,t,n)=>{const a=t=>{Object.assign(e.auth.apiTokensState,{loaders:j({},e.auth.apiTokensState.loaders,{[t.key]:t.value})})},o=t=>{Object.assign(e.auth.apiTokensState,{errors:j({},e.auth.apiTokensState.errors,{[t.key]:t.value}),loaders:j({},e.auth.apiTokensState.loaders,{[t.key]:!1})})},i=t=>{Object.assign(e.auth.apiTokensState,t)};return{setApiTokensLoader:a,setApiTokensError:o,setApiTokensState:i,resetApiTokensState:()=>{e.auth.apiTokensState=Xl(Uu)},loadApiTokens:async e=>{null!=e&&e.silentLoading||a({key:oc.LOAD_API_TOKENS,value:!0});try{var n;const[o=[],s=[]]=await Promise.all([t.auth.getUserApiTokensData(),t.auth.getTenantApiTokensData()]);i({apiTokensDataUser:o,apiTokensDataTenant:s}),a({key:oc.LOAD_API_TOKENS,value:!1}),null==e||null==(n=e.callback)||n.call(e,!0)}catch(t){var s;o({key:oc.LOAD_API_TOKENS,value:Gc(t)}),a({key:oc.LOAD_API_TOKENS,value:!1}),null==e||null==(s=e.callback)||s.call(e,null,t)}},loadUserApiTokens:async e=>{null!=e&&e.silentLoading||a({key:oc.LOAD_API_TOKENS,value:!0});try{var n,s;const[o=[],r]=await Promise.all([t.auth.getUserApiTokensData(),t.auth.getUserAccessTokensData()]),l=(null!=(n=r.accessTokens)?n:[]).map((e=>j({},e,{type:ln.AccessToken}))).concat(o.map((e=>j({},e,{type:ln.ClientCredentials})))).sort(((e,t)=>new Date(t.createdAt)-new Date(e.createdAt)));i({apiTokensDataUser:null!=l?l:[]}),a({key:oc.LOAD_API_TOKENS,value:!1}),null==e||null==(s=e.callback)||s.call(e,!0)}catch(t){var r;o({key:oc.LOAD_API_TOKENS,value:Gc(t)}),a({key:oc.LOAD_API_TOKENS,value:!1}),null==e||null==(r=e.callback)||r.call(e,null,t)}},loadTenantApiTokens:async e=>{null!=e&&e.silentLoading||a({key:oc.LOAD_API_TOKENS,value:!0});try{var n,s;const[o=[],r]=await Promise.all([t.auth.getTenantApiTokensData(),t.auth.getTenantAccessTokensData()]),l=(null!=(n=null==r?void 0:r.accessTokens)?n:[]).map((e=>j({},e,{type:ln.AccessToken}))).concat(o.map((e=>j({},e,{type:ln.ClientCredentials})))).sort(((e,t)=>new Date(t.createdAt)-new Date(e.createdAt)));i({apiTokensDataTenant:null!=l?l:[]}),a({key:oc.LOAD_API_TOKENS,value:!1}),null==e||null==(s=e.callback)||s.call(e,!0)}catch(t){var r;o({key:oc.LOAD_API_TOKENS,value:Gc(t)}),a({key:oc.LOAD_API_TOKENS,value:!1}),null==e||null==(r=e.callback)||r.call(e,null,t)}},addTenantApiToken:async n=>{const{description:s,roleIds:r,expires:l,callback:c}=n,u=oc.ADD_API_TOKEN;a({key:u,value:!0});try{const{policy:n}=e.auth.securityPolicyState.publicPolicy,o=(null==n?void 0:n.machineToMachineAuthStrategy)===ln.AccessToken;let d,g=null;l&&(g=1440*l),d=o?await t.auth.createTenantAccessToken({description:s,expiresInMinutes:g,roleIds:r}):await t.auth.updateTenantApiTokensData({description:s,roleIds:r,expiresInMinutes:g}),i({showAddTokenDialog:!1}),await Ql(200);const p=o?ln.AccessToken:ln.ClientCredentials;e.auth.apiTokensState.apiTokensDataTenant.unshift(j({},d,{type:p})),e.auth.apiTokensState.successDialog={open:!0,secret:d.secret,clientId:o?void 0:d.clientId},null==c||c(null)}catch(e){o({key:u,value:Gc(e)}),null==c||c(null,e)}finally{a({key:u,value:!1})}},addUserApiToken:async n=>{const{description:s,expires:r,callback:l}=n,c=oc.ADD_API_TOKEN;a({key:c,value:!0});try{const{policy:n}=e.auth.securityPolicyState.publicPolicy,o=(null==n?void 0:n.machineToMachineAuthStrategy)===ln.AccessToken;let u,d=null;r&&(d=1440*r),u=o?await t.auth.createUserAccessToken({description:s,expiresInMinutes:d}):await t.auth.updateUserApiTokensData({description:s,expiresInMinutes:d}),i({showAddTokenDialog:!1}),await Ql(200);const g=o?ln.AccessToken:ln.ClientCredentials;e.auth.apiTokensState.apiTokensDataUser.unshift(j({},u,{type:g})),e.auth.apiTokensState.successDialog={open:!0,secret:u.secret,clientId:o?void 0:u.clientId},null==l||l(null)}catch(e){o({key:c,value:Gc(e)}),null==l||l(null,e)}finally{a({key:c,value:!1})}},deleteUserApiToken:async n=>{const s=oc.DELETE_API_TOKEN;a({key:s,value:!0});try{const o=e.auth.apiTokensState.apiTokensDataUser;o.some((e=>e.id===n))?(await t.auth.deleteUserAccessToken({id:n}),i({apiTokensDataUser:o.filter((e=>e.id!==n)),deleteTokenDialog:{open:!1,id:n}})):(await t.auth.deleteUserApiToken({tokenId:n}),i({apiTokensDataUser:o.filter((e=>e.clientId!==n)),deleteTokenDialog:{open:!1,clientId:n}}))}catch(e){o({key:s,value:Gc(e)})}finally{a({key:s,value:!1})}},deleteTenantApiToken:async n=>{const s=oc.DELETE_API_TOKEN;a({key:s,value:!0});try{const o=e.auth.apiTokensState.apiTokensDataTenant;o.some((e=>e.id===n))?(await t.auth.deleteTenantAccessToken({id:n}),i({apiTokensDataTenant:o.filter((e=>e.id!==n)),deleteTokenDialog:{open:!1,id:n}})):(await t.auth.deleteTenantApiToken({tokenId:n}),i({apiTokensDataTenant:o.filter((e=>e.clientId!==n)),deleteTokenDialog:{open:!1,id:n}}))}catch(e){o({key:s,value:Gc(e)})}finally{a({key:s,value:!1})}}}},Ru={loading:!0,fetching:!0,error:null,userApplications:[],accountApplications:[]},Cu=e=>Mc(Ru,e),Nu=e=>{var t;return null!=(t=e.map((({appIds:e})=>e)).reduce(((e,t)=>(null==t||t.forEach((t=>{e&&!e.includes(t)&&e.push(t)})),e)),[]))?t:[]},Mu=(e,t,n)=>{const a=t=>{Object.assign(e.auth.applicationsState,t)},o=async({userIds:e})=>{try{const n=await t.applications.getUsersApplicationsId({userIds:e}),a=Nu(n),o=await t.applications.getApplicationsData({appIds:a});return e.reduce(((e,t)=>{var a,i,s;const r=null==(a=n.find((e=>e.userId==t)))?void 0:a.appIds;return e[t]=[...o.filter((e=>e.accessType===ql.FREE_ACCESS)),...null!=(i=null==r||null==(s=r.map((e=>o.find((t=>e===t.id)))))?void 0:s.filter((e=>!!e)))?i:[]],e}),{})}catch(e){a({error:Gc(e)})}},i="Assignment action failed. Try again or contact support.";return{setApplicationsState:a,resetApplicationsState:()=>{e.auth.applicationsState=Xl(Ru)},loadUserApplications:async()=>{a({loading:!0,fetching:!0});try{var n,o;const i=null!=(n=null==(o=e.auth.user)?void 0:o.id)?n:"",s=await t.applications.getUserApplicationsId({userId:i}),r=await t.applications.getApplicationsData({appIds:s});a({userApplications:r,fetching:!1,loading:!1})}catch(e){a({loading:!1,fetching:!1,error:Gc(e)})}},loadAccountApplications:async()=>{a({loading:!0,fetching:!0});try{const e=await t.applications.getTenantsApplications(),n=Nu(e),o=await t.applications.getApplicationsData({appIds:n}),i=await t.applications.getUsersOfApplications({appIds:n}),s=o.map((e=>{var t;return j({},e,{userIds:null==(t=i.find((t=>t.appId===e.id)))?void 0:t.userIds})}));a({accountApplications:s,fetching:!1,loading:!1})}catch(e){a({loading:!1,fetching:!1,error:Gc(e)})}},loadMultipleUsersApplications:o,assignUserToApps:async o=>{const{userId:s,appIds:r,callback:l}=o;try{var c,u,d,g,p,y,f,S,h;const a=null!=(c=null==(u=e.auth)||null==(d=u.user)?void 0:d.tenantId)?c:"";await t.applications.assignUserToApplications({userId:s,appIds:r,tenantId:a});const o=null==(g=e.auth)||null==(p=g.applicationsState)?void 0:p.accountApplications,i=null!=(y=null==(f=e.auth)||null==(S=f.teamState)?void 0:S.users)?y:[],v=null!=(h=null==o?void 0:o.filter((e=>r.includes(e.id))))?h:[];null!=v&&v.length&&n.setTeamState({users:i.map((e=>{var t;return e.id===s?j({},e,{applications:[...null!=(t=e.applications)?t:[],...v]}):e}))}),null==l||l(!0)}catch(e){a({error:Gc(e,i)}),null==l||l(!1)}},unassignUserFromApps:async o=>{const{userId:s,appIds:r,callback:l}=o;try{var c,u,d,g,p,y,f;const a=null!=(c=null==(u=e.auth)||null==(d=u.user)?void 0:d.tenantId)?c:"";await t.applications.unassignUserFromApplications({userId:s,appIds:r,tenantId:a});const o=null!=(g=null==(p=e.auth)||null==(y=p.teamState)?void 0:y.users)?g:[],i=null==(f=o.find((e=>e.id===s)))?void 0:f.applications;null!=i&&i.length&&r.length&&n.setTeamState({users:o.map((e=>e.id===s?j({},e,{applications:i.filter((e=>!r.includes(e.id)))}):e))}),null==l||l(!0)}catch(e){a({error:Gc(e,i)}),null==l||l(!1)}},assignNewUserToApps:async({appIds:a,user:o})=>{var i,s,r;const[l]=n.__getFeatureFlags(["multi-apps-admin-portal"]);if(!l)return;const c=null==(i=e.auth)||null==(s=i.applicationsState)?void 0:s.accountApplications,u=null!=(r=null==c?void 0:c.filter((e=>e.accessType===ql.FREE_ACCESS)))?r:[];if(null!=a&&a.length){var d,g,p;const n=null!=(d=null==(g=e.auth)||null==(p=g.user)?void 0:p.tenantId)?d:"";return await t.applications.assignUserToApplications({userId:o.id,appIds:a,tenantId:n}),a.map((e=>{var t;return null!=(t=null==c?void 0:c.find((t=>t.id===e)))?t:[]})).concat(u)}return u},mapUsersWithApplicationData:async({shouldLoadApps:e,users:t})=>{const[a]=n.__getFeatureFlags(["multi-apps-admin-portal"]);if(!a||!e)return t;const i=t.map((e=>e.id)),s=await o({userIds:i});return s?t.map((e=>null!=s&&s[e.id]?j({},e,{applications:s[e.id]}):e)):t}}},Fu={loading:!0,error:null},$u=e=>Mc(Fu,e),ju=["callback"],Gu=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auth.customLoginState,t)},i=async()=>{var t,n,a,o,i;return e.auth.isAuthenticated?null!=(o=null==(i=e.auth.tenantsState.activeTenant)?void 0:i.hasCustomLogin)&&o:!!(null==(t=await(null==(n=ne.getContext())||null==(a=n.tenantResolver)?void 0:a.call(n)))?void 0:t.tenant)};return{setCustomLoginState:o,resetCustomLoginState:()=>{e.auth.customLoginState=Xl(Fu)},loadTenantMetadata:async()=>{o({loading:!0});try{const e=await t.metadata.getAdminBoxMetadata();o({tenantMetadata:e,loading:!1})}catch(e){o({loading:!1,error:Gc(e)})}},updateTenantMetadata:async e=>{const{callback:n}=e,a=oe(e,ju);try{o({error:null,saving:!0});const e=Au(a);if(0===e.length)throw new Error("No changes to update");await t.metadata.updateAdminBoxMetadata({actions:e});const i=await t.metadata.getAdminBoxMetadata();o({tenantMetadata:i,saving:!1}),null==n||n(!0)}catch(e){o({error:Gc(e,"No changes to update"),saving:!1}),null==n||n(null,e)}},customLoginEnabled:i,loadCustomLoginRoutes:async()=>{try{var n;if(!await i())return;const s=e.auth.isAuthenticated,{getSettings:r,getPublicSettings:l}=t.accountSettings,{applicationUrl:c}=await(s?r():l());if(!c)return;const u=e.auth.routes,d=null!=(n=Zc(c))?n:"";a.setAuthState({routes:j({},u,{customLoginAuthenticatedUrl:c,customLoginUrl:u.loginUrl+d})}),o({customLoginSearchParams:null!=d?d:void 0})}catch{}}}},xu={step:pc.forgotPassword,loading:!1,email:"",passwordConfig:null},Vu=e=>Mc(xu,e),Bu=["callback"],Wu=(e,t,n)=>{const a=t=>{Object.assign(e.auth.forgotPasswordState,t)};return{setForgotPasswordState:a,resetForgotPasswordState:()=>{e.auth.forgotPasswordState=Xl(xu)},forgotPassword:async e=>{a({loading:!0});try{var n;await t.auth.forgotPassword(e),a({loading:!1,error:void 0,step:pc.success}),null==(n=e.callback)||n.call(e,!0)}catch(t){var o;a({loading:!1,error:Gc(t,"Unknown error occurred")}),null==(o=e.callback)||o.call(e,!1,t)}},resetPassword:async e=>{const{callback:n}=e,o=oe(e,Bu);a({loading:!0});try{await t.auth.resetPassword(o),a({loading:!1,error:void 0,step:pc.success}),null==n||n(!0)}catch(e){a({loading:!1,error:Gc(e)}),null==n||n(!1,e)}},loadPasswordConfig:async e=>{a({loading:!0});try{const n=await t.auth.loadPasswordConfig(e);a({loading:!1,passwordConfig:n})}catch(e){a({loading:!1,error:Gc(e)})}}}},zu={loaders:{},errors:{},groups:[],groupsConfiguration:{}},Ku=e=>Mc(zu,e),Hu=["roleIds","userIds"],qu=(e,t,n)=>{const a=t=>{Object.assign(e.auth.groupsState,{loaders:j({},e.auth.groupsState.loaders,{[t.key]:t.value})})},o=t=>{Object.assign(e.auth.groupsState,{errors:j({},e.auth.groupsState.errors,{[t.key]:t.value}),loaders:j({},e.auth.groupsState.loaders,{[t.key]:!1})})},i=t=>{Object.assign(e.auth.groupsState,t)},s=async()=>{const n=yc.GET_GROUPS,s=e.auth.groupsState;a({key:n,value:!0});try{const{groups:e}=await t.groups.getGroups({_groupsRelations:fc.rolesAndUsers});i(j({groups:e},s.selectedGroup&&{selectedGroup:e.find((e=>{var t;return e.id===(null==(t=s.selectedGroup)?void 0:t.id)}))}))}catch(e){o({key:n,value:Gc(e)})}finally{a({key:n,value:!1})}},r=async e=>{const n=yc.ADD_ROLES_TO_GROUP;a({key:n,value:!0});try{var i;await t.groups.addRolesToGroup(e.groupId,{roleIds:e.roleIds}),await s(),null==e||null==(i=e.callback)||i.call(e,!0)}catch(t){var r;o({key:n,value:Gc(t)}),null==e||null==(r=e.callback)||r.call(e,!1)}finally{a({key:n,value:!1})}},l=async e=>{const n=yc.ADD_USERS_TO_GROUP;a({key:n,value:!0});try{var i;await t.groups.addUsersToGroup(e.groupId,{userIds:e.userIds}),await s(),null==e||null==(i=e.callback)||i.call(e,!0)}catch(t){var r;null==e||null==(r=e.callback)||r.call(e,!1),o({key:n,value:Gc(t)})}finally{a({key:n,value:!1})}},c=async()=>{const e=yc.GET_GROUP_CONFIGURATION;a({key:e,value:!0});try{const n=await t.groups.getGroupConfiguration();i({groupsConfiguration:n})}catch(t){o({key:e,value:Gc(t)})}finally{a({key:e,value:!1})}};return{setUsersGroupsLoader:a,setUsersGroupsError:o,setGroupsState:i,resetUsersGroupsState:()=>{e.auth.groupsState=Xl(zu)},loadGroups:s,getGroupById:async e=>{const n=yc.GET_GROUP;a({key:n,value:!0});try{const o=await t.groups.getGroupById({groupId:e.groupId},{_groupsRelations:fc.rolesAndUsers});i({selectedGroup:o})}catch(e){o({key:n,value:Gc(e)})}finally{a({key:n,value:!1})}},createGroup:async e=>{const n=yc.CREATE_GROUP,{roleIds:i,userIds:c}=e,u=oe(e,Hu);a({key:n,value:!0});try{var d;const o=await t.groups.createGroup(j({name:u.name},!!u.description&&{description:u.description},{color:u.color}));null!=c&&c.length&&l({groupId:o.id,userIds:c}),null!=i&&i.length&&r({groupId:o.id,roleIds:i}),await s(),null==e||null==(d=e.callback)||d.call(e,!0)}catch(t){var g;o({key:n,value:Gc(t)}),null==e||null==(g=e.callback)||g.call(e,!1)}finally{a({key:n,value:!1})}},updateGroup:async e=>{const n=yc.UPDATE_GROUP;a({key:n,value:!0});try{var i;await t.groups.updateGroup(e),await s(),null==e||null==(i=e.callback)||i.call(e,!0)}catch(t){var r;o({key:n,value:Gc(t)}),null==e||null==(r=e.callback)||r.call(e,!1)}finally{a({key:n,value:!1})}},deleteGroup:async e=>{const n=yc.DELETE_GROUP;a({key:n,value:!0});try{var i;await t.groups.deleteGroup(e.groupId),await s(),null==e||null==(i=e.callback)||i.call(e,!0)}catch(t){var r;o({key:n,value:Gc(t)}),null==e||null==(r=e.callback)||r.call(e,!1,t)}finally{a({key:n,value:!1})}},addRolesToGroup:r,deleteRolesFromGroup:async e=>{const n=yc.DELETE_ROLES_FROM_GROUP;a({key:n,value:!0});try{var i;await t.groups.deleteRolesFromGroup(e.groupId,{roleIds:e.roleIds}),await s(),null==e||null==(i=e.callback)||i.call(e,!0)}catch(t){var r;o({key:n,value:Gc(t)}),null==e||null==(r=e.callback)||r.call(e,!1)}finally{a({key:n,value:!1})}},addUsersToGroup:l,deleteUsersFromGroup:async e=>{const n=yc.DELETE_USERS_FROM_GROUP;a({key:n,value:!0});try{var i;await t.groups.deleteUsersFromGroup(e.groupId,{userIds:e.userIds}),await s(),null==e||null==(i=e.callback)||i.call(e,!0)}catch(t){var r;o({key:n,value:Gc(t)}),null==e||null==(r=e.callback)||r.call(e,!1)}finally{a({key:n,value:!1})}},getGroupConfiguration:c,updateGroupConfiguration:async e=>{const n=yc.UPDATE_GROUP_CONFIGURATION;a({key:n,value:!0});try{await t.groups.updateGroupConfiguration(e),await c()}catch(e){o({key:n,value:Gc(e)})}finally{a({key:n,value:!1})}},getTeamUsers:async e=>{const n=yc.GET_TEAM_USERS;a({key:n,value:!0});try{const{items:o}=await t.users.getUsersV2({_filter:e.filter,_offset:e.pageOffset,_limit:e.pageSize,_includeSubTenants:!1});i({teamUsers:o})}catch(e){o({key:n,value:Gc(e)})}finally{a({key:n,value:!1})}}}},Ju={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}},Yu=e=>Mc(Ju,e),Xu=(e,t,n)=>({setGroupsDialogsState:t=>{Object.assign(e.auth.groupsDialogsState,t)},resetGroupsDialogsState:()=>{e.auth.groupsDialogsState=Xl(Ju)},openAddGroupDialog:()=>{e.auth.groupsDialogsState.addGroupDialogState.open=!0},closeAddGroupDialog:()=>{Object.assign(e.auth.groupsDialogsState.addGroupDialogState,{open:!1,group:void 0})},openAddMembersToGroupDialog:()=>{e.auth.groupsDialogsState.addMembersToGroupDialogState.open=!0},closeAddMembersToGroupDialog:()=>{Object.assign(e.auth.groupsDialogsState.addMembersToGroupDialogState,{open:!1,userIds:[]})},openEditGroupDialog:t=>{Object.assign(e.auth.groupsDialogsState.editGroupDialogState,j({},t,{open:!0}))},closeEditGroupDialog:()=>{Object.assign(e.auth.groupsDialogsState.editGroupDialogState,{open:!1,loading:!1,group:void 0})},openDeleteGroupDialog:t=>{Object.assign(e.auth.groupsDialogsState.deleteGroupDialogState,j({},t,{open:!0}))},closeDeleteGroupDialog:()=>{Object.assign(e.auth.groupsDialogsState.deleteGroupDialogState,{open:!1,loading:!1,group:void 0})},openDeleteMemberFromGroupDialog:t=>{Object.assign(e.auth.groupsDialogsState.deleteMemberFromGroupDialogState,t)},closeDeleteMemberFromGroupDialog:()=>{Object.assign(e.auth.groupsDialogsState.deleteMemberFromGroupDialogState,{open:!1,userId:void 0,email:void 0})}}),Qu={step:Sc.impersonating,loading:!1},Zu=e=>Mc(Qu,e),ed=["callback","events"],td=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auth.impersonateState,t)},i=()=>{e.auth.impersonateState=Xl(Qu)};return{setImpersonateState:o,resetImpersonateState:i,impersonate:async e=>{const{callback:n}=e,s=oe(e,ed);o({loading:!0});try{await t.impersonate.impersonate(s),o({step:Sc.success}),await Ql(1e3),await a.afterAuthNavigation({preventRedirectUrlOriginCleaning:!0}),i(),null==n||n(!0)}catch(e){o({loading:!1,error:Gc(e)})}}}},nd={flow:vc.Login,step:hc.preLogin,loading:!1,email:"",tenants:[]},ad=e=>Mc(nd,e),od=(e,t,n)=>{const a=n;const o=async(t,n={})=>{const{customLoginAuthenticatedUrl:a,forceStepUpUrl:o,shouldStepUpDuringLogin:i,preventRedirectUrlOriginCleaning:s=!1}=n,r=e.auth.onRedirectTo;let l;if(o)l=o;else{var c;if(i){const e=window.localStorage.getItem(pu);e&&!Xc(e)&&(l=e)}l||(l=await async function({customLoginAuthenticatedUrl:t,preventRedirectUrlOriginCleaning:n}){const{routes:a,includeQueryParam:o=!1,enforceRedirectToSameSite:i=!1,allowedRedirectOrigins:s=[]}=e.auth;if(t)return eu(t);const{authenticatedUrl:r,loginUrl:l,logoutUrl:c,socialLoginCallbackUrl:u,activateUrl:d}=a;let g=window.localStorage.getItem(pu);g&&![l,c,u,d].includes(g)||(g=r);const p=Qc({authenticatedUrl:g,includeQueryParam:o,enforceRedirectToSameSite:i,allowedRedirectOrigins:s});return n?p:(y=p).startsWith(null==(f=window)?void 0:f.location.origin)?y.replace(null==(S=window)?void 0:S.location.origin,""):y;var y,f,S}({customLoginAuthenticatedUrl:a,preventRedirectUrlOriginCleaning:s})),null==(c=window)||c.localStorage.removeItem(pu)}await Ql(200),await t(),r(l,{refresh:l.startsWith("http")})};return{afterAuthNavigationUtil:o,afterAuthNavigation:async t=>{var n,i;const{customLoginAuthenticatedUrl:s,stepUpUrl:r}=e.auth.routes,l=null==(n=window)?void 0:n.localStorage.getItem(du),c=e.auth.user;var u;if(l&&(null==(u=window)||u.localStorage.removeItem(du)),r&&l&&!fu(c))return o(a.resetLoginState,{forceStepUpUrl:r});let d=s;var g;return s||(await a.loadCustomLoginRoutes(),d=null==(g=e.auth.routes)?void 0:g.customLoginAuthenticatedUrl),o(a.resetLoginState,{customLoginAuthenticatedUrl:d,shouldStepUpDuringLogin:!!l,preventRedirectUrlOriginCleaning:null!=(i=null==t?void 0:t.preventRedirectUrlOriginCleaning)&&i})},afterStepUpAuthNavigation:async()=>o(a.resetStepUpState),__afterAuthenticationStateUpdate:async function({user:t,tenants:n=[],activeTenant:o},i={}){const s=e.auth.tenantsState;a.setAuthState(j({user:t,tenantsState:j({},s,{tenants:n,activeTenant:o,loading:!1})},i))}}},id={step:Ac.verify,loading:!1,saving:!1},sd=e=>Mc(id,e),rd=["callback"],ld=["callback"],cd=["callback"],ud=["callback","deviceId"],dd=["callback","deviceId"],gd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",pd=new Uint8Array(256);for(let e=0;e<gd.length;e++)pd[gd.charCodeAt(e)]=e;const yd=e=>{const t=new Uint8Array(e),n=t.length;let a,o="";for(a=0;a<n;a+=3)o+=gd[t[a]>>2],o+=gd[(3&t[a])<<4|t[a+1]>>4],o+=gd[(15&t[a+1])<<2|t[a+2]>>6],o+=gd[63&t[a+2]];return n%3==2?o=o.substring(0,o.length-1):n%3==1&&(o=o.substring(0,o.length-2)),o},fd=e=>{const t=.75*e.length,n=e.length;let a,o,i,s,r,l=0;const c=new Uint8Array(t);for(a=0;a<n;a+=4)o=pd[e.charCodeAt(a)],i=pd[e.charCodeAt(a+1)],s=pd[e.charCodeAt(a+2)],r=pd[e.charCodeAt(a+3)],c[l++]=o<<2|i>>4,c[l++]=(15&i)<<4|s>>2,c[l++]=(3&s)<<6|63&r;return c.buffer};function Sd(e,t="file"){const n=e.match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/);if(null==n)return null;const a=`image/${n[1]}`,o=((e,t)=>{const n=atob(e),a=[];for(let e=0;e<n.length;e+=512){const t=n.slice(e,e+512),o=new Array(t.length);for(let e=0;e<t.length;e++)o[e]=t.charCodeAt(e);a.push(new Uint8Array(o))}return new Blob(a,{type:t})})(n[2],a),i=new FormData;return i.append(t,new File([o],t,{type:a})),i}const hd=e=>{if(e instanceof Array){const t=[];for(const n of e)t.push(hd(n));return t}if(e instanceof ArrayBuffer)return yd(e);if(e instanceof Object){const t={};for(const n in e)t[n]=hd(e[n]);return t}return e},vd=e=>new Promise(((t,n)=>{const a=new FileReader;a.readAsText(e),a.onload=()=>t(a.result),a.onerror=n})),md=["callback","deviceId"],bd=["callback","deviceId"],Ad="input is invalid type",wd="undefined"!=typeof ArrayBuffer,Td="0123456789abcdef".split(""),Ed=[-2147483648,8388608,32768,128],Id=[24,16,8,0],kd=[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],Od=["hex","array","digest","arrayBuffer"],_d=[];Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),wd&&!ArrayBuffer.isView&&(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});const Pd=function(e){return function(t){const n=new Ld(!0).update(t);return null==n?void 0:n[e]()}},Ud=function(e){return function(t,n){const a=new Dd(t,!0).update(n);return null==a?void 0:a[e]()}};class Ld{constructor(e=!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=()=>Ld.prototype.digest(),e?(_d[0]=_d[16]=_d[1]=_d[2]=_d[3]=_d[4]=_d[5]=_d[6]=_d[7]=_d[8]=_d[9]=_d[10]=_d[11]=_d[12]=_d[13]=_d[14]=_d[15]=0,this.blocks=_d):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=e}update(e){if(this.finalized)return;let t;const n=typeof e;if("string"!==n){if("object"!==n)throw new Error(Ad);if(null===e)throw new Error(Ad);if(wd&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||wd&&ArrayBuffer.isView(e)))throw new Error(Ad);t=!0}let a,o,i=0;const s=e.length,r=this.blocks;for(;i<s;){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),t)for(o=this.start;i<s&&o<64;++i)r[o>>2]|=e[i]<<Id[3&o++];else for(o=this.start;i<s&&o<64;++i)a=e.charCodeAt(i),a<128?r[o>>2]|=a<<Id[3&o++]:a<2048?(r[o>>2]|=(192|a>>6)<<Id[3&o++],r[o>>2]|=(128|63&a)<<Id[3&o++]):a<55296||a>=57344?(r[o>>2]|=(224|a>>12)<<Id[3&o++],r[o>>2]|=(128|a>>6&63)<<Id[3&o++],r[o>>2]|=(128|63&a)<<Id[3&o++]):(a=65536+((1023&a)<<10|1023&e.charCodeAt(++i)),r[o>>2]|=(240|a>>18)<<Id[3&o++],r[o>>2]|=(128|a>>12&63)<<Id[3&o++],r[o>>2]|=(128|a>>6&63)<<Id[3&o++],r[o>>2]|=(128|63&a)<<Id[3&o++]);this.lastByteIndex=o,this.bytes+=o-this.start,o>=64?(this.block=r[16],this.start=o-64,this.hash(),this.hashed=!0):this.start=o}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 e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>2]|=Ed[3&t],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}hash(){let e,t,n,a,o,i,s,r,l,c,u,d=this.h0,g=this.h1,p=this.h2,y=this.h3,f=this.h4,S=this.h5,h=this.h6,v=this.h7;const m=this.blocks;for(e=16;e<64;++e)o=m[e-15],t=(o>>>7|o<<25)^(o>>>18|o<<14)^o>>>3,o=m[e-2],n=(o>>>17|o<<15)^(o>>>19|o<<13)^o>>>10,m[e]=m[e-16]+t+m[e-7]+n<<0;for(u=g&p,e=0;e<64;e+=4)this.first?(r=704751109,o=m[0]-210244248,v=o-1521486534<<0,y=o+143694565<<0,this.first=!1):(t=(d>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),n=(f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7),r=d&g,a=r^d&p^u,s=f&S^~f&h,o=v+n+s+kd[e]+m[e],i=t+a,v=y+o<<0,y=o+i<<0),t=(y>>>2|y<<30)^(y>>>13|y<<19)^(y>>>22|y<<10),n=(v>>>6|v<<26)^(v>>>11|v<<21)^(v>>>25|v<<7),l=y&d,a=l^y&g^r,s=v&f^~v&S,o=h+n+s+kd[e+1]+m[e+1],i=t+a,h=p+o<<0,p=o+i<<0,t=(p>>>2|p<<30)^(p>>>13|p<<19)^(p>>>22|p<<10),n=(h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7),c=p&y,a=c^p&d^l,s=h&v^~h&f,o=S+n+s+kd[e+2]+m[e+2],i=t+a,S=g+o<<0,g=o+i<<0,t=(g>>>2|g<<30)^(g>>>13|g<<19)^(g>>>22|g<<10),n=(S>>>6|S<<26)^(S>>>11|S<<21)^(S>>>25|S<<7),u=g&p,a=u^g&y^c,s=S&h^~S&v,o=f+n+s+kd[e+3]+m[e+3],i=t+a,f=d+o<<0,d=o+i<<0;this.h0=this.h0+d<<0,this.h1=this.h1+g<<0,this.h2=this.h2+p<<0,this.h3=this.h3+y<<0,this.h4=this.h4+f<<0,this.h5=this.h5+S<<0,this.h6=this.h6+h<<0,this.h7=this.h7+v<<0}hex(){this.finalize();const e=this.h0,t=this.h1,n=this.h2,a=this.h3,o=this.h4,i=this.h5,s=this.h6,r=this.h7;let l=Td[e>>28&15]+Td[e>>24&15]+Td[e>>20&15]+Td[e>>16&15]+Td[e>>12&15]+Td[e>>8&15]+Td[e>>4&15]+Td[15&e]+Td[t>>28&15]+Td[t>>24&15]+Td[t>>20&15]+Td[t>>16&15]+Td[t>>12&15]+Td[t>>8&15]+Td[t>>4&15]+Td[15&t]+Td[n>>28&15]+Td[n>>24&15]+Td[n>>20&15]+Td[n>>16&15]+Td[n>>12&15]+Td[n>>8&15]+Td[n>>4&15]+Td[15&n]+Td[a>>28&15]+Td[a>>24&15]+Td[a>>20&15]+Td[a>>16&15]+Td[a>>12&15]+Td[a>>8&15]+Td[a>>4&15]+Td[15&a]+Td[o>>28&15]+Td[o>>24&15]+Td[o>>20&15]+Td[o>>16&15]+Td[o>>12&15]+Td[o>>8&15]+Td[o>>4&15]+Td[15&o]+Td[i>>28&15]+Td[i>>24&15]+Td[i>>20&15]+Td[i>>16&15]+Td[i>>12&15]+Td[i>>8&15]+Td[i>>4&15]+Td[15&i]+Td[s>>28&15]+Td[s>>24&15]+Td[s>>20&15]+Td[s>>16&15]+Td[s>>12&15]+Td[s>>8&15]+Td[s>>4&15]+Td[15&s];return l+=Td[r>>28&15]+Td[r>>24&15]+Td[r>>20&15]+Td[r>>16&15]+Td[r>>12&15]+Td[r>>8&15]+Td[r>>4&15]+Td[15&r],l}digest(){this.finalize();const e=this.h0,t=this.h1,n=this.h2,a=this.h3,o=this.h4,i=this.h5,s=this.h6,r=this.h7,l=[e>>24&255,e>>16&255,e>>8&255,255&e,t>>24&255,t>>16&255,t>>8&255,255&t,n>>24&255,n>>16&255,n>>8&255,255&n,a>>24&255,a>>16&255,a>>8&255,255&a,o>>24&255,o>>16&255,o>>8&255,255&o,i>>24&255,i>>16&255,i>>8&255,255&i,s>>24&255,s>>16&255,s>>8&255,255&s];return l.push(r>>24&255,r>>16&255,r>>8&255,255&r),l}arrayBuffer(){this.finalize();const e=new ArrayBuffer(32),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),t.setUint32(28,this.h7),e}}class Dd extends Ld{constructor(e,t=!1){let n;super(t),this.inner=void 0,this.oKeyPad=void 0;const a=typeof e;if("string"===a){const t=[],a=e.length;let o,i=0;for(n=0;n<a;++n)o=e.charCodeAt(n),o<128?t[i++]=o:o<2048?(t[i++]=192|o>>6,t[i++]=128|63&o):o<55296||o>=57344?(t[i++]=224|o>>12,t[i++]=128|o>>6&63,t[i++]=128|63&o):(o=65536+((1023&o)<<10|1023&e.charCodeAt(++n)),t[i++]=240|o>>18,t[i++]=128|o>>12&63,t[i++]=128|o>>6&63,t[i++]=128|63&o);e=t}else{if("object"!==a)throw new Error(Ad);if(null===e)throw new Error(Ad);if(wd&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||wd&&ArrayBuffer.isView(e)))throw new Error(Ad)}var o;e.length>64&&(e=null==(o=new Ld(!0).update(e))?void 0:o.array());const i=[],s=[];for(n=0;n<64;++n){const t=e[n]||0;i[n]=92^t,s[n]=54^t}Ld.call(this,t),this.update(s),this.oKeyPad=i,this.inner=!0,this.sharedMemory=t}finalize(){if(super.finalize(),this.inner){this.inner=!1;const e=this.array();Ld.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(e),Ld.prototype.finalize.call(this)}}}const Rd=function(){const e=Pd("hex");e.create=function(){return new Ld},e.update=function(t){return e.create().update(t)};for(let t=0;t<Od.length;++t){const n=Od[t];e[n]=Pd(n)}return e}();async function Cd(e){const t=Rd.digest((new TextEncoder).encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}async function Nd(e){const t=await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}async function Md(e){var t,n;return null!=(t=window.crypto)&&null!=(n=t.subtle)&&n.digest?Nd(e):(console.warn("Generating CodeChallenge in non-secure domain:",window.location.origin),Cd(e))}function Fd(e=16){let t="";const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(let a=0;a<e;a++)t+=n.charAt(Math.floor(Math.random()*n.length));return t}!function(){const e=Ud("hex");e.create=function(e){return new Dd(e)},e.update=function(t,n){return e.create(t).update(n)};for(let t=0;t<Od.length;++t){const n=Od[t];e[n]=Ud(n)}}();const $d=new class{constructor(){this.loginWithSSO=e=>{if(this.isWebkitAvailable()){var t,n,a;null==(t=window.webkit)||null==(n=t.messageHandlers)||null==(a=n.FronteggNativeBridge)||a.postMessage(JSON.stringify({action:"loginWithSSO",payload:e}))}else{if(!this.isJsInterfaceAvailable())throw new Error("FronteggNativeBridge is not available");var o;null==(o=window.FronteggNativeBridge)||o.loginWithSSO(e)}},this.loginWithSocialLogin=e=>{if(this.isWebkitAvailable()){var t,n,a;null==(t=window.webkit)||null==(n=t.messageHandlers)||null==(a=n.FronteggNativeBridge)||a.postMessage(JSON.stringify({action:"loginWithSocialLogin",payload:e}))}else{if(!this.isJsInterfaceAvailable())throw new Error("FronteggNativeBridge is not available");var o;null==(o=window.FronteggNativeBridge)||o.loginWithSocialLogin(e)}},this.promptSocialLoginConsent=()=>{var e,t;return null!=(e=null==(t=window.FronteggNativeBridgeFunctions)?void 0:t.shouldPromptSocialLoginConsent)&&e}}isWebkitAvailable(){var e,t;return null!=(null==(e=window.webkit)||null==(t=e.messageHandlers)?void 0:t.FronteggNativeBridge)}isJsInterfaceAvailable(){return null!=window.FronteggNativeBridge}isSocialLoginAvailable(){return this.isAvailable("loginWithSocialLogin")}isLoginWithSSOAvailable(){return this.isAvailable("loginWithSSO")}isAvailable(e){var t,n;return!(!this.isWebkitAvailable()&&!this.isJsInterfaceAvailable())&&null!=(t=null==(n=window.FronteggNativeBridgeFunctions)?void 0:n[e])&&t}},jd=["callback"],Gd=["callback"],xd=["callback"],Vd=["callback"],Bd=["callback"],Wd=["callback","events"],zd=["callback"],Kd=["callback"],Hd=["user"],qd=["callback"],Jd=["callback"],Yd=["callback"],Xd=["callback"],Qd=["callback"],Zd=["callback"],eg=(e,t,n)=>{const a=n,o=t=>{var n;const{routes:a,loginState:o}=e.auth,i=null!=(n=localStorage.getItem("register-quick-login"))?n:o.quickLoginToRegister;return i&&"true"!==localStorage.getItem(`${t.id}-${i}`)&&!window.location.pathname.endsWith(a.logoutUrl)},i=async()=>{e.auth.hostedLoginBox?await(async()=>{const n=e.auth.user;if(null==n||!n.refreshToken)return ne.setAccessToken(null),ne.setUser(null),void a.setAuthState({user:null,isAuthenticated:!1});try{const e={grant_type:"refresh_token",refresh_token:null==n?void 0:n.refreshToken},o=await t.auth.exchangeOAuthTokensV2(e),i=await s(o.user);await a.__afterAuthenticationStateUpdate(j({},o,{user:i}),{isAuthenticated:!0})}catch(e){ne.setAccessToken(null),ne.setUser(null),a.setAuthState({user:null,isAuthenticated:!1})}})():await(async()=>{try{const{routes:i,loginState:l,onRedirectTo:c}=e.auth,{user:u,tenants:d=[],activeTenant:g}=await t.auth.refreshTokenV3();if(bu(u)){const e=await a.getMfaRequiredState(u);a.setAuthState(e),c(i.loginUrl,{preserveQueryParams:!0})}else{var n;u.id&&localStorage.setItem("userId",u.id);const e=null!=(n=localStorage.getItem("register-quick-login"))?n:l.quickLoginToRegister,t=o(u),i=await s(u);a.__afterAuthenticationStateUpdate({user:i,tenants:d,activeTenant:g},{loginState:j({},l,{quickLoginToRegister:e,flow:t?vc.RegisterQuickLogin:vc.Login}),isAuthenticated:!0}),await r(t)}}catch(e){ne.setAccessToken(null),ne.setUser(null),a.setAuthState({user:void 0,isAuthenticated:!1})}})()},s=async t=>{var n;const a=null==(n=e.auth.user)?void 0:n.entitlements;return gc(a,null==t?void 0:t.entitlements)?j({},t,{entitlements:a}):t},r=async t=>{var n;const o=new URL(null==(n=window)?void 0:n.location.href),{routes:i,loginState:s,onRedirectTo:r}=e.auth,l=o.searchParams.get("invitationToken"),c=[i.socialLoginCallbackUrl,i.oidcRedirectUrl,i.samlCallbackUrl];l||c.push(i.loginUrl,i.signUpUrl),t?r(i.loginUrl):c.some((e=>e&&window.location.pathname.endsWith(e)))&&(s.isNewUser&&i.signUpSuccessUrl&&i.socialLoginCallbackUrl===window.location.pathname?r(i.signUpSuccessUrl,{refresh:i.signUpSuccessUrl.startsWith("http")}):await a.afterAuthNavigation())},l=async()=>{try{const{isActive:e}=await t.auth.getSSOPublicConfiguration();a.setAuthState({isSSOAuth:e})}catch(e){a.setAuthState({isSSOAuth:!1})}},c=async()=>{let e;try{var n;const a=await t.metadata.getSamlMetadata();e=null==a||null==(n=a.configuration)?void 0:n.acsUrl}catch(e){console.error(e)}a.setAuthState({ssoACS:e})},u=t=>{Object.assign(e.auth.loginState,t)},d=async t=>{let{callback:n}=t,o=oe(t,jd);const i=e.auth.securityPolicyState.publicPolicy.policy;if(null==i||!i.authStrategy)return a.setLoginState({step:hc.loginWithPassword,loading:!1}),void(null==n||n());(null==i?void 0:i.authStrategy)===rn.EmailAndPassword?(a.setLoginState({step:hc.loginWithPassword,loading:!1}),null==n||n()):[rn.MagicLink,rn.Code,rn.SmsCode].includes(null==i?void 0:i.authStrategy)?await a.passwordlessPreLogin(j({},o,{type:null==i?void 0:i.authStrategy,callback:n})):(a.setLoginState({step:hc.loginWithPassword,loading:!1}),null==n||n())},g=async e=>{const{user:t,tenants:n=[],activeTenant:o}=e,i={step:Ac.recoveryCode,loading:!1,error:void 0,saving:!1};null!=t&&t.recoveryCode&&(i.recoveryCode=t.recoveryCode),a.setMfaState(i),a.setUser(t),a.setTenantsState({tenants:n,activeTenant:o,loading:!1}),t.id&&localStorage.setItem("userId",t.id)};return j({setLoginState:u,resetLoginState:()=>{e.auth.loginState=Xl(nd)},requestAuthorize:async e=>{const t=[],n=[];t.push(i()),e&&(a.setAuthState({isLoading:!0}),t.push(a.loadSocialLoginsConfigurationV2()),t.push(a.loadAllowSignUps()),t.push(a.loadPublicAuthStrategiesPolicy()),t.push(l()),t.push(a.loadVendorPublicInfo()),t.push(c()),n.push(a.loadCustomLoginRoutes())),await Promise.all(t),n.length>0&&await Promise.all(n),a.setAuthState({isLoading:!1})},requestAuthorizeSSR:async t=>{const n=[];n.push(a.loadSocialLoginsConfigurationV2()),n.push(a.loadAllowSignUps()),n.push(l()),n.push(a.loadVendorPublicInfo()),n.push(c()),n.push((async({accessToken:t,user:n})=>{if(!t)return void a.setAuthState({user:void 0,isAuthenticated:!1});const{onRedirectTo:o,routes:i}=e.auth;if(bu(n)){const e=await a.getMfaRequiredState(n);a.setAuthState(e),o(i.loginUrl,{preserveQueryParams:!0})}})(t)),n.push(a.loadCustomLoginRoutes()),await Promise.all(n)},preLogin:async n=>{const{email:a,recaptchaToken:o,invitationToken:i,callback:s}=n;u({loading:!0});try{const n=e.auth.onRedirectTo,r=tu(nu),l=await t.auth.preLoginV2({email:a,tenantId:r}),{address:c,idpType:g}=null!=l?l:{};if(c){let t=c;if(g===_c.Oidc&&!t.includes("redirect_uri")){const{oidcRedirectUrl:n}=e.auth.routes;t+=`&redirect_uri=${window.location.origin}${n}`}$d.isLoginWithSSOAvailable()?($d.loginWithSSO(a),u({loading:!1}),null==s||s()):(u({step:hc.redirectToSSO,loading:!1,ssoRedirectUrl:t}),setTimeout((()=>{n(t,{refresh:!0})}),2e3))}else await d({email:a,recaptchaToken:o,callback:s,invitationToken:i})}catch(e){await d({email:a,recaptchaToken:o,callback:s,invitationToken:i})}},postLogin:async n=>{const{onRedirectTo:o,routes:i}=e.auth;u({loading:!0});try{const e=await t.auth.postLogin(n);a.setAuthState({user:e.accessToken?e:void 0,isAuthenticated:!!e.accessToken}),await a.afterAuthNavigation()}catch(e){setTimeout((()=>{o(i.authenticatedUrl)}),1e3),u({step:hc.loginWithSSOFailed,loading:!1})}},login:async n=>{const{email:o,password:i,recaptchaToken:s,invitationToken:r,callback:l}=n;u({loading:!0});try{const{user:n,tenants:c=[],activeTenant:d}=await t.auth.loginv2({email:o,password:i,recaptchaToken:s,invitationToken:r}),{onRedirectTo:g,routes:p}=e.auth;if(bu(n)){const e=await a.getMfaRequiredState(n);a.setAuthState(e),g(p.loginUrl,{preserveQueryParams:!0})}else{const t=e.auth.loginState,i=!!n.accessToken;n.id&&localStorage.setItem("userId",n.id),await a.__afterAuthenticationStateUpdate({user:n,tenants:c,activeTenant:d},{loginState:{flow:t.flow,quickLoginToRegister:t.quickLoginToRegister,email:o,loading:!1,error:void 0,mfaToken:n.mfaToken,step:t.flow===vc.Login?hc.success:t.step,tenants:c,tenantsLoading:!0,isBreachedPassword:n.isBreachedPassword},isAuthenticated:i});const[s]=await a.__getFeatureFlags(["security-center-show-login-flows"]);t.flow===vc.Login&&(s&&n.isBreachedPassword&&!i?u({step:hc.breachedPassword,loading:!1}):i&&(await a.__shouldShowPromptPasskeys()?(u({step:hc.promptPasskeys,loading:!1}),g(p.loginUrl,{preserveQueryParams:!0})):await a.afterAuthNavigation()))}localStorage.removeItem("register-quick-login"),null==l||l(!0)}catch(e){ne.setAccessToken(null),ne.setUser(null),null==l||l(!1,e),u({email:o,error:Gc(e),loading:!1})}},logout:async n=>{const o=e.auth.hostedLoginBox;a.setAuthState({isLoading:!0});try{o?await t.auth.OAuthLogout():await t.auth.logout()}catch{}ne.isSessionPerTenantEnabled()&&wt(),a.resetAuthState(),await a.requestAuthorize(!0),null==n||n()},silentLogout:async e=>{var n;try{await t.auth.logout()}catch{}ne.isSessionPerTenantEnabled()&&wt(),setTimeout((()=>{var t;return null==e||null==(t=e.callback)?void 0:t.call(e,!0)}),null!=(n=null==e?void 0:e.callbackTimeout)?n:500)},recoverMfa:async e=>{u({loading:!0});try{var n;await t.auth.recoverMfaToken(e),u({loading:!1,error:void 0,step:hc.preLogin}),a.setAuthState({user:void 0,isAuthenticated:!1}),null==(n=e.callback)||n.call(e,!0)}catch(t){var o;u({error:Gc(t),loading:!1}),null==(o=e.callback)||o.call(e,!1,t)}},quickSmsPasswordlessPreLogin:async e=>{const{callback:n}=e,a=oe(e,Gd);try{u({loading:!0});const e=await t.auth.passwordlessPreLogin(j({},a,{type:rn.SmsCode}));u({step:hc.loginWithQuickSmsOtc,loading:!1,phoneNumber:null==e?void 0:e.phoneNumber,error:void 0}),null==n||n(!0)}catch(e){u({error:Gc(e),loading:!1}),null==n||n(e)}},changePhoneNumberWithVerification:async e=>{const{callback:n}=e,a=oe(e,xd);try{u({loading:!0});const e=await t.auth.changePhoneNumberWithVerification(a);u({phoneNumber:a.phoneNumber,loading:!1,changePhoneId:e.changePhoneId,step:hc.loginWithQuickSmsOtc,error:void 0}),null==n||n(!0)}catch(e){u({error:Gc(e),loading:!1})}},verifyChangePhoneNumber:async e=>{const{callback:n}=e,a=oe(e,Vd);try{u({loading:!0}),await t.auth.verifyChangePhoneNumber(a),u({loading:!1}),null==n||n(!0)}catch(e){u({error:Gc(e),loading:!1})}},passwordlessPreLogin:async e=>{const{callback:n}=e,a=oe(e,Bd);try{let e;u({loading:!0}),ru(a)&&(e=a.email);const o=await t.auth.passwordlessPreLogin(a),i=Jc[a.type];u({step:i,loading:!1,phoneNumber:null==o?void 0:o.phoneNumber,email:e,error:void 0}),null==n||n()}catch(e){u({error:Gc(e),loading:!1}),null==n||n(e)}},passwordlessPostLogin:async n=>{const{callback:o,events:i}=n,s=oe(n,Wd);try{u({loading:!0});const{user:n,tenants:l=[],activeTenant:c}=await t.auth.passwordlessPostLoginV2(s),{routes:d,onRedirectTo:g}=e.auth;if(bu(n)){const e=await a.getMfaRequiredState(n);a.setAuthState(e),g(d.loginUrl,{preserveQueryParams:!0})}else{const t=e.auth.loginState;if(n.emailVerified){var r;const e={email:n.email,origin:Uc.PASSWORDLESS,id:n.id,tenantId:n.tenantId,createdAt:new Date,name:n.name};null==i||null==(r=i.userVerified)||r.call(i,e),qc(Hc.USER_VERIFIED,e)}n.id&&localStorage.setItem("userId",n.id),await a.__afterAuthenticationStateUpdate({user:n,tenants:l,activeTenant:c}),u({error:void 0}),a.setAuthState({isLoading:!1}),t.flow===vc.Login?await a.__shouldShowPromptPasskeys()?(a.setLoginState({step:hc.promptPasskeys,loading:!1}),g(d.loginUrl,{preserveQueryParams:!0})):(a.setAuthState({isAuthenticated:!0}),await a.afterAuthNavigation()):g(d.loginUrl,{preserveQueryParams:!0}),localStorage.removeItem("register-quick-login"),null==o||o(!0)}}catch(e){u({error:Gc(e,"Failed to authenticate")}),null==o||o(null,e)}finally{u({loading:!1})}},verifyInviteToken:async e=>{try{u({loading:!0});const{name:n}=await t.auth.verifyInviteToken(e);u({inviteTokenTenantName:n})}catch(e){u({inviteTokenError:Gc(e,"We couldn't verify your invitation")})}finally{u({loading:!1})}},webAuthnPrelogin:async e=>{const{callback:n}=e,o=oe(e,zd);try{var i;a.setPasskeysState({loading:!0}),u({loading:!0});const{options:e}=await t.auth.webAuthnPreLogin(o);e.challenge=fd(e.challenge),e.allowCredentials=null==(i=e.allowCredentials)?void 0:i.map((e=>j({},e,{id:fd(e.id)}))),u({error:void 0}),null==n||n(e)}catch(e){u({error:Gc(e)}),null==n||n(null)}finally{a.setPasskeysState({loading:!1}),u({loading:!1})}},webAuthnPostLogin:async n=>{const{callback:o}=n,i=oe(n,Kd);try{var s;a.setPasskeysState({loading:!0}),u({loading:!0});const n=hd(i.publicKey),r=await t.auth.webAuthnPostLoginV2(j({},n,{response:j({},n.response,{userHandle:null!=(s=n.response.userHandle)?s:void 0}),recaptchaToken:i.recaptchaToken,invitationToken:i.invitationToken})),{user:l}=r,c=oe(r,Hd);if(bu(l)){const{routes:t,onRedirectTo:n}=e.auth,o=await a.getMfaRequiredState(l);a.setAuthState(o),n(t.loginUrl,{preserveQueryParams:!0})}else l.id&&localStorage.setItem("userId",l.id),await a.__afterAuthenticationStateUpdate(j({user:l},c),{isAuthenticated:!0}),u({error:void 0}),await a.afterAuthNavigation(),null==o||o(!0)}catch(e){u({error:Gc(e)}),null==o||o(null)}finally{a.setPasskeysState({loading:!1}),u({loading:!1})}},webAuthnCreateNewDeviceSession:async e=>{const{callback:n}=e;try{u({loading:!0});const{options:e}=await t.auth.webAuthnCreateNewDeviceSession();e.user.id=fd(e.user.id),e.challenge=fd(e.challenge),e.excludeCredentials=[],null==n||n(e)}catch(e){u({error:Gc(e)}),null==n||n(null)}finally{u({loading:!1})}},webAuthnVerifyNewDeviceSession:async e=>{const{callback:n}=e,a=oe(e,qd);try{u({loading:!0});const e=hd(a.publicKey),o="platform"===(null==e?void 0:e.authenticatorAttachment)?fn.Platform:fn.CrossPlatform;await t.auth.verifyNewDeviceSession({id:e.id,response:e.response,deviceType:o}),null==n||n(!0)}catch(e){u({error:Gc(e)}),null==n||n(null)}finally{u({loading:!1})}},getUserIP:async e=>{const{callback:n}=e;try{const{ip:e}=await t.metadata.getCurrentUserIpMetadata();a.setAuthState({userIp:e}),null==n||n(!0)}catch(e){null==n||n(!1)}},preEnrollMFAWebAuthnForLogin:async e=>{const{callback:n}=e,a=oe(e,Jd);u({loading:!0});try{var o;const e=await t.auth.preEnrollMFAWebAuthnForLogin(a),i=j({},e.options,{challenge:fd(e.options.challenge),user:j({},e.options.user,{id:fd(e.options.user.id)}),excludeCredentials:null==(o=e.options.excludeCredentials)?void 0:o.map((e=>j({},e,{id:fd(e.id)})))});u({loading:!1}),null==n||n({options:i,webauthnToken:e.webauthnToken})}catch(e){u({loading:!1,error:Gc(e)}),null==n||n(null)}},enrollMFAWebAuthnForLogin:async e=>{const{callback:n}=e,a=oe(e,Yd);u({loading:!0});try{const e=hd(a.publicKey),o=await t.auth.enrollMFAWebAuthnForLoginV2(j({},a,{options:e}));await g(o),u({loading:!1}),null==n||n(!0)}catch(e){u({loading:!1,error:Gc(e)}),null==n||n(null)}},enrollMFAAuthenticatorAppForLogin:async e=>{const{callback:n}=e,a=oe(e,Xd);u({loading:!0});try{const e=await t.auth.enrollMFAAuthenticatorAppForLoginV2(a);await g(e),u({loading:!1}),null==n||n(!0)}catch(e){u({loading:!1,error:Gc(e)}),null==n||n(null)}},preEnrollMFASMSForLogin:async e=>{const{callback:n}=e,o=oe(e,Qd);u({loading:!0});try{const e=await t.auth.preEnrollMFASMSForLogin(o);a.setMfaState({otcToken:e.otcToken,step:Ac.smsVerifyCode,phoneNumber:e.phoneNumber}),u({loading:!1}),null==n||n(!0)}catch(e){u({loading:!1,error:Gc(e)}),null==n||n(null)}},enrollMFASMSForLogin:async e=>{const{callback:n}=e,a=oe(e,Zd);u({loading:!0});try{const e=await t.auth.enrollMFASMSForLoginV2(a);await g(e),u({loading:!1}),null==n||n(!0)}catch(e){u({loading:!1,error:Gc(e)}),null==n||n(null)}},handleEnrollMFAResponse:g,resetBreachedPassword:async e=>{u({loading:!0});try{await t.auth.forgotPassword(e),u({loading:!1,error:void 0,step:hc.breachedPasswordSuccess}),a.setAuthState({isAuthenticated:!1})}catch(e){u({loading:!1,error:Gc(e)})}},refreshTokenForSocialLogins:async()=>{e.auth.hostedLoginBox?await(async()=>{const{user:n}=e.auth;if(null==n||!n.refreshToken)return ne.setAccessToken(null),ne.setUser(null),void a.setAuthState({user:null,isAuthenticated:!1});try{const e={grant_type:"refresh_token",refresh_token:null==n?void 0:n.refreshToken},o=await t.auth.exchangeOAuthTokensV2(e),i=await s(o.user);await a.__afterAuthenticationStateUpdate(j({},o,{user:i}),{isAuthenticated:!0})}catch(e){ne.setAccessToken(null),ne.setUser(null),a.setAuthState({user:null,isAuthenticated:!1})}})():await(async()=>{try{const{routes:i,loginState:l,onRedirectTo:c}=e.auth,{user:u,tenants:d=[],activeTenant:g}=await t.auth.refreshTokenV3();if(bu(u)){const e=await a.getMfaRequiredState(u);a.setAuthState(e),c(i.loginUrl,{preserveQueryParams:!0})}else{const e=await s(u);if(await a.__shouldShowPromptPasskeys())a.setLoginState({step:hc.promptPasskeys,loading:!1}),await a.__afterAuthenticationStateUpdate({user:e,tenants:d,activeTenant:g},{isLoading:!1}),c(i.loginUrl,{preserveQueryParams:!0});else{var n;u.id&&localStorage.setItem("userId",u.id);const t=null!=(n=localStorage.getItem("register-quick-login"))?n:l.quickLoginToRegister,i=o(u);await a.__afterAuthenticationStateUpdate({user:e,tenants:d,activeTenant:g},{loginState:j({},l,{quickLoginToRegister:t,flow:i?vc.RegisterQuickLogin:vc.Login}),isAuthenticated:!0}),await r(i)}}}catch(e){ne.setAccessToken(null),ne.setUser(null),a.setAuthState({user:void 0,isAuthenticated:!1})}})()},__refreshToken:i},((e,t,n)=>{const a=n,o=async()=>{const e=await t.auth.silentOAuthRefreshTokenV2();if(null==e||!e.user)throw new Error("couldn't refresh user token with oauth service");await a.__afterAuthenticationStateUpdate(e,{isAuthenticated:!0,isLoading:!1})},i=async n=>{var o;const{routes:i,onRedirectTo:s}=e.auth,{context:r,urlStrategy:l}=e.root;if(wu(l)===i.hostedLoginRedirectUrl)return void console.debug("Calling loginWithRedirect while in hostedLoginCallback route");a.setAuthState({isLoading:!0});const c=Fd(),u=Fd(),d=await Md(u);localStorage.setItem(yu,u);let g=`${window.location.origin}${"path"===l?"":"#"}${i.hostedLoginRedirectUrl}`;await a.loadCustomLoginRoutes();const p=null==(o=e.auth.customLoginState)?void 0:o.customLoginSearchParams;p&&(g.endsWith("/")&&(g=g.slice(0,-1)),g+=p);const y=`${t.fetch.getBaseUrl(r,"/oauth/authorize")}/oauth/authorize`,f=j({response_type:"code",client_id:r.clientId||"INVALID-CLIENT-ID",scope:"openid email profile",redirect_uri:g,code_challenge:d,code_challenge_method:"S256",nonce:c},n);if(r.tenantResolver){var S;const e=await(null==(S=r.tenantResolver)?void 0:S.call(r));null!=e&&e.tenant&&(f.organization=e.tenant)}const h=tu(nu);h&&(f.tenantId=h),s(`${y}?${new URLSearchParams(f).toString()}`,{refresh:!0})};return{requestHostedLoginAuthorize:async t=>{var n;null==(n=localStorage)||n.removeItem(du);const a=e.auth.disableSilentRefresh;if("login"===(null==t?void 0:t.prompt))return await i(t);try{if(a)throw new Error("silent refresh is disabled");return await o()}catch(e){return await i(t)}},requestHostedLoginAuthorizeV2:async t=>{var n,s;const{shouldRedirectToLogin:r,firstTime:l,loginDirectAction:c}=null!=t?t:{};let{additionalParams:u}=null!=t?t:{};if(null==(n=localStorage)||n.removeItem(du),l){const t=e.root.urlStrategy,n=wu(t);if(a.setAuthState({isLoading:!0}),su(n))return}const d=e.auth.disableSilentRefresh;if(c&&(u=u||{},u.login_direct_action=btoa(JSON.stringify(c))),"login"===(null==(s=u)?void 0:s.prompt))return await i(u);try{if(d)throw new Error("silent refresh is disabled");return await o()}catch(e){return r?await i(u):void a.setAuthState({isLoading:!1})}},__requestHostedLoginAuthorize:i,__requestHostedLoginSilentAuthorize:o,handleHostedLoginCallback:async n=>{var o;const i=localStorage.getItem(yu)||"INVALID-CODE-VERIFIER",s=e.auth.routes,r=e.root.urlStrategy;let l=`${window.location.origin}${"path"===r?"":"#"}${s.hostedLoginRedirectUrl}`;await a.loadCustomLoginRoutes();const c=null==(o=e.auth.customLoginState)?void 0:o.customLoginSearchParams;c&&(l.endsWith("/")&&(l=l.slice(0,-1)),l+=c);const u={code:n.code,redirect_uri:l,code_verifier:i,grant_type:"authorization_code"};try{const n=await t.auth.exchangeOAuthTokensV2(u);await a.__afterAuthenticationStateUpdate(n,{isAuthenticated:!0,isLoading:!1})}catch(e){a.setAuthState({isLoading:!1}),console.error("Failed to exchangeOAuthTokens",e)}finally{const t=e.auth.user,n=window.localStorage.getItem(du);window.localStorage.removeItem(du),n&&fu(t)?await a.afterStepUpAuthNavigation():await a.afterAuthNavigation()}}}})(e,t,n),od(e,0,n),function(e,t,n){const a=n,o=async t=>{const n=e.root.appName;return ut.getFeatureFlags(t,n)},i=async()=>await a.afterStepUpAuthNavigation(),s=async t=>{const n=e.auth.loginState,i=e.auth.mfaState.step,[s]=await o(["security-center-show-login-flows"]);if(n.flow===vc.Login)if(s&&n.isBreachedPassword&&!t)a.setLoginState({step:hc.breachedPassword,loading:!1});else{const e=await a.__shouldShowPromptPasskeys();i===Ac.smsVerifyCode&&e?a.setLoginState({step:hc.promptPasskeys,loading:!1}):await a.afterAuthNavigation()}};return{postHandleVerifyMFAResponseForStepUp:i,postHandleVerifyMFAResponseForLogin:s,handleVerifyMFAResponse:async(e,t=!1)=>{const{user:n,tenants:o,activeTenant:r}=e;a.setUser(n),a.setTenantsState({tenants:o,activeTenant:r,loading:!1}),n.id&&localStorage.setItem("userId",n.id);const l=!!n.accessToken;return a.setAuthState({isAuthenticated:l}),t?await i():await s(l)},__getFeatureFlags:o}}(e,0,n),((e,t,n)=>({getMfaRequiredState:async n=>{let a=hc.loginWithTwoFactor;const o=Xl(id),i=e.auth.loginState,{isAllowedToRemember:s,mfaDeviceExpiration:r}=await t.auth.checkIfAllowToRememberMfaDevice(n.mfaToken);!n.hasOwnProperty("mfaEnrolled")||n.mfaEnrolled?Object.assign(o,{mfaDevices:n.mfaDevices,step:ou(n.mfaDevices)}):(Object.assign(o,{step:iu(n.mfaStrategies),qrCode:n.qrCode,recoveryCode:n.recoveryCode,loading:!1,mfaToken:n.mfaToken,mfaStrategies:n.mfaStrategies}),a=hc.forceTwoFactor);let l={};const c=localStorage.getItem("register-quick-login");return c&&(l={quickLoginToRegister:c,flow:vc.RegisterQuickLogin}),{user:void 0,isAuthenticated:!1,mfaState:o,loginState:j({},i,l,{mfaToken:n.mfaToken,mfaRequired:n.mfaRequired,loading:!1,error:void 0,step:a,tenantsLoading:!0,email:n.userEmail,tenants:[],allowRememberMfaDevice:s,mfaDeviceExpiration:r,isBreachedPassword:n.isBreachedPassword})}}}))(e,t),((e,t,n)=>{const a=n,o=async(n,o,i)=>{let{callback:s}=n,r=oe(n,rd);o({loading:!0,error:void 0});try{const{user:n,tenants:l=[],activeTenant:c}=await t.auth.loginWithMfaV2(r),u=!!n.accessToken,d=await async function(t,n,a){const o=e.auth.loginState;let i={};if(!a){const e=o.flow===vc.Login?hc.success:o.step;i={loginState:{flow:o.flow,quickLoginToRegister:o.quickLoginToRegister,loading:!1,step:e,error:void 0,tenants:t}}}return j({},i,{isAuthenticated:n})}(l,u,i);return await a.__afterAuthenticationStateUpdate({user:n,tenants:l,activeTenant:c},d),n.id&&localStorage.setItem("userId",n.id),o({loading:!1,error:void 0}),i?await async function(e){await a.afterStepUpAuthNavigation(),null==e||e(!0)}(s):await async function(t,n){const o=e.auth.loginState;if(o.flow!==vc.Login)return;const[i]=await a.__getFeatureFlags(["security-center-show-login-flows"]);i&&o.isBreachedPassword&&!t?a.setLoginState({step:hc.breachedPassword,loading:!1}):await a.__shouldShowPromptPasskeys()?a.setLoginState({step:hc.promptPasskeys,loading:!1}):await a.afterAuthNavigation(),null==n||n(!0)}(u,s)}catch(e){o({loading:!1,error:Gc(e)}),null==s||s(!1,e)}};return{mfaWithAuthenticator:o,loginWithMfa:async e=>await o(e,a.setLoginState,!1)}})(e,t,n),((e,t,n)=>{const a=n,o=async(e,n)=>{var o;let{callback:i}=e,s=oe(e,ld);(n=null!=(o=n)?o:a.setLoginState)({loading:!0,error:void 0});try{const e=await t.auth.preVerifyMFAEmailCode(s);a.setMfaState({otcToken:e.otcToken,step:Ac.emailVerifyCode}),n({loading:!1,error:void 0}),null==i||i(!0)}catch(e){n({error:Gc(e)}),null==i||i(null)}},i=async(e,n)=>{var o;let{callback:i}=e,s=oe(e,cd);(n=null!=(o=n)?o:a.setLoginState)({loading:!0});try{const e=await t.auth.verifyMFAEmailCodeV2(s);await a.handleVerifyMFAResponse(e),n({loading:!1,error:void 0}),null==i||i(!0)}catch(e){n({loading:!1,error:Gc(e)}),null==i||i(null)}};return{preVerifyMFAEmailCode:o,verifyMFAEmailCode:i,preVerifyMFAEmailCodeForLogin:async e=>await o(e,a.setLoginState),verifyMFAEmailCodeForLogin:async e=>await i(e,a.setLoginState)}})(0,t,n),((e,t,n)=>{const a=n,o=async(e,n)=>{let{callback:o,deviceId:i}=e,s=oe(e,ud);n({loading:!1,error:void 0});try{const e=await t.auth.preVerifyMFASMSForLogin(i,s);a.setMfaState({otcToken:e.otcToken,step:Ac.smsVerifyCode,phoneNumber:e.phoneNumber}),n({loading:!1,error:void 0}),null==o||o(!0)}catch(e){n({loading:!1,error:Gc(e)}),null==o||o(null)}},i=async(e,n,o=!1)=>{let{callback:i,deviceId:s}=e,r=oe(e,dd);n({loading:!0});try{const e=await t.auth.verifyMFASMSForLoginV2(s,r);await a.handleVerifyMFAResponse(e,o),n({loading:!1,error:void 0}),null==i||i(!0)}catch(e){n({loading:!1,error:Gc(e)}),null==i||i(null)}};return{preVerifyMFASMS:o,verifyMFASMS:i,preVerifyMFASMSForLogin:async e=>await o(e,a.setLoginState),verifyMFASMSForLogin:async e=>await i(e,a.setLoginState,!1)}})(0,t,n),((e,t,n)=>{const a=n,o=async(e,n)=>{let{callback:a,deviceId:o}=e,i=oe(e,md);n({loading:!0});try{var s;const e=await t.auth.preVerifyMFAWebAuthnForLogin(o,i),r=j({},e.options,{challenge:fd(e.options.challenge),allowCredentials:null==(s=e.options.allowCredentials)?void 0:s.map((e=>j({},e,{id:fd(e.id)})))});n({loading:!1,error:void 0}),null==a||a({options:r,webauthnToken:e.webauthnToken})}catch(e){n({loading:!1,error:Gc(e)}),null==a||a(null)}},i=async(e,n,o)=>{let{callback:i,deviceId:s}=e,r=oe(e,bd);n({loading:!0});try{const e=hd(r.publicKey),l=await t.auth.verifyMFAWebAuthnForLoginV2(s,j({},r,{options:e}));await a.handleVerifyMFAResponse(l,o),n({loading:!1,error:void 0}),null==i||i(!0)}catch(e){n({loading:!1,error:Gc(e)}),null==i||i(null)}};return{preVerifyMFAWebAuthn:o,verifyMFAWebAuthn:i,preVerifyMFAWebAuthnForLogin:async e=>await o(e,a.setLoginState),verifyMFAWebAuthnForLogin:async e=>await i(e,a.setLoginState,!1)}})(0,t,n))},tg=["callback"],ng=["callback"],ag=["user"],og=["deviceId"],ig=["deviceId"],sg=["callback"],rg=["callback"],lg=["deviceId","callback"],cg=(e,t,n)=>{const a=n;async function o(t){const n=e.auth.mfaState.step;return{step:t.recoveryCode?Ac.recoveryCode:n,loading:!1,saving:!1,error:void 0,recoveryCode:null==t?void 0:t.recoveryCode}}const i=t=>{Object.assign(e.auth.mfaState,t)};return{setMfaState:i,resetMfaState:()=>{e.auth.mfaState=Xl(id)},getMFADevices:async()=>{i({loading:!0});try{const e=await t.auth.getMFADevices();i({loading:!1,error:void 0,mfaDevices:e})}catch(e){i({loading:!1,error:Gc(e)})}},getMFAStrategies:async()=>{i({loading:!0});try{const e=(await t.auth.getMFAStrategiesConfig()).strategies.filter((({isActive:e})=>e)).map((({strategy:e})=>e));i({loading:!1,error:void 0,mfaStrategies:e})}catch(e){i({loading:!1,error:Gc(e)})}},enrollMfa:async()=>{i({saving:!0});try{const{qrCode:e}=await t.auth.enrollMfa();i({saving:!1,error:void 0,qrCode:e})}catch(e){i({saving:!1,error:Gc(e)})}},verifyMfa:async n=>{const{callback:s}=n,r=oe(n,tg);i({saving:!0});try{const n=e.auth.user,l=await t.auth.verifyMfa(r),c=await t.auth.getMFADevices(),u=await o(l);i(j({},u,{mfaDevices:c})),a.setUser(j({},n,{mfaEnrolled:!0})),null==s||s(u.recoveryCode)}catch(e){i({saving:!1,error:Gc(e)}),null==s||s(null,e)}},verifyMfaAfterForce:async e=>{const{callback:n}=e,o=oe(e,ng);i({loading:!0});try{const e=await t.auth.loginWithMfaV2(o),{user:s}=e,r=oe(e,ag),l={step:Ac.recoveryCode,loading:!1,saving:!1,error:void 0};null!=s&&s.recoveryCode&&(l.recoveryCode=s.recoveryCode),i(l),await a.__afterAuthenticationStateUpdate(j({user:s},r)),null==n||n(l.recoveryCode)}catch(e){i({loading:!1,error:Gc(e)}),null==n||n(null,e)}},disableMfa:async e=>{i({saving:!0});try{var n;await t.auth.disableMfa(e);const a=await t.auth.getMFADevices();i({saving:!1,error:void 0,mfaDevices:a}),null==(n=e.callback)||n.call(e,!0)}catch(t){var a;i({saving:!1,error:Gc(t)}),null==(a=e.callback)||a.call(e,!1,t)}},preDisableMfaSms:async e=>{const{deviceId:n}=e,a=oe(e,og);i({saving:!0});try{var o;const e=await t.auth.preDisableMFASMS(n);i({saving:!1,error:void 0,otcToken:e.otcToken,phoneNumber:e.phoneNumber}),null==(o=a.callback)||o.call(a,!0)}catch(e){var s;i({saving:!1,error:Gc(e)}),null==(s=a.callback)||s.call(a,!1,e)}},disableMfaSms:async e=>{const{deviceId:n}=e,a=oe(e,ig);i({saving:!0});try{var o;await t.auth.disableMFASMS(n,a);const e=await t.auth.getMFADevices();i({saving:!1,error:void 0,mfaDevices:e}),null==(o=a.callback)||o.call(a,!0)}catch(e){var s;i({saving:!1,error:Gc(e)}),null==(s=a.callback)||s.call(a,!1,e)}},preEnrollMfaSms:async e=>{i({saving:!0});try{var n;const a=await t.auth.preEnrollMFASMS(e);i({saving:!1,error:void 0,otcToken:a.otcToken,phoneNumber:a.phoneNumber}),null==(n=e.callback)||n.call(e,!0)}catch(t){var a;i({saving:!1,error:Gc(t)}),null==(a=e.callback)||a.call(e,!1,t)}},enrollMfaSms:async e=>{const{callback:n}=e,a=oe(e,sg);i({saving:!0});try{const e=await t.auth.enrollMFASMS(a),s=await t.auth.getMFADevices(),r=await o(e);i(j({},r,{mfaDevices:s})),null==n||n(r.recoveryCode)}catch(e){i({saving:!1,error:Gc(e)}),null==n||n(null,e)}},preEnrollMfaWebAuthn:async e=>{i({saving:!0});try{var n,a;const o=await t.auth.preEnrollMFAWebAuthn(),s=j({},o.options,{challenge:fd(o.options.challenge),user:j({},o.options.user,{id:fd(o.options.user.id)}),excludeCredentials:null==(n=o.options.excludeCredentials)?void 0:n.map((e=>j({},e,{id:fd(e.id)})))});i({saving:!1}),null==(a=e.callback)||a.call(e,{options:s,webauthnToken:o.webauthnToken})}catch(t){var o;i({saving:!1,error:Gc(t)}),null==(o=e.callback)||o.call(e,null,t)}},enrollMfaWebAuthn:async e=>{const{callback:n}=e,a=oe(e,rg);i({saving:!0});try{const e=hd(a.publicKey),s=await t.auth.enrollMFAWebAuthn(j({},a,{options:e})),r=await t.auth.getMFADevices(),l=await o(s);i(j({},l,{mfaDevices:r})),null==n||n(l.recoveryCode)}catch(e){i({saving:!1,error:Gc(e)}),null==n||n(null,e)}},preDisableMfaWebAuthn:async e=>{const{deviceId:n,callback:a}=e;i({saving:!0});try{var o;const e=await t.auth.preDisableMFAWebAuthn(n),s=j({},e.options,{challenge:fd(e.options.challenge),allowCredentials:null==(o=e.options.allowCredentials)?void 0:o.map((e=>j({},e,{id:fd(e.id)})))});i({saving:!1}),null==a||a({options:s,webauthnToken:e.webauthnToken})}catch(e){i({saving:!1,error:Gc(e)}),null==a||a(null,e)}},disableMfaWebAuthn:async e=>{const{deviceId:n,callback:a}=e,o=oe(e,lg);i({saving:!0});try{const e=hd(o.publicKey);await t.auth.disableMFAWebAuthn(n,j({},o,{options:e}));const s=await t.auth.getMFADevices();i({saving:!1,error:void 0,mfaDevices:s}),null==a||a(!0)}catch(e){i({saving:!1,error:Gc(e)}),null==a||a(!1,e)}},__getMfaStateAfterEnroll:o}},ug={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:le.DESC,_sortBy:Gl.name},usersPageOffset:0,accountSettings:{}}},dg=e=>Mc(ug,e),gg=({items:e},t)=>e.map((e=>{var n,a;return{name:e.name,tenantId:e.tenantId,numberOfUsers:null!=(n=null==(a=t.find((t=>t.tenantId===e.tenantId)))?void 0:a.totalUsers)?n:0,createdAt:e.createdAt,metadata:e.metadata,isReseller:e.isReseller}}));function pg(e,t,n){var a,o;if(e.tenantId===t){var i;const t=[...null!=(i=null==e?void 0:e.children)?i:[],...n].filter(((e,t,n)=>t===n.findIndex((t=>t.tenantId===e.tenantId))));return j({},e,{children:t})}return j({},e,{children:null!=(a=null==e||null==(o=e.children)?void 0:o.map((e=>pg(e,t,n))))?a:[]})}function yg(e,t){var n;return j({},e,{children:null!=(n=e.children)&&n.length?e.children.filter((e=>e.tenantId!==t)).map((e=>yg(e,t))):[]})}const fg=(e,t,n)=>{var a,o;return e.tenantId===t?j({},e,{name:n}):j({},e,{children:null!=(a=null==e||null==(o=e.children)?void 0:o.map((e=>fg(e,t,n))))?a:[]})},Sg=(e,t,n)=>{var a,o;return e?e.tenantId===t?j({},e,{isReseller:n}):j({},e,{children:null!=(a=null==e||null==(o=e.children)?void 0:o.map((e=>Sg(e,t,n))))?a:[]}):{}},hg=(e,t,n)=>{const a=t=>{Object.assign(e.auth.allAccountsState,{loaders:j({},e.auth.allAccountsState.loaders,{[t.key]:t.value})})},o=t=>{Object.assign(e.auth.allAccountsState,{errors:j({},e.auth.allAccountsState.errors,{[t.key]:t.value}),loaders:j({},e.auth.allAccountsState.loaders,{[t.key]:!1})})},i=t=>{Object.assign(e.auth.allAccountsState,t)},s=t=>{Object.assign(e.auth.allAccountsState.selectedAccount,t)},r=()=>e.auth.allAccountsState,l=async e=>{var n,i,l,c,u,d,g,p;const{jwt:y,_tenantId:f,_email:S}=e,h=wc.GET_ACCOUNT_USERS;a({key:h,value:!0});const v=r(),m=null!=(n=null!=(i=null==e?void 0:e._offset)?i:null==v||null==(l=v.selectedAccount)||null==(c=l.usersQueryParams)?void 0:c._offset)?n:0,b=null!=(u=null!=(d=null==e?void 0:e._limit)?d:null==v||null==(g=v.selectedAccount)||null==(p=g.usersQueryParams)?void 0:p._limit)?u:10,A=j({_offset:m,_limit:b,_tenantId:f,_includeSubTenants:!1},!!S&&{_email:S});try{const{items:e,_metadata:{totalItems:n,totalPages:o}}=await t.users.getUsersV3(A,{jwt:y}),i={totalUsersItems:n,totalUsersPages:o,usersQueryParams:j({_offset:null!=m?m:0,_limit:null!=b?b:10},!!S&&{_email:S})};if(e.length){const n=e.map((e=>e.id)),a=await t.roles.getRoles(),o=await t.users.getUsersRoles({ids:n},{jwt:y}),r=e.map((e=>{var t,n;const i=null==o||null==(t=o.find((t=>t.userId===e.id)))?void 0:t.roleIds;return j({},e,{roles:null!=(n=null==i?void 0:i.map((e=>{var t;return null!=(t=null==a?void 0:a.find((t=>t.id===e)))?t:[]})))?n:[]})}));s(j({users:r},i))}else s(j({users:[]},i))}catch(e){o({key:h,value:Gc(e)})}finally{a({key:h,value:!1})}};return{setAllAccountsLoader:a,setAllAccountsError:o,setAllAccountsState:i,setSelectedAccountState:s,resetAllAccountsState:()=>{e.auth.allAccountsState=Xl(ug)},clearSelectedAccount:()=>{e.auth.allAccountsState.selectedAccount=Xl(ug.selectedAccount)},loadAccounts:async e=>{const n=wc.GET_ACCOUNTS;a({key:n,value:!0});const{accountsQueryParams:l}=r(),{jwt:c,_limit:u,_offset:d}=e,g={_offset:null!=d?d:l._offset,_limit:null!=u?u:l._limit,_subTenantId:null==e?void 0:e._subTenantId};try{if(c){var p;const{selectedAccount:n}=r(),{items:a,_links:o}=await t.tenants.searchSubTenants(g,{jwt:c}),i=await t.tenants.getTenantsUsersCount({tenantIds:a.map((e=>e.tenantId))},{jwt:c}),l=gg({items:a},i),u=pg(n.accounts?n.accounts:n,null!=(p=null==e?void 0:e._subTenantId)?p:"",l.map((e=>({name:e.name,tenantId:e.tenantId,numberOfUsers:e.numberOfUsers,createdAt:e.createdAt,metadata:e.metadata,children:[],loadMoreLink:null==o?void 0:o.next,isReseller:e.isReseller}))));s({accounts:u})}else{var y;const{accounts:n}=r(),{items:a,_links:o}=await t.tenants.searchSubTenants(g),s=await t.tenants.getTenantsUsersCount({tenantIds:a.map((e=>e.tenantId))}),l=gg({items:a},s),c=pg(n,null!=(y=null==e?void 0:e._subTenantId)?y:"",l.map((e=>({name:e.name,tenantId:e.tenantId,numberOfUsers:e.numberOfUsers,createdAt:e.createdAt,metadata:e.metadata,children:[],loadMoreLink:null==o?void 0:o.next,isReseller:e.isReseller}))));i({accounts:c})}}catch(e){o({key:n,value:Gc(e)})}finally{a({key:n,value:!1})}},searchAccounts:async e=>{const{jwt:n}=e,s=wc.SEARCH_ACCOUNTS;a({key:s,value:!0});const{rootAccount:l}=r();try{if(null!=e&&e._subTenantId){var c;const{items:a}=await t.tenants.searchSubTenants({_offset:0,_limit:50,_filter:null!=(c=null==e?void 0:e._filter)?c:"",_subTenantId:e._subTenantId},{jwt:n});i({searchAccountsData:[...a,{name:l.name,tenantId:l.tenantId}]})}}catch(e){o({key:s,value:Gc(e)})}finally{a({key:s,value:!1})}},updateSubAccountAccessForUser:async e=>{const n=wc.UPDATE_SUB_ACCOUNT_ACCESS_FOR_USER;a({key:n,value:!0});const{selectedAccount:i}=r(),{userId:l,allowAccess:c,jwt:u,callback:d}=e;try{var g;await t.subTenants.updateSubAccountAccess(l,{allowAccess:c},{jwt:u}),s({users:null==i||null==(g=i.users)?void 0:g.map((e=>e.id===l?j({},e,{subAccountAccessAllowed:c}):e))}),null==d||d(!0)}catch(e){o({key:n,value:Gc(e)}),null==d||d(!1)}finally{a({key:n,value:!1})}},createSubAccount:async e=>{const n=wc.CREATE_SUB_ACCOUNT;a({key:n,value:!0});const{name:l,parentTenantId:c,tenantId:u,jwt:d,callback:g}=e;try{if(d){const{accounts:e,selectedAccount:n}=r(),a=await t.subTenants.createSubTenant({name:l,parentTenantId:c,tenantId:u},{jwt:d}),o=pg(e,null!=c?c:"",[{name:a.name,tenantId:a.tenantId,numberOfUsers:0,createdAt:new Date}]),g=pg(j({name:"",tenantId:""},null==n?void 0:n.accounts),null!=c?c:"",[{name:a.name,tenantId:a.tenantId,numberOfUsers:0,createdAt:new Date}]);i({accounts:o}),s({accounts:g})}else{const{accounts:e}=r(),n=await t.subTenants.createSubTenant({name:l,tenantId:u,parentTenantId:c}),a=pg(e,null!=c?c:"",[{name:n.name,tenantId:n.tenantId,numberOfUsers:0,createdAt:new Date}]);i({accounts:a})}null==g||g(!0)}catch(e){o({key:n,value:Gc(e)}),null==g||g(!1)}finally{a({key:n,value:!1})}},updateSubAccount:async e=>{},deleteSubAccount:async e=>{const n=wc.DELETE_SUB_ACCOUNT;a({key:n,value:!0});const{jwt:l,tenantId:c,callback:u}=e;try{if(l){const{selectedAccount:e,accounts:n}=r();await t.subTenants.deleteSubTenant(c,{jwt:l});const a=yg(n,c),o=yg(e.accounts,c);i({accounts:a}),s({accounts:o})}else{const{accounts:e}=r();await t.subTenants.deleteSubTenant(c);const n=yg(e,c);i({accounts:n})}null==u||u(!0)}catch(e){o({key:n,value:Gc(e)}),null==u||u(!1)}finally{a({key:n,value:!1})}},updateSubAccountSettings:async e=>{const n=wc.UPDATE_SUB_ACCOUNT_SETTINGS;a({key:n,value:!0});const{jwt:l,name:c,callback:u,tenantId:d}=e;try{if(l){const{selectedAccount:e,accounts:n}=r();await t.subTenants.updateSubTenant({tenantId:d},{name:c},{jwt:l});const a=fg(e.accounts,d,c);s({name:c,accounts:a});const o=fg(n,d,c);i({accounts:o})}else{const{accounts:e}=r();await t.subTenants.updateSubTenant({tenantId:d},{name:c});const n=fg(e,d,c);i({accounts:n})}null==u||u(!0)}catch(e){o({key:n,value:Gc(e)}),null==u||u(!1)}finally{a({key:n,value:!1})}},updateSubAccountManagement:async r=>{const l=wc.UPDATE_SUB_ACCOUNT_MANAGEMENT;n.setAllAccountsLoader({key:l,value:!0});const{jwt:c,isReseller:u,callback:d,tenantId:g,shouldUpdateSelectedAccount:p}=r,y=!!c;try{if(p){const{selectedAccount:n,accounts:a}=e.auth.allAccountsState;await t.subTenants.updateSubTenantManagement({tenantId:g},{isReseller:u},c?{jwt:c}:void 0);const o=Sg(n.accounts,g,null!=u&&u);s({accounts:o}),y||s({isReseller:u});const r=Sg(a,g,null!=u&&u);i({accounts:r})}else{const{accounts:n}=e.auth.allAccountsState;t.subTenants.updateSubTenantManagement({tenantId:g},{isReseller:u},c?{jwt:c}:void 0);const a=Sg(n,g,null!=u&&u);i({accounts:a})}null==d||d(!0)}catch(e){o({key:l,value:Gc(e)}),null==d||d(!1)}finally{a({key:l,value:!1})}},addUsersToAccount:async e=>{const{users:n,tenantId:i,jwt:s,callback:r,allowSubAccountAccess:c=!1,roleIds:u}=e,d=wc.ADD_USERS_TO_ACCOUNT;try{a({key:d,value:!0}),await t.subTenants.addUsersToSubTenant({users:n,tenantId:i,allowSubAccountAccess:c,roleIds:u},{jwt:s}),await l({jwt:s,_tenantId:i}),null==r||r(!0)}catch(e){o({key:d,value:Gc(e)}),null==r||r(!1)}finally{a({key:d,value:!1})}},getAccountUsers:l,deleteUsersFromAccount:async e=>{const n=wc.DELETE_USERS_FROM_ACCOUNT;a({key:n,value:!0});const{userId:i,subTenants:s,jwt:r,callback:c}=e;try{await t.subTenants.removeUserFromTenantAndSubTenants({userId:i,subTenants:s},{jwt:r}),await l({jwt:r,_tenantId:s[0].tenantId}),null==c||c(!0)}catch(e){o({key:n,value:Gc(e)}),null==c||c(!1)}finally{a({key:n,value:!1})}},setUserRolesForSubAccount:async e=>{const{userId:n,subTenantsRoles:i,jwt:s,callback:c}=e,u=wc.SET_USER_ROLES_FOR_SUB_ACCOUNT;try{a({key:u,value:!0});const{selectedAccount:e}=r();await t.subTenants.setUserRolesForSubTenants(n,{subTenantsRoles:i},{jwt:s}),await l({jwt:s,_tenantId:e.tenantId}),null==c||c(!0)}catch(e){o({key:u,value:Gc(e)}),null==c||c(!1)}finally{a({key:u,value:!1})}},getUserJwtForSubAccount:async e=>{const{tenantId:n,callback:i}=e,r=wc.GET_USER_JWT;try{a({key:r,value:!0});const e=await t.users.GetUserJwt({tenantId:n});s({userJwt:e,accessPermission:!0}),null==i||i(!0)}catch(e){o({key:r,value:Gc(e)}),s({accessPermission:!1}),null==i||i(!1)}finally{a({key:r,value:!1})}},setRootAccountData:async()=>{const n=wc.SET_ROOT_ACCOUNT_DATA;a({key:n,value:!0});const{activeTenant:s}=e.auth.tenantsState,{accounts:l}=r();if(s)try{var c;const e=await t.tenants.getTenantsUsersCount({tenantIds:[null==s?void 0:s.tenantId]}),o={name:null==s?void 0:s.name,tenantId:null==s?void 0:s.tenantId,numberOfUsers:null==(c=e[0])?void 0:c.totalUsers,createdAt:null==s?void 0:s.createdAt};i({rootAccount:o,accounts:j({},l,o)})}catch(e){o({key:n,value:Gc(e)})}finally{a({key:n,value:!1})}},setSelectedSubAccountData:async e=>{const{jwt:n}=e,i=wc.SET_SELECTED_SUB_ACCOUNT_DATA;try{var r,c,u,d,g,p,y;a({key:i,value:!0});const e=await t.accountSettings.getSettings({jwt:n}),[o,f,S]=await Promise.all([t.tenants.getTenantsUsersCount({tenantIds:[null!=(r=null==e?void 0:e.tenantId)?r:""]},{jwt:n}),t.tenants.getParentTenants({jwt:n}),t.tenants.getHierarchyMetadata({_tenantIds:[null!=(c=null==e?void 0:e.tenantId)?c:""]},{jwt:n})]);s({tenantId:null!=(u=e.tenantId)?u:"",name:e.name,numberOfUsersObject:o[0],parentsAccounts:f,numberOfSubAccounts:null==(d=S[0])?void 0:d.totalSubTenants,accountSettings:e,accounts:{name:e.name,tenantId:null!=(g=e.tenantId)?g:"",numberOfUsers:null==(p=o[0])?void 0:p.totalUsers,createdAt:void 0,children:[]}}),await l({jwt:n,_tenantId:null!=(y=null==e?void 0:e.tenantId)?y:""})}catch(e){o({key:i,value:Gc(e)})}finally{a({key:i,value:!1})}},loadNumberOfUsersForSelectedSubAccount:async e=>{const{tenantId:n,jwt:i}=e,r=wc.LOAD_NUMBER_OF_USERS_FOR_ACCOUNT;try{a({key:r,value:!0});const e=await t.tenants.getTenantsUsersCount({tenantIds:[n]},{jwt:i});s({numberOfUsersObject:e[0]})}catch(e){o({key:r,value:Gc(e)})}finally{a({key:r,value:!1})}}}},vg={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},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:[]}},mg=e=>Mc(vg,e),bg=(e,t,n)=>{const a=Xl(vg);return{setAllAccountDialogsState:t=>{Object.assign(e.auth.allAccountsDialogsState,t)},resetAllAccountDialogsState:()=>{e.auth.allAccountsDialogsState=Xl(vg)},openCreateSubAccountDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.createSubAccountDialog,j({},t,{open:!0}))},closeCreateSubAccountDialog:()=>{e.auth.allAccountsDialogsState.createSubAccountDialog=a.createSubAccountDialog},openUpdateSubAccountDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.updateSubAccountDialog,j({},t,{open:!0}))},closeUpdateSubAccountDialog:()=>{e.auth.allAccountsDialogsState.updateSubAccountDialog=a.updateSubAccountDialog},openEnableSubAccountManagementDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.enableSubAccountManagementDialog,j({},t,{open:!0}))},closeEnableSubAccountManagementDialog:()=>{e.auth.allAccountsDialogsState.enableSubAccountManagementDialog=a.enableSubAccountManagementDialog},openDisableSubAccountManagementDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.disableSubAccountManagementDialog,j({},t,{open:!0}))},closeDisableSubAccountManagementDialog:()=>{e.auth.allAccountsDialogsState.disableSubAccountManagementDialog=a.disableSubAccountManagementDialog},openDeleteSubAccountDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.deleteSubAccountDialog,j({},t,{open:!0}))},closeDeleteSubAccountDialog:()=>{e.auth.allAccountsDialogsState.deleteSubAccountDialog=a.deleteSubAccountDialog},openAddUsersToAccountDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.addUsersToAccountDialog,j({},t,{open:!0}))},closeAddUsersToAccountDialog:()=>{e.auth.allAccountsDialogsState.addUsersToAccountDialog=a.addUsersToAccountDialog},openDeleteUserFromAccountDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.deleteUserFromAccountDialog,j({},t,{open:!0}))},closeDeleteUserFromAccountDialog:()=>{e.auth.allAccountsDialogsState.deleteUserFromAccountDialog=a.deleteUserFromAccountDialog},openEditUserRolesDialog:t=>{Object.assign(e.auth.allAccountsDialogsState.editUserRolesDialog,j({},t,{open:!0}))},closeEditUserRolesDialog:()=>{e.auth.allAccountsDialogsState.editUserRolesDialog=a.editUserRolesDialog}}},Ag={devices:[],loading:!1,error:null},wg=e=>Mc(Ag,e),Tg=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auth.passkeysState,t)};return{setPasskeysState:o,resetPasskeysState:()=>{e.auth.passkeysState=Xl(Ag)},loadWebAuthnDevices:async()=>{o({loading:!0});try{const{devices:e}=await t.auth.getWebAuthnDevices();o({devices:e,loading:!1})}catch(e){o({loading:!1,error:Gc(e,null)})}},deleteWebAuthnDevice:async n=>{const{callback:a,deviceId:i}=n;o({loading:!0});try{await t.auth.deleteWebAuthnDevice(i);const n=e.auth.passkeysState.devices.filter((e=>e.id!==i));o({devices:n,loading:!1}),null==a||a(!0)}catch(e){o({loading:!1,error:Gc(e,null)}),null==a||a(null,e)}},__shouldShowPromptPasskeys:async function(){const{publicAuthStrategyPolicy:n}=e.auth.securityPolicyState,{policy:i}=n,s=await async function(e){var t;return!(null==e||null==(t=e.secondaryAuthStrategies)||!t.some((({isActive:e,strategy:t})=>e&&t===yn.Passkeys)))}(i),r="Passkeys"===localStorage.getItem("preferred-login-method"),l="true"===localStorage.getItem("dont-show-again-prompt-passkeys"),[c]=await a.__getFeatureFlags(["show-passkeys-new"]);if(!c||!s||r||l)return!1;{const{devices:e}=await t.auth.getWebAuthnDevices();return o({devices:null!=e?e:[]}),0===(null!=e&&e.length?e.length:0)}}}},Eg={loading:!1,error:null},Ig=e=>Mc(Eg,e),kg=["callback","profilePictureUrl"],Og=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auth.profileState,t)};return{setProfileState:o,resetProfileState:()=>{e.auth.profileState=Xl(Eg)},loadProfile:async()=>{o({loading:!0});try{const n=await Zl(t.teams.getProfile,3,2e3),i=e.auth.user;a.setUser(j({},i,n)),o({profile:n,loading:!1})}catch(e){o({loading:!1,error:Gc(e)})}},saveProfile:async n=>{const{callback:i,profilePictureUrl:s}=n,r=oe(n,kg);o({saving:!0,error:null,loading:!0});try{var l;const n=null!=(l=e.auth.profileState.profile)?l:{};let o=n.profilePictureUrl;if(s!==n.profilePictureUrl&&s&&(s||"").match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/)){const e=Sd(s,"image");if(e){o=await t.teams.updateProfileImage(e);const n=Date.now().toString(),a=new URL(o);a.searchParams.set("t",n),o=a.href}}const c=j({},n,r,{profilePictureUrl:o}),u=await t.users.updateUserProfileV2(c),d=e.auth.user;a.setUser(j({},d,u)),a.setProfileState({profile:u,saving:!1,loading:!1}),null==i||i(c)}catch(e){o({saving:!1,error:Gc(e),loading:!1}),null==i||i(null,e)}},changePassword:async e=>{o({loading:!0});try{var n;await t.teams.changePassword(e),o({loading:!1,error:void 0}),null==(n=e.callback)||n.call(e,!0)}catch(t){var a;o({loading:!1,error:Gc(t)}),null==(a=e.callback)||a.call(e,null,t)}}}},_g={loading:!1},Pg=e=>Mc(_g,e),Ug=["callback"],Lg=["id"],Dg=(e,t,n)=>{const a=t=>{Object.assign(e.auth.provisioningState,t)},o=async e=>{const{count:n}=await t.directory.countConfigurationUsers(e.id);return j({},e,{count:n})};return{setProvisioningState:a,resetProvisioningState:()=>{e.auth.provisioningState=Xl(_g)},__loadCountForConnection:o,loadProvisionConnections:async()=>{a({loading:!0,error:null});try{const e=await t.directory.getConfigs(),n=await Promise.all(e.map((e=>o(e))));a({connections:n,loading:!1})}catch(e){a({error:Gc(e),loading:!1})}},createProvisionConnection:async e=>{const{callback:n}=e,i=oe(e,Ug);a({loading:!0,error:null});try{const e=await t.directory.createConfiguration(i),s=await t.directory.getConfigs(),r=await Promise.all(s.map((e=>o(e))));a({connections:r,loading:!1}),null==n||n(e)}catch(e){a({error:Gc(e),loading:!1})}},deleteProvisionConnection:async e=>{const{id:n,callback:i}=e;a({loading:!0,error:null});try{await t.directory.deleteConfiguration(n);const e=await t.directory.getConfigs(),s=await Promise.all(e.map((e=>o(e))));a({connections:s,loading:!1}),null==i||i(!0)}catch(e){a({error:Gc(e),loading:!1}),null==i||i(!1,e)}},updateProvisionConnection:async e=>{const{id:n}=e,i=oe(e,Lg);a({loading:!0,error:null});try{await t.directory.updateConfiguration(n,i);const e=await t.directory.getConfigs(),s=await Promise.all(e.map((e=>o(e))));a({connections:s,loading:!1})}catch(e){a({error:Gc(e),loading:!1})}}}},Rg={step:Tc.ResetPhoneNumber,loading:!1},Cg=e=>Mc(Rg,e),Ng=["callback"],Mg=["callback"],Fg=["callback"],$g=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auth.resetPhoneNumberState,t)};return{setResetPhoneNumberState:o,resetResetPhoneNumberState:()=>{e.auth.resetPhoneNumberState=Xl(Rg)},resetPhoneNumber:async e=>{const{callback:n}=e,i=oe(e,Ng);o({loading:!0});try{const e=await t.auth.resetPhoneNumber(i);o({loading:!1,error:void 0,resetPhoneNumberToken:e.resetPhoneNumberToken,step:Tc.VerifyResetPhoneNumber}),a.setLoginState({email:i.email})}catch(e){o({loading:!1,error:Gc(e)}),null==n||n(null,e)}},verifyResetPhoneNumber:async e=>{const{callback:n}=e,a=oe(e,Mg);o({loading:!0});try{const e=await t.auth.verifyResetPhoneNumber(a);o({loading:!1,error:void 0,changePhoneNumberToken:e.changePhoneNumberToken,step:Tc.ChangePhoneNumber}),null==n||n(!0)}catch(e){o({loading:!1,error:Gc(e)}),null==n||n(null,e)}},changePhoneNumber:async n=>{const{callback:i}=n,s=oe(n,Fg);o({loading:!0});try{const{onRedirectTo:n,routes:r}=e.auth;await t.auth.changePhoneNumber({phoneNumber:s.phoneNumber,changePhoneNumberToken:s.changePhoneNumberToken}),a.setLoginState({step:hc.loginWithSmsOtc}),await a.passwordlessPreLogin({type:rn.SmsCode,email:s.email,recaptchaToken:s.recaptchaToken}),n(r.loginUrl),o({loading:!1}),null==i||i(!0)}catch(e){o({loading:!1,error:Gc(e)}),null==i||i(null,e)}}}},jg={loaders:{},errors:{},roles:[],permissions:[],permissionCategories:[]},Gg=e=>Mc(jg,e),xg=["callback"],Vg=["callback"],Bg=["callback"],Wg=["callback"],zg=["callback"],Kg=["callback"],Hg=(e,t,n)=>{const a=t=>{Object.assign(e.auth.rolesState,t)},o=t=>{Object.assign(e.auth.rolesState,{loaders:j({},e.auth.rolesState.loaders,{[t.key]:t.value})})},i=t=>{Object.assign(e.auth.rolesState,{errors:j({},e.auth.rolesState.errors,{[t.key]:t.value}),loaders:j({},e.auth.rolesState.loaders,{[t.key]:!1})})},s=async n=>{var s;const r=Ec.LOAD_ROLES;o({key:r,value:!(null!=(s=null==n?void 0:n.silentLoading)&&s)});try{const[n,i,s]=await Promise.all([t.roles.getRoles(),t.roles.getPermissions(),t.roles.getPermissionCategories()]),{selectedRole:l}=e.auth.rolesState,c=null==n?void 0:n.find((({id:e})=>(null==l?void 0:l.id)===e));a({roles:n,permissions:i,permissionCategories:s,selectedRole:c})}catch(e){i({key:r,value:Gc(e)})}finally{o({key:r,value:!1})}},r=async e=>{const{callback:n}=e,r=oe(e,zg),l=Ec.MANAGE_PERMISSIONS;o({key:l,value:!0});try{const e=await t.roles.attachPermissionsToRole(r);await s({silentLoading:!0}),a({saving:!1}),null==n||n(e)}catch(e){i({key:l,value:Gc(e)}),null==n||n(null,e)}finally{o({key:l,value:!1})}};return{setRolesState:a,setRolesStateLoader:o,setRolesStateError:i,resetRolesState:()=>{e.auth.rolesState=Xl(jg)},loadRolesAndPermissions:s,addRole:async e=>{const{callback:n}=e,a=oe(e,xg),r=Ec.ADD_ROLE;o({key:r,value:!0});try{const e=await t.roles.addRole(a);await s({silentLoading:!0}),null==n||n(e)}catch(e){i({key:r,value:Gc(e)}),null==n||n(null,e)}finally{o({key:r,value:!1})}},addRoleV2:async e=>{const{callback:n}=e,a=oe(e,Vg),r=Ec.ADD_ROLE;o({key:r,value:!0});try{const e=await t.roles.addRoleV2(a);await s({silentLoading:!0}),null==n||n(e)}catch(e){i({key:r,value:Gc(e)}),null==n||n(null,e)}finally{o({key:r,value:!1})}},updateRole:async e=>{const{callback:n}=e,r=oe(e,Bg),l=Ec.EDIT_ROLE_DIALOG;o({key:l,value:!0});try{const e=await t.roles.updateRole(r);await s({silentLoading:!0}),a({saving:!1}),null==n||n(e)}catch(e){i({key:l,value:Gc(e)}),null==n||n(null,e)}finally{o({key:l,value:!1})}},deleteRole:async e=>{const{callback:n}=e,r=oe(e,Wg),l=Ec.DELETE_ROLE_DIALOG;o({key:l,value:!0});try{await t.roles.deleteRole(r),await s({silentLoading:!0}),a({saving:!1}),null==n||n(!0)}catch(e){i({key:l,value:Gc(e)}),null==n||n(!1,e)}finally{o({key:l,value:!1})}},attachPermissionsToRole:r,attachPermissionToRoles:async e=>{const{callback:t}=e,n=oe(e,Kg),a=Ec.MANAGE_PERMISSIONS;o({key:a,value:!0});try{await Promise.all(n.roleIds.map((e=>r({roleId:e,permissionIds:[n.permissionId]})))),await s({silentLoading:!0}),null==t||t(!0)}catch(e){i({key:a,value:Gc(e)}),null==t||t(null,e)}finally{o({key:a,value:!1})}}}},qg={ipRestrictions:{loading:!1,pagination:{_offset:0,_limit:4,_filter:pn.ALLOW},totalPages:1,userIpValid:!1},emailDomainRestrictions:{loading:!0}},Jg=e=>Mc(qg,e),Yg=["callback"],Xg=["callback"],Qg=["callback"],Zg=["callback"],ep=(e,t,n)=>{const a=n,o=e=>{var t,n,a;return{_filter:null!=(t=null==e?void 0:e._filter)?t:pn.ALLOW,_limit:null!=(n=null==e?void 0:e._limit)?n:10,_offset:null!=(a=null==e?void 0:e._offset)?a:0}},i=e=>async(...t)=>{const[n]=await a.__getFeatureFlags(["security-center-admin-portal-major-version"]);await e(...t),n&&(await a.loadRecommendations(),await a.loadInsights())},s=t=>{Object.assign(e.auth.restrictionsState.ipRestrictions,t)},r=t=>{Object.assign(e.auth.restrictionsState.emailDomainRestrictions,t)},l=async()=>{try{const{valid:e}=await t.auth.testCurrentIpInAllowList();s({userIpValid:e})}catch(e){s({error:Gc(e)})}},c=i((async()=>{s({loading:!0,error:null});try{const n=e.auth.restrictionsState.ipRestrictions,a=await t.auth.getIPRestrictionsConfig(),i=o({_filter:a.strategy,_limit:n.pagination._limit,_offset:n.pagination._offset}),{items:r,_metadata:{totalPages:l}}=await t.auth.getIPRestrictions(i);s({data:{restrictions:r,config:a},totalPages:l,pagination:i,loading:!1})}catch(e){s({error:Gc(e),loading:!1})}})),u=i((async n=>{const{callback:a}=n,i=oe(n,Yg);s({saving:!0,error:null});try{var r,c;await t.auth.createIPRestriction(i);const n=e.auth.restrictionsState.ipRestrictions,u=o(n.pagination),{items:d,_metadata:{totalPages:g}}=await t.auth.getIPRestrictions(u),p=d;await l(),s({data:{config:null!=(r=null==(c=n.data)?void 0:c.config)?r:{isActive:!1,strategy:pn.ALLOW},restrictions:p},pagination:u,totalPages:g,saving:!1}),null==a||a(!0)}catch(e){s({saving:!1,error:Gc(e)}),null==a||a(null,e)}})),d=i((async n=>{const{callback:a}=n,i=oe(n,Xg);s({saving:!0,error:null});try{await t.auth.updateIPRestrictionConfig(i);const n=e.auth.restrictionsState.ipRestrictions,r=await t.auth.getIPRestrictionsConfig(),c=o(j({},n.pagination,{_filter:r.strategy})),{items:u,_metadata:{totalPages:d}}=await t.auth.getIPRestrictions(c),g=u;await l(),s({data:{config:r,restrictions:g},pagination:c,totalPages:d,saving:!1}),null==a||a(!0)}catch(e){s({saving:!1,error:Gc(e)}),null==a||a(null,e)}})),g=i((async n=>{const{id:a,callback:i}=n;s({saving:!0,error:null});try{var r;await t.auth.deleteIPRestriction(a);const n=e.auth.restrictionsState.ipRestrictions,c=o(n.pagination),{items:u,_metadata:{totalPages:d}}=await t.auth.getIPRestrictions(c),g=u;await l(),s({data:{config:(null==(r=n.data)?void 0:r.config)||{isActive:!1,strategy:pn.ALLOW},restrictions:g},pagination:c,totalPages:d,saving:!1}),null==i||i(!0)}catch(e){s({saving:!1,error:Gc(e)}),null==i||i(null,e)}})),p=i(l),y=i((async n=>{const{callback:a}=n;s({saving:!0,error:null});try{var i;const n=null!=(i=e.auth.userIp)?i:"";await Promise.all([t.auth.createIPRestriction({ip:n,isActive:!0,description:"My IP",strategy:pn.ALLOW}),t.auth.updateIPRestrictionConfig({isActive:!0})]);const r=e.auth.restrictionsState.ipRestrictions,l=o(r.pagination),{items:c,_metadata:{totalPages:u}}=await t.auth.getIPRestrictions(l),d=c;s({data:{config:{isActive:!0,strategy:pn.ALLOW},restrictions:d},userIpValid:!0,pagination:l,totalPages:u,saving:!1}),null==a||a(!0)}catch(e){s({saving:!1,error:e}),null==a||a(!1,e)}})),f=i((async()=>{r({loading:!0,error:null});try{const e=await t.auth.getDomainRestrictionsConfig(),n=(await t.auth.getDomainRestrictions()).items.filter((t=>t.type===e.listType));r({data:{restrictions:n,config:e},loading:!1})}catch(e){r({error:Gc(e),loading:!1})}})),S=i((async n=>{const{callback:a}=n,o=oe(n,Qg);r({saving:!0,error:null});const i=e.auth.restrictionsState.emailDomainRestrictions;try{var s;await t.auth.createDomainRestriction(o);const e=(await t.auth.getDomainRestrictions()).items.filter((e=>{var t;return e.type===(null==(t=i.data)?void 0:t.config.listType)}));r({data:{config:(null==(s=i.data)?void 0:s.config)||{active:!1,blockPublicDomains:!1,listType:o.type},restrictions:e},saving:!1}),null==a||a(!0)}catch(e){r({saving:!1,error:Gc(e)}),null==a||a(null,e)}})),h=i((async e=>{const{callback:n}=e,a=oe(e,Zg);r({saving:!0,error:null});try{const e=await t.auth.updateDomainRestrictionConfig(a),o=(await t.auth.getDomainRestrictions()).items.filter((t=>t.type===e.listType));r({data:{config:e,restrictions:o},saving:!1}),null==n||n(!0)}catch(e){r({saving:!1,error:Gc(e)}),null==n||n(null,e)}})),v=i((async n=>{const{id:a}=n;r({saving:!0,error:null});const o=e.auth.restrictionsState.emailDomainRestrictions;try{var i;await t.auth.deleteDomainRestriction(a);const e=(await t.auth.getDomainRestrictions()).items.filter((e=>{var t;return e.type===(null==(t=o.data)?void 0:t.config.listType)}));r({data:{config:(null==(i=o.data)?void 0:i.config)||{active:!1,blockPublicDomains:!1,listType:pn.ALLOW},restrictions:e},saving:!1})}catch(e){r({saving:!1,error:Gc(e)})}}));return{setRestrictionsState:t=>{Object.assign(e.auth.restrictionsState,t)},setIpRestrictionsState:s,setEmailDomainRestrictionsState:r,__securityCenterSagaWrapper:i,loadIpRestrictions:c,saveIpRestriction:u,saveIpRestrictionsConfig:d,deleteIpRestriction:g,checkIfUserIpValid:p,addCurrentUserIpAndActivate:y,loadEmailDomainRestrictions:f,saveEmailDomainRestriction:S,saveEmailDomainRestrictionsConfig:h,deleteEmailDomainRestriction:v}},tp={loaders:{},errors:{},recommendations:void 0,insights:void 0,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}}},np=e=>Mc(tp,e),ap=["callback"],op=(e,t,n)=>{const a=n,o=async e=>{var n,o,l,c;const{key:u,tableState:d,updateStateKey:g,_offset:p,_limit:y,_preset:f,_email:S,_maxInactiveSeconds:h}=e;r({key:u,value:!1}),s({key:u,value:!0});const v=null!=(n=null!=p?p:null==d||null==(o=d.queryParams)?void 0:o._offset)?n:0,m=null!=(l=null!=y?y:null==d||null==(c=d.queryParams)?void 0:c._limit)?l:10,b=j({_offset:v,_limit:m,_includeSubTenants:!1,_preset:f,_maxInactiveSeconds:h},!!S&&{_email:S});try{const{items:e,_metadata:{totalItems:n,totalPages:o}}=await t.users.getUsersV3(b),r={totalUsersItems:n,totalUsersPages:o,usersPageOffset:v,queryParams:j({_offset:v,_limit:m,_maxInactiveSeconds:h},!!S&&{_email:S})};if(e.length){const n=await(async e=>{const n=e.map((e=>e.id)),a=await t.roles.getRoles(),o=await t.users.getUsersRoles({ids:n});return e.map((e=>{var t,n;const i=null==o||null==(t=o.find((t=>t.userId===e.id)))?void 0:t.roleIds;return j({},e,{roles:null!=(n=null==i?void 0:i.map((e=>{var t;return null!=(t=null==a?void 0:a.find((t=>t.id===e)))?t:[]})))?n:[]})}))})(e);a.setSecurityCenterState({[g]:j({users:n},r)})}else i({[g]:j({users:[]},r)})}catch(e){r({key:u,value:Gc(e)})}finally{s({key:u,value:!1})}},i=t=>{Object.assign(e.auth.securityCenterState,t)},s=t=>{Object.assign(e.auth.securityCenterState,{loaders:j({},e.auth.securityCenterState.loaders,{[t.key]:t.value})})},r=t=>{Object.assign(e.auth.securityCenterState,{errors:j({},e.auth.securityCenterState.errors,{[t.key]:t.value}),loaders:j({},e.auth.securityCenterState.loaders,{[t.key]:!1})})};return{setSecurityCenterState:i,resetSecurityCenterState:()=>{e.auth.securityCenterState=Xl(tp)},setSecurityCenterStateLoader:s,setSecurityCenterStateError:r,loadRecommendations:async()=>{const e=Ic.RECOMMENDATIONS;s({key:e,value:!0});try{var n;const{recommendations:a,scoring:o}=await t.securityCenter.getRecommendations();i({recommendations:a.items,score:null!=(n=null==o?void 0:o.score)?n:0})}catch(t){r({key:e,value:Gc(t)})}finally{s({key:e,value:!1})}},loadInsights:async()=>{const e=Ic.INSIGHTS;s({key:e,value:!0});try{const{insights:n}=await t.securityCenter.getInsights();i({insights:n.items})}catch(t){r({key:e,value:Gc(t)})}finally{s({key:e,value:!1})}},sendResetBreachedPasswordEmail:async e=>{const{callback:n}=e,a=oe(e,ap),o=Ic.SEND_BREACHED_PASSWORD_EMAIL;r({key:o,value:!1}),s({key:o,value:!0});try{await t.auth.forgotPassword(a),null==n||n(!0)}catch(e){r({key:o,value:Gc(e)}),null==n||n(!1,e)}finally{s({key:o,value:!1})}},sendBulkResetBreachedPasswordEmails:async e=>{const{callback:n}=e,a=Ic.SEND_BULK_RESET_BREACHED_PASSWORD_EMAILS;r({key:a,value:!1}),s({key:a,value:!0});try{await t.users.sendResetBreachedPasswordEmails(),null==n||n(!0)}catch(e){r({key:a,value:Gc(e)}),null==n||n(!1)}finally{s({key:a,value:!1})}},loadBreachedPasswordUsers:async t=>{var n;const a=Ic.BREACHED_PASSWORD_USERS_TABLE,i=null==(n=e.auth.securityCenterState)?void 0:n.breachedPasswordUsersTable;await o(j({key:a,updateStateKey:"breachedPasswordUsersTable",_preset:xl.BREACHED_PASSWORDS,tableState:i},t))},loadUnenrolledMfaUsers:async t=>{var n;const a=Ic.UNENROLLED_MFA_USERS_TABLE,i=null==(n=e.auth.securityCenterState)?void 0:n.unenrolledMfaUsersTable;await o(j({key:a,updateStateKey:"unenrolledMfaUsersTable",_preset:xl.MFA_UNENROLLED,tableState:i},t))},loadInactiveUsers:async t=>{var n;const a=Ic.INACTIVE_USERS_TABLE,i=null==(n=e.auth.securityCenterState)?void 0:n.inactiveUsersTable;await o(j({key:a,updateStateKey:"inactiveUsersTable",_preset:xl.INACTIVE,tableState:i},t))}}},ip={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}},sp=e=>Mc(ip,e),rp=["callback"],lp=["callback"],cp=["callback"],up=(e,t,n)=>{const a=n,o=async e=>{var t,n;if(!await a.customLoginEnabled())return e;const o=await i();return null!=o&&null!=(t=o.mainAuthStrategies)&&null!=(n=t[0])&&n.strategy?j({},e,{authStrategy:o.mainAuthStrategies[0].strategy}):e},i=async()=>{let n;return n=e.auth.isAuthenticated?await t.auth.getPublicAuthStrategiesConfigForAuthenticatedUser():await t.auth.getVendorPublicAuthStrategiesConfig(),n},s=t=>{Object.assign(e.auth.securityPolicyState.globalPolicy,t)},r=t=>{Object.assign(e.auth.securityPolicyState.publicPolicy,t)},l=t=>{Object.assign(e.auth.securityPolicyState.mfaPolicy,t)},c=t=>{Object.assign(e.auth.securityPolicyState.vendorMfaPolicy,t)},u=t=>{Object.assign(e.auth.securityPolicyState.lockoutPolicy,t)},d=t=>{Object.assign(e.auth.securityPolicyState.vendorLockoutPolicy,t)},g=t=>{Object.assign(e.auth.securityPolicyState.captchaPolicy,t)},p=t=>{Object.assign(e.auth.securityPolicyState.passwordHistoryPolicy,t)},y=t=>{Object.assign(e.auth.securityPolicyState.vendorPasswordHistoryPolicy,t)},f=t=>{Object.assign(e.auth.securityPolicyState.passwordPolicy,t)},S=t=>{Object.assign(e.auth.securityPolicyState.publicAuthStrategyPolicy,t)},h=async()=>{s({loading:!0,error:null});try{const e=await t.auth.getGlobalSecurityPolicy();s({policy:e,loading:!1})}catch(e){s({error:Gc(e),loading:!1})}},v=async()=>{l({loading:!0,error:null});try{const e=await t.auth.getMfaPolicy();l({policy:e,loading:!1})}catch(e){l({error:Gc(e),loading:!1})}},m=async()=>{l({loading:!0,error:null});try{const e=await t.auth.getVendorMfaPolicy();c({policy:e,loading:!1})}catch(e){c({error:Gc(e),loading:!1})}},b=async()=>{u({loading:!0,error:null});try{const e=await t.auth.getLockoutPolicy();u({policy:e,loading:!1})}catch(e){u({error:Gc(e),loading:!1})}},A=async()=>{d({loading:!0,error:null});try{const e=await t.auth.getVendorLockoutPolicy();d({policy:e,loading:!1})}catch(e){d({error:Gc(e),loading:!1})}},w=async()=>{u({loading:!0,error:null});try{const e=await t.auth.getCaptchaPolicy();g({policy:e,loading:!1})}catch(e){g({error:Gc(e),loading:!1})}},T=async()=>{y({loading:!0,error:null});try{const e=await t.auth.getVendorPasswordHistoryPolicy();y({policy:e,loading:!1})}catch(e){y({error:Gc(e),loading:!1})}},E=async()=>{S({loading:!0,error:null});try{var t,n;const o=await i();await(async t=>{var n,o;const i=await a.customLoginEnabled();if(!t||!i)return;const{policy:s}=null!=(n=null==(o=e.auth.securityPolicyState)?void 0:o.publicPolicy)?n:{policy:null};r({policy:j({},s,{authStrategy:t}),loading:!1})})(null==o||null==(t=o.mainAuthStrategies)||null==(n=t[0])?void 0:n.strategy),S({policy:o,loading:!1})}catch(e){S({error:Gc(e),loading:!1})}};return{setSecurityPolicyState:t=>{Object.assign(e.auth.securityPolicyState,t)},setSecurityPolicyGlobalState:s,setSecurityPolicyPublicState:r,setSecurityPolicyMfaState:l,setSecurityPolicyVendorMfaState:c,setSecurityPolicyLockoutState:u,setSecurityPolicyVendorLockoutState:d,setSecurityPolicyCaptchaState:g,setSecurityPolicyPasswordHistoryState:p,setSecurityPolicyVendorPasswordHistoryState:y,resetSecurityPolicyState:()=>{e.auth.securityPolicyState=Xl(ip)},setSecurityPolicyPasswordState:f,setSecurityPolicyAuthStrategyPublicState:S,loadSecurityPolicy:async()=>{await Promise.all([h(),v(),m(),b(),A(),T(),w(),E()])},loadGlobalSecurityPolicy:h,loadPublicSecurityPolicy:async()=>{r({loading:!0,error:null});try{const e=await t.auth.getVendorConfig(),n=await o(e);r({policy:n,loading:!1})}catch(e){r({error:Gc(e),loading:!1})}},loadVendorPasswordConfig:async()=>{f({loading:!0,error:null});try{const e=await t.auth.getPasswordConfigPolicy();f({policy:e,loading:!1})}catch(e){f({error:Gc(e),loading:!1})}},loadSecurityPolicyMfa:v,loadSecurityPolicyVendorMfa:m,loadSecurityPolicyLockout:b,loadSecurityPolicyVendorLockout:A,loadSecurityPolicyCaptcha:w,loadSecurityPolicyPasswordHistory:async()=>{p({loading:!0,error:null});try{const e=await t.auth.getPasswordHistoryPolicy();p({policy:e,loading:!1})}catch(e){p({error:Gc(e),loading:!1})}},loadSecurityPolicyVendorPasswordHistory:T,loadPublicAuthStrategiesPolicy:E,saveSecurityPolicyMfa:async e=>{const{callback:n}=e,a=oe(e,rp);l({saving:!0,error:null});try{const e=await t.auth.saveMfaPolicy(a);l({policy:e,saving:!1}),null==n||n(e)}catch(e){l({saving:!1,error:Gc(e)}),null==n||n(null,e)}},saveSecurityPolicyLockout:async e=>{const{callback:n}=e,a=oe(e,lp);u({saving:!0,error:null});try{const e=await t.auth.saveLockoutPolicy(a);u({policy:e,saving:!1}),null==n||n(e)}catch(e){u({saving:!1,error:Gc(e)}),null==n||n(null,e)}},saveSecurityPolicyPasswordHistory:async e=>{const{callback:n}=e,a=oe(e,cp);p({saving:!0,error:null});try{const e=await t.auth.savePasswordHistoryPolicy(a);p({policy:e,saving:!1}),null==n||n(e)}catch(e){p({saving:!1,error:Gc(e)}),null==n||n(null,e)}},__getSecurityPolicyPublicStateWithCustomLogin:o}},dp={loading:!1,configurations:{}},gp=e=>Mc(dp,e),pp=["callback"],yp=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auth.sessionsPolicyState,t)};return{setSessionsPolicyState:o,resetSessionsPolicyState:()=>{e.auth.sessionsPolicyState=Xl(dp)},loadSessionsPolicy:async()=>{o({loading:!0,error:null});try{const e=await t.auth.getSessionConfigurations();o({configurations:e,loading:!1})}catch(e){a.setSessionsState({error:e,loading:!1})}},createOrUpdateSessionsPolicy:async e=>{const{callback:n}=e,i=oe(e,pp);try{o({loading:!0,error:null}),await t.auth.createOrUpdateSessionConfigrations(i),await a.loadSessionsPolicy(),null==n||n(!0)}catch(e){o({error:e,loading:!1})}}}},fp={loading:!1,sessions:[]},Sp=e=>Mc(fp,e),hp=(e,t,n)=>{const a=t=>{Object.assign(e.auth.sessionsState,t)},o=async()=>{a({loading:!0,error:null});try{const e=await t.auth.getCurrentUserSessions();a({sessions:e,loading:!1})}catch(e){a({error:Gc(e),loading:!1})}};return{setSessionsState:a,resetSessionsState:()=>{e.auth.sessionsState=Xl(fp)},loadUserSessions:o,loadCurrentUserSession:async()=>{a({loading:!0,error:null});try{const e=await t.auth.getCurrentUserSession();a({currentSession:e,loading:!1})}catch(e){a({error:Gc(e),loading:!1})}},deleteUserSession:async e=>{const{id:n}=e;a({loading:!0,error:null});try{await t.auth.deleteSessionForUser(n),await o()}catch(e){a({error:Gc(e),loading:!1})}},deleteAllUserSessions:async()=>{a({loading:!0,error:null});try{await t.auth.deleteAllSessionsForUser(),await o()}catch(e){a({error:Gc(e),loading:!1})}},revokeUserSessions:async e=>{const{callback:n,userId:o}=e;a({loading:!0,error:null});try{await t.auth.revokeSessionsForUser(o),a({loading:!1}),null==n||n(!0)}catch(e){a({error:Gc(e),loading:!1}),null==n||n(!1)}}}},vp={loading:!1,allowSignUps:!1,allowNotVerifiedUsersLogin:!1,firstLoad:!0,stage:kc.SignUp},mp=e=>Mc(vp,e),bp=["events","url"],Ap=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auth.signUpState,t)},i=()=>{e.auth.signUpState=Xl(vp)};return{setSignUpState:o,resetSignUpState:i,resetSignUpStateSoft:()=>{const{allowSignUps:t,allowNotVerifiedUsersLogin:n}=e.auth.signUpState;i(),o({allowSignUps:t,allowNotVerifiedUsersLogin:n})},signUpUser:async n=>{const{events:i,url:s}=n,r=oe(n,bp);o({loading:!0});try{const{routes:n,onRedirectTo:c}=e.auth,{shouldActivate:u,user:d,tenantId:g,userId:p,tenants:y=[],activeTenant:f}=await t.auth.signUpUser(Tu(r));if(!r.invitationToken){var l;const{email:e,name:t,companyName:n,phoneNumber:a}=r,o={email:e,name:t,companyName:n,url:s,phoneNumber:a||void 0,authenticationType:Lc.PASSWORD,id:p,tenantId:g,createdAt:new Date};null==i||null==(l=i.signUpComplete)||l.call(i,o),qc(Hc.SIGNUP_COMPLETED,o)}if(!u&&d&&bu(d)){const e=await a.getMfaRequiredState(d);a.setAuthState(e),c(n.loginUrl)}else{const t=e.auth.tenantsState;o({loading:!1,shouldActivate:u,stage:kc.SignUpSuccess}),a.setAuthState({user:d,isAuthenticated:!(null==d||!d.accessToken),tenantsState:j({},t,{tenants:y,activeTenant:f})})}}catch(e){ne.setAccessToken(null),ne.setUser(null),o({error:Gc(e)})}finally{o({loading:!1})}},loadAllowSignUps:async()=>{o({loading:!0});try{const e=await t.auth.getVendorConfig(),n=await a.__getSecurityPolicyPublicStateWithCustomLogin(e),{allowSignups:i,allowNotVerifiedUsersLogin:s}=e;o({loading:!1,allowSignUps:i,allowNotVerifiedUsersLogin:s,firstLoad:!1}),a.setSecurityPolicyPublicState({policy:n,loading:!1})}catch(e){o({loading:!1,error:Gc(e),firstLoad:!1})}}}},wp={loading:!1,error:null,phoneNumbers:void 0},Tp=e=>Mc(wp,e),Ep=["callback"],Ip=["callback"],kp=["callback","phoneId"],Op=["callback","phoneId"],_p=["callback"],Pp=(e,t,n)=>{const a=t=>{Object.assign(e.auth.smsState,t)},o=async()=>{a({loading:!0});const e={_limit:10,_offset:0};try{const{items:n}=await t.userPhoneNumbers.getUserPhoneNumbers(e);a({phoneNumbers:n})}catch(e){a({error:Gc(e)})}finally{a({loading:!1})}};return{setSmsState:a,resetSmsState:()=>{e.auth.smsState=Xl(wp)},loadPhoneNumbers:o,setUpPhoneNumber:async e=>{const{callback:n}=e,i=oe(e,Ep);a({loading:!0});try{const{otcToken:e}=await t.userPhoneNumbers.createPhoneNumber(i);a({otcToken:e}),await o(),null==n||n(!0)}catch(e){a({error:Gc(e)}),null==n||n(!1,e)}finally{a({loading:!1})}},verifyPhoneNumber:async e=>{const{callback:n}=e,i=oe(e,Ip);a({loading:!0});try{await t.userPhoneNumbers.verifyPhoneNumber(i),await o(),null==n||n(!0)}catch(e){a({error:Gc(e)}),null==n||n(!1,e)}finally{a({loading:!1})}},deletePhoneNumber:async e=>{const{callback:n,phoneId:o}=e;oe(e,kp),a({loading:!0});try{const{otcToken:e}=await t.userPhoneNumbers.deletePhoneNumber(o);a({otcToken:e}),null==n||n(!0)}catch(e){a({error:Gc(e)}),null==n||n(!1,e)}finally{a({loading:!1})}},verifyDeletePhoneNumber:async e=>{const{callback:n,phoneId:i}=e,s=oe(e,Op);a({loading:!0});try{await t.userPhoneNumbers.verifyDeletePhoneNumber(i,s),await o(),null==n||n(!0)}catch(e){a({error:Gc(e)}),null==n||n(!1,e)}finally{a({loading:!1})}},preVerifyPhoneNumber:async e=>{const{callback:n}=e,o=oe(e,_p);a({loading:!0});try{const{otcToken:e}=await t.userPhoneNumbers.preVerifyPhoneNumber(o);a({otcToken:e}),null==n||n(!0)}catch(e){a({error:Gc(e)}),null==n||n(!1,e)}finally{a({loading:!1})}}}},Up={firstLoad:!0,loading:!1,error:""},Lp=e=>Mc(Up,e),Dp=["authorizationUrl"],Rp=["events","url"],Cp=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auth.socialLoginState,t)};return{setSocialLoginsState:o,resetSocialLoginsState:()=>{e.auth.socialLoginState=Xl(Up)},setSocialLoginError:e=>{o({error:e.error,loading:!1,firstLoad:!1})},loadSocialLoginsConfiguration:async()=>{try{o({loading:!0});const e=await t.auth.getSocialLoginProviders();o({socialLoginsConfig:e,loading:!1,firstLoad:!1})}catch(e){o({error:Gc(e),loading:!1,firstLoad:!1})}},loadSocialLoginsConfigurationV2:async n=>{try{var a;const i=e.root.context;o({loading:!0});const s=await(async()=>{let n;return n=e.auth.isAuthenticated?await t.auth.getSocialLoginProvidersV2ForAuthenticatedUser():await t.auth.getSocialLoginProvidersV2(),n})(),{providers:r}=await t.auth.getCustomSocialLoginProvidersV1(),l={socialLoginsConfigV2:s.map((e=>{let{authorizationUrl:n}=e,a=oe(e,Dp);const o=t.fetch.getBaseUrl(i,null!=n?n:"");return j({},a,{authorizationUrl:n?`${o}${n}`:null})})),customSocialLoginsConfig:r,loading:!1,firstLoad:!1};o(l),null==n||null==(a=n.callback)||a.call(n,l)}catch(e){var i;null==n||null==(i=n.callback)||i.call(n,null,e),o({error:Gc(e),loading:!1,firstLoad:!1})}},loginViaSocialLogin:async e=>{const{events:n,url:i}=e,s=oe(e,Rp);try{o({loading:!0});const{email:e,isNewUser:c,userId:u,tenantId:d,name:g}=await t.auth.loginViaSocialLogin(s);if(c){var r,l;const t={email:e,url:i,createdAt:new Date,id:u,tenantId:d},a=j({},t,{socialProvider:s.provider,authenticationType:Lc.SOCIAL_LOGIN});null==n||null==(r=n.signUpComplete)||r.call(n,a),qc(Hc.SIGNUP_COMPLETED,a);const o=j({},t,{origin:Uc.SOCIAL_LOGIN,name:g});null==n||null==(l=n.userVerified)||l.call(n,o),qc(Hc.USER_VERIFIED,o)}u&&localStorage.setItem("userId",u),a.setLoginState({email:e,isNewUser:c}),a.refreshTokenForSocialLogins(),localStorage.removeItem("register-quick-login"),o({loading:!1})}catch(e){o({loading:!1,error:Gc(e,"Failed to authenticate"),firstLoad:!1})}}}},Np={firstLoad:!0,loading:!0,saving:!1,errors:{},loaders:{},ssoConfigurations:[]},Mp=e=>Mc(Np,e),Fp=["callback","samlVendor"],$p=["callback"],jp=["callback","ssoConfigId"],Gp=["callback","ssoConfigId"],xp=["callback","ssoConfigId"],Vp=(e,t,n)=>j({},((e,t,n)=>{const a=n,o=async()=>{try{const e=await t.auth.getSamlRoles(),n=await t.auth.getSamlRolesGroups();i({authorizationRoles:e.roleIds,rolesGroups:n,error:void 0})}catch(e){i({error:Gc(e)})}},i=t=>{Object.assign(e.auth.ssoState,t)};return{setSSOState:i,resetSSOState:()=>{e.auth.ssoState=Xl(Np)},setSSOLoader:t=>{Object.assign(e.auth.ssoState,{loaders:j({},e.auth.ssoState.loaders,{[t.key]:t.value})})},setSSOError:t=>{Object.assign(e.auth.ssoState,{errors:j({},e.auth.ssoState.errors,{[t.key]:t.value}),loaders:j({},e.auth.ssoState.loaders,{[t.key]:!1})})},loadSSOConfigurations:async()=>{try{var e,n;i({loading:!0});const a=await t.auth.getSamlConfiguration(),o=await t.auth.getOidcConfiguration(),s=await t.metadata.getSamlMetadata();a.acsUrl=null==s||null==(e=s.configuration)?void 0:e.acsUrl,a.spEntityId=null==s||null==(n=s.configuration)?void 0:n.spEntityId,a.isSamlActive=null==s?void 0:s.isActive,i({samlConfiguration:a,oidcConfiguration:o,loading:!1,firstLoad:!1})}catch(e){i({error:Gc(e),loading:!1})}},saveSSOConfigurations:async n=>{const{callback:a,samlVendor:o}=n,s=oe(n,Fp),r=e.auth.ssoState.samlConfiguration,l=j({},r,s);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:j({},r,l)});if(i({error:void 0,[c]:!0}),n.type===_c.Saml){var u,d;const e=await t.metadata.getSamlMetadata();l.acsUrl=null==e||null==(u=e.configuration)?void 0:u.acsUrl,l.spEntityId=null==e||null==(d=e.configuration)?void 0:d.spEntityId}const e=ec(l,["validated","generatedVerification","createdAt","updatedAt"]);(null==r?void 0:r.domain)!==(null==e?void 0:e.domain)&&(e.ssoEndpoint="",e.publicCertificate="",e.signRequest=!1),e.type=null==o?void 0:o.toLowerCase();const s=await t.auth.updateSamlConfiguration(e);s.isSamlActive=null==r?void 0:r.isSamlActive,i({samlConfiguration:s,error:void 0,[c]:!1}),null==a||a(!0)}catch(e){i({samlConfiguration:r,error:Gc(e),[c]:!1}),null==a||a(null,e)}},saveSSOConfigurationsFile:async n=>{const a=e.auth.ssoState.samlConfiguration,o="saving";i({error:void 0,[o]:!0});try{const e=await vd(n[0]),s=await t.auth.updateSamlVendorMetadata({metadata:e});s.isSamlActive=null==a?void 0:a.isSamlActive,i({samlConfiguration:s,error:void 0,[o]:!1})}catch(e){i({samlConfiguration:a,error:Gc(e),[o]:!1})}},saveSSOConfigurationsFileWithCallback:async n=>{const{configFile:a,callback:o}=n,s=e.auth.ssoState.samlConfiguration,r="saving";i({error:void 0,[r]:!0});try{const e=await vd(a),n=await t.auth.updateSamlVendorMetadata({metadata:e});n.isSamlActive=null==s?void 0:s.isSamlActive,i({samlConfiguration:n,error:void 0,[r]:!1}),null==o||o(!0)}catch(e){i({samlConfiguration:s,error:Gc(e),[r]:!1}),null==o||o(null,e)}},validateSSODomain:async n=>{const{callback:a}=null!=n?n:{},o=e.auth.ssoState.samlConfiguration;if(!o){const e=new Error("IllegalState: samlConfiguration is not defined");return console.error(e),void(null==a||a(null,e))}try{i({error:void 0,saving:!0}),await t.auth.validateSamlDomain(),i({samlConfiguration:j({},o,{validated:!0}),error:void 0,saving:!1}),null==a||a(!0)}catch(e){i({samlConfiguration:j({},o,{validated:!1}),error:Gc(e),saving:!1}),null==a||a(null,e)}},loadSSOAuthorizationRoles:async()=>{try{const e=await t.auth.getSamlRoles(),n=await t.auth.getSamlRolesGroups();i({authorizationRoles:e.roleIds,rolesGroups:n,error:void 0})}catch(e){i({error:Gc(e)})}},updateSSOAuthorizationRoles:async e=>{const{callback:n,authorizationRoles:a,groups:s}=e;try{i({error:void 0,saving:!0}),await t.auth.updateSamlRoles({roleIds:a}),s&&await(async e=>{try{await Promise.all(e.map((e=>t.auth.updateSamlGroup({id:e.id,roleIds:e.roleIds,group:e.group}))))}catch(e){i({error:Gc(e)})}})(s),await o(),i({error:void 0,saving:!1}),null==n||n(!0)}catch(e){i({error:Gc(e),saving:!1}),null==n||n(null,e)}},deleteSamlGroup:async e=>{const{id:n,callback:a}=e;try{i({error:void 0,saving:!0}),await t.auth.deleteSamlGroup({id:n}),await o(),i({error:void 0,saving:!1}),null==a||a(!0)}catch(e){i({error:Gc(e),saving:!1}),null==a||a(null,e)}},createSamlGroup:async e=>{const{group:n,roleIds:a,callback:s}=e;try{i({error:void 0,saving:!0}),await t.auth.createSamlGroup({group:n,roleIds:a}),await o(),i({error:void 0,saving:!1}),null==s||s(!0)}catch(e){i({error:Gc(e),saving:!1}),null==s||s(null,e)}},oidcPostlogin:async e=>{const n={code:e.code,redirectUri:e.redirectUri,RelayState:e.state};try{i({loading:!0}),await t.auth.oidcPostLoginV2(n),await a.__refreshToken(),i({loading:!1})}catch(e){i({loading:!1,error:Gc(e,"Failed to authenticate"),firstLoad:!1})}}}})(e,t,n),((e,t,n)=>{const a=n,o=async()=>{try{return await t.auth.getOidcConfiguration()}catch(e){return null}},i=async()=>{try{return await t.metadata.getSamlMetadata()}catch(e){return null}},s=async(e,t,n)=>{a.setSSOLoader({key:e,value:!0});try{await n()}catch(n){a.setSSOError({key:e,value:Gc(n)}),null==t||t(null,n)}finally{a.setSSOLoader({key:e,value:!1})}};return{loadSSOConfigurationsV2:async()=>{await s(Oc.LOAD_SSO_CONFIGURATIONS,void 0,(async()=>{const[e,n]=await Promise.all([o(),i()]),s=await t.auth.getSSOConfigurations();a.setSSOState({ssoConfigurations:s,oidcConfiguration:e,samlMetadata:n})}))},saveSSOConfigurationV2:async n=>{const{callback:o}=n,i=oe(n,$p),r=e.auth.ssoState.ssoConfigurations;await s(Oc.SAVE_SSO_CONFIGURATION,o,(async()=>{var e;const n=await t.auth.createSSOConfiguration(j({},i,{enabled:null!=(e=i.enabled)&&e}));a.setSSOState({ssoConfigurations:[...r,n]}),null==o||o(n)}))},updateSSOConfiguration:async n=>{const{callback:o,ssoConfigId:i}=n,r=oe(n,jp),l=e.auth.ssoState.ssoConfigurations;await s(Oc.UPDATE_SSO_CONFIGURATION,o,(async()=>{const e=await t.auth.updateSSOConfiguration(i,r),n=l.map((t=>t.id===i?e:t));a.setSSOState({ssoConfigurations:n}),null==o||o(e)}))},deleteSSOConfiguration:async n=>{const{ssoConfigId:o,callback:i}=n,r=e.auth.ssoState.ssoConfigurations;await s(Oc.DELETE_SSO_CONFIGURATION,i,(async()=>{await t.auth.deleteSSOConfiguration(o),a.setSSOState({ssoConfigurations:r.filter((({id:e})=>e!==o))}),null==i||i(!0)}))},saveSSODomain:async n=>{const{callback:o,ssoConfigId:i}=n,r=oe(n,Gp),l=e.auth.ssoState.ssoConfigurations;await s(Oc.SAVE_SSO_DOMAIN,o,(async()=>{const e=await t.auth.createSSODomain(i,r),n=l.map((t=>t.id===i?j({},t,{domains:[...t.domains,e]}):t));a.setSSOState({ssoConfigurations:n}),null==o||o(e)}))},deleteSSODomain:async n=>{const{ssoConfigId:o,domainId:i,callback:r}=n,l=e.auth.ssoState.ssoConfigurations;await s(Oc.DELETE_SSO_DOMAIN,r,(async()=>{await t.auth.deleteSSODomain(o,i);const e=l.map((e=>e.id===o?j({},e,{domains:e.domains.filter((({id:e})=>e!==i))}):e));a.setSSOState({ssoConfigurations:e}),null==r||r(!0)}))},validateSSODomainV2:async n=>{const{callback:o,domainId:i,ssoConfigId:r}=n;await s(Oc.VALIDATE_SSO_DOMAIN,o,(async()=>{const n=e.auth.ssoState.ssoConfigurations;await t.auth.validateSSODomainV2(r,i);const s=n.map((e=>e.id===r?j({},e,{domains:e.domains.map((e=>e.id===i?j({},e,{validated:!0}):e))}):e));a.setSSOState({ssoConfigurations:s}),null==o||o(!0)}))},setSSOGroups:async n=>{const{groupsToAdd:o,groupsToDelete:i,ssoConfigId:r,callback:l}=n;await s(Oc.SAVE_SSO_GROUPS,l,(async()=>{const n=e.auth.ssoState.ssoConfigurations;await Promise.all(i.map((e=>t.auth.deleteSSOGroup(r,e)))),await Promise.all(o.map((e=>t.auth.createSSOGroup(r,e))));const s=await t.auth.getSSOGroups(r),c=n.map((e=>e.id===r?j({},e,{groups:s}):e));a.setSSOState({ssoConfigurations:c}),null==l||l(!0)}))},updateSSOGroups:async e=>{const{ssoConfigId:n,changedGroups:a,callback:o}=e;await s(Oc.SAVE_SSO_GROUPS,o,(async()=>{await Promise.all(a.map((e=>t.auth.updateSSOGroup(n,e)))),null==o||o(!0)}))},setSSODefaultRoles:async n=>{const{callback:o,ssoConfigId:i,roleIds:r}=n;await s(Oc.UPDATE_SSO_DEFAULT_ROLES,o,(async()=>{const n=e.auth.ssoState.ssoConfigurations;await t.auth.setSSODefaultRoles(i,{roleIds:r});const s=n.map((e=>e.id===i?j({},e,{roleIds:r}):e));a.setSSOState({ssoConfigurations:s}),null==o||o(!0)}))},saveSSOConfigurationByMetadata:async n=>{const{configFile:o,callback:i}=n;await s(Oc.SAVE_SSO_CONFIGURATION_BY_METADATA,i,(async()=>{const n=e.auth.ssoState.ssoConfigurations,s=await vd(o),r=await t.auth.createSSOConfigurationByMetadata({metadata:s});a.setSSOState({ssoConfigurations:[...n,r]}),null==i||i(r)}))},updateSSOConfigurationByMetadata:async n=>{const{callback:o,ssoConfigId:i,configFile:r}=n;await s(Oc.UPDATE_SSO_CONFIGURATION_BY_METADATA,o,(async()=>{const n=e.auth.ssoState.ssoConfigurations,s=await vd(r),l=await t.auth.updateSSOConfigurationByMetadata(i,{metadata:s}),c=n.map((e=>e.id===i?l:e));a.setSSOState({ssoConfigurations:c}),null==o||o(l)}))},saveSSOConfigurationByUrl:async n=>{const{metadataUrl:o,configMetadata:i,ssoConfigId:r,callback:l}=n;await s(Oc.SAVE_SSO_CONFIGURATION_BY_METADATA,l,(async()=>{const n=e.auth.ssoState.ssoConfigurations,s={url:o,configMetadata:i};let c,u;r?(c=await t.auth.updateSSOConfigurationByMetadataUrl(r,s),u=n.map((e=>e.id===r?c:e))):(c=await t.auth.createSSOConfigurationByMetadataUrl(s),u=[c,...n]),a.setSSOState({ssoConfigurations:u}),null==l||l(c)}))},saveSSOConfigurationByData:async n=>{const{callback:o,ssoConfigId:i}=n,r=oe(n,xp),l=e.auth.ssoState.ssoConfigurations;await s(Oc.SAVE_SSO_CONFIGURATION,o,(async()=>{let e,n;i?(e=await t.auth.updateSSOConfiguration(i,r),n=l.map((t=>t.id===i?e:t))):(e=await t.auth.createSSOConfiguration(r),n=[e,...l]),a.setSSOState({ssoConfigurations:n}),null==o||o(e)}))}}})(e,t,n)),Bp={loading:!1,mfaDevices:void 0,mfaToken:""},Wp=e=>Mc(Bp,e),zp=(e,t,n)=>{const a=n;return j({setStepUpState:t=>{Object.assign(e.auth.stepUpState,t)},resetStepUpState:()=>{e.auth.stepUpState=Xl(Bp)},stepUpWithAuthenticator:async e=>{await a.mfaWithAuthenticator(e,a.setStepUpState,!0)},preVerifyMFASMSForStepUp:async e=>{await a.preVerifyMFASMS(e,a.setStepUpState)},verifyMFASMSForStepUp:async e=>{await a.verifyMFASMS(e,a.setStepUpState,!0)},preVerifyMFAWebAuthnForStepUp:async e=>{await a.preVerifyMFAWebAuthn(e,a.setStepUpState)},verifyMFAWebAuthnForStepUp:async e=>{await a.verifyMFAWebAuthn(e,a.setStepUpState,!0)},preVerifyMFAEmailCodeForStepUp:async e=>{await a.preVerifyMFAEmailCode(e,a.setStepUpState)},verifyMFAEmailCodeForStepUp:async e=>{await a.verifyMFAEmailCode(e,a.setStepUpState)}},((e,t,n)=>{const a=n;return{generateStepUpSession:async n=>{const{maxAge:o,callback:i}=n;a.setStepUpState({mfaDevices:void 0,mfaToken:""});try{const e=await t.auth.generateStepupSession({maxAge:o});e.hasOwnProperty("user")?await(async e=>{await a.__afterAuthenticationStateUpdate(e),await a.afterStepUpAuthNavigation()})(e):await(async({mfaToken:e,mfaDevices:t})=>{a.setStepUpState({mfaDevices:t,mfaToken:e});const n=await ou(t);a.setMfaState({step:n})})(e),null==i||i(!0)}catch(t){null==i||i(!1),await(async t=>{if((e=>"MFA is not enrolled"===(null==e?void 0:e.message))(t))return void a.setMfaState({step:Ac.noMFAEnrolledStepUp});window.localStorage.setItem(du,"true");const n=e.auth.routes;ne.onRedirectTo(n.logoutUrl,{preserveQueryParams:!0})})(t)}}}})(e,t,n),((e,t,n)=>{const a=n;return{stepUpHostedLogin:async t=>{var n,o;const i={acr_values:lu},{maxAge:s}=t||{};void 0!==s&&(i.max_age=s.toString());const r=null==(n=e.auth.tenantsState)||null==(o=n.activeTenant)?void 0:o.alias;r&&(i.organization=r),Su(),window.localStorage.setItem(du,"true"),await a.__requestHostedLoginAuthorize(i)}}})(e,0,n))},Kp={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}},Hp=e=>Mc(Kp,e),qp=["callback","appIds"],Jp=["roles"],Yp=["callback","profileImage"],Xp=["callback"],Qp=["callback"],Zp=["callback"],ey=["callback","userId"],ty=["callback"],ny=["callback"],ay=["callback"],oy=["callback"],iy=["callback"],sy=["callback"],ry=(e,t,n)=>{const a=t=>{Object.assign(e.auth.teamState,t)};return j({setTeamLoader:t=>{Object.assign(e.auth.teamState,{loaders:j({},e.auth.teamState.loaders,{[t.key]:t.value})})},setTeamError:t=>{Object.assign(e.auth.teamState,{errors:j({},e.auth.teamState.errors,{[t.key]:t.value}),loaders:j({},e.auth.teamState.loaders,{[t.key]:!1})})},setTeamState:a,resetTeamState:()=>{e.auth.teamState=Xl(Kp)},openAddUserDialog:e=>{a({addUserDialogState:j({open:!0,loading:!1,error:!1},e)})},closeAddUserDialog:t=>{var n,o;null==(n=(o=e.auth.teamState.addUserDialogState).onClose)||n.call(o,t),a({addUserDialogState:{loading:!1,error:!1,open:!1}})},openDeleteUserDialog:e=>{a({deleteUserDialogState:j({open:!0,loading:!1,error:!1},e)})},closeDeleteUserDialog:t=>{var n,o;null==(n=(o=e.auth.teamState.deleteUserDialogState).onClose)||n.call(o,t),a({deleteUserDialogState:{loading:!1,error:!1,open:!1}})},lockUser:async e=>{}},((e,t,n)=>{const a=n,o=async()=>{try{const{groups:e}=await t.groups.getGroups({_groupsRelations:$l.roles});return e}catch(e){return[]}},i=async e=>{a.setTeamLoader({key:Pc.ROLES_AND_PERMISSIONS,value:!0});try{var n;const[{items:o},{items:i}]=await Promise.all([t.teams.loadAvailableRoles(),t.teams.loadAvailablePermissions()]);a.setTeamState({roles:o,permissions:i}),null==e||null==(n=e.callback)||n.call(e,{roles:o,permissions:i})}catch(t){var o;null==e||null==(o=e.callback)||o.call(e,null,t),a.setTeamError({key:Pc.ROLES_AND_PERMISSIONS,value:Gc(t)})}finally{a.setTeamLoader({key:Pc.ROLES_AND_PERMISSIONS,value:!1})}};return{loadRoles:i,loadUsers:async n=>{var o,s,r,l;const{silentLoading:c,callback:u}=n,d=e.auth.teamState,g=null!=(o=n.pageSize)?o:d.pageSize,p=null!=(s=n.pageOffset)?s:d.pageOffset,y=null!=(r=n.filter)?r:d.filter,f=null!=(l=n.sort)?l:d.sort;a.setTeamLoader({key:Pc.USERS,value:!c}),a.setTeamState({pageSize:g,pageOffset:p,filter:y,sort:f});try{const[{items:e,totalPages:n,totalItems:o}]=await Promise.all([t.teams.loadUsers({pageSize:g,pageOffset:p,filter:y,sort:f}),i()]);a.setTeamState({users:e,totalPages:n,totalItems:o}),null==u||u(e)}catch(e){a.setTeamError({key:Pc.USERS,value:Gc(e)}),a.setTeamState({totalPages:0,users:[]}),null==u||u(null,e)}a.setTeamLoader({key:Pc.USERS,value:!1})},loadUsersV2:async s=>{var r,l,c,u,d;const{silentLoading:g,callback:p,shouldLoadRoles:y=!0,shouldLoadApps:f}=s,S=e.auth.teamState,h=null!=(r=s.pageSize)?r:S.pageSize,v=null!=(l=s.pageOffset)?l:S.pageOffset,m=null!=(c=s.filter)?c:S.filterV2,b=null!=(u=s.sort)?u:S.sortV2,A=null!=(d=null==s?void 0:s.shouldShowSubTenantUsersIfReseller)?d:null==S?void 0:S.shouldShowSubTenantUsersIfReseller;a.setTeamLoader({key:Pc.USERS,value:!g}),a.setTeamState({pageSize:h,pageOffset:v,filterV2:m,sortV2:b});try{const[{items:e,_metadata:{totalPages:a,totalItems:r}},{items:l},{items:c},u]=await Promise.all([t.users.getUsersV2(j({},(null==m?void 0:m.length)&&{_filter:m},b&&{_sortBy:b},s.order&&{_order:s.order},{_offset:v,_limit:h,_includeSubTenants:A})),t.teams.loadAvailableRoles(),t.teams.loadAvailablePermissions(),o(),y?i():void 0]),d=e.map((e=>{var t;return j({},e,{groups:null==e||null==(t=e.groups)?void 0:t.map((e=>u.filter((t=>t.id===e.id)))).flat()})})).map((e=>j({},e,{roleIds:e.roles.map((e=>e.id))}))),g=await n.mapUsersWithApplicationData({shouldLoadApps:f,users:d});n.setTeamState({users:g,totalPages:a,totalItems:r,roles:l,permissions:c}),null==p||p(e)}catch(e){a.setTeamError({key:Pc.USERS,value:Gc(e)}),a.setTeamState({totalPages:0,users:[]}),null==p||p(null,e)}a.setTeamLoader({key:Pc.USERS,value:!1})},addUser:async o=>{const{callback:i,appIds:s}=o,r=oe(o,qp),l=e.auth.teamState;a.setTeamState({addUserDialogState:j({},l.addUserDialogState,{loading:!0})});try{var c;const e=await t.teams.addUser(r),{roles:o}=e,u=j({},oe(e,Jp),{roleIds:null!=(c=null==o?void 0:o.map((e=>e.id)))?c:[]}),d=await n.assignNewUserToApps({appIds:s,user:u});d&&(u.applications=d),null==i||i(u),a.setTeamState({users:[u,...l.users],addUserDialogState:{open:!1,loading:!1}})}catch(e){a.setTeamState({addUserDialogState:j({},l.addUserDialogState,{loading:!1,error:Gc(e)})}),null==i||i(null,e)}},addUsersBulk:async n=>{const{callback:o}=n,i=e.auth.teamState;a.setTeamState({addUserDialogState:j({},i.addUserDialogState,{loading:!0})});const s=[],r=[],l=n.emails.map((e=>j({email:e,roleIds:n.roleIds},n.expirationInSeconds&&{expirationInSeconds:n.expirationInSeconds})));a.setTeamState({addUserDialogState:{open:!0,loading:!0}});for(let e=0;e<l.length;e++){const n=l.at(e);try{await t.teams.addUser(n),s.push(n.email)}catch(e){r.push(n.email)}}const c={pageOffset:0,pageSize:10,filter:"",silentLoading:n.emails.length>0};await a.loadUsersV2(c),a.setTeamState({addUserDialogState:{loading:!1}}),null==o||o({unallowedEmails:r,allowedEmails:s})},updateUser:async n=>{const{callback:o}=n,i=oe(n,Yp),{id:s}=i,r=e.auth.teamState,l=r.users.find((e=>e.id===i.id));if(void 0!==l){a.setTeamLoader({key:Pc.UPDATE_USER,value:s||""}),a.setTeamState({addUserDialogState:j({},r.addUserDialogState,{loading:!0})}),a.setTeamState({addUserDialogState:j({},r.addUserDialogState,{loading:!0}),users:r.users.map((e=>e.id===i.id?j({},e,i):e))});try{var c;l.roleIds.length>0&&0===(null==(c=i.roleIds)?void 0:c.length)&&(i.roleIds=[""]);const{item:e}=await t.teams.updateUser(i);null==o||o(e),a.setTeamState({users:r.users.map((t=>t.id===e.id?j({},t,e,{groups:t.groups,createdAt:t.createdAt,customData:t.customData,lastLogin:t.lastLogin}):t))}),a.setTeamLoader({key:Pc.UPDATE_USER,value:!1})}catch(e){a.setTeamState({addUserDialogState:j({},r.addUserDialogState,{loading:!1,error:Gc(e)}),users:r.users.map((e=>e.id===i.id?j({},e,l):e))}),a.setTeamLoader({key:Pc.UPDATE_USER,value:!1}),null==o||o(null,e)}}else null==o||o(null,"User not in state")},deleteUser:async n=>{const{callback:o}=n,i=oe(n,Xp),s=e.auth.teamState;a.setTeamState({deleteUserDialogState:j({},s.deleteUserDialogState,{loading:!0})});try{await t.teams.deleteUser(i),null==o||o(!0),a.setTeamState({users:s.users.filter((e=>e.id!==i.userId)),deleteUserDialogState:{open:!1,loading:!1}})}catch(e){a.setTeamState({deleteUserDialogState:j({},s.deleteUserDialogState,{loading:!1,error:Gc(e)})}),null==o||o(null,e)}},getTemporaryUsersConfig:async()=>{a.setTeamError({key:Pc.CONFIG_TEMPORARY_USERS,value:!1});try{const e=await t.teams.getTemporaryUserConfiguration();a.setTeamState({temporaryUsersConfig:e})}catch(e){a.setTeamError({key:Pc.CONFIG_TEMPORARY_USERS,value:Gc(e)})}},updateUserExpirationTime:async n=>{const{callback:o}=n,i=oe(n,Qp),s=e.auth.teamState;a.setTeamLoader({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:!0});try{const e=await t.teams.updateUserExpirationTime(i);a.setTeamState({users:s.users.map((t=>t.id===i.userId?j({},t,{temporaryExpirationDate:new Date(e.temporaryExpirationDate)}):t))}),null==o||o(!0)}catch(e){a.setTeamError({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:Gc(e)}),null==o||o(null,e)}finally{a.setTeamLoader({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:!1})}},setUserAsPermanent:async n=>{const{callback:o}=n,i=oe(n,Zp),s=e.auth.teamState;a.setTeamLoader({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:!0});try{await t.teams.setPermanentUser(i.userId),a.setTeamState({users:s.users.map((e=>e.id===i.userId?j({},e,{temporaryExpirationDate:void 0}):e))}),null==o||o(!0)}catch(e){a.setTeamError({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:Gc(e)}),null==o||o(null,e)}finally{a.setTeamLoader({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:!1})}}}})(e,t,n),((e,t,n)=>{const a=n;return{loadAllSubTenantsUsers:async n=>{var o,i,s,r,l;const{silentLoading:c,callback:u}=n,d=e.auth.teamState.allUsersQueryParams,g={_limit:(null!=(o=n._limit)?o:d._limit)||20,_offset:(null!=(i=n._offset)?i:d._offset)||0,_filter:(null!=(s=n._filter)?s:d._filter)||"",_sortBy:(null!=(r=n._sortBy)?r:d._sortBy)||"name",_order:(null!=(l=n._order)?l:d._order)||"DESC"};a.setTeamLoader({key:Pc.USERS,value:!c}),a.setTeamState({allUsersQueryParams:g});try{const[{items:e,_metadata:{totalPages:n,totalItems:o}},{items:i},{items:s}]=await Promise.all([t.subTenants.loadAllUsers(j({},g)),t.teams.loadAvailableRoles(),t.teams.loadAvailablePermissions()]);a.setTeamState({allUsers:e,totalPages:n,totalItems:o,roles:i,permissions:s}),null==u||u(e)}catch(e){a.setTeamError({key:Pc.USERS,value:Gc(e)}),a.setTeamState({totalPages:0,users:[]}),null==u||u(null,e)}a.setTeamLoader({key:Pc.USERS,value:!1})},setUserRolesForSubTenants:async n=>{const{callback:o,userId:i}=n,s=oe(n,ey),r=e.auth.teamState;a.setTeamState({addUserDialogState:j({},r.addUserDialogState,{loading:!0})});try{await t.subTenants.setUserRolesForSubTenants(i,s);const e=r.allUsers.find((e=>e.id===i));let n=[];e&&(n=e.tenants.map((e=>{var t;return j({},e,{roles:(null==(t=s.subTenantsRoles.find((t=>t.tenantId===e.tenantId)))?void 0:t.roleIds.map((e=>r.roles.find((({id:t})=>e===t)))).filter((e=>e)))||e.roles})}))),a.setTeamState({allUsers:[...r.allUsers.filter((e=>e.id!==i)),...e?[j({},e,{tenants:n})]:[]],addUserDialogState:{open:!1,loading:!1}}),null==o||o(!0)}catch(e){a.setTeamState({addUserDialogState:j({},r.addUserDialogState,{loading:!1,error:Gc(e)})}),null==o||o(null,e)}},deleteUserFromSubTenants:async n=>{const{callback:o}=n,i=oe(n,ty),s=e.auth.teamState;a.setTeamState({deleteUserDialogState:j({},s.deleteUserDialogState,{loading:!0})});try{await t.subTenants.removeUserFromTenantAndSubTenants(i),null==o||o(!0),a.setTeamState({allUsers:s.allUsers.filter((e=>e.id!==i.userId&&e.tenants.length===i.subTenants.length)),deleteUserDialogState:{open:!1,loading:!1}})}catch(e){a.setTeamState({deleteUserDialogState:j({},s.deleteUserDialogState,{loading:!1,error:Gc(e)})}),null==o||o(null,e)}},addUserToSubTenants:async n=>{const{callback:o}=n,i=oe(n,ny),s=e.auth.teamState;a.setTeamState({addUserDialogState:j({},s.addUserDialogState,{loading:!0})});try{await t.subTenants.addUserToTenantAndSubTenants(i);const{items:e,_metadata:{totalPages:n,totalItems:s}}=await t.subTenants.loadAllUsers({_limit:20,_offset:0,_filter:"",_sortBy:"name",_order:"DESC"});a.setTeamState({allUsers:e,totalPages:n,totalItems:s,addUserDialogState:{open:!1,loading:!1}}),null==o||o(null)}catch(e){a.setTeamState({addUserDialogState:j({},s.addUserDialogState,{loading:!1,error:Gc(e)})}),null==o||o(null,e)}}}})(e,t,n),((e,t,n)=>{const a=n,o=async(e,t,n,o)=>{a.setTeamLoader({key:e,value:t});try{await o()}catch(t){a.setTeamError({key:e,value:Gc(t)}),null==n||n(null,t)}finally{a.setTeamLoader({key:e,value:!1})}};return{resendActivationLink:async e=>{const{callback:n}=e,a=oe(e,ay);await o(Pc.RESEND_ACTIVATE_LINK,a.userId,n,(async()=>{await t.teams.resendActivationLink(a),null==n||n(!0)}))},resendInvitationLink:async e=>{const{callback:n}=e,a=oe(e,oy);await o(Pc.RESEND_INVITATION_LINK,a.email,n,(async()=>{await t.teams.resendInvitationLink(a),null==n||n(!0)}))},resendInvitationEmail:async e=>{const{callback:n}=e,a=oe(e,iy);await o(Pc.RESEND_INVITATION_LINK,n,a.email,(async()=>{await t.auth.resendInvitationEmail(a),null==n||n(!0)}))},resendInvitationLinkToAllSubTenants:async e=>{const{callback:n}=e,a=oe(e,sy);await o(Pc.RESEND_INVITATION_LINK,a.email,n,(async()=>{await t.teams.resendInvitationLinkToAllTenants(a),null==n||n(!0)}))}}})(0,t,n),((e,t,n)=>{const a=n;return{getInvitationLink:async()=>{a.setTeamError({key:Pc.GET_TOKEN_LINK,value:!1});try{await(async()=>{a.setTeamError({key:Pc.CONFIG_TOKEN_LINK,value:!1});try{const e=await t.teams.getInviteLinkConfiguration();a.setTeamState({inviteTokenState:j({},e)})}catch(e){a.setTeamError({key:Pc.CONFIG_TOKEN_LINK,value:Gc(e)})}})();const n=await t.teams.getInviteUserLink(),{inviteTokenState:o}=e.auth.teamState;a.setTeamState({inviteTokenState:j({},o,n)})}catch(e){a.setTeamError({key:Pc.GET_TOKEN_LINK,value:Gc(e)})}},createInvitationLink:async n=>{const{callback:o}=n;a.setTeamError({key:Pc.CREATE_TOKEN_LINK,value:!1});const{inviteTokenState:i}=e.auth.teamState;try{const e=await t.teams.createInviteUserLink({expiresInMinutes:43200});a.setTeamState({inviteTokenState:j({},i,e)}),null==o||o(e.token)}catch(e){null==o||o(null,e),a.setTeamError({key:Pc.CREATE_TOKEN_LINK,value:Gc(e)})}},updateInvitationLink:async n=>{const{callback:o,expiresInMinutes:i,shouldSendEmail:s}=n;a.setTeamError({key:Pc.UPDATE_TOKEN_LINK,value:!1});try{const{inviteTokenState:n}=e.auth.teamState,r=await t.teams.updateInviteUserLink({expiresInMinutes:i,shouldSendEmail:s});a.setTeamState({inviteTokenState:j({},n,r)}),null==o||o(!0)}catch(e){null==o||o(null,e),a.setTeamError({key:Pc.UPDATE_TOKEN_LINK,value:Gc(e)})}},deleteInvitationLink:async e=>{const{callback:n}=null!=e?e:{};a.setTeamError({key:Pc.DELETE_TOKEN_LINK,value:!1});try{await t.teams.deleteInviteUserLink(),a.setTeamState({inviteTokenState:void 0}),null==n||n(!0)}catch(e){a.setTeamError({key:Pc.DELETE_TOKEN_LINK,value:Gc(e)}),null==n||n(!1,e)}}}})(e,t,n))},ly={tenants:[],subTenants:[],loading:!0,tenantTree:null},cy=e=>Mc(ly,e),uy=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auth.tenantsState,t)};return{setTenantsState:o,resetTenantsState:()=>{e.auth.tenantsState=Xl(ly)},switchTenant:async e=>{const{tenantId:n,callback:o}=e;a.setAuthState({isLoading:!0});try{await t.tenants.switchTenant({tenantId:n}),await a.__refreshToken(),(null==o?void 0:o(!0))||a.setAuthState({isLoading:!1})}catch(e){a.setAuthState({isLoading:!1}),null==o||o(!1,e)}},loadTenants:async e=>{o({loading:!0});try{var t;const n=Et(),a=await n();o({tenants:a.tenants,activeTenant:a.activeTenant,loading:!1}),null==e||null==(t=e.callback)||t.call(e,[])}catch(t){var n;null==e||null==(n=e.callback)||n.call(e,[],t),o({loading:!1})}},loadSubTenants:async e=>{o({loading:!0});try{var n;const a=await t.tenants.getSubTenants();o({subTenants:a,loading:!1}),null==e||null==(n=e.callback)||n.call(e,!0)}catch(t){var a;o({loading:!1}),null==e||null==(a=e.callback)||a.call(e,null,t)}},loadSubTenantsTree:async e=>{o({loading:!0});try{var n;const a=await t.tenants.getSubTenantsAsTree();o({tenantTree:a,loading:!1}),null==e||null==(n=e.callback)||n.call(e,!0)}catch(t){var a;o({loading:!1}),null==e||null==(a=e.callback)||a.call(e,null,t)}}}},dy=(e,t,n)=>{const a=t=>{e.auth.user&&(e.auth.user.entitlements=t)},o=t=>{var n;gc(null==(n=e.auth.user)?void 0:n.entitlements,t)||a(t)};return{setEntitlements:a,handleFetchedEntitlements:o,loadEntitlements:async e=>{const n=null==e?void 0:e.callback;try{const e=await t.entitlements.loadEntitlementsV2();o(e),null==n||n(!0)}catch(e){null==n||n(!1)}}}},gy=["routes"],py=e=>{const t=null!=e?e:{},{routes:n}=t,a=oe(t,gy);return Mc(j({routes:j({},Yc,n),onRedirectTo:()=>{},isAuthenticated:!1,isLoading:!0,isSSOAuth:!1,user:null,error:void 0,userIp:void 0},a,{acceptInvitationState:$c(null==a?void 0:a.acceptInvitationState),accountSettingsState:Bc(null==a?void 0:a.accountSettingsState),activateAccountState:Kc(null==a?void 0:a.activateAccountState),apiTokensState:Lu(null==a?void 0:a.apiTokensState),applicationsState:Cu(null==a?void 0:a.applicationsState),customLoginState:$u(null==a?void 0:a.customLoginState),forgotPasswordState:Vu(null==a?void 0:a.forgotPasswordState),groupsState:Ku(null==a?void 0:a.groupsState),groupsDialogsState:Yu(null==a?void 0:a.groupsDialogsState),impersonateState:Zu(null==a?void 0:a.impersonateState),loginState:ad(null==a?void 0:a.loginState),mfaState:sd(null==a?void 0:a.mfaState),allAccountsState:dg(null==a?void 0:a.allAccountsState),allAccountsDialogsState:mg(null==a?void 0:a.allAccountsDialogsState),passkeysState:wg(null==a?void 0:a.passkeysState),profileState:Ig(null==a?void 0:a.profileState),provisioningState:Pg(null==a?void 0:a.provisioningState),resetPhoneNumberState:Cg(null==a?void 0:a.resetPhoneNumberState),rolesState:Gg(null==a?void 0:a.rolesState),restrictionsState:Jg(null==a?void 0:a.restrictionsState),securityCenterState:np(null==a?void 0:a.securityCenterState),securityPolicyState:sp(null==a?void 0:a.securityPolicyState),sessionsPolicyState:gp(null==a?void 0:a.sessionsPolicyState),sessionsState:Sp(null==a?void 0:a.sessionsState),signUpState:mp(null==a?void 0:a.signUpState),smsState:Tp(null==a?void 0:a.smsState),socialLoginState:Lp(null==a?void 0:a.socialLoginState),ssoState:Mp(null==a?void 0:a.ssoState),stepUpState:Wp(null==a?void 0:a.stepUpState),teamState:Hp(null==a?void 0:a.teamState),tenantsState:cy(null==a?void 0:a.tenantsState)}))},yy=(e,t,n,a)=>{const o=t=>{Object.keys(t).forEach((n=>{tc(e.auth[n])?Object.assign(e.auth[n],t[n]):e.auth[n]=t[n]}))},i={acceptInvitationActions:xc(e,t),accountSettingsActions:Wc(e,t),activateAccountActions:Pu(e,t,n),apiTokensActions:Du(e,t),applicationsActions:Mu(e,t,n),customLoginActions:Gu(e,t,n),entitlementsActions:dy(e,t),forgotPasswordActions:Wu(e,t),groupsActions:qu(e,t),groupsDialogsActions:Xu(e),impersonateActions:td(e,t,n),loginActions:eg(e,t,n),mfaActions:cg(e,t,n),allAccountsActions:hg(e,t,n),allAccountsDialogActions:bg(e),passkeysActions:Tg(e,t,n),profileActions:Og(e,t,n),provisioningActions:Dg(e,t),resetPhoneNumberActions:$g(e,t,n),rolesActions:Hg(e,t),restrictionsActions:ep(e,t,n),securityCenterActions:op(e,t,n),securityPolicyActions:up(e,t,n),sessionsPolicyActions:yp(e,t,n),sessionsActions:hp(e,t),signUpActions:Ap(e,t,n),smsActions:Pp(e,t),socialLoginActions:Cp(e,t,n),ssoActions:Vp(e,t,n),stepUpActions:zp(e,t,n),teamActions:ry(e,t,n),tenantsActions:uy(e,t,n)};return[j({setAuthState:o,setState:o,resetAuthState:()=>{o(a)},setUser:e=>{o({user:e})}},Object.values(i).reduce(((e,t)=>j({},e,t)),{})),i]},fy={isLoading:!1,isSaving:!1,list:[],processIds:[],slackChannels:{isLoading:!1}},Sy=e=>Mc(fy,e),hy=["email","slack","sms","webhook"],vy={sms:{title:"connectivity.sms",events:e=>(null==e?void 0:e.length)||0,isActive:e=>{var t;return null!=(t=null==e?void 0:e.some((({enabled:e})=>e)))&&t},image:"sms"},email:{title:"common.email",events:e=>(null==e?void 0:e.length)||0,isActive:e=>{var t;return null!=(t=null==e?void 0:e.some((({enabled:e})=>e)))&&t},image:"email"},slack:{title:"connectivity.slack",events:e=>{var t;return(null==e||null==(t=e.slackSubscriptions)?void 0:t.length)||0},isActive:e=>!(null==e||!e.slackSubscriptions.some((({isActive:e})=>e))),image:"slack"},webhook:{title:"connectivity.webhook",events:e=>(null==e?void 0:e.length)||0,isActive:e=>{var t;return null!=(t=null==e?void 0:e.some((({isActive:e})=>e)))&&t},image:"webhook"}},my=["id"],by=["id","enabled"],Ay=(e,t,n)=>{const a={slack:t.connectivity.getSlackConfiguration,email:t.connectivity.getEmailConfiguration,sms:t.connectivity.getSMSConfiguration,webhook:t.connectivity.getWebhooksConfigurations,categories:t.connectivity.getCategories,channelMap:t.connectivity.getChannelMaps},o=["categories","channelMap"],i={slack:t.connectivity.postSlackConfiguration,email:t.connectivity.postEmailConfiguration,sms:t.connectivity.postSMSConfiguration,webhook:t.connectivity.postWebhooksConfiguration},s=t=>{Object.assign(e.connectivity,t)},r=t=>{var n;const a=null!=(n=e.connectivity.retryResult)?n:{};e.connectivity.retryResult=j({},a,t)},l=()=>{e.connectivity=Xl(fy)},c=async(e,t)=>{try{return await a[e](t)}catch(e){return}},u=async()=>{try{s({slackChannels:{isLoading:!0}});const e=await t.connectivity.getSlackChannels();s({error:void 0,slackChannels:{isLoading:!1,data:e}})}catch(e){s({error:void 0,slackChannels:{isLoading:!1}})}},d=async e=>{const t=null!=e?e:hy;s({isLoading:!0});try{const e=await Promise.all([...t.map((e=>c(e))),c("categories"),(async()=>(await Promise.all(t.map((e=>c("channelMap",e))))).reduce(((e,n,a)=>j({},e,{[`${t[a]}`]:n})),{}))()]),n=await c("webhook"),a=e.reduce(((n,a,i)=>t[i]?e[e.length-1][t[i]].length?j({},n,{[`${t[i]}`]:a,list:[...n.list,{id:i,key:t[i],events:vy[t[i]].events(a),active:vy[t[i]].isActive(a),platform:vy[t[i]].title,image:vy[t[i]].image}]}):n:j({},n,{[`${o[i-t.length]}`]:a})),{list:[],webhook:n});s(j({},a,{error:void 0,isSaving:!1,isLoading:!1}))}catch(e){s({isLoading:!1,error:Gc(e)})}},g=async(t,n)=>{const{list:a}=e.connectivity,o=a.find((({key:e})=>e===t));if(!o)return;const i=vy[t].isActive(n);i!==o.active&&s({list:a.map((e=>e.key===t?j({},e,{active:i}):e))})},p=async n=>{const{platform:a,data:o,callback:r}=n,l=e.connectivity.processIds;try{if(s({isSaving:!0,processIds:"webhook"===a?[o._id,...l]:l}),"slack"===a?await(async n=>{var a;const o=null==(a=e.connectivity.slack)?void 0:a.slackSubscriptions;if(!o)return;const{slackSubscriptions:s}=n;await Promise.all([...s.reduce(((e,t)=>{var n,a;return!t.id&&t.slackEvents&&null!=(n=t.slackEvents[0].channelIds)&&n.length||(null==o?void 0:o.find((e=>{let{id:n}=e,a=oe(e,my);return n===t.id&&JSON.stringify(j({id:n},a))!==JSON.stringify(t)})))&&t.slackEvents&&null!=(a=t.slackEvents[0].channelIds)&&a.length?[...e,t]:e}),[]).map((e=>i.slack(e))),...s.reduce(((e,t)=>t.id&&!t.slackEvents[0].channelIds.length?[...e,t]:e),[]).map((e=>t.connectivity.deleteSlackConfiguration(e)))])})(o):["sms","email"].includes(a)?await(async(n,a)=>{const o=e.connectivity.processIds,i=e.connectivity[a];if(!i)return;let r=[];try{r=await Promise.all([...n.reduce(((e,t)=>!i.find((({eventKey:e})=>e===t.eventKey))&&t.subscriptions[0].recipients.filter((e=>e)).length?[...e,t]:e),[]).map((e=>"email"===a?t.connectivity.postEmailConfiguration(e):t.connectivity.postSMSConfiguration(e))),...n.reduce(((e,t)=>{const n=i.find((({eventKey:e})=>e===t.eventKey));return n&&JSON.stringify(n)!==JSON.stringify(t)?[...e,t]:e}),[]).map((e=>{const{subscriptions:n,eventKey:o}=e,i=n[0],{id:s="",enabled:r}=i,l=oe(i,by);return Promise.all(["email"===a?t.connectivity.patchEmailConfiguration({eventKey:o,enabled:r}):t.connectivity.patchSMSConfiguration({eventKey:o,enabled:r}),"email"===a?t.connectivity.putEmailSubscriptions(s,o,j({},l,{enabled:r})):t.connectivity.putSMSSubscriptions(s,o,j({},l,{enabled:r}))])})),...n.reduce(((e,t)=>{const n=i.find((({eventKey:e})=>e===t.eventKey));return n&&n.subscriptions[0].recipients.length&&!t.subscriptions[0].recipients.filter((e=>!!e)).length?[...e,t]:e}),[]).map((({eventKey:e,subscriptions:n})=>"email"===a?t.connectivity.deleteEmailSubscriptions(e,n[0].id||""):t.connectivity.deleteSMSSubscriptions(e,n[0].id||"")))])}catch{}if(r.length){const e=await c(a);s({error:void 0,isSaving:!1,[`${a}`]:e,processIds:e.id?o.filter((t=>t!==e.id)):o}),await g(a,e)}else s({error:void 0,isSaving:!1,[`${a}`]:i,processIds:o})})(o,a):await i[a](o),!["sms","email"].includes(a)){const e=await c(a);"webhook"===a&&(e.id=o._id),s({error:void 0,isSaving:!1,[`${a}`]:e,processIds:e.id?l.filter((t=>t!==e.id)):l}),await g(a,e),null==r||r(!0)}}catch(e){s({error:Gc(e),isSaving:!1,isLoading:!1})}},y=async e=>{try{await t.connectivity.postSlackCode(e)}catch{}s({error:void 0,isSaving:!1})},f=async()=>{const n=e.connectivity.slackChannels;try{s({slackChannels:j({},n,{isLoadingScope:!0})});const{clientId:e}=await t.connectivity.getSlackScope();s({slackChannels:{error:void 0,clientId:e,isLoadingScope:!1,isLoading:!1}})}catch{s({slackChannels:{error:void 0,isLoadingScope:!1,isLoading:!1}})}},S=async n=>{const{callback:a,webhookId:o}=n,i=e.connectivity.processIds;try{s({isSaving:!0}),await t.connectivity.deleteWebhooksConfiguration(o)}catch(e){null==a||a(null,Gc(e))}const r=await c("webhook");r&&s({error:void 0,isSaving:!1,webhook:r,processIds:r.id?i.filter((e=>e!==r.id)):i}),null==a||a(!0)},h=async e=>{try{s({isTesting:!0});const{statusCode:n,body:a}=await t.connectivity.postWebhookTest(e);if([201,200].includes(n)){const e=JSON.stringify(a,null,2);s({isTesting:!1,testResult:{status:"success",message:e}})}else s({isTesting:!1,testResult:{status:"failed"}})}catch(e){s({isTesting:!1,testResult:{status:"failed",message:Gc(e)}})}},v=async e=>{try{const{statusCode:n}=await t.connectivity.postWebhookRetry(e);r({[e]:{isProcess:!1,success:202===n}})}catch(t){r({[e]:{isProcess:!1,success:!1}})}},m=async n=>{const{id:a,limit:o,offset:i}=n,r=e.connectivity.webhookLogs;try{s({webhookLogs:j({},r,{isLoading:!0})});const e=await t.connectivity.getWebhookLog(a,i,o);s({error:void 0,webhookLogs:j({isLoading:!1},e)})}catch(e){s({error:void 0,webhookLogs:{isLoading:!1}})}};return{setConnectivityState:s,initData:l,resetConnectivityState:l,loadSlackActions:u,loadSlackChannels:u,loadDataAction:d,loadConnectivityChannels:d,postDataAction:p,postChannelData:p,postCodeAction:y,postSlackCode:y,loadScope:f,loadSlackPermissions:f,deleteWebhookConfigAction:S,deleteWebhookConfig:S,postWebhookTestAction:h,postWebhookTest:h,postWebhookRetryAction:v,postWebhookRetry:v,loadWebhookLogsAction:m,loadWebhookLogs:m,cleanWebhookTestData:()=>{s({testResult:void 0})},cleanWebhookLogsData:async()=>{s({webhookLogs:void 0})},cleanWebhookTestMessage:async e=>{var t;s({testResult:{status:null==(t=e.testResult)?void 0:t.status,message:void 0}})},cleanError:async()=>{s({error:void 0})},cleanSlackData:async()=>{s({slackChannels:{isLoading:!1}})}}};let wy;!function(e){e.UNKNWON="unknown",e.CARD="card"}(wy||(wy={}));const Ty={loading:!1,error:null,fetching:!0,config:null},Ey=e=>Mc(Ty,e);let Iy,ky,Oy;!function(e){e.STRIPE="Stripe"}(Iy||(Iy={})),function(e){e.ACTIVE="ACTIVE",e.CANCELED="CANCELED",e.INCOMPLETE="INCOMPLETE",e.EXPIRED="EXPIRED",e.TRIALING="TRIALING"}(ky||(ky={})),function(e){e.AT_PERIOD_END="atPeriodEnd"}(Oy||(Oy={}));const _y=(e,t,n)=>{const a=t=>{Object.assign(e.subscriptions.config,t)},o=t=>{Object.assign(e.subscriptions.config,{error:t,loading:!1,fetching:!1})};return{setPaymentConfigState:a,resetPaymentConfigState:()=>{e.subscriptions.config=Xl(Ty)},loadPaymentConfiguration:async()=>{a({loading:!0});try{var e;(null!=(e=await t.subscriptions.getPaymentProviders())?e:[]).find((e=>"1"===e.status&&e.providerType===Ur.Stripe))?await(async()=>{a({loading:!0});try{const e=await t.subscriptions.getStripePaymentProviderConfiguration(),n={paymentProvider:Iy.STRIPE,apiKey:e.publishableKey};a({config:n}),a({loading:!1,fetching:!1})}catch(e){o(Gc(e))}})():o(Gc("Payment provider not configured"))}catch(e){o(Gc(e))}}}},Py={loading:!1,error:null,fetching:!0},Uy=e=>Mc(Py,e);function Ly({policy:e}){return{policy:Oy.AT_PERIOD_END}}function Dy(e){switch(e){case Or.ACTIVE:return ky.ACTIVE;case Or.INCOMPLETE:return ky.INCOMPLETE;case Or.CANCELED:return ky.CANCELED;case Or.EXPIRED:return ky.EXPIRED;case Or.TRIALING:return ky.TRIALING;default:return ky.EXPIRED}}const Ry=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.subscriptions.billing.information,t)},i=e=>{o({error:e,loading:!1,fetching:!1})},s=async(n,s)=>{o({loading:!0});try{var r,l;const i=await t.subscriptions.getSubscriptionSummaries(n),{currentPlanId:c,externallyManaged:u}=i;let d,g=null;u?d=await t.subscriptions.getSubscriptionPlan(c):([,d]=await Promise.all([a.loadSubscription(),t.subscriptions.getSubscriptionPlan(c)]),g=e.subscriptions.billing.subscription.subscription||null),o(j({loading:!1,fetching:!1,summary:i},g?{subscription:{id:g.id,externalId:g.externalId,startDate:g.startDate,currentPeriodStart:g.currentPeriodStart,currentPeriodEnd:g.currentPeriodEnd,status:s?ky.ACTIVE:Dy(g.status),cancellation:g.cancellation&&Ly(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(e){i(Gc(e))}};return{setBillingInformationState:o,resetBillingInformationState:()=>{e.subscriptions.billing.information=Xl(Py)},loadSummaries:s,loadBillingInformation:async t=>{var n,a;const o=null==(n=e.subscriptions.config.config)?void 0:n.paymentProvider,r=null==(a=e.auth.user)?void 0:a.tenantId;o&&r?await s(r,t):i(o?"Not authorized":"Internal feature failure")}}},Cy={loading:!1,error:null,fetching:!0,invoices:[],invoiceDownload:{loading:!1,error:null}},Ny=e=>Mc(Cy,e),My=(e,t,n)=>{const a=t=>{Object.assign(e.subscriptions.billing.invoices,t)},o=t=>{Object.assign(e.subscriptions.billing.invoices.invoiceDownload,t)},i=async()=>{a({loading:!0});try{const e=(await t.subscriptions.getSubscriptionInvoices()).map((e=>({id:e.id,externalId:e.externalId,subscriptionId:e.subscriptionId,paymentDate:new Date(Date.parse(e.paymentDate)),totalAmount:+((e.totalAmount||0)/100).toFixed(2),currency:e.currency||"usd",paid:e.paid||!1,receiptNumber:e.receiptNumber})));a({loading:!1,fetching:!1,invoices:e})}catch(t){e=Gc(t),a({error:e,loading:!1,fetching:!1})}var e},s=async e=>{o({loading:!0,error:null});try{await t.subscriptions.getSubscriptionInvoicePdf(e.invoiceId,e.filename),o({loading:!1,error:null})}catch(e){o({loading:!1,error:Gc(e,null)})}};return{setBillingInvoiceState:a,resetBillingInvoiceState:()=>{e.subscriptions.billing.invoices=Xl(Cy)},loadInvoices:i,loadBillingInvoices:i,downloadInvoice:s,downloadBillingInvoice:s}},Fy={loading:!1,error:null,fetching:!0},$y=e=>Mc(Fy,e),jy=(e,t,n)=>{const a=t=>{Object.assign(e.subscriptions.billing.paymentMethod,t)},o=e=>{a({loading:e})},i=e=>{a({error:e,loading:!1,fetching:!1})},s=async()=>{o(!0);try{const e=(await t.subscriptions.getPaymentMethods())[0];a({paymentMethod:e,loading:!1,fetching:!1})}catch(e){i(Gc(e))}};return{setBillingPaymentMethodState:a,resetBillingPaymentMethodState:()=>{e.subscriptions.billing.paymentMethod=Xl(Fy)},loadPaymentMethod:s,submitPaymentMethod:async()=>{o(!0)},submitPaymentMethodError:async e=>{i(e)},submitPaymentMethodSuccess:async()=>await s(),updatePaymentMethodBillingDetails:async e=>{o(!0);const{id:n,email:a,address:r,callback:l}=e;try{await t.subscriptions.updatePaymentMethodBillingDetails(n,j({email:a},r)),await s(),null==l||l(!0)}catch(e){i(Gc(e)),null==l||l(!1,e)}finally{o(!1)}}}},Gy={loading:!1,error:null,fetching:!0,cancellation:{loading:!1,error:null},renewal:{loading:!1,error:null}},xy=e=>Mc(Gy,e),Vy=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.subscriptions.billing.subscription,t)},i=e=>{o({error:e,loading:!1,fetching:!1})},s=t=>{Object.assign(e.subscriptions.billing.subscription.cancellation,{loading:t})},r=t=>{Object.assign(e.subscriptions.billing.subscription.cancellation,{error:t})},l=t=>{Object.assign(e.subscriptions.billing.subscription.renewal,{loading:t})},c=t=>{Object.assign(e.subscriptions.billing.subscription.renewal,{error:t})},u=async()=>{o({loading:!0});try{const[e]=await t.subscriptions.getManagedSubscriptions();o({subscription:e,fetching:!1,loading:!1,error:null})}catch(e){i(Gc(e))}};return{setBillingSubscriptionState:o,resetBillingSubscriptionState:()=>{e.subscriptions.billing.subscription=Xl(Gy)},setCancellationLoading:s,setCancellationError:r,setRenewalLoading:l,setRenewalError:c,loadSubscription:u,loadSubscriptionTenant:async()=>{var t;const n=null==(t=e.auth.user)?void 0:t.tenantId;n?await a.loadSummaries(n):i("TenantId is not defined")},cancelSubscription:async()=>{const{subscription:n}=e.subscriptions.billing.subscription;if(!n)return void r("Subscription not found.");if(null!=n&&n.externallyManaged)return void r("Billing is externally managed.");const{id:a,cancellation:o,status:i}=n||{};if(!o&&i===Or.ACTIVE)try{s(!0),await t.subscriptions.cancelManagedSubscription(a),await u(),s(!1)}catch(e){r(Gc(e))}},renewSubscription:async()=>{const{subscription:n}=e.subscriptions.billing.subscription;if(!n)return void c("Subscription not found.");if(null!=n&&n.externallyManaged)return void c("Billing is externally managed");const{id:a,cancellation:o}=n||{};if((null==o?void 0:o.policy)===Pr.AT_PERIOD_END)try{l(!0),await t.subscriptions.renewManagedSubscription(a),await u(),l(!1)}catch(e){c(Gc(e))}}}},By=e=>Mc({information:Uy(null==e?void 0:e.information),invoices:Ny(null==e?void 0:e.invoices),paymentMethod:$y(null==e?void 0:e.paymentMethod),subscription:xy(null==e?void 0:e.subscription)}),Wy={loading:!1,error:null,fetching:!0,plans:[]},zy=e=>Mc(Wy,e),Ky=(e,t,n)=>{const a=t=>{Object.assign(e.subscriptions.plans,t)};return{setPlansState:a,resetPlansState:()=>{e.subscriptions.plans=Xl(Wy)},loadPlans:async()=>{a({loading:!0});try{const e=(await t.subscriptions.getSubscriptionPlans()).map((e=>{var t,n;return{id:e.id,name:e.name,description:e.description,price:(null==(t=e.price)?void 0:t.amount)||0,currency:(null==(n=e.price)?void 0:n.currency)||"usd",recurringInterval:"month",slug:e.slug}}));a({fetching:!1,loading:!1,plans:e})}catch(t){e=Gc(t),a({loading:!1,fetching:!1,error:e})}var e}}},Hy={fetching:!0,loading:!1,error:null,confirmed:!1},qy=e=>Mc(Hy,e),Jy=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.subscriptions.checkout,t)};return{setCheckoutState:o,resetCheckoutState:()=>{e.subscriptions.checkout=Xl(Hy)},loadCheckout:()=>{o({fetching:!1,loading:!1,error:null,confirmed:!1})},resetCheckout:()=>{o({loading:!1,error:null,confirmed:!1})},submitCheckout:()=>{o({loading:!0,error:null})},confirmCheckout:async n=>{const{paymentMethodId:i,planId:s}=n,r=e.subscriptions.billing.subscription.subscription,l=e.subscriptions.billing.information.summary,c=(null==r?void 0:r.status)===Or.TRIALING,u=!(null==l||!l.paymentMethodId);if(r){if(o({loading:!0,error:null}),c&&u)return o({loading:!1,error:null,confirmed:!0}),void a.setBillingSubscriptionState({subscription:j({},r,{status:Or.ACTIVE})});try{await t.subscriptions.updateManagedSubscription(r.id,{paymentMethodId:i,planId:s}),await Promise.all([a.loadBillingInformation(),a.loadPaymentMethod(),a.loadInvoices()]),o({loading:!1,error:null,confirmed:!0})}catch(e){o({loading:!1,error:Gc(e)})}}else o({loading:!1,error:"Subscription not found"})},errorCheckout:e=>{o({loading:!1,error:e})}}},Yy={loading:!1,error:null,cardSetupIntentSecret:null},Xy=e=>Mc(Yy,e),Qy=(e,t,n)=>{const a=t=>{Object.assign(e.subscriptions.stripe,t)};return{createCardSetupIntentSecret:async n=>{a({loading:!0,error:null,cardSetupIntentSecret:null});try{const e={};n&&(e.paymentMethodId=n);const{setupIntentSecret:o}=await t.subscriptions.createStripePaymentMethodSetupIntentSecret(e);a({cardSetupIntentSecret:o,loading:!1})}catch(t){o=Gc(t),Object.assign(e.subscriptions.stripe,{error:o,loading:!1,fetching:!1})}var o}}},Zy={loading:!1,fetching:!0,vendorPublicConfig:null},ef=e=>Mc(Zy,e),tf=(e,t,n)=>{const a=t=>{Object.assign(e.subscriptions.vendorPublicConfig,t)},o=t=>{Object.assign(e.subscriptions.vendorPublicConfig,{error:t,loading:!1,fetching:!1})},i=t=>{Object.assign(e.subscriptions.vendorPublicConfig,{error:null,loading:t})};return{setVendorPublicConfigState:a,resetVendorPublicConfigState:()=>{e.subscriptions.vendorPublicConfig=Xl(Zy)},setVendorPublicConfigError:o,setVendorPublicConfigLoading:i,loadVendorPublicConfiguration:async()=>{i(!0);try{const e=await t.subscriptions.getVendorPublicConfigurations();a({fetching:!1,loading:!1,vendorPublicConfig:e})}catch(e){o(Gc(e))}}}},nf=e=>Mc({config:Ey(null==e?void 0:e.config),billing:By(null==e?void 0:e.billing),plans:zy(null==e?void 0:e.plans),checkout:qy(null==e?void 0:e.checkout),stripe:Xy(null==e?void 0:e.stripe),vendorPublicConfig:ef(null==e?void 0:e.vendorPublicConfig)}),af=(e,t,n)=>{const a=_y(e,t),[o,i]=((e,t,n)=>{const a=Ry(e,t,n),o=jy(e,t),i=My(e,t),s=Vy(e,t,n);return[j({},a,o,i,s),{information:a,invoices:i,paymentMethod:o,subscription:s}]})(e,t,n),s=Ky(e,t),r=Jy(e,t,n),l=Qy(e,t),c=tf(e,t);return[j({},a,o,s,r,l,c),{config:a,billing:i,plans:s,checkout:r,stripe:l,vendorPublicConfig:c}]},of={loading:!1},sf=e=>Mc(of,e),rf=(e,t,n)=>{const a=t=>{Object.assign(e.vendor,t)},o=async()=>{a({loading:!0});try{var e;const n=await t.vendor.getVendorPublicInfo();n.whiteLabelMode=null!=(e=n.whiteLabelMode)&&e,a(j({},n,{loading:!1}))}catch(e){a({loading:!1}),console.error("failed to getVendorPublicInfo - ",e)}};return{setVendorState:a,resetVendorState:()=>{e.vendor=Xl(of)},loadVendorPublicInfo:o,loadVendorPublicConfiguration:o}},lf={loading:!0,pageOffset:0,pageSize:20,logs:[],sort:[],filter:[],totalPages:0,isDownloadingCsv:!1},cf=e=>Mc(lf,e),uf=(e,t,n)=>{const a=n,o=t=>{Object.assign(e.auditLogs.auditLogsState,t)};return{setAuditLogsState:o,resetAuditLogsState:()=>{e.auditLogs.auditLogsState=Xl(lf)},exportAuditsCsv:async()=>{const n=e.auditLogs.auditLogsState,{columns:a}=e.auditLogs.auditsMetadataState;try{const e=n.filter,i=n.sort.reduce(((e,t)=>j({},e,{sortBy:t.id,sortDirection:t.desc?"desc":"asc"})),{}),s=e.reduce(((e,t)=>j({},e,{[t.id]:t.value})),{});o({isDownloadingCsv:!0});const r="audits.csv";await t.audits.exportAudits(j({endpoint:"csv/v2",headerProps:a,offset:0,outputFileName:r},i,s))}catch(e){console.error("failed to export audits - ",e)}o({isDownloadingCsv:!1})},loadAuditLogs:async n=>{o({loading:!(null!=n&&n.silentLoading),error:null});const i=e.auditLogs.auditLogsState,{columns:s}=e.auditLogs.auditsMetadataState;try{var r,l,c,u,d;const e=null!=(r=n.pageSize)?r:i.pageSize,g=null!=(l=n.pageOffset)?l:i.pageOffset,p=null!=(c=n.filter)?c:i.filter,y=null!=(u=n.sort)?u:i.sort;o({pageSize:e,pageOffset:g,filter:p,sort:y});const f=y.reduce(((e,t)=>j({},e,{sortBy:t.id,sortDirection:t.desc?"desc":"asc"})),{}),S=p.reduce(((e,t)=>j({},e,{[t.id]:t.value})),{});s||await a.loadAuditsMetadata();const{data:h,total:v}=await t.audits.getAudits(j({offset:g,count:e},f,S));o({loading:!1,logs:null!=h?h:[],totalPages:+Math.ceil(v/e)}),null==n||null==(d=n.callback)||d.call(n,!0)}catch(e){var g;o({loading:!1,error:Gc(e)}),null==n||null==(g=n.callback)||g.call(n,null,e)}}}},df={loading:!0},gf=e=>Mc(df,e),pf=(e,t,n)=>{const a=t=>{Object.assign(e.auditLogs.auditsMetadataState,t)};return{setAuditsMetadataState:a,resetAuditsMetadataState:()=>{e.auditLogs.auditsMetadataState=Xl(df)},loadAuditsMetadata:async()=>{a({loading:!0,error:null});try{const{properties:e}=await t.metadata.getAuditsMetadata();a({columns:e,loading:!1})}catch(e){a({error:e,loading:!1})}}}},yf=e=>({auditLogsState:cf(null==e?void 0:e.auditLogsState),auditsMetadataState:gf(null==e?void 0:e.auditsMetadataState)}),ff=(e,t,n)=>j({},uf(e,t,n),pf(e,t));var Sf=n(262),hf=n.n(Sf);const vf={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},mf=(e,t)=>Object.keys(e).reduce(((n,a)=>t.includes(a)?j({},n,{[a]:e[a]}):j({},n,{[a]:()=>{console.debug(`Action ${String(a)} was called`)}})),{}),bf={clientId:"CLIENT_ID_16806d3d-8fc3-4450-be97-abdaf66b723e",secret:"SECRET_16806d3d-8fc3-4450-be97-abdaf66b723e",createdAt:"createdAt",description:"Demo API Token (preview only)"},Af=j({},bf,{roleIds:[],tenantId:"my-tenant-id",createdByUserId:"createdByUserId"}),wf=[{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"}],Tf={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},Ef=j({},Tf,{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}),If={loading:!1,error:void 0,saving:!0,profile:Tf},kf={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"},Of={allowSignups:!0,allowNotVerifiedUsersLogin:!1,apiTokensEnabled:!0,forcePermissions:!1,authStrategy:rn.EmailAndPassword,machineToMachineAuthStrategy:ln.ClientCredentials},_f={id:"id",enforceMFAType:"DontForce",createdAt:new Date,updatedAt:new Date},Pf={id:"id",enabled:!0,maxAttempts:1,createdAt:new Date,updatedAt:new Date},Uf={id:"id",enabled:!0,historySize:1,createdAt:new Date,updatedAt:new Date},Lf={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},Df={id:"id",createdAt:"createdAt",updatedAt:"updatedAt",properties:[],vendorId:"vendorId",entityName:"saml",isActive:!0,configuration:{acsUrl:"acsUrl",spEntityId:"spEntityId"}},Rf=[{id:"id",description:"description",key:"key",name:"name",permissions:[],permissionLevel:1}],Cf={firstLoad:!1,loading:!1,error:void 0,saving:!1,samlConfiguration:Lf,roles:Rf,authorizationRoles:[],errors:{},loaders:{},ssoConfigurations:[]},Nf=[{description:"string",fePermission:!0,id:"id",key:"key",name:"name",roleIds:[],createdAt:new Date,updatedAt:new Date,categoryId:"categoryId"}],Mf={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:[wf[0]],groups:[{id:"id2",name:"Developers",color:"#03A9F4",roles:[wf[0]],managedBy:jl.FRONTEGG}]},Ff={id:Mf.id,email:Mf.email,name:Mf.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:[wf[1]],tenantIds:[],metadata:"",sub:"",tenants:[]},$f={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:[wf[1]],groups:[{id:"id1",name:"Designers",color:"#E1F5E2",roles:[wf[0]],managedBy:jl.FRONTEGG}]},jf={id:$f.id,email:$f.email,name:$f.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:[wf[1]],tenantIds:[],metadata:"",sub:"",tenants:[]},Gf={metadata:"",mfaEnrolled:!1,provider:"",sub:"",tenantIds:[],tenants:[],verified:!1,id:"id",email:"email",name:"name",tenantId:"tenantId",createdAt:new Date},xf=[$f,Mf],Vf=[jf,Ff],Bf=[Gf],Wf=[{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}],zf=[{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"}],Kf={isActive:!0,strategy:pn.ALLOW},Hf=[{updatedAt:new Date,createdAt:new Date,id:"1",ip:"255.255.255.255",isActive:!0,strategy:pn.ALLOW,description:"My IP"},{updatedAt:new Date,createdAt:new Date,id:"2",ip:"255.255.255.254",isActive:!0,strategy:pn.ALLOW,description:"IP 2"},{updatedAt:new Date,createdAt:new Date,id:"3",ip:"255.255.255.253",isActive:!0,strategy:pn.BLOCK,description:"IP 3"},{updatedAt:new Date,createdAt:new Date,id:"4",ip:"255.255.255.253",isActive:!0,strategy:pn.BLOCK,description:"IP 4"}],qf=e=>{const t=[];return Array.from({length:e}).forEach(((e,n)=>{t.push(j({},$f,{name:"Demo User",id:`id${n}`,profilePictureUrl:null,createdAt:new Date}))})),t},Jf=e=>({id:"b43b2c4b-e056-4eec-8c55-d200a475bbc0"+e,key:e,name:e,description:null,isDefault:!0,createdAt:new Date,updatedAt:new Date,permissions:[],tenantId:"tenantId",vendorId:"vendorId"}),Yf=[{id:"id1",name:"Designers",color:"#E1F5E2",description:"The whole design team",users:qf(6),roles:[Jf("Editor")],metadata:'{"lastTermsCheck":"2022-08-16T10:31:11.270Z"}',managedBy:jl.FRONTEGG},{id:"id2",name:"Developers",color:"#03A9F4",description:"All frontend and backend developers",users:qf(44),roles:[Jf("Editor")],managedBy:jl.FRONTEGG},{id:"id3",name:"Product",color:"#E1583E",description:"PMs and team leads",users:qf(8),roles:[Jf("Viewer")],managedBy:jl.FRONTEGG},{id:"id4",name:"Management",color:"#9AE0FF",description:"Executives",users:qf(5),roles:[Jf("Admin")],managedBy:jl.FRONTEGG},{id:"id5",name:"Sales",color:"#ED8E7C",users:qf(21),description:"BDR, AE, and inside sales",roles:[Jf("Viewer")],managedBy:jl.FRONTEGG},{id:"id6",name:"Support",color:"#A79D7B",users:qf(23),description:"Dev success and customer success",roles:[Jf("Admin")],managedBy:jl.FRONTEGG},{id:"id7",name:"Marketing",color:"#2CA744",users:qf(10),description:"The marketing department",roles:[Jf("Viewer")],managedBy:jl.FRONTEGG},{id:"id8",name:"HR",color:"#EAE1C2",users:qf(4),description:"Human resources",roles:[Jf("Viewer")],managedBy:jl.FRONTEGG},{id:"id9",name:"Finance",color:"#5587C0",users:qf(3),roles:[Jf("Viewer")],managedBy:jl.FRONTEGG},{id:"id10",name:"Operations",color:"#B1CAE7",users:qf(8),roles:[Jf("Editor")],managedBy:jl.FRONTEGG},{id:"id11",name:"Legal",color:"#2CA744",users:qf(4),roles:[Jf("Viewer")],managedBy:jl.FRONTEGG}],Xf={scoring:{score:79},recommendations:{items:[{code:Bl.FORCE_MFA,severity:Kl.WARNING,category:Hl.MFA},{code:Bl.ENABLE_FORCE_RELOGIN,severity:Kl.WARNING,category:Hl.SESSIONS}]}},Qf={insights:{items:[{category:Hl.MFA,code:Wl.PARTIALLY_FORCED_MFA,metadata:{totalUsers:2,mfa:{enrolledUsersCount:1}}},{category:Hl.SESSIONS,code:Wl.PARTIAL_SESSION_SETTINGS,metadata:{totalUsers:2,sessions:{idleTimeoutRecommendation:1800}}},{category:Hl.PASSWORD,code:Wl.IMPROVE_PASSWORD_HISTORY_POLICY,metadata:{password:{userLockoutRecommendation:5,historyRecommendations:5}}},{category:Hl.DOMAIN,code:Wl.NO_IP_RESTRICTIONS,metadata:{restrictions:{ipsCount:1,domainsCount:1}}}]}},Zf={users:Vf,totalUsersItems:2,totalUsersPages:1,usersPageOffset:0},eS={users:[Vf[0]],totalUsersItems:1,totalUsersPages:1,usersPageOffset:0,queryParams:{_maxInactiveSeconds:7776e3}},tS={users:[Vf[1]],totalUsersItems:1,totalUsersPages:1,usersPageOffset:0};Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.ASSIGNABLE,new Date,new Date,Pl.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 nS,aS=new Uint8Array(16);function oS(){if(!nS&&!(nS="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 nS(aS)}const iS=/^(?:[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,sS=function(e){return"string"==typeof e&&iS.test(e)};for(var rS=[],lS=0;lS<256;++lS)rS.push((lS+256).toString(16).substr(1));const cS=function(e,t,n){var a=(e=e||{}).random||(e.rng||oS)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=a[o];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(rS[e[t+0]]+rS[e[t+1]]+rS[e[t+2]]+rS[e[t+3]]+"-"+rS[e[t+4]]+rS[e[t+5]]+"-"+rS[e[t+6]]+rS[e[t+7]]+"-"+rS[e[t+8]]+rS[e[t+9]]+"-"+rS[e[t+10]]+rS[e[t+11]]+rS[e[t+12]]+rS[e[t+13]]+rS[e[t+14]]+rS[e[t+15]]).toLowerCase();if(!sS(n))throw TypeError("Stringified UUID is invalid");return n}(a)},uS=["callback"],dS=["callback"],gS=["callback","profilePictureUrl"],pS=["callback"],yS=["callback"],fS=["callback"],SS=["callback"],hS=["callback"],vS=["callback"],mS=["callback"],bS=["callback"],AS=["callback","samlVendor"],wS=["callback"],TS=["callback"],ES=["callback","profileImage"],IS=["callback"],kS=["callback"],OS=["callback"],_S=["callback"],PS=["callback"],US=["callback"],LS=["callback"],DS=["callback"],RS=e=>"createdAt"!==e.id,CS={total:20,data:Array.from(Array(5).keys()).map((e=>j({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-e}:40.201`})))},NS={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}]},MS=(e,t,n)=>{const a=((e,t,n)=>{const a=uf(e,t,n),o=mf(a,["setAuditLogsState","resetAuditLogsState"]);return o.loadAuditLogs=async t=>{o.setAuditLogsState({loading:!t.silentLoading,error:null});const a=e.auditLogs.auditLogsState,{columns:i}=e.auditLogs.auditsMetadataState;try{var s,r,l,c,u;const e=null!=(s=t.pageSize)?s:a.pageSize,d=null!=(r=t.pageOffset)?r:a.pageOffset,g=null!=(l=t.filter)?l:a.filter,p=null!=(c=t.sort)?c:a.sort;o.setAuditLogsState({pageSize:e,pageOffset:d,filter:g,sort:p}),i||await n.loadAuditsMetadata();const{data:y,total:f}=((e,t)=>{const{data:n}=CS;let a=n.filter((e=>t=>e.filter(RS).every((e=>t[e.id].includes(e.value))))(e));if(t.length){const{id:e,desc:n=!1}=t[0];a=a.sort(((e,t)=>(n,a)=>n[e]>a[e]?t?-1:1:a[e]>n[e]?t?1:-1:0)(e,n))}return{data:a,total:a.length}})(g,p);o.setAuditLogsState({loading:!1,logs:null!=y?y:[],totalPages:+Math.ceil(f/e)}),null==t||null==(u=t.callback)||u.call(t,!0)}catch(e){var d;o.setAuditLogsState({loading:!1,error:Gc(e)}),null==t||null==(d=t.callback)||d.call(t,null,e)}},o})(e,t,n),o=((e,t,n)=>{const a=pf(e,t),o=mf(a,["setAuditsMetadataState","resetAuditsMetadataState"]);return o.loadAuditsMetadata=async()=>{o.setAuditsMetadataState({loading:!0,error:null});try{const{properties:e}=NS;o.setAuditsMetadataState({columns:e,loading:!1})}catch(e){o.setAuditsMetadataState({error:e,loading:!1})}},o})(e,t);return j({},a,o)},FS={id:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",externalId:"sub_1JbhYVEwsu4qiqnnfMhYAdY6",startDate:"2021-09-20T08:08:51.000Z",status:Or.ACTIVE,externallyManaged:!1,cancellation:null,currentPeriodStart:"2021-09-20T08:08:51.000Z",currentPeriodEnd:"2021-10-20T08:08:51.000Z",plan:{slug:"test"}},$S=[{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"}],jS=[{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:""}],GS=[{id:"id",externalId:"externalId",type:_r.CARD,isDefault:!0,last4:"4242",expMonth:11,expYear:25,brand:"visa",billingDetails:{name:"Dummy",email:"dummy@email.com"}}],xS={allowPlanDowngrade:!0,allowPlanCancellation:!0},VS=(e,t,n)=>{const a=((e,t,n)=>{const a=_y(e,t),o=mf(a,["setPaymentConfigState","resetPaymentConfigState"]);return o.loadPaymentConfiguration=async()=>{o.setPaymentConfigState({loading:!0}),await Ql(500),o.setPaymentConfigState({loading:!1,fetching:!1,config:{paymentProvider:Iy.STRIPE,apiKey:""}})},o})(e,t),[o,i]=((e,t,n)=>{const a=((e,t,n)=>{const a=Ry(e,t,n),o=mf(a,["setBillingInformationState","resetBillingInformationState"]);return o.loadBillingInformation=async()=>{var e,t;o.setBillingInformationState({loading:!0}),await Ql(500),o.setBillingInformationState({loading:!1,fetching:!1,summary:{subscriptionId:FS.id,paymentMethodId:"mockPaymentMethodId",tenantConfigurationId:"mockTenantConfigurationId",providerType:Ur.Stripe,externallyManaged:!1,currentPlanId:$S[0].id,defaultPlanId:$S[0].id},plan:j({},$S[0],{price:null==(e=$S[0].price)?void 0:e.amount,currency:null==(t=$S[0].price)?void 0:t.currency,recurringInterval:"month"})})},o})(e,t,n),o=((e,t,n)=>{const a=jy(e,t),o=mf(a,["setBillingPaymentMethodState","resetBillingPaymentMethodState"]);return o.loadPaymentMethod=async()=>{o.setBillingPaymentMethodState({loading:!0}),await Ql(500),o.setBillingPaymentMethodState({paymentMethod:GS[0],loading:!1,fetching:!1})},o})(e,t),i=((e,t,n)=>{const a=My(e,t),o=mf(a,["setBillingInvoiceState","resetBillingInvoiceState"]);return o.loadBillingInvoices=async()=>{o.setBillingInvoiceState({loading:!0}),await Ql(500),o.setBillingInvoiceState({loading:!1,fetching:!1,invoices:jS.map((e=>j({},e,{selectedPlan:"Premium",paymentDate:new Date(Date.parse(e.paymentDate)),totalAmount:+((e.totalAmount||0)/100).toFixed(2)})))})},o.loadInvoices=o.loadBillingInvoices,o})(e,t),s=((e,t,n)=>{const a=Vy(e,t,n),o=mf(a,["setBillingSubscriptionState","resetBillingSubscriptionState","setCancellationLoading","setCancellationError","setRenewalLoading","setRenewalError"]);return o.loadSubscription=async()=>{o.setBillingSubscriptionState({loading:!0}),await Ql(500),o.setBillingSubscriptionState({subscription:FS,fetching:!1,loading:!1,error:null})},o})(e,t,n);return[j({},a,o,i,s),{information:a,invoices:i,paymentMethod:o,subscription:s}]})(e,t,n),s=((e,t,n)=>{const a=Ky(e,t),o=mf(a,["setPlansState","resetPlansState"]);return o.loadPlans=async()=>{o.setPlansState({loading:!0}),await Ql(500),o.setPlansState({fetching:!1,loading:!1,plans:$S.map((e=>{var t,n;return j({},e,{price:(null==(t=e.price)?void 0:t.amount)||0,currency:(null==(n=e.price)?void 0:n.currency)||"usd",recurringInterval:"month"})}))})},o})(e,t),r=((e,t,n)=>{const a=Jy(e,t,n);return mf(a,["setCheckoutState","resetCheckoutState","errorCheckout","resetCheckout"])})(e,t,n),l=((e,t,n)=>{const a=Qy(e,t);return mf(a,[])})(e,t),c=((e,t,n)=>{const a=tf(e,t),o=mf(a,["setVendorPublicConfigState","resetVendorPublicConfigState","setVendorPublicConfigError","setVendorPublicConfigLoading"]);return o.loadVendorPublicConfiguration=async()=>{o.setVendorPublicConfigLoading(!0),await Ql(),o.setVendorPublicConfigState({fetching:!1,loading:!1,vendorPublicConfig:xS})},o})(e,t);return[j({},a,o,s,r,l,c),{config:a,billing:i,plans:s,checkout:r,stripe:l,vendorPublicConfig:c}]},BS=(e,t,n)=>{const{authActions:a,authStateActions:o}=((e,t,n)=>{const a=((e,t,n)=>{const a=xc(e,t);return mf(a,["setAcceptInvitationState","resetAcceptInvitationState"])})(e,t),o=((e,t,n)=>{const a=Wc(e,t),o=mf(a,["setAccountSettingsState","resetAccountSettingsState"]);return o.saveAccountSettings=async t=>{var n;o.setAccountSettingsState({loading:!0}),await Ql();const a=e.auth.accountSettingsState,{address:i,timezone:s,dateFormat:r,timeFormat:l,currency:c,logo:u}=a,d=j({address:i,timezone:s,dateFormat:r,timeFormat:l,currency:c,logo:u},t);o.setAccountSettingsState(j({},d,{loading:!1})),null==(n=t.callback)||n.call(t,d)},o.loadAccountSettings=async e=>{o.setAccountSettingsState({loading:!(null!=e&&e.silentLoading),error:null}),await Ql(),o.setAccountSettingsState(j({address:"Tel-aviv",timezone:"Asia/Jerusalem",dateFormat:"DD/MM/YYYY",timeFormat:"HH:mm",currency:"USD",loading:!1},e))},o})(e,t),i=((e,t,n)=>{const a=Pu(e,t,n);return mf(a,["setActivateState","resetActivateState","setActivateStrategyState"])})(e,t,n),s=((e,t,n)=>{const a=hg(e,t,n);return mf(a,["setAllAccountsLoader","setAllAccountsError","setAllAccountsState","setSelectedAccountState","resetAllAccountsState","clearSelectedAccount"])})(e,t,n),r=bg(e),l=((e,t,n)=>{const a=Du(e,t),o=mf(a,["setApiTokensState","resetApiTokensState","setApiTokensLoader","setApiTokensError"]);return o.addTenantApiToken=async t=>{const{description:n,roleIds:a,callback:i}=t;o.setApiTokensLoader({key:oc.ADD_API_TOKEN,value:!0});const{apiTokensDataTenant:s}=e.auth.apiTokensState,r=j({},Af,{description:n,roleIds:a,clientId:`CLIENT_ID_${cS()}`});o.setApiTokensState({showAddTokenDialog:!1}),await Ql(200),o.setApiTokensState({apiTokensDataTenant:[...s,r],successDialog:{open:!0,secret:r.secret,clientId:r.clientId}}),await Ql(200),o.setApiTokensLoader({key:oc.ADD_API_TOKEN,value:!1}),null==i||i(null)},o.deleteTenantApiToken=async e=>{o.setApiTokensLoader({key:oc.DELETE_API_TOKEN,value:!0}),await Ql(200);const t=[Af];o.setApiTokensState({apiTokensDataTenant:t.filter((t=>t.clientId!==e)),deleteTokenDialog:{open:!1,clientId:e}}),o.setApiTokensLoader({key:oc.DELETE_API_TOKEN,value:!1})},o.loadApiTokens=async e=>{var t;null!=e&&e.silentLoading||o.setApiTokensLoader({key:oc.LOAD_API_TOKENS,value:!0});const n=[bf],a=[Af];o.setApiTokensState({apiTokensDataUser:n,apiTokensDataTenant:a}),await Ql(200),o.setApiTokensLoader({key:oc.LOAD_API_TOKENS,value:!1}),null==e||null==(t=e.callback)||t.call(e,!0)},o.loadUserApiTokens=async e=>{var t;null!=e&&e.silentLoading||o.setApiTokensLoader({key:oc.LOAD_API_TOKENS,value:!0});const n=[bf];o.setApiTokensState({apiTokensDataUser:n}),await Ql(200),o.setApiTokensLoader({key:oc.LOAD_API_TOKENS,value:!1}),null==e||null==(t=e.callback)||t.call(e,!0)},o.loadTenantApiTokens=async e=>{var t;null!=e&&e.silentLoading||o.setApiTokensLoader({key:oc.LOAD_API_TOKENS,value:!0});const n=[Af];o.setApiTokensState({apiTokensDataTenant:n}),await Ql(200),o.setApiTokensLoader({key:oc.LOAD_API_TOKENS,value:!1}),null==e||null==(t=e.callback)||t.call(e,!0)},o})(e,t),c=((e,t,n)=>{const a=Mu(e,t,n);return mf(a,["setApplicationsState","resetApplicationsState"])})(e,t,n),u=((e,t,n)=>{const a=Gu(e,t,n),o=mf(a,["setCustomLoginState","resetCustomLoginState"]);return o.loadTenantMetadata=async()=>{o.setCustomLoginState({loading:!0}),await Ql(),o.setCustomLoginState({loading:!1})},o.updateTenantMetadata=async e=>{const{callback:t}=e;o.setCustomLoginState({loading:!0,error:null}),await Ql(),o.setCustomLoginState({loading:!1,error:null}),null==t||t(!0)},o})(e,t,n),d=((e,t,n)=>{const a=dy(e,t);return mf(a,["setEntitlements","handleFetchedEntitlements"])})(e,t),g=((e,t,n)=>{const a=Wu(e,t),o=mf(a,["setForgotPasswordState","resetForgotPasswordState"]);return o.loadPasswordConfig=async e=>{o.setForgotPasswordState({loading:!0});try{o.setForgotPasswordState({loading:!1,passwordConfig:{allowPassphrases:!0,maxLength:128,minLength:6,minPhraseLength:6,minOptionalTestsToPass:1}})}catch(e){o.setForgotPasswordState({loading:!1,error:Gc(e)})}},o})(e,t),p=((e,t,n)=>{const a=qu(e,t),o=mf(a,["setGroupsState","resetUsersGroupsState","setUsersGroupsLoader","setUsersGroupsError"]);return o.loadGroups=async()=>{const e=yc.GET_GROUPS;o.setUsersGroupsLoader({key:e,value:!0});const t=Yf;o.setGroupsState({groups:t}),o.setUsersGroupsLoader({key:e,value:!1})},o.createGroup=async t=>{var n;const a=yc.CREATE_GROUP,{groups:i}=e.auth.groupsState;o.setUsersGroupsLoader({key:a,value:!0}),await Ql(500),o.setGroupsState({groups:[j({},t,{id:`${t.name}ID`,managedBy:jl.FRONTEGG}),...null!=i?i:[]]}),null==t||null==(n=t.callback)||n.call(t,!0),o.setUsersGroupsLoader({key:a,value:!1})},o.updateGroup=async t=>{var n,a,i,s,r;const l=yc.UPDATE_GROUP,c=e.auth.groupsState;o.setUsersGroupsLoader({key:l,value:!0}),await Ql(500),o.setGroupsState({groups:null==c||null==(n=c.groups)?void 0:n.map((e=>{var n;return e.id===t.groupId?j({},t,{id:t.groupId,name:null!=(n=null==t?void 0:t.name)?n:"",managedBy:jl.FRONTEGG}):e})),selectedGroup:j({},null==c?void 0:c.selectedGroup,{name:null!=(a=null==t?void 0:t.name)?a:"",color:null!=(i=null==t?void 0:t.color)?i:"",description:null!=(s=null==t?void 0:t.description)?s:""})}),null==t||null==(r=t.callback)||r.call(t,!0),o.setUsersGroupsLoader({key:l,value:!1})},o.deleteGroup=async t=>{var n,a;const i=yc.DELETE_GROUP,s=e.auth.groupsState;o.setUsersGroupsLoader({key:i,value:!0}),await Ql(500),o.setGroupsState({groups:null==s||null==(n=s.groups)?void 0:n.filter((e=>e.id!==t.groupId))}),null==t||null==(a=t.callback)||a.call(t,!0),o.setUsersGroupsLoader({key:i,value:!1})},o.addRolesToGroup=async t=>{var n,a;const i=yc.ADD_ROLES_TO_GROUP,s=e.auth.groupsState;o.setUsersGroupsLoader({key:i,value:!0}),await Ql(500),o.setGroupsState({groups:null==s||null==(n=s.groups)?void 0:n.map((e=>{var n;return e.id===t.groupId?j({},e,{roles:[...null!=(n=null==e?void 0:e.roles)?n:[],...t.roleIds.map((e=>({id:e,name:e})))]}):e}))}),null==t||null==(a=t.callback)||a.call(t,!0),o.setUsersGroupsLoader({key:i,value:!1})},o.deleteRolesFromGroup=async t=>{var n,a;const i=yc.DELETE_ROLES_FROM_GROUP,s=e.auth.groupsState;o.setUsersGroupsLoader({key:i,value:!0}),await Ql(500),o.setGroupsState({groups:null==s||null==(n=s.groups)?void 0:n.map((e=>{var n;return e.id===t.groupId?j({},e,{roles:null==e||null==(n=e.roles)?void 0:n.filter((e=>!t.roleIds.includes(e.id)))}):e}))}),null==t||null==(a=t.callback)||a.call(t,!0),o.setUsersGroupsLoader({key:i,value:!1})},o.addUsersToGroup=async t=>{var n,a;const i=yc.ADD_USERS_TO_GROUP,s=e.auth.groupsState;o.setUsersGroupsLoader({key:i,value:!0}),await Ql(500),o.setGroupsState({groups:null==s||null==(n=s.groups)?void 0:n.map((e=>{var n;return e.id===t.groupId?j({},e,{users:[...null!=(n=null==e?void 0:e.users)?n:[],...t.userIds.map((e=>({id:e,name:e})))]}):e}))}),null==t||null==(a=t.callback)||a.call(t,!0),o.setUsersGroupsLoader({key:i,value:!1})},o.deleteUsersFromGroup=async t=>{var n,a;const i=yc.DELETE_USERS_FROM_GROUP,s=e.auth.groupsState;o.setUsersGroupsLoader({key:i,value:!0}),await Ql(500),o.setGroupsState({groups:null==s||null==(n=s.groups)?void 0:n.map((e=>{var n;return e.id===t.groupId?j({},e,{users:null==e||null==(n=e.users)?void 0:n.filter((e=>!t.userIds.includes(e.id)))}):e}))}),null==t||null==(a=t.callback)||a.call(t,!0),o.setUsersGroupsLoader({key:i,value:!1})},o.getGroupConfiguration=async()=>{const t=yc.GET_GROUP_CONFIGURATION,{groupsConfiguration:n}=e.auth.groupsState;o.setUsersGroupsLoader({key:t,value:!0}),n&&o.setGroupsState({groupsConfiguration:j({},n)}),o.setUsersGroupsLoader({key:t,value:!1})},o.updateGroupConfiguration=async t=>{const n=yc.UPDATE_GROUP_CONFIGURATION,{groupsConfiguration:a}=e.auth.groupsState;o.setUsersGroupsLoader({key:n,value:!0}),a&&o.setGroupsState({groupsConfiguration:j({},a,t)}),o.setUsersGroupsLoader({key:n,value:!1})},o})(e,t),y=Xu(e),f=((e,t,n)=>{const a=td(e,t,n);return mf(a,["setImpersonateState","resetImpersonateState"])})(e,t,n),S=((e,t,n)=>{const a=n,o=eg(e,t,a),i=mf(o,["setLoginState","resetLoginState","afterAuthNavigation"]);return i.requestAuthorize=async e=>{e&&a.setAuthState({isLoading:!0});const t=Ef;await a.loadTenants(),a.setAuthState({user:t,isAuthenticated:!0,isLoading:!1})},i.getUserIP=async e=>{const{callback:t}=e;try{const{ip:e}=Hf[0];await a.setAuthState({userIp:e}),null==t||t(!0,e)}catch(e){null==t||t(!1,e)}},i})(e,t,n),h=((e,t,n)=>{const a=n,o=cg(e,t,a),i=mf(o,["setMfaState","resetMfaState"]);return i.enrollMfa=async()=>{i.setMfaState({saving:!0}),i.setMfaState({saving:!1,error:void 0,qrCode:"test"})},i.verifyMfa=async t=>{const{callback:n}=t,{mfaDevices:o={webauthn:[],phones:[],authenticators:[],emails:[]}}=(oe(t,uS),e.auth.mfaState);i.setMfaState({saving:!0}),await Ql();const s={token:"token",recoveryCode:"recoveryCode"},r={step:Ac.recoveryCode,loading:!1,error:void 0,saving:!1,mfaDevices:j({},o,{authenticators:[{id:"authenticator-id"}]})};null!=s&&s.recoveryCode&&(r.recoveryCode=s.recoveryCode),i.setMfaState(r),a.setUser(j({},Ef,{mfaEnrolled:!0})),null==n||n(r.recoveryCode)},i.disableMfa=async t=>{var n;const{mfaDevices:o={webauthn:[],phones:[],authenticators:[],emails:[]}}=e.auth.mfaState;i.setMfaState({saving:!0}),await Ql(),i.setMfaState({saving:!1,error:void 0,mfaDevices:j({},o,{authenticators:[]})}),a.setUser(j({},Ef)),null==(n=t.callback)||n.call(t,!0)},i.verifyMfaAfterForce=async e=>{const{callback:t}=e,n=oe(e,dS);i.setMfaState({loading:!0}),await Ql();const o=j({},n,{recoveryCode:"recoveryCode"}),s={step:Ac.recoveryCode,loading:!1,error:void 0,saving:!1};null!=o&&o.recoveryCode&&(s.recoveryCode=o.recoveryCode),i.setMfaState(s),await Ql(),a.setUser(j({},Ef,{mfaEnrolled:!0})),null==t||t(s.recoveryCode)},i.preDisableMfaSms=async e=>{i.setMfaState({saving:!0});try{var t;i.setMfaState({saving:!1,error:void 0,otcToken:"otc-token",phoneNumber:"+972504589346"}),null==(t=e.callback)||t.call(e,!0)}catch(t){var n;i.setMfaState({saving:!1,error:Gc(t)}),null==(n=e.callback)||n.call(e,!1,t)}},i.disableMfaSms=async t=>{var n;const{mfaDevices:o={webauthn:[],phones:[],authenticators:[],emails:[]}}=e.auth.mfaState;i.setMfaState({saving:!0}),await Ql(),i.setMfaState({loading:!1,error:void 0,mfaDevices:j({},o,{phones:[]})}),a.setUser(j({},Ef)),null==(n=t.callback)||n.call(t,!0)},i.preEnrollMfaSms=async e=>{var t;i.setMfaState({saving:!0}),await Ql(),i.setMfaState({saving:!1,error:void 0,otcToken:"otc-token",phoneNumber:"+972504589346"}),null==(t=e.callback)||t.call(e,!0)},i.enrollMfaSms=async t=>{const{callback:n}=t,{mfaDevices:o={webauthn:[],phones:[],authenticators:[],emails:[]}}=e.auth.mfaState;i.setMfaState({saving:!0}),await Ql();const s={token:"token",recoveryCode:"recoveryCode"},r={step:Ac.recoveryCode,loading:!1,error:void 0,saving:!1,mfaDevices:j({},o,{phones:[{id:"phone-id",phoneNumber:"+972504589346"}]})};null!=s&&s.recoveryCode&&(r.recoveryCode=s.recoveryCode),i.setMfaState(r),a.setUser(j({},Ef,{mfaEnrolled:!0})),null==n||n(r.recoveryCode)},i})(e,t,n),v=((e,t,n)=>{const a=Tg(e,t,n);return mf(a,["setPasskeysState","resetPasskeysState"])})(e,t,n),m=((e,t,n)=>{const a=Og(e,t,n),o=mf(a,["setProfileState","resetProfileState"]);return o.loadProfile=async()=>{o.setProfileState({loading:!0}),await Ql(),n.setUser(j({},Ef,Tf)),o.setProfileState({loading:!1,profile:Tf})},o.saveProfile=async e=>{const{callback:t,profilePictureUrl:a}=e,i=oe(e,gS);o.setProfileState({saving:!0,error:null});const s=If;let r=s.profile.profilePictureUrl;a!==s.profile.profilePictureUrl&&a&&(a||"").match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/)&&(r=a);const l=j({},s.profile,i,{profilePictureUrl:r}),c=Ef;await Ql(),n.setUser(j({},c,l)),o.setProfileState({loading:!1,error:null,saving:!1,profile:l}),null==t||t(l)},o.changePassword=async e=>{var t;o.setProfileState({loading:!0}),await Ql(),o.setProfileState({loading:!1,error:void 0}),null==(t=e.callback)||t.call(e,!0)},o})(e,t,n),b=((e,t,n)=>{const a=Dg(e,t);return mf(a,["setProvisioningState","resetProvisioningState"])})(e,t),A=((e,t,n)=>{const a=$g(e,t,n);return mf(a,["setResetPhoneNumberState","resetResetPhoneNumberState"])})(e,t,n),w=((e,t,n)=>{const a=ep(e,t,n),o=mf(a,["setRestrictionsState","setIpRestrictionsState","setEmailDomainRestrictionsState"]);return o.loadIpRestrictions=async()=>{o.setIpRestrictionsState({loading:!0,error:null}),o.setIpRestrictionsState({data:{restrictions:Hf.filter((e=>e.strategy===Kf.strategy)),config:Kf},totalPages:1,pagination:{_filter:pn.ALLOW,_limit:50,_offset:0},loading:!1})},o.loadEmailDomainRestrictions=async()=>{o.setEmailDomainRestrictionsState({loading:!0,error:null}),o.setEmailDomainRestrictionsState({loading:!1,data:{restrictions:[{domain:"mock.com",id:"1",type:pn.ALLOW}],config:{active:!0,listType:pn.ALLOW,blockPublicDomains:!1}}})},o.saveIpRestriction=async t=>{var n,a,i;const{callback:s}=t,r=oe(t,pS);o.setIpRestrictionsState({saving:!0,error:null});const l=e.auth.restrictionsState.ipRestrictions,c=l.data.restrictions.filter((e=>e.ip!==r.ip));o.setIpRestrictionsState({data:{config:null!=(n=null==(a=l.data)?void 0:a.config)?n:{isActive:!1,strategy:pn.ALLOW},restrictions:[...c,j({},r,{createdAt:new Date,updatedAt:new Date,id:cS(),isActive:null==(i=r.isActive)||i,strategy:l.data.config.strategy})]},totalPages:1,pagination:{_filter:pn.ALLOW,_limit:50,_offset:0},saving:!1}),null==s||s(!0)},o.saveIpRestrictionsConfig=async t=>{var n,a,i;const{callback:s}=t,r=oe(t,yS),l=e.auth.restrictionsState.ipRestrictions;o.setIpRestrictionsState({saving:!0,error:null}),o.setIpRestrictionsState({data:{config:j({},null==(n=l.data)?void 0:n.config,r),restrictions:null!=(a=null==(i=l.data)?void 0:i.restrictions)?a:[]},pagination:{_filter:pn.ALLOW,_limit:50,_offset:0},totalPages:1,saving:!1}),o.setIpRestrictionsState({saving:!1,error:null}),null==s||s(!0)},o.deleteIpRestriction=async t=>{var n;const{callback:a,id:i}=t;o.setIpRestrictionsState({saving:!0,error:null});const s=e.auth.restrictionsState.ipRestrictions;o.setIpRestrictionsState({data:{config:(null==(n=s.data)?void 0:n.config)||{isActive:!1,strategy:pn.ALLOW},restrictions:s.data.restrictions.filter((e=>e.id!==i))},pagination:{_filter:pn.ALLOW,_limit:50,_offset:0},totalPages:1,saving:!1,error:null}),null==a||a(!0)},o.checkIfUserIpValid=async()=>{o.setIpRestrictionsState({loading:!0,error:null});try{const t=e.auth.restrictionsState.ipRestrictions,n=Hf[0].ip,a=!!t.data.restrictions.find((e=>e.isActive&&e.ip===n));o.setIpRestrictionsState({userIpValid:a,loading:!1})}catch(e){o.setIpRestrictionsState({error:Gc(e),loading:!1})}},o.saveEmailDomainRestriction=async t=>{var n,a;const{callback:i}=t,s=oe(t,fS),r=e.auth.restrictionsState.emailDomainRestrictions;o.setEmailDomainRestrictionsState({saving:!0,error:null}),await Ql(),null==i||i(!0),o.setEmailDomainRestrictionsState({data:{config:(null==(n=r.data)?void 0:n.config)||{active:!1,blockPublicDomains:!1,listType:s.type},restrictions:[...(null==(a=r.data)?void 0:a.restrictions)||[],j({},s,{id:Date.now().toString()})]},saving:!1})},o.saveEmailDomainRestrictionsConfig=async t=>{var n;const{callback:a}=t,i=oe(t,SS),s=e.auth.restrictionsState.emailDomainRestrictions;o.setEmailDomainRestrictionsState({saving:!0,error:null}),await Ql(),null==a||a(!0),o.setEmailDomainRestrictionsState({data:{config:{active:i.active,blockPublicDomains:i.blockPublicDomains||!1,listType:i.type||pn.ALLOW},restrictions:[...(null==(n=s.data)?void 0:n.restrictions)||[]]},saving:!1})},o.deleteEmailDomainRestriction=async t=>{var n,a;const{id:i}=t,s=e.auth.restrictionsState.emailDomainRestrictions;o.setEmailDomainRestrictionsState({saving:!0,error:null}),await Ql(),o.setEmailDomainRestrictionsState({data:{config:(null==(n=s.data)?void 0:n.config)||{active:!1,blockPublicDomains:!1,listType:pn.ALLOW},restrictions:((null==(a=s.data)?void 0:a.restrictions)||[]).filter((e=>e.id===i))},saving:!1})},o})(e,t,n),T=((e,t,n)=>{const a=Hg(e,t),o=mf(a,["setRolesState","setRolesStateError","setRolesStateLoader","resetRolesState"]);return o.loadRolesAndPermissions=async e=>{var t;const n=Ec.LOAD_ROLES;o.setRolesStateLoader({key:n,value:!(null!=(t=null==e?void 0:e.silentLoading)&&t)});try{o.setRolesState({roles:wf})}catch(e){o.setRolesStateError({key:n,value:Gc(e)})}finally{o.setRolesStateLoader({key:n,value:!1})}},o})(e,t),E=((e,t,n)=>{const a=op(e,t,n),o=mf(a,["setSecurityCenterState","setSecurityCenterStateError","setSecurityCenterStateLoader","resetSecurityCenterState"]);return o.loadRecommendations=async()=>{const e=Ic.RECOMMENDATIONS;o.setSecurityCenterStateLoader({key:e,value:!0}),await Ql(),o.setSecurityCenterState({recommendations:Xf.recommendations.items,score:Xf.scoring.score}),o.setSecurityCenterStateLoader({key:e,value:!1})},o.loadInsights=async()=>{const e=Ic.INSIGHTS;o.setSecurityCenterStateLoader({key:e,value:!0}),await Ql(),o.setSecurityCenterState({insights:Qf.insights.items}),o.setSecurityCenterStateLoader({key:e,value:!1})},o.loadBreachedPasswordUsers=async()=>{const e=Ic.BREACHED_PASSWORD_USERS_TABLE;o.setSecurityCenterStateLoader({key:e,value:!0}),await Ql(),o.setSecurityCenterState({breachedPasswordUsersTable:Zf}),o.setSecurityCenterStateLoader({key:e,value:!1})},o.loadUnenrolledMfaUsers=async()=>{const e=Ic.UNENROLLED_MFA_USERS_TABLE;o.setSecurityCenterStateLoader({key:e,value:!0}),await Ql(),o.setSecurityCenterState({unenrolledMfaUsersTable:tS}),o.setSecurityCenterStateLoader({key:e,value:!1})},o.loadInactiveUsers=async()=>{const e=Ic.INACTIVE_USERS_TABLE;o.setSecurityCenterStateLoader({key:e,value:!0}),await Ql(),o.setSecurityCenterState({inactiveUsersTable:eS}),o.setSecurityCenterStateLoader({key:e,value:!1})},o.sendResetBreachedPasswordEmail=async e=>{const{callback:t}=e,n=Ic.SEND_BREACHED_PASSWORD_EMAIL;o.setSecurityCenterStateLoader({key:n,value:!0}),await Ql(),null==t||t(!0),o.setSecurityCenterStateLoader({key:n,value:!1})},o})(e,t,n),I=((e,t,n)=>{const a=up(e,t,n),o=mf(a,["setSecurityPolicyState","setSecurityPolicyGlobalState","setSecurityPolicyPublicState","setSecurityPolicyMfaState","setSecurityPolicyVendorMfaState","setSecurityPolicyLockoutState","setSecurityPolicyVendorLockoutState","setSecurityPolicyCaptchaState","setSecurityPolicyPasswordHistoryState","setSecurityPolicyVendorPasswordHistoryState","resetSecurityPolicyState","setSecurityPolicyPasswordState","setSecurityPolicyAuthStrategyPublicState"]);return o.loadSecurityPolicy=async()=>{o.setSecurityPolicyGlobalState({loading:!0,error:null}),await Promise.all([o.loadSecurityPolicyMfa(),o.loadSecurityPolicyVendorMfa(),o.loadSecurityPolicyLockout(),o.loadSecurityPolicyVendorLockout(),o.loadSecurityPolicyPasswordHistory(),o.loadSecurityPolicyVendorPasswordHistory(),o.loadSecurityPolicyCaptcha()]),await Ql(),o.setSecurityPolicyGlobalState({policy:kf,loading:!1})},o.loadPublicSecurityPolicy=async()=>{o.setSecurityPolicyPublicState({loading:!0,error:null});try{o.setSecurityPolicyPublicState({policy:Of,loading:!1})}catch(e){o.setSecurityPolicyPublicState({error:Gc(e),loading:!1})}},o.saveSecurityPolicyMfa=async e=>{var t;const{callback:n}=e,a=oe(e,hS);o.setSecurityPolicyMfaState({saving:!0,error:null});const i=j({},Pf,{id:null!=(t=a.id)?t:Pf.id,enforceMFAType:a.enforceMFAType});await Ql(),o.setSecurityPolicyMfaState({policy:i,saving:!1}),null==n||n(i)},o.loadSecurityPolicyMfa=async()=>{o.setSecurityPolicyMfaState({loading:!0,error:null}),await Ql(),o.setSecurityPolicyMfaState({policy:_f,loading:!1})},o.loadSecurityPolicyVendorMfa=async()=>{o.setSecurityPolicyVendorMfaState({loading:!0,error:null}),await Ql(),o.setSecurityPolicyVendorMfaState({policy:_f,loading:!1})},o.saveSecurityPolicyLockout=async e=>{const{callback:t}=e,n=oe(e,vS);o.setSecurityPolicyLockoutState({saving:!0,error:null}),await Ql();const a=j({},Pf,n,{id:n.id?n.id:Pf.id});null==t||t(a),o.setSecurityPolicyLockoutState({policy:a,saving:!1})},o.loadSecurityPolicyLockout=async()=>{o.setSecurityPolicyLockoutState({loading:!0,error:null}),await Ql(),o.setSecurityPolicyLockoutState({policy:Pf,loading:!1})},o.loadSecurityPolicyVendorLockout=async()=>{o.setSecurityPolicyVendorLockoutState({loading:!0,error:null}),await Ql(),o.setSecurityPolicyVendorLockoutState({policy:Pf,loading:!1})},o.loadSecurityPolicyCaptcha=async()=>{o.setSecurityPolicyLockoutState({loading:!0,error:null}),await Ql(),o.setSecurityPolicyLockoutState({policy:Pf,loading:!1})},o.saveSecurityPolicyPasswordHistory=async e=>{const{callback:t}=e,n=oe(e,mS);o.setSecurityPolicyPasswordHistoryState({saving:!0,error:null}),await Ql();const a=j({},Uf,n,{id:n.id?n.id:Uf.id});null==t||t(a),o.setSecurityPolicyPasswordHistoryState({policy:a,saving:!1})},o.loadSecurityPolicyPasswordHistory=async()=>{o.setSecurityPolicyPasswordHistoryState({loading:!0,error:null}),await Ql(),o.setSecurityPolicyPasswordHistoryState({policy:Uf,loading:!1})},o.loadSecurityPolicyVendorPasswordHistory=async()=>{o.setSecurityPolicyVendorPasswordHistoryState({loading:!0,error:null}),await Ql(),o.setSecurityPolicyVendorPasswordHistoryState({policy:Uf,loading:!1})},o})(e,t,n),k=((e,t,n)=>{const a=hp(e,t),o=mf(a,["setSessionsState","resetSessionsState"]);return o.loadUserSessions=async()=>{o.setSessionsState({loading:!0,error:null}),o.setSessionsState({sessions:zf,loading:!1})},o.deleteUserSession=async t=>{const{id:n}=t;o.setSessionsState({loading:!0,error:null});const a=e.auth.sessionsState.sessions.filter((e=>e.id!==n));o.setSessionsState({sessions:a,loading:!1})},o.deleteAllUserSessions=async()=>{o.setSessionsState({loading:!0,error:null});const e=zf.filter((e=>e.current));o.setSessionsState({sessions:e,loading:!1})},o})(e,t),O=((e,t,n)=>{const a=yp(e,t,n),o=mf(a,["setSessionsPolicyState","resetSessionsPolicyState"]);return o.loadSessionsPolicy=async()=>{o.setSessionsPolicyState({loading:!0,error:null});const t=e.auth.sessionsPolicyState;o.setSessionsPolicyState(j({},t,{loading:!1}))},o.createOrUpdateSessionsPolicy=async e=>{const{callback:t}=e,n=oe(e,bS);o.setSessionsPolicyState({loading:!0,error:null}),null==t||t(!0),o.setSessionsPolicyState({configurations:n,loading:!1})},o})(e,t,n),_=((e,t,n)=>{const a=Ap(e,t,n);return mf(a,["setSignUpState","resetSignUpState","resetSignUpStateSoft"])})(e,t,n),P=((e,t,n)=>{const a=Pp(e,t);return mf(a,["setSmsState","resetSmsState"])})(e,t),U=((e,t,n)=>{const a=Cp(e,t,n);return mf(a,["setSocialLoginsState","resetSocialLoginsState","setSocialLoginError"])})(e,t,n),L=((e,t,n)=>{const a=Vp(e,t,n),o=mf(a,["setSSOState","resetSSOState"]);return o.loadSSOConfigurations=async()=>{o.setSSOState({loading:!0}),await Ql(),o.setSSOState({samlConfiguration:Lf,loading:!1,firstLoad:!1})},o.saveSSOConfigurations=async e=>{var t,n;const{callback:a,samlVendor:i}=e,s=oe(e,AS),r=Cf.samlConfiguration,l=j({},r,s);let c="saving";if((null==l?void 0:l.enabled)!==r.enabled&&(c="loading"),null==l||!l.domain)return void o.setSSOState({samlConfiguration:j({},r,l)});o.setSSOState({error:void 0,[c]:!0}),await Ql(),l.acsUrl=null==Df||null==(t=Df.configuration)?void 0:t.acsUrl,l.spEntityId=null==Df||null==(n=Df.configuration)?void 0:n.spEntityId;const u=ec(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 Ql(),o.setSSOState({samlConfiguration:u,error:void 0,[c]:!1}),null==a||a(!0)},o.saveSSOConfigurationsFile=async t=>{const n="saving";o.setSSOState({error:void 0,[n]:!0});const a=j({},e.auth.ssoState.samlConfiguration,{enabled:!0},t[0]);o.setSSOState({samlConfiguration:a,error:void 0,[n]:!1})},o.validateSSODomain=async e=>{const{callback:t}=null!=e?e:{},n=Cf.samlConfiguration;o.setSSOState({error:void 0,saving:!0}),await Ql(),o.setSSOState({samlConfiguration:j({},n,{validated:!0}),error:void 0,saving:!1}),null==t||t(!0)},o.loadSSOAuthorizationRoles=async()=>{await Ql(),o.setSSOState({authorizationRoles:["1","2","3"],error:void 0})},o.updateSSOAuthorizationRoles=async e=>{const{callback:t,authorizationRoles:n}=e;o.setSSOState({error:void 0,saving:!0}),await Ql(),o.setSSOState({authorizationRoles:n,error:void 0,saving:!1}),null==t||t(!0)},o})(e,t,n),D=((e,t,n)=>{const a=zp(e,t,n);return mf(a,["setStepUpState","resetStepUpState"])})(e,t,n),R=((e,t,n)=>{const a=ry(e,t,n),o=mf(a,["setTeamState","resetTeamState","setTeamLoader","setTeamError","openAddUserDialog","closeAddUserDialog","openDeleteUserDialog","closeDeleteUserDialog"]);return o.loadUsersV2=async t=>{var n,a,i,s;const{silentLoading:r,callback:l}=t,c=e.auth.teamState,u=null!=(n=t.pageSize)?n:c.pageSize,d=null!=(a=t.pageOffset)?a:c.pageOffset,g=null!=(i=t.filter)?i:c.filterV2,p=null!=(s=t.sort)?s:c.sortV2;o.setTeamLoader({key:Pc.USERS,value:!r}),o.setTeamState({pageSize:u,pageOffset:d,filterV2:g,sortV2:p}),await Ql(),o.setTeamState({users:xf,totalPages:2,totalItems:10,roles:Rf,permissions:Nf}),o.setTeamLoader({key:Pc.USERS,value:!1}),null==l||l(xf)},o.loadAllSubTenantsUsers=async t=>{var n,a,i,s,r;const{silentLoading:l,callback:c}=t,u=e.auth.teamState,d=null!=(n=t._limit)?n:u.allUsersQueryParams._limit,g=null!=(a=t._offset)?a:u.allUsersQueryParams._offset,p=null!=(i=t._filter)?i:u.allUsersQueryParams._filter,y=null!=(s=t._sortBy)?s:u.allUsersQueryParams._sortBy,f=null!=(r=t._order)?r:u.allUsersQueryParams._order;o.setTeamLoader({key:Pc.USERS,value:!l}),o.setTeamState({allUsersQueryParams:{_limit:d,_offset:g,_filter:p,_sortBy:y,_order:f}}),await Ql(),o.setTeamState({allUsers:Bf,totalPages:2,totalItems:10,roles:Rf,permissions:Nf}),o.setTeamLoader({key:Pc.USERS,value:!1}),null==c||c(Bf)},o.loadRoles=async e=>{var t;o.setTeamLoader({key:Pc.ROLES_AND_PERMISSIONS,value:!0}),await Ql(),o.setTeamState({roles:Rf,permissions:Nf}),o.setTeamLoader({key:Pc.ROLES_AND_PERMISSIONS,value:!0}),null==e||null==(t=e.callback)||t.call(e,{roles:Rf,permissions:Nf})},o.addUser=async t=>{const{callback:n}=t,a=oe(t,wS),i=e.auth.teamState;o.setTeamState({addUserDialogState:j({},i.addUserDialogState,{loading:!0})}),await Ql();const s=new Date,r=j({},$f,{groups:[]},a,{id:`${cS()}`,temporaryExpirationDate:a.expirationInSeconds?new Date(s.setSeconds(s.getSeconds()+a.expirationInSeconds)):void 0});null==n||n(r),o.setTeamState({users:[r,...i.users],addUserDialogState:{open:!1,loading:!1}})},o.addUserToSubTenants=async t=>{const{callback:n}=t,a=oe(t,TS),i=e.auth.teamState;o.setTeamState({addUserDialogState:j({},i.addUserDialogState,{loading:!0})}),await Ql();const s=j({},$f,a,{id:`${cS()}`});o.setTeamState({users:[s,...i.users],addUserDialogState:{open:!1,loading:!1}}),null==n||n(null)},o.updateUser=async t=>{var n;const{callback:a}=t,i=oe(t,ES),{id:s}=i,r=e.auth.teamState,l=r.users.find((e=>e.id===i.id));o.setTeamLoader({key:Pc.UPDATE_USER,value:s||""}),o.setTeamState({addUserDialogState:j({},r.addUserDialogState,{loading:!0})}),o.setTeamState({addUserDialogState:j({},r.addUserDialogState,{loading:!0}),users:r.users.map((e=>e.id===i.id?j({},e,i):e))}),l.roleIds.length>0&&0===(null==(n=i.roleIds)?void 0:n.length)&&(i.roleIds=[""]),await Ql();const c=j({},l,i);null==a||a(c),o.setTeamState({users:r.users.map((e=>e.id===c.id?j({},e,c,{createdAt:e.createdAt,customData:e.customData,lastLogin:e.lastLogin}):e))}),o.setTeamLoader({key:Pc.UPDATE_USER,value:!1})},o.deleteUser=async t=>{const{callback:n}=t,a=oe(t,IS),i=e.auth.teamState;o.setTeamState({deleteUserDialogState:j({},i.deleteUserDialogState,{loading:!0})}),await Ql(),null==n||n(!0),o.setTeamState({users:i.users.filter((e=>e.id!==a.userId)),deleteUserDialogState:{open:!1,loading:!1}})},o.updateUserExpirationTime=async t=>{const{callback:n}=t,a=oe(t,kS),i=e.auth.teamState;o.setTeamLoader({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:!0});const s=new Date;o.setTeamState({users:i.users.map((e=>e.id===a.userId?j({},e,{temporaryExpirationDate:a.expirationInSeconds?new Date(s.setSeconds(s.getSeconds()+a.expirationInSeconds)):void 0}):e))}),await Ql(),null==n||n(!0),o.setTeamLoader({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:!1})},o.setUserAsPermanent=async t=>{const{callback:n}=t,a=oe(t,OS),i=e.auth.teamState;o.setTeamLoader({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:!0}),o.setTeamState({users:i.users.map((e=>e.id===a.userId?j({},e,{temporaryExpirationDate:void 0}):e))}),await Ql(),null==n||n(!0),o.setTeamLoader({key:Pc.UPDATE_USER_EXPIRATION_TIME,value:!1})},o.deleteUserFromSubTenants=async t=>{const{callback:n}=t,a=oe(t,_S),i=e.auth.teamState;o.setTeamState({deleteUserDialogState:j({},i.deleteUserDialogState,{loading:!0})}),await Ql(),null==n||n(!0),o.setTeamState({allUsers:i.allUsers.filter((e=>e.id!==a.userId)),deleteUserDialogState:{open:!1,loading:!1}})},o.resendActivationLink=async e=>{const{callback:t}=e,n=oe(e,PS);o.setTeamLoader({key:Pc.RESEND_ACTIVATE_LINK,value:n.userId}),await Ql(),null==t||t(!0),o.setTeamLoader({key:Pc.RESEND_ACTIVATE_LINK,value:!1})},o.resendInvitationLink=async e=>{const{callback:t}=e,n=oe(e,US);o.setTeamLoader({key:Pc.RESEND_INVITATION_LINK,value:n.email}),await Ql(),null==t||t(!0),o.setTeamLoader({key:Pc.RESEND_INVITATION_LINK,value:!1})},o.resendInvitationEmail=async e=>{const{callback:t}=e,n=oe(e,LS);o.setTeamLoader({key:Pc.RESEND_INVITATION_LINK,value:n.email}),await Ql(),null==t||t(!0),o.setTeamLoader({key:Pc.RESEND_INVITATION_LINK,value:!1})},o.resendInvitationLinkToAllSubTenants=async e=>{const{callback:t}=e,n=oe(e,DS);o.setTeamLoader({key:Pc.RESEND_INVITATION_LINK,value:n.email}),await Ql(),null==t||t(!0),o.setTeamLoader({key:Pc.RESEND_INVITATION_LINK,value:!1})},o})(e,t,n),C=((e,t,n)=>{const a=uy(e,t,n),o=mf(a,["setTenantsState","resetTenantsState"]);return o.loadTenants=async()=>{o.setTenantsState({loading:!0}),o.setTenantsState({tenants:Wf,activeTenant:Wf[0],loading:!1})},o})(e,t,n),N={acceptInvitationActions:a,accountSettingsActions:o,activateAccountActions:i,allAccountsActions:s,allAccountsDialogActions:r,apiTokensActions:l,applicationsActions:c,customLoginActions:u,entitlementsActions:d,forgotPasswordActions:g,groupsActions:p,groupsDialogsActions:y,impersonateActions:f,loginActions:S,mfaActions:h,passkeysActions:v,profileActions:m,provisioningActions:b,resetPhoneNumberActions:A,restrictionsActions:w,rolesActions:T,securityCenterActions:E,securityPolicyActions:I,sessionsActions:k,sessionsPolicyActions:O,signUpActions:_,smsActions:P,socialLoginActions:U,ssoActions:L,stepUpActions:D,teamActions:R,tenantsActions:C},M=t=>{Object.keys(t).forEach((n=>{tc(e.auth[n])?Object.assign(e.auth[n],t[n]):e.auth[n]=t[n]}))};return{authActions:j({setState:M,setAuthState:M,resetAuthState:()=>{},setUser:e=>{M({user:e})}},a,o,i,s,r,l,c,u,d,g,p,y,f,S,h,v,m,b,A,w,T,E,I,k,O,_,P,U,L,D,R,C),authStateActions:N}})(e,t,n),i=((e,t,n)=>{const a=Ay(e,t,n);return mf(a,["setConnectivityState","resetConnectivityState","initData","resetConnectivityState","cleanWebhookTestData","cleanWebhookLogsData","cleanWebhookTestMessage","cleanError","cleanSlackData"])})(e,t,n),[s,r]=VS(e,t,n),l=((e,t,n)=>{const a=rf(e,t,n),o=mf(a,["setVendorState","resetVendorState"]);return o.loadVendorPublicInfo=async()=>{try{o.setVendorState({whiteLabelMode:!1}),await Ql()}catch(e){console.error("failed to getVendorPublicInfo - ",e)}},o.loadVendorPublicConfiguration=o.loadVendorPublicInfo,o})(e,t,n);return{authActions:a,authStateActions:o,connectivityActions:i,subscriptionsActions:s,subscriptionsStateActions:r,vendorActions:l,auditsActions:MS(e,t,n)}},WS=(e,t,n=!1,a,o,i=!1,s="path")=>zS({name:e.appName,context:e.context,storeHolder:t,previewMode:n,builderMode:i,urlStrategy:s,initialState:{root:j({},e),auth:j({},null==o?void 0:o.auth,a),connectivity:j({},null==o?void 0:o.connectivity),subscriptions:j({},null==o?void 0:o.subscriptions),vendor:j({},null==o?void 0:o.vendor),auditLogs:j({},null==o?void 0:o.auditLogs),audits:j({},null==o?void 0:o.audits)}}),zS=e=>{var n,a,o,i,s,r,l;const{storeHolder:c}=e;let u=c;if("undefined"==typeof window&&null==c)throw Error("createFronteggStore(initState, storeHolder) failed, storeHolder must not be null in Server-Side rendering");if(u||(u=window),u.store)return u.store;const{context:d,previewMode:g=!1,builderMode:p=!1,urlStrategy:y="path"}=e;g||p||ne.setContext(d),void 0===d.requestCredentials&&(d.requestCredentials="include");const f=e.name||"Default",S=py(null==(n=e.initialState)?void 0:n.auth),h=Sy(null==(a=e.initialState)?void 0:a.connectivity),v=nf(null==(o=e.initialState)?void 0:o.subscriptions),m=sf(null==(i=e.initialState)?void 0:i.vendor),b=yf(null==(s=e.initialState)?void 0:s.auditLogs),A=(w=null==(r=e.initialState)?void 0:r.audits,Mc(vf,w));var w;const T=null==(l=e.initialState)?void 0:l.auth;T&&Object.keys(T).forEach((e=>{hf()(S,e,T[e],{merge:!0})}));const E=Xl(S),I=Mc({root:{appName:f,context:d,urlStrategy:y,previewMode:g},auth:S,connectivity:h,subscriptions:v,vendor:m,auditLogs:b,audits:A});!function(e,t){"string"==typeof t&&(console.warn("string name option is deprecated, use { name }. https://github.com/pmndrs/valtio/pull/400"),t={name:t});const{enabled:n,name:a="",...o}=t||{};let i;try{i=(null==n||n)&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!i)return void(n&&console.warn("[Warning] Please install/enable Redux devtools extension"));let s=!1;const r=i.connect({name:a,...o});X(e,(t=>{const n=t.filter((([e,t])=>t[0]!==te)).map((([e,t])=>`${e}:${t.map(String).join(".")}`)).join(", ");if(n)if(s)s=!1;else{const t=Object.assign({},Q(e));delete t[te],r.send({type:n,updatedAt:(new Date).toLocaleString()},t)}})),r.subscribe((t=>{var n,a,o,i,l,c;if("ACTION"===t.type&&t.payload)try{Object.assign(e,JSON.parse(t.payload))}catch(e){console.error("please dispatch a serializable value that JSON.parse() and proxy() support\n",e)}if("DISPATCH"===t.type&&t.state){if("JUMP_TO_ACTION"===(null==(n=t.payload)?void 0:n.type)||"JUMP_TO_STATE"===(null==(a=t.payload)?void 0:a.type)){s=!0;const n=JSON.parse(t.state);Object.assign(e,n)}e[te]=t}else if("DISPATCH"===t.type&&"COMMIT"===(null==(o=t.payload)?void 0:o.type))r.init(Q(e));else if("DISPATCH"===t.type&&"IMPORT_STATE"===(null==(i=t.payload)?void 0:i.type)){const n=null==(l=t.payload.nextLiftedState)?void 0:l.actionsById,a=(null==(c=t.payload.nextLiftedState)?void 0:c.computedStates)||[];s=!0,a.forEach((({state:t},a)=>{const o=n[a]||"No action found";Object.assign(e,t),0===a?r.init(Q(e)):r.send(o,Q(e))}))}}));r.init(Q(e))}(I,{name:`${f} Store`,enabled:!0});const k={},O={};ne.setContext(e.context),ne.setAppName(f);const _=j({},Jl,{fetch:t});if(e.previewMode||e.builderMode){const{authActions:t,authStateActions:n,connectivityActions:a,subscriptionsActions:o,subscriptionsStateActions:i,vendorActions:s,auditsActions:r}=BS(I,_,O);k.auth=n,k.connectivity=a,k.subscriptions=i,k.vendor=s,k.auditLogs=r,k.audits={},Object.assign(O,j({},t,a,o,s,r));const l={dispatch:e=>{setTimeout((()=>{const[n,...i]=e.type.split("/"),r=i.join("/");"auth"===n&&"function"==typeof t[r]?t[r](e.payload):"connectivity"===n&&"function"==typeof a[r]?a[r](e.payload):"subscriptions"===n&&"function"==typeof o[r]?o[r](e.payload):"vendor"===n&&"function"==typeof s[r]&&s[r](e.payload)}))},getState:()=>I,subscribe:e=>X(I,e),store:I,actions:O,stateActions:k};return e.previewMode&&l.dispatch({type:"auth/requestAuthorize",payload:!0}),l}{const[e,t]=yy(I,_,O,E),n=Ay(I,_,O),[a,o]=af(I,_,O),i=rf(I,_,O),s=ff(I,_,O),r=((e,t,n)=>{const a=()=>{e.audits.isLoading=!1},o=t=>{var n;e.audits.error=null!=(n=e.audits.error)?n:{},Object.assign(e.audits.error,{[t.name]:t.error})},i=t=>{e.audits.filters=t,e.audits.currentPage=0,e.audits.offset=0,e.audits.isLoading=!0},s=async()=>{const{sortBy:n,sortDirection:a}=e.audits;try{i=await t.audits.getAuditsStats({sortBy:n,sortDirection:a,count:20}),e.audits.error=void 0,e.audits.totalToday=i.totalToday,e.audits.severeThisWeek=i.severeThisWeek}catch(e){const t={name:"stats",error:e};console.error("failed to load stats - ",e),o(t)}var i},r=async()=>{try{n=await t.metadata.getAuditsMetadata(),e.audits.error={},e.audits.headerProps=n.properties,e.audits.themeAudits=n.theme?n.theme.styles:{}}catch(e){const t={name:"metadata",error:e};console.error("failed to load metadata - ",e),o(t)}var n},l=e=>e.reduce(((e,t)=>(e[t.key]=t.value,e)),{}),c=async n=>{const{filters:i,sortBy:s,sortDirection:r,filter:c,offset:u,virtualScroll:d}=e.audits,{appendMode:g=d,onlyOneLoad:p=!0,offset:y=0}=n||{},{rowsData:f}=g?e.audits:{rowsData:[]};try{const n=l(i),{data:o,total:g}=await t.audits.getAudits(j({},d&&{paginationMode:"virtual"},{sortDirection:r,sortBy:s,filter:c},n,{offset:d?f.length+y||f.length+u:y||u,count:20}));(t=>{e.audits.error={},e.audits.rowsData=t.rowsData,e.audits.lastUpdated=new Date,e.audits.total=t.total})({rowsData:[...f,...o],total:g}),p&&a()}catch(e){const t={name:"audits",error:e};console.error("failed to load audits - ",e),o(t)}};return{initData:async()=>{e.audits.isLoading=!0,await Promise.all([s(),r(),c({onlyOneLoad:!1})]),a()},loadAudits:c,removeFilter:async t=>{const{filters:n}=e.audits,a=n.findIndex((e=>e.key===t.key));if(a<0)return;const o=[...n.slice(0,a),...n.slice(a+1)];i(o)},filterData:async t=>{const{filters:n}=e.audits;let a=n.findIndex((e=>e.key===t.key));a<0&&(a=n.length);const o=[...n.slice(0,a),t,...n.slice(a+1)];i(o)},exportCSV:async()=>{const{filters:n,sortBy:a,sortDirection:o,filter:i,headerProps:s=[]}=e.audits,r=l(n);e.audits.isDownloadingCsv=!0;try{await t.audits.exportAudits(j({endpoint:"csv/v2",headerProps:s,sortDirection:o,sortBy:a,filter:i},r,{offset:0,outputFileName:"audits.csv"}))}catch(e){console.error("failed to export audits - ",e)}finally{e.audits.isDownloadingCsv=!1}}}})(I,_);return k.auth=t,k.connectivity=n,k.subscriptions=o,k.vendor=i,k.auditLogs=s,k.audits=r,Object.assign(O,j({},e,n,a,i,s)),{dispatch:t=>{const[o,...s]=t.type.split("/"),r=s.join("/");"auth"===o&&"function"==typeof e[r]?e[r](t.payload):"connectivity"===o&&"function"==typeof n[r]?n[r](t.payload):"subscriptions"===o&&"function"==typeof a[r]?a[r](t.payload):"vendor"===o&&"function"==typeof i[r]&&i[r](t.payload)},getState:()=>I,subscribe:e=>X(I,e),store:I,actions:O,stateActions:k}}};function KS(e,t=0,n=1){return Math.min(Math.max(t,e),n)}function HS(e){if(e.type)return e;if("#"===e.charAt(0))return HS(function(e){e=e.substr(1);const t=new RegExp(`.{1,${e.length>=6?2:1}}`,"g");let n=e.match(t);return n&&1===n[0].length&&(n=n.map((e=>e+e))),n?`rgb${4===n.length?"a":""}(${n.map(((e,t)=>t<3?parseInt(e,16):Math.round(parseInt(e,16)/255*1e3)/1e3)).join(", ")})`:""}(e));const t=e.indexOf("("),n=e.substring(0,t);if(-1===["rgb","rgba","hsl","hsla","color"].indexOf(n))throw new Error("MUI: Unsupported `%s` color.\nThe following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color(). "+e);const a=e.substring(t+1,e.length-1);let o,i;if("color"===n){if(i=a.split(" "),o=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(o))throw new Error("MUI: unsupported `%s` color space.\nThe following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020."+o)}else i=a.split(",");return{type:n,values:i.map((e=>parseFloat(e))),colorSpace:o}}function qS(e){const{type:t,colorSpace:n}=e;let{values:a}=e;return-1!==t.indexOf("rgb")?a=a.map(((e,t)=>t<3?parseInt(e,10):e)):-1!==t.indexOf("hsl")&&(a[1]=`${a[1]}%`,a[2]=`${a[2]}%`),a=-1!==t.indexOf("color")?`${n} ${a.join(" ")}`:`${a.join(", ")}`,`${t}(${a})`}function JS(e){if(0===e.indexOf("#"))return e;const{values:t}=HS(e);return`#${t.map(((e,t)=>function(e){const t=e.toString(16);return 1===t.length?`0${t}`:t}(3===t?Math.round(255*e):e))).join("")}`}function YS(e,t){return e=HS(e),t=KS(t),"rgb"!==e.type&&"hsl"!==e.type||(e.type+="a"),"color"===e.type?e.values[3]=`/${t}`:e.values[3]=t,qS(e)}function XS(e,t){if(e=HS(e),t=KS(t),-1!==e.type.indexOf("hsl"))e.values[2]*=1-t;else if(-1!==e.type.indexOf("rgb")||-1!==e.type.indexOf("color"))for(let n=0;n<3;n+=1)e.values[n]*=1-t;return qS(e)}function QS(e,t){if(e=HS(e),t=KS(t),-1!==e.type.indexOf("hsl"))e.values[2]+=(100-e.values[2])*t;else if(-1!==e.type.indexOf("rgb"))for(let n=0;n<3;n+=1)e.values[n]+=(255-e.values[n])*t;else if(-1!==e.type.indexOf("color"))for(let n=0;n<3;n+=1)e.values[n]+=(1-e.values[n])*t;return qS(e)}const ZS=e=>{if(e)return{main:e,light:JS(QS(e,.4)),dark:JS(XS(e,.15)),hover:JS(XS(e,.15)),active:JS(XS(e,.2))}},eh=e=>{if(e)return{main:e,light:QS(e,.7),dark:XS(e,.2)}},th=(e,t)=>{var n,a,o,i,s,r,l,c,u,d,g,p;return null!=e&&e.palette&&"string"==typeof(null==e||null==(n=e.palette)?void 0:n.primary)?j({},t,{palette:{primary:j({},ZS(null==e||null==(a=e.palette)?void 0:a.primary),{contrastText:null!=(o=null==e||null==(i=e.palette)?void 0:i.primaryText)?o:"#000000"}),secondary:j({},ZS(null==e||null==(s=e.palette)?void 0:s.secondary),{contrastText:null!=(r=null==e||null==(l=e.palette)?void 0:l.secondaryText)?r:"#000000"}),danger:j({},ZS(null==e||null==(c=e.palette)?void 0:c.error),{contrastText:"#FFF"}),success:j({},eh(null==e||null==(u=e.palette)?void 0:u.success),{contrastText:"#FFF"}),error:j({},eh(null==e||null==(d=e.palette)?void 0:d.error),{contrastText:"#FFF"}),warning:j({},eh(null==e||null==(g=e.palette)?void 0:g.warning),{contrastText:"#FFF"}),info:j({},eh(null==e||null==(p=e.palette)?void 0:p.info),{contrastText:"#FFF"})}}):{}},nh={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",permissions:["fe.secure.read.securityPolicy"]},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 ah{constructor(){this._theme=nh.theme,this._themeV2=nh.themeV2,this._navigation=nh.navigation,this._localizations=nh.localizations,this._integrations=nh.integrations}static getInstance(e="default"){return this._instances[e]}static set(e,t="default"){const n=new ah;return n.set(e),ah._instances[t]=n,n}get theme(){var e;return null!=(e=this._theme)?e:{}}get themeV2(){var e;return null!=(e=this._themeV2)?e:{}}get navigation(){var e;return null!=(e=this._navigation)?e:{}}get localizations(){var e;return null!=(e=this._localizations)?e:{}}get integrations(){var e;return null!=(e=this._integrations)?e:{}}set(e){try{var t,n,a,o,i,s,r,l,c;this._navigation=Nc().all([null!=(t=nh.navigation)?t:{},null!=(n=null==e?void 0:e.navigation)?n:{}]),this._theme=Nc().all([null!=(a=nh.theme)?a:{},th(null==e?void 0:e.theme,nh.theme)]),this._themeV2=Nc().all([null!=(o=nh.themeV2)?o:{},null!=(i=null==e?void 0:e.themeV2)?i:{}]),this._localizations=Nc().all([null!=(s=nh.localizations)?s:{},null!=(r=null==e?void 0:e.localizations)?r:{}]),this._integrations=Nc().all([null!=(l=nh.integrations)?l:{},null!=(c=null==e?void 0:e.integrations)?c:{}])}catch(e){this._navigation=nh.navigation,this._theme=nh.theme,this._themeV2=nh.themeV2,this._localizations=nh.localizations,this._integrations=nh.integrations}}}ah._instances={};var oh=function(e){return e.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map((function(e){return e.toLowerCase()})).join("")},ih=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=document.createElement(t);return Object.keys(n).forEach((function(e){return a.setAttribute(e,n[e])})),e.appendChild(a),a},sh=function(e){return new Promise((function(t,n){var a=4e3,o=setInterval((function(){return null!=e.themeSetter?(clearInterval(o),void t(!0)):a<0?(n("Failed to load Renderer with themeSetter"),void clearInterval(o)):void(a-=50)}),50)}))},rh=function(e){var t=e.toString();if(t){var n=new URL(window.location.href);n.search=t,window.history.pushState(null,"",n.toString())}};let lh,ch,uh,dh,gh,ph,yh,fh,Sh,hh,vh,mh,bh;!function(e){e.phoneNumber="phoneNumber"}(lh||(lh={})),function(e){e.Name="name",e.PhoneNumber="phoneNumber",e.Address="address",e.JobTitle="jobTitle"}(ch||(ch={})),function(e){e.LoginSessions="loginSessions",e.Mfa="mfa"}(uh||(uh={})),function(e){e.Name="name",e.PhoneNumber="phoneNumber"}(dh||(dh={})),function(e){e.CompanyName="companyName",e.Address="address",e.Website="website",e.Timezone="timezone",e.Currency="currency"}(gh||(gh={})),function(e){e.User="user",e.Applications="applications",e.Groups="groups",e.Roles="roles",e.JoinedAt="joinedAt",e.LastSeen="lastSeen",e.ManagedBy="managedBy"}(ph||(ph={})),function(e){e.Invoices="invoices"}(yh||(yh={})),function(e){e.SessionManagement="sessionManagement",e.GeneralSettings="generalSettings",e.IpRestrictions="ipRestrictions",e.DomainRestrictions="domainRestrictions"}(fh||(fh={})),function(e){e.IdleSessionTimeout="idleSessionTimeout",e.ForceReLogin="forceReLogin",e.MaximumConcurrentSessions="maximumConcurrentSessions"}(Sh||(Sh={})),function(e){e.Mfa="mfa",e.UserLockout="userLockout",e.PasswordHistory="passwordHistory"}(hh||(hh={})),function(e){e.IpAddressRestrictions="ipAddressRestrictions"}(vh||(vh={})),function(e){e.RestrictSignupByEmailDomain="restrictSignupByEmailDomain"}(mh||(mh={})),function(e){e.Settings="settings",e.CustomLogin="customLogin"}(bh||(bh={}));const Ah={hidden:"hidden",viewOnly:"viewOnly",edit:"edit"},wh={hidden:"hidden",edit:"edit"},Th="7.0.0-alpha.4";var Eh={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"},Ih=function(){function t(e,n){var a,o,i=this,s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];P(this,t),this.name=void 0,this.iframeRendering=void 0,this.options=void 0,this.loading=!0,this.cdnUrl="https://assets.frontegg.com/admin-box/".concat(Th),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.updateLocalizations=void 0,this.loadAdminBoxMetadata=M($().mark((function e(){var t,n,a,o,s,r,l,c,u,d,g,p;return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=tt,i.options.metadata){e.next=25;break}return e.prev=2,e.next=5,t("/metadata",{entityName:"adminBox"});case 5:if(u=e.sent,d=null==u||null==(n=u.rows)||null==(a=n[0])||null==(o=a.configuration)||null==(s=o.metadataOverrides)?void 0:s.url,g=null!=(r=null==u||null==(l=u.rows)||null==(c=l[0])?void 0:c.configuration)?r:{},!d){e.next=19;break}return e.prev=9,e.next=12,t(d,{},{credentials:"same-origin"});case 12:(p=e.sent)&&(g=Nc()(g,p)),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(9),console.error("Failed to get metadata overrides",e.t0);case 19:i.options.metadata=g,e.next=25;break;case 22:e.prev=22,e.t1=e.catch(2),console.error("failed to get admin portal metadata",e.t1);case 25:ah.set(i.options.metadata,i.name);case 26:case"end":return e.stop()}}),e,null,[[2,22],[9,16]])}))),this.requestAuthorize=M($().mark((function e(){var t,n,a;return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=null==(t=i.options.authOptions)||null==(n=t.hostedLoginOptions)?void 0:n.loadUserOnFirstLoad,i.options.builderMode||"nextjs"===i.options.framework||(i.options.hostedLoginBox&&!i.options.customLoginBox?a&&i.store.dispatch({type:"auth/requestHostedLoginAuthorizeV2",payload:{shouldRedirectToLogin:!1,firstTime:!0}}):i.store.dispatch({type:"auth/requestAuthorize",payload:!0}));case 2:case"end":return e.stop()}}),e)}))),this.loadFeatureFlags=M($().mark((function e(){var t;return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!i.options.previewMode&&!i.options.builderMode){e.next=4;break}ut.set(Eh,i.name),e.next=15;break;case 4:return e.prev=4,e.next=7,dt();case 7:t=e.sent,i.options.overrideFeatureFlags&&Object.assign(t,i.options.overrideFeatureFlags),ut.set(t,i.name),e.next=15;break;case 12:e.prev=12,e.t0=e.catch(4),console.error("failed to get admin portal feature flags",e.t0);case 15:case"end":return e.stop()}}),e,null,[[4,12]])}))),this.setFeatureFlagsForPreview=function(e){ut.set(Object.assign({},Eh,e),i.name)},this.queryFeatureFlags=function(e){return ut.getFeatureFlags(e,i.name)},this.updateLocalizationsSetter=function(e){i.updateLocalizations=e},this.getEntitlementsFromStore=function(){var e;return null==(e=i.store.getState().auth.user)?void 0:e.entitlements},this.getUserFromStore=function(){return i.store.getState().auth.user},this.getEntitlementsQueryData=function(e){var t=i.getUserFromStore();return{entitlements:i.getEntitlementsFromStore(),attributes:{custom:e,jwt:t}}};var l=oh(n),c="frontegg-app-".concat(l);this.iframeRendering=s,this.name=l,this.options=Object.assign({},e,{contextOptions:Object.assign({requestCredentials:"include"},e.contextOptions)}),this.options.cdnUrl&&(this.cdnUrl=this.options.cdnUrl),this.customElementName=c;var u,d,g=this.options.authOptions?Object.assign({},this.options.authOptions,{hostedLoginBox:this.options.hostedLoginBox}):{hostedLoginBox:this.options.hostedLoginBox};if(g.onRedirectTo=e.onRedirectTo,g.disableSilentRefresh=null==(a=this.options.authOptions)?void 0:a.disableSilentRefresh,this.options.store){if(this.store=this.options.store,!r&&this.options.store.getState().root.appName!==n)throw Error("Mismatch in store names")}else this.store=zS({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({},g,null!=(u=this.options.authOptions)?u:{}),auditLogs:Object.assign({},null!=(d=this.options.auditsOptions)?d:{})}});R.setInstance(l,this),this.setEntitlementsOptions(e.entitlementsOptions),this.setSessionContext({enableSessionPerTenant:null==(o=e.authOptions)?void 0:o.enableSessionPerTenant}),ne.setAppName(l)}var n,a,o,i;return D(t,[{key:"setEntitlementsOptions",value:function(e){ne.setEntitlementsOptions(Object.assign({},e))}},{key:"setSessionContext",value:function(e){ne.setSessionContext(Object.assign({},e))}},{key:"initContainers",value:(i=M($().mark((function e(t){return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.adminPortalEl=t.adminPortalEl,this.loginBoxEl=t.loginBoxEl,this.checkoutDialogEl=t.checkoutDialogEl,this.adminPortalContainer=t.adminPortalContainer,this.loginBoxContainer=t.loginBoxContainer,this.checkoutDialogContainer=t.checkoutDialogContainer;try{"nextjs"!==this.options.framework&&document.body.classList.add("frontegg-loading")}catch(e){console.error("Failed to add frontegg-loading to body classList")}return e.next=9,this.loadFeatureFlags();case 9:return e.next=11,Promise.all([this.loadAdminBoxMetadata(),this.requestAuthorize()]);case 11:this.options.previewMode||this.options.customLoginBox||(this.loadLoginBox(),n=this.name,a=void 0,void 0,i=void 0,null==(i=null==(o=ah.getInstance(n))||null==(a=o.integrations)?void 0:a.gtm)||i.filter((function(e){var t=e.id;return e.enabled&&/^GTM-[a-zA-Z0-9]+$/.test(t)})).forEach((function(e){var t=e.id,n=document.createElement("script");n.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(t,"');\n "),document.body.appendChild(n)}))),this.options.lazyLoadAdminPortal||this.loadScript("FronteggAdminPortal");case 13:case"end":return e.stop()}var n,a,o,i}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"updateMetadata",value:function(e){var t;ah.set(e,this.name),null!=e&&e.localizations&&(null==(t=this.updateLocalizations)||t.call(this,e.localizations))}},{key:"addOnLoadedListener",value:function(e){this.loading?this.loadingListeners.push(e):e()}},{key:"ready",value:function(e){this.loading?e():this.addOnLoadedListener(e)}},{key:"loginWithRedirect",value:function(){this.store.dispatch({type:"auth/setState",payload:{isLoading:!0}}),this.store.dispatch({type:"auth/requestHostedLoginAuthorize"})}},{key:"logout",value:function(){this.store.dispatch({type:"auth/setState",payload:{isLoading:!0}}),this.store.dispatch({type:"auth/logout"})}},{key:"loadScript",value:function(t){var n=this;return new Promise((function(a,o){if(window[t])a(window[t]);else{var i=document.createElement("script");i.src="".concat(n.cdnUrl,"/").concat({FronteggLoginBox:"login-box/index.js",FronteggAdminPortal:"admin-portal/index.js"}[t]),i.setAttribute("id","".concat(t,"Script")),i.setAttribute("cdn-url",n.cdnUrl),i.onload=function(){window["".concat(t,"Init")]?a(window["".concat(t,"Init")]({FronteggRestApi:k,FronteggTypes:O,FronteggReduxStore:_,ValtioVanilla:e})):a(window[t])},i.onerror=function(e){console.log("Profile page error",e),o(e)},document.body.append(i)}}))}},{key:"loadLoginBox",value:(o=M($().mark((function e(){return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.loadScript("FronteggLoginBox");case 2:e.sent.render(this.loginBoxEl,{injector:this,options:this.options}),this.loading=!1,this.loadingListeners.forEach((function(e){try{e()}catch(e){console.error("Failed to call loadLoginBoxListener",e)}})),this.loadingListeners=[];case 7:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"showAdminPortal",value:(a=M($().mark((function e(t){var n,a,o,i,s;return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=(null!=t?t:{isMultiApp:!1}).isMultiApp,a=this.queryFeatureFlags(["multi-apps-admin-portal"]),l=1,o=function(e){if(Array.isArray(e))return e}(r=a)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var a,o,i,s,r=[],l=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(a=i.call(n)).done)&&(r.push(a.value),r.length!==t);l=!0);}catch(e){c=!0,o=e}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw o}}return r}}(r,l)||function(e,t){if(e){if("string"==typeof e)return C(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?C(e,t):void 0}}(r,l)||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.")}(),i=o[0],ne.setRequestSource(se.AdminPortal),e.next=5,this.loadScript("FronteggAdminPortal");case 5:s=e.sent,this.adminPortalRenderer=s.render(this.adminPortalEl,{injector:this,options:Object.assign({isMultiApp:i&&n},this.options)});case 7:case"end":return e.stop()}var r,l}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"openHostedAdminPortal",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this.options.contextOptions.baseUrl,n="".concat(t,"/oauth/portal");e?window.open(n,"_blank"):window.location.href=n}},{key:"hideAdminPortal",value:function(){try{var e,t=new URLSearchParams(window.location.search);null==(e=this.adminPortalRenderer)||e.unmount(),rh(t),ne.setRequestSource(null)}catch(e){console.error("Failed to unmount admin portal",e)}}},{key:"showCheckoutDialog",value:(n=M($().mark((function e(t){var n;return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.loadScript("FronteggAdminPortal");case 2:n=e.sent,this.checkoutDialogRenderer=n.renderCheckoutDialog(this.checkoutDialogEl,Object.assign({injector:this},t,{options:this.options}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"hideCheckoutDialog",value:function(){try{var e;null==(e=this.checkoutDialogRenderer)||e.unmount()}catch(e){console.error("Failed to unmount checkout dialog",e)}}},{key:"getFeatureEntitlements",value:function(e,t){var n=this.getEntitlementsQueryData(t),a=n.entitlements,o=n.attributes;return uc(a,e,o)}},{key:"getPermissionEntitlements",value:function(e,t){var n=this.getEntitlementsQueryData(t),a=n.entitlements,o=n.attributes;return cc(a,e,o)}},{key:"getEntitlements",value:function(e,t){return"permissionKey"in e?this.getPermissionEntitlements(e.permissionKey,t):this.getFeatureEntitlements(e.featureKey,t)}},{key:"loadEntitlements",value:function(e){this.store.dispatch({type:"auth/loadEntitlements",payload:{callback:e}})}},{key:"stepUp",value:function(e){var t=this.store.getState(),n=(null==t?void 0:t.auth)||{},a=n.hostedLoginBox,o=n.routes.stepUpUrl;a?this.store.dispatch({type:"auth/stepUpHostedLogin",payload:e}):hu(o,t.auth.onRedirectTo,null==e?void 0:e.maxAge)}},{key:"isSteppedUp",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=(null==(e=this.store.getState())?void 0:e.auth)||{},a=n.user;return fu(a,t)}},{key:"switchTenant",value:function(e){this.store.dispatch({type:"auth/switchTenant",payload:e})}},{key:"close",value:function(){this.hideAdminPortal(),this.hideCheckoutDialog()}}]),t}(),kh=function(){function e(){P(this,e)}return D(e,null,[{key:"setAuthentication",value:function(e,t,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"default",o=R.getInstance(a);e&&t?(ne.setAccessToken(t),ne.setUser(Object.assign({},n,{accessToken:t})),o.store.actions.setAuthState({isLoading:!1,isAuthenticated:e,user:n}),o.store.actions.loadTenants()):(ne.setAccessToken(null),ne.setUser(null),o.store.actions.setAuthState({isLoading:!1,isAuthenticated:!1,user:null}))}}]),e}(),Oh=function(){function e(){P(this,e)}return D(e,null,[{key:"show",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";R.getInstance(e).showAdminPortal()}},{key:"showMultiApp",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";R.getInstance(e).showAdminPortal({isMultiApp:!0})}},{key:"openHosted",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";R.getInstance(t).openHostedAdminPortal(e)}},{key:"hide",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";R.getInstance(e).hideAdminPortal()}}]),e}(),_h=function(){function e(){P(this,e)}return D(e,null,[{key:"show",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";R.getInstance(t).showCheckoutDialog(e)}},{key:"hide",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";R.getInstance(e).hideCheckoutDialog()}}]),e}(),Ph=function(e){var t;return null!=(t=window.FronteggAdminPortal.adminPortalStaticThemesDefaults[e])?t:void 0},Uh=function(){function e(t,n,a,o){var i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];P(this,e),this.app=void 0,this.options=void 0,this.store=void 0,this.setRoute=function(){},this.themeSetter=void 0,this.themeOptions={};var s={baseUrl:"preview"};if(a){if(this.store=a,!i&&a.getState().root.appName!==t)throw Error("Mismatch in store names")}else this.store=WS({context:s,appName:t},this,!0,void 0,void 0,!0);this.options=Object.assign({themeOptions:n,iframeRendering:!0,metadata:{},previewMode:!0,builderMode:!0,store:this.store,contextOptions:s},o),this.app=new Ih(this.options,t,!0),ah.set({},t)}var t;return D(e,[{key:"render",value:(t=M($().mark((function e(t){var n,a,o,i,s=this;return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=t.querySelector("#root"))||((n=t.ownerDocument.createElement("div")).setAttribute("id","root"),t.appendChild(n)),this.app.adminPortalContainer=t,this.app.adminPortalEl=n,a=function(e){s.themeSetter=e},o=function(e){s.setRoute=e},e.next=8,this.app.loadScript("FronteggAdminPortal");case 8:return i=e.sent,this.app.adminPortalRenderer=i.renderPage(n,{options:this.options,injector:this.app,setThemeSetter:a,setStaticRouteSetter:o}),this.app.loading=!1,e.next=13,sh(this);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"setStaticRoute",value:function(e){var t;null==(t=this.setRoute)||t.call(this,e)}},{key:"unmount",value:function(){try{var e;null==(e=this.app.adminPortalRenderer)||e.unmount()}catch(e){console.error("Failed to unmount admin Portal renderer",e)}}},{key:"setTheme",value:function(e){var t;this.themeOptions=e,this.themeSetter||console.warn("this.themeSetter is not defined yet"),null==(t=this.themeSetter)||t.call(this,this.themeOptions)}}]),e}(),Lh="modern",Dh=function(e){var t,n=window.FronteggAdminPortal.themes;return null!=(t=n[e])?t:n[Lh]},Rh=function(){function e(t,n,a,o){var i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];P(this,e),this.app=void 0,this.options=void 0,this.store=void 0,this.themeSetter=void 0,this.setRoute=function(){},this.themeOptions={};var s={baseUrl:"preview"};if(a){if(this.store=a,!i&&a.getState().root.appName!==t)throw Error("Mismatch in store names")}else this.store=WS({context:s,appName:t},this,!0,void 0,void 0,!0);this.options=Object.assign({themeOptions:n,iframeRendering:!0,metadata:{},previewMode:!0,builderMode:!0,store:this.store,contextOptions:s,onRedirectTo:function(){console.debug("path")}},o),this.app=new Ih(this.options,t,!0,i),ah.set({},t)}var t;return D(e,[{key:"render",value:(t=M($().mark((function e(t){var n,a,o,i,s=this;return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=t.querySelector("#root"))||((n=t.ownerDocument.createElement("div")).setAttribute("id","root"),t.appendChild(n)),this.app.loginBoxContainer=t,this.app.loginBoxEl=n,a=function(e){s.themeSetter=e},o=function(e){s.setRoute=e},e.next=8,this.app.loadScript("FronteggLoginBox");case 8:return i=e.sent,this.app.loginBoxRenderer=i.renderPage(n,{options:this.options,injector:this.app,setThemeSetter:a,setStaticRouteSetter:o,staticRoute:"/account/login"}),e.next=12,sh(this);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"unmount",value:function(){try{var e;null==(e=this.app.loginBoxRenderer)||e.unmount()}catch(e){console.error("Failed to unmount login box renderer",e)}}},{key:"setTheme",value:function(e){var t;this.themeOptions=e,this.themeSetter||console.warn("this.themeSetter is not defined yet"),null==(t=this.themeSetter)||t.call(this,this.themeOptions)}},{key:"setStaticRoute",value:function(e){var t;this.setRoute||console.warn("this.setRoute is not defined yet"),null==(t=this.setRoute)||t.call(this,e)}},{key:"setStore",value:function(e){this.store.dispatch({type:"auth/setState",payload:e})}}]),e}();function Ch(e,t){return Ch=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ch(e,t)}function Nh(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ch(e,t)}function Mh(e,t){if(t&&("object"===U(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function Fh(e){return Fh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Fh(e)}function $h(){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(e){return!1}}function jh(e,t,n){return jh=$h()?Reflect.construct.bind():function(e,t,n){var a=[null];a.push.apply(a,t);var o=new(Function.bind.apply(e,a));return n&&Ch(o,n.prototype),o},jh.apply(null,arguments)}function Gh(e){var t="function"==typeof Map?new Map:void 0;return Gh=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,a)}function a(){return jh(e,arguments,Fh(this).constructor)}return a.prototype=Object.create(e.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),Ch(a,e)},Gh(e)}function xh(e){var t=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(e){return!1}}();return function(){var n,a=Fh(e);if(t){var o=Fh(this).constructor;n=Reflect.construct(a,arguments,o)}else n=a.apply(this,arguments);return Mh(this,n)}}var Vh=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default",n=new Ih(e,t);if("undefined"!=typeof document){var a;if(!e.contextOptions.baseUrl){var o=new Error('Edit <FronteggProvider/> options { ContextOptions: { baseUrl: "" } } in order to connect your application');throw document.body.innerHTML="",alert(o.message),o}if(!customElements.get("frontegg-app")){var i=function(e){Nh(n,e);var t=xh(n);function n(){var e;P(this,n);for(var a=arguments.length,o=new Array(a),i=0;i<a;i++)o[i]=arguments[i];return(e=t.call.apply(t,[this].concat(o))).app=null,e}return D(n,[{key:"connectedCallback",value:function(){this.updateContent()}},{key:"attributeChangedCallback",value:function(e,t,n){if("app-name"===e){if(null===t)return;if(t===n)return;this.innerHTML="",null===n?this.remove():this.updateContent()}console.debug("attributeChangedCallback",e,t,n)}},{key:"updateContent",value:function(){var e,t=null!=(e=this.getAttribute("app-name"))?e:"default",n=R.getInstance(t);if(null===n)throw Error("FronteggApp not found for appName: '".concat(t,"'"));this.setAttribute("id","frontegg-app-".concat(n.name));var a=ih(this,"div",{id:"frontegg-admin-portal-container-".concat(n.name)}),o=ih(this,"div",{id:"frontegg-login-box-container-".concat(n.name)}),i=ih(this,"div",{id:"frontegg-checkout-dialog-container-".concat(n.name)}),s=a.attachShadow({mode:"open"}),r=o.attachShadow({mode:"open"}),l=i.attachShadow({mode:"open"}),c=ih(s,"div",{id:"frontegg-admin-portal-".concat(n.name),class:"frontegg-root-content"}),u=ih(r,"div",{id:"frontegg-login-box-".concat(n.name),class:"frontegg-root-content"}),d=ih(l,"div",{id:"frontegg-checkout-dialog-".concat(n.name),class:"frontegg-root-content"});n.initContainers({adminPortalEl:c,loginBoxEl:u,adminPortalContainer:a,loginBoxContainer:o,checkoutDialogContainer:i,checkoutDialogEl:d})}}],[{key:"observedAttributes",get:function(){return["app-name"]}}]),n}(Gh(HTMLElement));customElements.define("frontegg-app",i)}null==(a=document.querySelector('frontegg-app[app-name="'.concat(n.name,'"]')))||a.remove();var s=document.createElement("frontegg-app");s.setAttribute("app-name",n.name),document.body.appendChild(s)}return n}})(),a})()));