@singlebase/elements 0.3.0 → 0.5.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.
Files changed (51) hide show
  1. package/README.md +2 -0
  2. package/dist/{display-8HEcKYR4.js → authui-display-BCZBP7HR.js} +11 -10
  3. package/dist/authui-display-BCZBP7HR.js.map +1 -0
  4. package/dist/{display-CLDNNZQy.cjs → authui-display-CLGFSqRi.cjs} +21 -21
  5. package/dist/authui-display-CLGFSqRi.cjs.map +1 -0
  6. package/dist/authui.cjs +1 -1
  7. package/dist/authui.d.ts +9 -9
  8. package/dist/authui.js +2 -2
  9. package/dist/chat-DRenTJlI.cjs +3001 -0
  10. package/dist/chat-DRenTJlI.cjs.map +1 -0
  11. package/dist/chat-bXaRWel7.js +4926 -0
  12. package/dist/chat-bXaRWel7.js.map +1 -0
  13. package/dist/chat-messages.d.ts +109 -0
  14. package/dist/chat.cjs +2 -0
  15. package/dist/chat.cjs.map +1 -0
  16. package/dist/chat.d.ts +10 -0
  17. package/dist/chat.js +13 -0
  18. package/dist/chat.js.map +1 -0
  19. package/dist/elements/{account-screen.d.ts → authui-account.d.ts} +1 -1
  20. package/dist/elements/{buttons.d.ts → authui-buttons.d.ts} +1 -1
  21. package/dist/elements/{display.d.ts → authui-display.d.ts} +1 -1
  22. package/dist/elements/{form-base.d.ts → authui-form-base.d.ts} +1 -1
  23. package/dist/elements/{guard.d.ts → authui-guard.d.ts} +1 -1
  24. package/dist/elements/{auth-screen.d.ts → authui.d.ts} +3 -3
  25. package/dist/elements/chat.d.ts +312 -0
  26. package/dist/files-BOwtpYyQ.js +168 -0
  27. package/dist/files-BOwtpYyQ.js.map +1 -0
  28. package/dist/files-DW8A4Jl-.cjs +38 -0
  29. package/dist/files-DW8A4Jl-.cjs.map +1 -0
  30. package/dist/index.cjs +1 -1
  31. package/dist/index.d.ts +3 -2
  32. package/dist/index.js +36 -25
  33. package/dist/index.js.map +1 -1
  34. package/dist/singlebase-elements.min.js +6841 -1824
  35. package/dist/singlebase-elements.min.js.map +1 -1
  36. package/dist/styles/chat.d.ts +6 -0
  37. package/dist/styles/tokens.d.ts +1 -1
  38. package/dist/{uploader-eFYKpk8b.cjs → uploader-DGV2y9uT.cjs} +41 -77
  39. package/dist/uploader-DGV2y9uT.cjs.map +1 -0
  40. package/dist/{uploader-D-Da1trc.js → uploader-abQoem5q.js} +309 -463
  41. package/dist/uploader-abQoem5q.js.map +1 -0
  42. package/dist/uploader.cjs +1 -1
  43. package/dist/uploader.js +5 -4
  44. package/dist/uploader.js.map +1 -1
  45. package/dist/utils/markdown.d.ts +108 -0
  46. package/package.json +13 -5
  47. package/dist/display-8HEcKYR4.js.map +0 -1
  48. package/dist/display-CLDNNZQy.cjs.map +0 -1
  49. package/dist/uploader-D-Da1trc.js.map +0 -1
  50. package/dist/uploader-eFYKpk8b.cjs.map +0 -1
  51. /package/dist/elements/{base.d.ts → authui-base.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";var Je=Object.defineProperty;var xe=o=>{throw TypeError(o)};var Qe=(o,a,t)=>a in o?Je(o,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[a]=t;var p=(o,a,t)=>Qe(o,typeof a!="symbol"?a+"":a,t),Te=(o,a,t)=>a.has(o)||xe("Cannot "+t);var l=(o,a,t)=>(Te(o,a,"read from private field"),t?t.call(o):a.get(o)),h=(o,a,t)=>a.has(o)?xe("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(o):a.set(o,t),c=(o,a,t,e)=>(Te(o,a,"write to private field"),e?e.call(o,t):a.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"),ve=require("./uploader-eFYKpk8b.cjs"),S=require("@singlebase/core");class Fe{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 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",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 Be(o){return o?{...we,...o}:we}var Xe=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,pe=(o,a,t,e)=>{for(var s=Ze(a,t),n=o.length-1,d;n>=0;n--)(d=o[n])&&(s=d(a,t,s)||s);return s&&Xe(a,t,s),s},P,A,k,_,O;class f extends i.LitElement{constructor(){super(...arguments);h(this,P,null);h(this,A,{});h(this,k);h(this,_);h(this,O);p(this,"auth",new Fe(this));p(this,"appliedConfig",new Set)}get client(){return l(this,P)}set client(t){c(this,P,t)}get messages(){return l(this,A)}set messages(t){c(this,A,t)}get theme(){return l(this,k)}set theme(t){c(this,k,t)}get density(){return l(this,_)}set density(t){c(this,_,t)}get fieldStyle(){return l(this,O)}set fieldStyle(t){c(this,O,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 Be(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()}}P=new WeakMap,A=new WeakMap,k=new WeakMap,_=new WeakMap,O=new WeakMap,p(f,"styles",[ve.tokenDefaults,ve.sharedStyles]);pe([r.property({attribute:!1})],f.prototype,"client");pe([r.property({attribute:!1})],f.prototype,"messages");pe([r.property({reflect:!0})],f.prototype,"theme");pe([r.property({reflect:!0})],f.prototype,"density");pe([r.property({reflect:!0,attribute:"field-style"})],f.prototype,"fieldStyle");class be{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 ts=["load","success","error","signin","signup","signout","session","account-updated","password-change","email-change","username-change","expired","navigate","goto"],es={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 Ue(o){return"on"+o.replace(/(^|-)([a-z])/g,(a,t,e)=>e.toUpperCase())}class ss{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=ts.map(t=>a.on(t,e=>this.publish(t,e)))))}publish(a,t){const e=this.host[Ue(a)];if(typeof e=="function")try{e.call(this.host,t)}catch(d){console.error(`[singlebase] ${Ue(a)} threw:`,d)}const s={detail:t,bubbles:!0,composed:!0};this.host.dispatchEvent(new CustomEvent(`singlebase-${a}`,s));const n=es[a];n&&this.host.dispatchEvent(new CustomEvent(n,s))}release(){this.unsubscribes.forEach(a=>a()),this.unsubscribes=[]}hostDisconnected(){this.release(),this.client=null}}var is=Object.defineProperty,ns=Object.getOwnPropertyDescriptor,$e=(o,a,t,e)=>{for(var s=ns(a,t),n=o.length-1,d;n>=0;n--)(d=o[n])&&(s=d(a,t,s)||s);return s&&is(a,t,s),s},x,T,U;class ge extends f{constructor(){super(...arguments);h(this,x,"idle");h(this,T,"");h(this,U,"");p(this,"abortController",null)}get phase(){return l(this,x)}set phase(t){c(this,x,t)}get formError(){return l(this,T)}set formError(t){c(this,T,t)}get noticeMessage(){return l(this,U)}set noticeMessage(t){c(this,U,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 Je=Object.defineProperty;var Oe=o=>{throw TypeError(o)};var Qe=(o,a,t)=>a in o?Je(o,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[a]=t;var p=(o,a,t)=>Qe(o,typeof a!="symbol"?a+"":a,t),xe=(o,a,t)=>a.has(o)||Oe("Cannot "+t);var l=(o,a,t)=>(xe(o,a,"read from private field"),t?t.call(o):a.get(o)),h=(o,a,t)=>a.has(o)?Oe("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(o):a.set(o,t),c=(o,a,t,e)=>(xe(o,a,"write to private field"),e?e.call(o,t):a.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"),Ie=require("./uploader-DGV2y9uT.cjs"),S=require("@singlebase/core"),Xe=require("./files-DW8A4Jl-.cjs");class Fe{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 ve={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 Be(o){return o?{...ve,...o}:ve}var Ze=Object.defineProperty,ts=Object.getOwnPropertyDescriptor,pe=(o,a,t,e)=>{for(var s=ts(a,t),n=o.length-1,d;n>=0;n--)(d=o[n])&&(s=d(a,t,s)||s);return s&&Ze(a,t,s),s},P,A,k,_,O;class f extends i.LitElement{constructor(){super(...arguments);h(this,P,null);h(this,A,{});h(this,k);h(this,_);h(this,O);p(this,"auth",new Fe(this));p(this,"appliedConfig",new Set)}get client(){return l(this,P)}set client(t){c(this,P,t)}get messages(){return l(this,A)}set messages(t){c(this,A,t)}get theme(){return l(this,k)}set theme(t){c(this,k,t)}get density(){return l(this,_)}set density(t){c(this,_,t)}get fieldStyle(){return l(this,O)}set fieldStyle(t){c(this,O,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 Be(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()}}P=new WeakMap,A=new WeakMap,k=new WeakMap,_=new WeakMap,O=new WeakMap,p(f,"styles",[Xe.tokenDefaults,Ie.sharedStyles]);pe([r.property({attribute:!1})],f.prototype,"client");pe([r.property({attribute:!1})],f.prototype,"messages");pe([r.property({reflect:!0})],f.prototype,"theme");pe([r.property({reflect:!0})],f.prototype,"density");pe([r.property({reflect:!0,attribute:"field-style"})],f.prototype,"fieldStyle");class be{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 es=["load","success","error","signin","signup","signout","session","account-updated","password-change","email-change","username-change","expired","navigate","goto"],ss={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 Te(o){return"on"+o.replace(/(^|-)([a-z])/g,(a,t,e)=>e.toUpperCase())}class is{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=es.map(t=>a.on(t,e=>this.publish(t,e)))))}publish(a,t){const e=this.host[Te(a)];if(typeof e=="function")try{e.call(this.host,t)}catch(d){console.error(`[singlebase] ${Te(a)} threw:`,d)}const s={detail:t,bubbles:!0,composed:!0};this.host.dispatchEvent(new CustomEvent(`singlebase-${a}`,s));const n=ss[a];n&&this.host.dispatchEvent(new CustomEvent(n,s))}release(){this.unsubscribes.forEach(a=>a()),this.unsubscribes=[]}hostDisconnected(){this.release(),this.client=null}}var ns=Object.defineProperty,as=Object.getOwnPropertyDescriptor,Se=(o,a,t,e)=>{for(var s=as(a,t),n=o.length-1,d;n>=0;n--)(d=o[n])&&(s=d(a,t,s)||s);return s&&ns(a,t,s),s},x,T,U;class ge extends f{constructor(){super(...arguments);h(this,x,"idle");h(this,T,"");h(this,U,"");p(this,"abortController",null)}get phase(){return l(this,x)}set phase(t){c(this,x,t)}get formError(){return l(this,T)}set formError(t){c(this,T,t)}get noticeMessage(){return l(this,U)}set noticeMessage(t){c(this,U,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
- `}}x=new WeakMap,T=new WeakMap,U=new WeakMap;$e([r.state()],ge.prototype,"phase");$e([r.state()],ge.prototype,"formError");$e([r.state()],ge.prototype,"noticeMessage");function Ee(o){return[o==null?void 0:o.first_name,o==null?void 0:o.last_name].filter(Boolean).join(" ").trim()}function Ce(o){const a=Ee(o);if(a)return a.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 as=Object.defineProperty,rs=Object.getOwnPropertyDescriptor,g=(o,a,t,e)=>{for(var s=e>1?void 0:e?rs(a,t):a,n=o.length-1,d;n>=0;n--)(d=o[n])&&(s=(e?d(a,t,s):d(s))||s);return e&&s&&as(a,t,s),s};const os={profile_photo:!0},ls=".jpg,.jpeg,.png,.webp,image/jpeg,image/png,image/webp";var L,M,N,D,I,F,B,R,j,G,H,q,V,K,Y,W,z,J,Q,X,Z,tt,et,st,it,nt,Le;exports.SinglebaseAccountScreen=(Le=class extends ge{constructor(){super(...arguments);h(this,L,"");h(this,M,"");h(this,N,null);h(this,D,"singlebase-oauth-nonce");h(this,I,"");h(this,F,"");h(this,B,!1);h(this,R,"");h(this,j,"");h(this,G,"");h(this,H,"");h(this,q,"");h(this,V,0);h(this,K,"");h(this,Y,"");h(this,W,"");h(this,z,"");h(this,J,"");h(this,Q,"request");h(this,X,"");h(this,Z,"");h(this,tt,"");h(this,et,"");h(this,st,"");h(this,it,"");h(this,nt,"");p(this,"settingsCtl",new be(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 n;const{completed:e,failed:s}=t.detail;try{e.length?(await((n=this.resolvedClient)==null?void 0:n.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,L)}set logoText(t){c(this,L,t)}get logoUrl(){return l(this,M)}set logoUrl(t){c(this,M,t)}get settings(){return l(this,N)}set settings(t){c(this,N,t)}get nonceStorageKey(){return l(this,D)}set nonceStorageKey(t){c(this,D,t)}get editMode(){return l(this,I)}set editMode(t){c(this,I,t)}get toast(){return l(this,F)}set toast(t){c(this,F,t)}get photoBusy(){return l(this,B)}set photoBusy(t){c(this,B,t)}get photoFailed(){return l(this,R)}set photoFailed(t){c(this,R,t)}get profileSaved(){return l(this,j)}set profileSaved(t){c(this,j,t)}get passSaved(){return l(this,G)}set passSaved(t){c(this,G,t)}get profileError(){return l(this,H)}set profileError(t){c(this,H,t)}get newPassError(){return l(this,q)}set newPassError(t){c(this,q,t)}get deleteStage(){return l(this,V)}set deleteStage(t){c(this,V,t)}get confirmText(){return l(this,K)}set confirmText(t){c(this,K,t)}get dFirst(){return l(this,Y)}set dFirst(t){c(this,Y,t)}get dLast(){return l(this,W)}set dLast(t){c(this,W,t)}get dPhone(){return l(this,z)}set dPhone(t){c(this,z,t)}get dEmail(){return l(this,J)}set dEmail(t){c(this,J,t)}get emailStep(){return l(this,Q)}set emailStep(t){c(this,Q,t)}get dNewEmail(){return l(this,X)}set dNewEmail(t){c(this,X,t)}get emailCode(){return l(this,Z)}set emailCode(t){c(this,Z,t)}get emailError(){return l(this,tt)}set emailError(t){c(this,tt,t)}get emailSaved(){return l(this,et)}set emailSaved(t){c(this,et,t)}get curPass(){return l(this,st)}set curPass(t){c(this,st,t)}get newPass(){return l(this,it)}set newPass(t){c(this,it,t)}get confirmPass(){return l(this,nt)}set confirmPass(t){c(this,nt,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
12
+ `}}x=new WeakMap,T=new WeakMap,U=new WeakMap;Se([r.state()],ge.prototype,"phase");Se([r.state()],ge.prototype,"formError");Se([r.state()],ge.prototype,"noticeMessage");function $e(o){return[o==null?void 0:o.first_name,o==null?void 0:o.last_name].filter(Boolean).join(" ").trim()}function Ee(o){const a=$e(o);if(a)return a.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 rs=Object.defineProperty,os=Object.getOwnPropertyDescriptor,g=(o,a,t,e)=>{for(var s=e>1?void 0:e?os(a,t):a,n=o.length-1,d;n>=0;n--)(d=o[n])&&(s=(e?d(a,t,s):d(s))||s);return e&&s&&rs(a,t,s),s};const ls={profile_photo:!0},hs=".jpg,.jpeg,.png,.webp,image/jpeg,image/png,image/webp";var L,M,N,D,I,F,B,R,j,q,G,H,V,K,Y,W,z,J,Q,X,Z,tt,et,st,it,nt,Ue;exports.SinglebaseAccountScreen=(Ue=class extends ge{constructor(){super(...arguments);h(this,L,"");h(this,M,"");h(this,N,null);h(this,D,"singlebase-oauth-nonce");h(this,I,"");h(this,F,"");h(this,B,!1);h(this,R,"");h(this,j,"");h(this,q,"");h(this,G,"");h(this,H,"");h(this,V,0);h(this,K,"");h(this,Y,"");h(this,W,"");h(this,z,"");h(this,J,"");h(this,Q,"request");h(this,X,"");h(this,Z,"");h(this,tt,"");h(this,et,"");h(this,st,"");h(this,it,"");h(this,nt,"");p(this,"settingsCtl",new be(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 n;const{completed:e,failed:s}=t.detail;try{e.length?(await((n=this.resolvedClient)==null?void 0:n.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,L)}set logoText(t){c(this,L,t)}get logoUrl(){return l(this,M)}set logoUrl(t){c(this,M,t)}get settings(){return l(this,N)}set settings(t){c(this,N,t)}get nonceStorageKey(){return l(this,D)}set nonceStorageKey(t){c(this,D,t)}get editMode(){return l(this,I)}set editMode(t){c(this,I,t)}get toast(){return l(this,F)}set toast(t){c(this,F,t)}get photoBusy(){return l(this,B)}set photoBusy(t){c(this,B,t)}get photoFailed(){return l(this,R)}set photoFailed(t){c(this,R,t)}get profileSaved(){return l(this,j)}set profileSaved(t){c(this,j,t)}get passSaved(){return l(this,q)}set passSaved(t){c(this,q,t)}get profileError(){return l(this,G)}set profileError(t){c(this,G,t)}get newPassError(){return l(this,H)}set newPassError(t){c(this,H,t)}get deleteStage(){return l(this,V)}set deleteStage(t){c(this,V,t)}get confirmText(){return l(this,K)}set confirmText(t){c(this,K,t)}get dFirst(){return l(this,Y)}set dFirst(t){c(this,Y,t)}get dLast(){return l(this,W)}set dLast(t){c(this,W,t)}get dPhone(){return l(this,z)}set dPhone(t){c(this,z,t)}get dEmail(){return l(this,J)}set dEmail(t){c(this,J,t)}get emailStep(){return l(this,Q)}set emailStep(t){c(this,Q,t)}get dNewEmail(){return l(this,X)}set dNewEmail(t){c(this,X,t)}get emailCode(){return l(this,Z)}set emailCode(t){c(this,Z,t)}get emailError(){return l(this,tt)}set emailError(t){c(this,tt,t)}get emailSaved(){return l(this,et)}set emailSaved(t){c(this,et,t)}get curPass(){return l(this,st)}set curPass(t){c(this,st,t)}get newPass(){return l(this,it)}set newPass(t){c(this,it,t)}get confirmPass(){return l(this,nt)}set confirmPass(t){c(this,nt,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 Ee(this.user)}get initials(){return Ce(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`
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 $e(this.user)}get initials(){return Ee(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>
@@ -136,9 +136,9 @@
136
136
  view="button"
137
137
  max-files="1"
138
138
  branding="false"
139
- accept=${ls}
139
+ accept=${hs}
140
140
  .client=${this.uploadClient}
141
- .options=${os}
141
+ .options=${ls}
142
142
  @singlebase-upload-selected=${this.onPhotoSelected}
143
143
  @singlebase-upload-complete=${this.onPhotoUploaded}
144
144
  @singlebase-upload-error=${this.onPhotoProblem}
@@ -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>`}},L=new WeakMap,M=new WeakMap,N=new WeakMap,D=new WeakMap,I=new WeakMap,F=new WeakMap,B=new WeakMap,R=new WeakMap,j=new WeakMap,G=new WeakMap,H=new WeakMap,q=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,nt=new WeakMap,Le);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 hs=Object.defineProperty,cs=Object.getOwnPropertyDescriptor,w=(o,a,t,e)=>{for(var s=e>1?void 0:e?cs(a,t):a,n=o.length-1,d;n>=0;n--)(d=o[n])&&(s=(e?d(a,t,s):d(s))||s);return e&&s&&hs(a,t,s),s},at,rt,ot,lt,ht,ct,dt,Me;exports.SinglebaseAuthButtons=(Me=class extends ge{constructor(){super(...arguments);h(this,at,"signout");h(this,rt,"signin");h(this,ot,"");h(this,lt,"");h(this,ht,!1);h(this,ct,null);h(this,dt,"singlebase-oauth-nonce");p(this,"settingsCtl",new be(this))}get type(){return l(this,at)}set type(t){c(this,at,t)}get intent(){return l(this,rt)}set intent(t){c(this,rt,t)}get provider(){return l(this,ot)}set provider(t){c(this,ot,t)}get providerName(){return l(this,lt)}set providerName(t){c(this,lt,t)}get embedded(){return l(this,ht)}set embedded(t){c(this,ht,t)}get settings(){return l(this,ct)}set settings(t){c(this,ct,t)}get nonceStorageKey(){return l(this,dt)}set nonceStorageKey(t){c(this,dt,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(([,n])=>n.enabled).map(([n,d])=>({id:n,name:d.provider_name,mark:s[n]??d.provider_name.slice(0,2)}))}async startOAuth(t,e,s=!1){const n=this.resolvedClient;if(!n)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 me;const b=await n.createOAuthNonce(this.signal);(me=globalThis.sessionStorage)==null||me.setItem(this.nonceStorageKey,b);const{oauth_redirect_url:v}=await n.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`
407
+ `:i.html`<p class="disabled-note">Not signed in.</p>`}},L=new WeakMap,M=new WeakMap,N=new WeakMap,D=new WeakMap,I=new WeakMap,F=new WeakMap,B=new WeakMap,R=new WeakMap,j=new WeakMap,q=new WeakMap,G=new WeakMap,H=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,nt=new WeakMap,Ue);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 cs=Object.defineProperty,ds=Object.getOwnPropertyDescriptor,w=(o,a,t,e)=>{for(var s=e>1?void 0:e?ds(a,t):a,n=o.length-1,d;n>=0;n--)(d=o[n])&&(s=(e?d(a,t,s):d(s))||s);return e&&s&&cs(a,t,s),s},at,rt,ot,lt,ht,ct,dt,Le;exports.SinglebaseAuthButtons=(Le=class extends ge{constructor(){super(...arguments);h(this,at,"signout");h(this,rt,"signin");h(this,ot,"");h(this,lt,"");h(this,ht,!1);h(this,ct,null);h(this,dt,"singlebase-oauth-nonce");p(this,"settingsCtl",new be(this))}get type(){return l(this,at)}set type(t){c(this,at,t)}get intent(){return l(this,rt)}set intent(t){c(this,rt,t)}get provider(){return l(this,ot)}set provider(t){c(this,ot,t)}get providerName(){return l(this,lt)}set providerName(t){c(this,lt,t)}get embedded(){return l(this,ht)}set embedded(t){c(this,ht,t)}get settings(){return l(this,ct)}set settings(t){c(this,ct,t)}get nonceStorageKey(){return l(this,dt)}set nonceStorageKey(t){c(this,dt,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(([,n])=>n.enabled).map(([n,d])=>({id:n,name:d.provider_name,mark:s[n]??d.provider_name.slice(0,2)}))}async startOAuth(t,e,s=!1){const n=this.resolvedClient;if(!n)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 me;const b=await n.createOAuthNonce(this.signal);(me=globalThis.sessionStorage)==null||me.setItem(this.nonceStorageKey,b);const{oauth_redirect_url:v}=await n.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
 
@@ -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()}},at=new WeakMap,rt=new WeakMap,ot=new WeakMap,lt=new WeakMap,ht=new WeakMap,ct=new WeakMap,dt=new WeakMap,Me);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 Re=Object.defineProperty,ds=Object.getOwnPropertyDescriptor,us=(o,a,t)=>a in o?Re(o,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[a]=t,u=(o,a,t,e)=>{for(var s=e>1?void 0:e?ds(a,t):a,n=o.length-1,d;n>=0;n--)(d=o[n])&&(s=(e?d(a,t,s):d(s))||s);return e&&s&&Re(a,t,s),s},ps=(o,a,t)=>us(o,a+"",t);const je=["signin","signup","forgot","verify","otp","newpass","invite"],Ge=["account"],gs=[...je,...Ge,"oauth-callback"];function ye(o){return je.includes(o)}function He(o){return Ge.includes(o)}function Se(o){return gs.includes(o)}const $={fromAttribute:o=>o===null?!0:o!=="false",toAttribute:o=>o?null:"false"};var ut,pt,gt,mt,bt,ft,vt,wt,yt,St,$t,Et,Ct,Pt,At,kt,_t,Ot,xt,Tt,Ut,Lt,Mt,Nt,Dt,It,Ft,Bt,Rt,jt,Gt,Ht,qt,Vt,Kt,Yt,Wt,zt,Jt,Qt,Xt,Zt,te,ee,se,ie,ne,Ne;exports.SinglebaseAuthScreen=(Ne=class extends f{constructor(){super(...arguments);h(this,ut,"signin");h(this,pt,"");h(this,gt,!1);h(this,mt,null);h(this,bt,!0);h(this,ft,!0);h(this,vt,!0);h(this,wt,!0);h(this,yt,!0);h(this,St,!0);h(this,$t,"card");h(this,Et,"bottom");h(this,Ct,!1);h(this,Pt,"");h(this,At,"");h(this,kt,"");h(this,_t,"");h(this,Ot,"");h(this,xt,!0);h(this,Tt,"");h(this,Ut,"");h(this,Lt,"");h(this,Mt,"singlebase-oauth-nonce");h(this,Nt,"");h(this,Dt,"");h(this,It,"");h(this,Ft,0);h(this,Bt,"");h(this,Rt,"");h(this,jt,"");h(this,Gt,"");h(this,Ht,"");h(this,qt,"");h(this,Vt,"");h(this,Kt,"");h(this,Yt,"");h(this,Wt,["","","","","",""]);h(this,zt,"signin_code");h(this,Jt,!1);h(this,Qt,"");h(this,Xt,"");h(this,Zt,"");h(this,te,"");h(this,ee,"");h(this,se,0);h(this,ie,!1);p(this,"settingsCtl",new be(this));p(this,"bridge",new ss(this));p(this,"uidBase",`sb-${Math.random().toString(36).slice(2,8)}`);p(this,"gotoUnsubscribe");p(this,"gotoClient",null);h(this,ne,!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,ut)}set initialScreen(t){c(this,ut,t)}get screen(){return l(this,pt)}set screen(t){c(this,pt,t)}get noAccountView(){return l(this,gt)}set noAccountView(t){c(this,gt,t)}get settings(){return l(this,mt)}set settings(t){c(this,mt,t)}get authEnabled(){return l(this,bt)}set authEnabled(t){c(this,bt,t)}get allowEmailSignin(){return l(this,ft)}set allowEmailSignin(t){c(this,ft,t)}get allowEmailSignup(){return l(this,vt)}set allowEmailSignup(t){c(this,vt,t)}get allowEmailOtp(){return l(this,wt)}set allowEmailOtp(t){c(this,wt,t)}get allowOauth(){return l(this,yt)}set allowOauth(t){c(this,yt,t)}get allowAccountCreation(){return l(this,St)}set allowAccountCreation(t){c(this,St,t)}get layout(){return l(this,$t)}set layout(t){c(this,$t,t)}get oauthPlacement(){return l(this,Et)}set oauthPlacement(t){c(this,Et,t)}get stepped(){return l(this,Ct)}set stepped(t){c(this,Ct,t)}get logoText(){return l(this,Pt)}set logoText(t){c(this,Pt,t)}get logoUrl(){return l(this,At)}set logoUrl(t){c(this,At,t)}get brandLine(){return l(this,kt)}set brandLine(t){c(this,kt,t)}get brandFoot(){return l(this,_t)}set brandFoot(t){c(this,_t,t)}get signInTitle(){return l(this,Ot)}set signInTitle(t){c(this,Ot,t)}get branding(){return l(this,xt)}set branding(t){c(this,xt,t)}get redirectUrl(){return l(this,Tt)}set redirectUrl(t){c(this,Tt,t)}get tosUrl(){return l(this,Ut)}set tosUrl(t){c(this,Ut,t)}get privacyUrl(){return l(this,Lt)}set privacyUrl(t){c(this,Lt,t)}get nonceStorageKey(){return l(this,Mt)}set nonceStorageKey(t){c(this,Mt,t)}get inviteEmail(){return l(this,Nt)}set inviteEmail(t){c(this,Nt,t)}get inviteOrg(){return l(this,Dt)}set inviteOrg(t){c(this,Dt,t)}get inviteCode(){return l(this,It)}set inviteCode(t){c(this,It,t)}get step(){return l(this,Ft)}set step(t){c(this,Ft,t)}get method(){return l(this,Bt)}set method(t){c(this,Bt,t)}get email(){return l(this,Rt)}set email(t){c(this,Rt,t)}get password(){return l(this,jt)}set password(t){c(this,jt,t)}get name(){return l(this,Gt)}set name(t){c(this,Gt,t)}get firstName(){return l(this,Ht)}set firstName(t){c(this,Ht,t)}get lastName(){return l(this,qt)}set lastName(t){c(this,qt,t)}get phone(){return l(this,Vt)}set phone(t){c(this,Vt,t)}get newPass(){return l(this,Kt)}set newPass(t){c(this,Kt,t)}get confirmPass(){return l(this,Yt)}set confirmPass(t){c(this,Yt,t)}get code(){return l(this,Wt)}set code(t){c(this,Wt,t)}get verifyNext(){return l(this,zt)}set verifyNext(t){c(this,zt,t)}get loading(){return l(this,Jt)}set loading(t){c(this,Jt,t)}get banner(){return l(this,Qt)}set banner(t){c(this,Qt,t)}get notice(){return l(this,Xt)}set notice(t){c(this,Xt,t)}get emailError(){return l(this,Zt)}set emailError(t){c(this,Zt,t)}get passError(){return l(this,te)}set passError(t){c(this,te,t)}get newPassError(){return l(this,ee)}set newPassError(t){c(this,ee,t)}get attempts(){return l(this,se)}set attempts(t){c(this,se,t)}get needsMfaCode(){return l(this,ie)}set needsMfaCode(t){c(this,ie,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: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(He(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"&&ye(this.activeScreen)}get redirectTarget(){var t;return ve.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,ne)}set callbackDone(t){c(this,ne,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 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 n.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 this.branding?i.html`<div class="branding" part="branding">
475
+ `}render(){return this.type==="oauth"?this.renderOAuth():this.type==="link"?this.renderLink():this.renderSignOut()}},at=new WeakMap,rt=new WeakMap,ot=new WeakMap,lt=new WeakMap,ht=new WeakMap,ct=new WeakMap,dt=new WeakMap,Le);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 Re=Object.defineProperty,us=Object.getOwnPropertyDescriptor,ps=(o,a,t)=>a in o?Re(o,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[a]=t,u=(o,a,t,e)=>{for(var s=e>1?void 0:e?us(a,t):a,n=o.length-1,d;n>=0;n--)(d=o[n])&&(s=(e?d(a,t,s):d(s))||s);return e&&s&&Re(a,t,s),s},gs=(o,a,t)=>ps(o,a+"",t);const je=["signin","signup","forgot","verify","otp","newpass","invite"],qe=["account"],ms=[...je,...qe,"oauth-callback"];function we(o){return je.includes(o)}function Ge(o){return qe.includes(o)}function ye(o){return ms.includes(o)}const $={fromAttribute:o=>o===null?!0:o!=="false",toAttribute:o=>o?null:"false"};var ut,pt,gt,mt,bt,ft,vt,wt,yt,St,$t,Et,Ct,Pt,At,kt,_t,Ot,xt,Tt,Ut,Lt,Mt,Nt,Dt,It,Ft,Bt,Rt,jt,qt,Gt,Ht,Vt,Kt,Yt,Wt,zt,Jt,Qt,Xt,Zt,te,ee,se,ie,ne,Me;exports.SinglebaseAuthScreen=(Me=class extends f{constructor(){super(...arguments);h(this,ut,"signin");h(this,pt,"");h(this,gt,!1);h(this,mt,null);h(this,bt,!0);h(this,ft,!0);h(this,vt,!0);h(this,wt,!0);h(this,yt,!0);h(this,St,!0);h(this,$t,"card");h(this,Et,"bottom");h(this,Ct,!1);h(this,Pt,"");h(this,At,"");h(this,kt,"");h(this,_t,"");h(this,Ot,"");h(this,xt,!0);h(this,Tt,"");h(this,Ut,"");h(this,Lt,"");h(this,Mt,"singlebase-oauth-nonce");h(this,Nt,"");h(this,Dt,"");h(this,It,"");h(this,Ft,0);h(this,Bt,"");h(this,Rt,"");h(this,jt,"");h(this,qt,"");h(this,Gt,"");h(this,Ht,"");h(this,Vt,"");h(this,Kt,"");h(this,Yt,"");h(this,Wt,["","","","","",""]);h(this,zt,"signin_code");h(this,Jt,!1);h(this,Qt,"");h(this,Xt,"");h(this,Zt,"");h(this,te,"");h(this,ee,"");h(this,se,0);h(this,ie,!1);p(this,"settingsCtl",new be(this));p(this,"bridge",new is(this));p(this,"uidBase",`sb-${Math.random().toString(36).slice(2,8)}`);p(this,"gotoUnsubscribe");p(this,"gotoClient",null);h(this,ne,!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,ut)}set initialScreen(t){c(this,ut,t)}get screen(){return l(this,pt)}set screen(t){c(this,pt,t)}get noAccountView(){return l(this,gt)}set noAccountView(t){c(this,gt,t)}get settings(){return l(this,mt)}set settings(t){c(this,mt,t)}get authEnabled(){return l(this,bt)}set authEnabled(t){c(this,bt,t)}get allowEmailSignin(){return l(this,ft)}set allowEmailSignin(t){c(this,ft,t)}get allowEmailSignup(){return l(this,vt)}set allowEmailSignup(t){c(this,vt,t)}get allowEmailOtp(){return l(this,wt)}set allowEmailOtp(t){c(this,wt,t)}get allowOauth(){return l(this,yt)}set allowOauth(t){c(this,yt,t)}get allowAccountCreation(){return l(this,St)}set allowAccountCreation(t){c(this,St,t)}get layout(){return l(this,$t)}set layout(t){c(this,$t,t)}get oauthPlacement(){return l(this,Et)}set oauthPlacement(t){c(this,Et,t)}get stepped(){return l(this,Ct)}set stepped(t){c(this,Ct,t)}get logoText(){return l(this,Pt)}set logoText(t){c(this,Pt,t)}get logoUrl(){return l(this,At)}set logoUrl(t){c(this,At,t)}get brandLine(){return l(this,kt)}set brandLine(t){c(this,kt,t)}get brandFoot(){return l(this,_t)}set brandFoot(t){c(this,_t,t)}get signInTitle(){return l(this,Ot)}set signInTitle(t){c(this,Ot,t)}get branding(){return l(this,xt)}set branding(t){c(this,xt,t)}get redirectUrl(){return l(this,Tt)}set redirectUrl(t){c(this,Tt,t)}get tosUrl(){return l(this,Ut)}set tosUrl(t){c(this,Ut,t)}get privacyUrl(){return l(this,Lt)}set privacyUrl(t){c(this,Lt,t)}get nonceStorageKey(){return l(this,Mt)}set nonceStorageKey(t){c(this,Mt,t)}get inviteEmail(){return l(this,Nt)}set inviteEmail(t){c(this,Nt,t)}get inviteOrg(){return l(this,Dt)}set inviteOrg(t){c(this,Dt,t)}get inviteCode(){return l(this,It)}set inviteCode(t){c(this,It,t)}get step(){return l(this,Ft)}set step(t){c(this,Ft,t)}get method(){return l(this,Bt)}set method(t){c(this,Bt,t)}get email(){return l(this,Rt)}set email(t){c(this,Rt,t)}get password(){return l(this,jt)}set password(t){c(this,jt,t)}get name(){return l(this,qt)}set name(t){c(this,qt,t)}get firstName(){return l(this,Gt)}set firstName(t){c(this,Gt,t)}get lastName(){return l(this,Ht)}set lastName(t){c(this,Ht,t)}get phone(){return l(this,Vt)}set phone(t){c(this,Vt,t)}get newPass(){return l(this,Kt)}set newPass(t){c(this,Kt,t)}get confirmPass(){return l(this,Yt)}set confirmPass(t){c(this,Yt,t)}get code(){return l(this,Wt)}set code(t){c(this,Wt,t)}get verifyNext(){return l(this,zt)}set verifyNext(t){c(this,zt,t)}get loading(){return l(this,Jt)}set loading(t){c(this,Jt,t)}get banner(){return l(this,Qt)}set banner(t){c(this,Qt,t)}get notice(){return l(this,Xt)}set notice(t){c(this,Xt,t)}get emailError(){return l(this,Zt)}set emailError(t){c(this,Zt,t)}get passError(){return l(this,te)}set passError(t){c(this,te,t)}get newPassError(){return l(this,ee)}set newPassError(t){c(this,ee,t)}get attempts(){return l(this,se)}set attempts(t){c(this,se,t)}get needsMfaCode(){return l(this,ie)}set needsMfaCode(t){c(this,ie,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:d})=>{ye(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 ye(t)?t:"signin"}get activeScreen(){if(this.isOAuthCallback)return"oauth-callback";const t=this.auth.state.status==="authenticated",e=this.requestedScreen;if(Ge(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"&&we(this.activeScreen)}get redirectTarget(){var t;return Ie.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,ne)}set callbackDone(t){c(this,ne,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 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 n.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 this.branding?i.html`<div class="branding" part="branding">
476
476
  <a href="https://singlebase.cloud" target="_blank" rel="noopener noreferrer"
477
477
  >${this.msg.brandingLabel}</a
478
478
  >
@@ -582,14 +582,14 @@
582
582
  >
583
583
  ${this.msg.otpInsteadLink}
584
584
  </button>`:i.nothing}
585
- `}renderAccordion(t){const e=this.cfg,s=t==="signin"&&e.allowEmailSignin||t==="signup"&&e.allowEmailSignup||t==="otp"&&e.allowEmailOtp,n=e.allowOauth;if(!s&&!n)return i.nothing;const d=s&&n,m=s?n&&this.method||"email":"oauth",b=m==="email",v=m==="oauth",me=t==="signup"?this.msg.emailMethodTitleSignUp:this.msg.emailMethodTitle,Ve=t==="otp"?this.msg.emailMethodMetaOtp:t==="signup"?this.msg.emailMethodMetaSignUp:this.msg.emailMethodMeta,Pe=(_e,Ke,Ye,We,ze,Oe)=>i.html`
586
- <div class="acc-item ${_e?"open":""} ${d?"":"bare"}" part="acc-item">
585
+ `}renderAccordion(t){const e=this.cfg,s=t==="signin"&&e.allowEmailSignin||t==="signup"&&e.allowEmailSignup||t==="otp"&&e.allowEmailOtp,n=e.allowOauth;if(!s&&!n)return i.nothing;const d=s&&n,m=s?n&&this.method||"email":"oauth",b=m==="email",v=m==="oauth",me=t==="signup"?this.msg.emailMethodTitleSignUp:this.msg.emailMethodTitle,Ve=t==="otp"?this.msg.emailMethodMetaOtp:t==="signup"?this.msg.emailMethodMetaSignUp:this.msg.emailMethodMeta,Ce=(ke,Ke,Ye,We,ze,_e)=>i.html`
586
+ <div class="acc-item ${ke?"open":""} ${d?"":"bare"}" part="acc-item">
587
587
  ${d?i.html`
588
588
  <button
589
589
  type="button"
590
590
  class="acc-head"
591
- aria-expanded=${_e?"true":"false"}
592
- aria-controls=${this.uid(`acc-${Oe}`)}
591
+ aria-expanded=${ke?"true":"false"}
592
+ aria-controls=${this.uid(`acc-${_e}`)}
593
593
  @click=${ze}
594
594
  >
595
595
  <span class="chev" aria-hidden="true">›</span>
@@ -597,13 +597,13 @@
597
597
  <span class="acc-meta">${Ye}</span>
598
598
  </button>
599
599
  `:i.nothing}
600
- <div class="acc-body" id=${this.uid(`acc-${Oe}`)}>
600
+ <div class="acc-body" id=${this.uid(`acc-${_e}`)}>
601
601
  <div class="acc-clip">
602
602
  <div class="acc-inner">${We}</div>
603
603
  </div>
604
604
  </div>
605
605
  </div>
606
- `,Ae=s?Pe(b,me,Ve,this.renderEmailMethodBody(t),()=>this.method=b?"":"email","email"):i.nothing,ke=n?Pe(v,this.msg.oauthMethodTitle,this.msg.oauthMethodMeta,i.html`<singlebase-authui-buttons
606
+ `,Pe=s?Ce(b,me,Ve,this.renderEmailMethodBody(t),()=>this.method=b?"":"email","email"):i.nothing,Ae=n?Ce(v,this.msg.oauthMethodTitle,this.msg.oauthMethodMeta,i.html`<singlebase-authui-buttons
607
607
  type="oauth"
608
608
  embedded
609
609
  theme=${E.ifDefined(this.theme)}
@@ -615,7 +615,7 @@
615
615
  intent=${t==="signup"?"signup":"signin"}
616
616
  ></singlebase-authui-buttons>`,()=>this.method=v?"":"oauth","oauth"):i.nothing;return i.html`
617
617
  <div class="acc-wrap">
618
- ${this.oauthPlacement==="top"?i.html`${ke}${Ae}`:i.html`${Ae}${ke}`}
618
+ ${this.oauthPlacement==="top"?i.html`${Ae}${Pe}`:i.html`${Pe}${Ae}`}
619
619
  </div>
620
620
  `}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`
621
621
  ${this.renderCodeRow()}
@@ -813,7 +813,7 @@
813
813
  logo-text=${this.logoText}
814
814
  logo-url=${this.logoUrl}
815
815
  ></singlebase-authui-account>
816
- `);if(this.showsSignedInInterstitial)return this.noAccountView?i.nothing:this.panel(this.renderSignedIn());const e=this.cfg,s=!e.allowEmailSignin&&!e.allowEmailOtp&&!e.allowOauth,n=!e.authEnabled||s&&ye(t);return i.html`
816
+ `);if(this.showsSignedInInterstitial)return this.noAccountView?i.nothing:this.panel(this.renderSignedIn());const e=this.cfg,s=!e.allowEmailSignin&&!e.allowEmailOtp&&!e.allowOauth,n=!e.authEnabled||s&&we(t);return i.html`
817
817
  ${this.layout==="split"?i.html`
818
818
  <div class="brand-panel">
819
819
  ${this.renderBrandMark()}
@@ -822,7 +822,7 @@
822
822
  </div>
823
823
  `:i.nothing}
824
824
  ${this.panel(n?this.renderBlocked():this.renderGuest(t))}
825
- `}},ut=new WeakMap,pt=new WeakMap,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,xt=new WeakMap,Tt=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,Gt=new WeakMap,Ht=new WeakMap,qt=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,ne=new WeakMap,Ne);ps(exports.SinglebaseAuthScreen,"styles",[...f.styles,i.css`
825
+ `}},ut=new WeakMap,pt=new WeakMap,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,xt=new WeakMap,Tt=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,Gt=new WeakMap,Ht=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,ne=new WeakMap,Me);gs(exports.SinglebaseAuthScreen,"styles",[...f.styles,i.css`
826
826
  /* the mock's root */
827
827
  :host {
828
828
  display: flex;
@@ -924,7 +924,7 @@
924
924
  border-bottom: 1px solid var(--sb-border, #e4e6e9);
925
925
  }
926
926
  }
927
- `]);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 ms=Object.defineProperty,bs=Object.getOwnPropertyDescriptor,fe=(o,a,t,e)=>{for(var s=e>1?void 0:e?bs(a,t):a,n=o.length-1,d;n>=0;n--)(d=o[n])&&(s=(e?d(a,t,s):d(s))||s);return e&&s&&ms(a,t,s),s};const fs=["loading","authenticated","unauthenticated"];var ae,re,oe,De;exports.SinglebaseAuthGuard=(De=class extends f{constructor(){super(...arguments);h(this,ae,"");h(this,re,null);h(this,oe,"unauthenticated");p(this,"warnedFor",null)}get slot(){return l(this,ae)}set slot(t){c(this,ae,t)}get predicate(){return l(this,re)}set predicate(t){c(this,re,t)}get onMismatch(){return l(this,oe)}set onMismatch(t){c(this,oe,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=fs.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>`}},ae=new WeakMap,re=new WeakMap,oe=new WeakMap,De);fe([r.property({reflect:!0})],exports.SinglebaseAuthGuard.prototype,"slot",1);fe([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);fe([r.property({attribute:"on-mismatch"})],exports.SinglebaseAuthGuard.prototype,"onMismatch",1);exports.SinglebaseAuthGuard=fe([r.customElement("singlebase-authui-guard")],exports.SinglebaseAuthGuard);var qe=Object.defineProperty,vs=Object.getOwnPropertyDescriptor,ws=(o,a,t)=>a in o?qe(o,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[a]=t,C=(o,a,t,e)=>{for(var s=e>1?void 0:e?vs(a,t):a,n=o.length-1,d;n>=0;n--)(d=o[n])&&(s=(e?d(a,t,s):d(s))||s);return e&&s&&qe(a,t,s),s},ys=(o,a,t)=>ws(o,a+"",t);const Ss="profile_photo";var le,he,ce,de,ue,Ie;exports.SinglebaseAuthDisplay=(Ie=class extends f{constructor(){super(...arguments);h(this,le,"");h(this,he,"");h(this,ce,!1);h(this,de,"");h(this,ue,!1)}get path(){return l(this,le)}set path(t){c(this,le,t)}get fallback(){return l(this,he)}set fallback(t){c(this,he,t)}get avatar(){return l(this,ce)}set avatar(t){c(this,ce,t)}get alt(){return l(this,de)}set alt(t){c(this,de,t)}get imageFailed(){return l(this,ue)}set imageFailed(t){c(this,ue,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||Ss);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
927
+ `]);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 bs=Object.defineProperty,fs=Object.getOwnPropertyDescriptor,fe=(o,a,t,e)=>{for(var s=e>1?void 0:e?fs(a,t):a,n=o.length-1,d;n>=0;n--)(d=o[n])&&(s=(e?d(a,t,s):d(s))||s);return e&&s&&bs(a,t,s),s};const vs=["loading","authenticated","unauthenticated"];var ae,re,oe,Ne;exports.SinglebaseAuthGuard=(Ne=class extends f{constructor(){super(...arguments);h(this,ae,"");h(this,re,null);h(this,oe,"unauthenticated");p(this,"warnedFor",null)}get slot(){return l(this,ae)}set slot(t){c(this,ae,t)}get predicate(){return l(this,re)}set predicate(t){c(this,re,t)}get onMismatch(){return l(this,oe)}set onMismatch(t){c(this,oe,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=vs.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>`}},ae=new WeakMap,re=new WeakMap,oe=new WeakMap,Ne);fe([r.property({reflect:!0})],exports.SinglebaseAuthGuard.prototype,"slot",1);fe([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);fe([r.property({attribute:"on-mismatch"})],exports.SinglebaseAuthGuard.prototype,"onMismatch",1);exports.SinglebaseAuthGuard=fe([r.customElement("singlebase-authui-guard")],exports.SinglebaseAuthGuard);var He=Object.defineProperty,ws=Object.getOwnPropertyDescriptor,ys=(o,a,t)=>a in o?He(o,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[a]=t,C=(o,a,t,e)=>{for(var s=e>1?void 0:e?ws(a,t):a,n=o.length-1,d;n>=0;n--)(d=o[n])&&(s=(e?d(a,t,s):d(s))||s);return e&&s&&He(a,t,s),s},Ss=(o,a,t)=>ys(o,a+"",t);const $s="profile_photo";var le,he,ce,de,ue,De;exports.SinglebaseAuthDisplay=(De=class extends f{constructor(){super(...arguments);h(this,le,"");h(this,he,"");h(this,ce,!1);h(this,de,"");h(this,ue,!1)}get path(){return l(this,le)}set path(t){c(this,le,t)}get fallback(){return l(this,he)}set fallback(t){c(this,he,t)}get avatar(){return l(this,ce)}set avatar(t){c(this,ce,t)}get alt(){return l(this,de)}set alt(t){c(this,de,t)}get imageFailed(){return l(this,ue)}set imageFailed(t){c(this,ue,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||$s);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
928
928
  part="avatar-image"
929
929
  src=${e}
930
930
  alt=${this.alt}
@@ -933,8 +933,8 @@
933
933
  part="avatar-initials"
934
934
  class="initials"
935
935
  aria-hidden=${this.alt?"false":"true"}
936
- >${Ce(t)}</span
937
- >`}},le=new WeakMap,he=new WeakMap,ce=new WeakMap,de=new WeakMap,ue=new WeakMap,Ie);ys(exports.SinglebaseAuthDisplay,"styles",[...f.styles,i.css`
936
+ >${Ee(t)}</span
937
+ >`}},le=new WeakMap,he=new WeakMap,ce=new WeakMap,de=new WeakMap,ue=new WeakMap,De);Ss(exports.SinglebaseAuthDisplay,"styles",[...f.styles,i.css`
938
938
  /* Text sits in a sentence; an avatar is a box the host sizes. */
939
939
  :host {
940
940
  display: inline;
@@ -972,5 +972,5 @@
972
972
  color: var(--sb-muted-ink, #61666c);
973
973
  user-select: none;
974
974
  }
975
- `]);C([r.property()],exports.SinglebaseAuthDisplay.prototype,"path",1);C([r.property()],exports.SinglebaseAuthDisplay.prototype,"fallback",1);C([r.property({type:Boolean,reflect:!0})],exports.SinglebaseAuthDisplay.prototype,"avatar",1);C([r.property()],exports.SinglebaseAuthDisplay.prototype,"alt",1);C([r.state()],exports.SinglebaseAuthDisplay.prototype,"imageFailed",1);exports.SinglebaseAuthDisplay=C([r.customElement("singlebase-authui-display")],exports.SinglebaseAuthDisplay);exports.AuthController=Fe;exports.SettingsController=be;exports.defaultMessages=we;exports.fullNameOf=Ee;exports.initialsOf=Ce;exports.isGuestScreen=ye;exports.isProtectedScreen=He;exports.isScreen=Se;exports.resolveMessages=Be;
976
- //# sourceMappingURL=display-CLDNNZQy.cjs.map
975
+ `]);C([r.property()],exports.SinglebaseAuthDisplay.prototype,"path",1);C([r.property()],exports.SinglebaseAuthDisplay.prototype,"fallback",1);C([r.property({type:Boolean,reflect:!0})],exports.SinglebaseAuthDisplay.prototype,"avatar",1);C([r.property()],exports.SinglebaseAuthDisplay.prototype,"alt",1);C([r.state()],exports.SinglebaseAuthDisplay.prototype,"imageFailed",1);exports.SinglebaseAuthDisplay=C([r.customElement("singlebase-authui-display")],exports.SinglebaseAuthDisplay);exports.AuthController=Fe;exports.SettingsController=be;exports.defaultMessages=ve;exports.fullNameOf=$e;exports.initialsOf=Ee;exports.isGuestScreen=we;exports.isProtectedScreen=Ge;exports.isScreen=ye;exports.resolveMessages=Be;
976
+ //# sourceMappingURL=authui-display-CLGFSqRi.cjs.map