@nocios/crudify-ui 4.1.66 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
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};
@@ -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 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;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkASKWBHUAjs = require('./chunk-ASKWBHUA.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 = _chunkASKWBHUAjs.a; exports.GlobalNotificationProvider = _chunk6RWBJJWLjs.g; exports.LoginComponent = _chunkASKWBHUAjs.f; exports.Policies = _chunkASKWBHUAjs.e; exports.SessionStatus = _chunkASKWBHUAjs.g; exports.SessionTimeIndicator = G; exports.UserProfileDisplay = _chunkASKWBHUAjs.b; exports.useGlobalNotification = _chunk6RWBJJWLjs.h;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJWIFFUC5js = require('./chunk-JWIFFUC5.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 = _chunkJWIFFUC5js.h; exports.GlobalNotificationProvider = _chunk6RWBJJWLjs.g; exports.LoginComponent = _chunkJWIFFUC5js.m; exports.Policies = _chunkJWIFFUC5js.l; exports.SessionStatus = _chunkJWIFFUC5js.n; exports.SessionTimeIndicator = G; exports.UserProfileDisplay = _chunkJWIFFUC5js.i; exports.useGlobalNotification = _chunk6RWBJJWLjs.h;
@@ -1 +1 @@
1
- import{a as T,b as L,e as M,f as R,g as k}from"./chunk-B7SKVPIB.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};
1
+ import{h as T,i as L,l as M,m as R,n as k}from"./chunk-IIXFLIEW.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
@@ -485,6 +485,8 @@ interface TranslationsProviderProps {
485
485
  translationUrl?: string;
486
486
  enableDebug?: boolean;
487
487
  skipAutoInit?: boolean;
488
+ autoSyncI18n?: boolean;
489
+ i18nInstance?: any;
488
490
  }
489
491
  interface TranslationsContextValue {
490
492
  t: (key: string, variables?: Record<string, any>) => string;
package/dist/index.d.ts CHANGED
@@ -485,6 +485,8 @@ interface TranslationsProviderProps {
485
485
  translationUrl?: string;
486
486
  enableDebug?: boolean;
487
487
  skipAutoInit?: boolean;
488
+ autoSyncI18n?: boolean;
489
+ i18nInstance?: any;
488
490
  }
489
491
  interface TranslationsContextValue {
490
492
  t: (key: string, variables?: Record<string, any>) => string;