/*! For license information please see main.1007134f.js.LICENSE.txt */ (()=>{var e={1832(e,t,n){"use strict";n.d(t,{A:()=>o});const r={backendProxy:"https://proxy-service-gateway-au4uagnd.uc.gateway.dev",webhookService:{NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_AUTHOR_ONBOARDING_VAPI_ASSISTANT_ID:"89d317fb-f742-48e3-bcdb-2a0ffa4d4c9a",REACT_APP_BACKEND_URL:"https://proxy-service-gateway-au4uagnd.uc.gateway.dev",REACT_APP_DEEPER_ONBOARDING_VAPI_ASSISTANT_ID:"4e5b0f3e-3322-468c-b185-4ef8ee8e1866",REACT_APP_STRIPE_PUBLISHABLE_KEY:"pk_live_51RsqLlQlQWc4RelR90DIbICaVuL54pY1MINimpUB6cNk5ic8OzUMq0nYQDQkYtrwvYO9JwrRuX45vjB7DmVzCcrU00tDVCiytg",REACT_APP_SUPABASE_ANON_KEY:"sb_publishable_bsBi_9kdOMYnN374Wg8TWQ_-Pltqp4G",REACT_APP_SUPABASE_URL:"https://jzohkzrrroxrjjomkjbg.supabase.co",REACT_APP_VAPI_PUBLIC_KEY:"0cc61bed-52da-4674-b316-6ada9ecd7157"}.REACT_APP_WEBHOOK_SERVICE_URL,expertService:{NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_AUTHOR_ONBOARDING_VAPI_ASSISTANT_ID:"89d317fb-f742-48e3-bcdb-2a0ffa4d4c9a",REACT_APP_BACKEND_URL:"https://proxy-service-gateway-au4uagnd.uc.gateway.dev",REACT_APP_DEEPER_ONBOARDING_VAPI_ASSISTANT_ID:"4e5b0f3e-3322-468c-b185-4ef8ee8e1866",REACT_APP_STRIPE_PUBLISHABLE_KEY:"pk_live_51RsqLlQlQWc4RelR90DIbICaVuL54pY1MINimpUB6cNk5ic8OzUMq0nYQDQkYtrwvYO9JwrRuX45vjB7DmVzCcrU00tDVCiytg",REACT_APP_SUPABASE_ANON_KEY:"sb_publishable_bsBi_9kdOMYnN374Wg8TWQ_-Pltqp4G",REACT_APP_SUPABASE_URL:"https://jzohkzrrroxrjjomkjbg.supabase.co",REACT_APP_VAPI_PUBLIC_KEY:"0cc61bed-52da-4674-b316-6ada9ecd7157"}.REACT_APP_EXPERT_SERVICE_URL,ruleService:{NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_AUTHOR_ONBOARDING_VAPI_ASSISTANT_ID:"89d317fb-f742-48e3-bcdb-2a0ffa4d4c9a",REACT_APP_BACKEND_URL:"https://proxy-service-gateway-au4uagnd.uc.gateway.dev",REACT_APP_DEEPER_ONBOARDING_VAPI_ASSISTANT_ID:"4e5b0f3e-3322-468c-b185-4ef8ee8e1866",REACT_APP_STRIPE_PUBLISHABLE_KEY:"pk_live_51RsqLlQlQWc4RelR90DIbICaVuL54pY1MINimpUB6cNk5ic8OzUMq0nYQDQkYtrwvYO9JwrRuX45vjB7DmVzCcrU00tDVCiytg",REACT_APP_SUPABASE_ANON_KEY:"sb_publishable_bsBi_9kdOMYnN374Wg8TWQ_-Pltqp4G",REACT_APP_SUPABASE_URL:"https://jzohkzrrroxrjjomkjbg.supabase.co",REACT_APP_VAPI_PUBLIC_KEY:"0cc61bed-52da-4674-b316-6ada9ecd7157"}.REACT_APP_RULE_SERVICE_URL,baseUrl:{NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_AUTHOR_ONBOARDING_VAPI_ASSISTANT_ID:"89d317fb-f742-48e3-bcdb-2a0ffa4d4c9a",REACT_APP_BACKEND_URL:"https://proxy-service-gateway-au4uagnd.uc.gateway.dev",REACT_APP_DEEPER_ONBOARDING_VAPI_ASSISTANT_ID:"4e5b0f3e-3322-468c-b185-4ef8ee8e1866",REACT_APP_STRIPE_PUBLISHABLE_KEY:"pk_live_51RsqLlQlQWc4RelR90DIbICaVuL54pY1MINimpUB6cNk5ic8OzUMq0nYQDQkYtrwvYO9JwrRuX45vjB7DmVzCcrU00tDVCiytg",REACT_APP_SUPABASE_ANON_KEY:"sb_publishable_bsBi_9kdOMYnN374Wg8TWQ_-Pltqp4G",REACT_APP_SUPABASE_URL:"https://jzohkzrrroxrjjomkjbg.supabase.co",REACT_APP_VAPI_PUBLIC_KEY:"0cc61bed-52da-4674-b316-6ada9ecd7157"}.REACT_APP_SITE_URL||"https://apexreplicant.ai",supabaseUrl:"https://jzohkzrrroxrjjomkjbg.supabase.co",supabaseAnonKey:"sb_publishable_bsBi_9kdOMYnN374Wg8TWQ_-Pltqp4G"},a=["backendProxy","supabaseUrl","supabaseAnonKey"].filter((e=>!r[e]));a.length>0&&(console.error("\u274c Missing required environment variables for:",a),console.error("Please check your .env file configuration"));const o=r},402(e,t,n){"use strict";n.d(t,{A:()=>c});var r=n(5043),a=n(9994),o=n(1832),i=n(4650),s=n.n(i),l=n(7351),u=n(579);const c=e=>{let{expertData:t,initialMode:n="signup",signinOnly:i=!1,showSignupLinks:c=!1,opaqueCard:d=!1}=e;const[f,h]=(0,r.useState)(i?"signin":n),[p,m]=(0,r.useState)(!1),[g,v]=(0,r.useState)(""),[y,b]=(0,r.useState)(""),[w,_]=(0,r.useState)(""),[S,x]=(0,r.useState)(""),[k,A]=(0,r.useState)(""),[E,C]=(0,r.useState)(""),[T,P]=(0,r.useState)(!1),[j,O]=(0,r.useState)(!1),[N,R]=(0,r.useState)(""),[L,M]=(0,r.useState)(""),[I,D]=(0,r.useState)(""),[$,F]=(0,r.useState)(""),[U,B]=(0,r.useState)(""),[z,H]=(0,r.useState)(""),[Z,W]=(0,r.useState)(""),[K,G]=(0,r.useState)(""),[q,V]=(0,r.useState)(""),[Y,Q]=(0,r.useState)(""),[J,X]=(0,r.useState)(!1),[ee,te]=(0,r.useState)(!1),[ne,re]=(0,r.useState)(!1),[ae,oe]=(0,r.useState)(""),[ie,se]=(0,r.useState)(!1),[le,ue]=(0,r.useState)(""),[ce,de]=(0,r.useState)(!1),[fe,he]=(0,r.useState)(""),[pe,me]=(0,r.useState)(""),[ge,ve]=(0,r.useState)(""),[ye,be]=(0,r.useState)(""),[we,_e]=(0,r.useState)(""),[Se,xe]=(0,r.useState)(""),[ke,Ae]=(0,r.useState)(!1),[Ee,Ce]=(0,r.useState)(!1),Te=e=>({background:"rgba(255,255,255,0.06)",border:"1px solid ".concat(e?"rgba(239,68,68,0.5)":"rgba(255,255,255,0.1)"),color:"white"}),Pe=async()=>{if(y){te(!0),Q("");try{const{error:e}=await a.N.auth.resend({type:"signup",email:y});e&&Q(e.message||"Failed to resend code")}catch(e){Q("Something went wrong. Please try again.")}finally{te(!1)}}},je=async e=>{if(e.preventDefault(),6===q.length){X(!0),Q("");try{const{error:e}=await a.N.auth.verifyOtp({email:y,token:q,type:"email"});if(e)return void Q(e.message||"Invalid code");re(!0)}catch(t){Q("Something went wrong. Please try again.")}finally{X(!1)}}else Q("Please enter a 6-digit code")},Oe=async e=>{if(e.preventDefault(),s().isEmail(ae)){de(!0),ue("");try{const e=await fetch("https://jzohkzrrroxrjjomkjbg.supabase.co/functions/v1/otp-reset/request",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:ae.toLowerCase().trim()})}),t=await e.json();if(!e.ok||!t.success)return void ue(t.error||"Failed to send reset code. Please try again.");se(!0)}catch(t){ue("Something went wrong. Please try again.")}finally{de(!1)}}else ue("Please enter a valid email address")},Ne=async e=>{if(e.preventDefault(),me(""),be(""),xe(""),ue(""),6===fe.length)if(ge.length<8||!/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])/.test(ge))be("Must be 8+ chars with uppercase, lowercase, number, and special character");else if(ge===we){Ae(!0);try{const e=await fetch("https://jzohkzrrroxrjjomkjbg.supabase.co/functions/v1/otp-reset/confirm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:ae.toLowerCase().trim(),otp:fe,new_password:ge})}),t=await e.json();if(!e.ok||!t.success){const e=t.error||"Failed to reset password";return void(e.includes("expired")?me("Code expired \u2014 use the link below to request a new one"):e.includes("Invalid OTP")||e.includes("Invalid or expired OTP")?(me("Incorrect code \u2014 please try again"),he("")):e.includes("User not found")?ue("No account found with that email address"):ue(e))}Ce(!0),await a.N.auth.signInWithPassword({email:ae.toLowerCase().trim(),password:ge})}catch(t){ue("Something went wrong. Please try again.")}finally{Ae(!1)}}else xe("Passwords don't match");else me("Please enter the 6-digit code from your email")};return"forgot-password"===f?(0,u.jsx)("div",{className:"rounded-xl p-6",style:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,215,0,0.25)"},children:ie?Ee?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4",style:{background:"rgba(34,197,94,0.15)",border:"1px solid rgba(34,197,94,0.4)"},children:(0,u.jsx)("svg",{className:"w-8 h-8 text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,u.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),(0,u.jsx)("h3",{className:"text-xl font-bold text-green-400 mb-2 text-center",children:"Password Updated!"}),(0,u.jsx)("p",{className:"text-gray-300 text-sm text-center",children:"Signing you in..."})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("h3",{className:"text-xl font-bold text-white mb-1 text-center",children:"Check Your Email"}),(0,u.jsxs)("p",{className:"text-gray-400 text-xs text-center mb-4",children:["We sent a 6-digit code to"," ",(0,u.jsx)("span",{className:"text-yellow-400 font-medium",children:ae})]}),le&&(0,u.jsx)("p",{className:"text-red-400 text-xs mb-3 text-center",children:le}),(0,u.jsxs)("form",{onSubmit:Ne,className:"space-y-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("input",{type:"text",value:fe,onChange:e=>{he(e.target.value.replace(/\D/g,"").slice(0,6)),me("")},placeholder:"000000",maxLength:6,autoFocus:!0,inputMode:"numeric",className:"w-full px-4 py-3 rounded-lg text-center text-2xl font-bold placeholder-gray-500 focus:outline-none tracking-widest",style:{background:"rgba(255,255,255,0.06)",border:"1px solid ".concat(pe?"rgba(239,68,68,0.5)":"rgba(255,255,255,0.15)"),color:"#67e8f9",letterSpacing:"0.5em"}}),pe&&(0,u.jsx)("p",{className:"text-red-400 text-xs mt-1",children:pe})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("input",{type:"password",value:ge,onChange:e=>{ve(e.target.value),be(""),we&&e.target.value===we&&xe("")},placeholder:"New password",disabled:ke,className:"w-full px-3 py-2.5 rounded-lg text-sm placeholder-gray-500 focus:outline-none",style:{background:"rgba(255,255,255,0.06)",border:"1px solid ".concat(ye?"rgba(239,68,68,0.5)":"rgba(255,255,255,0.1)"),color:"white"}}),ye&&(0,u.jsx)("p",{className:"text-red-400 text-xs mt-1",children:ye})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("input",{type:"password",value:we,onChange:e=>{_e(e.target.value),e.target.value&&e.target.value!==ge?xe("Passwords don't match"):xe("")},placeholder:"Confirm new password",disabled:ke,className:"w-full px-3 py-2.5 rounded-lg text-sm placeholder-gray-500 focus:outline-none",style:{background:"rgba(255,255,255,0.06)",border:"1px solid ".concat(Se?"rgba(239,68,68,0.5)":"rgba(255,255,255,0.1)"),color:"white"}}),Se&&(0,u.jsx)("p",{className:"text-red-400 text-xs mt-1",children:Se})]}),(0,u.jsx)("button",{type:"submit",disabled:ke||6!==fe.length,className:"w-full py-3 rounded-lg font-bold text-sm transition-all hover:scale-[1.01] disabled:opacity-50",style:{background:"#FFD700",color:"#1A1A2E"},children:ke?"Resetting...":"Reset Password \u2192"})]}),(0,u.jsxs)("div",{className:"mt-4 text-center space-y-2",children:[(0,u.jsx)("button",{type:"button",onClick:()=>{se(!1),he(""),me(""),ue("")},className:"text-xs text-gray-500 hover:text-gray-300 transition-colors block w-full",children:"\u2190 Request a new code"}),(0,u.jsx)("button",{type:"button",onClick:()=>h("signin"),className:"text-xs text-gray-500 hover:text-gray-300 transition-colors",children:"Back to Sign In"})]})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("h3",{className:"text-xl font-bold text-white mb-2 text-center",children:"Reset Password"}),(0,u.jsx)("p",{className:"text-gray-400 text-sm mb-5 text-center",children:"Enter your email and we'll send you a 6-digit reset code."}),(0,u.jsxs)("form",{onSubmit:Oe,className:"space-y-3",children:[(0,u.jsx)("input",{type:"email",value:ae,onChange:e=>{oe(e.target.value),ue("")},placeholder:"Email address",autoFocus:!0,disabled:ce,className:"w-full px-3 py-2.5 rounded-lg text-sm placeholder-gray-500 focus:outline-none",style:{background:"rgba(255,255,255,0.06)",border:"1px solid ".concat(le?"rgba(239,68,68,0.5)":"rgba(255,255,255,0.1)"),color:"white"}}),le&&(0,u.jsx)("p",{className:"text-red-400 text-xs",children:le}),(0,u.jsx)("button",{type:"submit",disabled:ce,className:"w-full py-3 rounded-lg font-bold text-sm transition-all hover:scale-[1.01] disabled:opacity-50",style:{background:"#FFD700",color:"#1A1A2E"},children:ce?"Sending...":"Send Code \u2192"})]}),(0,u.jsx)("div",{className:"mt-4 text-center",children:(0,u.jsx)("button",{onClick:()=>h("signin"),className:"text-xs text-gray-500 hover:text-gray-300 transition-colors",children:"\u2190 Back to Sign In"})})]})}):"check-email"===f?(0,u.jsx)("div",{className:"rounded-xl p-6",style:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,215,0,0.25)"},children:ne?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4",style:{background:"rgba(34,197,94,0.15)",border:"1px solid rgba(34,197,94,0.4)"},children:(0,u.jsx)("svg",{className:"w-8 h-8 text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,u.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),(0,u.jsx)("h3",{className:"text-xl font-bold text-green-400 mb-2 text-center",children:"Email Confirmed!"}),(0,u.jsx)("p",{className:"text-gray-300 text-sm mb-5 text-center",children:"Your account is ready. You're now signed in."})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4",style:{background:"rgba(34,197,94,0.15)",border:"1px solid rgba(34,197,94,0.4)"},children:(0,u.jsx)("svg",{className:"w-8 h-8 text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,u.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}),(0,u.jsx)("h3",{className:"text-xl font-bold text-white mb-2 text-center",children:"Check your email"}),(0,u.jsxs)("p",{className:"text-gray-300 text-sm mb-5 leading-relaxed text-center",children:["We sent a 6-digit confirmation code to"," ",(0,u.jsx)("span",{className:"text-yellow-400 font-medium",children:y}),". Enter it below to activate your account."]}),(0,u.jsxs)("form",{onSubmit:je,className:"space-y-3",children:[(0,u.jsx)("input",{type:"text",value:q,onChange:e=>V(e.target.value.replace(/\D/g,"").slice(0,6)),placeholder:"000000",maxLength:6,autoFocus:!0,className:"w-full px-4 py-3 rounded-lg text-center text-2xl font-bold placeholder-gray-500 focus:outline-none tracking-widest",style:{background:"rgba(255,255,255,0.06)",border:"1px solid ".concat(Y?"rgba(239,68,68,0.5)":"rgba(255,255,255,0.15)"),color:"#67e8f9",letterSpacing:"0.5em"}}),Y&&(0,u.jsx)("p",{className:"text-red-400 text-xs text-center",children:Y}),(0,u.jsx)("button",{type:"submit",disabled:J||6!==q.length,className:"w-full py-3 rounded-lg font-bold text-sm transition-all hover:scale-[1.01] disabled:opacity-50",style:{background:"#FFD700",color:"#1A1A2E"},children:J?"Confirming...":"Confirm Email \u2192"})]}),(0,u.jsx)("div",{className:"mt-4 text-center",children:(0,u.jsx)("button",{onClick:Pe,disabled:ee,className:"text-xs text-gray-500 hover:text-gray-300 transition-colors disabled:opacity-50",children:ee?"Sending...":"Didn't receive a code? Resend"})})]})}):(0,u.jsxs)("div",{className:"rounded-xl p-5",style:{background:d?"rgba(20,21,50,0.97)":"rgba(255,255,255,0.03)",border:"1px solid rgba(255,215,0,0.25)"},children:[!i&&(0,u.jsxs)("div",{className:"flex rounded-lg overflow-hidden mb-5",style:{border:"1px solid rgba(255,215,0,0.2)"},children:[(0,u.jsx)("button",{onClick:()=>h("signup"),className:"flex-1 py-2 text-sm font-semibold transition-all",style:{background:"signup"===f?"rgba(255,215,0,0.15)":"transparent",color:"signup"===f?"#FFD700":"#9CA3AF",borderRight:"1px solid rgba(255,215,0,0.2)"},children:"Create Account"}),(0,u.jsx)("button",{onClick:()=>h("signin"),className:"flex-1 py-2 text-sm font-semibold transition-all",style:{background:"signin"===f?"rgba(255,215,0,0.15)":"transparent",color:"signin"===f?"#FFD700":"#9CA3AF"},children:"Sign In"})]}),("signin"===f||i)&&(0,u.jsxs)("button",{type:"button",onClick:async()=>{m(!0),v(""),G("");try{const{error:e}=await a.N.auth.signInWithOAuth({provider:"google",options:{redirectTo:"".concat(window.location.origin,"/auth/callback?role=client&returnTo=").concat(encodeURIComponent(window.location.pathname))}});e&&(v("Failed to sign in with Google. Please try again."),m(!1))}catch(e){v("Something went wrong. Please try again."),m(!1)}},disabled:p,className:"w-full flex items-center justify-center gap-2.5 py-2.5 px-4 rounded-lg font-medium text-sm transition-all hover:bg-gray-100 disabled:opacity-50 mb-4",style:{background:"white",color:"#111"},children:[(0,u.jsxs)("svg",{className:"w-4 h-4 flex-shrink-0",viewBox:"0 0 24 24",children:[(0,u.jsx)("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),(0,u.jsx)("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),(0,u.jsx)("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),(0,u.jsx)("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),"Continue with Google"]}),c&&(0,u.jsxs)("p",{className:"text-center text-xs text-gray-500 -mt-3 mb-4",children:["New here? ",(0,u.jsx)("a",{href:"/experts",className:"text-yellow-400 hover:underline",children:"Browse our expert directory"})," to get started as a client, or ",(0,u.jsx)("a",{href:"/signup",className:"text-yellow-400 hover:underline",children:"apply as an expert"}),"."]}),(0,u.jsxs)("div",{className:"relative my-4",children:[(0,u.jsx)("div",{className:"absolute inset-0 flex items-center",children:(0,u.jsx)("div",{className:"w-full border-t",style:{borderColor:"rgba(255,255,255,0.08)"}})}),(0,u.jsx)("div",{className:"relative flex justify-center text-xs",children:(0,u.jsx)("span",{className:"px-2 text-gray-500",style:{backgroundColor:"#1a1a2e"},children:"or continue with email"})})]}),g&&(0,u.jsx)("div",{className:"mb-4 p-3 rounded-lg text-sm text-red-400",style:{background:"rgba(239,68,68,0.1)",border:"1px solid rgba(239,68,68,0.3)"},children:g}),"signup"===f?(0,u.jsxs)("form",{onSubmit:async e=>{e.preventDefault(),m(!0),v(""),R(""),M(""),D(""),F(""),B("");let n=!0;if(w.trim()&&/^[a-zA-Z\s]+$/.test(w.trim())||(R("Please enter a valid name (letters only)"),n=!1),s().isEmail(S)||(M("Please enter a valid email"),n=!1),(k.length<6||!/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])/.test(k))&&(D("Must be 6+ chars with uppercase, lowercase, number, and special character"),n=!1),s().isMobilePhone(E,"en-US")||(F("Please enter a valid U.S. phone number"),n=!1),T||(B("You must agree to the Terms of Use"),n=!1),n)try{const e=new Date;e.setFullYear(e.getFullYear()+100);const n=await fetch("".concat(o.A.backendProxy,"/signup"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:w,email:S,role:"client",password:k,selected:["A_CLIENT"],linkedIn:"https://linkedin.com/in/dummy",phone_number:E,selectedDateTime:e,primary_expert_id:null===t||void 0===t?void 0:t.id,otherSpecialty:null,referral:null,website:null,blog:null,youtube:null,info:null,sms_consent:j,sms_consent_method:"website"})}),a=await n.json();var r;if(n.ok)null!==(r=a.welcome_coupon)&&void 0!==r&&r.coupon_code&&(0,l.Mo)(a.welcome_coupon.coupon_code),b(S),h("check-email");else"email-dup"===a.status?M(a.message):v(a.message||"Signup failed. Please try again.")}catch(a){v("Network error. Please check your connection.")}finally{m(!1)}else m(!1)},className:"space-y-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("input",{type:"text",placeholder:"Full name",value:w,onChange:e=>_(e.target.value),disabled:p,className:"w-full px-3 py-2.5 rounded-lg text-sm placeholder-gray-500 focus:outline-none",style:Te(N)}),N&&(0,u.jsx)("p",{className:"text-red-400 text-xs mt-1",children:N})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("input",{type:"email",placeholder:"Email address",value:S,onChange:e=>x(e.target.value),disabled:p,className:"w-full px-3 py-2.5 rounded-lg text-sm placeholder-gray-500 focus:outline-none",style:Te(L)}),L&&(0,u.jsx)("p",{className:"text-red-400 text-xs mt-1",children:L})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("input",{type:"password",placeholder:"Password",value:k,onChange:e=>A(e.target.value),disabled:p,className:"w-full px-3 py-2.5 rounded-lg text-sm placeholder-gray-500 focus:outline-none",style:Te(I)}),I&&(0,u.jsx)("p",{className:"text-red-400 text-xs mt-1",children:I}),!I&&(0,u.jsx)("p",{className:"text-gray-600 text-xs mt-1",children:"Uppercase, lowercase, number, and special character required"})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("input",{type:"tel",placeholder:"U.S. phone number",value:E,onChange:e=>C(e.target.value),disabled:p,className:"w-full px-3 py-2.5 rounded-lg text-sm placeholder-gray-500 focus:outline-none",style:Te($)}),$&&(0,u.jsx)("p",{className:"text-red-400 text-xs mt-1",children:$})]}),(0,u.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer",children:[(0,u.jsx)("input",{type:"checkbox",checked:T,onChange:e=>{P(e.target.checked),e.target.checked&&B("")},className:"mt-0.5 flex-shrink-0",disabled:p}),(0,u.jsxs)("span",{className:"text-xs text-gray-400",children:["I agree to the"," ",(0,u.jsx)("a",{href:"https://expertscale.ai/TOU.html",target:"_blank",rel:"noopener noreferrer",className:"text-yellow-400 hover:underline",children:"Terms"})," ","and"," ",(0,u.jsx)("a",{href:"https://expertscale.ai/privacy-policy.html",target:"_blank",rel:"noopener noreferrer",className:"text-yellow-400 hover:underline",children:"Privacy Policy"})]})]}),U&&(0,u.jsx)("p",{className:"text-red-400 text-xs",children:U}),(0,u.jsxs)("label",{className:"flex items-start gap-2 cursor-pointer",children:[(0,u.jsx)("input",{type:"checkbox",checked:j,onChange:e=>O(e.target.checked),className:"mt-0.5 flex-shrink-0",disabled:p}),(0,u.jsx)("span",{className:"text-xs text-gray-400",children:"I consent to SMS notifications from Expert Scale. Reply STOP to opt out."})]}),(0,u.jsx)("button",{type:"submit",disabled:p,className:"w-full py-3 rounded-lg font-bold text-sm transition-all hover:scale-[1.01] disabled:opacity-50",style:{background:"#FFD700",color:"#1A1A2E"},children:p?"Creating account...":"Create Free Account \u2192"}),(0,u.jsx)("p",{className:"text-xs text-gray-500 text-center",children:"Free to start \xb7 No credit card required"})]}):(0,u.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),m(!0),G(""),!z.trim()||!Z.trim())return G("Email and password are required"),void m(!1);const{error:t}=await a.N.auth.signInWithPassword({email:z,password:Z});t&&("email_not_confirmed"===t.code?G("Email not confirmed. Please check your inbox and verify your account."):G(t.message||"Login failed. Check your email and password."),m(!1))},className:"space-y-3",children:[(0,u.jsx)("div",{children:(0,u.jsx)("input",{type:"email",placeholder:"Email address",value:z,onChange:e=>H(e.target.value),disabled:p,className:"w-full px-3 py-2.5 rounded-lg text-sm placeholder-gray-500 focus:outline-none",style:Te(!1)})}),(0,u.jsx)("div",{children:(0,u.jsx)("input",{type:"password",placeholder:"Password",value:Z,onChange:e=>W(e.target.value),disabled:p,className:"w-full px-3 py-2.5 rounded-lg text-sm placeholder-gray-500 focus:outline-none",style:Te(!1)})}),K&&(0,u.jsx)("p",{className:"text-red-400 text-xs",children:K}),(0,u.jsx)("button",{type:"submit",disabled:p,className:"w-full py-3 rounded-lg font-bold text-sm transition-all hover:scale-[1.01] disabled:opacity-50",style:{background:"#FFD700",color:"#1A1A2E"},children:p?"Signing in...":"Sign In \u2192"}),(0,u.jsx)("div",{className:"text-center text-xs",children:(0,u.jsx)("button",{type:"button",onClick:()=>{h("forgot-password"),oe(z),se(!1),ue("")},className:"text-gray-500 hover:text-yellow-400 transition-colors",children:"Forgot password?"})})]})]})}},8729(e,t,n){"use strict";n.d(t,{A:()=>c,O:()=>u});var r=n(5043),a=n(5847),o=n(9994),i=n(1832),s=n(579);const l=(0,r.createContext)();function u(e){let{children:t}=e;const n=(0,a.Zp)(),u=(0,a.zy)(),[c,d]=(0,r.useState)(null),[f,h]=(0,r.useState)(null),[p,m]=(0,r.useState)(null),[g,v]=(0,r.useState)(null),[y,b]=(0,r.useState)(null),[w,_]=(0,r.useState)(null),[S,x]=(0,r.useState)(null),[k,A]=(0,r.useState)(!0),[E,C]=(0,r.useState)(null),T=async function(e){var t,r;let a=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(console.log("\ud83d\udd0d fetchUserRoleAndExpertId called with session:",{hasSession:!!e,hasAccessToken:!(null===e||void 0===e||!e.access_token),tokenLength:null===e||void 0===e||null===(t=e.access_token)||void 0===t?void 0:t.length,userId:null===e||void 0===e||null===(r=e.user)||void 0===r?void 0:r.id,setLoading:a}),a&&A(!0),null===e||void 0===e||!e.access_token)return console.log("\u274c No access token, setting role to null"),h(null),m(null),v(null),b(null),_(null),x(null),C(null),void A(!1);console.log("\ud83d\udce1 Making role-check request to:","".concat(i.A.backendProxy,"/role-check")),console.log("\ud83d\udd27 Using API Gateway endpoint (updated 2025-09-09)");try{const t=await fetch("".concat(i.A.backendProxy,"/role-check"),{method:"GET",headers:{Authorization:"Bearer ".concat(e.access_token),"X-Jwt-Token":e.access_token,"Content-Type":"application/json"},credentials:"include"});if(t.ok){const r=await t.json();console.log("\u2705 Role check successful:",r.role,r),h(r.role),console.log("\ud83d\udd0d AuthContext: Setting clientId and names:",{received_client_id:r.client_id,received_client_name:r.client_name,received_expert_name:r.expert_name,role:r.role,email:r.email||"unknown"}),m(r.client_id||null),v(r.client_name||null),b(r.expert_id||null),_(r.expert_name||null),x(r.client_expert_id||null),"expert"===r.role&&await(async e=>{if(null!==e&&void 0!==e&&e.access_token)try{console.log("\ud83d\udd0d Checking expert registration status...");const r=await fetch("".concat(i.A.backendProxy,"/check-registration"),{method:"GET",headers:{Authorization:"Bearer ".concat(e.access_token),"X-Jwt-Token":e.access_token,"Content-Type":"application/json"}});if(r.ok){var t;const e=await r.json();console.log("\u2705 Registration status:",e.stage);const a=null===(t=e.stage)||void 0===t?void 0:t.toLowerCase();if(C(e.stage),"approved"===a){const e=u.pathname,t=["/onboarding-preview","/client-onboarding-preview"];["/complete-registration","/account","/logout","/reset-password","/login","/"].includes(e)||t.some((t=>e.startsWith(t)))||(console.log("\ud83d\udd04 Redirecting incomplete expert to complete-registration"),n("/complete-registration"))}if("applied"===a||"interviewed"===a){const t=u.pathname;["/","/account","/logout","/reset-password","/login"].includes(t)||(console.log("\ud83d\udd04 Redirecting ".concat(e.stage.toLowerCase()," expert to home page")),n("/"))}}else console.log("\u2139\ufe0f Registration check failed or not applicable:",r.status)}catch(r){console.error("Error checking registration status:",r)}})(e)}else console.error("\u274c Role check failed:",t.statusText),h(null),m(null),v(null),b(null),_(null),x(null),C(null)}catch(o){console.error("Error fetching role and expert ID:",o),h(null),m(null),v(null),b(null),_(null),x(null)}finally{A(!1)}};(0,r.useEffect)((()=>{(async()=>{const{data:{session:e},error:t}=await o.N.auth.getSession(),n=(null===e||void 0===e?void 0:e.user)||null;d(n),n?await T(e):(h(null),m(null),v(null),b(null),_(null),x(null),C(null)),A(!1)})();const{data:e}=o.N.auth.onAuthStateChange(((e,t)=>{var n;console.log("\ud83d\udd04 Auth state change detected:",{event:e,hasUser:!(null===t||void 0===t||!t.user),userId:null===t||void 0===t||null===(n=t.user)||void 0===n?void 0:n.id,hasToken:!(null===t||void 0===t||!t.access_token)});const r=(null===t||void 0===t?void 0:t.user)||null;d(r),r?(console.log("\ud83d\udc64 User found, calling fetchUserRoleAndExpertId..."),T(t,!0)):(console.log("\u274c No user, clearing role and expertId"),h(null),m(null),v(null),b(null),_(null),x(null),C(null),A(!1))}));return()=>{e.subscription.unsubscribe()}}),[]);return(0,s.jsx)(l.Provider,{value:{user:c,isLoggedIn:!!c,role:f,clientId:p,clientName:g,expertId:y,expertName:w,clientExpertId:S,expertStage:E,setRole:h,checkingAuth:k,getAuthToken:async()=>{var e;const{data:{session:t}}=await o.N.auth.getSession();if(null!==t&&void 0!==t&&t.access_token)return t.access_token;const{data:{session:n}}=await o.N.auth.refreshSession();return null!==(e=null===n||void 0===n?void 0:n.access_token)&&void 0!==e?e:null}},children:t})}function c(){return(0,r.useContext)(l)}},1323(e,t,n){"use strict";n.d(t,{I:()=>x,f:()=>k});var r=n(9379),a=n(5043);class o extends Error{}function i(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(n){return atob(t)}}function s(e,t){if("string"!==typeof e)throw new o("Invalid token specified: must be a string");t||(t={});const n=!0===t.header?0:1,r=e.split(".")[n];if("string"!==typeof r)throw new o("Invalid token specified: missing part #".concat(n+1));let a;try{a=i(r)}catch(s){throw new o("Invalid token specified: invalid base64 for part #".concat(n+1," (").concat(s.message,")"))}try{return JSON.parse(a)}catch(s){throw new o("Invalid token specified: invalid json for part #".concat(n+1," (").concat(s.message,")"))}}o.prototype.name="InvalidTokenError";var l=n(579);const u=(0,a.createContext)(),c="SET_LOADING",d="SET_ERROR",f="SET_RULES",h="ADD_RULE",p="UPDATE_RULE",m="DELETE_RULE",g="SET_ANALYTICS",v="SET_TEST_RESULTS",y="SET_TEMPLATES",b="CLEAR_ERROR",w={rules:[],templates:[],analytics:null,testResults:null,loading:!1,error:null};function _(e,t){switch(t.type){case c:return(0,r.A)((0,r.A)({},e),{},{loading:t.payload,error:t.payload?null:e.error});case d:return(0,r.A)((0,r.A)({},e),{},{error:t.payload,loading:!1});case b:return(0,r.A)((0,r.A)({},e),{},{error:null});case f:return(0,r.A)((0,r.A)({},e),{},{rules:t.payload,loading:!1,error:null});case h:return(0,r.A)((0,r.A)({},e),{},{rules:[...e.rules,t.payload],loading:!1,error:null});case p:return(0,r.A)((0,r.A)({},e),{},{rules:e.rules.map((e=>e.id===t.payload.id?t.payload:e)),loading:!1,error:null});case m:return(0,r.A)((0,r.A)({},e),{},{rules:e.rules.filter((e=>e.id!==t.payload)),loading:!1,error:null});case g:return(0,r.A)((0,r.A)({},e),{},{analytics:t.payload,loading:!1,error:null});case v:return(0,r.A)((0,r.A)({},e),{},{testResults:t.payload,loading:!1,error:null});case y:return(0,r.A)((0,r.A)({},e),{},{templates:t.payload,loading:!1,error:null});default:return e}}const S=[{id:"client_frustration_alert",name:"\ud83d\udd25 Client Frustration Alert",description:"Get notified when clients express frustration or request human help",category:"escalation",service_type:"session",rule_category:"escalation",conditions:{operator:"OR",rules:[{field:"sentiment_score",operator:"less_than",value:.3},{field:"call_summary",operator:"contains_any",value:["frustrated","speak to human","real person","not satisfied"]}]},actions:[{type:"immediate_escalation",config:{priority:"high",notification_type:"client_frustration"}}]},{id:"session_summary_email",name:"\ud83d\udce7 Session Summary Email",description:"Automatically send session summaries after each completed call",category:"notification",service_type:"session",rule_category:"business_intelligence",conditions:{operator:"AND",rules:[{field:"session_status",operator:"equals",value:"completed"},{field:"session_duration",operator:"greater_than",value:300}]},actions:[{type:"notify_expert",config:{notification_type:"session_complete",template:"session_summary"}}]},{id:"quality_lead_followup",name:"\ud83c\udfaf Quality Lead Follow-up",description:"Send personalized follow-up emails to A and B level prospects",category:"follow_up",service_type:"session",rule_category:"business_intelligence",conditions:{operator:"AND",rules:[{field:"lead_score",operator:"in",value:["A","B"]},{field:"session_status",operator:"equals",value:"completed"}]},actions:[{type:"client_followup",config:{template:"quality_lead_followup",delay_hours:24}}]}];function x(e){let{children:t}=e;const[n,o]=(0,a.useReducer)(_,w),i=(0,a.useCallback)((()=>{const e=localStorage.getItem("accessToken");if(!e)return null;try{return s(e).api_key||"default-key"}catch(t){return console.error("Error decoding token:",t),"default-key"}}),[]),x=(0,a.useCallback)((()=>{const e=localStorage.getItem("accessToken");if(!e)return null;try{const t=s(e);return t.sub||t.user_id}catch(t){return console.error("Error decoding token:",t),null}}),[]),k=(0,a.useCallback)((async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=i();if(!n)throw new Error("No API key available");const a=await fetch("".concat("https://us-central1-apex-replicant.cloudfunctions.net/rule-service").concat(e),(0,r.A)({headers:(0,r.A)({"Content-Type":"application/json","x-api-key":n},t.headers)},t));if(!a.ok)throw new Error("API call failed: ".concat(a.status," ").concat(a.statusText));return await a.json()}),[i]),A=(0,a.useCallback)((async()=>{const e=x();if(e){o({type:c,payload:!0});try{const t=await k("/rules?expert_id=".concat(e,"&service_type=session"));o({type:f,payload:t.rules||[]})}catch(t){console.error("Error loading rules:",t),o({type:d,payload:t.message})}}else o({type:d,payload:"No expert ID available"})}),[k,x]),E=(0,a.useCallback)((async e=>{const t=x();if(!t)throw new Error("No expert ID available");o({type:c,payload:!0});try{const n=await k("/rules",{method:"POST",body:JSON.stringify((0,r.A)((0,r.A)({},e),{},{expert_id:t,rule_scope:"expert"}))});return o({type:h,payload:n}),n}catch(n){throw console.error("Error creating rule:",n),o({type:d,payload:n.message}),n}}),[k,x]),C=(0,a.useCallback)((async(e,t)=>{o({type:c,payload:!0});try{const n=await k("/rules/".concat(e),{method:"PUT",body:JSON.stringify(t)});return o({type:p,payload:n}),n}catch(n){throw console.error("Error updating rule:",n),o({type:d,payload:n.message}),n}}),[k]),T=(0,a.useCallback)((async e=>{o({type:c,payload:!0});try{await k("/rules/".concat(e),{method:"DELETE"}),o({type:m,payload:e})}catch(t){throw console.error("Error deleting rule:",t),o({type:d,payload:t.message}),t}}),[k]),P=(0,a.useCallback)((async(e,t)=>{o({type:c,payload:!0});try{const n=await k("/rules/".concat(e,"/toggle"),{method:"POST",body:JSON.stringify({is_active:t})});o({type:p,payload:n.rule})}catch(n){console.error("Error toggling rule:",n),o({type:d,payload:n.message})}}),[k]),j=(0,a.useCallback)((async(e,t)=>{o({type:c,payload:!0});try{const n=await k("/rules/".concat(e,"/test"),{method:"POST",body:JSON.stringify(t)});return o({type:v,payload:n}),n}catch(n){throw console.error("Error testing rule:",n),o({type:d,payload:n.message}),n}}),[k]),O=(0,a.useCallback)((async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"24h";const t=x();if(t){o({type:c,payload:!0});try{const n=await k("/analytics?service_type=session&time_range=".concat(e,"&expert_id=").concat(t));o({type:g,payload:n})}catch(n){console.error("Error loading analytics:",n),o({type:d,payload:n.message})}}}),[k,x]),N=(0,a.useCallback)((async()=>{try{o({type:y,payload:S})}catch(e){console.error("Error loading templates:",e),o({type:d,payload:e.message})}}),[]),R=(0,a.useCallback)((()=>{o({type:b})}),[]),L=(0,a.useCallback)((e=>n.templates.find((t=>t.id===e))),[n.templates]);(0,a.useEffect)((()=>{N()}),[N]);const M={rules:n.rules,templates:n.templates,analytics:n.analytics,testResults:n.testResults,loading:n.loading,error:n.error,loadRules:A,createRule:E,updateRule:C,deleteRule:T,toggleRule:P,testRule:j,loadAnalytics:O,loadTemplates:N,clearError:R,getTemplate:L};return(0,l.jsx)(u.Provider,{value:M,children:t})}function k(){const e=(0,a.useContext)(u);if(void 0===e)throw new Error("useRules must be used within a RuleProvider");return e}},9994(e,t,n){"use strict";n.d(t,{N:()=>Gt});class r extends Error{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"FunctionsError",n=arguments.length>2?arguments[2]:void 0;super(e),this.name=t,this.context=n}}class a extends r{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class o extends r{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class i extends r{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var s;!function(e){e.Any="any",e.ApNortheast1="ap-northeast-1",e.ApNortheast2="ap-northeast-2",e.ApSouth1="ap-south-1",e.ApSoutheast1="ap-southeast-1",e.ApSoutheast2="ap-southeast-2",e.CaCentral1="ca-central-1",e.EuCentral1="eu-central-1",e.EuWest1="eu-west-1",e.EuWest2="eu-west-2",e.EuWest3="eu-west-3",e.SaEast1="sa-east-1",e.UsEast1="us-east-1",e.UsWest1="us-west-1",e.UsWest2="us-west-2"}(s||(s={}));var l=function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function i(e){try{l(r.next(e))}catch(t){o(t)}}function s(e){try{l(r.throw(e))}catch(t){o(t)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}l((r=r.apply(e,t||[])).next())}))};class u{constructor(e){let{headers:t={},customFetch:r,region:a=s.Any}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.url=e,this.headers=t,this.region=a,this.fetch=(e=>{let t;return t=e||("undefined"===typeof fetch?function(){for(var e=arguments.length,t=new Array(e),r=0;r{let{default:n}=e;return n(...t)}))}:fetch),function(){return t(...arguments)}})(r)}setAuth(e){this.headers.Authorization="Bearer ".concat(e)}invoke(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n;return l(this,void 0,void 0,(function*(){try{const{headers:r,method:s,body:l}=t;let u={},{region:c}=t;c||(c=this.region);const d=new URL("".concat(this.url,"/").concat(e));let f;c&&"any"!==c&&(u["x-region"]=c,d.searchParams.set("forceFunctionRegion",c)),l&&(r&&!Object.prototype.hasOwnProperty.call(r,"Content-Type")||!r)&&("undefined"!==typeof Blob&&l instanceof Blob||l instanceof ArrayBuffer?(u["Content-Type"]="application/octet-stream",f=l):"string"===typeof l?(u["Content-Type"]="text/plain",f=l):"undefined"!==typeof FormData&&l instanceof FormData?f=l:(u["Content-Type"]="application/json",f=JSON.stringify(l)));const h=yield this.fetch(d.toString(),{method:s||"POST",headers:Object.assign(Object.assign(Object.assign({},u),this.headers),r),body:f}).catch((e=>{throw new a(e)})),p=h.headers.get("x-relay-error");if(p&&"true"===p)throw new o(h);if(!h.ok)throw new i(h);let m,g=(null!==(n=h.headers.get("Content-Type"))&&void 0!==n?n:"text/plain").split(";")[0].trim();return m="application/json"===g?yield h.json():"application/octet-stream"===g?yield h.blob():"text/event-stream"===g?h:"multipart/form-data"===g?yield h.formData():yield h.text(),{data:m,error:null,response:h}}catch(r){return{data:null,error:r,response:r instanceof i||r instanceof o?r.context:void 0}}}))}}var c=n(7980);const{PostgrestClient:d,PostgrestQueryBuilder:f,PostgrestFilterBuilder:h,PostgrestTransformBuilder:p,PostgrestBuilder:m,PostgrestError:g}=c;const v=function(){if("undefined"!==typeof WebSocket)return WebSocket;if("undefined"!==typeof n.g.WebSocket)return n.g.WebSocket;if("undefined"!==typeof window.WebSocket)return window.WebSocket;if("undefined"!==typeof self.WebSocket)return self.WebSocket;throw new Error("`WebSocket` is not supported in this environment")}();const y="realtime-js/".concat("2.11.15");var b,w,_,S,x,k;!function(e){e[e.connecting=0]="connecting",e[e.open=1]="open",e[e.closing=2]="closing",e[e.closed=3]="closed"}(b||(b={})),function(e){e.closed="closed",e.errored="errored",e.joined="joined",e.joining="joining",e.leaving="leaving"}(w||(w={})),function(e){e.close="phx_close",e.error="phx_error",e.join="phx_join",e.reply="phx_reply",e.leave="phx_leave",e.access_token="access_token"}(_||(_={})),function(e){e.websocket="websocket"}(S||(S={})),function(e){e.Connecting="connecting",e.Open="open",e.Closing="closing",e.Closed="closed"}(x||(x={}));class A{constructor(){this.HEADER_LENGTH=1}decode(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):t("string"===typeof e?JSON.parse(e):{})}_binaryDecode(e){const t=new DataView(e),n=new TextDecoder;return this._decodeBroadcast(e,t,n)}_decodeBroadcast(e,t,n){const r=t.getUint8(1),a=t.getUint8(2);let o=this.HEADER_LENGTH+2;const i=n.decode(e.slice(o,o+r));o+=r;const s=n.decode(e.slice(o,o+a));o+=a;return{ref:null,topic:i,event:s,payload:JSON.parse(n.decode(e.slice(o,e.byteLength)))}}}class E{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=t}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout((()=>{this.tries=this.tries+1,this.callback()}),this.timerCalc(this.tries+1))}}!function(e){e.abstime="abstime",e.bool="bool",e.date="date",e.daterange="daterange",e.float4="float4",e.float8="float8",e.int2="int2",e.int4="int4",e.int4range="int4range",e.int8="int8",e.int8range="int8range",e.json="json",e.jsonb="jsonb",e.money="money",e.numeric="numeric",e.oid="oid",e.reltime="reltime",e.text="text",e.time="time",e.timestamp="timestamp",e.timestamptz="timestamptz",e.timetz="timetz",e.tsrange="tsrange",e.tstzrange="tstzrange"}(k||(k={}));const C=function(e,t){var n;const r=null!==(n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).skipTypes)&&void 0!==n?n:[];return Object.keys(t).reduce(((n,a)=>(n[a]=T(a,e,t,r),n)),{})},T=(e,t,n,r)=>{const a=t.find((t=>t.name===e)),o=null===a||void 0===a?void 0:a.type,i=n[e];return o&&!r.includes(o)?P(o,i):j(i)},P=(e,t)=>{if("_"===e.charAt(0)){const n=e.slice(1,e.length);return L(t,n)}switch(e){case k.bool:return O(t);case k.float4:case k.float8:case k.int2:case k.int4:case k.int8:case k.numeric:case k.oid:return N(t);case k.json:case k.jsonb:return R(t);case k.timestamp:return M(t);case k.abstime:case k.date:case k.daterange:case k.int4range:case k.int8range:case k.money:case k.reltime:case k.text:case k.time:case k.timestamptz:case k.timetz:case k.tsrange:case k.tstzrange:default:return j(t)}},j=e=>e,O=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},N=e=>{if("string"===typeof e){const t=parseFloat(e);if(!Number.isNaN(t))return t}return e},R=e=>{if("string"===typeof e)try{return JSON.parse(e)}catch(t){return console.log("JSON parse error: ".concat(t)),e}return e},L=(e,t)=>{if("string"!==typeof e)return e;const n=e.length-1,r=e[n];if("{"===e[0]&&"}"===r){let r;const o=e.slice(1,n);try{r=JSON.parse("["+o+"]")}catch(a){r=o?o.split(","):[]}return r.map((e=>P(t,e)))}return e},M=e=>"string"===typeof e?e.replace(" ","T"):e,I=e=>{let t=e;return t=t.replace(/^ws/i,"http"),t=t.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),t.replace(/\/+$/,"")};class D{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e4;this.channel=e,this.event=t,this.payload=n,this.timeout=r,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,t){var n;return this._hasReceived(e)&&t(null===(n=this.receivedResp)||void 0===n?void 0:n.response),this.recHooks.push({status:e,callback:t}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);this.channel._on(this.refEvent,{},(e=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=e,this._matchReceive(e)})),this.timeoutTimer=setTimeout((()=>{this.trigger("timeout",{})}),this.timeout)}trigger(e,t){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:t})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive(e){let{status:t,response:n}=e;this.recHooks.filter((e=>e.status===t)).forEach((e=>e.callback(n)))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var $,F,U,B;!function(e){e.SYNC="sync",e.JOIN="join",e.LEAVE="leave"}($||($={}));class z{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const n=(null===t||void 0===t?void 0:t.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(n.state,{},(e=>{const{onJoin:t,onLeave:n,onSync:r}=this.caller;this.joinRef=this.channel._joinRef(),this.state=z.syncState(this.state,e,t,n),this.pendingDiffs.forEach((e=>{this.state=z.syncDiff(this.state,e,t,n)})),this.pendingDiffs=[],r()})),this.channel._on(n.diff,{},(e=>{const{onJoin:t,onLeave:n,onSync:r}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(e):(this.state=z.syncDiff(this.state,e,t,n),r())})),this.onJoin(((e,t,n)=>{this.channel._trigger("presence",{event:"join",key:e,currentPresences:t,newPresences:n})})),this.onLeave(((e,t,n)=>{this.channel._trigger("presence",{event:"leave",key:e,currentPresences:t,leftPresences:n})})),this.onSync((()=>{this.channel._trigger("presence",{event:"sync"})}))}static syncState(e,t,n,r){const a=this.cloneDeep(e),o=this.transformState(t),i={},s={};return this.map(a,((e,t)=>{o[e]||(s[e]=t)})),this.map(o,((e,t)=>{const n=a[e];if(n){const r=t.map((e=>e.presence_ref)),a=n.map((e=>e.presence_ref)),o=t.filter((e=>a.indexOf(e.presence_ref)<0)),l=n.filter((e=>r.indexOf(e.presence_ref)<0));o.length>0&&(i[e]=o),l.length>0&&(s[e]=l)}else i[e]=t})),this.syncDiff(a,{joins:i,leaves:s},n,r)}static syncDiff(e,t,n,r){const{joins:a,leaves:o}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return n||(n=()=>{}),r||(r=()=>{}),this.map(a,((t,r)=>{var a;const o=null!==(a=e[t])&&void 0!==a?a:[];if(e[t]=this.cloneDeep(r),o.length>0){const n=e[t].map((e=>e.presence_ref)),r=o.filter((e=>n.indexOf(e.presence_ref)<0));e[t].unshift(...r)}n(t,o,r)})),this.map(o,((t,n)=>{let a=e[t];if(!a)return;const o=n.map((e=>e.presence_ref));a=a.filter((e=>o.indexOf(e.presence_ref)<0)),e[t]=a,r(t,a,n),0===a.length&&delete e[t]})),e}static map(e,t){return Object.getOwnPropertyNames(e).map((n=>t(n,e[n])))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce(((t,n)=>{const r=e[n];return t[n]="metas"in r?r.metas.map((e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e))):r,t}),{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}!function(e){e.ALL="*",e.INSERT="INSERT",e.UPDATE="UPDATE",e.DELETE="DELETE"}(F||(F={})),function(e){e.BROADCAST="broadcast",e.PRESENCE="presence",e.POSTGRES_CHANGES="postgres_changes",e.SYSTEM="system"}(U||(U={})),function(e){e.SUBSCRIBED="SUBSCRIBED",e.TIMED_OUT="TIMED_OUT",e.CLOSED="CLOSED",e.CHANNEL_ERROR="CHANNEL_ERROR"}(B||(B={}));class H{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{config:{}},n=arguments.length>2?arguments[2]:void 0;this.topic=e,this.params=t,this.socket=n,this.bindings={},this.state=w.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""},private:!1},t.config),this.timeout=this.socket.timeout,this.joinPush=new D(this,_.join,this.params,this.timeout),this.rejoinTimer=new E((()=>this._rejoinUntilConnected()),this.socket.reconnectAfterMs),this.joinPush.receive("ok",(()=>{this.state=w.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach((e=>e.send())),this.pushBuffer=[]})),this._onClose((()=>{this.rejoinTimer.reset(),this.socket.log("channel","close ".concat(this.topic," ").concat(this._joinRef())),this.state=w.closed,this.socket._remove(this)})),this._onError((e=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel","error ".concat(this.topic),e),this.state=w.errored,this.rejoinTimer.scheduleTimeout())})),this.joinPush.receive("timeout",(()=>{this._isJoining()&&(this.socket.log("channel","timeout ".concat(this.topic),this.joinPush.timeout),this.state=w.errored,this.rejoinTimer.scheduleTimeout())})),this._on(_.reply,{},((e,t)=>{this._trigger(this._replyEventName(t),e)})),this.presence=new z(this),this.broadcastEndpointURL=I(this.socket.endPoint)+"/api/broadcast",this.private=this.params.config.private||!1}subscribe(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.timeout;var n,r;if(this.socket.isConnected()||this.socket.connect(),this.state==w.closed){const{config:{broadcast:a,presence:o,private:i}}=this.params;this._onError((t=>null===e||void 0===e?void 0:e(B.CHANNEL_ERROR,t))),this._onClose((()=>null===e||void 0===e?void 0:e(B.CLOSED)));const s={},l={broadcast:a,presence:o,postgres_changes:null!==(r=null===(n=this.bindings.postgres_changes)||void 0===n?void 0:n.map((e=>e.filter)))&&void 0!==r?r:[],private:i};this.socket.accessTokenValue&&(s.access_token=this.socket.accessTokenValue),this.updateJoinPayload(Object.assign({config:l},s)),this.joinedOnce=!0,this._rejoin(t),this.joinPush.receive("ok",(async t=>{let{postgres_changes:n}=t;var r;if(this.socket.setAuth(),void 0!==n){const t=this.bindings.postgres_changes,a=null!==(r=null===t||void 0===t?void 0:t.length)&&void 0!==r?r:0,o=[];for(let r=0;r{this.state=w.errored,null===e||void 0===e||e(B.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(t).join(", ")||"error")))})).receive("timeout",(()=>{null===e||void 0===e||e(B.TIMED_OUT)}))}return this}presenceState(){return this.presence.state}async track(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return await this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)}async untrack(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return await this.send({type:"presence",event:"untrack"},e)}on(e,t,n){return this._on(e,t,n)}async send(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n,r;if(this._canPush()||"broadcast"!==e.type)return new Promise((n=>{var r,a,o;const i=this._push(e.type,e,t.timeout||this.timeout);"broadcast"!==e.type||(null===(o=null===(a=null===(r=this.params)||void 0===r?void 0:r.config)||void 0===a?void 0:a.broadcast)||void 0===o?void 0:o.ack)||n("ok"),i.receive("ok",(()=>n("ok"))),i.receive("error",(()=>n("error"))),i.receive("timeout",(()=>n("timed out")))}));{const{event:o,payload:i}=e,s={method:"POST",headers:{Authorization:this.socket.accessTokenValue?"Bearer ".concat(this.socket.accessTokenValue):"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:o,payload:i,private:this.private}]})};try{const e=await this._fetchWithTimeout(this.broadcastEndpointURL,s,null!==(n=t.timeout)&&void 0!==n?n:this.timeout);return await(null===(r=e.body)||void 0===r?void 0:r.cancel()),e.ok?"ok":"error"}catch(a){return"AbortError"===a.name?"timed out":"error"}}}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.timeout;this.state=w.leaving;const t=()=>{this.socket.log("channel","leave ".concat(this.topic)),this._trigger(_.close,"leave",this._joinRef())};this.joinPush.destroy();let n=null;return new Promise((r=>{n=new D(this,_.leave,{},e),n.receive("ok",(()=>{t(),r("ok")})).receive("timeout",(()=>{t(),r("timed out")})).receive("error",(()=>{r("error")})),n.send(),this._canPush()||n.trigger("ok",{})})).finally((()=>{null===n||void 0===n||n.destroy()}))}teardown(){this.pushBuffer.forEach((e=>e.destroy())),this.rejoinTimer&&clearTimeout(this.rejoinTimer.timer),this.joinPush.destroy()}async _fetchWithTimeout(e,t,n){const r=new AbortController,a=setTimeout((()=>r.abort()),n),o=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:r.signal}));return clearTimeout(a),o}_push(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.timeout;if(!this.joinedOnce)throw"tried to push '".concat(e,"' to '").concat(this.topic,"' before joining. Use channel.subscribe() before pushing events");let r=new D(this,e,t,n);return this._canPush()?r.send():(r.startTimeout(),this.pushBuffer.push(r)),r}_onMessage(e,t,n){return t}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,t,n){var r,a;const o=e.toLocaleLowerCase(),{close:i,error:s,leave:l,join:u}=_;if(n&&[i,s,l,u].indexOf(o)>=0&&n!==this._joinRef())return;let c=this._onMessage(o,t,n);if(t&&!c)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(o)?null===(r=this.bindings.postgres_changes)||void 0===r||r.filter((e=>{var t,n,r;return"*"===(null===(t=e.filter)||void 0===t?void 0:t.event)||(null===(r=null===(n=e.filter)||void 0===n?void 0:n.event)||void 0===r?void 0:r.toLocaleLowerCase())===o})).map((e=>e.callback(c,n))):null===(a=this.bindings[o])||void 0===a||a.filter((e=>{var n,r,a,i,s,l;if(["broadcast","presence","postgres_changes"].includes(o)){if("id"in e){const o=e.id,i=null===(n=e.filter)||void 0===n?void 0:n.event;return o&&(null===(r=t.ids)||void 0===r?void 0:r.includes(o))&&("*"===i||(null===i||void 0===i?void 0:i.toLocaleLowerCase())===(null===(a=t.data)||void 0===a?void 0:a.type.toLocaleLowerCase()))}{const n=null===(s=null===(i=null===e||void 0===e?void 0:e.filter)||void 0===i?void 0:i.event)||void 0===s?void 0:s.toLocaleLowerCase();return"*"===n||n===(null===(l=null===t||void 0===t?void 0:t.event)||void 0===l?void 0:l.toLocaleLowerCase())}}return e.type.toLocaleLowerCase()===o})).map((e=>{if("object"===typeof c&&"ids"in c){const e=c.data,{schema:t,table:n,commit_timestamp:r,type:a,errors:o}=e,i={schema:t,table:n,commit_timestamp:r,eventType:a,new:{},old:{},errors:o};c=Object.assign(Object.assign({},i),this._getPayloadRecords(e))}e.callback(c,n)}))}_isClosed(){return this.state===w.closed}_isJoined(){return this.state===w.joined}_isJoining(){return this.state===w.joining}_isLeaving(){return this.state===w.leaving}_replyEventName(e){return"chan_reply_".concat(e)}_on(e,t,n){const r=e.toLocaleLowerCase(),a={type:r,filter:t,callback:n};return this.bindings[r]?this.bindings[r].push(a):this.bindings[r]=[a],this}_off(e,t){const n=e.toLocaleLowerCase();return this.bindings[n]=this.bindings[n].filter((e=>{var r;return!((null===(r=e.type)||void 0===r?void 0:r.toLocaleLowerCase())===n&&H.isEqual(e.filter,t))})),this}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(_.close,{},e)}_onError(e){this._on(_.error,{},(t=>e(t)))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.timeout;this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=w.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const t={new:{},old:{}};return"INSERT"!==e.type&&"UPDATE"!==e.type||(t.new=C(e.columns,e.record)),"UPDATE"!==e.type&&"DELETE"!==e.type||(t.old=C(e.columns,e.old_record)),t}}const Z=()=>{};class W{constructor(e,t){var r;this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=1e4,this.heartbeatIntervalMs=25e3,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=Z,this.ref=0,this.logger=Z,this.conn=null,this.sendBuffer=[],this.serializer=new A,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._resolveFetch=e=>{let t;return t=e||("undefined"===typeof fetch?function(){for(var e=arguments.length,t=new Array(e),r=0;r{let{default:n}=e;return n(...t)}))}:fetch),function(){return t(...arguments)}},this.endPoint="".concat(e,"/").concat(S.websocket),this.httpEndpoint=I(e),(null===t||void 0===t?void 0:t.transport)?this.transport=t.transport:this.transport=null,(null===t||void 0===t?void 0:t.params)&&(this.params=t.params),(null===t||void 0===t?void 0:t.timeout)&&(this.timeout=t.timeout),(null===t||void 0===t?void 0:t.logger)&&(this.logger=t.logger),((null===t||void 0===t?void 0:t.logLevel)||(null===t||void 0===t?void 0:t.log_level))&&(this.logLevel=t.logLevel||t.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),(null===t||void 0===t?void 0:t.heartbeatIntervalMs)&&(this.heartbeatIntervalMs=t.heartbeatIntervalMs);const a=null===(r=null===t||void 0===t?void 0:t.params)||void 0===r?void 0:r.apikey;if(a&&(this.accessTokenValue=a,this.apiKey=a),this.reconnectAfterMs=(null===t||void 0===t?void 0:t.reconnectAfterMs)?t.reconnectAfterMs:e=>[1e3,2e3,5e3,1e4][e-1]||1e4,this.encode=(null===t||void 0===t?void 0:t.encode)?t.encode:(e,t)=>t(JSON.stringify(e)),this.decode=(null===t||void 0===t?void 0:t.decode)?t.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new E((async()=>{this.disconnect(),this.connect()}),this.reconnectAfterMs),this.fetch=this._resolveFetch(null===t||void 0===t?void 0:t.fetch),null===t||void 0===t?void 0:t.worker){if("undefined"!==typeof window&&!window.Worker)throw new Error("Web Worker is not supported");this.worker=(null===t||void 0===t?void 0:t.worker)||!1,this.workerUrl=null===t||void 0===t?void 0:t.workerUrl}this.accessToken=(null===t||void 0===t?void 0:t.accessToken)||null}connect(){if(!this.conn){if(this.transport||(this.transport=v),!this.transport)throw new Error("No transport provided");this.conn=new this.transport(this.endpointURL()),this.setupConnection()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:"1.0.0"}))}disconnect(e,t){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,null!==t&&void 0!==t?t:""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset(),this.channels.forEach((e=>e.teardown())))}getChannels(){return this.channels}async removeChannel(e){const t=await e.unsubscribe();return 0===this.channels.length&&this.disconnect(),t}async removeAllChannels(){const e=await Promise.all(this.channels.map((e=>e.unsubscribe())));return this.channels=[],this.disconnect(),e}log(e,t,n){this.logger(e,t,n)}connectionState(){switch(this.conn&&this.conn.readyState){case b.connecting:return x.Connecting;case b.open:return x.Open;case b.closing:return x.Closing;default:return x.Closed}}isConnected(){return this.connectionState()===x.Open}channel(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{config:{}};const n="realtime:".concat(e),r=this.getChannels().find((e=>e.topic===n));if(r)return r;{const n=new H("realtime:".concat(e),t,this);return this.channels.push(n),n}}push(e){const{topic:t,event:n,payload:r,ref:a}=e,o=()=>{this.encode(e,(e=>{var t;null===(t=this.conn)||void 0===t||t.send(e)}))};this.log("push","".concat(t," ").concat(n," (").concat(a,")"),r),this.isConnected()?o():this.sendBuffer.push(o)}async setAuth(){let e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||this.accessToken&&await this.accessToken()||this.accessTokenValue;this.accessTokenValue!=e&&(this.accessTokenValue=e,this.channels.forEach((t=>{const n={access_token:e,version:y};e&&t.updateJoinPayload(n),t.joinedOnce&&t._isJoined()&&t._push(_.access_token,{access_token:e})})))}async sendHeartbeat(){var e;if(this.isConnected()){if(this.pendingHeartbeatRef)return this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.heartbeatCallback("timeout"),void(null===(e=this.conn)||void 0===e||e.close(1e3,"hearbeat timeout"));this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatCallback("sent"),await this.setAuth()}else this.heartbeatCallback("disconnected")}onHeartbeat(e){this.heartbeatCallback=e}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach((e=>e())),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let t=this.channels.find((t=>t.topic===e&&(t._isJoined()||t._isJoining())));t&&(this.log("transport",'leaving duplicate topic "'.concat(e,'"')),t.unsubscribe())}_remove(e){this.channels=this.channels.filter((t=>t.topic!==e.topic))}setupConnection(){this.conn&&(this.conn.binaryType="arraybuffer",this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e))}_onConnMessage(e){this.decode(e.data,(e=>{let{topic:t,event:n,payload:r,ref:a}=e;"phoenix"===t&&"phx_reply"===n&&this.heartbeatCallback("ok"==e.payload.status?"ok":"error"),a&&a===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null),this.log("receive","".concat(r.status||""," ").concat(t," ").concat(n," ").concat(a&&"("+a+")"||""),r),Array.from(this.channels).filter((e=>e._isMember(t))).forEach((e=>e._trigger(n,r,a))),this.stateChangeCallbacks.message.forEach((t=>t(e)))}))}_onConnOpen(){this.log("transport","connected to ".concat(this.endpointURL())),this.flushSendBuffer(),this.reconnectTimer.reset(),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this.stateChangeCallbacks.open.forEach((e=>e()))}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval((()=>this.sendHeartbeat()),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker","starting worker for from ".concat(this.workerUrl)):this.log("worker","starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=e=>{this.log("worker","worker error",e.message),this.workerRef.terminate()},this.workerRef.onmessage=e=>{"keepAlive"===e.data.event&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_onConnClose(e){this.log("transport","close",e),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach((t=>t(e)))}_onConnError(e){this.log("transport","".concat(e)),this._triggerChanError(),this.stateChangeCallbacks.error.forEach((t=>t(e)))}_triggerChanError(){this.channels.forEach((e=>e._trigger(_.error)))}_appendParams(e,t){if(0===Object.keys(t).length)return e;const n=e.match(/\?/)?"&":"?",r=new URLSearchParams(t);return"".concat(e).concat(n).concat(r)}_workerObjectUrl(e){let t;if(e)t=e;else{const e=new Blob(['\n addEventListener("message", (e) => {\n if (e.data.event === "start") {\n setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);\n }\n });'],{type:"application/javascript"});t=URL.createObjectURL(e)}return t}}class K extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function G(e){return"object"===typeof e&&null!==e&&"__isStorageError"in e}class q extends K{constructor(e,t){super(e),this.name="StorageApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class V extends K{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}}var Y=function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function i(e){try{l(r.next(e))}catch(t){o(t)}}function s(e){try{l(r.throw(e))}catch(t){o(t)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}l((r=r.apply(e,t||[])).next())}))};const Q=e=>{let t;return t=e||("undefined"===typeof fetch?function(){for(var e=arguments.length,t=new Array(e),r=0;r{let{default:n}=e;return n(...t)}))}:fetch),function(){return t(...arguments)}},J=e=>{if(Array.isArray(e))return e.map((e=>J(e)));if("function"===typeof e||e!==Object(e))return e;const t={};return Object.entries(e).forEach((e=>{let[n,r]=e;const a=n.replace(/([-_][a-z])/gi,(e=>e.toUpperCase().replace(/[-_]/g,"")));t[a]=J(r)})),t};var X=function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function i(e){try{l(r.next(e))}catch(t){o(t)}}function s(e){try{l(r.throw(e))}catch(t){o(t)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}l((r=r.apply(e,t||[])).next())}))};const ee=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),te=(e,t,r)=>X(void 0,void 0,void 0,(function*(){const a=yield Y(void 0,void 0,void 0,(function*(){return"undefined"===typeof Response?(yield Promise.resolve().then(n.bind(n,4630))).Response:Response}));e instanceof a&&!(null===r||void 0===r?void 0:r.noResolveJson)?e.json().then((n=>{t(new q(ee(n),e.status||500))})).catch((e=>{t(new V(ee(e),e))})):t(new V(ee(e),e))}));function ne(e,t,n,r,a,o){return X(this,void 0,void 0,(function*(){return new Promise(((i,s)=>{e(n,((e,t,n,r)=>{const a={method:e,headers:(null===t||void 0===t?void 0:t.headers)||{}};return"GET"===e?a:(a.headers=Object.assign({"Content-Type":"application/json"},null===t||void 0===t?void 0:t.headers),r&&(a.body=JSON.stringify(r)),Object.assign(Object.assign({},a),n))})(t,r,a,o)).then((e=>{if(!e.ok)throw e;return(null===r||void 0===r?void 0:r.noResolveJson)?e:e.json()})).then((e=>i(e))).catch((e=>te(e,s,r)))}))}))}function re(e,t,n,r){return X(this,void 0,void 0,(function*(){return ne(e,"GET",t,n,r)}))}function ae(e,t,n,r,a){return X(this,void 0,void 0,(function*(){return ne(e,"POST",t,r,a,n)}))}function oe(e,t,n,r,a){return X(this,void 0,void 0,(function*(){return ne(e,"DELETE",t,r,a,n)}))}var ie=function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function i(e){try{l(r.next(e))}catch(t){o(t)}}function s(e){try{l(r.throw(e))}catch(t){o(t)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}l((r=r.apply(e,t||[])).next())}))};const se={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},le={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class ue{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0;this.url=e,this.headers=t,this.bucketId=n,this.fetch=Q(r)}uploadOrUpdate(e,t,n,r){return ie(this,void 0,void 0,(function*(){try{let a;const o=Object.assign(Object.assign({},le),r);let i=Object.assign(Object.assign({},this.headers),"POST"===e&&{"x-upsert":String(o.upsert)});const s=o.metadata;"undefined"!==typeof Blob&&n instanceof Blob?(a=new FormData,a.append("cacheControl",o.cacheControl),s&&a.append("metadata",this.encodeMetadata(s)),a.append("",n)):"undefined"!==typeof FormData&&n instanceof FormData?(a=n,a.append("cacheControl",o.cacheControl),s&&a.append("metadata",this.encodeMetadata(s))):(a=n,i["cache-control"]="max-age=".concat(o.cacheControl),i["content-type"]=o.contentType,s&&(i["x-metadata"]=this.toBase64(this.encodeMetadata(s)))),(null===r||void 0===r?void 0:r.headers)&&(i=Object.assign(Object.assign({},i),r.headers));const l=this._removeEmptyFolders(t),u=this._getFinalPath(l),c=yield this.fetch("".concat(this.url,"/object/").concat(u),Object.assign({method:e,body:a,headers:i},(null===o||void 0===o?void 0:o.duplex)?{duplex:o.duplex}:{})),d=yield c.json();if(c.ok)return{data:{path:l,id:d.Id,fullPath:d.Key},error:null};return{data:null,error:d}}catch(a){if(G(a))return{data:null,error:a};throw a}}))}upload(e,t,n){return ie(this,void 0,void 0,(function*(){return this.uploadOrUpdate("POST",e,t,n)}))}uploadToSignedUrl(e,t,n,r){return ie(this,void 0,void 0,(function*(){const a=this._removeEmptyFolders(e),o=this._getFinalPath(a),i=new URL(this.url+"/object/upload/sign/".concat(o));i.searchParams.set("token",t);try{let e;const t=Object.assign({upsert:le.upsert},r),o=Object.assign(Object.assign({},this.headers),{"x-upsert":String(t.upsert)});"undefined"!==typeof Blob&&n instanceof Blob?(e=new FormData,e.append("cacheControl",t.cacheControl),e.append("",n)):"undefined"!==typeof FormData&&n instanceof FormData?(e=n,e.append("cacheControl",t.cacheControl)):(e=n,o["cache-control"]="max-age=".concat(t.cacheControl),o["content-type"]=t.contentType);const s=yield this.fetch(i.toString(),{method:"PUT",body:e,headers:o}),l=yield s.json();if(s.ok)return{data:{path:a,fullPath:l.Key},error:null};return{data:null,error:l}}catch(s){if(G(s))return{data:null,error:s};throw s}}))}createSignedUploadUrl(e,t){return ie(this,void 0,void 0,(function*(){try{let n=this._getFinalPath(e);const r=Object.assign({},this.headers);(null===t||void 0===t?void 0:t.upsert)&&(r["x-upsert"]="true");const a=yield ae(this.fetch,"".concat(this.url,"/object/upload/sign/").concat(n),{},{headers:r}),o=new URL(this.url+a.url),i=o.searchParams.get("token");if(!i)throw new K("No token returned by API");return{data:{signedUrl:o.toString(),path:e,token:i},error:null}}catch(n){if(G(n))return{data:null,error:n};throw n}}))}update(e,t,n){return ie(this,void 0,void 0,(function*(){return this.uploadOrUpdate("PUT",e,t,n)}))}move(e,t,n){return ie(this,void 0,void 0,(function*(){try{return{data:yield ae(this.fetch,"".concat(this.url,"/object/move"),{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null===n||void 0===n?void 0:n.destinationBucket},{headers:this.headers}),error:null}}catch(r){if(G(r))return{data:null,error:r};throw r}}))}copy(e,t,n){return ie(this,void 0,void 0,(function*(){try{return{data:{path:(yield ae(this.fetch,"".concat(this.url,"/object/copy"),{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null===n||void 0===n?void 0:n.destinationBucket},{headers:this.headers})).Key},error:null}}catch(r){if(G(r))return{data:null,error:r};throw r}}))}createSignedUrl(e,t,n){return ie(this,void 0,void 0,(function*(){try{let r=this._getFinalPath(e),a=yield ae(this.fetch,"".concat(this.url,"/object/sign/").concat(r),Object.assign({expiresIn:t},(null===n||void 0===n?void 0:n.transform)?{transform:n.transform}:{}),{headers:this.headers});const o=(null===n||void 0===n?void 0:n.download)?"&download=".concat(!0===n.download?"":n.download):"";return a={signedUrl:encodeURI("".concat(this.url).concat(a.signedURL).concat(o))},{data:a,error:null}}catch(r){if(G(r))return{data:null,error:r};throw r}}))}createSignedUrls(e,t,n){return ie(this,void 0,void 0,(function*(){try{const r=yield ae(this.fetch,"".concat(this.url,"/object/sign/").concat(this.bucketId),{expiresIn:t,paths:e},{headers:this.headers}),a=(null===n||void 0===n?void 0:n.download)?"&download=".concat(!0===n.download?"":n.download):"";return{data:r.map((e=>Object.assign(Object.assign({},e),{signedUrl:e.signedURL?encodeURI("".concat(this.url).concat(e.signedURL).concat(a)):null}))),error:null}}catch(r){if(G(r))return{data:null,error:r};throw r}}))}download(e,t){return ie(this,void 0,void 0,(function*(){const n="undefined"!==typeof(null===t||void 0===t?void 0:t.transform)?"render/image/authenticated":"object",r=this.transformOptsToQueryString((null===t||void 0===t?void 0:t.transform)||{}),a=r?"?".concat(r):"";try{const t=this._getFinalPath(e),r=yield re(this.fetch,"".concat(this.url,"/").concat(n,"/").concat(t).concat(a),{headers:this.headers,noResolveJson:!0});return{data:yield r.blob(),error:null}}catch(o){if(G(o))return{data:null,error:o};throw o}}))}info(e){return ie(this,void 0,void 0,(function*(){const t=this._getFinalPath(e);try{const e=yield re(this.fetch,"".concat(this.url,"/object/info/").concat(t),{headers:this.headers});return{data:J(e),error:null}}catch(n){if(G(n))return{data:null,error:n};throw n}}))}exists(e){return ie(this,void 0,void 0,(function*(){const t=this._getFinalPath(e);try{return yield function(e,t,n,r){return X(this,void 0,void 0,(function*(){return ne(e,"HEAD",t,Object.assign(Object.assign({},n),{noResolveJson:!0}),r)}))}(this.fetch,"".concat(this.url,"/object/").concat(t),{headers:this.headers}),{data:!0,error:null}}catch(n){if(G(n)&&n instanceof V){const e=n.originalError;if([400,404].includes(null===e||void 0===e?void 0:e.status))return{data:!1,error:n}}throw n}}))}getPublicUrl(e,t){const n=this._getFinalPath(e),r=[],a=(null===t||void 0===t?void 0:t.download)?"download=".concat(!0===t.download?"":t.download):"";""!==a&&r.push(a);const o="undefined"!==typeof(null===t||void 0===t?void 0:t.transform)?"render/image":"object",i=this.transformOptsToQueryString((null===t||void 0===t?void 0:t.transform)||{});""!==i&&r.push(i);let s=r.join("&");return""!==s&&(s="?".concat(s)),{data:{publicUrl:encodeURI("".concat(this.url,"/").concat(o,"/public/").concat(n).concat(s))}}}remove(e){return ie(this,void 0,void 0,(function*(){try{return{data:yield oe(this.fetch,"".concat(this.url,"/object/").concat(this.bucketId),{prefixes:e},{headers:this.headers}),error:null}}catch(t){if(G(t))return{data:null,error:t};throw t}}))}list(e,t,n){return ie(this,void 0,void 0,(function*(){try{const r=Object.assign(Object.assign(Object.assign({},se),t),{prefix:e||""});return{data:yield ae(this.fetch,"".concat(this.url,"/object/list/").concat(this.bucketId),r,{headers:this.headers},n),error:null}}catch(r){if(G(r))return{data:null,error:r};throw r}}))}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return"undefined"!==typeof Buffer?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return"".concat(this.bucketId,"/").concat(e)}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){const t=[];return e.width&&t.push("width=".concat(e.width)),e.height&&t.push("height=".concat(e.height)),e.resize&&t.push("resize=".concat(e.resize)),e.format&&t.push("format=".concat(e.format)),e.quality&&t.push("quality=".concat(e.quality)),t.join("&")}}const ce={"X-Client-Info":"storage-js/".concat("2.7.1")};var de=function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function i(e){try{l(r.next(e))}catch(t){o(t)}}function s(e){try{l(r.throw(e))}catch(t){o(t)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}l((r=r.apply(e,t||[])).next())}))};class fe{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;this.url=e,this.headers=Object.assign(Object.assign({},ce),t),this.fetch=Q(n)}listBuckets(){return de(this,void 0,void 0,(function*(){try{return{data:yield re(this.fetch,"".concat(this.url,"/bucket"),{headers:this.headers}),error:null}}catch(e){if(G(e))return{data:null,error:e};throw e}}))}getBucket(e){return de(this,void 0,void 0,(function*(){try{return{data:yield re(this.fetch,"".concat(this.url,"/bucket/").concat(e),{headers:this.headers}),error:null}}catch(t){if(G(t))return{data:null,error:t};throw t}}))}createBucket(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{public:!1};return de(this,void 0,void 0,(function*(){try{return{data:yield ae(this.fetch,"".concat(this.url,"/bucket"),{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(G(n))return{data:null,error:n};throw n}}))}updateBucket(e,t){return de(this,void 0,void 0,(function*(){try{const n=yield function(e,t,n,r,a){return X(this,void 0,void 0,(function*(){return ne(e,"PUT",t,r,a,n)}))}(this.fetch,"".concat(this.url,"/bucket/").concat(e),{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers});return{data:n,error:null}}catch(n){if(G(n))return{data:null,error:n};throw n}}))}emptyBucket(e){return de(this,void 0,void 0,(function*(){try{return{data:yield ae(this.fetch,"".concat(this.url,"/bucket/").concat(e,"/empty"),{},{headers:this.headers}),error:null}}catch(t){if(G(t))return{data:null,error:t};throw t}}))}deleteBucket(e){return de(this,void 0,void 0,(function*(){try{return{data:yield oe(this.fetch,"".concat(this.url,"/bucket/").concat(e),{},{headers:this.headers}),error:null}}catch(t){if(G(t))return{data:null,error:t};throw t}}))}}class he extends fe{constructor(e){super(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},arguments.length>2?arguments[2]:void 0)}from(e){return new ue(this.url,this.headers,e,this.fetch)}}let pe="";pe="undefined"!==typeof Deno?"deno":"undefined"!==typeof document?"web":"undefined"!==typeof navigator&&"ReactNative"===navigator.product?"react-native":"node";const me={headers:{"X-Client-Info":"supabase-js-".concat(pe,"/").concat("2.52.1")}},ge={schema:"public"},ve={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},ye={};var be=n(4630),we=function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function i(e){try{l(r.next(e))}catch(t){o(t)}}function s(e){try{l(r.throw(e))}catch(t){o(t)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}l((r=r.apply(e,t||[])).next())}))};const _e=e=>{let t;return t=e||("undefined"===typeof fetch?be.default:fetch),function(){return t(...arguments)}},Se=(e,t,n)=>{const r=_e(n),a="undefined"===typeof Headers?be.Headers:Headers;return(n,o)=>we(void 0,void 0,void 0,(function*(){var i;const s=null!==(i=yield t())&&void 0!==i?i:e;let l=new a(null===o||void 0===o?void 0:o.headers);return l.has("apikey")||l.set("apikey",e),l.has("Authorization")||l.set("Authorization","Bearer ".concat(s)),r(n,Object.assign(Object.assign({},o),{headers:l}))}))};var xe=function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function i(e){try{l(r.next(e))}catch(t){o(t)}}function s(e){try{l(r.throw(e))}catch(t){o(t)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}l((r=r.apply(e,t||[])).next())}))};const ke="2.71.1",Ae=3e4,Ee=9e4,Ce={"X-Client-Info":"gotrue-js/".concat(ke)},Te="X-Supabase-Api-Version",Pe={timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"},je=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i;class Oe extends Error{constructor(e,t,n){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t,this.code=n}}function Ne(e){return"object"===typeof e&&null!==e&&"__isAuthError"in e}class Re extends Oe{constructor(e,t,n){super(e,t,n),this.name="AuthApiError",this.status=t,this.code=n}}class Le extends Oe{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class Me extends Oe{constructor(e,t,n,r){super(e,n,r),this.name=t,this.status=n}}class Ie extends Me{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}class De extends Me{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class $e extends Me{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class Fe extends Me{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class Ue extends Me{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class Be extends Me{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}}function ze(e){return Ne(e)&&"AuthRetryableFetchError"===e.name}class He extends Me{constructor(e,t,n){super(e,"AuthWeakPasswordError",t,"weak_password"),this.reasons=n}}class Ze extends Me{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const We="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),Ke=" \t\n\r=".split(""),Ge=(()=>{const e=new Array(128);for(let t=0;t=6;){const e=t.queue>>t.queuedBits-6&63;n(We[e]),t.queuedBits-=6}else if(t.queuedBits>0)for(t.queue=t.queue<<6-t.queuedBits,t.queuedBits=6;t.queuedBits>=6;){const e=t.queue>>t.queuedBits-6&63;n(We[e]),t.queuedBits-=6}}function Ve(e,t,n){const r=Ge[e];if(!(r>-1)){if(-2===r)return;throw new Error('Invalid Base64-URL character "'.concat(String.fromCharCode(e),'"'))}for(t.queue=t.queue<<6|r,t.queuedBits+=6;t.queuedBits>=8;)n(t.queue>>t.queuedBits-8&255),t.queuedBits-=8}function Ye(e){const t=[],n=e=>{t.push(String.fromCodePoint(e))},r={utf8seq:0,codepoint:0},a={queue:0,queuedBits:0},o=e=>{!function(e,t,n){if(0===t.utf8seq){if(e<=127)return void n(e);for(let n=1;n<6;n+=1)if(0===(e>>7-n&1)){t.utf8seq=n;break}if(2===t.utf8seq)t.codepoint=31&e;else if(3===t.utf8seq)t.codepoint=15&e;else{if(4!==t.utf8seq)throw new Error("Invalid UTF-8 sequence");t.codepoint=7&e}t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw new Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|63&e,t.utf8seq-=1,0===t.utf8seq&&n(t.codepoint)}}(e,r,n)};for(let i=0;i>6),void t(128|63&e);if(e<=65535)return t(224|e>>12),t(128|e>>6&63),void t(128|63&e);if(e<=1114111)return t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),void t(128|63&e);throw new Error("Unrecognized Unicode codepoint: ".concat(e.toString(16)))}t(e)}function Je(e,t){for(let n=0;n55295&&r<=56319){const t=1024*(r-55296)&65535;r=65536+(e.charCodeAt(n+1)-56320&65535|t),n+=1}Qe(r,t)}}function Xe(e){const t=[],n={queue:0,queuedBits:0},r=e=>{t.push(e)};for(let a=0;a{t.push(e)};return e.forEach((e=>qe(e,n,r))),qe(null,n,r),t.join("")}const tt=()=>"undefined"!==typeof window&&"undefined"!==typeof document,nt={tested:!1,writable:!1},rt=()=>{if(!tt())return!1;try{if("object"!==typeof globalThis.localStorage)return!1}catch(t){return!1}if(nt.tested)return nt.writable;const e="lswt-".concat(Math.random()).concat(Math.random());try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),nt.tested=!0,nt.writable=!0}catch(t){nt.tested=!0,nt.writable=!1}return nt.writable};const at=e=>{let t;return t=e||("undefined"===typeof fetch?function(){for(var e=arguments.length,t=new Array(e),r=0;r{let{default:n}=e;return n(...t)}))}:fetch),function(){return t(...arguments)}},ot=async(e,t,n)=>{await e.setItem(t,JSON.stringify(n))},it=async(e,t)=>{const n=await e.getItem(t);if(!n)return null;try{return JSON.parse(n)}catch(r){return n}},st=async(e,t)=>{await e.removeItem(t)};class lt{constructor(){this.promise=new lt.promiseConstructor(((e,t)=>{this.resolve=e,this.reject=t}))}}function ut(e){const t=e.split(".");if(3!==t.length)throw new Ze("Invalid JWT structure");for(let n=0;nString.fromCharCode(e))).join("")}(e);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function ft(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const r=function(){const e=new Uint32Array(56);if("undefined"===typeof crypto){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=e.length;let n="";for(let r=0;r<56;r++)n+=e.charAt(Math.floor(Math.random()*t));return n}return crypto.getRandomValues(e),Array.from(e,ct).join("")}();let a=r;n&&(a+="/PASSWORD_RECOVERY"),await ot(e,"".concat(t,"-code-verifier"),a);const o=await dt(r);return[o,r===o?"plain":"s256"]}lt.promiseConstructor=Promise;const ht=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;const pt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function mt(e){if(!pt.test(e))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function gt(){return new Proxy({},{get:(e,t)=>{if("__isUserNotAvailableProxy"===t)return!0;if("symbol"===typeof t){const e=t.toString();if("Symbol(Symbol.toPrimitive)"===e||"Symbol(Symbol.toStringTag)"===e||"Symbol(util.inspect.custom)"===e)return}throw new Error('@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "'.concat(t,'" property of the session object is not supported. Please use getUser() instead.'))},set:(e,t)=>{throw new Error('@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "'.concat(t,'" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.'))},deleteProperty:(e,t)=>{throw new Error('@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "'.concat(t,'" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.'))}})}function vt(e){return JSON.parse(JSON.stringify(e))}var yt=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"===typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);ae.msg||e.message||e.error_description||e.error||JSON.stringify(e),wt=[502,503,504];async function _t(e){var t,n;if(!("object"===typeof(n=e)&&null!==n&&"status"in n&&"ok"in n&&"json"in n&&"function"===typeof n.json))throw new Be(bt(e),0);if(wt.includes(e.status))throw new Be(bt(e),e.status);let r,a;try{r=await e.json()}catch(i){throw new Le(bt(i),i)}const o=function(e){const t=e.headers.get(Te);if(!t)return null;if(!t.match(ht))return null;try{return new Date("".concat(t,"T00:00:00.0Z"))}catch(i){return null}}(e);if(o&&o.getTime()>=Pe.timestamp&&"object"===typeof r&&r&&"string"===typeof r.code?a=r.code:"object"===typeof r&&r&&"string"===typeof r.error_code&&(a=r.error_code),a){if("weak_password"===a)throw new He(bt(r),e.status,(null===(t=r.weak_password)||void 0===t?void 0:t.reasons)||[]);if("session_not_found"===a)throw new Ie}else if("object"===typeof r&&r&&"object"===typeof r.weak_password&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce(((e,t)=>e&&"string"===typeof t),!0))throw new He(bt(r),e.status,r.weak_password.reasons);throw new Re(bt(r),e.status||500,a)}async function St(e,t,n,r){var a;const o=Object.assign({},null===r||void 0===r?void 0:r.headers);o[Te]||(o[Te]=Pe.name),(null===r||void 0===r?void 0:r.jwt)&&(o.Authorization="Bearer ".concat(r.jwt));const i=null!==(a=null===r||void 0===r?void 0:r.query)&&void 0!==a?a:{};(null===r||void 0===r?void 0:r.redirectTo)&&(i.redirect_to=r.redirectTo);const s=Object.keys(i).length?"?"+new URLSearchParams(i).toString():"",l=await async function(e,t,n,r,a,o){const i=((e,t,n,r)=>{const a={method:e,headers:(null===t||void 0===t?void 0:t.headers)||{}};return"GET"===e?a:(a.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},null===t||void 0===t?void 0:t.headers),a.body=JSON.stringify(r),Object.assign(Object.assign({},a),n))})(t,r,a,o);let s;try{s=await e(n,Object.assign({},i))}catch(l){throw console.error(l),new Be(bt(l),0)}s.ok||await _t(s);if(null===r||void 0===r?void 0:r.noResolveJson)return s;try{return await s.json()}catch(l){await _t(l)}}(e,t,n+s,{headers:o,noResolveJson:null===r||void 0===r?void 0:r.noResolveJson},{},null===r||void 0===r?void 0:r.body);return(null===r||void 0===r?void 0:r.xform)?null===r||void 0===r?void 0:r.xform(l):{data:Object.assign({},l),error:null}}function xt(e){var t;let n=null;var r;(function(e){return e.access_token&&e.refresh_token&&e.expires_in})(e)&&(n=Object.assign({},e),e.expires_at||(n.expires_at=(r=e.expires_in,Math.round(Date.now()/1e3)+r)));return{data:{session:n,user:null!==(t=e.user)&&void 0!==t?t:e},error:null}}function kt(e){const t=xt(e);return!t.error&&e.weak_password&&"object"===typeof e.weak_password&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.message&&"string"===typeof e.weak_password.message&&e.weak_password.reasons.reduce(((e,t)=>e&&"string"===typeof t),!0)&&(t.data.weak_password=e.weak_password),t}function At(e){var t;return{data:{user:null!==(t=e.user)&&void 0!==t?t:e},error:null}}function Et(e){return{data:e,error:null}}function Ct(e){const{action_link:t,email_otp:n,hashed_token:r,redirect_to:a,verification_type:o}=e,i=yt(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]);return{data:{properties:{action_link:t,email_otp:n,hashed_token:r,redirect_to:a,verification_type:o},user:Object.assign({},i)},error:null}}function Tt(e){return e}const Pt=["global","local","others"];var jt=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"===typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a1&&void 0!==arguments[1]?arguments[1]:Pt[0];if(Pt.indexOf(t)<0)throw new Error("@supabase/auth-js: Parameter scope must be one of ".concat(Pt.join(", ")));try{return await St(this.fetch,"POST","".concat(this.url,"/logout?scope=").concat(t),{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(n){if(Ne(n))return{data:null,error:n};throw n}}async inviteUserByEmail(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{return await St(this.fetch,"POST","".concat(this.url,"/invite"),{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:At})}catch(n){if(Ne(n))return{data:{user:null},error:n};throw n}}async generateLink(e){try{const{options:t}=e,n=jt(e,["options"]),r=Object.assign(Object.assign({},n),t);return"newEmail"in n&&(r.new_email=null===n||void 0===n?void 0:n.newEmail,delete r.newEmail),await St(this.fetch,"POST","".concat(this.url,"/admin/generate_link"),{body:r,headers:this.headers,xform:Ct,redirectTo:null===t||void 0===t?void 0:t.redirectTo})}catch(t){if(Ne(t))return{data:{properties:null,user:null},error:t};throw t}}async createUser(e){try{return await St(this.fetch,"POST","".concat(this.url,"/admin/users"),{body:e,headers:this.headers,xform:At})}catch(t){if(Ne(t))return{data:{user:null},error:t};throw t}}async listUsers(e){var t,n,r,a,o,i,s;try{const l={nextPage:null,lastPage:0,total:0},u=await St(this.fetch,"GET","".concat(this.url,"/admin/users"),{headers:this.headers,noResolveJson:!0,query:{page:null!==(n=null===(t=null===e||void 0===e?void 0:e.page)||void 0===t?void 0:t.toString())&&void 0!==n?n:"",per_page:null!==(a=null===(r=null===e||void 0===e?void 0:e.perPage)||void 0===r?void 0:r.toString())&&void 0!==a?a:""},xform:Tt});if(u.error)throw u.error;const c=await u.json(),d=null!==(o=u.headers.get("x-total-count"))&&void 0!==o?o:0,f=null!==(s=null===(i=u.headers.get("link"))||void 0===i?void 0:i.split(","))&&void 0!==s?s:[];return f.length>0&&(f.forEach((e=>{const t=parseInt(e.split(";")[0].split("=")[1].substring(0,1)),n=JSON.parse(e.split(";")[1].split("=")[1]);l["".concat(n,"Page")]=t})),l.total=parseInt(d)),{data:Object.assign(Object.assign({},c),l),error:null}}catch(l){if(Ne(l))return{data:{users:[]},error:l};throw l}}async getUserById(e){mt(e);try{return await St(this.fetch,"GET","".concat(this.url,"/admin/users/").concat(e),{headers:this.headers,xform:At})}catch(t){if(Ne(t))return{data:{user:null},error:t};throw t}}async updateUserById(e,t){mt(e);try{return await St(this.fetch,"PUT","".concat(this.url,"/admin/users/").concat(e),{body:t,headers:this.headers,xform:At})}catch(n){if(Ne(n))return{data:{user:null},error:n};throw n}}async deleteUser(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];mt(e);try{return await St(this.fetch,"DELETE","".concat(this.url,"/admin/users/").concat(e),{headers:this.headers,body:{should_soft_delete:t},xform:At})}catch(n){if(Ne(n))return{data:{user:null},error:n};throw n}}async _listFactors(e){mt(e.userId);try{const{data:t,error:n}=await St(this.fetch,"GET","".concat(this.url,"/admin/users/").concat(e.userId,"/factors"),{headers:this.headers,xform:e=>({data:{factors:e},error:null})});return{data:t,error:n}}catch(t){if(Ne(t))return{data:null,error:t};throw t}}async _deleteFactor(e){mt(e.userId),mt(e.id);try{return{data:await St(this.fetch,"DELETE","".concat(this.url,"/admin/users/").concat(e.userId,"/factors/").concat(e.id),{headers:this.headers}),error:null}}catch(t){if(Ne(t))return{data:null,error:t};throw t}}}function Nt(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{getItem:t=>e[t]||null,setItem:(t,n)=>{e[t]=n},removeItem:t=>{delete e[t]}}}const Rt=!!(globalThis&&rt()&&globalThis.localStorage&&"true"===globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug"));class Lt extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class Mt extends Lt{}async function It(e,t,n){Rt&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",e,t);const r=new globalThis.AbortController;return t>0&&setTimeout((()=>{r.abort(),Rt&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",e)}),t),await Promise.resolve().then((()=>globalThis.navigator.locks.request(e,0===t?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},(async r=>{if(!r){if(0===t)throw Rt&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",e),new Mt('Acquiring an exclusive Navigator LockManager lock "'.concat(e,'" immediately failed'));if(Rt)try{const e=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(e,null," "))}catch(a){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",a)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await n()}Rt&&console.log("@supabase/gotrue-js: navigatorLock: acquired",e,r.name);try{return await n()}finally{Rt&&console.log("@supabase/gotrue-js: navigatorLock: released",e,r.name)}}))))}!function(){if("object"!==typeof globalThis)try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch(e){"undefined"!==typeof self&&(self.globalThis=self)}}();const Dt={url:"http://localhost:9999",storageKey:"supabase.auth.token",autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:Ce,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function $t(e,t,n){return await n()}const Ft={};class Ut{constructor(e){var t,n;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=Ut.nextInstanceID,Ut.nextInstanceID+=1,this.instanceID>0&&tt()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");const r=Object.assign(Object.assign({},Dt),e);if(this.logDebugMessages=!!r.debug,"function"===typeof r.debug&&(this.logger=r.debug),this.persistSession=r.persistSession,this.storageKey=r.storageKey,this.autoRefreshToken=r.autoRefreshToken,this.admin=new Ot({url:r.url,headers:r.headers,fetch:r.fetch}),this.url=r.url,this.headers=r.headers,this.fetch=at(r.fetch),this.lock=r.lock||$t,this.detectSessionInUrl=r.detectSessionInUrl,this.flowType=r.flowType,this.hasCustomAuthorizationHeader=r.hasCustomAuthorizationHeader,r.lock?this.lock=r.lock:tt()&&(null===(t=null===globalThis||void 0===globalThis?void 0:globalThis.navigator)||void 0===t?void 0:t.locks)?this.lock=It:this.lock=$t,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?(r.storage?this.storage=r.storage:rt()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=Nt(this.memoryStorage)),r.userStorage&&(this.userStorage=r.userStorage)):(this.memoryStorage={},this.storage=Nt(this.memoryStorage)),tt()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(a){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",a)}null===(n=this.broadcastChannel)||void 0===n||n.addEventListener("message",(async e=>{this._debug("received broadcast notification from other tab or client",e),await this._notifyAllSubscribers(e.data.event,e.data.session,!1)}))}this.initialize()}get jwks(){var e,t;return null!==(t=null===(e=Ft[this.storageKey])||void 0===e?void 0:e.jwks)&&void 0!==t?t:{keys:[]}}set jwks(e){Ft[this.storageKey]=Object.assign(Object.assign({},Ft[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,t;return null!==(t=null===(e=Ft[this.storageKey])||void 0===e?void 0:e.cachedAt)&&void 0!==t?t:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){Ft[this.storageKey]=Object.assign(Object.assign({},Ft[this.storageKey]),{cachedAt:e})}_debug(){if(this.logDebugMessages){for(var e=arguments.length,t=new Array(e),n=0;nawait this._acquireLock(-1,(async()=>await this._initialize())))()),await this.initializePromise}async _initialize(){var e;try{const t=function(e){const t={},n=new URL(e);if(n.hash&&"#"===n.hash[0])try{new URLSearchParams(n.hash.substring(1)).forEach(((e,n)=>{t[n]=e}))}catch(r){}return n.searchParams.forEach(((e,n)=>{t[n]=e})),t}(window.location.href);let n="none";if(this._isImplicitGrantCallback(t)?n="implicit":await this._isPKCECallback(t)&&(n="pkce"),tt()&&this.detectSessionInUrl&&"none"!==n){const{data:r,error:a}=await this._getSessionFromURL(t,n);if(a){if(this._debug("#_initialize()","error detecting session from URL",a),function(e){return Ne(e)&&"AuthImplicitGrantRedirectError"===e.name}(a)){const t=null===(e=a.details)||void 0===e?void 0:e.code;if("identity_already_exists"===t||"identity_not_found"===t||"single_identity_not_deletable"===t)return{error:a}}return await this._removeSession(),{error:a}}const{session:o,redirectType:i}=r;return this._debug("#_initialize()","detected session in URL",o,"redirect type",i),await this._saveSession(o),setTimeout((async()=>{"recovery"===i?await this._notifyAllSubscribers("PASSWORD_RECOVERY",o):await this._notifyAllSubscribers("SIGNED_IN",o)}),0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(t){return Ne(t)?{error:t}:{error:new Le("Unexpected error during initialization",t)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var t,n,r;try{const a=await St(this.fetch,"POST","".concat(this.url,"/signup"),{headers:this.headers,body:{data:null!==(n=null===(t=null===e||void 0===e?void 0:e.options)||void 0===t?void 0:t.data)&&void 0!==n?n:{},gotrue_meta_security:{captcha_token:null===(r=null===e||void 0===e?void 0:e.options)||void 0===r?void 0:r.captchaToken}},xform:xt}),{data:o,error:i}=a;if(i||!o)return{data:{user:null,session:null},error:i};const s=o.session,l=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",s)),{data:{user:l,session:s},error:null}}catch(a){if(Ne(a))return{data:{user:null,session:null},error:a};throw a}}async signUp(e){var t,n,r;try{let a;if("email"in e){const{email:n,password:r,options:o}=e;let i=null,s=null;"pkce"===this.flowType&&([i,s]=await ft(this.storage,this.storageKey)),a=await St(this.fetch,"POST","".concat(this.url,"/signup"),{headers:this.headers,redirectTo:null===o||void 0===o?void 0:o.emailRedirectTo,body:{email:n,password:r,data:null!==(t=null===o||void 0===o?void 0:o.data)&&void 0!==t?t:{},gotrue_meta_security:{captcha_token:null===o||void 0===o?void 0:o.captchaToken},code_challenge:i,code_challenge_method:s},xform:xt})}else{if(!("phone"in e))throw new $e("You must provide either an email or phone number and a password");{const{phone:t,password:o,options:i}=e;a=await St(this.fetch,"POST","".concat(this.url,"/signup"),{headers:this.headers,body:{phone:t,password:o,data:null!==(n=null===i||void 0===i?void 0:i.data)&&void 0!==n?n:{},channel:null!==(r=null===i||void 0===i?void 0:i.channel)&&void 0!==r?r:"sms",gotrue_meta_security:{captcha_token:null===i||void 0===i?void 0:i.captchaToken}},xform:xt})}}const{data:o,error:i}=a;if(i||!o)return{data:{user:null,session:null},error:i};const s=o.session,l=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",s)),{data:{user:l,session:s},error:null}}catch(a){if(Ne(a))return{data:{user:null,session:null},error:a};throw a}}async signInWithPassword(e){try{let t;if("email"in e){const{email:n,password:r,options:a}=e;t=await St(this.fetch,"POST","".concat(this.url,"/token?grant_type=password"),{headers:this.headers,body:{email:n,password:r,gotrue_meta_security:{captcha_token:null===a||void 0===a?void 0:a.captchaToken}},xform:kt})}else{if(!("phone"in e))throw new $e("You must provide either an email or phone number and a password");{const{phone:n,password:r,options:a}=e;t=await St(this.fetch,"POST","".concat(this.url,"/token?grant_type=password"),{headers:this.headers,body:{phone:n,password:r,gotrue_meta_security:{captcha_token:null===a||void 0===a?void 0:a.captchaToken}},xform:kt})}}const{data:n,error:r}=t;return r?{data:{user:null,session:null},error:r}:n&&n.session&&n.user?(n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),{data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:r}):{data:{user:null,session:null},error:new De}}catch(t){if(Ne(t))return{data:{user:null,session:null},error:t};throw t}}async signInWithOAuth(e){var t,n,r,a;return await this._handleProviderSignIn(e.provider,{redirectTo:null===(t=e.options)||void 0===t?void 0:t.redirectTo,scopes:null===(n=e.options)||void 0===n?void 0:n.scopes,queryParams:null===(r=e.options)||void 0===r?void 0:r.queryParams,skipBrowserRedirect:null===(a=e.options)||void 0===a?void 0:a.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,(async()=>this._exchangeCodeForSession(e)))}async signInWithWeb3(e){const{chain:t}=e;if("solana"===t)return await this.signInWithSolana(e);throw new Error('@supabase/auth-js: Unsupported chain "'.concat(t,'"'))}async signInWithSolana(e){var t,n,r,a,o,i,s,l,u,c,d,f;let h,p;if("message"in e)h=e.message,p=e.signature;else{const{chain:d,wallet:f,statement:m,options:g}=e;let v;if(tt())if("object"===typeof f)v=f;else{const e=window;if(!("solana"in e)||"object"!==typeof e.solana||!("signIn"in e.solana&&"function"===typeof e.solana.signIn||"signMessage"in e.solana&&"function"===typeof e.solana.signMessage))throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.");v=e.solana}else{if("object"!==typeof f||!(null===g||void 0===g?void 0:g.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");v=f}const y=new URL(null!==(t=null===g||void 0===g?void 0:g.url)&&void 0!==t?t:window.location.href);if("signIn"in v&&v.signIn){const e=await v.signIn(Object.assign(Object.assign(Object.assign({issuedAt:(new Date).toISOString()},null===g||void 0===g?void 0:g.signInWithSolana),{version:"1",domain:y.host,uri:y.href}),m?{statement:m}:null));let t;if(Array.isArray(e)&&e[0]&&"object"===typeof e[0])t=e[0];else{if(!(e&&"object"===typeof e&&"signedMessage"in e&&"signature"in e))throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");t=e}if(!("signedMessage"in t&&"signature"in t&&("string"===typeof t.signedMessage||t.signedMessage instanceof Uint8Array)&&t.signature instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields");h="string"===typeof t.signedMessage?t.signedMessage:(new TextDecoder).decode(t.signedMessage),p=t.signature}else{if(!("signMessage"in v)||"function"!==typeof v.signMessage||!("publicKey"in v)||"object"!==typeof v||!v.publicKey||!("toBase58"in v.publicKey)||"function"!==typeof v.publicKey.toBase58)throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");h=["".concat(y.host," wants you to sign in with your Solana account:"),v.publicKey.toBase58(),...m?["",m,""]:[""],"Version: 1","URI: ".concat(y.href),"Issued At: ".concat(null!==(r=null===(n=null===g||void 0===g?void 0:g.signInWithSolana)||void 0===n?void 0:n.issuedAt)&&void 0!==r?r:(new Date).toISOString()),...(null===(a=null===g||void 0===g?void 0:g.signInWithSolana)||void 0===a?void 0:a.notBefore)?["Not Before: ".concat(g.signInWithSolana.notBefore)]:[],...(null===(o=null===g||void 0===g?void 0:g.signInWithSolana)||void 0===o?void 0:o.expirationTime)?["Expiration Time: ".concat(g.signInWithSolana.expirationTime)]:[],...(null===(i=null===g||void 0===g?void 0:g.signInWithSolana)||void 0===i?void 0:i.chainId)?["Chain ID: ".concat(g.signInWithSolana.chainId)]:[],...(null===(s=null===g||void 0===g?void 0:g.signInWithSolana)||void 0===s?void 0:s.nonce)?["Nonce: ".concat(g.signInWithSolana.nonce)]:[],...(null===(l=null===g||void 0===g?void 0:g.signInWithSolana)||void 0===l?void 0:l.requestId)?["Request ID: ".concat(g.signInWithSolana.requestId)]:[],...(null===(c=null===(u=null===g||void 0===g?void 0:g.signInWithSolana)||void 0===u?void 0:u.resources)||void 0===c?void 0:c.length)?["Resources",...g.signInWithSolana.resources.map((e=>"- ".concat(e)))]:[]].join("\n");const e=await v.signMessage((new TextEncoder).encode(h),"utf8");if(!e||!(e instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");p=e}}try{const{data:t,error:n}=await St(this.fetch,"POST","".concat(this.url,"/token?grant_type=web3"),{headers:this.headers,body:Object.assign({chain:"solana",message:h,signature:et(p)},(null===(d=e.options)||void 0===d?void 0:d.captchaToken)?{gotrue_meta_security:{captcha_token:null===(f=e.options)||void 0===f?void 0:f.captchaToken}}:null),xform:xt});if(n)throw n;return t&&t.session&&t.user?(t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),{data:Object.assign({},t),error:n}):{data:{user:null,session:null},error:new De}}catch(m){if(Ne(m))return{data:{user:null,session:null},error:m};throw m}}async _exchangeCodeForSession(e){const t=await it(this.storage,"".concat(this.storageKey,"-code-verifier")),[n,r]=(null!==t&&void 0!==t?t:"").split("/");try{const{data:t,error:a}=await St(this.fetch,"POST","".concat(this.url,"/token?grant_type=pkce"),{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:xt});if(await st(this.storage,"".concat(this.storageKey,"-code-verifier")),a)throw a;return t&&t.session&&t.user?(t.session&&(await this._saveSession(t.session),await this._notifyAllSubscribers("SIGNED_IN",t.session)),{data:Object.assign(Object.assign({},t),{redirectType:null!==r&&void 0!==r?r:null}),error:a}):{data:{user:null,session:null,redirectType:null},error:new De}}catch(a){if(Ne(a))return{data:{user:null,session:null,redirectType:null},error:a};throw a}}async signInWithIdToken(e){try{const{options:t,provider:n,token:r,access_token:a,nonce:o}=e,i=await St(this.fetch,"POST","".concat(this.url,"/token?grant_type=id_token"),{headers:this.headers,body:{provider:n,id_token:r,access_token:a,nonce:o,gotrue_meta_security:{captcha_token:null===t||void 0===t?void 0:t.captchaToken}},xform:xt}),{data:s,error:l}=i;return l?{data:{user:null,session:null},error:l}:s&&s.session&&s.user?(s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",s.session)),{data:s,error:l}):{data:{user:null,session:null},error:new De}}catch(t){if(Ne(t))return{data:{user:null,session:null},error:t};throw t}}async signInWithOtp(e){var t,n,r,a,o;try{if("email"in e){const{email:r,options:a}=e;let o=null,i=null;"pkce"===this.flowType&&([o,i]=await ft(this.storage,this.storageKey));const{error:s}=await St(this.fetch,"POST","".concat(this.url,"/otp"),{headers:this.headers,body:{email:r,data:null!==(t=null===a||void 0===a?void 0:a.data)&&void 0!==t?t:{},create_user:null===(n=null===a||void 0===a?void 0:a.shouldCreateUser)||void 0===n||n,gotrue_meta_security:{captcha_token:null===a||void 0===a?void 0:a.captchaToken},code_challenge:o,code_challenge_method:i},redirectTo:null===a||void 0===a?void 0:a.emailRedirectTo});return{data:{user:null,session:null},error:s}}if("phone"in e){const{phone:t,options:n}=e,{data:i,error:s}=await St(this.fetch,"POST","".concat(this.url,"/otp"),{headers:this.headers,body:{phone:t,data:null!==(r=null===n||void 0===n?void 0:n.data)&&void 0!==r?r:{},create_user:null===(a=null===n||void 0===n?void 0:n.shouldCreateUser)||void 0===a||a,gotrue_meta_security:{captcha_token:null===n||void 0===n?void 0:n.captchaToken},channel:null!==(o=null===n||void 0===n?void 0:n.channel)&&void 0!==o?o:"sms"}});return{data:{user:null,session:null,messageId:null===i||void 0===i?void 0:i.message_id},error:s}}throw new $e("You must provide either an email or phone number.")}catch(i){if(Ne(i))return{data:{user:null,session:null},error:i};throw i}}async verifyOtp(e){var t,n;try{let r,a;"options"in e&&(r=null===(t=e.options)||void 0===t?void 0:t.redirectTo,a=null===(n=e.options)||void 0===n?void 0:n.captchaToken);const{data:o,error:i}=await St(this.fetch,"POST","".concat(this.url,"/verify"),{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:a}}),redirectTo:r,xform:xt});if(i)throw i;if(!o)throw new Error("An error occurred on token verification.");const s=o.session,l=o.user;return(null===s||void 0===s?void 0:s.access_token)&&(await this._saveSession(s),await this._notifyAllSubscribers("recovery"==e.type?"PASSWORD_RECOVERY":"SIGNED_IN",s)),{data:{user:l,session:s},error:null}}catch(r){if(Ne(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithSSO(e){var t,n,r;try{let a=null,o=null;return"pkce"===this.flowType&&([a,o]=await ft(this.storage,this.storageKey)),await St(this.fetch,"POST","".concat(this.url,"/sso"),{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:null!==(n=null===(t=e.options)||void 0===t?void 0:t.redirectTo)&&void 0!==n?n:void 0}),(null===(r=null===e||void 0===e?void 0:e.options)||void 0===r?void 0:r.captchaToken)?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:o}),headers:this.headers,xform:Et})}catch(a){if(Ne(a))return{data:null,error:a};throw a}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,(async()=>await this._reauthenticate()))}async _reauthenticate(){try{return await this._useSession((async e=>{const{data:{session:t},error:n}=e;if(n)throw n;if(!t)throw new Ie;const{error:r}=await St(this.fetch,"GET","".concat(this.url,"/reauthenticate"),{headers:this.headers,jwt:t.access_token});return{data:{user:null,session:null},error:r}}))}catch(e){if(Ne(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{const t="".concat(this.url,"/resend");if("email"in e){const{email:n,type:r,options:a}=e,{error:o}=await St(this.fetch,"POST",t,{headers:this.headers,body:{email:n,type:r,gotrue_meta_security:{captcha_token:null===a||void 0===a?void 0:a.captchaToken}},redirectTo:null===a||void 0===a?void 0:a.emailRedirectTo});return{data:{user:null,session:null},error:o}}if("phone"in e){const{phone:n,type:r,options:a}=e,{data:o,error:i}=await St(this.fetch,"POST",t,{headers:this.headers,body:{phone:n,type:r,gotrue_meta_security:{captcha_token:null===a||void 0===a?void 0:a.captchaToken}}});return{data:{user:null,session:null,messageId:null===o||void 0===o?void 0:o.message_id},error:i}}throw new $e("You must provide either an email or phone number and a type")}catch(t){if(Ne(t))return{data:{user:null,session:null},error:t};throw t}}async getSession(){await this.initializePromise;return await this._acquireLock(-1,(async()=>this._useSession((async e=>e))))}async _acquireLock(e,t){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const e=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=(async()=>(await e,await t()))();return this.pendingInLock.push((async()=>{try{await n}catch(e){}})()),n}return await this.lock("lock:".concat(this.storageKey),e,(async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const e=t();for(this.pendingInLock.push((async()=>{try{await e}catch(t){}})()),await e;this.pendingInLock.length;){const e=[...this.pendingInLock];await Promise.all(e),this.pendingInLock.splice(0,e.length)}return await e}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}}))}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const t=await this.__loadSession();return await e(t)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",(new Error).stack);try{let e=null;const t=await it(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",t),null!==t&&(this._isValidSession(t)?e=t:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const n=!!e.expires_at&&1e3*e.expires_at-Date.now()(t||"user"!==n||(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),t=!0,this.suppressGetSessionWarning=!0),Reflect.get(e,n,r))})}return{data:{session:e},error:null}}const{session:r,error:a}=await this._callRefreshToken(e.refresh_token);return a?{data:{session:null},error:a}:{data:{session:r},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;return await this._acquireLock(-1,(async()=>await this._getUser()))}async _getUser(e){try{return e?await St(this.fetch,"GET","".concat(this.url,"/user"),{headers:this.headers,jwt:e,xform:At}):await this._useSession((async e=>{var t,n,r;const{data:a,error:o}=e;if(o)throw o;return(null===(t=a.session)||void 0===t?void 0:t.access_token)||this.hasCustomAuthorizationHeader?await St(this.fetch,"GET","".concat(this.url,"/user"),{headers:this.headers,jwt:null!==(r=null===(n=a.session)||void 0===n?void 0:n.access_token)&&void 0!==r?r:void 0,xform:At}):{data:{user:null},error:new Ie}}))}catch(t){if(Ne(t))return function(e){return Ne(e)&&"AuthSessionMissingError"===e.name}(t)&&(await this._removeSession(),await st(this.storage,"".concat(this.storageKey,"-code-verifier"))),{data:{user:null},error:t};throw t}}async updateUser(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return await this.initializePromise,await this._acquireLock(-1,(async()=>await this._updateUser(e,t)))}async _updateUser(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{return await this._useSession((async n=>{const{data:r,error:a}=n;if(a)throw a;if(!r.session)throw new Ie;const o=r.session;let i=null,s=null;"pkce"===this.flowType&&null!=e.email&&([i,s]=await ft(this.storage,this.storageKey));const{data:l,error:u}=await St(this.fetch,"PUT","".concat(this.url,"/user"),{headers:this.headers,redirectTo:null===t||void 0===t?void 0:t.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:i,code_challenge_method:s}),jwt:o.access_token,xform:At});if(u)throw u;return o.user=l.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),{data:{user:o.user},error:null}}))}catch(n){if(Ne(n))return{data:{user:null},error:n};throw n}}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,(async()=>await this._setSession(e)))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new Ie;const t=Date.now()/1e3;let n=t,r=!0,a=null;const{payload:o}=ut(e.access_token);if(o.exp&&(n=o.exp,r=n<=t),r){const{session:t,error:n}=await this._callRefreshToken(e.refresh_token);if(n)return{data:{user:null,session:null},error:n};if(!t)return{data:{user:null,session:null},error:null};a=t}else{const{data:r,error:o}=await this._getUser(e.access_token);if(o)throw o;a={access_token:e.access_token,refresh_token:e.refresh_token,user:r.user,token_type:"bearer",expires_in:n-t,expires_at:n},await this._saveSession(a),await this._notifyAllSubscribers("SIGNED_IN",a)}return{data:{user:a.user,session:a},error:null}}catch(t){if(Ne(t))return{data:{session:null,user:null},error:t};throw t}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,(async()=>await this._refreshSession(e)))}async _refreshSession(e){try{return await this._useSession((async t=>{var n;if(!e){const{data:r,error:a}=t;if(a)throw a;e=null!==(n=r.session)&&void 0!==n?n:void 0}if(!(null===e||void 0===e?void 0:e.refresh_token))throw new Ie;const{session:r,error:a}=await this._callRefreshToken(e.refresh_token);return a?{data:{user:null,session:null},error:a}:r?{data:{user:r.user,session:r},error:null}:{data:{user:null,session:null},error:null}}))}catch(t){if(Ne(t))return{data:{user:null,session:null},error:t};throw t}}async _getSessionFromURL(e,t){try{if(!tt())throw new Fe("No browser detected.");if(e.error||e.error_description||e.error_code)throw new Fe(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(t){case"implicit":if("pkce"===this.flowType)throw new Ue("Not a valid PKCE flow url.");break;case"pkce":if("implicit"===this.flowType)throw new Fe("Not a valid implicit grant flow url.")}if("pkce"===t){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Ue("No code detected.");const{data:t,error:n}=await this._exchangeCodeForSession(e.code);if(n)throw n;const r=new URL(window.location.href);return r.searchParams.delete("code"),window.history.replaceState(window.history.state,"",r.toString()),{data:{session:t.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:r,access_token:a,refresh_token:o,expires_in:i,expires_at:s,token_type:l}=e;if(!a||!i||!o||!l)throw new Fe("No session defined in URL");const u=Math.round(Date.now()/1e3),c=parseInt(i);let d=u+c;s&&(d=parseInt(s));const f=d-u;1e3*f<=Ae&&console.warn("@supabase/gotrue-js: Session as retrieved from URL expires in ".concat(f,"s, should have been closer to ").concat(c,"s"));const h=d-c;u-h>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",h,d,u):u-h<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",h,d,u);const{data:p,error:m}=await this._getUser(a);if(m)throw m;const g={provider_token:n,provider_refresh_token:r,access_token:a,expires_in:c,expires_at:d,refresh_token:o,token_type:l,user:p.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:g,redirectType:e.type},error:null}}catch(n){if(Ne(n))return{data:{session:null,redirectType:null},error:n};throw n}}_isImplicitGrantCallback(e){return Boolean(e.access_token||e.error_description)}async _isPKCECallback(e){const t=await it(this.storage,"".concat(this.storageKey,"-code-verifier"));return!(!e.code||!t)}async signOut(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{scope:"global"};return await this.initializePromise,await this._acquireLock(-1,(async()=>await this._signOut(e)))}async _signOut(){let{scope:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{scope:"global"};return await this._useSession((async t=>{var n;const{data:r,error:a}=t;if(a)return{error:a};const o=null===(n=r.session)||void 0===n?void 0:n.access_token;if(o){const{error:t}=await this.admin.signOut(o,e);if(t&&(!function(e){return Ne(e)&&"AuthApiError"===e.name}(t)||404!==t.status&&401!==t.status&&403!==t.status))return{error:t}}return"others"!==e&&(await this._removeSession(),await st(this.storage,"".concat(this.storageKey,"-code-verifier"))),{error:null}}))}onAuthStateChange(e){const t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})),n={id:t,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",t),this.stateChangeEmitters.delete(t)}};return this._debug("#onAuthStateChange()","registered callback with id",t),this.stateChangeEmitters.set(t,n),(async()=>{await this.initializePromise,await this._acquireLock(-1,(async()=>{this._emitInitialSession(t)}))})(),{data:{subscription:n}}}async _emitInitialSession(e){return await this._useSession((async t=>{var n,r;try{const{data:{session:r},error:a}=t;if(a)throw a;await(null===(n=this.stateChangeEmitters.get(e))||void 0===n?void 0:n.callback("INITIAL_SESSION",r)),this._debug("INITIAL_SESSION","callback id",e,"session",r)}catch(a){await(null===(r=this.stateChangeEmitters.get(e))||void 0===r?void 0:r.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",a),console.error(a)}}))}async resetPasswordForEmail(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,r=null;"pkce"===this.flowType&&([n,r]=await ft(this.storage,this.storageKey,!0));try{return await St(this.fetch,"POST","".concat(this.url,"/recover"),{body:{email:e,code_challenge:n,code_challenge_method:r,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(a){if(Ne(a))return{data:null,error:a};throw a}}async getUserIdentities(){var e;try{const{data:t,error:n}=await this.getUser();if(n)throw n;return{data:{identities:null!==(e=t.user.identities)&&void 0!==e?e:[]},error:null}}catch(t){if(Ne(t))return{data:null,error:t};throw t}}async linkIdentity(e){var t;try{const{data:n,error:r}=await this._useSession((async t=>{var n,r,a,o,i;const{data:s,error:l}=t;if(l)throw l;const u=await this._getUrlForProvider("".concat(this.url,"/user/identities/authorize"),e.provider,{redirectTo:null===(n=e.options)||void 0===n?void 0:n.redirectTo,scopes:null===(r=e.options)||void 0===r?void 0:r.scopes,queryParams:null===(a=e.options)||void 0===a?void 0:a.queryParams,skipBrowserRedirect:!0});return await St(this.fetch,"GET",u,{headers:this.headers,jwt:null!==(i=null===(o=s.session)||void 0===o?void 0:o.access_token)&&void 0!==i?i:void 0})}));if(r)throw r;return tt()&&!(null===(t=e.options)||void 0===t?void 0:t.skipBrowserRedirect)&&window.location.assign(null===n||void 0===n?void 0:n.url),{data:{provider:e.provider,url:null===n||void 0===n?void 0:n.url},error:null}}catch(n){if(Ne(n))return{data:{provider:e.provider,url:null},error:n};throw n}}async unlinkIdentity(e){try{return await this._useSession((async t=>{var n,r;const{data:a,error:o}=t;if(o)throw o;return await St(this.fetch,"DELETE","".concat(this.url,"/user/identities/").concat(e.identity_id),{headers:this.headers,jwt:null!==(r=null===(n=a.session)||void 0===n?void 0:n.access_token)&&void 0!==r?r:void 0})}))}catch(t){if(Ne(t))return{data:null,error:t};throw t}}async _refreshAccessToken(e){const t="#_refreshAccessToken(".concat(e.substring(0,5),"...)");this._debug(t,"begin");try{const a=Date.now();return await(n=async n=>(n>0&&await async function(e){return await new Promise((t=>{setTimeout((()=>t(null)),e)}))}(200*Math.pow(2,n-1)),this._debug(t,"refreshing attempt",n),await St(this.fetch,"POST","".concat(this.url,"/token?grant_type=refresh_token"),{body:{refresh_token:e},headers:this.headers,xform:xt})),r=(e,t)=>{const n=200*Math.pow(2,e);return t&&ze(t)&&Date.now()+n-a{(async()=>{for(let o=0;o<1/0;o++)try{const t=await n(o);if(!r(o,null,t))return void e(t)}catch(a){if(!r(o,a))return void t(a)}})()})))}catch(a){if(this._debug(t,"error",a),Ne(a))return{data:{session:null,user:null},error:a};throw a}finally{this._debug(t,"end")}var n,r}_isValidSession(e){return"object"===typeof e&&null!==e&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,t){const n=await this._getUrlForProvider("".concat(this.url,"/authorize"),e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",t,"url",n),tt()&&!t.skipBrowserRedirect&&window.location.assign(n),{data:{provider:e,url:n},error:null}}async _recoverAndRefresh(){var e,t;const n="#_recoverAndRefresh()";this._debug(n,"begin");try{const a=await it(this.storage,this.storageKey);if(a&&this.userStorage){let t=await it(this.userStorage,this.storageKey+"-user");this.storage.isServer||!Object.is(this.storage,this.userStorage)||t||(t={user:a.user},await ot(this.userStorage,this.storageKey+"-user",t)),a.user=null!==(e=null===t||void 0===t?void 0:t.user)&&void 0!==e?e:gt()}else if(a&&!a.user&&!a.user){const e=await it(this.storage,this.storageKey+"-user");e&&(null===e||void 0===e?void 0:e.user)?(a.user=e.user,await st(this.storage,this.storageKey+"-user"),await ot(this.storage,this.storageKey,a)):a.user=gt()}if(this._debug(n,"session from storage",a),!this._isValidSession(a))return this._debug(n,"session is not valid"),void(null!==a&&await this._removeSession());const o=1e3*(null!==(t=a.expires_at)&&void 0!==t?t:1/0)-Date.now()2&&void 0!==arguments[2])||arguments[2];const r="#_notifyAllSubscribers(".concat(e,")");this._debug(r,"begin",t,"broadcast = ".concat(n));try{this.broadcastChannel&&n&&this.broadcastChannel.postMessage({event:e,session:t});const r=[],a=Array.from(this.stateChangeEmitters.values()).map((async n=>{try{await n.callback(e,t)}catch(a){r.push(a)}}));if(await Promise.all(a),r.length>0){for(let e=0;ethis._autoRefreshTokenTick()),Ae);this.autoRefreshTicker=e,e&&"object"===typeof e&&"function"===typeof e.unref?e.unref():"undefined"!==typeof Deno&&"function"===typeof Deno.unrefTimer&&Deno.unrefTimer(e),setTimeout((async()=>{await this.initializePromise,await this._autoRefreshTokenTick()}),0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,(async()=>{try{const t=Date.now();try{return await this._useSession((async e=>{const{data:{session:n}}=e;if(!n||!n.refresh_token||!n.expires_at)return void this._debug("#_autoRefreshTokenTick()","no session");const r=Math.floor((1e3*n.expires_at-t)/Ae);this._debug("#_autoRefreshTokenTick()","access token expires in ".concat(r," ticks, a tick lasts ").concat(Ae,"ms, refresh threshold is ").concat(3," ticks")),r<=3&&await this._callRefreshToken(n.refresh_token)}))}catch(e){console.error("Auto refresh tick failed with error. This is likely a transient error.",e)}}finally{this._debug("#_autoRefreshTokenTick()","end")}}))}catch(e){if(!(e.isAcquireTimeout||e instanceof Lt))throw e;this._debug("auto refresh token tick lock not available")}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!tt()||!(null===window||void 0===window?void 0:window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),null===window||void 0===window||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const t="#_onVisibilityChanged(".concat(e,")");this._debug(t,"visibilityState",document.visibilityState),"visible"===document.visibilityState?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,(async()=>{"visible"===document.visibilityState?await this._recoverAndRefresh():this._debug(t,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting")})))):"hidden"===document.visibilityState&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,t,n){const r=["provider=".concat(encodeURIComponent(t))];if((null===n||void 0===n?void 0:n.redirectTo)&&r.push("redirect_to=".concat(encodeURIComponent(n.redirectTo))),(null===n||void 0===n?void 0:n.scopes)&&r.push("scopes=".concat(encodeURIComponent(n.scopes))),"pkce"===this.flowType){const[e,t]=await ft(this.storage,this.storageKey),n=new URLSearchParams({code_challenge:"".concat(encodeURIComponent(e)),code_challenge_method:"".concat(encodeURIComponent(t))});r.push(n.toString())}if(null===n||void 0===n?void 0:n.queryParams){const e=new URLSearchParams(n.queryParams);r.push(e.toString())}return(null===n||void 0===n?void 0:n.skipBrowserRedirect)&&r.push("skip_http_redirect=".concat(n.skipBrowserRedirect)),"".concat(e,"?").concat(r.join("&"))}async _unenroll(e){try{return await this._useSession((async t=>{var n;const{data:r,error:a}=t;return a?{data:null,error:a}:await St(this.fetch,"DELETE","".concat(this.url,"/factors/").concat(e.factorId),{headers:this.headers,jwt:null===(n=null===r||void 0===r?void 0:r.session)||void 0===n?void 0:n.access_token})}))}catch(t){if(Ne(t))return{data:null,error:t};throw t}}async _enroll(e){try{return await this._useSession((async t=>{var n,r;const{data:a,error:o}=t;if(o)return{data:null,error:o};const i=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},"phone"===e.factorType?{phone:e.phone}:{issuer:e.issuer}),{data:s,error:l}=await St(this.fetch,"POST","".concat(this.url,"/factors"),{body:i,headers:this.headers,jwt:null===(n=null===a||void 0===a?void 0:a.session)||void 0===n?void 0:n.access_token});return l?{data:null,error:l}:("totp"===e.factorType&&(null===(r=null===s||void 0===s?void 0:s.totp)||void 0===r?void 0:r.qr_code)&&(s.totp.qr_code="data:image/svg+xml;utf-8,".concat(s.totp.qr_code)),{data:s,error:null})}))}catch(t){if(Ne(t))return{data:null,error:t};throw t}}async _verify(e){return this._acquireLock(-1,(async()=>{try{return await this._useSession((async t=>{var n;const{data:r,error:a}=t;if(a)return{data:null,error:a};const{data:o,error:i}=await St(this.fetch,"POST","".concat(this.url,"/factors/").concat(e.factorId,"/verify"),{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:null===(n=null===r||void 0===r?void 0:r.session)||void 0===n?void 0:n.access_token});return i?{data:null,error:i}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+o.expires_in},o)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",o),{data:o,error:i})}))}catch(t){if(Ne(t))return{data:null,error:t};throw t}}))}async _challenge(e){return this._acquireLock(-1,(async()=>{try{return await this._useSession((async t=>{var n;const{data:r,error:a}=t;return a?{data:null,error:a}:await St(this.fetch,"POST","".concat(this.url,"/factors/").concat(e.factorId,"/challenge"),{body:{channel:e.channel},headers:this.headers,jwt:null===(n=null===r||void 0===r?void 0:r.session)||void 0===n?void 0:n.access_token})}))}catch(t){if(Ne(t))return{data:null,error:t};throw t}}))}async _challengeAndVerify(e){const{data:t,error:n}=await this._challenge({factorId:e.factorId});return n?{data:null,error:n}:await this._verify({factorId:e.factorId,challengeId:t.id,code:e.code})}async _listFactors(){const{data:{user:e},error:t}=await this.getUser();if(t)return{data:null,error:t};const n=(null===e||void 0===e?void 0:e.factors)||[],r=n.filter((e=>"totp"===e.factor_type&&"verified"===e.status)),a=n.filter((e=>"phone"===e.factor_type&&"verified"===e.status));return{data:{all:n,totp:r,phone:a},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,(async()=>await this._useSession((async e=>{var t,n;const{data:{session:r},error:a}=e;if(a)return{data:null,error:a};if(!r)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:o}=ut(r.access_token);let i=null;o.aal&&(i=o.aal);let s=i;(null!==(n=null===(t=r.user.factors)||void 0===t?void 0:t.filter((e=>"verified"===e.status)))&&void 0!==n?n:[]).length>0&&(s="aal2");return{data:{currentLevel:i,nextLevel:s,currentAuthenticationMethods:o.amr||[]},error:null}}))))}async fetchJwk(e){let t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{keys:[]}).keys.find((t=>t.kid===e));if(t)return t;const n=Date.now();if(t=this.jwks.keys.find((t=>t.kid===e)),t&&this.jwks_cached_at+6e5>n)return t;const{data:r,error:a}=await St(this.fetch,"GET","".concat(this.url,"/.well-known/jwks.json"),{headers:this.headers});if(a)throw a;return r.keys&&0!==r.keys.length?(this.jwks=r,this.jwks_cached_at=n,t=r.keys.find((t=>t.kid===e)),t||null):null}async getClaims(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{let n=e;if(!n){const{data:e,error:t}=await this.getSession();if(t||!e.session)return{data:null,error:t};n=e.session.access_token}const{header:r,payload:a,signature:o,raw:{header:i,payload:s}}=ut(n);(null===t||void 0===t?void 0:t.allowExpired)||function(e){if(!e)throw new Error("Missing exp claim");if(e<=Math.floor(Date.now()/1e3))throw new Error("JWT has expired")}(a.exp);const l=r.alg&&!r.alg.startsWith("HS")&&r.kid&&"crypto"in globalThis&&"subtle"in globalThis.crypto?await this.fetchJwk(r.kid,(null===t||void 0===t?void 0:t.keys)?{keys:t.keys}:null===t||void 0===t?void 0:t.jwks):null;if(!l){const{error:e}=await this.getUser(n);if(e)throw e;return{data:{claims:a,header:r,signature:o},error:null}}const u=function(e){switch(e){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}(r.alg),c=await crypto.subtle.importKey("jwk",l,u,!0,["verify"]);if(!await crypto.subtle.verify(u,c,o,function(e){const t=[];return Je(e,(e=>t.push(e))),new Uint8Array(t)}("".concat(i,".").concat(s))))throw new Ze("Invalid JWT signature");return{data:{claims:a,header:r,signature:o},error:null}}catch(n){if(Ne(n))return{data:null,error:n};throw n}}}Ut.nextInstanceID=0;const Bt=Ut;class zt extends Bt{constructor(e){super(e)}}var Ht=function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function i(e){try{l(r.next(e))}catch(t){o(t)}}function s(e){try{l(r.throw(e))}catch(t){o(t)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}l((r=r.apply(e,t||[])).next())}))};class Zt{constructor(e,t,n){var r,a,o;if(this.supabaseUrl=e,this.supabaseKey=t,!e)throw new Error("supabaseUrl is required.");if(!t)throw new Error("supabaseKey is required.");const i=(s=e).endsWith("/")?s:s+"/";var s;const l=new URL(i);this.realtimeUrl=new URL("realtime/v1",l),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",l),this.storageUrl=new URL("storage/v1",l),this.functionsUrl=new URL("functions/v1",l);const u="sb-".concat(l.hostname.split(".")[0],"-auth-token"),c=function(e,t){var n,r;const{db:a,auth:o,realtime:i,global:s}=e,{db:l,auth:u,realtime:c,global:d}=t,f={db:Object.assign(Object.assign({},l),a),auth:Object.assign(Object.assign({},u),o),realtime:Object.assign(Object.assign({},c),i),global:Object.assign(Object.assign(Object.assign({},d),s),{headers:Object.assign(Object.assign({},null!==(n=null===d||void 0===d?void 0:d.headers)&&void 0!==n?n:{}),null!==(r=null===s||void 0===s?void 0:s.headers)&&void 0!==r?r:{})}),accessToken:()=>xe(this,void 0,void 0,(function*(){return""}))};return e.accessToken?f.accessToken=e.accessToken:delete f.accessToken,f}(null!==n&&void 0!==n?n:{},{db:ge,realtime:ye,auth:Object.assign(Object.assign({},ve),{storageKey:u}),global:me});this.storageKey=null!==(r=c.auth.storageKey)&&void 0!==r?r:"",this.headers=null!==(a=c.global.headers)&&void 0!==a?a:{},c.accessToken?(this.accessToken=c.accessToken,this.auth=new Proxy({},{get:(e,t)=>{throw new Error("@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.".concat(String(t)," is not possible"))}})):this.auth=this._initSupabaseAuthClient(null!==(o=c.auth)&&void 0!==o?o:{},this.headers,c.global.fetch),this.fetch=Se(t,this._getAccessToken.bind(this),c.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},c.realtime)),this.rest=new d(new URL("rest/v1",l).href,{headers:this.headers,schema:c.db.schema,fetch:this.fetch}),c.accessToken||this._listenForAuthEvents()}get functions(){return new u(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}get storage(){return new he(this.storageUrl.href,this.headers,this.fetch)}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.rest.rpc(e,t,n)}channel(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{config:{}};return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,t;return Ht(this,void 0,void 0,(function*(){if(this.accessToken)return yield this.accessToken();const{data:n}=yield this.auth.getSession();return null!==(t=null===(e=n.session)||void 0===e?void 0:e.access_token)&&void 0!==t?t:null}))}_initSupabaseAuthClient(e,t,n){let{autoRefreshToken:r,persistSession:a,detectSessionInUrl:o,storage:i,storageKey:s,flowType:l,lock:u,debug:c}=e;const d={Authorization:"Bearer ".concat(this.supabaseKey),apikey:"".concat(this.supabaseKey)};return new zt({url:this.authUrl.href,headers:Object.assign(Object.assign({},d),t),storageKey:s,autoRefreshToken:r,persistSession:a,detectSessionInUrl:o,storage:i,flowType:l,lock:u,debug:c,fetch:n,hasCustomAuthorizationHeader:"Authorization"in this.headers})}_initRealtimeClient(e){return new W(this.realtimeUrl.href,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},null===e||void 0===e?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange(((e,t)=>{this._handleTokenChanged(e,"CLIENT",null===t||void 0===t?void 0:t.access_token)}))}_handleTokenChanged(e,t,n){"TOKEN_REFRESHED"!==e&&"SIGNED_IN"!==e||this.changedAccessToken===n?"SIGNED_OUT"===e&&(this.realtime.setAuth(),"STORAGE"==t&&this.auth.signOut(),this.changedAccessToken=void 0):this.changedAccessToken=n}}(function(){if("undefined"!==typeof window||"undefined"===typeof process||void 0===process.version||null===process.version)return!1;const e=process.version.match(/^v(\d+)\./);return!!e&&parseInt(e[1],10)<=18})()&&console.warn("\u26a0\ufe0f Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");const Wt="https://jzohkzrrroxrjjomkjbg.supabase.co",Kt="sb_publishable_bsBi_9kdOMYnN374Wg8TWQ_-Pltqp4G";const Gt=new Zt(Wt,Kt,qt);var qt},7351(e,t,n){"use strict";n.d(t,{Mo:()=>h,Ny:()=>u,Up:()=>d,Wb:()=>p,XB:()=>c,nQ:()=>m});var r=n(9379);const a=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:86400,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const o={path:"/",sameSite:"Strict",secure:"https:"===window.location.protocol},i=(0,r.A)((0,r.A)({},o),a);let s="".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t));n&&(s+="; Max-Age=".concat(n)),i.path&&(s+="; Path=".concat(i.path)),i.sameSite&&(s+="; SameSite=".concat(i.sameSite)),i.secure&&(s+="; Secure"),document.cookie=s,console.log("\ud83c\udf6a Cookie set: ".concat(e," (expires in ").concat(n,"s)"))},o=e=>{const t=encodeURIComponent(e)+"=",n=document.cookie.split(";");for(let r=0;r1&&void 0!==arguments[1]?arguments[1]:{};const n=(0,r.A)((0,r.A)({},{path:"/"}),t);let a="".concat(encodeURIComponent(e),"=; Max-Age=0");n.path&&(a+="; Path=".concat(n.path)),n.domain&&(a+="; Domain=".concat(n.domain)),document.cookie=a,console.log("\ud83c\udf6a Cookie deleted: ".concat(e))},s="pendingInviteCode",l="pendingInviteProtegeId",u=(e,t)=>{a(s,e,86400),a(l,t,86400),console.log("\ud83c\udf9f\ufe0f Invite code stored in cookies for 24 hours")},c=()=>{const e=o(s),t=o(l);return e&&t?(console.log("\ud83c\udf9f\ufe0f Invite code retrieved from cookies"),{code:e,protegeId:t}):null},d=()=>{i(s),i(l),console.log("\ud83c\udf9f\ufe0f Invite code cleared from cookies")},f="pendingCouponCode",h=e=>{a(f,e.toUpperCase(),604800)},p=()=>o(f),m=()=>{i(f)}},4630(e,t,n){"use strict";n.r(t),n.d(t,{Headers:()=>i,Request:()=>s,Response:()=>l,default:()=>o,fetch:()=>a});var r=function(){if("undefined"!==typeof self)return self;if("undefined"!==typeof window)return window;if("undefined"!==typeof n.g)return n.g;throw new Error("unable to locate global object")}();const a=r.fetch,o=r.fetch.bind(r),i=r.Headers,s=r.Request,l=r.Response},9286(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(n(4630)),o=r(n(2611));t.default=class{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.isMaybeSingle=e.isMaybeSingle,e.fetch?this.fetch=e.fetch:"undefined"===typeof fetch?this.fetch=a.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=Object.assign({},this.headers),this.headers[e]=t,this}then(e,t){void 0===this.schema||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),"GET"!==this.method&&"HEAD"!==this.method&&(this.headers["Content-Type"]="application/json");let n=(0,this.fetch)(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then((async e=>{var t,n,r;let a=null,i=null,s=null,l=e.status,u=e.statusText;if(e.ok){if("HEAD"!==this.method){const t=await e.text();""===t||(i="text/csv"===this.headers.Accept||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?t:JSON.parse(t))}const r=null===(t=this.headers.Prefer)||void 0===t?void 0:t.match(/count=(exact|planned|estimated)/),o=null===(n=e.headers.get("content-range"))||void 0===n?void 0:n.split("/");r&&o&&o.length>1&&(s=parseInt(o[1])),this.isMaybeSingle&&"GET"===this.method&&Array.isArray(i)&&(i.length>1?(a={code:"PGRST116",details:"Results contain ".concat(i.length," rows, application/vnd.pgrst.object+json requires 1 row"),hint:null,message:"JSON object requested, multiple (or no) rows returned"},i=null,s=null,l=406,u="Not Acceptable"):i=1===i.length?i[0]:null)}else{const t=await e.text();try{a=JSON.parse(t),Array.isArray(a)&&404===e.status&&(i=[],a=null,l=200,u="OK")}catch(c){404===e.status&&""===t?(l=204,u="No Content"):a={message:t}}if(a&&this.isMaybeSingle&&(null===(r=null===a||void 0===a?void 0:a.details)||void 0===r?void 0:r.includes("0 rows"))&&(a=null,l=200,u="OK"),a&&this.shouldThrowOnError)throw new o.default(a)}return{error:a,data:i,count:s,status:l,statusText:u}}));return this.shouldThrowOnError||(n=n.catch((e=>{var t,n,r;return{error:{message:"".concat(null!==(t=null===e||void 0===e?void 0:e.name)&&void 0!==t?t:"FetchError",": ").concat(null===e||void 0===e?void 0:e.message),details:"".concat(null!==(n=null===e||void 0===e?void 0:e.stack)&&void 0!==n?n:""),hint:"",code:"".concat(null!==(r=null===e||void 0===e?void 0:e.code)&&void 0!==r?r:"")},data:null,count:null,status:0,statusText:""}}))),n.then(e,t)}returns(){return this}overrideTypes(){return this}}},1210(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(n(8829)),o=r(n(5736)),i=n(5745);class s{constructor(e){let{headers:t={},schema:n,fetch:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.url=e,this.headers=Object.assign(Object.assign({},i.DEFAULT_HEADERS),t),this.schemaName=n,this.fetch=r}from(e){const t=new URL("".concat(this.url,"/").concat(e));return new a.default(t,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new s(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{head:r=!1,get:a=!1,count:i}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const s=new URL("".concat(this.url,"/rpc/").concat(e));let l;r||a?(t=r?"HEAD":"GET",Object.entries(n).filter((e=>{let[t,n]=e;return void 0!==n})).map((e=>{let[t,n]=e;return[t,Array.isArray(n)?"{".concat(n.join(","),"}"):"".concat(n)]})).forEach((e=>{let[t,n]=e;s.searchParams.append(t,n)}))):(t="POST",l=n);const u=Object.assign({},this.headers);return i&&(u.Prefer="count=".concat(i)),new o.default({method:t,url:s,headers:u,schema:this.schemaName,body:l,fetch:this.fetch,allowEmpty:!1})}}t.default=s},2611(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}}t.default=n},5736(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(n(7374));class o extends a.default{eq(e,t){return this.url.searchParams.append(e,"eq.".concat(t)),this}neq(e,t){return this.url.searchParams.append(e,"neq.".concat(t)),this}gt(e,t){return this.url.searchParams.append(e,"gt.".concat(t)),this}gte(e,t){return this.url.searchParams.append(e,"gte.".concat(t)),this}lt(e,t){return this.url.searchParams.append(e,"lt.".concat(t)),this}lte(e,t){return this.url.searchParams.append(e,"lte.".concat(t)),this}like(e,t){return this.url.searchParams.append(e,"like.".concat(t)),this}likeAllOf(e,t){return this.url.searchParams.append(e,"like(all).{".concat(t.join(","),"}")),this}likeAnyOf(e,t){return this.url.searchParams.append(e,"like(any).{".concat(t.join(","),"}")),this}ilike(e,t){return this.url.searchParams.append(e,"ilike.".concat(t)),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,"ilike(all).{".concat(t.join(","),"}")),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,"ilike(any).{".concat(t.join(","),"}")),this}is(e,t){return this.url.searchParams.append(e,"is.".concat(t)),this}in(e,t){const n=Array.from(new Set(t)).map((e=>"string"===typeof e&&new RegExp("[,()]").test(e)?'"'.concat(e,'"'):"".concat(e))).join(",");return this.url.searchParams.append(e,"in.(".concat(n,")")),this}contains(e,t){return"string"===typeof t?this.url.searchParams.append(e,"cs.".concat(t)):Array.isArray(t)?this.url.searchParams.append(e,"cs.{".concat(t.join(","),"}")):this.url.searchParams.append(e,"cs.".concat(JSON.stringify(t))),this}containedBy(e,t){return"string"===typeof t?this.url.searchParams.append(e,"cd.".concat(t)):Array.isArray(t)?this.url.searchParams.append(e,"cd.{".concat(t.join(","),"}")):this.url.searchParams.append(e,"cd.".concat(JSON.stringify(t))),this}rangeGt(e,t){return this.url.searchParams.append(e,"sr.".concat(t)),this}rangeGte(e,t){return this.url.searchParams.append(e,"nxl.".concat(t)),this}rangeLt(e,t){return this.url.searchParams.append(e,"sl.".concat(t)),this}rangeLte(e,t){return this.url.searchParams.append(e,"nxr.".concat(t)),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,"adj.".concat(t)),this}overlaps(e,t){return"string"===typeof t?this.url.searchParams.append(e,"ov.".concat(t)):this.url.searchParams.append(e,"ov.{".concat(t.join(","),"}")),this}textSearch(e,t){let{config:n,type:r}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a="";"plain"===r?a="pl":"phrase"===r?a="ph":"websearch"===r&&(a="w");const o=void 0===n?"":"(".concat(n,")");return this.url.searchParams.append(e,"".concat(a,"fts").concat(o,".").concat(t)),this}match(e){return Object.entries(e).forEach((e=>{let[t,n]=e;this.url.searchParams.append(t,"eq.".concat(n))})),this}not(e,t,n){return this.url.searchParams.append(e,"not.".concat(t,".").concat(n)),this}or(e){let{foreignTable:t,referencedTable:n=t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=n?"".concat(n,".or"):"or";return this.url.searchParams.append(r,"(".concat(e,")")),this}filter(e,t,n){return this.url.searchParams.append(e,"".concat(t,".").concat(n)),this}}t.default=o},8829(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(n(5736));t.default=class{constructor(e,t){let{headers:n={},schema:r,fetch:a}=t;this.url=e,this.headers=n,this.schema=r,this.fetch=a}select(e){let{head:t=!1,count:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=t?"HEAD":"GET";let o=!1;const i=(null!==e&&void 0!==e?e:"*").split("").map((e=>/\s/.test(e)&&!o?"":('"'===e&&(o=!o),e))).join("");return this.url.searchParams.set("select",i),n&&(this.headers.Prefer="count=".concat(n)),new a.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e){let{count:t,defaultToNull:n=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=[];if(this.headers.Prefer&&r.push(this.headers.Prefer),t&&r.push("count=".concat(t)),n||r.push("missing=default"),this.headers.Prefer=r.join(","),Array.isArray(e)){const t=e.reduce(((e,t)=>e.concat(Object.keys(t))),[]);if(t.length>0){const e=[...new Set(t)].map((e=>'"'.concat(e,'"')));this.url.searchParams.set("columns",e.join(","))}}return new a.default({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}upsert(e){let{onConflict:t,ignoreDuplicates:n=!1,count:r,defaultToNull:o=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=["resolution=".concat(n?"ignore":"merge","-duplicates")];if(void 0!==t&&this.url.searchParams.set("on_conflict",t),this.headers.Prefer&&i.push(this.headers.Prefer),r&&i.push("count=".concat(r)),o||i.push("missing=default"),this.headers.Prefer=i.join(","),Array.isArray(e)){const t=e.reduce(((e,t)=>e.concat(Object.keys(t))),[]);if(t.length>0){const e=[...new Set(t)].map((e=>'"'.concat(e,'"')));this.url.searchParams.set("columns",e.join(","))}}return new a.default({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}update(e){let{count:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=[];return this.headers.Prefer&&n.push(this.headers.Prefer),t&&n.push("count=".concat(t)),this.headers.Prefer=n.join(","),new a.default({method:"PATCH",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}delete(){let{count:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=[];return e&&t.push("count=".concat(e)),this.headers.Prefer&&t.unshift(this.headers.Prefer),this.headers.Prefer=t.join(","),new a.default({method:"DELETE",url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}}},7374(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(n(9286));class o extends a.default{select(e){let t=!1;const n=(null!==e&&void 0!==e?e:"*").split("").map((e=>/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e))).join("");return this.url.searchParams.set("select",n),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e){let{ascending:t=!0,nullsFirst:n,foreignTable:r,referencedTable:a=r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=a?"".concat(a,".order"):"order",i=this.url.searchParams.get(o);return this.url.searchParams.set(o,"".concat(i?"".concat(i,","):"").concat(e,".").concat(t?"asc":"desc").concat(void 0===n?"":n?".nullsfirst":".nullslast")),this}limit(e){let{foreignTable:t,referencedTable:n=t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r="undefined"===typeof n?"limit":"".concat(n,".limit");return this.url.searchParams.set(r,"".concat(e)),this}range(e,t){let{foreignTable:n,referencedTable:r=n}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const a="undefined"===typeof r?"offset":"".concat(r,".offset"),o="undefined"===typeof r?"limit":"".concat(r,".limit");return this.url.searchParams.set(a,"".concat(e)),this.url.searchParams.set(o,"".concat(t-e+1)),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return"GET"===this.method?this.headers.Accept="application/json":this.headers.Accept="application/vnd.pgrst.object+json",this.isMaybeSingle=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain(){let{analyze:e=!1,verbose:t=!1,settings:n=!1,buffers:r=!1,wal:a=!1,format:o="text"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var i;const s=[e?"analyze":null,t?"verbose":null,n?"settings":null,r?"buffers":null,a?"wal":null].filter(Boolean).join("|"),l=null!==(i=this.headers.Accept)&&void 0!==i?i:"application/json";return this.headers.Accept="application/vnd.pgrst.plan+".concat(o,'; for="').concat(l,'"; options=').concat(s,";"),this}rollback(){var e;return(null!==(e=this.headers.Prefer)&&void 0!==e?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}}t.default=o},5745(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_HEADERS=void 0;const r=n(400);t.DEFAULT_HEADERS={"X-Client-Info":"postgrest-js/".concat(r.version)}},7980(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PostgrestError=t.PostgrestBuilder=t.PostgrestTransformBuilder=t.PostgrestFilterBuilder=t.PostgrestQueryBuilder=t.PostgrestClient=void 0;const a=r(n(1210));t.PostgrestClient=a.default;const o=r(n(8829));t.PostgrestQueryBuilder=o.default;const i=r(n(5736));t.PostgrestFilterBuilder=i.default;const s=r(n(7374));t.PostgrestTransformBuilder=s.default;const l=r(n(9286));t.PostgrestBuilder=l.default;const u=r(n(2611));t.PostgrestError=u.default,t.default={PostgrestClient:a.default,PostgrestQueryBuilder:o.default,PostgrestFilterBuilder:i.default,PostgrestTransformBuilder:s.default,PostgrestBuilder:l.default,PostgrestError:u.default}},400(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version=void 0,t.version="0.0.0-automated"},2740(e){"use strict";e.exports=function(e,t,n,r,a,o,i,s){if(!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[n,r,a,o,i,s],c=0;(l=new Error(t.replace(/%s/g,(function(){return u[c++]})))).name="Invariant Violation"}throw l.framesToPop=1,l}}},7004(e,t,n){"use strict";var r=n(8853),a=n(5043),o=n(7950);function i(e){var t="https://react.dev/errors/"+e;if(1$||(e.current=D[$],D[$]=null,$--)}function B(e,t){$++,D[$]=e.current,e.current=t}var z=F(null),H=F(null),Z=F(null),W=F(null);function K(e,t){switch(B(Z,t),B(H,e),B(z,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?ad(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)e=od(t=ad(t),e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}U(z),B(z,e)}function G(){U(z),U(H),U(Z)}function q(e){null!==e.memoizedState&&B(W,e);var t=z.current,n=od(t,e.type);t!==n&&(B(H,e),B(z,n))}function V(e){H.current===e&&(U(z),U(H)),W.current===e&&(U(W),qd._currentValue=I)}var Y=Object.prototype.hasOwnProperty,Q=r.unstable_scheduleCallback,J=r.unstable_cancelCallback,X=r.unstable_shouldYield,ee=r.unstable_requestPaint,te=r.unstable_now,ne=r.unstable_getCurrentPriorityLevel,re=r.unstable_ImmediatePriority,ae=r.unstable_UserBlockingPriority,oe=r.unstable_NormalPriority,ie=r.unstable_LowPriority,se=r.unstable_IdlePriority,le=r.log,ue=r.unstable_setDisableYieldValue,ce=null,de=null;function fe(e){if("function"===typeof le&&ue(e),de&&"function"===typeof de.setStrictMode)try{de.setStrictMode(ce,e)}catch(t){}}var he=Math.clz32?Math.clz32:function(e){return 0===(e>>>=0)?32:31-(pe(e)/me|0)|0},pe=Math.log,me=Math.LN2;var ge=256,ve=4194304;function ye(e){var t=42&e;if(0!==t)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return 4194048&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function be(e,t,n){var r=e.pendingLanes;if(0===r)return 0;var a=0,o=e.suspendedLanes,i=e.pingedLanes;e=e.warmLanes;var s=134217727&r;return 0!==s?0!==(r=s&~o)?a=ye(r):0!==(i&=s)?a=ye(i):n||0!==(n=s&~e)&&(a=ye(n)):0!==(s=r&~o)?a=ye(s):0!==i?a=ye(i):n||0!==(n=r&~e)&&(a=ye(n)),0===a?0:0!==t&&t!==a&&0===(t&o)&&((o=a&-a)>=(n=t&-t)||32===o&&0!==(4194048&n))?t:a}function we(e,t){return 0===(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)}function _e(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;default:return-1}}function Se(){var e=ge;return 0===(4194048&(ge<<=1))&&(ge=256),e}function xe(){var e=ve;return 0===(62914560&(ve<<=1))&&(ve=4194304),e}function ke(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ae(e,t){e.pendingLanes|=t,268435456!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ee(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-he(t);e.entangledLanes|=t,e.entanglements[r]=1073741824|e.entanglements[r]|4194090&n}function Ce(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-he(n),a=1<)":-1--a||l[r]!==u[a]){var c="\n"+l[r].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}}while(1<=r&&0<=a);break}}}finally{ot=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?at(n):""}function st(e){switch(e.tag){case 26:case 27:case 5:return at(e.type);case 16:return at("Lazy");case 13:return at("Suspense");case 19:return at("SuspenseList");case 0:case 15:return it(e.type,!1);case 11:return it(e.type.render,!1);case 1:return it(e.type,!0);case 31:return at("Activity");default:return""}}function lt(e){try{var t="";do{t+=st(e),e=e.return}while(e);return t}catch(n){return"\nError generating stack: "+n.message+"\n"+n.stack}}function ut(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function ct(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function dt(e){e._valueTracker||(e._valueTracker=function(e){var t=ct(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&"undefined"!==typeof n&&"function"===typeof n.get&&"function"===typeof n.set){var a=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(e){r=""+e,o.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e))}function ft(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=ct(e)?e.checked?"true":"false":e.value),(e=r)!==n&&(t.setValue(e),!0)}function ht(e){if("undefined"===typeof(e=e||("undefined"!==typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}var pt=/[\n"\\]/g;function mt(e){return e.replace(pt,(function(e){return"\\"+e.charCodeAt(0).toString(16)+" "}))}function gt(e,t,n,r,a,o,i,s){e.name="",null!=i&&"function"!==typeof i&&"symbol"!==typeof i&&"boolean"!==typeof i?e.type=i:e.removeAttribute("type"),null!=t?"number"===i?(0===t&&""===e.value||e.value!=t)&&(e.value=""+ut(t)):e.value!==""+ut(t)&&(e.value=""+ut(t)):"submit"!==i&&"reset"!==i||e.removeAttribute("value"),null!=t?yt(e,i,ut(t)):null!=n?yt(e,i,ut(n)):null!=r&&e.removeAttribute("value"),null==a&&null!=o&&(e.defaultChecked=!!o),null!=a&&(e.checked=a&&"function"!==typeof a&&"symbol"!==typeof a),null!=s&&"function"!==typeof s&&"symbol"!==typeof s&&"boolean"!==typeof s?e.name=""+ut(s):e.removeAttribute("name")}function vt(e,t,n,r,a,o,i,s){if(null!=o&&"function"!==typeof o&&"symbol"!==typeof o&&"boolean"!==typeof o&&(e.type=o),null!=t||null!=n){if(!("submit"!==o&&"reset"!==o||void 0!==t&&null!==t))return;n=null!=n?""+ut(n):"",t=null!=t?""+ut(t):n,s||t===e.value||(e.value=t),e.defaultValue=t}r="function"!==typeof(r=null!=r?r:a)&&"symbol"!==typeof r&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,null!=i&&"function"!==typeof i&&"symbol"!==typeof i&&"boolean"!==typeof i&&(e.name=i)}function yt(e,t,n){"number"===t&&ht(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function bt(e,t,n,r){if(e=e.options,t){t={};for(var a=0;a=xn),En=String.fromCharCode(32),Cn=!1;function Tn(e,t){switch(e){case"keyup":return-1!==_n.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Pn(e){return"object"===typeof(e=e.detail)&&"data"in e?e.data:null}var jn=!1;var On={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Nn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!On[e.type]:"textarea"===t}function Rn(e,t,n,r){Nt?Rt?Rt.push(r):Rt=[r]:Nt=r,0<(t=Zc(t,"onChange")).length&&(n=new Xt("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Ln=null,Mn=null;function In(e){Ic(e,0)}function Dn(e){if(ft(He(e)))return e}function $n(e,t){if("change"===e)return t}var Fn=!1;if($t){var Un;if($t){var Bn="oninput"in document;if(!Bn){var zn=document.createElement("div");zn.setAttribute("oninput","return;"),Bn="function"===typeof zn.oninput}Un=Bn}else Un=!1;Fn=Un&&(!document.documentMode||9=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=Qn(r)}}function Xn(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?Xn(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function er(e){for(var t=ht((e=null!=e&&null!=e.ownerDocument&&null!=e.ownerDocument.defaultView?e.ownerDocument.defaultView:window).document);t instanceof e.HTMLIFrameElement;){try{var n="string"===typeof t.contentWindow.location.href}catch(r){n=!1}if(!n)break;t=ht((e=t.contentWindow).document)}return t}function tr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}var nr=$t&&"documentMode"in document&&11>=document.documentMode,rr=null,ar=null,or=null,ir=!1;function sr(e,t,n){var r=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;ir||null==rr||rr!==ht(r)||("selectionStart"in(r=rr)&&tr(r)?r={start:r.selectionStart,end:r.selectionEnd}:r={anchorNode:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset},or&&Yn(or,r)||(or=r,0<(r=Zc(ar,"onSelect")).length&&(t=new Xt("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=rr)))}function lr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var ur={animationend:lr("Animation","AnimationEnd"),animationiteration:lr("Animation","AnimationIteration"),animationstart:lr("Animation","AnimationStart"),transitionrun:lr("Transition","TransitionRun"),transitionstart:lr("Transition","TransitionStart"),transitioncancel:lr("Transition","TransitionCancel"),transitionend:lr("Transition","TransitionEnd")},cr={},dr={};function fr(e){if(cr[e])return cr[e];if(!ur[e])return e;var t,n=ur[e];for(t in n)if(n.hasOwnProperty(t)&&t in dr)return cr[e]=n[t];return e}$t&&(dr=document.createElement("div").style,"AnimationEvent"in window||(delete ur.animationend.animation,delete ur.animationiteration.animation,delete ur.animationstart.animation),"TransitionEvent"in window||delete ur.transitionend.transition);var hr=fr("animationend"),pr=fr("animationiteration"),mr=fr("animationstart"),gr=fr("transitionrun"),vr=fr("transitionstart"),yr=fr("transitioncancel"),br=fr("transitionend"),wr=new Map,_r="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Sr(e,t){wr.set(e,t),qe(t,[e])}_r.push("scrollEnd");var xr=new WeakMap;function kr(e,t){if("object"===typeof e&&null!==e){var n=xr.get(e);return void 0!==n?n:(t={value:e,source:t,stack:lt(t)},xr.set(e,t),t)}return{value:e,source:t,stack:lt(t)}}var Ar=[],Er=0,Cr=0;function Tr(){for(var e=Er,t=Cr=Er=0;t>=i,a-=i,Qr=1<<32-he(t)+a|n<o?o:8;var i=L.T,s={};L.T=s,Bi(e,!1,t,n);try{var l=a(),u=L.S;if(null!==u&&u(s,l),null!==l&&"object"===typeof l&&"function"===typeof l.then)Ui(e,t,function(e,t){var n=[],r={status:"pending",value:null,reason:null,then:function(e){n.push(e)}};return e.then((function(){r.status="fulfilled",r.value=t;for(var e=0;ep?(m=d,d=null):m=d.sibling;var g=h(a,d,s[p],l);if(null===g){null===d&&(d=m);break}e&&d&&null===g.alternate&&t(a,d),i=o(g,i,p),null===c?u=g:c.sibling=g,c=g,d=m}if(p===s.length)return n(a,d),oa&&Xr(a,p),u;if(null===d){for(;pm?(g=p,p=null):g=p.sibling;var b=h(a,p,y.value,u);if(null===b){null===p&&(p=g);break}e&&p&&null===b.alternate&&t(a,p),s=o(b,s,m),null===d?c=b:d.sibling=b,d=b,p=g}if(y.done)return n(a,p),oa&&Xr(a,m),c;if(null===p){for(;!y.done;m++,y=l.next())null!==(y=f(a,y.value,u))&&(s=o(y,s,m),null===d?c=y:d.sibling=y,d=y);return oa&&Xr(a,m),c}for(p=r(p);!y.done;m++,y=l.next())null!==(y=v(p,a,m,y.value,u))&&(e&&null!==y.alternate&&p.delete(null===y.key?m:y.key),s=o(y,s,m),null===d?c=y:d.sibling=y,d=y);return e&&p.forEach((function(e){return t(a,e)})),oa&&Xr(a,m),c}(l,u,c=b.call(c),d)}if("function"===typeof c.then)return y(l,u,Qi(c),d);if(c.$$typeof===_)return y(l,u,Ca(l,c),d);Xi(l,c)}return"string"===typeof c&&""!==c||"number"===typeof c||"bigint"===typeof c?(c=""+c,null!==u&&6===u.tag?(n(l,u.sibling),(d=a(u,c)).return=l,l=d):(n(l,u),(d=zr(c,l.mode,d)).return=l,l=d),s(l)):n(l,u)}return function(e,t,n,r){try{Yi=0;var a=y(e,t,n,r);return Vi=null,a}catch(i){if(i===Wa||i===Ga)throw i;var o=Ir(29,i,null,e.mode);return o.lanes=r,o.return=e,o}}}var ns=ts(!0),rs=ts(!1),as=F(null),os=null;function is(e){var t=e.alternate;B(cs,1&cs.current),B(as,e),null===os&&(null===t||null!==po.current||null!==t.memoizedState)&&(os=e)}function ss(e){if(22===e.tag){if(B(cs,cs.current),B(as,e),null===os){var t=e.alternate;null!==t&&null!==t.memoizedState&&(os=e)}}else ls()}function ls(){B(cs,cs.current),B(as,as.current)}function us(e){U(as),os===e&&(os=null),U(cs)}var cs=F(0);function ds(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||"$?"===n.data||gd(n)))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(0!==(128&t.flags))return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}function fs(e,t,n,r){n=null===(n=n(r,t=e.memoizedState))||void 0===n?t:f({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}var hs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Lu(),a=ao(r);a.payload=t,void 0!==n&&null!==n&&(a.callback=n),null!==(t=oo(e,a,r))&&(Iu(t,e,r),io(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Lu(),a=ao(r);a.tag=1,a.payload=t,void 0!==n&&null!==n&&(a.callback=n),null!==(t=oo(e,a,r))&&(Iu(t,e,r),io(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Lu(),r=ao(n);r.tag=2,void 0!==t&&null!==t&&(r.callback=t),null!==(t=oo(e,r,n))&&(Iu(t,e,n),io(t,e,n))}};function ps(e,t,n,r,a,o,i){return"function"===typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,o,i):!t.prototype||!t.prototype.isPureReactComponent||(!Yn(n,r)||!Yn(a,o))}function ms(e,t,n,r){e=t.state,"function"===typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,r),"function"===typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&hs.enqueueReplaceState(t,t.state,null)}function gs(e,t){var n=t;if("ref"in t)for(var r in n={},t)"ref"!==r&&(n[r]=t[r]);if(e=e.defaultProps)for(var a in n===t&&(n=f({},n)),e)void 0===n[a]&&(n[a]=e[a]);return n}var vs="function"===typeof reportError?reportError:function(e){if("object"===typeof window&&"function"===typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"===typeof e&&null!==e&&"string"===typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"===typeof process&&"function"===typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)};function ys(e){vs(e)}function bs(e){console.error(e)}function ws(e){vs(e)}function _s(e,t){try{(0,e.onUncaughtError)(t.value,{componentStack:t.stack})}catch(n){setTimeout((function(){throw n}))}}function Ss(e,t,n){try{(0,e.onCaughtError)(n.value,{componentStack:n.stack,errorBoundary:1===t.tag?t.stateNode:null})}catch(r){setTimeout((function(){throw r}))}}function xs(e,t,n){return(n=ao(n)).tag=3,n.payload={element:null},n.callback=function(){_s(e,t)},n}function ks(e){return(e=ao(e)).tag=3,e}function As(e,t,n,r){var a=n.type.getDerivedStateFromError;if("function"===typeof a){var o=r.value;e.payload=function(){return a(o)},e.callback=function(){Ss(t,n,r)}}var i=n.stateNode;null!==i&&"function"===typeof i.componentDidCatch&&(e.callback=function(){Ss(t,n,r),"function"!==typeof a&&(null===ku?ku=new Set([this]):ku.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:null!==e?e:""})})}var Es=Error(i(461)),Cs=!1;function Ts(e,t,n,r){t.child=null===e?rs(t,null,n,r):ns(t,e.child,n,r)}function Ps(e,t,n,r,a){n=n.render;var o=t.ref;if("ref"in r){var i={};for(var s in r)"ref"!==s&&(i[s]=r[s])}else i=r;return Aa(t),r=No(e,t,n,i,o,a),s=Io(),null===e||Cs?(oa&&s&&ta(t),t.flags|=1,Ts(e,t,r,a),t.child):(Do(e,t,a),Vs(e,t,a))}function js(e,t,n,r,a){if(null===e){var o=n.type;return"function"!==typeof o||Dr(o)||void 0!==o.defaultProps||null!==n.compare?((e=Ur(n.type,null,r,t,t.mode,a)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=o,Os(e,t,o,r,a))}if(o=e.child,!Ys(e,a)){var i=o.memoizedProps;if((n=null!==(n=n.compare)?n:Yn)(i,r)&&e.ref===t.ref)return Vs(e,t,a)}return t.flags|=1,(e=$r(o,r)).ref=t.ref,e.return=t,t.child=e}function Os(e,t,n,r,a){if(null!==e){var o=e.memoizedProps;if(Yn(o,r)&&e.ref===t.ref){if(Cs=!1,t.pendingProps=r=o,!Ys(e,a))return t.lanes=e.lanes,Vs(e,t,a);0!==(131072&e.flags)&&(Cs=!0)}}return Ms(e,t,n,r,a)}function Ns(e,t,n){var r=t.pendingProps,a=r.children,o=null!==e?e.memoizedState:null;if("hidden"===r.mode){if(0!==(128&t.flags)){if(r=null!==o?o.baseLanes|n:n,null!==e){for(a=t.child=e.child,o=0;null!==a;)o=o|a.lanes|a.childLanes,a=a.sibling;t.childLanes=o&~r}else t.childLanes=0,t.child=null;return Rs(e,t,r,n)}if(0===(536870912&n))return t.lanes=t.childLanes=536870912,Rs(e,t,null!==o?o.baseLanes|n:n,n);t.memoizedState={baseLanes:0,cachePool:null},null!==e&&Ha(0,null!==o?o.cachePool:null),null!==o?go(t,o):vo(),ss(t)}else null!==o?(Ha(0,o.cachePool),go(t,o),ls(),t.memoizedState=null):(null!==e&&Ha(0,null),vo(),ls());return Ts(e,t,a,n),t.child}function Rs(e,t,n,r){var a=za();return a=null===a?null:{parent:Na._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},null!==e&&Ha(0,null),vo(),ss(t),null!==e&&xa(e,t,r,!0),null}function Ls(e,t){var n=t.ref;if(null===n)null!==e&&null!==e.ref&&(t.flags|=4194816);else{if("function"!==typeof n&&"object"!==typeof n)throw Error(i(284));null!==e&&e.ref===n||(t.flags|=4194816)}}function Ms(e,t,n,r,a){return Aa(t),n=No(e,t,n,r,void 0,a),r=Io(),null===e||Cs?(oa&&r&&ta(t),t.flags|=1,Ts(e,t,n,a),t.child):(Do(e,t,a),Vs(e,t,a))}function Is(e,t,n,r,a,o){return Aa(t),t.updateQueue=null,n=Lo(t,r,n,a),Ro(e),r=Io(),null===e||Cs?(oa&&r&&ta(t),t.flags|=1,Ts(e,t,n,o),t.child):(Do(e,t,o),Vs(e,t,o))}function Ds(e,t,n,r,a){if(Aa(t),null===t.stateNode){var o=Lr,i=n.contextType;"object"===typeof i&&null!==i&&(o=Ea(i)),o=new n(r,o),t.memoizedState=null!==o.state&&void 0!==o.state?o.state:null,o.updater=hs,t.stateNode=o,o._reactInternals=t,(o=t.stateNode).props=r,o.state=t.memoizedState,o.refs={},no(t),i=n.contextType,o.context="object"===typeof i&&null!==i?Ea(i):Lr,o.state=t.memoizedState,"function"===typeof(i=n.getDerivedStateFromProps)&&(fs(t,n,i,r),o.state=t.memoizedState),"function"===typeof n.getDerivedStateFromProps||"function"===typeof o.getSnapshotBeforeUpdate||"function"!==typeof o.UNSAFE_componentWillMount&&"function"!==typeof o.componentWillMount||(i=o.state,"function"===typeof o.componentWillMount&&o.componentWillMount(),"function"===typeof o.UNSAFE_componentWillMount&&o.UNSAFE_componentWillMount(),i!==o.state&&hs.enqueueReplaceState(o,o.state,null),co(t,r,o,a),uo(),o.state=t.memoizedState),"function"===typeof o.componentDidMount&&(t.flags|=4194308),r=!0}else if(null===e){o=t.stateNode;var s=t.memoizedProps,l=gs(n,s);o.props=l;var u=o.context,c=n.contextType;i=Lr,"object"===typeof c&&null!==c&&(i=Ea(c));var d=n.getDerivedStateFromProps;c="function"===typeof d||"function"===typeof o.getSnapshotBeforeUpdate,s=t.pendingProps!==s,c||"function"!==typeof o.UNSAFE_componentWillReceiveProps&&"function"!==typeof o.componentWillReceiveProps||(s||u!==i)&&ms(t,o,r,i),to=!1;var f=t.memoizedState;o.state=f,co(t,r,o,a),uo(),u=t.memoizedState,s||f!==u||to?("function"===typeof d&&(fs(t,n,d,r),u=t.memoizedState),(l=to||ps(t,n,l,r,f,u,i))?(c||"function"!==typeof o.UNSAFE_componentWillMount&&"function"!==typeof o.componentWillMount||("function"===typeof o.componentWillMount&&o.componentWillMount(),"function"===typeof o.UNSAFE_componentWillMount&&o.UNSAFE_componentWillMount()),"function"===typeof o.componentDidMount&&(t.flags|=4194308)):("function"===typeof o.componentDidMount&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=u),o.props=r,o.state=u,o.context=i,r=l):("function"===typeof o.componentDidMount&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,ro(e,t),c=gs(n,i=t.memoizedProps),o.props=c,d=t.pendingProps,f=o.context,u=n.contextType,l=Lr,"object"===typeof u&&null!==u&&(l=Ea(u)),(u="function"===typeof(s=n.getDerivedStateFromProps)||"function"===typeof o.getSnapshotBeforeUpdate)||"function"!==typeof o.UNSAFE_componentWillReceiveProps&&"function"!==typeof o.componentWillReceiveProps||(i!==d||f!==l)&&ms(t,o,r,l),to=!1,f=t.memoizedState,o.state=f,co(t,r,o,a),uo();var h=t.memoizedState;i!==d||f!==h||to||null!==e&&null!==e.dependencies&&ka(e.dependencies)?("function"===typeof s&&(fs(t,n,s,r),h=t.memoizedState),(c=to||ps(t,n,c,r,f,h,l)||null!==e&&null!==e.dependencies&&ka(e.dependencies))?(u||"function"!==typeof o.UNSAFE_componentWillUpdate&&"function"!==typeof o.componentWillUpdate||("function"===typeof o.componentWillUpdate&&o.componentWillUpdate(r,h,l),"function"===typeof o.UNSAFE_componentWillUpdate&&o.UNSAFE_componentWillUpdate(r,h,l)),"function"===typeof o.componentDidUpdate&&(t.flags|=4),"function"===typeof o.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!==typeof o.componentDidUpdate||i===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),"function"!==typeof o.getSnapshotBeforeUpdate||i===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=h),o.props=r,o.state=h,o.context=l,r=c):("function"!==typeof o.componentDidUpdate||i===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),"function"!==typeof o.getSnapshotBeforeUpdate||i===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return o=r,Ls(e,t),r=0!==(128&t.flags),o||r?(o=t.stateNode,n=r&&"function"!==typeof n.getDerivedStateFromError?null:o.render(),t.flags|=1,null!==e&&r?(t.child=ns(t,e.child,null,a),t.child=ns(t,null,n,a)):Ts(e,t,n,a),t.memoizedState=o.state,e=t.child):e=Vs(e,t,a),e}function $s(e,t,n,r){return ha(),t.flags|=256,Ts(e,t,n,r),t.child}var Fs={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Us(e){return{baseLanes:e,cachePool:Za()}}function Bs(e,t,n){return e=null!==e?e.childLanes&~n:0,t&&(e|=gu),e}function zs(e,t,n){var r,a=t.pendingProps,o=!1,s=0!==(128&t.flags);if((r=s)||(r=(null===e||null!==e.memoizedState)&&0!==(2&cs.current)),r&&(o=!0,t.flags&=-129),r=0!==(32&t.flags),t.flags&=-33,null===e){if(oa){if(o?is(t):ls(),oa){var l,u=aa;if(l=u){e:{for(l=u,u=sa;8!==l.nodeType;){if(!u){u=null;break e}if(null===(l=vd(l.nextSibling))){u=null;break e}}u=l}null!==u?(t.memoizedState={dehydrated:u,treeContext:null!==Yr?{id:Qr,overflow:Jr}:null,retryLane:536870912,hydrationErrors:null},(l=Ir(18,null,null,0)).stateNode=u,l.return=t,t.child=l,ra=t,aa=null,l=!0):l=!1}l||ua(t)}if(null!==(u=t.memoizedState)&&null!==(u=u.dehydrated))return gd(u)?t.lanes=32:t.lanes=536870912,null;us(t)}return u=a.children,a=a.fallback,o?(ls(),u=Zs({mode:"hidden",children:u},o=t.mode),a=Br(a,o,n,null),u.return=t,a.return=t,u.sibling=a,t.child=u,(o=t.child).memoizedState=Us(n),o.childLanes=Bs(e,r,n),t.memoizedState=Fs,a):(is(t),Hs(t,u))}if(null!==(l=e.memoizedState)&&null!==(u=l.dehydrated)){if(s)256&t.flags?(is(t),t.flags&=-257,t=Ws(e,t,n)):null!==t.memoizedState?(ls(),t.child=e.child,t.flags|=128,t=null):(ls(),o=a.fallback,u=t.mode,a=Zs({mode:"visible",children:a.children},u),(o=Br(o,u,n,null)).flags|=2,a.return=t,o.return=t,a.sibling=o,t.child=a,ns(t,e.child,null,n),(a=t.child).memoizedState=Us(n),a.childLanes=Bs(e,r,n),t.memoizedState=Fs,t=o);else if(is(t),gd(u)){if(r=u.nextSibling&&u.nextSibling.dataset)var c=r.dgst;r=c,(a=Error(i(419))).stack="",a.digest=r,ma({value:a,source:null,stack:null}),t=Ws(e,t,n)}else if(Cs||xa(e,t,n,!1),r=0!==(n&e.childLanes),Cs||r){if(null!==(r=ru)&&(0!==(a=0!==((a=0!==(42&(a=n&-n))?1:Te(a))&(r.suspendedLanes|n))?0:a)&&a!==l.retryLane))throw l.retryLane=a,Or(e,a),Iu(r,e,a),Es;"$?"===u.data||Gu(),t=Ws(e,t,n)}else"$?"===u.data?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,aa=vd(u.nextSibling),ra=t,oa=!0,ia=null,sa=!1,null!==e&&(qr[Vr++]=Qr,qr[Vr++]=Jr,qr[Vr++]=Yr,Qr=e.id,Jr=e.overflow,Yr=t),(t=Hs(t,a.children)).flags|=4096);return t}return o?(ls(),o=a.fallback,u=t.mode,c=(l=e.child).sibling,(a=$r(l,{mode:"hidden",children:a.children})).subtreeFlags=65011712&l.subtreeFlags,null!==c?o=$r(c,o):(o=Br(o,u,n,null)).flags|=2,o.return=t,a.return=t,a.sibling=o,t.child=a,a=o,o=t.child,null===(u=e.child.memoizedState)?u=Us(n):(null!==(l=u.cachePool)?(c=Na._currentValue,l=l.parent!==c?{parent:c,pool:c}:l):l=Za(),u={baseLanes:u.baseLanes|n,cachePool:l}),o.memoizedState=u,o.childLanes=Bs(e,r,n),t.memoizedState=Fs,a):(is(t),e=(n=e.child).sibling,(n=$r(n,{mode:"visible",children:a.children})).return=t,n.sibling=null,null!==e&&(null===(r=t.deletions)?(t.deletions=[e],t.flags|=16):r.push(e)),t.child=n,t.memoizedState=null,n)}function Hs(e,t){return(t=Zs({mode:"visible",children:t},e.mode)).return=e,e.child=t}function Zs(e,t){return(e=Ir(22,e,null,t)).lanes=0,e.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null},e}function Ws(e,t,n){return ns(t,e.child,null,n),(e=Hs(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function Ks(e,t,n){e.lanes|=t;var r=e.alternate;null!==r&&(r.lanes|=t),_a(e.return,t,n)}function Gs(e,t,n,r,a){var o=e.memoizedState;null===o?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=a)}function qs(e,t,n){var r=t.pendingProps,a=r.revealOrder,o=r.tail;if(Ts(e,t,r.children,n),0!==(2&(r=cs.current)))r=1&r|2,t.flags|=128;else{if(null!==e&&0!==(128&e.flags))e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&Ks(e,n,t);else if(19===e.tag)Ks(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}switch(B(cs,r),a){case"forwards":for(n=t.child,a=null;null!==n;)null!==(e=n.alternate)&&null===ds(e)&&(a=n),n=n.sibling;null===(n=a)?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),Gs(t,!1,a,n,o);break;case"backwards":for(n=null,a=t.child,t.child=null;null!==a;){if(null!==(e=a.alternate)&&null===ds(e)){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}Gs(t,!0,n,null,o);break;case"together":Gs(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Vs(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),hu|=t.lanes,0===(n&t.childLanes)){if(null===e)return null;if(xa(e,t,n,!1),0===(n&t.childLanes))return null}if(null!==e&&t.child!==e.child)throw Error(i(153));if(null!==t.child){for(n=$r(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=$r(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function Ys(e,t){return 0!==(e.lanes&t)||!(null===(e=e.dependencies)||!ka(e))}function Qs(e,t,n){if(null!==e)if(e.memoizedProps!==t.pendingProps)Cs=!0;else{if(!Ys(e,n)&&0===(128&t.flags))return Cs=!1,function(e,t,n){switch(t.tag){case 3:K(t,t.stateNode.containerInfo),ba(0,Na,e.memoizedState.cache),ha();break;case 27:case 5:q(t);break;case 4:K(t,t.stateNode.containerInfo);break;case 10:ba(0,t.type,t.memoizedProps.value);break;case 13:var r=t.memoizedState;if(null!==r)return null!==r.dehydrated?(is(t),t.flags|=128,null):0!==(n&t.child.childLanes)?zs(e,t,n):(is(t),null!==(e=Vs(e,t,n))?e.sibling:null);is(t);break;case 19:var a=0!==(128&e.flags);if((r=0!==(n&t.childLanes))||(xa(e,t,n,!1),r=0!==(n&t.childLanes)),a){if(r)return qs(e,t,n);t.flags|=128}if(null!==(a=t.memoizedState)&&(a.rendering=null,a.tail=null,a.lastEffect=null),B(cs,cs.current),r)break;return null;case 22:case 23:return t.lanes=0,Ns(e,t,n);case 24:ba(0,Na,e.memoizedState.cache)}return Vs(e,t,n)}(e,t,n);Cs=0!==(131072&e.flags)}else Cs=!1,oa&&0!==(1048576&t.flags)&&ea(t,Gr,t.index);switch(t.lanes=0,t.tag){case 16:e:{e=t.pendingProps;var r=t.elementType,a=r._init;if(r=a(r._payload),t.type=r,"function"!==typeof r){if(void 0!==r&&null!==r){if((a=r.$$typeof)===S){t.tag=11,t=Ps(null,t,r,e,n);break e}if(a===A){t.tag=14,t=js(null,t,r,e,n);break e}}throw t=N(r)||r,Error(i(306,t,""))}Dr(r)?(e=gs(r,e),t.tag=1,t=Ds(null,t,r,e,n)):(t.tag=0,t=Ms(null,t,r,e,n))}return t;case 0:return Ms(e,t,t.type,t.pendingProps,n);case 1:return Ds(e,t,r=t.type,a=gs(r,t.pendingProps),n);case 3:e:{if(K(t,t.stateNode.containerInfo),null===e)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,ro(e,t),co(t,r,null,n);var s=t.memoizedState;if(r=s.cache,ba(0,Na,r),r!==o.cache&&Sa(t,[Na],n,!0),uo(),r=s.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,256&t.flags){t=$s(e,t,r,n);break e}if(r!==a){ma(a=kr(Error(i(424)),t)),t=$s(e,t,r,n);break e}if(9===(e=t.stateNode.containerInfo).nodeType)e=e.body;else e="HTML"===e.nodeName?e.ownerDocument.body:e;for(aa=vd(e.firstChild),ra=t,oa=!0,ia=null,sa=!0,n=rs(t,null,r,n),t.child=n;n;)n.flags=-3&n.flags|4096,n=n.sibling}else{if(ha(),r===a){t=Vs(e,t,n);break e}Ts(e,t,r,n)}t=t.child}return t;case 26:return Ls(e,t),null===e?(n=Td(t.type,null,t.pendingProps,null))?t.memoizedState=n:oa||(n=t.type,e=t.pendingProps,(r=rd(Z.current).createElement(n))[Ne]=t,r[Re]=e,ed(r,n,e),We(r),t.stateNode=r):t.memoizedState=Td(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return q(t),null===e&&oa&&(r=t.stateNode=wd(t.type,t.pendingProps,Z.current),ra=t,sa=!0,a=aa,hd(t.type)?(yd=a,aa=vd(r.firstChild)):aa=a),Ts(e,t,t.pendingProps.children,n),Ls(e,t),null===e&&(t.flags|=4194304),t.child;case 5:return null===e&&oa&&((a=r=aa)&&(null!==(r=function(e,t,n,r){for(;1===e.nodeType;){var a=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&("INPUT"!==e.nodeName||"hidden"!==e.type))break}else if(r){if(!e[Fe])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if("stylesheet"===(o=e.getAttribute("rel"))&&e.hasAttribute("data-precedence"))break;if(o!==a.rel||e.getAttribute("href")!==(null==a.href||""===a.href?null:a.href)||e.getAttribute("crossorigin")!==(null==a.crossOrigin?null:a.crossOrigin)||e.getAttribute("title")!==(null==a.title?null:a.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(((o=e.getAttribute("src"))!==(null==a.src?null:a.src)||e.getAttribute("type")!==(null==a.type?null:a.type)||e.getAttribute("crossorigin")!==(null==a.crossOrigin?null:a.crossOrigin))&&o&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else{if("input"!==t||"hidden"!==e.type)return e;var o=null==a.name?null:""+a.name;if("hidden"===a.type&&e.getAttribute("name")===o)return e}if(null===(e=vd(e.nextSibling)))break}return null}(r,t.type,t.pendingProps,sa))?(t.stateNode=r,ra=t,aa=vd(r.firstChild),sa=!1,a=!0):a=!1),a||ua(t)),q(t),a=t.type,o=t.pendingProps,s=null!==e?e.memoizedProps:null,r=o.children,id(a,o)?r=null:null!==s&&id(a,s)&&(t.flags|=32),null!==t.memoizedState&&(a=No(e,t,Mo,null,null,n),qd._currentValue=a),Ls(e,t),Ts(e,t,r,n),t.child;case 6:return null===e&&oa&&((e=n=aa)&&(null!==(n=function(e,t,n){if(""===t)return null;for(;3!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!n)return null;if(null===(e=vd(e.nextSibling)))return null}return e}(n,t.pendingProps,sa))?(t.stateNode=n,ra=t,aa=null,e=!0):e=!1),e||ua(t)),null;case 13:return zs(e,t,n);case 4:return K(t,t.stateNode.containerInfo),r=t.pendingProps,null===e?t.child=ns(t,null,r,n):Ts(e,t,r,n),t.child;case 11:return Ps(e,t,t.type,t.pendingProps,n);case 7:return Ts(e,t,t.pendingProps,n),t.child;case 8:case 12:return Ts(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,ba(0,t.type,r.value),Ts(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Aa(t),r=r(a=Ea(a)),t.flags|=1,Ts(e,t,r,n),t.child;case 14:return js(e,t,t.type,t.pendingProps,n);case 15:return Os(e,t,t.type,t.pendingProps,n);case 19:return qs(e,t,n);case 31:return r=t.pendingProps,n=t.mode,r={mode:r.mode,children:r.children},null===e?((n=Zs(r,n)).ref=t.ref,t.child=n,n.return=t,t=n):((n=$r(e.child,r)).ref=t.ref,t.child=n,n.return=t,t=n),t;case 22:return Ns(e,t,n);case 24:return Aa(t),r=Ea(Na),null===e?(null===(a=za())&&(a=ru,o=Ra(),a.pooledCache=o,o.refCount++,null!==o&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},no(t),ba(0,Na,a)):(0!==(e.lanes&n)&&(ro(e,t),co(t,null,null,n),uo()),a=e.memoizedState,o=t.memoizedState,a.parent!==r?(a={parent:r,cache:r},t.memoizedState=a,0===t.lanes&&(t.memoizedState=t.updateQueue.baseState=a),ba(0,Na,r)):(r=o.cache,ba(0,Na,r),r!==a.cache&&Sa(t,[Na],n,!0))),Ts(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Js(e){e.flags|=4}function Xs(e,t){if("stylesheet"!==t.type||0!==(4&t.state.loading))e.flags&=-16777217;else if(e.flags|=16777216,!Bd(t)){if(null!==(t=as.current)&&((4194048&ou)===ou?null!==os:(62914560&ou)!==ou&&0===(536870912&ou)||t!==os))throw Ja=qa,Ka;e.flags|=8192}}function el(e,t){null!==t&&(e.flags|=4),16384&e.flags&&(t=22!==e.tag?xe():536870912,e.lanes|=t,vu|=t)}function tl(e,t){if(!oa)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;null!==n;)null!==n.alternate&&(r=n),n=n.sibling;null===r?t||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function nl(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,r=0;if(t)for(var a=e.child;null!==a;)n|=a.lanes|a.childLanes,r|=65011712&a.subtreeFlags,r|=65011712&a.flags,a.return=e,a=a.sibling;else for(a=e.child;null!==a;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags,r|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function rl(e,t,n){var r=t.pendingProps;switch(na(t),t.tag){case 31:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 1:return nl(t),null;case 3:return n=t.stateNode,r=null,null!==e&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),wa(Na),G(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),null!==e&&null!==e.child||(fa(t)?Js(t):null===e||e.memoizedState.isDehydrated&&0===(256&t.flags)||(t.flags|=1024,pa())),nl(t),null;case 26:return n=t.memoizedState,null===e?(Js(t),null!==n?(nl(t),Xs(t,n)):(nl(t),t.flags&=-16777217)):n?n!==e.memoizedState?(Js(t),nl(t),Xs(t,n)):(nl(t),t.flags&=-16777217):(e.memoizedProps!==r&&Js(t),nl(t),t.flags&=-16777217),null;case 27:V(t),n=Z.current;var a=t.type;if(null!==e&&null!=t.stateNode)e.memoizedProps!==r&&Js(t);else{if(!r){if(null===t.stateNode)throw Error(i(166));return nl(t),null}e=z.current,fa(t)?ca(t):(e=wd(a,r,n),t.stateNode=e,Js(t))}return nl(t),null;case 5:if(V(t),n=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==r&&Js(t);else{if(!r){if(null===t.stateNode)throw Error(i(166));return nl(t),null}if(e=z.current,fa(t))ca(t);else{switch(a=rd(Z.current),e){case 1:e=a.createElementNS("http://www.w3.org/2000/svg",n);break;case 2:e=a.createElementNS("http://www.w3.org/1998/Math/MathML",n);break;default:switch(n){case"svg":e=a.createElementNS("http://www.w3.org/2000/svg",n);break;case"math":e=a.createElementNS("http://www.w3.org/1998/Math/MathML",n);break;case"script":(e=a.createElement("div")).innerHTML="