@trieoh/identityx-sdk-ts 0.12.5 → 0.12.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/react.js +2 -2
- package/dist/cjs/react.js.map +1 -1
- package/dist/esm/{api-DjM6jYaR.d.ts → api-BjzcDj0c.d.ts} +3 -3
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/react.d.ts +61 -3
- package/dist/esm/react.js +2 -2
- package/dist/esm/react.js.map +1 -1
- package/package.json +14 -6
package/dist/esm/react.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {createContext,useRef,useSyncExternalStore,useEffect,useCallback,useMemo,useContext,useState}from'react';import {logger,createDefaultFetchClient,simpleFetch}from'@trieoh/envoy-fetch-ts';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {RiEyeCloseLine,RiEyeLine}from'react-icons/ri';import {GoPerson}from'react-icons/go';import {ImExit}from'react-icons/im';import {FaDesktop,FaTabletAlt,FaMobileAlt,FaTrashAlt}from'react-icons/fa';import {UAParser}from'ua-parser-js';import {FiCheck,FiInfo}from'react-icons/fi';function ye(e,t){if(t.startsWith("http"))return t;let r=e.replace(/\/$/,""),o=t.replace(/^\//,"");return `${r}/${o}`}var W={isAuthenticated:false,isInitializing:true},Se=new Set,Me=()=>Se.forEach(e=>e()),b={subscribe:e=>(Se.add(e),()=>Se.delete(e)),getSnapshot:()=>W,getServerSnapshot:()=>W,set:e=>{W={...W,...e},Me();},reset:()=>{W={isAuthenticated:false,isInitializing:false},Me();}};typeof window<"u"&&window.addEventListener("storage",e=>{if(e.key==="trieoh_access_expiry")if(!e.newValue)b.reset();else {let t=parseInt(e.newValue,10),r=!isNaN(t)&&t>Date.now();b.set({isAuthenticated:r,isInitializing:false});}});var I={getItem:e=>typeof window<"u"?localStorage.getItem(e):null,setItem:(e,t)=>{typeof window<"u"&&localStorage.setItem(e,t);},removeItem:e=>{typeof window<"u"&&localStorage.removeItem(e);}},G={getItem:e=>typeof window<"u"?sessionStorage.getItem(e):null,setItem:(e,t)=>{typeof window<"u"&&sessionStorage.setItem(e,t);},removeItem:e=>{typeof window<"u"&&sessionStorage.removeItem(e);}},O={get:e=>{if(typeof window>"u")return null;let t=e+"=",r=document.cookie.split(";");for(let o=0;o<r.length;o++){let i=r[o];for(;i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(t)===0)return i.substring(t.length,i.length)}return null},set:(e,t,r={})=>{if(typeof window>"u")return;let{expires:o,path:i="/",domain:s,secure:n=window.location.protocol==="https:",sameSite:l=n?"None":"Lax"}=r,a=window.location.hostname==="localhost",d=[`${e}=${t}`,s&&!a?`Domain=${s}`:"",`Path=${i}`,`SameSite=${l}`,n?"Secure":"",o?`expires=${o}`:""];document.cookie=d.filter(Boolean).join("; ");},remove:(e,t)=>{O.set(e,"",{expires:"Thu, 01 Jan 1970 00:00:00 GMT",domain:t||void 0});}};function F(e){try{let r=encodeURIComponent(JSON.stringify(e)).split("").reverse().join("");return "tr_"+btoa(r)}catch{return ""}}function q(e){if(!e)return null;try{if(!e.startsWith("tr_"))return null;let t=e.replace(/^tr_/,""),o=atob(t).split("").reverse().join("");return JSON.parse(decodeURIComponent(o))}catch{return null}}var le="trieoh_access_token",U={getAccessToken:()=>q(G.getItem(le)),setAccessToken:e=>{e?G.setItem(le,F(e)):G.removeItem(le);},clear:()=>{G.removeItem(le);}};var X=null,Re="trieoh_access_expiry",ue="trieoh_refresh_expiry",ce="trieoh_refresh_domain";function Be(e){if(typeof window>"u")return null;let t=window.location.hostname;if(t==="localhost"||t==="127.0.0.1"||t.includes("localhost"))return null;if(e)try{let o=e;return o.startsWith("http")&&(o=new URL(o).hostname),t===o||t.endsWith("."+o)?o:t}catch{return t}return t}function Fe(e){try{let t=e.split(".")[1];if(!t)return null;let r=t.replace(/-/g,"+").replace(/_/g,"/");for(;r.length%4;)r+="=";let o=decodeURIComponent(atob(r).split("").map(i=>"%"+("00"+i.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(o)}catch(t){return logger.error("Error decoding JWT:",t),null}}function Z(e){let{access_token_string:t,refresh_token_string:r,access_expires_at:o,refresh_expires_at:i}=e,s=Fe(t);if(!s){logger.error("Failed to decode tokens");return}U.setAccessToken(t);let n=new Date(i).getTime(),l=new Date(o).getTime(),a=Be(e.domain);O.set("refresh_token",r,{expires:new Date(n).toUTCString(),domain:a}),X=F({access_data:s,refresh_expiry_date:n}),I.setItem(Re,F(l)),I.setItem(ue,F(n)),a?I.setItem(ce,a):I.removeItem(ce),b.set({isAuthenticated:true,isInitializing:false}),logger.log("Auth session saved");}function ee(){if(X)return q(X);let e=U.getAccessToken();if(!e)return null;let t=Fe(e);if(!t||t.exp*1e3<=Date.now())return null;let r=I.getItem(ue);if(!r)return null;let o=q(r);if(!o)return null;let i={access_data:t,refresh_expiry_date:o};return X=F(i),i}function Ue(e,t){try{let r=I.getItem(e);if(!r)return !0;let o=q(r);return o?o-Date.now()<=t*1e3:!0}catch(r){return logger.warn("Error reading expiry:",r),true}}var _e=(e=30)=>Ue(Re,e),me=(e=10)=>Ue(ue,e);function j(){X=null,U.clear(),I.removeItem(Re),I.removeItem(ue);let e=I.getItem(ce)||Be();O.remove("refresh_token",e),I.removeItem(ce),b.reset(),logger.log("Auth tokens and claims cleared");}function He(){let e=ee();return e?e.access_data.sub:null}function nt(){let e=typeof window>"u",t=typeof import.meta<"u"&&import.meta.env?import.meta.env:{},r=typeof process<"u"?process.env:{},o=t.VITE_TRIEOH_AUTH_PROJECT_ID||r.NEXT_PUBLIC_TRIEOH_AUTH_PROJECT_ID||r.PUBLIC_TRIEOH_AUTH_PROJECT_ID||"",i=e&&r.TRIEOH_AUTH_API_KEY||"";return {PROJECT_ID:o,API_KEY:i,BASE_URL:"https://api.trieauth.trieoh.com"}}var de=null,Ee={};function ze(e){Ee={...Ee,...e},de=null;}function ke(){return de||(de={...nt(),...Ee}),de}var y={get PROJECT_ID(){return ke().PROJECT_ID},get BASE_URL(){return ke().BASE_URL}};var pe=class{constructor(t){this.isRefreshing=false;this.refreshPromise=null;this.baseURL=t?.baseURL||y.BASE_URL,this.authBaseURL=t?.authBaseURL||this.baseURL,this.onTokenRefreshed=t?.onTokenRefreshed,this.onRefreshFailed=t?.onRefreshFailed;}async refreshToken(){return this.isRefreshing&&this.refreshPromise?this.refreshPromise:(this.isRefreshing=true,this.refreshPromise=(async()=>{try{let t=await simpleFetch(ye(this.authBaseURL,"/auth/refresh"),{method:"POST",credentials:"include"});if(t.code!==200||!t.data)throw t.code!==503&&j(),new Error(t.message||"Failed to refresh token");Z(t.data);let r=ee();r&&this.onTokenRefreshed?.(r),logger.log("Token refreshed successfully");}catch(t){throw logger.warn("Failed to refresh token:",t),j(),this.onRefreshFailed?.(t),t}finally{this.isRefreshing=false,this.refreshPromise=null;}})(),this.refreshPromise)}async beforeRequest(){if(me()){j();return}let t=!!U.getAccessToken(),r=!!O.get("refresh_token");if(!t&&r||t&&_e(30))try{await this.refreshToken();}catch(o){logger.warn("Proactive refresh failed:",o);}}async fetch(t,r){let o=r?.requiresAuth!==false,i=t.includes("/auth/refresh");o&&!i&&!r?.skipRefresh&&await this.beforeRequest();let s=ye(this.baseURL,t),n=async()=>{let a=U.getAccessToken(),d=new Headers(r?.headers);return o&&a&&d.set("Authorization",`Bearer ${a}`),d.has("Content-Type")||d.set("Content-Type","application/json"),fetch(s,{...r,headers:d,credentials:"include"})},l=await n();if(l.status===401&&o&&!i&&_e(30)){logger.log("401 detected and token is expiring/expired, attempting refresh...");try{await this.refreshToken(),l=await n();}catch{logger.error("Retry failed after refresh error");}}return l}};function H(e){if(!e)return;let{requiresAuth:t,skipRefresh:r,...o}=e,i={};return t!==void 0&&(i.requiresAuth=t),r!==void 0&&(i.skipRefresh=r),{...o,adapterInit:{...o.adapterInit,...i}}}var fe=class{constructor(t,r,o,i){this.interceptor=new pe({baseURL:t,authBaseURL:r,onTokenRefreshed:o}),this.client=createDefaultFetchClient({...i,adapter:this.interceptor.fetch.bind(this.interceptor)});}request(t,r){return this.client.request(t,H(r))}get(t,r){return this.client.get(t,H(r))}post(t,r,o){return this.client.post(t,r,H(o))}put(t,r,o){return this.client.put(t,r,H(o))}patch(t,r,o){return this.client.patch(t,r,H(o))}delete(t,r,o){return this.client.delete(t,r,H(o))}query(t,r){return this.client.query(t,H(r))}};var $=()=>{if(!y.PROJECT_ID||y.PROJECT_ID.trim()==="")throw new Error("[TRIEOH SDK] Project ID is missing. Please set PUBLIC_TRIEOH_AUTH_PROJECT_ID, NEXT_PUBLIC_TRIEOH_AUTH_PROJECT_ID or VITE_TRIEOH_AUTH_PROJECT_ID.")};var Ve=(e,t)=>({login:async(r,o)=>{y.PROJECT_ID&&$();let i=`/auth/login${y.PROJECT_ID?`?project_id=${y.PROJECT_ID}`:""}`,s=await e.post(i,{email:r,password:o},{requiresAuth:false});return s.success&&(Z(s.data),t?.onLogin?.(s)),s},register:async(r,o)=>{let i={requiresAuth:false},s=`/auth/register${y.PROJECT_ID?`?project_id=${y.PROJECT_ID}`:""}`;y.PROJECT_ID&&$();let n=await e.post(s,{email:r,password:o},i);return n.success&&t?.onRegister?.(n),n},logout:async r=>{let o=`/auth/logout${y.PROJECT_ID?`?project_id=${y.PROJECT_ID}`:""}`,i=await e.post(o);return (i.success||r?.forceLogout)&&j(),i},refresh:async()=>{let r=await e.post("/auth/refresh",void 0,{skipRefresh:true});return r.success&&(Z(r.data),t?.onRefresh?.(r)),r},sessions:async()=>e.get("/sessions"),currentSession:async()=>e.get("/sessions/me"),revokeASession:async r=>e.delete(`/sessions/${r}`),revokeSessions:async(r=false)=>{let o=r?"/sessions":"/sessions/others";return e.delete(o)},profile:()=>He(),sendForgotPassword:async r=>{let o={requiresAuth:false};return y.PROJECT_ID?($(),e.post("/account/forgot-password",{email:r,project_id:y.PROJECT_ID},o)):e.post("/account/forgot-password",{email:r},o)},resetPassword:async(r,o)=>{let i=await e.post(`/account/reset-password?token=${r}`,{new_password:o},{requiresAuth:false});return i.success&&t?.onResetPassword?.(i),i},verifyEmail:async r=>{let o=`/account/verify?token=${r}`,i=await e.post(o);return i.success&&t?.onVerify?.(i),i},resendVerifyEmail:async()=>e.post("/account/verify/resend"),health:async()=>e.get("/health",{requiresAuth:false}),authHealth:async()=>e.get("/protected/health")});var je=createContext(null);function Kr({children:e,baseURL:t,projectId:r,isProjectMode:o=true,fallback:i,waitSession:s=true,clientConfig:n,onLogin:l,onResetPassword:a,onRegister:d,onVerify:h,onRefresh:f}){let g=useRef(false),{isAuthenticated:p,isInitializing:c}=useSyncExternalStore(b.subscribe,b.getSnapshot,b.getServerSnapshot);useEffect(()=>{ze({...r?{PROJECT_ID:r}:{},...t?{BASE_URL:t}:{}});},[r,t]);let R=useCallback(D=>{b.set({isAuthenticated:!!D.access_data,isInitializing:false}),f?.();},[f]),_=useMemo(()=>new fe(t,void 0,R,n),[t,R,n]),x=useMemo(()=>Ve(_,{onLogin:l,onResetPassword:a,onRegister:d,onVerify:h,onRefresh:f}),[_,l,a,d,h,f]);useEffect(()=>{o&&$(),(async()=>{if(g.current)return;if(g.current=true,ee()){b.set({isAuthenticated:true,isInitializing:false});return}if(!!!O.get("refresh_token")||me()){b.reset(),b.set({isInitializing:false});return}logger.log("No cached claims, attempting silent refresh...");try{(await x.refresh()).success?(b.set({isAuthenticated:!0,isInitializing:!1}),logger.log("Session restored.")):(b.reset(),logger.warn("No active session."));}catch{b.reset(),logger.warn("Could not restore session (offline?).");}finally{b.set({isInitializing:false});}})();},[x,o]);let A=useMemo(()=>({auth:x,isAuthenticated:p,isInitializing:c,isProjectMode:o}),[x,p,c,o]);return s&&c?i??null:jsx(je.Provider,{value:A,children:e})}function S(){let e=useContext(je);if(!e)throw new Error("useAuth must be used inside <AuthProvider>");return e}function Ce(e,{insertAt:t}={}){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",t==="top"&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e));}Ce(`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */@layer properties;@layer theme,base,components,utilities;@layer theme{:root,:host{--font-sans: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--spacing: .25rem;--font-weight-extralight: 200;--font-weight-light: 300;--font-weight-normal: 400;--font-weight-medium: 500;--font-weight-semibold: 600;--radius-lg: .5rem;--ease-in-out: cubic-bezier(.4, 0, .2, 1);--animate-spin: spin 1s linear infinite;--default-transition-duration: .15s;--default-transition-timing-function: cubic-bezier(.4, 0, .2, 1);--default-font-family: var(--font-sans);--default-mono-font-family: var(--font-mono);--color-trieoh-primary: oklch(.1139 .0789 264.05);--color-trieoh-secondary: oklch(.7975 .1018 262.7);--color-trieoh-neutral1: oklch(.9702 0 0);--color-trieoh-neutral2: oklch(.1944 .0051 248.09);--radius-trieoh-full: 50%;--font-inter: "Inter", sans-serif}}@layer base{*,:after,:before,::backdrop,::file-selector-button{box-sizing:border-box;margin:0;padding:0;border:0 solid}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;tab-size:4;font-family:var(--default-font-family, ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings, normal);font-variation-settings:var(--default-font-variation-settings, normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings, normal);font-variation-settings:var(--default-mono-font-variation-settings, normal);font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea,::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;border-radius:0;background-color:transparent;opacity:1}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px){::placeholder{color:currentcolor;@supports (color: color-mix(in lab,red,red)){color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit,::-webkit-datetime-edit-year-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]),::file-selector-button{appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.\\@container{container-type:inline-size}.trieoh-button-loading{&:after{content:"";position:absolute;top:0;left:-150%;width:150%;height:100%;background:linear-gradient(120deg,transparent 0%,var(--trieoh-neutral2) 40%,transparent 80%);@supports (color: color-mix(in lab,red,red)){background:linear-gradient(120deg,transparent 0%,color-mix(in oklab,var(--trieoh-neutral2) 40%,white 15%) 40%,transparent 80%)}animation:trieoh-shine 1.5s infinite}}.absolute{position:absolute}.relative{position:relative}.top-0{top:calc(var(--spacing) * 0)}.right-0{right:calc(var(--spacing) * 0)}.m-0{margin:calc(var(--spacing) * 0)}.m-2{margin:calc(var(--spacing) * 2)}.m-\\[0\\.125rem\\]{margin:.125rem}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-\\[0\\.625rem\\]{margin-bottom:.625rem}.box-border{box-sizing:border-box}.block{display:block}.contents{display:contents}.flex{display:flex}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.h-12{height:calc(var(--spacing) * 12)}.h-16{height:calc(var(--spacing) * 16)}.h-\\[3\\.25rem\\]{height:3.25rem}.h-\\[64px\\]{height:64px}.h-auto{height:auto}.h-full{height:100%}.max-h-\\[max\\(75dvh\\,32rem\\)\\]{max-height:max(75dvh,32rem)}.min-h-screen{min-height:100vh}.w-12{width:calc(var(--spacing) * 12)}.w-16{width:calc(var(--spacing) * 16)}.w-\\[64px\\]{width:64px}.w-full{width:100%}.max-w-\\[14rem\\]{max-width:14rem}.max-w-\\[25rem\\]{max-width:25rem}.max-w-\\[30rem\\]{max-width:30rem}.min-w-0{min-width:calc(var(--spacing) * 0)}.min-w-\\[10rem\\]{min-width:10rem}.min-w-\\[15rem\\]{min-width:15rem}.min-w-\\[20rem\\]{min-width:20rem}.flex-1{flex:1}.flex-\\[0_1_auto\\]{flex:0 1 auto}.flex-\\[1_1_auto\\]{flex:1 1 auto}.shrink-0{flex-shrink:0}.animate-spin{animation:var(--animate-spin)}.cursor-pointer{cursor:pointer}.appearance-none{appearance:none}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-1{gap:calc(var(--spacing) * 1)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-5{gap:calc(var(--spacing) * 5)}.gap-6{gap:calc(var(--spacing) * 6)}.gap-8{gap:calc(var(--spacing) * 8)}.gap-\\[0\\.625rem\\]{gap:.625rem}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded-\\[0\\.25rem\\]{border-radius:.25rem}.rounded-full{border-radius:calc(infinity * 1px)}.rounded-lg{border-radius:var(--radius-lg)}.rounded-trieoh-full{border-radius:var(--radius-trieoh-full)}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-none{--tw-border-style: none;border-style:none}.\\!border-\\[\\#e53935\\]{border-color:#e53935!important}.border-\\[rgba\\(0\\,0\\,0\\,0\\.3\\)\\]{border-color:#0000004d}.border-trieoh-neutral2{border-color:var(--color-trieoh-neutral2)}.border-trieoh-secondary{border-color:var(--color-trieoh-secondary)}.bg-\\[oklch\\(0\\.8853_0_0\\/30\\%\\)\\]{background-color:#d9d9d94d}.bg-transparent{background-color:transparent}.bg-trieoh-neutral1{background-color:var(--color-trieoh-neutral1)}.bg-trieoh-secondary\\/10{background-color:color-mix(in srgb,oklch(.7975 .1018 262.7) 10%,transparent);@supports (color: color-mix(in lab,red,red)){background-color:color-mix(in oklab,var(--color-trieoh-secondary) 10%,transparent)}}.p-2{padding:calc(var(--spacing) * 2)}.p-6{padding:calc(var(--spacing) * 6)}.p-\\[0\\.625rem\\]{padding:.625rem}.p-\\[1\\.5rem_0\\.5rem\\]{padding:1.5rem .5rem}.p-\\[1\\.25rem_0\\.75rem\\]{padding:1.25rem .75rem}.p-\\[1\\.25rem_1\\.5rem\\]{padding:1.25rem 1.5rem}.p-\\[1rem_0\\]{padding:1rem 0}.px-\\[0\\.75rem\\]{padding-inline:.75rem}.px-\\[0\\.625rem\\]{padding-inline:.625rem}.px-\\[1\\.5rem\\]{padding-inline:1.5rem}.py-4{padding-block:calc(var(--spacing) * 4)}.py-\\[0\\.125rem\\]{padding-block:.125rem}.py-\\[0\\.0625rem\\]{padding-block:.0625rem}.text-center{text-align:center}.font-inter{font-family:var(--font-inter)}.text-\\[0\\.75rem\\]{font-size:.75rem}.text-\\[0\\.875rem\\]{font-size:.875rem}.text-\\[1rem\\]{font-size:1rem}.font-extralight{--tw-font-weight: var(--font-weight-extralight);font-weight:var(--font-weight-extralight)}.font-light{--tw-font-weight: var(--font-weight-light);font-weight:var(--font-weight-light)}.font-medium{--tw-font-weight: var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight: var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight: var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.text-\\[\\#6b7280\\]{color:#6b7280}.text-\\[\\#10b981\\]{color:#10b981}.text-\\[\\#e53935\\]{color:#e53935}.text-\\[oklch\\(0\\.628_0\\.2577_29\\.23\\)\\]{color:red}.text-trieoh-neutral2{color:var(--color-trieoh-neutral2)}.text-trieoh-primary{color:var(--color-trieoh-primary)}.text-trieoh-secondary{color:var(--color-trieoh-secondary)}.line-through{text-decoration-line:line-through}.opacity-50{opacity:50%}.opacity-60{opacity:60%}.opacity-95{opacity:95%}.opacity-100{opacity:100%}.\\!shadow-none{--tw-shadow: 0 0 #0000 !important;box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)!important}.shadow-\\[0_0\\.25rem_0\\.25rem_0_rgba\\(0\\,0\\,0\\,0\\.25\\)\\]{--tw-shadow: 0 .25rem .25rem 0 var(--tw-shadow-color, rgba(0,0,0,.25));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\\[0_0\\.25rem_1rem_rgba\\(0\\,0\\,0\\,0\\.25\\)\\]{--tw-shadow: 0 .25rem 1rem var(--tw-shadow-color, rgba(0,0,0,.25));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.transition-\\[color\\,text-decoration\\,opacity\\]{transition-property:color,text-decoration,opacity;transition-timing-function:var(--tw-ease, var(--default-transition-timing-function));transition-duration:var(--tw-duration, var(--default-transition-duration))}.transition-\\[opacity\\,transform\\]{transition-property:opacity,transform;transition-timing-function:var(--tw-ease, var(--default-transition-timing-function));transition-duration:var(--tw-duration, var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease, var(--default-transition-timing-function));transition-duration:var(--tw-duration, var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease, var(--default-transition-timing-function));transition-duration:var(--tw-duration, var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease, var(--default-transition-timing-function));transition-duration:var(--tw-duration, var(--default-transition-duration))}.duration-150{--tw-duration: .15s;transition-duration:.15s}.duration-200{--tw-duration: .2s;transition-duration:.2s}.duration-500{--tw-duration: .5s;transition-duration:.5s}.duration-\\[120ms\\]{--tw-duration: .12s;transition-duration:.12s}.ease-in-out{--tw-ease: var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.outline-none{--tw-outline-style: none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.hover\\:scale-\\[1\\.02\\]{&:hover{@media(hover:hover){scale:1.02}}}.hover\\:scale-\\[1\\.05\\]{&:hover{@media(hover:hover){scale:1.05}}}.hover\\:text-trieoh-primary{&:hover{@media(hover:hover){color:var(--color-trieoh-primary)}}}.hover\\:opacity-100{&:hover{@media(hover:hover){opacity:100%}}}.active\\:scale-\\[0\\.95\\]{&:active{scale:.95}}.active\\:scale-\\[0\\.98\\]{&:active{scale:.98}}.active\\:scale-\\[0\\.99\\]{&:active{scale:.99}}.disabled\\:\\!transform-none{&:disabled{transform:none!important}}.disabled\\:cursor-not-allowed{&:disabled{cursor:not-allowed}}.disabled\\:opacity-60{&:disabled{opacity:60%}}.\\@\\[640px\\]\\:flex-row{@container (width >= 640px){flex-direction:row}}.\\@\\[640px\\]\\:items-center{@container (width >= 640px){align-items:center}}.\\@\\[640px\\]\\:justify-between{@container (width >= 640px){justify-content:space-between}}.\\@\\[640px\\]\\:gap-2{@container (width >= 640px){gap:calc(var(--spacing) * 2)}}.\\@\\[640px\\]\\:gap-4{@container (width >= 640px){gap:calc(var(--spacing) * 4)}}.\\@\\[640px\\]\\:gap-8{@container (width >= 640px){gap:calc(var(--spacing) * 8)}}.\\@\\[640px\\]\\:text-left{@container (width >= 640px){text-align:left}}}@import url(https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap);@property --tw-border-style{syntax: "*"; inherits: false; initial-value: solid;}@property --tw-font-weight{syntax: "*"; inherits: false;}@property --tw-shadow{syntax: "*"; inherits: false; initial-value: 0 0 #0000;}@property --tw-shadow-color{syntax: "*"; inherits: false;}@property --tw-shadow-alpha{syntax: "<percentage>"; inherits: false; initial-value: 100%;}@property --tw-inset-shadow{syntax: "*"; inherits: false; initial-value: 0 0 #0000;}@property --tw-inset-shadow-color{syntax: "*"; inherits: false;}@property --tw-inset-shadow-alpha{syntax: "<percentage>"; inherits: false; initial-value: 100%;}@property --tw-ring-color{syntax: "*"; inherits: false;}@property --tw-ring-shadow{syntax: "*"; inherits: false; initial-value: 0 0 #0000;}@property --tw-inset-ring-color{syntax: "*"; inherits: false;}@property --tw-inset-ring-shadow{syntax: "*"; inherits: false; initial-value: 0 0 #0000;}@property --tw-ring-inset{syntax: "*"; inherits: false;}@property --tw-ring-offset-width{syntax: "<length>"; inherits: false; initial-value: 0px;}@property --tw-ring-offset-color{syntax: "*"; inherits: false; initial-value: #fff;}@property --tw-ring-offset-shadow{syntax: "*"; inherits: false; initial-value: 0 0 #0000;}@property --tw-duration{syntax: "*"; inherits: false;}@property --tw-ease{syntax: "*"; inherits: false;}@keyframes spin{to{transform:rotate(360deg)}}@keyframes trieoh-shine{0%{left:-150%}to{left:150%}}@layer properties{@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style: solid;--tw-font-weight: initial;--tw-shadow: 0 0 #0000;--tw-shadow-color: initial;--tw-shadow-alpha: 100%;--tw-inset-shadow: 0 0 #0000;--tw-inset-shadow-color: initial;--tw-inset-shadow-alpha: 100%;--tw-ring-color: initial;--tw-ring-shadow: 0 0 #0000;--tw-inset-ring-color: initial;--tw-inset-ring-shadow: 0 0 #0000;--tw-ring-inset: initial;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-offset-shadow: 0 0 #0000;--tw-duration: initial;--tw-ease: initial}}}
|
|
2
|
-
`);function k({name:e,label:t,placeholder:r,type:o="text",value:i,onValueChange:s,onBlur:n,autoComplete:l,rulesStatus:a=[],submitted:d=false,inputRef:h}){let[f,g]=useState(false),p=a.some(c=>!c.passed);return jsxs("div",{className:"font-inter relative w-full flex flex-col gap-1 text-trieoh-neutral2",children:[jsx("label",{htmlFor:e,className:"text-[1rem] font-semibold",children:t}),jsxs("div",{className:`flex justify-between items-center px-[0.625rem] py-[0.0625rem] gap-[0.625rem] border-b-2 border-trieoh-neutral2 ${p&&d?"!border-[#e53935]":""}`,children:[jsx("input",{type:f?"text":o,name:e,id:e,placeholder:r,value:i,onChange:c=>s&&s(c.target.value),onBlur:n,autoComplete:l,"aria-invalid":p&&d,ref:h,className:"min-w-[10rem] flex-1 text-trieoh-base font-light text-trieoh-neutral2 appearance-none bg-transparent outline-none border-none !shadow-none py-[0.125rem]"}),o==="password"&&(f?jsx(RiEyeCloseLine,{className:"cursor-pointer shrink-0 select-none",size:24,onClick:()=>g(false)}):jsx(RiEyeLine,{className:"cursor-pointer shrink-0 select-none",size:24,onClick:()=>g(true)}))]}),jsx("div",{className:"text-[0.75rem] text-[#6b7280] transition-opacity duration-200 ease-in-out",children:a.map((c,R)=>{let _=["transition-[color,text-decoration,opacity] duration-[120ms] ease opacity-95 m-[0.125rem]",c.passed?"line-through opacity-60 text-[#10b981]":"",!c.passed&&d?"text-[#e53935] font-semibold opacity-100":""].filter(Boolean).join(" ");return jsx("p",{className:_,children:c.message},c.id??R)})})]})}function E({label:e,onSubmit:t,loading:r}){return jsx("button",{type:"submit",onClick:t,disabled:r,className:`font-inter w-full h-[3.25rem] text-trieoh-xl font-semibold outline-none bg-transparent relative overflow-hidden min-w-[10rem] shrink-0 border-2 border-trieoh-neutral2 text-trieoh-neutral2 cursor-pointer px-[1.5rem] transition-transform duration-500 rounded-[0.25rem] hover:scale-[1.02] active:scale-[0.99] disabled:opacity-60 disabled:cursor-not-allowed disabled:!transform-none ${r?"trieoh-button-loading":""}`,children:e})}function T({mainText:e,subText:t}){return jsxs("div",{className:"font-inter flex flex-col items-center",children:[jsx("div",{className:"flex justify-center items-center p-2 bg-[oklch(0.8853_0_0/30%)] rounded-trieoh-full mb-[0.625rem]",children:jsx(GoPerson,{className:"w-[64px] h-[64px] p-[0.625rem] bg-trieoh-neutral1 rounded-trieoh-full shadow-[0_0.25rem_1rem_rgba(0,0,0,0.25)]",size:70})}),jsx("h3",{className:"text-center text-trieoh-xl font-medium m-0",children:e}),jsx("span",{className:"text-center text-[0.875rem] font-light opacity-60",children:t})]})}function C(e,t){return e.map(r=>({id:r.id,message:r.message,passed:!!r.test(t)}))}function yt({onSuccess:e,onFailed:t,signUpRedirect:r,forgotPasswordRedirect:o,emailRules:i}){let[s,n]=useState(""),[l,a]=useState(""),[d,h]=useState(false),[f,g]=useState(false),p=useRef(null),c=useRef(null),{auth:R}=S(),_={email:i||[{message:"Digite um e-mail v\xE1lido, ex: exemplo@dominio.com",test:w=>/\S+@\S+\.\S+/.test(w)}],password:[]},x=C(_.email,s),A=C(_.password,l);return jsxs("form",{className:"font-inter flex flex-col w-full max-w-[30rem] min-w-[15rem] max-h-[max(75dvh,32rem)] overflow-hidden gap-5 items-center bg-trieoh-neutral1 text-trieoh-neutral2 p-[1.25rem_1.5rem] shadow-[0_0.25rem_0.25rem_0_rgba(0,0,0,0.25)] transition-transform duration-150 ease-in-out rounded-[0.25rem]",children:[jsx(T,{mainText:"Fa\xE7a login na sua conta",subText:"Insira seus dados para fazer login"}),jsxs("div",{className:"w-full flex flex-col gap-[0.625rem] flex-[1_1_auto] overflow-y-auto mb-2",children:[jsx(k,{label:"Email",name:"email",placeholder:"teste@gmail.com",autoComplete:"email",type:"email",value:s,onValueChange:n,inputRef:p,rulesStatus:x,submitted:d}),jsx(k,{label:"Senha",name:"password",placeholder:"**********",autoComplete:"current-password",type:"password",value:l,onValueChange:a,inputRef:c,rulesStatus:A,submitted:d})]}),jsx(E,{label:"Entrar",onSubmit:async w=>{w.preventDefault(),h(true);let B=x.some(v=>!v.passed),V=A.some(v=>!v.passed);if(B){p.current?.focus();return}if(V){c.current?.focus();return}g(true);let N=await R.login(s,l);N.success?e&&await e(N.message):t&&await t(N.message,N.trace),g(false);},loading:f}),o&&jsx("span",{className:"text-trieoh-sm font-semibold text-center cursor-pointer",children:jsx("span",{className:"cursor-pointer text-trieoh-secondary transition-colors duration-200 hover:text-trieoh-primary",onClick:o,children:"Esqueceu sua senha?"})}),r&&jsxs(Fragment,{children:[jsxs("div",{className:"flex items-center gap-[0.625rem] w-full text-trieoh-base font-semibold opacity-60",children:[jsx("hr",{className:"flex-1"}),"OU",jsx("hr",{className:"flex-1"})]}),jsxs("span",{className:"text-trieoh-sm font-semibold",children:["Ainda n\xE3o possui uma conta? ",jsx("span",{className:"cursor-pointer text-trieoh-secondary transition-colors duration-200 hover:text-trieoh-primary",onClick:r,children:"Cadastra-se"})]})]})]})}function Rt({onSuccess:e,onFailed:t,loginRedirect:r,emailRules:o,passwordRules:i}){let[s,n]=useState(""),[l,a]=useState(""),[d,h]=useState(""),[f,g]=useState(false),[p,c]=useState(false),R=useRef(null),_=useRef(null),x=useRef(null),{auth:A}=S(),D={email:o||[{message:"Digite um e-mail v\xE1lido, ex: exemplo@dominio.com",test:v=>/\S+@\S+\.\S+/.test(v)}],password:i||[{message:"M\xEDnimo de 8 caracteres.",test:v=>v.length>=8},{message:"Deve conter uma letra mai\xFAscula.",test:v=>/[A-Z]/.test(v)},{message:"Inclua pelo menos um caractere especial, ex: ! @ # $ % & * . ,",test:v=>/[!@#$%^&*(),.?":{}|<>_\-+=~`;/\\[\]]/.test(v)},{message:"Deve conter um n\xFAmero.",test:v=>/\d/.test(v)}],confirmPassword:[{message:"Senhas n\xE3o conferem.",test:v=>v===l}]},w=C(D.email,s),B=C(D.password,l),V=C(D.confirmPassword,d);return jsxs("form",{className:"font-inter flex flex-col w-full max-w-[30rem] min-w-[15rem] max-h-[max(75dvh,32rem)] overflow-hidden gap-5 items-center bg-trieoh-neutral1 text-trieoh-neutral2 p-[1.25rem_1.5rem] shadow-[0_0.25rem_0.25rem_0_rgba(0,0,0,0.25)] transition-transform duration-150 ease-in-out rounded-[0.25rem]",children:[jsx(T,{mainText:"Crie sua conta",subText:"Insira seus dados para come\xE7ar"}),jsxs("div",{className:"w-full flex flex-col gap-[0.625rem] flex-[1_1_auto] overflow-y-auto mb-2",children:[jsx(k,{label:"Email",name:"email",placeholder:"teste@gmail.com",autoComplete:"email",type:"email",value:s,onValueChange:n,inputRef:R,rulesStatus:w,submitted:f}),jsx(k,{label:"Senha",name:"password",placeholder:"**********",autoComplete:"new-password",type:"password",value:l,onValueChange:a,inputRef:_,rulesStatus:B,submitted:f}),jsx(k,{label:"Confirme a Senha",name:"confirm-password",placeholder:"**********",autoComplete:"new-password",type:"password",value:d,onValueChange:h,inputRef:x,rulesStatus:V,submitted:f})]}),jsx(E,{label:"Criar Conta",onSubmit:async v=>{v.preventDefault(),g(true);let ot=w.some(Y=>!Y.passed),it=B.some(Y=>!Y.passed),st=V.some(Y=>!Y.passed);if(ot){R.current?.focus();return}if(it){_.current?.focus();return}if(st){x.current?.focus();return}c(true);let ae=await A.register(s,l);ae.success?e&&await e(ae.message):t&&await t(ae.message,ae.trace),c(false);},loading:p}),r&&jsxs(Fragment,{children:[jsxs("div",{className:"flex items-center gap-[0.625rem] w-full text-trieoh-base font-semibold opacity-60",children:[jsx("hr",{className:"flex-1"}),"OU",jsx("hr",{className:"flex-1"})]}),jsxs("span",{className:"text-trieoh-sm font-semibold",children:["J\xE1 possui uma conta? ",jsx("span",{className:"cursor-pointer text-trieoh-secondary transition-colors duration-200 hover:text-trieoh-primary",onClick:r,children:"Entre"})]})]})]})}var kt={xs:"text-trieoh-sm",sm:"text-trieoh-base",md:"text-trieoh-xl",lg:"text-trieoh-2xl",xl:"text-trieoh-3xl","2xl":"text-trieoh-6xl"};function Et({size:e}){let t=e?kt[e]:"text-trieoh-xl";return jsxs("span",{className:`font-inter font-medium ${t}`,children:["\xA9 ",new Date().getFullYear()," TrieOH"]})}function It({onSuccess:e,onFailed:t,forceLogout:r}){let{auth:o}=S(),[i,s]=useState(false);return jsxs("button",{onClick:async l=>{if(l.preventDefault(),i)return;s(true);let a=await o.logout({forceLogout:r});a.success?e&&await e(a.message):t&&await t(a.message,a.trace),s(false);},type:"button",disabled:i,className:"font-inter border-none bg-transparent cursor-pointer flex items-end gap-1 text-trieoh-base font-medium text-[oklch(0.628_0.2577_29.23)] transition-transform duration-200 hover:scale-[1.05] active:scale-[0.98] disabled:opacity-60 disabled:cursor-not-allowed disabled:!transform-none",children:[jsx(ImExit,{size:24})," ",jsx("span",{children:"Log out"})]})}var Ye={mobile:FaMobileAlt,tablet:FaTabletAlt,desktop:FaDesktop};function We(e){let{device:t,os:r,browser:o}=UAParser(e);return {deviceType:t.type??"desktop",os:r.name,browser:o.name}}function Ge(e){let t=We(e);return {device:Mt(t.deviceType),os:t.os,browser:t.browser}}function Mt(e){if(!e)return "desktop";switch(e){case "mobile":return "mobile";case "tablet":return "tablet";default:return "desktop"}}function Xe(e){let t=Date.now()-new Date(e).getTime(),r=Math.floor(t/1e3),o=Math.floor(r/60),i=Math.floor(o/60),s=Math.floor(i/24),n=Math.floor(s/7);return r<60?"agora mesmo":o<60?`${o} minutos atr\xE1s`:i<24?`${i} horas atr\xE1s`:s<7?`${s} dias atr\xE1s`:`${n} semanas atr\xE1s`}function Ie({is_current:e,session_id:t,user_agent:r,issued_at:o,user_ip:i,onClick:s}){let n=Ge(r),l=Ye[n.device];return jsx("div",{className:"border-t border-[rgba(0,0,0,0.3)] p-[1.25rem_0.75rem] text-trieoh-neutral2",children:jsxs("div",{className:"relative flex flex-col items-center gap-2 flex-1 text-center @[640px]:flex-row @[640px]:items-center @[640px]:gap-4 @[640px]:text-left",children:[jsx(l,{size:40}),jsxs("div",{className:"flex flex-col min-w-0",children:[jsxs("h3",{className:"text-trieoh-base font-semibold m-0",children:[n.browser," - ",n.os]}),jsxs("span",{className:"inline-flex flex-col text-trieoh-sm font-extralight @[640px]:flex-row @[640px]:gap-2 @[640px]:items-center",children:[e&&jsx("strong",{className:"text-trieoh-primary font-normal",children:"\u2022 Sess\xE3o Atual \u2022"}),jsx("span",{children:`${i} - ${Xe(o)}`})]})]}),!e&&jsx(FaTrashAlt,{size:20,color:"red",onClick:a=>s(a,t),className:"absolute top-0 right-0 cursor-pointer opacity-60 transition-[opacity,transform] duration-200 hover:opacity-100 hover:scale-[1.05] active:scale-[0.95]"})]})})}function Ut({revokeAll:e=false,onSuccess:t}){let{auth:r}=S(),[o,i]=useState(false),[s,n]=useState([]),l=async()=>{let h=await r.sessions();if(h.success){let f=r.profile()?.session_id,g=h.data.sort((p,c)=>p.session_id===f?-1:c.session_id===f?1:0);n(g);}};useEffect(()=>{l();},[]);let a=async(h,f)=>{h.preventDefault();let g=s.find(p=>p.session_id===f);if(g){n(s.filter(p=>p.session_id!==f));try{(await r.revokeASession(f)).success||n(c=>[...c,g]);}catch{n(p=>[...p,g]);}}};return jsxs("div",{className:"font-inter w-full min-w-[20rem] m-2 @container bg-trieoh-neutral1 text-trieoh-neutral2 p-[1.5rem_0.5rem] rounded-lg",children:[jsxs("div",{className:"w-full flex flex-wrap items-center justify-center text-center gap-4 box-border px-[0.75rem] @[640px]:justify-between @[640px]:text-left @[640px]:gap-8",children:[jsxs("div",{className:"flex-[0_1_auto] max-w-[25rem]",children:[jsx("h3",{className:"font-semibold text-trieoh-2xl m-0 mb-1",children:"Navegadores e Dispositivos"}),jsx("p",{className:"font-extralight text-trieoh-base m-0",children:"Esses navegadores e dispositivos est\xE3o atualmente conectados \xE0 sua conta. Remova quaisquer dispositivos n\xE3o autorizados."})]}),jsx("button",{type:"submit",onClick:async h=>{if(h.preventDefault(),o)return;i(true);let f=await r.revokeSessions(e),g=r.profile()?.session_id;f.success&&(n(e?[]:s.filter(p=>p.session_id===g)),t&&t(f.message)),i(false);},disabled:o,className:`font-inter w-full max-w-[14rem] p-[1rem_0] h-auto text-trieoh-base font-semibold outline-none bg-transparent relative overflow-hidden shrink-0 border-2 border-trieoh-neutral2 text-trieoh-neutral2 cursor-pointer transition-transform duration-500 rounded-[0.25rem] hover:scale-[1.02] active:scale-[0.99] disabled:opacity-60 disabled:cursor-not-allowed disabled:!transform-none ${o?"trieoh-button-loading":""}`,children:"Revogar todas as sess\xF5es"})]}),jsx("div",{className:"mt-4",children:s.length>0?s.map(h=>jsx(Ie,{...h,is_current:r.profile()?.session_id===h.session_id,onClick:a},h.session_id)):jsx("span",{className:"block border-t border-[rgba(0,0,0,0.3)] p-[1.25rem_0.75rem] text-center font-semibold",children:"Nenhuma Sess\xE3o Dispon\xEDvel"})})]})}function Ze({onSuccess:e,onFailed:t,loginRedirect:r,emailRules:o}){let[i,s]=useState(""),[n,l]=useState(false),[a,d]=useState(false),h=useRef(null),{auth:f}=S(),p=C({email:o||[{message:"Digite um e-mail v\xE1lido, ex: exemplo@dominio.com",test:R=>/\S+@\S+\.\S+/.test(R)}]}.email,i);return jsxs("form",{className:"font-inter flex flex-col w-full max-w-[30rem] min-w-[15rem] max-h-[max(75dvh,32rem)] overflow-hidden gap-5 items-center bg-trieoh-neutral1 text-trieoh-neutral2 p-[1.25rem_1.5rem] shadow-[0_0.25rem_0.25rem_0_rgba(0,0,0,0.25)] transition-transform duration-150 ease-in-out rounded-[0.25rem]",children:[jsx(T,{mainText:"Esqueci a senha",subText:"Insira seu e-mail para receber um link de redefini\xE7\xE3o."}),jsx("div",{className:"w-full flex flex-col gap-[0.625rem] flex-[1_1_auto] overflow-y-auto mb-2",children:jsx(k,{label:"Email",name:"email",placeholder:"teste@gmail.com",autoComplete:"email",type:"email",value:i,onValueChange:s,inputRef:h,rulesStatus:p,submitted:n})}),jsx(E,{label:a?"Enviando...":"Enviar link de redefini\xE7\xE3o",onSubmit:async R=>{if(R.preventDefault(),l(true),p.some(A=>!A.passed)){h.current?.focus();return}d(true);let x=await f.sendForgotPassword(i);x.success?e&&await e(x.message):t&&await t(x.message,x.trace),d(false);},loading:a}),r&&jsxs(Fragment,{children:[jsxs("div",{className:"flex items-center gap-[0.625rem] w-full text-trieoh-base font-semibold opacity-60",children:[jsx("hr",{className:"flex-1"}),"OU",jsx("hr",{className:"flex-1"})]}),jsxs("span",{className:"text-trieoh-sm font-semibold",children:["Lembrou-se da sua senha? ",jsx("span",{className:"cursor-pointer text-trieoh-secondary transition-colors duration-200 hover:text-trieoh-primary",onClick:r,children:"Login"})]})]})]})}function Vt({token:e,onSuccess:t,onFailed:r,loginRedirect:o,passwordRules:i}){let[s,n]=useState(""),[l,a]=useState(""),[d,h]=useState(false),[f,g]=useState(false),p=useRef(null),c=useRef(null),{auth:R}=S(),_={password:i||[{message:"M\xEDnimo de 8 caracteres.",test:w=>w.length>=8},{message:"Deve conter uma letra mai\xFAscula.",test:w=>/[A-Z]/.test(w)},{message:"Inclua pelo menos um caractere especial, ex: ! @ # $ % & * . ,",test:w=>/[!@#$%^&*(),.?":{}|<>_\-+=~`;/\\[\]]/.test(w)},{message:"Deve conter um n\xFAmero.",test:w=>/\d/.test(w)}],confirmPassword:[{message:"Senhas n\xE3o conferem.",test:w=>w===s}]},x=C(_.password,s),A=C(_.confirmPassword,l);return jsxs("form",{className:"font-inter flex flex-col w-full max-w-[30rem] min-w-[15rem] max-h-[max(75dvh,32rem)] overflow-hidden gap-5 items-center bg-trieoh-neutral1 text-trieoh-neutral2 p-[1.25rem_1.5rem] shadow-[0_0.25rem_0.25rem_0_rgba(0,0,0,0.25)] transition-transform duration-150 ease-in-out rounded-[0.25rem]",children:[jsx(T,{mainText:"Redefinir Senha",subText:"Crie uma nova senha para sua conta"}),jsxs("div",{className:"w-full flex flex-col gap-[0.625rem] flex-[1_1_auto] overflow-y-auto mb-2",children:[jsx(k,{label:"Nova Senha",name:"password",placeholder:"**********",autoComplete:"new-password",type:"password",value:s,onValueChange:n,inputRef:p,rulesStatus:x,submitted:d}),jsx(k,{label:"Confirme a Nova Senha",name:"confirm-password",placeholder:"**********",autoComplete:"new-password",type:"password",value:l,onValueChange:a,inputRef:c,rulesStatus:A,submitted:d})]}),jsx(E,{label:"Redefinir Senha",onSubmit:async w=>{w.preventDefault(),h(true);let B=x.some(v=>!v.passed),V=A.some(v=>!v.passed);if(B){p.current?.focus();return}if(V){c.current?.focus();return}g(true);let N=await R.resetPassword(e,s);N.success?t&&await t(N.message):r&&await r(N.message,N.trace),g(false);},loading:f}),o&&jsxs("span",{className:"text-trieoh-sm font-semibold",children:["Lembrou-se da sua senha? ",jsx("span",{className:"cursor-pointer text-trieoh-secondary transition-colors duration-200 hover:text-trieoh-primary",onClick:o,children:"Login"})]})]})}function Kt(e,t,r){let[o,i]=useState(true),[s,n]=useState("verifying"),[l,a]=useState("Verificando seu e-mail..."),{auth:d}=S(),h=useRef(false),f=async()=>{if(!h.current){h.current=true,i(true),n("verifying");try{if(d.profile()?.is_verified){n("already_verified"),a("Seu e-mail j\xE1 est\xE1 verificado."),i(!1);return}let c=await d.verifyEmail(e);c.success?(await d.refresh(),n("success"),a(c.message||"E-mail verificado com sucesso!"),t&&await t(c.message)):(n("error"),a(c.message||"Falha na verifica\xE7\xE3o do e-mail."),r&&await r(c.message,c.trace));}catch{n("error"),a("Ocorreu um erro inesperado durante a verifica\xE7\xE3o.");}finally{i(false);}}};return useEffect(()=>{e&&!h.current&&f();},[e]),{loading:o,status:s,message:l,onRetry:p=>{p.preventDefault(),h.current=false,f();},setStatus:n,setLoading:i,setMessage:a}}function Yt({token:e,onSuccess:t,onFailed:r}){let{loading:o,status:i,message:s,onRetry:n}=Kt(e,t,r);return jsx("div",{className:"font-inter flex flex-col w-full h-full min-h-screen items-center justify-center bg-trieoh-neutral1 text-trieoh-neutral2 p-6",children:jsxs("div",{className:"w-full max-w-[30rem] flex flex-col gap-8 items-center bg-trieoh-neutral1 text-trieoh-neutral2 p-[1.25rem_1.5rem] shadow-[0_0.25rem_0.25rem_0_rgba(0,0,0,0.25)] rounded-[0.25rem]",children:[jsx(T,{mainText:i==="verifying"?"Verificando...":i==="error"?"Ops! Falha na verifica\xE7\xE3o":"Tudo pronto!",subText:s}),i==="verifying"&&jsx("div",{className:"w-full flex justify-center py-4",children:jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-trieoh-secondary"})}),i==="error"&&jsx("div",{className:"w-full flex flex-col gap-6 items-center",children:jsx("div",{className:"w-full mt-2",children:jsx(E,{label:"Tentar novamente",onSubmit:n,loading:o})})}),(i==="success"||i==="already_verified")&&jsxs("div",{className:"w-full flex flex-col gap-4 items-center",children:[jsx("div",{className:"w-16 h-16 flex items-center justify-center rounded-full bg-trieoh-secondary/10 text-trieoh-secondary",children:i==="success"?jsx(FiCheck,{size:40}):jsx(FiInfo,{size:40})}),jsx("p",{className:"text-trieoh-sm font-semibold opacity-50 text-center",children:"Voc\xEA j\xE1 pode fechar esta janela ou continuar navegando em sua conta."})]})]})})}function Wt({onSuccess:e,onFailed:t}){let[r,o]=useState(false),[i,s]=useState(false),{auth:n}=S();return jsxs("div",{className:"font-inter flex flex-col w-full max-w-[30rem] min-w-[15rem] max-h-[max(75dvh,32rem)] overflow-hidden gap-5 items-center bg-trieoh-neutral1 text-trieoh-neutral2 p-[1.25rem_1.5rem] shadow-[0_0.25rem_0.25rem_0_rgba(0,0,0,0.25)] transition-transform duration-150 ease-in-out rounded-[0.25rem]",children:[jsx(T,{mainText:"Reenviar Verifica\xE7\xE3o",subText:"N\xE3o recebeu o e-mail de verifica\xE7\xE3o? Clique no bot\xE3o abaixo para reenviar."}),jsx(E,{label:i?"E-mail Reenviado":"Reenviar E-mail de Verifica\xE7\xE3o",onSubmit:async()=>{o(true);let a=await n.resendVerifyEmail();a.success?(s(true),e&&await e(a.message)):t&&await t(a.message,a.trace),o(false);},loading:r}),i&&jsx("p",{className:"text-trieoh-sm font-semibold text-trieoh-secondary",children:"Um novo link de verifica\xE7\xE3o foi enviado para seu e-mail."})]})}export{Kr as AuthProvider,k as BasicInputField,It as BasicLogoutButton,Et as Copyright,Ze as ForgotPassword,Wt as ResendVerifyEmail,Vt as ResetPassword,Ut as Sessions,yt as SignIn,Rt as SignUp,Yt as VerifyEmail,S as useAuth};//# sourceMappingURL=react.js.map
|
|
1
|
+
import {createContext,forwardRef,useState,useId,useRef,useSyncExternalStore,useEffect,useCallback,useMemo,useContext}from'react';import {logger,createDefaultFetchClient,simpleFetch}from'@trieoh/envoy-fetch-ts';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {EyeOff,Eye,LogOut,Check,Info,Loader2,ArrowRight,CheckCircle2,XCircle,Sparkles,User,Monitor,Tablet,Smartphone,Trash2}from'lucide-react';import {UAParser}from'ua-parser-js';import {toast}from'sonner';import {useForm}from'react-hook-form';import {zodResolver}from'@hookform/resolvers/zod';import {z}from'zod';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {motion,AnimatePresence}from'motion/react';import {cva}from'class-variance-authority';function Be(e,r){if(r.startsWith("http"))return r;let t=e.replace(/\/$/,""),o=r.replace(/^\//,"");return `${t}/${o}`}var ae={isAuthenticated:false,isInitializing:true},De=new Set,ht=()=>De.forEach(e=>e()),A={subscribe:e=>(De.add(e),()=>De.delete(e)),getSnapshot:()=>ae,getServerSnapshot:()=>ae,set:e=>{ae={...ae,...e},ht();},reset:()=>{ae={isAuthenticated:false,isInitializing:false},ht();}};typeof window<"u"&&window.addEventListener("storage",e=>{if(e.key==="trieoh_access_expiry")if(!e.newValue)A.reset();else {let r=Number(e.newValue),t=!isNaN(r)&&r>Date.now();A.set({isAuthenticated:t,isInitializing:false});}});var O={getItem:e=>typeof window<"u"?localStorage.getItem(e):null,setItem:(e,r)=>{typeof window<"u"&&localStorage.setItem(e,r);},removeItem:e=>{typeof window<"u"&&localStorage.removeItem(e);}},ie={getItem:e=>typeof window<"u"?sessionStorage.getItem(e):null,setItem:(e,r)=>{typeof window<"u"&&sessionStorage.setItem(e,r);},removeItem:e=>{typeof window<"u"&&sessionStorage.removeItem(e);}};var xe="trieoh_access_token",K={getAccessToken:()=>ie.getItem(xe),setAccessToken:e=>{e?ie.setItem(xe,e):ie.removeItem(xe);},clear:()=>{ie.removeItem(xe);}};var se=null,Ue="trieoh_access_expiry",ye="trieoh_refresh_expiry",He="trieoh_refresh_token";function vt(e){try{let r=e.split(".")[1];if(!r)return null;let t=r.replace(/-/g,"+").replace(/_/g,"/");for(;t.length%4;)t+="=";let o=decodeURIComponent(atob(t).split("").map(a=>"%"+("00"+a.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(o)}catch(r){return logger.error("Error decoding JWT:",r),null}}function Z(e){let{access_token:r,refresh_token:t,access_expires_at:o,refresh_expires_at:a}=e,i=vt(r);if(!i){logger.error("Failed to decode tokens");return}K.setAccessToken(r);let s=new Date(a).getTime(),c=new Date(o).getTime();O.setItem(He,t),O.setItem(Ue,String(c)),O.setItem(ye,String(s)),se={access_data:i,refresh_expiry_date:s},A.set({isAuthenticated:true,isInitializing:false}),logger.log("Auth session saved");}function qe(){return O.getItem(He)}function le(){if(se)return se;let e=K.getAccessToken();if(!e)return null;let r=vt(e);if(!r||r.exp*1e3<=Date.now())return null;let t=O.getItem(ye);if(!t)return null;let o=Number(t);if(isNaN(o))return null;let a={access_data:r,refresh_expiry_date:o};return se=a,a}function wt(e,r){try{let t=O.getItem(e);if(!t)return !0;let o=Number(t);return isNaN(o)?!0:o-Date.now()<=r*1e3}catch(t){return logger.warn("Error reading expiry:",t),true}}var je=(e=30)=>wt(Ue,e),ke=(e=10)=>wt(ye,e);function ce(){se=null,K.clear(),O.removeItem(Ue),O.removeItem(ye),O.removeItem(He),A.reset(),logger.log("Auth tokens and claims cleared");}function bt(){let e=le();return e?e.access_data.sub:null}function qt(){let e=typeof window>"u",r=typeof import.meta<"u"&&import.meta.env?import.meta.env:{},t=typeof process<"u"?process.env:{},o=r.VITE_TRIEOH_AUTH_PROJECT_ID||t.NEXT_PUBLIC_TRIEOH_AUTH_PROJECT_ID||t.PUBLIC_TRIEOH_AUTH_PROJECT_ID||"",a=e&&t.TRIEOH_AUTH_API_KEY||"";return {PROJECT_ID:o,API_KEY:a,BASE_URL:"https://api.trieauth.trieoh.com"}}var Se=null,Je={};function xt(e){Je={...Je,...e},Se=null;}function $e(){return Se||(Se={...qt(),...Je}),Se}var k={get PROJECT_ID(){return $e().PROJECT_ID},get BASE_URL(){return $e().BASE_URL}};var Re=class{constructor(r){this.isRefreshing=false;this.refreshPromise=null;this.baseURL=r?.baseURL||k.BASE_URL,this.authBaseURL=r?.authBaseURL||this.baseURL,this.onTokenRefreshed=r?.onTokenRefreshed,this.onRefreshFailed=r?.onRefreshFailed;}async refreshToken(){return this.isRefreshing&&this.refreshPromise?this.refreshPromise:(this.isRefreshing=true,this.refreshPromise=(async()=>{let r=true;try{let t=qe();if(!t)throw r=!0,new Error("No refresh token available");let o=await simpleFetch(Be(this.authBaseURL,"/auth/refresh"),{method:"POST",credentials:"include",headers:{refresh_token:t}});if(o.code!==200||!o.data)throw r=o.code!==503,new Error(o.message||"Failed to refresh token");Z(o.data);let a=le();a&&this.onTokenRefreshed?.(a),logger.log("Token refreshed successfully");}catch(t){throw logger.warn("Failed to refresh token:",t),r&&ce(),this.onRefreshFailed?.(t),t}finally{this.isRefreshing=false,this.refreshPromise=null;}})(),this.refreshPromise)}async beforeRequest(){if(ke()){ce();return}if(!!!K.getAccessToken()||je(30))try{await this.refreshToken();}catch(t){logger.warn("Proactive refresh failed:",t);}}async fetch(r,t){let o=t?.requiresAuth!==false,a=r.includes("/auth/refresh");o&&!a&&!t?.skipRefresh&&await this.beforeRequest();let i=Be(this.baseURL,r),s=async()=>{let n=K.getAccessToken(),d=new Headers(t?.headers);return o&&n&&d.set("Authorization",`Bearer ${n}`),d.has("Content-Type")||d.set("Content-Type","application/json"),fetch(i,{...t,headers:d,credentials:"include"})},c=await s();if(c.status===401&&o&&!a){let n=!!qe(),d=je(30);if(n&&d){logger.log("401 detected and token is expiring/expired, attempting refresh...");try{await this.refreshToken(),c=await s();}catch{logger.error("Retry failed after refresh error");}}}return c}};function Y(e){if(!e)return;let{requiresAuth:r,skipRefresh:t,...o}=e,a={};return r!==void 0&&(a.requiresAuth=r),t!==void 0&&(a.skipRefresh=t),{...o,adapterInit:{...o.adapterInit,...a}}}var Pe=class{constructor(r,t,o,a){this.interceptor=new Re({baseURL:r,authBaseURL:t,onTokenRefreshed:o}),this.client=createDefaultFetchClient({...a,adapter:this.interceptor.fetch.bind(this.interceptor)});}request(r,t){return this.client.request(r,Y(t))}get(r,t){return this.client.get(r,Y(t))}post(r,t,o){return this.client.post(r,t,Y(o))}put(r,t,o){return this.client.put(r,t,Y(o))}patch(r,t,o){return this.client.patch(r,t,Y(o))}delete(r,t,o){return this.client.delete(r,t,Y(o))}query(r,t){return this.client.query(r,Y(t))}};var X=()=>{if(!k.PROJECT_ID||k.PROJECT_ID.trim()==="")throw new Error("[TRIEOH SDK] Project ID is missing. Please set PUBLIC_TRIEOH_AUTH_PROJECT_ID, NEXT_PUBLIC_TRIEOH_AUTH_PROJECT_ID or VITE_TRIEOH_AUTH_PROJECT_ID.")};var yt=(e,r)=>({isSetupDone:async()=>e.get("/auth/setup",{requiresAuth:false}),setup:async(t,o)=>{k.PROJECT_ID&&X();let a=`/auth/setup${k.PROJECT_ID?`?project_id=${k.PROJECT_ID}`:""}`,i=await e.post(a,{email:t,password:o},{requiresAuth:false});return i.success&&(Z(i.data),r?.onSetup?.(i)),i},login:async(t,o)=>{k.PROJECT_ID&&X();let a=`/auth/login${k.PROJECT_ID?`?project_id=${k.PROJECT_ID}`:""}`,i=await e.post(a,{email:t,password:o},{requiresAuth:false});return i.success&&(Z(i.data),r?.onLogin?.(i)),i},register:async(t,o)=>{let a={requiresAuth:false},i=`/auth/register${k.PROJECT_ID?`?project_id=${k.PROJECT_ID}`:""}`;k.PROJECT_ID&&X();let s=await e.post(i,{email:t,password:o},a);return s.success&&r?.onRegister?.(s),s},logout:async t=>{let o=`/auth/logout${k.PROJECT_ID?`?project_id=${k.PROJECT_ID}`:""}`,a=await e.post(o);return (a.success||t?.forceLogout)&&ce(),a},refresh:async()=>{let t=await e.post("/auth/refresh",void 0,{skipRefresh:true});return t.success&&(Z(t.data),r?.onRefresh?.(t)),t},sessions:async()=>e.get("/sessions"),currentSession:async()=>e.get("/sessions/me"),revokeASession:async t=>e.delete(`/sessions/${t}`),revokeSessions:async(t=false)=>{let o=t?"/sessions":"/sessions/others";return e.delete(o)},profile:()=>bt(),sendForgotPassword:async t=>{let o={requiresAuth:false};return k.PROJECT_ID?(X(),e.post("/account/forgot-password",{email:t,project_id:k.PROJECT_ID},o)):e.post("/account/forgot-password",{email:t},o)},resetPassword:async(t,o)=>{let a=await e.post(`/account/reset-password?token=${t}`,{new_password:o},{requiresAuth:false});return a.success&&r?.onResetPassword?.(a),a},verifyEmail:async t=>{let o=`/account/verify?token=${t}`,a=await e.post(o);return a.success&&r?.onVerify?.(a),a},resendVerifyEmail:async()=>e.post("/account/verify/resend"),health:async()=>e.get("/health",{requiresAuth:false}),authHealth:async()=>e.get("/protected/health")});var St=createContext(null);function za({children:e,baseURL:r,projectId:t,isProjectMode:o=true,fallback:a,waitSession:i=true,clientConfig:s,onLogin:c,onSetup:n,onResetPassword:d,onRegister:p,onVerify:l,onRefresh:f}){let h=useRef(false),{isAuthenticated:g,isInitializing:x}=useSyncExternalStore(A.subscribe,A.getSnapshot,A.getServerSnapshot);useEffect(()=>{xt({...t?{PROJECT_ID:t}:{},...r?{BASE_URL:r}:{}});},[t,r]);let E=useCallback(w=>{A.set({isAuthenticated:!!w.access_data,isInitializing:false}),f?.();},[f]),y=useMemo(()=>new Pe(r,void 0,E,s),[r,E,s]),C=useMemo(()=>yt(y,{onLogin:c,onSetup:n,onResetPassword:d,onRegister:p,onVerify:l,onRefresh:f}),[y,c,n,d,p,l,f]);useEffect(()=>{o&&X(),(async()=>{if(!h.current){if(h.current=true,le()){A.set({isAuthenticated:true,isInitializing:false});return}if(ke()){A.reset(),A.set({isInitializing:false});return}logger.log("No cached claims, attempting silent refresh...");try{await y.interceptor.refreshToken(),logger.log("Session restored.");}catch{A.reset(),logger.warn("Could not restore session (offline?).");}finally{A.set({isInitializing:false});}}})();},[C,o]);let J=useMemo(()=>({auth:C,isAuthenticated:g,isInitializing:x,isProjectMode:o}),[C,g,x,o]);return i&&x?a??null:jsx(St.Provider,{value:J,children:e})}function v(){let e=useContext(St);if(!e)throw new Error("useAuth must be used inside <AuthProvider>");return e}function Xe(e,{insertAt:r}={}){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",r==="top"&&t.firstChild?t.insertBefore(o,t.firstChild):t.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e));}Xe(`/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */@layer properties;@layer theme,base,components,utilities;@layer theme,base,components,utilities;@layer theme{:root,:host{--font-sans: var(--font-sans, "Inter", sans-serif);--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-green-500: oklch(72.3% .219 149.579);--spacing: .25rem;--container-md: 28rem;--text-xs: .75rem;--text-xs--line-height: calc(1 / .75);--text-sm: .875rem;--text-sm--line-height: calc(1.25 / .875);--text-base: 1rem;--text-base--line-height: 1.5 ;--text-lg: 1.125rem;--text-lg--line-height: calc(1.75 / 1.125);--text-xl: 1.25rem;--text-xl--line-height: calc(1.75 / 1.25);--text-2xl: 1.5rem;--text-2xl--line-height: calc(2 / 1.5);--text-3xl: 1.875rem;--text-3xl--line-height: 1.2 ;--text-4xl: 2.25rem;--text-4xl--line-height: calc(2.5 / 2.25);--font-weight-extralight: 200;--font-weight-light: 300;--font-weight-normal: 400;--font-weight-medium: 500;--font-weight-semibold: 600;--font-weight-bold: 700;--tracking-tighter: -.05em;--tracking-tight: -.025em;--tracking-normal: 0em;--tracking-wider: .05em;--tracking-widest: .1em;--radius-sm: calc(var(--radius, .625rem) - 4px);--radius-md: calc(var(--radius, .625rem) - 2px);--radius-lg: var(--radius, .625rem);--radius-2xl: 1rem;--ease-out: cubic-bezier(0, 0, .2, 1);--ease-in-out: cubic-bezier(.4, 0, .2, 1);--animate-spin: spin 1s linear infinite;--blur-sm: 8px;--blur-3xl: 64px;--default-transition-duration: .15s;--default-transition-timing-function: cubic-bezier(.4, 0, .2, 1);--default-font-family: var(--font-sans);--default-mono-font-family: var(--font-mono);--color-background: var(--background, oklch(.9702 0 0));--color-foreground: var(--foreground, oklch(.1944 .0051 248.09));--color-primary: var(--primary, oklch(.7975 .1018 262.7));--color-primary-foreground: var(--primary-foreground, oklch(.9702 0 0));--color-secondary: var(--secondary, oklch(.1139 .0789 264.05));--color-secondary-foreground: var(--secondary-foreground, oklch(.9702 0 0));--color-muted: var(--muted, oklch(.9569 .0026 248.09));--color-muted-foreground: var(--muted-foreground, oklch(.5278 0 0));--color-border: var(--border, oklch(.869 .0093 248.09));--color-input: var(--input, oklch(.9145 .0062 248.09));--color-destructive: var(--destructive, oklch(.6373 .1718 28.92));--color-destructive-foreground: var(--destructive-foreground, oklch(.9851 0 0));--color-ring: var(--ring, oklch(.7975 .1018 262.7));--color-accent: var(--accent, oklch(.9326 .0313 262.7));--color-accent-foreground: var(--accent-foreground, oklch(.1944 .0051 248.09));--radius-full: 9999px}}@layer base{*,:after,:before,::backdrop,::file-selector-button{box-sizing:border-box;margin:0;padding:0;border:0 solid}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;tab-size:4;font-family:var(--default-font-family, ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings, normal);font-variation-settings:var(--default-font-variation-settings, normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings, normal);font-variation-settings:var(--default-mono-font-variation-settings, normal);font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea,::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;border-radius:0;background-color:transparent;opacity:1}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px){::placeholder{color:currentcolor;@supports (color: color-mix(in lab,red,red)){color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit,::-webkit-datetime-edit-year-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]),::file-selector-button{appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.\\@container{container-type:inline-size}.pointer-events-none{pointer-events:none}.button-loading{&:after{content:"";position:absolute;top:0;left:-150%;width:150%;height:100%;background:linear-gradient(120deg,transparent 0%,var(--color-foreground) 40%,transparent 80%);@supports (color: color-mix(in lab,red,red)){background:linear-gradient(120deg,transparent 0%,color-mix(in oklab,var(--color-foreground) 40%,white 15%) 40%,transparent 80%)}animation:shine 1.5s infinite}}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.inset-0{inset:calc(var(--spacing) * 0)}.top-0{top:calc(var(--spacing) * 0)}.top-1\\.5{top:calc(var(--spacing) * 1.5)}.top-1\\/2{top:50%}.top-\\[-10\\%\\]{top:-10%}.right-0{right:calc(var(--spacing) * 0)}.right-3{right:calc(var(--spacing) * 3)}.right-\\[-10\\%\\]{right:-10%}.bottom-\\[-10\\%\\]{bottom:-10%}.left-3\\.5{left:calc(var(--spacing) * 3.5)}.left-\\[-10\\%\\]{left:-10%}.z-10{z-index:10}.m-0{margin:calc(var(--spacing) * 0)}.m-2{margin:calc(var(--spacing) * 2)}.m-\\[0\\.125rem\\]{margin:.125rem}.mx-auto{margin-inline:auto}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mt-8{margin-top:calc(var(--spacing) * 8)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-2\\.5{margin-bottom:calc(var(--spacing) * 2.5)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.mb-6{margin-bottom:calc(var(--spacing) * 6)}.mb-10{margin-bottom:calc(var(--spacing) * 10)}.box-border{box-sizing:border-box}.block{display:block}.contents{display:contents}.flex{display:flex}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.h-1{height:calc(var(--spacing) * 1)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-9{height:calc(var(--spacing) * 9)}.h-10{height:calc(var(--spacing) * 10)}.h-11{height:calc(var(--spacing) * 11)}.h-12{height:calc(var(--spacing) * 12)}.h-13{height:calc(var(--spacing) * 13)}.h-16{height:calc(var(--spacing) * 16)}.h-\\[40\\%\\]{height:40%}.h-auto{height:auto}.h-full{height:100%}.max-h-\\[max\\(75dvh\\,32rem\\)\\]{max-height:max(75dvh,32rem)}.min-h-80{min-height:calc(var(--spacing) * 80)}.min-h-screen{min-height:100vh}.w-4{width:calc(var(--spacing) * 4)}.w-5{width:calc(var(--spacing) * 5)}.w-10{width:calc(var(--spacing) * 10)}.w-12{width:calc(var(--spacing) * 12)}.w-16{width:calc(var(--spacing) * 16)}.w-\\[40\\%\\]{width:40%}.w-full{width:100%}.max-w-56{max-width:calc(var(--spacing) * 56)}.max-w-100{max-width:calc(var(--spacing) * 100)}.max-w-120{max-width:calc(var(--spacing) * 120)}.max-w-\\[320px\\]{max-width:320px}.max-w-md{max-width:var(--container-md)}.min-w-0{min-width:calc(var(--spacing) * 0)}.min-w-40{min-width:calc(var(--spacing) * 40)}.min-w-60{min-width:calc(var(--spacing) * 60)}.min-w-\\[20rem\\]{min-width:20rem}.flex-1{flex:1}.flex-\\[0_1_auto\\]{flex:0 1 auto}.flex-\\[1_1_auto\\]{flex:1 1 auto}.shrink-0{flex-shrink:0}.-translate-y-1\\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.animate-spin{animation:var(--animate-spin)}.cursor-pointer{cursor:pointer}.appearance-none{appearance:none}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\\.5{gap:calc(var(--spacing) * 2.5)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-5{gap:calc(var(--spacing) * 5)}.gap-6{gap:calc(var(--spacing) * 6)}.gap-8{gap:calc(var(--spacing) * 8)}.space-y-1{:where(&>:not(:last-child)){--tw-space-y-reverse: 0;margin-block-start:calc(calc(var(--spacing) * 1) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1) * calc(1 - var(--tw-space-y-reverse)))}}.space-y-4{:where(&>:not(:last-child)){--tw-space-y-reverse: 0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}}.space-y-5{:where(&>:not(:last-child)){--tw-space-y-reverse: 0;margin-block-start:calc(calc(var(--spacing) * 5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 5) * calc(1 - var(--tw-space-y-reverse)))}}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-\\[14px\\]{border-radius:14px}.rounded-full{border-radius:var(--radius-full)}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-none{--tw-border-style: none;border-style:none}.border-border{border-color:var(--color-border)}.border-border\\/40{border-color:var(--color-border);@supports (color: color-mix(in lab,red,red)){border-color:color-mix(in oklab,var(--color-border) 40%,transparent)}}.border-border\\/50{border-color:var(--color-border);@supports (color: color-mix(in lab,red,red)){border-color:color-mix(in oklab,var(--color-border) 50%,transparent)}}.border-destructive\\!{border-color:var(--color-destructive)!important}.border-destructive\\/50{border-color:var(--color-destructive);@supports (color: color-mix(in lab,red,red)){border-color:color-mix(in oklab,var(--color-destructive) 50%,transparent)}}.border-foreground{border-color:var(--color-foreground)}.border-input{border-color:var(--color-input)}.border-primary{border-color:var(--color-primary)}.border-secondary\\/20{border-color:var(--color-secondary);@supports (color: color-mix(in lab,red,red)){border-color:color-mix(in oklab,var(--color-secondary) 20%,transparent)}}.bg-background{background-color:var(--color-background)}.bg-destructive{background-color:var(--color-destructive)}.bg-destructive\\/5{background-color:var(--color-destructive);@supports (color: color-mix(in lab,red,red)){background-color:color-mix(in oklab,var(--color-destructive) 5%,transparent)}}.bg-foreground\\/10{background-color:var(--color-foreground);@supports (color: color-mix(in lab,red,red)){background-color:color-mix(in oklab,var(--color-foreground) 10%,transparent)}}.bg-muted\\/30{background-color:var(--color-muted);@supports (color: color-mix(in lab,red,red)){background-color:color-mix(in oklab,var(--color-muted) 30%,transparent)}}.bg-muted\\/40{background-color:var(--color-muted);@supports (color: color-mix(in lab,red,red)){background-color:color-mix(in oklab,var(--color-muted) 40%,transparent)}}.bg-muted\\/50{background-color:var(--color-muted);@supports (color: color-mix(in lab,red,red)){background-color:color-mix(in oklab,var(--color-muted) 50%,transparent)}}.bg-primary{background-color:var(--color-primary)}.bg-primary\\/10{background-color:var(--color-primary);@supports (color: color-mix(in lab,red,red)){background-color:color-mix(in oklab,var(--color-primary) 10%,transparent)}}.bg-primary\\/20{background-color:var(--color-primary);@supports (color: color-mix(in lab,red,red)){background-color:color-mix(in oklab,var(--color-primary) 20%,transparent)}}.bg-primary\\/40{background-color:var(--color-primary);@supports (color: color-mix(in lab,red,red)){background-color:color-mix(in oklab,var(--color-primary) 40%,transparent)}}.bg-secondary{background-color:var(--color-secondary)}.bg-transparent{background-color:transparent}.p-1{padding:calc(var(--spacing) * 1)}.p-2{padding:calc(var(--spacing) * 2)}.p-2\\.5{padding:calc(var(--spacing) * 2.5)}.p-6{padding:calc(var(--spacing) * 6)}.p-\\[1\\.5rem_0\\.5rem\\]{padding:1.5rem .5rem}.p-\\[1\\.25rem_0\\.75rem\\]{padding:1.25rem .75rem}.p-\\[1\\.25rem_1\\.5rem\\]{padding:1.25rem 1.5rem}.p-\\[1rem_0\\]{padding:1rem 0}.px-1{padding-inline:calc(var(--spacing) * 1)}.px-2\\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-3\\.5{padding-inline:calc(var(--spacing) * 3.5)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-6{padding-inline:calc(var(--spacing) * 6)}.px-8{padding-inline:calc(var(--spacing) * 8)}.py-0\\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-px{padding-block:1px}.pt-4{padding-top:calc(var(--spacing) * 4)}.pr-10{padding-right:calc(var(--spacing) * 10)}.pb-1{padding-bottom:calc(var(--spacing) * 1)}.text-center{text-align:center}.font-sans{font-family:var(--font-sans)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading, var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading, var(--text-3xl--line-height))}.text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading, var(--text-4xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading, var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading, var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading, var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading, var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading, var(--text-xs--line-height))}.text-\\[10px\\]{font-size:10px}.text-\\[11px\\]{font-size:11px}.leading-none{--tw-leading: 1;line-height:1}.font-bold{--tw-font-weight: var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-extralight{--tw-font-weight: var(--font-weight-extralight);font-weight:var(--font-weight-extralight)}.font-light{--tw-font-weight: var(--font-weight-light);font-weight:var(--font-weight-light)}.font-medium{--tw-font-weight: var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight: var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight: var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-tight{--tw-tracking: var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-tighter{--tw-tracking: var(--tracking-tighter);letter-spacing:var(--tracking-tighter)}.tracking-wider{--tw-tracking: var(--tracking-wider);letter-spacing:var(--tracking-wider)}.tracking-widest{--tw-tracking: var(--tracking-widest);letter-spacing:var(--tracking-widest)}.whitespace-nowrap{white-space:nowrap}.text-destructive{color:var(--color-destructive)}.text-destructive-foreground{color:var(--color-destructive-foreground)}.text-destructive\\/80{color:var(--color-destructive);@supports (color: color-mix(in lab,red,red)){color:color-mix(in oklab,var(--color-destructive) 80%,transparent)}}.text-foreground{color:var(--color-foreground)}.text-green-500{color:var(--color-green-500)}.text-muted-foreground{color:var(--color-muted-foreground)}.text-primary{color:var(--color-primary)}.text-primary-foreground{color:var(--color-primary-foreground)}.text-primary\\/70{color:var(--color-primary);@supports (color: color-mix(in lab,red,red)){color:color-mix(in oklab,var(--color-primary) 70%,transparent)}}.text-secondary-foreground{color:var(--color-secondary-foreground)}.uppercase{text-transform:uppercase}.line-through{text-decoration-line:line-through}.underline-offset-4{text-underline-offset:4px}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.opacity-50{opacity:50%}.opacity-60{opacity:60%}.opacity-95{opacity:95%}.opacity-100{opacity:100%}.shadow-\\[0_0\\.25rem_0\\.25rem_0_rgba\\(0\\,0\\,0\\,0\\.25\\)\\]{--tw-shadow: 0 .25rem .25rem 0 var(--tw-shadow-color, rgba(0,0,0,.25));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\\[0_0\\.25rem_1rem_rgba\\(0\\,0\\,0\\,0\\.25\\)\\]{--tw-shadow: 0 .25rem 1rem var(--tw-shadow-color, rgba(0,0,0,.25));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px var(--tw-shadow-color, rgb(0 0 0 / .1)), 0 4px 6px -4px var(--tw-shadow-color, rgb(0 0 0 / .1));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-none\\!{--tw-shadow: 0 0 #0000 !important;box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)!important}.shadow-sm{--tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / .1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / .1));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-1{--tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-primary\\/10{--tw-shadow-color: var(--color-primary);@supports (color: color-mix(in lab,red,red)){--tw-shadow-color: color-mix(in oklab, color-mix(in oklab, var(--color-primary) 10%, transparent) var(--tw-shadow-alpha), transparent)}}.ring-destructive\\/20{--tw-ring-color: var(--color-destructive);@supports (color: color-mix(in lab,red,red)){--tw-ring-color: color-mix(in oklab, var(--color-destructive) 20%, transparent)}}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur-3xl{--tw-blur: blur(var(--blur-3xl));filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.backdrop-blur-sm{--tw-backdrop-blur: blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease, var(--default-transition-timing-function));transition-duration:var(--tw-duration, var(--default-transition-duration))}.transition-\\[color\\,text-decoration\\,opacity\\]{transition-property:color,text-decoration,opacity;transition-timing-function:var(--tw-ease, var(--default-transition-timing-function));transition-duration:var(--tw-duration, var(--default-transition-duration))}.transition-\\[opacity\\,transform\\]{transition-property:opacity,transform;transition-timing-function:var(--tw-ease, var(--default-transition-timing-function));transition-duration:var(--tw-duration, var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease, var(--default-transition-timing-function));transition-duration:var(--tw-duration, var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease, var(--default-transition-timing-function));transition-duration:var(--tw-duration, var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease, var(--default-transition-timing-function));transition-duration:var(--tw-duration, var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease, var(--default-transition-timing-function));transition-duration:var(--tw-duration, var(--default-transition-duration))}.duration-150{--tw-duration: .15s;transition-duration:.15s}.duration-200{--tw-duration: .2s;transition-duration:.2s}.duration-500{--tw-duration: .5s;transition-duration:.5s}.duration-\\[120ms\\]{--tw-duration: .12s;transition-duration:.12s}.ease-in-out{--tw-ease: var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease: var(--ease-out);transition-timing-function:var(--ease-out)}.outline-none{--tw-outline-style: none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.group-hover\\:translate-x-1{&:is(:where(.group):hover *){@media(hover:hover){--tw-translate-x: calc(var(--spacing) * 1);translate:var(--tw-translate-x) var(--tw-translate-y)}}}.peer-placeholder-shown\\:top-3\\.5{&:is(:where(.peer):placeholder-shown~*){top:calc(var(--spacing) * 3.5)}}.peer-placeholder-shown\\:text-\\[15px\\]{&:is(:where(.peer):placeholder-shown~*){font-size:15px}}.peer-placeholder-shown\\:font-normal{&:is(:where(.peer):placeholder-shown~*){--tw-font-weight: var(--font-weight-normal);font-weight:var(--font-weight-normal)}}.peer-placeholder-shown\\:tracking-normal{&:is(:where(.peer):placeholder-shown~*){--tw-tracking: var(--tracking-normal);letter-spacing:var(--tracking-normal)}}.peer-placeholder-shown\\:text-destructive\\/60{&:is(:where(.peer):placeholder-shown~*){color:var(--color-destructive);@supports (color: color-mix(in lab,red,red)){color:color-mix(in oklab,var(--color-destructive) 60%,transparent)}}}.peer-placeholder-shown\\:text-muted-foreground{&:is(:where(.peer):placeholder-shown~*){color:var(--color-muted-foreground)}}.peer-focus\\:top-1\\.5{&:is(:where(.peer):focus~*){top:calc(var(--spacing) * 1.5)}}.peer-focus\\:text-\\[10px\\]{&:is(:where(.peer):focus~*){font-size:10px}}.peer-focus\\:font-semibold{&:is(:where(.peer):focus~*){--tw-font-weight: var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}}.peer-focus\\:tracking-wider{&:is(:where(.peer):focus~*){--tw-tracking: var(--tracking-wider);letter-spacing:var(--tracking-wider)}}.peer-focus\\:text-destructive\\/80{&:is(:where(.peer):focus~*){color:var(--color-destructive);@supports (color: color-mix(in lab,red,red)){color:color-mix(in oklab,var(--color-destructive) 80%,transparent)}}}.peer-focus\\:text-primary\\/70{&:is(:where(.peer):focus~*){color:var(--color-primary);@supports (color: color-mix(in lab,red,red)){color:color-mix(in oklab,var(--color-primary) 70%,transparent)}}}.selection\\:bg-primary\\/10{& *::selection{background-color:var(--color-primary);@supports (color: color-mix(in lab,red,red)){background-color:color-mix(in oklab,var(--color-primary) 10%,transparent)}}&::selection{background-color:var(--color-primary);@supports (color: color-mix(in lab,red,red)){background-color:color-mix(in oklab,var(--color-primary) 10%,transparent)}}}.selection\\:text-primary{& *::selection{color:var(--color-primary)}&::selection{color:var(--color-primary)}}.placeholder\\:text-transparent{&::placeholder{color:transparent}}.hover\\:scale-\\[1\\.02\\]{&:hover{@media(hover:hover){scale:1.02}}}.hover\\:scale-\\[1\\.05\\]{&:hover{@media(hover:hover){scale:1.05}}}.hover\\:bg-accent{&:hover{@media(hover:hover){background-color:var(--color-accent)}}}.hover\\:text-accent-foreground{&:hover{@media(hover:hover){color:var(--color-accent-foreground)}}}.hover\\:text-primary\\/70{&:hover{@media(hover:hover){color:var(--color-primary);@supports (color: color-mix(in lab,red,red)){color:color-mix(in oklab,var(--color-primary) 70%,transparent)}}}}.hover\\:underline{&:hover{@media(hover:hover){text-decoration-line:underline}}}.hover\\:opacity-80{&:hover{@media(hover:hover){opacity:80%}}}.hover\\:opacity-90{&:hover{@media(hover:hover){opacity:90%}}}.hover\\:opacity-100{&:hover{@media(hover:hover){opacity:100%}}}.focus\\:bg-muted\\/60{&:focus{background-color:var(--color-muted);@supports (color: color-mix(in lab,red,red)){background-color:color-mix(in oklab,var(--color-muted) 60%,transparent)}}}.focus\\:outline-none{&:focus{--tw-outline-style: none;outline-style:none}}.focus-visible\\:ring-0{&:focus-visible{--tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus-visible\\:ring-1{&:focus-visible{--tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus-visible\\:ring-ring{&:focus-visible{--tw-ring-color: var(--color-ring)}}.focus-visible\\:outline-none{&:focus-visible{--tw-outline-style: none;outline-style:none}}.active\\:scale-\\[0\\.95\\]{&:active{scale:.95}}.active\\:scale-\\[0\\.98\\]{&:active{scale:.98}}.active\\:scale-\\[0\\.99\\]{&:active{scale:.99}}.disabled\\:pointer-events-none{&:disabled{pointer-events:none}}.disabled\\:transform-none\\!{&:disabled{transform:none!important}}.disabled\\:cursor-not-allowed{&:disabled{cursor:not-allowed}}.disabled\\:opacity-50{&:disabled{opacity:50%}}.disabled\\:opacity-60{&:disabled{opacity:60%}}.\\@\\[640px\\]\\:flex-row{@container (width >= 640px){flex-direction:row}}.\\@\\[640px\\]\\:items-center{@container (width >= 640px){align-items:center}}.\\@\\[640px\\]\\:justify-between{@container (width >= 640px){justify-content:space-between}}.\\@\\[640px\\]\\:gap-2{@container (width >= 640px){gap:calc(var(--spacing) * 2)}}.\\@\\[640px\\]\\:gap-4{@container (width >= 640px){gap:calc(var(--spacing) * 4)}}.\\@\\[640px\\]\\:gap-8{@container (width >= 640px){gap:calc(var(--spacing) * 8)}}.\\@\\[640px\\]\\:text-left{@container (width >= 640px){text-align:left}}}@import url(https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap);@layer base{button:not(:disabled),[role=button]:not(:disabled){cursor:pointer}}@property --tw-translate-x{syntax: "*"; inherits: false; initial-value: 0;}@property --tw-translate-y{syntax: "*"; inherits: false; initial-value: 0;}@property --tw-translate-z{syntax: "*"; inherits: false; initial-value: 0;}@property --tw-space-y-reverse{syntax: "*"; inherits: false; initial-value: 0;}@property --tw-border-style{syntax: "*"; inherits: false; initial-value: solid;}@property --tw-leading{syntax: "*"; inherits: false;}@property --tw-font-weight{syntax: "*"; inherits: false;}@property --tw-tracking{syntax: "*"; inherits: false;}@property --tw-shadow{syntax: "*"; inherits: false; initial-value: 0 0 #0000;}@property --tw-shadow-color{syntax: "*"; inherits: false;}@property --tw-shadow-alpha{syntax: "<percentage>"; inherits: false; initial-value: 100%;}@property --tw-inset-shadow{syntax: "*"; inherits: false; initial-value: 0 0 #0000;}@property --tw-inset-shadow-color{syntax: "*"; inherits: false;}@property --tw-inset-shadow-alpha{syntax: "<percentage>"; inherits: false; initial-value: 100%;}@property --tw-ring-color{syntax: "*"; inherits: false;}@property --tw-ring-shadow{syntax: "*"; inherits: false; initial-value: 0 0 #0000;}@property --tw-inset-ring-color{syntax: "*"; inherits: false;}@property --tw-inset-ring-shadow{syntax: "*"; inherits: false; initial-value: 0 0 #0000;}@property --tw-ring-inset{syntax: "*"; inherits: false;}@property --tw-ring-offset-width{syntax: "<length>"; inherits: false; initial-value: 0px;}@property --tw-ring-offset-color{syntax: "*"; inherits: false; initial-value: #fff;}@property --tw-ring-offset-shadow{syntax: "*"; inherits: false; initial-value: 0 0 #0000;}@property --tw-outline-style{syntax: "*"; inherits: false; initial-value: solid;}@property --tw-blur{syntax: "*"; inherits: false;}@property --tw-brightness{syntax: "*"; inherits: false;}@property --tw-contrast{syntax: "*"; inherits: false;}@property --tw-grayscale{syntax: "*"; inherits: false;}@property --tw-hue-rotate{syntax: "*"; inherits: false;}@property --tw-invert{syntax: "*"; inherits: false;}@property --tw-opacity{syntax: "*"; inherits: false;}@property --tw-saturate{syntax: "*"; inherits: false;}@property --tw-sepia{syntax: "*"; inherits: false;}@property --tw-drop-shadow{syntax: "*"; inherits: false;}@property --tw-drop-shadow-color{syntax: "*"; inherits: false;}@property --tw-drop-shadow-alpha{syntax: "<percentage>"; inherits: false; initial-value: 100%;}@property --tw-drop-shadow-size{syntax: "*"; inherits: false;}@property --tw-backdrop-blur{syntax: "*"; inherits: false;}@property --tw-backdrop-brightness{syntax: "*"; inherits: false;}@property --tw-backdrop-contrast{syntax: "*"; inherits: false;}@property --tw-backdrop-grayscale{syntax: "*"; inherits: false;}@property --tw-backdrop-hue-rotate{syntax: "*"; inherits: false;}@property --tw-backdrop-invert{syntax: "*"; inherits: false;}@property --tw-backdrop-opacity{syntax: "*"; inherits: false;}@property --tw-backdrop-saturate{syntax: "*"; inherits: false;}@property --tw-backdrop-sepia{syntax: "*"; inherits: false;}@property --tw-duration{syntax: "*"; inherits: false;}@property --tw-ease{syntax: "*"; inherits: false;}@keyframes spin{to{transform:rotate(360deg)}}@keyframes shine{0%{left:-150%}to{left:150%}}@layer properties{@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x: 0;--tw-translate-y: 0;--tw-translate-z: 0;--tw-space-y-reverse: 0;--tw-border-style: solid;--tw-leading: initial;--tw-font-weight: initial;--tw-tracking: initial;--tw-shadow: 0 0 #0000;--tw-shadow-color: initial;--tw-shadow-alpha: 100%;--tw-inset-shadow: 0 0 #0000;--tw-inset-shadow-color: initial;--tw-inset-shadow-alpha: 100%;--tw-ring-color: initial;--tw-ring-shadow: 0 0 #0000;--tw-inset-ring-color: initial;--tw-inset-ring-shadow: 0 0 #0000;--tw-ring-inset: initial;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-offset-shadow: 0 0 #0000;--tw-outline-style: solid;--tw-blur: initial;--tw-brightness: initial;--tw-contrast: initial;--tw-grayscale: initial;--tw-hue-rotate: initial;--tw-invert: initial;--tw-opacity: initial;--tw-saturate: initial;--tw-sepia: initial;--tw-drop-shadow: initial;--tw-drop-shadow-color: initial;--tw-drop-shadow-alpha: 100%;--tw-drop-shadow-size: initial;--tw-backdrop-blur: initial;--tw-backdrop-brightness: initial;--tw-backdrop-contrast: initial;--tw-backdrop-grayscale: initial;--tw-backdrop-hue-rotate: initial;--tw-backdrop-invert: initial;--tw-backdrop-opacity: initial;--tw-backdrop-saturate: initial;--tw-backdrop-sepia: initial;--tw-duration: initial;--tw-ease: initial}}}
|
|
2
|
+
`);function T({name:e,label:r,placeholder:t,type:o="text",value:a,onValueChange:i,onBlur:s,autoComplete:c,rulesStatus:n=[],submitted:d=false,inputRef:p}){let[l,f]=useState(false),h=n.some(g=>!g.passed);return jsxs("div",{className:"font-sans relative w-full flex flex-col gap-1 text-foreground",children:[jsx("label",{htmlFor:e,className:"text-base font-semibold",children:r}),jsxs("div",{className:`flex justify-between items-center px-2.5 py-px gap-2.5 border-b-2 border-foreground ${h&&d?"border-destructive!":""}`,children:[jsx("input",{type:l?"text":o,name:e,id:e,placeholder:t,value:a,onChange:g=>i&&i(g.target.value),onBlur:s,autoComplete:c,"aria-invalid":h&&d,ref:p,className:"min-w-40 flex-1 text-base font-light text-foreground appearance-none bg-transparent outline-none border-none shadow-none! py-0.5"}),o==="password"&&(l?jsx(EyeOff,{className:"cursor-pointer shrink-0 select-none",size:24,onClick:()=>f(false)}):jsx(Eye,{className:"cursor-pointer shrink-0 select-none",size:24,onClick:()=>f(true)}))]}),jsx("div",{className:"text-xs text-muted-foreground transition-opacity duration-200 ease-in-out",children:n.map((g,x)=>{let E=["transition-[color,text-decoration,opacity] duration-[120ms] ease opacity-95 m-[0.125rem]",g.passed?"line-through opacity-60 text-green-500":"",!g.passed&&d?"text-destructive font-semibold opacity-100":""].filter(Boolean).join(" ");return jsx("p",{className:E,children:g.message},g.id??x)})})]})}function _({label:e,onSubmit:r,loading:t}){return jsx("button",{type:"submit",onClick:r,disabled:t,className:`font-sans w-full h-13 text-xl font-semibold outline-none bg-transparent relative overflow-hidden min-w-40 shrink-0 border-2 border-foreground text-foreground cursor-pointer px-6 transition-transform duration-500 rounded-lg hover:scale-[1.02] active:scale-[0.99] disabled:opacity-60 disabled:cursor-not-allowed disabled:transform-none! ${t?"button-loading":""}`,children:e})}function N({mainText:e,subText:r}){return jsxs("div",{className:"font-sans flex flex-col items-center",children:[jsx("div",{className:"flex justify-center items-center p-2 bg-foreground/10 rounded-full mb-2.5",children:jsx(User,{className:"w-16 h-16 p-2.5 bg-background rounded-full shadow-[0_0.25rem_1rem_rgba(0,0,0,0.25)]",size:70})}),jsx("h3",{className:"text-center text-xl font-medium m-0",children:e}),jsx("span",{className:"text-center text-sm font-light opacity-60",children:r})]})}function L(e,r){return e.map(t=>({id:t.id,message:t.message,passed:!!t.test(r)}))}function ar({onSuccess:e,onFailed:r,signUpRedirect:t,forgotPasswordRedirect:o,emailRules:a}){let[i,s]=useState(""),[c,n]=useState(""),[d,p]=useState(false),[l,f]=useState(false),h=useRef(null),g=useRef(null),{auth:x}=v(),E={email:a||[{message:"Digite um e-mail v\xE1lido, ex: exemplo@dominio.com",test:w=>/\S+@\S+\.\S+/.test(w)}],password:[]},y=L(E.email,i),C=L(E.password,c);return jsxs("form",{className:"font-sans flex flex-col w-full max-w-120 min-w-60 max-h-[max(75dvh,32rem)] overflow-hidden gap-5 items-center bg-background text-foreground p-[1.25rem_1.5rem] shadow-[0_0.25rem_0.25rem_0_rgba(0,0,0,0.25)] transition-transform duration-150 ease-in-out rounded-lg",children:[jsx(N,{mainText:"Fa\xE7a login na sua conta",subText:"Insira seus dados para fazer login"}),jsxs("div",{className:"w-full flex flex-col gap-2.5 flex-[1_1_auto] overflow-y-auto mb-2",children:[jsx(T,{label:"Email",name:"email",placeholder:"teste@gmail.com",autoComplete:"email",type:"email",value:i,onValueChange:s,inputRef:h,rulesStatus:y,submitted:d}),jsx(T,{label:"Senha",name:"password",placeholder:"**********",autoComplete:"current-password",type:"password",value:c,onValueChange:n,inputRef:g,rulesStatus:C,submitted:d})]}),jsx(_,{label:"Entrar",onSubmit:async w=>{w.preventDefault(),p(true);let Q=y.some(b=>!b.passed),W=C.some(b=>!b.passed);if(Q){h.current?.focus();return}if(W){g.current?.focus();return}f(true);let V=await x.login(i,c);V.success?e&&await e(V.message):r&&await r(V.message,V.trace),f(false);},loading:l}),o&&jsx("span",{className:"text-sm font-semibold text-center cursor-pointer",children:jsx("span",{className:"cursor-pointer text-primary transition-colors duration-200 hover:opacity-80",onClick:o,children:"Esqueceu sua senha?"})}),t&&jsxs(Fragment,{children:[jsxs("div",{className:"flex items-center gap-2.5 w-full text-base font-semibold opacity-60",children:[jsx("hr",{className:"flex-1"}),"OU",jsx("hr",{className:"flex-1"})]}),jsxs("span",{className:"text-sm font-semibold",children:["Ainda n\xE3o possui uma conta? ",jsx("span",{className:"cursor-pointer text-primary transition-colors duration-200 hover:opacity-80",onClick:t,children:"Cadastra-se"})]})]})]})}function sr({onSuccess:e,onFailed:r,loginRedirect:t,emailRules:o,passwordRules:a}){let[i,s]=useState(""),[c,n]=useState(""),[d,p]=useState(""),[l,f]=useState(false),[h,g]=useState(false),x=useRef(null),E=useRef(null),y=useRef(null),{auth:C}=v(),J={email:o||[{message:"Digite um e-mail v\xE1lido, ex: exemplo@dominio.com",test:b=>/\S+@\S+\.\S+/.test(b)}],password:a||[{message:"M\xEDnimo de 8 caracteres.",test:b=>b.length>=8},{message:"Deve conter uma letra mai\xFAscula.",test:b=>/[A-Z]/.test(b)},{message:"Inclua pelo menos um caractere especial, ex: ! @ # $ % & * . ,",test:b=>/[!@#$%^&*(),.?":{}|<>_\-+=~`;/\\[\]]/.test(b)},{message:"Deve conter um n\xFAmero.",test:b=>/\d/.test(b)}],confirmPassword:[{message:"Senhas n\xE3o conferem.",test:b=>b===c}]},w=L(J.email,i),Q=L(J.password,c),W=L(J.confirmPassword,d);return jsxs("form",{className:"font-sans flex flex-col w-full max-w-120 min-w-60 max-h-[max(75dvh,32rem)] overflow-hidden gap-5 items-center bg-background text-foreground p-[1.25rem_1.5rem] shadow-[0_0.25rem_0.25rem_0_rgba(0,0,0,0.25)] transition-transform duration-150 ease-in-out rounded-lg",children:[jsx(N,{mainText:"Crie sua conta",subText:"Insira seus dados para come\xE7ar"}),jsxs("div",{className:"w-full flex flex-col gap-2.5 flex-[1_1_auto] overflow-y-auto mb-2",children:[jsx(T,{label:"Email",name:"email",placeholder:"teste@gmail.com",autoComplete:"email",type:"email",value:i,onValueChange:s,inputRef:x,rulesStatus:w,submitted:l}),jsx(T,{label:"Senha",name:"password",placeholder:"**********",autoComplete:"new-password",type:"password",value:c,onValueChange:n,inputRef:E,rulesStatus:Q,submitted:l}),jsx(T,{label:"Confirme a Senha",name:"confirm-password",placeholder:"**********",autoComplete:"new-password",type:"password",value:d,onValueChange:p,inputRef:y,rulesStatus:W,submitted:l})]}),jsx(_,{label:"Criar Conta",onSubmit:async b=>{b.preventDefault(),f(true);let Dt=w.some(oe=>!oe.passed),Ut=Q.some(oe=>!oe.passed),Ht=W.some(oe=>!oe.passed);if(Dt){x.current?.focus();return}if(Ut){E.current?.focus();return}if(Ht){y.current?.focus();return}g(true);let be=await C.register(i,c);be.success?e&&await e(be.message):r&&await r(be.message,be.trace),g(false);},loading:h}),t&&jsxs(Fragment,{children:[jsxs("div",{className:"flex items-center gap-2.5 w-full text-base font-semibold opacity-60",children:[jsx("hr",{className:"flex-1"}),"OU",jsx("hr",{className:"flex-1"})]}),jsxs("span",{className:"text-sm font-semibold",children:["J\xE1 possui uma conta? ",jsx("span",{className:"cursor-pointer text-primary transition-colors duration-200 hover:opacity-80",onClick:t,children:"Entre"})]})]})]})}var lr={xs:"text-xs",sm:"text-sm",md:"text-base",lg:"text-lg",xl:"text-xl","2xl":"text-2xl"};function cr({size:e}){let r=e?lr[e]:"text-base";return jsxs("span",{className:`font-sans font-medium ${r}`,children:["\xA9 ",new Date().getFullYear()," TrieOH"]})}function ur({onSuccess:e,onFailed:r,forceLogout:t}){let{auth:o}=v(),[a,i]=useState(false);return jsxs("button",{onClick:async c=>{if(c.preventDefault(),a)return;i(true);let n=await o.logout({forceLogout:t});n.success?e&&await e(n.message):r&&await r(n.message,n.trace),i(false);},type:"button",disabled:a,className:"font-sans border-none bg-transparent cursor-pointer flex items-end gap-1 text-base font-medium text-destructive transition-transform duration-200 hover:scale-[1.05] active:scale-[0.98] disabled:opacity-60 disabled:cursor-not-allowed disabled:transform-none!",children:[jsx(LogOut,{size:24})," ",jsx("span",{children:"Log out"})]})}var At={mobile:Smartphone,tablet:Tablet,desktop:Monitor};function Tt(e){let{device:r,os:t,browser:o}=UAParser(e);return {deviceType:r.type??"desktop",os:t.name,browser:o.name}}function Ct(e){let r=Tt(e);return {device:br(r.deviceType),os:r.os,browser:r.browser}}function br(e){if(!e)return "desktop";switch(e){case "mobile":return "mobile";case "tablet":return "tablet";default:return "desktop"}}function _t(e){let r=Date.now()-new Date(e).getTime(),t=Math.floor(r/1e3),o=Math.floor(t/60),a=Math.floor(o/60),i=Math.floor(a/24),s=Math.floor(i/7);return t<60?"agora mesmo":o<60?`${o} minutos atr\xE1s`:a<24?`${a} horas atr\xE1s`:i<7?`${i} dias atr\xE1s`:`${s} semanas atr\xE1s`}function Qe({is_current:e,session_id:r,user_agent:t,issued_at:o,user_ip:a,onClick:i}){let s=Ct(t),c=At[s.device];return jsx("div",{className:"border-t border-border p-[1.25rem_0.75rem] text-foreground",children:jsxs("div",{className:"relative flex flex-col items-center gap-2 flex-1 text-center @[640px]:flex-row @[640px]:items-center @[640px]:gap-4 @[640px]:text-left",children:[jsx(c,{size:40}),jsxs("div",{className:"flex flex-col min-w-0",children:[jsxs("h3",{className:"text-base font-semibold m-0",children:[s.browser," - ",s.os]}),jsxs("span",{className:"inline-flex flex-col text-sm font-extralight @[640px]:flex-row @[640px]:gap-2 @[640px]:items-center",children:[e&&jsx("strong",{className:"text-primary font-normal",children:"\u2022 Sess\xE3o Atual \u2022"}),jsx("span",{children:`${a} - ${_t(o)}`})]})]}),!e&&jsx(Trash2,{size:20,className:"absolute top-0 right-0 cursor-pointer text-destructive opacity-60 transition-[opacity,transform] duration-200 hover:opacity-100 hover:scale-[1.05] active:scale-[0.95]",onClick:n=>i(n,r)})]})})}function kr({revokeAll:e=false,onSuccess:r}){let{auth:t}=v(),[o,a]=useState(false),[i,s]=useState([]),c=async()=>{let p=await t.sessions();if(p.success){let l=t.profile()?.session_id,f=p.data.sort((h,g)=>h.session_id===l?-1:g.session_id===l?1:0);s(f);}};useEffect(()=>{c();},[]);let n=async(p,l)=>{p.preventDefault();let f=i.find(h=>h.session_id===l);if(f){s(i.filter(h=>h.session_id!==l));try{(await t.revokeASession(l)).success||s(g=>[...g,f]);}catch{s(h=>[...h,f]);}}};return jsxs("div",{className:"font-sans w-full min-w-[20rem] m-2 @container bg-background text-foreground p-[1.5rem_0.5rem] rounded-lg",children:[jsxs("div",{className:"w-full flex flex-wrap items-center justify-center text-center gap-4 box-border px-3 @[640px]:justify-between @[640px]:text-left @[640px]:gap-8",children:[jsxs("div",{className:"flex-[0_1_auto] max-w-100",children:[jsx("h3",{className:"font-semibold text-2xl m-0 mb-1",children:"Navegadores e Dispositivos"}),jsx("p",{className:"font-extralight text-base m-0",children:"Esses navegadores e dispositivos est\xE3o atualmente conectados \xE0 sua conta. Remova quaisquer dispositivos n\xE3o autorizados."})]}),jsx("button",{type:"submit",onClick:async p=>{if(p.preventDefault(),o)return;a(true);let l=await t.revokeSessions(e),f=t.profile()?.session_id;l.success&&(s(e?[]:i.filter(h=>h.session_id===f)),r&&r(l.message)),a(false);},disabled:o,className:`font-sans w-full max-w-56 p-[1rem_0] h-auto text-base font-semibold outline-none bg-transparent relative overflow-hidden shrink-0 border-2 border-foreground text-foreground cursor-pointer transition-transform duration-500 rounded-lg hover:scale-[1.02] active:scale-[0.99] disabled:opacity-60 disabled:cursor-not-allowed disabled:transform-none! ${o?"button-loading":""}`,children:"Revogar todas as sess\xF5es"})]}),jsx("div",{className:"mt-4",children:i.length>0?i.map(p=>jsx(Qe,{...p,is_current:t.profile()?.session_id===p.session_id,onClick:n},p.session_id)):jsx("span",{className:"block border-t border-border p-[1.25rem_0.75rem] text-center font-semibold",children:"Nenhuma Sess\xE3o Dispon\xEDvel"})})]})}function It({onSuccess:e,onFailed:r,loginRedirect:t,emailRules:o}){let[a,i]=useState(""),[s,c]=useState(false),[n,d]=useState(false),p=useRef(null),{auth:l}=v(),h=L({email:o||[{message:"Digite um e-mail v\xE1lido, ex: exemplo@dominio.com",test:x=>/\S+@\S+\.\S+/.test(x)}]}.email,a);return jsxs("form",{className:"font-sans flex flex-col w-full max-w-120 min-w-60 max-h-[max(75dvh,32rem)] overflow-hidden gap-5 items-center bg-background text-foreground p-[1.25rem_1.5rem] shadow-[0_0.25rem_0.25rem_0_rgba(0,0,0,0.25)] transition-transform duration-150 ease-in-out rounded-lg",children:[jsx(N,{mainText:"Esqueci a senha",subText:"Insira seu e-mail para receber um link de redefini\xE7\xE3o."}),jsx("div",{className:"w-full flex flex-col gap-2.5 flex-[1_1_auto] overflow-y-auto mb-2",children:jsx(T,{label:"Email",name:"email",placeholder:"teste@gmail.com",autoComplete:"email",type:"email",value:a,onValueChange:i,inputRef:p,rulesStatus:h,submitted:s})}),jsx(_,{label:n?"Enviando...":"Enviar link de redefini\xE7\xE3o",onSubmit:async x=>{if(x.preventDefault(),c(true),h.some(C=>!C.passed)){p.current?.focus();return}d(true);let y=await l.sendForgotPassword(a);y.success?e&&await e(y.message):r&&await r(y.message,y.trace),d(false);},loading:n}),t&&jsxs(Fragment,{children:[jsxs("div",{className:"flex items-center gap-2.5 w-full text-base font-semibold opacity-60",children:[jsx("hr",{className:"flex-1"}),"OU",jsx("hr",{className:"flex-1"})]}),jsxs("span",{className:"text-sm font-semibold",children:["Lembrou-se da sua senha? ",jsx("span",{className:"cursor-pointer text-primary transition-colors duration-200 hover:opacity-80",onClick:t,children:"Login"})]})]})]})}function Pr({token:e,onSuccess:r,onFailed:t,loginRedirect:o,passwordRules:a}){let[i,s]=useState(""),[c,n]=useState(""),[d,p]=useState(false),[l,f]=useState(false),h=useRef(null),g=useRef(null),{auth:x}=v(),E={password:a||[{message:"M\xEDnimo de 8 caracteres.",test:w=>w.length>=8},{message:"Deve conter uma letra mai\xFAscula.",test:w=>/[A-Z]/.test(w)},{message:"Inclua pelo menos um caractere especial, ex: ! @ # $ % & * . ,",test:w=>/[!@#$%^&*(),.?":{}|<>_\-+=~`;/\\[\]]/.test(w)},{message:"Deve conter um n\xFAmero.",test:w=>/\d/.test(w)}],confirmPassword:[{message:"Senhas n\xE3o conferem.",test:w=>w===i}]},y=L(E.password,i),C=L(E.confirmPassword,c);return jsxs("form",{className:"font-sans flex flex-col w-full max-w-120 min-w-60 max-h-[max(75dvh,32rem)] overflow-hidden gap-5 items-center bg-background text-foreground p-[1.25rem_1.5rem] shadow-[0_0.25rem_0.25rem_0_rgba(0,0,0,0.25)] transition-transform duration-150 ease-in-out rounded-lg",children:[jsx(N,{mainText:"Redefinir Senha",subText:"Crie uma nova senha para sua conta"}),jsxs("div",{className:"w-full flex flex-col gap-2.5 flex-[1_1_auto] overflow-y-auto mb-2",children:[jsx(T,{label:"Nova Senha",name:"password",placeholder:"**********",autoComplete:"new-password",type:"password",value:i,onValueChange:s,inputRef:h,rulesStatus:y,submitted:d}),jsx(T,{label:"Confirme a Nova Senha",name:"confirm-password",placeholder:"**********",autoComplete:"new-password",type:"password",value:c,onValueChange:n,inputRef:g,rulesStatus:C,submitted:d})]}),jsx(_,{label:"Redefinir Senha",onSubmit:async w=>{w.preventDefault(),p(true);let Q=y.some(b=>!b.passed),W=C.some(b=>!b.passed);if(Q){h.current?.focus();return}if(W){g.current?.focus();return}f(true);let V=await x.resetPassword(e,i);V.success?r&&await r(V.message):t&&await t(V.message,V.trace),f(false);},loading:l}),o&&jsxs("span",{className:"text-sm font-semibold",children:["Lembrou-se da sua senha? ",jsx("span",{className:"cursor-pointer text-primary transition-colors duration-200 hover:opacity-80",onClick:o,children:"Login"})]})]})}function _r(e,r,t){let[o,a]=useState(true),[i,s]=useState("verifying"),[c,n]=useState("Verificando seu e-mail..."),{auth:d}=v(),p=useRef(false),l=async()=>{if(!p.current){p.current=true,a(true),s("verifying");try{if(d.profile()?.is_verified){s("already_verified"),n("Seu e-mail j\xE1 est\xE1 verificado."),a(!1);return}let g=await d.verifyEmail(e);g.success?(await d.refresh(),s("success"),n(g.message||"E-mail verificado com sucesso!"),r&&await r(g.message)):(s("error"),n(g.message||"Falha na verifica\xE7\xE3o do e-mail."),t&&await t(g.message,g.trace));}catch{s("error"),n("Ocorreu um erro inesperado durante a verifica\xE7\xE3o.");}finally{a(false);}}};return useEffect(()=>{e&&!p.current&&l();},[e]),{loading:o,status:i,message:c,onRetry:h=>{h.preventDefault(),p.current=false,l();},setStatus:s,setLoading:a,setMessage:n}}function Nr({token:e,onSuccess:r,onFailed:t}){let{loading:o,status:a,message:i,onRetry:s}=_r(e,r,t);return jsx("div",{className:"font-sans flex flex-col w-full h-full min-h-screen items-center justify-center bg-background text-foreground p-6",children:jsxs("div",{className:"w-full max-w-120 flex flex-col gap-8 items-center bg-background text-foreground p-[1.25rem_1.5rem] shadow-[0_0.25rem_0.25rem_0_rgba(0,0,0,0.25)] rounded-lg",children:[jsx(N,{mainText:a==="verifying"?"Verificando...":a==="error"?"Ops! Falha na verifica\xE7\xE3o":"Tudo pronto!",subText:i}),a==="verifying"&&jsx("div",{className:"w-full flex justify-center py-4",children:jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary"})}),a==="error"&&jsx("div",{className:"w-full flex flex-col gap-6 items-center",children:jsx("div",{className:"w-full mt-2",children:jsx(_,{label:"Tentar novamente",onSubmit:s,loading:o})})}),(a==="success"||a==="already_verified")&&jsxs("div",{className:"w-full flex flex-col gap-4 items-center",children:[jsx("div",{className:"w-16 h-16 flex items-center justify-center rounded-full bg-primary/10 text-primary",children:a==="success"?jsx(Check,{size:40}):jsx(Info,{size:40})}),jsx("p",{className:"text-sm font-semibold opacity-50 text-center",children:"Voc\xEA j\xE1 pode fechar esta janela ou continuar navegando em sua conta."})]})]})})}function Ir({onSuccess:e,onFailed:r}){let[t,o]=useState(false),[a,i]=useState(false),{auth:s}=v();return jsxs("div",{className:"font-sans flex flex-col w-full max-w-120 min-w-60 max-h-[max(75dvh,32rem)] overflow-hidden gap-5 items-center bg-background text-foreground p-[1.25rem_1.5rem] shadow-[0_0.25rem_0.25rem_0_rgba(0,0,0,0.25)] transition-transform duration-150 ease-in-out rounded-lg",children:[jsx(N,{mainText:"Reenviar Verifica\xE7\xE3o",subText:"N\xE3o recebeu o e-mail de verifica\xE7\xE3o? Clique no bot\xE3o abaixo para reenviar."}),jsx(_,{label:a?"E-mail Reenviado":"Reenviar E-mail de Verifica\xE7\xE3o",onSubmit:async()=>{o(true);let n=await s.resendVerifyEmail();n.success?(i(true),e&&await e(n.message)):r&&await r(n.message,n.trace),o(false);},loading:t}),a&&jsx("p",{className:"text-sm font-semibold text-primary",children:"Um novo link de verifica\xE7\xE3o foi enviado para seu e-mail."})]})}function D(...e){return twMerge(clsx(e))}var zt=forwardRef(({label:e,id:r,type:t="text",error:o,className:a,value:i,onChange:s,onFocus:c,onBlur:n,...d},p)=>{let[l,f]=useState(false),h=useId(),g=r??h,x=t==="password";return jsxs("div",{className:"w-full font-body group relative",children:[jsx("input",{ref:p,id:g,type:x?l?"text":"password":t,value:i,placeholder:" ",onChange:s,onFocus:c,onBlur:n,className:D("peer h-13 w-full rounded-sm text-sm text-foreground outline-none","border border-secondary/20 bg-muted/40 transition-all duration-200","placeholder:text-transparent focus-visible:ring-0 focus:bg-muted/60","px-3.5 pt-4 pb-1",x&&"pr-10",o&&"bg-destructive/5 ring-1 ring-destructive/20 border-destructive/50",a),...d}),jsx("label",{htmlFor:g,className:D("pointer-events-none absolute transition-all duration-200 ease-out left-3.5","top-1.5 text-[10px] font-semibold tracking-wider text-primary/70","peer-placeholder-shown:top-3.5 peer-placeholder-shown:text-[15px] peer-placeholder-shown:font-normal peer-placeholder-shown:tracking-normal peer-placeholder-shown:text-muted-foreground","peer-focus:top-1.5 peer-focus:text-[10px] peer-focus:font-semibold peer-focus:tracking-wider peer-focus:text-primary/70",o&&"text-destructive/80",o&&"peer-placeholder-shown:text-destructive/60",o&&"peer-focus:text-destructive/80"),children:e}),x&&jsx("button",{type:"button",tabIndex:-1,onClick:()=>{f(y=>!y);},className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground transition-colors hover:text-primary/70 focus:outline-none","aria-label":l?"Ocultar senha":"Mostrar senha",children:l?jsx(EyeOff,{size:16}):jsx(Eye,{size:16})})]})});zt.displayName="FormInput";var R=zt;var jr=({message:e,className:r})=>jsx(AnimatePresence,{children:e&&jsx(motion.p,{initial:{opacity:0,height:0,marginTop:0},animate:{opacity:1,height:"auto",marginTop:6},exit:{opacity:0,height:0,marginTop:0},transition:{duration:.2,ease:"easeOut"},className:D("text-[11px] font-medium text-destructive tracking-tight leading-none px-1 overflow-hidden",r),children:e})}),P=jr;var Jr=cva("inline-flex items-center justify-center whitespace-nowrap rounded-sm text-sm font-semibold transition-all focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 active:scale-[0.98]",{variants:{variant:{default:"bg-primary text-primary-foreground hover:opacity-90",destructive:"bg-destructive text-destructive-foreground hover:opacity-90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:opacity-80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-12 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),I=({className:e,variant:r,size:t,...o})=>jsx("button",{className:D(Jr({variant:r,size:t,className:e})),...o});var Zr=z.object({email:z.email("E-mail inv\xE1lido"),password:z.string().min(1,"A senha \xE9 obrigat\xF3ria")});function it({onSuccess:e,onFailed:r,signUpRedirect:t,forgotPasswordRedirect:o}){let[a,i]=useState(false),{auth:s}=v(),{register:c,handleSubmit:n,formState:{errors:d}}=useForm({resolver:zodResolver(Zr),defaultValues:{email:"",password:""}});return jsxs("form",{onSubmit:n(async l=>{i(true);try{let f=await s.login(l.email,l.password);f.success?e?await e(f.message):toast.success("Login realizado com sucesso!"):r?await r(f.message,f.trace):toast.error(f.message||"Erro ao entrar");}catch{toast.error("Ocorreu um erro inesperado");}finally{i(false);}}),className:"space-y-4",children:[jsxs("div",{className:"space-y-1",children:[jsx(R,{label:"E-mail",type:"email",autoComplete:"email",error:!!d.email,...c("email")}),jsx(P,{message:d.email?.message})]}),jsxs("div",{className:"space-y-1",children:[jsx(R,{label:"Senha",type:"password",autoComplete:"current-password",error:!!d.password,...c("password")}),jsx(P,{message:d.password?.message})]}),o&&jsx("div",{className:"flex justify-end",children:jsx("button",{type:"button",onClick:o,className:"text-xs text-primary hover:underline font-medium",children:"Esqueceu a senha?"})}),jsx(I,{type:"submit",disabled:a,className:"w-full flex items-center justify-center gap-2",children:a?jsx(Loader2,{className:"w-5 h-5 animate-spin"}):jsxs(Fragment,{children:["Entrar",jsx(ArrowRight,{className:"w-4 h-4"})]})})]})}var so=z.object({email:z.email("E-mail inv\xE1lido"),password:z.string().min(6,"A senha deve ter pelo menos 6 caracteres"),confirmPassword:z.string()}).refine(e=>e.password===e.confirmPassword,{message:"As senhas n\xE3o coincidem",path:["confirmPassword"]});function nt({onSuccess:e,onFailed:r,signInRedirect:t}){let[o,a]=useState(false),{auth:i}=v(),{register:s,handleSubmit:c,formState:{errors:n}}=useForm({resolver:zodResolver(so),defaultValues:{email:"",password:"",confirmPassword:""}});return jsxs("form",{onSubmit:c(async p=>{a(true);try{let l=await i.register(p.email,p.password);l.success?e?await e(l.message):(toast.success("Conta criada com sucesso!"),t&&t()):r?await r(l.message,l.trace):toast.error(l.message||"Erro ao criar conta");}catch{toast.error("Ocorreu um erro inesperado");}finally{a(false);}}),className:"space-y-4",children:[jsxs("div",{className:"space-y-1",children:[jsx(R,{label:"E-mail",type:"email",autoComplete:"email",error:!!n.email,...s("email")}),jsx(P,{message:n.email?.message})]}),jsxs("div",{className:"space-y-1",children:[jsx(R,{label:"Senha",type:"password",autoComplete:"new-password",error:!!n.password,...s("password")}),jsx(P,{message:n.password?.message})]}),jsxs("div",{className:"space-y-1",children:[jsx(R,{label:"Confirmar Senha",type:"password",autoComplete:"new-password",error:!!n.confirmPassword,...s("confirmPassword")}),jsx(P,{message:n.confirmPassword?.message})]}),jsx(I,{type:"submit",disabled:o,className:"w-full flex items-center justify-center gap-2",children:o?jsx(Loader2,{className:"w-5 h-5 animate-spin"}):jsxs(Fragment,{children:["Criar Conta",jsx(ArrowRight,{className:"w-4 h-4"})]})})]})}var fo=z.object({email:z.email("E-mail inv\xE1lido")});function dt({onSuccess:e,onFailed:r,signInRedirect:t}){let[o,a]=useState(false),{auth:i}=v(),{register:s,handleSubmit:c,formState:{errors:n}}=useForm({resolver:zodResolver(fo),defaultValues:{email:""}});return jsxs("form",{onSubmit:c(async p=>{a(true);try{let l=await i.sendForgotPassword(p.email);l.success?e?await e(l.message):toast.success("Link de redefini\xE7\xE3o enviado com sucesso!"):r?await r(l.message,l.trace):toast.error(l.message||"Erro ao enviar link");}catch{toast.error("Ocorreu um erro inesperado");}finally{a(false);}}),className:"space-y-4",children:[jsxs("div",{className:"space-y-1",children:[jsx(R,{label:"E-mail",type:"email",autoComplete:"email",error:!!n.email,...s("email")}),jsx(P,{message:n.email?.message})]}),jsx(I,{type:"submit",disabled:o,className:"w-full flex items-center justify-center gap-2",children:o?jsx(Loader2,{className:"w-5 h-5 animate-spin"}):jsxs(Fragment,{children:["Enviar link",jsx(ArrowRight,{className:"w-4 h-4"})]})})]})}var ko=z.object({password:z.string().min(6,"A senha deve ter pelo menos 6 caracteres"),confirmPassword:z.string()}).refine(e=>e.password===e.confirmPassword,{message:"As senhas n\xE3o coincidem",path:["confirmPassword"]});function So({token:e,onSuccess:r,onFailed:t,signInRedirect:o}){let[a,i]=useState(false),{auth:s}=v(),{register:c,handleSubmit:n,formState:{errors:d}}=useForm({resolver:zodResolver(ko),defaultValues:{password:"",confirmPassword:""}}),p=async l=>{i(true);try{let f=await s.resetPassword(e,l.password);f.success?r?await r(f.message):toast.success("Senha redefinida com sucesso!"):t?await t(f.message,f.trace):toast.error(f.message||"Erro ao redefinir senha");}catch{toast.error("Ocorreu um erro inesperado");}finally{i(false);}};return jsxs("div",{className:"w-full max-w-md z-10 flex flex-col antialiased selection:bg-primary/10 selection:text-primary",children:[jsxs("div",{className:"text-center mb-6",children:[jsx(motion.h1,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"font-heading text-3xl font-bold tracking-tight mb-2",children:"Redefinir Senha"}),jsx("p",{className:"text-muted-foreground text-sm mb-4",children:"Crie uma nova senha para sua conta"})]}),jsxs("form",{onSubmit:n(p),className:"space-y-4",children:[jsxs("div",{className:"space-y-1",children:[jsx(R,{label:"Nova Senha",type:"password",autoComplete:"new-password",error:!!d.password,...c("password")}),jsx(P,{message:d.password?.message})]}),jsxs("div",{className:"space-y-1",children:[jsx(R,{label:"Confirmar Nova Senha",type:"password",autoComplete:"new-password",error:!!d.confirmPassword,...c("confirmPassword")}),jsx(P,{message:d.confirmPassword?.message})]}),jsx(I,{type:"submit",disabled:a,className:"w-full flex items-center justify-center gap-2",children:a?jsx(Loader2,{className:"w-5 h-5 animate-spin"}):jsxs(Fragment,{children:["Redefinir Senha",jsx(ArrowRight,{className:"w-4 h-4"})]})}),o&&jsx("div",{className:"text-center mt-4",children:jsx("button",{type:"button",onClick:o,className:"text-xs text-primary font-semibold hover:underline",children:"Voltar para o login"})})]})]})}function No({token:e,onSuccess:r,onFailed:t,signInRedirect:o}){let[a,i]=useState("verifying"),[s,c]=useState("Verificando seu e-mail..."),[n,d]=useState(true),{auth:p}=v(),l=useRef(false),f=async()=>{if(!l.current){l.current=true,d(true),i("verifying");try{if(p.profile()?.is_verified){i("already_verified"),c("Seu e-mail j\xE1 est\xE1 verificado."),d(!1);return}let g=await p.verifyEmail(e);g.success?(await p.refresh(),i("success"),c(g.message||"E-mail verificado com sucesso!"),r&&await r(g.message)):(i("error"),c(g.message||"Falha na verifica\xE7\xE3o do e-mail."),t&&await t(g.message,g.trace));}catch{i("error"),c("Ocorreu um erro inesperado durante a verifica\xE7\xE3o.");}finally{d(false);}}};return useEffect(()=>{e&&!l.current&&f();},[e]),jsx("div",{className:"w-full max-w-md z-10 flex flex-col antialiased selection:bg-primary/10 selection:text-primary",children:jsxs("div",{className:"text-center mb-6",children:[jsxs(motion.div,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},className:"flex justify-center mb-4",children:[a==="verifying"&&jsx(Loader2,{className:"w-12 h-12 text-primary animate-spin"}),(a==="success"||a==="already_verified")&&jsx(CheckCircle2,{className:"w-12 h-12 text-green-500"}),a==="error"&&jsx(XCircle,{className:"w-12 h-12 text-destructive"})]}),jsx(motion.h1,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"font-heading text-3xl font-bold tracking-tight mb-2",children:a==="verifying"?"Verificando...":a==="error"?"Falha na verifica\xE7\xE3o":"E-mail Verificado!"}),jsx("p",{className:"text-muted-foreground text-sm mb-6",children:s}),a==="error"&&jsx(I,{onClick:()=>{l.current=false,f();},disabled:n,className:"w-full flex items-center justify-center gap-2",children:"Tentar novamente"}),(a==="success"||a==="already_verified")&&jsxs("div",{className:"space-y-4",children:[jsx("p",{className:"text-xs text-muted-foreground",children:"Voc\xEA j\xE1 pode continuar navegando em sua conta."}),o&&jsxs(I,{onClick:o,className:"w-full flex items-center justify-center gap-2",children:["Ir para o login",jsx(ArrowRight,{className:"w-4 h-4"})]})]})]})})}function Fe({children:e,className:r,backLink:t}){return jsxs("main",{className:D("bg-background h-full text-foreground min-h-screen relative overflow-hidden","flex flex-col px-4","antialiased selection:bg-primary/10 selection:text-primary",r),children:[jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[40%] h-[40%] bg-primary/20 rounded-full blur-3xl pointer-events-none"}),jsx("div",{className:"absolute bottom-[-10%] right-[-10%] w-[40%] h-[40%] bg-primary/20 rounded-full blur-3xl pointer-events-none"}),t&&jsx("div",{className:"relative z-10 pt-4",children:t}),jsx("div",{className:"relative z-10 flex-1 flex justify-center items-center",children:e})]})}var Bo=z.object({email:z.string().email("E-mail inv\xE1lido"),password:z.string().min(8,"A senha deve ter pelo menos 8 caracteres"),confirmPassword:z.string().min(1,"A confirma\xE7\xE3o de senha \xE9 obrigat\xF3ria")}).refine(e=>e.password===e.confirmPassword,{message:"As senhas n\xE3o coincidem",path:["confirmPassword"]});function Do({onSuccess:e,onFailed:r,backLink:t}){let[o,a]=useState(false),{auth:i}=v(),{register:s,handleSubmit:c,formState:{errors:n}}=useForm({resolver:zodResolver(Bo),defaultValues:{email:"",password:"",confirmPassword:""}}),d=async p=>{a(true);try{let l=await i.setup(p.email,p.password);l.success?e?await e(l.message):toast.success("Configura\xE7\xE3o inicial realizada com sucesso!"):r?await r(l.message,l.trace):toast.error(l.message||"Erro ao realizar setup");}catch(l){console.error(l),toast.error("Ocorreu um erro inesperado");}finally{a(false);}};return jsx(Fe,{backLink:t,children:jsxs("div",{className:"w-full max-w-md z-10 flex flex-col",children:[jsxs("div",{className:"mb-10 text-center",children:[jsxs(motion.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},className:"inline-flex items-center gap-2 px-3 py-1 rounded-full bg-primary/10 text-primary text-xs font-bold uppercase tracking-widest mb-4",children:[jsx(Sparkles,{size:14}),"Setup Inicial"]}),jsx("h1",{className:"font-heading text-4xl font-bold tracking-tight mb-3",children:"Bem-vindo ao IdentityX"}),jsx("p",{className:"text-muted-foreground text-base max-w-[320px] mx-auto",children:"Vamos come\xE7ar criando sua conta de administrador mestre."})]}),jsx(motion.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},transition:{delay:.1},className:"bg-card/50 backdrop-blur-sm border border-border/40 p-1 rounded-2xl",children:jsx("div",{className:"bg-background rounded-[14px] p-6 shadow-sm",children:jsxs("form",{onSubmit:c(d),className:"space-y-5",children:[jsxs("div",{className:"space-y-1",children:[jsx(R,{label:"E-mail do Administrador",type:"email",autoComplete:"email",error:!!n.email,...s("email")}),jsx(P,{message:n.email?.message})]}),jsxs("div",{className:"space-y-1",children:[jsx(R,{label:"Senha",type:"password",autoComplete:"new-password",error:!!n.password,...s("password")}),jsx(P,{message:n.password?.message})]}),jsxs("div",{className:"space-y-1",children:[jsx(R,{label:"Confirmar Senha",type:"password",autoComplete:"new-password",error:!!n.confirmPassword,...s("confirmPassword")}),jsx(P,{message:n.confirmPassword?.message})]}),jsx(I,{type:"submit",disabled:o,className:"w-full flex items-center justify-center gap-2 h-13 mt-4 text-base font-bold shadow-lg shadow-primary/10 group",children:o?jsx(Loader2,{className:"w-5 h-5 animate-spin"}):jsxs(Fragment,{children:["Finalizar Configura\xE7\xE3o",jsx(ArrowRight,{className:"w-4 h-4 transition-transform group-hover:translate-x-1"})]})})]})})}),jsxs("div",{className:"mt-8 text-center",children:[jsx("div",{className:"h-1 w-full bg-muted/30 rounded-full overflow-hidden",children:jsx(motion.div,{initial:{width:0},animate:{width:"100%"},transition:{duration:1.5,ease:"easeInOut"},className:"h-full bg-primary/40"})}),jsx("p",{className:"text-[10px] text-muted-foreground mt-2 font-medium uppercase tracking-tighter",children:"Passo 1 de 1 \u2022 Configurando ambiente"})]})]})})}var jo={signin:{title:"Bem-vindo de volta",subtitle:"Entre com suas credenciais para acessar a plataforma",toggleLabel:"Ainda n\xE3o tem uma conta?",toggleAction:"Cadastre-se",toggleTo:"signup"},signup:{title:"Criar sua conta",subtitle:"Preencha os dados abaixo para se cadastrar",toggleLabel:"J\xE1 possui uma conta?",toggleAction:"Fa\xE7a login",toggleTo:"signin"},"forgot-password":{title:"Recuperar senha",subtitle:"Digite seu e-mail para receber instru\xE7\xF5es",toggleLabel:"Lembrou da senha?",toggleAction:"Voltar ao login",toggleTo:"signin"}};function $o({initialView:e="signin",onLoginSuccess:r,onSignUpSuccess:t,onFailed:o,backLink:a}){let[i,s]=useState(e),c=async d=>{s("signin"),t&&await t(d);},n=jo[i];return jsx(Fe,{backLink:a,children:jsxs("div",{className:"w-full max-w-md z-10 flex flex-col",children:[jsxs("div",{className:"text-center mb-6",children:[jsx(motion.h1,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},className:"font-heading text-3xl font-bold tracking-tight mb-2",children:n.title},i+"-h1"),jsx("p",{className:"text-muted-foreground text-sm mb-4",children:n.subtitle}),jsxs("div",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-muted/50 border border-border/50 text-xs font-medium text-muted-foreground",children:[n.toggleLabel,jsx("button",{type:"button",onClick:()=>s(n.toggleTo),className:"text-primary font-semibold hover:underline",children:n.toggleAction})]})]}),jsx("div",{className:"relative min-h-80",children:jsxs(AnimatePresence,{mode:"wait",children:[i==="signin"&&jsx(motion.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},exit:{opacity:0,x:10},transition:{duration:.2},className:"absolute inset-0",children:jsx(it,{onSuccess:r,onFailed:o,signUpRedirect:()=>s("signup"),forgotPasswordRedirect:()=>s("forgot-password")})},"signin"),i==="signup"&&jsx(motion.div,{initial:{opacity:0,x:10},animate:{opacity:1,x:0},exit:{opacity:0,x:-10},transition:{duration:.2},className:"absolute inset-0",children:jsx(nt,{onSuccess:c,onFailed:o,signInRedirect:()=>s("signin")})},"signup"),i==="forgot-password"&&jsx(motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2},className:"absolute inset-0",children:jsx(dt,{onFailed:o,signInRedirect:()=>s("signin")})},"forgot-password")]})})]})})}export{za as AuthProvider,T as BasicInputField,ur as BasicLogoutButton,cr as Copyright,It as ForgotPassword,$o as ModernAuth,dt as ModernForgotPassword,So as ModernResetPassword,Do as ModernSetup,it as ModernSignIn,nt as ModernSignUp,No as ModernVerifyEmail,Ir as ResendVerifyEmail,Pr as ResetPassword,kr as Sessions,ar as SignIn,sr as SignUp,Nr as VerifyEmail,v as useAuth};//# sourceMappingURL=react.js.map
|
|
3
3
|
//# sourceMappingURL=react.js.map
|