@singlebase/elements 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{authui-display-CKfGK5va.js → authui-display-BM_F3-5e.js} +473 -499
- package/dist/authui-display-BM_F3-5e.js.map +1 -0
- package/dist/{authui-display-aWNht0cW.cjs → authui-display-CMVHTNFz.cjs} +51 -51
- package/dist/authui-display-CMVHTNFz.cjs.map +1 -0
- package/dist/authui.cjs +1 -1
- package/dist/authui.js +2 -2
- package/dist/{chat-CEh6RygY.js → chat-BH_3e1jT.js} +793 -653
- package/dist/chat-BH_3e1jT.js.map +1 -0
- package/dist/{chat-C-gsskho.cjs → chat-ezUmd9II.cjs} +310 -287
- package/dist/chat-ezUmd9II.cjs.map +1 -0
- package/dist/chat-messages.d.ts +8 -1
- package/dist/chat.cjs +1 -1
- package/dist/chat.d.ts +1 -1
- package/dist/chat.js +1 -1
- package/dist/elements/authui.d.ts +0 -4
- package/dist/elements/chat.d.ts +46 -8
- package/dist/elements/uploader.d.ts +0 -6
- package/dist/files-4T62wkwj.cjs +77 -0
- package/dist/files-4T62wkwj.cjs.map +1 -0
- package/dist/{files-DDJWPzZW.js → files-DS-H-3yN.js} +56 -57
- package/dist/files-DS-H-3yN.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +4 -4
- package/dist/messages.d.ts +0 -2
- package/dist/singlebase-elements.min.js +2004 -1917
- package/dist/singlebase-elements.min.js.map +1 -1
- package/dist/upload-messages.d.ts +0 -1
- package/dist/{uploader-660JIgIN.cjs → uploader-COP8PkJ6.cjs} +7 -7
- package/dist/uploader-COP8PkJ6.cjs.map +1 -0
- package/dist/{uploader-vfczkX51.js → uploader-tdMU9Gxv.js} +235 -262
- package/dist/uploader-tdMU9Gxv.js.map +1 -0
- package/dist/uploader.cjs +1 -1
- package/dist/uploader.js +2 -2
- package/dist/utils/branding.d.ts +5 -5
- package/package.json +3 -3
- package/dist/authui-display-CKfGK5va.js.map +0 -1
- package/dist/authui-display-aWNht0cW.cjs.map +0 -1
- package/dist/chat-C-gsskho.cjs.map +0 -1
- package/dist/chat-CEh6RygY.js.map +0 -1
- package/dist/files-DDJWPzZW.js.map +0 -1
- package/dist/files-DyxcjZsx.cjs +0 -75
- package/dist/files-DyxcjZsx.cjs.map +0 -1
- package/dist/uploader-660JIgIN.cjs.map +0 -1
- package/dist/uploader-vfczkX51.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ts=Object.defineProperty;var Le=d=>{throw TypeError(d)};var es=(d,a,t)=>a in d?ts(d,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[a]=t;var p=(d,a,t)=>es(d,typeof a!="symbol"?a+"":a,t),Me=(d,a,t)=>a.has(d)||Le("Cannot "+t);var o=(d,a,t)=>(Me(d,a,"read from private field"),t?t.call(d):a.get(d)),l=(d,a,t)=>a.has(d)?Le("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(d):a.set(d,t),h=(d,a,t,e)=>(Me(d,a,"write to private field"),e?e.call(d,t):a.set(d,t),t);const i=require("lit"),r=require("lit/decorators.js"),E=require("lit/directives/if-defined.js"),y=require("@singlebase/singlebase-sdk"),je=require("./uploader-660JIgIN.cjs"),Ce=require("./files-DyxcjZsx.cjs"),S=require("@singlebase/core");class qe{constructor(a){p(this,"host");p(this,"client",null);p(this,"unsubscribe",null);p(this,"state",{status:"loading",session:null,user:null});this.host=a,a.addController(this)}bind(a){var t;a!==this.client&&((t=this.unsubscribe)==null||t.call(this),this.unsubscribe=null,this.client=a,a&&(this.state=a.getState(),this.unsubscribe=a.subscribe(e=>{this.state=e,this.host.requestUpdate()}),this.host.requestUpdate()))}hostDisconnected(){var a;(a=this.unsubscribe)==null||a.call(this),this.unsubscribe=null}}const Se={signInTitle:"Sign in",signUpTitle:"Create your account",forgotTitle:"Reset your password",verifyTitle:"Enter your code",otpTitle:"Sign in with a code",newPassTitle:"Choose a new password",inviteTitle:"You have been invited",signInSubEmailAndOauth:"Use your email or a connected provider.",signInSubEmailOnly:"Use your email address and password.",signInSubOauthOnly:"Continue with a connected provider.",signUpSub:"Free to start. No card required.",forgotSub:"We will email you a six-digit code to confirm it is you.",otpSub:"No password needed — we will email you a six-digit code.",inviteSub:"Set up your account to continue.",signInCta:"Sign in",signUpCta:"Create account",forgotCta:"Send code",verifyCta:"Verify code",otpCta:"Email me a code",newPassCta:"Save password",inviteCta:"Create account",continueCta:"Continue",backCta:"Back",emailMethodTitle:"Email",emailMethodTitleSignUp:"Email and password",emailMethodMeta:"Password or one-time code",emailMethodMetaSignUp:"Create with an address",emailMethodMetaOtp:"One-time code",oauthMethodTitle:"Single sign-on",oauthMethodMeta:"Google, GitHub, and more",fullNameLabel:"Full name",fullNamePlaceholder:"Ada Lovelace",emailLabel:"Email",emailPlaceholder:"you@company.com",passwordLabel:"Password",passwordPlaceholder:"••••••••",newPasswordLabel:"New password",newPasswordPlaceholder:"At least 10 characters",confirmPasswordLabel:"Confirm password",confirmPasswordPlaceholder:"Repeat it",currentPasswordLabel:"Current password",firstNameLabel:"First name",firstNamePlaceholder:"Ada",lastNameLabel:"Last name",lastNamePlaceholder:"Lovelace",phoneLabel:"Phone number",phonePlaceholder:"+1 (555) 000-0000",invitedEmailLabel:"Invited email",forgotLink:"Forgot?",otpInsteadLink:"Email me a one-time code instead",footTextSignIn:"New here?",footActionSignIn:"Create an account",footTextSignUp:"Already have an account?",footActionSignUp:"Sign in",resendQuestion:"Did not get it?",resendCta:"Resend code",oauthPrimaryLabel:"Continue with Google",oauthContinueWith:"Continue with",blockedTitleDisabled:"Sign-in is turned off",blockedTitleUnavailable:"Sign-in unavailable",blockedBodyDisabled:"Authentication is currently disabled for this application.",blockedBodyUnavailable:"No sign-in methods are enabled for this application.",blockedHint:"Contact the site owner if you think this is a mistake.",signOutCta:"Sign out",addPhotoLink:"Add photo",changePhotoLink:"Change",photoUploading:"Uploading…",photoUpdated:"Photo updated",editingLabel:"Editing",uploadPhotoCta:"Upload photo",replacePhotoCta:"Replace photo",photoHint:"PNG or JPG, up to 2 MB.",doneCta:"Done",cancelCta:"Cancel",editAccountCta:"Edit account",saveChangesCta:"Save changes",emailChangeHint:"We will send a verification link to the new address.",passwordSectionTitle:"Password",passwordChangedHint:"Last changed three months ago.",changePasswordCta:"Change password",updatePasswordCta:"Update password",twoFaTitle:"Two-factor authentication",twoFaHintOff:"Add a second step when signing in.",twoFaHintOn:"Enabled with an authenticator app.",twoFaScanHint:"Scan with your authenticator app, then enter the 6-digit code.",connectedTitle:"Connected accounts",connectedHint:"Sign in with any provider you connect here.",addAnotherLabel:"Add another",disconnectCta:"Disconnect",notConnectedLabel:"Not connected",deleteAccountCta:"Delete account",deleteAccountConfirmCta:"Permanently delete account",deletePanelBody:"This removes your profile, sessions and connected providers. It cannot be undone.",deleteConfirmLabel:"Type DELETE to confirm",deleteConfirmPlaceholder:"DELETE",savedNote:"Saved",passwordUpdatedNote:"Password updated",changeEmailTitle:"Email",newEmailLabel:"New email",changeEmailCta:"Send verification code",changeUsernameTitle:"Username",newUsernameLabel:"New username",changeUsernameCta:"Send verification code",genericErrorMessage:"Something went wrong. Please try again.",rateLimitedMessage:"Too many attempts. Try again in 5 minutes or reset your password.",codeSentNeutral:"If an eligible account exists, a code has been sent.",invalidEmailError:"Enter a valid email address.",requiredError:"This cannot be empty.",passwordMinError:"Use at least 10 characters.",passwordMatchError:"Both passwords must match.",codeIncompleteError:"Enter all six digits.",invalidPhoneError:"Enter a valid phone number.",notYetSupported:"Not yet supported",alreadySignedInTitle:"You are already signed in",alreadySignedInSub:"Continue where you left off, or sign out to use another account.",alreadySignedInSubPrefix:"Signed in as",continueHint:"Continuing takes you to your account.",consentPrefix:"By continuing you agree to our",consentJoin:"and",termsLabel:"Terms",privacyLabel:"Privacy Policy",emailUnchangedError:"That is already your email address.",emailUpdatedNote:"Email updated",changeEmailCtaShort:"Change email",changeEmailHint:"We will send a code to your current address to confirm it is you.",changeEmailConfirmHint:"Enter the code we sent, and your email becomes",changeEmailElsewhereHint:"Your email is changed below, with a verification step.",confirmChangeCta:"Confirm change",codeLabel:"Verification code",brandingLabel:"Auth by Singlebase",linkRequiresSignIn:"Sign in first, then link a provider.",oauthCallbackTitle:"Finishing sign-in",oauthCallbackSub:"One moment while we complete your sign-in.",oauthDenied:"Sign-in was cancelled or denied."};function He(d){return d?{...Se,...d}:Se}var ss=Object.defineProperty,is=Object.getOwnPropertyDescriptor,C=(d,a,t,e)=>{for(var s=is(a,t),n=d.length-1,c;n>=0;n--)(c=d[n])&&(s=c(a,t,s)||s);return s&&ss(a,t,s),s},A,k,_,O,T,x;class f extends i.LitElement{constructor(){super(...arguments);l(this,A,null);l(this,k,{});l(this,_);l(this,O);l(this,T);l(this,x);p(this,"auth",new qe(this));p(this,"appliedConfig",new Set)}get client(){return o(this,A)}set client(t){h(this,A,t)}get messages(){return o(this,k)}set messages(t){h(this,k,t)}get theme(){return o(this,_)}set theme(t){h(this,_,t)}get density(){return o(this,O)}set density(t){h(this,O,t)}get fieldStyle(){return o(this,T)}set fieldStyle(t){h(this,T,t)}get radius(){return o(this,x)}set radius(t){h(this,x,t)}get resolvedClient(){var t;return this.client?this.client:((t=S.getDefaultClient())==null?void 0:t.auth)??null}get uiConfig(){var t;return((t=this.resolvedClient)==null?void 0:t.authui)??null}get msg(){var e;const t=(e=this.uiConfig)==null?void 0:e.messages;return He(t?{...t,...this.messages}:this.messages)}applyUIConfig(){const t=this.uiConfig;if(t){for(const e of S.AUTHUI_PROP_KEYS){const s=t[e];s!==void 0&&e in this&&(this.hasAttribute(S.authUIAttributeFor(e))||this.appliedConfig.has(e)||(this.appliedConfig.add(e),this[e]=s))}for(const[e,s]of Object.entries(t.tokens??{}))e.startsWith("--")&&(this.style.getPropertyValue(e)||this.style.setProperty(e,s))}}isAuthenticated(){var t;return((t=this.resolvedClient)==null?void 0:t.isAuthenticated())??!1}getUser(){var t;return((t=this.resolvedClient)==null?void 0:t.getUser())??null}async refreshSession(){var t;return(t=this.resolvedClient)==null?void 0:t.refreshSession()}async logout(){var t;await((t=this.resolvedClient)==null?void 0:t.logout())}willUpdate(t){super.willUpdate(t),this.auth.bind(this.resolvedClient),this.applyUIConfig()}}A=new WeakMap,k=new WeakMap,_=new WeakMap,O=new WeakMap,T=new WeakMap,x=new WeakMap,p(f,"styles",[Ce.tokenDefaults,je.sharedStyles]);C([r.property({attribute:!1})],f.prototype,"client");C([r.property({attribute:!1})],f.prototype,"messages");C([r.property({reflect:!0})],f.prototype,"theme");C([r.property({reflect:!0})],f.prototype,"density");C([r.property({reflect:!0,attribute:"field-style"})],f.prototype,"fieldStyle");C([r.property({reflect:!0})],f.prototype,"radius");class we{constructor(a){p(this,"host");p(this,"client",null);p(this,"cache",new WeakMap);p(this,"settings",null);p(this,"error",null);this.host=a,a.addController(this)}hostConnected(){}load(a,t){if(t){this.settings=t;return}if(!a||a===this.client)return;this.client=a;let e=this.cache.get(a);e||(e=a.getSettings(),this.cache.set(a,e)),e.then(s=>{this.settings=s,this.error=null,this.host.requestUpdate()}).catch(s=>{this.error=s,this.host.requestUpdate()})}}const ns=["load","success","error","signin","signup","signout","session","account-updated","password-change","email-change","username-change","expired","navigate","goto"],as={load:"auth:ready",signin:"auth:signin",signup:"auth:signup",session:"auth:session","account-updated":"auth:profile-update",signout:"auth:signout",error:"auth:error",navigate:"auth:navigate"};function Ne(d){return"on"+d.replace(/(^|-)([a-z])/g,(a,t,e)=>e.toUpperCase())}class rs{constructor(a){p(this,"unsubscribes",[]);p(this,"client",null);this.host=a,a.addController(this)}bind(a){a!==this.client&&(this.release(),this.client=a,a&&(this.unsubscribes=ns.map(t=>a.on(t,e=>this.publish(t,e)))))}publish(a,t){const e=this.host[Ne(a)];if(typeof e=="function")try{e.call(this.host,t)}catch(c){console.error(`[singlebase] ${Ne(a)} threw:`,c)}const s={detail:t,bubbles:!0,composed:!0};this.host.dispatchEvent(new CustomEvent(`singlebase-${a}`,s));const n=as[a];n&&this.host.dispatchEvent(new CustomEvent(n,s))}release(){this.unsubscribes.forEach(a=>a()),this.unsubscribes=[]}hostDisconnected(){this.release(),this.client=null}}var os=Object.defineProperty,ls=Object.getOwnPropertyDescriptor,Pe=(d,a,t,e)=>{for(var s=ls(a,t),n=d.length-1,c;n>=0;n--)(c=d[n])&&(s=c(a,t,s)||s);return s&&os(a,t,s),s},U,L,M;class fe extends f{constructor(){super(...arguments);l(this,U,"idle");l(this,L,"");l(this,M,"");p(this,"abortController",null)}get phase(){return o(this,U)}set phase(t){h(this,U,t)}get formError(){return o(this,L)}set formError(t){h(this,L,t)}get noticeMessage(){return o(this,M)}set noticeMessage(t){h(this,M,t)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this.abortController)==null||t.abort()}get signal(){var t;return(t=this.abortController)==null||t.abort(),this.abortController=new AbortController,this.abortController.signal}async run(t){this.phase="submitting",this.formError="";try{await t(),this.phase="success"}catch(e){if(this.isAbortError(e))return;this.phase="error",this.formError=this.describeError(e)}}isAbortError(t){return t instanceof DOMException&&t.name==="AbortError"}describeError(t){if(t instanceof y.SinglebaseAuthError){const e=y.mapErrorToHint(t.code);return e==="disable_retry_show_rate_limited"?this.msg.rateLimitedMessage:e==="generic_credentials_message"?this.msg.genericErrorMessage:this.msg.genericErrorMessage}return this.msg.genericErrorMessage}get submitting(){return this.phase==="submitting"}renderStatus(){return i.html`
|
|
1
|
+
"use strict";var Xe=Object.defineProperty;var xe=o=>{throw TypeError(o)};var Ze=(o,n,t)=>n in o?Xe(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t;var p=(o,n,t)=>Ze(o,typeof n!="symbol"?n+"":n,t),Ue=(o,n,t)=>n.has(o)||xe("Cannot "+t);var l=(o,n,t)=>(Ue(o,n,"read from private field"),t?t.call(o):n.get(o)),h=(o,n,t)=>n.has(o)?xe("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(o):n.set(o,t),c=(o,n,t,e)=>(Ue(o,n,"write to private field"),e?e.call(o,t):n.set(o,t),t);const i=require("lit"),r=require("lit/decorators.js"),E=require("lit/directives/if-defined.js"),y=require("@singlebase/singlebase-sdk"),Be=require("./uploader-COP8PkJ6.cjs"),$e=require("./files-4T62wkwj.cjs"),S=require("@singlebase/core");class Re{constructor(n){p(this,"host");p(this,"client",null);p(this,"unsubscribe",null);p(this,"state",{status:"loading",session:null,user:null});this.host=n,n.addController(this)}bind(n){var t;n!==this.client&&((t=this.unsubscribe)==null||t.call(this),this.unsubscribe=null,this.client=n,n&&(this.state=n.getState(),this.unsubscribe=n.subscribe(e=>{this.state=e,this.host.requestUpdate()}),this.host.requestUpdate()))}hostDisconnected(){var n;(n=this.unsubscribe)==null||n.call(this),this.unsubscribe=null}}const we={signInTitle:"Sign in",signUpTitle:"Create your account",forgotTitle:"Reset your password",verifyTitle:"Enter your code",otpTitle:"Sign in with a code",newPassTitle:"Choose a new password",inviteTitle:"You have been invited",signInSubEmailAndOauth:"Use your email or a connected provider.",signInSubEmailOnly:"Use your email address and password.",signInSubOauthOnly:"Continue with a connected provider.",signUpSub:"Free to start. No card required.",forgotSub:"We will email you a six-digit code to confirm it is you.",otpSub:"No password needed — we will email you a six-digit code.",inviteSub:"Set up your account to continue.",signInCta:"Sign in",signUpCta:"Create account",forgotCta:"Send code",verifyCta:"Verify code",otpCta:"Email me a code",newPassCta:"Save password",inviteCta:"Create account",continueCta:"Continue",backCta:"Back",emailMethodTitle:"Email",emailMethodTitleSignUp:"Email and password",emailMethodMeta:"Password or one-time code",emailMethodMetaSignUp:"Create with an address",emailMethodMetaOtp:"One-time code",oauthMethodTitle:"Single sign-on",oauthMethodMeta:"Google, GitHub, and more",fullNameLabel:"Full name",fullNamePlaceholder:"Ada Lovelace",emailLabel:"Email",emailPlaceholder:"you@company.com",passwordLabel:"Password",passwordPlaceholder:"••••••••",newPasswordLabel:"New password",newPasswordPlaceholder:"At least 10 characters",confirmPasswordLabel:"Confirm password",confirmPasswordPlaceholder:"Repeat it",currentPasswordLabel:"Current password",firstNameLabel:"First name",firstNamePlaceholder:"Ada",lastNameLabel:"Last name",lastNamePlaceholder:"Lovelace",phoneLabel:"Phone number",phonePlaceholder:"+1 (555) 000-0000",invitedEmailLabel:"Invited email",forgotLink:"Forgot?",otpInsteadLink:"Email me a one-time code instead",footTextSignIn:"New here?",footActionSignIn:"Create an account",footTextSignUp:"Already have an account?",footActionSignUp:"Sign in",resendQuestion:"Did not get it?",resendCta:"Resend code",oauthPrimaryLabel:"Continue with Google",oauthContinueWith:"Continue with",blockedTitleDisabled:"Sign-in is turned off",blockedTitleUnavailable:"Sign-in unavailable",blockedBodyDisabled:"Authentication is currently disabled for this application.",blockedBodyUnavailable:"No sign-in methods are enabled for this application.",blockedHint:"Contact the site owner if you think this is a mistake.",signOutCta:"Sign out",addPhotoLink:"Add photo",changePhotoLink:"Change",photoUploading:"Uploading…",photoUpdated:"Photo updated",editingLabel:"Editing",uploadPhotoCta:"Upload photo",replacePhotoCta:"Replace photo",photoHint:"PNG or JPG, up to 2 MB.",doneCta:"Done",cancelCta:"Cancel",editAccountCta:"Edit account",saveChangesCta:"Save changes",emailChangeHint:"We will send a verification link to the new address.",passwordSectionTitle:"Password",passwordChangedHint:"Last changed three months ago.",changePasswordCta:"Change password",updatePasswordCta:"Update password",twoFaTitle:"Two-factor authentication",twoFaHintOff:"Add a second step when signing in.",twoFaHintOn:"Enabled with an authenticator app.",twoFaScanHint:"Scan with your authenticator app, then enter the 6-digit code.",connectedTitle:"Connected accounts",connectedHint:"Sign in with any provider you connect here.",addAnotherLabel:"Add another",disconnectCta:"Disconnect",notConnectedLabel:"Not connected",deleteAccountCta:"Delete account",deleteAccountConfirmCta:"Permanently delete account",deletePanelBody:"This removes your profile, sessions and connected providers. It cannot be undone.",deleteConfirmLabel:"Type DELETE to confirm",deleteConfirmPlaceholder:"DELETE",savedNote:"Saved",passwordUpdatedNote:"Password updated",changeEmailTitle:"Email",newEmailLabel:"New email",changeEmailCta:"Send verification code",changeUsernameTitle:"Username",newUsernameLabel:"New username",changeUsernameCta:"Send verification code",genericErrorMessage:"Something went wrong. Please try again.",rateLimitedMessage:"Too many attempts. Try again in 5 minutes or reset your password.",codeSentNeutral:"If an eligible account exists, a code has been sent.",invalidEmailError:"Enter a valid email address.",requiredError:"This cannot be empty.",passwordMinError:"Use at least 10 characters.",passwordMatchError:"Both passwords must match.",codeIncompleteError:"Enter all six digits.",invalidPhoneError:"Enter a valid phone number.",notYetSupported:"Not yet supported",alreadySignedInTitle:"You are already signed in",alreadySignedInSub:"Continue where you left off, or sign out to use another account.",alreadySignedInSubPrefix:"Signed in as",continueHint:"Continuing takes you to your account.",consentPrefix:"By continuing you agree to our",consentJoin:"and",termsLabel:"Terms",privacyLabel:"Privacy Policy",emailUnchangedError:"That is already your email address.",emailUpdatedNote:"Email updated",changeEmailCtaShort:"Change email",changeEmailHint:"We will send a code to your current address to confirm it is you.",changeEmailConfirmHint:"Enter the code we sent, and your email becomes",changeEmailElsewhereHint:"Your email is changed below, with a verification step.",confirmChangeCta:"Confirm change",codeLabel:"Verification code",linkRequiresSignIn:"Sign in first, then link a provider.",oauthCallbackTitle:"Finishing sign-in",oauthCallbackSub:"One moment while we complete your sign-in.",oauthDenied:"Sign-in was cancelled or denied."};function je(o){return o?{...we,...o}:we}var ts=Object.defineProperty,es=Object.getOwnPropertyDescriptor,C=(o,n,t,e)=>{for(var s=es(n,t),a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=d(n,t,s)||s);return s&&ts(n,t,s),s},A,k,_,O,T,x;class f extends i.LitElement{constructor(){super(...arguments);h(this,A,null);h(this,k,{});h(this,_);h(this,O);h(this,T);h(this,x);p(this,"auth",new Re(this));p(this,"appliedConfig",new Set)}get client(){return l(this,A)}set client(t){c(this,A,t)}get messages(){return l(this,k)}set messages(t){c(this,k,t)}get theme(){return l(this,_)}set theme(t){c(this,_,t)}get density(){return l(this,O)}set density(t){c(this,O,t)}get fieldStyle(){return l(this,T)}set fieldStyle(t){c(this,T,t)}get radius(){return l(this,x)}set radius(t){c(this,x,t)}get resolvedClient(){var t;return this.client?this.client:((t=S.getDefaultClient())==null?void 0:t.auth)??null}get uiConfig(){var t;return((t=this.resolvedClient)==null?void 0:t.authui)??null}get msg(){var e;const t=(e=this.uiConfig)==null?void 0:e.messages;return je(t?{...t,...this.messages}:this.messages)}applyUIConfig(){const t=this.uiConfig;if(t){for(const e of S.AUTHUI_PROP_KEYS){const s=t[e];s!==void 0&&e in this&&(this.hasAttribute(S.authUIAttributeFor(e))||this.appliedConfig.has(e)||(this.appliedConfig.add(e),this[e]=s))}for(const[e,s]of Object.entries(t.tokens??{}))e.startsWith("--")&&(this.style.getPropertyValue(e)||this.style.setProperty(e,s))}}isAuthenticated(){var t;return((t=this.resolvedClient)==null?void 0:t.isAuthenticated())??!1}getUser(){var t;return((t=this.resolvedClient)==null?void 0:t.getUser())??null}async refreshSession(){var t;return(t=this.resolvedClient)==null?void 0:t.refreshSession()}async logout(){var t;await((t=this.resolvedClient)==null?void 0:t.logout())}willUpdate(t){super.willUpdate(t),this.auth.bind(this.resolvedClient),this.applyUIConfig()}}A=new WeakMap,k=new WeakMap,_=new WeakMap,O=new WeakMap,T=new WeakMap,x=new WeakMap,p(f,"styles",[$e.tokenDefaults,Be.sharedStyles]);C([r.property({attribute:!1})],f.prototype,"client");C([r.property({attribute:!1})],f.prototype,"messages");C([r.property({reflect:!0})],f.prototype,"theme");C([r.property({reflect:!0})],f.prototype,"density");C([r.property({reflect:!0,attribute:"field-style"})],f.prototype,"fieldStyle");C([r.property({reflect:!0})],f.prototype,"radius");class fe{constructor(n){p(this,"host");p(this,"client",null);p(this,"cache",new WeakMap);p(this,"settings",null);p(this,"error",null);this.host=n,n.addController(this)}hostConnected(){}load(n,t){if(t){this.settings=t;return}if(!n||n===this.client)return;this.client=n;let e=this.cache.get(n);e||(e=n.getSettings(),this.cache.set(n,e)),e.then(s=>{this.settings=s,this.error=null,this.host.requestUpdate()}).catch(s=>{this.error=s,this.host.requestUpdate()})}}const ss=["load","success","error","signin","signup","signout","session","account-updated","password-change","email-change","username-change","expired","navigate","goto"],is={load:"auth:ready",signin:"auth:signin",signup:"auth:signup",session:"auth:session","account-updated":"auth:profile-update",signout:"auth:signout",error:"auth:error",navigate:"auth:navigate"};function Le(o){return"on"+o.replace(/(^|-)([a-z])/g,(n,t,e)=>e.toUpperCase())}class as{constructor(n){p(this,"unsubscribes",[]);p(this,"client",null);this.host=n,n.addController(this)}bind(n){n!==this.client&&(this.release(),this.client=n,n&&(this.unsubscribes=ss.map(t=>n.on(t,e=>this.publish(t,e)))))}publish(n,t){const e=this.host[Le(n)];if(typeof e=="function")try{e.call(this.host,t)}catch(d){console.error(`[singlebase] ${Le(n)} threw:`,d)}const s={detail:t,bubbles:!0,composed:!0};this.host.dispatchEvent(new CustomEvent(`singlebase-${n}`,s));const a=is[n];a&&this.host.dispatchEvent(new CustomEvent(a,s))}release(){this.unsubscribes.forEach(n=>n()),this.unsubscribes=[]}hostDisconnected(){this.release(),this.client=null}}var ns=Object.defineProperty,rs=Object.getOwnPropertyDescriptor,Ee=(o,n,t,e)=>{for(var s=rs(n,t),a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=d(n,t,s)||s);return s&&ns(n,t,s),s},U,L,M;class me extends f{constructor(){super(...arguments);h(this,U,"idle");h(this,L,"");h(this,M,"");p(this,"abortController",null)}get phase(){return l(this,U)}set phase(t){c(this,U,t)}get formError(){return l(this,L)}set formError(t){c(this,L,t)}get noticeMessage(){return l(this,M)}set noticeMessage(t){c(this,M,t)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this.abortController)==null||t.abort()}get signal(){var t;return(t=this.abortController)==null||t.abort(),this.abortController=new AbortController,this.abortController.signal}async run(t){this.phase="submitting",this.formError="";try{await t(),this.phase="success"}catch(e){if(this.isAbortError(e))return;this.phase="error",this.formError=this.describeError(e)}}isAbortError(t){return t instanceof DOMException&&t.name==="AbortError"}describeError(t){if(t instanceof y.SinglebaseAuthError){const e=y.mapErrorToHint(t.code);return e==="disable_retry_show_rate_limited"?this.msg.rateLimitedMessage:e==="generic_credentials_message"?this.msg.genericErrorMessage:this.msg.genericErrorMessage}return this.msg.genericErrorMessage}get submitting(){return this.phase==="submitting"}renderStatus(){return i.html`
|
|
2
2
|
<div
|
|
3
3
|
role="status"
|
|
4
4
|
aria-live="polite"
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
</div>
|
|
10
10
|
${this.formError?i.html`<p class="banner" role="alert">${this.formError}</p>`:null}
|
|
11
11
|
${this.noticeMessage?i.html`<p class="notice" role="status">${this.noticeMessage}</p>`:null}
|
|
12
|
-
`}}U=new WeakMap,L=new WeakMap,M=new WeakMap;
|
|
12
|
+
`}}U=new WeakMap,L=new WeakMap,M=new WeakMap;Ee([r.state()],me.prototype,"phase");Ee([r.state()],me.prototype,"formError");Ee([r.state()],me.prototype,"noticeMessage");function Ce(o){return[o==null?void 0:o.first_name,o==null?void 0:o.last_name].filter(Boolean).join(" ").trim()}function Pe(o){const n=Ce(o);if(n)return n.split(/\s+/).map(e=>e[0]).join("").slice(0,2).toUpperCase();const t=(o==null?void 0:o.email)??"";return t?t[0].toUpperCase():"·"}var os=Object.defineProperty,ls=Object.getOwnPropertyDescriptor,g=(o,n,t,e)=>{for(var s=e>1?void 0:e?ls(n,t):n,a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&os(n,t,s),s};const hs={profile_photo:!0},cs=".jpg,.jpeg,.png,.webp,image/jpeg,image/png,image/webp";var N,D,I,F,B,R,j,q,H,G,V,K,Y,W,z,J,Q,X,Z,tt,et,st,it,at,nt,rt,Me;exports.SinglebaseAccountScreen=(Me=class extends me{constructor(){super(...arguments);h(this,N,"");h(this,D,"");h(this,I,null);h(this,F,"singlebase-oauth-nonce");h(this,B,"");h(this,R,"");h(this,j,!1);h(this,q,"");h(this,H,"");h(this,G,"");h(this,V,"");h(this,K,"");h(this,Y,0);h(this,W,"");h(this,z,"");h(this,J,"");h(this,Q,"");h(this,X,"");h(this,Z,"request");h(this,tt,"");h(this,et,"");h(this,st,"");h(this,it,"");h(this,at,"");h(this,nt,"");h(this,rt,"");p(this,"settingsCtl",new fe(this));p(this,"flashTimer");p(this,"uidBase",`sb-acct-${Math.random().toString(36).slice(2,8)}`);p(this,"uploadClientFor",null);p(this,"uploadClientCache",null);p(this,"onChoosePhoto",()=>{var t;this.formError="",(t=this.renderRoot.querySelector("singlebase-uploader"))==null||t.open()});p(this,"onPhotoSelected",()=>{this.photoBusy=!0,this.toast=""});p(this,"onPhotoUploaded",async t=>{var a;const{completed:e,failed:s}=t.detail;try{e.length?(await((a=this.resolvedClient)==null?void 0:a.getAccount()),this.photoFailed="",this.toast=this.msg.photoUpdated):s.length&&(this.formError=s[0].error||this.msg.genericErrorMessage)}catch(d){this.formError=this.describeError(d)}finally{this.photoBusy=!1}});p(this,"onPhotoProblem",t=>{this.photoBusy=!1,this.formError=t.detail.message})}get logoText(){return l(this,N)}set logoText(t){c(this,N,t)}get logoUrl(){return l(this,D)}set logoUrl(t){c(this,D,t)}get settings(){return l(this,I)}set settings(t){c(this,I,t)}get nonceStorageKey(){return l(this,F)}set nonceStorageKey(t){c(this,F,t)}get editMode(){return l(this,B)}set editMode(t){c(this,B,t)}get toast(){return l(this,R)}set toast(t){c(this,R,t)}get photoBusy(){return l(this,j)}set photoBusy(t){c(this,j,t)}get photoFailed(){return l(this,q)}set photoFailed(t){c(this,q,t)}get profileSaved(){return l(this,H)}set profileSaved(t){c(this,H,t)}get passSaved(){return l(this,G)}set passSaved(t){c(this,G,t)}get profileError(){return l(this,V)}set profileError(t){c(this,V,t)}get newPassError(){return l(this,K)}set newPassError(t){c(this,K,t)}get deleteStage(){return l(this,Y)}set deleteStage(t){c(this,Y,t)}get confirmText(){return l(this,W)}set confirmText(t){c(this,W,t)}get dFirst(){return l(this,z)}set dFirst(t){c(this,z,t)}get dLast(){return l(this,J)}set dLast(t){c(this,J,t)}get dPhone(){return l(this,Q)}set dPhone(t){c(this,Q,t)}get dEmail(){return l(this,X)}set dEmail(t){c(this,X,t)}get emailStep(){return l(this,Z)}set emailStep(t){c(this,Z,t)}get dNewEmail(){return l(this,tt)}set dNewEmail(t){c(this,tt,t)}get emailCode(){return l(this,et)}set emailCode(t){c(this,et,t)}get emailError(){return l(this,st)}set emailError(t){c(this,st,t)}get emailSaved(){return l(this,it)}set emailSaved(t){c(this,it,t)}get curPass(){return l(this,at)}set curPass(t){c(this,at,t)}get newPass(){return l(this,nt)}set newPass(t){c(this,nt,t)}get confirmPass(){return l(this,rt)}set confirmPass(t){c(this,rt,t)}uid(t){return`${this.uidBase}-${t}`}willUpdate(t){super.willUpdate(t),this.settingsCtl.load(this.resolvedClient,this.settings)}disconnectedCallback(){super.disconnectedCallback(),clearTimeout(this.flashTimer)}flash(t,e){this[t]=e,clearTimeout(this.flashTimer),this.flashTimer=setTimeout(()=>{this[t]=""},2600)}renderLogo(){return this.logoUrl?i.html`<img
|
|
13
13
|
part="logo"
|
|
14
14
|
src=${this.logoUrl}
|
|
15
15
|
alt=${this.logoText}
|
|
16
16
|
style="display:block;align-self:flex-start;height:var(--sb-logo-height,20px);width:auto;max-width:100%"
|
|
17
|
-
/>`:this.logoText?i.html`<div class="logo-dot" part="logo">${this.logoText}</div>`:i.nothing}get user(){const t=this.auth.state;return t.status==="authenticated"?t.user:null}get fullName(){return
|
|
17
|
+
/>`:this.logoText?i.html`<div class="logo-dot" part="logo">${this.logoText}</div>`:i.nothing}get user(){const t=this.auth.state;return t.status==="authenticated"?t.user:null}get fullName(){return Ce(this.user)}get initials(){return Pe(this.user)}get uploadClient(){const t=this.resolvedClient;return t?(this.uploadClientFor!==t&&(this.uploadClientFor=t,this.uploadClientCache={files:y.createFilesUploadApi(t.dispatcher)}),this.uploadClientCache):null}startProfileEdit(){const t=this.user;t&&(this.dFirst=t.first_name??"",this.dLast=t.last_name??"",this.dPhone=t.phone??"",this.dEmail=t.email,this.profileError="",this.profileSaved="",this.passSaved="",this.toast="",this.editMode="profile")}async onSaveProfile(){const t=this.resolvedClient;if(t){if(!this.dFirst.trim()||!this.dLast.trim()){this.profileError="First and last name cannot be empty.";return}if(this.dPhone.replace(/\D/g,"").length<7){this.profileError=this.msg.invalidPhoneError;return}await this.run(async()=>{await t.updateAccount({first_name:this.dFirst,last_name:this.dLast,phone:this.dPhone},this.signal),this.editMode="",this.flash("profileSaved",this.msg.savedNote)})}}startPassEdit(){this.curPass="",this.newPass="",this.confirmPass="",this.newPassError="",this.passSaved="",this.profileSaved="",this.toast="",this.editMode="password"}async onChangePass(){const t=this.resolvedClient;if(t){if(!this.curPass){this.newPassError="Enter your current password.";return}if(this.newPass.length<10){this.newPassError=this.msg.passwordMinError;return}if(this.newPass!==this.confirmPass){this.newPassError=this.msg.passwordMatchError;return}await this.run(async()=>{await t.changePassword({password:this.newPass},this.signal),this.editMode="",this.curPass="",this.newPass="",this.confirmPass="",this.flash("passSaved",this.msg.passwordUpdatedNote)})}}startEmailEdit(){this.emailStep="request",this.dNewEmail="",this.emailCode="",this.emailError="",this.emailSaved="",this.toast="",this.editMode="email"}async onRequestEmailCode(){const t=this.resolvedClient;if(!(!t||!this.user)){if(!this.dNewEmail.includes("@")){this.emailError=this.msg.invalidEmailError;return}if(this.dNewEmail.toLowerCase()===this.user.email.toLowerCase()){this.emailError=this.msg.emailUnchangedError;return}await this.run(async()=>{await t.requestCode({email:this.user.email,purpose:"email_change"},this.signal),this.emailStep="confirm",this.emailError=""})}}async onConfirmEmailChange(){const t=this.resolvedClient;if(!(!t||!this.user)){if(this.emailCode.length<6){this.emailError=this.msg.codeIncompleteError;return}await this.run(async()=>{await t.changeEmail({email:this.user.email,code:this.emailCode,new_email:this.dNewEmail},this.signal),this.editMode="",this.emailCode="",this.dNewEmail="",this.flash("emailSaved",this.msg.emailUpdatedNote)})}}renderEmailSection(){var s;const t=this.editMode!=="email",e=this.editMode!==""&&this.editMode!=="email";return i.html`
|
|
18
18
|
<div class="rule"></div>
|
|
19
19
|
<div class="section">
|
|
20
20
|
<h3 class="sec-title">${this.msg.changeEmailTitle}</h3>
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
placeholder=${this.msg.emailPlaceholder}
|
|
46
46
|
aria-invalid=${this.emailError?"true":"false"}
|
|
47
47
|
?disabled=${this.submitting}
|
|
48
|
-
@input=${
|
|
48
|
+
@input=${a=>{this.dNewEmail=a.target.value,this.emailError=""}}
|
|
49
49
|
/>
|
|
50
50
|
<p class="hint">${this.msg.changeEmailHint}</p>
|
|
51
51
|
</div>
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
placeholder="000000"
|
|
85
85
|
aria-invalid=${this.emailError?"true":"false"}
|
|
86
86
|
?disabled=${this.submitting}
|
|
87
|
-
@input=${
|
|
87
|
+
@input=${a=>{this.emailCode=a.target.value.replace(/\D/g,"").slice(0,6),this.emailError=""}}
|
|
88
88
|
/>
|
|
89
89
|
<p class="hint">${this.msg.changeEmailConfirmHint} ${this.dNewEmail}</p>
|
|
90
90
|
</div>
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
</div>
|
|
111
111
|
`}
|
|
112
112
|
</div>
|
|
113
|
-
`}async onSignOut(){const t=this.resolvedClient;t&&await this.run(async()=>{await t.signOut()})}async onConnectProvider(t){const e=this.resolvedClient,s=this.auth.state;!e||s.status!=="authenticated"||await this.run(async()=>{var m;const
|
|
113
|
+
`}async onSignOut(){const t=this.resolvedClient;t&&await this.run(async()=>{await t.signOut()})}async onConnectProvider(t){const e=this.resolvedClient,s=this.auth.state;!e||s.status!=="authenticated"||await this.run(async()=>{var m;const a=await e.createOAuthNonce(this.signal);(m=globalThis.sessionStorage)==null||m.setItem(this.nonceStorageKey,a);const{oauth_redirect_url:d}=await e.startOAuth({provider:t,nonce:a,intent:"link",id_token:s.session.id_token,refresh_token:s.session.refresh_token},this.signal);globalThis.location.assign(d)})}get availableProviders(){const t=this.settings??this.settingsCtl.settings;if(!t||!t.oauth_settings.enabled)return[];const e={google:"G",github:"GH",linkedin:"in",facebook:"f"};return Object.entries(t.oauth_providers).filter(([,s])=>s.enabled).map(([s,a])=>({id:s,name:a.provider_name,mark:e[s]??a.provider_name.slice(0,2)}))}renderIdentity(){const t=this.user,e=this.editMode!==""&&this.editMode!=="avatar",s=t!=null&&t.profile_photo&&t.profile_photo!==this.photoFailed?t.profile_photo:"";return i.html`
|
|
114
114
|
<div class="acct-nav">
|
|
115
115
|
<div class="acct-who">
|
|
116
116
|
<div class="avatar-col">
|
|
@@ -136,9 +136,9 @@
|
|
|
136
136
|
view="button"
|
|
137
137
|
max-files="1"
|
|
138
138
|
branding="false"
|
|
139
|
-
accept=${
|
|
139
|
+
accept=${cs}
|
|
140
140
|
.client=${this.uploadClient}
|
|
141
|
-
.options=${
|
|
141
|
+
.options=${hs}
|
|
142
142
|
@singlebase-upload-selected=${this.onPhotoSelected}
|
|
143
143
|
@singlebase-upload-complete=${this.onPhotoUploaded}
|
|
144
144
|
@singlebase-upload-error=${this.onPhotoProblem}
|
|
@@ -154,13 +154,13 @@
|
|
|
154
154
|
${this.msg.signOutCta}
|
|
155
155
|
</button>
|
|
156
156
|
</div>
|
|
157
|
-
`}renderProfileSection(){const t=this.user;if(!t)return i.nothing;const e=this.editMode!=="profile",s=this.editMode!==""&&this.editMode!=="profile",
|
|
157
|
+
`}renderProfileSection(){const t=this.user;if(!t)return i.nothing;const e=this.editMode!=="profile",s=this.editMode!==""&&this.editMode!=="profile",a=[[this.msg.firstNameLabel,t.first_name||"—"],[this.msg.lastNameLabel,t.last_name||"—"],[this.msg.phoneLabel,t.phone||"—"],[this.msg.emailLabel,t.email||"—"]];return i.html`
|
|
158
158
|
<div class="section">
|
|
159
159
|
${e?i.html`
|
|
160
160
|
<div class="sum-list">
|
|
161
|
-
${
|
|
161
|
+
${a.map(([d,m])=>i.html`
|
|
162
162
|
<div class="sum-row">
|
|
163
|
-
<span class="sum-label">${
|
|
163
|
+
<span class="sum-label">${d}</span>
|
|
164
164
|
<span class="sum-value">${m}</span>
|
|
165
165
|
</div>
|
|
166
166
|
`)}
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
.value=${this.dFirst}
|
|
189
189
|
placeholder=${this.msg.firstNamePlaceholder}
|
|
190
190
|
?disabled=${this.submitting}
|
|
191
|
-
@input=${
|
|
191
|
+
@input=${d=>{this.dFirst=d.target.value,this.profileError=""}}
|
|
192
192
|
/>
|
|
193
193
|
</div>
|
|
194
194
|
<div class="field">
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
.value=${this.dLast}
|
|
201
201
|
placeholder=${this.msg.lastNamePlaceholder}
|
|
202
202
|
?disabled=${this.submitting}
|
|
203
|
-
@input=${
|
|
203
|
+
@input=${d=>{this.dLast=d.target.value,this.profileError=""}}
|
|
204
204
|
/>
|
|
205
205
|
</div>
|
|
206
206
|
</div>
|
|
@@ -213,7 +213,7 @@
|
|
|
213
213
|
.value=${this.dPhone}
|
|
214
214
|
placeholder=${this.msg.phonePlaceholder}
|
|
215
215
|
?disabled=${this.submitting}
|
|
216
|
-
@input=${
|
|
216
|
+
@input=${d=>{this.dPhone=d.target.value,this.profileError=""}}
|
|
217
217
|
/>
|
|
218
218
|
</div>
|
|
219
219
|
<div class="field">
|
|
@@ -404,7 +404,7 @@
|
|
|
404
404
|
${i.nothing}
|
|
405
405
|
</div>
|
|
406
406
|
</div>
|
|
407
|
-
`:i.html`<p class="disabled-note">Not signed in.</p>`}},N=new WeakMap,D=new WeakMap,I=new WeakMap,F=new WeakMap,B=new WeakMap,R=new WeakMap,j=new WeakMap,q=new WeakMap,H=new WeakMap,G=new WeakMap,V=new WeakMap,K=new WeakMap,Y=new WeakMap,W=new WeakMap,z=new WeakMap,J=new WeakMap,Q=new WeakMap,X=new WeakMap,Z=new WeakMap,tt=new WeakMap,et=new WeakMap,st=new WeakMap,it=new WeakMap,
|
|
407
|
+
`:i.html`<p class="disabled-note">Not signed in.</p>`}},N=new WeakMap,D=new WeakMap,I=new WeakMap,F=new WeakMap,B=new WeakMap,R=new WeakMap,j=new WeakMap,q=new WeakMap,H=new WeakMap,G=new WeakMap,V=new WeakMap,K=new WeakMap,Y=new WeakMap,W=new WeakMap,z=new WeakMap,J=new WeakMap,Q=new WeakMap,X=new WeakMap,Z=new WeakMap,tt=new WeakMap,et=new WeakMap,st=new WeakMap,it=new WeakMap,at=new WeakMap,nt=new WeakMap,rt=new WeakMap,Me);g([r.property({attribute:"logo-text"})],exports.SinglebaseAccountScreen.prototype,"logoText",1);g([r.property({attribute:"logo-url"})],exports.SinglebaseAccountScreen.prototype,"logoUrl",1);g([r.property({attribute:!1})],exports.SinglebaseAccountScreen.prototype,"settings",1);g([r.property({attribute:"nonce-storage-key"})],exports.SinglebaseAccountScreen.prototype,"nonceStorageKey",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"editMode",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"toast",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"photoBusy",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"photoFailed",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"profileSaved",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"passSaved",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"profileError",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"newPassError",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"deleteStage",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"confirmText",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"dFirst",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"dLast",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"dPhone",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"dEmail",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"emailStep",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"dNewEmail",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"emailCode",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"emailError",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"emailSaved",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"curPass",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"newPass",1);g([r.state()],exports.SinglebaseAccountScreen.prototype,"confirmPass",1);exports.SinglebaseAccountScreen=g([r.customElement("singlebase-authui-account")],exports.SinglebaseAccountScreen);var ds=Object.defineProperty,us=Object.getOwnPropertyDescriptor,w=(o,n,t,e)=>{for(var s=e>1?void 0:e?us(n,t):n,a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&ds(n,t,s),s},ot,lt,ht,ct,dt,ut,pt,Ne;exports.SinglebaseAuthButtons=(Ne=class extends me{constructor(){super(...arguments);h(this,ot,"signout");h(this,lt,"signin");h(this,ht,"");h(this,ct,"");h(this,dt,!1);h(this,ut,null);h(this,pt,"singlebase-oauth-nonce");p(this,"settingsCtl",new fe(this))}get type(){return l(this,ot)}set type(t){c(this,ot,t)}get intent(){return l(this,lt)}set intent(t){c(this,lt,t)}get provider(){return l(this,ht)}set provider(t){c(this,ht,t)}get providerName(){return l(this,ct)}set providerName(t){c(this,ct,t)}get embedded(){return l(this,dt)}set embedded(t){c(this,dt,t)}get settings(){return l(this,ut)}set settings(t){c(this,ut,t)}get nonceStorageKey(){return l(this,pt)}set nonceStorageKey(t){c(this,pt,t)}willUpdate(t){super.willUpdate(t),this.type==="oauth"&&this.settingsCtl.load(this.resolvedClient,this.settings)}get effectiveSettings(){return this.settings??this.settingsCtl.settings}get providers(){const t=this.effectiveSettings;if(!t||!t.oauth_settings.enabled)return[];if(!(this.intent==="signup"?t.oauth_settings.allow_signup:t.oauth_settings.allow_signin)&&this.intent!=="link")return[];const s={google:"G",github:"GH",linkedin:"in",facebook:"f"};return Object.entries(t.oauth_providers).filter(([,a])=>a.enabled).map(([a,d])=>({id:a,name:d.provider_name,mark:s[a]??d.provider_name.slice(0,2)}))}async startOAuth(t,e,s=!1){const a=this.resolvedClient;if(!a)return;let d,m;if(s){const b=this.auth.state;if(b.status!=="authenticated"){this.formError=this.msg.linkRequiresSignIn,this.phase="error";return}d=b.session.id_token,m=b.session.refresh_token}await this.run(async()=>{var be;const b=await a.createOAuthNonce(this.signal);(be=globalThis.sessionStorage)==null||be.setItem(this.nonceStorageKey,b);const{oauth_redirect_url:v}=await a.startOAuth({provider:t,nonce:b,intent:e,...s?{id_token:d,refresh_token:m}:{}},this.signal);globalThis.location.assign(v)})}renderOAuth(){const t=this.providers;if(t.length===0)return i.nothing;const[e,...s]=t;return i.html`
|
|
408
408
|
<div class="stack">
|
|
409
409
|
${this.formError?i.html`<div class="banner" part="banner" role="alert">${this.formError}</div>`:i.nothing}
|
|
410
410
|
|
|
@@ -421,17 +421,17 @@
|
|
|
421
421
|
|
|
422
422
|
${s.length?i.html`
|
|
423
423
|
<div class="icon-row">
|
|
424
|
-
${s.map(
|
|
424
|
+
${s.map(a=>i.html`
|
|
425
425
|
<button
|
|
426
426
|
type="button"
|
|
427
427
|
class="icon-btn"
|
|
428
428
|
part="oauth-button"
|
|
429
|
-
aria-label=${`${this.msg.oauthContinueWith} ${
|
|
430
|
-
title=${`${this.msg.oauthContinueWith} ${
|
|
429
|
+
aria-label=${`${this.msg.oauthContinueWith} ${a.name}`}
|
|
430
|
+
title=${`${this.msg.oauthContinueWith} ${a.name}`}
|
|
431
431
|
?disabled=${this.submitting}
|
|
432
|
-
@click=${()=>this.startOAuth(
|
|
432
|
+
@click=${()=>this.startOAuth(a.id,this.intent)}
|
|
433
433
|
>
|
|
434
|
-
<span class="tile-mark">${
|
|
434
|
+
<span class="tile-mark">${a.mark}</span>
|
|
435
435
|
</button>
|
|
436
436
|
`)}
|
|
437
437
|
</div>
|
|
@@ -472,7 +472,7 @@
|
|
|
472
472
|
${this.msg.signOutCta}
|
|
473
473
|
</button>
|
|
474
474
|
</div>
|
|
475
|
-
`}render(){return this.type==="oauth"?this.renderOAuth():this.type==="link"?this.renderLink():this.renderSignOut()}},ot=new WeakMap,lt=new WeakMap,ht=new WeakMap,dt=new WeakMap,ct=new WeakMap,ut=new WeakMap,pt=new WeakMap,Ie);w([r.property()],exports.SinglebaseAuthButtons.prototype,"type",1);w([r.property()],exports.SinglebaseAuthButtons.prototype,"intent",1);w([r.property()],exports.SinglebaseAuthButtons.prototype,"provider",1);w([r.property({attribute:"provider-name"})],exports.SinglebaseAuthButtons.prototype,"providerName",1);w([r.property({type:Boolean})],exports.SinglebaseAuthButtons.prototype,"embedded",1);w([r.property({attribute:!1})],exports.SinglebaseAuthButtons.prototype,"settings",1);w([r.property({attribute:"nonce-storage-key"})],exports.SinglebaseAuthButtons.prototype,"nonceStorageKey",1);exports.SinglebaseAuthButtons=w([r.customElement("singlebase-authui-buttons")],exports.SinglebaseAuthButtons);var Ge=Object.defineProperty,ms=Object.getOwnPropertyDescriptor,bs=(d,a,t)=>a in d?Ge(d,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[a]=t,u=(d,a,t,e)=>{for(var s=e>1?void 0:e?ms(a,t):a,n=d.length-1,c;n>=0;n--)(c=d[n])&&(s=(e?c(a,t,s):c(s))||s);return e&&s&&Ge(a,t,s),s},fs=(d,a,t)=>bs(d,a+"",t);const Ve=["signin","signup","forgot","verify","otp","newpass","invite"],Ke=["account"],vs=[...Ve,...Ke,"oauth-callback"];function $e(d){return Ve.includes(d)}function Ye(d){return Ke.includes(d)}function Ee(d){return vs.includes(d)}const $={fromAttribute:d=>d===null?!0:d!=="false",toAttribute:d=>d?null:"false"};var gt,mt,bt,ft,vt,wt,yt,St,$t,Et,Ct,Pt,At,kt,_t,Ot,Tt,xt,Ut,Lt,Mt,Nt,Dt,It,Ft,Bt,Rt,jt,qt,Ht,Gt,Vt,Kt,Yt,Wt,zt,Jt,Qt,Xt,Zt,te,ee,se,ie,ne,ae,re,oe,le,Fe;exports.SinglebaseAuthScreen=(Fe=class extends f{constructor(){super(...arguments);l(this,gt,"signin");l(this,mt,"");l(this,bt,!1);l(this,ft,null);l(this,vt,!0);l(this,wt,!0);l(this,yt,!0);l(this,St,!0);l(this,$t,!0);l(this,Et,!0);l(this,Ct,"card");l(this,Pt,"bottom");l(this,At,!1);l(this,kt,"");l(this,_t,"");l(this,Ot,"");l(this,Tt,"");l(this,xt,"");l(this,Ut,!0);l(this,Lt,"");l(this,Mt,"");l(this,Nt,"");l(this,Dt,"");l(this,It,"");l(this,Ft,"singlebase-oauth-nonce");l(this,Bt,"");l(this,Rt,"");l(this,jt,"");l(this,qt,0);l(this,Ht,"");l(this,Gt,"");l(this,Vt,"");l(this,Kt,"");l(this,Yt,"");l(this,Wt,"");l(this,zt,"");l(this,Jt,"");l(this,Qt,"");l(this,Xt,["","","","","",""]);l(this,Zt,"signin_code");l(this,te,!1);l(this,ee,"");l(this,se,"");l(this,ie,"");l(this,ne,"");l(this,ae,"");l(this,re,0);l(this,oe,!1);p(this,"settingsCtl",new we(this));p(this,"bridge",new rs(this));p(this,"uidBase",`sb-${Math.random().toString(36).slice(2,8)}`);p(this,"gotoUnsubscribe");p(this,"gotoClient",null);l(this,le,!1);p(this,"abortController",null);p(this,"onContinue",()=>{this.followRedirect()||(this.dispatchEvent(new CustomEvent("singlebase-continue",{detail:{user:this.getUser()},bubbles:!0,composed:!0})),this.goto("account"))});p(this,"onInterstitialSignOut",async()=>{var t;await((t=this.resolvedClient)==null?void 0:t.logout()),this.goto("signin")})}get initialScreen(){return o(this,gt)}set initialScreen(t){h(this,gt,t)}get screen(){return o(this,mt)}set screen(t){h(this,mt,t)}get noAccountView(){return o(this,bt)}set noAccountView(t){h(this,bt,t)}get settings(){return o(this,ft)}set settings(t){h(this,ft,t)}get authEnabled(){return o(this,vt)}set authEnabled(t){h(this,vt,t)}get allowEmailSignin(){return o(this,wt)}set allowEmailSignin(t){h(this,wt,t)}get allowEmailSignup(){return o(this,yt)}set allowEmailSignup(t){h(this,yt,t)}get allowEmailOtp(){return o(this,St)}set allowEmailOtp(t){h(this,St,t)}get allowOauth(){return o(this,$t)}set allowOauth(t){h(this,$t,t)}get allowAccountCreation(){return o(this,Et)}set allowAccountCreation(t){h(this,Et,t)}get layout(){return o(this,Ct)}set layout(t){h(this,Ct,t)}get oauthPlacement(){return o(this,Pt)}set oauthPlacement(t){h(this,Pt,t)}get stepped(){return o(this,At)}set stepped(t){h(this,At,t)}get logoText(){return o(this,kt)}set logoText(t){h(this,kt,t)}get logoUrl(){return o(this,_t)}set logoUrl(t){h(this,_t,t)}get brandLine(){return o(this,Ot)}set brandLine(t){h(this,Ot,t)}get brandFoot(){return o(this,Tt)}set brandFoot(t){h(this,Tt,t)}get signInTitle(){return o(this,xt)}set signInTitle(t){h(this,xt,t)}get branding(){return o(this,Ut)}set branding(t){h(this,Ut,t)}get brandingText(){return o(this,Lt)}set brandingText(t){h(this,Lt,t)}get brandingUrl(){return o(this,Mt)}set brandingUrl(t){h(this,Mt,t)}get redirectUrl(){return o(this,Nt)}set redirectUrl(t){h(this,Nt,t)}get tosUrl(){return o(this,Dt)}set tosUrl(t){h(this,Dt,t)}get privacyUrl(){return o(this,It)}set privacyUrl(t){h(this,It,t)}get nonceStorageKey(){return o(this,Ft)}set nonceStorageKey(t){h(this,Ft,t)}get inviteEmail(){return o(this,Bt)}set inviteEmail(t){h(this,Bt,t)}get inviteOrg(){return o(this,Rt)}set inviteOrg(t){h(this,Rt,t)}get inviteCode(){return o(this,jt)}set inviteCode(t){h(this,jt,t)}get step(){return o(this,qt)}set step(t){h(this,qt,t)}get method(){return o(this,Ht)}set method(t){h(this,Ht,t)}get email(){return o(this,Gt)}set email(t){h(this,Gt,t)}get password(){return o(this,Vt)}set password(t){h(this,Vt,t)}get name(){return o(this,Kt)}set name(t){h(this,Kt,t)}get firstName(){return o(this,Yt)}set firstName(t){h(this,Yt,t)}get lastName(){return o(this,Wt)}set lastName(t){h(this,Wt,t)}get phone(){return o(this,zt)}set phone(t){h(this,zt,t)}get newPass(){return o(this,Jt)}set newPass(t){h(this,Jt,t)}get confirmPass(){return o(this,Qt)}set confirmPass(t){h(this,Qt,t)}get code(){return o(this,Xt)}set code(t){h(this,Xt,t)}get verifyNext(){return o(this,Zt)}set verifyNext(t){h(this,Zt,t)}get loading(){return o(this,te)}set loading(t){h(this,te,t)}get banner(){return o(this,ee)}set banner(t){h(this,ee,t)}get notice(){return o(this,se)}set notice(t){h(this,se,t)}get emailError(){return o(this,ie)}set emailError(t){h(this,ie,t)}get passError(){return o(this,ne)}set passError(t){h(this,ne,t)}get newPassError(){return o(this,ae)}set newPassError(t){h(this,ae,t)}get attempts(){return o(this,re)}set attempts(t){h(this,re,t)}get needsMfaCode(){return o(this,oe)}set needsMfaCode(t){h(this,oe,t)}uid(t){return`${this.uidBase}-${t}`}willUpdate(t){super.willUpdate(t),this.settingsCtl.load(this.resolvedClient,this.settings),this.bridge.bind(this.resolvedClient),this.bindGoto(this.resolvedClient)}disconnectedCallback(){var t,e;super.disconnectedCallback(),(t=this.gotoUnsubscribe)==null||t.call(this),this.gotoUnsubscribe=void 0,this.gotoClient=null,(e=this.abortController)==null||e.abort()}bindGoto(t){var n;if(t===this.gotoClient||((n=this.gotoUnsubscribe)==null||n.call(this),this.gotoUnsubscribe=void 0,this.gotoClient=t,!t))return;const e=t.on("goto",({screen:c})=>{Ee(c)&&this.goto(c)}),s=t.on("signin",()=>{this.followRedirect()});this.gotoUnsubscribe=()=>{e(),s()}}goto(t){this.screen!==t&&(this.screen=t,this.step=0,this.banner="",this.notice="",this.dispatchEvent(new CustomEvent("singlebase-screen-change",{detail:{screen:t},bubbles:!0,composed:!0})))}get cfg(){const t=this.settings??this.settingsCtl.settings;if(!t)return{authEnabled:this.authEnabled,allowEmailSignin:this.allowEmailSignin,allowEmailSignup:this.allowEmailSignup&&this.allowAccountCreation,allowEmailOtp:this.allowEmailOtp,allowOauth:this.allowOauth,mfa:!1};const e=t.auth_settings,s=e.second_factor==="email_otp";return{authEnabled:t.enabled&&e.enabled&&this.authEnabled,allowEmailSignin:e.allow_signin&&this.allowEmailSignin,allowEmailSignup:e.allow_signup&&this.allowEmailSignup&&this.allowAccountCreation,allowEmailOtp:this.allowEmailOtp&&e.allow_signin&&!s,allowOauth:t.oauth_settings.enabled&&this.allowOauth,mfa:s}}get requestedScreen(){const t=this.screen||this.initialScreen||"signin";return Ee(t)?t:"signin"}get activeScreen(){if(this.isOAuthCallback)return"oauth-callback";const t=this.auth.state.status==="authenticated",e=this.requestedScreen;if(Ye(e))return t?e:"signin";if(t)return this.screen!==""||this.initialScreen!=="signin"?e:"account";const s=this.cfg;let n=e;return n==="signup"&&!s.allowEmailSignup&&(n="signin"),(n==="forgot"||n==="newpass")&&!s.allowEmailSignin&&(n="signin"),n==="otp"&&!s.allowEmailOtp&&(n="signin"),n==="signin"&&!s.allowEmailSignin&&s.allowEmailOtp&&(n="otp"),n}get showsSignedInInterstitial(){return this.auth.state.status==="authenticated"&&$e(this.activeScreen)}get redirectTarget(){var t;return je.resolveRedirectTarget(this.redirectUrl||this.redirectParam,(t=globalThis.location)==null?void 0:t.href,e=>console.warn(`[singlebase] ${e}`))}get redirectParam(){var e;const t=new URLSearchParams(((e=globalThis.location)==null?void 0:e.search)??"");return t.get("redirect")??t.get("next")??""}followRedirect(){var e;const t=this.redirectTarget;return t?((e=globalThis.location)==null||e.assign(t),!0):!1}get isOAuthCallback(){var e;const t=new URLSearchParams(((e=globalThis.location)==null?void 0:e.search)??"");return t.has("access_code")||t.has("error")}get callbackDone(){return o(this,le)}set callbackDone(t){h(this,le,t)}cleanCallbackUrl(){var s;const t=(s=globalThis.location)==null?void 0:s.href;if(!t||!globalThis.history)return;const e=new URL(t);e.searchParams.delete("access_code"),e.searchParams.delete("error"),globalThis.history.replaceState({},"",e.toString())}async handleOAuthCallback(){var m,b;if(this.callbackDone)return;this.callbackDone=!0;const t=new URLSearchParams(((m=globalThis.location)==null?void 0:m.search)??""),e=t.get("access_code"),s=t.get("error"),n=this.resolvedClient;if(s){this.cleanCallbackUrl(),this.banner=this.msg.oauthDenied;return}if(!e||!n)return;const c=(b=globalThis.sessionStorage)==null?void 0:b.getItem(this.nonceStorageKey);if(this.cleanCallbackUrl(),!c){this.banner=this.msg.genericErrorMessage;return}await this.withLoading(async()=>{var v;await n.completeOAuth({access_code:e,nonce:c},this.signal()),(v=globalThis.sessionStorage)==null||v.removeItem(this.nonceStorageKey)})}renderLogo(){return this.logoUrl?i.html`<img class="logo-img" part="logo" src=${this.logoUrl} alt=${this.logoText} />`:this.logoText?i.html`<div class="logo-dot" part="logo">${this.logoText}</div>`:i.nothing}renderBrandMark(){return this.logoUrl?i.html`<img class="brand-img" part="logo" src=${this.logoUrl} alt=${this.logoText} />`:this.logoText?i.html`<div class="brand-mark" part="logo">${this.logoText}</div>`:i.nothing}renderBranding(){return Ce.renderBranding(this.branding,this.brandingText,this.msg.brandingLabel,this.brandingUrl)}panel(t){return i.html`<div class="panel">${t}${this.renderBranding()}</div>`}renderOAuthCallback(){return i.html`
|
|
475
|
+
`}render(){return this.type==="oauth"?this.renderOAuth():this.type==="link"?this.renderLink():this.renderSignOut()}},ot=new WeakMap,lt=new WeakMap,ht=new WeakMap,ct=new WeakMap,dt=new WeakMap,ut=new WeakMap,pt=new WeakMap,Ne);w([r.property()],exports.SinglebaseAuthButtons.prototype,"type",1);w([r.property()],exports.SinglebaseAuthButtons.prototype,"intent",1);w([r.property()],exports.SinglebaseAuthButtons.prototype,"provider",1);w([r.property({attribute:"provider-name"})],exports.SinglebaseAuthButtons.prototype,"providerName",1);w([r.property({type:Boolean})],exports.SinglebaseAuthButtons.prototype,"embedded",1);w([r.property({attribute:!1})],exports.SinglebaseAuthButtons.prototype,"settings",1);w([r.property({attribute:"nonce-storage-key"})],exports.SinglebaseAuthButtons.prototype,"nonceStorageKey",1);exports.SinglebaseAuthButtons=w([r.customElement("singlebase-authui-buttons")],exports.SinglebaseAuthButtons);var qe=Object.defineProperty,ps=Object.getOwnPropertyDescriptor,gs=(o,n,t)=>n in o?qe(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t,u=(o,n,t,e)=>{for(var s=e>1?void 0:e?ps(n,t):n,a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&qe(n,t,s),s},ms=(o,n,t)=>gs(o,n+"",t);const He=["signin","signup","forgot","verify","otp","newpass","invite"],Ge=["account"],bs=[...He,...Ge,"oauth-callback"];function ye(o){return He.includes(o)}function Ve(o){return Ge.includes(o)}function Se(o){return bs.includes(o)}const $={fromAttribute:o=>o===null?!0:o!=="false",toAttribute:o=>o?null:"false"};var gt,mt,bt,ft,vt,wt,yt,St,$t,Et,Ct,Pt,At,kt,_t,Ot,Tt,xt,Ut,Lt,Mt,Nt,Dt,It,Ft,Bt,Rt,jt,qt,Ht,Gt,Vt,Kt,Yt,Wt,zt,Jt,Qt,Xt,Zt,te,ee,se,ie,ae,ne,re,De;exports.SinglebaseAuthScreen=(De=class extends f{constructor(){super(...arguments);h(this,gt,"signin");h(this,mt,"");h(this,bt,!1);h(this,ft,null);h(this,vt,!0);h(this,wt,!0);h(this,yt,!0);h(this,St,!0);h(this,$t,!0);h(this,Et,!0);h(this,Ct,"card");h(this,Pt,"bottom");h(this,At,!1);h(this,kt,"");h(this,_t,"");h(this,Ot,"");h(this,Tt,"");h(this,xt,"");h(this,Ut,!0);h(this,Lt,"");h(this,Mt,"");h(this,Nt,"");h(this,Dt,"singlebase-oauth-nonce");h(this,It,"");h(this,Ft,"");h(this,Bt,"");h(this,Rt,0);h(this,jt,"");h(this,qt,"");h(this,Ht,"");h(this,Gt,"");h(this,Vt,"");h(this,Kt,"");h(this,Yt,"");h(this,Wt,"");h(this,zt,"");h(this,Jt,["","","","","",""]);h(this,Qt,"signin_code");h(this,Xt,!1);h(this,Zt,"");h(this,te,"");h(this,ee,"");h(this,se,"");h(this,ie,"");h(this,ae,0);h(this,ne,!1);p(this,"settingsCtl",new fe(this));p(this,"bridge",new as(this));p(this,"uidBase",`sb-${Math.random().toString(36).slice(2,8)}`);p(this,"gotoUnsubscribe");p(this,"gotoClient",null);h(this,re,!1);p(this,"abortController",null);p(this,"onContinue",()=>{this.followRedirect()||(this.dispatchEvent(new CustomEvent("singlebase-continue",{detail:{user:this.getUser()},bubbles:!0,composed:!0})),this.goto("account"))});p(this,"onInterstitialSignOut",async()=>{var t;await((t=this.resolvedClient)==null?void 0:t.logout()),this.goto("signin")})}get initialScreen(){return l(this,gt)}set initialScreen(t){c(this,gt,t)}get screen(){return l(this,mt)}set screen(t){c(this,mt,t)}get noAccountView(){return l(this,bt)}set noAccountView(t){c(this,bt,t)}get settings(){return l(this,ft)}set settings(t){c(this,ft,t)}get authEnabled(){return l(this,vt)}set authEnabled(t){c(this,vt,t)}get allowEmailSignin(){return l(this,wt)}set allowEmailSignin(t){c(this,wt,t)}get allowEmailSignup(){return l(this,yt)}set allowEmailSignup(t){c(this,yt,t)}get allowEmailOtp(){return l(this,St)}set allowEmailOtp(t){c(this,St,t)}get allowOauth(){return l(this,$t)}set allowOauth(t){c(this,$t,t)}get allowAccountCreation(){return l(this,Et)}set allowAccountCreation(t){c(this,Et,t)}get layout(){return l(this,Ct)}set layout(t){c(this,Ct,t)}get oauthPlacement(){return l(this,Pt)}set oauthPlacement(t){c(this,Pt,t)}get stepped(){return l(this,At)}set stepped(t){c(this,At,t)}get logoText(){return l(this,kt)}set logoText(t){c(this,kt,t)}get logoUrl(){return l(this,_t)}set logoUrl(t){c(this,_t,t)}get brandLine(){return l(this,Ot)}set brandLine(t){c(this,Ot,t)}get brandFoot(){return l(this,Tt)}set brandFoot(t){c(this,Tt,t)}get signInTitle(){return l(this,xt)}set signInTitle(t){c(this,xt,t)}get branding(){return l(this,Ut)}set branding(t){c(this,Ut,t)}get redirectUrl(){return l(this,Lt)}set redirectUrl(t){c(this,Lt,t)}get tosUrl(){return l(this,Mt)}set tosUrl(t){c(this,Mt,t)}get privacyUrl(){return l(this,Nt)}set privacyUrl(t){c(this,Nt,t)}get nonceStorageKey(){return l(this,Dt)}set nonceStorageKey(t){c(this,Dt,t)}get inviteEmail(){return l(this,It)}set inviteEmail(t){c(this,It,t)}get inviteOrg(){return l(this,Ft)}set inviteOrg(t){c(this,Ft,t)}get inviteCode(){return l(this,Bt)}set inviteCode(t){c(this,Bt,t)}get step(){return l(this,Rt)}set step(t){c(this,Rt,t)}get method(){return l(this,jt)}set method(t){c(this,jt,t)}get email(){return l(this,qt)}set email(t){c(this,qt,t)}get password(){return l(this,Ht)}set password(t){c(this,Ht,t)}get name(){return l(this,Gt)}set name(t){c(this,Gt,t)}get firstName(){return l(this,Vt)}set firstName(t){c(this,Vt,t)}get lastName(){return l(this,Kt)}set lastName(t){c(this,Kt,t)}get phone(){return l(this,Yt)}set phone(t){c(this,Yt,t)}get newPass(){return l(this,Wt)}set newPass(t){c(this,Wt,t)}get confirmPass(){return l(this,zt)}set confirmPass(t){c(this,zt,t)}get code(){return l(this,Jt)}set code(t){c(this,Jt,t)}get verifyNext(){return l(this,Qt)}set verifyNext(t){c(this,Qt,t)}get loading(){return l(this,Xt)}set loading(t){c(this,Xt,t)}get banner(){return l(this,Zt)}set banner(t){c(this,Zt,t)}get notice(){return l(this,te)}set notice(t){c(this,te,t)}get emailError(){return l(this,ee)}set emailError(t){c(this,ee,t)}get passError(){return l(this,se)}set passError(t){c(this,se,t)}get newPassError(){return l(this,ie)}set newPassError(t){c(this,ie,t)}get attempts(){return l(this,ae)}set attempts(t){c(this,ae,t)}get needsMfaCode(){return l(this,ne)}set needsMfaCode(t){c(this,ne,t)}uid(t){return`${this.uidBase}-${t}`}willUpdate(t){super.willUpdate(t),this.settingsCtl.load(this.resolvedClient,this.settings),this.bridge.bind(this.resolvedClient),this.bindGoto(this.resolvedClient)}disconnectedCallback(){var t,e;super.disconnectedCallback(),(t=this.gotoUnsubscribe)==null||t.call(this),this.gotoUnsubscribe=void 0,this.gotoClient=null,(e=this.abortController)==null||e.abort()}bindGoto(t){var a;if(t===this.gotoClient||((a=this.gotoUnsubscribe)==null||a.call(this),this.gotoUnsubscribe=void 0,this.gotoClient=t,!t))return;const e=t.on("goto",({screen:d})=>{Se(d)&&this.goto(d)}),s=t.on("signin",()=>{this.followRedirect()});this.gotoUnsubscribe=()=>{e(),s()}}goto(t){this.screen!==t&&(this.screen=t,this.step=0,this.banner="",this.notice="",this.dispatchEvent(new CustomEvent("singlebase-screen-change",{detail:{screen:t},bubbles:!0,composed:!0})))}get cfg(){const t=this.settings??this.settingsCtl.settings;if(!t)return{authEnabled:this.authEnabled,allowEmailSignin:this.allowEmailSignin,allowEmailSignup:this.allowEmailSignup&&this.allowAccountCreation,allowEmailOtp:this.allowEmailOtp,allowOauth:this.allowOauth,mfa:!1};const e=t.auth_settings,s=e.second_factor==="email_otp";return{authEnabled:t.enabled&&e.enabled&&this.authEnabled,allowEmailSignin:e.allow_signin&&this.allowEmailSignin,allowEmailSignup:e.allow_signup&&this.allowEmailSignup&&this.allowAccountCreation,allowEmailOtp:this.allowEmailOtp&&e.allow_signin&&!s,allowOauth:t.oauth_settings.enabled&&this.allowOauth,mfa:s}}get requestedScreen(){const t=this.screen||this.initialScreen||"signin";return Se(t)?t:"signin"}get activeScreen(){if(this.isOAuthCallback)return"oauth-callback";const t=this.auth.state.status==="authenticated",e=this.requestedScreen;if(Ve(e))return t?e:"signin";if(t)return this.screen!==""||this.initialScreen!=="signin"?e:"account";const s=this.cfg;let a=e;return a==="signup"&&!s.allowEmailSignup&&(a="signin"),(a==="forgot"||a==="newpass")&&!s.allowEmailSignin&&(a="signin"),a==="otp"&&!s.allowEmailOtp&&(a="signin"),a==="signin"&&!s.allowEmailSignin&&s.allowEmailOtp&&(a="otp"),a}get showsSignedInInterstitial(){return this.auth.state.status==="authenticated"&&ye(this.activeScreen)}get redirectTarget(){var t;return Be.resolveRedirectTarget(this.redirectUrl||this.redirectParam,(t=globalThis.location)==null?void 0:t.href,e=>console.warn(`[singlebase] ${e}`))}get redirectParam(){var e;const t=new URLSearchParams(((e=globalThis.location)==null?void 0:e.search)??"");return t.get("redirect")??t.get("next")??""}followRedirect(){var e;const t=this.redirectTarget;return t?((e=globalThis.location)==null||e.assign(t),!0):!1}get isOAuthCallback(){var e;const t=new URLSearchParams(((e=globalThis.location)==null?void 0:e.search)??"");return t.has("access_code")||t.has("error")}get callbackDone(){return l(this,re)}set callbackDone(t){c(this,re,t)}cleanCallbackUrl(){var s;const t=(s=globalThis.location)==null?void 0:s.href;if(!t||!globalThis.history)return;const e=new URL(t);e.searchParams.delete("access_code"),e.searchParams.delete("error"),globalThis.history.replaceState({},"",e.toString())}async handleOAuthCallback(){var m,b;if(this.callbackDone)return;this.callbackDone=!0;const t=new URLSearchParams(((m=globalThis.location)==null?void 0:m.search)??""),e=t.get("access_code"),s=t.get("error"),a=this.resolvedClient;if(s){this.cleanCallbackUrl(),this.banner=this.msg.oauthDenied;return}if(!e||!a)return;const d=(b=globalThis.sessionStorage)==null?void 0:b.getItem(this.nonceStorageKey);if(this.cleanCallbackUrl(),!d){this.banner=this.msg.genericErrorMessage;return}await this.withLoading(async()=>{var v;await a.completeOAuth({access_code:e,nonce:d},this.signal()),(v=globalThis.sessionStorage)==null||v.removeItem(this.nonceStorageKey)})}renderLogo(){return this.logoUrl?i.html`<img class="logo-img" part="logo" src=${this.logoUrl} alt=${this.logoText} />`:this.logoText?i.html`<div class="logo-dot" part="logo">${this.logoText}</div>`:i.nothing}renderBrandMark(){return this.logoUrl?i.html`<img class="brand-img" part="logo" src=${this.logoUrl} alt=${this.logoText} />`:this.logoText?i.html`<div class="brand-mark" part="logo">${this.logoText}</div>`:i.nothing}renderBranding(){return $e.renderBranding(this.branding,"Auth")}panel(t){return i.html`<div class="panel">${t}${this.renderBranding()}</div>`}renderOAuthCallback(){return i.html`
|
|
476
476
|
<div class="stack">
|
|
477
477
|
<div class="head">
|
|
478
478
|
${this.renderLogo()}
|
|
@@ -486,7 +486,7 @@
|
|
|
486
486
|
<span>${this.msg.backCta}</span>
|
|
487
487
|
</button>`:i.nothing}
|
|
488
488
|
</div>
|
|
489
|
-
`}setScreen(t,e={}){const s=this.screen!==t;this.screen=t,this.banner="",this.emailError="",this.passError="",Object.assign(this,e),s&&this.dispatchEvent(new CustomEvent("singlebase-screen-change",{detail:{screen:t},bubbles:!0,composed:!0}))}async withLoading(t){this.loading=!0,this.banner="";try{await t()}catch(e){this.banner=this.describeError(e)}finally{this.loading=!1}}describeError(t){if(t instanceof y.SinglebaseAuthError){if(t.code==="AUTH_RATE_LIMITED")return this.msg.rateLimitedMessage;if(t.code==="INVALID_TOKEN")return"That code is not valid. Check it and try again."}return this.msg.genericErrorMessage}get codeValue(){return this.code.join("")}async onSubmit(t){t==null||t.preventDefault();const e=this.resolvedClient;if(!e)return;const s=this.activeScreen;if(this.cfg,s==="forgot"||s==="otp"){if(!this.email.includes("@")){this.emailError=this.msg.invalidEmailError;return}const
|
|
489
|
+
`}setScreen(t,e={}){const s=this.screen!==t;this.screen=t,this.banner="",this.emailError="",this.passError="",Object.assign(this,e),s&&this.dispatchEvent(new CustomEvent("singlebase-screen-change",{detail:{screen:t},bubbles:!0,composed:!0}))}async withLoading(t){this.loading=!0,this.banner="";try{await t()}catch(e){this.banner=this.describeError(e)}finally{this.loading=!1}}describeError(t){if(t instanceof y.SinglebaseAuthError){if(t.code==="AUTH_RATE_LIMITED")return this.msg.rateLimitedMessage;if(t.code==="INVALID_TOKEN")return"That code is not valid. Check it and try again."}return this.msg.genericErrorMessage}get codeValue(){return this.code.join("")}async onSubmit(t){t==null||t.preventDefault();const e=this.resolvedClient;if(!e)return;const s=this.activeScreen;if(this.cfg,s==="forgot"||s==="otp"){if(!this.email.includes("@")){this.emailError=this.msg.invalidEmailError;return}const a=s==="forgot"?"password_reset":"signin";await this.withLoading(async()=>{await e.requestCode({email:this.email,purpose:a},this.signal()),this.notice=this.msg.codeSentNeutral,this.screen="verify",this.verifyNext=s==="forgot"?"newpass":"signin_code",this.code=["","","","","",""]});return}if(s==="verify"){if(this.codeValue.length<6){this.banner=this.msg.codeIncompleteError;return}if(this.verifyNext==="newpass"){this.setScreen("newpass",{notice:""});return}await this.withLoading(async()=>{await e.signIn({email:this.email,grant_type:"code",code:this.codeValue},this.signal()),this.notice=""});return}if(s==="newpass"){if(this.newPass.length<10){this.newPassError=this.msg.passwordMinError;return}if(this.newPass!==this.confirmPass){this.newPassError=this.msg.passwordMatchError;return}await this.withLoading(async()=>{await e.resetPassword({email:this.email,code:this.codeValue,new_password:this.newPass},this.signal()),this.newPass="",this.confirmPass=""});return}if(s==="invite"){if(!this.firstName.trim()||!this.lastName.trim()){this.banner="Enter your first and last name.";return}if(this.phone.replace(/\D/g,"").length<7){this.banner=this.msg.invalidPhoneError;return}if(this.password.length<10){this.passError=this.msg.passwordMinError;return}const a=this.inviteCode||this.codeValue;if(a.length<6){this.banner=this.msg.codeIncompleteError;return}await this.withLoading(async()=>{await e.acceptInvite({email:this.inviteEmail,grant_type:"code",purpose:"invite",code:a,password:this.password,phone:this.phone},this.signal())});return}if(this.stepped&&(s==="signup"&&this.step<2||s==="signin"&&this.step<1)){if(!this.email.includes("@")){this.emailError=this.msg.invalidEmailError;return}this.step+=1;return}if(!this.email.includes("@")){this.emailError=this.msg.invalidEmailError;return}if(s==="signup"){if(this.password.length<8){this.passError="Password must be at least 8 characters.";return}const[a,...d]=this.name.trim().split(/\s+/);await this.withLoading(async()=>{const m=await e.signUp({email:this.email,password:this.password,first_name:a||this.name,last_name:d.join(" ")||"—"},this.signal()),b=y.resolveScreen({next_action:m.next_action,next_operation:m.next_operation});this.setScreen("signin",{notice:"Account created. Sign in to continue.",step:0,password:"",needsMfaCode:b==="signin_with_code"})});return}if(this.password.length<8){this.attempts+=1,this.passError="Password must be at least 8 characters.",this.banner=this.attempts>=3?this.msg.rateLimitedMessage:"";return}await this.withLoading(async()=>{try{await e.signIn({email:this.email,password:this.password,...this.needsMfaCode?{code:this.codeValue}:{}},this.signal()),this.step=0}catch(a){if(a instanceof y.SinglebaseAuthError&&a.code==="CODE_REQUIRED"){this.needsMfaCode=!0,await e.requestCode({email:this.email,purpose:"signin"},this.signal()),this.notice=this.msg.codeSentNeutral;return}if(a instanceof y.SinglebaseAuthError&&a.code==="INVALID_CREDENTIALS"){this.attempts+=1,this.banner=this.attempts>=3?this.msg.rateLimitedMessage:"That email and password do not match.";return}throw a}})}signal(){var t;return(t=this.abortController)==null||t.abort(),this.abortController=new AbortController,this.abortController.signal}onCodeInput(t,e){var b;const a=e.target.value.replace(/\D/g,"");if(a.length>1){this.fillCode(t,a);return}const d=a.slice(-1),m=this.code.slice();m[t]=d,this.code=m,this.banner="",d&&((b=this.renderRoot.querySelectorAll(".code-row input, .code-row-sm input")[t+1])==null||b.focus())}onCodePaste(t,e){var a;const s=(((a=e.clipboardData)==null?void 0:a.getData("text"))??"").replace(/\D/g,"");s&&(e.preventDefault(),this.fillCode(t,s))}fillCode(t,e){const s=this.code.slice();for(let d=0;d<e.length&&t+d<s.length;d+=1)s[t+d]=e[d];this.code=s,this.banner="";const a=Math.min(t+e.length,s.length-1);this.updateComplete.then(()=>{var m;(m=this.renderRoot.querySelectorAll(".code-row input, .code-row-sm input")[a])==null||m.focus()})}async onResend(){const t=this.resolvedClient;if(!t||this.loading)return;const e=this.verifyNext==="newpass"?"password_reset":"signin";await this.withLoading(async()=>{await t.requestCode({email:this.email,purpose:e},this.signal()),this.notice="New code sent.",this.code=["","","","","",""]})}goBack(){if(this.step>0&&["forgot","verify","otp","newpass"].indexOf(this.activeScreen)<0){this.step-=1,this.banner="",this.notice="";return}this.setScreen("signin",{step:0,notice:"",code:["","","","","",""]})}titleFor(t){const e=this.msg;switch(t){case"signup":return e.signUpTitle;case"forgot":return e.forgotTitle;case"verify":return e.verifyTitle;case"otp":return e.otpTitle;case"newpass":return e.newPassTitle;case"invite":return e.inviteTitle;default:return this.signInTitle||e.signInTitle}}subFor(t){const e=this.msg,s=this.cfg;switch(t){case"signup":return e.signUpSub;case"forgot":return e.forgotSub;case"verify":return`We sent a 6-digit code to ${this.email||"your inbox"}. It expires in 10 minutes.`;case"otp":return e.otpSub;case"newpass":return`Your code is confirmed. Set a new password for ${this.email||"your account"}.`;case"invite":return`${this.inviteOrg||"Acme"} invited you to join. Set up your account to continue.`;default:return!s.allowEmailSignin&&!s.allowEmailOtp?e.signInSubOauthOnly:s.allowOauth?e.signInSubEmailAndOauth:e.signInSubEmailOnly}}ctaFor(t){const e=this.msg;if(this.stepped&&(t==="signup"&&this.step<2||t==="signin"&&this.step<1))return e.continueCta;switch(t){case"signup":return e.signUpCta;case"forgot":return e.forgotCta;case"verify":return e.verifyCta;case"otp":return e.otpCta;case"newpass":return e.newPassCta;case"invite":return e.inviteCta;default:return e.signInCta}}stepPct(){if(!this.stepped)return 100;const t=this.activeScreen==="signup"?3:2;return Math.round((this.step+1)/t*100)}renderPrimary(t){return i.html`
|
|
490
490
|
<button type="submit" class="primary" part="button-primary" ?disabled=${this.loading}>
|
|
491
491
|
${this.loading?i.html`<span class="spinner" part="spinner"></span>`:i.nothing}
|
|
492
492
|
<span>${t}</span>
|
|
@@ -542,13 +542,13 @@
|
|
|
542
542
|
autocomplete=${s===0?"one-time-code":"off"}
|
|
543
543
|
.value=${e}
|
|
544
544
|
?disabled=${this.loading}
|
|
545
|
-
@input=${
|
|
546
|
-
@paste=${
|
|
545
|
+
@input=${a=>this.onCodeInput(s,a)}
|
|
546
|
+
@paste=${a=>this.onCodePaste(s,a)}
|
|
547
547
|
/>
|
|
548
548
|
`)}
|
|
549
549
|
</div>
|
|
550
|
-
`}renderEmailMethodBody(t){const e=this.cfg,s=this.stepped,
|
|
551
|
-
${
|
|
550
|
+
`}renderEmailMethodBody(t){const e=this.cfg,s=this.stepped,a=t==="signup"&&(!s||this.step===0),d=t==="signup"&&(!s||this.step===1)||t==="signin"&&(!s||this.step===0)||t==="otp",m=t==="signup"&&(!s||this.step===2)||t==="signin"&&(!s||this.step===1),b=t==="signin"&&e.allowEmailSignin&&e.allowEmailOtp&&(!s||this.step===0);return i.html`
|
|
551
|
+
${a?i.html`
|
|
552
552
|
<div class="field">
|
|
553
553
|
<label for=${this.uid("name")}>${this.msg.fullNameLabel}</label>
|
|
554
554
|
<input
|
|
@@ -562,7 +562,7 @@
|
|
|
562
562
|
/>
|
|
563
563
|
</div>
|
|
564
564
|
`:i.nothing}
|
|
565
|
-
${
|
|
565
|
+
${d?this.renderEmailField(this.uid("email")):i.nothing}
|
|
566
566
|
${m?this.renderPasswordField(this.uid("pass"),e.allowEmailSignin&&t==="signin"):i.nothing}
|
|
567
567
|
${this.needsMfaCode&&t==="signin"?i.html`
|
|
568
568
|
<div class="field">
|
|
@@ -578,28 +578,28 @@
|
|
|
578
578
|
>
|
|
579
579
|
${this.msg.otpInsteadLink}
|
|
580
580
|
</button>`:i.nothing}
|
|
581
|
-
`}renderAccordion(t){const e=this.cfg,s=t==="signin"&&e.allowEmailSignin||t==="signup"&&e.allowEmailSignup||t==="otp"&&e.allowEmailOtp,
|
|
582
|
-
<div class="acc-item ${
|
|
583
|
-
${
|
|
581
|
+
`}renderAccordion(t){const e=this.cfg,s=t==="signin"&&e.allowEmailSignin||t==="signup"&&e.allowEmailSignup||t==="otp"&&e.allowEmailOtp,a=e.allowOauth;if(!s&&!a)return i.nothing;const d=s&&a,m=s?a&&this.method||"email":"oauth",b=m==="email",v=m==="oauth",be=t==="signup"?this.msg.emailMethodTitleSignUp:this.msg.emailMethodTitle,Ye=t==="otp"?this.msg.emailMethodMetaOtp:t==="signup"?this.msg.emailMethodMetaSignUp:this.msg.emailMethodMeta,Ae=(Oe,We,ze,Je,Qe,Te)=>i.html`
|
|
582
|
+
<div class="acc-item ${Oe?"open":""} ${d?"":"bare"}" part="acc-item">
|
|
583
|
+
${d?i.html`
|
|
584
584
|
<button
|
|
585
585
|
type="button"
|
|
586
586
|
class="acc-head"
|
|
587
|
-
aria-expanded=${
|
|
588
|
-
aria-controls=${this.uid(`acc-${
|
|
589
|
-
@click=${
|
|
587
|
+
aria-expanded=${Oe?"true":"false"}
|
|
588
|
+
aria-controls=${this.uid(`acc-${Te}`)}
|
|
589
|
+
@click=${Qe}
|
|
590
590
|
>
|
|
591
591
|
<span class="chev" aria-hidden="true">›</span>
|
|
592
|
-
<span class="acc-title">${
|
|
593
|
-
<span class="acc-meta">${
|
|
592
|
+
<span class="acc-title">${We}</span>
|
|
593
|
+
<span class="acc-meta">${ze}</span>
|
|
594
594
|
</button>
|
|
595
595
|
`:i.nothing}
|
|
596
|
-
<div class="acc-body" id=${this.uid(`acc-${
|
|
596
|
+
<div class="acc-body" id=${this.uid(`acc-${Te}`)}>
|
|
597
597
|
<div class="acc-clip">
|
|
598
|
-
<div class="acc-inner">${
|
|
598
|
+
<div class="acc-inner">${Je}</div>
|
|
599
599
|
</div>
|
|
600
600
|
</div>
|
|
601
601
|
</div>
|
|
602
|
-
`,
|
|
602
|
+
`,ke=s?Ae(b,be,Ye,this.renderEmailMethodBody(t),()=>this.method=b?"":"email","email"):i.nothing,_e=a?Ae(v,this.msg.oauthMethodTitle,this.msg.oauthMethodMeta,i.html`<singlebase-authui-buttons
|
|
603
603
|
type="oauth"
|
|
604
604
|
embedded
|
|
605
605
|
theme=${E.ifDefined(this.theme)}
|
|
@@ -611,7 +611,7 @@
|
|
|
611
611
|
intent=${t==="signup"?"signup":"signin"}
|
|
612
612
|
></singlebase-authui-buttons>`,()=>this.method=v?"":"oauth","oauth"):i.nothing;return i.html`
|
|
613
613
|
<div class="acc-wrap">
|
|
614
|
-
${this.oauthPlacement==="top"?i.html`${
|
|
614
|
+
${this.oauthPlacement==="top"?i.html`${_e}${ke}`:i.html`${ke}${_e}`}
|
|
615
615
|
</div>
|
|
616
616
|
`}renderScreenBody(t){return this.cfg,["signin","signup","otp"].indexOf(t)>=0?this.renderAccordion(t):t==="forgot"?i.html`<div class="fields">${this.renderEmailField(this.uid("reset"))}</div>`:t==="verify"?i.html`
|
|
617
617
|
${this.renderCodeRow()}
|
|
@@ -714,7 +714,7 @@
|
|
|
714
714
|
${this.passError?i.html`<p class="err">${this.passError}</p>`:i.nothing}
|
|
715
715
|
</div>
|
|
716
716
|
</div>
|
|
717
|
-
`:i.nothing}renderGuest(t){const e=this.cfg,s=["forgot","verify","newpass","invite"].indexOf(t)>=0,
|
|
717
|
+
`:i.nothing}renderGuest(t){const e=this.cfg,s=["forgot","verify","newpass","invite"].indexOf(t)>=0,a=this.stepped&&this.step>0||["forgot","verify","otp","newpass"].indexOf(t)>=0,d=t==="signin"&&e.allowEmailSignup||t==="signup"&&e.allowEmailSignin,m=this.stepped&&(t==="signin"||t==="signup");return i.html`
|
|
718
718
|
<form class="stack" @submit=${this.onSubmit} novalidate>
|
|
719
719
|
<div class="head">
|
|
720
720
|
${this.layout!=="split"?this.renderLogo():i.nothing}
|
|
@@ -728,15 +728,15 @@
|
|
|
728
728
|
${this.banner?i.html`<div class="banner" part="banner" role="alert">${this.banner}</div>`:i.nothing}
|
|
729
729
|
${this.notice?i.html`<div class="notice" part="notice" role="status">${this.notice}</div>`:i.nothing}
|
|
730
730
|
${this.renderScreenBody(t)}
|
|
731
|
-
${s||
|
|
731
|
+
${s||a?i.html`
|
|
732
732
|
<div class="actions">
|
|
733
733
|
${s?this.renderPrimary(this.ctaFor(t)):i.nothing}
|
|
734
|
-
${
|
|
734
|
+
${a?i.html`<button type="button" class="ghost" @click=${this.goBack}>
|
|
735
735
|
${this.msg.backCta}
|
|
736
736
|
</button>`:i.nothing}
|
|
737
737
|
</div>
|
|
738
738
|
`:i.nothing}
|
|
739
|
-
${
|
|
739
|
+
${d?i.html`
|
|
740
740
|
<p class="foot">
|
|
741
741
|
<span
|
|
742
742
|
>${t==="signup"?this.msg.footTextSignUp:this.msg.footTextSignIn}</span
|
|
@@ -809,7 +809,7 @@
|
|
|
809
809
|
logo-text=${this.logoText}
|
|
810
810
|
logo-url=${this.logoUrl}
|
|
811
811
|
></singlebase-authui-account>
|
|
812
|
-
`);if(this.showsSignedInInterstitial)return this.noAccountView?i.nothing:this.panel(this.renderSignedIn());const e=this.cfg,s=!e.allowEmailSignin&&!e.allowEmailOtp&&!e.allowOauth,
|
|
812
|
+
`);if(this.showsSignedInInterstitial)return this.noAccountView?i.nothing:this.panel(this.renderSignedIn());const e=this.cfg,s=!e.allowEmailSignin&&!e.allowEmailOtp&&!e.allowOauth,a=!e.authEnabled||s&&ye(t);return i.html`
|
|
813
813
|
${this.layout==="split"?i.html`
|
|
814
814
|
<div class="brand-panel">
|
|
815
815
|
${this.renderBrandMark()}
|
|
@@ -817,8 +817,8 @@
|
|
|
817
817
|
${this.brandFoot?i.html`<div class="brand-foot">${this.brandFoot}</div>`:i.nothing}
|
|
818
818
|
</div>
|
|
819
819
|
`:i.nothing}
|
|
820
|
-
${this.panel(
|
|
821
|
-
`}},gt=new WeakMap,mt=new WeakMap,bt=new WeakMap,ft=new WeakMap,vt=new WeakMap,wt=new WeakMap,yt=new WeakMap,St=new WeakMap,$t=new WeakMap,Et=new WeakMap,Ct=new WeakMap,Pt=new WeakMap,At=new WeakMap,kt=new WeakMap,_t=new WeakMap,Ot=new WeakMap,Tt=new WeakMap,xt=new WeakMap,Ut=new WeakMap,Lt=new WeakMap,Mt=new WeakMap,Nt=new WeakMap,Dt=new WeakMap,It=new WeakMap,Ft=new WeakMap,Bt=new WeakMap,Rt=new WeakMap,jt=new WeakMap,qt=new WeakMap,Ht=new WeakMap,Gt=new WeakMap,Vt=new WeakMap,Kt=new WeakMap,Yt=new WeakMap,Wt=new WeakMap,zt=new WeakMap,Jt=new WeakMap,Qt=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,te=new WeakMap,ee=new WeakMap,se=new WeakMap,ie=new WeakMap,
|
|
820
|
+
${this.panel(a?this.renderBlocked():this.renderGuest(t))}
|
|
821
|
+
`}},gt=new WeakMap,mt=new WeakMap,bt=new WeakMap,ft=new WeakMap,vt=new WeakMap,wt=new WeakMap,yt=new WeakMap,St=new WeakMap,$t=new WeakMap,Et=new WeakMap,Ct=new WeakMap,Pt=new WeakMap,At=new WeakMap,kt=new WeakMap,_t=new WeakMap,Ot=new WeakMap,Tt=new WeakMap,xt=new WeakMap,Ut=new WeakMap,Lt=new WeakMap,Mt=new WeakMap,Nt=new WeakMap,Dt=new WeakMap,It=new WeakMap,Ft=new WeakMap,Bt=new WeakMap,Rt=new WeakMap,jt=new WeakMap,qt=new WeakMap,Ht=new WeakMap,Gt=new WeakMap,Vt=new WeakMap,Kt=new WeakMap,Yt=new WeakMap,Wt=new WeakMap,zt=new WeakMap,Jt=new WeakMap,Qt=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,te=new WeakMap,ee=new WeakMap,se=new WeakMap,ie=new WeakMap,ae=new WeakMap,ne=new WeakMap,re=new WeakMap,De);ms(exports.SinglebaseAuthScreen,"styles",[...f.styles,$e.brandingStyles,i.css`
|
|
822
822
|
/* the mock's root */
|
|
823
823
|
:host {
|
|
824
824
|
display: flex;
|
|
@@ -904,7 +904,7 @@
|
|
|
904
904
|
border-bottom: 1px solid var(--sb-border, #e4e6e9);
|
|
905
905
|
}
|
|
906
906
|
}
|
|
907
|
-
`]);u([r.property({attribute:"initial-screen"})],exports.SinglebaseAuthScreen.prototype,"initialScreen",1);u([r.property({reflect:!0})],exports.SinglebaseAuthScreen.prototype,"screen",1);u([r.property({type:Boolean,attribute:"no-account-view"})],exports.SinglebaseAuthScreen.prototype,"noAccountView",1);u([r.property({attribute:!1})],exports.SinglebaseAuthScreen.prototype,"settings",1);u([r.property({converter:$,attribute:"auth-enabled"})],exports.SinglebaseAuthScreen.prototype,"authEnabled",1);u([r.property({converter:$,attribute:"allow-email-signin"})],exports.SinglebaseAuthScreen.prototype,"allowEmailSignin",1);u([r.property({converter:$,attribute:"allow-email-signup"})],exports.SinglebaseAuthScreen.prototype,"allowEmailSignup",1);u([r.property({converter:$,attribute:"allow-email-otp"})],exports.SinglebaseAuthScreen.prototype,"allowEmailOtp",1);u([r.property({converter:$,attribute:"allow-oauth"})],exports.SinglebaseAuthScreen.prototype,"allowOauth",1);u([r.property({converter:$,attribute:"allow-account-creation"})],exports.SinglebaseAuthScreen.prototype,"allowAccountCreation",1);u([r.property()],exports.SinglebaseAuthScreen.prototype,"layout",1);u([r.property({attribute:"oauth-placement"})],exports.SinglebaseAuthScreen.prototype,"oauthPlacement",1);u([r.property({type:Boolean})],exports.SinglebaseAuthScreen.prototype,"stepped",1);u([r.property({attribute:"logo-text"})],exports.SinglebaseAuthScreen.prototype,"logoText",1);u([r.property({attribute:"logo-url"})],exports.SinglebaseAuthScreen.prototype,"logoUrl",1);u([r.property({attribute:"brand-line"})],exports.SinglebaseAuthScreen.prototype,"brandLine",1);u([r.property({attribute:"brand-foot"})],exports.SinglebaseAuthScreen.prototype,"brandFoot",1);u([r.property({attribute:"sign-in-title"})],exports.SinglebaseAuthScreen.prototype,"signInTitle",1);u([r.property({converter:$,attribute:"branding"})],exports.SinglebaseAuthScreen.prototype,"branding",1);u([r.property({attribute:"
|
|
907
|
+
`]);u([r.property({attribute:"initial-screen"})],exports.SinglebaseAuthScreen.prototype,"initialScreen",1);u([r.property({reflect:!0})],exports.SinglebaseAuthScreen.prototype,"screen",1);u([r.property({type:Boolean,attribute:"no-account-view"})],exports.SinglebaseAuthScreen.prototype,"noAccountView",1);u([r.property({attribute:!1})],exports.SinglebaseAuthScreen.prototype,"settings",1);u([r.property({converter:$,attribute:"auth-enabled"})],exports.SinglebaseAuthScreen.prototype,"authEnabled",1);u([r.property({converter:$,attribute:"allow-email-signin"})],exports.SinglebaseAuthScreen.prototype,"allowEmailSignin",1);u([r.property({converter:$,attribute:"allow-email-signup"})],exports.SinglebaseAuthScreen.prototype,"allowEmailSignup",1);u([r.property({converter:$,attribute:"allow-email-otp"})],exports.SinglebaseAuthScreen.prototype,"allowEmailOtp",1);u([r.property({converter:$,attribute:"allow-oauth"})],exports.SinglebaseAuthScreen.prototype,"allowOauth",1);u([r.property({converter:$,attribute:"allow-account-creation"})],exports.SinglebaseAuthScreen.prototype,"allowAccountCreation",1);u([r.property()],exports.SinglebaseAuthScreen.prototype,"layout",1);u([r.property({attribute:"oauth-placement"})],exports.SinglebaseAuthScreen.prototype,"oauthPlacement",1);u([r.property({type:Boolean})],exports.SinglebaseAuthScreen.prototype,"stepped",1);u([r.property({attribute:"logo-text"})],exports.SinglebaseAuthScreen.prototype,"logoText",1);u([r.property({attribute:"logo-url"})],exports.SinglebaseAuthScreen.prototype,"logoUrl",1);u([r.property({attribute:"brand-line"})],exports.SinglebaseAuthScreen.prototype,"brandLine",1);u([r.property({attribute:"brand-foot"})],exports.SinglebaseAuthScreen.prototype,"brandFoot",1);u([r.property({attribute:"sign-in-title"})],exports.SinglebaseAuthScreen.prototype,"signInTitle",1);u([r.property({converter:$,attribute:"branding"})],exports.SinglebaseAuthScreen.prototype,"branding",1);u([r.property({attribute:"redirect-url"})],exports.SinglebaseAuthScreen.prototype,"redirectUrl",1);u([r.property({attribute:"tos-url"})],exports.SinglebaseAuthScreen.prototype,"tosUrl",1);u([r.property({attribute:"privacy-url"})],exports.SinglebaseAuthScreen.prototype,"privacyUrl",1);u([r.property({attribute:"nonce-storage-key"})],exports.SinglebaseAuthScreen.prototype,"nonceStorageKey",1);u([r.property({attribute:"invite-email"})],exports.SinglebaseAuthScreen.prototype,"inviteEmail",1);u([r.property({attribute:"invite-org"})],exports.SinglebaseAuthScreen.prototype,"inviteOrg",1);u([r.property({attribute:"invite-code"})],exports.SinglebaseAuthScreen.prototype,"inviteCode",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"step",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"method",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"email",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"password",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"name",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"firstName",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"lastName",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"phone",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"newPass",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"confirmPass",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"code",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"verifyNext",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"loading",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"banner",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"notice",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"emailError",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"passError",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"newPassError",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"attempts",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"needsMfaCode",1);u([r.state()],exports.SinglebaseAuthScreen.prototype,"callbackDone",1);exports.SinglebaseAuthScreen=u([r.customElement("singlebase-authui")],exports.SinglebaseAuthScreen);var fs=Object.defineProperty,vs=Object.getOwnPropertyDescriptor,ve=(o,n,t,e)=>{for(var s=e>1?void 0:e?vs(n,t):n,a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&fs(n,t,s),s};const ws=["loading","authenticated","unauthenticated"];var oe,le,he,Ie;exports.SinglebaseAuthGuard=(Ie=class extends f{constructor(){super(...arguments);h(this,oe,"");h(this,le,null);h(this,he,"unauthenticated");p(this,"warnedFor",null)}get slot(){return l(this,oe)}set slot(t){c(this,oe,t)}get predicate(){return l(this,le)}set predicate(t){c(this,le,t)}get onMismatch(){return l(this,he)}set onMismatch(t){c(this,he,t)}createRenderRoot(){return this}get activeState(){const t=this.auth.state.status;if(t==="loading")return"loading";if(t!=="authenticated")return"unauthenticated";if(!this.predicate)return"authenticated";this.warnOnce(this.predicate);const e=this.auth.state.user;return S.matchesPredicate(e,this.predicate)?"authenticated":this.onMismatch==="hidden"?"hidden":"unauthenticated"}warnOnce(t){const e=JSON.stringify(t);if(this.warnedFor!==e){this.warnedFor=e;for(const s of S.validatePredicate(t))console.warn(`[singlebase] <singlebase-authui-guard> predicate: ${s}`)}}render(){const t=this.activeState;if(this.slot){const e=ws.includes(this.slot)&&this.slot===t;return this.toggleAttribute("hidden",!e),i.html`<slot></slot>`}this.toggleAttribute("hidden",!1);for(const e of Array.from(this.children)){const s=e.getAttribute("slot");e.toggleAttribute("hidden",s!==t)}return i.html`<slot></slot>`}},oe=new WeakMap,le=new WeakMap,he=new WeakMap,Ie);ve([r.property({reflect:!0})],exports.SinglebaseAuthGuard.prototype,"slot",1);ve([r.property({converter:{fromAttribute:o=>{if(!o)return null;try{return JSON.parse(o)}catch{return console.error("[singlebase] guard predicate is not valid JSON:",o),null}},toAttribute:o=>o?JSON.stringify(o):null}})],exports.SinglebaseAuthGuard.prototype,"predicate",1);ve([r.property({attribute:"on-mismatch"})],exports.SinglebaseAuthGuard.prototype,"onMismatch",1);exports.SinglebaseAuthGuard=ve([r.customElement("singlebase-authui-guard")],exports.SinglebaseAuthGuard);var Ke=Object.defineProperty,ys=Object.getOwnPropertyDescriptor,Ss=(o,n,t)=>n in o?Ke(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t,P=(o,n,t,e)=>{for(var s=e>1?void 0:e?ys(n,t):n,a=o.length-1,d;a>=0;a--)(d=o[a])&&(s=(e?d(n,t,s):d(s))||s);return e&&s&&Ke(n,t,s),s},$s=(o,n,t)=>Ss(o,n+"",t);const Es="profile_photo";var ce,de,ue,pe,ge,Fe;exports.SinglebaseAuthDisplay=(Fe=class extends f{constructor(){super(...arguments);h(this,ce,"");h(this,de,"");h(this,ue,!1);h(this,pe,"");h(this,ge,!1)}get path(){return l(this,ce)}set path(t){c(this,ce,t)}get fallback(){return l(this,de)}set fallback(t){c(this,de,t)}get avatar(){return l(this,ue)}set avatar(t){c(this,ue,t)}get alt(){return l(this,pe)}set alt(t){c(this,pe,t)}get imageFailed(){return l(this,ge)}set imageFailed(t){c(this,ge,t)}willUpdate(t){super.willUpdate(t),(t.has("path")||t.has("avatar"))&&(this.imageFailed=!1)}get profile(){const t=this.auth.state;return t.status==="authenticated"?t.user:null}get textValue(){const t=this.profile;if(!t||!this.path)return"";const e=S.getPath(t,this.path);return e==null||e===""?"":Array.isArray(e)?e.filter(s=>s!=null).join(", "):typeof e=="object"?"":String(e)}get avatarSrc(){const t=this.profile;if(!t)return"";const e=S.getPath(t,this.path||Es);return typeof e=="string"?e:""}render(){if(this.auth.state.status==="loading")return i.nothing;if(this.avatar)return this.renderAvatar();const t=this.textValue;return t?i.html`<span part="text">${t}</span>`:this.fallback?i.html`<span part="text">${this.fallback}</span>`:i.nothing}renderAvatar(){const t=this.profile;if(!t)return i.nothing;const e=this.avatarSrc;return e&&!this.imageFailed?i.html`<img
|
|
908
908
|
part="avatar-image"
|
|
909
909
|
src=${e}
|
|
910
910
|
alt=${this.alt}
|
|
@@ -913,8 +913,8 @@
|
|
|
913
913
|
part="avatar-initials"
|
|
914
914
|
class="initials"
|
|
915
915
|
aria-hidden=${this.alt?"false":"true"}
|
|
916
|
-
>${
|
|
917
|
-
>`}},
|
|
916
|
+
>${Pe(t)}</span
|
|
917
|
+
>`}},ce=new WeakMap,de=new WeakMap,ue=new WeakMap,pe=new WeakMap,ge=new WeakMap,Fe);$s(exports.SinglebaseAuthDisplay,"styles",[...f.styles,i.css`
|
|
918
918
|
/* Text sits in a sentence; an avatar is a box the host sizes. */
|
|
919
919
|
:host {
|
|
920
920
|
display: inline;
|
|
@@ -952,5 +952,5 @@
|
|
|
952
952
|
color: var(--sb-muted-ink, #61666c);
|
|
953
953
|
user-select: none;
|
|
954
954
|
}
|
|
955
|
-
`]);P([r.property()],exports.SinglebaseAuthDisplay.prototype,"path",1);P([r.property()],exports.SinglebaseAuthDisplay.prototype,"fallback",1);P([r.property({type:Boolean,reflect:!0})],exports.SinglebaseAuthDisplay.prototype,"avatar",1);P([r.property()],exports.SinglebaseAuthDisplay.prototype,"alt",1);P([r.state()],exports.SinglebaseAuthDisplay.prototype,"imageFailed",1);exports.SinglebaseAuthDisplay=P([r.customElement("singlebase-authui-display")],exports.SinglebaseAuthDisplay);exports.AuthController=
|
|
956
|
-
//# sourceMappingURL=authui-display-
|
|
955
|
+
`]);P([r.property()],exports.SinglebaseAuthDisplay.prototype,"path",1);P([r.property()],exports.SinglebaseAuthDisplay.prototype,"fallback",1);P([r.property({type:Boolean,reflect:!0})],exports.SinglebaseAuthDisplay.prototype,"avatar",1);P([r.property()],exports.SinglebaseAuthDisplay.prototype,"alt",1);P([r.state()],exports.SinglebaseAuthDisplay.prototype,"imageFailed",1);exports.SinglebaseAuthDisplay=P([r.customElement("singlebase-authui-display")],exports.SinglebaseAuthDisplay);exports.AuthController=Re;exports.SettingsController=fe;exports.defaultMessages=we;exports.fullNameOf=Ce;exports.initialsOf=Pe;exports.isGuestScreen=ye;exports.isProtectedScreen=Ve;exports.isScreen=Se;exports.resolveMessages=je;
|
|
956
|
+
//# sourceMappingURL=authui-display-CMVHTNFz.cjs.map
|