@nocios/crudify-ui 4.2.0 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-PZRCUUGR.mjs +1 -0
- package/dist/chunk-UUVJCOSW.js +1 -0
- package/dist/components.js +1 -1
- package/dist/components.mjs +1 -1
- package/dist/index.d.mts +3 -6
- package/dist/index.d.ts +3 -6
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-IIXFLIEW.mjs +0 -1
- package/dist/chunk-JWIFFUC5.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as oo,c as X,h as no,j as te,l as so}from"./chunk-CM6XOYDL.mjs";import{g as M}from"./chunk-BJ6PIVZR.mjs";import{a as ro,e as to}from"./chunk-5JKS55SE.mjs";var oe={es:{"checkCode.codeLabel":"C\xF3digo de Verificaci\xF3n","checkCode.codePlaceholder":"Ingresa el c\xF3digo de 6 d\xEDgitos","checkCode.codeRequired":"El c\xF3digo es obligatorio","checkCode.emailLabel":"Correo Electr\xF3nico","checkCode.emailPlaceholder":"Ingresa tu correo electr\xF3nico","checkCode.emailRequired":"El correo electr\xF3nico es obligatorio","checkCode.instructions":"Ingresa el c\xF3digo de 6 d\xEDgitos que enviamos a tu correo electr\xF3nico.","checkCode.invalidEmail":"Ingresa un correo electr\xF3nico v\xE1lido","checkCode.resendCodeLink":"Reenviar c\xF3digo","checkCode.title":"Verificar C\xF3digo","checkCode.verifyButton":"Verificar C\xF3digo","common.back":"Volver","common.backToLogin":"Volver","error.app.config":"Error de Configuraci\xF3n: {{message}}","error.app.initialization":"Error durante la inicializaci\xF3n final de la aplicaci\xF3n.","error.transaction":"Error en la operaci\xF3n","error.unknown":"Ocurri\xF3 un error desconocido.","errors.DUPLICATE":"El campo <b>{{field}}</b> debe ser \xFAnico.","errors.FOREIGN_KEY_NOT_FOUND":"El campo <b>{{field}}</b> debe referenciar un \xEDtem existente.","errors.INVALID_EMAIL":"El campo <b>{{field}}</b> debe ser un correo electr\xF3nico v\xE1lido.","errors.INVALID_OBJECT_ID":"El campo <b>{{field}}</b> debe ser un valor v\xE1lido.","errors.IN_USE":"El \xEDtem est\xE1 en uso y no puede ser eliminado.","errors.MAX_LENGTH":"El campo <b>{{field}}</b> no debe exceder los <b>{{length}}</b> caracteres.","errors.MIN_LENGTH":"El campo <b>{{field}}</b> debe tener al menos <b>{{length}}</b> caracteres.","errors.MUST_NOT_BE_EMAIL":"El campo <b>{{field}}</b> no debe ser un correo electr\xF3nico.","errors.NO_PERMISSION":"No tienes permiso para realizar esta acci\xF3n.","errors.NO_SPACES":"El campo <b>{{field}}</b> no debe contener espacios.","errors.ONE_OR_MORE_OPERATIONS_FAILED":"Error en la operaci\xF3n","errors.REQUIRED":"El campo <b>{{field}}</b> es obligatorio.","errors.TOKEN_HAS_EXPIRED":"La sesi\xF3n ha expirado. Por favor, inicia sesi\xF3n nuevamente.","errors.TOO_MANY_REQUESTS":"L\xEDmite de solicitudes alcanzado. Por favor intenta m\xE1s tarde.","errors.UNAUTHORIZED":"No est\xE1s autorizado para realizar esta acci\xF3n.","errors.all_password_fields_required":"Todos los campos de contrase\xF1a son obligatorios","errors.auth.INVALID_API_KEY":"Clave de API inv\xE1lida","errors.auth.INVALID_CREDENTIALS":"Usuario y/o contrase\xF1a incorrectos","errors.auth.NO_PERMISSION":"No tienes permisos suficientes","errors.auth.SESSION_EXPIRED":"Tu sesi\xF3n ha expirado. Por favor, inicia sesi\xF3n nuevamente.","errors.auth.TOO_MANY_REQUESTS":"Demasiados intentos. Por favor espera 15 minutos e intenta nuevamente","errors.auth.UNAUTHORIZED":"No tienes permisos para realizar esta acci\xF3n","errors.auth.USER_NOT_ACTIVE":"Usuario no activo","errors.auth.USER_NOT_FOUND":"Usuario no encontrado","errors.data.BAD_REQUEST":"Solicitud inv\xE1lida","errors.data.FIELD_ERROR":"Error en los datos ingresados","errors.data.IN_USE":"El elemento est\xE1 en uso y no puede ser eliminado","errors.data.ITEM_NOT_FOUND":"El elemento solicitado no fue encontrado","errors.data.NOT_FOUND":"No se encontr\xF3 lo solicitado","errors.internal_error_changing_password":"Error interno al cambiar la contrase\xF1a. Intenta nuevamente","errors.password_min_length":"La contrase\xF1a debe tener al menos 8 caracteres","errors.password_mismatch":"Las contrase\xF1as no coinciden","errors.password_must_be_different":"La nueva contrase\xF1a debe ser diferente a la actual","errors.system.DATABASE_CONNECTION_ERROR":"Error de conexi\xF3n. Verifica tu conexi\xF3n a internet.","errors.system.INTERNAL_SERVER_ERROR":"Error interno del servidor. Intenta nuevamente.","errors.system.INVALID_CONFIGURATION":"Error de configuraci\xF3n del sistema","errors.system.TOO_MANY_REQUESTS":"Demasiadas solicitudes. Por favor espera un momento e intenta nuevamente","errors.system.UNKNOWN_OPERATION":"Operaci\xF3n no reconocida","errors.users_module_not_configured":"M\xF3dulo de usuarios no configurado","footer.copyright":"Nocios S.R.L. Todos los derechos reservados.","footer.version":"Versi\xF3n","forgotPassword.checkEmailInstructions":"Revisa tu bandeja de entrada para el c\xF3digo de verificaci\xF3n","forgotPassword.codeAlreadyExistsMessage":"Ya se envi\xF3 un c\xF3digo y a\xFAn es v\xE1lido","forgotPassword.emailLabel":"Correo Electr\xF3nico","forgotPassword.emailPlaceholder":"Ingresa tu correo electr\xF3nico","forgotPassword.emailRequired":"El correo electr\xF3nico es obligatorio","forgotPassword.emailSentMessage":"C\xF3digo enviado exitosamente","forgotPassword.enterCodeLink":"Ingresar C\xF3digo","forgotPassword.instructions":"Ingresa tu correo electr\xF3nico y te enviaremos un c\xF3digo para restablecer tu contrase\xF1a.","forgotPassword.invalidEmail":"Ingresa un correo electr\xF3nico v\xE1lido","forgotPassword.sendCodeButton":"Enviar C\xF3digo","forgotPassword.title":"Recuperar Contrase\xF1a","loading.app.configInitial":"Cargando configuraci\xF3n inicial...","loading.app.generic":"Cargando...","loading.app.starting":"Iniciando aplicaci\xF3n...","loading.app.themeSetup":"Generando tema...","loading.app.validatingSession":"Validando sesi\xF3n...","login.alreadyHaveCodeLink":"\xBFYa tienes un c\xF3digo?","login.forgotPasswordLink":"\xBFOlvidaste tu contrase\xF1a?","login.initializationError":"Error de inicializaci\xF3n","login.initializing":"Inicializando...","login.loginButton":"Iniciar Sesi\xF3n","login.logoAlt":"Logotipo","login.noAccountPrompt":"\xBFNo tienes una cuenta?","login.notInitialized":"Sistema no inicializado","login.passwordLabel":"Contrase\xF1a","login.passwordPlaceholder":"Ingresa tu contrase\xF1a","login.passwordRequired":"Contrase\xF1a es obligatoria","login.signUpLink":"Reg\xEDstrate","login.usernameOrEmailLabel":"Usuario o Correo Electr\xF3nico","login.usernameOrEmailPlaceholder":"Ingresa tu usuario o correo electr\xF3nico","login.usernameRequired":"Usuario o correo electr\xF3nico es obligatorio","resetPassword.codeExpiredOrInvalid":"El c\xF3digo ha expirado o es inv\xE1lido","resetPassword.confirmPasswordLabel":"Confirmar Contrase\xF1a","resetPassword.confirmPasswordPlaceholder":"Confirma tu nueva contrase\xF1a","resetPassword.confirmPasswordRequired":"Confirma tu contrase\xF1a","resetPassword.goToLoginButton":"Ir al Login","resetPassword.instructions":"Ingresa tu nueva contrase\xF1a.","resetPassword.invalidCode":"El c\xF3digo de verificaci\xF3n es inv\xE1lido. Por favor, verifica el enlace o solicita uno nuevo.","resetPassword.missingParameters":"Faltan par\xE1metros obligatorios","resetPassword.newPasswordLabel":"Nueva Contrase\xF1a","resetPassword.newPasswordPlaceholder":"Ingresa tu nueva contrase\xF1a","resetPassword.newPasswordRequired":"La nueva contrase\xF1a es obligatoria","resetPassword.passwordTooShort":"La contrase\xF1a debe tener al menos 8 caracteres","resetPassword.passwordsDoNotMatch":"Las contrase\xF1as no coinciden","resetPassword.requestNewCodeButton":"Solicitar Nuevo C\xF3digo","resetPassword.resetPasswordButton":"Restablecer Contrase\xF1a","resetPassword.successInstructions":"Ahora puedes iniciar sesi\xF3n con tu nueva contrase\xF1a","resetPassword.successMessage":"Contrase\xF1a restablecida exitosamente","resetPassword.title":"Nueva Contrase\xF1a","resetPassword.validatingCode":"Validando c\xF3digo..."},en:{"checkCode.codeLabel":"Verification Code","checkCode.codePlaceholder":"Enter 6-digit code","checkCode.codeRequired":"Code is required","checkCode.emailLabel":"Email Address","checkCode.emailPlaceholder":"Enter your email address","checkCode.emailRequired":"Email address is required","checkCode.instructions":"Enter the 6-digit code we sent to your email address.","checkCode.invalidEmail":"Enter a valid email address","checkCode.resendCodeLink":"Resend code","checkCode.title":"Verify Code","checkCode.verifyButton":"Verify Code","common.back":"Back","common.backToLogin":"Back to Login","error.app.config":"Configuration Error: {{message}}","error.app.initialization":"Error during final application initialization.","error.transaction":"Operation error","error.unknown":"An unknown error occurred.","errors.DUPLICATE":"The field <b>{{field}}</b> must be unique.","errors.FOREIGN_KEY_NOT_FOUND":"The field <b>{{field}}</b> must reference an existing item.","errors.INVALID_EMAIL":"The field <b>{{field}}</b> must be a valid email address.","errors.INVALID_OBJECT_ID":"The field <b>{{field}}</b> must be a valid value.","errors.IN_USE":"The item is currently in use and cannot be deleted.","errors.MAX_LENGTH":"The field <b>{{field}}</b> must not exceed <b>{{maxLength}}</b> characters.","errors.MIN_LENGTH":"The field <b>{{field}}</b> must have at least <b>{{minLength}}</b> characters.","errors.MUST_NOT_BE_EMAIL":"The field <b>{{field}}</b> must not be an email address.","errors.NO_PERMISSION":"You do not have permission to perform this action.","errors.NO_SPACES":"The field <b>{{field}}</b> must not contain spaces.","errors.ONE_OR_MORE_OPERATIONS_FAILED":"Operation error","errors.REQUIRED":"The field <b>{{field}}</b> is required.","errors.TOKEN_HAS_EXPIRED":"Your session has expired, please log in again.","errors.TOO_MANY_REQUESTS":"Request limit reached. Please try again later.","errors.UNAUTHORIZED":"You are not authorized to perform this action.","errors.all_password_fields_required":"All password fields are required","errors.auth.INVALID_API_KEY":"Invalid API key","errors.auth.INVALID_CREDENTIALS":"Incorrect username and/or password","errors.auth.NO_PERMISSION":"Insufficient permissions","errors.auth.SESSION_EXPIRED":"Your session has expired. Please log in again.","errors.auth.TOO_MANY_REQUESTS":"Too many attempts. Please wait 15 minutes and try again","errors.auth.UNAUTHORIZED":"You don't have permission to perform this action","errors.auth.USER_NOT_ACTIVE":"User account is not active","errors.auth.USER_NOT_FOUND":"User not found","errors.data.BAD_REQUEST":"Invalid request","errors.data.FIELD_ERROR":"Error in the provided data","errors.data.IN_USE":"The item is in use and cannot be deleted","errors.data.ITEM_NOT_FOUND":"The requested item was not found","errors.data.NOT_FOUND":"The requested resource was not found","errors.internal_error_changing_password":"Internal error changing password. Please try again","errors.password_min_length":"Password must be at least 8 characters","errors.password_mismatch":"Passwords do not match","errors.password_must_be_different":"New password must be different from current password","errors.system.DATABASE_CONNECTION_ERROR":"Connection error. Please check your internet connection.","errors.system.INTERNAL_SERVER_ERROR":"Internal server error. Please try again.","errors.system.INVALID_CONFIGURATION":"System configuration error","errors.system.TOO_MANY_REQUESTS":"Too many requests. Please wait a moment and try again","errors.system.UNKNOWN_OPERATION":"Unrecognized operation","errors.users_module_not_configured":"Users module not configured","footer.copyright":"Nocios S.R.L. All Rights Reserved.","footer.version":"Version","forgotPassword.checkEmailInstructions":"Check your inbox for the verification code","forgotPassword.codeAlreadyExistsMessage":"A code was already sent and is still valid","forgotPassword.emailLabel":"Email Address","forgotPassword.emailPlaceholder":"Enter your email address","forgotPassword.emailRequired":"Email address is required","forgotPassword.emailSentMessage":"Code sent successfully","forgotPassword.enterCodeLink":"Enter Code","forgotPassword.instructions":"Enter your email address and we'll send you a code to reset your password.","forgotPassword.invalidEmail":"Enter a valid email address","forgotPassword.sendCodeButton":"Send Code","forgotPassword.title":"Reset Password","loading.app.configInitial":"Loading initial configuration...","loading.app.generic":"Loading...","loading.app.starting":"Starting application...","loading.app.themeSetup":"Generating theme...","loading.app.validatingSession":"Validating session...","login.alreadyHaveCodeLink":"Already have a code?","login.forgotPasswordLink":"Forgot Password?","login.initializationError":"Initialization error","login.initializing":"Initializing...","login.loginButton":"Log In","login.logoAlt":"Logo","login.noAccountPrompt":"Don't have an account?","login.notInitialized":"System not initialized","login.passwordLabel":"Password","login.passwordPlaceholder":"Enter your password","login.passwordRequired":"Password is required","login.signUpLink":"Sign up","login.usernameOrEmailLabel":"Username or Email","login.usernameOrEmailPlaceholder":"Enter your username or email","login.usernameRequired":"Username or email is required","resetPassword.codeExpiredOrInvalid":"Code expired or invalid","resetPassword.confirmPasswordLabel":"Confirm Password","resetPassword.confirmPasswordPlaceholder":"Confirm your new password","resetPassword.confirmPasswordRequired":"Confirm your password","resetPassword.goToLoginButton":"Go to Login","resetPassword.instructions":"Enter your new password.","resetPassword.invalidCode":"The verification code is invalid. Please check the link or request a new one.","resetPassword.missingParameters":"Missing required parameters","resetPassword.newPasswordLabel":"New Password","resetPassword.newPasswordPlaceholder":"Enter your new password","resetPassword.newPasswordRequired":"New password is required","resetPassword.passwordTooShort":"Password must be at least 8 characters","resetPassword.passwordsDoNotMatch":"Passwords do not match","resetPassword.requestNewCodeButton":"Request New Code","resetPassword.resetPasswordButton":"Reset Password","resetPassword.successInstructions":"You can now log in with your new password","resetPassword.successMessage":"Password reset successfully","resetPassword.title":"New Password","resetPassword.validatingCode":"Validating code..."}},Vt=()=>Object.keys(oe),Wt=e=>oe[e]||oe.es;import Re from"@nocios/crudify-browser";var ao="crudify_translations_",Jo=3600*1e3;function io(e){let o=0;for(let r=0;r<e.length;r++){let t=e.charCodeAt(r);o=(o<<5)-o+t,o=o&o}return Math.abs(o).toString(36)}var De=class e{constructor(){this.enableDebug=!1;this.initializationPromise=null;this.isInitialized=!1}static getInstance(){return e.instance||(e.instance=new e),e.instance}setDebug(o){this.enableDebug=o}async ensureCrudifyInitialized(o,r){if(!this.isInitialized)return this.initializationPromise?(this.enableDebug&&console.log("[TranslationService] Waiting for crudify initialization..."),this.initializationPromise):(this.enableDebug&&console.log("[TranslationService] Initializing crudify SDK..."),this.initializationPromise=(async()=>{try{let t=Re.getTokenData();if(t&&t.endpoint){this.enableDebug&&console.log("[TranslationService] Crudify already initialized"),this.isInitialized=!0;return}Re.config(r);let c=await Re.init(o,this.enableDebug?"debug":"none");if(c.success===!1)throw new Error(`Failed to initialize crudify: ${JSON.stringify(c.errors||"Unknown error")}`);this.isInitialized=!0,this.enableDebug&&console.log("[TranslationService] Crudify SDK initialized successfully")}catch(t){throw console.error("[TranslationService] Failed to initialize crudify:",t),this.initializationPromise=null,t}})(),this.initializationPromise)}async fetchTranslations(o){let{apiKey:r,sections:t,crudifyEnv:c="stg",urlTranslations:a}=o;console.log("[TranslationService] \u{1F4E5} fetchTranslations called with:",{apiKeyHash:io(r),crudifyEnv:c,sections:t,hasUrlTranslations:!!a,urlTranslationsKeys:a?Object.keys(a).length:0});let n=this.getFromCache(r),f=n?this.isCacheExpired(n):!0;if(console.log("[TranslationService] \u{1F4BE} Cache check:",{hasCached:!!n,isCacheExpired:f}),n&&!f){console.log("[TranslationService] \u2705 Using cached translations");let l=this.mergeWithUrlTranslations(n.data.translations,a);return console.log("[TranslationService] \u{1F504} Merged result (from cache):",{languages:Object.keys(l),sampleLang:Object.keys(l)[0],keysInSampleLang:l[Object.keys(l)[0]]?Object.keys(l[Object.keys(l)[0]]).length:0}),l}try{await this.ensureCrudifyInitialized(r,c)}catch(l){return console.error("[TranslationService] \u274C Failed to initialize crudify:",l),n?(console.warn("[TranslationService] \u26A0\uFE0F Using expired cache (init failed)"),this.mergeWithUrlTranslations(n.data.translations,a)):(console.warn("[TranslationService] \u26A0\uFE0F Using critical bundle (init failed)"),this.getCriticalTranslationsOnly())}try{console.log("[TranslationService] \u{1F310} Fetching from API via crudify SDK...");let l=await this.fetchFromAPI(t);console.log("[TranslationService] \u{1F4E6} API response received:",{languages:l.languages,translationsKeys:Object.keys(l.translations),timestamp:l.timestamp});let y=Object.keys(l.translations)[0];y&&console.log(`[TranslationService] \u{1F4CB} API translations sample (${y}):`,{totalKeys:Object.keys(l.translations[y]).length,firstFiveKeys:Object.keys(l.translations[y]).slice(0,5)}),this.hasDataChanged(n,l)||!n?(console.log("[TranslationService] \u{1F4BE} Data changed, updating cache"),this.saveToCache(r,l)):(console.log("[TranslationService] \u{1F4BE} Data unchanged, refreshing cache timestamp"),this.refreshCacheTimestamp(r));let g=this.mergeWithUrlTranslations(l.translations,a);return console.log("[TranslationService] \u{1F504} Final merged result:",{languages:Object.keys(g),sampleLang:Object.keys(g)[0],keysInSampleLang:g[Object.keys(g)[0]]?Object.keys(g[Object.keys(g)[0]]).length:0}),g}catch(l){return console.error("[TranslationService] \u274C API fetch failed:",l),n?(console.warn("[TranslationService] \u26A0\uFE0F Using expired cache as fallback"),this.mergeWithUrlTranslations(n.data.translations,a)):(console.warn("[TranslationService] \u26A0\uFE0F Using critical bundle translations"),this.getCriticalTranslationsOnly())}}async fetchFromAPI(o){let r=await Re.getTranslation(o);if(!r.success)throw new Error(`Crudify API error: ${r.errors?JSON.stringify(r.errors):"Unknown error"}`);if(!r.data)throw new Error("No translation data in response");return r.data}mergeWithUrlTranslations(o,r){if(!r||Object.keys(r).length===0)return o;let t={};return Object.keys(o).forEach(c=>{t[c]={...o[c],...r}}),t}hasDataChanged(o,r){if(!o||o.data.timestamp!==r.timestamp)return!0;let t=this.hashData(r.translations);return o.dataHash!==t}hashData(o){let r=JSON.stringify(o),t=0;for(let c=0;c<r.length;c++){let a=r.charCodeAt(c);t=(t<<5)-t+a,t=t&t}return t.toString(36)}saveToCache(o,r){try{let t=this.getCacheKey(o),c={data:r,cachedAt:Date.now(),dataHash:this.hashData(r.translations)};localStorage.setItem(t,JSON.stringify(c)),this.enableDebug&&console.log("[TranslationService] Saved to cache:",t)}catch(t){console.error("[TranslationService] Failed to save cache:",t)}}getFromCache(o){try{let r=this.getCacheKey(o),t=localStorage.getItem(r);return t?JSON.parse(t):null}catch(r){return console.error("[TranslationService] Failed to read cache:",r),null}}refreshCacheTimestamp(o){try{let r=this.getFromCache(o);if(r){r.cachedAt=Date.now();let t=this.getCacheKey(o);localStorage.setItem(t,JSON.stringify(r))}}catch(r){console.error("[TranslationService] Failed to refresh cache timestamp:",r)}}isCacheExpired(o){return Date.now()-o.cachedAt>Jo}getCacheKey(o){return`${ao}${io(o)}`}getCriticalTranslationsOnly(){return oe}invalidateCache(o){let r=this.getCacheKey(o);localStorage.removeItem(r),this.enableDebug&&console.log("[TranslationService] Cache invalidated:",r)}async prefetchTranslations(o){try{await this.fetchTranslations(o),this.enableDebug&&console.log("[TranslationService] Prefetch completed")}catch(r){console.error("[TranslationService] Prefetch failed:",r)}}clearAllCaches(){try{let r=Object.keys(localStorage).filter(t=>t.startsWith(ao));r.forEach(t=>localStorage.removeItem(t)),this.enableDebug&&console.log(`[TranslationService] Cleared ${r.length} cache entries`)}catch(o){console.error("[TranslationService] Failed to clear caches:",o)}}},Be=De.getInstance();import{createContext as Qo,useContext as Xo,useEffect as co,useState as ye,useMemo as Zo,useCallback as er}from"react";import{jsx as rr}from"react/jsx-runtime";var uo=Qo(null);function lo(e,o,r){return{...e,...o,...r||{}}}function or(e,o,r,t,c){co(()=>{if(!t||!e||!o)return;let a=r||typeof window<"u"&&window.i18next||typeof window<"u"&&window.i18n;if(!a||!a.addResourceBundle){c&&console.log("[TranslationsProvider] i18next not found, skipping auto-sync");return}c&&console.log("[TranslationsProvider] Auto-syncing translations with i18next",{languages:Object.keys(e),currentLanguage:o}),Object.keys(e).forEach(n=>{e[n]&&Object.keys(e[n]).length>0&&(a.addResourceBundle(n,"translation",e[n],!0,!0),c&&console.log(`[TranslationsProvider] Synced ${Object.keys(e[n]).length} keys for language: ${n}`))}),a.language!==o&&(a.changeLanguage(o),c&&console.log(`[TranslationsProvider] Changed i18next language to: ${o}`))},[e,o,r,t,c])}var Qt=({children:e,apiKey:o,crudifyEnv:r="stg",sections:t,language:c="es",devTranslations:a,translationUrl:n,enableDebug:f=!1,skipAutoInit:l=!0,autoSyncI18n:y=!0,i18nInstance:p})=>{let[g,d]=ye({}),[s,i]=ye(!0),[u,T]=ye(null),[E,m]=ye(void 0),[w,x]=ye(!1),C=er(async()=>{if(w){f&&console.log("[TranslationsProvider] Skipping reload - using fallback translations");return}i(!0),T(null);let P;if(n)try{f&&console.log(`[TranslationsProvider] Fetching translations from URL: ${n}`);let R=await fetch(n);if(!R.ok)throw new Error(`Failed to fetch translations: ${R.statusText}`);P=await R.json(),m(P),f&&console.log("[TranslationsProvider] URL translations loaded:",{keysCount:P?Object.keys(P).length:0})}catch(R){console.error("[TranslationsProvider] Failed to load URL translations:",R),P=void 0,m(void 0)}try{Be.setDebug(f);let R=await Be.fetchTranslations({apiKey:o,crudifyEnv:r,sections:t,urlTranslations:P}),U={};Object.keys(R).forEach(I=>{let K=oe[I]||{},Q=R[I]||{};U[I]=lo(K,Q,a)}),d(U),f&&console.log("[TranslationsProvider] Loaded translations:",{languages:Object.keys(U),keysCount:Object.keys(U[c]||{}).length})}catch(R){console.error("[TranslationsProvider] Failed to load:",R),T(R.message),x(!0);let U={};Object.keys(oe).forEach(I=>{let K=oe[I],Q=P||E||{};U[I]=lo(K,Q,a)}),d(U),f&&console.log("[TranslationsProvider] Using fallback translations (critical + URL)")}finally{i(!1)}},[o,r,t,n,a,f,c,w]);co(()=>{C();let P=setInterval(C,3600*1e3);return()=>clearInterval(P)},[C]);let S=Zo(()=>(P,R)=>{let I=(g[c]||{})[P];if(!I){let K=Object.keys(g);for(let Q of K)if(g[Q][P]){I=g[Q][P];break}}return I||(f&&console.warn(`[TranslationsProvider] Missing translation: "${P}"`),I=P),R&&typeof I=="string"&&Object.entries(R).forEach(([K,Q])=>{let Ee=new RegExp(`{{${K}}}`,"g");I=I.replace(Ee,String(Q))}),I},[g,c,f]);or(g,c,p,y,f);let h={t:S,language:c,availableLanguages:Object.keys(g),translations:g,isLoading:s,error:u,refreshTranslations:C};return rr(uo.Provider,{value:h,children:e})},go=()=>{let e=Xo(uo);if(!e)throw new Error("useTranslations must be used within TranslationsProvider");return e};import{Box as zr,Typography as Mr}from"@mui/material";import{createContext as nr,useContext as sr,useMemo as ze}from"react";import{useState as Ue,useEffect as tr}from"react";var mo=(e,o)=>{let[r,t]=Ue({}),[c,a]=Ue(!1),[n,f]=Ue(null);return tr(()=>{if(console.log("\u{1F527} [I18nProvider] Hybrid translation loading:",{hasProvidedTranslations:!!o&&Object.keys(o).length>0,hasUrl:!!e,providedKeys:o?Object.keys(o).length:0}),o&&Object.keys(o).length>0){console.log("\u2705 [I18nProvider] Using provided translations (highest priority)"),t(o),a(!1),f(null);return}if(!e){console.log("\u26A0\uFE0F [I18nProvider] No translations provided, using empty object (keys will show as-is)"),t({}),a(!1),f(null);return}console.log("\u{1F310} [I18nProvider] Loading translations from URL:",e);let l=!1;return a(!0),f(null),fetch(e).then(y=>{if(!y.ok)throw new Error(`Failed to load translations: ${y.status}`);return y.json()}).then(y=>{l||(console.log("\u2705 [I18nProvider] Translations loaded successfully from URL:",{url:e,keysLoaded:Object.keys(y).length}),t(y),a(!1))}).catch(y=>{l||(console.error("\u274C [I18nProvider] Failed to load translations from URL:",e,y),f(y.message),console.log("\u{1F504} [I18nProvider] Falling back to empty translations (keys will show as-is)"),t({}),a(!1))}),()=>{l=!0}},[e,o]),{translations:r,loading:c,error:n}};import{jsx as fo}from"react/jsx-runtime";var po=nr(null),ar=()=>{try{return go()}catch{return null}},ir=(e,o)=>e&&e[o]?e[o]:o.split(".").reduce((r,t)=>r&&typeof r=="object"?r[t]:void 0,e),yo=({children:e,translations:o,translationsUrl:r,language:t="en"})=>{let a=ar()?.translations?.[t]||{},{translations:n,loading:f}=mo(r,o),l=ze(()=>({...a,...n,...o||{}}),[a,n,o]),y=ze(()=>(g,d)=>{let s=ir(l,g);return s==null&&(console.log(`\u{1F50D} [I18nProvider] Translation not found for key: "${g}" - showing key as-is`),s=g),d&&typeof s=="string"&&Object.entries(d).forEach(([i,u])=>{s=s.replace(new RegExp(`{{${i}}}`,"g"),u)}),typeof s=="string"?s:g},[l]),p=ze(()=>({t:y,language:t}),[y,t]);return f?fo("div",{children:"Loading translations..."}):fo(po.Provider,{value:p,children:e})},q=()=>{let e=sr(po);if(!e)throw new Error("useTranslation must be used within I18nProvider");return e};import{createContext as lr,useContext as cr,useReducer as dr,useEffect as ho}from"react";import{jsx as gr}from"react/jsx-runtime";var wo={currentScreen:"login",searchParams:{},formData:{username:"",password:"",email:"",code:"",newPassword:"",confirmPassword:""},loading:!1,errors:{global:[]},emailSent:!1,codeAlreadyExists:!1,codeValidated:!1,fromCodeVerification:!1,config:{}};function ur(e,o){switch(o.type){case"SET_SCREEN":let r={...e,currentScreen:o.payload.screen,searchParams:o.payload.params||e.searchParams,errors:{global:[]}},t=new URLSearchParams(r.searchParams),c=t.toString()?`?${t.toString()}`:window.location.pathname;try{window.history.replaceState({},"",c)}catch{}return r;case"SET_SEARCH_PARAMS":return{...e,searchParams:o.payload};case"UPDATE_FORM_DATA":return{...e,formData:{...e.formData,...o.payload},errors:{...e.errors,...Object.keys(o.payload).reduce((a,n)=>({...a,[n]:void 0}),{})}};case"SET_LOADING":return{...e,loading:o.payload};case"SET_ERRORS":return{...e,errors:{...e.errors,...o.payload}};case"CLEAR_ERRORS":return{...e,errors:{global:[]}};case"SET_EMAIL_SENT":return{...e,emailSent:o.payload};case"SET_CODE_ALREADY_EXISTS":return{...e,codeAlreadyExists:o.payload};case"SET_CODE_VALIDATED":return{...e,codeValidated:o.payload};case"SET_FROM_CODE_VERIFICATION":return{...e,fromCodeVerification:o.payload};case"RESET_FORM":return{...e,formData:wo.formData,errors:{global:[]},loading:!1,emailSent:!1,codeAlreadyExists:!1,codeValidated:!1,fromCodeVerification:!1};case"INIT_CONFIG":return{...e,config:o.payload};default:return e}}var bo=lr(void 0),Po=({children:e,initialScreen:o="login",config:r,autoReadFromCookies:t=!0})=>{let[c,a]=dr(ur,{...wo,currentScreen:o});ho(()=>{a({type:"INIT_CONFIG",payload:(()=>{let s={};if(t)try{let i=ro("logo");if(i){let u=decodeURIComponent(i);u.startsWith("http")&&(s.logo=u)}}catch(i){console.error("Error reading configuration from cookies:",i)}return{publicApiKey:r?.publicApiKey,env:r?.env,appName:r?.appName,logo:r?.logo||s.logo,loginActions:r?.loginActions}})()})},[r,t]),ho(()=>{let d=new URLSearchParams(window.location.search),s={};d.forEach((i,u)=>{s[u]=i}),Object.keys(s).length>0&&a({type:"SET_SEARCH_PARAMS",payload:s}),o==="checkCode"&&s.email&&a({type:"UPDATE_FORM_DATA",payload:{email:s.email,code:s.code||""}}),o==="resetPassword"&&s.link&&a({type:"SET_SEARCH_PARAMS",payload:s})},[o]);let g={state:c,dispatch:a,setScreen:(d,s)=>{a({type:"SET_SCREEN",payload:{screen:d,params:s}})},updateFormData:d=>{a({type:"UPDATE_FORM_DATA",payload:d})},setFieldError:(d,s)=>{a({type:"SET_ERRORS",payload:{[d]:s}})},clearErrors:()=>{a({type:"CLEAR_ERRORS"})},setLoading:d=>{a({type:"SET_LOADING",payload:d})}};return gr(bo.Provider,{value:g,children:e})},Ie=()=>{let e=cr(bo);if(e===void 0)throw new Error("useLoginState must be used within a LoginStateProvider");return e};import{useEffect as mr,useRef as fr}from"react";import{Typography as Me,TextField as Co,Button as pr,Box as he,CircularProgress as yr,Alert as hr,Link as xo}from"@mui/material";import{Fragment as br,jsx as H,jsxs as we}from"react/jsx-runtime";var wr=({onScreenChange:e,onExternalNavigate:o,onLoginSuccess:r,onError:t,redirectUrl:c="/"})=>{let{crudify:a}=X(),{state:n,updateFormData:f,setFieldError:l,clearErrors:y,setLoading:p}=Ie(),{login:g}=te(),d=q(),{t:s}=d,i=d.i18n,u=fr(null),T=to(s,{currentLanguage:i?.language,enableDebug:!1}),E=()=>{if(n.searchParams.redirect)try{let h=decodeURIComponent(n.searchParams.redirect);if(h.startsWith("/")&&!h.startsWith("//"))return h}catch{}return c||"/"};mr(()=>{let h=setTimeout(()=>{u.current&&u.current.focus()},100);return()=>clearTimeout(h)},[]);let m=h=>{console.log("\u{1F50D} [LoginForm] Translating parsed error:",h);let P=T.translateError({code:h.code,message:h.message,field:h.field});return console.log("\u{1F50D} [LoginForm] Translation result:",P),P},w=async()=>{if(!n.loading){if(!n.formData.username.trim()){l("username",s("login.usernameRequired"));return}if(!n.formData.password.trim()){l("password",s("login.passwordRequired"));return}y(),p(!0);try{let h=await g(n.formData.username,n.formData.password);if(p(!1),h.success){console.log("\u{1F510} LoginForm - Login successful via SessionProvider, calling onLoginSuccess");let P=E();r&&r(h.data,P)}else{let P=h.rawResponse||h;x(P)}}catch(h){p(!1);let R=M(h).map(m);l("global",R),t&&t(R.join(", "))}}},x=h=>{M(h).forEach(R=>{if(R.field)l(R.field,m(R));else{let U=n.errors.global||[];l("global",[...U,m(R)])}})};return we(br,{children:[we(he,{component:"form",noValidate:!0,onSubmit:h=>{h.preventDefault(),w()},onKeyDown:h=>{h.key==="Enter"&&!n.loading&&(h.preventDefault(),w())},sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[we(he,{sx:{mb:1},children:[H(Me,{variant:"body2",component:"label",htmlFor:"email",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:s("login.usernameOrEmailLabel")}),H(Co,{fullWidth:!0,id:"email",name:"email",type:"email",value:n.formData.username,disabled:n.loading,onChange:h=>f({username:h.target.value}),error:!!n.errors.username,helperText:n.errors.username,autoComplete:"email",placeholder:s("login.usernameOrEmailPlaceholder"),inputRef:u,required:!0})]}),we(he,{sx:{mb:1},children:[H(Me,{variant:"body2",component:"label",htmlFor:"password",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:s("login.passwordLabel")}),H(Co,{fullWidth:!0,id:"password",name:"password",type:"password",value:n.formData.password,disabled:n.loading,onChange:h=>f({password:h.target.value}),error:!!n.errors.password,helperText:n.errors.password,autoComplete:"current-password",placeholder:s("login.passwordPlaceholder"),required:!0})]}),n.config.loginActions?.includes("forgotPassword")&&H(he,{sx:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:H(xo,{sx:{cursor:"pointer"},onClick:()=>{e?.("forgotPassword",n.searchParams)},variant:"body2",color:"secondary",children:s("login.forgotPasswordLink")})}),H(pr,{disabled:n.loading,type:"submit",fullWidth:!0,variant:"contained",color:"primary",sx:{mt:1,mb:2},children:n.loading?H(yr,{size:20}):s("login.loginButton")})]}),H(he,{children:n.errors.global&&n.errors.global.length>0&&n.errors.global.map((h,P)=>H(hr,{variant:"filled",sx:{mt:2},severity:"error",children:H("div",{children:h})},P))}),n.config.loginActions?.includes("createUser")&&we(Me,{variant:"body2",align:"center",sx:{color:"text.secondary",mt:3},children:[s("login.noAccountPrompt")," ",H(xo,{sx:{cursor:"pointer"},onClick:()=>{let P=`/public/users/create${Object.keys(n.searchParams).length>0?`?${new URLSearchParams(n.searchParams).toString()}`:""}`;o?.(P)},fontWeight:"medium",color:"secondary",children:s("login.signUpLink")})]})]})},To=wr;import{useState as de}from"react";import{Typography as ue,TextField as Pr,Button as Eo,Box as ne,CircularProgress as Cr,Alert as xr,Link as Ve}from"@mui/material";import{Fragment as vo,jsx as N,jsxs as le}from"react/jsx-runtime";var Tr=({onScreenChange:e,onError:o})=>{let{crudify:r}=X(),[t,c]=de(""),[a,n]=de(!1),[f,l]=de([]),[y,p]=de(null),[g,d]=de(!1),[s,i]=de(!1),{t:u}=q(),T=C=>{let S=[`errors.auth.${C.code}`,`errors.data.${C.code}`,`errors.system.${C.code}`,`errors.${C.code}`,`forgotPassword.${C.code.toLowerCase()}`];for(let h of S){let P=u(h);if(P!==h)return P}return C.message||u("error.unknown")},E=C=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(C),m=async()=>{if(!(a||!r)){if(l([]),p(null),!t){p(u("forgotPassword.emailRequired"));return}if(!E(t)){p(u("forgotPassword.invalidEmail"));return}n(!0);try{let C=[{operation:"requestPasswordReset",data:{email:t}}],S=await r.transaction(C);if(S.success)S.data&&S.data.existingCodeValid?i(!0):d(!0);else{let P=M(S).map(T);l(P)}}catch(C){let h=M(C).map(T);l(h),o&&o(h.join(", "))}finally{n(!1)}}},w=()=>{e?.("login")},x=()=>{if(g||s){e?.("checkCode",{email:t});return}if(!t){p(u("forgotPassword.emailRequired"));return}if(!E(t)){p(u("forgotPassword.invalidEmail"));return}e?.("checkCode",{email:t})};return g||s?N(vo,{children:le(ne,{sx:{width:"100%",display:"flex",flexDirection:"column",gap:2,textAlign:"center"},children:[le(ne,{sx:{mb:2},children:[N(ue,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:u(s?"forgotPassword.codeAlreadyExistsMessage":"forgotPassword.emailSentMessage")}),N(ue,{variant:"body2",sx:{color:s?"success.main":"grey.600"},children:u("forgotPassword.checkEmailInstructions")})]}),N(Eo,{type:"button",onClick:x,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:u("forgotPassword.enterCodeLink")}),N(ne,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:N(Ve,{sx:{cursor:"pointer"},onClick:w,variant:"body2",color:"secondary",children:u("common.back")})})]})}):le(vo,{children:[le(ne,{component:"form",noValidate:!0,sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[le(ne,{sx:{mb:2},children:[N(ue,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:u("forgotPassword.title")}),N(ue,{variant:"body2",sx:{color:"grey.600"},children:u("forgotPassword.instructions")})]}),le(ne,{sx:{mb:1},children:[N(ue,{variant:"body2",component:"label",htmlFor:"email",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:u("forgotPassword.emailLabel")}),N(Pr,{fullWidth:!0,id:"email",name:"email",type:"email",value:t,disabled:a,onChange:C=>c(C.target.value),error:!!y,helperText:y,autoComplete:"email",placeholder:u("forgotPassword.emailPlaceholder"),required:!0})]}),N(Eo,{disabled:a,type:"button",onClick:m,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:a?N(Cr,{size:20}):u("forgotPassword.sendCodeButton")}),le(ne,{sx:{display:"flex",justifyContent:"center",alignItems:"center",gap:2},children:[N(Ve,{sx:{cursor:"pointer"},onClick:w,variant:"body2",color:"secondary",children:u("common.back")}),N(ue,{variant:"body2",sx:{color:"grey.400"},children:"\u2022"}),N(Ve,{sx:{cursor:"pointer"},onClick:x,variant:"body2",color:"secondary",children:u("login.alreadyHaveCodeLink")})]})]}),N(ne,{children:f.length>0&&f.map((C,S)=>N(xr,{variant:"filled",sx:{mt:2},severity:"error",children:C},S))})]})},So=Tr;import{useState as W,useEffect as Ro}from"react";import{Typography as Le,TextField as Io,Button as Er,Box as se,CircularProgress as Lo,Alert as ko,Link as vr}from"@mui/material";import{Fragment as Rr,jsx as F,jsxs as be}from"react/jsx-runtime";var Sr=({onScreenChange:e,onError:o,searchParams:r,onResetSuccess:t})=>{let{crudify:c}=X(),[a,n]=W(""),[f,l]=W(""),[y,p]=W(!1),[g,d]=W([]),[s,i]=W(null),[u,T]=W(null),[E,m]=W(""),[w,x]=W(""),[C,S]=W(!1),[h,P]=W(!0),[R,U]=W(!1),[I,K]=W(null),[Q,Ee]=W(!1),{t:O}=q(),ve=v=>{let L=[`errors.auth.${v.code}`,`errors.data.${v.code}`,`errors.system.${v.code}`,`errors.${v.code}`,`resetPassword.${v.code.toLowerCase()}`];for(let z of L){let V=O(z);if(V!==z)return V}return v.message||O("error.unknown")},Se=v=>r?r instanceof URLSearchParams?r.get(v):r[v]||null:null;Ro(()=>{if(r){if(r){let v=Se("fromCodeVerification"),L=Se("email"),z=Se("code");if(v==="true"&&L&&z){m(L),x(z),S(!0),U(!0),P(!1);return}let V=Se("link");if(V)try{let $=decodeURIComponent(V),[Y,pe]=$.split("/");if(Y&&pe&&Y.length===6){x(Y),m(pe),S(!1),K({email:pe,code:Y});return}}catch{}if(L&&z){m(L),x(z),S(!1),K({email:L,code:z});return}}d([O("resetPassword.invalidCode")]),P(!1),setTimeout(()=>e?.("forgotPassword"),3e3)}},[r,c,O,e]),Ro(()=>{c&&I&&!Q&&(Ee(!0),(async(L,z)=>{try{let V=[{operation:"validatePasswordResetCode",data:{email:L,codePassword:z}}],$=await c.transaction(V);if($.data&&Array.isArray($.data)){let Y=$.data[0];if(Y&&Y.response&&Y.response.status==="OK"){U(!0);return}}if($.success)U(!0);else{let pe=M($).map(ve);d(pe),setTimeout(()=>e?.("forgotPassword"),3e3)}}catch(V){let Y=M(V).map(ve);d(Y),setTimeout(()=>e?.("forgotPassword"),3e3)}finally{P(!1),K(null),Ee(!1)}})(I.email,I.code))},[c,I,O,e]);let $o=v=>v.length<8?O("resetPassword.passwordTooShort"):null,Yo=async()=>{if(y||!c)return;d([]),i(null),T(null);let v=!1;if(!a)i(O("resetPassword.newPasswordRequired")),v=!0;else{let L=$o(a);L&&(i(L),v=!0)}if(f?a!==f&&(T(O("resetPassword.passwordsDoNotMatch")),v=!0):(T(O("resetPassword.confirmPasswordRequired")),v=!0),!v){p(!0);try{let L=[{operation:"validateAndResetPassword",data:{email:E,codePassword:w,newPassword:a}}],z=await c.transaction(L);if(z.success)d([]),setTimeout(()=>{t?.()},1e3);else{let $=M(z).map(ve);d($)}}catch(L){let V=M(L).map(ve);d(V),o&&o(V.join(", "))}p(!1)}},Go=()=>{C?e?.("checkCode",{email:E}):e?.("forgotPassword")};return h?F(se,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"300px"},children:F(Lo,{})}):R?be(Rr,{children:[be(se,{component:"form",noValidate:!0,sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[be(se,{sx:{mb:2},children:[F(Le,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:O("resetPassword.title")}),F(Le,{variant:"body2",sx:{color:"grey.600"},children:O("resetPassword.instructions")})]}),be(se,{sx:{mb:1},children:[F(Le,{variant:"body2",component:"label",htmlFor:"newPassword",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:O("resetPassword.newPasswordLabel")}),F(Io,{fullWidth:!0,id:"newPassword",name:"newPassword",type:"password",value:a,disabled:y,onChange:v=>n(v.target.value),error:!!s,helperText:s,autoComplete:"new-password",placeholder:O("resetPassword.newPasswordPlaceholder"),required:!0})]}),be(se,{sx:{mb:1},children:[F(Le,{variant:"body2",component:"label",htmlFor:"confirmPassword",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:O("resetPassword.confirmPasswordLabel")}),F(Io,{fullWidth:!0,id:"confirmPassword",name:"confirmPassword",type:"password",value:f,disabled:y,onChange:v=>l(v.target.value),error:!!u,helperText:u,autoComplete:"new-password",placeholder:O("resetPassword.confirmPasswordPlaceholder"),required:!0})]}),F(Er,{disabled:y,type:"button",onClick:Yo,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:y?F(Lo,{size:20}):O("resetPassword.resetPasswordButton")}),F(se,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:F(vr,{sx:{cursor:"pointer"},onClick:Go,variant:"body2",color:"secondary",children:O("common.back")})})]}),F(se,{children:g.length>0&&g.map((v,L)=>F(ko,{variant:"filled",sx:{mt:2},severity:"error",children:v},L))})]}):F(se,{children:g.length>0&&g.map((v,L)=>F(ko,{variant:"filled",sx:{mt:2},severity:"error",children:v},L))})},Ao=Sr;import{useState as Pe,useEffect as Ir}from"react";import{Typography as We,TextField as Lr,Button as kr,Box as Ce,CircularProgress as Ar,Alert as _r,Link as Or}from"@mui/material";import{Fragment as Fr,jsx as Z,jsxs as ke}from"react/jsx-runtime";var Nr=({onScreenChange:e,onError:o,searchParams:r})=>{let{crudify:t}=X(),[c,a]=Pe(""),[n,f]=Pe(!1),[l,y]=Pe([]),[p,g]=Pe(null),[d,s]=Pe(""),{t:i}=q(),u=x=>r?r instanceof URLSearchParams?r.get(x):r[x]||null:null,T=x=>{let C=[`errors.auth.${x.code}`,`errors.data.${x.code}`,`errors.system.${x.code}`,`errors.${x.code}`,`checkCode.${x.code.toLowerCase()}`];for(let S of C){let h=i(S);if(h!==S)return h}return x.message||i("error.unknown")};Ir(()=>{let x=u("email");x?s(x):e?.("forgotPassword")},[r,e]);let E=async()=>{if(!(n||!t)){if(y([]),g(null),!c){g(i("checkCode.codeRequired"));return}if(c.length!==6){g(i("checkCode.codeRequired"));return}f(!0);try{let x=[{operation:"validatePasswordResetCode",data:{email:d,codePassword:c}}],C=await t.transaction(x);if(C.success)e?.("resetPassword",{email:d,code:c,fromCodeVerification:"true"});else{let h=M(C).map(T);y(h),f(!1)}}catch(x){let S=M(x).map(T);y(S),f(!1),o&&o(S.join(", "))}}},m=()=>{e?.("forgotPassword")},w=x=>{let C=x.target.value.replace(/\D/g,"").slice(0,6);a(C)};return ke(Fr,{children:[ke(Ce,{component:"form",noValidate:!0,sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[ke(Ce,{sx:{mb:2},children:[Z(We,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:i("checkCode.title")}),Z(We,{variant:"body2",sx:{color:"grey.600"},children:i("checkCode.instructions")})]}),ke(Ce,{sx:{mb:1},children:[Z(We,{variant:"body2",component:"label",htmlFor:"code",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:i("checkCode.codeLabel")}),Z(Lr,{fullWidth:!0,id:"code",name:"code",type:"text",value:c,disabled:n,onChange:w,error:!!p,helperText:p,placeholder:i("checkCode.codePlaceholder"),inputProps:{maxLength:6,style:{textAlign:"center",fontSize:"1.5rem",letterSpacing:"0.4rem"}},required:!0})]}),Z(kr,{disabled:n||c.length!==6,type:"button",onClick:E,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:n?Z(Ar,{size:20}):i("checkCode.verifyButton")}),Z(Ce,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:Z(Or,{sx:{cursor:"pointer"},onClick:m,variant:"body2",color:"secondary",children:i("common.back")})})]}),Z(Ce,{children:l.length>0&&l.map((x,C)=>Z(_r,{sx:{mt:2},severity:"error",children:x},C))})]})},_o=Nr;import{Box as Dr,CircularProgress as Br,Alert as Oo,Typography as je}from"@mui/material";import{Fragment as Ur,jsx as ge,jsxs as No}from"react/jsx-runtime";var Fo=({children:e,fallback:o})=>{let{isLoading:r,error:t,isInitialized:c}=X(),{t:a}=q();return r?o||No(Dr,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"200px",gap:2},children:[ge(Br,{}),ge(je,{variant:"body2",color:"text.secondary",children:a("login.initializing")!=="login.initializing"?a("login.initializing"):"Initializing..."})]}):t?ge(Oo,{severity:"error",sx:{mt:2},children:No(je,{variant:"body2",children:[a("login.initializationError")!=="login.initializationError"?a("login.initializationError"):"Initialization error",":"," ",t]})}):c?ge(Ur,{children:e}):ge(Oo,{severity:"warning",sx:{mt:2},children:ge(je,{variant:"body2",children:a("login.notInitialized")!=="login.notInitialized"?a("login.notInitialized"):"System not initialized"})})};import{jsx as G,jsxs as jr}from"react/jsx-runtime";var Vr=({onScreenChange:e,onExternalNavigate:o,onLoginSuccess:r,onError:t,redirectUrl:c="/"})=>{let{t:a}=q(),{state:n,setScreen:f}=Ie(),{config:l}=te(),{showNotification:y}=no(),p=(d,s)=>{let i=s;d==="login"?i={}:d==="forgotPassword"&&!s&&(i={}),f(d,i),e?.(d,i)},g=()=>{let d={onScreenChange:p,onExternalNavigate:o,onError:t,redirectUrl:c};switch(n.currentScreen){case"forgotPassword":return G(So,{...d});case"checkCode":return G(_o,{...d,searchParams:n.searchParams});case"resetPassword":return G(Ao,{...d,searchParams:n.searchParams,onResetSuccess:()=>{let s=a("resetPassword.successMessage");y(s,"success"),p("login")}});default:return G(To,{...d,onLoginSuccess:r})}};return jr(Fo,{children:[G(zr,{sx:{display:"flex",justifyContent:"center",mb:3},children:G("img",{src:l.logo||"https://logos.crudia.com/nocios-default.png",alt:a("login.logoAlt"),style:{width:"100%",maxWidth:"150px",height:"auto"},onError:d=>{let s=d.target;s.src="https://logos.crudia.com/nocios-default.png"}})}),!l.logo&&l.appName&&G(Mr,{variant:"h6",component:"h1",sx:{textAlign:"center",mb:2},children:l.appName}),g()]})},Wr=({translations:e,translationsUrl:o,language:r="en",initialScreen:t="login",autoReadFromCookies:c=!0,...a})=>{let{config:n}=te();return G(yo,{translations:e,translationsUrl:o,language:r,children:G(oo,{config:n,children:G(Po,{config:n,initialScreen:t,autoReadFromCookies:c,children:G(Vr,{...a})})})})},is=Wr;import{Box as j,Card as Do,CardContent as Bo,Typography as J,Chip as Ae,Avatar as qr,Divider as Hr,CircularProgress as Kr,Alert as Uo,List as $r,ListItem as qe,ListItemText as He,ListItemIcon as Yr,Collapse as Gr,IconButton as Ke}from"@mui/material";import{Person as Jr,Email as Qr,Badge as Xr,Security as Zr,Schedule as et,AccountCircle as ot,ExpandMore as rt,ExpandLess as tt,Info as nt}from"@mui/icons-material";import{useState as st}from"react";import{Fragment as lt,jsx as b,jsxs as k}from"react/jsx-runtime";var at=({showExtendedData:e=!0,showProfileCard:o=!0,autoRefresh:r=!0})=>{let{userProfile:t,loading:c,error:a,extendedData:n,refreshProfile:f}=so({autoFetch:r,retryOnError:!0,maxRetries:3}),[l,y]=st(!1);if(c)return k(j,{display:"flex",justifyContent:"center",alignItems:"center",p:3,children:[b(Kr,{}),b(J,{variant:"body2",sx:{ml:2},children:"Cargando perfil de usuario..."})]});if(a)return k(Uo,{severity:"error",action:b(Ke,{color:"inherit",size:"small",onClick:f,children:b(J,{variant:"caption",children:"Reintentar"})}),children:["Error al cargar el perfil: ",a]});if(!t)return b(Uo,{severity:"warning",children:"No se encontr\xF3 informaci\xF3n del usuario"});let p=n?.displayData||{},g=n?.totalFields||0,d=m=>{if(!m)return"No disponible";try{return new Date(m).toLocaleString("es-ES",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return m}},s=(m,w)=>w==null?"No disponible":typeof w=="boolean"?w?"S\xED":"No":Array.isArray(w)?w.length>0?w.join(", "):"Ninguno":typeof w=="object"?JSON.stringify(w,null,2):String(w),i=[{key:"id",label:"ID",icon:b(Xr,{})},{key:"email",label:"Email",icon:b(Qr,{})},{key:"username",label:"Usuario",icon:b(Jr,{})},{key:"fullName",label:"Nombre completo",icon:b(ot,{})},{key:"role",label:"Rol",icon:b(Zr,{})}],u=[{key:"firstName",label:"Nombre"},{key:"lastName",label:"Apellido"},{key:"isActive",label:"Activo"},{key:"lastLogin",label:"\xDAltimo login"},{key:"createdAt",label:"Creado"},{key:"updatedAt",label:"Actualizado"}],T=[...i.map(m=>m.key),...u.map(m=>m.key),"permissions"],E=Object.keys(p).filter(m=>!T.includes(m)).map(m=>({key:m,label:m}));return k(j,{children:[o&&b(Do,{sx:{mb:2},children:k(Bo,{children:[k(j,{display:"flex",alignItems:"center",mb:2,children:[b(qr,{src:p.avatar,sx:{width:56,height:56,mr:2},children:p.fullName?.[0]||p.username?.[0]||p.email?.[0]}),k(j,{children:[b(J,{variant:"h6",children:p.fullName||p.username||p.email}),b(J,{variant:"body2",color:"text.secondary",children:p.role||"Usuario"}),p.isActive!==void 0&&b(Ae,{label:p.isActive?"Activo":"Inactivo",color:p.isActive?"success":"error",size:"small",sx:{mt:.5}})]})]}),b(j,{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(250px, 1fr))",gap:2,children:i.map(({key:m,label:w,icon:x})=>p[m]?k(j,{display:"flex",alignItems:"center",children:[b(j,{sx:{mr:1,color:"text.secondary"},children:x}),k(j,{children:[b(J,{variant:"caption",color:"text.secondary",children:w}),b(J,{variant:"body2",children:s(m,p[m])})]})]},m):null)}),p.permissions&&Array.isArray(p.permissions)&&p.permissions.length>0&&k(j,{mt:2,children:[b(J,{variant:"caption",color:"text.secondary",display:"block",children:"Permisos"}),k(j,{display:"flex",flexWrap:"wrap",gap:.5,mt:.5,children:[p.permissions.slice(0,5).map((m,w)=>b(Ae,{label:m,size:"small",variant:"outlined"},w)),p.permissions.length>5&&b(Ae,{label:`+${p.permissions.length-5} m\xE1s`,size:"small"})]})]})]})}),e&&b(Do,{children:k(Bo,{children:[k(j,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[k(J,{variant:"h6",display:"flex",alignItems:"center",children:[b(nt,{sx:{mr:1}}),"Informaci\xF3n Detallada"]}),b(Ae,{label:`${g} campos totales`,size:"small"})]}),k($r,{dense:!0,children:[u.map(({key:m,label:w})=>p[m]!==void 0&&k(qe,{divider:!0,children:[b(Yr,{children:b(et,{fontSize:"small"})}),b(He,{primary:w,secondary:m.includes("At")||m.includes("Login")?d(p[m]):s(m,p[m])})]},m)),E.length>0&&k(lt,{children:[b(Hr,{sx:{my:1}}),b(qe,{children:b(He,{primary:k(j,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[k(J,{variant:"subtitle2",children:["Campos Personalizados (",E.length,")"]}),b(Ke,{size:"small",onClick:()=>y(!l),children:l?b(tt,{}):b(rt,{})})]})})}),b(Gr,{in:l,children:E.map(({key:m,label:w})=>b(qe,{sx:{pl:4},children:b(He,{primary:w,secondary:s(m,p[m])})},m))})]})]}),k(j,{mt:2,display:"flex",justifyContent:"space-between",alignItems:"center",children:[k(J,{variant:"caption",color:"text.secondary",children:["\xDAltima actualizaci\xF3n: ",d(p.updatedAt)]}),b(Ke,{size:"small",onClick:f,disabled:c,children:b(J,{variant:"caption",children:"Actualizar"})})]})]})})]})},it=at;var zo=["create","read","update","delete"],Mo=["create","read","update","delete"];import{useRef as _t}from"react";import{useTranslation as Ot}from"react-i18next";import{Box as Oe,Typography as qo,Button as Nt,Stack as Ft,Alert as Ho,Divider as Dt}from"@mui/material";import{Add as Bt}from"@mui/icons-material";import{forwardRef as bt}from"react";import{useTranslation as Pt}from"react-i18next";import{Box as ce,FormControl as Ct,InputLabel as xt,Select as Tt,MenuItem as Et,IconButton as vt,Typography as me,FormHelperText as St,Stack as _e,Paper as jo,Divider as Rt,Button as Qe}from"@mui/material";import{Delete as It,SelectAll as Lt,ClearAll as kt}from"@mui/icons-material";import{useState as ct,useEffect as dt,useRef as ut}from"react";import{useTranslation as gt}from"react-i18next";import{Box as $e,Typography as xe,Button as Vo,Stack as Ye,FormHelperText as Wo,ToggleButton as Ge,ToggleButtonGroup as mt}from"@mui/material";import{CheckCircle as ft,Cancel as pt,SelectAll as yt,ClearAll as ht}from"@mui/icons-material";import{jsx as D,jsxs as ae}from"react/jsx-runtime";var wt=({value:e,onChange:o,availableFields:r,error:t,disabled:c=!1})=>{let{t:a}=gt(),[n,f]=ct("custom"),l=ut(!1);dt(()=>{let s=e||{allow:[],owner_allow:[],deny:[]},i=new Set(r),u=(s.allow||[]).filter(w=>i.has(w)),T=(s.owner_allow||[]).filter(w=>i.has(w)),E=(s.deny||[]).filter(w=>i.has(w));r.forEach(w=>{!u.includes(w)&&!T.includes(w)&&!E.includes(w)&&E.push(w)});let m={allow:u,owner_allow:T,deny:E};JSON.stringify(m)!==JSON.stringify(s)&&o(m),u.length===r.length?f("all"):E.length===r.length?f("none"):f("custom")},[r,e]);let y=()=>{l.current=!0,o({allow:[...r],owner_allow:[],deny:[]}),f("all"),setTimeout(()=>{l.current=!1},0)},p=()=>{l.current=!0,o({allow:[],owner_allow:[],deny:[...r]}),f("none"),setTimeout(()=>{l.current=!1},0)},g=s=>e?.allow?.includes(s)?"allow":e?.owner_allow?.includes(s)?"owner_allow":"deny",d=(s,i)=>{l.current=!0;let u=new Set(e?.allow||[]),T=new Set(e?.owner_allow||[]),E=new Set(e?.deny||[]);u.delete(s),T.delete(s),E.delete(s),i==="allow"&&u.add(s),i==="owner_allow"&&T.add(s),i==="deny"&&E.add(s),o({allow:Array.from(u),owner_allow:Array.from(T),deny:Array.from(E)}),f("custom"),setTimeout(()=>{l.current=!1},0)};return r.length===0?ae($e,{children:[D(xe,{variant:"body2",color:"text.secondary",sx:{mb:1},children:a("modules.form.publicPolicies.fields.conditions.label")}),D(xe,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic"},children:a("modules.form.publicPolicies.fields.conditions.noFieldsAvailable")}),t&&D(Wo,{error:!0,sx:{mt:1},children:t})]}):ae($e,{children:[D(xe,{variant:"body2",color:"text.secondary",sx:{mb:2},children:a("modules.form.publicPolicies.fields.conditions.label")}),ae(Ye,{direction:"row",spacing:1,sx:{mb:3},children:[D(Vo,{variant:n==="all"?"contained":"outlined",startIcon:D(yt,{}),onClick:y,disabled:c,size:"small",sx:{minWidth:120,...n==="all"&&{backgroundColor:"#16a34a","&:hover":{backgroundColor:"#15803d"}}},children:a("modules.form.publicPolicies.fields.conditions.allFields")}),D(Vo,{variant:n==="none"?"contained":"outlined",startIcon:D(ht,{}),onClick:p,disabled:c,size:"small",sx:{minWidth:120,...n==="none"&&{backgroundColor:"#cf222e","&:hover":{backgroundColor:"#bc1f2c"}}},children:a("modules.form.publicPolicies.fields.conditions.noFields")})]}),ae($e,{sx:{p:2,border:"1px solid #d1d9e0",borderRadius:1,backgroundColor:"#f6f8fa"},children:[D(xe,{variant:"body2",color:"text.secondary",sx:{mb:2},children:a("modules.form.publicPolicies.fields.conditions.help")}),D(Ye,{spacing:1,children:r.map(s=>{let i=g(s);return ae(Ye,{direction:"row",spacing:1,alignItems:"center",children:[D(xe,{variant:"body2",sx:{minWidth:100,fontFamily:"monospace"},children:s}),ae(mt,{value:i,exclusive:!0,size:"small",children:[ae(Ge,{value:"allow",onClick:()=>d(s,"allow"),disabled:c,sx:{px:2,color:i==="allow"?"#ffffff":"#6b7280",backgroundColor:i==="allow"?"#16a34a":"#f3f4f6",borderColor:i==="allow"?"#16a34a":"#d1d5db","&:hover":{backgroundColor:i==="allow"?"#15803d":"#e5e7eb",borderColor:i==="allow"?"#15803d":"#9ca3af"},"&.Mui-selected":{backgroundColor:"#16a34a",color:"#ffffff","&:hover":{backgroundColor:"#15803d"}}},children:[D(ft,{sx:{fontSize:16,mr:.5}}),a("modules.form.publicPolicies.fields.conditions.states.allow")]}),D(Ge,{value:"owner_allow",onClick:()=>d(s,"owner_allow"),disabled:c,sx:{px:2,color:i==="owner_allow"?"#ffffff":"#6b7280",backgroundColor:i==="owner_allow"?"#0ea5e9":"#f3f4f6",borderColor:i==="owner_allow"?"#0ea5e9":"#d1d5db","&:hover":{backgroundColor:i==="owner_allow"?"#0284c7":"#e5e7eb",borderColor:i==="owner_allow"?"#0284c7":"#9ca3af"},"&.Mui-selected":{backgroundColor:"#0ea5e9",color:"#ffffff","&:hover":{backgroundColor:"#0284c7"}}},children:a("modules.form.publicPolicies.fields.conditions.states.ownerAllow")}),ae(Ge,{value:"deny",onClick:()=>d(s,"deny"),disabled:c,sx:{px:2,color:i==="deny"?"#ffffff":"#6b7280",backgroundColor:i==="deny"?"#dc2626":"#f3f4f6",borderColor:i==="deny"?"#dc2626":"#d1d5db","&:hover":{backgroundColor:i==="deny"?"#b91c1c":"#e5e7eb",borderColor:i==="deny"?"#b91c1c":"#9ca3af"},"&.Mui-selected":{backgroundColor:"#dc2626",color:"#ffffff","&:hover":{backgroundColor:"#b91c1c"}}},children:[D(pt,{sx:{fontSize:16,mr:.5}}),a("modules.form.publicPolicies.fields.conditions.states.deny")]})]})]},s)})})]}),t&&D(Wo,{error:!0,sx:{mt:1},children:t})]})},Je=wt;import{jsx as _,jsxs as B}from"react/jsx-runtime";var At=bt(({policy:e,onChange:o,onRemove:r,availableFields:t,isSubmitting:c=!1,usedActions:a,error:n},f)=>{let{t:l}=Pt(),y=new Set(Array.from(a||[]));y.delete(e.action);let p=zo.map(g=>({value:g,label:l(`modules.form.publicPolicies.fields.action.options.${g}`)}));return B(jo,{ref:f,sx:{p:3,border:"1px solid #d1d9e0",borderRadius:2,position:"relative",backgroundColor:"#ffffff"},children:[B(ce,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:3},children:[_(me,{variant:"subtitle1",sx:{fontWeight:600,color:"#111418",fontSize:"1rem"},children:l("modules.form.publicPolicies.policyTitle")}),_(vt,{onClick:r,size:"small",disabled:c,"aria-label":l("modules.form.publicPolicies.removePolicy"),sx:{color:"#656d76","&:hover":{color:"#cf222e",backgroundColor:"rgba(207, 34, 46, 0.1)"}},children:_(It,{})})]}),B(_e,{spacing:3,children:[_(_e,{direction:{xs:"column",md:"row"},spacing:2,children:_(ce,{sx:{flex:1,minWidth:200},children:B(Ct,{fullWidth:!0,children:[_(xt,{children:l("modules.form.publicPolicies.fields.action.label")}),_(Tt,{value:e.action,label:l("modules.form.publicPolicies.fields.action.label"),disabled:c,onChange:g=>{let d=g.target.value,s={...e,action:d};d==="delete"?(s.permission="deny",delete s.fields):(s.fields={allow:[],owner_allow:[],deny:t},delete s.permission),o(s)},sx:{backgroundColor:"#ffffff","&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"#8c959f"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"#0969da",borderWidth:2}},children:p.map(g=>{let d=y.has(g.value);return _(Et,{value:g.value,disabled:d,children:g.label},g.value)})}),n&&_(St,{error:!0,children:n})]})})}),e.action==="delete"?B(ce,{children:[_(me,{variant:"body2",color:"text.secondary",sx:{mb:2},children:l("modules.form.publicPolicies.fields.conditions.label")}),B(_e,{direction:"row",spacing:1,sx:{mb:3},children:[_(Qe,{variant:e.permission==="*"?"contained":"outlined",startIcon:_(Lt,{}),onClick:()=>o({...e,permission:"*"}),disabled:c,size:"small",sx:{minWidth:140,whiteSpace:"nowrap",...e.permission==="*"&&{backgroundColor:"#16a34a","&:hover":{backgroundColor:"#15803d"}}},children:l("modules.form.publicPolicies.fields.conditions.allFields")}),_(Qe,{variant:e.permission==="owner"?"contained":"outlined",onClick:()=>o({...e,permission:"owner"}),disabled:c,size:"small",sx:{minWidth:140,whiteSpace:"nowrap",...e.permission==="owner"&&{backgroundColor:"#0ea5e9","&:hover":{backgroundColor:"#0284c7"}}},children:l("modules.form.publicPolicies.fields.conditions.states.ownerAllow")}),_(Qe,{variant:e.permission==="deny"?"contained":"outlined",startIcon:_(kt,{}),onClick:()=>o({...e,permission:"deny"}),disabled:c,size:"small",sx:{minWidth:140,whiteSpace:"nowrap",...e.permission==="deny"&&{backgroundColor:"#cf222e","&:hover":{backgroundColor:"#bc1f2c"}}},children:l("modules.form.publicPolicies.fields.conditions.noFields")})]})]}):_(Je,{value:e.fields||{allow:[],owner_allow:[],deny:[]},onChange:g=>o({...e,fields:g}),availableFields:t,disabled:c}),_(jo,{variant:"outlined",sx:{p:2,backgroundColor:"#f9fafb"},children:e.action==="delete"?B(me,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[B(ce,{component:"span",sx:{color:e.permission==="*"?"#16a34a":e.permission==="owner"?"#0ea5e9":"#dc2626"},children:[l("modules.form.publicPolicies.fields.conditions.states.allow"),":"]})," ",e.permission||"-"]}):B(_e,{spacing:.5,divider:_(Rt,{sx:{borderColor:"#e5e7eb"}}),children:[B(me,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[B(ce,{component:"span",sx:{color:"#16a34a"},children:[l("modules.form.publicPolicies.fields.conditions.states.allow"),":"]})," ",(e?.fields?.allow||[]).join(", ")||"-"]}),B(me,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[B(ce,{component:"span",sx:{color:"#0ea5e9"},children:[l("modules.form.publicPolicies.fields.conditions.states.ownerAllow"),":"]})," ",(e?.fields?.owner_allow||[]).join(", ")||"-"]}),B(me,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[B(ce,{component:"span",sx:{color:"#dc2626"},children:[l("modules.form.publicPolicies.fields.conditions.states.deny"),":"]})," ",(e?.fields?.deny||[]).join(", ")||"-"]})]})})]})]})}),Xe=At;import{Fragment as Mt,jsx as ee,jsxs as Ne}from"react/jsx-runtime";var Ut=()=>{let e=globalThis?.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`},zt=({policies:e,onChange:o,availableFields:r,errors:t,isSubmitting:c=!1})=>{let{t:a}=Ot(),n=_t({}),f=new Set((e||[]).map(i=>i.action).filter(Boolean)),l=Mo.filter(i=>!f.has(i)),y=l.length>0,p=()=>{let i=l[0]||"create",u={id:Ut(),action:i};i==="delete"?u.permission="deny":u.fields={allow:[],owner_allow:[],deny:r};let T=[...e||[],u];o(T),setTimeout(()=>{let E=T.length-1,m=n.current[E];m&&m.scrollIntoView({behavior:"smooth",block:"center"})},100)},g=i=>{let u=[...e];u.splice(i,1),o(u)},d=(()=>{if(!t)return null;if(typeof t=="string")return t;let i=t._error;return typeof i=="string"?i:null})(),s=new Set((e||[]).map(i=>i.action));return Ne(Mt,{children:[ee(Dt,{sx:{borderColor:"#e0e4e7"}}),Ne(Oe,{children:[ee(Oe,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3,children:Ne(Oe,{children:[ee(qo,{variant:"h6",sx:{fontWeight:600,color:"#111418",mb:1},children:a("modules.form.publicPolicies.title")}),ee(qo,{variant:"body2",color:"text.secondary",sx:{fontSize:"0.875rem"},children:a("modules.form.publicPolicies.description")})]})}),d&&ee(Ho,{severity:"error",sx:{mb:3},children:d}),Ne(Ft,{spacing:3,children:[(e||[]).length===0?ee(Ho,{severity:"info",children:a("modules.form.publicPolicies.noPolicies")}):e.map((i,u)=>ee(Xe,{ref:T=>{n.current[u]=T},policy:i,onChange:T=>{let E=[...e];E[u]=T,o(E)},onRemove:()=>g(u),availableFields:r,isSubmitting:c,usedActions:s,error:typeof t=="object"&&t&&i.id in t?t[i.id]:void 0},i.id)),y&&ee(Oe,{children:ee(Nt,{type:"button",variant:"outlined",startIcon:ee(Bt,{}),onClick:p,disabled:c,sx:{borderColor:"#d0d7de",color:"#656d76","&:hover":{borderColor:"#8c959f",backgroundColor:"transparent"}},children:a("modules.form.publicPolicies.addPolicy")})})]})]})]})},Hs=zt;import{useState as Ze}from"react";import{Button as Fe,TextField as Ko,Box as fe,Alert as Te,Typography as ie,CircularProgress as eo}from"@mui/material";import{jsx as A,jsxs as re}from"react/jsx-runtime";function Xs(){let[e,o]=Ze(""),[r,t]=Ze(""),[c,a]=Ze(!1),{isAuthenticated:n,isLoading:f,error:l,login:y,logout:p,refreshTokens:g,clearError:d,isExpiringSoon:s,expiresIn:i}=te(),u=async m=>{if(m.preventDefault(),!e||!r)return;(await y(e,r)).success&&(o(""),t(""),a(!1))},T=async()=>{await p()},E=async()=>{await g()};return n?re(fe,{sx:{maxWidth:600,mx:"auto",p:3},children:[A(ie,{variant:"h4",gutterBottom:!0,children:"Welcome! \u{1F389}"}),A(Te,{severity:"success",sx:{mb:3},children:"You are successfully logged in with Refresh Token Pattern enabled"}),re(fe,{sx:{mb:3,p:2,bgcolor:"background.paper",border:1,borderColor:"divider",borderRadius:1},children:[A(ie,{variant:"h6",gutterBottom:!0,children:"Token Status"}),re(ie,{variant:"body2",color:"text.secondary",children:["Access Token expires in: ",Math.round(i/1e3/60)," minutes"]}),s&&A(Te,{severity:"warning",sx:{mt:1},children:"Token expires soon - automatic refresh will happen"})]}),re(fe,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[A(Fe,{variant:"contained",onClick:E,disabled:f,startIcon:f?A(eo,{size:16}):null,children:"Refresh Tokens"}),A(Fe,{variant:"outlined",color:"error",onClick:T,disabled:f,children:"Logout"})]}),l&&A(Te,{severity:"error",sx:{mt:2},onClose:d,children:l})]}):re(fe,{sx:{maxWidth:400,mx:"auto",p:3},children:[A(ie,{variant:"h4",gutterBottom:!0,align:"center",children:"Login with Refresh Tokens"}),A(Te,{severity:"info",sx:{mb:3},children:"This demo shows the new Refresh Token Pattern with automatic session management"}),c?re("form",{onSubmit:u,children:[A(Ko,{fullWidth:!0,label:"Email",type:"email",value:e,onChange:m=>o(m.target.value),margin:"normal",required:!0,autoComplete:"email"}),A(Ko,{fullWidth:!0,label:"Password",type:"password",value:r,onChange:m=>t(m.target.value),margin:"normal",required:!0,autoComplete:"current-password"}),A(Fe,{type:"submit",fullWidth:!0,variant:"contained",size:"large",disabled:f,startIcon:f?A(eo,{size:16}):null,sx:{mt:3,mb:2},children:f?"Logging in...":"Login"})]}):A(Fe,{fullWidth:!0,variant:"contained",size:"large",onClick:()=>a(!0),sx:{mt:2},children:"Show Login Form"}),l&&A(Te,{severity:"error",sx:{mt:2},onClose:d,children:l})]})}function Zs(){let{isAuthenticated:e,isLoading:o,isExpiringSoon:r,expiresIn:t}=te();return o?re(fe,{sx:{display:"flex",alignItems:"center",gap:1},children:[A(eo,{size:16}),A(ie,{variant:"caption",children:"Loading session..."})]}):e?re(fe,{children:[A(ie,{variant:"caption",color:"success.main",children:"\u2713 Authenticated"}),r&&re(ie,{variant:"caption",color:"warning.main",display:"block",children:["\u26A0 Token expires in ",Math.round(t/1e3/60)," min"]})]}):A(ie,{variant:"caption",color:"text.secondary",children:"Not logged in"})}export{oe as a,Vt as b,Wt as c,De as d,Be as e,Qt as f,go as g,is as h,it as i,zo as j,Mo as k,Hs as l,Xs as m,Zs as n};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk6RWBJJWLjs = require('./chunk-6RWBJJWL.js');var _chunkYIIUEOXCjs = require('./chunk-YIIUEOXC.js');var _chunkAT74WV5Wjs = require('./chunk-AT74WV5W.js');var oe={es:{"checkCode.codeLabel":"C\xF3digo de Verificaci\xF3n","checkCode.codePlaceholder":"Ingresa el c\xF3digo de 6 d\xEDgitos","checkCode.codeRequired":"El c\xF3digo es obligatorio","checkCode.emailLabel":"Correo Electr\xF3nico","checkCode.emailPlaceholder":"Ingresa tu correo electr\xF3nico","checkCode.emailRequired":"El correo electr\xF3nico es obligatorio","checkCode.instructions":"Ingresa el c\xF3digo de 6 d\xEDgitos que enviamos a tu correo electr\xF3nico.","checkCode.invalidEmail":"Ingresa un correo electr\xF3nico v\xE1lido","checkCode.resendCodeLink":"Reenviar c\xF3digo","checkCode.title":"Verificar C\xF3digo","checkCode.verifyButton":"Verificar C\xF3digo","common.back":"Volver","common.backToLogin":"Volver","error.app.config":"Error de Configuraci\xF3n: {{message}}","error.app.initialization":"Error durante la inicializaci\xF3n final de la aplicaci\xF3n.","error.transaction":"Error en la operaci\xF3n","error.unknown":"Ocurri\xF3 un error desconocido.","errors.DUPLICATE":"El campo <b>{{field}}</b> debe ser \xFAnico.","errors.FOREIGN_KEY_NOT_FOUND":"El campo <b>{{field}}</b> debe referenciar un \xEDtem existente.","errors.INVALID_EMAIL":"El campo <b>{{field}}</b> debe ser un correo electr\xF3nico v\xE1lido.","errors.INVALID_OBJECT_ID":"El campo <b>{{field}}</b> debe ser un valor v\xE1lido.","errors.IN_USE":"El \xEDtem est\xE1 en uso y no puede ser eliminado.","errors.MAX_LENGTH":"El campo <b>{{field}}</b> no debe exceder los <b>{{length}}</b> caracteres.","errors.MIN_LENGTH":"El campo <b>{{field}}</b> debe tener al menos <b>{{length}}</b> caracteres.","errors.MUST_NOT_BE_EMAIL":"El campo <b>{{field}}</b> no debe ser un correo electr\xF3nico.","errors.NO_PERMISSION":"No tienes permiso para realizar esta acci\xF3n.","errors.NO_SPACES":"El campo <b>{{field}}</b> no debe contener espacios.","errors.ONE_OR_MORE_OPERATIONS_FAILED":"Error en la operaci\xF3n","errors.REQUIRED":"El campo <b>{{field}}</b> es obligatorio.","errors.TOKEN_HAS_EXPIRED":"La sesi\xF3n ha expirado. Por favor, inicia sesi\xF3n nuevamente.","errors.TOO_MANY_REQUESTS":"L\xEDmite de solicitudes alcanzado. Por favor intenta m\xE1s tarde.","errors.UNAUTHORIZED":"No est\xE1s autorizado para realizar esta acci\xF3n.","errors.all_password_fields_required":"Todos los campos de contrase\xF1a son obligatorios","errors.auth.INVALID_API_KEY":"Clave de API inv\xE1lida","errors.auth.INVALID_CREDENTIALS":"Usuario y/o contrase\xF1a incorrectos","errors.auth.NO_PERMISSION":"No tienes permisos suficientes","errors.auth.SESSION_EXPIRED":"Tu sesi\xF3n ha expirado. Por favor, inicia sesi\xF3n nuevamente.","errors.auth.TOO_MANY_REQUESTS":"Demasiados intentos. Por favor espera 15 minutos e intenta nuevamente","errors.auth.UNAUTHORIZED":"No tienes permisos para realizar esta acci\xF3n","errors.auth.USER_NOT_ACTIVE":"Usuario no activo","errors.auth.USER_NOT_FOUND":"Usuario no encontrado","errors.data.BAD_REQUEST":"Solicitud inv\xE1lida","errors.data.FIELD_ERROR":"Error en los datos ingresados","errors.data.IN_USE":"El elemento est\xE1 en uso y no puede ser eliminado","errors.data.ITEM_NOT_FOUND":"El elemento solicitado no fue encontrado","errors.data.NOT_FOUND":"No se encontr\xF3 lo solicitado","errors.internal_error_changing_password":"Error interno al cambiar la contrase\xF1a. Intenta nuevamente","errors.password_min_length":"La contrase\xF1a debe tener al menos 8 caracteres","errors.password_mismatch":"Las contrase\xF1as no coinciden","errors.password_must_be_different":"La nueva contrase\xF1a debe ser diferente a la actual","errors.system.DATABASE_CONNECTION_ERROR":"Error de conexi\xF3n. Verifica tu conexi\xF3n a internet.","errors.system.INTERNAL_SERVER_ERROR":"Error interno del servidor. Intenta nuevamente.","errors.system.INVALID_CONFIGURATION":"Error de configuraci\xF3n del sistema","errors.system.TOO_MANY_REQUESTS":"Demasiadas solicitudes. Por favor espera un momento e intenta nuevamente","errors.system.UNKNOWN_OPERATION":"Operaci\xF3n no reconocida","errors.users_module_not_configured":"M\xF3dulo de usuarios no configurado","footer.copyright":"Nocios S.R.L. Todos los derechos reservados.","footer.version":"Versi\xF3n","forgotPassword.checkEmailInstructions":"Revisa tu bandeja de entrada para el c\xF3digo de verificaci\xF3n","forgotPassword.codeAlreadyExistsMessage":"Ya se envi\xF3 un c\xF3digo y a\xFAn es v\xE1lido","forgotPassword.emailLabel":"Correo Electr\xF3nico","forgotPassword.emailPlaceholder":"Ingresa tu correo electr\xF3nico","forgotPassword.emailRequired":"El correo electr\xF3nico es obligatorio","forgotPassword.emailSentMessage":"C\xF3digo enviado exitosamente","forgotPassword.enterCodeLink":"Ingresar C\xF3digo","forgotPassword.instructions":"Ingresa tu correo electr\xF3nico y te enviaremos un c\xF3digo para restablecer tu contrase\xF1a.","forgotPassword.invalidEmail":"Ingresa un correo electr\xF3nico v\xE1lido","forgotPassword.sendCodeButton":"Enviar C\xF3digo","forgotPassword.title":"Recuperar Contrase\xF1a","loading.app.configInitial":"Cargando configuraci\xF3n inicial...","loading.app.generic":"Cargando...","loading.app.starting":"Iniciando aplicaci\xF3n...","loading.app.themeSetup":"Generando tema...","loading.app.validatingSession":"Validando sesi\xF3n...","login.alreadyHaveCodeLink":"\xBFYa tienes un c\xF3digo?","login.forgotPasswordLink":"\xBFOlvidaste tu contrase\xF1a?","login.initializationError":"Error de inicializaci\xF3n","login.initializing":"Inicializando...","login.loginButton":"Iniciar Sesi\xF3n","login.logoAlt":"Logotipo","login.noAccountPrompt":"\xBFNo tienes una cuenta?","login.notInitialized":"Sistema no inicializado","login.passwordLabel":"Contrase\xF1a","login.passwordPlaceholder":"Ingresa tu contrase\xF1a","login.passwordRequired":"Contrase\xF1a es obligatoria","login.signUpLink":"Reg\xEDstrate","login.usernameOrEmailLabel":"Usuario o Correo Electr\xF3nico","login.usernameOrEmailPlaceholder":"Ingresa tu usuario o correo electr\xF3nico","login.usernameRequired":"Usuario o correo electr\xF3nico es obligatorio","resetPassword.codeExpiredOrInvalid":"El c\xF3digo ha expirado o es inv\xE1lido","resetPassword.confirmPasswordLabel":"Confirmar Contrase\xF1a","resetPassword.confirmPasswordPlaceholder":"Confirma tu nueva contrase\xF1a","resetPassword.confirmPasswordRequired":"Confirma tu contrase\xF1a","resetPassword.goToLoginButton":"Ir al Login","resetPassword.instructions":"Ingresa tu nueva contrase\xF1a.","resetPassword.invalidCode":"El c\xF3digo de verificaci\xF3n es inv\xE1lido. Por favor, verifica el enlace o solicita uno nuevo.","resetPassword.missingParameters":"Faltan par\xE1metros obligatorios","resetPassword.newPasswordLabel":"Nueva Contrase\xF1a","resetPassword.newPasswordPlaceholder":"Ingresa tu nueva contrase\xF1a","resetPassword.newPasswordRequired":"La nueva contrase\xF1a es obligatoria","resetPassword.passwordTooShort":"La contrase\xF1a debe tener al menos 8 caracteres","resetPassword.passwordsDoNotMatch":"Las contrase\xF1as no coinciden","resetPassword.requestNewCodeButton":"Solicitar Nuevo C\xF3digo","resetPassword.resetPasswordButton":"Restablecer Contrase\xF1a","resetPassword.successInstructions":"Ahora puedes iniciar sesi\xF3n con tu nueva contrase\xF1a","resetPassword.successMessage":"Contrase\xF1a restablecida exitosamente","resetPassword.title":"Nueva Contrase\xF1a","resetPassword.validatingCode":"Validando c\xF3digo..."},en:{"checkCode.codeLabel":"Verification Code","checkCode.codePlaceholder":"Enter 6-digit code","checkCode.codeRequired":"Code is required","checkCode.emailLabel":"Email Address","checkCode.emailPlaceholder":"Enter your email address","checkCode.emailRequired":"Email address is required","checkCode.instructions":"Enter the 6-digit code we sent to your email address.","checkCode.invalidEmail":"Enter a valid email address","checkCode.resendCodeLink":"Resend code","checkCode.title":"Verify Code","checkCode.verifyButton":"Verify Code","common.back":"Back","common.backToLogin":"Back to Login","error.app.config":"Configuration Error: {{message}}","error.app.initialization":"Error during final application initialization.","error.transaction":"Operation error","error.unknown":"An unknown error occurred.","errors.DUPLICATE":"The field <b>{{field}}</b> must be unique.","errors.FOREIGN_KEY_NOT_FOUND":"The field <b>{{field}}</b> must reference an existing item.","errors.INVALID_EMAIL":"The field <b>{{field}}</b> must be a valid email address.","errors.INVALID_OBJECT_ID":"The field <b>{{field}}</b> must be a valid value.","errors.IN_USE":"The item is currently in use and cannot be deleted.","errors.MAX_LENGTH":"The field <b>{{field}}</b> must not exceed <b>{{maxLength}}</b> characters.","errors.MIN_LENGTH":"The field <b>{{field}}</b> must have at least <b>{{minLength}}</b> characters.","errors.MUST_NOT_BE_EMAIL":"The field <b>{{field}}</b> must not be an email address.","errors.NO_PERMISSION":"You do not have permission to perform this action.","errors.NO_SPACES":"The field <b>{{field}}</b> must not contain spaces.","errors.ONE_OR_MORE_OPERATIONS_FAILED":"Operation error","errors.REQUIRED":"The field <b>{{field}}</b> is required.","errors.TOKEN_HAS_EXPIRED":"Your session has expired, please log in again.","errors.TOO_MANY_REQUESTS":"Request limit reached. Please try again later.","errors.UNAUTHORIZED":"You are not authorized to perform this action.","errors.all_password_fields_required":"All password fields are required","errors.auth.INVALID_API_KEY":"Invalid API key","errors.auth.INVALID_CREDENTIALS":"Incorrect username and/or password","errors.auth.NO_PERMISSION":"Insufficient permissions","errors.auth.SESSION_EXPIRED":"Your session has expired. Please log in again.","errors.auth.TOO_MANY_REQUESTS":"Too many attempts. Please wait 15 minutes and try again","errors.auth.UNAUTHORIZED":"You don't have permission to perform this action","errors.auth.USER_NOT_ACTIVE":"User account is not active","errors.auth.USER_NOT_FOUND":"User not found","errors.data.BAD_REQUEST":"Invalid request","errors.data.FIELD_ERROR":"Error in the provided data","errors.data.IN_USE":"The item is in use and cannot be deleted","errors.data.ITEM_NOT_FOUND":"The requested item was not found","errors.data.NOT_FOUND":"The requested resource was not found","errors.internal_error_changing_password":"Internal error changing password. Please try again","errors.password_min_length":"Password must be at least 8 characters","errors.password_mismatch":"Passwords do not match","errors.password_must_be_different":"New password must be different from current password","errors.system.DATABASE_CONNECTION_ERROR":"Connection error. Please check your internet connection.","errors.system.INTERNAL_SERVER_ERROR":"Internal server error. Please try again.","errors.system.INVALID_CONFIGURATION":"System configuration error","errors.system.TOO_MANY_REQUESTS":"Too many requests. Please wait a moment and try again","errors.system.UNKNOWN_OPERATION":"Unrecognized operation","errors.users_module_not_configured":"Users module not configured","footer.copyright":"Nocios S.R.L. All Rights Reserved.","footer.version":"Version","forgotPassword.checkEmailInstructions":"Check your inbox for the verification code","forgotPassword.codeAlreadyExistsMessage":"A code was already sent and is still valid","forgotPassword.emailLabel":"Email Address","forgotPassword.emailPlaceholder":"Enter your email address","forgotPassword.emailRequired":"Email address is required","forgotPassword.emailSentMessage":"Code sent successfully","forgotPassword.enterCodeLink":"Enter Code","forgotPassword.instructions":"Enter your email address and we'll send you a code to reset your password.","forgotPassword.invalidEmail":"Enter a valid email address","forgotPassword.sendCodeButton":"Send Code","forgotPassword.title":"Reset Password","loading.app.configInitial":"Loading initial configuration...","loading.app.generic":"Loading...","loading.app.starting":"Starting application...","loading.app.themeSetup":"Generating theme...","loading.app.validatingSession":"Validating session...","login.alreadyHaveCodeLink":"Already have a code?","login.forgotPasswordLink":"Forgot Password?","login.initializationError":"Initialization error","login.initializing":"Initializing...","login.loginButton":"Log In","login.logoAlt":"Logo","login.noAccountPrompt":"Don't have an account?","login.notInitialized":"System not initialized","login.passwordLabel":"Password","login.passwordPlaceholder":"Enter your password","login.passwordRequired":"Password is required","login.signUpLink":"Sign up","login.usernameOrEmailLabel":"Username or Email","login.usernameOrEmailPlaceholder":"Enter your username or email","login.usernameRequired":"Username or email is required","resetPassword.codeExpiredOrInvalid":"Code expired or invalid","resetPassword.confirmPasswordLabel":"Confirm Password","resetPassword.confirmPasswordPlaceholder":"Confirm your new password","resetPassword.confirmPasswordRequired":"Confirm your password","resetPassword.goToLoginButton":"Go to Login","resetPassword.instructions":"Enter your new password.","resetPassword.invalidCode":"The verification code is invalid. Please check the link or request a new one.","resetPassword.missingParameters":"Missing required parameters","resetPassword.newPasswordLabel":"New Password","resetPassword.newPasswordPlaceholder":"Enter your new password","resetPassword.newPasswordRequired":"New password is required","resetPassword.passwordTooShort":"Password must be at least 8 characters","resetPassword.passwordsDoNotMatch":"Passwords do not match","resetPassword.requestNewCodeButton":"Request New Code","resetPassword.resetPasswordButton":"Reset Password","resetPassword.successInstructions":"You can now log in with your new password","resetPassword.successMessage":"Password reset successfully","resetPassword.title":"New Password","resetPassword.validatingCode":"Validating code..."}},Vt= exports.b =()=>Object.keys(oe),Wt= exports.c =e=>oe[e]||oe.es;var _crudifybrowser = require('@nocios/crudify-browser'); var _crudifybrowser2 = _interopRequireDefault(_crudifybrowser);var ao="crudify_translations_",Jo=3600*1e3;function io(e){let o=0;for(let r=0;r<e.length;r++){let t=e.charCodeAt(r);o=(o<<5)-o+t,o=o&o}return Math.abs(o).toString(36)}var De=class e{constructor(){this.enableDebug=!1;this.initializationPromise=null;this.isInitialized=!1}static getInstance(){return e.instance||(e.instance=new e),e.instance}setDebug(o){this.enableDebug=o}async ensureCrudifyInitialized(o,r){if(!this.isInitialized)return this.initializationPromise?(this.enableDebug&&console.log("[TranslationService] Waiting for crudify initialization..."),this.initializationPromise):(this.enableDebug&&console.log("[TranslationService] Initializing crudify SDK..."),this.initializationPromise=(async()=>{try{let t=_crudifybrowser2.default.getTokenData();if(t&&t.endpoint){this.enableDebug&&console.log("[TranslationService] Crudify already initialized"),this.isInitialized=!0;return}_crudifybrowser2.default.config(r);let c=await _crudifybrowser2.default.init(o,this.enableDebug?"debug":"none");if(c.success===!1)throw new Error(`Failed to initialize crudify: ${JSON.stringify(c.errors||"Unknown error")}`);this.isInitialized=!0,this.enableDebug&&console.log("[TranslationService] Crudify SDK initialized successfully")}catch(t){throw console.error("[TranslationService] Failed to initialize crudify:",t),this.initializationPromise=null,t}})(),this.initializationPromise)}async fetchTranslations(o){let{apiKey:r,sections:t,crudifyEnv:c="stg",urlTranslations:a}=o;console.log("[TranslationService] \u{1F4E5} fetchTranslations called with:",{apiKeyHash:io(r),crudifyEnv:c,sections:t,hasUrlTranslations:!!a,urlTranslationsKeys:a?Object.keys(a).length:0});let n=this.getFromCache(r),f=n?this.isCacheExpired(n):!0;if(console.log("[TranslationService] \u{1F4BE} Cache check:",{hasCached:!!n,isCacheExpired:f}),n&&!f){console.log("[TranslationService] \u2705 Using cached translations");let l=this.mergeWithUrlTranslations(n.data.translations,a);return console.log("[TranslationService] \u{1F504} Merged result (from cache):",{languages:Object.keys(l),sampleLang:Object.keys(l)[0],keysInSampleLang:l[Object.keys(l)[0]]?Object.keys(l[Object.keys(l)[0]]).length:0}),l}try{await this.ensureCrudifyInitialized(r,c)}catch(l){return console.error("[TranslationService] \u274C Failed to initialize crudify:",l),n?(console.warn("[TranslationService] \u26A0\uFE0F Using expired cache (init failed)"),this.mergeWithUrlTranslations(n.data.translations,a)):(console.warn("[TranslationService] \u26A0\uFE0F Using critical bundle (init failed)"),this.getCriticalTranslationsOnly())}try{console.log("[TranslationService] \u{1F310} Fetching from API via crudify SDK...");let l=await this.fetchFromAPI(t);console.log("[TranslationService] \u{1F4E6} API response received:",{languages:l.languages,translationsKeys:Object.keys(l.translations),timestamp:l.timestamp});let y=Object.keys(l.translations)[0];y&&console.log(`[TranslationService] \u{1F4CB} API translations sample (${y}):`,{totalKeys:Object.keys(l.translations[y]).length,firstFiveKeys:Object.keys(l.translations[y]).slice(0,5)}),this.hasDataChanged(n,l)||!n?(console.log("[TranslationService] \u{1F4BE} Data changed, updating cache"),this.saveToCache(r,l)):(console.log("[TranslationService] \u{1F4BE} Data unchanged, refreshing cache timestamp"),this.refreshCacheTimestamp(r));let g=this.mergeWithUrlTranslations(l.translations,a);return console.log("[TranslationService] \u{1F504} Final merged result:",{languages:Object.keys(g),sampleLang:Object.keys(g)[0],keysInSampleLang:g[Object.keys(g)[0]]?Object.keys(g[Object.keys(g)[0]]).length:0}),g}catch(l){return console.error("[TranslationService] \u274C API fetch failed:",l),n?(console.warn("[TranslationService] \u26A0\uFE0F Using expired cache as fallback"),this.mergeWithUrlTranslations(n.data.translations,a)):(console.warn("[TranslationService] \u26A0\uFE0F Using critical bundle translations"),this.getCriticalTranslationsOnly())}}async fetchFromAPI(o){let r=await _crudifybrowser2.default.getTranslation(o);if(!r.success)throw new Error(`Crudify API error: ${r.errors?JSON.stringify(r.errors):"Unknown error"}`);if(!r.data)throw new Error("No translation data in response");return r.data}mergeWithUrlTranslations(o,r){if(!r||Object.keys(r).length===0)return o;let t={};return Object.keys(o).forEach(c=>{t[c]={...o[c],...r}}),t}hasDataChanged(o,r){if(!o||o.data.timestamp!==r.timestamp)return!0;let t=this.hashData(r.translations);return o.dataHash!==t}hashData(o){let r=JSON.stringify(o),t=0;for(let c=0;c<r.length;c++){let a=r.charCodeAt(c);t=(t<<5)-t+a,t=t&t}return t.toString(36)}saveToCache(o,r){try{let t=this.getCacheKey(o),c={data:r,cachedAt:Date.now(),dataHash:this.hashData(r.translations)};localStorage.setItem(t,JSON.stringify(c)),this.enableDebug&&console.log("[TranslationService] Saved to cache:",t)}catch(t){console.error("[TranslationService] Failed to save cache:",t)}}getFromCache(o){try{let r=this.getCacheKey(o),t=localStorage.getItem(r);return t?JSON.parse(t):null}catch(r){return console.error("[TranslationService] Failed to read cache:",r),null}}refreshCacheTimestamp(o){try{let r=this.getFromCache(o);if(r){r.cachedAt=Date.now();let t=this.getCacheKey(o);localStorage.setItem(t,JSON.stringify(r))}}catch(r){console.error("[TranslationService] Failed to refresh cache timestamp:",r)}}isCacheExpired(o){return Date.now()-o.cachedAt>Jo}getCacheKey(o){return`${ao}${io(o)}`}getCriticalTranslationsOnly(){return oe}invalidateCache(o){let r=this.getCacheKey(o);localStorage.removeItem(r),this.enableDebug&&console.log("[TranslationService] Cache invalidated:",r)}async prefetchTranslations(o){try{await this.fetchTranslations(o),this.enableDebug&&console.log("[TranslationService] Prefetch completed")}catch(r){console.error("[TranslationService] Prefetch failed:",r)}}clearAllCaches(){try{let r=Object.keys(localStorage).filter(t=>t.startsWith(ao));r.forEach(t=>localStorage.removeItem(t)),this.enableDebug&&console.log(`[TranslationService] Cleared ${r.length} cache entries`)}catch(o){console.error("[TranslationService] Failed to clear caches:",o)}}},Be= exports.e =De.getInstance();var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var uo=_react.createContext.call(void 0, null);function lo(e,o,r){return{...e,...o,...r||{}}}function or(e,o,r,t,c){_react.useEffect.call(void 0, ()=>{if(!t||!e||!o)return;let a=r||typeof window<"u"&&window.i18next||typeof window<"u"&&window.i18n;if(!a||!a.addResourceBundle){c&&console.log("[TranslationsProvider] i18next not found, skipping auto-sync");return}c&&console.log("[TranslationsProvider] Auto-syncing translations with i18next",{languages:Object.keys(e),currentLanguage:o}),Object.keys(e).forEach(n=>{e[n]&&Object.keys(e[n]).length>0&&(a.addResourceBundle(n,"translation",e[n],!0,!0),c&&console.log(`[TranslationsProvider] Synced ${Object.keys(e[n]).length} keys for language: ${n}`))}),a.language!==o&&(a.changeLanguage(o),c&&console.log(`[TranslationsProvider] Changed i18next language to: ${o}`))},[e,o,r,t,c])}var Qt=({children:e,apiKey:o,crudifyEnv:r="stg",sections:t,language:c="es",devTranslations:a,translationUrl:n,enableDebug:f=!1,skipAutoInit:l=!0,autoSyncI18n:y=!0,i18nInstance:p})=>{let[g,d]=_react.useState.call(void 0, {}),[s,i]=_react.useState.call(void 0, !0),[u,T]=_react.useState.call(void 0, null),[E,m]=_react.useState.call(void 0, void 0),[w,x]=_react.useState.call(void 0, !1),C=_react.useCallback.call(void 0, async()=>{if(w){f&&console.log("[TranslationsProvider] Skipping reload - using fallback translations");return}i(!0),T(null);let P;if(n)try{f&&console.log(`[TranslationsProvider] Fetching translations from URL: ${n}`);let R=await fetch(n);if(!R.ok)throw new Error(`Failed to fetch translations: ${R.statusText}`);P=await R.json(),m(P),f&&console.log("[TranslationsProvider] URL translations loaded:",{keysCount:P?Object.keys(P).length:0})}catch(R){console.error("[TranslationsProvider] Failed to load URL translations:",R),P=void 0,m(void 0)}try{Be.setDebug(f);let R=await Be.fetchTranslations({apiKey:o,crudifyEnv:r,sections:t,urlTranslations:P}),U={};Object.keys(R).forEach(I=>{let K=oe[I]||{},Q=R[I]||{};U[I]=lo(K,Q,a)}),d(U),f&&console.log("[TranslationsProvider] Loaded translations:",{languages:Object.keys(U),keysCount:Object.keys(U[c]||{}).length})}catch(R){console.error("[TranslationsProvider] Failed to load:",R),T(R.message),x(!0);let U={};Object.keys(oe).forEach(I=>{let K=oe[I],Q=P||E||{};U[I]=lo(K,Q,a)}),d(U),f&&console.log("[TranslationsProvider] Using fallback translations (critical + URL)")}finally{i(!1)}},[o,r,t,n,a,f,c,w]);_react.useEffect.call(void 0, ()=>{C();let P=setInterval(C,3600*1e3);return()=>clearInterval(P)},[C]);let S=_react.useMemo.call(void 0, ()=>(P,R)=>{let I=(g[c]||{})[P];if(!I){let K=Object.keys(g);for(let Q of K)if(g[Q][P]){I=g[Q][P];break}}return I||(f&&console.warn(`[TranslationsProvider] Missing translation: "${P}"`),I=P),R&&typeof I=="string"&&Object.entries(R).forEach(([K,Q])=>{let Ee=new RegExp(`{{${K}}}`,"g");I=I.replace(Ee,String(Q))}),I},[g,c,f]);or(g,c,p,y,f);let h={t:S,language:c,availableLanguages:Object.keys(g),translations:g,isLoading:s,error:u,refreshTranslations:C};return _jsxruntime.jsx.call(void 0, uo.Provider,{value:h,children:e})},go= exports.g =()=>{let e=_react.useContext.call(void 0, uo);if(!e)throw new Error("useTranslations must be used within TranslationsProvider");return e};var _material = require('@mui/material');var mo=(e,o)=>{let[r,t]=_react.useState.call(void 0, {}),[c,a]=_react.useState.call(void 0, !1),[n,f]=_react.useState.call(void 0, null);return _react.useEffect.call(void 0, ()=>{if(console.log("\u{1F527} [I18nProvider] Hybrid translation loading:",{hasProvidedTranslations:!!o&&Object.keys(o).length>0,hasUrl:!!e,providedKeys:o?Object.keys(o).length:0}),o&&Object.keys(o).length>0){console.log("\u2705 [I18nProvider] Using provided translations (highest priority)"),t(o),a(!1),f(null);return}if(!e){console.log("\u26A0\uFE0F [I18nProvider] No translations provided, using empty object (keys will show as-is)"),t({}),a(!1),f(null);return}console.log("\u{1F310} [I18nProvider] Loading translations from URL:",e);let l=!1;return a(!0),f(null),fetch(e).then(y=>{if(!y.ok)throw new Error(`Failed to load translations: ${y.status}`);return y.json()}).then(y=>{l||(console.log("\u2705 [I18nProvider] Translations loaded successfully from URL:",{url:e,keysLoaded:Object.keys(y).length}),t(y),a(!1))}).catch(y=>{l||(console.error("\u274C [I18nProvider] Failed to load translations from URL:",e,y),f(y.message),console.log("\u{1F504} [I18nProvider] Falling back to empty translations (keys will show as-is)"),t({}),a(!1))}),()=>{l=!0}},[e,o]),{translations:r,loading:c,error:n}};var po=_react.createContext.call(void 0, null),ar=()=>{try{return go()}catch (e2){return null}},ir=(e,o)=>e&&e[o]?e[o]:o.split(".").reduce((r,t)=>r&&typeof r=="object"?r[t]:void 0,e),yo=({children:e,translations:o,translationsUrl:r,language:t="en"})=>{let a=_optionalChain([ar, 'call', _2 => _2(), 'optionalAccess', _3 => _3.translations, 'optionalAccess', _4 => _4[t]])||{},{translations:n,loading:f}=mo(r,o),l=_react.useMemo.call(void 0, ()=>({...a,...n,...o||{}}),[a,n,o]),y=_react.useMemo.call(void 0, ()=>(g,d)=>{let s=ir(l,g);return s==null&&(console.log(`\u{1F50D} [I18nProvider] Translation not found for key: "${g}" - showing key as-is`),s=g),d&&typeof s=="string"&&Object.entries(d).forEach(([i,u])=>{s=s.replace(new RegExp(`{{${i}}}`,"g"),u)}),typeof s=="string"?s:g},[l]),p=_react.useMemo.call(void 0, ()=>({t:y,language:t}),[y,t]);return f?_jsxruntime.jsx.call(void 0, "div",{children:"Loading translations..."}):_jsxruntime.jsx.call(void 0, po.Provider,{value:p,children:e})},q=()=>{let e=_react.useContext.call(void 0, po);if(!e)throw new Error("useTranslation must be used within I18nProvider");return e};var wo={currentScreen:"login",searchParams:{},formData:{username:"",password:"",email:"",code:"",newPassword:"",confirmPassword:""},loading:!1,errors:{global:[]},emailSent:!1,codeAlreadyExists:!1,codeValidated:!1,fromCodeVerification:!1,config:{}};function ur(e,o){switch(o.type){case"SET_SCREEN":let r={...e,currentScreen:o.payload.screen,searchParams:o.payload.params||e.searchParams,errors:{global:[]}},t=new URLSearchParams(r.searchParams),c=t.toString()?`?${t.toString()}`:window.location.pathname;try{window.history.replaceState({},"",c)}catch (e3){}return r;case"SET_SEARCH_PARAMS":return{...e,searchParams:o.payload};case"UPDATE_FORM_DATA":return{...e,formData:{...e.formData,...o.payload},errors:{...e.errors,...Object.keys(o.payload).reduce((a,n)=>({...a,[n]:void 0}),{})}};case"SET_LOADING":return{...e,loading:o.payload};case"SET_ERRORS":return{...e,errors:{...e.errors,...o.payload}};case"CLEAR_ERRORS":return{...e,errors:{global:[]}};case"SET_EMAIL_SENT":return{...e,emailSent:o.payload};case"SET_CODE_ALREADY_EXISTS":return{...e,codeAlreadyExists:o.payload};case"SET_CODE_VALIDATED":return{...e,codeValidated:o.payload};case"SET_FROM_CODE_VERIFICATION":return{...e,fromCodeVerification:o.payload};case"RESET_FORM":return{...e,formData:wo.formData,errors:{global:[]},loading:!1,emailSent:!1,codeAlreadyExists:!1,codeValidated:!1,fromCodeVerification:!1};case"INIT_CONFIG":return{...e,config:o.payload};default:return e}}var bo=_react.createContext.call(void 0, void 0),Po=({children:e,initialScreen:o="login",config:r,autoReadFromCookies:t=!0})=>{let[c,a]=_react.useReducer.call(void 0, ur,{...wo,currentScreen:o});_react.useEffect.call(void 0, ()=>{a({type:"INIT_CONFIG",payload:(()=>{let s={};if(t)try{let i=_chunkAT74WV5Wjs.a.call(void 0, "logo");if(i){let u=decodeURIComponent(i);u.startsWith("http")&&(s.logo=u)}}catch(i){console.error("Error reading configuration from cookies:",i)}return{publicApiKey:_optionalChain([r, 'optionalAccess', _5 => _5.publicApiKey]),env:_optionalChain([r, 'optionalAccess', _6 => _6.env]),appName:_optionalChain([r, 'optionalAccess', _7 => _7.appName]),logo:_optionalChain([r, 'optionalAccess', _8 => _8.logo])||s.logo,loginActions:_optionalChain([r, 'optionalAccess', _9 => _9.loginActions])}})()})},[r,t]),_react.useEffect.call(void 0, ()=>{let d=new URLSearchParams(window.location.search),s={};d.forEach((i,u)=>{s[u]=i}),Object.keys(s).length>0&&a({type:"SET_SEARCH_PARAMS",payload:s}),o==="checkCode"&&s.email&&a({type:"UPDATE_FORM_DATA",payload:{email:s.email,code:s.code||""}}),o==="resetPassword"&&s.link&&a({type:"SET_SEARCH_PARAMS",payload:s})},[o]);let g={state:c,dispatch:a,setScreen:(d,s)=>{a({type:"SET_SCREEN",payload:{screen:d,params:s}})},updateFormData:d=>{a({type:"UPDATE_FORM_DATA",payload:d})},setFieldError:(d,s)=>{a({type:"SET_ERRORS",payload:{[d]:s}})},clearErrors:()=>{a({type:"CLEAR_ERRORS"})},setLoading:d=>{a({type:"SET_LOADING",payload:d})}};return _jsxruntime.jsx.call(void 0, bo.Provider,{value:g,children:e})},Ie=()=>{let e=_react.useContext.call(void 0, bo);if(e===void 0)throw new Error("useLoginState must be used within a LoginStateProvider");return e};var wr=({onScreenChange:e,onExternalNavigate:o,onLoginSuccess:r,onError:t,redirectUrl:c="/"})=>{let{crudify:a}=_chunk6RWBJJWLjs.c.call(void 0, ),{state:n,updateFormData:f,setFieldError:l,clearErrors:y,setLoading:p}=Ie(),{login:g}=_chunk6RWBJJWLjs.j.call(void 0, ),d=q(),{t:s}=d,i=d.i18n,u=_react.useRef.call(void 0, null),T=_chunkAT74WV5Wjs.e.call(void 0, s,{currentLanguage:_optionalChain([i, 'optionalAccess', _10 => _10.language]),enableDebug:!1}),E=()=>{if(n.searchParams.redirect)try{let h=decodeURIComponent(n.searchParams.redirect);if(h.startsWith("/")&&!h.startsWith("//"))return h}catch (e4){}return c||"/"};_react.useEffect.call(void 0, ()=>{let h=setTimeout(()=>{u.current&&u.current.focus()},100);return()=>clearTimeout(h)},[]);let m=h=>{console.log("\u{1F50D} [LoginForm] Translating parsed error:",h);let P=T.translateError({code:h.code,message:h.message,field:h.field});return console.log("\u{1F50D} [LoginForm] Translation result:",P),P},w=async()=>{if(!n.loading){if(!n.formData.username.trim()){l("username",s("login.usernameRequired"));return}if(!n.formData.password.trim()){l("password",s("login.passwordRequired"));return}y(),p(!0);try{let h=await g(n.formData.username,n.formData.password);if(p(!1),h.success){console.log("\u{1F510} LoginForm - Login successful via SessionProvider, calling onLoginSuccess");let P=E();r&&r(h.data,P)}else{let P=h.rawResponse||h;x(P)}}catch(h){p(!1);let R=_chunkYIIUEOXCjs.g.call(void 0, h).map(m);l("global",R),t&&t(R.join(", "))}}},x=h=>{_chunkYIIUEOXCjs.g.call(void 0, h).forEach(R=>{if(R.field)l(R.field,m(R));else{let U=n.errors.global||[];l("global",[...U,m(R)])}})};return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, _material.Box,{component:"form",noValidate:!0,onSubmit:h=>{h.preventDefault(),w()},onKeyDown:h=>{h.key==="Enter"&&!n.loading&&(h.preventDefault(),w())},sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:1},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",component:"label",htmlFor:"email",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:s("login.usernameOrEmailLabel")}),_jsxruntime.jsx.call(void 0, _material.TextField,{fullWidth:!0,id:"email",name:"email",type:"email",value:n.formData.username,disabled:n.loading,onChange:h=>f({username:h.target.value}),error:!!n.errors.username,helperText:n.errors.username,autoComplete:"email",placeholder:s("login.usernameOrEmailPlaceholder"),inputRef:u,required:!0})]}),_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:1},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",component:"label",htmlFor:"password",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:s("login.passwordLabel")}),_jsxruntime.jsx.call(void 0, _material.TextField,{fullWidth:!0,id:"password",name:"password",type:"password",value:n.formData.password,disabled:n.loading,onChange:h=>f({password:h.target.value}),error:!!n.errors.password,helperText:n.errors.password,autoComplete:"current-password",placeholder:s("login.passwordPlaceholder"),required:!0})]}),_optionalChain([n, 'access', _11 => _11.config, 'access', _12 => _12.loginActions, 'optionalAccess', _13 => _13.includes, 'call', _14 => _14("forgotPassword")])&&_jsxruntime.jsx.call(void 0, _material.Box,{sx:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:_jsxruntime.jsx.call(void 0, _material.Link,{sx:{cursor:"pointer"},onClick:()=>{_optionalChain([e, 'optionalCall', _15 => _15("forgotPassword",n.searchParams)])},variant:"body2",color:"secondary",children:s("login.forgotPasswordLink")})}),_jsxruntime.jsx.call(void 0, _material.Button,{disabled:n.loading,type:"submit",fullWidth:!0,variant:"contained",color:"primary",sx:{mt:1,mb:2},children:n.loading?_jsxruntime.jsx.call(void 0, _material.CircularProgress,{size:20}):s("login.loginButton")})]}),_jsxruntime.jsx.call(void 0, _material.Box,{children:n.errors.global&&n.errors.global.length>0&&n.errors.global.map((h,P)=>_jsxruntime.jsx.call(void 0, _material.Alert,{variant:"filled",sx:{mt:2},severity:"error",children:_jsxruntime.jsx.call(void 0, "div",{children:h})},P))}),_optionalChain([n, 'access', _16 => _16.config, 'access', _17 => _17.loginActions, 'optionalAccess', _18 => _18.includes, 'call', _19 => _19("createUser")])&&_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"body2",align:"center",sx:{color:"text.secondary",mt:3},children:[s("login.noAccountPrompt")," ",_jsxruntime.jsx.call(void 0, _material.Link,{sx:{cursor:"pointer"},onClick:()=>{let P=`/public/users/create${Object.keys(n.searchParams).length>0?`?${new URLSearchParams(n.searchParams).toString()}`:""}`;_optionalChain([o, 'optionalCall', _20 => _20(P)])},fontWeight:"medium",color:"secondary",children:s("login.signUpLink")})]})]})},To=wr;var Tr=({onScreenChange:e,onError:o})=>{let{crudify:r}=_chunk6RWBJJWLjs.c.call(void 0, ),[t,c]=_react.useState.call(void 0, ""),[a,n]=_react.useState.call(void 0, !1),[f,l]=_react.useState.call(void 0, []),[y,p]=_react.useState.call(void 0, null),[g,d]=_react.useState.call(void 0, !1),[s,i]=_react.useState.call(void 0, !1),{t:u}=q(),T=C=>{let S=[`errors.auth.${C.code}`,`errors.data.${C.code}`,`errors.system.${C.code}`,`errors.${C.code}`,`forgotPassword.${C.code.toLowerCase()}`];for(let h of S){let P=u(h);if(P!==h)return P}return C.message||u("error.unknown")},E=C=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(C),m=async()=>{if(!(a||!r)){if(l([]),p(null),!t){p(u("forgotPassword.emailRequired"));return}if(!E(t)){p(u("forgotPassword.invalidEmail"));return}n(!0);try{let C=[{operation:"requestPasswordReset",data:{email:t}}],S=await r.transaction(C);if(S.success)S.data&&S.data.existingCodeValid?i(!0):d(!0);else{let P=_chunkYIIUEOXCjs.g.call(void 0, S).map(T);l(P)}}catch(C){let h=_chunkYIIUEOXCjs.g.call(void 0, C).map(T);l(h),o&&o(h.join(", "))}finally{n(!1)}}},w=()=>{_optionalChain([e, 'optionalCall', _21 => _21("login")])},x=()=>{if(g||s){_optionalChain([e, 'optionalCall', _22 => _22("checkCode",{email:t})]);return}if(!t){p(u("forgotPassword.emailRequired"));return}if(!E(t)){p(u("forgotPassword.invalidEmail"));return}_optionalChain([e, 'optionalCall', _23 => _23("checkCode",{email:t})])};return g||s?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{width:"100%",display:"flex",flexDirection:"column",gap:2,textAlign:"center"},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:2},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:u(s?"forgotPassword.codeAlreadyExistsMessage":"forgotPassword.emailSentMessage")}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",sx:{color:s?"success.main":"grey.600"},children:u("forgotPassword.checkEmailInstructions")})]}),_jsxruntime.jsx.call(void 0, _material.Button,{type:"button",onClick:x,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:u("forgotPassword.enterCodeLink")}),_jsxruntime.jsx.call(void 0, _material.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:_jsxruntime.jsx.call(void 0, _material.Link,{sx:{cursor:"pointer"},onClick:w,variant:"body2",color:"secondary",children:u("common.back")})})]})}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, _material.Box,{component:"form",noValidate:!0,sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:2},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:u("forgotPassword.title")}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",sx:{color:"grey.600"},children:u("forgotPassword.instructions")})]}),_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:1},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",component:"label",htmlFor:"email",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:u("forgotPassword.emailLabel")}),_jsxruntime.jsx.call(void 0, _material.TextField,{fullWidth:!0,id:"email",name:"email",type:"email",value:t,disabled:a,onChange:C=>c(C.target.value),error:!!y,helperText:y,autoComplete:"email",placeholder:u("forgotPassword.emailPlaceholder"),required:!0})]}),_jsxruntime.jsx.call(void 0, _material.Button,{disabled:a,type:"button",onClick:m,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:a?_jsxruntime.jsx.call(void 0, _material.CircularProgress,{size:20}):u("forgotPassword.sendCodeButton")}),_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",gap:2},children:[_jsxruntime.jsx.call(void 0, _material.Link,{sx:{cursor:"pointer"},onClick:w,variant:"body2",color:"secondary",children:u("common.back")}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",sx:{color:"grey.400"},children:"\u2022"}),_jsxruntime.jsx.call(void 0, _material.Link,{sx:{cursor:"pointer"},onClick:x,variant:"body2",color:"secondary",children:u("login.alreadyHaveCodeLink")})]})]}),_jsxruntime.jsx.call(void 0, _material.Box,{children:f.length>0&&f.map((C,S)=>_jsxruntime.jsx.call(void 0, _material.Alert,{variant:"filled",sx:{mt:2},severity:"error",children:C},S))})]})},So=Tr;var Sr=({onScreenChange:e,onError:o,searchParams:r,onResetSuccess:t})=>{let{crudify:c}=_chunk6RWBJJWLjs.c.call(void 0, ),[a,n]=_react.useState.call(void 0, ""),[f,l]=_react.useState.call(void 0, ""),[y,p]=_react.useState.call(void 0, !1),[g,d]=_react.useState.call(void 0, []),[s,i]=_react.useState.call(void 0, null),[u,T]=_react.useState.call(void 0, null),[E,m]=_react.useState.call(void 0, ""),[w,x]=_react.useState.call(void 0, ""),[C,S]=_react.useState.call(void 0, !1),[h,P]=_react.useState.call(void 0, !0),[R,U]=_react.useState.call(void 0, !1),[I,K]=_react.useState.call(void 0, null),[Q,Ee]=_react.useState.call(void 0, !1),{t:O}=q(),ve=v=>{let L=[`errors.auth.${v.code}`,`errors.data.${v.code}`,`errors.system.${v.code}`,`errors.${v.code}`,`resetPassword.${v.code.toLowerCase()}`];for(let z of L){let V=O(z);if(V!==z)return V}return v.message||O("error.unknown")},Se=v=>r?r instanceof URLSearchParams?r.get(v):r[v]||null:null;_react.useEffect.call(void 0, ()=>{if(r){if(r){let v=Se("fromCodeVerification"),L=Se("email"),z=Se("code");if(v==="true"&&L&&z){m(L),x(z),S(!0),U(!0),P(!1);return}let V=Se("link");if(V)try{let $=decodeURIComponent(V),[Y,pe]=$.split("/");if(Y&&pe&&Y.length===6){x(Y),m(pe),S(!1),K({email:pe,code:Y});return}}catch (e5){}if(L&&z){m(L),x(z),S(!1),K({email:L,code:z});return}}d([O("resetPassword.invalidCode")]),P(!1),setTimeout(()=>_optionalChain([e, 'optionalCall', _24 => _24("forgotPassword")]),3e3)}},[r,c,O,e]),_react.useEffect.call(void 0, ()=>{c&&I&&!Q&&(Ee(!0),(async(L,z)=>{try{let V=[{operation:"validatePasswordResetCode",data:{email:L,codePassword:z}}],$=await c.transaction(V);if($.data&&Array.isArray($.data)){let Y=$.data[0];if(Y&&Y.response&&Y.response.status==="OK"){U(!0);return}}if($.success)U(!0);else{let pe=_chunkYIIUEOXCjs.g.call(void 0, $).map(ve);d(pe),setTimeout(()=>_optionalChain([e, 'optionalCall', _25 => _25("forgotPassword")]),3e3)}}catch(V){let Y=_chunkYIIUEOXCjs.g.call(void 0, V).map(ve);d(Y),setTimeout(()=>_optionalChain([e, 'optionalCall', _26 => _26("forgotPassword")]),3e3)}finally{P(!1),K(null),Ee(!1)}})(I.email,I.code))},[c,I,O,e]);let $o=v=>v.length<8?O("resetPassword.passwordTooShort"):null,Yo=async()=>{if(y||!c)return;d([]),i(null),T(null);let v=!1;if(!a)i(O("resetPassword.newPasswordRequired")),v=!0;else{let L=$o(a);L&&(i(L),v=!0)}if(f?a!==f&&(T(O("resetPassword.passwordsDoNotMatch")),v=!0):(T(O("resetPassword.confirmPasswordRequired")),v=!0),!v){p(!0);try{let L=[{operation:"validateAndResetPassword",data:{email:E,codePassword:w,newPassword:a}}],z=await c.transaction(L);if(z.success)d([]),setTimeout(()=>{_optionalChain([t, 'optionalCall', _27 => _27()])},1e3);else{let $=_chunkYIIUEOXCjs.g.call(void 0, z).map(ve);d($)}}catch(L){let V=_chunkYIIUEOXCjs.g.call(void 0, L).map(ve);d(V),o&&o(V.join(", "))}p(!1)}},Go=()=>{C?_optionalChain([e, 'optionalCall', _28 => _28("checkCode",{email:E})]):_optionalChain([e, 'optionalCall', _29 => _29("forgotPassword")])};return h?_jsxruntime.jsx.call(void 0, _material.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"300px"},children:_jsxruntime.jsx.call(void 0, _material.CircularProgress,{})}):R?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, _material.Box,{component:"form",noValidate:!0,sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:2},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:O("resetPassword.title")}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",sx:{color:"grey.600"},children:O("resetPassword.instructions")})]}),_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:1},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",component:"label",htmlFor:"newPassword",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:O("resetPassword.newPasswordLabel")}),_jsxruntime.jsx.call(void 0, _material.TextField,{fullWidth:!0,id:"newPassword",name:"newPassword",type:"password",value:a,disabled:y,onChange:v=>n(v.target.value),error:!!s,helperText:s,autoComplete:"new-password",placeholder:O("resetPassword.newPasswordPlaceholder"),required:!0})]}),_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:1},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",component:"label",htmlFor:"confirmPassword",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:O("resetPassword.confirmPasswordLabel")}),_jsxruntime.jsx.call(void 0, _material.TextField,{fullWidth:!0,id:"confirmPassword",name:"confirmPassword",type:"password",value:f,disabled:y,onChange:v=>l(v.target.value),error:!!u,helperText:u,autoComplete:"new-password",placeholder:O("resetPassword.confirmPasswordPlaceholder"),required:!0})]}),_jsxruntime.jsx.call(void 0, _material.Button,{disabled:y,type:"button",onClick:Yo,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:y?_jsxruntime.jsx.call(void 0, _material.CircularProgress,{size:20}):O("resetPassword.resetPasswordButton")}),_jsxruntime.jsx.call(void 0, _material.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:_jsxruntime.jsx.call(void 0, _material.Link,{sx:{cursor:"pointer"},onClick:Go,variant:"body2",color:"secondary",children:O("common.back")})})]}),_jsxruntime.jsx.call(void 0, _material.Box,{children:g.length>0&&g.map((v,L)=>_jsxruntime.jsx.call(void 0, _material.Alert,{variant:"filled",sx:{mt:2},severity:"error",children:v},L))})]}):_jsxruntime.jsx.call(void 0, _material.Box,{children:g.length>0&&g.map((v,L)=>_jsxruntime.jsx.call(void 0, _material.Alert,{variant:"filled",sx:{mt:2},severity:"error",children:v},L))})},Ao=Sr;var Nr=({onScreenChange:e,onError:o,searchParams:r})=>{let{crudify:t}=_chunk6RWBJJWLjs.c.call(void 0, ),[c,a]=_react.useState.call(void 0, ""),[n,f]=_react.useState.call(void 0, !1),[l,y]=_react.useState.call(void 0, []),[p,g]=_react.useState.call(void 0, null),[d,s]=_react.useState.call(void 0, ""),{t:i}=q(),u=x=>r?r instanceof URLSearchParams?r.get(x):r[x]||null:null,T=x=>{let C=[`errors.auth.${x.code}`,`errors.data.${x.code}`,`errors.system.${x.code}`,`errors.${x.code}`,`checkCode.${x.code.toLowerCase()}`];for(let S of C){let h=i(S);if(h!==S)return h}return x.message||i("error.unknown")};_react.useEffect.call(void 0, ()=>{let x=u("email");x?s(x):_optionalChain([e, 'optionalCall', _30 => _30("forgotPassword")])},[r,e]);let E=async()=>{if(!(n||!t)){if(y([]),g(null),!c){g(i("checkCode.codeRequired"));return}if(c.length!==6){g(i("checkCode.codeRequired"));return}f(!0);try{let x=[{operation:"validatePasswordResetCode",data:{email:d,codePassword:c}}],C=await t.transaction(x);if(C.success)_optionalChain([e, 'optionalCall', _31 => _31("resetPassword",{email:d,code:c,fromCodeVerification:"true"})]);else{let h=_chunkYIIUEOXCjs.g.call(void 0, C).map(T);y(h),f(!1)}}catch(x){let S=_chunkYIIUEOXCjs.g.call(void 0, x).map(T);y(S),f(!1),o&&o(S.join(", "))}}},m=()=>{_optionalChain([e, 'optionalCall', _32 => _32("forgotPassword")])},w=x=>{let C=x.target.value.replace(/\D/g,"").slice(0,6);a(C)};return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, _material.Box,{component:"form",noValidate:!0,sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:2},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:i("checkCode.title")}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",sx:{color:"grey.600"},children:i("checkCode.instructions")})]}),_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:1},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",component:"label",htmlFor:"code",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:i("checkCode.codeLabel")}),_jsxruntime.jsx.call(void 0, _material.TextField,{fullWidth:!0,id:"code",name:"code",type:"text",value:c,disabled:n,onChange:w,error:!!p,helperText:p,placeholder:i("checkCode.codePlaceholder"),inputProps:{maxLength:6,style:{textAlign:"center",fontSize:"1.5rem",letterSpacing:"0.4rem"}},required:!0})]}),_jsxruntime.jsx.call(void 0, _material.Button,{disabled:n||c.length!==6,type:"button",onClick:E,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:n?_jsxruntime.jsx.call(void 0, _material.CircularProgress,{size:20}):i("checkCode.verifyButton")}),_jsxruntime.jsx.call(void 0, _material.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:_jsxruntime.jsx.call(void 0, _material.Link,{sx:{cursor:"pointer"},onClick:m,variant:"body2",color:"secondary",children:i("common.back")})})]}),_jsxruntime.jsx.call(void 0, _material.Box,{children:l.length>0&&l.map((x,C)=>_jsxruntime.jsx.call(void 0, _material.Alert,{sx:{mt:2},severity:"error",children:x},C))})]})},_o=Nr;var Fo=({children:e,fallback:o})=>{let{isLoading:r,error:t,isInitialized:c}=_chunk6RWBJJWLjs.c.call(void 0, ),{t:a}=q();return r?o||_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"200px",gap:2},children:[_jsxruntime.jsx.call(void 0, _material.CircularProgress,{}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",color:"text.secondary",children:a("login.initializing")!=="login.initializing"?a("login.initializing"):"Initializing..."})]}):t?_jsxruntime.jsx.call(void 0, _material.Alert,{severity:"error",sx:{mt:2},children:_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"body2",children:[a("login.initializationError")!=="login.initializationError"?a("login.initializationError"):"Initialization error",":"," ",t]})}):c?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e}):_jsxruntime.jsx.call(void 0, _material.Alert,{severity:"warning",sx:{mt:2},children:_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",children:a("login.notInitialized")!=="login.notInitialized"?a("login.notInitialized"):"System not initialized"})})};var Vr=({onScreenChange:e,onExternalNavigate:o,onLoginSuccess:r,onError:t,redirectUrl:c="/"})=>{let{t:a}=q(),{state:n,setScreen:f}=Ie(),{config:l}=_chunk6RWBJJWLjs.j.call(void 0, ),{showNotification:y}=_chunk6RWBJJWLjs.h.call(void 0, ),p=(d,s)=>{let i=s;d==="login"?i={}:d==="forgotPassword"&&!s&&(i={}),f(d,i),_optionalChain([e, 'optionalCall', _33 => _33(d,i)])},g=()=>{let d={onScreenChange:p,onExternalNavigate:o,onError:t,redirectUrl:c};switch(n.currentScreen){case"forgotPassword":return _jsxruntime.jsx.call(void 0, So,{...d});case"checkCode":return _jsxruntime.jsx.call(void 0, _o,{...d,searchParams:n.searchParams});case"resetPassword":return _jsxruntime.jsx.call(void 0, Ao,{...d,searchParams:n.searchParams,onResetSuccess:()=>{let s=a("resetPassword.successMessage");y(s,"success"),p("login")}});default:return _jsxruntime.jsx.call(void 0, To,{...d,onLoginSuccess:r})}};return _jsxruntime.jsxs.call(void 0, Fo,{children:[_jsxruntime.jsx.call(void 0, _material.Box,{sx:{display:"flex",justifyContent:"center",mb:3},children:_jsxruntime.jsx.call(void 0, "img",{src:l.logo||"https://logos.crudia.com/nocios-default.png",alt:a("login.logoAlt"),style:{width:"100%",maxWidth:"150px",height:"auto"},onError:d=>{let s=d.target;s.src="https://logos.crudia.com/nocios-default.png"}})}),!l.logo&&l.appName&&_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h6",component:"h1",sx:{textAlign:"center",mb:2},children:l.appName}),g()]})},Wr=({translations:e,translationsUrl:o,language:r="en",initialScreen:t="login",autoReadFromCookies:c=!0,...a})=>{let{config:n}=_chunk6RWBJJWLjs.j.call(void 0, );return _jsxruntime.jsx.call(void 0, yo,{translations:e,translationsUrl:o,language:r,children:_jsxruntime.jsx.call(void 0, _chunk6RWBJJWLjs.b,{config:n,children:_jsxruntime.jsx.call(void 0, Po,{config:n,initialScreen:t,autoReadFromCookies:c,children:_jsxruntime.jsx.call(void 0, Vr,{...a})})})})},is= exports.h =Wr;var _iconsmaterial = require('@mui/icons-material');var at=({showExtendedData:e=!0,showProfileCard:o=!0,autoRefresh:r=!0})=>{let{userProfile:t,loading:c,error:a,extendedData:n,refreshProfile:f}=_chunk6RWBJJWLjs.l.call(void 0, {autoFetch:r,retryOnError:!0,maxRetries:3}),[l,y]=_react.useState.call(void 0, !1);if(c)return _jsxruntime.jsxs.call(void 0, _material.Box,{display:"flex",justifyContent:"center",alignItems:"center",p:3,children:[_jsxruntime.jsx.call(void 0, _material.CircularProgress,{}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",sx:{ml:2},children:"Cargando perfil de usuario..."})]});if(a)return _jsxruntime.jsxs.call(void 0, _material.Alert,{severity:"error",action:_jsxruntime.jsx.call(void 0, _material.IconButton,{color:"inherit",size:"small",onClick:f,children:_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"caption",children:"Reintentar"})}),children:["Error al cargar el perfil: ",a]});if(!t)return _jsxruntime.jsx.call(void 0, _material.Alert,{severity:"warning",children:"No se encontr\xF3 informaci\xF3n del usuario"});let p=_optionalChain([n, 'optionalAccess', _34 => _34.displayData])||{},g=_optionalChain([n, 'optionalAccess', _35 => _35.totalFields])||0,d=m=>{if(!m)return"No disponible";try{return new Date(m).toLocaleString("es-ES",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch (e6){return m}},s=(m,w)=>w==null?"No disponible":typeof w=="boolean"?w?"S\xED":"No":Array.isArray(w)?w.length>0?w.join(", "):"Ninguno":typeof w=="object"?JSON.stringify(w,null,2):String(w),i=[{key:"id",label:"ID",icon:_jsxruntime.jsx.call(void 0, _iconsmaterial.Badge,{})},{key:"email",label:"Email",icon:_jsxruntime.jsx.call(void 0, _iconsmaterial.Email,{})},{key:"username",label:"Usuario",icon:_jsxruntime.jsx.call(void 0, _iconsmaterial.Person,{})},{key:"fullName",label:"Nombre completo",icon:_jsxruntime.jsx.call(void 0, _iconsmaterial.AccountCircle,{})},{key:"role",label:"Rol",icon:_jsxruntime.jsx.call(void 0, _iconsmaterial.Security,{})}],u=[{key:"firstName",label:"Nombre"},{key:"lastName",label:"Apellido"},{key:"isActive",label:"Activo"},{key:"lastLogin",label:"\xDAltimo login"},{key:"createdAt",label:"Creado"},{key:"updatedAt",label:"Actualizado"}],T=[...i.map(m=>m.key),...u.map(m=>m.key),"permissions"],E=Object.keys(p).filter(m=>!T.includes(m)).map(m=>({key:m,label:m}));return _jsxruntime.jsxs.call(void 0, _material.Box,{children:[o&&_jsxruntime.jsx.call(void 0, _material.Card,{sx:{mb:2},children:_jsxruntime.jsxs.call(void 0, _material.CardContent,{children:[_jsxruntime.jsxs.call(void 0, _material.Box,{display:"flex",alignItems:"center",mb:2,children:[_jsxruntime.jsx.call(void 0, _material.Avatar,{src:p.avatar,sx:{width:56,height:56,mr:2},children:_optionalChain([p, 'access', _36 => _36.fullName, 'optionalAccess', _37 => _37[0]])||_optionalChain([p, 'access', _38 => _38.username, 'optionalAccess', _39 => _39[0]])||_optionalChain([p, 'access', _40 => _40.email, 'optionalAccess', _41 => _41[0]])}),_jsxruntime.jsxs.call(void 0, _material.Box,{children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h6",children:p.fullName||p.username||p.email}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",color:"text.secondary",children:p.role||"Usuario"}),p.isActive!==void 0&&_jsxruntime.jsx.call(void 0, _material.Chip,{label:p.isActive?"Activo":"Inactivo",color:p.isActive?"success":"error",size:"small",sx:{mt:.5}})]})]}),_jsxruntime.jsx.call(void 0, _material.Box,{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(250px, 1fr))",gap:2,children:i.map(({key:m,label:w,icon:x})=>p[m]?_jsxruntime.jsxs.call(void 0, _material.Box,{display:"flex",alignItems:"center",children:[_jsxruntime.jsx.call(void 0, _material.Box,{sx:{mr:1,color:"text.secondary"},children:x}),_jsxruntime.jsxs.call(void 0, _material.Box,{children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"caption",color:"text.secondary",children:w}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",children:s(m,p[m])})]})]},m):null)}),p.permissions&&Array.isArray(p.permissions)&&p.permissions.length>0&&_jsxruntime.jsxs.call(void 0, _material.Box,{mt:2,children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"caption",color:"text.secondary",display:"block",children:"Permisos"}),_jsxruntime.jsxs.call(void 0, _material.Box,{display:"flex",flexWrap:"wrap",gap:.5,mt:.5,children:[p.permissions.slice(0,5).map((m,w)=>_jsxruntime.jsx.call(void 0, _material.Chip,{label:m,size:"small",variant:"outlined"},w)),p.permissions.length>5&&_jsxruntime.jsx.call(void 0, _material.Chip,{label:`+${p.permissions.length-5} m\xE1s`,size:"small"})]})]})]})}),e&&_jsxruntime.jsx.call(void 0, _material.Card,{children:_jsxruntime.jsxs.call(void 0, _material.CardContent,{children:[_jsxruntime.jsxs.call(void 0, _material.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"h6",display:"flex",alignItems:"center",children:[_jsxruntime.jsx.call(void 0, _iconsmaterial.Info,{sx:{mr:1}}),"Informaci\xF3n Detallada"]}),_jsxruntime.jsx.call(void 0, _material.Chip,{label:`${g} campos totales`,size:"small"})]}),_jsxruntime.jsxs.call(void 0, _material.List,{dense:!0,children:[u.map(({key:m,label:w})=>p[m]!==void 0&&_jsxruntime.jsxs.call(void 0, _material.ListItem,{divider:!0,children:[_jsxruntime.jsx.call(void 0, _material.ListItemIcon,{children:_jsxruntime.jsx.call(void 0, _iconsmaterial.Schedule,{fontSize:"small"})}),_jsxruntime.jsx.call(void 0, _material.ListItemText,{primary:w,secondary:m.includes("At")||m.includes("Login")?d(p[m]):s(m,p[m])})]},m)),E.length>0&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _material.Divider,{sx:{my:1}}),_jsxruntime.jsx.call(void 0, _material.ListItem,{children:_jsxruntime.jsx.call(void 0, _material.ListItemText,{primary:_jsxruntime.jsxs.call(void 0, _material.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"subtitle2",children:["Campos Personalizados (",E.length,")"]}),_jsxruntime.jsx.call(void 0, _material.IconButton,{size:"small",onClick:()=>y(!l),children:l?_jsxruntime.jsx.call(void 0, _iconsmaterial.ExpandLess,{}):_jsxruntime.jsx.call(void 0, _iconsmaterial.ExpandMore,{})})]})})}),_jsxruntime.jsx.call(void 0, _material.Collapse,{in:l,children:E.map(({key:m,label:w})=>_jsxruntime.jsx.call(void 0, _material.ListItem,{sx:{pl:4},children:_jsxruntime.jsx.call(void 0, _material.ListItemText,{primary:w,secondary:s(m,p[m])})},m))})]})]}),_jsxruntime.jsxs.call(void 0, _material.Box,{mt:2,display:"flex",justifyContent:"space-between",alignItems:"center",children:[_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"caption",color:"text.secondary",children:["\xDAltima actualizaci\xF3n: ",d(p.updatedAt)]}),_jsxruntime.jsx.call(void 0, _material.IconButton,{size:"small",onClick:f,disabled:c,children:_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"caption",children:"Actualizar"})})]})]})})]})},it= exports.i =at;var zo=["create","read","update","delete"],Mo= exports.k =["create","read","update","delete"];var _reacti18next = require('react-i18next');var wt=({value:e,onChange:o,availableFields:r,error:t,disabled:c=!1})=>{let{t:a}=_reacti18next.useTranslation.call(void 0, ),[n,f]=_react.useState.call(void 0, "custom"),l=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{let s=e||{allow:[],owner_allow:[],deny:[]},i=new Set(r),u=(s.allow||[]).filter(w=>i.has(w)),T=(s.owner_allow||[]).filter(w=>i.has(w)),E=(s.deny||[]).filter(w=>i.has(w));r.forEach(w=>{!u.includes(w)&&!T.includes(w)&&!E.includes(w)&&E.push(w)});let m={allow:u,owner_allow:T,deny:E};JSON.stringify(m)!==JSON.stringify(s)&&o(m),u.length===r.length?f("all"):E.length===r.length?f("none"):f("custom")},[r,e]);let y=()=>{l.current=!0,o({allow:[...r],owner_allow:[],deny:[]}),f("all"),setTimeout(()=>{l.current=!1},0)},p=()=>{l.current=!0,o({allow:[],owner_allow:[],deny:[...r]}),f("none"),setTimeout(()=>{l.current=!1},0)},g=s=>_optionalChain([e, 'optionalAccess', _42 => _42.allow, 'optionalAccess', _43 => _43.includes, 'call', _44 => _44(s)])?"allow":_optionalChain([e, 'optionalAccess', _45 => _45.owner_allow, 'optionalAccess', _46 => _46.includes, 'call', _47 => _47(s)])?"owner_allow":"deny",d=(s,i)=>{l.current=!0;let u=new Set(_optionalChain([e, 'optionalAccess', _48 => _48.allow])||[]),T=new Set(_optionalChain([e, 'optionalAccess', _49 => _49.owner_allow])||[]),E=new Set(_optionalChain([e, 'optionalAccess', _50 => _50.deny])||[]);u.delete(s),T.delete(s),E.delete(s),i==="allow"&&u.add(s),i==="owner_allow"&&T.add(s),i==="deny"&&E.add(s),o({allow:Array.from(u),owner_allow:Array.from(T),deny:Array.from(E)}),f("custom"),setTimeout(()=>{l.current=!1},0)};return r.length===0?_jsxruntime.jsxs.call(void 0, _material.Box,{children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1},children:a("modules.form.publicPolicies.fields.conditions.label")}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic"},children:a("modules.form.publicPolicies.fields.conditions.noFieldsAvailable")}),t&&_jsxruntime.jsx.call(void 0, _material.FormHelperText,{error:!0,sx:{mt:1},children:t})]}):_jsxruntime.jsxs.call(void 0, _material.Box,{children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2},children:a("modules.form.publicPolicies.fields.conditions.label")}),_jsxruntime.jsxs.call(void 0, _material.Stack,{direction:"row",spacing:1,sx:{mb:3},children:[_jsxruntime.jsx.call(void 0, _material.Button,{variant:n==="all"?"contained":"outlined",startIcon:_jsxruntime.jsx.call(void 0, _iconsmaterial.SelectAll,{}),onClick:y,disabled:c,size:"small",sx:{minWidth:120,...n==="all"&&{backgroundColor:"#16a34a","&:hover":{backgroundColor:"#15803d"}}},children:a("modules.form.publicPolicies.fields.conditions.allFields")}),_jsxruntime.jsx.call(void 0, _material.Button,{variant:n==="none"?"contained":"outlined",startIcon:_jsxruntime.jsx.call(void 0, _iconsmaterial.ClearAll,{}),onClick:p,disabled:c,size:"small",sx:{minWidth:120,...n==="none"&&{backgroundColor:"#cf222e","&:hover":{backgroundColor:"#bc1f2c"}}},children:a("modules.form.publicPolicies.fields.conditions.noFields")})]}),_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{p:2,border:"1px solid #d1d9e0",borderRadius:1,backgroundColor:"#f6f8fa"},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2},children:a("modules.form.publicPolicies.fields.conditions.help")}),_jsxruntime.jsx.call(void 0, _material.Stack,{spacing:1,children:r.map(s=>{let i=g(s);return _jsxruntime.jsxs.call(void 0, _material.Stack,{direction:"row",spacing:1,alignItems:"center",children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",sx:{minWidth:100,fontFamily:"monospace"},children:s}),_jsxruntime.jsxs.call(void 0, _material.ToggleButtonGroup,{value:i,exclusive:!0,size:"small",children:[_jsxruntime.jsxs.call(void 0, _material.ToggleButton,{value:"allow",onClick:()=>d(s,"allow"),disabled:c,sx:{px:2,color:i==="allow"?"#ffffff":"#6b7280",backgroundColor:i==="allow"?"#16a34a":"#f3f4f6",borderColor:i==="allow"?"#16a34a":"#d1d5db","&:hover":{backgroundColor:i==="allow"?"#15803d":"#e5e7eb",borderColor:i==="allow"?"#15803d":"#9ca3af"},"&.Mui-selected":{backgroundColor:"#16a34a",color:"#ffffff","&:hover":{backgroundColor:"#15803d"}}},children:[_jsxruntime.jsx.call(void 0, _iconsmaterial.CheckCircle,{sx:{fontSize:16,mr:.5}}),a("modules.form.publicPolicies.fields.conditions.states.allow")]}),_jsxruntime.jsx.call(void 0, _material.ToggleButton,{value:"owner_allow",onClick:()=>d(s,"owner_allow"),disabled:c,sx:{px:2,color:i==="owner_allow"?"#ffffff":"#6b7280",backgroundColor:i==="owner_allow"?"#0ea5e9":"#f3f4f6",borderColor:i==="owner_allow"?"#0ea5e9":"#d1d5db","&:hover":{backgroundColor:i==="owner_allow"?"#0284c7":"#e5e7eb",borderColor:i==="owner_allow"?"#0284c7":"#9ca3af"},"&.Mui-selected":{backgroundColor:"#0ea5e9",color:"#ffffff","&:hover":{backgroundColor:"#0284c7"}}},children:a("modules.form.publicPolicies.fields.conditions.states.ownerAllow")}),_jsxruntime.jsxs.call(void 0, _material.ToggleButton,{value:"deny",onClick:()=>d(s,"deny"),disabled:c,sx:{px:2,color:i==="deny"?"#ffffff":"#6b7280",backgroundColor:i==="deny"?"#dc2626":"#f3f4f6",borderColor:i==="deny"?"#dc2626":"#d1d5db","&:hover":{backgroundColor:i==="deny"?"#b91c1c":"#e5e7eb",borderColor:i==="deny"?"#b91c1c":"#9ca3af"},"&.Mui-selected":{backgroundColor:"#dc2626",color:"#ffffff","&:hover":{backgroundColor:"#b91c1c"}}},children:[_jsxruntime.jsx.call(void 0, _iconsmaterial.Cancel,{sx:{fontSize:16,mr:.5}}),a("modules.form.publicPolicies.fields.conditions.states.deny")]})]})]},s)})})]}),t&&_jsxruntime.jsx.call(void 0, _material.FormHelperText,{error:!0,sx:{mt:1},children:t})]})},Je=wt;var At=_react.forwardRef.call(void 0, ({policy:e,onChange:o,onRemove:r,availableFields:t,isSubmitting:c=!1,usedActions:a,error:n},f)=>{let{t:l}=_reacti18next.useTranslation.call(void 0, ),y=new Set(Array.from(a||[]));y.delete(e.action);let p=zo.map(g=>({value:g,label:l(`modules.form.publicPolicies.fields.action.options.${g}`)}));return _jsxruntime.jsxs.call(void 0, _material.Paper,{ref:f,sx:{p:3,border:"1px solid #d1d9e0",borderRadius:2,position:"relative",backgroundColor:"#ffffff"},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:3},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"subtitle1",sx:{fontWeight:600,color:"#111418",fontSize:"1rem"},children:l("modules.form.publicPolicies.policyTitle")}),_jsxruntime.jsx.call(void 0, _material.IconButton,{onClick:r,size:"small",disabled:c,"aria-label":l("modules.form.publicPolicies.removePolicy"),sx:{color:"#656d76","&:hover":{color:"#cf222e",backgroundColor:"rgba(207, 34, 46, 0.1)"}},children:_jsxruntime.jsx.call(void 0, _iconsmaterial.Delete,{})})]}),_jsxruntime.jsxs.call(void 0, _material.Stack,{spacing:3,children:[_jsxruntime.jsx.call(void 0, _material.Stack,{direction:{xs:"column",md:"row"},spacing:2,children:_jsxruntime.jsx.call(void 0, _material.Box,{sx:{flex:1,minWidth:200},children:_jsxruntime.jsxs.call(void 0, _material.FormControl,{fullWidth:!0,children:[_jsxruntime.jsx.call(void 0, _material.InputLabel,{children:l("modules.form.publicPolicies.fields.action.label")}),_jsxruntime.jsx.call(void 0, _material.Select,{value:e.action,label:l("modules.form.publicPolicies.fields.action.label"),disabled:c,onChange:g=>{let d=g.target.value,s={...e,action:d};d==="delete"?(s.permission="deny",delete s.fields):(s.fields={allow:[],owner_allow:[],deny:t},delete s.permission),o(s)},sx:{backgroundColor:"#ffffff","&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"#8c959f"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"#0969da",borderWidth:2}},children:p.map(g=>{let d=y.has(g.value);return _jsxruntime.jsx.call(void 0, _material.MenuItem,{value:g.value,disabled:d,children:g.label},g.value)})}),n&&_jsxruntime.jsx.call(void 0, _material.FormHelperText,{error:!0,children:n})]})})}),e.action==="delete"?_jsxruntime.jsxs.call(void 0, _material.Box,{children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2},children:l("modules.form.publicPolicies.fields.conditions.label")}),_jsxruntime.jsxs.call(void 0, _material.Stack,{direction:"row",spacing:1,sx:{mb:3},children:[_jsxruntime.jsx.call(void 0, _material.Button,{variant:e.permission==="*"?"contained":"outlined",startIcon:_jsxruntime.jsx.call(void 0, _iconsmaterial.SelectAll,{}),onClick:()=>o({...e,permission:"*"}),disabled:c,size:"small",sx:{minWidth:140,whiteSpace:"nowrap",...e.permission==="*"&&{backgroundColor:"#16a34a","&:hover":{backgroundColor:"#15803d"}}},children:l("modules.form.publicPolicies.fields.conditions.allFields")}),_jsxruntime.jsx.call(void 0, _material.Button,{variant:e.permission==="owner"?"contained":"outlined",onClick:()=>o({...e,permission:"owner"}),disabled:c,size:"small",sx:{minWidth:140,whiteSpace:"nowrap",...e.permission==="owner"&&{backgroundColor:"#0ea5e9","&:hover":{backgroundColor:"#0284c7"}}},children:l("modules.form.publicPolicies.fields.conditions.states.ownerAllow")}),_jsxruntime.jsx.call(void 0, _material.Button,{variant:e.permission==="deny"?"contained":"outlined",startIcon:_jsxruntime.jsx.call(void 0, _iconsmaterial.ClearAll,{}),onClick:()=>o({...e,permission:"deny"}),disabled:c,size:"small",sx:{minWidth:140,whiteSpace:"nowrap",...e.permission==="deny"&&{backgroundColor:"#cf222e","&:hover":{backgroundColor:"#bc1f2c"}}},children:l("modules.form.publicPolicies.fields.conditions.noFields")})]})]}):_jsxruntime.jsx.call(void 0, Je,{value:e.fields||{allow:[],owner_allow:[],deny:[]},onChange:g=>o({...e,fields:g}),availableFields:t,disabled:c}),_jsxruntime.jsx.call(void 0, _material.Paper,{variant:"outlined",sx:{p:2,backgroundColor:"#f9fafb"},children:e.action==="delete"?_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{component:"span",sx:{color:e.permission==="*"?"#16a34a":e.permission==="owner"?"#0ea5e9":"#dc2626"},children:[l("modules.form.publicPolicies.fields.conditions.states.allow"),":"]})," ",e.permission||"-"]}):_jsxruntime.jsxs.call(void 0, _material.Stack,{spacing:.5,divider:_jsxruntime.jsx.call(void 0, _material.Divider,{sx:{borderColor:"#e5e7eb"}}),children:[_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{component:"span",sx:{color:"#16a34a"},children:[l("modules.form.publicPolicies.fields.conditions.states.allow"),":"]})," ",(_optionalChain([e, 'optionalAccess', _51 => _51.fields, 'optionalAccess', _52 => _52.allow])||[]).join(", ")||"-"]}),_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{component:"span",sx:{color:"#0ea5e9"},children:[l("modules.form.publicPolicies.fields.conditions.states.ownerAllow"),":"]})," ",(_optionalChain([e, 'optionalAccess', _53 => _53.fields, 'optionalAccess', _54 => _54.owner_allow])||[]).join(", ")||"-"]}),_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{component:"span",sx:{color:"#dc2626"},children:[l("modules.form.publicPolicies.fields.conditions.states.deny"),":"]})," ",(_optionalChain([e, 'optionalAccess', _55 => _55.fields, 'optionalAccess', _56 => _56.deny])||[]).join(", ")||"-"]})]})})]})]})}),Xe=At;var Ut=()=>{let e=_optionalChain([globalThis, 'optionalAccess', _57 => _57.crypto]);return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`},zt=({policies:e,onChange:o,availableFields:r,errors:t,isSubmitting:c=!1})=>{let{t:a}=_reacti18next.useTranslation.call(void 0, ),n=_react.useRef.call(void 0, {}),f=new Set((e||[]).map(i=>i.action).filter(Boolean)),l=Mo.filter(i=>!f.has(i)),y=l.length>0,p=()=>{let i=l[0]||"create",u={id:Ut(),action:i};i==="delete"?u.permission="deny":u.fields={allow:[],owner_allow:[],deny:r};let T=[...e||[],u];o(T),setTimeout(()=>{let E=T.length-1,m=n.current[E];m&&m.scrollIntoView({behavior:"smooth",block:"center"})},100)},g=i=>{let u=[...e];u.splice(i,1),o(u)},d=(()=>{if(!t)return null;if(typeof t=="string")return t;let i=t._error;return typeof i=="string"?i:null})(),s=new Set((e||[]).map(i=>i.action));return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _material.Divider,{sx:{borderColor:"#e0e4e7"}}),_jsxruntime.jsxs.call(void 0, _material.Box,{children:[_jsxruntime.jsx.call(void 0, _material.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3,children:_jsxruntime.jsxs.call(void 0, _material.Box,{children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h6",sx:{fontWeight:600,color:"#111418",mb:1},children:a("modules.form.publicPolicies.title")}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",color:"text.secondary",sx:{fontSize:"0.875rem"},children:a("modules.form.publicPolicies.description")})]})}),d&&_jsxruntime.jsx.call(void 0, _material.Alert,{severity:"error",sx:{mb:3},children:d}),_jsxruntime.jsxs.call(void 0, _material.Stack,{spacing:3,children:[(e||[]).length===0?_jsxruntime.jsx.call(void 0, _material.Alert,{severity:"info",children:a("modules.form.publicPolicies.noPolicies")}):e.map((i,u)=>_jsxruntime.jsx.call(void 0, Xe,{ref:T=>{n.current[u]=T},policy:i,onChange:T=>{let E=[...e];E[u]=T,o(E)},onRemove:()=>g(u),availableFields:r,isSubmitting:c,usedActions:s,error:typeof t=="object"&&t&&i.id in t?t[i.id]:void 0},i.id)),y&&_jsxruntime.jsx.call(void 0, _material.Box,{children:_jsxruntime.jsx.call(void 0, _material.Button,{type:"button",variant:"outlined",startIcon:_jsxruntime.jsx.call(void 0, _iconsmaterial.Add,{}),onClick:p,disabled:c,sx:{borderColor:"#d0d7de",color:"#656d76","&:hover":{borderColor:"#8c959f",backgroundColor:"transparent"}},children:a("modules.form.publicPolicies.addPolicy")})})]})]})]})},Hs= exports.l =zt;function Xs(){let[e,o]=_react.useState.call(void 0, ""),[r,t]=_react.useState.call(void 0, ""),[c,a]=_react.useState.call(void 0, !1),{isAuthenticated:n,isLoading:f,error:l,login:y,logout:p,refreshTokens:g,clearError:d,isExpiringSoon:s,expiresIn:i}=_chunk6RWBJJWLjs.j.call(void 0, ),u=async m=>{if(m.preventDefault(),!e||!r)return;(await y(e,r)).success&&(o(""),t(""),a(!1))},T=async()=>{await p()},E=async()=>{await g()};return n?_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{maxWidth:600,mx:"auto",p:3},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h4",gutterBottom:!0,children:"Welcome! \u{1F389}"}),_jsxruntime.jsx.call(void 0, _material.Alert,{severity:"success",sx:{mb:3},children:"You are successfully logged in with Refresh Token Pattern enabled"}),_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:3,p:2,bgcolor:"background.paper",border:1,borderColor:"divider",borderRadius:1},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h6",gutterBottom:!0,children:"Token Status"}),_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"body2",color:"text.secondary",children:["Access Token expires in: ",Math.round(i/1e3/60)," minutes"]}),s&&_jsxruntime.jsx.call(void 0, _material.Alert,{severity:"warning",sx:{mt:1},children:"Token expires soon - automatic refresh will happen"})]}),_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[_jsxruntime.jsx.call(void 0, _material.Button,{variant:"contained",onClick:E,disabled:f,startIcon:f?_jsxruntime.jsx.call(void 0, _material.CircularProgress,{size:16}):null,children:"Refresh Tokens"}),_jsxruntime.jsx.call(void 0, _material.Button,{variant:"outlined",color:"error",onClick:T,disabled:f,children:"Logout"})]}),l&&_jsxruntime.jsx.call(void 0, _material.Alert,{severity:"error",sx:{mt:2},onClose:d,children:l})]}):_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{maxWidth:400,mx:"auto",p:3},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h4",gutterBottom:!0,align:"center",children:"Login with Refresh Tokens"}),_jsxruntime.jsx.call(void 0, _material.Alert,{severity:"info",sx:{mb:3},children:"This demo shows the new Refresh Token Pattern with automatic session management"}),c?_jsxruntime.jsxs.call(void 0, "form",{onSubmit:u,children:[_jsxruntime.jsx.call(void 0, _material.TextField,{fullWidth:!0,label:"Email",type:"email",value:e,onChange:m=>o(m.target.value),margin:"normal",required:!0,autoComplete:"email"}),_jsxruntime.jsx.call(void 0, _material.TextField,{fullWidth:!0,label:"Password",type:"password",value:r,onChange:m=>t(m.target.value),margin:"normal",required:!0,autoComplete:"current-password"}),_jsxruntime.jsx.call(void 0, _material.Button,{type:"submit",fullWidth:!0,variant:"contained",size:"large",disabled:f,startIcon:f?_jsxruntime.jsx.call(void 0, _material.CircularProgress,{size:16}):null,sx:{mt:3,mb:2},children:f?"Logging in...":"Login"})]}):_jsxruntime.jsx.call(void 0, _material.Button,{fullWidth:!0,variant:"contained",size:"large",onClick:()=>a(!0),sx:{mt:2},children:"Show Login Form"}),l&&_jsxruntime.jsx.call(void 0, _material.Alert,{severity:"error",sx:{mt:2},onClose:d,children:l})]})}function Zs(){let{isAuthenticated:e,isLoading:o,isExpiringSoon:r,expiresIn:t}=_chunk6RWBJJWLjs.j.call(void 0, );return o?_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[_jsxruntime.jsx.call(void 0, _material.CircularProgress,{size:16}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"caption",children:"Loading session..."})]}):e?_jsxruntime.jsxs.call(void 0, _material.Box,{children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"caption",color:"success.main",children:"\u2713 Authenticated"}),r&&_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"caption",color:"warning.main",display:"block",children:["\u26A0 Token expires in ",Math.round(t/1e3/60)," min"]})]}):_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"caption",color:"text.secondary",children:"Not logged in"})}exports.a = oe; exports.b = Vt; exports.c = Wt; exports.d = De; exports.e = Be; exports.f = Qt; exports.g = go; exports.h = is; exports.i = it; exports.j = zo; exports.k = Mo; exports.l = Hs; exports.m = Xs; exports.n = Zs;
|
package/dist/components.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkUUVJCOSWjs = require('./chunk-UUVJCOSW.js');var _chunk6RWBJJWLjs = require('./chunk-6RWBJJWL.js');require('./chunk-YIIUEOXC.js');require('./chunk-AT74WV5W.js');var _react = require('react');var _jsxruntime = require('react/jsx-runtime');function G({showBelowMinutes:d=5,position:f="bottom-right",colorNormal:m="#ed6c02",colorCritical:x="#d32f2f",style:g,className:u}={}){let{isAuthenticated:o,tokens:t}=_chunk6RWBJJWLjs.f.call(void 0, ),[i,h]=_react.useState.call(void 0, 0),[y,S]=_react.useState.call(void 0, 100);if(_react.useEffect.call(void 0, ()=>{if(!o||!t)return;let P=setInterval(()=>{let C=Date.now(),p=t.expiresAt-C,w=900*1e3;h(Math.max(0,p)),S(Math.max(0,p/w*100))},1e3);return()=>clearInterval(P)},[o,t]),!o||i<=0)return null;let e=Math.floor(i/6e4),b=Math.floor(i%6e4/1e3);if(e>=d)return null;let s=e<2,a=s?x:m,v={"top-left":{top:"16px",left:"16px"},"top-right":{top:"16px",right:"16px"},"bottom-left":{bottom:"16px",left:"16px"},"bottom-right":{bottom:"16px",right:"16px"}}[f];return _jsxruntime.jsxs.call(void 0, "div",{className:u,style:{position:"fixed",...v,padding:"12px 16px",backgroundColor:"white",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",minWidth:"200px",zIndex:9999,fontFamily:"system-ui, -apple-system, sans-serif",...g},children:[_jsxruntime.jsxs.call(void 0, "div",{style:{marginBottom:"8px"},children:[_jsxruntime.jsx.call(void 0, "div",{style:{fontSize:"12px",fontWeight:600,color:a,marginBottom:"4px"},children:s?"\u26A0\uFE0F Sesi\xF3n expirando":"\u23F0 Sesi\xF3n por expirar"}),_jsxruntime.jsxs.call(void 0, "div",{style:{fontSize:"14px",color:"#333",fontWeight:500},children:[e,":",b.toString().padStart(2,"0")]})]}),_jsxruntime.jsx.call(void 0, "div",{style:{width:"100%",height:"6px",backgroundColor:"#e0e0e0",borderRadius:"3px",overflow:"hidden"},children:_jsxruntime.jsx.call(void 0, "div",{style:{width:`${y}%`,height:"100%",backgroundColor:a,transition:"width 1s linear"}})})]})}exports.CrudifyLogin = _chunkUUVJCOSWjs.h; exports.GlobalNotificationProvider = _chunk6RWBJJWLjs.g; exports.LoginComponent = _chunkUUVJCOSWjs.m; exports.Policies = _chunkUUVJCOSWjs.l; exports.SessionStatus = _chunkUUVJCOSWjs.n; exports.SessionTimeIndicator = G; exports.UserProfileDisplay = _chunkUUVJCOSWjs.i; exports.useGlobalNotification = _chunk6RWBJJWLjs.h;
|
package/dist/components.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as T,i as L,l as M,m as R,n as k}from"./chunk-
|
|
1
|
+
import{h as T,i as L,l as M,m as R,n as k}from"./chunk-PZRCUUGR.mjs";import{f as l,g as I,h as N}from"./chunk-CM6XOYDL.mjs";import"./chunk-BJ6PIVZR.mjs";import"./chunk-5JKS55SE.mjs";import{useEffect as B,useState as c}from"react";import{jsx as r,jsxs as n}from"react/jsx-runtime";function G({showBelowMinutes:d=5,position:f="bottom-right",colorNormal:m="#ed6c02",colorCritical:x="#d32f2f",style:g,className:u}={}){let{isAuthenticated:o,tokens:t}=l(),[i,h]=c(0),[y,S]=c(100);if(B(()=>{if(!o||!t)return;let P=setInterval(()=>{let C=Date.now(),p=t.expiresAt-C,w=900*1e3;h(Math.max(0,p)),S(Math.max(0,p/w*100))},1e3);return()=>clearInterval(P)},[o,t]),!o||i<=0)return null;let e=Math.floor(i/6e4),b=Math.floor(i%6e4/1e3);if(e>=d)return null;let s=e<2,a=s?x:m,v={"top-left":{top:"16px",left:"16px"},"top-right":{top:"16px",right:"16px"},"bottom-left":{bottom:"16px",left:"16px"},"bottom-right":{bottom:"16px",right:"16px"}}[f];return n("div",{className:u,style:{position:"fixed",...v,padding:"12px 16px",backgroundColor:"white",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",minWidth:"200px",zIndex:9999,fontFamily:"system-ui, -apple-system, sans-serif",...g},children:[n("div",{style:{marginBottom:"8px"},children:[r("div",{style:{fontSize:"12px",fontWeight:600,color:a,marginBottom:"4px"},children:s?"\u26A0\uFE0F Sesi\xF3n expirando":"\u23F0 Sesi\xF3n por expirar"}),n("div",{style:{fontSize:"14px",color:"#333",fontWeight:500},children:[e,":",b.toString().padStart(2,"0")]})]}),r("div",{style:{width:"100%",height:"6px",backgroundColor:"#e0e0e0",borderRadius:"3px",overflow:"hidden"},children:r("div",{style:{width:`${y}%`,height:"100%",backgroundColor:a,transition:"width 1s linear"}})})]})}export{T as CrudifyLogin,I as GlobalNotificationProvider,R as LoginComponent,M as Policies,k as SessionStatus,G as SessionTimeIndicator,L as UserProfileDisplay,N as useGlobalNotification};
|
package/dist/index.d.mts
CHANGED
|
@@ -476,7 +476,6 @@ declare const useCrudifyInitializer: () => CrudifyInitializerContextValue;
|
|
|
476
476
|
|
|
477
477
|
interface TranslationsProviderProps {
|
|
478
478
|
children: React.ReactNode;
|
|
479
|
-
subscriberKey: string;
|
|
480
479
|
apiKey: string;
|
|
481
480
|
crudifyEnv?: "dev" | "stg" | "api" | "prod";
|
|
482
481
|
sections?: string[];
|
|
@@ -511,7 +510,6 @@ interface TranslationsContextValue {
|
|
|
511
510
|
* await crudify.init(publicApiKey, 'debug')
|
|
512
511
|
*
|
|
513
512
|
* <TranslationsProvider
|
|
514
|
-
* subscriberKey="mycompany"
|
|
515
513
|
* apiKey="xxx"
|
|
516
514
|
* language="es"
|
|
517
515
|
* translationUrl="https://example.com/locales/es/translation.json"
|
|
@@ -536,14 +534,12 @@ declare const TranslationsProvider: React.FC<TranslationsProviderProps>;
|
|
|
536
534
|
declare const useTranslations: () => TranslationsContextValue;
|
|
537
535
|
|
|
538
536
|
interface FetchTranslationsOptions {
|
|
539
|
-
subscriberKey: string;
|
|
540
537
|
apiKey: string;
|
|
541
538
|
crudifyEnv?: "dev" | "stg" | "api" | "prod";
|
|
542
539
|
sections?: string[];
|
|
543
540
|
urlTranslations?: Record<string, string>;
|
|
544
541
|
}
|
|
545
542
|
interface TranslationResponse {
|
|
546
|
-
subscriberKey: string;
|
|
547
543
|
languages: string[];
|
|
548
544
|
translations: Record<string, Record<string, string>>;
|
|
549
545
|
timestamp: string;
|
|
@@ -618,7 +614,8 @@ declare class TranslationService {
|
|
|
618
614
|
*/
|
|
619
615
|
private isCacheExpired;
|
|
620
616
|
/**
|
|
621
|
-
* Generate cache key
|
|
617
|
+
* Generate cache key from apiKey
|
|
618
|
+
* Uses a hash to ensure privacy and consistent length
|
|
622
619
|
*/
|
|
623
620
|
private getCacheKey;
|
|
624
621
|
/**
|
|
@@ -628,7 +625,7 @@ declare class TranslationService {
|
|
|
628
625
|
/**
|
|
629
626
|
* Invalidate cache (useful for testing/debugging)
|
|
630
627
|
*/
|
|
631
|
-
invalidateCache(
|
|
628
|
+
invalidateCache(apiKey: string): void;
|
|
632
629
|
/**
|
|
633
630
|
* Prefetch translations in background
|
|
634
631
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -476,7 +476,6 @@ declare const useCrudifyInitializer: () => CrudifyInitializerContextValue;
|
|
|
476
476
|
|
|
477
477
|
interface TranslationsProviderProps {
|
|
478
478
|
children: React.ReactNode;
|
|
479
|
-
subscriberKey: string;
|
|
480
479
|
apiKey: string;
|
|
481
480
|
crudifyEnv?: "dev" | "stg" | "api" | "prod";
|
|
482
481
|
sections?: string[];
|
|
@@ -511,7 +510,6 @@ interface TranslationsContextValue {
|
|
|
511
510
|
* await crudify.init(publicApiKey, 'debug')
|
|
512
511
|
*
|
|
513
512
|
* <TranslationsProvider
|
|
514
|
-
* subscriberKey="mycompany"
|
|
515
513
|
* apiKey="xxx"
|
|
516
514
|
* language="es"
|
|
517
515
|
* translationUrl="https://example.com/locales/es/translation.json"
|
|
@@ -536,14 +534,12 @@ declare const TranslationsProvider: React.FC<TranslationsProviderProps>;
|
|
|
536
534
|
declare const useTranslations: () => TranslationsContextValue;
|
|
537
535
|
|
|
538
536
|
interface FetchTranslationsOptions {
|
|
539
|
-
subscriberKey: string;
|
|
540
537
|
apiKey: string;
|
|
541
538
|
crudifyEnv?: "dev" | "stg" | "api" | "prod";
|
|
542
539
|
sections?: string[];
|
|
543
540
|
urlTranslations?: Record<string, string>;
|
|
544
541
|
}
|
|
545
542
|
interface TranslationResponse {
|
|
546
|
-
subscriberKey: string;
|
|
547
543
|
languages: string[];
|
|
548
544
|
translations: Record<string, Record<string, string>>;
|
|
549
545
|
timestamp: string;
|
|
@@ -618,7 +614,8 @@ declare class TranslationService {
|
|
|
618
614
|
*/
|
|
619
615
|
private isCacheExpired;
|
|
620
616
|
/**
|
|
621
|
-
* Generate cache key
|
|
617
|
+
* Generate cache key from apiKey
|
|
618
|
+
* Uses a hash to ensure privacy and consistent length
|
|
622
619
|
*/
|
|
623
620
|
private getCacheKey;
|
|
624
621
|
/**
|
|
@@ -628,7 +625,7 @@ declare class TranslationService {
|
|
|
628
625
|
/**
|
|
629
626
|
* Invalidate cache (useful for testing/debugging)
|
|
630
627
|
*/
|
|
631
|
-
invalidateCache(
|
|
628
|
+
invalidateCache(apiKey: string): void;
|
|
632
629
|
/**
|
|
633
630
|
* Prefetch translations in background
|
|
634
631
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkUUVJCOSWjs = require('./chunk-UUVJCOSW.js');var _chunkU6FDNJHAjs = require('./chunk-U6FDNJHA.js');var _chunk6RWBJJWLjs = require('./chunk-6RWBJJWL.js');var _chunkNNY4A73Vjs = require('./chunk-NNY4A73V.js');var _chunkYIIUEOXCjs = require('./chunk-YIIUEOXC.js');var _chunkAT74WV5Wjs = require('./chunk-AT74WV5W.js');var _crudifybrowser = require('@nocios/crudify-browser'); var _crudifybrowser2 = _interopRequireDefault(_crudifybrowser); _createStarExport(_crudifybrowser);var _react = require('react');var _material = require('@mui/material');var _jsxruntime = require('react/jsx-runtime');var ki=(i={})=>{try{let e=_chunkAT74WV5Wjs.a.call(void 0, "theme");if(e){let t=JSON.parse(decodeURIComponent(e));return{...i,...t}}}catch(e){console.warn("Error parsing theme from cookie:",e)}return i};function Oi({children:i,defaultTheme:e={},disableCssBaseline:t=!1}){let r=_react.useMemo.call(void 0, ()=>{let n=ki(e);return _material.createTheme.call(void 0, n)},[e]);return _jsxruntime.jsxs.call(void 0, _material.ThemeProvider,{theme:r,children:[!t&&_jsxruntime.jsx.call(void 0, _material.CssBaseline,{}),i]})}var _reactrouterdom = require('react-router-dom');var Di={border:"5px solid rgba(0, 0, 0, 0.1)",borderTopColor:"#3B82F6",borderRadius:"50%",width:"50px",height:"50px",animation:"spin 1s linear infinite"},Gi=()=>_jsxruntime.jsx.call(void 0, "style",{children:`
|
|
2
2
|
@keyframes spin {
|
|
3
3
|
0% { transform: rotate(0deg); }
|
|
4
4
|
100% { transform: rotate(360deg); }
|
|
5
5
|
}
|
|
6
|
-
`});function T({stage:i="loading",message:e}){let r=e||{initializing:"Initializing application...","validating-session":"Validating session...",loading:"Loading..."}[i];return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, Gi,{}),_jsxruntime.jsxs.call(void 0, "div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw",backgroundColor:"#f0f2f5",fontFamily:'"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',color:"#333",textAlign:"center",boxSizing:"border-box",padding:"20px",background:"#fff"},children:[_jsxruntime.jsx.call(void 0, "div",{style:Di}),_jsxruntime.jsx.call(void 0, "p",{style:{fontSize:"1.25em",fontWeight:"500",marginTop:"24px",color:"#1f2937"},children:r})]})]})}var Ki=/^[a-zA-Z0-9\-_./\?=&%#]+$/,$i=[/^https?:\/\//i,/^ftp:\/\//i,/^\/\//,/javascript:/i,/data:/i,/vbscript:/i,/about:/i,/\.\.\//,/\.\.\\/,/%2e%2e%2f/i,/%2e%2e%5c/i,/%2f%2f/i,/%5c%5c/i,/[\x00-\x1f\x7f-\x9f]/,/\\/],P= exports.validateInternalRedirect =(i,e="/")=>{if(!i||typeof i!="string")return e;let t=i.trim();if(!t)return e;if(!t.startsWith("/"))return console.warn("\u{1F6A8} Open redirect blocked (relative path):",i),e;if(!Ki.test(t))return console.warn("\u{1F6A8} Open redirect blocked (invalid characters):",i),e;let r=t.toLowerCase();for(let o of $i)if(o.test(r))return console.warn("\u{1F6A8} Open redirect blocked (dangerous pattern):",i),e;let n=t.split("?")[0].split("/").filter(Boolean);if(n.length===0)return t;for(let o of n)if(o===".."||o.includes(":")||o.length>100)return console.warn("\u{1F6A8} Open redirect blocked (suspicious path part):",o),e;return t},S= exports.extractSafeRedirectFromUrl =(i,e="/")=>{try{let r=(typeof i=="string"?new URLSearchParams(i):i).get("redirect");if(!r)return e;let n=decodeURIComponent(r);return P(n,e)}catch(t){return console.warn("\u{1F6A8} Error parsing redirect parameter:",t),e}};function N({children:i,loadingComponent:e,loginPath:t="/login"}){let{isAuthenticated:r,isLoading:n,isInitialized:o,tokens:s,error:a}=_chunk6RWBJJWLjs.j.call(void 0, ),u=_reactrouterdom.useLocation.call(void 0, );if(!o||n)return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e||_jsxruntime.jsx.call(void 0, T,{stage:"validating-session"})});let p=r&&_optionalChain([s, 'optionalAccess', _2 => _2.accessToken])&&s.accessToken.length>0;if(a||!r||!p){s&&(!s.accessToken||s.accessToken.length===0)&&localStorage.removeItem("crudify_tokens");let g=u.pathname+u.search,I=P(g),m=encodeURIComponent(I);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:`${t}?redirect=${m}`,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:i})}function O({children:i,redirectTo:e="/"}){let{isAuthenticated:t}=_chunk6RWBJJWLjs.j.call(void 0, ),r=_reactrouterdom.useLocation.call(void 0, );if(t){let n=new URLSearchParams(r.search),o=S(n,e);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:o,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:i})}var R=class i{constructor(){this.state={status:"UNINITIALIZED",priority:null,publicApiKey:null,env:null,error:null,initializedBy:null};this.initializationPromise=null;this.highPriorityInitializerPresent=!1;this.waitingForHighPriority=new Set;this.HIGH_PRIORITY_WAIT_TIMEOUT=100}static getInstance(){return i.instance||(i.instance=new i),i.instance}registerHighPriorityInitializer(){this.highPriorityInitializerPresent=!0}isHighPriorityInitializerPresent(){return this.highPriorityInitializerPresent}getState(){return{...this.state}}async initialize(e){let{priority:t,publicApiKey:r,env:n,enableLogging:o,requestedBy:s}=e;if(this.state.status==="INITIALIZED"){this.state.publicApiKey!==r&&console.warn(`[CrudifyInitialization] ${s} attempted to initialize with different key. Already initialized with key: ${_optionalChain([this, 'access', _3 => _3.state, 'access', _4 => _4.publicApiKey, 'optionalAccess', _5 => _5.slice, 'call', _6 => _6(0,10)])}... by ${this.state.initializedBy}`);return}if(this.initializationPromise)return o&&console.log(`[CrudifyInitialization] ${s} waiting for ongoing initialization...`),this.initializationPromise;if(t==="LOW"&&this.highPriorityInitializerPresent&&this.state.status==="UNINITIALIZED"){if(o&&console.log(`[CrudifyInitialization] ${s} (LOW priority) waiting for HIGH priority initializer...`),this.waitingForHighPriority.add(s),await this.waitForHighPriorityOrTimeout(o),this.waitingForHighPriority.delete(s),this.getState().status==="INITIALIZED"){o&&console.log(`[CrudifyInitialization] ${s} found initialization completed by HIGH priority`);return}o&&console.warn(`[CrudifyInitialization] ${s} timeout waiting for HIGH priority, initializing with LOW priority`)}t==="HIGH"&&this.state.status==="INITIALIZING"&&this.state.priority==="LOW"&&(console.warn(`[CrudifyInitialization] HIGH priority request from ${s} interrupting LOW priority initialization by ${this.state.initializedBy}`),this.state.status="UNINITIALIZED",this.initializationPromise=null),o&&console.log(`[CrudifyInitialization] ${s} starting initialization (${t} priority)...`),this.state.status="INITIALIZING",this.state.priority=t,this.state.initializedBy=s,this.initializationPromise=this.performInitialization(r,n,o);try{await this.initializationPromise,this.state.status="INITIALIZED",this.state.publicApiKey=r,this.state.env=n,this.state.error=null,o&&console.log(`[CrudifyInitialization] \u2705 Successfully initialized by ${s} (${t} priority)`)}catch(a){throw this.state.status="ERROR",this.state.error=a instanceof Error?a:new Error(String(a)),this.initializationPromise=null,console.error(`[CrudifyInitialization] \u274C Initialization failed for ${s}:`,a),a}}async waitForHighPriorityOrTimeout(e){return new Promise(t=>{let n=0,o=setInterval(()=>{if(n+=10,this.state.status==="INITIALIZED"&&this.state.priority==="HIGH"){clearInterval(o),t();return}if(this.state.status==="INITIALIZING"&&this.state.priority==="HIGH"){n=0;return}n>=this.HIGH_PRIORITY_WAIT_TIMEOUT&&(clearInterval(o),e&&console.log(`[CrudifyInitialization] Timeout waiting for HIGH priority (${this.HIGH_PRIORITY_WAIT_TIMEOUT}ms)`),t())},10)})}async performInitialization(e,t,r){let n=_crudifybrowser2.default.getTokenData();if(n&&n.endpoint){r&&console.log("[CrudifyInitialization] SDK already initialized externally");return}_crudifybrowser2.default.config(t);let o=r?"debug":"none",s=await _crudifybrowser2.default.init(e,o);if(s.success===!1)throw new Error(`Crudify initialization failed: ${JSON.stringify(s.errors||"Unknown error")}`)}reset(){this.state={status:"UNINITIALIZED",priority:null,publicApiKey:null,env:null,error:null,initializedBy:null},this.initializationPromise=null,this.highPriorityInitializerPresent=!1,this.waitingForHighPriority.clear()}isInitialized(){return this.state.status==="INITIALIZED"}getDiagnostics(){return{...this.state,waitingCount:this.waitingForHighPriority.size,waitingComponents:Array.from(this.waitingForHighPriority),hasActivePromise:this.initializationPromise!==null}}},x= exports.crudifyInitManager =R.getInstance();var D=_react.createContext.call(void 0, void 0),Qi= exports.CrudifyInitializer =({config:i,children:e,fallback:t=null,onInitialized:r,onError:n})=>{let[o,s]=_react.useState.call(void 0, !1),[a,u]=_react.useState.call(void 0, !1),[p,g]=_react.useState.call(void 0, null),I=_react.useRef.call(void 0, !1),m=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{I.current||(x.registerHighPriorityInitializer(),I.current=!0),m.current||(m.current=!0,(async()=>{u(!0),g(null);try{await x.initialize({priority:"HIGH",publicApiKey:i.publicApiKey,env:i.env||"stg",enableLogging:i.enableLogging,requestedBy:"CrudifyInitializer"}),s(!0),u(!1),r&&r()}catch(C){let b=C instanceof Error?C:new Error(String(C));g(b),u(!1),n&&n(b)}})())},[i.publicApiKey,i.env,i.enableLogging,r,n]);let F={isInitialized:o,isInitializing:a,error:p};return a&&t?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:t}):(p&&console.error("[CrudifyInitializer] Initialization failed:",p),_jsxruntime.jsx.call(void 0, D.Provider,{value:F,children:e}))},Xi= exports.useCrudifyInitializer =()=>{let i=_react.useContext.call(void 0, D);if(!i)throw new Error("useCrudifyInitializer must be used within CrudifyInitializer");return i};var _crudifyadmin = require('@nocios/crudify-admin'); var _crudifyadmin2 = _interopRequireDefault(_crudifyadmin);var G=!1,y=null;async function ie(){let e=_chunk6RWBJJWLjs.e.getInstance().getTokenInfo(),t=_optionalChain([e, 'optionalAccess', _7 => _7.apiEndpointAdmin]),r=_optionalChain([e, 'optionalAccess', _8 => _8.apiKeyEndpointAdmin]);return t&&r?{apiUrl:t,apiKey:r}:_chunk6RWBJJWLjs.a.waitForCredentials()}async function ee(){if(!G)return y||(y=(async()=>{try{let i=_chunk6RWBJJWLjs.e.getInstance(),{apiUrl:e,apiKey:t}=await ie();_crudifyadmin2.default.init({url:e,apiKey:t,getAdditionalHeaders:()=>{let r=i.getTokenInfo();return _optionalChain([r, 'optionalAccess', _9 => _9.crudifyTokens, 'optionalAccess', _10 => _10.accessToken])?{Authorization:`Bearer ${r.crudifyTokens.accessToken}`}:{}}}),G=!0}catch(i){throw y=null,console.error("[crudifyAdminWrapper] Initialization failed:",i),i}})(),y)}async function c(i){try{await ee();let e=await i();return!e.success&&_optionalChain([e, 'access', _11 => _11.errors, 'optionalAccess', _12 => _12.includes, 'call', _13 => _13("401")])?await _chunk6RWBJJWLjs.e.getInstance().refreshTokens()?await i():(console.error("[crudifyAdmin] Token refresh failed"),typeof window<"u"&&(window.location.href="/login"),e):e}catch(e){return console.error("[crudifyAdmin] Operation error:",e),{success:!1,errors:e instanceof Error?e.message:"Unknown error"}}}var te={listModules:()=>c(()=>_crudifyadmin2.default.listModules()),getModule:i=>c(()=>_crudifyadmin2.default.getModule(i)),createModule:i=>c(()=>_crudifyadmin2.default.createModule(i)),editModule:(i,e)=>c(()=>_crudifyadmin2.default.editModule(i,e)),deleteModule:i=>c(()=>_crudifyadmin2.default.deleteModule(i)),activateModule:i=>c(()=>_crudifyadmin2.default.activateModule(i)),deactivateModule:i=>c(()=>_crudifyadmin2.default.deactivateModule(i)),getModuleVersions:i=>c(()=>_crudifyadmin2.default.getModuleVersions(i))};exports.AuthRoute = O; exports.CRITICAL_TRANSLATIONS = _chunkJWIFFUC5js.a; exports.CrudifyInitializationManager = R; exports.CrudifyInitializer = Qi; exports.CrudifyLogin = _chunkJWIFFUC5js.h; exports.CrudifyProvider = _chunk6RWBJJWLjs.b; exports.CrudifyThemeProvider = Oi; exports.ERROR_CODES = _chunkYIIUEOXCjs.a; exports.ERROR_SEVERITY_MAP = _chunkYIIUEOXCjs.b; exports.GlobalNotificationProvider = _chunk6RWBJJWLjs.g; exports.LoginComponent = _chunkJWIFFUC5js.m; exports.POLICY_ACTIONS = _chunkJWIFFUC5js.j; exports.PREFERRED_POLICY_ORDER = _chunkJWIFFUC5js.k; exports.Policies = _chunkJWIFFUC5js.l; exports.ProtectedRoute = N; exports.SessionDebugInfo = _chunk6RWBJJWLjs.k; exports.SessionLoadingScreen = T; exports.SessionManager = _chunk6RWBJJWLjs.e; exports.SessionProvider = _chunk6RWBJJWLjs.i; exports.SessionStatus = _chunkJWIFFUC5js.n; exports.TokenStorage = _chunk6RWBJJWLjs.d; exports.TranslationService = _chunkJWIFFUC5js.d; exports.TranslationsProvider = _chunkJWIFFUC5js.f; exports.UserProfileDisplay = _chunkJWIFFUC5js.i; exports.createErrorTranslator = _chunkAT74WV5Wjs.e; exports.crudify = _crudifybrowser2.default; exports.crudifyAdmin = te; exports.crudifyInitManager = x; exports.decodeJwtSafely = _chunkAT74WV5Wjs.h; exports.extractSafeRedirectFromUrl = S; exports.getCookie = _chunkAT74WV5Wjs.a; exports.getCriticalLanguages = _chunkJWIFFUC5js.b; exports.getCriticalTranslations = _chunkJWIFFUC5js.c; exports.getCurrentUserEmail = _chunkAT74WV5Wjs.i; exports.getErrorMessage = _chunkYIIUEOXCjs.e; exports.handleCrudifyError = _chunkYIIUEOXCjs.g; exports.isTokenExpired = _chunkAT74WV5Wjs.j; exports.parseApiError = _chunkYIIUEOXCjs.c; exports.parseJavaScriptError = _chunkYIIUEOXCjs.f; exports.parseTransactionError = _chunkYIIUEOXCjs.d; exports.secureLocalStorage = _chunkNNY4A73Vjs.b; exports.secureSessionStorage = _chunkNNY4A73Vjs.a; exports.translateError = _chunkAT74WV5Wjs.d; exports.translateErrorCode = _chunkAT74WV5Wjs.b; exports.translateErrorCodes = _chunkAT74WV5Wjs.c; exports.translationService = _chunkJWIFFUC5js.e; exports.useAuth = _chunkU6FDNJHAjs.b; exports.useCrudify = _chunk6RWBJJWLjs.c; exports.useCrudifyInitializer = Xi; exports.useCrudifyWithNotifications = _chunkU6FDNJHAjs.d; exports.useData = _chunkU6FDNJHAjs.c; exports.useGlobalNotification = _chunk6RWBJJWLjs.h; exports.useSession = _chunk6RWBJJWLjs.f; exports.useSessionContext = _chunk6RWBJJWLjs.j; exports.useTranslations = _chunkJWIFFUC5js.g; exports.useUserData = _chunkU6FDNJHAjs.a; exports.useUserProfile = _chunk6RWBJJWLjs.l; exports.validateInternalRedirect = P;
|
|
6
|
+
`});function T({stage:i="loading",message:e}){let r=e||{initializing:"Initializing application...","validating-session":"Validating session...",loading:"Loading..."}[i];return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, Gi,{}),_jsxruntime.jsxs.call(void 0, "div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",width:"100vw",backgroundColor:"#f0f2f5",fontFamily:'"Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',color:"#333",textAlign:"center",boxSizing:"border-box",padding:"20px",background:"#fff"},children:[_jsxruntime.jsx.call(void 0, "div",{style:Di}),_jsxruntime.jsx.call(void 0, "p",{style:{fontSize:"1.25em",fontWeight:"500",marginTop:"24px",color:"#1f2937"},children:r})]})]})}var Ki=/^[a-zA-Z0-9\-_./\?=&%#]+$/,$i=[/^https?:\/\//i,/^ftp:\/\//i,/^\/\//,/javascript:/i,/data:/i,/vbscript:/i,/about:/i,/\.\.\//,/\.\.\\/,/%2e%2e%2f/i,/%2e%2e%5c/i,/%2f%2f/i,/%5c%5c/i,/[\x00-\x1f\x7f-\x9f]/,/\\/],P= exports.validateInternalRedirect =(i,e="/")=>{if(!i||typeof i!="string")return e;let t=i.trim();if(!t)return e;if(!t.startsWith("/"))return console.warn("\u{1F6A8} Open redirect blocked (relative path):",i),e;if(!Ki.test(t))return console.warn("\u{1F6A8} Open redirect blocked (invalid characters):",i),e;let r=t.toLowerCase();for(let o of $i)if(o.test(r))return console.warn("\u{1F6A8} Open redirect blocked (dangerous pattern):",i),e;let n=t.split("?")[0].split("/").filter(Boolean);if(n.length===0)return t;for(let o of n)if(o===".."||o.includes(":")||o.length>100)return console.warn("\u{1F6A8} Open redirect blocked (suspicious path part):",o),e;return t},S= exports.extractSafeRedirectFromUrl =(i,e="/")=>{try{let r=(typeof i=="string"?new URLSearchParams(i):i).get("redirect");if(!r)return e;let n=decodeURIComponent(r);return P(n,e)}catch(t){return console.warn("\u{1F6A8} Error parsing redirect parameter:",t),e}};function N({children:i,loadingComponent:e,loginPath:t="/login"}){let{isAuthenticated:r,isLoading:n,isInitialized:o,tokens:s,error:a}=_chunk6RWBJJWLjs.j.call(void 0, ),u=_reactrouterdom.useLocation.call(void 0, );if(!o||n)return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e||_jsxruntime.jsx.call(void 0, T,{stage:"validating-session"})});let p=r&&_optionalChain([s, 'optionalAccess', _2 => _2.accessToken])&&s.accessToken.length>0;if(a||!r||!p){s&&(!s.accessToken||s.accessToken.length===0)&&localStorage.removeItem("crudify_tokens");let g=u.pathname+u.search,I=P(g),m=encodeURIComponent(I);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:`${t}?redirect=${m}`,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:i})}function O({children:i,redirectTo:e="/"}){let{isAuthenticated:t}=_chunk6RWBJJWLjs.j.call(void 0, ),r=_reactrouterdom.useLocation.call(void 0, );if(t){let n=new URLSearchParams(r.search),o=S(n,e);return _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate,{to:o,replace:!0})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:i})}var R=class i{constructor(){this.state={status:"UNINITIALIZED",priority:null,publicApiKey:null,env:null,error:null,initializedBy:null};this.initializationPromise=null;this.highPriorityInitializerPresent=!1;this.waitingForHighPriority=new Set;this.HIGH_PRIORITY_WAIT_TIMEOUT=100}static getInstance(){return i.instance||(i.instance=new i),i.instance}registerHighPriorityInitializer(){this.highPriorityInitializerPresent=!0}isHighPriorityInitializerPresent(){return this.highPriorityInitializerPresent}getState(){return{...this.state}}async initialize(e){let{priority:t,publicApiKey:r,env:n,enableLogging:o,requestedBy:s}=e;if(this.state.status==="INITIALIZED"){this.state.publicApiKey!==r&&console.warn(`[CrudifyInitialization] ${s} attempted to initialize with different key. Already initialized with key: ${_optionalChain([this, 'access', _3 => _3.state, 'access', _4 => _4.publicApiKey, 'optionalAccess', _5 => _5.slice, 'call', _6 => _6(0,10)])}... by ${this.state.initializedBy}`);return}if(this.initializationPromise)return o&&console.log(`[CrudifyInitialization] ${s} waiting for ongoing initialization...`),this.initializationPromise;if(t==="LOW"&&this.highPriorityInitializerPresent&&this.state.status==="UNINITIALIZED"){if(o&&console.log(`[CrudifyInitialization] ${s} (LOW priority) waiting for HIGH priority initializer...`),this.waitingForHighPriority.add(s),await this.waitForHighPriorityOrTimeout(o),this.waitingForHighPriority.delete(s),this.getState().status==="INITIALIZED"){o&&console.log(`[CrudifyInitialization] ${s} found initialization completed by HIGH priority`);return}o&&console.warn(`[CrudifyInitialization] ${s} timeout waiting for HIGH priority, initializing with LOW priority`)}t==="HIGH"&&this.state.status==="INITIALIZING"&&this.state.priority==="LOW"&&(console.warn(`[CrudifyInitialization] HIGH priority request from ${s} interrupting LOW priority initialization by ${this.state.initializedBy}`),this.state.status="UNINITIALIZED",this.initializationPromise=null),o&&console.log(`[CrudifyInitialization] ${s} starting initialization (${t} priority)...`),this.state.status="INITIALIZING",this.state.priority=t,this.state.initializedBy=s,this.initializationPromise=this.performInitialization(r,n,o);try{await this.initializationPromise,this.state.status="INITIALIZED",this.state.publicApiKey=r,this.state.env=n,this.state.error=null,o&&console.log(`[CrudifyInitialization] \u2705 Successfully initialized by ${s} (${t} priority)`)}catch(a){throw this.state.status="ERROR",this.state.error=a instanceof Error?a:new Error(String(a)),this.initializationPromise=null,console.error(`[CrudifyInitialization] \u274C Initialization failed for ${s}:`,a),a}}async waitForHighPriorityOrTimeout(e){return new Promise(t=>{let n=0,o=setInterval(()=>{if(n+=10,this.state.status==="INITIALIZED"&&this.state.priority==="HIGH"){clearInterval(o),t();return}if(this.state.status==="INITIALIZING"&&this.state.priority==="HIGH"){n=0;return}n>=this.HIGH_PRIORITY_WAIT_TIMEOUT&&(clearInterval(o),e&&console.log(`[CrudifyInitialization] Timeout waiting for HIGH priority (${this.HIGH_PRIORITY_WAIT_TIMEOUT}ms)`),t())},10)})}async performInitialization(e,t,r){let n=_crudifybrowser2.default.getTokenData();if(n&&n.endpoint){r&&console.log("[CrudifyInitialization] SDK already initialized externally");return}_crudifybrowser2.default.config(t);let o=r?"debug":"none",s=await _crudifybrowser2.default.init(e,o);if(s.success===!1)throw new Error(`Crudify initialization failed: ${JSON.stringify(s.errors||"Unknown error")}`)}reset(){this.state={status:"UNINITIALIZED",priority:null,publicApiKey:null,env:null,error:null,initializedBy:null},this.initializationPromise=null,this.highPriorityInitializerPresent=!1,this.waitingForHighPriority.clear()}isInitialized(){return this.state.status==="INITIALIZED"}getDiagnostics(){return{...this.state,waitingCount:this.waitingForHighPriority.size,waitingComponents:Array.from(this.waitingForHighPriority),hasActivePromise:this.initializationPromise!==null}}},x= exports.crudifyInitManager =R.getInstance();var D=_react.createContext.call(void 0, void 0),Qi= exports.CrudifyInitializer =({config:i,children:e,fallback:t=null,onInitialized:r,onError:n})=>{let[o,s]=_react.useState.call(void 0, !1),[a,u]=_react.useState.call(void 0, !1),[p,g]=_react.useState.call(void 0, null),I=_react.useRef.call(void 0, !1),m=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{I.current||(x.registerHighPriorityInitializer(),I.current=!0),m.current||(m.current=!0,(async()=>{u(!0),g(null);try{await x.initialize({priority:"HIGH",publicApiKey:i.publicApiKey,env:i.env||"stg",enableLogging:i.enableLogging,requestedBy:"CrudifyInitializer"}),s(!0),u(!1),r&&r()}catch(C){let b=C instanceof Error?C:new Error(String(C));g(b),u(!1),n&&n(b)}})())},[i.publicApiKey,i.env,i.enableLogging,r,n]);let F={isInitialized:o,isInitializing:a,error:p};return a&&t?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:t}):(p&&console.error("[CrudifyInitializer] Initialization failed:",p),_jsxruntime.jsx.call(void 0, D.Provider,{value:F,children:e}))},Xi= exports.useCrudifyInitializer =()=>{let i=_react.useContext.call(void 0, D);if(!i)throw new Error("useCrudifyInitializer must be used within CrudifyInitializer");return i};var _crudifyadmin = require('@nocios/crudify-admin'); var _crudifyadmin2 = _interopRequireDefault(_crudifyadmin);var G=!1,y=null;async function ie(){let e=_chunk6RWBJJWLjs.e.getInstance().getTokenInfo(),t=_optionalChain([e, 'optionalAccess', _7 => _7.apiEndpointAdmin]),r=_optionalChain([e, 'optionalAccess', _8 => _8.apiKeyEndpointAdmin]);return t&&r?{apiUrl:t,apiKey:r}:_chunk6RWBJJWLjs.a.waitForCredentials()}async function ee(){if(!G)return y||(y=(async()=>{try{let i=_chunk6RWBJJWLjs.e.getInstance(),{apiUrl:e,apiKey:t}=await ie();_crudifyadmin2.default.init({url:e,apiKey:t,getAdditionalHeaders:()=>{let r=i.getTokenInfo();return _optionalChain([r, 'optionalAccess', _9 => _9.crudifyTokens, 'optionalAccess', _10 => _10.accessToken])?{Authorization:`Bearer ${r.crudifyTokens.accessToken}`}:{}}}),G=!0}catch(i){throw y=null,console.error("[crudifyAdminWrapper] Initialization failed:",i),i}})(),y)}async function c(i){try{await ee();let e=await i();return!e.success&&_optionalChain([e, 'access', _11 => _11.errors, 'optionalAccess', _12 => _12.includes, 'call', _13 => _13("401")])?await _chunk6RWBJJWLjs.e.getInstance().refreshTokens()?await i():(console.error("[crudifyAdmin] Token refresh failed"),typeof window<"u"&&(window.location.href="/login"),e):e}catch(e){return console.error("[crudifyAdmin] Operation error:",e),{success:!1,errors:e instanceof Error?e.message:"Unknown error"}}}var te={listModules:()=>c(()=>_crudifyadmin2.default.listModules()),getModule:i=>c(()=>_crudifyadmin2.default.getModule(i)),createModule:i=>c(()=>_crudifyadmin2.default.createModule(i)),editModule:(i,e)=>c(()=>_crudifyadmin2.default.editModule(i,e)),deleteModule:i=>c(()=>_crudifyadmin2.default.deleteModule(i)),activateModule:i=>c(()=>_crudifyadmin2.default.activateModule(i)),deactivateModule:i=>c(()=>_crudifyadmin2.default.deactivateModule(i)),getModuleVersions:i=>c(()=>_crudifyadmin2.default.getModuleVersions(i))};exports.AuthRoute = O; exports.CRITICAL_TRANSLATIONS = _chunkUUVJCOSWjs.a; exports.CrudifyInitializationManager = R; exports.CrudifyInitializer = Qi; exports.CrudifyLogin = _chunkUUVJCOSWjs.h; exports.CrudifyProvider = _chunk6RWBJJWLjs.b; exports.CrudifyThemeProvider = Oi; exports.ERROR_CODES = _chunkYIIUEOXCjs.a; exports.ERROR_SEVERITY_MAP = _chunkYIIUEOXCjs.b; exports.GlobalNotificationProvider = _chunk6RWBJJWLjs.g; exports.LoginComponent = _chunkUUVJCOSWjs.m; exports.POLICY_ACTIONS = _chunkUUVJCOSWjs.j; exports.PREFERRED_POLICY_ORDER = _chunkUUVJCOSWjs.k; exports.Policies = _chunkUUVJCOSWjs.l; exports.ProtectedRoute = N; exports.SessionDebugInfo = _chunk6RWBJJWLjs.k; exports.SessionLoadingScreen = T; exports.SessionManager = _chunk6RWBJJWLjs.e; exports.SessionProvider = _chunk6RWBJJWLjs.i; exports.SessionStatus = _chunkUUVJCOSWjs.n; exports.TokenStorage = _chunk6RWBJJWLjs.d; exports.TranslationService = _chunkUUVJCOSWjs.d; exports.TranslationsProvider = _chunkUUVJCOSWjs.f; exports.UserProfileDisplay = _chunkUUVJCOSWjs.i; exports.createErrorTranslator = _chunkAT74WV5Wjs.e; exports.crudify = _crudifybrowser2.default; exports.crudifyAdmin = te; exports.crudifyInitManager = x; exports.decodeJwtSafely = _chunkAT74WV5Wjs.h; exports.extractSafeRedirectFromUrl = S; exports.getCookie = _chunkAT74WV5Wjs.a; exports.getCriticalLanguages = _chunkUUVJCOSWjs.b; exports.getCriticalTranslations = _chunkUUVJCOSWjs.c; exports.getCurrentUserEmail = _chunkAT74WV5Wjs.i; exports.getErrorMessage = _chunkYIIUEOXCjs.e; exports.handleCrudifyError = _chunkYIIUEOXCjs.g; exports.isTokenExpired = _chunkAT74WV5Wjs.j; exports.parseApiError = _chunkYIIUEOXCjs.c; exports.parseJavaScriptError = _chunkYIIUEOXCjs.f; exports.parseTransactionError = _chunkYIIUEOXCjs.d; exports.secureLocalStorage = _chunkNNY4A73Vjs.b; exports.secureSessionStorage = _chunkNNY4A73Vjs.a; exports.translateError = _chunkAT74WV5Wjs.d; exports.translateErrorCode = _chunkAT74WV5Wjs.b; exports.translateErrorCodes = _chunkAT74WV5Wjs.c; exports.translationService = _chunkUUVJCOSWjs.e; exports.useAuth = _chunkU6FDNJHAjs.b; exports.useCrudify = _chunk6RWBJJWLjs.c; exports.useCrudifyInitializer = Xi; exports.useCrudifyWithNotifications = _chunkU6FDNJHAjs.d; exports.useData = _chunkU6FDNJHAjs.c; exports.useGlobalNotification = _chunk6RWBJJWLjs.h; exports.useSession = _chunk6RWBJJWLjs.f; exports.useSessionContext = _chunk6RWBJJWLjs.j; exports.useTranslations = _chunkUUVJCOSWjs.g; exports.useUserData = _chunkU6FDNJHAjs.a; exports.useUserProfile = _chunk6RWBJJWLjs.l; exports.validateInternalRedirect = P;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as K,b as $,c as _,d as B,e as Z,f as W,g as V,h as Ii,i as hi,j as Pi,k as zi,l as Ri,m as xi,n as Ci}from"./chunk-
|
|
1
|
+
import{a as K,b as $,c as _,d as B,e as Z,f as W,g as V,h as Ii,i as hi,j as Pi,k as zi,l as Ri,m as xi,n as Ci}from"./chunk-PZRCUUGR.mjs";import{a as vi,b as Ti,c as Si,d as bi}from"./chunk-K4SVB2X6.mjs";import{a as E,b as q,c as Y,d as J,e as d,f as ei,g as ni,h as si,i as ai,j as f,k as li,l as mi}from"./chunk-CM6XOYDL.mjs";import{a as Ai,b as wi}from"./chunk-T2CPA46I.mjs";import{a as ci,b as ui,c as pi,d as di,e as fi,f as yi,g as gi}from"./chunk-BJ6PIVZR.mjs";import{a as v,b as Q,c as X,d as j,e as ii,h as ti,i as ri,j as oi}from"./chunk-5JKS55SE.mjs";import{default as $e}from"@nocios/crudify-browser";export*from"@nocios/crudify-browser";import{useMemo as Ei}from"react";import{ThemeProvider as Li,createTheme as Mi,CssBaseline as Ni}from"@mui/material";import{jsx as Hi,jsxs as Ui}from"react/jsx-runtime";var ki=(i={})=>{try{let e=v("theme");if(e){let t=JSON.parse(decodeURIComponent(e));return{...i,...t}}}catch(e){console.warn("Error parsing theme from cookie:",e)}return i};function Oi({children:i,defaultTheme:e={},disableCssBaseline:t=!1}){let r=Ei(()=>{let n=ki(e);return Mi(n)},[e]);return Ui(Li,{theme:r,children:[!t&&Hi(Ni,{}),i]})}import{Navigate as _i,useLocation as Bi}from"react-router-dom";import{Fragment as Fi,jsx as h,jsxs as L}from"react/jsx-runtime";var Di={border:"5px solid rgba(0, 0, 0, 0.1)",borderTopColor:"#3B82F6",borderRadius:"50%",width:"50px",height:"50px",animation:"spin 1s linear infinite"},Gi=()=>h("style",{children:`
|
|
2
2
|
@keyframes spin {
|
|
3
3
|
0% { transform: rotate(0deg); }
|
|
4
4
|
100% { transform: rotate(360deg); }
|
package/package.json
CHANGED
package/dist/chunk-IIXFLIEW.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as oo,c as X,h as no,j as ne,l as so}from"./chunk-CM6XOYDL.mjs";import{g as M}from"./chunk-BJ6PIVZR.mjs";import{a as ro,e as to}from"./chunk-5JKS55SE.mjs";var re={es:{"checkCode.codeLabel":"C\xF3digo de Verificaci\xF3n","checkCode.codePlaceholder":"Ingresa el c\xF3digo de 6 d\xEDgitos","checkCode.codeRequired":"El c\xF3digo es obligatorio","checkCode.emailLabel":"Correo Electr\xF3nico","checkCode.emailPlaceholder":"Ingresa tu correo electr\xF3nico","checkCode.emailRequired":"El correo electr\xF3nico es obligatorio","checkCode.instructions":"Ingresa el c\xF3digo de 6 d\xEDgitos que enviamos a tu correo electr\xF3nico.","checkCode.invalidEmail":"Ingresa un correo electr\xF3nico v\xE1lido","checkCode.resendCodeLink":"Reenviar c\xF3digo","checkCode.title":"Verificar C\xF3digo","checkCode.verifyButton":"Verificar C\xF3digo","common.back":"Volver","common.backToLogin":"Volver","error.app.config":"Error de Configuraci\xF3n: {{message}}","error.app.initialization":"Error durante la inicializaci\xF3n final de la aplicaci\xF3n.","error.transaction":"Error en la operaci\xF3n","error.unknown":"Ocurri\xF3 un error desconocido.","errors.DUPLICATE":"El campo <b>{{field}}</b> debe ser \xFAnico.","errors.FOREIGN_KEY_NOT_FOUND":"El campo <b>{{field}}</b> debe referenciar un \xEDtem existente.","errors.INVALID_EMAIL":"El campo <b>{{field}}</b> debe ser un correo electr\xF3nico v\xE1lido.","errors.INVALID_OBJECT_ID":"El campo <b>{{field}}</b> debe ser un valor v\xE1lido.","errors.IN_USE":"El \xEDtem est\xE1 en uso y no puede ser eliminado.","errors.MAX_LENGTH":"El campo <b>{{field}}</b> no debe exceder los <b>{{length}}</b> caracteres.","errors.MIN_LENGTH":"El campo <b>{{field}}</b> debe tener al menos <b>{{length}}</b> caracteres.","errors.MUST_NOT_BE_EMAIL":"El campo <b>{{field}}</b> no debe ser un correo electr\xF3nico.","errors.NO_PERMISSION":"No tienes permiso para realizar esta acci\xF3n.","errors.NO_SPACES":"El campo <b>{{field}}</b> no debe contener espacios.","errors.ONE_OR_MORE_OPERATIONS_FAILED":"Error en la operaci\xF3n","errors.REQUIRED":"El campo <b>{{field}}</b> es obligatorio.","errors.TOKEN_HAS_EXPIRED":"La sesi\xF3n ha expirado. Por favor, inicia sesi\xF3n nuevamente.","errors.TOO_MANY_REQUESTS":"L\xEDmite de solicitudes alcanzado. Por favor intenta m\xE1s tarde.","errors.UNAUTHORIZED":"No est\xE1s autorizado para realizar esta acci\xF3n.","errors.all_password_fields_required":"Todos los campos de contrase\xF1a son obligatorios","errors.auth.INVALID_API_KEY":"Clave de API inv\xE1lida","errors.auth.INVALID_CREDENTIALS":"Usuario y/o contrase\xF1a incorrectos","errors.auth.NO_PERMISSION":"No tienes permisos suficientes","errors.auth.SESSION_EXPIRED":"Tu sesi\xF3n ha expirado. Por favor, inicia sesi\xF3n nuevamente.","errors.auth.TOO_MANY_REQUESTS":"Demasiados intentos. Por favor espera 15 minutos e intenta nuevamente","errors.auth.UNAUTHORIZED":"No tienes permisos para realizar esta acci\xF3n","errors.auth.USER_NOT_ACTIVE":"Usuario no activo","errors.auth.USER_NOT_FOUND":"Usuario no encontrado","errors.data.BAD_REQUEST":"Solicitud inv\xE1lida","errors.data.FIELD_ERROR":"Error en los datos ingresados","errors.data.IN_USE":"El elemento est\xE1 en uso y no puede ser eliminado","errors.data.ITEM_NOT_FOUND":"El elemento solicitado no fue encontrado","errors.data.NOT_FOUND":"No se encontr\xF3 lo solicitado","errors.internal_error_changing_password":"Error interno al cambiar la contrase\xF1a. Intenta nuevamente","errors.password_min_length":"La contrase\xF1a debe tener al menos 8 caracteres","errors.password_mismatch":"Las contrase\xF1as no coinciden","errors.password_must_be_different":"La nueva contrase\xF1a debe ser diferente a la actual","errors.system.DATABASE_CONNECTION_ERROR":"Error de conexi\xF3n. Verifica tu conexi\xF3n a internet.","errors.system.INTERNAL_SERVER_ERROR":"Error interno del servidor. Intenta nuevamente.","errors.system.INVALID_CONFIGURATION":"Error de configuraci\xF3n del sistema","errors.system.TOO_MANY_REQUESTS":"Demasiadas solicitudes. Por favor espera un momento e intenta nuevamente","errors.system.UNKNOWN_OPERATION":"Operaci\xF3n no reconocida","errors.users_module_not_configured":"M\xF3dulo de usuarios no configurado","footer.copyright":"Nocios S.R.L. Todos los derechos reservados.","footer.version":"Versi\xF3n","forgotPassword.checkEmailInstructions":"Revisa tu bandeja de entrada para el c\xF3digo de verificaci\xF3n","forgotPassword.codeAlreadyExistsMessage":"Ya se envi\xF3 un c\xF3digo y a\xFAn es v\xE1lido","forgotPassword.emailLabel":"Correo Electr\xF3nico","forgotPassword.emailPlaceholder":"Ingresa tu correo electr\xF3nico","forgotPassword.emailRequired":"El correo electr\xF3nico es obligatorio","forgotPassword.emailSentMessage":"C\xF3digo enviado exitosamente","forgotPassword.enterCodeLink":"Ingresar C\xF3digo","forgotPassword.instructions":"Ingresa tu correo electr\xF3nico y te enviaremos un c\xF3digo para restablecer tu contrase\xF1a.","forgotPassword.invalidEmail":"Ingresa un correo electr\xF3nico v\xE1lido","forgotPassword.sendCodeButton":"Enviar C\xF3digo","forgotPassword.title":"Recuperar Contrase\xF1a","loading.app.configInitial":"Cargando configuraci\xF3n inicial...","loading.app.generic":"Cargando...","loading.app.starting":"Iniciando aplicaci\xF3n...","loading.app.themeSetup":"Generando tema...","loading.app.validatingSession":"Validando sesi\xF3n...","login.alreadyHaveCodeLink":"\xBFYa tienes un c\xF3digo?","login.forgotPasswordLink":"\xBFOlvidaste tu contrase\xF1a?","login.initializationError":"Error de inicializaci\xF3n","login.initializing":"Inicializando...","login.loginButton":"Iniciar Sesi\xF3n","login.logoAlt":"Logotipo","login.noAccountPrompt":"\xBFNo tienes una cuenta?","login.notInitialized":"Sistema no inicializado","login.passwordLabel":"Contrase\xF1a","login.passwordPlaceholder":"Ingresa tu contrase\xF1a","login.passwordRequired":"Contrase\xF1a es obligatoria","login.signUpLink":"Reg\xEDstrate","login.usernameOrEmailLabel":"Usuario o Correo Electr\xF3nico","login.usernameOrEmailPlaceholder":"Ingresa tu usuario o correo electr\xF3nico","login.usernameRequired":"Usuario o correo electr\xF3nico es obligatorio","resetPassword.codeExpiredOrInvalid":"El c\xF3digo ha expirado o es inv\xE1lido","resetPassword.confirmPasswordLabel":"Confirmar Contrase\xF1a","resetPassword.confirmPasswordPlaceholder":"Confirma tu nueva contrase\xF1a","resetPassword.confirmPasswordRequired":"Confirma tu contrase\xF1a","resetPassword.goToLoginButton":"Ir al Login","resetPassword.instructions":"Ingresa tu nueva contrase\xF1a.","resetPassword.invalidCode":"El c\xF3digo de verificaci\xF3n es inv\xE1lido. Por favor, verifica el enlace o solicita uno nuevo.","resetPassword.missingParameters":"Faltan par\xE1metros obligatorios","resetPassword.newPasswordLabel":"Nueva Contrase\xF1a","resetPassword.newPasswordPlaceholder":"Ingresa tu nueva contrase\xF1a","resetPassword.newPasswordRequired":"La nueva contrase\xF1a es obligatoria","resetPassword.passwordTooShort":"La contrase\xF1a debe tener al menos 8 caracteres","resetPassword.passwordsDoNotMatch":"Las contrase\xF1as no coinciden","resetPassword.requestNewCodeButton":"Solicitar Nuevo C\xF3digo","resetPassword.resetPasswordButton":"Restablecer Contrase\xF1a","resetPassword.successInstructions":"Ahora puedes iniciar sesi\xF3n con tu nueva contrase\xF1a","resetPassword.successMessage":"Contrase\xF1a restablecida exitosamente","resetPassword.title":"Nueva Contrase\xF1a","resetPassword.validatingCode":"Validando c\xF3digo..."},en:{"checkCode.codeLabel":"Verification Code","checkCode.codePlaceholder":"Enter 6-digit code","checkCode.codeRequired":"Code is required","checkCode.emailLabel":"Email Address","checkCode.emailPlaceholder":"Enter your email address","checkCode.emailRequired":"Email address is required","checkCode.instructions":"Enter the 6-digit code we sent to your email address.","checkCode.invalidEmail":"Enter a valid email address","checkCode.resendCodeLink":"Resend code","checkCode.title":"Verify Code","checkCode.verifyButton":"Verify Code","common.back":"Back","common.backToLogin":"Back to Login","error.app.config":"Configuration Error: {{message}}","error.app.initialization":"Error during final application initialization.","error.transaction":"Operation error","error.unknown":"An unknown error occurred.","errors.DUPLICATE":"The field <b>{{field}}</b> must be unique.","errors.FOREIGN_KEY_NOT_FOUND":"The field <b>{{field}}</b> must reference an existing item.","errors.INVALID_EMAIL":"The field <b>{{field}}</b> must be a valid email address.","errors.INVALID_OBJECT_ID":"The field <b>{{field}}</b> must be a valid value.","errors.IN_USE":"The item is currently in use and cannot be deleted.","errors.MAX_LENGTH":"The field <b>{{field}}</b> must not exceed <b>{{maxLength}}</b> characters.","errors.MIN_LENGTH":"The field <b>{{field}}</b> must have at least <b>{{minLength}}</b> characters.","errors.MUST_NOT_BE_EMAIL":"The field <b>{{field}}</b> must not be an email address.","errors.NO_PERMISSION":"You do not have permission to perform this action.","errors.NO_SPACES":"The field <b>{{field}}</b> must not contain spaces.","errors.ONE_OR_MORE_OPERATIONS_FAILED":"Operation error","errors.REQUIRED":"The field <b>{{field}}</b> is required.","errors.TOKEN_HAS_EXPIRED":"Your session has expired, please log in again.","errors.TOO_MANY_REQUESTS":"Request limit reached. Please try again later.","errors.UNAUTHORIZED":"You are not authorized to perform this action.","errors.all_password_fields_required":"All password fields are required","errors.auth.INVALID_API_KEY":"Invalid API key","errors.auth.INVALID_CREDENTIALS":"Incorrect username and/or password","errors.auth.NO_PERMISSION":"Insufficient permissions","errors.auth.SESSION_EXPIRED":"Your session has expired. Please log in again.","errors.auth.TOO_MANY_REQUESTS":"Too many attempts. Please wait 15 minutes and try again","errors.auth.UNAUTHORIZED":"You don't have permission to perform this action","errors.auth.USER_NOT_ACTIVE":"User account is not active","errors.auth.USER_NOT_FOUND":"User not found","errors.data.BAD_REQUEST":"Invalid request","errors.data.FIELD_ERROR":"Error in the provided data","errors.data.IN_USE":"The item is in use and cannot be deleted","errors.data.ITEM_NOT_FOUND":"The requested item was not found","errors.data.NOT_FOUND":"The requested resource was not found","errors.internal_error_changing_password":"Internal error changing password. Please try again","errors.password_min_length":"Password must be at least 8 characters","errors.password_mismatch":"Passwords do not match","errors.password_must_be_different":"New password must be different from current password","errors.system.DATABASE_CONNECTION_ERROR":"Connection error. Please check your internet connection.","errors.system.INTERNAL_SERVER_ERROR":"Internal server error. Please try again.","errors.system.INVALID_CONFIGURATION":"System configuration error","errors.system.TOO_MANY_REQUESTS":"Too many requests. Please wait a moment and try again","errors.system.UNKNOWN_OPERATION":"Unrecognized operation","errors.users_module_not_configured":"Users module not configured","footer.copyright":"Nocios S.R.L. All Rights Reserved.","footer.version":"Version","forgotPassword.checkEmailInstructions":"Check your inbox for the verification code","forgotPassword.codeAlreadyExistsMessage":"A code was already sent and is still valid","forgotPassword.emailLabel":"Email Address","forgotPassword.emailPlaceholder":"Enter your email address","forgotPassword.emailRequired":"Email address is required","forgotPassword.emailSentMessage":"Code sent successfully","forgotPassword.enterCodeLink":"Enter Code","forgotPassword.instructions":"Enter your email address and we'll send you a code to reset your password.","forgotPassword.invalidEmail":"Enter a valid email address","forgotPassword.sendCodeButton":"Send Code","forgotPassword.title":"Reset Password","loading.app.configInitial":"Loading initial configuration...","loading.app.generic":"Loading...","loading.app.starting":"Starting application...","loading.app.themeSetup":"Generating theme...","loading.app.validatingSession":"Validating session...","login.alreadyHaveCodeLink":"Already have a code?","login.forgotPasswordLink":"Forgot Password?","login.initializationError":"Initialization error","login.initializing":"Initializing...","login.loginButton":"Log In","login.logoAlt":"Logo","login.noAccountPrompt":"Don't have an account?","login.notInitialized":"System not initialized","login.passwordLabel":"Password","login.passwordPlaceholder":"Enter your password","login.passwordRequired":"Password is required","login.signUpLink":"Sign up","login.usernameOrEmailLabel":"Username or Email","login.usernameOrEmailPlaceholder":"Enter your username or email","login.usernameRequired":"Username or email is required","resetPassword.codeExpiredOrInvalid":"Code expired or invalid","resetPassword.confirmPasswordLabel":"Confirm Password","resetPassword.confirmPasswordPlaceholder":"Confirm your new password","resetPassword.confirmPasswordRequired":"Confirm your password","resetPassword.goToLoginButton":"Go to Login","resetPassword.instructions":"Enter your new password.","resetPassword.invalidCode":"The verification code is invalid. Please check the link or request a new one.","resetPassword.missingParameters":"Missing required parameters","resetPassword.newPasswordLabel":"New Password","resetPassword.newPasswordPlaceholder":"Enter your new password","resetPassword.newPasswordRequired":"New password is required","resetPassword.passwordTooShort":"Password must be at least 8 characters","resetPassword.passwordsDoNotMatch":"Passwords do not match","resetPassword.requestNewCodeButton":"Request New Code","resetPassword.resetPasswordButton":"Reset Password","resetPassword.successInstructions":"You can now log in with your new password","resetPassword.successMessage":"Password reset successfully","resetPassword.title":"New Password","resetPassword.validatingCode":"Validating code..."}},Mt=()=>Object.keys(re),Vt=e=>re[e]||re.es;import Re from"@nocios/crudify-browser";var ao="crudify_translations_",Go=3600*1e3,De=class e{constructor(){this.enableDebug=!1;this.initializationPromise=null;this.isInitialized=!1}static getInstance(){return e.instance||(e.instance=new e),e.instance}setDebug(o){this.enableDebug=o}async ensureCrudifyInitialized(o,r){if(!this.isInitialized)return this.initializationPromise?(this.enableDebug&&console.log("[TranslationService] Waiting for crudify initialization..."),this.initializationPromise):(this.enableDebug&&console.log("[TranslationService] Initializing crudify SDK..."),this.initializationPromise=(async()=>{try{let t=Re.getTokenData();if(t&&t.endpoint){this.enableDebug&&console.log("[TranslationService] Crudify already initialized"),this.isInitialized=!0;return}Re.config(r);let c=await Re.init(o,this.enableDebug?"debug":"none");if(c.success===!1)throw new Error(`Failed to initialize crudify: ${JSON.stringify(c.errors||"Unknown error")}`);this.isInitialized=!0,this.enableDebug&&console.log("[TranslationService] Crudify SDK initialized successfully")}catch(t){throw console.error("[TranslationService] Failed to initialize crudify:",t),this.initializationPromise=null,t}})(),this.initializationPromise)}async fetchTranslations(o){let{subscriberKey:r,apiKey:t,sections:c,crudifyEnv:s="stg",urlTranslations:a}=o;console.log("[TranslationService] \u{1F4E5} fetchTranslations called with:",{subscriberKey:r,crudifyEnv:s,sections:c,hasUrlTranslations:!!a,urlTranslationsKeys:a?Object.keys(a).length:0});let f=this.getFromCache(r),d=f?this.isCacheExpired(f):!0;if(console.log("[TranslationService] \u{1F4BE} Cache check:",{hasCached:!!f,isCacheExpired:d}),f&&!d){console.log("[TranslationService] \u2705 Using cached translations");let u=this.mergeWithUrlTranslations(f.data.translations,a);return console.log("[TranslationService] \u{1F504} Merged result (from cache):",{languages:Object.keys(u),sampleLang:Object.keys(u)[0],keysInSampleLang:u[Object.keys(u)[0]]?Object.keys(u[Object.keys(u)[0]]).length:0}),u}try{await this.ensureCrudifyInitialized(t,s)}catch(u){return console.error("[TranslationService] \u274C Failed to initialize crudify:",u),f?(console.warn("[TranslationService] \u26A0\uFE0F Using expired cache (init failed)"),this.mergeWithUrlTranslations(f.data.translations,a)):(console.warn("[TranslationService] \u26A0\uFE0F Using critical bundle (init failed)"),this.getCriticalTranslationsOnly())}try{console.log("[TranslationService] \u{1F310} Fetching from API via crudify SDK...");let u=await this.fetchFromAPI(c);console.log("[TranslationService] \u{1F4E6} API response received:",{subscriberKey:u.subscriberKey,languages:u.languages,translationsKeys:Object.keys(u.translations),timestamp:u.timestamp});let g=Object.keys(u.translations)[0];g&&console.log(`[TranslationService] \u{1F4CB} API translations sample (${g}):`,{totalKeys:Object.keys(u.translations[g]).length,firstFiveKeys:Object.keys(u.translations[g]).slice(0,5)}),this.hasDataChanged(f,u)||!f?(console.log("[TranslationService] \u{1F4BE} Data changed, updating cache"),this.saveToCache(r,u)):(console.log("[TranslationService] \u{1F4BE} Data unchanged, refreshing cache timestamp"),this.refreshCacheTimestamp(r));let l=this.mergeWithUrlTranslations(u.translations,a);return console.log("[TranslationService] \u{1F504} Final merged result:",{languages:Object.keys(l),sampleLang:Object.keys(l)[0],keysInSampleLang:l[Object.keys(l)[0]]?Object.keys(l[Object.keys(l)[0]]).length:0}),l}catch(u){return console.error("[TranslationService] \u274C API fetch failed:",u),f?(console.warn("[TranslationService] \u26A0\uFE0F Using expired cache as fallback"),this.mergeWithUrlTranslations(f.data.translations,a)):(console.warn("[TranslationService] \u26A0\uFE0F Using critical bundle translations"),this.getCriticalTranslationsOnly())}}async fetchFromAPI(o){let r=await Re.getTranslation(o);if(!r.success)throw new Error(`Crudify API error: ${r.errors?JSON.stringify(r.errors):"Unknown error"}`);if(!r.data)throw new Error("No translation data in response");return r.data}mergeWithUrlTranslations(o,r){if(!r||Object.keys(r).length===0)return o;let t={};return Object.keys(o).forEach(c=>{t[c]={...o[c],...r}}),t}hasDataChanged(o,r){if(!o||o.data.timestamp!==r.timestamp)return!0;let t=this.hashData(r.translations);return o.dataHash!==t}hashData(o){let r=JSON.stringify(o),t=0;for(let c=0;c<r.length;c++){let s=r.charCodeAt(c);t=(t<<5)-t+s,t=t&t}return t.toString(36)}saveToCache(o,r){try{let t=this.getCacheKey(o),c={data:r,cachedAt:Date.now(),dataHash:this.hashData(r.translations)};localStorage.setItem(t,JSON.stringify(c)),this.enableDebug&&console.log("[TranslationService] Saved to cache:",t)}catch(t){console.error("[TranslationService] Failed to save cache:",t)}}getFromCache(o){try{let r=this.getCacheKey(o),t=localStorage.getItem(r);return t?JSON.parse(t):null}catch(r){return console.error("[TranslationService] Failed to read cache:",r),null}}refreshCacheTimestamp(o){try{let r=this.getFromCache(o);if(r){r.cachedAt=Date.now();let t=this.getCacheKey(o);localStorage.setItem(t,JSON.stringify(r))}}catch(r){console.error("[TranslationService] Failed to refresh cache timestamp:",r)}}isCacheExpired(o){return Date.now()-o.cachedAt>Go}getCacheKey(o){return`${ao}${o}`}getCriticalTranslationsOnly(){return re}invalidateCache(o){let r=this.getCacheKey(o);localStorage.removeItem(r),this.enableDebug&&console.log("[TranslationService] Cache invalidated:",r)}async prefetchTranslations(o){try{await this.fetchTranslations(o),this.enableDebug&&console.log("[TranslationService] Prefetch completed")}catch(r){console.error("[TranslationService] Prefetch failed:",r)}}clearAllCaches(){try{let r=Object.keys(localStorage).filter(t=>t.startsWith(ao));r.forEach(t=>localStorage.removeItem(t)),this.enableDebug&&console.log(`[TranslationService] Cleared ${r.length} cache entries`)}catch(o){console.error("[TranslationService] Failed to clear caches:",o)}}},Be=De.getInstance();import{createContext as Jo,useContext as Qo,useEffect as lo,useState as he,useMemo as Xo,useCallback as Zo}from"react";import{jsx as or}from"react/jsx-runtime";var co=Jo(null);function io(e,o,r){return{...e,...o,...r||{}}}function er(e,o,r,t,c){lo(()=>{if(!t||!e||!o)return;let s=r||typeof window<"u"&&window.i18next||typeof window<"u"&&window.i18n;if(!s||!s.addResourceBundle){c&&console.log("[TranslationsProvider] i18next not found, skipping auto-sync");return}c&&console.log("[TranslationsProvider] Auto-syncing translations with i18next",{languages:Object.keys(e),currentLanguage:o}),Object.keys(e).forEach(a=>{e[a]&&Object.keys(e[a]).length>0&&(s.addResourceBundle(a,"translation",e[a],!0,!0),c&&console.log(`[TranslationsProvider] Synced ${Object.keys(e[a]).length} keys for language: ${a}`))}),s.language!==o&&(s.changeLanguage(o),c&&console.log(`[TranslationsProvider] Changed i18next language to: ${o}`))},[e,o,r,t,c])}var Jt=({children:e,subscriberKey:o,apiKey:r,crudifyEnv:t="stg",sections:c,language:s="es",devTranslations:a,translationUrl:f,enableDebug:d=!1,skipAutoInit:u=!0,autoSyncI18n:g=!0,i18nInstance:h})=>{let[l,n]=he({}),[i,m]=he(!0),[x,C]=he(null),[p,w]=he(void 0),[P,T]=he(!1),v=Zo(async()=>{if(P){d&&console.log("[TranslationsProvider] Skipping reload - using fallback translations");return}m(!0),C(null);let S;if(f)try{d&&console.log(`[TranslationsProvider] Fetching translations from URL: ${f}`);let I=await fetch(f);if(!I.ok)throw new Error(`Failed to fetch translations: ${I.statusText}`);S=await I.json(),w(S),d&&console.log("[TranslationsProvider] URL translations loaded:",{keysCount:S?Object.keys(S).length:0})}catch(I){console.error("[TranslationsProvider] Failed to load URL translations:",I),S=void 0,w(void 0)}try{Be.setDebug(d);let I=await Be.fetchTranslations({subscriberKey:o,apiKey:r,crudifyEnv:t,sections:c,urlTranslations:S}),V={};Object.keys(I).forEach(_=>{let oe=re[_]||{},$=I[_]||{};V[_]=io(oe,$,a)}),n(V),d&&console.log("[TranslationsProvider] Loaded translations:",{languages:Object.keys(V),keysCount:Object.keys(V[s]||{}).length})}catch(I){console.error("[TranslationsProvider] Failed to load:",I),C(I.message),T(!0);let V={};Object.keys(re).forEach(_=>{let oe=re[_],$=S||p||{};V[_]=io(oe,$,a)}),n(V),d&&console.log("[TranslationsProvider] Using fallback translations (critical + URL)")}finally{m(!1)}},[o,r,t,c,f,a,d,s,P]);lo(()=>{v();let S=setInterval(v,3600*1e3);return()=>clearInterval(S)},[v]);let y=Xo(()=>(S,I)=>{let _=(l[s]||{})[S];if(!_){let oe=Object.keys(l);for(let $ of oe)if(l[$][S]){_=l[$][S];break}}return _||(d&&console.warn(`[TranslationsProvider] Missing translation: "${S}"`),_=S),I&&typeof _=="string"&&Object.entries(I).forEach(([oe,$])=>{let O=new RegExp(`{{${oe}}}`,"g");_=_.replace(O,String($))}),_},[l,s,d]);er(l,s,h,g,d);let R={t:y,language:s,availableLanguages:Object.keys(l),translations:l,isLoading:i,error:x,refreshTranslations:v};return or(co.Provider,{value:R,children:e})},uo=()=>{let e=Qo(co);if(!e)throw new Error("useTranslations must be used within TranslationsProvider");return e};import{Box as Ur,Typography as zr}from"@mui/material";import{createContext as tr,useContext as nr,useMemo as ze}from"react";import{useState as Ue,useEffect as rr}from"react";var go=(e,o)=>{let[r,t]=Ue({}),[c,s]=Ue(!1),[a,f]=Ue(null);return rr(()=>{if(console.log("\u{1F527} [I18nProvider] Hybrid translation loading:",{hasProvidedTranslations:!!o&&Object.keys(o).length>0,hasUrl:!!e,providedKeys:o?Object.keys(o).length:0}),o&&Object.keys(o).length>0){console.log("\u2705 [I18nProvider] Using provided translations (highest priority)"),t(o),s(!1),f(null);return}if(!e){console.log("\u26A0\uFE0F [I18nProvider] No translations provided, using empty object (keys will show as-is)"),t({}),s(!1),f(null);return}console.log("\u{1F310} [I18nProvider] Loading translations from URL:",e);let d=!1;return s(!0),f(null),fetch(e).then(u=>{if(!u.ok)throw new Error(`Failed to load translations: ${u.status}`);return u.json()}).then(u=>{d||(console.log("\u2705 [I18nProvider] Translations loaded successfully from URL:",{url:e,keysLoaded:Object.keys(u).length}),t(u),s(!1))}).catch(u=>{d||(console.error("\u274C [I18nProvider] Failed to load translations from URL:",e,u),f(u.message),console.log("\u{1F504} [I18nProvider] Falling back to empty translations (keys will show as-is)"),t({}),s(!1))}),()=>{d=!0}},[e,o]),{translations:r,loading:c,error:a}};import{jsx as mo}from"react/jsx-runtime";var fo=tr(null),sr=()=>{try{return uo()}catch{return null}},ar=(e,o)=>e&&e[o]?e[o]:o.split(".").reduce((r,t)=>r&&typeof r=="object"?r[t]:void 0,e),po=({children:e,translations:o,translationsUrl:r,language:t="en"})=>{let s=sr()?.translations?.[t]||{},{translations:a,loading:f}=go(r,o),d=ze(()=>({...s,...a,...o||{}}),[s,a,o]),u=ze(()=>(h,l)=>{let n=ar(d,h);return n==null&&(console.log(`\u{1F50D} [I18nProvider] Translation not found for key: "${h}" - showing key as-is`),n=h),l&&typeof n=="string"&&Object.entries(l).forEach(([i,m])=>{n=n.replace(new RegExp(`{{${i}}}`,"g"),m)}),typeof n=="string"?n:h},[d]),g=ze(()=>({t:u,language:t}),[u,t]);return f?mo("div",{children:"Loading translations..."}):mo(fo.Provider,{value:g,children:e})},H=()=>{let e=nr(fo);if(!e)throw new Error("useTranslation must be used within I18nProvider");return e};import{createContext as ir,useContext as lr,useReducer as cr,useEffect as yo}from"react";import{jsx as ur}from"react/jsx-runtime";var ho={currentScreen:"login",searchParams:{},formData:{username:"",password:"",email:"",code:"",newPassword:"",confirmPassword:""},loading:!1,errors:{global:[]},emailSent:!1,codeAlreadyExists:!1,codeValidated:!1,fromCodeVerification:!1,config:{}};function dr(e,o){switch(o.type){case"SET_SCREEN":let r={...e,currentScreen:o.payload.screen,searchParams:o.payload.params||e.searchParams,errors:{global:[]}},t=new URLSearchParams(r.searchParams),c=t.toString()?`?${t.toString()}`:window.location.pathname;try{window.history.replaceState({},"",c)}catch{}return r;case"SET_SEARCH_PARAMS":return{...e,searchParams:o.payload};case"UPDATE_FORM_DATA":return{...e,formData:{...e.formData,...o.payload},errors:{...e.errors,...Object.keys(o.payload).reduce((s,a)=>({...s,[a]:void 0}),{})}};case"SET_LOADING":return{...e,loading:o.payload};case"SET_ERRORS":return{...e,errors:{...e.errors,...o.payload}};case"CLEAR_ERRORS":return{...e,errors:{global:[]}};case"SET_EMAIL_SENT":return{...e,emailSent:o.payload};case"SET_CODE_ALREADY_EXISTS":return{...e,codeAlreadyExists:o.payload};case"SET_CODE_VALIDATED":return{...e,codeValidated:o.payload};case"SET_FROM_CODE_VERIFICATION":return{...e,fromCodeVerification:o.payload};case"RESET_FORM":return{...e,formData:ho.formData,errors:{global:[]},loading:!1,emailSent:!1,codeAlreadyExists:!1,codeValidated:!1,fromCodeVerification:!1};case"INIT_CONFIG":return{...e,config:o.payload};default:return e}}var wo=ir(void 0),bo=({children:e,initialScreen:o="login",config:r,autoReadFromCookies:t=!0})=>{let[c,s]=cr(dr,{...ho,currentScreen:o});yo(()=>{s({type:"INIT_CONFIG",payload:(()=>{let n={};if(t)try{let i=ro("logo");if(i){let m=decodeURIComponent(i);m.startsWith("http")&&(n.logo=m)}}catch(i){console.error("Error reading configuration from cookies:",i)}return{publicApiKey:r?.publicApiKey,env:r?.env,appName:r?.appName,logo:r?.logo||n.logo,loginActions:r?.loginActions}})()})},[r,t]),yo(()=>{let l=new URLSearchParams(window.location.search),n={};l.forEach((i,m)=>{n[m]=i}),Object.keys(n).length>0&&s({type:"SET_SEARCH_PARAMS",payload:n}),o==="checkCode"&&n.email&&s({type:"UPDATE_FORM_DATA",payload:{email:n.email,code:n.code||""}}),o==="resetPassword"&&n.link&&s({type:"SET_SEARCH_PARAMS",payload:n})},[o]);let h={state:c,dispatch:s,setScreen:(l,n)=>{s({type:"SET_SCREEN",payload:{screen:l,params:n}})},updateFormData:l=>{s({type:"UPDATE_FORM_DATA",payload:l})},setFieldError:(l,n)=>{s({type:"SET_ERRORS",payload:{[l]:n}})},clearErrors:()=>{s({type:"CLEAR_ERRORS"})},setLoading:l=>{s({type:"SET_LOADING",payload:l})}};return ur(wo.Provider,{value:h,children:e})},Ie=()=>{let e=lr(wo);if(e===void 0)throw new Error("useLoginState must be used within a LoginStateProvider");return e};import{useEffect as gr,useRef as mr}from"react";import{Typography as Me,TextField as Po,Button as fr,Box as we,CircularProgress as pr,Alert as yr,Link as Co}from"@mui/material";import{Fragment as wr,jsx as K,jsxs as be}from"react/jsx-runtime";var hr=({onScreenChange:e,onExternalNavigate:o,onLoginSuccess:r,onError:t,redirectUrl:c="/"})=>{let{crudify:s}=X(),{state:a,updateFormData:f,setFieldError:d,clearErrors:u,setLoading:g}=Ie(),{login:h}=ne(),l=H(),{t:n}=l,i=l.i18n,m=mr(null),x=to(n,{currentLanguage:i?.language,enableDebug:!1}),C=()=>{if(a.searchParams.redirect)try{let y=decodeURIComponent(a.searchParams.redirect);if(y.startsWith("/")&&!y.startsWith("//"))return y}catch{}return c||"/"};gr(()=>{let y=setTimeout(()=>{m.current&&m.current.focus()},100);return()=>clearTimeout(y)},[]);let p=y=>{console.log("\u{1F50D} [LoginForm] Translating parsed error:",y);let R=x.translateError({code:y.code,message:y.message,field:y.field});return console.log("\u{1F50D} [LoginForm] Translation result:",R),R},w=async()=>{if(!a.loading){if(!a.formData.username.trim()){d("username",n("login.usernameRequired"));return}if(!a.formData.password.trim()){d("password",n("login.passwordRequired"));return}u(),g(!0);try{let y=await h(a.formData.username,a.formData.password);if(g(!1),y.success){console.log("\u{1F510} LoginForm - Login successful via SessionProvider, calling onLoginSuccess");let R=C();r&&r(y.data,R)}else{let R=y.rawResponse||y;P(R)}}catch(y){g(!1);let S=M(y).map(p);d("global",S),t&&t(S.join(", "))}}},P=y=>{M(y).forEach(S=>{if(S.field)d(S.field,p(S));else{let I=a.errors.global||[];d("global",[...I,p(S)])}})};return be(wr,{children:[be(we,{component:"form",noValidate:!0,onSubmit:y=>{y.preventDefault(),w()},onKeyDown:y=>{y.key==="Enter"&&!a.loading&&(y.preventDefault(),w())},sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[be(we,{sx:{mb:1},children:[K(Me,{variant:"body2",component:"label",htmlFor:"email",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:n("login.usernameOrEmailLabel")}),K(Po,{fullWidth:!0,id:"email",name:"email",type:"email",value:a.formData.username,disabled:a.loading,onChange:y=>f({username:y.target.value}),error:!!a.errors.username,helperText:a.errors.username,autoComplete:"email",placeholder:n("login.usernameOrEmailPlaceholder"),inputRef:m,required:!0})]}),be(we,{sx:{mb:1},children:[K(Me,{variant:"body2",component:"label",htmlFor:"password",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:n("login.passwordLabel")}),K(Po,{fullWidth:!0,id:"password",name:"password",type:"password",value:a.formData.password,disabled:a.loading,onChange:y=>f({password:y.target.value}),error:!!a.errors.password,helperText:a.errors.password,autoComplete:"current-password",placeholder:n("login.passwordPlaceholder"),required:!0})]}),a.config.loginActions?.includes("forgotPassword")&&K(we,{sx:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:K(Co,{sx:{cursor:"pointer"},onClick:()=>{e?.("forgotPassword",a.searchParams)},variant:"body2",color:"secondary",children:n("login.forgotPasswordLink")})}),K(fr,{disabled:a.loading,type:"submit",fullWidth:!0,variant:"contained",color:"primary",sx:{mt:1,mb:2},children:a.loading?K(pr,{size:20}):n("login.loginButton")})]}),K(we,{children:a.errors.global&&a.errors.global.length>0&&a.errors.global.map((y,R)=>K(yr,{variant:"filled",sx:{mt:2},severity:"error",children:K("div",{children:y})},R))}),a.config.loginActions?.includes("createUser")&&be(Me,{variant:"body2",align:"center",sx:{color:"text.secondary",mt:3},children:[n("login.noAccountPrompt")," ",K(Co,{sx:{cursor:"pointer"},onClick:()=>{let R=`/public/users/create${Object.keys(a.searchParams).length>0?`?${new URLSearchParams(a.searchParams).toString()}`:""}`;o?.(R)},fontWeight:"medium",color:"secondary",children:n("login.signUpLink")})]})]})},xo=hr;import{useState as ue}from"react";import{Typography as ge,TextField as br,Button as To,Box as se,CircularProgress as Pr,Alert as Cr,Link as Ve}from"@mui/material";import{Fragment as Eo,jsx as F,jsxs as ce}from"react/jsx-runtime";var xr=({onScreenChange:e,onError:o})=>{let{crudify:r}=X(),[t,c]=ue(""),[s,a]=ue(!1),[f,d]=ue([]),[u,g]=ue(null),[h,l]=ue(!1),[n,i]=ue(!1),{t:m}=H(),x=T=>{let v=[`errors.auth.${T.code}`,`errors.data.${T.code}`,`errors.system.${T.code}`,`errors.${T.code}`,`forgotPassword.${T.code.toLowerCase()}`];for(let y of v){let R=m(y);if(R!==y)return R}return T.message||m("error.unknown")},C=T=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(T),p=async()=>{if(!(s||!r)){if(d([]),g(null),!t){g(m("forgotPassword.emailRequired"));return}if(!C(t)){g(m("forgotPassword.invalidEmail"));return}a(!0);try{let T=[{operation:"requestPasswordReset",data:{email:t}}],v=await r.transaction(T);if(v.success)v.data&&v.data.existingCodeValid?i(!0):l(!0);else{let R=M(v).map(x);d(R)}}catch(T){let y=M(T).map(x);d(y),o&&o(y.join(", "))}finally{a(!1)}}},w=()=>{e?.("login")},P=()=>{if(h||n){e?.("checkCode",{email:t});return}if(!t){g(m("forgotPassword.emailRequired"));return}if(!C(t)){g(m("forgotPassword.invalidEmail"));return}e?.("checkCode",{email:t})};return h||n?F(Eo,{children:ce(se,{sx:{width:"100%",display:"flex",flexDirection:"column",gap:2,textAlign:"center"},children:[ce(se,{sx:{mb:2},children:[F(ge,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:m(n?"forgotPassword.codeAlreadyExistsMessage":"forgotPassword.emailSentMessage")}),F(ge,{variant:"body2",sx:{color:n?"success.main":"grey.600"},children:m("forgotPassword.checkEmailInstructions")})]}),F(To,{type:"button",onClick:P,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:m("forgotPassword.enterCodeLink")}),F(se,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:F(Ve,{sx:{cursor:"pointer"},onClick:w,variant:"body2",color:"secondary",children:m("common.back")})})]})}):ce(Eo,{children:[ce(se,{component:"form",noValidate:!0,sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[ce(se,{sx:{mb:2},children:[F(ge,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:m("forgotPassword.title")}),F(ge,{variant:"body2",sx:{color:"grey.600"},children:m("forgotPassword.instructions")})]}),ce(se,{sx:{mb:1},children:[F(ge,{variant:"body2",component:"label",htmlFor:"email",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:m("forgotPassword.emailLabel")}),F(br,{fullWidth:!0,id:"email",name:"email",type:"email",value:t,disabled:s,onChange:T=>c(T.target.value),error:!!u,helperText:u,autoComplete:"email",placeholder:m("forgotPassword.emailPlaceholder"),required:!0})]}),F(To,{disabled:s,type:"button",onClick:p,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:s?F(Pr,{size:20}):m("forgotPassword.sendCodeButton")}),ce(se,{sx:{display:"flex",justifyContent:"center",alignItems:"center",gap:2},children:[F(Ve,{sx:{cursor:"pointer"},onClick:w,variant:"body2",color:"secondary",children:m("common.back")}),F(ge,{variant:"body2",sx:{color:"grey.400"},children:"\u2022"}),F(Ve,{sx:{cursor:"pointer"},onClick:P,variant:"body2",color:"secondary",children:m("login.alreadyHaveCodeLink")})]})]}),F(se,{children:f.length>0&&f.map((T,v)=>F(Cr,{variant:"filled",sx:{mt:2},severity:"error",children:T},v))})]})},vo=xr;import{useState as j,useEffect as So}from"react";import{Typography as Le,TextField as Ro,Button as Tr,Box as ae,CircularProgress as Io,Alert as Lo,Link as Er}from"@mui/material";import{Fragment as Sr,jsx as D,jsxs as Pe}from"react/jsx-runtime";var vr=({onScreenChange:e,onError:o,searchParams:r,onResetSuccess:t})=>{let{crudify:c}=X(),[s,a]=j(""),[f,d]=j(""),[u,g]=j(!1),[h,l]=j([]),[n,i]=j(null),[m,x]=j(null),[C,p]=j(""),[w,P]=j(""),[T,v]=j(!1),[y,R]=j(!0),[S,I]=j(!1),[V,_]=j(null),[oe,$]=j(!1),{t:O}=H(),ve=E=>{let L=[`errors.auth.${E.code}`,`errors.data.${E.code}`,`errors.system.${E.code}`,`errors.${E.code}`,`resetPassword.${E.code.toLowerCase()}`];for(let z of L){let W=O(z);if(W!==z)return W}return E.message||O("error.unknown")},Se=E=>r?r instanceof URLSearchParams?r.get(E):r[E]||null:null;So(()=>{if(r){if(r){let E=Se("fromCodeVerification"),L=Se("email"),z=Se("code");if(E==="true"&&L&&z){p(L),P(z),v(!0),I(!0),R(!1);return}let W=Se("link");if(W)try{let Y=decodeURIComponent(W),[G,ye]=Y.split("/");if(G&&ye&&G.length===6){P(G),p(ye),v(!1),_({email:ye,code:G});return}}catch{}if(L&&z){p(L),P(z),v(!1),_({email:L,code:z});return}}l([O("resetPassword.invalidCode")]),R(!1),setTimeout(()=>e?.("forgotPassword"),3e3)}},[r,c,O,e]),So(()=>{c&&V&&!oe&&($(!0),(async(L,z)=>{try{let W=[{operation:"validatePasswordResetCode",data:{email:L,codePassword:z}}],Y=await c.transaction(W);if(Y.data&&Array.isArray(Y.data)){let G=Y.data[0];if(G&&G.response&&G.response.status==="OK"){I(!0);return}}if(Y.success)I(!0);else{let ye=M(Y).map(ve);l(ye),setTimeout(()=>e?.("forgotPassword"),3e3)}}catch(W){let G=M(W).map(ve);l(G),setTimeout(()=>e?.("forgotPassword"),3e3)}finally{R(!1),_(null),$(!1)}})(V.email,V.code))},[c,V,O,e]);let Ko=E=>E.length<8?O("resetPassword.passwordTooShort"):null,$o=async()=>{if(u||!c)return;l([]),i(null),x(null);let E=!1;if(!s)i(O("resetPassword.newPasswordRequired")),E=!0;else{let L=Ko(s);L&&(i(L),E=!0)}if(f?s!==f&&(x(O("resetPassword.passwordsDoNotMatch")),E=!0):(x(O("resetPassword.confirmPasswordRequired")),E=!0),!E){g(!0);try{let L=[{operation:"validateAndResetPassword",data:{email:C,codePassword:w,newPassword:s}}],z=await c.transaction(L);if(z.success)l([]),setTimeout(()=>{t?.()},1e3);else{let Y=M(z).map(ve);l(Y)}}catch(L){let W=M(L).map(ve);l(W),o&&o(W.join(", "))}g(!1)}},Yo=()=>{T?e?.("checkCode",{email:C}):e?.("forgotPassword")};return y?D(ae,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"300px"},children:D(Io,{})}):S?Pe(Sr,{children:[Pe(ae,{component:"form",noValidate:!0,sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[Pe(ae,{sx:{mb:2},children:[D(Le,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:O("resetPassword.title")}),D(Le,{variant:"body2",sx:{color:"grey.600"},children:O("resetPassword.instructions")})]}),Pe(ae,{sx:{mb:1},children:[D(Le,{variant:"body2",component:"label",htmlFor:"newPassword",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:O("resetPassword.newPasswordLabel")}),D(Ro,{fullWidth:!0,id:"newPassword",name:"newPassword",type:"password",value:s,disabled:u,onChange:E=>a(E.target.value),error:!!n,helperText:n,autoComplete:"new-password",placeholder:O("resetPassword.newPasswordPlaceholder"),required:!0})]}),Pe(ae,{sx:{mb:1},children:[D(Le,{variant:"body2",component:"label",htmlFor:"confirmPassword",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:O("resetPassword.confirmPasswordLabel")}),D(Ro,{fullWidth:!0,id:"confirmPassword",name:"confirmPassword",type:"password",value:f,disabled:u,onChange:E=>d(E.target.value),error:!!m,helperText:m,autoComplete:"new-password",placeholder:O("resetPassword.confirmPasswordPlaceholder"),required:!0})]}),D(Tr,{disabled:u,type:"button",onClick:$o,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:u?D(Io,{size:20}):O("resetPassword.resetPasswordButton")}),D(ae,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:D(Er,{sx:{cursor:"pointer"},onClick:Yo,variant:"body2",color:"secondary",children:O("common.back")})})]}),D(ae,{children:h.length>0&&h.map((E,L)=>D(Lo,{variant:"filled",sx:{mt:2},severity:"error",children:E},L))})]}):D(ae,{children:h.length>0&&h.map((E,L)=>D(Lo,{variant:"filled",sx:{mt:2},severity:"error",children:E},L))})},ko=vr;import{useState as Ce,useEffect as Rr}from"react";import{Typography as We,TextField as Ir,Button as Lr,Box as xe,CircularProgress as kr,Alert as Ar,Link as _r}from"@mui/material";import{Fragment as Nr,jsx as Z,jsxs as ke}from"react/jsx-runtime";var Or=({onScreenChange:e,onError:o,searchParams:r})=>{let{crudify:t}=X(),[c,s]=Ce(""),[a,f]=Ce(!1),[d,u]=Ce([]),[g,h]=Ce(null),[l,n]=Ce(""),{t:i}=H(),m=P=>r?r instanceof URLSearchParams?r.get(P):r[P]||null:null,x=P=>{let T=[`errors.auth.${P.code}`,`errors.data.${P.code}`,`errors.system.${P.code}`,`errors.${P.code}`,`checkCode.${P.code.toLowerCase()}`];for(let v of T){let y=i(v);if(y!==v)return y}return P.message||i("error.unknown")};Rr(()=>{let P=m("email");P?n(P):e?.("forgotPassword")},[r,e]);let C=async()=>{if(!(a||!t)){if(u([]),h(null),!c){h(i("checkCode.codeRequired"));return}if(c.length!==6){h(i("checkCode.codeRequired"));return}f(!0);try{let P=[{operation:"validatePasswordResetCode",data:{email:l,codePassword:c}}],T=await t.transaction(P);if(T.success)e?.("resetPassword",{email:l,code:c,fromCodeVerification:"true"});else{let y=M(T).map(x);u(y),f(!1)}}catch(P){let v=M(P).map(x);u(v),f(!1),o&&o(v.join(", "))}}},p=()=>{e?.("forgotPassword")},w=P=>{let T=P.target.value.replace(/\D/g,"").slice(0,6);s(T)};return ke(Nr,{children:[ke(xe,{component:"form",noValidate:!0,sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[ke(xe,{sx:{mb:2},children:[Z(We,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:i("checkCode.title")}),Z(We,{variant:"body2",sx:{color:"grey.600"},children:i("checkCode.instructions")})]}),ke(xe,{sx:{mb:1},children:[Z(We,{variant:"body2",component:"label",htmlFor:"code",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:i("checkCode.codeLabel")}),Z(Ir,{fullWidth:!0,id:"code",name:"code",type:"text",value:c,disabled:a,onChange:w,error:!!g,helperText:g,placeholder:i("checkCode.codePlaceholder"),inputProps:{maxLength:6,style:{textAlign:"center",fontSize:"1.5rem",letterSpacing:"0.4rem"}},required:!0})]}),Z(Lr,{disabled:a||c.length!==6,type:"button",onClick:C,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:a?Z(kr,{size:20}):i("checkCode.verifyButton")}),Z(xe,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:Z(_r,{sx:{cursor:"pointer"},onClick:p,variant:"body2",color:"secondary",children:i("common.back")})})]}),Z(xe,{children:d.length>0&&d.map((P,T)=>Z(Ar,{sx:{mt:2},severity:"error",children:P},T))})]})},Ao=Or;import{Box as Fr,CircularProgress as Dr,Alert as _o,Typography as je}from"@mui/material";import{Fragment as Br,jsx as me,jsxs as Oo}from"react/jsx-runtime";var No=({children:e,fallback:o})=>{let{isLoading:r,error:t,isInitialized:c}=X(),{t:s}=H();return r?o||Oo(Fr,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"200px",gap:2},children:[me(Dr,{}),me(je,{variant:"body2",color:"text.secondary",children:s("login.initializing")!=="login.initializing"?s("login.initializing"):"Initializing..."})]}):t?me(_o,{severity:"error",sx:{mt:2},children:Oo(je,{variant:"body2",children:[s("login.initializationError")!=="login.initializationError"?s("login.initializationError"):"Initialization error",":"," ",t]})}):c?me(Br,{children:e}):me(_o,{severity:"warning",sx:{mt:2},children:me(je,{variant:"body2",children:s("login.notInitialized")!=="login.notInitialized"?s("login.notInitialized"):"System not initialized"})})};import{jsx as J,jsxs as Wr}from"react/jsx-runtime";var Mr=({onScreenChange:e,onExternalNavigate:o,onLoginSuccess:r,onError:t,redirectUrl:c="/"})=>{let{t:s}=H(),{state:a,setScreen:f}=Ie(),{config:d}=ne(),{showNotification:u}=no(),g=(l,n)=>{let i=n;l==="login"?i={}:l==="forgotPassword"&&!n&&(i={}),f(l,i),e?.(l,i)},h=()=>{let l={onScreenChange:g,onExternalNavigate:o,onError:t,redirectUrl:c};switch(a.currentScreen){case"forgotPassword":return J(vo,{...l});case"checkCode":return J(Ao,{...l,searchParams:a.searchParams});case"resetPassword":return J(ko,{...l,searchParams:a.searchParams,onResetSuccess:()=>{let n=s("resetPassword.successMessage");u(n,"success"),g("login")}});default:return J(xo,{...l,onLoginSuccess:r})}};return Wr(No,{children:[J(Ur,{sx:{display:"flex",justifyContent:"center",mb:3},children:J("img",{src:d.logo||"https://logos.crudia.com/nocios-default.png",alt:s("login.logoAlt"),style:{width:"100%",maxWidth:"150px",height:"auto"},onError:l=>{let n=l.target;n.src="https://logos.crudia.com/nocios-default.png"}})}),!d.logo&&d.appName&&J(zr,{variant:"h6",component:"h1",sx:{textAlign:"center",mb:2},children:d.appName}),h()]})},Vr=({translations:e,translationsUrl:o,language:r="en",initialScreen:t="login",autoReadFromCookies:c=!0,...s})=>{let{config:a}=ne();return J(po,{translations:e,translationsUrl:o,language:r,children:J(oo,{config:a,children:J(bo,{config:a,initialScreen:t,autoReadFromCookies:c,children:J(Mr,{...s})})})})},as=Vr;import{Box as q,Card as Fo,CardContent as Do,Typography as Q,Chip as Ae,Avatar as jr,Divider as qr,CircularProgress as Hr,Alert as Bo,List as Kr,ListItem as qe,ListItemText as He,ListItemIcon as $r,Collapse as Yr,IconButton as Ke}from"@mui/material";import{Person as Gr,Email as Jr,Badge as Qr,Security as Xr,Schedule as Zr,AccountCircle as et,ExpandMore as ot,ExpandLess as rt,Info as tt}from"@mui/icons-material";import{useState as nt}from"react";import{Fragment as it,jsx as b,jsxs as k}from"react/jsx-runtime";var st=({showExtendedData:e=!0,showProfileCard:o=!0,autoRefresh:r=!0})=>{let{userProfile:t,loading:c,error:s,extendedData:a,refreshProfile:f}=so({autoFetch:r,retryOnError:!0,maxRetries:3}),[d,u]=nt(!1);if(c)return k(q,{display:"flex",justifyContent:"center",alignItems:"center",p:3,children:[b(Hr,{}),b(Q,{variant:"body2",sx:{ml:2},children:"Cargando perfil de usuario..."})]});if(s)return k(Bo,{severity:"error",action:b(Ke,{color:"inherit",size:"small",onClick:f,children:b(Q,{variant:"caption",children:"Reintentar"})}),children:["Error al cargar el perfil: ",s]});if(!t)return b(Bo,{severity:"warning",children:"No se encontr\xF3 informaci\xF3n del usuario"});let g=a?.displayData||{},h=a?.totalFields||0,l=p=>{if(!p)return"No disponible";try{return new Date(p).toLocaleString("es-ES",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return p}},n=(p,w)=>w==null?"No disponible":typeof w=="boolean"?w?"S\xED":"No":Array.isArray(w)?w.length>0?w.join(", "):"Ninguno":typeof w=="object"?JSON.stringify(w,null,2):String(w),i=[{key:"id",label:"ID",icon:b(Qr,{})},{key:"email",label:"Email",icon:b(Jr,{})},{key:"username",label:"Usuario",icon:b(Gr,{})},{key:"fullName",label:"Nombre completo",icon:b(et,{})},{key:"role",label:"Rol",icon:b(Xr,{})}],m=[{key:"firstName",label:"Nombre"},{key:"lastName",label:"Apellido"},{key:"isActive",label:"Activo"},{key:"lastLogin",label:"\xDAltimo login"},{key:"createdAt",label:"Creado"},{key:"updatedAt",label:"Actualizado"}],x=[...i.map(p=>p.key),...m.map(p=>p.key),"permissions"],C=Object.keys(g).filter(p=>!x.includes(p)).map(p=>({key:p,label:p}));return k(q,{children:[o&&b(Fo,{sx:{mb:2},children:k(Do,{children:[k(q,{display:"flex",alignItems:"center",mb:2,children:[b(jr,{src:g.avatar,sx:{width:56,height:56,mr:2},children:g.fullName?.[0]||g.username?.[0]||g.email?.[0]}),k(q,{children:[b(Q,{variant:"h6",children:g.fullName||g.username||g.email}),b(Q,{variant:"body2",color:"text.secondary",children:g.role||"Usuario"}),g.isActive!==void 0&&b(Ae,{label:g.isActive?"Activo":"Inactivo",color:g.isActive?"success":"error",size:"small",sx:{mt:.5}})]})]}),b(q,{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(250px, 1fr))",gap:2,children:i.map(({key:p,label:w,icon:P})=>g[p]?k(q,{display:"flex",alignItems:"center",children:[b(q,{sx:{mr:1,color:"text.secondary"},children:P}),k(q,{children:[b(Q,{variant:"caption",color:"text.secondary",children:w}),b(Q,{variant:"body2",children:n(p,g[p])})]})]},p):null)}),g.permissions&&Array.isArray(g.permissions)&&g.permissions.length>0&&k(q,{mt:2,children:[b(Q,{variant:"caption",color:"text.secondary",display:"block",children:"Permisos"}),k(q,{display:"flex",flexWrap:"wrap",gap:.5,mt:.5,children:[g.permissions.slice(0,5).map((p,w)=>b(Ae,{label:p,size:"small",variant:"outlined"},w)),g.permissions.length>5&&b(Ae,{label:`+${g.permissions.length-5} m\xE1s`,size:"small"})]})]})]})}),e&&b(Fo,{children:k(Do,{children:[k(q,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[k(Q,{variant:"h6",display:"flex",alignItems:"center",children:[b(tt,{sx:{mr:1}}),"Informaci\xF3n Detallada"]}),b(Ae,{label:`${h} campos totales`,size:"small"})]}),k(Kr,{dense:!0,children:[m.map(({key:p,label:w})=>g[p]!==void 0&&k(qe,{divider:!0,children:[b($r,{children:b(Zr,{fontSize:"small"})}),b(He,{primary:w,secondary:p.includes("At")||p.includes("Login")?l(g[p]):n(p,g[p])})]},p)),C.length>0&&k(it,{children:[b(qr,{sx:{my:1}}),b(qe,{children:b(He,{primary:k(q,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[k(Q,{variant:"subtitle2",children:["Campos Personalizados (",C.length,")"]}),b(Ke,{size:"small",onClick:()=>u(!d),children:d?b(rt,{}):b(ot,{})})]})})}),b(Yr,{in:d,children:C.map(({key:p,label:w})=>b(qe,{sx:{pl:4},children:b(He,{primary:w,secondary:n(p,g[p])})},p))})]})]}),k(q,{mt:2,display:"flex",justifyContent:"space-between",alignItems:"center",children:[k(Q,{variant:"caption",color:"text.secondary",children:["\xDAltima actualizaci\xF3n: ",l(g.updatedAt)]}),b(Ke,{size:"small",onClick:f,disabled:c,children:b(Q,{variant:"caption",children:"Actualizar"})})]})]})})]})},at=st;var Uo=["create","read","update","delete"],zo=["create","read","update","delete"];import{useRef as At}from"react";import{useTranslation as _t}from"react-i18next";import{Box as Oe,Typography as jo,Button as Ot,Stack as Nt,Alert as qo,Divider as Ft}from"@mui/material";import{Add as Dt}from"@mui/icons-material";import{forwardRef as wt}from"react";import{useTranslation as bt}from"react-i18next";import{Box as de,FormControl as Pt,InputLabel as Ct,Select as xt,MenuItem as Tt,IconButton as Et,Typography as fe,FormHelperText as vt,Stack as _e,Paper as Wo,Divider as St,Button as Qe}from"@mui/material";import{Delete as Rt,SelectAll as It,ClearAll as Lt}from"@mui/icons-material";import{useState as lt,useEffect as ct,useRef as dt}from"react";import{useTranslation as ut}from"react-i18next";import{Box as $e,Typography as Te,Button as Mo,Stack as Ye,FormHelperText as Vo,ToggleButton as Ge,ToggleButtonGroup as gt}from"@mui/material";import{CheckCircle as mt,Cancel as ft,SelectAll as pt,ClearAll as yt}from"@mui/icons-material";import{jsx as B,jsxs as ie}from"react/jsx-runtime";var ht=({value:e,onChange:o,availableFields:r,error:t,disabled:c=!1})=>{let{t:s}=ut(),[a,f]=lt("custom"),d=dt(!1);ct(()=>{let n=e||{allow:[],owner_allow:[],deny:[]},i=new Set(r),m=(n.allow||[]).filter(w=>i.has(w)),x=(n.owner_allow||[]).filter(w=>i.has(w)),C=(n.deny||[]).filter(w=>i.has(w));r.forEach(w=>{!m.includes(w)&&!x.includes(w)&&!C.includes(w)&&C.push(w)});let p={allow:m,owner_allow:x,deny:C};JSON.stringify(p)!==JSON.stringify(n)&&o(p),m.length===r.length?f("all"):C.length===r.length?f("none"):f("custom")},[r,e]);let u=()=>{d.current=!0,o({allow:[...r],owner_allow:[],deny:[]}),f("all"),setTimeout(()=>{d.current=!1},0)},g=()=>{d.current=!0,o({allow:[],owner_allow:[],deny:[...r]}),f("none"),setTimeout(()=>{d.current=!1},0)},h=n=>e?.allow?.includes(n)?"allow":e?.owner_allow?.includes(n)?"owner_allow":"deny",l=(n,i)=>{d.current=!0;let m=new Set(e?.allow||[]),x=new Set(e?.owner_allow||[]),C=new Set(e?.deny||[]);m.delete(n),x.delete(n),C.delete(n),i==="allow"&&m.add(n),i==="owner_allow"&&x.add(n),i==="deny"&&C.add(n),o({allow:Array.from(m),owner_allow:Array.from(x),deny:Array.from(C)}),f("custom"),setTimeout(()=>{d.current=!1},0)};return r.length===0?ie($e,{children:[B(Te,{variant:"body2",color:"text.secondary",sx:{mb:1},children:s("modules.form.publicPolicies.fields.conditions.label")}),B(Te,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic"},children:s("modules.form.publicPolicies.fields.conditions.noFieldsAvailable")}),t&&B(Vo,{error:!0,sx:{mt:1},children:t})]}):ie($e,{children:[B(Te,{variant:"body2",color:"text.secondary",sx:{mb:2},children:s("modules.form.publicPolicies.fields.conditions.label")}),ie(Ye,{direction:"row",spacing:1,sx:{mb:3},children:[B(Mo,{variant:a==="all"?"contained":"outlined",startIcon:B(pt,{}),onClick:u,disabled:c,size:"small",sx:{minWidth:120,...a==="all"&&{backgroundColor:"#16a34a","&:hover":{backgroundColor:"#15803d"}}},children:s("modules.form.publicPolicies.fields.conditions.allFields")}),B(Mo,{variant:a==="none"?"contained":"outlined",startIcon:B(yt,{}),onClick:g,disabled:c,size:"small",sx:{minWidth:120,...a==="none"&&{backgroundColor:"#cf222e","&:hover":{backgroundColor:"#bc1f2c"}}},children:s("modules.form.publicPolicies.fields.conditions.noFields")})]}),ie($e,{sx:{p:2,border:"1px solid #d1d9e0",borderRadius:1,backgroundColor:"#f6f8fa"},children:[B(Te,{variant:"body2",color:"text.secondary",sx:{mb:2},children:s("modules.form.publicPolicies.fields.conditions.help")}),B(Ye,{spacing:1,children:r.map(n=>{let i=h(n);return ie(Ye,{direction:"row",spacing:1,alignItems:"center",children:[B(Te,{variant:"body2",sx:{minWidth:100,fontFamily:"monospace"},children:n}),ie(gt,{value:i,exclusive:!0,size:"small",children:[ie(Ge,{value:"allow",onClick:()=>l(n,"allow"),disabled:c,sx:{px:2,color:i==="allow"?"#ffffff":"#6b7280",backgroundColor:i==="allow"?"#16a34a":"#f3f4f6",borderColor:i==="allow"?"#16a34a":"#d1d5db","&:hover":{backgroundColor:i==="allow"?"#15803d":"#e5e7eb",borderColor:i==="allow"?"#15803d":"#9ca3af"},"&.Mui-selected":{backgroundColor:"#16a34a",color:"#ffffff","&:hover":{backgroundColor:"#15803d"}}},children:[B(mt,{sx:{fontSize:16,mr:.5}}),s("modules.form.publicPolicies.fields.conditions.states.allow")]}),B(Ge,{value:"owner_allow",onClick:()=>l(n,"owner_allow"),disabled:c,sx:{px:2,color:i==="owner_allow"?"#ffffff":"#6b7280",backgroundColor:i==="owner_allow"?"#0ea5e9":"#f3f4f6",borderColor:i==="owner_allow"?"#0ea5e9":"#d1d5db","&:hover":{backgroundColor:i==="owner_allow"?"#0284c7":"#e5e7eb",borderColor:i==="owner_allow"?"#0284c7":"#9ca3af"},"&.Mui-selected":{backgroundColor:"#0ea5e9",color:"#ffffff","&:hover":{backgroundColor:"#0284c7"}}},children:s("modules.form.publicPolicies.fields.conditions.states.ownerAllow")}),ie(Ge,{value:"deny",onClick:()=>l(n,"deny"),disabled:c,sx:{px:2,color:i==="deny"?"#ffffff":"#6b7280",backgroundColor:i==="deny"?"#dc2626":"#f3f4f6",borderColor:i==="deny"?"#dc2626":"#d1d5db","&:hover":{backgroundColor:i==="deny"?"#b91c1c":"#e5e7eb",borderColor:i==="deny"?"#b91c1c":"#9ca3af"},"&.Mui-selected":{backgroundColor:"#dc2626",color:"#ffffff","&:hover":{backgroundColor:"#b91c1c"}}},children:[B(ft,{sx:{fontSize:16,mr:.5}}),s("modules.form.publicPolicies.fields.conditions.states.deny")]})]})]},n)})})]}),t&&B(Vo,{error:!0,sx:{mt:1},children:t})]})},Je=ht;import{jsx as N,jsxs as U}from"react/jsx-runtime";var kt=wt(({policy:e,onChange:o,onRemove:r,availableFields:t,isSubmitting:c=!1,usedActions:s,error:a},f)=>{let{t:d}=bt(),u=new Set(Array.from(s||[]));u.delete(e.action);let g=Uo.map(h=>({value:h,label:d(`modules.form.publicPolicies.fields.action.options.${h}`)}));return U(Wo,{ref:f,sx:{p:3,border:"1px solid #d1d9e0",borderRadius:2,position:"relative",backgroundColor:"#ffffff"},children:[U(de,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:3},children:[N(fe,{variant:"subtitle1",sx:{fontWeight:600,color:"#111418",fontSize:"1rem"},children:d("modules.form.publicPolicies.policyTitle")}),N(Et,{onClick:r,size:"small",disabled:c,"aria-label":d("modules.form.publicPolicies.removePolicy"),sx:{color:"#656d76","&:hover":{color:"#cf222e",backgroundColor:"rgba(207, 34, 46, 0.1)"}},children:N(Rt,{})})]}),U(_e,{spacing:3,children:[N(_e,{direction:{xs:"column",md:"row"},spacing:2,children:N(de,{sx:{flex:1,minWidth:200},children:U(Pt,{fullWidth:!0,children:[N(Ct,{children:d("modules.form.publicPolicies.fields.action.label")}),N(xt,{value:e.action,label:d("modules.form.publicPolicies.fields.action.label"),disabled:c,onChange:h=>{let l=h.target.value,n={...e,action:l};l==="delete"?(n.permission="deny",delete n.fields):(n.fields={allow:[],owner_allow:[],deny:t},delete n.permission),o(n)},sx:{backgroundColor:"#ffffff","&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"#8c959f"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"#0969da",borderWidth:2}},children:g.map(h=>{let l=u.has(h.value);return N(Tt,{value:h.value,disabled:l,children:h.label},h.value)})}),a&&N(vt,{error:!0,children:a})]})})}),e.action==="delete"?U(de,{children:[N(fe,{variant:"body2",color:"text.secondary",sx:{mb:2},children:d("modules.form.publicPolicies.fields.conditions.label")}),U(_e,{direction:"row",spacing:1,sx:{mb:3},children:[N(Qe,{variant:e.permission==="*"?"contained":"outlined",startIcon:N(It,{}),onClick:()=>o({...e,permission:"*"}),disabled:c,size:"small",sx:{minWidth:140,whiteSpace:"nowrap",...e.permission==="*"&&{backgroundColor:"#16a34a","&:hover":{backgroundColor:"#15803d"}}},children:d("modules.form.publicPolicies.fields.conditions.allFields")}),N(Qe,{variant:e.permission==="owner"?"contained":"outlined",onClick:()=>o({...e,permission:"owner"}),disabled:c,size:"small",sx:{minWidth:140,whiteSpace:"nowrap",...e.permission==="owner"&&{backgroundColor:"#0ea5e9","&:hover":{backgroundColor:"#0284c7"}}},children:d("modules.form.publicPolicies.fields.conditions.states.ownerAllow")}),N(Qe,{variant:e.permission==="deny"?"contained":"outlined",startIcon:N(Lt,{}),onClick:()=>o({...e,permission:"deny"}),disabled:c,size:"small",sx:{minWidth:140,whiteSpace:"nowrap",...e.permission==="deny"&&{backgroundColor:"#cf222e","&:hover":{backgroundColor:"#bc1f2c"}}},children:d("modules.form.publicPolicies.fields.conditions.noFields")})]})]}):N(Je,{value:e.fields||{allow:[],owner_allow:[],deny:[]},onChange:h=>o({...e,fields:h}),availableFields:t,disabled:c}),N(Wo,{variant:"outlined",sx:{p:2,backgroundColor:"#f9fafb"},children:e.action==="delete"?U(fe,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[U(de,{component:"span",sx:{color:e.permission==="*"?"#16a34a":e.permission==="owner"?"#0ea5e9":"#dc2626"},children:[d("modules.form.publicPolicies.fields.conditions.states.allow"),":"]})," ",e.permission||"-"]}):U(_e,{spacing:.5,divider:N(St,{sx:{borderColor:"#e5e7eb"}}),children:[U(fe,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[U(de,{component:"span",sx:{color:"#16a34a"},children:[d("modules.form.publicPolicies.fields.conditions.states.allow"),":"]})," ",(e?.fields?.allow||[]).join(", ")||"-"]}),U(fe,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[U(de,{component:"span",sx:{color:"#0ea5e9"},children:[d("modules.form.publicPolicies.fields.conditions.states.ownerAllow"),":"]})," ",(e?.fields?.owner_allow||[]).join(", ")||"-"]}),U(fe,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[U(de,{component:"span",sx:{color:"#dc2626"},children:[d("modules.form.publicPolicies.fields.conditions.states.deny"),":"]})," ",(e?.fields?.deny||[]).join(", ")||"-"]})]})})]})]})}),Xe=kt;import{Fragment as zt,jsx as ee,jsxs as Ne}from"react/jsx-runtime";var Bt=()=>{let e=globalThis?.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`},Ut=({policies:e,onChange:o,availableFields:r,errors:t,isSubmitting:c=!1})=>{let{t:s}=_t(),a=At({}),f=new Set((e||[]).map(i=>i.action).filter(Boolean)),d=zo.filter(i=>!f.has(i)),u=d.length>0,g=()=>{let i=d[0]||"create",m={id:Bt(),action:i};i==="delete"?m.permission="deny":m.fields={allow:[],owner_allow:[],deny:r};let x=[...e||[],m];o(x),setTimeout(()=>{let C=x.length-1,p=a.current[C];p&&p.scrollIntoView({behavior:"smooth",block:"center"})},100)},h=i=>{let m=[...e];m.splice(i,1),o(m)},l=(()=>{if(!t)return null;if(typeof t=="string")return t;let i=t._error;return typeof i=="string"?i:null})(),n=new Set((e||[]).map(i=>i.action));return Ne(zt,{children:[ee(Ft,{sx:{borderColor:"#e0e4e7"}}),Ne(Oe,{children:[ee(Oe,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3,children:Ne(Oe,{children:[ee(jo,{variant:"h6",sx:{fontWeight:600,color:"#111418",mb:1},children:s("modules.form.publicPolicies.title")}),ee(jo,{variant:"body2",color:"text.secondary",sx:{fontSize:"0.875rem"},children:s("modules.form.publicPolicies.description")})]})}),l&&ee(qo,{severity:"error",sx:{mb:3},children:l}),Ne(Nt,{spacing:3,children:[(e||[]).length===0?ee(qo,{severity:"info",children:s("modules.form.publicPolicies.noPolicies")}):e.map((i,m)=>ee(Xe,{ref:x=>{a.current[m]=x},policy:i,onChange:x=>{let C=[...e];C[m]=x,o(C)},onRemove:()=>h(m),availableFields:r,isSubmitting:c,usedActions:n,error:typeof t=="object"&&t&&i.id in t?t[i.id]:void 0},i.id)),u&&ee(Oe,{children:ee(Ot,{type:"button",variant:"outlined",startIcon:ee(Dt,{}),onClick:g,disabled:c,sx:{borderColor:"#d0d7de",color:"#656d76","&:hover":{borderColor:"#8c959f",backgroundColor:"transparent"}},children:s("modules.form.publicPolicies.addPolicy")})})]})]})]})},qs=Ut;import{useState as Ze}from"react";import{Button as Fe,TextField as Ho,Box as pe,Alert as Ee,Typography as le,CircularProgress as eo}from"@mui/material";import{jsx as A,jsxs as te}from"react/jsx-runtime";function Qs(){let[e,o]=Ze(""),[r,t]=Ze(""),[c,s]=Ze(!1),{isAuthenticated:a,isLoading:f,error:d,login:u,logout:g,refreshTokens:h,clearError:l,isExpiringSoon:n,expiresIn:i}=ne(),m=async p=>{if(p.preventDefault(),!e||!r)return;(await u(e,r)).success&&(o(""),t(""),s(!1))},x=async()=>{await g()},C=async()=>{await h()};return a?te(pe,{sx:{maxWidth:600,mx:"auto",p:3},children:[A(le,{variant:"h4",gutterBottom:!0,children:"Welcome! \u{1F389}"}),A(Ee,{severity:"success",sx:{mb:3},children:"You are successfully logged in with Refresh Token Pattern enabled"}),te(pe,{sx:{mb:3,p:2,bgcolor:"background.paper",border:1,borderColor:"divider",borderRadius:1},children:[A(le,{variant:"h6",gutterBottom:!0,children:"Token Status"}),te(le,{variant:"body2",color:"text.secondary",children:["Access Token expires in: ",Math.round(i/1e3/60)," minutes"]}),n&&A(Ee,{severity:"warning",sx:{mt:1},children:"Token expires soon - automatic refresh will happen"})]}),te(pe,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[A(Fe,{variant:"contained",onClick:C,disabled:f,startIcon:f?A(eo,{size:16}):null,children:"Refresh Tokens"}),A(Fe,{variant:"outlined",color:"error",onClick:x,disabled:f,children:"Logout"})]}),d&&A(Ee,{severity:"error",sx:{mt:2},onClose:l,children:d})]}):te(pe,{sx:{maxWidth:400,mx:"auto",p:3},children:[A(le,{variant:"h4",gutterBottom:!0,align:"center",children:"Login with Refresh Tokens"}),A(Ee,{severity:"info",sx:{mb:3},children:"This demo shows the new Refresh Token Pattern with automatic session management"}),c?te("form",{onSubmit:m,children:[A(Ho,{fullWidth:!0,label:"Email",type:"email",value:e,onChange:p=>o(p.target.value),margin:"normal",required:!0,autoComplete:"email"}),A(Ho,{fullWidth:!0,label:"Password",type:"password",value:r,onChange:p=>t(p.target.value),margin:"normal",required:!0,autoComplete:"current-password"}),A(Fe,{type:"submit",fullWidth:!0,variant:"contained",size:"large",disabled:f,startIcon:f?A(eo,{size:16}):null,sx:{mt:3,mb:2},children:f?"Logging in...":"Login"})]}):A(Fe,{fullWidth:!0,variant:"contained",size:"large",onClick:()=>s(!0),sx:{mt:2},children:"Show Login Form"}),d&&A(Ee,{severity:"error",sx:{mt:2},onClose:l,children:d})]})}function Xs(){let{isAuthenticated:e,isLoading:o,isExpiringSoon:r,expiresIn:t}=ne();return o?te(pe,{sx:{display:"flex",alignItems:"center",gap:1},children:[A(eo,{size:16}),A(le,{variant:"caption",children:"Loading session..."})]}):e?te(pe,{children:[A(le,{variant:"caption",color:"success.main",children:"\u2713 Authenticated"}),r&&te(le,{variant:"caption",color:"warning.main",display:"block",children:["\u26A0 Token expires in ",Math.round(t/1e3/60)," min"]})]}):A(le,{variant:"caption",color:"text.secondary",children:"Not logged in"})}export{re as a,Mt as b,Vt as c,De as d,Be as e,Jt as f,uo as g,as as h,at as i,Uo as j,zo as k,qs as l,Qs as m,Xs as n};
|
package/dist/chunk-JWIFFUC5.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk6RWBJJWLjs = require('./chunk-6RWBJJWL.js');var _chunkYIIUEOXCjs = require('./chunk-YIIUEOXC.js');var _chunkAT74WV5Wjs = require('./chunk-AT74WV5W.js');var re={es:{"checkCode.codeLabel":"C\xF3digo de Verificaci\xF3n","checkCode.codePlaceholder":"Ingresa el c\xF3digo de 6 d\xEDgitos","checkCode.codeRequired":"El c\xF3digo es obligatorio","checkCode.emailLabel":"Correo Electr\xF3nico","checkCode.emailPlaceholder":"Ingresa tu correo electr\xF3nico","checkCode.emailRequired":"El correo electr\xF3nico es obligatorio","checkCode.instructions":"Ingresa el c\xF3digo de 6 d\xEDgitos que enviamos a tu correo electr\xF3nico.","checkCode.invalidEmail":"Ingresa un correo electr\xF3nico v\xE1lido","checkCode.resendCodeLink":"Reenviar c\xF3digo","checkCode.title":"Verificar C\xF3digo","checkCode.verifyButton":"Verificar C\xF3digo","common.back":"Volver","common.backToLogin":"Volver","error.app.config":"Error de Configuraci\xF3n: {{message}}","error.app.initialization":"Error durante la inicializaci\xF3n final de la aplicaci\xF3n.","error.transaction":"Error en la operaci\xF3n","error.unknown":"Ocurri\xF3 un error desconocido.","errors.DUPLICATE":"El campo <b>{{field}}</b> debe ser \xFAnico.","errors.FOREIGN_KEY_NOT_FOUND":"El campo <b>{{field}}</b> debe referenciar un \xEDtem existente.","errors.INVALID_EMAIL":"El campo <b>{{field}}</b> debe ser un correo electr\xF3nico v\xE1lido.","errors.INVALID_OBJECT_ID":"El campo <b>{{field}}</b> debe ser un valor v\xE1lido.","errors.IN_USE":"El \xEDtem est\xE1 en uso y no puede ser eliminado.","errors.MAX_LENGTH":"El campo <b>{{field}}</b> no debe exceder los <b>{{length}}</b> caracteres.","errors.MIN_LENGTH":"El campo <b>{{field}}</b> debe tener al menos <b>{{length}}</b> caracteres.","errors.MUST_NOT_BE_EMAIL":"El campo <b>{{field}}</b> no debe ser un correo electr\xF3nico.","errors.NO_PERMISSION":"No tienes permiso para realizar esta acci\xF3n.","errors.NO_SPACES":"El campo <b>{{field}}</b> no debe contener espacios.","errors.ONE_OR_MORE_OPERATIONS_FAILED":"Error en la operaci\xF3n","errors.REQUIRED":"El campo <b>{{field}}</b> es obligatorio.","errors.TOKEN_HAS_EXPIRED":"La sesi\xF3n ha expirado. Por favor, inicia sesi\xF3n nuevamente.","errors.TOO_MANY_REQUESTS":"L\xEDmite de solicitudes alcanzado. Por favor intenta m\xE1s tarde.","errors.UNAUTHORIZED":"No est\xE1s autorizado para realizar esta acci\xF3n.","errors.all_password_fields_required":"Todos los campos de contrase\xF1a son obligatorios","errors.auth.INVALID_API_KEY":"Clave de API inv\xE1lida","errors.auth.INVALID_CREDENTIALS":"Usuario y/o contrase\xF1a incorrectos","errors.auth.NO_PERMISSION":"No tienes permisos suficientes","errors.auth.SESSION_EXPIRED":"Tu sesi\xF3n ha expirado. Por favor, inicia sesi\xF3n nuevamente.","errors.auth.TOO_MANY_REQUESTS":"Demasiados intentos. Por favor espera 15 minutos e intenta nuevamente","errors.auth.UNAUTHORIZED":"No tienes permisos para realizar esta acci\xF3n","errors.auth.USER_NOT_ACTIVE":"Usuario no activo","errors.auth.USER_NOT_FOUND":"Usuario no encontrado","errors.data.BAD_REQUEST":"Solicitud inv\xE1lida","errors.data.FIELD_ERROR":"Error en los datos ingresados","errors.data.IN_USE":"El elemento est\xE1 en uso y no puede ser eliminado","errors.data.ITEM_NOT_FOUND":"El elemento solicitado no fue encontrado","errors.data.NOT_FOUND":"No se encontr\xF3 lo solicitado","errors.internal_error_changing_password":"Error interno al cambiar la contrase\xF1a. Intenta nuevamente","errors.password_min_length":"La contrase\xF1a debe tener al menos 8 caracteres","errors.password_mismatch":"Las contrase\xF1as no coinciden","errors.password_must_be_different":"La nueva contrase\xF1a debe ser diferente a la actual","errors.system.DATABASE_CONNECTION_ERROR":"Error de conexi\xF3n. Verifica tu conexi\xF3n a internet.","errors.system.INTERNAL_SERVER_ERROR":"Error interno del servidor. Intenta nuevamente.","errors.system.INVALID_CONFIGURATION":"Error de configuraci\xF3n del sistema","errors.system.TOO_MANY_REQUESTS":"Demasiadas solicitudes. Por favor espera un momento e intenta nuevamente","errors.system.UNKNOWN_OPERATION":"Operaci\xF3n no reconocida","errors.users_module_not_configured":"M\xF3dulo de usuarios no configurado","footer.copyright":"Nocios S.R.L. Todos los derechos reservados.","footer.version":"Versi\xF3n","forgotPassword.checkEmailInstructions":"Revisa tu bandeja de entrada para el c\xF3digo de verificaci\xF3n","forgotPassword.codeAlreadyExistsMessage":"Ya se envi\xF3 un c\xF3digo y a\xFAn es v\xE1lido","forgotPassword.emailLabel":"Correo Electr\xF3nico","forgotPassword.emailPlaceholder":"Ingresa tu correo electr\xF3nico","forgotPassword.emailRequired":"El correo electr\xF3nico es obligatorio","forgotPassword.emailSentMessage":"C\xF3digo enviado exitosamente","forgotPassword.enterCodeLink":"Ingresar C\xF3digo","forgotPassword.instructions":"Ingresa tu correo electr\xF3nico y te enviaremos un c\xF3digo para restablecer tu contrase\xF1a.","forgotPassword.invalidEmail":"Ingresa un correo electr\xF3nico v\xE1lido","forgotPassword.sendCodeButton":"Enviar C\xF3digo","forgotPassword.title":"Recuperar Contrase\xF1a","loading.app.configInitial":"Cargando configuraci\xF3n inicial...","loading.app.generic":"Cargando...","loading.app.starting":"Iniciando aplicaci\xF3n...","loading.app.themeSetup":"Generando tema...","loading.app.validatingSession":"Validando sesi\xF3n...","login.alreadyHaveCodeLink":"\xBFYa tienes un c\xF3digo?","login.forgotPasswordLink":"\xBFOlvidaste tu contrase\xF1a?","login.initializationError":"Error de inicializaci\xF3n","login.initializing":"Inicializando...","login.loginButton":"Iniciar Sesi\xF3n","login.logoAlt":"Logotipo","login.noAccountPrompt":"\xBFNo tienes una cuenta?","login.notInitialized":"Sistema no inicializado","login.passwordLabel":"Contrase\xF1a","login.passwordPlaceholder":"Ingresa tu contrase\xF1a","login.passwordRequired":"Contrase\xF1a es obligatoria","login.signUpLink":"Reg\xEDstrate","login.usernameOrEmailLabel":"Usuario o Correo Electr\xF3nico","login.usernameOrEmailPlaceholder":"Ingresa tu usuario o correo electr\xF3nico","login.usernameRequired":"Usuario o correo electr\xF3nico es obligatorio","resetPassword.codeExpiredOrInvalid":"El c\xF3digo ha expirado o es inv\xE1lido","resetPassword.confirmPasswordLabel":"Confirmar Contrase\xF1a","resetPassword.confirmPasswordPlaceholder":"Confirma tu nueva contrase\xF1a","resetPassword.confirmPasswordRequired":"Confirma tu contrase\xF1a","resetPassword.goToLoginButton":"Ir al Login","resetPassword.instructions":"Ingresa tu nueva contrase\xF1a.","resetPassword.invalidCode":"El c\xF3digo de verificaci\xF3n es inv\xE1lido. Por favor, verifica el enlace o solicita uno nuevo.","resetPassword.missingParameters":"Faltan par\xE1metros obligatorios","resetPassword.newPasswordLabel":"Nueva Contrase\xF1a","resetPassword.newPasswordPlaceholder":"Ingresa tu nueva contrase\xF1a","resetPassword.newPasswordRequired":"La nueva contrase\xF1a es obligatoria","resetPassword.passwordTooShort":"La contrase\xF1a debe tener al menos 8 caracteres","resetPassword.passwordsDoNotMatch":"Las contrase\xF1as no coinciden","resetPassword.requestNewCodeButton":"Solicitar Nuevo C\xF3digo","resetPassword.resetPasswordButton":"Restablecer Contrase\xF1a","resetPassword.successInstructions":"Ahora puedes iniciar sesi\xF3n con tu nueva contrase\xF1a","resetPassword.successMessage":"Contrase\xF1a restablecida exitosamente","resetPassword.title":"Nueva Contrase\xF1a","resetPassword.validatingCode":"Validando c\xF3digo..."},en:{"checkCode.codeLabel":"Verification Code","checkCode.codePlaceholder":"Enter 6-digit code","checkCode.codeRequired":"Code is required","checkCode.emailLabel":"Email Address","checkCode.emailPlaceholder":"Enter your email address","checkCode.emailRequired":"Email address is required","checkCode.instructions":"Enter the 6-digit code we sent to your email address.","checkCode.invalidEmail":"Enter a valid email address","checkCode.resendCodeLink":"Resend code","checkCode.title":"Verify Code","checkCode.verifyButton":"Verify Code","common.back":"Back","common.backToLogin":"Back to Login","error.app.config":"Configuration Error: {{message}}","error.app.initialization":"Error during final application initialization.","error.transaction":"Operation error","error.unknown":"An unknown error occurred.","errors.DUPLICATE":"The field <b>{{field}}</b> must be unique.","errors.FOREIGN_KEY_NOT_FOUND":"The field <b>{{field}}</b> must reference an existing item.","errors.INVALID_EMAIL":"The field <b>{{field}}</b> must be a valid email address.","errors.INVALID_OBJECT_ID":"The field <b>{{field}}</b> must be a valid value.","errors.IN_USE":"The item is currently in use and cannot be deleted.","errors.MAX_LENGTH":"The field <b>{{field}}</b> must not exceed <b>{{maxLength}}</b> characters.","errors.MIN_LENGTH":"The field <b>{{field}}</b> must have at least <b>{{minLength}}</b> characters.","errors.MUST_NOT_BE_EMAIL":"The field <b>{{field}}</b> must not be an email address.","errors.NO_PERMISSION":"You do not have permission to perform this action.","errors.NO_SPACES":"The field <b>{{field}}</b> must not contain spaces.","errors.ONE_OR_MORE_OPERATIONS_FAILED":"Operation error","errors.REQUIRED":"The field <b>{{field}}</b> is required.","errors.TOKEN_HAS_EXPIRED":"Your session has expired, please log in again.","errors.TOO_MANY_REQUESTS":"Request limit reached. Please try again later.","errors.UNAUTHORIZED":"You are not authorized to perform this action.","errors.all_password_fields_required":"All password fields are required","errors.auth.INVALID_API_KEY":"Invalid API key","errors.auth.INVALID_CREDENTIALS":"Incorrect username and/or password","errors.auth.NO_PERMISSION":"Insufficient permissions","errors.auth.SESSION_EXPIRED":"Your session has expired. Please log in again.","errors.auth.TOO_MANY_REQUESTS":"Too many attempts. Please wait 15 minutes and try again","errors.auth.UNAUTHORIZED":"You don't have permission to perform this action","errors.auth.USER_NOT_ACTIVE":"User account is not active","errors.auth.USER_NOT_FOUND":"User not found","errors.data.BAD_REQUEST":"Invalid request","errors.data.FIELD_ERROR":"Error in the provided data","errors.data.IN_USE":"The item is in use and cannot be deleted","errors.data.ITEM_NOT_FOUND":"The requested item was not found","errors.data.NOT_FOUND":"The requested resource was not found","errors.internal_error_changing_password":"Internal error changing password. Please try again","errors.password_min_length":"Password must be at least 8 characters","errors.password_mismatch":"Passwords do not match","errors.password_must_be_different":"New password must be different from current password","errors.system.DATABASE_CONNECTION_ERROR":"Connection error. Please check your internet connection.","errors.system.INTERNAL_SERVER_ERROR":"Internal server error. Please try again.","errors.system.INVALID_CONFIGURATION":"System configuration error","errors.system.TOO_MANY_REQUESTS":"Too many requests. Please wait a moment and try again","errors.system.UNKNOWN_OPERATION":"Unrecognized operation","errors.users_module_not_configured":"Users module not configured","footer.copyright":"Nocios S.R.L. All Rights Reserved.","footer.version":"Version","forgotPassword.checkEmailInstructions":"Check your inbox for the verification code","forgotPassword.codeAlreadyExistsMessage":"A code was already sent and is still valid","forgotPassword.emailLabel":"Email Address","forgotPassword.emailPlaceholder":"Enter your email address","forgotPassword.emailRequired":"Email address is required","forgotPassword.emailSentMessage":"Code sent successfully","forgotPassword.enterCodeLink":"Enter Code","forgotPassword.instructions":"Enter your email address and we'll send you a code to reset your password.","forgotPassword.invalidEmail":"Enter a valid email address","forgotPassword.sendCodeButton":"Send Code","forgotPassword.title":"Reset Password","loading.app.configInitial":"Loading initial configuration...","loading.app.generic":"Loading...","loading.app.starting":"Starting application...","loading.app.themeSetup":"Generating theme...","loading.app.validatingSession":"Validating session...","login.alreadyHaveCodeLink":"Already have a code?","login.forgotPasswordLink":"Forgot Password?","login.initializationError":"Initialization error","login.initializing":"Initializing...","login.loginButton":"Log In","login.logoAlt":"Logo","login.noAccountPrompt":"Don't have an account?","login.notInitialized":"System not initialized","login.passwordLabel":"Password","login.passwordPlaceholder":"Enter your password","login.passwordRequired":"Password is required","login.signUpLink":"Sign up","login.usernameOrEmailLabel":"Username or Email","login.usernameOrEmailPlaceholder":"Enter your username or email","login.usernameRequired":"Username or email is required","resetPassword.codeExpiredOrInvalid":"Code expired or invalid","resetPassword.confirmPasswordLabel":"Confirm Password","resetPassword.confirmPasswordPlaceholder":"Confirm your new password","resetPassword.confirmPasswordRequired":"Confirm your password","resetPassword.goToLoginButton":"Go to Login","resetPassword.instructions":"Enter your new password.","resetPassword.invalidCode":"The verification code is invalid. Please check the link or request a new one.","resetPassword.missingParameters":"Missing required parameters","resetPassword.newPasswordLabel":"New Password","resetPassword.newPasswordPlaceholder":"Enter your new password","resetPassword.newPasswordRequired":"New password is required","resetPassword.passwordTooShort":"Password must be at least 8 characters","resetPassword.passwordsDoNotMatch":"Passwords do not match","resetPassword.requestNewCodeButton":"Request New Code","resetPassword.resetPasswordButton":"Reset Password","resetPassword.successInstructions":"You can now log in with your new password","resetPassword.successMessage":"Password reset successfully","resetPassword.title":"New Password","resetPassword.validatingCode":"Validating code..."}},Mt= exports.b =()=>Object.keys(re),Vt= exports.c =e=>re[e]||re.es;var _crudifybrowser = require('@nocios/crudify-browser'); var _crudifybrowser2 = _interopRequireDefault(_crudifybrowser);var ao="crudify_translations_",Go=3600*1e3,De= exports.d =class e{constructor(){this.enableDebug=!1;this.initializationPromise=null;this.isInitialized=!1}static getInstance(){return e.instance||(e.instance=new e),e.instance}setDebug(o){this.enableDebug=o}async ensureCrudifyInitialized(o,r){if(!this.isInitialized)return this.initializationPromise?(this.enableDebug&&console.log("[TranslationService] Waiting for crudify initialization..."),this.initializationPromise):(this.enableDebug&&console.log("[TranslationService] Initializing crudify SDK..."),this.initializationPromise=(async()=>{try{let t=_crudifybrowser2.default.getTokenData();if(t&&t.endpoint){this.enableDebug&&console.log("[TranslationService] Crudify already initialized"),this.isInitialized=!0;return}_crudifybrowser2.default.config(r);let c=await _crudifybrowser2.default.init(o,this.enableDebug?"debug":"none");if(c.success===!1)throw new Error(`Failed to initialize crudify: ${JSON.stringify(c.errors||"Unknown error")}`);this.isInitialized=!0,this.enableDebug&&console.log("[TranslationService] Crudify SDK initialized successfully")}catch(t){throw console.error("[TranslationService] Failed to initialize crudify:",t),this.initializationPromise=null,t}})(),this.initializationPromise)}async fetchTranslations(o){let{subscriberKey:r,apiKey:t,sections:c,crudifyEnv:s="stg",urlTranslations:a}=o;console.log("[TranslationService] \u{1F4E5} fetchTranslations called with:",{subscriberKey:r,crudifyEnv:s,sections:c,hasUrlTranslations:!!a,urlTranslationsKeys:a?Object.keys(a).length:0});let f=this.getFromCache(r),d=f?this.isCacheExpired(f):!0;if(console.log("[TranslationService] \u{1F4BE} Cache check:",{hasCached:!!f,isCacheExpired:d}),f&&!d){console.log("[TranslationService] \u2705 Using cached translations");let u=this.mergeWithUrlTranslations(f.data.translations,a);return console.log("[TranslationService] \u{1F504} Merged result (from cache):",{languages:Object.keys(u),sampleLang:Object.keys(u)[0],keysInSampleLang:u[Object.keys(u)[0]]?Object.keys(u[Object.keys(u)[0]]).length:0}),u}try{await this.ensureCrudifyInitialized(t,s)}catch(u){return console.error("[TranslationService] \u274C Failed to initialize crudify:",u),f?(console.warn("[TranslationService] \u26A0\uFE0F Using expired cache (init failed)"),this.mergeWithUrlTranslations(f.data.translations,a)):(console.warn("[TranslationService] \u26A0\uFE0F Using critical bundle (init failed)"),this.getCriticalTranslationsOnly())}try{console.log("[TranslationService] \u{1F310} Fetching from API via crudify SDK...");let u=await this.fetchFromAPI(c);console.log("[TranslationService] \u{1F4E6} API response received:",{subscriberKey:u.subscriberKey,languages:u.languages,translationsKeys:Object.keys(u.translations),timestamp:u.timestamp});let g=Object.keys(u.translations)[0];g&&console.log(`[TranslationService] \u{1F4CB} API translations sample (${g}):`,{totalKeys:Object.keys(u.translations[g]).length,firstFiveKeys:Object.keys(u.translations[g]).slice(0,5)}),this.hasDataChanged(f,u)||!f?(console.log("[TranslationService] \u{1F4BE} Data changed, updating cache"),this.saveToCache(r,u)):(console.log("[TranslationService] \u{1F4BE} Data unchanged, refreshing cache timestamp"),this.refreshCacheTimestamp(r));let l=this.mergeWithUrlTranslations(u.translations,a);return console.log("[TranslationService] \u{1F504} Final merged result:",{languages:Object.keys(l),sampleLang:Object.keys(l)[0],keysInSampleLang:l[Object.keys(l)[0]]?Object.keys(l[Object.keys(l)[0]]).length:0}),l}catch(u){return console.error("[TranslationService] \u274C API fetch failed:",u),f?(console.warn("[TranslationService] \u26A0\uFE0F Using expired cache as fallback"),this.mergeWithUrlTranslations(f.data.translations,a)):(console.warn("[TranslationService] \u26A0\uFE0F Using critical bundle translations"),this.getCriticalTranslationsOnly())}}async fetchFromAPI(o){let r=await _crudifybrowser2.default.getTranslation(o);if(!r.success)throw new Error(`Crudify API error: ${r.errors?JSON.stringify(r.errors):"Unknown error"}`);if(!r.data)throw new Error("No translation data in response");return r.data}mergeWithUrlTranslations(o,r){if(!r||Object.keys(r).length===0)return o;let t={};return Object.keys(o).forEach(c=>{t[c]={...o[c],...r}}),t}hasDataChanged(o,r){if(!o||o.data.timestamp!==r.timestamp)return!0;let t=this.hashData(r.translations);return o.dataHash!==t}hashData(o){let r=JSON.stringify(o),t=0;for(let c=0;c<r.length;c++){let s=r.charCodeAt(c);t=(t<<5)-t+s,t=t&t}return t.toString(36)}saveToCache(o,r){try{let t=this.getCacheKey(o),c={data:r,cachedAt:Date.now(),dataHash:this.hashData(r.translations)};localStorage.setItem(t,JSON.stringify(c)),this.enableDebug&&console.log("[TranslationService] Saved to cache:",t)}catch(t){console.error("[TranslationService] Failed to save cache:",t)}}getFromCache(o){try{let r=this.getCacheKey(o),t=localStorage.getItem(r);return t?JSON.parse(t):null}catch(r){return console.error("[TranslationService] Failed to read cache:",r),null}}refreshCacheTimestamp(o){try{let r=this.getFromCache(o);if(r){r.cachedAt=Date.now();let t=this.getCacheKey(o);localStorage.setItem(t,JSON.stringify(r))}}catch(r){console.error("[TranslationService] Failed to refresh cache timestamp:",r)}}isCacheExpired(o){return Date.now()-o.cachedAt>Go}getCacheKey(o){return`${ao}${o}`}getCriticalTranslationsOnly(){return re}invalidateCache(o){let r=this.getCacheKey(o);localStorage.removeItem(r),this.enableDebug&&console.log("[TranslationService] Cache invalidated:",r)}async prefetchTranslations(o){try{await this.fetchTranslations(o),this.enableDebug&&console.log("[TranslationService] Prefetch completed")}catch(r){console.error("[TranslationService] Prefetch failed:",r)}}clearAllCaches(){try{let r=Object.keys(localStorage).filter(t=>t.startsWith(ao));r.forEach(t=>localStorage.removeItem(t)),this.enableDebug&&console.log(`[TranslationService] Cleared ${r.length} cache entries`)}catch(o){console.error("[TranslationService] Failed to clear caches:",o)}}},Be= exports.e =De.getInstance();var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var co=_react.createContext.call(void 0, null);function io(e,o,r){return{...e,...o,...r||{}}}function er(e,o,r,t,c){_react.useEffect.call(void 0, ()=>{if(!t||!e||!o)return;let s=r||typeof window<"u"&&window.i18next||typeof window<"u"&&window.i18n;if(!s||!s.addResourceBundle){c&&console.log("[TranslationsProvider] i18next not found, skipping auto-sync");return}c&&console.log("[TranslationsProvider] Auto-syncing translations with i18next",{languages:Object.keys(e),currentLanguage:o}),Object.keys(e).forEach(a=>{e[a]&&Object.keys(e[a]).length>0&&(s.addResourceBundle(a,"translation",e[a],!0,!0),c&&console.log(`[TranslationsProvider] Synced ${Object.keys(e[a]).length} keys for language: ${a}`))}),s.language!==o&&(s.changeLanguage(o),c&&console.log(`[TranslationsProvider] Changed i18next language to: ${o}`))},[e,o,r,t,c])}var Jt=({children:e,subscriberKey:o,apiKey:r,crudifyEnv:t="stg",sections:c,language:s="es",devTranslations:a,translationUrl:f,enableDebug:d=!1,skipAutoInit:u=!0,autoSyncI18n:g=!0,i18nInstance:h})=>{let[l,n]=_react.useState.call(void 0, {}),[i,m]=_react.useState.call(void 0, !0),[x,C]=_react.useState.call(void 0, null),[p,w]=_react.useState.call(void 0, void 0),[P,T]=_react.useState.call(void 0, !1),v=_react.useCallback.call(void 0, async()=>{if(P){d&&console.log("[TranslationsProvider] Skipping reload - using fallback translations");return}m(!0),C(null);let S;if(f)try{d&&console.log(`[TranslationsProvider] Fetching translations from URL: ${f}`);let I=await fetch(f);if(!I.ok)throw new Error(`Failed to fetch translations: ${I.statusText}`);S=await I.json(),w(S),d&&console.log("[TranslationsProvider] URL translations loaded:",{keysCount:S?Object.keys(S).length:0})}catch(I){console.error("[TranslationsProvider] Failed to load URL translations:",I),S=void 0,w(void 0)}try{Be.setDebug(d);let I=await Be.fetchTranslations({subscriberKey:o,apiKey:r,crudifyEnv:t,sections:c,urlTranslations:S}),V={};Object.keys(I).forEach(_=>{let oe=re[_]||{},$=I[_]||{};V[_]=io(oe,$,a)}),n(V),d&&console.log("[TranslationsProvider] Loaded translations:",{languages:Object.keys(V),keysCount:Object.keys(V[s]||{}).length})}catch(I){console.error("[TranslationsProvider] Failed to load:",I),C(I.message),T(!0);let V={};Object.keys(re).forEach(_=>{let oe=re[_],$=S||p||{};V[_]=io(oe,$,a)}),n(V),d&&console.log("[TranslationsProvider] Using fallback translations (critical + URL)")}finally{m(!1)}},[o,r,t,c,f,a,d,s,P]);_react.useEffect.call(void 0, ()=>{v();let S=setInterval(v,3600*1e3);return()=>clearInterval(S)},[v]);let y=_react.useMemo.call(void 0, ()=>(S,I)=>{let _=(l[s]||{})[S];if(!_){let oe=Object.keys(l);for(let $ of oe)if(l[$][S]){_=l[$][S];break}}return _||(d&&console.warn(`[TranslationsProvider] Missing translation: "${S}"`),_=S),I&&typeof _=="string"&&Object.entries(I).forEach(([oe,$])=>{let O=new RegExp(`{{${oe}}}`,"g");_=_.replace(O,String($))}),_},[l,s,d]);er(l,s,h,g,d);let R={t:y,language:s,availableLanguages:Object.keys(l),translations:l,isLoading:i,error:x,refreshTranslations:v};return _jsxruntime.jsx.call(void 0, co.Provider,{value:R,children:e})},uo= exports.g =()=>{let e=_react.useContext.call(void 0, co);if(!e)throw new Error("useTranslations must be used within TranslationsProvider");return e};var _material = require('@mui/material');var go=(e,o)=>{let[r,t]=_react.useState.call(void 0, {}),[c,s]=_react.useState.call(void 0, !1),[a,f]=_react.useState.call(void 0, null);return _react.useEffect.call(void 0, ()=>{if(console.log("\u{1F527} [I18nProvider] Hybrid translation loading:",{hasProvidedTranslations:!!o&&Object.keys(o).length>0,hasUrl:!!e,providedKeys:o?Object.keys(o).length:0}),o&&Object.keys(o).length>0){console.log("\u2705 [I18nProvider] Using provided translations (highest priority)"),t(o),s(!1),f(null);return}if(!e){console.log("\u26A0\uFE0F [I18nProvider] No translations provided, using empty object (keys will show as-is)"),t({}),s(!1),f(null);return}console.log("\u{1F310} [I18nProvider] Loading translations from URL:",e);let d=!1;return s(!0),f(null),fetch(e).then(u=>{if(!u.ok)throw new Error(`Failed to load translations: ${u.status}`);return u.json()}).then(u=>{d||(console.log("\u2705 [I18nProvider] Translations loaded successfully from URL:",{url:e,keysLoaded:Object.keys(u).length}),t(u),s(!1))}).catch(u=>{d||(console.error("\u274C [I18nProvider] Failed to load translations from URL:",e,u),f(u.message),console.log("\u{1F504} [I18nProvider] Falling back to empty translations (keys will show as-is)"),t({}),s(!1))}),()=>{d=!0}},[e,o]),{translations:r,loading:c,error:a}};var fo=_react.createContext.call(void 0, null),sr=()=>{try{return uo()}catch (e2){return null}},ar=(e,o)=>e&&e[o]?e[o]:o.split(".").reduce((r,t)=>r&&typeof r=="object"?r[t]:void 0,e),po=({children:e,translations:o,translationsUrl:r,language:t="en"})=>{let s=_optionalChain([sr, 'call', _2 => _2(), 'optionalAccess', _3 => _3.translations, 'optionalAccess', _4 => _4[t]])||{},{translations:a,loading:f}=go(r,o),d=_react.useMemo.call(void 0, ()=>({...s,...a,...o||{}}),[s,a,o]),u=_react.useMemo.call(void 0, ()=>(h,l)=>{let n=ar(d,h);return n==null&&(console.log(`\u{1F50D} [I18nProvider] Translation not found for key: "${h}" - showing key as-is`),n=h),l&&typeof n=="string"&&Object.entries(l).forEach(([i,m])=>{n=n.replace(new RegExp(`{{${i}}}`,"g"),m)}),typeof n=="string"?n:h},[d]),g=_react.useMemo.call(void 0, ()=>({t:u,language:t}),[u,t]);return f?_jsxruntime.jsx.call(void 0, "div",{children:"Loading translations..."}):_jsxruntime.jsx.call(void 0, fo.Provider,{value:g,children:e})},H=()=>{let e=_react.useContext.call(void 0, fo);if(!e)throw new Error("useTranslation must be used within I18nProvider");return e};var ho={currentScreen:"login",searchParams:{},formData:{username:"",password:"",email:"",code:"",newPassword:"",confirmPassword:""},loading:!1,errors:{global:[]},emailSent:!1,codeAlreadyExists:!1,codeValidated:!1,fromCodeVerification:!1,config:{}};function dr(e,o){switch(o.type){case"SET_SCREEN":let r={...e,currentScreen:o.payload.screen,searchParams:o.payload.params||e.searchParams,errors:{global:[]}},t=new URLSearchParams(r.searchParams),c=t.toString()?`?${t.toString()}`:window.location.pathname;try{window.history.replaceState({},"",c)}catch (e3){}return r;case"SET_SEARCH_PARAMS":return{...e,searchParams:o.payload};case"UPDATE_FORM_DATA":return{...e,formData:{...e.formData,...o.payload},errors:{...e.errors,...Object.keys(o.payload).reduce((s,a)=>({...s,[a]:void 0}),{})}};case"SET_LOADING":return{...e,loading:o.payload};case"SET_ERRORS":return{...e,errors:{...e.errors,...o.payload}};case"CLEAR_ERRORS":return{...e,errors:{global:[]}};case"SET_EMAIL_SENT":return{...e,emailSent:o.payload};case"SET_CODE_ALREADY_EXISTS":return{...e,codeAlreadyExists:o.payload};case"SET_CODE_VALIDATED":return{...e,codeValidated:o.payload};case"SET_FROM_CODE_VERIFICATION":return{...e,fromCodeVerification:o.payload};case"RESET_FORM":return{...e,formData:ho.formData,errors:{global:[]},loading:!1,emailSent:!1,codeAlreadyExists:!1,codeValidated:!1,fromCodeVerification:!1};case"INIT_CONFIG":return{...e,config:o.payload};default:return e}}var wo=_react.createContext.call(void 0, void 0),bo=({children:e,initialScreen:o="login",config:r,autoReadFromCookies:t=!0})=>{let[c,s]=_react.useReducer.call(void 0, dr,{...ho,currentScreen:o});_react.useEffect.call(void 0, ()=>{s({type:"INIT_CONFIG",payload:(()=>{let n={};if(t)try{let i=_chunkAT74WV5Wjs.a.call(void 0, "logo");if(i){let m=decodeURIComponent(i);m.startsWith("http")&&(n.logo=m)}}catch(i){console.error("Error reading configuration from cookies:",i)}return{publicApiKey:_optionalChain([r, 'optionalAccess', _5 => _5.publicApiKey]),env:_optionalChain([r, 'optionalAccess', _6 => _6.env]),appName:_optionalChain([r, 'optionalAccess', _7 => _7.appName]),logo:_optionalChain([r, 'optionalAccess', _8 => _8.logo])||n.logo,loginActions:_optionalChain([r, 'optionalAccess', _9 => _9.loginActions])}})()})},[r,t]),_react.useEffect.call(void 0, ()=>{let l=new URLSearchParams(window.location.search),n={};l.forEach((i,m)=>{n[m]=i}),Object.keys(n).length>0&&s({type:"SET_SEARCH_PARAMS",payload:n}),o==="checkCode"&&n.email&&s({type:"UPDATE_FORM_DATA",payload:{email:n.email,code:n.code||""}}),o==="resetPassword"&&n.link&&s({type:"SET_SEARCH_PARAMS",payload:n})},[o]);let h={state:c,dispatch:s,setScreen:(l,n)=>{s({type:"SET_SCREEN",payload:{screen:l,params:n}})},updateFormData:l=>{s({type:"UPDATE_FORM_DATA",payload:l})},setFieldError:(l,n)=>{s({type:"SET_ERRORS",payload:{[l]:n}})},clearErrors:()=>{s({type:"CLEAR_ERRORS"})},setLoading:l=>{s({type:"SET_LOADING",payload:l})}};return _jsxruntime.jsx.call(void 0, wo.Provider,{value:h,children:e})},Ie=()=>{let e=_react.useContext.call(void 0, wo);if(e===void 0)throw new Error("useLoginState must be used within a LoginStateProvider");return e};var hr=({onScreenChange:e,onExternalNavigate:o,onLoginSuccess:r,onError:t,redirectUrl:c="/"})=>{let{crudify:s}=_chunk6RWBJJWLjs.c.call(void 0, ),{state:a,updateFormData:f,setFieldError:d,clearErrors:u,setLoading:g}=Ie(),{login:h}=_chunk6RWBJJWLjs.j.call(void 0, ),l=H(),{t:n}=l,i=l.i18n,m=_react.useRef.call(void 0, null),x=_chunkAT74WV5Wjs.e.call(void 0, n,{currentLanguage:_optionalChain([i, 'optionalAccess', _10 => _10.language]),enableDebug:!1}),C=()=>{if(a.searchParams.redirect)try{let y=decodeURIComponent(a.searchParams.redirect);if(y.startsWith("/")&&!y.startsWith("//"))return y}catch (e4){}return c||"/"};_react.useEffect.call(void 0, ()=>{let y=setTimeout(()=>{m.current&&m.current.focus()},100);return()=>clearTimeout(y)},[]);let p=y=>{console.log("\u{1F50D} [LoginForm] Translating parsed error:",y);let R=x.translateError({code:y.code,message:y.message,field:y.field});return console.log("\u{1F50D} [LoginForm] Translation result:",R),R},w=async()=>{if(!a.loading){if(!a.formData.username.trim()){d("username",n("login.usernameRequired"));return}if(!a.formData.password.trim()){d("password",n("login.passwordRequired"));return}u(),g(!0);try{let y=await h(a.formData.username,a.formData.password);if(g(!1),y.success){console.log("\u{1F510} LoginForm - Login successful via SessionProvider, calling onLoginSuccess");let R=C();r&&r(y.data,R)}else{let R=y.rawResponse||y;P(R)}}catch(y){g(!1);let S=_chunkYIIUEOXCjs.g.call(void 0, y).map(p);d("global",S),t&&t(S.join(", "))}}},P=y=>{_chunkYIIUEOXCjs.g.call(void 0, y).forEach(S=>{if(S.field)d(S.field,p(S));else{let I=a.errors.global||[];d("global",[...I,p(S)])}})};return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, _material.Box,{component:"form",noValidate:!0,onSubmit:y=>{y.preventDefault(),w()},onKeyDown:y=>{y.key==="Enter"&&!a.loading&&(y.preventDefault(),w())},sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:1},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",component:"label",htmlFor:"email",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:n("login.usernameOrEmailLabel")}),_jsxruntime.jsx.call(void 0, _material.TextField,{fullWidth:!0,id:"email",name:"email",type:"email",value:a.formData.username,disabled:a.loading,onChange:y=>f({username:y.target.value}),error:!!a.errors.username,helperText:a.errors.username,autoComplete:"email",placeholder:n("login.usernameOrEmailPlaceholder"),inputRef:m,required:!0})]}),_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:1},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",component:"label",htmlFor:"password",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:n("login.passwordLabel")}),_jsxruntime.jsx.call(void 0, _material.TextField,{fullWidth:!0,id:"password",name:"password",type:"password",value:a.formData.password,disabled:a.loading,onChange:y=>f({password:y.target.value}),error:!!a.errors.password,helperText:a.errors.password,autoComplete:"current-password",placeholder:n("login.passwordPlaceholder"),required:!0})]}),_optionalChain([a, 'access', _11 => _11.config, 'access', _12 => _12.loginActions, 'optionalAccess', _13 => _13.includes, 'call', _14 => _14("forgotPassword")])&&_jsxruntime.jsx.call(void 0, _material.Box,{sx:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:_jsxruntime.jsx.call(void 0, _material.Link,{sx:{cursor:"pointer"},onClick:()=>{_optionalChain([e, 'optionalCall', _15 => _15("forgotPassword",a.searchParams)])},variant:"body2",color:"secondary",children:n("login.forgotPasswordLink")})}),_jsxruntime.jsx.call(void 0, _material.Button,{disabled:a.loading,type:"submit",fullWidth:!0,variant:"contained",color:"primary",sx:{mt:1,mb:2},children:a.loading?_jsxruntime.jsx.call(void 0, _material.CircularProgress,{size:20}):n("login.loginButton")})]}),_jsxruntime.jsx.call(void 0, _material.Box,{children:a.errors.global&&a.errors.global.length>0&&a.errors.global.map((y,R)=>_jsxruntime.jsx.call(void 0, _material.Alert,{variant:"filled",sx:{mt:2},severity:"error",children:_jsxruntime.jsx.call(void 0, "div",{children:y})},R))}),_optionalChain([a, 'access', _16 => _16.config, 'access', _17 => _17.loginActions, 'optionalAccess', _18 => _18.includes, 'call', _19 => _19("createUser")])&&_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"body2",align:"center",sx:{color:"text.secondary",mt:3},children:[n("login.noAccountPrompt")," ",_jsxruntime.jsx.call(void 0, _material.Link,{sx:{cursor:"pointer"},onClick:()=>{let R=`/public/users/create${Object.keys(a.searchParams).length>0?`?${new URLSearchParams(a.searchParams).toString()}`:""}`;_optionalChain([o, 'optionalCall', _20 => _20(R)])},fontWeight:"medium",color:"secondary",children:n("login.signUpLink")})]})]})},xo=hr;var xr=({onScreenChange:e,onError:o})=>{let{crudify:r}=_chunk6RWBJJWLjs.c.call(void 0, ),[t,c]=_react.useState.call(void 0, ""),[s,a]=_react.useState.call(void 0, !1),[f,d]=_react.useState.call(void 0, []),[u,g]=_react.useState.call(void 0, null),[h,l]=_react.useState.call(void 0, !1),[n,i]=_react.useState.call(void 0, !1),{t:m}=H(),x=T=>{let v=[`errors.auth.${T.code}`,`errors.data.${T.code}`,`errors.system.${T.code}`,`errors.${T.code}`,`forgotPassword.${T.code.toLowerCase()}`];for(let y of v){let R=m(y);if(R!==y)return R}return T.message||m("error.unknown")},C=T=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(T),p=async()=>{if(!(s||!r)){if(d([]),g(null),!t){g(m("forgotPassword.emailRequired"));return}if(!C(t)){g(m("forgotPassword.invalidEmail"));return}a(!0);try{let T=[{operation:"requestPasswordReset",data:{email:t}}],v=await r.transaction(T);if(v.success)v.data&&v.data.existingCodeValid?i(!0):l(!0);else{let R=_chunkYIIUEOXCjs.g.call(void 0, v).map(x);d(R)}}catch(T){let y=_chunkYIIUEOXCjs.g.call(void 0, T).map(x);d(y),o&&o(y.join(", "))}finally{a(!1)}}},w=()=>{_optionalChain([e, 'optionalCall', _21 => _21("login")])},P=()=>{if(h||n){_optionalChain([e, 'optionalCall', _22 => _22("checkCode",{email:t})]);return}if(!t){g(m("forgotPassword.emailRequired"));return}if(!C(t)){g(m("forgotPassword.invalidEmail"));return}_optionalChain([e, 'optionalCall', _23 => _23("checkCode",{email:t})])};return h||n?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{width:"100%",display:"flex",flexDirection:"column",gap:2,textAlign:"center"},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:2},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:m(n?"forgotPassword.codeAlreadyExistsMessage":"forgotPassword.emailSentMessage")}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",sx:{color:n?"success.main":"grey.600"},children:m("forgotPassword.checkEmailInstructions")})]}),_jsxruntime.jsx.call(void 0, _material.Button,{type:"button",onClick:P,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:m("forgotPassword.enterCodeLink")}),_jsxruntime.jsx.call(void 0, _material.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:_jsxruntime.jsx.call(void 0, _material.Link,{sx:{cursor:"pointer"},onClick:w,variant:"body2",color:"secondary",children:m("common.back")})})]})}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, _material.Box,{component:"form",noValidate:!0,sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:2},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:m("forgotPassword.title")}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",sx:{color:"grey.600"},children:m("forgotPassword.instructions")})]}),_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:1},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",component:"label",htmlFor:"email",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:m("forgotPassword.emailLabel")}),_jsxruntime.jsx.call(void 0, _material.TextField,{fullWidth:!0,id:"email",name:"email",type:"email",value:t,disabled:s,onChange:T=>c(T.target.value),error:!!u,helperText:u,autoComplete:"email",placeholder:m("forgotPassword.emailPlaceholder"),required:!0})]}),_jsxruntime.jsx.call(void 0, _material.Button,{disabled:s,type:"button",onClick:p,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:s?_jsxruntime.jsx.call(void 0, _material.CircularProgress,{size:20}):m("forgotPassword.sendCodeButton")}),_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",gap:2},children:[_jsxruntime.jsx.call(void 0, _material.Link,{sx:{cursor:"pointer"},onClick:w,variant:"body2",color:"secondary",children:m("common.back")}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",sx:{color:"grey.400"},children:"\u2022"}),_jsxruntime.jsx.call(void 0, _material.Link,{sx:{cursor:"pointer"},onClick:P,variant:"body2",color:"secondary",children:m("login.alreadyHaveCodeLink")})]})]}),_jsxruntime.jsx.call(void 0, _material.Box,{children:f.length>0&&f.map((T,v)=>_jsxruntime.jsx.call(void 0, _material.Alert,{variant:"filled",sx:{mt:2},severity:"error",children:T},v))})]})},vo=xr;var vr=({onScreenChange:e,onError:o,searchParams:r,onResetSuccess:t})=>{let{crudify:c}=_chunk6RWBJJWLjs.c.call(void 0, ),[s,a]=_react.useState.call(void 0, ""),[f,d]=_react.useState.call(void 0, ""),[u,g]=_react.useState.call(void 0, !1),[h,l]=_react.useState.call(void 0, []),[n,i]=_react.useState.call(void 0, null),[m,x]=_react.useState.call(void 0, null),[C,p]=_react.useState.call(void 0, ""),[w,P]=_react.useState.call(void 0, ""),[T,v]=_react.useState.call(void 0, !1),[y,R]=_react.useState.call(void 0, !0),[S,I]=_react.useState.call(void 0, !1),[V,_]=_react.useState.call(void 0, null),[oe,$]=_react.useState.call(void 0, !1),{t:O}=H(),ve=E=>{let L=[`errors.auth.${E.code}`,`errors.data.${E.code}`,`errors.system.${E.code}`,`errors.${E.code}`,`resetPassword.${E.code.toLowerCase()}`];for(let z of L){let W=O(z);if(W!==z)return W}return E.message||O("error.unknown")},Se=E=>r?r instanceof URLSearchParams?r.get(E):r[E]||null:null;_react.useEffect.call(void 0, ()=>{if(r){if(r){let E=Se("fromCodeVerification"),L=Se("email"),z=Se("code");if(E==="true"&&L&&z){p(L),P(z),v(!0),I(!0),R(!1);return}let W=Se("link");if(W)try{let Y=decodeURIComponent(W),[G,ye]=Y.split("/");if(G&&ye&&G.length===6){P(G),p(ye),v(!1),_({email:ye,code:G});return}}catch (e5){}if(L&&z){p(L),P(z),v(!1),_({email:L,code:z});return}}l([O("resetPassword.invalidCode")]),R(!1),setTimeout(()=>_optionalChain([e, 'optionalCall', _24 => _24("forgotPassword")]),3e3)}},[r,c,O,e]),_react.useEffect.call(void 0, ()=>{c&&V&&!oe&&($(!0),(async(L,z)=>{try{let W=[{operation:"validatePasswordResetCode",data:{email:L,codePassword:z}}],Y=await c.transaction(W);if(Y.data&&Array.isArray(Y.data)){let G=Y.data[0];if(G&&G.response&&G.response.status==="OK"){I(!0);return}}if(Y.success)I(!0);else{let ye=_chunkYIIUEOXCjs.g.call(void 0, Y).map(ve);l(ye),setTimeout(()=>_optionalChain([e, 'optionalCall', _25 => _25("forgotPassword")]),3e3)}}catch(W){let G=_chunkYIIUEOXCjs.g.call(void 0, W).map(ve);l(G),setTimeout(()=>_optionalChain([e, 'optionalCall', _26 => _26("forgotPassword")]),3e3)}finally{R(!1),_(null),$(!1)}})(V.email,V.code))},[c,V,O,e]);let Ko=E=>E.length<8?O("resetPassword.passwordTooShort"):null,$o=async()=>{if(u||!c)return;l([]),i(null),x(null);let E=!1;if(!s)i(O("resetPassword.newPasswordRequired")),E=!0;else{let L=Ko(s);L&&(i(L),E=!0)}if(f?s!==f&&(x(O("resetPassword.passwordsDoNotMatch")),E=!0):(x(O("resetPassword.confirmPasswordRequired")),E=!0),!E){g(!0);try{let L=[{operation:"validateAndResetPassword",data:{email:C,codePassword:w,newPassword:s}}],z=await c.transaction(L);if(z.success)l([]),setTimeout(()=>{_optionalChain([t, 'optionalCall', _27 => _27()])},1e3);else{let Y=_chunkYIIUEOXCjs.g.call(void 0, z).map(ve);l(Y)}}catch(L){let W=_chunkYIIUEOXCjs.g.call(void 0, L).map(ve);l(W),o&&o(W.join(", "))}g(!1)}},Yo=()=>{T?_optionalChain([e, 'optionalCall', _28 => _28("checkCode",{email:C})]):_optionalChain([e, 'optionalCall', _29 => _29("forgotPassword")])};return y?_jsxruntime.jsx.call(void 0, _material.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"300px"},children:_jsxruntime.jsx.call(void 0, _material.CircularProgress,{})}):S?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, _material.Box,{component:"form",noValidate:!0,sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:2},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:O("resetPassword.title")}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",sx:{color:"grey.600"},children:O("resetPassword.instructions")})]}),_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:1},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",component:"label",htmlFor:"newPassword",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:O("resetPassword.newPasswordLabel")}),_jsxruntime.jsx.call(void 0, _material.TextField,{fullWidth:!0,id:"newPassword",name:"newPassword",type:"password",value:s,disabled:u,onChange:E=>a(E.target.value),error:!!n,helperText:n,autoComplete:"new-password",placeholder:O("resetPassword.newPasswordPlaceholder"),required:!0})]}),_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:1},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",component:"label",htmlFor:"confirmPassword",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:O("resetPassword.confirmPasswordLabel")}),_jsxruntime.jsx.call(void 0, _material.TextField,{fullWidth:!0,id:"confirmPassword",name:"confirmPassword",type:"password",value:f,disabled:u,onChange:E=>d(E.target.value),error:!!m,helperText:m,autoComplete:"new-password",placeholder:O("resetPassword.confirmPasswordPlaceholder"),required:!0})]}),_jsxruntime.jsx.call(void 0, _material.Button,{disabled:u,type:"button",onClick:$o,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:u?_jsxruntime.jsx.call(void 0, _material.CircularProgress,{size:20}):O("resetPassword.resetPasswordButton")}),_jsxruntime.jsx.call(void 0, _material.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:_jsxruntime.jsx.call(void 0, _material.Link,{sx:{cursor:"pointer"},onClick:Yo,variant:"body2",color:"secondary",children:O("common.back")})})]}),_jsxruntime.jsx.call(void 0, _material.Box,{children:h.length>0&&h.map((E,L)=>_jsxruntime.jsx.call(void 0, _material.Alert,{variant:"filled",sx:{mt:2},severity:"error",children:E},L))})]}):_jsxruntime.jsx.call(void 0, _material.Box,{children:h.length>0&&h.map((E,L)=>_jsxruntime.jsx.call(void 0, _material.Alert,{variant:"filled",sx:{mt:2},severity:"error",children:E},L))})},ko=vr;var Or=({onScreenChange:e,onError:o,searchParams:r})=>{let{crudify:t}=_chunk6RWBJJWLjs.c.call(void 0, ),[c,s]=_react.useState.call(void 0, ""),[a,f]=_react.useState.call(void 0, !1),[d,u]=_react.useState.call(void 0, []),[g,h]=_react.useState.call(void 0, null),[l,n]=_react.useState.call(void 0, ""),{t:i}=H(),m=P=>r?r instanceof URLSearchParams?r.get(P):r[P]||null:null,x=P=>{let T=[`errors.auth.${P.code}`,`errors.data.${P.code}`,`errors.system.${P.code}`,`errors.${P.code}`,`checkCode.${P.code.toLowerCase()}`];for(let v of T){let y=i(v);if(y!==v)return y}return P.message||i("error.unknown")};_react.useEffect.call(void 0, ()=>{let P=m("email");P?n(P):_optionalChain([e, 'optionalCall', _30 => _30("forgotPassword")])},[r,e]);let C=async()=>{if(!(a||!t)){if(u([]),h(null),!c){h(i("checkCode.codeRequired"));return}if(c.length!==6){h(i("checkCode.codeRequired"));return}f(!0);try{let P=[{operation:"validatePasswordResetCode",data:{email:l,codePassword:c}}],T=await t.transaction(P);if(T.success)_optionalChain([e, 'optionalCall', _31 => _31("resetPassword",{email:l,code:c,fromCodeVerification:"true"})]);else{let y=_chunkYIIUEOXCjs.g.call(void 0, T).map(x);u(y),f(!1)}}catch(P){let v=_chunkYIIUEOXCjs.g.call(void 0, P).map(x);u(v),f(!1),o&&o(v.join(", "))}}},p=()=>{_optionalChain([e, 'optionalCall', _32 => _32("forgotPassword")])},w=P=>{let T=P.target.value.replace(/\D/g,"").slice(0,6);s(T)};return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, _material.Box,{component:"form",noValidate:!0,sx:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:2},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h5",component:"h1",sx:{mb:1,fontWeight:600},children:i("checkCode.title")}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",sx:{color:"grey.600"},children:i("checkCode.instructions")})]}),_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:1},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",component:"label",htmlFor:"code",sx:{display:"block",fontWeight:500,color:"grey.700",mb:.5},children:i("checkCode.codeLabel")}),_jsxruntime.jsx.call(void 0, _material.TextField,{fullWidth:!0,id:"code",name:"code",type:"text",value:c,disabled:a,onChange:w,error:!!g,helperText:g,placeholder:i("checkCode.codePlaceholder"),inputProps:{maxLength:6,style:{textAlign:"center",fontSize:"1.5rem",letterSpacing:"0.4rem"}},required:!0})]}),_jsxruntime.jsx.call(void 0, _material.Button,{disabled:a||c.length!==6,type:"button",onClick:C,fullWidth:!0,variant:"contained",color:"primary",sx:{mt:2,mb:2},children:a?_jsxruntime.jsx.call(void 0, _material.CircularProgress,{size:20}):i("checkCode.verifyButton")}),_jsxruntime.jsx.call(void 0, _material.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:_jsxruntime.jsx.call(void 0, _material.Link,{sx:{cursor:"pointer"},onClick:p,variant:"body2",color:"secondary",children:i("common.back")})})]}),_jsxruntime.jsx.call(void 0, _material.Box,{children:d.length>0&&d.map((P,T)=>_jsxruntime.jsx.call(void 0, _material.Alert,{sx:{mt:2},severity:"error",children:P},T))})]})},Ao=Or;var No=({children:e,fallback:o})=>{let{isLoading:r,error:t,isInitialized:c}=_chunk6RWBJJWLjs.c.call(void 0, ),{t:s}=H();return r?o||_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"200px",gap:2},children:[_jsxruntime.jsx.call(void 0, _material.CircularProgress,{}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",color:"text.secondary",children:s("login.initializing")!=="login.initializing"?s("login.initializing"):"Initializing..."})]}):t?_jsxruntime.jsx.call(void 0, _material.Alert,{severity:"error",sx:{mt:2},children:_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"body2",children:[s("login.initializationError")!=="login.initializationError"?s("login.initializationError"):"Initialization error",":"," ",t]})}):c?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:e}):_jsxruntime.jsx.call(void 0, _material.Alert,{severity:"warning",sx:{mt:2},children:_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",children:s("login.notInitialized")!=="login.notInitialized"?s("login.notInitialized"):"System not initialized"})})};var Mr=({onScreenChange:e,onExternalNavigate:o,onLoginSuccess:r,onError:t,redirectUrl:c="/"})=>{let{t:s}=H(),{state:a,setScreen:f}=Ie(),{config:d}=_chunk6RWBJJWLjs.j.call(void 0, ),{showNotification:u}=_chunk6RWBJJWLjs.h.call(void 0, ),g=(l,n)=>{let i=n;l==="login"?i={}:l==="forgotPassword"&&!n&&(i={}),f(l,i),_optionalChain([e, 'optionalCall', _33 => _33(l,i)])},h=()=>{let l={onScreenChange:g,onExternalNavigate:o,onError:t,redirectUrl:c};switch(a.currentScreen){case"forgotPassword":return _jsxruntime.jsx.call(void 0, vo,{...l});case"checkCode":return _jsxruntime.jsx.call(void 0, Ao,{...l,searchParams:a.searchParams});case"resetPassword":return _jsxruntime.jsx.call(void 0, ko,{...l,searchParams:a.searchParams,onResetSuccess:()=>{let n=s("resetPassword.successMessage");u(n,"success"),g("login")}});default:return _jsxruntime.jsx.call(void 0, xo,{...l,onLoginSuccess:r})}};return _jsxruntime.jsxs.call(void 0, No,{children:[_jsxruntime.jsx.call(void 0, _material.Box,{sx:{display:"flex",justifyContent:"center",mb:3},children:_jsxruntime.jsx.call(void 0, "img",{src:d.logo||"https://logos.crudia.com/nocios-default.png",alt:s("login.logoAlt"),style:{width:"100%",maxWidth:"150px",height:"auto"},onError:l=>{let n=l.target;n.src="https://logos.crudia.com/nocios-default.png"}})}),!d.logo&&d.appName&&_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h6",component:"h1",sx:{textAlign:"center",mb:2},children:d.appName}),h()]})},Vr=({translations:e,translationsUrl:o,language:r="en",initialScreen:t="login",autoReadFromCookies:c=!0,...s})=>{let{config:a}=_chunk6RWBJJWLjs.j.call(void 0, );return _jsxruntime.jsx.call(void 0, po,{translations:e,translationsUrl:o,language:r,children:_jsxruntime.jsx.call(void 0, _chunk6RWBJJWLjs.b,{config:a,children:_jsxruntime.jsx.call(void 0, bo,{config:a,initialScreen:t,autoReadFromCookies:c,children:_jsxruntime.jsx.call(void 0, Mr,{...s})})})})},as= exports.h =Vr;var _iconsmaterial = require('@mui/icons-material');var st=({showExtendedData:e=!0,showProfileCard:o=!0,autoRefresh:r=!0})=>{let{userProfile:t,loading:c,error:s,extendedData:a,refreshProfile:f}=_chunk6RWBJJWLjs.l.call(void 0, {autoFetch:r,retryOnError:!0,maxRetries:3}),[d,u]=_react.useState.call(void 0, !1);if(c)return _jsxruntime.jsxs.call(void 0, _material.Box,{display:"flex",justifyContent:"center",alignItems:"center",p:3,children:[_jsxruntime.jsx.call(void 0, _material.CircularProgress,{}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",sx:{ml:2},children:"Cargando perfil de usuario..."})]});if(s)return _jsxruntime.jsxs.call(void 0, _material.Alert,{severity:"error",action:_jsxruntime.jsx.call(void 0, _material.IconButton,{color:"inherit",size:"small",onClick:f,children:_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"caption",children:"Reintentar"})}),children:["Error al cargar el perfil: ",s]});if(!t)return _jsxruntime.jsx.call(void 0, _material.Alert,{severity:"warning",children:"No se encontr\xF3 informaci\xF3n del usuario"});let g=_optionalChain([a, 'optionalAccess', _34 => _34.displayData])||{},h=_optionalChain([a, 'optionalAccess', _35 => _35.totalFields])||0,l=p=>{if(!p)return"No disponible";try{return new Date(p).toLocaleString("es-ES",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch (e6){return p}},n=(p,w)=>w==null?"No disponible":typeof w=="boolean"?w?"S\xED":"No":Array.isArray(w)?w.length>0?w.join(", "):"Ninguno":typeof w=="object"?JSON.stringify(w,null,2):String(w),i=[{key:"id",label:"ID",icon:_jsxruntime.jsx.call(void 0, _iconsmaterial.Badge,{})},{key:"email",label:"Email",icon:_jsxruntime.jsx.call(void 0, _iconsmaterial.Email,{})},{key:"username",label:"Usuario",icon:_jsxruntime.jsx.call(void 0, _iconsmaterial.Person,{})},{key:"fullName",label:"Nombre completo",icon:_jsxruntime.jsx.call(void 0, _iconsmaterial.AccountCircle,{})},{key:"role",label:"Rol",icon:_jsxruntime.jsx.call(void 0, _iconsmaterial.Security,{})}],m=[{key:"firstName",label:"Nombre"},{key:"lastName",label:"Apellido"},{key:"isActive",label:"Activo"},{key:"lastLogin",label:"\xDAltimo login"},{key:"createdAt",label:"Creado"},{key:"updatedAt",label:"Actualizado"}],x=[...i.map(p=>p.key),...m.map(p=>p.key),"permissions"],C=Object.keys(g).filter(p=>!x.includes(p)).map(p=>({key:p,label:p}));return _jsxruntime.jsxs.call(void 0, _material.Box,{children:[o&&_jsxruntime.jsx.call(void 0, _material.Card,{sx:{mb:2},children:_jsxruntime.jsxs.call(void 0, _material.CardContent,{children:[_jsxruntime.jsxs.call(void 0, _material.Box,{display:"flex",alignItems:"center",mb:2,children:[_jsxruntime.jsx.call(void 0, _material.Avatar,{src:g.avatar,sx:{width:56,height:56,mr:2},children:_optionalChain([g, 'access', _36 => _36.fullName, 'optionalAccess', _37 => _37[0]])||_optionalChain([g, 'access', _38 => _38.username, 'optionalAccess', _39 => _39[0]])||_optionalChain([g, 'access', _40 => _40.email, 'optionalAccess', _41 => _41[0]])}),_jsxruntime.jsxs.call(void 0, _material.Box,{children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h6",children:g.fullName||g.username||g.email}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",color:"text.secondary",children:g.role||"Usuario"}),g.isActive!==void 0&&_jsxruntime.jsx.call(void 0, _material.Chip,{label:g.isActive?"Activo":"Inactivo",color:g.isActive?"success":"error",size:"small",sx:{mt:.5}})]})]}),_jsxruntime.jsx.call(void 0, _material.Box,{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(250px, 1fr))",gap:2,children:i.map(({key:p,label:w,icon:P})=>g[p]?_jsxruntime.jsxs.call(void 0, _material.Box,{display:"flex",alignItems:"center",children:[_jsxruntime.jsx.call(void 0, _material.Box,{sx:{mr:1,color:"text.secondary"},children:P}),_jsxruntime.jsxs.call(void 0, _material.Box,{children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"caption",color:"text.secondary",children:w}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",children:n(p,g[p])})]})]},p):null)}),g.permissions&&Array.isArray(g.permissions)&&g.permissions.length>0&&_jsxruntime.jsxs.call(void 0, _material.Box,{mt:2,children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"caption",color:"text.secondary",display:"block",children:"Permisos"}),_jsxruntime.jsxs.call(void 0, _material.Box,{display:"flex",flexWrap:"wrap",gap:.5,mt:.5,children:[g.permissions.slice(0,5).map((p,w)=>_jsxruntime.jsx.call(void 0, _material.Chip,{label:p,size:"small",variant:"outlined"},w)),g.permissions.length>5&&_jsxruntime.jsx.call(void 0, _material.Chip,{label:`+${g.permissions.length-5} m\xE1s`,size:"small"})]})]})]})}),e&&_jsxruntime.jsx.call(void 0, _material.Card,{children:_jsxruntime.jsxs.call(void 0, _material.CardContent,{children:[_jsxruntime.jsxs.call(void 0, _material.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"h6",display:"flex",alignItems:"center",children:[_jsxruntime.jsx.call(void 0, _iconsmaterial.Info,{sx:{mr:1}}),"Informaci\xF3n Detallada"]}),_jsxruntime.jsx.call(void 0, _material.Chip,{label:`${h} campos totales`,size:"small"})]}),_jsxruntime.jsxs.call(void 0, _material.List,{dense:!0,children:[m.map(({key:p,label:w})=>g[p]!==void 0&&_jsxruntime.jsxs.call(void 0, _material.ListItem,{divider:!0,children:[_jsxruntime.jsx.call(void 0, _material.ListItemIcon,{children:_jsxruntime.jsx.call(void 0, _iconsmaterial.Schedule,{fontSize:"small"})}),_jsxruntime.jsx.call(void 0, _material.ListItemText,{primary:w,secondary:p.includes("At")||p.includes("Login")?l(g[p]):n(p,g[p])})]},p)),C.length>0&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _material.Divider,{sx:{my:1}}),_jsxruntime.jsx.call(void 0, _material.ListItem,{children:_jsxruntime.jsx.call(void 0, _material.ListItemText,{primary:_jsxruntime.jsxs.call(void 0, _material.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"subtitle2",children:["Campos Personalizados (",C.length,")"]}),_jsxruntime.jsx.call(void 0, _material.IconButton,{size:"small",onClick:()=>u(!d),children:d?_jsxruntime.jsx.call(void 0, _iconsmaterial.ExpandLess,{}):_jsxruntime.jsx.call(void 0, _iconsmaterial.ExpandMore,{})})]})})}),_jsxruntime.jsx.call(void 0, _material.Collapse,{in:d,children:C.map(({key:p,label:w})=>_jsxruntime.jsx.call(void 0, _material.ListItem,{sx:{pl:4},children:_jsxruntime.jsx.call(void 0, _material.ListItemText,{primary:w,secondary:n(p,g[p])})},p))})]})]}),_jsxruntime.jsxs.call(void 0, _material.Box,{mt:2,display:"flex",justifyContent:"space-between",alignItems:"center",children:[_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"caption",color:"text.secondary",children:["\xDAltima actualizaci\xF3n: ",l(g.updatedAt)]}),_jsxruntime.jsx.call(void 0, _material.IconButton,{size:"small",onClick:f,disabled:c,children:_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"caption",children:"Actualizar"})})]})]})})]})},at= exports.i =st;var Uo=["create","read","update","delete"],zo= exports.k =["create","read","update","delete"];var _reacti18next = require('react-i18next');var ht=({value:e,onChange:o,availableFields:r,error:t,disabled:c=!1})=>{let{t:s}=_reacti18next.useTranslation.call(void 0, ),[a,f]=_react.useState.call(void 0, "custom"),d=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{let n=e||{allow:[],owner_allow:[],deny:[]},i=new Set(r),m=(n.allow||[]).filter(w=>i.has(w)),x=(n.owner_allow||[]).filter(w=>i.has(w)),C=(n.deny||[]).filter(w=>i.has(w));r.forEach(w=>{!m.includes(w)&&!x.includes(w)&&!C.includes(w)&&C.push(w)});let p={allow:m,owner_allow:x,deny:C};JSON.stringify(p)!==JSON.stringify(n)&&o(p),m.length===r.length?f("all"):C.length===r.length?f("none"):f("custom")},[r,e]);let u=()=>{d.current=!0,o({allow:[...r],owner_allow:[],deny:[]}),f("all"),setTimeout(()=>{d.current=!1},0)},g=()=>{d.current=!0,o({allow:[],owner_allow:[],deny:[...r]}),f("none"),setTimeout(()=>{d.current=!1},0)},h=n=>_optionalChain([e, 'optionalAccess', _42 => _42.allow, 'optionalAccess', _43 => _43.includes, 'call', _44 => _44(n)])?"allow":_optionalChain([e, 'optionalAccess', _45 => _45.owner_allow, 'optionalAccess', _46 => _46.includes, 'call', _47 => _47(n)])?"owner_allow":"deny",l=(n,i)=>{d.current=!0;let m=new Set(_optionalChain([e, 'optionalAccess', _48 => _48.allow])||[]),x=new Set(_optionalChain([e, 'optionalAccess', _49 => _49.owner_allow])||[]),C=new Set(_optionalChain([e, 'optionalAccess', _50 => _50.deny])||[]);m.delete(n),x.delete(n),C.delete(n),i==="allow"&&m.add(n),i==="owner_allow"&&x.add(n),i==="deny"&&C.add(n),o({allow:Array.from(m),owner_allow:Array.from(x),deny:Array.from(C)}),f("custom"),setTimeout(()=>{d.current=!1},0)};return r.length===0?_jsxruntime.jsxs.call(void 0, _material.Box,{children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1},children:s("modules.form.publicPolicies.fields.conditions.label")}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",color:"text.secondary",sx:{fontStyle:"italic"},children:s("modules.form.publicPolicies.fields.conditions.noFieldsAvailable")}),t&&_jsxruntime.jsx.call(void 0, _material.FormHelperText,{error:!0,sx:{mt:1},children:t})]}):_jsxruntime.jsxs.call(void 0, _material.Box,{children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2},children:s("modules.form.publicPolicies.fields.conditions.label")}),_jsxruntime.jsxs.call(void 0, _material.Stack,{direction:"row",spacing:1,sx:{mb:3},children:[_jsxruntime.jsx.call(void 0, _material.Button,{variant:a==="all"?"contained":"outlined",startIcon:_jsxruntime.jsx.call(void 0, _iconsmaterial.SelectAll,{}),onClick:u,disabled:c,size:"small",sx:{minWidth:120,...a==="all"&&{backgroundColor:"#16a34a","&:hover":{backgroundColor:"#15803d"}}},children:s("modules.form.publicPolicies.fields.conditions.allFields")}),_jsxruntime.jsx.call(void 0, _material.Button,{variant:a==="none"?"contained":"outlined",startIcon:_jsxruntime.jsx.call(void 0, _iconsmaterial.ClearAll,{}),onClick:g,disabled:c,size:"small",sx:{minWidth:120,...a==="none"&&{backgroundColor:"#cf222e","&:hover":{backgroundColor:"#bc1f2c"}}},children:s("modules.form.publicPolicies.fields.conditions.noFields")})]}),_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{p:2,border:"1px solid #d1d9e0",borderRadius:1,backgroundColor:"#f6f8fa"},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2},children:s("modules.form.publicPolicies.fields.conditions.help")}),_jsxruntime.jsx.call(void 0, _material.Stack,{spacing:1,children:r.map(n=>{let i=h(n);return _jsxruntime.jsxs.call(void 0, _material.Stack,{direction:"row",spacing:1,alignItems:"center",children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",sx:{minWidth:100,fontFamily:"monospace"},children:n}),_jsxruntime.jsxs.call(void 0, _material.ToggleButtonGroup,{value:i,exclusive:!0,size:"small",children:[_jsxruntime.jsxs.call(void 0, _material.ToggleButton,{value:"allow",onClick:()=>l(n,"allow"),disabled:c,sx:{px:2,color:i==="allow"?"#ffffff":"#6b7280",backgroundColor:i==="allow"?"#16a34a":"#f3f4f6",borderColor:i==="allow"?"#16a34a":"#d1d5db","&:hover":{backgroundColor:i==="allow"?"#15803d":"#e5e7eb",borderColor:i==="allow"?"#15803d":"#9ca3af"},"&.Mui-selected":{backgroundColor:"#16a34a",color:"#ffffff","&:hover":{backgroundColor:"#15803d"}}},children:[_jsxruntime.jsx.call(void 0, _iconsmaterial.CheckCircle,{sx:{fontSize:16,mr:.5}}),s("modules.form.publicPolicies.fields.conditions.states.allow")]}),_jsxruntime.jsx.call(void 0, _material.ToggleButton,{value:"owner_allow",onClick:()=>l(n,"owner_allow"),disabled:c,sx:{px:2,color:i==="owner_allow"?"#ffffff":"#6b7280",backgroundColor:i==="owner_allow"?"#0ea5e9":"#f3f4f6",borderColor:i==="owner_allow"?"#0ea5e9":"#d1d5db","&:hover":{backgroundColor:i==="owner_allow"?"#0284c7":"#e5e7eb",borderColor:i==="owner_allow"?"#0284c7":"#9ca3af"},"&.Mui-selected":{backgroundColor:"#0ea5e9",color:"#ffffff","&:hover":{backgroundColor:"#0284c7"}}},children:s("modules.form.publicPolicies.fields.conditions.states.ownerAllow")}),_jsxruntime.jsxs.call(void 0, _material.ToggleButton,{value:"deny",onClick:()=>l(n,"deny"),disabled:c,sx:{px:2,color:i==="deny"?"#ffffff":"#6b7280",backgroundColor:i==="deny"?"#dc2626":"#f3f4f6",borderColor:i==="deny"?"#dc2626":"#d1d5db","&:hover":{backgroundColor:i==="deny"?"#b91c1c":"#e5e7eb",borderColor:i==="deny"?"#b91c1c":"#9ca3af"},"&.Mui-selected":{backgroundColor:"#dc2626",color:"#ffffff","&:hover":{backgroundColor:"#b91c1c"}}},children:[_jsxruntime.jsx.call(void 0, _iconsmaterial.Cancel,{sx:{fontSize:16,mr:.5}}),s("modules.form.publicPolicies.fields.conditions.states.deny")]})]})]},n)})})]}),t&&_jsxruntime.jsx.call(void 0, _material.FormHelperText,{error:!0,sx:{mt:1},children:t})]})},Je=ht;var kt=_react.forwardRef.call(void 0, ({policy:e,onChange:o,onRemove:r,availableFields:t,isSubmitting:c=!1,usedActions:s,error:a},f)=>{let{t:d}=_reacti18next.useTranslation.call(void 0, ),u=new Set(Array.from(s||[]));u.delete(e.action);let g=Uo.map(h=>({value:h,label:d(`modules.form.publicPolicies.fields.action.options.${h}`)}));return _jsxruntime.jsxs.call(void 0, _material.Paper,{ref:f,sx:{p:3,border:"1px solid #d1d9e0",borderRadius:2,position:"relative",backgroundColor:"#ffffff"},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:3},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"subtitle1",sx:{fontWeight:600,color:"#111418",fontSize:"1rem"},children:d("modules.form.publicPolicies.policyTitle")}),_jsxruntime.jsx.call(void 0, _material.IconButton,{onClick:r,size:"small",disabled:c,"aria-label":d("modules.form.publicPolicies.removePolicy"),sx:{color:"#656d76","&:hover":{color:"#cf222e",backgroundColor:"rgba(207, 34, 46, 0.1)"}},children:_jsxruntime.jsx.call(void 0, _iconsmaterial.Delete,{})})]}),_jsxruntime.jsxs.call(void 0, _material.Stack,{spacing:3,children:[_jsxruntime.jsx.call(void 0, _material.Stack,{direction:{xs:"column",md:"row"},spacing:2,children:_jsxruntime.jsx.call(void 0, _material.Box,{sx:{flex:1,minWidth:200},children:_jsxruntime.jsxs.call(void 0, _material.FormControl,{fullWidth:!0,children:[_jsxruntime.jsx.call(void 0, _material.InputLabel,{children:d("modules.form.publicPolicies.fields.action.label")}),_jsxruntime.jsx.call(void 0, _material.Select,{value:e.action,label:d("modules.form.publicPolicies.fields.action.label"),disabled:c,onChange:h=>{let l=h.target.value,n={...e,action:l};l==="delete"?(n.permission="deny",delete n.fields):(n.fields={allow:[],owner_allow:[],deny:t},delete n.permission),o(n)},sx:{backgroundColor:"#ffffff","&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"#8c959f"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"#0969da",borderWidth:2}},children:g.map(h=>{let l=u.has(h.value);return _jsxruntime.jsx.call(void 0, _material.MenuItem,{value:h.value,disabled:l,children:h.label},h.value)})}),a&&_jsxruntime.jsx.call(void 0, _material.FormHelperText,{error:!0,children:a})]})})}),e.action==="delete"?_jsxruntime.jsxs.call(void 0, _material.Box,{children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2},children:d("modules.form.publicPolicies.fields.conditions.label")}),_jsxruntime.jsxs.call(void 0, _material.Stack,{direction:"row",spacing:1,sx:{mb:3},children:[_jsxruntime.jsx.call(void 0, _material.Button,{variant:e.permission==="*"?"contained":"outlined",startIcon:_jsxruntime.jsx.call(void 0, _iconsmaterial.SelectAll,{}),onClick:()=>o({...e,permission:"*"}),disabled:c,size:"small",sx:{minWidth:140,whiteSpace:"nowrap",...e.permission==="*"&&{backgroundColor:"#16a34a","&:hover":{backgroundColor:"#15803d"}}},children:d("modules.form.publicPolicies.fields.conditions.allFields")}),_jsxruntime.jsx.call(void 0, _material.Button,{variant:e.permission==="owner"?"contained":"outlined",onClick:()=>o({...e,permission:"owner"}),disabled:c,size:"small",sx:{minWidth:140,whiteSpace:"nowrap",...e.permission==="owner"&&{backgroundColor:"#0ea5e9","&:hover":{backgroundColor:"#0284c7"}}},children:d("modules.form.publicPolicies.fields.conditions.states.ownerAllow")}),_jsxruntime.jsx.call(void 0, _material.Button,{variant:e.permission==="deny"?"contained":"outlined",startIcon:_jsxruntime.jsx.call(void 0, _iconsmaterial.ClearAll,{}),onClick:()=>o({...e,permission:"deny"}),disabled:c,size:"small",sx:{minWidth:140,whiteSpace:"nowrap",...e.permission==="deny"&&{backgroundColor:"#cf222e","&:hover":{backgroundColor:"#bc1f2c"}}},children:d("modules.form.publicPolicies.fields.conditions.noFields")})]})]}):_jsxruntime.jsx.call(void 0, Je,{value:e.fields||{allow:[],owner_allow:[],deny:[]},onChange:h=>o({...e,fields:h}),availableFields:t,disabled:c}),_jsxruntime.jsx.call(void 0, _material.Paper,{variant:"outlined",sx:{p:2,backgroundColor:"#f9fafb"},children:e.action==="delete"?_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{component:"span",sx:{color:e.permission==="*"?"#16a34a":e.permission==="owner"?"#0ea5e9":"#dc2626"},children:[d("modules.form.publicPolicies.fields.conditions.states.allow"),":"]})," ",e.permission||"-"]}):_jsxruntime.jsxs.call(void 0, _material.Stack,{spacing:.5,divider:_jsxruntime.jsx.call(void 0, _material.Divider,{sx:{borderColor:"#e5e7eb"}}),children:[_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{component:"span",sx:{color:"#16a34a"},children:[d("modules.form.publicPolicies.fields.conditions.states.allow"),":"]})," ",(_optionalChain([e, 'optionalAccess', _51 => _51.fields, 'optionalAccess', _52 => _52.allow])||[]).join(", ")||"-"]}),_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{component:"span",sx:{color:"#0ea5e9"},children:[d("modules.form.publicPolicies.fields.conditions.states.ownerAllow"),":"]})," ",(_optionalChain([e, 'optionalAccess', _53 => _53.fields, 'optionalAccess', _54 => _54.owner_allow])||[]).join(", ")||"-"]}),_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"body2",sx:{fontFamily:"monospace",color:"text.secondary"},children:[_jsxruntime.jsxs.call(void 0, _material.Box,{component:"span",sx:{color:"#dc2626"},children:[d("modules.form.publicPolicies.fields.conditions.states.deny"),":"]})," ",(_optionalChain([e, 'optionalAccess', _55 => _55.fields, 'optionalAccess', _56 => _56.deny])||[]).join(", ")||"-"]})]})})]})]})}),Xe=kt;var Bt=()=>{let e=_optionalChain([globalThis, 'optionalAccess', _57 => _57.crypto]);return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`},Ut=({policies:e,onChange:o,availableFields:r,errors:t,isSubmitting:c=!1})=>{let{t:s}=_reacti18next.useTranslation.call(void 0, ),a=_react.useRef.call(void 0, {}),f=new Set((e||[]).map(i=>i.action).filter(Boolean)),d=zo.filter(i=>!f.has(i)),u=d.length>0,g=()=>{let i=d[0]||"create",m={id:Bt(),action:i};i==="delete"?m.permission="deny":m.fields={allow:[],owner_allow:[],deny:r};let x=[...e||[],m];o(x),setTimeout(()=>{let C=x.length-1,p=a.current[C];p&&p.scrollIntoView({behavior:"smooth",block:"center"})},100)},h=i=>{let m=[...e];m.splice(i,1),o(m)},l=(()=>{if(!t)return null;if(typeof t=="string")return t;let i=t._error;return typeof i=="string"?i:null})(),n=new Set((e||[]).map(i=>i.action));return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _material.Divider,{sx:{borderColor:"#e0e4e7"}}),_jsxruntime.jsxs.call(void 0, _material.Box,{children:[_jsxruntime.jsx.call(void 0, _material.Box,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3,children:_jsxruntime.jsxs.call(void 0, _material.Box,{children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h6",sx:{fontWeight:600,color:"#111418",mb:1},children:s("modules.form.publicPolicies.title")}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"body2",color:"text.secondary",sx:{fontSize:"0.875rem"},children:s("modules.form.publicPolicies.description")})]})}),l&&_jsxruntime.jsx.call(void 0, _material.Alert,{severity:"error",sx:{mb:3},children:l}),_jsxruntime.jsxs.call(void 0, _material.Stack,{spacing:3,children:[(e||[]).length===0?_jsxruntime.jsx.call(void 0, _material.Alert,{severity:"info",children:s("modules.form.publicPolicies.noPolicies")}):e.map((i,m)=>_jsxruntime.jsx.call(void 0, Xe,{ref:x=>{a.current[m]=x},policy:i,onChange:x=>{let C=[...e];C[m]=x,o(C)},onRemove:()=>h(m),availableFields:r,isSubmitting:c,usedActions:n,error:typeof t=="object"&&t&&i.id in t?t[i.id]:void 0},i.id)),u&&_jsxruntime.jsx.call(void 0, _material.Box,{children:_jsxruntime.jsx.call(void 0, _material.Button,{type:"button",variant:"outlined",startIcon:_jsxruntime.jsx.call(void 0, _iconsmaterial.Add,{}),onClick:g,disabled:c,sx:{borderColor:"#d0d7de",color:"#656d76","&:hover":{borderColor:"#8c959f",backgroundColor:"transparent"}},children:s("modules.form.publicPolicies.addPolicy")})})]})]})]})},qs= exports.l =Ut;function Qs(){let[e,o]=_react.useState.call(void 0, ""),[r,t]=_react.useState.call(void 0, ""),[c,s]=_react.useState.call(void 0, !1),{isAuthenticated:a,isLoading:f,error:d,login:u,logout:g,refreshTokens:h,clearError:l,isExpiringSoon:n,expiresIn:i}=_chunk6RWBJJWLjs.j.call(void 0, ),m=async p=>{if(p.preventDefault(),!e||!r)return;(await u(e,r)).success&&(o(""),t(""),s(!1))},x=async()=>{await g()},C=async()=>{await h()};return a?_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{maxWidth:600,mx:"auto",p:3},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h4",gutterBottom:!0,children:"Welcome! \u{1F389}"}),_jsxruntime.jsx.call(void 0, _material.Alert,{severity:"success",sx:{mb:3},children:"You are successfully logged in with Refresh Token Pattern enabled"}),_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{mb:3,p:2,bgcolor:"background.paper",border:1,borderColor:"divider",borderRadius:1},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h6",gutterBottom:!0,children:"Token Status"}),_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"body2",color:"text.secondary",children:["Access Token expires in: ",Math.round(i/1e3/60)," minutes"]}),n&&_jsxruntime.jsx.call(void 0, _material.Alert,{severity:"warning",sx:{mt:1},children:"Token expires soon - automatic refresh will happen"})]}),_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[_jsxruntime.jsx.call(void 0, _material.Button,{variant:"contained",onClick:C,disabled:f,startIcon:f?_jsxruntime.jsx.call(void 0, _material.CircularProgress,{size:16}):null,children:"Refresh Tokens"}),_jsxruntime.jsx.call(void 0, _material.Button,{variant:"outlined",color:"error",onClick:x,disabled:f,children:"Logout"})]}),d&&_jsxruntime.jsx.call(void 0, _material.Alert,{severity:"error",sx:{mt:2},onClose:l,children:d})]}):_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{maxWidth:400,mx:"auto",p:3},children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"h4",gutterBottom:!0,align:"center",children:"Login with Refresh Tokens"}),_jsxruntime.jsx.call(void 0, _material.Alert,{severity:"info",sx:{mb:3},children:"This demo shows the new Refresh Token Pattern with automatic session management"}),c?_jsxruntime.jsxs.call(void 0, "form",{onSubmit:m,children:[_jsxruntime.jsx.call(void 0, _material.TextField,{fullWidth:!0,label:"Email",type:"email",value:e,onChange:p=>o(p.target.value),margin:"normal",required:!0,autoComplete:"email"}),_jsxruntime.jsx.call(void 0, _material.TextField,{fullWidth:!0,label:"Password",type:"password",value:r,onChange:p=>t(p.target.value),margin:"normal",required:!0,autoComplete:"current-password"}),_jsxruntime.jsx.call(void 0, _material.Button,{type:"submit",fullWidth:!0,variant:"contained",size:"large",disabled:f,startIcon:f?_jsxruntime.jsx.call(void 0, _material.CircularProgress,{size:16}):null,sx:{mt:3,mb:2},children:f?"Logging in...":"Login"})]}):_jsxruntime.jsx.call(void 0, _material.Button,{fullWidth:!0,variant:"contained",size:"large",onClick:()=>s(!0),sx:{mt:2},children:"Show Login Form"}),d&&_jsxruntime.jsx.call(void 0, _material.Alert,{severity:"error",sx:{mt:2},onClose:l,children:d})]})}function Xs(){let{isAuthenticated:e,isLoading:o,isExpiringSoon:r,expiresIn:t}=_chunk6RWBJJWLjs.j.call(void 0, );return o?_jsxruntime.jsxs.call(void 0, _material.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[_jsxruntime.jsx.call(void 0, _material.CircularProgress,{size:16}),_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"caption",children:"Loading session..."})]}):e?_jsxruntime.jsxs.call(void 0, _material.Box,{children:[_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"caption",color:"success.main",children:"\u2713 Authenticated"}),r&&_jsxruntime.jsxs.call(void 0, _material.Typography,{variant:"caption",color:"warning.main",display:"block",children:["\u26A0 Token expires in ",Math.round(t/1e3/60)," min"]})]}):_jsxruntime.jsx.call(void 0, _material.Typography,{variant:"caption",color:"text.secondary",children:"Not logged in"})}exports.a = re; exports.b = Mt; exports.c = Vt; exports.d = De; exports.e = Be; exports.f = Jt; exports.g = uo; exports.h = as; exports.i = at; exports.j = Uo; exports.k = zo; exports.l = qs; exports.m = Qs; exports.n = Xs;
|