/*! For license information please see api-triage.js.LICENSE.txt */ (()=>{"use strict";var e,t,r,s={4029:(e,t,r)=>{var s=r(6540),n=r(961);function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;ts.createElement(e,i({context:t},this.props)))}}}const l=a;class c{setBaseUrl(e){if(!e)throw new TypeError("ApiClientOption baseUrl is required.");if("string"==typeof e)try{this.baseUrl=new URL(e)}catch(e){throw new TypeError("ApiClientOption baseUrl is invalid.",{cause:e})}else{if(!(e instanceof URL))throw new TypeError("ApiClientOptions baseurl should be a string or URL");this.baseUrl=e}return this}setResourceName(e){if(!e)throw new TypeError("ApiClientOptions.setResourceName resourceName is required.");if("string"!=typeof e)throw new TypeError("ApiClientOptions.setResourceName resourceName should be a valid string.");return this.resourceName=e,this}getBaseUrl(){return this.baseUrl}getResourceName(){return this.resourceName}async getHeaders(){const e=await this.getCsrfToken();if(e)return{"X-CSRF-Token":e}}async getCsrfToken(){if("undefined"==typeof browser||void 0===browser.cookies){const e=document?.cookie?.split("; ")?.find(e=>e.startsWith("csrfToken"))?.split("=");return e&&2===e.length?e[1]:null}const e=this.baseUrl.toString(),t="/"===e.slice(-1)?e:`${e}/`,r=await browser.cookies.get({name:"csrfToken",url:t});return r?.value||null}}var h=r(5556),d=r.n(h);class p extends Error{constructor(e,t){super(e),this.name="PassboltApiFetchError",this.data=t||{}}}const u=p;class m extends Error{constructor(){super("An internal error occurred. The server response could not be parsed. Please contact your administrator."),this.name="PassboltBadResponseError"}}const g=m;class f extends Error{constructor(e){super(e=e||"The service is unavailable"),this.name="PassboltServiceUnavailableError"}}const E=f,y=["GET","POST","PUT","DELETE"];class v{constructor(e){if(this.options=e,!this.options.getBaseUrl())throw new TypeError("ApiClient constructor error: baseUrl is required.");if(!this.options.getResourceName())throw new TypeError("ApiClient constructor error: resourceName is required.");try{let e=this.options.getBaseUrl().toString();e.endsWith("/")&&(e=e.slice(0,-1));let t=this.options.getResourceName();t.startsWith("/")&&(t=t.slice(1)),t.endsWith("/")&&(t=t.slice(0,-1)),this.baseUrl=`${e}/${t}`,this.baseUrl=new URL(this.baseUrl)}catch(e){throw new TypeError("ApiClient constructor error: b.",{cause:e})}this.apiVersion="api-version=v2"}getDefaultHeaders(){return{Accept:"application/json","content-type":"application/json"}}async buildFetchOptions(){const e=await this.options.getHeaders();return{credentials:"include",headers:{...this.getDefaultHeaders(),...e}}}async get(e,t){this.assertValidId(e);const r=this.buildUrl(`${this.baseUrl}/${e}`,t||{});return this.fetchAndHandleResponse("GET",r)}async delete(e,t,r,s){let n;this.assertValidId(e),void 0===s&&(s=!1),n=s?this.buildUrl(`${this.baseUrl}/${e}/dry-run`,r||{}):this.buildUrl(`${this.baseUrl}/${e}`,r||{});let i=null;return t&&(i=this.buildBody(t)),this.fetchAndHandleResponse("DELETE",n,i)}async findAll(e){const t=this.buildUrl(this.baseUrl.toString(),e||{});return this.fetchAndHandleResponse("GET",t)}async create(e,t){const r=this.buildUrl(this.baseUrl.toString(),t||{}),s=this.buildBody(e);return this.fetchAndHandleResponse("POST",r,s)}async update(e,t,r,s){let n;this.assertValidId(e),void 0===s&&(s=!1),n=s?this.buildUrl(`${this.baseUrl}/${e}/dry-run`,r||{}):this.buildUrl(`${this.baseUrl}/${e}`,r||{});let i=null;return t&&(i=this.buildBody(t)),this.fetchAndHandleResponse("PUT",n,i)}async updateAll(e,t={}){const r=this.buildUrl(this.baseUrl.toString(),t),s=e?this.buildBody(e):null;return this.fetchAndHandleResponse("PUT",r,s)}assertValidId(e){if(!e)throw new TypeError("ApiClient.assertValidId error: id cannot be empty");if("string"!=typeof e)throw new TypeError("ApiClient.assertValidId error: id should be a string")}assertMethod(e){if("string"!=typeof e)throw new TypeError("ApiClient.assertValidMethod method should be a string.");if(y.indexOf(e.toUpperCase())<0)throw new TypeError(`ApiClient.assertValidMethod error: method ${e} is not supported.`)}assertUrl(e){if(!e)throw new TypeError("ApliClient.assertUrl error: url is required.");if(!(e instanceof URL))throw new TypeError("ApliClient.assertUrl error: url should be a valid URL object.");if("https:"!==e.protocol&&"http:"!==e.protocol)throw new TypeError("ApliClient.assertUrl error: url protocol should only be https or http.")}assertBody(e){if(!(e instanceof FormData)&&"string"!=typeof e)throw new TypeError("ApiClient.assertBody error: body should be a string or a FormData.")}buildBody(e){return JSON.stringify(e)}buildUrl(e,t){if("string"!=typeof e)throw new TypeError("ApiClient.buildUrl error: url should be a string.");const r=new URL(`${e}.json?${this.apiVersion}`);t=t||{};for(const[e,s]of Object.entries(t)){if("string"!=typeof e)throw new TypeError("ApiClient.buildUrl error: urlOptions key should be a string.");if("string"==typeof s)r.searchParams.append(e,s);else{if(!Array.isArray(s))throw new TypeError("ApiClient.buildUrl error: urlOptions value should be a string or array.");s.forEach(t=>{r.searchParams.append(e,t)})}}return r}async sendRequest(e,t,r,s){this.assertUrl(t),this.assertMethod(e),r&&this.assertBody(r);const n="undefined"!=typeof customApiClientFetch?customApiClientFetch:fetch,i={...await this.buildFetchOptions(),...s};i.method=e,r&&(i.body=r);try{return await n(t.toString(),i)}catch(e){throw console.error(e),navigator.onLine?new E("Unable to reach the server, an unexpected error occurred"):new E("Unable to reach the server, you are not connected to the network")}}async fetchAndHandleResponse(e,t,r,s){const n=await this.sendRequest(e,t,r,s);return this.parseResponseJson(n)}async parseResponseJson(e){let t;try{t=await e.json()}catch(t){throw console.debug(e.url.toString(),t),new g(t,e)}if(!e.ok){const r=t.header.message;throw new u(r,{code:e.status,body:t.body})}return t}}const b=class{constructor(e){this.apiClientOptions=e}async find(){this.initClient();const e=await this.apiClient.findAll(),t=e?.body;return t}async save(e){this.initClient(),await this.apiClient.create(e)}async delete(e){this.initClient(),await this.apiClient.delete(e)}async checkDomainAllowed(e){this.initClient("dry-run"),await this.apiClient.create(e)}initClient(e="settings"){this.apiClientOptions.setResourceName(`self-registration/${e}`),this.apiClient=new v(this.apiClientOptions)}},w=[{id:"azure",name:"Microsoft",icon:s.createElement("svg",{width:"65",height:"64",viewBox:"0 0 65 64",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s.createElement("path",{d:"M31.3512 3.04762H3.92261V30.4762H31.3512V3.04762Z",fill:"#F25022"}),s.createElement("path",{d:"M31.3512 33.5238H3.92261V60.9524H31.3512V33.5238Z",fill:"#00A4EF"}),s.createElement("path",{d:"M61.8274 3.04762H34.3988V30.4762H61.8274V3.04762Z",fill:"#7FBA00"}),s.createElement("path",{d:"M61.8274 33.5238H34.3988V60.9524H61.8274V33.5238Z",fill:"#FFB900"})),defaultConfig:{url:"https://login.microsoftonline.com",client_id:"",client_secret:"",tenant_id:"",client_secret_expiry:"",prompt:"login",email_claim:"email",login_hint:!0}},{id:"google",name:"Google",icon:s.createElement("svg",{width:"65",height:"64",viewBox:"0 0 65 64",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s.createElement("path",{d:"M63.9451 32.72C63.9451 30.6133 63.7584 28.6133 63.4384 26.6667H33.3051V38.6933H50.5584C49.7851 42.64 47.5184 45.9733 44.1584 48.24V56.24H54.4517C60.4784 50.6667 63.9451 42.4533 63.9451 32.72Z",fill:"#4285F4"}),s.createElement("path",{d:"M33.305 64C41.945 64 49.1717 61.12 54.4517 56.24L44.1583 48.24C41.2783 50.16 37.625 51.3333 33.305 51.3333C24.9583 51.3333 17.8917 45.7067 15.3583 38.1067H4.745V46.3467C9.99833 56.8 20.7983 64 33.305 64Z",fill:"#34A853"}),s.createElement("path",{d:"M15.3584 38.1067C14.6917 36.1867 14.3451 34.1333 14.3451 32C14.3451 29.8667 14.7184 27.8133 15.3584 25.8933V17.6533H4.74505C2.55838 21.9733 1.30505 26.8267 1.30505 32C1.30505 37.1733 2.55838 42.0267 4.74505 46.3467L15.3584 38.1067Z",fill:"#FBBC05"}),s.createElement("path",{d:"M33.305 12.6667C38.025 12.6667 42.2383 14.2933 45.5717 17.4667L54.6917 8.34667C49.1717 3.17334 41.945 0 33.305 0C20.7983 0 9.99833 7.20001 4.745 17.6533L15.3583 25.8933C17.8917 18.2933 24.9583 12.6667 33.305 12.6667Z",fill:"#EA4335"})),defaultConfig:{client_id:"",client_secret:""}},{id:"oauth2",name:"OpenID",hiddenIfDisabled:!0,disabledForRecover:!0,icon:s.createElement("svg",{width:"65",height:"60",viewBox:"0 0 65 60",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s.createElement("path",{d:"M64.2468 34.9929L62.9089 21.0968L57.9256 23.9083C53.2914 21.0968 47.3581 19.1061 40.7332 18.3046V24.4577C44.5336 25.117 47.9462 26.3321 50.7513 27.9544L45.5031 30.9146L64.2533 34.9929H64.2468Z",fill:"#B3B3B3"}),s.createElement("path",{d:"M9.94184 38.8774C9.94184 32.0069 17.4264 26.2222 27.632 24.4577V18.2981C12.023 20.1854 0.246826 28.6783 0.246826 38.8774C0.246826 49.0766 12.8891 58.1769 29.3319 59.6312V53.5557C18.2666 52.166 9.94184 46.1228 9.94184 38.8774Z",fill:"#B3B3B3"}),s.createElement("path",{d:"M29.332 5.09999V59.6377L39.027 55.0746V0.362366L29.332 5.09999Z",fill:"#F8931E"})),defaultConfig:{url:"",openid_configuration_path:"",scope:"openid email profile",client_id:"",client_secret:""}},{id:"adfs",name:"AD FS",hiddenIfDisabled:!0,disabledForRecover:!0,icon:s.createElement("svg",{width:"65",height:"64",viewBox:"0 0 65 64",fill:"none",xmlns:"http://www.w3.org/2000/svg"},s.createElement("path",{d:"M64.5443 48.7454V62.166C64.5443 63.7378 64.0607 64.0602 62.5695 63.8184C52.5746 62.3272 42.4587 60.957 32.3831 59.5464C30.5695 59.3046 29.9247 58.6597 29.9247 56.6849C30.0859 49.5514 30.0053 42.3776 29.9247 35.1635C29.9247 33.5917 30.4083 33.1081 31.9801 33.1081C42.2975 33.1887 52.4536 33.1887 62.5695 33.1887C64.2219 33.1887 64.6249 33.8335 64.6249 35.3247C64.4637 39.8386 64.5443 44.2718 64.5443 48.7454Z",fill:"#00AAF2"}),s.createElement("path",{d:"M47.416 30.6093C42.3379 30.6093 37.2598 30.5287 32.1817 30.6093C30.6099 30.6093 29.9651 30.2869 29.9651 28.4733C30.0457 21.1786 30.0457 14.0048 29.9651 6.79069C29.9651 5.38011 30.4487 4.89648 31.7787 4.65467C42.1767 3.16349 52.5747 1.7126 62.9726 0.140816C64.7862 -0.100997 64.4638 1.10807 64.4638 2.11563C64.4638 8.56399 64.5444 15.1333 64.4638 21.5816C64.4638 23.9595 64.3832 26.3373 64.4638 28.7151C64.5444 30.2063 63.9802 30.6093 62.5696 30.6093C57.5721 30.5287 52.4941 30.6093 47.416 30.6093Z",fill:"#00AAF2"}),s.createElement("path",{d:"M13.8038 33.3096H25.1691C26.3782 33.3096 26.9021 33.7126 26.9021 34.962V57.37C26.9021 58.6597 26.3378 58.7806 25.1691 58.6597C17.6326 57.5312 10.096 56.4431 2.59981 55.3952C1.10863 55.1534 0.625 54.6698 0.625 53.098C0.705605 47.1332 0.705605 41.1685 0.625 35.0829C0.625 33.5917 1.02802 33.1887 2.51921 33.1887C6.34792 33.3096 10.0154 33.3096 13.8038 33.3096Z",fill:"#00AAF2"}),s.createElement("path",{d:"M13.8038 30.6093H2.59977C1.18919 30.6093 0.705566 30.1257 0.705566 28.6345C0.786171 22.7504 0.786171 16.8663 0.705566 10.9418C0.705566 9.53126 1.10859 9.04763 2.59977 8.80582C10.1363 7.83856 17.6728 6.7504 25.169 5.54133C26.902 5.29952 27.0633 5.86375 27.0633 7.27433V28.7151C27.0633 30.2869 26.4184 30.5287 25.0078 30.5287C21.2597 30.5287 17.4713 30.6093 13.8038 30.6093Z",fill:"#00AAF2"})),defaultConfig:{url:"",openid_configuration_path:"",scope:"openid email profile",client_id:"",client_secret:""}}];function S(){return S=Object.assign?Object.assign.bind():function(e){for(var t=1;t{},onInitializeTriageRequested:()=>{},onTriageRequested:()=>{},onRegistrationRequested:()=>{},handleSwitchToSsoSignInState:()=>{},handleSwitchToUsernameState:()=>{},handleSwitchToEnterNameState:()=>{}});class T extends s.Component{constructor(e){super(e),this.state=Object.assign(this.defaultState,e.value)}get defaultState(){return this.findSsoProviderId=this.findSsoProviderId.bind(this),{unexpectedError:null,state:I.INITIAL_STATE,isSsoRecoverEnabled:!1,ssoProviderId:null,getSsoProviderId:this.getSsoProviderId.bind(this),onInitializeTriageRequested:this.onInitializeTriageRequested.bind(this),onTriageRequested:this.onTriageRequested.bind(this),onRegistrationRequested:this.onRegistrationRequested.bind(this),handleSwitchToSsoSignInState:this.handleSwitchToSsoSignInState.bind(this),handleSwitchToUsernameState:this.handleSwitchToUsernameState.bind(this),handleSwitchToEnterNameState:this.handleSwitchToEnterNameState.bind(this)}}async onInitializeTriageRequested(){const e=this.isSsoAvailable(),t=e?await this.findSsoProviderId():null,r=e&&Boolean(t);this.setState({ssoProviderId:t,isSsoRecoverEnabled:r,state:r?I.SSO_SIGN_IN_STATE:I.USERNAME_STATE})}isSsoAvailable(){return this.props.context.siteSettings.canIUse("ssoRecover")&&this.props.context.siteSettings.canIUse("sso")}getSsoProviderId(){return this.state.ssoProviderId}async findSsoProviderId(){const e=this.props.context.getApiClientOptions();e.setResourceName("sso/settings/current");const t=new v(e);let r=null;try{r=await t.findAll()}catch(e){return console.error(e),null}const s=r.body.provider;if(!s)return null;const n=w.find(e=>e.id===s);if(!n){const e=new Error("The given SSO provider id is not valid");return console.error(e),null}return n.disabledForRecover?(console.log("Recover processes with this SSO provider is not supported"),null):s}async onTriageRequested(e){const t={username:e},r=this.props.context.getApiClientOptions();r.setResourceName("users/recover");const s=new v(r);await s.create(t).then(this.handleTriageSuccess.bind(this)).catch(t=>this.handleTriageError(t,e))}async handleTriageSuccess(){return this.setState({state:I.CHECK_MAILBOX_STATE})}async handleTriageError(e,t){const r=e.data&&404===e.data.code;let s=I.USERNAME_NOT_FOUND_ERROR;if(r&&this.canIUseSelfRegistrationSettings)try{await this.isDomainAllowedToSelfRegister(t),s=I.NAME_STATE}catch(e){e.data&&(400===e.data.code||403===e.data.code)||(this.setState({unexpectedError:new E(e.message)}),s=I.UNEXPECTED_ERROR_STATE)}this.setState({username:t,state:s})}async onRegistrationRequested(e,t){const r={username:this.state.username,profile:{first_name:e,last_name:t}};this.register(r)}async handleRegistrationSuccess(){return this.setState({state:I.CHECK_MAILBOX_STATE})}async handleRegistrationError(){this.setState({state:I.UNEXPECTED_ERROR_STATE})}handleSwitchToSsoSignInState(){this.setState({state:I.SSO_SIGN_IN_STATE})}handleSwitchToUsernameState(){this.setState({state:I.USERNAME_STATE})}handleSwitchToEnterNameState(e){this.setState({username:e,state:I.NAME_STATE})}get canIUseSelfRegistrationSettings(){return this.props.context.siteSettings.canIUse("selfRegistration")}async isDomainAllowedToSelfRegister(e){const t=this.props.context.getApiClientOptions(),r=new b(t),s={email:e,provider:"email_domains"};await r.checkDomainAllowed(s)}async register(e){const t=this.props.context.getApiClientOptions().setResourceName("users/register"),r=new v(t);await r.create(e).then(this.handleRegistrationSuccess.bind(this)).catch(this.handleRegistrationError.bind(this))}render(){return s.createElement(C.Provider,{value:this.state},this.props.children)}}T.propTypes={context:d().any,value:d().any,children:d().any};const x=o(T);function P(e){return class extends s.Component{render(){return s.createElement(C.Consumer,null,t=>s.createElement(e,S({apiTriageContext:t},this.props)))}}}const I={INITIAL_STATE:"Initial State",USERNAME_STATE:"Enter username state",SSO_SIGN_IN_STATE:"SSO Sign in state",CHECK_MAILBOX_STATE:"Check mailbox state",NAME_STATE:"Enter name state",USERNAME_NOT_FOUND_ERROR:"Username not found error state",UNEXPECTED_ERROR_STATE:"Unexpected error state"};var R,O,A=r(2389);function U(){return U=Object.assign?Object.assign.bind():function(e){for(var t=1;tt.split(".").reduce((e,t)=>e?.[t],e),F=(e,t)=>{if(void 0===e||"string"!=typeof e||!e.length)return!1;if((t=t||{}).whitelistedProtocols&&!Array.isArray(t.whitelistedProtocols))throw new TypeError("The whitelistedProtocols should be an array of string.");if(t.defaultProtocol&&"string"!=typeof t.defaultProtocol)throw new TypeError("The defaultProtocol should be a string.");const r=t.whitelistedProtocols||[j.HTTP,j.HTTPS],s=[j.JAVASCRIPT],n=t.defaultProtocol||"";!/^((?!:\/\/).)*:\/\//.test(e)&&n&&(e=`${n}//${e}`);try{const t=new URL(e);return!s.includes(t.protocol)&&!!r.includes(t.protocol)&&t.href}catch(e){return console.error("Failed to sanitize URL:",e),!1}},j={FTP:"http:",FTPS:"https:",HTTP:"http:",HTTPS:"https:",JAVASCRIPT:"javascript:",SSH:"ssh:"};class B{constructor(e){this.settings=this.sanitizeDto(e)}sanitizeDto(e){const t=JSON.parse(JSON.stringify(e));return this.sanitizeEmailValidateRegex(t),t}sanitizeEmailValidateRegex(e){const t=e?.passbolt?.email?.validate?.regex;t&&"string"==typeof t&&t.trim().length&&(e.passbolt.email.validate.regex=t.trim().replace(/^\/+/,"").replace(/\/+$/,""))}canIUse(e){let t=!1;const r=`passbolt.plugins.${e}`,s=$(this.settings,r)||null;if(s&&"object"==typeof s){const e=$(s,"enabled");void 0!==e&&!0!==e||(t=!0)}return t}isFeatureBeta(e){(0,V.A)(e);const t=`passbolt.plugins.${e}.isInBeta`;return $(this.settings,t)||!1}getPluginSettings(e){const t=`passbolt.plugins.${e}`;return $(this.settings,t)}getRememberMeOptions(){return(this.getPluginSettings("rememberMe")||{}).options||{}}get hasRememberMeUntilILogoutOption(){return void 0!==(this.getRememberMeOptions()||{})[-1]}getServerTimezone(){return $(this.settings,"passbolt.app.server_timezone")}get termsLink(){const e=$(this.settings,"passbolt.legal.terms.url");return!!e&&F(e)}get privacyLink(){const e=$(this.settings,"passbolt.legal.privacy_policy.url");return!!e&&F(e)}get registrationPublic(){return!0===$(this.settings,"passbolt.registration.public")}get debug(){return!0===$(this.settings,"app.debug")}get url(){return $(this.settings,"app.url")||""}get version(){return $(this.settings,"app.version.number")}get isCommunityEdition(){return"ce"===$(this.settings,"passbolt.edition")}get locale(){return $(this.settings,"app.locale")||B.DEFAULT_LOCALE.locale}async setLocale(e){this.settings.app.locale=e}get supportedLocales(){return $(this.settings,"passbolt.plugins.locale.options")||B.DEFAULT_SUPPORTED_LOCALES}get generatorConfiguration(){return $(this.settings,"passbolt.plugins.generator.configuration")}get emailValidateRegex(){return this.settings?.passbolt?.email?.validate?.regex||null}static get DEFAULT_SUPPORTED_LOCALES(){return[B.DEFAULT_LOCALE]}static get DEFAULT_LOCALE(){return{locale:"en-UK",label:"English"}}}var M=r(3050),q=r.n(M);class H{static validate(e){return"string"==typeof e&&q()("^[\\p{L}0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\p{L}0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[_\\p{L}0-9][-_\\p{L}0-9]*\\.)*(?:[\\p{L}0-9][-\\p{L}0-9]{0,62})\\.(?:(?:[a-z]{2}\\.)?[a-z]{2,})$","i").test(e)}}class z{constructor(e){if("string"!=typeof e)throw Error("The regex should be a string.");this.regex=new(q())(e)}validate(e){return"string"==typeof e&&this.regex.test(e)}}class K{static validate(e,t){return K.getValidator(t).validate(e)}static getValidator(e){return e&&e instanceof B&&e.emailValidateRegex?new z(e.emailValidateRegex):H}}class W extends s.Component{constructor(e){super(e),this.state=this.defaultState,this.createInputRefs(),this.bindEventHandlers()}get defaultState(){return{loading:!0,processing:!1,username:"",usernameError:null,agreedTerms:!1,agreedTermsError:null,hasAlreadyBeenValidated:!1}}componentDidMount(){null!==this.props.context.siteSettings&&this.setState({loading:!1},()=>{this.focusUsernameElement()})}async componentDidUpdate(){this.state.loading&&null!==this.props.context.siteSettings&&this.setState({loading:!1},()=>{this.focusUsernameElement()})}focusUsernameElement(){this.isFocusOnBrowserExtension()||this.usernameRef.current.focus()}isFocusOnBrowserExtension(){const e=document.activeElement;return!!e&&"iframe"===e.tagName.toLowerCase()}bindEventHandlers(){this.handleInputChange=this.handleInputChange.bind(this),this.handleFormSubmit=this.handleFormSubmit.bind(this),this.handleUsernameInputOnKeyUp=this.handleUsernameInputOnKeyUp.bind(this)}createInputRefs(){this.usernameRef=s.createRef()}async handleInputChange(e){const t=e.target,r="checkbox"===t.type?t.checked:t.value,s=t.name;await this.setState({[s]:r}),this.state.hasAlreadyBeenValidated&&await this.validate()}handleUsernameInputOnKeyUp(){if(this.state.hasAlreadyBeenValidated){const e=this.validateUsernameInput();this.setState(e)}}async handleFormSubmit(e){if(e.preventDefault(),await this.setState({hasAlreadyBeenValidated:!0}),!this.state.processing){if(await this.toggleProcessing(),await this.validate(),this.hasValidationError())return void await this.toggleProcessing();this.props.apiTriageContext.onTriageRequested(this.state.username.trim())}}async toggleProcessing(){const e=this.state.processing;return this.setState({processing:!e})}async validate(){return await Promise.all([this.validateUsernameInput(),this.validateAgreedTerms()]),this.hasValidationError()}async validateUsernameInput(){let e=null;const t=this.state.username.trim();return t.length?K.validate(t,this.props.context.siteSettings)||(e=this.translate("Please enter a valid email address.")):e=this.translate("A username is required."),this.setState({username:t,usernameError:e})}async validateAgreedTerms(){let e=!1;const t=this.privacyLink||this.termsLink,r=this.state.agreedTerms;return t&&!r&&(e=!0),this.setState({agreedTermsError:e})}hasValidationError(){return null!==this.state.usernameError||this.state.agreedTermsError}hasAllInputDisabled(){return this.state.processing||this.state.loading}get privacyLink(){return!!this.props.context.siteSettings&&this.props.context.siteSettings.privacyLink}get termsLink(){return!!this.props.context.siteSettings&&this.props.context.siteSettings.termsLink}get translate(){return this.props.t}render(){return s.createElement("div",{className:"enter-username"},s.createElement("h1",null,s.createElement(A.x6,null,"Please enter your email to continue.")),s.createElement("form",{acceptCharset:"utf-8",onSubmit:this.handleFormSubmit,noValidate:!0},s.createElement("div",{className:`input text required ${this.state.usernameError?"error":""} ${this.hasAllInputDisabled()?"disabled":""}`},s.createElement("label",{htmlFor:"username"},s.createElement(A.x6,null,"Email")),s.createElement("input",{id:"username-input",type:"text",ref:this.usernameRef,name:"username",value:this.state.username,onKeyUp:this.handleUsernameInputOnKeyUp,onChange:this.handleInputChange,placeholder:this.translate("you@organization.com"),required:"required",disabled:this.hasAllInputDisabled()}),this.state.usernameError&&s.createElement("div",{className:"error-message"},this.state.usernameError)),(this.privacyLink||this.termsLink)&&s.createElement("div",{className:"input checkbox "+(this.state.agreedTermsError?"error":"")},s.createElement("input",{type:"checkbox",name:"agreedTerms",value:this.state.agreedTerms,onChange:this.handleInputChange,id:"checkbox-terms",disabled:this.hasAllInputDisabled()}),s.createElement("label",{htmlFor:"checkbox-terms"},(this.privacyLink||this.termsLink)&&s.createElement("span",null,this.termsLink&&!this.privacyLink&&s.createElement(A.x6,null,"I accept the ",s.createElement("a",{href:this.termsLink,target:"_blank",rel:"noopener noreferrer"},"terms")),!this.termsLink&&this.privacyLink&&s.createElement(A.x6,null,"I accept the ",s.createElement("a",{href:this.privacyLink,target:"_blank",rel:"noopener noreferrer"},"privacy policy")),this.termsLink&&this.privacyLink&&s.createElement(A.x6,null,"I accept the ",s.createElement("a",{href:this.termsLink,target:"_blank",rel:"noopener noreferrer"},"terms")," and the ",s.createElement("a",{href:this.privacyLink,target:"_blank",rel:"noopener noreferrer"},"privacy policy"))))),s.createElement("div",{className:"form-actions"},s.createElement(D,{disabled:this.hasAllInputDisabled(),big:!0,processing:this.state.processing,fullWidth:!0,value:this.translate("Next")}),this.props.isSsoRecoverEnabled&&s.createElement("button",{className:"link",type:"button",onClick:this.props.onSecondaryActionClick},s.createElement(A.x6,null,"Continue with SSO.")))))}}W.defaultProps={isSsoRecoverEnabled:!1},W.propTypes={apiTriageContext:d().object,context:d().any,isSsoRecoverEnabled:d().bool.isRequired,onSecondaryActionClick:d().func,t:d().func};const G=o(P((0,A.CI)("common")(W)));class Z extends s.Component{constructor(e){super(e),this.state=this.defaultState,this.createInputRefs(),this.bindEventHandlers()}componentDidMount(){this.setState({loading:!1},()=>{this.firstnameRef.current.focus()})}get defaultState(){return{loading:!0,processing:!1,firstname:"",firstnameError:null,lastname:"",lastnameError:null,hasAlreadyBeenValidated:!1}}bindEventHandlers(){this.handleInputChange=this.handleInputChange.bind(this),this.handleFormSubmit=this.handleFormSubmit.bind(this),this.handleFirstnameInputOnKeyUp=this.handleFirstnameInputOnKeyUp.bind(this),this.handleLastnameInputOnKeyUp=this.handleLastnameInputOnKeyUp.bind(this)}createInputRefs(){this.firstnameRef=s.createRef(),this.lastnameRef=s.createRef()}handleInputChange(e){const t=e.target,r=t.value,s=t.name;this.setState({[s]:r})}handleFirstnameInputOnKeyUp(){if(this.state.hasAlreadyBeenValidated){const e=this.validateFirstnameInput();this.setState(e)}}handleLastnameInputOnKeyUp(){if(this.state.hasAlreadyBeenValidated){const e=this.validateLastnameInput();this.setState(e)}}async handleFormSubmit(e){if(e.preventDefault(),await this.setState({hasAlreadyBeenValidated:!0}),!this.state.processing){if(await this.toggleProcessing(),await this.validate(),this.hasValidationError())return await this.toggleProcessing(),void this.focusFirstFieldError();await this.props.apiTriageContext.onRegistrationRequested(this.state.firstname,this.state.lastname)}}async toggleProcessing(){const e=this.state.processing;return this.setState({processing:!e})}async validate(){return await Promise.all([this.validateFirstnameInput(),this.validateLastnameInput()]),this.hasValidationError()}async validateFirstnameInput(){let e=null;return this.state.firstname.trim().length||(e=this.translate("A first name is required.")),this.setState({firstnameError:e})}async validateLastnameInput(){let e=null;return this.state.lastname.trim().length||(e=this.translate("A last name is required.")),this.setState({lastnameError:e})}focusFirstFieldError(){this.state.firstnameError?this.firstnameRef.current.focus():this.state.lastnameError&&this.lastnameRef.current.focus()}hasValidationError(){return null!==this.state.firstnameError||null!==this.state.lastnameError}hasAllInputDisabled(){return this.state.processing||this.state.loading}get translate(){return this.props.t}render(){return s.createElement("div",{className:"enter-name"},s.createElement("h1",null,s.createElement(A.x6,null,"New here? Enter your name to get started.")),s.createElement("form",{acceptCharset:"utf-8",onSubmit:this.handleFormSubmit,noValidate:!0},s.createElement("div",{className:`input text required ${this.state.firstnameError?"error":""} ${this.hasAllInputDisabled()?"disabled":""}`},s.createElement("label",{htmlFor:"firstname"},s.createElement(A.x6,null,"First name")),s.createElement("input",{id:"firstname-input",type:"text",name:"firstname",ref:this.firstnameRef,value:this.state.firstname,onKeyUp:this.handleFirstnameInputOnKeyUp,onChange:this.handleInputChange,disabled:this.hasAllInputDisabled(),placeholder:this.translate("First name"),required:"required"}),this.state.firstnameError&&s.createElement("div",{className:"error-message"},this.state.firstnameError)),s.createElement("div",{className:`input text required ${this.state.lastnameError?"error":""} ${this.hasAllInputDisabled()?"disabled":""}`},s.createElement("label",{htmlFor:"lastname"},s.createElement(A.x6,null,"Last name")),s.createElement("input",{id:"lastname-input",type:"text",name:"lastname",ref:this.lastnameRef,value:this.state.lastname,onKeyUp:this.handleLastnameInputOnKeyUp,onChange:this.handleInputChange,disabled:this.hasAllInputDisabled(),placeholder:this.translate("Last name"),required:"required"}),this.state.lastnameError&&s.createElement("div",{className:"error-message"},this.state.lastnameError)),s.createElement("div",{className:"form-actions"},s.createElement(D,{disabled:this.hasAllInputDisabled(),big:!0,fullWidth:!0,processing:this.state.processing,value:this.translate("Sign up")}),s.createElement("a",{href:`${this.props.context.trustedDomain}/auth/login?locale=${this.props.context.locale}`,rel:"noopener noreferrer"},s.createElement(A.x6,null,"I already have an account")))))}}Z.propTypes={apiTriageContext:d().object,context:d().any,t:d().func};const J=o(P((0,A.CI)("common")(Z)));class X extends s.Component{render(){return s.createElement("div",{className:"email-sent-instructions"},s.createElement("div",{className:"email-sent-bg"}),s.createElement("h1",null,s.createElement(A.x6,null,"Check your mailbox!")),s.createElement("p",null,s.createElement(A.x6,null,"We sent you a link to verify your email."),s.createElement("br",null),s.createElement(A.x6,null,"Check your spam folder if you do not hear from us after a while.")))}}X.propTypes={};const Y=(0,A.CI)("common")(X);class Q extends s.Component{render(){return s.createElement("div",{className:"setup-error"},s.createElement("h1",null,s.createElement(A.x6,null,"Access to this service requires an invitation.")),s.createElement("p",null,s.createElement(A.x6,null,"This email is not associated with any approved users on this domain.")," ",s.createElement(A.x6,null,"Please contact your administrator to request an invitation link.")),s.createElement("div",{className:"form-actions"},s.createElement("a",{href:`${this.props.context.trustedDomain}/users/recover`,className:"button primary big full-width",role:"button",rel:"noopener noreferrer"},s.createElement(A.x6,null,"Try with another email"))))}}Q.propTypes={context:d().any};const ee=o((0,A.CI)("common")(Q));var te;function re(){return re=Object.assign?Object.assign.bind():function(e){for(var t=1;t{if(Object.prototype.hasOwnProperty.call(e,t))return e[t];throw new Error},this._props)}static _normalizePropName(e){return e.replace(/([A-Z])/g,(e,t)=>`_${t.toLowerCase()}`).replace(/\._/,".").replace(/^_/,"").replace(/^\./,"")}}const de=he;class pe extends Error{constructor(e="Collection validation error."){super(e),this.name="CollectionValidationError",this.errors=[]}addItemValidationError(e,t){if(!Number.isInteger(e))throw new TypeError('CollectionValidationError::addEntityValidationError expects "position" to be an integer.');if(!(t instanceof ge||t instanceof pe))throw new TypeError('CollectionValidationError::addEntityValidationError expects "entityValidationError" to be an instance of EntityValidationError or CollectionValidationError.');this.errors[e]=t}addCollectionValidationError(e,t){if("string"!=typeof e)throw new TypeError('CollectionValidationError::addCollectionValidationError expects "rule" to be a string.');if("string"!=typeof t)throw new TypeError('CollectionValidationError::addCollectionValidationError expects "error" to be a string.');this.errors[e]=t}hasErrors(){return this.errors.some(e=>Object.keys(e.details).length>0)}get details(){const e={};for(const t in this.errors)this.errors[t]instanceof ge||this.errors[t]instanceof pe?e[t]=this.errors[t].details:e[t]=this.errors[t];return e}}const ue=pe;class me extends Error{constructor(e="Entity validation error."){super(e),this.name="EntityValidationError",this.details={}}addError(e,t,r){if("string"!=typeof e)throw new TypeError("EntityValidationError addError property should be a string.");if("string"!=typeof t)throw new TypeError("EntityValidationError addError rule should be a string.");if("string"!=typeof r)throw new TypeError("EntityValidationError addError message should be a string.");Object.prototype.hasOwnProperty.call(this.details,e)||(this.details[e]={}),this.details[e][t]=r}addAssociationError(e,t){if("string"!=typeof e)throw new TypeError("EntityValidationError addAssociationError associationName should be a string.");if(!(t instanceof me||t instanceof ue))throw new TypeError("EntityValidationError addAssociationError errorDetails should be an object.");this.details[e]=t}getError(e,t){if(!this.hasError(e,t))return null;const r=this.details[e];return t?r[t]:r}hasError(e,t){if("string"!=typeof e)throw new TypeError("EntityValidationError hasError property should be a string.");const r=this.details&&Object.prototype.hasOwnProperty.call(this.details,e);if(!r)return!1;if(!t)return r;if("string"!=typeof t)throw new TypeError("EntityValidationError hasError rule should be a string.");return Object.prototype.hasOwnProperty.call(this.details[e],t)}hasErrors(){return Object.keys(this.details).length>0}getFirstRuleErrorByField(e){if(!this.hasError(e))return null;const t=this.details[e];return t[Object.keys(t)[0]]}}const ge=me;var fe=r(7761),Ee=r.n(fe);class ye{static validateSchema(e,t){if(!t)throw new TypeError(`Could not validate entity ${e}. No schema for entity ${e}.`);if(!t.type)throw new TypeError(`Could not validate entity ${e}. Type missing.`);if("array"!==t.type){if("object"===t.type){if(!t.required||!Array.isArray(t.required))throw new TypeError(`Could not validate entity ${e}. Schema error: no required properties.`);if(!t.properties||!Object.keys(t).length)throw new TypeError(`Could not validate entity ${e}. Schema error: no properties.`);const r=t.properties;for(const e in r){if(!Object.prototype.hasOwnProperty.call(r,e)||!r[e].type&&!r[e].anyOf)throw TypeError(`Invalid schema. Type missing for ${e}...`);if(r[e].anyOf&&(!Array.isArray(r[e].anyOf)||!r[e].anyOf.length))throw new TypeError(`Invalid schema, prop ${e} anyOf should be an array`)}}}else if(!t.items)throw new TypeError(`Could not validate entity ${e}. Schema error: missing item definition.`)}static validate(e,t,r){if(!e||!t||!r)throw new TypeError(`Could not validate entity ${e}. No data provided.`);switch(r.type){case"object":return ye.validateObject(e,t,r);case"array":return ye.validateArray(e,t,r);default:throw new TypeError(`Could not validate entity ${e}. Unsupported type.`)}}static validateArray(e,t,r){let s;const n=ye.validateProp("items",t,r);if("number"==typeof r.minItems&&(ye.isGreaterThanOrEqual(t.length,r.minItems)||(s=ye.handleCollectionValidationError("minItems",`The items array should contain at least ${r.minItems} item(s).`,s))),"number"==typeof r.maxItems&&(ye.isLessThanOrEqual(t.length,r.maxItems)||(s=ye.handleCollectionValidationError("maxItems",`The items array should contain at maximum ${r.maxItems} item(s).`,s))),s)throw s;return n}static validateObject(e,t,r){const s=r.required,n=r.properties,i={};let a;for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r))if(null!==t?.[r]||!0!==n[r]?.nullable){if(s.includes(r)){if(!Object.prototype.hasOwnProperty.call(t,r)){a=ye.getOrInitEntityValidationError(e,a),a.addError(r,"required",`The ${r} is required.`);continue}}else if(!Object.prototype.hasOwnProperty.call(t,r))continue;try{i[r]=ye.validateProp(r,t[r],n[r])}catch(t){if(!(t instanceof ge))throw t;a=ye.getOrInitEntityValidationError(e,a),a.details[r]=t.details[r]}}else i[r]=null;if(a)throw a;return i}static getOrInitEntityValidationError(e,t){return t||new ge(`Could not validate entity ${e}.`)}static validateProp(e,t,r){if(r.anyOf)return ye.validateAnyOf(e,t,r.anyOf),t;if(!0===r.nullable&&null===t)return t;if(ye.validatePropType(e,t,r),r.enum)return ye.validatePropEnum(e,t,r),t;switch(r.type){case"string":ye.validatePropTypeString(e,t,r);break;case"integer":case"number":ye.validatePropTypeNumber(e,t,r);break;case"array":ye.validatePropTypeArray(e,t,r);break;case"object":case"boolean":case"blob":case"null":break;case"x-custom":ye.validatePropCustom(e,t,r);break;default:throw new TypeError(`Could not validate property ${e}. Unsupported prop type ${r.type}`)}return t}static validatePropType(e,t,r){if(!ye.isValidPropType(t,r.type))throw ye.handlePropertyValidationError(e,"type",`The ${e} is not a valid ${r.type}.`)}static validatePropCustom(e,t,r){try{r.validationCallback(t)}catch(t){throw ye.handlePropertyValidationError(e,"custom",`The ${e} is not valid: ${t.message}`)}}static validatePropTypeString(e,t,r){let s;if(r.format&&(ye.isValidStringFormat(t,r.format)||(s=ye.handlePropertyValidationError(e,"format",`The ${e} is not a valid ${r.format}.`,s))),r.notEmpty&&(ye.isValidStringNotEmpty(t)||(s=ye.handlePropertyValidationError(e,"notEmpty",`The ${e} should be not empty`,s))),r.length&&(ye.isValidStringLength(t,r.length,r.length)||(s=ye.handlePropertyValidationError(e,"length",`The ${e} should be ${r.length} character in length.`,s))),r.minLength&&(ye.isValidStringLength(t,r.minLength)||(s=ye.handlePropertyValidationError(e,"minLength",`The ${e} should be ${r.minLength} character in length minimum.`,s))),r.maxLength&&(ye.isValidStringLength(t,0,r.maxLength)||(s=ye.handlePropertyValidationError(e,"maxLength",`The ${e} should be ${r.maxLength} character in length maximum.`,s))),r.pattern&&(Ee().matches(t,r.pattern)||(s=ye.handlePropertyValidationError(e,"pattern",`The ${e} is not valid.`,s))),r.custom&&(r.custom(t)||(s=ye.handlePropertyValidationError(e,"custom",`The ${e} is not valid.`,s))),s)throw s}static handlePropertyValidationError(e,t,r,s=null){return(s=s||new ge(`Could not validate property ${e}.`)).addError(e,t,r),s}static handleCollectionValidationError(e,t,r=null){return(r=r||new ue("Could not validate collection.")).addCollectionValidationError(e,t),r}static validatePropTypeNumber(e,t,r){let s;if("number"==typeof r.minimum&&(ye.isGreaterThanOrEqual(t,r.minimum)||(s=ye.handlePropertyValidationError(e,"minimum",`The ${e} should be greater or equal to ${r.minimum}.`,s))),"number"==typeof r.maximum&&(ye.isLesserThanOrEqual(t,r.maximum)||(s=ye.handlePropertyValidationError(e,"maximum",`The ${e} should be lesser or equal to ${r.maximum}.`,s))),s)throw s}static validatePropTypeArray(e,t,r){let s;if(r?.items&&"object"==typeof r.items){for(let n=0;n=t}static isLessThanOrEqual(e,t){return e<=t}static isLesserThanOrEqual(e,t){return e<=t}}const ve=ye,be=["https://login.microsoftonline.com","https://login.microsoftonline.us","https://login.partner.microsoftonline.cn"],we=/^https:\/\/login\.(microsoftonline\.(com|us)|partner\.microsoftonline\.cn)$/;class Se extends de{constructor(e,t={}){const r=Se.sanitizeDto(e);super(ve.validate(Se.ENTITY_NAME,r,Se.getSchema()),t)}static getSchema(){return{type:"object",required:["url","client_id","tenant_id","client_secret","client_secret_expiry"],properties:{url:{type:"string",pattern:we},client_id:{type:"string",format:"uuid"},tenant_id:{type:"string",format:"uuid"},client_secret:{type:"string",minLength:1},client_secret_expiry:{type:"string",format:"date-time"},email_claim:{type:"string",enum:["email","preferred_username","upn"]},prompt:{type:"string",enum:["login","none"]},login_hint:{type:"boolean"}}}}static sanitizeDto(e){return e=Object.assign({},e),e?.email_claim||(e.email_claim="email"),e?.prompt||(e.prompt="login"),void 0===e.login_hint&&(e.login_hint=!0),e}static get ENTITY_NAME(){return"AzureSsoSettings"}static get PROVIDER_ID(){return"azure"}static get SUPPORTED_URLS(){return be}}const Ce=Se,Te=["https://accounts.google.com"];class xe extends de{constructor(e,t={}){super(ve.validate(xe.ENTITY_NAME,e,xe.getSchema()),t)}static getSchema(){return{type:"object",required:["client_id","client_secret"],properties:{client_id:{type:"string",minLength:1},client_secret:{type:"string",minLength:1}}}}static get ENTITY_NAME(){return"GoogleSsoSettings"}static get PROVIDER_ID(){return"google"}static get SUPPORTED_URLS(){return Te}}const Pe=xe,Ie={[Ce.PROVIDER_ID]:Ce.SUPPORTED_URLS,[Pe.PROVIDER_ID]:Pe.SUPPORTED_URLS},Re=class{constructor(e){this.apiClientOptions=e}async getUrl(e){this.apiClientOptions.setResourceName(`/sso/recover/${e}`);const t=new v(this.apiClientOptions),r=await t.create(),s=new URL(r.body.url),n=Ie[e];if(!n)throw new Error("The url should be part of the list of supported single sign-on urls.");if(!n.some(e=>e===s.origin))throw new Error("The url should be part of the list of supported single sign-on urls.");return s}},Oe=/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[0-5][a-fA-F0-9]{3}-[089aAbB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$/,Ae="default",Ue="registration_required",Le=class{constructor(e,t){this.popup=null,this.intervalCheck=null,this.expectedSuccessUrl=`${e}/sso/recover/${t}/success`,this.expectedErrorUrl=`${e}/sso/recover/error`,this.resolvePromise=null,this.rejectPromise=null,this.verifyPopup=this.verifyPopup.bind(this),this.handlePopupVerification=this.handlePopupVerification.bind(this),this.processSuccessUrl=this.processSuccessUrl.bind(this),this.processErrorUrl=this.processErrorUrl.bind(this)}getSsoTokenFromThirdParty(e){return this.popup=window.open(void 0,"__blank","popup,width=380,height=600"),this.popup.opener=null,this.popup.location.href=e.toString(),new Promise(this.handlePopupVerification)}handlePopupVerification(e,t){this.resolvePromise=e,this.rejectPromise=t,this.intervalCheck=setInterval(this.verifyPopup,200)}verifyPopup(){if(!this.popup||this.popup?.closed)return this.rejectPromise(new Error("The user navigated away from the tab where the SSO sign-in initiated")),void this.close();let e=null;try{e=this.popup.location.href}catch(e){return void console.error(e)}e.startsWith(this.expectedSuccessUrl)?this.processSuccessUrl(e):e.startsWith(this.expectedErrorUrl)&&this.processErrorUrl(e)}processSuccessUrl(e){const t=new URL(e).searchParams.get("token");var r;r=t,new(q())(Oe).test(r)&&(this.resolvePromise({case:Ae,token:t}),this.close())}processErrorUrl(e){const t=new URL(e).searchParams.get("email");var r;r=t,new(q())("^[\\p{L}0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\p{L}0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[_\\p{L}0-9][-_\\p{L}0-9]*\\.)*(?:[\\p{L}0-9][-\\p{L}0-9]{0,62})\\.(?:(?:[a-z]{2}\\.)?[a-z]{2,})$").test(r)&&(this.resolvePromise({case:Ue,email:t}),this.close())}close(){this.rejectPromise=null,this.resolvePromise=null,this.popup?.close(),this.popup=null,clearInterval(this.intervalCheck)}},ke=class{constructor(e,t,r,s){this.providerId=e,this.apiClientOptions=t.getApiClientOptions();const n=t.trustedDomain.replace(/\/$/,"");this.getUrlForSsoIdentificationService=new Re(t.getApiClientOptions()),this.getRecoverUrlService=new ce(n,t.getApiClientOptions()),this.ssoPopupHandler=new Le(n,e),this.successCallback=r,this.registrationRequiredCallback=s}async exec(){const e=await this.getUrlForSsoIdentificationService.getUrl(this.providerId),t=await this.ssoPopupHandler.getSsoTokenFromThirdParty(e);if(t.case===Ae){const e=await this.getRecoverUrlService.getRecoverUrl(t.token);this.successCallback(e.toString())}else t.case===Ue&&this.registrationRequiredCallback(t.email)}stopProcess(){this.ssoPopupHandler.close()}};class _e extends s.Component{constructor(e){super(e),this.state=this.defaultState,this.bindEventHandlers(),this.identifyViaSsoService=new ke(this.props.ssoProvider.id,this.props.context,this.handleSsoAuthSuccess,this.handleSsoAuthSuccessForRegistration)}get defaultState(){return{processing:!1}}componentDidMount(){window.addEventListener("beforeunload",this.handleBeforeUnload)}componentWillUnmount(){this.handleBeforeUnload()}handleBeforeUnload(){this.identifyViaSsoService.stopProcess(),window.removeEventListener("beforeunload",this.handleBeforeUnload)}bindEventHandlers(){this.handleBeforeUnload=this.handleBeforeUnload.bind(this),this.handleSsoRecoverClick=this.handleSsoRecoverClick.bind(this),this.handleGoToEmailClick=this.handleGoToEmailClick.bind(this),this.handleSsoAuthSuccess=this.handleSsoAuthSuccess.bind(this),this.handleSsoAuthSuccessForRegistration=this.handleSsoAuthSuccessForRegistration.bind(this)}async handleSsoRecoverClick(){if(!this.state.processing){this.toggleProcessing();try{await this.identifyViaSsoService.exec()}catch(e){console.error('Failed to identify via sso":',e)}this.toggleProcessing()}}handleSsoAuthSuccess(e){window.location.href=e}handleSsoAuthSuccessForRegistration(e){this.props.onUserRegistrationRequired(e)}handleGoToEmailClick(){this.identifyViaSsoService.stopProcess(),this.props.onSecondaryActionClick()}toggleProcessing(){const e=this.state.processing;this.setState({processing:!e})}isProcessing(){return this.state.processing}render(){const e=this.props.ssoProvider;if(!e)return null;const t=this.isProcessing(),r=t?"disabled":"";return s.createElement("div",{className:"enter-username"},s.createElement("h1",null,s.createElement(A.x6,null,"Welcome back!")),s.createElement("p",null,s.createElement(A.x6,null,"Your browser is not configured to work with this passbolt instance.")," ",s.createElement(A.x6,null,"Please authenticate with the Single Sign-On provider to continue.")),s.createElement("div",{className:"sso-login-form form-actions"},s.createElement("button",{type:"button",className:`sso-login-button ${r} ${e.id}`,onClick:this.handleSsoRecoverClick,disabled:t},s.createElement("span",{className:"provider-logo"},e.icon),this.props.t("Sign in with {{providerName}}",{providerName:e.name})),s.createElement("button",{type:"button",className:"link",onClick:this.handleGoToEmailClick},s.createElement(A.x6,null,"Continue with my email."))))}}_e.propTypes={ssoProvider:d().object,onSecondaryActionClick:d().func,onUserRegistrationRequired:d().func,context:d().any,t:d().func};const Ne=o((0,A.CI)("common")(_e));class De extends s.Component{componentDidMount(){this.initializeTriage(),this.getSsoProviderData=this.getSsoProviderData.bind(this)}initializeTriage(){setTimeout(this.props.apiTriageContext.onInitializeTriageRequested,1e3)}getSsoProviderData(){const e=this.props.apiTriageContext.getSsoProviderId();return w.find(t=>t.id===e)}render(){switch(this.props.apiTriageContext.state){case I.USERNAME_STATE:return s.createElement(G,{isSsoRecoverEnabled:this.props.apiTriageContext.isSsoRecoverEnabled,onSecondaryActionClick:this.props.apiTriageContext.handleSwitchToSsoSignInState});case I.SSO_SIGN_IN_STATE:return s.createElement(Ne,{ssoProvider:this.getSsoProviderData(),onSecondaryActionClick:this.props.apiTriageContext.handleSwitchToUsernameState,onUserRegistrationRequired:this.props.apiTriageContext.handleSwitchToEnterNameState});case I.CHECK_MAILBOX_STATE:return s.createElement(Y,null);case I.NAME_STATE:return s.createElement(J,null);case I.USERNAME_NOT_FOUND_ERROR:return s.createElement(ee,null);case I.UNEXPECTED_ERROR_STATE:return s.createElement(le,{error:this.props.apiTriageContext.unexpectedError});default:return s.createElement(_,null)}}}De.propTypes={apiTriageContext:d().object};const Ve=P(De);var $e;function Fe(){return Fe=Object.assign?Object.assign.bind():function(e){for(var t=1;tthis.getTranslationPath(e,t)},supportedLngs:this.supportedLocales,fallbackLng:!1,ns:["common"],defaultNS:"common",keySeparator:!1,nsSeparator:!1,debug:!1}),this.setState({ready:!0})}getTranslationPath(e,t){const r=e[0],s=t[0],n="en-GB"===r?"en-UK":r;return(this.props.loadingPath||"/locales/{{lng}}/{{ns}}.json").replace("{{lng}}",n).replace("{{ns}}",s)}get supportedLocales(){let e=[];return this.props.context.siteSettings?.supportedLocales?e=this.props.context.siteSettings?.supportedLocales.map(e=>e.locale):e.push(this.locale),e.includes("en-UK")&&e.push("en-GB"),e}get locale(){return this.props.context.locale}async componentDidUpdate(e){await this.handleLocaleChange(e.context.locale)}async handleLocaleChange(e){this.locale!==e&&await ze.Ay.changeLanguage(this.locale)}get isReady(){return this.state.ready}render(){return s.createElement(s.Fragment,null,this.isReady&&this.props.children)}}We.propTypes={context:d().any,loadingPath:d().any,children:d().any};const Ge=o(We),Ze=new class{allPropTypes=(...e)=>(...t)=>{const r=e.map(e=>e(...t)).filter(Boolean);if(0===r.length)return;const s=r.map(e=>e.message).join("\n");return new Error(s)}};var Je;function Xe(){return Xe=Object.assign?Object.assign.bind():function(e){for(var t=1;te.value!==this.state.selectedValue);return this.props.search&&""!==this.state.search?this.getItemsMatch(e,this.state.search):e}get selectedItemLabel(){const e=this.props.items&&this.props.items.find(e=>e.value===this.state.selectedValue);return e&&e.label||s.createElement(s.Fragment,null," ")}static getDerivedStateFromProps(e,t){return void 0!==e.value&&e.value!==t.selectedValue?{selectedValue:e.value}:null}bindCallback(){this.handleDocumentClickEvent=this.handleDocumentClickEvent.bind(this),this.handleDocumentContextualMenuEvent=this.handleDocumentContextualMenuEvent.bind(this),this.handleDocumentDragStartEvent=this.handleDocumentDragStartEvent.bind(this),this.handleDocumentScrollEvent=this.handleDocumentScrollEvent.bind(this),this.handleSelectClick=this.handleSelectClick.bind(this),this.handleInputChange=this.handleInputChange.bind(this),this.handleItemClick=this.handleItemClick.bind(this),this.handleSelectKeyDown=this.handleSelectKeyDown.bind(this),this.handleItemKeyDown=this.handleItemKeyDown.bind(this),this.handleBlur=this.handleBlur.bind(this)}createRefs(){this.selectedItemRef=s.createRef(),this.selectItemsRef=s.createRef(),this.itemsRef=s.createRef()}componentDidMount(){document.addEventListener("click",this.handleDocumentClickEvent,{capture:!0}),document.addEventListener("contextmenu",this.handleDocumentContextualMenuEvent,{capture:!0}),document.addEventListener("dragstart",this.handleDocumentDragStartEvent,{capture:!0}),document.addEventListener("scroll",this.handleDocumentScrollEvent,{capture:!0})}componentWillUnmount(){document.removeEventListener("click",this.handleDocumentClickEvent,{capture:!0}),document.removeEventListener("contextmenu",this.handleDocumentContextualMenuEvent,{capture:!0}),document.removeEventListener("dragstart",this.handleDocumentDragStartEvent,{capture:!0}),document.removeEventListener("scroll",this.handleDocumentScrollEvent,{capture:!0})}handleDocumentClickEvent(e){this.selectedItemRef.current.contains(e.target)||this.selectItemsRef.current.contains(e.target)||this.closeSelect()}handleDocumentContextualMenuEvent(e){this.selectedItemRef.current.contains(e.target)||this.selectItemsRef.current.contains(e.target)||this.closeSelect()}handleDocumentDragStartEvent(){this.closeSelect()}handleDocumentScrollEvent(e){this.itemsRef.current.contains(e.target)||this.selectItemsRef.current.contains(e.target)||this.closeSelect()}handleSelectClick(){if(this.props.disabled)this.closeSelect();else{const e=!this.state.open;e?this.forceVisibilitySelect():this.resetStyleSelect(),this.setState({open:e})}}getFirstParentWithTransform(){let e=this.selectedItemRef.current.parentElement;for(;null!==e&&""===e.style.getPropertyValue("transform");)e=e.parentElement;return e}forceVisibilitySelect(){const e=this.selectedItemRef.current.getBoundingClientRect(),{width:t,height:r}=e;let{top:s,left:n}=e;const i=this.getFirstParentWithTransform();if(i){const e=i.getBoundingClientRect();s-=e.top,n-=e.left}const a={position:"fixed",zIndex:1,width:t,height:r,top:s,left:n};this.setState({style:a})}handleBlur(e){e.currentTarget.contains(e.relatedTarget)||this.closeSelect()}closeSelect(){this.resetStyleSelect(),this.setState({open:!1})}resetStyleSelect(){this.setState({style:void 0})}handleInputChange(e){const t=e.target,r=t.value,s=t.name;this.setState({[s]:r})}handleItemClick(e){if(this.setState({selectedValue:e.value,open:!1}),"function"==typeof this.props.onChange){const t={target:{value:e.value,name:this.props.name}};this.props.onChange(t)}this.closeSelect()}getItemsMatch(e,t){const r=t&&t.split(/\s+/)||[""];return e.filter(e=>r.every(t=>((e,t)=>(e=>new RegExp((e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))(e),"i"))(e).test(t))(t,e.label)))}handleSelectKeyDown(e){switch(e.keyCode){case 13:return e.stopPropagation(),void this.handleSelectClick();case 40:return e.preventDefault(),e.stopPropagation(),void(this.state.open?this.focusItem(0):this.handleSelectClick());case 38:return e.preventDefault(),e.stopPropagation(),void(this.state.open?this.focusItem(this.listItemsFiltered.length-1):this.handleSelectClick());case 27:return e.stopPropagation(),void this.closeSelect();default:return}}focusItem(e){this.itemsRef.current.childNodes[e]?.focus()}handleItemKeyDown(e,t){switch(e.keyCode){case 13:return e.stopPropagation(),void this.handleItemClick(t);case 40:return e.stopPropagation(),e.preventDefault(),void(e.target.nextSibling?e.target.nextSibling.focus():this.focusItem(0));case 38:return e.stopPropagation(),e.preventDefault(),void(e.target.previousSibling?e.target.previousSibling.focus():this.focusItem(this.listItemsFiltered.length-1));default:return}}hasFilteredItems(){return this.listItemsFiltered.length>0}render(){return s.createElement("div",{className:`select-container ${this.props.className}`,style:{width:this.state.style?.width,height:this.state.style?.height}},s.createElement("div",{onKeyDown:this.handleSelectKeyDown,onBlur:this.handleBlur,id:this.props.id,className:`select ${this.props.direction} ${this.state.open?"open":""}`,style:this.state.style},s.createElement("div",{ref:this.selectedItemRef,className:"selected-value "+(this.props.disabled?"disabled":""),tabIndex:this.props.disabled?-1:0,onClick:this.handleSelectClick},s.createElement("span",{className:"value"},this.selectedItemLabel),s.createElement(se,null)),s.createElement("div",{ref:this.selectItemsRef,className:"select-items "+(this.state.open?"visible":"")},this.props.search&&s.createElement(s.Fragment,null,s.createElement("input",{className:"search-input",name:"search",value:this.state.search,onChange:this.handleInputChange,type:"text"}),s.createElement(Ye,{className:"search"})),s.createElement("ul",{ref:this.itemsRef,className:"items"},this.hasFilteredItems()&&this.listItemsFiltered.map(e=>s.createElement("li",{tabIndex:e.disabled?-1:0,key:e.value,className:`option ${e.value}`,onKeyDown:t=>this.handleItemKeyDown(t,e),onClick:()=>this.handleItemClick(e)},e.label)),!this.hasFilteredItems()&&this.props.search&&s.createElement("li",{className:"option no-results"},s.createElement(A.x6,null,"No results match")," ",s.createElement("span",null,this.state.search))))))}}Qe.defaultProps={id:"",name:"select",className:"",direction:"bottom"},Qe.propTypes={id:d().string,name:d().string,className:d().string,direction:d().oneOf(Object.values({top:"top",bottom:"bottom",left:"left",right:"right"})),search:d().bool,items:d().array,value:Ze.allPropTypes(d().oneOfType([d().string,d().number,d().bool]),(e,t,r)=>{const s=e[t],n=e.items;if(null!==s&&n.length>0&&n.every(e=>e.value!==s))return new Error(`Invalid prop ${t} passed to ${r}. Expected the value ${s} in items.`)}),disabled:d().bool,onChange:d().func};const et=(0,A.CI)("common")(Qe);class tt extends s.Component{constructor(e){super(e),this.state=this.defaultState,this.bindHandlers()}async componentDidMount(){await this.initLocale()}async componentDidUpdate(e){await this.handleLocaleChange(e.context.locale)}async handleLocaleChange(e){this.props.context.locale!==e&&await this.setState({locale:this.props.context.locale})}get defaultState(){return{loading:!0,locale:null,processing:!1}}get areActionsAllowed(){return!this.state.processing}bindHandlers(){this.handleLocaleInputChange=this.handleLocaleInputChange.bind(this)}async handleLocaleInputChange(e){const t=e.target.value;await this.updateLocale(t)}async updateLocale(e){await this.toggleProcessing(),await this.props.context.onUpdateLocaleRequested(e),await this.toggleProcessing()}async initLocale(){await this.setState({locale:this.props.context.locale,loading:!1})}async toggleProcessing(){const e=this.state.processing;return this.setState({processing:!e})}isLoading(){return this.state.loading}get supportedLocales(){return this.props.context.siteSettings.supportedLocales?this.props.context.siteSettings.supportedLocales.map(e=>({value:e.locale,label:e.label})):[]}render(){return s.createElement(s.Fragment,null,!this.isLoading()&&s.createElement("div",{className:"select-wrapper input"},s.createElement(et,{id:"user-locale-input",className:"setup-extension",name:"locale",value:this.state.locale,disabled:!this.areActionsAllowed,items:this.supportedLocales,onChange:this.handleLocaleInputChange})))}}tt.propTypes={context:d().any};const rt=o(tt);class st extends s.Component{get statesToHideLocaleSwitch(){return[I.INITIAL_STATE]}get mustDisplayLocaleSwitch(){return!this.statesToHideLocaleSwitch.includes(this.props.apiTriageContext.state)}render(){return s.createElement(s.Fragment,null,this.mustDisplayLocaleSwitch&&s.createElement(rt,null))}}st.propTypes={apiTriageContext:d().any};const nt=P(st);var it,at,ot,lt,ct;function ht(){return ht=Object.assign?Object.assign.bind():function(e){for(var t=1;te===t.locale);if(t)return t.locale}}getBrowserLocale(){const e=this.state.siteSettings.supportedLocales.find(e=>navigator.language===e.locale);if(e)return e.locale}getBrowserSimilarLocale(){const e=navigator.language.split("-")[0],t=this.state.siteSettings.supportedLocales.find(t=>e===t.locale.split("-")[0]);if(t)return t.locale}async onUpdateLocaleRequested(e){await this.setState({locale:e}),this.setUrlLocale(e)}setUrlLocale(e){const t=new URL(window.location.href);t.searchParams.set("locale",e),window.history.replaceState(null,null,t)}isReady(){return null!==this.state.siteSettings&&null!==this.state.locale}render(){return s.createElement(l.Provider,{value:this.state},this.isReady()&&s.createElement(Ge,{loadingPath:`${this.state.trustedDomain}/locales/{{lng}}/{{ns}}.json`},s.createElement(x,null,s.createElement("div",{id:"container",className:"container page login"},s.createElement("div",{className:"content"},s.createElement("div",{className:"header"},s.createElement("div",{className:"logo-svg"},s.createElement(dt,{role:"img",width:"20rem",height:"3.5rem"}))),s.createElement("div",{className:"login-form"},s.createElement(Ve,null)),s.createElement(nt,null)),s.createElement(He,null)))))}}const ut=pt,mt=document.createElement("div");document.body.appendChild(mt),n.render(s.createElement(ut,null),mt)}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return s[e].call(r.exports,r,r.exports,i),r.exports}i.m=s,e=[],i.O=(t,r,s,n)=>{if(!r){var a=1/0;for(h=0;h=n)&&Object.keys(i.O).every(e=>i.O[e](r[l]))?r.splice(l--,1):(o=!1,n0&&e[h-1][2]>n;h--)e[h]=e[h-1];e[h]=[r,s,n]},i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(e,s){if(1&s&&(e=this(e)),8&s)return e;if("object"==typeof e&&e){if(4&s&&e.__esModule)return e;if(16&s&&"function"==typeof e.then)return e}var n=Object.create(null);i.r(n);var a={};t=t||[null,r({}),r([]),r(r)];for(var o=2&s&&e;("object"==typeof o||"function"==typeof o)&&!~t.indexOf(o);o=r(o))Object.getOwnPropertyNames(o).forEach(t=>a[t]=()=>e[t]);return a.default=()=>e,i.d(n,a),n},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.e=()=>Promise.resolve(),i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.j=666,(()=>{var e={666:0};i.O.j=t=>0===e[t];var t=(t,r)=>{var s,n,[a,o,l]=r,c=0;if(a.some(t=>0!==e[t])){for(s in o)i.o(o,s)&&(i.m[s]=o[s]);if(l)var h=l(i)}for(t&&t(r);ci(4029));a=i.O(a)})();