limbo-component 4.2.1 → 4.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/limbo.cjs.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react"),t=require("react-dom"),l=require("react/jsx-runtime"),n={jpg:["image/jpeg"],jpeg:["image/jpeg"],png:["image/png"],gif:["image/gif"],webp:["image/webp"],svg:["image/svg+xml"],mp4:["video/mp4"],webm:["video/webm"],mov:["video/quicktime"],avi:["video/x-msvideo"],mkv:["video/x-matroska"],pdf:["application/pdf"],doc:["application/msword"],docx:["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],xls:["application/vnd.ms-excel"],xlsx:["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],ppt:["application/vnd.ms-powerpoint"],pptx:["application/vnd.openxmlformats-officedocument.presentationml.presentation"],txt:["text/plain"],csv:["text/csv"],json:["application/json"],xml:["application/xml","text/xml"],html:["text/html"],css:["text/css"],js:["text/javascript","application/javascript"],md:["text/markdown"],mp3:["audio/mpeg"],wav:["audio/wav"],ogg:["audio/ogg"],aac:["audio/aac"],flac:["audio/flac"]},a={image:["image/jpeg","image/png","image/webp","image/svg+xml"],video:["image/gif","video/mp4","video/webm","video/quicktime","video/x-msvideo","video/x-matroska"],document:["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/plain","text/csv"],audio:["audio/mpeg","audio/wav","audio/ogg","audio/webm","audio/aac","audio/flac"]},r=new Set(["jpg","jpeg","png","webp","svg","bmp","tiff","ico"]),i=new Set(["mp4","webm","mov","avi","mkv","gif"]),o=Object.freeze({categories:[],extensions:[],mimeTypes:[],acceptString:"",includesImages:!0,includesVideos:!0,isAllTypes:!0,raw:null});function s(e){if(!e)return o;const t=Array.isArray(e)?e.join(","):String(e),l=t.split(",").map(e=>e.trim()).filter(Boolean);if(0===l.length)return o;const s=[],c=[],u=new Set;for(const r of l)if(r.endsWith("/*")){const e=r.replace("/*","");a[e]&&(s.push(e),a[e].forEach(e=>u.add(e)))}else if(r.startsWith(".")){const e=r.slice(1).toLowerCase();c.push(e),(n[e]||[]).forEach(e=>u.add(e))}else r.includes("/")&&u.add(r);const d=s.includes("image")||c.some(e=>r.has(e)),b=s.includes("video")||c.some(e=>i.has(e));return{categories:s,extensions:c,mimeTypes:[...u],acceptString:[...u].join(","),includesImages:d,includesVideos:b,isAllTypes:!1,raw:t}}function c(e){if(!e||e.isAllTypes)return"Todos los formatos";const t=new Set;for(const l of e.categories)switch(l){case"image":t.add("Imágenes");break;case"video":t.add("Videos");break;case"document":t.add("Documentos");break;case"audio":t.add("Audio")}for(const l of e.extensions)t.add(l.toUpperCase());return[...t].join(", ")||"Todos los formatos"}function u(e,t=!1){const l=t?"Cambiar":"Seleccionar";if(!e)return`${l} archivo`;const n=s(e);if(n.isAllTypes)return`${l} archivo`;const{includesImages:a,includesVideos:r,categories:i}=n,o=i.some(e=>"image"!==e&&"video"!==e);return!a||r||o?!r||a||o?`${l} archivo`:`${l} vídeo`:`${"Cambiar"==l?"Editar":l} imagen`}const d={es:{"button.select":"Seleccionar","button.upload":"Subir archivo","button.cancel":"Cancelar","button.close":"Cerrar","button.save":"Guardar","button.delete":"Eliminar","button.download":"Descargar","button.copy":"Copiar URL","button.crop":"Recortar","button.apply":"Aplicar","button.reset":"Reiniciar","button.back":"Volver","button.next":"Siguiente","button.previous":"Anterior","tab.gallery":"Galería","tab.upload":"Subir","tab.ia":"IA","tab.stock":"Stock","tab.cropper":"Recortar","message.loading":"Cargando...","message.uploading":"Subiendo archivo...","message.processing":"Procesando...","message.no_images":"No hay archivos disponibles","message.upload_success":"Archivo subido correctamente","message.upload_error":"Error al subir el archivo","message.delete_confirm":"¿Estás seguro de que deseas eliminar este archivo? Esta acción también eliminará todos sus recortes.","message.copy_success":"URL copiada al portapapeles","message.copy_error":"Error al copiar URL","error.file_too_large":"El archivo es demasiado grande","error.invalid_format":"Formato de archivo no válido","error.upload_failed":"Error al subir el archivo","error.network":"Error de conexión","error.unknown":"Error desconocido","error.api_key_missing":"API Key no proporcionada","placeholder.search":"Buscar archivos...","placeholder.prompt":"Describe la imagen que quieres generar...","label.file_name":"Nombre del archivo","label.file_size":"Tamaño","label.dimensions":"Dimensiones","label.format":"Formato","label.uploaded_by":"Subido por","label.uploaded_at":"Fecha de subida","preset.square":"Cuadrado","preset.landscape":"Paisaje","preset.portrait":"Retrato","preset.thumbnail":"Miniatura","preset.medium":"Medio","preset.large":"Grande","preset.custom":"Personalizado","imageCard.aria.zoom":"Ampliar {filename}","imageCard.aria.zoomPreview":"Previsualizar {filename}","imageCard.aria.zoomWithCrops":"Ver {n} recortes de {filename}","imageCard.aria.crop":"Recortar {filename}","imageCard.aria.copyUrl":"Copiar URL de {filename}","imageCard.aria.copied":"URL copiada","imageCard.aria.download":"Descargar {filename}","imageCard.aria.rename":"Renombrar {filename}","imageCard.aria.delete":"Eliminar {filename}","aiStarter.label":"Instrucciones base","aiStarter.copy":"Copiar","aiStarter.copied":"Copiado","aiStarter.copyAriaLabel":"Copiar instrucciones base","aiStarter.readMore":"Leer más","aiStarter.readLess":"Leer menos","tags.input.placeholder":"Escribir etiqueta...","tags.input.labelOptional":"Etiquetas (opcional)","tags.input.label":"Etiquetas","tags.input.hint":"Pulsa espacio o coma para confirmar","tags.input.ariaLabel":"Añadir etiquetas","tags.autocomplete.empty":"Sin resultados","tags.section.label":"Etiquetas","tags.search.placeholder":"Buscar por nombre o etiqueta...","tags.pill.ariaDelete":"Eliminar etiqueta {tag}","editAssetModal.title":"Editar asset","editAssetModal.nameLabel":"Nombre","editAssetModal.close":"Cerrar","editAssetModal.save":"Guardar cambios","editAssetModal.cancel":"Cancelar","editAssetModal.saveError":"Error al guardar. Inténtalo de nuevo.","imageCard.editButton":"Editar asset"},en:{"button.select":"Select","button.upload":"Upload file","button.cancel":"Cancel","button.close":"Close","button.save":"Save","button.delete":"Delete","button.download":"Download","button.copy":"Copy URL","button.crop":"Crop","button.apply":"Apply","button.reset":"Reset","button.back":"Back","button.next":"Next","button.previous":"Previous","tab.gallery":"Gallery","tab.upload":"Upload","tab.ia":"AI","tab.stock":"Stock","tab.cropper":"Crop","message.loading":"Loading...","message.uploading":"Uploading file...","message.processing":"Processing...","message.no_images":"No files available","message.upload_success":"File uploaded successfully","message.upload_error":"Error uploading file","message.delete_confirm":"Are you sure you want to delete this file?","message.copy_success":"URL copied to clipboard","message.copy_error":"Error copying URL","error.file_too_large":"File is too large","error.invalid_format":"Invalid file format","error.upload_failed":"Upload failed","error.network":"Network error","error.unknown":"Unknown error","error.api_key_missing":"API Key not provided","placeholder.search":"Search files...","placeholder.prompt":"Describe the image you want to generate...","label.file_name":"File name","label.file_size":"Size","label.dimensions":"Dimensions","label.format":"Format","label.uploaded_by":"Uploaded by","label.uploaded_at":"Upload date","preset.square":"Square","preset.landscape":"Landscape","preset.portrait":"Portrait","preset.thumbnail":"Thumbnail","preset.medium":"Medium","preset.large":"Large","preset.custom":"Custom","imageCard.aria.zoom":"Enlarge {filename}","imageCard.aria.zoomPreview":"Preview {filename}","imageCard.aria.zoomWithCrops":"View {n} crops of {filename}","imageCard.aria.crop":"Crop {filename}","imageCard.aria.copyUrl":"Copy URL of {filename}","imageCard.aria.copied":"URL copied","imageCard.aria.download":"Download {filename}","imageCard.aria.rename":"Rename {filename}","imageCard.aria.delete":"Delete {filename}","aiStarter.label":"Base instructions","aiStarter.copy":"Copy","aiStarter.copied":"Copied","aiStarter.copyAriaLabel":"Copy base instructions","aiStarter.readMore":"Read more","aiStarter.readLess":"Read less","tags.input.placeholder":"Add tag...","tags.input.labelOptional":"Tags (optional)","tags.input.label":"Tags","tags.input.hint":"Press space or comma to confirm","tags.input.ariaLabel":"Add tags","tags.autocomplete.empty":"No results","tags.section.label":"Tags","tags.search.placeholder":"Search by name or tag...","tags.pill.ariaDelete":"Remove tag {tag}","editAssetModal.title":"Edit asset","editAssetModal.nameLabel":"Name","editAssetModal.close":"Close","editAssetModal.save":"Save changes","editAssetModal.cancel":"Cancel","editAssetModal.saveError":"Error saving. Please try again.","imageCard.editButton":"Edit asset"},pt:{"imageCard.aria.zoom":"Ampliar {filename}","imageCard.aria.zoomPreview":"Pré-visualizar {filename}","imageCard.aria.zoomWithCrops":"Ver {n} recortes de {filename}","imageCard.aria.crop":"Recortar {filename}","imageCard.aria.copyUrl":"Copiar URL de {filename}","imageCard.aria.copied":"URL copiada","imageCard.aria.download":"Descarregar {filename}","imageCard.aria.rename":"Renomear {filename}","imageCard.aria.delete":"Eliminar {filename}","aiStarter.label":"Instruções base","aiStarter.copy":"Copiar","aiStarter.copied":"Copiado","aiStarter.copyAriaLabel":"Copiar instruções base","aiStarter.readMore":"Ler mais","aiStarter.readLess":"Ler menos","tags.input.placeholder":"Adicionar etiqueta...","tags.input.labelOptional":"Etiquetas (opcional)","tags.input.label":"Etiquetas","tags.input.hint":"Prima espaço ou vírgula para confirmar","tags.input.ariaLabel":"Adicionar etiquetas","tags.autocomplete.empty":"Sem resultados","tags.section.label":"Etiquetas","tags.search.placeholder":"Pesquisar por nome ou etiqueta...","tags.pill.ariaDelete":"Remover etiqueta {tag}","editAssetModal.title":"Editar asset","editAssetModal.nameLabel":"Nome","editAssetModal.close":"Fechar","editAssetModal.save":"Guardar alterações","editAssetModal.cancel":"Cancelar","editAssetModal.saveError":"Erro ao guardar. Tente novamente.","imageCard.editButton":"Editar asset"},fr:{"imageCard.aria.zoom":"Agrandir {filename}","imageCard.aria.zoomPreview":"Prévisualiser {filename}","imageCard.aria.zoomWithCrops":"Voir {n} recadrages de {filename}","imageCard.aria.crop":"Recadrer {filename}","imageCard.aria.copyUrl":"Copier l'URL de {filename}","imageCard.aria.copied":"URL copiée","imageCard.aria.download":"Télécharger {filename}","imageCard.aria.rename":"Renommer {filename}","imageCard.aria.delete":"Supprimer {filename}","aiStarter.label":"Instructions de base","aiStarter.copy":"Copier","aiStarter.copied":"Copié","aiStarter.copyAriaLabel":"Copier les instructions de base","aiStarter.readMore":"Lire plus","aiStarter.readLess":"Lire moins","tags.input.placeholder":"Ajouter un tag...","tags.input.labelOptional":"Étiquettes (optionnel)","tags.input.label":"Étiquettes","tags.input.hint":"Appuyez sur espace ou virgule pour confirmer","tags.input.ariaLabel":"Ajouter des étiquettes","tags.autocomplete.empty":"Aucun résultat","tags.section.label":"Étiquettes","tags.search.placeholder":"Rechercher par nom ou tag...","tags.pill.ariaDelete":"Supprimer l'étiquette {tag}","editAssetModal.title":"Modifier le fichier","editAssetModal.nameLabel":"Nom","editAssetModal.close":"Fermer","editAssetModal.save":"Enregistrer les modifications","editAssetModal.cancel":"Annuler","editAssetModal.saveError":"Erreur lors de l'enregistrement. Réessayez.","imageCard.editButton":"Modifier l'asset"}};class b{constructor(e="es",t={}){this.locale=e,this.messages=this._mergeMessages(t)}_mergeMessages(e){const t={...d};return Object.keys(e).forEach(l=>{t[l]={...t[l]||{},...e[l]}}),t}t(e,t={}){let l=(this.messages[this.locale]||this.messages.es)[e]||e;return Object.keys(t).forEach(e=>{l=l.replace(`{${e}}`,t[e])}),l}setLocale(e){this.messages[e]?this.locale=e:console.warn(`Locale ${e} not available, keeping ${this.locale}`)}getLocale(){return this.locale}getAvailableLocales(){return Object.keys(this.messages)}addMessages(e,t){this.messages[e]={...this.messages[e]||{},...t}}hasKey(e){return e in(this.messages[this.locale]||this.messages.es)}}const m=new b;function h(e,t={}){return m.t(e,t)}class p{constructor(){this.globalConfig={},this.defaults={container:"#limbo-default",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],ui:{showActions:["select","download","copy","delete","crop","rename"],hideActions:[],theme:"light",language:"es",compactMode:!1,showTabs:!0,showPreview:!0},cropper:{quality:.9,format:"webp",aspectRatio:null,lockAspectRatio:!1,showFreeAspectRatio:!0,showDimensionInputs:!1,enableEditMode:!0,showDownloadInCropper:!1,showCropName:!1,mandatoryCrops:[],allowCustomCrops:!0},gallery:{filters:{showNameFilter:!0,showUploadedByFilter:!1,showDateFilter:!0,showTypeFilter:!1,enabledFilters:["name","date"],customFilters:[]},loading:{showPlaceholders:!0,placeholderCount:10,showSpinner:!0},pagination:{itemsPerPage:20,showPageSize:!0}},validation:{accept:null,maxSize:"10MB",formats:["jpg","jpeg","png","webp","gif"],minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,allowedCategories:null},folders:{include:[],exclude:[],includeNoFolder:!0,showFolderSelector:!0,showFolderFilter:!0,showFolderInfo:!0,allowMoveFolder:!0,allowCreateFolder:!0,defaultFolder:null},downloadFormat:"webp",return:{format:"url",autoAssign:!0,includeMetadata:!1},autoInputs:{dataset:"data-limbo-input-file",buttonText:"Seleccionar archivo",buttonStyle:"primary",buttonClass:"limbo-auto-button",scanOnLoad:!0,observeChanges:!0},presets:{aspects:[{name:"square",ratio:"1:1",label:"Cuadrado"},{name:"landscape",ratio:"16:9",label:"Paisaje"},{name:"portrait",ratio:"9:16",label:"Retrato"}],sizes:[{name:"thumbnail",width:300,height:300,fit:"cover",label:"Miniatura"},{name:"medium",width:800,height:600,fit:"cover",label:"Medio"},{name:"large",width:1920,height:1080,fit:"cover",label:"Grande"}],required:[],lockUserCrop:!1,allowArbitrary:!0,defaultAspect:"square",defaultSize:"medium"},modal:{size:"medium",title:"Limbo Image Manager",backdrop:!0,closeOnEscape:!0,closeOnBackdrop:!0,showCloseButton:!0},callbacks:{onUpload:null,onSelect:null,onDelete:null,onCropsSaved:null,onCropperComplete:null,onCropperCancelled:null,onCropperError:null},autoDestroy:!1,autoHideOnComplete:!1,debug:!1,apiEndpoint:null,auth:{apiKey:null,publicKey:null,portal:null,authMode:"jwt",tokenStorage:"memory",autoRefresh:!0,refreshBuffer:30},apiKey:null,aiStarterPrompt:"Editorial corporate photography, authentic human moments, warm cinematic lighting, natural professional interaction, premium contemporary aesthetic, subtle shadows, asymmetrical editorial composition, intentional negative space, non-stock photography style, refined warm-neutral color palette with beige, soft whites, warm browns, deep burgundy and navy blue tones, understated sophistication, realistic office atmosphere. Avoid: fake smiles, corporate posing, flat lighting, overly clean scenes, oversaturated colors, generic stock photo aesthetic."}}setGlobal(e){return this.globalConfig={...this.globalConfig,...e},this}getGlobal(){return{...this.globalConfig}}merge(e={}){return this._deepMerge(this.defaults,this.globalConfig,e)}_deepMerge(...e){const t={};return e.forEach(e=>{e&&"object"==typeof e&&Object.keys(e).forEach(l=>{e[l]&&"object"==typeof e[l]&&!Array.isArray(e[l])?t[l]=this._deepMerge(t[l]||{},e[l]):t[l]=e[l]})}),t}setDefaults(e){return this.defaults=this._deepMerge(this.defaults,e),this}getDefaults(){return JSON.parse(JSON.stringify(this.defaults))}resetDefaults(){return this.defaults=this._getOriginalDefaults(),this}get(e,t=null){const l=t||this.merge();return this._getValueByPath(l,e)}set(e,t){return this._setValueByPath(this.globalConfig,e,t),this}_getValueByPath(e,t){return t.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:void 0,e)}_setValueByPath(e,t,l){const n=t.split("."),a=n.pop();n.reduce((e,t)=>(e[t]&&"object"==typeof e[t]||(e[t]={}),e[t]),e)[a]=l}_getOriginalDefaults(){return{container:"#limbo-default",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],ui:{showActions:["select","download","copy","delete","crop","rename"],hideActions:[],theme:"light",language:"es",compactMode:!1,showTabs:!0,showPreview:!0},interaction:{allowSelection:!1,allowCropping:!0,requiresCropping:!1,selectionMode:"direct"},cropper:{quality:.9,format:"webp",aspectRatio:null,lockAspectRatio:!1,showFreeAspectRatio:!0,showDimensionInputs:!1,enableEditMode:!0,showDownloadInCropper:!1,showCropName:!1,mandatoryCrops:[],allowCustomCrops:!0},gallery:{filters:{showNameFilter:!0,showUploadedByFilter:!1,showDateFilter:!0,showTypeFilter:!1,enabledFilters:["name","date"],customFilters:[]},loading:{showPlaceholders:!0,placeholderCount:10,showSpinner:!0},pagination:{itemsPerPage:20,showPageSize:!0}},validation:{accept:null,maxSize:"10MB",formats:["jpg","jpeg","png","svg","webp","gif"],minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,allowedCategories:null},folders:{include:[],exclude:[],includeNoFolder:!0,showFolderSelector:!1,showFolderFilter:!1,showFolderInfo:!0,allowMoveFolder:!0,allowCreateFolder:!0,defaultFolder:null},return:{format:"url",autoAssign:!0,includeMetadata:!1},autoInputs:{dataset:"data-limbo-input-file",buttonText:"Seleccionar archivo",buttonStyle:"primary",buttonClass:"limbo-auto-button",scanOnLoad:!0,observeChanges:!0},modal:{size:"medium",title:"Limbo Image Manager",backdrop:!0,closeOnEscape:!0,closeOnBackdrop:!0,showCloseButton:!0},i18n:{locale:"es",messages:{},autoDetect:!0},theme:{colors:{},spacing:{},typography:{},borderRadius:{},shadows:{},customProperties:{}},callbacks:{onUpload:null,onSelect:null,onDelete:null,onCropsSaved:null,onCropperComplete:null,onCropperCancelled:null,onCropperError:null},autoDestroy:!1,autoHideOnComplete:!1,debug:!1,apiEndpoint:null,auth:{apiKey:null,publicKey:null,portal:null,authMode:"jwt",tokenStorage:"memory",autoRefresh:!0,refreshBuffer:30},apiKey:null}}_validatePresets(e){const t=[];if(e.aspects&&e.aspects.forEach((e,l)=>{e.name&&e.ratio||t.push(`Aspect preset ${l}: name and ratio are required`),e.ratio&&!/^\d+:\d+$/.test(e.ratio)&&t.push(`Aspect preset ${e.name}: ratio must be in format "w:h"`)}),e.sizes&&e.sizes.forEach((e,l)=>{e.name&&e.width||t.push(`Size preset ${l}: name and width are required`),e.width&&e.width<=0&&t.push(`Size preset ${e.name}: width must be positive`),e.height&&e.height<=0&&t.push(`Size preset ${e.name}: height must be positive`)}),e.required&&Array.isArray(e.required)){const l=[...e.aspects?.map(e=>e.name)||[],...e.sizes?.map(e=>e.name)||[]];e.required.forEach(e=>{l.includes(e)||t.push(`Required preset "${e}" not found in available presets`)})}return t}getPreset(e,t,l="aspect"){const n=e.presets||this.defaults.presets;return"aspect"===l?n.aspects?.find(e=>e.name===t):"size"===l?n.sizes?.find(e=>e.name===t):null}isPresetRequired(e,t){const l=e.presets||this.defaults.presets;return l.required?.includes(t)||!1}getAvailableAspects(e){return(e.presets||this.defaults.presets).aspects||[]}getAvailableSizes(e){return(e.presets||this.defaults.presets).sizes||[]}createI18n(e){const t=e.i18n||this.defaults.i18n;let l=t.locale;if(t.autoDetect&&"auto"===l){const e=(navigator.language||navigator.userLanguage).split("-")[0];l=["es","en"].includes(e)?e:"es"}else t.autoDetect&&!l&&(l="es");return new b(l,t.messages)}validate(e){const t=[],l=this._deepMerge(this.globalConfig.auth||{},e.auth||{}),n=e.apiKey||this.globalConfig.apiKey;if("jwt"!==l.authMode&&n||l.apiKey||t.push("auth.apiKey es requerido para autenticación JWT"),"legacy"!==l.authMode||n||t.push("apiKey es requerido para modo legacy"),l.apiKey||n||t.push("Se requiere configuración de autenticación (auth.apiKey o apiKey legacy)"),e.mode&&!["embed","modal","button"].includes(e.mode)&&t.push("mode debe ser: embed, modal o button"),e.features&&!Array.isArray(e.features)&&t.push("features debe ser un array"),e.presets){const l=this._validatePresets(e.presets);t.push(...l)}return{isValid:0===t.length,errors:t}}setJWTAuth(e,t=null,l={}){const n={apiKey:e,publicKey:t,authMode:"jwt",tokenStorage:l.tokenStorage||"memory",autoRefresh:!1!==l.autoRefresh,refreshBuffer:l.refreshBuffer||30,portal:l.portal||null,...l};return this.set("auth",n),this}getAuthConfig(e=null){const t=e||this.merge();return{authMode:t.auth?.authMode||(t.apiKey?"legacy":"jwt"),apiKey:t.auth?.apiKey||t.apiKey,publicKey:t.auth?.publicKey,portal:t.auth?.portal,tokenStorage:t.auth?.tokenStorage||"memory",autoRefresh:!1!==t.auth?.autoRefresh,refreshBuffer:t.auth?.refreshBuffer||30}}isJWTMode(e=null){return"jwt"===this.getAuthConfig(e).authMode}isLegacyMode(e=null){return"legacy"===this.getAuthConfig(e).authMode}migrateToJWT(e=null){const t=e||this.globalConfig.apiKey;if(!t)throw new Error("No hay apiKey para migrar a JWT");return this.setJWTAuth(t),this}getMandatoryCrops(e=null){const t=e||this.merge();return t.cropper?.mandatoryCrops||[]}hasMandatoryCrops(e=null){return this.getMandatoryCrops(e).length>0}isEditModeEnabled(e=null){const t=e||this.merge();return!1!==t.cropper?.enableEditMode}showDimensionInputs(e=null){const t=e||this.merge();return!0===t.cropper?.showDimensionInputs}showDownloadInCropper(e=null){const t=e||this.merge();return!0===t.cropper?.showDownloadInCropper}showCropName(e=null){const t=e||this.merge();return!0===t.cropper?.showCropName}allowCustomCrops(e=null){const t=e||this.merge();return!1!==t.cropper?.allowCustomCrops}getGalleryFilters(e=null){const t=e||this.merge();return t.gallery?.filters||this.defaults.gallery.filters}isGalleryFilterEnabled(e,t=null){const l=this.getGalleryFilters(t);return l.enabledFilters?.includes(e)||!1}getCustomGalleryFilters(e=null){return this.getGalleryFilters(e).customFilters||[]}getGalleryLoadingConfig(e=null){const t=e||this.merge();return t.gallery?.loading||this.defaults.gallery.loading}showGalleryPlaceholders(e=null){return!1!==this.getGalleryLoadingConfig(e).showPlaceholders}getPlaceholderCount(e=null){return this.getGalleryLoadingConfig(e).placeholderCount||10}showGallerySpinner(e=null){return!1!==this.getGalleryLoadingConfig(e).showSpinner}getGalleryPagination(e=null){const t=e||this.merge();return t.gallery?.pagination||this.defaults.gallery.pagination}getItemsPerPage(e=null){return this.getGalleryPagination(e).itemsPerPage||20}getFolderConfig(e=null){return(e||this.merge()).folders||this.defaults.folders}hasFolderFilters(e=null){const t=this.getFolderConfig(e);return t.include?.length>0||t.exclude?.length>0}getFolderApiParams(e=null){const t=this.getFolderConfig(e),l={};return t.include?.length>0?l.folders_include=t.include.join(","):t.exclude?.length>0&&(l.folders_exclude=t.exclude.join(",")),this.hasFolderFilters(e)&&void 0!==t.includeNoFolder&&(l.include_no_folder=t.includeNoFolder?"1":"0"),l}showFolderSelectorInUpload(e=null){const t=e||this.merge();return!0===t.folders?.showFolderSelector}showFolderFilterInGallery(e=null){const t=e||this.merge();return!0===t.folders?.showFolderFilter}canCreateFolder(e=null){const t=e||this.merge();return!1!==t.folders?.allowCreateFolder}getDefaultUploadFolder(e=null){const t=e||this.merge();return t.folders?.defaultFolder||null}getAllowedFolderSlugs(e=null){const t=e||this.merge(),l=t.folders?.include;return l&&l.length>0?l:null}getAllowedCategories(e=null){const t=e||this.merge();return t.validation?.allowedCategories||null}isCategoryAllowed(e,t=null){const l=this.getAllowedCategories(t);return null===l||l.includes(e)}isMultiTypeEnabled(e=null){const t=this.getAllowedCategories(e);return null===t||(t.length>1||1===t.length&&"image"!==t[0])}showTypeFilter(e=null){const t=e||this.merge();return!0===t.gallery?.filters?.showTypeFilter}getTypeFilterOptions(e=null){const t=this.getAllowedCategories(e),l=[{value:"",label:"Todos los tipos"},{value:"image",label:"Imágenes"},{value:"video",label:"Videos"},{value:"document",label:"Documentos"},{value:"audio",label:"Audio"}];return null===t?l:l.filter(e=>""===e.value||t.includes(e.value))}getResolvedAccept(e=null){const t=e||this.merge();return t.validation?.accept?s(t.validation.accept):t.validation?.allowedCategories?s(t.validation.allowedCategories.map(e=>`${e}/*`).join(",")):s(null)}}var f,g,v,y,x={exports:{}},w={},k={exports:{}},C={};function S(){return g||(g=1,k.exports=(f||(f=1,function(e){function t(e,t){var l=e.length;e.push(t);e:for(;0<l;){var n=l-1>>>1,r=e[n];if(!(0<a(r,t)))break e;e[n]=t,e[l]=r,l=n}}function l(e){return 0===e.length?null:e[0]}function n(e){if(0===e.length)return null;var t=e[0],l=e.pop();if(l!==t){e[0]=l;e:for(var n=0,r=e.length,i=r>>>1;n<i;){var o=2*(n+1)-1,s=e[o],c=o+1,u=e[c];if(0>a(s,l))c<r&&0>a(u,s)?(e[n]=u,e[c]=l,n=c):(e[n]=s,e[o]=l,n=o);else{if(!(c<r&&0>a(u,l)))break e;e[n]=u,e[c]=l,n=c}}}return t}function a(e,t){var l=e.sortIndex-t.sortIndex;return 0!==l?l:e.id-t.id}if(e.unstable_now=void 0,"object"==typeof performance&&"function"==typeof performance.now){var r=performance;e.unstable_now=function(){return r.now()}}else{var i=Date,o=i.now();e.unstable_now=function(){return i.now()-o}}var s=[],c=[],u=1,d=null,b=3,m=!1,h=!1,p=!1,f=!1,g="function"==typeof setTimeout?setTimeout:null,v="function"==typeof clearTimeout?clearTimeout:null,y="undefined"!=typeof setImmediate?setImmediate:null;function x(e){for(var a=l(c);null!==a;){if(null===a.callback)n(c);else{if(!(a.startTime<=e))break;n(c),a.sortIndex=a.expirationTime,t(s,a)}a=l(c)}}function w(e){if(p=!1,x(e),!h)if(null!==l(s))h=!0,C||(C=!0,k());else{var t=l(c);null!==t&&A(w,t.startTime-e)}}var k,C=!1,S=-1,j=5,N=-1;function E(){return!(!f&&e.unstable_now()-N<j)}function $(){if(f=!1,C){var t=e.unstable_now();N=t;var a=!0;try{e:{h=!1,p&&(p=!1,v(S),S=-1),m=!0;var r=b;try{t:{for(x(t),d=l(s);null!==d&&!(d.expirationTime>t&&E());){var i=d.callback;if("function"==typeof i){d.callback=null,b=d.priorityLevel;var o=i(d.expirationTime<=t);if(t=e.unstable_now(),"function"==typeof o){d.callback=o,x(t),a=!0;break t}d===l(s)&&n(s),x(t)}else n(s);d=l(s)}if(null!==d)a=!0;else{var u=l(c);null!==u&&A(w,u.startTime-t),a=!1}}break e}finally{d=null,b=r,m=!1}a=void 0}}finally{a?k():C=!1}}}if("function"==typeof y)k=function(){y($)};else if("undefined"!=typeof MessageChannel){var _=new MessageChannel,T=_.port2;_.port1.onmessage=$,k=function(){T.postMessage(null)}}else k=function(){g($,0)};function A(t,l){S=g(function(){t(e.unstable_now())},l)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):j=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_next=function(e){switch(b){case 1:case 2:case 3:var t=3;break;default:t=b}var l=b;b=t;try{return e()}finally{b=l}},e.unstable_requestPaint=function(){f=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var l=b;b=e;try{return t()}finally{b=l}},e.unstable_scheduleCallback=function(n,a,r){var i=e.unstable_now();switch(r="object"==typeof r&&null!==r&&"number"==typeof(r=r.delay)&&0<r?i+r:i,n){case 1:var o=-1;break;case 2:o=250;break;case 5:o=1073741823;break;case 4:o=1e4;break;default:o=5e3}return n={id:u++,callback:a,priorityLevel:n,startTime:r,expirationTime:o=r+o,sortIndex:-1},r>i?(n.sortIndex=r,t(c,n),null===l(s)&&n===l(c)&&(p?(v(S),S=-1):p=!0,A(w,r-i))):(n.sortIndex=o,t(s,n),h||m||(h=!0,C||(C=!0,k()))),n},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=b;return function(){var l=b;b=t;try{return e.apply(this,arguments)}finally{b=l}}}}(C)),C)),k.exports}function j(){if(v)return w;v=1;var l=S(),n=e,a=t;function r(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)t+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType)}function o(e){var t=e,l=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{!!(4098&(t=e).flags)&&(l=t.return),e=t.return}while(e)}return 3===t.tag?l:null}function s(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function c(e){if(31===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function u(e){if(o(e)!==e)throw Error(r(188))}function d(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e;for(e=e.child;null!==e;){if(null!==(t=d(e)))return t;e=e.sibling}return null}var b=Object.assign,m=Symbol.for("react.element"),h=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),x=Symbol.for("react.consumer"),k=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),$=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),T=Symbol.for("react.memo_cache_sentinel"),A=Symbol.iterator;function z(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=A&&e[A]||e["@@iterator"])?e:null}var L=Symbol.for("react.client.reference");function M(e){if(null==e)return null;if("function"==typeof e)return e.$$typeof===L?null:e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case f:return"Fragment";case y:return"Profiler";case g:return"StrictMode";case j:return"Suspense";case N:return"SuspenseList";case _:return"Activity"}if("object"==typeof e)switch(e.$$typeof){case p:return"Portal";case k:return e.displayName||"Context";case x:return(e._context.displayName||"Context")+".Consumer";case C:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case E:return null!==(t=e.displayName||null)?t:M(e.type)||"Memo";case $:t=e._payload,e=e._init;try{return M(e(t))}catch(l){}}return null}var I=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R={pending:!1,data:null,method:null,action:null},O=[],F=-1;function U(e){return{current:e}}function B(e){0>F||(e.current=O[F],O[F]=null,F--)}function q(e,t){F++,O[F]=e.current,e.current=t}var W,V,H=U(null),K=U(null),G=U(null),Q=U(null);function X(e,t){switch(q(G,t),q(K,e),q(H,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?yd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)e=xd(t=yd(t),e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}B(H),q(H,e)}function Y(){B(H),B(K),B(G)}function J(e){null!==e.memoizedState&&q(Q,e);var t=H.current,l=xd(t,e.type);t!==l&&(q(K,e),q(H,l))}function Z(e){K.current===e&&(B(H),B(K)),Q.current===e&&(B(Q),bb._currentValue=R)}function ee(e){if(void 0===W)try{throw Error()}catch(l){var t=l.stack.trim().match(/\n( *(at )?)/);W=t&&t[1]||"",V=-1<l.stack.indexOf("\n at")?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return"\n"+W+e+V}var te=!1;function le(e,t){if(!e||te)return"";te=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var n={DetermineComponentFrameRoot:function(){try{if(t){var l=function(){throw Error()};if(Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(l,[])}catch(a){var n=a}Reflect.construct(e,[],l)}else{try{l.call()}catch(r){n=r}e.call(l.prototype)}}else{try{throw Error()}catch(i){n=i}(l=e())&&"function"==typeof l.catch&&l.catch(function(){})}}catch(o){if(o&&n&&"string"==typeof o.stack)return[o.stack,n.stack]}return[null,null]}};n.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var a=Object.getOwnPropertyDescriptor(n.DetermineComponentFrameRoot,"name");a&&a.configurable&&Object.defineProperty(n.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var r=n.DetermineComponentFrameRoot(),i=r[0],o=r[1];if(i&&o){var s=i.split("\n"),c=o.split("\n");for(a=n=0;n<s.length&&!s[n].includes("DetermineComponentFrameRoot");)n++;for(;a<c.length&&!c[a].includes("DetermineComponentFrameRoot");)a++;if(n===s.length||a===c.length)for(n=s.length-1,a=c.length-1;1<=n&&0<=a&&s[n]!==c[a];)a--;for(;1<=n&&0<=a;n--,a--)if(s[n]!==c[a]){if(1!==n||1!==a)do{if(n--,0>--a||s[n]!==c[a]){var u="\n"+s[n].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}}while(1<=n&&0<=a);break}}}finally{te=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?ee(l):""}function ne(e,t){switch(e.tag){case 26:case 27:case 5:return ee(e.type);case 16:return ee("Lazy");case 13:return e.child!==t&&null!==t?ee("Suspense Fallback"):ee("Suspense");case 19:return ee("SuspenseList");case 0:case 15:return le(e.type,!1);case 11:return le(e.type.render,!1);case 1:return le(e.type,!0);case 31:return ee("Activity");default:return""}}function ae(e){try{var t="",l=null;do{t+=ne(e,l),l=e,e=e.return}while(e);return t}catch(n){return"\nError generating stack: "+n.message+"\n"+n.stack}}var re=Object.prototype.hasOwnProperty,ie=l.unstable_scheduleCallback,oe=l.unstable_cancelCallback,se=l.unstable_shouldYield,ce=l.unstable_requestPaint,ue=l.unstable_now,de=l.unstable_getCurrentPriorityLevel,be=l.unstable_ImmediatePriority,me=l.unstable_UserBlockingPriority,he=l.unstable_NormalPriority,pe=l.unstable_LowPriority,fe=l.unstable_IdlePriority,ge=l.log,ve=l.unstable_setDisableYieldValue,ye=null,xe=null;function we(e){if("function"==typeof ge&&ve(e),xe&&"function"==typeof xe.setStrictMode)try{xe.setStrictMode(ye,e)}catch(t){}}var ke=Math.clz32?Math.clz32:function(e){return 0===(e>>>=0)?32:31-(Ce(e)/Se|0)|0},Ce=Math.log,Se=Math.LN2;var je=256,Ne=262144,Ee=4194304;function $e(e){var t=42&e;if(0!==t)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function _e(e,t,l){var n=e.pendingLanes;if(0===n)return 0;var a=0,r=e.suspendedLanes,i=e.pingedLanes;e=e.warmLanes;var o=134217727&n;return 0!==o?0!==(n=o&~r)?a=$e(n):0!==(i&=o)?a=$e(i):l||0!==(l=o&~e)&&(a=$e(l)):0!==(o=n&~r)?a=$e(o):0!==i?a=$e(i):l||0!==(l=n&~e)&&(a=$e(l)),0===a?0:0!==t&&t!==a&&0===(t&r)&&((r=a&-a)>=(l=t&-t)||32===r&&4194048&l)?t:a}function Te(e,t){return 0===(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)}function Ae(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;default:return-1}}function ze(){var e=Ee;return!(62914560&(Ee<<=1))&&(Ee=4194304),e}function Le(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function Me(e,t){e.pendingLanes|=t,268435456!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ie(e,t,l){e.pendingLanes|=t,e.suspendedLanes&=~t;var n=31-ke(t);e.entangledLanes|=t,e.entanglements[n]=1073741824|e.entanglements[n]|261930&l}function Pe(e,t){var l=e.entangledLanes|=t;for(e=e.entanglements;l;){var n=31-ke(l),a=1<<n;a&t|e[n]&t&&(e[n]|=t),l&=~a}}function De(e,t){var l=t&-t;return 0!==((l=42&l?1:Re(l))&(e.suspendedLanes|t))?0:l}function Re(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Oe(e){return 2<(e&=-e)?8<e?134217727&e?32:268435456:8:2}function Fe(){var e=D.p;return 0!==e?e:void 0===(e=window.event)?32:$b(e.type)}function Ue(e,t){var l=D.p;try{return D.p=e,t()}finally{D.p=l}}var Be=Math.random().toString(36).slice(2),qe="__reactFiber$"+Be,We="__reactProps$"+Be,Ve="__reactContainer$"+Be,He="__reactEvents$"+Be,Ke="__reactListeners$"+Be,Ge="__reactHandles$"+Be,Qe="__reactResources$"+Be,Xe="__reactMarker$"+Be;function Ye(e){delete e[qe],delete e[We],delete e[He],delete e[Ke],delete e[Ge]}function Je(e){var t=e[qe];if(t)return t;for(var l=e.parentNode;l;){if(t=l[Ve]||l[qe]){if(l=t.alternate,null!==t.child||null!==l&&null!==l.child)for(e=Rd(e);null!==e;){if(l=e[qe])return l;e=Rd(e)}return t}l=(e=l).parentNode}return null}function Ze(e){if(e=e[qe]||e[Ve]){var t=e.tag;if(5===t||6===t||13===t||31===t||26===t||27===t||3===t)return e}return null}function et(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e.stateNode;throw Error(r(33))}function tt(e){var t=e[Qe];return t||(t=e[Qe]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function lt(e){e[Xe]=!0}var nt=new Set,at={};function rt(e,t){it(e,t),it(e+"Capture",t)}function it(e,t){for(at[e]=t,e=0;e<t.length;e++)nt.add(t[e])}var ot=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),st={},ct={};function ut(e,t,l){if(a=t,re.call(ct,a)||!re.call(st,a)&&(ot.test(a)?ct[a]=!0:(st[a]=!0,0)))if(null===l)e.removeAttribute(t);else{switch(typeof l){case"undefined":case"function":case"symbol":return void e.removeAttribute(t);case"boolean":var n=t.toLowerCase().slice(0,5);if("data-"!==n&&"aria-"!==n)return void e.removeAttribute(t)}e.setAttribute(t,""+l)}var a}function dt(e,t,l){if(null===l)e.removeAttribute(t);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(t)}e.setAttribute(t,""+l)}}function bt(e,t,l,n){if(null===n)e.removeAttribute(l);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(l)}e.setAttributeNS(t,l,""+n)}}function mt(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function ht(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function pt(e){if(!e._valueTracker){var t=ht(e)?"checked":"value";e._valueTracker=function(e,t,l){var n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&void 0!==n&&"function"==typeof n.get&&"function"==typeof n.set){var a=n.get,r=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(e){l=""+e,r.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return l},setValue:function(e){l=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e,t,""+e[t])}}function ft(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var l=t.getValue(),n="";return e&&(n=ht(e)?e.checked?"true":"false":e.value),(e=n)!==l&&(t.setValue(e),!0)}function gt(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}var vt=/[\n"\\]/g;function yt(e){return e.replace(vt,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function xt(e,t,l,n,a,r,i,o){e.name="",null!=i&&"function"!=typeof i&&"symbol"!=typeof i&&"boolean"!=typeof i?e.type=i:e.removeAttribute("type"),null!=t?"number"===i?(0===t&&""===e.value||e.value!=t)&&(e.value=""+mt(t)):e.value!==""+mt(t)&&(e.value=""+mt(t)):"submit"!==i&&"reset"!==i||e.removeAttribute("value"),null!=t?kt(e,i,mt(t)):null!=l?kt(e,i,mt(l)):null!=n&&e.removeAttribute("value"),null==a&&null!=r&&(e.defaultChecked=!!r),null!=a&&(e.checked=a&&"function"!=typeof a&&"symbol"!=typeof a),null!=o&&"function"!=typeof o&&"symbol"!=typeof o&&"boolean"!=typeof o?e.name=""+mt(o):e.removeAttribute("name")}function wt(e,t,l,n,a,r,i,o){if(null!=r&&"function"!=typeof r&&"symbol"!=typeof r&&"boolean"!=typeof r&&(e.type=r),null!=t||null!=l){if(("submit"===r||"reset"===r)&&null==t)return void pt(e);l=null!=l?""+mt(l):"",t=null!=t?""+mt(t):l,o||t===e.value||(e.value=t),e.defaultValue=t}n="function"!=typeof(n=null!=n?n:a)&&"symbol"!=typeof n&&!!n,e.checked=o?e.checked:!!n,e.defaultChecked=!!n,null!=i&&"function"!=typeof i&&"symbol"!=typeof i&&"boolean"!=typeof i&&(e.name=i),pt(e)}function kt(e,t,l){"number"===t&&gt(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function Ct(e,t,l,n){if(e=e.options,t){t={};for(var a=0;a<l.length;a++)t["$"+l[a]]=!0;for(l=0;l<e.length;l++)a=t.hasOwnProperty("$"+e[l].value),e[l].selected!==a&&(e[l].selected=a),a&&n&&(e[l].defaultSelected=!0)}else{for(l=""+mt(l),t=null,a=0;a<e.length;a++){if(e[a].value===l)return e[a].selected=!0,void(n&&(e[a].defaultSelected=!0));null!==t||e[a].disabled||(t=e[a])}null!==t&&(t.selected=!0)}}function St(e,t,l){null==t||((t=""+mt(t))!==e.value&&(e.value=t),null!=l)?e.defaultValue=null!=l?""+mt(l):"":e.defaultValue!==t&&(e.defaultValue=t)}function jt(e,t,l,n){if(null==t){if(null!=n){if(null!=l)throw Error(r(92));if(I(n)){if(1<n.length)throw Error(r(93));n=n[0]}l=n}null==l&&(l=""),t=l}l=mt(t),e.defaultValue=l,(n=e.textContent)===l&&""!==n&&null!==n&&(e.value=n),pt(e)}function Nt(e,t){if(t){var l=e.firstChild;if(l&&l===e.lastChild&&3===l.nodeType)return void(l.nodeValue=t)}e.textContent=t}var Et=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function $t(e,t,l){var n=0===t.indexOf("--");null==l||"boolean"==typeof l||""===l?n?e.setProperty(t,""):"float"===t?e.cssFloat="":e[t]="":n?e.setProperty(t,l):"number"!=typeof l||0===l||Et.has(t)?"float"===t?e.cssFloat=l:e[t]=(""+l).trim():e[t]=l+"px"}function _t(e,t,l){if(null!=t&&"object"!=typeof t)throw Error(r(62));if(e=e.style,null!=l){for(var n in l)!l.hasOwnProperty(n)||null!=t&&t.hasOwnProperty(n)||(0===n.indexOf("--")?e.setProperty(n,""):"float"===n?e.cssFloat="":e[n]="");for(var a in t)n=t[a],t.hasOwnProperty(a)&&l[a]!==n&&$t(e,a,n)}else for(var i in t)t.hasOwnProperty(i)&&$t(e,i,t[i])}function Tt(e){if(-1===e.indexOf("-"))return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var At=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),zt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Lt(e){return zt.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Mt(){}var It=null;function Pt(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var Dt=null,Rt=null;function Ot(e){var t=Ze(e);if(t&&(e=t.stateNode)){var l=e[We]||null;e:switch(e=t.stateNode,t.type){case"input":if(xt(e,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),t=l.name,"radio"===l.type&&null!=t){for(l=e;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+yt(""+t)+'"][type="radio"]'),t=0;t<l.length;t++){var n=l[t];if(n!==e&&n.form===e.form){var a=n[We]||null;if(!a)throw Error(r(90));xt(n,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<l.length;t++)(n=l[t]).form===e.form&&ft(n)}break e;case"textarea":St(e,l.value,l.defaultValue);break e;case"select":null!=(t=l.value)&&Ct(e,!!l.multiple,t,!1)}}}var Ft=!1;function Ut(e,t,l){if(Ft)return e(t,l);Ft=!0;try{return e(t)}finally{if(Ft=!1,(null!==Dt||null!==Rt)&&(tu(),Dt&&(t=Dt,e=Rt,Rt=Dt=null,Ot(t),e)))for(t=0;t<e.length;t++)Ot(e[t])}}function Bt(e,t){var l=e.stateNode;if(null===l)return null;var n=l[We]||null;if(null===n)return null;l=n[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(n=!n.disabled)||(n=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!n;break e;default:e=!1}if(e)return null;if(l&&"function"!=typeof l)throw Error(r(231,t,typeof l));return l}var qt=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),Wt=!1;if(qt)try{var Vt={};Object.defineProperty(Vt,"passive",{get:function(){Wt=!0}}),window.addEventListener("test",Vt,Vt),window.removeEventListener("test",Vt,Vt)}catch(Zb){Wt=!1}var Ht=null,Kt=null,Gt=null;function Qt(){if(Gt)return Gt;var e,t,l=Kt,n=l.length,a="value"in Ht?Ht.value:Ht.textContent,r=a.length;for(e=0;e<n&&l[e]===a[e];e++);var i=n-e;for(t=1;t<=i&&l[n-t]===a[r-t];t++);return Gt=a.slice(e,1<t?1-t:void 0)}function Xt(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function Yt(){return!0}function Jt(){return!1}function Zt(e){function t(t,l,n,a,r){for(var i in this._reactName=t,this._targetInst=n,this.type=l,this.nativeEvent=a,this.target=r,this.currentTarget=null,e)e.hasOwnProperty(i)&&(t=e[i],this[i]=t?t(a):a[i]);return this.isDefaultPrevented=(null!=a.defaultPrevented?a.defaultPrevented:!1===a.returnValue)?Yt:Jt,this.isPropagationStopped=Jt,this}return b(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=Yt)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=Yt)},persist:function(){},isPersistent:Yt}),t}var el,tl,ll,nl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},al=Zt(nl),rl=b({},nl,{view:0,detail:0}),il=Zt(rl),ol=b({},rl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:vl,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==ll&&(ll&&"mousemove"===e.type?(el=e.screenX-ll.screenX,tl=e.screenY-ll.screenY):tl=el=0,ll=e),el)},movementY:function(e){return"movementY"in e?e.movementY:tl}}),sl=Zt(ol),cl=Zt(b({},ol,{dataTransfer:0})),ul=Zt(b({},rl,{relatedTarget:0})),dl=Zt(b({},nl,{animationName:0,elapsedTime:0,pseudoElement:0})),bl=Zt(b({},nl,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}})),ml=Zt(b({},nl,{data:0})),hl={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},pl={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},fl={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function gl(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=fl[e])&&!!t[e]}function vl(){return gl}var yl=Zt(b({},rl,{key:function(e){if(e.key){var t=hl[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=Xt(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?pl[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:vl,charCode:function(e){return"keypress"===e.type?Xt(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?Xt(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}})),xl=Zt(b({},ol,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),wl=Zt(b({},rl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:vl})),kl=Zt(b({},nl,{propertyName:0,elapsedTime:0,pseudoElement:0})),Cl=Zt(b({},ol,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Sl=Zt(b({},nl,{newState:0,oldState:0})),jl=[9,13,27,32],Nl=qt&&"CompositionEvent"in window,El=null;qt&&"documentMode"in document&&(El=document.documentMode);var $l=qt&&"TextEvent"in window&&!El,_l=qt&&(!Nl||El&&8<El&&11>=El),Tl=String.fromCharCode(32),Al=!1;function zl(e,t){switch(e){case"keyup":return-1!==jl.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ll(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Ml=!1;var Il={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Pl(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!Il[e.type]:"textarea"===t}function Dl(e,t,l,n){Dt?Rt?Rt.push(n):Rt=[n]:Dt=n,0<(t=rd(t,"onChange")).length&&(l=new al("onChange","change",null,l,n),e.push({event:l,listeners:t}))}var Rl=null,Ol=null;function Fl(e){Yu(e,0)}function Ul(e){if(ft(et(e)))return e}function Bl(e,t){if("change"===e)return t}var ql=!1;if(qt){var Wl;if(qt){var Vl="oninput"in document;if(!Vl){var Hl=document.createElement("div");Hl.setAttribute("oninput","return;"),Vl="function"==typeof Hl.oninput}Wl=Vl}else Wl=!1;ql=Wl&&(!document.documentMode||9<document.documentMode)}function Kl(){Rl&&(Rl.detachEvent("onpropertychange",Gl),Ol=Rl=null)}function Gl(e){if("value"===e.propertyName&&Ul(Ol)){var t=[];Dl(t,Ol,e,Pt(e)),Ut(Fl,t)}}function Ql(e,t,l){"focusin"===e?(Kl(),Ol=l,(Rl=t).attachEvent("onpropertychange",Gl)):"focusout"===e&&Kl()}function Xl(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Ul(Ol)}function Yl(e,t){if("click"===e)return Ul(t)}function Jl(e,t){if("input"===e||"change"===e)return Ul(t)}var Zl="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t};function en(e,t){if(Zl(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var l=Object.keys(e),n=Object.keys(t);if(l.length!==n.length)return!1;for(n=0;n<l.length;n++){var a=l[n];if(!re.call(t,a)||!Zl(e[a],t[a]))return!1}return!0}function tn(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ln(e,t){var l,n=tn(e);for(e=0;n;){if(3===n.nodeType){if(l=e+n.textContent.length,e<=t&&l>=t)return{node:n,offset:t-e};e=l}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=tn(n)}}function nn(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?nn(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function an(e){for(var t=gt((e=null!=e&&null!=e.ownerDocument&&null!=e.ownerDocument.defaultView?e.ownerDocument.defaultView:window).document);t instanceof e.HTMLIFrameElement;){try{var l="string"==typeof t.contentWindow.location.href}catch(n){l=!1}if(!l)break;t=gt((e=t.contentWindow).document)}return t}function rn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}var on=qt&&"documentMode"in document&&11>=document.documentMode,sn=null,cn=null,un=null,dn=!1;function bn(e,t,l){var n=l.window===l?l.document:9===l.nodeType?l:l.ownerDocument;dn||null==sn||sn!==gt(n)||("selectionStart"in(n=sn)&&rn(n)?n={start:n.selectionStart,end:n.selectionEnd}:n={anchorNode:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset},un&&en(un,n)||(un=n,0<(n=rd(cn,"onSelect")).length&&(t=new al("onSelect","select",null,t,l),e.push({event:t,listeners:n}),t.target=sn)))}function mn(e,t){var l={};return l[e.toLowerCase()]=t.toLowerCase(),l["Webkit"+e]="webkit"+t,l["Moz"+e]="moz"+t,l}var hn={animationend:mn("Animation","AnimationEnd"),animationiteration:mn("Animation","AnimationIteration"),animationstart:mn("Animation","AnimationStart"),transitionrun:mn("Transition","TransitionRun"),transitionstart:mn("Transition","TransitionStart"),transitioncancel:mn("Transition","TransitionCancel"),transitionend:mn("Transition","TransitionEnd")},pn={},fn={};function gn(e){if(pn[e])return pn[e];if(!hn[e])return e;var t,l=hn[e];for(t in l)if(l.hasOwnProperty(t)&&t in fn)return pn[e]=l[t];return e}qt&&(fn=document.createElement("div").style,"AnimationEvent"in window||(delete hn.animationend.animation,delete hn.animationiteration.animation,delete hn.animationstart.animation),"TransitionEvent"in window||delete hn.transitionend.transition);var vn=gn("animationend"),yn=gn("animationiteration"),xn=gn("animationstart"),wn=gn("transitionrun"),kn=gn("transitionstart"),Cn=gn("transitioncancel"),Sn=gn("transitionend"),jn=new Map,Nn="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function En(e,t){jn.set(e,t),rt(t,[e])}Nn.push("scrollEnd");var $n="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)},_n=[],Tn=0,An=0;function zn(){for(var e=Tn,t=An=Tn=0;t<e;){var l=_n[t];_n[t++]=null;var n=_n[t];_n[t++]=null;var a=_n[t];_n[t++]=null;var r=_n[t];if(_n[t++]=null,null!==n&&null!==a){var i=n.pending;null===i?a.next=a:(a.next=i.next,i.next=a),n.pending=a}0!==r&&Pn(l,a,r)}}function Ln(e,t,l,n){_n[Tn++]=e,_n[Tn++]=t,_n[Tn++]=l,_n[Tn++]=n,An|=n,e.lanes|=n,null!==(e=e.alternate)&&(e.lanes|=n)}function Mn(e,t,l,n){return Ln(e,t,l,n),Dn(e)}function In(e,t){return Ln(e,null,null,t),Dn(e)}function Pn(e,t,l){e.lanes|=l;var n=e.alternate;null!==n&&(n.lanes|=l);for(var a=!1,r=e.return;null!==r;)r.childLanes|=l,null!==(n=r.alternate)&&(n.childLanes|=l),22===r.tag&&(null===(e=r.stateNode)||1&e._visibility||(a=!0)),e=r,r=r.return;return 3===e.tag?(r=e.stateNode,a&&null!==t&&(a=31-ke(l),null===(n=(e=r.hiddenUpdates)[a])?e[a]=[t]:n.push(t),t.lane=536870912|l),r):null}function Dn(e){if(50<Hc)throw Hc=0,Kc=null,Error(r(185));for(var t=e.return;null!==t;)t=(e=t).return;return 3===e.tag?e.stateNode:null}var Rn={};function On(e,t,l,n){this.tag=e,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Fn(e,t,l,n){return new On(e,t,l,n)}function Un(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Bn(e,t){var l=e.alternate;return null===l?((l=Fn(e.tag,t,e.key,e.mode)).elementType=e.elementType,l.type=e.type,l.stateNode=e.stateNode,l.alternate=e,e.alternate=l):(l.pendingProps=t,l.type=e.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=65011712&e.flags,l.childLanes=e.childLanes,l.lanes=e.lanes,l.child=e.child,l.memoizedProps=e.memoizedProps,l.memoizedState=e.memoizedState,l.updateQueue=e.updateQueue,t=e.dependencies,l.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},l.sibling=e.sibling,l.index=e.index,l.ref=e.ref,l.refCleanup=e.refCleanup,l}function qn(e,t){e.flags&=65011714;var l=e.alternate;return null===l?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=l.childLanes,e.lanes=l.lanes,e.child=l.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=l.memoizedProps,e.memoizedState=l.memoizedState,e.updateQueue=l.updateQueue,e.type=l.type,t=l.dependencies,e.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Wn(e,t,l,n,a,i){var o=0;if(n=e,"function"==typeof e)Un(e)&&(o=1);else if("string"==typeof e)o=function(e,t,l){if(1===l||null!=t.itemProp)return!1;switch(e){case"meta":case"title":return!0;case"style":if("string"!=typeof t.precedence||"string"!=typeof t.href||""===t.href)break;return!0;case"link":if("string"!=typeof t.rel||"string"!=typeof t.href||""===t.href||t.onLoad||t.onError)break;return"stylesheet"!==t.rel||(e=t.disabled,"string"==typeof t.precedence&&null==e);case"script":if(t.async&&"function"!=typeof t.async&&"symbol"!=typeof t.async&&!t.onLoad&&!t.onError&&t.src&&"string"==typeof t.src)return!0}return!1}(e,l,H.current)?26:"html"===e||"head"===e||"body"===e?27:5;else e:switch(e){case _:return(e=Fn(31,l,t,a)).elementType=_,e.lanes=i,e;case f:return Vn(l.children,a,i,t);case g:o=8,a|=24;break;case y:return(e=Fn(12,l,t,2|a)).elementType=y,e.lanes=i,e;case j:return(e=Fn(13,l,t,a)).elementType=j,e.lanes=i,e;case N:return(e=Fn(19,l,t,a)).elementType=N,e.lanes=i,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case k:o=10;break e;case x:o=9;break e;case C:o=11;break e;case E:o=14;break e;case $:o=16,n=null;break e}o=29,l=Error(r(130,null===e?"null":typeof e,"")),n=null}return(t=Fn(o,l,t,a)).elementType=e,t.type=n,t.lanes=i,t}function Vn(e,t,l,n){return(e=Fn(7,e,n,t)).lanes=l,e}function Hn(e,t,l){return(e=Fn(6,e,null,t)).lanes=l,e}function Kn(e){var t=Fn(18,null,null,0);return t.stateNode=e,t}function Gn(e,t,l){return(t=Fn(4,null!==e.children?e.children:[],e.key,t)).lanes=l,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Qn=new WeakMap;function Xn(e,t){if("object"==typeof e&&null!==e){var l=Qn.get(e);return void 0!==l?l:(t={value:e,source:t,stack:ae(t)},Qn.set(e,t),t)}return{value:e,source:t,stack:ae(t)}}var Yn=[],Jn=0,Zn=null,ea=0,ta=[],la=0,na=null,aa=1,ra="";function ia(e,t){Yn[Jn++]=ea,Yn[Jn++]=Zn,Zn=e,ea=t}function oa(e,t,l){ta[la++]=aa,ta[la++]=ra,ta[la++]=na,na=e;var n=aa;e=ra;var a=32-ke(n)-1;n&=~(1<<a),l+=1;var r=32-ke(t)+a;if(30<r){var i=a-a%5;r=(n&(1<<i)-1).toString(32),n>>=i,a-=i,aa=1<<32-ke(t)+a|l<<a|n,ra=r+e}else aa=1<<r|l<<a|n,ra=e}function sa(e){null!==e.return&&(ia(e,1),oa(e,1,0))}function ca(e){for(;e===Zn;)Zn=Yn[--Jn],Yn[Jn]=null,ea=Yn[--Jn],Yn[Jn]=null;for(;e===na;)na=ta[--la],ta[la]=null,ra=ta[--la],ta[la]=null,aa=ta[--la],ta[la]=null}function ua(e,t){ta[la++]=aa,ta[la++]=ra,ta[la++]=na,aa=t.id,ra=t.overflow,na=e}var da=null,ba=null,ma=!1,ha=null,pa=!1,fa=Error(r(519));function ga(e){throw Ca(Xn(Error(r(418,1<arguments.length&&void 0!==arguments[1]&&arguments[1]?"text":"HTML","")),e)),fa}function va(e){var t=e.stateNode,l=e.type,n=e.memoizedProps;switch(t[qe]=e,t[We]=n,l){case"dialog":Ju("cancel",t),Ju("close",t);break;case"iframe":case"object":case"embed":Ju("load",t);break;case"video":case"audio":for(l=0;l<Qu.length;l++)Ju(Qu[l],t);break;case"source":Ju("error",t);break;case"img":case"image":case"link":Ju("error",t),Ju("load",t);break;case"details":Ju("toggle",t);break;case"input":Ju("invalid",t),wt(t,n.value,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name,!0);break;case"select":Ju("invalid",t);break;case"textarea":Ju("invalid",t),jt(t,n.value,n.defaultValue,n.children)}"string"!=typeof(l=n.children)&&"number"!=typeof l&&"bigint"!=typeof l||t.textContent===""+l||!0===n.suppressHydrationWarning||dd(t.textContent,l)?(null!=n.popover&&(Ju("beforetoggle",t),Ju("toggle",t)),null!=n.onScroll&&Ju("scroll",t),null!=n.onScrollEnd&&Ju("scrollend",t),null!=n.onClick&&(t.onclick=Mt),t=!0):t=!1,t||ga(e,!0)}function ya(e){for(da=e.return;da;)switch(da.tag){case 5:case 31:case 13:return void(pa=!1);case 27:case 3:return void(pa=!0);default:da=da.return}}function xa(e){if(e!==da)return!1;if(!ma)return ya(e),ma=!0,!1;var t,l=e.tag;if((t=3!==l&&27!==l)&&((t=5===l)&&(t=!("form"!==(t=e.type)&&"button"!==t)||wd(e.type,e.memoizedProps)),t=!t),t&&ba&&ga(e),ya(e),13===l){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(r(317));ba=Dd(e)}else if(31===l){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(r(317));ba=Dd(e)}else 27===l?(l=ba,$d(e.type)?(e=Pd,Pd=null,ba=e):ba=l):ba=da?Id(e.stateNode.nextSibling):null;return!0}function wa(){ba=da=null,ma=!1}function ka(){var e=ha;return null!==e&&(null===zc?zc=e:zc.push.apply(zc,e),ha=null),e}function Ca(e){null===ha?ha=[e]:ha.push(e)}var Sa=U(null),ja=null,Na=null;function Ea(e,t,l){q(Sa,t._currentValue),t._currentValue=l}function $a(e){e._currentValue=Sa.current,B(Sa)}function _a(e,t,l){for(;null!==e;){var n=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==n&&(n.childLanes|=t)):null!==n&&(n.childLanes&t)!==t&&(n.childLanes|=t),e===l)break;e=e.return}}function Ta(e,t,l,n){var a=e.child;for(null!==a&&(a.return=e);null!==a;){var i=a.dependencies;if(null!==i){var o=a.child;i=i.firstContext;e:for(;null!==i;){var s=i;i=a;for(var c=0;c<t.length;c++)if(s.context===t[c]){i.lanes|=l,null!==(s=i.alternate)&&(s.lanes|=l),_a(i.return,l,e),n||(o=null);break e}i=s.next}}else if(18===a.tag){if(null===(o=a.return))throw Error(r(341));o.lanes|=l,null!==(i=o.alternate)&&(i.lanes|=l),_a(o,l,e),o=null}else o=a.child;if(null!==o)o.return=a;else for(o=a;null!==o;){if(o===e){o=null;break}if(null!==(a=o.sibling)){a.return=o.return,o=a;break}o=o.return}a=o}}function Aa(e,t,l,n){e=null;for(var a=t,i=!1;null!==a;){if(!i)if(524288&a.flags)i=!0;else if(262144&a.flags)break;if(10===a.tag){var o=a.alternate;if(null===o)throw Error(r(387));if(null!==(o=o.memoizedProps)){var s=a.type;Zl(a.pendingProps.value,o.value)||(null!==e?e.push(s):e=[s])}}else if(a===Q.current){if(null===(o=a.alternate))throw Error(r(387));o.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(null!==e?e.push(bb):e=[bb])}a=a.return}null!==e&&Ta(t,e,l,n),t.flags|=262144}function za(e){for(e=e.firstContext;null!==e;){if(!Zl(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function La(e){ja=e,Na=null,null!==(e=e.dependencies)&&(e.firstContext=null)}function Ma(e){return Pa(ja,e)}function Ia(e,t){return null===ja&&La(e),Pa(e,t)}function Pa(e,t){var l=t._currentValue;if(t={context:t,memoizedValue:l,next:null},null===Na){if(null===e)throw Error(r(308));Na=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Na=Na.next=t;return l}var Da="undefined"!=typeof AbortController?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,l){e.push(l)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Ra=l.unstable_scheduleCallback,Oa=l.unstable_NormalPriority,Fa={$$typeof:k,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ua(){return{controller:new Da,data:new Map,refCount:0}}function Ba(e){e.refCount--,0===e.refCount&&Ra(Oa,function(){e.controller.abort()})}var qa=null,Wa=0,Va=0,Ha=null;function Ka(){if(0===--Wa&&null!==qa){null!==Ha&&(Ha.status="fulfilled");var e=qa;qa=null,Va=0,Ha=null;for(var t=0;t<e.length;t++)(0,e[t])()}}var Ga=P.S;P.S=function(e,t){Ic=ue(),"object"==typeof t&&null!==t&&"function"==typeof t.then&&function(e,t){if(null===qa){var l=qa=[];Wa=0,Va=Wu(),Ha={status:"pending",value:void 0,then:function(e){l.push(e)}}}Wa++,t.then(Ka,Ka)}(0,t),null!==Ga&&Ga(e,t)};var Qa=U(null);function Xa(){var e=Qa.current;return null!==e?e:fc.pooledCache}function Ya(e,t){q(Qa,null===t?Qa.current:t.pool)}function Ja(){var e=Xa();return null===e?null:{parent:Fa._currentValue,pool:e}}var Za=Error(r(460)),er=Error(r(474)),tr=Error(r(542)),lr={then:function(){}};function nr(e){return"fulfilled"===(e=e.status)||"rejected"===e}function ar(e,t,l){switch(void 0===(l=e[l])?e.push(t):l!==t&&(t.then(Mt,Mt),t=l),t.status){case"fulfilled":return t.value;case"rejected":throw sr(e=t.reason),e;default:if("string"==typeof t.status)t.then(Mt,Mt);else{if(null!==(e=fc)&&100<e.shellSuspendCounter)throw Error(r(482));(e=t).status="pending",e.then(function(e){if("pending"===t.status){var l=t;l.status="fulfilled",l.value=e}},function(e){if("pending"===t.status){var l=t;l.status="rejected",l.reason=e}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw sr(e=t.reason),e}throw ir=t,Za}}function rr(e){try{return(0,e._init)(e._payload)}catch(t){if(null!==t&&"object"==typeof t&&"function"==typeof t.then)throw ir=t,Za;throw t}}var ir=null;function or(){if(null===ir)throw Error(r(459));var e=ir;return ir=null,e}function sr(e){if(e===Za||e===tr)throw Error(r(483))}var cr=null,ur=0;function dr(e){var t=ur;return ur+=1,null===cr&&(cr=[]),ar(cr,e,t)}function br(e,t){t=t.props.ref,e.ref=void 0!==t?t:null}function mr(e,t){if(t.$$typeof===m)throw Error(r(525));throw e=Object.prototype.toString.call(t),Error(r(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function hr(e){function t(t,l){if(e){var n=t.deletions;null===n?(t.deletions=[l],t.flags|=16):n.push(l)}}function l(l,n){if(!e)return null;for(;null!==n;)t(l,n),n=n.sibling;return null}function n(e){for(var t=new Map;null!==e;)null!==e.key?t.set(e.key,e):t.set(e.index,e),e=e.sibling;return t}function a(e,t){return(e=Bn(e,t)).index=0,e.sibling=null,e}function i(t,l,n){return t.index=n,e?null!==(n=t.alternate)?(n=n.index)<l?(t.flags|=67108866,l):n:(t.flags|=67108866,l):(t.flags|=1048576,l)}function o(t){return e&&null===t.alternate&&(t.flags|=67108866),t}function s(e,t,l,n){return null===t||6!==t.tag?((t=Hn(l,e.mode,n)).return=e,t):((t=a(t,l)).return=e,t)}function c(e,t,l,n){var r=l.type;return r===f?d(e,t,l.props.children,n,l.key):null!==t&&(t.elementType===r||"object"==typeof r&&null!==r&&r.$$typeof===$&&rr(r)===t.type)?(br(t=a(t,l.props),l),t.return=e,t):(br(t=Wn(l.type,l.key,l.props,null,e.mode,n),l),t.return=e,t)}function u(e,t,l,n){return null===t||4!==t.tag||t.stateNode.containerInfo!==l.containerInfo||t.stateNode.implementation!==l.implementation?((t=Gn(l,e.mode,n)).return=e,t):((t=a(t,l.children||[])).return=e,t)}function d(e,t,l,n,r){return null===t||7!==t.tag?((t=Vn(l,e.mode,n,r)).return=e,t):((t=a(t,l)).return=e,t)}function b(e,t,l){if("string"==typeof t&&""!==t||"number"==typeof t||"bigint"==typeof t)return(t=Hn(""+t,e.mode,l)).return=e,t;if("object"==typeof t&&null!==t){switch(t.$$typeof){case h:return br(l=Wn(t.type,t.key,t.props,null,e.mode,l),t),l.return=e,l;case p:return(t=Gn(t,e.mode,l)).return=e,t;case $:return b(e,t=rr(t),l)}if(I(t)||z(t))return(t=Vn(t,e.mode,l,null)).return=e,t;if("function"==typeof t.then)return b(e,dr(t),l);if(t.$$typeof===k)return b(e,Ia(e,t),l);mr(e,t)}return null}function m(e,t,l,n){var a=null!==t?t.key:null;if("string"==typeof l&&""!==l||"number"==typeof l||"bigint"==typeof l)return null!==a?null:s(e,t,""+l,n);if("object"==typeof l&&null!==l){switch(l.$$typeof){case h:return l.key===a?c(e,t,l,n):null;case p:return l.key===a?u(e,t,l,n):null;case $:return m(e,t,l=rr(l),n)}if(I(l)||z(l))return null!==a?null:d(e,t,l,n,null);if("function"==typeof l.then)return m(e,t,dr(l),n);if(l.$$typeof===k)return m(e,t,Ia(e,l),n);mr(e,l)}return null}function g(e,t,l,n,a){if("string"==typeof n&&""!==n||"number"==typeof n||"bigint"==typeof n)return s(t,e=e.get(l)||null,""+n,a);if("object"==typeof n&&null!==n){switch(n.$$typeof){case h:return c(t,e=e.get(null===n.key?l:n.key)||null,n,a);case p:return u(t,e=e.get(null===n.key?l:n.key)||null,n,a);case $:return g(e,t,l,n=rr(n),a)}if(I(n)||z(n))return d(t,e=e.get(l)||null,n,a,null);if("function"==typeof n.then)return g(e,t,l,dr(n),a);if(n.$$typeof===k)return g(e,t,l,Ia(t,n),a);mr(t,n)}return null}function v(s,c,u,d){if("object"==typeof u&&null!==u&&u.type===f&&null===u.key&&(u=u.props.children),"object"==typeof u&&null!==u){switch(u.$$typeof){case h:e:{for(var y=u.key;null!==c;){if(c.key===y){if((y=u.type)===f){if(7===c.tag){l(s,c.sibling),(d=a(c,u.props.children)).return=s,s=d;break e}}else if(c.elementType===y||"object"==typeof y&&null!==y&&y.$$typeof===$&&rr(y)===c.type){l(s,c.sibling),br(d=a(c,u.props),u),d.return=s,s=d;break e}l(s,c);break}t(s,c),c=c.sibling}u.type===f?((d=Vn(u.props.children,s.mode,d,u.key)).return=s,s=d):(br(d=Wn(u.type,u.key,u.props,null,s.mode,d),u),d.return=s,s=d)}return o(s);case p:e:{for(y=u.key;null!==c;){if(c.key===y){if(4===c.tag&&c.stateNode.containerInfo===u.containerInfo&&c.stateNode.implementation===u.implementation){l(s,c.sibling),(d=a(c,u.children||[])).return=s,s=d;break e}l(s,c);break}t(s,c),c=c.sibling}(d=Gn(u,s.mode,d)).return=s,s=d}return o(s);case $:return v(s,c,u=rr(u),d)}if(I(u))return function(a,r,o,s){for(var c=null,u=null,d=r,h=r=0,p=null;null!==d&&h<o.length;h++){d.index>h?(p=d,d=null):p=d.sibling;var f=m(a,d,o[h],s);if(null===f){null===d&&(d=p);break}e&&d&&null===f.alternate&&t(a,d),r=i(f,r,h),null===u?c=f:u.sibling=f,u=f,d=p}if(h===o.length)return l(a,d),ma&&ia(a,h),c;if(null===d){for(;h<o.length;h++)null!==(d=b(a,o[h],s))&&(r=i(d,r,h),null===u?c=d:u.sibling=d,u=d);return ma&&ia(a,h),c}for(d=n(d);h<o.length;h++)null!==(p=g(d,a,h,o[h],s))&&(e&&null!==p.alternate&&d.delete(null===p.key?h:p.key),r=i(p,r,h),null===u?c=p:u.sibling=p,u=p);return e&&d.forEach(function(e){return t(a,e)}),ma&&ia(a,h),c}(s,c,u,d);if(z(u)){if("function"!=typeof(y=z(u)))throw Error(r(150));return function(a,o,s,c){if(null==s)throw Error(r(151));for(var u=null,d=null,h=o,p=o=0,f=null,v=s.next();null!==h&&!v.done;p++,v=s.next()){h.index>p?(f=h,h=null):f=h.sibling;var y=m(a,h,v.value,c);if(null===y){null===h&&(h=f);break}e&&h&&null===y.alternate&&t(a,h),o=i(y,o,p),null===d?u=y:d.sibling=y,d=y,h=f}if(v.done)return l(a,h),ma&&ia(a,p),u;if(null===h){for(;!v.done;p++,v=s.next())null!==(v=b(a,v.value,c))&&(o=i(v,o,p),null===d?u=v:d.sibling=v,d=v);return ma&&ia(a,p),u}for(h=n(h);!v.done;p++,v=s.next())null!==(v=g(h,a,p,v.value,c))&&(e&&null!==v.alternate&&h.delete(null===v.key?p:v.key),o=i(v,o,p),null===d?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),ma&&ia(a,p),u}(s,c,u=y.call(u),d)}if("function"==typeof u.then)return v(s,c,dr(u),d);if(u.$$typeof===k)return v(s,c,Ia(s,u),d);mr(s,u)}return"string"==typeof u&&""!==u||"number"==typeof u||"bigint"==typeof u?(u=""+u,null!==c&&6===c.tag?(l(s,c.sibling),(d=a(c,u)).return=s,s=d):(l(s,c),(d=Hn(u,s.mode,d)).return=s,s=d),o(s)):l(s,c)}return function(e,t,l,n){try{ur=0;var a=v(e,t,l,n);return cr=null,a}catch(i){if(i===Za||i===tr)throw i;var r=Fn(29,i,null,e.mode);return r.lanes=n,r.return=e,r}}}var pr=hr(!0),fr=hr(!1),gr=!1;function vr(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function yr(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function xr(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function wr(e,t,l){var n=e.updateQueue;if(null===n)return null;if(n=n.shared,2&pc){var a=n.pending;return null===a?t.next=t:(t.next=a.next,a.next=t),n.pending=t,t=Dn(e),Pn(e,null,l),t}return Ln(e,n,t,l),Dn(e)}function kr(e,t,l){if(null!==(t=t.updateQueue)&&(t=t.shared,4194048&l)){var n=t.lanes;l|=n&=e.pendingLanes,t.lanes=l,Pe(e,l)}}function Cr(e,t){var l=e.updateQueue,n=e.alternate;if(null!==n&&l===(n=n.updateQueue)){var a=null,r=null;if(null!==(l=l.firstBaseUpdate)){do{var i={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};null===r?a=r=i:r=r.next=i,l=l.next}while(null!==l);null===r?a=r=t:r=r.next=t}else a=r=t;return l={baseState:n.baseState,firstBaseUpdate:a,lastBaseUpdate:r,shared:n.shared,callbacks:n.callbacks},void(e.updateQueue=l)}null===(e=l.lastBaseUpdate)?l.firstBaseUpdate=t:e.next=t,l.lastBaseUpdate=t}var Sr=!1;function jr(){if(Sr){if(null!==Ha)throw Ha}}function Nr(e,t,l,n){Sr=!1;var a=e.updateQueue;gr=!1;var r=a.firstBaseUpdate,i=a.lastBaseUpdate,o=a.shared.pending;if(null!==o){a.shared.pending=null;var s=o,c=s.next;s.next=null,null===i?r=c:i.next=c,i=s;var u=e.alternate;null!==u&&((o=(u=u.updateQueue).lastBaseUpdate)!==i&&(null===o?u.firstBaseUpdate=c:o.next=c,u.lastBaseUpdate=s))}if(null!==r){var d=a.baseState;for(i=0,u=c=s=null,o=r;;){var m=-536870913&o.lane,h=m!==o.lane;if(h?(vc&m)===m:(n&m)===m){0!==m&&m===Va&&(Sr=!0),null!==u&&(u=u.next={lane:0,tag:o.tag,payload:o.payload,callback:null,next:null});e:{var p=e,f=o;m=t;var g=l;switch(f.tag){case 1:if("function"==typeof(p=f.payload)){d=p.call(g,d,m);break e}d=p;break e;case 3:p.flags=-65537&p.flags|128;case 0:if(null==(m="function"==typeof(p=f.payload)?p.call(g,d,m):p))break e;d=b({},d,m);break e;case 2:gr=!0}}null!==(m=o.callback)&&(e.flags|=64,h&&(e.flags|=8192),null===(h=a.callbacks)?a.callbacks=[m]:h.push(m))}else h={lane:m,tag:o.tag,payload:o.payload,callback:o.callback,next:null},null===u?(c=u=h,s=d):u=u.next=h,i|=m;if(null===(o=o.next)){if(null===(o=a.shared.pending))break;o=(h=o).next,h.next=null,a.lastBaseUpdate=h,a.shared.pending=null}}null===u&&(s=d),a.baseState=s,a.firstBaseUpdate=c,a.lastBaseUpdate=u,null===r&&(a.shared.lanes=0),Nc|=i,e.lanes=i,e.memoizedState=d}}function Er(e,t){if("function"!=typeof e)throw Error(r(191,e));e.call(t)}function $r(e,t){var l=e.callbacks;if(null!==l)for(e.callbacks=null,e=0;e<l.length;e++)Er(l[e],t)}var _r=U(null),Tr=U(0);function Ar(e,t){q(Tr,e=Sc),q(_r,t),Sc=e|t.baseLanes}function zr(){q(Tr,Sc),q(_r,_r.current)}function Lr(){Sc=Tr.current,B(_r),B(Tr)}var Mr=U(null),Ir=null;function Pr(e){var t=e.alternate;q(Ur,1&Ur.current),q(Mr,e),null===Ir&&(null===t||null!==_r.current||null!==t.memoizedState)&&(Ir=e)}function Dr(e){q(Ur,Ur.current),q(Mr,e),null===Ir&&(Ir=e)}function Rr(e){22===e.tag?(q(Ur,Ur.current),q(Mr,e),null===Ir&&(Ir=e)):Or()}function Or(){q(Ur,Ur.current),q(Mr,Mr.current)}function Fr(e){B(Mr),Ir===e&&(Ir=null),B(Ur)}var Ur=U(0);function Br(e){for(var t=e;null!==t;){if(13===t.tag){var l=t.memoizedState;if(null!==l&&(null===(l=l.dehydrated)||Ld(l)||Md(l)))return t}else if(19!==t.tag||"forwards"!==t.memoizedProps.revealOrder&&"backwards"!==t.memoizedProps.revealOrder&&"unstable_legacy-backwards"!==t.memoizedProps.revealOrder&&"together"!==t.memoizedProps.revealOrder){if(null!==t.child){t.child.return=t,t=t.child;continue}}else if(128&t.flags)return t;if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var qr=0,Wr=null,Vr=null,Hr=null,Kr=!1,Gr=!1,Qr=!1,Xr=0,Yr=0,Jr=null,Zr=0;function ei(){throw Error(r(321))}function ti(e,t){if(null===t)return!1;for(var l=0;l<t.length&&l<e.length;l++)if(!Zl(e[l],t[l]))return!1;return!0}function li(e,t,l,n,a,r){return qr=r,Wr=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,P.H=null===e||null===e.memoizedState?vo:yo,Qr=!1,r=l(n,a),Qr=!1,Gr&&(r=ai(t,l,n,a)),ni(e),r}function ni(e){P.H=go;var t=null!==Vr&&null!==Vr.next;if(qr=0,Hr=Vr=Wr=null,Kr=!1,Yr=0,Jr=null,t)throw Error(r(300));null===e||Io||null!==(e=e.dependencies)&&za(e)&&(Io=!0)}function ai(e,t,l,n){Wr=e;var a=0;do{if(Gr&&(Jr=null),Yr=0,Gr=!1,25<=a)throw Error(r(301));if(a+=1,Hr=Vr=null,null!=e.updateQueue){var i=e.updateQueue;i.lastEffect=null,i.events=null,i.stores=null,null!=i.memoCache&&(i.memoCache.index=0)}P.H=xo,i=t(l,n)}while(Gr);return i}function ri(){var e=P.H,t=e.useState()[0];return t="function"==typeof t.then?di(t):t,e=e.useState()[0],(null!==Vr?Vr.memoizedState:null)!==e&&(Wr.flags|=1024),t}function ii(){var e=0!==Xr;return Xr=0,e}function oi(e,t,l){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l}function si(e){if(Kr){for(e=e.memoizedState;null!==e;){var t=e.queue;null!==t&&(t.pending=null),e=e.next}Kr=!1}qr=0,Hr=Vr=Wr=null,Gr=!1,Yr=Xr=0,Jr=null}function ci(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===Hr?Wr.memoizedState=Hr=e:Hr=Hr.next=e,Hr}function ui(){if(null===Vr){var e=Wr.alternate;e=null!==e?e.memoizedState:null}else e=Vr.next;var t=null===Hr?Wr.memoizedState:Hr.next;if(null!==t)Hr=t,Vr=e;else{if(null===e){if(null===Wr.alternate)throw Error(r(467));throw Error(r(310))}e={memoizedState:(Vr=e).memoizedState,baseState:Vr.baseState,baseQueue:Vr.baseQueue,queue:Vr.queue,next:null},null===Hr?Wr.memoizedState=Hr=e:Hr=Hr.next=e}return Hr}function di(e){var t=Yr;return Yr+=1,null===Jr&&(Jr=[]),e=ar(Jr,e,t),t=Wr,null===(null===Hr?t.memoizedState:Hr.next)&&(t=t.alternate,P.H=null===t||null===t.memoizedState?vo:yo),e}function bi(e){if(null!==e&&"object"==typeof e){if("function"==typeof e.then)return di(e);if(e.$$typeof===k)return Ma(e)}throw Error(r(438,String(e)))}function mi(e){var t=null,l=Wr.updateQueue;if(null!==l&&(t=l.memoCache),null==t){var n=Wr.alternate;null!==n&&(null!==(n=n.updateQueue)&&(null!=(n=n.memoCache)&&(t={data:n.data.map(function(e){return e.slice()}),index:0})))}if(null==t&&(t={data:[],index:0}),null===l&&(l={lastEffect:null,events:null,stores:null,memoCache:null},Wr.updateQueue=l),l.memoCache=t,void 0===(l=t.data[t.index]))for(l=t.data[t.index]=Array(e),n=0;n<e;n++)l[n]=T;return t.index++,l}function hi(e,t){return"function"==typeof t?t(e):t}function pi(e){return fi(ui(),Vr,e)}function fi(e,t,l){var n=e.queue;if(null===n)throw Error(r(311));n.lastRenderedReducer=l;var a=e.baseQueue,i=n.pending;if(null!==i){if(null!==a){var o=a.next;a.next=i.next,i.next=o}t.baseQueue=a=i,n.pending=null}if(i=e.baseState,null===a)e.memoizedState=i;else{var s=o=null,c=null,u=t=a.next,d=!1;do{var b=-536870913&u.lane;if(b!==u.lane?(vc&b)===b:(qr&b)===b){var m=u.revertLane;if(0===m)null!==c&&(c=c.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),b===Va&&(d=!0);else{if((qr&m)===m){u=u.next,m===Va&&(d=!0);continue}b={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(s=c=b,o=i):c=c.next=b,Wr.lanes|=m,Nc|=m}b=u.action,Qr&&l(i,b),i=u.hasEagerState?u.eagerState:l(i,b)}else m={lane:b,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(s=c=m,o=i):c=c.next=m,Wr.lanes|=b,Nc|=b;u=u.next}while(null!==u&&u!==t);if(null===c?o=i:c.next=s,!Zl(i,e.memoizedState)&&(Io=!0,d&&null!==(l=Ha)))throw l;e.memoizedState=i,e.baseState=o,e.baseQueue=c,n.lastRenderedState=i}return null===a&&(n.lanes=0),[e.memoizedState,n.dispatch]}function gi(e){var t=ui(),l=t.queue;if(null===l)throw Error(r(311));l.lastRenderedReducer=e;var n=l.dispatch,a=l.pending,i=t.memoizedState;if(null!==a){l.pending=null;var o=a=a.next;do{i=e(i,o.action),o=o.next}while(o!==a);Zl(i,t.memoizedState)||(Io=!0),t.memoizedState=i,null===t.baseQueue&&(t.baseState=i),l.lastRenderedState=i}return[i,n]}function vi(e,t,l){var n=Wr,a=ui(),i=ma;if(i){if(void 0===l)throw Error(r(407));l=l()}else l=t();var o=!Zl((Vr||a).memoizedState,l);if(o&&(a.memoizedState=l,Io=!0),a=a.queue,qi(wi.bind(null,n,a,e),[e]),a.getSnapshot!==t||o||null!==Hr&&1&Hr.memoizedState.tag){if(n.flags|=2048,Ri(9,{destroy:void 0},xi.bind(null,n,a,l,t),null),null===fc)throw Error(r(349));i||127&qr||yi(n,t,l)}return l}function yi(e,t,l){e.flags|=16384,e={getSnapshot:t,value:l},null===(t=Wr.updateQueue)?(t={lastEffect:null,events:null,stores:null,memoCache:null},Wr.updateQueue=t,t.stores=[e]):null===(l=t.stores)?t.stores=[e]:l.push(e)}function xi(e,t,l,n){t.value=l,t.getSnapshot=n,ki(t)&&Ci(e)}function wi(e,t,l){return l(function(){ki(t)&&Ci(e)})}function ki(e){var t=e.getSnapshot;e=e.value;try{var l=t();return!Zl(e,l)}catch(n){return!0}}function Ci(e){var t=In(e,2);null!==t&&Xc(t,e,2)}function Si(e){var t=ci();if("function"==typeof e){var l=e;if(e=l(),Qr){we(!0);try{l()}finally{we(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:hi,lastRenderedState:e},t}function ji(e,t,l,n){return e.baseState=l,fi(e,Vr,"function"==typeof n?n:hi)}function Ni(e,t,l,n,a){if(ho(e))throw Error(r(485));if(null!==(e=t.action)){var i={payload:a,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(e){i.listeners.push(e)}};null!==P.T?l(!0):i.isTransition=!1,n(i),null===(l=t.pending)?(i.next=t.pending=i,Ei(t,i)):(i.next=l.next,t.pending=l.next=i)}}function Ei(e,t){var l=t.action,n=t.payload,a=e.state;if(t.isTransition){var r=P.T,i={};P.T=i;try{var o=l(a,n),s=P.S;null!==s&&s(i,o),$i(e,t,o)}catch(c){Ti(e,t,c)}finally{null!==r&&null!==i.types&&(r.types=i.types),P.T=r}}else try{$i(e,t,r=l(a,n))}catch(u){Ti(e,t,u)}}function $i(e,t,l){null!==l&&"object"==typeof l&&"function"==typeof l.then?l.then(function(l){_i(e,t,l)},function(l){return Ti(e,t,l)}):_i(e,t,l)}function _i(e,t,l){t.status="fulfilled",t.value=l,Ai(t),e.state=l,null!==(t=e.pending)&&((l=t.next)===t?e.pending=null:(l=l.next,t.next=l,Ei(e,l)))}function Ti(e,t,l){var n=e.pending;if(e.pending=null,null!==n){n=n.next;do{t.status="rejected",t.reason=l,Ai(t),t=t.next}while(t!==n)}e.action=null}function Ai(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function zi(e,t){return t}function Li(e,t){if(ma){var l=fc.formState;if(null!==l){e:{var n=Wr;if(ma){if(ba){t:{for(var a=ba,r=pa;8!==a.nodeType;){if(!r){a=null;break t}if(null===(a=Id(a.nextSibling))){a=null;break t}}a="F!"===(r=a.data)||"F"===r?a:null}if(a){ba=Id(a.nextSibling),n="F!"===a.data;break e}}ga(n)}n=!1}n&&(t=l[0])}}return(l=ci()).memoizedState=l.baseState=t,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:zi,lastRenderedState:t},l.queue=n,l=uo.bind(null,Wr,n),n.dispatch=l,n=Si(!1),r=mo.bind(null,Wr,!1,n.queue),a={state:t,dispatch:null,action:e,pending:null},(n=ci()).queue=a,l=Ni.bind(null,Wr,a,r,l),a.dispatch=l,n.memoizedState=e,[t,l,!1]}function Mi(e){return Ii(ui(),Vr,e)}function Ii(e,t,l){if(t=fi(e,t,zi)[0],e=pi(hi)[0],"object"==typeof t&&null!==t&&"function"==typeof t.then)try{var n=di(t)}catch(i){if(i===Za)throw tr;throw i}else n=t;var a=(t=ui()).queue,r=a.dispatch;return l!==t.memoizedState&&(Wr.flags|=2048,Ri(9,{destroy:void 0},Pi.bind(null,a,l),null)),[n,r,e]}function Pi(e,t){e.action=t}function Di(e){var t=ui(),l=Vr;if(null!==l)return Ii(t,l,e);ui(),t=t.memoizedState;var n=(l=ui()).queue.dispatch;return l.memoizedState=e,[t,n,!1]}function Ri(e,t,l,n){return e={tag:e,create:l,deps:n,inst:t,next:null},null===(t=Wr.updateQueue)&&(t={lastEffect:null,events:null,stores:null,memoCache:null},Wr.updateQueue=t),null===(l=t.lastEffect)?t.lastEffect=e.next=e:(n=l.next,l.next=e,e.next=n,t.lastEffect=e),e}function Oi(){return ui().memoizedState}function Fi(e,t,l,n){var a=ci();Wr.flags|=e,a.memoizedState=Ri(1|t,{destroy:void 0},l,void 0===n?null:n)}function Ui(e,t,l,n){var a=ui();n=void 0===n?null:n;var r=a.memoizedState.inst;null!==Vr&&null!==n&&ti(n,Vr.memoizedState.deps)?a.memoizedState=Ri(t,r,l,n):(Wr.flags|=e,a.memoizedState=Ri(1|t,r,l,n))}function Bi(e,t){Fi(8390656,8,e,t)}function qi(e,t){Ui(2048,8,e,t)}function Wi(e){var t=ui().memoizedState;return function(e){Wr.flags|=4;var t=Wr.updateQueue;if(null===t)t={lastEffect:null,events:null,stores:null,memoCache:null},Wr.updateQueue=t,t.events=[e];else{var l=t.events;null===l?t.events=[e]:l.push(e)}}({ref:t,nextImpl:e}),function(){if(2&pc)throw Error(r(440));return t.impl.apply(void 0,arguments)}}function Vi(e,t){return Ui(4,2,e,t)}function Hi(e,t){return Ui(4,4,e,t)}function Ki(e,t){if("function"==typeof t){e=e();var l=t(e);return function(){"function"==typeof l?l():t(null)}}if(null!=t)return e=e(),t.current=e,function(){t.current=null}}function Gi(e,t,l){l=null!=l?l.concat([e]):null,Ui(4,4,Ki.bind(null,t,e),l)}function Qi(){}function Xi(e,t){var l=ui();t=void 0===t?null:t;var n=l.memoizedState;return null!==t&&ti(t,n[1])?n[0]:(l.memoizedState=[e,t],e)}function Yi(e,t){var l=ui();t=void 0===t?null:t;var n=l.memoizedState;if(null!==t&&ti(t,n[1]))return n[0];if(n=e(),Qr){we(!0);try{e()}finally{we(!1)}}return l.memoizedState=[n,t],n}function Ji(e,t,l){return void 0===l||1073741824&qr&&!(261930&vc)?e.memoizedState=t:(e.memoizedState=l,e=Qc(),Wr.lanes|=e,Nc|=e,l)}function Zi(e,t,l,n){return Zl(l,t)?l:null!==_r.current?(e=Ji(e,l,n),Zl(e,t)||(Io=!0),e):42&qr&&(!(1073741824&qr)||261930&vc)?(e=Qc(),Wr.lanes|=e,Nc|=e,t):(Io=!0,e.memoizedState=l)}function eo(e,t,l,n,a){var r=D.p;D.p=0!==r&&8>r?r:8;var i,o,s,c=P.T,u={};P.T=u,mo(e,!1,t,l);try{var d=a(),b=P.S;if(null!==b&&b(u,d),null!==d&&"object"==typeof d&&"function"==typeof d.then)bo(e,t,(i=n,o=[],s={status:"pending",value:null,reason:null,then:function(e){o.push(e)}},d.then(function(){s.status="fulfilled",s.value=i;for(var e=0;e<o.length;e++)(0,o[e])(i)},function(e){for(s.status="rejected",s.reason=e,e=0;e<o.length;e++)(0,o[e])(void 0)}),s),Gc());else bo(e,t,n,Gc())}catch(m){bo(e,t,{then:function(){},status:"rejected",reason:m},Gc())}finally{D.p=r,null!==c&&null!==u.types&&(c.types=u.types),P.T=c}}function to(){}function lo(e,t,l,n){if(5!==e.tag)throw Error(r(476));var a=no(e).queue;eo(e,a,t,R,null===l?to:function(){return ao(e),l(n)})}function no(e){var t=e.memoizedState;if(null!==t)return t;var l={};return(t={memoizedState:R,baseState:R,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:hi,lastRenderedState:R},next:null}).next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:hi,lastRenderedState:l},next:null},e.memoizedState=t,null!==(e=e.alternate)&&(e.memoizedState=t),t}function ao(e){var t=no(e);null===t.next&&(t=e.alternate.memoizedState),bo(e,t.next.queue,{},Gc())}function ro(){return Ma(bb)}function io(){return ui().memoizedState}function oo(){return ui().memoizedState}function so(e){for(var t=e.return;null!==t;){switch(t.tag){case 24:case 3:var l=Gc(),n=wr(t,e=xr(l),l);return null!==n&&(Xc(n,t,l),kr(n,t,l)),t={cache:Ua()},void(e.payload=t)}t=t.return}}function co(e,t,l){var n=Gc();l={lane:n,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},ho(e)?po(t,l):null!==(l=Mn(e,t,l,n))&&(Xc(l,e,n),fo(l,t,n))}function uo(e,t,l){bo(e,t,l,Gc())}function bo(e,t,l,n){var a={lane:n,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(ho(e))po(t,a);else{var r=e.alternate;if(0===e.lanes&&(null===r||0===r.lanes)&&null!==(r=t.lastRenderedReducer))try{var i=t.lastRenderedState,o=r(i,l);if(a.hasEagerState=!0,a.eagerState=o,Zl(o,i))return Ln(e,t,a,0),null===fc&&zn(),!1}catch(s){}if(null!==(l=Mn(e,t,a,n)))return Xc(l,e,n),fo(l,t,n),!0}return!1}function mo(e,t,l,n){if(n={lane:2,revertLane:Wu(),gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},ho(e)){if(t)throw Error(r(479))}else null!==(t=Mn(e,l,n,2))&&Xc(t,e,2)}function ho(e){var t=e.alternate;return e===Wr||null!==t&&t===Wr}function po(e,t){Gr=Kr=!0;var l=e.pending;null===l?t.next=t:(t.next=l.next,l.next=t),e.pending=t}function fo(e,t,l){if(4194048&l){var n=t.lanes;l|=n&=e.pendingLanes,t.lanes=l,Pe(e,l)}}var go={readContext:Ma,use:bi,useCallback:ei,useContext:ei,useEffect:ei,useImperativeHandle:ei,useLayoutEffect:ei,useInsertionEffect:ei,useMemo:ei,useReducer:ei,useRef:ei,useState:ei,useDebugValue:ei,useDeferredValue:ei,useTransition:ei,useSyncExternalStore:ei,useId:ei,useHostTransitionStatus:ei,useFormState:ei,useActionState:ei,useOptimistic:ei,useMemoCache:ei,useCacheRefresh:ei};go.useEffectEvent=ei;var vo={readContext:Ma,use:bi,useCallback:function(e,t){return ci().memoizedState=[e,void 0===t?null:t],e},useContext:Ma,useEffect:Bi,useImperativeHandle:function(e,t,l){l=null!=l?l.concat([e]):null,Fi(4194308,4,Ki.bind(null,t,e),l)},useLayoutEffect:function(e,t){return Fi(4194308,4,e,t)},useInsertionEffect:function(e,t){Fi(4,2,e,t)},useMemo:function(e,t){var l=ci();t=void 0===t?null:t;var n=e();if(Qr){we(!0);try{e()}finally{we(!1)}}return l.memoizedState=[n,t],n},useReducer:function(e,t,l){var n=ci();if(void 0!==l){var a=l(t);if(Qr){we(!0);try{l(t)}finally{we(!1)}}}else a=t;return n.memoizedState=n.baseState=a,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:a},n.queue=e,e=e.dispatch=co.bind(null,Wr,e),[n.memoizedState,e]},useRef:function(e){return e={current:e},ci().memoizedState=e},useState:function(e){var t=(e=Si(e)).queue,l=uo.bind(null,Wr,t);return t.dispatch=l,[e.memoizedState,l]},useDebugValue:Qi,useDeferredValue:function(e,t){return Ji(ci(),e,t)},useTransition:function(){var e=Si(!1);return e=eo.bind(null,Wr,e.queue,!0,!1),ci().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,l){var n=Wr,a=ci();if(ma){if(void 0===l)throw Error(r(407));l=l()}else{if(l=t(),null===fc)throw Error(r(349));127&vc||yi(n,t,l)}a.memoizedState=l;var i={value:l,getSnapshot:t};return a.queue=i,Bi(wi.bind(null,n,i,e),[e]),n.flags|=2048,Ri(9,{destroy:void 0},xi.bind(null,n,i,l,t),null),l},useId:function(){var e=ci(),t=fc.identifierPrefix;if(ma){var l=ra;t="_"+t+"R_"+(l=(aa&~(1<<32-ke(aa)-1)).toString(32)+l),0<(l=Xr++)&&(t+="H"+l.toString(32)),t+="_"}else t="_"+t+"r_"+(l=Zr++).toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:ro,useFormState:Li,useActionState:Li,useOptimistic:function(e){var t=ci();t.memoizedState=t.baseState=e;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=l,t=mo.bind(null,Wr,!0,l),l.dispatch=t,[e,t]},useMemoCache:mi,useCacheRefresh:function(){return ci().memoizedState=so.bind(null,Wr)},useEffectEvent:function(e){var t=ci(),l={impl:e};return t.memoizedState=l,function(){if(2&pc)throw Error(r(440));return l.impl.apply(void 0,arguments)}}},yo={readContext:Ma,use:bi,useCallback:Xi,useContext:Ma,useEffect:qi,useImperativeHandle:Gi,useInsertionEffect:Vi,useLayoutEffect:Hi,useMemo:Yi,useReducer:pi,useRef:Oi,useState:function(){return pi(hi)},useDebugValue:Qi,useDeferredValue:function(e,t){return Zi(ui(),Vr.memoizedState,e,t)},useTransition:function(){var e=pi(hi)[0],t=ui().memoizedState;return["boolean"==typeof e?e:di(e),t]},useSyncExternalStore:vi,useId:io,useHostTransitionStatus:ro,useFormState:Mi,useActionState:Mi,useOptimistic:function(e,t){return ji(ui(),0,e,t)},useMemoCache:mi,useCacheRefresh:oo};yo.useEffectEvent=Wi;var xo={readContext:Ma,use:bi,useCallback:Xi,useContext:Ma,useEffect:qi,useImperativeHandle:Gi,useInsertionEffect:Vi,useLayoutEffect:Hi,useMemo:Yi,useReducer:gi,useRef:Oi,useState:function(){return gi(hi)},useDebugValue:Qi,useDeferredValue:function(e,t){var l=ui();return null===Vr?Ji(l,e,t):Zi(l,Vr.memoizedState,e,t)},useTransition:function(){var e=gi(hi)[0],t=ui().memoizedState;return["boolean"==typeof e?e:di(e),t]},useSyncExternalStore:vi,useId:io,useHostTransitionStatus:ro,useFormState:Di,useActionState:Di,useOptimistic:function(e,t){var l=ui();return null!==Vr?ji(l,0,e,t):(l.baseState=e,[e,l.queue.dispatch])},useMemoCache:mi,useCacheRefresh:oo};function wo(e,t,l,n){l=null==(l=l(n,t=e.memoizedState))?t:b({},t,l),e.memoizedState=l,0===e.lanes&&(e.updateQueue.baseState=l)}xo.useEffectEvent=Wi;var ko={enqueueSetState:function(e,t,l){e=e._reactInternals;var n=Gc(),a=xr(n);a.payload=t,null!=l&&(a.callback=l),null!==(t=wr(e,a,n))&&(Xc(t,e,n),kr(t,e,n))},enqueueReplaceState:function(e,t,l){e=e._reactInternals;var n=Gc(),a=xr(n);a.tag=1,a.payload=t,null!=l&&(a.callback=l),null!==(t=wr(e,a,n))&&(Xc(t,e,n),kr(t,e,n))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var l=Gc(),n=xr(l);n.tag=2,null!=t&&(n.callback=t),null!==(t=wr(e,n,l))&&(Xc(t,e,l),kr(t,e,l))}};function Co(e,t,l,n,a,r,i){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(n,r,i):!t.prototype||!t.prototype.isPureReactComponent||(!en(l,n)||!en(a,r))}function So(e,t,l,n){e=t.state,"function"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(l,n),"function"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(l,n),t.state!==e&&ko.enqueueReplaceState(t,t.state,null)}function jo(e,t){var l=t;if("ref"in t)for(var n in l={},t)"ref"!==n&&(l[n]=t[n]);if(e=e.defaultProps)for(var a in l===t&&(l=b({},l)),e)void 0===l[a]&&(l[a]=e[a]);return l}function No(e){$n(e)}function Eo(e){console.error(e)}function $o(e){$n(e)}function _o(e,t){try{(0,e.onUncaughtError)(t.value,{componentStack:t.stack})}catch(l){setTimeout(function(){throw l})}}function To(e,t,l){try{(0,e.onCaughtError)(l.value,{componentStack:l.stack,errorBoundary:1===t.tag?t.stateNode:null})}catch(n){setTimeout(function(){throw n})}}function Ao(e,t,l){return(l=xr(l)).tag=3,l.payload={element:null},l.callback=function(){_o(e,t)},l}function zo(e){return(e=xr(e)).tag=3,e}function Lo(e,t,l,n){var a=l.type.getDerivedStateFromError;if("function"==typeof a){var r=n.value;e.payload=function(){return a(r)},e.callback=function(){To(t,l,n)}}var i=l.stateNode;null!==i&&"function"==typeof i.componentDidCatch&&(e.callback=function(){To(t,l,n),"function"!=typeof a&&(null===Rc?Rc=new Set([this]):Rc.add(this));var e=n.stack;this.componentDidCatch(n.value,{componentStack:null!==e?e:""})})}var Mo=Error(r(461)),Io=!1;function Po(e,t,l,n){t.child=null===e?fr(t,null,l,n):pr(t,e.child,l,n)}function Do(e,t,l,n,a){l=l.render;var r=t.ref;if("ref"in n){var i={};for(var o in n)"ref"!==o&&(i[o]=n[o])}else i=n;return La(t),n=li(e,t,l,i,r,a),o=ii(),null===e||Io?(ma&&o&&sa(t),t.flags|=1,Po(e,t,n,a),t.child):(oi(e,t,a),is(e,t,a))}function Ro(e,t,l,n,a){if(null===e){var r=l.type;return"function"!=typeof r||Un(r)||void 0!==r.defaultProps||null!==l.compare?((e=Wn(l.type,null,n,t,t.mode,a)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=r,Oo(e,t,r,n,a))}if(r=e.child,!os(e,a)){var i=r.memoizedProps;if((l=null!==(l=l.compare)?l:en)(i,n)&&e.ref===t.ref)return is(e,t,a)}return t.flags|=1,(e=Bn(r,n)).ref=t.ref,e.return=t,t.child=e}function Oo(e,t,l,n,a){if(null!==e){var r=e.memoizedProps;if(en(r,n)&&e.ref===t.ref){if(Io=!1,t.pendingProps=n=r,!os(e,a))return t.lanes=e.lanes,is(e,t,a);131072&e.flags&&(Io=!0)}}return Ho(e,t,l,n,a)}function Fo(e,t,l,n){var a=n.children,r=null!==e?e.memoizedState:null;if(null===e&&null===t.stateNode&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),"hidden"===n.mode){if(128&t.flags){if(r=null!==r?r.baseLanes|l:l,null!==e){for(n=t.child=e.child,a=0;null!==n;)a=a|n.lanes|n.childLanes,n=n.sibling;n=a&~r}else n=0,t.child=null;return Bo(e,t,r,l,n)}if(!(536870912&l))return n=t.lanes=536870912,Bo(e,t,null!==r?r.baseLanes|l:l,l,n);t.memoizedState={baseLanes:0,cachePool:null},null!==e&&Ya(0,null!==r?r.cachePool:null),null!==r?Ar(t,r):zr(),Rr(t)}else null!==r?(Ya(0,r.cachePool),Ar(t,r),Or(),t.memoizedState=null):(null!==e&&Ya(0,null),zr(),Or());return Po(e,t,a,l),t.child}function Uo(e,t){return null!==e&&22===e.tag||null!==t.stateNode||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Bo(e,t,l,n,a){var r=Xa();return r=null===r?null:{parent:Fa._currentValue,pool:r},t.memoizedState={baseLanes:l,cachePool:r},null!==e&&Ya(0,null),zr(),Rr(t),null!==e&&Aa(e,t,n,!0),t.childLanes=a,null}function qo(e,t){return(t=ts({mode:t.mode,children:t.children},e.mode)).ref=e.ref,e.child=t,t.return=e,t}function Wo(e,t,l){return pr(t,e.child,null,l),(e=qo(t,t.pendingProps)).flags|=2,Fr(t),t.memoizedState=null,e}function Vo(e,t){var l=t.ref;if(null===l)null!==e&&null!==e.ref&&(t.flags|=4194816);else{if("function"!=typeof l&&"object"!=typeof l)throw Error(r(284));null!==e&&e.ref===l||(t.flags|=4194816)}}function Ho(e,t,l,n,a){return La(t),l=li(e,t,l,n,void 0,a),n=ii(),null===e||Io?(ma&&n&&sa(t),t.flags|=1,Po(e,t,l,a),t.child):(oi(e,t,a),is(e,t,a))}function Ko(e,t,l,n,a,r){return La(t),t.updateQueue=null,l=ai(t,n,l,a),ni(e),n=ii(),null===e||Io?(ma&&n&&sa(t),t.flags|=1,Po(e,t,l,r),t.child):(oi(e,t,r),is(e,t,r))}function Go(e,t,l,n,a){if(La(t),null===t.stateNode){var r=Rn,i=l.contextType;"object"==typeof i&&null!==i&&(r=Ma(i)),r=new l(n,r),t.memoizedState=null!==r.state&&void 0!==r.state?r.state:null,r.updater=ko,t.stateNode=r,r._reactInternals=t,(r=t.stateNode).props=n,r.state=t.memoizedState,r.refs={},vr(t),i=l.contextType,r.context="object"==typeof i&&null!==i?Ma(i):Rn,r.state=t.memoizedState,"function"==typeof(i=l.getDerivedStateFromProps)&&(wo(t,l,i,n),r.state=t.memoizedState),"function"==typeof l.getDerivedStateFromProps||"function"==typeof r.getSnapshotBeforeUpdate||"function"!=typeof r.UNSAFE_componentWillMount&&"function"!=typeof r.componentWillMount||(i=r.state,"function"==typeof r.componentWillMount&&r.componentWillMount(),"function"==typeof r.UNSAFE_componentWillMount&&r.UNSAFE_componentWillMount(),i!==r.state&&ko.enqueueReplaceState(r,r.state,null),Nr(t,n,r,a),jr(),r.state=t.memoizedState),"function"==typeof r.componentDidMount&&(t.flags|=4194308),n=!0}else if(null===e){r=t.stateNode;var o=t.memoizedProps,s=jo(l,o);r.props=s;var c=r.context,u=l.contextType;i=Rn,"object"==typeof u&&null!==u&&(i=Ma(u));var d=l.getDerivedStateFromProps;u="function"==typeof d||"function"==typeof r.getSnapshotBeforeUpdate,o=t.pendingProps!==o,u||"function"!=typeof r.UNSAFE_componentWillReceiveProps&&"function"!=typeof r.componentWillReceiveProps||(o||c!==i)&&So(t,r,n,i),gr=!1;var b=t.memoizedState;r.state=b,Nr(t,n,r,a),jr(),c=t.memoizedState,o||b!==c||gr?("function"==typeof d&&(wo(t,l,d,n),c=t.memoizedState),(s=gr||Co(t,l,s,n,b,c,i))?(u||"function"!=typeof r.UNSAFE_componentWillMount&&"function"!=typeof r.componentWillMount||("function"==typeof r.componentWillMount&&r.componentWillMount(),"function"==typeof r.UNSAFE_componentWillMount&&r.UNSAFE_componentWillMount()),"function"==typeof r.componentDidMount&&(t.flags|=4194308)):("function"==typeof r.componentDidMount&&(t.flags|=4194308),t.memoizedProps=n,t.memoizedState=c),r.props=n,r.state=c,r.context=i,n=s):("function"==typeof r.componentDidMount&&(t.flags|=4194308),n=!1)}else{r=t.stateNode,yr(e,t),u=jo(l,i=t.memoizedProps),r.props=u,d=t.pendingProps,b=r.context,c=l.contextType,s=Rn,"object"==typeof c&&null!==c&&(s=Ma(c)),(c="function"==typeof(o=l.getDerivedStateFromProps)||"function"==typeof r.getSnapshotBeforeUpdate)||"function"!=typeof r.UNSAFE_componentWillReceiveProps&&"function"!=typeof r.componentWillReceiveProps||(i!==d||b!==s)&&So(t,r,n,s),gr=!1,b=t.memoizedState,r.state=b,Nr(t,n,r,a),jr();var m=t.memoizedState;i!==d||b!==m||gr||null!==e&&null!==e.dependencies&&za(e.dependencies)?("function"==typeof o&&(wo(t,l,o,n),m=t.memoizedState),(u=gr||Co(t,l,u,n,b,m,s)||null!==e&&null!==e.dependencies&&za(e.dependencies))?(c||"function"!=typeof r.UNSAFE_componentWillUpdate&&"function"!=typeof r.componentWillUpdate||("function"==typeof r.componentWillUpdate&&r.componentWillUpdate(n,m,s),"function"==typeof r.UNSAFE_componentWillUpdate&&r.UNSAFE_componentWillUpdate(n,m,s)),"function"==typeof r.componentDidUpdate&&(t.flags|=4),"function"==typeof r.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!=typeof r.componentDidUpdate||i===e.memoizedProps&&b===e.memoizedState||(t.flags|=4),"function"!=typeof r.getSnapshotBeforeUpdate||i===e.memoizedProps&&b===e.memoizedState||(t.flags|=1024),t.memoizedProps=n,t.memoizedState=m),r.props=n,r.state=m,r.context=s,n=u):("function"!=typeof r.componentDidUpdate||i===e.memoizedProps&&b===e.memoizedState||(t.flags|=4),"function"!=typeof r.getSnapshotBeforeUpdate||i===e.memoizedProps&&b===e.memoizedState||(t.flags|=1024),n=!1)}return r=n,Vo(e,t),n=!!(128&t.flags),r||n?(r=t.stateNode,l=n&&"function"!=typeof l.getDerivedStateFromError?null:r.render(),t.flags|=1,null!==e&&n?(t.child=pr(t,e.child,null,a),t.child=pr(t,null,l,a)):Po(e,t,l,a),t.memoizedState=r.state,e=t.child):e=is(e,t,a),e}function Qo(e,t,l,n){return wa(),t.flags|=256,Po(e,t,l,n),t.child}var Xo={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Yo(e){return{baseLanes:e,cachePool:Ja()}}function Jo(e,t,l){return e=null!==e?e.childLanes&~l:0,t&&(e|=_c),e}function Zo(e,t,l){var n,a=t.pendingProps,i=!1,o=!!(128&t.flags);if((n=o)||(n=(null===e||null!==e.memoizedState)&&!!(2&Ur.current)),n&&(i=!0,t.flags&=-129),n=!!(32&t.flags),t.flags&=-33,null===e){if(ma){if(i?Pr(t):Or(),(e=ba)?null!==(e=null!==(e=zd(e,pa))&&"&"!==e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==na?{id:aa,overflow:ra}:null,retryLane:536870912,hydrationErrors:null},(l=Kn(e)).return=t,t.child=l,da=t,ba=null):e=null,null===e)throw ga(t);return Md(e)?t.lanes=32:t.lanes=536870912,null}var s=a.children;return a=a.fallback,i?(Or(),s=ts({mode:"hidden",children:s},i=t.mode),a=Vn(a,i,l,null),s.return=t,a.return=t,s.sibling=a,t.child=s,(a=t.child).memoizedState=Yo(l),a.childLanes=Jo(e,n,l),t.memoizedState=Xo,Uo(null,a)):(Pr(t),es(t,s))}var c=e.memoizedState;if(null!==c&&null!==(s=c.dehydrated)){if(o)256&t.flags?(Pr(t),t.flags&=-257,t=ls(e,t,l)):null!==t.memoizedState?(Or(),t.child=e.child,t.flags|=128,t=null):(Or(),s=a.fallback,i=t.mode,a=ts({mode:"visible",children:a.children},i),(s=Vn(s,i,l,null)).flags|=2,a.return=t,s.return=t,a.sibling=s,t.child=a,pr(t,e.child,null,l),(a=t.child).memoizedState=Yo(l),a.childLanes=Jo(e,n,l),t.memoizedState=Xo,t=Uo(null,a));else if(Pr(t),Md(s)){if(n=s.nextSibling&&s.nextSibling.dataset)var u=n.dgst;n=u,(a=Error(r(419))).stack="",a.digest=n,Ca({value:a,source:null,stack:null}),t=ls(e,t,l)}else if(Io||Aa(e,t,l,!1),n=0!==(l&e.childLanes),Io||n){if(null!==(n=fc)&&(0!==(a=De(n,l))&&a!==c.retryLane))throw c.retryLane=a,In(e,a),Xc(n,e,a),Mo;Ld(s)||su(),t=ls(e,t,l)}else Ld(s)?(t.flags|=192,t.child=e.child,t=null):(e=c.treeContext,ba=Id(s.nextSibling),da=t,ma=!0,ha=null,pa=!1,null!==e&&ua(t,e),(t=es(t,a.children)).flags|=4096);return t}return i?(Or(),s=a.fallback,i=t.mode,u=(c=e.child).sibling,(a=Bn(c,{mode:"hidden",children:a.children})).subtreeFlags=65011712&c.subtreeFlags,null!==u?s=Bn(u,s):(s=Vn(s,i,l,null)).flags|=2,s.return=t,a.return=t,a.sibling=s,t.child=a,Uo(null,a),a=t.child,null===(s=e.child.memoizedState)?s=Yo(l):(null!==(i=s.cachePool)?(c=Fa._currentValue,i=i.parent!==c?{parent:c,pool:c}:i):i=Ja(),s={baseLanes:s.baseLanes|l,cachePool:i}),a.memoizedState=s,a.childLanes=Jo(e,n,l),t.memoizedState=Xo,Uo(e.child,a)):(Pr(t),e=(l=e.child).sibling,(l=Bn(l,{mode:"visible",children:a.children})).return=t,l.sibling=null,null!==e&&(null===(n=t.deletions)?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=l,t.memoizedState=null,l)}function es(e,t){return(t=ts({mode:"visible",children:t},e.mode)).return=e,e.child=t}function ts(e,t){return(e=Fn(22,e,null,t)).lanes=0,e}function ls(e,t,l){return pr(t,e.child,null,l),(e=es(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function ns(e,t,l){e.lanes|=t;var n=e.alternate;null!==n&&(n.lanes|=t),_a(e.return,t,l)}function as(e,t,l,n,a,r){var i=e.memoizedState;null===i?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:n,tail:l,tailMode:a,treeForkCount:r}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=n,i.tail=l,i.tailMode=a,i.treeForkCount=r)}function rs(e,t,l){var n=t.pendingProps,a=n.revealOrder,r=n.tail;n=n.children;var i=Ur.current,o=!!(2&i);if(o?(i=1&i|2,t.flags|=128):i&=1,q(Ur,i),Po(e,t,n,l),n=ma?ea:0,!o&&null!==e&&128&e.flags)e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&ns(e,l,t);else if(19===e.tag)ns(e,l,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(a){case"forwards":for(l=t.child,a=null;null!==l;)null!==(e=l.alternate)&&null===Br(e)&&(a=l),l=l.sibling;null===(l=a)?(a=t.child,t.child=null):(a=l.sibling,l.sibling=null),as(t,!1,a,l,r,n);break;case"backwards":case"unstable_legacy-backwards":for(l=null,a=t.child,t.child=null;null!==a;){if(null!==(e=a.alternate)&&null===Br(e)){t.child=a;break}e=a.sibling,a.sibling=l,l=a,a=e}as(t,!0,l,null,r,n);break;case"together":as(t,!1,null,null,void 0,n);break;default:t.memoizedState=null}return t.child}function is(e,t,l){if(null!==e&&(t.dependencies=e.dependencies),Nc|=t.lanes,0===(l&t.childLanes)){if(null===e)return null;if(Aa(e,t,l,!1),0===(l&t.childLanes))return null}if(null!==e&&t.child!==e.child)throw Error(r(153));if(null!==t.child){for(l=Bn(e=t.child,e.pendingProps),t.child=l,l.return=t;null!==e.sibling;)e=e.sibling,(l=l.sibling=Bn(e,e.pendingProps)).return=t;l.sibling=null}return t.child}function os(e,t){return 0!==(e.lanes&t)||!(null===(e=e.dependencies)||!za(e))}function ss(e,t,l){if(null!==e)if(e.memoizedProps!==t.pendingProps)Io=!0;else{if(!(os(e,l)||128&t.flags))return Io=!1,function(e,t,l){switch(t.tag){case 3:X(t,t.stateNode.containerInfo),Ea(0,Fa,e.memoizedState.cache),wa();break;case 27:case 5:J(t);break;case 4:X(t,t.stateNode.containerInfo);break;case 10:Ea(0,t.type,t.memoizedProps.value);break;case 31:if(null!==t.memoizedState)return t.flags|=128,Dr(t),null;break;case 13:var n=t.memoizedState;if(null!==n)return null!==n.dehydrated?(Pr(t),t.flags|=128,null):0!==(l&t.child.childLanes)?Zo(e,t,l):(Pr(t),null!==(e=is(e,t,l))?e.sibling:null);Pr(t);break;case 19:var a=!!(128&e.flags);if((n=0!==(l&t.childLanes))||(Aa(e,t,l,!1),n=0!==(l&t.childLanes)),a){if(n)return rs(e,t,l);t.flags|=128}if(null!==(a=t.memoizedState)&&(a.rendering=null,a.tail=null,a.lastEffect=null),q(Ur,Ur.current),n)break;return null;case 22:return t.lanes=0,Fo(e,t,l,t.pendingProps);case 24:Ea(0,Fa,e.memoizedState.cache)}return is(e,t,l)}(e,t,l);Io=!!(131072&e.flags)}else Io=!1,ma&&1048576&t.flags&&oa(t,ea,t.index);switch(t.lanes=0,t.tag){case 16:e:{var n=t.pendingProps;if(e=rr(t.elementType),t.type=e,"function"!=typeof e){if(null!=e){var a=e.$$typeof;if(a===C){t.tag=11,t=Do(null,t,e,n,l);break e}if(a===E){t.tag=14,t=Ro(null,t,e,n,l);break e}}throw t=M(e)||e,Error(r(306,t,""))}Un(e)?(n=jo(e,n),t.tag=1,t=Go(null,t,e,n,l)):(t.tag=0,t=Ho(null,t,e,n,l))}return t;case 0:return Ho(e,t,t.type,t.pendingProps,l);case 1:return Go(e,t,n=t.type,a=jo(n,t.pendingProps),l);case 3:e:{if(X(t,t.stateNode.containerInfo),null===e)throw Error(r(387));n=t.pendingProps;var i=t.memoizedState;a=i.element,yr(e,t),Nr(t,n,null,l);var o=t.memoizedState;if(n=o.cache,Ea(0,Fa,n),n!==i.cache&&Ta(t,[Fa],l,!0),jr(),n=o.element,i.isDehydrated){if(i={element:n,isDehydrated:!1,cache:o.cache},t.updateQueue.baseState=i,t.memoizedState=i,256&t.flags){t=Qo(e,t,n,l);break e}if(n!==a){Ca(a=Xn(Error(r(424)),t)),t=Qo(e,t,n,l);break e}if(9===(e=t.stateNode.containerInfo).nodeType)e=e.body;else e="HTML"===e.nodeName?e.ownerDocument.body:e;for(ba=Id(e.firstChild),da=t,ma=!0,ha=null,pa=!0,l=fr(t,null,n,l),t.child=l;l;)l.flags=-3&l.flags|4096,l=l.sibling}else{if(wa(),n===a){t=is(e,t,l);break e}Po(e,t,n,l)}t=t.child}return t;case 26:return Vo(e,t),null===e?(l=Kd(t.type,null,t.pendingProps,null))?t.memoizedState=l:ma||(l=t.type,e=t.pendingProps,(n=vd(G.current).createElement(l))[qe]=t,n[We]=e,hd(n,l,e),lt(n),t.stateNode=n):t.memoizedState=Kd(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return J(t),null===e&&ma&&(n=t.stateNode=Od(t.type,t.pendingProps,G.current),da=t,pa=!0,a=ba,$d(t.type)?(Pd=a,ba=Id(n.firstChild)):ba=a),Po(e,t,t.pendingProps.children,l),Vo(e,t),null===e&&(t.flags|=4194304),t.child;case 5:return null===e&&ma&&((a=n=ba)&&(null!==(n=function(e,t,l,n){for(;1===e.nodeType;){var a=l;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!n&&("INPUT"!==e.nodeName||"hidden"!==e.type))break}else if(n){if(!e[Xe])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if("stylesheet"===(r=e.getAttribute("rel"))&&e.hasAttribute("data-precedence"))break;if(r!==a.rel||e.getAttribute("href")!==(null==a.href||""===a.href?null:a.href)||e.getAttribute("crossorigin")!==(null==a.crossOrigin?null:a.crossOrigin)||e.getAttribute("title")!==(null==a.title?null:a.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(((r=e.getAttribute("src"))!==(null==a.src?null:a.src)||e.getAttribute("type")!==(null==a.type?null:a.type)||e.getAttribute("crossorigin")!==(null==a.crossOrigin?null:a.crossOrigin))&&r&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else{if("input"!==t||"hidden"!==e.type)return e;var r=null==a.name?null:""+a.name;if("hidden"===a.type&&e.getAttribute("name")===r)return e}if(null===(e=Id(e.nextSibling)))break}return null}(n,t.type,t.pendingProps,pa))?(t.stateNode=n,da=t,ba=Id(n.firstChild),pa=!1,a=!0):a=!1),a||ga(t)),J(t),a=t.type,i=t.pendingProps,o=null!==e?e.memoizedProps:null,n=i.children,wd(a,i)?n=null:null!==o&&wd(a,o)&&(t.flags|=32),null!==t.memoizedState&&(a=li(e,t,ri,null,null,l),bb._currentValue=a),Vo(e,t),Po(e,t,n,l),t.child;case 6:return null===e&&ma&&((e=l=ba)&&(null!==(l=function(e,t,l){if(""===t)return null;for(;3!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!l)return null;if(null===(e=Id(e.nextSibling)))return null}return e}(l,t.pendingProps,pa))?(t.stateNode=l,da=t,ba=null,e=!0):e=!1),e||ga(t)),null;case 13:return Zo(e,t,l);case 4:return X(t,t.stateNode.containerInfo),n=t.pendingProps,null===e?t.child=pr(t,null,n,l):Po(e,t,n,l),t.child;case 11:return Do(e,t,t.type,t.pendingProps,l);case 7:return Po(e,t,t.pendingProps,l),t.child;case 8:case 12:return Po(e,t,t.pendingProps.children,l),t.child;case 10:return n=t.pendingProps,Ea(0,t.type,n.value),Po(e,t,n.children,l),t.child;case 9:return a=t.type._context,n=t.pendingProps.children,La(t),n=n(a=Ma(a)),t.flags|=1,Po(e,t,n,l),t.child;case 14:return Ro(e,t,t.type,t.pendingProps,l);case 15:return Oo(e,t,t.type,t.pendingProps,l);case 19:return rs(e,t,l);case 31:return function(e,t,l){var n=t.pendingProps,a=!!(128&t.flags);if(t.flags&=-129,null===e){if(ma){if("hidden"===n.mode)return e=qo(t,n),t.lanes=536870912,Uo(null,e);if(Dr(t),(e=ba)?null!==(e=null!==(e=zd(e,pa))&&"&"===e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==na?{id:aa,overflow:ra}:null,retryLane:536870912,hydrationErrors:null},(l=Kn(e)).return=t,t.child=l,da=t,ba=null):e=null,null===e)throw ga(t);return t.lanes=536870912,null}return qo(t,n)}var i=e.memoizedState;if(null!==i){var o=i.dehydrated;if(Dr(t),a)if(256&t.flags)t.flags&=-257,t=Wo(e,t,l);else{if(null===t.memoizedState)throw Error(r(558));t.child=e.child,t.flags|=128,t=null}else if(Io||Aa(e,t,l,!1),a=0!==(l&e.childLanes),Io||a){if(null!==(n=fc)&&0!==(o=De(n,l))&&o!==i.retryLane)throw i.retryLane=o,In(e,o),Xc(n,e,o),Mo;su(),t=Wo(e,t,l)}else e=i.treeContext,ba=Id(o.nextSibling),da=t,ma=!0,ha=null,pa=!1,null!==e&&ua(t,e),(t=qo(t,n)).flags|=4096;return t}return(e=Bn(e.child,{mode:n.mode,children:n.children})).ref=t.ref,t.child=e,e.return=t,e}(e,t,l);case 22:return Fo(e,t,l,t.pendingProps);case 24:return La(t),n=Ma(Fa),null===e?(null===(a=Xa())&&(a=fc,i=Ua(),a.pooledCache=i,i.refCount++,null!==i&&(a.pooledCacheLanes|=l),a=i),t.memoizedState={parent:n,cache:a},vr(t),Ea(0,Fa,a)):(0!==(e.lanes&l)&&(yr(e,t),Nr(t,null,null,l),jr()),a=e.memoizedState,i=t.memoizedState,a.parent!==n?(a={parent:n,cache:n},t.memoizedState=a,0===t.lanes&&(t.memoizedState=t.updateQueue.baseState=a),Ea(0,Fa,n)):(n=i.cache,Ea(0,Fa,n),n!==a.cache&&Ta(t,[Fa],l,!0))),Po(e,t,t.pendingProps.children,l),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function cs(e){e.flags|=4}function us(e,t,l,n,a){if((t=!!(32&e.mode))&&(t=!1),t){if(e.flags|=16777216,(335544128&a)===a)if(e.stateNode.complete)e.flags|=8192;else{if(!ru())throw ir=lr,er;e.flags|=8192}}else e.flags&=-16777217}function ds(e,t){if("stylesheet"!==t.type||4&t.state.loading)e.flags&=-16777217;else if(e.flags|=16777216,!ib(t)){if(!ru())throw ir=lr,er;e.flags|=8192}}function bs(e,t){null!==t&&(e.flags|=4),16384&e.flags&&(t=22!==e.tag?ze():536870912,e.lanes|=t,Tc|=t)}function ms(e,t){if(!ma)switch(e.tailMode){case"hidden":t=e.tail;for(var l=null;null!==t;)null!==t.alternate&&(l=t),t=t.sibling;null===l?e.tail=null:l.sibling=null;break;case"collapsed":l=e.tail;for(var n=null;null!==l;)null!==l.alternate&&(n=l),l=l.sibling;null===n?t||null===e.tail?e.tail=null:e.tail.sibling=null:n.sibling=null}}function hs(e){var t=null!==e.alternate&&e.alternate.child===e.child,l=0,n=0;if(t)for(var a=e.child;null!==a;)l|=a.lanes|a.childLanes,n|=65011712&a.subtreeFlags,n|=65011712&a.flags,a.return=e,a=a.sibling;else for(a=e.child;null!==a;)l|=a.lanes|a.childLanes,n|=a.subtreeFlags,n|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=n,e.childLanes=l,t}function ps(e,t,l){var n=t.pendingProps;switch(ca(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 1:return hs(t),null;case 3:return l=t.stateNode,n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),$a(Fa),Y(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),null!==e&&null!==e.child||(xa(t)?cs(t):null===e||e.memoizedState.isDehydrated&&!(256&t.flags)||(t.flags|=1024,ka())),hs(t),null;case 26:var a=t.type,i=t.memoizedState;return null===e?(cs(t),null!==i?(hs(t),ds(t,i)):(hs(t),us(t,a,0,0,l))):i?i!==e.memoizedState?(cs(t),hs(t),ds(t,i)):(hs(t),t.flags&=-16777217):((e=e.memoizedProps)!==n&&cs(t),hs(t),us(t,a,0,0,l)),null;case 27:if(Z(t),l=G.current,a=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==n&&cs(t);else{if(!n){if(null===t.stateNode)throw Error(r(166));return hs(t),null}e=H.current,xa(t)?va(t):(e=Od(a,n,l),t.stateNode=e,cs(t))}return hs(t),null;case 5:if(Z(t),a=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==n&&cs(t);else{if(!n){if(null===t.stateNode)throw Error(r(166));return hs(t),null}if(i=H.current,xa(t))va(t);else{var o=vd(G.current);switch(i){case 1:i=o.createElementNS("http://www.w3.org/2000/svg",a);break;case 2:i=o.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;default:switch(a){case"svg":i=o.createElementNS("http://www.w3.org/2000/svg",a);break;case"math":i=o.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;case"script":(i=o.createElement("div")).innerHTML="<script><\/script>",i=i.removeChild(i.firstChild);break;case"select":i="string"==typeof n.is?o.createElement("select",{is:n.is}):o.createElement("select"),n.multiple?i.multiple=!0:n.size&&(i.size=n.size);break;default:i="string"==typeof n.is?o.createElement(a,{is:n.is}):o.createElement(a)}}i[qe]=t,i[We]=n;e:for(o=t.child;null!==o;){if(5===o.tag||6===o.tag)i.appendChild(o.stateNode);else if(4!==o.tag&&27!==o.tag&&null!==o.child){o.child.return=o,o=o.child;continue}if(o===t)break e;for(;null===o.sibling;){if(null===o.return||o.return===t)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}t.stateNode=i;e:switch(hd(i,a,n),a){case"button":case"input":case"select":case"textarea":n=!!n.autoFocus;break e;case"img":n=!0;break e;default:n=!1}n&&cs(t)}}return hs(t),us(t,t.type,null===e||e.memoizedProps,t.pendingProps,l),null;case 6:if(e&&null!=t.stateNode)e.memoizedProps!==n&&cs(t);else{if("string"!=typeof n&&null===t.stateNode)throw Error(r(166));if(e=G.current,xa(t)){if(e=t.stateNode,l=t.memoizedProps,n=null,null!==(a=da))switch(a.tag){case 27:case 5:n=a.memoizedProps}e[qe]=t,(e=!!(e.nodeValue===l||null!==n&&!0===n.suppressHydrationWarning||dd(e.nodeValue,l)))||ga(t,!0)}else(e=vd(e).createTextNode(n))[qe]=t,t.stateNode=e}return hs(t),null;case 31:if(l=t.memoizedState,null===e||null!==e.memoizedState){if(n=xa(t),null!==l){if(null===e){if(!n)throw Error(r(318));if(!(e=null!==(e=t.memoizedState)?e.dehydrated:null))throw Error(r(557));e[qe]=t}else wa(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;hs(t),e=!1}else l=ka(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return 256&t.flags?(Fr(t),t):(Fr(t),null);if(128&t.flags)throw Error(r(558))}return hs(t),null;case 13:if(n=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(a=xa(t),null!==n&&null!==n.dehydrated){if(null===e){if(!a)throw Error(r(318));if(!(a=null!==(a=t.memoizedState)?a.dehydrated:null))throw Error(r(317));a[qe]=t}else wa(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;hs(t),a=!1}else a=ka(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return 256&t.flags?(Fr(t),t):(Fr(t),null)}return Fr(t),128&t.flags?(t.lanes=l,t):(l=null!==n,e=null!==e&&null!==e.memoizedState,l&&(a=null,null!==(n=t.child).alternate&&null!==n.alternate.memoizedState&&null!==n.alternate.memoizedState.cachePool&&(a=n.alternate.memoizedState.cachePool.pool),i=null,null!==n.memoizedState&&null!==n.memoizedState.cachePool&&(i=n.memoizedState.cachePool.pool),i!==a&&(n.flags|=2048)),l!==e&&l&&(t.child.flags|=8192),bs(t,t.updateQueue),hs(t),null);case 4:return Y(),null===e&&td(t.stateNode.containerInfo),hs(t),null;case 10:return $a(t.type),hs(t),null;case 19:if(B(Ur),null===(n=t.memoizedState))return hs(t),null;if(a=!!(128&t.flags),null===(i=n.rendering))if(a)ms(n,!1);else{if(0!==jc||null!==e&&128&e.flags)for(e=t.child;null!==e;){if(null!==(i=Br(e))){for(t.flags|=128,ms(n,!1),e=i.updateQueue,t.updateQueue=e,bs(t,e),t.subtreeFlags=0,e=l,l=t.child;null!==l;)qn(l,e),l=l.sibling;return q(Ur,1&Ur.current|2),ma&&ia(t,n.treeForkCount),t.child}e=e.sibling}null!==n.tail&&ue()>Pc&&(t.flags|=128,a=!0,ms(n,!1),t.lanes=4194304)}else{if(!a)if(null!==(e=Br(i))){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,bs(t,e),ms(n,!0),null===n.tail&&"hidden"===n.tailMode&&!i.alternate&&!ma)return hs(t),null}else 2*ue()-n.renderingStartTime>Pc&&536870912!==l&&(t.flags|=128,a=!0,ms(n,!1),t.lanes=4194304);n.isBackwards?(i.sibling=t.child,t.child=i):(null!==(e=n.last)?e.sibling=i:t.child=i,n.last=i)}return null!==n.tail?(e=n.tail,n.rendering=e,n.tail=e.sibling,n.renderingStartTime=ue(),e.sibling=null,l=Ur.current,q(Ur,a?1&l|2:1&l),ma&&ia(t,n.treeForkCount),e):(hs(t),null);case 22:case 23:return Fr(t),Lr(),n=null!==t.memoizedState,null!==e?null!==e.memoizedState!==n&&(t.flags|=8192):n&&(t.flags|=8192),n?!!(536870912&l)&&!(128&t.flags)&&(hs(t),6&t.subtreeFlags&&(t.flags|=8192)):hs(t),null!==(l=t.updateQueue)&&bs(t,l.retryQueue),l=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(l=e.memoizedState.cachePool.pool),n=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(n=t.memoizedState.cachePool.pool),n!==l&&(t.flags|=2048),null!==e&&B(Qa),null;case 24:return l=null,null!==e&&(l=e.memoizedState.cache),t.memoizedState.cache!==l&&(t.flags|=2048),$a(Fa),hs(t),null;case 25:case 30:return null}throw Error(r(156,t.tag))}function fs(e,t){switch(ca(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return $a(Fa),Y(),65536&(e=t.flags)&&!(128&e)?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return Z(t),null;case 31:if(null!==t.memoizedState){if(Fr(t),null===t.alternate)throw Error(r(340));wa()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 13:if(Fr(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(r(340));wa()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return B(Ur),null;case 4:return Y(),null;case 10:return $a(t.type),null;case 22:case 23:return Fr(t),Lr(),null!==e&&B(Qa),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return $a(Fa),null;default:return null}}function gs(e,t){switch(ca(t),t.tag){case 3:$a(Fa),Y();break;case 26:case 27:case 5:Z(t);break;case 4:Y();break;case 31:null!==t.memoizedState&&Fr(t);break;case 13:Fr(t);break;case 19:B(Ur);break;case 10:$a(t.type);break;case 22:case 23:Fr(t),Lr(),null!==e&&B(Qa);break;case 24:$a(Fa)}}function vs(e,t){try{var l=t.updateQueue,n=null!==l?l.lastEffect:null;if(null!==n){var a=n.next;l=a;do{if((l.tag&e)===e){n=void 0;var r=l.create,i=l.inst;n=r(),i.destroy=n}l=l.next}while(l!==a)}}catch(o){ju(t,t.return,o)}}function ys(e,t,l){try{var n=t.updateQueue,a=null!==n?n.lastEffect:null;if(null!==a){var r=a.next;n=r;do{if((n.tag&e)===e){var i=n.inst,o=i.destroy;if(void 0!==o){i.destroy=void 0,a=t;var s=l,c=o;try{c()}catch(u){ju(a,s,u)}}}n=n.next}while(n!==r)}}catch(u){ju(t,t.return,u)}}function xs(e){var t=e.updateQueue;if(null!==t){var l=e.stateNode;try{$r(t,l)}catch(n){ju(e,e.return,n)}}}function ws(e,t,l){l.props=jo(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(n){ju(e,t,n)}}function ks(e,t){try{var l=e.ref;if(null!==l){switch(e.tag){case 26:case 27:case 5:var n=e.stateNode;break;default:n=e.stateNode}"function"==typeof l?e.refCleanup=l(n):l.current=n}}catch(a){ju(e,t,a)}}function Cs(e,t){var l=e.ref,n=e.refCleanup;if(null!==l)if("function"==typeof n)try{n()}catch(a){ju(e,t,a)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof l)try{l(null)}catch(r){ju(e,t,r)}else l.current=null}function Ss(e){var t=e.type,l=e.memoizedProps,n=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":l.autoFocus&&n.focus();break e;case"img":l.src?n.src=l.src:l.srcSet&&(n.srcset=l.srcSet)}}catch(a){ju(e,e.return,a)}}function js(e,t,l){try{var n=e.stateNode;!function(e,t,l,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var a=null,i=null,o=null,s=null,c=null,u=null,d=null;for(h in l){var b=l[h];if(l.hasOwnProperty(h)&&null!=b)switch(h){case"checked":case"value":break;case"defaultValue":c=b;default:n.hasOwnProperty(h)||bd(e,t,h,null,n,b)}}for(var m in n){var h=n[m];if(b=l[m],n.hasOwnProperty(m)&&(null!=h||null!=b))switch(m){case"type":i=h;break;case"name":a=h;break;case"checked":u=h;break;case"defaultChecked":d=h;break;case"value":o=h;break;case"defaultValue":s=h;break;case"children":case"dangerouslySetInnerHTML":if(null!=h)throw Error(r(137,t));break;default:h!==b&&bd(e,t,m,h,n,b)}}return void xt(e,o,s,c,u,d,i,a);case"select":for(i in h=o=s=m=null,l)if(c=l[i],l.hasOwnProperty(i)&&null!=c)switch(i){case"value":break;case"multiple":h=c;default:n.hasOwnProperty(i)||bd(e,t,i,null,n,c)}for(a in n)if(i=n[a],c=l[a],n.hasOwnProperty(a)&&(null!=i||null!=c))switch(a){case"value":m=i;break;case"defaultValue":s=i;break;case"multiple":o=i;default:i!==c&&bd(e,t,a,i,n,c)}return t=s,l=o,n=h,void(null!=m?Ct(e,!!l,m,!1):!!n!=!!l&&(null!=t?Ct(e,!!l,t,!0):Ct(e,!!l,l?[]:"",!1)));case"textarea":for(s in h=m=null,l)if(a=l[s],l.hasOwnProperty(s)&&null!=a&&!n.hasOwnProperty(s))switch(s){case"value":case"children":break;default:bd(e,t,s,null,n,a)}for(o in n)if(a=n[o],i=l[o],n.hasOwnProperty(o)&&(null!=a||null!=i))switch(o){case"value":m=a;break;case"defaultValue":h=a;break;case"children":break;case"dangerouslySetInnerHTML":if(null!=a)throw Error(r(91));break;default:a!==i&&bd(e,t,o,a,n,i)}return void St(e,m,h);case"option":for(var p in l)if(m=l[p],l.hasOwnProperty(p)&&null!=m&&!n.hasOwnProperty(p))if("selected"===p)e.selected=!1;else bd(e,t,p,null,n,m);for(c in n)if(m=n[c],h=l[c],n.hasOwnProperty(c)&&m!==h&&(null!=m||null!=h))if("selected"===c)e.selected=m&&"function"!=typeof m&&"symbol"!=typeof m;else bd(e,t,c,m,n,h);return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var f in l)m=l[f],l.hasOwnProperty(f)&&null!=m&&!n.hasOwnProperty(f)&&bd(e,t,f,null,n,m);for(u in n)if(m=n[u],h=l[u],n.hasOwnProperty(u)&&m!==h&&(null!=m||null!=h))switch(u){case"children":case"dangerouslySetInnerHTML":if(null!=m)throw Error(r(137,t));break;default:bd(e,t,u,m,n,h)}return;default:if(Tt(t)){for(var g in l)m=l[g],l.hasOwnProperty(g)&&void 0!==m&&!n.hasOwnProperty(g)&&md(e,t,g,void 0,n,m);for(d in n)m=n[d],h=l[d],!n.hasOwnProperty(d)||m===h||void 0===m&&void 0===h||md(e,t,d,m,n,h);return}}for(var v in l)m=l[v],l.hasOwnProperty(v)&&null!=m&&!n.hasOwnProperty(v)&&bd(e,t,v,null,n,m);for(b in n)m=n[b],h=l[b],!n.hasOwnProperty(b)||m===h||null==m&&null==h||bd(e,t,b,m,n,h)}(n,e.type,l,t),n[We]=t}catch(a){ju(e,e.return,a)}}function Ns(e){return 5===e.tag||3===e.tag||26===e.tag||27===e.tag&&$d(e.type)||4===e.tag}function Es(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||Ns(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(27===e.tag&&$d(e.type))continue e;if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function $s(e,t,l){var n=e.tag;if(5===n||6===n)e=e.stateNode,t?(9===l.nodeType?l.body:"HTML"===l.nodeName?l.ownerDocument.body:l).insertBefore(e,t):((t=9===l.nodeType?l.body:"HTML"===l.nodeName?l.ownerDocument.body:l).appendChild(e),null!=(l=l._reactRootContainer)||null!==t.onclick||(t.onclick=Mt));else if(4!==n&&(27===n&&$d(e.type)&&(l=e.stateNode,t=null),null!==(e=e.child)))for($s(e,t,l),e=e.sibling;null!==e;)$s(e,t,l),e=e.sibling}function _s(e,t,l){var n=e.tag;if(5===n||6===n)e=e.stateNode,t?l.insertBefore(e,t):l.appendChild(e);else if(4!==n&&(27===n&&$d(e.type)&&(l=e.stateNode),null!==(e=e.child)))for(_s(e,t,l),e=e.sibling;null!==e;)_s(e,t,l),e=e.sibling}function Ts(e){var t=e.stateNode,l=e.memoizedProps;try{for(var n=e.type,a=t.attributes;a.length;)t.removeAttributeNode(a[0]);hd(t,n,l),t[qe]=e,t[We]=l}catch(r){ju(e,e.return,r)}}var As=!1,zs=!1,Ls=!1,Ms="function"==typeof WeakSet?WeakSet:Set,Is=null;function Ps(e,t,l){var n=l.flags;switch(l.tag){case 0:case 11:case 15:Xs(e,l),4&n&&vs(5,l);break;case 1:if(Xs(e,l),4&n)if(e=l.stateNode,null===t)try{e.componentDidMount()}catch(i){ju(l,l.return,i)}else{var a=jo(l.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(a,t,e.__reactInternalSnapshotBeforeUpdate)}catch(o){ju(l,l.return,o)}}64&n&&xs(l),512&n&&ks(l,l.return);break;case 3:if(Xs(e,l),64&n&&null!==(e=l.updateQueue)){if(t=null,null!==l.child)switch(l.child.tag){case 27:case 5:case 1:t=l.child.stateNode}try{$r(e,t)}catch(i){ju(l,l.return,i)}}break;case 27:null===t&&4&n&&Ts(l);case 26:case 5:Xs(e,l),null===t&&4&n&&Ss(l),512&n&&ks(l,l.return);break;case 12:Xs(e,l);break;case 31:Xs(e,l),4&n&&Bs(e,l);break;case 13:Xs(e,l),4&n&&qs(e,l),64&n&&(null!==(e=l.memoizedState)&&(null!==(e=e.dehydrated)&&function(e,t){var l=e.ownerDocument;if("$~"===e.data)e._reactRetry=t;else if("$?"!==e.data||"loading"!==l.readyState)t();else{var n=function(){t(),l.removeEventListener("DOMContentLoaded",n)};l.addEventListener("DOMContentLoaded",n),e._reactRetry=n}}(e,l=_u.bind(null,l))));break;case 22:if(!(n=null!==l.memoizedState||As)){t=null!==t&&null!==t.memoizedState||zs,a=As;var r=zs;As=n,(zs=t)&&!r?Js(e,l,!!(8772&l.subtreeFlags)):Xs(e,l),As=a,zs=r}break;case 30:break;default:Xs(e,l)}}function Ds(e){var t=e.alternate;null!==t&&(e.alternate=null,Ds(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&Ye(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Rs=null,Os=!1;function Fs(e,t,l){for(l=l.child;null!==l;)Us(e,t,l),l=l.sibling}function Us(e,t,l){if(xe&&"function"==typeof xe.onCommitFiberUnmount)try{xe.onCommitFiberUnmount(ye,l)}catch(r){}switch(l.tag){case 26:zs||Cs(l,t),Fs(e,t,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode).parentNode.removeChild(l);break;case 27:zs||Cs(l,t);var n=Rs,a=Os;$d(l.type)&&(Rs=l.stateNode,Os=!1),Fs(e,t,l),Fd(l.stateNode),Rs=n,Os=a;break;case 5:zs||Cs(l,t);case 6:if(n=Rs,a=Os,Rs=null,Fs(e,t,l),Os=a,null!==(Rs=n))if(Os)try{(9===Rs.nodeType?Rs.body:"HTML"===Rs.nodeName?Rs.ownerDocument.body:Rs).removeChild(l.stateNode)}catch(i){ju(l,t,i)}else try{Rs.removeChild(l.stateNode)}catch(i){ju(l,t,i)}break;case 18:null!==Rs&&(Os?(_d(9===(e=Rs).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,l.stateNode),Hb(e)):_d(Rs,l.stateNode));break;case 4:n=Rs,a=Os,Rs=l.stateNode.containerInfo,Os=!0,Fs(e,t,l),Rs=n,Os=a;break;case 0:case 11:case 14:case 15:ys(2,l,t),zs||ys(4,l,t),Fs(e,t,l);break;case 1:zs||(Cs(l,t),"function"==typeof(n=l.stateNode).componentWillUnmount&&ws(l,t,n)),Fs(e,t,l);break;case 21:Fs(e,t,l);break;case 22:zs=(n=zs)||null!==l.memoizedState,Fs(e,t,l),zs=n;break;default:Fs(e,t,l)}}function Bs(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&null!==(e=e.memoizedState))){e=e.dehydrated;try{Hb(e)}catch(l){ju(t,t.return,l)}}}function qs(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&(null!==(e=e.memoizedState)&&null!==(e=e.dehydrated))))try{Hb(e)}catch(l){ju(t,t.return,l)}}function Ws(e,t){var l=function(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return null===t&&(t=e.stateNode=new Ms),t;case 22:return null===(t=(e=e.stateNode)._retryCache)&&(t=e._retryCache=new Ms),t;default:throw Error(r(435,e.tag))}}(e);t.forEach(function(t){if(!l.has(t)){l.add(t);var n=Tu.bind(null,e,t);t.then(n,n)}})}function Vs(e,t){var l=t.deletions;if(null!==l)for(var n=0;n<l.length;n++){var a=l[n],i=e,o=t,s=o;e:for(;null!==s;){switch(s.tag){case 27:if($d(s.type)){Rs=s.stateNode,Os=!1;break e}break;case 5:Rs=s.stateNode,Os=!1;break e;case 3:case 4:Rs=s.stateNode.containerInfo,Os=!0;break e}s=s.return}if(null===Rs)throw Error(r(160));Us(i,o,a),Rs=null,Os=!1,null!==(i=a.alternate)&&(i.return=null),a.return=null}if(13886&t.subtreeFlags)for(t=t.child;null!==t;)Ks(t,e),t=t.sibling}var Hs=null;function Ks(e,t){var l=e.alternate,n=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Vs(t,e),Gs(e),4&n&&(ys(3,e,e.return),vs(3,e),ys(5,e,e.return));break;case 1:Vs(t,e),Gs(e),512&n&&(zs||null===l||Cs(l,l.return)),64&n&&As&&(null!==(e=e.updateQueue)&&(null!==(n=e.callbacks)&&(l=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=null===l?n:l.concat(n))));break;case 26:var a=Hs;if(Vs(t,e),Gs(e),512&n&&(zs||null===l||Cs(l,l.return)),4&n){var i=null!==l?l.memoizedState:null;if(n=e.memoizedState,null===l)if(null===n)if(null===e.stateNode){e:{n=e.type,l=e.memoizedProps,a=a.ownerDocument||a;t:switch(n){case"title":(!(i=a.getElementsByTagName("title")[0])||i[Xe]||i[qe]||"http://www.w3.org/2000/svg"===i.namespaceURI||i.hasAttribute("itemprop"))&&(i=a.createElement(n),a.head.insertBefore(i,a.querySelector("head > title"))),hd(i,n,l),i[qe]=e,lt(i),n=i;break e;case"link":var o=ab("link","href",a).get(n+(l.href||""));if(o)for(var s=0;s<o.length;s++)if((i=o[s]).getAttribute("href")===(null==l.href||""===l.href?null:l.href)&&i.getAttribute("rel")===(null==l.rel?null:l.rel)&&i.getAttribute("title")===(null==l.title?null:l.title)&&i.getAttribute("crossorigin")===(null==l.crossOrigin?null:l.crossOrigin)){o.splice(s,1);break t}hd(i=a.createElement(n),n,l),a.head.appendChild(i);break;case"meta":if(o=ab("meta","content",a).get(n+(l.content||"")))for(s=0;s<o.length;s++)if((i=o[s]).getAttribute("content")===(null==l.content?null:""+l.content)&&i.getAttribute("name")===(null==l.name?null:l.name)&&i.getAttribute("property")===(null==l.property?null:l.property)&&i.getAttribute("http-equiv")===(null==l.httpEquiv?null:l.httpEquiv)&&i.getAttribute("charset")===(null==l.charSet?null:l.charSet)){o.splice(s,1);break t}hd(i=a.createElement(n),n,l),a.head.appendChild(i);break;default:throw Error(r(468,n))}i[qe]=e,lt(i),n=i}e.stateNode=n}else rb(a,e.type,e.stateNode);else e.stateNode=Zd(a,n,e.memoizedProps);else i!==n?(null===i?null!==l.stateNode&&(l=l.stateNode).parentNode.removeChild(l):i.count--,null===n?rb(a,e.type,e.stateNode):Zd(a,n,e.memoizedProps)):null===n&&null!==e.stateNode&&js(e,e.memoizedProps,l.memoizedProps)}break;case 27:Vs(t,e),Gs(e),512&n&&(zs||null===l||Cs(l,l.return)),null!==l&&4&n&&js(e,e.memoizedProps,l.memoizedProps);break;case 5:if(Vs(t,e),Gs(e),512&n&&(zs||null===l||Cs(l,l.return)),32&e.flags){a=e.stateNode;try{Nt(a,"")}catch(p){ju(e,e.return,p)}}4&n&&null!=e.stateNode&&js(e,a=e.memoizedProps,null!==l?l.memoizedProps:a),1024&n&&(Ls=!0);break;case 6:if(Vs(t,e),Gs(e),4&n){if(null===e.stateNode)throw Error(r(162));n=e.memoizedProps,l=e.stateNode;try{l.nodeValue=n}catch(p){ju(e,e.return,p)}}break;case 3:if(nb=null,a=Hs,Hs=qd(t.containerInfo),Vs(t,e),Hs=a,Gs(e),4&n&&null!==l&&l.memoizedState.isDehydrated)try{Hb(t.containerInfo)}catch(p){ju(e,e.return,p)}Ls&&(Ls=!1,Qs(e));break;case 4:n=Hs,Hs=qd(e.stateNode.containerInfo),Vs(t,e),Gs(e),Hs=n;break;case 12:default:Vs(t,e),Gs(e);break;case 31:case 19:Vs(t,e),Gs(e),4&n&&(null!==(n=e.updateQueue)&&(e.updateQueue=null,Ws(e,n)));break;case 13:Vs(t,e),Gs(e),8192&e.child.flags&&null!==e.memoizedState!=(null!==l&&null!==l.memoizedState)&&(Mc=ue()),4&n&&(null!==(n=e.updateQueue)&&(e.updateQueue=null,Ws(e,n)));break;case 22:a=null!==e.memoizedState;var c=null!==l&&null!==l.memoizedState,u=As,d=zs;if(As=u||a,zs=d||c,Vs(t,e),zs=d,As=u,Gs(e),8192&n)e:for(t=e.stateNode,t._visibility=a?-2&t._visibility:1|t._visibility,a&&(null===l||c||As||zs||Ys(e)),l=null,t=e;;){if(5===t.tag||26===t.tag){if(null===l){c=l=t;try{if(i=c.stateNode,a)"function"==typeof(o=i.style).setProperty?o.setProperty("display","none","important"):o.display="none";else{s=c.stateNode;var b=c.memoizedProps.style,m=null!=b&&b.hasOwnProperty("display")?b.display:null;s.style.display=null==m||"boolean"==typeof m?"":(""+m).trim()}}catch(p){ju(c,c.return,p)}}}else if(6===t.tag){if(null===l){c=t;try{c.stateNode.nodeValue=a?"":c.memoizedProps}catch(p){ju(c,c.return,p)}}}else if(18===t.tag){if(null===l){c=t;try{var h=c.stateNode;a?Td(h,!0):Td(c.stateNode,!1)}catch(p){ju(c,c.return,p)}}}else if((22!==t.tag&&23!==t.tag||null===t.memoizedState||t===e)&&null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;null===t.sibling;){if(null===t.return||t.return===e)break e;l===t&&(l=null),t=t.return}l===t&&(l=null),t.sibling.return=t.return,t=t.sibling}4&n&&(null!==(n=e.updateQueue)&&(null!==(l=n.retryQueue)&&(n.retryQueue=null,Ws(e,l))));case 30:case 21:}}function Gs(e){var t=e.flags;if(2&t){try{for(var l,n=e.return;null!==n;){if(Ns(n)){l=n;break}n=n.return}if(null==l)throw Error(r(160));switch(l.tag){case 27:var a=l.stateNode;_s(e,Es(e),a);break;case 5:var i=l.stateNode;32&l.flags&&(Nt(i,""),l.flags&=-33),_s(e,Es(e),i);break;case 3:case 4:var o=l.stateNode.containerInfo;$s(e,Es(e),o);break;default:throw Error(r(161))}}catch(s){ju(e,e.return,s)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function Qs(e){if(1024&e.subtreeFlags)for(e=e.child;null!==e;){var t=e;Qs(t),5===t.tag&&1024&t.flags&&t.stateNode.reset(),e=e.sibling}}function Xs(e,t){if(8772&t.subtreeFlags)for(t=t.child;null!==t;)Ps(e,t.alternate,t),t=t.sibling}function Ys(e){for(e=e.child;null!==e;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:ys(4,t,t.return),Ys(t);break;case 1:Cs(t,t.return);var l=t.stateNode;"function"==typeof l.componentWillUnmount&&ws(t,t.return,l),Ys(t);break;case 27:Fd(t.stateNode);case 26:case 5:Cs(t,t.return),Ys(t);break;case 22:null===t.memoizedState&&Ys(t);break;default:Ys(t)}e=e.sibling}}function Js(e,t,l){for(l=l&&!!(8772&t.subtreeFlags),t=t.child;null!==t;){var n=t.alternate,a=e,r=t,i=r.flags;switch(r.tag){case 0:case 11:case 15:Js(a,r,l),vs(4,r);break;case 1:if(Js(a,r,l),"function"==typeof(a=(n=r).stateNode).componentDidMount)try{a.componentDidMount()}catch(c){ju(n,n.return,c)}if(null!==(a=(n=r).updateQueue)){var o=n.stateNode;try{var s=a.shared.hiddenCallbacks;if(null!==s)for(a.shared.hiddenCallbacks=null,a=0;a<s.length;a++)Er(s[a],o)}catch(c){ju(n,n.return,c)}}l&&64&i&&xs(r),ks(r,r.return);break;case 27:Ts(r);case 26:case 5:Js(a,r,l),l&&null===n&&4&i&&Ss(r),ks(r,r.return);break;case 12:Js(a,r,l);break;case 31:Js(a,r,l),l&&4&i&&Bs(a,r);break;case 13:Js(a,r,l),l&&4&i&&qs(a,r);break;case 22:null===r.memoizedState&&Js(a,r,l),ks(r,r.return);break;case 30:break;default:Js(a,r,l)}t=t.sibling}}function Zs(e,t){var l=null;null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(l=e.memoizedState.cachePool.pool),e=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(e=t.memoizedState.cachePool.pool),e!==l&&(null!=e&&e.refCount++,null!=l&&Ba(l))}function ec(e,t){e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Ba(e))}function tc(e,t,l,n){if(10256&t.subtreeFlags)for(t=t.child;null!==t;)lc(e,t,l,n),t=t.sibling}function lc(e,t,l,n){var a=t.flags;switch(t.tag){case 0:case 11:case 15:tc(e,t,l,n),2048&a&&vs(9,t);break;case 1:case 31:case 13:default:tc(e,t,l,n);break;case 3:tc(e,t,l,n),2048&a&&(e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Ba(e)));break;case 12:if(2048&a){tc(e,t,l,n),e=t.stateNode;try{var r=t.memoizedProps,i=r.id,o=r.onPostCommit;"function"==typeof o&&o(i,null===t.alternate?"mount":"update",e.passiveEffectDuration,-0)}catch(s){ju(t,t.return,s)}}else tc(e,t,l,n);break;case 23:break;case 22:r=t.stateNode,i=t.alternate,null!==t.memoizedState?2&r._visibility?tc(e,t,l,n):ac(e,t):2&r._visibility?tc(e,t,l,n):(r._visibility|=2,nc(e,t,l,n,!!(10256&t.subtreeFlags)||!1)),2048&a&&Zs(i,t);break;case 24:tc(e,t,l,n),2048&a&&ec(t.alternate,t)}}function nc(e,t,l,n,a){for(a=a&&(!!(10256&t.subtreeFlags)||!1),t=t.child;null!==t;){var r=e,i=t,o=l,s=n,c=i.flags;switch(i.tag){case 0:case 11:case 15:nc(r,i,o,s,a),vs(8,i);break;case 23:break;case 22:var u=i.stateNode;null!==i.memoizedState?2&u._visibility?nc(r,i,o,s,a):ac(r,i):(u._visibility|=2,nc(r,i,o,s,a)),a&&2048&c&&Zs(i.alternate,i);break;case 24:nc(r,i,o,s,a),a&&2048&c&&ec(i.alternate,i);break;default:nc(r,i,o,s,a)}t=t.sibling}}function ac(e,t){if(10256&t.subtreeFlags)for(t=t.child;null!==t;){var l=e,n=t,a=n.flags;switch(n.tag){case 22:ac(l,n),2048&a&&Zs(n.alternate,n);break;case 24:ac(l,n),2048&a&&ec(n.alternate,n);break;default:ac(l,n)}t=t.sibling}}var rc=8192;function ic(e,t,l){if(e.subtreeFlags&rc)for(e=e.child;null!==e;)oc(e,t,l),e=e.sibling}function oc(e,t,l){switch(e.tag){case 26:ic(e,t,l),e.flags&rc&&null!==e.memoizedState&&function(e,t,l,n){if(!("stylesheet"!==l.type||"string"==typeof n.media&&!1===matchMedia(n.media).matches||4&l.state.loading)){if(null===l.instance){var a=Gd(n.href),r=t.querySelector(Qd(a));if(r)return null!==(t=r._p)&&"object"==typeof t&&"function"==typeof t.then&&(e.count++,e=sb.bind(e),t.then(e,e)),l.state.loading|=4,l.instance=r,void lt(r);r=t.ownerDocument||t,n=Xd(n),(a=Ud.get(a))&&tb(n,a),lt(r=r.createElement("link"));var i=r;i._p=new Promise(function(e,t){i.onload=e,i.onerror=t}),hd(r,"link",n),l.instance=r}null===e.stylesheets&&(e.stylesheets=new Map),e.stylesheets.set(l,t),(t=l.state.preload)&&!(3&l.state.loading)&&(e.count++,l=sb.bind(e),t.addEventListener("load",l),t.addEventListener("error",l))}}(l,Hs,e.memoizedState,e.memoizedProps);break;case 5:default:ic(e,t,l);break;case 3:case 4:var n=Hs;Hs=qd(e.stateNode.containerInfo),ic(e,t,l),Hs=n;break;case 22:null===e.memoizedState&&(null!==(n=e.alternate)&&null!==n.memoizedState?(n=rc,rc=16777216,ic(e,t,l),rc=n):ic(e,t,l))}}function sc(e){var t=e.alternate;if(null!==t&&null!==(e=t.child)){t.child=null;do{t=e.sibling,e.sibling=null,e=t}while(null!==e)}}function cc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var l=0;l<t.length;l++){var n=t[l];Is=n,bc(n,e)}sc(e)}if(10256&e.subtreeFlags)for(e=e.child;null!==e;)uc(e),e=e.sibling}function uc(e){switch(e.tag){case 0:case 11:case 15:cc(e),2048&e.flags&&ys(9,e,e.return);break;case 3:case 12:default:cc(e);break;case 22:var t=e.stateNode;null!==e.memoizedState&&2&t._visibility&&(null===e.return||13!==e.return.tag)?(t._visibility&=-3,dc(e)):cc(e)}}function dc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var l=0;l<t.length;l++){var n=t[l];Is=n,bc(n,e)}sc(e)}for(e=e.child;null!==e;){switch((t=e).tag){case 0:case 11:case 15:ys(8,t,t.return),dc(t);break;case 22:2&(l=t.stateNode)._visibility&&(l._visibility&=-3,dc(t));break;default:dc(t)}e=e.sibling}}function bc(e,t){for(;null!==Is;){var l=Is;switch(l.tag){case 0:case 11:case 15:ys(8,l,t);break;case 23:case 22:if(null!==l.memoizedState&&null!==l.memoizedState.cachePool){var n=l.memoizedState.cachePool.pool;null!=n&&n.refCount++}break;case 24:Ba(l.memoizedState.cache)}if(null!==(n=l.child))n.return=l,Is=n;else e:for(l=e;null!==Is;){var a=(n=Is).sibling,r=n.return;if(Ds(n),n===l){Is=null;break e}if(null!==a){a.return=r,Is=a;break e}Is=r}}}var mc={getCacheForType:function(e){var t=Ma(Fa),l=t.data.get(e);return void 0===l&&(l=e(),t.data.set(e,l)),l},cacheSignal:function(){return Ma(Fa).controller.signal}},hc="function"==typeof WeakMap?WeakMap:Map,pc=0,fc=null,gc=null,vc=0,yc=0,xc=null,wc=!1,kc=!1,Cc=!1,Sc=0,jc=0,Nc=0,Ec=0,$c=0,_c=0,Tc=0,Ac=null,zc=null,Lc=!1,Mc=0,Ic=0,Pc=1/0,Dc=null,Rc=null,Oc=0,Fc=null,Uc=null,Bc=0,qc=0,Wc=null,Vc=null,Hc=0,Kc=null;function Gc(){return 2&pc&&0!==vc?vc&-vc:null!==P.T?Wu():Fe()}function Qc(){if(0===_c)if(536870912&vc&&!ma)_c=536870912;else{var e=Ne;!(3932160&(Ne<<=1))&&(Ne=262144),_c=e}return null!==(e=Mr.current)&&(e.flags|=32),_c}function Xc(e,t,l){(e!==fc||2!==yc&&9!==yc)&&null===e.cancelPendingCommit||(nu(e,0),eu(e,vc,_c,!1)),Me(e,l),2&pc&&e===fc||(e===fc&&(!(2&pc)&&(Ec|=l),4===jc&&eu(e,vc,_c,!1)),Du(e))}function Yc(e,t,l){if(6&pc)throw Error(r(327));for(var n=!l&&!(127&t)&&0===(t&e.expiredLanes)||Te(e,t),a=n?function(e,t){var l=pc;pc|=2;var n=iu(),a=ou();fc!==e||vc!==t?(Dc=null,Pc=ue()+500,nu(e,t)):kc=Te(e,t);e:for(;;)try{if(0!==yc&&null!==gc){t=gc;var i=xc;t:switch(yc){case 1:yc=0,xc=null,hu(e,t,i,1);break;case 2:case 9:if(nr(i)){yc=0,xc=null,mu(t);break}t=function(){2!==yc&&9!==yc||fc!==e||(yc=7),Du(e)},i.then(t,t);break e;case 3:yc=7;break e;case 4:yc=5;break e;case 7:nr(i)?(yc=0,xc=null,mu(t)):(yc=0,xc=null,hu(e,t,i,7));break;case 5:var o=null;switch(gc.tag){case 26:o=gc.memoizedState;case 5:case 27:var s=gc;if(o?ib(o):s.stateNode.complete){yc=0,xc=null;var c=s.sibling;if(null!==c)gc=c;else{var u=s.return;null!==u?(gc=u,pu(u)):gc=null}break t}}yc=0,xc=null,hu(e,t,i,5);break;case 6:yc=0,xc=null,hu(e,t,i,6);break;case 8:lu(),jc=6;break e;default:throw Error(r(462))}}du();break}catch(d){au(e,d)}return Na=ja=null,P.H=n,P.A=a,pc=l,null!==gc?0:(fc=null,vc=0,zn(),jc)}(e,t):cu(e,t,!0),i=n;;){if(0===a){kc&&!n&&eu(e,t,0,!1);break}if(l=e.current.alternate,!i||Zc(l)){if(2===a){if(i=t,e.errorRecoveryDisabledLanes&i)var o=0;else o=0!==(o=-536870913&e.pendingLanes)?o:536870912&o?536870912:0;if(0!==o){t=o;e:{var s=e;a=Ac;var c=s.current.memoizedState.isDehydrated;if(c&&(nu(s,o).flags|=256),2!==(o=cu(s,o,!1))){if(Cc&&!c){s.errorRecoveryDisabledLanes|=i,Ec|=i,a=4;break e}i=zc,zc=a,null!==i&&(null===zc?zc=i:zc.push.apply(zc,i))}a=o}if(i=!1,2!==a)continue}}if(1===a){nu(e,0),eu(e,t,0,!0);break}e:{switch(n=e,i=a){case 0:case 1:throw Error(r(345));case 4:if((4194048&t)!==t)break;case 6:eu(n,t,_c,!wc);break e;case 2:zc=null;break;case 3:case 5:break;default:throw Error(r(329))}if((62914560&t)===t&&10<(a=Mc+300-ue())){if(eu(n,t,_c,!wc),0!==_e(n,0,!0))break e;Bc=t,n.timeoutHandle=Cd(Jc.bind(null,n,l,zc,Dc,Lc,t,_c,Ec,Tc,wc,i,"Throttled",-0,0),a)}else Jc(n,l,zc,Dc,Lc,t,_c,Ec,Tc,wc,i,null,-0,0)}break}a=cu(e,t,!1),i=!1}Du(e)}function Jc(e,t,l,n,a,r,i,o,s,c,u,d,b,m){if(e.timeoutHandle=-1,8192&(d=t.subtreeFlags)||!(16785408&~d)){oc(t,r,d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Mt});var h=(62914560&r)===r?Mc-ue():(4194048&r)===r?Ic-ue():0;if(null!==(h=function(e,t){return e.stylesheets&&0===e.count&&ub(e,e.stylesheets),0<e.count||0<e.imgCount?function(l){var n=setTimeout(function(){if(e.stylesheets&&ub(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&0===ob&&(ob=62500*function(){if("function"==typeof performance.getEntriesByType){for(var e=0,t=0,l=performance.getEntriesByType("resource"),n=0;n<l.length;n++){var a=l[n],r=a.transferSize,i=a.initiatorType,o=a.duration;if(r&&o&&pd(i)){for(i=0,o=a.responseEnd,n+=1;n<l.length;n++){var s=l[n],c=s.startTime;if(c>o)break;var u=s.transferSize,d=s.initiatorType;u&&pd(d)&&(i+=u*((s=s.responseEnd)<o?1:(o-c)/(s-c)))}if(--n,t+=8*(r+i)/(a.duration/1e3),10<++e)break}}if(0<e)return t/e/1e6}return navigator.connection&&"number"==typeof(e=navigator.connection.downlink)?e:5}());var a=setTimeout(function(){if(e.waitingForImages=!1,0===e.count&&(e.stylesheets&&ub(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>ob?50:800)+t);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(n),clearTimeout(a)}}:null}(d,h)))return Bc=r,e.cancelPendingCommit=h(gu.bind(null,e,t,r,l,n,a,i,o,s,u,d,null,b,m)),void eu(e,r,i,!c)}gu(e,t,r,l,n,a,i,o,s)}function Zc(e){for(var t=e;;){var l=t.tag;if((0===l||11===l||15===l)&&16384&t.flags&&(null!==(l=t.updateQueue)&&null!==(l=l.stores)))for(var n=0;n<l.length;n++){var a=l[n],r=a.getSnapshot;a=a.value;try{if(!Zl(r(),a))return!1}catch(i){return!1}}if(l=t.child,16384&t.subtreeFlags&&null!==l)l.return=t,t=l;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function eu(e,t,l,n){t&=~$c,t&=~Ec,e.suspendedLanes|=t,e.pingedLanes&=~t,n&&(e.warmLanes|=t),n=e.expirationTimes;for(var a=t;0<a;){var r=31-ke(a),i=1<<r;n[r]=-1,a&=~i}0!==l&&Ie(e,l,t)}function tu(){return!!(6&pc)||(Ru(0),!1)}function lu(){if(null!==gc){if(0===yc)var e=gc.return;else Na=ja=null,si(e=gc),cr=null,ur=0,e=gc;for(;null!==e;)gs(e.alternate,e),e=e.return;gc=null}}function nu(e,t){var l=e.timeoutHandle;-1!==l&&(e.timeoutHandle=-1,Sd(l)),null!==(l=e.cancelPendingCommit)&&(e.cancelPendingCommit=null,l()),Bc=0,lu(),fc=e,gc=l=Bn(e.current,null),vc=t,yc=0,xc=null,wc=!1,kc=Te(e,t),Cc=!1,Tc=_c=$c=Ec=Nc=jc=0,zc=Ac=null,Lc=!1,8&t&&(t|=32&t);var n=e.entangledLanes;if(0!==n)for(e=e.entanglements,n&=t;0<n;){var a=31-ke(n),r=1<<a;t|=e[a],n&=~r}return Sc=t,zn(),l}function au(e,t){Wr=null,P.H=go,t===Za||t===tr?(t=or(),yc=3):t===er?(t=or(),yc=4):yc=t===Mo?8:null!==t&&"object"==typeof t&&"function"==typeof t.then?6:1,xc=t,null===gc&&(jc=1,_o(e,Xn(t,e.current)))}function ru(){var e=Mr.current;return null===e||((4194048&vc)===vc?null===Ir:!!((62914560&vc)===vc||536870912&vc)&&e===Ir)}function iu(){var e=P.H;return P.H=go,null===e?go:e}function ou(){var e=P.A;return P.A=mc,e}function su(){jc=4,wc||(4194048&vc)!==vc&&null!==Mr.current||(kc=!0),!(134217727&Nc)&&!(134217727&Ec)||null===fc||eu(fc,vc,_c,!1)}function cu(e,t,l){var n=pc;pc|=2;var a=iu(),r=ou();fc===e&&vc===t||(Dc=null,nu(e,t)),t=!1;var i=jc;e:for(;;)try{if(0!==yc&&null!==gc){var o=gc,s=xc;switch(yc){case 8:lu(),i=6;break e;case 3:case 2:case 9:case 6:null===Mr.current&&(t=!0);var c=yc;if(yc=0,xc=null,hu(e,o,s,c),l&&kc){i=0;break e}break;default:c=yc,yc=0,xc=null,hu(e,o,s,c)}}uu(),i=jc;break}catch(u){au(e,u)}return t&&e.shellSuspendCounter++,Na=ja=null,pc=n,P.H=a,P.A=r,null===gc&&(fc=null,vc=0,zn()),i}function uu(){for(;null!==gc;)bu(gc)}function du(){for(;null!==gc&&!se();)bu(gc)}function bu(e){var t=ss(e.alternate,e,Sc);e.memoizedProps=e.pendingProps,null===t?pu(e):gc=t}function mu(e){var t=e,l=t.alternate;switch(t.tag){case 15:case 0:t=Ko(l,t,t.pendingProps,t.type,void 0,vc);break;case 11:t=Ko(l,t,t.pendingProps,t.type.render,t.ref,vc);break;case 5:si(t);default:gs(l,t),t=ss(l,t=gc=qn(t,Sc),Sc)}e.memoizedProps=e.pendingProps,null===t?pu(e):gc=t}function hu(e,t,l,n){Na=ja=null,si(t),cr=null,ur=0;var a=t.return;try{if(function(e,t,l,n,a){if(l.flags|=32768,null!==n&&"object"==typeof n&&"function"==typeof n.then){if(null!==(t=l.alternate)&&Aa(t,l,a,!0),null!==(l=Mr.current)){switch(l.tag){case 31:case 13:return null===Ir?su():null===l.alternate&&0===jc&&(jc=3),l.flags&=-257,l.flags|=65536,l.lanes=a,n===lr?l.flags|=16384:(null===(t=l.updateQueue)?l.updateQueue=new Set([n]):t.add(n),Nu(e,n,a)),!1;case 22:return l.flags|=65536,n===lr?l.flags|=16384:(null===(t=l.updateQueue)?(t={transitions:null,markerInstances:null,retryQueue:new Set([n])},l.updateQueue=t):null===(l=t.retryQueue)?t.retryQueue=new Set([n]):l.add(n),Nu(e,n,a)),!1}throw Error(r(435,l.tag))}return Nu(e,n,a),su(),!1}if(ma)return null!==(t=Mr.current)?(!(65536&t.flags)&&(t.flags|=256),t.flags|=65536,t.lanes=a,n!==fa&&Ca(Xn(e=Error(r(422),{cause:n}),l))):(n!==fa&&Ca(Xn(t=Error(r(423),{cause:n}),l)),(e=e.current.alternate).flags|=65536,a&=-a,e.lanes|=a,n=Xn(n,l),Cr(e,a=Ao(e.stateNode,n,a)),4!==jc&&(jc=2)),!1;var i=Error(r(520),{cause:n});if(i=Xn(i,l),null===Ac?Ac=[i]:Ac.push(i),4!==jc&&(jc=2),null===t)return!0;n=Xn(n,l),l=t;do{switch(l.tag){case 3:return l.flags|=65536,e=a&-a,l.lanes|=e,Cr(l,e=Ao(l.stateNode,n,e)),!1;case 1:if(t=l.type,i=l.stateNode,!(128&l.flags||"function"!=typeof t.getDerivedStateFromError&&(null===i||"function"!=typeof i.componentDidCatch||null!==Rc&&Rc.has(i))))return l.flags|=65536,a&=-a,l.lanes|=a,Lo(a=zo(a),e,l,n),Cr(l,a),!1}l=l.return}while(null!==l);return!1}(e,a,t,l,vc))return jc=1,_o(e,Xn(l,e.current)),void(gc=null)}catch(i){if(null!==a)throw gc=a,i;return jc=1,_o(e,Xn(l,e.current)),void(gc=null)}32768&t.flags?(ma||1===n?e=!0:kc||536870912&vc?e=!1:(wc=e=!0,(2===n||9===n||3===n||6===n)&&(null!==(n=Mr.current)&&13===n.tag&&(n.flags|=16384))),fu(t,e)):pu(t)}function pu(e){var t=e;do{if(32768&t.flags)return void fu(t,wc);e=t.return;var l=ps(t.alternate,t,Sc);if(null!==l)return void(gc=l);if(null!==(t=t.sibling))return void(gc=t);gc=t=e}while(null!==t);0===jc&&(jc=5)}function fu(e,t){do{var l=fs(e.alternate,e);if(null!==l)return l.flags&=32767,void(gc=l);if(null!==(l=e.return)&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!t&&null!==(e=e.sibling))return void(gc=e);gc=e=l}while(null!==e);jc=6,gc=null}function gu(e,t,l,n,a,i,o,s,c){e.cancelPendingCommit=null;do{ku()}while(0!==Oc);if(6&pc)throw Error(r(327));if(null!==t){if(t===e.current)throw Error(r(177));if(i=t.lanes|t.childLanes,function(e,t,l,n,a,r){var i=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var o=e.entanglements,s=e.expirationTimes,c=e.hiddenUpdates;for(l=i&~l;0<l;){var u=31-ke(l),d=1<<u;o[u]=0,s[u]=-1;var b=c[u];if(null!==b)for(c[u]=null,u=0;u<b.length;u++){var m=b[u];null!==m&&(m.lane&=-536870913)}l&=~d}0!==n&&Ie(e,n,0),0!==r&&0===a&&0!==e.tag&&(e.suspendedLanes|=r&~(i&~t))}(e,l,i|=An,o,s,c),e===fc&&(gc=fc=null,vc=0),Uc=t,Fc=e,Bc=l,qc=i,Wc=a,Vc=n,10256&t.subtreeFlags||10256&t.flags?(e.callbackNode=null,e.callbackPriority=0,ie(he,function(){return Cu(),null})):(e.callbackNode=null,e.callbackPriority=0),n=!!(13878&t.flags),13878&t.subtreeFlags||n){n=P.T,P.T=null,a=D.p,D.p=2,o=pc,pc|=4;try{!function(e,t){if(e=e.containerInfo,fd=wb,rn(e=an(e))){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{var n=(l=(l=e.ownerDocument)&&l.defaultView||window).getSelection&&l.getSelection();if(n&&0!==n.rangeCount){l=n.anchorNode;var a=n.anchorOffset,i=n.focusNode;n=n.focusOffset;try{l.nodeType,i.nodeType}catch(f){l=null;break e}var o=0,s=-1,c=-1,u=0,d=0,b=e,m=null;t:for(;;){for(var h;b!==l||0!==a&&3!==b.nodeType||(s=o+a),b!==i||0!==n&&3!==b.nodeType||(c=o+n),3===b.nodeType&&(o+=b.nodeValue.length),null!==(h=b.firstChild);)m=b,b=h;for(;;){if(b===e)break t;if(m===l&&++u===a&&(s=o),m===i&&++d===n&&(c=o),null!==(h=b.nextSibling))break;m=(b=m).parentNode}b=h}l=-1===s||-1===c?null:{start:s,end:c}}else l=null}l=l||{start:0,end:0}}else l=null;for(gd={focusedElem:e,selectionRange:l},wb=!1,Is=t;null!==Is;)if(e=(t=Is).child,1028&t.subtreeFlags&&null!==e)e.return=t,Is=e;else for(;null!==Is;){switch(i=(t=Is).alternate,e=t.flags,t.tag){case 0:if(4&e&&null!==(e=null!==(e=t.updateQueue)?e.events:null))for(l=0;l<e.length;l++)(a=e[l]).ref.impl=a.nextImpl;break;case 11:case 15:case 5:case 26:case 27:case 6:case 4:case 17:break;case 1:if(1024&e&&null!==i){e=void 0,l=t,a=i.memoizedProps,i=i.memoizedState,n=l.stateNode;try{var p=jo(l.type,a);e=n.getSnapshotBeforeUpdate(p,i),n.__reactInternalSnapshotBeforeUpdate=e}catch(g){ju(l,l.return,g)}}break;case 3:if(1024&e)if(9===(l=(e=t.stateNode.containerInfo).nodeType))Ad(e);else if(1===l)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Ad(e);break;default:e.textContent=""}break;default:if(1024&e)throw Error(r(163))}if(null!==(e=t.sibling)){e.return=t.return,Is=e;break}Is=t.return}}(e,t)}finally{pc=o,D.p=a,P.T=n}}Oc=1,vu(),yu(),xu()}}function vu(){if(1===Oc){Oc=0;var e=Fc,t=Uc,l=!!(13878&t.flags);if(13878&t.subtreeFlags||l){l=P.T,P.T=null;var n=D.p;D.p=2;var a=pc;pc|=4;try{Ks(t,e);var r=gd,i=an(e.containerInfo),o=r.focusedElem,s=r.selectionRange;if(i!==o&&o&&o.ownerDocument&&nn(o.ownerDocument.documentElement,o)){if(null!==s&&rn(o)){var c=s.start,u=s.end;if(void 0===u&&(u=c),"selectionStart"in o)o.selectionStart=c,o.selectionEnd=Math.min(u,o.value.length);else{var d=o.ownerDocument||document,b=d&&d.defaultView||window;if(b.getSelection){var m=b.getSelection(),h=o.textContent.length,p=Math.min(s.start,h),f=void 0===s.end?p:Math.min(s.end,h);!m.extend&&p>f&&(i=f,f=p,p=i);var g=ln(o,p),v=ln(o,f);if(g&&v&&(1!==m.rangeCount||m.anchorNode!==g.node||m.anchorOffset!==g.offset||m.focusNode!==v.node||m.focusOffset!==v.offset)){var y=d.createRange();y.setStart(g.node,g.offset),m.removeAllRanges(),p>f?(m.addRange(y),m.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),m.addRange(y))}}}}for(d=[],m=o;m=m.parentNode;)1===m.nodeType&&d.push({element:m,left:m.scrollLeft,top:m.scrollTop});for("function"==typeof o.focus&&o.focus(),o=0;o<d.length;o++){var x=d[o];x.element.scrollLeft=x.left,x.element.scrollTop=x.top}}wb=!!fd,gd=fd=null}finally{pc=a,D.p=n,P.T=l}}e.current=t,Oc=2}}function yu(){if(2===Oc){Oc=0;var e=Fc,t=Uc,l=!!(8772&t.flags);if(8772&t.subtreeFlags||l){l=P.T,P.T=null;var n=D.p;D.p=2;var a=pc;pc|=4;try{Ps(e,t.alternate,t)}finally{pc=a,D.p=n,P.T=l}}Oc=3}}function xu(){if(4===Oc||3===Oc){Oc=0,ce();var e=Fc,t=Uc,l=Bc,n=Vc;10256&t.subtreeFlags||10256&t.flags?Oc=5:(Oc=0,Uc=Fc=null,wu(e,e.pendingLanes));var a=e.pendingLanes;if(0===a&&(Rc=null),Oe(l),t=t.stateNode,xe&&"function"==typeof xe.onCommitFiberRoot)try{xe.onCommitFiberRoot(ye,t,void 0,!(128&~t.current.flags))}catch(s){}if(null!==n){t=P.T,a=D.p,D.p=2,P.T=null;try{for(var r=e.onRecoverableError,i=0;i<n.length;i++){var o=n[i];r(o.value,{componentStack:o.stack})}}finally{P.T=t,D.p=a}}3&Bc&&ku(),Du(e),a=e.pendingLanes,261930&l&&42&a?e===Kc?Hc++:(Hc=0,Kc=e):Hc=0,Ru(0)}}function wu(e,t){0===(e.pooledCacheLanes&=t)&&(null!=(t=e.pooledCache)&&(e.pooledCache=null,Ba(t)))}function ku(){return vu(),yu(),xu(),Cu()}function Cu(){if(5!==Oc)return!1;var e=Fc,t=qc;qc=0;var l=Oe(Bc),n=P.T,a=D.p;try{D.p=32>l?32:l,P.T=null,l=Wc,Wc=null;var i=Fc,o=Bc;if(Oc=0,Uc=Fc=null,Bc=0,6&pc)throw Error(r(331));var s=pc;if(pc|=4,uc(i.current),lc(i,i.current,o,l),pc=s,Ru(0,!1),xe&&"function"==typeof xe.onPostCommitFiberRoot)try{xe.onPostCommitFiberRoot(ye,i)}catch(c){}return!0}finally{D.p=a,P.T=n,wu(e,t)}}function Su(e,t,l){t=Xn(l,t),null!==(e=wr(e,t=Ao(e.stateNode,t,2),2))&&(Me(e,2),Du(e))}function ju(e,t,l){if(3===e.tag)Su(e,e,l);else for(;null!==t;){if(3===t.tag){Su(t,e,l);break}if(1===t.tag){var n=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof n.componentDidCatch&&(null===Rc||!Rc.has(n))){e=Xn(l,e),null!==(n=wr(t,l=zo(2),2))&&(Lo(l,n,t,e),Me(n,2),Du(n));break}}t=t.return}}function Nu(e,t,l){var n=e.pingCache;if(null===n){n=e.pingCache=new hc;var a=new Set;n.set(t,a)}else void 0===(a=n.get(t))&&(a=new Set,n.set(t,a));a.has(l)||(Cc=!0,a.add(l),e=Eu.bind(null,e,t,l),t.then(e,e))}function Eu(e,t,l){var n=e.pingCache;null!==n&&n.delete(t),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,fc===e&&(vc&l)===l&&(4===jc||3===jc&&(62914560&vc)===vc&&300>ue()-Mc?!(2&pc)&&nu(e,0):$c|=l,Tc===vc&&(Tc=0)),Du(e)}function $u(e,t){0===t&&(t=ze()),null!==(e=In(e,t))&&(Me(e,t),Du(e))}function _u(e){var t=e.memoizedState,l=0;null!==t&&(l=t.retryLane),$u(e,l)}function Tu(e,t){var l=0;switch(e.tag){case 31:case 13:var n=e.stateNode,a=e.memoizedState;null!==a&&(l=a.retryLane);break;case 19:n=e.stateNode;break;case 22:n=e.stateNode._retryCache;break;default:throw Error(r(314))}null!==n&&n.delete(t),$u(e,l)}var Au=null,zu=null,Lu=!1,Mu=!1,Iu=!1,Pu=0;function Du(e){e!==zu&&null===e.next&&(null===zu?Au=zu=e:zu=zu.next=e),Mu=!0,Lu||(Lu=!0,Nd(function(){6&pc?ie(be,Ou):Fu()}))}function Ru(e,t){if(!Iu&&Mu){Iu=!0;do{for(var l=!1,n=Au;null!==n;){if(0!==e){var a=n.pendingLanes;if(0===a)var r=0;else{var i=n.suspendedLanes,o=n.pingedLanes;r=(1<<31-ke(42|e)+1)-1,r=201326741&(r&=a&~(i&~o))?201326741&r|1:r?2|r:0}0!==r&&(l=!0,qu(n,r))}else r=vc,!(3&(r=_e(n,n===fc?r:0,null!==n.cancelPendingCommit||-1!==n.timeoutHandle)))||Te(n,r)||(l=!0,qu(n,r));n=n.next}}while(l);Iu=!1}}function Ou(){Fu()}function Fu(){Mu=Lu=!1;var e=0;0!==Pu&&function(){var e=window.event;if(e&&"popstate"===e.type)return e!==kd&&(kd=e,!0);return kd=null,!1}()&&(e=Pu);for(var t=ue(),l=null,n=Au;null!==n;){var a=n.next,r=Uu(n,t);0===r?(n.next=null,null===l?Au=a:l.next=a,null===a&&(zu=l)):(l=n,(0!==e||3&r)&&(Mu=!0)),n=a}0!==Oc&&5!==Oc||Ru(e),0!==Pu&&(Pu=0)}function Uu(e,t){for(var l=e.suspendedLanes,n=e.pingedLanes,a=e.expirationTimes,r=-62914561&e.pendingLanes;0<r;){var i=31-ke(r),o=1<<i,s=a[i];-1===s?0!==(o&l)&&0===(o&n)||(a[i]=Ae(o,t)):s<=t&&(e.expiredLanes|=o),r&=~o}if(l=vc,l=_e(e,e===(t=fc)?l:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle),n=e.callbackNode,0===l||e===t&&(2===yc||9===yc)||null!==e.cancelPendingCommit)return null!==n&&null!==n&&oe(n),e.callbackNode=null,e.callbackPriority=0;if(!(3&l)||Te(e,l)){if((t=l&-l)===e.callbackPriority)return t;switch(null!==n&&oe(n),Oe(l)){case 2:case 8:l=me;break;case 32:default:l=he;break;case 268435456:l=fe}return n=Bu.bind(null,e),l=ie(l,n),e.callbackPriority=t,e.callbackNode=l,t}return null!==n&&null!==n&&oe(n),e.callbackPriority=2,e.callbackNode=null,2}function Bu(e,t){if(0!==Oc&&5!==Oc)return e.callbackNode=null,e.callbackPriority=0,null;var l=e.callbackNode;if(ku()&&e.callbackNode!==l)return null;var n=vc;return 0===(n=_e(e,e===fc?n:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle))?null:(Yc(e,n,t),Uu(e,ue()),null!=e.callbackNode&&e.callbackNode===l?Bu.bind(null,e):null)}function qu(e,t){if(ku())return null;Yc(e,t,!0)}function Wu(){if(0===Pu){var e=Va;0===e&&(e=je,!(261888&(je<<=1))&&(je=256)),Pu=e}return Pu}function Vu(e){return null==e||"symbol"==typeof e||"boolean"==typeof e?null:"function"==typeof e?e:Lt(""+e)}function Hu(e,t){var l=t.ownerDocument.createElement("input");return l.name=t.name,l.value=t.value,e.id&&l.setAttribute("form",e.id),t.parentNode.insertBefore(l,t),e=new FormData(e),l.parentNode.removeChild(l),e}for(var Ku=0;Ku<Nn.length;Ku++){var Gu=Nn[Ku];En(Gu.toLowerCase(),"on"+(Gu[0].toUpperCase()+Gu.slice(1)))}En(vn,"onAnimationEnd"),En(yn,"onAnimationIteration"),En(xn,"onAnimationStart"),En("dblclick","onDoubleClick"),En("focusin","onFocus"),En("focusout","onBlur"),En(wn,"onTransitionRun"),En(kn,"onTransitionStart"),En(Cn,"onTransitionCancel"),En(Sn,"onTransitionEnd"),it("onMouseEnter",["mouseout","mouseover"]),it("onMouseLeave",["mouseout","mouseover"]),it("onPointerEnter",["pointerout","pointerover"]),it("onPointerLeave",["pointerout","pointerover"]),rt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),rt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),rt("onBeforeInput",["compositionend","keypress","textInput","paste"]),rt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),rt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),rt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Qu="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Xu=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Qu));function Yu(e,t){t=!!(4&t);for(var l=0;l<e.length;l++){var n=e[l],a=n.event;n=n.listeners;e:{var r=void 0;if(t)for(var i=n.length-1;0<=i;i--){var o=n[i],s=o.instance,c=o.currentTarget;if(o=o.listener,s!==r&&a.isPropagationStopped())break e;r=o,a.currentTarget=c;try{r(a)}catch(u){$n(u)}a.currentTarget=null,r=s}else for(i=0;i<n.length;i++){if(s=(o=n[i]).instance,c=o.currentTarget,o=o.listener,s!==r&&a.isPropagationStopped())break e;r=o,a.currentTarget=c;try{r(a)}catch(u){$n(u)}a.currentTarget=null,r=s}}}}function Ju(e,t){var l=t[He];void 0===l&&(l=t[He]=new Set);var n=e+"__bubble";l.has(n)||(ld(t,e,2,!1),l.add(n))}function Zu(e,t,l){var n=0;t&&(n|=4),ld(l,e,n,t)}var ed="_reactListening"+Math.random().toString(36).slice(2);function td(e){if(!e[ed]){e[ed]=!0,nt.forEach(function(t){"selectionchange"!==t&&(Xu.has(t)||Zu(t,!1,e),Zu(t,!0,e))});var t=9===e.nodeType?e:e.ownerDocument;null===t||t[ed]||(t[ed]=!0,Zu("selectionchange",!1,t))}}function ld(e,t,l,n){switch($b(t)){case 2:var a=kb;break;case 8:a=Cb;break;default:a=Sb}l=a.bind(null,t,l,e),a=void 0,!Wt||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(a=!0),n?void 0!==a?e.addEventListener(t,l,{capture:!0,passive:a}):e.addEventListener(t,l,!0):void 0!==a?e.addEventListener(t,l,{passive:a}):e.addEventListener(t,l,!1)}function nd(e,t,l,n,a){var r=n;if(!(1&t||2&t||null===n))e:for(;;){if(null===n)return;var i=n.tag;if(3===i||4===i){var s=n.stateNode.containerInfo;if(s===a)break;if(4===i)for(i=n.return;null!==i;){var c=i.tag;if((3===c||4===c)&&i.stateNode.containerInfo===a)return;i=i.return}for(;null!==s;){if(null===(i=Je(s)))return;if(5===(c=i.tag)||6===c||26===c||27===c){n=r=i;continue e}s=s.parentNode}}n=n.return}Ut(function(){var n=r,a=Pt(l),i=[];e:{var s=jn.get(e);if(void 0!==s){var c=al,u=e;switch(e){case"keypress":if(0===Xt(l))break e;case"keydown":case"keyup":c=yl;break;case"focusin":u="focus",c=ul;break;case"focusout":u="blur",c=ul;break;case"beforeblur":case"afterblur":c=ul;break;case"click":if(2===l.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":c=sl;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":c=cl;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":c=wl;break;case vn:case yn:case xn:c=dl;break;case Sn:c=kl;break;case"scroll":case"scrollend":c=il;break;case"wheel":c=Cl;break;case"copy":case"cut":case"paste":c=bl;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=xl;break;case"toggle":case"beforetoggle":c=Sl}var d=!!(4&t),b=!d&&("scroll"===e||"scrollend"===e),m=d?null!==s?s+"Capture":null:s;d=[];for(var h,p=n;null!==p;){var f=p;if(h=f.stateNode,5!==(f=f.tag)&&26!==f&&27!==f||null===h||null===m||null!=(f=Bt(p,m))&&d.push(ad(p,f,h)),b)break;p=p.return}0<d.length&&(s=new c(s,u,null,l,a),i.push({event:s,listeners:d}))}}if(!(7&t)){if(c="mouseout"===e||"pointerout"===e,(!(s="mouseover"===e||"pointerover"===e)||l===It||!(u=l.relatedTarget||l.fromElement)||!Je(u)&&!u[Ve])&&(c||s)&&(s=a.window===a?a:(s=a.ownerDocument)?s.defaultView||s.parentWindow:window,c?(c=n,null!==(u=(u=l.relatedTarget||l.toElement)?Je(u):null)&&(b=o(u),d=u.tag,u!==b||5!==d&&27!==d&&6!==d)&&(u=null)):(c=null,u=n),c!==u)){if(d=sl,f="onMouseLeave",m="onMouseEnter",p="mouse","pointerout"!==e&&"pointerover"!==e||(d=xl,f="onPointerLeave",m="onPointerEnter",p="pointer"),b=null==c?s:et(c),h=null==u?s:et(u),(s=new d(f,p+"leave",c,l,a)).target=b,s.relatedTarget=h,f=null,Je(a)===n&&((d=new d(m,p+"enter",u,l,a)).target=h,d.relatedTarget=b,f=d),b=f,c&&u)e:{for(d=id,p=u,h=0,f=m=c;f;f=d(f))h++;f=0;for(var g=p;g;g=d(g))f++;for(;0<h-f;)m=d(m),h--;for(;0<f-h;)p=d(p),f--;for(;h--;){if(m===p||null!==p&&m===p.alternate){d=m;break e}m=d(m),p=d(p)}d=null}else d=null;null!==c&&od(i,s,c,d,!1),null!==u&&null!==b&&od(i,b,u,d,!0)}if("select"===(c=(s=n?et(n):window).nodeName&&s.nodeName.toLowerCase())||"input"===c&&"file"===s.type)var v=Bl;else if(Pl(s))if(ql)v=Jl;else{v=Xl;var y=Ql}else!(c=s.nodeName)||"input"!==c.toLowerCase()||"checkbox"!==s.type&&"radio"!==s.type?n&&Tt(n.elementType)&&(v=Bl):v=Yl;switch(v&&(v=v(e,n))?Dl(i,v,l,a):(y&&y(e,s,n),"focusout"===e&&n&&"number"===s.type&&null!=n.memoizedProps.value&&kt(s,"number",s.value)),y=n?et(n):window,e){case"focusin":(Pl(y)||"true"===y.contentEditable)&&(sn=y,cn=n,un=null);break;case"focusout":un=cn=sn=null;break;case"mousedown":dn=!0;break;case"contextmenu":case"mouseup":case"dragend":dn=!1,bn(i,l,a);break;case"selectionchange":if(on)break;case"keydown":case"keyup":bn(i,l,a)}var x;if(Nl)e:{switch(e){case"compositionstart":var w="onCompositionStart";break e;case"compositionend":w="onCompositionEnd";break e;case"compositionupdate":w="onCompositionUpdate";break e}w=void 0}else Ml?zl(e,l)&&(w="onCompositionEnd"):"keydown"===e&&229===l.keyCode&&(w="onCompositionStart");w&&(_l&&"ko"!==l.locale&&(Ml||"onCompositionStart"!==w?"onCompositionEnd"===w&&Ml&&(x=Qt()):(Kt="value"in(Ht=a)?Ht.value:Ht.textContent,Ml=!0)),0<(y=rd(n,w)).length&&(w=new ml(w,e,null,l,a),i.push({event:w,listeners:y}),x?w.data=x:null!==(x=Ll(l))&&(w.data=x))),(x=$l?function(e,t){switch(e){case"compositionend":return Ll(t);case"keypress":return 32!==t.which?null:(Al=!0,Tl);case"textInput":return(e=t.data)===Tl&&Al?null:e;default:return null}}(e,l):function(e,t){if(Ml)return"compositionend"===e||!Nl&&zl(e,t)?(e=Qt(),Gt=Kt=Ht=null,Ml=!1,e):null;switch(e){case"paste":default:return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return _l&&"ko"!==t.locale?null:t.data}}(e,l))&&(0<(w=rd(n,"onBeforeInput")).length&&(y=new ml("onBeforeInput","beforeinput",null,l,a),i.push({event:y,listeners:w}),y.data=x)),function(e,t,l,n,a){if("submit"===t&&l&&l.stateNode===a){var r=Vu((a[We]||null).action),i=n.submitter;i&&null!==(t=(t=i[We]||null)?Vu(t.formAction):i.getAttribute("formAction"))&&(r=t,i=null);var o=new al("action","action",null,n,a);e.push({event:o,listeners:[{instance:null,listener:function(){if(n.defaultPrevented){if(0!==Pu){var e=i?Hu(a,i):new FormData(a);lo(l,{pending:!0,data:e,method:a.method,action:r},null,e)}}else"function"==typeof r&&(o.preventDefault(),e=i?Hu(a,i):new FormData(a),lo(l,{pending:!0,data:e,method:a.method,action:r},r,e))},currentTarget:a}]})}}(i,e,n,l,a)}Yu(i,t)})}function ad(e,t,l){return{instance:e,listener:t,currentTarget:l}}function rd(e,t){for(var l=t+"Capture",n=[];null!==e;){var a=e,r=a.stateNode;if(5!==(a=a.tag)&&26!==a&&27!==a||null===r||(null!=(a=Bt(e,l))&&n.unshift(ad(e,a,r)),null!=(a=Bt(e,t))&&n.push(ad(e,a,r))),3===e.tag)return n;e=e.return}return[]}function id(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag&&27!==e.tag);return e||null}function od(e,t,l,n,a){for(var r=t._reactName,i=[];null!==l&&l!==n;){var o=l,s=o.alternate,c=o.stateNode;if(o=o.tag,null!==s&&s===n)break;5!==o&&26!==o&&27!==o||null===c||(s=c,a?null!=(c=Bt(l,r))&&i.unshift(ad(l,c,s)):a||null!=(c=Bt(l,r))&&i.push(ad(l,c,s))),l=l.return}0!==i.length&&e.push({event:t,listeners:i})}var sd=/\r\n?/g,cd=/\u0000|\uFFFD/g;function ud(e){return("string"==typeof e?e:""+e).replace(sd,"\n").replace(cd,"")}function dd(e,t){return t=ud(t),ud(e)===t}function bd(e,t,l,n,a,i){switch(l){case"children":"string"==typeof n?"body"===t||"textarea"===t&&""===n||Nt(e,n):("number"==typeof n||"bigint"==typeof n)&&"body"!==t&&Nt(e,""+n);break;case"className":dt(e,"class",n);break;case"tabIndex":dt(e,"tabindex",n);break;case"dir":case"role":case"viewBox":case"width":case"height":dt(e,l,n);break;case"style":_t(e,n,i);break;case"data":if("object"!==t){dt(e,"data",n);break}case"src":case"href":if(""===n&&("a"!==t||"href"!==l)){e.removeAttribute(l);break}if(null==n||"function"==typeof n||"symbol"==typeof n||"boolean"==typeof n){e.removeAttribute(l);break}n=Lt(""+n),e.setAttribute(l,n);break;case"action":case"formAction":if("function"==typeof n){e.setAttribute(l,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}if("function"==typeof i&&("formAction"===l?("input"!==t&&bd(e,t,"name",a.name,a,null),bd(e,t,"formEncType",a.formEncType,a,null),bd(e,t,"formMethod",a.formMethod,a,null),bd(e,t,"formTarget",a.formTarget,a,null)):(bd(e,t,"encType",a.encType,a,null),bd(e,t,"method",a.method,a,null),bd(e,t,"target",a.target,a,null))),null==n||"symbol"==typeof n||"boolean"==typeof n){e.removeAttribute(l);break}n=Lt(""+n),e.setAttribute(l,n);break;case"onClick":null!=n&&(e.onclick=Mt);break;case"onScroll":null!=n&&Ju("scroll",e);break;case"onScrollEnd":null!=n&&Ju("scrollend",e);break;case"dangerouslySetInnerHTML":if(null!=n){if("object"!=typeof n||!("__html"in n))throw Error(r(61));if(null!=(l=n.__html)){if(null!=a.children)throw Error(r(60));e.innerHTML=l}}break;case"multiple":e.multiple=n&&"function"!=typeof n&&"symbol"!=typeof n;break;case"muted":e.muted=n&&"function"!=typeof n&&"symbol"!=typeof n;break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":case"autoFocus":break;case"xlinkHref":if(null==n||"function"==typeof n||"boolean"==typeof n||"symbol"==typeof n){e.removeAttribute("xlink:href");break}l=Lt(""+n),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":null!=n&&"function"!=typeof n&&"symbol"!=typeof n?e.setAttribute(l,""+n):e.removeAttribute(l);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":n&&"function"!=typeof n&&"symbol"!=typeof n?e.setAttribute(l,""):e.removeAttribute(l);break;case"capture":case"download":!0===n?e.setAttribute(l,""):!1!==n&&null!=n&&"function"!=typeof n&&"symbol"!=typeof n?e.setAttribute(l,n):e.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":null!=n&&"function"!=typeof n&&"symbol"!=typeof n&&!isNaN(n)&&1<=n?e.setAttribute(l,n):e.removeAttribute(l);break;case"rowSpan":case"start":null==n||"function"==typeof n||"symbol"==typeof n||isNaN(n)?e.removeAttribute(l):e.setAttribute(l,n);break;case"popover":Ju("beforetoggle",e),Ju("toggle",e),ut(e,"popover",n);break;case"xlinkActuate":bt(e,"http://www.w3.org/1999/xlink","xlink:actuate",n);break;case"xlinkArcrole":bt(e,"http://www.w3.org/1999/xlink","xlink:arcrole",n);break;case"xlinkRole":bt(e,"http://www.w3.org/1999/xlink","xlink:role",n);break;case"xlinkShow":bt(e,"http://www.w3.org/1999/xlink","xlink:show",n);break;case"xlinkTitle":bt(e,"http://www.w3.org/1999/xlink","xlink:title",n);break;case"xlinkType":bt(e,"http://www.w3.org/1999/xlink","xlink:type",n);break;case"xmlBase":bt(e,"http://www.w3.org/XML/1998/namespace","xml:base",n);break;case"xmlLang":bt(e,"http://www.w3.org/XML/1998/namespace","xml:lang",n);break;case"xmlSpace":bt(e,"http://www.w3.org/XML/1998/namespace","xml:space",n);break;case"is":ut(e,"is",n);break;case"innerText":case"textContent":break;default:(!(2<l.length)||"o"!==l[0]&&"O"!==l[0]||"n"!==l[1]&&"N"!==l[1])&&ut(e,l=At.get(l)||l,n)}}function md(e,t,l,n,a,i){switch(l){case"style":_t(e,n,i);break;case"dangerouslySetInnerHTML":if(null!=n){if("object"!=typeof n||!("__html"in n))throw Error(r(61));if(null!=(l=n.__html)){if(null!=a.children)throw Error(r(60));e.innerHTML=l}}break;case"children":"string"==typeof n?Nt(e,n):("number"==typeof n||"bigint"==typeof n)&&Nt(e,""+n);break;case"onScroll":null!=n&&Ju("scroll",e);break;case"onScrollEnd":null!=n&&Ju("scrollend",e);break;case"onClick":null!=n&&(e.onclick=Mt);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":case"innerText":case"textContent":break;default:at.hasOwnProperty(l)||("o"!==l[0]||"n"!==l[1]||(a=l.endsWith("Capture"),t=l.slice(2,a?l.length-7:void 0),"function"==typeof(i=null!=(i=e[We]||null)?i[l]:null)&&e.removeEventListener(t,i,a),"function"!=typeof n)?l in e?e[l]=n:!0===n?e.setAttribute(l,""):ut(e,l,n):("function"!=typeof i&&null!==i&&(l in e?e[l]=null:e.hasAttribute(l)&&e.removeAttribute(l)),e.addEventListener(t,n,a)))}}function hd(e,t,l){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ju("error",e),Ju("load",e);var n,a=!1,i=!1;for(n in l)if(l.hasOwnProperty(n)){var o=l[n];if(null!=o)switch(n){case"src":a=!0;break;case"srcSet":i=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:bd(e,t,n,o,l,null)}}return i&&bd(e,t,"srcSet",l.srcSet,l,null),void(a&&bd(e,t,"src",l.src,l,null));case"input":Ju("invalid",e);var s=n=o=i=null,c=null,u=null;for(a in l)if(l.hasOwnProperty(a)){var d=l[a];if(null!=d)switch(a){case"name":i=d;break;case"type":o=d;break;case"checked":c=d;break;case"defaultChecked":u=d;break;case"value":n=d;break;case"defaultValue":s=d;break;case"children":case"dangerouslySetInnerHTML":if(null!=d)throw Error(r(137,t));break;default:bd(e,t,a,d,l,null)}}return void wt(e,n,s,c,u,o,i,!1);case"select":for(i in Ju("invalid",e),a=o=n=null,l)if(l.hasOwnProperty(i)&&null!=(s=l[i]))switch(i){case"value":n=s;break;case"defaultValue":o=s;break;case"multiple":a=s;default:bd(e,t,i,s,l,null)}return t=n,l=o,e.multiple=!!a,void(null!=t?Ct(e,!!a,t,!1):null!=l&&Ct(e,!!a,l,!0));case"textarea":for(o in Ju("invalid",e),n=i=a=null,l)if(l.hasOwnProperty(o)&&null!=(s=l[o]))switch(o){case"value":a=s;break;case"defaultValue":i=s;break;case"children":n=s;break;case"dangerouslySetInnerHTML":if(null!=s)throw Error(r(91));break;default:bd(e,t,o,s,l,null)}return void jt(e,a,i,n);case"option":for(c in l)if(l.hasOwnProperty(c)&&null!=(a=l[c]))if("selected"===c)e.selected=a&&"function"!=typeof a&&"symbol"!=typeof a;else bd(e,t,c,a,l,null);return;case"dialog":Ju("beforetoggle",e),Ju("toggle",e),Ju("cancel",e),Ju("close",e);break;case"iframe":case"object":Ju("load",e);break;case"video":case"audio":for(a=0;a<Qu.length;a++)Ju(Qu[a],e);break;case"image":Ju("error",e),Ju("load",e);break;case"details":Ju("toggle",e);break;case"embed":case"source":case"link":Ju("error",e),Ju("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(u in l)if(l.hasOwnProperty(u)&&null!=(a=l[u]))switch(u){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:bd(e,t,u,a,l,null)}return;default:if(Tt(t)){for(d in l)l.hasOwnProperty(d)&&(void 0!==(a=l[d])&&md(e,t,d,a,l,void 0));return}}for(s in l)l.hasOwnProperty(s)&&(null!=(a=l[s])&&bd(e,t,s,a,l,null))}function pd(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}var fd=null,gd=null;function vd(e){return 9===e.nodeType?e:e.ownerDocument}function yd(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function xd(e,t){if(0===e)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return 1===e&&"foreignObject"===t?0:e}function wd(e,t){return"textarea"===e||"noscript"===e||"string"==typeof t.children||"number"==typeof t.children||"bigint"==typeof t.children||"object"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var kd=null;var Cd="function"==typeof setTimeout?setTimeout:void 0,Sd="function"==typeof clearTimeout?clearTimeout:void 0,jd="function"==typeof Promise?Promise:void 0,Nd="function"==typeof queueMicrotask?queueMicrotask:void 0!==jd?function(e){return jd.resolve(null).then(e).catch(Ed)}:Cd;function Ed(e){setTimeout(function(){throw e})}function $d(e){return"head"===e}function _d(e,t){var l=t,n=0;do{var a=l.nextSibling;if(e.removeChild(l),a&&8===a.nodeType)if("/$"===(l=a.data)||"/&"===l){if(0===n)return e.removeChild(a),void Hb(t);n--}else if("$"===l||"$?"===l||"$~"===l||"$!"===l||"&"===l)n++;else if("html"===l)Fd(e.ownerDocument.documentElement);else if("head"===l){Fd(l=e.ownerDocument.head);for(var r=l.firstChild;r;){var i=r.nextSibling,o=r.nodeName;r[Xe]||"SCRIPT"===o||"STYLE"===o||"LINK"===o&&"stylesheet"===r.rel.toLowerCase()||l.removeChild(r),r=i}}else"body"===l&&Fd(e.ownerDocument.body);l=a}while(l);Hb(t)}function Td(e,t){var l=e;e=0;do{var n=l.nextSibling;if(1===l.nodeType?t?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",""===l.getAttribute("style")&&l.removeAttribute("style")):3===l.nodeType&&(t?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),n&&8===n.nodeType)if("/$"===(l=n.data)){if(0===e)break;e--}else"$"!==l&&"$?"!==l&&"$~"!==l&&"$!"!==l||e++;l=n}while(l)}function Ad(e){var t=e.firstChild;for(t&&10===t.nodeType&&(t=t.nextSibling);t;){var l=t;switch(t=t.nextSibling,l.nodeName){case"HTML":case"HEAD":case"BODY":Ad(l),Ye(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if("stylesheet"===l.rel.toLowerCase())continue}e.removeChild(l)}}function zd(e,t){for(;8!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!t)return null;if(null===(e=Id(e.nextSibling)))return null}return e}function Ld(e){return"$?"===e.data||"$~"===e.data}function Md(e){return"$!"===e.data||"$?"===e.data&&"loading"!==e.ownerDocument.readyState}function Id(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t||"$~"===t||"&"===t||"F!"===t||"F"===t)break;if("/$"===t||"/&"===t)return null}}return e}var Pd=null;function Dd(e){e=e.nextSibling;for(var t=0;e;){if(8===e.nodeType){var l=e.data;if("/$"===l||"/&"===l){if(0===t)return Id(e.nextSibling);t--}else"$"!==l&&"$!"!==l&&"$?"!==l&&"$~"!==l&&"&"!==l||t++}e=e.nextSibling}return null}function Rd(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var l=e.data;if("$"===l||"$!"===l||"$?"===l||"$~"===l||"&"===l){if(0===t)return e;t--}else"/$"!==l&&"/&"!==l||t++}e=e.previousSibling}return null}function Od(e,t,l){switch(t=vd(l),e){case"html":if(!(e=t.documentElement))throw Error(r(452));return e;case"head":if(!(e=t.head))throw Error(r(453));return e;case"body":if(!(e=t.body))throw Error(r(454));return e;default:throw Error(r(451))}}function Fd(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Ye(e)}var Ud=new Map,Bd=new Set;function qd(e){return"function"==typeof e.getRootNode?e.getRootNode():9===e.nodeType?e:e.ownerDocument}var Wd=D.d;D.d={f:function(){var e=Wd.f(),t=tu();return e||t},r:function(e){var t=Ze(e);null!==t&&5===t.tag&&"form"===t.type?ao(t):Wd.r(e)},D:function(e){Wd.D(e),Hd("dns-prefetch",e,null)},C:function(e,t){Wd.C(e,t),Hd("preconnect",e,t)},L:function(e,t,l){Wd.L(e,t,l);var n=Vd;if(n&&e&&t){var a='link[rel="preload"][as="'+yt(t)+'"]';"image"===t&&l&&l.imageSrcSet?(a+='[imagesrcset="'+yt(l.imageSrcSet)+'"]',"string"==typeof l.imageSizes&&(a+='[imagesizes="'+yt(l.imageSizes)+'"]')):a+='[href="'+yt(e)+'"]';var r=a;switch(t){case"style":r=Gd(e);break;case"script":r=Yd(e)}Ud.has(r)||(e=b({rel:"preload",href:"image"===t&&l&&l.imageSrcSet?void 0:e,as:t},l),Ud.set(r,e),null!==n.querySelector(a)||"style"===t&&n.querySelector(Qd(r))||"script"===t&&n.querySelector(Jd(r))||(hd(t=n.createElement("link"),"link",e),lt(t),n.head.appendChild(t)))}},m:function(e,t){Wd.m(e,t);var l=Vd;if(l&&e){var n=t&&"string"==typeof t.as?t.as:"script",a='link[rel="modulepreload"][as="'+yt(n)+'"][href="'+yt(e)+'"]',r=a;switch(n){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":r=Yd(e)}if(!Ud.has(r)&&(e=b({rel:"modulepreload",href:e},t),Ud.set(r,e),null===l.querySelector(a))){switch(n){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Jd(r)))return}hd(n=l.createElement("link"),"link",e),lt(n),l.head.appendChild(n)}}},X:function(e,t){Wd.X(e,t);var l=Vd;if(l&&e){var n=tt(l).hoistableScripts,a=Yd(e),r=n.get(a);r||((r=l.querySelector(Jd(a)))||(e=b({src:e,async:!0},t),(t=Ud.get(a))&&lb(e,t),lt(r=l.createElement("script")),hd(r,"link",e),l.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},n.set(a,r))}},S:function(e,t,l){Wd.S(e,t,l);var n=Vd;if(n&&e){var a=tt(n).hoistableStyles,r=Gd(e);t=t||"default";var i=a.get(r);if(!i){var o={loading:0,preload:null};if(i=n.querySelector(Qd(r)))o.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":t},l),(l=Ud.get(r))&&tb(e,l);var s=i=n.createElement("link");lt(s),hd(s,"link",e),s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),s.addEventListener("load",function(){o.loading|=1}),s.addEventListener("error",function(){o.loading|=2}),o.loading|=4,eb(i,t,n)}i={type:"stylesheet",instance:i,count:1,state:o},a.set(r,i)}}},M:function(e,t){Wd.M(e,t);var l=Vd;if(l&&e){var n=tt(l).hoistableScripts,a=Yd(e),r=n.get(a);r||((r=l.querySelector(Jd(a)))||(e=b({src:e,async:!0,type:"module"},t),(t=Ud.get(a))&&lb(e,t),lt(r=l.createElement("script")),hd(r,"link",e),l.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},n.set(a,r))}}};var Vd="undefined"==typeof document?null:document;function Hd(e,t,l){var n=Vd;if(n&&"string"==typeof t&&t){var a=yt(t);a='link[rel="'+e+'"][href="'+a+'"]',"string"==typeof l&&(a+='[crossorigin="'+l+'"]'),Bd.has(a)||(Bd.add(a),e={rel:e,crossOrigin:l,href:t},null===n.querySelector(a)&&(hd(t=n.createElement("link"),"link",e),lt(t),n.head.appendChild(t)))}}function Kd(e,t,l,n){var a,i,o,s,c=(c=G.current)?qd(c):null;if(!c)throw Error(r(446));switch(e){case"meta":case"title":return null;case"style":return"string"==typeof l.precedence&&"string"==typeof l.href?(t=Gd(l.href),(n=(l=tt(c).hoistableStyles).get(t))||(n={type:"style",instance:null,count:0,state:null},l.set(t,n)),n):{type:"void",instance:null,count:0,state:null};case"link":if("stylesheet"===l.rel&&"string"==typeof l.href&&"string"==typeof l.precedence){e=Gd(l.href);var u=tt(c).hoistableStyles,d=u.get(e);if(d||(c=c.ownerDocument||c,d={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,d),(u=c.querySelector(Qd(e)))&&!u._p&&(d.instance=u,d.state.loading=5),Ud.has(e)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Ud.set(e,l),u||(a=c,i=e,o=l,s=d.state,a.querySelector('link[rel="preload"][as="style"]['+i+"]")?s.loading=1:(i=a.createElement("link"),s.preload=i,i.addEventListener("load",function(){return s.loading|=1}),i.addEventListener("error",function(){return s.loading|=2}),hd(i,"link",o),lt(i),a.head.appendChild(i))))),t&&null===n)throw Error(r(528,""));return d}if(t&&null!==n)throw Error(r(529,""));return null;case"script":return t=l.async,"string"==typeof(l=l.src)&&t&&"function"!=typeof t&&"symbol"!=typeof t?(t=Yd(l),(n=(l=tt(c).hoistableScripts).get(t))||(n={type:"script",instance:null,count:0,state:null},l.set(t,n)),n):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,e))}}function Gd(e){return'href="'+yt(e)+'"'}function Qd(e){return'link[rel="stylesheet"]['+e+"]"}function Xd(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function Yd(e){return'[src="'+yt(e)+'"]'}function Jd(e){return"script[async]"+e}function Zd(e,t,l){if(t.count++,null===t.instance)switch(t.type){case"style":var n=e.querySelector('style[data-href~="'+yt(l.href)+'"]');if(n)return t.instance=n,lt(n),n;var a=b({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return lt(n=(e.ownerDocument||e).createElement("style")),hd(n,"style",a),eb(n,l.precedence,e),t.instance=n;case"stylesheet":a=Gd(l.href);var i=e.querySelector(Qd(a));if(i)return t.state.loading|=4,t.instance=i,lt(i),i;n=Xd(l),(a=Ud.get(a))&&tb(n,a),lt(i=(e.ownerDocument||e).createElement("link"));var o=i;return o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),hd(i,"link",n),t.state.loading|=4,eb(i,l.precedence,e),t.instance=i;case"script":return i=Yd(l.src),(a=e.querySelector(Jd(i)))?(t.instance=a,lt(a),a):(n=l,(a=Ud.get(i))&&lb(n=b({},l),a),lt(a=(e=e.ownerDocument||e).createElement("script")),hd(a,"link",n),e.head.appendChild(a),t.instance=a);case"void":return null;default:throw Error(r(443,t.type))}else"stylesheet"===t.type&&!(4&t.state.loading)&&(n=t.instance,t.state.loading|=4,eb(n,l.precedence,e));return t.instance}function eb(e,t,l){for(var n=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),a=n.length?n[n.length-1]:null,r=a,i=0;i<n.length;i++){var o=n[i];if(o.dataset.precedence===t)r=o;else if(r!==a)break}r?r.parentNode.insertBefore(e,r.nextSibling):(t=9===l.nodeType?l.head:l).insertBefore(e,t.firstChild)}function tb(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.title&&(e.title=t.title)}function lb(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.integrity&&(e.integrity=t.integrity)}var nb=null;function ab(e,t,l){if(null===nb){var n=new Map,a=nb=new Map;a.set(l,n)}else(n=(a=nb).get(l))||(n=new Map,a.set(l,n));if(n.has(e))return n;for(n.set(e,null),l=l.getElementsByTagName(e),a=0;a<l.length;a++){var r=l[a];if(!(r[Xe]||r[qe]||"link"===e&&"stylesheet"===r.getAttribute("rel"))&&"http://www.w3.org/2000/svg"!==r.namespaceURI){var i=r.getAttribute(t)||"";i=e+i;var o=n.get(i);o?o.push(r):n.set(i,[r])}}return n}function rb(e,t,l){(e=e.ownerDocument||e).head.insertBefore(l,"title"===t?e.querySelector("head > title"):null)}function ib(e){return!!("stylesheet"!==e.type||3&e.state.loading)}var ob=0;function sb(){if(this.count--,0===this.count&&(0===this.imgCount||!this.waitingForImages))if(this.stylesheets)ub(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}var cb=null;function ub(e,t){e.stylesheets=null,null!==e.unsuspend&&(e.count++,cb=new Map,t.forEach(db,e),cb=null,sb.call(e))}function db(e,t){if(!(4&t.state.loading)){var l=cb.get(e);if(l)var n=l.get(null);else{l=new Map,cb.set(e,l);for(var a=e.querySelectorAll("link[data-precedence],style[data-precedence]"),r=0;r<a.length;r++){var i=a[r];"LINK"!==i.nodeName&&"not all"===i.getAttribute("media")||(l.set(i.dataset.precedence,i),n=i)}n&&l.set(null,n)}i=(a=t.instance).getAttribute("data-precedence"),(r=l.get(i)||n)===n&&l.set(null,a),l.set(i,a),this.count++,n=sb.bind(this),a.addEventListener("load",n),a.addEventListener("error",n),r?r.parentNode.insertBefore(a,r.nextSibling):(e=9===e.nodeType?e.head:e).insertBefore(a,e.firstChild),t.state.loading|=4}}var bb={$$typeof:k,Provider:null,Consumer:null,_currentValue:R,_currentValue2:R,_threadCount:0};function mb(e,t,l,n,a,r,i,o,s){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Le(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Le(0),this.hiddenUpdates=Le(null),this.identifierPrefix=n,this.onUncaughtError=a,this.onCaughtError=r,this.onRecoverableError=i,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=s,this.incompleteTransitions=new Map}function hb(e,t,l,n,a,r,i,o,s,c,u,d){return e=new mb(e,t,l,i,s,c,u,d,o),t=1,!0===r&&(t|=24),r=Fn(3,null,null,t),e.current=r,r.stateNode=e,(t=Ua()).refCount++,e.pooledCache=t,t.refCount++,r.memoizedState={element:n,isDehydrated:l,cache:t},vr(r),e}function pb(e){return e?e=Rn:Rn}function fb(e,t,l,n,a,r){a=pb(a),null===n.context?n.context=a:n.pendingContext=a,(n=xr(t)).payload={element:l},null!==(r=void 0===r?null:r)&&(n.callback=r),null!==(l=wr(e,n,t))&&(Xc(l,0,t),kr(l,e,t))}function gb(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var l=e.retryLane;e.retryLane=0!==l&&l<t?l:t}}function vb(e,t){gb(e,t),(e=e.alternate)&&gb(e,t)}function yb(e){if(13===e.tag||31===e.tag){var t=In(e,67108864);null!==t&&Xc(t,0,67108864),vb(e,67108864)}}function xb(e){if(13===e.tag||31===e.tag){var t=Gc(),l=In(e,t=Re(t));null!==l&&Xc(l,0,t),vb(e,t)}}var wb=!0;function kb(e,t,l,n){var a=P.T;P.T=null;var r=D.p;try{D.p=2,Sb(e,t,l,n)}finally{D.p=r,P.T=a}}function Cb(e,t,l,n){var a=P.T;P.T=null;var r=D.p;try{D.p=8,Sb(e,t,l,n)}finally{D.p=r,P.T=a}}function Sb(e,t,l,n){if(wb){var a=jb(n);if(null===a)nd(e,t,n,Nb,l),Db(e,n);else if(function(e,t,l,n,a){switch(t){case"focusin":return Tb=Rb(Tb,e,t,l,n,a),!0;case"dragenter":return Ab=Rb(Ab,e,t,l,n,a),!0;case"mouseover":return zb=Rb(zb,e,t,l,n,a),!0;case"pointerover":var r=a.pointerId;return Lb.set(r,Rb(Lb.get(r)||null,e,t,l,n,a)),!0;case"gotpointercapture":return r=a.pointerId,Mb.set(r,Rb(Mb.get(r)||null,e,t,l,n,a)),!0}return!1}(a,e,t,l,n))n.stopPropagation();else if(Db(e,n),4&t&&-1<Pb.indexOf(e)){for(;null!==a;){var r=Ze(a);if(null!==r)switch(r.tag){case 3:if((r=r.stateNode).current.memoizedState.isDehydrated){var i=$e(r.pendingLanes);if(0!==i){var o=r;for(o.pendingLanes|=2,o.entangledLanes|=2;i;){var s=1<<31-ke(i);o.entanglements[1]|=s,i&=~s}Du(r),!(6&pc)&&(Pc=ue()+500,Ru(0))}}break;case 31:case 13:null!==(o=In(r,2))&&Xc(o,0,2),tu(),vb(r,2)}if(null===(r=jb(n))&&nd(e,t,n,Nb,l),r===a)break;a=r}null!==a&&n.stopPropagation()}else nd(e,t,n,null,l)}}function jb(e){return Eb(e=Pt(e))}var Nb=null;function Eb(e){if(Nb=null,null!==(e=Je(e))){var t=o(e);if(null===t)e=null;else{var l=t.tag;if(13===l){if(null!==(e=s(t)))return e;e=null}else if(31===l){if(null!==(e=c(t)))return e;e=null}else if(3===l){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Nb=e,null}function $b(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(de()){case be:return 2;case me:return 8;case he:case pe:return 32;case fe:return 268435456;default:return 32}default:return 32}}var _b=!1,Tb=null,Ab=null,zb=null,Lb=new Map,Mb=new Map,Ib=[],Pb="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Db(e,t){switch(e){case"focusin":case"focusout":Tb=null;break;case"dragenter":case"dragleave":Ab=null;break;case"mouseover":case"mouseout":zb=null;break;case"pointerover":case"pointerout":Lb.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Mb.delete(t.pointerId)}}function Rb(e,t,l,n,a,r){return null===e||e.nativeEvent!==r?(e={blockedOn:t,domEventName:l,eventSystemFlags:n,nativeEvent:r,targetContainers:[a]},null!==t&&(null!==(t=Ze(t))&&yb(t)),e):(e.eventSystemFlags|=n,t=e.targetContainers,null!==a&&-1===t.indexOf(a)&&t.push(a),e)}function Ob(e){var t=Je(e.target);if(null!==t){var l=o(t);if(null!==l)if(13===(t=l.tag)){if(null!==(t=s(l)))return e.blockedOn=t,void Ue(e.priority,function(){xb(l)})}else if(31===t){if(null!==(t=c(l)))return e.blockedOn=t,void Ue(e.priority,function(){xb(l)})}else if(3===t&&l.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===l.tag?l.stateNode.containerInfo:null)}e.blockedOn=null}function Fb(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var l=jb(e.nativeEvent);if(null!==l)return null!==(t=Ze(l))&&yb(t),e.blockedOn=l,!1;var n=new(l=e.nativeEvent).constructor(l.type,l);It=n,l.target.dispatchEvent(n),It=null,t.shift()}return!0}function Ub(e,t,l){Fb(e)&&l.delete(t)}function Bb(){_b=!1,null!==Tb&&Fb(Tb)&&(Tb=null),null!==Ab&&Fb(Ab)&&(Ab=null),null!==zb&&Fb(zb)&&(zb=null),Lb.forEach(Ub),Mb.forEach(Ub)}function qb(e,t){e.blockedOn===t&&(e.blockedOn=null,_b||(_b=!0,l.unstable_scheduleCallback(l.unstable_NormalPriority,Bb)))}var Wb=null;function Vb(e){Wb!==e&&(Wb=e,l.unstable_scheduleCallback(l.unstable_NormalPriority,function(){Wb===e&&(Wb=null);for(var t=0;t<e.length;t+=3){var l=e[t],n=e[t+1],a=e[t+2];if("function"!=typeof n){if(null===Eb(n||l))continue;break}var r=Ze(l);null!==r&&(e.splice(t,3),t-=3,lo(r,{pending:!0,data:a,method:l.method,action:n},n,a))}}))}function Hb(e){function t(t){return qb(t,e)}null!==Tb&&qb(Tb,e),null!==Ab&&qb(Ab,e),null!==zb&&qb(zb,e),Lb.forEach(t),Mb.forEach(t);for(var l=0;l<Ib.length;l++){var n=Ib[l];n.blockedOn===e&&(n.blockedOn=null)}for(;0<Ib.length&&null===(l=Ib[0]).blockedOn;)Ob(l),null===l.blockedOn&&Ib.shift();if(null!=(l=(e.ownerDocument||e).$$reactFormReplay))for(n=0;n<l.length;n+=3){var a=l[n],r=l[n+1],i=a[We]||null;if("function"==typeof r)i||Vb(l);else if(i){var o=null;if(r&&r.hasAttribute("formAction")){if(a=r,i=r[We]||null)o=i.formAction;else if(null!==Eb(a))continue}else o=i.action;"function"==typeof o?l[n+1]=o:(l.splice(n,3),n-=3),Vb(l)}}}function Kb(){function e(e){e.canIntercept&&"react-transition"===e.info&&e.intercept({handler:function(){return new Promise(function(e){return a=e})},focusReset:"manual",scroll:"manual"})}function t(){null!==a&&(a(),a=null),n||setTimeout(l,20)}function l(){if(!n&&!navigation.transition){var e=navigation.currentEntry;e&&null!=e.url&&navigation.navigate(e.url,{state:e.getState(),info:"react-transition",history:"replace"})}}if("object"==typeof navigation){var n=!1,a=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(l,100),function(){n=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),null!==a&&(a(),a=null)}}}function Gb(e){this._internalRoot=e}function Qb(e){this._internalRoot=e}Qb.prototype.render=Gb.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(r(409));fb(t.current,Gc(),e,t,null,null)},Qb.prototype.unmount=Gb.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;fb(e.current,2,null,e,null,null),tu(),t[Ve]=null}},Qb.prototype.unstable_scheduleHydration=function(e){if(e){var t=Fe();e={blockedOn:null,target:e,priority:t};for(var l=0;l<Ib.length&&0!==t&&t<Ib[l].priority;l++);Ib.splice(l,0,e),0===l&&Ob(e)}};var Xb=n.version;if("19.2.3"!==Xb)throw Error(r(527,Xb,"19.2.3"));D.findDOMNode=function(e){var t=e._reactInternals;if(void 0===t){if("function"==typeof e.render)throw Error(r(188));throw e=Object.keys(e).join(","),Error(r(268,e))}return e=function(e){var t=e.alternate;if(!t){if(null===(t=o(e)))throw Error(r(188));return t!==e?null:e}for(var l=e,n=t;;){var a=l.return;if(null===a)break;var i=a.alternate;if(null===i){if(null!==(n=a.return)){l=n;continue}break}if(a.child===i.child){for(i=a.child;i;){if(i===l)return u(a),e;if(i===n)return u(a),t;i=i.sibling}throw Error(r(188))}if(l.return!==n.return)l=a,n=i;else{for(var s=!1,c=a.child;c;){if(c===l){s=!0,l=a,n=i;break}if(c===n){s=!0,n=a,l=i;break}c=c.sibling}if(!s){for(c=i.child;c;){if(c===l){s=!0,l=i,n=a;break}if(c===n){s=!0,n=i,l=a;break}c=c.sibling}if(!s)throw Error(r(189))}}if(l.alternate!==n)throw Error(r(190))}if(3!==l.tag)throw Error(r(188));return l.stateNode.current===l?e:t}(t),e=null===(e=null!==e?d(e):null)?null:e.stateNode};var Yb={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:P,reconcilerVersion:"19.2.3"};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var Jb=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Jb.isDisabled&&Jb.supportsFiber)try{ye=Jb.inject(Yb),xe=Jb}catch(em){}}return w.createRoot=function(e,t){if(!i(e))throw Error(r(299));var l=!1,n="",a=No,o=Eo,s=$o;return null!=t&&(!0===t.unstable_strictMode&&(l=!0),void 0!==t.identifierPrefix&&(n=t.identifierPrefix),void 0!==t.onUncaughtError&&(a=t.onUncaughtError),void 0!==t.onCaughtError&&(o=t.onCaughtError),void 0!==t.onRecoverableError&&(s=t.onRecoverableError)),t=hb(e,1,!1,null,0,l,n,null,a,o,s,Kb),e[Ve]=t.current,td(e),new Gb(t)},w.hydrateRoot=function(e,t,l){if(!i(e))throw Error(r(299));var n=!1,a="",o=No,s=Eo,c=$o,u=null;return null!=l&&(!0===l.unstable_strictMode&&(n=!0),void 0!==l.identifierPrefix&&(a=l.identifierPrefix),void 0!==l.onUncaughtError&&(o=l.onUncaughtError),void 0!==l.onCaughtError&&(s=l.onCaughtError),void 0!==l.onRecoverableError&&(c=l.onRecoverableError),void 0!==l.formState&&(u=l.formState)),(t=hb(e,1,!0,t,0,n,a,u,o,s,c,Kb)).context=pb(null),l=t.current,(a=xr(n=Re(n=Gc()))).callback=null,wr(l,a,n),l=n,t.current.lanes=l,Me(t,l),Du(t),e[Ve]=t.current,td(e),new Qb(t)},w.version="19.2.3",w}var N=(y||(y=1,function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}(),x.exports=j()),x.exports);const E=new class{constructor(){this.supportsContainerQueries=this.detectContainerQueries(),this.init()}detectContainerQueries(){if("undefined"==typeof window)return!1;try{if("CSS"in window&&"supports"in window.CSS)return window.CSS.supports("container-type","inline-size");const e=document.createElement("div");return e.style.containerType="inline-size","inline-size"===e.style.containerType}catch{return!1}}init(){"undefined"!=typeof window&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>this.applyClasses()):this.applyClasses())}applyClasses(){document.querySelectorAll(".limbo-component-container-wrapper").forEach(e=>{this.supportsContainerQueries?(e.classList.add("container-queries-supported"),e.classList.remove("container-queries-fallback")):(e.classList.add("container-queries-fallback"),e.classList.remove("container-queries-supported"))}),this.supportsContainerQueries?(document.body.classList.add("container-queries-supported"),document.body.classList.remove("container-queries-fallback")):(document.body.classList.add("container-queries-fallback"),document.body.classList.remove("container-queries-supported"))}getContainerWidth(e){if(!e)return window.innerWidth;let t=e.closest(".limbo-component-container-wrapper");return t||(t=e.closest(".limbo-modal-content")),t||(t=e.closest(".limbo-modal")),t||(t=document.body),t.offsetWidth||t.clientWidth}shouldUseMobileStyles(e,t=768){return this.getContainerWidth(e)<=t}applyResponsiveClasses(e){if(this.supportsContainerQueries)return;const t=this.shouldUseMobileStyles(e),l=this.shouldUseMobileStyles(e,1024)&&!t;e.classList.toggle("limbo-mobile-fallback",t),e.classList.toggle("limbo-tablet-fallback",l),e.classList.toggle("limbo-desktop-fallback",!t&&!l)}observeResize(){if(!this.supportsContainerQueries)if("ResizeObserver"in window){const e=new ResizeObserver(e=>{e.forEach(e=>{this.applyResponsiveClasses(e.target)})});document.querySelectorAll(".limbo-component-container-wrapper").forEach(t=>{e.observe(t)})}else window.addEventListener("resize",()=>{document.querySelectorAll(".limbo-component-container-wrapper").forEach(e=>{this.applyResponsiveClasses(e)})})}};function $(t={}){const{useContainerQuery:l=!1,containerElement:n=null}=t,[a,r]=e.useState(()=>{const e=l&&n?E.getContainerWidth(n):"undefined"!=typeof window?window.innerWidth:0,t="undefined"!=typeof window&&(e<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)),a="undefined"!=typeof window&&("ontouchstart"in window||navigator.maxTouchPoints>0);return{isMobile:t,isTouch:a,isTablet:"undefined"!=typeof window&&(e>768&&e<=1024&&a),orientation:"undefined"!=typeof window?window.innerHeight>window.innerWidth?"portrait":"landscape":"portrait",viewport:{width:"undefined"!=typeof window?window.innerWidth:0,height:"undefined"!=typeof window?window.innerHeight:0},container:{width:e,supportsContainerQueries:E.supportsContainerQueries}}});e.useEffect(()=>{if("undefined"==typeof window)return;const e=()=>{const e=window.innerWidth,t=window.innerHeight,a=l&&n?E.getContainerWidth(n):e,i=a<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),o="ontouchstart"in window||navigator.maxTouchPoints>0;r({isMobile:i,isTouch:o,isTablet:a>768&&a<=1024&&o,orientation:t>e?"portrait":"landscape",viewport:{width:e,height:t},container:{width:a,supportsContainerQueries:E.supportsContainerQueries}})};let t;const a=()=>{clearTimeout(t),t=setTimeout(e,150)};return window.addEventListener("resize",a),window.addEventListener("orientationchange",()=>{setTimeout(e,100)}),()=>{clearTimeout(t),window.removeEventListener("resize",a),window.removeEventListener("orientationchange",e)}},[l,n]);const i="portrait"===a.orientation,o="landscape"===a.orientation,s=a.isMobile||a.isTablet&&i;return{...a,isPortrait:i,isLandscape:o,isCompactMode:s,isMobileSize:a.viewport.width<=640,isTabletSize:a.viewport.width>640&&a.viewport.width<=1024,isDesktopSize:a.viewport.width>1024,deviceClass:a.isMobile?"mobile":a.isTablet?"tablet":"desktop"}}function _({tabs:e,active:t,onChange:n}){const{isMobile:a,isTouch:r}=$(),i=["limbo-tabs","lb:flex","lb:gap-4","lb:border-b-2","lb:border-brand-blue-200","lb:mb-6",a&&"lb:overflow-x-auto lb:scrollbar-none"].filter(Boolean).join(" "),o=e=>{const t=["limbo-tab","lb:relative","lb:px-6","lb:py-2","lb:font-medium","lb:text-brand-blue-1000","lb:bg-transparent","lb:border-0","lb:border-b-2","lb:cursor-pointer","lb:transition-all","lb:duration-200","lb:hover:text-pink-1000","lb:focus:outline-none","lb:focus-visible:ring-2","lb:focus-visible:ring-brand-blue-400","lb:focus-visible:ring-offset-2","lb:min-h-[44px]","lb:min-w-[44px]"];return e?t.push("lb:border-b-brand-blue-1000","lb:font-semibold","limbo-active"):t.push("lb:border-b-transparent"),a&&t.push("lb:min-w-[120px]","lb:text-base","lb:shrink-0"),r&&t.push("lb:touch-manipulation"),t.join(" ")};return l.jsx("div",{className:i,role:"tablist","aria-label":"Opciones de navegación",style:a?{WebkitOverflowScrolling:"touch",scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,children:e.map(a=>{const i=t===a.id;return!i&&a.hideNonActive?null:l.jsx("button",{"data-tab-id":a.id,onClick:()=>n(a.id),onKeyDown:t=>((t,l)=>{const a=e.findIndex(e=>e.id===l);let r=a;switch(t.key){case"ArrowLeft":case"ArrowUp":t.preventDefault(),r=a>0?a-1:e.length-1;break;case"ArrowRight":case"ArrowDown":t.preventDefault(),r=a<e.length-1?a+1:0;break;case"Home":t.preventDefault(),r=0;break;case"End":t.preventDefault(),r=e.length-1;break;case"Enter":case" ":return t.preventDefault(),void n(l);default:return}const i=e[r];i&&!i.hideNonActive&&(n(i.id),setTimeout(()=>{const e=document.querySelector(`[data-tab-id="${i.id}"]`);e&&e.focus()},0))})(t,a.id),className:o(i),role:"tab","aria-selected":i,"aria-controls":`tabpanel-${a.id}`,tabIndex:i?0:-1,id:`tab-${a.id}`,style:r?{WebkitTapHighlightColor:"transparent"}:void 0,children:a.label},a.id)})})}function T({isOpen:e,onReload:t,onClose:n}){return e?l.jsx("div",{className:"lb:fixed lb:inset-0 lb:bg-black/50 lb:flex lb:items-center lb:justify-center lb:z-[9999]",onClick:e=>{e.target===e.currentTarget&&n?.()},children:l.jsxs("div",{className:"lb:bg-white lb:rounded-lg lb:p-6 lb:max-w-sm lb:w-full lb:mx-4 lb:shadow-xl",children:[l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-3 lb:mb-4",children:[l.jsx("div",{className:"lb:flex-shrink-0 lb:w-10 lb:h-10 lb:bg-amber-100 lb:rounded-full lb:flex lb:items-center lb:justify-center",children:l.jsx("svg",{className:"lb:w-5 lb:h-5 lb:text-amber-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"})})}),l.jsxs("div",{children:[l.jsx("h3",{className:"lb:text-base lb:font-semibold lb:text-gray-900",children:"Sesión expirada"}),l.jsx("p",{className:"lb:text-sm lb:text-gray-500 lb:mt-0.5",children:"Tu sesión de Limbo ha caducado por inactividad."})]})]}),l.jsxs("div",{className:"lb:bg-amber-50 lb:rounded-md lb:p-3 lb:mb-5 lb:text-sm lb:text-amber-800",children:[l.jsx("p",{className:"lb:font-medium lb:mb-1",children:"¿Qué puedes hacer?"}),l.jsxs("ul",{className:"lb:list-disc lb:list-inside lb:space-y-1 lb:text-amber-700",children:[l.jsx("li",{children:"Recarga la página para continuar con tu trabajo."}),l.jsx("li",{children:"Si el problema persiste, cierra sesión y vuelve a entrar."})]})]}),l.jsxs("div",{className:"lb:flex lb:justify-end lb:gap-2",children:[n&&l.jsx("button",{type:"button",onClick:n,className:"lb:px-4 lb:py-2 lb:text-sm lb:font-medium lb:text-gray-700 lb:border lb:border-gray-300 lb:rounded-md lb:hover:bg-gray-50 lb:transition-colors",children:"Ignorar"}),l.jsx("button",{type:"button",onClick:t,className:"lb:px-4 lb:py-2 lb:text-sm lb:font-medium lb:bg-brand-blue-800 lb:text-white lb:rounded-md lb:hover:bg-brand-blue-1000 lb:transition-colors",children:"Recargar página"})]})]})}):null}function A(t,l=500){const[n,a]=e.useState(t);return e.useEffect(()=>{const e=setTimeout(()=>{a(t)},l);return()=>{clearTimeout(e)}},[t,l]),n}const z="https://led-dev-limbo-dev.eu.els.local",L="https://limbo.lefebvre.es";let M={publicKey:null,token:null,authMode:null,tokenEndpoint:null,tokenProvider:null,prod:!1},I=!1,P=null,D=null;function R(e){P="number"==typeof e&&e>0?Date.now()+1e3*e-3e4:null}async function O(){if(D)return D;D=(async()=>{if("jwt"===M.authMode&&M.tokenProvider){console.log("🔑 Calling tokenProvider...");const e=await M.tokenProvider(),t="string"==typeof e?e:e?.token,l="object"==typeof e?e?.expires_in:null;if(!t)throw new Error("tokenProvider returned no token");return M.token=t,R(l),console.log("✅ Token obtained from tokenProvider"),t}if("session"===M.authMode){const e=F(M),t=M.tokenEndpoint||"/auth/token",l=await fetch(`${e}${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({public_key:M.publicKey}),credentials:"include"});if(!l.ok)throw new Error(`Session auth failed: ${l.status}`);const n=await l.json();if(!n.token)throw new Error("Session auth returned no token");return M.token=n.token,R(n.expires_in),n.token}throw new Error(`Cannot refresh token in authMode='${M.authMode}'`)})();try{return await D}finally{D=null}}function F({prod:e=!1}={}){return e?L:z}async function U({isFormData:e=!1,useJWT:t=!0,customHeaders:l={}}={}){const n={};if(e||(n["Content-Type"]="application/json"),t){M.token&&null!==P&&Date.now()>=P&&(console.log("⏰ Token caducado por TTL, refrescando proactivamente"),M.token=null,P=null);let e=M.token;if(!e&&("jwt"===M.authMode&&M.tokenProvider||"session"===M.authMode))try{e=await O()}catch(a){throw console.error("❌ Token acquisition failed:",a),new Error("Failed to obtain token: "+a.message)}e?n.Authorization=`Bearer ${e}`:console.warn("⚠️ No JWT token available:",{authMode:M.authMode,hasPublicKey:!!M.publicKey,hasTokenProvider:!!M.tokenProvider})}return e&&delete n["Content-Type"],{...n,...l}}function B(e,t=null){e!==M.token&&(I=!1),M.token=e,R(t)}function q(){return{...M}}async function W({endpoint:e,method:t="GET",body:l=null,prod:n=!1,basePath:a="",customHeaders:r={},isFormData:i=!1,useJWT:o=!0,_isRetry:s=!1}){try{const c=n||M.prod,u=await U({isFormData:i,useJWT:o,customHeaders:r});"GET"===t&&!l&&u["Content-Type"]&&delete u["Content-Type"];const d=await fetch(`${F({prod:c})}${a}${e}`,{method:t,headers:u,body:l?i?l:JSON.stringify(l):void 0,credentials:"include"});if(204===d.status)return{success:!0,data:null,message:"No content",httpCode:204,timestamp:(new Date).toISOString()};if(!d.ok){let c=`HTTP ${d.status}: ${d.statusText}`,u=null;try{const e=await d.json();u=e,e.error?c=`${e.error.code}: ${e.error.message}`:e.message&&(c=e.message)}catch{}if(401===d.status){let c=!1;if("jwt"===M.authMode&&M.tokenProvider&&!s&&I){c=!0,M.token=null,P=null;try{return await O(),W({endpoint:e,method:t,body:l,prod:n,basePath:a,isFormData:i,useJWT:o,customHeaders:r,_isRetry:!0})}catch{}}window.dispatchEvent(new CustomEvent("tokenExpiredError",{detail:{error:{response:{status:401,data:u}},refreshAttempted:c}}))}throw new Error(c)}return o&&(I=!0),d.json()}catch(c){throw new Error(`API Error: ${c.message}`)}}function V(){const e=q();return e?.prod||!1?"https://limbo.lefebvre.es":"https://led-dev-limbo-dev.eu.els.local"}function H(e){if(!e?.id)return null;return`${V()}/api/assets/${e.id}/download`}function K(e){if(!e)return null;if(e.startsWith("http://")||e.startsWith("https://"))return e;if(e.startsWith("/")){return`${V()}${e}`}return e}function G(e){if(!e?.success||!e?.data)return{result:null};const t=e.data;return{result:{id:t.id,filename:t.filename||t.original_filename,mime_type:t.mime_type,file_size:t.file_size,width:t.width,height:t.height,upload_date:t.upload_date||t.created_at,processed_date:t.processed_date,processing_status:t.processing_status||t.status,url:K(t.url)||H(t),url_webp:K(t.url_webp),url_original:K(t.url_original),format:t.format,format_original:t.format_original,permanent:t.permanent??!0,expires_at:t.expires_at,metadata:t.metadata||{},asset_type:t.asset_type||null,asset_subtype:t.asset_subtype||null,thumbnail_url:K(t.thumbnail_url)||null,folder:t.folder||null,tags:t.tags||[],variants:Q(t.variants||[]),variants_count:t.variants_count||t.variants?.length||0}}}function Q(e){return Array.isArray(e)?e.map(e=>({id:e.id,name:e.name,width:e.width,height:e.height,format:e.format||e.output_format,file_size:e.file_size,crop_params:e.crop_params,url:K(e.url),permanent:e.permanent??!0,expires_at:e.expires_at,created_at:e.created_at})):[]}function X(e){if(!e?.success||!e?.data)return{result:null};const t=e.data;if(t.id&&t.url&&t.name&&!t.processing_mode&&!t.variants)return console.log("[adaptVariantGenerationFromV2] Detectado formato de /variants/upload"),{result:{id:t.id,name:t.name,width:t.width,height:t.height,format:t.format,file_size:t.file_size,url:t.url,urlSigned:t.url,status:"completed",created_at:t.created_at||(new Date).toISOString()}};if("sync"===t.processing_mode&&t.variants&&t.variants.length>0){const e=t.variants[0];return{result:{id:e.id||null,name:e.name,width:parseInt(e.size?.split("x")[0])||e.width,height:parseInt(e.size?.split("x")[1])||e.height,format:e.format,file_size:e.file_size,url:e.url,urlSigned:e.url,status:e.status,asset_id:t.asset_id,created_at:e.created_at||(new Date).toISOString(),all_variants:t.variants}}}return{result:{job_id:t.job_id,asset_id:t.asset_id,variants_requested:t.variants_requested||[],processing_mode:t.processing_mode||"async",estimated_completion:t.estimated_completion,variant_statuses:(t.variant_statuses||t.variants||[]).map(e=>({name:e.name,status:e.status,size:e.expected_size||e.size,format:e.format}))}}}function Y(e){if(e.message&&!e.message.includes("API Error:"))return e;let t=e.message||"Unknown API error";return t.startsWith("API Error: ")&&(t=t.substring(11)),new Error(t)}const J="/api";async function Z(e={}){try{const t={url_expires:"0",...e},l=`/assets?${new URLSearchParams(t).toString()}`;return function(e){if(!e?.success||!Array.isArray(e?.data?.data))return{result:[]};const t={result:e.data.data.map(e=>({id:e.id,filename:e.filename||e.original_filename,mime_type:e.mime_type,file_size:e.file_size,width:e.width,height:e.height,upload_date:e.upload_date||e.created_at,processing_status:e.processing_status||e.status,variants:e.variants_count&&(Q(e.variants)||Q(e.image_variants))||[],url:K(e.url)||H(e),url_webp:K(e.url_webp),format:e.format,permanent:e.permanent??!0,expires_at:e.expires_at,folder:e.folder||null,tags:e.tags||[],asset_type:e.asset_type||null,asset_subtype:e.asset_subtype||null,thumbnail_url:K(e.thumbnail_url)||null,metadata:e.metadata||{},variants_count:e.variants_count||0}))};return e.data.pagination&&(t.pagination={page:e.data.pagination.page,limit:e.data.pagination.limit,total:e.data.pagination.total,pages:e.data.pagination.pages}),t}(await W({endpoint:l,method:"GET",basePath:J,useJWT:!0}))}catch(t){throw Y(t)}}async function ee(e,t=null,l=!1,n=null,a=null){try{const r=new FormData;r.append("file",e),t&&r.append("uploaded_by",t),l&&r.append("store_original",l.toString()),n&&r.append("folder",n),a&&Array.isArray(a)&&a.length>0&&a.forEach(e=>r.append("tags[]",e));return function(e){if(!e?.success||!e?.data)return{result:null};const t=e.data;return{result:{id:t.id,filename:t.filename||t.original_filename,mime_type:t.mime_type,file_size:t.file_size,width:t.width,height:t.height,status:t.status,upload_date:t.created_at,url:K(t.url),url_webp:K(t.url_webp),url_original:K(t.url_original),format:t.format,format_original:t.format_original,permanent:t.permanent??!0,folder:t.folder||null,tags:t.tags||[],processing:t.processing||{master_webp:"processing"===t.status?"queued":"completed",variants:"processing"===t.status?"queued":"completed"},asset_type:t.asset_type||null,asset_subtype:t.asset_subtype||null,thumbnail_url:K(t.thumbnail_url)||null,checksum:t.checksum,storage_path:t.storage_path_base,metadata:t.metadata||{}}}}(await W({endpoint:"/assets",method:"POST",body:r,basePath:J,isFormData:!0,useJWT:!0}))}catch(r){throw Y(r)}}async function te(e,t){try{return G(await W({endpoint:`/assets/${e}`,method:"PATCH",body:t,basePath:J,useJWT:!0}))}catch(l){throw Y(l)}}async function le(e,t=0){try{const n=new URLSearchParams({url_expires:t.toString()}),a=await W({endpoint:`/assets/${e}/variants?${n}`,method:"GET",basePath:J,useJWT:!0});return l=a,l?.success&&Array.isArray(l?.data?.variants)?{result:l.data.variants.map(e=>({id:e.id,name:e.filename||e.name||`Variante ${e.id}`,filename:e.filename,mime_type:e.mime_type,format:e.format||e.output_format||(e.mime_type?e.mime_type.split("/")[1]:"jpg"),file_size:e.file_size,width:e.width,height:e.height,upload_date:e.upload_date||e.created_at,processing_status:e.processing_status||e.status,url:K(e.url)||H(e),permanent:e.permanent??!0,expires_at:e.expires_at,metadata:e.metadata||{},crop_data:e.crop_data||{},crop_params:e.crop_params||e.crop_data||{},parent_asset_id:e.parent_asset_id||l.data.asset_id,variant_type:e.variant_type||"crop"}))}:{result:[]}}catch(n){throw Y(n)}var l}function ne({value:t=[],onChange:n,placeholder:a,disabled:r=!1,id:i,ariaLabel:o}){const s=Array.isArray(t)?t:[],[c,u]=e.useState(""),[d,b]=e.useState([]),[m,p]=e.useState(!1),[f,g]=e.useState(-1),v=e.useRef(null),y=e.useRef(null),x=A(c,400);function w(e){const t=e.trim();t&&(s.includes(t)||n?.([...s,t]),u(""))}function k(e){n?.(s.filter(t=>t!==e))}return e.useEffect(()=>{if(x.length<1)return void b([]);let e=!1;return async function({search:e="",limit:t=10}={}){try{const l=new URLSearchParams;e&&l.set("search",e),l.set("limit",String(t));const n=`/tags?${l.toString()}`,a=await W({endpoint:n,method:"GET",basePath:J,useJWT:!0});return(a?.data?.tags||[]).map(e=>({tag:e,count:null}))}catch{return[]}}({search:x,limit:10}).then(t=>{console.log("[TagsInput] listTags response:",t),e||b(Array.isArray(t)?t:[])}).catch(t=>{console.error("[TagsInput] listTags error:",t),e||b([])}),()=>{e=!0}},[x]),e.useEffect(()=>{d.length>0&&x.length>=1&&p(!0)},[d,x]),e.useEffect(()=>{function e(e){if(!v.current)return;y.current&&y.current.contains(e.target)?p(!0):v.current.contains(e.target)||(p(!1),g(-1))}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),l.jsxs("div",{className:"lb:relative lb:w-full lb:flex lb:flex-col lb:gap-2",children:[l.jsx("div",{className:"lb:flex lb:flex-wrap lb:gap-2 lb:p-2 lb:border lb:border-neutral-gray-200 lb:rounded-md lb:bg-brand-purple-050 lb:max-h-[88px] lb:overflow-y-auto",children:s.map(e=>l.jsxs("span",{className:"lb:inline-flex lb:items-center lb:gap-1 lb:px-2 lb:py-1 lb:bg-brand-purple-050 lb:text-brand-purple-1000 lb:text-xs lb:font-semibold lb:rounded-full lb:border lb:border-brand-purple-200",children:[e,l.jsx("button",{type:"button","aria-label":h("tags.pill.ariaDelete",{tag:e}),onClick:t=>{t.stopPropagation(),k(e)},className:"lb:text-brand-purple-400 lb:hover:text-brand-purple-1000 lb:leading-none lb:cursor-pointer lb:ml-1 lb:w-3 lb:h-3 lb:flex lb:items-center lb:justify-center",children:"×"})]},e))}),l.jsx("div",{role:"combobox","aria-expanded":m,"aria-haspopup":"listbox","aria-label":o||h("tags.input.ariaLabel"),onClick:function(){y.current?.focus()},className:"lb:flex lb:flex-wrap lb:gap-2 lb:p-2 lb:min-h-[42px] lb:border lb:border-neutral-gray-200 lb:rounded-md lb:bg-white lb:focus-within:ring-2 lb:focus-within:ring-brand-purple-400 lb:focus-within:border-brand-purple-400 lb:cursor-text"+(r?" lb:opacity-50 lb:pointer-events-none":""),children:l.jsx("input",{type:"text",id:i,ref:y,value:c,onChange:function(e){u(e.target.value),g(-1)},onKeyDown:function(e){" "!==e.key&&","!==e.key||c.trim()&&(e.preventDefault(),w(c.trim()),u("")),"Enter"===e.key&&f>=0&&d[f]&&(e.preventDefault(),w(d[f].tag),u(""),p(!1),g(-1)),"Backspace"===e.key&&""===c&&s.length>0&&k(s[s.length-1]),"ArrowDown"===e.key&&(e.preventDefault(),g(e=>Math.min(e+1,d.length-1))),"ArrowUp"===e.key&&(e.preventDefault(),g(e=>Math.max(e-1,-1))),"Escape"===e.key&&(p(!1),g(-1))},onFocus:()=>{p(!0)},disabled:r,"aria-autocomplete":"list","aria-controls":"tags-input-listbox",className:"lb:outline-none lb:border-0 lb:bg-transparent lb:text-sm lb:text-neutral-gray-900 lb:placeholder-neutral-gray-300 lb:flex-1 lb:min-w-[80px] lb:py-1",placeholder:a||h("tags.input.placeholder")})}),m&&x.length>=1&&l.jsx("div",{role:"listbox",id:"tags-input-listbox",className:"lb:absolute lb:z-50 lb:mt-1 lb:w-full lb:max-h-48 lb:overflow-y-auto lb:bg-white lb:border lb:border-neutral-gray-100 lb:rounded-md lb:shadow-md lb:top-18",children:0===d.length?l.jsx("div",{className:"lb:px-3 lb:py-2 lb:text-sm lb:text-neutral-gray-500 lb:italic",children:h("tags.autocomplete.empty")}):d.map((e,t)=>l.jsxs("div",{role:"option","aria-selected":t===f,onMouseDown:t=>{t.preventDefault(),function(e){w(e.tag),u(""),p(!1),g(-1)}(e)},className:"lb:px-3 lb:py-2 lb:text-sm lb:text-neutral-gray-900 lb:cursor-pointer lb:hover:bg-brand-purple-050 lb:flex lb:items-center lb:justify-between"+(t===f?" lb:bg-brand-purple-050":""),children:[l.jsx("span",{children:e.tag}),l.jsx("span",{className:"lb:text-xs lb:text-neutral-gray-500",children:e.count})]},e.tag))})]})}const ae=["button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"]):not([disabled])',"a[href]"].join(", "),re=e=>{if("true"===e.getAttribute("aria-hidden"))return!1;if(e.hasAttribute("inert"))return!1;if(e.hasAttribute("hidden"))return!1;let t=e.parentElement;for(;t;){if(t.hasAttribute("inert"))return!1;if("true"===t.getAttribute("aria-hidden"))return!1;t=t.parentElement}return!0};function ie(t,{onClose:l,isActive:n=!0}={}){e.useEffect(()=>{if(!n)return;const e=t?.current;if(!e)return;const a=t=>{if("Escape"===t.key)return t.preventDefault(),void l?.();if("Tab"!==t.key)return;const n=(a=e,Array.from(a.querySelectorAll(ae)).filter(re));var a;if(0===n.length)return void t.preventDefault();const r=n[0],i=n[n.length-1],o=document.activeElement;t.shiftKey?o!==r&&e.contains(o)||(t.preventDefault(),i.focus()):o===i&&(t.preventDefault(),r.focus())};return e.addEventListener("keydown",a),()=>e.removeEventListener("keydown",a)},[t,l,n])}function oe({isOpen:t,asset:n,onClose:a,onSave:r}){const[i,o]=e.useState(""),[s,c]=e.useState([]),[u,d]=e.useState(!1),[b,m]=e.useState(null),p=e.useRef(null),f=e.useRef(null);if(e.useEffect(()=>{n?.id&&(o(n.filename??n.original_filename??""),c(Array.isArray(n.tags)?n.tags:[]))},[n?.id]),ie(p,{onClose:a,isActive:t}),e.useEffect(()=>{t&&setTimeout(()=>f.current?.focus(),0)},[t]),!t||!n)return null;return l.jsx("div",{className:"lb:fixed lb:inset-0 lb:bg-black/50 lb:flex lb:items-center lb:justify-center lb:z-[9999]",onClick:function(e){e.target===e.currentTarget&&a()},children:l.jsxs("div",{ref:p,role:"dialog","aria-modal":"true","aria-labelledby":"edit-asset-modal-title",className:"lb:bg-white lb:rounded-lg lb:p-6 lb:max-w-md lb:w-full lb:mx-4 lb:shadow-xl",children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:mb-5",children:[l.jsx("h2",{id:"edit-asset-modal-title",className:"lb:text-base lb:font-semibold lb:text-neutral-gray-900",children:h("editAssetModal.title")}),l.jsx("button",{type:"button","aria-label":h("editAssetModal.close"),onClick:a,className:"lb:text-neutral-gray-400 lb:hover:text-neutral-gray-700 lb:p-1 lb:rounded",children:"×"})]}),l.jsxs("div",{className:"lb:mb-4",children:[l.jsx("label",{htmlFor:"edit-asset-name",className:"lb:block lb:text-sm lb:font-semibold lb:text-neutral-gray-700 lb:mb-2",children:h("editAssetModal.nameLabel")}),l.jsx("input",{id:"edit-asset-name",ref:f,type:"text",value:i,onChange:e=>o(e.target.value),disabled:u,className:"lb:w-full lb:px-3 lb:py-2 lb:text-sm lb:border lb:border-neutral-gray-200 lb:rounded-md lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:text-neutral-gray-900"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"lb:block lb:text-sm lb:font-semibold lb:text-neutral-gray-700 lb:mb-2 lb:mt-4",children:h("tags.input.label")}),l.jsx(ne,{value:s,onChange:c,disabled:u,id:"edit-asset-tags"}),l.jsx("p",{className:"lb:text-xs lb:text-neutral-gray-500 lb:mt-2",children:h("tags.input.hint")})]}),b&&l.jsx("p",{className:"lb:text-xs lb:text-red-800 lb:mt-3",children:b}),l.jsxs("div",{className:"lb:flex lb:justify-end lb:gap-2 lb:mt-6",children:[l.jsx("button",{type:"button",onClick:a,disabled:u,className:"lb:px-4 lb:py-2 lb:text-sm lb:font-semibold lb:text-neutral-gray-700 lb:border lb:border-neutral-gray-300 lb:rounded-md lb:hover:bg-neutral-gray-050 lb:transition-colors",children:h("editAssetModal.cancel")}),l.jsx("button",{type:"button",onClick:async function(){d(!0),m(null);try{await r({name:i,tags:s}),a()}catch(e){m(e.message||h("editAssetModal.saveError"))}finally{d(!1)}},disabled:u,className:"lb:px-4 lb:py-2 lb:text-sm lb:font-semibold lb:bg-brand-blue-800 lb:text-white lb:rounded-md lb:hover:bg-brand-blue-1000 lb:transition-colors"+(u?" lb:opacity-70 lb:cursor-not-allowed":""),children:h("editAssetModal.save")})]})]})})}function se(){const[t,l]=e.useState(!1),[n,a]=e.useState(null);return{deleteImg:async e=>{if(!e)return a("ID de imagen no proporcionado"),!1;l(!0),a(null);try{const t=await async function(e){try{return await W({endpoint:`/assets/${e}`,method:"DELETE",basePath:J,useJWT:!0})}catch(n){throw Y(n)}}(e);return!1!==t.success}catch(t){return a(t.message),!1}finally{l(!1)}},loading:t,error:n,reset:()=>{a(null)}}}const ce=new Map,ue=6e5,de="limbo_gallery_cache";(()=>{try{const e=sessionStorage.getItem(de);if(e){const t=JSON.parse(e),l=Date.now();let n=!1;if(Object.entries(t).forEach(([e,t])=>{t.timestamp&&l-t.timestamp<ue?ce.set(e,t):n=!0}),n)if(0===ce.size)sessionStorage.removeItem(de);else{const e={};ce.forEach((t,l)=>{e[l]=t}),sessionStorage.setItem(de,JSON.stringify(e))}}}catch{}})();const be=()=>{ce.clear();try{sessionStorage.removeItem(de)}catch{}};function me(t,l=!1,n={},a=!0){const r=e.useMemo(()=>JSON.stringify(n),[n]),i=e.useRef((()=>{const e=r,t=ce.get(e),l=Date.now();return t&&l-t.timestamp<ue?{images:t.data,pagination:t.pagination||null,loading:!1}:{images:[],pagination:null,loading:a}})()),[o,s]=e.useState(i.current.images),[c,u]=e.useState(i.current.loading),[d,b]=e.useState(null),[m,h]=e.useState(i.current.pagination),[p,f]=e.useState(0),[g,v]=e.useState(0);e.useEffect(()=>{if(!a)return void u(!1);const e=`${r}`,t=ce.get(e),l=Date.now();if(t&&l-t.timestamp<ue)return s(t.data),h(t.pagination||null),void u(!1);u(!0);let i=!0;return(async()=>{if(p>=3)i&&(b("Error de autenticación: Verifica tus credenciales API"),u(!1));else try{const t=await Z(n);if(!i)return;const a=t.result||t.data||[],r=t.pagination||null;s(a),h(r),b(null),f(0),ce.set(e,{data:a,pagination:r,timestamp:l}),(()=>{try{const e={};ce.forEach((t,l)=>{e[l]=t}),sessionStorage.setItem(de,JSON.stringify(e))}catch{}})()}catch(t){i&&(b(t.message),f(e=>e+1))}finally{i&&u(!1)}})(),()=>{i=!1}},[t,l,r,p,a,g]);return{images:o,loading:c,error:d,pagination:m,setImages:s,invalidateCache:()=>{ce.clear();try{sessionStorage.removeItem(de)}catch{}},refetch:()=>{ce.clear();try{sessionStorage.removeItem(de)}catch{}u(!0),v(e=>e+1)}}}function he(){const[t,l]=e.useState({}),[n,a]=e.useState({}),[r,i]=e.useState({});return{loadVariants:e.useCallback(async(e,r=!1)=>{if(e&&!n[e]){if(!r&&t[e])return t[e];a(t=>({...t,[e]:!0})),i(t=>({...t,[e]:null}));try{const t=await le(e),n=t?.result||[];return l(t=>({...t,[e]:n})),n}catch(o){return console.error("Error loading variants:",o),i(t=>({...t,[e]:o.message})),[]}finally{a(t=>({...t,[e]:!1}))}}},[t,n]),getVariants:e.useCallback(e=>t[e]||[],[t]),isLoading:e.useCallback(e=>n[e]||!1,[n]),getError:e.useCallback(e=>r[e]||null,[r]),clearVariants:e.useCallback(e=>{l(t=>{const l={...t};return delete l[e],l}),a(t=>{const l={...t};return delete l[e],l}),i(t=>{const l={...t};return delete l[e],l})},[]),refreshVariants:e.useCallback(async e=>{if(e){a(t=>({...t,[e]:!0})),i(t=>({...t,[e]:null}));try{const t=await le(e),n=t?.result||[];return l(t=>({...t,[e]:n})),n}catch(t){return console.error("Error refreshing variants:",t),i(l=>({...l,[e]:t.message})),[]}finally{a(t=>({...t,[e]:!1}))}}},[]),removeVariant:e.useCallback(async(e,t)=>{try{return await async function(e,t){try{return await W({endpoint:`/assets/${e}/variants/${t}`,method:"DELETE",basePath:J,useJWT:!0})}catch(l){throw Y(l)}}(e,t),l(l=>{const n=l[e]||[];return{...l,[e]:n.filter(e=>e.id!==t)}}),{success:!0}}catch(n){return console.error("Error deleting variant:",n),{success:!1,error:n.message}}},[])}}function pe(){return l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:gap-2 lb:py-2 lb:px-4 lb:border-t lb:h-8 lb:border-brand-purple-200 lb:bg-brand-purple-50 lb:rounded-b-md lb:mt-3",style:{background:"linear-gradient(90deg,#001978,#2134f1 50%,#f81bbd 95%)",color:"white"},children:[l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 52",fill:"currentColor",className:"lb:w-5 lb:h-5 lb:text-white","aria-hidden":"true",children:[l.jsx("path",{d:"M29.0863 15.2704H24.9419V36.7321H37.5259V33.1048H29.0863V15.2704Z"}),l.jsx("path",{d:"M18.1601 33.1048H9.72056V36.7321H22.3045V15.2704H18.1601V33.1048Z"}),l.jsx("path",{d:"M44.0063 51.846L3.16483 50.1834C1.35636 50.1834 0 48.5965 0 46.8584V4.99294C0 3.33041 1.65777 1.8946 3.31554 1.81903L44.157 0.1565C46.2669 0.0809304 48 1.74346 48 3.8594V47.8408C48 50.0323 46.1915 51.846 43.9309 51.7704H44.0063V51.846ZM4.89796 46.405L42.9513 47.4629C43.4788 47.4629 44.0063 47.0095 44.0063 46.4805V5.21965C44.0063 4.69066 43.6295 4.31282 43.102 4.31282L4.82261 5.67307C4.14443 5.67307 3.61695 6.27762 3.61695 6.95775V45.1203C3.61695 45.8004 4.14443 46.3294 4.82261 46.405H4.89796Z"})]}),l.jsxs("span",{className:"lb:text-xs lb:text-neutral-50",children:["Powered by ",l.jsx("span",{className:"lb:font-semibold lb:text-white",children:"Limbo"})]})]})}function fe({variant:t="info",toast:n=!1,fixed:a=!1,onClose:r,className:i="",children:o,role:s}){const[c,u]=e.useState(!1);if(e.useEffect(()=>{u(!1)},[o]),c)return null;const d=n||a?`${a?"lb:fixed lb:top-4 lb:right-4 lb:z-10000":n?"lb:absolute lb:top-5 lb:right-5 lb:w-fit lb:m-4 lb:z-50":""} ${{success:"lb:bg-green-600",danger:"lb:bg-red-500",warning:"lb:bg-yellow-500",info:"lb:bg-blue-500"}[t]||"lb:bg-gray-600"} lb:text-white lb:px-5 lb:py-3 lb:rounded-lg lb:shadow-lg lb:transition-all lb:duration-300 lb:animate-fade-in`:`limbo-alert limbo-alert-${t}`;return l.jsxs("div",{className:`${d} lb:pr-8 ${i}`,role:s||"alert",children:[o,l.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),r?r():u(!0)},className:"lb:absolute lb:top-1/2 lb:-translate-y-1/2 lb:right-2 lb:p-1 lb:rounded-full lb:opacity-60 lb:hover:opacity-100 lb:transition-opacity lb:cursor-pointer","aria-label":"Cerrar",children:l.jsx("span",{className:"icon icon-close-small-white icon--sm","aria-hidden":"true"})})]})}"undefined"!=typeof window&&window.addEventListener("pageshow",e=>{e.persisted&&be()});const ge=new Map,ve=new Map,ye=18e5;if("undefined"!=typeof document){const e=18e5;let t=null;document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState?t=Date.now():"visible"===document.visibilityState&&null!==t&&(Date.now()-t>e&&(ge.forEach(({blobUrl:e})=>{try{URL.revokeObjectURL(e)}catch{}}),ge.clear(),ve.clear()),t=null)}),window.addEventListener("pageshow",e=>{e.persisted&&(ge.forEach(({blobUrl:e})=>{try{URL.revokeObjectURL(e)}catch{}}),ge.clear(),ve.clear())})}const xe=async(e,{bypassHttpCache:t=!1}={})=>{if(!e)return Promise.reject(new Error("No URL provided"));const l=ge.get(e);if(l&&Date.now()-l.timestamp<ye)return l.blobUrl;if(ve.has(e))return ve.get(e);const n=(async()=>{try{let n,a,r=0;const i=t?{cache:"reload"}:{};for(;r<2;)try{if(n=await fetch(e,i),!n.ok)throw new Error(`Failed to fetch image: ${n.status}`);break}catch(l){if(a=l,r+=1,r>=2)throw a}const o=await n.blob(),s=URL.createObjectURL(o);return ge.set(e,{blobUrl:s,timestamp:Date.now(),size:o.size}),s}finally{ve.delete(e)}})();return ve.set(e,n),n},we=e=>{const t=ge.get(e);return t&&Date.now()-t.timestamp<ye?t.blobUrl:e},ke=e=>{const t=ge.get(e);return t&&Date.now()-t.timestamp<ye},Ce=async(e,t=4)=>{const l=new Map,n=e.filter(e=>!ke(e));if(0===n.length)return e.forEach(e=>{l.set(e,we(e))}),l;const a=[];for(let r=0;r<n.length;r+=t)a.push(n.slice(r,r+t));for(const r of a){(await Promise.allSettled(r.map(async e=>({url:e,blobUrl:await xe(e)})))).forEach(e=>{"fulfilled"===e.status&&l.set(e.value.url,e.value.blobUrl)})}return l},Se=e=>{if(!e)return;const t=ge.get(e);if(t){try{URL.revokeObjectURL(t.blobUrl)}catch{}ge.delete(e)}ve.delete(e)},je=()=>{ge.forEach(({blobUrl:e})=>{try{URL.revokeObjectURL(e)}catch{}}),ge.clear(),ve.clear()};function Ne({isOpen:t=!1,onClose:n,title:a="",subtitle:r="",headerActions:i=null,footerHints:o=null,ariaLabel:s="Visor de archivo",children:c}){const u=e.useRef(null),d=e.useCallback(e=>{"Escape"===e.key&&(e.preventDefault(),n?.())},[n]);return e.useEffect(()=>{if(t)return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,d]),e.useEffect(()=>(document.body.style.overflow=t?"hidden":"",()=>{document.body.style.overflow=""}),[t]),t?l.jsxs("div",{className:"lb:fixed lb:inset-0 lb:bg-black/95 lb:z-[10000] lb:flex lb:flex-col",role:"dialog","aria-modal":"true","aria-label":s,children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:px-4 lb:py-3 lb:bg-black/50 lb:backdrop-blur-sm",children:[l.jsxs("div",{className:"lb:flex-1 lb:min-w-0",children:[a&&l.jsx("h2",{className:"lb:text-white lb:font-medium lb:text-sm lb:truncate",children:a.includes(".")?a.split(".").slice(0,-1).join("."):a}),r&&l.jsx("p",{className:"lb:text-gray-400 lb:text-xs lb:mt-0.5 lb:truncate",children:r})]}),i&&l.jsx("div",{className:"lb:flex lb:items-center lb:gap-2 lb:mx-4",children:i}),l.jsx("button",{type:"button",onClick:n,className:"lb:w-10 lb:h-10 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-white/10 lb:hover:bg-red-1000/80 lb:text-white lb:transition-colors","aria-label":"Cerrar visor (ESC)",title:"Cerrar (ESC)",children:l.jsx("svg",{className:"lb:w-6 lb:h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),l.jsx("div",{ref:u,className:"lb:flex-1 lb:overflow-hidden lb:flex lb:items-center lb:justify-center",onClick:e=>{e.target===u.current&&n?.()},children:c}),o&&l.jsx("div",{className:"lb:px-4 lb:py-2 lb:bg-black/50 lb:backdrop-blur-sm lb:text-center",children:l.jsx("p",{className:"lb:text-gray-400 lb:text-xs",children:o})})]}):null}function Ee({isOpen:t=!1,src:n,title:a="",subtitle:r="",onClose:i}){const[o,s]=e.useState(!1),[c,u]=e.useState(!0),d=e.useRef(null);e.useEffect(()=>{t&&(s(!1),u(!0))},[t]);const b=e.useCallback(e=>{" "===e.key&&d.current&&(e.preventDefault(),d.current.paused?d.current.play():d.current.pause())},[]);e.useEffect(()=>{if(t)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[t,b]);const m=l.jsxs("button",{type:"button",onClick:async()=>{if(n)try{const e=await fetch(n,{mode:"cors"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const t=await e.blob(),l=URL.createObjectURL(t),r=document.createElement("a");r.href=l,r.download=a||"video",r.style.display="none",document.body.appendChild(r),r.click(),setTimeout(()=>{URL.revokeObjectURL(l),document.body.removeChild(r)},100)}catch{window.open(n,"_blank")}},className:"lb:flex lb:items-center lb:gap-2 lb:px-3 lb:py-1.5 lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:text-sm lb:transition-colors","aria-label":"Descargar video",title:"Descargar video",children:[l.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),l.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Descargar"})]}),h=l.jsxs("span",{children:[l.jsxs("span",{className:"lb:hidden lb:sm:inline",children:[l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"Espacio"})," ","para pausar/reproducir •"," "]}),l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return l.jsx(Ne,{isOpen:t,onClose:i,title:a,subtitle:r,ariaLabel:"Visor de video",headerActions:m,footerHints:h,children:o?l.jsxs("div",{className:"lb:text-center lb:text-white",children:[l.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),l.jsx("p",{className:"lb:text-lg lb:font-medium",children:"No se puede reproducir el video"}),l.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:a})]}):l.jsxs("div",{className:"lb:relative lb:w-full lb:max-w-5xl lb:max-h-full lb:flex lb:items-center lb:justify-center lb:px-4",children:[c&&l.jsx("div",{className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center",children:l.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-white/20 lb:border-t-white lb:rounded-full lb:animate-spin"})}),l.jsx("video",{ref:d,src:n,className:"lb:max-w-full lb:max-h-[calc(100vh-140px)] lb:h-full lb:w-full lb:rounded-lg",controls:!0,autoPlay:!0,preload:"metadata",onCanPlay:()=>u(!1),onError:()=>{s(!0),u(!1)},children:"Tu navegador no soporta la reproduccion de video."})]})})}function $e({isOpen:t=!1,src:n,title:a="",subtitle:r="",onClose:i}){const[o,s]=e.useState(!1),[c,u]=e.useState(!1),[d,b]=e.useState(0),[m,h]=e.useState(0),p=e.useRef(null);e.useEffect(()=>{t&&(u(!1),s(!1),b(0),h(0))},[t]);const f=e.useCallback(()=>{p.current&&(p.current.paused?p.current.play():p.current.pause())},[]),g=e.useCallback(e=>{" "===e.key&&(e.preventDefault(),f())},[f]);e.useEffect(()=>{if(t)return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[t,g]);const v=e=>{if(!e||isNaN(e))return"0:00";return`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,"0")}`},y=l.jsxs("button",{type:"button",onClick:async()=>{if(n)try{const e=await fetch(n,{mode:"cors"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const t=await e.blob(),l=URL.createObjectURL(t),r=document.createElement("a");r.href=l,r.download=a||"audio",r.style.display="none",document.body.appendChild(r),r.click(),setTimeout(()=>{URL.revokeObjectURL(l),document.body.removeChild(r)},100)}catch{window.open(n,"_blank")}},className:"lb:flex lb:items-center lb:gap-2 lb:px-3 lb:py-1.5 lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:text-sm lb:transition-colors","aria-label":"Descargar audio",title:"Descargar audio",children:[l.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),l.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Descargar"})]}),x=l.jsxs("span",{children:[l.jsxs("span",{className:"lb:hidden lb:sm:inline",children:[l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"Espacio"})," ","para pausar/reproducir •"," "]}),l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return l.jsx(Ne,{isOpen:t,onClose:i,title:a,subtitle:r,ariaLabel:"Visor de audio",headerActions:y,footerHints:x,children:c?l.jsxs("div",{className:"lb:text-center lb:text-white",children:[l.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),l.jsx("p",{className:"lb:text-lg lb:font-medium",children:"No se puede reproducir el audio"}),l.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:a})]}):l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-8 lb:w-full lb:max-w-md lb:px-4",children:[l.jsxs("div",{className:"lb:relative",children:[l.jsx("div",{className:"lb:w-40 lb:h-40 lb:flex lb:items-center lb:justify-center lb:rounded-full lb:bg-linear-to-br lb:from-purple-600/30 lb:to-blue-600/30 lb:border-2 lb:border-white/10 "+(o?"lb:animate-pulse":""),children:l.jsx("span",{className:"icon icon-audio lb:text-white lb:w-16 lb:h-16"})}),l.jsx("button",{type:"button",onClick:f,className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center lb:rounded-full lb:bg-black/0 lb:hover:bg-white/10 lb:transition-colors lb:cursor-pointer","aria-label":o?"Pausar":"Reproducir",children:l.jsx("div",{className:"lb:w-14 lb:h-14 lb:rounded-full lb:bg-white/90 lb:flex lb:items-center lb:justify-center lb:shadow-lg",children:l.jsx("span",{className:`icon ${o?"icon-pause":"icon-play"} icon--lg lb:text-gray-800 ${o?"":"lb:ml-0.5"}`})})})]}),l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-3 lb:text-white lb:text-sm",children:[l.jsx("span",{className:"lb:font-mono lb:min-w-[3ch] lb:text-right",children:v(m)}),l.jsx("div",{className:"lb:w-64 lb:h-2 lb:bg-white/20 lb:rounded-full lb:cursor-pointer lb:relative",onClick:e=>{if(!p.current||!d)return;const t=e.currentTarget.getBoundingClientRect(),l=(e.clientX-t.left)/t.width;p.current.currentTime=l*d},role:"slider","aria-label":"Progreso de audio","aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":d,tabIndex:0,children:l.jsx("div",{className:"lb:h-full lb:bg-purple-500 lb:rounded-full lb:transition-all lb:duration-100",style:{width:d>0?m/d*100+"%":"0%"}})}),l.jsx("span",{className:"lb:font-mono lb:min-w-[3ch] lb:text-gray-400",children:v(d)})]}),l.jsx("audio",{ref:p,src:n,onPlay:()=>s(!0),onPause:()=>s(!1),onTimeUpdate:()=>h(p.current?.currentTime||0),onLoadedMetadata:()=>b(p.current?.duration||0),onEnded:()=>{s(!1),h(0)},onError:()=>u(!0),preload:"metadata"})]})})}function _e({isOpen:t=!1,src:n,title:a="",subtitle:r="",onClose:i}){const[o,s]=e.useState(!0),[c,u]=e.useState(!1),[d,b]=e.useState(null),m=e.useRef(null);e.useEffect(()=>{if(!t||!n)return;let e=!1;return s(!0),u(!1),fetch(n).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.blob()}).then(t=>{if(e)return;m.current&&URL.revokeObjectURL(m.current);const l=URL.createObjectURL(t);m.current=l,b(l)}).catch(()=>{e||(u(!0),s(!1))}),()=>{e=!0}},[n,t]),e.useEffect(()=>()=>{m.current&&(URL.revokeObjectURL(m.current),m.current=null)},[]);const h=()=>{if(!n)return;const e=document.createElement("a");e.href=n,e.download=a||"document.pdf",e.target="_blank",document.body.appendChild(e),e.click(),document.body.removeChild(e)},p=l.jsxs("button",{type:"button",onClick:h,className:"lb:flex lb:items-center lb:gap-2 lb:px-3 lb:py-1.5 lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:text-sm lb:transition-colors","aria-label":"Abrir PDF en nueva pestaña",title:"Abrir PDF en nueva pestaña",children:[l.jsx("span",{className:"icon icon-arrow-left-white lb:rotate-40 lb:me-0 lb:pe-0 icon--sm"}),l.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Abrir en nueva pestaña"})]}),f=l.jsxs("span",{children:[l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return l.jsx(Ne,{isOpen:t,onClose:i,title:a,subtitle:r,ariaLabel:"Visor de PDF",headerActions:p,footerHints:f,children:c?l.jsxs("div",{className:"lb:text-center lb:text-white",children:[l.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),l.jsx("p",{className:"lb:text-lg lb:font-medium",children:"No se puede mostrar el PDF"}),l.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:a}),l.jsx("button",{type:"button",onClick:h,className:"lb:mt-4 lb:px-6 lb:py-2.5 lb:bg-white lb:text-gray-900 lb:rounded-lg lb:font-medium lb:text-sm lb:hover:bg-gray-100 lb:transition-colors",children:"Descargar PDF"})]}):l.jsxs("div",{className:"lb:relative lb:w-full lb:h-full lb:px-4 lb:py-2",children:[o&&l.jsx("div",{className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center lb:z-10",children:l.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-white/20 lb:border-t-white lb:rounded-full lb:animate-spin"})}),d&&l.jsx("iframe",{src:d,title:a||"PDF Viewer",className:"lb:w-full lb:h-full lb:rounded-lg lb:bg-white",onLoad:()=>s(!1),onError:()=>{u(!0),s(!1)}})]})})}const Te={"application/pdf":{symbol:"icon-doc-pdf",label:"PDF",color:"#dc2626"},"application/msword":{symbol:"icon-doc-word",label:"DOC",color:"#2563eb"},"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{symbol:"icon-doc-word",label:"DOCX",color:"#2563eb"},"application/vnd.ms-excel":{symbol:"icon-doc-xls",label:"XLS",color:"#16a34a"},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":{symbol:"icon-doc-xls",label:"XLSX",color:"#16a34a"},"application/vnd.ms-powerpoint":{symbol:"icon-doc-ppt",label:"PPT",color:"#ea580c"},"application/vnd.openxmlformats-officedocument.presentationml.presentation":{symbol:"icon-doc-ppt",label:"PPTX",color:"#ea580c"},"text/plain":{symbol:"icon-doc-text",label:"TXT",color:"#6b7280"},"text/csv":{symbol:"icon-doc-report",label:"CSV",color:"#16a34a"},"audio/mp3":{symbol:"icon-support-person",label:"MP3",color:"#0891b2"},"audio/mpeg":{symbol:"icon-support-person",label:"MP3",color:"#0891b2"},"audio/wav":{symbol:"icon-support-person",label:"WAV",color:"#0891b2"},"audio/ogg":{symbol:"icon-support-person",label:"OGG",color:"#0891b2"},"video/mp4":{symbol:"icon-video",label:"MP4",color:"#7c3aed"},"video/x-msvideo":{symbol:"icon-video",label:"AVI",color:"#7c3aed"},"video/x-matroska":{symbol:"icon-video",label:"MKV",color:"#7c3aed"},default:{symbol:"icon-clip",label:"FILE",color:"#6b7280"}},Ae={video:{symbol:"🎬",label:"VIDEO",color:"#7c3aed"},audio:{symbol:"🎵",label:"AUDIO",color:"#0891b2"},document:{symbol:"📄",label:"DOC",color:"#6b7280"},image:{symbol:"🖼️",label:"IMG",color:"#0ea5e9"}};function ze(e,t){return Te[e]?Te[e]:t&&Ae[t]?Ae[t]:e?.startsWith("video/")?Ae.video:e?.startsWith("audio/")?Ae.audio:e?.startsWith("image/")?Ae.image:Te.default}function Le(e){if(!e||0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return Math.round(e/Math.pow(1024,t)*100)/100+" "+["Bytes","KB","MB","GB"][t]}function Me({file:e,mimeType:t,category:n}){const a=ze(t,n),r=e?.name||"archivo",i=Le(e?.size);return l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:min-h-50",children:[l.jsx("div",{className:"lb:w-24 lb:h-24 lb:flex lb:items-center lb:justify-center lb:bg-gray-100 lb:rounded-xl lb:mb-4",children:l.jsx("span",{className:`icon ${a.symbol} lb:h-[55%] lb:w-[55%] lb:max-h-50 lb:max-w-50`,"aria-hidden":"true"})}),l.jsx("p",{className:"lb:text-sm lb:font-medium lb:text-gray-800 lb:text-center lb:max-w-full lb:truncate lb:px-4",children:r}),l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:mt-3",children:[l.jsx("span",{className:"lb:text-xs lb:text-gray-500",children:i}),l.jsx("span",{className:"lb:text-xs lb:font-bold lb:uppercase lb:px-2 lb:py-0.5 lb:rounded",style:{backgroundColor:a.color,color:"white"},children:a.label})]})]})}function Ie({isOpen:e=!1,src:t,title:n="",subtitle:a="",mimeType:r="",fileSize:i=0,onClose:o}){const s=ze(r),c=l.jsxs("span",{children:[l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return l.jsx(Ne,{isOpen:e,onClose:o,title:n,subtitle:a,ariaLabel:"Visor de documento",footerHints:c,children:l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-6 lb:text-center lb:px-4",children:[l.jsx("div",{className:"lb:w-32 lb:h-32 lb:flex lb:items-center lb:justify-center lb:bg-white/5 lb:rounded-2xl lb:border lb:border-white/10",children:l.jsx("span",{className:`icon ${s.symbol}-white lb:min-w-16 lb:min-h-16`,"aria-hidden":"true"})}),l.jsx("span",{className:"lb:text-sm lb:font-bold lb:uppercase lb:px-4 lb:py-1.5 lb:rounded-full",style:{backgroundColor:s.color,color:"white"},children:s.label}),l.jsxs("div",{children:[l.jsx("p",{className:"lb:text-white lb:font-medium lb:text-lg lb:max-w-md lb:truncate",children:n}),i>0&&l.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-1",children:Le(i)})]}),l.jsx("p",{className:"lb:text-gray-500 lb:text-sm",children:"Este tipo de archivo no se puede previsualizar"}),l.jsxs("button",{type:"button",onClick:async()=>{if(t)try{const e=await fetch(t,{mode:"cors"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const l=await e.blob(),a=URL.createObjectURL(l),r=document.createElement("a");r.href=a,r.download=n||"document",r.style.display="none",document.body.appendChild(r),r.click(),setTimeout(()=>{URL.revokeObjectURL(a),document.body.removeChild(r)},100)}catch{window.open(t,"_blank")}},className:"lb:flex lb:items-center lb:gap-2 lb:px-8 lb:py-3 lb:bg-white lb:text-gray-900 lb:rounded-lg lb:font-medium lb:text-sm lb:hover:bg-gray-100 lb:transition-colors lb:shadow-lg","aria-label":"Descargar archivo",children:[l.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),"Descargar archivo"]})]})})}const Pe=2097152;function De({isOpen:t=!1,src:n,title:a="",subtitle:r="",mimeType:i="",onClose:o}){const[s,c]=e.useState(!0),[u,d]=e.useState(!1),[b,m]=e.useState(""),[h,p]=e.useState(!1);e.useEffect(()=>{if(!t||!n)return;let e=!1;return c(!0),d(!1),m(""),p(!1),fetch(n).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.blob()}).then(t=>{if(e)return;const l=t.size>Pe?t.slice(0,Pe):t;return t.size>Pe&&p(!0),l.text()}).then(t=>{if(!e){if("application/json"===i||a.endsWith(".json"))try{const e=JSON.parse(t);t=JSON.stringify(e,null,2)}catch{}m(t),c(!1)}}).catch(()=>{e||(d(!0),c(!1))}),()=>{e=!0}},[n,t,i,a]);const f=async()=>{if(n)try{const e=await fetch(n,{mode:"cors"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const t=await e.blob(),l=URL.createObjectURL(t),r=document.createElement("a");r.href=l,r.download=a||"file.txt",r.style.display="none",document.body.appendChild(r),r.click(),setTimeout(()=>{URL.revokeObjectURL(l),document.body.removeChild(r)},100)}catch{window.open(n,"_blank")}},g=b?b.split("\n").length:0,v=l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2",children:[g>0&&l.jsxs("span",{className:"lb:text-gray-400 lb:text-xs",children:[g," ",1===g?"linea":"lineas"]}),l.jsxs("button",{type:"button",onClick:f,className:"lb:flex lb:items-center lb:gap-2 lb:px-3 lb:py-1.5 lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:text-sm lb:transition-colors","aria-label":"Descargar archivo",title:"Descargar archivo",children:[l.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),l.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Descargar"})]})]}),y=l.jsxs("span",{children:[l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return l.jsx(Ne,{isOpen:t,onClose:o,title:a,subtitle:r,ariaLabel:"Visor de texto",headerActions:v,footerHints:y,children:u?l.jsxs("div",{className:"lb:text-center lb:text-white",children:[l.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),l.jsx("p",{className:"lb:text-lg lb:font-medium",children:"No se puede mostrar el archivo"}),l.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:a}),l.jsx("button",{type:"button",onClick:f,className:"lb:mt-4 lb:px-6 lb:py-2.5 lb:bg-white lb:text-gray-900 lb:rounded-lg lb:font-medium lb:text-sm lb:hover:bg-gray-100 lb:transition-colors",children:"Descargar archivo"})]}):s?l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-white/20 lb:border-t-white lb:rounded-full lb:animate-spin"})}):l.jsxs("div",{className:"lb:relative lb:w-full lb:h-full lb:px-4 lb:py-2 lb:overflow-hidden lb:flex lb:flex-col",children:[h&&l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:px-4 lb:py-2 lb:bg-yellow-900/50 lb:border lb:border-yellow-700/50 lb:rounded-lg lb:mb-2 lb:shrink-0",children:[l.jsx("svg",{className:"lb:w-4 lb:h-4 lb:text-yellow-400 lb:shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01"})}),l.jsx("span",{className:"lb:text-yellow-300 lb:text-xs",children:"Archivo truncado (mostrando primeros 2MB). Descarga el archivo completo para ver todo el contenido."})]}),l.jsx("div",{className:"lb:flex-1 lb:overflow-auto lb:rounded-lg lb:bg-gray-900/80 lb:border lb:border-white/10",children:l.jsx("pre",{className:"lb:p-4 lb:text-sm lb:text-gray-200 lb:font-mono lb:whitespace-pre-wrap lb:break-words lb:leading-relaxed lb:m-0",children:b})})]})})}function Re({src:t,alt:n="Imagen",title:a="",subtitle:r="",onClose:i,isOpen:o=!1,tags:s=[]}){const[c,u]=e.useState(1),[d,b]=e.useState({x:0,y:0}),[m,h]=e.useState(!1),[p,f]=e.useState(!1),[g,v]=e.useState({x:0,y:0}),[y,x]=e.useState(!1),[w,k]=e.useState(!1),C=e.useRef(null),S=e.useRef(null);e.useEffect(()=>{o&&(u(1),b({x:0,y:0}),x(!1),k(!1))},[o]);const j=e.useCallback(()=>{u(e=>Math.min(e+.25,5)),b({x:0,y:0})},[]),N=e.useCallback(()=>{u(e=>Math.max(e-.25,.25)),b({x:0,y:0})},[]),E=e.useCallback(()=>{u(1),b({x:0,y:0})},[]),$=e.useCallback(()=>{u(1),b({x:0,y:0})},[]),_=e.useCallback(e=>{if((e.ctrlKey||e.metaKey)&&("+"===e.key||"="===e.key))return e.preventDefault(),void j();if((e.ctrlKey||e.metaKey)&&"-"===e.key)return e.preventDefault(),void N();if((e.ctrlKey||e.metaKey)&&"0"===e.key)return e.preventDefault(),void E();if(c>1){const t=50;switch(e.key){case"ArrowUp":e.preventDefault(),b(e=>({...e,y:e.y+t}));break;case"ArrowDown":e.preventDefault(),b(e=>({...e,y:e.y-t}));break;case"ArrowLeft":e.preventDefault(),b(e=>({...e,x:e.x+t}));break;case"ArrowRight":e.preventDefault(),b(e=>({...e,x:e.x-t}))}}},[j,N,E,c]),T=e.useCallback(e=>{(e.ctrlKey||e.metaKey)&&(e.preventDefault(),e.deltaY<0?j():N())},[j,N]),A=e.useCallback(e=>{c>1&&0===e.button&&(e.preventDefault(),h(!0),f(!1),v({x:e.clientX-d.x,y:e.clientY-d.y}))},[c,d]),z=e.useCallback(e=>{m&&(f(!0),b({x:e.clientX-g.x,y:e.clientY-g.y}))},[m,g]),L=e.useCallback(()=>{h(!1)},[]),M=e.useCallback(e=>{e.stopPropagation(),1!==c||p||(u(2),b({x:0,y:0})),f(!1)},[c,p]),I=e.useCallback(e=>{e.stopPropagation(),1===c?(u(2),b({x:0,y:0})):E()},[c,E]);e.useEffect(()=>{if(!o)return;document.addEventListener("keydown",_),document.addEventListener("mouseup",L),document.addEventListener("mousemove",z);const e=e=>{!e.ctrlKey&&!e.metaKey||"+"!==e.key&&"-"!==e.key&&"="!==e.key&&"0"!==e.key||e.preventDefault()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",_),document.removeEventListener("mouseup",L),document.removeEventListener("mousemove",z),document.removeEventListener("keydown",e)}},[o,_,L,z]);const P=Math.round(100*c),D=l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",onClick:N,disabled:c<=.25,className:"lb:w-8 lb:h-8 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:disabled:opacity-30 lb:disabled:cursor-not-allowed lb:transition-colors","aria-label":"Reducir zoom",title:"Reducir zoom (Ctrl -)",children:l.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})}),l.jsxs("div",{className:"lb:w-20 lb:text-center lb:text-white lb:text-sm lb:font-medium lb:bg-white/10 lb:rounded-lg lb:px-2 lb:py-1.5 lb:cursor-pointer lb:hover:bg-white/20 lb:transition-colors",onClick:E,title:"Click para restablecer zoom",role:"button",tabIndex:0,onKeyDown:e=>"Enter"===e.key&&E(),children:[P,"%"]}),l.jsx("button",{type:"button",onClick:j,disabled:c>=5,className:"lb:w-8 lb:h-8 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:disabled:opacity-30 lb:disabled:cursor-not-allowed lb:transition-colors","aria-label":"Aumentar zoom",title:"Aumentar zoom (Ctrl +)",children:l.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),l.jsx("button",{type:"button",onClick:$,className:"lb:w-8 lb:h-8 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:transition-colors lb:ml-2","aria-label":"Ajustar a pantalla",title:"Ajustar a pantalla (Ctrl 0)",children:l.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})})]}),R=l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"lb:hidden lb:sm:inline",children:[l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"Ctrl"})," ","+ rueda para zoom •"," ",l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"Ctrl"})," ","+"," ",l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"+"})," ","/"," ",l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"-"})," ","zoom • Click para zoom • Doble click para restablecer • Flechas para mover •"," ",l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]}),l.jsx("span",{className:"lb:sm:hidden",children:"Click para zoom • Doble click para restablecer • ESC para cerrar"})]});return l.jsx(Ne,{isOpen:o,onClose:i,title:a,subtitle:r,ariaLabel:"Visor de imagen",headerActions:D,footerHints:R,children:l.jsxs("div",{ref:C,className:`lb:w-full lb:h-full lb:overflow-hidden lb:flex lb:items-center lb:justify-center ${c>1?"lb:cursor-grab":"lb:cursor-zoom-in"} ${m?"lb:cursor-grabbing":""}`,onClick:e=>{e.target===C.current&&i?.()},onWheel:T,onMouseDown:A,children:[!y&&!w&&l.jsx("div",{className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center",children:l.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-white/20 lb:border-t-white lb:rounded-full lb:animate-spin"})}),w&&l.jsxs("div",{className:"lb:text-center lb:text-white",children:[l.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),l.jsx("p",{className:"lb:text-lg lb:font-medium",children:"Error al cargar la imagen"}),l.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:"No se pudo cargar la imagen"})]}),l.jsx("img",{ref:S,src:t,alt:n,className:"lb:max-w-full lb:max-h-full lb:object-contain lb:transition-opacity lb:duration-200 lb:select-none "+(y?"lb:opacity-100":"lb:opacity-0"),style:{transform:`scale(${c}) translate(${d.x/c}px, ${d.y/c}px)`,transition:m?"none":"transform 0.2s ease-out"},onLoad:()=>x(!0),onError:()=>k(!0),onClick:M,onDoubleClick:I,draggable:!1}),s&&s.length>0&&l.jsxs("div",{className:"lb:absolute lb:top-4 lb:left-1/2 lb:-translate-x-1/2 lb:flex lb:flex-wrap lb:gap-2 lb:justify-center lb:max-w-[90%] lb:px-4 lb:max-h-24 lb:overflow-y-auto",children:[s.slice(0,20).map(e=>l.jsx("span",{className:"lb:inline-flex lb:items-center lb:px-2 lb:py-0.5 lb:bg-white/20 lb:text-white lb:text-xs lb:font-semibold lb:rounded-full lb:whitespace-nowrap",children:e},e)),s.length>20&&l.jsxs("span",{className:"lb:inline-flex lb:items-center lb:px-2 lb:py-0.5 lb:bg-white/20 lb:text-white lb:text-xs lb:font-semibold lb:rounded-full",children:["+",s.length-20]})]})]})})}function Oe({image:t,isOpen:n,onClose:a,onSelect:r,onDelete:i,onCrop:o,onVariantDeleted:s,allowedActions:c={select:!0,download:!0,copy:!0,delete:!0,crop:!0}}){const{loadVariants:u,getVariants:d,isLoading:b,getError:m,removeVariant:h}=he(),p=window.limboCore?.accessibilityManager,[f,g]=e.useState(null),[v,y]=e.useState(null),[x,w]=e.useState(null),[k,C]=e.useState(null),[S,j]=e.useState({}),[N,E]=e.useState({}),$=(window.limboCore?.config?.getGlobal()||{}).interaction||{allowSelection:!1,allowCropping:!0},_=$.allowSelection&&c.select&&r,T=$.allowCropping&&c.crop&&o,A=c.download,z=c.copy,L=c.delete,[M,I]=e.useState(new Set),[P,D]=e.useState(new Set),[R,O]=e.useState({}),[F,U]=e.useState(!1),B=e.useRef(null),q=e.useRef(null),W=e.useCallback(e=>{if("Escape"===e.key){if(x)return;e.preventDefault(),a?.()}if("Tab"===e.key&&B.current){const t=B.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),l=t[0],n=t[t.length-1];e.shiftKey&&document.activeElement===l?(e.preventDefault(),n?.focus()):e.shiftKey||document.activeElement!==n||(e.preventDefault(),l?.focus())}},[a,x]);e.useEffect(()=>{if(n)return q.current?.focus(),document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[n,W]);const V=e.useMemo(()=>t?.variants||[],[t?.variants]),H=d(t?.id),K=(H.length>0?H:V).filter(e=>!P.has(e.id)),G=b(t?.id),Q=m(t?.id);e.useEffect(()=>{n&&t?.id&&u(t.id,!0)},[n,t?.id]),e.useEffect(()=>{n&&(I(new Set),D(new Set),O({}),j({}),E({}))},[n]),e.useEffect(()=>{if(n&&P.size>0&&0===K.length){const e=setTimeout(()=>{document.dispatchEvent(new CustomEvent("limbo:variantsCleared",{detail:{assetId:t?.id}})),a?.()},1200);return()=>clearTimeout(e)}},[n,P.size,K.length,t?.id,a]);const X=K.map(e=>e.id).join(",");e.useEffect(()=>{if(!n||!t?.url)return;let e=!1;return(async()=>{const l={},n={},a={},r="original",i=ke(t.url);if(i?(n[r]=!0,l[r]=!1,a.original=we(t.url)):(l[r]=!0,n[r]=!1),K.forEach(e=>{ke(e.url)?(n[e.id]=!0,l[e.id]=!1,a[e.id]=we(e.url)):(l[e.id]=!0,n[e.id]=!1)}),j(l),E(n),Object.keys(a).length>0&&O(a),!i){const l=await xe(t.url);if(e)return;l&&(O(e=>({...e,original:l})),j(e=>({...e,[r]:!1})),E(e=>({...e,[r]:!0})))}if(K.length>0){const t=K.filter(e=>!ke(e.url));if(t.length>0){const l=t.map(e=>e.url),n=await Ce(l,4);if(e)return;const a={},r={},i={};t.forEach((e,t)=>{n[t]&&(a[e.id]=n[t],r[e.id]=!1,i[e.id]=!0)}),Object.keys(a).length>0&&(O(e=>({...e,...a})),j(e=>({...e,...r})),E(e=>({...e,...i})))}}})(),()=>{e=!0}},[n,t?.url,X]);if(!n)return null;const Y=e=>{p?.announce(`Abriendo visor de imagen: ${e.name}`);const t=R[e.id]||we(e.url);w({src:t,title:e.name||e.filename||"Recorte",subtitle:`${e.width}×${e.height} · ${Math.round((e.file_size||0)/1024)}KB`})},J=()=>{p?.announce(`Abriendo visor de imagen: ${t.filename}`);const e=R.original||we(t.url);w({src:e,title:t.filename||"Original",subtitle:`${t.width}×${t.height} · ${Math.round((t.file_size||0)/1024)}KB`})},Z=[{...t,isOriginal:!0},...K.map(e=>({...e,isOriginal:!1}))];return l.jsxs("div",{className:"lb:fixed lb:inset-0 lb:bg-black/85 lb:flex lb:items-center lb:justify-center lb:z-[1000] lb:p-4",onClick:()=>{x||a?.()},role:"dialog","aria-modal":"true","aria-labelledby":"variants-modal-title","aria-describedby":"variants-modal-description",children:[l.jsxs("div",{ref:B,className:"lb:relative lb:bg-white lb:rounded-xl lb:max-w-[95vw] lb:max-h-[90vh] lb:overflow-hidden lb:shadow-2xl lb:flex lb:flex-col lb:w-[900px]",onClick:e=>e.stopPropagation(),children:[l.jsxs("div",{className:"lb:px-5 lb:py-4 lb:border-b lb:border-gray-200 lb:flex lb:justify-between lb:items-center lb:bg-gray-50",children:[l.jsxs("div",{className:"lb:flex-1 lb:min-w-0 lb:pr-4",children:[l.jsx("h2",{id:"variants-modal-title",className:"lb:m-0 lb:text-lg lb:font-semibold lb:text-gray-900 lb:truncate",children:t?.filename}),l.jsxs("p",{id:"variants-modal-description",className:"lb:text-sm lb:text-gray-500 lb:mt-1",children:["Imagen original y ",K.length," recorte",1!==K.length?"s":""," disponible",1!==K.length?"s":""]})]}),l.jsx("button",{ref:q,className:"lb:w-10 lb:h-10 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-gray-100 lb:hover:bg-red-200 lb:text-gray-500 lb:hover:text-red-1000 lb:transition-colors lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400",onClick:a,"aria-label":"Cerrar modal (ESC)",title:"Cerrar (ESC)",children:l.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),F&&l.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-white/80 lb:flex lb:flex-col lb:items-center lb:justify-center lb:z-50 lb:rounded-xl",children:[l.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-gray-200 lb:border-t-brand-blue-800 lb:rounded-full lb:animate-spin lb:mb-4"}),l.jsx("p",{className:"lb:text-base lb:font-medium lb:text-gray-700",children:"Eliminando recorte..."})]}),f&&l.jsx("div",{className:"lb:mx-2 lb:mt-2 lb:px-2 lb:py-1.5 lb:rounded lb:text-xs "+("success"===v?"lb:bg-green-50 lb:text-green-1000":"lb:bg-red-50 lb:text-red-1000"),role:"alert",children:f}),l.jsx("div",{className:"lb:p-5 lb:overflow-y-auto lb:flex-1 lb:bg-gray-50/50",children:G?l.jsxs("div",{className:"lb:text-center lb:py-16 lb:text-gray-500",role:"status","aria-live":"polite",children:[l.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-gray-200 lb:border-t-brand-blue-800 lb:rounded-full lb:animate-spin lb:mx-auto lb:mb-4"}),l.jsx("p",{className:"lb:text-base",children:"Cargando variantes..."})]}):Q?l.jsxs("div",{className:"lb:text-center lb:py-16 lb:text-red-1000",role:"alert",children:[l.jsx("svg",{className:"lb:w-12 lb:h-12 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),l.jsxs("p",{className:"lb:text-base lb:font-medium",children:["Error: ",Q]}),l.jsx("button",{onClick:()=>u(t.id,!0),className:"lb:mt-4 lb:text-sm lb:px-5 lb:py-2.5 lb:rounded-lg lb:bg-brand-blue-800 lb:text-white lb:hover:bg-brand-blue-1000 lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-2",children:"Reintentar"})]}):0===K.length?l.jsxs("div",{className:"lb:text-center lb:py-16 lb:text-gray-500",children:[l.jsx("svg",{className:"lb:w-12 lb:h-12 lb:mx-auto lb:mb-4 lb:text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),l.jsx("p",{className:"lb:text-base",children:"No hay recortes disponibles"})]}):l.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:lg:grid-cols-3 lb:gap-5",role:"list","aria-label":"Lista de imágenes",children:Z.map((e,n)=>{const c=e.isOriginal,u=!c&&M.has(e.id),d=c?R.original||we(e.url):R[e.id]||we(e.url),b=c?"Original":e.name||e.filename||`Recorte ${n}`,m=c?t.width:e.width,f=c?t.height:e.height,v=c?t.file_size:e.file_size||0,x=c?"original":e.id,w=S[x]&&!u,$=N[x];return l.jsxs("article",{role:"listitem","aria-label":`${b} - ${m}×${f} píxeles`,className:`lb:rounded-xl lb:overflow-hidden lb:transition-all lb:shadow-sm lb:hover:shadow-lg ${c?"lb:ring-2 lb:ring-brand-blue-800 lb:ring-offset-2 lb:bg-white":"lb:border lb:border-gray-200 lb:bg-white lb:hover:border-brand-blue-400"} lb:focus-within:ring-2 lb:focus-within:ring-brand-blue-400`,children:[l.jsxs("button",{type:"button",title:_?"Click para seleccionar":"Click para ampliar con zoom",className:"lb:relative lb:w-full lb:cursor-pointer lb:aspect-square lb:flex lb:items-center lb:justify-center lb:overflow-hidden lb:bg-gray-100 lb:focus:outline-none lb:group",onClick:u?void 0:()=>{_?c?(r?.(t),a?.()):(e=>{const l={id:e.id,filename:`${t.filename}_${e.name}`,url:e.url,width:e.width,height:e.height,mime_type:`image/${e.format}`,file_size:e.file_size,upload_date:e.created_at,processing_status:"completed",is_variant:!0,parent_asset_id:t.id,variant_info:e};p?.announce(`Recorte seleccionado: ${e.name}`),r?.(l),a?.()})(e):c?J():Y(e)},"aria-label":_?`Seleccionar ${b}`:`Ver ${b} en tamaño completo con zoom`,disabled:u,children:[w&&!u&&l.jsx("div",{className:"lb:w-full lb:aspect-square lb:rounded lb:bg-neutral-gray-200 lb:animate-pulse lb:flex lb:items-center lb:justify-center lb:absolute lb:inset-0 lb:z-10",children:l.jsx("span",{className:"icon icon-spinner lb:w-8 lb:h-8 lb:animate-spin"})}),u?l.jsxs("div",{className:"lb:text-center lb:text-gray-400",children:[l.jsx("svg",{className:"lb:w-10 lb:h-10 lb:mx-auto lb:mb-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),l.jsx("span",{className:"lb:text-sm",children:"Error al cargar"})]}):l.jsxs(l.Fragment,{children:[l.jsx("img",{src:d,alt:`${b} - ${m}×${f}px`,loading:c?"eager":"lazy",onLoad:()=>{E(e=>e[x]?e:{...e,[x]:!0}),j(e=>e[x]?{...e,[x]:!1}:e)},onError:c?void 0:()=>{return t=e.id,void I(e=>new Set([...e,t]));var t},className:"lb:w-full lb:h-full lb:object-contain lb:p-3 lb:transition-all lb:duration-300 lb:group-hover:scale-105 "+($?"lb:opacity-100":"lb:opacity-0")}),l.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-black/0 lb:group-hover:bg-black/10 lb:transition-colors lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:bg-black/60 lb:text-white lb:px-3 lb:py-1.5 lb:rounded-full lb:text-xs lb:font-medium lb:flex lb:items-center lb:gap-1.5",children:_?l.jsxs(l.Fragment,{children:[l.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Seleccionar"]}):l.jsxs(l.Fragment,{children:[l.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})}),"Ampliar"]})})})]}),c&&l.jsx("span",{className:"lb:absolute lb:top-3 lb:left-3 lb:bg-brand-blue-800 lb:text-white lb:text-xs lb:font-bold lb:px-3 lb:py-1.5 lb:rounded-lg lb:shadow-lg lb:z-20",children:"ORIGINAL"})]}),l.jsxs("div",{className:"lb:px-4 lb:py-3 lb:border-t lb:border-gray-100 lb:bg-white",children:[l.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-900 lb:truncate lb:mb-2",title:b,children:b}),l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[l.jsxs("span",{className:"lb:text-xs lb:text-gray-500 lb:font-medium",children:[m,"×",f," ·"," ",Math.round(v/1024),"KB"]}),l.jsxs("div",{className:"lb:flex lb:gap-2",role:"group","aria-label":`Acciones para ${b}`,children:[c&&T&&l.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:rounded-lg lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:cursor-pointer lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:e=>{e.stopPropagation(),o&&(p?.announce(`Abriendo herramienta de recorte para ${t.filename}`),o(t),a?.())},"aria-label":"Crear nuevo recorte",title:"Recortar",children:l.jsx("span",{className:"icon icon-scissors-white icon--sm"})}),z&&l.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:rounded-lg lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:cursor-pointer lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:l=>{l.stopPropagation();(async(e,t,l)=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(t);else{const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),document.body.removeChild(e)}C(e),p?.announce(`URL de ${l} copiada al portapapeles`),setTimeout(()=>C(null),2e3)}catch(n){console.error("Error al copiar URL:",n),p?.announceError(`Error al copiar URL de ${l}. Inténtalo de nuevo.`)}})(c?"original":e.id,c?t.url||t.path:e.url,b)},"aria-label":k===(c?"original":e.id)?"¡Copiado!":`Copiar URL de ${b}`,title:k===(c?"original":e.id)?"¡Copiado!":"Copiar URL",children:l.jsx("span",{className:`icon ${k===(c?"original":e.id)?"icon-copied-white":"icon-copy-white"} icon--sm`})}),A&&l.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:rounded-lg lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:cursor-pointer lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:l=>{l.stopPropagation(),c?(async()=>{const{downloadImage:e}=await Promise.resolve().then(()=>$n);await e(t.url||t.path,t.filename||"limbo-image",{originalFormat:t.format,accessibilityManager:p})})():(async e=>{const{downloadImage:t}=await Promise.resolve().then(()=>$n);await t(e.url,e.name||"limbo-variant",{originalFormat:e.format||e.output_format,accessibilityManager:p})})(e)},"aria-label":`Descargar ${b}`,title:"Descargar",children:l.jsx("span",{className:"icon icon-download-white icon--sm"})}),L&&(!c||i)&&l.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:rounded-lg lb:bg-red-1000 lb:hover:bg-red-800 lb:cursor-pointer lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-red-800 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:l=>{l.stopPropagation(),c?(async()=>{if(!i)return;window.confirm(`¿Estás seguro de que deseas eliminar "${t.filename}"? Esta acción también eliminará todos sus recortes.`)&&(p?.announce(`Eliminando imagen ${t.filename}`),await i(t.id),a?.())})():(async e=>{if(window.confirm(`¿Estás seguro de que deseas eliminar el recorte "${e.name||e.filename}"?`)){U(!0),p?.announce(`Eliminando recorte ${e.name||e.filename}`);try{const l=await h(t.id,e.id);l.success?(D(t=>new Set([...t,e.id])),e.url&&Se(e.url),g("Recorte eliminado correctamente"),y("success"),p?.announce("Recorte eliminado correctamente"),s?.(),document.dispatchEvent(new CustomEvent("limbo:variantDeleted",{detail:{assetId:t?.id,variantId:e.id}})),setTimeout(()=>{g(null),y(null)},3e3)):(g(`Error al eliminar recorte: ${l.error}`),y("error"),p?.announceError(`Error al eliminar recorte: ${l.error}`),setTimeout(()=>{g(null),y(null)},5e3))}finally{U(!1)}}})(e)},"aria-label":`Eliminar ${b}`,title:"Eliminar",children:l.jsx("span",{className:"icon icon-delete-white icon--2sm"})}),_&&l.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:cursor-pointer lb:rounded-lg lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:t=>{t.stopPropagation(),c?J():Y(e)},"aria-label":`Ampliar ${b}`,title:"Ampliar",children:l.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})})})]})]})]})]},c?"original":e.id)})})})]}),l.jsx(Re,{isOpen:!!x,src:x?.src||"",alt:x?.title||"Imagen",title:x?.title,subtitle:x?.subtitle,onClose:()=>w(null)})]})}const Fe="/api";let Ue={data:null,timestamp:0,pending:null};const Be=new Set;function qe(){Ue.data=null,Ue.timestamp=0,Ue.pending=null,Be.forEach(e=>e())}async function We(e={}){return Ue.data&&Date.now()-Ue.timestamp<3e5?Ue.data:(Ue.pending||(Ue.pending=async function(e={}){try{const t={include_counts:"true",...e},l=`/folders?${new URLSearchParams(t).toString()}`;return function(e){if(!e?.success||!e?.data)return{folders:[],total:0};const t=(e.data.folders||[]).map(e=>({id:e.id,name:e.name,slug:e.slug,description:e.description,visibility:e.visibility||"public",sort_order:e.sort_order||0,assets_count:e.assets_count||0,created_at:e.created_at,updated_at:e.updated_at}));return{folders:t,total:e.data.total||t.length}}(await W({endpoint:l,method:"GET",basePath:Fe,useJWT:!0}))}catch(t){throw Y(t)}}(e).then(e=>(Ue.data=e,Ue.timestamp=Date.now(),Ue.pending=null,e)).catch(e=>{throw Ue.pending=null,e})),Ue.pending)}function Ve(t={}){const{autoFetch:l=!0,visibility:n=null,allowedSlugs:a=null,excludeSlugs:r=null}=t,[i,o]=e.useState([]),[s,c]=e.useState(!1),[u,d]=e.useState(null),[b,m]=e.useState(!1),h=e.useRef(null),p=e.useCallback(e=>{let t=[...e];return a&&a.length>0&&(t=t.filter(e=>a.includes(e.slug))),r&&r.length>0&&(t=t.filter(e=>!r.includes(e.slug))),t.sort((e,t)=>e.sort_order!==t.sort_order?e.sort_order-t.sort_order:e.name.localeCompare(t.name)),t},[a,r]),f=e.useCallback(async(e={})=>{c(!0),d(null);try{const t={...n&&{visibility:n},...e},l=await We(t),a=p(l.folders||[]);return o(a),a}catch(t){return d(t.message),[]}finally{c(!1)}},[n,p]),g=e.useCallback(()=>(qe(),f()),[f]),v=e.useCallback(async e=>{m(!0),d(null);try{const t=await async function(e){try{return function(e){if(!e?.success||!e?.data)return{folder:null};const t=e.data;return{folder:{id:t.id,name:t.name,slug:t.slug,description:t.description,visibility:t.visibility||"public",sort_order:t.sort_order||0,assets_count:t.assets_count||0,created_at:t.created_at,updated_at:t.updated_at}}}(await W({endpoint:"/folders",method:"POST",body:{name:e.name,...e.slug&&{slug:e.slug},...e.description&&{description:e.description},...e.visibility&&{visibility:e.visibility}},basePath:Fe,useJWT:!0}))}catch(u){throw Y(u)}}(e),l=t.folder;return l&&(qe(),o(e=>{const t=[...e,l];return t.sort((e,t)=>e.sort_order!==t.sort_order?e.sort_order-t.sort_order:e.name.localeCompare(t.name)),t})),l}catch(t){return d(t.message),null}finally{m(!1)}},[]),y=e.useCallback(e=>i.find(t=>t.slug===e)||null,[i]),x=e.useCallback(e=>i.find(t=>t.id===e)||null,[i]);return h.current=f,e.useEffect(()=>{const e=()=>h.current?.();return Be.add(e),()=>Be.delete(e)},[]),e.useEffect(()=>{l&&f()},[l,f]),{folders:i,loading:s,error:u,creating:b,fetchFolders:f,create:v,refresh:g,findBySlug:y,findById:x,hasLoaded:!s&&i.length>=0}}function He({value:t=null,onChange:n,allowCreate:a=!0,placeholder:r="Sin carpeta",label:i=null,disabled:o=!1,className:s="",showAssetCount:c=!1,includeNoFolder:u=!0,allowedSlugs:d=null,excludeSlugs:b=null,mode:m="upload"}){const h=e.useId(),[p,f]=e.useState(!1),[g,v]=e.useState(""),[y,x]=e.useState(null),{folders:w,loading:k,error:C,creating:S,create:j,refresh:N}=Ve({autoFetch:!0,allowedSlugs:d,excludeSlugs:b}),E=async e=>{if(e.preventDefault(),x(null),!g.trim())return void x("El nombre es requerido");const t=await j({name:g.trim()});t?(n?.(t),f(!1),v("")):x("Error al crear la carpeta")},$=()=>{f(!1),v(""),x(null)};if(p)return l.jsxs("div",{className:`limbo-folder-selector limbo-folder-selector--creating ${s}`,children:[i&&l.jsxs("label",{className:"limbo-filter-label lb:block lb:mb-1 lb:text-white lb:ms-6",children:[i," ",S&&l.jsx("span",{className:"limbo-filter-searching","aria-hidden":"true",children:l.jsx("span",{className:"icon icon-spinner lb:animate-spin lb:w-3 lb:h-3"})})]}),l.jsxs("form",{onSubmit:E,className:"lb:flex lb:gap-2 lb:items-center lb:flex-col",children:[l.jsx("div",{children:l.jsx("input",{type:"text",value:g,onChange:e=>v(e.target.value),placeholder:"Nombre de la carpeta...",className:"limbo-filter-input lb:flex-1",autoFocus:!0,disabled:S})}),l.jsxs("div",{className:"lb:flex lb:gap-2",children:[l.jsx("button",{type:"submit",disabled:S||!g.trim(),className:"limbo-btn limbo-btn--primary lb:px-3 lb:py-1.5 lb:text-sm lb:rounded lb:bg-brand-blue-1000 lb:text-white lb:border-0 lb:cursor-pointer disabled:lb:opacity-50 disabled:lb:cursor-not-allowed lb:hover:bg-brand-blue-800",children:S?"...":"Crear"}),l.jsx("button",{type:"button",onClick:$,disabled:S,className:"limbo-btn limbo-btn--ghost lb:px-2 lb:py-1.5 lb:text-sm lb:rounded lb:hover:bg-gray-200 lb:bg-gray-300 lb:border lb:border-gray-300 lb:cursor-pointer",children:"Cancelar"})]})]}),y&&l.jsx("p",{className:"lb:text-red-600 lb:text-xs lb:mt-1",children:y})]});const _="filter"===m?"Todas las carpetas":r;return l.jsxs("div",{className:`limbo-folder-selector ${s}`,children:[i&&l.jsxs("label",{htmlFor:h,className:"limbo-filter-label lb:block lb:mb-1 lb:text-white",children:[i,k&&l.jsx("span",{className:"limbo-filter-searching","aria-hidden":"true",children:l.jsx("span",{className:"icon icon-spinner lb:animate-spin lb:w-3 lb:h-3"})})]}),l.jsx("div",{className:"lb:relative",children:l.jsxs("select",{id:h,value:t||"",onChange:e=>{const t=e.target.value;if("__create__"===t)return void f(!0);if(""===t||"__none__"===t)return void n?.(null);const l=w.find(e=>e.slug===t);n?.(l||null)},disabled:o||k,className:"limbo-filter-input limbo-filter-select lb:w-full",children:[u&&l.jsx("option",{value:"",children:_}),k&&l.jsx("option",{value:"",disabled:!0,children:"Cargando carpetas..."}),C&&!k&&l.jsx("option",{value:"",disabled:!0,children:"Error al cargar carpetas"}),!k&&!C&&w.map(e=>l.jsxs("option",{value:e.slug,children:[e.name,c&&` (${e.assets_count})`]},e.id)),a&&!k&&!C&&l.jsxs(l.Fragment,{children:[l.jsx("option",{disabled:!0,children:"──────────────"}),l.jsx("option",{value:"__create__",children:"+ Crear nueva carpeta..."})]})]})}),C&&l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:mt-1",children:[l.jsx("p",{className:"lb:text-red-600 lb:text-xs",children:C}),l.jsx("button",{type:"button",onClick:N,className:"lb:text-xs lb:text-brand-blue-1000 lb:underline lb:cursor-pointer",children:"Reintentar"})]})]})}const Ke={pdf:{symbol:"icon-doc-pdf",color:"#dc2626"},doc:{symbol:"icon-doc-word",color:"#2563eb"},docx:{symbol:"icon-doc-word",color:"#2563eb"},xls:{symbol:"icon-doc-xls",color:"#16a34a"},xlsx:{symbol:"icon-doc-xls",color:"#16a34a"},ppt:{symbol:"icon-doc-ppt",color:"#ea580c"},pptx:{symbol:"icon-doc-ppt",color:"#ea580c"},txt:{symbol:"icon-doc-text",color:"#6b7280"},csv:{symbol:"icon-doc-report",color:"#16a34a"},mp4:{symbol:"icon-video",color:"#7c3aed"},webm:{symbol:"icon-video",color:"#7c3aed"},mov:{symbol:"icon-video",color:"#7c3aed"},avi:{symbol:"icon-video",color:"#7c3aed"},mkv:{symbol:"icon-video",color:"#7c3aed"},gif:{symbol:"icon-video",color:"#7a3f2d"},mp3:{symbol:"icon-support-person",color:"#0891b2"},mpeg:{symbol:"icon-support-person",color:"#0891b2"},wav:{symbol:"icon-support-person",color:"#0891b2"},ogg:{symbol:"icon-support-person",color:"#0891b2"},aac:{symbol:"icon-support-person",color:"#0891b2"},flac:{symbol:"icon-support-person",color:"#0891b2"},default:{symbol:"icon-clip",color:"#6b7280"}},Ge=(e,t)=>0===t?e:Ge(t,e%t),Qe=new Set(["text/plain","text/csv","text/html","text/xml","text/css","text/javascript","text/markdown","application/json","application/xml","application/javascript"]);const Xe=e.memo(function({image:t,onDelete:n,onCrop:a,onSelect:r,onFolderChange:i,thumbnailSize:o=32,isDeleting:s=!1,showFolderInfo:c=!0,allowMoveFolder:u=!0,allowedFolderSlugs:d=null,excludedFolderSlugs:b=null,allowCreateFolder:m=!1,allowedActions:p={select:!0,download:!0,copy:!0,delete:!0,crop:!0,variants:!0,rename:!0},onEdit:f=null}){const[g,v]=e.useState(!1),[y,x]=e.useState(!1),[w,k]=e.useState(!1),[C,S]=e.useState(t.variants_count||0),[j,N]=e.useState(!1),[E,_]=e.useState(!1);e.useEffect(()=>{if(!j)return;const e=e=>{e.target.closest(".limbo-image-card-wrapper")||N(!1)},l=e=>{e.detail?.id!==t.id&&N(!1)};return document.addEventListener("click",e),document.addEventListener("limbo:folder-dropdown-open",l),()=>{document.removeEventListener("click",e),document.removeEventListener("limbo:folder-dropdown-open",l)}},[j,t.id]);const T=e.useMemo(()=>(e=>{if(e.asset_type)return e.asset_type;const t=e.mime_type||e.original_mime||"";return"image/gif"===t?"video":t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.includes("pdf")||t.includes("document")||t.includes("spreadsheet")||t.includes("presentation")||t.includes("text/")?"document":"unknown"})(t),[t]),A="image"===T,z=(t.mime_type||t.original_mime||"").includes("image/gif"),L=A||z,M=e.useMemo(()=>(e=>{if(!e)return"";const t=e.split(".");return t.length>1?t.pop().toLowerCase():""})(t.filename),[t.filename]),I=Ke[M]||Ke.default,P=e.useMemo(()=>((e,t)=>{if(!e||!t||e<=0||t<=0)return null;const l=Ge(Math.round(e),Math.round(t)),n=Math.round(e)/l,a=Math.round(t)/l;return n>20||a>20?null:`${n}:${a}`})(t.width,t.height),[t.width,t.height]),D=t.url||t.path,R=L&&t.thumbnail_url?t.thumbnail_url:D,[O,F]=e.useState(()=>we(R)),[U,B]=e.useState(()=>!ke(R)),[q,W]=e.useState(!1),[V,H]=e.useState(()=>ke(R)),K=e.useRef(null),{isMobile:G,isTouch:Q}=$(),X=window.limboCore?.accessibilityManager,Y=(window.limboCore?.config?.getGlobal()||{}).interaction||{allowSelection:!1,allowCropping:!0},J=async e=>{e.stopPropagation();let l=t.url||t.path;try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(l);else{const e=document.createElement("textarea");e.value=l,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),document.body.removeChild(e)}v(!0),X?.announce(`URL de ${t.filename} copiada al portapapeles. Nota: La URL puede tener un tiempo de validez limitado.`),setTimeout(()=>v(!1),2e3)}catch(n){console.error("Error al copiar URL:",n),X?.announce(`Error al copiar URL de ${t.filename}. Inténtalo de nuevo.`),alert(`Error al copiar URL de ${t.filename}. Por favor, inténtalo de nuevo.`)}},Z=async e=>{e.preventDefault(),e.stopPropagation();const l=t.url||t.path,n=t.filename||"limbo-file";if(!A){try{X?.announce(`Descargando ${n}`);const e=await fetch(l,{mode:"cors"});if(!e.ok)throw new Error(`HTTP error: ${e.status}`);const t=await e.blob(),a=window.URL.createObjectURL(t),r=document.createElement("a");r.href=a,r.download=n,r.style.display="none",document.body.appendChild(r),r.click(),setTimeout(()=>{window.URL.revokeObjectURL(a),document.body.removeChild(r)},100),X?.announce(`${n} descargado correctamente`)}catch(r){console.error("Error downloading file:",r),X?.announce(`Error al descargar ${n}`)}return}const{downloadImage:a}=await Promise.resolve().then(()=>$n);await a(l,n,{originalFormat:t.format,accessibilityManager:X})},ee=e=>{e.stopPropagation(),X?.announce(`Editando imagen ${t.filename}`),a?.(t)},te=e.useCallback(e=>{e.stopPropagation(),n?.(t.id)},[t.id,n]),le=A&&(t.variants&&t.variants.length>0||t.variants_count>0||C>0),ne=C,ae=e.useCallback(()=>{S(e=>Math.max(0,e-1))},[]);e.useEffect(()=>{S(t.variants_count||0)},[t.variants_count]),e.useEffect(()=>{if(!L)return B(!1),void H(!0);if(t.thumbnail_url){if(ke(t.thumbnail_url)){const e=we(t.thumbnail_url);return F(e),B(!1),W(!1),void H(!0)}return F(t.thumbnail_url),B(!0),W(!1),void H(!1)}const e=t.url||t.path;if(ke(e))return F(we(e)),B(!1),W(!1),void H(!0);B(!0),W(!1),H(!1),xe(e).then(e=>{F(e),B(!1),H(!0)}).catch(()=>{F(e),B(!1),W(!0)})},[t.url,t.path,t.thumbnail_url,L]),e.useEffect(()=>{if(!L||!U)return;const e=K.current;e&&e.complete&&e.naturalWidth>0&&(B(!1),H(!0),W(!1))},[L,U,O]);const re=Y.allowSelection&&p.select&&r,ie=z?D:null,oe=A&&!z&&Y.allowCropping&&p.crop&&a,se=()=>{le?(X?.announce(`Mostrando recortes de ${t.filename}`),x(!0)):re?(X?.announce(`Seleccionando ${t.filename} para el portal`),r?.(t)):(X?.announce(`Abriendo visor de ${t.filename}`),k(!0))};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:`limbo-image-card-wrapper lb:relative lb:cursor-pointer lb:focus:outline-0 ${s?"lb:opacity-50":""} ${G?"limbo-image-card-wrapper--mobile":""} ${j?"limbo-image-card-wrapper--has-active-dropdown":""}`,onClick:se,onKeyDown:e=>{if("INPUT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName)switch(e.key){case"Enter":case" ":e.preventDefault(),se();break;case"d":case"D":p.download&&(e.preventDefault(),Z(e));break;case"c":case"C":p.copy&&(e.preventDefault(),J(e));break;case"Delete":case"Backspace":p.delete&&n&&(e.preventDefault(),te(e));break;case"x":case"X":p.crop&&a&&(e.preventDefault(),ee(e));break;case"v":case"V":p.variants&&(e.preventDefault(),(e=>{e.stopPropagation(),X?.announce(`Mostrando recortes de ${t.filename}`),x(!0)})(e))}},onMouseEnter:ie?()=>{ie&&t.thumbnail_url&&F(ie)}:void 0,onMouseLeave:ie?()=>{ie&&t.thumbnail_url&&F(t.thumbnail_url)}:void 0,title:le?`Ver ${ne} recorte${1!==ne?"s":""} de ${t.filename}`:L?G?"Toque para ampliar imagen":"Click para ampliar imagen con zoom":G?"Toque para previsualizar":"Click para previsualizar",role:"button",tabIndex:0,"aria-label":L?`${z?"GIF":"Imagen"} ${t.filename}. ${t.width}x${t.height} px`:`Archivo ${t.filename}. Tipo: ${T}`,style:{...Q&&{touchAction:"manipulation",WebkitTapHighlightColor:"transparent"}},children:[E&&l.jsxs("div",{className:"limbo-moving-overlay",children:[l.jsx("span",{className:"icon icon-spinner lb:animate-spin lb:w-6 lb:h-6"}),l.jsx("span",{className:"lb:text-xs lb:text-gray-600 lb:font-medium",children:"Moviendo..."})]}),l.jsxs("div",{className:`limbo-image-actions ${j?"limbo-image-actions--expanded":""} ${G?"limbo-image-actions--mobile":""}`,children:[l.jsxs("div",{className:"limbo-image-actions__buttons",children:[(re||!L)&&l.jsx("button",{type:"button",title:le?`Ver ${ne} recortes`:L?"Ampliar imagen":"Previsualizar archivo","aria-label":le?h("imageCard.aria.zoomWithCrops",{n:ne,filename:t.filename}):h(L?"imageCard.aria.zoom":"imageCard.aria.zoomPreview",{filename:t.filename}),className:"limbo-action-btn lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(G?"lb:btn--touch":""),onClick:e=>{e?.stopPropagation(),X?.announce(`Abriendo visor de ${t.filename}`),k(!0)},tabIndex:0,children:l.jsx("span",{className:`icon ${L?"icon-zoom-in-white":"icon-search-white"} icon--sm`,"aria-hidden":"true"})}),oe&&l.jsx("button",{type:"button",title:"Nuevo recorte","aria-label":h("imageCard.aria.crop",{filename:t.filename}),className:"limbo-action-btn limbo-btn-crop lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(G?"lb:btn--touch":""),onClick:ee,tabIndex:0,children:l.jsx("span",{className:"icon icon-scissors-white icon--sm","aria-hidden":"true"})}),p.copy&&l.jsx("button",{type:"button",title:g?"¡Copiado!":"Copiar URL","aria-label":g?h("imageCard.aria.copied"):h("imageCard.aria.copyUrl",{filename:t.filename}),className:"limbo-action-btn limbo-btn-copy lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(G?"lb:btn--touch":""),onClick:J,tabIndex:0,children:l.jsx("span",{className:`icon ${g?"icon-copied-white":"icon-copy-white"} icon--sm`,"aria-hidden":"true"})}),p.download&&l.jsx("button",{type:"button",title:"Descargar","aria-label":h("imageCard.aria.download",{filename:t.filename}),className:"limbo-action-btn limbo-btn-download lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(G?"lb:btn--touch":""),onClick:Z,tabIndex:0,children:l.jsx("span",{className:"icon icon-download-white icon--sm","aria-hidden":"true"})}),u&&i&&l.jsx("button",{type:"button",title:t.folder?`Mover de carpeta (${t.folder?.name||t.folder?.slug||""})`:"Asignar a carpeta",className:`limbo-action-btn limbo-btn-folder lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 ${G?"lb:btn--touch":""} ${j?"limbo-action-btn--active":""}`,onClick:e=>{e.stopPropagation();const l=!j;N(l),l&&document.dispatchEvent(new CustomEvent("limbo:folder-dropdown-open",{detail:{id:t.id}}))},"aria-expanded":j,"aria-label":j?"Cerrar selector de carpeta":t.folder?`Mover de carpeta (${t.folder?.name||t.folder?.slug||""})`:"Asignar a carpeta",tabIndex:0,children:l.jsx("span",{className:"icon icon-folder-white icon--sm","aria-hidden":"true"})}),p.rename&&f&&l.jsx("button",{type:"button",title:"Editar archivo","aria-label":h("imageCard.aria.rename",{filename:t.filename}),className:"limbo-action-btn limbo-btn-rename lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(G?"lb:btn--touch":""),onClick:e=>{e.stopPropagation(),f(t)},tabIndex:0,children:l.jsx("span",{className:"icon icon-edit-white icon--sm","aria-hidden":"true"})}),p.delete&&n&&l.jsx("button",{onClick:te,disabled:s,className:"limbo-action-btn limbo-btn-delete lb:bg-red-800 lb:hover:bg-red-700 lb:border lb:border-red-700 "+(G?"lb:btn--touch lb:active:lb:bg-red-800":""),title:"Eliminar archivo","aria-label":h("imageCard.aria.delete",{filename:t.filename}),tabIndex:0,children:s?"…":l.jsx("span",{className:"icon icon-delete-white icon--1sm","aria-hidden":"true"})})]}),j&&u&&i&&l.jsx("div",{className:"limbo-image-actions__folder",onClick:e=>e.stopPropagation(),children:l.jsx(He,{value:t.folder?.slug||null,onChange:async e=>{if(!E){_(!0);try{await(i?.(t,e??null)),qe(),X?.announce(e?`${t.filename} movido a carpeta ${e.name}`:`${t.filename} movido a Sin carpeta`)}catch(l){console.error("Error moving to folder:",l),X?.announce(`Error al mover ${t.filename}`)}finally{_(!1),N(!1)}}},allowCreate:m,placeholder:"Sin carpeta",label:"Mover a carpeta",includeNoFolder:!0,allowedSlugs:d,excludeSlugs:b,disabled:E,mode:"upload"})})]}),l.jsxs("div",{className:"limbo-image-card "+(G?"limbo-image-card--mobile":""),children:[!L&&(t.thumbnail_url?l.jsxs("div",{className:"lb:relative lb:w-full lb:h-full lb:rounded lb:overflow-hidden lb:border lb:border-neutral-300",style:{...G&&{minHeight:`${Math.max(3*o,80)}px`}},children:[l.jsx("img",{src:t.thumbnail_url,alt:t.name||t.filename,className:"lb:w-full lb:h-full lb:object-cover lb:aspect-square",loading:"lazy",decoding:"async",draggable:!1,onError:e=>{e.target.style.display="none",e.target.nextElementSibling?.classList.remove("lb:hidden")}}),l.jsx("div",{className:(t.thumbnail_url?"lb:flex":"lb:hidden")+"lb:absolute lb:inset-0 lb:bg-linear-to-br lb:from-neutral-100 lb:to-neutral-200 lb:flex-col lb:items-center lb:justify-center",children:l.jsx("span",{className:"lb:mb-2 lb:h-[25%] lb:w-[25%]","aria-hidden":"true",children:l.jsx("span",{className:`icon ${I.symbol} lb:min-w-full lb:min-h-full`})})}),l.jsx("span",{className:"lb:absolute lb:bottom-1.5 lb:right-1.5 lb:text-[10px] lb:uppercase lb:font-bold lb:tracking-wide lb:px-1.5 lb:py-0.5 lb:rounded lb:shadow-sm",style:{backgroundColor:I.color,color:"white"},children:M||T})]}):l.jsxs("div",{className:"lb:w-full lb:h-full lb:rounded lb:bg-linear-to-br lb:from-neutral-100 lb:to-neutral-200 lb:flex lb:flex-col lb:items-center lb:justify-center lb:border lb:border-neutral-300",style:{...G&&{minHeight:`${Math.max(3*o,80)}px`}},children:[l.jsx("span",{className:"lb:mb-2 lb:h-[25%] lb:w-[25%]","aria-hidden":"true",children:l.jsx("span",{className:`icon ${I.symbol} lb:min-w-full lb:min-h-full`})}),l.jsx("span",{className:"lb:text-xs lb:uppercase lb:font-bold lb:tracking-wide lb:px-2 lb:py-0.5 lb:rounded",style:{backgroundColor:I.color,color:"white"},children:M||T})]})),L&&l.jsxs(l.Fragment,{children:[U&&!q&&l.jsx("div",{className:"lb:w-full lb:aspect-square lb:rounded lb:bg-neutral-200 lb:animate-pulse lb:flex lb:items-center lb:justify-center lb:absolute lb:inset-0 lb:z-10 "+(le?"lb:ring-2 lb:ring-brand-blue-400 lb:ring-offset-2":""),style:{...G&&{minHeight:`${Math.max(3*o,80)}px`}},children:l.jsx("span",{className:"icon icon-spinner lb:w-8 lb:h-8 lb:animate-spin"})}),q&&!V&&l.jsxs("div",{className:"lb:z-0 lb:absolute lb:top-0 lb:left-0 lb:w-full lb:aspect-square lb:rounded lb:bg-neutral-100 lb:flex lb:flex-col lb:items-center lb:justify-center lb:text-neutral-400",style:{...G&&{minHeight:`${Math.max(3*o,80)}px`}},children:[l.jsx("span",{className:"icon icon-close icon--lg lb:mb-1","aria-hidden":"true"}),l.jsx("span",{className:"lb:text-xs",children:"Error al cargar"})]}),l.jsx("img",{ref:K,src:O,loading:"lazy",decoding:"async",alt:t.name||(t.filename.split(".")[0]??t.filename),className:`lb:z-1 lb:w-full lb:object-cover lb:rounded lb:aspect-square lb:transition-opacity lb:duration-300 ${le?"lb:ring-2 lb:ring-brand-blue-400 lb:ring-offset-2":""} ${V?"lb:opacity-100":"lb:opacity-0"}`,sizes:`height: ${6*o}px,width: ${6*o}px`,draggable:!1,onLoad:()=>{B(!1),H(!0),W(!1)},onError:()=>{B(!1),W(!0)},style:{...G&&{minHeight:`${Math.max(3*o,80)}px`,height:"auto",aspectRatio:"1 / 1",objectFit:"cover"}}}),z&&l.jsx("span",{className:"lb:absolute lb:bottom-1.5 lb:right-1.5 lb:text-[10px] lb:uppercase lb:font-bold lb:tracking-wide lb:px-1.5 lb:py-0.5 lb:rounded lb:shadow-sm",style:{backgroundColor:I.color,color:"white"},children:M||T}),A&&!le&&t.width&&t.height&&l.jsxs("span",{className:"lb:absolute lb:bottom-1.5 lb:right-1.5 lb:text-[10px] lb:font-bold lb:tracking-wide lb:px-1.5 lb:py-0.5 lb:rounded lb:shadow-sm lb:leading-tight lb:text-center lb:flex lb:flex-col lb:items-center",style:{backgroundColor:"rgba(15,23,42,0.72)",color:"white"},title:`${t.width} × ${t.height} px`,children:[l.jsxs("span",{children:[t.width,"×",t.height]}),P&&l.jsx("span",{style:{opacity:.85},children:P})]})]}),l.jsxs("div",{className:"limbo-card-info-overlay lb:z-9 "+(G?"limbo-card-info-overlay--mobile":""),children:[l.jsxs("span",{className:"limbo-card-info-name lb:truncate lb:max-w-full",children:[t.filename.split(".")[0]??t.filename,le&&l.jsx("span",{className:"limbo-variants-indicator",style:{marginLeft:"4px",padding:"1px 6px",backgroundColor:"#dc2626",color:"white",borderRadius:"10px",fontSize:"10px",fontWeight:"700",display:"inline-block"},title:`${ne} recorte${1!==ne?"s":""}`,children:ne})]}),c&&t.folder&&l.jsxs("span",{className:"limbo-card-info-folder lb:flex lb:items-center lb:gap-1 lb:bg-brand-blue-50 lb:rounded-md lb:px-1",title:`Carpeta: ${t.folder?.name||t.folder?.slug||t.folder}`,children:[l.jsx("span",{className:"icon icon-folder icon--sm"}),l.jsx("span",{className:"lb:truncate lb:max-w-20",children:t.folder?.name||t.folder?.slug||("string"==typeof t.folder?t.folder:"Sin carpeta")})]})]})]})]}),l.jsx(Oe,{image:t,isOpen:y,onClose:()=>x(!1),onSelect:r,onDelete:n,onCrop:a,onVariantDeleted:ae,allowedActions:{select:p.select,download:p.download,copy:p.copy,delete:p.delete,crop:p.crop}}),w&&(()=>{const e=t.url||t.path,n=()=>k(!1),a=t.file_size?`${Math.round(t.file_size/1024)}KB`:"",r=t.mime_type||"";return L?l.jsx(Re,{isOpen:!0,src:e,alt:t.name||t.filename,title:t.filename,subtitle:`${t.width||"?"}×${t.height||"?"} · ${a}`,onClose:n,tags:t.tags||[]}):"video"===T?l.jsx(Ee,{isOpen:!0,src:e,title:t.filename,subtitle:`${M.toUpperCase()} · ${a}`,onClose:n}):"audio"===T?l.jsx($e,{isOpen:!0,src:e,title:t.filename,subtitle:`${M.toUpperCase()} · ${a}`,onClose:n}):r.includes("pdf")?l.jsx(_e,{isOpen:!0,src:e,title:t.filename,subtitle:a,onClose:n}):(e=>!(!e||!Qe.has(e)&&!e.startsWith("text/")))(r)?l.jsx(De,{isOpen:!0,src:e,title:t.filename,subtitle:`${M.toUpperCase()} · ${a}`,mimeType:r,fileSize:t.file_size||0,onClose:n}):l.jsx(Ie,{isOpen:!0,src:e,title:t.filename,subtitle:`${M.toUpperCase()} · ${a}`,mimeType:r,fileSize:t.file_size||0,onClose:n})})()]})});function Ye(){return l.jsxs("div",{className:"limbo-image-card lb:animate-pulse",role:"status","aria-label":"Cargando imágen...",children:[l.jsx("div",{className:"lb:w-full lb:aspect-square lb:bg-neutral-gray-200 lb:rounded-md lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-spinner"})}),l.jsx("div",{className:"limbo-image-card-name lb:opacity-100 position-relative lb:bottom-0 lb:p-2",children:l.jsx("div",{className:"lb:h-4 lb:bg-neutral-gray-200 lb:rounded lb:w-3/4"})}),l.jsx("span",{className:"sr-only",children:"Cargando imágen..."})]})}const Je=[{value:"",label:"Todos los tipos"},{value:"image",label:"Imágenes"},{value:"video",label:"Videos"},{value:"document",label:"Documentos"},{value:"audio",label:"Audio"}];function Ze({onSelect:t,onCrop:r,onDelete:i,deletingId:o,images:s,loading:c,error:u,filters:d={name:"",dateFrom:"",dateTo:"",uploadedBy:"",assetType:"",folder:""},debouncedFilters:b=null,onFiltersChange:m,filterConfig:p={showNameFilter:!0,showUploadedByFilter:!1,showDateFilter:!0,showTypeFilter:!1},loadingConfig:f={showPlaceholders:!0,placeholderCount:10,showSpinner:!0},allowedActions:g={select:!0,download:!0,copy:!0,delete:!0,crop:!0,variants:!0},allowedCategories:v=null,resolvedAccept:y=null,folderConfig:x=null,onFolderChange:w=null,onRename:k=null,onEdit:C=null}){const{isSearching:S,searchPending:j}=function(t,l,n){const[a,r]=e.useState(!1),i=e.useRef(null);return e.useEffect(()=>(Object.keys(t).some(e=>t[e]!==l[e])?i.current=setTimeout(()=>{r(!0)},150):(i.current&&clearTimeout(i.current),r(!1)),()=>{i.current&&clearTimeout(i.current)}),[t,l]),{isSearching:a||n,searchPending:a}}(d,b||d,c),N=!1!==p.showNameFilter,E=!0===p.showUploadedByFilter,$=!1!==p.showDateFilter,_=!1!==p.showTypeFilter,T=!0===x?.showFolderFilter,A=x?.include?.length>0?x.include:null,z=x?.exclude?.length>0?x.exclude:null,L=!1!==x?.showFolderInfo,M=!1!==x?.allowMoveFolder&&!!w,I=!0===x?.allowCreateFolder,P=e.useMemo(()=>{const e=y&&!y.isAllTypes?function(e){if(!e||e.isAllTypes)return null;const t=new Set(e.categories);for(const l of e.extensions){const e=n[l]||[];for(const l of e)for(const[e,n]of Object.entries(a))n.includes(l)&&t.add(e)}for(const l of e.mimeTypes)for(const[e,n]of Object.entries(a))(n.includes(l)||l.startsWith(e+"/"))&&t.add(e);return t.size>0?[...t]:null}(y):v;return e?Je.filter(t=>""===t.value||e.includes(t.value)):Je},[y,v]),D=e.useRef(null),R=window.limboCore?.accessibilityManager;e.useEffect(()=>{if(D.current&&window.limboCore?.keyboardManager){const e="gallery-grid";D.current.setAttribute("data-grid-id",e),window.limboCore.keyboardManager.setupGridNavigation(D.current,{itemSelector:".limbo-image-card",gridId:e,columns:"auto"})}},[s]),e.useEffect(()=>{if(!c&&s.length>0){const e=s.slice(0,12).map(e=>e.url||e.path).filter(Boolean);e.length>0&&Ce(e,4)}},[c,s]);const O=e.useMemo(()=>{if(!d.assetType)return"archivos";return{image:"imágenes",video:"videos",document:"documentos",audio:"archivos de audio"}[d.assetType]||"archivos"},[d.assetType]);e.useEffect(()=>{c?R?.announceLoading(!0,"galería"):c||u?u&&R?.announceError(u,"galería"):(R?.announceLoading(!1,"galería"),s.length>0&&R?.announce(`Se encontraron ${s.length} ${O} en la galería`))},[c,u,s.length,R,O]),e.useEffect(()=>{j&&R?.announce("Buscando...","polite")},[j,R]);const F=e=>{const{name:t,value:l}=e.target;m&&m({...d,[t]:l})},U=d.name||d.dateFrom||d.dateTo||d.uploadedBy||d.assetType||d.folder,B=S&&s.length>0&&!c;return l.jsxs("div",{className:"lb:w-full lb:max-w-full lb:py-2 lb:overflow-x-hidden lb:box-border",children:[l.jsx("div",{className:"lb:px-2 lb:mb-3 lb:mx-2 lb:max-w-full lb:overflow-x-hidden lb:box-border",children:l.jsxs("form",{className:"limbo-filters flex items-stretch content-stretch flex-row",onSubmit:e=>e.preventDefault(),role:"search","aria-label":"Filtrar archivos",children:[N&&l.jsxs("div",{className:"limbo-filter-group limbo-filter-group--name",children:[l.jsxs("label",{htmlFor:"name",className:"limbo-filter-label",children:["Nombre",j&&l.jsx("span",{className:"limbo-filter-searching","aria-hidden":"true",children:l.jsx("span",{className:"icon icon-spinner lb:animate-spin lb:w-3 lb:h-3"})})]}),l.jsx("input",{type:"text",name:"name",id:"name",placeholder:h("tags.search.placeholder"),value:d.name,onChange:F,className:"limbo-filter-input",autoComplete:"off"})]}),$&&l.jsxs("div",{className:"limbo-filter-dates lb:flex-row lb:md:flex ",children:[l.jsxs("div",{className:"limbo-filter-group limbo-filter-group--date",children:[l.jsx("label",{htmlFor:"dateFrom",className:"limbo-filter-label",children:"Desde"}),l.jsx("input",{type:"date",name:"dateFrom",id:"dateFrom",value:d.dateFrom,onChange:F,className:"limbo-filter-input"})]}),l.jsxs("div",{className:"limbo-filter-group limbo-filter-group--date",children:[l.jsx("label",{htmlFor:"dateTo",className:"limbo-filter-label",children:"Hasta"}),l.jsx("input",{type:"date",name:"dateTo",id:"dateTo",value:d.dateTo,onChange:F,className:"limbo-filter-input"})]})]}),_&&P.length>1&&l.jsxs("div",{className:"limbo-filter-group limbo-filter-group--type",children:[l.jsx("label",{htmlFor:"assetType",className:"limbo-filter-label",children:"Tipo"}),l.jsx("select",{name:"assetType",id:"assetType",value:d.assetType||"",onChange:F,className:"limbo-filter-input limbo-filter-select",children:P.map(e=>l.jsx("option",{value:e.value,children:e.label},e.value))})]}),T&&l.jsx("div",{className:"limbo-filter-group limbo-filter-group--folder",children:l.jsx(He,{value:d.folder||"",onChange:e=>F({target:{name:"folder",value:e?.slug||""}}),allowCreate:!1,label:"Carpeta",showAssetCount:!0,includeNoFolder:!0,allowedSlugs:A,excludeSlugs:z,mode:"filter"})}),E&&l.jsxs("div",{className:"limbo-filter-group",children:[l.jsx("label",{htmlFor:"uploadedBy",className:"limbo-filter-label",children:"Subido por"}),l.jsx("input",{type:"text",name:"uploadedBy",id:"uploadedBy",placeholder:"Usuario...",value:d.uploadedBy,onChange:F,className:"limbo-filter-input",style:{minWidth:"100px",maxWidth:"140px"}})]}),l.jsxs("div",{children:[l.jsx("span",{className:"lb:h-[37%] block"}),l.jsxs("button",{type:"button",onClick:()=>{m&&m({name:"",uploadedBy:"",dateFrom:"",dateTo:"",assetType:"",folder:""})},disabled:!U,className:"limbo-filter-clear-btn","aria-label":"Limpiar todos los filtros",title:"Limpiar filtros",children:[l.jsx("span",{className:"icon icon-close-small"}),"Limpiar"]})]})]})}),c?l.jsxs("div",{className:"lb:relative",children:[l.jsx("div",{className:"lb:relative lb:inset-0 lb:flex lb:items-center lb:justify-center lb:bg-white/80 lb:z-10 lb:min-h-75",children:l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-3",children:[l.jsx("span",{className:"icon icon-spinner lb:p-4 lb:animate-spin"}),l.jsxs("span",{className:"lb:text-sm lb:text-gray-600 lb:font-medium",children:["Cargando ",O,"..."]})]})}),f.showPlaceholders&&l.jsx("div",{ref:D,className:"limbo-gallery lb:opacity-30","data-limbo-responsive":!0,role:"grid","aria-label":`Cargando ${O} de la galería`,"aria-busy":"true",children:Array.from({length:f.placeholderCount}).map((e,t)=>l.jsx("div",{role:"gridcell","aria-posinset":t+1,"aria-setsize":f.placeholderCount,className:"lb:min-w-0",children:l.jsx(Ye,{})},`skeleton-${t}`))})]}):u?l.jsx(fe,{variant:"danger",className:"lb:text-center",children:u}):l.jsxs("div",{className:"lb:relative",children:[B&&l.jsx("div",{className:"limbo-search-overlay",role:"status","aria-live":"polite","aria-label":"Buscando archivos",children:l.jsxs("div",{className:"limbo-search-overlay__content",children:[l.jsx("span",{className:"icon icon-spinner lb:animate-spin"}),l.jsx("span",{children:"Buscando..."})]})}),l.jsx("div",{ref:D,className:"limbo-gallery lb:px-3 lb:pt-4 lb:box-border lb:max-w-full "+(B?"lb:opacity-50 lb:pointer-events-none":""),"data-limbo-responsive":!0,"data-grid-id":"gallery-grid",role:"grid","aria-label":`Galería de ${O}. Use las flechas para navegar`,"aria-busy":B,children:s.length>0?s.map((e,n)=>l.jsx("div",{role:"gridcell","aria-posinset":n+1,"aria-setsize":s.length,className:"lb:min-w-0",children:l.jsx(Xe,{image:e,onSelect:t,onCrop:r,onDelete:g.delete&&i?()=>i(e.id):null,onFolderChange:w,onRename:k,onEdit:C,thumbnailSize:32,isDeleting:o===e.id,showFolderInfo:L,allowMoveFolder:M,allowedFolderSlugs:A,excludedFolderSlugs:z,allowCreateFolder:I,allowedActions:g})},e.id)):l.jsx("div",{className:"lb:col-span-full lb:text-center lb:text-gray-500 lb:py-8",role:"status","aria-live":"polite",children:l.jsxs("p",{children:["No se han encontrado ",O]})})})]})]})}function et({currentPage:t,totalPages:n,onPageChange:a,disabled:r=!1}){if(!n||n<=1)return null;const i=(()=>{const e=[],l=[],a=Math.max(1,t-2),r=Math.min(n,t+2);for(let t=a;t<=r;t++)e.push(t);return a>1&&(l.push(1),a>2&&l.push("...")),l.push(...e),r<n&&(r<n-1&&l.push("..."),l.push(n)),l})();return l.jsx("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:space-x-2 lb:py-4",children:l.jsxs("div",{className:"lb:flex lb:space-x-2 lb:mt-2",children:[l.jsxs("button",{onClick:()=>{t>1&&a(t-1)},disabled:r||t<=1,className:` lb:px-3 lb:py-2 lb:text-sm lb:font-medium lb:rounded-md lb:transition-colors lb:disabled:cursor-default lb:cursor-pointer ${r||t<=1?"lb:text-gray-400 lb:bg-gray-100 lb:cursor-not-allowed":"lb:text-gray-700 lb:bg-white lb:border lb:border-gray-300 lb:hover:bg-gray-50 lb:focus:ring-2 lb:focus:ring-blue-500"} `,children:[l.jsx("span",{className:"icon icon-arrow-left icon--sm"})," Anterior"]}),l.jsx("div",{className:"lb:flex lb:space-x-1",children:i.map((n,i)=>l.jsx(e.Fragment,{children:"..."===n?l.jsx("span",{className:"lb:px-3 lb:py-2 lb:text-sm lb:text-gray-500",children:"..."}):l.jsx("button",{onClick:()=>(e=>{e!==t&&a(e)})(n),disabled:r,className:` lb:px-3 lb:py-2 lb:text-sm lb:font-medium lb:rounded-md lb:transition-colors lb:disabled:cursor-default lb:cursor-pointer ${n===t?"lb:bg-brand-blue-800 lb:text-white lb:border lb:border-brand-blue-1000":r?"lb:text-gray-400 lb:bg-gray-100 lb:cursor-not-allowed":"lb:text-gray-700 lb:bg-white lb:border lb:border-gray-300 lb:hover:bg-gray-50 lb:focus:ring-2 lb:focus:ring-blue-500"} `,children:n})},`page-${n}-${i}`))}),l.jsxs("button",{onClick:()=>{t<n&&a(t+1)},disabled:r||t>=n,className:` lb:px-3 lb:py-2 lb:text-sm lb:font-medium lb:rounded-md lb:transition-colors lb:disabled:cursor-default lb:cursor-pointer ${r||t>=n?"lb:text-gray-400 lb:bg-gray-100 lb:cursor-not-allowed":"lb:text-gray-700 lb:bg-white lb:border lb:border-gray-300 lb:hover:bg-gray-50 lb:focus:ring-2 lb:focus:ring-blue-500"} `,children:["Siguiente ",l.jsx("span",{className:"icon icon-arrow-right icon--sm"})]})]})})}function tt({text:e="Cargando..."}){return l.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-neutral-gray-1000/20 lb:z-10 lb:flex lb:flex-col lb:items-center lb:justify-center lb:py-8 lb:text-gray-600",role:"status","aria-live":"polite","aria-label":e,children:[l.jsx("span",{className:"limbo-filter-searching","aria-hidden":"true",children:l.jsx("span",{className:"icon icon-spinner lb:animate-spin lb:min-w-7 lb:min-h-7"})}),l.jsx("p",{className:"lb:text-sm",id:"loader-text",children:e})]})}function lt({onSelect:e,onCrop:t,onDelete:n,onFolderChange:a,onRename:r,onEdit:i,onPageChange:o,onFiltersChange:s,images:c,loadingImages:u,imagesError:d,deleting:b,uploadedImage:m,pagination:h,currentPage:p,galleryFilters:f,debouncedFilters:g,allowedActions:v,resolvedAccept:y,allowedCategories:x,folderConfig:w,filterConfig:k,loadingConfig:C,resetUpload:S}){return l.jsxs(l.Fragment,{children:[b&&l.jsx(tt,{text:"Eliminando archivo..."}),m&&l.jsxs(fe,{variant:"success",toast:!0,onClose:S,children:[l.jsx("span",{className:"icon icon-tick-white icon--2sm"})," Archivo subido correctamente: ",m.filename]}),l.jsx(Ze,{onSelect:e,onCrop:t,onDelete:n,deletingId:b,images:c,loading:u,error:d,filters:f,debouncedFilters:g,onFiltersChange:s,filterConfig:k,loadingConfig:C,allowedActions:v,resolvedAccept:y,allowedCategories:x,folderConfig:w,onFolderChange:a,onRename:r,onEdit:i}),h&&!u&&l.jsx(et,{currentPage:h.page||p,totalPages:h.pages||1,onPageChange:o,disabled:u||b})]})}function nt({previewUrl:t,fileName:n}){const[a,r]=e.useState(!1),[i,o]=e.useState(!1),s=e.useRef(null);return i?l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:p-8 lb:min-h-[200px] lb:bg-gray-100 lb:rounded-lg",children:[l.jsx("span",{className:"icon icon-video icon--xl lb:text-gray-400 lb:mb-4"}),l.jsx("p",{className:"lb:text-sm lb:text-gray-600",children:"No se puede reproducir el video"}),l.jsx("p",{className:"lb:text-xs lb:text-gray-500 lb:mt-1",children:n})]}):l.jsxs("div",{className:"lb:relative lb:w-full lb:min-w-65 lb:max-w-md lb:aspect-video lb:bg-black lb:rounded-lg lb:overflow-hidden",children:[l.jsx("video",{ref:s,src:t,className:"lb:absolute lb:inset-0 lb:w-full lb:h-full lb:object-contain",onEnded:()=>{r(!1)},onError:()=>{o(!0)},onPlay:()=>r(!0),onPause:()=>r(!1),controls:!0,preload:"metadata",children:"Tu navegador no soporta la reproduccion de video."}),!a&&l.jsx("button",{type:"button",onClick:()=>{s.current&&(a?s.current.pause():s.current.play(),r(!a))},className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center lb:bg-black/30 lb:hover:bg-black/40 lb:transition-colors lb:cursor-pointer","aria-label":"Reproducir video",children:l.jsx("div",{className:"lb:w-16 lb:h-16 lb:rounded-full lb:bg-white/90 lb:flex lb:items-center lb:justify-center lb:shadow-lg",children:l.jsx("span",{className:"icon icon-play icon--lg lb:text-gray-800 lb:ml-1"})})}),l.jsxs("div",{className:"lb:absolute lb:top-2 lb:right-2 lb:bg-black/60 lb:text-white lb:px-2 lb:py-1 lb:rounded lb:text-xs lb:flex lb:items-center lb:gap-1",children:[l.jsx("span",{className:"icon icon-video icon--xs"}),l.jsx("span",{children:"VIDEO"})]})]})}function at({previewUrl:t,fileName:n,fileSize:a}){const[r,i]=e.useState(!1),[o,s]=e.useState(!1),[c,u]=e.useState(0),[d,b]=e.useState(0),m=e.useRef(null),h=e=>{if(!e||isNaN(e))return"0:00";return`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,"0")}`};return o?l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:p-8 lb:min-h-50 lb:bg-gray-100 lb:rounded-lg",children:[l.jsx("span",{className:"icon icon-audio icon--xl lb:text-gray-400 lb:mb-4"}),l.jsx("p",{className:"lb:text-sm lb:text-gray-600",children:"No se puede reproducir el audio"}),l.jsx("p",{className:"lb:text-xs lb:text-gray-500 lb:mt-1",children:n})]}):l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:p-6 lb:min-h-50",children:[l.jsxs("div",{className:"lb:relative lb:mb-4",children:[l.jsx("div",{className:"lb:w-24 lb:h-24 lb:flex lb:items-center lb:justify-center lb:bg-linear-to-br lb:from-purple-100 lb:to-blue-100 lb:rounded-full",children:l.jsx("span",{className:"icon icon-audio icon--xl lb:text-purple-600"})}),l.jsx("button",{type:"button",onClick:()=>{m.current&&(r?m.current.pause():m.current.play())},className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center lb:rounded-full lb:bg-black/0 lb:hover:bg-black/10 lb:transition-colors lb:cursor-pointer","aria-label":r?"Pausar":"Reproducir",children:l.jsx("div",{className:"lb:w-10 lb:h-10 lb:rounded-full lb:bg-white lb:shadow-md lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:`icon ${r?"icon-pause":"icon-play"} icon--md lb:text-gray-800 ${r?"":"lb:ml-0.5"}`})})})]}),l.jsx("p",{className:"lb:text-sm lb:font-medium lb:text-gray-800 lb:text-center lb:max-w-full lb:truncate lb:px-4",children:n}),l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:mt-2 lb:text-xs lb:text-gray-500",children:[l.jsx("span",{children:h(d)}),l.jsx("span",{children:"/"}),l.jsx("span",{children:h(c)}),a&&l.jsxs(l.Fragment,{children:[l.jsx("span",{children:"•"}),l.jsx("span",{children:Le(a)})]})]}),l.jsx("div",{className:"lb:w-full lb:max-w-xs lb:mt-3",children:l.jsx("div",{className:"lb:h-1.5 lb:bg-gray-200 lb:rounded-full lb:overflow-hidden lb:cursor-pointer",onClick:e=>{if(!m.current||!c)return;const t=e.currentTarget.getBoundingClientRect(),l=e.clientX-t.left;m.current.currentTime=l/t.width*c},role:"slider","aria-label":"Progreso de audio","aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":c,tabIndex:0,children:l.jsx("div",{className:"lb:h-full lb:bg-purple-500 lb:rounded-full lb:transition-all lb:duration-100 lb:pointer-events-none",style:{width:c>0?d/c*100+"%":"0%"}})})}),l.jsx("audio",{ref:m,src:t,onPlay:()=>i(!0),onPause:()=>i(!1),onTimeUpdate:()=>{m.current&&b(m.current.currentTime)},onLoadedMetadata:()=>{m.current&&u(m.current.duration)},onEnded:()=>{i(!1),b(0)},onError:()=>{s(!0)},preload:"metadata"})]})}function rt({file:t,image:n,onDiscard:a,onRetry:r,onDownload:i,onSelect:o,showRetry:s=!1,disabled:c=!1,showCropButton:u,onTagsChange:d=null,tags:b=[],selectedFolder:m=null,onFolderChange:h=null,folderConfig:p=null}){const f=t||n,[g,v]=e.useState(null),[y,x]=e.useState({name:"",size:"",type:"",category:"unknown"}),[w,k]=e.useState(!1),[C,S]=e.useState(!1),[j,N]=e.useState(""),E="image"===y.category,$="video"===y.category,_="audio"===y.category,T=void 0!==u?u:E;e.useEffect(()=>{if(!f)return void v(null);const e=URL.createObjectURL(f);v(e);const t=f.name||"archivo",l=f.type||"",n=(e=>e?e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":"application/pdf"===e||e.includes("document")||e.includes("msword")||e.includes("spreadsheet")||e.includes("presentation")||e.startsWith("text/")?"document":"unknown":"unknown")(l),a=(e=>{const t=e?.split(".")[0]?.toLowerCase()||"";return["ai-image","ai_image","generated","imagen-ia","imagen_ia"].some(e=>t.startsWith(e))})(t);if(x({name:t,size:Le(f.size||0),type:l,category:n}),a)N(""),S(!1);else{const e=t.split(".")[0];N(e)}return()=>{URL.revokeObjectURL(e)}},[f]);if(!f||!g)return null;return l.jsxs("div",{className:"lb:w-full lb:max-w-full lb:bg-white lb:border lb:border-gray-200 lb:rounded-lg lb:px-1 lb:sm:px-3 lb:py-2 lb:m-0 lb:shadow-sm lb:overflow-hidden lb:box-border",children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:mb-4 lb:px-1",children:[l.jsx("h3",{className:"lb:text-sm lb:font-medium lb:text-gray-700",children:(()=>{switch(y.category){case"image":return"Vista previa de imagen";case"video":return"Vista previa de video";case"audio":return"Vista previa de audio";case"document":return"Vista previa de documento";default:return"Vista previa de archivo"}})()}),l.jsx("button",{type:"button",onClick:a,disabled:c,className:"lb:p-1.5 lb:text-gray-400 lb:cursor-pointer lb:hover:text-gray-600 lb:hover:bg-red-300 lb:rounded lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":"Descartar archivo",title:"Descartar archivo",children:l.jsx("span",{className:"icon icon-close-small icon--md"})})]}),l.jsx("div",{className:"lb:flex lb:justify-center lb:content-stretch lb:items-stretch",children:l.jsxs("div",{className:"lb:flex lb:flex-col lb:justify-stretch lb:content-stretch",children:[p?.showFolderSelector&&h&&l.jsx("div",{className:"lb:mb-4 lb:px-1 lb:flex lb:items-stretch lb:justify-stretch",children:l.jsx(He,{value:m?.slug||m,onChange:h,allowCreate:!1!==p?.allowCreateFolder,label:"Guardar en carpeta",showAssetCount:!0,className:"lb:w-full",allowedSlugs:p?.include?.length>0?p.include:null,mode:"upload",disabled:c})}),d&&l.jsxs("div",{className:"lb:mb-4 lb:px-1",children:[l.jsx("label",{className:"lb:block lb:text-sm lb:font-semibold lb:text-neutral-gray-700 lb:mb-2",children:b.length>0?"Etiquetas":"Etiquetas (opcional)"}),l.jsx(ne,{value:b,onChange:d,disabled:c,id:"asset-preview-tags"}),l.jsx("p",{className:"lb:text-xs lb:text-neutral-gray-500 lb:mt-2",children:"Pulsa espacio o coma para confirmar una etiqueta"})]}),l.jsxs("div",{className:"lb:flex lb:flex-col lb:justify-center lb:md:flex-row lb:gap-2 lb:md:gap-6",children:[l.jsxs("div",{className:"lb:flex-1 lb:flex lb:flex-col lb:items-center lb:justify-center"+(E?" lb:min-w-100":""),children:[E?l.jsxs("div",{className:"lb:relative lb:w-full lb:max-w-md lb:aspect-video lb:bg-gray-100 lb:rounded-lg lb:overflow-hidden lb:cursor-zoom-in lb:hover:ring-2 lb:hover:ring-brand-blue-800 lb:transition-all",onClick:()=>k(!0),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),k(!0))},"aria-label":"Click para ver imagen en tamano completo",title:"Click para ver en tamano completo",children:[l.jsx("img",{src:g,alt:"Vista previa",className:"lb:absolute lb:inset-0 lb:w-full lb:h-full lb:object-contain"}),l.jsxs("div",{className:"lb:absolute lb:top-2 lb:right-2 lb:bg-black/50 lb:text-white lb:px-2 lb:py-1 lb:rounded lb:text-xs lb:flex lb:items-center lb:gap-1",children:[l.jsx("span",{className:"icon icon-search-white icon--xs"}),l.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Ampliar"})]})]}):$?l.jsx(nt,{previewUrl:g,fileName:y.name}):_?l.jsx(at,{previewUrl:g,fileName:y.name,fileSize:f?.size}):l.jsx(Me,{file:f,mimeType:y.type,category:y.category}),E&&l.jsx("div",{className:"lb:mt-3 lb:text-center lb:space-y-1 lb:w-full",children:l.jsx("div",{className:"lb:rounded-sm lb:w-fit lb:gap-0.5 lb:p-0.5 lb:min-w-fit lb:mx-auto",children:l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:gap-3 lb:text-xs lb:text-gray-500",children:[l.jsx("span",{children:y.size}),l.jsx("span",{children:"•"}),l.jsx("span",{children:y.type.split("/")[1]?.toUpperCase()||"FILE"})]})})})]}),l.jsxs("div",{className:"lb:flex lb:flex-row lb:md:flex-col lb:gap-2 lb:justify-items-stretch lb:justify-center lb:md:justify-start lb:items-stretch lb:md:min-w-35",children:[l.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-1",children:[l.jsxs("label",{htmlFor:"assetPreviewNameInput",className:"lb:flex lb:items-center lb:w-fit",children:[l.jsx("span",{className:"lb:me-1 lb:text-sm",children:"Nombre:"}),l.jsx("input",{id:"assetPreviewNameInput",onChange:e=>(e=>{const t=e.target.value.trim();N(e.target.value),t.length>0&&S(!1);const l=y.name,n=l.lastIndexOf("."),a=-1!==n?l.substring(n):"";x(e=>({...e,name:t?t+a:a}))})(e),value:j,className:"limbo-input-image-name lb:w-fit lb:px-1 lb:text-sm lb:font-medium lb:text-gray-800 lb:border lb:rounded lb:truncate lb:focus:outline lb:focus:outline-neutral-gray-100 lb:focus:transform-none lb:focus:shadow-none lb:focus:opacity-100 "+(C?"lb:border-red-1000 lb:bg-red-50":"lb:border-gray-300"),placeholder:"Escribe un nombre...",title:"El nombre es obligatorio",required:!0})]}),C&&l.jsx("span",{className:"lb:text-xs lb:text-red-1000 lb:ml-1",children:"El nombre es obligatorio"})]}),s&&r&&l.jsxs("button",{type:"button",onClick:r,disabled:c,className:"lb:flex-1 lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-white lb:border lb:border-gray-300 lb:text-gray-700 lb:rounded-lg lb:hover:bg-gray-50 lb:cursor-pointer lb:hover:border-gray-400 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium","aria-label":"Intentarlo de nuevo",title:"Generar de nuevo con el mismo prompt",children:[l.jsx("span",{className:"icon icon-refresh icon--sm"}),l.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Reintentar"}),l.jsx("span",{className:"lb:sm:hidden",children:"Retry"})]}),l.jsxs("button",{type:"button",onClick:()=>{if(!g||c)return;const e=document.createElement("a");e.href=g,e.download=y.name,document.body.appendChild(e),e.click(),document.body.removeChild(e),i&&i()},disabled:c,className:"lb:flex-1 lb:cursor-pointer lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-white lb:border lb:border-gray-300 lb:text-gray-700 lb:rounded-lg lb:hover:bg-gray-50 lb:hover:border-gray-400 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium","aria-label":"Descargar archivo",children:[l.jsx("span",{className:"icon icon-download icon--sm"}),l.jsx("span",{children:"Descargar"})]}),l.jsxs("button",{type:"button",onClick:()=>{j.trim()?(S(!1),o&&o(y.name,b)):S(!0)},disabled:c,className:"lb:flex-1 lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-brand-blue-800 lb:border lb:border-brand-blue-800 lb:text-white lb:rounded-lg lb:hover:bg-brand-blue-1000 lb:cursor-pointer lb:hover:border-brand-blue-1000 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium lb:shadow-sm","aria-label":T?"Seleccionar para recortar":"Seleccionar archivo",children:[l.jsx("span",{className:"icon icon-tick-white icon--sm"}),l.jsx("span",{children:"Seleccionar"})]})]})]})]})}),E&&l.jsx(Re,{isOpen:w,src:g,alt:y.name,title:y.name,subtitle:`${y.size} • ${y.type.split("/")[1]?.toUpperCase()||"IMAGE"}`,onClose:()=>k(!1)})]})}const it={image:["image/jpeg","image/png","image/webp","image/svg+xml"],video:["image/gif","video/mp4","video/webm","video/quicktime","video/x-msvideo"],document:["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","text/plain","text/csv","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation"],audio:["audio/mpeg","audio/wav","audio/ogg","audio/webm"]},ot={image:"JPG, PNG, SVG, WebP, GIF",video:"GIF, MP4, WebM, MOV, AVI",document:"PDF, DOC, DOCX, XLS, XLSX, TXT, PPT, PPTX",audio:"MP3, WAV, OGG"},st=["image","video","document","audio"];function ct({file:t,setFile:n,setPreviewUrl:a,fileInputRef:r,onSelect:i,disabled:o,allowedCategories:s=null,resolvedAccept:u=null,selectedFolder:d=null,onFolderChange:b=null,folderConfig:m=null,tags:h=[],onTagsChange:p=null}){const[f,g]=e.useState(!1),{acceptAttribute:v,allowedMimeTypes:y,formatLabels:x,categories:w}=e.useMemo(()=>{if(u&&!u.isAllTypes)return{acceptAttribute:u.acceptString,allowedMimeTypes:new Set(u.mimeTypes),formatLabels:c(u),categories:u.categories.length>0?u.categories:st};const e=null===s?st:s,t=[],l=[];return e.forEach(e=>{it[e]&&(t.push(...it[e]),ot[e]&&l.push(ot[e]))}),{acceptAttribute:t.join(","),allowedMimeTypes:new Set(t),formatLabels:l.join(", "),categories:e}},[s,u]),k=u&&!u.isAllTypes?u.includesImages&&1===u.categories.length&&"image"===u.categories[0]:1===w.length&&"image"===w[0],C=e=>{if(n(e),e){const t=URL.createObjectURL(e);a(t)}else a(null)};return l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-6","aria-label":k?"Subir imagen desde dispositivo":"Subir archivo desde dispositivo",children:[l.jsxs("label",{htmlFor:"file-input",className:"lb:w-full lb:max-w-full lb:flex lb:flex-col lb:items-center lb:justify-center lb:border-2 lb:border-dashed lb:rounded-xl lb:p-8 lb:cursor-pointer lb:transition lb:box-border "+(f?"lb:border-brand-blue-1000 lb:bg-brand-blue-100 lb:scale-[1.02]":"lb:border-brand-blue-200 lb:hover:border-brand-blue-1000 lb:hover:to-bright-blue-200 lb:hover:from-brand-blue-50 lb:focus-within:border-brand-blue-800 lb:from-bright-blue-50 lb:to-brand-blue-50 lb:bg-linear-to-br"),tabIndex:0,style:{outline:"none"},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),o||g(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),e.currentTarget.contains(e.relatedTarget)||g(!1)},onDrop:e=>{if(e.preventDefault(),e.stopPropagation(),g(!1),o)return;const t=e.dataTransfer?.files;if(t&&t.length>0){const e=t[0];(e=>{if(!e||!e.type)return!1;if(u&&!u.isAllTypes)return function(e,t){if(!t||t.isAllTypes)return!0;if(!e)return!1;if(t.mimeTypes.includes(e))return!0;for(const l of t.categories)if(e.startsWith(l+"/"))return!0;return!1}(e.type,u);if(y.has(e.type))return!0;for(const t of w)if("image"===t&&e.type.startsWith("image/")||"video"===t&&e.type.startsWith("video/")||"audio"===t&&e.type.startsWith("audio/"))return!0;return!1})(e)&&C(e)}},children:[l.jsx("span",{className:"icon icon-upload icon--lg lb:mb-2","aria-hidden":"true"}),l.jsx("span",{className:"lb:font-medium lb:text-brand-blue-1000 lb:mb-1",children:k?"Haz clic o arrastra una imagen aqui":"Haz clic o arrastra un archivo aqui"}),l.jsxs("span",{className:"lb:text-sm lb:text-neutral-700",children:["Formatos permitidos: ",l.jsx("span",{className:"lb:wrap-break-word",children:x})]}),l.jsx("input",{id:"file-input",ref:r,type:"file",accept:v,onChange:e=>{const t=e.target.files[0];C(t)},disabled:o,className:"lb:sr-only","aria-label":k?"Seleccionar imagen":"Seleccionar archivo"})]}),t&&l.jsx(rt,{file:t,onDiscard:()=>{n(null),a(null),r.current&&(r.current.value="")},onDownload:()=>{},onSelect:e=>{if(t&&!o&&i)if(e&&e!==t.name){const l=new File([t],e,{type:t.type});i(l,h)}else i(t,h)},showRetry:!1,disabled:o,selectedFolder:d,onFolderChange:b,folderConfig:m,tags:h,onTagsChange:p})]})}const ut="/api";const dt=new Map;function bt(t=!1){const[l,n]=e.useState([]),[a,r]=e.useState(!0),[i,o]=e.useState(null);e.useEffect(()=>{const e=`ai-services-${t}`,l=dt.get(e),a=Date.now();if(l&&a-l.timestamp<864e5)return n(l.data),void r(!1);let i=!0;return(async()=>{try{const l=await function(e=!1){return W({endpoint:"/ai/services",prod:e,basePath:ut})}(t);if(!i)return;const r=l?.data||l?.result||[],o=Array.isArray(r)?r.map(e=>({label:e.name||e.label,slug:e.slug,type:e.type,description:e.description,image:e.image,costInfo:e.cost_info||null,supportsImageInput:e.supports_image_input||!1})):Object.entries(r).map(([e,t])=>({label:e,slug:t,type:"image_generation",description:null,image:null,costInfo:null,supportsImageInput:!1}));n(o),dt.set(e,{data:o,timestamp:a})}catch(l){i&&o(l.message)}finally{i&&r(!1)}})(),()=>{i=!1}},[t]);return{services:l,loading:a,error:i,invalidateCache:()=>{dt.delete(`ai-services-${t}`)}}}const mt=new Map;function ht(t=!1){const[l,n]=e.useState(null),[a,r]=e.useState(!1),[i,o]=e.useState(null);return{params:l,loading:a,error:i,fetchParams:async e=>{r(!0),o(null);const l=`${t}-${e}`,a=Date.now(),i=mt.get(l);if(i&&a-i.timestamp<864e5)return n(i.data),r(!1),i.data;try{const r=await function({services:e=null,form:t=!1}={},l=!1){const n={};return e&&(n.services=e),!1!==t&&(n.form=t),W({endpoint:"/ai/params"+(Object.keys(n).length?"?"+new URLSearchParams(n).toString():""),method:"GET",prod:l,basePath:"/api/atenea"})}({services:e,form:!1},t),i=r?.result?.data||r?.data||r?.result||r;return n(i),mt.set(l,{data:i,timestamp:a}),i}catch(s){return o(s.message),n(null),null}finally{r(!1)}},reset:()=>{o(null),n(null)}}}function pt({show:e=!1,message:t="Cargando...",className:n=""}){return e?l.jsx("div",{className:`lb:absolute lb:inset-0 lb:min-h-50 lb:bg-white/80 lb:backdrop-blur-sm lb:z-50 lb:flex lb:flex-col lb:items-center lb:justify-center ${n}`,"aria-live":"polite","aria-busy":"true",role:"status",children:l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-4",children:[l.jsx("span",{className:"icon icon-spinner lb:p-4 lb:animate-spin"}),l.jsx("p",{className:"lb:text-brand-blue-1000 lb:font-medium lb:text-lg",children:t})]})}):null}const ft={DEV:"https://led-dev-limbo-dev.eu.els.local",PROD:"https://limbo.lefebvre.es"};function gt(e,t=!1){if(!e)return"";if(e.startsWith("/files/")){return(t?ft.PROD:ft.DEV)+e}return e}function vt(e){return"string"!=typeof e?e:e.replace(/&quot;/g,'"').replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&#39;/g,"'").replace(/&#x27;/g,"'")}function yt(e){return!(!e||"string"!=typeof e)&&!e.startsWith("blob:")}function xt(e,t={}){if(!e)return"";const{prefer:l="crop",isProd:n=!1}=t,a=vt(e);try{const e=JSON.parse(a),t=()=>{if(e.images&&Array.isArray(e.images))for(const t of e.images)if(t&&yt(t.url))return t.url;return null},r=e.original?.url,i=t();if("crop"===l){if(i)return gt(i,n);if(yt(r))return gt(r,n)}else{if(yt(r))return gt(r,n);if(i)return gt(i,n)}return yt(e.url)?gt(e.url,n):""}catch{if("string"==typeof a){if(a.startsWith("blob:"))return"";if(a.startsWith("/files/"))return gt(a,n);if(a.startsWith("http")||a.startsWith("/"))return a}}return"string"==typeof e&&(e.startsWith("{")||e.startsWith("["))?"":e}const wt=[{regex:/^php/i,reason:'El nombre no puede empezar por "php"'},{regex:/\.(php\d?|phtml|phar)$/i,reason:"Extensión no permitida (.php)"},{regex:/\.(asp|aspx|ashx|asmx)$/i,reason:"Extensión no permitida (.asp)"},{regex:/\.(jsp|jspx|jspf)$/i,reason:"Extensión no permitida (.jsp)"},{regex:/\.(exe|bat|cmd|sh|ps1|vbs|cgi)$/i,reason:"Extensión ejecutable no permitida"},{regex:/<script/i,reason:"El nombre contiene código no permitido"},{regex:/\.\./,reason:"El nombre contiene rutas relativas no permitidas"}];function kt(e){if(!e||"string"!=typeof e)return{valid:!1,error:"El nombre no puede estar vacío"};const t=e.trim();if(0===t.length)return{valid:!1,error:"El nombre no puede estar vacío"};if(t.length>255)return{valid:!1,error:"El nombre es demasiado largo (máx. 255 caracteres)"};for(const{regex:l,reason:n}of wt)if(l.test(t))return{valid:!1,error:n};return{valid:!0}}function Ct(e){if(!e||"string"!=typeof e)return"file";let t=e.normalize("NFD").replace(/[\u0300-\u036f]/g,"");return t=t.toLowerCase(),t=t.replace(/[^a-z0-9_]+/g,"-"),t=t.replace(/-+/g,"-").replace(/^-|-$/g,""),t||"file"}function St({image:t,onDiscard:n,onRetry:a,onDownload:r,onSelect:i,showRetry:o=!1,disabled:s=!1,selectedFolder:c=null,onFolderChange:u=null,folderConfig:d=null}){const[b,m]=e.useState(null),[h,p]=e.useState({name:"",size:"",type:""}),[f,g]=e.useState(!1),[v,y]=e.useState(!1),[x,w]=e.useState("");e.useEffect(()=>{if(!t)return void m(null);const e=URL.createObjectURL(t);m(e);const l=t.name||"imagen.webp",n=(e=>{const t=e?.split(".")[0]?.toLowerCase()||"";return["ai-image","ai_image","generated","imagen-ia","imagen_ia"].some(e=>t.startsWith(e))})(l);return p({name:l,size:k(t.size||0),type:t.type||"image/webp"}),n?(w(""),y(!1)):w(l.split(".")[0]),()=>{URL.revokeObjectURL(e)}},[t]);const k=e=>{if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return Math.round(e/Math.pow(1024,t)*100)/100+" "+["Bytes","KB","MB","GB"][t]};return t&&b?l.jsxs("div",{className:"lb:w-full lb:max-w-full lb:bg-white lb:border lb:border-gray-200 lb:rounded-lg lb:px-1 lb:sm:px-3 lb:py-2 lb:m-0 lb:shadow-sm lb:overflow-hidden lb:box-border",children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:mb-4 lb:px-1",children:[l.jsx("h3",{className:"lb:text-sm lb:font-medium lb:text-gray-700",children:"Vista previa de imagen"}),l.jsx("button",{type:"button",onClick:n,disabled:s,className:"lb:p-1.5 lb:text-gray-400 lb:cursor-pointer lb:hover:text-gray-600 lb:hover:bg-red-300 lb:rounded lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":"Descartar imagen",title:"Descartar imagen",children:l.jsx("span",{className:"icon icon-close-small icon--md"})})]}),d?.showFolderSelector&&u&&l.jsx("div",{className:"lb:mb-4 lb:px-1",children:l.jsx(He,{value:c?.slug||c,onChange:u,allowCreate:!1!==d?.allowCreateFolder,label:"Guardar en carpeta",showAssetCount:!0,allowedSlugs:d?.include?.length>0?d.include:null,mode:"upload",disabled:s})}),l.jsxs("div",{className:"lb:flex lb:flex-col lb:justify-center lb:md:flex-row lb:gap-2 lb:md:gap-6",children:[l.jsxs("div",{className:"lb:flex-1 lb:md:flex-[0.4] lb:flex lb:flex-col lb:items-center lb:justify-center",children:[l.jsxs("div",{className:"lb:relative lb:w-full lb:max-w-md lb:aspect-video lb:bg-gray-100 lb:rounded-lg lb:overflow-hidden lb:cursor-zoom-in lb:hover:ring-2 lb:hover:ring-brand-blue-800 lb:transition-all",onClick:()=>g(!0),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),g(!0))},"aria-label":"Click para ver imagen en tamaño completo",title:"Click para ver en tamaño completo",children:[l.jsx("img",{src:b,alt:"Vista previa",className:"lb:absolute lb:inset-0 lb:w-full lb:h-full lb:object-contain"}),l.jsxs("div",{className:"lb:absolute lb:top-2 lb:right-2 lb:bg-black/50 lb:text-white lb:px-2 lb:py-1 lb:rounded lb:text-xs lb:flex lb:items-center lb:gap-1",children:[l.jsx("span",{className:"icon icon-search-white icon--xs"}),l.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Ampliar"})]})]}),l.jsx("div",{className:"lb:mt-3 lb:text-center lb:space-y-1 lb:w-full",children:l.jsx("div",{className:"lb:rounded-sm lb:w-fit lb:gap-0.5 lb:p-0.5 lb:min-w-fit lb:mx-auto",children:l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:gap-3 lb:text-xs lb:text-gray-500",children:[l.jsx("span",{children:h.size}),l.jsx("span",{children:"•"}),l.jsx("span",{children:h.type.split("/")[1]?.toUpperCase()||"IMAGE"})]})})})]}),l.jsxs("div",{className:"lb:flex lb:flex-row lb:md:flex-col lb:gap-2 lb:justify-items-stretch lb:justify-center lb:md:justify-start lb:items-stretch lb:md:min-w-35",children:[l.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-1",children:[l.jsxs("label",{htmlFor:"uploadImageId",className:"lb:flex lb:items-center lb:w-fit",children:[l.jsx("span",{className:"lb:me-1 lb:text-sm",children:"Nombre:"}),l.jsx("input",{id:"uploadImageId",onChange:e=>(e=>{const t=e.target.value.trim();w(e.target.value);const l=kt(t||"_");l.valid?t.length>0&&y(!1):y(l.error);const n=h.name,a=n.lastIndexOf("."),r=-1!==a?n.substring(a):".webp";p(e=>({...e,name:t?t+r:r}))})(e),value:x,className:"limbo-input-image-name lb:w-fit lb:px-1 lb:text-sm lb:font-medium lb:text-gray-800 lb:border lb:rounded lb:truncate lb:focus:outline lb:focus:outline-neutral-gray-100 lb:focus:transform-none lb:focus:shadow-none lb:focus:opacity-100 "+(v?"lb:border-red-1000 lb:bg-red-50":"lb:border-gray-300"),placeholder:"Escribe un nombre...",title:"El nombre es obligatorio",required:!0})]}),v&&l.jsx("span",{className:"lb:text-xs lb:text-red-1000 lb:ml-1",children:"string"==typeof v?v:"El nombre es obligatorio"})]}),o&&a&&l.jsxs("button",{type:"button",onClick:a,disabled:s,className:"lb:flex-1 lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-white lb:border lb:border-gray-300 lb:text-gray-700 lb:rounded-lg lb:hover:bg-gray-50 lb:cursor-pointer lb:hover:border-gray-400 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium","aria-label":"Intentarlo de nuevo",title:"Generar de nuevo con el mismo prompt",children:[l.jsx("span",{className:"icon icon-refresh icon--sm"}),l.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Reintentar"}),l.jsx("span",{className:"lb:sm:hidden",children:"Retry"})]}),l.jsxs("button",{type:"button",onClick:()=>{if(!b||s)return;const e=document.createElement("a");e.href=b,e.download=h.name,document.body.appendChild(e),e.click(),document.body.removeChild(e),r&&r()},disabled:s,className:"lb:flex-1 lb:cursor-pointer lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-white lb:border lb:border-gray-300 lb:text-gray-700 lb:rounded-lg lb:hover:bg-gray-50 lb:hover:border-gray-400 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium","aria-label":"Descargar imagen",children:[l.jsx("span",{className:"icon icon-download icon--sm"}),l.jsx("span",{children:"Descargar"})]}),l.jsxs("button",{type:"button",onClick:()=>{const e=x.trim();if(!e)return void y("El nombre no puede estar vacío");const t=kt(e);t.valid?(y(!1),i&&i(h.name)):y(t.error)},disabled:s,className:"lb:flex-1 lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-brand-blue-800 lb:border lb:border-brand-blue-800 lb:text-white lb:rounded-lg lb:hover:bg-brand-blue-1000 lb:cursor-pointer lb:hover:border-brand-blue-1000 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium lb:shadow-sm","aria-label":"Seleccionar imagen para recortar",children:[l.jsx("span",{className:"icon icon-tick-white icon--sm"}),l.jsx("span",{children:"Seleccionar"})]})]})]}),l.jsx(Re,{isOpen:f,src:b,alt:h.name,title:h.name,subtitle:`${h.size} • ${h.type.split("/")[1]?.toUpperCase()||"IMAGE"}`,onClose:()=>g(!1)})]}):null}function jt({aiStarterPrompt:t,useStarter:n,onUseStarterChange:a}){const[r,i]=e.useState(!1),[o,s]=e.useState(!1),c=e.useRef(null),u=e.useId();if(e.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),null==t||""===t)return null;const d=n?"lb:rounded-md lb:border lb:border-brand-blue-1000 lb:bg-brand-blue-50 lb:p-4 lb:cursor-pointer lb:transition-all lb:duration-150 lb:mb-6 lb:w-full":"lb:rounded-md lb:border lb:border-neutral-gray-100 lb:bg-neutral-gray-25 lb:p-4 lb:cursor-pointer lb:opacity-55 lb:transition-all lb:duration-150 lb:mb-6 lb:w-full",b=r?"lb:text-[13px] lb:leading-[1.4] lb:text-neutral-gray-800 lb:whitespace-pre-wrap lb:break-words":"lb:text-[13px] lb:leading-[1.4] lb:text-neutral-gray-800 lb:truncate",m=o?"lb:text-xs lb:font-normal lb:text-green-1000 lb:px-2 lb:py-1 lb:rounded lb:bg-green-50":"lb:text-xs lb:font-normal lb:text-neutral-gray-700 lb:px-2 lb:py-1 lb:rounded lb:hover:bg-neutral-gray-50 lb:transition-colors";return l.jsxs("div",{role:"region","aria-label":h("aiStarter.label"),onClick:()=>{a(!n)},className:d,children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:gap-2 lb:mb-2",children:[l.jsxs("label",{className:"lb:flex lb:items-center lb:gap-2 lb:cursor-pointer",onClick:e=>e.stopPropagation(),children:[l.jsx("input",{type:"checkbox",checked:n,onChange:e=>{e.stopPropagation(),a(e.target.checked)},"aria-label":h("aiStarter.label"),onClick:e=>e.stopPropagation()}),l.jsx("span",{className:"lb:text-xs lb:font-semibold lb:text-brand-blue-1000 lb:select-none",children:h("aiStarter.label")})]}),l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-1 lb:shrink-0",role:"group","aria-label":h("aiStarter.label"),children:[l.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),"undefined"!=typeof navigator&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(t).catch(()=>{}),s(!0),c.current&&clearTimeout(c.current),c.current=setTimeout(function(){s(!1),c.current=null},2e3)},"aria-label":h(o?"aiStarter.copied":"aiStarter.copyAriaLabel"),"aria-live":"polite","aria-atomic":"true",className:m,children:h(o?"aiStarter.copied":"aiStarter.copy")}),l.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),i(e=>!e)},"aria-expanded":r,"aria-controls":u,"aria-label":h(r?"aiStarter.readLess":"aiStarter.readMore"),className:"lb:text-xs lb:font-normal lb:text-neutral-gray-700 lb:px-2 lb:py-1 lb:rounded lb:hover:bg-neutral-gray-50 lb:transition-colors",children:h(r?"aiStarter.readLess":"aiStarter.readMore")})]})]}),l.jsx("div",{id:u,className:b,children:t})]})}function Nt(e){return new Promise((t,l)=>{const n=new FileReader;n.onload=()=>t(n.result),n.onerror=l,n.readAsDataURL(e)})}function Et({prod:t,disabled:n,onSelect:a,selectedFolder:r,onFolderChange:i,folderConfig:o,aiStarterPrompt:s}){const c=bt(t),u=ht(t),[d,b]=e.useState(""),[m,h]=e.useState(""),[p,f]=e.useState({}),[g,v]=e.useState(!1),[y,x]=e.useState(null),[w,k]=e.useState(null),[C,S]=e.useState(null),[j,N]=e.useState(!0),[E,$]=e.useState(!1),[_,T]=e.useState([null,null]),[A,z]=e.useState([null,null]),[L,M]=e.useState(null),[I,P]=e.useState(!0),D=[e.useRef(null),e.useRef(null)],R=e.useRef([0,0]);e.useEffect(()=>{if(!c.loading&&1===c.services.length){const e=c.services[0];h(e.slug),N(!1),u.fetchParams(e.slug,!0)}},[c.loading,c.services]),e.useEffect(()=>{if(!m)return;const e=u.params?.[m]?.parameters;if(e){const t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default??""]));t.service=m,f(t)}},[m,u.params]);const O=e.useMemo(()=>{const e=c.services.find(e=>e.slug===m);if(e?.supportsImageInput)return!0;const t=u.params?.[m]?.parameters;return!!t&&Object.entries(t).some(([e,t])=>"image"===t.type||"file"===t.type||"image_data"===e||"image"===e||"reference_image"===e)},[m,c.services,u.params]),F=(e,t)=>{e&&(["image/jpeg","image/png","image/webp","image/svg+xml"].includes(e.type)?e.size>4194304?x("La imagen de referencia no puede superar los 4MB."):(T(l=>{const n=[...l];return n[t]=e,n}),z(l=>{const n=[...l];return n[t]&&URL.revokeObjectURL(n[t]),n[t]=URL.createObjectURL(e),n}),x(null)):x("Formato no soportado. Usa JPG, PNG, SVG o WebP."))},U=e=>t=>{F(t.target.files?.[0],e)},B=e=>t=>{t.preventDefault(),t.stopPropagation(),R.current[e]++,M(e)},q=e=>t=>{t.preventDefault(),t.stopPropagation(),R.current[e]--,0===R.current[e]&&M(null)},V=e=>{e.preventDefault(),e.stopPropagation()},H=e=>t=>{t.preventDefault(),t.stopPropagation(),R.current[e]=0,M(null),F(t.dataTransfer?.files?.[0],e)},K=e=>{T(t=>{const l=[...t];return l[e]=null,l}),z(t=>{const l=[...t];return l[e]&&URL.revokeObjectURL(l[e]),l[e]=null,l}),D[e]?.current&&(D[e].current.value="")};e.useEffect(()=>{const e=A;return()=>{e.forEach(e=>{e&&URL.revokeObjectURL(e)})}},[]);const G=e=>{const{name:t,value:l}=e.target;f(e=>({...e,[t]:l}))},Q=async(e,l=!1)=>{e.preventDefault(),v(!0),x(null),k(null);try{l?p.prompt=d:b(p.prompt||"");const{image_data:e,...a}=p;let r={...a};r.prompt=function({starter:e,user:t,useStarter:l}){const n=null==e?"":String(e),a=null==t?"":String(t);return l&&""!==n?"Follow this instructions prompt: ```"+n+"``` to complete this request prompt: ```"+a+"```":a}({starter:s,user:r.prompt,useStarter:I}),_[0]&&(r.image=await Nt(_[0])),_[1]&&(r.image2=await Nt(_[1]));const i=await function(e,t=!1){return W({endpoint:"/ai/generate",method:"POST",body:e,prod:t,basePath:ut})}(r,t);let o=null;if(i?.data?.images&&Array.isArray(i.data.images)&&i.data.images.length>0?o=i.data.images[0]:i?.result?.images&&Array.isArray(i.result.images)&&i.result.images.length>0?o=i.result.images[0]:Array.isArray(i)&&i.length>0?o=i[0]:"string"==typeof i&&(o=i),!o)throw new Error("No se pudo extraer la imagen de la respuesta");if(o.startsWith("http"))try{const e=`${window.limboCore?.config?.getGlobal()?.prod?"https://limbo.lefebvre.es":"https://led-dev-limbo-dev.eu.els.local"}/api/atenea/proxy?url=${encodeURIComponent(o)}`,t=await fetch(e,{credentials:"include",headers:{Authorization:`Bearer ${window.limboCore?.apiClient?.token||""}`}});if(!t.ok)throw new Error(`Failed to download image: ${t.status}`);const l=await t.blob(),n=new File([l],"ai-image.webp",{type:l.type||"image/webp"});S(n)}catch(n){throw new Error(`Error downloading image via proxy: ${n.message}`)}else{const e=o.replace(/^data:image\/\w+;base64,/,""),t=atob(e),l=new Array(t.length);for(let r=0;r<t.length;r++)l[r]=t.charCodeAt(r);const n=new Uint8Array(l),a=new File([n],"ai-image.webp",{type:"image/webp"});S(a)}k(i?.data?.images||i?.result?.images||null)}catch(a){x(a.message||"Error al generar la imagen")}finally{v(!1)}};return c.loading?l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:py-8",children:[l.jsx("span",{className:"limbo-loader lb:mr-2"})," Cargando servicios IA..."]}):c.services.length?l.jsx("div",{className:"lb:flex lb:flex-col lb:mx-4 lb:pb-2",children:j?l.jsxs(l.Fragment,{children:[l.jsx("h3",{id:"aiSelectDescription",className:"lb:text-2xl lb:font-semibold lb:text-brand-blue-1000 lb:mb-3",children:"Selecciona el modelo IA"}),c.error&&l.jsx(fe,{variant:"danger",children:c.error}),l.jsx("div",{className:"lb:flex lb:flex-row lb:flex-wrap lb:justify-around lb:items-stretch lb:justify-items-stretch lb:content-stretch lb:gap-3 lb:w-full lb:max-w-7xl",children:c.services.map(e=>l.jsxs("button",{type:"button",onClick:()=>{h(e.slug),N(!1),f({}),k(null),x(null),S(null),u.fetchParams(e.slug,!0)},disabled:c.loading||n,className:`lb:group lb:relative lb:p-4 lb:rounded-lg lb:border-2 lb:transition-all lb:duration-200 lb:overflow-hidden lb:flex lb:flex-col lb:items-center lb:justify-center lb:min-h-30 lb:grow basis-sm lb:min-w-70 lb:border-gray-200 lb:hover:border-brand-blue-800 lb:hover:shadow-md lb:hover:text-black lb:lg:w-min ${c.loading||n?"lb:opacity-50 lb:cursor-not-allowed":"lb:cursor-pointer"} `,style:{position:"relative"},children:[e.image&&l.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-cover lb:bg-center lb:transition-opacity lb:duration-200 lb:group-hover:opacity-35",style:{backgroundImage:`url(${e.image})`,opacity:.2}}),l.jsxs("div",{className:"lb:relative lb:z-10 lb:flex lb:flex-col lb:items-center lb:justify-center lb:gap-2 lb:text-center",children:[l.jsx("span",{className:"lb:text-base lb:font-semibold lb:text-neutral-black-000",children:e.label}),e.description&&l.jsx("span",{className:"lb:text-sm lb:text-gray-950 lb:line-clamp-2 lb:drop-shadow lb:drop-shadow-neutral-white-000",children:e.description})]}),e.costInfo&&l.jsx("span",{className:"lb:absolute lb:top-0 lb:left-1 lb:inline-flex lb:items-center lb:gap-1 lb:py-0 lb:px-1 lb:mt-1 lb:text-xs lb:font-medium lb:text-warning-1000 lb:rounded-md lb:group-hover:bg-white/90",style:{zoom:"82%"},children:e.costInfo})]},e.slug))})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"lb:flex lb:flex-wrap lb:items-center lb:gap-3 lb:mb-2",children:[l.jsx("h3",{className:"lb:text-2xl lb:font-semibold lb:text-brand-blue-1000",children:c.services.find(e=>e.slug===m)?.label||"Generación IA"}),c.services.find(e=>e.slug===m)?.costInfo&&l.jsxs("div",{title:"Coste estimado por imagen que le cuesta a la empresa, este coste depende de la calidad de la imagen generada y puede variar según el proveedor IA, ten en cuenta este coste para hacer un uso más responsable del servicio IA",className:"lb:flex lb:items-center lb:gap-1","aria-description":"Coste estimado por imagen que le cuesta a la empresa, este coste depende de la calidad de la imagen generada y puede variar según el proveedor IA, ten en cuenta este coste para hacer un uso más responsable del servicio IA",children:[l.jsxs("span",{className:"lb:inline-flex lb:items-center lb:gap-1 lb:px-2 lb:py-0.5 lb:text-xs lb:font-medium lb:text-warning-1000 lb:bg-yellow-200/60 lb:rounded-full lb:border lb:border-warning-1000 lb:select-none",children:[l.jsx("span",{className:"icon icon-euro-blue icon--2sm icon--warning",style:{filter:"var(--limbo-icon-warning-dark)"}}),"Coste:"," ",c.services.find(e=>e.slug===m)?.costInfo]}),l.jsx("span",{className:"icon icon-info lb:cursor-help"})]})]}),u.loading&&l.jsx("div",{children:"Cargando parámetros..."}),u.error&&l.jsx(fe,{variant:"danger",children:u.error}),m&&(()=>{const e=u.params?.[m]?.parameters;if(!e)return null;const t=Object.entries(e).filter(([e,t])=>!t.hidden&&"image"!==t.type&&"file"!==t.type),a=t.filter(([e])=>e.toLowerCase().includes("prompt")||e.toLowerCase().includes("query")),r=t.filter(([e])=>!e.toLowerCase().includes("prompt")&&!e.toLowerCase().includes("query")),i=(e,t)=>{let a=t.placeholder||"";a||(a="integer"===t.type?t.minValue&&t.maxValue?`Entre ${t.minValue} y ${t.maxValue}`:t.minValue?`Mínimo ${t.minValue}`:t.maxValue?`Máximo ${t.maxValue}`:"Introduce un número":e.toLowerCase().includes("prompt")?"Describe la imagen que deseas generar...":e.toLowerCase().includes("negative")?"Elementos a evitar en la imagen...":`Introduce ${(t.label||e).toLowerCase()}`);const r=e.toLowerCase().includes("prompt")||e.toLowerCase().includes("query");return l.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-1",children:[l.jsxs("label",{htmlFor:`ai-${e}`,className:"lb:text-xs lb:font-medium lb:text-brand-blue-1000",children:[t.label||e,t.required&&l.jsx("span",{className:"lb:text-red-1000 lb:ml-1",children:"*"})]}),t.options?l.jsx("select",{id:`ai-${e}`,name:e,value:p[e]??"",onChange:G,className:"limbo-input",disabled:n,title:t.label||e,children:t.options.map(e=>l.jsx("option",{value:e,children:e},e))}):r?l.jsx("textarea",{id:`ai-${e}`,name:e,value:p[e]??"",onChange:G,className:"limbo-input lb:resize-none lb:overflow-y-auto",disabled:n,required:t.required,placeholder:a,title:t.label||e,rows:3,style:{maxHeight:"9rem",minHeight:"3rem"},onInput:e=>{e.target.style.height="auto";const t=Math.min(e.target.scrollHeight,144);e.target.style.height=`${t}px`}}):l.jsx("input",{id:`ai-${e}`,type:"integer"===t.type?"number":"text",name:e,value:p[e]??"",onChange:G,className:"limbo-input",disabled:n,required:t.required,min:t.minValue,max:t.maxValue,placeholder:a,title:t.label||e})]},e)};return l.jsxs("div",{className:"lb:h-fit lb:w-full",children:[c.services.length>1&&l.jsxs("button",{type:"button",onClick:()=>{N(!0),h(""),f({}),k(null),x(null),S(null),K()},className:"lb:flex lb:cursor-pointer lb:items-center lb:gap-2 lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:mb-4 lb:font-medium",children:[l.jsx("span",{className:"icon icon-arrow-left"}),"Volver al menú de servicios"]}),l.jsxs("div",{className:"lb:relative lb:max-w-[89dvw]",children:[l.jsxs("form",{onSubmit:Q,"data-type":"ai",className:"lb:flex lb:flex-col lb:gap-3 lb:mt-4 lb:border-t lb:pt-4 lb:border-brand-blue-200","aria-label":"Formulario generación IA",children:[y&&l.jsx(fe,{variant:"danger",className:"lb:mb-2",children:y}),l.jsx(jt,{aiStarterPrompt:s,useStarter:I,onUseStarterChange:P}),l.jsx("div",{className:"lb:flex lb:flex-col lb:gap-3",children:a.map(([e,t])=>i(e,t))}),O&&l.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-2 lb:mt-1",children:[l.jsxs("label",{className:"lb:text-xs lb:font-medium lb:text-brand-blue-1000",children:["Imágenes de referencia",l.jsx("span",{className:"lb:text-neutral-gray-500 lb:ml-1 lb:font-normal",children:"(opcional, máx. 2)"})]}),l.jsx("div",{className:"lb:flex lb:flex-col lb:gap-2",children:[0,1].map(e=>_[e]?l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-3 lb:p-2 lb:bg-neutral-gray-50 lb:border lb:border-neutral-gray-200 lb:rounded-lg",children:[l.jsx("div",{className:"lb:w-16 lb:h-16 lb:rounded lb:overflow-hidden lb:shrink-0 lb:bg-neutral-gray-100",children:l.jsx("img",{src:A[e],alt:`Referencia ${e+1}`,className:"lb:w-full lb:h-full lb:object-cover"})}),l.jsxs("div",{className:"lb:flex-1 lb:min-w-0",children:[l.jsxs("p",{className:"lb:text-xs lb:text-neutral-gray-500 lb:mb-0.5",children:["Imagen ",e+1]}),l.jsx("p",{className:"lb:text-sm lb:text-neutral-gray-700 lb:truncate",children:_[e].name}),l.jsxs("p",{className:"lb:text-xs lb:text-neutral-gray-500",children:[(_[e].size/1024).toFixed(0)," KB"]})]}),l.jsx("button",{type:"button",onClick:()=>K(e),disabled:n||g,className:"lb:p-1.5 lb:text-neutral-gray-500 lb:cursor-pointer lb:hover:text-red-1000 lb:hover:bg-red-50 lb:rounded lb:transition-colors",title:`Quitar imagen ${e+1}`,children:l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[l.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),l.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},e):(0===e||_[0])&&l.jsxs("label",{className:"lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-3 lb:py-2.5 lb:border lb:border-dashed lb:rounded-lg lb:cursor-pointer lb:transition-colors lb:text-sm "+(L===e?"lb:border-brand-blue-800 lb:bg-brand-blue-50/50 lb:text-brand-blue-800":"lb:border-neutral-gray-300 lb:text-neutral-gray-700 lb:hover:border-brand-blue-800 lb:hover:bg-brand-blue-50/30"),onDragEnter:B(e),onDragLeave:q(e),onDragOver:V,onDrop:H(e),children:[l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[l.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),l.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),l.jsx("polyline",{points:"21 15 16 10 5 21"})]}),L===e?"Suelta la imagen aquí":0===e?"Subir imagen de referencia":"Añadir segunda imagen",l.jsx("input",{ref:D[e],type:"file",accept:"image/jpeg,image/png,image/webp,image/svg+xml",onChange:U(e),disabled:n||g,className:"lb:sr-only"})]},e))})]}),r.length>0&&l.jsxs("div",{className:"lb:border-t lb:border-gray-200 lb:pt-3",children:[l.jsxs("button",{type:"button",onClick:()=>$(!E),className:"lb:flex lb:items-center lb:gap-2 lb:text-sm lb:font-medium lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:mb-3 lb:transition-colors",children:[l.jsx("svg",{className:"lb:w-4 lb:h-4 lb:transition-transform "+(E?"lb:rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"Opciones avanzadas",!E&&l.jsxs("span",{className:"lb:text-xs lb:text-gray-500",children:["(",r.length," opciones)"]})]}),E&&l.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:lg:grid-cols-3 lb:xl:grid-cols-4 lb:gap-3 lb:animate-fadeIn",children:r.map(([e,t])=>i(e,t))})]}),(()=>{const e=Object.entries(p).some(([e,t])=>(e.toLowerCase().includes("prompt")||e.toLowerCase().includes("query"))&&"string"==typeof t&&t.trim().length>=5),t=g||n||!e;return l.jsx("button",{type:"submit",disabled:t,title:g?"Generando imagen...":e?C?"Generar otra imagen":"Generar imagen":"Escribe al menos 5 caracteres en el prompt",className:"limbo-btn lb:w-full lb:mt-2 "+(t?"lb:cursor-not-allowed limbo-btn-disabled":"limbo-btn-primary"),style:{minHeight:44},children:g?"Generando imagen...":C?"Generar otra imagen":"Generar imagen"})})()]}),l.jsx(pt,{show:g,message:"Generando imagen con IA..."})]})]})})(),C&&l.jsx("div",{className:"lb:mt-6 lb:md:w-full lb:mx-auto",children:l.jsx(St,{image:C,onDiscard:()=>{S(null),k(null),x(null)},onRetry:e=>Q(e,!0),onDownload:()=>{},onSelect:e=>{if(a){const t=C||w;if(e&&t&&e!==t.name){const l=new File([t],e,{type:t.type});a(l)}else a(t)}},showRetry:!0,disabled:g||n,selectedFolder:r,onFolderChange:i,folderConfig:o})})]})}):l.jsx(fe,{variant:"warning",children:"No hay servicios IA disponibles."})}const $t="/api";const _t=new Map;function Tt(t=!1){const[l,n]=e.useState([]),[a,r]=e.useState(!0),[i,o]=e.useState(null);e.useEffect(()=>{const e=`stock-services-${t}`,l=_t.get(e),a=Date.now();if(l&&a-l.timestamp<864e5)return n(l.data),void r(!1);let i=!0;return(async()=>{try{const l=await function(e=!1){return W({endpoint:"/stock/services",prod:e,basePath:$t})}(t);if(!i)return;if(204===l?.httpCode||null===l?.data)return n([]),o("No hay servicios de stock disponibles en este momento"),void _t.set(e,{data:[],timestamp:a});const r=l?.data||l?.result||[],s=Array.isArray(r)?r.map(e=>({label:e.name||e.label,slug:e.slug,type:e.type,description:e.description,image:e.image})):Object.entries(r).map(([e,t])=>({label:e,slug:t,type:"stock_image",description:null,image:null}));n(s),_t.set(e,{data:s,timestamp:a})}catch(l){i&&o(l.message)}finally{i&&r(!1)}})(),()=>{i=!1}},[t]);return{services:l,loading:a,error:i,invalidateCache:()=>{_t.delete(`stock-services-${t}`)}}}function At({isOpen:t,image:n,onSelect:a,onCancel:r}){const[i,o]=e.useState(null),[s,c]=e.useState(!1),[u,d]=e.useState(!1),[b,m]=e.useState(!1);e.useEffect(()=>{t&&n&&(o(n.previewUrl),c(!1),d(!1),m(!1))},[t,n]);const h=l.jsxs("div",{className:"lb:flex lb:gap-2 lb:ml-4 lb:shrink-0",children:[l.jsx("button",{type:"button",onClick:r,className:"lb:px-4 lb:py-2 lb:text-sm lb:font-medium lb:text-white lb:border lb:border-white/30 lb:rounded-md lb:hover:bg-white/10 lb:transition-colors lb:cursor-pointer",children:"Cancelar"}),l.jsx("button",{type:"button",onClick:a,className:"lb:px-4 lb:py-2 lb:text-sm lb:font-medium lb:bg-brand-blue-800 lb:text-white lb:rounded-md lb:hover:bg-brand-blue-1000 lb:transition-colors lb:cursor-pointer",children:"Seleccionar"})]});return l.jsx(Ne,{isOpen:t,onClose:r,title:n?.title||"Previsualizar imagen",ariaLabel:"Previsualización de imagen externa",headerActions:h,children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center lb:w-full lb:h-full lb:p-4",children:b?l.jsxs("div",{className:"lb:text-white/70 lb:text-sm lb:text-center",children:[l.jsx("p",{children:"No se pudo cargar la imagen."}),l.jsx("p",{className:"lb:text-xs lb:mt-1 lb:text-white/50",children:"Puedes seleccionarla igualmente para continuar."})]}):l.jsxs(l.Fragment,{children:[!u&&l.jsx("div",{className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"limbo-loader"})}),l.jsx("img",{src:i,alt:n?.title||"Imagen",onLoad:()=>d(!0),onError:()=>{!s&&n?.proxyUrl&&n.proxyUrl!==i?(c(!0),o(n.proxyUrl)):m(!0)},className:"lb:max-w-full lb:object-contain lb:rounded lb:transition-opacity lb:duration-300 "+(u?"lb:opacity-100":"lb:opacity-0"),style:{maxHeight:"calc(100vh - 130px)"}},i)]})})})}function zt({src:t,fallbackSrc:n,alt:a}){const[r,i]=e.useState(t),[o,s]=e.useState(!1),[c,u]=e.useState(!1);e.useEffect(()=>{i(t),s(!1),u(!1)},[t]);return l.jsxs("div",{className:"lb:relative lb:w-full lb:h-full",children:[!c&&l.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-linear-to-r lb:from-gray-200 lb:via-gray-100 lb:to-gray-200 lb:animate-pulse"}),l.jsx("img",{src:r,alt:a,onLoad:()=>u(!0),onError:()=>{!o&&n&&n!==r&&(s(!0),i(n))},className:"lb:object-cover lb:w-full lb:h-full lb:transition-opacity lb:duration-300 "+(c?"lb:opacity-100":"lb:opacity-0"),loading:"lazy"})]})}function Lt({prod:t,disabled:n,onSelect:a,selectedFolder:r,onFolderChange:i,folderConfig:o}){const s=e.useRef(null),c=Tt(t),u=(e,t)=>{try{const l=sessionStorage.getItem(`limbo_stock_${e}`);return l?JSON.parse(l):t}catch{return t}},[d,b]=e.useState(()=>u("selectedService","")),[m,h]=e.useState(()=>u("dynamicForm",{})),[p,f]=e.useState(()=>u("stockImages",[])),[g,v]=e.useState(()=>u("currentPage",1)),[y,x]=e.useState(()=>u("paginationInfo",null)),[w,k]=e.useState(null),C=ht(t),[S,j]=e.useState(!1),[N,E]=e.useState(null),[$,_]=e.useState(null),[T,A]=e.useState(!0),[z,L]=e.useState(!1),[M,I]=e.useState(null),[P,D]=e.useState(null);e.useEffect(()=>{sessionStorage.setItem("limbo_stock_selectedService",JSON.stringify(d))},[d]),e.useEffect(()=>{sessionStorage.setItem("limbo_stock_dynamicForm",JSON.stringify(m))},[m]),e.useEffect(()=>{sessionStorage.setItem("limbo_stock_stockImages",JSON.stringify(p))},[p]),e.useEffect(()=>{sessionStorage.setItem("limbo_stock_currentPage",JSON.stringify(g))},[g]),e.useEffect(()=>{sessionStorage.setItem("limbo_stock_paginationInfo",JSON.stringify(y))},[y]),e.useEffect(()=>{if(!c.loading&&1===c.services.length){const e=c.services[0];b(e.slug),A(!1),C.fetchParams(e.slug,!0)}},[c.loading,c.services]),e.useEffect(()=>{if(!d)return;const e=C.params?.[d]?.parameters;if(e){const t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default??""]));t.service=d,h(t)}},[d,C.params]);const R=e=>{const{name:t,value:l}=e.target;h(e=>({...e,[t]:l}))},O=async(e=1)=>{j(!0),E(null),1===e&&f([]);try{let l;if(1===e){const t=C.params?.[d]?.parameters,n={...m};Object.entries(t||{}).forEach(([e,t])=>{e in n||(n[e]=t.default??"")}),n.per_page=parseInt(n.per_page),n.service=d,n.page=e,l=n,s.current={...n}}else l={...s.current,page:e};const n=await function(e,t=!1){return W({endpoint:"/stock/search",method:"POST",body:e,prod:t,basePath:$t})}(l,t),a=n?.data?.images||[];let r=n?.data?.pagination||null,i=null;r&&(i={total:r.total_count??r.total??a.length,per_page:r.per_page??(Array.isArray(a)?a.length:0),current_page:r.page??r.current_page??e}),f(U(Array.isArray(a)?a:[])),x(i),v(i?.current_page||e)}catch(l){E(l.message||"Error al buscar imágenes")}finally{j(!1)}},U=e=>{const t=new Set,l=[];return(e||[]).forEach((e,n)=>{const a=e.url||e.preview_url||e.full||e.preview;a&&!t.has(a)&&(t.add(a),l.push({...e,preview:e.preview_url||e.preview||e.url||e.full,full:e.url||e.full||e.preview_url,id:e.id||n,title:e.title||e.filename||`Imagen ${n+1}`,source:e.service||d,sourceTitle:c.services.find(e=>e.slug===d)?.label||d}))}),l},B=async e=>{e.preventDefault();const t=m.query||m.search||m.term||"";t.trim().length<5?E("La búsqueda debe tener al menos 5 caracteres"):(k(t),await O(1))},V=e=>{e<1||O(e)},H=async e=>{_(e.id),E(null);try{const l={service:d,image_id:e.id},n=await function(e,t=!1){return W({endpoint:"/stock/download",method:"POST",body:e,prod:t,basePath:$t})}(l,t),a=n?.result?.url||n?.result?.download_url||n?.data?.images?.url||n?.data?.url||n?.images?.url||n?.url;if(!a)throw console.error("Download response structure:",n),new Error("No se pudo obtener la URL de descarga");{const l=`${F({prod:t})}/api/atenea/proxy?url=${encodeURIComponent(a)}`,r=await fetch(l,{credentials:"include",headers:{Authorization:`Bearer ${q().token||""}`}});if(!r.ok)throw new Error(`Error al descargar imagen: ${r.status}`);const i=await r.blob(),o=n?.result?.filename||n?.data?.images?.filename||n?.data?.filename||`stock-${e.id}.jpg`,s=new File([i],o,{type:i.type||"image/jpeg"});I(s)}}catch(l){E(l.message||"No se pudo recuperar la imagen seleccionada")}finally{_(null)}};return c.loading?l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:py-8",children:[l.jsx("span",{className:"limbo-loader lb:mr-2"})," Cargando servicios de Stock..."]}):c.services.length?l.jsx("div",{className:"lb:flex lb:flex-col lb:mx-4 lb:pb-2",children:T?l.jsxs(l.Fragment,{children:[l.jsx("h3",{className:"lb:text-2xl lb:font-semibold lb:text-brand-blue-1000 lb:mb-3",children:"Selecciona el servicio de Stock"}),c.error&&l.jsx(fe,{variant:"danger",children:c.error}),l.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:gap-3",children:c.services.map(e=>l.jsxs("button",{type:"button",onClick:()=>{b(e.slug),A(!1),h({}),f([]),v(1),x(null),E(null),C.fetchParams(e.slug,!0)},disabled:c.loading||n,className:`lb:group lb:relative lb:p-4 lb:rounded-lg lb:border-2 lb:transition-all lb:duration-200 lb:overflow-hidden lb:flex lb:flex-col lb:items-center lb:justify-center lb:min-h-30 lb:border-gray-200 lb:hover:border-brand-blue-300 lb:hover:shadow-md lb:lg:w-min ${c.loading||n?"lb:opacity-50 lb:cursor-not-allowed":"lb:cursor-pointer"} `,style:{position:"relative"},children:[e.image&&l.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-cover lb:bg-center lb:transition-opacity lb:duration-200 lb:group-hover:opacity-35",style:{backgroundImage:`url(${e.image})`,opacity:.2}}),l.jsxs("div",{className:"lb:relative lb:z-10 lb:flex lb:flex-col lb:items-center lb:justify-center lb:gap-2 lb:text-center",children:[l.jsx("span",{className:"lb:text-base lb:font-semibold lb:text-neutral-black-000",children:e.label}),e.description&&l.jsx("span",{className:"lb:text-sm lb:text-gray-950 lb:line-clamp-2 lb:drop-shadow lb:drop-shadow-neutral-white-000",children:e.description})]})]},e.slug))})]}):l.jsxs(l.Fragment,{children:[l.jsx("h3",{className:"lb:text-2xl lb:font-semibold lb:text-brand-blue-1000",children:c.services.find(e=>e.slug===d)?.label||"Búsqueda Stock"}),C.loading&&l.jsx("div",{children:"Cargando parámetros..."}),C.error&&l.jsx(fe,{variant:"danger",children:C.error}),d&&(()=>{const e=C.params?.[d]?.parameters;if(!e)return null;const t=Object.entries(e).filter(([,e])=>!e.hidden),a=t.filter(([e])=>e.toLowerCase().includes("query")||e.toLowerCase().includes("search")||e.toLowerCase().includes("term")),r=t.filter(([e])=>!e.toLowerCase().includes("query")&&!e.toLowerCase().includes("search")&&!e.toLowerCase().includes("term")),i=(e,t)=>{let a=t.placeholder||"";a||(a="integer"===t.type?t.minValue&&t.maxValue?`Entre ${t.minValue} y ${t.maxValue}`:t.minValue?`Mínimo ${t.minValue}`:t.maxValue?`Máximo ${t.maxValue}`:"Introduce un número":e.toLowerCase().includes("query")||e.toLowerCase().includes("search")||e.toLowerCase().includes("term")?"Buscar imágenes...":`Introduce ${(t.label||e).toLowerCase()}`);const r=e.toLowerCase().includes("query")||e.toLowerCase().includes("search")||e.toLowerCase().includes("term");return l.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-1",children:[l.jsxs("label",{htmlFor:`stock-${e}`,className:"lb:text-xs lb:font-medium lb:text-brand-blue-1000",children:[t.label||e,t.required&&l.jsx("span",{className:"lb:text-red-1000 lb:ml-1",children:"*"})]}),t.options&&t.multiple?l.jsx("div",{className:"lb:flex lb:flex-wrap lb:gap-2 lb:min-h-[50px] lb:px-2 lb:justify-between lb:border-2 lb:border-gray-transparent-500 lb:rounded-lg",children:t.options.map(t=>l.jsxs("label",{className:"lb:flex lb:items-center lb:gap-1",children:[l.jsx("input",{type:"checkbox",name:`stock-${e}`,value:t,checked:Array.isArray(m[e])&&m[e].includes(t),onChange:()=>((e,t)=>{h(l=>{const n=Array.isArray(l[e])?l[e]:[];return n.includes(t)?{...l,[e]:n.filter(e=>e!==t)}:{...l,[e]:[...n,t]}})})(e,t),disabled:n}),l.jsx("span",{className:"lb:text-xs",children:t})]},t))}):t.options?l.jsx("select",{id:`stock-${e}`,name:e,value:m[e]??"",onChange:R,className:"limbo-input",disabled:n,title:t.label||e,children:t.options.map(e=>l.jsx("option",{value:e,children:e},e))}):r?l.jsx("textarea",{id:`stock-${e}`,name:e,value:m[e]??"",onChange:R,className:"limbo-input lb:resize-none lb:overflow-y-auto",disabled:n,required:t.required,placeholder:a,title:t.label||e,rows:3,style:{maxHeight:"9rem",minHeight:"3rem"},onInput:e=>{e.target.style.height="auto";const t=Math.min(e.target.scrollHeight,144);e.target.style.height=`${t}px`}}):l.jsx("input",{id:`stock-${e}`,type:"integer"===t.type?"number":"text",name:e,value:m[e]??"",onChange:R,className:"limbo-input",disabled:n,required:t.required,min:t.minValue,max:t.maxValue,placeholder:a,title:t.label||e})]},e)};return l.jsxs("div",{children:[c.services.length>1&&l.jsxs("button",{type:"button",onClick:()=>{A(!0),b(""),h({}),f([]),v(1),x(null),E(null)},className:"lb:flex lb:cursor-pointer lb:items-center lb:gap-2 lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:mb-4 lb:font-medium",children:[l.jsx("span",{className:"icon icon-arrow-left"}),"Volver al menú de servicios"]}),l.jsxs("div",{className:"lb:relative lb:max-w-[89dvw]",children:[l.jsxs("form",{onSubmit:B,"data-type":"stock",className:"lb:flex lb:flex-col lb:gap-3 lb:mt-4 lb:border-t-1 lb:pt-4 lb:border-brand-blue-200","aria-label":"Formulario búsqueda de imágenes de Stock",children:[N&&l.jsx(fe,{variant:"danger",className:"lb:mt-4",children:N}),l.jsx("div",{className:"lb:flex lb:flex-col lb:gap-3",children:a.map(([e,t])=>i(e,t))}),r.length>0&&l.jsxs("div",{className:"lb:border-t lb:border-gray-200 lb:pt-3",children:[l.jsxs("button",{type:"button",onClick:()=>L(!z),className:"lb:flex lb:items-center lb:gap-2 lb:text-sm lb:font-medium lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:mb-3 lb:transition-colors",children:[l.jsx("svg",{className:"lb:w-4 lb:h-4 lb:transition-transform "+(z?"lb:rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"Opciones avanzadas",!z&&l.jsxs("span",{className:"lb:text-xs lb:text-gray-500",children:["(",r.length," opciones)"]})]}),z&&l.jsx("div",{className:"lb:grid lb:grid-cols-1 lb:md:grid-cols-2 lb:gap-3 lb:animate-fadeIn",children:r.map(([e,t])=>i(e,t))})]}),l.jsx("button",{type:"submit",disabled:S||n,className:"limbo-btn lb:w-full lb:mt-2 "+(S?"lb:cursor-not-allowed limbo-btn-disabled":"limbo-btn-primary"),style:{minHeight:44},children:S?"Buscando...":"Buscar imágenes"})]}),l.jsx(pt,{show:S&&!p.length,message:"Buscando imágenes..."})]})]})})(),M&&l.jsx("div",{className:"lb:mt-6 lb:md:w-full lb:mx-auto",children:l.jsx(St,{image:M,onDiscard:()=>{I(null),E(null)},onDownload:()=>{},onSelect:e=>{if(a)if(e&&M&&e!==M.name){const t=new File([M],e,{type:M.type});a(t)}else a(M)},showRetry:!1,disabled:n,selectedFolder:r,onFolderChange:i,folderConfig:o})}),!M&&p.length>0&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"lb:mt-6 lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:lg:grid-cols-4 lb:gap-1 lb:relative","aria-live":"polite",children:[l.jsx(pt,{show:S,message:"Cargando imágenes..."}),p.map((e,a)=>{const r=F({prod:t}),i=e.preview||e.thumbnail||e.url,o=i?`${r}/api/atenea/proxy?url=${encodeURIComponent(i)}`:null;return l.jsx("div",{className:"lb:border lb:border-brand-blue-200 lb:rounded-sm lb:overflow-hidden lb:bg-white lb:shadow-sm lb:hover:shadow-md lb:transition-all lb:duration-200 lb:cursor-pointer",title:"Ver imagen",onClick:()=>{$||S||n||D(e)},children:l.jsxs("div",{className:"lb:relative lb:aspect-video lb:bg-neutral-100",children:[l.jsx(zt,{src:i,fallbackSrc:o,alt:e.title||`Resultado ${a+1}`}),$===e.id&&l.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-white/90 lb:flex lb:flex-col lb:items-center lb:justify-center lb:gap-2",children:[l.jsxs("div",{className:"lb:relative lb:w-10 lb:h-10",children:[l.jsx("div",{className:"lb:absolute lb:inset-0 lb:border-4 lb:border-brand-blue-200 lb:rounded-full"}),l.jsx("div",{className:"lb:absolute lb:inset-0 lb:border-4 lb:border-brand-blue-800 lb:rounded-full lb:border-t-transparent lb:animate-spin"})]}),l.jsx("span",{className:"lb:text-sm lb:font-medium lb:text-brand-blue-1000",children:"Descargando..."})]})]})},e.id||a)})]}),y&&l.jsxs("div",{className:"lb:mt-6 lb:flex lb:items-center lb:justify-center lb:gap-2",children:[l.jsxs("button",{onClick:()=>V(y.current_page-1),disabled:y.current_page<=1||S,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(y.current_page<=1||S?" pointer-events-none cursor-default":" limbo-btn-primary"),children:[l.jsx("span",{className:"icon icon-arrow-left-white icon--sm"})," ","Anterior"]}),l.jsxs("span",{className:"lb:px-4 lb:py-2 lb:text-sm lb:text-neutral-700",children:["Página ",y.current_page," de"," ",Math.max(1,Math.ceil(y.total/y.per_page)),l.jsxs("span",{className:"lb:text-xs lb:text-neutral-500 lb:block",children:["(",y.total," imágenes totales)"]})]}),l.jsxs("button",{onClick:()=>V(y.current_page+1),disabled:S||y.current_page>=Math.ceil(y.total/y.per_page),className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(S||y.current_page>=Math.ceil(y.total/y.per_page)?" pointer-events-none cursor-default":" limbo-btn-primary"),children:["Siguiente"," ",l.jsx("span",{className:"icon icon-arrow-right-white icon--sm"})]})]})]}),!S&&0===p.length&&d&&w&&l.jsxs("div",{className:"lb:mt-6 lb:text-center lb:text-neutral-600 lb:py-8 lb:bg-neutral-50 lb:rounded-lg",children:[l.jsx("span",{className:"icon icon-search icon--lg lb:mb-2"}),l.jsxs("p",{children:['No se encontraron imágenes para "',m.query,'"']}),l.jsx("p",{className:"lb:text-sm lb:mt-1",children:"Intenta con otros términos de búsqueda"})]}),P&&(()=>{const e=F({prod:t}),n=P.preview||P.thumbnail||P.url,a=n?`${e}/api/atenea/proxy?url=${encodeURIComponent(n)}`:null;return l.jsx(At,{isOpen:!!P,image:{previewUrl:n,proxyUrl:a,title:P.title||P.filename||"Imagen"},onCancel:()=>D(null),onSelect:()=>{const e=P;D(null),H(e)}})})()]})}):l.jsx(fe,{variant:"warning",children:"No hay servicios de Stock disponibles."})}const Mt="/api";function It(e,t=!1){const l=new URLSearchParams;return e.portal&&l.set("portal",e.portal),e.media_type&&l.set("media_type",e.media_type),e.page&&l.set("page",String(e.page)),l.set("per_page",String(e.per_page)),e.search&&l.set("search",e.search),e.order&&l.set("order",e.order),W({endpoint:`/external/media?${l.toString()}`,method:"GET",prod:t,basePath:Mt})}const Pt=new Map;function Dt(t=!1){const[l,n]=e.useState([]),[a,r]=e.useState(!0),[i,o]=e.useState(null);e.useEffect(()=>{const e=`portal-sources-${t}`,l=Pt.get(e),a=Date.now();if(l&&a-l.timestamp<864e5)return n(l.data),void r(!1);let i=!0;return(async()=>{try{const l=await function(e=!1,t=!0){const l=new URLSearchParams;return l.set("active",t?"true":"false"),W({endpoint:`/external/portals?${l.toString()}`,method:"GET",prod:e,basePath:Mt})}(t,!0);if(!i)return;let r=l?.data||[];Array.isArray(r)||(r=[]);const o=r.map(e=>({id:e.slug||e.id,numericId:e.id,name:e.name,title:e.name,slug:e.slug,url:e.website_url,image:e.logo_url,isActive:e.is_active}));n(o),Pt.set(e,{data:o,timestamp:a})}catch(l){i&&o(l.message)}finally{i&&r(!1)}})(),()=>{i=!1}},[t]);return{sources:l,loading:a,error:i,invalidateCache:()=>{Pt.delete(`portal-sources-${t}`)}}}function Rt({isOpen:t=!1,video:n,onClose:a,onSelect:r=null}){const[i,o]=e.useState(!1),s=e.useMemo(()=>n?"youtube"===n.platform&&n.video_id?`https://www.youtube.com/embed/${n.video_id}?autoplay=1&rel=0`:"vimeo"===n.platform&&n.video_id?`https://player.vimeo.com/video/${n.video_id}?autoplay=1`:n.embed_url||null:null,[n]),c=e.useMemo(()=>n&&(n.player_url||n.embed_url||n.post_url)||"",[n]),u=e.useCallback(async()=>{if(c)try{await navigator.clipboard.writeText(c),o(!0),setTimeout(()=>o(!1),2e3)}catch{const e=document.createElement("textarea");e.value=c,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e),o(!0),setTimeout(()=>o(!1),2e3)}},[c]),d=e.useCallback(()=>{r&&n&&r(n)},[r,n]);if(!n)return null;const b=[n.portal_name,n.platform].filter(Boolean).join(" · "),m=r?l.jsxs("button",{type:"button",onClick:d,className:"lb:flex lb:items-center lb:gap-2 lb:px-4 lb:py-1.5 lb:rounded-lg lb:bg-brand-blue-800 lb:hover:bg-brand-blue-900 lb:text-white lb:text-sm lb:font-medium lb:transition-colors","aria-label":"Seleccionar video",children:[l.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),l.jsx("span",{children:"Seleccionar"})]}):l.jsx("button",{type:"button",onClick:u,disabled:!c,className:"lb:flex lb:items-center lb:gap-2 lb:px-4 lb:py-1.5 lb:rounded-lg lb:text-sm lb:font-medium lb:transition-colors "+(i?"lb:bg-green-600 lb:text-white":"lb:bg-white/10 lb:hover:bg-white/20 lb:text-white"),"aria-label":"Copiar URL del video",children:i?l.jsxs(l.Fragment,{children:[l.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),l.jsx("span",{children:"Copiado"})]}):l.jsxs(l.Fragment,{children:[l.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})}),l.jsx("span",{children:"Copiar URL"})]})}),h=l.jsxs("span",{children:[l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return l.jsx(Ne,{isOpen:t,onClose:a,title:n.title||"Video",subtitle:b,ariaLabel:"Vista previa de video externo",headerActions:m,footerHints:h,children:l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-3 lb:w-full lb:max-w-5xl lb:px-4",children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:px-4 lb:py-2 lb:bg-amber-500/20 lb:border lb:border-amber-500/40 lb:rounded-lg lb:text-amber-200 lb:text-sm",children:[l.jsx("svg",{className:"lb:w-5 lb:h-5 lb:shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),l.jsxs("span",{children:["Este video no se puede guardar en Limbo — alojado en"," ",l.jsx("strong",{className:"lb:capitalize",children:n.platform||"plataforma externa"})]})]}),l.jsx("div",{className:"lb:relative lb:w-full lb:aspect-video lb:bg-black lb:rounded-lg lb:overflow-hidden",children:s?l.jsx("iframe",{src:s,className:"lb:absolute lb:inset-0 lb:w-full lb:h-full",allow:"autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0,title:n.title||"Video"}):l.jsxs("div",{className:"lb:absolute lb:inset-0 lb:flex lb:flex-col lb:items-center lb:justify-center lb:text-white lb:gap-3",children:[l.jsx("svg",{className:"lb:w-16 lb:h-16 lb:text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})}),l.jsx("p",{className:"lb:text-sm lb:text-gray-400",children:"No se puede previsualizar este video"}),c&&l.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"lb:text-sm lb:text-brand-blue-400 lb:hover:text-brand-blue-300 lb:underline",children:"Abrir en nueva pestaña"})]})}),c&&l.jsx("p",{className:"lb:text-xs lb:text-gray-500 lb:truncate lb:max-w-full lb:px-2",children:c})]})})}const Ot=({src:t,fallbackSrc:n,alt:a,className:r,onError:i})=>{const[o,s]=e.useState("loading"),[c,u]=e.useState(t),[d,b]=e.useState(!1);return"error"===o?null:l.jsxs("div",{className:"lb:relative lb:w-full lb:h-full",children:["loading"===o&&l.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-linear-to-r lb:from-gray-200 lb:via-gray-100 lb:to-gray-200 lb:animate-pulse lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-spinner lb:w-8 lb:h-8 lb:text-gray-400 lb:animate-spin"})}),l.jsx("img",{src:c,alt:a,className:`${r} ${"loading"===o?"lb:opacity-0":"lb:opacity-100"} lb:transition-opacity lb:duration-300`,loading:"lazy",onLoad:()=>{s("loaded")},onError:()=>{n&&!d?(b(!0),u(n),s("loading")):(s("error"),i&&i())}})]})};function Ft({prod:t,disabled:n,onSelect:a,onVideoSelect:r,selectedFolder:i,onFolderChange:o,folderConfig:s,resolvedAccept:c=null,returnConfig:u=null}){const{sources:d,loading:b,error:m}=Dt(t),h=e.useMemo(()=>{if(!c||c.isAllTypes)return[{value:"images",label:"Imágenes"},{value:"videos",label:"Vídeos"},{value:"all",label:"Todo"}];const e=[];return c.includesImages&&e.push({value:"images",label:"Imágenes"}),c.includesVideos&&e.push({value:"videos",label:"Vídeos"}),e.length>1&&e.push({value:"all",label:"Todo"}),e.length>0?e:[{value:"images",label:"Imágenes"}]},[c]),p=h[0]?.value||"images",[f,g]=e.useState(null),[v,y]=e.useState(p),[x,w]=e.useState(""),[k,C]=e.useState([]),[S,j]=e.useState(1),[N,E]=e.useState(null),[$,_]=e.useState(!1),[T,A]=e.useState(null),[z,L]=e.useState(null),[M,I]=e.useState(null),[P,D]=e.useState(new Set),[R,O]=e.useState(!1),[U,B]=e.useState(null),[q,W]=e.useState(null),V=!!u&&"url"===u.format,H=e.useRef({}),K=e.useCallback((e,t,l,n)=>`${e}_${t}_${l}_${n}`,[]),G=e.useCallback(async(e,l,n,a)=>{const r=K(e,l,n,a),i=H.current[r];if(i)return C(i.items),E(i.pagination),j(a),A(null),void O(!0);_(!0),A(null);try{const i={portal:e,media_type:l,page:a,per_page:20};n.trim()&&(i.search=n.trim());const o=new Promise((e,t)=>setTimeout(()=>t(new Error("__timeout__")),25e3)),s=await Promise.race([It(i,t),o]),c=s?.data||{},u=c.items||[],d=c.pagination||{total_items:u.length,total_pages:1,current_page:a,per_page:20};H.current[r]={items:u,pagination:d},C(u),E(d),j(a),D(new Set),O(!0),0===u.length&&A("No se encontraron resultados para este portal.")}catch(o){const e="__timeout__"===o.message;A(e?"El portal tardó demasiado en responder. Puede estar temporalmente no disponible. Inténtalo de nuevo.":o.message||"Error al cargar media del portal"),C([]),E(null),O(!0)}finally{_(!1)}},[t,K]),Q=e.useCallback(e=>{e!==f&&(g(e),w(""),y(p),C([]),E(null),A(null),L(null),B(null),D(new Set),O(!1),H.current={},G(e,p,"",1))},[f,p,G]),X=e.useCallback(()=>{g(null),C([]),E(null),A(null),w(""),L(null),B(null),D(new Set),O(!1),H.current={}},[]),Y=e.useCallback(()=>{f&&(H.current={},G(f,v,x,1))},[f,v,x,G]),J=e.useCallback(e=>{"Enter"===e.key&&(e.preventDefault(),Y())},[Y]),Z=e.useCallback(e=>{e<1||!f||G(f,v,x,e)},[f,v,x,G]),ee=e.useCallback(e=>{B(null),r?r(e):a&&a(e)},[r,a]),te=e.useCallback(async e=>{if("video"===e.type){const t={type:"video",source:"portal",title:e.title||"",thumbnail:e.thumbnail||e.url,embed_url:e.embed_url||null,player_url:e.player_url||null,post_url:e.post_url||null,platform:e.platform||null,video_id:e.video_id||null,portal_slug:e.portal_slug||f,portal_name:e.portal_name||d.find(e=>e.slug===f)?.name||null,date_published:e.date_published||null,author:e.author||null};return void B(t)}const l=e.url||e.thumbnail;if(l){I(l),A(null);try{let n=null;try{const e=await fetch(l,{mode:"cors"});e.ok&&(n=await e.blob())}catch{}if(!n){const e=`${F({prod:t})}/api/external/proxy?url=${encodeURIComponent(l)}`,a=await fetch(e);if(!a.ok)throw new Error(`Error al descargar: ${a.status}`);n=await a.blob()}const a=e.title?`${e.title.substring(0,80)}.${"image/png"===e.mime_type?"png":"jpg"}`:`portal-${Date.now()}.jpg`,r=new File([n],a,{type:n.type||e.mime_type||"image/jpeg"});L(r)}catch(n){A(n.message||"No se pudo recuperar la imagen del portal")}finally{I(null)}}else A("No se encontró URL de la imagen")},[t,f,d]);if(b)return l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:py-8",children:[l.jsx("span",{className:"limbo-loader lb:mr-2"})," Cargando portales disponibles..."]});if(!d.length)return l.jsx(fe,{variant:"warning",children:"No hay portales externos disponibles."});if(!f)return l.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-4",children:[l.jsx("h3",{className:"lb:text-lg lb:font-semibold lb:text-brand-blue-1000",children:"Selecciona un Portal"}),m&&l.jsx(fe,{variant:"danger",children:m}),l.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:gap-3",children:d.map(e=>l.jsx("button",{type:"button",onClick:()=>Q(e.slug),disabled:n,className:"lb:relative lb:p-4 lb:rounded-lg lb:border-2 lb:transition-all lb:duration-200 lb:flex lb:flex-col lb:items-center lb:justify-center lb:min-h-25 lb:gap-2 lb:max-h-27.5 lb:box-border lb:border-gray-200 lb:bg-white lb:hover:border-brand-blue-350 lb:hover:shadow-md "+(n?"lb:opacity-50 lb:cursor-not-allowed":"lb:cursor-pointer"),children:e.image?l.jsx("img",{className:"lb:object-auto lb:bg-no-repeat lb:bg-center lb:max-h-full lb:object-contain lb:h-full lb:px-16",src:e.image,alt:e.title}):l.jsx("span",{className:"lb:text-sm lb:font-medium lb:text-brand-blue-800",children:e.name})},e.slug))})]});const le=d.find(e=>e.slug===f),ne=F({prod:t});return l.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-3",children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-3",children:[l.jsxs("button",{type:"button",onClick:X,className:"lb:flex lb:items-center lb:gap-1 lb:text-sm lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:font-medium lb:transition-colors",children:[l.jsx("span",{className:"icon icon-arrow-left icon--sm"}),"Portales"]}),l.jsx("span",{className:"lb:text-gray-300",children:"|"}),l.jsx("h3",{className:"lb:text-lg lb:font-semibold lb:text-brand-blue-1000",children:le?.name||f})]}),l.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-3 lb:border-t lb:pt-3 lb:border-brand-blue-200",children:[h.length>1&&l.jsx("div",{className:"lb:flex lb:gap-2",children:h.map(({value:e,label:t})=>l.jsx("button",{type:"button",onClick:()=>y(e),disabled:n||$,className:"lb:px-3 lb:py-1.5 lb:text-sm lb:rounded-md lb:font-medium lb:transition-colors "+(v===e?"lb:bg-brand-blue-800 lb:text-white":"lb:bg-gray-100 lb:text-gray-700 lb:hover:bg-gray-200"),children:t},e))}),l.jsxs("div",{className:"lb:flex lb:gap-2",children:[l.jsx("input",{type:"text",value:x,onChange:e=>w(e.target.value),onKeyDown:J,className:"limbo-input lb:flex-1",placeholder:"Buscar en el portal...",disabled:n||$}),l.jsxs("button",{type:"button",onClick:Y,disabled:n||$,className:"limbo-btn limbo-btn-primary lb:px-4 lb:py-2 lb:text-sm lb:font-medium lb:whitespace-nowrap lb:flex lb:items-center lb:gap-1.5",children:[$?l.jsx("span",{className:"limbo-loader limbo-loader--sm"}):l.jsx("span",{className:"icon icon-search-white icon--sm"}),"Buscar"]})]})]}),T&&!$&&l.jsx(fe,{variant:"warning",children:T}),z&&l.jsx("div",{className:"lb:mt-2 lb:md:w-full lb:mx-auto",children:l.jsx(St,{image:z,onDiscard:()=>{L(null),A(null)},onDownload:()=>{},onSelect:e=>{if(a)if(e&&z&&e!==z.name){const t=new File([z],e,{type:z.type});a(t)}else a(z)},showRetry:!1,disabled:n,selectedFolder:i,onFolderChange:o,folderConfig:s})}),!z&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"lb:relative lb:min-h-50","aria-live":"polite",children:[$&&l.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-white/80 lb:z-10 lb:flex lb:items-center lb:justify-center lb:rounded-lg",children:l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-2",children:[l.jsx("span",{className:"limbo-loader"}),l.jsx("span",{className:"lb:text-sm lb:text-brand-blue-800",children:"Cargando media..."})]})}),k.length>0&&l.jsxs("div",{className:"lb:relative lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:lg:grid-cols-4 lb:gap-2",children:[l.jsx(pt,{show:$,message:"Cargando media..."}),k.map((e,t)=>{const a=`${e.portal_slug}-${e.id||t}`,r=e.thumbnail||e.url;if(P.has(a)||!r)return null;const i=`${ne}/api/external/proxy?url=${encodeURIComponent(r)}`,o="video"===e.type;return l.jsxs("div",{className:"lb:group lb:border lb:border-brand-blue-200 lb:rounded-lg lb:overflow-hidden lb:bg-white lb:shadow-sm lb:hover:shadow-md lb:transition-all lb:duration-200 lb:cursor-pointer",onClick:()=>{M||$||n||(o?te(e):W(e))},children:[l.jsxs("div",{className:"lb:relative lb:aspect-video lb:bg-neutral-100",children:[l.jsx(Ot,{src:r,fallbackSrc:i,alt:e.alt||e.title||`Media ${t+1}`,className:"lb:object-cover lb:w-full lb:h-full",onError:()=>{D(e=>{const t=new Set(e);return t.add(a),t})}}),o&&l.jsx("span",{className:"lb:absolute lb:top-1 lb:left-1 lb:bg-black/60 lb:text-white lb:text-xs lb:px-2 lb:py-1 lb:rounded",children:"Video"}),M===(e.url||e.thumbnail)?l.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-white/90 lb:flex lb:flex-col lb:items-center lb:justify-center lb:gap-2",children:[l.jsxs("div",{className:"lb:relative lb:w-10 lb:h-10",children:[l.jsx("div",{className:"lb:absolute lb:inset-0 lb:border-4 lb:border-brand-blue-200 lb:rounded-full"}),l.jsx("div",{className:"lb:absolute lb:inset-0 lb:border-4 lb:border-brand-blue-800 lb:rounded-full lb:border-t-transparent lb:animate-spin"})]}),l.jsx("span",{className:"lb:text-sm lb:font-medium lb:text-brand-blue-1000",children:"Descargando..."})]}):o?l.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-black/0 lb:group-hover:bg-black/60 lb:transition-colors lb:duration-200 lb:flex lb:items-center lb:justify-center lb:flex-col lb:gap-1",children:[l.jsx("svg",{className:"lb:w-10 lb:h-10 lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:duration-200 lb:text-white",viewBox:"0 0 24 24",fill:"currentColor",children:l.jsx("path",{d:"M8 5v14l11-7z"})}),l.jsx("span",{className:"lb:text-sm lb:font-medium lb:text-white lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:duration-200",children:"Seleccionar vídeo"})]}):null]}),e.title&&l.jsx("div",{className:"lb:px-2 lb:pb-2 lb:pt-1",children:l.jsx("p",{className:"lb:text-xs lb:text-gray-600 lb:truncate",title:e.title,children:e.title})})]},a)})]}),!R&&!$&&0===k.length&&!T&&l.jsxs("div",{className:"lb:text-center lb:text-neutral-600 lb:py-10 lb:bg-neutral-50 lb:rounded-lg",children:[l.jsx("p",{className:"lb:font-medium lb:text-brand-blue-800",children:"Cargando contenido del portal..."}),l.jsx("p",{className:"lb:text-sm lb:mt-1 lb:text-neutral-500",children:"También puedes buscar por término específico"})]}),R&&!$&&0===k.length&&!T&&l.jsxs("div",{className:"lb:text-center lb:text-neutral-600 lb:py-8 lb:bg-neutral-50 lb:rounded-lg",children:[l.jsx("span",{className:"icon icon-search icon--lg lb:mb-2"}),l.jsx("p",{children:"No se encontraron resultados"}),x&&l.jsx("p",{className:"lb:text-sm lb:mt-1",children:"Intenta con otros términos de búsqueda"})]})]}),N&&N.total_pages>1&&l.jsxs("div",{className:"lb:mt-4 lb:flex lb:items-center lb:justify-center lb:gap-2",children:[l.jsxs("button",{onClick:()=>Z(S-1),disabled:1===S||$,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(1===S||$?" pointer-events-none cursor-default":" limbo-btn-primary"),children:[l.jsx("span",{className:"icon icon-arrow-left-white icon--sm"})," ","Anterior"]}),l.jsxs("span",{className:"lb:px-4 lb:py-2 lb:text-sm lb:text-neutral-700",children:["Página ",S," de ",N.total_pages,l.jsxs("span",{className:"lb:text-xs lb:text-neutral-500 lb:block",children:["(",N.total_items," resultados)"]})]}),l.jsxs("button",{onClick:()=>Z(S+1),disabled:$||S>=N.total_pages,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+($||S>=N.total_pages?" pointer-events-none cursor-default":" limbo-btn-primary"),children:["Siguiente"," ",l.jsx("span",{className:"icon icon-arrow-right-white icon--sm"})]})]})]}),l.jsx(Rt,{isOpen:!!U,video:U,onClose:()=>B(null),onSelect:V?ee:null}),q&&(()=>{const e=q.thumbnail||q.url,t=`${ne}/api/external/proxy?url=${encodeURIComponent(e)}`;return l.jsx(At,{isOpen:!!q,image:{previewUrl:e,proxyUrl:t,title:q.title||q.alt||"Imagen"},onCancel:()=>W(null),onSelect:()=>{const e=q;W(null),te(e)}})})()]})}const Ut=[{id:"upload",label:"Subir archivo"},{id:"ai",label:"Generar"},{id:"stock",label:"Buscar en Stock"},{id:"portals",label:"Otros portales"}];function Bt({onSelect:t,onVideoSelect:n,disabled:a=!1,apiKey:r,prod:i=!1,allowedCategories:o=null,resolvedAccept:s=null,returnConfig:c=null,folderConfig:u=null,selectedFolder:d=null,onFolderChange:b=null,aiStarterPrompt:m,tags:h=[],onTagsChange:p=null}){const{isMobile:f,isTouch:g}=$(),v=e.useMemo(()=>!s||s.isAllTypes||s.includesImages?Ut:s.includesVideos?Ut.filter(e=>"upload"===e.id||"portals"===e.id):Ut.filter(e=>"upload"===e.id),[s]),[y,x]=e.useState("upload"),[w,k]=e.useState(null),[C,S]=e.useState(null),j=e.useRef(),N=["limbo-tabs","lb:flex","lb:gap-4","lb:border-b-2","lb:border-brand-blue-200","lb:mb-4",f&&"lb:overflow-x-auto lb:scrollbar-none"].filter(Boolean).join(" "),E=e=>{const t=["limbo-tab","lb:relative","lb:px-4","lb:py-2","lb:font-medium","lb:text-brand-blue-1000","lb:bg-transparent","lb:border-0","lb:border-b-2","lb:cursor-pointer","lb:transition-all","lb:duration-200","lb:hover:text-pink-1000","lb:focus:outline-none","lb:focus-visible:ring-2","lb:focus-visible:ring-brand-blue-400","lb:focus-visible:ring-offset-2","lb:text-nowrap"];return e?t.push("lb:border-b-brand-blue-1000","lb:font-semibold","limbo-active"):t.push("lb:border-b-transparent"),f&&t.push("lb:min-w-[100px]","lb:min-h-[44px]","lb:text-sm","lb:shrink-0"),g&&t.push("lb:touch-manipulation"),t.join(" ")};return l.jsxs("div",{className:"limbo-upload-form lb:py-4 lb:max-w-7xl lb:mx-auto",children:[v.length>1&&l.jsx("div",{className:N,role:"tablist","aria-label":"Opciones de subida",style:f?{WebkitOverflowScrolling:"touch",scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,children:v.map(e=>{const t=y===e.id;return l.jsxs("button",{type:"button","data-upload-tab-id":e.id,className:E(t),"aria-current":t?"page":void 0,"aria-selected":t,role:"tab",tabIndex:t?0:-1,onClick:()=>x(e.id),onKeyDown:t=>((e,t)=>{const l=v.findIndex(e=>e.id===t);let n=l;switch(e.key){case"ArrowLeft":e.preventDefault(),n=l>0?l-1:v.length-1;break;case"ArrowRight":e.preventDefault(),n=l<v.length-1?l+1:0;break;case"Home":e.preventDefault(),n=0;break;case"End":e.preventDefault(),n=v.length-1;break;case"Enter":case" ":return e.preventDefault(),void x(t);default:return}const a=v[n];a&&(x(a.id),setTimeout(()=>{const e=document.querySelector(`[data-upload-tab-id="${a.id}"]`);e&&e.focus()},0))})(t,e.id),id:`upload-tab-${e.id}`,"aria-controls":`upload-tabpanel-${e.id}`,style:g?{WebkitTapHighlightColor:"transparent"}:void 0,children:["ai"===e.id?l.jsx("span",{className:"icon icon-ia lb:me-1"}):null,e.label]},e.id)})}),l.jsxs("div",{className:"limbo-tab-content lb:px-2 lb:py-2",role:"tabpanel",id:`upload-tabpanel-${y}`,"aria-labelledby":`upload-tab-${y}`,children:["upload"===y&&l.jsx(ct,{file:w,setFile:k,previewUrl:C,setPreviewUrl:S,fileInputRef:j,onSelect:t,disabled:a,allowedCategories:o,resolvedAccept:s,selectedFolder:d,onFolderChange:b,folderConfig:u,tags:h,onTagsChange:p}),"ai"===y&&l.jsx(Et,{apiKey:r,prod:i,disabled:a,onSelect:t,selectedFolder:d,onFolderChange:b,folderConfig:u,aiStarterPrompt:m}),"stock"===y&&l.jsx(Lt,{apiKey:r,prod:i,disabled:a,onSelect:t,selectedFolder:d,onFolderChange:b,folderConfig:u}),"portals"===y&&l.jsx(Ft,{apiKey:r,prod:i,disabled:a,onSelect:t,onVideoSelect:n,resolvedAccept:s,returnConfig:c,selectedFolder:d,onFolderChange:b,folderConfig:u})]})]})}function qt({onSelect:e,onVideoSelect:t,onFolderChange:n,uploading:a,uploadError:r,uploadedImage:i,selectedUploadFolder:o,apiKey:s,prod:c,allowedCategories:u,resolvedAccept:d,returnConfig:b,folderConfig:m,aiStarterPrompt:h,resetUpload:p,tags:f,onTagsChange:g}){return l.jsxs("div",{children:[a&&l.jsx(tt,{text:"Subiendo archivo..."}),r&&l.jsxs(fe,{variant:"danger",toast:!0,onClose:p,children:["Error al subir archivo: ",r]}),i&&l.jsxs(fe,{variant:"success",toast:!0,onClose:p,children:[l.jsx("span",{className:"icon icon-tick-white icon--2sm"})," Archivo subido correctamente: ",i.filename]}),l.jsx(Bt,{onSelect:e,onVideoSelect:t,disabled:a,apiKey:s,prod:c,allowedCategories:u,resolvedAccept:d,returnConfig:b,folderConfig:m,aiStarterPrompt:h,selectedFolder:o,onFolderChange:n,tags:f,onTagsChange:g})]})}const Wt="undefined"!=typeof window&&void 0!==window.document,Vt=Wt?window:{},Ht=!!Wt&&"ontouchstart"in Vt.document.documentElement,Kt=!!Wt&&"PointerEvent"in Vt,Gt="cropper",Qt=`${Gt}-canvas`,Xt=`${Gt}-crosshair`,Yt=`${Gt}-grid`,Jt=`${Gt}-handle`,Zt=`${Gt}-image`,el=`${Gt}-selection`,tl=`${Gt}-shade`,ll=`${Gt}-viewer`,nl="select",al="move",rl="scale",il="rotate",ol="transform",sl="none",cl="n-resize",ul="e-resize",dl="s-resize",bl="w-resize",ml="ne-resize",hl="nw-resize",pl="se-resize",fl="sw-resize",gl=Kt?"pointerdown":Ht?"touchstart":"mousedown",vl=Kt?"pointermove":Ht?"touchmove":"mousemove",yl=Kt?"pointerup pointercancel":Ht?"touchend touchcancel":"mouseup",xl="error",wl="keydown",kl="load",Cl="resize",Sl="wheel",jl="action",Nl="actionend",El="actionstart",$l="change",_l="transform";const Tl=Number.isNaN||Vt.isNaN;function Al(e){return"number"==typeof e&&!Tl(e)}function zl(e){return Al(e)&&e>0&&e<1/0}function Ll(e){return"object"==typeof e&&null!==e}const{hasOwnProperty:Ml}=Object.prototype;function Il(e){if(!Ll(e))return!1;try{const{constructor:t}=e,{prototype:l}=t;return t&&l&&Ml.call(l,"isPrototypeOf")}catch(t){return!1}}function Pl(e){return"function"==typeof e}function Dl(e){return"object"==typeof e&&null!==e&&1===e.nodeType}const Rl=/([a-z\d])([A-Z])/g;function Ol(e){return String(e).replace(Rl,"$1-$2").toLowerCase()}const Fl=/-[A-z\d]/g;function Ul(e){return e.replace(Fl,e=>e.slice(1).toUpperCase())}const Bl=/\s\s*/;function ql(e,t,l,n){t.trim().split(Bl).forEach(t=>{e.removeEventListener(t,l,n)})}function Wl(e,t,l,n){t.trim().split(Bl).forEach(t=>{e.addEventListener(t,l,n)})}function Vl(e,t,l,n){Wl(e,t,l,Object.assign(Object.assign({},n),{once:!0}))}const Hl={bubbles:!0,cancelable:!0,composed:!0};const Kl=Promise.resolve();function Gl(e){const{documentElement:t}=e.ownerDocument,l=e.getBoundingClientRect();return{left:l.left+(Vt.pageXOffset-t.clientLeft),top:l.top+(Vt.pageYOffset-t.clientTop)}}const Ql=/deg|g?rad|turn$/i;function Xl(e){const t=parseFloat(e)||0;if(0!==t){const[l="rad"]=String(e).match(Ql)||[];switch(l.toLowerCase()){case"deg":return t/360*(2*Math.PI);case"grad":return t/400*(2*Math.PI);case"turn":return t*(2*Math.PI)}}return t}const Yl="contain";function Jl(e,t=Yl){const{aspectRatio:l}=e;let{width:n,height:a}=e;const r=zl(n),i=zl(a);if(r&&i){const e=a*l;t===Yl&&e>n||"cover"===t&&e<n?a=n/l:n=a*l}else r?a=n/l:i&&(n=a*l);return{width:n,height:a}}function Zl(e,...t){if(0===t.length)return e;const[l,n,a,r,i,o]=e,[s,c,u,d,b,m]=t[0];return Zl(e=[l*s+a*c,n*s+r*c,l*u+a*d,n*u+r*d,l*b+a*m+i,n*b+r*m+o],...t.slice(1))}const en=/left|top|width|height/i,tn="open",ln=new WeakMap,nn=new WeakMap,an=new Map,rn=Vt.document&&Array.isArray(Vt.document.adoptedStyleSheets)&&"replaceSync"in Vt.CSSStyleSheet.prototype;class on extends HTMLElement{get $sharedStyle(){return(this.themeColor?`:host{--theme-color: ${this.themeColor};}`:"")+":host([hidden]){display:none!important}"}constructor(){var e,t;super(),this.shadowRootMode=tn,this.slottable=!0;const l=null===(t=null===(e=Object.getPrototypeOf(this))||void 0===e?void 0:e.constructor)||void 0===t?void 0:t.$name;l&&an.set(l,this.tagName.toLowerCase())}static get observedAttributes(){return["shadow-root-mode","slottable","theme-color"]}attributeChangedCallback(e,t,l){if(Object.is(l,t))return;const n=Ul(e);let a=l;switch(typeof this[n]){case"boolean":a=null!==l&&"false"!==l;break;case"number":a=Number(l)}switch(this[n]=a,e){case"theme-color":{const e=nn.get(this),t=this.$sharedStyle;e&&t&&(rn?e.replaceSync(t):e.textContent=t);break}}}$propertyChangedCallback(e,t,l){if(!Object.is(l,t))switch(e=Ol(e),typeof l){case"boolean":!0===l?this.hasAttribute(e)||this.setAttribute(e,""):this.removeAttribute(e);break;case"number":l=Tl(l)?"":String(l);default:l?this.getAttribute(e)!==l&&this.setAttribute(e,l):this.removeAttribute(e)}}connectedCallback(){Object.getPrototypeOf(this).constructor.observedAttributes.forEach(e=>{const t=Ul(e);let l=this[t];(function(e){return void 0===e})(l)||this.$propertyChangedCallback(t,void 0,l),Object.defineProperty(this,t,{enumerable:!0,configurable:!0,get:()=>l,set(e){const n=l;l=e,this.$propertyChangedCallback(t,n,e)}})});const e=this.shadowRoot||this.attachShadow({mode:this.shadowRootMode||tn});if(ln.set(this,e),nn.set(this,this.$addStyles(this.$sharedStyle)),this.$style&&this.$addStyles(this.$style),this.$template){const t=document.createElement("template");t.innerHTML=this.$template,e.appendChild(t.content)}if(this.slottable){const t=document.createElement("slot");e.appendChild(t)}}disconnectedCallback(){nn.has(this)&&nn.delete(this),ln.has(this)&&ln.delete(this)}$getTagNameOf(e){var t;return null!==(t=an.get(e))&&void 0!==t?t:e}$setStyles(e){return Object.keys(e).forEach(t=>{let l=e[t];Al(l)&&(l=0!==l&&en.test(t)?`${l}px`:String(l)),this.style[t]=l}),this}$getShadowRoot(){return this.shadowRoot||ln.get(this)}$addStyles(e){let t;const l=this.$getShadowRoot();return rn?(t=new CSSStyleSheet,t.replaceSync(e),l.adoptedStyleSheets=l.adoptedStyleSheets.concat(t)):(t=document.createElement("style"),t.textContent=e,l.appendChild(t)),t}$emit(e,t,l){return function(e,t,l,n){return e.dispatchEvent(new CustomEvent(t,Object.assign(Object.assign(Object.assign({},Hl),{detail:l}),n)))}(this,e,t,l)}$nextTick(e){return function(e,t){return t?Kl.then(e?t.bind(e):t):Kl}(this,e)}static $define(e,t){Ll(e)&&(t=e,e=""),e||(e=this.$name||this.name),e=Ol(e),Wt&&Vt.customElements&&!Vt.customElements.get(e)&&customElements.define(e,this,t)}}on.$version="2.1.1";class sn extends on{constructor(){super(...arguments),this.$onPointerDown=null,this.$onPointerMove=null,this.$onPointerUp=null,this.$onWheel=null,this.$wheeling=!1,this.$pointers=new Map,this.$style=':host{display:block;min-height:100px;min-width:200px;overflow:hidden;position:relative;touch-action:none;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}:host([background]){background-color:#fff;background-image:repeating-linear-gradient(45deg,#ccc 25%,transparent 0,transparent 75%,#ccc 0,#ccc),repeating-linear-gradient(45deg,#ccc 25%,transparent 0,transparent 75%,#ccc 0,#ccc);background-image:repeating-conic-gradient(#ccc 0 25%,#fff 0 50%);background-position:0 0,.5rem .5rem;background-size:1rem 1rem}:host([disabled]){pointer-events:none}:host([disabled]):after{bottom:0;content:"";cursor:not-allowed;display:block;left:0;pointer-events:none;position:absolute;right:0;top:0}',this.$action=sl,this.background=!1,this.disabled=!1,this.scaleStep=.1,this.themeColor="#39f"}static get observedAttributes(){return super.observedAttributes.concat(["background","disabled","scale-step"])}connectedCallback(){super.connectedCallback(),this.disabled||this.$bind()}disconnectedCallback(){this.disabled||this.$unbind(),super.disconnectedCallback()}$propertyChangedCallback(e,t,l){if(!Object.is(l,t)&&(super.$propertyChangedCallback(e,t,l),"disabled"===e))l?this.$unbind():this.$bind()}$bind(){this.$onPointerDown||(this.$onPointerDown=this.$handlePointerDown.bind(this),Wl(this,gl,this.$onPointerDown)),this.$onPointerMove||(this.$onPointerMove=this.$handlePointerMove.bind(this),Wl(this.ownerDocument,vl,this.$onPointerMove)),this.$onPointerUp||(this.$onPointerUp=this.$handlePointerUp.bind(this),Wl(this.ownerDocument,yl,this.$onPointerUp)),this.$onWheel||(this.$onWheel=this.$handleWheel.bind(this),Wl(this,Sl,this.$onWheel,{passive:!1,capture:!0}))}$unbind(){this.$onPointerDown&&(ql(this,gl,this.$onPointerDown),this.$onPointerDown=null),this.$onPointerMove&&(ql(this.ownerDocument,vl,this.$onPointerMove),this.$onPointerMove=null),this.$onPointerUp&&(ql(this.ownerDocument,yl,this.$onPointerUp),this.$onPointerUp=null),this.$onWheel&&(ql(this,Sl,this.$onWheel,{capture:!0}),this.$onWheel=null)}$handlePointerDown(e){const{buttons:t,button:l,type:n}=e;if(this.disabled||("pointerdown"===n&&"mouse"===e.pointerType||"mousedown"===n)&&(Al(t)&&1!==t||Al(l)&&0!==l||e.ctrlKey))return;const{$pointers:a}=this;let r="";if(e.changedTouches)Array.from(e.changedTouches).forEach(({identifier:e,pageX:t,pageY:l})=>{a.set(e,{startX:t,startY:l,endX:t,endY:l})});else{const{pointerId:t=0,pageX:l,pageY:n}=e;a.set(t,{startX:l,startY:n,endX:l,endY:n})}a.size>1?r=ol:Dl(e.target)&&(r=e.target.action||e.target.getAttribute("action")||""),!1!==this.$emit(El,{action:r,relatedEvent:e})&&(e.preventDefault(),this.$action=r,this.style.willChange="transform")}$handlePointerMove(e){const{$action:t,$pointers:l}=this;if(this.disabled||t===sl||0===l.size)return;if(!1===this.$emit("actionmove",{action:t,relatedEvent:e}))return;if(e.preventDefault(),e.changedTouches)Array.from(e.changedTouches).forEach(({identifier:e,pageX:t,pageY:n})=>{const a=l.get(e);a&&Object.assign(a,{endX:t,endY:n})});else{const{pointerId:t=0,pageX:n,pageY:a}=e,r=l.get(t);r&&Object.assign(r,{endX:n,endY:a})}const n={action:t,relatedEvent:e};if(t===ol){const t=new Map(l);let a=0,r=0,i=0,o=0,s=e.pageX,c=e.pageY;l.forEach((e,l)=>{t.delete(l),t.forEach(t=>{let l=t.startX-e.startX,n=t.startY-e.startY,u=t.endX-e.endX,d=t.endY-e.endY,b=0,m=0,h=0,p=0;if(0===l?n<0?h=2*Math.PI:n>0&&(h=Math.PI):l>0?h=Math.PI/2+Math.atan(n/l):l<0&&(h=1.5*Math.PI+Math.atan(n/l)),0===u?d<0?p=2*Math.PI:d>0&&(p=Math.PI):u>0?p=Math.PI/2+Math.atan(d/u):u<0&&(p=1.5*Math.PI+Math.atan(d/u)),p>0||h>0){const l=p-h,n=Math.abs(l);n>a&&(a=n,i=l,s=(e.startX+t.startX)/2,c=(e.startY+t.startY)/2)}if(l=Math.abs(l),n=Math.abs(n),u=Math.abs(u),d=Math.abs(d),l>0&&n>0?b=Math.sqrt(l*l+n*n):l>0?b=l:n>0&&(b=n),u>0&&d>0?m=Math.sqrt(u*u+d*d):u>0?m=u:d>0&&(m=d),b>0&&m>0){const l=(m-b)/b,n=Math.abs(l);n>r&&(r=n,o=l,s=(e.startX+t.startX)/2,c=(e.startY+t.startY)/2)}})});const u=a>0,d=r>0;u&&d?(n.rotate=i,n.scale=o,n.centerX=s,n.centerY=c):u?(n.action=il,n.rotate=i,n.centerX=s,n.centerY=c):d?(n.action=rl,n.scale=o,n.centerX=s,n.centerY=c):n.action=sl}else{const[e]=Array.from(l.values());Object.assign(n,e)}l.forEach(e=>{e.startX=e.endX,e.startY=e.endY}),n.action!==sl&&this.$emit(jl,n,{cancelable:!1})}$handlePointerUp(e){const{$action:t,$pointers:l}=this;if(!this.disabled&&t!==sl&&!1!==this.$emit(Nl,{action:t,relatedEvent:e})){if(e.preventDefault(),e.changedTouches)Array.from(e.changedTouches).forEach(({identifier:e})=>{l.delete(e)});else{const{pointerId:t=0}=e;l.delete(t)}0===l.size&&(this.style.willChange="",this.$action=sl)}}$handleWheel(e){if(this.disabled)return;if(e.preventDefault(),this.$wheeling)return;this.$wheeling=!0,setTimeout(()=>{this.$wheeling=!1},50);const t=(e.deltaY>0?-1:1)*this.scaleStep;this.$emit(jl,{action:rl,scale:t,relatedEvent:e},{cancelable:!1})}$setAction(e){return"string"==typeof e&&(this.$action=e),this}$toCanvas(e){return new Promise((t,l)=>{if(!this.isConnected)return void l(new Error("The current element is not connected to the DOM."));const n=document.createElement("canvas");let a=this.offsetWidth,r=this.offsetHeight,i=1;Il(e)&&(zl(e.width)||zl(e.height))&&(({width:a,height:r}=Jl({aspectRatio:a/r,width:e.width,height:e.height})),i=a/this.offsetWidth),n.width=a,n.height=r;const o=this.querySelector(this.$getTagNameOf(Zt));o?o.$ready().then(l=>{const s=n.getContext("2d");if(s){const[t,c,u,d,b,m]=o.$getTransform();let h=b,p=m,f=l.naturalWidth,g=l.naturalHeight;1!==i&&(h*=i,p*=i,f*=i,g*=i);const v=f/2,y=g/2;s.fillStyle="transparent",s.fillRect(0,0,a,r),Il(e)&&Pl(e.beforeDraw)&&e.beforeDraw.call(this,s,n),s.save(),s.translate(v,y),s.transform(t,c,u,d,h,p),s.translate(-v,-y),s.drawImage(l,0,0,f,g),s.restore()}t(n)}).catch(l):t(n)})}}sn.$name=Qt,sn.$version="2.1.1";const cn=new WeakMap,un=["alt","crossorigin","decoding","elementtiming","fetchpriority","loading","referrerpolicy","sizes","src","srcset"];class dn extends on{constructor(){super(...arguments),this.$isReady=!1,this.$matrix=[1,0,0,1,0,0],this.$onLoad=null,this.$onCanvasAction=null,this.$onCanvasActionEnd=null,this.$onCanvasActionStart=null,this.$actionStartTarget=null,this.$style=":host{display:inline-block}img{display:block;height:100%;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;width:100%}",this.$image=new Image,this.initialCenterSize="contain",this.rotatable=!1,this.scalable=!1,this.skewable=!1,this.slottable=!1,this.translatable=!1,this.alt="",this.crossorigin="",this.decoding="",this.elementtiming="",this.fetchpriority="",this.loading="",this.referrerpolicy="",this.sizes="",this.src="",this.srcset=""}set $canvas(e){cn.set(this,e)}get $canvas(){return cn.get(this)}static get observedAttributes(){return super.observedAttributes.concat(un,["initial-center-size","rotatable","scalable","skewable","translatable"])}attributeChangedCallback(e,t,l){Object.is(l,t)||(super.attributeChangedCallback(e,t,l),un.includes(e)&&this.$image.setAttribute(e,l))}$propertyChangedCallback(e,t,l){if(!Object.is(l,t))switch(super.$propertyChangedCallback(e,t,l),e){case"initialCenterSize":this.$nextTick(()=>{this.$center(l)});break;case"src":this.$isReady=!1}}connectedCallback(){super.connectedCallback();const{$image:e}=this,t=this.closest(this.$getTagNameOf(Qt));t&&(this.$canvas=t,this.$setStyles({display:"block",position:"absolute"}),this.$onCanvasActionStart=e=>{var t,l;this.$actionStartTarget=null===(l=null===(t=e.detail)||void 0===t?void 0:t.relatedEvent)||void 0===l?void 0:l.target},this.$onCanvasActionEnd=()=>{this.$actionStartTarget=null},this.$onCanvasAction=this.$handleAction.bind(this),Wl(t,El,this.$onCanvasActionStart),Wl(t,Nl,this.$onCanvasActionEnd),Wl(t,jl,this.$onCanvasAction)),this.$onLoad=this.$handleLoad.bind(this),Wl(e,kl,this.$onLoad),this.$getShadowRoot().appendChild(e)}disconnectedCallback(){const{$image:e,$canvas:t}=this;t&&(this.$onCanvasActionStart&&(ql(t,El,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(ql(t,Nl,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(ql(t,jl,this.$onCanvasAction),this.$onCanvasAction=null)),e&&this.$onLoad&&(ql(e,kl,this.$onLoad),this.$onLoad=null),this.$getShadowRoot().removeChild(e),super.disconnectedCallback()}$handleLoad(){const{$image:e}=this;this.$setStyles({width:e.naturalWidth,height:e.naturalHeight}),this.$canvas&&this.$center(this.initialCenterSize),this.$isReady=!0}$handleAction(e){if(this.hidden||!(this.rotatable||this.scalable||this.translatable))return;const{$canvas:t}=this,{detail:l}=e;if(l){const{relatedEvent:e}=l;let{action:n}=l;switch(n!==ol||this.rotatable&&this.scalable||(n=this.rotatable?il:this.scalable?rl:sl),n){case al:if(this.translatable){let n=null;e&&(n=e.target.closest(this.$getTagNameOf(el))),n||(n=t.querySelector(this.$getTagNameOf(el))),n&&n.multiple&&!n.active&&(n=t.querySelector(`${this.$getTagNameOf(el)}[active]`)),n&&!n.hidden&&n.movable&&!n.dynamic&&this.$actionStartTarget&&n.contains(this.$actionStartTarget)||this.$move(l.endX-l.startX,l.endY-l.startY)}break;case il:if(this.rotatable)if(e){const{x:t,y:n}=this.getBoundingClientRect();this.$rotate(l.rotate,e.clientX-t,e.clientY-n)}else this.$rotate(l.rotate);break;case rl:if(this.scalable)if(e){const t=e.target.closest(this.$getTagNameOf(el));if(!t||!t.zoomable||t.zoomable&&t.dynamic){const{x:t,y:n}=this.getBoundingClientRect();this.$zoom(l.scale,e.clientX-t,e.clientY-n)}}else this.$zoom(l.scale);break;case ol:if(this.rotatable&&this.scalable){const{rotate:t}=l;let{scale:n}=l;n<0?n=1/(1-n):n+=1;const a=Math.cos(t),r=Math.sin(t),[i,o,s,c]=[a*n,r*n,-r*n,a*n];if(e){const t=this.getBoundingClientRect(),l=e.clientX-t.x,n=e.clientY-t.y,[a,r,u,d]=this.$matrix,b=l-t.width/2,m=n-t.height/2,h=(b*d-u*m)/(a*d-u*r),p=(m*a-r*b)/(a*d-u*r);this.$transform(i,o,s,c,h*(1-i)+p*s,p*(1-c)+h*o)}else this.$transform(i,o,s,c,0,0)}}}}$ready(e){const{$image:t}=this,l=new Promise((e,l)=>{const n=new Error("Failed to load the image source");if(t.complete)t.naturalWidth>0&&t.naturalHeight>0?e(t):l(n);else{const a=()=>{ql(t,xl,r),setTimeout(()=>{e(t)})},r=()=>{ql(t,kl,a),l(n)};Vl(t,kl,a),Vl(t,xl,r)}});return Pl(e)&&l.then(t=>(e(t),t)),l}$center(e){const{parentElement:t}=this;if(!t)return this;const l=t.getBoundingClientRect(),n=l.width,a=l.height,{x:r,y:i,width:o,height:s}=this.getBoundingClientRect(),c=r+o/2,u=i+s/2,d=l.x+n/2,b=l.y+a/2,{translatable:m}=this;if(m||this.$isReady||(this.translatable=!0,this.$nextTick(()=>{this.translatable=m})),this.$move(d-c,b-u),e&&(o!==n||s!==a)){const t=n/o,l=a/s,{scalable:r}=this;switch(!e||r||this.$isReady||(this.scalable=!0,this.$nextTick(()=>{this.scalable=r})),e){case"cover":this.$scale(Math.max(t,l));break;case"contain":this.$scale(Math.min(t,l))}}return this}$move(e,t=e){if(this.translatable&&Al(e)&&Al(t)){const[l,n,a,r]=this.$matrix,i=(e*r-a*t)/(l*r-a*n),o=(t*l-n*e)/(l*r-a*n);this.$translate(i,o)}return this}$moveTo(e,t=e){if(this.translatable&&Al(e)&&Al(t)){const[l,n,a,r]=this.$matrix,i=(e*r-a*t)/(l*r-a*n),o=(t*l-n*e)/(l*r-a*n);this.$setTransform(l,n,a,r,i,o)}return this}$rotate(e,t,l){if(this.rotatable){const n=Xl(e),a=Math.cos(n),r=Math.sin(n),[i,o,s,c]=[a,r,-r,a];if(Al(t)&&Al(l)){const[e,n,a,r]=this.$matrix,{width:u,height:d}=this.getBoundingClientRect(),b=t-u/2,m=l-d/2,h=(b*r-a*m)/(e*r-a*n),p=(m*e-n*b)/(e*r-a*n);this.$transform(i,o,s,c,h*(1-i)-p*s,p*(1-c)-h*o)}else this.$transform(i,o,s,c,0,0)}return this}$zoom(e,t,l){if(!this.scalable||0===e)return this;if(e<0?e=1/(1-e):e+=1,Al(t)&&Al(l)){const[n,a,r,i]=this.$matrix,{width:o,height:s}=this.getBoundingClientRect(),c=t-o/2,u=l-s/2,d=(c*i-r*u)/(n*i-r*a),b=(u*n-a*c)/(n*i-r*a);this.$transform(e,0,0,e,d*(1-e),b*(1-e))}else this.$scale(e);return this}$scale(e,t=e){return this.scalable&&this.$transform(e,0,0,t,0,0),this}$skew(e,t=0){if(this.skewable){const l=Xl(e),n=Xl(t);this.$transform(1,Math.tan(n),Math.tan(l),1,0,0)}return this}$translate(e,t=e){return this.translatable&&Al(e)&&Al(t)&&this.$transform(1,0,0,1,e,t),this}$transform(e,t,l,n,a,r){return Al(e)&&Al(t)&&Al(l)&&Al(n)&&Al(a)&&Al(r)?this.$setTransform(Zl(this.$matrix,[e,t,l,n,a,r])):this}$setTransform(e,t,l,n,a,r){if((this.rotatable||this.scalable||this.skewable||this.translatable)&&(Array.isArray(e)&&([e,t,l,n,a,r]=e),Al(e)&&Al(t)&&Al(l)&&Al(n)&&Al(a)&&Al(r))){const i=[...this.$matrix],o=[e,t,l,n,a,r];if(!1===this.$emit(_l,{matrix:o,oldMatrix:i}))return this;this.$matrix=o,this.style.transform=`matrix(${o.join(", ")})`}return this}$getTransform(){return this.$matrix.slice()}$resetTransform(){return this.$setTransform([1,0,0,1,0,0])}}dn.$name=Zt,dn.$version="2.1.1";const bn=new WeakMap;class mn extends on{constructor(){super(...arguments),this.$onWindowResize=null,this.$onCanvasActionEnd=null,this.$onCanvasActionStart=null,this.$onSelectionChange=null,this.$style=":host{display:block;height:0;left:0;outline:var(--theme-color) solid 1px;position:relative;top:0;width:0}:host([transparent]){outline-color:transparent}",this.x=0,this.y=0,this.width=0,this.height=0,this.slottable=!1,this.themeColor="rgba(0, 0, 0, 0.65)"}set $canvas(e){bn.set(this,e)}get $canvas(){return bn.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["height","width","x","y"])}connectedCallback(){super.connectedCallback();const e=this.closest(this.$getTagNameOf(Qt));if(e){this.$canvas=e,this.style.position="absolute";const t=e.querySelector(this.$getTagNameOf(el));t&&(this.$onWindowResize=this.$render.bind(this),this.$onCanvasActionStart=e=>{t.hidden&&e.detail.action===nl&&(this.hidden=!1)},this.$onCanvasActionEnd=e=>{t.hidden&&e.detail.action===nl&&(this.hidden=!0)},this.$onSelectionChange=e=>{const{x:l,y:n,width:a,height:r}=e.defaultPrevented?t:e.detail;this.$change(l,n,a,r),(t.hidden||0===l&&0===n&&0===a&&0===r)&&(this.hidden=!0)},Wl(window,Cl,this.$onWindowResize),Wl(e,El,this.$onCanvasActionStart),Wl(e,Nl,this.$onCanvasActionEnd),Wl(e,$l,this.$onSelectionChange))}this.$render()}disconnectedCallback(){const{$canvas:e}=this;e&&(this.$onWindowResize&&(ql(window,Cl,this.$onWindowResize),this.$onWindowResize=null),this.$onCanvasActionStart&&(ql(e,El,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(ql(e,Nl,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onSelectionChange&&(ql(e,$l,this.$onSelectionChange),this.$onSelectionChange=null)),super.disconnectedCallback()}$change(e,t,l=this.width,n=this.height){return Al(e)&&Al(t)&&Al(l)&&Al(n)&&(e!==this.x||t!==this.y||l!==this.width||n!==this.height)?(this.hidden&&(this.hidden=!1),this.x=e,this.y=t,this.width=l,this.height=n,this.$render()):this}$reset(){return this.$change(0,0,0,0)}$render(){return this.$setStyles({transform:`translate(${this.x}px, ${this.y}px)`,width:this.width,height:this.height,outlineWidth:Vt.innerWidth*Vt.devicePixelRatio})}}mn.$name=tl,mn.$version="2.1.1";class hn extends on{constructor(){super(...arguments),this.$onCanvasCropEnd=null,this.$onCanvasCropStart=null,this.$style=':host{background-color:var(--theme-color);display:block}:host([action=move]),:host([action=select]){height:100%;left:0;position:absolute;top:0;width:100%}:host([action=move]){cursor:move}:host([action=select]){cursor:crosshair}:host([action$=-resize]){background-color:transparent;height:15px;position:absolute;width:15px}:host([action$=-resize]):after{background-color:var(--theme-color);content:"";display:block;height:5px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:5px}:host([action=n-resize]),:host([action=s-resize]){cursor:ns-resize;left:50%;transform:translateX(-50%);width:100%}:host([action=n-resize]){top:-8px}:host([action=s-resize]){bottom:-8px}:host([action=e-resize]),:host([action=w-resize]){cursor:ew-resize;height:100%;top:50%;transform:translateY(-50%)}:host([action=e-resize]){right:-8px}:host([action=w-resize]){left:-8px}:host([action=ne-resize]){cursor:nesw-resize;right:-8px;top:-8px}:host([action=nw-resize]){cursor:nwse-resize;left:-8px;top:-8px}:host([action=se-resize]){bottom:-8px;cursor:nwse-resize;right:-8px}:host([action=se-resize]):after{height:15px;width:15px}@media (pointer:coarse){:host([action=se-resize]):after{height:10px;width:10px}}@media (pointer:fine){:host([action=se-resize]):after{height:5px;width:5px}}:host([action=sw-resize]){bottom:-8px;cursor:nesw-resize;left:-8px}:host([plain]){background-color:transparent}',this.action=sl,this.plain=!1,this.slottable=!1,this.themeColor="rgba(51, 153, 255, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["action","plain"])}}hn.$name=Jt,hn.$version="2.1.1";const pn=new WeakMap;class fn extends on{constructor(){super(...arguments),this.$onCanvasAction=null,this.$onCanvasActionStart=null,this.$onCanvasActionEnd=null,this.$onDocumentKeyDown=null,this.$action="",this.$actionStartTarget=null,this.$changing=!1,this.$style=':host{display:block;left:0;position:relative;right:0}:host([outlined]){outline:1px solid var(--theme-color)}:host([multiple]){outline:1px dashed hsla(0,0%,100%,.5)}:host([multiple]):after{bottom:0;content:"";cursor:pointer;display:block;left:0;position:absolute;right:0;top:0}:host([multiple][active]){outline-color:var(--theme-color);z-index:1}:host([multiple])>*{visibility:hidden}:host([multiple][active])>*{visibility:visible}:host([multiple][active]):after{display:none}',this.$initialSelection={x:0,y:0,width:0,height:0},this.x=0,this.y=0,this.width=0,this.height=0,this.aspectRatio=NaN,this.initialAspectRatio=NaN,this.initialCoverage=NaN,this.active=!1,this.linked=!1,this.dynamic=!1,this.movable=!1,this.resizable=!1,this.zoomable=!1,this.multiple=!1,this.keyboard=!1,this.outlined=!1,this.precise=!1}set $canvas(e){pn.set(this,e)}get $canvas(){return pn.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["active","aspect-ratio","dynamic","height","initial-aspect-ratio","initial-coverage","keyboard","linked","movable","multiple","outlined","precise","resizable","width","x","y","zoomable"])}$propertyChangedCallback(e,t,l){if(!Object.is(l,t))switch(super.$propertyChangedCallback(e,t,l),e){case"x":case"y":case"width":case"height":this.$changing||this.$nextTick(()=>{this.$change(this.x,this.y,this.width,this.height,this.aspectRatio,!0)});break;case"aspectRatio":case"initialAspectRatio":this.$nextTick(()=>{this.$initSelection()});break;case"initialCoverage":this.$nextTick(()=>{zl(l)&&l<=1&&this.$initSelection(!0,!0)});break;case"keyboard":this.$nextTick(()=>{this.$canvas&&(l?this.$onDocumentKeyDown||(this.$onDocumentKeyDown=this.$handleKeyDown.bind(this),Wl(this.ownerDocument,wl,this.$onDocumentKeyDown)):this.$onDocumentKeyDown&&(ql(this.ownerDocument,wl,this.$onDocumentKeyDown),this.$onDocumentKeyDown=null))});break;case"multiple":this.$nextTick(()=>{if(this.$canvas){const e=this.$getSelections();l?(e.forEach(e=>{e.active=!1}),this.active=!0,this.$emit($l,{x:this.x,y:this.y,width:this.width,height:this.height})):(this.active=!1,e.slice(1).forEach(e=>{this.$removeSelection(e)}))}});break;case"precise":this.$nextTick(()=>{this.$change(this.x,this.y)});break;case"linked":l&&(this.dynamic=!0)}}connectedCallback(){super.connectedCallback();const e=this.closest(this.$getTagNameOf(Qt));e?(this.$canvas=e,this.$setStyles({position:"absolute",transform:`translate(${this.x}px, ${this.y}px)`}),this.hidden||this.$render(),this.$initSelection(!0),this.$onCanvasActionStart=this.$handleActionStart.bind(this),this.$onCanvasActionEnd=this.$handleActionEnd.bind(this),this.$onCanvasAction=this.$handleAction.bind(this),Wl(e,El,this.$onCanvasActionStart),Wl(e,Nl,this.$onCanvasActionEnd),Wl(e,jl,this.$onCanvasAction)):this.$render()}disconnectedCallback(){const{$canvas:e}=this;e&&(this.$onCanvasActionStart&&(ql(e,El,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(ql(e,Nl,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(ql(e,jl,this.$onCanvasAction),this.$onCanvasAction=null)),super.disconnectedCallback()}$getSelections(){let e=[];return this.parentElement&&(e=Array.from(this.parentElement.querySelectorAll(this.$getTagNameOf(el)))),e}$initSelection(e=!1,t=!1){const{initialCoverage:l,parentElement:n}=this;if(zl(l)&&n){const a=this.aspectRatio||this.initialAspectRatio;let r=(t?0:this.width)||n.offsetWidth*l,i=(t?0:this.height)||n.offsetHeight*l;zl(a)&&({width:r,height:i}=Jl({aspectRatio:a,width:r,height:i})),this.$change(this.x,this.y,r,i),e&&this.$center(),this.$initialSelection={x:this.x,y:this.y,width:this.width,height:this.height}}}$createSelection(){const e=this.cloneNode(!0);return this.hasAttribute("id")&&e.removeAttribute("id"),e.initialCoverage=NaN,this.active=!1,this.parentElement&&this.parentElement.insertBefore(e,this.nextSibling),e}$removeSelection(e=this){if(this.parentElement){const t=this.$getSelections();if(t.length>1){const l=t.indexOf(e),n=t[l+1]||t[l-1];n&&(e.active=!1,this.parentElement.removeChild(e),n.active=!0,n.$emit($l,{x:n.x,y:n.y,width:n.width,height:n.height}))}else this.$clear()}}$handleActionStart(e){var t,l;const n=null===(l=null===(t=e.detail)||void 0===t?void 0:t.relatedEvent)||void 0===l?void 0:l.target;this.$action="",this.$actionStartTarget=n,!this.hidden&&this.multiple&&!this.active&&n===this&&this.parentElement&&(this.$getSelections().forEach(e=>{e.active=!1}),this.active=!0,this.$emit($l,{x:this.x,y:this.y,width:this.width,height:this.height}))}$handleAction(e){const{currentTarget:t,detail:l}=e;if(!t||!l)return;const{relatedEvent:n}=l;let{action:a}=l;const r=n?function(e){if("function"==typeof e.composedPath)return e.composedPath().find(Dl)||e.target;return e.target}(n):null;if(!a&&this.multiple&&(a=this.$action||(null==r?void 0:r.action),this.$action=a),!a||this.hidden&&a!==nl||this.multiple&&!this.active&&a!==rl)return;const{width:i,height:o}=this;let s=l.endX-l.startX,c=l.endY-l.startY,{aspectRatio:u}=this;switch(!zl(u)&&n.shiftKey&&(u=zl(i)&&zl(o)?i/o:1),a){case nl:if(0!==s||0!==c){0===s?s=c:0===c&&(c=s);const{$canvas:e}=this,n=Gl(t);(this.multiple&&!this.hidden?this.$createSelection():this).$change(l.startX-n.left,l.startY-n.top,Math.abs(s),Math.abs(c),u),s<0?c<0?a=hl:c>0&&(a=fl):s>0&&(c<0?a=ml:c>0&&(a=pl)),e&&(e.$action=a)}break;case al:this.movable&&(this.dynamic||this.$actionStartTarget&&this.contains(this.$actionStartTarget))&&this.$move(s,c);break;case rl:if(n&&this.zoomable&&(this.dynamic||this.contains(n.target))){const e=Gl(t);this.$zoom(l.scale,n.pageX-e.left,n.pageY-e.top)}break;default:this.$resize(a,s,c,u)}}$handleActionEnd(){this.$action="",this.$actionStartTarget=null}$handleKeyDown(e){if(this.hidden||!this.keyboard||this.multiple&&!this.active||e.defaultPrevented)return;const{activeElement:t}=document;if(!t||!["INPUT","TEXTAREA"].includes(t.tagName)&&!["true","plaintext-only"].includes(t.contentEditable))switch(e.key){case"Backspace":e.metaKey&&(e.preventDefault(),this.$removeSelection());break;case"Delete":e.preventDefault(),this.$removeSelection();break;case"ArrowLeft":e.preventDefault(),this.$move(-1,0);break;case"ArrowRight":e.preventDefault(),this.$move(1,0);break;case"ArrowUp":e.preventDefault(),this.$move(0,-1);break;case"ArrowDown":e.preventDefault(),this.$move(0,1);break;case"+":e.preventDefault(),this.$zoom(.1);break;case"-":e.preventDefault(),this.$zoom(-.1)}}$center(){const{parentElement:e}=this;if(!e)return this;const t=(e.offsetWidth-this.width)/2,l=(e.offsetHeight-this.height)/2;return this.$change(t,l)}$move(e,t=e){return this.$moveTo(this.x+e,this.y+t)}$moveTo(e,t=e){return this.movable?this.$change(e,t):this}$resize(e,t=0,l=0,n=this.aspectRatio){if(!this.resizable)return this;const a=zl(n),{$canvas:r}=this;let{x:i,y:o,width:s,height:c}=this;switch(e){case cl:o+=l,c-=l,c<0&&(e=dl,c=-c,o-=c),a&&(i+=(t=l*n)/2,s-=t,s<0&&(s=-s,i-=s));break;case ul:s+=t,s<0&&(e=bl,s=-s,i-=s),a&&(o-=(l=t/n)/2,c+=l,c<0&&(c=-c,o-=c));break;case dl:c+=l,c<0&&(e=cl,c=-c,o-=c),a&&(i-=(t=l*n)/2,s+=t,s<0&&(s=-s,i-=s));break;case bl:i+=t,s-=t,s<0&&(e=ul,s=-s,i-=s),a&&(o+=(l=t/n)/2,c-=l,c<0&&(c=-c,o-=c));break;case ml:a&&(l=-t/n),o+=l,c-=l,s+=t,s<0&&c<0?(e=fl,s=-s,c=-c,i-=s,o-=c):s<0?(e=hl,s=-s,i-=s):c<0&&(e=pl,c=-c,o-=c);break;case hl:a&&(l=t/n),i+=t,o+=l,s-=t,c-=l,s<0&&c<0?(e=pl,s=-s,c=-c,i-=s,o-=c):s<0?(e=ml,s=-s,i-=s):c<0&&(e=fl,c=-c,o-=c);break;case pl:a&&(l=t/n),s+=t,c+=l,s<0&&c<0?(e=hl,s=-s,c=-c,i-=s,o-=c):s<0?(e=fl,s=-s,i-=s):c<0&&(e=ml,c=-c,o-=c);break;case fl:a&&(l=-t/n),i+=t,s-=t,c+=l,s<0&&c<0?(e=ml,s=-s,c=-c,i-=s,o-=c):s<0?(e=pl,s=-s,i-=s):c<0&&(e=hl,c=-c,o-=c)}return r&&r.$setAction(e),this.$change(i,o,s,c)}$zoom(e,t,l){if(!this.zoomable||0===e)return this;e<0?e=1/(1-e):e+=1;const{width:n,height:a}=this,r=n*e,i=a*e;let o=this.x,s=this.y;return Al(t)&&Al(l)?(o-=(r-n)*((t-this.x)/n),s-=(i-a)*((l-this.y)/a)):(o-=(r-n)/2,s-=(i-a)/2),this.$change(o,s,r,i)}$change(e,t,l=this.width,n=this.height,a=this.aspectRatio,r=!1){return this.$changing||!Al(e)||!Al(t)||!Al(l)||!Al(n)||l<0||n<0?this:(zl(a)&&({width:l,height:n}=Jl({aspectRatio:a,width:l,height:n},"cover")),this.precise||(e=Math.round(e),t=Math.round(t),l=Math.round(l),n=Math.round(n)),e===this.x&&t===this.y&&l===this.width&&n===this.height&&Object.is(a,this.aspectRatio)&&!r?this:(this.hidden&&(this.hidden=!1),!1===this.$emit($l,{x:e,y:t,width:l,height:n})?this:(this.$changing=!0,this.x=e,this.y=t,this.width=l,this.height=n,this.$changing=!1,this.$render())))}$reset(){const{x:e,y:t,width:l,height:n}=this.$initialSelection;return this.$change(e,t,l,n)}$clear(){return this.$change(0,0,0,0,NaN,!0),this.hidden=!0,this}$render(){return this.$setStyles({transform:`translate(${this.x}px, ${this.y}px)`,width:this.width,height:this.height})}$toCanvas(e){return new Promise((t,l)=>{if(!this.isConnected)return void l(new Error("The current element is not connected to the DOM."));const n=document.createElement("canvas");let{width:a,height:r}=this,i=1;if(Il(e)&&(zl(e.width)||zl(e.height))&&(({width:a,height:r}=Jl({aspectRatio:a/r,width:e.width,height:e.height})),i=a/this.width),n.width=a,n.height=r,!this.$canvas)return void t(n);const o=this.$canvas.querySelector(this.$getTagNameOf(Zt));o?o.$ready().then(l=>{const s=n.getContext("2d");if(s){const[t,c,u,d,b,m]=o.$getTransform(),h=-this.x,p=-this.y,f=(h*d-u*p)/(t*d-u*c),g=(p*t-c*h)/(t*d-u*c);let v=t*f+u*g+b,y=c*f+d*g+m,x=l.naturalWidth,w=l.naturalHeight;1!==i&&(v*=i,y*=i,x*=i,w*=i);const k=x/2,C=w/2;s.fillStyle="transparent",s.fillRect(0,0,a,r),Il(e)&&Pl(e.beforeDraw)&&e.beforeDraw.call(this,s,n),s.save(),s.translate(k,C),s.transform(t,c,u,d,v,y),s.translate(-k,-C),s.drawImage(l,0,0,x,w),s.restore()}t(n)}).catch(l):t(n)})}}fn.$name=el,fn.$version="2.1.1";class gn extends on{constructor(){super(...arguments),this.$style=":host{display:flex;flex-direction:column;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}:host([bordered]){border:1px dashed var(--theme-color)}:host([covered]){bottom:0;left:0;position:absolute;right:0;top:0}:host>span{display:flex;flex:1}:host>span+span{border-top:1px dashed var(--theme-color)}:host>span>span{flex:1}:host>span>span+span{border-left:1px dashed var(--theme-color)}",this.bordered=!1,this.columns=3,this.covered=!1,this.rows=3,this.slottable=!1,this.themeColor="rgba(238, 238, 238, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["bordered","columns","covered","rows"])}$propertyChangedCallback(e,t,l){Object.is(l,t)||(super.$propertyChangedCallback(e,t,l),"rows"!==e&&"columns"!==e||this.$nextTick(()=>{this.$render()}))}connectedCallback(){super.connectedCallback(),this.$render()}$render(){const e=this.$getShadowRoot(),t=document.createDocumentFragment();for(let l=0;l<this.rows;l+=1){const e=document.createElement("span");e.setAttribute("role","row");for(let t=0;t<this.columns;t+=1){const t=document.createElement("span");t.setAttribute("role","gridcell"),e.appendChild(t)}t.appendChild(e)}e&&(e.innerHTML="",e.appendChild(t))}}gn.$name=Yt,gn.$version="2.1.1";class vn extends on{constructor(){super(...arguments),this.$style=':host{display:inline-block;height:1em;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;vertical-align:middle;width:1em}:host:after,:host:before{background-color:var(--theme-color);content:"";display:block;position:absolute}:host:before{height:1px;left:0;top:50%;transform:translateY(-50%);width:100%}:host:after{height:100%;left:50%;top:0;transform:translateX(-50%);width:1px}:host([centered]){left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}',this.centered=!1,this.slottable=!1,this.themeColor="rgba(238, 238, 238, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["centered"])}}vn.$name=Xt,vn.$version="2.1.1";const yn=new WeakMap,xn=new WeakMap,wn=new WeakMap,kn=new WeakMap,Cn="vertical";class Sn extends on{constructor(){super(...arguments),this.$onSelectionChange=null,this.$onSourceImageLoad=null,this.$onSourceImageTransform=null,this.$scale=1,this.$style=":host{display:block;height:100%;overflow:hidden;position:relative;width:100%}",this.resize=Cn,this.selection="",this.slottable=!1}set $image(e){xn.set(this,e)}get $image(){return xn.get(this)}set $sourceImage(e){kn.set(this,e)}get $sourceImage(){return kn.get(this)}set $canvas(e){yn.set(this,e)}get $canvas(){return yn.get(this)}set $selection(e){wn.set(this,e)}get $selection(){return wn.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["resize","selection"])}connectedCallback(){var e,t;super.connectedCallback();let l=null;if(l=this.selection?null!==(t=null===(e=function(e){const t=e.getRootNode();switch(t.nodeType){case 1:return t.ownerDocument;case 9:case 11:return t}return null}(this))||void 0===e?void 0:e.querySelector(this.selection))&&void 0!==t?t:null:this.closest(this.$getTagNameOf(el)),Dl(l)){this.$selection=l,this.$onSelectionChange=this.$handleSelectionChange.bind(this),Wl(l,$l,this.$onSelectionChange);const e=l.closest(this.$getTagNameOf(Qt));if(e){this.$canvas=e;const t=e.querySelector(this.$getTagNameOf(Zt));t&&(this.$sourceImage=t,this.$image=t.cloneNode(!0),this.$getShadowRoot().appendChild(this.$image),this.$onSourceImageLoad=this.$handleSourceImageLoad.bind(this),this.$onSourceImageTransform=this.$handleSourceImageTransform.bind(this),Wl(t.$image,kl,this.$onSourceImageLoad),Wl(t,_l,this.$onSourceImageTransform))}this.$render()}}disconnectedCallback(){const{$selection:e,$sourceImage:t}=this;e&&this.$onSelectionChange&&(ql(e,$l,this.$onSelectionChange),this.$onSelectionChange=null),t&&this.$onSourceImageLoad&&(ql(t.$image,kl,this.$onSourceImageLoad),this.$onSourceImageLoad=null),t&&this.$onSourceImageTransform&&(ql(t,_l,this.$onSourceImageTransform),this.$onSourceImageTransform=null),super.disconnectedCallback()}$handleSelectionChange(e){this.$render(e.defaultPrevented?this.$selection:e.detail)}$handleSourceImageLoad(){const{$image:e,$sourceImage:t}=this,l=e.getAttribute("src"),n=t.getAttribute("src");n&&n!==l&&(e.setAttribute("src",n),e.$ready(()=>{this.$render()}))}$handleSourceImageTransform(e){this.$render(void 0,e.detail.matrix)}$render(e,t){const{$canvas:l,$selection:n}=this;e||n.hidden||(e=n),(!e||0===e.x&&0===e.y&&0===e.width&&0===e.height)&&(e={x:0,y:0,width:l.offsetWidth,height:l.offsetHeight});const{x:a,y:r,width:i,height:o}=e,s={},{clientWidth:c,clientHeight:u}=this;let d=c,b=u,m=NaN;switch(this.resize){case"both":m=1,d=i,b=o,s.width=i,s.height=o;break;case"horizontal":m=o>0?u/o:0,d=i*m,s.width=d;break;case Cn:m=i>0?c/i:0,b=o*m,s.height=b;break;default:c>0?m=i>0?c/i:0:u>0&&(m=o>0?u/o:0)}this.$scale=m,this.$setStyles(s),this.$sourceImage&&setTimeout(()=>{this.$transformImageByOffset(null!=t?t:this.$sourceImage.$getTransform(),-a,-r)})}$transformImageByOffset(e,t,l){const{$image:n,$scale:a,$sourceImage:r}=this;if(r&&n&&a>=0){const[i,o,s,c,u,d]=e,b=(t*c-s*l)/(i*c-s*o),m=(l*i-o*t)/(i*c-s*o),h=i*b+s*m+u,p=o*b+c*m+d;r.$ready(e=>{this.$setStyles.call(n,{width:e.naturalWidth*a,height:e.naturalHeight*a})}),n.$setTransform(i,o,s,c,h*a,p*a)}}}function jn(){const[t,l]=e.useState(!1),[n,a]=e.useState(null),[r,i]=e.useState(null),o=async(e,t)=>{if(!e||!t)return a("ID de asset y configuración de variante son requeridos"),null;l(!0),a(null),i(null);try{const l=await async function(e,{variant_name:t,width:l,height:a,crop_params:r,preset_aspect:i=null,preset_size:o=null,output_format:s="webp"}){try{const n=[{name:t,width:l,height:a,output_format:s,crop_params:r}];return i&&(n[0].preset_aspect=i),o&&(n[0].preset_size=o),X(await W({endpoint:`/assets/${e}/variants`,method:"POST",body:{variants:n,async:!1},basePath:J,useJWT:!0}))}catch(n){throw Y(n)}}(e,{variant_name:t.name,width:t.width,height:t.height,crop_params:t.crop_params,preset_aspect:t.preset_aspect,preset_size:t.preset_size,output_format:t.output_format});if(l?.result)return i(l.result),l.result;throw new Error("No se pudo crear la variante")}catch(r){return console.error("Error creating variant:",r),a(r.message||"Error desconocido al crear variante"),null}finally{l(!1)}};return{createVariant:o,createCropVariant:async(e,t,l={})=>{const n={name:l.name||`crop_${Date.now()}`,width:l.width||800,height:l.height||600,output_format:l.format||"webp",crop_params:{x:t.x||0,y:t.y||0,width:t.width||1,height:t.height||1}};return await o(e,n)},createVariantFromBlob:async(e,t,r={})=>{if(!e||!t)return a("ID de asset y blob son requeridos"),null;l(!0),a(null),i(null);try{const l=await async function(e,t,l={}){try{const n=new FormData,a=l.format||"webp",r=`${l.name||"variant"}.${a}`;return n.append("file",t,r),n.append("variant_name",l.name||"variant"),n.append("width",String(l.width||0)),n.append("height",String(l.height||0)),n.append("output_format",l.format||"webp"),n.append("permanent_url",!1!==l.permanentUrl?"true":"false"),X(await W({endpoint:`/assets/${e}/variants/upload`,method:"POST",body:n,basePath:J,isFormData:!0,useJWT:!0}))}catch(n){throw Y(n)}}(e,t,{name:r.name||`crop_${Date.now()}`,width:r.width||0,height:r.height||0,format:r.format||"webp"});if(l?.result)return i(l.result),l.result;throw new Error("No se pudo crear la variante")}catch(o){return console.error("Error creating variant from blob:",o),a(o.message||"Error desconocido al crear variante"),null}finally{l(!1)}},loading:t,error:n,createdVariant:r,reset:()=>{a(null),i(null)}}}Sn.$name=ll,Sn.$version="2.1.1",sn.$define(),vn.$define(),gn.$define(),hn.$define(),dn.$define(),fn.$define(),mn.$define(),Sn.$define();class Nn{constructor(e,t,l){this.canvasRef=e,this.imageRef=t,this.selectionRef=l}get canvasElement(){return this.canvasRef?.current}get image(){return this.imageRef?.current}get selectionElement(){return this.selectionRef?.current}get isReady(){return!!(this.canvasElement&&this.image&&this.selectionElement)}transform={move:(e,t)=>{if(!this.image)return!1;try{return this.image.$move(e,t),!0}catch(l){return console.warn("Error moving image:",l),!1}},moveTo:(e,t)=>{if(!this.image)return!1;try{return this.image.$moveTo(e,t),!0}catch(l){return console.warn("Error moving image to position:",l),!1}},zoom:e=>{if(!this.image)return!1;try{return this.image.$zoom(e),!0}catch(t){return console.warn("Error zooming image:",t),!1}},rotate:e=>{if(!this.image)return!1;try{const t=e*Math.PI/180;return this.image.$rotate(t),!0}catch(t){return console.warn("Error rotating image:",t),!1}},scale:(e,t=e)=>{if(!this.image)return!1;try{return this.image.$scale(e,t),!0}catch(l){return console.warn("Error scaling image:",l),!1}},center:(e="contain")=>{if(!this.image)return!1;try{return this.image.$center(e),!0}catch(t){return console.warn("Error centering image:",t),!1}},reset:()=>{if(!this.image)return!1;try{return this.image.$resetTransform(),!0}catch(e){return console.warn("Error resetting transform:",e),!1}},getTransform:()=>{if(!this.image)return null;try{return this.image.$getTransform()}catch(e){return console.warn("Error getting transform:",e),null}},setTransform:(e,t,l,n,a,r)=>{if(!this.image)return!1;try{return this.image.$setTransform(e,t,l,n,a,r),!0}catch(i){return console.warn("Error setting transform:",i),!1}},resetZoom:()=>{if(!this.image)return!1;try{const e=this.image.$getTransform();if(!e)return!1;const[t,l,n,a,r,i]=e,o=Math.sqrt(t*t+l*l),s=Math.sqrt(n*n+a*a),c=t/o,u=l/o,d=n/s,b=a/s;return this.image.$setTransform(c,u,d,b,r,i),!0}catch(e){return console.warn("Error resetting zoom:",e),!1}},setZoom:e=>{if(!this.image||e<=0)return!1;try{const t=this.image.$getTransform();if(!t)return!1;const[l,n,a,r,i,o]=t,s=Math.sqrt(l*l+n*n),c=Math.sqrt(a*a+r*r),u=l/s*e,d=n/s*e,b=a/c*e,m=r/c*e;return this.image.$setTransform(u,d,b,m,i,o),!0}catch(t){return console.warn("Error setting zoom level:",t),!1}},getZoom:()=>{if(!this.image)return 1;try{const e=this.image.$getTransform();if(!e)return 1;const[t,l]=e;return Math.sqrt(t*t+l*l)}catch(e){return console.warn("Error getting zoom level:",e),1}},fitToCanvas:(e=.1)=>{if(!this.image||!this.canvasElement)return!1;try{const t=this.canvasElement.getBoundingClientRect();let l=this.image.querySelector("img")||this.image;if(!l?.naturalWidth||!l?.naturalHeight)return!1;const n=1-e,a=t.width*n/l.naturalWidth,r=t.height*n/l.naturalHeight,i=Math.min(a,r,1);return this.transform.setZoom(i)}catch(t){return console.warn("Error fitting to canvas:",t),!1}}};selection={center:()=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$center(),!0}catch(e){return console.warn("Error centering selection:",e),!1}},reset:()=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$reset(),!0}catch(e){return console.warn("Error resetting selection:",e),!1}},setCoverage:e=>{if(!this.selectionElement||e<0||e>1)return!1;try{return this.selectionElement.initialCoverage=e,this.selectionElement.$reset(),!0}catch(t){return console.warn("Error setting coverage:",t),!1}},setAspectRatio:e=>{if(!this.selectionElement)return!1;try{let t;if(""===e||null==e)t=NaN;else if("number"==typeof e)t=e;else{if("string"!=typeof e)return console.warn("Unsupported aspect ratio type:",typeof e,e),!1;if(e.includes("/")){const[l,n]=e.split("/").map(e=>parseFloat(e.trim()));if(isNaN(l)||isNaN(n)||0===n)return console.warn("Invalid aspect ratio format:",e),!1;t=l/n}else if(t=parseFloat(e),isNaN(t))return console.warn("Invalid aspect ratio format:",e),!1}return this.selectionElement.aspectRatio=t,this.selectionElement.$render(),!0}catch(t){return console.warn("Error setting aspect ratio:",t),!1}},move:(e,t)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$move(e,t),!0}catch(l){return console.warn("Error moving selection:",l),!1}},zoom:e=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$zoom(e),!0}catch(t){return console.warn("Error zooming selection:",t),!1}},change:(e,t,l,n,a)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$change(e,t,l,n,a),!0}catch(r){return console.warn("Error changing selection:",r),!1}},set:(e,t,l,n)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.x=e,this.selectionElement.y=t,this.selectionElement.width=l,this.selectionElement.height=n,this.selectionElement.$render(),!0}catch(a){return console.warn("Error setting selection:",a),!1}},toCanvas:async(e={})=>{if(!this.selectionElement)return null;try{const t={width:800,height:600,imageSmoothingEnabled:!0,imageSmoothingQuality:"high",...e};return await this.selectionElement.$toCanvas(t)}catch(t){return console.warn("Error exporting to canvas:",t),null}},getData:()=>{if(!this.selectionElement)return null;try{return{x:this.selectionElement.x,y:this.selectionElement.y,width:this.selectionElement.width,height:this.selectionElement.height,aspectRatio:this.selectionElement.aspectRatio}}catch(e){return console.warn("Error getting selection data:",e),null}}};canvas={setBackground:e=>{if(!this.canvasElement)return!1;try{return this.canvasElement.background=e,!0}catch(t){return console.warn("Error setting background:",t),!1}},setScaleStep:e=>{if(!this.canvasElement)return!1;try{return this.canvasElement.scaleStep=e,!0}catch(t){return console.warn("Error setting scale step:",t),!1}},setDisabled:e=>{if(!this.canvasElement)return!1;try{return this.canvasElement.disabled=e,!0}catch(t){return console.warn("Error setting disabled state:",t),!1}}};utils={flipHorizontal:()=>{const e=this.transform.getTransform();if(!e)return!1;const[t,l,n,a,r,i]=e;return this.transform.setTransform(-t,l,n,a,r,i)},flipVertical:()=>{const e=this.transform.getTransform();if(!e)return!1;const[t,l,n,a,r,i]=e;return this.transform.setTransform(t,l,n,-a,r,i)},setupInitialView:async(e={})=>{const{paspartuFactor:t=.85,retries:l=3,retryDelay:n=200}=e;return new Promise(e=>{const a=(r=0)=>{if(!this.isReady)return r<l?void setTimeout(()=>a(r+1),n):void e(!1);try{const i=this.canvasElement.getBoundingClientRect();let o=this.image.querySelector("img")||this.image;if(!o?.naturalWidth||!o?.naturalHeight)return r<l?void setTimeout(()=>a(r+1),n):(this.transform.center(),void e(!1));if(i.width>0&&i.height>0){const l=i.width*t/o.naturalWidth,n=i.height*t/o.naturalHeight,a=Math.min(l,n,1);this.transform.setTransform(a,0,0,a,0,0)?setTimeout(()=>{this.transform.center(),this.selection.center(),e(!0)},100):(this.transform.reset(),setTimeout(()=>{a<1&&this.transform.scale(a),setTimeout(()=>{this.transform.center(),this.selection.center(),e(!0)},100)},100))}else this.transform.center(),e(!1)}catch(i){console.warn("Error in setup:",i),this.transform.center(),e(!1)}};a()})},resetAll:()=>{const e={transform:this.transform.reset(),selection:this.selection.reset(),center:!1};return setTimeout(()=>{e.center=this.transform.center()&&this.selection.center()},100),e},checkExportability:async()=>{try{return!!(await this.selection.toCanvas({width:1,height:1}))}catch{return!1}},resetZoomOnly:()=>this.transform.resetZoom(),getZoomInfo:()=>{const e=this.transform.getZoom();return{current:e,isZoomedIn:e>1,isZoomedOut:e<1,percentage:Math.round(100*e)}},setBackground:e=>this.canvas.setBackground(e)};setupEventListeners(e={}){const{onSelectionChange:t,onImageTransform:l,onAction:n,onActionStart:a,onActionMove:r,onActionEnd:i}=e,o=[];if(t&&this.selectionElement){const e=e=>{t({x:e.detail.x,y:e.detail.y,width:e.detail.width,height:e.detail.height})};this.selectionElement.addEventListener("change",e),o.push(()=>{this.selectionElement&&this.selectionElement.removeEventListener("change",e)})}if(l&&this.image){const e=e=>{l({matrix:e.detail.matrix,oldMatrix:e.detail.oldMatrix})};this.image.addEventListener("transform",e),o.push(()=>{this.image&&this.image.removeEventListener("transform",e)})}if(this.canvasElement){if(n){const e=e=>n(e.detail);this.canvasElement.addEventListener("action",e),o.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("action",e)})}if(a){const e=e=>a(e.detail);this.canvasElement.addEventListener("actionstart",e),o.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("actionstart",e)})}if(r){const e=e=>r(e.detail);this.canvasElement.addEventListener("actionmove",e),o.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("actionmove",e)})}if(i){const e=e=>i(e.detail);this.canvasElement.addEventListener("actionend",e),o.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("actionend",e)})}}return()=>{o.forEach(e=>e())}}}async function En(e,t,l={}){const{format:n=null,originalFormat:a="webp",onSuccess:r=null,onError:i=null,accessibilityManager:o=null}=l;try{const l=window.limboCore?.config?.getGlobal(),i=n||l?.downloadFormat||a||"webp",c=`${t.split(".")[0]}.${i}`;if(o&&o.announce(`Descargando ${c}`),e.startsWith("data:image/"))return function(e,t){const l=document.createElement("a");l.href=e,l.download=t,l.style.display="none",document.body.appendChild(l),l.click(),setTimeout(()=>{document.body.removeChild(l)},100)}(e,c),r&&r(c),o&&o.announce(`${c} descargado correctamente`),!0;let u;try{if(u=await fetch(e,{mode:"cors"}),!u.ok)throw new Error(`HTTP error! status: ${u.status}`)}catch(s){if(!e.startsWith("http"))throw s;{const t=(window.limboCore?.config?.getGlobal()||{}).prod?"https://limbo.lefebvre.es":"https://led-dev-limbo-dev.eu.els.local",l=window.limboCore?.apiClient?.token||"",n=`${t}/api/atenea/proxy?url=${encodeURIComponent(e)}`;if(u=await fetch(n,{credentials:"include",headers:{Authorization:`Bearer ${l}`}}),!u.ok)throw new Error(`Proxy error: ${u.status}`)}}const d=await u.blob();let b=d;const m=d.type;m!==`image/${"jpg"===i?"jpeg":i}`&&function(e){return["webp","jpeg","jpg","svg","png"].includes(e.toLowerCase())}(i)&&(b=await async function(e,t){return new Promise(l=>{const n=new Image,a=URL.createObjectURL(e);n.onload=()=>{try{const r=document.createElement("canvas");r.width=n.width,r.height=n.height;r.getContext("2d").drawImage(n,0,0);const i=`image/${"jpg"===t?"jpeg":t}`,o="png"===t?void 0:.92;r.toBlob(t=>{URL.revokeObjectURL(a),l(t||e)},i,o)}catch(r){URL.revokeObjectURL(a),l(e)}},n.onerror=()=>{URL.revokeObjectURL(a),l(e)},n.src=a})}(d,i));const h=window.URL.createObjectURL(b),p=document.createElement("a");return p.href=h,p.download=c,p.style.display="none",document.body.appendChild(p),p.click(),setTimeout(()=>{window.URL.revokeObjectURL(h),document.body.removeChild(p)},100),r&&r(c),o&&o.announce(`${c} descargado correctamente`),!0}catch(c){return console.error("Error downloading image:",c),i&&i(c),o&&o.announce(`Error al descargar la imagen: ${c.message}`),!1}}const $n=Object.freeze(Object.defineProperty({__proto__:null,default:En,downloadImage:En},Symbol.toStringTag,{value:"Module"}));function _n({image:t,onSave:n,onCancel:a,onDelete:r=null,onError:i=null,deleting:o=!1,onVariantCreated:s=null,onUpload:c=null,uploading:u=!1,cropperConfig:d=null}){const[b,m]=e.useState(!1),[h,p]=e.useState(null),[f,g]=e.useState(!1),[v,y]=e.useState(!0),[x,w]=e.useState(!0),[k,C]=e.useState(t.url||t.path||null);e.useEffect(()=>{const e=t.url||t.path;if(!e||e.startsWith("blob:")||e.startsWith("data:"))return void C(e);let l=!1;return xe(e,{bypassHttpCache:!0}).then(e=>{l||C(e)}).catch(()=>{l||C(e)}),()=>{l=!0}},[t.url,t.path]);const[S,j]=e.useState({x:20,y:100}),[N,E]=e.useState(!1),[$,_]=e.useState({x:0,y:0}),[T,A]=e.useState(!1),[z,L]=e.useState(!0),[M,I]=e.useState(!1),[P,D]=e.useState({horizontal:!1,vertical:!1}),[R,O]=e.useState(!1),[F,U]=e.useState(!1),[B,q]=e.useState(!1),[W,V]=e.useState(!1),[H]=e.useState(()=>{if(!t||!t.filename)return"image";const[e]=t.filename.split(".");return e}),K=e.useMemo(()=>{if(d)return{mandatoryCrops:d.mandatoryCrops||[],allowCustomCrops:!1!==d.allowAdditionalCrops,showDimensionInputs:!0===d.showDimensionInputs,maxCrops:d.maxCrops||null,localCropsOnly:!0===d.localCropsOnly,existingCrops:d.existingCrops||null};const e=window.limboCore?.config?.getGlobal()||{};return{mandatoryCrops:e.cropper?.mandatoryCrops||[],allowCustomCrops:!1!==e.cropper?.allowCustomCrops,showDimensionInputs:!0===e.cropper?.showDimensionInputs,maxCrops:e.cropper?.maxCrops||null,localCropsOnly:!0===e.cropper?.localCropsOnly,existingCrops:e.cropper?.existingCrops||null}},[d]),[G,Q]=e.useState(()=>K.mandatoryCrops.length>0?K.mandatoryCrops.map((e,t)=>({id:`crop-${t}`,label:e.label,width:e.width,height:e.height,required:!1!==e.required,isCustom:!1,confirmed:!1,lockDimensions:!(!e.width||!e.height),format:e.format||null,savedState:null})):[{id:"crop-default-0",label:H,width:t.width||1920,height:t.height||1080,required:!1,isCustom:!0,confirmed:!1,savedState:null}]),[X,Y]=e.useState(0),J=G[X],Z=e.useMemo(()=>J&&J.width&&J.height?J.width/J.height:"",[J]),ee=e.useMemo(()=>{const e=50;if(!Z||""===Z)return{minWidth:e,minHeight:e};if(Z>=1){return{minWidth:e,minHeight:e/Z}}return{minWidth:e*Z,minHeight:e}},[Z]),[te,le]=e.useState(!1),[ne,ae]=e.useState([]),[re,ie]=e.useState(null),oe=window.limboCore?.accessibilityManager,{createVariantFromBlob:se,loading:ce,error:ue}=jn(),de=((t,l={})=>{const n=e.useRef(null),a=e.useRef(null),r=e.useRef(null),i=e.useRef(null),[o,s]=e.useState(null),[c,u]=e.useState(null),[d,b]=e.useState(!1),[m,h]=e.useState(!0),[p,f]=e.useState(0),g={aspectRatio:"",shade:!0,paspartuFactor:.85,...l};e.useEffect(()=>{n.current&&a.current&&r.current&&(i.current=new Nn(n,a,r),b(!0))},[]),e.useEffect(()=>{if(i.current)return i.current.setupEventListeners({onSelectionChange:e=>{s(e)},onImageTransform:()=>{f(e=>e+1)}})},[d]),e.useEffect(()=>{i.current&&t&&(async()=>{i.current.selection.setAspectRatio(g.aspectRatio),i.current.canvas.setBackground(g.shade),await i.current.utils.setupInitialView({paspartuFactor:g.paspartuFactor});const e=await i.current.utils.checkExportability();h(e);const t=a.current?.querySelector("img")||a.current;t?.naturalWidth&&t?.naturalHeight&&u({naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,currentWidth:t.width,currentHeight:t.height})})()},[t]),e.useEffect(()=>{i.current&&d&&i.current.selection.setAspectRatio(g.aspectRatio)},[g.aspectRatio,d]),e.useEffect(()=>{i.current&&d&&i.current.canvas.setBackground(g.shade)},[g.shade,d]);const v=e.useMemo(()=>({move:(e,t)=>i.current?.transform.move(e,t)||!1,zoom:e=>i.current?.transform.zoom(e)||!1,rotate:e=>i.current?.transform.rotate(e)||!1,center:()=>i.current?.transform.center()||!1,reset:()=>i.current?.transform.reset()||!1,resetZoom:()=>i.current?.transform.resetZoom()||!1,setZoom:e=>i.current?.transform.setZoom(e)||!1,getZoom:()=>i.current?.transform.getZoom()||1,fitToCanvas:e=>i.current?.transform.fitToCanvas(e)||!1,flipHorizontal:()=>i.current?.utils.flipHorizontal()||!1,flipVertical:()=>i.current?.utils.flipVertical()||!1}),[]),y=e.useMemo(()=>({center:()=>i.current?.selection.center()||!1,reset:()=>i.current?.selection.reset()||!1,setCoverage:e=>i.current?.selection.setCoverage(e)||!1,setAspectRatio:e=>i.current?.selection.setAspectRatio(e)||!1,toCanvas:e=>i.current?.selection.toCanvas(e)||Promise.resolve(null)}),[]),x=e.useMemo(()=>({resetAll:()=>{if(i.current){const e=i.current.utils.resetAll();return s(null),e}return!1},setBackground:e=>i.current?.canvas.setBackground(e)||!1,resetZoomOnly:()=>i.current?.utils.resetZoomOnly()||!1,getZoomInfo:()=>i.current?.utils.getZoomInfo()||{current:1,percentage:100,isZoomedIn:!1,isZoomedOut:!1}}),[]);return{refs:{canvasRef:n,imageRef:a,selectionRef:r},state:{cropData:o,imageInfo:c,isReady:d,canExport:m,transformVersion:p},transform:v,selection:y,utils:x,manager:i.current}})(t,{aspectRatio:Z||null,showGrid:v,shade:x,initialCoverage:.5,paspartuFactor:.85}),{refs:be,state:me,transform:he,selection:pe,utils:ge}=de,{canvasRef:ve,imageRef:ye,selectionRef:we}=be,{cropData:ke,imageInfo:Ce,canExport:Se,transformVersion:je}=me,Ne=e.useMemo(()=>Ce||{naturalWidth:t.width||1920,naturalHeight:t.height||1080,currentWidth:t.width||1920,currentHeight:t.height||1080},[Ce,t.width,t.height]),Ee=e.useCallback(()=>y(e=>!e),[]),$e=e.useCallback(()=>w(e=>!e),[]),_e=e.useCallback(()=>U(e=>!e),[]),Te=e.useCallback(()=>q(e=>!e),[]),Ae=e.useCallback(()=>V(e=>!e),[]),ze=e.useCallback(()=>he.center(),[he]),Le=e.useCallback(()=>pe.center(),[pe]),Me=e.useCallback(()=>pe.reset(),[pe]),Ie=e.useCallback((e,t)=>he.move(e,t),[he]),Pe=e.useCallback(e=>he.zoom(e),[he]),De=e.useCallback(e=>he.rotate(e),[he]),Oe=e.useCallback(e=>{pe.setCoverage(e)},[pe]),Fe=e.useCallback(()=>{D(e=>{const t=!e.horizontal;return he.flipHorizontal(),{...e,horizontal:t}})},[he]),Ue=e.useCallback(()=>{D(e=>{const t=!e.vertical;return he.flipVertical(),{...e,vertical:t}})},[he]),Be=e.useCallback(()=>{if(!de.manager||!me.isReady)return null;try{const e=ke?{...ke}:null;let t=null;if(we.current){const e=we.current;t={x:e.x??0,y:e.y??0,width:e.width??0,height:e.height??0}}let l=null;if(ye.current){const e=ye.current.$getTransform?.();e&&Array.isArray(e)&&(l=[...e])}const n={cropData:e,selectorState:t,imageTransform:l,flipState:{horizontal:P.horizontal,vertical:P.vertical}};return Q(e=>e.map((e,t)=>t===X?{...e,savedState:n}:e)),n}catch(e){return console.warn("Error saving crop state:",e),null}},[de.manager,me.isReady,ke,P,X,ye,we]),qe=e.useCallback(e=>{const t=G[e];if(t&&t.savedState)if(de.manager&&me.isReady)try{const{savedState:e}=t;if(e.imageTransform&&ye.current&&Array.isArray(e.imageTransform)&&setTimeout(()=>{if(ye.current&&ye.current.$setTransform){const[t,l,n,a,r,i]=e.imageTransform;ye.current.$setTransform(t,l,n,a,r,i)}},100),e.selectorState&&we.current){const{x:t,y:l,width:n,height:a}=e.selectorState;setTimeout(()=>{we.current&&(we.current.x=t,we.current.y=l,we.current.width=n,we.current.height=a,we.current.$render&&we.current.$render())},150)}e.flipState&&D({horizontal:e.flipState.horizontal??!1,vertical:e.flipState.vertical??!1})}catch(l){console.error("Error restoring crop state:",l),setTimeout(()=>{ze(),setTimeout(()=>Le(),100)},100)}else console.warn("Cropper not ready for state restoration");else setTimeout(()=>{ze(),setTimeout(()=>Le(),100)},100)},[G,de.manager,me.isReady,ze,Le,we,ye]),We=e.useCallback(()=>{for(let e=0;e<G.length;e++){const t=G[e];if(!t.label||""===t.label.trim())return e}return-1},[G]),Ve=e.useCallback(async e=>{e!==X&&(I(!0),Be(),await new Promise(e=>setTimeout(e,100)),Y(e),await new Promise(e=>setTimeout(e,250)),qe(e),await new Promise(e=>setTimeout(e,200)),I(!1))},[X,Be,qe]),He=e.useCallback(()=>{if(!K.allowCustomCrops)return void alert("No se pueden añadir recortes personalizados en este modo.");const e={id:`crop-custom-${Date.now()}`,label:`Recorte ${G.length+1}`,width:t.width||1920,height:t.height||1080,required:!1,isCustom:!0,confirmed:!1,savedState:null};Q(t=>[...t,e]),oe?.announce(`Nuevo recorte personalizado añadido: ${e.label}. Selecciónalo para editarlo.`)},[K.allowCustomCrops,G.length,t.width,t.height,oe]),Ke=e.useCallback((e,t)=>{const l=parseInt(t,10);""===t||isNaN(l)||Q(t=>t.map((t,n)=>n===X?{...t,[e]:l}:t))},[X]),Ge=e.useCallback(e=>{const t=J[e];let l=100;if(ve.current&&Ce){const e=ve.current.getBoundingClientRect(),t=Math.min(e.width,e.height);l=Math.max(100,Math.round(.05*t))}const n=Math.max(l,Math.min(3500,t));n!==t&&Q(t=>t.map((t,l)=>l===X?{...t,[e]:n}:t));const a={...J,[e]:n},r=a.width/a.height,i=pe.getData?.();pe.setAspectRatio(r),i&&void 0!==i.x&&setTimeout(()=>{pe.set?.(i.x,i.y,i.width,i.height)},50)},[X,J,pe,ve,Ce]),Qe=e.useCallback(e=>{Q(t=>t.map((t,l)=>l===X?{...t,label:e}:t))},[X]),Xe=e.useCallback((e,t=null)=>{t=t||G[e].label;if(!window.confirm(`¿Estás seguro de que deseas eliminar "${t||"este recorte"}"? Esta acción también eliminará todos sus recortes.`))return;const l=G[e];if(l.required)alert("No se puede eliminar un recorte obligatorio.");else if(1!==G.length){if(Q(t=>t.filter((t,l)=>l!==e)),e===X){const t=Math.max(0,e-1);Y(t)}else e<X&&Y(e=>e-1);oe?.announce(`Recorte ${l.label} eliminado`)}else alert("Debe haber al menos un recorte.")},[G,X,oe]),Ye=e.useCallback(async()=>{if(!Se)return null;try{const e=await pe.toCanvas({width:800,height:600,imageSmoothingEnabled:!0,imageSmoothingQuality:"high"});return e?e.toDataURL(`image/${globalThis.downloadFormat||t.mime_type.split("/")[1]||"webp"}`,.9):null}catch(e){return console.warn("Error generating preview:",e),null}},[Se,t.mime_type,pe]),Je=e.useCallback(async()=>{if(b)return m(!1),p(null),void g(!1);if(Se){m(!0),g(!0);try{const e=await Ye();e?p(e):(m(!1),alert("No se puede exportar el recorte por restricciones de CORS en la imagen original."))}finally{g(!1)}}else alert("No se puede exportar el recorte por restricciones de CORS en la imagen original.")},[Se,Ye,b]),Ze=e.useCallback(e=>{e.target.closest(".limbo-preview-modal-header")&&(E(!0),_({x:e.clientX-S.x,y:e.clientY-S.y}))},[S]),et=e.useCallback(e=>{N&&(e.preventDefault(),j({x:e.clientX-$.x,y:e.clientY-$.y}))},[N,$]),tt=e.useCallback(()=>{E(!1)},[]),lt=e.useCallback(e=>{if(!e.target.closest(".limbo-preview-modal-header"))return;const t=e.touches[0];E(!0),_({x:t.clientX-S.x,y:t.clientY-S.y})},[S]),nt=e.useCallback(e=>{if(!N)return;e.preventDefault();const t=e.touches[0];j({x:t.clientX-$.x,y:t.clientY-$.y})},[N,$]),at=e.useCallback(()=>{E(!1)},[]);e.useEffect(()=>{if(N)return document.addEventListener("mousemove",et),document.addEventListener("mouseup",tt),document.addEventListener("touchmove",nt,{passive:!1}),document.addEventListener("touchend",at),()=>{document.removeEventListener("mousemove",et),document.removeEventListener("mouseup",tt),document.removeEventListener("touchmove",nt),document.removeEventListener("touchend",at)}},[N,et,tt,nt,at]),e.useEffect(()=>{if(!T)return;const e=e=>{"Escape"===e.key&&A(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[T]);const rt=e.useCallback(async(e,l=null)=>{const n=G[e];if(!n)throw new Error(`Crop ${e} no encontrado`);if(!n.savedState&&e!==X)throw new Error(`El recorte "${n.label}" aún no ha sido configurado`);const a={imageTransform:ye.current?.$getTransform?.(),selectorState:we.current?{x:we.current.x,y:we.current.y,width:we.current.width,height:we.current.height}:null};try{if(e!==X&&n.savedState){if(n.savedState.imageTransform&&ye.current?.$setTransform){const[e,t,l,a,r,i]=n.savedState.imageTransform;ye.current.$setTransform(e,t,l,a,r,i)}if(n.savedState.selectorState&&we.current?.$change){const{x:e,y:t,width:l,height:a}=n.savedState.selectorState;we.current.$change(e,t,l,a,NaN,!0)}await new Promise(e=>setTimeout(e,100))}const a=Math.min(n.width,3500),i=Math.min(n.height,3500);let o=await pe.toCanvas({width:a,height:i,imageSmoothingEnabled:!0,imageSmoothingQuality:"high"});if(!o)throw new Error(`No se pudo generar el canvas para "${n.label}"`);if(o.width!==a||o.height!==i){const e=document.createElement("canvas");e.width=a,e.height=i;const t=e.getContext("2d");t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high",t.drawImage(o,0,0,a,i),o=e}const u=n.format||globalThis.downloadFormat||"webp",d="webp"===u?"image/webp":"png"===u?"image/png":"image/jpeg",b=.9,m=await new Promise((e,t)=>{o.toBlob(l=>{l?e(l):t(new Error("No se pudo convertir el canvas a blob"))},d,b)}),h=`${Ct(n.label||"crop")}_${a}_${i}`,p=l||t.id,f=!p||"string"==typeof p&&p.startsWith("external"),g=(f||K.localCropsOnly)&&!c;if(f&&c&&!K.localCropsOnly)try{const e=new File([m],`${h}.${u}`,{type:d}),t=await c(e);if(t&&(t.id||t.url)){const e=n.savedState||{selectorState:we.current?{x:we.current.x,y:we.current.y,width:we.current.width,height:we.current.height}:null,imageTransform:ye.current?.$getTransform?.()||null,flipState:{horizontal:P.horizontal,vertical:P.vertical}},l={id:t.id||`uploaded-${Date.now()}`,name:h,filename:`${h}.${u}`,url:t.urlSigned||t.url,urlSigned:t.urlSigned||t.url,width:a,height:i,format:u,size:m.size,mime_type:d,isLocal:!1,originalAssetId:null,uploadedAssetId:t.id,cropState:e};return oe?.announceSuccess(`Recorte guardado: ${h}`),l}}catch(r){console.error("[CropperView] ❌ Error subiendo crop, fallback a local:",r)}if(g){const e=URL.createObjectURL(m),t=n.savedState||{selectorState:we.current?{x:we.current.x,y:we.current.y,width:we.current.width,height:we.current.height}:null,imageTransform:ye.current?.$getTransform?.()||null,flipState:{horizontal:P.horizontal,vertical:P.vertical}},l={id:`local-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:h,filename:`${h}.${u}`,url:e,urlSigned:e,width:a,height:i,format:u,size:m.size,mime_type:d,blob:m,isLocal:!0,originalAssetId:p||null,cropState:t};return oe?.announceSuccess(`Recorte creado localmente: ${h}`),l}const v=n.savedState||{selectorState:we.current?{x:we.current.x,y:we.current.y,width:we.current.width,height:we.current.height}:null,imageTransform:ye.current?.$getTransform?.()||null,flipState:{horizontal:P.horizontal,vertical:P.vertical}},y=await se(p,m,{name:h,width:a,height:i,format:u});if(y)return y.cropState=v,oe?.announceSuccess(`Recorte creado: ${h}`),s?.(p,y),y;throw new Error("No se pudo crear la variante")}finally{if(e!==X&&a.imageTransform&&ye.current?.$setTransform){const[e,t,l,n,r,i]=a.imageTransform;if(ye.current.$setTransform(e,t,l,n,r,i),a.selectorState&&we.current?.$change){const{x:e,y:t,width:l,height:n}=a.selectorState;we.current.$change(e,t,l,n,NaN,!0)}}}},[G,X,pe,se,t.id,s,oe,ye,we]),it=e.useCallback(async()=>{if(!Se){const e="No se puede exportar el recorte por restricciones de CORS en la imagen original.";return oe?.announceError(e),void alert(e)}if(!me.isReady){const e="El cropper aún no está inicializado. Espera un momento e inténtalo de nuevo.";return oe?.announceError(e),void alert(e)}Be(),oe?.announce("Creando recorte de la imagen");try{let e=t.id,l=null;if(t.file&&c){oe?.announce("Subiendo imagen...");const n=await c(t.file);if(!n||!n.id)throw new Error("No se pudo subir la imagen al servidor");e=n.id,l=n,oe?.announceSuccess("Imagen subida correctamente")}const a=await rt(X,e);a&&n(l?{crops:[a],asset:l}:a)}catch(e){console.warn("Error creating crop variant:",e);const t=e.message||"No se pudo crear el recorte. Inténtalo de nuevo.";oe?.announceError(t),alert(t),i?.(e)}},[Se,me.isReady,oe,Be,rt,X,n,i,t.file,t.id,c]),ot=e.useCallback(async e=>{Be(),oe?.announce(`Guardando ${e.length} recortes...`);try{let a=t.id,r=null;if(t.file&&c){oe?.announce("Subiendo imagen...");const e=await c(t.file,t.tags||null);if(!e||!e.id)throw new Error("No se pudo subir la imagen al servidor");a=e.id,r=e,oe?.announceSuccess("Imagen subida correctamente")}const i=[],o=[];for(const t of e)try{const e=await rt(t,a);e&&i.push(e)}catch(l){o.push({crop:G[t]?.label||`Crop ${t}`,error:l.message})}if(i.length>0&&(oe?.announceSuccess(`${i.length} recorte(s) guardado(s) correctamente`),n(r?{crops:i,asset:r}:i)),o.length>0){const e=`Errores al guardar algunos recortes:\n${o.map(e=>`- ${e.crop}: ${e.error}`).join("\n")}`;oe?.announceError(e),alert(e)}}catch(l){const e=l.message||"Error al procesar los recortes";oe?.announceError(e),alert(e),i?.(l)}},[Be,rt,G,oe,n,t.file,t.id,c,i]),st=e.useCallback(async()=>{(J.width>3500||J.height>3500)&&alert("Las dimensiones máximas permitidas son 3500x3500 píxeles. Por favor, ajusta el tamaño del recorte."),J.width=Math.min(J.width,3500),J.height=Math.min(J.height,3500);const e=We();if(-1!==e){const t=G[e];return alert(`El recorte "${t.label||t||"(sin nombre)"}" debe tener un nombre válido.`),void Y(e)}const t=G.findIndex((e,t)=>e.required&&!e.savedState&&t!==X);if(-1!==t){const e=G[t];return alert(`El recorte obligatorio "${e.label}" aún no ha sido configurado.\n\nPor favor, configura todos los recortes obligatorios antes de guardar.`),Y(t),void oe?.announce(`Recorte obligatorio "${e.label}" sin configurar. Por favor, configúralo.`,"assertive")}if(G.length>1){ie("save");const e=G.map((e,t)=>({crop:e,index:t})).filter(({crop:e,index:t})=>e.required||e.savedState||t===X).map(({index:e})=>e);return ae(e),void le(!0)}await it()},[We,G,it,X,oe]),ct=e.useCallback(async e=>{const l=G[e];if(!l)throw new Error(`Crop ${e} no encontrado`);if(!l.savedState&&e!==X)throw new Error(`El recorte "${l.label}" aún no ha sido configurado`);const n={imageTransform:ye.current?.$getTransform?.(),selectorState:we.current?{x:we.current.x,y:we.current.y,width:we.current.width,height:we.current.height}:null};try{if(e!==X&&l.savedState){if(l.savedState.imageTransform&&ye.current?.$setTransform){const[e,t,n,a,r,i]=l.savedState.imageTransform;ye.current.$setTransform(e,t,n,a,r,i)}if(l.savedState.selectorState&&we.current?.$change){const{x:e,y:t,width:n,height:a}=l.savedState.selectorState;we.current.$change(e,t,n,a,NaN,!0)}await new Promise(e=>setTimeout(e,100))}const n=await pe.toCanvas({width:l.width,height:l.height,imageSmoothingEnabled:!0,imageSmoothingQuality:"high"});if(!n)throw new Error(`No se pudo generar el canvas para "${l.label}"`);const a=n.toDataURL(`image/${globalThis.downloadFormat||t.mime_type?.split("/")[1]||"webp"}`,.9),r=`${Ct(l.label||"crop")}_${l.width}_${l.height}`;return await En(a,r,{accessibilityManager:oe,onSuccess:e=>{console.log(`✅ Descargado: ${e}`)},onError:e=>{throw new Error(`Error al descargar "${l.label}": ${e.message}`)}}),{crop:l.label,filename:r}}finally{if(e!==X&&n.imageTransform&&ye.current?.$setTransform){const[e,t,l,a,r,i]=n.imageTransform;if(ye.current.$setTransform(e,t,l,a,r,i),n.selectorState&&we.current?.$change){const{x:e,y:t,width:l,height:a}=n.selectorState;we.current.$change(e,t,l,a,NaN,!0)}}}},[G,X,pe,t.mime_type,oe,ye,we]),ut=e.useCallback(async e=>{Be(),oe?.announce(`Descargando ${e.length} recortes...`);const t=[],l=[];for(const a of e)try{const e=await ct(a);e&&t.push(e)}catch(n){l.push({crop:G[a]?.label||`Crop ${a}`,error:n.message})}if(t.length>0&&oe?.announceSuccess(`${t.length} recorte(s) descargado(s) correctamente`),l.length>0){const e=`Errores al descargar algunos recortes:\n${l.map(e=>`- ${e.crop}: ${e.error}`).join("\n")}`;oe?.announceError(e),alert(e)}},[Be,ct,G,oe]),dt=e.useCallback(async()=>{if(!Se){const e="No se puede descargar el recorte por restricciones de CORS en la imagen original.";return oe?.announceError(e),void alert(e)}Be(),oe?.announce("Preparando descarga del recorte");try{await ct(X),oe?.announceSuccess("Recorte descargado correctamente")}catch(e){console.error("Error downloading crop:",e);const t=e.message||"Error al descargar el recorte";oe?.announceError(t),alert(t)}},[Se,oe,Be,ct,X]),bt=e.useCallback(async()=>{const e=We();if(-1!==e){const t=G[e];return alert(`El recorte "${t.label||t||"(sin nombre)"}" debe tener un nombre válido.`),void Y(e)}if(G.length>1){ie("download");const e=G.map((e,t)=>({crop:e,index:t})).filter(({crop:e,index:t})=>e.savedState||t===X).map(({index:e})=>e);return ae(e),void le(!0)}await dt()},[We,G,dt,X]),mt=e.useMemo(()=>!!t.file||(!t.id||!("string"!=typeof t.id||!t.id.startsWith("external"))),[t.file,t.id]),ht=e.useCallback(async()=>{try{if(t.file&&c){oe?.announce("Subiendo imagen original...");const e=await c(t.file);if(!e||!e.id)throw new Error("No se pudo subir la imagen al servidor");return oe?.announceSuccess("Imagen guardada correctamente"),void n({asset:e,crops:[]})}if(mt){oe?.announce("Conservando imagen original...");const e={id:`local-original-${Date.now()}`,name:t.filename||"original",filename:t.filename||"image.jpg",url:t.url,urlSigned:t.url,width:t.width||Ce?.naturalWidth||1920,height:t.height||Ce?.naturalHeight||1080,mime_type:t.mime_type||"image/jpeg",isLocal:!0,isOriginal:!0};return oe?.announceSuccess("Imagen original conservada"),void n({crops:[e]})}if(t.id&&!t.id.startsWith("external")){oe?.announce("Seleccionando imagen original...");const e={id:t.id,name:t.filename||"original",filename:t.filename||"image.jpg",url:t.url,urlSigned:t.urlSigned||t.url,width:t.width||Ce?.naturalWidth||1920,height:t.height||Ce?.naturalHeight||1080,mime_type:t.mime_type||"image/jpeg",isOriginal:!0};return oe?.announceSuccess("Imagen original seleccionada"),void n({crops:[e],assetId:t.id})}a()}catch(e){console.error("Error guardando imagen original:",e);const t=e.message||"No se pudo guardar la imagen. Inténtalo de nuevo.";oe?.announceError(t),alert(t),i?.(e)}},[t,Ce,c,a,n,i,oe,mt]);return e.useEffect(()=>{m(!1),p(null)},[t]),e.useEffect(()=>{if(!de.manager||!me.isReady||!z)return;const e=K.existingCrops?.[0],t=e?.cropState;setTimeout(()=>{ze(),setTimeout(()=>{if(t){if(t.imageTransform&&ye.current?.$setTransform){const[e,l,n,a,r,i]=t.imageTransform;ye.current.$setTransform(e,l,n,a,r,i)}if(t.selectorState&&we.current){const{x:e,y:l,width:n,height:a}=t.selectorState;we.current.x=e,we.current.y=l,we.current.width=n,we.current.height=a,we.current.$render?.()}t.flipState&&D(t.flipState)}else Le();L(!1)},100)},50)},[de.manager,me.isReady,z,ze,Le,K.existingCrops]),e.useEffect(()=>{de.manager&&me.isReady&&(Z&&pe.setAspectRatio(Z),ge.setBackground(x))},[Z,x,de.manager,me.isReady,pe,ge]),e.useEffect(()=>{if(!Ce||!me.isReady||K.mandatoryCrops.length>0)return;const e=G[0];if(e&&"crop-default-0"===e.id&&(1920===e.width||1080===e.height)){const t=Math.min(Ce.naturalWidth,3500),l=Math.min(Ce.naturalHeight,3500);Q([{...e,width:t,height:l}])}},[Ce,me.isReady,K.mandatoryCrops.length,G]),e.useEffect(()=>{if(!b||!Se)return;const e=setTimeout(async()=>{g(e=>!h&&!e||e);try{const e=await Ye();e&&p(e)}finally{g(!1)}},300);return()=>{clearTimeout(e),g(!1)}},[ke,je,b,Se,Ye,Z,P,h]),e.useEffect(()=>{const e=ve.current,t=t=>{if("Delete"===t.key||"Backspace"===t.key||"Backspace"===t.key&&t.metaKey||"Backspace"===t.key&&t.ctrlKey){const l=t.target;if(e&&(l===e||l===document.body||l===document.documentElement||"CROPPER-CANVAS"===l.tagName||"CROPPER-SELECTION"===l.tagName||"CROPPER-IMAGE"===l.tagName||"CROPPER-HANDLE"===l.tagName||"CROPPER-GRID"===l.tagName||l.closest("cropper-canvas")||e.contains(l)))return t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),!1}};return document.addEventListener("keydown",t,!0),document.addEventListener("keyup",t,!0),window.addEventListener("keydown",t,!0),e&&e.addEventListener("keydown",t,!0),()=>{document.removeEventListener("keydown",t,!0),document.removeEventListener("keyup",t,!0),window.removeEventListener("keydown",t,!0),e&&e.removeEventListener("keydown",t,!0)}},[ve]),t?l.jsxs("div",{className:"limbo-cropper-view lb:px-2 lb:border-2 lb:border-gray-200/50 lb:rounded-lg lb:max-w-7xl lb:mx-auto lb:w-full lb:min-w-full lb:h-full lb:min-h-full lb:flex lb:flex-col",children:[l.jsxs("div",{className:"limbo-cropper-header lb:flex lb:flex-row lb:justify-between lb:items-start lb:flex-wrap lb:mx-2 lb:py-2 lb:border-b lb:border-gray-200 lb:bg-white lb:z-10 lb:shrink-0 lb:lg:gap-2",children:[l.jsxs("div",{className:"lb:flex-1 lb:min-w-fit lb:space-y-2 lb:max-w-fit",children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2",children:[l.jsx("h2",{className:"lb:text-lg lb:sm:text-xl lb:font-extrabold lb:text-gray-800",children:"Generar recortes"}),G.length>1&&l.jsx("span",{className:"lb:px-2 lb:py-0.5 lb:bg-blue-100 lb:text-blue-800 lb:text-xs lb:font-semibold lb:rounded",children:J.label})]}),l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2",children:[l.jsx("label",{className:"lb:text-xs lb:text-gray-500 lb:whitespace-nowrap lb:w-fit",children:"Nombre:"}),l.jsx("div",{className:"",children:H+"."+(globalThis.downloadFormat||t.mime_type.split("/")[1]||"webp")})]})]}),l.jsx("div",{className:"lb:flex lb:flex-row lb:self-end lb:gap-2 lb:w-full lb:max-w-fit lb:sm:w-auto lb:flex-wrap",children:l.jsxs("button",{onClick:()=>{window.confirm("Si cancelas, perderás todos los cambios realizados. ¿Deseas continuar?")&&a()},disabled:ce,className:"lb:flex lb:flex-row lb:items-center lb:gap-1 lb:self-end lb:w-full lb:max-w-fit lb:sm:w-auto lb:px-3 lb:cursor-pointer lb:py-1.5 lb:text-sm lb:rounded lb:bg-neutral-gray-500 lb:hover:bg-neutral-gray-700 lb:transition-colors lb:text-white lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":"Cancelar y volver",title:"Cancelar y volver",children:[l.jsx("span",{className:"icon icon-arrow-left-white icon--sm lb:m-0 lb:p-0"})," ","Volver"]})})]}),l.jsxs("div",{className:"limbo-cropper-status lb:bg-white lb:border-gray-100 lb:py-0 lb:pb-0 lb:flex-shrink-0",children:[ue&&l.jsxs(fe,{variant:"danger",className:"lb:mb-2 lb:text-sm",children:[l.jsx("strong",{children:"Error:"})," ",ue]}),Ce&&l.jsxs(fe,{variant:"info",className:"lb:mb-2 lb:text-sm",role:"status",children:[l.jsx("strong",{children:"Original:"})," ",Ce.naturalWidth," ×"," ",Ce.naturalHeight," px",Ce.currentWidth!==Ce.naturalWidth&&l.jsxs("span",{className:"lb:ml-2 lb:sm:ml-3 lb:text-xs lb:block lb:sm:inline",children:["(Mostrada: ",Math.round(Ce.currentWidth)," ×"," ",Math.round(Ce.currentHeight)," px)"]})]}),!Se&&l.jsx(fe,{variant:"warning",className:"lb:mb-2 lb:text-sm",children:"No se puede exportar por restricciones CORS"}),l.jsxs("div",{className:"lb:bg-white lb:border-b lb:border-gray-200 lb:py-2 lb:mx-2 lb:shrink-0 lb:sticky lb:top-0 lb:z-10 lb:mb-1",children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:mb-2",children:[l.jsxs("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-700",children:["Recortes ",G.length>1&&`(${G.length})`]}),K.allowCustomCrops&&l.jsxs("button",{onClick:He,disabled:ce,className:"lb:text-xs lb:cursor-pointer lb:px-2 lb:py-1 lb:bg-brand-blue-50 lb:hover:bg-brand-blue-200 lb:text-brand-blue-1000 lb:rounded lb:border lb:border-brand-blue-200 lb:transition-colors lb:flex lb:items-center lb:gap-1",title:"Añadir recorte personalizado",children:[l.jsx("span",{className:"icon icon-add icon--sm",style:{filter:"var(--limbo-icon-blue)"}}),"Añadir recorte"]})]}),l.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:lg:grid-cols-4 lb:xl:grid-cols-5 lb:gap-1.5 lb:max-h-48 lb:overflow-y-auto",children:G.map((e,t)=>{const n=e.savedState||t===X;return l.jsxs("label",{className:"lb:h-fit lb:flex lb:flex-col lb:p-1.5 lb:rounded lb:border lb:cursor-pointer lb:transition-colors lb:min-h-17.5 lb:w-full "+(X===t?"lb:bg-blue-50 lb:border-blue-300":n?"lb:bg-gray-50 lb:border-gray-200 lb:hover:bg-gray-100":"lb:bg-orange-50 lb:border-orange-300 lb:hover:bg-orange-100"),children:[l.jsx("input",{type:"radio",name:"active-crop",checked:X===t,onChange:()=>Ve(t),disabled:ce,className:"lb:hidden"}),l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-1 lb:mb-1",children:[l.jsx("div",{className:"lb:flex-1 lb:min-w-0",children:l.jsxs("div",{className:"lb:flex lb:flex-wrap lb:items-center lb:gap-1 lb:min-h-",children:[X!==t||e.required?l.jsx("span",{className:"lb:text-xs lb:font-medium lb:text-gray-800 lb:truncate",children:e.label}):l.jsx("input",{type:"text",value:e.label,onChange:e=>Qe(e.target.value),disabled:ce,className:"lb:w-full lb:max-h-fit lb:text-xs lb:px-1 lb:py-0.5 lb:border lb:border-gray-300 lb:rounded lb:focus:outline-none lb:focus:ring-1 lb:focus:ring-blue-500 lb:h-1",placeholder:"Nombre",maxLength:25,onClick:e=>e.stopPropagation()}),e.required&&l.jsx("span",{className:"lb:text-[10px] lb:px-1 lb:py-0.5 lb:bg-red-200 lb:text-red-1000 lb:rounded lb:whitespace-nowrap lb:truncate",children:"Obligatorio"})]})}),!e.required&&G.length>1&&l.jsx("button",{onClick:l=>{l.preventDefault(),l.stopPropagation(),Xe(t,e.label)},className:"lb:shrink-0 lb:hover:bg-red-500/70 lb:text-red-1000 lb:p-1 lb:rounded lb:max-h-fit lb:aspect-square lb:cursor-pointer lb:flex",title:"Eliminar",children:l.jsx("span",{className:"icon icon-close-small icon--xs"})})]}),l.jsx("div",{className:"lb:flex lb:items-center lb:gap-1 lb:mt-auto",children:X===t?l.jsxs(l.Fragment,{children:[l.jsx("input",{type:"number",min:"100",max:"3500",value:Math.min(e.width,3500),onChange:e=>Ke("width",e.target.value),onBlur:()=>Ge("width"),disabled:ce||e.lockDimensions,className:"lb:max-h-fit lb:flex-1 lb:text-xs lb:px-1 lb:py-0.5 lb:border lb:rounded lb:focus:outline-none lb:focus:ring-1 lb:focus:ring-blue-500 "+(e.lockDimensions?"lb:border-gray-200 lb:bg-gray-100 lb:text-gray-500 lb:cursor-not-allowed":"lb:border-gray-300"),placeholder:"Ancho",onClick:e=>e.stopPropagation(),title:e.lockDimensions?"Dimensiones bloqueadas (recorte obligatorio)":"Ancho en píxeles"}),l.jsx("span",{className:"lb:text-gray-400 lb:text-xs",children:"×"}),l.jsx("input",{type:"number",min:"100",max:"3500",value:Math.min(e.height,3500),onChange:e=>Ke("height",e.target.value),onBlur:()=>Ge("height"),disabled:ce||e.lockDimensions,className:"lb:max-h-fit lb:flex-1 lb:text-xs lb:px-1 lb:py-0.5 lb:border lb:rounded lb:focus:outline-none lb:focus:ring-1 lb:focus:ring-blue-500 "+(e.lockDimensions?"lb:border-gray-200 lb:bg-gray-100 lb:text-gray-500 lb:cursor-not-allowed":"lb:border-gray-300"),placeholder:"Alto",onClick:e=>e.stopPropagation(),title:e.lockDimensions?"Dimensiones bloqueadas (recorte obligatorio)":"Alto en píxeles"})]}):l.jsxs("span",{className:"lb:text-xs lb:text-gray-500",children:[e.width," × ",e.height," px"]})}),!n&&l.jsx("div",{className:"lb:text-xs lb:px-1 lb:py-0.5 lb:bg-orange-300 lb:text-neutral-gray-25 lb:text-shadow-xs lb:font-semibold lb:rounded lb:text-center lb:mt-1",children:"Sin configurar"})]},e.id)})})]})]}),l.jsxs("div",{className:"lb:flex lb:flex-col lb:lg:flex-row lb:flex-1 lb:w-full lb:overflow-hidden lb:lg:max-h-130 lb:mx-2 lb:py-1",children:[l.jsx("div",{className:"lb:relative lb:flex-1 lg:flex-2 lb:h-full lb:shrink-0 lb:grow-1 lb:order-0 lb:min-h-100 lb:lg:min-h-130",children:l.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-white lb:rounded-lg lb:border-2 lb:border-gray-200 lb:overflow-hidden",children:[l.jsx(pt,{show:z,message:"Cargando recortador..."}),l.jsx(pt,{show:M,message:`Cambiando a: ${G[X]?.label||"recorte"}...`}),l.jsxs("cropper-canvas",{ref:ve,style:{width:"100%",height:"100%",display:"block"},background:!!x||void 0,id:"limbo-cropperjs-canvas",tabindex:"-1",onKeyDown:e=>{"Delete"!==e.key&&"Backspace"!==e.key||(e.preventDefault(),e.stopPropagation())},children:[l.jsx("cropper-image",{ref:ye,src:k,alt:t.filename,id:"limbo-cropperjs-image",action:"move",crossOrigin:"anonymous",rotatable:!0,scalable:!0,skewable:!0,translatable:!0}),l.jsxs("cropper-selection",{ref:we,"initial-coverage":"0.5",movable:!0,resizable:!0,keyboard:"true",action:"move",style:{cursor:"move",minWidth:`${ee.minWidth}px`,minHeight:`${ee.minHeight}px`},"data-prevent-delete":"true",tabindex:"-1",children:[v&&l.jsx("cropper-grid",{role:"grid",action:"move",covered:!0,bordered:!0}),l.jsx("cropper-handle",{action:"move",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"32px",height:"32px",zIndex:"10"}}),l.jsx("cropper-handle",{action:"n-resize"}),l.jsx("cropper-handle",{action:"e-resize"}),l.jsx("cropper-handle",{action:"s-resize"}),l.jsx("cropper-handle",{action:"w-resize"}),l.jsx("cropper-handle",{action:"ne-resize"}),l.jsx("cropper-handle",{action:"nw-resize"}),l.jsx("cropper-handle",{action:"se-resize"}),l.jsx("cropper-handle",{action:"sw-resize"})]})]})]})}),l.jsx("div",{className:"lb:w-full lb:lg:max-w-80 lb:mt-2 lb:lg:my-0 lb:overflow-y-auto lb:bg-white lb:border-t lb:lg:border-t-0 lb:lg:border-l lb:border-gray-200 lb:shrink-0",children:l.jsxs("div",{className:"lb:h-full lb:mt-2 lb:lg:my-0 lb:me-2 lb:lg:mx-2 lb:space-y-2 lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:flex-wrap lb:md:flex-nowrap lb:items-start lb:flex-row lb:gap-2 lb:lg:gap-0 lb:lg:block",children:[l.jsxs("div",{className:"lb:bg-white lb:rounded lb:border lb:w-full lb:border-gray-200 lb:mb-2",children:[l.jsx("button",{onClick:Ae,className:"lb:hidden lb:sm:block lb:w-full lb:p-2 lb:mb-05 lb:cursor-pointer lb:hover:bg-neutral-gray-050/50 lb:transition-colors lb:rounded-t-sm","aria-expanded":W,"aria-label":"Mostrar/ocultar opciones de visualización",children:l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[l.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-700",children:"Transformar imagen"}),l.jsx("div",{className:"lb:text-center",children:l.jsx("span",{className:`icon ${W?"icon-chevron-up":"icon-chevron-down"} lb:text-center icon--xs`})})]})}),l.jsxs("div",{className:"lb:p-2 lb:space-y-2 lb:justify-items-stretch lb:static "+(W?"lb:block":"lb:sm:hidden"),children:[l.jsx("div",{className:"lb:mb-3 lb:block",children:l.jsxs("div",{className:"lb:grid lb:grid-cols-5 lb:gap-1 lb:content-center lb:h-fit lb:mx-auto",children:[l.jsx("button",{onClick:()=>Pe(-.2),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Alejar",disabled:ce,"aria-label":"Alejar imagen",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-zoom-out-blue"})})}),l.jsx("button",{onClick:()=>Ie(-10,-10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover arriba-izquierda",disabled:ce,"aria-label":"Mover imagen hacia arriba-izquierda",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-arrow-up-blue icon--md lb:-rotate-45"})})}),l.jsx("button",{onClick:()=>Ie(0,-10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover arriba",disabled:ce,"aria-label":"Mover imagen hacia arriba",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-arrow-up-blue icon--md"})})}),l.jsx("button",{onClick:()=>Ie(10,-10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover arriba-derecha",disabled:ce,"aria-label":"Mover imagen hacia arriba-derecha",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-arrow-up-blue icon--md lb:rotate-45"})})}),l.jsx("button",{onClick:()=>Pe(.2),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Acercar 20%",disabled:ce,"aria-label":"Acercar imagen",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-zoom-in-blue"})})}),l.jsx("button",{onClick:()=>De(-45),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Rotar -45°",disabled:ce,"aria-label":"Rotar imagen 45 grados a la izquierda",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"lb:text-brand-blue-1000 lb:font-medium",children:"-45°"})})}),l.jsx("button",{onClick:()=>Ie(-10,0),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover izquierda",disabled:ce,"aria-label":"Mover imagen hacia la izquierda",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-arrow-left-blue"})})}),l.jsx("button",{onClick:ze,className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Centrar y ajustar imagen",disabled:ce,"aria-label":"Centrar y ajustar imagen",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-radio-button-blue icon-md"})})}),l.jsx("button",{onClick:()=>Ie(10,0),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover derecha",disabled:ce,"aria-label":"Mover imagen hacia la derecha",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-arrow-right-blue"})})}),l.jsx("button",{onClick:()=>De(45),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Rotar +45°",disabled:ce,"aria-label":"Rotar imagen 45 grados a la derecha",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"lb:text-brand-blue-1000 lb:font-medium",children:"+45°"})})}),l.jsx("button",{onClick:Fe,className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:aspect-square "+(P.horizontal?"lb:bg-blue-100 lb:border lb:border-blue-300 lb:text-blue-800":"lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200"),title:"Voltear horizontalmente "+(P.horizontal?"(activo)":""),disabled:ce,"aria-label":"Voltear imagen horizontalmente","aria-pressed":P.horizontal,children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center lb:gap-2",children:l.jsx("span",{className:"icon icon-arrow-left-right-blue lb:border lb:border-brand-blue-1000 lb:rounded"})})}),l.jsx("button",{onClick:()=>Ie(-10,10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover abajo-izquierda",disabled:ce,"aria-label":"Mover imagen hacia abajo-izquierda",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-arrow-up-blue icon--md lb:-rotate-145"})})}),l.jsx("button",{onClick:()=>Ie(0,10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover abajo",disabled:ce,"aria-label":"Mover imagen hacia abajo",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-arrow-down-blue"})})}),l.jsx("button",{onClick:()=>Ie(10,10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover abajo-derecha",disabled:ce,"aria-label":"Mover imagen hacia abajo-derecha",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-arrow-up-blue icon--md lb:rotate-145"})})}),l.jsx("button",{onClick:Ue,className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:aspect-square lb:text-sm "+(P.vertical?"lb:bg-blue-100 lb:border lb:border-blue-300 lb:text-blue-800":"lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200"),title:"Voltear verticalmente "+(P.vertical?"(activo)":""),disabled:ce,"aria-label":"Voltear imagen verticalmente","aria-pressed":P.vertical,children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-arrow-up-down-blue lb:border lb:border-brand-blue-1000 lb:rounded"})})})]})}),l.jsx("div",{className:"lb:flex lb:flex-col lb:gap-2",children:l.jsx("button",{onClick:()=>{he.reset(),D({horizontal:!1,vertical:!1})},className:"lb:w-full lb:p-2 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",title:"Reiniciar transformaciones",disabled:ce,"aria-label":"Reiniciar todas las transformaciones de la imagen",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsxs("span",{children:[l.jsx("span",{className:"icon icon-refresh-blue icon--sm lb:align-[middle!important] "})," ","Reiniciar ajustes"]})})})})]})]}),l.jsxs("div",{className:"lb:bg-white lb:rounded lb:border lb:border-gray-200 lb:w-full"+(B?"":" lb:bg-neutral-gray-50/50"),children:[l.jsx("button",{onClick:Te,className:"lb:hidden lb:sm:block lb:w-full lb:cursor-pointer lb:hover:bg-neutral-gray-050/50 lb:p-2 lb:mb-05 lb:transition-colors lb:rounded-t-sm","aria-expanded":B,"aria-label":"Mostrar/ocultar opciones de visualizción",children:l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[l.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-700",children:"Ajustes del selector"}),l.jsx("div",{className:"lb:text-center",children:l.jsx("span",{className:`icon ${B?"icon-chevron-up":"icon-chevron-down"} lb:text-center icon--xs`})})]})}),l.jsxs("div",{className:"lb:p-2 lb:space-y-2 lb:justify-items-stretch lb:static "+(B?"lb:block":"lb:sm:hidden"),children:[l.jsx("div",{children:l.jsxs("div",{className:"lb:grid lb:grid-cols-2 lb:gap-2",children:[l.jsx("button",{onClick:()=>Oe(.5),className:"lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-xs lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",disabled:ce,"aria-label":"Selección 50%",title:"Tamaño de selector 50%",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{children:"50%"})})}),l.jsx("button",{onClick:()=>Oe(.7),className:"lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-xs lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",disabled:ce,"aria-label":"Selección 70%",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{children:"70%"})})}),l.jsx("button",{onClick:()=>Oe(.9),className:"lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-xs lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",disabled:ce,"aria-label":"Selección 90%",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{children:"90%"})})}),l.jsx("button",{onClick:()=>Oe(1),className:"lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-xs lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",disabled:ce,"aria-label":"Selección completa",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{children:"100%"})})})]})}),l.jsxs("div",{className:"lb:space-y-2 lb:pt-2",children:[l.jsx("button",{onClick:Le,className:"lb:w-full lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",title:"Centrar selección",disabled:ce,"aria-label":"Centrar área de selección",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsxs("span",{children:[l.jsx("span",{className:"icon icon-radio-button icon--sm lb:align-[middle!important] "})," ","Centrar selección"]})})}),l.jsx("button",{onClick:Me,className:"lb:w-full lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",title:"Reiniciar selección",disabled:ce,"aria-label":"Reiniciar área de selección",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsxs("span",{children:[l.jsx("span",{className:"icon icon-refresh icon--sm lb:align-[middle!important]"})," ","Reset selección"]})})})]})]})]}),l.jsxs("div",{className:"lb:bg-white lb:rounded lb:border lb:border-gray-200 lb:w-full",children:[l.jsx("button",{onClick:_e,className:"lb:hidden lb:sm:block lb:w-full lb:cursor-pointer lb:hover:bg-neutral-gray-050/50 lb:transition-colors lb:rounded-t-sm lb:mb-05 lb:p-2","aria-expanded":F,"aria-label":"Mostrar/ocultar opciones de visualización",children:l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[l.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-700",children:"Visualización"}),l.jsx("div",{className:"lb:text-center",children:l.jsx("span",{className:`icon ${F?"icon-chevron-up":"icon-chevron-down"} lb:text-center icon--xs`})})]})}),l.jsxs("div",{className:"lb:py-2 lb:space-y-2 lb:justify-items-stretch lb:static "+(F?"lb:block":"lb:sm:hidden"),children:[l.jsxs("button",{onClick:Ee,className:"lb:w-auto lb:flex lb:cursor-pointer lb:items-center lb:justify-between lb:mx-2 lb:p-1 lb:rounded lb:transition-colors "+(v?"lb:bg-blue-100 lb:border lb:border-blue-300 lb:text-blue-800":"lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200"),disabled:ce,"aria-pressed":v,title:"Mostrar/ocultar cuadrícula de la regla de los tercios en el selector","aria-label":"Activar/desactivar grid",children:[l.jsxs("span",{className:"lb:text-sm lb:flex lb:items-center",children:[l.jsx("span",{className:"icon icon-area-blue lb:me-1"})," ","Cuadrícula"]}),l.jsx("span",{className:"lb:text-xs",children:v?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"icon icon-tick icon--xs lb:align-[middle!important] lb:-mt-0.5"})," ","Activo"]}):"Inactivo"})]}),l.jsxs("button",{onClick:$e,className:"lb:w-auto lb:flex lb:cursor-pointer lb:items-center lb:justify-between lb:mx-2 lb:p-1 lb:rounded lb:transition-colors "+(x?"lb:bg-blue-100 lb:border lb:border-blue-300 lb:text-blue-800":"lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200"),disabled:ce,"aria-pressed":x,"aria-label":"Activar/desactivar sombreado",children:[l.jsxs("span",{className:"lb:text-sm lb:flex lb:items-center",children:[l.jsx("span",{className:"icon icon-comparison-blue lb:me-1"})," ","Tablero"]}),l.jsx("span",{className:"lb:text-xs",children:x?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"icon icon-tick icon--xs lb:align-[middle!important] lb:-mt-0.5"})," ","Activo"]}):"Inactivo"})]})]})]})]})})]}),l.jsxs("div",{className:"lb:flex lb:justify-between lb:shrink-0 lb:border-t lb:border-gray-200 lb:bg-white lb:mx-2 lb:mt-1 lb:py-2 lb:lg:gap-0",children:[l.jsxs("button",{onClick:()=>O(!0),className:"lb:text-nowrap lb:block lb:cursor-pointer lb:lg:flex lb:items-center lb:gap-2 lb:px-2 lb:py-1 lb:bg-gradient-to-br lb:from-brand-blue-50 lb:to-green-50 lb:hover:from-brand-blue-100 lb:hover:to-green-100 lb:border lb:border-blue-200 lb:rounded-lg lb:shadow-sm lb:transition-colors","aria-label":"Abrir guía de uso",children:[l.jsx("span",{className:"icon icon-lightbulb lb:text-yellow-500"}),l.jsx("span",{className:"lb:text-sm lb:font-semibold lb:text-blue-800",children:"Guía de uso"}),l.jsx("span",{className:"icon icon-arrow-down lb:scale-75 lb:-rotate-145"})]}),l.jsx("button",{onClick:Je,disabled:ce||!Se,className:`lb:px-3 lb:cursor-pointer lb:py-1.5 lb:text-sm lb:rounded lb:transition-colors ${b?"lb:bg-red-1000 lb:hover:bg-red-800 lb:text-white":"lb:bg-brand-blue-800 lb:hover:bg-brand-blue-1000 lb:text-white"} lb:disabled:opacity-50 lb:disabled:cursor-not-allowed`,"aria-label":"Vista previa",title:"Mostrar/Ocultar vista previa",children:l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-1",children:[l.jsx("span",{className:"icon icon-search-white icon--sm"}),l.jsx("span",{className:"lb:hidden lb:sm:inline lb:whitespace-nowrap",children:b?"Cerrar previa":"Vista previa"})]})}),l.jsxs("div",{className:"lb:flex lb:flex-row lb:gap-1 lb:lg:gap-2 lb:items-center lb:justify-end",children:[l.jsx("button",{onClick:bt,disabled:ce||!Se,className:"lb:cursor-pointer lb:px-3 lb:py-1.5 lb:text-sm lb:rounded lb:bg-brand-blue-800 lb:hover:bg-brand-blue-1000 lb:text-white lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":"Descargar",title:"Descargar recorte sin guardar",children:l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-1",children:[l.jsx("span",{className:"icon icon-download-white icon--sm"}),l.jsx("span",{className:"lb:hidden lb:md:inline lb:whitespace-nowrap",children:"Descargar"})]})}),t.file&&l.jsx("button",{onClick:ht,disabled:ce||u,className:"lb:px-3 lb:cursor-pointer lb:py-1.5 lb:text-sm lb:rounded lb:bg-teal-600 lb:hover:bg-teal-700 lb:text-white lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":"Conservar solo imagen original sin crear recortes",title:"Subir y guardar la imagen original sin crear recortes",children:l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-1",children:[l.jsx("span",{className:"icon icon-tick-white icon--sm"}),l.jsx("span",{className:"lb:hidden lb:md:inline lb:whitespace-nowrap",children:"Guardar sin recortar"})]})}),l.jsx("button",{onClick:st,disabled:ce||!ke||!Ne||!Se||!me.isReady,className:"lb:px-3 lb:cursor-pointer lb:py-1.5 lb:text-sm lb:rounded lb:bg-green-600 lb:hover:bg-green-700 lb:text-white lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed",title:"Guardar imagen recortada",children:l.jsx("div",{className:"lb:flex lb:items-center lb:gap-1",children:ce?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"icon icon-save-white icon--sm"}),l.jsx("span",{children:"Guardando..."})]}):l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"icon icon-save-white icon--sm"}),l.jsx("span",{className:"lb:hidden lb:md:inline lb:whitespace-nowrap",children:"Guardar recorte"})]})})})]})]}),te&&l.jsx("div",{className:"lb:fixed lb:inset-0 lb:bg-black lb:bg-opacity-50 lb:flex lb:items-center lb:justify-center lb:z-[9999] lb:p-4",children:l.jsxs("div",{className:"lb:bg-white lb:rounded-lg lb:shadow-xl lb:max-w-lg lb:w-full lb:max-h-[80vh] lb:overflow-hidden lb:flex lb:flex-col",children:[l.jsxs("div",{className:"lb:px-6 lb:py-4 lb:border-b lb:border-gray-200",children:[l.jsx("h3",{className:"lb:text-lg lb:font-semibold lb:text-gray-800",children:"save"===re?"Seleccionar recortes a guardar":"Seleccionar recortes a descargar"}),l.jsxs("p",{className:"lb:text-sm lb:text-gray-600 lb:mt-1",children:["Marca los recortes que deseas"," ","save"===re?"guardar":"descargar"]})]}),l.jsx("div",{className:"lb:px-6 lb:py-4 lb:overflow-y-auto lb:flex-1",children:l.jsx("div",{className:"lb:space-y-2",children:G.map((e,t)=>{const n=e.savedState||t===X,a=!e.required&&!n,r=e.required&&"save"===re;return l.jsxs("label",{className:`lb:flex lb:items-center lb:gap-3 lb:p-3 lb:rounded lb:border lb:transition-colors ${ne.includes(t)?"lb:bg-blue-50 lb:border-blue-300":a?"lb:bg-gray-100 lb:border-gray-300 lb:opacity-60":"lb:bg-gray-50 lb:border-gray-200 lb:hover:bg-gray-100"} ${a||r?"lb:cursor-not-allowed":"lb:cursor-pointer"}`,title:r?"Este recorte es obligatorio y debe ser guardado":"",children:[l.jsx("input",{type:"checkbox",checked:ne.includes(t),disabled:a||r,onChange:e=>{e.target.checked?ae(e=>[...e,t]):ae(e=>e.filter(e=>e!==t))},className:"lb:w-4 lb:h-4 lb:text-blue-600"}),l.jsxs("div",{className:"lb:flex-1 lb:min-w-0",children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:flex-wrap",children:[l.jsxs("span",{title:"Nombre del archivo a descargar",className:"lb:text-sm lb:font-medium lb:text-gray-800 lb:truncate",children:[e.label,"_",e.width,"_",e.height]}),e.required&&l.jsx("span",{className:"lb:text-xs lb:px-1.5 lb:py-0.5 lb:bg-red-200 lb:text-red-1000 lb:rounded lb:whitespace-nowrap",children:"Obligatorio"}),!n&&!e.required&&l.jsx("span",{className:"lb:text-xs lb:px-1.5 lb:py-0.5 lb:bg-orange-100 lb:text-orange-700 lb:rounded lb:whitespace-nowrap",children:"Sin configurar"})]}),l.jsxs("span",{title:"Dimensiones del recorte",className:"lb:text-xs lb:text-gray-500",children:[e.width," × ",e.height," px"]})]})]},e.id)})})}),l.jsxs("div",{className:"lb:px-6 lb:py-4 lb:border-t lb:border-gray-200 lb:flex lb:gap-3 lb:justify-end",children:[l.jsx("button",{onClick:()=>{le(!1),ie(null),ae([])},className:"limbo-btn limbo-btn-secondary lb:px-4 lb:py-2",children:"Cancelar"}),l.jsxs("button",{onClick:async()=>{if(le(!1),"save"===re)if(1===ne.length){const e=X;Y(ne[0]),await new Promise(e=>setTimeout(e,100)),await it(),Y(e)}else await ot(ne);else if(1===ne.length){const e=X;Y(ne[0]),await new Promise(e=>setTimeout(e,100)),await dt(),Y(e)}else await ut(ne);ie(null),ae([])},disabled:0===ne.length,className:"limbo-btn limbo-btn-primary lb:px-4 lb:py-2 lb:disabled:opacity-50 lb:disabled:cursor-not-allowed",children:["save"===re?"Guardar":"Descargar"," (",ne.length,")"]})]})]})}),R&&l.jsx("div",{className:"lb:fixed lb:inset-0 lb:bg-black/50 lb:flex lb:items-center lb:justify-center lb:z-[9999] lb:p-4",children:l.jsxs("div",{className:"lb:bg-white lb:rounded-lg lb:shadow-xl lb:max-w-5xl lb:w-full lb:max-h-[90vh] lb:overflow-hidden lb:flex lb:flex-col",children:[l.jsx("div",{className:"lb:px-6 lb:py-4 lb:border-b lb:border-gray-200 lb:bg-brand-blue-50",children:l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[l.jsxs("h3",{className:"lb:text-xl lb:font-semibold lb:text-brand-blue-1000 lb:flex lb:items-center lb:gap-2",children:[l.jsx("span",{className:"icon icon-lightbulb lb:text-yellow-500"}),"Guía de uso del Cropper"]}),l.jsx("button",{onClick:()=>O(!1),className:"lb:text-gray-400 lb:hover:text-gray-600 lb:p-1 lb:rounded-full lb:hover:bg-gray-100 lb:transition-colors","aria-label":"Cerrar modal",children:l.jsx("span",{className:"icon icon-close-small icon--lg"})})]})}),l.jsxs("div",{className:"lb:px-6 lb:py-4 lb:overflow-y-auto lb:flex-1 lb:space-y-4",children:[l.jsxs("div",{className:"lb:bg-brand-blue-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-brand-blue-400",children:[l.jsx("h4",{className:"lb:font-semibold lb:text-brand-blue-1000 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"🖱️ Navegación básica"}),l.jsxs("div",{className:"lb:text-sm lb:text-brand-blue-800 lb:space-y-2",children:[l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Arrastra la imagen:"})," Haz clic sobre la imagen dentro del área de selección y arrástrala para reposicionarla"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Zoom:"})," Usa la rueda del ratón sobre el canvas (fuera del área de selección) para hacer zoom"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Vista completa:"}),' Botón "Reset zoom" para ajustar automáticamente al tamaño óptimo']})]})]})]}),l.jsxs("div",{className:"lb:bg-brand-blue-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-brand-blue-400",children:[l.jsx("h4",{className:"lb:font-semibold lb:text-brand-blue-1000 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"✂️ Área de selección"}),l.jsxs("div",{className:"lb:text-sm lb:text-brand-blue-800 lb:space-y-2",children:[l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Mover selección:"})," Arrastra desde el centro",l.jsx("span",{className:"icon lb:bg-white icon-move lb:inline-block lb:mx-1 lb:align-middle lb:border lb:border-brand-blue-400 lb:rounded-full"}),"para reposicionar el área de recorte"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Redimensionar:"})," Arrastra desde las esquinas o bordes para cambiar el tamaño del área"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Tamaños rápidos:"})," Usa los botones de porcentaje (50%, 70%, 90%, 100%) para ajustar rápidamente el tamaño"]})]})]})]}),l.jsxs("div",{className:"lb:bg-brand-blue-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-brand-blue-400",children:[l.jsx("h4",{className:"lb:font-semibold lb:text-brand-blue-1000 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"⌨️ Atajos de teclado"}),l.jsxs("div",{className:"lb:text-sm lb:text-brand-blue-800 lb:space-y-2",children:[l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Flechas:"}),l.jsxs("span",{className:"lb:inline-flex lb:gap-1 lb:mx-1",children:[l.jsx("span",{className:"icon icon-arrow-right-box lb:rotate-180 icon--sm"}),l.jsx("span",{className:"icon icon-arrow-right-box icon--sm"}),l.jsx("span",{className:"icon icon-arrow-right-box lb:-rotate-90 icon--sm"}),l.jsx("span",{className:"icon icon-arrow-right-box lb:rotate-90 icon--sm"})]}),"Mueven la selección en incrementos de 10px"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Shift + Arrastrar:"})," Mantiene las proporciones al redimensionar el área de selección"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Ctrl + Rueda:"})," Control de zoom más preciso y fino"]})]})]})]}),l.jsxs("div",{className:"lb:bg-teal-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-teal-800",children:[l.jsx("h4",{className:"lb:font-semibold lb:text-teal-1000 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"👁️ Opciones de visualización"}),l.jsxs("div",{className:"lb:text-sm lb:text-teal-800 lb:space-y-2",children:[l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Cuadrícula:"})," Muestra la regla de los tercios para mejorar la composición de tus recortes"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Tablero:"})," Patrón de cuadros para alinear mejor las medidas o ver imágenes con transparencia"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Vista previa:"})," Muestra cómo quedará el recorte final antes de guardarlo"]})]})]})]}),l.jsxs("div",{className:"lb:bg-amber-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-amber-400",children:[l.jsx("h4",{className:"lb:font-semibold lb:text-amber-800 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"💡 Consejos profesionales"}),l.jsxs("div",{className:"lb:text-sm lb:text-amber-700 lb:space-y-2",children:[l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Orden de trabajo:"})," Primero aplica transformaciones (rotar, voltear), luego haz el recorte final"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Múltiples recortes:"})," Si tienes varios recortes configurados, revisa cada uno antes de guardar"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Calidad:"})," Las imágenes se exportan en alta calidad (JPEG 90%) manteniendo la mayor nitidez posible"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Proporciones:"})," Usa Shift al redimensionar para mantener el aspecto ratio original"]})]})]})]}),l.jsxs("div",{className:"lb:bg-orange-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-orange-500",children:[l.jsx("h4",{className:"lb:font-semibold lb:text-orange-800 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"⚠️ Notas importantes"}),l.jsxs("div",{className:"lb:text-sm lb:text-orange-700 lb:space-y-2",children:[l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Recortes grandes:"})," Imágenes de alta resolución pueden tardar más en procesarse"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Calidad de escala:"})," Evita ampliar demasiado áreas pequeñas, ya que puede afectar la nitidez"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Cambios pendientes:"})," Recuerda guardar tus cambios antes de cerrar o cambiar de imagen"]})]})]})]})]}),l.jsx("div",{className:"lb:px-6 lb:py-4 lb:border-t lb:border-gray-200 lb:bg-gray-50",children:l.jsx("button",{onClick:()=>O(!1),className:"limbo-btn limbo-btn-primary lb:w-full",children:"Entendido"})})]})}),b&&l.jsx("div",{className:"lb:min-w-[90%] lb:fixed lb:md:absolute lb:inset-0 lb:md:inset-auto lb:bg-black/50 lb:md:bg-transparent lb:flex lb:items-center lb:justify-center lb:md:block lb:z-9999 lb:md:z-50 lb:pointer-events-none",onClick:e=>{e.target===e.currentTarget&&window.innerWidth<768&&(m(!1),p(null))},children:l.jsxs("div",{className:"lb:pointer-events-auto lb:bg-white lb:rounded-lg lb:shadow-2xl lb:border-2 lb:border-brand-blue-800 lb:overflow-hidden lb:flex lb:flex-col lb:max-w-md lb:w-full lb:mx-4 lb:md:mx-0 lb:max-h-[80vh] lb:md:max-h-[600px]",style:{...window.innerWidth>=768?{position:"absolute",left:`${S.x}px`,top:`${S.y}px`,width:"420px",cursor:N?"grabbing":"default"}:{}},onMouseDown:Ze,onTouchStart:lt,children:[l.jsxs("div",{className:"limbo-preview-modal-header lb:px-4 lb:py-3 lb:bg-linear-to-r lb:from-brand-blue-800 lb:to-brand-blue-1000 lb:text-white lb:flex lb:items-center lb:justify-between lb:cursor-grab lb:active:cursor-grabbing lb:select-none",style:{cursor:N?"grabbing":"grab"},children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2",children:[l.jsx("span",{className:"icon icon-search-white icon--sm"}),l.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-white",children:"Vista previa"})]}),l.jsx("button",{onClick:()=>{m(!1),p(null)},className:"lb:flex lb:p-1 lb:hover:bg-white/20 lb:rounded lb:transition-colors lb:cursor-pointer lb:aspect-square lb:min-w-fit lb:min-h-fit","aria-label":"Cerrar vista previa",title:"Cerrar vista previa",children:l.jsx("span",{className:"icon icon-close-small-white icon--sm lb:p-0 lb:m-0 lb:py-auto lb:my-auto lb:mx-auto"})})]}),l.jsx("div",{className:"lb:flex-1 lb:overflow-auto lb:bg-gray-50 lb:p-4",children:f?l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center lb:h-full lb:min-h-[200px]",children:l.jsxs("div",{className:"lb:text-center",children:[l.jsx("div",{className:"lb:animate-spin lb:rounded-full lb:h-12 lb:w-12 lb:border-b-2 lb:border-blue-600 lb:mx-auto lb:mb-3"}),l.jsx("p",{className:"lb:text-sm lb:text-gray-600",children:"Generando vista previa..."})]})}):h?l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-3",children:[l.jsxs("div",{className:"lb:relative lb:w-full lb:bg-white lb:rounded-lg lb:border lb:border-gray-200 lb:overflow-hidden lb:shadow-sm lb:cursor-zoom-in lb:hover:ring-2 lb:hover:ring-brand-blue-800 lb:transition-all",onClick:()=>A(!0),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),A(!0))},"aria-label":"Click para ver recorte en tamaño completo",title:"Click para ampliar",children:[l.jsx("img",{src:h,alt:"Vista previa del recorte",className:"lb:w-full lb:h-auto lb:object-contain lb:max-h-[400px]"}),l.jsxs("div",{className:"lb:absolute lb:top-2 lb:right-2 lb:bg-black/60 lb:text-white lb:px-2 lb:py-1 lb:rounded lb:text-xs lb:flex lb:items-center lb:gap-1",children:[l.jsx("span",{className:"icon icon-search-white icon--xs"}),l.jsx("span",{children:"Ampliar"})]})]}),l.jsxs("div",{className:"lb:text-center lb:text-xs lb:text-gray-500",children:[l.jsx("p",{className:"lb:font-medium lb:text-gray-700 lb:mb-1",children:J?.label||"Recorte"}),l.jsxs("p",{children:[J?.width," × ",J?.height," px"]})]})]}):l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center lb:h-full lb:min-h-[200px]",children:l.jsx("p",{className:"lb:text-sm lb:text-gray-500",children:"No se pudo generar la vista previa"})})}),l.jsx("div",{className:"lb:px-4 lb:py-2 lb:bg-gray-100 lb:border-t lb:border-gray-200",children:l.jsxs("p",{className:"lb:text-xs lb:text-gray-600 lb:text-center",children:[l.jsxs("span",{className:"lb:hidden lb:md:inline",children:["Arrastra desde el título para mover •"," "]}),"Actualización automática al editar"]})})]})}),l.jsx(Re,{src:h,alt:"Vista previa del recorte",title:J?.label||"Recorte",subtitle:`${J?.width||0} × ${J?.height||0} px`,isOpen:T&&!!h,onClose:()=>A(!1)})]}):null}function Tn({onSave:e,onCancel:t,onError:n,onVariantCreated:a,onUploadAndCrop:r,onVideoSelect:i,onUploadWithFolder:o,onFolderChange:s,onDelete:c,isActionAllowed:u,selectedImage:d,uploading:b,uploadError:m,deleting:h,selectedUploadFolder:p,modeUI:f,apiKey:g,prod:v,allowedCategories:y,resolvedAccept:x,returnConfig:w,folderConfig:k,cropperConfig:C,resetUpload:S}){return l.jsxs(l.Fragment,{children:[d&&l.jsx(_n,{image:d,onSave:e,onCancel:t,onDelete:d?.id&&u("delete")?()=>c(d.id):null,onError:n,deleting:h,onVariantCreated:a,onUpload:d?.tags?e=>o(e,d.tags):o,uploading:b,cropperConfig:C}),!d&&("crop-only"===f?l.jsxs("div",{children:[b&&l.jsx(tt,{text:"Subiendo archivo..."}),m&&l.jsxs(fe,{variant:"danger",toast:!0,onClose:S,children:["Error al subir archivo: ",m]}),l.jsx(Bt,{onSelect:r,onVideoSelect:i,disabled:b,apiKey:g,prod:v,allowedCategories:y,resolvedAccept:x,returnConfig:w,folderConfig:k,selectedFolder:p,onFolderChange:s})]}):l.jsxs("div",{className:"limbo-empty-state lb:flex lb:flex-col lb:items-center lb:justify-center lb:py-12 lb:px-6 lb:text-center",children:[l.jsx("div",{className:"lb:text-gray-400 lb:mb-4",children:l.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),l.jsx("p",{className:"lb:text-gray-600 lb:mb-4",children:"Selecciona una imagen de la galería para comenzar a recortar."})]}))]})}function An({apiKey:t,onClose:n,prod:a=!1,features:r=["gallery","upload","cropper"],modeUI:i="full",ui:o={showActions:["select","download","copy","delete","crop","variants","rename"],hideActions:[],theme:"light",language:"es",compactMode:!1,showTabs:!0},callbacks:c={},instanceId:u=null,itemsPerPage:d=30,_externalImage:b=null,cropperConfig:m=null,folderConfig:h={include:[],exclude:[],includeNoFolder:!0,showFolderSelector:!0,showFolderFilter:!0,showFolderInfo:!0,allowMoveFolder:!0,allowCreateFolder:!0,defaultFolder:null},allowedCategories:p=null,accept:f=null,returnConfig:g=null,aiStarterPrompt:v}){const y=e.useRef(c);e.useEffect(()=>{y.current=c},[c]);const x=e.useRef(null);ie(x,{onClose:n}),e.useEffect(()=>{je(),["limbo_stock_selectedService","limbo_stock_dynamicForm","limbo_stock_stockImages","limbo_stock_currentPage","limbo_stock_paginationInfo","limbo_portals_searchName","limbo_portals_limit","limbo_portals_currentPage","limbo_portals_images","limbo_portals_portalResults","limbo_portals_paginationInfo"].forEach(e=>sessionStorage.removeItem(e))},[]),e.useEffect(()=>{const e=()=>{["limbo_stock_selectedService","limbo_stock_dynamicForm","limbo_stock_stockImages","limbo_stock_currentPage","limbo_stock_paginationInfo","limbo_portals_searchName","limbo_portals_limit","limbo_portals_currentPage","limbo_portals_images","limbo_portals_portalResults","limbo_portals_paginationInfo"].forEach(e=>sessionStorage.removeItem(e)),be(),je()},t=t=>{t.persisted&&e()};let l=null;const n=()=>{"hidden"===document.visibilityState?l=Date.now():"visible"===document.visibilityState&&null!==l&&(Date.now()-l>18e5&&e(),l=null)};return window.addEventListener("pageshow",t),document.addEventListener("visibilitychange",n),()=>{window.removeEventListener("pageshow",t),document.removeEventListener("visibilitychange",n)}},[]);const[w,k]=e.useState({name:"",uploadedBy:"",dateFrom:"",dateTo:"",assetType:"",folder:""}),[C,S]=e.useState(h?.defaultFolder||null),[j,N]=e.useState([]),[E,$]=e.useState(null),z=A(w.name,400),L=A(w.uploadedBy,400),M=e.useMemo(()=>s(f||(p?p.map(e=>`${e}/*`).join(","):null)),[f,p]),I=e=>!!e&&(e.startsWith("image/")&&"image/gif"!==e),P=(()=>{let e;switch(i){case"gallery-only":e=["gallery"];break;case"upload-only":e=["upload","cropper"];break;case"crop-only":e=["cropper"];break;case"ia-only":e=["ia"];break;default:e=[...r]}return M.isAllTypes||M.includesImages||(e=e.filter(e=>"cropper"!==e)),e})(),D=()=>P.includes("gallery")?"gallery":P.includes("upload")?"upload":P.includes("cropper")?"cropper":P.includes("ia")?"ia":P[0]||"gallery",[R,O]=e.useState(D()),[F,U]=e.useState(null),W=e.useRef(null);e.useEffect(()=>{!F&&W.current&&(URL.revokeObjectURL(W.current),W.current=null)},[F]);const[V,H]=e.useState(null);e.useEffect(()=>{b&&(console.log("📸 Imagen externa detectada:",b),U(b),O("cropper"))},[b]),e.useEffect(()=>{const e=()=>{console.log("[App] Modal cerrado, reseteando estado..."),U(null),O(D())};return window.limboCore?.events&&window.limboCore.events.on("modal:closed",e),()=>{window.limboCore?.events&&window.limboCore.events.off("modal:closed",e)}},[]);const[K,G]=e.useState(1),{isTokenExpired:Q,handleTokenExpiredClose:X,handleTokenExpiredReload:Y}=function(){const[t,l]=e.useState(!1),[n,a]=e.useState(!1),r=e.useCallback(async()=>{const e=q();if("jwt"!==e.authMode||!e.tokenProvider)return!1;a(!0);try{return B(await e.tokenProvider()),l(!1),!0}catch{return!1}finally{a(!1)}},[]),i=e.useCallback(e=>{if(401===e?.response?.status){const t=e.response.data;if("token_expired"===t?.error||t?.message?.includes("expired")||t?.message?.includes("caducado")||"string"==typeof t?.error&&t.error.includes("expired"))return l(!0),!0}return!1},[]),o=e.useCallback(()=>{l(!1)},[]),s=e.useCallback(()=>{l(!1),window.location.reload()},[]);return e.useEffect(()=>{const e=e=>{if(!e.detail?.error)return;const t=q();i(e.detail.error)&&("jwt"===t.authMode&&t.tokenProvider&&!e.detail.refreshAttempted?r().then(e=>{e||l(!0)}):l(!0))};return window.addEventListener("tokenExpiredError",e),()=>window.removeEventListener("tokenExpiredError",e)},[i,r]),{isTokenExpired:t,isRefreshing:n,checkTokenExpiration:i,handleTokenExpiredClose:o,handleTokenExpiredReload:s,tryRefreshToken:r}}(),{upload:J,loading:Z,error:le,uploadedImage:ne,reset:ae}=function(){const[t,l]=e.useState(!1),[n,a]=e.useState(null),[r,i]=e.useState(null);return{upload:async(e,t=null,n=null,r=null)=>{if(!e)return a("No se ha proporcionado ningún archivo"),null;l(!0),a(null),i(null);try{const l="object"==typeof n?n?.slug:n,a=await ee(e,t,!1,l,r),o=a.result||a;return i(o),o}catch(o){return a(o.message),null}finally{l(!1)}},loading:t,error:n,uploadedImage:r,reset:()=>{a(null),i(null)}}}(),{deleteImg:re,loading:ce,error:ue,reset:de}=se(),ge=e.useMemo(()=>({limit:d,page:K,...z&&{q:z},...L&&{uploadedBy:L},...w.dateFrom&&{dateFrom:w.dateFrom},...w.dateTo&&{dateTo:w.dateTo},...w.assetType&&{asset_type:w.assetType},...!M.isAllTypes&&M.raw&&{accept:M.raw},...w.folder&&{folder:w.folder},...h.include?.length>0&&{folders_include:h.include.join(",")},...0===h.include?.length&&h.exclude?.length>0&&{folders_exclude:h.exclude.join(",")},...(h.include?.length>0||h.exclude?.length>0)&&void 0!==h.includeNoFolder&&{include_no_folder:h.includeNoFolder?"1":"0"}}),[d,K,z,L,w.dateFrom,w.dateTo,w.assetType,w.folder,M.isAllTypes,M.raw,h.include,h.exclude,h.includeNoFolder]),ve=P.includes("gallery"),{images:ye,loading:xe,error:we,pagination:ke,invalidateCache:Ce,setImages:Ne,refetch:Ee}=me(t,a,ge,ve);e.useEffect(()=>{const e=()=>{Ee()};return document.addEventListener("limbo:variantsCleared",e),document.addEventListener("limbo:variantDeleted",e),()=>{document.removeEventListener("limbo:variantsCleared",e),document.removeEventListener("limbo:variantDeleted",e)}},[Ee]);const{refreshVariants:$e}=he(),_e=e.useCallback((e,t=null)=>J(e,null,C?.slug||C,t),[J,C]),{handleDelete:Te,handleAssetFolderChange:Ae,handleRenameAsset:ze,handleEditAsset:Le,handleVariantCreated:Me}=function({callbacksRef:t,deleteImg:l,evictFromCache:n,invalidateCache:a,refreshVariants:r,images:i,setImages:o,setCurrentPage:s,selectedImage:c,setSelectedImage:u,setActiveTab:d}){return{handleDelete:async e=>{if(!confirm("¿Estás seguro de que deseas eliminar este archivo? Esta acción también eliminará todos sus recortes."))return;const r=i.find(t=>t.id===e);await l(e)&&(r?.url&&n(r.url),a(),s(1),o(t=>t.filter(t=>t.id!==e)),c&&c.id===e&&(u(null),d("gallery")),t.current.onDelete&&t.current.onDelete({assetId:e}))},handleAssetFolderChange:async(e,t)=>{const l=t?.slug||null;try{return await te(e.id,{folder:l}),a(),o(l=>l.map(l=>l.id===e.id?{...l,folder:t??null}:l)),t}catch(n){throw console.error("Error al cambiar carpeta:",n),n}},handleRenameAsset:e.useCallback(async(e,t)=>{const l=await te(e.id,{original_filename:t}),n=l?.result||{};return a(),o(l=>l.map(l=>l.id!==e.id?l:{...l,filename:n.filename??t,...n.url&&{url:n.url},...void 0!==n.url_webp&&{url_webp:n.url_webp}})),l},[a,o]),handleEditAsset:e.useCallback(async(e,{name:t,tags:l})=>{const n=await te(e.id,{original_filename:t,tags:l}),r=n?.result||{};return a(),o(n=>n.map(n=>n.id!==e.id?n:{...n,filename:r.filename??t,tags:r.tags??l,...r.url&&{url:r.url},...void 0!==r.url_webp&&{url_webp:r.url_webp}})),n},[a,o]),handleVariantCreated:(e,t)=>{r(e),o(t=>t.map(t=>t.id===e?{...t,variants_count:(t.variants_count||0)+1}:t)),a()}}}({callbacksRef:y,deleteImg:re,evictFromCache:Se,invalidateCache:Ce,refreshVariants:$e,images:ye,setImages:Ne,setCurrentPage:G,selectedImage:F,setSelectedImage:U,setActiveTab:O}),Ie=e.useCallback(e=>{$(e)},[]),Pe=e.useCallback(async({name:e,tags:t})=>{E&&(await Le(E,{name:e,tags:t}),Ee?.())},[E,Le,Ee]),{handleUploadAndCrop:De,handleVideoSelect:Re}=function({callbacksRef:t,upload:l,refetch:n,activeFeatures:a,setActiveTab:r,setSelectedImage:i,setCurrentPage:o,setSuccessMessage:s,instanceId:c,selectedUploadFolder:u,tempBlobUrlRef:d,uploadTags:b=null}){return{handleUploadAndCrop:async(e,s=null)=>{if(!e.type?.startsWith("image/")||"image/gif"===e.type){const i=u?.slug||u,d=await l(e,null,i,s);return void(d&&(n(),o(1),a.includes("gallery")&&r("gallery"),t.current.onUpload&&t.current.onUpload({assetId:d.id,url:d.url,fileName:d.filename,mime:d.mime_type,width:d.width,height:d.height,instanceId:c})))}const m=URL.createObjectURL(e),h=await new Promise(e=>{const t=new Image;t.onload=()=>{e({width:t.naturalWidth,height:t.naturalHeight}),URL.revokeObjectURL(m)},t.onerror=()=>{e({width:1920,height:1080}),URL.revokeObjectURL(m)},t.src=m}),p=s||b,f={file:e,filename:e.name,mime_type:e.type,url:(()=>{const t=URL.createObjectURL(e);return d.current=t,t})(),width:h.width,height:h.height,tags:p};if(i(f),a.includes("cropper"))r("cropper");else{const a=u?.slug||u,i=await l(e,null,a,s);i&&(n(),o(1),r("gallery"),t.current.onUpload&&t.current.onUpload({assetId:i.id,url:i.url,fileName:i.filename,mime:i.mime_type,width:i.width,height:i.height,instanceId:c}))}},handleVideoSelect:e.useCallback(e=>{const l={...e,instanceId:c};t.current.onSelect&&t.current.onSelect(l),window.limboCore?.events&&window.limboCore.events.emit("select",l),"modal"===((window.limboCore?.config?.getGlobal()||{}).mode||"embed")&&window.limboCore?.modals?.closeAllModals(),s(`Vídeo seleccionado: ${e.title||"Sin título"}`),setTimeout(()=>s(null),3e3)},[c,s])}}({callbacksRef:y,upload:J,refetch:Ee,activeFeatures:P,setActiveTab:O,setSelectedImage:U,setCurrentPage:G,setSuccessMessage:H,instanceId:u,selectedUploadFolder:C,tempBlobUrlRef:W,uploadTags:j}),{handleCropSave:Oe,handleCropCancel:Fe,handleCropError:Ue}=function({callbacksRef:e,selectedImage:t,setSelectedImage:l,setActiveTab:n,setImages:a,setCurrentPage:r,setSuccessMessage:i,invalidateCache:o,refetch:s,evictFromCache:c,instanceId:u,activeFeatures:d,modeUI:b}){const m=()=>"crop-only"===b||1===d.length&&"cropper"===d[0]?"crop-only":d.includes("gallery")?"with-gallery":d.includes("upload")&&!d.includes("gallery")?"upload-only":"with-gallery";return{handleCropSave:d=>{const b=m(),h=window.limboCore?.config?.getGlobal()||{},p=h.mode||"embed",f=h.autoHideOnComplete||!1;let g=[],v=null;d.crops&&d.asset?(g=d.crops,v=d.asset):g=d.crops&&Array.isArray(d.crops)?d.crops:Array.isArray(d)?d:[d],v&&"with-gallery"===b&&(a(e=>[v,...e]),r(1),e.current.onUpload&&e.current.onUpload({assetId:v.id,url:v.url,fileName:v.filename,mime:v.mime_type,width:v.width,height:v.height,instanceId:u})),t?.url&&c(t.url),"with-gallery"===b&&(v?s():o());const y=v||t,x=g.some(e=>!0===e.isLocal),w={crops:g,assetId:y?.id,instanceId:u,localCrops:x,asset:y?{id:y.id,url:y.url||y.urlSigned,width:y.width,height:y.height,filename:y.filename,mime_type:y.mime_type}:null};console.log("[App] handleCropSave - callbackPayload:",w),console.log("[App] handleCropSave - crops:",g),console.log("[App] handleCropSave - crops[0]?.url:",g[0]?.url),console.log("[App] handleCropSave - asset:",w.asset),console.log("[App] handleCropSave - callbacksRef.current.onCropsSaved existe:",!!e.current.onCropsSaved),e.current.onCropsSaved?(console.log("[App] Llamando callbacksRef.current.onCropsSaved..."),e.current.onCropsSaved(w),console.log("[App] callbacksRef.current.onCropsSaved ejecutado")):console.warn("[App] ⚠️ callbacksRef.current.onCropsSaved NO existe"),window.limboCore?.events&&window.limboCore.events.emit("cropsSaved",w);const k=g.length;switch(i(`✅ ${k} recorte${1!==k?"s":""} guardado${1!==k?"s":""} correctamente`),setTimeout(()=>i(null),3e3),b){case"with-gallery":"modal"===p?e.current.onCropsSaved||(window.limboCore?.modals?.closeAllModals(),l(null),n("gallery")):(l(null),n("gallery"));break;case"upload-only":"modal"===p?e.current.onCropsSaved||(window.limboCore?.modals?.closeAllModals(),l(null),n("upload")):(l(null),n("upload"));break;case"crop-only":if("modal"===p)e.current.onCropperComplete&&e.current.onCropperComplete({crops:g,instanceId:u}),window.limboCore?.events&&window.limboCore.events.emit("cropperComplete",{crops:g,instanceId:u}),window.limboCore?.modals?.closeAllModals();else if(e.current.onCropperComplete&&e.current.onCropperComplete({crops:g,instanceId:u}),window.limboCore?.events&&window.limboCore.events.emit("cropperComplete",{crops:g,instanceId:u}),f){const e=document.querySelector(`#limbo-instance-${u}`);e&&(e.style.display="none")}}},handleCropCancel:()=>{const a=m(),r=(window.limboCore?.config?.getGlobal()||{}).mode||"embed";switch(e.current.onCropperCancelled&&e.current.onCropperCancelled({assetId:t?.id,instanceId:u}),window.limboCore?.events&&window.limboCore.events.emit("cropperCancelled",{assetId:t?.id,instanceId:u}),a){case"with-gallery":l(null),n("gallery");break;case"upload-only":"modal"===r?window.limboCore?.modals?.closeAllModals():(l(null),n("upload"));break;case"crop-only":"modal"===r?window.limboCore?.modals?.closeAllModals():window.limboCore?.events&&window.limboCore.events.emit("cropperClosed",{instanceId:u,reason:"cancelled"})}},handleCropError:l=>{e.current.onCropperError&&e.current.onCropperError(l,u),window.limboCore?.events&&window.limboCore.events.emit("cropperError",{error:l,assetId:t?.id,instanceId:u}),console.error("Cropper error:",l)}}}({callbacksRef:y,selectedImage:F,setSelectedImage:U,setActiveTab:O,setImages:Ne,setCurrentPage:G,setSuccessMessage:H,invalidateCache:Ce,evictFromCache:Se,refetch:Ee,instanceId:u,activeFeatures:P,modeUI:i}),Be=e=>!o.hideActions?.includes(e)&&(!!o.showActions?.includes(e)||!(o.showActions?.length>0)),qe=[{id:"gallery",label:"Galería",feature:"gallery"},{id:"upload",label:"Subir",feature:"upload"},{id:"cropper",label:"Recortador",hideNonActive:!0,feature:"cropper"}].filter(e=>P.includes(e.feature)),We=e=>{I(e.mime_type||e.original_mime)?(U(e),P.includes("cropper")&&O("cropper")):console.log("[App] ⚠️ Archivo no recortable:",e.mime_type||e.original_mime,"- saltando cropper")};return l.jsxs("div",{ref:x,className:"limbo-app-root",children:[o.showTabs&&"cropper"!=R&&l.jsx(_,{tabs:qe,active:R,onChange:e=>{O(e),"upload"!==e&&ae(),"gallery"!==e&&de()}}),we&&l.jsxs(fe,{variant:"danger",children:["Error al cargar archivos: ",we]}),ue&&l.jsxs(fe,{variant:"danger",children:["Error al eliminar archivo: ",ue]}),V&&l.jsx(fe,{variant:"success",fixed:!0,onClose:()=>H(null),children:V}),"gallery"===R&&l.jsx(lt,{onSelect:e=>{const t=m?.mandatoryCrops?.length>0,l=I(e.mime_type||e.original_mime);if(t&&l&&P.includes("cropper"))return console.log("[App] 📐 MandatoryCrops detectados, navegando al cropper primero"),void We(e);c.onSelect&&c.onSelect({assetId:e.id,url:e.url,fileName:e.filename,mime:e.mime_type,width:e.width,height:e.height,instanceId:u})},onCrop:We,onDelete:Be("delete")?Te:null,onFolderChange:Ae,onRename:ze,onEdit:Ie,onPageChange:e=>{G(e)},onFiltersChange:e=>{k(e),G(1)},images:ye,loadingImages:xe,imagesError:we,deleting:ce,uploadedImage:ne,pagination:ke,currentPage:K,galleryFilters:w,debouncedFilters:{name:z,uploadedBy:L,dateFrom:w.dateFrom,dateTo:w.dateTo,assetType:w.assetType,folder:w.folder},allowedActions:{select:Be("select"),download:Be("download"),copy:Be("copy"),delete:Be("delete"),crop:Be("crop"),rename:Be("rename")},resolvedAccept:M,allowedCategories:p,folderConfig:h,filterConfig:o.galleryFilters||{},loadingConfig:o.galleryLoading||{},resetUpload:ae}),"upload"===R&&l.jsx(qt,{onSelect:De,onVideoSelect:Re,onFolderChange:S,uploading:Z,uploadError:le,uploadedImage:ne,selectedUploadFolder:C,apiKey:t,prod:a,allowedCategories:p,resolvedAccept:M,returnConfig:g,folderConfig:h,aiStarterPrompt:v,resetUpload:ae,tags:j,onTagsChange:N}),"cropper"===R&&l.jsx(Tn,{onSave:Oe,onCancel:Fe,onError:Ue,onVariantCreated:Me,onUploadAndCrop:De,onVideoSelect:Re,onUploadWithFolder:_e,onFolderChange:S,onDelete:Te,isActionAllowed:Be,selectedImage:F,uploading:Z,uploadError:le,uploadedImage:ne,deleting:ce,selectedUploadFolder:C,modeUI:i,apiKey:t,prod:a,allowedCategories:p,resolvedAccept:M,returnConfig:g,folderConfig:h,cropperConfig:m,resetUpload:ae}),l.jsx(pe,{}),l.jsx(T,{isOpen:Q,onClose:X,onReload:Y}),l.jsx(oe,{isOpen:!!E,asset:E,onClose:()=>$(null),onSave:Pe})]})}class zn{constructor(e,t,l,n){this.id=e,this.config=t,this.eventManager=l,this.modalManager=n,this.root=null,this.container=null,this.modal=null,this.mounted=!1,this.destroyed=!1,this.button=null,this._handleAppClose=()=>{this.modal&&"function"==typeof this.modal.close&&this.modal.close()},this._validateConfig(),this._initialize()}_initialize(){"embed"===this.config.mode?this.mount():"button"===this.config.mode&&this._createButton(),this._emitDOMEvent("ready",{instance:this,config:this.config,timestamp:Date.now()})}mount(){if(this.mounted||this.destroyed)return this;if(this.container=this._resolveContainer(),!this.container)return this.eventManager.emit("error",{instanceId:this.id,error:"Container not found"}),this;try{this.root=N.createRoot(this.container),this.root.render(this._renderApp()),this.mounted=!0,this.eventManager.emit("ready",{instance:this})}catch(e){this.eventManager.emit("error",{instanceId:this.id,error:e.message})}return this}unmount(){return this.mounted?(this.root&&(this.root.unmount(),this.root=null),"button"===this.config.mode&&this.button,this.mounted=!1,this):this}open(){return"modal"!==this.config.mode&&"button"!==this.config.mode||(this.modal||this._createModal(),this.modal&&!this.modal.isOpened()&&(this.modal.open(),this.eventManager.emit("modal:open",{instance:this}))),this}close(){return this.modal&&this.modal.isOpened()&&(this.eventManager?.emit("modal:close",{instance:this}),this.modal.close()),this}updateConfig(e){return this.config={...this.config,...e},this.mounted&&this.root.render(this._renderApp()),this.eventManager.emit("config:updated",{instance:this,newConfig:e}),this}destroy(){this.destroyed||(this.unmount(),this.modal&&(this.modal.destroy(),this.modal=null),this.button&&this.button.parentNode&&(this.button.parentNode.removeChild(this.button),this.button=null),this.eventManager.emit("destroy",{instance:this}),this.container=null,this.config=null,this.eventManager=null,this.modalManager=null,this.destroyed=!0)}getId(){return this.id}getMode(){return this.config.mode}isMounted(){return this.mounted}isDestroyed(){return this.destroyed}getContainer(){return this.container}getConfig(){return{...this.config}}isContainerInDOM(){return this.container&&document.contains(this.container)}_createModal(){if(this.modalManager&&"modal"===this.config.mode&&(this.modal=this.modalManager.createModal({title:this.config.title||"Limbo Image Manager",size:this.config.modalSize||this.config.modal?.size||"large",usesReactFocusTrap:!0,onOpen:()=>{const e={instance:this,mode:"modal",timestamp:Date.now()};this._emitDOMEvent("modal:open",e),this.config.callbacks?.onOpen&&this.config.callbacks.onOpen(e)},onClose:()=>{const e={instance:this,mode:"modal",timestamp:Date.now()};this._emitDOMEvent("modal:close",e),this.config.callbacks?.onClose&&this.config.callbacks.onClose(e),this.config.autoDestroy&&this.destroy()},onDestroy:()=>{this.modal=null}}),this.modal)){const e=this.modal.getBodyContainer();this.root=N.createRoot(e),this.root.render(this._renderApp()),this.mounted=!0}}_createButton(){if(this.container||(this.container=this._resolveContainer()),!this.container)return void this.eventManager.emit("error",{instanceId:this.id,error:"Container not found for button mode"});const e=document.createElement("button");e.type="button",e.className="limbo-trigger-button",e.textContent=this.config.buttonText||"Abrir Limbo",e.style.cssText="\n background: #001978;\n color: white;\n border: none;\n padding: 10px 20px;\n border-radius: 6px;\n cursor: pointer;\n font-family: inherit;\n font-size: 14px;\n font-weight: 500;\n transition: all 0.2s ease;\n ",e.addEventListener("mouseenter",()=>{e.style.backgroundColor="#334793",e.style.transform="translateY(-1px)"}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor="#001978",e.style.transform="translateY(0)"}),e.addEventListener("click",()=>{this.open()}),this.container.appendChild(e),this.button=e,this.mounted=!0}_resolveContainer(){const{container:e}=this.config;return e?"string"==typeof e?document.querySelector(e):e instanceof Element?e:null:null}_renderApp(){return e.createElement("div",{id:`limbo-component-container-${this.id}`,className:"limbo-scope limbo-instance limbo-component-container-wrapper lb:h-full lb:w-full lb:py-2 lb:pb-0 lb:bg-white","data-limbo-id":this.id,"data-limbo-mode":this.config.mode,"data-limbo-version":"4.2.1","data-limbo-isolated":"true","aria-label":"Limbo Image Manager",role:"region"},e.createElement(An,{onClose:"modal"===this.config.mode?this._handleAppClose:void 0,apiKey:this.config.apiKey||null,publicKey:this.config.publicKey||null,token:this.config.token||null,prod:this.config.prod||!1,url:this.config.url,features:this.config.features,modeUI:this.config.modeUI||"full",ui:this.config.ui,callbacks:this._createCallbacks(),instanceId:this.id,authMode:this.config.authMode||(this.config.publicKey?"session":"manual"),_externalImage:this.config._externalImage||null,cropperConfig:this.config.cropper||null,allowedCategories:this.config.validation?.allowedCategories||null,accept:this.config.validation?.accept||null,returnConfig:this.config.returnConfig||null,aiStarterPrompt:this.config.aiStarterPrompt,folderConfig:this.config.folders||{include:[],exclude:[],includeNoFolder:!0},itemsPerPage:this.config.itemsPerPage||30}))}_createCallbacks(){return{onSelect:e=>{const t=this.config?.callbacks?.onSelect,l=this._createStandardPayload(e,"select");t&&Promise.resolve(t(l)).catch(e=>{console.error("[LimboInstance] Error en onSelect callback:",e)}),this.destroyed||this._emitDOMEvent("select",l)},onUpload:e=>{const t=this.config?.callbacks?.onUpload,l=this._createStandardPayload(e,"upload");t&&Promise.resolve(t(l)).catch(e=>{console.error("[LimboInstance] Error en onUpload callback:",e)}),this.destroyed||this._emitDOMEvent("upload",l)},onError:e=>{const t=this.config?.callbacks?.onError,l={instance:this,error:{message:e.message||"Unknown error",code:e.code||"UNKNOWN",timestamp:Date.now()}};t&&t(l.error),this.destroyed||this._emitDOMEvent("error",l)},onClose:()=>{const e=this.config?.callbacks?.onClose,t={instance:this,timestamp:Date.now()};e&&e(),this.destroyed||this._emitDOMEvent("close",t)},onCropsSaved:e=>{console.log("[LimboInstance] onCropsSaved recibido:",e),console.log("[LimboInstance] this.config?.callbacks:",this.config?.callbacks);const t=this.config?.callbacks?.onCropsSaved;console.log("[LimboInstance] userCallback existe:",!!t);const l={instance:this,eventType:"cropsSaved",timestamp:Date.now(),instanceId:this.id,...e};if(console.log("[LimboInstance] payload.crops:",l.crops),t){console.log("[LimboInstance] Llamando userCallback onCropsSaved");try{t(l),console.log("[LimboInstance] userCallback ejecutado correctamente")}catch(n){console.error("[LimboInstance] Error en userCallback:",n)}}else console.warn("[LimboInstance] ⚠️ userCallback onCropsSaved NO existe");this.destroyed||this._emitDOMEvent("cropsSaved",l)},onCropperComplete:e=>{console.log("[LimboInstance] onCropperComplete recibido:",e);const t=this.config?.callbacks?.onCropperComplete,l={instance:this,eventType:"cropperComplete",timestamp:Date.now(),instanceId:this.id,...e};t&&(console.log("[LimboInstance] Llamando userCallback onCropperComplete"),t(l)),this.destroyed||this._emitDOMEvent("cropperComplete",l)}}}_createStandardPayload(e,t){const l={instance:this,eventType:t,timestamp:Date.now(),instanceId:this.id,mode:this.config?.mode,features:this.config?.features};return e&&(e.assetId||e.id?(l.assetId=e.assetId||e.id,l.variants=e.variants||[],l.master=e.master||{urlSigned:e.url||e.urlSigned,width:e.width,height:e.height,mime:e.mime||e.mimeType},l.fileName=e.fileName||e.name,l.mime=e.mime||e.mimeType,l.width=e.width,l.height=e.height,l.fileBlob=e.fileBlob||e.file,l.metadata={uploadedBy:e.uploadedBy,uploadedAt:e.uploadedAt||e.timestamp,size:e.size,...e.metadata}):Object.assign(l,e)),l}_emitDOMEvent(e,t){if(this.destroyed)return;const l=new CustomEvent(`limbo:${e}`,{detail:t,bubbles:!0,cancelable:!0});(this.getContainer()||document).dispatchEvent(l),this.eventManager?.emit(e,t)}_validateConfig(){const e=q();if(!(this.config.auth?.apiKey||this.config.auth?.publicKey||this.config.auth?.token||this.config.apiKey||this.config.publicKey||this.config.token||this.config.tokenProvider||this.config.auth?.tokenProvider||e.token||e.publicKey||e.tokenProvider))throw new Error(`LimboInstance ${this.id}: Authentication is required. Provide either auth.publicKey (recommended), auth.apiKey (for server-side only), token, or tokenProvider`);if((this.config.auth?.apiKey||this.config.apiKey)&&"undefined"!=typeof window&&console.warn("⚠️ SECURITY WARNING: API Key detected in client-side code.\nThis is a security risk! Use publicKey instead for client applications.\nAPI Keys should only be used in server-side environments."),!["embed","modal","button"].includes(this.config.mode))throw new Error(`LimboInstance ${this.id}: invalid mode ${this.config.mode}`);if("embed"===this.config.mode&&!this.config.container)throw new Error(`LimboInstance ${this.id}: container is required for embed mode`);if("button"===this.config.mode&&!this.config.container)throw new Error(`LimboInstance ${this.id}: container is required for button mode`)}}class Ln{constructor(){this.instances=new Map,this.counter=0}create(e,t,l){const n="limbo-"+ ++this.counter,a=new zn(n,e,t,l);return this.instances.set(n,a),a}get(e){return this.instances.get(e)}getAll(){return Array.from(this.instances.values())}getActive(){return this.getAll().filter(e=>e.isMounted())}destroy(e){const t=this.instances.get(e);return!!t&&(t.destroy(),this.instances.delete(e),!0)}destroyAll(){this.instances.forEach(e=>e.destroy()),this.instances.clear()}cleanupOrphans(){const e=[];return this.instances.forEach((t,l)=>{t.isContainerInDOM()||e.push(l)}),e.forEach(e=>this.destroy(e)),e.length}getStats(){const e=this.getAll();return{total:e.length,active:e.filter(e=>e.isMounted()).length,embed:e.filter(e=>"embed"===e.getMode()).length,modal:e.filter(e=>"modal"===e.getMode()).length,button:e.filter(e=>"button"===e.getMode()).length}}}class Mn{constructor(){this.config=null,this.instances=new Map,this.observer=null,this.initialized=!1}configure(e,t,l){return this.config={selector:e.selector||null,dataset:e.dataset||"data-limbo-input-file",return:e.return||e.returnType||"json",mode:e.mode||"modal",features:e.features||["gallery","upload","cropper"],crop:e.crop||"free",quality:e.quality||.9,format:e.format||"webp",modeUI:e.modeUI||"full",modalSize:e.modalSize||"fullscreen",theme:e.theme||"light",compact:e.compact||!1,maxSize:e.maxSize||"10MB",formats:e.formats||["jpg","jpeg","png","svg","webp"],minWidth:e.minWidth||null,minHeight:e.minHeight||null,maxWidth:e.maxWidth||null,maxHeight:e.maxHeight||null,buttonText:e.buttonText||"Seleccionar archivo",buttonClass:e.buttonClass||"limbo-auto-button",buttonStyle:e.buttonStyle||"primary",showPreview:!1!==e.showPreview,allowMultiple:e.allowMultiple||!1,autoAssign:!1!==e.autoAssign,localCropsOnly:e.localCropsOnly||!1,...e},this.configManager=t,this.eventManager=l,this._initialize(),this}cleanup(){this.observer&&(this.observer.disconnect(),this.observer=null),this.instances.forEach(({input:e,button:t})=>{this._restoreInput(e,t)}),this.instances.clear(),this.config=null,this.initialized=!1}getStats(){return{configured:null!==this.config,totalInputs:this.instances.size,dataset:this.config?.dataset,returnType:this.config?.return}}_initialize(){this.initialized||(this._scanExistingInputs(),this._setupObserver(),this.initialized=!0,this.eventManager.emit("autoInputs:initialized",{config:this.config,inputsFound:this.instances.size}))}_scanExistingInputs(){const e=this.config.selector||`input[${this.config.dataset}]`;document.querySelectorAll(e).forEach(e=>this._processInput(e))}_processInput(e){const t=this._getInputId(e);if(this.instances.has(t))return;if(!this._validateInput(e))return;const l=this._createButton(e);this._hideInput(e),this._insertButton(e,l),this.instances.set(t,{input:e,button:l,config:this._getInputConfig(e)}),this.eventManager.emit("autoInputs:processed",{inputId:t,input:e,button:l})}_createButton(e){const t=document.createElement("button"),l=this._getInputConfig(e);t.type="button";const n=e.dataset.buttontext||e.getAttribute("data-limbo-button-text")||null;t.textContent=n||u(l.accept||null,!1);const a=[this.config.buttonClass];return l.buttonClass&&l.buttonClass!==this.config.buttonClass&&a.push(l.buttonClass),t.className=a.join(" "),this._styleButton(t,l),this._attachButtonEvents(t,e),t.setAttribute("aria-label",l.buttonText||this.config.buttonText),t.setAttribute("data-limbo-trigger","true"),t.setAttribute("data-limbo-input-id",l.inputId),l.disabled&&(t.disabled=!0),t}_styleButton(e,t){const l=t.buttonStyle||this.config.buttonStyle,n=t.theme||this.config.theme,a=t.compact||this.config.compact,r={border:"none",borderRadius:"8px",cursor:"pointer",fontFamily:"inherit",fontSize:a?"12px":"14px",fontWeight:"500",transition:"all 0.2s ease",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:a?"6px 12px":"8px 16px",textDecoration:"none",userSelect:"none"},i={primary:{backgroundColor:"dark"===n?"#3b82f6":"#001978",color:"white",hoverBg:"dark"===n?"#2563eb":"#334793"},secondary:{backgroundColor:"dark"===n?"#374151":"#f3f4f6",color:"dark"===n?"#f9fafb":"#374151",border:"1px solid "+("dark"===n?"#4b5563":"#d1d5db"),hoverBg:"dark"===n?"#4b5563":"#e5e7eb"},outline:{backgroundColor:"transparent",color:"dark"===n?"#3b82f6":"#001978",border:"2px solid "+("dark"===n?"#3b82f6":"#001978"),hoverBg:"dark"===n?"#3b82f6":"#001978",hoverColor:"white"},ghost:{backgroundColor:"transparent",color:"dark"===n?"#f9fafb":"#374151",hoverBg:"dark"===n?"#374151":"#f3f4f6"}},o=i[l]||i.primary;Object.assign(e.style,{...r,...o});const s=o.backgroundColor,c=o.color;e.addEventListener("mouseenter",()=>{e.style.backgroundColor=o.hoverBg||o.backgroundColor,o.hoverColor&&(e.style.color=o.hoverColor),e.style.transform="translateY(-1px)",e.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor=s,e.style.color=c,e.style.transform="translateY(0)",e.style.boxShadow="none"}),t.disabled&&(e.style.opacity="0.5",e.style.cursor="not-allowed")}_attachButtonEvents(e,t){e.addEventListener("click",e=>{e.preventDefault(),this._handleButtonClick(t)})}_handleButtonClick(e){const t=this._getInputConfig(e),l=this._createModalConfig(t);this.eventManager.emit("autoInputs:modalRequest",{input:e,config:l,callback:async t=>await this._handleImageSelection(e,t)})}async _handleImageSelection(e,t){const l=this._getInputConfig(e);let n=t;try{if(!t.original&&!t.images&&(t.id||t.assetId)){console.log("[AutoInputManager] 🔗 Selección directa detectada, obteniendo URL permanente...");const e=t.id||t.assetId;try{const l=await async function(e,t=!0,l=!0,n=0){try{const a=new URLSearchParams({include_variants:t.toString(),include_metadata:l.toString(),url_expires:n.toString()});return G(await W({endpoint:`/assets/${e}?${a}`,method:"GET",basePath:J,useJWT:!0}))}catch(a){throw Y(a)}}(e,!1,!1,!0);l?.result?.url?(console.log("[AutoInputManager] ✅ URL permanente obtenida:",l.result.url),n={original:{url:l.result.url,width:l.result.width||t.width,height:l.result.height||t.height,assetId:e},images:[]}):(console.warn("[AutoInputManager] ⚠️ No se pudo obtener URL permanente, usando URL temporal"),n={original:{url:t.url||t.path,width:t.width,height:t.height,assetId:e},images:[]})}catch(a){console.error("[AutoInputManager] Error obteniendo URL permanente:",a),n={original:{url:t.url||t.path,width:t.width,height:t.height,assetId:e},images:[]}}}const r=await this._formatImageData(n,l);console.log("[AutoInputManager] Valor formateado:",r),console.log("[AutoInputManager] Tipo de valor:",typeof r),!1!==l.autoAssign&&(e.value=r,console.log("[AutoInputManager] Valor asignado al input:",e.value)),this._updateButtonFeedback(e,n),e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:resultReady",{detail:{imageData:n,input:e,value:r,config:l,assignment:{format:l.return,smartAssign:!1!==l.smartAssign,autoAssign:!1!==l.autoAssign},legacy:{imageData:n,formatted:this._createFormattedResult(n,l)}},bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:imageSelected",{detail:{imageData:n,input:e,value:r,config:l,formatted:this._createFormattedResult(n,l)},bubbles:!0})),this.eventManager.emit("autoInputs:imageSelected",{input:e,imageData:n,value:r,config:l})}catch(r){console.error("Error handling image selection:",r),e.dispatchEvent(new CustomEvent("limbo:error",{detail:{error:r.message,input:e,imageData:n,config:l},bubbles:!0})),this._handleImageSelectionLegacy(e,t)}}_updateButtonFeedback(e,t){const l=this._getInputId(e),n=this.instances.get(l);if(!n||!n.button)return;const a=n.button,r=a.nextElementSibling;r&&r.classList.contains("limbo-button-feedback")&&r.remove();const i=document.createElement("span");i.className="limbo-button-feedback",i.style.cssText="\n display: inline-flex;\n align-items: center;\n gap: 6px;\n margin-left: 8px;\n padding: 4px 8px;\n background: #10b981;\n color: white;\n border-radius: 6px;\n font-size: 12px;\n font-weight: 500;\n animation: limbo-fade-in 0.3s ease-out;\n ";const o=t.images&&t.images.length>0,s=o?t.images.length:0;for(;i.firstChild;)i.removeChild(i.firstChild);i.appendChild(function(){const e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"svg");t.setAttribute("width","14"),t.setAttribute("height","14"),t.setAttribute("viewBox","0 0 20 20"),t.setAttribute("fill","currentColor");const l=document.createElementNS(e,"path");return l.setAttribute("fill-rule","evenodd"),l.setAttribute("d","M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"),l.setAttribute("clip-rule","evenodd"),t.appendChild(l),t}());const c=document.createElement("span");c.textContent=o?`${s} recorte${1!==s?"s":""} configurado${1!==s?"s":""}`:"Archivo seleccionado",i.appendChild(c),a.parentNode.insertBefore(i,a.nextSibling);let d=a.parentNode.querySelector(".limbo-powered-by");if(!d){d=document.createElement("div"),d.className="limbo-powered-by";const e=document.createElement("span");e.style.cssText="display:block;margin-top:2px;font-size:10px;color:#aaa;text-align:left;font-family:inherit;opacity:0.7;",e.textContent="Powered by ";const t=document.createElement("b");t.textContent="Limbo",e.appendChild(t),d.appendChild(e),a.parentNode.insertBefore(d,i.nextSibling)}a.style.backgroundColor="#10b981";const b=n.config?.accept||null;a.textContent=u(b,!0)}async _handleImageSelectionLegacy(e,t){const l=this._getInputConfig(e),n=await this._formatImageData(t,l);!1!==l.autoAssign&&(e.value=n),e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:imageSelected",{detail:{imageData:t,input:e,value:n,config:l,formatted:this._createFormattedResult(t,l)},bubbles:!0})),this.eventManager.emit("autoInputs:imageSelected",{input:e,imageData:t,value:n,config:l})}_createFormattedResult(e,t){return{url:e.url||e.path||"",base64:e.base64||e.dataUrl||"",assetId:e.assetId||e.id||"",fileName:e.fileName||e.filename||"",object:{url:e.url||e.path,assetId:e.assetId||e.id,fileName:e.fileName||e.filename,mime:e.mime||e.mime_type,width:e.width,height:e.height,size:e.size||e.file_size,created:e.created_at||e.created,metadata:e.metadata||{}},json:JSON.stringify({url:e.url||e.path,assetId:e.assetId||e.id,fileName:e.fileName||e.filename,mime:e.mime||e.mime_type,width:e.width,height:e.height,size:e.size||e.file_size}),metadata:{width:e.width,height:e.height,size:e.size||e.file_size,format:e.format||e.mime_type,quality:t.quality||this.config.quality,aspectRatio:e.width&&e.height?e.width/e.height:null}}}async _formatImageData(e,t=null){const l=(t||{}).return||this.config.return||"json",n=void 0!==e.original;switch(l){case"url":return n?e.images?.[0]?.url||e.original?.url||"":e.url||e.path||"";case"base64":return e.base64||e.dataUrl||"";case"assetId":return n?e.original?.assetId||"":e.assetId||e.id||"";case"fileName":return e.fileName||e.filename||"";default:try{if(n){const t={original:e.original?{url:e.original.url||e.original.urlSigned,width:e.original.width,height:e.original.height,assetId:e.original.assetId||e.original.id}:null,images:Array.isArray(e.images)?e.images.map(e=>{const t={url:e.url||e.urlSigned,width:e.width,height:e.height,name:e.name||e.filename||e.label};return e.cropState&&(t.cropState={selectorState:e.cropState.selectorState||null,imageTransform:e.cropState.imageTransform||null,flipState:e.cropState.flipState||null}),t}):[]};console.log("[AutoInputManager] Datos limpios para JSON:",t);const l=JSON.stringify(t);return console.log("[AutoInputManager] JSON generado:",l),l}const t={original:{url:e.url||e.path,width:e.width,height:e.height,assetId:e.assetId||e.id}};return console.log("[AutoInputManager] Datos legacy para JSON:",t),JSON.stringify(t)}catch(a){return console.error("[AutoInputManager] Error al serializar JSON:",a),console.error("[AutoInputManager] imageData problemático:",e),"{}"}}}_createModalConfig(e){return{mode:e.mode||this.config.mode||"modal",modeUI:e.modeUI||this.config.modeUI||"full",features:e.features||this.config.features,modalSize:e.modalSize||this.config.modalSize||"fullscreen",title:e.description||this.config.title||"Seleccionar archivo",cropper:this._getCropperConfig(e),ui:{showActions:this._getUIActions(e),hideActions:[],showTabs:this._shouldShowTabs(e),theme:e.theme||this.config.theme,compact:e.compact||this.config.compact,showPreview:void 0!==e.showPreview?e.showPreview:this.config.showPreview},validation:{accept:e.accept||null,maxSize:e.maxSize||this.config.maxSize,formats:e.formats||this.config.formats,minWidth:e.minWidth||this.config.minWidth,minHeight:e.minHeight||this.config.minHeight,maxWidth:e.maxWidth||this.config.maxWidth,maxHeight:e.maxHeight||this.config.maxHeight,required:e.required||!1},behavior:{allowMultiple:e.allowMultiple||this.config.allowMultiple,closeOnSelect:!0,autoAssign:void 0!==e.autoAssign?e.autoAssign:this.config.autoAssign,allowSelectNew:!1!==e.allowSelectNew},initialImageUrl:e.initialImageUrl||null,existingCrops:e.existingCrops||null,existingData:e.existingData||null,returnConfig:{format:e.return||this.config.return,quality:e.quality||this.config.quality,outputFormat:e.format||this.config.format},inputMeta:{inputId:e.inputId,inputName:e.inputName,inputType:e.inputType,placeholder:e.placeholder}}}_getCropperConfig(e){const t=e.crop||this.config.crop,l={quality:e.quality||this.config.quality,format:e.format||this.config.format,mandatoryCrops:e.mandatoryCrops||[],allowAdditionalCrops:!1!==e.allowAdditionalCrops,maxCrops:e.maxCrops||null,localCropsOnly:e.localCropsOnly??this.config.localCropsOnly??!1,existingCrops:e.existingCrops||null};if(e.mandatoryCrops&&e.mandatoryCrops.length>0)return{...l,aspectRatio:null};if(!t||"none"===t||"false"===t)return null;if("free"===t)return{...l,aspectRatio:null};const n={"1:1":1,"16:9":16/9,"4:3":4/3,"3:2":1.5,"2:1":2,square:1,landscape:16/9,portrait:3/4};if(n[t])return{...l,aspectRatio:n[t],minCropBoxWidth:e.minWidth||this.config.minWidth,minCropBoxHeight:e.minHeight||this.config.minHeight};if("string"==typeof t&&t.includes(":")){const[e,n]=t.split(":").map(Number);if(!isNaN(e)&&!isNaN(n)&&0!==n)return{...l,aspectRatio:e/n}}const a=parseFloat(t);return!isNaN(a)&&a>0?{...l,aspectRatio:a}:"object"==typeof t?{...l,...t}:null}_shouldShowTabs(e){const t=e.modeUI||this.config.modeUI||"full",l=e.features||this.config.features;return!["gallery-only","upload-only","crop-only","ia-only"].includes(t)&&(l&&l.length>1)}_getUIActions(e){const t=e.modeUI||this.config.modeUI||"full",l=e.features||this.config.features;let n=[];switch(t){case"gallery-only":case"upload-only":n=["select"];break;case"crop-only":n=["select","crop"];break;default:n=["select"],l.includes("cropper")&&n.push("crop"),l.includes("gallery")&&(n.push("download","copy","rename"),this.config.allowDelete&&n.push("delete"))}return n}_getInputId(e){if(e.id)return e.id;if(e.name)return e.name;let t=e.getAttribute("data-limbo-uid");return t||(t=`limbo-auto-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,e.setAttribute("data-limbo-uid",t)),t}_validateInput(e){return e instanceof HTMLInputElement}_getInputConfig(e){const t=e=>e?e.split(",").map(e=>e.trim()):null,l=e=>{if(!e)return null;const t=e.match(/^(\d+(?:\.\d+)?)(MB|KB|B)?$/i);if(!t)return null;const l=parseFloat(t[1]);switch((t[2]||"B").toUpperCase()){case"MB":return 1024*l*1024;case"KB":return 1024*l;default:return l}},n=(e,t=!1)=>null===e?t:"true"===e||"1"===e||""===e,a=e=>e?parseFloat(e):null,r=e=>{if(!e)return null;try{return JSON.parse(e)}catch(t){return console.warn("[Limbo AutoInputManager] Error parsing JSON attribute:",t),null}},i=r(e.dataset.mandatorycrops)||r(e.dataset.mandatoryCrops)||r(e.getAttribute("data-mandatory-crops"))||r(e.getAttribute("data-limbo-mandatory-crops"))||null;return{return:e.dataset.returntype||e.getAttribute("data-limbo-return")||this.config.return,mode:e.dataset.mode||e.getAttribute("data-limbo-mode")||this.config.mode,features:t(e.dataset.features)||t(e.getAttribute("data-limbo-features"))||this.config.features,crop:e.dataset.crop||e.getAttribute("data-limbo-crop")||this.config.crop,quality:a(e.dataset.quality)||a(e.getAttribute("data-limbo-quality"))||this.config.quality,format:e.dataset.format||e.getAttribute("data-limbo-format")||this.config.format,modeUI:e.dataset.modeui||e.dataset.modeUI||e.getAttribute("data-limbo-mode-ui")||this.config.modeUI,modalSize:e.dataset.modalsize||e.getAttribute("data-limbo-modal-size")||this.config.modalSize,theme:e.dataset.theme||e.getAttribute("data-limbo-theme")||this.config.theme,compact:n(e.dataset.compact,null)??n(e.getAttribute("data-limbo-compact"),this.config.compact),maxSize:l(e.getAttribute("data-limbo-max-size"))||l(this.config.maxSize),formats:t(e.getAttribute("data-limbo-formats"))||this.config.formats,minWidth:a(e.getAttribute("data-limbo-min-width"))||this.config.minWidth,minHeight:a(e.getAttribute("data-limbo-min-height"))||this.config.minHeight,maxWidth:a(e.getAttribute("data-limbo-max-width"))||this.config.maxWidth,maxHeight:a(e.getAttribute("data-limbo-max-height"))||this.config.maxHeight,buttonText:e.dataset.buttontext||e.getAttribute("data-limbo-button-text")||this.config.buttonText,buttonStyle:e.dataset.buttonstyle||e.getAttribute("data-limbo-button-style")||this.config.buttonStyle,buttonClass:e.dataset.buttonclass||e.getAttribute("data-limbo-button-class")||this.config.buttonClass,showPreview:n(e.getAttribute("data-limbo-show-preview"),this.config.showPreview),allowMultiple:n(e.getAttribute("data-limbo-allow-multiple"),this.config.allowMultiple),autoAssign:n(e.getAttribute("data-limbo-auto-assign"),this.config.autoAssign),placeholder:e.getAttribute("data-limbo-placeholder"),description:e.getAttribute("data-limbo-description"),required:n(e.getAttribute("data-limbo-required"),!1),disabled:n(e.getAttribute("data-limbo-disabled"),!1),inputId:this._getInputId(e),inputName:e.name,inputType:e.type,mandatoryCrops:i,allowAdditionalCrops:n(e.dataset.allowadditionalcrops,null)??n(e.getAttribute("data-limbo-allow-additional-crops"),!0),maxCrops:a(e.dataset.maxcrops)||a(e.getAttribute("data-limbo-max-crops"))||null,accept:e.dataset.accept||e.getAttribute("data-limbo-accept")||null,allowSelectNew:n(e.dataset.allowselectnew,null)??n(e.getAttribute("data-limbo-allow-select-new"),!0),...this._parseExistingInputValue(e.value)}}_parseExistingInputValue(e){if(!e||""===e.trim())return{initialImageUrl:null,existingCrops:null,existingData:null};try{const t=JSON.parse(e);return t.original&&t.original.url?(console.log("[AutoInputManager] Valor existente parseado:",t),{initialImageUrl:t.original.url,existingCrops:t.images||null,existingData:t}):t.url?{initialImageUrl:t.url,existingCrops:null,existingData:t}:{initialImageUrl:null,existingCrops:null,existingData:t}}catch(t){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")?{initialImageUrl:e,existingCrops:null,existingData:null}:{initialImageUrl:null,existingCrops:null,existingData:null}}}_generateInputId(){return`limbo-auto-input-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}_hideInput(e){e.style.display="none"}_insertButton(e,t){e.parentNode.insertBefore(t,e.nextSibling)}_restoreInput(e,t){e.style.display="",t&&t.parentNode&&t.parentNode.removeChild(t)}_setupObserver(){this.observer=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&this._scanNodeForInputs(e)})})}),this.observer.observe(document.body,{childList:!0,subtree:!0})}_scanNodeForInputs(e){const t=this.config.selector||`input[${this.config.dataset}]`;e.matches&&e.matches(t)&&this._processInput(e);const l=e.querySelectorAll&&e.querySelectorAll(t);l&&l.forEach(e=>this._processInput(e))}}class In{constructor(){this.listeners=new Map}emit(e,t={}){this._emitDOMEvent(e,t),this._executeListeners(e,t)}on(e,t){return this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),()=>this.off(e,t)}off(e,t){const l=this.listeners.get(e);if(l){const e=l.indexOf(t);e>-1&&l.splice(e,1)}}cleanup(){this.listeners.clear()}_emitDOMEvent(e,t){const l=new CustomEvent(`limbo:${e}`,{detail:{...t,timestamp:Date.now()},bubbles:!0,cancelable:!0});(t.instance?.getContainer()||document).dispatchEvent(l)}_executeListeners(e,t){const l=this.listeners.get(e);l&&l.forEach(l=>{try{l(t)}catch(n){console.error(`Error executing listener for ${e}:`,n)}})}getStats(){const e={};return this.listeners.forEach((t,l)=>{e[l]=t.length}),e}}class Pn{constructor(){this.activeModals=new Set,this.zIndexBase=1e4,this.focusableSelectors=["button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"]):not([disabled])',"a[href]"].join(", "),this.initialized=!1,this._initGlobalListeners()}createModal(e){const t=new Dn(this._generateModalId(),e,this);return this.activeModals.add(t),t}closeModal(e){const t=this._findModal(e);return!!t&&(t.close(),!0)}closeAllModals(){this.activeModals.forEach(e=>e.close()),this.activeModals.clear()}getActiveModal(){return Array.from(this.activeModals).pop()||null}getStats(){return{active:this.activeModals.size,nextZIndex:this._getNextZIndex()}}_generateModalId(){return`limbo-modal-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}_findModal(e){return Array.from(this.activeModals).find(t=>t.getId()===e)}_getNextZIndex(){return this.zIndexBase+10*this.activeModals.size}_removeModal(e){this.activeModals.delete(e),window.limboCore?.events&&window.limboCore.events.emit("modal:closed",{modalId:e.getId(),remainingModals:this.activeModals.size})}_handleGlobalKeydown(e){const t=this.getActiveModal();t&&(t.config&&t.config.usesReactFocusTrap||("Escape"===e.key&&(e.preventDefault(),t.close()),"Tab"===e.key&&this._handleTabTrap(e,t)))}_handleTabTrap(e,t){const l=t.getFocusableElements();if(0===l.length)return;const n=l[0],a=l[l.length-1];e.shiftKey?document.activeElement===n&&(e.preventDefault(),a.focus()):document.activeElement===a&&(e.preventDefault(),n.focus())}_initGlobalListeners(){this.initialized||(this.globalKeydownHandler=e=>this._handleGlobalKeydown(e),document.addEventListener("keydown",this.globalKeydownHandler),this.initialized=!0)}destroy(){this.closeAllModals(),this.initialized&&this.globalKeydownHandler&&(document.removeEventListener("keydown",this.globalKeydownHandler),this.initialized=!1,this.globalKeydownHandler=null)}}class Dn{constructor(e,t,l){this.id=e,this.config={title:t.title||"Limbo",content:t.content||null,showCloseButton:!1!==t.showCloseButton,backdrop:!1!==t.backdrop,keyboard:!1!==t.keyboard,focus:!1!==t.focus,animation:!1!==t.animation,size:t.size||"large",onOpen:t.onOpen||null,onClose:t.onClose||null,onDestroy:t.onDestroy||null,...t,usesReactFocusTrap:t.usesReactFocusTrap||!1},this.manager=l,this.element=null,this.backdrop=null,this.isOpen=!1,this.previousFocus=null,this._previousInertSiblings=[],this._create()}_create(){this._createBackdrop(),this._createModal(),this._attachEvents()}_createBackdrop(){this.config.backdrop&&(this.backdrop=document.createElement("div"),this.backdrop.className="limbo-modal-backdrop",this.backdrop.style.cssText=`\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.5);\n z-index: ${this.manager._getNextZIndex()};\n opacity: 0;\n transition: opacity 0.3s ease;\n `,this.backdrop.addEventListener("click",e=>{e.target===this.backdrop&&this.close()}))}_createModal(){this.element=document.createElement("div"),this.element.className=`limbo-scope limbo-modal limbo-modal--${this.config.size}`,this.element.id=this.id,this.element.setAttribute("role","dialog"),this.element.setAttribute("aria-modal","true"),this.element.setAttribute("aria-labelledby",`${this.id}-title`),this.element.tabIndex=-1;const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t={small:e?"width: 100%; height: 100%;":"max-width: 500px; min-height: 400px;",medium:e?"width: 100%; height: 100%;":"max-width: 800px; min-height: 500px;",large:e?"width: 100%; height: 100%;":"max-width: 1400px; min-height: 700px;",xlarge:e?"width: 100%; height: 100%;":"max-width: 95dvw; min-height: 85vh;",fullscreen:"width: 100%; height: 100%; max-width: 100%; max-height: 100%; border-radius: 0;"},l="fullscreen"===this.config.size,n=e||l?`\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n transform: ${e?"translateY(100%)":"scale(0.95)"};\n width: 100%;\n height: 100%;\n max-width: none;\n max-height: none;\n border-radius: 0;\n background: white;\n z-index: ${this.manager._getNextZIndex()+1};\n opacity: ${e?"1":"0"};\n transition: ${e?"transform":"all"} 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n padding-top: env(safe-area-inset-top);\n padding-left: env(safe-area-inset-left);\n padding-right: env(safe-area-inset-right);\n padding-bottom: env(safe-area-inset-bottom);\n `:`\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%) scale(0.8);\n ${t[this.config.size]}\n width: 90%;\n max-height: 90vh;\n background: white;\n border-radius: 16px;\n box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);\n z-index: ${this.manager._getNextZIndex()+1};\n opacity: 0;\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n `;this.element.style.cssText=n,this._createHeader(),this._createBody(),document.body.appendChild(this.backdrop),document.body.appendChild(this.element)}_createHeader(){const e=document.createElement("div");e.className="limbo-modal-header";const t=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e.style.cssText=`\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: ${t?"16px 20px":"20px 24px"};\n border-bottom: 1px solid #e9ecef;\n background: #f8f9fa;\n ${t?"position: sticky; top: 0; z-index: 10;":""}\n min-height: ${t?"60px":"auto"};\n `;const l=document.createElement("h2");if(l.id=`${this.id}-title`,l.className="limbo-modal-title",l.textContent=this.config.title,l.style.cssText="\n margin: 0;\n font-size: 18px;\n font-weight: 600;\n color: #001978;\n flex: 1;\n margin-right: 16px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n ",e.appendChild(l),this.config.showCloseButton){const l=document.createElement("button");l.type="button",l.className="limbo-modal-close",l.textContent="✕",l.setAttribute("aria-label","Cerrar modal"),l.style.cssText=`\n background: none;\n border: none;\n font-size: ${t?"28px":"24px"};\n color: #6c757d;\n cursor: pointer;\n padding: ${t?"8px":"4px"};\n border-radius: 4px;\n transition: all 0.2s ease;\n min-width: ${t?"44px":"auto"};\n min-height: ${t?"44px":"auto"};\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n `,l.addEventListener("mouseenter",()=>{l.style.backgroundColor="#f8f9fa",l.style.color="#001978"}),l.addEventListener("mouseleave",()=>{l.style.backgroundColor="transparent",l.style.color="#6c757d"}),l.addEventListener("click",()=>this.close()),e.appendChild(l)}this.element.appendChild(e)}_createBody(){const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t=document.createElement("div");t.className="limbo-modal-body",t.id=`${this.id}-body`,t.style.cssText=`\n flex: 1;\n overflow-y: auto;\n padding: 0;\n -webkit-overflow-scrolling: touch;\n ${e?"height: 100%; overscroll-behavior: contain;":""}\n `,this.config.content instanceof Element&&t.appendChild(this.config.content),this.element.appendChild(t)}_attachEvents(){this._originalBodyOverflow=document.body.style.overflow}open(){if(this.isOpen)return this;window.limbo&&window.limbo.core&&window.limbo.core.keyboard?(window.limbo.core.keyboard.pushFocus(document.activeElement),window.limbo.core.keyboard.setActiveModal(this.element)):this.previousFocus=document.activeElement,document.body.style.overflow="hidden",this._applyInertToSiblings();const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t="fullscreen"===this.config.size;return requestAnimationFrame(()=>{this.backdrop&&(this.backdrop.style.opacity="1"),this.element.style.opacity="1",this.element.style.transform=e?"translateY(0%)":t?"scale(1)":"translate(-50%, -50%) scale(1)"}),this.isOpen=!0,this.config.focus&&setTimeout(()=>{if(window.limbo&&window.limbo.core&&window.limbo.core.keyboard)window.limbo.core.keyboard.focusFirst(this.element);else{const e=this.getFocusableElements()[0];e&&e.focus()}},300),this.config.onOpen&&this.config.onOpen(this),this}close(){if(!this.isOpen)return this;const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t="fullscreen"===this.config.size;return this.backdrop&&(this.backdrop.style.opacity="0"),this.element.style.opacity="0",this.element.style.transform=e?"translateY(100%)":t?"scale(0.95)":"translate(-50%, -50%) scale(0.8)",setTimeout(()=>{this._cleanup()},300),this.isOpen=!1,window.limbo&&window.limbo.core&&window.limbo.core.keyboard&&(window.limbo.core.keyboard.setActiveModal(null),window.limbo.core.keyboard.releaseFocus()),this.config.onClose&&this.config.onClose(this),this}destroy(){this.close(),this.manager._removeModal(this),this.config.onDestroy&&this.config.onDestroy(this)}getBodyContainer(){return this.element.querySelector(".limbo-modal-body")}getFocusableElements(){return Array.from(this.element.querySelectorAll(this.manager.focusableSelectors))}getId(){return this.id}isOpened(){return this.isOpen}getConfig(){return{...this.config}}_applyInertToSiblings(){const e=Array.from(document.body.children).filter(e=>e!==this.element&&e!==this.backdrop);this._previousInertSiblings=e.map(e=>({node:e,hadInert:e.hasAttribute("inert")})),e.forEach(e=>e.setAttribute("inert",""))}_restoreInertSiblings(){this._previousInertSiblings.forEach(({node:e,hadInert:t})=>{!t&&e.isConnected&&e.removeAttribute("inert")}),this._previousInertSiblings=[]}_cleanup(){document.body.style.overflow=this._originalBodyOverflow||"",this._restoreInertSiblings(),this.previousFocus&&"function"==typeof this.previousFocus.focus&&!1!==this.previousFocus.isConnected&&this.previousFocus.focus(),this.backdrop&&this.backdrop.parentNode&&this.backdrop.parentNode.removeChild(this.backdrop),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class Rn{constructor(){this.currentTheme=null,this.customThemes=new Map,this.config=this._getDefaultConfig(),this.isInitialized=!1,this.isCompactMode=!1,this.compactBreakpoint=null,this.compactObserver=null,this.mediaQueryObserver=null,this.mutationObserver=null,this.storageListener=null,this.themeCache=new Map,this.appliedStyles=new Set,this.changeCallbacks=new Set}_getDefaultConfig(){return{theme:{auto:!0,storage:!0,inherit:!0,smooth:!0,detectSystem:!0},compact:{enabled:!1,auto:!0,breakpoint:768,forceOnMobile:!0,persistPreference:!0},presets:{light:{name:"light",displayName:"Claro",variables:{"--limbo-primary":"#3b82f6","--limbo-primary-hover":"#2563eb","--limbo-primary-light":"#dbeafe","--limbo-primary-dark":"#1e40af","--limbo-bg-primary":"#ffffff","--limbo-bg-secondary":"#f8fafc","--limbo-bg-tertiary":"#f1f5f9","--limbo-bg-overlay":"rgba(0, 0, 0, 0.5)","--limbo-bg-card":"#ffffff","--limbo-bg-input":"#ffffff","--limbo-text-primary":"#0f172a","--limbo-text-secondary":"#475569","--limbo-text-tertiary":"#64748b","--limbo-text-inverse":"#ffffff","--limbo-text-muted":"#94a3b8","--limbo-border-light":"#e2e8f0","--limbo-border-medium":"#cbd5e1","--limbo-border-strong":"#94a3b8","--limbo-border-focus":"#3b82f6","--limbo-success":"#10b981","--limbo-success-light":"#d1fae5","--limbo-error":"#ef4444","--limbo-error-light":"#fee2e2","--limbo-warning":"#f59e0b","--limbo-warning-light":"#fef3c7","--limbo-info":"#3b82f6","--limbo-info-light":"#dbeafe","--limbo-shadow-sm":"0 1px 2px 0 rgba(0, 0, 0, 0.05)","--limbo-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.1)","--limbo-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.1)","--limbo-shadow-xl":"0 20px 25px -5px rgba(0, 0, 0, 0.1)","--limbo-radius-sm":"4px","--limbo-radius-md":"6px","--limbo-radius-lg":"8px","--limbo-radius-xl":"12px","--limbo-font-family":"system-ui, -apple-system, sans-serif","--limbo-font-size-xs":"12px","--limbo-font-size-sm":"14px","--limbo-font-size-md":"16px","--limbo-font-size-lg":"18px","--limbo-font-size-xl":"20px","--limbo-z-dropdown":"1000","--limbo-z-sticky":"1020","--limbo-z-fixed":"1030","--limbo-z-modal":"1050","--limbo-z-tooltip":"1070","--limbo-transition-fast":"150ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-transition-normal":"300ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-transition-slow":"500ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-spacing-compact":"0.5rem","--limbo-spacing-compact-sm":"0.25rem","--limbo-spacing-compact-lg":"0.75rem","--limbo-font-size-compact-xs":"11px","--limbo-font-size-compact-sm":"12px","--limbo-font-size-compact-md":"14px","--limbo-font-size-compact-lg":"16px","--limbo-radius-compact":"4px","--limbo-radius-compact-sm":"3px","--limbo-radius-compact-lg":"6px","--limbo-button-height-compact":"32px","--limbo-input-height-compact":"36px","--limbo-modal-padding-compact":"12px","--limbo-card-padding-compact":"12px","--limbo-gap-compact":"8px","--limbo-gap-compact-sm":"4px","--limbo-gap-compact-lg":"12px"}},dark:{name:"dark",displayName:"Oscuro",variables:{"--limbo-primary":"#60a5fa","--limbo-primary-hover":"#3b82f6","--limbo-primary-light":"#1e293b","--limbo-primary-dark":"#93c5fd","--limbo-bg-primary":"#0f172a","--limbo-bg-secondary":"#1e293b","--limbo-bg-tertiary":"#334155","--limbo-bg-overlay":"rgba(0, 0, 0, 0.8)","--limbo-bg-card":"#1e293b","--limbo-bg-input":"#334155","--limbo-text-primary":"#f8fafc","--limbo-text-secondary":"#cbd5e1","--limbo-text-tertiary":"#94a3b8","--limbo-text-inverse":"#0f172a","--limbo-text-muted":"#64748b","--limbo-border-light":"#334155","--limbo-border-medium":"#475569","--limbo-border-strong":"#64748b","--limbo-border-focus":"#60a5fa","--limbo-success":"#34d399","--limbo-success-light":"#064e3b","--limbo-error":"#f87171","--limbo-error-light":"#7f1d1d","--limbo-warning":"#fbbf24","--limbo-warning-light":"#78350f","--limbo-info":"#60a5fa","--limbo-info-light":"#1e3a8a","--limbo-shadow-sm":"0 1px 2px 0 rgba(0, 0, 0, 0.2)","--limbo-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.3)","--limbo-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.4)","--limbo-shadow-xl":"0 20px 25px -5px rgba(0, 0, 0, 0.5)","--limbo-radius-sm":"4px","--limbo-radius-md":"6px","--limbo-radius-lg":"8px","--limbo-radius-xl":"12px","--limbo-font-family":"system-ui, -apple-system, sans-serif","--limbo-font-size-xs":"12px","--limbo-font-size-sm":"14px","--limbo-font-size-md":"16px","--limbo-font-size-lg":"18px","--limbo-font-size-xl":"20px","--limbo-z-dropdown":"1000","--limbo-z-sticky":"1020","--limbo-z-fixed":"1030","--limbo-z-modal":"1050","--limbo-z-tooltip":"1070","--limbo-transition-fast":"150ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-transition-normal":"300ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-transition-slow":"500ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-spacing-compact":"0.5rem","--limbo-spacing-compact-sm":"0.25rem","--limbo-spacing-compact-lg":"0.75rem","--limbo-font-size-compact-xs":"11px","--limbo-font-size-compact-sm":"12px","--limbo-font-size-compact-md":"14px","--limbo-font-size-compact-lg":"16px","--limbo-radius-compact":"4px","--limbo-radius-compact-sm":"3px","--limbo-radius-compact-lg":"6px","--limbo-button-height-compact":"32px","--limbo-input-height-compact":"36px","--limbo-modal-padding-compact":"12px","--limbo-card-padding-compact":"12px","--limbo-gap-compact":"8px","--limbo-gap-compact-sm":"4px","--limbo-gap-compact-lg":"12px"}},auto:{name:"auto",displayName:"Automático",variables:{}}},inheritance:{portalSelectors:["body","[data-theme]",".theme-light",".theme-dark",".light-theme",".dark-theme"],variablePrefix:"--",fallbackTheme:"light"},transitions:{duration:"300ms",easing:"cubic-bezier(0.4, 0, 0.2, 1)",properties:["background-color","border-color","color","fill","stroke","box-shadow"]}}}initialize(e={}){this.isInitialized?console.warn("ThemeManager already initialized"):(this.config=this._deepMerge(this.config,e),this._loadCustomThemes(),this.config.theme.inherit&&this._inheritPortalTheme(),this._applyInitialTheme(),this._applyInitialCompactMode(),this._setupObservers(),this._injectBaseStyles(),this.isInitialized=!0)}_injectBaseStyles(){if(document.getElementById("limbo-theme-styles"))return;const e=`\n :root {\n /* Variables de transición para cambios de tema */\n color-scheme: light dark;\n }\n \n [data-limbo-theme] {\n transition: ${this.config.transitions.properties.map(e=>`${e} ${this.config.transitions.duration} ${this.config.transitions.easing}`).join(", ")};\n }\n \n /* Clases de utilidad para temas */\n .limbo-theme-light {\n color-scheme: light;\n }\n \n .limbo-theme-dark {\n color-scheme: dark;\n }\n \n .limbo-theme-auto {\n color-scheme: light dark;\n }\n \n /* Estilos para elementos del componente con variables CSS */\n .limbo-component {\n background-color: var(--limbo-bg-primary);\n color: var(--limbo-text-primary);\n border-color: var(--limbo-border-light);\n border-radius: var(--limbo-radius-md);\n font-family: var(--limbo-font-family);\n font-size: var(--limbo-font-size-md);\n transition: var(--limbo-transition-normal);\n }\n \n .limbo-card {\n background-color: var(--limbo-bg-card);\n border: 1px solid var(--limbo-border-light);\n border-radius: var(--limbo-radius-lg);\n box-shadow: var(--limbo-shadow-md);\n color: var(--limbo-text-primary);\n }\n \n .limbo-input {\n background-color: var(--limbo-bg-input);\n border: 1px solid var(--limbo-border-medium);\n border-radius: var(--limbo-radius-md);\n color: var(--limbo-text-primary);\n font-family: var(--limbo-font-family);\n font-size: var(--limbo-font-size-md);\n transition: var(--limbo-transition-fast);\n }\n \n .limbo-input:focus {\n border-color: var(--limbo-border-focus);\n box-shadow: 0 0 0 3px var(--limbo-primary-light);\n outline: none;\n }\n \n .limbo-button {\n background-color: var(--limbo-primary);\n border: 1px solid var(--limbo-primary);\n border-radius: var(--limbo-radius-md);\n color: var(--limbo-text-inverse);\n font-family: var(--limbo-font-family);\n font-size: var(--limbo-font-size-md);\n transition: var(--limbo-transition-fast);\n cursor: pointer;\n }\n \n .limbo-button:hover {\n background-color: var(--limbo-primary-hover);\n border-color: var(--limbo-primary-hover);\n }\n \n .limbo-button.secondary {\n background-color: var(--limbo-bg-secondary);\n border-color: var(--limbo-border-medium);\n color: var(--limbo-text-primary);\n }\n \n .limbo-button.secondary:hover {\n background-color: var(--limbo-bg-tertiary);\n }\n \n /* Estados de feedback con variables */\n .limbo-state-success {\n background-color: var(--limbo-success-light);\n border-color: var(--limbo-success);\n color: var(--limbo-success);\n }\n \n .limbo-state-error {\n background-color: var(--limbo-error-light);\n border-color: var(--limbo-error);\n color: var(--limbo-error);\n }\n \n .limbo-state-warning {\n background-color: var(--limbo-warning-light);\n border-color: var(--limbo-warning);\n color: var(--limbo-warning);\n }\n \n .limbo-state-info {\n background-color: var(--limbo-info-light);\n border-color: var(--limbo-info);\n color: var(--limbo-info);\n }\n \n /* Overlay y modal con variables */\n .limbo-overlay {\n background-color: var(--limbo-bg-overlay);\n backdrop-filter: blur(4px);\n }\n \n .limbo-modal {\n background-color: var(--limbo-bg-card);\n border-radius: var(--limbo-radius-xl);\n box-shadow: var(--limbo-shadow-xl);\n color: var(--limbo-text-primary);\n }\n \n /* Responsive design con variables */\n @media (max-width: 640px) {\n .limbo-component {\n font-size: var(--limbo-font-size-sm);\n }\n }\n \n /* Modo reducido de movimiento */\n @media (prefers-reduced-motion: reduce) {\n [data-limbo-theme] {\n transition: none;\n }\n \n .limbo-component,\n .limbo-input,\n .limbo-button {\n transition: none;\n }\n }\n \n /* Esquemas de color automático */\n @media (prefers-color-scheme: dark) {\n :root:not([data-limbo-theme]) {\n color-scheme: dark;\n }\n }\n \n @media (prefers-color-scheme: light) {\n :root:not([data-limbo-theme]) {\n color-scheme: light;\n }\n }\n \n /* ===================================\n MODO COMPACTO - ESTILOS ESPECÍFICOS \n =================================== */\n \n /* Activación del modo compacto por atributo o clase */\n [data-limbo-compact="true"],\n .limbo-compact-mode {\n /* Componentes base más pequeños */\n --limbo-font-size-md: var(--limbo-font-size-compact-md);\n --limbo-font-size-sm: var(--limbo-font-size-compact-sm);\n --limbo-font-size-lg: var(--limbo-font-size-compact-lg);\n --limbo-spacing: var(--limbo-spacing-compact);\n --limbo-radius-md: var(--limbo-radius-compact);\n --limbo-gap: var(--limbo-gap-compact);\n }\n \n /* Botones compactos */\n [data-limbo-compact="true"] .limbo-button,\n .limbo-compact-mode .limbo-button {\n height: var(--limbo-button-height-compact);\n padding: var(--limbo-spacing-compact-sm) var(--limbo-spacing-compact);\n font-size: var(--limbo-font-size-compact-sm);\n border-radius: var(--limbo-radius-compact);\n min-width: auto;\n }\n \n /* Inputs compactos */\n [data-limbo-compact="true"] .limbo-input,\n .limbo-compact-mode .limbo-input {\n height: var(--limbo-input-height-compact);\n padding: var(--limbo-spacing-compact-sm) var(--limbo-spacing-compact);\n font-size: var(--limbo-font-size-compact-md);\n border-radius: var(--limbo-radius-compact);\n }\n \n /* Cards compactas */\n [data-limbo-compact="true"] .limbo-card,\n .limbo-compact-mode .limbo-card {\n padding: var(--limbo-card-padding-compact);\n border-radius: var(--limbo-radius-compact-lg);\n }\n \n /* Modales compactos */\n [data-limbo-compact="true"] .limbo-modal,\n .limbo-compact-mode .limbo-modal {\n padding: var(--limbo-modal-padding-compact);\n border-radius: var(--limbo-radius-compact-lg);\n max-width: 90vw;\n max-height: 90vh;\n }\n \n /* Tabs compactas */\n [data-limbo-compact="true"] .limbo-tabs,\n .limbo-compact-mode .limbo-tabs {\n gap: var(--limbo-gap-compact-sm);\n }\n \n [data-limbo-compact="true"] .limbo-tab,\n .limbo-compact-mode .limbo-tab {\n padding: var(--limbo-spacing-compact-sm) var(--limbo-spacing-compact);\n font-size: var(--limbo-font-size-compact-sm);\n border-radius: var(--limbo-radius-compact-sm);\n }\n \n /* Gallery compacta */\n [data-limbo-compact="true"] .limbo-gallery,\n .limbo-compact-mode .limbo-gallery {\n gap: var(--limbo-gap-compact-sm);\n }\n \n [data-limbo-compact="true"] .limbo-gallery-item,\n .limbo-compact-mode .limbo-gallery-item {\n border-radius: var(--limbo-radius-compact);\n min-height: 120px; /* Más pequeño para móviles */\n }\n \n /* Notificaciones compactas */\n [data-limbo-compact="true"] .limbo-notification,\n .limbo-compact-mode .limbo-notification {\n padding: var(--limbo-spacing-compact-sm) var(--limbo-spacing-compact);\n font-size: var(--limbo-font-size-compact-sm);\n border-radius: var(--limbo-radius-compact);\n }\n \n /* Progress indicators compactos */\n [data-limbo-compact="true"] .limbo-progress,\n .limbo-compact-mode .limbo-progress {\n height: 3px; /* Más delgado */\n }\n \n [data-limbo-compact="true"] .limbo-progress-circular,\n .limbo-compact-mode .limbo-progress-circular {\n width: 20px;\n height: 20px;\n }\n \n /* Auto-activación en pantallas pequeñas */\n @media (max-width: 768px) {\n :root[data-limbo-compact="auto"],\n .limbo-component[data-limbo-compact="auto"] {\n /* Aplicar automáticamente estilos compactos */\n --limbo-font-size-md: var(--limbo-font-size-compact-md);\n --limbo-font-size-sm: var(--limbo-font-size-compact-sm);\n --limbo-spacing: var(--limbo-spacing-compact);\n --limbo-radius-md: var(--limbo-radius-compact);\n --limbo-gap: var(--limbo-gap-compact);\n }\n \n /* Modal full-screen en móvil cuando es compacto */\n [data-limbo-compact="auto"] .limbo-modal,\n [data-limbo-compact="true"] .limbo-modal {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100vw;\n height: 100vh;\n max-width: 100vw;\n max-height: 100vh;\n border-radius: 0;\n margin: 0;\n }\n \n /* Tabs en accordion en móvil */\n [data-limbo-compact="auto"] .limbo-tabs,\n [data-limbo-compact="true"] .limbo-tabs {\n flex-direction: column;\n width: 100%;\n }\n \n /* Gallery de 2 columnas en móvil */\n [data-limbo-compact="auto"] .limbo-gallery,\n [data-limbo-compact="true"] .limbo-gallery {\n grid-template-columns: 1fr 1fr;\n gap: var(--limbo-gap-compact);\n }\n }\n \n /* Touch targets más grandes en móviles */\n @media (max-width: 768px) and (pointer: coarse) {\n [data-limbo-compact="auto"] .limbo-button,\n [data-limbo-compact="true"] .limbo-button {\n min-height: 44px; /* Tamaño mínimo de toque recomendado */\n padding: var(--limbo-spacing-compact) var(--limbo-spacing-compact-lg);\n }\n \n [data-limbo-compact="auto"] .limbo-tab,\n [data-limbo-compact="true"] .limbo-tab {\n min-height: 44px;\n }\n }\n `,t=document.createElement("style");t.id="limbo-theme-styles",t.textContent=e,document.head.appendChild(t)}applyTheme(e,t={}){const l=this._getTheme(e);if(!l)return console.warn(`Theme '${e}' not found`),!1;const n=this.currentTheme;return this._applyThemeVariables(l,t.scope),this._updateThemeAttributes(l.name),this.config.theme.storage&&!t.temporary&&this._saveThemePreference(l.name),this.currentTheme=l.name,this._triggerChangeCallbacks(l.name,n),!0}toggleTheme(e="light",t="dark"){const l=this.currentTheme===e?t:e;return this.applyTheme(l)}applyAutoTheme(){const e=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";return this.applyTheme(e)}registerTheme(e,t){const l={name:e,displayName:t.displayName||e,variables:t.variables||{},extends:t.extends||null,...t};if(l.extends){const e=this._getTheme(l.extends);e&&(l.variables={...e.variables,...l.variables})}return this.customThemes.set(e,l),this}removeTheme(e){if(this.config.presets[e])return console.warn(`Cannot remove predefined theme: ${e}`),!1;const t=this.customThemes.delete(e);return t&&this.currentTheme===e&&this.applyTheme(this.config.inheritance.fallbackTheme),t}getAvailableThemes(){const e=Object.keys(this.config.presets),t=Array.from(this.customThemes.keys());return{presets:e,custom:t,all:[...e,...t]}}getCurrentTheme(){return{name:this.currentTheme,theme:this._getTheme(this.currentTheme),isCustom:this.customThemes.has(this.currentTheme),variables:this._getCurrentVariables()}}enableCompactMode(e={}){const t={element:document.documentElement,persist:!0,...e};return t.element.setAttribute("data-limbo-compact","true"),t.element.classList.add("limbo-compact-mode"),this.isCompactMode=!0,t.persist&&this.config.compact.persistPreference&&this._saveCompactPreference(!0),this._triggerCompactChange(!0),this}disableCompactMode(e={}){const t={element:document.documentElement,persist:!0,...e};return t.element.setAttribute("data-limbo-compact","false"),t.element.classList.remove("limbo-compact-mode"),this.isCompactMode=!1,t.persist&&this.config.compact.persistPreference&&this._saveCompactPreference(!1),this._triggerCompactChange(!1),this}toggleCompactMode(e={}){return this.isCompactMode?this.disableCompactMode(e):this.enableCompactMode(e)}applyAutoCompactMode(){const e=this._shouldUseCompactMode();return e&&!this.isCompactMode?this.enableCompactMode({persist:!1}):!e&&this.isCompactMode&&this.disableCompactMode({persist:!1}),this}getCompactState(){return{isEnabled:this.isCompactMode,isAuto:this.config.compact.auto,breakpoint:this.config.compact.breakpoint,currentViewport:window.innerWidth,shouldBeCompact:this._shouldUseCompactMode()}}_shouldUseCompactMode(){if(!this.config.compact.auto)return this.config.compact.enabled;const e=window.innerWidth<=this.config.compact.breakpoint,t=/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),l="ontouchstart"in window||navigator.maxTouchPoints>0;return!(!this.config.compact.forceOnMobile||!t&&!l)||e}_saveCompactPreference(e){try{localStorage.setItem("limbo-compact-preference",e.toString())}catch(t){console.warn("Could not save compact preference:",t)}}_loadCompactPreference(){try{return"true"===localStorage.getItem("limbo-compact-preference")}catch(e){return console.warn("Could not load compact preference:",e),null}}_triggerCompactChange(e){this.changeCallbacks.forEach(t=>{try{t({type:"compact",isCompact:e,viewport:window.innerWidth,timestamp:Date.now()})}catch(l){console.error("Error in compact mode change callback:",l)}})}_inheritPortalTheme(){const e=this._detectPortalTheme();return e?(this.registerTheme("portal-inherited",e),"portal-inherited"):null}_detectPortalTheme(){const e={name:"portal-detected",displayName:"Tema del Portal",variables:{}};for(const t of this.config.inheritance.portalSelectors){const l=document.querySelector(t);if(l){const t=this._extractCSSVariables(l);Object.keys(t).length>0&&(e.variables={...e.variables,...t});const n=l.getAttribute("data-theme")||l.getAttribute("class")?.match(/theme-(\w+)/)||l.getAttribute("class")?.match(/(\w+)-theme/);n&&(e.detectedName=Array.isArray(n)?n[1]:n)}}return Object.keys(e.variables).length>0?e:null}_extractCSSVariables(e){const t={},l=getComputedStyle(e);["primary","primary-hover","primary-light","primary-dark","bg-primary","bg-secondary","bg-tertiary","bg-card","bg-input","text-primary","text-secondary","text-tertiary","text-inverse","border-light","border-medium","border-strong","border-focus","success","error","warning","info","shadow-sm","shadow-md","shadow-lg","shadow-xl","radius-sm","radius-md","radius-lg","radius-xl"].forEach(e=>{const n=`--limbo-${e}`,a=l.getPropertyValue(n).trim();a&&(t[n]=a)});return["--primary-color","--background-color","--text-color","--border-color","--accent-color","--surface-color"].forEach(e=>{const n=l.getPropertyValue(e).trim();if(n){const l=this._mapGenericToLimbo(e,n);l&&Object.assign(t,l)}}),t}_mapGenericToLimbo(e,t){return{"--primary-color":{"--limbo-primary":t},"--background-color":{"--limbo-bg-primary":t},"--text-color":{"--limbo-text-primary":t},"--border-color":{"--limbo-border-light":t},"--accent-color":{"--limbo-primary":t},"--surface-color":{"--limbo-bg-card":t}}[e]||null}_applyInitialTheme(){let e=this.config.inheritance.fallbackTheme;if(this.config.theme.storage){const t=this._loadThemePreference();t&&this._getTheme(t)&&(e=t)}const t=document.documentElement.getAttribute("data-limbo-theme");t&&this._getTheme(t)&&(e=t);const l=this._inheritPortalTheme();l&&(e=l),this.config.theme.auto&&"auto"===e&&(e=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),this.applyTheme(e,{temporary:!1})}_applyInitialCompactMode(){let e=!1;if(this.config.compact.persistPreference){const t=this._loadCompactPreference();null!==t&&(e=t)}const t=document.documentElement.getAttribute("data-limbo-compact");"true"===t?e=!0:"false"===t&&(e=!1),("auto"===t||this.config.compact.auto)&&(e=this._shouldUseCompactMode()),e?this.enableCompactMode({persist:!1}):this.disableCompactMode({persist:!1})}_applyThemeVariables(e,t=document.documentElement){const l="string"==typeof t?document.querySelector(t):t;l?(Object.entries(e.variables).forEach(([e,t])=>{l.style.setProperty(e,t),this.appliedStyles.add(`${l.tagName}:${e}`)}),this.themeCache.set(e.name,{theme:e,appliedAt:Date.now(),scope:l})):console.warn("Theme scope element not found")}_updateThemeAttributes(e){document.documentElement.setAttribute("data-limbo-theme",e),document.documentElement.classList.remove("limbo-theme-light","limbo-theme-dark","limbo-theme-auto"),document.documentElement.classList.add(`limbo-theme-${e}`),this._updateMetaThemeColor(e)}_updateMetaThemeColor(e){const t=this._getTheme(e);if(!t)return;const l=t.variables["--limbo-primary"]||"#3b82f6";let n=document.querySelector('meta[name="theme-color"]');n||(n=document.createElement("meta"),n.name="theme-color",document.head.appendChild(n)),n.content=l}_getTheme(e){return this.config.presets[e]?this.config.presets[e]:this.customThemes.has(e)?this.customThemes.get(e):null}_getCurrentVariables(){const e=this._getTheme(this.currentTheme);if(!e)return{};const t=getComputedStyle(document.documentElement),l={};return Object.keys(e.variables).forEach(e=>{l[e]=t.getPropertyValue(e).trim()}),l}_saveThemePreference(e){try{localStorage.setItem("limbo-theme-preference",e)}catch(t){console.warn("Could not save theme preference:",t)}}_loadThemePreference(){try{return localStorage.getItem("limbo-theme-preference")}catch(e){return console.warn("Could not load theme preference:",e),null}}_loadCustomThemes(){try{const e=localStorage.getItem("limbo-custom-themes");if(e){const t=JSON.parse(e);Object.entries(t).forEach(([e,t])=>{this.customThemes.set(e,t)})}}catch(e){console.warn("Could not load custom themes:",e)}}_saveCustomThemes(){try{const e=Object.fromEntries(this.customThemes);localStorage.setItem("limbo-custom-themes",JSON.stringify(e))}catch(e){console.warn("Could not save custom themes:",e)}}_setupObservers(){this.config.theme.detectSystem&&this._setupSystemObserver(),this.config.theme.storage&&this._setupStorageObserver(),this._setupMutationObserver(),this.config.compact.auto&&this._setupViewportObserver()}_setupSystemObserver(){const e=window.matchMedia("(prefers-color-scheme: dark)");e.addEventListener("change",e=>{if("auto"===this.currentTheme||this.config.theme.auto){const t=e.matches?"dark":"light";this.applyTheme(t,{temporary:!0})}}),this.mediaQueryObserver=e}_setupStorageObserver(){const e=e=>{"limbo-theme-preference"===e.key&&e.newValue!==this.currentTheme&&this._getTheme(e.newValue)&&this.applyTheme(e.newValue)};window.addEventListener("storage",e),this.storageListener=e}_setupMutationObserver(){const e=new MutationObserver(e=>{e.forEach(e=>{if("attributes"===e.type&&"data-limbo-theme"===e.attributeName){const t=e.target.getAttribute("data-limbo-theme");t&&t!==this.currentTheme&&this._getTheme(t)&&this.applyTheme(t)}})});e.observe(document.documentElement,{attributes:!0,attributeFilter:["data-limbo-theme"]}),this.mutationObserver=e}_setupViewportObserver(){const e=`(max-width: ${this.config.compact.breakpoint}px)`,t=window.matchMedia(e);t.addEventListener("change",()=>{("auto"===document.documentElement.getAttribute("data-limbo-compact")||this.config.compact.auto)&&this.applyAutoCompactMode()}),this.compactObserver=t,window.addEventListener("orientationchange",()=>{setTimeout(()=>{("auto"===document.documentElement.getAttribute("data-limbo-compact")||this.config.compact.auto)&&this.applyAutoCompactMode()},100)})}onThemeChange(e){return this.changeCallbacks.add(e),()=>this.changeCallbacks.delete(e)}_triggerChangeCallbacks(e,t){this.changeCallbacks.forEach(l=>{try{l({theme:e,previousTheme:t,themeData:this._getTheme(e),variables:this._getCurrentVariables()})}catch(n){console.error("Error in theme change callback:",n)}})}generateThemeFromColors(e,t){const l={name:e,displayName:e,variables:{}};t.primary&&(l.variables["--limbo-primary"]=t.primary,l.variables["--limbo-primary-hover"]=this._darkenColor(t.primary,10),l.variables["--limbo-primary-light"]=this._lightenColor(t.primary,40),l.variables["--limbo-primary-dark"]=this._darkenColor(t.primary,20)),t.background&&(l.variables["--limbo-bg-primary"]=t.background,l.variables["--limbo-bg-secondary"]=this._lightenColor(t.background,5),l.variables["--limbo-bg-tertiary"]=this._lightenColor(t.background,10),l.variables["--limbo-bg-card"]=t.background),t.text&&(l.variables["--limbo-text-primary"]=t.text,l.variables["--limbo-text-secondary"]=this._lightenColor(t.text,20),l.variables["--limbo-text-tertiary"]=this._lightenColor(t.text,40));const n=this._getTheme(this.config.inheritance.fallbackTheme);return n&&(l.variables={...n.variables,...l.variables}),this.registerTheme(e,l),l}_darkenColor(e,t){const l=parseInt(e.replace("#",""),16),n=Math.round(2.55*t),a=(l>>16)-n,r=(l>>8&255)-n,i=(255&l)-n;return"#"+(16777216+65536*(a<255?a<1?0:a:255)+256*(r<255?r<1?0:r:255)+(i<255?i<1?0:i:255)).toString(16).slice(1)}_lightenColor(e,t){const l=parseInt(e.replace("#",""),16),n=Math.round(2.55*t),a=(l>>16)+n,r=(l>>8&255)+n,i=(255&l)+n;return"#"+(16777216+65536*(a<255?a<1?0:a:255)+256*(r<255?r<1?0:r:255)+(i<255?i<1?0:i:255)).toString(16).slice(1)}_deepMerge(e,t){const l={...e};return Object.keys(t).forEach(n=>{t[n]&&"object"==typeof t[n]&&!Array.isArray(t[n])?l[n]=this._deepMerge(e[n]||{},t[n]):l[n]=t[n]}),l}getThemeInfo(){return{current:this.getCurrentTheme(),available:this.getAvailableThemes(),compact:this.getCompactState(),config:this.config,isInitialized:this.isInitialized,cache:{themes:this.themeCache.size,applied:this.appliedStyles.size},observers:{system:!!this.mediaQueryObserver,storage:!!this.storageListener,mutation:!!this.mutationObserver,viewport:!!this.compactObserver}}}debug(){return console.table(this.getThemeInfo()),this.getThemeInfo()}destroy(){this.mediaQueryObserver&&this.mediaQueryObserver.removeEventListener("change",this._setupSystemObserver),this.storageListener&&window.removeEventListener("storage",this.storageListener),this.mutationObserver&&this.mutationObserver.disconnect(),this.compactObserver&&this.compactObserver.removeEventListener("change",this._setupViewportObserver),this.changeCallbacks.clear(),this.themeCache.clear(),this.appliedStyles.clear(),this._saveCustomThemes();const e=document.getElementById("limbo-theme-styles");e&&e.remove(),this.isInitialized=!1}}const On={border:"none",borderRadius:"6px",cursor:"pointer",fontFamily:"inherit",fontWeight:"500",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"6px",transition:"background 0.2s ease, transform 0.1s ease",userSelect:"none",textDecoration:"none",lineHeight:"1.25"},Fn={bg:"#001978",hover:"#334793"},Un={bg:"#10b981",hover:"#059669"},Bn={bg:"#9ca3af",hover:"#9ca3af"};class qn extends HTMLElement{constructor(){super(),this._btn=null,this._limboInstance=null}connectedCallback(){this._ensureButton(),this._syncButton()}disconnectedCallback(){this._destroyLimboInstance()}static get observedAttributes(){return["accept","has-file","disabled","compact","label-select","label-change","return-format","button-class","existing-url","mandatory-crops","public-key","token","auth-mode"]}attributeChangedCallback(){this._btn&&this._syncButton()}markSelected(e){this.setAttribute("has-file",""),e&&this.setAttribute("existing-url",e),this._syncButton()}clearSelection(){this.removeAttribute("has-file"),this.removeAttribute("existing-url"),this._syncButton()}open(){this._open()}_ensureButton(){this._btn||(this._btn=document.createElement("button"),this._btn.type="button",this._btn.classList.add("limbo-selector-btn","limbo-trigger-button","mecano:my-2"),this._btn.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this._open()}),this.appendChild(this._btn))}_syncButton(){if(!this._btn)return;const e=this.getAttribute("accept")||null,t=this.hasAttribute("has-file"),l=this.hasAttribute("disabled"),n=this.hasAttribute("compact"),a=this.getAttribute("label-select")||null,r=this.getAttribute("label-change")||null,i=this.getAttribute("button-class")||null;this._btn.textContent=t?r||u(e,!0):a||u(e,!1),this._btn.disabled=l,i&&i.split(/\s+/).filter(Boolean).forEach(e=>this._btn.classList.add(e));const o=l?Bn:t?Un:Fn;Object.assign(this._btn.style,{...On,fontSize:n?"12px":"14px",padding:n?"6px 12px":"8px 16px",background:o.bg,color:"white",opacity:l?"0.55":"1",cursor:l?"not-allowed":"pointer"}),this._btn.onmouseenter=()=>{l||(this._btn.style.background=o.hover,this._btn.style.transform="translateY(-1px)",this._btn.style.boxShadow="0 4px 10px rgba(0,0,0,0.18)")},this._btn.onmouseleave=()=>{this._btn.style.background=o.bg,this._btn.style.transform="translateY(0)",this._btn.style.boxShadow="none"}}_open(){const e=window.Limbo||window.limboCore;if(!e)return void console.warn("[LimboSelector] window.Limbo no encontrado. Asegúrate de que el script de Limbo está cargado antes de usar <limbo-selector>.");const t=this.getAttribute("accept")||null,l=this.getAttribute("return-format")||"url",n=this.getAttribute("existing-url")||null,a=this.getAttribute("public-key")||null,r=this.getAttribute("token")||null,i=this.getAttribute("auth-mode")||null;(a||r)&&e.configure({...a&&{publicKey:a},...r&&{token:r},authMode:i||(r?"manual":"session")}),e.config?.setGlobal&&e.config.setGlobal({interaction:{allowSelection:!0,allowCropping:!0,selectionMode:"direct"}});let o=null;const s=this.getAttribute("mandatory-crops");if(s)try{o=JSON.parse(s)}catch{}this._destroyLimboInstance();try{const a={mode:"modal",modeUI:"full",modalSize:"fullscreen",features:["gallery","upload","cropper"],title:"Seleccionar archivo",validation:{accept:t},returnConfig:{format:l},initialImageUrl:n,interaction:{allowSelection:!0,allowCropping:!0},cropper:o?.length>0?{mandatoryCrops:o,allowAdditionalCrops:!0,maxCrops:10}:null},r=async e=>{const t="string"==typeof e?e:e?.images?.[0]?.url||e?.original?.url||e?.url||"";this.setAttribute("has-file",""),t&&this.setAttribute("existing-url",t),this._syncButton(),this.dispatchEvent(new CustomEvent("limbo:change",{detail:{data:e,url:t},bubbles:!0,composed:!0}))};e.events.emit("autoInputs:modalRequest",{config:a,input:null,callback:r})}catch(c){console.error("[LimboSelector] Error al abrir modal de Limbo:",c)}}_handleResult(e,t){if(this._limboInstance!==t)return;const l="string"==typeof e?e:e?.url||e?.master?.urlSigned||e?.master?.url||e?.asset?.url||e?.original?.url||e?.crops?.[0]?.url||e?.images?.[0]?.url||"";this.setAttribute("has-file",""),l&&this.setAttribute("existing-url",l),this._syncButton(),this.dispatchEvent(new CustomEvent("limbo:change",{detail:{data:e,url:l},bubbles:!0,composed:!0}));try{t?.close?.()}catch{}this._limboInstance=null}_destroyLimboInstance(){if(this._limboInstance){try{this._limboInstance.destroy?.()}catch{}this._limboInstance=null}}}function Wn(e="limbo-selector"){"undefined"==typeof customElements||customElements.get(e)||customElements.define(e,qn)}const Vn=new class{constructor(){this.config=new p,this.instances=new Ln,this.autoInputs=new Mn,this.events=new In,this.modals=new Pn,this.theme=new Rn,this.containerQueryDetector=E,this._setupInternalListeners(),this._initializeContainerQueries()}configure(e){this.config.setGlobal(e);const t={};var l;return"publicKey"in e&&(t.publicKey=e.publicKey),"apiKey"in e&&(t.apiKey=e.apiKey),"token"in e&&(t.token=e.token),"authMode"in e&&(t.authMode=e.authMode),"tokenProvider"in e&&(t.tokenProvider=e.tokenProvider),"prod"in e&&(t.prod=Boolean(e.prod)),"mode"in e&&(t.mode=e.mode),"callbacks"in e&&(t.callbacks=e.callbacks),"token"in(l=t)&&l.token!==M.token&&(I=!1,P=null),M={...M,...l},M.authMode||(M.token?M.authMode="manual":M.authMode="session"),this.config}setToken(e){return B(e),this.config.setGlobal({token:e}),this}create(e){const t=this.config.merge(e);return this.instances.create(t,this.events,this.modals)}configureAutoInputs(e){return this.autoInputs.configure(e,this.config,this.events)}setTheme(e){return e&&(this.config.set("theme",e),this.theme.setTheme(e),this.events.emit("theme:changed",{theme:e})),this}getTheme(){return this.theme.getCurrentTheme()}scanAndActivate(e=null){const t=this.autoInputs.config?.dataset||"data-limbo-input-file",l=e||`[${t}]`,n=document.querySelectorAll(l);if(0===n.length)return{found:0,processed:0,skipped:0};let a=0,r=0;return n.forEach(e=>{try{this.autoInputs._processInput(e),a++}catch(t){console.warn(`⚠️ Limbo: Error procesando input ${e.id||e.name}:`,t),r++}}),this.events.emit("limbo:scanCompleted",{found:n.length,processed:a,skipped:r,inputs:Array.from(n)}),{found:n.length,processed:a,skipped:r}}_initializeContainerQueries(){this.containerQueryDetector.observeResize(),setTimeout(()=>{document.querySelectorAll(".limbo-component-container-wrapper").forEach(e=>{this.containerQueryDetector.applyResponsiveClasses(e)})},100)}rescan(e=document){const t=this.autoInputs.config?.dataset||"data-limbo-input-file",l=e.querySelectorAll(`[${t}]`);let n=0;return l.forEach(e=>{if(!this.autoInputs.instances.has(this.autoInputs._getInputId(e)))try{this.autoInputs._processInput(e),n++}catch(t){console.warn("⚠️ Limbo: Error procesando nuevo input:",t)}}),n}init(e){const t=this._mapLegacyOptions(e);return this.create(t)}getInstances(){return this.instances.getAll()}destroy(){this.instances.destroyAll(),this.autoInputs.cleanup(),this.events.cleanup(),this.theme.removeTheme()}_mapLegacyOptions(e){return{container:e.container||"#image-manager",mode:"embed",features:["gallery","upload","cropper"],apiKey:e.apiKey,prod:e.prod||!1,url:void 0===e.url||e.url}}_setupInternalListeners(){this.events.on("autoInputs:modalRequest",({config:e,callback:t,input:l})=>{this._handleAutoInputModalRequest({config:e,callback:t,input:l})})}_handleAutoInputModalRequest({config:e,callback:t,input:l}){const n=l,a=async l=>{let a={};if(l.crops&&l.crops.length>0){const e=l.asset||l.original;a.original={url:e?.url||e?.urlSigned||l.originalUrl,width:e?.width||l.originalWidth,height:e?.height||l.originalHeight,assetId:e?.id||l.assetId},a.images=l.crops.map(e=>({url:e.url||e.urlSigned,width:e.width,height:e.height,name:e.name||e.filename}))}else l.asset?a.original={url:l.asset.url||l.asset.urlSigned,width:l.asset.width,height:l.asset.height,assetId:l.asset.id}:l.master?.urlSigned||l.master?.url?a.original={url:l.master.urlSigned||l.master.url,width:l.master.width||l.width,height:l.master.height||l.height,assetId:l.assetId}:l.url||l.urlSigned?a.original={url:l.url||l.urlSigned,width:l.width,height:l.height,assetId:l.assetId||l.id}:(console.warn("[Limbo] handleResult: formato de datos no reconocido",l),a=l);if(n){var r=e?.returnConfig?.format||"json",i="";i="url"===r?a.images?.[0]?.url||a.original?.url||"":"assetId"===r?a.original?.assetId||"":JSON.stringify(a),n.value=i,n.dispatchEvent(new Event("change",{bubbles:!0})),console.log("[Limbo] ✅ Valor asignado al input:",n.value?.substring(0,80))}try{await t(a)}catch(o){}u.close()},r={...e,mode:"modal",autoDestroy:!0,interaction:{allowSelection:!0,allowCropping:!0,...e.interaction},callbacks:{onSelect:e=>{a(e)},onCropsSaved:e=>{a(e)},onCropperComplete:e=>{a(e)},onUpload:t=>{"upload-only"!==e.modeUI||e.features?.includes("cropper")||a(t)},onClose:()=>{}}},i=e.validation?.accept||null,o=i?s(i):null,c=!o||o.isAllTypes||o.includesImages;if(e.initialImageUrl&&c){const t=this._extractAssetIdFromUrl(e.initialImageUrl)||e.existingData?.original?.assetId||null;t&&(r._externalImage={url:e.initialImageUrl,filename:e.initialImageUrl.split("/").pop()?.split("?")[0]||"image.jpg",width:1920,height:1080,mime_type:"image/jpeg",id:t})}e.cropper&&(r.cropper=e.cropper),this.config.setGlobal({interaction:{allowSelection:!0,allowCropping:!0,...e.interaction}});const u=this.create(r);u.open()}_extractAssetIdFromUrl(e){if(!e)return null;try{const t=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,l=e.match(t);return l&&l.length>=2?l[1]:l&&1===l.length?l[0]:null}catch(t){return console.warn("Error extracting asset ID from URL:",t),null}}openGallery(e={}){const t=this.create({mode:"modal",modeUI:"gallery-only",features:["gallery"],autoDestroy:!0,modal:{title:e.title||"Seleccionar Imagen",size:e.size||"large"},validation:{accept:e.accept||null},callbacks:{onSelect:l=>{e.onSelect?.(l),!1!==e.autoClose&&t.close()}},...e});return t.open(),t}openUploader(e={}){const t=!1!==e.redirectToGallery?["upload","gallery"]:["upload"],l=this.create({mode:"modal",modeUI:!1!==e.redirectToGallery?"full":"upload-only",features:t,autoDestroy:!0,modal:{title:e.title||"Subir Imagen",size:e.size||"medium"},validation:{accept:e.accept||null},callbacks:{onUpload:t=>{e.onUpload?.(t),!1===e.autoClose||e.redirectToGallery||l.close()}},...e});return l.open(),l}openCropper(e,t={}){if(!e)throw new Error("Limbo.openCropper: imageUrl es requerido");const l={url:e,filename:t.filename||"image.jpg",width:t.width||1920,height:t.height||1080,mime_type:t.mimeType||"image/jpeg",id:t.assetId||`external-${Date.now()}`},n=this.create({mode:"modal",modeUI:"crop-only",features:["cropper"],autoDestroy:!0,modal:{title:t.title||"Recortar Imagen",size:"xlarge"},cropper:{mandatoryCrops:t.mandatoryCrops||[],allowCustomCrops:!1!==t.allowCustomCrops,enforceRequiredCrops:!1!==t.enforceRequiredCrops},callbacks:{onCropperComplete:e=>{t.onComplete?.(e),!1!==t.autoClose&&n.close()},onCropperCancelled:e=>{t.onCancelled?.(e),!1!==t.autoClose&&n.close()},onCropperError:e=>{t.onError?.(e)}},_externalImage:l,...t});return n.open(),n}createInlineGallery(e,t={}){return this.create({container:e,mode:"embed",modeUI:"gallery-only",features:["gallery"],validation:{accept:t.accept||null},callbacks:{onSelect:t.onSelect,onDelete:t.onDelete},...t})}createInlineUploader(e,t={}){return this.create({container:e,mode:"embed",modeUI:"upload-only",features:["upload"],validation:{accept:t.accept||null},callbacks:{onUpload:t.onUpload},...t})}createStandaloneCropper(e,t,l={}){if(!e)throw new Error("Limbo.createStandaloneCropper: container es requerido");if(!t)throw new Error("Limbo.createStandaloneCropper: imageUrl es requerido");const n={url:t,filename:l.filename||"image.jpg",width:l.width||1920,height:l.height||1080,mime_type:l.mimeType||"image/jpeg",id:l.assetId||`external-${Date.now()}`};return this.create({container:e,mode:"embed",modeUI:"crop-only",features:["cropper"],autoHideOnComplete:!1!==l.autoHideOnComplete,cropper:{mandatoryCrops:l.mandatoryCrops||[],allowCustomCrops:!1!==l.allowCustomCrops,enforceRequiredCrops:!1!==l.enforceRequiredCrops},callbacks:{onCropperComplete:l.onComplete,onCropperCancelled:l.onCancelled,onCropperError:l.onError},_externalImage:n,...l})}createFullSelector(e,t={}){return this.create({container:e,mode:t.mode||"embed",modeUI:"full",features:["gallery","upload","cropper"],validation:{accept:t.accept||null},callbacks:{onSelect:t.onSelect,onUpload:t.onUpload,onDelete:t.onDelete,onCropsSaved:t.onCropsSaved},...t})}};"undefined"!=typeof window&&(window.Limbo=Vn,window.limboCore=Vn,Wn());"undefined"!=typeof window&&document.querySelector("#root")&&(Vn.configure({prod:!1,publicKey:"pk_e464fd744106b7a8d63d453c4bd02582",authMode:"session"}),Vn.create({container:"#root",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],title:"Limbo Image Manager - Development",url:!0}),Vn.configureAutoInputs({dataset:"data-limbo-input-file",return:"json",features:["gallery","upload","cropper"],modeUI:"full",modalSize:"large",title:"Seleccionar archivo",crops:"free",allowDelete:!1})),exports.LIMBO_BASE_URL=ft,exports.LimboSelector=qn,exports.decodeHtmlEntities=vt,exports.default=Vn,exports.extractImageUrl=xt,exports.getButtonLabel=u,exports.isValidImageUrl=yt,exports.parseImageData=function(e,t={}){const{isProd:l=!1}=t;if(!e)return{original:null,images:[],url:""};try{const t=JSON.parse(vt(e)),n=t.original?{...t.original,url:gt(t.original.url,l)}:null,a=(t.images||[]).map(e=>({...e,url:gt(e.url,l)}));return{original:n,images:a,url:a[0]?.url||n?.url||gt(t.url,l)||""}}catch{return{original:null,images:[],url:gt(e,l)}}},exports.prepareImageFieldsForPreview=function(e,t={}){const{isProd:l=!1}=t;if(!e?.fields)return e;const n=e.fields.map(e=>{if("image"===e.type&&"string"==typeof e.example_value){const t=xt(e.example_value,{isProd:l});return{...e,example_value:t||e.example_value}}return e});return{...e,fields:n}},exports.registerLimboSelector=Wn,exports.resolveUrl=gt;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react"),t=require("react-dom"),l=require("react/jsx-runtime"),n={jpg:["image/jpeg"],jpeg:["image/jpeg"],png:["image/png"],gif:["image/gif"],webp:["image/webp"],svg:["image/svg+xml"],mp4:["video/mp4"],webm:["video/webm"],mov:["video/quicktime"],avi:["video/x-msvideo"],mkv:["video/x-matroska"],pdf:["application/pdf"],doc:["application/msword"],docx:["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],xls:["application/vnd.ms-excel"],xlsx:["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],ppt:["application/vnd.ms-powerpoint"],pptx:["application/vnd.openxmlformats-officedocument.presentationml.presentation"],txt:["text/plain"],csv:["text/csv"],json:["application/json"],xml:["application/xml","text/xml"],html:["text/html"],css:["text/css"],js:["text/javascript","application/javascript"],md:["text/markdown"],mp3:["audio/mpeg"],wav:["audio/wav"],ogg:["audio/ogg"],aac:["audio/aac"],flac:["audio/flac"]},a={image:["image/jpeg","image/png","image/webp","image/svg+xml"],video:["image/gif","video/mp4","video/webm","video/quicktime","video/x-msvideo","video/x-matroska"],document:["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/plain","text/csv"],audio:["audio/mpeg","audio/wav","audio/ogg","audio/webm","audio/aac","audio/flac"]},r=new Set(["jpg","jpeg","png","webp","svg","bmp","tiff","ico"]),i=new Set(["mp4","webm","mov","avi","mkv","gif"]),o=Object.freeze({categories:[],extensions:[],mimeTypes:[],acceptString:"",includesImages:!0,includesVideos:!0,isAllTypes:!0,raw:null});function s(e){if(!e)return o;const t=Array.isArray(e)?e.join(","):String(e),l=t.split(",").map(e=>e.trim()).filter(Boolean);if(0===l.length)return o;const s=[],c=[],u=new Set;for(const r of l)if(r.endsWith("/*")){const e=r.replace("/*","");a[e]&&(s.push(e),a[e].forEach(e=>u.add(e)))}else if(r.startsWith(".")){const e=r.slice(1).toLowerCase();c.push(e),(n[e]||[]).forEach(e=>u.add(e))}else r.includes("/")&&u.add(r);const d=s.includes("image")||c.some(e=>r.has(e)),b=s.includes("video")||c.some(e=>i.has(e));return{categories:s,extensions:c,mimeTypes:[...u],acceptString:[...u].join(","),includesImages:d,includesVideos:b,isAllTypes:!1,raw:t}}function c(e){if(!e||e.isAllTypes)return"Todos los formatos";const t=new Set;for(const l of e.categories)switch(l){case"image":t.add("Imágenes");break;case"video":t.add("Videos");break;case"document":t.add("Documentos");break;case"audio":t.add("Audio")}for(const l of e.extensions)t.add(l.toUpperCase());return[...t].join(", ")||"Todos los formatos"}function u(e,t=!1){const l=t?"Cambiar":"Seleccionar";if(!e)return`${l} archivo`;const n=s(e);if(n.isAllTypes)return`${l} archivo`;const{includesImages:a,includesVideos:r,categories:i}=n,o=i.some(e=>"image"!==e&&"video"!==e);return!a||r||o?!r||a||o?`${l} archivo`:`${l} vídeo`:`${"Cambiar"==l?"Editar":l} imagen`}const d={es:{"button.select":"Seleccionar","button.upload":"Subir archivo","button.cancel":"Cancelar","button.close":"Cerrar","button.save":"Guardar","button.delete":"Eliminar","button.download":"Descargar","button.copy":"Copiar URL","button.crop":"Recortar","button.apply":"Aplicar","button.reset":"Reiniciar","button.back":"Volver","button.next":"Siguiente","button.previous":"Anterior","tab.gallery":"Galería","tab.upload":"Subir","tab.ia":"IA","tab.stock":"Stock","tab.cropper":"Recortar","message.loading":"Cargando...","message.uploading":"Subiendo archivo...","message.processing":"Procesando...","message.no_images":"No hay archivos disponibles","message.upload_success":"Archivo subido correctamente","message.upload_error":"Error al subir el archivo","message.delete_confirm":"¿Estás seguro de que deseas eliminar este archivo? Esta acción también eliminará todos sus recortes.","message.copy_success":"URL copiada al portapapeles","message.copy_error":"Error al copiar URL","error.file_too_large":"El archivo es demasiado grande","error.invalid_format":"Formato de archivo no válido","error.upload_failed":"Error al subir el archivo","error.network":"Error de conexión","error.unknown":"Error desconocido","error.api_key_missing":"API Key no proporcionada","placeholder.search":"Buscar archivos...","placeholder.prompt":"Describe la imagen que quieres generar...","label.file_name":"Nombre del archivo","label.file_size":"Tamaño","label.dimensions":"Dimensiones","label.format":"Formato","label.uploaded_by":"Subido por","label.uploaded_at":"Fecha de subida","preset.square":"Cuadrado","preset.landscape":"Paisaje","preset.portrait":"Retrato","preset.thumbnail":"Miniatura","preset.medium":"Medio","preset.large":"Grande","preset.custom":"Personalizado","imageCard.aria.zoom":"Ampliar {filename}","imageCard.aria.zoomPreview":"Previsualizar {filename}","imageCard.aria.zoomWithCrops":"Ver {n} recortes de {filename}","imageCard.aria.crop":"Recortar {filename}","imageCard.aria.copyUrl":"Copiar URL de {filename}","imageCard.aria.copied":"URL copiada","imageCard.aria.download":"Descargar {filename}","imageCard.aria.rename":"Renombrar {filename}","imageCard.aria.delete":"Eliminar {filename}","aiStarter.label":"Instrucciones base","aiStarter.copy":"Copiar","aiStarter.copied":"Copiado","aiStarter.copyAriaLabel":"Copiar instrucciones base","aiStarter.readMore":"Leer más","aiStarter.readLess":"Leer menos","tags.input.placeholder":"Escribir etiqueta...","tags.input.labelOptional":"Etiquetas (opcional)","tags.input.label":"Etiquetas","tags.input.hint":"Pulsa espacio o coma para confirmar","tags.input.ariaLabel":"Añadir etiquetas","tags.autocomplete.empty":"Sin resultados","tags.section.label":"Etiquetas","tags.search.placeholder":"Buscar por nombre o etiqueta...","tags.pill.ariaDelete":"Eliminar etiqueta {tag}","editAssetModal.title":"Editar asset","editAssetModal.nameLabel":"Nombre","editAssetModal.close":"Cerrar","editAssetModal.save":"Guardar cambios","editAssetModal.cancel":"Cancelar","editAssetModal.saveError":"Error al guardar. Inténtalo de nuevo.","imageCard.editButton":"Editar asset"},en:{"button.select":"Select","button.upload":"Upload file","button.cancel":"Cancel","button.close":"Close","button.save":"Save","button.delete":"Delete","button.download":"Download","button.copy":"Copy URL","button.crop":"Crop","button.apply":"Apply","button.reset":"Reset","button.back":"Back","button.next":"Next","button.previous":"Previous","tab.gallery":"Gallery","tab.upload":"Upload","tab.ia":"AI","tab.stock":"Stock","tab.cropper":"Crop","message.loading":"Loading...","message.uploading":"Uploading file...","message.processing":"Processing...","message.no_images":"No files available","message.upload_success":"File uploaded successfully","message.upload_error":"Error uploading file","message.delete_confirm":"Are you sure you want to delete this file?","message.copy_success":"URL copied to clipboard","message.copy_error":"Error copying URL","error.file_too_large":"File is too large","error.invalid_format":"Invalid file format","error.upload_failed":"Upload failed","error.network":"Network error","error.unknown":"Unknown error","error.api_key_missing":"API Key not provided","placeholder.search":"Search files...","placeholder.prompt":"Describe the image you want to generate...","label.file_name":"File name","label.file_size":"Size","label.dimensions":"Dimensions","label.format":"Format","label.uploaded_by":"Uploaded by","label.uploaded_at":"Upload date","preset.square":"Square","preset.landscape":"Landscape","preset.portrait":"Portrait","preset.thumbnail":"Thumbnail","preset.medium":"Medium","preset.large":"Large","preset.custom":"Custom","imageCard.aria.zoom":"Enlarge {filename}","imageCard.aria.zoomPreview":"Preview {filename}","imageCard.aria.zoomWithCrops":"View {n} crops of {filename}","imageCard.aria.crop":"Crop {filename}","imageCard.aria.copyUrl":"Copy URL of {filename}","imageCard.aria.copied":"URL copied","imageCard.aria.download":"Download {filename}","imageCard.aria.rename":"Rename {filename}","imageCard.aria.delete":"Delete {filename}","aiStarter.label":"Base instructions","aiStarter.copy":"Copy","aiStarter.copied":"Copied","aiStarter.copyAriaLabel":"Copy base instructions","aiStarter.readMore":"Read more","aiStarter.readLess":"Read less","tags.input.placeholder":"Add tag...","tags.input.labelOptional":"Tags (optional)","tags.input.label":"Tags","tags.input.hint":"Press space or comma to confirm","tags.input.ariaLabel":"Add tags","tags.autocomplete.empty":"No results","tags.section.label":"Tags","tags.search.placeholder":"Search by name or tag...","tags.pill.ariaDelete":"Remove tag {tag}","editAssetModal.title":"Edit asset","editAssetModal.nameLabel":"Name","editAssetModal.close":"Close","editAssetModal.save":"Save changes","editAssetModal.cancel":"Cancel","editAssetModal.saveError":"Error saving. Please try again.","imageCard.editButton":"Edit asset"},pt:{"imageCard.aria.zoom":"Ampliar {filename}","imageCard.aria.zoomPreview":"Pré-visualizar {filename}","imageCard.aria.zoomWithCrops":"Ver {n} recortes de {filename}","imageCard.aria.crop":"Recortar {filename}","imageCard.aria.copyUrl":"Copiar URL de {filename}","imageCard.aria.copied":"URL copiada","imageCard.aria.download":"Descarregar {filename}","imageCard.aria.rename":"Renomear {filename}","imageCard.aria.delete":"Eliminar {filename}","aiStarter.label":"Instruções base","aiStarter.copy":"Copiar","aiStarter.copied":"Copiado","aiStarter.copyAriaLabel":"Copiar instruções base","aiStarter.readMore":"Ler mais","aiStarter.readLess":"Ler menos","tags.input.placeholder":"Adicionar etiqueta...","tags.input.labelOptional":"Etiquetas (opcional)","tags.input.label":"Etiquetas","tags.input.hint":"Prima espaço ou vírgula para confirmar","tags.input.ariaLabel":"Adicionar etiquetas","tags.autocomplete.empty":"Sem resultados","tags.section.label":"Etiquetas","tags.search.placeholder":"Pesquisar por nome ou etiqueta...","tags.pill.ariaDelete":"Remover etiqueta {tag}","editAssetModal.title":"Editar asset","editAssetModal.nameLabel":"Nome","editAssetModal.close":"Fechar","editAssetModal.save":"Guardar alterações","editAssetModal.cancel":"Cancelar","editAssetModal.saveError":"Erro ao guardar. Tente novamente.","imageCard.editButton":"Editar asset"},fr:{"imageCard.aria.zoom":"Agrandir {filename}","imageCard.aria.zoomPreview":"Prévisualiser {filename}","imageCard.aria.zoomWithCrops":"Voir {n} recadrages de {filename}","imageCard.aria.crop":"Recadrer {filename}","imageCard.aria.copyUrl":"Copier l'URL de {filename}","imageCard.aria.copied":"URL copiée","imageCard.aria.download":"Télécharger {filename}","imageCard.aria.rename":"Renommer {filename}","imageCard.aria.delete":"Supprimer {filename}","aiStarter.label":"Instructions de base","aiStarter.copy":"Copier","aiStarter.copied":"Copié","aiStarter.copyAriaLabel":"Copier les instructions de base","aiStarter.readMore":"Lire plus","aiStarter.readLess":"Lire moins","tags.input.placeholder":"Ajouter un tag...","tags.input.labelOptional":"Étiquettes (optionnel)","tags.input.label":"Étiquettes","tags.input.hint":"Appuyez sur espace ou virgule pour confirmer","tags.input.ariaLabel":"Ajouter des étiquettes","tags.autocomplete.empty":"Aucun résultat","tags.section.label":"Étiquettes","tags.search.placeholder":"Rechercher par nom ou tag...","tags.pill.ariaDelete":"Supprimer l'étiquette {tag}","editAssetModal.title":"Modifier le fichier","editAssetModal.nameLabel":"Nom","editAssetModal.close":"Fermer","editAssetModal.save":"Enregistrer les modifications","editAssetModal.cancel":"Annuler","editAssetModal.saveError":"Erreur lors de l'enregistrement. Réessayez.","imageCard.editButton":"Modifier l'asset"}};class b{constructor(e="es",t={}){this.locale=e,this.messages=this._mergeMessages(t)}_mergeMessages(e){const t={...d};return Object.keys(e).forEach(l=>{t[l]={...t[l]||{},...e[l]}}),t}t(e,t={}){let l=(this.messages[this.locale]||this.messages.es)[e]||e;return Object.keys(t).forEach(e=>{l=l.replace(`{${e}}`,t[e])}),l}setLocale(e){this.messages[e]?this.locale=e:console.warn(`Locale ${e} not available, keeping ${this.locale}`)}getLocale(){return this.locale}getAvailableLocales(){return Object.keys(this.messages)}addMessages(e,t){this.messages[e]={...this.messages[e]||{},...t}}hasKey(e){return e in(this.messages[this.locale]||this.messages.es)}}const m=new b;function h(e,t={}){return m.t(e,t)}class p{constructor(){this.globalConfig={},this.defaults={container:"#limbo-default",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],ui:{showActions:["select","download","copy","delete","crop","rename"],hideActions:[],theme:"light",language:"es",compactMode:!1,showTabs:!0,showPreview:!0},cropper:{quality:.9,format:"webp",aspectRatio:null,lockAspectRatio:!1,showFreeAspectRatio:!0,showDimensionInputs:!1,enableEditMode:!0,showDownloadInCropper:!1,showCropName:!1,mandatoryCrops:[],allowCustomCrops:!0},gallery:{filters:{showNameFilter:!0,showUploadedByFilter:!1,showDateFilter:!0,showTypeFilter:!1,enabledFilters:["name","date"],customFilters:[]},loading:{showPlaceholders:!0,placeholderCount:10,showSpinner:!0},pagination:{itemsPerPage:20,showPageSize:!0}},validation:{accept:null,maxSize:"10MB",formats:["jpg","jpeg","png","webp","gif"],minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,allowedCategories:null},folders:{include:[],exclude:[],includeNoFolder:!0,showFolderSelector:!0,showFolderFilter:!0,showFolderInfo:!0,allowMoveFolder:!0,allowCreateFolder:!0,defaultFolder:null},downloadFormat:"webp",return:{format:"url",autoAssign:!0,includeMetadata:!1},autoInputs:{dataset:"data-limbo-input-file",buttonText:"Seleccionar archivo",buttonStyle:"primary",buttonClass:"limbo-auto-button",scanOnLoad:!0,observeChanges:!0},presets:{aspects:[{name:"square",ratio:"1:1",label:"Cuadrado"},{name:"landscape",ratio:"16:9",label:"Paisaje"},{name:"portrait",ratio:"9:16",label:"Retrato"}],sizes:[{name:"thumbnail",width:300,height:300,fit:"cover",label:"Miniatura"},{name:"medium",width:800,height:600,fit:"cover",label:"Medio"},{name:"large",width:1920,height:1080,fit:"cover",label:"Grande"}],required:[],lockUserCrop:!1,allowArbitrary:!0,defaultAspect:"square",defaultSize:"medium"},modal:{size:"medium",title:"Limbo Image Manager",backdrop:!0,closeOnEscape:!0,closeOnBackdrop:!0,showCloseButton:!0},callbacks:{onUpload:null,onSelect:null,onDelete:null,onCropsSaved:null,onCropperComplete:null,onCropperCancelled:null,onCropperError:null},autoDestroy:!1,autoHideOnComplete:!1,debug:!1,apiEndpoint:null,auth:{apiKey:null,publicKey:null,portal:null,authMode:"jwt",tokenStorage:"memory",autoRefresh:!0,refreshBuffer:30},apiKey:null,aiStarterPrompt:"Editorial corporate photography, authentic human moments, warm cinematic lighting, natural professional interaction, premium contemporary aesthetic, subtle shadows, asymmetrical editorial composition, intentional negative space, non-stock photography style, refined warm-neutral color palette with beige, soft whites, warm browns, deep burgundy and navy blue tones, understated sophistication, realistic office atmosphere. Avoid: fake smiles, corporate posing, flat lighting, overly clean scenes, oversaturated colors, generic stock photo aesthetic."}}setGlobal(e){return this.globalConfig={...this.globalConfig,...e},this}getGlobal(){return{...this.globalConfig}}merge(e={}){return this._deepMerge(this.defaults,this.globalConfig,e)}_deepMerge(...e){const t={};return e.forEach(e=>{e&&"object"==typeof e&&Object.keys(e).forEach(l=>{e[l]&&"object"==typeof e[l]&&!Array.isArray(e[l])?t[l]=this._deepMerge(t[l]||{},e[l]):t[l]=e[l]})}),t}setDefaults(e){return this.defaults=this._deepMerge(this.defaults,e),this}getDefaults(){return JSON.parse(JSON.stringify(this.defaults))}resetDefaults(){return this.defaults=this._getOriginalDefaults(),this}get(e,t=null){const l=t||this.merge();return this._getValueByPath(l,e)}set(e,t){return this._setValueByPath(this.globalConfig,e,t),this}_getValueByPath(e,t){return t.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:void 0,e)}_setValueByPath(e,t,l){const n=t.split("."),a=n.pop();n.reduce((e,t)=>(e[t]&&"object"==typeof e[t]||(e[t]={}),e[t]),e)[a]=l}_getOriginalDefaults(){return{container:"#limbo-default",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],ui:{showActions:["select","download","copy","delete","crop","rename"],hideActions:[],theme:"light",language:"es",compactMode:!1,showTabs:!0,showPreview:!0},interaction:{allowSelection:!1,allowCropping:!0,requiresCropping:!1,selectionMode:"direct"},cropper:{quality:.9,format:"webp",aspectRatio:null,lockAspectRatio:!1,showFreeAspectRatio:!0,showDimensionInputs:!1,enableEditMode:!0,showDownloadInCropper:!1,showCropName:!1,mandatoryCrops:[],allowCustomCrops:!0},gallery:{filters:{showNameFilter:!0,showUploadedByFilter:!1,showDateFilter:!0,showTypeFilter:!1,enabledFilters:["name","date"],customFilters:[]},loading:{showPlaceholders:!0,placeholderCount:10,showSpinner:!0},pagination:{itemsPerPage:20,showPageSize:!0}},validation:{accept:null,maxSize:"10MB",formats:["jpg","jpeg","png","svg","webp","gif"],minWidth:null,minHeight:null,maxWidth:null,maxHeight:null,allowedCategories:null},folders:{include:[],exclude:[],includeNoFolder:!0,showFolderSelector:!1,showFolderFilter:!1,showFolderInfo:!0,allowMoveFolder:!0,allowCreateFolder:!0,defaultFolder:null},return:{format:"url",autoAssign:!0,includeMetadata:!1},autoInputs:{dataset:"data-limbo-input-file",buttonText:"Seleccionar archivo",buttonStyle:"primary",buttonClass:"limbo-auto-button",scanOnLoad:!0,observeChanges:!0},modal:{size:"medium",title:"Limbo Image Manager",backdrop:!0,closeOnEscape:!0,closeOnBackdrop:!0,showCloseButton:!0},i18n:{locale:"es",messages:{},autoDetect:!0},theme:{colors:{},spacing:{},typography:{},borderRadius:{},shadows:{},customProperties:{}},callbacks:{onUpload:null,onSelect:null,onDelete:null,onCropsSaved:null,onCropperComplete:null,onCropperCancelled:null,onCropperError:null},autoDestroy:!1,autoHideOnComplete:!1,debug:!1,apiEndpoint:null,auth:{apiKey:null,publicKey:null,portal:null,authMode:"jwt",tokenStorage:"memory",autoRefresh:!0,refreshBuffer:30},apiKey:null}}_validatePresets(e){const t=[];if(e.aspects&&e.aspects.forEach((e,l)=>{e.name&&e.ratio||t.push(`Aspect preset ${l}: name and ratio are required`),e.ratio&&!/^\d+:\d+$/.test(e.ratio)&&t.push(`Aspect preset ${e.name}: ratio must be in format "w:h"`)}),e.sizes&&e.sizes.forEach((e,l)=>{e.name&&e.width||t.push(`Size preset ${l}: name and width are required`),e.width&&e.width<=0&&t.push(`Size preset ${e.name}: width must be positive`),e.height&&e.height<=0&&t.push(`Size preset ${e.name}: height must be positive`)}),e.required&&Array.isArray(e.required)){const l=[...e.aspects?.map(e=>e.name)||[],...e.sizes?.map(e=>e.name)||[]];e.required.forEach(e=>{l.includes(e)||t.push(`Required preset "${e}" not found in available presets`)})}return t}getPreset(e,t,l="aspect"){const n=e.presets||this.defaults.presets;return"aspect"===l?n.aspects?.find(e=>e.name===t):"size"===l?n.sizes?.find(e=>e.name===t):null}isPresetRequired(e,t){const l=e.presets||this.defaults.presets;return l.required?.includes(t)||!1}getAvailableAspects(e){return(e.presets||this.defaults.presets).aspects||[]}getAvailableSizes(e){return(e.presets||this.defaults.presets).sizes||[]}createI18n(e){const t=e.i18n||this.defaults.i18n;let l=t.locale;if(t.autoDetect&&"auto"===l){const e=(navigator.language||navigator.userLanguage).split("-")[0];l=["es","en"].includes(e)?e:"es"}else t.autoDetect&&!l&&(l="es");return new b(l,t.messages)}validate(e){const t=[],l=this._deepMerge(this.globalConfig.auth||{},e.auth||{}),n=e.apiKey||this.globalConfig.apiKey;if("jwt"!==l.authMode&&n||l.apiKey||t.push("auth.apiKey es requerido para autenticación JWT"),"legacy"!==l.authMode||n||t.push("apiKey es requerido para modo legacy"),l.apiKey||n||t.push("Se requiere configuración de autenticación (auth.apiKey o apiKey legacy)"),e.mode&&!["embed","modal","button"].includes(e.mode)&&t.push("mode debe ser: embed, modal o button"),e.features&&!Array.isArray(e.features)&&t.push("features debe ser un array"),e.presets){const l=this._validatePresets(e.presets);t.push(...l)}return{isValid:0===t.length,errors:t}}setJWTAuth(e,t=null,l={}){const n={apiKey:e,publicKey:t,authMode:"jwt",tokenStorage:l.tokenStorage||"memory",autoRefresh:!1!==l.autoRefresh,refreshBuffer:l.refreshBuffer||30,portal:l.portal||null,...l};return this.set("auth",n),this}getAuthConfig(e=null){const t=e||this.merge();return{authMode:t.auth?.authMode||(t.apiKey?"legacy":"jwt"),apiKey:t.auth?.apiKey||t.apiKey,publicKey:t.auth?.publicKey,portal:t.auth?.portal,tokenStorage:t.auth?.tokenStorage||"memory",autoRefresh:!1!==t.auth?.autoRefresh,refreshBuffer:t.auth?.refreshBuffer||30}}isJWTMode(e=null){return"jwt"===this.getAuthConfig(e).authMode}isLegacyMode(e=null){return"legacy"===this.getAuthConfig(e).authMode}migrateToJWT(e=null){const t=e||this.globalConfig.apiKey;if(!t)throw new Error("No hay apiKey para migrar a JWT");return this.setJWTAuth(t),this}getMandatoryCrops(e=null){const t=e||this.merge();return t.cropper?.mandatoryCrops||[]}hasMandatoryCrops(e=null){return this.getMandatoryCrops(e).length>0}isEditModeEnabled(e=null){const t=e||this.merge();return!1!==t.cropper?.enableEditMode}showDimensionInputs(e=null){const t=e||this.merge();return!0===t.cropper?.showDimensionInputs}showDownloadInCropper(e=null){const t=e||this.merge();return!0===t.cropper?.showDownloadInCropper}showCropName(e=null){const t=e||this.merge();return!0===t.cropper?.showCropName}allowCustomCrops(e=null){const t=e||this.merge();return!1!==t.cropper?.allowCustomCrops}getGalleryFilters(e=null){const t=e||this.merge();return t.gallery?.filters||this.defaults.gallery.filters}isGalleryFilterEnabled(e,t=null){const l=this.getGalleryFilters(t);return l.enabledFilters?.includes(e)||!1}getCustomGalleryFilters(e=null){return this.getGalleryFilters(e).customFilters||[]}getGalleryLoadingConfig(e=null){const t=e||this.merge();return t.gallery?.loading||this.defaults.gallery.loading}showGalleryPlaceholders(e=null){return!1!==this.getGalleryLoadingConfig(e).showPlaceholders}getPlaceholderCount(e=null){return this.getGalleryLoadingConfig(e).placeholderCount||10}showGallerySpinner(e=null){return!1!==this.getGalleryLoadingConfig(e).showSpinner}getGalleryPagination(e=null){const t=e||this.merge();return t.gallery?.pagination||this.defaults.gallery.pagination}getItemsPerPage(e=null){return this.getGalleryPagination(e).itemsPerPage||20}getFolderConfig(e=null){return(e||this.merge()).folders||this.defaults.folders}hasFolderFilters(e=null){const t=this.getFolderConfig(e);return t.include?.length>0||t.exclude?.length>0}getFolderApiParams(e=null){const t=this.getFolderConfig(e),l={};return t.include?.length>0?l.folders_include=t.include.join(","):t.exclude?.length>0&&(l.folders_exclude=t.exclude.join(",")),this.hasFolderFilters(e)&&void 0!==t.includeNoFolder&&(l.include_no_folder=t.includeNoFolder?"1":"0"),l}showFolderSelectorInUpload(e=null){const t=e||this.merge();return!0===t.folders?.showFolderSelector}showFolderFilterInGallery(e=null){const t=e||this.merge();return!0===t.folders?.showFolderFilter}canCreateFolder(e=null){const t=e||this.merge();return!1!==t.folders?.allowCreateFolder}getDefaultUploadFolder(e=null){const t=e||this.merge();return t.folders?.defaultFolder||null}getAllowedFolderSlugs(e=null){const t=e||this.merge(),l=t.folders?.include;return l&&l.length>0?l:null}getAllowedCategories(e=null){const t=e||this.merge();return t.validation?.allowedCategories||null}isCategoryAllowed(e,t=null){const l=this.getAllowedCategories(t);return null===l||l.includes(e)}isMultiTypeEnabled(e=null){const t=this.getAllowedCategories(e);return null===t||(t.length>1||1===t.length&&"image"!==t[0])}showTypeFilter(e=null){const t=e||this.merge();return!0===t.gallery?.filters?.showTypeFilter}getTypeFilterOptions(e=null){const t=this.getAllowedCategories(e),l=[{value:"",label:"Todos los tipos"},{value:"image",label:"Imágenes"},{value:"video",label:"Videos"},{value:"document",label:"Documentos"},{value:"audio",label:"Audio"}];return null===t?l:l.filter(e=>""===e.value||t.includes(e.value))}getResolvedAccept(e=null){const t=e||this.merge();return t.validation?.accept?s(t.validation.accept):t.validation?.allowedCategories?s(t.validation.allowedCategories.map(e=>`${e}/*`).join(",")):s(null)}}var f,g,v,y,x={exports:{}},w={},k={exports:{}},C={};function S(){return g||(g=1,k.exports=(f||(f=1,function(e){function t(e,t){var l=e.length;e.push(t);e:for(;0<l;){var n=l-1>>>1,r=e[n];if(!(0<a(r,t)))break e;e[n]=t,e[l]=r,l=n}}function l(e){return 0===e.length?null:e[0]}function n(e){if(0===e.length)return null;var t=e[0],l=e.pop();if(l!==t){e[0]=l;e:for(var n=0,r=e.length,i=r>>>1;n<i;){var o=2*(n+1)-1,s=e[o],c=o+1,u=e[c];if(0>a(s,l))c<r&&0>a(u,s)?(e[n]=u,e[c]=l,n=c):(e[n]=s,e[o]=l,n=o);else{if(!(c<r&&0>a(u,l)))break e;e[n]=u,e[c]=l,n=c}}}return t}function a(e,t){var l=e.sortIndex-t.sortIndex;return 0!==l?l:e.id-t.id}if(e.unstable_now=void 0,"object"==typeof performance&&"function"==typeof performance.now){var r=performance;e.unstable_now=function(){return r.now()}}else{var i=Date,o=i.now();e.unstable_now=function(){return i.now()-o}}var s=[],c=[],u=1,d=null,b=3,m=!1,h=!1,p=!1,f=!1,g="function"==typeof setTimeout?setTimeout:null,v="function"==typeof clearTimeout?clearTimeout:null,y="undefined"!=typeof setImmediate?setImmediate:null;function x(e){for(var a=l(c);null!==a;){if(null===a.callback)n(c);else{if(!(a.startTime<=e))break;n(c),a.sortIndex=a.expirationTime,t(s,a)}a=l(c)}}function w(e){if(p=!1,x(e),!h)if(null!==l(s))h=!0,C||(C=!0,k());else{var t=l(c);null!==t&&A(w,t.startTime-e)}}var k,C=!1,S=-1,j=5,N=-1;function E(){return!(!f&&e.unstable_now()-N<j)}function _(){if(f=!1,C){var t=e.unstable_now();N=t;var a=!0;try{e:{h=!1,p&&(p=!1,v(S),S=-1),m=!0;var r=b;try{t:{for(x(t),d=l(s);null!==d&&!(d.expirationTime>t&&E());){var i=d.callback;if("function"==typeof i){d.callback=null,b=d.priorityLevel;var o=i(d.expirationTime<=t);if(t=e.unstable_now(),"function"==typeof o){d.callback=o,x(t),a=!0;break t}d===l(s)&&n(s),x(t)}else n(s);d=l(s)}if(null!==d)a=!0;else{var u=l(c);null!==u&&A(w,u.startTime-t),a=!1}}break e}finally{d=null,b=r,m=!1}a=void 0}}finally{a?k():C=!1}}}if("function"==typeof y)k=function(){y(_)};else if("undefined"!=typeof MessageChannel){var $=new MessageChannel,T=$.port2;$.port1.onmessage=_,k=function(){T.postMessage(null)}}else k=function(){g(_,0)};function A(t,l){S=g(function(){t(e.unstable_now())},l)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):j=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_next=function(e){switch(b){case 1:case 2:case 3:var t=3;break;default:t=b}var l=b;b=t;try{return e()}finally{b=l}},e.unstable_requestPaint=function(){f=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var l=b;b=e;try{return t()}finally{b=l}},e.unstable_scheduleCallback=function(n,a,r){var i=e.unstable_now();switch(r="object"==typeof r&&null!==r&&"number"==typeof(r=r.delay)&&0<r?i+r:i,n){case 1:var o=-1;break;case 2:o=250;break;case 5:o=1073741823;break;case 4:o=1e4;break;default:o=5e3}return n={id:u++,callback:a,priorityLevel:n,startTime:r,expirationTime:o=r+o,sortIndex:-1},r>i?(n.sortIndex=r,t(c,n),null===l(s)&&n===l(c)&&(p?(v(S),S=-1):p=!0,A(w,r-i))):(n.sortIndex=o,t(s,n),h||m||(h=!0,C||(C=!0,k()))),n},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=b;return function(){var l=b;b=t;try{return e.apply(this,arguments)}finally{b=l}}}}(C)),C)),k.exports}function j(){if(v)return w;v=1;var l=S(),n=e,a=t;function r(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)t+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType)}function o(e){var t=e,l=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{!!(4098&(t=e).flags)&&(l=t.return),e=t.return}while(e)}return 3===t.tag?l:null}function s(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function c(e){if(31===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function u(e){if(o(e)!==e)throw Error(r(188))}function d(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e;for(e=e.child;null!==e;){if(null!==(t=d(e)))return t;e=e.sibling}return null}var b=Object.assign,m=Symbol.for("react.element"),h=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),x=Symbol.for("react.consumer"),k=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),$=Symbol.for("react.activity"),T=Symbol.for("react.memo_cache_sentinel"),A=Symbol.iterator;function z(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=A&&e[A]||e["@@iterator"])?e:null}var L=Symbol.for("react.client.reference");function M(e){if(null==e)return null;if("function"==typeof e)return e.$$typeof===L?null:e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case f:return"Fragment";case y:return"Profiler";case g:return"StrictMode";case j:return"Suspense";case N:return"SuspenseList";case $:return"Activity"}if("object"==typeof e)switch(e.$$typeof){case p:return"Portal";case k:return e.displayName||"Context";case x:return(e._context.displayName||"Context")+".Consumer";case C:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case E:return null!==(t=e.displayName||null)?t:M(e.type)||"Memo";case _:t=e._payload,e=e._init;try{return M(e(t))}catch(l){}}return null}var I=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R={pending:!1,data:null,method:null,action:null},O=[],F=-1;function U(e){return{current:e}}function B(e){0>F||(e.current=O[F],O[F]=null,F--)}function q(e,t){F++,O[F]=e.current,e.current=t}var W,V,H=U(null),K=U(null),G=U(null),Q=U(null);function X(e,t){switch(q(G,t),q(K,e),q(H,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?yd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)e=xd(t=yd(t),e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}B(H),q(H,e)}function Y(){B(H),B(K),B(G)}function J(e){null!==e.memoizedState&&q(Q,e);var t=H.current,l=xd(t,e.type);t!==l&&(q(K,e),q(H,l))}function Z(e){K.current===e&&(B(H),B(K)),Q.current===e&&(B(Q),bb._currentValue=R)}function ee(e){if(void 0===W)try{throw Error()}catch(l){var t=l.stack.trim().match(/\n( *(at )?)/);W=t&&t[1]||"",V=-1<l.stack.indexOf("\n at")?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return"\n"+W+e+V}var te=!1;function le(e,t){if(!e||te)return"";te=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var n={DetermineComponentFrameRoot:function(){try{if(t){var l=function(){throw Error()};if(Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(l,[])}catch(a){var n=a}Reflect.construct(e,[],l)}else{try{l.call()}catch(r){n=r}e.call(l.prototype)}}else{try{throw Error()}catch(i){n=i}(l=e())&&"function"==typeof l.catch&&l.catch(function(){})}}catch(o){if(o&&n&&"string"==typeof o.stack)return[o.stack,n.stack]}return[null,null]}};n.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var a=Object.getOwnPropertyDescriptor(n.DetermineComponentFrameRoot,"name");a&&a.configurable&&Object.defineProperty(n.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var r=n.DetermineComponentFrameRoot(),i=r[0],o=r[1];if(i&&o){var s=i.split("\n"),c=o.split("\n");for(a=n=0;n<s.length&&!s[n].includes("DetermineComponentFrameRoot");)n++;for(;a<c.length&&!c[a].includes("DetermineComponentFrameRoot");)a++;if(n===s.length||a===c.length)for(n=s.length-1,a=c.length-1;1<=n&&0<=a&&s[n]!==c[a];)a--;for(;1<=n&&0<=a;n--,a--)if(s[n]!==c[a]){if(1!==n||1!==a)do{if(n--,0>--a||s[n]!==c[a]){var u="\n"+s[n].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}}while(1<=n&&0<=a);break}}}finally{te=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?ee(l):""}function ne(e,t){switch(e.tag){case 26:case 27:case 5:return ee(e.type);case 16:return ee("Lazy");case 13:return e.child!==t&&null!==t?ee("Suspense Fallback"):ee("Suspense");case 19:return ee("SuspenseList");case 0:case 15:return le(e.type,!1);case 11:return le(e.type.render,!1);case 1:return le(e.type,!0);case 31:return ee("Activity");default:return""}}function ae(e){try{var t="",l=null;do{t+=ne(e,l),l=e,e=e.return}while(e);return t}catch(n){return"\nError generating stack: "+n.message+"\n"+n.stack}}var re=Object.prototype.hasOwnProperty,ie=l.unstable_scheduleCallback,oe=l.unstable_cancelCallback,se=l.unstable_shouldYield,ce=l.unstable_requestPaint,ue=l.unstable_now,de=l.unstable_getCurrentPriorityLevel,be=l.unstable_ImmediatePriority,me=l.unstable_UserBlockingPriority,he=l.unstable_NormalPriority,pe=l.unstable_LowPriority,fe=l.unstable_IdlePriority,ge=l.log,ve=l.unstable_setDisableYieldValue,ye=null,xe=null;function we(e){if("function"==typeof ge&&ve(e),xe&&"function"==typeof xe.setStrictMode)try{xe.setStrictMode(ye,e)}catch(t){}}var ke=Math.clz32?Math.clz32:function(e){return 0===(e>>>=0)?32:31-(Ce(e)/Se|0)|0},Ce=Math.log,Se=Math.LN2;var je=256,Ne=262144,Ee=4194304;function _e(e){var t=42&e;if(0!==t)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function $e(e,t,l){var n=e.pendingLanes;if(0===n)return 0;var a=0,r=e.suspendedLanes,i=e.pingedLanes;e=e.warmLanes;var o=134217727&n;return 0!==o?0!==(n=o&~r)?a=_e(n):0!==(i&=o)?a=_e(i):l||0!==(l=o&~e)&&(a=_e(l)):0!==(o=n&~r)?a=_e(o):0!==i?a=_e(i):l||0!==(l=n&~e)&&(a=_e(l)),0===a?0:0!==t&&t!==a&&0===(t&r)&&((r=a&-a)>=(l=t&-t)||32===r&&4194048&l)?t:a}function Te(e,t){return 0===(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)}function Ae(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;default:return-1}}function ze(){var e=Ee;return!(62914560&(Ee<<=1))&&(Ee=4194304),e}function Le(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function Me(e,t){e.pendingLanes|=t,268435456!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ie(e,t,l){e.pendingLanes|=t,e.suspendedLanes&=~t;var n=31-ke(t);e.entangledLanes|=t,e.entanglements[n]=1073741824|e.entanglements[n]|261930&l}function Pe(e,t){var l=e.entangledLanes|=t;for(e=e.entanglements;l;){var n=31-ke(l),a=1<<n;a&t|e[n]&t&&(e[n]|=t),l&=~a}}function De(e,t){var l=t&-t;return 0!==((l=42&l?1:Re(l))&(e.suspendedLanes|t))?0:l}function Re(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Oe(e){return 2<(e&=-e)?8<e?134217727&e?32:268435456:8:2}function Fe(){var e=D.p;return 0!==e?e:void 0===(e=window.event)?32:_b(e.type)}function Ue(e,t){var l=D.p;try{return D.p=e,t()}finally{D.p=l}}var Be=Math.random().toString(36).slice(2),qe="__reactFiber$"+Be,We="__reactProps$"+Be,Ve="__reactContainer$"+Be,He="__reactEvents$"+Be,Ke="__reactListeners$"+Be,Ge="__reactHandles$"+Be,Qe="__reactResources$"+Be,Xe="__reactMarker$"+Be;function Ye(e){delete e[qe],delete e[We],delete e[He],delete e[Ke],delete e[Ge]}function Je(e){var t=e[qe];if(t)return t;for(var l=e.parentNode;l;){if(t=l[Ve]||l[qe]){if(l=t.alternate,null!==t.child||null!==l&&null!==l.child)for(e=Rd(e);null!==e;){if(l=e[qe])return l;e=Rd(e)}return t}l=(e=l).parentNode}return null}function Ze(e){if(e=e[qe]||e[Ve]){var t=e.tag;if(5===t||6===t||13===t||31===t||26===t||27===t||3===t)return e}return null}function et(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e.stateNode;throw Error(r(33))}function tt(e){var t=e[Qe];return t||(t=e[Qe]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function lt(e){e[Xe]=!0}var nt=new Set,at={};function rt(e,t){it(e,t),it(e+"Capture",t)}function it(e,t){for(at[e]=t,e=0;e<t.length;e++)nt.add(t[e])}var ot=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),st={},ct={};function ut(e,t,l){if(a=t,re.call(ct,a)||!re.call(st,a)&&(ot.test(a)?ct[a]=!0:(st[a]=!0,0)))if(null===l)e.removeAttribute(t);else{switch(typeof l){case"undefined":case"function":case"symbol":return void e.removeAttribute(t);case"boolean":var n=t.toLowerCase().slice(0,5);if("data-"!==n&&"aria-"!==n)return void e.removeAttribute(t)}e.setAttribute(t,""+l)}var a}function dt(e,t,l){if(null===l)e.removeAttribute(t);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(t)}e.setAttribute(t,""+l)}}function bt(e,t,l,n){if(null===n)e.removeAttribute(l);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(l)}e.setAttributeNS(t,l,""+n)}}function mt(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function ht(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function pt(e){if(!e._valueTracker){var t=ht(e)?"checked":"value";e._valueTracker=function(e,t,l){var n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&void 0!==n&&"function"==typeof n.get&&"function"==typeof n.set){var a=n.get,r=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(e){l=""+e,r.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return l},setValue:function(e){l=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e,t,""+e[t])}}function ft(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var l=t.getValue(),n="";return e&&(n=ht(e)?e.checked?"true":"false":e.value),(e=n)!==l&&(t.setValue(e),!0)}function gt(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}var vt=/[\n"\\]/g;function yt(e){return e.replace(vt,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function xt(e,t,l,n,a,r,i,o){e.name="",null!=i&&"function"!=typeof i&&"symbol"!=typeof i&&"boolean"!=typeof i?e.type=i:e.removeAttribute("type"),null!=t?"number"===i?(0===t&&""===e.value||e.value!=t)&&(e.value=""+mt(t)):e.value!==""+mt(t)&&(e.value=""+mt(t)):"submit"!==i&&"reset"!==i||e.removeAttribute("value"),null!=t?kt(e,i,mt(t)):null!=l?kt(e,i,mt(l)):null!=n&&e.removeAttribute("value"),null==a&&null!=r&&(e.defaultChecked=!!r),null!=a&&(e.checked=a&&"function"!=typeof a&&"symbol"!=typeof a),null!=o&&"function"!=typeof o&&"symbol"!=typeof o&&"boolean"!=typeof o?e.name=""+mt(o):e.removeAttribute("name")}function wt(e,t,l,n,a,r,i,o){if(null!=r&&"function"!=typeof r&&"symbol"!=typeof r&&"boolean"!=typeof r&&(e.type=r),null!=t||null!=l){if(("submit"===r||"reset"===r)&&null==t)return void pt(e);l=null!=l?""+mt(l):"",t=null!=t?""+mt(t):l,o||t===e.value||(e.value=t),e.defaultValue=t}n="function"!=typeof(n=null!=n?n:a)&&"symbol"!=typeof n&&!!n,e.checked=o?e.checked:!!n,e.defaultChecked=!!n,null!=i&&"function"!=typeof i&&"symbol"!=typeof i&&"boolean"!=typeof i&&(e.name=i),pt(e)}function kt(e,t,l){"number"===t&&gt(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function Ct(e,t,l,n){if(e=e.options,t){t={};for(var a=0;a<l.length;a++)t["$"+l[a]]=!0;for(l=0;l<e.length;l++)a=t.hasOwnProperty("$"+e[l].value),e[l].selected!==a&&(e[l].selected=a),a&&n&&(e[l].defaultSelected=!0)}else{for(l=""+mt(l),t=null,a=0;a<e.length;a++){if(e[a].value===l)return e[a].selected=!0,void(n&&(e[a].defaultSelected=!0));null!==t||e[a].disabled||(t=e[a])}null!==t&&(t.selected=!0)}}function St(e,t,l){null==t||((t=""+mt(t))!==e.value&&(e.value=t),null!=l)?e.defaultValue=null!=l?""+mt(l):"":e.defaultValue!==t&&(e.defaultValue=t)}function jt(e,t,l,n){if(null==t){if(null!=n){if(null!=l)throw Error(r(92));if(I(n)){if(1<n.length)throw Error(r(93));n=n[0]}l=n}null==l&&(l=""),t=l}l=mt(t),e.defaultValue=l,(n=e.textContent)===l&&""!==n&&null!==n&&(e.value=n),pt(e)}function Nt(e,t){if(t){var l=e.firstChild;if(l&&l===e.lastChild&&3===l.nodeType)return void(l.nodeValue=t)}e.textContent=t}var Et=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function _t(e,t,l){var n=0===t.indexOf("--");null==l||"boolean"==typeof l||""===l?n?e.setProperty(t,""):"float"===t?e.cssFloat="":e[t]="":n?e.setProperty(t,l):"number"!=typeof l||0===l||Et.has(t)?"float"===t?e.cssFloat=l:e[t]=(""+l).trim():e[t]=l+"px"}function $t(e,t,l){if(null!=t&&"object"!=typeof t)throw Error(r(62));if(e=e.style,null!=l){for(var n in l)!l.hasOwnProperty(n)||null!=t&&t.hasOwnProperty(n)||(0===n.indexOf("--")?e.setProperty(n,""):"float"===n?e.cssFloat="":e[n]="");for(var a in t)n=t[a],t.hasOwnProperty(a)&&l[a]!==n&&_t(e,a,n)}else for(var i in t)t.hasOwnProperty(i)&&_t(e,i,t[i])}function Tt(e){if(-1===e.indexOf("-"))return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var At=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),zt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Lt(e){return zt.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Mt(){}var It=null;function Pt(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var Dt=null,Rt=null;function Ot(e){var t=Ze(e);if(t&&(e=t.stateNode)){var l=e[We]||null;e:switch(e=t.stateNode,t.type){case"input":if(xt(e,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),t=l.name,"radio"===l.type&&null!=t){for(l=e;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+yt(""+t)+'"][type="radio"]'),t=0;t<l.length;t++){var n=l[t];if(n!==e&&n.form===e.form){var a=n[We]||null;if(!a)throw Error(r(90));xt(n,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<l.length;t++)(n=l[t]).form===e.form&&ft(n)}break e;case"textarea":St(e,l.value,l.defaultValue);break e;case"select":null!=(t=l.value)&&Ct(e,!!l.multiple,t,!1)}}}var Ft=!1;function Ut(e,t,l){if(Ft)return e(t,l);Ft=!0;try{return e(t)}finally{if(Ft=!1,(null!==Dt||null!==Rt)&&(tu(),Dt&&(t=Dt,e=Rt,Rt=Dt=null,Ot(t),e)))for(t=0;t<e.length;t++)Ot(e[t])}}function Bt(e,t){var l=e.stateNode;if(null===l)return null;var n=l[We]||null;if(null===n)return null;l=n[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(n=!n.disabled)||(n=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!n;break e;default:e=!1}if(e)return null;if(l&&"function"!=typeof l)throw Error(r(231,t,typeof l));return l}var qt=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),Wt=!1;if(qt)try{var Vt={};Object.defineProperty(Vt,"passive",{get:function(){Wt=!0}}),window.addEventListener("test",Vt,Vt),window.removeEventListener("test",Vt,Vt)}catch(Zb){Wt=!1}var Ht=null,Kt=null,Gt=null;function Qt(){if(Gt)return Gt;var e,t,l=Kt,n=l.length,a="value"in Ht?Ht.value:Ht.textContent,r=a.length;for(e=0;e<n&&l[e]===a[e];e++);var i=n-e;for(t=1;t<=i&&l[n-t]===a[r-t];t++);return Gt=a.slice(e,1<t?1-t:void 0)}function Xt(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function Yt(){return!0}function Jt(){return!1}function Zt(e){function t(t,l,n,a,r){for(var i in this._reactName=t,this._targetInst=n,this.type=l,this.nativeEvent=a,this.target=r,this.currentTarget=null,e)e.hasOwnProperty(i)&&(t=e[i],this[i]=t?t(a):a[i]);return this.isDefaultPrevented=(null!=a.defaultPrevented?a.defaultPrevented:!1===a.returnValue)?Yt:Jt,this.isPropagationStopped=Jt,this}return b(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=Yt)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=Yt)},persist:function(){},isPersistent:Yt}),t}var el,tl,ll,nl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},al=Zt(nl),rl=b({},nl,{view:0,detail:0}),il=Zt(rl),ol=b({},rl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:vl,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==ll&&(ll&&"mousemove"===e.type?(el=e.screenX-ll.screenX,tl=e.screenY-ll.screenY):tl=el=0,ll=e),el)},movementY:function(e){return"movementY"in e?e.movementY:tl}}),sl=Zt(ol),cl=Zt(b({},ol,{dataTransfer:0})),ul=Zt(b({},rl,{relatedTarget:0})),dl=Zt(b({},nl,{animationName:0,elapsedTime:0,pseudoElement:0})),bl=Zt(b({},nl,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}})),ml=Zt(b({},nl,{data:0})),hl={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},pl={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},fl={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function gl(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=fl[e])&&!!t[e]}function vl(){return gl}var yl=Zt(b({},rl,{key:function(e){if(e.key){var t=hl[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=Xt(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?pl[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:vl,charCode:function(e){return"keypress"===e.type?Xt(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?Xt(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}})),xl=Zt(b({},ol,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),wl=Zt(b({},rl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:vl})),kl=Zt(b({},nl,{propertyName:0,elapsedTime:0,pseudoElement:0})),Cl=Zt(b({},ol,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Sl=Zt(b({},nl,{newState:0,oldState:0})),jl=[9,13,27,32],Nl=qt&&"CompositionEvent"in window,El=null;qt&&"documentMode"in document&&(El=document.documentMode);var _l=qt&&"TextEvent"in window&&!El,$l=qt&&(!Nl||El&&8<El&&11>=El),Tl=String.fromCharCode(32),Al=!1;function zl(e,t){switch(e){case"keyup":return-1!==jl.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ll(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Ml=!1;var Il={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Pl(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!Il[e.type]:"textarea"===t}function Dl(e,t,l,n){Dt?Rt?Rt.push(n):Rt=[n]:Dt=n,0<(t=rd(t,"onChange")).length&&(l=new al("onChange","change",null,l,n),e.push({event:l,listeners:t}))}var Rl=null,Ol=null;function Fl(e){Yu(e,0)}function Ul(e){if(ft(et(e)))return e}function Bl(e,t){if("change"===e)return t}var ql=!1;if(qt){var Wl;if(qt){var Vl="oninput"in document;if(!Vl){var Hl=document.createElement("div");Hl.setAttribute("oninput","return;"),Vl="function"==typeof Hl.oninput}Wl=Vl}else Wl=!1;ql=Wl&&(!document.documentMode||9<document.documentMode)}function Kl(){Rl&&(Rl.detachEvent("onpropertychange",Gl),Ol=Rl=null)}function Gl(e){if("value"===e.propertyName&&Ul(Ol)){var t=[];Dl(t,Ol,e,Pt(e)),Ut(Fl,t)}}function Ql(e,t,l){"focusin"===e?(Kl(),Ol=l,(Rl=t).attachEvent("onpropertychange",Gl)):"focusout"===e&&Kl()}function Xl(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Ul(Ol)}function Yl(e,t){if("click"===e)return Ul(t)}function Jl(e,t){if("input"===e||"change"===e)return Ul(t)}var Zl="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t};function en(e,t){if(Zl(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var l=Object.keys(e),n=Object.keys(t);if(l.length!==n.length)return!1;for(n=0;n<l.length;n++){var a=l[n];if(!re.call(t,a)||!Zl(e[a],t[a]))return!1}return!0}function tn(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ln(e,t){var l,n=tn(e);for(e=0;n;){if(3===n.nodeType){if(l=e+n.textContent.length,e<=t&&l>=t)return{node:n,offset:t-e};e=l}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=tn(n)}}function nn(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?nn(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function an(e){for(var t=gt((e=null!=e&&null!=e.ownerDocument&&null!=e.ownerDocument.defaultView?e.ownerDocument.defaultView:window).document);t instanceof e.HTMLIFrameElement;){try{var l="string"==typeof t.contentWindow.location.href}catch(n){l=!1}if(!l)break;t=gt((e=t.contentWindow).document)}return t}function rn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}var on=qt&&"documentMode"in document&&11>=document.documentMode,sn=null,cn=null,un=null,dn=!1;function bn(e,t,l){var n=l.window===l?l.document:9===l.nodeType?l:l.ownerDocument;dn||null==sn||sn!==gt(n)||("selectionStart"in(n=sn)&&rn(n)?n={start:n.selectionStart,end:n.selectionEnd}:n={anchorNode:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset},un&&en(un,n)||(un=n,0<(n=rd(cn,"onSelect")).length&&(t=new al("onSelect","select",null,t,l),e.push({event:t,listeners:n}),t.target=sn)))}function mn(e,t){var l={};return l[e.toLowerCase()]=t.toLowerCase(),l["Webkit"+e]="webkit"+t,l["Moz"+e]="moz"+t,l}var hn={animationend:mn("Animation","AnimationEnd"),animationiteration:mn("Animation","AnimationIteration"),animationstart:mn("Animation","AnimationStart"),transitionrun:mn("Transition","TransitionRun"),transitionstart:mn("Transition","TransitionStart"),transitioncancel:mn("Transition","TransitionCancel"),transitionend:mn("Transition","TransitionEnd")},pn={},fn={};function gn(e){if(pn[e])return pn[e];if(!hn[e])return e;var t,l=hn[e];for(t in l)if(l.hasOwnProperty(t)&&t in fn)return pn[e]=l[t];return e}qt&&(fn=document.createElement("div").style,"AnimationEvent"in window||(delete hn.animationend.animation,delete hn.animationiteration.animation,delete hn.animationstart.animation),"TransitionEvent"in window||delete hn.transitionend.transition);var vn=gn("animationend"),yn=gn("animationiteration"),xn=gn("animationstart"),wn=gn("transitionrun"),kn=gn("transitionstart"),Cn=gn("transitioncancel"),Sn=gn("transitionend"),jn=new Map,Nn="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function En(e,t){jn.set(e,t),rt(t,[e])}Nn.push("scrollEnd");var _n="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)},$n=[],Tn=0,An=0;function zn(){for(var e=Tn,t=An=Tn=0;t<e;){var l=$n[t];$n[t++]=null;var n=$n[t];$n[t++]=null;var a=$n[t];$n[t++]=null;var r=$n[t];if($n[t++]=null,null!==n&&null!==a){var i=n.pending;null===i?a.next=a:(a.next=i.next,i.next=a),n.pending=a}0!==r&&Pn(l,a,r)}}function Ln(e,t,l,n){$n[Tn++]=e,$n[Tn++]=t,$n[Tn++]=l,$n[Tn++]=n,An|=n,e.lanes|=n,null!==(e=e.alternate)&&(e.lanes|=n)}function Mn(e,t,l,n){return Ln(e,t,l,n),Dn(e)}function In(e,t){return Ln(e,null,null,t),Dn(e)}function Pn(e,t,l){e.lanes|=l;var n=e.alternate;null!==n&&(n.lanes|=l);for(var a=!1,r=e.return;null!==r;)r.childLanes|=l,null!==(n=r.alternate)&&(n.childLanes|=l),22===r.tag&&(null===(e=r.stateNode)||1&e._visibility||(a=!0)),e=r,r=r.return;return 3===e.tag?(r=e.stateNode,a&&null!==t&&(a=31-ke(l),null===(n=(e=r.hiddenUpdates)[a])?e[a]=[t]:n.push(t),t.lane=536870912|l),r):null}function Dn(e){if(50<Hc)throw Hc=0,Kc=null,Error(r(185));for(var t=e.return;null!==t;)t=(e=t).return;return 3===e.tag?e.stateNode:null}var Rn={};function On(e,t,l,n){this.tag=e,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Fn(e,t,l,n){return new On(e,t,l,n)}function Un(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Bn(e,t){var l=e.alternate;return null===l?((l=Fn(e.tag,t,e.key,e.mode)).elementType=e.elementType,l.type=e.type,l.stateNode=e.stateNode,l.alternate=e,e.alternate=l):(l.pendingProps=t,l.type=e.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=65011712&e.flags,l.childLanes=e.childLanes,l.lanes=e.lanes,l.child=e.child,l.memoizedProps=e.memoizedProps,l.memoizedState=e.memoizedState,l.updateQueue=e.updateQueue,t=e.dependencies,l.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},l.sibling=e.sibling,l.index=e.index,l.ref=e.ref,l.refCleanup=e.refCleanup,l}function qn(e,t){e.flags&=65011714;var l=e.alternate;return null===l?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=l.childLanes,e.lanes=l.lanes,e.child=l.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=l.memoizedProps,e.memoizedState=l.memoizedState,e.updateQueue=l.updateQueue,e.type=l.type,t=l.dependencies,e.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Wn(e,t,l,n,a,i){var o=0;if(n=e,"function"==typeof e)Un(e)&&(o=1);else if("string"==typeof e)o=function(e,t,l){if(1===l||null!=t.itemProp)return!1;switch(e){case"meta":case"title":return!0;case"style":if("string"!=typeof t.precedence||"string"!=typeof t.href||""===t.href)break;return!0;case"link":if("string"!=typeof t.rel||"string"!=typeof t.href||""===t.href||t.onLoad||t.onError)break;return"stylesheet"!==t.rel||(e=t.disabled,"string"==typeof t.precedence&&null==e);case"script":if(t.async&&"function"!=typeof t.async&&"symbol"!=typeof t.async&&!t.onLoad&&!t.onError&&t.src&&"string"==typeof t.src)return!0}return!1}(e,l,H.current)?26:"html"===e||"head"===e||"body"===e?27:5;else e:switch(e){case $:return(e=Fn(31,l,t,a)).elementType=$,e.lanes=i,e;case f:return Vn(l.children,a,i,t);case g:o=8,a|=24;break;case y:return(e=Fn(12,l,t,2|a)).elementType=y,e.lanes=i,e;case j:return(e=Fn(13,l,t,a)).elementType=j,e.lanes=i,e;case N:return(e=Fn(19,l,t,a)).elementType=N,e.lanes=i,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case k:o=10;break e;case x:o=9;break e;case C:o=11;break e;case E:o=14;break e;case _:o=16,n=null;break e}o=29,l=Error(r(130,null===e?"null":typeof e,"")),n=null}return(t=Fn(o,l,t,a)).elementType=e,t.type=n,t.lanes=i,t}function Vn(e,t,l,n){return(e=Fn(7,e,n,t)).lanes=l,e}function Hn(e,t,l){return(e=Fn(6,e,null,t)).lanes=l,e}function Kn(e){var t=Fn(18,null,null,0);return t.stateNode=e,t}function Gn(e,t,l){return(t=Fn(4,null!==e.children?e.children:[],e.key,t)).lanes=l,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Qn=new WeakMap;function Xn(e,t){if("object"==typeof e&&null!==e){var l=Qn.get(e);return void 0!==l?l:(t={value:e,source:t,stack:ae(t)},Qn.set(e,t),t)}return{value:e,source:t,stack:ae(t)}}var Yn=[],Jn=0,Zn=null,ea=0,ta=[],la=0,na=null,aa=1,ra="";function ia(e,t){Yn[Jn++]=ea,Yn[Jn++]=Zn,Zn=e,ea=t}function oa(e,t,l){ta[la++]=aa,ta[la++]=ra,ta[la++]=na,na=e;var n=aa;e=ra;var a=32-ke(n)-1;n&=~(1<<a),l+=1;var r=32-ke(t)+a;if(30<r){var i=a-a%5;r=(n&(1<<i)-1).toString(32),n>>=i,a-=i,aa=1<<32-ke(t)+a|l<<a|n,ra=r+e}else aa=1<<r|l<<a|n,ra=e}function sa(e){null!==e.return&&(ia(e,1),oa(e,1,0))}function ca(e){for(;e===Zn;)Zn=Yn[--Jn],Yn[Jn]=null,ea=Yn[--Jn],Yn[Jn]=null;for(;e===na;)na=ta[--la],ta[la]=null,ra=ta[--la],ta[la]=null,aa=ta[--la],ta[la]=null}function ua(e,t){ta[la++]=aa,ta[la++]=ra,ta[la++]=na,aa=t.id,ra=t.overflow,na=e}var da=null,ba=null,ma=!1,ha=null,pa=!1,fa=Error(r(519));function ga(e){throw Ca(Xn(Error(r(418,1<arguments.length&&void 0!==arguments[1]&&arguments[1]?"text":"HTML","")),e)),fa}function va(e){var t=e.stateNode,l=e.type,n=e.memoizedProps;switch(t[qe]=e,t[We]=n,l){case"dialog":Ju("cancel",t),Ju("close",t);break;case"iframe":case"object":case"embed":Ju("load",t);break;case"video":case"audio":for(l=0;l<Qu.length;l++)Ju(Qu[l],t);break;case"source":Ju("error",t);break;case"img":case"image":case"link":Ju("error",t),Ju("load",t);break;case"details":Ju("toggle",t);break;case"input":Ju("invalid",t),wt(t,n.value,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name,!0);break;case"select":Ju("invalid",t);break;case"textarea":Ju("invalid",t),jt(t,n.value,n.defaultValue,n.children)}"string"!=typeof(l=n.children)&&"number"!=typeof l&&"bigint"!=typeof l||t.textContent===""+l||!0===n.suppressHydrationWarning||dd(t.textContent,l)?(null!=n.popover&&(Ju("beforetoggle",t),Ju("toggle",t)),null!=n.onScroll&&Ju("scroll",t),null!=n.onScrollEnd&&Ju("scrollend",t),null!=n.onClick&&(t.onclick=Mt),t=!0):t=!1,t||ga(e,!0)}function ya(e){for(da=e.return;da;)switch(da.tag){case 5:case 31:case 13:return void(pa=!1);case 27:case 3:return void(pa=!0);default:da=da.return}}function xa(e){if(e!==da)return!1;if(!ma)return ya(e),ma=!0,!1;var t,l=e.tag;if((t=3!==l&&27!==l)&&((t=5===l)&&(t=!("form"!==(t=e.type)&&"button"!==t)||wd(e.type,e.memoizedProps)),t=!t),t&&ba&&ga(e),ya(e),13===l){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(r(317));ba=Dd(e)}else if(31===l){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(r(317));ba=Dd(e)}else 27===l?(l=ba,_d(e.type)?(e=Pd,Pd=null,ba=e):ba=l):ba=da?Id(e.stateNode.nextSibling):null;return!0}function wa(){ba=da=null,ma=!1}function ka(){var e=ha;return null!==e&&(null===zc?zc=e:zc.push.apply(zc,e),ha=null),e}function Ca(e){null===ha?ha=[e]:ha.push(e)}var Sa=U(null),ja=null,Na=null;function Ea(e,t,l){q(Sa,t._currentValue),t._currentValue=l}function _a(e){e._currentValue=Sa.current,B(Sa)}function $a(e,t,l){for(;null!==e;){var n=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==n&&(n.childLanes|=t)):null!==n&&(n.childLanes&t)!==t&&(n.childLanes|=t),e===l)break;e=e.return}}function Ta(e,t,l,n){var a=e.child;for(null!==a&&(a.return=e);null!==a;){var i=a.dependencies;if(null!==i){var o=a.child;i=i.firstContext;e:for(;null!==i;){var s=i;i=a;for(var c=0;c<t.length;c++)if(s.context===t[c]){i.lanes|=l,null!==(s=i.alternate)&&(s.lanes|=l),$a(i.return,l,e),n||(o=null);break e}i=s.next}}else if(18===a.tag){if(null===(o=a.return))throw Error(r(341));o.lanes|=l,null!==(i=o.alternate)&&(i.lanes|=l),$a(o,l,e),o=null}else o=a.child;if(null!==o)o.return=a;else for(o=a;null!==o;){if(o===e){o=null;break}if(null!==(a=o.sibling)){a.return=o.return,o=a;break}o=o.return}a=o}}function Aa(e,t,l,n){e=null;for(var a=t,i=!1;null!==a;){if(!i)if(524288&a.flags)i=!0;else if(262144&a.flags)break;if(10===a.tag){var o=a.alternate;if(null===o)throw Error(r(387));if(null!==(o=o.memoizedProps)){var s=a.type;Zl(a.pendingProps.value,o.value)||(null!==e?e.push(s):e=[s])}}else if(a===Q.current){if(null===(o=a.alternate))throw Error(r(387));o.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(null!==e?e.push(bb):e=[bb])}a=a.return}null!==e&&Ta(t,e,l,n),t.flags|=262144}function za(e){for(e=e.firstContext;null!==e;){if(!Zl(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function La(e){ja=e,Na=null,null!==(e=e.dependencies)&&(e.firstContext=null)}function Ma(e){return Pa(ja,e)}function Ia(e,t){return null===ja&&La(e),Pa(e,t)}function Pa(e,t){var l=t._currentValue;if(t={context:t,memoizedValue:l,next:null},null===Na){if(null===e)throw Error(r(308));Na=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Na=Na.next=t;return l}var Da="undefined"!=typeof AbortController?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,l){e.push(l)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Ra=l.unstable_scheduleCallback,Oa=l.unstable_NormalPriority,Fa={$$typeof:k,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ua(){return{controller:new Da,data:new Map,refCount:0}}function Ba(e){e.refCount--,0===e.refCount&&Ra(Oa,function(){e.controller.abort()})}var qa=null,Wa=0,Va=0,Ha=null;function Ka(){if(0===--Wa&&null!==qa){null!==Ha&&(Ha.status="fulfilled");var e=qa;qa=null,Va=0,Ha=null;for(var t=0;t<e.length;t++)(0,e[t])()}}var Ga=P.S;P.S=function(e,t){Ic=ue(),"object"==typeof t&&null!==t&&"function"==typeof t.then&&function(e,t){if(null===qa){var l=qa=[];Wa=0,Va=Wu(),Ha={status:"pending",value:void 0,then:function(e){l.push(e)}}}Wa++,t.then(Ka,Ka)}(0,t),null!==Ga&&Ga(e,t)};var Qa=U(null);function Xa(){var e=Qa.current;return null!==e?e:fc.pooledCache}function Ya(e,t){q(Qa,null===t?Qa.current:t.pool)}function Ja(){var e=Xa();return null===e?null:{parent:Fa._currentValue,pool:e}}var Za=Error(r(460)),er=Error(r(474)),tr=Error(r(542)),lr={then:function(){}};function nr(e){return"fulfilled"===(e=e.status)||"rejected"===e}function ar(e,t,l){switch(void 0===(l=e[l])?e.push(t):l!==t&&(t.then(Mt,Mt),t=l),t.status){case"fulfilled":return t.value;case"rejected":throw sr(e=t.reason),e;default:if("string"==typeof t.status)t.then(Mt,Mt);else{if(null!==(e=fc)&&100<e.shellSuspendCounter)throw Error(r(482));(e=t).status="pending",e.then(function(e){if("pending"===t.status){var l=t;l.status="fulfilled",l.value=e}},function(e){if("pending"===t.status){var l=t;l.status="rejected",l.reason=e}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw sr(e=t.reason),e}throw ir=t,Za}}function rr(e){try{return(0,e._init)(e._payload)}catch(t){if(null!==t&&"object"==typeof t&&"function"==typeof t.then)throw ir=t,Za;throw t}}var ir=null;function or(){if(null===ir)throw Error(r(459));var e=ir;return ir=null,e}function sr(e){if(e===Za||e===tr)throw Error(r(483))}var cr=null,ur=0;function dr(e){var t=ur;return ur+=1,null===cr&&(cr=[]),ar(cr,e,t)}function br(e,t){t=t.props.ref,e.ref=void 0!==t?t:null}function mr(e,t){if(t.$$typeof===m)throw Error(r(525));throw e=Object.prototype.toString.call(t),Error(r(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function hr(e){function t(t,l){if(e){var n=t.deletions;null===n?(t.deletions=[l],t.flags|=16):n.push(l)}}function l(l,n){if(!e)return null;for(;null!==n;)t(l,n),n=n.sibling;return null}function n(e){for(var t=new Map;null!==e;)null!==e.key?t.set(e.key,e):t.set(e.index,e),e=e.sibling;return t}function a(e,t){return(e=Bn(e,t)).index=0,e.sibling=null,e}function i(t,l,n){return t.index=n,e?null!==(n=t.alternate)?(n=n.index)<l?(t.flags|=67108866,l):n:(t.flags|=67108866,l):(t.flags|=1048576,l)}function o(t){return e&&null===t.alternate&&(t.flags|=67108866),t}function s(e,t,l,n){return null===t||6!==t.tag?((t=Hn(l,e.mode,n)).return=e,t):((t=a(t,l)).return=e,t)}function c(e,t,l,n){var r=l.type;return r===f?d(e,t,l.props.children,n,l.key):null!==t&&(t.elementType===r||"object"==typeof r&&null!==r&&r.$$typeof===_&&rr(r)===t.type)?(br(t=a(t,l.props),l),t.return=e,t):(br(t=Wn(l.type,l.key,l.props,null,e.mode,n),l),t.return=e,t)}function u(e,t,l,n){return null===t||4!==t.tag||t.stateNode.containerInfo!==l.containerInfo||t.stateNode.implementation!==l.implementation?((t=Gn(l,e.mode,n)).return=e,t):((t=a(t,l.children||[])).return=e,t)}function d(e,t,l,n,r){return null===t||7!==t.tag?((t=Vn(l,e.mode,n,r)).return=e,t):((t=a(t,l)).return=e,t)}function b(e,t,l){if("string"==typeof t&&""!==t||"number"==typeof t||"bigint"==typeof t)return(t=Hn(""+t,e.mode,l)).return=e,t;if("object"==typeof t&&null!==t){switch(t.$$typeof){case h:return br(l=Wn(t.type,t.key,t.props,null,e.mode,l),t),l.return=e,l;case p:return(t=Gn(t,e.mode,l)).return=e,t;case _:return b(e,t=rr(t),l)}if(I(t)||z(t))return(t=Vn(t,e.mode,l,null)).return=e,t;if("function"==typeof t.then)return b(e,dr(t),l);if(t.$$typeof===k)return b(e,Ia(e,t),l);mr(e,t)}return null}function m(e,t,l,n){var a=null!==t?t.key:null;if("string"==typeof l&&""!==l||"number"==typeof l||"bigint"==typeof l)return null!==a?null:s(e,t,""+l,n);if("object"==typeof l&&null!==l){switch(l.$$typeof){case h:return l.key===a?c(e,t,l,n):null;case p:return l.key===a?u(e,t,l,n):null;case _:return m(e,t,l=rr(l),n)}if(I(l)||z(l))return null!==a?null:d(e,t,l,n,null);if("function"==typeof l.then)return m(e,t,dr(l),n);if(l.$$typeof===k)return m(e,t,Ia(e,l),n);mr(e,l)}return null}function g(e,t,l,n,a){if("string"==typeof n&&""!==n||"number"==typeof n||"bigint"==typeof n)return s(t,e=e.get(l)||null,""+n,a);if("object"==typeof n&&null!==n){switch(n.$$typeof){case h:return c(t,e=e.get(null===n.key?l:n.key)||null,n,a);case p:return u(t,e=e.get(null===n.key?l:n.key)||null,n,a);case _:return g(e,t,l,n=rr(n),a)}if(I(n)||z(n))return d(t,e=e.get(l)||null,n,a,null);if("function"==typeof n.then)return g(e,t,l,dr(n),a);if(n.$$typeof===k)return g(e,t,l,Ia(t,n),a);mr(t,n)}return null}function v(s,c,u,d){if("object"==typeof u&&null!==u&&u.type===f&&null===u.key&&(u=u.props.children),"object"==typeof u&&null!==u){switch(u.$$typeof){case h:e:{for(var y=u.key;null!==c;){if(c.key===y){if((y=u.type)===f){if(7===c.tag){l(s,c.sibling),(d=a(c,u.props.children)).return=s,s=d;break e}}else if(c.elementType===y||"object"==typeof y&&null!==y&&y.$$typeof===_&&rr(y)===c.type){l(s,c.sibling),br(d=a(c,u.props),u),d.return=s,s=d;break e}l(s,c);break}t(s,c),c=c.sibling}u.type===f?((d=Vn(u.props.children,s.mode,d,u.key)).return=s,s=d):(br(d=Wn(u.type,u.key,u.props,null,s.mode,d),u),d.return=s,s=d)}return o(s);case p:e:{for(y=u.key;null!==c;){if(c.key===y){if(4===c.tag&&c.stateNode.containerInfo===u.containerInfo&&c.stateNode.implementation===u.implementation){l(s,c.sibling),(d=a(c,u.children||[])).return=s,s=d;break e}l(s,c);break}t(s,c),c=c.sibling}(d=Gn(u,s.mode,d)).return=s,s=d}return o(s);case _:return v(s,c,u=rr(u),d)}if(I(u))return function(a,r,o,s){for(var c=null,u=null,d=r,h=r=0,p=null;null!==d&&h<o.length;h++){d.index>h?(p=d,d=null):p=d.sibling;var f=m(a,d,o[h],s);if(null===f){null===d&&(d=p);break}e&&d&&null===f.alternate&&t(a,d),r=i(f,r,h),null===u?c=f:u.sibling=f,u=f,d=p}if(h===o.length)return l(a,d),ma&&ia(a,h),c;if(null===d){for(;h<o.length;h++)null!==(d=b(a,o[h],s))&&(r=i(d,r,h),null===u?c=d:u.sibling=d,u=d);return ma&&ia(a,h),c}for(d=n(d);h<o.length;h++)null!==(p=g(d,a,h,o[h],s))&&(e&&null!==p.alternate&&d.delete(null===p.key?h:p.key),r=i(p,r,h),null===u?c=p:u.sibling=p,u=p);return e&&d.forEach(function(e){return t(a,e)}),ma&&ia(a,h),c}(s,c,u,d);if(z(u)){if("function"!=typeof(y=z(u)))throw Error(r(150));return function(a,o,s,c){if(null==s)throw Error(r(151));for(var u=null,d=null,h=o,p=o=0,f=null,v=s.next();null!==h&&!v.done;p++,v=s.next()){h.index>p?(f=h,h=null):f=h.sibling;var y=m(a,h,v.value,c);if(null===y){null===h&&(h=f);break}e&&h&&null===y.alternate&&t(a,h),o=i(y,o,p),null===d?u=y:d.sibling=y,d=y,h=f}if(v.done)return l(a,h),ma&&ia(a,p),u;if(null===h){for(;!v.done;p++,v=s.next())null!==(v=b(a,v.value,c))&&(o=i(v,o,p),null===d?u=v:d.sibling=v,d=v);return ma&&ia(a,p),u}for(h=n(h);!v.done;p++,v=s.next())null!==(v=g(h,a,p,v.value,c))&&(e&&null!==v.alternate&&h.delete(null===v.key?p:v.key),o=i(v,o,p),null===d?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),ma&&ia(a,p),u}(s,c,u=y.call(u),d)}if("function"==typeof u.then)return v(s,c,dr(u),d);if(u.$$typeof===k)return v(s,c,Ia(s,u),d);mr(s,u)}return"string"==typeof u&&""!==u||"number"==typeof u||"bigint"==typeof u?(u=""+u,null!==c&&6===c.tag?(l(s,c.sibling),(d=a(c,u)).return=s,s=d):(l(s,c),(d=Hn(u,s.mode,d)).return=s,s=d),o(s)):l(s,c)}return function(e,t,l,n){try{ur=0;var a=v(e,t,l,n);return cr=null,a}catch(i){if(i===Za||i===tr)throw i;var r=Fn(29,i,null,e.mode);return r.lanes=n,r.return=e,r}}}var pr=hr(!0),fr=hr(!1),gr=!1;function vr(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function yr(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function xr(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function wr(e,t,l){var n=e.updateQueue;if(null===n)return null;if(n=n.shared,2&pc){var a=n.pending;return null===a?t.next=t:(t.next=a.next,a.next=t),n.pending=t,t=Dn(e),Pn(e,null,l),t}return Ln(e,n,t,l),Dn(e)}function kr(e,t,l){if(null!==(t=t.updateQueue)&&(t=t.shared,4194048&l)){var n=t.lanes;l|=n&=e.pendingLanes,t.lanes=l,Pe(e,l)}}function Cr(e,t){var l=e.updateQueue,n=e.alternate;if(null!==n&&l===(n=n.updateQueue)){var a=null,r=null;if(null!==(l=l.firstBaseUpdate)){do{var i={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};null===r?a=r=i:r=r.next=i,l=l.next}while(null!==l);null===r?a=r=t:r=r.next=t}else a=r=t;return l={baseState:n.baseState,firstBaseUpdate:a,lastBaseUpdate:r,shared:n.shared,callbacks:n.callbacks},void(e.updateQueue=l)}null===(e=l.lastBaseUpdate)?l.firstBaseUpdate=t:e.next=t,l.lastBaseUpdate=t}var Sr=!1;function jr(){if(Sr){if(null!==Ha)throw Ha}}function Nr(e,t,l,n){Sr=!1;var a=e.updateQueue;gr=!1;var r=a.firstBaseUpdate,i=a.lastBaseUpdate,o=a.shared.pending;if(null!==o){a.shared.pending=null;var s=o,c=s.next;s.next=null,null===i?r=c:i.next=c,i=s;var u=e.alternate;null!==u&&((o=(u=u.updateQueue).lastBaseUpdate)!==i&&(null===o?u.firstBaseUpdate=c:o.next=c,u.lastBaseUpdate=s))}if(null!==r){var d=a.baseState;for(i=0,u=c=s=null,o=r;;){var m=-536870913&o.lane,h=m!==o.lane;if(h?(vc&m)===m:(n&m)===m){0!==m&&m===Va&&(Sr=!0),null!==u&&(u=u.next={lane:0,tag:o.tag,payload:o.payload,callback:null,next:null});e:{var p=e,f=o;m=t;var g=l;switch(f.tag){case 1:if("function"==typeof(p=f.payload)){d=p.call(g,d,m);break e}d=p;break e;case 3:p.flags=-65537&p.flags|128;case 0:if(null==(m="function"==typeof(p=f.payload)?p.call(g,d,m):p))break e;d=b({},d,m);break e;case 2:gr=!0}}null!==(m=o.callback)&&(e.flags|=64,h&&(e.flags|=8192),null===(h=a.callbacks)?a.callbacks=[m]:h.push(m))}else h={lane:m,tag:o.tag,payload:o.payload,callback:o.callback,next:null},null===u?(c=u=h,s=d):u=u.next=h,i|=m;if(null===(o=o.next)){if(null===(o=a.shared.pending))break;o=(h=o).next,h.next=null,a.lastBaseUpdate=h,a.shared.pending=null}}null===u&&(s=d),a.baseState=s,a.firstBaseUpdate=c,a.lastBaseUpdate=u,null===r&&(a.shared.lanes=0),Nc|=i,e.lanes=i,e.memoizedState=d}}function Er(e,t){if("function"!=typeof e)throw Error(r(191,e));e.call(t)}function _r(e,t){var l=e.callbacks;if(null!==l)for(e.callbacks=null,e=0;e<l.length;e++)Er(l[e],t)}var $r=U(null),Tr=U(0);function Ar(e,t){q(Tr,e=Sc),q($r,t),Sc=e|t.baseLanes}function zr(){q(Tr,Sc),q($r,$r.current)}function Lr(){Sc=Tr.current,B($r),B(Tr)}var Mr=U(null),Ir=null;function Pr(e){var t=e.alternate;q(Ur,1&Ur.current),q(Mr,e),null===Ir&&(null===t||null!==$r.current||null!==t.memoizedState)&&(Ir=e)}function Dr(e){q(Ur,Ur.current),q(Mr,e),null===Ir&&(Ir=e)}function Rr(e){22===e.tag?(q(Ur,Ur.current),q(Mr,e),null===Ir&&(Ir=e)):Or()}function Or(){q(Ur,Ur.current),q(Mr,Mr.current)}function Fr(e){B(Mr),Ir===e&&(Ir=null),B(Ur)}var Ur=U(0);function Br(e){for(var t=e;null!==t;){if(13===t.tag){var l=t.memoizedState;if(null!==l&&(null===(l=l.dehydrated)||Ld(l)||Md(l)))return t}else if(19!==t.tag||"forwards"!==t.memoizedProps.revealOrder&&"backwards"!==t.memoizedProps.revealOrder&&"unstable_legacy-backwards"!==t.memoizedProps.revealOrder&&"together"!==t.memoizedProps.revealOrder){if(null!==t.child){t.child.return=t,t=t.child;continue}}else if(128&t.flags)return t;if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var qr=0,Wr=null,Vr=null,Hr=null,Kr=!1,Gr=!1,Qr=!1,Xr=0,Yr=0,Jr=null,Zr=0;function ei(){throw Error(r(321))}function ti(e,t){if(null===t)return!1;for(var l=0;l<t.length&&l<e.length;l++)if(!Zl(e[l],t[l]))return!1;return!0}function li(e,t,l,n,a,r){return qr=r,Wr=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,P.H=null===e||null===e.memoizedState?vo:yo,Qr=!1,r=l(n,a),Qr=!1,Gr&&(r=ai(t,l,n,a)),ni(e),r}function ni(e){P.H=go;var t=null!==Vr&&null!==Vr.next;if(qr=0,Hr=Vr=Wr=null,Kr=!1,Yr=0,Jr=null,t)throw Error(r(300));null===e||Io||null!==(e=e.dependencies)&&za(e)&&(Io=!0)}function ai(e,t,l,n){Wr=e;var a=0;do{if(Gr&&(Jr=null),Yr=0,Gr=!1,25<=a)throw Error(r(301));if(a+=1,Hr=Vr=null,null!=e.updateQueue){var i=e.updateQueue;i.lastEffect=null,i.events=null,i.stores=null,null!=i.memoCache&&(i.memoCache.index=0)}P.H=xo,i=t(l,n)}while(Gr);return i}function ri(){var e=P.H,t=e.useState()[0];return t="function"==typeof t.then?di(t):t,e=e.useState()[0],(null!==Vr?Vr.memoizedState:null)!==e&&(Wr.flags|=1024),t}function ii(){var e=0!==Xr;return Xr=0,e}function oi(e,t,l){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l}function si(e){if(Kr){for(e=e.memoizedState;null!==e;){var t=e.queue;null!==t&&(t.pending=null),e=e.next}Kr=!1}qr=0,Hr=Vr=Wr=null,Gr=!1,Yr=Xr=0,Jr=null}function ci(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===Hr?Wr.memoizedState=Hr=e:Hr=Hr.next=e,Hr}function ui(){if(null===Vr){var e=Wr.alternate;e=null!==e?e.memoizedState:null}else e=Vr.next;var t=null===Hr?Wr.memoizedState:Hr.next;if(null!==t)Hr=t,Vr=e;else{if(null===e){if(null===Wr.alternate)throw Error(r(467));throw Error(r(310))}e={memoizedState:(Vr=e).memoizedState,baseState:Vr.baseState,baseQueue:Vr.baseQueue,queue:Vr.queue,next:null},null===Hr?Wr.memoizedState=Hr=e:Hr=Hr.next=e}return Hr}function di(e){var t=Yr;return Yr+=1,null===Jr&&(Jr=[]),e=ar(Jr,e,t),t=Wr,null===(null===Hr?t.memoizedState:Hr.next)&&(t=t.alternate,P.H=null===t||null===t.memoizedState?vo:yo),e}function bi(e){if(null!==e&&"object"==typeof e){if("function"==typeof e.then)return di(e);if(e.$$typeof===k)return Ma(e)}throw Error(r(438,String(e)))}function mi(e){var t=null,l=Wr.updateQueue;if(null!==l&&(t=l.memoCache),null==t){var n=Wr.alternate;null!==n&&(null!==(n=n.updateQueue)&&(null!=(n=n.memoCache)&&(t={data:n.data.map(function(e){return e.slice()}),index:0})))}if(null==t&&(t={data:[],index:0}),null===l&&(l={lastEffect:null,events:null,stores:null,memoCache:null},Wr.updateQueue=l),l.memoCache=t,void 0===(l=t.data[t.index]))for(l=t.data[t.index]=Array(e),n=0;n<e;n++)l[n]=T;return t.index++,l}function hi(e,t){return"function"==typeof t?t(e):t}function pi(e){return fi(ui(),Vr,e)}function fi(e,t,l){var n=e.queue;if(null===n)throw Error(r(311));n.lastRenderedReducer=l;var a=e.baseQueue,i=n.pending;if(null!==i){if(null!==a){var o=a.next;a.next=i.next,i.next=o}t.baseQueue=a=i,n.pending=null}if(i=e.baseState,null===a)e.memoizedState=i;else{var s=o=null,c=null,u=t=a.next,d=!1;do{var b=-536870913&u.lane;if(b!==u.lane?(vc&b)===b:(qr&b)===b){var m=u.revertLane;if(0===m)null!==c&&(c=c.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),b===Va&&(d=!0);else{if((qr&m)===m){u=u.next,m===Va&&(d=!0);continue}b={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(s=c=b,o=i):c=c.next=b,Wr.lanes|=m,Nc|=m}b=u.action,Qr&&l(i,b),i=u.hasEagerState?u.eagerState:l(i,b)}else m={lane:b,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(s=c=m,o=i):c=c.next=m,Wr.lanes|=b,Nc|=b;u=u.next}while(null!==u&&u!==t);if(null===c?o=i:c.next=s,!Zl(i,e.memoizedState)&&(Io=!0,d&&null!==(l=Ha)))throw l;e.memoizedState=i,e.baseState=o,e.baseQueue=c,n.lastRenderedState=i}return null===a&&(n.lanes=0),[e.memoizedState,n.dispatch]}function gi(e){var t=ui(),l=t.queue;if(null===l)throw Error(r(311));l.lastRenderedReducer=e;var n=l.dispatch,a=l.pending,i=t.memoizedState;if(null!==a){l.pending=null;var o=a=a.next;do{i=e(i,o.action),o=o.next}while(o!==a);Zl(i,t.memoizedState)||(Io=!0),t.memoizedState=i,null===t.baseQueue&&(t.baseState=i),l.lastRenderedState=i}return[i,n]}function vi(e,t,l){var n=Wr,a=ui(),i=ma;if(i){if(void 0===l)throw Error(r(407));l=l()}else l=t();var o=!Zl((Vr||a).memoizedState,l);if(o&&(a.memoizedState=l,Io=!0),a=a.queue,qi(wi.bind(null,n,a,e),[e]),a.getSnapshot!==t||o||null!==Hr&&1&Hr.memoizedState.tag){if(n.flags|=2048,Ri(9,{destroy:void 0},xi.bind(null,n,a,l,t),null),null===fc)throw Error(r(349));i||127&qr||yi(n,t,l)}return l}function yi(e,t,l){e.flags|=16384,e={getSnapshot:t,value:l},null===(t=Wr.updateQueue)?(t={lastEffect:null,events:null,stores:null,memoCache:null},Wr.updateQueue=t,t.stores=[e]):null===(l=t.stores)?t.stores=[e]:l.push(e)}function xi(e,t,l,n){t.value=l,t.getSnapshot=n,ki(t)&&Ci(e)}function wi(e,t,l){return l(function(){ki(t)&&Ci(e)})}function ki(e){var t=e.getSnapshot;e=e.value;try{var l=t();return!Zl(e,l)}catch(n){return!0}}function Ci(e){var t=In(e,2);null!==t&&Xc(t,e,2)}function Si(e){var t=ci();if("function"==typeof e){var l=e;if(e=l(),Qr){we(!0);try{l()}finally{we(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:hi,lastRenderedState:e},t}function ji(e,t,l,n){return e.baseState=l,fi(e,Vr,"function"==typeof n?n:hi)}function Ni(e,t,l,n,a){if(ho(e))throw Error(r(485));if(null!==(e=t.action)){var i={payload:a,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(e){i.listeners.push(e)}};null!==P.T?l(!0):i.isTransition=!1,n(i),null===(l=t.pending)?(i.next=t.pending=i,Ei(t,i)):(i.next=l.next,t.pending=l.next=i)}}function Ei(e,t){var l=t.action,n=t.payload,a=e.state;if(t.isTransition){var r=P.T,i={};P.T=i;try{var o=l(a,n),s=P.S;null!==s&&s(i,o),_i(e,t,o)}catch(c){Ti(e,t,c)}finally{null!==r&&null!==i.types&&(r.types=i.types),P.T=r}}else try{_i(e,t,r=l(a,n))}catch(u){Ti(e,t,u)}}function _i(e,t,l){null!==l&&"object"==typeof l&&"function"==typeof l.then?l.then(function(l){$i(e,t,l)},function(l){return Ti(e,t,l)}):$i(e,t,l)}function $i(e,t,l){t.status="fulfilled",t.value=l,Ai(t),e.state=l,null!==(t=e.pending)&&((l=t.next)===t?e.pending=null:(l=l.next,t.next=l,Ei(e,l)))}function Ti(e,t,l){var n=e.pending;if(e.pending=null,null!==n){n=n.next;do{t.status="rejected",t.reason=l,Ai(t),t=t.next}while(t!==n)}e.action=null}function Ai(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function zi(e,t){return t}function Li(e,t){if(ma){var l=fc.formState;if(null!==l){e:{var n=Wr;if(ma){if(ba){t:{for(var a=ba,r=pa;8!==a.nodeType;){if(!r){a=null;break t}if(null===(a=Id(a.nextSibling))){a=null;break t}}a="F!"===(r=a.data)||"F"===r?a:null}if(a){ba=Id(a.nextSibling),n="F!"===a.data;break e}}ga(n)}n=!1}n&&(t=l[0])}}return(l=ci()).memoizedState=l.baseState=t,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:zi,lastRenderedState:t},l.queue=n,l=uo.bind(null,Wr,n),n.dispatch=l,n=Si(!1),r=mo.bind(null,Wr,!1,n.queue),a={state:t,dispatch:null,action:e,pending:null},(n=ci()).queue=a,l=Ni.bind(null,Wr,a,r,l),a.dispatch=l,n.memoizedState=e,[t,l,!1]}function Mi(e){return Ii(ui(),Vr,e)}function Ii(e,t,l){if(t=fi(e,t,zi)[0],e=pi(hi)[0],"object"==typeof t&&null!==t&&"function"==typeof t.then)try{var n=di(t)}catch(i){if(i===Za)throw tr;throw i}else n=t;var a=(t=ui()).queue,r=a.dispatch;return l!==t.memoizedState&&(Wr.flags|=2048,Ri(9,{destroy:void 0},Pi.bind(null,a,l),null)),[n,r,e]}function Pi(e,t){e.action=t}function Di(e){var t=ui(),l=Vr;if(null!==l)return Ii(t,l,e);ui(),t=t.memoizedState;var n=(l=ui()).queue.dispatch;return l.memoizedState=e,[t,n,!1]}function Ri(e,t,l,n){return e={tag:e,create:l,deps:n,inst:t,next:null},null===(t=Wr.updateQueue)&&(t={lastEffect:null,events:null,stores:null,memoCache:null},Wr.updateQueue=t),null===(l=t.lastEffect)?t.lastEffect=e.next=e:(n=l.next,l.next=e,e.next=n,t.lastEffect=e),e}function Oi(){return ui().memoizedState}function Fi(e,t,l,n){var a=ci();Wr.flags|=e,a.memoizedState=Ri(1|t,{destroy:void 0},l,void 0===n?null:n)}function Ui(e,t,l,n){var a=ui();n=void 0===n?null:n;var r=a.memoizedState.inst;null!==Vr&&null!==n&&ti(n,Vr.memoizedState.deps)?a.memoizedState=Ri(t,r,l,n):(Wr.flags|=e,a.memoizedState=Ri(1|t,r,l,n))}function Bi(e,t){Fi(8390656,8,e,t)}function qi(e,t){Ui(2048,8,e,t)}function Wi(e){var t=ui().memoizedState;return function(e){Wr.flags|=4;var t=Wr.updateQueue;if(null===t)t={lastEffect:null,events:null,stores:null,memoCache:null},Wr.updateQueue=t,t.events=[e];else{var l=t.events;null===l?t.events=[e]:l.push(e)}}({ref:t,nextImpl:e}),function(){if(2&pc)throw Error(r(440));return t.impl.apply(void 0,arguments)}}function Vi(e,t){return Ui(4,2,e,t)}function Hi(e,t){return Ui(4,4,e,t)}function Ki(e,t){if("function"==typeof t){e=e();var l=t(e);return function(){"function"==typeof l?l():t(null)}}if(null!=t)return e=e(),t.current=e,function(){t.current=null}}function Gi(e,t,l){l=null!=l?l.concat([e]):null,Ui(4,4,Ki.bind(null,t,e),l)}function Qi(){}function Xi(e,t){var l=ui();t=void 0===t?null:t;var n=l.memoizedState;return null!==t&&ti(t,n[1])?n[0]:(l.memoizedState=[e,t],e)}function Yi(e,t){var l=ui();t=void 0===t?null:t;var n=l.memoizedState;if(null!==t&&ti(t,n[1]))return n[0];if(n=e(),Qr){we(!0);try{e()}finally{we(!1)}}return l.memoizedState=[n,t],n}function Ji(e,t,l){return void 0===l||1073741824&qr&&!(261930&vc)?e.memoizedState=t:(e.memoizedState=l,e=Qc(),Wr.lanes|=e,Nc|=e,l)}function Zi(e,t,l,n){return Zl(l,t)?l:null!==$r.current?(e=Ji(e,l,n),Zl(e,t)||(Io=!0),e):42&qr&&(!(1073741824&qr)||261930&vc)?(e=Qc(),Wr.lanes|=e,Nc|=e,t):(Io=!0,e.memoizedState=l)}function eo(e,t,l,n,a){var r=D.p;D.p=0!==r&&8>r?r:8;var i,o,s,c=P.T,u={};P.T=u,mo(e,!1,t,l);try{var d=a(),b=P.S;if(null!==b&&b(u,d),null!==d&&"object"==typeof d&&"function"==typeof d.then)bo(e,t,(i=n,o=[],s={status:"pending",value:null,reason:null,then:function(e){o.push(e)}},d.then(function(){s.status="fulfilled",s.value=i;for(var e=0;e<o.length;e++)(0,o[e])(i)},function(e){for(s.status="rejected",s.reason=e,e=0;e<o.length;e++)(0,o[e])(void 0)}),s),Gc());else bo(e,t,n,Gc())}catch(m){bo(e,t,{then:function(){},status:"rejected",reason:m},Gc())}finally{D.p=r,null!==c&&null!==u.types&&(c.types=u.types),P.T=c}}function to(){}function lo(e,t,l,n){if(5!==e.tag)throw Error(r(476));var a=no(e).queue;eo(e,a,t,R,null===l?to:function(){return ao(e),l(n)})}function no(e){var t=e.memoizedState;if(null!==t)return t;var l={};return(t={memoizedState:R,baseState:R,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:hi,lastRenderedState:R},next:null}).next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:hi,lastRenderedState:l},next:null},e.memoizedState=t,null!==(e=e.alternate)&&(e.memoizedState=t),t}function ao(e){var t=no(e);null===t.next&&(t=e.alternate.memoizedState),bo(e,t.next.queue,{},Gc())}function ro(){return Ma(bb)}function io(){return ui().memoizedState}function oo(){return ui().memoizedState}function so(e){for(var t=e.return;null!==t;){switch(t.tag){case 24:case 3:var l=Gc(),n=wr(t,e=xr(l),l);return null!==n&&(Xc(n,t,l),kr(n,t,l)),t={cache:Ua()},void(e.payload=t)}t=t.return}}function co(e,t,l){var n=Gc();l={lane:n,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},ho(e)?po(t,l):null!==(l=Mn(e,t,l,n))&&(Xc(l,e,n),fo(l,t,n))}function uo(e,t,l){bo(e,t,l,Gc())}function bo(e,t,l,n){var a={lane:n,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(ho(e))po(t,a);else{var r=e.alternate;if(0===e.lanes&&(null===r||0===r.lanes)&&null!==(r=t.lastRenderedReducer))try{var i=t.lastRenderedState,o=r(i,l);if(a.hasEagerState=!0,a.eagerState=o,Zl(o,i))return Ln(e,t,a,0),null===fc&&zn(),!1}catch(s){}if(null!==(l=Mn(e,t,a,n)))return Xc(l,e,n),fo(l,t,n),!0}return!1}function mo(e,t,l,n){if(n={lane:2,revertLane:Wu(),gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},ho(e)){if(t)throw Error(r(479))}else null!==(t=Mn(e,l,n,2))&&Xc(t,e,2)}function ho(e){var t=e.alternate;return e===Wr||null!==t&&t===Wr}function po(e,t){Gr=Kr=!0;var l=e.pending;null===l?t.next=t:(t.next=l.next,l.next=t),e.pending=t}function fo(e,t,l){if(4194048&l){var n=t.lanes;l|=n&=e.pendingLanes,t.lanes=l,Pe(e,l)}}var go={readContext:Ma,use:bi,useCallback:ei,useContext:ei,useEffect:ei,useImperativeHandle:ei,useLayoutEffect:ei,useInsertionEffect:ei,useMemo:ei,useReducer:ei,useRef:ei,useState:ei,useDebugValue:ei,useDeferredValue:ei,useTransition:ei,useSyncExternalStore:ei,useId:ei,useHostTransitionStatus:ei,useFormState:ei,useActionState:ei,useOptimistic:ei,useMemoCache:ei,useCacheRefresh:ei};go.useEffectEvent=ei;var vo={readContext:Ma,use:bi,useCallback:function(e,t){return ci().memoizedState=[e,void 0===t?null:t],e},useContext:Ma,useEffect:Bi,useImperativeHandle:function(e,t,l){l=null!=l?l.concat([e]):null,Fi(4194308,4,Ki.bind(null,t,e),l)},useLayoutEffect:function(e,t){return Fi(4194308,4,e,t)},useInsertionEffect:function(e,t){Fi(4,2,e,t)},useMemo:function(e,t){var l=ci();t=void 0===t?null:t;var n=e();if(Qr){we(!0);try{e()}finally{we(!1)}}return l.memoizedState=[n,t],n},useReducer:function(e,t,l){var n=ci();if(void 0!==l){var a=l(t);if(Qr){we(!0);try{l(t)}finally{we(!1)}}}else a=t;return n.memoizedState=n.baseState=a,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:a},n.queue=e,e=e.dispatch=co.bind(null,Wr,e),[n.memoizedState,e]},useRef:function(e){return e={current:e},ci().memoizedState=e},useState:function(e){var t=(e=Si(e)).queue,l=uo.bind(null,Wr,t);return t.dispatch=l,[e.memoizedState,l]},useDebugValue:Qi,useDeferredValue:function(e,t){return Ji(ci(),e,t)},useTransition:function(){var e=Si(!1);return e=eo.bind(null,Wr,e.queue,!0,!1),ci().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,l){var n=Wr,a=ci();if(ma){if(void 0===l)throw Error(r(407));l=l()}else{if(l=t(),null===fc)throw Error(r(349));127&vc||yi(n,t,l)}a.memoizedState=l;var i={value:l,getSnapshot:t};return a.queue=i,Bi(wi.bind(null,n,i,e),[e]),n.flags|=2048,Ri(9,{destroy:void 0},xi.bind(null,n,i,l,t),null),l},useId:function(){var e=ci(),t=fc.identifierPrefix;if(ma){var l=ra;t="_"+t+"R_"+(l=(aa&~(1<<32-ke(aa)-1)).toString(32)+l),0<(l=Xr++)&&(t+="H"+l.toString(32)),t+="_"}else t="_"+t+"r_"+(l=Zr++).toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:ro,useFormState:Li,useActionState:Li,useOptimistic:function(e){var t=ci();t.memoizedState=t.baseState=e;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=l,t=mo.bind(null,Wr,!0,l),l.dispatch=t,[e,t]},useMemoCache:mi,useCacheRefresh:function(){return ci().memoizedState=so.bind(null,Wr)},useEffectEvent:function(e){var t=ci(),l={impl:e};return t.memoizedState=l,function(){if(2&pc)throw Error(r(440));return l.impl.apply(void 0,arguments)}}},yo={readContext:Ma,use:bi,useCallback:Xi,useContext:Ma,useEffect:qi,useImperativeHandle:Gi,useInsertionEffect:Vi,useLayoutEffect:Hi,useMemo:Yi,useReducer:pi,useRef:Oi,useState:function(){return pi(hi)},useDebugValue:Qi,useDeferredValue:function(e,t){return Zi(ui(),Vr.memoizedState,e,t)},useTransition:function(){var e=pi(hi)[0],t=ui().memoizedState;return["boolean"==typeof e?e:di(e),t]},useSyncExternalStore:vi,useId:io,useHostTransitionStatus:ro,useFormState:Mi,useActionState:Mi,useOptimistic:function(e,t){return ji(ui(),0,e,t)},useMemoCache:mi,useCacheRefresh:oo};yo.useEffectEvent=Wi;var xo={readContext:Ma,use:bi,useCallback:Xi,useContext:Ma,useEffect:qi,useImperativeHandle:Gi,useInsertionEffect:Vi,useLayoutEffect:Hi,useMemo:Yi,useReducer:gi,useRef:Oi,useState:function(){return gi(hi)},useDebugValue:Qi,useDeferredValue:function(e,t){var l=ui();return null===Vr?Ji(l,e,t):Zi(l,Vr.memoizedState,e,t)},useTransition:function(){var e=gi(hi)[0],t=ui().memoizedState;return["boolean"==typeof e?e:di(e),t]},useSyncExternalStore:vi,useId:io,useHostTransitionStatus:ro,useFormState:Di,useActionState:Di,useOptimistic:function(e,t){var l=ui();return null!==Vr?ji(l,0,e,t):(l.baseState=e,[e,l.queue.dispatch])},useMemoCache:mi,useCacheRefresh:oo};function wo(e,t,l,n){l=null==(l=l(n,t=e.memoizedState))?t:b({},t,l),e.memoizedState=l,0===e.lanes&&(e.updateQueue.baseState=l)}xo.useEffectEvent=Wi;var ko={enqueueSetState:function(e,t,l){e=e._reactInternals;var n=Gc(),a=xr(n);a.payload=t,null!=l&&(a.callback=l),null!==(t=wr(e,a,n))&&(Xc(t,e,n),kr(t,e,n))},enqueueReplaceState:function(e,t,l){e=e._reactInternals;var n=Gc(),a=xr(n);a.tag=1,a.payload=t,null!=l&&(a.callback=l),null!==(t=wr(e,a,n))&&(Xc(t,e,n),kr(t,e,n))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var l=Gc(),n=xr(l);n.tag=2,null!=t&&(n.callback=t),null!==(t=wr(e,n,l))&&(Xc(t,e,l),kr(t,e,l))}};function Co(e,t,l,n,a,r,i){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(n,r,i):!t.prototype||!t.prototype.isPureReactComponent||(!en(l,n)||!en(a,r))}function So(e,t,l,n){e=t.state,"function"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(l,n),"function"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(l,n),t.state!==e&&ko.enqueueReplaceState(t,t.state,null)}function jo(e,t){var l=t;if("ref"in t)for(var n in l={},t)"ref"!==n&&(l[n]=t[n]);if(e=e.defaultProps)for(var a in l===t&&(l=b({},l)),e)void 0===l[a]&&(l[a]=e[a]);return l}function No(e){_n(e)}function Eo(e){console.error(e)}function _o(e){_n(e)}function $o(e,t){try{(0,e.onUncaughtError)(t.value,{componentStack:t.stack})}catch(l){setTimeout(function(){throw l})}}function To(e,t,l){try{(0,e.onCaughtError)(l.value,{componentStack:l.stack,errorBoundary:1===t.tag?t.stateNode:null})}catch(n){setTimeout(function(){throw n})}}function Ao(e,t,l){return(l=xr(l)).tag=3,l.payload={element:null},l.callback=function(){$o(e,t)},l}function zo(e){return(e=xr(e)).tag=3,e}function Lo(e,t,l,n){var a=l.type.getDerivedStateFromError;if("function"==typeof a){var r=n.value;e.payload=function(){return a(r)},e.callback=function(){To(t,l,n)}}var i=l.stateNode;null!==i&&"function"==typeof i.componentDidCatch&&(e.callback=function(){To(t,l,n),"function"!=typeof a&&(null===Rc?Rc=new Set([this]):Rc.add(this));var e=n.stack;this.componentDidCatch(n.value,{componentStack:null!==e?e:""})})}var Mo=Error(r(461)),Io=!1;function Po(e,t,l,n){t.child=null===e?fr(t,null,l,n):pr(t,e.child,l,n)}function Do(e,t,l,n,a){l=l.render;var r=t.ref;if("ref"in n){var i={};for(var o in n)"ref"!==o&&(i[o]=n[o])}else i=n;return La(t),n=li(e,t,l,i,r,a),o=ii(),null===e||Io?(ma&&o&&sa(t),t.flags|=1,Po(e,t,n,a),t.child):(oi(e,t,a),is(e,t,a))}function Ro(e,t,l,n,a){if(null===e){var r=l.type;return"function"!=typeof r||Un(r)||void 0!==r.defaultProps||null!==l.compare?((e=Wn(l.type,null,n,t,t.mode,a)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=r,Oo(e,t,r,n,a))}if(r=e.child,!os(e,a)){var i=r.memoizedProps;if((l=null!==(l=l.compare)?l:en)(i,n)&&e.ref===t.ref)return is(e,t,a)}return t.flags|=1,(e=Bn(r,n)).ref=t.ref,e.return=t,t.child=e}function Oo(e,t,l,n,a){if(null!==e){var r=e.memoizedProps;if(en(r,n)&&e.ref===t.ref){if(Io=!1,t.pendingProps=n=r,!os(e,a))return t.lanes=e.lanes,is(e,t,a);131072&e.flags&&(Io=!0)}}return Ho(e,t,l,n,a)}function Fo(e,t,l,n){var a=n.children,r=null!==e?e.memoizedState:null;if(null===e&&null===t.stateNode&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),"hidden"===n.mode){if(128&t.flags){if(r=null!==r?r.baseLanes|l:l,null!==e){for(n=t.child=e.child,a=0;null!==n;)a=a|n.lanes|n.childLanes,n=n.sibling;n=a&~r}else n=0,t.child=null;return Bo(e,t,r,l,n)}if(!(536870912&l))return n=t.lanes=536870912,Bo(e,t,null!==r?r.baseLanes|l:l,l,n);t.memoizedState={baseLanes:0,cachePool:null},null!==e&&Ya(0,null!==r?r.cachePool:null),null!==r?Ar(t,r):zr(),Rr(t)}else null!==r?(Ya(0,r.cachePool),Ar(t,r),Or(),t.memoizedState=null):(null!==e&&Ya(0,null),zr(),Or());return Po(e,t,a,l),t.child}function Uo(e,t){return null!==e&&22===e.tag||null!==t.stateNode||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Bo(e,t,l,n,a){var r=Xa();return r=null===r?null:{parent:Fa._currentValue,pool:r},t.memoizedState={baseLanes:l,cachePool:r},null!==e&&Ya(0,null),zr(),Rr(t),null!==e&&Aa(e,t,n,!0),t.childLanes=a,null}function qo(e,t){return(t=ts({mode:t.mode,children:t.children},e.mode)).ref=e.ref,e.child=t,t.return=e,t}function Wo(e,t,l){return pr(t,e.child,null,l),(e=qo(t,t.pendingProps)).flags|=2,Fr(t),t.memoizedState=null,e}function Vo(e,t){var l=t.ref;if(null===l)null!==e&&null!==e.ref&&(t.flags|=4194816);else{if("function"!=typeof l&&"object"!=typeof l)throw Error(r(284));null!==e&&e.ref===l||(t.flags|=4194816)}}function Ho(e,t,l,n,a){return La(t),l=li(e,t,l,n,void 0,a),n=ii(),null===e||Io?(ma&&n&&sa(t),t.flags|=1,Po(e,t,l,a),t.child):(oi(e,t,a),is(e,t,a))}function Ko(e,t,l,n,a,r){return La(t),t.updateQueue=null,l=ai(t,n,l,a),ni(e),n=ii(),null===e||Io?(ma&&n&&sa(t),t.flags|=1,Po(e,t,l,r),t.child):(oi(e,t,r),is(e,t,r))}function Go(e,t,l,n,a){if(La(t),null===t.stateNode){var r=Rn,i=l.contextType;"object"==typeof i&&null!==i&&(r=Ma(i)),r=new l(n,r),t.memoizedState=null!==r.state&&void 0!==r.state?r.state:null,r.updater=ko,t.stateNode=r,r._reactInternals=t,(r=t.stateNode).props=n,r.state=t.memoizedState,r.refs={},vr(t),i=l.contextType,r.context="object"==typeof i&&null!==i?Ma(i):Rn,r.state=t.memoizedState,"function"==typeof(i=l.getDerivedStateFromProps)&&(wo(t,l,i,n),r.state=t.memoizedState),"function"==typeof l.getDerivedStateFromProps||"function"==typeof r.getSnapshotBeforeUpdate||"function"!=typeof r.UNSAFE_componentWillMount&&"function"!=typeof r.componentWillMount||(i=r.state,"function"==typeof r.componentWillMount&&r.componentWillMount(),"function"==typeof r.UNSAFE_componentWillMount&&r.UNSAFE_componentWillMount(),i!==r.state&&ko.enqueueReplaceState(r,r.state,null),Nr(t,n,r,a),jr(),r.state=t.memoizedState),"function"==typeof r.componentDidMount&&(t.flags|=4194308),n=!0}else if(null===e){r=t.stateNode;var o=t.memoizedProps,s=jo(l,o);r.props=s;var c=r.context,u=l.contextType;i=Rn,"object"==typeof u&&null!==u&&(i=Ma(u));var d=l.getDerivedStateFromProps;u="function"==typeof d||"function"==typeof r.getSnapshotBeforeUpdate,o=t.pendingProps!==o,u||"function"!=typeof r.UNSAFE_componentWillReceiveProps&&"function"!=typeof r.componentWillReceiveProps||(o||c!==i)&&So(t,r,n,i),gr=!1;var b=t.memoizedState;r.state=b,Nr(t,n,r,a),jr(),c=t.memoizedState,o||b!==c||gr?("function"==typeof d&&(wo(t,l,d,n),c=t.memoizedState),(s=gr||Co(t,l,s,n,b,c,i))?(u||"function"!=typeof r.UNSAFE_componentWillMount&&"function"!=typeof r.componentWillMount||("function"==typeof r.componentWillMount&&r.componentWillMount(),"function"==typeof r.UNSAFE_componentWillMount&&r.UNSAFE_componentWillMount()),"function"==typeof r.componentDidMount&&(t.flags|=4194308)):("function"==typeof r.componentDidMount&&(t.flags|=4194308),t.memoizedProps=n,t.memoizedState=c),r.props=n,r.state=c,r.context=i,n=s):("function"==typeof r.componentDidMount&&(t.flags|=4194308),n=!1)}else{r=t.stateNode,yr(e,t),u=jo(l,i=t.memoizedProps),r.props=u,d=t.pendingProps,b=r.context,c=l.contextType,s=Rn,"object"==typeof c&&null!==c&&(s=Ma(c)),(c="function"==typeof(o=l.getDerivedStateFromProps)||"function"==typeof r.getSnapshotBeforeUpdate)||"function"!=typeof r.UNSAFE_componentWillReceiveProps&&"function"!=typeof r.componentWillReceiveProps||(i!==d||b!==s)&&So(t,r,n,s),gr=!1,b=t.memoizedState,r.state=b,Nr(t,n,r,a),jr();var m=t.memoizedState;i!==d||b!==m||gr||null!==e&&null!==e.dependencies&&za(e.dependencies)?("function"==typeof o&&(wo(t,l,o,n),m=t.memoizedState),(u=gr||Co(t,l,u,n,b,m,s)||null!==e&&null!==e.dependencies&&za(e.dependencies))?(c||"function"!=typeof r.UNSAFE_componentWillUpdate&&"function"!=typeof r.componentWillUpdate||("function"==typeof r.componentWillUpdate&&r.componentWillUpdate(n,m,s),"function"==typeof r.UNSAFE_componentWillUpdate&&r.UNSAFE_componentWillUpdate(n,m,s)),"function"==typeof r.componentDidUpdate&&(t.flags|=4),"function"==typeof r.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!=typeof r.componentDidUpdate||i===e.memoizedProps&&b===e.memoizedState||(t.flags|=4),"function"!=typeof r.getSnapshotBeforeUpdate||i===e.memoizedProps&&b===e.memoizedState||(t.flags|=1024),t.memoizedProps=n,t.memoizedState=m),r.props=n,r.state=m,r.context=s,n=u):("function"!=typeof r.componentDidUpdate||i===e.memoizedProps&&b===e.memoizedState||(t.flags|=4),"function"!=typeof r.getSnapshotBeforeUpdate||i===e.memoizedProps&&b===e.memoizedState||(t.flags|=1024),n=!1)}return r=n,Vo(e,t),n=!!(128&t.flags),r||n?(r=t.stateNode,l=n&&"function"!=typeof l.getDerivedStateFromError?null:r.render(),t.flags|=1,null!==e&&n?(t.child=pr(t,e.child,null,a),t.child=pr(t,null,l,a)):Po(e,t,l,a),t.memoizedState=r.state,e=t.child):e=is(e,t,a),e}function Qo(e,t,l,n){return wa(),t.flags|=256,Po(e,t,l,n),t.child}var Xo={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Yo(e){return{baseLanes:e,cachePool:Ja()}}function Jo(e,t,l){return e=null!==e?e.childLanes&~l:0,t&&(e|=$c),e}function Zo(e,t,l){var n,a=t.pendingProps,i=!1,o=!!(128&t.flags);if((n=o)||(n=(null===e||null!==e.memoizedState)&&!!(2&Ur.current)),n&&(i=!0,t.flags&=-129),n=!!(32&t.flags),t.flags&=-33,null===e){if(ma){if(i?Pr(t):Or(),(e=ba)?null!==(e=null!==(e=zd(e,pa))&&"&"!==e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==na?{id:aa,overflow:ra}:null,retryLane:536870912,hydrationErrors:null},(l=Kn(e)).return=t,t.child=l,da=t,ba=null):e=null,null===e)throw ga(t);return Md(e)?t.lanes=32:t.lanes=536870912,null}var s=a.children;return a=a.fallback,i?(Or(),s=ts({mode:"hidden",children:s},i=t.mode),a=Vn(a,i,l,null),s.return=t,a.return=t,s.sibling=a,t.child=s,(a=t.child).memoizedState=Yo(l),a.childLanes=Jo(e,n,l),t.memoizedState=Xo,Uo(null,a)):(Pr(t),es(t,s))}var c=e.memoizedState;if(null!==c&&null!==(s=c.dehydrated)){if(o)256&t.flags?(Pr(t),t.flags&=-257,t=ls(e,t,l)):null!==t.memoizedState?(Or(),t.child=e.child,t.flags|=128,t=null):(Or(),s=a.fallback,i=t.mode,a=ts({mode:"visible",children:a.children},i),(s=Vn(s,i,l,null)).flags|=2,a.return=t,s.return=t,a.sibling=s,t.child=a,pr(t,e.child,null,l),(a=t.child).memoizedState=Yo(l),a.childLanes=Jo(e,n,l),t.memoizedState=Xo,t=Uo(null,a));else if(Pr(t),Md(s)){if(n=s.nextSibling&&s.nextSibling.dataset)var u=n.dgst;n=u,(a=Error(r(419))).stack="",a.digest=n,Ca({value:a,source:null,stack:null}),t=ls(e,t,l)}else if(Io||Aa(e,t,l,!1),n=0!==(l&e.childLanes),Io||n){if(null!==(n=fc)&&(0!==(a=De(n,l))&&a!==c.retryLane))throw c.retryLane=a,In(e,a),Xc(n,e,a),Mo;Ld(s)||su(),t=ls(e,t,l)}else Ld(s)?(t.flags|=192,t.child=e.child,t=null):(e=c.treeContext,ba=Id(s.nextSibling),da=t,ma=!0,ha=null,pa=!1,null!==e&&ua(t,e),(t=es(t,a.children)).flags|=4096);return t}return i?(Or(),s=a.fallback,i=t.mode,u=(c=e.child).sibling,(a=Bn(c,{mode:"hidden",children:a.children})).subtreeFlags=65011712&c.subtreeFlags,null!==u?s=Bn(u,s):(s=Vn(s,i,l,null)).flags|=2,s.return=t,a.return=t,a.sibling=s,t.child=a,Uo(null,a),a=t.child,null===(s=e.child.memoizedState)?s=Yo(l):(null!==(i=s.cachePool)?(c=Fa._currentValue,i=i.parent!==c?{parent:c,pool:c}:i):i=Ja(),s={baseLanes:s.baseLanes|l,cachePool:i}),a.memoizedState=s,a.childLanes=Jo(e,n,l),t.memoizedState=Xo,Uo(e.child,a)):(Pr(t),e=(l=e.child).sibling,(l=Bn(l,{mode:"visible",children:a.children})).return=t,l.sibling=null,null!==e&&(null===(n=t.deletions)?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=l,t.memoizedState=null,l)}function es(e,t){return(t=ts({mode:"visible",children:t},e.mode)).return=e,e.child=t}function ts(e,t){return(e=Fn(22,e,null,t)).lanes=0,e}function ls(e,t,l){return pr(t,e.child,null,l),(e=es(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function ns(e,t,l){e.lanes|=t;var n=e.alternate;null!==n&&(n.lanes|=t),$a(e.return,t,l)}function as(e,t,l,n,a,r){var i=e.memoizedState;null===i?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:n,tail:l,tailMode:a,treeForkCount:r}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=n,i.tail=l,i.tailMode=a,i.treeForkCount=r)}function rs(e,t,l){var n=t.pendingProps,a=n.revealOrder,r=n.tail;n=n.children;var i=Ur.current,o=!!(2&i);if(o?(i=1&i|2,t.flags|=128):i&=1,q(Ur,i),Po(e,t,n,l),n=ma?ea:0,!o&&null!==e&&128&e.flags)e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&ns(e,l,t);else if(19===e.tag)ns(e,l,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(a){case"forwards":for(l=t.child,a=null;null!==l;)null!==(e=l.alternate)&&null===Br(e)&&(a=l),l=l.sibling;null===(l=a)?(a=t.child,t.child=null):(a=l.sibling,l.sibling=null),as(t,!1,a,l,r,n);break;case"backwards":case"unstable_legacy-backwards":for(l=null,a=t.child,t.child=null;null!==a;){if(null!==(e=a.alternate)&&null===Br(e)){t.child=a;break}e=a.sibling,a.sibling=l,l=a,a=e}as(t,!0,l,null,r,n);break;case"together":as(t,!1,null,null,void 0,n);break;default:t.memoizedState=null}return t.child}function is(e,t,l){if(null!==e&&(t.dependencies=e.dependencies),Nc|=t.lanes,0===(l&t.childLanes)){if(null===e)return null;if(Aa(e,t,l,!1),0===(l&t.childLanes))return null}if(null!==e&&t.child!==e.child)throw Error(r(153));if(null!==t.child){for(l=Bn(e=t.child,e.pendingProps),t.child=l,l.return=t;null!==e.sibling;)e=e.sibling,(l=l.sibling=Bn(e,e.pendingProps)).return=t;l.sibling=null}return t.child}function os(e,t){return 0!==(e.lanes&t)||!(null===(e=e.dependencies)||!za(e))}function ss(e,t,l){if(null!==e)if(e.memoizedProps!==t.pendingProps)Io=!0;else{if(!(os(e,l)||128&t.flags))return Io=!1,function(e,t,l){switch(t.tag){case 3:X(t,t.stateNode.containerInfo),Ea(0,Fa,e.memoizedState.cache),wa();break;case 27:case 5:J(t);break;case 4:X(t,t.stateNode.containerInfo);break;case 10:Ea(0,t.type,t.memoizedProps.value);break;case 31:if(null!==t.memoizedState)return t.flags|=128,Dr(t),null;break;case 13:var n=t.memoizedState;if(null!==n)return null!==n.dehydrated?(Pr(t),t.flags|=128,null):0!==(l&t.child.childLanes)?Zo(e,t,l):(Pr(t),null!==(e=is(e,t,l))?e.sibling:null);Pr(t);break;case 19:var a=!!(128&e.flags);if((n=0!==(l&t.childLanes))||(Aa(e,t,l,!1),n=0!==(l&t.childLanes)),a){if(n)return rs(e,t,l);t.flags|=128}if(null!==(a=t.memoizedState)&&(a.rendering=null,a.tail=null,a.lastEffect=null),q(Ur,Ur.current),n)break;return null;case 22:return t.lanes=0,Fo(e,t,l,t.pendingProps);case 24:Ea(0,Fa,e.memoizedState.cache)}return is(e,t,l)}(e,t,l);Io=!!(131072&e.flags)}else Io=!1,ma&&1048576&t.flags&&oa(t,ea,t.index);switch(t.lanes=0,t.tag){case 16:e:{var n=t.pendingProps;if(e=rr(t.elementType),t.type=e,"function"!=typeof e){if(null!=e){var a=e.$$typeof;if(a===C){t.tag=11,t=Do(null,t,e,n,l);break e}if(a===E){t.tag=14,t=Ro(null,t,e,n,l);break e}}throw t=M(e)||e,Error(r(306,t,""))}Un(e)?(n=jo(e,n),t.tag=1,t=Go(null,t,e,n,l)):(t.tag=0,t=Ho(null,t,e,n,l))}return t;case 0:return Ho(e,t,t.type,t.pendingProps,l);case 1:return Go(e,t,n=t.type,a=jo(n,t.pendingProps),l);case 3:e:{if(X(t,t.stateNode.containerInfo),null===e)throw Error(r(387));n=t.pendingProps;var i=t.memoizedState;a=i.element,yr(e,t),Nr(t,n,null,l);var o=t.memoizedState;if(n=o.cache,Ea(0,Fa,n),n!==i.cache&&Ta(t,[Fa],l,!0),jr(),n=o.element,i.isDehydrated){if(i={element:n,isDehydrated:!1,cache:o.cache},t.updateQueue.baseState=i,t.memoizedState=i,256&t.flags){t=Qo(e,t,n,l);break e}if(n!==a){Ca(a=Xn(Error(r(424)),t)),t=Qo(e,t,n,l);break e}if(9===(e=t.stateNode.containerInfo).nodeType)e=e.body;else e="HTML"===e.nodeName?e.ownerDocument.body:e;for(ba=Id(e.firstChild),da=t,ma=!0,ha=null,pa=!0,l=fr(t,null,n,l),t.child=l;l;)l.flags=-3&l.flags|4096,l=l.sibling}else{if(wa(),n===a){t=is(e,t,l);break e}Po(e,t,n,l)}t=t.child}return t;case 26:return Vo(e,t),null===e?(l=Kd(t.type,null,t.pendingProps,null))?t.memoizedState=l:ma||(l=t.type,e=t.pendingProps,(n=vd(G.current).createElement(l))[qe]=t,n[We]=e,hd(n,l,e),lt(n),t.stateNode=n):t.memoizedState=Kd(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return J(t),null===e&&ma&&(n=t.stateNode=Od(t.type,t.pendingProps,G.current),da=t,pa=!0,a=ba,_d(t.type)?(Pd=a,ba=Id(n.firstChild)):ba=a),Po(e,t,t.pendingProps.children,l),Vo(e,t),null===e&&(t.flags|=4194304),t.child;case 5:return null===e&&ma&&((a=n=ba)&&(null!==(n=function(e,t,l,n){for(;1===e.nodeType;){var a=l;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!n&&("INPUT"!==e.nodeName||"hidden"!==e.type))break}else if(n){if(!e[Xe])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if("stylesheet"===(r=e.getAttribute("rel"))&&e.hasAttribute("data-precedence"))break;if(r!==a.rel||e.getAttribute("href")!==(null==a.href||""===a.href?null:a.href)||e.getAttribute("crossorigin")!==(null==a.crossOrigin?null:a.crossOrigin)||e.getAttribute("title")!==(null==a.title?null:a.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(((r=e.getAttribute("src"))!==(null==a.src?null:a.src)||e.getAttribute("type")!==(null==a.type?null:a.type)||e.getAttribute("crossorigin")!==(null==a.crossOrigin?null:a.crossOrigin))&&r&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else{if("input"!==t||"hidden"!==e.type)return e;var r=null==a.name?null:""+a.name;if("hidden"===a.type&&e.getAttribute("name")===r)return e}if(null===(e=Id(e.nextSibling)))break}return null}(n,t.type,t.pendingProps,pa))?(t.stateNode=n,da=t,ba=Id(n.firstChild),pa=!1,a=!0):a=!1),a||ga(t)),J(t),a=t.type,i=t.pendingProps,o=null!==e?e.memoizedProps:null,n=i.children,wd(a,i)?n=null:null!==o&&wd(a,o)&&(t.flags|=32),null!==t.memoizedState&&(a=li(e,t,ri,null,null,l),bb._currentValue=a),Vo(e,t),Po(e,t,n,l),t.child;case 6:return null===e&&ma&&((e=l=ba)&&(null!==(l=function(e,t,l){if(""===t)return null;for(;3!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!l)return null;if(null===(e=Id(e.nextSibling)))return null}return e}(l,t.pendingProps,pa))?(t.stateNode=l,da=t,ba=null,e=!0):e=!1),e||ga(t)),null;case 13:return Zo(e,t,l);case 4:return X(t,t.stateNode.containerInfo),n=t.pendingProps,null===e?t.child=pr(t,null,n,l):Po(e,t,n,l),t.child;case 11:return Do(e,t,t.type,t.pendingProps,l);case 7:return Po(e,t,t.pendingProps,l),t.child;case 8:case 12:return Po(e,t,t.pendingProps.children,l),t.child;case 10:return n=t.pendingProps,Ea(0,t.type,n.value),Po(e,t,n.children,l),t.child;case 9:return a=t.type._context,n=t.pendingProps.children,La(t),n=n(a=Ma(a)),t.flags|=1,Po(e,t,n,l),t.child;case 14:return Ro(e,t,t.type,t.pendingProps,l);case 15:return Oo(e,t,t.type,t.pendingProps,l);case 19:return rs(e,t,l);case 31:return function(e,t,l){var n=t.pendingProps,a=!!(128&t.flags);if(t.flags&=-129,null===e){if(ma){if("hidden"===n.mode)return e=qo(t,n),t.lanes=536870912,Uo(null,e);if(Dr(t),(e=ba)?null!==(e=null!==(e=zd(e,pa))&&"&"===e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==na?{id:aa,overflow:ra}:null,retryLane:536870912,hydrationErrors:null},(l=Kn(e)).return=t,t.child=l,da=t,ba=null):e=null,null===e)throw ga(t);return t.lanes=536870912,null}return qo(t,n)}var i=e.memoizedState;if(null!==i){var o=i.dehydrated;if(Dr(t),a)if(256&t.flags)t.flags&=-257,t=Wo(e,t,l);else{if(null===t.memoizedState)throw Error(r(558));t.child=e.child,t.flags|=128,t=null}else if(Io||Aa(e,t,l,!1),a=0!==(l&e.childLanes),Io||a){if(null!==(n=fc)&&0!==(o=De(n,l))&&o!==i.retryLane)throw i.retryLane=o,In(e,o),Xc(n,e,o),Mo;su(),t=Wo(e,t,l)}else e=i.treeContext,ba=Id(o.nextSibling),da=t,ma=!0,ha=null,pa=!1,null!==e&&ua(t,e),(t=qo(t,n)).flags|=4096;return t}return(e=Bn(e.child,{mode:n.mode,children:n.children})).ref=t.ref,t.child=e,e.return=t,e}(e,t,l);case 22:return Fo(e,t,l,t.pendingProps);case 24:return La(t),n=Ma(Fa),null===e?(null===(a=Xa())&&(a=fc,i=Ua(),a.pooledCache=i,i.refCount++,null!==i&&(a.pooledCacheLanes|=l),a=i),t.memoizedState={parent:n,cache:a},vr(t),Ea(0,Fa,a)):(0!==(e.lanes&l)&&(yr(e,t),Nr(t,null,null,l),jr()),a=e.memoizedState,i=t.memoizedState,a.parent!==n?(a={parent:n,cache:n},t.memoizedState=a,0===t.lanes&&(t.memoizedState=t.updateQueue.baseState=a),Ea(0,Fa,n)):(n=i.cache,Ea(0,Fa,n),n!==a.cache&&Ta(t,[Fa],l,!0))),Po(e,t,t.pendingProps.children,l),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function cs(e){e.flags|=4}function us(e,t,l,n,a){if((t=!!(32&e.mode))&&(t=!1),t){if(e.flags|=16777216,(335544128&a)===a)if(e.stateNode.complete)e.flags|=8192;else{if(!ru())throw ir=lr,er;e.flags|=8192}}else e.flags&=-16777217}function ds(e,t){if("stylesheet"!==t.type||4&t.state.loading)e.flags&=-16777217;else if(e.flags|=16777216,!ib(t)){if(!ru())throw ir=lr,er;e.flags|=8192}}function bs(e,t){null!==t&&(e.flags|=4),16384&e.flags&&(t=22!==e.tag?ze():536870912,e.lanes|=t,Tc|=t)}function ms(e,t){if(!ma)switch(e.tailMode){case"hidden":t=e.tail;for(var l=null;null!==t;)null!==t.alternate&&(l=t),t=t.sibling;null===l?e.tail=null:l.sibling=null;break;case"collapsed":l=e.tail;for(var n=null;null!==l;)null!==l.alternate&&(n=l),l=l.sibling;null===n?t||null===e.tail?e.tail=null:e.tail.sibling=null:n.sibling=null}}function hs(e){var t=null!==e.alternate&&e.alternate.child===e.child,l=0,n=0;if(t)for(var a=e.child;null!==a;)l|=a.lanes|a.childLanes,n|=65011712&a.subtreeFlags,n|=65011712&a.flags,a.return=e,a=a.sibling;else for(a=e.child;null!==a;)l|=a.lanes|a.childLanes,n|=a.subtreeFlags,n|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=n,e.childLanes=l,t}function ps(e,t,l){var n=t.pendingProps;switch(ca(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 1:return hs(t),null;case 3:return l=t.stateNode,n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),_a(Fa),Y(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),null!==e&&null!==e.child||(xa(t)?cs(t):null===e||e.memoizedState.isDehydrated&&!(256&t.flags)||(t.flags|=1024,ka())),hs(t),null;case 26:var a=t.type,i=t.memoizedState;return null===e?(cs(t),null!==i?(hs(t),ds(t,i)):(hs(t),us(t,a,0,0,l))):i?i!==e.memoizedState?(cs(t),hs(t),ds(t,i)):(hs(t),t.flags&=-16777217):((e=e.memoizedProps)!==n&&cs(t),hs(t),us(t,a,0,0,l)),null;case 27:if(Z(t),l=G.current,a=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==n&&cs(t);else{if(!n){if(null===t.stateNode)throw Error(r(166));return hs(t),null}e=H.current,xa(t)?va(t):(e=Od(a,n,l),t.stateNode=e,cs(t))}return hs(t),null;case 5:if(Z(t),a=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==n&&cs(t);else{if(!n){if(null===t.stateNode)throw Error(r(166));return hs(t),null}if(i=H.current,xa(t))va(t);else{var o=vd(G.current);switch(i){case 1:i=o.createElementNS("http://www.w3.org/2000/svg",a);break;case 2:i=o.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;default:switch(a){case"svg":i=o.createElementNS("http://www.w3.org/2000/svg",a);break;case"math":i=o.createElementNS("http://www.w3.org/1998/Math/MathML",a);break;case"script":(i=o.createElement("div")).innerHTML="<script><\/script>",i=i.removeChild(i.firstChild);break;case"select":i="string"==typeof n.is?o.createElement("select",{is:n.is}):o.createElement("select"),n.multiple?i.multiple=!0:n.size&&(i.size=n.size);break;default:i="string"==typeof n.is?o.createElement(a,{is:n.is}):o.createElement(a)}}i[qe]=t,i[We]=n;e:for(o=t.child;null!==o;){if(5===o.tag||6===o.tag)i.appendChild(o.stateNode);else if(4!==o.tag&&27!==o.tag&&null!==o.child){o.child.return=o,o=o.child;continue}if(o===t)break e;for(;null===o.sibling;){if(null===o.return||o.return===t)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}t.stateNode=i;e:switch(hd(i,a,n),a){case"button":case"input":case"select":case"textarea":n=!!n.autoFocus;break e;case"img":n=!0;break e;default:n=!1}n&&cs(t)}}return hs(t),us(t,t.type,null===e||e.memoizedProps,t.pendingProps,l),null;case 6:if(e&&null!=t.stateNode)e.memoizedProps!==n&&cs(t);else{if("string"!=typeof n&&null===t.stateNode)throw Error(r(166));if(e=G.current,xa(t)){if(e=t.stateNode,l=t.memoizedProps,n=null,null!==(a=da))switch(a.tag){case 27:case 5:n=a.memoizedProps}e[qe]=t,(e=!!(e.nodeValue===l||null!==n&&!0===n.suppressHydrationWarning||dd(e.nodeValue,l)))||ga(t,!0)}else(e=vd(e).createTextNode(n))[qe]=t,t.stateNode=e}return hs(t),null;case 31:if(l=t.memoizedState,null===e||null!==e.memoizedState){if(n=xa(t),null!==l){if(null===e){if(!n)throw Error(r(318));if(!(e=null!==(e=t.memoizedState)?e.dehydrated:null))throw Error(r(557));e[qe]=t}else wa(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;hs(t),e=!1}else l=ka(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return 256&t.flags?(Fr(t),t):(Fr(t),null);if(128&t.flags)throw Error(r(558))}return hs(t),null;case 13:if(n=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(a=xa(t),null!==n&&null!==n.dehydrated){if(null===e){if(!a)throw Error(r(318));if(!(a=null!==(a=t.memoizedState)?a.dehydrated:null))throw Error(r(317));a[qe]=t}else wa(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;hs(t),a=!1}else a=ka(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return 256&t.flags?(Fr(t),t):(Fr(t),null)}return Fr(t),128&t.flags?(t.lanes=l,t):(l=null!==n,e=null!==e&&null!==e.memoizedState,l&&(a=null,null!==(n=t.child).alternate&&null!==n.alternate.memoizedState&&null!==n.alternate.memoizedState.cachePool&&(a=n.alternate.memoizedState.cachePool.pool),i=null,null!==n.memoizedState&&null!==n.memoizedState.cachePool&&(i=n.memoizedState.cachePool.pool),i!==a&&(n.flags|=2048)),l!==e&&l&&(t.child.flags|=8192),bs(t,t.updateQueue),hs(t),null);case 4:return Y(),null===e&&td(t.stateNode.containerInfo),hs(t),null;case 10:return _a(t.type),hs(t),null;case 19:if(B(Ur),null===(n=t.memoizedState))return hs(t),null;if(a=!!(128&t.flags),null===(i=n.rendering))if(a)ms(n,!1);else{if(0!==jc||null!==e&&128&e.flags)for(e=t.child;null!==e;){if(null!==(i=Br(e))){for(t.flags|=128,ms(n,!1),e=i.updateQueue,t.updateQueue=e,bs(t,e),t.subtreeFlags=0,e=l,l=t.child;null!==l;)qn(l,e),l=l.sibling;return q(Ur,1&Ur.current|2),ma&&ia(t,n.treeForkCount),t.child}e=e.sibling}null!==n.tail&&ue()>Pc&&(t.flags|=128,a=!0,ms(n,!1),t.lanes=4194304)}else{if(!a)if(null!==(e=Br(i))){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,bs(t,e),ms(n,!0),null===n.tail&&"hidden"===n.tailMode&&!i.alternate&&!ma)return hs(t),null}else 2*ue()-n.renderingStartTime>Pc&&536870912!==l&&(t.flags|=128,a=!0,ms(n,!1),t.lanes=4194304);n.isBackwards?(i.sibling=t.child,t.child=i):(null!==(e=n.last)?e.sibling=i:t.child=i,n.last=i)}return null!==n.tail?(e=n.tail,n.rendering=e,n.tail=e.sibling,n.renderingStartTime=ue(),e.sibling=null,l=Ur.current,q(Ur,a?1&l|2:1&l),ma&&ia(t,n.treeForkCount),e):(hs(t),null);case 22:case 23:return Fr(t),Lr(),n=null!==t.memoizedState,null!==e?null!==e.memoizedState!==n&&(t.flags|=8192):n&&(t.flags|=8192),n?!!(536870912&l)&&!(128&t.flags)&&(hs(t),6&t.subtreeFlags&&(t.flags|=8192)):hs(t),null!==(l=t.updateQueue)&&bs(t,l.retryQueue),l=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(l=e.memoizedState.cachePool.pool),n=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(n=t.memoizedState.cachePool.pool),n!==l&&(t.flags|=2048),null!==e&&B(Qa),null;case 24:return l=null,null!==e&&(l=e.memoizedState.cache),t.memoizedState.cache!==l&&(t.flags|=2048),_a(Fa),hs(t),null;case 25:case 30:return null}throw Error(r(156,t.tag))}function fs(e,t){switch(ca(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return _a(Fa),Y(),65536&(e=t.flags)&&!(128&e)?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return Z(t),null;case 31:if(null!==t.memoizedState){if(Fr(t),null===t.alternate)throw Error(r(340));wa()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 13:if(Fr(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(r(340));wa()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return B(Ur),null;case 4:return Y(),null;case 10:return _a(t.type),null;case 22:case 23:return Fr(t),Lr(),null!==e&&B(Qa),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return _a(Fa),null;default:return null}}function gs(e,t){switch(ca(t),t.tag){case 3:_a(Fa),Y();break;case 26:case 27:case 5:Z(t);break;case 4:Y();break;case 31:null!==t.memoizedState&&Fr(t);break;case 13:Fr(t);break;case 19:B(Ur);break;case 10:_a(t.type);break;case 22:case 23:Fr(t),Lr(),null!==e&&B(Qa);break;case 24:_a(Fa)}}function vs(e,t){try{var l=t.updateQueue,n=null!==l?l.lastEffect:null;if(null!==n){var a=n.next;l=a;do{if((l.tag&e)===e){n=void 0;var r=l.create,i=l.inst;n=r(),i.destroy=n}l=l.next}while(l!==a)}}catch(o){ju(t,t.return,o)}}function ys(e,t,l){try{var n=t.updateQueue,a=null!==n?n.lastEffect:null;if(null!==a){var r=a.next;n=r;do{if((n.tag&e)===e){var i=n.inst,o=i.destroy;if(void 0!==o){i.destroy=void 0,a=t;var s=l,c=o;try{c()}catch(u){ju(a,s,u)}}}n=n.next}while(n!==r)}}catch(u){ju(t,t.return,u)}}function xs(e){var t=e.updateQueue;if(null!==t){var l=e.stateNode;try{_r(t,l)}catch(n){ju(e,e.return,n)}}}function ws(e,t,l){l.props=jo(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(n){ju(e,t,n)}}function ks(e,t){try{var l=e.ref;if(null!==l){switch(e.tag){case 26:case 27:case 5:var n=e.stateNode;break;default:n=e.stateNode}"function"==typeof l?e.refCleanup=l(n):l.current=n}}catch(a){ju(e,t,a)}}function Cs(e,t){var l=e.ref,n=e.refCleanup;if(null!==l)if("function"==typeof n)try{n()}catch(a){ju(e,t,a)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof l)try{l(null)}catch(r){ju(e,t,r)}else l.current=null}function Ss(e){var t=e.type,l=e.memoizedProps,n=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":l.autoFocus&&n.focus();break e;case"img":l.src?n.src=l.src:l.srcSet&&(n.srcset=l.srcSet)}}catch(a){ju(e,e.return,a)}}function js(e,t,l){try{var n=e.stateNode;!function(e,t,l,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var a=null,i=null,o=null,s=null,c=null,u=null,d=null;for(h in l){var b=l[h];if(l.hasOwnProperty(h)&&null!=b)switch(h){case"checked":case"value":break;case"defaultValue":c=b;default:n.hasOwnProperty(h)||bd(e,t,h,null,n,b)}}for(var m in n){var h=n[m];if(b=l[m],n.hasOwnProperty(m)&&(null!=h||null!=b))switch(m){case"type":i=h;break;case"name":a=h;break;case"checked":u=h;break;case"defaultChecked":d=h;break;case"value":o=h;break;case"defaultValue":s=h;break;case"children":case"dangerouslySetInnerHTML":if(null!=h)throw Error(r(137,t));break;default:h!==b&&bd(e,t,m,h,n,b)}}return void xt(e,o,s,c,u,d,i,a);case"select":for(i in h=o=s=m=null,l)if(c=l[i],l.hasOwnProperty(i)&&null!=c)switch(i){case"value":break;case"multiple":h=c;default:n.hasOwnProperty(i)||bd(e,t,i,null,n,c)}for(a in n)if(i=n[a],c=l[a],n.hasOwnProperty(a)&&(null!=i||null!=c))switch(a){case"value":m=i;break;case"defaultValue":s=i;break;case"multiple":o=i;default:i!==c&&bd(e,t,a,i,n,c)}return t=s,l=o,n=h,void(null!=m?Ct(e,!!l,m,!1):!!n!=!!l&&(null!=t?Ct(e,!!l,t,!0):Ct(e,!!l,l?[]:"",!1)));case"textarea":for(s in h=m=null,l)if(a=l[s],l.hasOwnProperty(s)&&null!=a&&!n.hasOwnProperty(s))switch(s){case"value":case"children":break;default:bd(e,t,s,null,n,a)}for(o in n)if(a=n[o],i=l[o],n.hasOwnProperty(o)&&(null!=a||null!=i))switch(o){case"value":m=a;break;case"defaultValue":h=a;break;case"children":break;case"dangerouslySetInnerHTML":if(null!=a)throw Error(r(91));break;default:a!==i&&bd(e,t,o,a,n,i)}return void St(e,m,h);case"option":for(var p in l)if(m=l[p],l.hasOwnProperty(p)&&null!=m&&!n.hasOwnProperty(p))if("selected"===p)e.selected=!1;else bd(e,t,p,null,n,m);for(c in n)if(m=n[c],h=l[c],n.hasOwnProperty(c)&&m!==h&&(null!=m||null!=h))if("selected"===c)e.selected=m&&"function"!=typeof m&&"symbol"!=typeof m;else bd(e,t,c,m,n,h);return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var f in l)m=l[f],l.hasOwnProperty(f)&&null!=m&&!n.hasOwnProperty(f)&&bd(e,t,f,null,n,m);for(u in n)if(m=n[u],h=l[u],n.hasOwnProperty(u)&&m!==h&&(null!=m||null!=h))switch(u){case"children":case"dangerouslySetInnerHTML":if(null!=m)throw Error(r(137,t));break;default:bd(e,t,u,m,n,h)}return;default:if(Tt(t)){for(var g in l)m=l[g],l.hasOwnProperty(g)&&void 0!==m&&!n.hasOwnProperty(g)&&md(e,t,g,void 0,n,m);for(d in n)m=n[d],h=l[d],!n.hasOwnProperty(d)||m===h||void 0===m&&void 0===h||md(e,t,d,m,n,h);return}}for(var v in l)m=l[v],l.hasOwnProperty(v)&&null!=m&&!n.hasOwnProperty(v)&&bd(e,t,v,null,n,m);for(b in n)m=n[b],h=l[b],!n.hasOwnProperty(b)||m===h||null==m&&null==h||bd(e,t,b,m,n,h)}(n,e.type,l,t),n[We]=t}catch(a){ju(e,e.return,a)}}function Ns(e){return 5===e.tag||3===e.tag||26===e.tag||27===e.tag&&_d(e.type)||4===e.tag}function Es(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||Ns(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(27===e.tag&&_d(e.type))continue e;if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function _s(e,t,l){var n=e.tag;if(5===n||6===n)e=e.stateNode,t?(9===l.nodeType?l.body:"HTML"===l.nodeName?l.ownerDocument.body:l).insertBefore(e,t):((t=9===l.nodeType?l.body:"HTML"===l.nodeName?l.ownerDocument.body:l).appendChild(e),null!=(l=l._reactRootContainer)||null!==t.onclick||(t.onclick=Mt));else if(4!==n&&(27===n&&_d(e.type)&&(l=e.stateNode,t=null),null!==(e=e.child)))for(_s(e,t,l),e=e.sibling;null!==e;)_s(e,t,l),e=e.sibling}function $s(e,t,l){var n=e.tag;if(5===n||6===n)e=e.stateNode,t?l.insertBefore(e,t):l.appendChild(e);else if(4!==n&&(27===n&&_d(e.type)&&(l=e.stateNode),null!==(e=e.child)))for($s(e,t,l),e=e.sibling;null!==e;)$s(e,t,l),e=e.sibling}function Ts(e){var t=e.stateNode,l=e.memoizedProps;try{for(var n=e.type,a=t.attributes;a.length;)t.removeAttributeNode(a[0]);hd(t,n,l),t[qe]=e,t[We]=l}catch(r){ju(e,e.return,r)}}var As=!1,zs=!1,Ls=!1,Ms="function"==typeof WeakSet?WeakSet:Set,Is=null;function Ps(e,t,l){var n=l.flags;switch(l.tag){case 0:case 11:case 15:Xs(e,l),4&n&&vs(5,l);break;case 1:if(Xs(e,l),4&n)if(e=l.stateNode,null===t)try{e.componentDidMount()}catch(i){ju(l,l.return,i)}else{var a=jo(l.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(a,t,e.__reactInternalSnapshotBeforeUpdate)}catch(o){ju(l,l.return,o)}}64&n&&xs(l),512&n&&ks(l,l.return);break;case 3:if(Xs(e,l),64&n&&null!==(e=l.updateQueue)){if(t=null,null!==l.child)switch(l.child.tag){case 27:case 5:case 1:t=l.child.stateNode}try{_r(e,t)}catch(i){ju(l,l.return,i)}}break;case 27:null===t&&4&n&&Ts(l);case 26:case 5:Xs(e,l),null===t&&4&n&&Ss(l),512&n&&ks(l,l.return);break;case 12:Xs(e,l);break;case 31:Xs(e,l),4&n&&Bs(e,l);break;case 13:Xs(e,l),4&n&&qs(e,l),64&n&&(null!==(e=l.memoizedState)&&(null!==(e=e.dehydrated)&&function(e,t){var l=e.ownerDocument;if("$~"===e.data)e._reactRetry=t;else if("$?"!==e.data||"loading"!==l.readyState)t();else{var n=function(){t(),l.removeEventListener("DOMContentLoaded",n)};l.addEventListener("DOMContentLoaded",n),e._reactRetry=n}}(e,l=$u.bind(null,l))));break;case 22:if(!(n=null!==l.memoizedState||As)){t=null!==t&&null!==t.memoizedState||zs,a=As;var r=zs;As=n,(zs=t)&&!r?Js(e,l,!!(8772&l.subtreeFlags)):Xs(e,l),As=a,zs=r}break;case 30:break;default:Xs(e,l)}}function Ds(e){var t=e.alternate;null!==t&&(e.alternate=null,Ds(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&Ye(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Rs=null,Os=!1;function Fs(e,t,l){for(l=l.child;null!==l;)Us(e,t,l),l=l.sibling}function Us(e,t,l){if(xe&&"function"==typeof xe.onCommitFiberUnmount)try{xe.onCommitFiberUnmount(ye,l)}catch(r){}switch(l.tag){case 26:zs||Cs(l,t),Fs(e,t,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode).parentNode.removeChild(l);break;case 27:zs||Cs(l,t);var n=Rs,a=Os;_d(l.type)&&(Rs=l.stateNode,Os=!1),Fs(e,t,l),Fd(l.stateNode),Rs=n,Os=a;break;case 5:zs||Cs(l,t);case 6:if(n=Rs,a=Os,Rs=null,Fs(e,t,l),Os=a,null!==(Rs=n))if(Os)try{(9===Rs.nodeType?Rs.body:"HTML"===Rs.nodeName?Rs.ownerDocument.body:Rs).removeChild(l.stateNode)}catch(i){ju(l,t,i)}else try{Rs.removeChild(l.stateNode)}catch(i){ju(l,t,i)}break;case 18:null!==Rs&&(Os?($d(9===(e=Rs).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,l.stateNode),Hb(e)):$d(Rs,l.stateNode));break;case 4:n=Rs,a=Os,Rs=l.stateNode.containerInfo,Os=!0,Fs(e,t,l),Rs=n,Os=a;break;case 0:case 11:case 14:case 15:ys(2,l,t),zs||ys(4,l,t),Fs(e,t,l);break;case 1:zs||(Cs(l,t),"function"==typeof(n=l.stateNode).componentWillUnmount&&ws(l,t,n)),Fs(e,t,l);break;case 21:Fs(e,t,l);break;case 22:zs=(n=zs)||null!==l.memoizedState,Fs(e,t,l),zs=n;break;default:Fs(e,t,l)}}function Bs(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&null!==(e=e.memoizedState))){e=e.dehydrated;try{Hb(e)}catch(l){ju(t,t.return,l)}}}function qs(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&(null!==(e=e.memoizedState)&&null!==(e=e.dehydrated))))try{Hb(e)}catch(l){ju(t,t.return,l)}}function Ws(e,t){var l=function(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return null===t&&(t=e.stateNode=new Ms),t;case 22:return null===(t=(e=e.stateNode)._retryCache)&&(t=e._retryCache=new Ms),t;default:throw Error(r(435,e.tag))}}(e);t.forEach(function(t){if(!l.has(t)){l.add(t);var n=Tu.bind(null,e,t);t.then(n,n)}})}function Vs(e,t){var l=t.deletions;if(null!==l)for(var n=0;n<l.length;n++){var a=l[n],i=e,o=t,s=o;e:for(;null!==s;){switch(s.tag){case 27:if(_d(s.type)){Rs=s.stateNode,Os=!1;break e}break;case 5:Rs=s.stateNode,Os=!1;break e;case 3:case 4:Rs=s.stateNode.containerInfo,Os=!0;break e}s=s.return}if(null===Rs)throw Error(r(160));Us(i,o,a),Rs=null,Os=!1,null!==(i=a.alternate)&&(i.return=null),a.return=null}if(13886&t.subtreeFlags)for(t=t.child;null!==t;)Ks(t,e),t=t.sibling}var Hs=null;function Ks(e,t){var l=e.alternate,n=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Vs(t,e),Gs(e),4&n&&(ys(3,e,e.return),vs(3,e),ys(5,e,e.return));break;case 1:Vs(t,e),Gs(e),512&n&&(zs||null===l||Cs(l,l.return)),64&n&&As&&(null!==(e=e.updateQueue)&&(null!==(n=e.callbacks)&&(l=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=null===l?n:l.concat(n))));break;case 26:var a=Hs;if(Vs(t,e),Gs(e),512&n&&(zs||null===l||Cs(l,l.return)),4&n){var i=null!==l?l.memoizedState:null;if(n=e.memoizedState,null===l)if(null===n)if(null===e.stateNode){e:{n=e.type,l=e.memoizedProps,a=a.ownerDocument||a;t:switch(n){case"title":(!(i=a.getElementsByTagName("title")[0])||i[Xe]||i[qe]||"http://www.w3.org/2000/svg"===i.namespaceURI||i.hasAttribute("itemprop"))&&(i=a.createElement(n),a.head.insertBefore(i,a.querySelector("head > title"))),hd(i,n,l),i[qe]=e,lt(i),n=i;break e;case"link":var o=ab("link","href",a).get(n+(l.href||""));if(o)for(var s=0;s<o.length;s++)if((i=o[s]).getAttribute("href")===(null==l.href||""===l.href?null:l.href)&&i.getAttribute("rel")===(null==l.rel?null:l.rel)&&i.getAttribute("title")===(null==l.title?null:l.title)&&i.getAttribute("crossorigin")===(null==l.crossOrigin?null:l.crossOrigin)){o.splice(s,1);break t}hd(i=a.createElement(n),n,l),a.head.appendChild(i);break;case"meta":if(o=ab("meta","content",a).get(n+(l.content||"")))for(s=0;s<o.length;s++)if((i=o[s]).getAttribute("content")===(null==l.content?null:""+l.content)&&i.getAttribute("name")===(null==l.name?null:l.name)&&i.getAttribute("property")===(null==l.property?null:l.property)&&i.getAttribute("http-equiv")===(null==l.httpEquiv?null:l.httpEquiv)&&i.getAttribute("charset")===(null==l.charSet?null:l.charSet)){o.splice(s,1);break t}hd(i=a.createElement(n),n,l),a.head.appendChild(i);break;default:throw Error(r(468,n))}i[qe]=e,lt(i),n=i}e.stateNode=n}else rb(a,e.type,e.stateNode);else e.stateNode=Zd(a,n,e.memoizedProps);else i!==n?(null===i?null!==l.stateNode&&(l=l.stateNode).parentNode.removeChild(l):i.count--,null===n?rb(a,e.type,e.stateNode):Zd(a,n,e.memoizedProps)):null===n&&null!==e.stateNode&&js(e,e.memoizedProps,l.memoizedProps)}break;case 27:Vs(t,e),Gs(e),512&n&&(zs||null===l||Cs(l,l.return)),null!==l&&4&n&&js(e,e.memoizedProps,l.memoizedProps);break;case 5:if(Vs(t,e),Gs(e),512&n&&(zs||null===l||Cs(l,l.return)),32&e.flags){a=e.stateNode;try{Nt(a,"")}catch(p){ju(e,e.return,p)}}4&n&&null!=e.stateNode&&js(e,a=e.memoizedProps,null!==l?l.memoizedProps:a),1024&n&&(Ls=!0);break;case 6:if(Vs(t,e),Gs(e),4&n){if(null===e.stateNode)throw Error(r(162));n=e.memoizedProps,l=e.stateNode;try{l.nodeValue=n}catch(p){ju(e,e.return,p)}}break;case 3:if(nb=null,a=Hs,Hs=qd(t.containerInfo),Vs(t,e),Hs=a,Gs(e),4&n&&null!==l&&l.memoizedState.isDehydrated)try{Hb(t.containerInfo)}catch(p){ju(e,e.return,p)}Ls&&(Ls=!1,Qs(e));break;case 4:n=Hs,Hs=qd(e.stateNode.containerInfo),Vs(t,e),Gs(e),Hs=n;break;case 12:default:Vs(t,e),Gs(e);break;case 31:case 19:Vs(t,e),Gs(e),4&n&&(null!==(n=e.updateQueue)&&(e.updateQueue=null,Ws(e,n)));break;case 13:Vs(t,e),Gs(e),8192&e.child.flags&&null!==e.memoizedState!=(null!==l&&null!==l.memoizedState)&&(Mc=ue()),4&n&&(null!==(n=e.updateQueue)&&(e.updateQueue=null,Ws(e,n)));break;case 22:a=null!==e.memoizedState;var c=null!==l&&null!==l.memoizedState,u=As,d=zs;if(As=u||a,zs=d||c,Vs(t,e),zs=d,As=u,Gs(e),8192&n)e:for(t=e.stateNode,t._visibility=a?-2&t._visibility:1|t._visibility,a&&(null===l||c||As||zs||Ys(e)),l=null,t=e;;){if(5===t.tag||26===t.tag){if(null===l){c=l=t;try{if(i=c.stateNode,a)"function"==typeof(o=i.style).setProperty?o.setProperty("display","none","important"):o.display="none";else{s=c.stateNode;var b=c.memoizedProps.style,m=null!=b&&b.hasOwnProperty("display")?b.display:null;s.style.display=null==m||"boolean"==typeof m?"":(""+m).trim()}}catch(p){ju(c,c.return,p)}}}else if(6===t.tag){if(null===l){c=t;try{c.stateNode.nodeValue=a?"":c.memoizedProps}catch(p){ju(c,c.return,p)}}}else if(18===t.tag){if(null===l){c=t;try{var h=c.stateNode;a?Td(h,!0):Td(c.stateNode,!1)}catch(p){ju(c,c.return,p)}}}else if((22!==t.tag&&23!==t.tag||null===t.memoizedState||t===e)&&null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;null===t.sibling;){if(null===t.return||t.return===e)break e;l===t&&(l=null),t=t.return}l===t&&(l=null),t.sibling.return=t.return,t=t.sibling}4&n&&(null!==(n=e.updateQueue)&&(null!==(l=n.retryQueue)&&(n.retryQueue=null,Ws(e,l))));case 30:case 21:}}function Gs(e){var t=e.flags;if(2&t){try{for(var l,n=e.return;null!==n;){if(Ns(n)){l=n;break}n=n.return}if(null==l)throw Error(r(160));switch(l.tag){case 27:var a=l.stateNode;$s(e,Es(e),a);break;case 5:var i=l.stateNode;32&l.flags&&(Nt(i,""),l.flags&=-33),$s(e,Es(e),i);break;case 3:case 4:var o=l.stateNode.containerInfo;_s(e,Es(e),o);break;default:throw Error(r(161))}}catch(s){ju(e,e.return,s)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function Qs(e){if(1024&e.subtreeFlags)for(e=e.child;null!==e;){var t=e;Qs(t),5===t.tag&&1024&t.flags&&t.stateNode.reset(),e=e.sibling}}function Xs(e,t){if(8772&t.subtreeFlags)for(t=t.child;null!==t;)Ps(e,t.alternate,t),t=t.sibling}function Ys(e){for(e=e.child;null!==e;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:ys(4,t,t.return),Ys(t);break;case 1:Cs(t,t.return);var l=t.stateNode;"function"==typeof l.componentWillUnmount&&ws(t,t.return,l),Ys(t);break;case 27:Fd(t.stateNode);case 26:case 5:Cs(t,t.return),Ys(t);break;case 22:null===t.memoizedState&&Ys(t);break;default:Ys(t)}e=e.sibling}}function Js(e,t,l){for(l=l&&!!(8772&t.subtreeFlags),t=t.child;null!==t;){var n=t.alternate,a=e,r=t,i=r.flags;switch(r.tag){case 0:case 11:case 15:Js(a,r,l),vs(4,r);break;case 1:if(Js(a,r,l),"function"==typeof(a=(n=r).stateNode).componentDidMount)try{a.componentDidMount()}catch(c){ju(n,n.return,c)}if(null!==(a=(n=r).updateQueue)){var o=n.stateNode;try{var s=a.shared.hiddenCallbacks;if(null!==s)for(a.shared.hiddenCallbacks=null,a=0;a<s.length;a++)Er(s[a],o)}catch(c){ju(n,n.return,c)}}l&&64&i&&xs(r),ks(r,r.return);break;case 27:Ts(r);case 26:case 5:Js(a,r,l),l&&null===n&&4&i&&Ss(r),ks(r,r.return);break;case 12:Js(a,r,l);break;case 31:Js(a,r,l),l&&4&i&&Bs(a,r);break;case 13:Js(a,r,l),l&&4&i&&qs(a,r);break;case 22:null===r.memoizedState&&Js(a,r,l),ks(r,r.return);break;case 30:break;default:Js(a,r,l)}t=t.sibling}}function Zs(e,t){var l=null;null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(l=e.memoizedState.cachePool.pool),e=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(e=t.memoizedState.cachePool.pool),e!==l&&(null!=e&&e.refCount++,null!=l&&Ba(l))}function ec(e,t){e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Ba(e))}function tc(e,t,l,n){if(10256&t.subtreeFlags)for(t=t.child;null!==t;)lc(e,t,l,n),t=t.sibling}function lc(e,t,l,n){var a=t.flags;switch(t.tag){case 0:case 11:case 15:tc(e,t,l,n),2048&a&&vs(9,t);break;case 1:case 31:case 13:default:tc(e,t,l,n);break;case 3:tc(e,t,l,n),2048&a&&(e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Ba(e)));break;case 12:if(2048&a){tc(e,t,l,n),e=t.stateNode;try{var r=t.memoizedProps,i=r.id,o=r.onPostCommit;"function"==typeof o&&o(i,null===t.alternate?"mount":"update",e.passiveEffectDuration,-0)}catch(s){ju(t,t.return,s)}}else tc(e,t,l,n);break;case 23:break;case 22:r=t.stateNode,i=t.alternate,null!==t.memoizedState?2&r._visibility?tc(e,t,l,n):ac(e,t):2&r._visibility?tc(e,t,l,n):(r._visibility|=2,nc(e,t,l,n,!!(10256&t.subtreeFlags)||!1)),2048&a&&Zs(i,t);break;case 24:tc(e,t,l,n),2048&a&&ec(t.alternate,t)}}function nc(e,t,l,n,a){for(a=a&&(!!(10256&t.subtreeFlags)||!1),t=t.child;null!==t;){var r=e,i=t,o=l,s=n,c=i.flags;switch(i.tag){case 0:case 11:case 15:nc(r,i,o,s,a),vs(8,i);break;case 23:break;case 22:var u=i.stateNode;null!==i.memoizedState?2&u._visibility?nc(r,i,o,s,a):ac(r,i):(u._visibility|=2,nc(r,i,o,s,a)),a&&2048&c&&Zs(i.alternate,i);break;case 24:nc(r,i,o,s,a),a&&2048&c&&ec(i.alternate,i);break;default:nc(r,i,o,s,a)}t=t.sibling}}function ac(e,t){if(10256&t.subtreeFlags)for(t=t.child;null!==t;){var l=e,n=t,a=n.flags;switch(n.tag){case 22:ac(l,n),2048&a&&Zs(n.alternate,n);break;case 24:ac(l,n),2048&a&&ec(n.alternate,n);break;default:ac(l,n)}t=t.sibling}}var rc=8192;function ic(e,t,l){if(e.subtreeFlags&rc)for(e=e.child;null!==e;)oc(e,t,l),e=e.sibling}function oc(e,t,l){switch(e.tag){case 26:ic(e,t,l),e.flags&rc&&null!==e.memoizedState&&function(e,t,l,n){if(!("stylesheet"!==l.type||"string"==typeof n.media&&!1===matchMedia(n.media).matches||4&l.state.loading)){if(null===l.instance){var a=Gd(n.href),r=t.querySelector(Qd(a));if(r)return null!==(t=r._p)&&"object"==typeof t&&"function"==typeof t.then&&(e.count++,e=sb.bind(e),t.then(e,e)),l.state.loading|=4,l.instance=r,void lt(r);r=t.ownerDocument||t,n=Xd(n),(a=Ud.get(a))&&tb(n,a),lt(r=r.createElement("link"));var i=r;i._p=new Promise(function(e,t){i.onload=e,i.onerror=t}),hd(r,"link",n),l.instance=r}null===e.stylesheets&&(e.stylesheets=new Map),e.stylesheets.set(l,t),(t=l.state.preload)&&!(3&l.state.loading)&&(e.count++,l=sb.bind(e),t.addEventListener("load",l),t.addEventListener("error",l))}}(l,Hs,e.memoizedState,e.memoizedProps);break;case 5:default:ic(e,t,l);break;case 3:case 4:var n=Hs;Hs=qd(e.stateNode.containerInfo),ic(e,t,l),Hs=n;break;case 22:null===e.memoizedState&&(null!==(n=e.alternate)&&null!==n.memoizedState?(n=rc,rc=16777216,ic(e,t,l),rc=n):ic(e,t,l))}}function sc(e){var t=e.alternate;if(null!==t&&null!==(e=t.child)){t.child=null;do{t=e.sibling,e.sibling=null,e=t}while(null!==e)}}function cc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var l=0;l<t.length;l++){var n=t[l];Is=n,bc(n,e)}sc(e)}if(10256&e.subtreeFlags)for(e=e.child;null!==e;)uc(e),e=e.sibling}function uc(e){switch(e.tag){case 0:case 11:case 15:cc(e),2048&e.flags&&ys(9,e,e.return);break;case 3:case 12:default:cc(e);break;case 22:var t=e.stateNode;null!==e.memoizedState&&2&t._visibility&&(null===e.return||13!==e.return.tag)?(t._visibility&=-3,dc(e)):cc(e)}}function dc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var l=0;l<t.length;l++){var n=t[l];Is=n,bc(n,e)}sc(e)}for(e=e.child;null!==e;){switch((t=e).tag){case 0:case 11:case 15:ys(8,t,t.return),dc(t);break;case 22:2&(l=t.stateNode)._visibility&&(l._visibility&=-3,dc(t));break;default:dc(t)}e=e.sibling}}function bc(e,t){for(;null!==Is;){var l=Is;switch(l.tag){case 0:case 11:case 15:ys(8,l,t);break;case 23:case 22:if(null!==l.memoizedState&&null!==l.memoizedState.cachePool){var n=l.memoizedState.cachePool.pool;null!=n&&n.refCount++}break;case 24:Ba(l.memoizedState.cache)}if(null!==(n=l.child))n.return=l,Is=n;else e:for(l=e;null!==Is;){var a=(n=Is).sibling,r=n.return;if(Ds(n),n===l){Is=null;break e}if(null!==a){a.return=r,Is=a;break e}Is=r}}}var mc={getCacheForType:function(e){var t=Ma(Fa),l=t.data.get(e);return void 0===l&&(l=e(),t.data.set(e,l)),l},cacheSignal:function(){return Ma(Fa).controller.signal}},hc="function"==typeof WeakMap?WeakMap:Map,pc=0,fc=null,gc=null,vc=0,yc=0,xc=null,wc=!1,kc=!1,Cc=!1,Sc=0,jc=0,Nc=0,Ec=0,_c=0,$c=0,Tc=0,Ac=null,zc=null,Lc=!1,Mc=0,Ic=0,Pc=1/0,Dc=null,Rc=null,Oc=0,Fc=null,Uc=null,Bc=0,qc=0,Wc=null,Vc=null,Hc=0,Kc=null;function Gc(){return 2&pc&&0!==vc?vc&-vc:null!==P.T?Wu():Fe()}function Qc(){if(0===$c)if(536870912&vc&&!ma)$c=536870912;else{var e=Ne;!(3932160&(Ne<<=1))&&(Ne=262144),$c=e}return null!==(e=Mr.current)&&(e.flags|=32),$c}function Xc(e,t,l){(e!==fc||2!==yc&&9!==yc)&&null===e.cancelPendingCommit||(nu(e,0),eu(e,vc,$c,!1)),Me(e,l),2&pc&&e===fc||(e===fc&&(!(2&pc)&&(Ec|=l),4===jc&&eu(e,vc,$c,!1)),Du(e))}function Yc(e,t,l){if(6&pc)throw Error(r(327));for(var n=!l&&!(127&t)&&0===(t&e.expiredLanes)||Te(e,t),a=n?function(e,t){var l=pc;pc|=2;var n=iu(),a=ou();fc!==e||vc!==t?(Dc=null,Pc=ue()+500,nu(e,t)):kc=Te(e,t);e:for(;;)try{if(0!==yc&&null!==gc){t=gc;var i=xc;t:switch(yc){case 1:yc=0,xc=null,hu(e,t,i,1);break;case 2:case 9:if(nr(i)){yc=0,xc=null,mu(t);break}t=function(){2!==yc&&9!==yc||fc!==e||(yc=7),Du(e)},i.then(t,t);break e;case 3:yc=7;break e;case 4:yc=5;break e;case 7:nr(i)?(yc=0,xc=null,mu(t)):(yc=0,xc=null,hu(e,t,i,7));break;case 5:var o=null;switch(gc.tag){case 26:o=gc.memoizedState;case 5:case 27:var s=gc;if(o?ib(o):s.stateNode.complete){yc=0,xc=null;var c=s.sibling;if(null!==c)gc=c;else{var u=s.return;null!==u?(gc=u,pu(u)):gc=null}break t}}yc=0,xc=null,hu(e,t,i,5);break;case 6:yc=0,xc=null,hu(e,t,i,6);break;case 8:lu(),jc=6;break e;default:throw Error(r(462))}}du();break}catch(d){au(e,d)}return Na=ja=null,P.H=n,P.A=a,pc=l,null!==gc?0:(fc=null,vc=0,zn(),jc)}(e,t):cu(e,t,!0),i=n;;){if(0===a){kc&&!n&&eu(e,t,0,!1);break}if(l=e.current.alternate,!i||Zc(l)){if(2===a){if(i=t,e.errorRecoveryDisabledLanes&i)var o=0;else o=0!==(o=-536870913&e.pendingLanes)?o:536870912&o?536870912:0;if(0!==o){t=o;e:{var s=e;a=Ac;var c=s.current.memoizedState.isDehydrated;if(c&&(nu(s,o).flags|=256),2!==(o=cu(s,o,!1))){if(Cc&&!c){s.errorRecoveryDisabledLanes|=i,Ec|=i,a=4;break e}i=zc,zc=a,null!==i&&(null===zc?zc=i:zc.push.apply(zc,i))}a=o}if(i=!1,2!==a)continue}}if(1===a){nu(e,0),eu(e,t,0,!0);break}e:{switch(n=e,i=a){case 0:case 1:throw Error(r(345));case 4:if((4194048&t)!==t)break;case 6:eu(n,t,$c,!wc);break e;case 2:zc=null;break;case 3:case 5:break;default:throw Error(r(329))}if((62914560&t)===t&&10<(a=Mc+300-ue())){if(eu(n,t,$c,!wc),0!==$e(n,0,!0))break e;Bc=t,n.timeoutHandle=Cd(Jc.bind(null,n,l,zc,Dc,Lc,t,$c,Ec,Tc,wc,i,"Throttled",-0,0),a)}else Jc(n,l,zc,Dc,Lc,t,$c,Ec,Tc,wc,i,null,-0,0)}break}a=cu(e,t,!1),i=!1}Du(e)}function Jc(e,t,l,n,a,r,i,o,s,c,u,d,b,m){if(e.timeoutHandle=-1,8192&(d=t.subtreeFlags)||!(16785408&~d)){oc(t,r,d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Mt});var h=(62914560&r)===r?Mc-ue():(4194048&r)===r?Ic-ue():0;if(null!==(h=function(e,t){return e.stylesheets&&0===e.count&&ub(e,e.stylesheets),0<e.count||0<e.imgCount?function(l){var n=setTimeout(function(){if(e.stylesheets&&ub(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&0===ob&&(ob=62500*function(){if("function"==typeof performance.getEntriesByType){for(var e=0,t=0,l=performance.getEntriesByType("resource"),n=0;n<l.length;n++){var a=l[n],r=a.transferSize,i=a.initiatorType,o=a.duration;if(r&&o&&pd(i)){for(i=0,o=a.responseEnd,n+=1;n<l.length;n++){var s=l[n],c=s.startTime;if(c>o)break;var u=s.transferSize,d=s.initiatorType;u&&pd(d)&&(i+=u*((s=s.responseEnd)<o?1:(o-c)/(s-c)))}if(--n,t+=8*(r+i)/(a.duration/1e3),10<++e)break}}if(0<e)return t/e/1e6}return navigator.connection&&"number"==typeof(e=navigator.connection.downlink)?e:5}());var a=setTimeout(function(){if(e.waitingForImages=!1,0===e.count&&(e.stylesheets&&ub(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>ob?50:800)+t);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(n),clearTimeout(a)}}:null}(d,h)))return Bc=r,e.cancelPendingCommit=h(gu.bind(null,e,t,r,l,n,a,i,o,s,u,d,null,b,m)),void eu(e,r,i,!c)}gu(e,t,r,l,n,a,i,o,s)}function Zc(e){for(var t=e;;){var l=t.tag;if((0===l||11===l||15===l)&&16384&t.flags&&(null!==(l=t.updateQueue)&&null!==(l=l.stores)))for(var n=0;n<l.length;n++){var a=l[n],r=a.getSnapshot;a=a.value;try{if(!Zl(r(),a))return!1}catch(i){return!1}}if(l=t.child,16384&t.subtreeFlags&&null!==l)l.return=t,t=l;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function eu(e,t,l,n){t&=~_c,t&=~Ec,e.suspendedLanes|=t,e.pingedLanes&=~t,n&&(e.warmLanes|=t),n=e.expirationTimes;for(var a=t;0<a;){var r=31-ke(a),i=1<<r;n[r]=-1,a&=~i}0!==l&&Ie(e,l,t)}function tu(){return!!(6&pc)||(Ru(0),!1)}function lu(){if(null!==gc){if(0===yc)var e=gc.return;else Na=ja=null,si(e=gc),cr=null,ur=0,e=gc;for(;null!==e;)gs(e.alternate,e),e=e.return;gc=null}}function nu(e,t){var l=e.timeoutHandle;-1!==l&&(e.timeoutHandle=-1,Sd(l)),null!==(l=e.cancelPendingCommit)&&(e.cancelPendingCommit=null,l()),Bc=0,lu(),fc=e,gc=l=Bn(e.current,null),vc=t,yc=0,xc=null,wc=!1,kc=Te(e,t),Cc=!1,Tc=$c=_c=Ec=Nc=jc=0,zc=Ac=null,Lc=!1,8&t&&(t|=32&t);var n=e.entangledLanes;if(0!==n)for(e=e.entanglements,n&=t;0<n;){var a=31-ke(n),r=1<<a;t|=e[a],n&=~r}return Sc=t,zn(),l}function au(e,t){Wr=null,P.H=go,t===Za||t===tr?(t=or(),yc=3):t===er?(t=or(),yc=4):yc=t===Mo?8:null!==t&&"object"==typeof t&&"function"==typeof t.then?6:1,xc=t,null===gc&&(jc=1,$o(e,Xn(t,e.current)))}function ru(){var e=Mr.current;return null===e||((4194048&vc)===vc?null===Ir:!!((62914560&vc)===vc||536870912&vc)&&e===Ir)}function iu(){var e=P.H;return P.H=go,null===e?go:e}function ou(){var e=P.A;return P.A=mc,e}function su(){jc=4,wc||(4194048&vc)!==vc&&null!==Mr.current||(kc=!0),!(134217727&Nc)&&!(134217727&Ec)||null===fc||eu(fc,vc,$c,!1)}function cu(e,t,l){var n=pc;pc|=2;var a=iu(),r=ou();fc===e&&vc===t||(Dc=null,nu(e,t)),t=!1;var i=jc;e:for(;;)try{if(0!==yc&&null!==gc){var o=gc,s=xc;switch(yc){case 8:lu(),i=6;break e;case 3:case 2:case 9:case 6:null===Mr.current&&(t=!0);var c=yc;if(yc=0,xc=null,hu(e,o,s,c),l&&kc){i=0;break e}break;default:c=yc,yc=0,xc=null,hu(e,o,s,c)}}uu(),i=jc;break}catch(u){au(e,u)}return t&&e.shellSuspendCounter++,Na=ja=null,pc=n,P.H=a,P.A=r,null===gc&&(fc=null,vc=0,zn()),i}function uu(){for(;null!==gc;)bu(gc)}function du(){for(;null!==gc&&!se();)bu(gc)}function bu(e){var t=ss(e.alternate,e,Sc);e.memoizedProps=e.pendingProps,null===t?pu(e):gc=t}function mu(e){var t=e,l=t.alternate;switch(t.tag){case 15:case 0:t=Ko(l,t,t.pendingProps,t.type,void 0,vc);break;case 11:t=Ko(l,t,t.pendingProps,t.type.render,t.ref,vc);break;case 5:si(t);default:gs(l,t),t=ss(l,t=gc=qn(t,Sc),Sc)}e.memoizedProps=e.pendingProps,null===t?pu(e):gc=t}function hu(e,t,l,n){Na=ja=null,si(t),cr=null,ur=0;var a=t.return;try{if(function(e,t,l,n,a){if(l.flags|=32768,null!==n&&"object"==typeof n&&"function"==typeof n.then){if(null!==(t=l.alternate)&&Aa(t,l,a,!0),null!==(l=Mr.current)){switch(l.tag){case 31:case 13:return null===Ir?su():null===l.alternate&&0===jc&&(jc=3),l.flags&=-257,l.flags|=65536,l.lanes=a,n===lr?l.flags|=16384:(null===(t=l.updateQueue)?l.updateQueue=new Set([n]):t.add(n),Nu(e,n,a)),!1;case 22:return l.flags|=65536,n===lr?l.flags|=16384:(null===(t=l.updateQueue)?(t={transitions:null,markerInstances:null,retryQueue:new Set([n])},l.updateQueue=t):null===(l=t.retryQueue)?t.retryQueue=new Set([n]):l.add(n),Nu(e,n,a)),!1}throw Error(r(435,l.tag))}return Nu(e,n,a),su(),!1}if(ma)return null!==(t=Mr.current)?(!(65536&t.flags)&&(t.flags|=256),t.flags|=65536,t.lanes=a,n!==fa&&Ca(Xn(e=Error(r(422),{cause:n}),l))):(n!==fa&&Ca(Xn(t=Error(r(423),{cause:n}),l)),(e=e.current.alternate).flags|=65536,a&=-a,e.lanes|=a,n=Xn(n,l),Cr(e,a=Ao(e.stateNode,n,a)),4!==jc&&(jc=2)),!1;var i=Error(r(520),{cause:n});if(i=Xn(i,l),null===Ac?Ac=[i]:Ac.push(i),4!==jc&&(jc=2),null===t)return!0;n=Xn(n,l),l=t;do{switch(l.tag){case 3:return l.flags|=65536,e=a&-a,l.lanes|=e,Cr(l,e=Ao(l.stateNode,n,e)),!1;case 1:if(t=l.type,i=l.stateNode,!(128&l.flags||"function"!=typeof t.getDerivedStateFromError&&(null===i||"function"!=typeof i.componentDidCatch||null!==Rc&&Rc.has(i))))return l.flags|=65536,a&=-a,l.lanes|=a,Lo(a=zo(a),e,l,n),Cr(l,a),!1}l=l.return}while(null!==l);return!1}(e,a,t,l,vc))return jc=1,$o(e,Xn(l,e.current)),void(gc=null)}catch(i){if(null!==a)throw gc=a,i;return jc=1,$o(e,Xn(l,e.current)),void(gc=null)}32768&t.flags?(ma||1===n?e=!0:kc||536870912&vc?e=!1:(wc=e=!0,(2===n||9===n||3===n||6===n)&&(null!==(n=Mr.current)&&13===n.tag&&(n.flags|=16384))),fu(t,e)):pu(t)}function pu(e){var t=e;do{if(32768&t.flags)return void fu(t,wc);e=t.return;var l=ps(t.alternate,t,Sc);if(null!==l)return void(gc=l);if(null!==(t=t.sibling))return void(gc=t);gc=t=e}while(null!==t);0===jc&&(jc=5)}function fu(e,t){do{var l=fs(e.alternate,e);if(null!==l)return l.flags&=32767,void(gc=l);if(null!==(l=e.return)&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!t&&null!==(e=e.sibling))return void(gc=e);gc=e=l}while(null!==e);jc=6,gc=null}function gu(e,t,l,n,a,i,o,s,c){e.cancelPendingCommit=null;do{ku()}while(0!==Oc);if(6&pc)throw Error(r(327));if(null!==t){if(t===e.current)throw Error(r(177));if(i=t.lanes|t.childLanes,function(e,t,l,n,a,r){var i=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var o=e.entanglements,s=e.expirationTimes,c=e.hiddenUpdates;for(l=i&~l;0<l;){var u=31-ke(l),d=1<<u;o[u]=0,s[u]=-1;var b=c[u];if(null!==b)for(c[u]=null,u=0;u<b.length;u++){var m=b[u];null!==m&&(m.lane&=-536870913)}l&=~d}0!==n&&Ie(e,n,0),0!==r&&0===a&&0!==e.tag&&(e.suspendedLanes|=r&~(i&~t))}(e,l,i|=An,o,s,c),e===fc&&(gc=fc=null,vc=0),Uc=t,Fc=e,Bc=l,qc=i,Wc=a,Vc=n,10256&t.subtreeFlags||10256&t.flags?(e.callbackNode=null,e.callbackPriority=0,ie(he,function(){return Cu(),null})):(e.callbackNode=null,e.callbackPriority=0),n=!!(13878&t.flags),13878&t.subtreeFlags||n){n=P.T,P.T=null,a=D.p,D.p=2,o=pc,pc|=4;try{!function(e,t){if(e=e.containerInfo,fd=wb,rn(e=an(e))){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{var n=(l=(l=e.ownerDocument)&&l.defaultView||window).getSelection&&l.getSelection();if(n&&0!==n.rangeCount){l=n.anchorNode;var a=n.anchorOffset,i=n.focusNode;n=n.focusOffset;try{l.nodeType,i.nodeType}catch(f){l=null;break e}var o=0,s=-1,c=-1,u=0,d=0,b=e,m=null;t:for(;;){for(var h;b!==l||0!==a&&3!==b.nodeType||(s=o+a),b!==i||0!==n&&3!==b.nodeType||(c=o+n),3===b.nodeType&&(o+=b.nodeValue.length),null!==(h=b.firstChild);)m=b,b=h;for(;;){if(b===e)break t;if(m===l&&++u===a&&(s=o),m===i&&++d===n&&(c=o),null!==(h=b.nextSibling))break;m=(b=m).parentNode}b=h}l=-1===s||-1===c?null:{start:s,end:c}}else l=null}l=l||{start:0,end:0}}else l=null;for(gd={focusedElem:e,selectionRange:l},wb=!1,Is=t;null!==Is;)if(e=(t=Is).child,1028&t.subtreeFlags&&null!==e)e.return=t,Is=e;else for(;null!==Is;){switch(i=(t=Is).alternate,e=t.flags,t.tag){case 0:if(4&e&&null!==(e=null!==(e=t.updateQueue)?e.events:null))for(l=0;l<e.length;l++)(a=e[l]).ref.impl=a.nextImpl;break;case 11:case 15:case 5:case 26:case 27:case 6:case 4:case 17:break;case 1:if(1024&e&&null!==i){e=void 0,l=t,a=i.memoizedProps,i=i.memoizedState,n=l.stateNode;try{var p=jo(l.type,a);e=n.getSnapshotBeforeUpdate(p,i),n.__reactInternalSnapshotBeforeUpdate=e}catch(g){ju(l,l.return,g)}}break;case 3:if(1024&e)if(9===(l=(e=t.stateNode.containerInfo).nodeType))Ad(e);else if(1===l)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Ad(e);break;default:e.textContent=""}break;default:if(1024&e)throw Error(r(163))}if(null!==(e=t.sibling)){e.return=t.return,Is=e;break}Is=t.return}}(e,t)}finally{pc=o,D.p=a,P.T=n}}Oc=1,vu(),yu(),xu()}}function vu(){if(1===Oc){Oc=0;var e=Fc,t=Uc,l=!!(13878&t.flags);if(13878&t.subtreeFlags||l){l=P.T,P.T=null;var n=D.p;D.p=2;var a=pc;pc|=4;try{Ks(t,e);var r=gd,i=an(e.containerInfo),o=r.focusedElem,s=r.selectionRange;if(i!==o&&o&&o.ownerDocument&&nn(o.ownerDocument.documentElement,o)){if(null!==s&&rn(o)){var c=s.start,u=s.end;if(void 0===u&&(u=c),"selectionStart"in o)o.selectionStart=c,o.selectionEnd=Math.min(u,o.value.length);else{var d=o.ownerDocument||document,b=d&&d.defaultView||window;if(b.getSelection){var m=b.getSelection(),h=o.textContent.length,p=Math.min(s.start,h),f=void 0===s.end?p:Math.min(s.end,h);!m.extend&&p>f&&(i=f,f=p,p=i);var g=ln(o,p),v=ln(o,f);if(g&&v&&(1!==m.rangeCount||m.anchorNode!==g.node||m.anchorOffset!==g.offset||m.focusNode!==v.node||m.focusOffset!==v.offset)){var y=d.createRange();y.setStart(g.node,g.offset),m.removeAllRanges(),p>f?(m.addRange(y),m.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),m.addRange(y))}}}}for(d=[],m=o;m=m.parentNode;)1===m.nodeType&&d.push({element:m,left:m.scrollLeft,top:m.scrollTop});for("function"==typeof o.focus&&o.focus(),o=0;o<d.length;o++){var x=d[o];x.element.scrollLeft=x.left,x.element.scrollTop=x.top}}wb=!!fd,gd=fd=null}finally{pc=a,D.p=n,P.T=l}}e.current=t,Oc=2}}function yu(){if(2===Oc){Oc=0;var e=Fc,t=Uc,l=!!(8772&t.flags);if(8772&t.subtreeFlags||l){l=P.T,P.T=null;var n=D.p;D.p=2;var a=pc;pc|=4;try{Ps(e,t.alternate,t)}finally{pc=a,D.p=n,P.T=l}}Oc=3}}function xu(){if(4===Oc||3===Oc){Oc=0,ce();var e=Fc,t=Uc,l=Bc,n=Vc;10256&t.subtreeFlags||10256&t.flags?Oc=5:(Oc=0,Uc=Fc=null,wu(e,e.pendingLanes));var a=e.pendingLanes;if(0===a&&(Rc=null),Oe(l),t=t.stateNode,xe&&"function"==typeof xe.onCommitFiberRoot)try{xe.onCommitFiberRoot(ye,t,void 0,!(128&~t.current.flags))}catch(s){}if(null!==n){t=P.T,a=D.p,D.p=2,P.T=null;try{for(var r=e.onRecoverableError,i=0;i<n.length;i++){var o=n[i];r(o.value,{componentStack:o.stack})}}finally{P.T=t,D.p=a}}3&Bc&&ku(),Du(e),a=e.pendingLanes,261930&l&&42&a?e===Kc?Hc++:(Hc=0,Kc=e):Hc=0,Ru(0)}}function wu(e,t){0===(e.pooledCacheLanes&=t)&&(null!=(t=e.pooledCache)&&(e.pooledCache=null,Ba(t)))}function ku(){return vu(),yu(),xu(),Cu()}function Cu(){if(5!==Oc)return!1;var e=Fc,t=qc;qc=0;var l=Oe(Bc),n=P.T,a=D.p;try{D.p=32>l?32:l,P.T=null,l=Wc,Wc=null;var i=Fc,o=Bc;if(Oc=0,Uc=Fc=null,Bc=0,6&pc)throw Error(r(331));var s=pc;if(pc|=4,uc(i.current),lc(i,i.current,o,l),pc=s,Ru(0,!1),xe&&"function"==typeof xe.onPostCommitFiberRoot)try{xe.onPostCommitFiberRoot(ye,i)}catch(c){}return!0}finally{D.p=a,P.T=n,wu(e,t)}}function Su(e,t,l){t=Xn(l,t),null!==(e=wr(e,t=Ao(e.stateNode,t,2),2))&&(Me(e,2),Du(e))}function ju(e,t,l){if(3===e.tag)Su(e,e,l);else for(;null!==t;){if(3===t.tag){Su(t,e,l);break}if(1===t.tag){var n=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof n.componentDidCatch&&(null===Rc||!Rc.has(n))){e=Xn(l,e),null!==(n=wr(t,l=zo(2),2))&&(Lo(l,n,t,e),Me(n,2),Du(n));break}}t=t.return}}function Nu(e,t,l){var n=e.pingCache;if(null===n){n=e.pingCache=new hc;var a=new Set;n.set(t,a)}else void 0===(a=n.get(t))&&(a=new Set,n.set(t,a));a.has(l)||(Cc=!0,a.add(l),e=Eu.bind(null,e,t,l),t.then(e,e))}function Eu(e,t,l){var n=e.pingCache;null!==n&&n.delete(t),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,fc===e&&(vc&l)===l&&(4===jc||3===jc&&(62914560&vc)===vc&&300>ue()-Mc?!(2&pc)&&nu(e,0):_c|=l,Tc===vc&&(Tc=0)),Du(e)}function _u(e,t){0===t&&(t=ze()),null!==(e=In(e,t))&&(Me(e,t),Du(e))}function $u(e){var t=e.memoizedState,l=0;null!==t&&(l=t.retryLane),_u(e,l)}function Tu(e,t){var l=0;switch(e.tag){case 31:case 13:var n=e.stateNode,a=e.memoizedState;null!==a&&(l=a.retryLane);break;case 19:n=e.stateNode;break;case 22:n=e.stateNode._retryCache;break;default:throw Error(r(314))}null!==n&&n.delete(t),_u(e,l)}var Au=null,zu=null,Lu=!1,Mu=!1,Iu=!1,Pu=0;function Du(e){e!==zu&&null===e.next&&(null===zu?Au=zu=e:zu=zu.next=e),Mu=!0,Lu||(Lu=!0,Nd(function(){6&pc?ie(be,Ou):Fu()}))}function Ru(e,t){if(!Iu&&Mu){Iu=!0;do{for(var l=!1,n=Au;null!==n;){if(0!==e){var a=n.pendingLanes;if(0===a)var r=0;else{var i=n.suspendedLanes,o=n.pingedLanes;r=(1<<31-ke(42|e)+1)-1,r=201326741&(r&=a&~(i&~o))?201326741&r|1:r?2|r:0}0!==r&&(l=!0,qu(n,r))}else r=vc,!(3&(r=$e(n,n===fc?r:0,null!==n.cancelPendingCommit||-1!==n.timeoutHandle)))||Te(n,r)||(l=!0,qu(n,r));n=n.next}}while(l);Iu=!1}}function Ou(){Fu()}function Fu(){Mu=Lu=!1;var e=0;0!==Pu&&function(){var e=window.event;if(e&&"popstate"===e.type)return e!==kd&&(kd=e,!0);return kd=null,!1}()&&(e=Pu);for(var t=ue(),l=null,n=Au;null!==n;){var a=n.next,r=Uu(n,t);0===r?(n.next=null,null===l?Au=a:l.next=a,null===a&&(zu=l)):(l=n,(0!==e||3&r)&&(Mu=!0)),n=a}0!==Oc&&5!==Oc||Ru(e),0!==Pu&&(Pu=0)}function Uu(e,t){for(var l=e.suspendedLanes,n=e.pingedLanes,a=e.expirationTimes,r=-62914561&e.pendingLanes;0<r;){var i=31-ke(r),o=1<<i,s=a[i];-1===s?0!==(o&l)&&0===(o&n)||(a[i]=Ae(o,t)):s<=t&&(e.expiredLanes|=o),r&=~o}if(l=vc,l=$e(e,e===(t=fc)?l:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle),n=e.callbackNode,0===l||e===t&&(2===yc||9===yc)||null!==e.cancelPendingCommit)return null!==n&&null!==n&&oe(n),e.callbackNode=null,e.callbackPriority=0;if(!(3&l)||Te(e,l)){if((t=l&-l)===e.callbackPriority)return t;switch(null!==n&&oe(n),Oe(l)){case 2:case 8:l=me;break;case 32:default:l=he;break;case 268435456:l=fe}return n=Bu.bind(null,e),l=ie(l,n),e.callbackPriority=t,e.callbackNode=l,t}return null!==n&&null!==n&&oe(n),e.callbackPriority=2,e.callbackNode=null,2}function Bu(e,t){if(0!==Oc&&5!==Oc)return e.callbackNode=null,e.callbackPriority=0,null;var l=e.callbackNode;if(ku()&&e.callbackNode!==l)return null;var n=vc;return 0===(n=$e(e,e===fc?n:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle))?null:(Yc(e,n,t),Uu(e,ue()),null!=e.callbackNode&&e.callbackNode===l?Bu.bind(null,e):null)}function qu(e,t){if(ku())return null;Yc(e,t,!0)}function Wu(){if(0===Pu){var e=Va;0===e&&(e=je,!(261888&(je<<=1))&&(je=256)),Pu=e}return Pu}function Vu(e){return null==e||"symbol"==typeof e||"boolean"==typeof e?null:"function"==typeof e?e:Lt(""+e)}function Hu(e,t){var l=t.ownerDocument.createElement("input");return l.name=t.name,l.value=t.value,e.id&&l.setAttribute("form",e.id),t.parentNode.insertBefore(l,t),e=new FormData(e),l.parentNode.removeChild(l),e}for(var Ku=0;Ku<Nn.length;Ku++){var Gu=Nn[Ku];En(Gu.toLowerCase(),"on"+(Gu[0].toUpperCase()+Gu.slice(1)))}En(vn,"onAnimationEnd"),En(yn,"onAnimationIteration"),En(xn,"onAnimationStart"),En("dblclick","onDoubleClick"),En("focusin","onFocus"),En("focusout","onBlur"),En(wn,"onTransitionRun"),En(kn,"onTransitionStart"),En(Cn,"onTransitionCancel"),En(Sn,"onTransitionEnd"),it("onMouseEnter",["mouseout","mouseover"]),it("onMouseLeave",["mouseout","mouseover"]),it("onPointerEnter",["pointerout","pointerover"]),it("onPointerLeave",["pointerout","pointerover"]),rt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),rt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),rt("onBeforeInput",["compositionend","keypress","textInput","paste"]),rt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),rt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),rt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Qu="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Xu=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Qu));function Yu(e,t){t=!!(4&t);for(var l=0;l<e.length;l++){var n=e[l],a=n.event;n=n.listeners;e:{var r=void 0;if(t)for(var i=n.length-1;0<=i;i--){var o=n[i],s=o.instance,c=o.currentTarget;if(o=o.listener,s!==r&&a.isPropagationStopped())break e;r=o,a.currentTarget=c;try{r(a)}catch(u){_n(u)}a.currentTarget=null,r=s}else for(i=0;i<n.length;i++){if(s=(o=n[i]).instance,c=o.currentTarget,o=o.listener,s!==r&&a.isPropagationStopped())break e;r=o,a.currentTarget=c;try{r(a)}catch(u){_n(u)}a.currentTarget=null,r=s}}}}function Ju(e,t){var l=t[He];void 0===l&&(l=t[He]=new Set);var n=e+"__bubble";l.has(n)||(ld(t,e,2,!1),l.add(n))}function Zu(e,t,l){var n=0;t&&(n|=4),ld(l,e,n,t)}var ed="_reactListening"+Math.random().toString(36).slice(2);function td(e){if(!e[ed]){e[ed]=!0,nt.forEach(function(t){"selectionchange"!==t&&(Xu.has(t)||Zu(t,!1,e),Zu(t,!0,e))});var t=9===e.nodeType?e:e.ownerDocument;null===t||t[ed]||(t[ed]=!0,Zu("selectionchange",!1,t))}}function ld(e,t,l,n){switch(_b(t)){case 2:var a=kb;break;case 8:a=Cb;break;default:a=Sb}l=a.bind(null,t,l,e),a=void 0,!Wt||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(a=!0),n?void 0!==a?e.addEventListener(t,l,{capture:!0,passive:a}):e.addEventListener(t,l,!0):void 0!==a?e.addEventListener(t,l,{passive:a}):e.addEventListener(t,l,!1)}function nd(e,t,l,n,a){var r=n;if(!(1&t||2&t||null===n))e:for(;;){if(null===n)return;var i=n.tag;if(3===i||4===i){var s=n.stateNode.containerInfo;if(s===a)break;if(4===i)for(i=n.return;null!==i;){var c=i.tag;if((3===c||4===c)&&i.stateNode.containerInfo===a)return;i=i.return}for(;null!==s;){if(null===(i=Je(s)))return;if(5===(c=i.tag)||6===c||26===c||27===c){n=r=i;continue e}s=s.parentNode}}n=n.return}Ut(function(){var n=r,a=Pt(l),i=[];e:{var s=jn.get(e);if(void 0!==s){var c=al,u=e;switch(e){case"keypress":if(0===Xt(l))break e;case"keydown":case"keyup":c=yl;break;case"focusin":u="focus",c=ul;break;case"focusout":u="blur",c=ul;break;case"beforeblur":case"afterblur":c=ul;break;case"click":if(2===l.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":c=sl;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":c=cl;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":c=wl;break;case vn:case yn:case xn:c=dl;break;case Sn:c=kl;break;case"scroll":case"scrollend":c=il;break;case"wheel":c=Cl;break;case"copy":case"cut":case"paste":c=bl;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=xl;break;case"toggle":case"beforetoggle":c=Sl}var d=!!(4&t),b=!d&&("scroll"===e||"scrollend"===e),m=d?null!==s?s+"Capture":null:s;d=[];for(var h,p=n;null!==p;){var f=p;if(h=f.stateNode,5!==(f=f.tag)&&26!==f&&27!==f||null===h||null===m||null!=(f=Bt(p,m))&&d.push(ad(p,f,h)),b)break;p=p.return}0<d.length&&(s=new c(s,u,null,l,a),i.push({event:s,listeners:d}))}}if(!(7&t)){if(c="mouseout"===e||"pointerout"===e,(!(s="mouseover"===e||"pointerover"===e)||l===It||!(u=l.relatedTarget||l.fromElement)||!Je(u)&&!u[Ve])&&(c||s)&&(s=a.window===a?a:(s=a.ownerDocument)?s.defaultView||s.parentWindow:window,c?(c=n,null!==(u=(u=l.relatedTarget||l.toElement)?Je(u):null)&&(b=o(u),d=u.tag,u!==b||5!==d&&27!==d&&6!==d)&&(u=null)):(c=null,u=n),c!==u)){if(d=sl,f="onMouseLeave",m="onMouseEnter",p="mouse","pointerout"!==e&&"pointerover"!==e||(d=xl,f="onPointerLeave",m="onPointerEnter",p="pointer"),b=null==c?s:et(c),h=null==u?s:et(u),(s=new d(f,p+"leave",c,l,a)).target=b,s.relatedTarget=h,f=null,Je(a)===n&&((d=new d(m,p+"enter",u,l,a)).target=h,d.relatedTarget=b,f=d),b=f,c&&u)e:{for(d=id,p=u,h=0,f=m=c;f;f=d(f))h++;f=0;for(var g=p;g;g=d(g))f++;for(;0<h-f;)m=d(m),h--;for(;0<f-h;)p=d(p),f--;for(;h--;){if(m===p||null!==p&&m===p.alternate){d=m;break e}m=d(m),p=d(p)}d=null}else d=null;null!==c&&od(i,s,c,d,!1),null!==u&&null!==b&&od(i,b,u,d,!0)}if("select"===(c=(s=n?et(n):window).nodeName&&s.nodeName.toLowerCase())||"input"===c&&"file"===s.type)var v=Bl;else if(Pl(s))if(ql)v=Jl;else{v=Xl;var y=Ql}else!(c=s.nodeName)||"input"!==c.toLowerCase()||"checkbox"!==s.type&&"radio"!==s.type?n&&Tt(n.elementType)&&(v=Bl):v=Yl;switch(v&&(v=v(e,n))?Dl(i,v,l,a):(y&&y(e,s,n),"focusout"===e&&n&&"number"===s.type&&null!=n.memoizedProps.value&&kt(s,"number",s.value)),y=n?et(n):window,e){case"focusin":(Pl(y)||"true"===y.contentEditable)&&(sn=y,cn=n,un=null);break;case"focusout":un=cn=sn=null;break;case"mousedown":dn=!0;break;case"contextmenu":case"mouseup":case"dragend":dn=!1,bn(i,l,a);break;case"selectionchange":if(on)break;case"keydown":case"keyup":bn(i,l,a)}var x;if(Nl)e:{switch(e){case"compositionstart":var w="onCompositionStart";break e;case"compositionend":w="onCompositionEnd";break e;case"compositionupdate":w="onCompositionUpdate";break e}w=void 0}else Ml?zl(e,l)&&(w="onCompositionEnd"):"keydown"===e&&229===l.keyCode&&(w="onCompositionStart");w&&($l&&"ko"!==l.locale&&(Ml||"onCompositionStart"!==w?"onCompositionEnd"===w&&Ml&&(x=Qt()):(Kt="value"in(Ht=a)?Ht.value:Ht.textContent,Ml=!0)),0<(y=rd(n,w)).length&&(w=new ml(w,e,null,l,a),i.push({event:w,listeners:y}),x?w.data=x:null!==(x=Ll(l))&&(w.data=x))),(x=_l?function(e,t){switch(e){case"compositionend":return Ll(t);case"keypress":return 32!==t.which?null:(Al=!0,Tl);case"textInput":return(e=t.data)===Tl&&Al?null:e;default:return null}}(e,l):function(e,t){if(Ml)return"compositionend"===e||!Nl&&zl(e,t)?(e=Qt(),Gt=Kt=Ht=null,Ml=!1,e):null;switch(e){case"paste":default:return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return $l&&"ko"!==t.locale?null:t.data}}(e,l))&&(0<(w=rd(n,"onBeforeInput")).length&&(y=new ml("onBeforeInput","beforeinput",null,l,a),i.push({event:y,listeners:w}),y.data=x)),function(e,t,l,n,a){if("submit"===t&&l&&l.stateNode===a){var r=Vu((a[We]||null).action),i=n.submitter;i&&null!==(t=(t=i[We]||null)?Vu(t.formAction):i.getAttribute("formAction"))&&(r=t,i=null);var o=new al("action","action",null,n,a);e.push({event:o,listeners:[{instance:null,listener:function(){if(n.defaultPrevented){if(0!==Pu){var e=i?Hu(a,i):new FormData(a);lo(l,{pending:!0,data:e,method:a.method,action:r},null,e)}}else"function"==typeof r&&(o.preventDefault(),e=i?Hu(a,i):new FormData(a),lo(l,{pending:!0,data:e,method:a.method,action:r},r,e))},currentTarget:a}]})}}(i,e,n,l,a)}Yu(i,t)})}function ad(e,t,l){return{instance:e,listener:t,currentTarget:l}}function rd(e,t){for(var l=t+"Capture",n=[];null!==e;){var a=e,r=a.stateNode;if(5!==(a=a.tag)&&26!==a&&27!==a||null===r||(null!=(a=Bt(e,l))&&n.unshift(ad(e,a,r)),null!=(a=Bt(e,t))&&n.push(ad(e,a,r))),3===e.tag)return n;e=e.return}return[]}function id(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag&&27!==e.tag);return e||null}function od(e,t,l,n,a){for(var r=t._reactName,i=[];null!==l&&l!==n;){var o=l,s=o.alternate,c=o.stateNode;if(o=o.tag,null!==s&&s===n)break;5!==o&&26!==o&&27!==o||null===c||(s=c,a?null!=(c=Bt(l,r))&&i.unshift(ad(l,c,s)):a||null!=(c=Bt(l,r))&&i.push(ad(l,c,s))),l=l.return}0!==i.length&&e.push({event:t,listeners:i})}var sd=/\r\n?/g,cd=/\u0000|\uFFFD/g;function ud(e){return("string"==typeof e?e:""+e).replace(sd,"\n").replace(cd,"")}function dd(e,t){return t=ud(t),ud(e)===t}function bd(e,t,l,n,a,i){switch(l){case"children":"string"==typeof n?"body"===t||"textarea"===t&&""===n||Nt(e,n):("number"==typeof n||"bigint"==typeof n)&&"body"!==t&&Nt(e,""+n);break;case"className":dt(e,"class",n);break;case"tabIndex":dt(e,"tabindex",n);break;case"dir":case"role":case"viewBox":case"width":case"height":dt(e,l,n);break;case"style":$t(e,n,i);break;case"data":if("object"!==t){dt(e,"data",n);break}case"src":case"href":if(""===n&&("a"!==t||"href"!==l)){e.removeAttribute(l);break}if(null==n||"function"==typeof n||"symbol"==typeof n||"boolean"==typeof n){e.removeAttribute(l);break}n=Lt(""+n),e.setAttribute(l,n);break;case"action":case"formAction":if("function"==typeof n){e.setAttribute(l,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}if("function"==typeof i&&("formAction"===l?("input"!==t&&bd(e,t,"name",a.name,a,null),bd(e,t,"formEncType",a.formEncType,a,null),bd(e,t,"formMethod",a.formMethod,a,null),bd(e,t,"formTarget",a.formTarget,a,null)):(bd(e,t,"encType",a.encType,a,null),bd(e,t,"method",a.method,a,null),bd(e,t,"target",a.target,a,null))),null==n||"symbol"==typeof n||"boolean"==typeof n){e.removeAttribute(l);break}n=Lt(""+n),e.setAttribute(l,n);break;case"onClick":null!=n&&(e.onclick=Mt);break;case"onScroll":null!=n&&Ju("scroll",e);break;case"onScrollEnd":null!=n&&Ju("scrollend",e);break;case"dangerouslySetInnerHTML":if(null!=n){if("object"!=typeof n||!("__html"in n))throw Error(r(61));if(null!=(l=n.__html)){if(null!=a.children)throw Error(r(60));e.innerHTML=l}}break;case"multiple":e.multiple=n&&"function"!=typeof n&&"symbol"!=typeof n;break;case"muted":e.muted=n&&"function"!=typeof n&&"symbol"!=typeof n;break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":case"autoFocus":break;case"xlinkHref":if(null==n||"function"==typeof n||"boolean"==typeof n||"symbol"==typeof n){e.removeAttribute("xlink:href");break}l=Lt(""+n),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":null!=n&&"function"!=typeof n&&"symbol"!=typeof n?e.setAttribute(l,""+n):e.removeAttribute(l);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":n&&"function"!=typeof n&&"symbol"!=typeof n?e.setAttribute(l,""):e.removeAttribute(l);break;case"capture":case"download":!0===n?e.setAttribute(l,""):!1!==n&&null!=n&&"function"!=typeof n&&"symbol"!=typeof n?e.setAttribute(l,n):e.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":null!=n&&"function"!=typeof n&&"symbol"!=typeof n&&!isNaN(n)&&1<=n?e.setAttribute(l,n):e.removeAttribute(l);break;case"rowSpan":case"start":null==n||"function"==typeof n||"symbol"==typeof n||isNaN(n)?e.removeAttribute(l):e.setAttribute(l,n);break;case"popover":Ju("beforetoggle",e),Ju("toggle",e),ut(e,"popover",n);break;case"xlinkActuate":bt(e,"http://www.w3.org/1999/xlink","xlink:actuate",n);break;case"xlinkArcrole":bt(e,"http://www.w3.org/1999/xlink","xlink:arcrole",n);break;case"xlinkRole":bt(e,"http://www.w3.org/1999/xlink","xlink:role",n);break;case"xlinkShow":bt(e,"http://www.w3.org/1999/xlink","xlink:show",n);break;case"xlinkTitle":bt(e,"http://www.w3.org/1999/xlink","xlink:title",n);break;case"xlinkType":bt(e,"http://www.w3.org/1999/xlink","xlink:type",n);break;case"xmlBase":bt(e,"http://www.w3.org/XML/1998/namespace","xml:base",n);break;case"xmlLang":bt(e,"http://www.w3.org/XML/1998/namespace","xml:lang",n);break;case"xmlSpace":bt(e,"http://www.w3.org/XML/1998/namespace","xml:space",n);break;case"is":ut(e,"is",n);break;case"innerText":case"textContent":break;default:(!(2<l.length)||"o"!==l[0]&&"O"!==l[0]||"n"!==l[1]&&"N"!==l[1])&&ut(e,l=At.get(l)||l,n)}}function md(e,t,l,n,a,i){switch(l){case"style":$t(e,n,i);break;case"dangerouslySetInnerHTML":if(null!=n){if("object"!=typeof n||!("__html"in n))throw Error(r(61));if(null!=(l=n.__html)){if(null!=a.children)throw Error(r(60));e.innerHTML=l}}break;case"children":"string"==typeof n?Nt(e,n):("number"==typeof n||"bigint"==typeof n)&&Nt(e,""+n);break;case"onScroll":null!=n&&Ju("scroll",e);break;case"onScrollEnd":null!=n&&Ju("scrollend",e);break;case"onClick":null!=n&&(e.onclick=Mt);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":case"innerText":case"textContent":break;default:at.hasOwnProperty(l)||("o"!==l[0]||"n"!==l[1]||(a=l.endsWith("Capture"),t=l.slice(2,a?l.length-7:void 0),"function"==typeof(i=null!=(i=e[We]||null)?i[l]:null)&&e.removeEventListener(t,i,a),"function"!=typeof n)?l in e?e[l]=n:!0===n?e.setAttribute(l,""):ut(e,l,n):("function"!=typeof i&&null!==i&&(l in e?e[l]=null:e.hasAttribute(l)&&e.removeAttribute(l)),e.addEventListener(t,n,a)))}}function hd(e,t,l){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ju("error",e),Ju("load",e);var n,a=!1,i=!1;for(n in l)if(l.hasOwnProperty(n)){var o=l[n];if(null!=o)switch(n){case"src":a=!0;break;case"srcSet":i=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:bd(e,t,n,o,l,null)}}return i&&bd(e,t,"srcSet",l.srcSet,l,null),void(a&&bd(e,t,"src",l.src,l,null));case"input":Ju("invalid",e);var s=n=o=i=null,c=null,u=null;for(a in l)if(l.hasOwnProperty(a)){var d=l[a];if(null!=d)switch(a){case"name":i=d;break;case"type":o=d;break;case"checked":c=d;break;case"defaultChecked":u=d;break;case"value":n=d;break;case"defaultValue":s=d;break;case"children":case"dangerouslySetInnerHTML":if(null!=d)throw Error(r(137,t));break;default:bd(e,t,a,d,l,null)}}return void wt(e,n,s,c,u,o,i,!1);case"select":for(i in Ju("invalid",e),a=o=n=null,l)if(l.hasOwnProperty(i)&&null!=(s=l[i]))switch(i){case"value":n=s;break;case"defaultValue":o=s;break;case"multiple":a=s;default:bd(e,t,i,s,l,null)}return t=n,l=o,e.multiple=!!a,void(null!=t?Ct(e,!!a,t,!1):null!=l&&Ct(e,!!a,l,!0));case"textarea":for(o in Ju("invalid",e),n=i=a=null,l)if(l.hasOwnProperty(o)&&null!=(s=l[o]))switch(o){case"value":a=s;break;case"defaultValue":i=s;break;case"children":n=s;break;case"dangerouslySetInnerHTML":if(null!=s)throw Error(r(91));break;default:bd(e,t,o,s,l,null)}return void jt(e,a,i,n);case"option":for(c in l)if(l.hasOwnProperty(c)&&null!=(a=l[c]))if("selected"===c)e.selected=a&&"function"!=typeof a&&"symbol"!=typeof a;else bd(e,t,c,a,l,null);return;case"dialog":Ju("beforetoggle",e),Ju("toggle",e),Ju("cancel",e),Ju("close",e);break;case"iframe":case"object":Ju("load",e);break;case"video":case"audio":for(a=0;a<Qu.length;a++)Ju(Qu[a],e);break;case"image":Ju("error",e),Ju("load",e);break;case"details":Ju("toggle",e);break;case"embed":case"source":case"link":Ju("error",e),Ju("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(u in l)if(l.hasOwnProperty(u)&&null!=(a=l[u]))switch(u){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:bd(e,t,u,a,l,null)}return;default:if(Tt(t)){for(d in l)l.hasOwnProperty(d)&&(void 0!==(a=l[d])&&md(e,t,d,a,l,void 0));return}}for(s in l)l.hasOwnProperty(s)&&(null!=(a=l[s])&&bd(e,t,s,a,l,null))}function pd(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}var fd=null,gd=null;function vd(e){return 9===e.nodeType?e:e.ownerDocument}function yd(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function xd(e,t){if(0===e)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return 1===e&&"foreignObject"===t?0:e}function wd(e,t){return"textarea"===e||"noscript"===e||"string"==typeof t.children||"number"==typeof t.children||"bigint"==typeof t.children||"object"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var kd=null;var Cd="function"==typeof setTimeout?setTimeout:void 0,Sd="function"==typeof clearTimeout?clearTimeout:void 0,jd="function"==typeof Promise?Promise:void 0,Nd="function"==typeof queueMicrotask?queueMicrotask:void 0!==jd?function(e){return jd.resolve(null).then(e).catch(Ed)}:Cd;function Ed(e){setTimeout(function(){throw e})}function _d(e){return"head"===e}function $d(e,t){var l=t,n=0;do{var a=l.nextSibling;if(e.removeChild(l),a&&8===a.nodeType)if("/$"===(l=a.data)||"/&"===l){if(0===n)return e.removeChild(a),void Hb(t);n--}else if("$"===l||"$?"===l||"$~"===l||"$!"===l||"&"===l)n++;else if("html"===l)Fd(e.ownerDocument.documentElement);else if("head"===l){Fd(l=e.ownerDocument.head);for(var r=l.firstChild;r;){var i=r.nextSibling,o=r.nodeName;r[Xe]||"SCRIPT"===o||"STYLE"===o||"LINK"===o&&"stylesheet"===r.rel.toLowerCase()||l.removeChild(r),r=i}}else"body"===l&&Fd(e.ownerDocument.body);l=a}while(l);Hb(t)}function Td(e,t){var l=e;e=0;do{var n=l.nextSibling;if(1===l.nodeType?t?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",""===l.getAttribute("style")&&l.removeAttribute("style")):3===l.nodeType&&(t?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),n&&8===n.nodeType)if("/$"===(l=n.data)){if(0===e)break;e--}else"$"!==l&&"$?"!==l&&"$~"!==l&&"$!"!==l||e++;l=n}while(l)}function Ad(e){var t=e.firstChild;for(t&&10===t.nodeType&&(t=t.nextSibling);t;){var l=t;switch(t=t.nextSibling,l.nodeName){case"HTML":case"HEAD":case"BODY":Ad(l),Ye(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if("stylesheet"===l.rel.toLowerCase())continue}e.removeChild(l)}}function zd(e,t){for(;8!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!t)return null;if(null===(e=Id(e.nextSibling)))return null}return e}function Ld(e){return"$?"===e.data||"$~"===e.data}function Md(e){return"$!"===e.data||"$?"===e.data&&"loading"!==e.ownerDocument.readyState}function Id(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t||"$~"===t||"&"===t||"F!"===t||"F"===t)break;if("/$"===t||"/&"===t)return null}}return e}var Pd=null;function Dd(e){e=e.nextSibling;for(var t=0;e;){if(8===e.nodeType){var l=e.data;if("/$"===l||"/&"===l){if(0===t)return Id(e.nextSibling);t--}else"$"!==l&&"$!"!==l&&"$?"!==l&&"$~"!==l&&"&"!==l||t++}e=e.nextSibling}return null}function Rd(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var l=e.data;if("$"===l||"$!"===l||"$?"===l||"$~"===l||"&"===l){if(0===t)return e;t--}else"/$"!==l&&"/&"!==l||t++}e=e.previousSibling}return null}function Od(e,t,l){switch(t=vd(l),e){case"html":if(!(e=t.documentElement))throw Error(r(452));return e;case"head":if(!(e=t.head))throw Error(r(453));return e;case"body":if(!(e=t.body))throw Error(r(454));return e;default:throw Error(r(451))}}function Fd(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Ye(e)}var Ud=new Map,Bd=new Set;function qd(e){return"function"==typeof e.getRootNode?e.getRootNode():9===e.nodeType?e:e.ownerDocument}var Wd=D.d;D.d={f:function(){var e=Wd.f(),t=tu();return e||t},r:function(e){var t=Ze(e);null!==t&&5===t.tag&&"form"===t.type?ao(t):Wd.r(e)},D:function(e){Wd.D(e),Hd("dns-prefetch",e,null)},C:function(e,t){Wd.C(e,t),Hd("preconnect",e,t)},L:function(e,t,l){Wd.L(e,t,l);var n=Vd;if(n&&e&&t){var a='link[rel="preload"][as="'+yt(t)+'"]';"image"===t&&l&&l.imageSrcSet?(a+='[imagesrcset="'+yt(l.imageSrcSet)+'"]',"string"==typeof l.imageSizes&&(a+='[imagesizes="'+yt(l.imageSizes)+'"]')):a+='[href="'+yt(e)+'"]';var r=a;switch(t){case"style":r=Gd(e);break;case"script":r=Yd(e)}Ud.has(r)||(e=b({rel:"preload",href:"image"===t&&l&&l.imageSrcSet?void 0:e,as:t},l),Ud.set(r,e),null!==n.querySelector(a)||"style"===t&&n.querySelector(Qd(r))||"script"===t&&n.querySelector(Jd(r))||(hd(t=n.createElement("link"),"link",e),lt(t),n.head.appendChild(t)))}},m:function(e,t){Wd.m(e,t);var l=Vd;if(l&&e){var n=t&&"string"==typeof t.as?t.as:"script",a='link[rel="modulepreload"][as="'+yt(n)+'"][href="'+yt(e)+'"]',r=a;switch(n){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":r=Yd(e)}if(!Ud.has(r)&&(e=b({rel:"modulepreload",href:e},t),Ud.set(r,e),null===l.querySelector(a))){switch(n){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Jd(r)))return}hd(n=l.createElement("link"),"link",e),lt(n),l.head.appendChild(n)}}},X:function(e,t){Wd.X(e,t);var l=Vd;if(l&&e){var n=tt(l).hoistableScripts,a=Yd(e),r=n.get(a);r||((r=l.querySelector(Jd(a)))||(e=b({src:e,async:!0},t),(t=Ud.get(a))&&lb(e,t),lt(r=l.createElement("script")),hd(r,"link",e),l.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},n.set(a,r))}},S:function(e,t,l){Wd.S(e,t,l);var n=Vd;if(n&&e){var a=tt(n).hoistableStyles,r=Gd(e);t=t||"default";var i=a.get(r);if(!i){var o={loading:0,preload:null};if(i=n.querySelector(Qd(r)))o.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":t},l),(l=Ud.get(r))&&tb(e,l);var s=i=n.createElement("link");lt(s),hd(s,"link",e),s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),s.addEventListener("load",function(){o.loading|=1}),s.addEventListener("error",function(){o.loading|=2}),o.loading|=4,eb(i,t,n)}i={type:"stylesheet",instance:i,count:1,state:o},a.set(r,i)}}},M:function(e,t){Wd.M(e,t);var l=Vd;if(l&&e){var n=tt(l).hoistableScripts,a=Yd(e),r=n.get(a);r||((r=l.querySelector(Jd(a)))||(e=b({src:e,async:!0,type:"module"},t),(t=Ud.get(a))&&lb(e,t),lt(r=l.createElement("script")),hd(r,"link",e),l.head.appendChild(r)),r={type:"script",instance:r,count:1,state:null},n.set(a,r))}}};var Vd="undefined"==typeof document?null:document;function Hd(e,t,l){var n=Vd;if(n&&"string"==typeof t&&t){var a=yt(t);a='link[rel="'+e+'"][href="'+a+'"]',"string"==typeof l&&(a+='[crossorigin="'+l+'"]'),Bd.has(a)||(Bd.add(a),e={rel:e,crossOrigin:l,href:t},null===n.querySelector(a)&&(hd(t=n.createElement("link"),"link",e),lt(t),n.head.appendChild(t)))}}function Kd(e,t,l,n){var a,i,o,s,c=(c=G.current)?qd(c):null;if(!c)throw Error(r(446));switch(e){case"meta":case"title":return null;case"style":return"string"==typeof l.precedence&&"string"==typeof l.href?(t=Gd(l.href),(n=(l=tt(c).hoistableStyles).get(t))||(n={type:"style",instance:null,count:0,state:null},l.set(t,n)),n):{type:"void",instance:null,count:0,state:null};case"link":if("stylesheet"===l.rel&&"string"==typeof l.href&&"string"==typeof l.precedence){e=Gd(l.href);var u=tt(c).hoistableStyles,d=u.get(e);if(d||(c=c.ownerDocument||c,d={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,d),(u=c.querySelector(Qd(e)))&&!u._p&&(d.instance=u,d.state.loading=5),Ud.has(e)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Ud.set(e,l),u||(a=c,i=e,o=l,s=d.state,a.querySelector('link[rel="preload"][as="style"]['+i+"]")?s.loading=1:(i=a.createElement("link"),s.preload=i,i.addEventListener("load",function(){return s.loading|=1}),i.addEventListener("error",function(){return s.loading|=2}),hd(i,"link",o),lt(i),a.head.appendChild(i))))),t&&null===n)throw Error(r(528,""));return d}if(t&&null!==n)throw Error(r(529,""));return null;case"script":return t=l.async,"string"==typeof(l=l.src)&&t&&"function"!=typeof t&&"symbol"!=typeof t?(t=Yd(l),(n=(l=tt(c).hoistableScripts).get(t))||(n={type:"script",instance:null,count:0,state:null},l.set(t,n)),n):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,e))}}function Gd(e){return'href="'+yt(e)+'"'}function Qd(e){return'link[rel="stylesheet"]['+e+"]"}function Xd(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function Yd(e){return'[src="'+yt(e)+'"]'}function Jd(e){return"script[async]"+e}function Zd(e,t,l){if(t.count++,null===t.instance)switch(t.type){case"style":var n=e.querySelector('style[data-href~="'+yt(l.href)+'"]');if(n)return t.instance=n,lt(n),n;var a=b({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return lt(n=(e.ownerDocument||e).createElement("style")),hd(n,"style",a),eb(n,l.precedence,e),t.instance=n;case"stylesheet":a=Gd(l.href);var i=e.querySelector(Qd(a));if(i)return t.state.loading|=4,t.instance=i,lt(i),i;n=Xd(l),(a=Ud.get(a))&&tb(n,a),lt(i=(e.ownerDocument||e).createElement("link"));var o=i;return o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),hd(i,"link",n),t.state.loading|=4,eb(i,l.precedence,e),t.instance=i;case"script":return i=Yd(l.src),(a=e.querySelector(Jd(i)))?(t.instance=a,lt(a),a):(n=l,(a=Ud.get(i))&&lb(n=b({},l),a),lt(a=(e=e.ownerDocument||e).createElement("script")),hd(a,"link",n),e.head.appendChild(a),t.instance=a);case"void":return null;default:throw Error(r(443,t.type))}else"stylesheet"===t.type&&!(4&t.state.loading)&&(n=t.instance,t.state.loading|=4,eb(n,l.precedence,e));return t.instance}function eb(e,t,l){for(var n=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),a=n.length?n[n.length-1]:null,r=a,i=0;i<n.length;i++){var o=n[i];if(o.dataset.precedence===t)r=o;else if(r!==a)break}r?r.parentNode.insertBefore(e,r.nextSibling):(t=9===l.nodeType?l.head:l).insertBefore(e,t.firstChild)}function tb(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.title&&(e.title=t.title)}function lb(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.integrity&&(e.integrity=t.integrity)}var nb=null;function ab(e,t,l){if(null===nb){var n=new Map,a=nb=new Map;a.set(l,n)}else(n=(a=nb).get(l))||(n=new Map,a.set(l,n));if(n.has(e))return n;for(n.set(e,null),l=l.getElementsByTagName(e),a=0;a<l.length;a++){var r=l[a];if(!(r[Xe]||r[qe]||"link"===e&&"stylesheet"===r.getAttribute("rel"))&&"http://www.w3.org/2000/svg"!==r.namespaceURI){var i=r.getAttribute(t)||"";i=e+i;var o=n.get(i);o?o.push(r):n.set(i,[r])}}return n}function rb(e,t,l){(e=e.ownerDocument||e).head.insertBefore(l,"title"===t?e.querySelector("head > title"):null)}function ib(e){return!!("stylesheet"!==e.type||3&e.state.loading)}var ob=0;function sb(){if(this.count--,0===this.count&&(0===this.imgCount||!this.waitingForImages))if(this.stylesheets)ub(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}var cb=null;function ub(e,t){e.stylesheets=null,null!==e.unsuspend&&(e.count++,cb=new Map,t.forEach(db,e),cb=null,sb.call(e))}function db(e,t){if(!(4&t.state.loading)){var l=cb.get(e);if(l)var n=l.get(null);else{l=new Map,cb.set(e,l);for(var a=e.querySelectorAll("link[data-precedence],style[data-precedence]"),r=0;r<a.length;r++){var i=a[r];"LINK"!==i.nodeName&&"not all"===i.getAttribute("media")||(l.set(i.dataset.precedence,i),n=i)}n&&l.set(null,n)}i=(a=t.instance).getAttribute("data-precedence"),(r=l.get(i)||n)===n&&l.set(null,a),l.set(i,a),this.count++,n=sb.bind(this),a.addEventListener("load",n),a.addEventListener("error",n),r?r.parentNode.insertBefore(a,r.nextSibling):(e=9===e.nodeType?e.head:e).insertBefore(a,e.firstChild),t.state.loading|=4}}var bb={$$typeof:k,Provider:null,Consumer:null,_currentValue:R,_currentValue2:R,_threadCount:0};function mb(e,t,l,n,a,r,i,o,s){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Le(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Le(0),this.hiddenUpdates=Le(null),this.identifierPrefix=n,this.onUncaughtError=a,this.onCaughtError=r,this.onRecoverableError=i,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=s,this.incompleteTransitions=new Map}function hb(e,t,l,n,a,r,i,o,s,c,u,d){return e=new mb(e,t,l,i,s,c,u,d,o),t=1,!0===r&&(t|=24),r=Fn(3,null,null,t),e.current=r,r.stateNode=e,(t=Ua()).refCount++,e.pooledCache=t,t.refCount++,r.memoizedState={element:n,isDehydrated:l,cache:t},vr(r),e}function pb(e){return e?e=Rn:Rn}function fb(e,t,l,n,a,r){a=pb(a),null===n.context?n.context=a:n.pendingContext=a,(n=xr(t)).payload={element:l},null!==(r=void 0===r?null:r)&&(n.callback=r),null!==(l=wr(e,n,t))&&(Xc(l,0,t),kr(l,e,t))}function gb(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var l=e.retryLane;e.retryLane=0!==l&&l<t?l:t}}function vb(e,t){gb(e,t),(e=e.alternate)&&gb(e,t)}function yb(e){if(13===e.tag||31===e.tag){var t=In(e,67108864);null!==t&&Xc(t,0,67108864),vb(e,67108864)}}function xb(e){if(13===e.tag||31===e.tag){var t=Gc(),l=In(e,t=Re(t));null!==l&&Xc(l,0,t),vb(e,t)}}var wb=!0;function kb(e,t,l,n){var a=P.T;P.T=null;var r=D.p;try{D.p=2,Sb(e,t,l,n)}finally{D.p=r,P.T=a}}function Cb(e,t,l,n){var a=P.T;P.T=null;var r=D.p;try{D.p=8,Sb(e,t,l,n)}finally{D.p=r,P.T=a}}function Sb(e,t,l,n){if(wb){var a=jb(n);if(null===a)nd(e,t,n,Nb,l),Db(e,n);else if(function(e,t,l,n,a){switch(t){case"focusin":return Tb=Rb(Tb,e,t,l,n,a),!0;case"dragenter":return Ab=Rb(Ab,e,t,l,n,a),!0;case"mouseover":return zb=Rb(zb,e,t,l,n,a),!0;case"pointerover":var r=a.pointerId;return Lb.set(r,Rb(Lb.get(r)||null,e,t,l,n,a)),!0;case"gotpointercapture":return r=a.pointerId,Mb.set(r,Rb(Mb.get(r)||null,e,t,l,n,a)),!0}return!1}(a,e,t,l,n))n.stopPropagation();else if(Db(e,n),4&t&&-1<Pb.indexOf(e)){for(;null!==a;){var r=Ze(a);if(null!==r)switch(r.tag){case 3:if((r=r.stateNode).current.memoizedState.isDehydrated){var i=_e(r.pendingLanes);if(0!==i){var o=r;for(o.pendingLanes|=2,o.entangledLanes|=2;i;){var s=1<<31-ke(i);o.entanglements[1]|=s,i&=~s}Du(r),!(6&pc)&&(Pc=ue()+500,Ru(0))}}break;case 31:case 13:null!==(o=In(r,2))&&Xc(o,0,2),tu(),vb(r,2)}if(null===(r=jb(n))&&nd(e,t,n,Nb,l),r===a)break;a=r}null!==a&&n.stopPropagation()}else nd(e,t,n,null,l)}}function jb(e){return Eb(e=Pt(e))}var Nb=null;function Eb(e){if(Nb=null,null!==(e=Je(e))){var t=o(e);if(null===t)e=null;else{var l=t.tag;if(13===l){if(null!==(e=s(t)))return e;e=null}else if(31===l){if(null!==(e=c(t)))return e;e=null}else if(3===l){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Nb=e,null}function _b(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(de()){case be:return 2;case me:return 8;case he:case pe:return 32;case fe:return 268435456;default:return 32}default:return 32}}var $b=!1,Tb=null,Ab=null,zb=null,Lb=new Map,Mb=new Map,Ib=[],Pb="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Db(e,t){switch(e){case"focusin":case"focusout":Tb=null;break;case"dragenter":case"dragleave":Ab=null;break;case"mouseover":case"mouseout":zb=null;break;case"pointerover":case"pointerout":Lb.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Mb.delete(t.pointerId)}}function Rb(e,t,l,n,a,r){return null===e||e.nativeEvent!==r?(e={blockedOn:t,domEventName:l,eventSystemFlags:n,nativeEvent:r,targetContainers:[a]},null!==t&&(null!==(t=Ze(t))&&yb(t)),e):(e.eventSystemFlags|=n,t=e.targetContainers,null!==a&&-1===t.indexOf(a)&&t.push(a),e)}function Ob(e){var t=Je(e.target);if(null!==t){var l=o(t);if(null!==l)if(13===(t=l.tag)){if(null!==(t=s(l)))return e.blockedOn=t,void Ue(e.priority,function(){xb(l)})}else if(31===t){if(null!==(t=c(l)))return e.blockedOn=t,void Ue(e.priority,function(){xb(l)})}else if(3===t&&l.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===l.tag?l.stateNode.containerInfo:null)}e.blockedOn=null}function Fb(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var l=jb(e.nativeEvent);if(null!==l)return null!==(t=Ze(l))&&yb(t),e.blockedOn=l,!1;var n=new(l=e.nativeEvent).constructor(l.type,l);It=n,l.target.dispatchEvent(n),It=null,t.shift()}return!0}function Ub(e,t,l){Fb(e)&&l.delete(t)}function Bb(){$b=!1,null!==Tb&&Fb(Tb)&&(Tb=null),null!==Ab&&Fb(Ab)&&(Ab=null),null!==zb&&Fb(zb)&&(zb=null),Lb.forEach(Ub),Mb.forEach(Ub)}function qb(e,t){e.blockedOn===t&&(e.blockedOn=null,$b||($b=!0,l.unstable_scheduleCallback(l.unstable_NormalPriority,Bb)))}var Wb=null;function Vb(e){Wb!==e&&(Wb=e,l.unstable_scheduleCallback(l.unstable_NormalPriority,function(){Wb===e&&(Wb=null);for(var t=0;t<e.length;t+=3){var l=e[t],n=e[t+1],a=e[t+2];if("function"!=typeof n){if(null===Eb(n||l))continue;break}var r=Ze(l);null!==r&&(e.splice(t,3),t-=3,lo(r,{pending:!0,data:a,method:l.method,action:n},n,a))}}))}function Hb(e){function t(t){return qb(t,e)}null!==Tb&&qb(Tb,e),null!==Ab&&qb(Ab,e),null!==zb&&qb(zb,e),Lb.forEach(t),Mb.forEach(t);for(var l=0;l<Ib.length;l++){var n=Ib[l];n.blockedOn===e&&(n.blockedOn=null)}for(;0<Ib.length&&null===(l=Ib[0]).blockedOn;)Ob(l),null===l.blockedOn&&Ib.shift();if(null!=(l=(e.ownerDocument||e).$$reactFormReplay))for(n=0;n<l.length;n+=3){var a=l[n],r=l[n+1],i=a[We]||null;if("function"==typeof r)i||Vb(l);else if(i){var o=null;if(r&&r.hasAttribute("formAction")){if(a=r,i=r[We]||null)o=i.formAction;else if(null!==Eb(a))continue}else o=i.action;"function"==typeof o?l[n+1]=o:(l.splice(n,3),n-=3),Vb(l)}}}function Kb(){function e(e){e.canIntercept&&"react-transition"===e.info&&e.intercept({handler:function(){return new Promise(function(e){return a=e})},focusReset:"manual",scroll:"manual"})}function t(){null!==a&&(a(),a=null),n||setTimeout(l,20)}function l(){if(!n&&!navigation.transition){var e=navigation.currentEntry;e&&null!=e.url&&navigation.navigate(e.url,{state:e.getState(),info:"react-transition",history:"replace"})}}if("object"==typeof navigation){var n=!1,a=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(l,100),function(){n=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),null!==a&&(a(),a=null)}}}function Gb(e){this._internalRoot=e}function Qb(e){this._internalRoot=e}Qb.prototype.render=Gb.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(r(409));fb(t.current,Gc(),e,t,null,null)},Qb.prototype.unmount=Gb.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;fb(e.current,2,null,e,null,null),tu(),t[Ve]=null}},Qb.prototype.unstable_scheduleHydration=function(e){if(e){var t=Fe();e={blockedOn:null,target:e,priority:t};for(var l=0;l<Ib.length&&0!==t&&t<Ib[l].priority;l++);Ib.splice(l,0,e),0===l&&Ob(e)}};var Xb=n.version;if("19.2.3"!==Xb)throw Error(r(527,Xb,"19.2.3"));D.findDOMNode=function(e){var t=e._reactInternals;if(void 0===t){if("function"==typeof e.render)throw Error(r(188));throw e=Object.keys(e).join(","),Error(r(268,e))}return e=function(e){var t=e.alternate;if(!t){if(null===(t=o(e)))throw Error(r(188));return t!==e?null:e}for(var l=e,n=t;;){var a=l.return;if(null===a)break;var i=a.alternate;if(null===i){if(null!==(n=a.return)){l=n;continue}break}if(a.child===i.child){for(i=a.child;i;){if(i===l)return u(a),e;if(i===n)return u(a),t;i=i.sibling}throw Error(r(188))}if(l.return!==n.return)l=a,n=i;else{for(var s=!1,c=a.child;c;){if(c===l){s=!0,l=a,n=i;break}if(c===n){s=!0,n=a,l=i;break}c=c.sibling}if(!s){for(c=i.child;c;){if(c===l){s=!0,l=i,n=a;break}if(c===n){s=!0,n=i,l=a;break}c=c.sibling}if(!s)throw Error(r(189))}}if(l.alternate!==n)throw Error(r(190))}if(3!==l.tag)throw Error(r(188));return l.stateNode.current===l?e:t}(t),e=null===(e=null!==e?d(e):null)?null:e.stateNode};var Yb={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:P,reconcilerVersion:"19.2.3"};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var Jb=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Jb.isDisabled&&Jb.supportsFiber)try{ye=Jb.inject(Yb),xe=Jb}catch(em){}}return w.createRoot=function(e,t){if(!i(e))throw Error(r(299));var l=!1,n="",a=No,o=Eo,s=_o;return null!=t&&(!0===t.unstable_strictMode&&(l=!0),void 0!==t.identifierPrefix&&(n=t.identifierPrefix),void 0!==t.onUncaughtError&&(a=t.onUncaughtError),void 0!==t.onCaughtError&&(o=t.onCaughtError),void 0!==t.onRecoverableError&&(s=t.onRecoverableError)),t=hb(e,1,!1,null,0,l,n,null,a,o,s,Kb),e[Ve]=t.current,td(e),new Gb(t)},w.hydrateRoot=function(e,t,l){if(!i(e))throw Error(r(299));var n=!1,a="",o=No,s=Eo,c=_o,u=null;return null!=l&&(!0===l.unstable_strictMode&&(n=!0),void 0!==l.identifierPrefix&&(a=l.identifierPrefix),void 0!==l.onUncaughtError&&(o=l.onUncaughtError),void 0!==l.onCaughtError&&(s=l.onCaughtError),void 0!==l.onRecoverableError&&(c=l.onRecoverableError),void 0!==l.formState&&(u=l.formState)),(t=hb(e,1,!0,t,0,n,a,u,o,s,c,Kb)).context=pb(null),l=t.current,(a=xr(n=Re(n=Gc()))).callback=null,wr(l,a,n),l=n,t.current.lanes=l,Me(t,l),Du(t),e[Ve]=t.current,td(e),new Qb(t)},w.version="19.2.3",w}var N=(y||(y=1,function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}(),x.exports=j()),x.exports);const E=new class{constructor(){this.supportsContainerQueries=this.detectContainerQueries(),this.init()}detectContainerQueries(){if("undefined"==typeof window)return!1;try{if("CSS"in window&&"supports"in window.CSS)return window.CSS.supports("container-type","inline-size");const e=document.createElement("div");return e.style.containerType="inline-size","inline-size"===e.style.containerType}catch{return!1}}init(){"undefined"!=typeof window&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>this.applyClasses()):this.applyClasses())}applyClasses(){document.querySelectorAll(".limbo-component-container-wrapper").forEach(e=>{this.supportsContainerQueries?(e.classList.add("container-queries-supported"),e.classList.remove("container-queries-fallback")):(e.classList.add("container-queries-fallback"),e.classList.remove("container-queries-supported"))}),this.supportsContainerQueries?(document.body.classList.add("container-queries-supported"),document.body.classList.remove("container-queries-fallback")):(document.body.classList.add("container-queries-fallback"),document.body.classList.remove("container-queries-supported"))}getContainerWidth(e){if(!e)return window.innerWidth;let t=e.closest(".limbo-component-container-wrapper");return t||(t=e.closest(".limbo-modal-content")),t||(t=e.closest(".limbo-modal")),t||(t=document.body),t.offsetWidth||t.clientWidth}shouldUseMobileStyles(e,t=768){return this.getContainerWidth(e)<=t}applyResponsiveClasses(e){if(this.supportsContainerQueries)return;const t=this.shouldUseMobileStyles(e),l=this.shouldUseMobileStyles(e,1024)&&!t;e.classList.toggle("limbo-mobile-fallback",t),e.classList.toggle("limbo-tablet-fallback",l),e.classList.toggle("limbo-desktop-fallback",!t&&!l)}observeResize(){if(!this.supportsContainerQueries)if("ResizeObserver"in window){const e=new ResizeObserver(e=>{e.forEach(e=>{this.applyResponsiveClasses(e.target)})});document.querySelectorAll(".limbo-component-container-wrapper").forEach(t=>{e.observe(t)})}else window.addEventListener("resize",()=>{document.querySelectorAll(".limbo-component-container-wrapper").forEach(e=>{this.applyResponsiveClasses(e)})})}};function _(t={}){const{useContainerQuery:l=!1,containerElement:n=null}=t,[a,r]=e.useState(()=>{const e=l&&n?E.getContainerWidth(n):"undefined"!=typeof window?window.innerWidth:0,t="undefined"!=typeof window&&(e<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)),a="undefined"!=typeof window&&("ontouchstart"in window||navigator.maxTouchPoints>0);return{isMobile:t,isTouch:a,isTablet:"undefined"!=typeof window&&(e>768&&e<=1024&&a),orientation:"undefined"!=typeof window?window.innerHeight>window.innerWidth?"portrait":"landscape":"portrait",viewport:{width:"undefined"!=typeof window?window.innerWidth:0,height:"undefined"!=typeof window?window.innerHeight:0},container:{width:e,supportsContainerQueries:E.supportsContainerQueries}}});e.useEffect(()=>{if("undefined"==typeof window)return;const e=()=>{const e=window.innerWidth,t=window.innerHeight,a=l&&n?E.getContainerWidth(n):e,i=a<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),o="ontouchstart"in window||navigator.maxTouchPoints>0;r({isMobile:i,isTouch:o,isTablet:a>768&&a<=1024&&o,orientation:t>e?"portrait":"landscape",viewport:{width:e,height:t},container:{width:a,supportsContainerQueries:E.supportsContainerQueries}})};let t;const a=()=>{clearTimeout(t),t=setTimeout(e,150)};return window.addEventListener("resize",a),window.addEventListener("orientationchange",()=>{setTimeout(e,100)}),()=>{clearTimeout(t),window.removeEventListener("resize",a),window.removeEventListener("orientationchange",e)}},[l,n]);const i="portrait"===a.orientation,o="landscape"===a.orientation,s=a.isMobile||a.isTablet&&i;return{...a,isPortrait:i,isLandscape:o,isCompactMode:s,isMobileSize:a.viewport.width<=640,isTabletSize:a.viewport.width>640&&a.viewport.width<=1024,isDesktopSize:a.viewport.width>1024,deviceClass:a.isMobile?"mobile":a.isTablet?"tablet":"desktop"}}function $({tabs:e,active:t,onChange:n}){const{isMobile:a,isTouch:r}=_(),i=["limbo-tabs","lb:flex","lb:gap-4","lb:border-b-2","lb:border-brand-blue-200","lb:mb-6",a&&"lb:overflow-x-auto lb:scrollbar-none"].filter(Boolean).join(" "),o=e=>{const t=["limbo-tab","lb:relative","lb:px-6","lb:py-2","lb:font-medium","lb:text-brand-blue-1000","lb:bg-transparent","lb:border-0","lb:border-b-2","lb:cursor-pointer","lb:transition-all","lb:duration-200","lb:hover:text-pink-1000","lb:focus:outline-none","lb:focus-visible:ring-2","lb:focus-visible:ring-brand-blue-400","lb:focus-visible:ring-offset-2","lb:min-h-[44px]","lb:min-w-[44px]"];return e?t.push("lb:border-b-brand-blue-1000","lb:font-semibold","limbo-active"):t.push("lb:border-b-transparent"),a&&t.push("lb:min-w-[120px]","lb:text-base","lb:shrink-0"),r&&t.push("lb:touch-manipulation"),t.join(" ")};return l.jsx("div",{className:i,role:"tablist","aria-label":"Opciones de navegación",style:a?{WebkitOverflowScrolling:"touch",scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,children:e.map(a=>{const i=t===a.id;return!i&&a.hideNonActive?null:l.jsx("button",{"data-tab-id":a.id,onClick:()=>n(a.id),onKeyDown:t=>((t,l)=>{const a=e.findIndex(e=>e.id===l);let r=a;switch(t.key){case"ArrowLeft":case"ArrowUp":t.preventDefault(),r=a>0?a-1:e.length-1;break;case"ArrowRight":case"ArrowDown":t.preventDefault(),r=a<e.length-1?a+1:0;break;case"Home":t.preventDefault(),r=0;break;case"End":t.preventDefault(),r=e.length-1;break;case"Enter":case" ":return t.preventDefault(),void n(l);default:return}const i=e[r];i&&!i.hideNonActive&&(n(i.id),setTimeout(()=>{const e=document.querySelector(`[data-tab-id="${i.id}"]`);e&&e.focus()},0))})(t,a.id),className:o(i),role:"tab","aria-selected":i,"aria-controls":`tabpanel-${a.id}`,tabIndex:i?0:-1,id:`tab-${a.id}`,style:r?{WebkitTapHighlightColor:"transparent"}:void 0,children:a.label},a.id)})})}function T({isOpen:e,onReload:t,onClose:n}){return e?l.jsx("div",{className:"lb:fixed lb:inset-0 lb:bg-black/50 lb:flex lb:items-center lb:justify-center lb:z-[9999]",onClick:e=>{e.target===e.currentTarget&&n?.()},children:l.jsxs("div",{className:"lb:bg-white lb:rounded-lg lb:p-6 lb:max-w-sm lb:w-full lb:mx-4 lb:shadow-xl",children:[l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-3 lb:mb-4",children:[l.jsx("div",{className:"lb:flex-shrink-0 lb:w-10 lb:h-10 lb:bg-amber-100 lb:rounded-full lb:flex lb:items-center lb:justify-center",children:l.jsx("svg",{className:"lb:w-5 lb:h-5 lb:text-amber-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"})})}),l.jsxs("div",{children:[l.jsx("h3",{className:"lb:text-base lb:font-semibold lb:text-gray-900",children:"Sesión expirada"}),l.jsx("p",{className:"lb:text-sm lb:text-gray-500 lb:mt-0.5",children:"Tu sesión de Limbo ha caducado por inactividad."})]})]}),l.jsxs("div",{className:"lb:bg-amber-50 lb:rounded-md lb:p-3 lb:mb-5 lb:text-sm lb:text-amber-800",children:[l.jsx("p",{className:"lb:font-medium lb:mb-1",children:"¿Qué puedes hacer?"}),l.jsxs("ul",{className:"lb:list-disc lb:list-inside lb:space-y-1 lb:text-amber-700",children:[l.jsx("li",{children:"Recarga la página para continuar con tu trabajo."}),l.jsx("li",{children:"Si el problema persiste, cierra sesión y vuelve a entrar."})]})]}),l.jsxs("div",{className:"lb:flex lb:justify-end lb:gap-2",children:[n&&l.jsx("button",{type:"button",onClick:n,className:"lb:px-4 lb:py-2 lb:text-sm lb:font-medium lb:text-gray-700 lb:border lb:border-gray-300 lb:rounded-md lb:hover:bg-gray-50 lb:transition-colors",children:"Ignorar"}),l.jsx("button",{type:"button",onClick:t,className:"lb:px-4 lb:py-2 lb:text-sm lb:font-medium lb:bg-brand-blue-800 lb:text-white lb:rounded-md lb:hover:bg-brand-blue-1000 lb:transition-colors",children:"Recargar página"})]})]})}):null}function A(t,l=500){const[n,a]=e.useState(t);return e.useEffect(()=>{const e=setTimeout(()=>{a(t)},l);return()=>{clearTimeout(e)}},[t,l]),n}const z="https://led-dev-limbo-dev.eu.els.local",L="https://limbo.lefebvre.es";let M={publicKey:null,token:null,authMode:null,tokenEndpoint:null,tokenProvider:null,prod:!1},I=!1,P=null,D=null;function R(e){P="number"==typeof e&&e>0?Date.now()+1e3*e-3e4:null}async function O(){if(D)return D;D=(async()=>{if("jwt"===M.authMode&&M.tokenProvider){console.log("🔑 Calling tokenProvider...");const e=await M.tokenProvider(),t="string"==typeof e?e:e?.token,l="object"==typeof e?e?.expires_in:null;if(!t)throw new Error("tokenProvider returned no token");return M.token=t,R(l),console.log("✅ Token obtained from tokenProvider"),t}if("session"===M.authMode){const e=F(M),t=M.tokenEndpoint||"/auth/token",l=await fetch(`${e}${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({public_key:M.publicKey}),credentials:"include"});if(!l.ok)throw new Error(`Session auth failed: ${l.status}`);const n=await l.json();if(!n.token)throw new Error("Session auth returned no token");return M.token=n.token,R(n.expires_in),n.token}throw new Error(`Cannot refresh token in authMode='${M.authMode}'`)})();try{return await D}finally{D=null}}function F({prod:e=!1}={}){return e?L:z}async function U({isFormData:e=!1,useJWT:t=!0,customHeaders:l={}}={}){const n={};if(e||(n["Content-Type"]="application/json"),t){M.token&&null!==P&&Date.now()>=P&&(console.log("⏰ Token caducado por TTL, refrescando proactivamente"),M.token=null,P=null);let e=M.token;if(!e&&("jwt"===M.authMode&&M.tokenProvider||"session"===M.authMode))try{e=await O()}catch(a){throw console.error("❌ Token acquisition failed:",a),new Error("Failed to obtain token: "+a.message)}e?n.Authorization=`Bearer ${e}`:console.warn("⚠️ No JWT token available:",{authMode:M.authMode,hasPublicKey:!!M.publicKey,hasTokenProvider:!!M.tokenProvider})}return e&&delete n["Content-Type"],{...n,...l}}function B(e,t=null){e!==M.token&&(I=!1),M.token=e,R(t)}function q(){return{...M}}async function W({endpoint:e,method:t="GET",body:l=null,prod:n=!1,basePath:a="",customHeaders:r={},isFormData:i=!1,useJWT:o=!0,_isRetry:s=!1}){try{const c=n||M.prod,u=await U({isFormData:i,useJWT:o,customHeaders:r});"GET"===t&&!l&&u["Content-Type"]&&delete u["Content-Type"];const d=await fetch(`${F({prod:c})}${a}${e}`,{method:t,headers:u,body:l?i?l:JSON.stringify(l):void 0,credentials:"include"});if(204===d.status)return{success:!0,data:null,message:"No content",httpCode:204,timestamp:(new Date).toISOString()};if(!d.ok){let c=`HTTP ${d.status}: ${d.statusText}`,u=null;try{const e=await d.json();u=e,e.error?c=`${e.error.code}: ${e.error.message}`:e.message&&(c=e.message)}catch{}if(401===d.status){let c=!1;if("jwt"===M.authMode&&M.tokenProvider&&!s&&I){c=!0,M.token=null,P=null;try{return await O(),W({endpoint:e,method:t,body:l,prod:n,basePath:a,isFormData:i,useJWT:o,customHeaders:r,_isRetry:!0})}catch{}}window.dispatchEvent(new CustomEvent("tokenExpiredError",{detail:{error:{response:{status:401,data:u}},refreshAttempted:c}}))}throw new Error(c)}return o&&(I=!0),d.json()}catch(c){throw new Error(`API Error: ${c.message}`)}}function V(){const e=q();return e?.prod||!1?"https://limbo.lefebvre.es":"https://led-dev-limbo-dev.eu.els.local"}function H(e){if(!e?.id)return null;return`${V()}/api/assets/${e.id}/download`}function K(e){if(!e)return null;if(e.startsWith("http://")||e.startsWith("https://"))return e;if(e.startsWith("/")){return`${V()}${e}`}return e}function G(e){if(!e?.success||!e?.data)return{result:null};const t=e.data;return{result:{id:t.id,filename:t.filename||t.original_filename,mime_type:t.mime_type,file_size:t.file_size,width:t.width,height:t.height,upload_date:t.upload_date||t.created_at,processed_date:t.processed_date,processing_status:t.processing_status||t.status,url:K(t.url)||H(t),url_webp:K(t.url_webp),url_original:K(t.url_original),format:t.format,format_original:t.format_original,permanent:t.permanent??!0,expires_at:t.expires_at,metadata:t.metadata||{},asset_type:t.asset_type||null,asset_subtype:t.asset_subtype||null,thumbnail_url:K(t.thumbnail_url)||null,folder:t.folder||null,tags:t.tags||[],variants:Q(t.variants||[]),variants_count:t.variants_count||t.variants?.length||0}}}function Q(e){return Array.isArray(e)?e.map(e=>({id:e.id,name:e.name,width:e.width,height:e.height,format:e.format||e.output_format,file_size:e.file_size,crop_params:e.crop_params,url:K(e.url),permanent:e.permanent??!0,expires_at:e.expires_at,created_at:e.created_at})):[]}function X(e){if(!e?.success||!e?.data)return{result:null};const t=e.data;if(t.id&&t.url&&t.name&&!t.processing_mode&&!t.variants)return console.log("[adaptVariantGenerationFromV2] Detectado formato de /variants/upload"),{result:{id:t.id,name:t.name,width:t.width,height:t.height,format:t.format,file_size:t.file_size,url:t.url,urlSigned:t.url,status:"completed",created_at:t.created_at||(new Date).toISOString()}};if("sync"===t.processing_mode&&t.variants&&t.variants.length>0){const e=t.variants[0];return{result:{id:e.id||null,name:e.name,width:parseInt(e.size?.split("x")[0])||e.width,height:parseInt(e.size?.split("x")[1])||e.height,format:e.format,file_size:e.file_size,url:e.url,urlSigned:e.url,status:e.status,asset_id:t.asset_id,created_at:e.created_at||(new Date).toISOString(),all_variants:t.variants}}}return{result:{job_id:t.job_id,asset_id:t.asset_id,variants_requested:t.variants_requested||[],processing_mode:t.processing_mode||"async",estimated_completion:t.estimated_completion,variant_statuses:(t.variant_statuses||t.variants||[]).map(e=>({name:e.name,status:e.status,size:e.expected_size||e.size,format:e.format}))}}}function Y(e){if(e.message&&!e.message.includes("API Error:"))return e;let t=e.message||"Unknown API error";return t.startsWith("API Error: ")&&(t=t.substring(11)),new Error(t)}const J="/api";async function Z(e={}){try{const t={url_expires:"0",...e},l=`/assets?${new URLSearchParams(t).toString()}`;return function(e){if(!e?.success||!Array.isArray(e?.data?.data))return{result:[]};const t={result:e.data.data.map(e=>({id:e.id,filename:e.filename||e.original_filename,mime_type:e.mime_type,file_size:e.file_size,width:e.width,height:e.height,upload_date:e.upload_date||e.created_at,processing_status:e.processing_status||e.status,variants:e.variants_count&&(Q(e.variants)||Q(e.image_variants))||[],url:K(e.url)||H(e),url_webp:K(e.url_webp),format:e.format,permanent:e.permanent??!0,expires_at:e.expires_at,folder:e.folder||null,tags:e.tags||[],asset_type:e.asset_type||null,asset_subtype:e.asset_subtype||null,thumbnail_url:K(e.thumbnail_url)||null,metadata:e.metadata||{},variants_count:e.variants_count||0}))};return e.data.pagination&&(t.pagination={page:e.data.pagination.page,limit:e.data.pagination.limit,total:e.data.pagination.total,pages:e.data.pagination.pages}),t}(await W({endpoint:l,method:"GET",basePath:J,useJWT:!0}))}catch(t){throw Y(t)}}async function ee(e,t=null,l=!1,n=null,a=null){try{const r=new FormData;r.append("file",e),t&&r.append("uploaded_by",t),l&&r.append("store_original",l.toString()),n&&r.append("folder",n),a&&Array.isArray(a)&&a.length>0&&a.forEach(e=>r.append("tags[]",e));return function(e){if(!e?.success||!e?.data)return{result:null};const t=e.data;return{result:{id:t.id,filename:t.filename||t.original_filename,mime_type:t.mime_type,file_size:t.file_size,width:t.width,height:t.height,status:t.status,upload_date:t.created_at,url:K(t.url),url_webp:K(t.url_webp),url_original:K(t.url_original),format:t.format,format_original:t.format_original,permanent:t.permanent??!0,folder:t.folder||null,tags:t.tags||[],processing:t.processing||{master_webp:"processing"===t.status?"queued":"completed",variants:"processing"===t.status?"queued":"completed"},asset_type:t.asset_type||null,asset_subtype:t.asset_subtype||null,thumbnail_url:K(t.thumbnail_url)||null,checksum:t.checksum,storage_path:t.storage_path_base,metadata:t.metadata||{}}}}(await W({endpoint:"/assets",method:"POST",body:r,basePath:J,isFormData:!0,useJWT:!0}))}catch(r){throw Y(r)}}async function te(e,t){try{return G(await W({endpoint:`/assets/${e}`,method:"PATCH",body:t,basePath:J,useJWT:!0}))}catch(l){throw Y(l)}}async function le(e,t=0){try{const n=new URLSearchParams({url_expires:t.toString()}),a=await W({endpoint:`/assets/${e}/variants?${n}`,method:"GET",basePath:J,useJWT:!0});return l=a,l?.success&&Array.isArray(l?.data?.variants)?{result:l.data.variants.map(e=>({id:e.id,name:e.filename||e.name||`Variante ${e.id}`,filename:e.filename,mime_type:e.mime_type,format:e.format||e.output_format||(e.mime_type?e.mime_type.split("/")[1]:"jpg"),file_size:e.file_size,width:e.width,height:e.height,upload_date:e.upload_date||e.created_at,processing_status:e.processing_status||e.status,url:K(e.url)||H(e),permanent:e.permanent??!0,expires_at:e.expires_at,metadata:e.metadata||{},crop_data:e.crop_data||{},crop_params:e.crop_params||e.crop_data||{},parent_asset_id:e.parent_asset_id||l.data.asset_id,variant_type:e.variant_type||"crop"}))}:{result:[]}}catch(n){throw Y(n)}var l}function ne({value:t=[],onChange:n,placeholder:a,disabled:r=!1,id:i,ariaLabel:o}){const s=Array.isArray(t)?t:[],[c,u]=e.useState(""),[d,b]=e.useState([]),[m,p]=e.useState(!1),[f,g]=e.useState(-1),v=e.useRef(null),y=e.useRef(null),x=A(c,400);function w(e){const t=e.trim();t&&(s.includes(t)||n?.([...s,t]),u(""))}function k(e){n?.(s.filter(t=>t!==e))}return e.useEffect(()=>{if(x.length<1)return void b([]);let e=!1;return async function({search:e="",limit:t=10}={}){try{const l=new URLSearchParams;e&&l.set("search",e),l.set("limit",String(t));const n=`/tags?${l.toString()}`,a=await W({endpoint:n,method:"GET",basePath:J,useJWT:!0});return(a?.data?.tags||[]).map(e=>({tag:e,count:null}))}catch{return[]}}({search:x,limit:10}).then(t=>{console.log("[TagsInput] listTags response:",t),e||b(Array.isArray(t)?t:[])}).catch(t=>{console.error("[TagsInput] listTags error:",t),e||b([])}),()=>{e=!0}},[x]),e.useEffect(()=>{d.length>0&&x.length>=1&&p(!0)},[d,x]),e.useEffect(()=>{function e(e){if(!v.current)return;y.current&&y.current.contains(e.target)?p(!0):v.current.contains(e.target)||(p(!1),g(-1))}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),l.jsxs("div",{className:"lb:relative lb:w-full lb:flex lb:flex-col lb:gap-2",children:[s.length>0&&l.jsx("div",{className:"lb:flex lb:flex-wrap lb:gap-2 lb:p-2 lb:border lb:border-neutral-gray-200 lb:rounded-md lb:bg-brand-purple-050 lb:max-h-[88px] lb:overflow-y-auto",children:s.map(e=>l.jsxs("span",{className:"lb:inline-flex lb:items-center lb:gap-1 lb:px-2 lb:py-1 lb:bg-brand-purple-050 lb:text-brand-purple-1000 lb:text-xs lb:font-semibold lb:rounded-full lb:border lb:border-brand-purple-200",children:[e,l.jsx("button",{type:"button","aria-label":h("tags.pill.ariaDelete",{tag:e}),onClick:t=>{t.stopPropagation(),k(e)},className:"lb:text-brand-purple-400 lb:hover:text-brand-purple-1000 lb:leading-none lb:cursor-pointer lb:ml-1 lb:w-3 lb:h-3 lb:flex lb:items-center lb:justify-center",children:"×"})]},e))}),l.jsx("div",{role:"combobox","aria-expanded":m,"aria-haspopup":"listbox","aria-label":o||h("tags.input.ariaLabel"),onClick:function(){y.current?.focus()},className:"lb:flex lb:flex-wrap lb:gap-2 lb:p-2 lb:min-h-[42px] lb:border lb:border-neutral-gray-200 lb:rounded-md lb:bg-white lb:focus-within:ring-2 lb:focus-within:ring-brand-purple-400 lb:focus-within:border-brand-purple-400 lb:cursor-text"+(r?" lb:opacity-50 lb:pointer-events-none":""),children:l.jsx("input",{type:"text",id:i,ref:y,value:c,onChange:function(e){u(e.target.value),g(-1)},onKeyDown:function(e){" "!==e.key&&","!==e.key||c.trim()&&(e.preventDefault(),w(c.trim()),u("")),"Enter"===e.key&&f>=0&&d[f]&&(e.preventDefault(),w(d[f].tag),u(""),p(!1),g(-1)),"Backspace"===e.key&&""===c&&s.length>0&&k(s[s.length-1]),"ArrowDown"===e.key&&(e.preventDefault(),g(e=>Math.min(e+1,d.length-1))),"ArrowUp"===e.key&&(e.preventDefault(),g(e=>Math.max(e-1,-1))),"Escape"===e.key&&(p(!1),g(-1))},onFocus:()=>{p(!0)},disabled:r,"aria-autocomplete":"list","aria-controls":"tags-input-listbox",className:"lb:outline-none lb:border-0 lb:bg-transparent lb:text-sm lb:text-neutral-gray-900 lb:placeholder-neutral-gray-300 lb:flex-1 lb:min-w-[80px] lb:py-1",placeholder:a||h("tags.input.placeholder")})}),m&&x.length>=1&&l.jsx("div",{role:"listbox",id:"tags-input-listbox",className:"lb:absolute lb:z-50 lb:mt-1 lb:w-full lb:max-h-48 lb:overflow-y-auto lb:bg-white lb:border lb:border-neutral-gray-100 lb:rounded-md lb:shadow-md lb:top-full lb:float-end",children:0===d.length?l.jsx("div",{className:"lb:px-3 lb:py-2 lb:text-sm lb:text-neutral-gray-500 lb:italic",children:h("tags.autocomplete.empty")}):d.map((e,t)=>l.jsxs("div",{role:"option","aria-selected":t===f,onMouseDown:t=>{t.preventDefault(),function(e){w(e.tag),u(""),p(!1),g(-1)}(e)},className:"lb:px-3 lb:py-2 lb:text-sm lb:text-neutral-gray-900 lb:cursor-pointer lb:hover:bg-brand-purple-050 lb:flex lb:items-center lb:justify-between"+(t===f?" lb:bg-brand-purple-050":""),children:[l.jsx("span",{children:e.tag}),l.jsx("span",{className:"lb:text-xs lb:text-neutral-gray-500",children:e.count})]},e.tag))})]})}const ae=["button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"]):not([disabled])',"a[href]"].join(", "),re=e=>{if("true"===e.getAttribute("aria-hidden"))return!1;if(e.hasAttribute("inert"))return!1;if(e.hasAttribute("hidden"))return!1;let t=e.parentElement;for(;t;){if(t.hasAttribute("inert"))return!1;if("true"===t.getAttribute("aria-hidden"))return!1;t=t.parentElement}return!0};function ie(t,{onClose:l,isActive:n=!0}={}){e.useEffect(()=>{if(!n)return;const e=t?.current;if(!e)return;const a=t=>{if("Escape"===t.key)return t.preventDefault(),void l?.();if("Tab"!==t.key)return;const n=(a=e,Array.from(a.querySelectorAll(ae)).filter(re));var a;if(0===n.length)return void t.preventDefault();const r=n[0],i=n[n.length-1],o=document.activeElement;t.shiftKey?o!==r&&e.contains(o)||(t.preventDefault(),i.focus()):o===i&&(t.preventDefault(),r.focus())};return e.addEventListener("keydown",a),()=>e.removeEventListener("keydown",a)},[t,l,n])}function oe({isOpen:t,asset:n,onClose:a,onSave:r}){const[i,o]=e.useState(""),[s,c]=e.useState([]),[u,d]=e.useState(!1),[b,m]=e.useState(null),p=e.useRef(null),f=e.useRef(null);if(e.useEffect(()=>{n?.id&&(o(n.filename??n.original_filename??""),c(Array.isArray(n.tags)?n.tags:[]))},[n?.id]),ie(p,{onClose:a,isActive:t}),e.useEffect(()=>{t&&setTimeout(()=>f.current?.focus(),0)},[t]),!t||!n)return null;return l.jsx("div",{className:"lb:fixed lb:inset-0 lb:bg-black/50 lb:flex lb:items-center lb:justify-center lb:z-[9999]",onClick:function(e){e.target===e.currentTarget&&a()},children:l.jsxs("div",{ref:p,role:"dialog","aria-modal":"true","aria-labelledby":"edit-asset-modal-title",className:"lb:bg-white lb:rounded-lg lb:p-6 lb:max-w-md lb:w-full lb:mx-4 lb:shadow-xl",children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:mb-5",children:[l.jsx("h2",{id:"edit-asset-modal-title",className:"lb:text-base lb:font-semibold lb:text-neutral-gray-900",children:h("editAssetModal.title")}),l.jsx("button",{type:"button","aria-label":h("editAssetModal.close"),onClick:a,className:"lb:text-neutral-gray-400 lb:hover:text-neutral-gray-700 lb:p-1 lb:rounded",children:"×"})]}),l.jsxs("div",{className:"lb:mb-4",children:[l.jsx("label",{htmlFor:"edit-asset-name",className:"lb:block lb:text-sm lb:font-semibold lb:text-neutral-gray-700 lb:mb-2",children:h("editAssetModal.nameLabel")}),l.jsx("input",{id:"edit-asset-name",ref:f,type:"text",value:i,onChange:e=>o(e.target.value),disabled:u,className:"lb:w-full lb:px-3 lb:py-2 lb:text-sm lb:border lb:border-neutral-gray-200 lb:rounded-md lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:text-neutral-gray-900"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"lb:block lb:text-sm lb:font-semibold lb:text-neutral-gray-700 lb:mb-2 lb:mt-4",children:h("tags.input.label")}),l.jsx(ne,{value:s,onChange:c,disabled:u,id:"edit-asset-tags"}),l.jsx("p",{className:"lb:text-xs lb:text-neutral-gray-500 lb:mt-2",children:h("tags.input.hint")})]}),b&&l.jsx("p",{className:"lb:text-xs lb:text-red-800 lb:mt-3",children:b}),l.jsxs("div",{className:"lb:flex lb:justify-end lb:gap-2 lb:mt-6",children:[l.jsx("button",{type:"button",onClick:a,disabled:u,className:"lb:px-4 lb:py-2 lb:text-sm lb:font-semibold lb:text-neutral-gray-700 lb:border lb:border-neutral-gray-300 lb:rounded-md lb:hover:bg-neutral-gray-050 lb:transition-colors",children:h("editAssetModal.cancel")}),l.jsx("button",{type:"button",onClick:async function(){d(!0),m(null);try{await r({name:i,tags:s}),a()}catch(e){m(e.message||h("editAssetModal.saveError"))}finally{d(!1)}},disabled:u,className:"lb:px-4 lb:py-2 lb:text-sm lb:font-semibold lb:bg-brand-blue-800 lb:text-white lb:rounded-md lb:hover:bg-brand-blue-1000 lb:transition-colors"+(u?" lb:opacity-70 lb:cursor-not-allowed":""),children:h("editAssetModal.save")})]})]})})}function se(){const[t,l]=e.useState(!1),[n,a]=e.useState(null);return{deleteImg:async e=>{if(!e)return a("ID de imagen no proporcionado"),!1;l(!0),a(null);try{const t=await async function(e){try{return await W({endpoint:`/assets/${e}`,method:"DELETE",basePath:J,useJWT:!0})}catch(n){throw Y(n)}}(e);return!1!==t.success}catch(t){return a(t.message),!1}finally{l(!1)}},loading:t,error:n,reset:()=>{a(null)}}}const ce=new Map,ue=6e5,de="limbo_gallery_cache";(()=>{try{const e=sessionStorage.getItem(de);if(e){const t=JSON.parse(e),l=Date.now();let n=!1;if(Object.entries(t).forEach(([e,t])=>{t.timestamp&&l-t.timestamp<ue?ce.set(e,t):n=!0}),n)if(0===ce.size)sessionStorage.removeItem(de);else{const e={};ce.forEach((t,l)=>{e[l]=t}),sessionStorage.setItem(de,JSON.stringify(e))}}}catch{}})();const be=()=>{ce.clear();try{sessionStorage.removeItem(de)}catch{}};function me(t,l=!1,n={},a=!0){const r=e.useMemo(()=>JSON.stringify(n),[n]),i=e.useRef((()=>{const e=r,t=ce.get(e),l=Date.now();return t&&l-t.timestamp<ue?{images:t.data,pagination:t.pagination||null,loading:!1}:{images:[],pagination:null,loading:a}})()),[o,s]=e.useState(i.current.images),[c,u]=e.useState(i.current.loading),[d,b]=e.useState(null),[m,h]=e.useState(i.current.pagination),[p,f]=e.useState(0),[g,v]=e.useState(0);e.useEffect(()=>{if(!a)return void u(!1);const e=`${r}`,t=ce.get(e),l=Date.now();if(t&&l-t.timestamp<ue)return s(t.data),h(t.pagination||null),void u(!1);u(!0);let i=!0;return(async()=>{if(p>=3)i&&(b("Error de autenticación: Verifica tus credenciales API"),u(!1));else try{const t=await Z(n);if(!i)return;const a=t.result||t.data||[],r=t.pagination||null;s(a),h(r),b(null),f(0),ce.set(e,{data:a,pagination:r,timestamp:l}),(()=>{try{const e={};ce.forEach((t,l)=>{e[l]=t}),sessionStorage.setItem(de,JSON.stringify(e))}catch{}})()}catch(t){i&&(b(t.message),f(e=>e+1))}finally{i&&u(!1)}})(),()=>{i=!1}},[t,l,r,p,a,g]);return{images:o,loading:c,error:d,pagination:m,setImages:s,invalidateCache:()=>{ce.clear();try{sessionStorage.removeItem(de)}catch{}},refetch:()=>{ce.clear();try{sessionStorage.removeItem(de)}catch{}u(!0),v(e=>e+1)}}}function he(){const[t,l]=e.useState({}),[n,a]=e.useState({}),[r,i]=e.useState({});return{loadVariants:e.useCallback(async(e,r=!1)=>{if(e&&!n[e]){if(!r&&t[e])return t[e];a(t=>({...t,[e]:!0})),i(t=>({...t,[e]:null}));try{const t=await le(e),n=t?.result||[];return l(t=>({...t,[e]:n})),n}catch(o){return console.error("Error loading variants:",o),i(t=>({...t,[e]:o.message})),[]}finally{a(t=>({...t,[e]:!1}))}}},[t,n]),getVariants:e.useCallback(e=>t[e]||[],[t]),isLoading:e.useCallback(e=>n[e]||!1,[n]),getError:e.useCallback(e=>r[e]||null,[r]),clearVariants:e.useCallback(e=>{l(t=>{const l={...t};return delete l[e],l}),a(t=>{const l={...t};return delete l[e],l}),i(t=>{const l={...t};return delete l[e],l})},[]),refreshVariants:e.useCallback(async e=>{if(e){a(t=>({...t,[e]:!0})),i(t=>({...t,[e]:null}));try{const t=await le(e),n=t?.result||[];return l(t=>({...t,[e]:n})),n}catch(t){return console.error("Error refreshing variants:",t),i(l=>({...l,[e]:t.message})),[]}finally{a(t=>({...t,[e]:!1}))}}},[]),removeVariant:e.useCallback(async(e,t)=>{try{return await async function(e,t){try{return await W({endpoint:`/assets/${e}/variants/${t}`,method:"DELETE",basePath:J,useJWT:!0})}catch(l){throw Y(l)}}(e,t),l(l=>{const n=l[e]||[];return{...l,[e]:n.filter(e=>e.id!==t)}}),{success:!0}}catch(n){return console.error("Error deleting variant:",n),{success:!1,error:n.message}}},[])}}function pe(){return l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:gap-2 lb:py-2 lb:px-4 lb:border-t lb:h-8 lb:border-brand-purple-200 lb:bg-brand-purple-50 lb:rounded-b-md lb:mt-3",style:{background:"linear-gradient(90deg,#001978,#2134f1 50%,#f81bbd 95%)",color:"white"},children:[l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 52",fill:"currentColor",className:"lb:w-5 lb:h-5 lb:text-white","aria-hidden":"true",children:[l.jsx("path",{d:"M29.0863 15.2704H24.9419V36.7321H37.5259V33.1048H29.0863V15.2704Z"}),l.jsx("path",{d:"M18.1601 33.1048H9.72056V36.7321H22.3045V15.2704H18.1601V33.1048Z"}),l.jsx("path",{d:"M44.0063 51.846L3.16483 50.1834C1.35636 50.1834 0 48.5965 0 46.8584V4.99294C0 3.33041 1.65777 1.8946 3.31554 1.81903L44.157 0.1565C46.2669 0.0809304 48 1.74346 48 3.8594V47.8408C48 50.0323 46.1915 51.846 43.9309 51.7704H44.0063V51.846ZM4.89796 46.405L42.9513 47.4629C43.4788 47.4629 44.0063 47.0095 44.0063 46.4805V5.21965C44.0063 4.69066 43.6295 4.31282 43.102 4.31282L4.82261 5.67307C4.14443 5.67307 3.61695 6.27762 3.61695 6.95775V45.1203C3.61695 45.8004 4.14443 46.3294 4.82261 46.405H4.89796Z"})]}),l.jsxs("span",{className:"lb:text-xs lb:text-neutral-50",children:["Powered by ",l.jsx("span",{className:"lb:font-semibold lb:text-white",children:"Limbo"})]})]})}function fe({variant:t="info",toast:n=!1,fixed:a=!1,onClose:r,className:i="",children:o,role:s}){const[c,u]=e.useState(!1);if(e.useEffect(()=>{u(!1)},[o]),c)return null;const d=n||a?`${a?"lb:fixed lb:top-4 lb:right-4 lb:z-10000":n?"lb:absolute lb:top-5 lb:right-5 lb:w-fit lb:m-4 lb:z-50":""} ${{success:"lb:bg-green-600",danger:"lb:bg-red-500",warning:"lb:bg-yellow-500",info:"lb:bg-blue-500"}[t]||"lb:bg-gray-600"} lb:text-white lb:px-5 lb:py-3 lb:rounded-lg lb:shadow-lg lb:transition-all lb:duration-300 lb:animate-fade-in`:`limbo-alert limbo-alert-${t}`;return l.jsxs("div",{className:`${d} lb:pr-8 ${i}`,role:s||"alert",children:[o,l.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),r?r():u(!0)},className:"lb:absolute lb:top-1/2 lb:-translate-y-1/2 lb:right-2 lb:p-1 lb:rounded-full lb:opacity-60 lb:hover:opacity-100 lb:transition-opacity lb:cursor-pointer","aria-label":"Cerrar",children:l.jsx("span",{className:"icon icon-close-small-white icon--sm","aria-hidden":"true"})})]})}"undefined"!=typeof window&&window.addEventListener("pageshow",e=>{e.persisted&&be()});const ge=new Map,ve=new Map,ye=18e5;if("undefined"!=typeof document){const e=18e5;let t=null;document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState?t=Date.now():"visible"===document.visibilityState&&null!==t&&(Date.now()-t>e&&(ge.forEach(({blobUrl:e})=>{try{URL.revokeObjectURL(e)}catch{}}),ge.clear(),ve.clear()),t=null)}),window.addEventListener("pageshow",e=>{e.persisted&&(ge.forEach(({blobUrl:e})=>{try{URL.revokeObjectURL(e)}catch{}}),ge.clear(),ve.clear())})}const xe=async(e,{bypassHttpCache:t=!1}={})=>{if(!e)return Promise.reject(new Error("No URL provided"));const l=ge.get(e);if(l&&Date.now()-l.timestamp<ye)return l.blobUrl;if(ve.has(e))return ve.get(e);const n=(async()=>{try{let n,a,r=0;const i=t?{cache:"reload"}:{};for(;r<2;)try{if(n=await fetch(e,i),!n.ok)throw new Error(`Failed to fetch image: ${n.status}`);break}catch(l){if(a=l,r+=1,r>=2)throw a}const o=await n.blob(),s=URL.createObjectURL(o);return ge.set(e,{blobUrl:s,timestamp:Date.now(),size:o.size}),s}finally{ve.delete(e)}})();return ve.set(e,n),n},we=e=>{const t=ge.get(e);return t&&Date.now()-t.timestamp<ye?t.blobUrl:e},ke=e=>{const t=ge.get(e);return t&&Date.now()-t.timestamp<ye},Ce=async(e,t=4)=>{const l=new Map,n=e.filter(e=>!ke(e));if(0===n.length)return e.forEach(e=>{l.set(e,we(e))}),l;const a=[];for(let r=0;r<n.length;r+=t)a.push(n.slice(r,r+t));for(const r of a){(await Promise.allSettled(r.map(async e=>({url:e,blobUrl:await xe(e)})))).forEach(e=>{"fulfilled"===e.status&&l.set(e.value.url,e.value.blobUrl)})}return l},Se=e=>{if(!e)return;const t=ge.get(e);if(t){try{URL.revokeObjectURL(t.blobUrl)}catch{}ge.delete(e)}ve.delete(e)},je=()=>{ge.forEach(({blobUrl:e})=>{try{URL.revokeObjectURL(e)}catch{}}),ge.clear(),ve.clear()};function Ne({isOpen:t=!1,onClose:n,title:a="",subtitle:r="",headerActions:i=null,footerHints:o=null,ariaLabel:s="Visor de archivo",children:c}){const u=e.useRef(null),d=e.useCallback(e=>{"Escape"===e.key&&(e.preventDefault(),n?.())},[n]);return e.useEffect(()=>{if(t)return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,d]),e.useEffect(()=>(document.body.style.overflow=t?"hidden":"",()=>{document.body.style.overflow=""}),[t]),t?l.jsxs("div",{className:"lb:fixed lb:inset-0 lb:bg-black/95 lb:z-[10000] lb:flex lb:flex-col",role:"dialog","aria-modal":"true","aria-label":s,children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:px-4 lb:py-3 lb:bg-black/50 lb:backdrop-blur-sm",children:[l.jsxs("div",{className:"lb:flex-1 lb:min-w-0",children:[a&&l.jsx("h2",{className:"lb:text-white lb:font-medium lb:text-sm lb:truncate",children:a.includes(".")?a.split(".").slice(0,-1).join("."):a}),r&&l.jsx("p",{className:"lb:text-gray-400 lb:text-xs lb:mt-0.5 lb:truncate",children:r})]}),i&&l.jsx("div",{className:"lb:flex lb:items-center lb:gap-2 lb:mx-4",children:i}),l.jsx("button",{type:"button",onClick:n,className:"lb:w-10 lb:h-10 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-white/10 lb:hover:bg-red-1000/80 lb:text-white lb:transition-colors","aria-label":"Cerrar visor (ESC)",title:"Cerrar (ESC)",children:l.jsx("svg",{className:"lb:w-6 lb:h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),l.jsx("div",{ref:u,className:"lb:flex-1 lb:overflow-hidden lb:flex lb:items-center lb:justify-center",onClick:e=>{e.target===u.current&&n?.()},children:c}),o&&l.jsx("div",{className:"lb:px-4 lb:py-2 lb:bg-black/50 lb:backdrop-blur-sm lb:text-center",children:l.jsx("p",{className:"lb:text-gray-400 lb:text-xs",children:o})})]}):null}function Ee({isOpen:t=!1,src:n,title:a="",subtitle:r="",onClose:i}){const[o,s]=e.useState(!1),[c,u]=e.useState(!0),d=e.useRef(null);e.useEffect(()=>{t&&(s(!1),u(!0))},[t]);const b=e.useCallback(e=>{" "===e.key&&d.current&&(e.preventDefault(),d.current.paused?d.current.play():d.current.pause())},[]);e.useEffect(()=>{if(t)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[t,b]);const m=l.jsxs("button",{type:"button",onClick:async()=>{if(n)try{const e=await fetch(n,{mode:"cors"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const t=await e.blob(),l=URL.createObjectURL(t),r=document.createElement("a");r.href=l,r.download=a||"video",r.style.display="none",document.body.appendChild(r),r.click(),setTimeout(()=>{URL.revokeObjectURL(l),document.body.removeChild(r)},100)}catch{window.open(n,"_blank")}},className:"lb:flex lb:items-center lb:gap-2 lb:px-3 lb:py-1.5 lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:text-sm lb:transition-colors","aria-label":"Descargar video",title:"Descargar video",children:[l.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),l.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Descargar"})]}),h=l.jsxs("span",{children:[l.jsxs("span",{className:"lb:hidden lb:sm:inline",children:[l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"Espacio"})," ","para pausar/reproducir •"," "]}),l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return l.jsx(Ne,{isOpen:t,onClose:i,title:a,subtitle:r,ariaLabel:"Visor de video",headerActions:m,footerHints:h,children:o?l.jsxs("div",{className:"lb:text-center lb:text-white",children:[l.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),l.jsx("p",{className:"lb:text-lg lb:font-medium",children:"No se puede reproducir el video"}),l.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:a})]}):l.jsxs("div",{className:"lb:relative lb:w-full lb:max-w-5xl lb:max-h-full lb:flex lb:items-center lb:justify-center lb:px-4",children:[c&&l.jsx("div",{className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center",children:l.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-white/20 lb:border-t-white lb:rounded-full lb:animate-spin"})}),l.jsx("video",{ref:d,src:n,className:"lb:max-w-full lb:max-h-[calc(100vh-140px)] lb:h-full lb:w-full lb:rounded-lg",controls:!0,autoPlay:!0,preload:"metadata",onCanPlay:()=>u(!1),onError:()=>{s(!0),u(!1)},children:"Tu navegador no soporta la reproduccion de video."})]})})}function _e({isOpen:t=!1,src:n,title:a="",subtitle:r="",onClose:i}){const[o,s]=e.useState(!1),[c,u]=e.useState(!1),[d,b]=e.useState(0),[m,h]=e.useState(0),p=e.useRef(null);e.useEffect(()=>{t&&(u(!1),s(!1),b(0),h(0))},[t]);const f=e.useCallback(()=>{p.current&&(p.current.paused?p.current.play():p.current.pause())},[]),g=e.useCallback(e=>{" "===e.key&&(e.preventDefault(),f())},[f]);e.useEffect(()=>{if(t)return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[t,g]);const v=e=>{if(!e||isNaN(e))return"0:00";return`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,"0")}`},y=l.jsxs("button",{type:"button",onClick:async()=>{if(n)try{const e=await fetch(n,{mode:"cors"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const t=await e.blob(),l=URL.createObjectURL(t),r=document.createElement("a");r.href=l,r.download=a||"audio",r.style.display="none",document.body.appendChild(r),r.click(),setTimeout(()=>{URL.revokeObjectURL(l),document.body.removeChild(r)},100)}catch{window.open(n,"_blank")}},className:"lb:flex lb:items-center lb:gap-2 lb:px-3 lb:py-1.5 lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:text-sm lb:transition-colors","aria-label":"Descargar audio",title:"Descargar audio",children:[l.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),l.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Descargar"})]}),x=l.jsxs("span",{children:[l.jsxs("span",{className:"lb:hidden lb:sm:inline",children:[l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"Espacio"})," ","para pausar/reproducir •"," "]}),l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return l.jsx(Ne,{isOpen:t,onClose:i,title:a,subtitle:r,ariaLabel:"Visor de audio",headerActions:y,footerHints:x,children:c?l.jsxs("div",{className:"lb:text-center lb:text-white",children:[l.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),l.jsx("p",{className:"lb:text-lg lb:font-medium",children:"No se puede reproducir el audio"}),l.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:a})]}):l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-8 lb:w-full lb:max-w-md lb:px-4",children:[l.jsxs("div",{className:"lb:relative",children:[l.jsx("div",{className:"lb:w-40 lb:h-40 lb:flex lb:items-center lb:justify-center lb:rounded-full lb:bg-linear-to-br lb:from-purple-600/30 lb:to-blue-600/30 lb:border-2 lb:border-white/10 "+(o?"lb:animate-pulse":""),children:l.jsx("span",{className:"icon icon-audio lb:text-white lb:w-16 lb:h-16"})}),l.jsx("button",{type:"button",onClick:f,className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center lb:rounded-full lb:bg-black/0 lb:hover:bg-white/10 lb:transition-colors lb:cursor-pointer","aria-label":o?"Pausar":"Reproducir",children:l.jsx("div",{className:"lb:w-14 lb:h-14 lb:rounded-full lb:bg-white/90 lb:flex lb:items-center lb:justify-center lb:shadow-lg",children:l.jsx("span",{className:`icon ${o?"icon-pause":"icon-play"} icon--lg lb:text-gray-800 ${o?"":"lb:ml-0.5"}`})})})]}),l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-3 lb:text-white lb:text-sm",children:[l.jsx("span",{className:"lb:font-mono lb:min-w-[3ch] lb:text-right",children:v(m)}),l.jsx("div",{className:"lb:w-64 lb:h-2 lb:bg-white/20 lb:rounded-full lb:cursor-pointer lb:relative",onClick:e=>{if(!p.current||!d)return;const t=e.currentTarget.getBoundingClientRect(),l=(e.clientX-t.left)/t.width;p.current.currentTime=l*d},role:"slider","aria-label":"Progreso de audio","aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":d,tabIndex:0,children:l.jsx("div",{className:"lb:h-full lb:bg-purple-500 lb:rounded-full lb:transition-all lb:duration-100",style:{width:d>0?m/d*100+"%":"0%"}})}),l.jsx("span",{className:"lb:font-mono lb:min-w-[3ch] lb:text-gray-400",children:v(d)})]}),l.jsx("audio",{ref:p,src:n,onPlay:()=>s(!0),onPause:()=>s(!1),onTimeUpdate:()=>h(p.current?.currentTime||0),onLoadedMetadata:()=>b(p.current?.duration||0),onEnded:()=>{s(!1),h(0)},onError:()=>u(!0),preload:"metadata"})]})})}function $e({isOpen:t=!1,src:n,title:a="",subtitle:r="",onClose:i}){const[o,s]=e.useState(!0),[c,u]=e.useState(!1),[d,b]=e.useState(null),m=e.useRef(null);e.useEffect(()=>{if(!t||!n)return;let e=!1;return s(!0),u(!1),fetch(n).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.blob()}).then(t=>{if(e)return;m.current&&URL.revokeObjectURL(m.current);const l=URL.createObjectURL(t);m.current=l,b(l)}).catch(()=>{e||(u(!0),s(!1))}),()=>{e=!0}},[n,t]),e.useEffect(()=>()=>{m.current&&(URL.revokeObjectURL(m.current),m.current=null)},[]);const h=()=>{if(!n)return;const e=document.createElement("a");e.href=n,e.download=a||"document.pdf",e.target="_blank",document.body.appendChild(e),e.click(),document.body.removeChild(e)},p=l.jsxs("button",{type:"button",onClick:h,className:"lb:flex lb:items-center lb:gap-2 lb:px-3 lb:py-1.5 lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:text-sm lb:transition-colors","aria-label":"Abrir PDF en nueva pestaña",title:"Abrir PDF en nueva pestaña",children:[l.jsx("span",{className:"icon icon-arrow-left-white lb:rotate-40 lb:me-0 lb:pe-0 icon--sm"}),l.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Abrir en nueva pestaña"})]}),f=l.jsxs("span",{children:[l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return l.jsx(Ne,{isOpen:t,onClose:i,title:a,subtitle:r,ariaLabel:"Visor de PDF",headerActions:p,footerHints:f,children:c?l.jsxs("div",{className:"lb:text-center lb:text-white",children:[l.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),l.jsx("p",{className:"lb:text-lg lb:font-medium",children:"No se puede mostrar el PDF"}),l.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:a}),l.jsx("button",{type:"button",onClick:h,className:"lb:mt-4 lb:px-6 lb:py-2.5 lb:bg-white lb:text-gray-900 lb:rounded-lg lb:font-medium lb:text-sm lb:hover:bg-gray-100 lb:transition-colors",children:"Descargar PDF"})]}):l.jsxs("div",{className:"lb:relative lb:w-full lb:h-full lb:px-4 lb:py-2",children:[o&&l.jsx("div",{className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center lb:z-10",children:l.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-white/20 lb:border-t-white lb:rounded-full lb:animate-spin"})}),d&&l.jsx("iframe",{src:d,title:a||"PDF Viewer",className:"lb:w-full lb:h-full lb:rounded-lg lb:bg-white",onLoad:()=>s(!1),onError:()=>{u(!0),s(!1)}})]})})}const Te={"application/pdf":{symbol:"icon-doc-pdf",label:"PDF",color:"#dc2626"},"application/msword":{symbol:"icon-doc-word",label:"DOC",color:"#2563eb"},"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{symbol:"icon-doc-word",label:"DOCX",color:"#2563eb"},"application/vnd.ms-excel":{symbol:"icon-doc-xls",label:"XLS",color:"#16a34a"},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":{symbol:"icon-doc-xls",label:"XLSX",color:"#16a34a"},"application/vnd.ms-powerpoint":{symbol:"icon-doc-ppt",label:"PPT",color:"#ea580c"},"application/vnd.openxmlformats-officedocument.presentationml.presentation":{symbol:"icon-doc-ppt",label:"PPTX",color:"#ea580c"},"text/plain":{symbol:"icon-doc-text",label:"TXT",color:"#6b7280"},"text/csv":{symbol:"icon-doc-report",label:"CSV",color:"#16a34a"},"audio/mp3":{symbol:"icon-support-person",label:"MP3",color:"#0891b2"},"audio/mpeg":{symbol:"icon-support-person",label:"MP3",color:"#0891b2"},"audio/wav":{symbol:"icon-support-person",label:"WAV",color:"#0891b2"},"audio/ogg":{symbol:"icon-support-person",label:"OGG",color:"#0891b2"},"video/mp4":{symbol:"icon-video",label:"MP4",color:"#7c3aed"},"video/x-msvideo":{symbol:"icon-video",label:"AVI",color:"#7c3aed"},"video/x-matroska":{symbol:"icon-video",label:"MKV",color:"#7c3aed"},default:{symbol:"icon-clip",label:"FILE",color:"#6b7280"}},Ae={video:{symbol:"🎬",label:"VIDEO",color:"#7c3aed"},audio:{symbol:"🎵",label:"AUDIO",color:"#0891b2"},document:{symbol:"📄",label:"DOC",color:"#6b7280"},image:{symbol:"🖼️",label:"IMG",color:"#0ea5e9"}};function ze(e,t){return Te[e]?Te[e]:t&&Ae[t]?Ae[t]:e?.startsWith("video/")?Ae.video:e?.startsWith("audio/")?Ae.audio:e?.startsWith("image/")?Ae.image:Te.default}function Le(e){if(!e||0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return Math.round(e/Math.pow(1024,t)*100)/100+" "+["Bytes","KB","MB","GB"][t]}function Me({file:e,mimeType:t,category:n}){const a=ze(t,n),r=e?.name||"archivo",i=Le(e?.size);return l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:min-h-50",children:[l.jsx("div",{className:"lb:w-24 lb:h-24 lb:flex lb:items-center lb:justify-center lb:bg-gray-100 lb:rounded-xl lb:mb-4",children:l.jsx("span",{className:`icon ${a.symbol} lb:h-[55%] lb:w-[55%] lb:max-h-50 lb:max-w-50`,"aria-hidden":"true"})}),l.jsx("p",{className:"lb:text-sm lb:font-medium lb:text-gray-800 lb:text-center lb:max-w-full lb:truncate lb:px-4",children:r}),l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:mt-3",children:[l.jsx("span",{className:"lb:text-xs lb:text-gray-500",children:i}),l.jsx("span",{className:"lb:text-xs lb:font-bold lb:uppercase lb:px-2 lb:py-0.5 lb:rounded",style:{backgroundColor:a.color,color:"white"},children:a.label})]})]})}function Ie({isOpen:e=!1,src:t,title:n="",subtitle:a="",mimeType:r="",fileSize:i=0,onClose:o}){const s=ze(r),c=l.jsxs("span",{children:[l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return l.jsx(Ne,{isOpen:e,onClose:o,title:n,subtitle:a,ariaLabel:"Visor de documento",footerHints:c,children:l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-6 lb:text-center lb:px-4",children:[l.jsx("div",{className:"lb:w-32 lb:h-32 lb:flex lb:items-center lb:justify-center lb:bg-white/5 lb:rounded-2xl lb:border lb:border-white/10",children:l.jsx("span",{className:`icon ${s.symbol}-white lb:min-w-16 lb:min-h-16`,"aria-hidden":"true"})}),l.jsx("span",{className:"lb:text-sm lb:font-bold lb:uppercase lb:px-4 lb:py-1.5 lb:rounded-full",style:{backgroundColor:s.color,color:"white"},children:s.label}),l.jsxs("div",{children:[l.jsx("p",{className:"lb:text-white lb:font-medium lb:text-lg lb:max-w-md lb:truncate",children:n}),i>0&&l.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-1",children:Le(i)})]}),l.jsx("p",{className:"lb:text-gray-500 lb:text-sm",children:"Este tipo de archivo no se puede previsualizar"}),l.jsxs("button",{type:"button",onClick:async()=>{if(t)try{const e=await fetch(t,{mode:"cors"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const l=await e.blob(),a=URL.createObjectURL(l),r=document.createElement("a");r.href=a,r.download=n||"document",r.style.display="none",document.body.appendChild(r),r.click(),setTimeout(()=>{URL.revokeObjectURL(a),document.body.removeChild(r)},100)}catch{window.open(t,"_blank")}},className:"lb:flex lb:items-center lb:gap-2 lb:px-8 lb:py-3 lb:bg-white lb:text-gray-900 lb:rounded-lg lb:font-medium lb:text-sm lb:hover:bg-gray-100 lb:transition-colors lb:shadow-lg","aria-label":"Descargar archivo",children:[l.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),"Descargar archivo"]})]})})}const Pe=2097152;function De({isOpen:t=!1,src:n,title:a="",subtitle:r="",mimeType:i="",onClose:o}){const[s,c]=e.useState(!0),[u,d]=e.useState(!1),[b,m]=e.useState(""),[h,p]=e.useState(!1);e.useEffect(()=>{if(!t||!n)return;let e=!1;return c(!0),d(!1),m(""),p(!1),fetch(n).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.blob()}).then(t=>{if(e)return;const l=t.size>Pe?t.slice(0,Pe):t;return t.size>Pe&&p(!0),l.text()}).then(t=>{if(!e){if("application/json"===i||a.endsWith(".json"))try{const e=JSON.parse(t);t=JSON.stringify(e,null,2)}catch{}m(t),c(!1)}}).catch(()=>{e||(d(!0),c(!1))}),()=>{e=!0}},[n,t,i,a]);const f=async()=>{if(n)try{const e=await fetch(n,{mode:"cors"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const t=await e.blob(),l=URL.createObjectURL(t),r=document.createElement("a");r.href=l,r.download=a||"file.txt",r.style.display="none",document.body.appendChild(r),r.click(),setTimeout(()=>{URL.revokeObjectURL(l),document.body.removeChild(r)},100)}catch{window.open(n,"_blank")}},g=b?b.split("\n").length:0,v=l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2",children:[g>0&&l.jsxs("span",{className:"lb:text-gray-400 lb:text-xs",children:[g," ",1===g?"linea":"lineas"]}),l.jsxs("button",{type:"button",onClick:f,className:"lb:flex lb:items-center lb:gap-2 lb:px-3 lb:py-1.5 lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:text-sm lb:transition-colors","aria-label":"Descargar archivo",title:"Descargar archivo",children:[l.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),l.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Descargar"})]})]}),y=l.jsxs("span",{children:[l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return l.jsx(Ne,{isOpen:t,onClose:o,title:a,subtitle:r,ariaLabel:"Visor de texto",headerActions:v,footerHints:y,children:u?l.jsxs("div",{className:"lb:text-center lb:text-white",children:[l.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),l.jsx("p",{className:"lb:text-lg lb:font-medium",children:"No se puede mostrar el archivo"}),l.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:a}),l.jsx("button",{type:"button",onClick:f,className:"lb:mt-4 lb:px-6 lb:py-2.5 lb:bg-white lb:text-gray-900 lb:rounded-lg lb:font-medium lb:text-sm lb:hover:bg-gray-100 lb:transition-colors",children:"Descargar archivo"})]}):s?l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-white/20 lb:border-t-white lb:rounded-full lb:animate-spin"})}):l.jsxs("div",{className:"lb:relative lb:w-full lb:h-full lb:px-4 lb:py-2 lb:overflow-hidden lb:flex lb:flex-col",children:[h&&l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:px-4 lb:py-2 lb:bg-yellow-900/50 lb:border lb:border-yellow-700/50 lb:rounded-lg lb:mb-2 lb:shrink-0",children:[l.jsx("svg",{className:"lb:w-4 lb:h-4 lb:text-yellow-400 lb:shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01"})}),l.jsx("span",{className:"lb:text-yellow-300 lb:text-xs",children:"Archivo truncado (mostrando primeros 2MB). Descarga el archivo completo para ver todo el contenido."})]}),l.jsx("div",{className:"lb:flex-1 lb:overflow-auto lb:rounded-lg lb:bg-gray-900/80 lb:border lb:border-white/10",children:l.jsx("pre",{className:"lb:p-4 lb:text-sm lb:text-gray-200 lb:font-mono lb:whitespace-pre-wrap lb:break-words lb:leading-relaxed lb:m-0",children:b})})]})})}function Re({src:t,alt:n="Imagen",title:a="",subtitle:r="",onClose:i,isOpen:o=!1,tags:s=[]}){const[c,u]=e.useState(1),[d,b]=e.useState({x:0,y:0}),[m,h]=e.useState(!1),[p,f]=e.useState(!1),[g,v]=e.useState({x:0,y:0}),[y,x]=e.useState(!1),[w,k]=e.useState(!1),C=e.useRef(null),S=e.useRef(null);e.useEffect(()=>{o&&(u(1),b({x:0,y:0}),x(!1),k(!1))},[o]);const j=e.useCallback(()=>{u(e=>Math.min(e+.25,5)),b({x:0,y:0})},[]),N=e.useCallback(()=>{u(e=>Math.max(e-.25,.25)),b({x:0,y:0})},[]),E=e.useCallback(()=>{u(1),b({x:0,y:0})},[]),_=e.useCallback(()=>{u(1),b({x:0,y:0})},[]),$=e.useCallback(e=>{if((e.ctrlKey||e.metaKey)&&("+"===e.key||"="===e.key))return e.preventDefault(),void j();if((e.ctrlKey||e.metaKey)&&"-"===e.key)return e.preventDefault(),void N();if((e.ctrlKey||e.metaKey)&&"0"===e.key)return e.preventDefault(),void E();if(c>1){const t=50;switch(e.key){case"ArrowUp":e.preventDefault(),b(e=>({...e,y:e.y+t}));break;case"ArrowDown":e.preventDefault(),b(e=>({...e,y:e.y-t}));break;case"ArrowLeft":e.preventDefault(),b(e=>({...e,x:e.x+t}));break;case"ArrowRight":e.preventDefault(),b(e=>({...e,x:e.x-t}))}}},[j,N,E,c]),T=e.useCallback(e=>{(e.ctrlKey||e.metaKey)&&(e.preventDefault(),e.deltaY<0?j():N())},[j,N]),A=e.useCallback(e=>{c>1&&0===e.button&&(e.preventDefault(),h(!0),f(!1),v({x:e.clientX-d.x,y:e.clientY-d.y}))},[c,d]),z=e.useCallback(e=>{m&&(f(!0),b({x:e.clientX-g.x,y:e.clientY-g.y}))},[m,g]),L=e.useCallback(()=>{h(!1)},[]),M=e.useCallback(e=>{e.stopPropagation(),1!==c||p||(u(2),b({x:0,y:0})),f(!1)},[c,p]),I=e.useCallback(e=>{e.stopPropagation(),1===c?(u(2),b({x:0,y:0})):E()},[c,E]);e.useEffect(()=>{if(!o)return;document.addEventListener("keydown",$),document.addEventListener("mouseup",L),document.addEventListener("mousemove",z);const e=e=>{!e.ctrlKey&&!e.metaKey||"+"!==e.key&&"-"!==e.key&&"="!==e.key&&"0"!==e.key||e.preventDefault()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",$),document.removeEventListener("mouseup",L),document.removeEventListener("mousemove",z),document.removeEventListener("keydown",e)}},[o,$,L,z]);const P=Math.round(100*c),D=l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",onClick:N,disabled:c<=.25,className:"lb:w-8 lb:h-8 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:disabled:opacity-30 lb:disabled:cursor-not-allowed lb:transition-colors","aria-label":"Reducir zoom",title:"Reducir zoom (Ctrl -)",children:l.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})}),l.jsxs("div",{className:"lb:w-20 lb:text-center lb:text-white lb:text-sm lb:font-medium lb:bg-white/10 lb:rounded-lg lb:px-2 lb:py-1.5 lb:cursor-pointer lb:hover:bg-white/20 lb:transition-colors",onClick:E,title:"Click para restablecer zoom",role:"button",tabIndex:0,onKeyDown:e=>"Enter"===e.key&&E(),children:[P,"%"]}),l.jsx("button",{type:"button",onClick:j,disabled:c>=5,className:"lb:w-8 lb:h-8 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:disabled:opacity-30 lb:disabled:cursor-not-allowed lb:transition-colors","aria-label":"Aumentar zoom",title:"Aumentar zoom (Ctrl +)",children:l.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),l.jsx("button",{type:"button",onClick:_,className:"lb:w-8 lb:h-8 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-white/10 lb:hover:bg-white/20 lb:text-white lb:transition-colors lb:ml-2","aria-label":"Ajustar a pantalla",title:"Ajustar a pantalla (Ctrl 0)",children:l.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})})]}),R=l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"lb:hidden lb:sm:inline",children:[l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"Ctrl"})," ","+ rueda para zoom •"," ",l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"Ctrl"})," ","+"," ",l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"+"})," ","/"," ",l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"-"})," ","zoom • Click para zoom • Doble click para restablecer • Flechas para mover •"," ",l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]}),l.jsx("span",{className:"lb:sm:hidden",children:"Click para zoom • Doble click para restablecer • ESC para cerrar"})]});return l.jsx(Ne,{isOpen:o,onClose:i,title:a,subtitle:r,ariaLabel:"Visor de imagen",headerActions:D,footerHints:R,children:l.jsxs("div",{ref:C,className:`lb:w-full lb:h-full lb:overflow-hidden lb:flex lb:items-center lb:justify-center ${c>1?"lb:cursor-grab":"lb:cursor-zoom-in"} ${m?"lb:cursor-grabbing":""}`,onClick:e=>{e.target===C.current&&i?.()},onWheel:T,onMouseDown:A,children:[!y&&!w&&l.jsx("div",{className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center",children:l.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-white/20 lb:border-t-white lb:rounded-full lb:animate-spin"})}),w&&l.jsxs("div",{className:"lb:text-center lb:text-white",children:[l.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),l.jsx("p",{className:"lb:text-lg lb:font-medium",children:"Error al cargar la imagen"}),l.jsx("p",{className:"lb:text-gray-400 lb:text-sm lb:mt-2",children:"No se pudo cargar la imagen"})]}),l.jsx("img",{ref:S,src:t,alt:n,className:"lb:max-w-full lb:max-h-full lb:object-contain lb:transition-opacity lb:duration-200 lb:select-none "+(y?"lb:opacity-100":"lb:opacity-0"),style:{transform:`scale(${c}) translate(${d.x/c}px, ${d.y/c}px)`,transition:m?"none":"transform 0.2s ease-out"},onLoad:()=>x(!0),onError:()=>k(!0),onClick:M,onDoubleClick:I,draggable:!1}),s&&s.length>0&&l.jsxs("div",{className:"lb:absolute lb:top-4 lb:left-1/2 lb:-translate-x-1/2 lb:flex lb:flex-wrap lb:gap-2 lb:justify-center lb:max-w-[90%] lb:px-4 lb:max-h-24 lb:overflow-y-auto",children:[s.slice(0,20).map(e=>l.jsx("span",{className:"lb:inline-flex lb:items-center lb:px-2 lb:py-0.5 lb:bg-white/20 lb:text-white lb:text-xs lb:font-semibold lb:rounded-full lb:whitespace-nowrap",children:e},e)),s.length>20&&l.jsxs("span",{className:"lb:inline-flex lb:items-center lb:px-2 lb:py-0.5 lb:bg-white/20 lb:text-white lb:text-xs lb:font-semibold lb:rounded-full",children:["+",s.length-20]})]})]})})}function Oe({image:t,isOpen:n,onClose:a,onSelect:r,onDelete:i,onCrop:o,onVariantDeleted:s,allowedActions:c={select:!0,download:!0,copy:!0,delete:!0,crop:!0}}){const{loadVariants:u,getVariants:d,isLoading:b,getError:m,removeVariant:h}=he(),p=window.limboCore?.accessibilityManager,[f,g]=e.useState(null),[v,y]=e.useState(null),[x,w]=e.useState(null),[k,C]=e.useState(null),[S,j]=e.useState({}),[N,E]=e.useState({}),_=(window.limboCore?.config?.getGlobal()||{}).interaction||{allowSelection:!1,allowCropping:!0},$=_.allowSelection&&c.select&&r,T=_.allowCropping&&c.crop&&o,A=c.download,z=c.copy,L=c.delete,[M,I]=e.useState(new Set),[P,D]=e.useState(new Set),[R,O]=e.useState({}),[F,U]=e.useState(!1),B=e.useRef(null),q=e.useRef(null),W=e.useCallback(e=>{if("Escape"===e.key){if(x)return;e.preventDefault(),a?.()}if("Tab"===e.key&&B.current){const t=B.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),l=t[0],n=t[t.length-1];e.shiftKey&&document.activeElement===l?(e.preventDefault(),n?.focus()):e.shiftKey||document.activeElement!==n||(e.preventDefault(),l?.focus())}},[a,x]);e.useEffect(()=>{if(n)return q.current?.focus(),document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[n,W]);const V=e.useMemo(()=>t?.variants||[],[t?.variants]),H=d(t?.id),K=(H.length>0?H:V).filter(e=>!P.has(e.id)),G=b(t?.id),Q=m(t?.id);e.useEffect(()=>{n&&t?.id&&u(t.id,!0)},[n,t?.id]),e.useEffect(()=>{n&&(I(new Set),D(new Set),O({}),j({}),E({}))},[n]),e.useEffect(()=>{if(n&&P.size>0&&0===K.length){const e=setTimeout(()=>{document.dispatchEvent(new CustomEvent("limbo:variantsCleared",{detail:{assetId:t?.id}})),a?.()},1200);return()=>clearTimeout(e)}},[n,P.size,K.length,t?.id,a]);const X=K.map(e=>e.id).join(",");e.useEffect(()=>{if(!n||!t?.url)return;let e=!1;return(async()=>{const l={},n={},a={},r="original",i=ke(t.url);if(i?(n[r]=!0,l[r]=!1,a.original=we(t.url)):(l[r]=!0,n[r]=!1),K.forEach(e=>{ke(e.url)?(n[e.id]=!0,l[e.id]=!1,a[e.id]=we(e.url)):(l[e.id]=!0,n[e.id]=!1)}),j(l),E(n),Object.keys(a).length>0&&O(a),!i){const l=await xe(t.url);if(e)return;l&&(O(e=>({...e,original:l})),j(e=>({...e,[r]:!1})),E(e=>({...e,[r]:!0})))}if(K.length>0){const t=K.filter(e=>!ke(e.url));if(t.length>0){const l=t.map(e=>e.url),n=await Ce(l,4);if(e)return;const a={},r={},i={};t.forEach((e,t)=>{n[t]&&(a[e.id]=n[t],r[e.id]=!1,i[e.id]=!0)}),Object.keys(a).length>0&&(O(e=>({...e,...a})),j(e=>({...e,...r})),E(e=>({...e,...i})))}}})(),()=>{e=!0}},[n,t?.url,X]);if(!n)return null;const Y=e=>{p?.announce(`Abriendo visor de imagen: ${e.name}`);const t=R[e.id]||we(e.url);w({src:t,title:e.name||e.filename||"Recorte",subtitle:`${e.width}×${e.height} · ${Math.round((e.file_size||0)/1024)}KB`})},J=()=>{p?.announce(`Abriendo visor de imagen: ${t.filename}`);const e=R.original||we(t.url);w({src:e,title:t.filename||"Original",subtitle:`${t.width}×${t.height} · ${Math.round((t.file_size||0)/1024)}KB`})},Z=[{...t,isOriginal:!0},...K.map(e=>({...e,isOriginal:!1}))];return l.jsxs("div",{className:"lb:fixed lb:inset-0 lb:bg-black/85 lb:flex lb:items-center lb:justify-center lb:z-[1000] lb:p-4",onClick:()=>{x||a?.()},role:"dialog","aria-modal":"true","aria-labelledby":"variants-modal-title","aria-describedby":"variants-modal-description",children:[l.jsxs("div",{ref:B,className:"lb:relative lb:bg-white lb:rounded-xl lb:max-w-[95vw] lb:max-h-[90vh] lb:overflow-hidden lb:shadow-2xl lb:flex lb:flex-col lb:w-[900px]",onClick:e=>e.stopPropagation(),children:[l.jsxs("div",{className:"lb:px-5 lb:py-4 lb:border-b lb:border-gray-200 lb:flex lb:justify-between lb:items-center lb:bg-gray-50",children:[l.jsxs("div",{className:"lb:flex-1 lb:min-w-0 lb:pr-4",children:[l.jsx("h2",{id:"variants-modal-title",className:"lb:m-0 lb:text-lg lb:font-semibold lb:text-gray-900 lb:truncate",children:t?.filename}),l.jsxs("p",{id:"variants-modal-description",className:"lb:text-sm lb:text-gray-500 lb:mt-1",children:["Imagen original y ",K.length," recorte",1!==K.length?"s":""," disponible",1!==K.length?"s":""]})]}),l.jsx("button",{ref:q,className:"lb:w-10 lb:h-10 lb:flex lb:items-center lb:justify-center lb:rounded-lg lb:bg-gray-100 lb:hover:bg-red-200 lb:text-gray-500 lb:hover:text-red-1000 lb:transition-colors lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400",onClick:a,"aria-label":"Cerrar modal (ESC)",title:"Cerrar (ESC)",children:l.jsx("svg",{className:"lb:w-5 lb:h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),F&&l.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-white/80 lb:flex lb:flex-col lb:items-center lb:justify-center lb:z-50 lb:rounded-xl",children:[l.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-gray-200 lb:border-t-brand-blue-800 lb:rounded-full lb:animate-spin lb:mb-4"}),l.jsx("p",{className:"lb:text-base lb:font-medium lb:text-gray-700",children:"Eliminando recorte..."})]}),f&&l.jsx("div",{className:"lb:mx-2 lb:mt-2 lb:px-2 lb:py-1.5 lb:rounded lb:text-xs "+("success"===v?"lb:bg-green-50 lb:text-green-1000":"lb:bg-red-50 lb:text-red-1000"),role:"alert",children:f}),l.jsx("div",{className:"lb:p-5 lb:overflow-y-auto lb:flex-1 lb:bg-gray-50/50",children:G?l.jsxs("div",{className:"lb:text-center lb:py-16 lb:text-gray-500",role:"status","aria-live":"polite",children:[l.jsx("div",{className:"lb:w-12 lb:h-12 lb:border-4 lb:border-gray-200 lb:border-t-brand-blue-800 lb:rounded-full lb:animate-spin lb:mx-auto lb:mb-4"}),l.jsx("p",{className:"lb:text-base",children:"Cargando variantes..."})]}):Q?l.jsxs("div",{className:"lb:text-center lb:py-16 lb:text-red-1000",role:"alert",children:[l.jsx("svg",{className:"lb:w-12 lb:h-12 lb:mx-auto lb:mb-4 lb:text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),l.jsxs("p",{className:"lb:text-base lb:font-medium",children:["Error: ",Q]}),l.jsx("button",{onClick:()=>u(t.id,!0),className:"lb:mt-4 lb:text-sm lb:px-5 lb:py-2.5 lb:rounded-lg lb:bg-brand-blue-800 lb:text-white lb:hover:bg-brand-blue-1000 lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-2",children:"Reintentar"})]}):0===K.length?l.jsxs("div",{className:"lb:text-center lb:py-16 lb:text-gray-500",children:[l.jsx("svg",{className:"lb:w-12 lb:h-12 lb:mx-auto lb:mb-4 lb:text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),l.jsx("p",{className:"lb:text-base",children:"No hay recortes disponibles"})]}):l.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:lg:grid-cols-3 lb:gap-5",role:"list","aria-label":"Lista de imágenes",children:Z.map((e,n)=>{const c=e.isOriginal,u=!c&&M.has(e.id),d=c?R.original||we(e.url):R[e.id]||we(e.url),b=c?"Original":e.name||e.filename||`Recorte ${n}`,m=c?t.width:e.width,f=c?t.height:e.height,v=c?t.file_size:e.file_size||0,x=c?"original":e.id,w=S[x]&&!u,_=N[x];return l.jsxs("article",{role:"listitem","aria-label":`${b} - ${m}×${f} píxeles`,className:`lb:rounded-xl lb:overflow-hidden lb:transition-all lb:shadow-sm lb:hover:shadow-lg ${c?"lb:ring-2 lb:ring-brand-blue-800 lb:ring-offset-2 lb:bg-white":"lb:border lb:border-gray-200 lb:bg-white lb:hover:border-brand-blue-400"} lb:focus-within:ring-2 lb:focus-within:ring-brand-blue-400`,children:[l.jsxs("button",{type:"button",title:$?"Click para seleccionar":"Click para ampliar con zoom",className:"lb:relative lb:w-full lb:cursor-pointer lb:aspect-square lb:flex lb:items-center lb:justify-center lb:overflow-hidden lb:bg-gray-100 lb:focus:outline-none lb:group",onClick:u?void 0:()=>{$?c?(r?.(t),a?.()):(e=>{const l={id:e.id,filename:`${t.filename}_${e.name}`,url:e.url,width:e.width,height:e.height,mime_type:`image/${e.format}`,file_size:e.file_size,upload_date:e.created_at,processing_status:"completed",is_variant:!0,parent_asset_id:t.id,variant_info:e};p?.announce(`Recorte seleccionado: ${e.name}`),r?.(l),a?.()})(e):c?J():Y(e)},"aria-label":$?`Seleccionar ${b}`:`Ver ${b} en tamaño completo con zoom`,disabled:u,children:[w&&!u&&l.jsx("div",{className:"lb:w-full lb:aspect-square lb:rounded lb:bg-neutral-gray-200 lb:animate-pulse lb:flex lb:items-center lb:justify-center lb:absolute lb:inset-0 lb:z-10",children:l.jsx("span",{className:"icon icon-spinner lb:w-8 lb:h-8 lb:animate-spin"})}),u?l.jsxs("div",{className:"lb:text-center lb:text-gray-400",children:[l.jsx("svg",{className:"lb:w-10 lb:h-10 lb:mx-auto lb:mb-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),l.jsx("span",{className:"lb:text-sm",children:"Error al cargar"})]}):l.jsxs(l.Fragment,{children:[l.jsx("img",{src:d,alt:`${b} - ${m}×${f}px`,loading:c?"eager":"lazy",onLoad:()=>{E(e=>e[x]?e:{...e,[x]:!0}),j(e=>e[x]?{...e,[x]:!1}:e)},onError:c?void 0:()=>{return t=e.id,void I(e=>new Set([...e,t]));var t},className:"lb:w-full lb:h-full lb:object-contain lb:p-3 lb:transition-all lb:duration-300 lb:group-hover:scale-105 "+(_?"lb:opacity-100":"lb:opacity-0")}),l.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-black/0 lb:group-hover:bg-black/10 lb:transition-colors lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:bg-black/60 lb:text-white lb:px-3 lb:py-1.5 lb:rounded-full lb:text-xs lb:font-medium lb:flex lb:items-center lb:gap-1.5",children:$?l.jsxs(l.Fragment,{children:[l.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Seleccionar"]}):l.jsxs(l.Fragment,{children:[l.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})}),"Ampliar"]})})})]}),c&&l.jsx("span",{className:"lb:absolute lb:top-3 lb:left-3 lb:bg-brand-blue-800 lb:text-white lb:text-xs lb:font-bold lb:px-3 lb:py-1.5 lb:rounded-lg lb:shadow-lg lb:z-20",children:"ORIGINAL"})]}),l.jsxs("div",{className:"lb:px-4 lb:py-3 lb:border-t lb:border-gray-100 lb:bg-white",children:[l.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-900 lb:truncate lb:mb-2",title:b,children:b}),l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[l.jsxs("span",{className:"lb:text-xs lb:text-gray-500 lb:font-medium",children:[m,"×",f," ·"," ",Math.round(v/1024),"KB"]}),l.jsxs("div",{className:"lb:flex lb:gap-2",role:"group","aria-label":`Acciones para ${b}`,children:[c&&T&&l.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:rounded-lg lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:cursor-pointer lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:e=>{e.stopPropagation(),o&&(p?.announce(`Abriendo herramienta de recorte para ${t.filename}`),o(t),a?.())},"aria-label":"Crear nuevo recorte",title:"Recortar",children:l.jsx("span",{className:"icon icon-scissors-white icon--sm"})}),z&&l.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:rounded-lg lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:cursor-pointer lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:l=>{l.stopPropagation();(async(e,t,l)=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(t);else{const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),document.body.removeChild(e)}C(e),p?.announce(`URL de ${l} copiada al portapapeles`),setTimeout(()=>C(null),2e3)}catch(n){console.error("Error al copiar URL:",n),p?.announceError(`Error al copiar URL de ${l}. Inténtalo de nuevo.`)}})(c?"original":e.id,c?t.url||t.path:e.url,b)},"aria-label":k===(c?"original":e.id)?"¡Copiado!":`Copiar URL de ${b}`,title:k===(c?"original":e.id)?"¡Copiado!":"Copiar URL",children:l.jsx("span",{className:`icon ${k===(c?"original":e.id)?"icon-copied-white":"icon-copy-white"} icon--sm`})}),A&&l.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:rounded-lg lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:cursor-pointer lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:l=>{l.stopPropagation(),c?(async()=>{const{downloadImage:e}=await Promise.resolve().then(()=>xn);await e(t.url||t.path,t.filename||"limbo-image",{originalFormat:t.format,accessibilityManager:p})})():(async e=>{const{downloadImage:t}=await Promise.resolve().then(()=>xn);await t(e.url,e.name||"limbo-variant",{originalFormat:e.format||e.output_format,accessibilityManager:p})})(e)},"aria-label":`Descargar ${b}`,title:"Descargar",children:l.jsx("span",{className:"icon icon-download-white icon--sm"})}),L&&(!c||i)&&l.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:rounded-lg lb:bg-red-1000 lb:hover:bg-red-800 lb:cursor-pointer lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-red-800 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:l=>{l.stopPropagation(),c?(async()=>{if(!i)return;window.confirm(`¿Estás seguro de que deseas eliminar "${t.filename}"? Esta acción también eliminará todos sus recortes.`)&&(p?.announce(`Eliminando imagen ${t.filename}`),await i(t.id),a?.())})():(async e=>{if(window.confirm(`¿Estás seguro de que deseas eliminar el recorte "${e.name||e.filename}"?`)){U(!0),p?.announce(`Eliminando recorte ${e.name||e.filename}`);try{const l=await h(t.id,e.id);l.success?(D(t=>new Set([...t,e.id])),e.url&&Se(e.url),g("Recorte eliminado correctamente"),y("success"),p?.announce("Recorte eliminado correctamente"),s?.(),document.dispatchEvent(new CustomEvent("limbo:variantDeleted",{detail:{assetId:t?.id,variantId:e.id}})),setTimeout(()=>{g(null),y(null)},3e3)):(g(`Error al eliminar recorte: ${l.error}`),y("error"),p?.announceError(`Error al eliminar recorte: ${l.error}`),setTimeout(()=>{g(null),y(null)},5e3))}finally{U(!1)}}})(e)},"aria-label":`Eliminar ${b}`,title:"Eliminar",children:l.jsx("span",{className:"icon icon-delete-white icon--2sm"})}),$&&l.jsx("button",{type:"button",className:"lb:w-8 lb:h-8 lb:cursor-pointer lb:rounded-lg lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:text-white lb:flex lb:items-center lb:justify-center lb:focus:outline-none lb:focus:ring-2 lb:focus:ring-brand-blue-400 lb:focus:ring-offset-1 lb:transition-colors lb:shadow-sm",onClick:t=>{t.stopPropagation(),c?J():Y(e)},"aria-label":`Ampliar ${b}`,title:"Ampliar",children:l.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})})})]})]})]})]},c?"original":e.id)})})})]}),l.jsx(Re,{isOpen:!!x,src:x?.src||"",alt:x?.title||"Imagen",title:x?.title,subtitle:x?.subtitle,onClose:()=>w(null)})]})}const Fe="/api";let Ue={data:null,timestamp:0,pending:null};const Be=new Set;function qe(){Ue.data=null,Ue.timestamp=0,Ue.pending=null,Be.forEach(e=>e())}async function We(e={}){return Ue.data&&Date.now()-Ue.timestamp<3e5?Ue.data:(Ue.pending||(Ue.pending=async function(e={}){try{const t={include_counts:"true",...e},l=`/folders?${new URLSearchParams(t).toString()}`;return function(e){if(!e?.success||!e?.data)return{folders:[],total:0};const t=(e.data.folders||[]).map(e=>({id:e.id,name:e.name,slug:e.slug,description:e.description,visibility:e.visibility||"public",sort_order:e.sort_order||0,assets_count:e.assets_count||0,created_at:e.created_at,updated_at:e.updated_at}));return{folders:t,total:e.data.total||t.length}}(await W({endpoint:l,method:"GET",basePath:Fe,useJWT:!0}))}catch(t){throw Y(t)}}(e).then(e=>(Ue.data=e,Ue.timestamp=Date.now(),Ue.pending=null,e)).catch(e=>{throw Ue.pending=null,e})),Ue.pending)}function Ve(t={}){const{autoFetch:l=!0,visibility:n=null,allowedSlugs:a=null,excludeSlugs:r=null}=t,[i,o]=e.useState([]),[s,c]=e.useState(!1),[u,d]=e.useState(null),[b,m]=e.useState(!1),h=e.useRef(null),p=e.useCallback(e=>{let t=[...e];return a&&a.length>0&&(t=t.filter(e=>a.includes(e.slug))),r&&r.length>0&&(t=t.filter(e=>!r.includes(e.slug))),t.sort((e,t)=>e.sort_order!==t.sort_order?e.sort_order-t.sort_order:e.name.localeCompare(t.name)),t},[a,r]),f=e.useCallback(async(e={})=>{c(!0),d(null);try{const t={...n&&{visibility:n},...e},l=await We(t),a=p(l.folders||[]);return o(a),a}catch(t){return d(t.message),[]}finally{c(!1)}},[n,p]),g=e.useCallback(()=>(qe(),f()),[f]),v=e.useCallback(async e=>{m(!0),d(null);try{const t=await async function(e){try{return function(e){if(!e?.success||!e?.data)return{folder:null};const t=e.data;return{folder:{id:t.id,name:t.name,slug:t.slug,description:t.description,visibility:t.visibility||"public",sort_order:t.sort_order||0,assets_count:t.assets_count||0,created_at:t.created_at,updated_at:t.updated_at}}}(await W({endpoint:"/folders",method:"POST",body:{name:e.name,...e.slug&&{slug:e.slug},...e.description&&{description:e.description},...e.visibility&&{visibility:e.visibility}},basePath:Fe,useJWT:!0}))}catch(u){throw Y(u)}}(e),l=t.folder;return l&&(qe(),o(e=>{const t=[...e,l];return t.sort((e,t)=>e.sort_order!==t.sort_order?e.sort_order-t.sort_order:e.name.localeCompare(t.name)),t})),l}catch(t){return d(t.message),null}finally{m(!1)}},[]),y=e.useCallback(e=>i.find(t=>t.slug===e)||null,[i]),x=e.useCallback(e=>i.find(t=>t.id===e)||null,[i]);return h.current=f,e.useEffect(()=>{const e=()=>h.current?.();return Be.add(e),()=>Be.delete(e)},[]),e.useEffect(()=>{l&&f()},[l,f]),{folders:i,loading:s,error:u,creating:b,fetchFolders:f,create:v,refresh:g,findBySlug:y,findById:x,hasLoaded:!s&&i.length>=0}}function He({value:t=null,onChange:n,allowCreate:a=!0,placeholder:r="Sin carpeta",label:i=null,disabled:o=!1,className:s="",showAssetCount:c=!1,includeNoFolder:u=!0,allowedSlugs:d=null,excludeSlugs:b=null,mode:m="upload"}){const h=e.useId(),[p,f]=e.useState(!1),[g,v]=e.useState(""),[y,x]=e.useState(null),{folders:w,loading:k,error:C,creating:S,create:j,refresh:N}=Ve({autoFetch:!0,allowedSlugs:d,excludeSlugs:b}),E=async e=>{if(e.preventDefault(),x(null),!g.trim())return void x("El nombre es requerido");const t=await j({name:g.trim()});t?(n?.(t),f(!1),v("")):x("Error al crear la carpeta")},_=()=>{f(!1),v(""),x(null)};if(p)return l.jsxs("div",{className:`limbo-folder-selector limbo-folder-selector--creating ${s}`,children:[i&&l.jsxs("label",{className:"limbo-filter-label lb:block lb:mb-1 lb:text-white lb:ms-6",children:[i," ",S&&l.jsx("span",{className:"limbo-filter-searching","aria-hidden":"true",children:l.jsx("span",{className:"icon icon-spinner lb:animate-spin lb:w-3 lb:h-3"})})]}),l.jsxs("form",{onSubmit:E,className:"lb:flex lb:gap-2 lb:items-center lb:flex-col",children:[l.jsx("div",{children:l.jsx("input",{type:"text",value:g,onChange:e=>v(e.target.value),placeholder:"Nombre de la carpeta...",className:"limbo-filter-input lb:flex-1",autoFocus:!0,disabled:S})}),l.jsxs("div",{className:"lb:flex lb:gap-2",children:[l.jsx("button",{type:"submit",disabled:S||!g.trim(),className:"limbo-btn limbo-btn--primary lb:px-3 lb:py-1.5 lb:text-sm lb:rounded lb:bg-brand-blue-1000 lb:text-white lb:border-0 lb:cursor-pointer disabled:lb:opacity-50 disabled:lb:cursor-not-allowed lb:hover:bg-brand-blue-800",children:S?"...":"Crear"}),l.jsx("button",{type:"button",onClick:_,disabled:S,className:"limbo-btn limbo-btn--ghost lb:px-2 lb:py-1.5 lb:text-sm lb:rounded lb:hover:bg-gray-200 lb:bg-gray-300 lb:border lb:border-gray-300 lb:cursor-pointer",children:"Cancelar"})]})]}),y&&l.jsx("p",{className:"lb:text-red-600 lb:text-xs lb:mt-1",children:y})]});const $="filter"===m?"Todas las carpetas":r;return l.jsxs("div",{className:`limbo-folder-selector ${s}`,children:[i&&l.jsxs("label",{htmlFor:h,className:"limbo-filter-label lb:block lb:mb-1 lb:text-white",children:[i,k&&l.jsx("span",{className:"limbo-filter-searching","aria-hidden":"true",children:l.jsx("span",{className:"icon icon-spinner lb:animate-spin lb:w-3 lb:h-3"})})]}),l.jsx("div",{className:"lb:relative",children:l.jsxs("select",{id:h,value:t||"",onChange:e=>{const t=e.target.value;if("__create__"===t)return void f(!0);if(""===t||"__none__"===t)return void n?.(null);const l=w.find(e=>e.slug===t);n?.(l||null)},disabled:o||k,className:"limbo-filter-input limbo-filter-select lb:w-full",children:[u&&l.jsx("option",{value:"",children:$}),k&&l.jsx("option",{value:"",disabled:!0,children:"Cargando carpetas..."}),C&&!k&&l.jsx("option",{value:"",disabled:!0,children:"Error al cargar carpetas"}),!k&&!C&&w.map(e=>l.jsxs("option",{value:e.slug,children:[e.name,c&&` (${e.assets_count})`]},e.id)),a&&!k&&!C&&l.jsxs(l.Fragment,{children:[l.jsx("option",{disabled:!0,children:"──────────────"}),l.jsx("option",{value:"__create__",children:"+ Crear nueva carpeta..."})]})]})}),C&&l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:mt-1",children:[l.jsx("p",{className:"lb:text-red-600 lb:text-xs",children:C}),l.jsx("button",{type:"button",onClick:N,className:"lb:text-xs lb:text-brand-blue-1000 lb:underline lb:cursor-pointer",children:"Reintentar"})]})]})}function Ke({isOpen:t,asset:n,onClose:a,onSave:r,folderConfig:i}){const[o,s]=e.useState(null),[c,u]=e.useState(!1),[d,b]=e.useState(null),m=e.useRef(null);if(e.useEffect(()=>{n&&s(n.folder?.slug||null)},[n]),ie(m,{onClose:a,isActive:t}),!t||!n)return null;return l.jsx("div",{className:"lb:fixed lb:inset-0 lb:bg-black/50 lb:flex lb:items-center lb:justify-center lb:z-[9999]",onClick:function(e){e.target===e.currentTarget&&a()},children:l.jsxs("div",{ref:m,role:"dialog","aria-modal":"true","aria-labelledby":"move-folder-modal-title",className:"lb:bg-white lb:rounded-lg lb:p-6 lb:max-w-md lb:w-full lb:mx-4 lb:shadow-xl",children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:mb-5",children:[l.jsx("h2",{id:"move-folder-modal-title",className:"lb:text-base lb:font-semibold lb:text-neutral-gray-900",children:"Mover de carpeta"}),l.jsx("button",{type:"button","aria-label":h("editAssetModal.close"),onClick:a,className:"lb:text-neutral-gray-400 lb:hover:text-neutral-gray-700 lb:p-1 lb:rounded",children:"×"})]}),l.jsx("div",{className:"lb:mb-4",children:l.jsx(He,{value:o,onChange:s,allowCreate:!1!==i?.allowCreateFolder,label:"Mover a carpeta",includeNoFolder:!0,allowedSlugs:i?.include?.length>0?i.include:null,excludeSlugs:i?.exclude?.length>0?i.exclude:null,disabled:c,mode:"upload"})}),d&&l.jsx("p",{className:"lb:text-xs lb:text-red-800 lb:mt-3",children:d}),l.jsxs("div",{className:"lb:flex lb:justify-end lb:gap-2 lb:mt-6",children:[l.jsx("button",{type:"button",onClick:a,disabled:c,className:"lb:px-4 lb:py-2 lb:text-sm lb:font-semibold lb:text-neutral-gray-700 lb:border lb:border-neutral-gray-300 lb:rounded-md lb:hover:bg-neutral-gray-050 lb:transition-colors",children:h("editAssetModal.cancel")}),l.jsx("button",{type:"button",onClick:async function(){u(!0),b(null);try{const e=o?{slug:o}:null;await r(n,e),a()}catch(e){b(e.message||h("editAssetModal.saveError"))}finally{u(!1)}},disabled:c,className:"lb:px-4 lb:py-2 lb:text-sm lb:font-semibold lb:bg-brand-blue-800 lb:text-white lb:rounded-md lb:hover:bg-brand-blue-1000 lb:transition-colors"+(c?" lb:opacity-70 lb:cursor-not-allowed":""),children:h("editAssetModal.save")})]})]})})}const Ge={pdf:{symbol:"icon-doc-pdf",color:"#dc2626"},doc:{symbol:"icon-doc-word",color:"#2563eb"},docx:{symbol:"icon-doc-word",color:"#2563eb"},xls:{symbol:"icon-doc-xls",color:"#16a34a"},xlsx:{symbol:"icon-doc-xls",color:"#16a34a"},ppt:{symbol:"icon-doc-ppt",color:"#ea580c"},pptx:{symbol:"icon-doc-ppt",color:"#ea580c"},txt:{symbol:"icon-doc-text",color:"#6b7280"},csv:{symbol:"icon-doc-report",color:"#16a34a"},mp4:{symbol:"icon-video",color:"#7c3aed"},webm:{symbol:"icon-video",color:"#7c3aed"},mov:{symbol:"icon-video",color:"#7c3aed"},avi:{symbol:"icon-video",color:"#7c3aed"},mkv:{symbol:"icon-video",color:"#7c3aed"},gif:{symbol:"icon-video",color:"#7a3f2d"},mp3:{symbol:"icon-support-person",color:"#0891b2"},mpeg:{symbol:"icon-support-person",color:"#0891b2"},wav:{symbol:"icon-support-person",color:"#0891b2"},ogg:{symbol:"icon-support-person",color:"#0891b2"},aac:{symbol:"icon-support-person",color:"#0891b2"},flac:{symbol:"icon-support-person",color:"#0891b2"},default:{symbol:"icon-clip",color:"#6b7280"}},Qe=(e,t)=>0===t?e:Qe(t,e%t),Xe=new Set(["text/plain","text/csv","text/html","text/xml","text/css","text/javascript","text/markdown","application/json","application/xml","application/javascript"]);const Ye=e.memo(function({image:t,onDelete:n,onCrop:a,onSelect:r,onFolderChange:i,thumbnailSize:o=32,isDeleting:s=!1,showFolderInfo:c=!0,allowMoveFolder:u=!0,allowedFolderSlugs:d=null,excludedFolderSlugs:b=null,allowCreateFolder:m=!1,allowedActions:p={select:!0,download:!0,copy:!0,delete:!0,crop:!0,variants:!0,rename:!0},onEdit:f=null}){const[g,v]=e.useState(!1),[y,x]=e.useState(!1),[w,k]=e.useState(!1),[C,S]=e.useState(t.variants_count||0),[j,N]=e.useState(!1),E=e.useMemo(()=>(e=>{if(e.asset_type)return e.asset_type;const t=e.mime_type||e.original_mime||"";return"image/gif"===t?"video":t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.includes("pdf")||t.includes("document")||t.includes("spreadsheet")||t.includes("presentation")||t.includes("text/")?"document":"unknown"})(t),[t]),$="image"===E,T=(t.mime_type||t.original_mime||"").includes("image/gif"),A=$||T,z=e.useMemo(()=>(e=>{if(!e)return"";const t=e.split(".");return t.length>1?t.pop().toLowerCase():""})(t.filename),[t.filename]),L=Ge[z]||Ge.default,M=e.useMemo(()=>((e,t)=>{if(!e||!t||e<=0||t<=0)return null;const l=Qe(Math.round(e),Math.round(t)),n=Math.round(e)/l,a=Math.round(t)/l;return n>20||a>20?null:`${n}:${a}`})(t.width,t.height),[t.width,t.height]),I=t.url||t.path,P=A&&t.thumbnail_url?t.thumbnail_url:I,[D,R]=e.useState(()=>we(P)),[O,F]=e.useState(()=>!ke(P)),[U,B]=e.useState(!1),[q,W]=e.useState(()=>ke(P)),V=e.useRef(null),{isMobile:H,isTouch:K}=_(),G=window.limboCore?.accessibilityManager,Q=(window.limboCore?.config?.getGlobal()||{}).interaction||{allowSelection:!1,allowCropping:!0},X=async e=>{e.stopPropagation();let l=t.url||t.path;try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(l);else{const e=document.createElement("textarea");e.value=l,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),document.body.removeChild(e)}v(!0),G?.announce(`URL de ${t.filename} copiada al portapapeles. Nota: La URL puede tener un tiempo de validez limitado.`),setTimeout(()=>v(!1),2e3)}catch(n){console.error("Error al copiar URL:",n),G?.announce(`Error al copiar URL de ${t.filename}. Inténtalo de nuevo.`),alert(`Error al copiar URL de ${t.filename}. Por favor, inténtalo de nuevo.`)}},Y=async e=>{e.preventDefault(),e.stopPropagation();const l=t.url||t.path,n=t.filename||"limbo-file";if(!$){try{G?.announce(`Descargando ${n}`);const e=await fetch(l,{mode:"cors"});if(!e.ok)throw new Error(`HTTP error: ${e.status}`);const t=await e.blob(),a=window.URL.createObjectURL(t),r=document.createElement("a");r.href=a,r.download=n,r.style.display="none",document.body.appendChild(r),r.click(),setTimeout(()=>{window.URL.revokeObjectURL(a),document.body.removeChild(r)},100),G?.announce(`${n} descargado correctamente`)}catch(r){console.error("Error downloading file:",r),G?.announce(`Error al descargar ${n}`)}return}const{downloadImage:a}=await Promise.resolve().then(()=>xn);await a(l,n,{originalFormat:t.format,accessibilityManager:G})},J=e=>{e.stopPropagation(),G?.announce(`Editando imagen ${t.filename}`),a?.(t)},Z=e.useCallback(e=>{e.stopPropagation(),n?.(t.id)},[t.id,n]),ee=$&&(t.variants&&t.variants.length>0||t.variants_count>0||C>0),te=C,le=e.useCallback(()=>{S(e=>Math.max(0,e-1))},[]);e.useEffect(()=>{S(t.variants_count||0)},[t.variants_count]),e.useEffect(()=>{if(!A)return F(!1),void W(!0);if(t.thumbnail_url){if(ke(t.thumbnail_url)){const e=we(t.thumbnail_url);return R(e),F(!1),B(!1),void W(!0)}return R(t.thumbnail_url),F(!0),B(!1),void W(!1)}const e=t.url||t.path;if(ke(e))return R(we(e)),F(!1),B(!1),void W(!0);F(!0),B(!1),W(!1),xe(e).then(e=>{R(e),F(!1),W(!0)}).catch(()=>{R(e),F(!1),B(!0)})},[t.url,t.path,t.thumbnail_url,A]),e.useEffect(()=>{if(!A||!O)return;const e=V.current;e&&e.complete&&e.naturalWidth>0&&(F(!1),W(!0),B(!1))},[A,O,D]);const ne=Q.allowSelection&&p.select&&r,ae=T?I:null,re=$&&!T&&Q.allowCropping&&p.crop&&a,ie=()=>{ee?(G?.announce(`Mostrando recortes de ${t.filename}`),x(!0)):ne?(G?.announce(`Seleccionando ${t.filename} para el portal`),r?.(t)):(G?.announce(`Abriendo visor de ${t.filename}`),k(!0))};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:`limbo-image-card-wrapper lb:relative lb:cursor-pointer lb:focus:outline-0 ${s?"lb:opacity-50":""} ${H?"limbo-image-card-wrapper--mobile":""}`,onClick:ie,onKeyDown:e=>{if("INPUT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName)switch(e.key){case"Enter":case" ":e.preventDefault(),ie();break;case"d":case"D":p.download&&(e.preventDefault(),Y(e));break;case"c":case"C":p.copy&&(e.preventDefault(),X(e));break;case"Delete":case"Backspace":p.delete&&n&&(e.preventDefault(),Z(e));break;case"x":case"X":p.crop&&a&&(e.preventDefault(),J(e));break;case"v":case"V":p.variants&&(e.preventDefault(),(e=>{e.stopPropagation(),G?.announce(`Mostrando recortes de ${t.filename}`),x(!0)})(e))}},onMouseEnter:ae?()=>{ae&&t.thumbnail_url&&R(ae)}:void 0,onMouseLeave:ae?()=>{ae&&t.thumbnail_url&&R(t.thumbnail_url)}:void 0,title:ee?`Ver ${te} recorte${1!==te?"s":""} de ${t.filename}`:A?H?"Toque para ampliar imagen":"Click para ampliar imagen con zoom":H?"Toque para previsualizar":"Click para previsualizar",role:"button",tabIndex:0,"aria-label":A?`${T?"GIF":"Imagen"} ${t.filename}. ${t.width}x${t.height} px`:`Archivo ${t.filename}. Tipo: ${E}`,style:{...K&&{touchAction:"manipulation",WebkitTapHighlightColor:"transparent"}},children:[l.jsx("div",{className:"limbo-image-actions "+(H?"limbo-image-actions--mobile":""),children:l.jsxs("div",{className:"limbo-image-actions__buttons",children:[(ne||!A)&&l.jsx("button",{type:"button",title:ee?`Ver ${te} recortes`:A?"Ampliar imagen":"Previsualizar archivo","aria-label":ee?h("imageCard.aria.zoomWithCrops",{n:te,filename:t.filename}):h(A?"imageCard.aria.zoom":"imageCard.aria.zoomPreview",{filename:t.filename}),className:"limbo-action-btn lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(H?"lb:btn--touch":""),onClick:e=>{e?.stopPropagation(),G?.announce(`Abriendo visor de ${t.filename}`),k(!0)},tabIndex:0,children:l.jsx("span",{className:`icon ${A?"icon-zoom-in-white":"icon-search-white"} icon--sm`,"aria-hidden":"true"})}),re&&l.jsx("button",{type:"button",title:"Nuevo recorte","aria-label":h("imageCard.aria.crop",{filename:t.filename}),className:"limbo-action-btn limbo-btn-crop lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(H?"lb:btn--touch":""),onClick:J,tabIndex:0,children:l.jsx("span",{className:"icon icon-scissors-white icon--sm","aria-hidden":"true"})}),p.copy&&l.jsx("button",{type:"button",title:g?"¡Copiado!":"Copiar URL","aria-label":g?h("imageCard.aria.copied"):h("imageCard.aria.copyUrl",{filename:t.filename}),className:"limbo-action-btn limbo-btn-copy lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(H?"lb:btn--touch":""),onClick:X,tabIndex:0,children:l.jsx("span",{className:`icon ${g?"icon-copied-white":"icon-copy-white"} icon--sm`,"aria-hidden":"true"})}),p.download&&l.jsx("button",{type:"button",title:"Descargar","aria-label":h("imageCard.aria.download",{filename:t.filename}),className:"limbo-action-btn limbo-btn-download lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(H?"lb:btn--touch":""),onClick:Y,tabIndex:0,children:l.jsx("span",{className:"icon icon-download-white icon--sm","aria-hidden":"true"})}),u&&i&&l.jsx("button",{type:"button",title:t.folder?`Mover de carpeta (${t.folder?.name||t.folder?.slug||""})`:"Asignar a carpeta",className:"limbo-action-btn limbo-btn-folder lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(H?"lb:btn--touch":""),onClick:e=>{e.stopPropagation(),N(!0)},"aria-label":t.folder?`Mover de carpeta (${t.folder?.name||t.folder?.slug||""})`:"Asignar a carpeta",tabIndex:0,children:l.jsx("span",{className:"icon icon-folder-white icon--sm","aria-hidden":"true"})}),p.rename&&f&&l.jsx("button",{type:"button",title:"Editar archivo","aria-label":h("imageCard.aria.rename",{filename:t.filename}),className:"limbo-action-btn limbo-btn-rename lb:bg-brand-blue-400 lb:hover:bg-brand-blue-800 lb:border lb:border-brand-blue-1000 "+(H?"lb:btn--touch":""),onClick:e=>{e.stopPropagation(),f(t)},tabIndex:0,children:l.jsx("span",{className:"icon icon-edit-white icon--sm","aria-hidden":"true"})}),p.delete&&n&&l.jsx("button",{onClick:Z,disabled:s,className:"limbo-action-btn limbo-btn-delete lb:bg-red-800 lb:hover:bg-red-700 lb:border lb:border-red-700 "+(H?"lb:btn--touch lb:active:lb:bg-red-800":""),title:"Eliminar archivo","aria-label":h("imageCard.aria.delete",{filename:t.filename}),tabIndex:0,children:s?"…":l.jsx("span",{className:"icon icon-delete-white icon--1sm","aria-hidden":"true"})})]})}),l.jsxs("div",{className:"limbo-image-card "+(H?"limbo-image-card--mobile":""),children:[!A&&(t.thumbnail_url?l.jsxs("div",{className:"lb:relative lb:w-full lb:h-full lb:rounded lb:overflow-hidden lb:border lb:border-neutral-300",style:{...H&&{minHeight:`${Math.max(3*o,80)}px`}},children:[l.jsx("img",{src:t.thumbnail_url,alt:t.name||t.filename,className:"lb:w-full lb:h-full lb:object-cover lb:aspect-square",loading:"lazy",decoding:"async",draggable:!1,onError:e=>{e.target.style.display="none",e.target.nextElementSibling?.classList.remove("lb:hidden")}}),l.jsx("div",{className:(t.thumbnail_url?"lb:flex":"lb:hidden")+"lb:absolute lb:inset-0 lb:bg-linear-to-br lb:from-neutral-100 lb:to-neutral-200 lb:flex-col lb:items-center lb:justify-center",children:l.jsx("span",{className:"lb:mb-2 lb:h-[25%] lb:w-[25%]","aria-hidden":"true",children:l.jsx("span",{className:`icon ${L.symbol} lb:min-w-full lb:min-h-full`})})}),l.jsx("span",{className:"lb:absolute lb:bottom-1.5 lb:right-1.5 lb:text-[10px] lb:uppercase lb:font-bold lb:tracking-wide lb:px-1.5 lb:py-0.5 lb:rounded lb:shadow-sm",style:{backgroundColor:L.color,color:"white"},children:z||E})]}):l.jsxs("div",{className:"lb:w-full lb:h-full lb:rounded lb:bg-linear-to-br lb:from-neutral-100 lb:to-neutral-200 lb:flex lb:flex-col lb:items-center lb:justify-center lb:border lb:border-neutral-300",style:{...H&&{minHeight:`${Math.max(3*o,80)}px`}},children:[l.jsx("span",{className:"lb:mb-2 lb:h-[25%] lb:w-[25%]","aria-hidden":"true",children:l.jsx("span",{className:`icon ${L.symbol} lb:min-w-full lb:min-h-full`})}),l.jsx("span",{className:"lb:text-xs lb:uppercase lb:font-bold lb:tracking-wide lb:px-2 lb:py-0.5 lb:rounded",style:{backgroundColor:L.color,color:"white"},children:z||E})]})),A&&l.jsxs(l.Fragment,{children:[O&&!U&&l.jsx("div",{className:"lb:w-full lb:aspect-square lb:rounded lb:bg-neutral-200 lb:animate-pulse lb:flex lb:items-center lb:justify-center lb:absolute lb:inset-0 lb:z-10 "+(ee?"lb:ring-2 lb:ring-brand-blue-400 lb:ring-offset-2":""),style:{...H&&{minHeight:`${Math.max(3*o,80)}px`}},children:l.jsx("span",{className:"icon icon-spinner lb:w-8 lb:h-8 lb:animate-spin"})}),U&&!q&&l.jsxs("div",{className:"lb:z-0 lb:absolute lb:top-0 lb:left-0 lb:w-full lb:aspect-square lb:rounded lb:bg-neutral-100 lb:flex lb:flex-col lb:items-center lb:justify-center lb:text-neutral-400",style:{...H&&{minHeight:`${Math.max(3*o,80)}px`}},children:[l.jsx("span",{className:"icon icon-close icon--lg lb:mb-1","aria-hidden":"true"}),l.jsx("span",{className:"lb:text-xs",children:"Error al cargar"})]}),l.jsx("img",{ref:V,src:D,loading:"lazy",decoding:"async",alt:t.name||(t.filename.split(".")[0]??t.filename),className:`lb:z-1 lb:w-full lb:object-cover lb:rounded lb:aspect-square lb:transition-opacity lb:duration-300 ${ee?"lb:ring-2 lb:ring-brand-blue-400 lb:ring-offset-2":""} ${q?"lb:opacity-100":"lb:opacity-0"}`,sizes:`height: ${6*o}px,width: ${6*o}px`,draggable:!1,onLoad:()=>{F(!1),W(!0),B(!1)},onError:()=>{F(!1),B(!0)},style:{...H&&{minHeight:`${Math.max(3*o,80)}px`,height:"auto",aspectRatio:"1 / 1",objectFit:"cover"}}}),T&&l.jsx("span",{className:"lb:absolute lb:bottom-1.5 lb:right-1.5 lb:text-[10px] lb:uppercase lb:font-bold lb:tracking-wide lb:px-1.5 lb:py-0.5 lb:rounded lb:shadow-sm",style:{backgroundColor:L.color,color:"white"},children:z||E}),$&&!ee&&t.width&&t.height&&l.jsxs("span",{className:"lb:absolute lb:bottom-1.5 lb:right-1.5 lb:text-[10px] lb:font-bold lb:tracking-wide lb:px-1.5 lb:py-0.5 lb:rounded lb:shadow-sm lb:leading-tight lb:text-center lb:flex lb:flex-col lb:items-center",style:{backgroundColor:"rgba(15,23,42,0.72)",color:"white"},title:`${t.width} × ${t.height} px`,children:[l.jsxs("span",{children:[t.width,"×",t.height]}),M&&l.jsx("span",{style:{opacity:.85},children:M})]})]}),l.jsxs("div",{className:"limbo-card-info-overlay lb:z-9 "+(H?"limbo-card-info-overlay--mobile":""),children:[l.jsxs("span",{className:"limbo-card-info-name lb:truncate lb:max-w-full",children:[t.filename.split(".")[0]??t.filename,ee&&l.jsx("span",{className:"limbo-variants-indicator",style:{marginLeft:"4px",padding:"1px 6px",backgroundColor:"#dc2626",color:"white",borderRadius:"10px",fontSize:"10px",fontWeight:"700",display:"inline-block"},title:`${te} recorte${1!==te?"s":""}`,children:te})]}),c&&t.folder&&l.jsxs("span",{className:"limbo-card-info-folder lb:flex lb:items-center lb:gap-1 lb:bg-brand-blue-50 lb:rounded-md lb:px-1",title:`Carpeta: ${t.folder?.name||t.folder?.slug||t.folder}`,children:[l.jsx("span",{className:"icon icon-folder icon--sm"}),l.jsx("span",{className:"lb:truncate lb:max-w-20",children:t.folder?.name||t.folder?.slug||("string"==typeof t.folder?t.folder:"Sin carpeta")})]})]})]})]}),l.jsx(Oe,{image:t,isOpen:y,onClose:()=>x(!1),onSelect:r,onDelete:n,onCrop:a,onVariantDeleted:le,allowedActions:{select:p.select,download:p.download,copy:p.copy,delete:p.delete,crop:p.crop}}),l.jsx(Ke,{isOpen:j,asset:t,onClose:()=>N(!1),onSave:async(e,t)=>{try{await(i?.(e,t??null)),qe(),G?.announce(t?`${e.filename} movido a carpeta ${t.name}`:`${e.filename} movido a Sin carpeta`)}catch(l){throw console.error("Error moving to folder:",l),G?.announce(`Error al mover ${e.filename}`),l}},folderConfig:void 0!==m||d||b?{allowCreateFolder:m,include:d,exclude:b}:null}),w&&(()=>{const e=t.url||t.path,n=()=>k(!1),a=t.file_size?`${Math.round(t.file_size/1024)}KB`:"",r=t.mime_type||"";return A?l.jsx(Re,{isOpen:!0,src:e,alt:t.name||t.filename,title:t.filename,subtitle:`${t.width||"?"}×${t.height||"?"} · ${a}`,onClose:n,tags:t.tags||[]}):"video"===E?l.jsx(Ee,{isOpen:!0,src:e,title:t.filename,subtitle:`${z.toUpperCase()} · ${a}`,onClose:n}):"audio"===E?l.jsx(_e,{isOpen:!0,src:e,title:t.filename,subtitle:`${z.toUpperCase()} · ${a}`,onClose:n}):r.includes("pdf")?l.jsx($e,{isOpen:!0,src:e,title:t.filename,subtitle:a,onClose:n}):(e=>!(!e||!Xe.has(e)&&!e.startsWith("text/")))(r)?l.jsx(De,{isOpen:!0,src:e,title:t.filename,subtitle:`${z.toUpperCase()} · ${a}`,mimeType:r,fileSize:t.file_size||0,onClose:n}):l.jsx(Ie,{isOpen:!0,src:e,title:t.filename,subtitle:`${z.toUpperCase()} · ${a}`,mimeType:r,fileSize:t.file_size||0,onClose:n})})()]})});function Je(){return l.jsxs("div",{className:"limbo-image-card lb:animate-pulse",role:"status","aria-label":"Cargando imágen...",children:[l.jsx("div",{className:"lb:w-full lb:aspect-square lb:bg-neutral-gray-200 lb:rounded-md lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-spinner"})}),l.jsx("div",{className:"limbo-image-card-name lb:opacity-100 position-relative lb:bottom-0 lb:p-2",children:l.jsx("div",{className:"lb:h-4 lb:bg-neutral-gray-200 lb:rounded lb:w-3/4"})}),l.jsx("span",{className:"sr-only",children:"Cargando imágen..."})]})}const Ze=[{value:"",label:"Todos los tipos"},{value:"image",label:"Imágenes"},{value:"video",label:"Videos"},{value:"document",label:"Documentos"},{value:"audio",label:"Audio"}];function et({onSelect:t,onCrop:r,onDelete:i,deletingId:o,images:s,loading:c,error:u,filters:d={name:"",dateFrom:"",dateTo:"",uploadedBy:"",assetType:"",folder:""},debouncedFilters:b=null,onFiltersChange:m,filterConfig:p={showNameFilter:!0,showUploadedByFilter:!1,showDateFilter:!0,showTypeFilter:!1},loadingConfig:f={showPlaceholders:!0,placeholderCount:10,showSpinner:!0},allowedActions:g={select:!0,download:!0,copy:!0,delete:!0,crop:!0,variants:!0},allowedCategories:v=null,resolvedAccept:y=null,folderConfig:x=null,onFolderChange:w=null,onRename:k=null,onEdit:C=null}){const{isSearching:S,searchPending:j}=function(t,l,n){const[a,r]=e.useState(!1),i=e.useRef(null);return e.useEffect(()=>(Object.keys(t).some(e=>t[e]!==l[e])?i.current=setTimeout(()=>{r(!0)},150):(i.current&&clearTimeout(i.current),r(!1)),()=>{i.current&&clearTimeout(i.current)}),[t,l]),{isSearching:a||n,searchPending:a}}(d,b||d,c),N=!1!==p.showNameFilter,E=!0===p.showUploadedByFilter,_=!1!==p.showDateFilter,$=!1!==p.showTypeFilter,T=!0===x?.showFolderFilter,A=x?.include?.length>0?x.include:null,z=x?.exclude?.length>0?x.exclude:null,L=!1!==x?.showFolderInfo,M=!1!==x?.allowMoveFolder&&!!w,I=!0===x?.allowCreateFolder,P=e.useMemo(()=>{const e=y&&!y.isAllTypes?function(e){if(!e||e.isAllTypes)return null;const t=new Set(e.categories);for(const l of e.extensions){const e=n[l]||[];for(const l of e)for(const[e,n]of Object.entries(a))n.includes(l)&&t.add(e)}for(const l of e.mimeTypes)for(const[e,n]of Object.entries(a))(n.includes(l)||l.startsWith(e+"/"))&&t.add(e);return t.size>0?[...t]:null}(y):v;return e?Ze.filter(t=>""===t.value||e.includes(t.value)):Ze},[y,v]),D=e.useRef(null),R=window.limboCore?.accessibilityManager;e.useEffect(()=>{if(D.current&&window.limboCore?.keyboardManager){const e="gallery-grid";D.current.setAttribute("data-grid-id",e),window.limboCore.keyboardManager.setupGridNavigation(D.current,{itemSelector:".limbo-image-card",gridId:e,columns:"auto"})}},[s]),e.useEffect(()=>{if(!c&&s.length>0){const e=s.slice(0,12).map(e=>e.url||e.path).filter(Boolean);e.length>0&&Ce(e,4)}},[c,s]);const O=e.useMemo(()=>{if(!d.assetType)return"archivos";return{image:"imágenes",video:"videos",document:"documentos",audio:"archivos de audio"}[d.assetType]||"archivos"},[d.assetType]);e.useEffect(()=>{c?R?.announceLoading(!0,"galería"):c||u?u&&R?.announceError(u,"galería"):(R?.announceLoading(!1,"galería"),s.length>0&&R?.announce(`Se encontraron ${s.length} ${O} en la galería`))},[c,u,s.length,R,O]),e.useEffect(()=>{j&&R?.announce("Buscando...","polite")},[j,R]);const F=e=>{const{name:t,value:l}=e.target;m&&m({...d,[t]:l})},U=d.name||d.dateFrom||d.dateTo||d.uploadedBy||d.assetType||d.folder,B=S&&s.length>0&&!c;return l.jsxs("div",{className:"lb:w-full lb:max-w-full lb:py-2 lb:overflow-x-hidden lb:box-border",children:[l.jsx("div",{className:"lb:px-2 lb:mb-3 lb:mx-2 lb:max-w-full lb:overflow-x-hidden lb:box-border",children:l.jsxs("form",{className:"limbo-filters flex items-stretch content-stretch flex-row",onSubmit:e=>e.preventDefault(),role:"search","aria-label":"Filtrar archivos",children:[N&&l.jsxs("div",{className:"limbo-filter-group limbo-filter-group--name",children:[l.jsxs("label",{htmlFor:"name",className:"limbo-filter-label",children:["Buscar",j&&l.jsx("span",{className:"limbo-filter-searching","aria-hidden":"true",children:l.jsx("span",{className:"icon icon-spinner lb:animate-spin lb:w-3 lb:h-3"})})]}),l.jsx("input",{type:"text",name:"name",id:"name",placeholder:h("tags.search.placeholder"),value:d.name,onChange:F,className:"limbo-filter-input",autoComplete:"off"})]}),_&&l.jsxs("div",{className:"limbo-filter-dates lb:flex-row lb:md:flex ",children:[l.jsxs("div",{className:"limbo-filter-group limbo-filter-group--date",children:[l.jsx("label",{htmlFor:"dateFrom",className:"limbo-filter-label",children:"Desde"}),l.jsx("input",{type:"date",name:"dateFrom",id:"dateFrom",value:d.dateFrom,onChange:F,className:"limbo-filter-input"})]}),l.jsxs("div",{className:"limbo-filter-group limbo-filter-group--date",children:[l.jsx("label",{htmlFor:"dateTo",className:"limbo-filter-label",children:"Hasta"}),l.jsx("input",{type:"date",name:"dateTo",id:"dateTo",value:d.dateTo,onChange:F,className:"limbo-filter-input"})]})]}),$&&P.length>1&&l.jsxs("div",{className:"limbo-filter-group limbo-filter-group--type",children:[l.jsx("label",{htmlFor:"assetType",className:"limbo-filter-label",children:"Tipo"}),l.jsx("select",{name:"assetType",id:"assetType",value:d.assetType||"",onChange:F,className:"limbo-filter-input limbo-filter-select",children:P.map(e=>l.jsx("option",{value:e.value,children:e.label},e.value))})]}),T&&l.jsx("div",{className:"limbo-filter-group limbo-filter-group--folder",children:l.jsx(He,{value:d.folder||"",onChange:e=>F({target:{name:"folder",value:e?.slug||""}}),allowCreate:!1,label:"Carpeta",showAssetCount:!0,includeNoFolder:!0,allowedSlugs:A,excludeSlugs:z,mode:"filter"})}),E&&l.jsxs("div",{className:"limbo-filter-group",children:[l.jsx("label",{htmlFor:"uploadedBy",className:"limbo-filter-label",children:"Subido por"}),l.jsx("input",{type:"text",name:"uploadedBy",id:"uploadedBy",placeholder:"Usuario...",value:d.uploadedBy,onChange:F,className:"limbo-filter-input",style:{minWidth:"100px",maxWidth:"140px"}})]}),l.jsxs("div",{children:[l.jsx("span",{className:"lb:h-[37%] block"}),l.jsxs("button",{type:"button",onClick:()=>{m&&m({name:"",uploadedBy:"",dateFrom:"",dateTo:"",assetType:"",folder:""})},disabled:!U,className:"limbo-filter-clear-btn","aria-label":"Limpiar todos los filtros",title:"Limpiar filtros",children:[l.jsx("span",{className:"icon icon-close-small"}),"Limpiar"]})]})]})}),c?l.jsxs("div",{className:"lb:relative",children:[l.jsx("div",{className:"lb:relative lb:inset-0 lb:flex lb:items-center lb:justify-center lb:bg-white/80 lb:z-10 lb:min-h-75",children:l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-3",children:[l.jsx("span",{className:"icon icon-spinner lb:p-4 lb:animate-spin"}),l.jsxs("span",{className:"lb:text-sm lb:text-gray-600 lb:font-medium",children:["Cargando ",O,"..."]})]})}),f.showPlaceholders&&l.jsx("div",{ref:D,className:"limbo-gallery lb:opacity-30","data-limbo-responsive":!0,role:"grid","aria-label":`Cargando ${O} de la galería`,"aria-busy":"true",children:Array.from({length:f.placeholderCount}).map((e,t)=>l.jsx("div",{role:"gridcell","aria-posinset":t+1,"aria-setsize":f.placeholderCount,className:"lb:min-w-0",children:l.jsx(Je,{})},`skeleton-${t}`))})]}):u?l.jsx(fe,{variant:"danger",className:"lb:text-center",children:u}):l.jsxs("div",{className:"lb:relative",children:[B&&l.jsx("div",{className:"limbo-search-overlay",role:"status","aria-live":"polite","aria-label":"Buscando archivos",children:l.jsxs("div",{className:"limbo-search-overlay__content",children:[l.jsx("span",{className:"icon icon-spinner lb:animate-spin"}),l.jsx("span",{children:"Buscando..."})]})}),l.jsx("div",{ref:D,className:"limbo-gallery lb:px-3 lb:pt-4 lb:box-border lb:max-w-full "+(B?"lb:opacity-50 lb:pointer-events-none":""),"data-limbo-responsive":!0,"data-grid-id":"gallery-grid",role:"grid","aria-label":`Galería de ${O}. Use las flechas para navegar`,"aria-busy":B,children:s.length>0?s.map((e,n)=>l.jsx("div",{role:"gridcell","aria-posinset":n+1,"aria-setsize":s.length,className:"lb:min-w-0",children:l.jsx(Ye,{image:e,onSelect:t,onCrop:r,onDelete:g.delete&&i?()=>i(e.id):null,onFolderChange:w,onRename:k,onEdit:C,thumbnailSize:32,isDeleting:o===e.id,showFolderInfo:L,allowMoveFolder:M,allowedFolderSlugs:A,excludedFolderSlugs:z,allowCreateFolder:I,allowedActions:g})},e.id)):l.jsx("div",{className:"lb:col-span-full lb:text-center lb:text-gray-500 lb:py-8",role:"status","aria-live":"polite",children:l.jsxs("p",{children:["No se han encontrado ",O]})})})]})]})}function tt({currentPage:t,totalPages:n,onPageChange:a,disabled:r=!1}){if(!n||n<=1)return null;const i=(()=>{const e=[],l=[],a=Math.max(1,t-2),r=Math.min(n,t+2);for(let t=a;t<=r;t++)e.push(t);return a>1&&(l.push(1),a>2&&l.push("...")),l.push(...e),r<n&&(r<n-1&&l.push("..."),l.push(n)),l})();return l.jsx("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:space-x-2 lb:py-4",children:l.jsxs("div",{className:"lb:flex lb:space-x-2 lb:mt-2",children:[l.jsxs("button",{onClick:()=>{t>1&&a(t-1)},disabled:r||t<=1,className:` lb:px-3 lb:py-2 lb:text-sm lb:font-medium lb:rounded-md lb:transition-colors lb:disabled:cursor-default lb:cursor-pointer ${r||t<=1?"lb:text-gray-400 lb:bg-gray-100 lb:cursor-not-allowed":"lb:text-gray-700 lb:bg-white lb:border lb:border-gray-300 lb:hover:bg-gray-50 lb:focus:ring-2 lb:focus:ring-blue-500"} `,children:[l.jsx("span",{className:"icon icon-arrow-left icon--sm"})," Anterior"]}),l.jsx("div",{className:"lb:flex lb:space-x-1",children:i.map((n,i)=>l.jsx(e.Fragment,{children:"..."===n?l.jsx("span",{className:"lb:px-3 lb:py-2 lb:text-sm lb:text-gray-500",children:"..."}):l.jsx("button",{onClick:()=>(e=>{e!==t&&a(e)})(n),disabled:r,className:` lb:px-3 lb:py-2 lb:text-sm lb:font-medium lb:rounded-md lb:transition-colors lb:disabled:cursor-default lb:cursor-pointer ${n===t?"lb:bg-brand-blue-800 lb:text-white lb:border lb:border-brand-blue-1000":r?"lb:text-gray-400 lb:bg-gray-100 lb:cursor-not-allowed":"lb:text-gray-700 lb:bg-white lb:border lb:border-gray-300 lb:hover:bg-gray-50 lb:focus:ring-2 lb:focus:ring-blue-500"} `,children:n})},`page-${n}-${i}`))}),l.jsxs("button",{onClick:()=>{t<n&&a(t+1)},disabled:r||t>=n,className:` lb:px-3 lb:py-2 lb:text-sm lb:font-medium lb:rounded-md lb:transition-colors lb:disabled:cursor-default lb:cursor-pointer ${r||t>=n?"lb:text-gray-400 lb:bg-gray-100 lb:cursor-not-allowed":"lb:text-gray-700 lb:bg-white lb:border lb:border-gray-300 lb:hover:bg-gray-50 lb:focus:ring-2 lb:focus:ring-blue-500"} `,children:["Siguiente ",l.jsx("span",{className:"icon icon-arrow-right icon--sm"})]})]})})}function lt({text:e="Cargando..."}){return l.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-neutral-gray-1000/20 lb:z-10 lb:flex lb:flex-col lb:items-center lb:justify-center lb:py-8 lb:text-gray-600",role:"status","aria-live":"polite","aria-label":e,children:[l.jsx("span",{className:"limbo-filter-searching","aria-hidden":"true",children:l.jsx("span",{className:"icon icon-spinner lb:animate-spin lb:min-w-7 lb:min-h-7"})}),l.jsx("p",{className:"lb:text-sm",id:"loader-text",children:e})]})}function nt({onSelect:e,onCrop:t,onDelete:n,onFolderChange:a,onRename:r,onEdit:i,onPageChange:o,onFiltersChange:s,images:c,loadingImages:u,imagesError:d,deleting:b,uploadedImage:m,pagination:h,currentPage:p,galleryFilters:f,debouncedFilters:g,allowedActions:v,resolvedAccept:y,allowedCategories:x,folderConfig:w,filterConfig:k,loadingConfig:C,resetUpload:S}){return l.jsxs(l.Fragment,{children:[b&&l.jsx(lt,{text:"Eliminando archivo..."}),m&&l.jsxs(fe,{variant:"success",toast:!0,onClose:S,children:[l.jsx("span",{className:"icon icon-tick-white icon--2sm"})," Archivo subido correctamente: ",m.filename]}),l.jsx(et,{onSelect:e,onCrop:t,onDelete:n,deletingId:b,images:c,loading:u,error:d,filters:f,debouncedFilters:g,onFiltersChange:s,filterConfig:k,loadingConfig:C,allowedActions:v,resolvedAccept:y,allowedCategories:x,folderConfig:w,onFolderChange:a,onRename:r,onEdit:i}),h&&!u&&l.jsx(tt,{currentPage:h.page||p,totalPages:h.pages||1,onPageChange:o,disabled:u||b})]})}function at({previewUrl:t,fileName:n}){const[a,r]=e.useState(!1),[i,o]=e.useState(!1),s=e.useRef(null);return i?l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:p-8 lb:min-h-[200px] lb:bg-gray-100 lb:rounded-lg",children:[l.jsx("span",{className:"icon icon-video icon--xl lb:text-gray-400 lb:mb-4"}),l.jsx("p",{className:"lb:text-sm lb:text-gray-600",children:"No se puede reproducir el video"}),l.jsx("p",{className:"lb:text-xs lb:text-gray-500 lb:mt-1",children:n})]}):l.jsxs("div",{className:"lb:relative lb:w-full lb:min-w-65 lb:max-w-md lb:aspect-video lb:bg-black lb:rounded-lg lb:overflow-hidden",children:[l.jsx("video",{ref:s,src:t,className:"lb:absolute lb:inset-0 lb:w-full lb:h-full lb:object-contain",onEnded:()=>{r(!1)},onError:()=>{o(!0)},onPlay:()=>r(!0),onPause:()=>r(!1),controls:!0,preload:"metadata",children:"Tu navegador no soporta la reproduccion de video."}),!a&&l.jsx("button",{type:"button",onClick:()=>{s.current&&(a?s.current.pause():s.current.play(),r(!a))},className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center lb:bg-black/30 lb:hover:bg-black/40 lb:transition-colors lb:cursor-pointer","aria-label":"Reproducir video",children:l.jsx("div",{className:"lb:w-16 lb:h-16 lb:rounded-full lb:bg-white/90 lb:flex lb:items-center lb:justify-center lb:shadow-lg",children:l.jsx("span",{className:"icon icon-play icon--lg lb:text-gray-800 lb:ml-1"})})}),l.jsxs("div",{className:"lb:absolute lb:top-2 lb:right-2 lb:bg-black/60 lb:text-white lb:px-2 lb:py-1 lb:rounded lb:text-xs lb:flex lb:items-center lb:gap-1",children:[l.jsx("span",{className:"icon icon-video icon--xs"}),l.jsx("span",{children:"VIDEO"})]})]})}function rt({previewUrl:t,fileName:n,fileSize:a}){const[r,i]=e.useState(!1),[o,s]=e.useState(!1),[c,u]=e.useState(0),[d,b]=e.useState(0),m=e.useRef(null),h=e=>{if(!e||isNaN(e))return"0:00";return`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,"0")}`};return o?l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:p-8 lb:min-h-50 lb:bg-gray-100 lb:rounded-lg",children:[l.jsx("span",{className:"icon icon-audio icon--xl lb:text-gray-400 lb:mb-4"}),l.jsx("p",{className:"lb:text-sm lb:text-gray-600",children:"No se puede reproducir el audio"}),l.jsx("p",{className:"lb:text-xs lb:text-gray-500 lb:mt-1",children:n})]}):l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:justify-center lb:p-6 lb:min-h-50",children:[l.jsxs("div",{className:"lb:relative lb:mb-4",children:[l.jsx("div",{className:"lb:w-24 lb:h-24 lb:flex lb:items-center lb:justify-center lb:bg-linear-to-br lb:from-purple-100 lb:to-blue-100 lb:rounded-full",children:l.jsx("span",{className:"icon icon-audio icon--xl lb:text-purple-600"})}),l.jsx("button",{type:"button",onClick:()=>{m.current&&(r?m.current.pause():m.current.play())},className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center lb:rounded-full lb:bg-black/0 lb:hover:bg-black/10 lb:transition-colors lb:cursor-pointer","aria-label":r?"Pausar":"Reproducir",children:l.jsx("div",{className:"lb:w-10 lb:h-10 lb:rounded-full lb:bg-white lb:shadow-md lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:`icon ${r?"icon-pause":"icon-play"} icon--md lb:text-gray-800 ${r?"":"lb:ml-0.5"}`})})})]}),l.jsx("p",{className:"lb:text-sm lb:font-medium lb:text-gray-800 lb:text-center lb:max-w-full lb:truncate lb:px-4",children:n}),l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:mt-2 lb:text-xs lb:text-gray-500",children:[l.jsx("span",{children:h(d)}),l.jsx("span",{children:"/"}),l.jsx("span",{children:h(c)}),a&&l.jsxs(l.Fragment,{children:[l.jsx("span",{children:"•"}),l.jsx("span",{children:Le(a)})]})]}),l.jsx("div",{className:"lb:w-full lb:max-w-xs lb:mt-3",children:l.jsx("div",{className:"lb:h-1.5 lb:bg-gray-200 lb:rounded-full lb:overflow-hidden lb:cursor-pointer",onClick:e=>{if(!m.current||!c)return;const t=e.currentTarget.getBoundingClientRect(),l=e.clientX-t.left;m.current.currentTime=l/t.width*c},role:"slider","aria-label":"Progreso de audio","aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":c,tabIndex:0,children:l.jsx("div",{className:"lb:h-full lb:bg-purple-500 lb:rounded-full lb:transition-all lb:duration-100 lb:pointer-events-none",style:{width:c>0?d/c*100+"%":"0%"}})})}),l.jsx("audio",{ref:m,src:t,onPlay:()=>i(!0),onPause:()=>i(!1),onTimeUpdate:()=>{m.current&&b(m.current.currentTime)},onLoadedMetadata:()=>{m.current&&u(m.current.duration)},onEnded:()=>{i(!1),b(0)},onError:()=>{s(!0)},preload:"metadata"})]})}function it({file:t,image:n,onDiscard:a,onRetry:r,onDownload:i,onSelect:o,showRetry:s=!1,disabled:c=!1,showCropButton:u,onTagsChange:d=null,tags:b=[],selectedFolder:m=null,onFolderChange:h=null,folderConfig:p=null}){const f=t||n,[g,v]=e.useState(null),[y,x]=e.useState({name:"",size:"",type:"",category:"unknown"}),[w,k]=e.useState(!1),[C,S]=e.useState(!1),[j,N]=e.useState(""),E="image"===y.category,_="video"===y.category,$="audio"===y.category,T=void 0!==u?u:E;e.useEffect(()=>{if(!f)return void v(null);const e=URL.createObjectURL(f);v(e);const t=f.name||"archivo",l=f.type||"",n=(e=>e?e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":"application/pdf"===e||e.includes("document")||e.includes("msword")||e.includes("spreadsheet")||e.includes("presentation")||e.startsWith("text/")?"document":"unknown":"unknown")(l),a=(e=>{const t=e?.split(".")[0]?.toLowerCase()||"";return["ai-image","ai_image","generated","imagen-ia","imagen_ia"].some(e=>t.startsWith(e))})(t);if(x({name:t,size:Le(f.size||0),type:l,category:n}),a)N(""),S(!1);else{const e=t.split(".")[0];N(e)}return()=>{URL.revokeObjectURL(e)}},[f]);if(!f||!g)return null;return l.jsxs("div",{className:"lb:w-full lb:max-w-full lb:bg-white lb:border lb:border-gray-200 lb:rounded-lg lb:px-1 lb:sm:px-3 lb:py-2 lb:m-0 lb:shadow-sm lb:overflow-hidden lb:box-border",children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:mb-4 lb:px-1",children:[l.jsx("h3",{className:"lb:text-sm lb:font-medium lb:text-gray-700",children:(()=>{switch(y.category){case"image":return"Vista previa de imagen";case"video":return"Vista previa de video";case"audio":return"Vista previa de audio";case"document":return"Vista previa de documento";default:return"Vista previa de archivo"}})()}),l.jsx("button",{type:"button",onClick:a,disabled:c,className:"lb:p-1.5 lb:text-gray-400 lb:cursor-pointer lb:hover:text-gray-600 lb:hover:bg-red-300 lb:rounded lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":"Descartar archivo",title:"Descartar archivo",children:l.jsx("span",{className:"icon icon-close-small icon--md"})})]}),l.jsx("div",{className:"lb:flex lb:justify-center lb:content-stretch lb:items-stretch",children:l.jsxs("div",{className:"lb:flex lb:flex-col lb:justify-stretch lb:content-stretch",children:[p?.showFolderSelector&&h&&l.jsx("div",{className:"lb:mb-4 lb:px-1 lb:flex lb:items-stretch lb:justify-stretch",children:l.jsx(He,{value:m?.slug||m,onChange:h,allowCreate:!1!==p?.allowCreateFolder,label:"Guardar en carpeta",showAssetCount:!0,className:"lb:w-full",allowedSlugs:p?.include?.length>0?p.include:null,mode:"upload",disabled:c})}),d&&l.jsxs("div",{className:"lb:mb-4 lb:px-1",children:[l.jsx("label",{className:"lb:block lb:text-sm lb:font-semibold lb:text-neutral-gray-700 lb:mb-2",children:b.length>0?"Etiquetas":"Etiquetas (opcional)"}),l.jsx(ne,{value:b,onChange:d,disabled:c,id:"asset-preview-tags"}),l.jsx("p",{className:"lb:text-xs lb:text-neutral-gray-500 lb:mt-2",children:"Pulsa espacio o coma para confirmar una etiqueta"})]}),l.jsxs("div",{className:"lb:flex lb:flex-col lb:justify-center lb:md:flex-row lb:gap-2 lb:md:gap-6",children:[l.jsxs("div",{className:"lb:flex-1 lb:flex lb:flex-col lb:items-center lb:justify-center"+(E?" lb:min-w-100":""),children:[E?l.jsxs("div",{className:"lb:relative lb:w-full lb:max-w-md lb:aspect-video lb:bg-gray-100 lb:rounded-lg lb:overflow-hidden lb:cursor-zoom-in lb:hover:ring-2 lb:hover:ring-brand-blue-800 lb:transition-all",onClick:()=>k(!0),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),k(!0))},"aria-label":"Click para ver imagen en tamano completo",title:"Click para ver en tamano completo",children:[l.jsx("img",{src:g,alt:"Vista previa",className:"lb:absolute lb:inset-0 lb:w-full lb:h-full lb:object-contain"}),l.jsxs("div",{className:"lb:absolute lb:top-2 lb:right-2 lb:bg-black/50 lb:text-white lb:px-2 lb:py-1 lb:rounded lb:text-xs lb:flex lb:items-center lb:gap-1",children:[l.jsx("span",{className:"icon icon-search-white icon--xs"}),l.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Ampliar"})]})]}):_?l.jsx(at,{previewUrl:g,fileName:y.name}):$?l.jsx(rt,{previewUrl:g,fileName:y.name,fileSize:f?.size}):l.jsx(Me,{file:f,mimeType:y.type,category:y.category}),E&&l.jsx("div",{className:"lb:mt-3 lb:text-center lb:space-y-1 lb:w-full",children:l.jsx("div",{className:"lb:rounded-sm lb:w-fit lb:gap-0.5 lb:p-0.5 lb:min-w-fit lb:mx-auto",children:l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:gap-3 lb:text-xs lb:text-gray-500",children:[l.jsx("span",{children:y.size}),l.jsx("span",{children:"•"}),l.jsx("span",{children:y.type.split("/")[1]?.toUpperCase()||"FILE"})]})})})]}),l.jsxs("div",{className:"lb:flex lb:flex-row lb:md:flex-col lb:gap-2 lb:justify-items-stretch lb:justify-center lb:md:justify-start lb:items-stretch lb:md:min-w-35",children:[l.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-1",children:[l.jsxs("label",{htmlFor:"assetPreviewNameInput",className:"lb:flex lb:items-center lb:w-fit",children:[l.jsx("span",{className:"lb:me-1 lb:text-sm",children:"Nombre:"}),l.jsx("input",{id:"assetPreviewNameInput",onChange:e=>(e=>{const t=e.target.value.trim();N(e.target.value),t.length>0&&S(!1);const l=y.name,n=l.lastIndexOf("."),a=-1!==n?l.substring(n):"";x(e=>({...e,name:t?t+a:a}))})(e),value:j,className:"limbo-input-image-name lb:w-fit lb:px-1 lb:text-sm lb:font-medium lb:text-gray-800 lb:border lb:rounded lb:truncate lb:focus:outline lb:focus:outline-neutral-gray-100 lb:focus:transform-none lb:focus:shadow-none lb:focus:opacity-100 "+(C?"lb:border-red-1000 lb:bg-red-50":"lb:border-gray-300"),placeholder:"Escribe un nombre...",title:"El nombre es obligatorio",required:!0})]}),C&&l.jsx("span",{className:"lb:text-xs lb:text-red-1000 lb:ml-1",children:"El nombre es obligatorio"})]}),s&&r&&l.jsxs("button",{type:"button",onClick:r,disabled:c,className:"lb:flex-1 lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-white lb:border lb:border-gray-300 lb:text-gray-700 lb:rounded-lg lb:hover:bg-gray-50 lb:cursor-pointer lb:hover:border-gray-400 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium","aria-label":"Intentarlo de nuevo",title:"Generar de nuevo con el mismo prompt",children:[l.jsx("span",{className:"icon icon-refresh icon--sm"}),l.jsx("span",{className:"lb:hidden lb:sm:inline",children:"Reintentar"}),l.jsx("span",{className:"lb:sm:hidden",children:"Retry"})]}),l.jsxs("button",{type:"button",onClick:()=>{if(!g||c)return;const e=document.createElement("a");e.href=g,e.download=y.name,document.body.appendChild(e),e.click(),document.body.removeChild(e),i&&i()},disabled:c,className:"lb:flex-1 lb:cursor-pointer lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-white lb:border lb:border-gray-300 lb:text-gray-700 lb:rounded-lg lb:hover:bg-gray-50 lb:hover:border-gray-400 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium","aria-label":"Descargar archivo",children:[l.jsx("span",{className:"icon icon-download icon--sm"}),l.jsx("span",{children:"Descargar"})]}),l.jsxs("button",{type:"button",onClick:()=>{j.trim()?(S(!1),o&&o(y.name,b)):S(!0)},disabled:c,className:"lb:flex-1 lb:md:flex-none lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-4 lb:py-2.5 lb:bg-brand-blue-800 lb:border lb:border-brand-blue-800 lb:text-white lb:rounded-lg lb:hover:bg-brand-blue-1000 lb:cursor-pointer lb:hover:border-brand-blue-1000 lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed lb:text-sm lb:font-medium lb:shadow-sm","aria-label":T?"Seleccionar para recortar":"Seleccionar archivo",children:[l.jsx("span",{className:"icon icon-tick-white icon--sm"}),l.jsx("span",{children:"Seleccionar"})]})]})]})]})}),E&&l.jsx(Re,{isOpen:w,src:g,alt:y.name,title:y.name,subtitle:`${y.size} • ${y.type.split("/")[1]?.toUpperCase()||"IMAGE"}`,onClose:()=>k(!1)})]})}const ot={image:["image/jpeg","image/png","image/webp","image/svg+xml"],video:["image/gif","video/mp4","video/webm","video/quicktime","video/x-msvideo"],document:["application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","text/plain","text/csv","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation"],audio:["audio/mpeg","audio/wav","audio/ogg","audio/webm"]},st={image:"JPG, PNG, SVG, WebP, GIF",video:"GIF, MP4, WebM, MOV, AVI",document:"PDF, DOC, DOCX, XLS, XLSX, TXT, PPT, PPTX",audio:"MP3, WAV, OGG"},ct=["image","video","document","audio"];function ut({file:t,setFile:n,setPreviewUrl:a,fileInputRef:r,onSelect:i,disabled:o,allowedCategories:s=null,resolvedAccept:u=null,selectedFolder:d=null,onFolderChange:b=null,folderConfig:m=null,tags:h=[],onTagsChange:p=null}){const[f,g]=e.useState(!1),{acceptAttribute:v,allowedMimeTypes:y,formatLabels:x,categories:w}=e.useMemo(()=>{if(u&&!u.isAllTypes)return{acceptAttribute:u.acceptString,allowedMimeTypes:new Set(u.mimeTypes),formatLabels:c(u),categories:u.categories.length>0?u.categories:ct};const e=null===s?ct:s,t=[],l=[];return e.forEach(e=>{ot[e]&&(t.push(...ot[e]),st[e]&&l.push(st[e]))}),{acceptAttribute:t.join(","),allowedMimeTypes:new Set(t),formatLabels:l.join(", "),categories:e}},[s,u]),k=u&&!u.isAllTypes?u.includesImages&&1===u.categories.length&&"image"===u.categories[0]:1===w.length&&"image"===w[0],C=e=>{if(n(e),e){const t=URL.createObjectURL(e);a(t)}else a(null)};return l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-6","aria-label":k?"Subir imagen desde dispositivo":"Subir archivo desde dispositivo",children:[l.jsxs("label",{htmlFor:"file-input",className:"lb:w-full lb:max-w-full lb:flex lb:flex-col lb:items-center lb:justify-center lb:border-2 lb:border-dashed lb:rounded-xl lb:p-8 lb:cursor-pointer lb:transition lb:box-border "+(f?"lb:border-brand-blue-1000 lb:bg-brand-blue-100 lb:scale-[1.02]":"lb:border-brand-blue-200 lb:hover:border-brand-blue-1000 lb:hover:to-bright-blue-200 lb:hover:from-brand-blue-50 lb:focus-within:border-brand-blue-800 lb:from-bright-blue-50 lb:to-brand-blue-50 lb:bg-linear-to-br"),tabIndex:0,style:{outline:"none"},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),o||g(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),e.currentTarget.contains(e.relatedTarget)||g(!1)},onDrop:e=>{if(e.preventDefault(),e.stopPropagation(),g(!1),o)return;const t=e.dataTransfer?.files;if(t&&t.length>0){const e=t[0];(e=>{if(!e||!e.type)return!1;if(u&&!u.isAllTypes)return function(e,t){if(!t||t.isAllTypes)return!0;if(!e)return!1;if(t.mimeTypes.includes(e))return!0;for(const l of t.categories)if(e.startsWith(l+"/"))return!0;return!1}(e.type,u);if(y.has(e.type))return!0;for(const t of w)if("image"===t&&e.type.startsWith("image/")||"video"===t&&e.type.startsWith("video/")||"audio"===t&&e.type.startsWith("audio/"))return!0;return!1})(e)&&C(e)}},children:[l.jsx("span",{className:"icon icon-upload icon--lg lb:mb-2","aria-hidden":"true"}),l.jsx("span",{className:"lb:font-medium lb:text-brand-blue-1000 lb:mb-1",children:k?"Haz clic o arrastra una imagen aqui":"Haz clic o arrastra un archivo aqui"}),l.jsxs("span",{className:"lb:text-sm lb:text-neutral-700",children:["Formatos permitidos: ",l.jsx("span",{className:"lb:wrap-break-word",children:x})]}),l.jsx("input",{id:"file-input",ref:r,type:"file",accept:v,onChange:e=>{const t=e.target.files[0];C(t)},disabled:o,className:"lb:sr-only","aria-label":k?"Seleccionar imagen":"Seleccionar archivo"})]}),t&&l.jsx(it,{file:t,onDiscard:()=>{n(null),a(null),r.current&&(r.current.value="")},onDownload:()=>{},onSelect:e=>{if(t&&!o&&i)if(e&&e!==t.name){const l=new File([t],e,{type:t.type});i(l,h)}else i(t,h)},showRetry:!1,disabled:o,selectedFolder:d,onFolderChange:b,folderConfig:m,tags:h,onTagsChange:p})]})}const dt="/api";const bt=new Map;function mt(t=!1){const[l,n]=e.useState([]),[a,r]=e.useState(!0),[i,o]=e.useState(null);e.useEffect(()=>{const e=`ai-services-${t}`,l=bt.get(e),a=Date.now();if(l&&a-l.timestamp<864e5)return n(l.data),void r(!1);let i=!0;return(async()=>{try{const l=await function(e=!1){return W({endpoint:"/ai/services",prod:e,basePath:dt})}(t);if(!i)return;const r=l?.data||l?.result||[],o=Array.isArray(r)?r.map(e=>({label:e.name||e.label,slug:e.slug,type:e.type,description:e.description,image:e.image,costInfo:e.cost_info||null,supportsImageInput:e.supports_image_input||!1})):Object.entries(r).map(([e,t])=>({label:e,slug:t,type:"image_generation",description:null,image:null,costInfo:null,supportsImageInput:!1}));n(o),bt.set(e,{data:o,timestamp:a})}catch(l){i&&o(l.message)}finally{i&&r(!1)}})(),()=>{i=!1}},[t]);return{services:l,loading:a,error:i,invalidateCache:()=>{bt.delete(`ai-services-${t}`)}}}const ht=new Map;function pt(t=!1){const[l,n]=e.useState(null),[a,r]=e.useState(!1),[i,o]=e.useState(null);return{params:l,loading:a,error:i,fetchParams:async e=>{r(!0),o(null);const l=`${t}-${e}`,a=Date.now(),i=ht.get(l);if(i&&a-i.timestamp<864e5)return n(i.data),r(!1),i.data;try{const r=await function({services:e=null,form:t=!1}={},l=!1){const n={};return e&&(n.services=e),!1!==t&&(n.form=t),W({endpoint:"/ai/params"+(Object.keys(n).length?"?"+new URLSearchParams(n).toString():""),method:"GET",prod:l,basePath:"/api/atenea"})}({services:e,form:!1},t),i=r?.result?.data||r?.data||r?.result||r;return n(i),ht.set(l,{data:i,timestamp:a}),i}catch(s){return o(s.message),n(null),null}finally{r(!1)}},reset:()=>{o(null),n(null)}}}function ft({show:e=!1,message:t="Cargando...",className:n=""}){return e?l.jsx("div",{className:`lb:absolute lb:inset-0 lb:min-h-50 lb:bg-white/80 lb:backdrop-blur-sm lb:z-50 lb:flex lb:flex-col lb:items-center lb:justify-center ${n}`,"aria-live":"polite","aria-busy":"true",role:"status",children:l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-4",children:[l.jsx("span",{className:"icon icon-spinner lb:p-4 lb:animate-spin"}),l.jsx("p",{className:"lb:text-brand-blue-1000 lb:font-medium lb:text-lg",children:t})]})}):null}function gt({aiStarterPrompt:t,useStarter:n,onUseStarterChange:a}){const[r,i]=e.useState(!1),[o,s]=e.useState(!1),c=e.useRef(null),u=e.useId();if(e.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),null==t||""===t)return null;const d=n?"lb:rounded-md lb:border lb:border-brand-blue-1000 lb:bg-brand-blue-50 lb:p-4 lb:cursor-pointer lb:transition-all lb:duration-150 lb:mb-6 lb:w-full":"lb:rounded-md lb:border lb:border-neutral-gray-100 lb:bg-neutral-gray-25 lb:p-4 lb:cursor-pointer lb:opacity-55 lb:transition-all lb:duration-150 lb:mb-6 lb:w-full",b=r?"lb:text-[13px] lb:leading-[1.4] lb:text-neutral-gray-800 lb:whitespace-pre-wrap lb:break-words":"lb:text-[13px] lb:leading-[1.4] lb:text-neutral-gray-800 lb:truncate",m=o?"lb:text-xs lb:font-normal lb:text-green-1000 lb:px-2 lb:py-1 lb:rounded lb:bg-green-50":"lb:text-xs lb:font-normal lb:text-neutral-gray-700 lb:px-2 lb:py-1 lb:rounded lb:hover:bg-neutral-gray-50 lb:transition-colors";return l.jsxs("div",{role:"region","aria-label":h("aiStarter.label"),onClick:()=>{a(!n)},className:d,children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:gap-2 lb:mb-2",children:[l.jsxs("label",{className:"lb:flex lb:items-center lb:gap-2 lb:cursor-pointer",onClick:e=>e.stopPropagation(),children:[l.jsx("input",{type:"checkbox",checked:n,onChange:e=>{e.stopPropagation(),a(e.target.checked)},"aria-label":h("aiStarter.label"),onClick:e=>e.stopPropagation()}),l.jsx("span",{className:"lb:text-xs lb:font-semibold lb:text-brand-blue-1000 lb:select-none",children:h("aiStarter.label")})]}),l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-1 lb:shrink-0",role:"group","aria-label":h("aiStarter.label"),children:[l.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),"undefined"!=typeof navigator&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(t).catch(()=>{}),s(!0),c.current&&clearTimeout(c.current),c.current=setTimeout(function(){s(!1),c.current=null},2e3)},"aria-label":h(o?"aiStarter.copied":"aiStarter.copyAriaLabel"),"aria-live":"polite","aria-atomic":"true",className:m,children:h(o?"aiStarter.copied":"aiStarter.copy")}),l.jsx("button",{type:"button",onClick:e=>{e.stopPropagation(),i(e=>!e)},"aria-expanded":r,"aria-controls":u,"aria-label":h(r?"aiStarter.readLess":"aiStarter.readMore"),className:"lb:text-xs lb:font-normal lb:text-neutral-gray-700 lb:px-2 lb:py-1 lb:rounded lb:hover:bg-neutral-gray-50 lb:transition-colors",children:h(r?"aiStarter.readLess":"aiStarter.readMore")})]})]}),l.jsx("div",{id:u,className:b,children:t})]})}function vt(e){return new Promise((t,l)=>{const n=new FileReader;n.onload=()=>t(n.result),n.onerror=l,n.readAsDataURL(e)})}function yt({prod:t,disabled:n,onSelect:a,selectedFolder:r,onFolderChange:i,folderConfig:o,aiStarterPrompt:s,tags:c=[],onTagsChange:u=null}){const d=mt(t),b=pt(t),[m,h]=e.useState(""),[p,f]=e.useState(""),[g,v]=e.useState({}),[y,x]=e.useState(!1),[w,k]=e.useState(null),[C,S]=e.useState(null),[j,N]=e.useState(null),[E,_]=e.useState(!0),[$,T]=e.useState(!1),[A,z]=e.useState([null,null]),[L,M]=e.useState([null,null]),[I,P]=e.useState(null),[D,R]=e.useState(!0),O=[e.useRef(null),e.useRef(null)],F=e.useRef([0,0]);e.useEffect(()=>{if(!d.loading&&1===d.services.length){const e=d.services[0];f(e.slug),_(!1),b.fetchParams(e.slug,!0)}},[d.loading,d.services]),e.useEffect(()=>{if(!p)return;const e=b.params?.[p]?.parameters;if(e){const t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default??""]));t.service=p,v(t)}},[p,b.params]);const U=e.useMemo(()=>{const e=d.services.find(e=>e.slug===p);if(e?.supportsImageInput)return!0;const t=b.params?.[p]?.parameters;return!!t&&Object.entries(t).some(([e,t])=>"image"===t.type||"file"===t.type||"image_data"===e||"image"===e||"reference_image"===e)},[p,d.services,b.params]),B=(e,t)=>{e&&(["image/jpeg","image/png","image/webp","image/svg+xml"].includes(e.type)?e.size>4194304?k("La imagen de referencia no puede superar los 4MB."):(z(l=>{const n=[...l];return n[t]=e,n}),M(l=>{const n=[...l];return n[t]&&URL.revokeObjectURL(n[t]),n[t]=URL.createObjectURL(e),n}),k(null)):k("Formato no soportado. Usa JPG, PNG, SVG o WebP."))},q=e=>t=>{B(t.target.files?.[0],e)},V=e=>t=>{t.preventDefault(),t.stopPropagation(),F.current[e]++,P(e)},H=e=>t=>{t.preventDefault(),t.stopPropagation(),F.current[e]--,0===F.current[e]&&P(null)},K=e=>{e.preventDefault(),e.stopPropagation()},G=e=>t=>{t.preventDefault(),t.stopPropagation(),F.current[e]=0,P(null),B(t.dataTransfer?.files?.[0],e)},Q=e=>{z(t=>{const l=[...t];return l[e]=null,l}),M(t=>{const l=[...t];return l[e]&&URL.revokeObjectURL(l[e]),l[e]=null,l}),O[e]?.current&&(O[e].current.value="")};e.useEffect(()=>{const e=L;return()=>{e.forEach(e=>{e&&URL.revokeObjectURL(e)})}},[]);const X=e=>{const{name:t,value:l}=e.target;v(e=>({...e,[t]:l}))},Y=async(e,l=!1)=>{e.preventDefault(),x(!0),k(null),S(null);try{l?g.prompt=m:h(g.prompt||"");const{image_data:e,...a}=g;let r={...a};r.prompt=function({starter:e,user:t,useStarter:l}){const n=null==e?"":String(e),a=null==t?"":String(t);return l&&""!==n?"Follow this instructions prompt: ```"+n+"``` to complete this request prompt: ```"+a+"```":a}({starter:s,user:r.prompt,useStarter:D}),A[0]&&(r.image=await vt(A[0])),A[1]&&(r.image2=await vt(A[1]));const i=await function(e,t=!1){return W({endpoint:"/ai/generate",method:"POST",body:e,prod:t,basePath:dt})}(r,t);let o=null;if(i?.data?.images&&Array.isArray(i.data.images)&&i.data.images.length>0?o=i.data.images[0]:i?.result?.images&&Array.isArray(i.result.images)&&i.result.images.length>0?o=i.result.images[0]:Array.isArray(i)&&i.length>0?o=i[0]:"string"==typeof i&&(o=i),!o)throw new Error("No se pudo extraer la imagen de la respuesta");if(o.startsWith("http"))try{const e=`${window.limboCore?.config?.getGlobal()?.prod?"https://limbo.lefebvre.es":"https://led-dev-limbo-dev.eu.els.local"}/api/atenea/proxy?url=${encodeURIComponent(o)}`,t=await fetch(e,{credentials:"include",headers:{Authorization:`Bearer ${window.limboCore?.apiClient?.token||""}`}});if(!t.ok)throw new Error(`Failed to download image: ${t.status}`);const l=await t.blob(),n=new File([l],"ai-image.webp",{type:l.type||"image/webp"});N(n)}catch(n){throw new Error(`Error downloading image via proxy: ${n.message}`)}else{const e=o.replace(/^data:image\/\w+;base64,/,""),t=atob(e),l=new Array(t.length);for(let r=0;r<t.length;r++)l[r]=t.charCodeAt(r);const n=new Uint8Array(l),a=new File([n],"ai-image.webp",{type:"image/webp"});N(a)}S(i?.data?.images||i?.result?.images||null)}catch(a){k(a.message||"Error al generar la imagen")}finally{x(!1)}};return d.loading?l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:py-8",children:[l.jsx("span",{className:"limbo-loader lb:mr-2"})," Cargando servicios IA..."]}):d.services.length?l.jsx("div",{className:"lb:flex lb:flex-col lb:mx-4 lb:pb-2",children:E?l.jsxs(l.Fragment,{children:[l.jsx("h3",{id:"aiSelectDescription",className:"lb:text-2xl lb:font-semibold lb:text-brand-blue-1000 lb:mb-3",children:"Selecciona el modelo IA"}),d.error&&l.jsx(fe,{variant:"danger",children:d.error}),l.jsx("div",{className:"lb:flex lb:flex-row lb:flex-wrap lb:justify-around lb:items-stretch lb:justify-items-stretch lb:content-stretch lb:gap-3 lb:w-full lb:max-w-7xl",children:d.services.map(e=>l.jsxs("button",{type:"button",onClick:()=>{f(e.slug),_(!1),v({}),S(null),k(null),N(null),b.fetchParams(e.slug,!0)},disabled:d.loading||n,className:`lb:group lb:relative lb:p-4 lb:rounded-lg lb:border-2 lb:transition-all lb:duration-200 lb:overflow-hidden lb:flex lb:flex-col lb:items-center lb:justify-center lb:min-h-30 lb:grow basis-sm lb:min-w-70 lb:border-gray-200 lb:hover:border-brand-blue-800 lb:hover:shadow-md lb:hover:text-black lb:lg:w-min ${d.loading||n?"lb:opacity-50 lb:cursor-not-allowed":"lb:cursor-pointer"} `,style:{position:"relative"},children:[e.image&&l.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-cover lb:bg-center lb:transition-opacity lb:duration-200 lb:group-hover:opacity-35",style:{backgroundImage:`url(${e.image})`,opacity:.2}}),l.jsxs("div",{className:"lb:relative lb:z-10 lb:flex lb:flex-col lb:items-center lb:justify-center lb:gap-2 lb:text-center",children:[l.jsx("span",{className:"lb:text-base lb:font-semibold lb:text-neutral-black-000",children:e.label}),e.description&&l.jsx("span",{className:"lb:text-sm lb:text-gray-950 lb:line-clamp-2 lb:drop-shadow lb:drop-shadow-neutral-white-000",children:e.description})]}),e.costInfo&&l.jsx("span",{className:"lb:absolute lb:top-0 lb:left-1 lb:inline-flex lb:items-center lb:gap-1 lb:py-0 lb:px-1 lb:mt-1 lb:text-xs lb:font-medium lb:text-warning-1000 lb:rounded-md lb:group-hover:bg-white/90",style:{zoom:"82%"},children:e.costInfo})]},e.slug))})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"lb:flex lb:flex-wrap lb:items-center lb:gap-3 lb:mb-2",children:[l.jsx("h3",{className:"lb:text-2xl lb:font-semibold lb:text-brand-blue-1000",children:d.services.find(e=>e.slug===p)?.label||"Generación IA"}),d.services.find(e=>e.slug===p)?.costInfo&&l.jsxs("div",{title:"Coste estimado por imagen que le cuesta a la empresa, este coste depende de la calidad de la imagen generada y puede variar según el proveedor IA, ten en cuenta este coste para hacer un uso más responsable del servicio IA",className:"lb:flex lb:items-center lb:gap-1","aria-description":"Coste estimado por imagen que le cuesta a la empresa, este coste depende de la calidad de la imagen generada y puede variar según el proveedor IA, ten en cuenta este coste para hacer un uso más responsable del servicio IA",children:[l.jsxs("span",{className:"lb:inline-flex lb:items-center lb:gap-1 lb:px-2 lb:py-0.5 lb:text-xs lb:font-medium lb:text-warning-1000 lb:bg-yellow-200/60 lb:rounded-full lb:border lb:border-warning-1000 lb:select-none",children:[l.jsx("span",{className:"icon icon-euro-blue icon--2sm icon--warning",style:{filter:"var(--limbo-icon-warning-dark)"}}),"Coste:"," ",d.services.find(e=>e.slug===p)?.costInfo]}),l.jsx("span",{className:"icon icon-info lb:cursor-help"})]})]}),b.loading&&l.jsx("div",{children:"Cargando parámetros..."}),b.error&&l.jsx(fe,{variant:"danger",children:b.error}),p&&(()=>{const e=b.params?.[p]?.parameters;if(!e)return null;const t=Object.entries(e).filter(([e,t])=>!t.hidden&&"image"!==t.type&&"file"!==t.type),a=t.filter(([e])=>e.toLowerCase().includes("prompt")||e.toLowerCase().includes("query")),r=t.filter(([e])=>!e.toLowerCase().includes("prompt")&&!e.toLowerCase().includes("query")),i=(e,t)=>{let a=t.placeholder||"";a||(a="integer"===t.type?t.minValue&&t.maxValue?`Entre ${t.minValue} y ${t.maxValue}`:t.minValue?`Mínimo ${t.minValue}`:t.maxValue?`Máximo ${t.maxValue}`:"Introduce un número":e.toLowerCase().includes("prompt")?"Describe la imagen que deseas generar...":e.toLowerCase().includes("negative")?"Elementos a evitar en la imagen...":`Introduce ${(t.label||e).toLowerCase()}`);const r=e.toLowerCase().includes("prompt")||e.toLowerCase().includes("query");return l.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-1",children:[l.jsxs("label",{htmlFor:`ai-${e}`,className:"lb:text-xs lb:font-medium lb:text-brand-blue-1000",children:[t.label||e,t.required&&l.jsx("span",{className:"lb:text-red-1000 lb:ml-1",children:"*"})]}),t.options?l.jsx("select",{id:`ai-${e}`,name:e,value:g[e]??"",onChange:X,className:"limbo-input",disabled:n,title:t.label||e,children:t.options.map(e=>l.jsx("option",{value:e,children:e},e))}):r?l.jsx("textarea",{id:`ai-${e}`,name:e,value:g[e]??"",onChange:X,className:"limbo-input lb:resize-none lb:overflow-y-auto",disabled:n,required:t.required,placeholder:a,title:t.label||e,rows:3,style:{maxHeight:"9rem",minHeight:"3rem"},onInput:e=>{e.target.style.height="auto";const t=Math.min(e.target.scrollHeight,144);e.target.style.height=`${t}px`}}):l.jsx("input",{id:`ai-${e}`,type:"integer"===t.type?"number":"text",name:e,value:g[e]??"",onChange:X,className:"limbo-input",disabled:n,required:t.required,min:t.minValue,max:t.maxValue,placeholder:a,title:t.label||e})]},e)};return l.jsxs("div",{className:"lb:h-fit lb:w-full",children:[d.services.length>1&&l.jsxs("button",{type:"button",onClick:()=>{_(!0),f(""),v({}),S(null),k(null),N(null),Q()},className:"lb:flex lb:cursor-pointer lb:items-center lb:gap-2 lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:mb-4 lb:font-medium",children:[l.jsx("span",{className:"icon icon-arrow-left"}),"Volver al menú de servicios"]}),l.jsxs("div",{className:"lb:relative lb:max-w-[89dvw]",children:[l.jsxs("form",{onSubmit:Y,"data-type":"ai",className:"lb:flex lb:flex-col lb:gap-3 lb:mt-4 lb:border-t lb:pt-4 lb:border-brand-blue-200","aria-label":"Formulario generación IA",children:[w&&l.jsx(fe,{variant:"danger",className:"lb:mb-2",children:w}),l.jsx(gt,{aiStarterPrompt:s,useStarter:D,onUseStarterChange:R}),l.jsx("div",{className:"lb:flex lb:flex-col lb:gap-3",children:a.map(([e,t])=>i(e,t))}),U&&l.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-2 lb:mt-1",children:[l.jsxs("label",{className:"lb:text-xs lb:font-medium lb:text-brand-blue-1000",children:["Imágenes de referencia",l.jsx("span",{className:"lb:text-neutral-gray-500 lb:ml-1 lb:font-normal",children:"(opcional, máx. 2)"})]}),l.jsx("div",{className:"lb:flex lb:flex-col lb:gap-2",children:[0,1].map(e=>A[e]?l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-3 lb:p-2 lb:bg-neutral-gray-50 lb:border lb:border-neutral-gray-200 lb:rounded-lg",children:[l.jsx("div",{className:"lb:w-16 lb:h-16 lb:rounded lb:overflow-hidden lb:shrink-0 lb:bg-neutral-gray-100",children:l.jsx("img",{src:L[e],alt:`Referencia ${e+1}`,className:"lb:w-full lb:h-full lb:object-cover"})}),l.jsxs("div",{className:"lb:flex-1 lb:min-w-0",children:[l.jsxs("p",{className:"lb:text-xs lb:text-neutral-gray-500 lb:mb-0.5",children:["Imagen ",e+1]}),l.jsx("p",{className:"lb:text-sm lb:text-neutral-gray-700 lb:truncate",children:A[e].name}),l.jsxs("p",{className:"lb:text-xs lb:text-neutral-gray-500",children:[(A[e].size/1024).toFixed(0)," KB"]})]}),l.jsx("button",{type:"button",onClick:()=>Q(e),disabled:n||y,className:"lb:p-1.5 lb:text-neutral-gray-500 lb:cursor-pointer lb:hover:text-red-1000 lb:hover:bg-red-50 lb:rounded lb:transition-colors",title:`Quitar imagen ${e+1}`,children:l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[l.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),l.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},e):(0===e||A[0])&&l.jsxs("label",{className:"lb:flex lb:items-center lb:justify-center lb:gap-2 lb:px-3 lb:py-2.5 lb:border lb:border-dashed lb:rounded-lg lb:cursor-pointer lb:transition-colors lb:text-sm "+(I===e?"lb:border-brand-blue-800 lb:bg-brand-blue-50/50 lb:text-brand-blue-800":"lb:border-neutral-gray-300 lb:text-neutral-gray-700 lb:hover:border-brand-blue-800 lb:hover:bg-brand-blue-50/30"),onDragEnter:V(e),onDragLeave:H(e),onDragOver:K,onDrop:G(e),children:[l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[l.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),l.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),l.jsx("polyline",{points:"21 15 16 10 5 21"})]}),I===e?"Suelta la imagen aquí":0===e?"Subir imagen de referencia":"Añadir segunda imagen",l.jsx("input",{ref:O[e],type:"file",accept:"image/jpeg,image/png,image/webp,image/svg+xml",onChange:q(e),disabled:n||y,className:"lb:sr-only"})]},e))})]}),r.length>0&&l.jsxs("div",{className:"lb:border-t lb:border-gray-200 lb:pt-3",children:[l.jsxs("button",{type:"button",onClick:()=>T(!$),className:"lb:flex lb:items-center lb:gap-2 lb:text-sm lb:font-medium lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:mb-3 lb:transition-colors",children:[l.jsx("svg",{className:"lb:w-4 lb:h-4 lb:transition-transform "+($?"lb:rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"Opciones avanzadas",!$&&l.jsxs("span",{className:"lb:text-xs lb:text-gray-500",children:["(",r.length," opciones)"]})]}),$&&l.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:lg:grid-cols-3 lb:xl:grid-cols-4 lb:gap-3 lb:animate-fadeIn",children:r.map(([e,t])=>i(e,t))})]}),(()=>{const e=Object.entries(g).some(([e,t])=>(e.toLowerCase().includes("prompt")||e.toLowerCase().includes("query"))&&"string"==typeof t&&t.trim().length>=5),t=y||n||!e;return l.jsx("button",{type:"submit",disabled:t,title:y?"Generando imagen...":e?j?"Generar otra imagen":"Generar imagen":"Escribe al menos 5 caracteres en el prompt",className:"limbo-btn lb:w-full lb:mt-2 "+(t?"lb:cursor-not-allowed limbo-btn-disabled":"limbo-btn-primary"),style:{minHeight:44},children:y?"Generando imagen...":j?"Generar otra imagen":"Generar imagen"})})()]}),l.jsx(ft,{show:y,message:"Generando imagen con IA..."})]})]})})(),j&&l.jsx("div",{className:"lb:mt-6 lb:md:w-full lb:mx-auto",children:l.jsx(it,{image:j,onDiscard:()=>{N(null),S(null),k(null)},onRetry:e=>Y(e,!0),onDownload:()=>{},onSelect:e=>{if(a){const t=j||C;if(e&&t&&e!==t.name){const l=new File([t],e,{type:t.type});a(l)}else a(t)}},showRetry:!0,disabled:y||n,selectedFolder:r,onFolderChange:i,folderConfig:o,tags:c,onTagsChange:u})})]})}):l.jsx(fe,{variant:"warning",children:"No hay servicios IA disponibles."})}const xt="/api";const wt=new Map;function kt(t=!1){const[l,n]=e.useState([]),[a,r]=e.useState(!0),[i,o]=e.useState(null);e.useEffect(()=>{const e=`stock-services-${t}`,l=wt.get(e),a=Date.now();if(l&&a-l.timestamp<864e5)return n(l.data),void r(!1);let i=!0;return(async()=>{try{const l=await function(e=!1){return W({endpoint:"/stock/services",prod:e,basePath:xt})}(t);if(!i)return;if(204===l?.httpCode||null===l?.data)return n([]),o("No hay servicios de stock disponibles en este momento"),void wt.set(e,{data:[],timestamp:a});const r=l?.data||l?.result||[],s=Array.isArray(r)?r.map(e=>({label:e.name||e.label,slug:e.slug,type:e.type,description:e.description,image:e.image})):Object.entries(r).map(([e,t])=>({label:e,slug:t,type:"stock_image",description:null,image:null}));n(s),wt.set(e,{data:s,timestamp:a})}catch(l){i&&o(l.message)}finally{i&&r(!1)}})(),()=>{i=!1}},[t]);return{services:l,loading:a,error:i,invalidateCache:()=>{wt.delete(`stock-services-${t}`)}}}function Ct({isOpen:t,image:n,onSelect:a,onCancel:r}){const[i,o]=e.useState(null),[s,c]=e.useState(!1),[u,d]=e.useState(!1),[b,m]=e.useState(!1);e.useEffect(()=>{t&&n&&(o(n.previewUrl),c(!1),d(!1),m(!1))},[t,n]);const h=l.jsxs("div",{className:"lb:flex lb:gap-2 lb:ml-4 lb:shrink-0",children:[l.jsx("button",{type:"button",onClick:r,className:"lb:px-4 lb:py-2 lb:text-sm lb:font-medium lb:text-white lb:border lb:border-white/30 lb:rounded-md lb:hover:bg-white/10 lb:transition-colors lb:cursor-pointer",children:"Cancelar"}),l.jsx("button",{type:"button",onClick:a,className:"lb:px-4 lb:py-2 lb:text-sm lb:font-medium lb:bg-brand-blue-800 lb:text-white lb:rounded-md lb:hover:bg-brand-blue-1000 lb:transition-colors lb:cursor-pointer",children:"Seleccionar"})]});return l.jsx(Ne,{isOpen:t,onClose:r,title:n?.title||"Previsualizar imagen",ariaLabel:"Previsualización de imagen externa",headerActions:h,children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center lb:w-full lb:h-full lb:p-4",children:b?l.jsxs("div",{className:"lb:text-white/70 lb:text-sm lb:text-center",children:[l.jsx("p",{children:"No se pudo cargar la imagen."}),l.jsx("p",{className:"lb:text-xs lb:mt-1 lb:text-white/50",children:"Puedes seleccionarla igualmente para continuar."})]}):l.jsxs(l.Fragment,{children:[!u&&l.jsx("div",{className:"lb:absolute lb:inset-0 lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"limbo-loader"})}),l.jsx("img",{src:i,alt:n?.title||"Imagen",onLoad:()=>d(!0),onError:()=>{!s&&n?.proxyUrl&&n.proxyUrl!==i?(c(!0),o(n.proxyUrl)):m(!0)},className:"lb:max-w-full lb:object-contain lb:rounded lb:transition-opacity lb:duration-300 "+(u?"lb:opacity-100":"lb:opacity-0"),style:{maxHeight:"calc(100vh - 130px)"}},i)]})})})}function St({src:t,fallbackSrc:n,alt:a}){const[r,i]=e.useState(t),[o,s]=e.useState(!1),[c,u]=e.useState(!1);e.useEffect(()=>{i(t),s(!1),u(!1)},[t]);return l.jsxs("div",{className:"lb:relative lb:w-full lb:h-full",children:[!c&&l.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-linear-to-r lb:from-gray-200 lb:via-gray-100 lb:to-gray-200 lb:animate-pulse"}),l.jsx("img",{src:r,alt:a,onLoad:()=>u(!0),onError:()=>{!o&&n&&n!==r&&(s(!0),i(n))},className:"lb:object-cover lb:w-full lb:h-full lb:transition-opacity lb:duration-300 "+(c?"lb:opacity-100":"lb:opacity-0"),loading:"lazy"})]})}function jt({prod:t,disabled:n,onSelect:a,selectedFolder:r,onFolderChange:i,folderConfig:o,tags:s=[],onTagsChange:c=null}){const u=e.useRef(null),d=kt(t),b=(e,t)=>{try{const l=sessionStorage.getItem(`limbo_stock_${e}`);return l?JSON.parse(l):t}catch{return t}},[m,h]=e.useState(()=>b("selectedService","")),[p,f]=e.useState(()=>b("dynamicForm",{})),[g,v]=e.useState(()=>b("stockImages",[])),[y,x]=e.useState(()=>b("currentPage",1)),[w,k]=e.useState(()=>b("paginationInfo",null)),[C,S]=e.useState(null),j=pt(t),[N,E]=e.useState(!1),[_,$]=e.useState(null),[T,A]=e.useState(null),[z,L]=e.useState(!0),[M,I]=e.useState(!1),[P,D]=e.useState(null),[R,O]=e.useState(null);e.useEffect(()=>{sessionStorage.setItem("limbo_stock_selectedService",JSON.stringify(m))},[m]),e.useEffect(()=>{sessionStorage.setItem("limbo_stock_dynamicForm",JSON.stringify(p))},[p]),e.useEffect(()=>{sessionStorage.setItem("limbo_stock_stockImages",JSON.stringify(g))},[g]),e.useEffect(()=>{sessionStorage.setItem("limbo_stock_currentPage",JSON.stringify(y))},[y]),e.useEffect(()=>{sessionStorage.setItem("limbo_stock_paginationInfo",JSON.stringify(w))},[w]),e.useEffect(()=>{if(!d.loading&&1===d.services.length){const e=d.services[0];h(e.slug),L(!1),j.fetchParams(e.slug,!0)}},[d.loading,d.services]),e.useEffect(()=>{if(!m)return;const e=j.params?.[m]?.parameters;if(e){const t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default??""]));t.service=m,f(t)}},[m,j.params]);const U=e=>{const{name:t,value:l}=e.target;f(e=>({...e,[t]:l}))},B=async(e=1)=>{E(!0),$(null),1===e&&v([]);try{let l;if(1===e){const t=j.params?.[m]?.parameters,n={...p};Object.entries(t||{}).forEach(([e,t])=>{e in n||(n[e]=t.default??"")}),n.per_page=parseInt(n.per_page),n.service=m,n.page=e,l=n,u.current={...n}}else l={...u.current,page:e};const n=await function(e,t=!1){return W({endpoint:"/stock/search",method:"POST",body:e,prod:t,basePath:xt})}(l,t),a=n?.data?.images||[];let r=n?.data?.pagination||null,i=null;r&&(i={total:r.total_count??r.total??a.length,per_page:r.per_page??(Array.isArray(a)?a.length:0),current_page:r.page??r.current_page??e}),v(V(Array.isArray(a)?a:[])),k(i),x(i?.current_page||e)}catch(l){$(l.message||"Error al buscar imágenes")}finally{E(!1)}},V=e=>{const t=new Set,l=[];return(e||[]).forEach((e,n)=>{const a=e.url||e.preview_url||e.full||e.preview;a&&!t.has(a)&&(t.add(a),l.push({...e,preview:e.preview_url||e.preview||e.url||e.full,full:e.url||e.full||e.preview_url,id:e.id||n,title:e.title||e.filename||`Imagen ${n+1}`,source:e.service||m,sourceTitle:d.services.find(e=>e.slug===m)?.label||m}))}),l},H=async e=>{e.preventDefault();const t=p.query||p.search||p.term||"";t.trim().length<5?$("La búsqueda debe tener al menos 5 caracteres"):(S(t),await B(1))},K=e=>{e<1||B(e)},G=async e=>{A(e.id),$(null);try{const l={service:m,image_id:e.id},n=await function(e,t=!1){return W({endpoint:"/stock/download",method:"POST",body:e,prod:t,basePath:xt})}(l,t),a=n?.result?.url||n?.result?.download_url||n?.data?.images?.url||n?.data?.url||n?.images?.url||n?.url;if(!a)throw console.error("Download response structure:",n),new Error("No se pudo obtener la URL de descarga");{const l=`${F({prod:t})}/api/atenea/proxy?url=${encodeURIComponent(a)}`,r=await fetch(l,{credentials:"include",headers:{Authorization:`Bearer ${q().token||""}`}});if(!r.ok)throw new Error(`Error al descargar imagen: ${r.status}`);const i=await r.blob(),o=n?.result?.filename||n?.data?.images?.filename||n?.data?.filename||`stock-${e.id}.jpg`,s=new File([i],o,{type:i.type||"image/jpeg"});D(s)}}catch(l){$(l.message||"No se pudo recuperar la imagen seleccionada")}finally{A(null)}};return d.loading?l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:py-8",children:[l.jsx("span",{className:"limbo-loader lb:mr-2"})," Cargando servicios de Stock..."]}):d.services.length?l.jsx("div",{className:"lb:flex lb:flex-col lb:mx-4 lb:pb-2",children:z?l.jsxs(l.Fragment,{children:[l.jsx("h3",{className:"lb:text-2xl lb:font-semibold lb:text-brand-blue-1000 lb:mb-3",children:"Selecciona el servicio de Stock"}),d.error&&l.jsx(fe,{variant:"danger",children:d.error}),l.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:gap-3",children:d.services.map(e=>l.jsxs("button",{type:"button",onClick:()=>{h(e.slug),L(!1),f({}),v([]),x(1),k(null),$(null),j.fetchParams(e.slug,!0)},disabled:d.loading||n,className:`lb:group lb:relative lb:p-4 lb:rounded-lg lb:border-2 lb:transition-all lb:duration-200 lb:overflow-hidden lb:flex lb:flex-col lb:items-center lb:justify-center lb:min-h-30 lb:border-gray-200 lb:hover:border-brand-blue-300 lb:hover:shadow-md lb:lg:w-min ${d.loading||n?"lb:opacity-50 lb:cursor-not-allowed":"lb:cursor-pointer"} `,style:{position:"relative"},children:[e.image&&l.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-cover lb:bg-center lb:transition-opacity lb:duration-200 lb:group-hover:opacity-35",style:{backgroundImage:`url(${e.image})`,opacity:.2}}),l.jsxs("div",{className:"lb:relative lb:z-10 lb:flex lb:flex-col lb:items-center lb:justify-center lb:gap-2 lb:text-center",children:[l.jsx("span",{className:"lb:text-base lb:font-semibold lb:text-neutral-black-000",children:e.label}),e.description&&l.jsx("span",{className:"lb:text-sm lb:text-gray-950 lb:line-clamp-2 lb:drop-shadow lb:drop-shadow-neutral-white-000",children:e.description})]})]},e.slug))})]}):l.jsxs(l.Fragment,{children:[l.jsx("h3",{className:"lb:text-2xl lb:font-semibold lb:text-brand-blue-1000",children:d.services.find(e=>e.slug===m)?.label||"Búsqueda Stock"}),j.loading&&l.jsx("div",{children:"Cargando parámetros..."}),j.error&&l.jsx(fe,{variant:"danger",children:j.error}),m&&(()=>{const e=j.params?.[m]?.parameters;if(!e)return null;const t=Object.entries(e).filter(([,e])=>!e.hidden),a=t.filter(([e])=>e.toLowerCase().includes("query")||e.toLowerCase().includes("search")||e.toLowerCase().includes("term")),r=t.filter(([e])=>!e.toLowerCase().includes("query")&&!e.toLowerCase().includes("search")&&!e.toLowerCase().includes("term")),i=(e,t)=>{let a=t.placeholder||"";a||(a="integer"===t.type?t.minValue&&t.maxValue?`Entre ${t.minValue} y ${t.maxValue}`:t.minValue?`Mínimo ${t.minValue}`:t.maxValue?`Máximo ${t.maxValue}`:"Introduce un número":e.toLowerCase().includes("query")||e.toLowerCase().includes("search")||e.toLowerCase().includes("term")?"Buscar imágenes...":`Introduce ${(t.label||e).toLowerCase()}`);const r=e.toLowerCase().includes("query")||e.toLowerCase().includes("search")||e.toLowerCase().includes("term");return l.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-1",children:[l.jsxs("label",{htmlFor:`stock-${e}`,className:"lb:text-xs lb:font-medium lb:text-brand-blue-1000",children:[t.label||e,t.required&&l.jsx("span",{className:"lb:text-red-1000 lb:ml-1",children:"*"})]}),t.options&&t.multiple?l.jsx("div",{className:"lb:flex lb:flex-wrap lb:gap-2 lb:min-h-[50px] lb:px-2 lb:justify-between lb:border-2 lb:border-gray-transparent-500 lb:rounded-lg",children:t.options.map(t=>l.jsxs("label",{className:"lb:flex lb:items-center lb:gap-1",children:[l.jsx("input",{type:"checkbox",name:`stock-${e}`,value:t,checked:Array.isArray(p[e])&&p[e].includes(t),onChange:()=>((e,t)=>{f(l=>{const n=Array.isArray(l[e])?l[e]:[];return n.includes(t)?{...l,[e]:n.filter(e=>e!==t)}:{...l,[e]:[...n,t]}})})(e,t),disabled:n}),l.jsx("span",{className:"lb:text-xs",children:t})]},t))}):t.options?l.jsx("select",{id:`stock-${e}`,name:e,value:p[e]??"",onChange:U,className:"limbo-input",disabled:n,title:t.label||e,children:t.options.map(e=>l.jsx("option",{value:e,children:e},e))}):r?l.jsx("textarea",{id:`stock-${e}`,name:e,value:p[e]??"",onChange:U,className:"limbo-input lb:resize-none lb:overflow-y-auto",disabled:n,required:t.required,placeholder:a,title:t.label||e,rows:3,style:{maxHeight:"9rem",minHeight:"3rem"},onInput:e=>{e.target.style.height="auto";const t=Math.min(e.target.scrollHeight,144);e.target.style.height=`${t}px`}}):l.jsx("input",{id:`stock-${e}`,type:"integer"===t.type?"number":"text",name:e,value:p[e]??"",onChange:U,className:"limbo-input",disabled:n,required:t.required,min:t.minValue,max:t.maxValue,placeholder:a,title:t.label||e})]},e)};return l.jsxs("div",{children:[d.services.length>1&&l.jsxs("button",{type:"button",onClick:()=>{L(!0),h(""),f({}),v([]),x(1),k(null),$(null)},className:"lb:flex lb:cursor-pointer lb:items-center lb:gap-2 lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:mb-4 lb:font-medium",children:[l.jsx("span",{className:"icon icon-arrow-left"}),"Volver al menú de servicios"]}),l.jsxs("div",{className:"lb:relative lb:max-w-[89dvw]",children:[l.jsxs("form",{onSubmit:H,"data-type":"stock",className:"lb:flex lb:flex-col lb:gap-3 lb:mt-4 lb:border-t-1 lb:pt-4 lb:border-brand-blue-200","aria-label":"Formulario búsqueda de imágenes de Stock",children:[_&&l.jsx(fe,{variant:"danger",className:"lb:mt-4",children:_}),l.jsx("div",{className:"lb:flex lb:flex-col lb:gap-3",children:a.map(([e,t])=>i(e,t))}),r.length>0&&l.jsxs("div",{className:"lb:border-t lb:border-gray-200 lb:pt-3",children:[l.jsxs("button",{type:"button",onClick:()=>I(!M),className:"lb:flex lb:items-center lb:gap-2 lb:text-sm lb:font-medium lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:mb-3 lb:transition-colors",children:[l.jsx("svg",{className:"lb:w-4 lb:h-4 lb:transition-transform "+(M?"lb:rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"Opciones avanzadas",!M&&l.jsxs("span",{className:"lb:text-xs lb:text-gray-500",children:["(",r.length," opciones)"]})]}),M&&l.jsx("div",{className:"lb:grid lb:grid-cols-1 lb:md:grid-cols-2 lb:gap-3 lb:animate-fadeIn",children:r.map(([e,t])=>i(e,t))})]}),l.jsx("button",{type:"submit",disabled:N||n,className:"limbo-btn lb:w-full lb:mt-2 "+(N?"lb:cursor-not-allowed limbo-btn-disabled":"limbo-btn-primary"),style:{minHeight:44},children:N?"Buscando...":"Buscar imágenes"})]}),l.jsx(ft,{show:N&&!g.length,message:"Buscando imágenes..."})]})]})})(),P&&l.jsx("div",{className:"lb:mt-6 lb:md:w-full lb:mx-auto",children:l.jsx(it,{image:P,onDiscard:()=>{D(null),$(null)},onDownload:()=>{},onSelect:e=>{if(a)if(e&&P&&e!==P.name){const t=new File([P],e,{type:P.type});a(t)}else a(P)},showRetry:!1,disabled:n,selectedFolder:r,onFolderChange:i,folderConfig:o,tags:s,onTagsChange:c})}),!P&&g.length>0&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"lb:mt-6 lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:lg:grid-cols-4 lb:gap-1 lb:relative","aria-live":"polite",children:[l.jsx(ft,{show:N,message:"Cargando imágenes..."}),g.map((e,a)=>{const r=F({prod:t}),i=e.preview||e.thumbnail||e.url,o=i?`${r}/api/atenea/proxy?url=${encodeURIComponent(i)}`:null;return l.jsx("div",{className:"lb:border lb:border-brand-blue-200 lb:rounded-sm lb:overflow-hidden lb:bg-white lb:shadow-sm lb:hover:shadow-md lb:transition-all lb:duration-200 lb:cursor-pointer",title:"Ver imagen",onClick:()=>{T||N||n||O(e)},children:l.jsxs("div",{className:"lb:relative lb:aspect-video lb:bg-neutral-100",children:[l.jsx(St,{src:i,fallbackSrc:o,alt:e.title||`Resultado ${a+1}`}),T===e.id&&l.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-white/90 lb:flex lb:flex-col lb:items-center lb:justify-center lb:gap-2",children:[l.jsxs("div",{className:"lb:relative lb:w-10 lb:h-10",children:[l.jsx("div",{className:"lb:absolute lb:inset-0 lb:border-4 lb:border-brand-blue-200 lb:rounded-full"}),l.jsx("div",{className:"lb:absolute lb:inset-0 lb:border-4 lb:border-brand-blue-800 lb:rounded-full lb:border-t-transparent lb:animate-spin"})]}),l.jsx("span",{className:"lb:text-sm lb:font-medium lb:text-brand-blue-1000",children:"Descargando..."})]})]})},e.id||a)})]}),w&&l.jsxs("div",{className:"lb:mt-6 lb:flex lb:items-center lb:justify-center lb:gap-2",children:[l.jsxs("button",{onClick:()=>K(w.current_page-1),disabled:w.current_page<=1||N,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(w.current_page<=1||N?" pointer-events-none cursor-default":" limbo-btn-primary"),children:[l.jsx("span",{className:"icon icon-arrow-left-white icon--sm"})," ","Anterior"]}),l.jsxs("span",{className:"lb:px-4 lb:py-2 lb:text-sm lb:text-neutral-700",children:["Página ",w.current_page," de"," ",Math.max(1,Math.ceil(w.total/w.per_page)),l.jsxs("span",{className:"lb:text-xs lb:text-neutral-500 lb:block",children:["(",w.total," imágenes totales)"]})]}),l.jsxs("button",{onClick:()=>K(w.current_page+1),disabled:N||w.current_page>=Math.ceil(w.total/w.per_page),className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(N||w.current_page>=Math.ceil(w.total/w.per_page)?" pointer-events-none cursor-default":" limbo-btn-primary"),children:["Siguiente"," ",l.jsx("span",{className:"icon icon-arrow-right-white icon--sm"})]})]})]}),!N&&0===g.length&&m&&C&&l.jsxs("div",{className:"lb:mt-6 lb:text-center lb:text-neutral-600 lb:py-8 lb:bg-neutral-50 lb:rounded-lg",children:[l.jsx("span",{className:"icon icon-search icon--lg lb:mb-2"}),l.jsxs("p",{children:['No se encontraron imágenes para "',p.query,'"']}),l.jsx("p",{className:"lb:text-sm lb:mt-1",children:"Intenta con otros términos de búsqueda"})]}),R&&(()=>{const e=F({prod:t}),n=R.preview||R.thumbnail||R.url,a=n?`${e}/api/atenea/proxy?url=${encodeURIComponent(n)}`:null;return l.jsx(Ct,{isOpen:!!R,image:{previewUrl:n,proxyUrl:a,title:R.title||R.filename||"Imagen"},onCancel:()=>O(null),onSelect:()=>{const e=R;O(null),G(e)}})})()]})}):l.jsx(fe,{variant:"warning",children:"No hay servicios de Stock disponibles."})}const Nt="/api";function Et(e,t=!1){const l=new URLSearchParams;return e.portal&&l.set("portal",e.portal),e.media_type&&l.set("media_type",e.media_type),e.page&&l.set("page",String(e.page)),l.set("per_page",String(e.per_page)),e.search&&l.set("search",e.search),e.order&&l.set("order",e.order),W({endpoint:`/external/media?${l.toString()}`,method:"GET",prod:t,basePath:Nt})}const _t=new Map;function $t(t=!1){const[l,n]=e.useState([]),[a,r]=e.useState(!0),[i,o]=e.useState(null);e.useEffect(()=>{const e=`portal-sources-${t}`,l=_t.get(e),a=Date.now();if(l&&a-l.timestamp<864e5)return n(l.data),void r(!1);let i=!0;return(async()=>{try{const l=await function(e=!1,t=!0){const l=new URLSearchParams;return l.set("active",t?"true":"false"),W({endpoint:`/external/portals?${l.toString()}`,method:"GET",prod:e,basePath:Nt})}(t,!0);if(!i)return;let r=l?.data||[];Array.isArray(r)||(r=[]);const o=r.map(e=>({id:e.slug||e.id,numericId:e.id,name:e.name,title:e.name,slug:e.slug,url:e.website_url,image:e.logo_url,isActive:e.is_active}));n(o),_t.set(e,{data:o,timestamp:a})}catch(l){i&&o(l.message)}finally{i&&r(!1)}})(),()=>{i=!1}},[t]);return{sources:l,loading:a,error:i,invalidateCache:()=>{_t.delete(`portal-sources-${t}`)}}}function Tt({isOpen:t=!1,video:n,onClose:a,onSelect:r=null}){const[i,o]=e.useState(!1),s=e.useMemo(()=>n?"youtube"===n.platform&&n.video_id?`https://www.youtube.com/embed/${n.video_id}?autoplay=1&rel=0`:"vimeo"===n.platform&&n.video_id?`https://player.vimeo.com/video/${n.video_id}?autoplay=1`:n.embed_url||null:null,[n]),c=e.useMemo(()=>n&&(n.player_url||n.embed_url||n.post_url)||"",[n]),u=e.useCallback(async()=>{if(c)try{await navigator.clipboard.writeText(c),o(!0),setTimeout(()=>o(!1),2e3)}catch{const e=document.createElement("textarea");e.value=c,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e),o(!0),setTimeout(()=>o(!1),2e3)}},[c]),d=e.useCallback(()=>{r&&n&&r(n)},[r,n]);if(!n)return null;const b=[n.portal_name,n.platform].filter(Boolean).join(" · "),m=r?l.jsxs("button",{type:"button",onClick:d,className:"lb:flex lb:items-center lb:gap-2 lb:px-4 lb:py-1.5 lb:rounded-lg lb:bg-brand-blue-800 lb:hover:bg-brand-blue-900 lb:text-white lb:text-sm lb:font-medium lb:transition-colors","aria-label":"Seleccionar video",children:[l.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),l.jsx("span",{children:"Seleccionar"})]}):l.jsx("button",{type:"button",onClick:u,disabled:!c,className:"lb:flex lb:items-center lb:gap-2 lb:px-4 lb:py-1.5 lb:rounded-lg lb:text-sm lb:font-medium lb:transition-colors "+(i?"lb:bg-green-600 lb:text-white":"lb:bg-white/10 lb:hover:bg-white/20 lb:text-white"),"aria-label":"Copiar URL del video",children:i?l.jsxs(l.Fragment,{children:[l.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),l.jsx("span",{children:"Copiado"})]}):l.jsxs(l.Fragment,{children:[l.jsx("svg",{className:"lb:w-4 lb:h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"})}),l.jsx("span",{children:"Copiar URL"})]})}),h=l.jsxs("span",{children:[l.jsx("kbd",{className:"lb:px-1.5 lb:py-0.5 lb:bg-white/10 lb:rounded lb:text-white",children:"ESC"})," ","cerrar"]});return l.jsx(Ne,{isOpen:t,onClose:a,title:n.title||"Video",subtitle:b,ariaLabel:"Vista previa de video externo",headerActions:m,footerHints:h,children:l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-3 lb:w-full lb:max-w-5xl lb:px-4",children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:px-4 lb:py-2 lb:bg-amber-500/20 lb:border lb:border-amber-500/40 lb:rounded-lg lb:text-amber-200 lb:text-sm",children:[l.jsx("svg",{className:"lb:w-5 lb:h-5 lb:shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),l.jsxs("span",{children:["Este video no se puede guardar en Limbo — alojado en"," ",l.jsx("strong",{className:"lb:capitalize",children:n.platform||"plataforma externa"})]})]}),l.jsx("div",{className:"lb:relative lb:w-full lb:aspect-video lb:bg-black lb:rounded-lg lb:overflow-hidden",children:s?l.jsx("iframe",{src:s,className:"lb:absolute lb:inset-0 lb:w-full lb:h-full",allow:"autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0,title:n.title||"Video"}):l.jsxs("div",{className:"lb:absolute lb:inset-0 lb:flex lb:flex-col lb:items-center lb:justify-center lb:text-white lb:gap-3",children:[l.jsx("svg",{className:"lb:w-16 lb:h-16 lb:text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})}),l.jsx("p",{className:"lb:text-sm lb:text-gray-400",children:"No se puede previsualizar este video"}),c&&l.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"lb:text-sm lb:text-brand-blue-400 lb:hover:text-brand-blue-300 lb:underline",children:"Abrir en nueva pestaña"})]})}),c&&l.jsx("p",{className:"lb:text-xs lb:text-gray-500 lb:truncate lb:max-w-full lb:px-2",children:c})]})})}const At=({src:t,fallbackSrc:n,alt:a,className:r,onError:i})=>{const[o,s]=e.useState("loading"),[c,u]=e.useState(t),[d,b]=e.useState(!1);return"error"===o?null:l.jsxs("div",{className:"lb:relative lb:w-full lb:h-full",children:["loading"===o&&l.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-linear-to-r lb:from-gray-200 lb:via-gray-100 lb:to-gray-200 lb:animate-pulse lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-spinner lb:w-8 lb:h-8 lb:text-gray-400 lb:animate-spin"})}),l.jsx("img",{src:c,alt:a,className:`${r} ${"loading"===o?"lb:opacity-0":"lb:opacity-100"} lb:transition-opacity lb:duration-300`,loading:"lazy",onLoad:()=>{s("loaded")},onError:()=>{n&&!d?(b(!0),u(n),s("loading")):(s("error"),i&&i())}})]})};function zt({prod:t,disabled:n,onSelect:a,onVideoSelect:r,selectedFolder:i,onFolderChange:o,folderConfig:s,resolvedAccept:c=null,returnConfig:u=null,tags:d=[],onTagsChange:b=null}){const{sources:m,loading:h,error:p}=$t(t),f=e.useMemo(()=>{if(!c||c.isAllTypes)return[{value:"images",label:"Imágenes"},{value:"videos",label:"Vídeos"},{value:"all",label:"Todo"}];const e=[];return c.includesImages&&e.push({value:"images",label:"Imágenes"}),c.includesVideos&&e.push({value:"videos",label:"Vídeos"}),e.length>1&&e.push({value:"all",label:"Todo"}),e.length>0?e:[{value:"images",label:"Imágenes"}]},[c]),g=f[0]?.value||"images",[v,y]=e.useState(null),[x,w]=e.useState(g),[k,C]=e.useState(""),[S,j]=e.useState([]),[N,E]=e.useState(1),[_,$]=e.useState(null),[T,A]=e.useState(!1),[z,L]=e.useState(null),[M,I]=e.useState(null),[P,D]=e.useState(null),[R,O]=e.useState(new Set),[U,B]=e.useState(!1),[q,W]=e.useState(null),[V,H]=e.useState(null),K=!!u&&"url"===u.format,G=e.useRef({}),Q=e.useCallback((e,t,l,n)=>`${e}_${t}_${l}_${n}`,[]),X=e.useCallback(async(e,l,n,a)=>{const r=Q(e,l,n,a),i=G.current[r];if(i)return j(i.items),$(i.pagination),E(a),L(null),void B(!0);A(!0),L(null);try{const i={portal:e,media_type:l,page:a,per_page:20};n.trim()&&(i.search=n.trim());const o=new Promise((e,t)=>setTimeout(()=>t(new Error("__timeout__")),25e3)),s=await Promise.race([Et(i,t),o]),c=s?.data||{},u=c.items||[],d=c.pagination||{total_items:u.length,total_pages:1,current_page:a,per_page:20};G.current[r]={items:u,pagination:d},j(u),$(d),E(a),O(new Set),B(!0),0===u.length&&L("No se encontraron resultados para este portal.")}catch(o){const e="__timeout__"===o.message;L(e?"El portal tardó demasiado en responder. Puede estar temporalmente no disponible. Inténtalo de nuevo.":o.message||"Error al cargar media del portal"),j([]),$(null),B(!0)}finally{A(!1)}},[t,Q]),Y=e.useCallback(e=>{e!==v&&(y(e),C(""),w(g),j([]),$(null),L(null),I(null),W(null),O(new Set),B(!1),G.current={},X(e,g,"",1))},[v,g,X]),J=e.useCallback(()=>{y(null),j([]),$(null),L(null),C(""),I(null),W(null),O(new Set),B(!1),G.current={}},[]),Z=e.useCallback(()=>{v&&(G.current={},X(v,x,k,1))},[v,x,k,X]),ee=e.useCallback(e=>{"Enter"===e.key&&(e.preventDefault(),Z())},[Z]),te=e.useCallback(e=>{e<1||!v||X(v,x,k,e)},[v,x,k,X]),le=e.useCallback(e=>{W(null),r?r(e):a&&a(e)},[r,a]),ne=e.useCallback(async e=>{if("video"===e.type){const t={type:"video",source:"portal",title:e.title||"",thumbnail:e.thumbnail||e.url,embed_url:e.embed_url||null,player_url:e.player_url||null,post_url:e.post_url||null,platform:e.platform||null,video_id:e.video_id||null,portal_slug:e.portal_slug||v,portal_name:e.portal_name||m.find(e=>e.slug===v)?.name||null,date_published:e.date_published||null,author:e.author||null};return void W(t)}const l=e.url||e.thumbnail;if(l){D(l),L(null);try{let n=null;try{const e=await fetch(l,{mode:"cors"});e.ok&&(n=await e.blob())}catch{}if(!n){const e=`${F({prod:t})}/api/external/proxy?url=${encodeURIComponent(l)}`,a=await fetch(e);if(!a.ok)throw new Error(`Error al descargar: ${a.status}`);n=await a.blob()}const a=e.title?`${e.title.substring(0,80)}.${"image/png"===e.mime_type?"png":"jpg"}`:`portal-${Date.now()}.jpg`,r=new File([n],a,{type:n.type||e.mime_type||"image/jpeg"});I(r)}catch(n){L(n.message||"No se pudo recuperar la imagen del portal")}finally{D(null)}}else L("No se encontró URL de la imagen")},[t,v,m]);if(h)return l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-center lb:py-8",children:[l.jsx("span",{className:"limbo-loader lb:mr-2"})," Cargando portales disponibles..."]});if(!m.length)return l.jsx(fe,{variant:"warning",children:"No hay portales externos disponibles."});if(!v)return l.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-4",children:[l.jsx("h3",{className:"lb:text-lg lb:font-semibold lb:text-brand-blue-1000",children:"Selecciona un Portal"}),p&&l.jsx(fe,{variant:"danger",children:p}),l.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:gap-3",children:m.map(e=>l.jsx("button",{type:"button",onClick:()=>Y(e.slug),disabled:n,className:"lb:relative lb:p-4 lb:rounded-lg lb:border-2 lb:transition-all lb:duration-200 lb:flex lb:flex-col lb:items-center lb:justify-center lb:min-h-25 lb:gap-2 lb:max-h-27.5 lb:box-border lb:border-gray-200 lb:bg-white lb:hover:border-brand-blue-350 lb:hover:shadow-md "+(n?"lb:opacity-50 lb:cursor-not-allowed":"lb:cursor-pointer"),children:e.image?l.jsx("img",{className:"lb:object-auto lb:bg-no-repeat lb:bg-center lb:max-h-full lb:object-contain lb:h-full lb:px-16",src:e.image,alt:e.title}):l.jsx("span",{className:"lb:text-sm lb:font-medium lb:text-brand-blue-800",children:e.name})},e.slug))})]});const ae=m.find(e=>e.slug===v),re=F({prod:t});return l.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-3",children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-3",children:[l.jsxs("button",{type:"button",onClick:J,className:"lb:flex lb:items-center lb:gap-1 lb:text-sm lb:text-brand-blue-800 lb:hover:text-brand-blue-1000 lb:font-medium lb:transition-colors",children:[l.jsx("span",{className:"icon icon-arrow-left icon--sm"}),"Portales"]}),l.jsx("span",{className:"lb:text-gray-300",children:"|"}),l.jsx("h3",{className:"lb:text-lg lb:font-semibold lb:text-brand-blue-1000",children:ae?.name||v})]}),l.jsxs("div",{className:"lb:flex lb:flex-col lb:gap-3 lb:border-t lb:pt-3 lb:border-brand-blue-200",children:[f.length>1&&l.jsx("div",{className:"lb:flex lb:gap-2",children:f.map(({value:e,label:t})=>l.jsx("button",{type:"button",onClick:()=>w(e),disabled:n||T,className:"lb:px-3 lb:py-1.5 lb:text-sm lb:rounded-md lb:font-medium lb:transition-colors "+(x===e?"lb:bg-brand-blue-800 lb:text-white":"lb:bg-gray-100 lb:text-gray-700 lb:hover:bg-gray-200"),children:t},e))}),l.jsxs("div",{className:"lb:flex lb:gap-2",children:[l.jsx("input",{type:"text",value:k,onChange:e=>C(e.target.value),onKeyDown:ee,className:"limbo-input lb:flex-1",placeholder:"Buscar en el portal...",disabled:n||T}),l.jsxs("button",{type:"button",onClick:Z,disabled:n||T,className:"limbo-btn limbo-btn-primary lb:px-4 lb:py-2 lb:text-sm lb:font-medium lb:whitespace-nowrap lb:flex lb:items-center lb:gap-1.5",children:[T?l.jsx("span",{className:"limbo-loader limbo-loader--sm"}):l.jsx("span",{className:"icon icon-search-white icon--sm"}),"Buscar"]})]})]}),z&&!T&&l.jsx(fe,{variant:"warning",children:z}),M&&l.jsx("div",{className:"lb:mt-2 lb:md:w-full lb:mx-auto",children:l.jsx(it,{image:M,onDiscard:()=>{I(null),L(null)},onDownload:()=>{},onSelect:e=>{if(a)if(e&&M&&e!==M.name){const t=new File([M],e,{type:M.type});a(t)}else a(M)},showRetry:!1,disabled:n,selectedFolder:i,onFolderChange:o,folderConfig:s,tags:d,onTagsChange:b})}),!M&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"lb:relative lb:min-h-50","aria-live":"polite",children:[T&&l.jsx("div",{className:"lb:absolute lb:inset-0 lb:bg-white/80 lb:z-10 lb:flex lb:items-center lb:justify-center lb:rounded-lg",children:l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-2",children:[l.jsx("span",{className:"limbo-loader"}),l.jsx("span",{className:"lb:text-sm lb:text-brand-blue-800",children:"Cargando media..."})]})}),S.length>0&&l.jsxs("div",{className:"lb:relative lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:lg:grid-cols-4 lb:gap-2",children:[l.jsx(ft,{show:T,message:"Cargando media..."}),S.map((e,t)=>{const a=`${e.portal_slug}-${e.id||t}`,r=e.thumbnail||e.url;if(R.has(a)||!r)return null;const i=`${re}/api/external/proxy?url=${encodeURIComponent(r)}`,o="video"===e.type;return l.jsxs("div",{className:"lb:group lb:border lb:border-brand-blue-200 lb:rounded-lg lb:overflow-hidden lb:bg-white lb:shadow-sm lb:hover:shadow-md lb:transition-all lb:duration-200 lb:cursor-pointer",onClick:()=>{P||T||n||(o?ne(e):H(e))},children:[l.jsxs("div",{className:"lb:relative lb:aspect-video lb:bg-neutral-100",children:[l.jsx(At,{src:r,fallbackSrc:i,alt:e.alt||e.title||`Media ${t+1}`,className:"lb:object-cover lb:w-full lb:h-full",onError:()=>{O(e=>{const t=new Set(e);return t.add(a),t})}}),o&&l.jsx("span",{className:"lb:absolute lb:top-1 lb:left-1 lb:bg-black/60 lb:text-white lb:text-xs lb:px-2 lb:py-1 lb:rounded",children:"Video"}),P===(e.url||e.thumbnail)?l.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-white/90 lb:flex lb:flex-col lb:items-center lb:justify-center lb:gap-2",children:[l.jsxs("div",{className:"lb:relative lb:w-10 lb:h-10",children:[l.jsx("div",{className:"lb:absolute lb:inset-0 lb:border-4 lb:border-brand-blue-200 lb:rounded-full"}),l.jsx("div",{className:"lb:absolute lb:inset-0 lb:border-4 lb:border-brand-blue-800 lb:rounded-full lb:border-t-transparent lb:animate-spin"})]}),l.jsx("span",{className:"lb:text-sm lb:font-medium lb:text-brand-blue-1000",children:"Descargando..."})]}):o?l.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-black/0 lb:group-hover:bg-black/60 lb:transition-colors lb:duration-200 lb:flex lb:items-center lb:justify-center lb:flex-col lb:gap-1",children:[l.jsx("svg",{className:"lb:w-10 lb:h-10 lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:duration-200 lb:text-white",viewBox:"0 0 24 24",fill:"currentColor",children:l.jsx("path",{d:"M8 5v14l11-7z"})}),l.jsx("span",{className:"lb:text-sm lb:font-medium lb:text-white lb:opacity-0 lb:group-hover:opacity-100 lb:transition-opacity lb:duration-200",children:"Seleccionar vídeo"})]}):null]}),e.title&&l.jsx("div",{className:"lb:px-2 lb:pb-2 lb:pt-1",children:l.jsx("p",{className:"lb:text-xs lb:text-gray-600 lb:truncate",title:e.title,children:e.title})})]},a)})]}),!U&&!T&&0===S.length&&!z&&l.jsxs("div",{className:"lb:text-center lb:text-neutral-600 lb:py-10 lb:bg-neutral-50 lb:rounded-lg",children:[l.jsx("p",{className:"lb:font-medium lb:text-brand-blue-800",children:"Cargando contenido del portal..."}),l.jsx("p",{className:"lb:text-sm lb:mt-1 lb:text-neutral-500",children:"También puedes buscar por término específico"})]}),U&&!T&&0===S.length&&!z&&l.jsxs("div",{className:"lb:text-center lb:text-neutral-600 lb:py-8 lb:bg-neutral-50 lb:rounded-lg",children:[l.jsx("span",{className:"icon icon-search icon--lg lb:mb-2"}),l.jsx("p",{children:"No se encontraron resultados"}),k&&l.jsx("p",{className:"lb:text-sm lb:mt-1",children:"Intenta con otros términos de búsqueda"})]})]}),_&&_.total_pages>1&&l.jsxs("div",{className:"lb:mt-4 lb:flex lb:items-center lb:justify-center lb:gap-2",children:[l.jsxs("button",{onClick:()=>te(N-1),disabled:1===N||T,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(1===N||T?" pointer-events-none cursor-default":" limbo-btn-primary"),children:[l.jsx("span",{className:"icon icon-arrow-left-white icon--sm"})," ","Anterior"]}),l.jsxs("span",{className:"lb:px-4 lb:py-2 lb:text-sm lb:text-neutral-700",children:["Página ",N," de ",_.total_pages,l.jsxs("span",{className:"lb:text-xs lb:text-neutral-500 lb:block",children:["(",_.total_items," resultados)"]})]}),l.jsxs("button",{onClick:()=>te(N+1),disabled:T||N>=_.total_pages,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(T||N>=_.total_pages?" pointer-events-none cursor-default":" limbo-btn-primary"),children:["Siguiente"," ",l.jsx("span",{className:"icon icon-arrow-right-white icon--sm"})]})]})]}),l.jsx(Tt,{isOpen:!!q,video:q,onClose:()=>W(null),onSelect:K?le:null}),V&&(()=>{const e=V.thumbnail||V.url,t=`${re}/api/external/proxy?url=${encodeURIComponent(e)}`;return l.jsx(Ct,{isOpen:!!V,image:{previewUrl:e,proxyUrl:t,title:V.title||V.alt||"Imagen"},onCancel:()=>H(null),onSelect:()=>{const e=V;H(null),ne(e)}})})()]})}const Lt=[{id:"upload",label:"Subir archivo"},{id:"ai",label:"Generar"},{id:"stock",label:"Buscar en Stock"},{id:"portals",label:"Otros portales"}];function Mt({onSelect:t,onVideoSelect:n,disabled:a=!1,apiKey:r,prod:i=!1,allowedCategories:o=null,resolvedAccept:s=null,returnConfig:c=null,folderConfig:u=null,selectedFolder:d=null,onFolderChange:b=null,aiStarterPrompt:m,tags:h=[],onTagsChange:p=null}){const{isMobile:f,isTouch:g}=_(),v=e.useMemo(()=>!s||s.isAllTypes||s.includesImages?Lt:s.includesVideos?Lt.filter(e=>"upload"===e.id||"portals"===e.id):Lt.filter(e=>"upload"===e.id),[s]),[y,x]=e.useState("upload"),[w,k]=e.useState(null),[C,S]=e.useState(null),j=e.useRef(),N=["limbo-tabs","lb:flex","lb:gap-4","lb:border-b-2","lb:border-brand-blue-200","lb:mb-4",f&&"lb:overflow-x-auto lb:scrollbar-none"].filter(Boolean).join(" "),E=e=>{const t=["limbo-tab","lb:relative","lb:px-4","lb:py-2","lb:font-medium","lb:text-brand-blue-1000","lb:bg-transparent","lb:border-0","lb:border-b-2","lb:cursor-pointer","lb:transition-all","lb:duration-200","lb:hover:text-pink-1000","lb:focus:outline-none","lb:focus-visible:ring-2","lb:focus-visible:ring-brand-blue-400","lb:focus-visible:ring-offset-2","lb:text-nowrap"];return e?t.push("lb:border-b-brand-blue-1000","lb:font-semibold","limbo-active"):t.push("lb:border-b-transparent"),f&&t.push("lb:min-w-[100px]","lb:min-h-[44px]","lb:text-sm","lb:shrink-0"),g&&t.push("lb:touch-manipulation"),t.join(" ")};return l.jsxs("div",{className:"limbo-upload-form lb:py-4 lb:max-w-7xl lb:mx-auto",children:[v.length>1&&l.jsx("div",{className:N,role:"tablist","aria-label":"Opciones de subida",style:f?{WebkitOverflowScrolling:"touch",scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,children:v.map(e=>{const t=y===e.id;return l.jsxs("button",{type:"button","data-upload-tab-id":e.id,className:E(t),"aria-current":t?"page":void 0,"aria-selected":t,role:"tab",tabIndex:t?0:-1,onClick:()=>x(e.id),onKeyDown:t=>((e,t)=>{const l=v.findIndex(e=>e.id===t);let n=l;switch(e.key){case"ArrowLeft":e.preventDefault(),n=l>0?l-1:v.length-1;break;case"ArrowRight":e.preventDefault(),n=l<v.length-1?l+1:0;break;case"Home":e.preventDefault(),n=0;break;case"End":e.preventDefault(),n=v.length-1;break;case"Enter":case" ":return e.preventDefault(),void x(t);default:return}const a=v[n];a&&(x(a.id),setTimeout(()=>{const e=document.querySelector(`[data-upload-tab-id="${a.id}"]`);e&&e.focus()},0))})(t,e.id),id:`upload-tab-${e.id}`,"aria-controls":`upload-tabpanel-${e.id}`,style:g?{WebkitTapHighlightColor:"transparent"}:void 0,children:["ai"===e.id?l.jsx("span",{className:"icon icon-ia lb:me-1"}):null,e.label]},e.id)})}),l.jsxs("div",{className:"limbo-tab-content lb:px-2 lb:py-2",role:"tabpanel",id:`upload-tabpanel-${y}`,"aria-labelledby":`upload-tab-${y}`,children:["upload"===y&&l.jsx(ut,{file:w,setFile:k,previewUrl:C,setPreviewUrl:S,fileInputRef:j,onSelect:t,disabled:a,allowedCategories:o,resolvedAccept:s,selectedFolder:d,onFolderChange:b,folderConfig:u,tags:h,onTagsChange:p}),"ai"===y&&l.jsx(yt,{apiKey:r,prod:i,disabled:a,onSelect:t,selectedFolder:d,onFolderChange:b,folderConfig:u,aiStarterPrompt:m,tags:h,onTagsChange:p}),"stock"===y&&l.jsx(jt,{apiKey:r,prod:i,disabled:a,onSelect:t,selectedFolder:d,onFolderChange:b,folderConfig:u,tags:h,onTagsChange:p}),"portals"===y&&l.jsx(zt,{apiKey:r,prod:i,disabled:a,onSelect:t,onVideoSelect:n,resolvedAccept:s,returnConfig:c,selectedFolder:d,onFolderChange:b,folderConfig:u,tags:h,onTagsChange:p})]})]})}function It({onSelect:e,onVideoSelect:t,onFolderChange:n,uploading:a,uploadError:r,uploadedImage:i,selectedUploadFolder:o,apiKey:s,prod:c,allowedCategories:u,resolvedAccept:d,returnConfig:b,folderConfig:m,aiStarterPrompt:h,resetUpload:p,tags:f,onTagsChange:g}){return l.jsxs("div",{children:[a&&l.jsx(lt,{text:"Subiendo archivo..."}),r&&l.jsxs(fe,{variant:"danger",toast:!0,onClose:p,children:["Error al subir archivo: ",r]}),i&&l.jsxs(fe,{variant:"success",toast:!0,onClose:p,children:[l.jsx("span",{className:"icon icon-tick-white icon--2sm"})," Archivo subido correctamente: ",i.filename]}),l.jsx(Mt,{onSelect:e,onVideoSelect:t,disabled:a,apiKey:s,prod:c,allowedCategories:u,resolvedAccept:d,returnConfig:b,folderConfig:m,aiStarterPrompt:h,selectedFolder:o,onFolderChange:n,tags:f,onTagsChange:g})]})}const Pt="undefined"!=typeof window&&void 0!==window.document,Dt=Pt?window:{},Rt=!!Pt&&"ontouchstart"in Dt.document.documentElement,Ot=!!Pt&&"PointerEvent"in Dt,Ft="cropper",Ut=`${Ft}-canvas`,Bt=`${Ft}-crosshair`,qt=`${Ft}-grid`,Wt=`${Ft}-handle`,Vt=`${Ft}-image`,Ht=`${Ft}-selection`,Kt=`${Ft}-shade`,Gt=`${Ft}-viewer`,Qt="select",Xt="move",Yt="scale",Jt="rotate",Zt="transform",el="none",tl="n-resize",ll="e-resize",nl="s-resize",al="w-resize",rl="ne-resize",il="nw-resize",ol="se-resize",sl="sw-resize",cl=Ot?"pointerdown":Rt?"touchstart":"mousedown",ul=Ot?"pointermove":Rt?"touchmove":"mousemove",dl=Ot?"pointerup pointercancel":Rt?"touchend touchcancel":"mouseup",bl="error",ml="keydown",hl="load",pl="resize",fl="wheel",gl="action",vl="actionend",yl="actionstart",xl="change",wl="transform";const kl=Number.isNaN||Dt.isNaN;function Cl(e){return"number"==typeof e&&!kl(e)}function Sl(e){return Cl(e)&&e>0&&e<1/0}function jl(e){return"object"==typeof e&&null!==e}const{hasOwnProperty:Nl}=Object.prototype;function El(e){if(!jl(e))return!1;try{const{constructor:t}=e,{prototype:l}=t;return t&&l&&Nl.call(l,"isPrototypeOf")}catch(t){return!1}}function _l(e){return"function"==typeof e}function $l(e){return"object"==typeof e&&null!==e&&1===e.nodeType}const Tl=/([a-z\d])([A-Z])/g;function Al(e){return String(e).replace(Tl,"$1-$2").toLowerCase()}const zl=/-[A-z\d]/g;function Ll(e){return e.replace(zl,e=>e.slice(1).toUpperCase())}const Ml=/\s\s*/;function Il(e,t,l,n){t.trim().split(Ml).forEach(t=>{e.removeEventListener(t,l,n)})}function Pl(e,t,l,n){t.trim().split(Ml).forEach(t=>{e.addEventListener(t,l,n)})}function Dl(e,t,l,n){Pl(e,t,l,Object.assign(Object.assign({},n),{once:!0}))}const Rl={bubbles:!0,cancelable:!0,composed:!0};const Ol=Promise.resolve();function Fl(e){const{documentElement:t}=e.ownerDocument,l=e.getBoundingClientRect();return{left:l.left+(Dt.pageXOffset-t.clientLeft),top:l.top+(Dt.pageYOffset-t.clientTop)}}const Ul=/deg|g?rad|turn$/i;function Bl(e){const t=parseFloat(e)||0;if(0!==t){const[l="rad"]=String(e).match(Ul)||[];switch(l.toLowerCase()){case"deg":return t/360*(2*Math.PI);case"grad":return t/400*(2*Math.PI);case"turn":return t*(2*Math.PI)}}return t}const ql="contain";function Wl(e,t=ql){const{aspectRatio:l}=e;let{width:n,height:a}=e;const r=Sl(n),i=Sl(a);if(r&&i){const e=a*l;t===ql&&e>n||"cover"===t&&e<n?a=n/l:n=a*l}else r?a=n/l:i&&(n=a*l);return{width:n,height:a}}function Vl(e,...t){if(0===t.length)return e;const[l,n,a,r,i,o]=e,[s,c,u,d,b,m]=t[0];return Vl(e=[l*s+a*c,n*s+r*c,l*u+a*d,n*u+r*d,l*b+a*m+i,n*b+r*m+o],...t.slice(1))}const Hl=/left|top|width|height/i,Kl="open",Gl=new WeakMap,Ql=new WeakMap,Xl=new Map,Yl=Dt.document&&Array.isArray(Dt.document.adoptedStyleSheets)&&"replaceSync"in Dt.CSSStyleSheet.prototype;class Jl extends HTMLElement{get $sharedStyle(){return(this.themeColor?`:host{--theme-color: ${this.themeColor};}`:"")+":host([hidden]){display:none!important}"}constructor(){var e,t;super(),this.shadowRootMode=Kl,this.slottable=!0;const l=null===(t=null===(e=Object.getPrototypeOf(this))||void 0===e?void 0:e.constructor)||void 0===t?void 0:t.$name;l&&Xl.set(l,this.tagName.toLowerCase())}static get observedAttributes(){return["shadow-root-mode","slottable","theme-color"]}attributeChangedCallback(e,t,l){if(Object.is(l,t))return;const n=Ll(e);let a=l;switch(typeof this[n]){case"boolean":a=null!==l&&"false"!==l;break;case"number":a=Number(l)}switch(this[n]=a,e){case"theme-color":{const e=Ql.get(this),t=this.$sharedStyle;e&&t&&(Yl?e.replaceSync(t):e.textContent=t);break}}}$propertyChangedCallback(e,t,l){if(!Object.is(l,t))switch(e=Al(e),typeof l){case"boolean":!0===l?this.hasAttribute(e)||this.setAttribute(e,""):this.removeAttribute(e);break;case"number":l=kl(l)?"":String(l);default:l?this.getAttribute(e)!==l&&this.setAttribute(e,l):this.removeAttribute(e)}}connectedCallback(){Object.getPrototypeOf(this).constructor.observedAttributes.forEach(e=>{const t=Ll(e);let l=this[t];(function(e){return void 0===e})(l)||this.$propertyChangedCallback(t,void 0,l),Object.defineProperty(this,t,{enumerable:!0,configurable:!0,get:()=>l,set(e){const n=l;l=e,this.$propertyChangedCallback(t,n,e)}})});const e=this.shadowRoot||this.attachShadow({mode:this.shadowRootMode||Kl});if(Gl.set(this,e),Ql.set(this,this.$addStyles(this.$sharedStyle)),this.$style&&this.$addStyles(this.$style),this.$template){const t=document.createElement("template");t.innerHTML=this.$template,e.appendChild(t.content)}if(this.slottable){const t=document.createElement("slot");e.appendChild(t)}}disconnectedCallback(){Ql.has(this)&&Ql.delete(this),Gl.has(this)&&Gl.delete(this)}$getTagNameOf(e){var t;return null!==(t=Xl.get(e))&&void 0!==t?t:e}$setStyles(e){return Object.keys(e).forEach(t=>{let l=e[t];Cl(l)&&(l=0!==l&&Hl.test(t)?`${l}px`:String(l)),this.style[t]=l}),this}$getShadowRoot(){return this.shadowRoot||Gl.get(this)}$addStyles(e){let t;const l=this.$getShadowRoot();return Yl?(t=new CSSStyleSheet,t.replaceSync(e),l.adoptedStyleSheets=l.adoptedStyleSheets.concat(t)):(t=document.createElement("style"),t.textContent=e,l.appendChild(t)),t}$emit(e,t,l){return function(e,t,l,n){return e.dispatchEvent(new CustomEvent(t,Object.assign(Object.assign(Object.assign({},Rl),{detail:l}),n)))}(this,e,t,l)}$nextTick(e){return function(e,t){return t?Ol.then(e?t.bind(e):t):Ol}(this,e)}static $define(e,t){jl(e)&&(t=e,e=""),e||(e=this.$name||this.name),e=Al(e),Pt&&Dt.customElements&&!Dt.customElements.get(e)&&customElements.define(e,this,t)}}Jl.$version="2.1.1";class Zl extends Jl{constructor(){super(...arguments),this.$onPointerDown=null,this.$onPointerMove=null,this.$onPointerUp=null,this.$onWheel=null,this.$wheeling=!1,this.$pointers=new Map,this.$style=':host{display:block;min-height:100px;min-width:200px;overflow:hidden;position:relative;touch-action:none;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}:host([background]){background-color:#fff;background-image:repeating-linear-gradient(45deg,#ccc 25%,transparent 0,transparent 75%,#ccc 0,#ccc),repeating-linear-gradient(45deg,#ccc 25%,transparent 0,transparent 75%,#ccc 0,#ccc);background-image:repeating-conic-gradient(#ccc 0 25%,#fff 0 50%);background-position:0 0,.5rem .5rem;background-size:1rem 1rem}:host([disabled]){pointer-events:none}:host([disabled]):after{bottom:0;content:"";cursor:not-allowed;display:block;left:0;pointer-events:none;position:absolute;right:0;top:0}',this.$action=el,this.background=!1,this.disabled=!1,this.scaleStep=.1,this.themeColor="#39f"}static get observedAttributes(){return super.observedAttributes.concat(["background","disabled","scale-step"])}connectedCallback(){super.connectedCallback(),this.disabled||this.$bind()}disconnectedCallback(){this.disabled||this.$unbind(),super.disconnectedCallback()}$propertyChangedCallback(e,t,l){if(!Object.is(l,t)&&(super.$propertyChangedCallback(e,t,l),"disabled"===e))l?this.$unbind():this.$bind()}$bind(){this.$onPointerDown||(this.$onPointerDown=this.$handlePointerDown.bind(this),Pl(this,cl,this.$onPointerDown)),this.$onPointerMove||(this.$onPointerMove=this.$handlePointerMove.bind(this),Pl(this.ownerDocument,ul,this.$onPointerMove)),this.$onPointerUp||(this.$onPointerUp=this.$handlePointerUp.bind(this),Pl(this.ownerDocument,dl,this.$onPointerUp)),this.$onWheel||(this.$onWheel=this.$handleWheel.bind(this),Pl(this,fl,this.$onWheel,{passive:!1,capture:!0}))}$unbind(){this.$onPointerDown&&(Il(this,cl,this.$onPointerDown),this.$onPointerDown=null),this.$onPointerMove&&(Il(this.ownerDocument,ul,this.$onPointerMove),this.$onPointerMove=null),this.$onPointerUp&&(Il(this.ownerDocument,dl,this.$onPointerUp),this.$onPointerUp=null),this.$onWheel&&(Il(this,fl,this.$onWheel,{capture:!0}),this.$onWheel=null)}$handlePointerDown(e){const{buttons:t,button:l,type:n}=e;if(this.disabled||("pointerdown"===n&&"mouse"===e.pointerType||"mousedown"===n)&&(Cl(t)&&1!==t||Cl(l)&&0!==l||e.ctrlKey))return;const{$pointers:a}=this;let r="";if(e.changedTouches)Array.from(e.changedTouches).forEach(({identifier:e,pageX:t,pageY:l})=>{a.set(e,{startX:t,startY:l,endX:t,endY:l})});else{const{pointerId:t=0,pageX:l,pageY:n}=e;a.set(t,{startX:l,startY:n,endX:l,endY:n})}a.size>1?r=Zt:$l(e.target)&&(r=e.target.action||e.target.getAttribute("action")||""),!1!==this.$emit(yl,{action:r,relatedEvent:e})&&(e.preventDefault(),this.$action=r,this.style.willChange="transform")}$handlePointerMove(e){const{$action:t,$pointers:l}=this;if(this.disabled||t===el||0===l.size)return;if(!1===this.$emit("actionmove",{action:t,relatedEvent:e}))return;if(e.preventDefault(),e.changedTouches)Array.from(e.changedTouches).forEach(({identifier:e,pageX:t,pageY:n})=>{const a=l.get(e);a&&Object.assign(a,{endX:t,endY:n})});else{const{pointerId:t=0,pageX:n,pageY:a}=e,r=l.get(t);r&&Object.assign(r,{endX:n,endY:a})}const n={action:t,relatedEvent:e};if(t===Zt){const t=new Map(l);let a=0,r=0,i=0,o=0,s=e.pageX,c=e.pageY;l.forEach((e,l)=>{t.delete(l),t.forEach(t=>{let l=t.startX-e.startX,n=t.startY-e.startY,u=t.endX-e.endX,d=t.endY-e.endY,b=0,m=0,h=0,p=0;if(0===l?n<0?h=2*Math.PI:n>0&&(h=Math.PI):l>0?h=Math.PI/2+Math.atan(n/l):l<0&&(h=1.5*Math.PI+Math.atan(n/l)),0===u?d<0?p=2*Math.PI:d>0&&(p=Math.PI):u>0?p=Math.PI/2+Math.atan(d/u):u<0&&(p=1.5*Math.PI+Math.atan(d/u)),p>0||h>0){const l=p-h,n=Math.abs(l);n>a&&(a=n,i=l,s=(e.startX+t.startX)/2,c=(e.startY+t.startY)/2)}if(l=Math.abs(l),n=Math.abs(n),u=Math.abs(u),d=Math.abs(d),l>0&&n>0?b=Math.sqrt(l*l+n*n):l>0?b=l:n>0&&(b=n),u>0&&d>0?m=Math.sqrt(u*u+d*d):u>0?m=u:d>0&&(m=d),b>0&&m>0){const l=(m-b)/b,n=Math.abs(l);n>r&&(r=n,o=l,s=(e.startX+t.startX)/2,c=(e.startY+t.startY)/2)}})});const u=a>0,d=r>0;u&&d?(n.rotate=i,n.scale=o,n.centerX=s,n.centerY=c):u?(n.action=Jt,n.rotate=i,n.centerX=s,n.centerY=c):d?(n.action=Yt,n.scale=o,n.centerX=s,n.centerY=c):n.action=el}else{const[e]=Array.from(l.values());Object.assign(n,e)}l.forEach(e=>{e.startX=e.endX,e.startY=e.endY}),n.action!==el&&this.$emit(gl,n,{cancelable:!1})}$handlePointerUp(e){const{$action:t,$pointers:l}=this;if(!this.disabled&&t!==el&&!1!==this.$emit(vl,{action:t,relatedEvent:e})){if(e.preventDefault(),e.changedTouches)Array.from(e.changedTouches).forEach(({identifier:e})=>{l.delete(e)});else{const{pointerId:t=0}=e;l.delete(t)}0===l.size&&(this.style.willChange="",this.$action=el)}}$handleWheel(e){if(this.disabled)return;if(e.preventDefault(),this.$wheeling)return;this.$wheeling=!0,setTimeout(()=>{this.$wheeling=!1},50);const t=(e.deltaY>0?-1:1)*this.scaleStep;this.$emit(gl,{action:Yt,scale:t,relatedEvent:e},{cancelable:!1})}$setAction(e){return"string"==typeof e&&(this.$action=e),this}$toCanvas(e){return new Promise((t,l)=>{if(!this.isConnected)return void l(new Error("The current element is not connected to the DOM."));const n=document.createElement("canvas");let a=this.offsetWidth,r=this.offsetHeight,i=1;El(e)&&(Sl(e.width)||Sl(e.height))&&(({width:a,height:r}=Wl({aspectRatio:a/r,width:e.width,height:e.height})),i=a/this.offsetWidth),n.width=a,n.height=r;const o=this.querySelector(this.$getTagNameOf(Vt));o?o.$ready().then(l=>{const s=n.getContext("2d");if(s){const[t,c,u,d,b,m]=o.$getTransform();let h=b,p=m,f=l.naturalWidth,g=l.naturalHeight;1!==i&&(h*=i,p*=i,f*=i,g*=i);const v=f/2,y=g/2;s.fillStyle="transparent",s.fillRect(0,0,a,r),El(e)&&_l(e.beforeDraw)&&e.beforeDraw.call(this,s,n),s.save(),s.translate(v,y),s.transform(t,c,u,d,h,p),s.translate(-v,-y),s.drawImage(l,0,0,f,g),s.restore()}t(n)}).catch(l):t(n)})}}Zl.$name=Ut,Zl.$version="2.1.1";const en=new WeakMap,tn=["alt","crossorigin","decoding","elementtiming","fetchpriority","loading","referrerpolicy","sizes","src","srcset"];class ln extends Jl{constructor(){super(...arguments),this.$isReady=!1,this.$matrix=[1,0,0,1,0,0],this.$onLoad=null,this.$onCanvasAction=null,this.$onCanvasActionEnd=null,this.$onCanvasActionStart=null,this.$actionStartTarget=null,this.$style=":host{display:inline-block}img{display:block;height:100%;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;width:100%}",this.$image=new Image,this.initialCenterSize="contain",this.rotatable=!1,this.scalable=!1,this.skewable=!1,this.slottable=!1,this.translatable=!1,this.alt="",this.crossorigin="",this.decoding="",this.elementtiming="",this.fetchpriority="",this.loading="",this.referrerpolicy="",this.sizes="",this.src="",this.srcset=""}set $canvas(e){en.set(this,e)}get $canvas(){return en.get(this)}static get observedAttributes(){return super.observedAttributes.concat(tn,["initial-center-size","rotatable","scalable","skewable","translatable"])}attributeChangedCallback(e,t,l){Object.is(l,t)||(super.attributeChangedCallback(e,t,l),tn.includes(e)&&this.$image.setAttribute(e,l))}$propertyChangedCallback(e,t,l){if(!Object.is(l,t))switch(super.$propertyChangedCallback(e,t,l),e){case"initialCenterSize":this.$nextTick(()=>{this.$center(l)});break;case"src":this.$isReady=!1}}connectedCallback(){super.connectedCallback();const{$image:e}=this,t=this.closest(this.$getTagNameOf(Ut));t&&(this.$canvas=t,this.$setStyles({display:"block",position:"absolute"}),this.$onCanvasActionStart=e=>{var t,l;this.$actionStartTarget=null===(l=null===(t=e.detail)||void 0===t?void 0:t.relatedEvent)||void 0===l?void 0:l.target},this.$onCanvasActionEnd=()=>{this.$actionStartTarget=null},this.$onCanvasAction=this.$handleAction.bind(this),Pl(t,yl,this.$onCanvasActionStart),Pl(t,vl,this.$onCanvasActionEnd),Pl(t,gl,this.$onCanvasAction)),this.$onLoad=this.$handleLoad.bind(this),Pl(e,hl,this.$onLoad),this.$getShadowRoot().appendChild(e)}disconnectedCallback(){const{$image:e,$canvas:t}=this;t&&(this.$onCanvasActionStart&&(Il(t,yl,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(Il(t,vl,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(Il(t,gl,this.$onCanvasAction),this.$onCanvasAction=null)),e&&this.$onLoad&&(Il(e,hl,this.$onLoad),this.$onLoad=null),this.$getShadowRoot().removeChild(e),super.disconnectedCallback()}$handleLoad(){const{$image:e}=this;this.$setStyles({width:e.naturalWidth,height:e.naturalHeight}),this.$canvas&&this.$center(this.initialCenterSize),this.$isReady=!0}$handleAction(e){if(this.hidden||!(this.rotatable||this.scalable||this.translatable))return;const{$canvas:t}=this,{detail:l}=e;if(l){const{relatedEvent:e}=l;let{action:n}=l;switch(n!==Zt||this.rotatable&&this.scalable||(n=this.rotatable?Jt:this.scalable?Yt:el),n){case Xt:if(this.translatable){let n=null;e&&(n=e.target.closest(this.$getTagNameOf(Ht))),n||(n=t.querySelector(this.$getTagNameOf(Ht))),n&&n.multiple&&!n.active&&(n=t.querySelector(`${this.$getTagNameOf(Ht)}[active]`)),n&&!n.hidden&&n.movable&&!n.dynamic&&this.$actionStartTarget&&n.contains(this.$actionStartTarget)||this.$move(l.endX-l.startX,l.endY-l.startY)}break;case Jt:if(this.rotatable)if(e){const{x:t,y:n}=this.getBoundingClientRect();this.$rotate(l.rotate,e.clientX-t,e.clientY-n)}else this.$rotate(l.rotate);break;case Yt:if(this.scalable)if(e){const t=e.target.closest(this.$getTagNameOf(Ht));if(!t||!t.zoomable||t.zoomable&&t.dynamic){const{x:t,y:n}=this.getBoundingClientRect();this.$zoom(l.scale,e.clientX-t,e.clientY-n)}}else this.$zoom(l.scale);break;case Zt:if(this.rotatable&&this.scalable){const{rotate:t}=l;let{scale:n}=l;n<0?n=1/(1-n):n+=1;const a=Math.cos(t),r=Math.sin(t),[i,o,s,c]=[a*n,r*n,-r*n,a*n];if(e){const t=this.getBoundingClientRect(),l=e.clientX-t.x,n=e.clientY-t.y,[a,r,u,d]=this.$matrix,b=l-t.width/2,m=n-t.height/2,h=(b*d-u*m)/(a*d-u*r),p=(m*a-r*b)/(a*d-u*r);this.$transform(i,o,s,c,h*(1-i)+p*s,p*(1-c)+h*o)}else this.$transform(i,o,s,c,0,0)}}}}$ready(e){const{$image:t}=this,l=new Promise((e,l)=>{const n=new Error("Failed to load the image source");if(t.complete)t.naturalWidth>0&&t.naturalHeight>0?e(t):l(n);else{const a=()=>{Il(t,bl,r),setTimeout(()=>{e(t)})},r=()=>{Il(t,hl,a),l(n)};Dl(t,hl,a),Dl(t,bl,r)}});return _l(e)&&l.then(t=>(e(t),t)),l}$center(e){const{parentElement:t}=this;if(!t)return this;const l=t.getBoundingClientRect(),n=l.width,a=l.height,{x:r,y:i,width:o,height:s}=this.getBoundingClientRect(),c=r+o/2,u=i+s/2,d=l.x+n/2,b=l.y+a/2,{translatable:m}=this;if(m||this.$isReady||(this.translatable=!0,this.$nextTick(()=>{this.translatable=m})),this.$move(d-c,b-u),e&&(o!==n||s!==a)){const t=n/o,l=a/s,{scalable:r}=this;switch(!e||r||this.$isReady||(this.scalable=!0,this.$nextTick(()=>{this.scalable=r})),e){case"cover":this.$scale(Math.max(t,l));break;case"contain":this.$scale(Math.min(t,l))}}return this}$move(e,t=e){if(this.translatable&&Cl(e)&&Cl(t)){const[l,n,a,r]=this.$matrix,i=(e*r-a*t)/(l*r-a*n),o=(t*l-n*e)/(l*r-a*n);this.$translate(i,o)}return this}$moveTo(e,t=e){if(this.translatable&&Cl(e)&&Cl(t)){const[l,n,a,r]=this.$matrix,i=(e*r-a*t)/(l*r-a*n),o=(t*l-n*e)/(l*r-a*n);this.$setTransform(l,n,a,r,i,o)}return this}$rotate(e,t,l){if(this.rotatable){const n=Bl(e),a=Math.cos(n),r=Math.sin(n),[i,o,s,c]=[a,r,-r,a];if(Cl(t)&&Cl(l)){const[e,n,a,r]=this.$matrix,{width:u,height:d}=this.getBoundingClientRect(),b=t-u/2,m=l-d/2,h=(b*r-a*m)/(e*r-a*n),p=(m*e-n*b)/(e*r-a*n);this.$transform(i,o,s,c,h*(1-i)-p*s,p*(1-c)-h*o)}else this.$transform(i,o,s,c,0,0)}return this}$zoom(e,t,l){if(!this.scalable||0===e)return this;if(e<0?e=1/(1-e):e+=1,Cl(t)&&Cl(l)){const[n,a,r,i]=this.$matrix,{width:o,height:s}=this.getBoundingClientRect(),c=t-o/2,u=l-s/2,d=(c*i-r*u)/(n*i-r*a),b=(u*n-a*c)/(n*i-r*a);this.$transform(e,0,0,e,d*(1-e),b*(1-e))}else this.$scale(e);return this}$scale(e,t=e){return this.scalable&&this.$transform(e,0,0,t,0,0),this}$skew(e,t=0){if(this.skewable){const l=Bl(e),n=Bl(t);this.$transform(1,Math.tan(n),Math.tan(l),1,0,0)}return this}$translate(e,t=e){return this.translatable&&Cl(e)&&Cl(t)&&this.$transform(1,0,0,1,e,t),this}$transform(e,t,l,n,a,r){return Cl(e)&&Cl(t)&&Cl(l)&&Cl(n)&&Cl(a)&&Cl(r)?this.$setTransform(Vl(this.$matrix,[e,t,l,n,a,r])):this}$setTransform(e,t,l,n,a,r){if((this.rotatable||this.scalable||this.skewable||this.translatable)&&(Array.isArray(e)&&([e,t,l,n,a,r]=e),Cl(e)&&Cl(t)&&Cl(l)&&Cl(n)&&Cl(a)&&Cl(r))){const i=[...this.$matrix],o=[e,t,l,n,a,r];if(!1===this.$emit(wl,{matrix:o,oldMatrix:i}))return this;this.$matrix=o,this.style.transform=`matrix(${o.join(", ")})`}return this}$getTransform(){return this.$matrix.slice()}$resetTransform(){return this.$setTransform([1,0,0,1,0,0])}}ln.$name=Vt,ln.$version="2.1.1";const nn=new WeakMap;class an extends Jl{constructor(){super(...arguments),this.$onWindowResize=null,this.$onCanvasActionEnd=null,this.$onCanvasActionStart=null,this.$onSelectionChange=null,this.$style=":host{display:block;height:0;left:0;outline:var(--theme-color) solid 1px;position:relative;top:0;width:0}:host([transparent]){outline-color:transparent}",this.x=0,this.y=0,this.width=0,this.height=0,this.slottable=!1,this.themeColor="rgba(0, 0, 0, 0.65)"}set $canvas(e){nn.set(this,e)}get $canvas(){return nn.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["height","width","x","y"])}connectedCallback(){super.connectedCallback();const e=this.closest(this.$getTagNameOf(Ut));if(e){this.$canvas=e,this.style.position="absolute";const t=e.querySelector(this.$getTagNameOf(Ht));t&&(this.$onWindowResize=this.$render.bind(this),this.$onCanvasActionStart=e=>{t.hidden&&e.detail.action===Qt&&(this.hidden=!1)},this.$onCanvasActionEnd=e=>{t.hidden&&e.detail.action===Qt&&(this.hidden=!0)},this.$onSelectionChange=e=>{const{x:l,y:n,width:a,height:r}=e.defaultPrevented?t:e.detail;this.$change(l,n,a,r),(t.hidden||0===l&&0===n&&0===a&&0===r)&&(this.hidden=!0)},Pl(window,pl,this.$onWindowResize),Pl(e,yl,this.$onCanvasActionStart),Pl(e,vl,this.$onCanvasActionEnd),Pl(e,xl,this.$onSelectionChange))}this.$render()}disconnectedCallback(){const{$canvas:e}=this;e&&(this.$onWindowResize&&(Il(window,pl,this.$onWindowResize),this.$onWindowResize=null),this.$onCanvasActionStart&&(Il(e,yl,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(Il(e,vl,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onSelectionChange&&(Il(e,xl,this.$onSelectionChange),this.$onSelectionChange=null)),super.disconnectedCallback()}$change(e,t,l=this.width,n=this.height){return Cl(e)&&Cl(t)&&Cl(l)&&Cl(n)&&(e!==this.x||t!==this.y||l!==this.width||n!==this.height)?(this.hidden&&(this.hidden=!1),this.x=e,this.y=t,this.width=l,this.height=n,this.$render()):this}$reset(){return this.$change(0,0,0,0)}$render(){return this.$setStyles({transform:`translate(${this.x}px, ${this.y}px)`,width:this.width,height:this.height,outlineWidth:Dt.innerWidth*Dt.devicePixelRatio})}}an.$name=Kt,an.$version="2.1.1";class rn extends Jl{constructor(){super(...arguments),this.$onCanvasCropEnd=null,this.$onCanvasCropStart=null,this.$style=':host{background-color:var(--theme-color);display:block}:host([action=move]),:host([action=select]){height:100%;left:0;position:absolute;top:0;width:100%}:host([action=move]){cursor:move}:host([action=select]){cursor:crosshair}:host([action$=-resize]){background-color:transparent;height:15px;position:absolute;width:15px}:host([action$=-resize]):after{background-color:var(--theme-color);content:"";display:block;height:5px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:5px}:host([action=n-resize]),:host([action=s-resize]){cursor:ns-resize;left:50%;transform:translateX(-50%);width:100%}:host([action=n-resize]){top:-8px}:host([action=s-resize]){bottom:-8px}:host([action=e-resize]),:host([action=w-resize]){cursor:ew-resize;height:100%;top:50%;transform:translateY(-50%)}:host([action=e-resize]){right:-8px}:host([action=w-resize]){left:-8px}:host([action=ne-resize]){cursor:nesw-resize;right:-8px;top:-8px}:host([action=nw-resize]){cursor:nwse-resize;left:-8px;top:-8px}:host([action=se-resize]){bottom:-8px;cursor:nwse-resize;right:-8px}:host([action=se-resize]):after{height:15px;width:15px}@media (pointer:coarse){:host([action=se-resize]):after{height:10px;width:10px}}@media (pointer:fine){:host([action=se-resize]):after{height:5px;width:5px}}:host([action=sw-resize]){bottom:-8px;cursor:nesw-resize;left:-8px}:host([plain]){background-color:transparent}',this.action=el,this.plain=!1,this.slottable=!1,this.themeColor="rgba(51, 153, 255, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["action","plain"])}}rn.$name=Wt,rn.$version="2.1.1";const on=new WeakMap;class sn extends Jl{constructor(){super(...arguments),this.$onCanvasAction=null,this.$onCanvasActionStart=null,this.$onCanvasActionEnd=null,this.$onDocumentKeyDown=null,this.$action="",this.$actionStartTarget=null,this.$changing=!1,this.$style=':host{display:block;left:0;position:relative;right:0}:host([outlined]){outline:1px solid var(--theme-color)}:host([multiple]){outline:1px dashed hsla(0,0%,100%,.5)}:host([multiple]):after{bottom:0;content:"";cursor:pointer;display:block;left:0;position:absolute;right:0;top:0}:host([multiple][active]){outline-color:var(--theme-color);z-index:1}:host([multiple])>*{visibility:hidden}:host([multiple][active])>*{visibility:visible}:host([multiple][active]):after{display:none}',this.$initialSelection={x:0,y:0,width:0,height:0},this.x=0,this.y=0,this.width=0,this.height=0,this.aspectRatio=NaN,this.initialAspectRatio=NaN,this.initialCoverage=NaN,this.active=!1,this.linked=!1,this.dynamic=!1,this.movable=!1,this.resizable=!1,this.zoomable=!1,this.multiple=!1,this.keyboard=!1,this.outlined=!1,this.precise=!1}set $canvas(e){on.set(this,e)}get $canvas(){return on.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["active","aspect-ratio","dynamic","height","initial-aspect-ratio","initial-coverage","keyboard","linked","movable","multiple","outlined","precise","resizable","width","x","y","zoomable"])}$propertyChangedCallback(e,t,l){if(!Object.is(l,t))switch(super.$propertyChangedCallback(e,t,l),e){case"x":case"y":case"width":case"height":this.$changing||this.$nextTick(()=>{this.$change(this.x,this.y,this.width,this.height,this.aspectRatio,!0)});break;case"aspectRatio":case"initialAspectRatio":this.$nextTick(()=>{this.$initSelection()});break;case"initialCoverage":this.$nextTick(()=>{Sl(l)&&l<=1&&this.$initSelection(!0,!0)});break;case"keyboard":this.$nextTick(()=>{this.$canvas&&(l?this.$onDocumentKeyDown||(this.$onDocumentKeyDown=this.$handleKeyDown.bind(this),Pl(this.ownerDocument,ml,this.$onDocumentKeyDown)):this.$onDocumentKeyDown&&(Il(this.ownerDocument,ml,this.$onDocumentKeyDown),this.$onDocumentKeyDown=null))});break;case"multiple":this.$nextTick(()=>{if(this.$canvas){const e=this.$getSelections();l?(e.forEach(e=>{e.active=!1}),this.active=!0,this.$emit(xl,{x:this.x,y:this.y,width:this.width,height:this.height})):(this.active=!1,e.slice(1).forEach(e=>{this.$removeSelection(e)}))}});break;case"precise":this.$nextTick(()=>{this.$change(this.x,this.y)});break;case"linked":l&&(this.dynamic=!0)}}connectedCallback(){super.connectedCallback();const e=this.closest(this.$getTagNameOf(Ut));e?(this.$canvas=e,this.$setStyles({position:"absolute",transform:`translate(${this.x}px, ${this.y}px)`}),this.hidden||this.$render(),this.$initSelection(!0),this.$onCanvasActionStart=this.$handleActionStart.bind(this),this.$onCanvasActionEnd=this.$handleActionEnd.bind(this),this.$onCanvasAction=this.$handleAction.bind(this),Pl(e,yl,this.$onCanvasActionStart),Pl(e,vl,this.$onCanvasActionEnd),Pl(e,gl,this.$onCanvasAction)):this.$render()}disconnectedCallback(){const{$canvas:e}=this;e&&(this.$onCanvasActionStart&&(Il(e,yl,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(Il(e,vl,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(Il(e,gl,this.$onCanvasAction),this.$onCanvasAction=null)),super.disconnectedCallback()}$getSelections(){let e=[];return this.parentElement&&(e=Array.from(this.parentElement.querySelectorAll(this.$getTagNameOf(Ht)))),e}$initSelection(e=!1,t=!1){const{initialCoverage:l,parentElement:n}=this;if(Sl(l)&&n){const a=this.aspectRatio||this.initialAspectRatio;let r=(t?0:this.width)||n.offsetWidth*l,i=(t?0:this.height)||n.offsetHeight*l;Sl(a)&&({width:r,height:i}=Wl({aspectRatio:a,width:r,height:i})),this.$change(this.x,this.y,r,i),e&&this.$center(),this.$initialSelection={x:this.x,y:this.y,width:this.width,height:this.height}}}$createSelection(){const e=this.cloneNode(!0);return this.hasAttribute("id")&&e.removeAttribute("id"),e.initialCoverage=NaN,this.active=!1,this.parentElement&&this.parentElement.insertBefore(e,this.nextSibling),e}$removeSelection(e=this){if(this.parentElement){const t=this.$getSelections();if(t.length>1){const l=t.indexOf(e),n=t[l+1]||t[l-1];n&&(e.active=!1,this.parentElement.removeChild(e),n.active=!0,n.$emit(xl,{x:n.x,y:n.y,width:n.width,height:n.height}))}else this.$clear()}}$handleActionStart(e){var t,l;const n=null===(l=null===(t=e.detail)||void 0===t?void 0:t.relatedEvent)||void 0===l?void 0:l.target;this.$action="",this.$actionStartTarget=n,!this.hidden&&this.multiple&&!this.active&&n===this&&this.parentElement&&(this.$getSelections().forEach(e=>{e.active=!1}),this.active=!0,this.$emit(xl,{x:this.x,y:this.y,width:this.width,height:this.height}))}$handleAction(e){const{currentTarget:t,detail:l}=e;if(!t||!l)return;const{relatedEvent:n}=l;let{action:a}=l;const r=n?function(e){if("function"==typeof e.composedPath)return e.composedPath().find($l)||e.target;return e.target}(n):null;if(!a&&this.multiple&&(a=this.$action||(null==r?void 0:r.action),this.$action=a),!a||this.hidden&&a!==Qt||this.multiple&&!this.active&&a!==Yt)return;const{width:i,height:o}=this;let s=l.endX-l.startX,c=l.endY-l.startY,{aspectRatio:u}=this;switch(!Sl(u)&&n.shiftKey&&(u=Sl(i)&&Sl(o)?i/o:1),a){case Qt:if(0!==s||0!==c){0===s?s=c:0===c&&(c=s);const{$canvas:e}=this,n=Fl(t);(this.multiple&&!this.hidden?this.$createSelection():this).$change(l.startX-n.left,l.startY-n.top,Math.abs(s),Math.abs(c),u),s<0?c<0?a=il:c>0&&(a=sl):s>0&&(c<0?a=rl:c>0&&(a=ol)),e&&(e.$action=a)}break;case Xt:this.movable&&(this.dynamic||this.$actionStartTarget&&this.contains(this.$actionStartTarget))&&this.$move(s,c);break;case Yt:if(n&&this.zoomable&&(this.dynamic||this.contains(n.target))){const e=Fl(t);this.$zoom(l.scale,n.pageX-e.left,n.pageY-e.top)}break;default:this.$resize(a,s,c,u)}}$handleActionEnd(){this.$action="",this.$actionStartTarget=null}$handleKeyDown(e){if(this.hidden||!this.keyboard||this.multiple&&!this.active||e.defaultPrevented)return;const{activeElement:t}=document;if(!t||!["INPUT","TEXTAREA"].includes(t.tagName)&&!["true","plaintext-only"].includes(t.contentEditable))switch(e.key){case"Backspace":e.metaKey&&(e.preventDefault(),this.$removeSelection());break;case"Delete":e.preventDefault(),this.$removeSelection();break;case"ArrowLeft":e.preventDefault(),this.$move(-1,0);break;case"ArrowRight":e.preventDefault(),this.$move(1,0);break;case"ArrowUp":e.preventDefault(),this.$move(0,-1);break;case"ArrowDown":e.preventDefault(),this.$move(0,1);break;case"+":e.preventDefault(),this.$zoom(.1);break;case"-":e.preventDefault(),this.$zoom(-.1)}}$center(){const{parentElement:e}=this;if(!e)return this;const t=(e.offsetWidth-this.width)/2,l=(e.offsetHeight-this.height)/2;return this.$change(t,l)}$move(e,t=e){return this.$moveTo(this.x+e,this.y+t)}$moveTo(e,t=e){return this.movable?this.$change(e,t):this}$resize(e,t=0,l=0,n=this.aspectRatio){if(!this.resizable)return this;const a=Sl(n),{$canvas:r}=this;let{x:i,y:o,width:s,height:c}=this;switch(e){case tl:o+=l,c-=l,c<0&&(e=nl,c=-c,o-=c),a&&(i+=(t=l*n)/2,s-=t,s<0&&(s=-s,i-=s));break;case ll:s+=t,s<0&&(e=al,s=-s,i-=s),a&&(o-=(l=t/n)/2,c+=l,c<0&&(c=-c,o-=c));break;case nl:c+=l,c<0&&(e=tl,c=-c,o-=c),a&&(i-=(t=l*n)/2,s+=t,s<0&&(s=-s,i-=s));break;case al:i+=t,s-=t,s<0&&(e=ll,s=-s,i-=s),a&&(o+=(l=t/n)/2,c-=l,c<0&&(c=-c,o-=c));break;case rl:a&&(l=-t/n),o+=l,c-=l,s+=t,s<0&&c<0?(e=sl,s=-s,c=-c,i-=s,o-=c):s<0?(e=il,s=-s,i-=s):c<0&&(e=ol,c=-c,o-=c);break;case il:a&&(l=t/n),i+=t,o+=l,s-=t,c-=l,s<0&&c<0?(e=ol,s=-s,c=-c,i-=s,o-=c):s<0?(e=rl,s=-s,i-=s):c<0&&(e=sl,c=-c,o-=c);break;case ol:a&&(l=t/n),s+=t,c+=l,s<0&&c<0?(e=il,s=-s,c=-c,i-=s,o-=c):s<0?(e=sl,s=-s,i-=s):c<0&&(e=rl,c=-c,o-=c);break;case sl:a&&(l=-t/n),i+=t,s-=t,c+=l,s<0&&c<0?(e=rl,s=-s,c=-c,i-=s,o-=c):s<0?(e=ol,s=-s,i-=s):c<0&&(e=il,c=-c,o-=c)}return r&&r.$setAction(e),this.$change(i,o,s,c)}$zoom(e,t,l){if(!this.zoomable||0===e)return this;e<0?e=1/(1-e):e+=1;const{width:n,height:a}=this,r=n*e,i=a*e;let o=this.x,s=this.y;return Cl(t)&&Cl(l)?(o-=(r-n)*((t-this.x)/n),s-=(i-a)*((l-this.y)/a)):(o-=(r-n)/2,s-=(i-a)/2),this.$change(o,s,r,i)}$change(e,t,l=this.width,n=this.height,a=this.aspectRatio,r=!1){return this.$changing||!Cl(e)||!Cl(t)||!Cl(l)||!Cl(n)||l<0||n<0?this:(Sl(a)&&({width:l,height:n}=Wl({aspectRatio:a,width:l,height:n},"cover")),this.precise||(e=Math.round(e),t=Math.round(t),l=Math.round(l),n=Math.round(n)),e===this.x&&t===this.y&&l===this.width&&n===this.height&&Object.is(a,this.aspectRatio)&&!r?this:(this.hidden&&(this.hidden=!1),!1===this.$emit(xl,{x:e,y:t,width:l,height:n})?this:(this.$changing=!0,this.x=e,this.y=t,this.width=l,this.height=n,this.$changing=!1,this.$render())))}$reset(){const{x:e,y:t,width:l,height:n}=this.$initialSelection;return this.$change(e,t,l,n)}$clear(){return this.$change(0,0,0,0,NaN,!0),this.hidden=!0,this}$render(){return this.$setStyles({transform:`translate(${this.x}px, ${this.y}px)`,width:this.width,height:this.height})}$toCanvas(e){return new Promise((t,l)=>{if(!this.isConnected)return void l(new Error("The current element is not connected to the DOM."));const n=document.createElement("canvas");let{width:a,height:r}=this,i=1;if(El(e)&&(Sl(e.width)||Sl(e.height))&&(({width:a,height:r}=Wl({aspectRatio:a/r,width:e.width,height:e.height})),i=a/this.width),n.width=a,n.height=r,!this.$canvas)return void t(n);const o=this.$canvas.querySelector(this.$getTagNameOf(Vt));o?o.$ready().then(l=>{const s=n.getContext("2d");if(s){const[t,c,u,d,b,m]=o.$getTransform(),h=-this.x,p=-this.y,f=(h*d-u*p)/(t*d-u*c),g=(p*t-c*h)/(t*d-u*c);let v=t*f+u*g+b,y=c*f+d*g+m,x=l.naturalWidth,w=l.naturalHeight;1!==i&&(v*=i,y*=i,x*=i,w*=i);const k=x/2,C=w/2;s.fillStyle="transparent",s.fillRect(0,0,a,r),El(e)&&_l(e.beforeDraw)&&e.beforeDraw.call(this,s,n),s.save(),s.translate(k,C),s.transform(t,c,u,d,v,y),s.translate(-k,-C),s.drawImage(l,0,0,x,w),s.restore()}t(n)}).catch(l):t(n)})}}sn.$name=Ht,sn.$version="2.1.1";class cn extends Jl{constructor(){super(...arguments),this.$style=":host{display:flex;flex-direction:column;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}:host([bordered]){border:1px dashed var(--theme-color)}:host([covered]){bottom:0;left:0;position:absolute;right:0;top:0}:host>span{display:flex;flex:1}:host>span+span{border-top:1px dashed var(--theme-color)}:host>span>span{flex:1}:host>span>span+span{border-left:1px dashed var(--theme-color)}",this.bordered=!1,this.columns=3,this.covered=!1,this.rows=3,this.slottable=!1,this.themeColor="rgba(238, 238, 238, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["bordered","columns","covered","rows"])}$propertyChangedCallback(e,t,l){Object.is(l,t)||(super.$propertyChangedCallback(e,t,l),"rows"!==e&&"columns"!==e||this.$nextTick(()=>{this.$render()}))}connectedCallback(){super.connectedCallback(),this.$render()}$render(){const e=this.$getShadowRoot(),t=document.createDocumentFragment();for(let l=0;l<this.rows;l+=1){const e=document.createElement("span");e.setAttribute("role","row");for(let t=0;t<this.columns;t+=1){const t=document.createElement("span");t.setAttribute("role","gridcell"),e.appendChild(t)}t.appendChild(e)}e&&(e.innerHTML="",e.appendChild(t))}}cn.$name=qt,cn.$version="2.1.1";class un extends Jl{constructor(){super(...arguments),this.$style=':host{display:inline-block;height:1em;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;vertical-align:middle;width:1em}:host:after,:host:before{background-color:var(--theme-color);content:"";display:block;position:absolute}:host:before{height:1px;left:0;top:50%;transform:translateY(-50%);width:100%}:host:after{height:100%;left:50%;top:0;transform:translateX(-50%);width:1px}:host([centered]){left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}',this.centered=!1,this.slottable=!1,this.themeColor="rgba(238, 238, 238, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["centered"])}}un.$name=Bt,un.$version="2.1.1";const dn=new WeakMap,bn=new WeakMap,mn=new WeakMap,hn=new WeakMap,pn="vertical";class fn extends Jl{constructor(){super(...arguments),this.$onSelectionChange=null,this.$onSourceImageLoad=null,this.$onSourceImageTransform=null,this.$scale=1,this.$style=":host{display:block;height:100%;overflow:hidden;position:relative;width:100%}",this.resize=pn,this.selection="",this.slottable=!1}set $image(e){bn.set(this,e)}get $image(){return bn.get(this)}set $sourceImage(e){hn.set(this,e)}get $sourceImage(){return hn.get(this)}set $canvas(e){dn.set(this,e)}get $canvas(){return dn.get(this)}set $selection(e){mn.set(this,e)}get $selection(){return mn.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["resize","selection"])}connectedCallback(){var e,t;super.connectedCallback();let l=null;if(l=this.selection?null!==(t=null===(e=function(e){const t=e.getRootNode();switch(t.nodeType){case 1:return t.ownerDocument;case 9:case 11:return t}return null}(this))||void 0===e?void 0:e.querySelector(this.selection))&&void 0!==t?t:null:this.closest(this.$getTagNameOf(Ht)),$l(l)){this.$selection=l,this.$onSelectionChange=this.$handleSelectionChange.bind(this),Pl(l,xl,this.$onSelectionChange);const e=l.closest(this.$getTagNameOf(Ut));if(e){this.$canvas=e;const t=e.querySelector(this.$getTagNameOf(Vt));t&&(this.$sourceImage=t,this.$image=t.cloneNode(!0),this.$getShadowRoot().appendChild(this.$image),this.$onSourceImageLoad=this.$handleSourceImageLoad.bind(this),this.$onSourceImageTransform=this.$handleSourceImageTransform.bind(this),Pl(t.$image,hl,this.$onSourceImageLoad),Pl(t,wl,this.$onSourceImageTransform))}this.$render()}}disconnectedCallback(){const{$selection:e,$sourceImage:t}=this;e&&this.$onSelectionChange&&(Il(e,xl,this.$onSelectionChange),this.$onSelectionChange=null),t&&this.$onSourceImageLoad&&(Il(t.$image,hl,this.$onSourceImageLoad),this.$onSourceImageLoad=null),t&&this.$onSourceImageTransform&&(Il(t,wl,this.$onSourceImageTransform),this.$onSourceImageTransform=null),super.disconnectedCallback()}$handleSelectionChange(e){this.$render(e.defaultPrevented?this.$selection:e.detail)}$handleSourceImageLoad(){const{$image:e,$sourceImage:t}=this,l=e.getAttribute("src"),n=t.getAttribute("src");n&&n!==l&&(e.setAttribute("src",n),e.$ready(()=>{this.$render()}))}$handleSourceImageTransform(e){this.$render(void 0,e.detail.matrix)}$render(e,t){const{$canvas:l,$selection:n}=this;e||n.hidden||(e=n),(!e||0===e.x&&0===e.y&&0===e.width&&0===e.height)&&(e={x:0,y:0,width:l.offsetWidth,height:l.offsetHeight});const{x:a,y:r,width:i,height:o}=e,s={},{clientWidth:c,clientHeight:u}=this;let d=c,b=u,m=NaN;switch(this.resize){case"both":m=1,d=i,b=o,s.width=i,s.height=o;break;case"horizontal":m=o>0?u/o:0,d=i*m,s.width=d;break;case pn:m=i>0?c/i:0,b=o*m,s.height=b;break;default:c>0?m=i>0?c/i:0:u>0&&(m=o>0?u/o:0)}this.$scale=m,this.$setStyles(s),this.$sourceImage&&setTimeout(()=>{this.$transformImageByOffset(null!=t?t:this.$sourceImage.$getTransform(),-a,-r)})}$transformImageByOffset(e,t,l){const{$image:n,$scale:a,$sourceImage:r}=this;if(r&&n&&a>=0){const[i,o,s,c,u,d]=e,b=(t*c-s*l)/(i*c-s*o),m=(l*i-o*t)/(i*c-s*o),h=i*b+s*m+u,p=o*b+c*m+d;r.$ready(e=>{this.$setStyles.call(n,{width:e.naturalWidth*a,height:e.naturalHeight*a})}),n.$setTransform(i,o,s,c,h*a,p*a)}}}function gn(){const[t,l]=e.useState(!1),[n,a]=e.useState(null),[r,i]=e.useState(null),o=async(e,t)=>{if(!e||!t)return a("ID de asset y configuración de variante son requeridos"),null;l(!0),a(null),i(null);try{const l=await async function(e,{variant_name:t,width:l,height:a,crop_params:r,preset_aspect:i=null,preset_size:o=null,output_format:s="webp"}){try{const n=[{name:t,width:l,height:a,output_format:s,crop_params:r}];return i&&(n[0].preset_aspect=i),o&&(n[0].preset_size=o),X(await W({endpoint:`/assets/${e}/variants`,method:"POST",body:{variants:n,async:!1},basePath:J,useJWT:!0}))}catch(n){throw Y(n)}}(e,{variant_name:t.name,width:t.width,height:t.height,crop_params:t.crop_params,preset_aspect:t.preset_aspect,preset_size:t.preset_size,output_format:t.output_format});if(l?.result)return i(l.result),l.result;throw new Error("No se pudo crear la variante")}catch(r){return console.error("Error creating variant:",r),a(r.message||"Error desconocido al crear variante"),null}finally{l(!1)}};return{createVariant:o,createCropVariant:async(e,t,l={})=>{const n={name:l.name||`crop_${Date.now()}`,width:l.width||800,height:l.height||600,output_format:l.format||"webp",crop_params:{x:t.x||0,y:t.y||0,width:t.width||1,height:t.height||1}};return await o(e,n)},createVariantFromBlob:async(e,t,r={})=>{if(!e||!t)return a("ID de asset y blob son requeridos"),null;l(!0),a(null),i(null);try{const l=await async function(e,t,l={}){try{const n=new FormData,a=l.format||"webp",r=`${l.name||"variant"}.${a}`;return n.append("file",t,r),n.append("variant_name",l.name||"variant"),n.append("width",String(l.width||0)),n.append("height",String(l.height||0)),n.append("output_format",l.format||"webp"),n.append("permanent_url",!1!==l.permanentUrl?"true":"false"),X(await W({endpoint:`/assets/${e}/variants/upload`,method:"POST",body:n,basePath:J,isFormData:!0,useJWT:!0}))}catch(n){throw Y(n)}}(e,t,{name:r.name||`crop_${Date.now()}`,width:r.width||0,height:r.height||0,format:r.format||"webp"});if(l?.result)return i(l.result),l.result;throw new Error("No se pudo crear la variante")}catch(o){return console.error("Error creating variant from blob:",o),a(o.message||"Error desconocido al crear variante"),null}finally{l(!1)}},loading:t,error:n,createdVariant:r,reset:()=>{a(null),i(null)}}}fn.$name=Gt,fn.$version="2.1.1",Zl.$define(),un.$define(),cn.$define(),rn.$define(),ln.$define(),sn.$define(),an.$define(),fn.$define();class vn{constructor(e,t,l){this.canvasRef=e,this.imageRef=t,this.selectionRef=l}get canvasElement(){return this.canvasRef?.current}get image(){return this.imageRef?.current}get selectionElement(){return this.selectionRef?.current}get isReady(){return!!(this.canvasElement&&this.image&&this.selectionElement)}transform={move:(e,t)=>{if(!this.image)return!1;try{return this.image.$move(e,t),!0}catch(l){return console.warn("Error moving image:",l),!1}},moveTo:(e,t)=>{if(!this.image)return!1;try{return this.image.$moveTo(e,t),!0}catch(l){return console.warn("Error moving image to position:",l),!1}},zoom:e=>{if(!this.image)return!1;try{return this.image.$zoom(e),!0}catch(t){return console.warn("Error zooming image:",t),!1}},rotate:e=>{if(!this.image)return!1;try{const t=e*Math.PI/180;return this.image.$rotate(t),!0}catch(t){return console.warn("Error rotating image:",t),!1}},scale:(e,t=e)=>{if(!this.image)return!1;try{return this.image.$scale(e,t),!0}catch(l){return console.warn("Error scaling image:",l),!1}},center:(e="contain")=>{if(!this.image)return!1;try{return this.image.$center(e),!0}catch(t){return console.warn("Error centering image:",t),!1}},reset:()=>{if(!this.image)return!1;try{return this.image.$resetTransform(),!0}catch(e){return console.warn("Error resetting transform:",e),!1}},getTransform:()=>{if(!this.image)return null;try{return this.image.$getTransform()}catch(e){return console.warn("Error getting transform:",e),null}},setTransform:(e,t,l,n,a,r)=>{if(!this.image)return!1;try{return this.image.$setTransform(e,t,l,n,a,r),!0}catch(i){return console.warn("Error setting transform:",i),!1}},resetZoom:()=>{if(!this.image)return!1;try{const e=this.image.$getTransform();if(!e)return!1;const[t,l,n,a,r,i]=e,o=Math.sqrt(t*t+l*l),s=Math.sqrt(n*n+a*a),c=t/o,u=l/o,d=n/s,b=a/s;return this.image.$setTransform(c,u,d,b,r,i),!0}catch(e){return console.warn("Error resetting zoom:",e),!1}},setZoom:e=>{if(!this.image||e<=0)return!1;try{const t=this.image.$getTransform();if(!t)return!1;const[l,n,a,r,i,o]=t,s=Math.sqrt(l*l+n*n),c=Math.sqrt(a*a+r*r),u=l/s*e,d=n/s*e,b=a/c*e,m=r/c*e;return this.image.$setTransform(u,d,b,m,i,o),!0}catch(t){return console.warn("Error setting zoom level:",t),!1}},getZoom:()=>{if(!this.image)return 1;try{const e=this.image.$getTransform();if(!e)return 1;const[t,l]=e;return Math.sqrt(t*t+l*l)}catch(e){return console.warn("Error getting zoom level:",e),1}},fitToCanvas:(e=.1)=>{if(!this.image||!this.canvasElement)return!1;try{const t=this.canvasElement.getBoundingClientRect();let l=this.image.querySelector("img")||this.image;if(!l?.naturalWidth||!l?.naturalHeight)return!1;const n=1-e,a=t.width*n/l.naturalWidth,r=t.height*n/l.naturalHeight,i=Math.min(a,r,1);return this.transform.setZoom(i)}catch(t){return console.warn("Error fitting to canvas:",t),!1}}};selection={center:()=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$center(),!0}catch(e){return console.warn("Error centering selection:",e),!1}},reset:()=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$reset(),!0}catch(e){return console.warn("Error resetting selection:",e),!1}},setCoverage:e=>{if(!this.selectionElement||e<0||e>1)return!1;try{return this.selectionElement.initialCoverage=e,this.selectionElement.$reset(),!0}catch(t){return console.warn("Error setting coverage:",t),!1}},setAspectRatio:e=>{if(!this.selectionElement)return!1;try{let t;if(""===e||null==e)t=NaN;else if("number"==typeof e)t=e;else{if("string"!=typeof e)return console.warn("Unsupported aspect ratio type:",typeof e,e),!1;if(e.includes("/")){const[l,n]=e.split("/").map(e=>parseFloat(e.trim()));if(isNaN(l)||isNaN(n)||0===n)return console.warn("Invalid aspect ratio format:",e),!1;t=l/n}else if(t=parseFloat(e),isNaN(t))return console.warn("Invalid aspect ratio format:",e),!1}return this.selectionElement.aspectRatio=t,this.selectionElement.$render(),!0}catch(t){return console.warn("Error setting aspect ratio:",t),!1}},move:(e,t)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$move(e,t),!0}catch(l){return console.warn("Error moving selection:",l),!1}},zoom:e=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$zoom(e),!0}catch(t){return console.warn("Error zooming selection:",t),!1}},change:(e,t,l,n,a)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$change(e,t,l,n,a),!0}catch(r){return console.warn("Error changing selection:",r),!1}},set:(e,t,l,n)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.x=e,this.selectionElement.y=t,this.selectionElement.width=l,this.selectionElement.height=n,this.selectionElement.$render(),!0}catch(a){return console.warn("Error setting selection:",a),!1}},toCanvas:async(e={})=>{if(!this.selectionElement)return null;try{const t={width:800,height:600,imageSmoothingEnabled:!0,imageSmoothingQuality:"high",...e};return await this.selectionElement.$toCanvas(t)}catch(t){return console.warn("Error exporting to canvas:",t),null}},getData:()=>{if(!this.selectionElement)return null;try{return{x:this.selectionElement.x,y:this.selectionElement.y,width:this.selectionElement.width,height:this.selectionElement.height,aspectRatio:this.selectionElement.aspectRatio}}catch(e){return console.warn("Error getting selection data:",e),null}}};canvas={setBackground:e=>{if(!this.canvasElement)return!1;try{return this.canvasElement.background=e,!0}catch(t){return console.warn("Error setting background:",t),!1}},setScaleStep:e=>{if(!this.canvasElement)return!1;try{return this.canvasElement.scaleStep=e,!0}catch(t){return console.warn("Error setting scale step:",t),!1}},setDisabled:e=>{if(!this.canvasElement)return!1;try{return this.canvasElement.disabled=e,!0}catch(t){return console.warn("Error setting disabled state:",t),!1}}};utils={flipHorizontal:()=>{const e=this.transform.getTransform();if(!e)return!1;const[t,l,n,a,r,i]=e;return this.transform.setTransform(-t,l,n,a,r,i)},flipVertical:()=>{const e=this.transform.getTransform();if(!e)return!1;const[t,l,n,a,r,i]=e;return this.transform.setTransform(t,l,n,-a,r,i)},setupInitialView:async(e={})=>{const{paspartuFactor:t=.85,retries:l=3,retryDelay:n=200}=e;return new Promise(e=>{const a=(r=0)=>{if(!this.isReady)return r<l?void setTimeout(()=>a(r+1),n):void e(!1);try{const i=this.canvasElement.getBoundingClientRect();let o=this.image.querySelector("img")||this.image;if(!o?.naturalWidth||!o?.naturalHeight)return r<l?void setTimeout(()=>a(r+1),n):(this.transform.center(),void e(!1));if(i.width>0&&i.height>0){const l=i.width*t/o.naturalWidth,n=i.height*t/o.naturalHeight,a=Math.min(l,n,1);this.transform.setTransform(a,0,0,a,0,0)?setTimeout(()=>{this.transform.center(),this.selection.center(),e(!0)},100):(this.transform.reset(),setTimeout(()=>{a<1&&this.transform.scale(a),setTimeout(()=>{this.transform.center(),this.selection.center(),e(!0)},100)},100))}else this.transform.center(),e(!1)}catch(i){console.warn("Error in setup:",i),this.transform.center(),e(!1)}};a()})},resetAll:()=>{const e={transform:this.transform.reset(),selection:this.selection.reset(),center:!1};return setTimeout(()=>{e.center=this.transform.center()&&this.selection.center()},100),e},checkExportability:async()=>{try{return!!(await this.selection.toCanvas({width:1,height:1}))}catch{return!1}},resetZoomOnly:()=>this.transform.resetZoom(),getZoomInfo:()=>{const e=this.transform.getZoom();return{current:e,isZoomedIn:e>1,isZoomedOut:e<1,percentage:Math.round(100*e)}},setBackground:e=>this.canvas.setBackground(e)};setupEventListeners(e={}){const{onSelectionChange:t,onImageTransform:l,onAction:n,onActionStart:a,onActionMove:r,onActionEnd:i}=e,o=[];if(t&&this.selectionElement){const e=e=>{t({x:e.detail.x,y:e.detail.y,width:e.detail.width,height:e.detail.height})};this.selectionElement.addEventListener("change",e),o.push(()=>{this.selectionElement&&this.selectionElement.removeEventListener("change",e)})}if(l&&this.image){const e=e=>{l({matrix:e.detail.matrix,oldMatrix:e.detail.oldMatrix})};this.image.addEventListener("transform",e),o.push(()=>{this.image&&this.image.removeEventListener("transform",e)})}if(this.canvasElement){if(n){const e=e=>n(e.detail);this.canvasElement.addEventListener("action",e),o.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("action",e)})}if(a){const e=e=>a(e.detail);this.canvasElement.addEventListener("actionstart",e),o.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("actionstart",e)})}if(r){const e=e=>r(e.detail);this.canvasElement.addEventListener("actionmove",e),o.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("actionmove",e)})}if(i){const e=e=>i(e.detail);this.canvasElement.addEventListener("actionend",e),o.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("actionend",e)})}}return()=>{o.forEach(e=>e())}}}async function yn(e,t,l={}){const{format:n=null,originalFormat:a="webp",onSuccess:r=null,onError:i=null,accessibilityManager:o=null}=l;try{const l=window.limboCore?.config?.getGlobal(),i=n||l?.downloadFormat||a||"webp",c=`${t.split(".")[0]}.${i}`;if(o&&o.announce(`Descargando ${c}`),e.startsWith("data:image/"))return function(e,t){const l=document.createElement("a");l.href=e,l.download=t,l.style.display="none",document.body.appendChild(l),l.click(),setTimeout(()=>{document.body.removeChild(l)},100)}(e,c),r&&r(c),o&&o.announce(`${c} descargado correctamente`),!0;let u;try{if(u=await fetch(e,{mode:"cors"}),!u.ok)throw new Error(`HTTP error! status: ${u.status}`)}catch(s){if(!e.startsWith("http"))throw s;{const t=(window.limboCore?.config?.getGlobal()||{}).prod?"https://limbo.lefebvre.es":"https://led-dev-limbo-dev.eu.els.local",l=window.limboCore?.apiClient?.token||"",n=`${t}/api/atenea/proxy?url=${encodeURIComponent(e)}`;if(u=await fetch(n,{credentials:"include",headers:{Authorization:`Bearer ${l}`}}),!u.ok)throw new Error(`Proxy error: ${u.status}`)}}const d=await u.blob();let b=d;const m=d.type;m!==`image/${"jpg"===i?"jpeg":i}`&&function(e){return["webp","jpeg","jpg","svg","png"].includes(e.toLowerCase())}(i)&&(b=await async function(e,t){return new Promise(l=>{const n=new Image,a=URL.createObjectURL(e);n.onload=()=>{try{const r=document.createElement("canvas");r.width=n.width,r.height=n.height;r.getContext("2d").drawImage(n,0,0);const i=`image/${"jpg"===t?"jpeg":t}`,o="png"===t?void 0:.92;r.toBlob(t=>{URL.revokeObjectURL(a),l(t||e)},i,o)}catch(r){URL.revokeObjectURL(a),l(e)}},n.onerror=()=>{URL.revokeObjectURL(a),l(e)},n.src=a})}(d,i));const h=window.URL.createObjectURL(b),p=document.createElement("a");return p.href=h,p.download=c,p.style.display="none",document.body.appendChild(p),p.click(),setTimeout(()=>{window.URL.revokeObjectURL(h),document.body.removeChild(p)},100),r&&r(c),o&&o.announce(`${c} descargado correctamente`),!0}catch(c){return console.error("Error downloading image:",c),i&&i(c),o&&o.announce(`Error al descargar la imagen: ${c.message}`),!1}}const xn=Object.freeze(Object.defineProperty({__proto__:null,default:yn,downloadImage:yn},Symbol.toStringTag,{value:"Module"})),wn={DEV:"https://led-dev-limbo-dev.eu.els.local",PROD:"https://limbo.lefebvre.es"};function kn(e,t=!1){if(!e)return"";if(e.startsWith("/files/")){return(t?wn.PROD:wn.DEV)+e}return e}function Cn(e){return"string"!=typeof e?e:e.replace(/&quot;/g,'"').replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&#39;/g,"'").replace(/&#x27;/g,"'")}function Sn(e){return!(!e||"string"!=typeof e)&&!e.startsWith("blob:")}function jn(e,t={}){if(!e)return"";const{prefer:l="crop",isProd:n=!1}=t,a=Cn(e);try{const e=JSON.parse(a),t=()=>{if(e.images&&Array.isArray(e.images))for(const t of e.images)if(t&&Sn(t.url))return t.url;return null},r=e.original?.url,i=t();if("crop"===l){if(i)return kn(i,n);if(Sn(r))return kn(r,n)}else{if(Sn(r))return kn(r,n);if(i)return kn(i,n)}return Sn(e.url)?kn(e.url,n):""}catch{if("string"==typeof a){if(a.startsWith("blob:"))return"";if(a.startsWith("/files/"))return kn(a,n);if(a.startsWith("http")||a.startsWith("/"))return a}}return"string"==typeof e&&(e.startsWith("{")||e.startsWith("["))?"":e}function Nn(e){if(!e||"string"!=typeof e)return"file";let t=e.normalize("NFD").replace(/[\u0300-\u036f]/g,"");return t=t.toLowerCase(),t=t.replace(/[^a-z0-9_]+/g,"-"),t=t.replace(/-+/g,"-").replace(/^-|-$/g,""),t||"file"}function En({image:t,onSave:n,onCancel:a,onDelete:r=null,onError:i=null,deleting:o=!1,onVariantCreated:s=null,onUpload:c=null,uploading:u=!1,cropperConfig:d=null}){const[b,m]=e.useState(!1),[h,p]=e.useState(null),[f,g]=e.useState(!1),[v,y]=e.useState(!0),[x,w]=e.useState(!0),[k,C]=e.useState(t.url||t.path||null);e.useEffect(()=>{const e=t.url||t.path;if(!e||e.startsWith("blob:")||e.startsWith("data:"))return void C(e);let l=!1;return xe(e,{bypassHttpCache:!0}).then(e=>{l||C(e)}).catch(()=>{l||C(e)}),()=>{l=!0}},[t.url,t.path]);const[S,j]=e.useState({x:20,y:100}),[N,E]=e.useState(!1),[_,$]=e.useState({x:0,y:0}),[T,A]=e.useState(!1),[z,L]=e.useState(!0),[M,I]=e.useState(!1),[P,D]=e.useState({horizontal:!1,vertical:!1}),[R,O]=e.useState(!1),[F,U]=e.useState(!1),[B,q]=e.useState(!1),[W,V]=e.useState(!1),[H]=e.useState(()=>{if(!t||!t.filename)return"image";const[e]=t.filename.split(".");return e}),K=e.useMemo(()=>{if(d)return{mandatoryCrops:d.mandatoryCrops||[],allowCustomCrops:!1!==d.allowAdditionalCrops,showDimensionInputs:!0===d.showDimensionInputs,maxCrops:d.maxCrops||null,localCropsOnly:!0===d.localCropsOnly,existingCrops:d.existingCrops||null};const e=window.limboCore?.config?.getGlobal()||{};return{mandatoryCrops:e.cropper?.mandatoryCrops||[],allowCustomCrops:!1!==e.cropper?.allowCustomCrops,showDimensionInputs:!0===e.cropper?.showDimensionInputs,maxCrops:e.cropper?.maxCrops||null,localCropsOnly:!0===e.cropper?.localCropsOnly,existingCrops:e.cropper?.existingCrops||null}},[d]),[G,Q]=e.useState(()=>K.mandatoryCrops.length>0?K.mandatoryCrops.map((e,t)=>({id:`crop-${t}`,label:e.label,width:e.width,height:e.height,required:!1!==e.required,isCustom:!1,confirmed:!1,lockDimensions:!(!e.width||!e.height),format:e.format||null,savedState:null})):[{id:"crop-default-0",label:H,width:t.width||1920,height:t.height||1080,required:!1,isCustom:!0,confirmed:!1,savedState:null}]),[X,Y]=e.useState(0),J=G[X],Z=e.useMemo(()=>J&&J.width&&J.height?J.width/J.height:"",[J]),ee=e.useMemo(()=>{const e=50;if(!Z||""===Z)return{minWidth:e,minHeight:e};if(Z>=1){return{minWidth:e,minHeight:e/Z}}return{minWidth:e*Z,minHeight:e}},[Z]),[te,le]=e.useState(!1),[ne,ae]=e.useState([]),[re,ie]=e.useState(null),oe=window.limboCore?.accessibilityManager,{createVariantFromBlob:se,loading:ce,error:ue}=gn(),de=((t,l={})=>{const n=e.useRef(null),a=e.useRef(null),r=e.useRef(null),i=e.useRef(null),[o,s]=e.useState(null),[c,u]=e.useState(null),[d,b]=e.useState(!1),[m,h]=e.useState(!0),[p,f]=e.useState(0),g={aspectRatio:"",shade:!0,paspartuFactor:.85,...l};e.useEffect(()=>{n.current&&a.current&&r.current&&(i.current=new vn(n,a,r),b(!0))},[]),e.useEffect(()=>{if(i.current)return i.current.setupEventListeners({onSelectionChange:e=>{s(e)},onImageTransform:()=>{f(e=>e+1)}})},[d]),e.useEffect(()=>{i.current&&t&&(async()=>{i.current.selection.setAspectRatio(g.aspectRatio),i.current.canvas.setBackground(g.shade),await i.current.utils.setupInitialView({paspartuFactor:g.paspartuFactor});const e=await i.current.utils.checkExportability();h(e);const t=a.current?.querySelector("img")||a.current;t?.naturalWidth&&t?.naturalHeight&&u({naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,currentWidth:t.width,currentHeight:t.height})})()},[t]),e.useEffect(()=>{i.current&&d&&i.current.selection.setAspectRatio(g.aspectRatio)},[g.aspectRatio,d]),e.useEffect(()=>{i.current&&d&&i.current.canvas.setBackground(g.shade)},[g.shade,d]);const v=e.useMemo(()=>({move:(e,t)=>i.current?.transform.move(e,t)||!1,zoom:e=>i.current?.transform.zoom(e)||!1,rotate:e=>i.current?.transform.rotate(e)||!1,center:()=>i.current?.transform.center()||!1,reset:()=>i.current?.transform.reset()||!1,resetZoom:()=>i.current?.transform.resetZoom()||!1,setZoom:e=>i.current?.transform.setZoom(e)||!1,getZoom:()=>i.current?.transform.getZoom()||1,fitToCanvas:e=>i.current?.transform.fitToCanvas(e)||!1,flipHorizontal:()=>i.current?.utils.flipHorizontal()||!1,flipVertical:()=>i.current?.utils.flipVertical()||!1}),[]),y=e.useMemo(()=>({center:()=>i.current?.selection.center()||!1,reset:()=>i.current?.selection.reset()||!1,setCoverage:e=>i.current?.selection.setCoverage(e)||!1,setAspectRatio:e=>i.current?.selection.setAspectRatio(e)||!1,toCanvas:e=>i.current?.selection.toCanvas(e)||Promise.resolve(null)}),[]),x=e.useMemo(()=>({resetAll:()=>{if(i.current){const e=i.current.utils.resetAll();return s(null),e}return!1},setBackground:e=>i.current?.canvas.setBackground(e)||!1,resetZoomOnly:()=>i.current?.utils.resetZoomOnly()||!1,getZoomInfo:()=>i.current?.utils.getZoomInfo()||{current:1,percentage:100,isZoomedIn:!1,isZoomedOut:!1}}),[]);return{refs:{canvasRef:n,imageRef:a,selectionRef:r},state:{cropData:o,imageInfo:c,isReady:d,canExport:m,transformVersion:p},transform:v,selection:y,utils:x,manager:i.current}})(t,{aspectRatio:Z||null,showGrid:v,shade:x,initialCoverage:.5,paspartuFactor:.85}),{refs:be,state:me,transform:he,selection:pe,utils:ge}=de,{canvasRef:ve,imageRef:ye,selectionRef:we}=be,{cropData:ke,imageInfo:Ce,canExport:Se,transformVersion:je}=me,Ne=e.useMemo(()=>Ce||{naturalWidth:t.width||1920,naturalHeight:t.height||1080,currentWidth:t.width||1920,currentHeight:t.height||1080},[Ce,t.width,t.height]),Ee=e.useCallback(()=>y(e=>!e),[]),_e=e.useCallback(()=>w(e=>!e),[]),$e=e.useCallback(()=>U(e=>!e),[]),Te=e.useCallback(()=>q(e=>!e),[]),Ae=e.useCallback(()=>V(e=>!e),[]),ze=e.useCallback(()=>he.center(),[he]),Le=e.useCallback(()=>pe.center(),[pe]),Me=e.useCallback(()=>pe.reset(),[pe]),Ie=e.useCallback((e,t)=>he.move(e,t),[he]),Pe=e.useCallback(e=>he.zoom(e),[he]),De=e.useCallback(e=>he.rotate(e),[he]),Oe=e.useCallback(e=>{pe.setCoverage(e)},[pe]),Fe=e.useCallback(()=>{D(e=>{const t=!e.horizontal;return he.flipHorizontal(),{...e,horizontal:t}})},[he]),Ue=e.useCallback(()=>{D(e=>{const t=!e.vertical;return he.flipVertical(),{...e,vertical:t}})},[he]),Be=e.useCallback(()=>{if(!de.manager||!me.isReady)return null;try{const e=ke?{...ke}:null;let t=null;if(we.current){const e=we.current;t={x:e.x??0,y:e.y??0,width:e.width??0,height:e.height??0}}let l=null;if(ye.current){const e=ye.current.$getTransform?.();e&&Array.isArray(e)&&(l=[...e])}const n={cropData:e,selectorState:t,imageTransform:l,flipState:{horizontal:P.horizontal,vertical:P.vertical}};return Q(e=>e.map((e,t)=>t===X?{...e,savedState:n}:e)),n}catch(e){return console.warn("Error saving crop state:",e),null}},[de.manager,me.isReady,ke,P,X,ye,we]),qe=e.useCallback(e=>{const t=G[e];if(t&&t.savedState)if(de.manager&&me.isReady)try{const{savedState:e}=t;if(e.imageTransform&&ye.current&&Array.isArray(e.imageTransform)&&setTimeout(()=>{if(ye.current&&ye.current.$setTransform){const[t,l,n,a,r,i]=e.imageTransform;ye.current.$setTransform(t,l,n,a,r,i)}},100),e.selectorState&&we.current){const{x:t,y:l,width:n,height:a}=e.selectorState;setTimeout(()=>{we.current&&(we.current.x=t,we.current.y=l,we.current.width=n,we.current.height=a,we.current.$render&&we.current.$render())},150)}e.flipState&&D({horizontal:e.flipState.horizontal??!1,vertical:e.flipState.vertical??!1})}catch(l){console.error("Error restoring crop state:",l),setTimeout(()=>{ze(),setTimeout(()=>Le(),100)},100)}else console.warn("Cropper not ready for state restoration");else setTimeout(()=>{ze(),setTimeout(()=>Le(),100)},100)},[G,de.manager,me.isReady,ze,Le,we,ye]),We=e.useCallback(()=>{for(let e=0;e<G.length;e++){const t=G[e];if(!t.label||""===t.label.trim())return e}return-1},[G]),Ve=e.useCallback(async e=>{e!==X&&(I(!0),Be(),await new Promise(e=>setTimeout(e,100)),Y(e),await new Promise(e=>setTimeout(e,250)),qe(e),await new Promise(e=>setTimeout(e,200)),I(!1))},[X,Be,qe]),He=e.useCallback(()=>{if(!K.allowCustomCrops)return void alert("No se pueden añadir recortes personalizados en este modo.");const e={id:`crop-custom-${Date.now()}`,label:`Recorte ${G.length+1}`,width:t.width||1920,height:t.height||1080,required:!1,isCustom:!0,confirmed:!1,savedState:null};Q(t=>[...t,e]),oe?.announce(`Nuevo recorte personalizado añadido: ${e.label}. Selecciónalo para editarlo.`)},[K.allowCustomCrops,G.length,t.width,t.height,oe]),Ke=e.useCallback((e,t)=>{const l=parseInt(t,10);""===t||isNaN(l)||Q(t=>t.map((t,n)=>n===X?{...t,[e]:l}:t))},[X]),Ge=e.useCallback(e=>{const t=J[e];let l=100;if(ve.current&&Ce){const e=ve.current.getBoundingClientRect(),t=Math.min(e.width,e.height);l=Math.max(100,Math.round(.05*t))}const n=Math.max(l,Math.min(3500,t));n!==t&&Q(t=>t.map((t,l)=>l===X?{...t,[e]:n}:t));const a={...J,[e]:n},r=a.width/a.height,i=pe.getData?.();pe.setAspectRatio(r),i&&void 0!==i.x&&setTimeout(()=>{pe.set?.(i.x,i.y,i.width,i.height)},50)},[X,J,pe,ve,Ce]),Qe=e.useCallback(e=>{Q(t=>t.map((t,l)=>l===X?{...t,label:e}:t))},[X]),Xe=e.useCallback((e,t=null)=>{t=t||G[e].label;if(!window.confirm(`¿Estás seguro de que deseas eliminar "${t||"este recorte"}"? Esta acción también eliminará todos sus recortes.`))return;const l=G[e];if(l.required)alert("No se puede eliminar un recorte obligatorio.");else if(1!==G.length){if(Q(t=>t.filter((t,l)=>l!==e)),e===X){const t=Math.max(0,e-1);Y(t)}else e<X&&Y(e=>e-1);oe?.announce(`Recorte ${l.label} eliminado`)}else alert("Debe haber al menos un recorte.")},[G,X,oe]),Ye=e.useCallback(async()=>{if(!Se)return null;try{const e=await pe.toCanvas({width:800,height:600,imageSmoothingEnabled:!0,imageSmoothingQuality:"high"});return e?e.toDataURL(`image/${globalThis.downloadFormat||t.mime_type.split("/")[1]||"webp"}`,.9):null}catch(e){return console.warn("Error generating preview:",e),null}},[Se,t.mime_type,pe]),Je=e.useCallback(async()=>{if(b)return m(!1),p(null),void g(!1);if(Se){m(!0),g(!0);try{const e=await Ye();e?p(e):(m(!1),alert("No se puede exportar el recorte por restricciones de CORS en la imagen original."))}finally{g(!1)}}else alert("No se puede exportar el recorte por restricciones de CORS en la imagen original.")},[Se,Ye,b]),Ze=e.useCallback(e=>{e.target.closest(".limbo-preview-modal-header")&&(E(!0),$({x:e.clientX-S.x,y:e.clientY-S.y}))},[S]),et=e.useCallback(e=>{N&&(e.preventDefault(),j({x:e.clientX-_.x,y:e.clientY-_.y}))},[N,_]),tt=e.useCallback(()=>{E(!1)},[]),lt=e.useCallback(e=>{if(!e.target.closest(".limbo-preview-modal-header"))return;const t=e.touches[0];E(!0),$({x:t.clientX-S.x,y:t.clientY-S.y})},[S]),nt=e.useCallback(e=>{if(!N)return;e.preventDefault();const t=e.touches[0];j({x:t.clientX-_.x,y:t.clientY-_.y})},[N,_]),at=e.useCallback(()=>{E(!1)},[]);e.useEffect(()=>{if(N)return document.addEventListener("mousemove",et),document.addEventListener("mouseup",tt),document.addEventListener("touchmove",nt,{passive:!1}),document.addEventListener("touchend",at),()=>{document.removeEventListener("mousemove",et),document.removeEventListener("mouseup",tt),document.removeEventListener("touchmove",nt),document.removeEventListener("touchend",at)}},[N,et,tt,nt,at]),e.useEffect(()=>{if(!T)return;const e=e=>{"Escape"===e.key&&A(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[T]);const rt=e.useCallback(async(e,l=null)=>{const n=G[e];if(!n)throw new Error(`Crop ${e} no encontrado`);if(!n.savedState&&e!==X)throw new Error(`El recorte "${n.label}" aún no ha sido configurado`);const a={imageTransform:ye.current?.$getTransform?.(),selectorState:we.current?{x:we.current.x,y:we.current.y,width:we.current.width,height:we.current.height}:null};try{if(e!==X&&n.savedState){if(n.savedState.imageTransform&&ye.current?.$setTransform){const[e,t,l,a,r,i]=n.savedState.imageTransform;ye.current.$setTransform(e,t,l,a,r,i)}if(n.savedState.selectorState&&we.current?.$change){const{x:e,y:t,width:l,height:a}=n.savedState.selectorState;we.current.$change(e,t,l,a,NaN,!0)}await new Promise(e=>setTimeout(e,100))}const a=Math.min(n.width,3500),i=Math.min(n.height,3500);let o=await pe.toCanvas({width:a,height:i,imageSmoothingEnabled:!0,imageSmoothingQuality:"high"});if(!o)throw new Error(`No se pudo generar el canvas para "${n.label}"`);if(o.width!==a||o.height!==i){const e=document.createElement("canvas");e.width=a,e.height=i;const t=e.getContext("2d");t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high",t.drawImage(o,0,0,a,i),o=e}const u=n.format||globalThis.downloadFormat||"webp",d="webp"===u?"image/webp":"png"===u?"image/png":"image/jpeg",b=.9,m=await new Promise((e,t)=>{o.toBlob(l=>{l?e(l):t(new Error("No se pudo convertir el canvas a blob"))},d,b)}),h=`${Nn(n.label||"crop")}_${a}_${i}`,p=l||t.id,f=!p||"string"==typeof p&&p.startsWith("external"),g=(f||K.localCropsOnly)&&!c;if(f&&c&&!K.localCropsOnly)try{const e=new File([m],`${h}.${u}`,{type:d}),t=await c(e);if(t&&(t.id||t.url)){const e=n.savedState||{selectorState:we.current?{x:we.current.x,y:we.current.y,width:we.current.width,height:we.current.height}:null,imageTransform:ye.current?.$getTransform?.()||null,flipState:{horizontal:P.horizontal,vertical:P.vertical}},l={id:t.id||`uploaded-${Date.now()}`,name:h,filename:`${h}.${u}`,url:t.urlSigned||t.url,urlSigned:t.urlSigned||t.url,width:a,height:i,format:u,size:m.size,mime_type:d,isLocal:!1,originalAssetId:null,uploadedAssetId:t.id,cropState:e};return oe?.announceSuccess(`Recorte guardado: ${h}`),l}}catch(r){console.error("[CropperView] ❌ Error subiendo crop, fallback a local:",r)}if(g){const e=URL.createObjectURL(m),t=n.savedState||{selectorState:we.current?{x:we.current.x,y:we.current.y,width:we.current.width,height:we.current.height}:null,imageTransform:ye.current?.$getTransform?.()||null,flipState:{horizontal:P.horizontal,vertical:P.vertical}},l={id:`local-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:h,filename:`${h}.${u}`,url:e,urlSigned:e,width:a,height:i,format:u,size:m.size,mime_type:d,blob:m,isLocal:!0,originalAssetId:p||null,cropState:t};return oe?.announceSuccess(`Recorte creado localmente: ${h}`),l}const v=n.savedState||{selectorState:we.current?{x:we.current.x,y:we.current.y,width:we.current.width,height:we.current.height}:null,imageTransform:ye.current?.$getTransform?.()||null,flipState:{horizontal:P.horizontal,vertical:P.vertical}},y=await se(p,m,{name:h,width:a,height:i,format:u});if(y)return y.cropState=v,oe?.announceSuccess(`Recorte creado: ${h}`),s?.(p,y),y;throw new Error("No se pudo crear la variante")}finally{if(e!==X&&a.imageTransform&&ye.current?.$setTransform){const[e,t,l,n,r,i]=a.imageTransform;if(ye.current.$setTransform(e,t,l,n,r,i),a.selectorState&&we.current?.$change){const{x:e,y:t,width:l,height:n}=a.selectorState;we.current.$change(e,t,l,n,NaN,!0)}}}},[G,X,pe,se,t.id,s,oe,ye,we]),it=e.useCallback(async()=>{if(!Se){const e="No se puede exportar el recorte por restricciones de CORS en la imagen original.";return oe?.announceError(e),void alert(e)}if(!me.isReady){const e="El cropper aún no está inicializado. Espera un momento e inténtalo de nuevo.";return oe?.announceError(e),void alert(e)}Be(),oe?.announce("Creando recorte de la imagen");try{let e=t.id,l=null;if(t.file&&c){oe?.announce("Subiendo imagen...");const n=await c(t.file);if(!n||!n.id)throw new Error("No se pudo subir la imagen al servidor");e=n.id,l=n,oe?.announceSuccess("Imagen subida correctamente")}const a=await rt(X,e);a&&n(l?{crops:[a],asset:l}:a)}catch(e){console.warn("Error creating crop variant:",e);const t=e.message||"No se pudo crear el recorte. Inténtalo de nuevo.";oe?.announceError(t),alert(t),i?.(e)}},[Se,me.isReady,oe,Be,rt,X,n,i,t.file,t.id,c]),ot=e.useCallback(async e=>{Be(),oe?.announce(`Guardando ${e.length} recortes...`);try{let a=t.id,r=null;if(t.file&&c){oe?.announce("Subiendo imagen...");const e=await c(t.file,t.tags||null);if(!e||!e.id)throw new Error("No se pudo subir la imagen al servidor");a=e.id,r=e,oe?.announceSuccess("Imagen subida correctamente")}const i=[],o=[];for(const t of e)try{const e=await rt(t,a);e&&i.push(e)}catch(l){o.push({crop:G[t]?.label||`Crop ${t}`,error:l.message})}if(i.length>0&&(oe?.announceSuccess(`${i.length} recorte(s) guardado(s) correctamente`),n(r?{crops:i,asset:r}:i)),o.length>0){const e=`Errores al guardar algunos recortes:\n${o.map(e=>`- ${e.crop}: ${e.error}`).join("\n")}`;oe?.announceError(e),alert(e)}}catch(l){const e=l.message||"Error al procesar los recortes";oe?.announceError(e),alert(e),i?.(l)}},[Be,rt,G,oe,n,t.file,t.id,c,i]),st=e.useCallback(async()=>{(J.width>3500||J.height>3500)&&alert("Las dimensiones máximas permitidas son 3500x3500 píxeles. Por favor, ajusta el tamaño del recorte."),J.width=Math.min(J.width,3500),J.height=Math.min(J.height,3500);const e=We();if(-1!==e){const t=G[e];return alert(`El recorte "${t.label||t||"(sin nombre)"}" debe tener un nombre válido.`),void Y(e)}const t=G.findIndex((e,t)=>e.required&&!e.savedState&&t!==X);if(-1!==t){const e=G[t];return alert(`El recorte obligatorio "${e.label}" aún no ha sido configurado.\n\nPor favor, configura todos los recortes obligatorios antes de guardar.`),Y(t),void oe?.announce(`Recorte obligatorio "${e.label}" sin configurar. Por favor, configúralo.`,"assertive")}if(G.length>1){ie("save");const e=G.map((e,t)=>({crop:e,index:t})).filter(({crop:e,index:t})=>e.required||e.savedState||t===X).map(({index:e})=>e);return ae(e),void le(!0)}await it()},[We,G,it,X,oe]),ct=e.useCallback(async e=>{const l=G[e];if(!l)throw new Error(`Crop ${e} no encontrado`);if(!l.savedState&&e!==X)throw new Error(`El recorte "${l.label}" aún no ha sido configurado`);const n={imageTransform:ye.current?.$getTransform?.(),selectorState:we.current?{x:we.current.x,y:we.current.y,width:we.current.width,height:we.current.height}:null};try{if(e!==X&&l.savedState){if(l.savedState.imageTransform&&ye.current?.$setTransform){const[e,t,n,a,r,i]=l.savedState.imageTransform;ye.current.$setTransform(e,t,n,a,r,i)}if(l.savedState.selectorState&&we.current?.$change){const{x:e,y:t,width:n,height:a}=l.savedState.selectorState;we.current.$change(e,t,n,a,NaN,!0)}await new Promise(e=>setTimeout(e,100))}const n=await pe.toCanvas({width:l.width,height:l.height,imageSmoothingEnabled:!0,imageSmoothingQuality:"high"});if(!n)throw new Error(`No se pudo generar el canvas para "${l.label}"`);const a=n.toDataURL(`image/${globalThis.downloadFormat||t.mime_type?.split("/")[1]||"webp"}`,.9),r=`${Nn(l.label||"crop")}_${l.width}_${l.height}`;return await yn(a,r,{accessibilityManager:oe,onSuccess:e=>{console.log(`✅ Descargado: ${e}`)},onError:e=>{throw new Error(`Error al descargar "${l.label}": ${e.message}`)}}),{crop:l.label,filename:r}}finally{if(e!==X&&n.imageTransform&&ye.current?.$setTransform){const[e,t,l,a,r,i]=n.imageTransform;if(ye.current.$setTransform(e,t,l,a,r,i),n.selectorState&&we.current?.$change){const{x:e,y:t,width:l,height:a}=n.selectorState;we.current.$change(e,t,l,a,NaN,!0)}}}},[G,X,pe,t.mime_type,oe,ye,we]),ut=e.useCallback(async e=>{Be(),oe?.announce(`Descargando ${e.length} recortes...`);const t=[],l=[];for(const a of e)try{const e=await ct(a);e&&t.push(e)}catch(n){l.push({crop:G[a]?.label||`Crop ${a}`,error:n.message})}if(t.length>0&&oe?.announceSuccess(`${t.length} recorte(s) descargado(s) correctamente`),l.length>0){const e=`Errores al descargar algunos recortes:\n${l.map(e=>`- ${e.crop}: ${e.error}`).join("\n")}`;oe?.announceError(e),alert(e)}},[Be,ct,G,oe]),dt=e.useCallback(async()=>{if(!Se){const e="No se puede descargar el recorte por restricciones de CORS en la imagen original.";return oe?.announceError(e),void alert(e)}Be(),oe?.announce("Preparando descarga del recorte");try{await ct(X),oe?.announceSuccess("Recorte descargado correctamente")}catch(e){console.error("Error downloading crop:",e);const t=e.message||"Error al descargar el recorte";oe?.announceError(t),alert(t)}},[Se,oe,Be,ct,X]),bt=e.useCallback(async()=>{const e=We();if(-1!==e){const t=G[e];return alert(`El recorte "${t.label||t||"(sin nombre)"}" debe tener un nombre válido.`),void Y(e)}if(G.length>1){ie("download");const e=G.map((e,t)=>({crop:e,index:t})).filter(({crop:e,index:t})=>e.savedState||t===X).map(({index:e})=>e);return ae(e),void le(!0)}await dt()},[We,G,dt,X]),mt=e.useMemo(()=>!!t.file||(!t.id||!("string"!=typeof t.id||!t.id.startsWith("external"))),[t.file,t.id]),ht=e.useCallback(async()=>{try{if(t.file&&c){oe?.announce("Subiendo imagen original...");const e=await c(t.file);if(!e||!e.id)throw new Error("No se pudo subir la imagen al servidor");return oe?.announceSuccess("Imagen guardada correctamente"),void n({asset:e,crops:[]})}if(mt){oe?.announce("Conservando imagen original...");const e={id:`local-original-${Date.now()}`,name:t.filename||"original",filename:t.filename||"image.jpg",url:t.url,urlSigned:t.url,width:t.width||Ce?.naturalWidth||1920,height:t.height||Ce?.naturalHeight||1080,mime_type:t.mime_type||"image/jpeg",isLocal:!0,isOriginal:!0};return oe?.announceSuccess("Imagen original conservada"),void n({crops:[e]})}if(t.id&&!t.id.startsWith("external")){oe?.announce("Seleccionando imagen original...");const e={id:t.id,name:t.filename||"original",filename:t.filename||"image.jpg",url:t.url,urlSigned:t.urlSigned||t.url,width:t.width||Ce?.naturalWidth||1920,height:t.height||Ce?.naturalHeight||1080,mime_type:t.mime_type||"image/jpeg",isOriginal:!0};return oe?.announceSuccess("Imagen original seleccionada"),void n({crops:[e],assetId:t.id})}a()}catch(e){console.error("Error guardando imagen original:",e);const t=e.message||"No se pudo guardar la imagen. Inténtalo de nuevo.";oe?.announceError(t),alert(t),i?.(e)}},[t,Ce,c,a,n,i,oe,mt]);return e.useEffect(()=>{m(!1),p(null)},[t]),e.useEffect(()=>{if(!de.manager||!me.isReady||!z)return;const e=K.existingCrops?.[0],t=e?.cropState;setTimeout(()=>{ze(),setTimeout(()=>{if(t){if(t.imageTransform&&ye.current?.$setTransform){const[e,l,n,a,r,i]=t.imageTransform;ye.current.$setTransform(e,l,n,a,r,i)}if(t.selectorState&&we.current){const{x:e,y:l,width:n,height:a}=t.selectorState;we.current.x=e,we.current.y=l,we.current.width=n,we.current.height=a,we.current.$render?.()}t.flipState&&D(t.flipState)}else Le();L(!1)},100)},50)},[de.manager,me.isReady,z,ze,Le,K.existingCrops]),e.useEffect(()=>{de.manager&&me.isReady&&(Z&&pe.setAspectRatio(Z),ge.setBackground(x))},[Z,x,de.manager,me.isReady,pe,ge]),e.useEffect(()=>{if(!Ce||!me.isReady||K.mandatoryCrops.length>0)return;const e=G[0];if(e&&"crop-default-0"===e.id&&(1920===e.width||1080===e.height)){const t=Math.min(Ce.naturalWidth,3500),l=Math.min(Ce.naturalHeight,3500);Q([{...e,width:t,height:l}])}},[Ce,me.isReady,K.mandatoryCrops.length,G]),e.useEffect(()=>{if(!b||!Se)return;const e=setTimeout(async()=>{g(e=>!h&&!e||e);try{const e=await Ye();e&&p(e)}finally{g(!1)}},300);return()=>{clearTimeout(e),g(!1)}},[ke,je,b,Se,Ye,Z,P,h]),e.useEffect(()=>{const e=ve.current,t=t=>{if("Delete"===t.key||"Backspace"===t.key||"Backspace"===t.key&&t.metaKey||"Backspace"===t.key&&t.ctrlKey){const l=t.target;if(e&&(l===e||l===document.body||l===document.documentElement||"CROPPER-CANVAS"===l.tagName||"CROPPER-SELECTION"===l.tagName||"CROPPER-IMAGE"===l.tagName||"CROPPER-HANDLE"===l.tagName||"CROPPER-GRID"===l.tagName||l.closest("cropper-canvas")||e.contains(l)))return t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),!1}};return document.addEventListener("keydown",t,!0),document.addEventListener("keyup",t,!0),window.addEventListener("keydown",t,!0),e&&e.addEventListener("keydown",t,!0),()=>{document.removeEventListener("keydown",t,!0),document.removeEventListener("keyup",t,!0),window.removeEventListener("keydown",t,!0),e&&e.removeEventListener("keydown",t,!0)}},[ve]),t?l.jsxs("div",{className:"limbo-cropper-view lb:px-2 lb:border-2 lb:border-gray-200/50 lb:rounded-lg lb:max-w-7xl lb:mx-auto lb:w-full lb:min-w-full lb:h-full lb:min-h-full lb:flex lb:flex-col",children:[l.jsxs("div",{className:"limbo-cropper-header lb:flex lb:flex-row lb:justify-between lb:items-start lb:flex-wrap lb:mx-2 lb:py-2 lb:border-b lb:border-gray-200 lb:bg-white lb:z-10 lb:shrink-0 lb:lg:gap-2",children:[l.jsxs("div",{className:"lb:flex-1 lb:min-w-fit lb:space-y-2 lb:max-w-fit",children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2",children:[l.jsx("h2",{className:"lb:text-lg lb:sm:text-xl lb:font-extrabold lb:text-gray-800",children:"Generar recortes"}),G.length>1&&l.jsx("span",{className:"lb:px-2 lb:py-0.5 lb:bg-blue-100 lb:text-blue-800 lb:text-xs lb:font-semibold lb:rounded",children:J.label})]}),l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2",children:[l.jsx("label",{className:"lb:text-xs lb:text-gray-500 lb:whitespace-nowrap lb:w-fit",children:"Nombre:"}),l.jsx("div",{className:"",children:H+"."+(globalThis.downloadFormat||t.mime_type.split("/")[1]||"webp")})]})]}),l.jsx("div",{className:"lb:flex lb:flex-row lb:self-end lb:gap-2 lb:w-full lb:max-w-fit lb:sm:w-auto lb:flex-wrap",children:l.jsxs("button",{onClick:()=>{window.confirm("Si cancelas, perderás todos los cambios realizados. ¿Deseas continuar?")&&a()},disabled:ce,className:"lb:flex lb:flex-row lb:items-center lb:gap-1 lb:self-end lb:w-full lb:max-w-fit lb:sm:w-auto lb:px-3 lb:cursor-pointer lb:py-1.5 lb:text-sm lb:rounded lb:bg-neutral-gray-500 lb:hover:bg-neutral-gray-700 lb:transition-colors lb:text-white lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":"Cancelar y volver",title:"Cancelar y volver",children:[l.jsx("span",{className:"icon icon-arrow-left-white icon--sm lb:m-0 lb:p-0"})," ","Volver"]})})]}),l.jsxs("div",{className:"limbo-cropper-status lb:bg-white lb:border-gray-100 lb:py-0 lb:pb-0 lb:flex-shrink-0",children:[ue&&l.jsxs(fe,{variant:"danger",className:"lb:mb-2 lb:text-sm",children:[l.jsx("strong",{children:"Error:"})," ",ue]}),Ce&&l.jsxs(fe,{variant:"info",className:"lb:mb-2 lb:text-sm",role:"status",children:[l.jsx("strong",{children:"Original:"})," ",Ce.naturalWidth," ×"," ",Ce.naturalHeight," px",Ce.currentWidth!==Ce.naturalWidth&&l.jsxs("span",{className:"lb:ml-2 lb:sm:ml-3 lb:text-xs lb:block lb:sm:inline",children:["(Mostrada: ",Math.round(Ce.currentWidth)," ×"," ",Math.round(Ce.currentHeight)," px)"]})]}),!Se&&l.jsx(fe,{variant:"warning",className:"lb:mb-2 lb:text-sm",children:"No se puede exportar por restricciones CORS"}),l.jsxs("div",{className:"lb:bg-white lb:border-b lb:border-gray-200 lb:py-2 lb:mx-2 lb:shrink-0 lb:sticky lb:top-0 lb:z-10 lb:mb-1",children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between lb:mb-2",children:[l.jsxs("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-700",children:["Recortes ",G.length>1&&`(${G.length})`]}),K.allowCustomCrops&&l.jsxs("button",{onClick:He,disabled:ce,className:"lb:text-xs lb:cursor-pointer lb:px-2 lb:py-1 lb:bg-brand-blue-50 lb:hover:bg-brand-blue-200 lb:text-brand-blue-1000 lb:rounded lb:border lb:border-brand-blue-200 lb:transition-colors lb:flex lb:items-center lb:gap-1",title:"Añadir recorte personalizado",children:[l.jsx("span",{className:"icon icon-add icon--sm",style:{filter:"var(--limbo-icon-blue)"}}),"Añadir recorte"]})]}),l.jsx("div",{className:"lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:lg:grid-cols-4 lb:xl:grid-cols-5 lb:gap-1.5 lb:max-h-48 lb:overflow-y-auto",children:G.map((e,t)=>{const n=e.savedState||t===X;return l.jsxs("label",{className:"lb:h-fit lb:flex lb:flex-col lb:p-1.5 lb:rounded lb:border lb:cursor-pointer lb:transition-colors lb:min-h-17.5 lb:w-full "+(X===t?"lb:bg-blue-50 lb:border-blue-300":n?"lb:bg-gray-50 lb:border-gray-200 lb:hover:bg-gray-100":"lb:bg-orange-50 lb:border-orange-300 lb:hover:bg-orange-100"),children:[l.jsx("input",{type:"radio",name:"active-crop",checked:X===t,onChange:()=>Ve(t),disabled:ce,className:"lb:hidden"}),l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-1 lb:mb-1",children:[l.jsx("div",{className:"lb:flex-1 lb:min-w-0",children:l.jsxs("div",{className:"lb:flex lb:flex-wrap lb:items-center lb:gap-1 lb:min-h-",children:[X!==t||e.required?l.jsx("span",{className:"lb:text-xs lb:font-medium lb:text-gray-800 lb:truncate",children:e.label}):l.jsx("input",{type:"text",value:e.label,onChange:e=>Qe(e.target.value),disabled:ce,className:"lb:w-full lb:max-h-fit lb:text-xs lb:px-1 lb:py-0.5 lb:border lb:border-gray-300 lb:rounded lb:focus:outline-none lb:focus:ring-1 lb:focus:ring-blue-500 lb:h-1",placeholder:"Nombre",maxLength:25,onClick:e=>e.stopPropagation()}),e.required&&l.jsx("span",{className:"lb:text-[10px] lb:px-1 lb:py-0.5 lb:bg-red-200 lb:text-red-1000 lb:rounded lb:whitespace-nowrap lb:truncate",children:"Obligatorio"})]})}),!e.required&&G.length>1&&l.jsx("button",{onClick:l=>{l.preventDefault(),l.stopPropagation(),Xe(t,e.label)},className:"lb:shrink-0 lb:hover:bg-red-500/70 lb:text-red-1000 lb:p-1 lb:rounded lb:max-h-fit lb:aspect-square lb:cursor-pointer lb:flex",title:"Eliminar",children:l.jsx("span",{className:"icon icon-close-small icon--xs"})})]}),l.jsx("div",{className:"lb:flex lb:items-center lb:gap-1 lb:mt-auto",children:X===t?l.jsxs(l.Fragment,{children:[l.jsx("input",{type:"number",min:"100",max:"3500",value:Math.min(e.width,3500),onChange:e=>Ke("width",e.target.value),onBlur:()=>Ge("width"),disabled:ce||e.lockDimensions,className:"lb:max-h-fit lb:flex-1 lb:text-xs lb:px-1 lb:py-0.5 lb:border lb:rounded lb:focus:outline-none lb:focus:ring-1 lb:focus:ring-blue-500 "+(e.lockDimensions?"lb:border-gray-200 lb:bg-gray-100 lb:text-gray-500 lb:cursor-not-allowed":"lb:border-gray-300"),placeholder:"Ancho",onClick:e=>e.stopPropagation(),title:e.lockDimensions?"Dimensiones bloqueadas (recorte obligatorio)":"Ancho en píxeles"}),l.jsx("span",{className:"lb:text-gray-400 lb:text-xs",children:"×"}),l.jsx("input",{type:"number",min:"100",max:"3500",value:Math.min(e.height,3500),onChange:e=>Ke("height",e.target.value),onBlur:()=>Ge("height"),disabled:ce||e.lockDimensions,className:"lb:max-h-fit lb:flex-1 lb:text-xs lb:px-1 lb:py-0.5 lb:border lb:rounded lb:focus:outline-none lb:focus:ring-1 lb:focus:ring-blue-500 "+(e.lockDimensions?"lb:border-gray-200 lb:bg-gray-100 lb:text-gray-500 lb:cursor-not-allowed":"lb:border-gray-300"),placeholder:"Alto",onClick:e=>e.stopPropagation(),title:e.lockDimensions?"Dimensiones bloqueadas (recorte obligatorio)":"Alto en píxeles"})]}):l.jsxs("span",{className:"lb:text-xs lb:text-gray-500",children:[e.width," × ",e.height," px"]})}),!n&&l.jsx("div",{className:"lb:text-xs lb:px-1 lb:py-0.5 lb:bg-orange-300 lb:text-neutral-gray-25 lb:text-shadow-xs lb:font-semibold lb:rounded lb:text-center lb:mt-1",children:"Sin configurar"})]},e.id)})})]})]}),l.jsxs("div",{className:"lb:flex lb:flex-col lb:lg:flex-row lb:flex-1 lb:w-full lb:overflow-hidden lb:lg:max-h-130 lb:mx-2 lb:py-1",children:[l.jsx("div",{className:"lb:relative lb:flex-1 lg:flex-2 lb:h-full lb:shrink-0 lb:grow-1 lb:order-0 lb:min-h-100 lb:lg:min-h-130",children:l.jsxs("div",{className:"lb:absolute lb:inset-0 lb:bg-white lb:rounded-lg lb:border-2 lb:border-gray-200 lb:overflow-hidden",children:[l.jsx(ft,{show:z,message:"Cargando recortador..."}),l.jsx(ft,{show:M,message:`Cambiando a: ${G[X]?.label||"recorte"}...`}),l.jsxs("cropper-canvas",{ref:ve,style:{width:"100%",height:"100%",display:"block"},background:!!x||void 0,id:"limbo-cropperjs-canvas",tabindex:"-1",onKeyDown:e=>{"Delete"!==e.key&&"Backspace"!==e.key||(e.preventDefault(),e.stopPropagation())},children:[l.jsx("cropper-image",{ref:ye,src:k,alt:t.filename,id:"limbo-cropperjs-image",action:"move",crossOrigin:"anonymous",rotatable:!0,scalable:!0,skewable:!0,translatable:!0}),l.jsxs("cropper-selection",{ref:we,"initial-coverage":"0.5",movable:!0,resizable:!0,keyboard:"true",action:"move",style:{cursor:"move",minWidth:`${ee.minWidth}px`,minHeight:`${ee.minHeight}px`},"data-prevent-delete":"true",tabindex:"-1",children:[v&&l.jsx("cropper-grid",{role:"grid",action:"move",covered:!0,bordered:!0}),l.jsx("cropper-handle",{action:"move",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"32px",height:"32px",zIndex:"10"}}),l.jsx("cropper-handle",{action:"n-resize"}),l.jsx("cropper-handle",{action:"e-resize"}),l.jsx("cropper-handle",{action:"s-resize"}),l.jsx("cropper-handle",{action:"w-resize"}),l.jsx("cropper-handle",{action:"ne-resize"}),l.jsx("cropper-handle",{action:"nw-resize"}),l.jsx("cropper-handle",{action:"se-resize"}),l.jsx("cropper-handle",{action:"sw-resize"})]})]})]})}),l.jsx("div",{className:"lb:w-full lb:lg:max-w-80 lb:mt-2 lb:lg:my-0 lb:overflow-y-auto lb:bg-white lb:border-t lb:lg:border-t-0 lb:lg:border-l lb:border-gray-200 lb:shrink-0",children:l.jsxs("div",{className:"lb:h-full lb:mt-2 lb:lg:my-0 lb:me-2 lb:lg:mx-2 lb:space-y-2 lb:grid lb:grid-cols-2 lb:md:grid-cols-3 lb:flex-wrap lb:md:flex-nowrap lb:items-start lb:flex-row lb:gap-2 lb:lg:gap-0 lb:lg:block",children:[l.jsxs("div",{className:"lb:bg-white lb:rounded lb:border lb:w-full lb:border-gray-200 lb:mb-2",children:[l.jsx("button",{onClick:Ae,className:"lb:hidden lb:sm:block lb:w-full lb:p-2 lb:mb-05 lb:cursor-pointer lb:hover:bg-neutral-gray-050/50 lb:transition-colors lb:rounded-t-sm","aria-expanded":W,"aria-label":"Mostrar/ocultar opciones de visualización",children:l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[l.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-700",children:"Transformar imagen"}),l.jsx("div",{className:"lb:text-center",children:l.jsx("span",{className:`icon ${W?"icon-chevron-up":"icon-chevron-down"} lb:text-center icon--xs`})})]})}),l.jsxs("div",{className:"lb:p-2 lb:space-y-2 lb:justify-items-stretch lb:static "+(W?"lb:block":"lb:sm:hidden"),children:[l.jsx("div",{className:"lb:mb-3 lb:block",children:l.jsxs("div",{className:"lb:grid lb:grid-cols-5 lb:gap-1 lb:content-center lb:h-fit lb:mx-auto",children:[l.jsx("button",{onClick:()=>Pe(-.2),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Alejar",disabled:ce,"aria-label":"Alejar imagen",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-zoom-out-blue"})})}),l.jsx("button",{onClick:()=>Ie(-10,-10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover arriba-izquierda",disabled:ce,"aria-label":"Mover imagen hacia arriba-izquierda",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-arrow-up-blue icon--md lb:-rotate-45"})})}),l.jsx("button",{onClick:()=>Ie(0,-10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover arriba",disabled:ce,"aria-label":"Mover imagen hacia arriba",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-arrow-up-blue icon--md"})})}),l.jsx("button",{onClick:()=>Ie(10,-10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover arriba-derecha",disabled:ce,"aria-label":"Mover imagen hacia arriba-derecha",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-arrow-up-blue icon--md lb:rotate-45"})})}),l.jsx("button",{onClick:()=>Pe(.2),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Acercar 20%",disabled:ce,"aria-label":"Acercar imagen",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-zoom-in-blue"})})}),l.jsx("button",{onClick:()=>De(-45),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Rotar -45°",disabled:ce,"aria-label":"Rotar imagen 45 grados a la izquierda",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"lb:text-brand-blue-1000 lb:font-medium",children:"-45°"})})}),l.jsx("button",{onClick:()=>Ie(-10,0),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover izquierda",disabled:ce,"aria-label":"Mover imagen hacia la izquierda",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-arrow-left-blue"})})}),l.jsx("button",{onClick:ze,className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Centrar y ajustar imagen",disabled:ce,"aria-label":"Centrar y ajustar imagen",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-radio-button-blue icon-md"})})}),l.jsx("button",{onClick:()=>Ie(10,0),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover derecha",disabled:ce,"aria-label":"Mover imagen hacia la derecha",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-arrow-right-blue"})})}),l.jsx("button",{onClick:()=>De(45),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Rotar +45°",disabled:ce,"aria-label":"Rotar imagen 45 grados a la derecha",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"lb:text-brand-blue-1000 lb:font-medium",children:"+45°"})})}),l.jsx("button",{onClick:Fe,className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:aspect-square "+(P.horizontal?"lb:bg-blue-100 lb:border lb:border-blue-300 lb:text-blue-800":"lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200"),title:"Voltear horizontalmente "+(P.horizontal?"(activo)":""),disabled:ce,"aria-label":"Voltear imagen horizontalmente","aria-pressed":P.horizontal,children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center lb:gap-2",children:l.jsx("span",{className:"icon icon-arrow-left-right-blue lb:border lb:border-brand-blue-1000 lb:rounded"})})}),l.jsx("button",{onClick:()=>Ie(-10,10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover abajo-izquierda",disabled:ce,"aria-label":"Mover imagen hacia abajo-izquierda",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-arrow-up-blue icon--md lb:-rotate-145"})})}),l.jsx("button",{onClick:()=>Ie(0,10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover abajo",disabled:ce,"aria-label":"Mover imagen hacia abajo",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-arrow-down-blue"})})}),l.jsx("button",{onClick:()=>Ie(10,10),className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200 lb:aspect-square",title:"Mover abajo-derecha",disabled:ce,"aria-label":"Mover imagen hacia abajo-derecha",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-arrow-up-blue icon--md lb:rotate-145"})})}),l.jsx("button",{onClick:Ue,className:"lb:px-0 lb:rounded lb:cursor-pointer lb:transition-colors lb:aspect-square lb:text-sm "+(P.vertical?"lb:bg-blue-100 lb:border lb:border-blue-300 lb:text-blue-800":"lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200"),title:"Voltear verticalmente "+(P.vertical?"(activo)":""),disabled:ce,"aria-label":"Voltear imagen verticalmente","aria-pressed":P.vertical,children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{className:"icon icon-arrow-up-down-blue lb:border lb:border-brand-blue-1000 lb:rounded"})})})]})}),l.jsx("div",{className:"lb:flex lb:flex-col lb:gap-2",children:l.jsx("button",{onClick:()=>{he.reset(),D({horizontal:!1,vertical:!1})},className:"lb:w-full lb:p-2 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",title:"Reiniciar transformaciones",disabled:ce,"aria-label":"Reiniciar todas las transformaciones de la imagen",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsxs("span",{children:[l.jsx("span",{className:"icon icon-refresh-blue icon--sm lb:align-[middle!important] "})," ","Reiniciar ajustes"]})})})})]})]}),l.jsxs("div",{className:"lb:bg-white lb:rounded lb:border lb:border-gray-200 lb:w-full"+(B?"":" lb:bg-neutral-gray-50/50"),children:[l.jsx("button",{onClick:Te,className:"lb:hidden lb:sm:block lb:w-full lb:cursor-pointer lb:hover:bg-neutral-gray-050/50 lb:p-2 lb:mb-05 lb:transition-colors lb:rounded-t-sm","aria-expanded":B,"aria-label":"Mostrar/ocultar opciones de visualizción",children:l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[l.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-700",children:"Ajustes del selector"}),l.jsx("div",{className:"lb:text-center",children:l.jsx("span",{className:`icon ${B?"icon-chevron-up":"icon-chevron-down"} lb:text-center icon--xs`})})]})}),l.jsxs("div",{className:"lb:p-2 lb:space-y-2 lb:justify-items-stretch lb:static "+(B?"lb:block":"lb:sm:hidden"),children:[l.jsx("div",{children:l.jsxs("div",{className:"lb:grid lb:grid-cols-2 lb:gap-2",children:[l.jsx("button",{onClick:()=>Oe(.5),className:"lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-xs lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",disabled:ce,"aria-label":"Selección 50%",title:"Tamaño de selector 50%",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{children:"50%"})})}),l.jsx("button",{onClick:()=>Oe(.7),className:"lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-xs lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",disabled:ce,"aria-label":"Selección 70%",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{children:"70%"})})}),l.jsx("button",{onClick:()=>Oe(.9),className:"lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-xs lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",disabled:ce,"aria-label":"Selección 90%",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{children:"90%"})})}),l.jsx("button",{onClick:()=>Oe(1),className:"lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-xs lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",disabled:ce,"aria-label":"Selección completa",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsx("span",{children:"100%"})})})]})}),l.jsxs("div",{className:"lb:space-y-2 lb:pt-2",children:[l.jsx("button",{onClick:Le,className:"lb:w-full lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",title:"Centrar selección",disabled:ce,"aria-label":"Centrar área de selección",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsxs("span",{children:[l.jsx("span",{className:"icon icon-radio-button icon--sm lb:align-[middle!important] "})," ","Centrar selección"]})})}),l.jsx("button",{onClick:Me,className:"lb:w-full lb:p-1 lb:rounded lb:cursor-pointer lb:transition-colors lb:text-sm lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200",title:"Reiniciar selección",disabled:ce,"aria-label":"Reiniciar área de selección",children:l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center",children:l.jsxs("span",{children:[l.jsx("span",{className:"icon icon-refresh icon--sm lb:align-[middle!important]"})," ","Reset selección"]})})})]})]})]}),l.jsxs("div",{className:"lb:bg-white lb:rounded lb:border lb:border-gray-200 lb:w-full",children:[l.jsx("button",{onClick:$e,className:"lb:hidden lb:sm:block lb:w-full lb:cursor-pointer lb:hover:bg-neutral-gray-050/50 lb:transition-colors lb:rounded-t-sm lb:mb-05 lb:p-2","aria-expanded":F,"aria-label":"Mostrar/ocultar opciones de visualización",children:l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[l.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-gray-700",children:"Visualización"}),l.jsx("div",{className:"lb:text-center",children:l.jsx("span",{className:`icon ${F?"icon-chevron-up":"icon-chevron-down"} lb:text-center icon--xs`})})]})}),l.jsxs("div",{className:"lb:py-2 lb:space-y-2 lb:justify-items-stretch lb:static "+(F?"lb:block":"lb:sm:hidden"),children:[l.jsxs("button",{onClick:Ee,className:"lb:w-auto lb:flex lb:cursor-pointer lb:items-center lb:justify-between lb:mx-2 lb:p-1 lb:rounded lb:transition-colors "+(v?"lb:bg-blue-100 lb:border lb:border-blue-300 lb:text-blue-800":"lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200"),disabled:ce,"aria-pressed":v,title:"Mostrar/ocultar cuadrícula de la regla de los tercios en el selector","aria-label":"Activar/desactivar grid",children:[l.jsxs("span",{className:"lb:text-sm lb:flex lb:items-center",children:[l.jsx("span",{className:"icon icon-area-blue lb:me-1"})," ","Cuadrícula"]}),l.jsx("span",{className:"lb:text-xs",children:v?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"icon icon-tick icon--xs lb:align-[middle!important] lb:-mt-0.5"})," ","Activo"]}):"Inactivo"})]}),l.jsxs("button",{onClick:_e,className:"lb:w-auto lb:flex lb:cursor-pointer lb:items-center lb:justify-between lb:mx-2 lb:p-1 lb:rounded lb:transition-colors "+(x?"lb:bg-blue-100 lb:border lb:border-blue-300 lb:text-blue-800":"lb:bg-gray-100 lb:border lb:border-gray-300 lb:text-gray-700 lb:hover:bg-gray-200"),disabled:ce,"aria-pressed":x,"aria-label":"Activar/desactivar sombreado",children:[l.jsxs("span",{className:"lb:text-sm lb:flex lb:items-center",children:[l.jsx("span",{className:"icon icon-comparison-blue lb:me-1"})," ","Tablero"]}),l.jsx("span",{className:"lb:text-xs",children:x?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"icon icon-tick icon--xs lb:align-[middle!important] lb:-mt-0.5"})," ","Activo"]}):"Inactivo"})]})]})]})]})})]}),l.jsxs("div",{className:"lb:flex lb:justify-between lb:shrink-0 lb:border-t lb:border-gray-200 lb:bg-white lb:mx-2 lb:mt-1 lb:py-2 lb:lg:gap-0",children:[l.jsxs("button",{onClick:()=>O(!0),className:"lb:text-nowrap lb:block lb:cursor-pointer lb:lg:flex lb:items-center lb:gap-2 lb:px-2 lb:py-1 lb:bg-gradient-to-br lb:from-brand-blue-50 lb:to-green-50 lb:hover:from-brand-blue-100 lb:hover:to-green-100 lb:border lb:border-blue-200 lb:rounded-lg lb:shadow-sm lb:transition-colors","aria-label":"Abrir guía de uso",children:[l.jsx("span",{className:"icon icon-lightbulb lb:text-yellow-500"}),l.jsx("span",{className:"lb:text-sm lb:font-semibold lb:text-blue-800",children:"Guía de uso"}),l.jsx("span",{className:"icon icon-arrow-down lb:scale-75 lb:-rotate-145"})]}),l.jsx("button",{onClick:Je,disabled:ce||!Se,className:`lb:px-3 lb:cursor-pointer lb:py-1.5 lb:text-sm lb:rounded lb:transition-colors ${b?"lb:bg-red-1000 lb:hover:bg-red-800 lb:text-white":"lb:bg-brand-blue-800 lb:hover:bg-brand-blue-1000 lb:text-white"} lb:disabled:opacity-50 lb:disabled:cursor-not-allowed`,"aria-label":"Vista previa",title:"Mostrar/Ocultar vista previa",children:l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-1",children:[l.jsx("span",{className:"icon icon-search-white icon--sm"}),l.jsx("span",{className:"lb:hidden lb:sm:inline lb:whitespace-nowrap",children:b?"Cerrar previa":"Vista previa"})]})}),l.jsxs("div",{className:"lb:flex lb:flex-row lb:gap-1 lb:lg:gap-2 lb:items-center lb:justify-end",children:[l.jsx("button",{onClick:bt,disabled:ce||!Se,className:"lb:cursor-pointer lb:px-3 lb:py-1.5 lb:text-sm lb:rounded lb:bg-brand-blue-800 lb:hover:bg-brand-blue-1000 lb:text-white lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":"Descargar",title:"Descargar recorte sin guardar",children:l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-1",children:[l.jsx("span",{className:"icon icon-download-white icon--sm"}),l.jsx("span",{className:"lb:hidden lb:md:inline lb:whitespace-nowrap",children:"Descargar"})]})}),t.file&&l.jsx("button",{onClick:ht,disabled:ce||u,className:"lb:px-3 lb:cursor-pointer lb:py-1.5 lb:text-sm lb:rounded lb:bg-teal-600 lb:hover:bg-teal-700 lb:text-white lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed","aria-label":"Conservar solo imagen original sin crear recortes",title:"Subir y guardar la imagen original sin crear recortes",children:l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-1",children:[l.jsx("span",{className:"icon icon-tick-white icon--sm"}),l.jsx("span",{className:"lb:hidden lb:md:inline lb:whitespace-nowrap",children:"Guardar sin recortar"})]})}),l.jsx("button",{onClick:st,disabled:ce||!ke||!Ne||!Se||!me.isReady,className:"lb:px-3 lb:cursor-pointer lb:py-1.5 lb:text-sm lb:rounded lb:bg-green-600 lb:hover:bg-green-700 lb:text-white lb:transition-colors lb:disabled:opacity-50 lb:disabled:cursor-not-allowed",title:"Guardar imagen recortada",children:l.jsx("div",{className:"lb:flex lb:items-center lb:gap-1",children:ce?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"icon icon-save-white icon--sm"}),l.jsx("span",{children:"Guardando..."})]}):l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"icon icon-save-white icon--sm"}),l.jsx("span",{className:"lb:hidden lb:md:inline lb:whitespace-nowrap",children:"Guardar recorte"})]})})})]})]}),te&&l.jsx("div",{className:"lb:fixed lb:inset-0 lb:bg-black lb:bg-opacity-50 lb:flex lb:items-center lb:justify-center lb:z-[9999] lb:p-4",children:l.jsxs("div",{className:"lb:bg-white lb:rounded-lg lb:shadow-xl lb:max-w-lg lb:w-full lb:max-h-[80vh] lb:overflow-hidden lb:flex lb:flex-col",children:[l.jsxs("div",{className:"lb:px-6 lb:py-4 lb:border-b lb:border-gray-200",children:[l.jsx("h3",{className:"lb:text-lg lb:font-semibold lb:text-gray-800",children:"save"===re?"Seleccionar recortes a guardar":"Seleccionar recortes a descargar"}),l.jsxs("p",{className:"lb:text-sm lb:text-gray-600 lb:mt-1",children:["Marca los recortes que deseas"," ","save"===re?"guardar":"descargar"]})]}),l.jsx("div",{className:"lb:px-6 lb:py-4 lb:overflow-y-auto lb:flex-1",children:l.jsx("div",{className:"lb:space-y-2",children:G.map((e,t)=>{const n=e.savedState||t===X,a=!e.required&&!n,r=e.required&&"save"===re;return l.jsxs("label",{className:`lb:flex lb:items-center lb:gap-3 lb:p-3 lb:rounded lb:border lb:transition-colors ${ne.includes(t)?"lb:bg-blue-50 lb:border-blue-300":a?"lb:bg-gray-100 lb:border-gray-300 lb:opacity-60":"lb:bg-gray-50 lb:border-gray-200 lb:hover:bg-gray-100"} ${a||r?"lb:cursor-not-allowed":"lb:cursor-pointer"}`,title:r?"Este recorte es obligatorio y debe ser guardado":"",children:[l.jsx("input",{type:"checkbox",checked:ne.includes(t),disabled:a||r,onChange:e=>{e.target.checked?ae(e=>[...e,t]):ae(e=>e.filter(e=>e!==t))},className:"lb:w-4 lb:h-4 lb:text-blue-600"}),l.jsxs("div",{className:"lb:flex-1 lb:min-w-0",children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2 lb:flex-wrap",children:[l.jsxs("span",{title:"Nombre del archivo a descargar",className:"lb:text-sm lb:font-medium lb:text-gray-800 lb:truncate",children:[e.label,"_",e.width,"_",e.height]}),e.required&&l.jsx("span",{className:"lb:text-xs lb:px-1.5 lb:py-0.5 lb:bg-red-200 lb:text-red-1000 lb:rounded lb:whitespace-nowrap",children:"Obligatorio"}),!n&&!e.required&&l.jsx("span",{className:"lb:text-xs lb:px-1.5 lb:py-0.5 lb:bg-orange-100 lb:text-orange-700 lb:rounded lb:whitespace-nowrap",children:"Sin configurar"})]}),l.jsxs("span",{title:"Dimensiones del recorte",className:"lb:text-xs lb:text-gray-500",children:[e.width," × ",e.height," px"]})]})]},e.id)})})}),l.jsxs("div",{className:"lb:px-6 lb:py-4 lb:border-t lb:border-gray-200 lb:flex lb:gap-3 lb:justify-end",children:[l.jsx("button",{onClick:()=>{le(!1),ie(null),ae([])},className:"limbo-btn limbo-btn-secondary lb:px-4 lb:py-2",children:"Cancelar"}),l.jsxs("button",{onClick:async()=>{if(le(!1),"save"===re)if(1===ne.length){const e=X;Y(ne[0]),await new Promise(e=>setTimeout(e,100)),await it(),Y(e)}else await ot(ne);else if(1===ne.length){const e=X;Y(ne[0]),await new Promise(e=>setTimeout(e,100)),await dt(),Y(e)}else await ut(ne);ie(null),ae([])},disabled:0===ne.length,className:"limbo-btn limbo-btn-primary lb:px-4 lb:py-2 lb:disabled:opacity-50 lb:disabled:cursor-not-allowed",children:["save"===re?"Guardar":"Descargar"," (",ne.length,")"]})]})]})}),R&&l.jsx("div",{className:"lb:fixed lb:inset-0 lb:bg-black/50 lb:flex lb:items-center lb:justify-center lb:z-[9999] lb:p-4",children:l.jsxs("div",{className:"lb:bg-white lb:rounded-lg lb:shadow-xl lb:max-w-5xl lb:w-full lb:max-h-[90vh] lb:overflow-hidden lb:flex lb:flex-col",children:[l.jsx("div",{className:"lb:px-6 lb:py-4 lb:border-b lb:border-gray-200 lb:bg-brand-blue-50",children:l.jsxs("div",{className:"lb:flex lb:items-center lb:justify-between",children:[l.jsxs("h3",{className:"lb:text-xl lb:font-semibold lb:text-brand-blue-1000 lb:flex lb:items-center lb:gap-2",children:[l.jsx("span",{className:"icon icon-lightbulb lb:text-yellow-500"}),"Guía de uso del Cropper"]}),l.jsx("button",{onClick:()=>O(!1),className:"lb:text-gray-400 lb:hover:text-gray-600 lb:p-1 lb:rounded-full lb:hover:bg-gray-100 lb:transition-colors","aria-label":"Cerrar modal",children:l.jsx("span",{className:"icon icon-close-small icon--lg"})})]})}),l.jsxs("div",{className:"lb:px-6 lb:py-4 lb:overflow-y-auto lb:flex-1 lb:space-y-4",children:[l.jsxs("div",{className:"lb:bg-brand-blue-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-brand-blue-400",children:[l.jsx("h4",{className:"lb:font-semibold lb:text-brand-blue-1000 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"🖱️ Navegación básica"}),l.jsxs("div",{className:"lb:text-sm lb:text-brand-blue-800 lb:space-y-2",children:[l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Arrastra la imagen:"})," Haz clic sobre la imagen dentro del área de selección y arrástrala para reposicionarla"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Zoom:"})," Usa la rueda del ratón sobre el canvas (fuera del área de selección) para hacer zoom"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Vista completa:"}),' Botón "Reset zoom" para ajustar automáticamente al tamaño óptimo']})]})]})]}),l.jsxs("div",{className:"lb:bg-brand-blue-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-brand-blue-400",children:[l.jsx("h4",{className:"lb:font-semibold lb:text-brand-blue-1000 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"✂️ Área de selección"}),l.jsxs("div",{className:"lb:text-sm lb:text-brand-blue-800 lb:space-y-2",children:[l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Mover selección:"})," Arrastra desde el centro",l.jsx("span",{className:"icon lb:bg-white icon-move lb:inline-block lb:mx-1 lb:align-middle lb:border lb:border-brand-blue-400 lb:rounded-full"}),"para reposicionar el área de recorte"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Redimensionar:"})," Arrastra desde las esquinas o bordes para cambiar el tamaño del área"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Tamaños rápidos:"})," Usa los botones de porcentaje (50%, 70%, 90%, 100%) para ajustar rápidamente el tamaño"]})]})]})]}),l.jsxs("div",{className:"lb:bg-brand-blue-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-brand-blue-400",children:[l.jsx("h4",{className:"lb:font-semibold lb:text-brand-blue-1000 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"⌨️ Atajos de teclado"}),l.jsxs("div",{className:"lb:text-sm lb:text-brand-blue-800 lb:space-y-2",children:[l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Flechas:"}),l.jsxs("span",{className:"lb:inline-flex lb:gap-1 lb:mx-1",children:[l.jsx("span",{className:"icon icon-arrow-right-box lb:rotate-180 icon--sm"}),l.jsx("span",{className:"icon icon-arrow-right-box icon--sm"}),l.jsx("span",{className:"icon icon-arrow-right-box lb:-rotate-90 icon--sm"}),l.jsx("span",{className:"icon icon-arrow-right-box lb:rotate-90 icon--sm"})]}),"Mueven la selección en incrementos de 10px"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Shift + Arrastrar:"})," Mantiene las proporciones al redimensionar el área de selección"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Ctrl + Rueda:"})," Control de zoom más preciso y fino"]})]})]})]}),l.jsxs("div",{className:"lb:bg-teal-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-teal-800",children:[l.jsx("h4",{className:"lb:font-semibold lb:text-teal-1000 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"👁️ Opciones de visualización"}),l.jsxs("div",{className:"lb:text-sm lb:text-teal-800 lb:space-y-2",children:[l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Cuadrícula:"})," Muestra la regla de los tercios para mejorar la composición de tus recortes"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Tablero:"})," Patrón de cuadros para alinear mejor las medidas o ver imágenes con transparencia"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Vista previa:"})," Muestra cómo quedará el recorte final antes de guardarlo"]})]})]})]}),l.jsxs("div",{className:"lb:bg-amber-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-amber-400",children:[l.jsx("h4",{className:"lb:font-semibold lb:text-amber-800 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"💡 Consejos profesionales"}),l.jsxs("div",{className:"lb:text-sm lb:text-amber-700 lb:space-y-2",children:[l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Orden de trabajo:"})," Primero aplica transformaciones (rotar, voltear), luego haz el recorte final"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Múltiples recortes:"})," Si tienes varios recortes configurados, revisa cada uno antes de guardar"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Calidad:"})," Las imágenes se exportan en alta calidad (JPEG 90%) manteniendo la mayor nitidez posible"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Proporciones:"})," Usa Shift al redimensionar para mantener el aspecto ratio original"]})]})]})]}),l.jsxs("div",{className:"lb:bg-orange-50 lb:rounded-lg lb:p-4 lb:border-l-4 lb:border-orange-500",children:[l.jsx("h4",{className:"lb:font-semibold lb:text-orange-800 lb:mb-3 lb:text-base lb:flex lb:items-center lb:gap-2",children:"⚠️ Notas importantes"}),l.jsxs("div",{className:"lb:text-sm lb:text-orange-700 lb:space-y-2",children:[l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Recortes grandes:"})," Imágenes de alta resolución pueden tardar más en procesarse"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Calidad de escala:"})," Evita ampliar demasiado áreas pequeñas, ya que puede afectar la nitidez"]})]}),l.jsxs("div",{className:"lb:flex lb:items-start lb:gap-2",children:[l.jsx("span",{className:"lb:font-bold lb:min-w-fit",children:"•"}),l.jsxs("div",{children:[l.jsx("strong",{children:"Cambios pendientes:"})," Recuerda guardar tus cambios antes de cerrar o cambiar de imagen"]})]})]})]})]}),l.jsx("div",{className:"lb:px-6 lb:py-4 lb:border-t lb:border-gray-200 lb:bg-gray-50",children:l.jsx("button",{onClick:()=>O(!1),className:"limbo-btn limbo-btn-primary lb:w-full",children:"Entendido"})})]})}),b&&l.jsx("div",{className:"lb:min-w-[90%] lb:fixed lb:md:absolute lb:inset-0 lb:md:inset-auto lb:bg-black/50 lb:md:bg-transparent lb:flex lb:items-center lb:justify-center lb:md:block lb:z-9999 lb:md:z-50 lb:pointer-events-none",onClick:e=>{e.target===e.currentTarget&&window.innerWidth<768&&(m(!1),p(null))},children:l.jsxs("div",{className:"lb:pointer-events-auto lb:bg-white lb:rounded-lg lb:shadow-2xl lb:border-2 lb:border-brand-blue-800 lb:overflow-hidden lb:flex lb:flex-col lb:max-w-md lb:w-full lb:mx-4 lb:md:mx-0 lb:max-h-[80vh] lb:md:max-h-[600px]",style:{...window.innerWidth>=768?{position:"absolute",left:`${S.x}px`,top:`${S.y}px`,width:"420px",cursor:N?"grabbing":"default"}:{}},onMouseDown:Ze,onTouchStart:lt,children:[l.jsxs("div",{className:"limbo-preview-modal-header lb:px-4 lb:py-3 lb:bg-linear-to-r lb:from-brand-blue-800 lb:to-brand-blue-1000 lb:text-white lb:flex lb:items-center lb:justify-between lb:cursor-grab lb:active:cursor-grabbing lb:select-none",style:{cursor:N?"grabbing":"grab"},children:[l.jsxs("div",{className:"lb:flex lb:items-center lb:gap-2",children:[l.jsx("span",{className:"icon icon-search-white icon--sm"}),l.jsx("h3",{className:"lb:text-sm lb:font-semibold lb:text-white",children:"Vista previa"})]}),l.jsx("button",{onClick:()=>{m(!1),p(null)},className:"lb:flex lb:p-1 lb:hover:bg-white/20 lb:rounded lb:transition-colors lb:cursor-pointer lb:aspect-square lb:min-w-fit lb:min-h-fit","aria-label":"Cerrar vista previa",title:"Cerrar vista previa",children:l.jsx("span",{className:"icon icon-close-small-white icon--sm lb:p-0 lb:m-0 lb:py-auto lb:my-auto lb:mx-auto"})})]}),l.jsx("div",{className:"lb:flex-1 lb:overflow-auto lb:bg-gray-50 lb:p-4",children:f?l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center lb:h-full lb:min-h-[200px]",children:l.jsxs("div",{className:"lb:text-center",children:[l.jsx("div",{className:"lb:animate-spin lb:rounded-full lb:h-12 lb:w-12 lb:border-b-2 lb:border-blue-600 lb:mx-auto lb:mb-3"}),l.jsx("p",{className:"lb:text-sm lb:text-gray-600",children:"Generando vista previa..."})]})}):h?l.jsxs("div",{className:"lb:flex lb:flex-col lb:items-center lb:gap-3",children:[l.jsxs("div",{className:"lb:relative lb:w-full lb:bg-white lb:rounded-lg lb:border lb:border-gray-200 lb:overflow-hidden lb:shadow-sm lb:cursor-zoom-in lb:hover:ring-2 lb:hover:ring-brand-blue-800 lb:transition-all",onClick:()=>A(!0),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),A(!0))},"aria-label":"Click para ver recorte en tamaño completo",title:"Click para ampliar",children:[l.jsx("img",{src:h,alt:"Vista previa del recorte",className:"lb:w-full lb:h-auto lb:object-contain lb:max-h-[400px]"}),l.jsxs("div",{className:"lb:absolute lb:top-2 lb:right-2 lb:bg-black/60 lb:text-white lb:px-2 lb:py-1 lb:rounded lb:text-xs lb:flex lb:items-center lb:gap-1",children:[l.jsx("span",{className:"icon icon-search-white icon--xs"}),l.jsx("span",{children:"Ampliar"})]})]}),l.jsxs("div",{className:"lb:text-center lb:text-xs lb:text-gray-500",children:[l.jsx("p",{className:"lb:font-medium lb:text-gray-700 lb:mb-1",children:J?.label||"Recorte"}),l.jsxs("p",{children:[J?.width," × ",J?.height," px"]})]})]}):l.jsx("div",{className:"lb:flex lb:items-center lb:justify-center lb:h-full lb:min-h-[200px]",children:l.jsx("p",{className:"lb:text-sm lb:text-gray-500",children:"No se pudo generar la vista previa"})})}),l.jsx("div",{className:"lb:px-4 lb:py-2 lb:bg-gray-100 lb:border-t lb:border-gray-200",children:l.jsxs("p",{className:"lb:text-xs lb:text-gray-600 lb:text-center",children:[l.jsxs("span",{className:"lb:hidden lb:md:inline",children:["Arrastra desde el título para mover •"," "]}),"Actualización automática al editar"]})})]})}),l.jsx(Re,{src:h,alt:"Vista previa del recorte",title:J?.label||"Recorte",subtitle:`${J?.width||0} × ${J?.height||0} px`,isOpen:T&&!!h,onClose:()=>A(!1)})]}):null}function _n({onSave:e,onCancel:t,onError:n,onVariantCreated:a,onUploadAndCrop:r,onVideoSelect:i,onUploadWithFolder:o,onFolderChange:s,onDelete:c,isActionAllowed:u,selectedImage:d,uploading:b,uploadError:m,deleting:h,selectedUploadFolder:p,modeUI:f,apiKey:g,prod:v,allowedCategories:y,resolvedAccept:x,returnConfig:w,folderConfig:k,cropperConfig:C,resetUpload:S}){return l.jsxs(l.Fragment,{children:[d&&l.jsx(En,{image:d,onSave:e,onCancel:t,onDelete:d?.id&&u("delete")?()=>c(d.id):null,onError:n,deleting:h,onVariantCreated:a,onUpload:d?.tags?e=>o(e,d.tags):o,uploading:b,cropperConfig:C}),!d&&("crop-only"===f?l.jsxs("div",{children:[b&&l.jsx(lt,{text:"Subiendo archivo..."}),m&&l.jsxs(fe,{variant:"danger",toast:!0,onClose:S,children:["Error al subir archivo: ",m]}),l.jsx(Mt,{onSelect:r,onVideoSelect:i,disabled:b,apiKey:g,prod:v,allowedCategories:y,resolvedAccept:x,returnConfig:w,folderConfig:k,selectedFolder:p,onFolderChange:s})]}):l.jsxs("div",{className:"limbo-empty-state lb:flex lb:flex-col lb:items-center lb:justify-center lb:py-12 lb:px-6 lb:text-center",children:[l.jsx("div",{className:"lb:text-gray-400 lb:mb-4",children:l.jsx("svg",{className:"lb:w-16 lb:h-16 lb:mx-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),l.jsx("p",{className:"lb:text-gray-600 lb:mb-4",children:"Selecciona una imagen de la galería para comenzar a recortar."})]}))]})}function $n({apiKey:t,onClose:n,prod:a=!1,features:r=["gallery","upload","cropper"],modeUI:i="full",ui:o={showActions:["select","download","copy","delete","crop","variants","rename"],hideActions:[],theme:"light",language:"es",compactMode:!1,showTabs:!0},callbacks:c={},instanceId:u=null,itemsPerPage:d=30,_externalImage:b=null,cropperConfig:m=null,folderConfig:h={include:[],exclude:[],includeNoFolder:!0,showFolderSelector:!0,showFolderFilter:!0,showFolderInfo:!0,allowMoveFolder:!0,allowCreateFolder:!0,defaultFolder:null},allowedCategories:p=null,accept:f=null,returnConfig:g=null,aiStarterPrompt:v}){const y=e.useRef(c);e.useEffect(()=>{y.current=c},[c]);const x=e.useRef(null);ie(x,{onClose:n}),e.useEffect(()=>{je(),["limbo_stock_selectedService","limbo_stock_dynamicForm","limbo_stock_stockImages","limbo_stock_currentPage","limbo_stock_paginationInfo","limbo_portals_searchName","limbo_portals_limit","limbo_portals_currentPage","limbo_portals_images","limbo_portals_portalResults","limbo_portals_paginationInfo"].forEach(e=>sessionStorage.removeItem(e))},[]),e.useEffect(()=>{const e=()=>{["limbo_stock_selectedService","limbo_stock_dynamicForm","limbo_stock_stockImages","limbo_stock_currentPage","limbo_stock_paginationInfo","limbo_portals_searchName","limbo_portals_limit","limbo_portals_currentPage","limbo_portals_images","limbo_portals_portalResults","limbo_portals_paginationInfo"].forEach(e=>sessionStorage.removeItem(e)),be(),je()},t=t=>{t.persisted&&e()};let l=null;const n=()=>{"hidden"===document.visibilityState?l=Date.now():"visible"===document.visibilityState&&null!==l&&(Date.now()-l>18e5&&e(),l=null)};return window.addEventListener("pageshow",t),document.addEventListener("visibilitychange",n),()=>{window.removeEventListener("pageshow",t),document.removeEventListener("visibilitychange",n)}},[]);const[w,k]=e.useState({name:"",uploadedBy:"",dateFrom:"",dateTo:"",assetType:"",folder:""}),[C,S]=e.useState(h?.defaultFolder||null),[j,N]=e.useState([]),[E,_]=e.useState(null),z=A(w.name,400),L=A(w.uploadedBy,400),M=e.useMemo(()=>s(f||(p?p.map(e=>`${e}/*`).join(","):null)),[f,p]),I=e=>!!e&&(e.startsWith("image/")&&"image/gif"!==e),P=(()=>{let e;switch(i){case"gallery-only":e=["gallery"];break;case"upload-only":e=["upload","cropper"];break;case"crop-only":e=["cropper"];break;case"ia-only":e=["ia"];break;default:e=[...r]}return M.isAllTypes||M.includesImages||(e=e.filter(e=>"cropper"!==e)),e})(),D=()=>P.includes("gallery")?"gallery":P.includes("upload")?"upload":P.includes("cropper")?"cropper":P.includes("ia")?"ia":P[0]||"gallery",[R,O]=e.useState(D()),[F,U]=e.useState(null),W=e.useRef(null);e.useEffect(()=>{!F&&W.current&&(URL.revokeObjectURL(W.current),W.current=null)},[F]);const[V,H]=e.useState(null);e.useEffect(()=>{b&&(console.log("📸 Imagen externa detectada:",b),U(b),O("cropper"))},[b]),e.useEffect(()=>{const e=()=>{console.log("[App] Modal cerrado, reseteando estado..."),U(null),O(D())};return window.limboCore?.events&&window.limboCore.events.on("modal:closed",e),()=>{window.limboCore?.events&&window.limboCore.events.off("modal:closed",e)}},[]);const[K,G]=e.useState(1),{isTokenExpired:Q,handleTokenExpiredClose:X,handleTokenExpiredReload:Y}=function(){const[t,l]=e.useState(!1),[n,a]=e.useState(!1),r=e.useCallback(async()=>{const e=q();if("jwt"!==e.authMode||!e.tokenProvider)return!1;a(!0);try{return B(await e.tokenProvider()),l(!1),!0}catch{return!1}finally{a(!1)}},[]),i=e.useCallback(e=>{if(401===e?.response?.status){const t=e.response.data;if("token_expired"===t?.error||t?.message?.includes("expired")||t?.message?.includes("caducado")||"string"==typeof t?.error&&t.error.includes("expired"))return l(!0),!0}return!1},[]),o=e.useCallback(()=>{l(!1)},[]),s=e.useCallback(()=>{l(!1),window.location.reload()},[]);return e.useEffect(()=>{const e=e=>{if(!e.detail?.error)return;const t=q();i(e.detail.error)&&("jwt"===t.authMode&&t.tokenProvider&&!e.detail.refreshAttempted?r().then(e=>{e||l(!0)}):l(!0))};return window.addEventListener("tokenExpiredError",e),()=>window.removeEventListener("tokenExpiredError",e)},[i,r]),{isTokenExpired:t,isRefreshing:n,checkTokenExpiration:i,handleTokenExpiredClose:o,handleTokenExpiredReload:s,tryRefreshToken:r}}(),{upload:J,loading:Z,error:le,uploadedImage:ne,reset:ae}=function(){const[t,l]=e.useState(!1),[n,a]=e.useState(null),[r,i]=e.useState(null);return{upload:async(e,t=null,n=null,r=null)=>{if(!e)return a("No se ha proporcionado ningún archivo"),null;l(!0),a(null),i(null);try{const l="object"==typeof n?n?.slug:n,a=await ee(e,t,!1,l,r),o=a.result||a;return i(o),o}catch(o){return a(o.message),null}finally{l(!1)}},loading:t,error:n,uploadedImage:r,reset:()=>{a(null),i(null)}}}(),{deleteImg:re,loading:ce,error:ue,reset:de}=se(),ge=e.useMemo(()=>({limit:d,page:K,...z&&{q:z},...L&&{uploadedBy:L},...w.dateFrom&&{dateFrom:w.dateFrom},...w.dateTo&&{dateTo:w.dateTo},...w.assetType&&{asset_type:w.assetType},...!M.isAllTypes&&M.raw&&{accept:M.raw},...w.folder&&{folder:w.folder},...h.include?.length>0&&{folders_include:h.include.join(",")},...0===h.include?.length&&h.exclude?.length>0&&{folders_exclude:h.exclude.join(",")},...(h.include?.length>0||h.exclude?.length>0)&&void 0!==h.includeNoFolder&&{include_no_folder:h.includeNoFolder?"1":"0"}}),[d,K,z,L,w.dateFrom,w.dateTo,w.assetType,w.folder,M.isAllTypes,M.raw,h.include,h.exclude,h.includeNoFolder]),ve=P.includes("gallery"),{images:ye,loading:xe,error:we,pagination:ke,invalidateCache:Ce,setImages:Ne,refetch:Ee}=me(t,a,ge,ve);e.useEffect(()=>{const e=()=>{Ee()};return document.addEventListener("limbo:variantsCleared",e),document.addEventListener("limbo:variantDeleted",e),()=>{document.removeEventListener("limbo:variantsCleared",e),document.removeEventListener("limbo:variantDeleted",e)}},[Ee]);const{refreshVariants:_e}=he(),$e=e.useCallback((e,t=null)=>J(e,null,C?.slug||C,t),[J,C]),{handleDelete:Te,handleAssetFolderChange:Ae,handleRenameAsset:ze,handleEditAsset:Le,handleVariantCreated:Me}=function({callbacksRef:t,deleteImg:l,evictFromCache:n,invalidateCache:a,refreshVariants:r,images:i,setImages:o,setCurrentPage:s,selectedImage:c,setSelectedImage:u,setActiveTab:d}){return{handleDelete:async e=>{if(!confirm("¿Estás seguro de que deseas eliminar este archivo? Esta acción también eliminará todos sus recortes."))return;const r=i.find(t=>t.id===e);await l(e)&&(r?.url&&n(r.url),a(),s(1),o(t=>t.filter(t=>t.id!==e)),c&&c.id===e&&(u(null),d("gallery")),t.current.onDelete&&t.current.onDelete({assetId:e}))},handleAssetFolderChange:async(e,t)=>{const l=t?.slug||null;try{return await te(e.id,{folder:l}),a(),o(l=>l.map(l=>l.id===e.id?{...l,folder:t??null}:l)),t}catch(n){throw console.error("Error al cambiar carpeta:",n),n}},handleRenameAsset:e.useCallback(async(e,t)=>{const l=await te(e.id,{original_filename:t}),n=l?.result||{};return a(),o(l=>l.map(l=>l.id!==e.id?l:{...l,filename:n.filename??t,...n.url&&{url:n.url},...void 0!==n.url_webp&&{url_webp:n.url_webp}})),l},[a,o]),handleEditAsset:e.useCallback(async(e,{name:t,tags:l})=>{const n=await te(e.id,{original_filename:t,tags:l}),r=n?.result||{};return a(),o(n=>n.map(n=>n.id!==e.id?n:{...n,filename:r.filename??t,tags:r.tags??l,...r.url&&{url:r.url},...void 0!==r.url_webp&&{url_webp:r.url_webp}})),n},[a,o]),handleVariantCreated:(e,t)=>{r(e),o(t=>t.map(t=>t.id===e?{...t,variants_count:(t.variants_count||0)+1}:t)),a()}}}({callbacksRef:y,deleteImg:re,evictFromCache:Se,invalidateCache:Ce,refreshVariants:_e,images:ye,setImages:Ne,setCurrentPage:G,selectedImage:F,setSelectedImage:U,setActiveTab:O}),Ie=e.useCallback(e=>{_(e)},[]),Pe=e.useCallback(async({name:e,tags:t})=>{E&&(await Le(E,{name:e,tags:t}),Ee?.())},[E,Le,Ee]),{handleUploadAndCrop:De,handleVideoSelect:Re}=function({callbacksRef:t,upload:l,refetch:n,activeFeatures:a,setActiveTab:r,setSelectedImage:i,setCurrentPage:o,setSuccessMessage:s,instanceId:c,selectedUploadFolder:u,tempBlobUrlRef:d,uploadTags:b=null}){return{handleUploadAndCrop:async(e,s=null)=>{if(!e.type?.startsWith("image/")||"image/gif"===e.type){const i=u?.slug||u,d=await l(e,null,i,s);return void(d&&(n(),o(1),a.includes("gallery")&&r("gallery"),t.current.onUpload&&t.current.onUpload({assetId:d.id,url:d.url,fileName:d.filename,mime:d.mime_type,width:d.width,height:d.height,instanceId:c})))}const m=URL.createObjectURL(e),h=await new Promise(e=>{const t=new Image;t.onload=()=>{e({width:t.naturalWidth,height:t.naturalHeight}),URL.revokeObjectURL(m)},t.onerror=()=>{e({width:1920,height:1080}),URL.revokeObjectURL(m)},t.src=m}),p=s||b,f={file:e,filename:e.name,mime_type:e.type,url:(()=>{const t=URL.createObjectURL(e);return d.current=t,t})(),width:h.width,height:h.height,tags:p};if(i(f),a.includes("cropper"))r("cropper");else{const a=u?.slug||u,i=await l(e,null,a,s);i&&(n(),o(1),r("gallery"),t.current.onUpload&&t.current.onUpload({assetId:i.id,url:i.url,fileName:i.filename,mime:i.mime_type,width:i.width,height:i.height,instanceId:c}))}},handleVideoSelect:e.useCallback(e=>{const l={...e,instanceId:c};t.current.onSelect&&t.current.onSelect(l),window.limboCore?.events&&window.limboCore.events.emit("select",l),"modal"===((window.limboCore?.config?.getGlobal()||{}).mode||"embed")&&window.limboCore?.modals?.closeAllModals(),s(`Vídeo seleccionado: ${e.title||"Sin título"}`),setTimeout(()=>s(null),3e3)},[c,s])}}({callbacksRef:y,upload:J,refetch:Ee,activeFeatures:P,setActiveTab:O,setSelectedImage:U,setCurrentPage:G,setSuccessMessage:H,instanceId:u,selectedUploadFolder:C,tempBlobUrlRef:W,uploadTags:j}),{handleCropSave:Oe,handleCropCancel:Fe,handleCropError:Ue}=function({callbacksRef:e,selectedImage:t,setSelectedImage:l,setActiveTab:n,setImages:a,setCurrentPage:r,setSuccessMessage:i,invalidateCache:o,refetch:s,evictFromCache:c,instanceId:u,activeFeatures:d,modeUI:b}){const m=()=>"crop-only"===b||1===d.length&&"cropper"===d[0]?"crop-only":d.includes("gallery")?"with-gallery":d.includes("upload")&&!d.includes("gallery")?"upload-only":"with-gallery";return{handleCropSave:d=>{const b=m(),h=window.limboCore?.config?.getGlobal()||{},p=h.mode||"embed",f=h.autoHideOnComplete||!1;let g=[],v=null;d.crops&&d.asset?(g=d.crops,v=d.asset):g=d.crops&&Array.isArray(d.crops)?d.crops:Array.isArray(d)?d:[d],v&&"with-gallery"===b&&(a(e=>[v,...e]),r(1),e.current.onUpload&&e.current.onUpload({assetId:v.id,url:v.url,fileName:v.filename,mime:v.mime_type,width:v.width,height:v.height,instanceId:u})),t?.url&&c(t.url),"with-gallery"===b&&(v?s():o());const y=v||t,x=g.some(e=>!0===e.isLocal),w={crops:g,assetId:y?.id,instanceId:u,localCrops:x,asset:y?{id:y.id,url:y.url||y.urlSigned,width:y.width,height:y.height,filename:y.filename,mime_type:y.mime_type}:null};console.log("[App] handleCropSave - callbackPayload:",w),console.log("[App] handleCropSave - crops:",g),console.log("[App] handleCropSave - crops[0]?.url:",g[0]?.url),console.log("[App] handleCropSave - asset:",w.asset),console.log("[App] handleCropSave - callbacksRef.current.onCropsSaved existe:",!!e.current.onCropsSaved),e.current.onCropsSaved?(console.log("[App] Llamando callbacksRef.current.onCropsSaved..."),e.current.onCropsSaved(w),console.log("[App] callbacksRef.current.onCropsSaved ejecutado")):console.warn("[App] ⚠️ callbacksRef.current.onCropsSaved NO existe"),window.limboCore?.events&&window.limboCore.events.emit("cropsSaved",w);const k=g.length;switch(i(`✅ ${k} recorte${1!==k?"s":""} guardado${1!==k?"s":""} correctamente`),setTimeout(()=>i(null),3e3),b){case"with-gallery":"modal"===p?e.current.onCropsSaved||(window.limboCore?.modals?.closeAllModals(),l(null),n("gallery")):(l(null),n("gallery"));break;case"upload-only":"modal"===p?e.current.onCropsSaved||(window.limboCore?.modals?.closeAllModals(),l(null),n("upload")):(l(null),n("upload"));break;case"crop-only":if("modal"===p)e.current.onCropperComplete&&e.current.onCropperComplete({crops:g,instanceId:u}),window.limboCore?.events&&window.limboCore.events.emit("cropperComplete",{crops:g,instanceId:u}),window.limboCore?.modals?.closeAllModals();else if(e.current.onCropperComplete&&e.current.onCropperComplete({crops:g,instanceId:u}),window.limboCore?.events&&window.limboCore.events.emit("cropperComplete",{crops:g,instanceId:u}),f){const e=document.querySelector(`#limbo-instance-${u}`);e&&(e.style.display="none")}}},handleCropCancel:()=>{const a=m(),r=(window.limboCore?.config?.getGlobal()||{}).mode||"embed";switch(e.current.onCropperCancelled&&e.current.onCropperCancelled({assetId:t?.id,instanceId:u}),window.limboCore?.events&&window.limboCore.events.emit("cropperCancelled",{assetId:t?.id,instanceId:u}),a){case"with-gallery":l(null),n("gallery");break;case"upload-only":"modal"===r?window.limboCore?.modals?.closeAllModals():(l(null),n("upload"));break;case"crop-only":"modal"===r?window.limboCore?.modals?.closeAllModals():window.limboCore?.events&&window.limboCore.events.emit("cropperClosed",{instanceId:u,reason:"cancelled"})}},handleCropError:l=>{e.current.onCropperError&&e.current.onCropperError(l,u),window.limboCore?.events&&window.limboCore.events.emit("cropperError",{error:l,assetId:t?.id,instanceId:u}),console.error("Cropper error:",l)}}}({callbacksRef:y,selectedImage:F,setSelectedImage:U,setActiveTab:O,setImages:Ne,setCurrentPage:G,setSuccessMessage:H,invalidateCache:Ce,evictFromCache:Se,refetch:Ee,instanceId:u,activeFeatures:P,modeUI:i}),Be=e=>!o.hideActions?.includes(e)&&(!!o.showActions?.includes(e)||!(o.showActions?.length>0)),qe=[{id:"gallery",label:"Galería",feature:"gallery"},{id:"upload",label:"Subir",feature:"upload"},{id:"cropper",label:"Recortador",hideNonActive:!0,feature:"cropper"}].filter(e=>P.includes(e.feature)),We=e=>{I(e.mime_type||e.original_mime)?(U(e),P.includes("cropper")&&O("cropper")):console.log("[App] ⚠️ Archivo no recortable:",e.mime_type||e.original_mime,"- saltando cropper")};return l.jsxs("div",{ref:x,className:"limbo-app-root",children:[o.showTabs&&"cropper"!=R&&l.jsx($,{tabs:qe,active:R,onChange:e=>{O(e),"upload"!==e&&ae(),"gallery"!==e&&de()}}),we&&l.jsxs(fe,{variant:"danger",children:["Error al cargar archivos: ",we]}),ue&&l.jsxs(fe,{variant:"danger",children:["Error al eliminar archivo: ",ue]}),V&&l.jsx(fe,{variant:"success",fixed:!0,onClose:()=>H(null),children:V}),"gallery"===R&&l.jsx(nt,{onSelect:e=>{const t=m?.mandatoryCrops?.length>0,l=I(e.mime_type||e.original_mime);if(t&&l&&P.includes("cropper"))return console.log("[App] 📐 MandatoryCrops detectados, navegando al cropper primero"),void We(e);c.onSelect&&c.onSelect({assetId:e.id,url:e.url,fileName:e.filename,mime:e.mime_type,width:e.width,height:e.height,instanceId:u})},onCrop:We,onDelete:Be("delete")?Te:null,onFolderChange:Ae,onRename:ze,onEdit:Ie,onPageChange:e=>{G(e)},onFiltersChange:e=>{k(e),G(1)},images:ye,loadingImages:xe,imagesError:we,deleting:ce,uploadedImage:ne,pagination:ke,currentPage:K,galleryFilters:w,debouncedFilters:{name:z,uploadedBy:L,dateFrom:w.dateFrom,dateTo:w.dateTo,assetType:w.assetType,folder:w.folder},allowedActions:{select:Be("select"),download:Be("download"),copy:Be("copy"),delete:Be("delete"),crop:Be("crop"),rename:Be("rename")},resolvedAccept:M,allowedCategories:p,folderConfig:h,filterConfig:o.galleryFilters||{},loadingConfig:o.galleryLoading||{},resetUpload:ae}),"upload"===R&&l.jsx(It,{onSelect:De,onVideoSelect:Re,onFolderChange:S,uploading:Z,uploadError:le,uploadedImage:ne,selectedUploadFolder:C,apiKey:t,prod:a,allowedCategories:p,resolvedAccept:M,returnConfig:g,folderConfig:h,aiStarterPrompt:v,resetUpload:ae,tags:j,onTagsChange:N}),"cropper"===R&&l.jsx(_n,{onSave:Oe,onCancel:Fe,onError:Ue,onVariantCreated:Me,onUploadAndCrop:De,onVideoSelect:Re,onUploadWithFolder:$e,onFolderChange:S,onDelete:Te,isActionAllowed:Be,selectedImage:F,uploading:Z,uploadError:le,uploadedImage:ne,deleting:ce,selectedUploadFolder:C,modeUI:i,apiKey:t,prod:a,allowedCategories:p,resolvedAccept:M,returnConfig:g,folderConfig:h,cropperConfig:m,resetUpload:ae}),l.jsx(pe,{}),l.jsx(T,{isOpen:Q,onClose:X,onReload:Y}),l.jsx(oe,{isOpen:!!E,asset:E,onClose:()=>_(null),onSave:Pe})]})}class Tn{constructor(e,t,l,n){this.id=e,this.config=t,this.eventManager=l,this.modalManager=n,this.root=null,this.container=null,this.modal=null,this.mounted=!1,this.destroyed=!1,this.button=null,this._handleAppClose=()=>{this.modal&&"function"==typeof this.modal.close&&this.modal.close()},this._validateConfig(),this._initialize()}_initialize(){"embed"===this.config.mode?this.mount():"button"===this.config.mode&&this._createButton(),this._emitDOMEvent("ready",{instance:this,config:this.config,timestamp:Date.now()})}mount(){if(this.mounted||this.destroyed)return this;if(this.container=this._resolveContainer(),!this.container)return this.eventManager.emit("error",{instanceId:this.id,error:"Container not found"}),this;try{this.root=N.createRoot(this.container),this.root.render(this._renderApp()),this.mounted=!0,this.eventManager.emit("ready",{instance:this})}catch(e){this.eventManager.emit("error",{instanceId:this.id,error:e.message})}return this}unmount(){return this.mounted?(this.root&&(this.root.unmount(),this.root=null),"button"===this.config.mode&&this.button,this.mounted=!1,this):this}open(){return"modal"!==this.config.mode&&"button"!==this.config.mode||(this.modal||this._createModal(),this.modal&&!this.modal.isOpened()&&(this.modal.open(),this.eventManager.emit("modal:open",{instance:this}))),this}close(){return this.modal&&this.modal.isOpened()&&(this.eventManager?.emit("modal:close",{instance:this}),this.modal.close()),this}updateConfig(e){return this.config={...this.config,...e},this.mounted&&this.root.render(this._renderApp()),this.eventManager.emit("config:updated",{instance:this,newConfig:e}),this}destroy(){this.destroyed||(this.unmount(),this.modal&&(this.modal.destroy(),this.modal=null),this.button&&this.button.parentNode&&(this.button.parentNode.removeChild(this.button),this.button=null),this.eventManager.emit("destroy",{instance:this}),this.container=null,this.config=null,this.eventManager=null,this.modalManager=null,this.destroyed=!0)}getId(){return this.id}getMode(){return this.config.mode}isMounted(){return this.mounted}isDestroyed(){return this.destroyed}getContainer(){return this.container}getConfig(){return{...this.config}}isContainerInDOM(){return this.container&&document.contains(this.container)}_createModal(){if(this.modalManager&&"modal"===this.config.mode&&(this.modal=this.modalManager.createModal({title:this.config.title||"Limbo Image Manager",size:this.config.modalSize||this.config.modal?.size||"large",usesReactFocusTrap:!0,onOpen:()=>{const e={instance:this,mode:"modal",timestamp:Date.now()};this._emitDOMEvent("modal:open",e),this.config.callbacks?.onOpen&&this.config.callbacks.onOpen(e)},onClose:()=>{const e={instance:this,mode:"modal",timestamp:Date.now()};this._emitDOMEvent("modal:close",e),this.config.callbacks?.onClose&&this.config.callbacks.onClose(e),this.config.autoDestroy&&this.destroy()},onDestroy:()=>{this.modal=null}}),this.modal)){const e=this.modal.getBodyContainer();this.root=N.createRoot(e),this.root.render(this._renderApp()),this.mounted=!0}}_createButton(){if(this.container||(this.container=this._resolveContainer()),!this.container)return void this.eventManager.emit("error",{instanceId:this.id,error:"Container not found for button mode"});const e=document.createElement("button");e.type="button",e.className="limbo-trigger-button",e.textContent=this.config.buttonText||"Abrir Limbo",e.style.cssText="\n background: #001978;\n color: white;\n border: none;\n padding: 10px 20px;\n border-radius: 6px;\n cursor: pointer;\n font-family: inherit;\n font-size: 14px;\n font-weight: 500;\n transition: all 0.2s ease;\n ",e.addEventListener("mouseenter",()=>{e.style.backgroundColor="#334793",e.style.transform="translateY(-1px)"}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor="#001978",e.style.transform="translateY(0)"}),e.addEventListener("click",()=>{this.open()}),this.container.appendChild(e),this.button=e,this.mounted=!0}_resolveContainer(){const{container:e}=this.config;return e?"string"==typeof e?document.querySelector(e):e instanceof Element?e:null:null}_renderApp(){return e.createElement("div",{id:`limbo-component-container-${this.id}`,className:"limbo-scope limbo-instance limbo-component-container-wrapper lb:h-full lb:w-full lb:py-2 lb:pb-0 lb:bg-white","data-limbo-id":this.id,"data-limbo-mode":this.config.mode,"data-limbo-version":"4.2.3","data-limbo-isolated":"true","aria-label":"Limbo Image Manager",role:"region"},e.createElement($n,{onClose:"modal"===this.config.mode?this._handleAppClose:void 0,apiKey:this.config.apiKey||null,publicKey:this.config.publicKey||null,token:this.config.token||null,prod:this.config.prod||!1,url:this.config.url,features:this.config.features,modeUI:this.config.modeUI||"full",ui:this.config.ui,callbacks:this._createCallbacks(),instanceId:this.id,authMode:this.config.authMode||(this.config.publicKey?"session":"manual"),_externalImage:this.config._externalImage||null,cropperConfig:this.config.cropper||null,allowedCategories:this.config.validation?.allowedCategories||null,accept:this.config.validation?.accept||null,returnConfig:this.config.returnConfig||null,aiStarterPrompt:this.config.aiStarterPrompt,folderConfig:this.config.folders||{include:[],exclude:[],includeNoFolder:!0},itemsPerPage:this.config.itemsPerPage||30}))}_createCallbacks(){return{onSelect:e=>{const t=this.config?.callbacks?.onSelect,l=this._createStandardPayload(e,"select");t&&Promise.resolve(t(l)).catch(e=>{console.error("[LimboInstance] Error en onSelect callback:",e)}),this.destroyed||this._emitDOMEvent("select",l)},onUpload:e=>{const t=this.config?.callbacks?.onUpload,l=this._createStandardPayload(e,"upload");t&&Promise.resolve(t(l)).catch(e=>{console.error("[LimboInstance] Error en onUpload callback:",e)}),this.destroyed||this._emitDOMEvent("upload",l)},onError:e=>{const t=this.config?.callbacks?.onError,l={instance:this,error:{message:e.message||"Unknown error",code:e.code||"UNKNOWN",timestamp:Date.now()}};t&&t(l.error),this.destroyed||this._emitDOMEvent("error",l)},onClose:()=>{const e=this.config?.callbacks?.onClose,t={instance:this,timestamp:Date.now()};e&&e(),this.destroyed||this._emitDOMEvent("close",t)},onCropsSaved:e=>{console.log("[LimboInstance] onCropsSaved recibido:",e),console.log("[LimboInstance] this.config?.callbacks:",this.config?.callbacks);const t=this.config?.callbacks?.onCropsSaved;console.log("[LimboInstance] userCallback existe:",!!t);const l={instance:this,eventType:"cropsSaved",timestamp:Date.now(),instanceId:this.id,...e};if(console.log("[LimboInstance] payload.crops:",l.crops),t){console.log("[LimboInstance] Llamando userCallback onCropsSaved");try{t(l),console.log("[LimboInstance] userCallback ejecutado correctamente")}catch(n){console.error("[LimboInstance] Error en userCallback:",n)}}else console.warn("[LimboInstance] ⚠️ userCallback onCropsSaved NO existe");this.destroyed||this._emitDOMEvent("cropsSaved",l)},onCropperComplete:e=>{console.log("[LimboInstance] onCropperComplete recibido:",e);const t=this.config?.callbacks?.onCropperComplete,l={instance:this,eventType:"cropperComplete",timestamp:Date.now(),instanceId:this.id,...e};t&&(console.log("[LimboInstance] Llamando userCallback onCropperComplete"),t(l)),this.destroyed||this._emitDOMEvent("cropperComplete",l)}}}_createStandardPayload(e,t){const l={instance:this,eventType:t,timestamp:Date.now(),instanceId:this.id,mode:this.config?.mode,features:this.config?.features};return e&&(e.assetId||e.id?(l.assetId=e.assetId||e.id,l.variants=e.variants||[],l.master=e.master||{urlSigned:e.url||e.urlSigned,width:e.width,height:e.height,mime:e.mime||e.mimeType},l.fileName=e.fileName||e.name,l.mime=e.mime||e.mimeType,l.width=e.width,l.height=e.height,l.fileBlob=e.fileBlob||e.file,l.metadata={uploadedBy:e.uploadedBy,uploadedAt:e.uploadedAt||e.timestamp,size:e.size,...e.metadata}):Object.assign(l,e)),l}_emitDOMEvent(e,t){if(this.destroyed)return;const l=new CustomEvent(`limbo:${e}`,{detail:t,bubbles:!0,cancelable:!0});(this.getContainer()||document).dispatchEvent(l),this.eventManager?.emit(e,t)}_validateConfig(){const e=q();if(!(this.config.auth?.apiKey||this.config.auth?.publicKey||this.config.auth?.token||this.config.apiKey||this.config.publicKey||this.config.token||this.config.tokenProvider||this.config.auth?.tokenProvider||e.token||e.publicKey||e.tokenProvider))throw new Error(`LimboInstance ${this.id}: Authentication is required. Provide either auth.publicKey (recommended), auth.apiKey (for server-side only), token, or tokenProvider`);if((this.config.auth?.apiKey||this.config.apiKey)&&"undefined"!=typeof window&&console.warn("⚠️ SECURITY WARNING: API Key detected in client-side code.\nThis is a security risk! Use publicKey instead for client applications.\nAPI Keys should only be used in server-side environments."),!["embed","modal","button"].includes(this.config.mode))throw new Error(`LimboInstance ${this.id}: invalid mode ${this.config.mode}`);if("embed"===this.config.mode&&!this.config.container)throw new Error(`LimboInstance ${this.id}: container is required for embed mode`);if("button"===this.config.mode&&!this.config.container)throw new Error(`LimboInstance ${this.id}: container is required for button mode`)}}class An{constructor(){this.instances=new Map,this.counter=0}create(e,t,l){const n="limbo-"+ ++this.counter,a=new Tn(n,e,t,l);return this.instances.set(n,a),a}get(e){return this.instances.get(e)}getAll(){return Array.from(this.instances.values())}getActive(){return this.getAll().filter(e=>e.isMounted())}destroy(e){const t=this.instances.get(e);return!!t&&(t.destroy(),this.instances.delete(e),!0)}destroyAll(){this.instances.forEach(e=>e.destroy()),this.instances.clear()}cleanupOrphans(){const e=[];return this.instances.forEach((t,l)=>{t.isContainerInDOM()||e.push(l)}),e.forEach(e=>this.destroy(e)),e.length}getStats(){const e=this.getAll();return{total:e.length,active:e.filter(e=>e.isMounted()).length,embed:e.filter(e=>"embed"===e.getMode()).length,modal:e.filter(e=>"modal"===e.getMode()).length,button:e.filter(e=>"button"===e.getMode()).length}}}class zn{constructor(){this.config=null,this.instances=new Map,this.observer=null,this.initialized=!1}configure(e,t,l){return this.config={selector:e.selector||null,dataset:e.dataset||"data-limbo-input-file",return:e.return||e.returnType||"json",mode:e.mode||"modal",features:e.features||["gallery","upload","cropper"],crop:e.crop||"free",quality:e.quality||.9,format:e.format||"webp",modeUI:e.modeUI||"full",modalSize:e.modalSize||"fullscreen",theme:e.theme||"light",compact:e.compact||!1,maxSize:e.maxSize||"10MB",formats:e.formats||["jpg","jpeg","png","svg","webp"],minWidth:e.minWidth||null,minHeight:e.minHeight||null,maxWidth:e.maxWidth||null,maxHeight:e.maxHeight||null,buttonText:e.buttonText||"Seleccionar archivo",buttonClass:e.buttonClass||"limbo-auto-button",buttonStyle:e.buttonStyle||"primary",showPreview:!1!==e.showPreview,allowMultiple:e.allowMultiple||!1,autoAssign:!1!==e.autoAssign,localCropsOnly:e.localCropsOnly||!1,...e},this.configManager=t,this.eventManager=l,this._initialize(),this}cleanup(){this.observer&&(this.observer.disconnect(),this.observer=null),this.instances.forEach(({input:e,button:t})=>{this._restoreInput(e,t)}),this.instances.clear(),this.config=null,this.initialized=!1}getStats(){return{configured:null!==this.config,totalInputs:this.instances.size,dataset:this.config?.dataset,returnType:this.config?.return}}_initialize(){this.initialized||(this._scanExistingInputs(),this._setupObserver(),this.initialized=!0,this.eventManager.emit("autoInputs:initialized",{config:this.config,inputsFound:this.instances.size}))}_scanExistingInputs(){const e=this.config.selector||`input[${this.config.dataset}]`;document.querySelectorAll(e).forEach(e=>this._processInput(e))}_processInput(e){const t=this._getInputId(e);if(this.instances.has(t))return;if(!this._validateInput(e))return;const l=this._createButton(e);this._hideInput(e),this._insertButton(e,l),this.instances.set(t,{input:e,button:l,config:this._getInputConfig(e)}),this.eventManager.emit("autoInputs:processed",{inputId:t,input:e,button:l})}_createButton(e){const t=document.createElement("button"),l=this._getInputConfig(e);t.type="button";const n=e.dataset.buttontext||e.getAttribute("data-limbo-button-text")||null;t.textContent=n||u(l.accept||null,!1);const a=[this.config.buttonClass];return l.buttonClass&&l.buttonClass!==this.config.buttonClass&&a.push(l.buttonClass),t.className=a.join(" "),this._styleButton(t,l),this._attachButtonEvents(t,e),t.setAttribute("aria-label",l.buttonText||this.config.buttonText),t.setAttribute("data-limbo-trigger","true"),t.setAttribute("data-limbo-input-id",l.inputId),l.disabled&&(t.disabled=!0),t}_styleButton(e,t){const l=t.buttonStyle||this.config.buttonStyle,n=t.theme||this.config.theme,a=t.compact||this.config.compact,r={border:"none",borderRadius:"8px",cursor:"pointer",fontFamily:"inherit",fontSize:a?"12px":"14px",fontWeight:"500",transition:"all 0.2s ease",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:a?"6px 12px":"8px 16px",textDecoration:"none",userSelect:"none"},i={primary:{backgroundColor:"dark"===n?"#3b82f6":"#001978",color:"white",hoverBg:"dark"===n?"#2563eb":"#334793"},secondary:{backgroundColor:"dark"===n?"#374151":"#f3f4f6",color:"dark"===n?"#f9fafb":"#374151",border:"1px solid "+("dark"===n?"#4b5563":"#d1d5db"),hoverBg:"dark"===n?"#4b5563":"#e5e7eb"},outline:{backgroundColor:"transparent",color:"dark"===n?"#3b82f6":"#001978",border:"2px solid "+("dark"===n?"#3b82f6":"#001978"),hoverBg:"dark"===n?"#3b82f6":"#001978",hoverColor:"white"},ghost:{backgroundColor:"transparent",color:"dark"===n?"#f9fafb":"#374151",hoverBg:"dark"===n?"#374151":"#f3f4f6"}},o=i[l]||i.primary;Object.assign(e.style,{...r,...o});const s=o.backgroundColor,c=o.color;e.addEventListener("mouseenter",()=>{e.style.backgroundColor=o.hoverBg||o.backgroundColor,o.hoverColor&&(e.style.color=o.hoverColor),e.style.transform="translateY(-1px)",e.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor=s,e.style.color=c,e.style.transform="translateY(0)",e.style.boxShadow="none"}),t.disabled&&(e.style.opacity="0.5",e.style.cursor="not-allowed")}_attachButtonEvents(e,t){e.addEventListener("click",e=>{e.preventDefault(),this._handleButtonClick(t)})}_handleButtonClick(e){const t=this._getInputConfig(e),l=this._createModalConfig(t);this.eventManager.emit("autoInputs:modalRequest",{input:e,config:l,callback:async t=>await this._handleImageSelection(e,t)})}async _handleImageSelection(e,t){const l=this._getInputConfig(e);let n=t;try{if(!t.original&&!t.images&&(t.id||t.assetId)){console.log("[AutoInputManager] 🔗 Selección directa detectada, obteniendo URL permanente...");const e=t.id||t.assetId;try{const l=await async function(e,t=!0,l=!0,n=0){try{const a=new URLSearchParams({include_variants:t.toString(),include_metadata:l.toString(),url_expires:n.toString()});return G(await W({endpoint:`/assets/${e}?${a}`,method:"GET",basePath:J,useJWT:!0}))}catch(a){throw Y(a)}}(e,!1,!1,!0);l?.result?.url?(console.log("[AutoInputManager] ✅ URL permanente obtenida:",l.result.url),n={original:{url:l.result.url,width:l.result.width||t.width,height:l.result.height||t.height,assetId:e},images:[]}):(console.warn("[AutoInputManager] ⚠️ No se pudo obtener URL permanente, usando URL temporal"),n={original:{url:t.url||t.path,width:t.width,height:t.height,assetId:e},images:[]})}catch(a){console.error("[AutoInputManager] Error obteniendo URL permanente:",a),n={original:{url:t.url||t.path,width:t.width,height:t.height,assetId:e},images:[]}}}const r=await this._formatImageData(n,l);console.log("[AutoInputManager] Valor formateado:",r),console.log("[AutoInputManager] Tipo de valor:",typeof r),!1!==l.autoAssign&&(e.value=r,console.log("[AutoInputManager] Valor asignado al input:",e.value)),this._updateButtonFeedback(e,n),e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:resultReady",{detail:{imageData:n,input:e,value:r,config:l,assignment:{format:l.return,smartAssign:!1!==l.smartAssign,autoAssign:!1!==l.autoAssign},legacy:{imageData:n,formatted:this._createFormattedResult(n,l)}},bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:imageSelected",{detail:{imageData:n,input:e,value:r,config:l,formatted:this._createFormattedResult(n,l)},bubbles:!0})),this.eventManager.emit("autoInputs:imageSelected",{input:e,imageData:n,value:r,config:l})}catch(r){console.error("Error handling image selection:",r),e.dispatchEvent(new CustomEvent("limbo:error",{detail:{error:r.message,input:e,imageData:n,config:l},bubbles:!0})),this._handleImageSelectionLegacy(e,t)}}_updateButtonFeedback(e,t){const l=this._getInputId(e),n=this.instances.get(l);if(!n||!n.button)return;const a=n.button,r=a.nextElementSibling;r&&r.classList.contains("limbo-button-feedback")&&r.remove();const i=document.createElement("span");i.className="limbo-button-feedback",i.style.cssText="\n display: inline-flex;\n align-items: center;\n gap: 6px;\n margin-left: 8px;\n padding: 4px 8px;\n background: #10b981;\n color: white;\n border-radius: 6px;\n font-size: 12px;\n font-weight: 500;\n animation: limbo-fade-in 0.3s ease-out;\n ";const o=t.images&&t.images.length>0,s=o?t.images.length:0;for(;i.firstChild;)i.removeChild(i.firstChild);i.appendChild(function(){const e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"svg");t.setAttribute("width","14"),t.setAttribute("height","14"),t.setAttribute("viewBox","0 0 20 20"),t.setAttribute("fill","currentColor");const l=document.createElementNS(e,"path");return l.setAttribute("fill-rule","evenodd"),l.setAttribute("d","M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"),l.setAttribute("clip-rule","evenodd"),t.appendChild(l),t}());const c=document.createElement("span");c.textContent=o?`${s} recorte${1!==s?"s":""} configurado${1!==s?"s":""}`:"Archivo seleccionado",i.appendChild(c),a.parentNode.insertBefore(i,a.nextSibling);let d=a.parentNode.querySelector(".limbo-powered-by");if(!d){d=document.createElement("div"),d.className="limbo-powered-by";const e=document.createElement("span");e.style.cssText="display:block;margin-top:2px;font-size:10px;color:#aaa;text-align:left;font-family:inherit;opacity:0.7;",e.textContent="Powered by ";const t=document.createElement("b");t.textContent="Limbo",e.appendChild(t),d.appendChild(e),a.parentNode.insertBefore(d,i.nextSibling)}a.style.backgroundColor="#10b981";const b=n.config?.accept||null;a.textContent=u(b,!0)}async _handleImageSelectionLegacy(e,t){const l=this._getInputConfig(e),n=await this._formatImageData(t,l);!1!==l.autoAssign&&(e.value=n),e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:imageSelected",{detail:{imageData:t,input:e,value:n,config:l,formatted:this._createFormattedResult(t,l)},bubbles:!0})),this.eventManager.emit("autoInputs:imageSelected",{input:e,imageData:t,value:n,config:l})}_createFormattedResult(e,t){return{url:e.url||e.path||"",base64:e.base64||e.dataUrl||"",assetId:e.assetId||e.id||"",fileName:e.fileName||e.filename||"",object:{url:e.url||e.path,assetId:e.assetId||e.id,fileName:e.fileName||e.filename,mime:e.mime||e.mime_type,width:e.width,height:e.height,size:e.size||e.file_size,created:e.created_at||e.created,metadata:e.metadata||{}},json:JSON.stringify({url:e.url||e.path,assetId:e.assetId||e.id,fileName:e.fileName||e.filename,mime:e.mime||e.mime_type,width:e.width,height:e.height,size:e.size||e.file_size}),metadata:{width:e.width,height:e.height,size:e.size||e.file_size,format:e.format||e.mime_type,quality:t.quality||this.config.quality,aspectRatio:e.width&&e.height?e.width/e.height:null}}}async _formatImageData(e,t=null){const l=(t||{}).return||this.config.return||"json",n=void 0!==e.original;switch(l){case"url":return n?e.images?.[0]?.url||e.original?.url||"":e.url||e.path||"";case"base64":return e.base64||e.dataUrl||"";case"assetId":return n?e.original?.assetId||"":e.assetId||e.id||"";case"fileName":return e.fileName||e.filename||"";default:try{if(n){const t={original:e.original?{url:e.original.url||e.original.urlSigned,width:e.original.width,height:e.original.height,assetId:e.original.assetId||e.original.id}:null,images:Array.isArray(e.images)?e.images.map(e=>{const t={url:e.url||e.urlSigned,width:e.width,height:e.height,name:e.name||e.filename||e.label};return e.cropState&&(t.cropState={selectorState:e.cropState.selectorState||null,imageTransform:e.cropState.imageTransform||null,flipState:e.cropState.flipState||null}),t}):[]};console.log("[AutoInputManager] Datos limpios para JSON:",t);const l=JSON.stringify(t);return console.log("[AutoInputManager] JSON generado:",l),l}const t={original:{url:e.url||e.path,width:e.width,height:e.height,assetId:e.assetId||e.id}};return console.log("[AutoInputManager] Datos legacy para JSON:",t),JSON.stringify(t)}catch(a){return console.error("[AutoInputManager] Error al serializar JSON:",a),console.error("[AutoInputManager] imageData problemático:",e),"{}"}}}_createModalConfig(e){return{mode:e.mode||this.config.mode||"modal",modeUI:e.modeUI||this.config.modeUI||"full",features:e.features||this.config.features,modalSize:e.modalSize||this.config.modalSize||"fullscreen",title:e.description||this.config.title||"Seleccionar archivo",cropper:this._getCropperConfig(e),ui:{showActions:this._getUIActions(e),hideActions:[],showTabs:this._shouldShowTabs(e),theme:e.theme||this.config.theme,compact:e.compact||this.config.compact,showPreview:void 0!==e.showPreview?e.showPreview:this.config.showPreview},validation:{accept:e.accept||null,maxSize:e.maxSize||this.config.maxSize,formats:e.formats||this.config.formats,minWidth:e.minWidth||this.config.minWidth,minHeight:e.minHeight||this.config.minHeight,maxWidth:e.maxWidth||this.config.maxWidth,maxHeight:e.maxHeight||this.config.maxHeight,required:e.required||!1},behavior:{allowMultiple:e.allowMultiple||this.config.allowMultiple,closeOnSelect:!0,autoAssign:void 0!==e.autoAssign?e.autoAssign:this.config.autoAssign,allowSelectNew:!1!==e.allowSelectNew},initialImageUrl:e.initialImageUrl||null,existingCrops:e.existingCrops||null,existingData:e.existingData||null,returnConfig:{format:e.return||this.config.return,quality:e.quality||this.config.quality,outputFormat:e.format||this.config.format},inputMeta:{inputId:e.inputId,inputName:e.inputName,inputType:e.inputType,placeholder:e.placeholder}}}_getCropperConfig(e){const t=e.crop||this.config.crop,l={quality:e.quality||this.config.quality,format:e.format||this.config.format,mandatoryCrops:e.mandatoryCrops||[],allowAdditionalCrops:!1!==e.allowAdditionalCrops,maxCrops:e.maxCrops||null,localCropsOnly:e.localCropsOnly??this.config.localCropsOnly??!1,existingCrops:e.existingCrops||null};if(e.mandatoryCrops&&e.mandatoryCrops.length>0)return{...l,aspectRatio:null};if(!t||"none"===t||"false"===t)return null;if("free"===t)return{...l,aspectRatio:null};const n={"1:1":1,"16:9":16/9,"4:3":4/3,"3:2":1.5,"2:1":2,square:1,landscape:16/9,portrait:3/4};if(n[t])return{...l,aspectRatio:n[t],minCropBoxWidth:e.minWidth||this.config.minWidth,minCropBoxHeight:e.minHeight||this.config.minHeight};if("string"==typeof t&&t.includes(":")){const[e,n]=t.split(":").map(Number);if(!isNaN(e)&&!isNaN(n)&&0!==n)return{...l,aspectRatio:e/n}}const a=parseFloat(t);return!isNaN(a)&&a>0?{...l,aspectRatio:a}:"object"==typeof t?{...l,...t}:null}_shouldShowTabs(e){const t=e.modeUI||this.config.modeUI||"full",l=e.features||this.config.features;return!["gallery-only","upload-only","crop-only","ia-only"].includes(t)&&(l&&l.length>1)}_getUIActions(e){const t=e.modeUI||this.config.modeUI||"full",l=e.features||this.config.features;let n=[];switch(t){case"gallery-only":case"upload-only":n=["select"];break;case"crop-only":n=["select","crop"];break;default:n=["select"],l.includes("cropper")&&n.push("crop"),l.includes("gallery")&&(n.push("download","copy","rename"),this.config.allowDelete&&n.push("delete"))}return n}_getInputId(e){if(e.id)return e.id;if(e.name)return e.name;let t=e.getAttribute("data-limbo-uid");return t||(t=`limbo-auto-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,e.setAttribute("data-limbo-uid",t)),t}_validateInput(e){return e instanceof HTMLInputElement}_getInputConfig(e){const t=e=>e?e.split(",").map(e=>e.trim()):null,l=e=>{if(!e)return null;const t=e.match(/^(\d+(?:\.\d+)?)(MB|KB|B)?$/i);if(!t)return null;const l=parseFloat(t[1]);switch((t[2]||"B").toUpperCase()){case"MB":return 1024*l*1024;case"KB":return 1024*l;default:return l}},n=(e,t=!1)=>null===e?t:"true"===e||"1"===e||""===e,a=e=>e?parseFloat(e):null,r=e=>{if(!e)return null;try{return JSON.parse(e)}catch(t){return console.warn("[Limbo AutoInputManager] Error parsing JSON attribute:",t),null}},i=r(e.dataset.mandatorycrops)||r(e.dataset.mandatoryCrops)||r(e.getAttribute("data-mandatory-crops"))||r(e.getAttribute("data-limbo-mandatory-crops"))||null;return{return:e.dataset.returntype||e.getAttribute("data-limbo-return")||this.config.return,mode:e.dataset.mode||e.getAttribute("data-limbo-mode")||this.config.mode,features:t(e.dataset.features)||t(e.getAttribute("data-limbo-features"))||this.config.features,crop:e.dataset.crop||e.getAttribute("data-limbo-crop")||this.config.crop,quality:a(e.dataset.quality)||a(e.getAttribute("data-limbo-quality"))||this.config.quality,format:e.dataset.format||e.getAttribute("data-limbo-format")||this.config.format,modeUI:e.dataset.modeui||e.dataset.modeUI||e.getAttribute("data-limbo-mode-ui")||this.config.modeUI,modalSize:e.dataset.modalsize||e.getAttribute("data-limbo-modal-size")||this.config.modalSize,theme:e.dataset.theme||e.getAttribute("data-limbo-theme")||this.config.theme,compact:n(e.dataset.compact,null)??n(e.getAttribute("data-limbo-compact"),this.config.compact),maxSize:l(e.getAttribute("data-limbo-max-size"))||l(this.config.maxSize),formats:t(e.getAttribute("data-limbo-formats"))||this.config.formats,minWidth:a(e.getAttribute("data-limbo-min-width"))||this.config.minWidth,minHeight:a(e.getAttribute("data-limbo-min-height"))||this.config.minHeight,maxWidth:a(e.getAttribute("data-limbo-max-width"))||this.config.maxWidth,maxHeight:a(e.getAttribute("data-limbo-max-height"))||this.config.maxHeight,buttonText:e.dataset.buttontext||e.getAttribute("data-limbo-button-text")||this.config.buttonText,buttonStyle:e.dataset.buttonstyle||e.getAttribute("data-limbo-button-style")||this.config.buttonStyle,buttonClass:e.dataset.buttonclass||e.getAttribute("data-limbo-button-class")||this.config.buttonClass,showPreview:n(e.getAttribute("data-limbo-show-preview"),this.config.showPreview),allowMultiple:n(e.getAttribute("data-limbo-allow-multiple"),this.config.allowMultiple),autoAssign:n(e.getAttribute("data-limbo-auto-assign"),this.config.autoAssign),placeholder:e.getAttribute("data-limbo-placeholder"),description:e.getAttribute("data-limbo-description"),required:n(e.getAttribute("data-limbo-required"),!1),disabled:n(e.getAttribute("data-limbo-disabled"),!1),inputId:this._getInputId(e),inputName:e.name,inputType:e.type,mandatoryCrops:i,allowAdditionalCrops:n(e.dataset.allowadditionalcrops,null)??n(e.getAttribute("data-limbo-allow-additional-crops"),!0),maxCrops:a(e.dataset.maxcrops)||a(e.getAttribute("data-limbo-max-crops"))||null,accept:e.dataset.accept||e.getAttribute("data-limbo-accept")||null,allowSelectNew:n(e.dataset.allowselectnew,null)??n(e.getAttribute("data-limbo-allow-select-new"),!0),...this._parseExistingInputValue(e.value)}}_parseExistingInputValue(e){if(!e||""===e.trim())return{initialImageUrl:null,existingCrops:null,existingData:null};try{const t=JSON.parse(e);return t.original&&t.original.url?(console.log("[AutoInputManager] Valor existente parseado:",t),{initialImageUrl:t.original.url,existingCrops:t.images||null,existingData:t}):t.url?{initialImageUrl:t.url,existingCrops:null,existingData:t}:{initialImageUrl:null,existingCrops:null,existingData:t}}catch(t){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")?{initialImageUrl:e,existingCrops:null,existingData:null}:{initialImageUrl:null,existingCrops:null,existingData:null}}}_generateInputId(){return`limbo-auto-input-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}_hideInput(e){e.style.display="none"}_insertButton(e,t){e.parentNode.insertBefore(t,e.nextSibling)}_restoreInput(e,t){e.style.display="",t&&t.parentNode&&t.parentNode.removeChild(t)}_setupObserver(){this.observer=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&this._scanNodeForInputs(e)})})}),this.observer.observe(document.body,{childList:!0,subtree:!0})}_scanNodeForInputs(e){const t=this.config.selector||`input[${this.config.dataset}]`;e.matches&&e.matches(t)&&this._processInput(e);const l=e.querySelectorAll&&e.querySelectorAll(t);l&&l.forEach(e=>this._processInput(e))}}class Ln{constructor(){this.listeners=new Map}emit(e,t={}){this._emitDOMEvent(e,t),this._executeListeners(e,t)}on(e,t){return this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),()=>this.off(e,t)}off(e,t){const l=this.listeners.get(e);if(l){const e=l.indexOf(t);e>-1&&l.splice(e,1)}}cleanup(){this.listeners.clear()}_emitDOMEvent(e,t){const l=new CustomEvent(`limbo:${e}`,{detail:{...t,timestamp:Date.now()},bubbles:!0,cancelable:!0});(t.instance?.getContainer()||document).dispatchEvent(l)}_executeListeners(e,t){const l=this.listeners.get(e);l&&l.forEach(l=>{try{l(t)}catch(n){console.error(`Error executing listener for ${e}:`,n)}})}getStats(){const e={};return this.listeners.forEach((t,l)=>{e[l]=t.length}),e}}class Mn{constructor(){this.activeModals=new Set,this.zIndexBase=1e4,this.focusableSelectors=["button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"]):not([disabled])',"a[href]"].join(", "),this.initialized=!1,this._initGlobalListeners()}createModal(e){const t=new In(this._generateModalId(),e,this);return this.activeModals.add(t),t}closeModal(e){const t=this._findModal(e);return!!t&&(t.close(),!0)}closeAllModals(){this.activeModals.forEach(e=>e.close()),this.activeModals.clear()}getActiveModal(){return Array.from(this.activeModals).pop()||null}getStats(){return{active:this.activeModals.size,nextZIndex:this._getNextZIndex()}}_generateModalId(){return`limbo-modal-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}_findModal(e){return Array.from(this.activeModals).find(t=>t.getId()===e)}_getNextZIndex(){return this.zIndexBase+10*this.activeModals.size}_removeModal(e){this.activeModals.delete(e),window.limboCore?.events&&window.limboCore.events.emit("modal:closed",{modalId:e.getId(),remainingModals:this.activeModals.size})}_handleGlobalKeydown(e){const t=this.getActiveModal();t&&(t.config&&t.config.usesReactFocusTrap||("Escape"===e.key&&(e.preventDefault(),t.close()),"Tab"===e.key&&this._handleTabTrap(e,t)))}_handleTabTrap(e,t){const l=t.getFocusableElements();if(0===l.length)return;const n=l[0],a=l[l.length-1];e.shiftKey?document.activeElement===n&&(e.preventDefault(),a.focus()):document.activeElement===a&&(e.preventDefault(),n.focus())}_initGlobalListeners(){this.initialized||(this.globalKeydownHandler=e=>this._handleGlobalKeydown(e),document.addEventListener("keydown",this.globalKeydownHandler),this.initialized=!0)}destroy(){this.closeAllModals(),this.initialized&&this.globalKeydownHandler&&(document.removeEventListener("keydown",this.globalKeydownHandler),this.initialized=!1,this.globalKeydownHandler=null)}}class In{constructor(e,t,l){this.id=e,this.config={title:t.title||"Limbo",content:t.content||null,showCloseButton:!1!==t.showCloseButton,backdrop:!1!==t.backdrop,keyboard:!1!==t.keyboard,focus:!1!==t.focus,animation:!1!==t.animation,size:t.size||"large",onOpen:t.onOpen||null,onClose:t.onClose||null,onDestroy:t.onDestroy||null,...t,usesReactFocusTrap:t.usesReactFocusTrap||!1},this.manager=l,this.element=null,this.backdrop=null,this.isOpen=!1,this.previousFocus=null,this._previousInertSiblings=[],this._create()}_create(){this._createBackdrop(),this._createModal(),this._attachEvents()}_createBackdrop(){this.config.backdrop&&(this.backdrop=document.createElement("div"),this.backdrop.className="limbo-modal-backdrop",this.backdrop.style.cssText=`\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.5);\n z-index: ${this.manager._getNextZIndex()};\n opacity: 0;\n transition: opacity 0.3s ease;\n `,this.backdrop.addEventListener("click",e=>{e.target===this.backdrop&&this.close()}))}_createModal(){this.element=document.createElement("div"),this.element.className=`limbo-scope limbo-modal limbo-modal--${this.config.size}`,this.element.id=this.id,this.element.setAttribute("role","dialog"),this.element.setAttribute("aria-modal","true"),this.element.setAttribute("aria-labelledby",`${this.id}-title`),this.element.tabIndex=-1;const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t={small:e?"width: 100%; height: 100%;":"max-width: 500px; min-height: 400px;",medium:e?"width: 100%; height: 100%;":"max-width: 800px; min-height: 500px;",large:e?"width: 100%; height: 100%;":"max-width: 1400px; min-height: 700px;",xlarge:e?"width: 100%; height: 100%;":"max-width: 95dvw; min-height: 85vh;",fullscreen:"width: 100%; height: 100%; max-width: 100%; max-height: 100%; border-radius: 0;"},l="fullscreen"===this.config.size,n=e||l?`\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n transform: ${e?"translateY(100%)":"scale(0.95)"};\n width: 100%;\n height: 100%;\n max-width: none;\n max-height: none;\n border-radius: 0;\n background: white;\n z-index: ${this.manager._getNextZIndex()+1};\n opacity: ${e?"1":"0"};\n transition: ${e?"transform":"all"} 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n padding-top: env(safe-area-inset-top);\n padding-left: env(safe-area-inset-left);\n padding-right: env(safe-area-inset-right);\n padding-bottom: env(safe-area-inset-bottom);\n `:`\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%) scale(0.8);\n ${t[this.config.size]}\n width: 90%;\n max-height: 90vh;\n background: white;\n border-radius: 16px;\n box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);\n z-index: ${this.manager._getNextZIndex()+1};\n opacity: 0;\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n `;this.element.style.cssText=n,this._createHeader(),this._createBody(),document.body.appendChild(this.backdrop),document.body.appendChild(this.element)}_createHeader(){const e=document.createElement("div");e.className="limbo-modal-header";const t=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e.style.cssText=`\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: ${t?"16px 20px":"20px 24px"};\n border-bottom: 1px solid #e9ecef;\n background: #f8f9fa;\n ${t?"position: sticky; top: 0; z-index: 10;":""}\n min-height: ${t?"60px":"auto"};\n `;const l=document.createElement("h2");if(l.id=`${this.id}-title`,l.className="limbo-modal-title",l.textContent=this.config.title,l.style.cssText="\n margin: 0;\n font-size: 18px;\n font-weight: 600;\n color: #001978;\n flex: 1;\n margin-right: 16px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n ",e.appendChild(l),this.config.showCloseButton){const l=document.createElement("button");l.type="button",l.className="limbo-modal-close",l.textContent="✕",l.setAttribute("aria-label","Cerrar modal"),l.style.cssText=`\n background: none;\n border: none;\n font-size: ${t?"28px":"24px"};\n color: #6c757d;\n cursor: pointer;\n padding: ${t?"8px":"4px"};\n border-radius: 4px;\n transition: all 0.2s ease;\n min-width: ${t?"44px":"auto"};\n min-height: ${t?"44px":"auto"};\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n `,l.addEventListener("mouseenter",()=>{l.style.backgroundColor="#f8f9fa",l.style.color="#001978"}),l.addEventListener("mouseleave",()=>{l.style.backgroundColor="transparent",l.style.color="#6c757d"}),l.addEventListener("click",()=>this.close()),e.appendChild(l)}this.element.appendChild(e)}_createBody(){const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t=document.createElement("div");t.className="limbo-modal-body",t.id=`${this.id}-body`,t.style.cssText=`\n flex: 1;\n overflow-y: auto;\n padding: 0;\n -webkit-overflow-scrolling: touch;\n ${e?"height: 100%; overscroll-behavior: contain;":""}\n `,this.config.content instanceof Element&&t.appendChild(this.config.content),this.element.appendChild(t)}_attachEvents(){this._originalBodyOverflow=document.body.style.overflow}open(){if(this.isOpen)return this;window.limbo&&window.limbo.core&&window.limbo.core.keyboard?(window.limbo.core.keyboard.pushFocus(document.activeElement),window.limbo.core.keyboard.setActiveModal(this.element)):this.previousFocus=document.activeElement,document.body.style.overflow="hidden",this._applyInertToSiblings();const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t="fullscreen"===this.config.size;return requestAnimationFrame(()=>{this.backdrop&&(this.backdrop.style.opacity="1"),this.element.style.opacity="1",this.element.style.transform=e?"translateY(0%)":t?"scale(1)":"translate(-50%, -50%) scale(1)"}),this.isOpen=!0,this.config.focus&&setTimeout(()=>{if(window.limbo&&window.limbo.core&&window.limbo.core.keyboard)window.limbo.core.keyboard.focusFirst(this.element);else{const e=this.getFocusableElements()[0];e&&e.focus()}},300),this.config.onOpen&&this.config.onOpen(this),this}close(){if(!this.isOpen)return this;const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t="fullscreen"===this.config.size;return this.backdrop&&(this.backdrop.style.opacity="0"),this.element.style.opacity="0",this.element.style.transform=e?"translateY(100%)":t?"scale(0.95)":"translate(-50%, -50%) scale(0.8)",setTimeout(()=>{this._cleanup()},300),this.isOpen=!1,window.limbo&&window.limbo.core&&window.limbo.core.keyboard&&(window.limbo.core.keyboard.setActiveModal(null),window.limbo.core.keyboard.releaseFocus()),this.config.onClose&&this.config.onClose(this),this}destroy(){this.close(),this.manager._removeModal(this),this.config.onDestroy&&this.config.onDestroy(this)}getBodyContainer(){return this.element.querySelector(".limbo-modal-body")}getFocusableElements(){return Array.from(this.element.querySelectorAll(this.manager.focusableSelectors))}getId(){return this.id}isOpened(){return this.isOpen}getConfig(){return{...this.config}}_applyInertToSiblings(){const e=Array.from(document.body.children).filter(e=>e!==this.element&&e!==this.backdrop);this._previousInertSiblings=e.map(e=>({node:e,hadInert:e.hasAttribute("inert")})),e.forEach(e=>e.setAttribute("inert",""))}_restoreInertSiblings(){this._previousInertSiblings.forEach(({node:e,hadInert:t})=>{!t&&e.isConnected&&e.removeAttribute("inert")}),this._previousInertSiblings=[]}_cleanup(){document.body.style.overflow=this._originalBodyOverflow||"",this._restoreInertSiblings(),this.previousFocus&&"function"==typeof this.previousFocus.focus&&!1!==this.previousFocus.isConnected&&this.previousFocus.focus(),this.backdrop&&this.backdrop.parentNode&&this.backdrop.parentNode.removeChild(this.backdrop),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class Pn{constructor(){this.currentTheme=null,this.customThemes=new Map,this.config=this._getDefaultConfig(),this.isInitialized=!1,this.isCompactMode=!1,this.compactBreakpoint=null,this.compactObserver=null,this.mediaQueryObserver=null,this.mutationObserver=null,this.storageListener=null,this.themeCache=new Map,this.appliedStyles=new Set,this.changeCallbacks=new Set}_getDefaultConfig(){return{theme:{auto:!0,storage:!0,inherit:!0,smooth:!0,detectSystem:!0},compact:{enabled:!1,auto:!0,breakpoint:768,forceOnMobile:!0,persistPreference:!0},presets:{light:{name:"light",displayName:"Claro",variables:{"--limbo-primary":"#3b82f6","--limbo-primary-hover":"#2563eb","--limbo-primary-light":"#dbeafe","--limbo-primary-dark":"#1e40af","--limbo-bg-primary":"#ffffff","--limbo-bg-secondary":"#f8fafc","--limbo-bg-tertiary":"#f1f5f9","--limbo-bg-overlay":"rgba(0, 0, 0, 0.5)","--limbo-bg-card":"#ffffff","--limbo-bg-input":"#ffffff","--limbo-text-primary":"#0f172a","--limbo-text-secondary":"#475569","--limbo-text-tertiary":"#64748b","--limbo-text-inverse":"#ffffff","--limbo-text-muted":"#94a3b8","--limbo-border-light":"#e2e8f0","--limbo-border-medium":"#cbd5e1","--limbo-border-strong":"#94a3b8","--limbo-border-focus":"#3b82f6","--limbo-success":"#10b981","--limbo-success-light":"#d1fae5","--limbo-error":"#ef4444","--limbo-error-light":"#fee2e2","--limbo-warning":"#f59e0b","--limbo-warning-light":"#fef3c7","--limbo-info":"#3b82f6","--limbo-info-light":"#dbeafe","--limbo-shadow-sm":"0 1px 2px 0 rgba(0, 0, 0, 0.05)","--limbo-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.1)","--limbo-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.1)","--limbo-shadow-xl":"0 20px 25px -5px rgba(0, 0, 0, 0.1)","--limbo-radius-sm":"4px","--limbo-radius-md":"6px","--limbo-radius-lg":"8px","--limbo-radius-xl":"12px","--limbo-font-family":"system-ui, -apple-system, sans-serif","--limbo-font-size-xs":"12px","--limbo-font-size-sm":"14px","--limbo-font-size-md":"16px","--limbo-font-size-lg":"18px","--limbo-font-size-xl":"20px","--limbo-z-dropdown":"1000","--limbo-z-sticky":"1020","--limbo-z-fixed":"1030","--limbo-z-modal":"1050","--limbo-z-tooltip":"1070","--limbo-transition-fast":"150ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-transition-normal":"300ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-transition-slow":"500ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-spacing-compact":"0.5rem","--limbo-spacing-compact-sm":"0.25rem","--limbo-spacing-compact-lg":"0.75rem","--limbo-font-size-compact-xs":"11px","--limbo-font-size-compact-sm":"12px","--limbo-font-size-compact-md":"14px","--limbo-font-size-compact-lg":"16px","--limbo-radius-compact":"4px","--limbo-radius-compact-sm":"3px","--limbo-radius-compact-lg":"6px","--limbo-button-height-compact":"32px","--limbo-input-height-compact":"36px","--limbo-modal-padding-compact":"12px","--limbo-card-padding-compact":"12px","--limbo-gap-compact":"8px","--limbo-gap-compact-sm":"4px","--limbo-gap-compact-lg":"12px"}},dark:{name:"dark",displayName:"Oscuro",variables:{"--limbo-primary":"#60a5fa","--limbo-primary-hover":"#3b82f6","--limbo-primary-light":"#1e293b","--limbo-primary-dark":"#93c5fd","--limbo-bg-primary":"#0f172a","--limbo-bg-secondary":"#1e293b","--limbo-bg-tertiary":"#334155","--limbo-bg-overlay":"rgba(0, 0, 0, 0.8)","--limbo-bg-card":"#1e293b","--limbo-bg-input":"#334155","--limbo-text-primary":"#f8fafc","--limbo-text-secondary":"#cbd5e1","--limbo-text-tertiary":"#94a3b8","--limbo-text-inverse":"#0f172a","--limbo-text-muted":"#64748b","--limbo-border-light":"#334155","--limbo-border-medium":"#475569","--limbo-border-strong":"#64748b","--limbo-border-focus":"#60a5fa","--limbo-success":"#34d399","--limbo-success-light":"#064e3b","--limbo-error":"#f87171","--limbo-error-light":"#7f1d1d","--limbo-warning":"#fbbf24","--limbo-warning-light":"#78350f","--limbo-info":"#60a5fa","--limbo-info-light":"#1e3a8a","--limbo-shadow-sm":"0 1px 2px 0 rgba(0, 0, 0, 0.2)","--limbo-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.3)","--limbo-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.4)","--limbo-shadow-xl":"0 20px 25px -5px rgba(0, 0, 0, 0.5)","--limbo-radius-sm":"4px","--limbo-radius-md":"6px","--limbo-radius-lg":"8px","--limbo-radius-xl":"12px","--limbo-font-family":"system-ui, -apple-system, sans-serif","--limbo-font-size-xs":"12px","--limbo-font-size-sm":"14px","--limbo-font-size-md":"16px","--limbo-font-size-lg":"18px","--limbo-font-size-xl":"20px","--limbo-z-dropdown":"1000","--limbo-z-sticky":"1020","--limbo-z-fixed":"1030","--limbo-z-modal":"1050","--limbo-z-tooltip":"1070","--limbo-transition-fast":"150ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-transition-normal":"300ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-transition-slow":"500ms cubic-bezier(0.4, 0, 0.2, 1)","--limbo-spacing-compact":"0.5rem","--limbo-spacing-compact-sm":"0.25rem","--limbo-spacing-compact-lg":"0.75rem","--limbo-font-size-compact-xs":"11px","--limbo-font-size-compact-sm":"12px","--limbo-font-size-compact-md":"14px","--limbo-font-size-compact-lg":"16px","--limbo-radius-compact":"4px","--limbo-radius-compact-sm":"3px","--limbo-radius-compact-lg":"6px","--limbo-button-height-compact":"32px","--limbo-input-height-compact":"36px","--limbo-modal-padding-compact":"12px","--limbo-card-padding-compact":"12px","--limbo-gap-compact":"8px","--limbo-gap-compact-sm":"4px","--limbo-gap-compact-lg":"12px"}},auto:{name:"auto",displayName:"Automático",variables:{}}},inheritance:{portalSelectors:["body","[data-theme]",".theme-light",".theme-dark",".light-theme",".dark-theme"],variablePrefix:"--",fallbackTheme:"light"},transitions:{duration:"300ms",easing:"cubic-bezier(0.4, 0, 0.2, 1)",properties:["background-color","border-color","color","fill","stroke","box-shadow"]}}}initialize(e={}){this.isInitialized?console.warn("ThemeManager already initialized"):(this.config=this._deepMerge(this.config,e),this._loadCustomThemes(),this.config.theme.inherit&&this._inheritPortalTheme(),this._applyInitialTheme(),this._applyInitialCompactMode(),this._setupObservers(),this._injectBaseStyles(),this.isInitialized=!0)}_injectBaseStyles(){if(document.getElementById("limbo-theme-styles"))return;const e=`\n :root {\n /* Variables de transición para cambios de tema */\n color-scheme: light dark;\n }\n \n [data-limbo-theme] {\n transition: ${this.config.transitions.properties.map(e=>`${e} ${this.config.transitions.duration} ${this.config.transitions.easing}`).join(", ")};\n }\n \n /* Clases de utilidad para temas */\n .limbo-theme-light {\n color-scheme: light;\n }\n \n .limbo-theme-dark {\n color-scheme: dark;\n }\n \n .limbo-theme-auto {\n color-scheme: light dark;\n }\n \n /* Estilos para elementos del componente con variables CSS */\n .limbo-component {\n background-color: var(--limbo-bg-primary);\n color: var(--limbo-text-primary);\n border-color: var(--limbo-border-light);\n border-radius: var(--limbo-radius-md);\n font-family: var(--limbo-font-family);\n font-size: var(--limbo-font-size-md);\n transition: var(--limbo-transition-normal);\n }\n \n .limbo-card {\n background-color: var(--limbo-bg-card);\n border: 1px solid var(--limbo-border-light);\n border-radius: var(--limbo-radius-lg);\n box-shadow: var(--limbo-shadow-md);\n color: var(--limbo-text-primary);\n }\n \n .limbo-input {\n background-color: var(--limbo-bg-input);\n border: 1px solid var(--limbo-border-medium);\n border-radius: var(--limbo-radius-md);\n color: var(--limbo-text-primary);\n font-family: var(--limbo-font-family);\n font-size: var(--limbo-font-size-md);\n transition: var(--limbo-transition-fast);\n }\n \n .limbo-input:focus {\n border-color: var(--limbo-border-focus);\n box-shadow: 0 0 0 3px var(--limbo-primary-light);\n outline: none;\n }\n \n .limbo-button {\n background-color: var(--limbo-primary);\n border: 1px solid var(--limbo-primary);\n border-radius: var(--limbo-radius-md);\n color: var(--limbo-text-inverse);\n font-family: var(--limbo-font-family);\n font-size: var(--limbo-font-size-md);\n transition: var(--limbo-transition-fast);\n cursor: pointer;\n }\n \n .limbo-button:hover {\n background-color: var(--limbo-primary-hover);\n border-color: var(--limbo-primary-hover);\n }\n \n .limbo-button.secondary {\n background-color: var(--limbo-bg-secondary);\n border-color: var(--limbo-border-medium);\n color: var(--limbo-text-primary);\n }\n \n .limbo-button.secondary:hover {\n background-color: var(--limbo-bg-tertiary);\n }\n \n /* Estados de feedback con variables */\n .limbo-state-success {\n background-color: var(--limbo-success-light);\n border-color: var(--limbo-success);\n color: var(--limbo-success);\n }\n \n .limbo-state-error {\n background-color: var(--limbo-error-light);\n border-color: var(--limbo-error);\n color: var(--limbo-error);\n }\n \n .limbo-state-warning {\n background-color: var(--limbo-warning-light);\n border-color: var(--limbo-warning);\n color: var(--limbo-warning);\n }\n \n .limbo-state-info {\n background-color: var(--limbo-info-light);\n border-color: var(--limbo-info);\n color: var(--limbo-info);\n }\n \n /* Overlay y modal con variables */\n .limbo-overlay {\n background-color: var(--limbo-bg-overlay);\n backdrop-filter: blur(4px);\n }\n \n .limbo-modal {\n background-color: var(--limbo-bg-card);\n border-radius: var(--limbo-radius-xl);\n box-shadow: var(--limbo-shadow-xl);\n color: var(--limbo-text-primary);\n }\n \n /* Responsive design con variables */\n @media (max-width: 640px) {\n .limbo-component {\n font-size: var(--limbo-font-size-sm);\n }\n }\n \n /* Modo reducido de movimiento */\n @media (prefers-reduced-motion: reduce) {\n [data-limbo-theme] {\n transition: none;\n }\n \n .limbo-component,\n .limbo-input,\n .limbo-button {\n transition: none;\n }\n }\n \n /* Esquemas de color automático */\n @media (prefers-color-scheme: dark) {\n :root:not([data-limbo-theme]) {\n color-scheme: dark;\n }\n }\n \n @media (prefers-color-scheme: light) {\n :root:not([data-limbo-theme]) {\n color-scheme: light;\n }\n }\n \n /* ===================================\n MODO COMPACTO - ESTILOS ESPECÍFICOS \n =================================== */\n \n /* Activación del modo compacto por atributo o clase */\n [data-limbo-compact="true"],\n .limbo-compact-mode {\n /* Componentes base más pequeños */\n --limbo-font-size-md: var(--limbo-font-size-compact-md);\n --limbo-font-size-sm: var(--limbo-font-size-compact-sm);\n --limbo-font-size-lg: var(--limbo-font-size-compact-lg);\n --limbo-spacing: var(--limbo-spacing-compact);\n --limbo-radius-md: var(--limbo-radius-compact);\n --limbo-gap: var(--limbo-gap-compact);\n }\n \n /* Botones compactos */\n [data-limbo-compact="true"] .limbo-button,\n .limbo-compact-mode .limbo-button {\n height: var(--limbo-button-height-compact);\n padding: var(--limbo-spacing-compact-sm) var(--limbo-spacing-compact);\n font-size: var(--limbo-font-size-compact-sm);\n border-radius: var(--limbo-radius-compact);\n min-width: auto;\n }\n \n /* Inputs compactos */\n [data-limbo-compact="true"] .limbo-input,\n .limbo-compact-mode .limbo-input {\n height: var(--limbo-input-height-compact);\n padding: var(--limbo-spacing-compact-sm) var(--limbo-spacing-compact);\n font-size: var(--limbo-font-size-compact-md);\n border-radius: var(--limbo-radius-compact);\n }\n \n /* Cards compactas */\n [data-limbo-compact="true"] .limbo-card,\n .limbo-compact-mode .limbo-card {\n padding: var(--limbo-card-padding-compact);\n border-radius: var(--limbo-radius-compact-lg);\n }\n \n /* Modales compactos */\n [data-limbo-compact="true"] .limbo-modal,\n .limbo-compact-mode .limbo-modal {\n padding: var(--limbo-modal-padding-compact);\n border-radius: var(--limbo-radius-compact-lg);\n max-width: 90vw;\n max-height: 90vh;\n }\n \n /* Tabs compactas */\n [data-limbo-compact="true"] .limbo-tabs,\n .limbo-compact-mode .limbo-tabs {\n gap: var(--limbo-gap-compact-sm);\n }\n \n [data-limbo-compact="true"] .limbo-tab,\n .limbo-compact-mode .limbo-tab {\n padding: var(--limbo-spacing-compact-sm) var(--limbo-spacing-compact);\n font-size: var(--limbo-font-size-compact-sm);\n border-radius: var(--limbo-radius-compact-sm);\n }\n \n /* Gallery compacta */\n [data-limbo-compact="true"] .limbo-gallery,\n .limbo-compact-mode .limbo-gallery {\n gap: var(--limbo-gap-compact-sm);\n }\n \n [data-limbo-compact="true"] .limbo-gallery-item,\n .limbo-compact-mode .limbo-gallery-item {\n border-radius: var(--limbo-radius-compact);\n min-height: 120px; /* Más pequeño para móviles */\n }\n \n /* Notificaciones compactas */\n [data-limbo-compact="true"] .limbo-notification,\n .limbo-compact-mode .limbo-notification {\n padding: var(--limbo-spacing-compact-sm) var(--limbo-spacing-compact);\n font-size: var(--limbo-font-size-compact-sm);\n border-radius: var(--limbo-radius-compact);\n }\n \n /* Progress indicators compactos */\n [data-limbo-compact="true"] .limbo-progress,\n .limbo-compact-mode .limbo-progress {\n height: 3px; /* Más delgado */\n }\n \n [data-limbo-compact="true"] .limbo-progress-circular,\n .limbo-compact-mode .limbo-progress-circular {\n width: 20px;\n height: 20px;\n }\n \n /* Auto-activación en pantallas pequeñas */\n @media (max-width: 768px) {\n :root[data-limbo-compact="auto"],\n .limbo-component[data-limbo-compact="auto"] {\n /* Aplicar automáticamente estilos compactos */\n --limbo-font-size-md: var(--limbo-font-size-compact-md);\n --limbo-font-size-sm: var(--limbo-font-size-compact-sm);\n --limbo-spacing: var(--limbo-spacing-compact);\n --limbo-radius-md: var(--limbo-radius-compact);\n --limbo-gap: var(--limbo-gap-compact);\n }\n \n /* Modal full-screen en móvil cuando es compacto */\n [data-limbo-compact="auto"] .limbo-modal,\n [data-limbo-compact="true"] .limbo-modal {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100vw;\n height: 100vh;\n max-width: 100vw;\n max-height: 100vh;\n border-radius: 0;\n margin: 0;\n }\n \n /* Tabs en accordion en móvil */\n [data-limbo-compact="auto"] .limbo-tabs,\n [data-limbo-compact="true"] .limbo-tabs {\n flex-direction: column;\n width: 100%;\n }\n \n /* Gallery de 2 columnas en móvil */\n [data-limbo-compact="auto"] .limbo-gallery,\n [data-limbo-compact="true"] .limbo-gallery {\n grid-template-columns: 1fr 1fr;\n gap: var(--limbo-gap-compact);\n }\n }\n \n /* Touch targets más grandes en móviles */\n @media (max-width: 768px) and (pointer: coarse) {\n [data-limbo-compact="auto"] .limbo-button,\n [data-limbo-compact="true"] .limbo-button {\n min-height: 44px; /* Tamaño mínimo de toque recomendado */\n padding: var(--limbo-spacing-compact) var(--limbo-spacing-compact-lg);\n }\n \n [data-limbo-compact="auto"] .limbo-tab,\n [data-limbo-compact="true"] .limbo-tab {\n min-height: 44px;\n }\n }\n `,t=document.createElement("style");t.id="limbo-theme-styles",t.textContent=e,document.head.appendChild(t)}applyTheme(e,t={}){const l=this._getTheme(e);if(!l)return console.warn(`Theme '${e}' not found`),!1;const n=this.currentTheme;return this._applyThemeVariables(l,t.scope),this._updateThemeAttributes(l.name),this.config.theme.storage&&!t.temporary&&this._saveThemePreference(l.name),this.currentTheme=l.name,this._triggerChangeCallbacks(l.name,n),!0}toggleTheme(e="light",t="dark"){const l=this.currentTheme===e?t:e;return this.applyTheme(l)}applyAutoTheme(){const e=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";return this.applyTheme(e)}registerTheme(e,t){const l={name:e,displayName:t.displayName||e,variables:t.variables||{},extends:t.extends||null,...t};if(l.extends){const e=this._getTheme(l.extends);e&&(l.variables={...e.variables,...l.variables})}return this.customThemes.set(e,l),this}removeTheme(e){if(this.config.presets[e])return console.warn(`Cannot remove predefined theme: ${e}`),!1;const t=this.customThemes.delete(e);return t&&this.currentTheme===e&&this.applyTheme(this.config.inheritance.fallbackTheme),t}getAvailableThemes(){const e=Object.keys(this.config.presets),t=Array.from(this.customThemes.keys());return{presets:e,custom:t,all:[...e,...t]}}getCurrentTheme(){return{name:this.currentTheme,theme:this._getTheme(this.currentTheme),isCustom:this.customThemes.has(this.currentTheme),variables:this._getCurrentVariables()}}enableCompactMode(e={}){const t={element:document.documentElement,persist:!0,...e};return t.element.setAttribute("data-limbo-compact","true"),t.element.classList.add("limbo-compact-mode"),this.isCompactMode=!0,t.persist&&this.config.compact.persistPreference&&this._saveCompactPreference(!0),this._triggerCompactChange(!0),this}disableCompactMode(e={}){const t={element:document.documentElement,persist:!0,...e};return t.element.setAttribute("data-limbo-compact","false"),t.element.classList.remove("limbo-compact-mode"),this.isCompactMode=!1,t.persist&&this.config.compact.persistPreference&&this._saveCompactPreference(!1),this._triggerCompactChange(!1),this}toggleCompactMode(e={}){return this.isCompactMode?this.disableCompactMode(e):this.enableCompactMode(e)}applyAutoCompactMode(){const e=this._shouldUseCompactMode();return e&&!this.isCompactMode?this.enableCompactMode({persist:!1}):!e&&this.isCompactMode&&this.disableCompactMode({persist:!1}),this}getCompactState(){return{isEnabled:this.isCompactMode,isAuto:this.config.compact.auto,breakpoint:this.config.compact.breakpoint,currentViewport:window.innerWidth,shouldBeCompact:this._shouldUseCompactMode()}}_shouldUseCompactMode(){if(!this.config.compact.auto)return this.config.compact.enabled;const e=window.innerWidth<=this.config.compact.breakpoint,t=/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),l="ontouchstart"in window||navigator.maxTouchPoints>0;return!(!this.config.compact.forceOnMobile||!t&&!l)||e}_saveCompactPreference(e){try{localStorage.setItem("limbo-compact-preference",e.toString())}catch(t){console.warn("Could not save compact preference:",t)}}_loadCompactPreference(){try{return"true"===localStorage.getItem("limbo-compact-preference")}catch(e){return console.warn("Could not load compact preference:",e),null}}_triggerCompactChange(e){this.changeCallbacks.forEach(t=>{try{t({type:"compact",isCompact:e,viewport:window.innerWidth,timestamp:Date.now()})}catch(l){console.error("Error in compact mode change callback:",l)}})}_inheritPortalTheme(){const e=this._detectPortalTheme();return e?(this.registerTheme("portal-inherited",e),"portal-inherited"):null}_detectPortalTheme(){const e={name:"portal-detected",displayName:"Tema del Portal",variables:{}};for(const t of this.config.inheritance.portalSelectors){const l=document.querySelector(t);if(l){const t=this._extractCSSVariables(l);Object.keys(t).length>0&&(e.variables={...e.variables,...t});const n=l.getAttribute("data-theme")||l.getAttribute("class")?.match(/theme-(\w+)/)||l.getAttribute("class")?.match(/(\w+)-theme/);n&&(e.detectedName=Array.isArray(n)?n[1]:n)}}return Object.keys(e.variables).length>0?e:null}_extractCSSVariables(e){const t={},l=getComputedStyle(e);["primary","primary-hover","primary-light","primary-dark","bg-primary","bg-secondary","bg-tertiary","bg-card","bg-input","text-primary","text-secondary","text-tertiary","text-inverse","border-light","border-medium","border-strong","border-focus","success","error","warning","info","shadow-sm","shadow-md","shadow-lg","shadow-xl","radius-sm","radius-md","radius-lg","radius-xl"].forEach(e=>{const n=`--limbo-${e}`,a=l.getPropertyValue(n).trim();a&&(t[n]=a)});return["--primary-color","--background-color","--text-color","--border-color","--accent-color","--surface-color"].forEach(e=>{const n=l.getPropertyValue(e).trim();if(n){const l=this._mapGenericToLimbo(e,n);l&&Object.assign(t,l)}}),t}_mapGenericToLimbo(e,t){return{"--primary-color":{"--limbo-primary":t},"--background-color":{"--limbo-bg-primary":t},"--text-color":{"--limbo-text-primary":t},"--border-color":{"--limbo-border-light":t},"--accent-color":{"--limbo-primary":t},"--surface-color":{"--limbo-bg-card":t}}[e]||null}_applyInitialTheme(){let e=this.config.inheritance.fallbackTheme;if(this.config.theme.storage){const t=this._loadThemePreference();t&&this._getTheme(t)&&(e=t)}const t=document.documentElement.getAttribute("data-limbo-theme");t&&this._getTheme(t)&&(e=t);const l=this._inheritPortalTheme();l&&(e=l),this.config.theme.auto&&"auto"===e&&(e=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),this.applyTheme(e,{temporary:!1})}_applyInitialCompactMode(){let e=!1;if(this.config.compact.persistPreference){const t=this._loadCompactPreference();null!==t&&(e=t)}const t=document.documentElement.getAttribute("data-limbo-compact");"true"===t?e=!0:"false"===t&&(e=!1),("auto"===t||this.config.compact.auto)&&(e=this._shouldUseCompactMode()),e?this.enableCompactMode({persist:!1}):this.disableCompactMode({persist:!1})}_applyThemeVariables(e,t=document.documentElement){const l="string"==typeof t?document.querySelector(t):t;l?(Object.entries(e.variables).forEach(([e,t])=>{l.style.setProperty(e,t),this.appliedStyles.add(`${l.tagName}:${e}`)}),this.themeCache.set(e.name,{theme:e,appliedAt:Date.now(),scope:l})):console.warn("Theme scope element not found")}_updateThemeAttributes(e){document.documentElement.setAttribute("data-limbo-theme",e),document.documentElement.classList.remove("limbo-theme-light","limbo-theme-dark","limbo-theme-auto"),document.documentElement.classList.add(`limbo-theme-${e}`),this._updateMetaThemeColor(e)}_updateMetaThemeColor(e){const t=this._getTheme(e);if(!t)return;const l=t.variables["--limbo-primary"]||"#3b82f6";let n=document.querySelector('meta[name="theme-color"]');n||(n=document.createElement("meta"),n.name="theme-color",document.head.appendChild(n)),n.content=l}_getTheme(e){return this.config.presets[e]?this.config.presets[e]:this.customThemes.has(e)?this.customThemes.get(e):null}_getCurrentVariables(){const e=this._getTheme(this.currentTheme);if(!e)return{};const t=getComputedStyle(document.documentElement),l={};return Object.keys(e.variables).forEach(e=>{l[e]=t.getPropertyValue(e).trim()}),l}_saveThemePreference(e){try{localStorage.setItem("limbo-theme-preference",e)}catch(t){console.warn("Could not save theme preference:",t)}}_loadThemePreference(){try{return localStorage.getItem("limbo-theme-preference")}catch(e){return console.warn("Could not load theme preference:",e),null}}_loadCustomThemes(){try{const e=localStorage.getItem("limbo-custom-themes");if(e){const t=JSON.parse(e);Object.entries(t).forEach(([e,t])=>{this.customThemes.set(e,t)})}}catch(e){console.warn("Could not load custom themes:",e)}}_saveCustomThemes(){try{const e=Object.fromEntries(this.customThemes);localStorage.setItem("limbo-custom-themes",JSON.stringify(e))}catch(e){console.warn("Could not save custom themes:",e)}}_setupObservers(){this.config.theme.detectSystem&&this._setupSystemObserver(),this.config.theme.storage&&this._setupStorageObserver(),this._setupMutationObserver(),this.config.compact.auto&&this._setupViewportObserver()}_setupSystemObserver(){const e=window.matchMedia("(prefers-color-scheme: dark)");e.addEventListener("change",e=>{if("auto"===this.currentTheme||this.config.theme.auto){const t=e.matches?"dark":"light";this.applyTheme(t,{temporary:!0})}}),this.mediaQueryObserver=e}_setupStorageObserver(){const e=e=>{"limbo-theme-preference"===e.key&&e.newValue!==this.currentTheme&&this._getTheme(e.newValue)&&this.applyTheme(e.newValue)};window.addEventListener("storage",e),this.storageListener=e}_setupMutationObserver(){const e=new MutationObserver(e=>{e.forEach(e=>{if("attributes"===e.type&&"data-limbo-theme"===e.attributeName){const t=e.target.getAttribute("data-limbo-theme");t&&t!==this.currentTheme&&this._getTheme(t)&&this.applyTheme(t)}})});e.observe(document.documentElement,{attributes:!0,attributeFilter:["data-limbo-theme"]}),this.mutationObserver=e}_setupViewportObserver(){const e=`(max-width: ${this.config.compact.breakpoint}px)`,t=window.matchMedia(e);t.addEventListener("change",()=>{("auto"===document.documentElement.getAttribute("data-limbo-compact")||this.config.compact.auto)&&this.applyAutoCompactMode()}),this.compactObserver=t,window.addEventListener("orientationchange",()=>{setTimeout(()=>{("auto"===document.documentElement.getAttribute("data-limbo-compact")||this.config.compact.auto)&&this.applyAutoCompactMode()},100)})}onThemeChange(e){return this.changeCallbacks.add(e),()=>this.changeCallbacks.delete(e)}_triggerChangeCallbacks(e,t){this.changeCallbacks.forEach(l=>{try{l({theme:e,previousTheme:t,themeData:this._getTheme(e),variables:this._getCurrentVariables()})}catch(n){console.error("Error in theme change callback:",n)}})}generateThemeFromColors(e,t){const l={name:e,displayName:e,variables:{}};t.primary&&(l.variables["--limbo-primary"]=t.primary,l.variables["--limbo-primary-hover"]=this._darkenColor(t.primary,10),l.variables["--limbo-primary-light"]=this._lightenColor(t.primary,40),l.variables["--limbo-primary-dark"]=this._darkenColor(t.primary,20)),t.background&&(l.variables["--limbo-bg-primary"]=t.background,l.variables["--limbo-bg-secondary"]=this._lightenColor(t.background,5),l.variables["--limbo-bg-tertiary"]=this._lightenColor(t.background,10),l.variables["--limbo-bg-card"]=t.background),t.text&&(l.variables["--limbo-text-primary"]=t.text,l.variables["--limbo-text-secondary"]=this._lightenColor(t.text,20),l.variables["--limbo-text-tertiary"]=this._lightenColor(t.text,40));const n=this._getTheme(this.config.inheritance.fallbackTheme);return n&&(l.variables={...n.variables,...l.variables}),this.registerTheme(e,l),l}_darkenColor(e,t){const l=parseInt(e.replace("#",""),16),n=Math.round(2.55*t),a=(l>>16)-n,r=(l>>8&255)-n,i=(255&l)-n;return"#"+(16777216+65536*(a<255?a<1?0:a:255)+256*(r<255?r<1?0:r:255)+(i<255?i<1?0:i:255)).toString(16).slice(1)}_lightenColor(e,t){const l=parseInt(e.replace("#",""),16),n=Math.round(2.55*t),a=(l>>16)+n,r=(l>>8&255)+n,i=(255&l)+n;return"#"+(16777216+65536*(a<255?a<1?0:a:255)+256*(r<255?r<1?0:r:255)+(i<255?i<1?0:i:255)).toString(16).slice(1)}_deepMerge(e,t){const l={...e};return Object.keys(t).forEach(n=>{t[n]&&"object"==typeof t[n]&&!Array.isArray(t[n])?l[n]=this._deepMerge(e[n]||{},t[n]):l[n]=t[n]}),l}getThemeInfo(){return{current:this.getCurrentTheme(),available:this.getAvailableThemes(),compact:this.getCompactState(),config:this.config,isInitialized:this.isInitialized,cache:{themes:this.themeCache.size,applied:this.appliedStyles.size},observers:{system:!!this.mediaQueryObserver,storage:!!this.storageListener,mutation:!!this.mutationObserver,viewport:!!this.compactObserver}}}debug(){return console.table(this.getThemeInfo()),this.getThemeInfo()}destroy(){this.mediaQueryObserver&&this.mediaQueryObserver.removeEventListener("change",this._setupSystemObserver),this.storageListener&&window.removeEventListener("storage",this.storageListener),this.mutationObserver&&this.mutationObserver.disconnect(),this.compactObserver&&this.compactObserver.removeEventListener("change",this._setupViewportObserver),this.changeCallbacks.clear(),this.themeCache.clear(),this.appliedStyles.clear(),this._saveCustomThemes();const e=document.getElementById("limbo-theme-styles");e&&e.remove(),this.isInitialized=!1}}const Dn={border:"none",borderRadius:"6px",cursor:"pointer",fontFamily:"inherit",fontWeight:"500",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"6px",transition:"background 0.2s ease, transform 0.1s ease",userSelect:"none",textDecoration:"none",lineHeight:"1.25"},Rn={bg:"#001978",hover:"#334793"},On={bg:"#10b981",hover:"#059669"},Fn={bg:"#9ca3af",hover:"#9ca3af"};class Un extends HTMLElement{constructor(){super(),this._btn=null,this._limboInstance=null}connectedCallback(){this._ensureButton(),this._syncButton()}disconnectedCallback(){this._destroyLimboInstance()}static get observedAttributes(){return["accept","has-file","disabled","compact","label-select","label-change","return-format","button-class","existing-url","mandatory-crops","public-key","token","auth-mode"]}attributeChangedCallback(){this._btn&&this._syncButton()}markSelected(e){this.setAttribute("has-file",""),e&&this.setAttribute("existing-url",e),this._syncButton()}clearSelection(){this.removeAttribute("has-file"),this.removeAttribute("existing-url"),this._syncButton()}open(){this._open()}_ensureButton(){this._btn||(this._btn=document.createElement("button"),this._btn.type="button",this._btn.classList.add("limbo-selector-btn","limbo-trigger-button","mecano:my-2"),this._btn.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this._open()}),this.appendChild(this._btn))}_syncButton(){if(!this._btn)return;const e=this.getAttribute("accept")||null,t=this.hasAttribute("has-file"),l=this.hasAttribute("disabled"),n=this.hasAttribute("compact"),a=this.getAttribute("label-select")||null,r=this.getAttribute("label-change")||null,i=this.getAttribute("button-class")||null;this._btn.textContent=t?r||u(e,!0):a||u(e,!1),this._btn.disabled=l,i&&i.split(/\s+/).filter(Boolean).forEach(e=>this._btn.classList.add(e));const o=l?Fn:t?On:Rn;Object.assign(this._btn.style,{...Dn,fontSize:n?"12px":"14px",padding:n?"6px 12px":"8px 16px",background:o.bg,color:"white",opacity:l?"0.55":"1",cursor:l?"not-allowed":"pointer"}),this._btn.onmouseenter=()=>{l||(this._btn.style.background=o.hover,this._btn.style.transform="translateY(-1px)",this._btn.style.boxShadow="0 4px 10px rgba(0,0,0,0.18)")},this._btn.onmouseleave=()=>{this._btn.style.background=o.bg,this._btn.style.transform="translateY(0)",this._btn.style.boxShadow="none"}}_open(){const e=window.Limbo||window.limboCore;if(!e)return void console.warn("[LimboSelector] window.Limbo no encontrado. Asegúrate de que el script de Limbo está cargado antes de usar <limbo-selector>.");const t=this.getAttribute("accept")||null,l=this.getAttribute("return-format")||"url",n=this.getAttribute("existing-url")||null,a=this.getAttribute("public-key")||null,r=this.getAttribute("token")||null,i=this.getAttribute("auth-mode")||null;(a||r)&&e.configure({...a&&{publicKey:a},...r&&{token:r},authMode:i||(r?"manual":"session")}),e.config?.setGlobal&&e.config.setGlobal({interaction:{allowSelection:!0,allowCropping:!0,selectionMode:"direct"}});let o=null;const s=this.getAttribute("mandatory-crops");if(s)try{o=JSON.parse(s)}catch{}this._destroyLimboInstance();try{const a={mode:"modal",modeUI:"full",modalSize:"fullscreen",features:["gallery","upload","cropper"],title:"Seleccionar archivo",validation:{accept:t},returnConfig:{format:l},initialImageUrl:n,interaction:{allowSelection:!0,allowCropping:!0},cropper:o?.length>0?{mandatoryCrops:o,allowAdditionalCrops:!0,maxCrops:10}:null},r=async e=>{const t="string"==typeof e?e:e?.images?.[0]?.url||e?.original?.url||e?.url||"";this.setAttribute("has-file",""),t&&this.setAttribute("existing-url",t),this._syncButton(),this.dispatchEvent(new CustomEvent("limbo:change",{detail:{data:e,url:t},bubbles:!0,composed:!0}))};e.events.emit("autoInputs:modalRequest",{config:a,input:null,callback:r})}catch(c){console.error("[LimboSelector] Error al abrir modal de Limbo:",c)}}_handleResult(e,t){if(this._limboInstance!==t)return;const l="string"==typeof e?e:e?.url||e?.master?.urlSigned||e?.master?.url||e?.asset?.url||e?.original?.url||e?.crops?.[0]?.url||e?.images?.[0]?.url||"";this.setAttribute("has-file",""),l&&this.setAttribute("existing-url",l),this._syncButton(),this.dispatchEvent(new CustomEvent("limbo:change",{detail:{data:e,url:l},bubbles:!0,composed:!0}));try{t?.close?.()}catch{}this._limboInstance=null}_destroyLimboInstance(){if(this._limboInstance){try{this._limboInstance.destroy?.()}catch{}this._limboInstance=null}}}function Bn(e="limbo-selector"){"undefined"==typeof customElements||customElements.get(e)||customElements.define(e,Un)}const qn=new class{constructor(){this.config=new p,this.instances=new An,this.autoInputs=new zn,this.events=new Ln,this.modals=new Mn,this.theme=new Pn,this.containerQueryDetector=E,this._setupInternalListeners(),this._initializeContainerQueries()}configure(e){this.config.setGlobal(e);const t={};var l;return"publicKey"in e&&(t.publicKey=e.publicKey),"apiKey"in e&&(t.apiKey=e.apiKey),"token"in e&&(t.token=e.token),"authMode"in e&&(t.authMode=e.authMode),"tokenProvider"in e&&(t.tokenProvider=e.tokenProvider),"prod"in e&&(t.prod=Boolean(e.prod)),"mode"in e&&(t.mode=e.mode),"callbacks"in e&&(t.callbacks=e.callbacks),"token"in(l=t)&&l.token!==M.token&&(I=!1,P=null),M={...M,...l},M.authMode||(M.token?M.authMode="manual":M.authMode="session"),this.config}setToken(e){return B(e),this.config.setGlobal({token:e}),this}create(e){const t=this.config.merge(e);return this.instances.create(t,this.events,this.modals)}configureAutoInputs(e){return this.autoInputs.configure(e,this.config,this.events)}setTheme(e){return e&&(this.config.set("theme",e),this.theme.setTheme(e),this.events.emit("theme:changed",{theme:e})),this}getTheme(){return this.theme.getCurrentTheme()}scanAndActivate(e=null){const t=this.autoInputs.config?.dataset||"data-limbo-input-file",l=e||`[${t}]`,n=document.querySelectorAll(l);if(0===n.length)return{found:0,processed:0,skipped:0};let a=0,r=0;return n.forEach(e=>{try{this.autoInputs._processInput(e),a++}catch(t){console.warn(`⚠️ Limbo: Error procesando input ${e.id||e.name}:`,t),r++}}),this.events.emit("limbo:scanCompleted",{found:n.length,processed:a,skipped:r,inputs:Array.from(n)}),{found:n.length,processed:a,skipped:r}}_initializeContainerQueries(){this.containerQueryDetector.observeResize(),setTimeout(()=>{document.querySelectorAll(".limbo-component-container-wrapper").forEach(e=>{this.containerQueryDetector.applyResponsiveClasses(e)})},100)}rescan(e=document){const t=this.autoInputs.config?.dataset||"data-limbo-input-file",l=e.querySelectorAll(`[${t}]`);let n=0;return l.forEach(e=>{if(!this.autoInputs.instances.has(this.autoInputs._getInputId(e)))try{this.autoInputs._processInput(e),n++}catch(t){console.warn("⚠️ Limbo: Error procesando nuevo input:",t)}}),n}init(e){const t=this._mapLegacyOptions(e);return this.create(t)}getInstances(){return this.instances.getAll()}destroy(){this.instances.destroyAll(),this.autoInputs.cleanup(),this.events.cleanup(),this.theme.removeTheme()}_mapLegacyOptions(e){return{container:e.container||"#image-manager",mode:"embed",features:["gallery","upload","cropper"],apiKey:e.apiKey,prod:e.prod||!1,url:void 0===e.url||e.url}}_setupInternalListeners(){this.events.on("autoInputs:modalRequest",({config:e,callback:t,input:l})=>{this._handleAutoInputModalRequest({config:e,callback:t,input:l})})}_handleAutoInputModalRequest({config:e,callback:t,input:l}){const n=l,a=async l=>{let a={};if(l.crops&&l.crops.length>0){const e=l.asset||l.original;a.original={url:e?.url||e?.urlSigned||l.originalUrl,width:e?.width||l.originalWidth,height:e?.height||l.originalHeight,assetId:e?.id||l.assetId},a.images=l.crops.map(e=>({url:e.url||e.urlSigned,width:e.width,height:e.height,name:e.name||e.filename}))}else l.asset?a.original={url:l.asset.url||l.asset.urlSigned,width:l.asset.width,height:l.asset.height,assetId:l.asset.id}:l.master?.urlSigned||l.master?.url?a.original={url:l.master.urlSigned||l.master.url,width:l.master.width||l.width,height:l.master.height||l.height,assetId:l.assetId}:l.url||l.urlSigned?a.original={url:l.url||l.urlSigned,width:l.width,height:l.height,assetId:l.assetId||l.id}:(console.warn("[Limbo] handleResult: formato de datos no reconocido",l),a=l);if(n){var r=e?.returnConfig?.format||"json",i="";i="url"===r?a.images?.[0]?.url||a.original?.url||"":"assetId"===r?a.original?.assetId||"":JSON.stringify(a),n.value=i,n.dispatchEvent(new Event("change",{bubbles:!0})),console.log("[Limbo] ✅ Valor asignado al input:",n.value?.substring(0,80))}try{await t(a)}catch(o){}u.close()},r={...e,mode:"modal",autoDestroy:!0,interaction:{allowSelection:!0,allowCropping:!0,...e.interaction},callbacks:{onSelect:e=>{a(e)},onCropsSaved:e=>{a(e)},onCropperComplete:e=>{a(e)},onUpload:t=>{"upload-only"!==e.modeUI||e.features?.includes("cropper")||a(t)},onClose:()=>{}}},i=e.validation?.accept||null,o=i?s(i):null,c=!o||o.isAllTypes||o.includesImages;if(e.initialImageUrl&&c){const t=this._extractAssetIdFromUrl(e.initialImageUrl)||e.existingData?.original?.assetId||null;t&&(r._externalImage={url:e.initialImageUrl,filename:e.initialImageUrl.split("/").pop()?.split("?")[0]||"image.jpg",width:1920,height:1080,mime_type:"image/jpeg",id:t})}e.cropper&&(r.cropper=e.cropper),this.config.setGlobal({interaction:{allowSelection:!0,allowCropping:!0,...e.interaction}});const u=this.create(r);u.open()}_extractAssetIdFromUrl(e){if(!e)return null;try{const t=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,l=e.match(t);return l&&l.length>=2?l[1]:l&&1===l.length?l[0]:null}catch(t){return console.warn("Error extracting asset ID from URL:",t),null}}openGallery(e={}){const t=this.create({mode:"modal",modeUI:"gallery-only",features:["gallery"],autoDestroy:!0,modal:{title:e.title||"Seleccionar Imagen",size:e.size||"large"},validation:{accept:e.accept||null},callbacks:{onSelect:l=>{e.onSelect?.(l),!1!==e.autoClose&&t.close()}},...e});return t.open(),t}openUploader(e={}){const t=!1!==e.redirectToGallery?["upload","gallery"]:["upload"],l=this.create({mode:"modal",modeUI:!1!==e.redirectToGallery?"full":"upload-only",features:t,autoDestroy:!0,modal:{title:e.title||"Subir Imagen",size:e.size||"medium"},validation:{accept:e.accept||null},callbacks:{onUpload:t=>{e.onUpload?.(t),!1===e.autoClose||e.redirectToGallery||l.close()}},...e});return l.open(),l}openCropper(e,t={}){if(!e)throw new Error("Limbo.openCropper: imageUrl es requerido");const l={url:e,filename:t.filename||"image.jpg",width:t.width||1920,height:t.height||1080,mime_type:t.mimeType||"image/jpeg",id:t.assetId||`external-${Date.now()}`},n=this.create({mode:"modal",modeUI:"crop-only",features:["cropper"],autoDestroy:!0,modal:{title:t.title||"Recortar Imagen",size:"xlarge"},cropper:{mandatoryCrops:t.mandatoryCrops||[],allowCustomCrops:!1!==t.allowCustomCrops,enforceRequiredCrops:!1!==t.enforceRequiredCrops},callbacks:{onCropperComplete:e=>{t.onComplete?.(e),!1!==t.autoClose&&n.close()},onCropperCancelled:e=>{t.onCancelled?.(e),!1!==t.autoClose&&n.close()},onCropperError:e=>{t.onError?.(e)}},_externalImage:l,...t});return n.open(),n}createInlineGallery(e,t={}){return this.create({container:e,mode:"embed",modeUI:"gallery-only",features:["gallery"],validation:{accept:t.accept||null},callbacks:{onSelect:t.onSelect,onDelete:t.onDelete},...t})}createInlineUploader(e,t={}){return this.create({container:e,mode:"embed",modeUI:"upload-only",features:["upload"],validation:{accept:t.accept||null},callbacks:{onUpload:t.onUpload},...t})}createStandaloneCropper(e,t,l={}){if(!e)throw new Error("Limbo.createStandaloneCropper: container es requerido");if(!t)throw new Error("Limbo.createStandaloneCropper: imageUrl es requerido");const n={url:t,filename:l.filename||"image.jpg",width:l.width||1920,height:l.height||1080,mime_type:l.mimeType||"image/jpeg",id:l.assetId||`external-${Date.now()}`};return this.create({container:e,mode:"embed",modeUI:"crop-only",features:["cropper"],autoHideOnComplete:!1!==l.autoHideOnComplete,cropper:{mandatoryCrops:l.mandatoryCrops||[],allowCustomCrops:!1!==l.allowCustomCrops,enforceRequiredCrops:!1!==l.enforceRequiredCrops},callbacks:{onCropperComplete:l.onComplete,onCropperCancelled:l.onCancelled,onCropperError:l.onError},_externalImage:n,...l})}createFullSelector(e,t={}){return this.create({container:e,mode:t.mode||"embed",modeUI:"full",features:["gallery","upload","cropper"],validation:{accept:t.accept||null},callbacks:{onSelect:t.onSelect,onUpload:t.onUpload,onDelete:t.onDelete,onCropsSaved:t.onCropsSaved},...t})}};"undefined"!=typeof window&&(window.Limbo=qn,window.limboCore=qn,Bn());"undefined"!=typeof window&&document.querySelector("#root")&&(qn.configure({prod:!1,publicKey:"pk_e464fd744106b7a8d63d453c4bd02582",authMode:"session"}),qn.create({container:"#root",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],title:"Limbo Image Manager - Development",url:!0}),qn.configureAutoInputs({dataset:"data-limbo-input-file",return:"json",features:["gallery","upload","cropper"],modeUI:"full",modalSize:"large",title:"Seleccionar archivo",crops:"free",allowDelete:!1})),exports.LIMBO_BASE_URL=wn,exports.LimboSelector=Un,exports.decodeHtmlEntities=Cn,exports.default=qn,exports.extractImageUrl=jn,exports.getButtonLabel=u,exports.isValidImageUrl=Sn,exports.parseImageData=function(e,t={}){const{isProd:l=!1}=t;if(!e)return{original:null,images:[],url:""};try{const t=JSON.parse(Cn(e)),n=t.original?{...t.original,url:kn(t.original.url,l)}:null,a=(t.images||[]).map(e=>({...e,url:kn(e.url,l)}));return{original:n,images:a,url:a[0]?.url||n?.url||kn(t.url,l)||""}}catch{return{original:null,images:[],url:kn(e,l)}}},exports.prepareImageFieldsForPreview=function(e,t={}){const{isProd:l=!1}=t;if(!e?.fields)return e;const n=e.fields.map(e=>{if("image"===e.type&&"string"==typeof e.example_value){const t=jn(e.example_value,{isProd:l});return{...e,example_value:t||e.example_value}}return e});return{...e,fields:n}},exports.registerLimboSelector=Bn,exports.resolveUrl=kn;
2
2
  //# sourceMappingURL=limbo.cjs.map