@tempots/beatui 0.49.0 → 0.50.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.cjs.js +1 -1
- package/dist/auth/index.es.js +467 -461
- package/dist/beatui.css +4 -0
- package/dist/beatui.tailwind.css +4 -0
- package/dist/types/components/auth/auth-container.d.ts +1 -1
- package/dist/types/components/auth/signup-form.d.ts +1 -1
- package/dist/types/components/auth/types.d.ts +2 -0
- package/package.json +1 -1
package/dist/auth/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@tempots/dom"),u=require("../notice-CNrZMX-r.cjs"),w=require("../modal-CwLXTMFb.cjs"),S=require("../translations-Cd5YXXFP.cjs"),y=require("../translations-0qZADR5l.cjs"),X=require("@tempots/ui"),q={google:{name:"Google",icon:"logos:google-icon",color:"#4285f4"},github:{name:"GitHub",icon:"logos:github-icon",color:"#333"},apple:{name:"Apple",icon:"logos:apple",color:"#000"},facebook:{name:"Facebook",icon:"logos:facebook",color:"#1877f2"},twitter:{name:"Twitter",icon:"logos:twitter",color:"#1da1f2"},microsoft:{name:"Microsoft",icon:"logos:microsoft-icon",color:"#00a4ef"},discord:{name:"Discord",icon:"logos:discord-icon",color:"#5865f2"},linkedin:{name:"LinkedIn",icon:"logos:linkedin-icon",color:"#0077b5"},instagram:{name:"Instagram",icon:"logos:instagram-icon",color:"#e4405f"},tiktok:{name:"TikTok",icon:"logos:tiktok-icon",color:"#000"},snapchat:{name:"Snapchat",icon:"logos:snapchat-icon",color:"#fffc00"},reddit:{name:"Reddit",icon:"logos:reddit-icon",color:"#ff4500"},pinterest:{name:"Pinterest",icon:"logos:pinterest-icon",color:"#bd081c"},twitch:{name:"Twitch",icon:"logos:twitch",color:"#9146ff"},steam:{name:"Steam",icon:"logos:steam-icon",color:"#000"},epic:{name:"Epic Games",icon:"simple-icons:epicgames",color:"#313131"},playstation:{name:"PlayStation",icon:"logos:playstation-icon",color:"#003791"},xbox:{name:"Xbox",icon:"logos:xbox-icon",color:"#107c10"},whatsapp:{name:"WhatsApp",icon:"logos:whatsapp-icon",color:"#25d366"},wechat:{name:"WeChat",icon:"logos:wechat-icon",color:"#1aad19"},amazon:{name:"Amazon",icon:"logos:amazon-icon",color:"#ff9900"},yahoo:{name:"Yahoo",icon:"logos:yahoo-icon",color:"#720e9e"},paypal:{name:"PayPal",icon:"logos:paypal",color:"#0070ba"},x:{name:"X",icon:"simple-icons:x",color:"#000"}};function D(o){return q[o]?.name||o}function Y(o){return q[o]?.icon||"mdi:account"}function Z(o){return q[o]?.color||"#666"}function J(o,e="Continue with {provider}"){return e.replace("{provider}",D(o))}const P={minLength:8,requireUppercase:!0,requireLowercase:!0,requireNumbers:!0,requireSymbols:!1};function K(o){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o)}function V(o=32){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let i="";for(let l=0;l<o;l++)i+=e.charAt(Math.floor(Math.random()*e.length));return i}function Q(o,e,i,l=[],c={}){const r={google:"https://accounts.google.com/oauth/authorize",github:"https://github.com/login/oauth/authorize",apple:"https://appleid.apple.com/auth/authorize",facebook:"https://www.facebook.com/v18.0/dialog/oauth",twitter:"https://twitter.com/i/oauth2/authorize",microsoft:"https://login.microsoftonline.com/common/oauth2/v2.0/authorize",discord:"https://discord.com/api/oauth2/authorize",linkedin:"https://www.linkedin.com/oauth/v2/authorization",instagram:"https://api.instagram.com/oauth/authorize",tiktok:"https://www.tiktok.com/v2/auth/authorize",snapchat:"https://accounts.snapchat.com/accounts/oauth2/authorize",reddit:"https://www.reddit.com/api/v1/authorize",pinterest:"https://api.pinterest.com/oauth/",twitch:"https://id.twitch.tv/oauth2/authorize",steam:"https://steamcommunity.com/oauth/authorize",epic:"https://auth.epicgames.com/authorize",playstation:"https://auth.api.sonyentertainmentnetwork.com/oauth/authorize",xbox:"https://login.live.com/oauth20_authorize.srf",whatsapp:"https://web.whatsapp.com/oauth/authorize",wechat:"https://open.weixin.qq.com/connect/qrconnect",amazon:"https://www.amazon.com/ap/oa",yahoo:"https://api.login.yahoo.com/oauth2/request_auth",paypal:"https://www.paypal.com/signin/authorize",x:"https://api.twitter.com/oauth2/authorize"},a={google:["openid","email","profile"],github:["user:email"],apple:["email","name"],facebook:["email"],twitter:["users.read"],microsoft:["openid","email","profile"],discord:["identify","email"],linkedin:["r_liteprofile","r_emailaddress"],instagram:["user_profile","user_media"],tiktok:["user.info.basic","user.external.id"],snapchat:["user.info.basic","user.external.id"],reddit:["identity","email"],pinterest:["read_public","read_relationships"],twitch:["openid","email","profile"],steam:["openid","email","profile"],epic:["openid","email","profile"],playstation:["openid","email","profile"],xbox:["openid","email","profile"],whatsapp:["openid","email","profile"],wechat:["openid","email","profile"],amazon:["openid","email","profile"],yahoo:["openid","email","profile"],paypal:["openid","email","profile"],x:["openid","email","profile"]},n=r[o];if(!n)throw new Error(`Unsupported provider: ${o}`);const m=l.length>0?l:a[o],s=V(),f=new URLSearchParams({client_id:e,redirect_uri:i,scope:m.join(" "),state:s,response_type:"code",...c});return`${n}?${f.toString()}`}function tt(o,e,i,l){const c=window.open(o,`${e}_login`,"width=500,height=600,scrollbars=yes,resizable=yes");if(!c){l?.(new Error("Failed to open popup window"));return}const r=setInterval(()=>{c.closed&&(clearInterval(r),l?.(new Error("Login cancelled")))},1e3),a=n=>{n.origin===window.location.origin&&(n.data.type==="SOCIAL_LOGIN_SUCCESS"?(clearInterval(r),c.close(),window.removeEventListener("message",a),i?.(n.data.result)):n.data.type==="SOCIAL_LOGIN_ERROR"&&(clearInterval(r),c.close(),window.removeEventListener("message",a),l?.(new Error(n.data.error))))};window.addEventListener("message",a)}function ot(o){return o instanceof Error?o.message:typeof o=="string"?o:o&&typeof o=="object"&&"message"in o?String(o.message):"An unexpected error occurred"}function et(){return typeof window<"u"&&typeof document<"u"}function A({task:o,message:e,onStart:i,onEnd:l}){return async c=>{i?.();const r=await u.taskToValidation({task:o!=null?()=>o(c):async()=>null,errorMessage:e,errorPath:["root"],validation:a=>a!=null?u.a.invalid({message:a}):u.a.valid});return l?.(),r}}function C(o=P){let e=w.string();return o.minLength&&(e=e.min(o.minLength,`Password must be at least ${o.minLength} characters`)),o.requireUppercase&&(e=e.regex(/[A-Z]/,"Password must contain at least one uppercase letter")),o.requireLowercase&&(e=e.regex(/[a-z]/,"Password must contain at least one lowercase letter")),o.requireNumbers&&(e=e.regex(/[0-9]/,"Password must contain at least one number")),o.requireSymbols&&(e=e.regex(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/,"Password must contain at least one special character")),o.customValidation&&(e=e.refine(i=>o.customValidation(i))),e}const B=w.string().min(1,"Email is required").email("Please enter a valid email address");function T(o){const e=o?C(o):w.string().refine(i=>i.length>0?null:"Password is required");return w.object({email:B,password:e,rememberMe:w.boolean().default(!1)}).schema()}function $(o=P,e){const i=C(o),l=e?.showNameField!==!1,c=e?.showConfirmPassword!==!1,r=e?.showAcceptTermsAndConditions!==!1,a={name:l?w.string().min(1,"Name is required").optional():w.string().optional(),email:B,password:i,confirmPassword:c?w.string().min(1,"Please confirm your password"):w.string(),acceptTerms:r?w.boolean().refine(m=>m===!0,"You must accept the terms and conditions"):w.boolean().default(!0)},n=w.object(a);return c?n.refine(m=>m.password===m.confirmPassword?null:"Passwords don't match",{path:["confirmPassword"]}).schema():n.schema()}const W=w.object({email:B}).schema(),at=T(),nt=$(),rt={signIn:T,signUp:$,resetPassword:()=>W};function st(o){const e=B.validate(o);return e.success?null:e.errors[0]?.message||"Invalid email"}function it(o,e=P){const l=C(e).validate(o);return l.success?null:l.errors[0]?.message||"Invalid password"}function O(o,e=P){const i={length:o.length>=(e.minLength||8),uppercase:/[A-Z]/.test(o),lowercase:/[a-z]/.test(o),numbers:/[0-9]/.test(o),symbols:/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(o),custom:e.customValidation?e.customValidation(o)===null:o.length>0},l=[!0,e.requireUppercase,e.requireLowercase,e.requireNumbers,e.requireSymbols,!!e.customValidation].filter(Boolean).length,c=[i.length,e.requireUppercase?i.uppercase:null,e.requireLowercase?i.lowercase:null,e.requireNumbers?i.numbers:null,e.requireSymbols?i.symbols:null,e.customValidation?i.custom:null].filter(n=>n===!0).length,r=l>0?Math.round(c/l*100):0;let a;return r<40?a="weak":r<60?a="fair":r<80?a="good":a="strong",{strength:a,score:r,checks:i}}const F=()=>t.localStorageProp({key:"bui_auth_email",defaultValue:null});function R({onSignIn:o,passwordRules:e,labels:i,showRememberMe:l}){const c=t.prop(!1),r=F(),a=T(e),n=u.useForm({schema:a,onSubmit:A({task:o,message:"Reset password failed",onStart:()=>{c.set(!0),n.controller.disable()},onEnd:()=>{c.set(!1),n.controller.enable()}}),initialValue:{email:"",password:""}}),{controller:m,submit:s}=n;c.on(m.setDisabled);const f=m.field("email"),b=m.field("password");return r.on(h=>{h!=null&&f.change(h)}),f.signal.on(h=>{r.value!=null&&(r.value=h)}),t.Use(S.AuthI18n,h=>t.html.form(t.OnDispose(m.dispose,r.dispose,c.dispose),t.attr.class("bc-auth-form__form"),t.on.submit(s),u.Stack(t.attr.class("bc-auth-form__fields"),t.Ensure(m.error,g=>u.Notice({variant:"danger",tone:"prominent",role:"alert"},t.html.div(g))),u.Control(u.EmailInput,{controller:f,label:t.coalesce(i?.emailLabel,h.$.emailLabel)}),u.Control(u.PasswordInput,{controller:b,label:t.coalesce(i?.passwordLabel,h.$.passwordLabel)}),t.When(l??!0,()=>t.html.div(t.attr.class("bc-auth-form__remember-me"),t.html.label(t.attr.class("bc-auth-form__checkbox-label"),u.CheckboxInput({value:r.map(g=>g!=null),after:t.html.span(t.coalesce(i?.rememberMeLabel,h.$.rememberMeLabel)),onChange:g=>{g?r.value=f.signal.value??"":r.value=null}}))))),y.Button({type:"submit",variant:"filled",color:"primary",loading:c,disabled:m.disabledOrHasErrors},t.attr.class("bc-auth-form__submit"),t.coalesce(i?.signInButton,h.$.signInButton))))}function M({password:o,rules:e=P,showLabel:i=!0,className:l}){const c=t.computedOf(o)(s=>!s||s.length===0?{strength:"weak",score:0,checks:{length:!1,uppercase:!1,lowercase:!1,numbers:!1,symbols:!1,custom:!1}}:O(s,e)),r=c.map(s=>s.strength),a=c.map(s=>s.score),n=c.map(s=>s.checks),m=t.computedOf(r,l)((s,f)=>["bc-password-strength",`bc-password-strength--${s}`,f].filter(Boolean).join(" "));return t.html.div(t.OnDispose(c,m),t.attr.class(m),t.html.div(t.attr.class("bc-password-strength__bar"),t.html.div(t.attr.class("bc-password-strength__fill"),t.attr.style(a.map(s=>`width: ${s}%`)))),t.When(i,()=>t.Use(S.AuthI18n,s=>t.html.div(t.attr.class("bc-password-strength__label"),t.computedOf(r,s)((f,b)=>{switch(f){case"weak":return b.passwordStrengthWeak;case"fair":return b.passwordStrengthFair;case"good":return b.passwordStrengthGood;case"strong":return b.passwordStrengthStrong;default:return b.passwordStrengthWeak}})))),t.html.div(t.attr.class("bc-password-strength__requirements"),t.When(e.minLength!==void 0,()=>t.html.div(t.attr.class("bc-password-strength__requirement"),t.attr.class(t.computedOf(n)(s=>s.length?"bc-password-strength__requirement--met":"")),t.html.span(t.attr.class("bc-password-strength__requirement-icon"),t.computedOf(n)(s=>s.length?"✓":"○")),t.html.span(t.attr.class("bc-password-strength__requirement-text"),`At least ${e.minLength} characters`))),t.When(e.requireUppercase===!0,()=>t.html.div(t.attr.class("bc-password-strength__requirement"),t.attr.class(t.computedOf(n)(s=>s.uppercase?"bc-password-strength__requirement--met":"")),t.html.span(t.attr.class("bc-password-strength__requirement-icon"),t.computedOf(n)(s=>s.uppercase?"✓":"○")),t.html.span(t.attr.class("bc-password-strength__requirement-text"),"One uppercase letter"))),t.When(e.requireLowercase===!0,()=>t.html.div(t.attr.class("bc-password-strength__requirement"),t.attr.class(t.computedOf(n)(s=>s.lowercase?"bc-password-strength__requirement--met":"")),t.html.span(t.attr.class("bc-password-strength__requirement-icon"),t.computedOf(n)(s=>s.lowercase?"✓":"○")),t.html.span(t.attr.class("bc-password-strength__requirement-text"),"One lowercase letter"))),t.When(e.requireNumbers===!0,()=>t.html.div(t.attr.class("bc-password-strength__requirement"),t.attr.class(t.computedOf(n)(s=>s.numbers?"bc-password-strength__requirement--met":"")),t.html.span(t.attr.class("bc-password-strength__requirement-icon"),t.computedOf(n)(s=>s.numbers?"✓":"○")),t.html.span(t.attr.class("bc-password-strength__requirement-text"),"One number"))),t.When(e.requireSymbols===!0,()=>t.html.div(t.attr.class("bc-password-strength__requirement"),t.attr.class(t.computedOf(n)(s=>s.symbols?"bc-password-strength__requirement--met":"")),t.html.span(t.attr.class("bc-password-strength__requirement-icon"),t.computedOf(n)(s=>s.symbols?"✓":"○")),t.html.span(t.attr.class("bc-password-strength__requirement-text"),"One special character")))))}function ct({password:o,rules:e=P,className:i}){const l=t.computedOf(o)(n=>!n||n.length===0?{strength:"weak",score:0}:O(n,e)),c=l.map(n=>n.strength),r=l.map(n=>n.score),a=t.computedOf(c,i)((n,m)=>["bc-password-strength-bar",`bc-password-strength-bar--${n}`,m].filter(Boolean).join(" "));return t.html.div(t.OnDispose(l,a),t.attr.class(a),t.html.div(t.attr.class("bc-password-strength-bar__fill"),t.attr.style(r.map(n=>`width: ${n}%`))))}function lt({password:o,rules:e=P,className:i}){const l=t.computedOf(o)(r=>!r||r.length===0?"weak":O(r,e).strength),c=t.computedOf(l,i)((r,a)=>["bc-password-strength-text",`bc-password-strength-text--${r}`,a].filter(Boolean).join(" "));return t.Fragment(t.OnDispose(l,c),t.Use(S.AuthI18n,r=>t.html.span(t.attr.class(c),t.computedOf(l,r)((a,n)=>{switch(a){case"weak":return n.passwordStrengthWeak;case"fair":return n.passwordStrengthFair;case"good":return n.passwordStrengthGood;case"strong":return n.passwordStrengthStrong;default:return n.passwordStrengthWeak}}))))}function N({passwordRules:o,labels:e,showPasswordStrength:i,onSignUp:l,showNameField:c,showConfirmPassword:r,showAcceptTermsAndConditions:a,termsAndConditions:n}){const m=t.prop(!1),s=o||P,f=$(s,{showNameField:c!==!1,showConfirmPassword:r!==!1,showAcceptTermsAndConditions:a!==!1}),b=u.useForm({schema:f,onSubmit:A({task:l!=null?v=>l({email:v.email,password:v.password,name:v.name}):void 0,message:"Reset password failed",onStart:()=>{m.set(!0),b.controller.disable()},onEnd:()=>{m.set(!1),b.controller.enable()}}),initialValue:{name:"",email:"",password:"",confirmPassword:"",acceptTerms:!1}}),{controller:h,submit:g}=b;m.on(h.setDisabled);const _=h.field("name"),I=h.field("email"),x=h.field("password"),z=h.field("confirmPassword"),k=h.field("acceptTerms");return t.Use(S.AuthI18n,v=>t.html.form(t.OnDispose(h.dispose,m.dispose),t.attr.class("bc-auth-form__form"),t.on.submit(g),u.Stack(t.attr.class("bc-auth-form__fields"),t.Ensure(h.error,L=>u.Notice({variant:"danger",tone:"prominent",role:"alert"},t.html.div(L))),t.When(c!==!1,()=>u.Control(y.TextInput,{controller:_.transform(L=>L??"",L=>L===""?void 0:L),label:t.coalesce(e?.nameLabel,v.$.nameLabel)})),u.Control(u.EmailInput,{controller:I,label:t.coalesce(e?.emailLabel,v.$.emailLabel)}),u.Control(u.PasswordInput,{controller:x,label:t.coalesce(e?.passwordLabel,v.$.passwordLabel)}),t.When(i??!1,()=>M({password:x.signal,rules:s,showLabel:!0})),t.When(r??!1,()=>u.Control(u.PasswordInput,{controller:z,label:t.coalesce(e?.confirmPasswordLabel,v.$.confirmPasswordLabel)})),t.When(a??!1,()=>t.html.div(t.attr.class("bc-auth-form__terms"),t.html.label(t.attr.class("bc-auth-form__checkbox-label"),u.CheckboxInput({value:k.signal.map(L=>L??!1),onChange:L=>k.change(L)}),t.html.span(n||t.coalesce(e?.acceptTermsLabel,v.$.acceptTermsLabel))),t.When(k.errorVisible,()=>t.html.div(t.attr.class("bc-auth-form__field-error"),k.error.map(L=>L||"")))))),y.Button({type:"submit",variant:"filled",color:"primary",loading:m,disabled:h.disabledOrHasErrors},t.attr.class("bc-auth-form__submit"),t.coalesce(e?.signUpButton,v.$.signUpButton))))}function G({onResetPassword:o,labels:e={}}){const i=F(),l=t.prop(!1),c=u.useForm({schema:W,onSubmit:A({task:o,message:"Reset password failed",onStart:()=>{l.set(!0),c.controller.disable()},onEnd:()=>{l.set(!1),c.controller.enable()}}),initialValue:{email:""}}),{controller:r,submit:a}=c;l.on(r.setDisabled);const n=r.field("email");return i.on(m=>{m!=null&&n.change(m)}),t.Use(S.AuthI18n,m=>t.html.form(t.OnDispose(r.dispose,i.dispose,l.dispose),t.attr.class("bc-auth-form__form"),t.Ensure(r.error,s=>u.Notice({variant:"danger",tone:"prominent",role:"alert"},t.html.div(s))),t.html.p(t.attr.class("bc-auth-form__description"),t.coalesce(e?.resetPasswordDescription,m.$.resetPasswordDescription)),t.on.submit(a),u.Stack(t.attr.class("bc-auth-form__fields"),u.Control(u.EmailInput,{controller:n,label:t.coalesce(e?.emailLabel,m.$.emailLabel)})),y.Button({loading:l,type:"submit",variant:"filled",color:"primary",disabled:r.disabledOrHasErrors},t.attr.class("bc-auth-form__submit"),t.coalesce(e?.resetPasswordButton,m.$.resetPasswordButton))))}function p({provider:o,onClick:e,size:i="md",name:l,icon:c,color:r,flow:a,labels:n}){const m=async()=>{if(e)try{a==="popup"?await e():await e()}catch(s){console.error(`Social login error for ${o} (${a||"redirect"} flow):`,s)}};return y.Button({type:"button",variant:"filled",size:i,color:r,onClick:m,roundedness:"full"},t.attr.class("bc-social-login-button"),t.attr.class(t.computedOf(o)(s=>`bc-social-login-button--${s}`)),t.html.span(t.attr.class("bc-social-login-button__inner"),t.html.span(t.attr.class("bc-social-login-button__icon"),y.Icon({icon:c,size:i},t.attr.class("bc-social-login-button__icon-inner"))),t.Use(S.AuthI18n,s=>t.html.span(t.attr.class("bc-social-login-button__label"),t.bind(t.coalesce(n?.continueWithProvider,s.$.continueWithProvider))(l)))))}function j({providers:o,onProviderClick:e,size:i="md",className:l}){return u.Stack(t.attr.class("bc-social-login-buttons"),t.attr.class(l),t.ForEach(o,c=>p({provider:c.$.provider,flow:c.$.flow,color:c.map(({provider:r})=>d[r].color),name:c.map(({provider:r})=>d[r].name),icon:c.map(({provider:r})=>d[r].icon),onClick:async()=>{e&&await e(c.$.provider.value)},size:i})))}const d={google:{name:"Google",icon:"logos:google-icon",color:"red"},github:{name:"GitHub",icon:"logos:github-icon",color:"black"},apple:{name:"Apple",icon:"logos:apple",color:"stone"},facebook:{name:"Facebook",icon:"logos:facebook",color:"blue"},twitter:{name:"Twitter",icon:"logos:twitter",color:"sky"},x:{name:"X",icon:"logos:x",color:"zinc"},microsoft:{name:"Microsoft",icon:"logos:microsoft-icon",color:"amber"},discord:{name:"Discord",icon:"logos:discord-icon",color:"indigo"},linkedin:{name:"LinkedIn",icon:"logos:linkedin-icon",color:"cyan"},instagram:{name:"Instagram",icon:"logos:instagram-icon",color:"fuchsia"},tiktok:{name:"TikTok",icon:"logos:tiktok-icon",color:"teal"},snapchat:{name:"Snapchat",icon:"streamline-logos:snapchat-logo-solid",color:"yellow"},reddit:{name:"Reddit",icon:"logos:reddit-icon",color:"orange"},pinterest:{name:"Pinterest",icon:"logos:pinterest",color:"rose"},twitch:{name:"Twitch",icon:"logos:twitch",color:"purple"},steam:{name:"Steam",icon:"logos:steam",color:"slate"},epic:{name:"Epic Games",icon:"streamline-logos:epic-games-logo-solid",color:"neutral"},playstation:{name:"PlayStation",icon:"streamline-logos:playstation-logo-solid",color:"violet"},xbox:{name:"Xbox",icon:"streamline-logos:xbox-live-logo-solid",color:"green"},whatsapp:{name:"WhatsApp",icon:"logos:whatsapp-icon",color:"emerald"},wechat:{name:"WeChat",icon:"streamline-logos:wechat-logo",color:"lime"},amazon:{name:"Amazon",icon:"streamline-logos:amazon-logo-solid",color:"red"},yahoo:{name:"Yahoo",icon:"logos:yahoo",color:"rose"},paypal:{name:"PayPal",icon:"logos:paypal",color:"blue"}},mt=o=>p({...o,...d.google,provider:"google"}),ut=o=>p({...o,...d.github,provider:"github"}),dt=o=>p({...o,...d.apple,provider:"apple"}),pt=o=>p({...o,...d.facebook,provider:"facebook"}),ht=o=>p({...o,...d.x,provider:"x"}),gt=o=>p({...o,...d.twitter,provider:"twitter"}),ft=o=>p({...o,...d.microsoft,provider:"microsoft"}),bt=o=>p({...o,...d.discord,provider:"discord"}),wt=o=>p({...o,...d.linkedin,provider:"linkedin"}),Lt=o=>p({...o,...d.instagram,provider:"instagram"}),_t=o=>p({...o,...d.tiktok,provider:"tiktok"}),kt=o=>p({...o,...d.snapchat,provider:"snapchat"}),vt=o=>p({...o,...d.reddit,provider:"reddit"}),St=o=>p({...o,...d.pinterest,provider:"pinterest"}),Pt=o=>p({...o,...d.twitch,provider:"twitch"}),yt=o=>p({...o,...d.steam,provider:"steam"}),Bt=o=>p({...o,...d.epic,provider:"epic"}),It=o=>p({...o,...d.playstation,provider:"playstation"}),xt=o=>p({...o,...d.xbox,provider:"xbox"}),qt=o=>p({...o,...d.whatsapp,provider:"whatsapp"}),At=o=>p({...o,...d.wechat,provider:"wechat"}),Ct=o=>p({...o,...d.amazon,provider:"amazon"}),Tt=o=>p({...o,...d.yahoo,provider:"yahoo"}),$t=o=>p({...o,...d.paypal,provider:"paypal"});function E({providers:o}){return u.Stack(j({providers:o}))}function H({mode:o,socialProviders:e,passwordRules:i,showRememberMe:l,showSocialDivider:c,showPasswordStrength:r,labels:a,onSignIn:n,onSignUp:m,onResetPassword:s,onModeChange:f,showContainer:b},...h){const g=o!=null?t.Value.deriveProp(o):t.prop("signin");return g.on(_=>f?.(_)),t.Use(S.AuthI18n,_=>{function I(){const k=t.coalesce(a?.hasAccountLink,_.$.hasAccountLink);return t.html.button(t.attr.type("button"),t.attr.class("bc-auth-form__link"),t.on.click(()=>g.set("signin")),k)}function x(){return t.html.button(t.attr.type("button"),t.attr.class("bc-auth-form__link"),t.on.click(()=>g.set("signup")),t.coalesce(a?.noAccountLink,_.$.noAccountLink))}function z(){return t.html.button(t.attr.type("button"),t.attr.class("bc-auth-form__link"),t.on.click(()=>g.set("reset-password")),t.coalesce(a?.forgotPasswordLink,_.$.forgotPasswordLink))}return t.html.div(X.classes({"bc-auth-container":!0,"bc-auth-container--styled":t.Value.map(b??!0,k=>k)}),t.attr.class(g.map(k=>`bc-auth-container--${k}`)),t.attr.class("bc-auth-form"),t.OnDispose(g.dispose),t.OneOfValue(g,{signin:()=>t.Fragment(t.html.h2(t.attr.class("bc-auth-form__title"),t.coalesce(a?.signInTitle,_.$.signInTitle)),e!=null?t.Fragment(E({providers:e}),t.When(c??!1,U)):null,R({onSignIn:n,showRememberMe:l,passwordRules:i,labels:{emailLabel:a?.emailLabel,passwordLabel:a?.passwordLabel,rememberMeLabel:a?.rememberMeLabel,signInButton:a?.signInButton,forgotPasswordLink:a?.forgotPasswordLink,noAccountLink:a?.noAccountLink}}),u.Stack(t.attr.class("bc-auth-form__footer"),x(),z())),signup:()=>t.Fragment(t.html.h2(t.attr.class("bc-auth-form__title"),t.coalesce(a?.signUpTitle,_.$.signUpTitle)),e!=null?t.Fragment(E({providers:e}),t.When(c??!1,U)):null,N({labels:{nameLabel:a?.nameLabel,emailLabel:a?.emailLabel,passwordLabel:a?.passwordLabel,confirmPasswordLabel:a?.confirmPasswordLabel,acceptTermsLabel:a?.acceptTermsLabel,signUpButton:a?.signUpButton,hasAccountLink:a?.hasAccountLink},onSignUp:m,passwordRules:i,showPasswordStrength:r}),u.Stack(t.attr.class("bc-auth-form__footer"),I())),"reset-password":()=>t.Fragment(t.html.h2(t.attr.class("bc-auth-form__title"),t.coalesce(a?.resetPasswordTitle,_.$.resetPasswordTitle)),G({labels:{backToSignInLink:a?.backToSignInLink,emailLabel:a?.emailLabel,resetPasswordButton:a?.resetPasswordButton,resetPasswordDescription:a?.resetPasswordDescription},onResetPassword:s}),u.Stack(t.attr.class("bc-auth-form__footer"),I()))}),...h)})}function Ot(o){return w.Modal({size:"sm",dismissable:!0,showCloseButton:!0},(e,i)=>o(l=>e({body:H({showContainer:!1,...l}),header:t.Use(S.AuthI18n,c=>t.coalesce(l.modalTitle,c.$.authenticationTitle))})))}function U({labels:o,className:e}={}){return t.html.div(t.attr.class("bc-auth-divider"),t.attr.class(e),t.html.div(t.attr.class("bc-auth-divider__line")),t.Use(S.AuthI18n,i=>t.html.span(t.attr.class("bc-auth-divider__text"),t.coalesce(o?.text,i.$.orDivider))),t.html.div(t.attr.class("bc-auth-divider__line")))}exports.AmazonLoginButton=Ct;exports.AppleLoginButton=dt;exports.AuthContainer=H;exports.AuthDivider=U;exports.AuthModal=Ot;exports.DiscordLoginButton=bt;exports.EpicLoginButton=Bt;exports.FacebookLoginButton=pt;exports.GitHubLoginButton=ut;exports.GoogleLoginButton=mt;exports.InstagramLoginButton=Lt;exports.LinkedInLoginButton=wt;exports.MicrosoftLoginButton=ft;exports.PasswordStrengthBar=ct;exports.PasswordStrengthIndicator=M;exports.PasswordStrengthText=lt;exports.PayPalLoginButton=$t;exports.PinterestLoginButton=St;exports.PlayStationLoginButton=It;exports.RedditLoginButton=vt;exports.ResetPasswordForm=G;exports.SignInForm=R;exports.SignUpForm=N;exports.SnapchatLoginButton=kt;exports.SocialLoginButton=p;exports.SocialLoginButtons=j;exports.SocialProviders=E;exports.SteamLoginButton=yt;exports.TiktokLoginButton=_t;exports.TwitchLoginButton=Pt;exports.TwitterLoginButton=gt;exports.WeChatLoginButton=At;exports.WhatsAppLoginButton=qt;exports.XLoginButtin=ht;exports.XboxLoginButton=xt;exports.YahooLoginButton=Tt;exports.authSchemas=rt;exports.calculatePasswordStrength=O;exports.createPasswordSchema=C;exports.createSignInSchema=T;exports.createSignUpSchema=$;exports.createSocialLoginUrl=Q;exports.defaultPasswordRules=P;exports.defaultSignInSchema=at;exports.defaultSignUpSchema=nt;exports.emailSchema=B;exports.formatAuthError=ot;exports.formatProviderName=D;exports.formatSocialLoginText=J;exports.generateRandomString=V;exports.getProviderColor=Z;exports.getProviderIcon=Y;exports.isBrowser=et;exports.isValidEmail=K;exports.openSocialLoginPopup=tt;exports.providerInfo=q;exports.requestToControllerValidation=A;exports.resetPasswordSchema=W;exports.socialProviderInfo=d;exports.useAuthEmailProp=F;exports.validateEmail=st;exports.validatePassword=it;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@tempots/dom"),u=require("../notice-CNrZMX-r.cjs"),g=require("../modal-CwLXTMFb.cjs"),y=require("../translations-Cd5YXXFP.cjs"),I=require("../translations-0qZADR5l.cjs"),Z=require("@tempots/ui"),C={google:{name:"Google",icon:"logos:google-icon",color:"#4285f4"},github:{name:"GitHub",icon:"logos:github-icon",color:"#333"},apple:{name:"Apple",icon:"logos:apple",color:"#000"},facebook:{name:"Facebook",icon:"logos:facebook",color:"#1877f2"},twitter:{name:"Twitter",icon:"logos:twitter",color:"#1da1f2"},microsoft:{name:"Microsoft",icon:"logos:microsoft-icon",color:"#00a4ef"},discord:{name:"Discord",icon:"logos:discord-icon",color:"#5865f2"},linkedin:{name:"LinkedIn",icon:"logos:linkedin-icon",color:"#0077b5"},instagram:{name:"Instagram",icon:"logos:instagram-icon",color:"#e4405f"},tiktok:{name:"TikTok",icon:"logos:tiktok-icon",color:"#000"},snapchat:{name:"Snapchat",icon:"logos:snapchat-icon",color:"#fffc00"},reddit:{name:"Reddit",icon:"logos:reddit-icon",color:"#ff4500"},pinterest:{name:"Pinterest",icon:"logos:pinterest-icon",color:"#bd081c"},twitch:{name:"Twitch",icon:"logos:twitch",color:"#9146ff"},steam:{name:"Steam",icon:"logos:steam-icon",color:"#000"},epic:{name:"Epic Games",icon:"simple-icons:epicgames",color:"#313131"},playstation:{name:"PlayStation",icon:"logos:playstation-icon",color:"#003791"},xbox:{name:"Xbox",icon:"logos:xbox-icon",color:"#107c10"},whatsapp:{name:"WhatsApp",icon:"logos:whatsapp-icon",color:"#25d366"},wechat:{name:"WeChat",icon:"logos:wechat-icon",color:"#1aad19"},amazon:{name:"Amazon",icon:"logos:amazon-icon",color:"#ff9900"},yahoo:{name:"Yahoo",icon:"logos:yahoo-icon",color:"#720e9e"},paypal:{name:"PayPal",icon:"logos:paypal",color:"#0070ba"},x:{name:"X",icon:"simple-icons:x",color:"#000"}};function R(o){return C[o]?.name||o}function J(o){return C[o]?.icon||"mdi:account"}function K(o){return C[o]?.color||"#666"}function Q(o,e="Continue with {provider}"){return e.replace("{provider}",R(o))}const B={minLength:8,requireUppercase:!0,requireLowercase:!0,requireNumbers:!0,requireSymbols:!1};function tt(o){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o)}function M(o=32){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let i="";for(let l=0;l<o;l++)i+=e.charAt(Math.floor(Math.random()*e.length));return i}function ot(o,e,i,l=[],c={}){const n={google:"https://accounts.google.com/oauth/authorize",github:"https://github.com/login/oauth/authorize",apple:"https://appleid.apple.com/auth/authorize",facebook:"https://www.facebook.com/v18.0/dialog/oauth",twitter:"https://twitter.com/i/oauth2/authorize",microsoft:"https://login.microsoftonline.com/common/oauth2/v2.0/authorize",discord:"https://discord.com/api/oauth2/authorize",linkedin:"https://www.linkedin.com/oauth/v2/authorization",instagram:"https://api.instagram.com/oauth/authorize",tiktok:"https://www.tiktok.com/v2/auth/authorize",snapchat:"https://accounts.snapchat.com/accounts/oauth2/authorize",reddit:"https://www.reddit.com/api/v1/authorize",pinterest:"https://api.pinterest.com/oauth/",twitch:"https://id.twitch.tv/oauth2/authorize",steam:"https://steamcommunity.com/oauth/authorize",epic:"https://auth.epicgames.com/authorize",playstation:"https://auth.api.sonyentertainmentnetwork.com/oauth/authorize",xbox:"https://login.live.com/oauth20_authorize.srf",whatsapp:"https://web.whatsapp.com/oauth/authorize",wechat:"https://open.weixin.qq.com/connect/qrconnect",amazon:"https://www.amazon.com/ap/oa",yahoo:"https://api.login.yahoo.com/oauth2/request_auth",paypal:"https://www.paypal.com/signin/authorize",x:"https://api.twitter.com/oauth2/authorize"},m={google:["openid","email","profile"],github:["user:email"],apple:["email","name"],facebook:["email"],twitter:["users.read"],microsoft:["openid","email","profile"],discord:["identify","email"],linkedin:["r_liteprofile","r_emailaddress"],instagram:["user_profile","user_media"],tiktok:["user.info.basic","user.external.id"],snapchat:["user.info.basic","user.external.id"],reddit:["identity","email"],pinterest:["read_public","read_relationships"],twitch:["openid","email","profile"],steam:["openid","email","profile"],epic:["openid","email","profile"],playstation:["openid","email","profile"],xbox:["openid","email","profile"],whatsapp:["openid","email","profile"],wechat:["openid","email","profile"],amazon:["openid","email","profile"],yahoo:["openid","email","profile"],paypal:["openid","email","profile"],x:["openid","email","profile"]},a=n[o];if(!a)throw new Error(`Unsupported provider: ${o}`);const r=l.length>0?l:m[o],s=M(),h=new URLSearchParams({client_id:e,redirect_uri:i,scope:r.join(" "),state:s,response_type:"code",...c});return`${a}?${h.toString()}`}function et(o,e,i,l){const c=window.open(o,`${e}_login`,"width=500,height=600,scrollbars=yes,resizable=yes");if(!c){l?.(new Error("Failed to open popup window"));return}const n=setInterval(()=>{c.closed&&(clearInterval(n),l?.(new Error("Login cancelled")))},1e3),m=a=>{a.origin===window.location.origin&&(a.data.type==="SOCIAL_LOGIN_SUCCESS"?(clearInterval(n),c.close(),window.removeEventListener("message",m),i?.(a.data.result)):a.data.type==="SOCIAL_LOGIN_ERROR"&&(clearInterval(n),c.close(),window.removeEventListener("message",m),l?.(new Error(a.data.error))))};window.addEventListener("message",m)}function at(o){return o instanceof Error?o.message:typeof o=="string"?o:o&&typeof o=="object"&&"message"in o?String(o.message):"An unexpected error occurred"}function nt(){return typeof window<"u"&&typeof document<"u"}function T({task:o,message:e,onStart:i,onEnd:l}){return async c=>{i?.();const n=await u.taskToValidation({task:o!=null?()=>o(c):async()=>null,errorMessage:e,errorPath:["root"],validation:m=>m!=null?u.a.invalid({message:m}):u.a.valid});return l?.(),n}}function $(o=B){let e=g.string();return o.minLength&&(e=e.min(o.minLength,`Password must be at least ${o.minLength} characters`)),o.requireUppercase&&(e=e.regex(/[A-Z]/,"Password must contain at least one uppercase letter")),o.requireLowercase&&(e=e.regex(/[a-z]/,"Password must contain at least one lowercase letter")),o.requireNumbers&&(e=e.regex(/[0-9]/,"Password must contain at least one number")),o.requireSymbols&&(e=e.regex(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/,"Password must contain at least one special character")),o.customValidation&&(e=e.refine(i=>o.customValidation(i))),e}const x=g.string().min(1,"Email is required").email("Please enter a valid email address");function O(o){const e=o?$(o):g.string().refine(i=>i.length>0?null:"Password is required");return g.object({email:x,password:e,rememberMe:g.boolean().default(!1)}).schema()}function z(o=B,e){const i=$(o),l=e?.showNameField!==!1,c=e?.showConfirmPassword!==!1,n=e?.showAcceptTermsAndConditions!==!1,m={name:l?g.string().min(1,"Name is required").optional():g.string().optional(),email:x,password:i,confirmPassword:c?g.string().min(1,"Please confirm your password"):g.string(),acceptTerms:n?g.boolean().refine(r=>r===!0,"You must accept the terms and conditions"):g.boolean().default(!0)},a=g.object(m);return c?a.refine(r=>r.password===r.confirmPassword?null:"Passwords don't match",{path:["confirmPassword"]}).schema():a.schema()}const D=g.object({email:x}).schema(),rt=O(),st=z(),it={signIn:O,signUp:z,resetPassword:()=>D};function ct(o){const e=x.validate(o);return e.success?null:e.errors[0]?.message||"Invalid email"}function lt(o,e=B){const l=$(e).validate(o);return l.success?null:l.errors[0]?.message||"Invalid password"}function E(o,e=B){const i={length:o.length>=(e.minLength||8),uppercase:/[A-Z]/.test(o),lowercase:/[a-z]/.test(o),numbers:/[0-9]/.test(o),symbols:/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(o),custom:e.customValidation?e.customValidation(o)===null:o.length>0},l=[!0,e.requireUppercase,e.requireLowercase,e.requireNumbers,e.requireSymbols,!!e.customValidation].filter(Boolean).length,c=[i.length,e.requireUppercase?i.uppercase:null,e.requireLowercase?i.lowercase:null,e.requireNumbers?i.numbers:null,e.requireSymbols?i.symbols:null,e.customValidation?i.custom:null].filter(a=>a===!0).length,n=l>0?Math.round(c/l*100):0;let m;return n<40?m="weak":n<60?m="fair":n<80?m="good":m="strong",{strength:m,score:n,checks:i}}const V=()=>t.localStorageProp({key:"bui_auth_email",defaultValue:null});function N({onSignIn:o,passwordRules:e,labels:i,showRememberMe:l}){const c=t.prop(!1),n=V(),m=O(e),a=u.useForm({schema:m,onSubmit:T({task:o,message:"Reset password failed",onStart:()=>{c.set(!0),a.controller.disable()},onEnd:()=>{c.set(!1),a.controller.enable()}}),initialValue:{email:"",password:""}}),{controller:r,submit:s}=a;c.on(r.setDisabled);const h=r.field("email"),f=r.field("password");return n.on(b=>{b!=null&&h.change(b)}),h.signal.on(b=>{n.value!=null&&(n.value=b)}),t.Use(y.AuthI18n,b=>t.html.form(t.OnDispose(r.dispose,n.dispose,c.dispose),t.attr.class("bc-auth-form__form"),t.on.submit(s),u.Stack(t.attr.class("bc-auth-form__fields"),t.Ensure(r.error,L=>u.Notice({variant:"danger",tone:"prominent",role:"alert"},t.html.div(L))),u.Control(u.EmailInput,{controller:h,label:t.coalesce(i?.emailLabel,b.$.emailLabel)}),u.Control(u.PasswordInput,{controller:f,label:t.coalesce(i?.passwordLabel,b.$.passwordLabel)}),t.When(l??!0,()=>t.html.div(t.attr.class("bc-auth-form__remember-me"),t.html.label(t.attr.class("bc-auth-form__checkbox-label"),u.CheckboxInput({value:n.map(L=>L!=null),after:t.html.span(t.coalesce(i?.rememberMeLabel,b.$.rememberMeLabel)),onChange:L=>{L?n.value=h.signal.value??"":n.value=null}}))))),I.Button({type:"submit",variant:"filled",color:"primary",loading:c,disabled:r.disabledOrHasErrors},t.attr.class("bc-auth-form__submit"),t.coalesce(i?.signInButton,b.$.signInButton))))}function G({password:o,rules:e=B,showLabel:i=!0,className:l}){const c=t.computedOf(o)(s=>!s||s.length===0?{strength:"weak",score:0,checks:{length:!1,uppercase:!1,lowercase:!1,numbers:!1,symbols:!1,custom:!1}}:E(s,e)),n=c.map(s=>s.strength),m=c.map(s=>s.score),a=c.map(s=>s.checks),r=t.computedOf(n,l)((s,h)=>["bc-password-strength",`bc-password-strength--${s}`,h].filter(Boolean).join(" "));return t.html.div(t.OnDispose(c,r),t.attr.class(r),t.html.div(t.attr.class("bc-password-strength__bar"),t.html.div(t.attr.class("bc-password-strength__fill"),t.attr.style(m.map(s=>`width: ${s}%`)))),t.When(i,()=>t.Use(y.AuthI18n,s=>t.html.div(t.attr.class("bc-password-strength__label"),t.computedOf(n,s)((h,f)=>{switch(h){case"weak":return f.passwordStrengthWeak;case"fair":return f.passwordStrengthFair;case"good":return f.passwordStrengthGood;case"strong":return f.passwordStrengthStrong;default:return f.passwordStrengthWeak}})))),t.html.div(t.attr.class("bc-password-strength__requirements"),t.When(e.minLength!==void 0,()=>t.html.div(t.attr.class("bc-password-strength__requirement"),t.attr.class(t.computedOf(a)(s=>s.length?"bc-password-strength__requirement--met":"")),t.html.span(t.attr.class("bc-password-strength__requirement-icon"),t.computedOf(a)(s=>s.length?"✓":"○")),t.html.span(t.attr.class("bc-password-strength__requirement-text"),`At least ${e.minLength} characters`))),t.When(e.requireUppercase===!0,()=>t.html.div(t.attr.class("bc-password-strength__requirement"),t.attr.class(t.computedOf(a)(s=>s.uppercase?"bc-password-strength__requirement--met":"")),t.html.span(t.attr.class("bc-password-strength__requirement-icon"),t.computedOf(a)(s=>s.uppercase?"✓":"○")),t.html.span(t.attr.class("bc-password-strength__requirement-text"),"One uppercase letter"))),t.When(e.requireLowercase===!0,()=>t.html.div(t.attr.class("bc-password-strength__requirement"),t.attr.class(t.computedOf(a)(s=>s.lowercase?"bc-password-strength__requirement--met":"")),t.html.span(t.attr.class("bc-password-strength__requirement-icon"),t.computedOf(a)(s=>s.lowercase?"✓":"○")),t.html.span(t.attr.class("bc-password-strength__requirement-text"),"One lowercase letter"))),t.When(e.requireNumbers===!0,()=>t.html.div(t.attr.class("bc-password-strength__requirement"),t.attr.class(t.computedOf(a)(s=>s.numbers?"bc-password-strength__requirement--met":"")),t.html.span(t.attr.class("bc-password-strength__requirement-icon"),t.computedOf(a)(s=>s.numbers?"✓":"○")),t.html.span(t.attr.class("bc-password-strength__requirement-text"),"One number"))),t.When(e.requireSymbols===!0,()=>t.html.div(t.attr.class("bc-password-strength__requirement"),t.attr.class(t.computedOf(a)(s=>s.symbols?"bc-password-strength__requirement--met":"")),t.html.span(t.attr.class("bc-password-strength__requirement-icon"),t.computedOf(a)(s=>s.symbols?"✓":"○")),t.html.span(t.attr.class("bc-password-strength__requirement-text"),"One special character")))))}function mt({password:o,rules:e=B,className:i}){const l=t.computedOf(o)(a=>!a||a.length===0?{strength:"weak",score:0}:E(a,e)),c=l.map(a=>a.strength),n=l.map(a=>a.score),m=t.computedOf(c,i)((a,r)=>["bc-password-strength-bar",`bc-password-strength-bar--${a}`,r].filter(Boolean).join(" "));return t.html.div(t.OnDispose(l,m),t.attr.class(m),t.html.div(t.attr.class("bc-password-strength-bar__fill"),t.attr.style(n.map(a=>`width: ${a}%`))))}function ut({password:o,rules:e=B,className:i}){const l=t.computedOf(o)(n=>!n||n.length===0?"weak":E(n,e).strength),c=t.computedOf(l,i)((n,m)=>["bc-password-strength-text",`bc-password-strength-text--${n}`,m].filter(Boolean).join(" "));return t.Fragment(t.OnDispose(l,c),t.Use(y.AuthI18n,n=>t.html.span(t.attr.class(c),t.computedOf(l,n)((m,a)=>{switch(m){case"weak":return a.passwordStrengthWeak;case"fair":return a.passwordStrengthFair;case"good":return a.passwordStrengthGood;case"strong":return a.passwordStrengthStrong;default:return a.passwordStrengthWeak}}))))}function j({passwordRules:o,labels:e,initialEmail:i,initialName:l,showPasswordStrength:c,onSignUp:n,showNameField:m,showConfirmPassword:a,showAcceptTermsAndConditions:r,termsAndConditions:s}){const h=t.prop(!1),f=o||B,b=z(f,{showNameField:m!==!1,showConfirmPassword:a!==!1,showAcceptTermsAndConditions:r!==!1}),L=u.useForm({schema:b,onSubmit:T({task:n!=null?S=>n({email:S.email,password:S.password,name:S.name}):void 0,message:"Reset password failed",onStart:()=>{h.set(!0),L.controller.disable()},onEnd:()=>{h.set(!1),L.controller.enable()}}),initialValue:{name:l??"",email:i??"",password:"",confirmPassword:"",acceptTerms:!1}}),{controller:_,submit:P}=L;h.on(_.setDisabled);const k=_.field("name"),q=_.field("email"),A=_.field("password"),U=_.field("confirmPassword"),v=_.field("acceptTerms");return t.Use(y.AuthI18n,S=>t.html.form(t.OnDispose(_.dispose,h.dispose),t.attr.class("bc-auth-form__form"),t.on.submit(P),u.Stack(t.attr.class("bc-auth-form__fields"),t.Ensure(_.error,w=>u.Notice({variant:"danger",tone:"prominent",role:"alert"},t.html.div(w))),t.When(m!==!1,()=>u.Control(I.TextInput,{controller:k.transform(w=>w??"",w=>w===""?void 0:w),label:t.coalesce(e?.nameLabel,S.$.nameLabel)})),u.Control(u.EmailInput,{controller:q,label:t.coalesce(e?.emailLabel,S.$.emailLabel)}),u.Control(u.PasswordInput,{controller:A,label:t.coalesce(e?.passwordLabel,S.$.passwordLabel)}),t.When(c??!1,()=>G({password:A.signal,rules:f,showLabel:!0})),t.When(a??!1,()=>u.Control(u.PasswordInput,{controller:U,label:t.coalesce(e?.confirmPasswordLabel,S.$.confirmPasswordLabel)})),t.When(r??!1,()=>t.html.div(t.attr.class("bc-auth-form__terms"),t.html.label(t.attr.class("bc-auth-form__checkbox-label"),u.CheckboxInput({value:v.signal.map(w=>w??!1),onChange:w=>v.change(w)}),t.html.span(s||t.coalesce(e?.acceptTermsLabel,S.$.acceptTermsLabel))),t.When(v.errorVisible,()=>t.html.div(t.attr.class("bc-auth-form__field-error"),v.error.map(w=>w||"")))))),I.Button({type:"submit",variant:"filled",color:"primary",loading:h,disabled:_.disabledOrHasErrors},t.attr.class("bc-auth-form__submit"),t.coalesce(e?.signUpButton,S.$.signUpButton))))}function H({onResetPassword:o,labels:e={}}){const i=V(),l=t.prop(!1),c=u.useForm({schema:D,onSubmit:T({task:o,message:"Reset password failed",onStart:()=>{l.set(!0),c.controller.disable()},onEnd:()=>{l.set(!1),c.controller.enable()}}),initialValue:{email:""}}),{controller:n,submit:m}=c;l.on(n.setDisabled);const a=n.field("email");return i.on(r=>{r!=null&&a.change(r)}),t.Use(y.AuthI18n,r=>t.html.form(t.OnDispose(n.dispose,i.dispose,l.dispose),t.attr.class("bc-auth-form__form"),t.Ensure(n.error,s=>u.Notice({variant:"danger",tone:"prominent",role:"alert"},t.html.div(s))),t.html.p(t.attr.class("bc-auth-form__description"),t.coalesce(e?.resetPasswordDescription,r.$.resetPasswordDescription)),t.on.submit(m),u.Stack(t.attr.class("bc-auth-form__fields"),u.Control(u.EmailInput,{controller:a,label:t.coalesce(e?.emailLabel,r.$.emailLabel)})),I.Button({loading:l,type:"submit",variant:"filled",color:"primary",disabled:n.disabledOrHasErrors},t.attr.class("bc-auth-form__submit"),t.coalesce(e?.resetPasswordButton,r.$.resetPasswordButton))))}function p({provider:o,onClick:e,size:i="md",name:l,icon:c,color:n,flow:m,labels:a}){const r=async()=>{if(e)try{m==="popup"?await e():await e()}catch(s){console.error(`Social login error for ${o} (${m||"redirect"} flow):`,s)}};return I.Button({type:"button",variant:"filled",size:i,color:n,onClick:r,roundedness:"full"},t.attr.class("bc-social-login-button"),t.attr.class(t.computedOf(o)(s=>`bc-social-login-button--${s}`)),t.html.span(t.attr.class("bc-social-login-button__inner"),t.html.span(t.attr.class("bc-social-login-button__icon"),I.Icon({icon:c,size:i},t.attr.class("bc-social-login-button__icon-inner"))),t.Use(y.AuthI18n,s=>t.html.span(t.attr.class("bc-social-login-button__label"),t.bind(t.coalesce(a?.continueWithProvider,s.$.continueWithProvider))(l)))))}function X({providers:o,onProviderClick:e,size:i="md",className:l}){return u.Stack(t.attr.class("bc-social-login-buttons"),t.attr.class(l),t.ForEach(o,c=>p({provider:c.$.provider,flow:c.$.flow,color:c.map(({provider:n})=>d[n].color),name:c.map(({provider:n})=>d[n].name),icon:c.map(({provider:n})=>d[n].icon),onClick:async()=>{e&&await e(c.$.provider.value)},size:i})))}const d={google:{name:"Google",icon:"logos:google-icon",color:"red"},github:{name:"GitHub",icon:"logos:github-icon",color:"black"},apple:{name:"Apple",icon:"logos:apple",color:"stone"},facebook:{name:"Facebook",icon:"logos:facebook",color:"blue"},twitter:{name:"Twitter",icon:"logos:twitter",color:"sky"},x:{name:"X",icon:"logos:x",color:"zinc"},microsoft:{name:"Microsoft",icon:"logos:microsoft-icon",color:"amber"},discord:{name:"Discord",icon:"logos:discord-icon",color:"indigo"},linkedin:{name:"LinkedIn",icon:"logos:linkedin-icon",color:"cyan"},instagram:{name:"Instagram",icon:"logos:instagram-icon",color:"fuchsia"},tiktok:{name:"TikTok",icon:"logos:tiktok-icon",color:"teal"},snapchat:{name:"Snapchat",icon:"streamline-logos:snapchat-logo-solid",color:"yellow"},reddit:{name:"Reddit",icon:"logos:reddit-icon",color:"orange"},pinterest:{name:"Pinterest",icon:"logos:pinterest",color:"rose"},twitch:{name:"Twitch",icon:"logos:twitch",color:"purple"},steam:{name:"Steam",icon:"logos:steam",color:"slate"},epic:{name:"Epic Games",icon:"streamline-logos:epic-games-logo-solid",color:"neutral"},playstation:{name:"PlayStation",icon:"streamline-logos:playstation-logo-solid",color:"violet"},xbox:{name:"Xbox",icon:"streamline-logos:xbox-live-logo-solid",color:"green"},whatsapp:{name:"WhatsApp",icon:"logos:whatsapp-icon",color:"emerald"},wechat:{name:"WeChat",icon:"streamline-logos:wechat-logo",color:"lime"},amazon:{name:"Amazon",icon:"streamline-logos:amazon-logo-solid",color:"red"},yahoo:{name:"Yahoo",icon:"logos:yahoo",color:"rose"},paypal:{name:"PayPal",icon:"logos:paypal",color:"blue"}},dt=o=>p({...o,...d.google,provider:"google"}),pt=o=>p({...o,...d.github,provider:"github"}),ht=o=>p({...o,...d.apple,provider:"apple"}),gt=o=>p({...o,...d.facebook,provider:"facebook"}),ft=o=>p({...o,...d.x,provider:"x"}),bt=o=>p({...o,...d.twitter,provider:"twitter"}),wt=o=>p({...o,...d.microsoft,provider:"microsoft"}),Lt=o=>p({...o,...d.discord,provider:"discord"}),_t=o=>p({...o,...d.linkedin,provider:"linkedin"}),kt=o=>p({...o,...d.instagram,provider:"instagram"}),vt=o=>p({...o,...d.tiktok,provider:"tiktok"}),St=o=>p({...o,...d.snapchat,provider:"snapchat"}),Pt=o=>p({...o,...d.reddit,provider:"reddit"}),yt=o=>p({...o,...d.pinterest,provider:"pinterest"}),Bt=o=>p({...o,...d.twitch,provider:"twitch"}),It=o=>p({...o,...d.steam,provider:"steam"}),xt=o=>p({...o,...d.epic,provider:"epic"}),qt=o=>p({...o,...d.playstation,provider:"playstation"}),At=o=>p({...o,...d.xbox,provider:"xbox"}),Ct=o=>p({...o,...d.whatsapp,provider:"whatsapp"}),Tt=o=>p({...o,...d.wechat,provider:"wechat"}),$t=o=>p({...o,...d.amazon,provider:"amazon"}),Ot=o=>p({...o,...d.yahoo,provider:"yahoo"}),zt=o=>p({...o,...d.paypal,provider:"paypal"});function W({providers:o}){return u.Stack(X({providers:o}))}function Y({mode:o,socialProviders:e,initialName:i,initialEmail:l,passwordRules:c,showRememberMe:n,showSocialDivider:m,showPasswordStrength:a,labels:r,onSignIn:s,onSignUp:h,onResetPassword:f,onModeChange:b,showContainer:L},..._){const P=o!=null?t.Value.deriveProp(o):t.prop("signin");return P.on(k=>b?.(k)),t.Use(y.AuthI18n,k=>{function q(){const v=t.coalesce(r?.hasAccountLink,k.$.hasAccountLink);return t.html.button(t.attr.type("button"),t.attr.class("bc-auth-form__link"),t.on.click(()=>P.set("signin")),v)}function A(){return t.html.button(t.attr.type("button"),t.attr.class("bc-auth-form__link"),t.on.click(()=>P.set("signup")),t.coalesce(r?.noAccountLink,k.$.noAccountLink))}function U(){return t.html.button(t.attr.type("button"),t.attr.class("bc-auth-form__link"),t.on.click(()=>P.set("reset-password")),t.coalesce(r?.forgotPasswordLink,k.$.forgotPasswordLink))}return t.html.div(Z.classes({"bc-auth-container":!0,"bc-auth-container--styled":t.Value.map(L??!0,v=>v)}),t.attr.class(P.map(v=>`bc-auth-container--${v}`)),t.attr.class("bc-auth-form"),t.OnDispose(P.dispose),t.OneOfValue(P,{signin:()=>t.Fragment(t.html.h2(t.attr.class("bc-auth-form__title"),t.coalesce(r?.signInTitle,k.$.signInTitle)),e!=null?t.Fragment(W({providers:e}),t.When(m??!1,F)):null,N({onSignIn:s,showRememberMe:n,passwordRules:c,labels:{emailLabel:r?.emailLabel,passwordLabel:r?.passwordLabel,rememberMeLabel:r?.rememberMeLabel,signInButton:r?.signInButton,forgotPasswordLink:r?.forgotPasswordLink,noAccountLink:r?.noAccountLink}}),u.Stack(t.attr.class("bc-auth-form__footer"),A(),U())),signup:()=>t.Fragment(t.html.h2(t.attr.class("bc-auth-form__title"),t.coalesce(r?.signUpTitle,k.$.signUpTitle)),e!=null?t.Fragment(W({providers:e}),t.When(m??!1,F)):null,j({labels:{nameLabel:r?.nameLabel,emailLabel:r?.emailLabel,passwordLabel:r?.passwordLabel,confirmPasswordLabel:r?.confirmPasswordLabel,acceptTermsLabel:r?.acceptTermsLabel,signUpButton:r?.signUpButton,hasAccountLink:r?.hasAccountLink},initialEmail:l,initialName:i,onSignUp:h,passwordRules:c,showPasswordStrength:a}),u.Stack(t.attr.class("bc-auth-form__footer"),q())),"reset-password":()=>t.Fragment(t.html.h2(t.attr.class("bc-auth-form__title"),t.coalesce(r?.resetPasswordTitle,k.$.resetPasswordTitle)),H({labels:{backToSignInLink:r?.backToSignInLink,emailLabel:r?.emailLabel,resetPasswordButton:r?.resetPasswordButton,resetPasswordDescription:r?.resetPasswordDescription},onResetPassword:f}),u.Stack(t.attr.class("bc-auth-form__footer"),q()))}),..._)})}function Et(o){return g.Modal({size:"sm",dismissable:!0,showCloseButton:!0},(e,i)=>o(l=>e({body:Y({showContainer:!1,...l}),header:t.Use(y.AuthI18n,c=>t.coalesce(l.modalTitle,c.$.authenticationTitle))})))}function F({labels:o,className:e}={}){return t.html.div(t.attr.class("bc-auth-divider"),t.attr.class(e),t.html.div(t.attr.class("bc-auth-divider__line")),t.Use(y.AuthI18n,i=>t.html.span(t.attr.class("bc-auth-divider__text"),t.coalesce(o?.text,i.$.orDivider))),t.html.div(t.attr.class("bc-auth-divider__line")))}exports.AmazonLoginButton=$t;exports.AppleLoginButton=ht;exports.AuthContainer=Y;exports.AuthDivider=F;exports.AuthModal=Et;exports.DiscordLoginButton=Lt;exports.EpicLoginButton=xt;exports.FacebookLoginButton=gt;exports.GitHubLoginButton=pt;exports.GoogleLoginButton=dt;exports.InstagramLoginButton=kt;exports.LinkedInLoginButton=_t;exports.MicrosoftLoginButton=wt;exports.PasswordStrengthBar=mt;exports.PasswordStrengthIndicator=G;exports.PasswordStrengthText=ut;exports.PayPalLoginButton=zt;exports.PinterestLoginButton=yt;exports.PlayStationLoginButton=qt;exports.RedditLoginButton=Pt;exports.ResetPasswordForm=H;exports.SignInForm=N;exports.SignUpForm=j;exports.SnapchatLoginButton=St;exports.SocialLoginButton=p;exports.SocialLoginButtons=X;exports.SocialProviders=W;exports.SteamLoginButton=It;exports.TiktokLoginButton=vt;exports.TwitchLoginButton=Bt;exports.TwitterLoginButton=bt;exports.WeChatLoginButton=Tt;exports.WhatsAppLoginButton=Ct;exports.XLoginButtin=ft;exports.XboxLoginButton=At;exports.YahooLoginButton=Ot;exports.authSchemas=it;exports.calculatePasswordStrength=E;exports.createPasswordSchema=$;exports.createSignInSchema=O;exports.createSignUpSchema=z;exports.createSocialLoginUrl=ot;exports.defaultPasswordRules=B;exports.defaultSignInSchema=rt;exports.defaultSignUpSchema=st;exports.emailSchema=x;exports.formatAuthError=at;exports.formatProviderName=R;exports.formatSocialLoginText=Q;exports.generateRandomString=M;exports.getProviderColor=K;exports.getProviderIcon=J;exports.isBrowser=nt;exports.isValidEmail=tt;exports.openSocialLoginPopup=et;exports.providerInfo=C;exports.requestToControllerValidation=T;exports.resetPasswordSchema=D;exports.socialProviderInfo=d;exports.useAuthEmailProp=V;exports.validateEmail=ct;exports.validatePassword=lt;
|