{"version":3,"file":"umb-app-auth-modal.element-CDWCE6-E.js","sources":["../../../src/packages/core/auth/modals/umb-app-auth-modal.element.ts"],"sourcesContent":["import type { ManifestAuthProvider } from '../../extension-registry/models/auth-provider.model.js';\nimport { UmbModalBaseElement } from '../../modal/index.js';\nimport { UmbTextStyles } from '../../style/text-style.style.js';\nimport { UMB_AUTH_CONTEXT } from '../auth.context.token.js';\nimport type { UmbAuthProviderDefaultProps } from '../types.js';\nimport type { UmbModalAppAuthConfig, UmbModalAppAuthValue } from './umb-app-auth-modal.token.js';\nimport { css, customElement, html, state } from '@umbraco-cms/backoffice/external/lit';\n\n@customElement('umb-app-auth-modal')\nexport class UmbAppAuthModalElement extends UmbModalBaseElement {\n\t@state()\n\tprivate _error?: string;\n\n\tget props(): UmbAuthProviderDefaultProps {\n\t\treturn {\n\t\t\tuserLoginState: this.data?.userLoginState ?? 'loggingIn',\n\t\t\tonSubmit: this.onSubmit.bind(this),\n\t\t};\n\t}\n\n\tget headline() {\n\t\treturn this.data?.userLoginState === 'timedOut'\n\t\t\t? this.localize.term('login_instruction')\n\t\t\t: this.localize.term(\n\t\t\t\t\t[\n\t\t\t\t\t\t'login_greeting0',\n\t\t\t\t\t\t'login_greeting1',\n\t\t\t\t\t\t'login_greeting2',\n\t\t\t\t\t\t'login_greeting3',\n\t\t\t\t\t\t'login_greeting4',\n\t\t\t\t\t\t'login_greeting5',\n\t\t\t\t\t\t'login_greeting6',\n\t\t\t\t\t][new Date().getDay()],\n\t\t\t\t);\n\t}\n\n\toverride render() {\n\t\treturn html`\n\t\t\t
\n\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\t\"Logo\"\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t

${this.headline}

\n\t\t\t\t\t\t
\n\t\t\t\t\t\t${this._error ? html`

${this._error}

` : ''}\n\t\t\t\t\t\t${this.data?.userLoginState === 'timedOut'\n\t\t\t\t\t\t\t? html`

${this.localize.term('login_timeout')}

`\n\t\t\t\t\t\t\t: ''}\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t
\n\t\t`;\n\t}\n\n\tprivate onSubmit = async (providerOrManifest: string | ManifestAuthProvider, loginHint?: string) => {\n\t\ttry {\n\t\t\tconst authContext = await this.getContext(UMB_AUTH_CONTEXT);\n\t\t\tif (!authContext) {\n\t\t\t\tthrow new Error('Auth context not available');\n\t\t\t}\n\n\t\t\tconst manifest = typeof providerOrManifest === 'string' ? undefined : providerOrManifest;\n\t\t\tconst providerName =\n\t\t\t\ttypeof providerOrManifest === 'string' ? providerOrManifest : providerOrManifest.forProviderName;\n\n\t\t\t// If the user is timed out, we do not want to lose the state, so avoid redirecting to the provider\n\t\t\t// and instead just make the authorization request. In all other cases, we want to redirect to the provider.\n\t\t\tconst isTimedOut = this.data?.userLoginState === 'timedOut';\n\n\t\t\tawait authContext.makeAuthorizationRequest(providerName, isTimedOut ? false : true, loginHint, manifest);\n\n\t\t\tconst isAuthed = authContext.getIsAuthorized();\n\t\t\tthis.value = { success: isAuthed };\n\t\t\tif (isAuthed) {\n\t\t\t\tthis._submitModal();\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error('[AuthModal] Error submitting auth request', error);\n\t\t\tthis._error = error instanceof Error ? error.message : 'Unknown error (see console)';\n\t\t}\n\t};\n\n\tstatic override styles = [\n\t\tUmbTextStyles,\n\t\tcss`\n\t\t\t:host {\n\t\t\t\tdisplay: block;\n\t\t\t\tbackground: rgb(244, 244, 244);\n\n\t\t\t\t--image: url('/umbraco/backoffice/assets/login.jpg') no-repeat center center/cover;\n\t\t\t\t--curves-color: var(--umb-login-curves-color, #f5c1bc);\n\t\t\t\t--curves-display: var(--umb-login-curves-display, inline);\n\t\t\t}\n\n\t\t\t#layout {\n\t\t\t\tdisplay: flex;\n\t\t\t\tjustify-content: center;\n\t\t\t\tpadding: 32px 0 32px 32px;\n\t\t\t\twidth: 100vw;\n\t\t\t\tmax-width: 1920px;\n\t\t\t\theight: calc(100vh - 64px);\n\t\t\t}\n\n\t\t\t#graphic {\n\t\t\t\tposition: relative;\n\t\t\t\twidth: 100%;\n\t\t\t\theight: 100%;\n\t\t\t\tbackground: var(--umb-login-image, var(--image));\n\t\t\t\tborder-radius: var(--umb-login-image-border-radius, 38px);\n\t\t\t\tposition: relative;\n\t\t\t\toverflow: hidden;\n\t\t\t\tcolor: var(--curves-color);\n\t\t\t}\n\n\t\t\t#graphic svg {\n\t\t\t\tposition: absolute;\n\t\t\t\twidth: 45%;\n\t\t\t\theight: fit-content;\n\t\t\t\tdisplay: var(--curves-display);\n\t\t\t}\n\n\t\t\t#curve-top {\n\t\t\t\ttop: 0px;\n\t\t\t\tright: 0px;\n\t\t\t}\n\n\t\t\t#curve-bottom {\n\t\t\t\tbottom: 0px;\n\t\t\t\tleft: 0px;\n\t\t\t}\n\n\t\t\t#content-container {\n\t\t\t\tbackground: var(--umb-login-content-background, none);\n\t\t\t\tdisplay: var(--umb-login-content-display, flex);\n\t\t\t\twidth: var(--umb-login-content-width, 100%);\n\t\t\t\theight: var(--umb-login-content-height, 100%);\n\t\t\t\toverflow: auto;\n\t\t\t\tborder-radius: var(--umb-login-content-border-radius, 0);\n\t\t\t\tpadding: 16px;\n\t\t\t\tmargin: auto;\n\t\t\t}\n\n\t\t\t#content {\n\t\t\t\tmax-width: 360px;\n\t\t\t\tmargin: auto;\n\t\t\t\twidth: 100%;\n\t\t\t}\n\n\t\t\t#logo-on-background {\n\t\t\t\tdisplay: none;\n\t\t\t}\n\n\t\t\t#logo-on-image,\n\t\t\t#logo-on-background {\n\t\t\t\tposition: absolute;\n\t\t\t\ttop: 24px;\n\t\t\t\tleft: 24px;\n\t\t\t\theight: 55px;\n\t\t\t}\n\n\t\t\t#header {\n\t\t\t\ttext-align: center;\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\tgap: var(--uui-size-space-5);\n\t\t\t}\n\n\t\t\t#greeting {\n\t\t\t\tcolor: var(--umb-login-greeting-color, var(--uui-color-interactive-emphasis));\n\t\t\t\ttext-align: center;\n\t\t\t\tfont-weight: 400;\n\t\t\t\tfont-size: var(--umb-login-header-font-size-large, 4rem);\n\t\t\t\tmargin: 0 0 var(--uui-size-layout-1);\n\t\t\t\tline-height: 1.2;\n\t\t\t}\n\n\t\t\t#providers {\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\tgap: var(--uui-size-space-5);\n\t\t\t}\n\n\t\t\t@media (max-width: 900px) {\n\t\t\t\t#graphic {\n\t\t\t\t\tdisplay: none;\n\t\t\t\t}\n\t\t\t\t#logo-on-background {\n\t\t\t\t\tdisplay: block;\n\t\t\t\t}\n\t\t\t}\n\t\t`,\n\t];\n}\n\nexport default UmbAppAuthModalElement;\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'umb-app-auth-modal': UmbAppAuthModalElement;\n\t}\n}\n"],"names":["UmbAppAuthModalElement","UmbModalBaseElement","providerOrManifest","loginHint","authContext","UMB_AUTH_CONTEXT","manifest","providerName","isTimedOut","isAuthed","error","html","UmbTextStyles","css","__decorateClass","state","customElement","UmbAppAuthModalElement$1"],"mappings":";;;;;;;;;;AASa,IAAAA,IAAN,cAAqCC,EAAiE;AAAA,EAAtG,cAAA;AAAA,UAAA,GAAA,SAAA,GA6EE,KAAA,WAAW,OAAOC,GAAmDC,MAAuB;AAC/F,UAAA;AACH,cAAMC,IAAc,MAAM,KAAK,WAAWC,CAAgB;AAC1D,YAAI,CAACD;AACE,gBAAA,IAAI,MAAM,4BAA4B;AAG7C,cAAME,IAAW,OAAOJ,KAAuB,WAAW,SAAYA,GAChEK,IACL,OAAOL,KAAuB,WAAWA,IAAqBA,EAAmB,iBAI5EM,IAAa,KAAK,MAAM,mBAAmB;AAEjD,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