limbo-component 1.8.1 → 1.8.2

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.umd.js CHANGED
@@ -1,4 +1,4 @@
1
1
  !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Limbo=t()}(this,function(){"use strict";const e={es:{"button.select":"Seleccionar","button.upload":"Subir imagen","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 imagen...","message.processing":"Procesando...","message.no_images":"No hay imágenes disponibles","message.upload_success":"Imagen subida correctamente","message.upload_error":"Error al subir la imagen","message.delete_confirm":"¿Estás seguro de que deseas eliminar esta imagen? 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 imágenes...","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"},en:{"button.select":"Select","button.upload":"Upload image","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 image...","message.processing":"Processing...","message.no_images":"No images available","message.upload_success":"Image uploaded successfully","message.upload_error":"Error uploading image","message.delete_confirm":"Are you sure you want to delete this image?","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 images...","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"}};class t{constructor(e="es",t={}){this.locale=e,this.messages=this._mergeMessages(t)}_mergeMessages(t){const n={...e};return Object.keys(t).forEach(e=>{n[e]={...n[e]||{},...t[e]}}),n}t(e,t={}){let n=(this.messages[this.locale]||this.messages.es)[e]||e;return Object.keys(t).forEach(e=>{n=n.replace(`{${e}}`,t[e])}),n}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)}}new t;class n{constructor(){this.globalConfig={},this.defaults={container:"#limbo-default",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],ui:{showActions:["select","download","copy","delete","crop"],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,enabledFilters:["name","date"],customFilters:[]},loading:{showPlaceholders:!0,placeholderCount:10,showSpinner:!0},pagination:{itemsPerPage:20,showPageSize:!0}},validation:{maxSize:"10MB",formats:["jpg","jpeg","png","webp","gif"],minWidth:null,minHeight:null,maxWidth:null,maxHeight:null},downloadFormat:"webp",return:{format:"url",autoAssign:!0,includeMetadata:!1},autoInputs:{dataset:"data-limbo-input-file",buttonText:"Seleccionar imagen",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}}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(n=>{e[n]&&"object"==typeof e[n]&&!Array.isArray(e[n])?t[n]=this._deepMerge(t[n]||{},e[n]):t[n]=e[n]})}),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 n=t||this.merge();return this._getValueByPath(n,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,n){const r=t.split("."),a=r.pop();r.reduce((e,t)=>(e[t]&&"object"==typeof e[t]||(e[t]={}),e[t]),e)[a]=n}_getOriginalDefaults(){return{container:"#limbo-default",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],ui:{showActions:["select","download","copy","delete","crop"],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,enabledFilters:["name","date"],customFilters:[]},loading:{showPlaceholders:!0,placeholderCount:10,showSpinner:!0},pagination:{itemsPerPage:20,showPageSize:!0}},validation:{maxSize:"10MB",formats:["jpg","jpeg","png","webp","gif"],minWidth:null,minHeight:null,maxWidth:null,maxHeight:null},return:{format:"url",autoAssign:!0,includeMetadata:!1},autoInputs:{dataset:"data-limbo-input-file",buttonText:"Seleccionar imagen",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,n)=>{e.name&&e.ratio||t.push(`Aspect preset ${n}: 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,n)=>{e.name&&e.width||t.push(`Size preset ${n}: 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 n=[...e.aspects?.map(e=>e.name)||[],...e.sizes?.map(e=>e.name)||[]];e.required.forEach(e=>{n.includes(e)||t.push(`Required preset "${e}" not found in available presets`)})}return t}getPreset(e,t,n="aspect"){const r=e.presets||this.defaults.presets;return"aspect"===n?r.aspects?.find(e=>e.name===t):"size"===n?r.sizes?.find(e=>e.name===t):null}isPresetRequired(e,t){const n=e.presets||this.defaults.presets;return n.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 n=e.i18n||this.defaults.i18n;let r=n.locale;if(n.autoDetect&&"auto"===r){const e=(navigator.language||navigator.userLanguage).split("-")[0];r=["es","en"].includes(e)?e:"es"}else n.autoDetect&&!r&&(r="es");return new t(r,n.messages)}validate(e){const t=[],n=this._deepMerge(this.globalConfig.auth||{},e.auth||{}),r=e.apiKey||this.globalConfig.apiKey;if("jwt"!==n.authMode&&r||n.apiKey||t.push("auth.apiKey es requerido para autenticación JWT"),"legacy"!==n.authMode||r||t.push("apiKey es requerido para modo legacy"),n.apiKey||r||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 n=this._validatePresets(e.presets);t.push(...n)}return{isValid:0===t.length,errors:t}}setJWTAuth(e,t=null,n={}){const r={apiKey:e,publicKey:t,authMode:"jwt",tokenStorage:n.tokenStorage||"memory",autoRefresh:!1!==n.autoRefresh,refreshBuffer:n.refreshBuffer||30,portal:n.portal||null,...n};return this.set("auth",r),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 n=this.getGalleryFilters(t);return n.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}}function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var a,i,o={exports:{}},s={};function l(){if(a)return s;a=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.iterator;var p={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},f=Object.assign,g={};function b(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||p}function y(){}function v(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||p}b.prototype.isReactComponent={},b.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},b.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},y.prototype=b.prototype;var x=v.prototype=new y;x.constructor=v,f(x,b.prototype),x.isPureReactComponent=!0;var w=Array.isArray,k={H:null,A:null,T:null,S:null,V:null},S=Object.prototype.hasOwnProperty;function C(t,n,r,a,i,o){return r=o.ref,{$$typeof:e,type:t,key:n,ref:void 0!==r?r:null,props:o}}function E(t){return"object"==typeof t&&null!==t&&t.$$typeof===e}var N=/\/+/g;function j(e,t){return"object"==typeof e&&null!==e&&null!=e.key?(n=""+e.key,r={"=":"=0",":":"=2"},"$"+n.replace(/[=:]/g,function(e){return r[e]})):t.toString(36);var n,r}function _(){}function $(n,r,a,i,o){var s=typeof n;"undefined"!==s&&"boolean"!==s||(n=null);var l,c,u=!1;if(null===n)u=!0;else switch(s){case"bigint":case"string":case"number":u=!0;break;case"object":switch(n.$$typeof){case e:case t:u=!0;break;case m:return $((u=n._init)(n._payload),r,a,i,o)}}if(u)return o=o(n),u=""===i?"."+j(n,0):i,w(o)?(a="",null!=u&&(a=u.replace(N,"$&/")+"/"),$(o,r,a,"",function(e){return e})):null!=o&&(E(o)&&(l=o,c=a+(null==o.key||n&&n.key===o.key?"":(""+o.key).replace(N,"$&/")+"/")+u,o=C(l.type,c,void 0,0,0,l.props)),r.push(o)),1;u=0;var d,p=""===i?".":i+":";if(w(n))for(var f=0;f<n.length;f++)u+=$(i=n[f],r,a,s=p+j(i,f),o);else if("function"==typeof(f=null===(d=n)||"object"!=typeof d?null:"function"==typeof(d=h&&d[h]||d["@@iterator"])?d:null))for(n=f.call(n),f=0;!(i=n.next()).done;)u+=$(i=i.value,r,a,s=p+j(i,f++),o);else if("object"===s){if("function"==typeof n.then)return $(function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch("string"==typeof e.status?e.then(_,_):(e.status="pending",e.then(function(t){"pending"===e.status&&(e.status="fulfilled",e.value=t)},function(t){"pending"===e.status&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}(n),r,a,i,o);throw r=String(n),Error("Objects are not valid as a React child (found: "+("[object Object]"===r?"object with keys {"+Object.keys(n).join(", ")+"}":r)+"). If you meant to render a collection of children, use an array instead.")}return u}function z(e,t,n){if(null==e)return e;var r=[],a=0;return $(e,r,"","",function(e){return t.call(n,e,a++)}),r}function T(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var A="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)};function P(){}return s.Children={map:z,forEach:function(e,t,n){z(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return z(e,function(){t++}),t},toArray:function(e){return z(e,function(e){return e})||[]},only:function(e){if(!E(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},s.Component=b,s.Fragment=n,s.Profiler=i,s.PureComponent=v,s.StrictMode=r,s.Suspense=u,s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=k,s.__COMPILER_RUNTIME={__proto__:null,c:function(e){return k.H.useMemoCache(e)}},s.cache=function(e){return function(){return e.apply(null,arguments)}},s.cloneElement=function(e,t,n){if(null==e)throw Error("The argument must be a React element, but you passed "+e+".");var r=f({},e.props),a=e.key;if(null!=t)for(i in void 0!==t.ref&&void 0,void 0!==t.key&&(a=""+t.key),t)!S.call(t,i)||"key"===i||"__self"===i||"__source"===i||"ref"===i&&void 0===t.ref||(r[i]=t[i]);var i=arguments.length-2;if(1===i)r.children=n;else if(1<i){for(var o=Array(i),s=0;s<i;s++)o[s]=arguments[s+2];r.children=o}return C(e.type,a,void 0,0,0,r)},s.createContext=function(e){return(e={$$typeof:l,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider=e,e.Consumer={$$typeof:o,_context:e},e},s.createElement=function(e,t,n){var r,a={},i=null;if(null!=t)for(r in void 0!==t.key&&(i=""+t.key),t)S.call(t,r)&&"key"!==r&&"__self"!==r&&"__source"!==r&&(a[r]=t[r]);var o=arguments.length-2;if(1===o)a.children=n;else if(1<o){for(var s=Array(o),l=0;l<o;l++)s[l]=arguments[l+2];a.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps)void 0===a[r]&&(a[r]=o[r]);return C(e,i,void 0,0,0,a)},s.createRef=function(){return{current:null}},s.forwardRef=function(e){return{$$typeof:c,render:e}},s.isValidElement=E,s.lazy=function(e){return{$$typeof:m,_payload:{_status:-1,_result:e},_init:T}},s.memo=function(e,t){return{$$typeof:d,type:e,compare:void 0===t?null:t}},s.startTransition=function(e){var t=k.T,n={};k.T=n;try{var r=e(),a=k.S;null!==a&&a(n,r),"object"==typeof r&&null!==r&&"function"==typeof r.then&&r.then(P,A)}catch(i){A(i)}finally{k.T=t}},s.unstable_useCacheRefresh=function(){return k.H.useCacheRefresh()},s.use=function(e){return k.H.use(e)},s.useActionState=function(e,t,n){return k.H.useActionState(e,t,n)},s.useCallback=function(e,t){return k.H.useCallback(e,t)},s.useContext=function(e){return k.H.useContext(e)},s.useDebugValue=function(){},s.useDeferredValue=function(e,t){return k.H.useDeferredValue(e,t)},s.useEffect=function(e,t,n){var r=k.H;if("function"==typeof n)throw Error("useEffect CRUD overload is not enabled in this build of React.");return r.useEffect(e,t)},s.useId=function(){return k.H.useId()},s.useImperativeHandle=function(e,t,n){return k.H.useImperativeHandle(e,t,n)},s.useInsertionEffect=function(e,t){return k.H.useInsertionEffect(e,t)},s.useLayoutEffect=function(e,t){return k.H.useLayoutEffect(e,t)},s.useMemo=function(e,t){return k.H.useMemo(e,t)},s.useOptimistic=function(e,t){return k.H.useOptimistic(e,t)},s.useReducer=function(e,t,n){return k.H.useReducer(e,t,n)},s.useRef=function(e){return k.H.useRef(e)},s.useState=function(e){return k.H.useState(e)},s.useSyncExternalStore=function(e,t,n){return k.H.useSyncExternalStore(e,t,n)},s.useTransition=function(){return k.H.useTransition()},s.version="19.1.1",s}function c(){return i||(i=1,o.exports=l()),o.exports}var u=c();const d=r(u);var m,h,p={exports:{}},f={},g={exports:{}},b={};function y(){return h||(h=1,g.exports=(m||(m=1,function(e){function t(e,t){var n=e.length;e.push(t);e:for(;0<n;){var r=n-1>>>1,i=e[r];if(!(0<a(i,t)))break e;e[r]=t,e[n]=i,n=r}}function n(e){return 0===e.length?null:e[0]}function r(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var r=0,i=e.length,o=i>>>1;r<o;){var s=2*(r+1)-1,l=e[s],c=s+1,u=e[c];if(0>a(l,n))c<i&&0>a(u,l)?(e[r]=u,e[c]=n,r=c):(e[r]=l,e[s]=n,r=s);else{if(!(c<i&&0>a(u,n)))break e;e[r]=u,e[c]=n,r=c}}}return t}function a(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if(e.unstable_now=void 0,"object"==typeof performance&&"function"==typeof performance.now){var i=performance;e.unstable_now=function(){return i.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var l=[],c=[],u=1,d=null,m=3,h=!1,p=!1,f=!1,g=!1,b="function"==typeof setTimeout?setTimeout:null,y="function"==typeof clearTimeout?clearTimeout:null,v="undefined"!=typeof setImmediate?setImmediate:null;function x(e){for(var a=n(c);null!==a;){if(null===a.callback)r(c);else{if(!(a.startTime<=e))break;r(c),a.sortIndex=a.expirationTime,t(l,a)}a=n(c)}}function w(e){if(f=!1,x(e),!p)if(null!==n(l))p=!0,S||(S=!0,k());else{var t=n(c);null!==t&&T(w,t.startTime-e)}}var k,S=!1,C=-1,E=5,N=-1;function j(){return!(!g&&e.unstable_now()-N<E)}function _(){if(g=!1,S){var t=e.unstable_now();N=t;var a=!0;try{e:{p=!1,f&&(f=!1,y(C),C=-1),h=!0;var i=m;try{t:{for(x(t),d=n(l);null!==d&&!(d.expirationTime>t&&j());){var o=d.callback;if("function"==typeof o){d.callback=null,m=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),"function"==typeof s){d.callback=s,x(t),a=!0;break t}d===n(l)&&r(l),x(t)}else r(l);d=n(l)}if(null!==d)a=!0;else{var u=n(c);null!==u&&T(w,u.startTime-t),a=!1}}break e}finally{d=null,m=i,h=!1}a=void 0}}finally{a?k():S=!1}}}if("function"==typeof v)k=function(){v(_)};else if("undefined"!=typeof MessageChannel){var $=new MessageChannel,z=$.port2;$.port1.onmessage=_,k=function(){z.postMessage(null)}}else k=function(){b(_,0)};function T(t,n){C=b(function(){t(e.unstable_now())},n)}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"):E=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return m},e.unstable_next=function(e){switch(m){case 1:case 2:case 3:var t=3;break;default:t=m}var n=m;m=t;try{return e()}finally{m=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=m;m=e;try{return t()}finally{m=n}},e.unstable_scheduleCallback=function(r,a,i){var o=e.unstable_now();switch(i="object"==typeof i&&null!==i&&"number"==typeof(i=i.delay)&&0<i?o+i:o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return r={id:u++,callback:a,priorityLevel:r,startTime:i,expirationTime:s=i+s,sortIndex:-1},i>o?(r.sortIndex=i,t(c,r),null===n(l)&&r===n(c)&&(f?(y(C),C=-1):f=!0,T(w,i-o))):(r.sortIndex=s,t(l,r),p||h||(p=!0,S||(S=!0,k()))),r},e.unstable_shouldYield=j,e.unstable_wrapCallback=function(e){var t=m;return function(){var n=m;m=t;try{return e.apply(this,arguments)}finally{m=n}}}}(b)),b)),g.exports}var v,x,w,k,S={exports:{}},C={};function E(){if(v)return C;v=1;var e=c();function t(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}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 n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},a=Symbol.for("react.portal");var i=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function o(e,t){return"font"===e?"":"string"==typeof t?"use-credentials"===t?t:"":void 0}return C.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,C.createPortal=function(e,n){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!n||1!==n.nodeType&&9!==n.nodeType&&11!==n.nodeType)throw Error(t(299));return function(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:a,key:null==r?null:""+r,children:e,containerInfo:t,implementation:n}}(e,n,null,r)},C.flushSync=function(e){var t=i.T,n=r.p;try{if(i.T=null,r.p=2,e)return e()}finally{i.T=t,r.p=n,r.d.f()}},C.preconnect=function(e,t){"string"==typeof e&&(t?t="string"==typeof(t=t.crossOrigin)?"use-credentials"===t?t:"":void 0:t=null,r.d.C(e,t))},C.prefetchDNS=function(e){"string"==typeof e&&r.d.D(e)},C.preinit=function(e,t){if("string"==typeof e&&t&&"string"==typeof t.as){var n=t.as,a=o(n,t.crossOrigin),i="string"==typeof t.integrity?t.integrity:void 0,s="string"==typeof t.fetchPriority?t.fetchPriority:void 0;"style"===n?r.d.S(e,"string"==typeof t.precedence?t.precedence:void 0,{crossOrigin:a,integrity:i,fetchPriority:s}):"script"===n&&r.d.X(e,{crossOrigin:a,integrity:i,fetchPriority:s,nonce:"string"==typeof t.nonce?t.nonce:void 0})}},C.preinitModule=function(e,t){if("string"==typeof e)if("object"==typeof t&&null!==t){if(null==t.as||"script"===t.as){var n=o(t.as,t.crossOrigin);r.d.M(e,{crossOrigin:n,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0})}}else null==t&&r.d.M(e)},C.preload=function(e,t){if("string"==typeof e&&"object"==typeof t&&null!==t&&"string"==typeof t.as){var n=t.as,a=o(n,t.crossOrigin);r.d.L(e,n,{crossOrigin:a,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0,type:"string"==typeof t.type?t.type:void 0,fetchPriority:"string"==typeof t.fetchPriority?t.fetchPriority:void 0,referrerPolicy:"string"==typeof t.referrerPolicy?t.referrerPolicy:void 0,imageSrcSet:"string"==typeof t.imageSrcSet?t.imageSrcSet:void 0,imageSizes:"string"==typeof t.imageSizes?t.imageSizes:void 0,media:"string"==typeof t.media?t.media:void 0})}},C.preloadModule=function(e,t){if("string"==typeof e)if(t){var n=o(t.as,t.crossOrigin);r.d.m(e,{as:"string"==typeof t.as&&"script"!==t.as?t.as:void 0,crossOrigin:n,integrity:"string"==typeof t.integrity?t.integrity:void 0})}else r.d.m(e)},C.requestFormReset=function(e){r.d.r(e)},C.unstable_batchedUpdates=function(e,t){return e(t)},C.useFormState=function(e,t,n){return i.H.useFormState(e,t,n)},C.useFormStatus=function(){return i.H.useHostTransitionStatus()},C.version="19.1.1",C}function N(){if(w)return f;w=1;var e=y(),t=c(),n=(x||(x=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)}}(),S.exports=E()),S.exports);function r(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}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 a(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType)}function i(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{!!(4098&(t=e).flags)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function o(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 s(e){if(i(e)!==e)throw Error(r(188))}function l(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=l(e)))return t;e=e.sibling}return null}var u=Object.assign,d=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),v=Symbol.for("react.provider"),k=Symbol.for("react.consumer"),C=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),T=Symbol.for("react.activity"),A=Symbol.for("react.memo_cache_sentinel"),P=Symbol.iterator;function M(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=P&&e[P]||e["@@iterator"])?e:null}var I=Symbol.for("react.client.reference");function L(e){if(null==e)return null;if("function"==typeof e)return e.$$typeof===I?null:e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case p:return"Fragment";case b:return"Profiler";case g:return"StrictMode";case j:return"Suspense";case _:return"SuspenseList";case T:return"Activity"}if("object"==typeof e)switch(e.$$typeof){case h:return"Portal";case C:return(e.displayName||"Context")+".Provider";case k:return(e._context.displayName||"Context")+".Consumer";case N:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case $:return null!==(t=e.displayName||null)?t:L(e.type)||"Memo";case z:t=e._payload,e=e._init;try{return L(e(t))}catch(n){}}return null}var O=Array.isArray,R=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},U=[],q=-1;function B(e){return{current:e}}function H(e){0>q||(e.current=U[q],U[q]=null,q--)}function W(e,t){q++,U[q]=e.current,e.current=t}var V=B(null),K=B(null),G=B(null),Q=B(null);function Y(e,t){switch(W(G,t),W(K,e),W(V,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?ld(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)e=cd(t=ld(t),e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}H(V),W(V,e)}function X(){H(V),H(K),H(G)}function J(e){null!==e.memoizedState&&W(Q,e);var t=V.current,n=cd(t,e.type);t!==n&&(W(K,e),W(V,n))}function Z(e){K.current===e&&(H(V),H(K)),Q.current===e&&(H(Q),Jd._currentValue=F)}var ee=Object.prototype.hasOwnProperty,te=e.unstable_scheduleCallback,ne=e.unstable_cancelCallback,re=e.unstable_shouldYield,ae=e.unstable_requestPaint,ie=e.unstable_now,oe=e.unstable_getCurrentPriorityLevel,se=e.unstable_ImmediatePriority,le=e.unstable_UserBlockingPriority,ce=e.unstable_NormalPriority,ue=e.unstable_LowPriority,de=e.unstable_IdlePriority,me=e.log,he=e.unstable_setDisableYieldValue,pe=null,fe=null;function ge(e){if("function"==typeof me&&he(e),fe&&"function"==typeof fe.setStrictMode)try{fe.setStrictMode(pe,e)}catch(t){}}var be=Math.clz32?Math.clz32:function(e){return 0===(e>>>=0)?32:31-(ye(e)/ve|0)|0},ye=Math.log,ve=Math.LN2;var xe=256,we=4194304;function ke(e){var t=42&e;if(0!==t)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return 4194048&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Se(e,t,n){var r=e.pendingLanes;if(0===r)return 0;var a=0,i=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=134217727&r;return 0!==s?0!==(r=s&~i)?a=ke(r):0!==(o&=s)?a=ke(o):n||0!==(n=s&~e)&&(a=ke(n)):0!==(s=r&~i)?a=ke(s):0!==o?a=ke(o):n||0!==(n=r&~e)&&(a=ke(n)),0===a?0:0!==t&&t!==a&&0===(t&i)&&((i=a&-a)>=(n=t&-t)||32===i&&4194048&n)?t:a}function Ce(e,t){return 0===(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)}function Ee(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 Ne(){var e=xe;return!(4194048&(xe<<=1))&&(xe=256),e}function je(){var e=we;return!(62914560&(we<<=1))&&(we=4194304),e}function _e(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function $e(e,t){e.pendingLanes|=t,268435456!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ze(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-be(t);e.entangledLanes|=t,e.entanglements[r]=1073741824|e.entanglements[r]|4194090&n}function Te(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-be(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}function Ae(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 Pe(e){return 2<(e&=-e)?8<e?134217727&e?32:268435456:8:2}function Me(){var e=D.p;return 0!==e?e:void 0===(e=window.event)?32:hm(e.type)}var Ie=Math.random().toString(36).slice(2),Le="__reactFiber$"+Ie,Oe="__reactProps$"+Ie,Re="__reactContainer$"+Ie,De="__reactEvents$"+Ie,Fe="__reactListeners$"+Ie,Ue="__reactHandles$"+Ie,qe="__reactResources$"+Ie,Be="__reactMarker$"+Ie;function He(e){delete e[Le],delete e[Oe],delete e[De],delete e[Fe],delete e[Ue]}function We(e){var t=e[Le];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Re]||n[Le]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=Sd(e);null!==e;){if(n=e[Le])return n;e=Sd(e)}return t}n=(e=n).parentNode}return null}function Ve(e){if(e=e[Le]||e[Re]){var t=e.tag;if(5===t||6===t||13===t||26===t||27===t||3===t)return e}return null}function Ke(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e.stateNode;throw Error(r(33))}function Ge(e){var t=e[qe];return t||(t=e[qe]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Qe(e){e[Be]=!0}var Ye=new Set,Xe={};function Je(e,t){Ze(e,t),Ze(e+"Capture",t)}function Ze(e,t){for(Xe[e]=t,e=0;e<t.length;e++)Ye.add(t[e])}var et,tt,nt=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]*$"),rt={},at={};function it(e,t,n){if(a=t,ee.call(at,a)||!ee.call(rt,a)&&(nt.test(a)?at[a]=!0:(rt[a]=!0,0)))if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":return void e.removeAttribute(t);case"boolean":var r=t.toLowerCase().slice(0,5);if("data-"!==r&&"aria-"!==r)return void e.removeAttribute(t)}e.setAttribute(t,""+n)}var a}function ot(e,t,n){if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(t)}e.setAttribute(t,""+n)}}function st(e,t,n,r){if(null===r)e.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(n)}e.setAttributeNS(t,n,""+r)}}function lt(e){if(void 0===et)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);et=t&&t[1]||"",tt=-1<n.stack.indexOf("\n at")?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return"\n"+et+e+tt}var ct=!1;function ut(e,t){if(!e||ct)return"";ct=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(n,[])}catch(a){var r=a}Reflect.construct(e,[],n)}else{try{n.call()}catch(i){r=i}e.call(n.prototype)}}else{try{throw Error()}catch(o){r=o}(n=e())&&"function"==typeof n.catch&&n.catch(function(){})}}catch(s){if(s&&r&&"string"==typeof s.stack)return[s.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var a=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,"name");a&&a.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var i=r.DetermineComponentFrameRoot(),o=i[0],s=i[1];if(o&&s){var l=o.split("\n"),c=s.split("\n");for(a=r=0;r<l.length&&!l[r].includes("DetermineComponentFrameRoot");)r++;for(;a<c.length&&!c[a].includes("DetermineComponentFrameRoot");)a++;if(r===l.length||a===c.length)for(r=l.length-1,a=c.length-1;1<=r&&0<=a&&l[r]!==c[a];)a--;for(;1<=r&&0<=a;r--,a--)if(l[r]!==c[a]){if(1!==r||1!==a)do{if(r--,0>--a||l[r]!==c[a]){var u="\n"+l[r].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}}while(1<=r&&0<=a);break}}}finally{ct=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?lt(n):""}function dt(e){switch(e.tag){case 26:case 27:case 5:return lt(e.type);case 16:return lt("Lazy");case 13:return lt("Suspense");case 19:return lt("SuspenseList");case 0:case 15:return ut(e.type,!1);case 11:return ut(e.type.render,!1);case 1:return ut(e.type,!0);case 31:return lt("Activity");default:return""}}function mt(e){try{var t="";do{t+=dt(e),e=e.return}while(e);return t}catch(n){return"\nError generating stack: "+n.message+"\n"+n.stack}}function ht(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function pt(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function ft(e){e._valueTracker||(e._valueTracker=function(e){var t=pt(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&void 0!==n&&"function"==typeof n.get&&"function"==typeof n.set){var a=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(e){r=""+e,i.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e))}function gt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=pt(e)?e.checked?"true":"false":e.value),(e=r)!==n&&(t.setValue(e),!0)}function bt(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 yt=/[\n"\\]/g;function vt(e){return e.replace(yt,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function xt(e,t,n,r,a,i,o,s){e.name="",null!=o&&"function"!=typeof o&&"symbol"!=typeof o&&"boolean"!=typeof o?e.type=o:e.removeAttribute("type"),null!=t?"number"===o?(0===t&&""===e.value||e.value!=t)&&(e.value=""+ht(t)):e.value!==""+ht(t)&&(e.value=""+ht(t)):"submit"!==o&&"reset"!==o||e.removeAttribute("value"),null!=t?kt(e,o,ht(t)):null!=n?kt(e,o,ht(n)):null!=r&&e.removeAttribute("value"),null==a&&null!=i&&(e.defaultChecked=!!i),null!=a&&(e.checked=a&&"function"!=typeof a&&"symbol"!=typeof a),null!=s&&"function"!=typeof s&&"symbol"!=typeof s&&"boolean"!=typeof s?e.name=""+ht(s):e.removeAttribute("name")}function wt(e,t,n,r,a,i,o,s){if(null!=i&&"function"!=typeof i&&"symbol"!=typeof i&&"boolean"!=typeof i&&(e.type=i),null!=t||null!=n){if(("submit"===i||"reset"===i)&&null==t)return;n=null!=n?""+ht(n):"",t=null!=t?""+ht(t):n,s||t===e.value||(e.value=t),e.defaultValue=t}r="function"!=typeof(r=null!=r?r:a)&&"symbol"!=typeof r&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,null!=o&&"function"!=typeof o&&"symbol"!=typeof o&&"boolean"!=typeof o&&(e.name=o)}function kt(e,t,n){"number"===t&&bt(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function St(e,t,n,r){if(e=e.options,t){t={};for(var a=0;a<n.length;a++)t["$"+n[a]]=!0;for(n=0;n<e.length;n++)a=t.hasOwnProperty("$"+e[n].value),e[n].selected!==a&&(e[n].selected=a),a&&r&&(e[n].defaultSelected=!0)}else{for(n=""+ht(n),t=null,a=0;a<e.length;a++){if(e[a].value===n)return e[a].selected=!0,void(r&&(e[a].defaultSelected=!0));null!==t||e[a].disabled||(t=e[a])}null!==t&&(t.selected=!0)}}function Ct(e,t,n){null==t||((t=""+ht(t))!==e.value&&(e.value=t),null!=n)?e.defaultValue=null!=n?""+ht(n):"":e.defaultValue!==t&&(e.defaultValue=t)}function Et(e,t,n,a){if(null==t){if(null!=a){if(null!=n)throw Error(r(92));if(O(a)){if(1<a.length)throw Error(r(93));a=a[0]}n=a}null==n&&(n=""),t=n}n=ht(t),e.defaultValue=n,(a=e.textContent)===n&&""!==a&&null!==a&&(e.value=a)}function Nt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var jt=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,n){var r=0===t.indexOf("--");null==n||"boolean"==typeof n||""===n?r?e.setProperty(t,""):"float"===t?e.cssFloat="":e[t]="":r?e.setProperty(t,n):"number"!=typeof n||0===n||jt.has(t)?"float"===t?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function $t(e,t,n){if(null!=t&&"object"!=typeof t)throw Error(r(62));if(e=e.style,null!=n){for(var a in n)!n.hasOwnProperty(a)||null!=t&&t.hasOwnProperty(a)||(0===a.indexOf("--")?e.setProperty(a,""):"float"===a?e.cssFloat="":e[a]="");for(var i in t)a=t[i],t.hasOwnProperty(i)&&n[i]!==a&&_t(e,i,a)}else for(var o in t)t.hasOwnProperty(o)&&_t(e,o,t[o])}function zt(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 Tt=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"]]),At=/^[\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 Pt(e){return At.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}var Mt=null;function It(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var Lt=null,Ot=null;function Rt(e){var t=Ve(e);if(t&&(e=t.stateNode)){var n=e[Oe]||null;e:switch(e=t.stateNode,t.type){case"input":if(xt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,"radio"===n.type&&null!=t){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+vt(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var a=n[t];if(a!==e&&a.form===e.form){var i=a[Oe]||null;if(!i)throw Error(r(90));xt(a,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name)}}for(t=0;t<n.length;t++)(a=n[t]).form===e.form&&gt(a)}break e;case"textarea":Ct(e,n.value,n.defaultValue);break e;case"select":null!=(t=n.value)&&St(e,!!n.multiple,t,!1)}}}var Dt=!1;function Ft(e,t,n){if(Dt)return e(t,n);Dt=!0;try{return e(t)}finally{if(Dt=!1,(null!==Lt||null!==Ot)&&(Wc(),Lt&&(t=Lt,e=Ot,Ot=Lt=null,Rt(t),e)))for(t=0;t<e.length;t++)Rt(e[t])}}function Ut(e,t){var n=e.stateNode;if(null===n)return null;var a=n[Oe]||null;if(null===a)return null;n=a[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":(a=!a.disabled)||(a=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!a;break e;default:e=!1}if(e)return null;if(n&&"function"!=typeof n)throw Error(r(231,t,typeof n));return n}var qt=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),Bt=!1;if(qt)try{var Ht={};Object.defineProperty(Ht,"passive",{get:function(){Bt=!0}}),window.addEventListener("test",Ht,Ht),window.removeEventListener("test",Ht,Ht)}catch(Om){Bt=!1}var Wt=null,Vt=null,Kt=null;function Gt(){if(Kt)return Kt;var e,t,n=Vt,r=n.length,a="value"in Wt?Wt.value:Wt.textContent,i=a.length;for(e=0;e<r&&n[e]===a[e];e++);var o=r-e;for(t=1;t<=o&&n[r-t]===a[i-t];t++);return Kt=a.slice(e,1<t?1-t:void 0)}function Qt(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 Xt(){return!1}function Jt(e){function t(t,n,r,a,i){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=a,this.target=i,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(a):a[o]);return this.isDefaultPrevented=(null!=a.defaultPrevented?a.defaultPrevented:!1===a.returnValue)?Yt:Xt,this.isPropagationStopped=Xt,this}return u(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 Zt,en,tn,nn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},rn=Jt(nn),an=u({},nn,{view:0,detail:0}),on=Jt(an),sn=u({},an,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:yn,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!==tn&&(tn&&"mousemove"===e.type?(Zt=e.screenX-tn.screenX,en=e.screenY-tn.screenY):en=Zt=0,tn=e),Zt)},movementY:function(e){return"movementY"in e?e.movementY:en}}),ln=Jt(sn),cn=Jt(u({},sn,{dataTransfer:0})),un=Jt(u({},an,{relatedTarget:0})),dn=Jt(u({},nn,{animationName:0,elapsedTime:0,pseudoElement:0})),mn=Jt(u({},nn,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}})),hn=Jt(u({},nn,{data:0})),pn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},fn={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"},gn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function bn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=gn[e])&&!!t[e]}function yn(){return bn}var vn=Jt(u({},an,{key:function(e){if(e.key){var t=pn[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=Qt(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?fn[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:yn,charCode:function(e){return"keypress"===e.type?Qt(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?Qt(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}})),xn=Jt(u({},sn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),wn=Jt(u({},an,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:yn})),kn=Jt(u({},nn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Sn=Jt(u({},sn,{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})),Cn=Jt(u({},nn,{newState:0,oldState:0})),En=[9,13,27,32],Nn=qt&&"CompositionEvent"in window,jn=null;qt&&"documentMode"in document&&(jn=document.documentMode);var _n=qt&&"TextEvent"in window&&!jn,$n=qt&&(!Nn||jn&&8<jn&&11>=jn),zn=String.fromCharCode(32),Tn=!1;function An(e,t){switch(e){case"keyup":return-1!==En.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Pn(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Mn=!1;var In={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 Ln(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!In[e.type]:"textarea"===t}function On(e,t,n,r){Lt?Ot?Ot.push(r):Ot=[r]:Lt=r,0<(t=Gu(t,"onChange")).length&&(n=new rn("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Rn=null,Dn=null;function Fn(e){Fu(e,0)}function Un(e){if(gt(Ke(e)))return e}function qn(e,t){if("change"===e)return t}var Bn=!1;if(qt){var Hn;if(qt){var Wn="oninput"in document;if(!Wn){var Vn=document.createElement("div");Vn.setAttribute("oninput","return;"),Wn="function"==typeof Vn.oninput}Hn=Wn}else Hn=!1;Bn=Hn&&(!document.documentMode||9<document.documentMode)}function Kn(){Rn&&(Rn.detachEvent("onpropertychange",Gn),Dn=Rn=null)}function Gn(e){if("value"===e.propertyName&&Un(Dn)){var t=[];On(t,Dn,e,It(e)),Ft(Fn,t)}}function Qn(e,t,n){"focusin"===e?(Kn(),Dn=n,(Rn=t).attachEvent("onpropertychange",Gn)):"focusout"===e&&Kn()}function Yn(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Un(Dn)}function Xn(e,t){if("click"===e)return Un(t)}function Jn(e,t){if("input"===e||"change"===e)return Un(t)}var Zn="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t};function er(e,t){if(Zn(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var a=n[r];if(!ee.call(t,a)||!Zn(e[a],t[a]))return!1}return!0}function tr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function nr(e,t){var n,r=tr(e);for(e=0;r;){if(3===r.nodeType){if(n=e+r.textContent.length,e<=t&&n>=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=tr(r)}}function rr(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?rr(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function ar(e){for(var t=bt((e=null!=e&&null!=e.ownerDocument&&null!=e.ownerDocument.defaultView?e.ownerDocument.defaultView:window).document);t instanceof e.HTMLIFrameElement;){try{var n="string"==typeof t.contentWindow.location.href}catch(r){n=!1}if(!n)break;t=bt((e=t.contentWindow).document)}return t}function ir(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 or=qt&&"documentMode"in document&&11>=document.documentMode,sr=null,lr=null,cr=null,ur=!1;function dr(e,t,n){var r=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;ur||null==sr||sr!==bt(r)||("selectionStart"in(r=sr)&&ir(r)?r={start:r.selectionStart,end:r.selectionEnd}:r={anchorNode:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset},cr&&er(cr,r)||(cr=r,0<(r=Gu(lr,"onSelect")).length&&(t=new rn("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=sr)))}function mr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var hr={animationend:mr("Animation","AnimationEnd"),animationiteration:mr("Animation","AnimationIteration"),animationstart:mr("Animation","AnimationStart"),transitionrun:mr("Transition","TransitionRun"),transitionstart:mr("Transition","TransitionStart"),transitioncancel:mr("Transition","TransitionCancel"),transitionend:mr("Transition","TransitionEnd")},pr={},fr={};function gr(e){if(pr[e])return pr[e];if(!hr[e])return e;var t,n=hr[e];for(t in n)if(n.hasOwnProperty(t)&&t in fr)return pr[e]=n[t];return e}qt&&(fr=document.createElement("div").style,"AnimationEvent"in window||(delete hr.animationend.animation,delete hr.animationiteration.animation,delete hr.animationstart.animation),"TransitionEvent"in window||delete hr.transitionend.transition);var br=gr("animationend"),yr=gr("animationiteration"),vr=gr("animationstart"),xr=gr("transitionrun"),wr=gr("transitionstart"),kr=gr("transitioncancel"),Sr=gr("transitionend"),Cr=new Map,Er="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 Nr(e,t){Cr.set(e,t),Je(t,[e])}Er.push("scrollEnd");var jr=new WeakMap;function _r(e,t){if("object"==typeof e&&null!==e){var n=jr.get(e);return void 0!==n?n:(t={value:e,source:t,stack:mt(t)},jr.set(e,t),t)}return{value:e,source:t,stack:mt(t)}}var $r=[],zr=0,Tr=0;function Ar(){for(var e=zr,t=Tr=zr=0;t<e;){var n=$r[t];$r[t++]=null;var r=$r[t];$r[t++]=null;var a=$r[t];$r[t++]=null;var i=$r[t];if($r[t++]=null,null!==r&&null!==a){var o=r.pending;null===o?a.next=a:(a.next=o.next,o.next=a),r.pending=a}0!==i&&Lr(n,a,i)}}function Pr(e,t,n,r){$r[zr++]=e,$r[zr++]=t,$r[zr++]=n,$r[zr++]=r,Tr|=r,e.lanes|=r,null!==(e=e.alternate)&&(e.lanes|=r)}function Mr(e,t,n,r){return Pr(e,t,n,r),Or(e)}function Ir(e,t){return Pr(e,null,null,t),Or(e)}function Lr(e,t,n){e.lanes|=n;var r=e.alternate;null!==r&&(r.lanes|=n);for(var a=!1,i=e.return;null!==i;)i.childLanes|=n,null!==(r=i.alternate)&&(r.childLanes|=n),22===i.tag&&(null===(e=i.stateNode)||1&e._visibility||(a=!0)),e=i,i=i.return;return 3===e.tag?(i=e.stateNode,a&&null!==t&&(a=31-be(n),null===(r=(e=i.hiddenUpdates)[a])?e[a]=[t]:r.push(t),t.lane=536870912|n),i):null}function Or(e){if(50<Lc)throw Lc=0,Oc=null,Error(r(185));for(var t=e.return;null!==t;)t=(e=t).return;return 3===e.tag?e.stateNode:null}var Rr={};function Dr(e,t,n,r){this.tag=e,this.key=n,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=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Fr(e,t,n,r){return new Dr(e,t,n,r)}function Ur(e){return!(!(e=e.prototype)||!e.isReactComponent)}function qr(e,t){var n=e.alternate;return null===n?((n=Fr(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=65011712&e.flags,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Br(e,t){e.flags&=65011714;var n=e.alternate;return null===n?(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=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Hr(e,t,n,a,i,o){var s=0;if(a=e,"function"==typeof e)Ur(e)&&(s=1);else if("string"==typeof e)s=function(e,t,n){if(1===n||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,n,V.current)?26:"html"===e||"head"===e||"body"===e?27:5;else e:switch(e){case T:return(e=Fr(31,n,t,i)).elementType=T,e.lanes=o,e;case p:return Wr(n.children,i,o,t);case g:s=8,i|=24;break;case b:return(e=Fr(12,n,t,2|i)).elementType=b,e.lanes=o,e;case j:return(e=Fr(13,n,t,i)).elementType=j,e.lanes=o,e;case _:return(e=Fr(19,n,t,i)).elementType=_,e.lanes=o,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case v:case C:s=10;break e;case k:s=9;break e;case N:s=11;break e;case $:s=14;break e;case z:s=16,a=null;break e}s=29,n=Error(r(130,null===e?"null":typeof e,"")),a=null}return(t=Fr(s,n,t,i)).elementType=e,t.type=a,t.lanes=o,t}function Wr(e,t,n,r){return(e=Fr(7,e,r,t)).lanes=n,e}function Vr(e,t,n){return(e=Fr(6,e,null,t)).lanes=n,e}function Kr(e,t,n){return(t=Fr(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Gr=[],Qr=0,Yr=null,Xr=0,Jr=[],Zr=0,ea=null,ta=1,na="";function ra(e,t){Gr[Qr++]=Xr,Gr[Qr++]=Yr,Yr=e,Xr=t}function aa(e,t,n){Jr[Zr++]=ta,Jr[Zr++]=na,Jr[Zr++]=ea,ea=e;var r=ta;e=na;var a=32-be(r)-1;r&=~(1<<a),n+=1;var i=32-be(t)+a;if(30<i){var o=a-a%5;i=(r&(1<<o)-1).toString(32),r>>=o,a-=o,ta=1<<32-be(t)+a|n<<a|r,na=i+e}else ta=1<<i|n<<a|r,na=e}function ia(e){null!==e.return&&(ra(e,1),aa(e,1,0))}function oa(e){for(;e===Yr;)Yr=Gr[--Qr],Gr[Qr]=null,Xr=Gr[--Qr],Gr[Qr]=null;for(;e===ea;)ea=Jr[--Zr],Jr[Zr]=null,na=Jr[--Zr],Jr[Zr]=null,ta=Jr[--Zr],Jr[Zr]=null}var sa=null,la=null,ca=!1,ua=null,da=!1,ma=Error(r(519));function ha(e){throw va(_r(Error(r(418,"")),e)),ma}function pa(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[Le]=e,t[Oe]=r,n){case"dialog":Uu("cancel",t),Uu("close",t);break;case"iframe":case"object":case"embed":Uu("load",t);break;case"video":case"audio":for(n=0;n<Ru.length;n++)Uu(Ru[n],t);break;case"source":Uu("error",t);break;case"img":case"image":case"link":Uu("error",t),Uu("load",t);break;case"details":Uu("toggle",t);break;case"input":Uu("invalid",t),wt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0),ft(t);break;case"select":Uu("invalid",t);break;case"textarea":Uu("invalid",t),Et(t,r.value,r.defaultValue,r.children),ft(t)}"string"!=typeof(n=r.children)&&"number"!=typeof n&&"bigint"!=typeof n||t.textContent===""+n||!0===r.suppressHydrationWarning||ed(t.textContent,n)?(null!=r.popover&&(Uu("beforetoggle",t),Uu("toggle",t)),null!=r.onScroll&&Uu("scroll",t),null!=r.onScrollEnd&&Uu("scrollend",t),null!=r.onClick&&(t.onclick=td),t=!0):t=!1,t||ha(e)}function fa(e){for(sa=e.return;sa;)switch(sa.tag){case 5:case 13:return void(da=!1);case 27:case 3:return void(da=!0);default:sa=sa.return}}function ga(e){if(e!==sa)return!1;if(!ca)return fa(e),ca=!0,!1;var t,n=e.tag;if((t=3!==n&&27!==n)&&((t=5===n)&&(t=!("form"!==(t=e.type)&&"button"!==t)||ud(e.type,e.memoizedProps)),t=!t),t&&la&&ha(e),fa(e),13===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(r(317));e:{for(e=e.nextSibling,n=0;e;){if(8===e.nodeType)if("/$"===(t=e.data)){if(0===n){la=wd(e.nextSibling);break e}n--}else"$"!==t&&"$!"!==t&&"$?"!==t||n++;e=e.nextSibling}la=null}}else 27===n?(n=la,bd(e.type)?(e=kd,kd=null,la=e):la=n):la=sa?wd(e.stateNode.nextSibling):null;return!0}function ba(){la=sa=null,ca=!1}function ya(){var e=ua;return null!==e&&(null===Sc?Sc=e:Sc.push.apply(Sc,e),ua=null),e}function va(e){null===ua?ua=[e]:ua.push(e)}var xa=B(null),wa=null,ka=null;function Sa(e,t,n){W(xa,t._currentValue),t._currentValue=n}function Ca(e){e._currentValue=xa.current,H(xa)}function Ea(e,t,n){for(;null!==e;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==r&&(r.childLanes|=t)):null!==r&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Na(e,t,n,a){var i=e.child;for(null!==i&&(i.return=e);null!==i;){var o=i.dependencies;if(null!==o){var s=i.child;o=o.firstContext;e:for(;null!==o;){var l=o;o=i;for(var c=0;c<t.length;c++)if(l.context===t[c]){o.lanes|=n,null!==(l=o.alternate)&&(l.lanes|=n),Ea(o.return,n,e),a||(s=null);break e}o=l.next}}else if(18===i.tag){if(null===(s=i.return))throw Error(r(341));s.lanes|=n,null!==(o=s.alternate)&&(o.lanes|=n),Ea(s,n,e),s=null}else s=i.child;if(null!==s)s.return=i;else for(s=i;null!==s;){if(s===e){s=null;break}if(null!==(i=s.sibling)){i.return=s.return,s=i;break}s=s.return}i=s}}function ja(e,t,n,a){e=null;for(var i=t,o=!1;null!==i;){if(!o)if(524288&i.flags)o=!0;else if(262144&i.flags)break;if(10===i.tag){var s=i.alternate;if(null===s)throw Error(r(387));if(null!==(s=s.memoizedProps)){var l=i.type;Zn(i.pendingProps.value,s.value)||(null!==e?e.push(l):e=[l])}}else if(i===Q.current){if(null===(s=i.alternate))throw Error(r(387));s.memoizedState.memoizedState!==i.memoizedState.memoizedState&&(null!==e?e.push(Jd):e=[Jd])}i=i.return}null!==e&&Na(t,e,n,a),t.flags|=262144}function _a(e){for(e=e.firstContext;null!==e;){if(!Zn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function $a(e){wa=e,ka=null,null!==(e=e.dependencies)&&(e.firstContext=null)}function za(e){return Aa(wa,e)}function Ta(e,t){return null===wa&&$a(e),Aa(e,t)}function Aa(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},null===ka){if(null===e)throw Error(r(308));ka=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else ka=ka.next=t;return n}var Pa="undefined"!=typeof AbortController?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Ma=e.unstable_scheduleCallback,Ia=e.unstable_NormalPriority,La={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Oa(){return{controller:new Pa,data:new Map,refCount:0}}function Ra(e){e.refCount--,0===e.refCount&&Ma(Ia,function(){e.controller.abort()})}var Da=null,Fa=0,Ua=0,qa=null;function Ba(){if(0===--Fa&&null!==Da){null!==qa&&(qa.status="fulfilled");var e=Da;Da=null,Ua=0,qa=null;for(var t=0;t<e.length;t++)(0,e[t])()}}var Ha=R.S;R.S=function(e,t){"object"==typeof t&&null!==t&&"function"==typeof t.then&&function(e,t){if(null===Da){var n=Da=[];Fa=0,Ua=Pu(),qa={status:"pending",value:void 0,then:function(e){n.push(e)}}}Fa++,t.then(Ba,Ba)}(0,t),null!==Ha&&Ha(e,t)};var Wa=B(null);function Va(){var e=Wa.current;return null!==e?e:sc.pooledCache}function Ka(e,t){W(Wa,null===t?Wa.current:t.pool)}function Ga(){var e=Va();return null===e?null:{parent:La._currentValue,pool:e}}var Qa=Error(r(460)),Ya=Error(r(474)),Xa=Error(r(542)),Ja={then:function(){}};function Za(e){return"fulfilled"===(e=e.status)||"rejected"===e}function ei(){}function ti(e,t,n){switch(void 0===(n=e[n])?e.push(t):n!==t&&(t.then(ei,ei),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw ai(e=t.reason),e;default:if("string"==typeof t.status)t.then(ei,ei);else{if(null!==(e=sc)&&100<e.shellSuspendCounter)throw Error(r(482));(e=t).status="pending",e.then(function(e){if("pending"===t.status){var n=t;n.status="fulfilled",n.value=e}},function(e){if("pending"===t.status){var n=t;n.status="rejected",n.reason=e}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw ai(e=t.reason),e}throw ni=t,Qa}}var ni=null;function ri(){if(null===ni)throw Error(r(459));var e=ni;return ni=null,e}function ai(e){if(e===Qa||e===Xa)throw Error(r(483))}var ii=!1;function oi(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function si(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 li(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ci(e,t,n){var r=e.updateQueue;if(null===r)return null;if(r=r.shared,2&oc){var a=r.pending;return null===a?t.next=t:(t.next=a.next,a.next=t),r.pending=t,t=Or(e),Lr(e,null,n),t}return Pr(e,r,t,n),Or(e)}function ui(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,4194048&n)){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,Te(e,n)}}function di(e,t){var n=e.updateQueue,r=e.alternate;if(null!==r&&n===(r=r.updateQueue)){var a=null,i=null;if(null!==(n=n.firstBaseUpdate)){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};null===i?a=i=o:i=i.next=o,n=n.next}while(null!==n);null===i?a=i=t:i=i.next=t}else a=i=t;return n={baseState:r.baseState,firstBaseUpdate:a,lastBaseUpdate:i,shared:r.shared,callbacks:r.callbacks},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var mi=!1;function hi(){if(mi){if(null!==qa)throw qa}}function pi(e,t,n,r){mi=!1;var a=e.updateQueue;ii=!1;var i=a.firstBaseUpdate,o=a.lastBaseUpdate,s=a.shared.pending;if(null!==s){a.shared.pending=null;var l=s,c=l.next;l.next=null,null===o?i=c:o.next=c,o=l;var d=e.alternate;null!==d&&((s=(d=d.updateQueue).lastBaseUpdate)!==o&&(null===s?d.firstBaseUpdate=c:s.next=c,d.lastBaseUpdate=l))}if(null!==i){var m=a.baseState;for(o=0,d=c=l=null,s=i;;){var h=-536870913&s.lane,p=h!==s.lane;if(p?(cc&h)===h:(r&h)===h){0!==h&&h===Ua&&(mi=!0),null!==d&&(d=d.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});e:{var f=e,g=s;h=t;var b=n;switch(g.tag){case 1:if("function"==typeof(f=g.payload)){m=f.call(b,m,h);break e}m=f;break e;case 3:f.flags=-65537&f.flags|128;case 0:if(null==(h="function"==typeof(f=g.payload)?f.call(b,m,h):f))break e;m=u({},m,h);break e;case 2:ii=!0}}null!==(h=s.callback)&&(e.flags|=64,p&&(e.flags|=8192),null===(p=a.callbacks)?a.callbacks=[h]:p.push(h))}else p={lane:h,tag:s.tag,payload:s.payload,callback:s.callback,next:null},null===d?(c=d=p,l=m):d=d.next=p,o|=h;if(null===(s=s.next)){if(null===(s=a.shared.pending))break;s=(p=s).next,p.next=null,a.lastBaseUpdate=p,a.shared.pending=null}}null===d&&(l=m),a.baseState=l,a.firstBaseUpdate=c,a.lastBaseUpdate=d,null===i&&(a.shared.lanes=0),bc|=o,e.lanes=o,e.memoizedState=m}}function fi(e,t){if("function"!=typeof e)throw Error(r(191,e));e.call(t)}function gi(e,t){var n=e.callbacks;if(null!==n)for(e.callbacks=null,e=0;e<n.length;e++)fi(n[e],t)}var bi=B(null),yi=B(0);function vi(e,t){W(yi,e=fc),W(bi,t),fc=e|t.baseLanes}function xi(){W(yi,fc),W(bi,bi.current)}function wi(){fc=yi.current,H(bi),H(yi)}var ki=0,Si=null,Ci=null,Ei=null,Ni=!1,ji=!1,_i=!1,$i=0,zi=0,Ti=null,Ai=0;function Pi(){throw Error(r(321))}function Mi(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Zn(e[n],t[n]))return!1;return!0}function Ii(e,t,n,r,a,i){return ki=i,Si=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,R.H=null===e||null===e.memoizedState?Yo:Xo,_i=!1,i=n(r,a),_i=!1,ji&&(i=Oi(t,n,r,a)),Li(e),i}function Li(e){R.H=Qo;var t=null!==Ci&&null!==Ci.next;if(ki=0,Ei=Ci=Si=null,Ni=!1,zi=0,Ti=null,t)throw Error(r(300));null===e||Ts||null!==(e=e.dependencies)&&_a(e)&&(Ts=!0)}function Oi(e,t,n,a){Si=e;var i=0;do{if(ji&&(Ti=null),zi=0,ji=!1,25<=i)throw Error(r(301));if(i+=1,Ei=Ci=null,null!=e.updateQueue){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,null!=o.memoCache&&(o.memoCache.index=0)}R.H=Jo,o=t(n,a)}while(ji);return o}function Ri(){var e=R.H,t=e.useState()[0];return t="function"==typeof t.then?Hi(t):t,e=e.useState()[0],(null!==Ci?Ci.memoizedState:null)!==e&&(Si.flags|=1024),t}function Di(){var e=0!==$i;return $i=0,e}function Fi(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Ui(e){if(Ni){for(e=e.memoizedState;null!==e;){var t=e.queue;null!==t&&(t.pending=null),e=e.next}Ni=!1}ki=0,Ei=Ci=Si=null,ji=!1,zi=$i=0,Ti=null}function qi(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===Ei?Si.memoizedState=Ei=e:Ei=Ei.next=e,Ei}function Bi(){if(null===Ci){var e=Si.alternate;e=null!==e?e.memoizedState:null}else e=Ci.next;var t=null===Ei?Si.memoizedState:Ei.next;if(null!==t)Ei=t,Ci=e;else{if(null===e){if(null===Si.alternate)throw Error(r(467));throw Error(r(310))}e={memoizedState:(Ci=e).memoizedState,baseState:Ci.baseState,baseQueue:Ci.baseQueue,queue:Ci.queue,next:null},null===Ei?Si.memoizedState=Ei=e:Ei=Ei.next=e}return Ei}function Hi(e){var t=zi;return zi+=1,null===Ti&&(Ti=[]),e=ti(Ti,e,t),t=Si,null===(null===Ei?t.memoizedState:Ei.next)&&(t=t.alternate,R.H=null===t||null===t.memoizedState?Yo:Xo),e}function Wi(e){if(null!==e&&"object"==typeof e){if("function"==typeof e.then)return Hi(e);if(e.$$typeof===C)return za(e)}throw Error(r(438,String(e)))}function Vi(e){var t=null,n=Si.updateQueue;if(null!==n&&(t=n.memoCache),null==t){var r=Si.alternate;null!==r&&(null!==(r=r.updateQueue)&&(null!=(r=r.memoCache)&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(null==t&&(t={data:[],index:0}),null===n&&(n={lastEffect:null,events:null,stores:null,memoCache:null},Si.updateQueue=n),n.memoCache=t,void 0===(n=t.data[t.index]))for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=A;return t.index++,n}function Ki(e,t){return"function"==typeof t?t(e):t}function Gi(e){return Qi(Bi(),Ci,e)}function Qi(e,t,n){var a=e.queue;if(null===a)throw Error(r(311));a.lastRenderedReducer=n;var i=e.baseQueue,o=a.pending;if(null!==o){if(null!==i){var s=i.next;i.next=o.next,o.next=s}t.baseQueue=i=o,a.pending=null}if(o=e.baseState,null===i)e.memoizedState=o;else{var l=s=null,c=null,u=t=i.next,d=!1;do{var m=-536870913&u.lane;if(m!==u.lane?(cc&m)===m:(ki&m)===m){var h=u.revertLane;if(0===h)null!==c&&(c=c.next={lane:0,revertLane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),m===Ua&&(d=!0);else{if((ki&h)===h){u=u.next,h===Ua&&(d=!0);continue}m={lane:0,revertLane:u.revertLane,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(l=c=m,s=o):c=c.next=m,Si.lanes|=h,bc|=h}m=u.action,_i&&n(o,m),o=u.hasEagerState?u.eagerState:n(o,m)}else h={lane:m,revertLane:u.revertLane,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(l=c=h,s=o):c=c.next=h,Si.lanes|=m,bc|=m;u=u.next}while(null!==u&&u!==t);if(null===c?s=o:c.next=l,!Zn(o,e.memoizedState)&&(Ts=!0,d&&null!==(n=qa)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=c,a.lastRenderedState=o}return null===i&&(a.lanes=0),[e.memoizedState,a.dispatch]}function Yi(e){var t=Bi(),n=t.queue;if(null===n)throw Error(r(311));n.lastRenderedReducer=e;var a=n.dispatch,i=n.pending,o=t.memoizedState;if(null!==i){n.pending=null;var s=i=i.next;do{o=e(o,s.action),s=s.next}while(s!==i);Zn(o,t.memoizedState)||(Ts=!0),t.memoizedState=o,null===t.baseQueue&&(t.baseState=o),n.lastRenderedState=o}return[o,a]}function Xi(e,t,n){var a=Si,i=Bi(),o=ca;if(o){if(void 0===n)throw Error(r(407));n=n()}else n=t();var s=!Zn((Ci||i).memoizedState,n);if(s&&(i.memoizedState=n,Ts=!0),i=i.queue,wo(2048,8,eo.bind(null,a,i,e),[e]),i.getSnapshot!==t||s||null!==Ei&&1&Ei.memoizedState.tag){if(a.flags|=2048,yo(9,{destroy:void 0,resource:void 0},Zi.bind(null,a,i,n,t),null),null===sc)throw Error(r(349));o||124&ki||Ji(a,t,n)}return n}function Ji(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=Si.updateQueue)?(t={lastEffect:null,events:null,stores:null,memoCache:null},Si.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function Zi(e,t,n,r){t.value=n,t.getSnapshot=r,to(t)&&no(e)}function eo(e,t,n){return n(function(){to(t)&&no(e)})}function to(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Zn(e,n)}catch(r){return!0}}function no(e){var t=Ir(e,2);null!==t&&Fc(t,e,2)}function ro(e){var t=qi();if("function"==typeof e){var n=e;if(e=n(),_i){ge(!0);try{n()}finally{ge(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ki,lastRenderedState:e},t}function ao(e,t,n,r){return e.baseState=n,Qi(e,Ci,"function"==typeof r?r:Ki)}function io(e,t,n,a,i){if(Vo(e))throw Error(r(485));if(null!==(e=t.action)){var o={payload:i,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};null!==R.T?n(!0):o.isTransition=!1,a(o),null===(n=t.pending)?(o.next=t.pending=o,oo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function oo(e,t){var n=t.action,r=t.payload,a=e.state;if(t.isTransition){var i=R.T,o={};R.T=o;try{var s=n(a,r),l=R.S;null!==l&&l(o,s),so(e,t,s)}catch(c){co(e,t,c)}finally{R.T=i}}else try{so(e,t,i=n(a,r))}catch(u){co(e,t,u)}}function so(e,t,n){null!==n&&"object"==typeof n&&"function"==typeof n.then?n.then(function(n){lo(e,t,n)},function(n){return co(e,t,n)}):lo(e,t,n)}function lo(e,t,n){t.status="fulfilled",t.value=n,uo(t),e.state=n,null!==(t=e.pending)&&((n=t.next)===t?e.pending=null:(n=n.next,t.next=n,oo(e,n)))}function co(e,t,n){var r=e.pending;if(e.pending=null,null!==r){r=r.next;do{t.status="rejected",t.reason=n,uo(t),t=t.next}while(t!==r)}e.action=null}function uo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function mo(e,t){return t}function ho(e,t){if(ca){var n=sc.formState;if(null!==n){e:{var r=Si;if(ca){if(la){t:{for(var a=la,i=da;8!==a.nodeType;){if(!i){a=null;break t}if(null===(a=wd(a.nextSibling))){a=null;break t}}a="F!"===(i=a.data)||"F"===i?a:null}if(a){la=wd(a.nextSibling),r="F!"===a.data;break e}}ha(r)}r=!1}r&&(t=n[0])}}return(n=qi()).memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:mo,lastRenderedState:t},n.queue=r,n=Bo.bind(null,Si,r),r.dispatch=n,r=ro(!1),i=Wo.bind(null,Si,!1,r.queue),a={state:t,dispatch:null,action:e,pending:null},(r=qi()).queue=a,n=io.bind(null,Si,a,i,n),a.dispatch=n,r.memoizedState=e,[t,n,!1]}function po(e){return fo(Bi(),Ci,e)}function fo(e,t,n){if(t=Qi(e,t,mo)[0],e=Gi(Ki)[0],"object"==typeof t&&null!==t&&"function"==typeof t.then)try{var r=Hi(t)}catch(o){if(o===Qa)throw Xa;throw o}else r=t;var a=(t=Bi()).queue,i=a.dispatch;return n!==t.memoizedState&&(Si.flags|=2048,yo(9,{destroy:void 0,resource:void 0},go.bind(null,a,n),null)),[r,i,e]}function go(e,t){e.action=t}function bo(e){var t=Bi(),n=Ci;if(null!==n)return fo(t,n,e);Bi(),t=t.memoizedState;var r=(n=Bi()).queue.dispatch;return n.memoizedState=e,[t,r,!1]}function yo(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},null===(t=Si.updateQueue)&&(t={lastEffect:null,events:null,stores:null,memoCache:null},Si.updateQueue=t),null===(n=t.lastEffect)?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function vo(){return Bi().memoizedState}function xo(e,t,n,r){var a=qi();r=void 0===r?null:r,Si.flags|=e,a.memoizedState=yo(1|t,{destroy:void 0,resource:void 0},n,r)}function wo(e,t,n,r){var a=Bi();r=void 0===r?null:r;var i=a.memoizedState.inst;null!==Ci&&null!==r&&Mi(r,Ci.memoizedState.deps)?a.memoizedState=yo(t,i,n,r):(Si.flags|=e,a.memoizedState=yo(1|t,i,n,r))}function ko(e,t){xo(8390656,8,e,t)}function So(e,t){wo(2048,8,e,t)}function Co(e,t){return wo(4,2,e,t)}function Eo(e,t){return wo(4,4,e,t)}function No(e,t){if("function"==typeof t){e=e();var n=t(e);return function(){"function"==typeof n?n():t(null)}}if(null!=t)return e=e(),t.current=e,function(){t.current=null}}function jo(e,t,n){n=null!=n?n.concat([e]):null,wo(4,4,No.bind(null,t,e),n)}function _o(){}function $o(e,t){var n=Bi();t=void 0===t?null:t;var r=n.memoizedState;return null!==t&&Mi(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function zo(e,t){var n=Bi();t=void 0===t?null:t;var r=n.memoizedState;if(null!==t&&Mi(t,r[1]))return r[0];if(r=e(),_i){ge(!0);try{e()}finally{ge(!1)}}return n.memoizedState=[r,t],r}function To(e,t,n){return void 0===n||1073741824&ki?e.memoizedState=t:(e.memoizedState=n,e=Dc(),Si.lanes|=e,bc|=e,n)}function Ao(e,t,n,r){return Zn(n,t)?n:null!==bi.current?(e=To(e,n,r),Zn(e,t)||(Ts=!0),e):42&ki?(e=Dc(),Si.lanes|=e,bc|=e,t):(Ts=!0,e.memoizedState=n)}function Po(e,t,n,r,a){var i=D.p;D.p=0!==i&&8>i?i:8;var o,s,l,c=R.T,u={};R.T=u,Wo(e,!1,t,n);try{var d=a(),m=R.S;if(null!==m&&m(u,d),null!==d&&"object"==typeof d&&"function"==typeof d.then)Ho(e,t,(o=r,s=[],l={status:"pending",value:null,reason:null,then:function(e){s.push(e)}},d.then(function(){l.status="fulfilled",l.value=o;for(var e=0;e<s.length;e++)(0,s[e])(o)},function(e){for(l.status="rejected",l.reason=e,e=0;e<s.length;e++)(0,s[e])(void 0)}),l),Rc());else Ho(e,t,r,Rc())}catch(h){Ho(e,t,{then:function(){},status:"rejected",reason:h},Rc())}finally{D.p=i,R.T=c}}function Mo(){}function Io(e,t,n,a){if(5!==e.tag)throw Error(r(476));var i=Lo(e).queue;Po(e,i,t,F,null===n?Mo:function(){return Oo(e),n(a)})}function Lo(e){var t=e.memoizedState;if(null!==t)return t;var n={};return(t={memoizedState:F,baseState:F,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ki,lastRenderedState:F},next:null}).next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ki,lastRenderedState:n},next:null},e.memoizedState=t,null!==(e=e.alternate)&&(e.memoizedState=t),t}function Oo(e){Ho(e,Lo(e).next.queue,{},Rc())}function Ro(){return za(Jd)}function Do(){return Bi().memoizedState}function Fo(){return Bi().memoizedState}function Uo(e){for(var t=e.return;null!==t;){switch(t.tag){case 24:case 3:var n=Rc(),r=ci(t,e=li(n),n);return null!==r&&(Fc(r,t,n),ui(r,t,n)),t={cache:Oa()},void(e.payload=t)}t=t.return}}function qo(e,t,n){var r=Rc();n={lane:r,revertLane:0,action:n,hasEagerState:!1,eagerState:null,next:null},Vo(e)?Ko(t,n):null!==(n=Mr(e,t,n,r))&&(Fc(n,e,r),Go(n,t,r))}function Bo(e,t,n){Ho(e,t,n,Rc())}function Ho(e,t,n,r){var a={lane:r,revertLane:0,action:n,hasEagerState:!1,eagerState:null,next:null};if(Vo(e))Ko(t,a);else{var i=e.alternate;if(0===e.lanes&&(null===i||0===i.lanes)&&null!==(i=t.lastRenderedReducer))try{var o=t.lastRenderedState,s=i(o,n);if(a.hasEagerState=!0,a.eagerState=s,Zn(s,o))return Pr(e,t,a,0),null===sc&&Ar(),!1}catch(l){}if(null!==(n=Mr(e,t,a,r)))return Fc(n,e,r),Go(n,t,r),!0}return!1}function Wo(e,t,n,a){if(a={lane:2,revertLane:Pu(),action:a,hasEagerState:!1,eagerState:null,next:null},Vo(e)){if(t)throw Error(r(479))}else null!==(t=Mr(e,n,a,2))&&Fc(t,e,2)}function Vo(e){var t=e.alternate;return e===Si||null!==t&&t===Si}function Ko(e,t){ji=Ni=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Go(e,t,n){if(4194048&n){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,Te(e,n)}}var Qo={readContext:za,use:Wi,useCallback:Pi,useContext:Pi,useEffect:Pi,useImperativeHandle:Pi,useLayoutEffect:Pi,useInsertionEffect:Pi,useMemo:Pi,useReducer:Pi,useRef:Pi,useState:Pi,useDebugValue:Pi,useDeferredValue:Pi,useTransition:Pi,useSyncExternalStore:Pi,useId:Pi,useHostTransitionStatus:Pi,useFormState:Pi,useActionState:Pi,useOptimistic:Pi,useMemoCache:Pi,useCacheRefresh:Pi},Yo={readContext:za,use:Wi,useCallback:function(e,t){return qi().memoizedState=[e,void 0===t?null:t],e},useContext:za,useEffect:ko,useImperativeHandle:function(e,t,n){n=null!=n?n.concat([e]):null,xo(4194308,4,No.bind(null,t,e),n)},useLayoutEffect:function(e,t){return xo(4194308,4,e,t)},useInsertionEffect:function(e,t){xo(4,2,e,t)},useMemo:function(e,t){var n=qi();t=void 0===t?null:t;var r=e();if(_i){ge(!0);try{e()}finally{ge(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=qi();if(void 0!==n){var a=n(t);if(_i){ge(!0);try{n(t)}finally{ge(!1)}}}else a=t;return r.memoizedState=r.baseState=a,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:a},r.queue=e,e=e.dispatch=qo.bind(null,Si,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},qi().memoizedState=e},useState:function(e){var t=(e=ro(e)).queue,n=Bo.bind(null,Si,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:_o,useDeferredValue:function(e,t){return To(qi(),e,t)},useTransition:function(){var e=ro(!1);return e=Po.bind(null,Si,e.queue,!0,!1),qi().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var a=Si,i=qi();if(ca){if(void 0===n)throw Error(r(407));n=n()}else{if(n=t(),null===sc)throw Error(r(349));124&cc||Ji(a,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,ko(eo.bind(null,a,o,e),[e]),a.flags|=2048,yo(9,{destroy:void 0,resource:void 0},Zi.bind(null,a,o,n,t),null),n},useId:function(){var e=qi(),t=sc.identifierPrefix;if(ca){var n=na;t="«"+t+"R"+(n=(ta&~(1<<32-be(ta)-1)).toString(32)+n),0<(n=$i++)&&(t+="H"+n.toString(32)),t+="»"}else t="«"+t+"r"+(n=Ai++).toString(32)+"»";return e.memoizedState=t},useHostTransitionStatus:Ro,useFormState:ho,useActionState:ho,useOptimistic:function(e){var t=qi();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Wo.bind(null,Si,!0,n),n.dispatch=t,[e,t]},useMemoCache:Vi,useCacheRefresh:function(){return qi().memoizedState=Uo.bind(null,Si)}},Xo={readContext:za,use:Wi,useCallback:$o,useContext:za,useEffect:So,useImperativeHandle:jo,useInsertionEffect:Co,useLayoutEffect:Eo,useMemo:zo,useReducer:Gi,useRef:vo,useState:function(){return Gi(Ki)},useDebugValue:_o,useDeferredValue:function(e,t){return Ao(Bi(),Ci.memoizedState,e,t)},useTransition:function(){var e=Gi(Ki)[0],t=Bi().memoizedState;return["boolean"==typeof e?e:Hi(e),t]},useSyncExternalStore:Xi,useId:Do,useHostTransitionStatus:Ro,useFormState:po,useActionState:po,useOptimistic:function(e,t){return ao(Bi(),0,e,t)},useMemoCache:Vi,useCacheRefresh:Fo},Jo={readContext:za,use:Wi,useCallback:$o,useContext:za,useEffect:So,useImperativeHandle:jo,useInsertionEffect:Co,useLayoutEffect:Eo,useMemo:zo,useReducer:Yi,useRef:vo,useState:function(){return Yi(Ki)},useDebugValue:_o,useDeferredValue:function(e,t){var n=Bi();return null===Ci?To(n,e,t):Ao(n,Ci.memoizedState,e,t)},useTransition:function(){var e=Yi(Ki)[0],t=Bi().memoizedState;return["boolean"==typeof e?e:Hi(e),t]},useSyncExternalStore:Xi,useId:Do,useHostTransitionStatus:Ro,useFormState:bo,useActionState:bo,useOptimistic:function(e,t){var n=Bi();return null!==Ci?ao(n,0,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:Vi,useCacheRefresh:Fo},Zo=null,es=0;function ts(e){var t=es;return es+=1,null===Zo&&(Zo=[]),ti(Zo,e,t)}function ns(e,t){t=t.props.ref,e.ref=void 0!==t?t:null}function rs(e,t){if(t.$$typeof===d)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 as(e){return(0,e._init)(e._payload)}function is(e){function t(t,n){if(e){var r=t.deletions;null===r?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;null!==r;)t(n,r),r=r.sibling;return null}function a(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 i(e,t){return(e=qr(e,t)).index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?null!==(r=t.alternate)?(r=r.index)<n?(t.flags|=67108866,n):r:(t.flags|=67108866,n):(t.flags|=1048576,n)}function s(t){return e&&null===t.alternate&&(t.flags|=67108866),t}function l(e,t,n,r){return null===t||6!==t.tag?((t=Vr(n,e.mode,r)).return=e,t):((t=i(t,n)).return=e,t)}function c(e,t,n,r){var a=n.type;return a===p?d(e,t,n.props.children,r,n.key):null!==t&&(t.elementType===a||"object"==typeof a&&null!==a&&a.$$typeof===z&&as(a)===t.type)?(ns(t=i(t,n.props),n),t.return=e,t):(ns(t=Hr(n.type,n.key,n.props,null,e.mode,r),n),t.return=e,t)}function u(e,t,n,r){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=Kr(n,e.mode,r)).return=e,t):((t=i(t,n.children||[])).return=e,t)}function d(e,t,n,r,a){return null===t||7!==t.tag?((t=Wr(n,e.mode,r,a)).return=e,t):((t=i(t,n)).return=e,t)}function f(e,t,n){if("string"==typeof t&&""!==t||"number"==typeof t||"bigint"==typeof t)return(t=Vr(""+t,e.mode,n)).return=e,t;if("object"==typeof t&&null!==t){switch(t.$$typeof){case m:return ns(n=Hr(t.type,t.key,t.props,null,e.mode,n),t),n.return=e,n;case h:return(t=Kr(t,e.mode,n)).return=e,t;case z:return f(e,t=(0,t._init)(t._payload),n)}if(O(t)||M(t))return(t=Wr(t,e.mode,n,null)).return=e,t;if("function"==typeof t.then)return f(e,ts(t),n);if(t.$$typeof===C)return f(e,Ta(e,t),n);rs(e,t)}return null}function g(e,t,n,r){var a=null!==t?t.key:null;if("string"==typeof n&&""!==n||"number"==typeof n||"bigint"==typeof n)return null!==a?null:l(e,t,""+n,r);if("object"==typeof n&&null!==n){switch(n.$$typeof){case m:return n.key===a?c(e,t,n,r):null;case h:return n.key===a?u(e,t,n,r):null;case z:return g(e,t,n=(a=n._init)(n._payload),r)}if(O(n)||M(n))return null!==a?null:d(e,t,n,r,null);if("function"==typeof n.then)return g(e,t,ts(n),r);if(n.$$typeof===C)return g(e,t,Ta(e,n),r);rs(e,n)}return null}function b(e,t,n,r,a){if("string"==typeof r&&""!==r||"number"==typeof r||"bigint"==typeof r)return l(t,e=e.get(n)||null,""+r,a);if("object"==typeof r&&null!==r){switch(r.$$typeof){case m:return c(t,e=e.get(null===r.key?n:r.key)||null,r,a);case h:return u(t,e=e.get(null===r.key?n:r.key)||null,r,a);case z:return b(e,t,n,r=(0,r._init)(r._payload),a)}if(O(r)||M(r))return d(t,e=e.get(n)||null,r,a,null);if("function"==typeof r.then)return b(e,t,n,ts(r),a);if(r.$$typeof===C)return b(e,t,n,Ta(t,r),a);rs(t,r)}return null}function y(l,c,u,d){if("object"==typeof u&&null!==u&&u.type===p&&null===u.key&&(u=u.props.children),"object"==typeof u&&null!==u){switch(u.$$typeof){case m:e:{for(var v=u.key;null!==c;){if(c.key===v){if((v=u.type)===p){if(7===c.tag){n(l,c.sibling),(d=i(c,u.props.children)).return=l,l=d;break e}}else if(c.elementType===v||"object"==typeof v&&null!==v&&v.$$typeof===z&&as(v)===c.type){n(l,c.sibling),ns(d=i(c,u.props),u),d.return=l,l=d;break e}n(l,c);break}t(l,c),c=c.sibling}u.type===p?((d=Wr(u.props.children,l.mode,d,u.key)).return=l,l=d):(ns(d=Hr(u.type,u.key,u.props,null,l.mode,d),u),d.return=l,l=d)}return s(l);case h:e:{for(v=u.key;null!==c;){if(c.key===v){if(4===c.tag&&c.stateNode.containerInfo===u.containerInfo&&c.stateNode.implementation===u.implementation){n(l,c.sibling),(d=i(c,u.children||[])).return=l,l=d;break e}n(l,c);break}t(l,c),c=c.sibling}(d=Kr(u,l.mode,d)).return=l,l=d}return s(l);case z:return y(l,c,u=(v=u._init)(u._payload),d)}if(O(u))return function(r,i,s,l){for(var c=null,u=null,d=i,m=i=0,h=null;null!==d&&m<s.length;m++){d.index>m?(h=d,d=null):h=d.sibling;var p=g(r,d,s[m],l);if(null===p){null===d&&(d=h);break}e&&d&&null===p.alternate&&t(r,d),i=o(p,i,m),null===u?c=p:u.sibling=p,u=p,d=h}if(m===s.length)return n(r,d),ca&&ra(r,m),c;if(null===d){for(;m<s.length;m++)null!==(d=f(r,s[m],l))&&(i=o(d,i,m),null===u?c=d:u.sibling=d,u=d);return ca&&ra(r,m),c}for(d=a(d);m<s.length;m++)null!==(h=b(d,r,m,s[m],l))&&(e&&null!==h.alternate&&d.delete(null===h.key?m:h.key),i=o(h,i,m),null===u?c=h:u.sibling=h,u=h);return e&&d.forEach(function(e){return t(r,e)}),ca&&ra(r,m),c}(l,c,u,d);if(M(u)){if("function"!=typeof(v=M(u)))throw Error(r(150));return function(i,s,l,c){if(null==l)throw Error(r(151));for(var u=null,d=null,m=s,h=s=0,p=null,y=l.next();null!==m&&!y.done;h++,y=l.next()){m.index>h?(p=m,m=null):p=m.sibling;var v=g(i,m,y.value,c);if(null===v){null===m&&(m=p);break}e&&m&&null===v.alternate&&t(i,m),s=o(v,s,h),null===d?u=v:d.sibling=v,d=v,m=p}if(y.done)return n(i,m),ca&&ra(i,h),u;if(null===m){for(;!y.done;h++,y=l.next())null!==(y=f(i,y.value,c))&&(s=o(y,s,h),null===d?u=y:d.sibling=y,d=y);return ca&&ra(i,h),u}for(m=a(m);!y.done;h++,y=l.next())null!==(y=b(m,i,h,y.value,c))&&(e&&null!==y.alternate&&m.delete(null===y.key?h:y.key),s=o(y,s,h),null===d?u=y:d.sibling=y,d=y);return e&&m.forEach(function(e){return t(i,e)}),ca&&ra(i,h),u}(l,c,u=v.call(u),d)}if("function"==typeof u.then)return y(l,c,ts(u),d);if(u.$$typeof===C)return y(l,c,Ta(l,u),d);rs(l,u)}return"string"==typeof u&&""!==u||"number"==typeof u||"bigint"==typeof u?(u=""+u,null!==c&&6===c.tag?(n(l,c.sibling),(d=i(c,u)).return=l,l=d):(n(l,c),(d=Vr(u,l.mode,d)).return=l,l=d),s(l)):n(l,c)}return function(e,t,n,r){try{es=0;var a=y(e,t,n,r);return Zo=null,a}catch(o){if(o===Qa||o===Xa)throw o;var i=Fr(29,o,null,e.mode);return i.lanes=r,i.return=e,i}}}var os=is(!0),ss=is(!1),ls=B(null),cs=null;function us(e){var t=e.alternate;W(ps,1&ps.current),W(ls,e),null===cs&&(null===t||null!==bi.current||null!==t.memoizedState)&&(cs=e)}function ds(e){if(22===e.tag){if(W(ps,ps.current),W(ls,e),null===cs){var t=e.alternate;null!==t&&null!==t.memoizedState&&(cs=e)}}else ms()}function ms(){W(ps,ps.current),W(ls,ls.current)}function hs(e){H(ls),cs===e&&(cs=null),H(ps)}var ps=B(0);function fs(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||"$?"===n.data||xd(n)))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(128&t.flags)return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}function gs(e,t,n,r){n=null==(n=n(r,t=e.memoizedState))?t:u({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}var bs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Rc(),a=li(r);a.payload=t,null!=n&&(a.callback=n),null!==(t=ci(e,a,r))&&(Fc(t,e,r),ui(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Rc(),a=li(r);a.tag=1,a.payload=t,null!=n&&(a.callback=n),null!==(t=ci(e,a,r))&&(Fc(t,e,r),ui(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Rc(),r=li(n);r.tag=2,null!=t&&(r.callback=t),null!==(t=ci(e,r,n))&&(Fc(t,e,n),ui(t,e,n))}};function ys(e,t,n,r,a,i,o){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,i,o):!t.prototype||!t.prototype.isPureReactComponent||(!er(n,r)||!er(a,i))}function vs(e,t,n,r){e=t.state,"function"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,r),"function"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&bs.enqueueReplaceState(t,t.state,null)}function xs(e,t){var n=t;if("ref"in t)for(var r in n={},t)"ref"!==r&&(n[r]=t[r]);if(e=e.defaultProps)for(var a in n===t&&(n=u({},n)),e)void 0===n[a]&&(n[a]=e[a]);return n}var ws="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)};function ks(e){ws(e)}function Ss(e){console.error(e)}function Cs(e){ws(e)}function Es(e,t){try{(0,e.onUncaughtError)(t.value,{componentStack:t.stack})}catch(n){setTimeout(function(){throw n})}}function Ns(e,t,n){try{(0,e.onCaughtError)(n.value,{componentStack:n.stack,errorBoundary:1===t.tag?t.stateNode:null})}catch(r){setTimeout(function(){throw r})}}function js(e,t,n){return(n=li(n)).tag=3,n.payload={element:null},n.callback=function(){Es(e,t)},n}function _s(e){return(e=li(e)).tag=3,e}function $s(e,t,n,r){var a=n.type.getDerivedStateFromError;if("function"==typeof a){var i=r.value;e.payload=function(){return a(i)},e.callback=function(){Ns(t,n,r)}}var o=n.stateNode;null!==o&&"function"==typeof o.componentDidCatch&&(e.callback=function(){Ns(t,n,r),"function"!=typeof a&&(null===_c?_c=new Set([this]):_c.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:null!==e?e:""})})}var zs=Error(r(461)),Ts=!1;function As(e,t,n,r){t.child=null===e?ss(t,null,n,r):os(t,e.child,n,r)}function Ps(e,t,n,r,a){n=n.render;var i=t.ref;if("ref"in r){var o={};for(var s in r)"ref"!==s&&(o[s]=r[s])}else o=r;return $a(t),r=Ii(e,t,n,o,i,a),s=Di(),null===e||Ts?(ca&&s&&ia(t),t.flags|=1,As(e,t,r,a),t.child):(Fi(e,t,a),Zs(e,t,a))}function Ms(e,t,n,r,a){if(null===e){var i=n.type;return"function"!=typeof i||Ur(i)||void 0!==i.defaultProps||null!==n.compare?((e=Hr(n.type,null,r,t,t.mode,a)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=i,Is(e,t,i,r,a))}if(i=e.child,!el(e,a)){var o=i.memoizedProps;if((n=null!==(n=n.compare)?n:er)(o,r)&&e.ref===t.ref)return Zs(e,t,a)}return t.flags|=1,(e=qr(i,r)).ref=t.ref,e.return=t,t.child=e}function Is(e,t,n,r,a){if(null!==e){var i=e.memoizedProps;if(er(i,r)&&e.ref===t.ref){if(Ts=!1,t.pendingProps=r=i,!el(e,a))return t.lanes=e.lanes,Zs(e,t,a);131072&e.flags&&(Ts=!0)}}return Ds(e,t,n,r,a)}function Ls(e,t,n){var r=t.pendingProps,a=r.children,i=null!==e?e.memoizedState:null;if("hidden"===r.mode){if(128&t.flags){if(r=null!==i?i.baseLanes|n:n,null!==e){for(a=t.child=e.child,i=0;null!==a;)i=i|a.lanes|a.childLanes,a=a.sibling;t.childLanes=i&~r}else t.childLanes=0,t.child=null;return Os(e,t,r,n)}if(!(536870912&n))return t.lanes=t.childLanes=536870912,Os(e,t,null!==i?i.baseLanes|n:n,n);t.memoizedState={baseLanes:0,cachePool:null},null!==e&&Ka(0,null!==i?i.cachePool:null),null!==i?vi(t,i):xi(),ds(t)}else null!==i?(Ka(0,i.cachePool),vi(t,i),ms(),t.memoizedState=null):(null!==e&&Ka(0,null),xi(),ms());return As(e,t,a,n),t.child}function Os(e,t,n,r){var a=Va();return a=null===a?null:{parent:La._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},null!==e&&Ka(0,null),xi(),ds(t),null!==e&&ja(e,t,r,!0),null}function Rs(e,t){var n=t.ref;if(null===n)null!==e&&null!==e.ref&&(t.flags|=4194816);else{if("function"!=typeof n&&"object"!=typeof n)throw Error(r(284));null!==e&&e.ref===n||(t.flags|=4194816)}}function Ds(e,t,n,r,a){return $a(t),n=Ii(e,t,n,r,void 0,a),r=Di(),null===e||Ts?(ca&&r&&ia(t),t.flags|=1,As(e,t,n,a),t.child):(Fi(e,t,a),Zs(e,t,a))}function Fs(e,t,n,r,a,i){return $a(t),t.updateQueue=null,n=Oi(t,r,n,a),Li(e),r=Di(),null===e||Ts?(ca&&r&&ia(t),t.flags|=1,As(e,t,n,i),t.child):(Fi(e,t,i),Zs(e,t,i))}function Us(e,t,n,r,a){if($a(t),null===t.stateNode){var i=Rr,o=n.contextType;"object"==typeof o&&null!==o&&(i=za(o)),i=new n(r,i),t.memoizedState=null!==i.state&&void 0!==i.state?i.state:null,i.updater=bs,t.stateNode=i,i._reactInternals=t,(i=t.stateNode).props=r,i.state=t.memoizedState,i.refs={},oi(t),o=n.contextType,i.context="object"==typeof o&&null!==o?za(o):Rr,i.state=t.memoizedState,"function"==typeof(o=n.getDerivedStateFromProps)&&(gs(t,n,o,r),i.state=t.memoizedState),"function"==typeof n.getDerivedStateFromProps||"function"==typeof i.getSnapshotBeforeUpdate||"function"!=typeof i.UNSAFE_componentWillMount&&"function"!=typeof i.componentWillMount||(o=i.state,"function"==typeof i.componentWillMount&&i.componentWillMount(),"function"==typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount(),o!==i.state&&bs.enqueueReplaceState(i,i.state,null),pi(t,r,i,a),hi(),i.state=t.memoizedState),"function"==typeof i.componentDidMount&&(t.flags|=4194308),r=!0}else if(null===e){i=t.stateNode;var s=t.memoizedProps,l=xs(n,s);i.props=l;var c=i.context,u=n.contextType;o=Rr,"object"==typeof u&&null!==u&&(o=za(u));var d=n.getDerivedStateFromProps;u="function"==typeof d||"function"==typeof i.getSnapshotBeforeUpdate,s=t.pendingProps!==s,u||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(s||c!==o)&&vs(t,i,r,o),ii=!1;var m=t.memoizedState;i.state=m,pi(t,r,i,a),hi(),c=t.memoizedState,s||m!==c||ii?("function"==typeof d&&(gs(t,n,d,r),c=t.memoizedState),(l=ii||ys(t,n,l,r,m,c,o))?(u||"function"!=typeof i.UNSAFE_componentWillMount&&"function"!=typeof i.componentWillMount||("function"==typeof i.componentWillMount&&i.componentWillMount(),"function"==typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount()),"function"==typeof i.componentDidMount&&(t.flags|=4194308)):("function"==typeof i.componentDidMount&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),i.props=r,i.state=c,i.context=o,r=l):("function"==typeof i.componentDidMount&&(t.flags|=4194308),r=!1)}else{i=t.stateNode,si(e,t),u=xs(n,o=t.memoizedProps),i.props=u,d=t.pendingProps,m=i.context,c=n.contextType,l=Rr,"object"==typeof c&&null!==c&&(l=za(c)),(c="function"==typeof(s=n.getDerivedStateFromProps)||"function"==typeof i.getSnapshotBeforeUpdate)||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(o!==d||m!==l)&&vs(t,i,r,l),ii=!1,m=t.memoizedState,i.state=m,pi(t,r,i,a),hi();var h=t.memoizedState;o!==d||m!==h||ii||null!==e&&null!==e.dependencies&&_a(e.dependencies)?("function"==typeof s&&(gs(t,n,s,r),h=t.memoizedState),(u=ii||ys(t,n,u,r,m,h,l)||null!==e&&null!==e.dependencies&&_a(e.dependencies))?(c||"function"!=typeof i.UNSAFE_componentWillUpdate&&"function"!=typeof i.componentWillUpdate||("function"==typeof i.componentWillUpdate&&i.componentWillUpdate(r,h,l),"function"==typeof i.UNSAFE_componentWillUpdate&&i.UNSAFE_componentWillUpdate(r,h,l)),"function"==typeof i.componentDidUpdate&&(t.flags|=4),"function"==typeof i.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!=typeof i.componentDidUpdate||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),"function"!=typeof i.getSnapshotBeforeUpdate||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=h),i.props=r,i.state=h,i.context=l,r=u):("function"!=typeof i.componentDidUpdate||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),"function"!=typeof i.getSnapshotBeforeUpdate||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),r=!1)}return i=r,Rs(e,t),r=!!(128&t.flags),i||r?(i=t.stateNode,n=r&&"function"!=typeof n.getDerivedStateFromError?null:i.render(),t.flags|=1,null!==e&&r?(t.child=os(t,e.child,null,a),t.child=os(t,null,n,a)):As(e,t,n,a),t.memoizedState=i.state,e=t.child):e=Zs(e,t,a),e}function qs(e,t,n,r){return ba(),t.flags|=256,As(e,t,n,r),t.child}var Bs={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Hs(e){return{baseLanes:e,cachePool:Ga()}}function Ws(e,t,n){return e=null!==e?e.childLanes&~n:0,t&&(e|=xc),e}function Vs(e,t,n){var a,i=t.pendingProps,o=!1,s=!!(128&t.flags);if((a=s)||(a=(null===e||null!==e.memoizedState)&&!!(2&ps.current)),a&&(o=!0,t.flags&=-129),a=!!(32&t.flags),t.flags&=-33,null===e){if(ca){if(o?us(t):ms(),ca){var l,c=la;if(l=c){e:{for(l=c,c=da;8!==l.nodeType;){if(!c){c=null;break e}if(null===(l=wd(l.nextSibling))){c=null;break e}}c=l}null!==c?(t.memoizedState={dehydrated:c,treeContext:null!==ea?{id:ta,overflow:na}:null,retryLane:536870912,hydrationErrors:null},(l=Fr(18,null,null,0)).stateNode=c,l.return=t,t.child=l,sa=t,la=null,l=!0):l=!1}l||ha(t)}if(null!==(c=t.memoizedState)&&null!==(c=c.dehydrated))return xd(c)?t.lanes=32:t.lanes=536870912,null;hs(t)}return c=i.children,i=i.fallback,o?(ms(),c=Gs({mode:"hidden",children:c},o=t.mode),i=Wr(i,o,n,null),c.return=t,i.return=t,c.sibling=i,t.child=c,(o=t.child).memoizedState=Hs(n),o.childLanes=Ws(e,a,n),t.memoizedState=Bs,i):(us(t),Ks(t,c))}if(null!==(l=e.memoizedState)&&null!==(c=l.dehydrated)){if(s)256&t.flags?(us(t),t.flags&=-257,t=Qs(e,t,n)):null!==t.memoizedState?(ms(),t.child=e.child,t.flags|=128,t=null):(ms(),o=i.fallback,c=t.mode,i=Gs({mode:"visible",children:i.children},c),(o=Wr(o,c,n,null)).flags|=2,i.return=t,o.return=t,i.sibling=o,t.child=i,os(t,e.child,null,n),(i=t.child).memoizedState=Hs(n),i.childLanes=Ws(e,a,n),t.memoizedState=Bs,t=o);else if(us(t),xd(c)){if(a=c.nextSibling&&c.nextSibling.dataset)var u=a.dgst;a=u,(i=Error(r(419))).stack="",i.digest=a,va({value:i,source:null,stack:null}),t=Qs(e,t,n)}else if(Ts||ja(e,t,n,!1),a=0!==(n&e.childLanes),Ts||a){if(null!==(a=sc)&&(0!==(i=0!==((i=42&(i=n&-n)?1:Ae(i))&(a.suspendedLanes|n))?0:i)&&i!==l.retryLane))throw l.retryLane=i,Ir(e,i),Fc(a,e,i),zs;"$?"===c.data||Xc(),t=Qs(e,t,n)}else"$?"===c.data?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,la=wd(c.nextSibling),sa=t,ca=!0,ua=null,da=!1,null!==e&&(Jr[Zr++]=ta,Jr[Zr++]=na,Jr[Zr++]=ea,ta=e.id,na=e.overflow,ea=t),(t=Ks(t,i.children)).flags|=4096);return t}return o?(ms(),o=i.fallback,c=t.mode,u=(l=e.child).sibling,(i=qr(l,{mode:"hidden",children:i.children})).subtreeFlags=65011712&l.subtreeFlags,null!==u?o=qr(u,o):(o=Wr(o,c,n,null)).flags|=2,o.return=t,i.return=t,i.sibling=o,t.child=i,i=o,o=t.child,null===(c=e.child.memoizedState)?c=Hs(n):(null!==(l=c.cachePool)?(u=La._currentValue,l=l.parent!==u?{parent:u,pool:u}:l):l=Ga(),c={baseLanes:c.baseLanes|n,cachePool:l}),o.memoizedState=c,o.childLanes=Ws(e,a,n),t.memoizedState=Bs,i):(us(t),e=(n=e.child).sibling,(n=qr(n,{mode:"visible",children:i.children})).return=t,n.sibling=null,null!==e&&(null===(a=t.deletions)?(t.deletions=[e],t.flags|=16):a.push(e)),t.child=n,t.memoizedState=null,n)}function Ks(e,t){return(t=Gs({mode:"visible",children:t},e.mode)).return=e,e.child=t}function Gs(e,t){return(e=Fr(22,e,null,t)).lanes=0,e.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null},e}function Qs(e,t,n){return os(t,e.child,null,n),(e=Ks(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function Ys(e,t,n){e.lanes|=t;var r=e.alternate;null!==r&&(r.lanes|=t),Ea(e.return,t,n)}function Xs(e,t,n,r,a){var i=e.memoizedState;null===i?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:a}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=a)}function Js(e,t,n){var r=t.pendingProps,a=r.revealOrder,i=r.tail;if(As(e,t,r.children,n),2&(r=ps.current))r=1&r|2,t.flags|=128;else{if(null!==e&&128&e.flags)e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&Ys(e,n,t);else if(19===e.tag)Ys(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}switch(W(ps,r),a){case"forwards":for(n=t.child,a=null;null!==n;)null!==(e=n.alternate)&&null===fs(e)&&(a=n),n=n.sibling;null===(n=a)?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),Xs(t,!1,a,n,i);break;case"backwards":for(n=null,a=t.child,t.child=null;null!==a;){if(null!==(e=a.alternate)&&null===fs(e)){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}Xs(t,!0,n,null,i);break;case"together":Xs(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Zs(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),bc|=t.lanes,0===(n&t.childLanes)){if(null===e)return null;if(ja(e,t,n,!1),0===(n&t.childLanes))return null}if(null!==e&&t.child!==e.child)throw Error(r(153));if(null!==t.child){for(n=qr(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=qr(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function el(e,t){return 0!==(e.lanes&t)||!(null===(e=e.dependencies)||!_a(e))}function tl(e,t,n){if(null!==e)if(e.memoizedProps!==t.pendingProps)Ts=!0;else{if(!(el(e,n)||128&t.flags))return Ts=!1,function(e,t,n){switch(t.tag){case 3:Y(t,t.stateNode.containerInfo),Sa(0,La,e.memoizedState.cache),ba();break;case 27:case 5:J(t);break;case 4:Y(t,t.stateNode.containerInfo);break;case 10:Sa(0,t.type,t.memoizedProps.value);break;case 13:var r=t.memoizedState;if(null!==r)return null!==r.dehydrated?(us(t),t.flags|=128,null):0!==(n&t.child.childLanes)?Vs(e,t,n):(us(t),null!==(e=Zs(e,t,n))?e.sibling:null);us(t);break;case 19:var a=!!(128&e.flags);if((r=0!==(n&t.childLanes))||(ja(e,t,n,!1),r=0!==(n&t.childLanes)),a){if(r)return Js(e,t,n);t.flags|=128}if(null!==(a=t.memoizedState)&&(a.rendering=null,a.tail=null,a.lastEffect=null),W(ps,ps.current),r)break;return null;case 22:case 23:return t.lanes=0,Ls(e,t,n);case 24:Sa(0,La,e.memoizedState.cache)}return Zs(e,t,n)}(e,t,n);Ts=!!(131072&e.flags)}else Ts=!1,ca&&1048576&t.flags&&aa(t,Xr,t.index);switch(t.lanes=0,t.tag){case 16:e:{e=t.pendingProps;var a=t.elementType,i=a._init;if(a=i(a._payload),t.type=a,"function"!=typeof a){if(null!=a){if((i=a.$$typeof)===N){t.tag=11,t=Ps(null,t,a,e,n);break e}if(i===$){t.tag=14,t=Ms(null,t,a,e,n);break e}}throw t=L(a)||a,Error(r(306,t,""))}Ur(a)?(e=xs(a,e),t.tag=1,t=Us(null,t,a,e,n)):(t.tag=0,t=Ds(null,t,a,e,n))}return t;case 0:return Ds(e,t,t.type,t.pendingProps,n);case 1:return Us(e,t,a=t.type,i=xs(a,t.pendingProps),n);case 3:e:{if(Y(t,t.stateNode.containerInfo),null===e)throw Error(r(387));a=t.pendingProps;var o=t.memoizedState;i=o.element,si(e,t),pi(t,a,null,n);var s=t.memoizedState;if(a=s.cache,Sa(0,La,a),a!==o.cache&&Na(t,[La],n,!0),hi(),a=s.element,o.isDehydrated){if(o={element:a,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,256&t.flags){t=qs(e,t,a,n);break e}if(a!==i){va(i=_r(Error(r(424)),t)),t=qs(e,t,a,n);break e}if(9===(e=t.stateNode.containerInfo).nodeType)e=e.body;else e="HTML"===e.nodeName?e.ownerDocument.body:e;for(la=wd(e.firstChild),sa=t,ca=!0,ua=null,da=!0,n=ss(t,null,a,n),t.child=n;n;)n.flags=-3&n.flags|4096,n=n.sibling}else{if(ba(),a===i){t=Zs(e,t,n);break e}As(e,t,a,n)}t=t.child}return t;case 26:return Rs(e,t),null===e?(n=Ad(t.type,null,t.pendingProps,null))?t.memoizedState=n:ca||(n=t.type,e=t.pendingProps,(a=sd(G.current).createElement(n))[Le]=t,a[Oe]=e,ad(a,n,e),Qe(a),t.stateNode=a):t.memoizedState=Ad(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return J(t),null===e&&ca&&(a=t.stateNode=Cd(t.type,t.pendingProps,G.current),sa=t,da=!0,i=la,bd(t.type)?(kd=i,la=wd(a.firstChild)):la=i),As(e,t,t.pendingProps.children,n),Rs(e,t),null===e&&(t.flags|=4194304),t.child;case 5:return null===e&&ca&&((i=a=la)&&(null!==(a=function(e,t,n,r){for(;1===e.nodeType;){var a=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&("INPUT"!==e.nodeName||"hidden"!==e.type))break}else if(r){if(!e[Be])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if("stylesheet"===(i=e.getAttribute("rel"))&&e.hasAttribute("data-precedence"))break;if(i!==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(((i=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))&&i&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else{if("input"!==t||"hidden"!==e.type)return e;var i=null==a.name?null:""+a.name;if("hidden"===a.type&&e.getAttribute("name")===i)return e}if(null===(e=wd(e.nextSibling)))break}return null}(a,t.type,t.pendingProps,da))?(t.stateNode=a,sa=t,la=wd(a.firstChild),da=!1,i=!0):i=!1),i||ha(t)),J(t),i=t.type,o=t.pendingProps,s=null!==e?e.memoizedProps:null,a=o.children,ud(i,o)?a=null:null!==s&&ud(i,s)&&(t.flags|=32),null!==t.memoizedState&&(i=Ii(e,t,Ri,null,null,n),Jd._currentValue=i),Rs(e,t),As(e,t,a,n),t.child;case 6:return null===e&&ca&&((e=n=la)&&(null!==(n=function(e,t,n){if(""===t)return null;for(;3!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!n)return null;if(null===(e=wd(e.nextSibling)))return null}return e}(n,t.pendingProps,da))?(t.stateNode=n,sa=t,la=null,e=!0):e=!1),e||ha(t)),null;case 13:return Vs(e,t,n);case 4:return Y(t,t.stateNode.containerInfo),a=t.pendingProps,null===e?t.child=os(t,null,a,n):As(e,t,a,n),t.child;case 11:return Ps(e,t,t.type,t.pendingProps,n);case 7:return As(e,t,t.pendingProps,n),t.child;case 8:case 12:return As(e,t,t.pendingProps.children,n),t.child;case 10:return a=t.pendingProps,Sa(0,t.type,a.value),As(e,t,a.children,n),t.child;case 9:return i=t.type._context,a=t.pendingProps.children,$a(t),a=a(i=za(i)),t.flags|=1,As(e,t,a,n),t.child;case 14:return Ms(e,t,t.type,t.pendingProps,n);case 15:return Is(e,t,t.type,t.pendingProps,n);case 19:return Js(e,t,n);case 31:return a=t.pendingProps,n=t.mode,a={mode:a.mode,children:a.children},null===e?((n=Gs(a,n)).ref=t.ref,t.child=n,n.return=t,t=n):((n=qr(e.child,a)).ref=t.ref,t.child=n,n.return=t,t=n),t;case 22:return Ls(e,t,n);case 24:return $a(t),a=za(La),null===e?(null===(i=Va())&&(i=sc,o=Oa(),i.pooledCache=o,o.refCount++,null!==o&&(i.pooledCacheLanes|=n),i=o),t.memoizedState={parent:a,cache:i},oi(t),Sa(0,La,i)):(0!==(e.lanes&n)&&(si(e,t),pi(t,null,null,n),hi()),i=e.memoizedState,o=t.memoizedState,i.parent!==a?(i={parent:a,cache:a},t.memoizedState=i,0===t.lanes&&(t.memoizedState=t.updateQueue.baseState=i),Sa(0,La,a)):(a=o.cache,Sa(0,La,a),a!==i.cache&&Na(t,[La],n,!0))),As(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function nl(e){e.flags|=4}function rl(e,t){if("stylesheet"!==t.type||4&t.state.loading)e.flags&=-16777217;else if(e.flags|=16777216,!Wd(t)){if(null!==(t=ls.current)&&((4194048&cc)===cc?null!==cs:(62914560&cc)!==cc&&!(536870912&cc)||t!==cs))throw ni=Ja,Ya;e.flags|=8192}}function al(e,t){null!==t&&(e.flags|=4),16384&e.flags&&(t=22!==e.tag?je():536870912,e.lanes|=t,wc|=t)}function il(e,t){if(!ca)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;null!==n;)null!==n.alternate&&(r=n),n=n.sibling;null===r?t||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function ol(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,r=0;if(t)for(var a=e.child;null!==a;)n|=a.lanes|a.childLanes,r|=65011712&a.subtreeFlags,r|=65011712&a.flags,a.return=e,a=a.sibling;else for(a=e.child;null!==a;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags,r|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function sl(e,t,n){var a=t.pendingProps;switch(oa(t),t.tag){case 31:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 1:return ol(t),null;case 3:return n=t.stateNode,a=null,null!==e&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Ca(La),X(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),null!==e&&null!==e.child||(ga(t)?nl(t):null===e||e.memoizedState.isDehydrated&&!(256&t.flags)||(t.flags|=1024,ya())),ol(t),null;case 26:return n=t.memoizedState,null===e?(nl(t),null!==n?(ol(t),rl(t,n)):(ol(t),t.flags&=-16777217)):n?n!==e.memoizedState?(nl(t),ol(t),rl(t,n)):(ol(t),t.flags&=-16777217):(e.memoizedProps!==a&&nl(t),ol(t),t.flags&=-16777217),null;case 27:Z(t),n=G.current;var i=t.type;if(null!==e&&null!=t.stateNode)e.memoizedProps!==a&&nl(t);else{if(!a){if(null===t.stateNode)throw Error(r(166));return ol(t),null}e=V.current,ga(t)?pa(t):(e=Cd(i,a,n),t.stateNode=e,nl(t))}return ol(t),null;case 5:if(Z(t),n=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==a&&nl(t);else{if(!a){if(null===t.stateNode)throw Error(r(166));return ol(t),null}if(e=V.current,ga(t))pa(t);else{switch(i=sd(G.current),e){case 1:e=i.createElementNS("http://www.w3.org/2000/svg",n);break;case 2:e=i.createElementNS("http://www.w3.org/1998/Math/MathML",n);break;default:switch(n){case"svg":e=i.createElementNS("http://www.w3.org/2000/svg",n);break;case"math":e=i.createElementNS("http://www.w3.org/1998/Math/MathML",n);break;case"script":(e=i.createElement("div")).innerHTML="<script><\/script>",e=e.removeChild(e.firstChild);break;case"select":e="string"==typeof a.is?i.createElement("select",{is:a.is}):i.createElement("select"),a.multiple?e.multiple=!0:a.size&&(e.size=a.size);break;default:e="string"==typeof a.is?i.createElement(n,{is:a.is}):i.createElement(n)}}e[Le]=t,e[Oe]=a;e:for(i=t.child;null!==i;){if(5===i.tag||6===i.tag)e.appendChild(i.stateNode);else if(4!==i.tag&&27!==i.tag&&null!==i.child){i.child.return=i,i=i.child;continue}if(i===t)break e;for(;null===i.sibling;){if(null===i.return||i.return===t)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}t.stateNode=e;e:switch(ad(e,n,a),n){case"button":case"input":case"select":case"textarea":e=!!a.autoFocus;break e;case"img":e=!0;break e;default:e=!1}e&&nl(t)}}return ol(t),t.flags&=-16777217,null;case 6:if(e&&null!=t.stateNode)e.memoizedProps!==a&&nl(t);else{if("string"!=typeof a&&null===t.stateNode)throw Error(r(166));if(e=G.current,ga(t)){if(e=t.stateNode,n=t.memoizedProps,a=null,null!==(i=sa))switch(i.tag){case 27:case 5:a=i.memoizedProps}e[Le]=t,(e=!!(e.nodeValue===n||null!==a&&!0===a.suppressHydrationWarning||ed(e.nodeValue,n)))||ha(t)}else(e=sd(e).createTextNode(a))[Le]=t,t.stateNode=e}return ol(t),null;case 13:if(a=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(i=ga(t),null!==a&&null!==a.dehydrated){if(null===e){if(!i)throw Error(r(318));if(!(i=null!==(i=t.memoizedState)?i.dehydrated:null))throw Error(r(317));i[Le]=t}else ba(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;ol(t),i=!1}else i=ya(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return 256&t.flags?(hs(t),t):(hs(t),null)}if(hs(t),128&t.flags)return t.lanes=n,t;if(n=null!==a,e=null!==e&&null!==e.memoizedState,n){i=null,null!==(a=t.child).alternate&&null!==a.alternate.memoizedState&&null!==a.alternate.memoizedState.cachePool&&(i=a.alternate.memoizedState.cachePool.pool);var o=null;null!==a.memoizedState&&null!==a.memoizedState.cachePool&&(o=a.memoizedState.cachePool.pool),o!==i&&(a.flags|=2048)}return n!==e&&n&&(t.child.flags|=8192),al(t,t.updateQueue),ol(t),null;case 4:return X(),null===e&&Hu(t.stateNode.containerInfo),ol(t),null;case 10:return Ca(t.type),ol(t),null;case 19:if(H(ps),null===(i=t.memoizedState))return ol(t),null;if(a=!!(128&t.flags),null===(o=i.rendering))if(a)il(i,!1);else{if(0!==gc||null!==e&&128&e.flags)for(e=t.child;null!==e;){if(null!==(o=fs(e))){for(t.flags|=128,il(i,!1),e=o.updateQueue,t.updateQueue=e,al(t,e),t.subtreeFlags=0,e=n,n=t.child;null!==n;)Br(n,e),n=n.sibling;return W(ps,1&ps.current|2),t.child}e=e.sibling}null!==i.tail&&ie()>Nc&&(t.flags|=128,a=!0,il(i,!1),t.lanes=4194304)}else{if(!a)if(null!==(e=fs(o))){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,al(t,e),il(i,!0),null===i.tail&&"hidden"===i.tailMode&&!o.alternate&&!ca)return ol(t),null}else 2*ie()-i.renderingStartTime>Nc&&536870912!==n&&(t.flags|=128,a=!0,il(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(null!==(e=i.last)?e.sibling=o:t.child=o,i.last=o)}return null!==i.tail?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=ie(),t.sibling=null,e=ps.current,W(ps,a?1&e|2:1&e),t):(ol(t),null);case 22:case 23:return hs(t),wi(),a=null!==t.memoizedState,null!==e?null!==e.memoizedState!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?!!(536870912&n)&&!(128&t.flags)&&(ol(t),6&t.subtreeFlags&&(t.flags|=8192)):ol(t),null!==(n=t.updateQueue)&&al(t,n.retryQueue),n=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),a=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(a=t.memoizedState.cachePool.pool),a!==n&&(t.flags|=2048),null!==e&&H(Wa),null;case 24:return n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ca(La),ol(t),null;case 25:case 30:return null}throw Error(r(156,t.tag))}function ll(e,t){switch(oa(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return Ca(La),X(),65536&(e=t.flags)&&!(128&e)?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return Z(t),null;case 13:if(hs(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(r(340));ba()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return H(ps),null;case 4:return X(),null;case 10:return Ca(t.type),null;case 22:case 23:return hs(t),wi(),null!==e&&H(Wa),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return Ca(La),null;default:return null}}function cl(e,t){switch(oa(t),t.tag){case 3:Ca(La),X();break;case 26:case 27:case 5:Z(t);break;case 4:X();break;case 13:hs(t);break;case 19:H(ps);break;case 10:Ca(t.type);break;case 22:case 23:hs(t),wi(),null!==e&&H(Wa);break;case 24:Ca(La)}}function ul(e,t){try{var n=t.updateQueue,r=null!==n?n.lastEffect:null;if(null!==r){var a=r.next;n=a;do{if((n.tag&e)===e){r=void 0;var i=n.create,o=n.inst;r=i(),o.destroy=r}n=n.next}while(n!==a)}}catch(s){pu(t,t.return,s)}}function dl(e,t,n){try{var r=t.updateQueue,a=null!==r?r.lastEffect:null;if(null!==a){var i=a.next;r=i;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(void 0!==s){o.destroy=void 0,a=t;var l=n,c=s;try{c()}catch(u){pu(a,l,u)}}}r=r.next}while(r!==i)}}catch(u){pu(t,t.return,u)}}function ml(e){var t=e.updateQueue;if(null!==t){var n=e.stateNode;try{gi(t,n)}catch(r){pu(e,e.return,r)}}}function hl(e,t,n){n.props=xs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(r){pu(e,t,r)}}function pl(e,t){try{var n=e.ref;if(null!==n){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;default:r=e.stateNode}"function"==typeof n?e.refCleanup=n(r):n.current=r}}catch(a){pu(e,t,a)}}function fl(e,t){var n=e.ref,r=e.refCleanup;if(null!==n)if("function"==typeof r)try{r()}catch(a){pu(e,t,a)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof n)try{n(null)}catch(i){pu(e,t,i)}else n.current=null}function gl(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&r.focus();break e;case"img":n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(a){pu(e,e.return,a)}}function bl(e,t,n){try{var a=e.stateNode;!function(e,t,n,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var i=null,o=null,s=null,l=null,c=null,u=null,d=null;for(p in n){var m=n[p];if(n.hasOwnProperty(p)&&null!=m)switch(p){case"checked":case"value":break;case"defaultValue":c=m;default:a.hasOwnProperty(p)||nd(e,t,p,null,a,m)}}for(var h in a){var p=a[h];if(m=n[h],a.hasOwnProperty(h)&&(null!=p||null!=m))switch(h){case"type":o=p;break;case"name":i=p;break;case"checked":u=p;break;case"defaultChecked":d=p;break;case"value":s=p;break;case"defaultValue":l=p;break;case"children":case"dangerouslySetInnerHTML":if(null!=p)throw Error(r(137,t));break;default:p!==m&&nd(e,t,h,p,a,m)}}return void xt(e,s,l,c,u,d,o,i);case"select":for(o in p=s=l=h=null,n)if(c=n[o],n.hasOwnProperty(o)&&null!=c)switch(o){case"value":break;case"multiple":p=c;default:a.hasOwnProperty(o)||nd(e,t,o,null,a,c)}for(i in a)if(o=a[i],c=n[i],a.hasOwnProperty(i)&&(null!=o||null!=c))switch(i){case"value":h=o;break;case"defaultValue":l=o;break;case"multiple":s=o;default:o!==c&&nd(e,t,i,o,a,c)}return t=l,n=s,a=p,void(null!=h?St(e,!!n,h,!1):!!a!=!!n&&(null!=t?St(e,!!n,t,!0):St(e,!!n,n?[]:"",!1)));case"textarea":for(l in p=h=null,n)if(i=n[l],n.hasOwnProperty(l)&&null!=i&&!a.hasOwnProperty(l))switch(l){case"value":case"children":break;default:nd(e,t,l,null,a,i)}for(s in a)if(i=a[s],o=n[s],a.hasOwnProperty(s)&&(null!=i||null!=o))switch(s){case"value":h=i;break;case"defaultValue":p=i;break;case"children":break;case"dangerouslySetInnerHTML":if(null!=i)throw Error(r(91));break;default:i!==o&&nd(e,t,s,i,a,o)}return void Ct(e,h,p);case"option":for(var f in n)if(h=n[f],n.hasOwnProperty(f)&&null!=h&&!a.hasOwnProperty(f))if("selected"===f)e.selected=!1;else nd(e,t,f,null,a,h);for(c in a)if(h=a[c],p=n[c],a.hasOwnProperty(c)&&h!==p&&(null!=h||null!=p))if("selected"===c)e.selected=h&&"function"!=typeof h&&"symbol"!=typeof h;else nd(e,t,c,h,a,p);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 g in n)h=n[g],n.hasOwnProperty(g)&&null!=h&&!a.hasOwnProperty(g)&&nd(e,t,g,null,a,h);for(u in a)if(h=a[u],p=n[u],a.hasOwnProperty(u)&&h!==p&&(null!=h||null!=p))switch(u){case"children":case"dangerouslySetInnerHTML":if(null!=h)throw Error(r(137,t));break;default:nd(e,t,u,h,a,p)}return;default:if(zt(t)){for(var b in n)h=n[b],n.hasOwnProperty(b)&&void 0!==h&&!a.hasOwnProperty(b)&&rd(e,t,b,void 0,a,h);for(d in a)h=a[d],p=n[d],!a.hasOwnProperty(d)||h===p||void 0===h&&void 0===p||rd(e,t,d,h,a,p);return}}for(var y in n)h=n[y],n.hasOwnProperty(y)&&null!=h&&!a.hasOwnProperty(y)&&nd(e,t,y,null,a,h);for(m in a)h=a[m],p=n[m],!a.hasOwnProperty(m)||h===p||null==h&&null==p||nd(e,t,m,h,a,p)}(a,e.type,n,t),a[Oe]=t}catch(i){pu(e,e.return,i)}}function yl(e){return 5===e.tag||3===e.tag||26===e.tag||27===e.tag&&bd(e.type)||4===e.tag}function vl(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||yl(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&&bd(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 xl(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?(9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).insertBefore(e,t):((t=9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=td));else if(4!==r&&(27===r&&bd(e.type)&&(n=e.stateNode,t=null),null!==(e=e.child)))for(xl(e,t,n),e=e.sibling;null!==e;)xl(e,t,n),e=e.sibling}function wl(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==r&&(27===r&&bd(e.type)&&(n=e.stateNode),null!==(e=e.child)))for(wl(e,t,n),e=e.sibling;null!==e;)wl(e,t,n),e=e.sibling}function kl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,a=t.attributes;a.length;)t.removeAttributeNode(a[0]);ad(t,r,n),t[Le]=e,t[Oe]=n}catch(i){pu(e,e.return,i)}}var Sl=!1,Cl=!1,El=!1,Nl="function"==typeof WeakSet?WeakSet:Set,jl=null;function _l(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Ul(e,n),4&r&&ul(5,n);break;case 1:if(Ul(e,n),4&r)if(e=n.stateNode,null===t)try{e.componentDidMount()}catch(o){pu(n,n.return,o)}else{var a=xs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(a,t,e.__reactInternalSnapshotBeforeUpdate)}catch(s){pu(n,n.return,s)}}64&r&&ml(n),512&r&&pl(n,n.return);break;case 3:if(Ul(e,n),64&r&&null!==(e=n.updateQueue)){if(t=null,null!==n.child)switch(n.child.tag){case 27:case 5:case 1:t=n.child.stateNode}try{gi(e,t)}catch(o){pu(n,n.return,o)}}break;case 27:null===t&&4&r&&kl(n);case 26:case 5:Ul(e,n),null===t&&4&r&&gl(n),512&r&&pl(n,n.return);break;case 12:Ul(e,n);break;case 13:Ul(e,n),4&r&&Ml(e,n),64&r&&(null!==(e=n.memoizedState)&&(null!==(e=e.dehydrated)&&function(e,t){var n=e.ownerDocument;if("$?"!==e.data||"complete"===n.readyState)t();else{var r=function(){t(),n.removeEventListener("DOMContentLoaded",r)};n.addEventListener("DOMContentLoaded",r),e._reactRetry=r}}(e,n=yu.bind(null,n))));break;case 22:if(!(r=null!==n.memoizedState||Sl)){t=null!==t&&null!==t.memoizedState||Cl,a=Sl;var i=Cl;Sl=r,(Cl=t)&&!i?Bl(e,n,!!(8772&n.subtreeFlags)):Ul(e,n),Sl=a,Cl=i}break;case 30:break;default:Ul(e,n)}}function $l(e){var t=e.alternate;null!==t&&(e.alternate=null,$l(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&He(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 zl=null,Tl=!1;function Al(e,t,n){for(n=n.child;null!==n;)Pl(e,t,n),n=n.sibling}function Pl(e,t,n){if(fe&&"function"==typeof fe.onCommitFiberUnmount)try{fe.onCommitFiberUnmount(pe,n)}catch(i){}switch(n.tag){case 26:Cl||fl(n,t),Al(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode).parentNode.removeChild(n);break;case 27:Cl||fl(n,t);var r=zl,a=Tl;bd(n.type)&&(zl=n.stateNode,Tl=!1),Al(e,t,n),Ed(n.stateNode),zl=r,Tl=a;break;case 5:Cl||fl(n,t);case 6:if(r=zl,a=Tl,zl=null,Al(e,t,n),Tl=a,null!==(zl=r))if(Tl)try{(9===zl.nodeType?zl.body:"HTML"===zl.nodeName?zl.ownerDocument.body:zl).removeChild(n.stateNode)}catch(o){pu(n,t,o)}else try{zl.removeChild(n.stateNode)}catch(o){pu(n,t,o)}break;case 18:null!==zl&&(Tl?(yd(9===(e=zl).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,n.stateNode),Tm(e)):yd(zl,n.stateNode));break;case 4:r=zl,a=Tl,zl=n.stateNode.containerInfo,Tl=!0,Al(e,t,n),zl=r,Tl=a;break;case 0:case 11:case 14:case 15:Cl||dl(2,n,t),Cl||dl(4,n,t),Al(e,t,n);break;case 1:Cl||(fl(n,t),"function"==typeof(r=n.stateNode).componentWillUnmount&&hl(n,t,r)),Al(e,t,n);break;case 21:Al(e,t,n);break;case 22:Cl=(r=Cl)||null!==n.memoizedState,Al(e,t,n),Cl=r;break;default:Al(e,t,n)}}function Ml(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&(null!==(e=e.memoizedState)&&null!==(e=e.dehydrated))))try{Tm(e)}catch(n){pu(t,t.return,n)}}function Il(e,t){var n=function(e){switch(e.tag){case 13:case 19:var t=e.stateNode;return null===t&&(t=e.stateNode=new Nl),t;case 22:return null===(t=(e=e.stateNode)._retryCache)&&(t=e._retryCache=new Nl),t;default:throw Error(r(435,e.tag))}}(e);t.forEach(function(t){var r=vu.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}function Ll(e,t){var n=t.deletions;if(null!==n)for(var a=0;a<n.length;a++){var i=n[a],o=e,s=t,l=s;e:for(;null!==l;){switch(l.tag){case 27:if(bd(l.type)){zl=l.stateNode,Tl=!1;break e}break;case 5:zl=l.stateNode,Tl=!1;break e;case 3:case 4:zl=l.stateNode.containerInfo,Tl=!0;break e}l=l.return}if(null===zl)throw Error(r(160));Pl(o,s,i),zl=null,Tl=!1,null!==(o=i.alternate)&&(o.return=null),i.return=null}if(13878&t.subtreeFlags)for(t=t.child;null!==t;)Rl(t,e),t=t.sibling}var Ol=null;function Rl(e,t){var n=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Ll(t,e),Dl(e),4&a&&(dl(3,e,e.return),ul(3,e),dl(5,e,e.return));break;case 1:Ll(t,e),Dl(e),512&a&&(Cl||null===n||fl(n,n.return)),64&a&&Sl&&(null!==(e=e.updateQueue)&&(null!==(a=e.callbacks)&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=null===n?a:n.concat(a))));break;case 26:var i=Ol;if(Ll(t,e),Dl(e),512&a&&(Cl||null===n||fl(n,n.return)),4&a){var o=null!==n?n.memoizedState:null;if(a=e.memoizedState,null===n)if(null===a)if(null===e.stateNode){e:{a=e.type,n=e.memoizedProps,i=i.ownerDocument||i;t:switch(a){case"title":(!(o=i.getElementsByTagName("title")[0])||o[Be]||o[Le]||"http://www.w3.org/2000/svg"===o.namespaceURI||o.hasAttribute("itemprop"))&&(o=i.createElement(a),i.head.insertBefore(o,i.querySelector("head > title"))),ad(o,a,n),o[Le]=e,Qe(o),a=o;break e;case"link":var s=Bd("link","href",i).get(a+(n.href||""));if(s)for(var l=0;l<s.length;l++)if((o=s[l]).getAttribute("href")===(null==n.href||""===n.href?null:n.href)&&o.getAttribute("rel")===(null==n.rel?null:n.rel)&&o.getAttribute("title")===(null==n.title?null:n.title)&&o.getAttribute("crossorigin")===(null==n.crossOrigin?null:n.crossOrigin)){s.splice(l,1);break t}ad(o=i.createElement(a),a,n),i.head.appendChild(o);break;case"meta":if(s=Bd("meta","content",i).get(a+(n.content||"")))for(l=0;l<s.length;l++)if((o=s[l]).getAttribute("content")===(null==n.content?null:""+n.content)&&o.getAttribute("name")===(null==n.name?null:n.name)&&o.getAttribute("property")===(null==n.property?null:n.property)&&o.getAttribute("http-equiv")===(null==n.httpEquiv?null:n.httpEquiv)&&o.getAttribute("charset")===(null==n.charSet?null:n.charSet)){s.splice(l,1);break t}ad(o=i.createElement(a),a,n),i.head.appendChild(o);break;default:throw Error(r(468,a))}o[Le]=e,Qe(o),a=o}e.stateNode=a}else Hd(i,e.type,e.stateNode);else e.stateNode=Rd(i,a,e.memoizedProps);else o!==a?(null===o?null!==n.stateNode&&(n=n.stateNode).parentNode.removeChild(n):o.count--,null===a?Hd(i,e.type,e.stateNode):Rd(i,a,e.memoizedProps)):null===a&&null!==e.stateNode&&bl(e,e.memoizedProps,n.memoizedProps)}break;case 27:Ll(t,e),Dl(e),512&a&&(Cl||null===n||fl(n,n.return)),null!==n&&4&a&&bl(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Ll(t,e),Dl(e),512&a&&(Cl||null===n||fl(n,n.return)),32&e.flags){i=e.stateNode;try{Nt(i,"")}catch(p){pu(e,e.return,p)}}4&a&&null!=e.stateNode&&bl(e,i=e.memoizedProps,null!==n?n.memoizedProps:i),1024&a&&(El=!0);break;case 6:if(Ll(t,e),Dl(e),4&a){if(null===e.stateNode)throw Error(r(162));a=e.memoizedProps,n=e.stateNode;try{n.nodeValue=a}catch(p){pu(e,e.return,p)}}break;case 3:if(qd=null,i=Ol,Ol=_d(t.containerInfo),Ll(t,e),Ol=i,Dl(e),4&a&&null!==n&&n.memoizedState.isDehydrated)try{Tm(t.containerInfo)}catch(p){pu(e,e.return,p)}El&&(El=!1,Fl(e));break;case 4:a=Ol,Ol=_d(e.stateNode.containerInfo),Ll(t,e),Dl(e),Ol=a;break;case 12:default:Ll(t,e),Dl(e);break;case 13:Ll(t,e),Dl(e),8192&e.child.flags&&null!==e.memoizedState!=(null!==n&&null!==n.memoizedState)&&(Ec=ie()),4&a&&(null!==(a=e.updateQueue)&&(e.updateQueue=null,Il(e,a)));break;case 22:i=null!==e.memoizedState;var c=null!==n&&null!==n.memoizedState,u=Sl,d=Cl;if(Sl=u||i,Cl=d||c,Ll(t,e),Cl=d,Sl=u,Dl(e),8192&a)e:for(t=e.stateNode,t._visibility=i?-2&t._visibility:1|t._visibility,i&&(null===n||c||Sl||Cl||ql(e)),n=null,t=e;;){if(5===t.tag||26===t.tag){if(null===n){c=n=t;try{if(o=c.stateNode,i)"function"==typeof(s=o.style).setProperty?s.setProperty("display","none","important"):s.display="none";else{l=c.stateNode;var m=c.memoizedProps.style,h=null!=m&&m.hasOwnProperty("display")?m.display:null;l.style.display=null==h||"boolean"==typeof h?"":(""+h).trim()}}catch(p){pu(c,c.return,p)}}}else if(6===t.tag){if(null===n){c=t;try{c.stateNode.nodeValue=i?"":c.memoizedProps}catch(p){pu(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;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}4&a&&(null!==(a=e.updateQueue)&&(null!==(n=a.retryQueue)&&(a.retryQueue=null,Il(e,n))));break;case 19:Ll(t,e),Dl(e),4&a&&(null!==(a=e.updateQueue)&&(e.updateQueue=null,Il(e,a)));case 30:case 21:}}function Dl(e){var t=e.flags;if(2&t){try{for(var n,a=e.return;null!==a;){if(yl(a)){n=a;break}a=a.return}if(null==n)throw Error(r(160));switch(n.tag){case 27:var i=n.stateNode;wl(e,vl(e),i);break;case 5:var o=n.stateNode;32&n.flags&&(Nt(o,""),n.flags&=-33),wl(e,vl(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;xl(e,vl(e),s);break;default:throw Error(r(161))}}catch(l){pu(e,e.return,l)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function Fl(e){if(1024&e.subtreeFlags)for(e=e.child;null!==e;){var t=e;Fl(t),5===t.tag&&1024&t.flags&&t.stateNode.reset(),e=e.sibling}}function Ul(e,t){if(8772&t.subtreeFlags)for(t=t.child;null!==t;)_l(e,t.alternate,t),t=t.sibling}function ql(e){for(e=e.child;null!==e;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:dl(4,t,t.return),ql(t);break;case 1:fl(t,t.return);var n=t.stateNode;"function"==typeof n.componentWillUnmount&&hl(t,t.return,n),ql(t);break;case 27:Ed(t.stateNode);case 26:case 5:fl(t,t.return),ql(t);break;case 22:null===t.memoizedState&&ql(t);break;default:ql(t)}e=e.sibling}}function Bl(e,t,n){for(n=n&&!!(8772&t.subtreeFlags),t=t.child;null!==t;){var r=t.alternate,a=e,i=t,o=i.flags;switch(i.tag){case 0:case 11:case 15:Bl(a,i,n),ul(4,i);break;case 1:if(Bl(a,i,n),"function"==typeof(a=(r=i).stateNode).componentDidMount)try{a.componentDidMount()}catch(c){pu(r,r.return,c)}if(null!==(a=(r=i).updateQueue)){var s=r.stateNode;try{var l=a.shared.hiddenCallbacks;if(null!==l)for(a.shared.hiddenCallbacks=null,a=0;a<l.length;a++)fi(l[a],s)}catch(c){pu(r,r.return,c)}}n&&64&o&&ml(i),pl(i,i.return);break;case 27:kl(i);case 26:case 5:Bl(a,i,n),n&&null===r&&4&o&&gl(i),pl(i,i.return);break;case 12:Bl(a,i,n);break;case 13:Bl(a,i,n),n&&4&o&&Ml(a,i);break;case 22:null===i.memoizedState&&Bl(a,i,n),pl(i,i.return);break;case 30:break;default:Bl(a,i,n)}t=t.sibling}}function Hl(e,t){var n=null;null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),e=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(e=t.memoizedState.cachePool.pool),e!==n&&(null!=e&&e.refCount++,null!=n&&Ra(n))}function Wl(e,t){e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Ra(e))}function Vl(e,t,n,r){if(10256&t.subtreeFlags)for(t=t.child;null!==t;)Kl(e,t,n,r),t=t.sibling}function Kl(e,t,n,r){var a=t.flags;switch(t.tag){case 0:case 11:case 15:Vl(e,t,n,r),2048&a&&ul(9,t);break;case 1:case 13:default:Vl(e,t,n,r);break;case 3:Vl(e,t,n,r),2048&a&&(e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Ra(e)));break;case 12:if(2048&a){Vl(e,t,n,r),e=t.stateNode;try{var i=t.memoizedProps,o=i.id,s=i.onPostCommit;"function"==typeof s&&s(o,null===t.alternate?"mount":"update",e.passiveEffectDuration,-0)}catch(l){pu(t,t.return,l)}}else Vl(e,t,n,r);break;case 23:break;case 22:i=t.stateNode,o=t.alternate,null!==t.memoizedState?2&i._visibility?Vl(e,t,n,r):Ql(e,t):2&i._visibility?Vl(e,t,n,r):(i._visibility|=2,Gl(e,t,n,r,!!(10256&t.subtreeFlags))),2048&a&&Hl(o,t);break;case 24:Vl(e,t,n,r),2048&a&&Wl(t.alternate,t)}}function Gl(e,t,n,r,a){for(a=a&&!!(10256&t.subtreeFlags),t=t.child;null!==t;){var i=e,o=t,s=n,l=r,c=o.flags;switch(o.tag){case 0:case 11:case 15:Gl(i,o,s,l,a),ul(8,o);break;case 23:break;case 22:var u=o.stateNode;null!==o.memoizedState?2&u._visibility?Gl(i,o,s,l,a):Ql(i,o):(u._visibility|=2,Gl(i,o,s,l,a)),a&&2048&c&&Hl(o.alternate,o);break;case 24:Gl(i,o,s,l,a),a&&2048&c&&Wl(o.alternate,o);break;default:Gl(i,o,s,l,a)}t=t.sibling}}function Ql(e,t){if(10256&t.subtreeFlags)for(t=t.child;null!==t;){var n=e,r=t,a=r.flags;switch(r.tag){case 22:Ql(n,r),2048&a&&Hl(r.alternate,r);break;case 24:Ql(n,r),2048&a&&Wl(r.alternate,r);break;default:Ql(n,r)}t=t.sibling}}var Yl=8192;function Xl(e){if(e.subtreeFlags&Yl)for(e=e.child;null!==e;)Jl(e),e=e.sibling}function Jl(e){switch(e.tag){case 26:Xl(e),e.flags&Yl&&null!==e.memoizedState&&function(e,t,n){if(null===Vd)throw Error(r(475));var a=Vd;if(!("stylesheet"!==t.type||"string"==typeof n.media&&!1===matchMedia(n.media).matches||4&t.state.loading)){if(null===t.instance){var i=Pd(n.href),o=e.querySelector(Md(i));if(o)return null!==(e=o._p)&&"object"==typeof e&&"function"==typeof e.then&&(a.count++,a=Gd.bind(a),e.then(a,a)),t.state.loading|=4,t.instance=o,void Qe(o);o=e.ownerDocument||e,n=Id(n),(i=Nd.get(i))&&Fd(n,i),Qe(o=o.createElement("link"));var s=o;s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),ad(o,"link",n),t.instance=o}null===a.stylesheets&&(a.stylesheets=new Map),a.stylesheets.set(t,e),(e=t.state.preload)&&!(3&t.state.loading)&&(a.count++,t=Gd.bind(a),e.addEventListener("load",t),e.addEventListener("error",t))}}(Ol,e.memoizedState,e.memoizedProps);break;case 5:default:Xl(e);break;case 3:case 4:var t=Ol;Ol=_d(e.stateNode.containerInfo),Xl(e),Ol=t;break;case 22:null===e.memoizedState&&(null!==(t=e.alternate)&&null!==t.memoizedState?(t=Yl,Yl=16777216,Xl(e),Yl=t):Xl(e))}}function Zl(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 ec(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var r=t[n];jl=r,rc(r,e)}Zl(e)}if(10256&e.subtreeFlags)for(e=e.child;null!==e;)tc(e),e=e.sibling}function tc(e){switch(e.tag){case 0:case 11:case 15:ec(e),2048&e.flags&&dl(9,e,e.return);break;case 3:case 12:default:ec(e);break;case 22:var t=e.stateNode;null!==e.memoizedState&&2&t._visibility&&(null===e.return||13!==e.return.tag)?(t._visibility&=-3,nc(e)):ec(e)}}function nc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var r=t[n];jl=r,rc(r,e)}Zl(e)}for(e=e.child;null!==e;){switch((t=e).tag){case 0:case 11:case 15:dl(8,t,t.return),nc(t);break;case 22:2&(n=t.stateNode)._visibility&&(n._visibility&=-3,nc(t));break;default:nc(t)}e=e.sibling}}function rc(e,t){for(;null!==jl;){var n=jl;switch(n.tag){case 0:case 11:case 15:dl(8,n,t);break;case 23:case 22:if(null!==n.memoizedState&&null!==n.memoizedState.cachePool){var r=n.memoizedState.cachePool.pool;null!=r&&r.refCount++}break;case 24:Ra(n.memoizedState.cache)}if(null!==(r=n.child))r.return=n,jl=r;else e:for(n=e;null!==jl;){var a=(r=jl).sibling,i=r.return;if($l(r),r===n){jl=null;break e}if(null!==a){a.return=i,jl=a;break e}jl=i}}}var ac={getCacheForType:function(e){var t=za(La),n=t.data.get(e);return void 0===n&&(n=e(),t.data.set(e,n)),n}},ic="function"==typeof WeakMap?WeakMap:Map,oc=0,sc=null,lc=null,cc=0,uc=0,dc=null,mc=!1,hc=!1,pc=!1,fc=0,gc=0,bc=0,yc=0,vc=0,xc=0,wc=0,kc=null,Sc=null,Cc=!1,Ec=0,Nc=1/0,jc=null,_c=null,$c=0,zc=null,Tc=null,Ac=0,Pc=0,Mc=null,Ic=null,Lc=0,Oc=null;function Rc(){if(2&oc&&0!==cc)return cc&-cc;if(null!==R.T){return 0!==Ua?Ua:Pu()}return Me()}function Dc(){0===xc&&(xc=536870912&cc&&!ca?536870912:Ne());var e=ls.current;return null!==e&&(e.flags|=32),xc}function Fc(e,t,n){(e!==sc||2!==uc&&9!==uc)&&null===e.cancelPendingCommit||(Kc(e,0),Hc(e,cc,xc,!1)),$e(e,n),2&oc&&e===sc||(e===sc&&(!(2&oc)&&(yc|=n),4===gc&&Hc(e,cc,xc,!1)),Nu(e))}function Uc(e,t,n){if(6&oc)throw Error(r(327));for(var a=!n&&!(124&t)&&0===(t&e.expiredLanes)||Ce(e,t),i=a?function(e,t){var n=oc;oc|=2;var a=Qc(),i=Yc();sc!==e||cc!==t?(jc=null,Nc=ie()+500,Kc(e,t)):hc=Ce(e,t);e:for(;;)try{if(0!==uc&&null!==lc){t=lc;var o=dc;t:switch(uc){case 1:uc=0,dc=null,ru(e,t,o,1);break;case 2:case 9:if(Za(o)){uc=0,dc=null,nu(t);break}t=function(){2!==uc&&9!==uc||sc!==e||(uc=7),Nu(e)},o.then(t,t);break e;case 3:uc=7;break e;case 4:uc=5;break e;case 7:Za(o)?(uc=0,dc=null,nu(t)):(uc=0,dc=null,ru(e,t,o,7));break;case 5:var s=null;switch(lc.tag){case 26:s=lc.memoizedState;case 5:case 27:var l=lc;if(!s||Wd(s)){uc=0,dc=null;var c=l.sibling;if(null!==c)lc=c;else{var u=l.return;null!==u?(lc=u,au(u)):lc=null}break t}}uc=0,dc=null,ru(e,t,o,5);break;case 6:uc=0,dc=null,ru(e,t,o,6);break;case 8:Vc(),gc=6;break e;default:throw Error(r(462))}}eu();break}catch(d){Gc(e,d)}return ka=wa=null,R.H=a,R.A=i,oc=n,null!==lc?0:(sc=null,cc=0,Ar(),gc)}(e,t):Jc(e,t,!0),o=a;;){if(0===i){hc&&!a&&Hc(e,t,0,!1);break}if(n=e.current.alternate,!o||Bc(n)){if(2===i){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=0!==(s=-536870913&e.pendingLanes)?s:536870912&s?536870912:0;if(0!==s){t=s;e:{var l=e;i=kc;var c=l.current.memoizedState.isDehydrated;if(c&&(Kc(l,s).flags|=256),2!==(s=Jc(l,s,!1))){if(pc&&!c){l.errorRecoveryDisabledLanes|=o,yc|=o,i=4;break e}o=Sc,Sc=i,null!==o&&(null===Sc?Sc=o:Sc.push.apply(Sc,o))}i=s}if(o=!1,2!==i)continue}}if(1===i){Kc(e,0),Hc(e,t,0,!0);break}e:{switch(a=e,o=i){case 0:case 1:throw Error(r(345));case 4:if((4194048&t)!==t)break;case 6:Hc(a,t,xc,!mc);break e;case 2:Sc=null;break;case 3:case 5:break;default:throw Error(r(329))}if((62914560&t)===t&&10<(i=Ec+300-ie())){if(Hc(a,t,xc,!mc),0!==Se(a,0,!0))break e;a.timeoutHandle=md(qc.bind(null,a,n,Sc,jc,Cc,t,xc,yc,wc,mc,o,2,-0,0),i)}else qc(a,n,Sc,jc,Cc,t,xc,yc,wc,mc,o,0,-0,0)}break}i=Jc(e,t,!1),o=!1}Nu(e)}function qc(e,t,n,a,i,o,s,l,c,u,d,m,h,p){if(e.timeoutHandle=-1,(8192&(m=t.subtreeFlags)||!(16785408&~m))&&(Vd={stylesheets:null,count:0,unsuspend:Kd},Jl(t),null!==(m=function(){if(null===Vd)throw Error(r(475));var e=Vd;return e.stylesheets&&0===e.count&&Yd(e,e.stylesheets),0<e.count?function(t){var n=setTimeout(function(){if(e.stylesheets&&Yd(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4);return e.unsuspend=t,function(){e.unsuspend=null,clearTimeout(n)}}:null}())))return e.cancelPendingCommit=m(ou.bind(null,e,t,o,n,a,i,s,l,c,d,1,h,p)),void Hc(e,o,s,!u);ou(e,t,o,n,a,i,s,l,c)}function Bc(e){for(var t=e;;){var n=t.tag;if((0===n||11===n||15===n)&&16384&t.flags&&(null!==(n=t.updateQueue)&&null!==(n=n.stores)))for(var r=0;r<n.length;r++){var a=n[r],i=a.getSnapshot;a=a.value;try{if(!Zn(i(),a))return!1}catch(o){return!1}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;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 Hc(e,t,n,r){t&=~vc,t&=~yc,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var a=t;0<a;){var i=31-be(a),o=1<<i;r[i]=-1,a&=~o}0!==n&&ze(e,n,t)}function Wc(){return!!(6&oc)||(ju(0),!1)}function Vc(){if(null!==lc){if(0===uc)var e=lc.return;else ka=wa=null,Ui(e=lc),Zo=null,es=0,e=lc;for(;null!==e;)cl(e.alternate,e),e=e.return;lc=null}}function Kc(e,t){var n=e.timeoutHandle;-1!==n&&(e.timeoutHandle=-1,hd(n)),null!==(n=e.cancelPendingCommit)&&(e.cancelPendingCommit=null,n()),Vc(),sc=e,lc=n=qr(e.current,null),cc=t,uc=0,dc=null,mc=!1,hc=Ce(e,t),pc=!1,wc=xc=vc=yc=bc=gc=0,Sc=kc=null,Cc=!1,8&t&&(t|=32&t);var r=e.entangledLanes;if(0!==r)for(e=e.entanglements,r&=t;0<r;){var a=31-be(r),i=1<<a;t|=e[a],r&=~i}return fc=t,Ar(),n}function Gc(e,t){Si=null,R.H=Qo,t===Qa||t===Xa?(t=ri(),uc=3):t===Ya?(t=ri(),uc=4):uc=t===zs?8:null!==t&&"object"==typeof t&&"function"==typeof t.then?6:1,dc=t,null===lc&&(gc=1,Es(e,_r(t,e.current)))}function Qc(){var e=R.H;return R.H=Qo,null===e?Qo:e}function Yc(){var e=R.A;return R.A=ac,e}function Xc(){gc=4,mc||(4194048&cc)!==cc&&null!==ls.current||(hc=!0),!(134217727&bc)&&!(134217727&yc)||null===sc||Hc(sc,cc,xc,!1)}function Jc(e,t,n){var r=oc;oc|=2;var a=Qc(),i=Yc();sc===e&&cc===t||(jc=null,Kc(e,t)),t=!1;var o=gc;e:for(;;)try{if(0!==uc&&null!==lc){var s=lc,l=dc;switch(uc){case 8:Vc(),o=6;break e;case 3:case 2:case 9:case 6:null===ls.current&&(t=!0);var c=uc;if(uc=0,dc=null,ru(e,s,l,c),n&&hc){o=0;break e}break;default:c=uc,uc=0,dc=null,ru(e,s,l,c)}}Zc(),o=gc;break}catch(u){Gc(e,u)}return t&&e.shellSuspendCounter++,ka=wa=null,oc=r,R.H=a,R.A=i,null===lc&&(sc=null,cc=0,Ar()),o}function Zc(){for(;null!==lc;)tu(lc)}function eu(){for(;null!==lc&&!re();)tu(lc)}function tu(e){var t=tl(e.alternate,e,fc);e.memoizedProps=e.pendingProps,null===t?au(e):lc=t}function nu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Fs(n,t,t.pendingProps,t.type,void 0,cc);break;case 11:t=Fs(n,t,t.pendingProps,t.type.render,t.ref,cc);break;case 5:Ui(t);default:cl(n,t),t=tl(n,t=lc=Br(t,fc),fc)}e.memoizedProps=e.pendingProps,null===t?au(e):lc=t}function ru(e,t,n,a){ka=wa=null,Ui(t),Zo=null,es=0;var i=t.return;try{if(function(e,t,n,a,i){if(n.flags|=32768,null!==a&&"object"==typeof a&&"function"==typeof a.then){if(null!==(t=n.alternate)&&ja(t,n,i,!0),null!==(n=ls.current)){switch(n.tag){case 13:return null===cs?Xc():null===n.alternate&&0===gc&&(gc=3),n.flags&=-257,n.flags|=65536,n.lanes=i,a===Ja?n.flags|=16384:(null===(t=n.updateQueue)?n.updateQueue=new Set([a]):t.add(a),fu(e,a,i)),!1;case 22:return n.flags|=65536,a===Ja?n.flags|=16384:(null===(t=n.updateQueue)?(t={transitions:null,markerInstances:null,retryQueue:new Set([a])},n.updateQueue=t):null===(n=t.retryQueue)?t.retryQueue=new Set([a]):n.add(a),fu(e,a,i)),!1}throw Error(r(435,n.tag))}return fu(e,a,i),Xc(),!1}if(ca)return null!==(t=ls.current)?(!(65536&t.flags)&&(t.flags|=256),t.flags|=65536,t.lanes=i,a!==ma&&va(_r(e=Error(r(422),{cause:a}),n))):(a!==ma&&va(_r(t=Error(r(423),{cause:a}),n)),(e=e.current.alternate).flags|=65536,i&=-i,e.lanes|=i,a=_r(a,n),di(e,i=js(e.stateNode,a,i)),4!==gc&&(gc=2)),!1;var o=Error(r(520),{cause:a});if(o=_r(o,n),null===kc?kc=[o]:kc.push(o),4!==gc&&(gc=2),null===t)return!0;a=_r(a,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,di(n,e=js(n.stateNode,a,e)),!1;case 1:if(t=n.type,o=n.stateNode,!(128&n.flags||"function"!=typeof t.getDerivedStateFromError&&(null===o||"function"!=typeof o.componentDidCatch||null!==_c&&_c.has(o))))return n.flags|=65536,i&=-i,n.lanes|=i,$s(i=_s(i),e,n,a),di(n,i),!1}n=n.return}while(null!==n);return!1}(e,i,t,n,cc))return gc=1,Es(e,_r(n,e.current)),void(lc=null)}catch(o){if(null!==i)throw lc=i,o;return gc=1,Es(e,_r(n,e.current)),void(lc=null)}32768&t.flags?(ca||1===a?e=!0:hc||536870912&cc?e=!1:(mc=e=!0,(2===a||9===a||3===a||6===a)&&(null!==(a=ls.current)&&13===a.tag&&(a.flags|=16384))),iu(t,e)):au(t)}function au(e){var t=e;do{if(32768&t.flags)return void iu(t,mc);e=t.return;var n=sl(t.alternate,t,fc);if(null!==n)return void(lc=n);if(null!==(t=t.sibling))return void(lc=t);lc=t=e}while(null!==t);0===gc&&(gc=5)}function iu(e,t){do{var n=ll(e.alternate,e);if(null!==n)return n.flags&=32767,void(lc=n);if(null!==(n=e.return)&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&null!==(e=e.sibling))return void(lc=e);lc=e=n}while(null!==e);gc=6,lc=null}function ou(e,t,n,a,i,o,s,l,c){e.cancelPendingCommit=null;do{du()}while(0!==$c);if(6&oc)throw Error(r(327));if(null!==t){if(t===e.current)throw Error(r(177));if(o=t.lanes|t.childLanes,function(e,t,n,r,a,i){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,l=e.expirationTimes,c=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-be(n),d=1<<u;s[u]=0,l[u]=-1;var m=c[u];if(null!==m)for(c[u]=null,u=0;u<m.length;u++){var h=m[u];null!==h&&(h.lane&=-536870913)}n&=~d}0!==r&&ze(e,r,0),0!==i&&0===a&&0!==e.tag&&(e.suspendedLanes|=i&~(o&~t))}(e,n,o|=Tr,s,l,c),e===sc&&(lc=sc=null,cc=0),Tc=t,zc=e,Ac=n,Pc=o,Mc=i,Ic=a,10256&t.subtreeFlags||10256&t.flags?(e.callbackNode=null,e.callbackPriority=0,te(ce,function(){return mu(),null})):(e.callbackNode=null,e.callbackPriority=0),a=!!(13878&t.flags),13878&t.subtreeFlags||a){a=R.T,R.T=null,i=D.p,D.p=2,s=oc,oc|=4;try{!function(e,t){if(e=e.containerInfo,id=om,ir(e=ar(e))){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{var a=(n=(n=e.ownerDocument)&&n.defaultView||window).getSelection&&n.getSelection();if(a&&0!==a.rangeCount){n=a.anchorNode;var i=a.anchorOffset,o=a.focusNode;a=a.focusOffset;try{n.nodeType,o.nodeType}catch(g){n=null;break e}var s=0,l=-1,c=-1,u=0,d=0,m=e,h=null;t:for(;;){for(var p;m!==n||0!==i&&3!==m.nodeType||(l=s+i),m!==o||0!==a&&3!==m.nodeType||(c=s+a),3===m.nodeType&&(s+=m.nodeValue.length),null!==(p=m.firstChild);)h=m,m=p;for(;;){if(m===e)break t;if(h===n&&++u===i&&(l=s),h===o&&++d===a&&(c=s),null!==(p=m.nextSibling))break;h=(m=h).parentNode}m=p}n=-1===l||-1===c?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(od={focusedElem:e,selectionRange:n},om=!1,jl=t;null!==jl;)if(e=(t=jl).child,1024&t.subtreeFlags&&null!==e)e.return=t,jl=e;else for(;null!==jl;){switch(o=(t=jl).alternate,e=t.flags,t.tag){case 0:case 11:case 15:case 5:case 26:case 27:case 6:case 4:case 17:break;case 1:if(1024&e&&null!==o){e=void 0,n=t,i=o.memoizedProps,o=o.memoizedState,a=n.stateNode;try{var f=xs(n.type,i,(n.elementType,n.type));e=a.getSnapshotBeforeUpdate(f,o),a.__reactInternalSnapshotBeforeUpdate=e}catch(b){pu(n,n.return,b)}}break;case 3:if(1024&e)if(9===(n=(e=t.stateNode.containerInfo).nodeType))vd(e);else if(1===n)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":vd(e);break;default:e.textContent=""}break;default:if(1024&e)throw Error(r(163))}if(null!==(e=t.sibling)){e.return=t.return,jl=e;break}jl=t.return}}(e,t)}finally{oc=s,D.p=i,R.T=a}}$c=1,su(),lu(),cu()}}function su(){if(1===$c){$c=0;var e=zc,t=Tc,n=!!(13878&t.flags);if(13878&t.subtreeFlags||n){n=R.T,R.T=null;var r=D.p;D.p=2;var a=oc;oc|=4;try{Rl(t,e);var i=od,o=ar(e.containerInfo),s=i.focusedElem,l=i.selectionRange;if(o!==s&&s&&s.ownerDocument&&rr(s.ownerDocument.documentElement,s)){if(null!==l&&ir(s)){var c=l.start,u=l.end;if(void 0===u&&(u=c),"selectionStart"in s)s.selectionStart=c,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,m=d&&d.defaultView||window;if(m.getSelection){var h=m.getSelection(),p=s.textContent.length,f=Math.min(l.start,p),g=void 0===l.end?f:Math.min(l.end,p);!h.extend&&f>g&&(o=g,g=f,f=o);var b=nr(s,f),y=nr(s,g);if(b&&y&&(1!==h.rangeCount||h.anchorNode!==b.node||h.anchorOffset!==b.offset||h.focusNode!==y.node||h.focusOffset!==y.offset)){var v=d.createRange();v.setStart(b.node,b.offset),h.removeAllRanges(),f>g?(h.addRange(v),h.extend(y.node,y.offset)):(v.setEnd(y.node,y.offset),h.addRange(v))}}}}for(d=[],h=s;h=h.parentNode;)1===h.nodeType&&d.push({element:h,left:h.scrollLeft,top:h.scrollTop});for("function"==typeof s.focus&&s.focus(),s=0;s<d.length;s++){var x=d[s];x.element.scrollLeft=x.left,x.element.scrollTop=x.top}}om=!!id,od=id=null}finally{oc=a,D.p=r,R.T=n}}e.current=t,$c=2}}function lu(){if(2===$c){$c=0;var e=zc,t=Tc,n=!!(8772&t.flags);if(8772&t.subtreeFlags||n){n=R.T,R.T=null;var r=D.p;D.p=2;var a=oc;oc|=4;try{_l(e,t.alternate,t)}finally{oc=a,D.p=r,R.T=n}}$c=3}}function cu(){if(4===$c||3===$c){$c=0,ae();var e=zc,t=Tc,n=Ac,r=Ic;10256&t.subtreeFlags||10256&t.flags?$c=5:($c=0,Tc=zc=null,uu(e,e.pendingLanes));var a=e.pendingLanes;if(0===a&&(_c=null),Pe(n),t=t.stateNode,fe&&"function"==typeof fe.onCommitFiberRoot)try{fe.onCommitFiberRoot(pe,t,void 0,!(128&~t.current.flags))}catch(l){}if(null!==r){t=R.T,a=D.p,D.p=2,R.T=null;try{for(var i=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];i(s.value,{componentStack:s.stack})}}finally{R.T=t,D.p=a}}3&Ac&&du(),Nu(e),a=e.pendingLanes,4194090&n&&42&a?e===Oc?Lc++:(Lc=0,Oc=e):Lc=0,ju(0)}}function uu(e,t){0===(e.pooledCacheLanes&=t)&&(null!=(t=e.pooledCache)&&(e.pooledCache=null,Ra(t)))}function du(e){return su(),lu(),cu(),mu()}function mu(){if(5!==$c)return!1;var e=zc,t=Pc;Pc=0;var n=Pe(Ac),a=R.T,i=D.p;try{D.p=32>n?32:n,R.T=null,n=Mc,Mc=null;var o=zc,s=Ac;if($c=0,Tc=zc=null,Ac=0,6&oc)throw Error(r(331));var l=oc;if(oc|=4,tc(o.current),Kl(o,o.current,s,n),oc=l,ju(0,!1),fe&&"function"==typeof fe.onPostCommitFiberRoot)try{fe.onPostCommitFiberRoot(pe,o)}catch(c){}return!0}finally{D.p=i,R.T=a,uu(e,t)}}function hu(e,t,n){t=_r(n,t),null!==(e=ci(e,t=js(e.stateNode,t,2),2))&&($e(e,2),Nu(e))}function pu(e,t,n){if(3===e.tag)hu(e,e,n);else for(;null!==t;){if(3===t.tag){hu(t,e,n);break}if(1===t.tag){var r=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===_c||!_c.has(r))){e=_r(n,e),null!==(r=ci(t,n=_s(2),2))&&($s(n,r,t,e),$e(r,2),Nu(r));break}}t=t.return}}function fu(e,t,n){var r=e.pingCache;if(null===r){r=e.pingCache=new ic;var a=new Set;r.set(t,a)}else void 0===(a=r.get(t))&&(a=new Set,r.set(t,a));a.has(n)||(pc=!0,a.add(n),e=gu.bind(null,e,t,n),t.then(e,e))}function gu(e,t,n){var r=e.pingCache;null!==r&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,sc===e&&(cc&n)===n&&(4===gc||3===gc&&(62914560&cc)===cc&&300>ie()-Ec?!(2&oc)&&Kc(e,0):vc|=n,wc===cc&&(wc=0)),Nu(e)}function bu(e,t){0===t&&(t=je()),null!==(e=Ir(e,t))&&($e(e,t),Nu(e))}function yu(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),bu(e,n)}function vu(e,t){var n=0;switch(e.tag){case 13:var a=e.stateNode,i=e.memoizedState;null!==i&&(n=i.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(r(314))}null!==a&&a.delete(t),bu(e,n)}var xu=null,wu=null,ku=!1,Su=!1,Cu=!1,Eu=0;function Nu(e){e!==wu&&null===e.next&&(null===wu?xu=wu=e:wu=wu.next=e),Su=!0,ku||(ku=!0,fd(function(){6&oc?te(se,_u):$u()}))}function ju(e,t){if(!Cu&&Su){Cu=!0;do{for(var n=!1,r=xu;null!==r;){if(0!==e){var a=r.pendingLanes;if(0===a)var i=0;else{var o=r.suspendedLanes,s=r.pingedLanes;i=(1<<31-be(42|e)+1)-1,i=201326741&(i&=a&~(o&~s))?201326741&i|1:i?2|i:0}0!==i&&(n=!0,Au(r,i))}else i=cc,!(3&(i=Se(r,r===sc?i:0,null!==r.cancelPendingCommit||-1!==r.timeoutHandle)))||Ce(r,i)||(n=!0,Au(r,i));r=r.next}}while(n);Cu=!1}}function _u(){$u()}function $u(){Su=ku=!1;var e=0;0!==Eu&&(function(){var e=window.event;if(e&&"popstate"===e.type)return e!==dd&&(dd=e,!0);return dd=null,!1}()&&(e=Eu),Eu=0);for(var t=ie(),n=null,r=xu;null!==r;){var a=r.next,i=zu(r,t);0===i?(r.next=null,null===n?xu=a:n.next=a,null===a&&(wu=n)):(n=r,(0!==e||3&i)&&(Su=!0)),r=a}ju(e)}function zu(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,i=-62914561&e.pendingLanes;0<i;){var o=31-be(i),s=1<<o,l=a[o];-1===l?0!==(s&n)&&0===(s&r)||(a[o]=Ee(s,t)):l<=t&&(e.expiredLanes|=s),i&=~s}if(n=cc,n=Se(e,e===(t=sc)?n:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle),r=e.callbackNode,0===n||e===t&&(2===uc||9===uc)||null!==e.cancelPendingCommit)return null!==r&&null!==r&&ne(r),e.callbackNode=null,e.callbackPriority=0;if(!(3&n)||Ce(e,n)){if((t=n&-n)===e.callbackPriority)return t;switch(null!==r&&ne(r),Pe(n)){case 2:case 8:n=le;break;case 32:default:n=ce;break;case 268435456:n=de}return r=Tu.bind(null,e),n=te(n,r),e.callbackPriority=t,e.callbackNode=n,t}return null!==r&&null!==r&&ne(r),e.callbackPriority=2,e.callbackNode=null,2}function Tu(e,t){if(0!==$c&&5!==$c)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(du()&&e.callbackNode!==n)return null;var r=cc;return 0===(r=Se(e,e===sc?r:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle))?null:(Uc(e,r,t),zu(e,ie()),null!=e.callbackNode&&e.callbackNode===n?Tu.bind(null,e):null)}function Au(e,t){if(du())return null;Uc(e,t,!0)}function Pu(){return 0===Eu&&(Eu=Ne()),Eu}function Mu(e){return null==e||"symbol"==typeof e||"boolean"==typeof e?null:"function"==typeof e?e:Pt(""+e)}function Iu(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}for(var Lu=0;Lu<Er.length;Lu++){var Ou=Er[Lu];Nr(Ou.toLowerCase(),"on"+(Ou[0].toUpperCase()+Ou.slice(1)))}Nr(br,"onAnimationEnd"),Nr(yr,"onAnimationIteration"),Nr(vr,"onAnimationStart"),Nr("dblclick","onDoubleClick"),Nr("focusin","onFocus"),Nr("focusout","onBlur"),Nr(xr,"onTransitionRun"),Nr(wr,"onTransitionStart"),Nr(kr,"onTransitionCancel"),Nr(Sr,"onTransitionEnd"),Ze("onMouseEnter",["mouseout","mouseover"]),Ze("onMouseLeave",["mouseout","mouseover"]),Ze("onPointerEnter",["pointerout","pointerover"]),Ze("onPointerLeave",["pointerout","pointerover"]),Je("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Je("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Je("onBeforeInput",["compositionend","keypress","textInput","paste"]),Je("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Je("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Je("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ru="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(" "),Du=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ru));function Fu(e,t){t=!!(4&t);for(var n=0;n<e.length;n++){var r=e[n],a=r.event;r=r.listeners;e:{var i=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],l=s.instance,c=s.currentTarget;if(s=s.listener,l!==i&&a.isPropagationStopped())break e;i=s,a.currentTarget=c;try{i(a)}catch(u){ws(u)}a.currentTarget=null,i=l}else for(o=0;o<r.length;o++){if(l=(s=r[o]).instance,c=s.currentTarget,s=s.listener,l!==i&&a.isPropagationStopped())break e;i=s,a.currentTarget=c;try{i(a)}catch(u){ws(u)}a.currentTarget=null,i=l}}}}function Uu(e,t){var n=t[De];void 0===n&&(n=t[De]=new Set);var r=e+"__bubble";n.has(r)||(Wu(t,e,2,!1),n.add(r))}function qu(e,t,n){var r=0;t&&(r|=4),Wu(n,e,r,t)}var Bu="_reactListening"+Math.random().toString(36).slice(2);function Hu(e){if(!e[Bu]){e[Bu]=!0,Ye.forEach(function(t){"selectionchange"!==t&&(Du.has(t)||qu(t,!1,e),qu(t,!0,e))});var t=9===e.nodeType?e:e.ownerDocument;null===t||t[Bu]||(t[Bu]=!0,qu("selectionchange",!1,t))}}function Wu(e,t,n,r){switch(hm(t)){case 2:var a=sm;break;case 8:a=lm;break;default:a=cm}n=a.bind(null,t,n,e),a=void 0,!Bt||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(a=!0),r?void 0!==a?e.addEventListener(t,n,{capture:!0,passive:a}):e.addEventListener(t,n,!0):void 0!==a?e.addEventListener(t,n,{passive:a}):e.addEventListener(t,n,!1)}function Vu(e,t,n,r,a){var o=r;if(!(1&t||2&t||null===r))e:for(;;){if(null===r)return;var s=r.tag;if(3===s||4===s){var l=r.stateNode.containerInfo;if(l===a)break;if(4===s)for(s=r.return;null!==s;){var c=s.tag;if((3===c||4===c)&&s.stateNode.containerInfo===a)return;s=s.return}for(;null!==l;){if(null===(s=We(l)))return;if(5===(c=s.tag)||6===c||26===c||27===c){r=o=s;continue e}l=l.parentNode}}r=r.return}Ft(function(){var r=o,a=It(n),s=[];e:{var l=Cr.get(e);if(void 0!==l){var c=rn,u=e;switch(e){case"keypress":if(0===Qt(n))break e;case"keydown":case"keyup":c=vn;break;case"focusin":u="focus",c=un;break;case"focusout":u="blur",c=un;break;case"beforeblur":case"afterblur":c=un;break;case"click":if(2===n.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":c=ln;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":c=cn;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":c=wn;break;case br:case yr:case vr:c=dn;break;case Sr:c=kn;break;case"scroll":case"scrollend":c=on;break;case"wheel":c=Sn;break;case"copy":case"cut":case"paste":c=mn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=xn;break;case"toggle":case"beforetoggle":c=Cn}var d=!!(4&t),m=!d&&("scroll"===e||"scrollend"===e),h=d?null!==l?l+"Capture":null:l;d=[];for(var p,f=r;null!==f;){var g=f;if(p=g.stateNode,5!==(g=g.tag)&&26!==g&&27!==g||null===p||null===h||null!=(g=Ut(f,h))&&d.push(Ku(f,g,p)),m)break;f=f.return}0<d.length&&(l=new c(l,u,null,n,a),s.push({event:l,listeners:d}))}}if(!(7&t)){if(c="mouseout"===e||"pointerout"===e,(!(l="mouseover"===e||"pointerover"===e)||n===Mt||!(u=n.relatedTarget||n.fromElement)||!We(u)&&!u[Re])&&(c||l)&&(l=a.window===a?a:(l=a.ownerDocument)?l.defaultView||l.parentWindow:window,c?(c=r,null!==(u=(u=n.relatedTarget||n.toElement)?We(u):null)&&(m=i(u),d=u.tag,u!==m||5!==d&&27!==d&&6!==d)&&(u=null)):(c=null,u=r),c!==u)){if(d=ln,g="onMouseLeave",h="onMouseEnter",f="mouse","pointerout"!==e&&"pointerover"!==e||(d=xn,g="onPointerLeave",h="onPointerEnter",f="pointer"),m=null==c?l:Ke(c),p=null==u?l:Ke(u),(l=new d(g,f+"leave",c,n,a)).target=m,l.relatedTarget=p,g=null,We(a)===r&&((d=new d(h,f+"enter",u,n,a)).target=p,d.relatedTarget=m,g=d),m=g,c&&u)e:{for(h=u,f=0,p=d=c;p;p=Qu(p))f++;for(p=0,g=h;g;g=Qu(g))p++;for(;0<f-p;)d=Qu(d),f--;for(;0<p-f;)h=Qu(h),p--;for(;f--;){if(d===h||null!==h&&d===h.alternate)break e;d=Qu(d),h=Qu(h)}d=null}else d=null;null!==c&&Yu(s,l,c,d,!1),null!==u&&null!==m&&Yu(s,m,u,d,!0)}if("select"===(c=(l=r?Ke(r):window).nodeName&&l.nodeName.toLowerCase())||"input"===c&&"file"===l.type)var b=qn;else if(Ln(l))if(Bn)b=Jn;else{b=Yn;var y=Qn}else!(c=l.nodeName)||"input"!==c.toLowerCase()||"checkbox"!==l.type&&"radio"!==l.type?r&&zt(r.elementType)&&(b=qn):b=Xn;switch(b&&(b=b(e,r))?On(s,b,n,a):(y&&y(e,l,r),"focusout"===e&&r&&"number"===l.type&&null!=r.memoizedProps.value&&kt(l,"number",l.value)),y=r?Ke(r):window,e){case"focusin":(Ln(y)||"true"===y.contentEditable)&&(sr=y,lr=r,cr=null);break;case"focusout":cr=lr=sr=null;break;case"mousedown":ur=!0;break;case"contextmenu":case"mouseup":case"dragend":ur=!1,dr(s,n,a);break;case"selectionchange":if(or)break;case"keydown":case"keyup":dr(s,n,a)}var v;if(Nn)e:{switch(e){case"compositionstart":var x="onCompositionStart";break e;case"compositionend":x="onCompositionEnd";break e;case"compositionupdate":x="onCompositionUpdate";break e}x=void 0}else Mn?An(e,n)&&(x="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(x="onCompositionStart");x&&($n&&"ko"!==n.locale&&(Mn||"onCompositionStart"!==x?"onCompositionEnd"===x&&Mn&&(v=Gt()):(Vt="value"in(Wt=a)?Wt.value:Wt.textContent,Mn=!0)),0<(y=Gu(r,x)).length&&(x=new hn(x,e,null,n,a),s.push({event:x,listeners:y}),v?x.data=v:null!==(v=Pn(n))&&(x.data=v))),(v=_n?function(e,t){switch(e){case"compositionend":return Pn(t);case"keypress":return 32!==t.which?null:(Tn=!0,zn);case"textInput":return(e=t.data)===zn&&Tn?null:e;default:return null}}(e,n):function(e,t){if(Mn)return"compositionend"===e||!Nn&&An(e,t)?(e=Gt(),Kt=Vt=Wt=null,Mn=!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 $n&&"ko"!==t.locale?null:t.data}}(e,n))&&(0<(x=Gu(r,"onBeforeInput")).length&&(y=new hn("onBeforeInput","beforeinput",null,n,a),s.push({event:y,listeners:x}),y.data=v)),function(e,t,n,r,a){if("submit"===t&&n&&n.stateNode===a){var i=Mu((a[Oe]||null).action),o=r.submitter;o&&null!==(t=(t=o[Oe]||null)?Mu(t.formAction):o.getAttribute("formAction"))&&(i=t,o=null);var s=new rn("action","action",null,r,a);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(0!==Eu){var e=o?Iu(a,o):new FormData(a);Io(n,{pending:!0,data:e,method:a.method,action:i},null,e)}}else"function"==typeof i&&(s.preventDefault(),e=o?Iu(a,o):new FormData(a),Io(n,{pending:!0,data:e,method:a.method,action:i},i,e))},currentTarget:a}]})}}(s,e,r,n,a)}Fu(s,t)})}function Ku(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Gu(e,t){for(var n=t+"Capture",r=[];null!==e;){var a=e,i=a.stateNode;if(5!==(a=a.tag)&&26!==a&&27!==a||null===i||(null!=(a=Ut(e,n))&&r.unshift(Ku(e,a,i)),null!=(a=Ut(e,t))&&r.push(Ku(e,a,i))),3===e.tag)return r;e=e.return}return[]}function Qu(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag&&27!==e.tag);return e||null}function Yu(e,t,n,r,a){for(var i=t._reactName,o=[];null!==n&&n!==r;){var s=n,l=s.alternate,c=s.stateNode;if(s=s.tag,null!==l&&l===r)break;5!==s&&26!==s&&27!==s||null===c||(l=c,a?null!=(c=Ut(n,i))&&o.unshift(Ku(n,c,l)):a||null!=(c=Ut(n,i))&&o.push(Ku(n,c,l))),n=n.return}0!==o.length&&e.push({event:t,listeners:o})}var Xu=/\r\n?/g,Ju=/\u0000|\uFFFD/g;function Zu(e){return("string"==typeof e?e:""+e).replace(Xu,"\n").replace(Ju,"")}function ed(e,t){return t=Zu(t),Zu(e)===t}function td(){}function nd(e,t,n,a,i,o){switch(n){case"children":"string"==typeof a?"body"===t||"textarea"===t&&""===a||Nt(e,a):("number"==typeof a||"bigint"==typeof a)&&"body"!==t&&Nt(e,""+a);break;case"className":ot(e,"class",a);break;case"tabIndex":ot(e,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":ot(e,n,a);break;case"style":$t(e,a,o);break;case"data":if("object"!==t){ot(e,"data",a);break}case"src":case"href":if(""===a&&("a"!==t||"href"!==n)){e.removeAttribute(n);break}if(null==a||"function"==typeof a||"symbol"==typeof a||"boolean"==typeof a){e.removeAttribute(n);break}a=Pt(""+a),e.setAttribute(n,a);break;case"action":case"formAction":if("function"==typeof a){e.setAttribute(n,"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 o&&("formAction"===n?("input"!==t&&nd(e,t,"name",i.name,i,null),nd(e,t,"formEncType",i.formEncType,i,null),nd(e,t,"formMethod",i.formMethod,i,null),nd(e,t,"formTarget",i.formTarget,i,null)):(nd(e,t,"encType",i.encType,i,null),nd(e,t,"method",i.method,i,null),nd(e,t,"target",i.target,i,null))),null==a||"symbol"==typeof a||"boolean"==typeof a){e.removeAttribute(n);break}a=Pt(""+a),e.setAttribute(n,a);break;case"onClick":null!=a&&(e.onclick=td);break;case"onScroll":null!=a&&Uu("scroll",e);break;case"onScrollEnd":null!=a&&Uu("scrollend",e);break;case"dangerouslySetInnerHTML":if(null!=a){if("object"!=typeof a||!("__html"in a))throw Error(r(61));if(null!=(n=a.__html)){if(null!=i.children)throw Error(r(60));e.innerHTML=n}}break;case"multiple":e.multiple=a&&"function"!=typeof a&&"symbol"!=typeof a;break;case"muted":e.muted=a&&"function"!=typeof a&&"symbol"!=typeof a;break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":case"autoFocus":break;case"xlinkHref":if(null==a||"function"==typeof a||"boolean"==typeof a||"symbol"==typeof a){e.removeAttribute("xlink:href");break}n=Pt(""+a),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":null!=a&&"function"!=typeof a&&"symbol"!=typeof a?e.setAttribute(n,""+a):e.removeAttribute(n);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":a&&"function"!=typeof a&&"symbol"!=typeof a?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":!0===a?e.setAttribute(n,""):!1!==a&&null!=a&&"function"!=typeof a&&"symbol"!=typeof a?e.setAttribute(n,a):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":null!=a&&"function"!=typeof a&&"symbol"!=typeof a&&!isNaN(a)&&1<=a?e.setAttribute(n,a):e.removeAttribute(n);break;case"rowSpan":case"start":null==a||"function"==typeof a||"symbol"==typeof a||isNaN(a)?e.removeAttribute(n):e.setAttribute(n,a);break;case"popover":Uu("beforetoggle",e),Uu("toggle",e),it(e,"popover",a);break;case"xlinkActuate":st(e,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":st(e,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":st(e,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":st(e,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":st(e,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":st(e,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":st(e,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":st(e,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":st(e,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":it(e,"is",a);break;case"innerText":case"textContent":break;default:(!(2<n.length)||"o"!==n[0]&&"O"!==n[0]||"n"!==n[1]&&"N"!==n[1])&&it(e,n=Tt.get(n)||n,a)}}function rd(e,t,n,a,i,o){switch(n){case"style":$t(e,a,o);break;case"dangerouslySetInnerHTML":if(null!=a){if("object"!=typeof a||!("__html"in a))throw Error(r(61));if(null!=(n=a.__html)){if(null!=i.children)throw Error(r(60));e.innerHTML=n}}break;case"children":"string"==typeof a?Nt(e,a):("number"==typeof a||"bigint"==typeof a)&&Nt(e,""+a);break;case"onScroll":null!=a&&Uu("scroll",e);break;case"onScrollEnd":null!=a&&Uu("scrollend",e);break;case"onClick":null!=a&&(e.onclick=td);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":case"innerText":case"textContent":break;default:Xe.hasOwnProperty(n)||("o"!==n[0]||"n"!==n[1]||(i=n.endsWith("Capture"),t=n.slice(2,i?n.length-7:void 0),"function"==typeof(o=null!=(o=e[Oe]||null)?o[n]:null)&&e.removeEventListener(t,o,i),"function"!=typeof a)?n in e?e[n]=a:!0===a?e.setAttribute(n,""):it(e,n,a):("function"!=typeof o&&null!==o&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,a,i)))}}function ad(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Uu("error",e),Uu("load",e);var a,i=!1,o=!1;for(a in n)if(n.hasOwnProperty(a)){var s=n[a];if(null!=s)switch(a){case"src":i=!0;break;case"srcSet":o=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:nd(e,t,a,s,n,null)}}return o&&nd(e,t,"srcSet",n.srcSet,n,null),void(i&&nd(e,t,"src",n.src,n,null));case"input":Uu("invalid",e);var l=a=s=o=null,c=null,u=null;for(i in n)if(n.hasOwnProperty(i)){var d=n[i];if(null!=d)switch(i){case"name":o=d;break;case"type":s=d;break;case"checked":c=d;break;case"defaultChecked":u=d;break;case"value":a=d;break;case"defaultValue":l=d;break;case"children":case"dangerouslySetInnerHTML":if(null!=d)throw Error(r(137,t));break;default:nd(e,t,i,d,n,null)}}return wt(e,a,l,c,u,s,o,!1),void ft(e);case"select":for(o in Uu("invalid",e),i=s=a=null,n)if(n.hasOwnProperty(o)&&null!=(l=n[o]))switch(o){case"value":a=l;break;case"defaultValue":s=l;break;case"multiple":i=l;default:nd(e,t,o,l,n,null)}return t=a,n=s,e.multiple=!!i,void(null!=t?St(e,!!i,t,!1):null!=n&&St(e,!!i,n,!0));case"textarea":for(s in Uu("invalid",e),a=o=i=null,n)if(n.hasOwnProperty(s)&&null!=(l=n[s]))switch(s){case"value":i=l;break;case"defaultValue":o=l;break;case"children":a=l;break;case"dangerouslySetInnerHTML":if(null!=l)throw Error(r(91));break;default:nd(e,t,s,l,n,null)}return Et(e,i,o,a),void ft(e);case"option":for(c in n)if(n.hasOwnProperty(c)&&null!=(i=n[c]))if("selected"===c)e.selected=i&&"function"!=typeof i&&"symbol"!=typeof i;else nd(e,t,c,i,n,null);return;case"dialog":Uu("beforetoggle",e),Uu("toggle",e),Uu("cancel",e),Uu("close",e);break;case"iframe":case"object":Uu("load",e);break;case"video":case"audio":for(i=0;i<Ru.length;i++)Uu(Ru[i],e);break;case"image":Uu("error",e),Uu("load",e);break;case"details":Uu("toggle",e);break;case"embed":case"source":case"link":Uu("error",e),Uu("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 n)if(n.hasOwnProperty(u)&&null!=(i=n[u]))switch(u){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:nd(e,t,u,i,n,null)}return;default:if(zt(t)){for(d in n)n.hasOwnProperty(d)&&(void 0!==(i=n[d])&&rd(e,t,d,i,n,void 0));return}}for(l in n)n.hasOwnProperty(l)&&(null!=(i=n[l])&&nd(e,t,l,i,n,null))}var id=null,od=null;function sd(e){return 9===e.nodeType?e:e.ownerDocument}function ld(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 cd(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 ud(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 dd=null;var md="function"==typeof setTimeout?setTimeout:void 0,hd="function"==typeof clearTimeout?clearTimeout:void 0,pd="function"==typeof Promise?Promise:void 0,fd="function"==typeof queueMicrotask?queueMicrotask:void 0!==pd?function(e){return pd.resolve(null).then(e).catch(gd)}:md;function gd(e){setTimeout(function(){throw e})}function bd(e){return"head"===e}function yd(e,t){var n=t,r=0,a=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&8===i.nodeType)if("/$"===(n=i.data)){if(0<r&&8>r){n=r;var o=e.ownerDocument;if(1&n&&Ed(o.documentElement),2&n&&Ed(o.body),4&n)for(Ed(n=o.head),o=n.firstChild;o;){var s=o.nextSibling,l=o.nodeName;o[Be]||"SCRIPT"===l||"STYLE"===l||"LINK"===l&&"stylesheet"===o.rel.toLowerCase()||n.removeChild(o),o=s}}if(0===a)return e.removeChild(i),void Tm(t);a--}else"$"===n||"$?"===n||"$!"===n?a++:r=n.charCodeAt(0)-48;else r=0;n=i}while(n);Tm(t)}function vd(e){var t=e.firstChild;for(t&&10===t.nodeType&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":vd(n),He(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if("stylesheet"===n.rel.toLowerCase())continue}e.removeChild(n)}}function xd(e){return"$!"===e.data||"$?"===e.data&&"complete"===e.ownerDocument.readyState}function wd(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||"F!"===t||"F"===t)break;if("/$"===t)return null}}return e}var kd=null;function Sd(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n){if(0===t)return e;t--}else"/$"===n&&t++}e=e.previousSibling}return null}function Cd(e,t,n){switch(t=sd(n),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 Ed(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);He(e)}var Nd=new Map,jd=new Set;function _d(e){return"function"==typeof e.getRootNode?e.getRootNode():9===e.nodeType?e:e.ownerDocument}var $d=D.d;D.d={f:function(){var e=$d.f(),t=Wc();return e||t},r:function(e){var t=Ve(e);null!==t&&5===t.tag&&"form"===t.type?Oo(t):$d.r(e)},D:function(e){$d.D(e),Td("dns-prefetch",e,null)},C:function(e,t){$d.C(e,t),Td("preconnect",e,t)},L:function(e,t,n){$d.L(e,t,n);var r=zd;if(r&&e&&t){var a='link[rel="preload"][as="'+vt(t)+'"]';"image"===t&&n&&n.imageSrcSet?(a+='[imagesrcset="'+vt(n.imageSrcSet)+'"]',"string"==typeof n.imageSizes&&(a+='[imagesizes="'+vt(n.imageSizes)+'"]')):a+='[href="'+vt(e)+'"]';var i=a;switch(t){case"style":i=Pd(e);break;case"script":i=Ld(e)}Nd.has(i)||(e=u({rel:"preload",href:"image"===t&&n&&n.imageSrcSet?void 0:e,as:t},n),Nd.set(i,e),null!==r.querySelector(a)||"style"===t&&r.querySelector(Md(i))||"script"===t&&r.querySelector(Od(i))||(ad(t=r.createElement("link"),"link",e),Qe(t),r.head.appendChild(t)))}},m:function(e,t){$d.m(e,t);var n=zd;if(n&&e){var r=t&&"string"==typeof t.as?t.as:"script",a='link[rel="modulepreload"][as="'+vt(r)+'"][href="'+vt(e)+'"]',i=a;switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":i=Ld(e)}if(!Nd.has(i)&&(e=u({rel:"modulepreload",href:e},t),Nd.set(i,e),null===n.querySelector(a))){switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(Od(i)))return}ad(r=n.createElement("link"),"link",e),Qe(r),n.head.appendChild(r)}}},X:function(e,t){$d.X(e,t);var n=zd;if(n&&e){var r=Ge(n).hoistableScripts,a=Ld(e),i=r.get(a);i||((i=n.querySelector(Od(a)))||(e=u({src:e,async:!0},t),(t=Nd.get(a))&&Ud(e,t),Qe(i=n.createElement("script")),ad(i,"link",e),n.head.appendChild(i)),i={type:"script",instance:i,count:1,state:null},r.set(a,i))}},S:function(e,t,n){$d.S(e,t,n);var r=zd;if(r&&e){var a=Ge(r).hoistableStyles,i=Pd(e);t=t||"default";var o=a.get(i);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Md(i)))s.loading=5;else{e=u({rel:"stylesheet",href:e,"data-precedence":t},n),(n=Nd.get(i))&&Fd(e,n);var l=o=r.createElement("link");Qe(l),ad(l,"link",e),l._p=new Promise(function(e,t){l.onload=e,l.onerror=t}),l.addEventListener("load",function(){s.loading|=1}),l.addEventListener("error",function(){s.loading|=2}),s.loading|=4,Dd(o,t,r)}o={type:"stylesheet",instance:o,count:1,state:s},a.set(i,o)}}},M:function(e,t){$d.M(e,t);var n=zd;if(n&&e){var r=Ge(n).hoistableScripts,a=Ld(e),i=r.get(a);i||((i=n.querySelector(Od(a)))||(e=u({src:e,async:!0,type:"module"},t),(t=Nd.get(a))&&Ud(e,t),Qe(i=n.createElement("script")),ad(i,"link",e),n.head.appendChild(i)),i={type:"script",instance:i,count:1,state:null},r.set(a,i))}}};var zd="undefined"==typeof document?null:document;function Td(e,t,n){var r=zd;if(r&&"string"==typeof t&&t){var a=vt(t);a='link[rel="'+e+'"][href="'+a+'"]',"string"==typeof n&&(a+='[crossorigin="'+n+'"]'),jd.has(a)||(jd.add(a),e={rel:e,crossOrigin:n,href:t},null===r.querySelector(a)&&(ad(t=r.createElement("link"),"link",e),Qe(t),r.head.appendChild(t)))}}function Ad(e,t,n,a){var i,o,s,l,c=(c=G.current)?_d(c):null;if(!c)throw Error(r(446));switch(e){case"meta":case"title":return null;case"style":return"string"==typeof n.precedence&&"string"==typeof n.href?(t=Pd(n.href),(a=(n=Ge(c).hoistableStyles).get(t))||(a={type:"style",instance:null,count:0,state:null},n.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if("stylesheet"===n.rel&&"string"==typeof n.href&&"string"==typeof n.precedence){e=Pd(n.href);var u=Ge(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(Md(e)))&&!u._p&&(d.instance=u,d.state.loading=5),Nd.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Nd.set(e,n),u||(i=c,o=e,s=n,l=d.state,i.querySelector('link[rel="preload"][as="style"]['+o+"]")?l.loading=1:(o=i.createElement("link"),l.preload=o,o.addEventListener("load",function(){return l.loading|=1}),o.addEventListener("error",function(){return l.loading|=2}),ad(o,"link",s),Qe(o),i.head.appendChild(o))))),t&&null===a)throw Error(r(528,""));return d}if(t&&null!==a)throw Error(r(529,""));return null;case"script":return t=n.async,"string"==typeof(n=n.src)&&t&&"function"!=typeof t&&"symbol"!=typeof t?(t=Ld(n),(a=(n=Ge(c).hoistableScripts).get(t))||(a={type:"script",instance:null,count:0,state:null},n.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,e))}}function Pd(e){return'href="'+vt(e)+'"'}function Md(e){return'link[rel="stylesheet"]['+e+"]"}function Id(e){return u({},e,{"data-precedence":e.precedence,precedence:null})}function Ld(e){return'[src="'+vt(e)+'"]'}function Od(e){return"script[async]"+e}function Rd(e,t,n){if(t.count++,null===t.instance)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+vt(n.href)+'"]');if(a)return t.instance=a,Qe(a),a;var i=u({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return Qe(a=(e.ownerDocument||e).createElement("style")),ad(a,"style",i),Dd(a,n.precedence,e),t.instance=a;case"stylesheet":i=Pd(n.href);var o=e.querySelector(Md(i));if(o)return t.state.loading|=4,t.instance=o,Qe(o),o;a=Id(n),(i=Nd.get(i))&&Fd(a,i),Qe(o=(e.ownerDocument||e).createElement("link"));var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),ad(o,"link",a),t.state.loading|=4,Dd(o,n.precedence,e),t.instance=o;case"script":return o=Ld(n.src),(i=e.querySelector(Od(o)))?(t.instance=i,Qe(i),i):(a=n,(i=Nd.get(o))&&Ud(a=u({},n),i),Qe(i=(e=e.ownerDocument||e).createElement("script")),ad(i,"link",a),e.head.appendChild(i),t.instance=i);case"void":return null;default:throw Error(r(443,t.type))}else"stylesheet"===t.type&&!(4&t.state.loading)&&(a=t.instance,t.state.loading|=4,Dd(a,n.precedence,e));return t.instance}function Dd(e,t,n){for(var r=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),a=r.length?r[r.length-1]:null,i=a,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)i=s;else if(i!==a)break}i?i.parentNode.insertBefore(e,i.nextSibling):(t=9===n.nodeType?n.head:n).insertBefore(e,t.firstChild)}function Fd(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.title&&(e.title=t.title)}function Ud(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.integrity&&(e.integrity=t.integrity)}var qd=null;function Bd(e,t,n){if(null===qd){var r=new Map,a=qd=new Map;a.set(n,r)}else(r=(a=qd).get(n))||(r=new Map,a.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),a=0;a<n.length;a++){var i=n[a];if(!(i[Be]||i[Le]||"link"===e&&"stylesheet"===i.getAttribute("rel"))&&"http://www.w3.org/2000/svg"!==i.namespaceURI){var o=i.getAttribute(t)||"";o=e+o;var s=r.get(o);s?s.push(i):r.set(o,[i])}}return r}function Hd(e,t,n){(e=e.ownerDocument||e).head.insertBefore(n,"title"===t?e.querySelector("head > title"):null)}function Wd(e){return!!("stylesheet"!==e.type||3&e.state.loading)}var Vd=null;function Kd(){}function Gd(){if(this.count--,0===this.count)if(this.stylesheets)Yd(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}var Qd=null;function Yd(e,t){e.stylesheets=null,null!==e.unsuspend&&(e.count++,Qd=new Map,t.forEach(Xd,e),Qd=null,Gd.call(e))}function Xd(e,t){if(!(4&t.state.loading)){var n=Qd.get(e);if(n)var r=n.get(null);else{n=new Map,Qd.set(e,n);for(var a=e.querySelectorAll("link[data-precedence],style[data-precedence]"),i=0;i<a.length;i++){var o=a[i];"LINK"!==o.nodeName&&"not all"===o.getAttribute("media")||(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}o=(a=t.instance).getAttribute("data-precedence"),(i=n.get(o)||r)===r&&n.set(null,a),n.set(o,a),this.count++,r=Gd.bind(this),a.addEventListener("load",r),a.addEventListener("error",r),i?i.parentNode.insertBefore(a,i.nextSibling):(e=9===e.nodeType?e.head:e).insertBefore(a,e.firstChild),t.state.loading|=4}}var Jd={$$typeof:C,Provider:null,Consumer:null,_currentValue:F,_currentValue2:F,_threadCount:0};function Zd(e,t,n,r,a,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=_e(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=_e(0),this.hiddenUpdates=_e(null),this.identifierPrefix=r,this.onUncaughtError=a,this.onCaughtError=i,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=s,this.incompleteTransitions=new Map}function em(e,t,n,r,a,i,o,s,l,c,u,d){return e=new Zd(e,t,n,o,s,l,c,d),t=1,!0===i&&(t|=24),i=Fr(3,null,null,t),e.current=i,i.stateNode=e,(t=Oa()).refCount++,e.pooledCache=t,t.refCount++,i.memoizedState={element:r,isDehydrated:n,cache:t},oi(i),e}function tm(e){return e?e=Rr:Rr}function nm(e,t,n,r,a,i){a=tm(a),null===r.context?r.context=a:r.pendingContext=a,(r=li(t)).payload={element:n},null!==(i=void 0===i?null:i)&&(r.callback=i),null!==(n=ci(e,r,t))&&(Fc(n,0,t),ui(n,e,t))}function rm(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function am(e,t){rm(e,t),(e=e.alternate)&&rm(e,t)}function im(e){if(13===e.tag){var t=Ir(e,67108864);null!==t&&Fc(t,0,67108864),am(e,67108864)}}var om=!0;function sm(e,t,n,r){var a=R.T;R.T=null;var i=D.p;try{D.p=2,cm(e,t,n,r)}finally{D.p=i,R.T=a}}function lm(e,t,n,r){var a=R.T;R.T=null;var i=D.p;try{D.p=8,cm(e,t,n,r)}finally{D.p=i,R.T=a}}function cm(e,t,n,r){if(om){var a=um(r);if(null===a)Vu(e,t,r,dm,n),km(e,r);else if(function(e,t,n,r,a){switch(t){case"focusin":return fm=Sm(fm,e,t,n,r,a),!0;case"dragenter":return gm=Sm(gm,e,t,n,r,a),!0;case"mouseover":return bm=Sm(bm,e,t,n,r,a),!0;case"pointerover":var i=a.pointerId;return ym.set(i,Sm(ym.get(i)||null,e,t,n,r,a)),!0;case"gotpointercapture":return i=a.pointerId,vm.set(i,Sm(vm.get(i)||null,e,t,n,r,a)),!0}return!1}(a,e,t,n,r))r.stopPropagation();else if(km(e,r),4&t&&-1<wm.indexOf(e)){for(;null!==a;){var i=Ve(a);if(null!==i)switch(i.tag){case 3:if((i=i.stateNode).current.memoizedState.isDehydrated){var o=ke(i.pendingLanes);if(0!==o){var s=i;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var l=1<<31-be(o);s.entanglements[1]|=l,o&=~l}Nu(i),!(6&oc)&&(Nc=ie()+500,ju(0))}}break;case 13:null!==(s=Ir(i,2))&&Fc(s,0,2),Wc(),am(i,2)}if(null===(i=um(r))&&Vu(e,t,r,dm,n),i===a)break;a=i}null!==a&&r.stopPropagation()}else Vu(e,t,r,null,n)}}function um(e){return mm(e=It(e))}var dm=null;function mm(e){if(dm=null,null!==(e=We(e))){var t=i(e);if(null===t)e=null;else{var n=t.tag;if(13===n){if(null!==(e=o(t)))return e;e=null}else if(3===n){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return dm=e,null}function hm(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(oe()){case se:return 2;case le:return 8;case ce:case ue:return 32;case de:return 268435456;default:return 32}default:return 32}}var pm=!1,fm=null,gm=null,bm=null,ym=new Map,vm=new Map,xm=[],wm="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 km(e,t){switch(e){case"focusin":case"focusout":fm=null;break;case"dragenter":case"dragleave":gm=null;break;case"mouseover":case"mouseout":bm=null;break;case"pointerover":case"pointerout":ym.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":vm.delete(t.pointerId)}}function Sm(e,t,n,r,a,i){return null===e||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[a]},null!==t&&(null!==(t=Ve(t))&&im(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,null!==a&&-1===t.indexOf(a)&&t.push(a),e)}function Cm(e){var t=We(e.target);if(null!==t){var n=i(t);if(null!==n)if(13===(t=n.tag)){if(null!==(t=o(n)))return e.blockedOn=t,void function(e,t){var n=D.p;try{return D.p=e,t()}finally{D.p=n}}(e.priority,function(){if(13===n.tag){var e=Rc();e=Ae(e);var t=Ir(n,e);null!==t&&Fc(t,0,e),am(n,e)}})}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function Em(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=um(e.nativeEvent);if(null!==n)return null!==(t=Ve(n))&&im(t),e.blockedOn=n,!1;var r=new(n=e.nativeEvent).constructor(n.type,n);Mt=r,n.target.dispatchEvent(r),Mt=null,t.shift()}return!0}function Nm(e,t,n){Em(e)&&n.delete(t)}function jm(){pm=!1,null!==fm&&Em(fm)&&(fm=null),null!==gm&&Em(gm)&&(gm=null),null!==bm&&Em(bm)&&(bm=null),ym.forEach(Nm),vm.forEach(Nm)}function _m(t,n){t.blockedOn===n&&(t.blockedOn=null,pm||(pm=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,jm)))}var $m=null;function zm(t){$m!==t&&($m=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){$m===t&&($m=null);for(var e=0;e<t.length;e+=3){var n=t[e],r=t[e+1],a=t[e+2];if("function"!=typeof r){if(null===mm(r||n))continue;break}var i=Ve(n);null!==i&&(t.splice(e,3),e-=3,Io(i,{pending:!0,data:a,method:n.method,action:r},r,a))}}))}function Tm(e){function t(t){return _m(t,e)}null!==fm&&_m(fm,e),null!==gm&&_m(gm,e),null!==bm&&_m(bm,e),ym.forEach(t),vm.forEach(t);for(var n=0;n<xm.length;n++){var r=xm[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<xm.length&&null===(n=xm[0]).blockedOn;)Cm(n),null===n.blockedOn&&xm.shift();if(null!=(n=(e.ownerDocument||e).$$reactFormReplay))for(r=0;r<n.length;r+=3){var a=n[r],i=n[r+1],o=a[Oe]||null;if("function"==typeof i)o||zm(n);else if(o){var s=null;if(i&&i.hasAttribute("formAction")){if(a=i,o=i[Oe]||null)s=o.formAction;else if(null!==mm(a))continue}else s=o.action;"function"==typeof s?n[r+1]=s:(n.splice(r,3),r-=3),zm(n)}}}function Am(e){this._internalRoot=e}function Pm(e){this._internalRoot=e}Pm.prototype.render=Am.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(r(409));nm(t.current,Rc(),e,t,null,null)},Pm.prototype.unmount=Am.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;nm(e.current,2,null,e,null,null),Wc(),t[Re]=null}},Pm.prototype.unstable_scheduleHydration=function(e){if(e){var t=Me();e={blockedOn:null,target:e,priority:t};for(var n=0;n<xm.length&&0!==t&&t<xm[n].priority;n++);xm.splice(n,0,e),0===n&&Cm(e)}};var Mm=t.version;if("19.1.1"!==Mm)throw Error(r(527,Mm,"19.1.1"));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=i(e)))throw Error(r(188));return t!==e?null:e}for(var n=e,a=t;;){var o=n.return;if(null===o)break;var l=o.alternate;if(null===l){if(null!==(a=o.return)){n=a;continue}break}if(o.child===l.child){for(l=o.child;l;){if(l===n)return s(o),e;if(l===a)return s(o),t;l=l.sibling}throw Error(r(188))}if(n.return!==a.return)n=o,a=l;else{for(var c=!1,u=o.child;u;){if(u===n){c=!0,n=o,a=l;break}if(u===a){c=!0,a=o,n=l;break}u=u.sibling}if(!c){for(u=l.child;u;){if(u===n){c=!0,n=l,a=o;break}if(u===a){c=!0,a=l,n=o;break}u=u.sibling}if(!c)throw Error(r(189))}}if(n.alternate!==a)throw Error(r(190))}if(3!==n.tag)throw Error(r(188));return n.stateNode.current===n?e:t}(t),e=null===(e=null!==e?l(e):null)?null:e.stateNode};var Im={bundleType:0,version:"19.1.1",rendererPackageName:"react-dom",currentDispatcherRef:R,reconcilerVersion:"19.1.1"};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var Lm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Lm.isDisabled&&Lm.supportsFiber)try{pe=Lm.inject(Im),fe=Lm}catch(Rm){}}return f.createRoot=function(e,t){if(!a(e))throw Error(r(299));var n=!1,i="",o=ks,s=Ss,l=Cs;return null!=t&&(!0===t.unstable_strictMode&&(n=!0),void 0!==t.identifierPrefix&&(i=t.identifierPrefix),void 0!==t.onUncaughtError&&(o=t.onUncaughtError),void 0!==t.onCaughtError&&(s=t.onCaughtError),void 0!==t.onRecoverableError&&(l=t.onRecoverableError),void 0!==t.unstable_transitionCallbacks&&t.unstable_transitionCallbacks),t=em(e,1,!1,null,0,n,i,o,s,l,0,null),e[Re]=t.current,Hu(e),new Am(t)},f.hydrateRoot=function(e,t,n){if(!a(e))throw Error(r(299));var i=!1,o="",s=ks,l=Ss,c=Cs,u=null;return null!=n&&(!0===n.unstable_strictMode&&(i=!0),void 0!==n.identifierPrefix&&(o=n.identifierPrefix),void 0!==n.onUncaughtError&&(s=n.onUncaughtError),void 0!==n.onCaughtError&&(l=n.onCaughtError),void 0!==n.onRecoverableError&&(c=n.onRecoverableError),void 0!==n.unstable_transitionCallbacks&&n.unstable_transitionCallbacks,void 0!==n.formState&&(u=n.formState)),(t=em(e,1,!0,t,0,i,o,s,l,c,0,u)).context=tm(null),n=t.current,(o=li(i=Ae(i=Rc()))).callback=null,ci(n,o,i),n=i,t.current.lanes=n,$e(t,n),Nu(t),e[Re]=t.current,Hu(e),new Pm(t)},f.version="19.1.1",f}var j,_,$=(k||(k=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)}}(),p.exports=N()),p.exports),z={exports:{}},T={};var A=(_||(_=1,z.exports=function(){if(j)return T;j=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(t,n,r){var a=null;if(void 0!==r&&(a=""+r),void 0!==n.key&&(a=""+n.key),"key"in n)for(var i in r={},n)"key"!==i&&(r[i]=n[i]);else r=n;return n=r.ref,{$$typeof:e,type:t,key:a,ref:void 0!==n?n:null,props:r}}return T.Fragment=t,T.jsx=n,T.jsxs=n,T}()),z.exports);const P=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),n=this.shouldUseMobileStyles(e,1024)&&!t;e.classList.toggle("limbo-mobile-fallback",t),e.classList.toggle("limbo-tablet-fallback",n),e.classList.toggle("limbo-desktop-fallback",!t&&!n)}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 M(e={}){const{useContainerQuery:t=!1,containerElement:n=null}=e,[r,a]=u.useState(()=>{const e=t&&n?P.getContainerWidth(n):"undefined"!=typeof window?window.innerWidth:0,r="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:r,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:P.supportsContainerQueries}}});u.useEffect(()=>{if("undefined"==typeof window)return;const e=()=>{const e=window.innerWidth,r=window.innerHeight,i=t&&n?P.getContainerWidth(n):e,o=i<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),s="ontouchstart"in window||navigator.maxTouchPoints>0;a({isMobile:o,isTouch:s,isTablet:i>768&&i<=1024&&s,orientation:r>e?"portrait":"landscape",viewport:{width:e,height:r},container:{width:i,supportsContainerQueries:P.supportsContainerQueries}})};let r;const i=()=>{clearTimeout(r),r=setTimeout(e,150)};return window.addEventListener("resize",i),window.addEventListener("orientationchange",()=>{setTimeout(e,100)}),()=>{clearTimeout(r),window.removeEventListener("resize",i),window.removeEventListener("orientationchange",e)}},[t,n]);const i="portrait"===r.orientation,o="landscape"===r.orientation,s=r.isMobile||r.isTablet&&i;return{...r,isPortrait:i,isLandscape:o,isCompactMode:s,isMobileSize:r.viewport.width<=640,isTabletSize:r.viewport.width>640&&r.viewport.width<=1024,isDesktopSize:r.viewport.width>1024,deviceClass:r.isMobile?"mobile":r.isTablet?"tablet":"desktop"}}function I({tabs:e,active:t,onChange:n}){const{isMobile:r,isTouch:a}=M();return A.jsx("div",{className:"limbo-tabs "+(r?"limbo-tabs--mobile":""),role:"tablist","aria-label":"Opciones de navegación",style:{...r&&{overflowX:"auto",WebkitOverflowScrolling:"touch",scrollbarWidth:"none",msOverflowStyle:"none"}},children:e.map(i=>{const o=t===i.id;return!o&&i.hideNonActive?null:A.jsx("button",{"data-tab-id":i.id,onClick:()=>n(i.id),onKeyDown:t=>((t,r)=>{const a=e.findIndex(e=>e.id===r);let i=a;switch(t.key){case"ArrowLeft":case"ArrowUp":t.preventDefault(),i=a>0?a-1:e.length-1;break;case"ArrowRight":case"ArrowDown":t.preventDefault(),i=a<e.length-1?a+1:0;break;case"Home":t.preventDefault(),i=0;break;case"End":t.preventDefault(),i=e.length-1;break;case"Enter":case" ":return t.preventDefault(),void n(r);default:return}const o=e[i];o&&!o.hideNonActive&&(n(o.id),setTimeout(()=>{const e=document.querySelector(`[data-tab-id="${o.id}"]`);e&&e.focus()},0))})(t,i.id),className:`limbo-tab ${o?"active":""} ${r?"limbo-tab--mobile":""}`,role:"tab","aria-selected":o,"aria-controls":`tabpanel-${i.id}`,tabIndex:o?0:-1,id:`tab-${i.id}`,style:{...r&&{minWidth:"120px",minHeight:"44px",padding:"12px 16px",flexShrink:0,fontSize:"16px"},...a&&{touchAction:"manipulation",WebkitTapHighlightColor:"transparent"}},children:i.label},i.id)})})}const L="https://led-dev-limbo-dev.eu.els.local",O="https://limbo.lefebvre.com";let R={publicKey:null,token:null,authMode:null,tokenEndpoint:null,prod:!1};function D({prod:e=!1}={}){return e?O:L}async function F({endpoint:e,method:t="GET",body:n=null,prod:r=!1,basePath:a="",customHeaders:i={},isFormData:o=!1,useJWT:s=!0}){try{const l=r||R.prod,c=await async function({isFormData:e=!1,useJWT:t=!0,customHeaders:n={}}={}){const r={};e||(r["Content-Type"]="application/json");let a=R.token;if(t){if("session"===R.authMode&&!a)try{const e=D(R),t=R.tokenEndpoint||"/auth/token",n=await fetch(`${e}${t}`,{method:"POST",headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":"*"},body:JSON.stringify({public_key:R.publicKey}),credentials:"include"});if(!n.ok)throw new Error(`Session auth failed: ${n.status}`);a=(await n.json()).token,R.token=a}catch(i){throw console.error("❌ Session authentication failed:",i),new Error("Failed to authenticate with session. User must be logged in.")}a?r.Authorization=`Bearer ${a}`:console.warn("⚠️ No JWT token available:",{authMode:R.authMode,hasPublicKey:!!R.publicKey})}return e&&delete r["Content-Type"],{...r,...n}}({isFormData:o,useJWT:s,customHeaders:i});"GET"===t&&!n&&c["Content-Type"]&&delete c["Content-Type"];const u=await fetch(`${D({prod:l})}${a}${e}`,{method:t,headers:c,body:n?o?n:JSON.stringify(n):void 0,credentials:"include"});if(!u.ok){let e=`HTTP ${u.status}: ${u.statusText}`,t=null;try{const n=await u.json();t=n,n.error?e=`${n.error.code}: ${n.error.message}`:n.message&&(e=n.message)}catch{}throw 401===u.status&&t&&("token_expired"===t.error||t.message&&t.message.includes("expired")||t.message&&t.message.includes("caducado")||t.error&&t.error.includes("expired"))&&window.dispatchEvent(new CustomEvent("tokenExpiredError",{detail:{error:{response:{status:401,data:t}}}})),new Error(e)}return u.json()}catch(l){throw new Error(`API Error: ${l.message}`)}}function U(){const e={...R};return e?.prod||!1?"https://limbo.lefebvre.com":"http://localhost"}function q(e){if(!e?.id)return null;return`${U()}/api/assets/${e.id}/download`}function B(e){if(!e)return null;if(e.startsWith("http://")||e.startsWith("https://"))return e;if(e.startsWith("/")){return`${U()}${e}`}return e}function H(e){return Array.isArray(e)?e.map(e=>({id:e.id,name:e.name,width:e.width,height:e.height,format:e.output_format,file_size:e.file_size,crop_params:e.crop_params,url:B(e.url),expires_at:e.expires_at,created_at:e.created_at})):[]}function W(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 V="/api";async function K(e={}){try{const t=new URLSearchParams(e).toString(),n=t?`/assets?${t}`:"/assets";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&&(H(e.variants)||H(e.image_variants))||[],url:B(e.master_url||e.master?.url_signed||e.urls?.original||e.url)||q(e),webp_available:e.webp_available||!!e.webp_url,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 F({endpoint:n,method:"GET",basePath:V,useJWT:!0}))}catch(t){throw W(t)}}async function G(e,t=null,n=!1){try{const r=new FormData;r.append("file",e),t&&r.append("uploaded_by",t),n&&r.append("store_original",n.toString());return function(e){if(!e?.success||!e?.data)return{result:null};const t=e.data;return{result:{id:t.id,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:B(t.master?.url_signed),master_format:t.master?.format,processing:t.processing||{master_webp:"processing"===t.status?"queued":"completed",variants:"processing"===t.status?"queued":"completed"},checksum:t.checksum,storage_path:t.storage_path_base,metadata:t.metadata||{}}}}(await F({endpoint:"/assets",method:"POST",body:r,basePath:V,isFormData:!0,useJWT:!0}))}catch(r){throw W(r)}}async function Q(e){try{const n=await F({endpoint:`/assets/${e}/variants`,method:"GET",basePath:V,useJWT:!0});return t=n,t?.success&&Array.isArray(t?.data?.variants)?{result:t.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.output_format||e.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:B(e.master_url||e.master?.url_signed||e.urls?.original||e.url)||q(e),webp_available:e.webp_available||!!e.webp_url,metadata:e.metadata||{},crop_data:e.crop_data||{},crop_params:e.crop_params||e.crop_data||{},parent_asset_id:e.parent_asset_id||t.data.asset_id,variant_type:e.variant_type||"crop"}))}:{result:[]}}catch(n){throw W(n)}var t}function Y(){const[e,t]=u.useState({}),[n,r]=u.useState({}),[a,i]=u.useState({}),o=u.useCallback(async a=>{if(a&&!n[a]){if(e[a])return e[a];r(e=>({...e,[a]:!0})),i(e=>({...e,[a]:null}));try{const e=await Q(a),n=e?.result||[];return t(e=>({...e,[a]:n})),n}catch(o){return console.error("Error loading variants:",o),i(e=>({...e,[a]:o.message})),[]}finally{r(e=>({...e,[a]:!1}))}}},[e,n]),s=u.useCallback(t=>e[t]||[],[e]),l=u.useCallback(e=>n[e]||!1,[n]),c=u.useCallback(e=>a[e]||null,[a]),d=u.useCallback(e=>{t(t=>{const n={...t};return delete n[e],n}),r(t=>{const n={...t};return delete n[e],n}),i(t=>{const n={...t};return delete n[e],n})},[]),m=u.useCallback(async e=>(d(e),await o(e)),[d,o]),h=u.useCallback(async(e,n)=>{try{return await async function(e,t){try{return await F({endpoint:`/assets/${e}/variants/${t}`,method:"DELETE",basePath:V,useJWT:!0})}catch(n){throw W(n)}}(e,n),t(t=>{const r=t[e]||[];return{...t,[e]:r.filter(e=>e.id!==n)}}),{success:!0}}catch(r){return console.error("Error deleting variant:",r),{success:!1,error:r.message}}},[]);return{loadVariants:o,getVariants:s,isLoading:l,getError:c,clearVariants:d,refreshVariants:m,removeVariant:h}}function X({image:e,isOpen:t,onClose:n,onSelect:r,onDelete:a,onCrop:i,onVariantDeleted:o,allowedActions:s={select:!0,download:!0,copy:!0,delete:!0,crop:!0}}){const{loadVariants:l,getVariants:c,isLoading:m,getError:h,removeVariant:p}=Y(),f=window.limboCore?.accessibilityManager,[g,b]=d.useState(null),[y,v]=d.useState(null),x=(window.limboCore?.config?.getGlobal()||{}).interaction||{allowSelection:!1,allowCropping:!0},w=x.allowSelection&&s.select&&r,k=x.allowCropping&&s.crop&&i,S=s.copy,C=s.download,E=s.delete,[N,j]=d.useState(new Set),_=d.useMemo(()=>e?.variants||[],[e?.variants]),$=c(e?.id),z=_.length>0?_:$,T=0===_.length&&m(e?.id),P=0===_.length?h(e?.id):null;u.useEffect(()=>{!t||!e?.id||e?.variants&&0!==e.variants.length||l(e.id)},[t,e?.id,e?.variants,l]),d.useEffect(()=>{t&&j(new Set)},[t]);if(!t)return null;return A.jsx("div",{className:"limbo-modal-overlay",onClick:n,role:"dialog","aria-modal":"true","aria-labelledby":"variants-modal-title",children:A.jsxs("div",{className:"limbo-modal-content limbo-variants-modal",onClick:e=>e.stopPropagation(),children:[A.jsxs("div",{className:"limbo-modal-header",children:[A.jsxs("h2",{id:"variants-modal-title",children:["Recortes de ",e?.filename]}),A.jsx("button",{className:"limbo-modal-close",onClick:n,"aria-label":"Cerrar modal de recortes",children:"✕"})]}),g&&A.jsx("div",{className:`limbo-variants-message limbo-variants-message--${y} mt-1`,role:"alert",style:{padding:"12px 20px",margin:"0 20px 15px 20px",borderRadius:"4px",backgroundColor:"success"===y?"#d4edda":"#f8d7da",color:"success"===y?"#155724":"#721c24",border:"1px solid "+("success"===y?"#c3e6cb":"#f5c6cb")},children:g}),A.jsx("div",{className:"limbo-modal-body",children:T?A.jsxs("div",{className:"limbo-variants-loading",children:[A.jsx("div",{className:"limbo-loader"}),A.jsx("p",{children:"Cargando recortes..."})]}):P?A.jsxs("div",{className:"limbo-variants-error",children:[A.jsxs("p",{children:["Error al cargar recortes: ",P]}),A.jsx("button",{onClick:()=>l(e.id),className:"btn btn-primary",children:"Reintentar"})]}):0===z.length?A.jsxs("div",{className:"limbo-variants-empty",children:[A.jsx("p",{children:"Esta imagen no tiene recortes aún."}),A.jsx("small",{children:"Los recortes aparecerán aquí después de hacer recortes o redimensionados."})]}):A.jsxs(A.Fragment,{children:[A.jsxs("div",{className:"limbo-variant-section",children:[A.jsx("h3",{children:"Imagen original"}),A.jsxs("div",{onClick:()=>{f?.announce(`Abriendo imagen original ${e.filename} en nueva pestaña`),window.open(e.url,"_blank")},className:"limbo-variant-card limbo-variant-original cursor-pointer",children:[A.jsx("div",{className:"limbo-variant-preview",children:A.jsx("img",{src:e.url,alt:e.filename,loading:"lazy"})}),A.jsxs("div",{className:"limbo-variant-info",children:[A.jsx("div",{className:"limbo-variant-name",children:e.filename}),A.jsxs("div",{className:"limbo-variant-meta",children:[A.jsxs("span",{children:[e.width,"×",e.height]}),A.jsxs("span",{children:[Math.round(e.file_size/1024)," KB"]})]})]}),A.jsxs("div",{className:"limbo-variant-actions",children:[w&&A.jsx("button",{className:"btn btn-success btn-sm",onClick:t=>{t.stopPropagation(),r?.(e),n?.()},title:"Seleccionar original",children:"Seleccionar"}),k&&A.jsx("button",{className:"btn btn-crop btn-sm",onClick:t=>{t.stopPropagation(),i&&(f?.announce(`Abriendo herramienta de recorte para ${e.filename}`),i(e),n?.())},title:"Recortar imagen",children:A.jsx("span",{className:"icon icon-scissors-white icon--sm"})}),S&&A.jsx("button",{className:"btn btn-secondary btn-sm",onClick:t=>{t.stopPropagation(),(async()=>{try{await navigator.clipboard.writeText(e.url),f?.announce("URL de imagen original copiada")}catch(t){console.error("Error copying original URL:",t),f?.announceError("Error al copiar URL")}})()},title:"Copiar URL",children:A.jsx("span",{className:"icon icon-copy-white icon--sm"})}),C&&A.jsx("button",{className:"btn btn-primary btn-sm",onClick:t=>{t.stopPropagation(),(async()=>{const{downloadImage:t}=await Promise.resolve().then(()=>nn);await t(e.url||e.path,e.filename||"limbo-image",{originalFormat:e.format,accessibilityManager:f})})()},title:"Descargar",children:A.jsx("span",{className:"icon icon-download-white icon--sm"})}),E&&a&&A.jsx("button",{className:"btn btn-danger btn-sm",onClick:t=>{t.stopPropagation(),(async()=>{if(!a)return;window.confirm(`¿Estás seguro de que deseas eliminar "${e.filename}"? Esta acción también eliminará todos sus recortes.`)&&(f?.announce(`Eliminando imagen ${e.filename}`),await a(e.id),n?.())})()},title:"Eliminar imagen",children:A.jsx("span",{className:"icon icon-close-small-white icon--sm m-[0!important]"})})]})]})]}),A.jsxs("div",{className:"limbo-variant-section",children:[A.jsxs("h3",{children:["Recortes (",z.length,")"]}),A.jsx("div",{className:"limbo-variants-grid",children:z.map(t=>{const a=N.has(t.id);return A.jsxs("div",{className:"limbo-variant-card "+(a?"":"cursor-pointer"),onClick:a?void 0:()=>(e=>{f?.announce(`Abriendo recorte ${e.name} en nueva pestaña`),window.open(e.url,"_blank")})(t),children:[A.jsxs("div",{className:"limbo-variant-preview",children:[A.jsx("img",{src:t.url,alt:t.name||t.filename||`Variante ${t.id}`,loading:"eager",onError:()=>{return e=t.id,void j(t=>new Set([...t,e]));var e},style:{display:a?"none":"block"}}),a&&A.jsx("div",{className:"limbo-variant-error",style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100px",backgroundColor:"#f5f5f5",color:"#666"},children:A.jsx("span",{children:"Error al cargar preview"})})]}),A.jsxs("div",{className:"limbo-variant-info",children:[A.jsx("div",{className:"limbo-variant-name",children:t.name||t.filename||`Variante ${t.id}`}),A.jsxs("div",{className:"limbo-variant-meta",children:[A.jsxs("span",{children:[t.width,"×",t.height]}),A.jsx("span",{children:(t.format||"jpg").toUpperCase()}),A.jsxs("span",{children:[Math.round((t.file_size||0)/1024)," KB"]})]}),t.crop_params&&A.jsxs("div",{className:"limbo-variant-crop-badge",children:[A.jsx("span",{className:"icon icon-scissors icon--xs"})," ","Recortada"]})]}),A.jsxs("div",{className:"limbo-variant-actions",children:[w&&A.jsx("button",{className:"btn btn-success btn-sm",onClick:a=>{a.stopPropagation(),(t=>{const a={id:t.id,filename:`${e.filename}_${t.name}`,url:t.url,width:t.width,height:t.height,mime_type:`image/${t.format}`,file_size:t.file_size,upload_date:t.created_at,processing_status:"completed",is_variant:!0,parent_asset_id:e.id,variant_info:t};f?.announce(`Recorte seleccionado: ${t.name}`),r?.(a),n?.()})(t)},title:`Seleccionar variante ${t.name||t.filename||t.id}`,children:"Seleccionar"}),S&&A.jsx("button",{className:"btn btn-secondary btn-sm",onClick:e=>{e.stopPropagation(),(async e=>{try{await navigator.clipboard.writeText(e.url),f?.announce(`URL de recorte ${e.name} copiada`)}catch(t){console.error("Error copying variant URL:",t),f?.announceError("Error al copiar URL de recorte")}})(t)},title:"Copiar URL",children:A.jsx("span",{className:"icon icon-copy-white icon--sm"})}),C&&A.jsx("button",{className:"btn btn-primary btn-sm",onClick:e=>{e.stopPropagation(),(async e=>{const{downloadImage:t}=await Promise.resolve().then(()=>nn);await t(e.url,e.name||"limbo-variant",{originalFormat:e.format||e.output_format,accessibilityManager:f})})(t)},title:"Descargar",children:A.jsx("span",{className:"icon icon-download-white icon--sm"})}),E&&A.jsx("button",{className:"btn btn-danger btn-sm",onClick:n=>{n.stopPropagation(),(async t=>{if(window.confirm(`¿Estás seguro de que deseas eliminar el recorte "${t.name||t.filename}"?`)){f?.announce(`Eliminando recorte ${t.name||t.filename}`);const n=await p(e.id,t.id);n.success?(b("Recorte eliminado correctamente"),v("success"),f?.announce("Recorte eliminado correctamente"),o?.(),setTimeout(()=>{b(null),v(null)},3e3)):(b(`Error al eliminar recorte: ${n.error}`),v("error"),f?.announceError(`Error al eliminar recorte: ${n.error}`),setTimeout(()=>{b(null),v(null)},5e3))}})(t)},title:"Eliminar variante",children:A.jsx("span",{className:"icon icon-close-small-white icon--sm m-[0!important]"})})]})]},t.id)})})]})]})})]})})}function J({image:e,onDelete:t,onCrop:n,onSelect:r,thumbnailSize:a=32,isDeleting:i=!1,allowedActions:o={select:!0,download:!0,copy:!0,delete:!0,crop:!0,variants:!0}}){const[s,l]=u.useState(!1),[c,m]=u.useState(!1),[h,p]=u.useState(e.variants_count||0),{isMobile:f,isTouch:g}=M(),b=window.limboCore?.accessibilityManager,y=(window.limboCore?.config?.getGlobal()||{}).interaction||{allowSelection:!1,allowCropping:!0},v=n=>{n.stopPropagation(),b?.announce(`Eliminando imagen ${e.filename}`,"assertive"),t?.(e)},x=async t=>{t.stopPropagation();let n=e.url||e.path;try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(n);else{const e=document.createElement("textarea");e.value=n,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),document.body.removeChild(e)}l(!0),b?.announce(`URL de ${e.filename} copiada al portapapeles. Nota: La URL puede tener un tiempo de validez limitado.`),setTimeout(()=>l(!1),2e3)}catch(r){console.error("Error al copiar URL:",r),b?.announce(`Error al copiar URL de ${e.filename}. Inténtalo de nuevo.`),alert(`Error al copiar URL de ${e.filename}. Por favor, inténtalo de nuevo.`)}},w=async t=>{t.preventDefault(),t.stopPropagation();const{downloadImage:n}=await Promise.resolve().then(()=>nn);await n(e.url||e.path,e.filename||"limbo-image",{originalFormat:e.format,accessibilityManager:b})},k=t=>{t.stopPropagation(),b?.announce(`Editando imagen ${e.filename}`),n?.(e)},S=e.variants&&e.variants.length>0||h>0,C=h,E=d.useCallback(()=>{p(e=>Math.max(0,e-1))},[]);d.useEffect(()=>{p(e.variants_count||0)},[e.variants_count]);const N=t=>{t.stopPropagation(),b?.announce(`Mostrando recortes de ${e.filename}`),m(!0)},j=y.allowSelection&&o.select&&r,_=y.allowCropping&&o.crop&&n,$=S&&!1!==o.variants,z=()=>{window.open(e.url||e.path,"_blank")};return A.jsxs(A.Fragment,{children:[A.jsxs("div",{className:`limbo-image-card flex flex-col items-center cursor-pointer relative transition ${i?"opacity-50":""} ${f?"limbo-image-card--mobile":""}`,onClick:z,onKeyDown:e=>{switch(e.key){case"Enter":case" ":e.preventDefault(),z();break;case"d":case"D":o.download&&(e.preventDefault(),w(e));break;case"c":case"C":o.copy&&(e.preventDefault(),x(e));break;case"Delete":case"Backspace":o.delete&&t&&(e.preventDefault(),v(e));break;case"x":case"X":o.crop&&n&&(e.preventDefault(),k(e));break;case"v":case"V":o.variants&&(e.preventDefault(),N(e))}},title:f?"Toque para ver imagen":"Haga click en la imagen para ver preview en nueva pestaña",role:"button",tabIndex:0,"aria-label":`Imagen ${e.filename}. ${e.width}x${e.height} px`,style:{...g&&{touchAction:"manipulation",WebkitTapHighlightColor:"transparent"}},children:[A.jsxs("div",{className:"limbo-image-actions "+(f?"limbo-image-actions--mobile":""),children:[$&&A.jsxs("button",{type:"button",title:`Ver ${C} recorte${1!==C?"s":""}`,className:"btn btn-variants border border-brand-blue-050/50 "+(f?"btn--touch":""),onClick:N,tabIndex:-1,style:{...f&&{width:"40px",height:"40px"},position:"relative"},children:[A.jsx("span",{className:"icon icon-album-menu-white icon--sm","aria-hidden":"true"}),C>0&&A.jsx("span",{className:"variants-count-badge",style:{position:"absolute",top:"-8px",right:"-8px",background:"#dc2626",color:"white",borderRadius:"50%",minWidth:"20px",height:"20px",fontSize:"12px",fontWeight:"700",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:"1",border:"2px solid white",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.4)",zIndex:"999"},children:C})]}),j&&A.jsx("button",{type:"button",title:"Seleccionar imagen",className:"btn btn-success border border-brand-blue-050/50 "+(f?"btn--touch":""),onClick:t=>{t.stopPropagation(),b?.announce(`Seleccionando ${e.filename} para el portal`),r?.(e)},tabIndex:-1,style:{...f&&{width:"40px",height:"40px"}},children:A.jsx("span",{className:"icon icon-tick-white icon--sm","aria-hidden":"true"})}),_&&A.jsx("button",{type:"button",title:"Editar imagen",className:"btn btn-crop border border-brand-blue-050/50 "+(f?"btn--touch":""),onClick:k,tabIndex:-1,style:{...f&&{width:"40px",height:"40px"}},children:A.jsx("span",{className:"icon icon-scissors-white icon--sm","aria-hidden":"true"})}),o.copy&&A.jsx("button",{type:"button",title:s?"¡Copiado!":"Copiar URL",className:"btn btn-copy border border-brand-blue-050/50 "+(f?"btn--touch":""),onClick:x,tabIndex:-1,style:{...f&&{width:"40px",height:"40px"}},children:A.jsx("span",{className:`icon ${s?"icon-copied-white":"icon-copy-white"} icon--sm`,"aria-hidden":"true"})}),o.download&&A.jsx("button",{type:"button",title:"Descargar",className:"btn btn-download border border-brand-blue-050/50 "+(f?"btn--touch":""),onClick:w,tabIndex:-1,style:{...f&&{width:"40px",height:"40px"}},children:A.jsx("span",{className:"icon icon-download-white icon--sm","aria-hidden":"true"})}),o.delete&&t&&A.jsx("button",{onClick:v,disabled:i,className:"btn btn-delete border border-brand-blue-050/50 "+(f?"btn--touch":""),title:"Eliminar imagen",tabIndex:-1,style:{...f&&{width:"40px",height:"40px"}},children:i?"…":A.jsx("span",{className:"icon icon-close-small-white icon--sm","aria-hidden":"true"})})]}),A.jsx("img",{src:e.url||e.path,loading:"eager",alt:e.filename.split(".")[0]??e.filename,className:"w-full object-cover rounded aspect-square",sizes:`height: ${6*a}px,width: ${6*a}px`,draggable:!1,style:{...f&&{minHeight:`${Math.max(3*a,80)}px`,height:"auto",aspectRatio:"1 / 1",objectFit:"cover"}}}),A.jsx("span",{className:"text-xs mt-1 truncate w-full text-center limbo-image-card-name "+(f?"limbo-image-card-name--mobile":""),style:{...f&&{fontSize:"0.75rem",lineHeight:"1.2",maxWidth:"100%",padding:"2px 4px",backgroundColor:"rgba(255, 255, 255, 0.9)",borderRadius:"4px",color:"#333",fontWeight:"500"}},children:e.filename.split(".")[0]??e.filename})]}),A.jsx(X,{image:e,isOpen:c,onClose:()=>m(!1),onSelect:r,onDelete:t,onCrop:n,onVariantDeleted:E,allowedActions:{select:o.select,download:o.download,copy:o.copy,delete:o.delete,crop:o.crop}})]})}function Z(){return A.jsxs("div",{className:"limbo-image-card animate-pulse",role:"status","aria-label":"Cargando imagen...",children:[A.jsx("div",{className:"w-full aspect-square bg-neutral-gray-200 rounded-md flex items-center justify-center",children:A.jsx("svg",{className:"w-12 h-12 text-neutral-gray-300",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:A.jsx("path",{fillRule:"evenodd",d:"M4 3a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V5a2 2 0 00-2-2H4zm12 12H4l4-8 3 6 2-4 3 6z",clipRule:"evenodd"})})}),A.jsx("div",{className:"limbo-image-card-name opacity-100 position-relative bottom-0 p-2",children:A.jsx("div",{className:"h-4 bg-neutral-gray-200 rounded w-3/4"})}),A.jsx("span",{className:"limbo-sr-only",children:"Cargando imagen..."})]})}function ee({text:e="Cargando..."}){return A.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-gray-600",role:"status","aria-live":"polite","aria-label":e,children:[A.jsxs("svg",{className:"animate-spin h-6 w-6 mb-2 text-blue-500",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-hidden":"true",children:[A.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),A.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8H4z"})]}),A.jsx("p",{className:"text-sm",id:"loader-text",children:e})]})}function te({onSelect:e,onCrop:t,onDelete:n,deletingId:r,images:a,loading:i,error:o,filters:s={name:"",dateFrom:"",dateTo:"",uploadedBy:""},onFiltersChange:l,filterConfig:c={showNameFilter:!0,showUploadedByFilter:!1,showDateFilter:!0},loadingConfig:d={showPlaceholders:!0,placeholderCount:10,showSpinner:!0},allowedActions:m={select:!0,download:!0,copy:!0,delete:!0,crop:!0,variants:!0}}){const h=!1!==c.showNameFilter,p=!0===c.showUploadedByFilter,f=!1!==c.showDateFilter,g=u.useRef(null),b=window.limboCore?.accessibilityManager;u.useEffect(()=>{if(g.current&&window.limboCore?.keyboardManager){const e="gallery-grid";g.current.setAttribute("data-grid-id",e),window.limboCore.keyboardManager.setupGridNavigation(g.current,{itemSelector:".limbo-image-card",gridId:e,columns:"auto"})}},[a]),u.useEffect(()=>{i?b?.announceLoading(!0,"galería"):i||o?o&&b?.announceError(o,"galería"):(b?.announceLoading(!1,"galería"),a.length>0&&b?.announce(`Se encontraron ${a.length} imágenes en la galería`))},[i,o,a.length,b]);const y=e=>{const{name:t,value:n}=e.target;l&&l({...s,[t]:n})};return A.jsxs("div",{className:"w-full",children:[A.jsx("div",{className:"limbo-card mb-6 p-4 bg-brand-blue-050 shadow-md",children:A.jsxs("form",{className:"limbo-form-grid flex flex-col sm:flex-row flex-wrap gap-4 items-start sm:items-end justify-between",onSubmit:e=>e.preventDefault(),"aria-label":"Filtrar imágenes",children:[h&&A.jsxs("div",{className:"flex flex-col w-full sm:min-w-[180px] sm:flex-1",children:[A.jsx("label",{htmlFor:"name",className:"form-label mb-1",children:"Nombre"}),A.jsx("input",{type:"text",name:"name",id:"name",placeholder:"Buscar por nombre...",value:s.name,onChange:y,className:"form-control",autoComplete:"off"})]}),A.jsxs("div",{className:"flex flex-col sm:flex-row flex-wrap gap-2 justify-between items-start sm:items-end w-full sm:w-auto",children:[f&&A.jsxs(A.Fragment,{children:[A.jsxs("div",{className:"flex flex-col w-full sm:w-auto",children:[A.jsx("label",{htmlFor:"dateFrom",className:"form-label mb-1",children:"Desde"}),A.jsx("input",{type:"date",name:"dateFrom",id:"dateFrom",value:s.dateFrom,onChange:y,className:"form-control"})]}),A.jsxs("div",{className:"flex flex-col w-full sm:w-auto",children:[A.jsx("label",{htmlFor:"dateTo",className:"form-label mb-1",children:"Hasta"}),A.jsx("input",{type:"date",name:"dateTo",id:"dateTo",value:s.dateTo,onChange:y,className:"form-control"})]})]}),p&&A.jsxs("div",{className:"flex flex-col w-full sm:w-auto",children:[A.jsx("label",{htmlFor:"uploadedBy",className:"form-label mb-1",children:"Subido por"}),A.jsx("input",{type:"text",name:"uploadedBy",id:"uploadedBy",placeholder:"Subido por",value:s.uploadedBy,onChange:y,className:"form-control"})]})]})]})}),i?d.showPlaceholders?A.jsx("div",{ref:g,className:"limbo-gallery mt-4","data-limbo-responsive":!0,role:"grid","aria-label":"Cargando imágenes de la galería","aria-busy":"true",children:Array.from({length:d.placeholderCount}).map((e,t)=>A.jsx("div",{role:"gridcell","aria-posinset":t+1,"aria-setsize":d.placeholderCount,children:A.jsx(Z,{})},`skeleton-${t}`))}):d.showSpinner?A.jsx(ee,{text:"Cargando imágenes..."}):null:o?A.jsx("div",{className:"alert alert-danger text-center",children:o}):A.jsx("div",{ref:g,className:"limbo-gallery mt-4","data-limbo-responsive":!0,"data-grid-id":"gallery-grid",role:"grid","aria-label":"Galería de imágenes. Use las flechas para navegar entre imágenes",children:a.length>0?a.map((i,o)=>A.jsx("div",{role:"gridcell","aria-posinset":o+1,"aria-setsize":a.length,children:A.jsx(J,{image:i,onSelect:e,onCrop:t,onDelete:m.delete&&n?()=>n(i.id):null,thumbnailSize:32,isDeleting:r===i.id,allowedActions:m})},i.id)):A.jsx("div",{className:"col-span-full text-center text-gray-500 py-8",role:"status","aria-live":"polite",children:A.jsx("p",{children:"No se han encontrado imágenes"})})})]})}function ne({file:e,setFile:t,previewUrl:n,setPreviewUrl:r,fileInputRef:a,onUpload:i,disabled:o}){return A.jsxs("form",{onSubmit:n=>{n.preventDefault(),e&&!o&&(i(e),t(null),r(null),a.current&&(a.current.value=""))},className:"flex flex-col items-center gap-6","aria-label":"Subir imagen desde dispositivo",children:[A.jsxs("label",{htmlFor:"file-input",className:"w-full flex flex-col items-center justify-center border-2 border-dashed border-brand-blue-200 rounded-xl p-8 cursor-pointer hover:border-brand-blue-1000 hover:to-bright-blue-200 hover:from-brand-blue-050 focus-within:border-brand-blue-800 from-bright-blue-050 to-brand-blue-050 bg-linear-to-br transition",tabIndex:0,style:{outline:"none"},children:[A.jsx("span",{className:"icon icon-upload icon--lg mb-2","aria-hidden":"true"}),A.jsx("span",{className:"font-medium text-brand-blue-1000 mb-1",children:"Haz clic o arrastra una imagen aquí"}),A.jsx("span",{className:"text-sm text-neutral-700",children:"Formatos permitidos: JPG, PNG, GIF, SVG, WebP"}),A.jsx("input",{id:"file-input",ref:a,type:"file",accept:"image/jpeg,image/png,image/svg,image/webp,image/gif",onChange:e=>{const n=e.target.files[0];if(t(n),n){const e=URL.createObjectURL(n);r(e)}else r(null)},disabled:o,className:"sr-only","aria-label":"Seleccionar imagen"})]}),n&&A.jsxs("div",{className:"w-full flex flex-col items-center gap-2",children:[A.jsx("img",{src:n,alt:e?.name||"Previsualización",className:"rounded-lg shadow-md border border-brand-blue-200 max-h-64 object-contain bg-white",style:{maxWidth:"100%"}}),A.jsxs("div",{className:"text-sm text-neutral-800 bg-brand-blue-050 p-2 rounded w-full text-center",children:[A.jsxs("p",{children:[A.jsx("span",{className:"font-medium",children:"Archivo:"})," ",e?.name]}),A.jsxs("p",{children:[A.jsx("span",{className:"font-medium",children:"Tamaño:"})," ",e?(e.size/1024/1024).toFixed(2):"--"," MB"]}),A.jsxs("p",{children:[A.jsx("span",{className:"font-medium",children:"Tipo:"})," ",e?.type]})]})]}),A.jsx("button",{type:"submit",disabled:!e||o,title:e?"Subir imagen a la galeria":"Proporcione una imagen antes de continuar",className:"limbo-btn w-full mt-2 "+(e?"limbo-btn-primary":"cursor-not-allowed limbo-btn-disabled"),style:{minHeight:44},children:o?"Subiendo...":"Subir imagen"})]})}const re="/api";const ae=new Map;function ie(e=!1){const[t,n]=u.useState([]),[r,a]=u.useState(!0),[i,o]=u.useState(null);u.useEffect(()=>{const t=`ai-services-${e}`,r=ae.get(t),i=Date.now();if(r&&i-r.timestamp<864e5)return n(r.data),void a(!1);let s=!0;return(async()=>{try{const r=await function(e=!1){return F({endpoint:"/ai/services",prod:e,basePath:re})}(e);if(!s)return;const a=r?.data?.images||[];n(a),ae.set(t,{data:a,timestamp:i})}catch(r){s&&o(r.message)}finally{s&&a(!1)}})(),()=>{s=!1}},[e]);return{services:t,loading:r,error:i,invalidateCache:()=>{ae.delete(`ai-services-${e}`)}}}const oe=new Map;function se(e=!1){const[t,n]=u.useState(null),[r,a]=u.useState(!1),[i,o]=u.useState(null);return{params:t,loading:r,error:i,fetchParams:async t=>{a(!0),o(null);const r=`${e}-${t}`,i=Date.now(),s=oe.get(r);if(s&&i-s.timestamp<864e5)return n(s.data),a(!1),s.data;try{const a=await function({services:e=null,form:t=!1}={},n=!1){const r={};return e&&(r.services=e),!1!==t&&(r.form=t),F({endpoint:"/ai/params"+(Object.keys(r).length?"?"+new URLSearchParams(r).toString():""),method:"GET",prod:n,basePath:"/api/atenea"})}({services:t,form:!1},e),o=a?.result?.data||a?.data||a?.result||a;return n(o),oe.set(r,{data:o,timestamp:i}),o}catch(l){return o(l.message),n(null),null}finally{a(!1)}},reset:()=>{o(null),n(null)}}}function le({prod:e,disabled:t,onSelected:n,onGenerated:r}){const a=ie(e),i=se(e),[o,s]=u.useState(""),[l,c]=u.useState({}),[m,h]=u.useState(!1),[p,f]=u.useState(null),[g,b]=u.useState(null),y={"dall-e-2":"Dalle2","dall-e-3":"Dalle3","freepik-classic":"Freepik Classic","freepik-mystic":"Freepik Mystic","freepik-google":"Freepik Google","freepik-flux":"Freepik Flux",shutterstock:"Shutterstock",freepikstock:"Freepik"},v=e=>y[e]||e;d.useEffect(()=>{if(!a.loading&&1===a.services.length){const e=a.services[0];s(e),i.fetchParams(e,!0)}},[a.loading,a.services]);d.useEffect(()=>{if(!o)return;const e=i.params?.[o]?.parameters;if(e){const t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default??""]));t.service=o,c(t)}},[o,i.params]);const x=e=>{const{name:t,value:n}=e.target;c(e=>({...e,[t]:n}))},w=async t=>{t.preventDefault(),h(!0),f(null),b(null);try{const t=await function(e,t=!1){return F({endpoint:"/ai/generate",method:"POST",body:e,prod:t,basePath:re})}(l,e);let a=null;if(t?.data?.images&&Array.isArray(t.data.images)&&t.data.images.length>0?a=t.data.images[0]:t?.result?.images&&Array.isArray(t.result.images)&&t.result.images.length>0?a=t.result.images[0]:Array.isArray(t)&&t.length>0?a=t[0]:"string"==typeof t&&(a=t),!a||!r)throw new Error("No se pudo extraer la imagen de la respuesta");if(a.startsWith("http"))try{const e=await fetch(a);if(!e.ok)throw new Error(`Failed to download image: ${e.status}`);const t=await e.blob(),n=new File([t],"ai-image.png",{type:t.type||"image/png"});r(n)}catch(n){throw new Error(`Error downloading image: ${n.message}`)}else{const e=a.replace(/^data:image\/\w+;base64,/,""),t=atob(e),n=new Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);const i=new Uint8Array(n),o=new File([i],"ai-image.webp",{type:"image/webp"});r(o)}b(t?.data?.images||t?.result?.images||null)}catch(a){f(a.message||"Error al generar la imagen")}finally{h(!1)}};return a.loading?A.jsxs("div",{className:"flex items-center justify-center py-8",children:[A.jsx("span",{className:"limbo-loader mr-2"})," Cargando servicios IA..."]}):a.services.length?A.jsxs("div",{className:"flex flex-col gap-4",children:[A.jsx("h3",{id:"aiSelectDescription",className:"text-lg font-semibold text-brand-blue-1000",children:1===a.services.length?`Generación con ${v(o)}`:"Selecciona el modelo IA"}),a.services.length>1&&A.jsxs("select",{name:"aiService","aria-describedby":"aiSelectDescription",title:"Selecciona el servicio IA",value:o,onChange:async e=>{const t=e.target.value;s(t),c({}),b(null),t&&await i.fetchParams(t,!0)},disabled:a.loading||t,className:"limbo-input",children:[A.jsx("option",{value:"",children:"-- Selecciona --"}),a.services.map(e=>A.jsx("option",{value:e,children:v(e)},e))]}),a.error&&A.jsx("div",{className:"alert alert-danger",children:a.error}),i.loading&&A.jsx("div",{children:"Cargando parámetros..."}),i.error&&A.jsx("div",{className:"alert alert-danger",children:i.error}),o&&(()=>{const e=i.params?.[o]?.parameters;if(!e)return null;const n=Object.entries(e).filter(([e,t])=>!t.disabled),r=n.length>3;return A.jsxs("form",{onSubmit:w,"data-type":"ai",className:"flex flex-col gap-3 mt-4 border-t-1 pt-4 border-brand-blue-200","aria-label":"Formulario generación IA",children:[A.jsx("div",{className:r?"grid grid-cols-1 md:grid-cols-2 gap-3":"flex flex-col gap-3",children:n.map(([e,n])=>{let r=n.placeholder||"";return r||(r="integer"===n.type?n.minValue&&n.maxValue?`Entre ${n.minValue} y ${n.maxValue}`:n.minValue?`Mínimo ${n.minValue}`:n.maxValue?`Máximo ${n.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 ${(n.label||e).toLowerCase()}`),A.jsxs("div",{className:"flex flex-col gap-1",children:[A.jsxs("label",{htmlFor:`ai-${e}`,className:"text-xs font-medium text-brand-blue-900",children:[n.label||e,n.required&&A.jsx("span",{className:"text-red-600 ml-1",children:"*"})]}),n.options?A.jsx("select",{id:`ai-${e}`,name:e,value:l[e]??"",onChange:x,className:"limbo-input",disabled:t,title:n.label||e,children:n.options.map(e=>A.jsx("option",{value:e,children:e},e))}):A.jsx("input",{id:`ai-${e}`,type:"integer"===n.type?"number":"text",name:e,value:l[e]??"",onChange:x,className:"limbo-input",disabled:t,required:n.required,min:n.minValue,max:n.maxValue,placeholder:r,title:n.label||e})]},e)})}),A.jsx("button",{type:"submit",disabled:m||t,title:m?"Generando imagen...":"Generar imagen",className:"limbo-btn w-full mt-2 "+(m?"cursor-not-allowed limbo-btn-disabled":"limbo-btn-primary"),style:{minHeight:44},children:m?"Generando...":"Generar imagen"})]})})(),p&&A.jsx("div",{className:"alert alert-danger",children:p}),g&&g.map((e,t)=>A.jsxs("div",{className:"mt-6 text-center",children:[A.jsx("img",{src:e.contains("http")?e:`data:image/png;base64, ${e}`,alt:"Imagen generada con IA",className:"rounded-lg shadow-md border border-brand-blue-200 max-h-72 mx-auto"}),A.jsx("button",{className:"limbo-btn limbo-btn-primary mt-4",children:"Aceptar y subir"})]},"img-"+t))]}):A.jsx("div",{className:"alert alert-warning",children:"No hay servicios IA disponibles."})}const ce="/api";const ue=new Map;function de(e=!1){const[t,n]=u.useState([]),[r,a]=u.useState(!0),[i,o]=u.useState(null);u.useEffect(()=>{const t=`stock-services-${e}`,r=ue.get(t),i=Date.now();if(r&&i-r.timestamp<864e5)return n(r.data),void a(!1);let s=!0;return(async()=>{try{const r=await function(e=!1){return F({endpoint:"/stock/services",prod:e,basePath:ce})}(e);if(!s)return;const a=r?.data?.images||[];n(a),ue.set(t,{data:a,timestamp:i})}catch(r){s&&o(r.message)}finally{s&&a(!1)}})(),()=>{s=!1}},[e]);return{services:t,loading:r,error:i,invalidateCache:()=>{ue.delete(`stock-services-${e}`)}}}function me({prod:e,disabled:t,onSelected:n}){const r=d.useRef(null),a=de(e),i=(e,t)=>{try{const n=sessionStorage.getItem(`limbo_stock_${e}`);return n?JSON.parse(n):t}catch{return t}},[o,s]=u.useState(()=>i("selectedService","")),[l,c]=u.useState(()=>i("dynamicForm",{})),[m,h]=u.useState(()=>i("stockImages",[])),[p,f]=u.useState(()=>i("currentPage",1)),[g,b]=u.useState(()=>i("paginationInfo",null)),y=se(e),[v,x]=u.useState(!1),[w,k]=u.useState(null),[S,C]=u.useState(null);d.useEffect(()=>{sessionStorage.setItem("limbo_stock_selectedService",JSON.stringify(o))},[o]),d.useEffect(()=>{sessionStorage.setItem("limbo_stock_dynamicForm",JSON.stringify(l))},[l]),d.useEffect(()=>{sessionStorage.setItem("limbo_stock_stockImages",JSON.stringify(m))},[m]),d.useEffect(()=>{sessionStorage.setItem("limbo_stock_currentPage",JSON.stringify(p))},[p]),d.useEffect(()=>{sessionStorage.setItem("limbo_stock_paginationInfo",JSON.stringify(g))},[g]);const E={shutterstock:"Shutterstock",freepikstock:"Freepik"},N=e=>E[e]||e;d.useEffect(()=>{if(!a.loading&&1===a.services.length){const e=a.services[0];s(e),y.fetchParams(e,!0)}},[a.loading,a.services]);d.useEffect(()=>{if(!o)return;const e=y.params?.[o]?.parameters;if(e){const t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default??""]));t.service=o,c(t)}},[o,y.params]);const j=e=>{const{name:t,value:n}=e.target;c(e=>({...e,[t]:n}))},_=async(t=1)=>{x(!0),k(null),1===t&&h([]);try{let n;if(1===t){const e=y.params?.[o]?.parameters,a={...l};Object.entries(e||{}).forEach(([e,t])=>{e in a||(a[e]=t.default??"")}),a.per_page=parseInt(a.per_page),a.service=o,a.page=t,n=a,r.current={...a}}else n={...r.current,page:t};const a=await function(e,t=!1){return F({endpoint:"/stock/search",method:"POST",body:e,prod:t,basePath:ce})}(n,e),i=a?.data?.images||[];let s=a?.data?.pagination||null,c=null;s&&(c={total:s.total_count??s.total??i.length,per_page:s.per_page??(Array.isArray(i)?i.length:0),current_page:s.page??s.current_page??t}),h($(Array.isArray(i)?i:[])),b(c),f(c?.current_page||t)}catch(n){k(n.message||"Error al buscar imágenes")}finally{x(!1)}},$=e=>{const t=new Set,n=[];return(e||[]).forEach((e,r)=>{const a=e.url||e.preview_url||e.full||e.preview;a&&!t.has(a)&&(t.add(a),n.push({...e,preview:e.preview_url||e.preview||e.url||e.full,full:e.url||e.full||e.preview_url,id:e.id||r,title:e.title||e.filename||`Imagen ${r+1}`,source:e.service||o,sourceTitle:E?.[o]||o}))}),n},z=async e=>{e.preventDefault();(l.query||l.search||l.term||"").trim().length<5?k("La búsqueda debe tener al menos 5 caracteres"):await _(1)},T=e=>{e<1||_(e)},P=async t=>{C(t.id),k(null);try{const r={service:o,image_id:t.id},a=await function(e,t=!1){return F({endpoint:"/stock/download",method:"POST",body:e,prod:t,basePath:ce})}(r,e);if(!a?.result?.url&&!a?.result?.download_url)throw new Error("No se pudo obtener la URL de descarga");{const e=a.result.url||a.result.download_url,r=await fetch(e),i=await r.blob(),o=a.result.filename||`stock-${t.id}.jpg`,s=new File([i],o,{type:i.type||"image/jpeg"});n&&n(s)}}catch(r){k(r.message||"No se pudo recuperar la imagen seleccionada")}finally{C(null)}};return a.loading?A.jsxs("div",{className:"flex items-center justify-center py-8",children:[A.jsx("span",{className:"limbo-loader mr-2"})," Cargando servicios de Stock..."]}):a.services.length?A.jsxs("div",{className:"flex flex-col gap-4",children:[A.jsx("h3",{className:"text-lg font-semibold text-brand-blue-1000",children:1===a.services.length?`Búsqueda en ${N(o)}`:"Selecciona el servicio de Stock"}),a.services.length>1&&A.jsxs("select",{value:o,onChange:async e=>{const t=e.target.value;s(t),c({}),h([]),f(1),t&&await y.fetchParams(t,!0)},disabled:a.loading||t,className:"limbo-input",children:[A.jsx("option",{value:"",children:"-- Selecciona --"}),a.services.map(e=>A.jsx("option",{value:e,children:N(e)},e))]}),a.error&&A.jsx("div",{className:"alert alert-danger",children:a.error}),y.loading&&A.jsx("div",{children:"Cargando parámetros..."}),y.error&&A.jsx("div",{className:"alert alert-danger",children:y.error}),o&&(()=>{const e=y.params?.[o]?.parameters;if(!e)return null;const n=Object.entries(e).filter(([,e])=>!e.disabled),r=n.length>3;return A.jsxs("form",{onSubmit:z,"data-type":"stock",className:"flex flex-col gap-3 mt-4 border-t-1 pt-4 border-brand-blue-200","aria-label":"Formulario búsqueda de imágenes de Stock",children:[A.jsx("div",{className:r?"grid grid-cols-1 md:grid-cols-2 gap-3":"flex flex-col gap-3",children:n.map(([e,n])=>{let r=n.placeholder||"";return r||(r="integer"===n.type?n.minValue&&n.maxValue?`Entre ${n.minValue} y ${n.maxValue}`:n.minValue?`Mínimo ${n.minValue}`:n.maxValue?`Máximo ${n.maxValue}`:"Introduce un número":e.toLowerCase().includes("query")||e.toLowerCase().includes("search")||e.toLowerCase().includes("term")?"Buscar imágenes...":`Introduce ${(n.label||e).toLowerCase()}`),A.jsxs("div",{className:"flex flex-col gap-1",children:[A.jsxs("label",{htmlFor:`stock-${e}`,className:"text-xs font-medium text-brand-blue-900",children:[n.label||e,n.required&&A.jsx("span",{className:"text-red-600 ml-1",children:"*"})]}),n.options&&n.multiple?A.jsx("div",{className:"flex flex-wrap gap-2 min-h-[50px] px-2 justify-between border-2 border-gray-transparent-500 rounded-lg",children:n.options.map(n=>A.jsxs("label",{className:"flex items-center gap-1",children:[A.jsx("input",{type:"checkbox",name:`stock-${e}`,value:n,checked:Array.isArray(l[e])&&l[e].includes(n),onChange:()=>((e,t)=>{c(n=>{const r=Array.isArray(n[e])?n[e]:[];return r.includes(t)?{...n,[e]:r.filter(e=>e!==t)}:{...n,[e]:[...r,t]}})})(e,n),disabled:t}),A.jsx("span",{className:"text-xs",children:n})]},n))}):n.options?A.jsx("select",{id:`stock-${e}`,name:e,value:l[e]??"",onChange:j,className:"limbo-input",disabled:t,title:n.label||e,children:n.options.map(e=>A.jsx("option",{value:e,children:e},e))}):A.jsx("input",{id:`stock-${e}`,type:"integer"===n.type?"number":"text",name:e,value:l[e]??"",onChange:j,className:"limbo-input",disabled:t,required:n.required,min:n.minValue,max:n.maxValue,placeholder:r,title:n.label||e})]},e)})}),A.jsx("button",{type:"submit",disabled:v||t,className:"limbo-btn w-full mt-2 "+(v?"cursor-not-allowed limbo-btn-disabled":"limbo-btn-primary"),style:{minHeight:44},children:v?"Buscando...":"Buscar imágenes"})]})})(),w&&A.jsx("div",{className:"alert alert-danger",children:w}),m.length>0&&A.jsxs(A.Fragment,{children:[A.jsxs("div",{className:"mt-6 grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 relative","aria-live":"polite",children:[v&&A.jsx("div",{className:"absolute inset-0 bg-white/80 z-10 flex items-center justify-center rounded-lg",children:A.jsxs("div",{className:"flex flex-col items-center gap-2",children:[A.jsx("span",{className:"limbo-loader"}),A.jsx("span",{className:"text-sm text-brand-blue-800",children:"Buscando imágenes..."})]})}),m.map((e,n)=>A.jsxs("div",{className:"border border-brand-blue-200 rounded-lg overflow-hidden bg-white shadow-sm hover:shadow-md transition-shadow",children:[A.jsxs("div",{className:"relative aspect-video bg-neutral-100",children:[A.jsx("img",{src:e.preview||e.thumbnail||e.url,alt:e.title||`Resultado ${n+1}`,className:"object-cover w-full h-full",loading:"lazy"}),e.id&&A.jsxs("span",{className:"absolute bottom-1 right-1 bg-black/60 text-white text-xs px-2 py-1 rounded",children:["ID: ",e.id]})]}),A.jsx("div",{className:"p-2",children:A.jsx("button",{className:"limbo-btn w-full text-sm "+(S===e.id?"limbo-btn-disabled cursor-not-allowed":"limbo-btn-primary"),onClick:()=>P(e),disabled:v||t||S===e.id,children:S===e.id?A.jsxs(A.Fragment,{children:[A.jsx("span",{className:"limbo-loader limbo-loader--sm mr-1"}),"Descargando..."]}):"Seleccionar"})})]},e.id||n))]}),g&&A.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2",children:[A.jsxs("button",{onClick:()=>T(g.current_page-1),disabled:g.current_page<=1||v,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(g.current_page<=1||v?" pointer-events-none cursor-default":" limbo-btn-primary"),children:[A.jsx("span",{className:"icon icon-arrow-left-white icon--sm"})," ","Anterior"]}),A.jsxs("span",{className:"px-4 py-2 text-sm text-neutral-700",children:["Página ",g.current_page," de"," ",Math.max(1,Math.ceil(g.total/g.per_page)),A.jsxs("span",{className:"text-xs text-neutral-500 block",children:["(",g.total," imágenes totales)"]})]}),A.jsxs("button",{onClick:()=>T(g.current_page+1),disabled:v||g.current_page>=Math.ceil(g.total/g.per_page),className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(v||g.current_page>=Math.ceil(g.total/g.per_page)?" pointer-events-none cursor-default":" limbo-btn-primary"),children:["Siguiente"," ",A.jsx("span",{className:"icon icon-arrow-right-white icon--sm"})]})]})]}),!v&&0===m.length&&o&&l.query&&A.jsxs("div",{className:"mt-6 text-center text-neutral-600 py-8 bg-neutral-50 rounded-lg",children:[A.jsx("span",{className:"icon icon-search icon--lg mb-2"}),A.jsxs("p",{children:['No se encontraron imágenes para "',l.query,'"']}),A.jsx("p",{className:"text-sm mt-1",children:"Intenta con otros términos de búsqueda"})]})]}):A.jsx("div",{className:"alert alert-warning",children:"No hay servicios de Stock disponibles."})}const he="/api";const pe=new Map;function fe(e=!1){const[t,n]=u.useState([]),[r,a]=u.useState(!0),[i,o]=u.useState(null);u.useEffect(()=>{const t=`portal-sources-${e}`,r=pe.get(t),i=Date.now();if(r&&i-r.timestamp<864e5)return n(r.data),void a(!1);let s=!0;return(async()=>{try{const r=await function(e=!1){return F({endpoint:"/external/sources",prod:e,basePath:he})}(e);if(!s)return;const a=r?.data?.sources||{},o=Object.entries(a).map(([e,t])=>({id:e,...t}));n(o),pe.set(t,{data:o,timestamp:i})}catch(r){s&&o(r.message)}finally{s&&a(!1)}})(),()=>{s=!1}},[e]);return{sources:t,loading:r,error:i,invalidateCache:()=>{pe.delete(`portal-sources-${e}`)}}}const ge=({src:e,alt:t,className:n,onError:r})=>{const[a,i]=d.useState("loading");return"error"===a?null:A.jsx("img",{src:e,alt:t,className:n,loading:"lazy",onLoad:()=>{i("loaded")},onError:()=>{i("error"),r&&r()}})};function be({prod:e,disabled:t,onSelected:n}){const r=d.useRef(null),a=fe(e),i=(e,t)=>{try{const n=sessionStorage.getItem(`limbo_portals_${e}`);return n?JSON.parse(n):t}catch{return t}},[o,s]=u.useState(()=>i("selectedPortals",[])),[l,c]=u.useState(()=>i("searchName","")),[m,h]=u.useState(()=>i("limit",20)),[p,f]=u.useState(()=>i("currentPage",1)),[g,b]=u.useState(!1),[y,v]=u.useState(null),[x,w]=u.useState(()=>i("images",[])),[k,S]=u.useState(()=>i("portalResults",{})),[C,E]=u.useState(()=>i("paginationInfo",null)),[N,j]=u.useState(null),_=u.useRef({}),[$,z]=u.useState(new Set);d.useEffect(()=>{sessionStorage.setItem("limbo_portals_selectedPortals",JSON.stringify(o))},[o]),d.useEffect(()=>{sessionStorage.setItem("limbo_portals_searchName",JSON.stringify(l))},[l]),d.useEffect(()=>{sessionStorage.setItem("limbo_portals_limit",JSON.stringify(m))},[m]),d.useEffect(()=>{sessionStorage.setItem("limbo_portals_currentPage",JSON.stringify(p))},[p]),d.useEffect(()=>{sessionStorage.setItem("limbo_portals_images",JSON.stringify(x))},[x]),d.useEffect(()=>{sessionStorage.setItem("limbo_portals_portalResults",JSON.stringify(k))},[k]),d.useEffect(()=>{sessionStorage.setItem("limbo_portals_paginationInfo",JSON.stringify(C))},[C]);const T=async(t=1)=>{if(0===o.length)return void v("Selecciona al menos un portal");const n=((e,t,n,r)=>`${e.sort().join(",")}_${t}_${n}_${r}`)(o,l.trim(),m,t),a=_.current[n];if(a)return w(a.images),S(a.portalResults),E(a.paginationInfo),f(t),void v(null);b(!0),v(null),1===t&&(w([]),S({}),E(null));try{let a;1===t?(a={sources:o,limit:m,page:t,name:l.trim()},r.current={...a}):a={...r.current,page:t};const i=await function(e,t=!1){return F({endpoint:"/external/search",method:"POST",body:e,prod:t,basePath:he})}(a,e),s=i?.data?.sources||{},c=[],u={},d=new Set;let h=null;Object.entries(s).forEach(([e,t])=>{u[e]={title:t.meta?.title||e,status:200,response:"OK",count:t.images?.length||0},Array.isArray(t.images)&&(t.images.forEach(n=>{const r=n.url||n.thumbnail;r&&!d.has(r)&&(d.add(r),c.push({...n,source:e,sourceTitle:t.meta?.title||e,preview:n.thumbnail||n.url,full:n.url}))}),!h&&t.pagination&&(h=t.pagination))}),_.current[n]={images:c,portalResults:u,paginationInfo:h},w(c),S(u),E(h),f(t),z(new Set),0!==c.length||i?.result?.success||v(i?.result?.message||"No se encontraron imágenes")}catch(i){v(i.message||"Error al buscar imágenes en portales")}finally{b(!1)}},P=e=>{e<1||T(e)};return a.loading?A.jsxs("div",{className:"flex items-center justify-center py-8",children:[A.jsx("span",{className:"limbo-loader mr-2"})," Cargando portales disponibles..."]}):a.sources.length?A.jsxs("div",{className:"flex flex-col gap-4",children:[A.jsx("h3",{className:"text-lg font-semibold text-brand-blue-1000",children:"Buscar en Portales Externos"}),A.jsxs("form",{onSubmit:e=>{e.preventDefault(),T(1)},className:"flex flex-col gap-4 border-t-1 pt-4 border-brand-blue-200",children:[A.jsxs("div",{className:"flex flex-col gap-2",children:[A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsxs("label",{className:"text-sm font-medium text-brand-blue-1000",children:["Portales (",o.length," seleccionados)"]}),A.jsx("button",{type:"button",onClick:()=>{o.length===a.sources.length?s([]):s(a.sources.map(e=>e.id))},className:"text-xs text-brand-blue-800 hover:underline",children:o.length===a.sources.length?"Deseleccionar todos":"Seleccionar todos"})]}),A.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2",children:a.sources.map(e=>A.jsxs("label",{className:"flex items-center gap-2 p-2 border border-brand-blue-200 rounded cursor-pointer hover:bg-brand-blue-050 transition",children:[A.jsx("input",{type:"checkbox",checked:o.includes(e.id),onChange:()=>{return t=e.id,void s(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]);var t},disabled:t,className:"w-4 h-4"}),A.jsx("span",{className:"text-sm",children:e.title})]},e.id))})]}),A.jsxs("div",{className:"flex flex-col gap-1",children:[A.jsx("label",{htmlFor:"portal-search-name",className:"text-sm font-medium text-brand-blue-1000",children:"Buscar por nombre (opcional)"}),A.jsx("input",{id:"portal-search-name",type:"text",value:l,onChange:e=>c(e.target.value),className:"limbo-input",placeholder:"Deja vacío para ver todas las imágenes",disabled:t})]}),A.jsxs("div",{className:"flex flex-col gap-1",children:[A.jsx("label",{htmlFor:"portal-limit",className:"text-sm font-medium text-brand-blue-1000",children:"Imágenes por página"}),A.jsxs("select",{id:"portal-limit",value:m,onChange:e=>h(Number(e.target.value)),className:"limbo-input",disabled:t,children:[A.jsx("option",{value:10,children:"10"}),A.jsx("option",{value:20,children:"20"}),A.jsx("option",{value:50,children:"50"}),A.jsx("option",{value:100,children:"100"})]})]}),A.jsx("button",{type:"submit",disabled:g||t||0===o.length,className:"limbo-btn w-full "+(g||0===o.length?"cursor-not-allowed limbo-btn-disabled":"limbo-btn-primary"),style:{minHeight:44},children:g?"Buscando...":"Buscar imágenes"})]}),a.error&&A.jsx("div",{className:"alert alert-danger",children:a.error}),y&&A.jsx("div",{className:"alert alert-danger",children:y}),Object.keys(k).length>0&&A.jsxs("div",{className:"bg-neutral-50 rounded-lg p-3",children:[A.jsx("h4",{className:"text-sm font-semibold mb-2",children:"Resultados por portal:"}),A.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2 text-sm",children:Object.entries(k).map(([e,t])=>A.jsxs("div",{className:"flex items-center justify-between p-2 rounded "+(200===t.status?"bg-green-50":"bg-red-50"),children:[A.jsx("span",{className:"font-medium",children:t.title}),A.jsx("span",{className:200===t.status?"text-green-700":"text-red-700",children:200===t.status?`${t.count} imágenes`:t.response})]},e))})]}),(x.length>0||g)&&A.jsxs(A.Fragment,{children:[A.jsxs("div",{className:"mt-6 relative","aria-live":"polite",children:[g&&A.jsx("div",{className:"absolute inset-0 bg-white/80 z-10 flex items-center justify-center rounded-lg",children:A.jsxs("div",{className:"flex flex-col items-center gap-2",children:[A.jsx("span",{className:"limbo-loader"}),A.jsx("span",{className:"text-sm text-brand-blue-800",children:"Buscando imágenes..."})]})}),A.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 "+(g?"opacity-50":""),children:x.map((r,a)=>{const i=`${r.source}-${r.id||a}`,o=r.preview||r.thumbnail||r.url||r.full;return $.has(i)?null:A.jsxs("div",{className:"border border-brand-blue-200 rounded-lg overflow-hidden bg-white shadow-sm hover:shadow-md transition-shadow",children:[A.jsxs("div",{className:"relative aspect-video bg-neutral-100",children:[A.jsx(ge,{src:o,alt:r.title||r.filename||`Imagen ${a+1}`,className:"object-cover w-full h-full",onError:()=>{z(e=>{const t=new Set(e);return t.add(i),t})}}),A.jsx("span",{className:"absolute top-1 left-1 bg-black/60 text-white text-xs px-2 py-1 rounded",children:r.sourceTitle}),r.id&&A.jsxs("span",{className:"absolute bottom-1 right-1 bg-black/60 text-white text-xs px-2 py-1 rounded",children:["ID: ",r.id]})]}),A.jsxs("div",{className:"p-2",children:[r.title&&A.jsx("p",{className:"text-xs text-neutral-700 mb-1 truncate",title:r.title,children:r.title}),A.jsx("button",{className:"limbo-btn w-full text-sm "+(N===(r.url||r.full)?"limbo-btn-disabled cursor-not-allowed":"limbo-btn-primary"),onClick:()=>(async t=>{j(t.url||t.full),v(null);try{const r=t.full||t.url||t.preview;if(!r)throw new Error("No se encontró URL de la imagen");const a=`${D({prod:e})}/api/atenea/proxy?url=${encodeURIComponent(r)}`,i=await fetch(a);if(!i.ok)throw new Error(`Error al descargar: ${i.status}`);const o=await i.blob(),s=t.filename||t.title||`portal-${t.id||Date.now()}.jpg`,l=new File([o],s,{type:o.type||"image/jpeg"});n&&n(l)}catch(r){v(r.message||"No se pudo recuperar la imagen del portal")}finally{j(null)}})(r),disabled:g||t||N===(r.url||r.full),children:N===(r.url||r.full)?A.jsxs(A.Fragment,{children:[A.jsx("span",{className:"limbo-loader limbo-loader--sm mr-1"}),"Descargando..."]}):"Seleccionar"})]})]},i)})})]}),A.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2",children:[A.jsxs("button",{onClick:()=>P(p-1),disabled:1===p||g,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(1===p||g?" pointer-events-none cursor-default":" limbo-btn-primary"),children:[A.jsx("span",{className:"icon icon-arrow-left-white icon--sm"})," ","Anterior"]}),A.jsxs("span",{className:"px-4 py-2 text-sm text-neutral-700",children:["Página ",p,C&&A.jsxs(A.Fragment,{children:[" ","de ",C.pages,A.jsxs("span",{className:"text-xs text-neutral-500 block",children:["(",C.total," imágenes totales)"]})]})]}),A.jsxs("button",{onClick:()=>P(p+1),disabled:g||C&&p>=C.pages,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(g||C&&p>=C.pages?" pointer-events-none cursor-default":" limbo-btn-primary"),children:["Siguiente"," ",A.jsx("span",{className:"icon icon-arrow-right-white icon--sm"})]})]})]}),!g&&0===x.length&&Object.keys(k).length>0&&A.jsxs("div",{className:"mt-6 text-center text-neutral-600 py-8 bg-neutral-50 rounded-lg",children:[A.jsx("span",{className:"icon icon-search icon--lg mb-2"}),A.jsx("p",{children:"No se encontraron imágenes en los portales seleccionados"}),l&&A.jsx("p",{className:"text-sm mt-1",children:"Intenta con otros términos o sin filtro de nombre"})]})]}):A.jsx("div",{className:"alert alert-warning",children:"No hay portales externos disponibles."})}const ye=[{id:"upload",label:"Subir archivo"},{id:"ai",label:"Generar con IA"},{id:"stock",label:"Buscar en Stock"},{id:"portals",label:"Otros portales"}];function ve({onUpload:e,disabled:t=!1,apiKey:n,prod:r=!1}){const[a,i]=u.useState("upload"),[o,s]=u.useState(null),[l,c]=u.useState(null),d=u.useRef();return A.jsxs("div",{className:"limbo-upload-form p-4 border-2 border-gray-200/50 rounded-lg min-w-fit max-w-5xl mx-auto",children:[A.jsx("div",{className:"limbo-tabs-container",children:A.jsx("div",{className:"limbo-tabs mb-6 min-w-fit",role:"tablist","aria-label":"Opciones de subida de imagen",children:ye.map(e=>A.jsx("button",{type:"button","data-upload-tab-id":e.id,className:"text-nowrap limbo-tab"+(a===e.id?" active":""),"aria-current":a===e.id?"page":void 0,"aria-selected":a===e.id,role:"tab",tabIndex:a===e.id?0:-1,onClick:()=>i(e.id),onKeyDown:t=>((e,t)=>{const n=ye.findIndex(e=>e.id===t);let r=n;switch(e.key){case"ArrowLeft":e.preventDefault(),r=n>0?n-1:ye.length-1;break;case"ArrowRight":e.preventDefault(),r=n<ye.length-1?n+1:0;break;case"Home":e.preventDefault(),r=0;break;case"End":e.preventDefault(),r=ye.length-1;break;case"Enter":case" ":return e.preventDefault(),void i(t);default:return}const a=ye[r];a&&(i(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}`,children:e.label},e.id))})}),A.jsxs("div",{className:"limbo-tab-content",role:"tabpanel",id:`upload-tabpanel-${a}`,"aria-labelledby":`upload-tab-${a}`,children:["upload"===a&&A.jsx(ne,{file:o,setFile:s,previewUrl:l,setPreviewUrl:c,fileInputRef:d,onUpload:e,disabled:t}),"ai"===a&&A.jsx(le,{apiKey:n,prod:r,disabled:t,onGenerated:e=>{i("upload"),s(e),c(URL.createObjectURL(e))}}),"stock"===a&&A.jsx(me,{apiKey:n,prod:r,disabled:t,onSelected:e=>{i("upload"),s(e),c(URL.createObjectURL(e))}}),"portals"===a&&A.jsx(be,{apiKey:n,prod:r,disabled:t,onSelected:e=>{i("upload"),s(e),c(URL.createObjectURL(e))}})]})]})}const xe="undefined"!=typeof window&&void 0!==window.document,we=xe?window:{},ke=!!xe&&"ontouchstart"in we.document.documentElement,Se=!!xe&&"PointerEvent"in we,Ce="cropper",Ee=`${Ce}-canvas`,Ne=`${Ce}-crosshair`,je=`${Ce}-grid`,_e=`${Ce}-handle`,$e=`${Ce}-image`,ze=`${Ce}-selection`,Te=`${Ce}-shade`,Ae=`${Ce}-viewer`,Pe="select",Me="move",Ie="scale",Le="rotate",Oe="transform",Re="none",De="n-resize",Fe="e-resize",Ue="s-resize",qe="w-resize",Be="ne-resize",He="nw-resize",We="se-resize",Ve="sw-resize",Ke=Se?"pointerdown":ke?"touchstart":"mousedown",Ge=Se?"pointermove":ke?"touchmove":"mousemove",Qe=Se?"pointerup pointercancel":ke?"touchend touchcancel":"mouseup",Ye="error",Xe="keydown",Je="load",Ze="wheel",et="action",tt="actionend",nt="actionstart",rt="change",at="transform";const it=Number.isNaN||we.isNaN;function ot(e){return"number"==typeof e&&!it(e)}function st(e){return ot(e)&&e>0&&e<1/0}function lt(e){return"object"==typeof e&&null!==e}const{hasOwnProperty:ct}=Object.prototype;function ut(e){if(!lt(e))return!1;try{const{constructor:t}=e,{prototype:n}=t;return t&&n&&ct.call(n,"isPrototypeOf")}catch(t){return!1}}function dt(e){return"function"==typeof e}function mt(e){return"object"==typeof e&&null!==e&&1===e.nodeType}const ht=/([a-z\d])([A-Z])/g;function pt(e){return String(e).replace(ht,"$1-$2").toLowerCase()}const ft=/-[A-z\d]/g;function gt(e){return e.replace(ft,e=>e.slice(1).toUpperCase())}const bt=/\s\s*/;function yt(e,t,n,r){t.trim().split(bt).forEach(t=>{e.removeEventListener(t,n,r)})}function vt(e,t,n,r){t.trim().split(bt).forEach(t=>{e.addEventListener(t,n,r)})}function xt(e,t,n,r){vt(e,t,n,Object.assign(Object.assign({},r),{once:!0}))}const wt={bubbles:!0,cancelable:!0,composed:!0};const kt=Promise.resolve();function St(e){const{documentElement:t}=e.ownerDocument,n=e.getBoundingClientRect();return{left:n.left+(we.pageXOffset-t.clientLeft),top:n.top+(we.pageYOffset-t.clientTop)}}const Ct=/deg|g?rad|turn$/i;function Et(e){const t=parseFloat(e)||0;if(0!==t){const[n="rad"]=String(e).match(Ct)||[];switch(n.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 Nt="contain";function jt(e,t=Nt){const{aspectRatio:n}=e;let{width:r,height:a}=e;const i=st(r),o=st(a);if(i&&o){const e=a*n;t===Nt&&e>r||"cover"===t&&e<r?a=r/n:r=a*n}else i?a=r/n:o&&(r=a*n);return{width:r,height:a}}function _t(e,...t){if(0===t.length)return e;const[n,r,a,i,o,s]=e,[l,c,u,d,m,h]=t[0];return _t(e=[n*l+a*c,r*l+i*c,n*u+a*d,r*u+i*d,n*m+a*h+o,r*m+i*h+s],...t.slice(1))}const $t=/left|top|width|height/i,zt="open",Tt=new WeakMap,At=new WeakMap,Pt=new Map,Mt=we.document&&Array.isArray(we.document.adoptedStyleSheets)&&"replaceSync"in we.CSSStyleSheet.prototype;class It extends HTMLElement{get $sharedStyle(){return(this.themeColor?`:host{--theme-color: ${this.themeColor};}`:"")+":host([hidden]){display:none!important}"}constructor(){var e,t;super(),this.shadowRootMode=zt,this.slottable=!0;const n=null===(t=null===(e=Object.getPrototypeOf(this))||void 0===e?void 0:e.constructor)||void 0===t?void 0:t.$name;n&&Pt.set(n,this.tagName.toLowerCase())}static get observedAttributes(){return["shadow-root-mode","slottable","theme-color"]}attributeChangedCallback(e,t,n){if(Object.is(n,t))return;const r=gt(e);let a=n;switch(typeof this[r]){case"boolean":a=null!==n&&"false"!==n;break;case"number":a=Number(n)}switch(this[r]=a,e){case"theme-color":{const e=At.get(this),t=this.$sharedStyle;e&&t&&(Mt?e.replaceSync(t):e.textContent=t);break}}}$propertyChangedCallback(e,t,n){if(!Object.is(n,t))switch(e=pt(e),typeof n){case"boolean":!0===n?this.hasAttribute(e)||this.setAttribute(e,""):this.removeAttribute(e);break;case"number":n=it(n)?"":String(n);default:n?this.getAttribute(e)!==n&&this.setAttribute(e,n):this.removeAttribute(e)}}connectedCallback(){Object.getPrototypeOf(this).constructor.observedAttributes.forEach(e=>{const t=gt(e);let n=this[t];(function(e){return void 0===e})(n)||this.$propertyChangedCallback(t,void 0,n),Object.defineProperty(this,t,{enumerable:!0,configurable:!0,get:()=>n,set(e){const r=n;n=e,this.$propertyChangedCallback(t,r,e)}})});const e=this.attachShadow({mode:this.shadowRootMode||zt});if(this.shadowRoot||Tt.set(this,e),At.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(){At.has(this)&&At.delete(this),Tt.has(this)&&Tt.delete(this)}$getTagNameOf(e){var t;return null!==(t=Pt.get(e))&&void 0!==t?t:e}$setStyles(e){return Object.keys(e).forEach(t=>{let n=e[t];ot(n)&&(n=0!==n&&$t.test(t)?`${n}px`:String(n)),this.style[t]=n}),this}$getShadowRoot(){return this.shadowRoot||Tt.get(this)}$addStyles(e){let t;const n=this.$getShadowRoot();return Mt?(t=new CSSStyleSheet,t.replaceSync(e),n.adoptedStyleSheets=n.adoptedStyleSheets.concat(t)):(t=document.createElement("style"),t.textContent=e,n.appendChild(t)),t}$emit(e,t,n){return function(e,t,n,r){return e.dispatchEvent(new CustomEvent(t,Object.assign(Object.assign(Object.assign({},wt),{detail:n}),r)))}(this,e,t,n)}$nextTick(e){return function(e,t){return t?kt.then(e?t.bind(e):t):kt}(this,e)}static $define(e,t){lt(e)&&(t=e,e=""),e||(e=this.$name||this.name),e=pt(e),xe&&we.customElements&&!we.customElements.get(e)&&customElements.define(e,this,t)}}It.$version="2.0.0";class Lt extends It{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=Re,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,n){if(!Object.is(n,t)&&(super.$propertyChangedCallback(e,t,n),"disabled"===e))n?this.$unbind():this.$bind()}$bind(){this.$onPointerDown||(this.$onPointerDown=this.$handlePointerDown.bind(this),vt(this,Ke,this.$onPointerDown)),this.$onPointerMove||(this.$onPointerMove=this.$handlePointerMove.bind(this),vt(this.ownerDocument,Ge,this.$onPointerMove)),this.$onPointerUp||(this.$onPointerUp=this.$handlePointerUp.bind(this),vt(this.ownerDocument,Qe,this.$onPointerUp)),this.$onWheel||(this.$onWheel=this.$handleWheel.bind(this),vt(this,Ze,this.$onWheel,{passive:!1,capture:!0}))}$unbind(){this.$onPointerDown&&(yt(this,Ke,this.$onPointerDown),this.$onPointerDown=null),this.$onPointerMove&&(yt(this.ownerDocument,Ge,this.$onPointerMove),this.$onPointerMove=null),this.$onPointerUp&&(yt(this.ownerDocument,Qe,this.$onPointerUp),this.$onPointerUp=null),this.$onWheel&&(yt(this,Ze,this.$onWheel,{capture:!0}),this.$onWheel=null)}$handlePointerDown(e){const{buttons:t,button:n,type:r}=e;if(this.disabled||("pointerdown"===r&&"mouse"===e.pointerType||"mousedown"===r)&&(ot(t)&&1!==t||ot(n)&&0!==n||e.ctrlKey))return;const{$pointers:a}=this;let i="";if(e.changedTouches)Array.from(e.changedTouches).forEach(({identifier:e,pageX:t,pageY:n})=>{a.set(e,{startX:t,startY:n,endX:t,endY:n})});else{const{pointerId:t=0,pageX:n,pageY:r}=e;a.set(t,{startX:n,startY:r,endX:n,endY:r})}a.size>1?i=Oe:mt(e.target)&&(i=e.target.action||e.target.getAttribute("action")||""),!1!==this.$emit(nt,{action:i,relatedEvent:e})&&(e.preventDefault(),this.$action=i,this.style.willChange="transform")}$handlePointerMove(e){const{$action:t,$pointers:n}=this;if(this.disabled||t===Re||0===n.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:r})=>{const a=n.get(e);a&&Object.assign(a,{endX:t,endY:r})});else{const{pointerId:t=0,pageX:r,pageY:a}=e,i=n.get(t);i&&Object.assign(i,{endX:r,endY:a})}const r={action:t,relatedEvent:e};if(t===Oe){const t=new Map(n);let a=0,i=0,o=0,s=0,l=e.pageX,c=e.pageY;n.forEach((e,n)=>{t.delete(n),t.forEach(t=>{let n=t.startX-e.startX,r=t.startY-e.startY,u=t.endX-e.endX,d=t.endY-e.endY,m=0,h=0,p=0,f=0;if(0===n?r<0?p=2*Math.PI:r>0&&(p=Math.PI):n>0?p=Math.PI/2+Math.atan(r/n):n<0&&(p=1.5*Math.PI+Math.atan(r/n)),0===u?d<0?f=2*Math.PI:d>0&&(f=Math.PI):u>0?f=Math.PI/2+Math.atan(d/u):u<0&&(f=1.5*Math.PI+Math.atan(d/u)),f>0||p>0){const n=f-p,r=Math.abs(n);r>a&&(a=r,o=n,l=(e.startX+t.startX)/2,c=(e.startY+t.startY)/2)}if(n=Math.abs(n),r=Math.abs(r),u=Math.abs(u),d=Math.abs(d),n>0&&r>0?m=Math.sqrt(n*n+r*r):n>0?m=n:r>0&&(m=r),u>0&&d>0?h=Math.sqrt(u*u+d*d):u>0?h=u:d>0&&(h=d),m>0&&h>0){const n=(h-m)/m,r=Math.abs(n);r>i&&(i=r,s=n,l=(e.startX+t.startX)/2,c=(e.startY+t.startY)/2)}})});const u=a>0,d=i>0;u&&d?(r.rotate=o,r.scale=s,r.centerX=l,r.centerY=c):u?(r.action=Le,r.rotate=o,r.centerX=l,r.centerY=c):d?(r.action=Ie,r.scale=s,r.centerX=l,r.centerY=c):r.action=Re}else{const[e]=Array.from(n.values());Object.assign(r,e)}n.forEach(e=>{e.startX=e.endX,e.startY=e.endY}),r.action!==Re&&this.$emit(et,r,{cancelable:!1})}$handlePointerUp(e){const{$action:t,$pointers:n}=this;if(!this.disabled&&t!==Re&&!1!==this.$emit(tt,{action:t,relatedEvent:e})){if(e.preventDefault(),e.changedTouches)Array.from(e.changedTouches).forEach(({identifier:e})=>{n.delete(e)});else{const{pointerId:t=0}=e;n.delete(t)}0===n.size&&(this.style.willChange="",this.$action=Re)}}$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(et,{action:Ie,scale:t,relatedEvent:e},{cancelable:!1})}$setAction(e){return"string"==typeof e&&(this.$action=e),this}$toCanvas(e){return new Promise((t,n)=>{if(!this.isConnected)return void n(new Error("The current element is not connected to the DOM."));const r=document.createElement("canvas");let a=this.offsetWidth,i=this.offsetHeight,o=1;ut(e)&&(st(e.width)||st(e.height))&&(({width:a,height:i}=jt({aspectRatio:a/i,width:e.width,height:e.height})),o=a/this.offsetWidth),r.width=a,r.height=i;const s=this.querySelector(this.$getTagNameOf($e));s?s.$ready().then(n=>{const l=r.getContext("2d");if(l){const[t,c,u,d,m,h]=s.$getTransform();let p=m,f=h,g=n.naturalWidth,b=n.naturalHeight;1!==o&&(p*=o,f*=o,g*=o,b*=o);const y=g/2,v=b/2;l.fillStyle="transparent",l.fillRect(0,0,a,i),ut(e)&&dt(e.beforeDraw)&&e.beforeDraw.call(this,l,r),l.save(),l.translate(y,v),l.transform(t,c,u,d,p,f),l.translate(-y,-v),l.drawImage(n,0,0,g,b),l.restore()}t(r)}).catch(n):t(r)})}}Lt.$name=Ee,Lt.$version="2.0.0";const Ot=new WeakMap,Rt=["alt","crossorigin","decoding","importance","loading","referrerpolicy","sizes","src","srcset"];class Dt extends It{constructor(){super(...arguments),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}set $canvas(e){Ot.set(this,e)}get $canvas(){return Ot.get(this)}static get observedAttributes(){return super.observedAttributes.concat(Rt,["initial-center-size","rotatable","scalable","skewable","translatable"])}attributeChangedCallback(e,t,n){Object.is(n,t)||(super.attributeChangedCallback(e,t,n),Rt.includes(e)&&this.$image.setAttribute(e,n))}$propertyChangedCallback(e,t,n){if(!Object.is(n,t)&&(super.$propertyChangedCallback(e,t,n),"initialCenterSize"===e))this.$nextTick(()=>{this.$center(n)})}connectedCallback(){super.connectedCallback();const{$image:e}=this,t=this.closest(this.$getTagNameOf(Ee));t&&(this.$canvas=t,this.$setStyles({display:"block",position:"absolute"}),this.$onCanvasActionStart=e=>{var t,n;this.$actionStartTarget=null===(n=null===(t=e.detail)||void 0===t?void 0:t.relatedEvent)||void 0===n?void 0:n.target},this.$onCanvasActionEnd=()=>{this.$actionStartTarget=null},this.$onCanvasAction=this.$handleAction.bind(this),vt(t,nt,this.$onCanvasActionStart),vt(t,tt,this.$onCanvasActionEnd),vt(t,et,this.$onCanvasAction)),this.$onLoad=this.$handleLoad.bind(this),vt(e,Je,this.$onLoad),this.$getShadowRoot().appendChild(e)}disconnectedCallback(){const{$image:e,$canvas:t}=this;t&&(this.$onCanvasActionStart&&(yt(t,nt,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(yt(t,tt,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(yt(t,et,this.$onCanvasAction),this.$onCanvasAction=null)),e&&this.$onLoad&&(yt(e,Je,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)}$handleAction(e){if(this.hidden||!(this.rotatable||this.scalable||this.translatable))return;const{$canvas:t}=this,{detail:n}=e;if(n){const{relatedEvent:e}=n;let{action:r}=n;switch(r!==Oe||this.rotatable&&this.scalable||(r=this.rotatable?Le:this.scalable?Ie:Re),r){case Me:if(this.translatable){let r=null;e&&(r=e.target.closest(this.$getTagNameOf(ze))),r||(r=t.querySelector(this.$getTagNameOf(ze))),r&&r.multiple&&!r.active&&(r=t.querySelector(`${this.$getTagNameOf(ze)}[active]`)),r&&!r.hidden&&r.movable&&!r.dynamic&&this.$actionStartTarget&&r.contains(this.$actionStartTarget)||this.$move(n.endX-n.startX,n.endY-n.startY)}break;case Le:if(this.rotatable)if(e){const{x:t,y:r}=this.getBoundingClientRect();this.$rotate(n.rotate,e.clientX-t,e.clientY-r)}else this.$rotate(n.rotate);break;case Ie:if(this.scalable)if(e){const t=e.target.closest(this.$getTagNameOf(ze));if(!t||!t.zoomable||t.zoomable&&t.dynamic){const{x:t,y:r}=this.getBoundingClientRect();this.$zoom(n.scale,e.clientX-t,e.clientY-r)}}else this.$zoom(n.scale);break;case Oe:if(this.rotatable&&this.scalable){const{rotate:t}=n;let{scale:r}=n;r<0?r=1/(1-r):r+=1;const a=Math.cos(t),i=Math.sin(t),[o,s,l,c]=[a*r,i*r,-i*r,a*r];if(e){const t=this.getBoundingClientRect(),n=e.clientX-t.x,r=e.clientY-t.y,[a,i,u,d]=this.$matrix,m=n-t.width/2,h=r-t.height/2,p=(m*d-u*h)/(a*d-u*i),f=(h*a-i*m)/(a*d-u*i);this.$transform(o,s,l,c,p*(1-o)+f*l,f*(1-c)+p*s)}else this.$transform(o,s,l,c,0,0)}}}}$ready(e){const{$image:t}=this,n=new Promise((e,n)=>{const r=new Error("Failed to load the image source");if(t.complete)t.naturalWidth>0&&t.naturalHeight>0?e(t):n(r);else{const a=()=>{yt(t,Ye,i),e(t)},i=()=>{yt(t,Je,a),n(r)};xt(t,Je,a),xt(t,Ye,i)}});return dt(e)&&n.then(t=>(e(t),t)),n}$center(e){const{parentElement:t}=this;if(!t)return this;const n=t.getBoundingClientRect(),r=n.width,a=n.height,{x:i,y:o,width:s,height:l}=this.getBoundingClientRect(),c=i+s/2,u=o+l/2,d=n.x+r/2,m=n.y+a/2;if(this.$move(d-c,m-u),e&&(s!==r||l!==a)){const t=r/s,n=a/l;switch(e){case"cover":this.$scale(Math.max(t,n));break;case"contain":this.$scale(Math.min(t,n))}}return this}$move(e,t=e){if(this.translatable&&ot(e)&&ot(t)){const[n,r,a,i]=this.$matrix,o=(e*i-a*t)/(n*i-a*r),s=(t*n-r*e)/(n*i-a*r);this.$translate(o,s)}return this}$moveTo(e,t=e){if(this.translatable&&ot(e)&&ot(t)){const[n,r,a,i]=this.$matrix,o=(e*i-a*t)/(n*i-a*r),s=(t*n-r*e)/(n*i-a*r);this.$setTransform(n,r,a,i,o,s)}return this}$rotate(e,t,n){if(this.rotatable){const r=Et(e),a=Math.cos(r),i=Math.sin(r),[o,s,l,c]=[a,i,-i,a];if(ot(t)&&ot(n)){const[e,r,a,i]=this.$matrix,{width:u,height:d}=this.getBoundingClientRect(),m=t-u/2,h=n-d/2,p=(m*i-a*h)/(e*i-a*r),f=(h*e-r*m)/(e*i-a*r);this.$transform(o,s,l,c,p*(1-o)-f*l,f*(1-c)-p*s)}else this.$transform(o,s,l,c,0,0)}return this}$zoom(e,t,n){if(!this.scalable||0===e)return this;if(e<0?e=1/(1-e):e+=1,ot(t)&&ot(n)){const[r,a,i,o]=this.$matrix,{width:s,height:l}=this.getBoundingClientRect(),c=t-s/2,u=n-l/2,d=(c*o-i*u)/(r*o-i*a),m=(u*r-a*c)/(r*o-i*a);this.$transform(e,0,0,e,d*(1-e),m*(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 n=Et(e),r=Et(t);this.$transform(1,Math.tan(r),Math.tan(n),1,0,0)}return this}$translate(e,t=e){return this.translatable&&ot(e)&&ot(t)&&this.$transform(1,0,0,1,e,t),this}$transform(e,t,n,r,a,i){return ot(e)&&ot(t)&&ot(n)&&ot(r)&&ot(a)&&ot(i)?this.$setTransform(_t(this.$matrix,[e,t,n,r,a,i])):this}$setTransform(e,t,n,r,a,i){if((this.rotatable||this.scalable||this.skewable||this.translatable)&&(Array.isArray(e)&&([e,t,n,r,a,i]=e),ot(e)&&ot(t)&&ot(n)&&ot(r)&&ot(a)&&ot(i))){const o=[...this.$matrix],s=[e,t,n,r,a,i];if(!1===this.$emit(at,{matrix:s,oldMatrix:o}))return this;this.$matrix=s,this.style.transform=`matrix(${s.join(", ")})`}return this}$getTransform(){return this.$matrix.slice()}$resetTransform(){return this.$setTransform([1,0,0,1,0,0])}}Dt.$name=$e,Dt.$version="2.0.0";const Ft=new WeakMap;class Ut extends It{constructor(){super(...arguments),this.$onCanvasChange=null,this.$onCanvasActionEnd=null,this.$onCanvasActionStart=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){Ft.set(this,e)}get $canvas(){return Ft.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["height","width","x","y"])}connectedCallback(){super.connectedCallback();const e=this.closest(this.$getTagNameOf(Ee));if(e){this.$canvas=e,this.style.position="absolute";const t=e.querySelector(this.$getTagNameOf(ze));t&&(this.$onCanvasActionStart=e=>{t.hidden&&e.detail.action===Pe&&(this.hidden=!1)},this.$onCanvasActionEnd=e=>{t.hidden&&e.detail.action===Pe&&(this.hidden=!0)},this.$onCanvasChange=e=>{const{x:n,y:r,width:a,height:i}=e.detail;this.$change(n,r,a,i),(t.hidden||0===n&&0===r&&0===a&&0===i)&&(this.hidden=!0)},vt(e,nt,this.$onCanvasActionStart),vt(e,tt,this.$onCanvasActionEnd),vt(e,rt,this.$onCanvasChange))}this.$render()}disconnectedCallback(){const{$canvas:e}=this;e&&(this.$onCanvasActionStart&&(yt(e,nt,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(yt(e,tt,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasChange&&(yt(e,rt,this.$onCanvasChange),this.$onCanvasChange=null)),super.disconnectedCallback()}$change(e,t,n=this.width,r=this.height){return ot(e)&&ot(t)&&ot(n)&&ot(r)&&(e!==this.x||t!==this.y||n!==this.width||r!==this.height)?(this.hidden&&(this.hidden=!1),this.x=e,this.y=t,this.width=n,this.height=r,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:we.innerWidth})}}Ut.$name=Te,Ut.$version="2.0.0";class qt extends It{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=Re,this.plain=!1,this.slottable=!1,this.themeColor="rgba(51, 153, 255, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["action","plain"])}}qt.$name=_e,qt.$version="2.0.0";const Bt=new WeakMap;class Ht extends It{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){Bt.set(this,e)}get $canvas(){return Bt.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,n){if(!Object.is(n,t))switch(super.$propertyChangedCallback(e,t,n),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(()=>{st(n)&&n<=1&&this.$initSelection(!0,!0)});break;case"keyboard":this.$nextTick(()=>{this.$canvas&&(n?this.$onDocumentKeyDown||(this.$onDocumentKeyDown=this.$handleKeyDown.bind(this),vt(this.ownerDocument,Xe,this.$onDocumentKeyDown)):this.$onDocumentKeyDown&&(yt(this.ownerDocument,Xe,this.$onDocumentKeyDown),this.$onDocumentKeyDown=null))});break;case"multiple":this.$nextTick(()=>{if(this.$canvas){const e=this.$getSelections();n?(e.forEach(e=>{e.active=!1}),this.active=!0,this.$emit(rt,{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":n&&(this.dynamic=!0)}}connectedCallback(){super.connectedCallback();const e=this.closest(this.$getTagNameOf(Ee));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),vt(e,nt,this.$onCanvasActionStart),vt(e,tt,this.$onCanvasActionEnd),vt(e,et,this.$onCanvasAction)):this.$render()}disconnectedCallback(){const{$canvas:e}=this;e&&(this.$onCanvasActionStart&&(yt(e,nt,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(yt(e,tt,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(yt(e,et,this.$onCanvasAction),this.$onCanvasAction=null)),super.disconnectedCallback()}$getSelections(){let e=[];return this.parentElement&&(e=Array.from(this.parentElement.querySelectorAll(this.$getTagNameOf(ze)))),e}$initSelection(e=!1,t=!1){const{initialCoverage:n,parentElement:r}=this;if(st(n)&&r){const a=this.aspectRatio||this.initialAspectRatio;let i=(t?0:this.width)||r.offsetWidth*n,o=(t?0:this.height)||r.offsetHeight*n;st(a)&&({width:i,height:o}=jt({aspectRatio:a,width:i,height:o})),this.$change(this.x,this.y,i,o),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 n=t.indexOf(e),r=t[n+1]||t[n-1];r&&(e.active=!1,this.parentElement.removeChild(e),r.active=!0,r.$emit(rt,{x:r.x,y:r.y,width:r.width,height:r.height}))}else this.$clear()}}$handleActionStart(e){var t,n;const r=null===(n=null===(t=e.detail)||void 0===t?void 0:t.relatedEvent)||void 0===n?void 0:n.target;this.$action="",this.$actionStartTarget=r,!this.hidden&&this.multiple&&!this.active&&r===this&&this.parentElement&&(this.$getSelections().forEach(e=>{e.active=!1}),this.active=!0,this.$emit(rt,{x:this.x,y:this.y,width:this.width,height:this.height}))}$handleAction(e){const{currentTarget:t,detail:n}=e;if(!t||!n)return;const{relatedEvent:r}=n;let{action:a}=n;if(!a&&this.multiple&&(a=this.$action||(null==r?void 0:r.target.action),this.$action=a),!a||this.hidden&&a!==Pe||this.multiple&&!this.active&&a!==Ie)return;const i=n.endX-n.startX,o=n.endY-n.startY,{width:s,height:l}=this;let{aspectRatio:c}=this;switch(!st(c)&&r.shiftKey&&(c=st(s)&&st(l)?s/l:1),a){case Pe:if(0!==i&&0!==o){const{$canvas:e}=this,r=St(t);(this.multiple&&!this.hidden?this.$createSelection():this).$change(n.startX-r.left,n.startY-r.top,Math.abs(i),Math.abs(o),c),i<0?o<0?a=He:o>0&&(a=Ve):i>0&&(o<0?a=Be:o>0&&(a=We)),e&&(e.$action=a)}break;case Me:this.movable&&(this.dynamic||this.$actionStartTarget&&this.contains(this.$actionStartTarget))&&this.$move(i,o);break;case Ie:if(r&&this.zoomable&&(this.dynamic||this.contains(r.target))){const e=St(t);this.$zoom(n.scale,r.pageX-e.left,r.pageY-e.top)}break;default:this.$resize(a,i,o,c)}}$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,n=(e.offsetHeight-this.height)/2;return this.$change(t,n)}$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,n=0,r=this.aspectRatio){if(!this.resizable)return this;const a=st(r),{$canvas:i}=this;let{x:o,y:s,width:l,height:c}=this;switch(e){case De:s+=n,c-=n,c<0&&(e=Ue,c=-c,s-=c),a&&(o+=(t=n*r)/2,l-=t,l<0&&(l=-l,o-=l));break;case Fe:l+=t,l<0&&(e=qe,l=-l,o-=l),a&&(s-=(n=t/r)/2,c+=n,c<0&&(c=-c,s-=c));break;case Ue:c+=n,c<0&&(e=De,c=-c,s-=c),a&&(o-=(t=n*r)/2,l+=t,l<0&&(l=-l,o-=l));break;case qe:o+=t,l-=t,l<0&&(e=Fe,l=-l,o-=l),a&&(s+=(n=t/r)/2,c-=n,c<0&&(c=-c,s-=c));break;case Be:a&&(n=-t/r),s+=n,c-=n,l+=t,l<0&&c<0?(e=Ve,l=-l,c=-c,o-=l,s-=c):l<0?(e=He,l=-l,o-=l):c<0&&(e=We,c=-c,s-=c);break;case He:a&&(n=t/r),o+=t,s+=n,l-=t,c-=n,l<0&&c<0?(e=We,l=-l,c=-c,o-=l,s-=c):l<0?(e=Be,l=-l,o-=l):c<0&&(e=Ve,c=-c,s-=c);break;case We:a&&(n=t/r),l+=t,c+=n,l<0&&c<0?(e=He,l=-l,c=-c,o-=l,s-=c):l<0?(e=Ve,l=-l,o-=l):c<0&&(e=Be,c=-c,s-=c);break;case Ve:a&&(n=-t/r),o+=t,l-=t,c+=n,l<0&&c<0?(e=Be,l=-l,c=-c,o-=l,s-=c):l<0?(e=We,l=-l,o-=l):c<0&&(e=He,c=-c,s-=c)}return i&&i.$setAction(e),this.$change(o,s,l,c)}$zoom(e,t,n){if(!this.zoomable||0===e)return this;e<0?e=1/(1-e):e+=1;const{width:r,height:a}=this,i=r*e,o=a*e;let s=this.x,l=this.y;return ot(t)&&ot(n)?(s-=(i-r)*((t-this.x)/r),l-=(o-a)*((n-this.y)/a)):(s-=(i-r)/2,l-=(o-a)/2),this.$change(s,l,i,o)}$change(e,t,n=this.width,r=this.height,a=this.aspectRatio,i=!1){return this.$changing||!ot(e)||!ot(t)||!ot(n)||!ot(r)||n<0||r<0?this:(st(a)&&({width:n,height:r}=jt({aspectRatio:a,width:n,height:r},"cover")),this.precise||(e=Math.round(e),t=Math.round(t),n=Math.round(n),r=Math.round(r)),e===this.x&&t===this.y&&n===this.width&&r===this.height&&Object.is(a,this.aspectRatio)&&!i?this:(this.hidden&&(this.hidden=!1),!1===this.$emit(rt,{x:e,y:t,width:n,height:r})?this:(this.$changing=!0,this.x=e,this.y=t,this.width=n,this.height=r,this.$changing=!1,this.$render())))}$reset(){const{x:e,y:t,width:n,height:r}=this.$initialSelection;return this.$change(e,t,n,r)}$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,n)=>{if(!this.isConnected)return void n(new Error("The current element is not connected to the DOM."));const r=document.createElement("canvas");let{width:a,height:i}=this,o=1;if(ut(e)&&(st(e.width)||st(e.height))&&(({width:a,height:i}=jt({aspectRatio:a/i,width:e.width,height:e.height})),o=a/this.width),r.width=a,r.height=i,!this.$canvas)return void t(r);const s=this.$canvas.querySelector(this.$getTagNameOf($e));s?s.$ready().then(n=>{const l=r.getContext("2d");if(l){const[t,c,u,d,m,h]=s.$getTransform(),p=-this.x,f=-this.y,g=(p*d-u*f)/(t*d-u*c),b=(f*t-c*p)/(t*d-u*c);let y=t*g+u*b+m,v=c*g+d*b+h,x=n.naturalWidth,w=n.naturalHeight;1!==o&&(y*=o,v*=o,x*=o,w*=o);const k=x/2,S=w/2;l.fillStyle="transparent",l.fillRect(0,0,a,i),ut(e)&&dt(e.beforeDraw)&&e.beforeDraw.call(this,l,r),l.save(),l.translate(k,S),l.transform(t,c,u,d,y,v),l.translate(-k,-S),l.drawImage(n,0,0,x,w),l.restore()}t(r)}).catch(n):t(r)})}}Ht.$name=ze,Ht.$version="2.0.0";class Wt extends It{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,n){Object.is(n,t)||(super.$propertyChangedCallback(e,t,n),"rows"!==e&&"columns"!==e||this.$nextTick(()=>{this.$render()}))}connectedCallback(){super.connectedCallback(),this.$render()}$render(){const e=this.$getShadowRoot(),t=document.createDocumentFragment();for(let n=0;n<this.rows;n+=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))}}Wt.$name=je,Wt.$version="2.0.0";class Vt extends It{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"])}}Vt.$name=Ne,Vt.$version="2.0.0";const Kt=new WeakMap,Gt=new WeakMap,Qt=new WeakMap,Yt=new WeakMap,Xt="vertical";class Jt extends It{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=Xt,this.selection="",this.slottable=!1}set $image(e){Gt.set(this,e)}get $image(){return Gt.get(this)}set $sourceImage(e){Yt.set(this,e)}get $sourceImage(){return Yt.get(this)}set $canvas(e){Kt.set(this,e)}get $canvas(){return Kt.get(this)}set $selection(e){Qt.set(this,e)}get $selection(){return Qt.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["resize","selection"])}connectedCallback(){super.connectedCallback();let e=null;if(e=this.selection?this.ownerDocument.querySelector(this.selection):this.closest(this.$getTagNameOf(ze)),mt(e)){this.$selection=e,this.$onSelectionChange=this.$handleSelectionChange.bind(this),vt(e,rt,this.$onSelectionChange);const t=e.closest(this.$getTagNameOf(Ee));if(t){this.$canvas=t;const e=t.querySelector(this.$getTagNameOf($e));e&&(this.$sourceImage=e,this.$image=e.cloneNode(!0),this.$getShadowRoot().appendChild(this.$image),this.$onSourceImageLoad=this.$handleSourceImageLoad.bind(this),this.$onSourceImageTransform=this.$handleSourceImageTransform.bind(this),vt(e.$image,Je,this.$onSourceImageLoad),vt(e,at,this.$onSourceImageTransform))}this.$render()}}disconnectedCallback(){const{$selection:e,$sourceImage:t}=this;e&&this.$onSelectionChange&&(yt(e,rt,this.$onSelectionChange),this.$onSelectionChange=null),t&&this.$onSourceImageLoad&&(yt(t.$image,Je,this.$onSourceImageLoad),this.$onSourceImageLoad=null),t&&this.$onSourceImageTransform&&(yt(t,at,this.$onSourceImageTransform),this.$onSourceImageTransform=null),super.disconnectedCallback()}$handleSelectionChange(e){this.$render(e.detail)}$handleSourceImageLoad(){const{$image:e,$sourceImage:t}=this,n=e.getAttribute("src"),r=t.getAttribute("src");r&&r!==n&&(e.setAttribute("src",r),e.$ready(()=>{setTimeout(()=>{this.$render()},50)}))}$handleSourceImageTransform(e){this.$render(void 0,e.detail.matrix)}$render(e,t){const{$canvas:n,$selection:r}=this;e||r.hidden||(e=r),(!e||0===e.x&&0===e.y&&0===e.width&&0===e.height)&&(e={x:0,y:0,width:n.offsetWidth,height:n.offsetHeight});const{x:a,y:i,width:o,height:s}=e,l={},{clientWidth:c,clientHeight:u}=this;let d=c,m=u,h=NaN;switch(this.resize){case"both":h=1,d=o,m=s,l.width=o,l.height=s;break;case"horizontal":h=s>0?u/s:0,d=o*h,l.width=d;break;case Xt:h=o>0?c/o:0,m=s*h,l.height=m;break;default:c>0?h=o>0?c/o:0:u>0&&(h=s>0?u/s:0)}this.$scale=h,this.$setStyles(l),this.$sourceImage&&this.$transformImageByOffset(null!=t?t:this.$sourceImage.$getTransform(),-a,-i)}$transformImageByOffset(e,t,n){const{$image:r,$scale:a,$sourceImage:i}=this;if(i&&r&&a>=0){const[i,o,s,l,c,u]=e,d=(t*l-s*n)/(i*l-s*o),m=(n*i-o*t)/(i*l-s*o),h=i*d+s*m+c,p=o*d+l*m+u;r.$ready(e=>{this.$setStyles.call(r,{width:e.naturalWidth*a,height:e.naturalHeight*a})}),r.$setTransform(i,o,s,l,h*a,p*a)}}}function Zt(){const[e,t]=u.useState(!1),[n,r]=u.useState(null),[a,i]=u.useState(null),o=async(e,a)=>{if(!e||!a)return r("ID de asset y configuración de variante son requeridos"),null;t(!0),r(null),i(null);try{const t=await async function(e,{variant_name:t,width:r,height:a,crop_params:i,preset_aspect:o=null,preset_size:s=null,output_format:l="webp"}){try{const n=[{name:t,width:r,height:a,output_format:l,crop_params:i}];return o&&(n[0].preset_aspect=o),s&&(n[0].preset_size=s),function(e){if(!e?.success||!e?.data)return{result:null};const t=e.data;return{result:{job_id:t.job_id,asset_id:t.asset_id,variants_requested:t.variants_requested||[],processing_mode:t.async?"async":"sync",estimated_completion:t.estimated_completion,variant_statuses:(t.variant_statuses||[]).map(e=>({name:e.name,status:e.status,size:e.expected_size,format:e.format}))}}}(await F({endpoint:`/assets/${e}/variants`,method:"POST",body:{variants:n,async:!1},basePath:V,useJWT:!0}))}catch(n){throw W(n)}}(e,{variant_name:a.name,width:a.width,height:a.height,crop_params:a.crop_params,preset_aspect:a.preset_aspect,preset_size:a.preset_size,output_format:a.output_format});if(t?.result)return i(t.result),t.result;throw new Error("No se pudo crear la variante")}catch(o){return console.error("Error creating variant:",o),r(o.message||"Error desconocido al crear variante"),null}finally{t(!1)}};return{createVariant:o,createCropVariant:async(e,t,n={})=>{const r={name:n.name||`crop_${Date.now()}`,width:n.width||800,height:n.height||600,output_format:n.format||"webp",crop_params:{x:t.x||0,y:t.y||0,width:t.width||1,height:t.height||1}};return await o(e,r)},loading:e,error:n,createdVariant:a,reset:()=>{r(null),i(null)}}}Jt.$name=Ae,Jt.$version="2.0.0",
2
2
  /*! Cropper.js v2.0.0 | (c) 2015-present Chen Fengyuan | MIT */
3
- Lt.$define(),Vt.$define(),Wt.$define(),qt.$define(),Dt.$define(),Ht.$define(),Ut.$define(),Jt.$define();class en{constructor(e,t,n){this.canvasRef=e,this.imageRef=t,this.selectionRef=n}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(n){return console.warn("Error moving image:",n),!1}},moveTo:(e,t)=>{if(!this.image)return!1;try{return this.image.$moveTo(e,t),!0}catch(n){return console.warn("Error moving image to position:",n),!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(n){return console.warn("Error scaling image:",n),!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,n,r,a,i)=>{if(!this.image)return!1;try{return this.image.$setTransform(e,t,n,r,a,i),!0}catch(o){return console.warn("Error setting transform:",o),!1}},resetZoom:()=>{if(!this.image)return!1;try{const e=this.image.$getTransform();if(!e)return!1;const[t,n,r,a,i,o]=e,s=Math.sqrt(t*t+n*n),l=Math.sqrt(r*r+a*a),c=t/s,u=n/s,d=r/l,m=a/l;return this.image.$setTransform(c,u,d,m,i,o),!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[n,r,a,i,o,s]=t,l=Math.sqrt(n*n+r*r),c=Math.sqrt(a*a+i*i),u=n/l*e,d=r/l*e,m=a/c*e,h=i/c*e;return this.image.$setTransform(u,d,m,h,o,s),!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,n]=e;return Math.sqrt(t*t+n*n)}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 n=this.image.querySelector("img")||this.image;if(!n?.naturalWidth||!n?.naturalHeight)return!1;const r=1-e,a=t.width*r/n.naturalWidth,i=t.height*r/n.naturalHeight,o=Math.min(a,i,1);return this.transform.setZoom(o)}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[n,r]=e.split("/").map(e=>parseFloat(e.trim()));if(isNaN(n)||isNaN(r)||0===r)return console.warn("Invalid aspect ratio format:",e),!1;t=n/r}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(n){return console.warn("Error moving selection:",n),!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,n,r,a)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$change(e,t,n,r,a),!0}catch(i){return console.warn("Error changing selection:",i),!1}},set:(e,t,n,r)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.x=e,this.selectionElement.y=t,this.selectionElement.width=n,this.selectionElement.height=r,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,n,r,a,i,o]=e;return this.transform.setTransform(-t,n,r,a,i,o)},flipVertical:()=>{const e=this.transform.getTransform();if(!e)return!1;const[t,n,r,a,i,o]=e;return this.transform.setTransform(t,n,r,-a,i,o)},setupInitialView:async(e={})=>{const{paspartuFactor:t=.85,retries:n=3,retryDelay:r=200}=e;return new Promise(e=>{const a=(i=0)=>{if(!this.isReady)return i<n?void setTimeout(()=>a(i+1),r):void e(!1);try{const o=this.canvasElement.getBoundingClientRect();let s=this.image.querySelector("img")||this.image;if(!s?.naturalWidth||!s?.naturalHeight)return i<n?void setTimeout(()=>a(i+1),r):(this.transform.center(),void e(!1));if(o.width>0&&o.height>0){const n=o.width*t/s.naturalWidth,r=o.height*t/s.naturalHeight,a=Math.min(n,r,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(o){console.warn("Error in setup:",o),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:n,onAction:r,onActionStart:a,onActionMove:i,onActionEnd:o}=e,s=[];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),s.push(()=>{this.selectionElement&&this.selectionElement.removeEventListener("change",e)})}if(n&&this.image){const e=e=>{n({matrix:e.detail.matrix,oldMatrix:e.detail.oldMatrix})};this.image.addEventListener("transform",e),s.push(()=>{this.image&&this.image.removeEventListener("transform",e)})}if(this.canvasElement){if(r){const e=e=>r(e.detail);this.canvasElement.addEventListener("action",e),s.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("action",e)})}if(a){const e=e=>a(e.detail);this.canvasElement.addEventListener("actionstart",e),s.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("actionstart",e)})}if(i){const e=e=>i(e.detail);this.canvasElement.addEventListener("actionmove",e),s.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("actionmove",e)})}if(o){const e=e=>o(e.detail);this.canvasElement.addEventListener("actionend",e),s.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("actionend",e)})}}return()=>{s.forEach(e=>e())}}}async function tn(e,t,n={}){const{format:r=null,originalFormat:a="webp",onSuccess:i=null,onError:o=null,accessibilityManager:s=null}=n;try{const n=window.limboCore?.config?.getGlobal(),o=r||n?.downloadFormat||a||"webp",l=`${t.split(".")[0]}.${o}`;if(s&&s.announce(`Descargando ${l}`),e.startsWith("data:image/"))return function(e,t){const n=document.createElement("a");n.href=e,n.download=t,n.style.display="none",document.body.appendChild(n),n.click(),setTimeout(()=>{document.body.removeChild(n)},100)}(e,l),i&&i(l),s&&s.announce(`${l} descargado correctamente`),!0;const c=await fetch(e,{mode:"cors"});if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);const u=await c.blob();let d=u;const m=u.type;m!==`image/${"jpg"===o?"jpeg":o}`&&function(e){return["webp","jpeg","jpg","png"].includes(e.toLowerCase())}(o)&&(d=await async function(e,t){return new Promise((n,r)=>{const a=new Image,i=URL.createObjectURL(e);a.onload=()=>{try{const r=document.createElement("canvas");r.width=a.width,r.height=a.height;r.getContext("2d").drawImage(a,0,0);const o=`image/${"jpg"===t?"jpeg":t}`,s="png"===t?void 0:.92;r.toBlob(t=>{URL.revokeObjectURL(i),n(t||e)},o,s)}catch(r){URL.revokeObjectURL(i),n(e)}},a.onerror=()=>{URL.revokeObjectURL(i),n(e)},a.src=i})}(u,o));const h=window.URL.createObjectURL(d),p=document.createElement("a");return p.href=h,p.download=l,p.style.display="none",document.body.appendChild(p),p.click(),setTimeout(()=>{window.URL.revokeObjectURL(h),document.body.removeChild(p)},100),i&&i(l),s&&s.announce(`${l} descargado correctamente`),!0}catch(l){return console.error("Error downloading image:",l),o&&o(l),s&&s.announce(`Error al descargar la imagen: ${l.message}`),!1}}const nn=Object.freeze(Object.defineProperty({__proto__:null,default:tn,downloadImage:tn},Symbol.toStringTag,{value:"Module"}));function rn({image:e,onSave:t,onCancel:n,onDelete:r,onError:a=null,deleting:i=!1,onVariantCreated:o=null}){const[s,l]=u.useState(!1),[c,d]=u.useState(null),[m,h]=u.useState(!1),[p,f]=u.useState(!0),[g,b]=u.useState(!0),[y,v]=u.useState({horizontal:!1,vertical:!1}),[x,w]=u.useState(!1),[k,S]=u.useState(!0),[C,E]=u.useState(!0),[N,j]=u.useState(!0),[_,$]=u.useState({current:1,percentage:100}),[z]=u.useState(()=>{const[t]=e.filename.split(".");return t}),T=u.useMemo(()=>{const e=window.limboCore?.config?.getGlobal()||{};return{mandatoryCrops:e.cropper?.mandatoryCrops||[],allowCustomCrops:!1!==e.cropper?.allowCustomCrops,showDimensionInputs:!0===e.cropper?.showDimensionInputs}},[]),[P,M]=u.useState(()=>T.mandatoryCrops.length>0?T.mandatoryCrops.map((e,t)=>({id:`crop-${t}`,label:e.label,width:e.width,height:e.height,required:!1!==e.required,isCustom:!1,confirmed:!1,savedState:null})):[{id:"crop-default-0",label:z,width:e.width||1920,height:e.height||1080,required:!1,isCustom:!0,confirmed:!1,savedState:null}]),[I,L]=u.useState(0),O=P[I],[R,D]=u.useState(!1),F=u.useMemo(()=>O&&O.width&&O.height?O.width/O.height:"",[O]),U=u.useMemo(()=>{const e=50;if(!F||""===F)return{minWidth:e,minHeight:e};if(F>=1){return{minWidth:e,minHeight:e/F}}return{minWidth:e*F,minHeight:e}},[F]),[q,B]=u.useState(!1),[H,W]=u.useState([]),[V,K]=u.useState(null),G=window.limboCore?.accessibilityManager,{createCropVariant:Q,loading:Y,error:X}=Zt(),J=((e,t={})=>{const n=u.useRef(null),r=u.useRef(null),a=u.useRef(null),i=u.useRef(null),[o,s]=u.useState(null),[l,c]=u.useState(null),[d,m]=u.useState(!1),[h,p]=u.useState(!0),[f,g]=u.useState(0),b={aspectRatio:"",shade:!0,paspartuFactor:.85,...t};u.useEffect(()=>{n.current&&r.current&&a.current&&(i.current=new en(n,r,a),m(!0))},[]),u.useEffect(()=>{if(i.current)return i.current.setupEventListeners({onSelectionChange:e=>{s(e)},onImageTransform:()=>{g(e=>e+1)}})},[d]),u.useEffect(()=>{i.current&&e&&(async()=>{i.current.selection.setAspectRatio(b.aspectRatio),i.current.canvas.setBackground(b.shade),await i.current.utils.setupInitialView({paspartuFactor:b.paspartuFactor});const e=await i.current.utils.checkExportability();p(e);const t=r.current?.querySelector("img")||r.current;t?.naturalWidth&&t?.naturalHeight&&c({naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,currentWidth:t.width,currentHeight:t.height})})()},[e,b.aspectRatio,b.shade,b.paspartuFactor]);const y=u.useCallback(()=>({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}),[]),v=u.useCallback(()=>({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=u.useCallback(()=>({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:r,selectionRef:a},state:{cropData:o,imageInfo:l,isReady:d,canExport:h,transformVersion:f},transform:y(),selection:v(),utils:x(),manager:i.current}})(e,{aspectRatio:F||null,showGrid:p,shade:g,initialCoverage:.5,paspartuFactor:.85}),{refs:Z,state:ee,transform:te,selection:ne,utils:re}=J,{canvasRef:ae,imageRef:ie,selectionRef:oe}=Z,{cropData:se,imageInfo:le,canExport:ce,transformVersion:ue}=ee,de=u.useMemo(()=>le||{naturalWidth:e.width||1920,naturalHeight:e.height||1080,currentWidth:e.width||1920,currentHeight:e.height||1080},[le,e.width,e.height]),me=u.useCallback(()=>f(e=>!e),[]),he=u.useCallback(()=>b(e=>!e),[]),pe=u.useCallback(()=>w(e=>!e),[]),fe=u.useCallback(()=>S(e=>!e),[]),ge=u.useCallback(()=>E(e=>!e),[]),be=u.useCallback(()=>j(e=>!e),[]),ye=u.useCallback(()=>te.center(),[te]),ve=u.useCallback(()=>ne.center(),[ne]),xe=u.useCallback(()=>ne.reset(),[ne]),we=u.useCallback((e,t)=>te.move(e,t),[te]),ke=u.useCallback(e=>te.zoom(e),[te]),Se=u.useCallback(e=>te.rotate(e),[te]),Ce=u.useCallback(e=>{ne.setCoverage(e)},[ne]),Ee=u.useCallback(()=>re.resetZoomOnly(),[re]),Ne=u.useCallback(()=>{v(e=>{const t=!e.horizontal;return te.flipHorizontal(),{...e,horizontal:t}})},[te]),je=u.useCallback(()=>{v(e=>{const t=!e.vertical;return te.flipVertical(),{...e,vertical:t}})},[te]),_e=u.useCallback(()=>{if(J.manager&&ee.isReady)try{const e=se?{...se}:null,t=J.manager.transform.getZoom(),n={cropData:e,transforms:{zoom:t,rotation:J.manager.transform.getRotation(),flipHorizontal:y.horizontal,flipVertical:y.vertical}};return M(e=>e.map((e,t)=>t===I?{...e,savedState:n}:e)),n}catch(e){return console.warn("Error saving crop state:",e),null}},[J.manager,ee.isReady,se,y,I]),$e=u.useCallback(e=>{if(J.manager&&ee.isReady&&e)try{const{cropData:t,transforms:n}=e;if(n&&(re.resetAll(),n.zoom&&1!==n.zoom&&J.manager.transform.setZoom(n.zoom),n.rotation&&0!==n.rotation&&J.manager.transform.setRotation(n.rotation),n.flipHorizontal&&J.manager.transform.flipHorizontal(),n.flipVertical&&J.manager.transform.flipVertical(),v({horizontal:n.flipHorizontal||!1,vertical:n.flipVertical||!1})),t){const{x:e,y:n,width:r,height:a}=t;ne.set(e,n,r,a)}}catch(t){console.warn("Error restoring crop state:",t)}},[J.manager,ee.isReady,ne,re]),ze=u.useCallback(()=>{for(let e=0;e<P.length;e++){const t=P[e];if(!t.label||""===t.label.trim())return e}return-1},[P]),Te=u.useCallback(e=>{e!==I&&(_e(),L(e),D(!0))},[I,_e]),Ae=u.useCallback(()=>{if(!T.allowCustomCrops)return void alert("No se pueden añadir recortes personalizados en este modo.");_e();const t={id:`crop-custom-${Date.now()}`,label:`Recorte ${P.length+1}`,width:e.width||1920,height:e.height||1080,required:!1,isCustom:!0,confirmed:!1,savedState:null};M(e=>[...e,t]),L(P.length),G?.announce(`Nuevo recorte personalizado añadido: ${t.label}`)},[T.allowCustomCrops,_e,P.length,e.width,e.height,G]),Pe=u.useCallback((e,t)=>{const n=parseInt(t,10);""===t||isNaN(n)||M(t=>t.map((t,r)=>r===I?{...t,[e]:n}:t))},[I]),Me=u.useCallback(e=>{const t=O[e];let n=100;if(ae.current&&le){const e=ae.current.getBoundingClientRect(),t=Math.min(e.width,e.height);n=Math.max(100,Math.round(.05*t))}const r=Math.max(n,Math.min(5e3,t));r!==t&&M(t=>t.map((t,n)=>n===I?{...t,[e]:r}:t));const a={...O,[e]:r},i=a.width/a.height,o=ne.getData?.();ne.setAspectRatio(i),o&&void 0!==o.x&&setTimeout(()=>{ne.set?.(o.x,o.y,o.width,o.height)},50)},[I,O,ne,ae,le]),Ie=u.useCallback(e=>{M(t=>t.map((t,n)=>n===I?{...t,label:e}:t))},[I]),Le=u.useCallback(e=>{const t=P[e];if(t.required)alert("No se puede eliminar un recorte obligatorio.");else if(1!==P.length){if(M(t=>t.filter((t,n)=>n!==e)),e===I){const t=Math.max(0,e-1);L(t)}else e<I&&L(e=>e-1);G?.announce(`Recorte ${t.label} eliminado`)}else alert("Debe haber al menos un recorte.")},[P,I,G]),Oe=u.useCallback(async()=>{if(!ce)return null;try{const t=await ne.toCanvas({width:800,height:600,imageSmoothingEnabled:!0,imageSmoothingQuality:"high"});return t?t.toDataURL(`image/${globalThis.downloadFormat||e.mime_type.split("/")[1]||"webp"}`,.9):null}catch(t){return console.warn("Error generating preview:",t),null}},[ce,e.mime_type,ne]),Re=u.useCallback(async()=>{if(s)return l(!1),d(null),void h(!1);if(ce){l(!0),h(!0);try{const e=await Oe();e?d(e):(l(!1),alert("No se puede exportar el recorte por restricciones de CORS en la imagen original."))}finally{h(!1)}}else alert("No se puede exportar el recorte por restricciones de CORS en la imagen original.")},[ce,Oe,s]),De=u.useCallback(async()=>{if(!ce){const e="No se puede exportar el recorte por restricciones de CORS en la imagen original.";return G?.announceError(e),void alert(e)}if(!ee.isReady){const e="El cropper aún no está inicializado. Espera un momento e inténtalo de nuevo.";return G?.announceError(e),void alert(e)}G?.announce("Creando recorte de la imagen");try{if(!se||!de)throw console.error("❌ Datos faltantes:",{cropData:se,effectiveImageInfo:de}),new Error(`No hay datos de recorte disponibles. CropData: ${!!se}, ImageInfo: ${!!de}`);if(!se.x&&0!==se.x||!se.y&&0!==se.y||!se.width||!se.height)throw console.error("❌ CropData inválido:",se),new Error("Los datos de recorte no tienen las propiedades esperadas");if(!de.naturalWidth||!de.naturalHeight)throw console.error("❌ ImageInfo inválido:",de),new Error("Los datos de imagen no tienen las dimensiones esperadas");const{x:n,y:r,width:a,height:i}=se,{naturalWidth:s,naturalHeight:l}=de,c={x:n/s,y:r/l,width:a/s,height:i/l},u=Math.min(O.width,5e3),d=Math.min(O.height,5e3),m=Date.now(),h=`${z}_${O.label||"crop"}_${m}`,p=await Q(e.id,c,{name:h,width:u,height:d,format:globalThis.downloadFormat||"webp",quality:90});p&&(G?.announceSuccess(`Recorte creado: ${h}`),o?.(e.id,p),t(p))}catch(n){console.warn("Error creating crop variant:",n);const e="No se pudo crear el recorte. Inténtalo de nuevo.";G?.announceError(e),alert(e),a?.(n)}},[ce,ee.isReady,G,se,de,z,O.label,O.width,O.height,Q,e.id,o,t,a]),Fe=u.useCallback(async()=>{const e=ze();if(-1!==e){const t=P[e];return alert(`El recorte "${t.label||t||"(sin nombre)"}" debe tener un nombre válido.`),void L(e)}if(P.length>1)return K("save"),W(P.map((e,t)=>t)),void B(!0);await De()},[ze,P,De]),Ue=u.useCallback(async()=>{if(!ce){const e="No se puede descargar el recorte por restricciones de CORS en la imagen original.";return G?.announceError(e),void alert(e)}try{G?.announce("Preparando descarga del recorte");let e=c;if(e||(e=await Oe()),!e)throw new Error("No se pudo generar la imagen para descargar");const t=O.label.replace(/\.[^/.]+$/," ").replace(" ","-").trim(),n=`${z}_${t||"crop"}`;await tn(e,n,{accessibilityManager:G,onSuccess:e=>{G?.announce(`Recorte descargado como ${e}`)},onError:e=>{G?.announceError(`Error al descargar: ${e.message}`),alert(`Error al descargar la imagen: ${e.message}`)}})}catch(e){console.error("Error downloading crop:",e),G?.announceError(`Error al descargar el recorte: ${e.message}`),alert(`Error al descargar el recorte: ${e.message}`)}},[ce,G,c,O.label,z,Oe]),qe=u.useCallback(async()=>{const e=ze();if(-1!==e){const t=P[e];return alert(`El recorte "${t.label||t||"(sin nombre)"}" debe tener un nombre válido.`),void L(e)}if(P.length>1)return K("download"),W(P.map((e,t)=>t)),void B(!0);await Ue()},[ze,P,Ue]);return u.useEffect(()=>{l(!1),d(null)},[e]),u.useEffect(()=>{J.manager&&(F&&ne.setAspectRatio(F),re.setBackground(g))},[F,g,J.manager,ne,re]),u.useEffect(()=>{if(!J.manager||!ee.isReady)return;const e=O?.savedState;e?($e(e),D(!1)):F&&(ne.setAspectRatio(F),R&&setTimeout(()=>{ne.center(),D(!1)},100))},[I,O,F,J.manager,ee.isReady,$e,ne,R]),u.useEffect(()=>{if(!le||!ee.isReady||T.mandatoryCrops.length>0)return;const e=P[0];if(e&&"crop-default-0"===e.id&&(1920===e.width||1080===e.height)){const t=Math.min(le.naturalWidth,5e3),n=Math.min(le.naturalHeight,5e3);M([{...e,width:t,height:n}]),console.log(`[CropperView] Crop por defecto actualizado a ${t}×${n}px`)}},[le,ee.isReady,T.mandatoryCrops.length,P]),u.useEffect(()=>{if(J.manager&&J.manager.utils)try{const e=J.manager.transform.getZoom(),t={current:e,isZoomedIn:e>1,isZoomedOut:e<1,percentage:Math.round(100*e)};$(t)}catch(e){console.warn("Error updating zoom info:",e)}},[ue,J.manager]),u.useEffect(()=>{if(!s||!ce)return;const e=setTimeout(async()=>{h(e=>!c&&!e||e);try{const e=await Oe();e&&d(e)}finally{h(!1)}},300);return()=>{clearTimeout(e),h(!1)}},[se,ue,s,ce,Oe,F,y,c]),u.useEffect(()=>{const e=ae.current,t=t=>{if("Delete"===t.key||"Backspace"===t.key||"Backspace"===t.key&&t.metaKey||"Backspace"===t.key&&t.ctrlKey){const n=t.target;if(e&&(n===e||n===document.body||n===document.documentElement||"CROPPER-CANVAS"===n.tagName||"CROPPER-SELECTION"===n.tagName||"CROPPER-IMAGE"===n.tagName||"CROPPER-HANDLE"===n.tagName||"CROPPER-GRID"===n.tagName||n.closest("cropper-canvas")||e.contains(n)))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)}},[ae]),e?A.jsxs("div",{className:"limbo-cropper-view px-2 border-2 border-gray-200/50 rounded-lg min-w-fit max-w-7xl mx-auto h-full min-h-full flex flex-col",children:[A.jsxs("div",{className:"limbo-cropper-header flex flex-col sm:flex-row justify-between items-start sm:items-center p-4 lg:p-6 pb-4 border-b border-gray-200 bg-white z-10 flex-shrink-0 gap-4 lg:gap-2",children:[A.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("h2",{className:"text-lg sm:text-xl font-bold text-gray-800",children:"Generar recortes"}),P.length>1&&A.jsx("span",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 text-xs font-semibold rounded",children:O.label})]}),A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("label",{className:"text-xs text-gray-500 whitespace-nowrap",children:"Nombre:"}),A.jsx("div",{className:"",children:z+"."+(globalThis.downloadFormat||e.mime_type.split("/")[1]||"webp")})]})]}),A.jsxs("div",{className:"flex flex-row self-end gap-2 w-full sm:w-auto",children:[A.jsx("button",{onClick:n,disabled:Y,className:"limbo-btn limbo-btn-secondary px-4 sm:py-1 h-min flex-1","aria-label":"Cancelar y volver",title:"Cancelar y volver",children:"Cancelar"}),A.jsx("button",{onClick:()=>r?.(e),disabled:i|Y,className:"limbo-btn limbo-btn-danger px-4 sm:py-1 h-min flex-1 sm:flex-initial","aria-label":`Eliminar imagen ${e.filename}`,title:`Eliminar imagen ${e.filename}`,children:i?"Eliminando...":"Eliminar"})]})]}),A.jsxs("div",{className:"limbo-cropper-status bg-white border-gray-100 px-4 sm:px-6 py-2 pb-0 flex-shrink-0",children:[X&&A.jsxs("div",{className:"alert alert-danger mb-2 text-sm",role:"alert",children:[A.jsx("strong",{children:"Error:"})," ",X]}),le&&A.jsxs("div",{className:"alert alert-secondary mb-2 text-sm",role:"status",children:[A.jsx("strong",{children:"Original:"})," ",le.naturalWidth," ×"," ",le.naturalHeight," px",le.currentWidth!==le.naturalWidth&&A.jsxs("span",{className:"ml-2 sm:ml-3 text-xs block sm:inline",children:["(Mostrada: ",Math.round(le.currentWidth)," ×"," ",Math.round(le.currentHeight)," px)"]})]}),!ce&&A.jsx("div",{className:"alert alert-warning mb-2 text-sm",role:"alert",children:"⚠️ No se puede exportar por restricciones CORS"}),A.jsxs("div",{className:"bg-white border-b border-gray-200 p-3 sm:p-4 flex-shrink-0 sticky top-0 z-10 mb-3 shadow-sm",children:[A.jsxs("div",{className:"flex items-center justify-between mb-3",children:[A.jsxs("h3",{className:"text-sm font-semibold text-gray-700",children:["Recortes ",P.length>1&&`(${P.length})`]}),T.allowCustomCrops&&A.jsxs("button",{onClick:Ae,disabled:Y,className:"text-xs cursor-pointer px-2 py-1 bg-green-100 hover:bg-green-200 text-green-800 rounded border border-green-300 transition-colors flex items-center gap-1",title:"Añadir recorte personalizado",children:[A.jsx("span",{className:"icon icon-add-green text-green-800 icon--xs"}),"Añadir recorte"]})]}),A.jsx("div",{className:"space-y-2 max-h-48 overflow-y-auto grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-2 justify-items-stretch items-start justify-stretch w-full",children:P.map((e,t)=>A.jsxs("label",{className:"flex items-center gap-3 p-2 rounded border cursor-pointer transition-colors "+(I===t?"bg-blue-50 border-blue-300":"bg-gray-50 border-gray-200 hover:bg-gray-100"),children:[A.jsx("input",{type:"radio",name:"active-crop",checked:I===t,onChange:()=>Te(t),disabled:Y,className:"w-4 h-4 text-blue-600 hidden"}),A.jsxs("div",{className:"flex-1 min-w-0",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("span",{className:"text-sm font-medium text-gray-800 truncate",children:O.label===e.label&&!1===e.required?A.jsx("input",{type:"text",value:e.label,onChange:e=>Ie(e.target.value),disabled:Y||e.required,className:"w-full text-sm px-2 py-1.5 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 disabled:cursor-not-allowed",placeholder:"Nombre del recorte",required:!0,maxLength:25}):e.label}),e.required&&A.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-red-100 text-red-700 rounded",children:"Obligatorio"}),e.isCustom&&A.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-purple-100 text-purple-700 rounded",children:"Personalizado"})]}),A.jsxs("span",{className:"text-xs text-gray-500",children:[e.width," × ",e.height," px"]})]}),!e.required&&P.length>1&&A.jsx("button",{onClick:e=>{e.preventDefault(),Le(t)},className:"flex items-stretch group max-h-fit hover:bg-red-500/50 text-red-500 hover:text-red-700 p-1 rounded-full aspect-square cursor-pointer",title:"Eliminar recorte",children:A.jsx("span",{className:"group-hover:bg-gray-transparent-50 icon icon-close-small icon--xs"})})]},e.id))}),O&&A.jsx("div",{className:"mt-4 pt-4 border-t border-gray-200 space-y-3",children:A.jsxs("div",{children:[A.jsx("label",{className:"text-xs font-medium text-gray-700 block mb-1",children:"Dimensiones (px)"}),A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("input",{type:"number",min:"100",max:"5000",value:O.width,onChange:e=>Pe("width",e.target.value),onBlur:()=>Me("width"),disabled:Y,className:"flex-1 text-sm px-2 py-1.5 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Ancho"}),A.jsx("span",{className:"text-gray-400 font-bold",children:"×"}),A.jsx("input",{type:"number",min:"100",max:"5000",value:O.height,onChange:e=>Pe("height",e.target.value),onBlur:()=>Me("height"),disabled:Y,className:"flex-1 text-sm px-2 py-1.5 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Alto"})]}),A.jsxs("div",{className:"flex items-center justify-between mt-1",children:[A.jsxs("span",{className:"text-xs text-gray-500",children:["Proporción:"," ",F?F.toFixed(2):"N/A"]}),A.jsx("span",{className:"text-xs text-gray-400",children:"Min: 100px | Max: 5000px"})]})]})})]})]}),A.jsxs("div",{className:"cropper-main-content-area flex flex-col lg:flex-row flex-1 overflow-hidden rounded-lg gap-4 md:gap-0 aspect-auto lg:aspect-square xl:aspect-auto w-full max-w-[95%] lg:max-w-full self-center lg:max-h-[50rem]",children:[A.jsx("div",{className:"flex-1 relative min-w-0 order-1",children:A.jsxs("div",{className:"limbo-cropper-container lg:absolute inset-2 sm:inset-4 bg-white rounded-lg border-2 border-gray-200 shadow-lg overflow-hidden",children:[s&&A.jsxs("div",{className:"absolute top-2 sm:top-4 right-2 sm:right-4 bg-white rounded-lg border border-gray-300 p-2 sm:p-3 z-50 shadow-xl w-48 sm:w-64 max-w-[calc(50%-1rem)] sm:max-w-[calc(50%-2rem)] md:min-w-1/4",children:[A.jsxs("div",{className:"flex justify-between items-center mb-2",children:[A.jsx("h3",{className:"text-xs font-semibold text-gray-700",children:"Vista previa"}),A.jsx("button",{onClick:()=>{l(!1),d(null)},className:"text-gray-400 hover:text-gray-600 p-1 -m-1","aria-label":"Cerrar vista previa",children:A.jsx("span",{className:"icon icon-close-small text-xs"})})]}),A.jsx("div",{className:"bg-gray-50 rounded p-2 flex justify-center items-center min-h-[80px] relative",children:c?A.jsxs("div",{className:"relative w-full h-full flex justify-center items-center",children:[A.jsx("img",{src:c,alt:"Vista previa del recorte",className:"max-w-full max-h-80 object-contain rounded shadow-sm"}),m&&A.jsx("div",{className:"absolute top-1 right-1 bg-blue-500 rounded-full p-1",children:A.jsx("div",{className:"animate-spin w-3 h-3 border border-white border-t-transparent rounded-full"})})]}):A.jsxs("div",{className:"flex flex-col items-center justify-center",children:[A.jsx("div",{className:"animate-spin w-6 h-6 border-2 border-blue-500 border-t-transparent rounded-full mb-2"}),A.jsx("span",{className:"text-xs text-gray-500",children:"Generando..."})]})})]}),A.jsxs("cropper-canvas",{ref:ae,style:{width:"100%",height:"100%",display:"block"},background:!!g||void 0,id:"limbo-cropperjs-canvas",tabindex:"-1",onKeyDown:e=>{"Delete"!==e.key&&"Backspace"!==e.key||(e.preventDefault(),e.stopPropagation())},children:[A.jsx("cropper-image",{ref:ie,src:e.url||e.path,alt:e.filename,id:"limbo-cropperjs-image",action:"move",crossOrigin:"anonymous",rotatable:!0,scalable:!0,skewable:!0,translatable:!0}),A.jsxs("cropper-selection",{ref:oe,"initial-coverage":"0.5",movable:!0,resizable:!0,keyboard:"true",action:"move",style:{cursor:"move",minWidth:`${U.minWidth}px`,minHeight:`${U.minHeight}px`},"data-prevent-delete":"true",tabindex:"-1",children:[p&&A.jsx("cropper-grid",{role:"grid",action:"move",covered:!0,bordered:!0}),A.jsx("cropper-handle",{action:"move",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"32px",height:"32px",zIndex:"10"}}),A.jsx("cropper-handle",{action:"n-resize"}),A.jsx("cropper-handle",{action:"e-resize"}),A.jsx("cropper-handle",{action:"s-resize"}),A.jsx("cropper-handle",{action:"w-resize"}),A.jsx("cropper-handle",{action:"ne-resize"}),A.jsx("cropper-handle",{action:"nw-resize"}),A.jsx("cropper-handle",{action:"se-resize"}),A.jsx("cropper-handle",{action:"sw-resize"})]})]})]})}),A.jsx("div",{className:"flex limbo-cropper-controls w-full lg:w-80 h-full bg-white border-t md:border-t-0 md:border-l border-gray-200 lg:overflow-y-auto flex-shrink-0 order-1 max-h-none",children:A.jsxs("div",{className:"p-3 min-h-full sm:p-4 space-y-3 sm:space-y-4 relative w-full grid grid-cols-1 lg:flex lg:flex-col",children:[A.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:[A.jsx("button",{onClick:fe,className:"w-full p-2 my-1 cursor-pointer hover:bg-neutral-gray-050/50 transition-colors rounded-md","aria-expanded":k,"aria-label":"Mostrar/ocultar opciones de visualizción",children:A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Visualización"}),A.jsx("div",{className:"text-center",children:A.jsx("span",{className:`icon ${k?"icon-chevron-up":"icon-chevron-down"} text-center icon--xs`})})]})}),k&&A.jsxs("div",{className:"pb-2 space-y-2",children:[A.jsxs("button",{onClick:me,className:"w-full flex cursor-pointer items-center justify-between p-2 rounded transition-colors "+(p?"bg-blue-100 border border-blue-300 text-blue-800":"bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200"),disabled:Y,"aria-pressed":p,title:"Mostrar/ocultar cuadrícula de la regla de los tercios en el selector","aria-label":"Activar/desactivar grid",children:[A.jsxs("span",{className:"text-sm flex items-center",children:[A.jsx("span",{className:"icon icon-area-blue me-1"})," ","Cuadrícula"]}),A.jsx("span",{className:"text-xs",children:p?A.jsxs(A.Fragment,{children:[A.jsx("span",{className:"icon icon-tick icon--xs align-[middle!important] -mt-0.5"})," ","Activo"]}):"Inactivo"})]}),A.jsxs("button",{onClick:he,className:"w-full flex cursor-pointer items-center justify-between p-2 rounded transition-colors "+(g?"bg-blue-100 border border-blue-300 text-blue-800":"bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200"),disabled:Y,"aria-pressed":g,"aria-label":"Activar/desactivar sombreado",children:[A.jsxs("span",{className:"text-sm flex items-center",children:[A.jsx("span",{className:"icon icon-comparison-blue me-1"})," ","Tablero"]}),A.jsx("span",{className:"text-xs",children:g?A.jsxs(A.Fragment,{children:[A.jsx("span",{className:"icon icon-tick icon--xs align-[middle!important] -mt-0.5"})," ","Activo"]}):"Inactivo"})]})]})]}),A.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 p-4"+(C?"":" bg-neutral-gray-50/50"),children:[A.jsx("button",{onClick:ge,className:"w-full p-2 my-1 cursor-pointer hover:bg-neutral-gray-050/50 transition-colors rounded-md","aria-expanded":C,"aria-label":"Mostrar/ocultar opciones de visualizción",children:A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Ajustes del selector"}),A.jsx("div",{className:"text-center",children:A.jsx("span",{className:`icon ${C?"icon-chevron-up":"icon-chevron-down"} text-center icon--xs`})})]})}),C&&A.jsxs("div",{children:[A.jsx("div",{className:"mt-3",children:A.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[A.jsx("button",{onClick:()=>Ce(.5),className:"p-2 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",disabled:Y,"aria-label":"Selección 50%",title:"Tamaño de selector 50%",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{children:"50%"})})}),A.jsx("button",{onClick:()=>Ce(.7),className:"p-2 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",disabled:Y,"aria-label":"Selección 70%",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{children:"70%"})})}),A.jsx("button",{onClick:()=>Ce(.9),className:"p-2 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",disabled:Y,"aria-label":"Selección 90%",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{children:"90%"})})}),A.jsx("button",{onClick:()=>Ce(1),className:"p-2 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",disabled:Y,"aria-label":"Selección completa",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{children:"100%"})})})]})}),A.jsxs("div",{className:"space-y-2 pt-2",children:[A.jsx("button",{onClick:ve,className:"w-full p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Centrar selección",disabled:Y,"aria-label":"Centrar área de selección",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsxs("span",{children:[A.jsx("span",{className:"icon icon-radio-button icon--sm align-[middle!important] "})," ","Centrar selección"]})})}),A.jsx("button",{onClick:xe,className:"w-full p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Reiniciar selección",disabled:Y,"aria-label":"Reiniciar área de selección",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsxs("span",{children:[A.jsx("span",{className:"icon icon-refresh icon--sm lign-[middle!important] "})," ","Reset selección"]})})})]})]})]}),A.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:[A.jsx("button",{onClick:be,className:"w-full p-2 my-1 cursor-pointer hover:bg-neutral-gray-050/50 transition-colors rounded-md","aria-expanded":N,"aria-label":"Mostrar/ocultar opciones de visualizción",children:A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Transformar imagen"}),A.jsx("div",{className:"text-center",children:A.jsx("span",{className:`icon ${N?"icon-chevron-up":"icon-chevron-down"} text-center icon--xs`})})]})}),N&&A.jsxs(A.Fragment,{children:[A.jsxs("div",{className:"mb-4 hidden lg:block",children:[A.jsx("p",{className:"text-xs text-gray-600 mb-2",children:"Mover imagen"}),A.jsxs("div",{className:"grid grid-cols-3 gap-1",children:[A.jsx("div",{}),A.jsx("button",{onClick:()=>we(0,-10),className:"p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Mover arriba",disabled:Y,"aria-label":"Mover imagen hacia arriba",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-up-blue"})})}),A.jsx("div",{}),A.jsx("button",{onClick:()=>we(-10,0),className:"p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Mover izquierda",disabled:Y,"aria-label":"Mover imagen hacia la izquierda",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-left-blue"})})}),A.jsx("button",{onClick:ye,className:"p-2 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Centrar y ajustar imagen",disabled:Y,"aria-label":"Centrar y ajustar imagen",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-radio-button-blue icon-md"})})}),A.jsx("button",{onClick:()=>we(10,0),className:"p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Mover derecha",disabled:Y,"aria-label":"Mover imagen hacia la derecha",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-right-blue"})})}),A.jsx("div",{}),A.jsx("button",{onClick:()=>we(0,10),className:"p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Mover abajo",disabled:Y,"aria-label":"Mover imagen hacia abajo",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-down-blue"})})}),A.jsx("div",{})]})]}),A.jsxs("div",{className:"mb-4",children:[A.jsxs("p",{className:"text-xs text-gray-600 mb-2",children:["Zoom ",_?_.percentage+"%":""]}),A.jsxs("div",{className:"flex gap-1",children:[A.jsx("button",{onClick:()=>ke(-.2),className:"flex-1 p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Alejar 20%",disabled:Y,"aria-label":"Alejar imagen",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-zoom-out-blue"})})}),A.jsx("button",{onClick:Ee,className:"flex-1 p-2 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Restablecer zoom original",disabled:Y,"aria-label":"Restablecer el zoom para que la imagen se vea con su resolución original",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-screenshot-blue"})})}),A.jsx("button",{onClick:()=>ke(.2),className:"flex-1 p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Acercar 20%",disabled:Y,"aria-label":"Acercar imagen",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-zoom-in-blue"})})})]})]}),A.jsxs("div",{className:"mb-4",children:[A.jsx("p",{className:"text-xs text-gray-600 mb-2",children:"Rotación"}),A.jsxs("div",{className:"flex gap-1 *:text-brand-blue-1000 *:text-sm",children:[A.jsx("button",{onClick:()=>Se(-90),className:"flex-1 p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Rotar -90°",disabled:Y,"aria-label":"Rotar imagen 90 grados a la izquierda",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-reply-blue"})})}),A.jsx("button",{onClick:()=>Se(-45),className:"flex-1 p-2 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Rotar -45°",disabled:Y,"aria-label":"Rotar imagen 45 grados a la izquierda",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{children:"-45°"})})}),A.jsx("button",{onClick:()=>Se(45),className:"flex-1 p-2 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Rotar +45°",disabled:Y,"aria-label":"Rotar imagen 45 grados a la derecha",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{children:"+45°"})})}),A.jsx("button",{onClick:()=>Se(90),className:"flex-1 p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Rotar +90°",disabled:Y,"aria-label":"Rotar imagen 90 grados a la derecha",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-send-arrow-blue"})})})]})]}),A.jsxs("div",{className:"mb-4",children:[A.jsx("p",{className:"text-xs text-gray-600 mb-2",children:"Voltear"}),A.jsxs("div",{className:"flex gap-1",children:[A.jsx("button",{onClick:Ne,className:"flex-1 p-2 rounded cursor-pointer transition-colors text-sm "+(y.horizontal?"bg-blue-100 border border-blue-300 text-blue-800":"bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200"),title:"Voltear horizontalmente "+(y.horizontal?"(activo)":""),disabled:Y,"aria-label":"Voltear imagen horizontalmente","aria-pressed":y.horizontal,children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-left-right-blue border border-brand-blue-1000 rounded"})})}),A.jsx("button",{onClick:je,className:"flex-1 p-2 cursor-pointer rounded transition-colors text-sm "+(y.vertical?"bg-blue-100 border border-blue-300 text-blue-800":"bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200"),title:"Voltear verticalmente "+(y.vertical?"(activo)":""),disabled:Y,"aria-label":"Voltear imagen verticalmente","aria-pressed":y.vertical,children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-up-down-blue border border-brand-blue-1000 rounded"})})})]})]}),A.jsx("button",{onClick:()=>{te.reset(),v({horizontal:!1,vertical:!1})},className:"w-full p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Reiniciar transformaciones",disabled:Y,"aria-label":"Reiniciar todas las transformaciones de la imagen",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsxs("span",{children:[A.jsx("span",{className:"icon icon-refresh-blue icon--sm align-[middle!important] "})," ","Reiniciar ajustes"]})})})]})]}),A.jsxs("div",{className:"bg-gradient-to-br from-brand-blue-50 to-green-50 rounded-lg border border-blue-200 shadow-sm hidden lg:block",children:[A.jsxs("button",{onClick:pe,className:"w-full p-4 flex items-center justify-between cursor-pointer hover:bg-blue-100/50 transition-colors rounded-t-lg","aria-expanded":x,"aria-label":"Mostrar/ocultar guía de uso",children:[A.jsxs("h3",{className:"text-lg font-semibold text-blue-800 flex items-center",children:[A.jsx("span",{className:"icon icon-lightbulb text-yellow-500 mr-2"}),"Guía de uso"]}),A.jsx("span",{className:"icon icon-arrow-down-blue transition-transform duration-200 "+(x?"rotate-180":"")})]}),x&&A.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[A.jsxs("div",{className:"bg-white/60 rounded-md p-3 border-l-4 border-blue-400",children:[A.jsx("h4",{className:"font-semibold text-blue-700 mb-2 text-sm",children:"🖱️ Navegación básica"}),A.jsxs("div",{className:"text-sm text-blue-600 space-y-1",children:[A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Arrastra la imagen:"})," Haz clic sobre la imagen del área de selección y arrastra"]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Zoom:"})," Usa la rueda del ratón (fuera del área de selección)"]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Vista completa:"}),' Botón "Reset zoom" para ajustar al tamaño óptimo']})]})]}),A.jsxs("div",{className:"bg-white/60 rounded-md p-3 border-l-4 border-green-400",children:[A.jsx("h4",{className:"font-semibold text-green-700 mb-2 text-sm",children:"✂️ Área de selección"}),A.jsxs("div",{className:"text-sm text-green-600 space-y-1",children:[A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Mover selección:"})," Arrastra desde el centro",A.jsx("span",{className:"icon bg-white icon-move align-[middle!important] mx-1 border border-green-600 rounded-full"})]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Redimensionar:"})," Arrastra desde las esquinas o bordes"]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Tamaños rápidos:"})," Usa los botones 50%, 70%, 90%, 100%"]})]})]}),A.jsxs("div",{className:"bg-white/60 rounded-md p-3 border-l-4 border-purple-400",children:[A.jsx("h4",{className:"font-semibold text-purple-700 mb-2 text-sm",children:"⌨️ Atajos de teclado"}),A.jsxs("div",{className:"text-sm text-purple-600 space-y-1",children:[A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Flechas:"}),A.jsx("span",{className:"icon icon-arrow-right-box rotate-180 mx-1"}),A.jsx("span",{className:"icon icon-arrow-right-box mx-1"}),A.jsx("span",{className:"icon icon-arrow-right-box -rotate-90 mx-1"}),A.jsx("span",{className:"icon icon-arrow-right-box rotate-90 mx-1"}),"Mueven la selección (10px)"]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Shift + Arrastrar:"})," Mantiene proporciones al redimensionar"]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Ctrl + Rueda:"})," Zoom más preciso"]})]})]}),A.jsxs("div",{className:"bg-white/60 rounded-md p-3 border-l-4 border-amber-400",children:[A.jsx("h4",{className:"font-semibold text-amber-700 mb-2 text-sm",children:"💡 Consejos profesionales"}),A.jsxs("div",{className:"text-sm text-amber-600 space-y-1",children:[A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Vista previa:"}),' Usa el botón "Vista previa" antes de guardar']}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Cuadricula:"})," Actívalo para aplicar la regla de los tercios"]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Tablero:"})," Actívalo para cuadrar medjor las medidas o como ayuda visual para imagenes con transparencia"]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Transformaciones:"})," Rota y voltea antes de hacer el recorte final"]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Calidad:"})," Las imágenes se exportan en alta calidad (JPEG 90%)"]})]})]}),A.jsxs("div",{className:"bg-white/60 rounded-md p-3 border-l-4 border-orange-600",children:[A.jsx("h4",{className:"font-semibold text-orange-700 mb-2 text-sm",children:"⚠️ Advertencias"}),A.jsxs("div",{className:"text-sm text-orange-600 space-y-1",children:[A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Recortes grandes:"})," Pueden tardar más en procesarse"]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Calidad de imagen:"})," La calidad puede verse afectada al escalar"]})]})]})]})]})]})})]}),A.jsx("div",{className:"limbo-cropper-footer flex-shrink-0 border-t border-gray-200 bg-white p-4",children:A.jsxs("div",{className:"flex flex-row gap-2 sm:gap-3 items-stretch sm:items-center justify-end max-w-7xl mx-auto",children:[A.jsx("button",{onClick:Re,disabled:Y||!ce,className:"px-6 py-2.5 min-h-[44px] transition-colors order-2 "+(s?"limbo-btn limbo-btn-danger":"limbo-btn limbo-btn-info"),"aria-label":"Generar vista previa del recorte",title:"Mostar/Ocultar vista previa del recorte",children:A.jsxs("div",{className:"flex items-center justify-center",children:[A.jsx("span",{className:"icon md:mr-1 icon-search-white"}),A.jsx("span",{className:"hidden md:block text-nowrap",children:s?"Cerrar previa":"Vista previa"})]})}),A.jsx("button",{onClick:qe,disabled:Y||!ce,className:"limbo-btn limbo-btn-primary px-6 py-2.5 min-h-[44px] order-3","aria-label":"Descargar recorte sin guardar",title:"Descargar recorte sin guardar",children:A.jsxs("div",{className:"flex items-center justify-center",children:[A.jsx("span",{className:"icon icon-download-white md:mr-1"}),A.jsx("span",{className:"hidden md:block text-nowrap",children:"Descargar"})]})}),A.jsx("button",{onClick:Fe,disabled:Y||!se||!de||!ce||!ee.isReady,className:"limbo-btn limbo-btn-success px-6 py-2.5 min-h-[44px] order-4","aria-label":"Guardar imagen recortada",title:"Guardar imagen recortada",children:A.jsx("div",{className:"flex items-center justify-center",children:Y?A.jsxs(A.Fragment,{children:[A.jsx("span",{className:"hidden md:block text-nowrap icon icon-save-white md:mr-1"}),"Guardando..."]}):A.jsxs(A.Fragment,{children:[A.jsx("span",{className:"icon icon-save-white md:mr-1"}),A.jsx("span",{className:"hidden md:block text-nowrap",children:"Guardar recorte"})]})})})]})}),q&&A.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] p-4",children:A.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] overflow-hidden flex flex-col",children:[A.jsxs("div",{className:"px-6 py-4 border-b border-gray-200",children:[A.jsx("h3",{className:"text-lg font-semibold text-gray-800",children:"save"===V?"Seleccionar recortes a guardar":"Seleccionar recortes a descargar"}),A.jsxs("p",{className:"text-sm text-gray-600 mt-1",children:["Marca los recortes que deseas ","save"===V?"guardar":"descargar"]})]}),A.jsx("div",{className:"px-6 py-4 overflow-y-auto flex-1",children:A.jsx("div",{className:"space-y-2",children:P.map((e,t)=>A.jsxs("label",{className:`flex items-center gap-3 p-3 rounded border cursor-pointer transition-colors ${H.includes(t)?"bg-blue-50 border-blue-300":"bg-gray-50 border-gray-200 hover:bg-gray-100"} ${e.required?"opacity-75":""}`,children:[A.jsx("input",{type:"checkbox",checked:H.includes(t),disabled:e.required,onChange:e=>{e.target.checked?W(e=>[...e,t]):W(e=>e.filter(e=>e!==t))},className:"w-4 h-4 text-blue-600"}),A.jsxs("div",{className:"flex-1 min-w-0",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("span",{className:"text-sm font-medium text-gray-800 truncate",children:e.label}),e.required&&A.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-red-100 text-red-700 rounded",children:"Obligatorio"})]}),A.jsxs("span",{className:"text-xs text-gray-500",children:[e.width," × ",e.height," px"]})]})]},e.id))})}),A.jsxs("div",{className:"px-6 py-4 border-t border-gray-200 flex gap-3 justify-end",children:[A.jsx("button",{onClick:()=>{B(!1),K(null),W([])},className:"limbo-btn limbo-btn-secondary px-4 py-2",children:"Cancelar"}),A.jsxs("button",{onClick:async()=>{B(!1),"save"===V?await De():await Ue(),K(null),W([])},disabled:0===H.length,className:"limbo-btn limbo-btn-primary px-4 py-2 disabled:opacity-50 disabled:cursor-not-allowed",children:["save"===V?"Guardar":"Descargar"," (",H.length,")"]})]})]})})]}):null}function an({currentPage:e,totalPages:t,onPageChange:n,disabled:r=!1}){if(!t||t<=1)return null;const a=(()=>{const n=[],r=[],a=Math.max(1,e-2),i=Math.min(t,e+2);for(let e=a;e<=i;e++)n.push(e);return a>1&&(r.push(1),a>2&&r.push("...")),r.push(...n),i<t&&(i<t-1&&r.push("..."),r.push(t)),r})();return A.jsxs("div",{className:"flex items-center justify-center space-x-2 py-4",children:[A.jsxs("button",{onClick:()=>{e>1&&n(e-1)},disabled:r||e<=1,className:`\n px-3 py-2 text-sm font-medium rounded-md transition-colors disabled:cursor-default cursor-pointer\n ${r||e<=1?"text-gray-400 bg-gray-100 cursor-not-allowed":"text-gray-700 bg-white border border-gray-300 hover:bg-gray-50 focus:ring-2 focus:ring-blue-500"}\n `,children:[A.jsx("span",{className:"icon icon-arrow-left-white icon--sm"})," Anterior"]}),A.jsx("div",{className:"flex space-x-1",children:a.map((t,a)=>A.jsx(d.Fragment,{children:"..."===t?A.jsx("span",{className:"px-3 py-2 text-sm text-gray-500",children:"..."}):A.jsx("button",{onClick:()=>(t=>{t!==e&&n(t)})(t),disabled:r,className:`\n px-3 py-2 text-sm font-medium rounded-md transition-colors disabled:cursor-default cursor-pointer\n ${t===e?"bg-blue-600 text-white border border-blue-600":r?"text-gray-400 bg-gray-100 cursor-not-allowed":"text-gray-700 bg-white border border-gray-300 hover:bg-gray-50 focus:ring-2 focus:ring-blue-500"}\n `,children:t})},`page-${t}-${a}`))}),A.jsxs("button",{onClick:()=>{e<t&&n(e+1)},disabled:r||e>=t,className:`\n px-3 py-2 text-sm font-medium rounded-md transition-colors disabled:cursor-default cursor-pointer\n ${r||e>=t?"text-gray-400 bg-gray-100 cursor-not-allowed":"text-gray-700 bg-white border border-gray-300 hover:bg-gray-50 focus:ring-2 focus:ring-blue-500"}\n `,children:["Siguiente ",A.jsx("span",{className:"icon icon-arrow-right-white icon--sm"})]}),A.jsxs("div",{className:"text-sm text-gray-500 ml-4",children:["Página ",e," de ",t]})]})}function on({isOpen:e,onClose:t}){return e?A.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",style:{zIndex:9999},children:A.jsxs("div",{className:"bg-white rounded-lg p-6 max-w-md mx-4 shadow-xl",children:[A.jsxs("div",{className:"flex items-center mb-4",children:[A.jsx("svg",{className:"w-6 h-6 text-red-600 mr-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:A.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-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"})}),A.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Sesión Expirada"})]}),A.jsxs("div",{className:"mb-6",children:[A.jsx("p",{className:"text-gray-600 mb-2",children:"Su sesión ha expirado por seguridad."}),A.jsx("p",{className:"text-gray-600",children:"Es necesario recargar la página para obtener un nuevo token de acceso."})]}),A.jsx("div",{className:"flex justify-end space-x-3",children:A.jsx("button",{onClick:t,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors",children:"Recargar Página"})})]})}):null}function sn(){const[e,t]=u.useState(!1),[n,r]=u.useState(null);return{deleteImg:async e=>{if(!e)return r("ID de imagen no proporcionado"),!1;t(!0),r(null);try{const t=await async function(e){try{return await F({endpoint:`/assets/${e}`,method:"DELETE",basePath:V,useJWT:!0})}catch(n){throw W(n)}}(e);return!1!==t.success}catch(a){return r(a.message),!1}finally{t(!1)}},loading:e,error:n,reset:()=>{r(null)}}}const ln=new Map;function cn(e,t=500){const[n,r]=u.useState(e);return u.useEffect(()=>{const n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n}function un({apiKey:e,prod:t=!1,url:n=!0,features:r=["gallery","upload","cropper"],modeUI:a="full",ui:i={showActions:["select","download","copy","delete","crop","variants"],hideActions:[],theme:"light",language:"es",compactMode:!1,showTabs:!0},callbacks:o={},instanceId:s=null,itemsPerPage:l=10}){sessionStorage.removeItem("limbo_stock_selectedService"),sessionStorage.removeItem("limbo_stock_dynamicForm"),sessionStorage.removeItem("limbo_stock_stockImages"),sessionStorage.removeItem("limbo_stock_currentPage"),sessionStorage.removeItem("limbo_stock_paginationInfo"),sessionStorage.removeItem("limbo_portals_searchName"),sessionStorage.removeItem("limbo_portals_limit"),sessionStorage.removeItem("limbo_portals_currentPage"),sessionStorage.removeItem("limbo_portals_images"),sessionStorage.removeItem("limbo_portals_portalResults"),sessionStorage.removeItem("limbo_portals_paginationInfo");const[c,d]=u.useState({name:"",uploadedBy:"",dateFrom:"",dateTo:""}),m=cn(c.name,500),h=cn(c.uploadedBy,500),p=(()=>{switch(a){case"gallery-only":return["gallery"];case"upload-only":return["upload"];case"crop-only":return["cropper"];case"ia-only":return["ia"];default:return r}})(),[f,g]=u.useState(p.includes("gallery")?"gallery":p.includes("upload")?"upload":p.includes("cropper")?"cropper":p.includes("ia")?"ia":p[0]||"gallery"),[b,y]=u.useState(null),[v,x]=u.useState(1),{isTokenExpired:w,handleTokenExpiredClose:k}=function(){const[e,t]=u.useState(!1),n=u.useCallback(e=>{if(401===e?.response?.status){const n=e.response.data;if("token_expired"===n?.error||n?.message?.includes("expired")||n?.message?.includes("caducado")||n?.error?.includes("expired"))return t(!0),!0}return!1},[]),r=u.useCallback(()=>{t(!1),alert("El token ha expirado. La página se recargará para obtener un nuevo token."),window.location.reload()},[]);return u.useEffect(()=>{const e=e=>{e.detail&&e.detail.error&&n(e.detail.error)};return window.addEventListener("tokenExpiredError",e),()=>{window.removeEventListener("tokenExpiredError",e)}},[n]),{isTokenExpired:e,checkTokenExpiration:n,handleTokenExpiredClose:r}}(),{upload:S,loading:C,error:E,uploadedImage:N,reset:j}=function(){const[e,t]=u.useState(!1),[n,r]=u.useState(null),[a,i]=u.useState(null);return{upload:async(e,n=null)=>{if(!e)return r("No se ha proporcionado ningún archivo"),null;t(!0),r(null),i(null);try{const t=await G(e,n,!1),r=t.result||t;return i(r),r}catch(a){return r(a.message),null}finally{t(!1)}},loading:e,error:n,uploadedImage:a,reset:()=>{r(null),i(null)}}}(),{deleteImg:_,loading:$,error:z,reset:T}=sn(),P={limit:l,page:v,...m&&{name:m},...h&&{uploadedBy:h},...c.dateFrom&&{dateFrom:c.dateFrom},...c.dateTo&&{dateTo:c.dateTo}},{images:M,loading:L,error:O,pagination:R,invalidateCache:D,setImages:F}=function(e,t=!1,n={}){const[r,a]=u.useState([]),[i,o]=u.useState(!0),[s,l]=u.useState(null),[c,d]=u.useState(null),[m,h]=u.useState(0),p=u.useMemo(()=>JSON.stringify(n),[n]);return u.useEffect(()=>{const e=`${p}`,t=ln.get(e),r=Date.now();if(t&&r-t.timestamp<6e5)return a(t.data),d(t.pagination||null),void o(!1);let i=!0;return(async()=>{if(m>=3)i&&(l("Error de autenticación: Verifica tus credenciales API"),o(!1));else try{const t=await K(n);if(!i)return;const o=t.result||t.data||[],s=t.pagination||null;a(o),d(s),l(null),h(0),ln.set(e,{data:o,pagination:s,timestamp:r})}catch(t){i&&(l(t.message),h(e=>e+1))}finally{i&&o(!1)}})(),()=>{i=!1}},[e,t,p,m,n]),{images:r,loading:i,error:s,pagination:c,setImages:a,invalidateCache:()=>{ln.delete(`${p}`)}}}(e,t,P),{refreshVariants:U}=Y(),q=e=>!i.hideActions?.includes(e)&&(!!i.showActions?.includes(e)||!(i.showActions?.length>0)),B=[{id:"gallery",label:"Galería",feature:"gallery"},{id:"upload",label:"Subir nueva",feature:"upload"},{id:"cropper",label:"Recortador",hideNonActive:!0,feature:"cropper"}].filter(e=>p.includes(e.feature)),H=async e=>{if(!confirm("¿Estás seguro de que deseas eliminar esta imagen? Esta acción también eliminará todos sus recortes."))return;await _(e)&&(D(),x(1),F(t=>t.filter(t=>t.id!==e)),b&&b.id===e&&(y(null),g("gallery")))},W=()=>"crop-only"===a||1===p.length&&"cropper"===p[0]?"crop-only":p.includes("gallery")?"with-gallery":p.includes("upload")&&!p.includes("gallery")?"upload-only":"with-gallery";return A.jsxs("div",{className:"limbo-card-parent max-w-7xl mx-auto my-8 p-6 shadow-xs w-full",children:[i.showTabs&&"cropper"!=f&&A.jsx(I,{tabs:B,active:f,onChange:e=>{g(e),"upload"!==e&&j(),"gallery"!==e&&T()}}),O&&A.jsxs("div",{className:"alert alert-danger",children:["Error al cargar imágenes: ",O]}),z&&A.jsxs("div",{className:"alert alert-danger",children:["Error al eliminar imagen: ",z]}),"gallery"===f&&A.jsxs(A.Fragment,{children:[$&&A.jsx(ee,{text:"Eliminando imagen..."}),A.jsx(te,{onSelect:e=>{o.onSelect&&o.onSelect({assetId:e.id,url:e.url,fileName:e.filename,mime:e.mime_type,width:e.width,height:e.height,instanceId:s})},onCrop:e=>{y(e),p.includes("cropper")&&g("cropper")},onDelete:q("delete")?H:null,deletingId:$,images:M,loading:L,error:O,filters:c,onFiltersChange:e=>{d(e),x(1)},filterConfig:i.galleryFilters||{},loadingConfig:i.galleryLoading||{},allowedActions:{select:q("select"),download:q("download"),copy:q("copy"),delete:q("delete"),crop:q("crop")}}),R&&!L&&A.jsx(an,{currentPage:R.page||v,totalPages:R.pages||1,onPageChange:e=>{x(e)},disabled:L||$})]}),"upload"===f&&A.jsxs("div",{children:[C&&A.jsx(ee,{text:"Subiendo imagen..."}),E&&A.jsxs("div",{className:"alert alert-danger",children:["Error al subir imagen: ",E]}),N&&A.jsxs("div",{className:"alert alert-success",children:["✅ Imagen subida correctamente: ",N.filename]}),A.jsx(ve,{onUpload:async e=>{const t=await S(e);t&&(D(),x(1),F(e=>[t,...e]),g("gallery"),o.onUpload&&o.onUpload({assetId:t.id,url:t.url,fileName:t.filename,mime:t.mime_type,width:t.width,height:t.height,instanceId:s}))},disabled:C,apiKey:e,prod:t})]}),"cropper"===f&&A.jsx(rn,{image:b,onSave:e=>{const t=W(),n=window.limboCore?.config?.getGlobal()||{},r=n.mode||"embed",a=n.autoHideOnComplete||!1,i=Array.isArray(e)?e:[e];switch("with-gallery"===t&&D(),o.onCropsSaved&&o.onCropsSaved({crops:i,assetId:b?.id,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropsSaved",{crops:i,assetId:b?.id,instanceId:s}),t){case"with-gallery":y(null),g("gallery");break;case"upload-only":"modal"===r?window.limboCore?.modals?.closeAllModals():(y(null),g("upload"));break;case"crop-only":if("modal"===r)o.onCropperComplete&&o.onCropperComplete({crops:i,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropperComplete",{crops:i,instanceId:s}),window.limboCore?.modals?.closeAllModals();else if(o.onCropperComplete&&o.onCropperComplete({crops:i,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropperComplete",{crops:i,instanceId:s}),a){const e=document.querySelector(`#limbo-instance-${s}`);e&&(e.style.display="none")}}},onCancel:()=>{const e=W(),t=(window.limboCore?.config?.getGlobal()||{}).mode||"embed";switch(o.onCropperCancelled&&o.onCropperCancelled({assetId:b?.id,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropperCancelled",{assetId:b?.id,instanceId:s}),e){case"with-gallery":y(null),g("gallery");break;case"upload-only":"modal"===t?window.limboCore?.modals?.closeAllModals():(y(null),g("upload"));break;case"crop-only":"modal"===t?window.limboCore?.modals?.closeAllModals():window.limboCore?.events&&window.limboCore.events.emit("cropperClosed",{instanceId:s,reason:"cancelled"})}},onDelete:()=>H(b?.id),onError:e=>{o.onCropperError&&o.onCropperError(e,s),window.limboCore?.events&&window.limboCore.events.emit("cropperError",{error:e,assetId:b?.id,instanceId:s}),console.error("Cropper error:",e)},deleting:$,onVariantCreated:(e,t)=>{U(e)}}),A.jsx(on,{isOpen:w,onClose:k})]})}class dn{constructor(e,t,n,r){this.id=e,this.config=t,this.eventManager=n,this.modalManager=r,this.root=null,this.container=null,this.modal=null,this.mounted=!1,this.destroyed=!1,this.button=null,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=$.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.modal.close(),this.eventManager.emit("modal:close",{instance:this})),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||"large",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=$.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 d.createElement("div",{id:`limbo-component-container-${this.id}`,className:"limbo-instance limbo-component-container-wrapper py-3","data-limbo-id":this.id,"data-limbo-mode":this.config.mode,"data-limbo-version":"2.0","data-limbo-isolated":"true","aria-label":"Limbo Image Manager",role:"region"},d.createElement(un,{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"}))}_createCallbacks(){return{onSelect:e=>{const t=this._createStandardPayload(e,"select");this.config.callbacks?.onSelect&&this.config.callbacks.onSelect(t),this._emitDOMEvent("select",t)},onUpload:e=>{const t=this._createStandardPayload(e,"upload");this.config.callbacks?.onUpload&&this.config.callbacks.onUpload(t),this._emitDOMEvent("upload",t)},onError:e=>{const t={instance:this,error:{message:e.message||"Unknown error",code:e.code||"UNKNOWN",timestamp:Date.now()}};this.config.callbacks?.onError&&this.config.callbacks.onError(t.error),this._emitDOMEvent("error",t)},onClose:()=>{const e={instance:this,timestamp:Date.now()};this.config.callbacks?.onClose&&this.config.callbacks.onClose(),this._emitDOMEvent("close",e)}}}_createStandardPayload(e,t){const n={instance:this,eventType:t,timestamp:Date.now(),instanceId:this.id,mode:this.config.mode,features:this.config.features};return e&&(e.assetId||e.id?(n.assetId=e.assetId||e.id,n.variants=e.variants||[],n.master=e.master||{urlSigned:e.url||e.urlSigned,width:e.width,height:e.height,mime:e.mime||e.mimeType},n.fileName=e.fileName||e.name,n.mime=e.mime||e.mimeType,n.width=e.width,n.height=e.height,n.fileBlob=e.fileBlob||e.file,n.metadata={uploadedBy:e.uploadedBy,uploadedAt:e.uploadedAt||e.timestamp,size:e.size,...e.metadata}):Object.assign(n,e)),n}_emitDOMEvent(e,t){const n=new CustomEvent(`limbo:${e}`,{detail:t,bubbles:!0,cancelable:!0});(this.getContainer()||document).dispatchEvent(n),this.eventManager.emit(e,t)}_validateConfig(){if(!(this.config.auth?.apiKey||this.config.auth?.publicKey||this.config.auth?.token||this.config.apiKey||this.config.publicKey||this.config.token))throw new Error(`LimboInstance ${this.id}: Authentication is required. Provide either auth.publicKey (recommended) or auth.apiKey (for server-side only)`);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 mn{constructor(){this.instances=new Map,this.counter=0}create(e,t,n){const r="limbo-"+ ++this.counter,a=new dn(r,e,t,n);return this.instances.set(r,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,n)=>{t.isContainerInDOM()||e.push(n)}),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 hn{constructor(){this.config=null,this.instances=new Map,this.observer=null,this.initialized=!1}configure(e,t,n){return this.config={dataset:e.dataset||"data-limbo-input-file",return:e.return||"url",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||"medium",theme:e.theme||"light",compact:e.compact||!1,maxSize:e.maxSize||"10MB",formats:e.formats||["jpg","jpeg","png","webp"],minWidth:e.minWidth||null,minHeight:e.minHeight||null,maxWidth:e.maxWidth||null,maxHeight:e.maxHeight||null,buttonText:e.buttonText||"Seleccionar Imagen",buttonClass:e.buttonClass||"limbo-auto-button",buttonStyle:e.buttonStyle||"primary",showPreview:!1!==e.showPreview,allowMultiple:e.allowMultiple||!1,autoAssign:!1!==e.autoAssign,...e},this.configManager=t,this.eventManager=n,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=`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 n=this._createButton(e);this._hideInput(e),this._insertButton(e,n),this.instances.set(t,{input:e,button:n,config:this._getInputConfig(e)}),this.eventManager.emit("autoInputs:processed",{inputId:t,input:e,button:n})}_createButton(e){const t=document.createElement("button"),n=this._getInputConfig(e);t.type="button",t.textContent=n.buttonText||this.config.buttonText;const r=[this.config.buttonClass];return n.buttonClass&&n.buttonClass!==this.config.buttonClass&&r.push(n.buttonClass),t.className=r.join(" "),this._styleButton(t,n),this._attachButtonEvents(t,e),t.setAttribute("aria-label",n.buttonText||this.config.buttonText),t.setAttribute("data-limbo-trigger","true"),t.setAttribute("data-limbo-input-id",n.inputId),n.disabled&&(t.disabled=!0),t}_styleButton(e,t){const n=t.buttonStyle||this.config.buttonStyle,r=t.theme||this.config.theme,a=t.compact||this.config.compact,i={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"},o={primary:{backgroundColor:"dark"===r?"#3b82f6":"#001978",color:"white",hoverBg:"dark"===r?"#2563eb":"#334793"},secondary:{backgroundColor:"dark"===r?"#374151":"#f3f4f6",color:"dark"===r?"#f9fafb":"#374151",border:"1px solid "+("dark"===r?"#4b5563":"#d1d5db"),hoverBg:"dark"===r?"#4b5563":"#e5e7eb"},outline:{backgroundColor:"transparent",color:"dark"===r?"#3b82f6":"#001978",border:"2px solid "+("dark"===r?"#3b82f6":"#001978"),hoverBg:"dark"===r?"#3b82f6":"#001978",hoverColor:"white"},ghost:{backgroundColor:"transparent",color:"dark"===r?"#f9fafb":"#374151",hoverBg:"dark"===r?"#374151":"#f3f4f6"}},s=o[n]||o.primary;Object.assign(e.style,{...i,...s});const l=s.backgroundColor,c=s.color;e.addEventListener("mouseenter",()=>{e.style.backgroundColor=s.hoverBg||s.backgroundColor,s.hoverColor&&(e.style.color=s.hoverColor),e.style.transform="translateY(-1px)",e.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor=l,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),n=this._createModalConfig(t);this.eventManager.emit("autoInputs:modalRequest",{input:e,config:n,callback:async t=>await this._handleImageSelection(e,t)})}async _handleImageSelection(e,t){const n=this._getInputConfig(e);try{const r=await this._formatImageData(t,n);!1!==n.autoAssign&&(e.value=r),e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:resultReady",{detail:{imageData:t,input:e,value:r,config:n,assignment:{format:n.return,smartAssign:!1!==n.smartAssign,autoAssign:!1!==n.autoAssign},legacy:{imageData:t,formatted:this._createFormattedResult(t,n)}},bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:imageSelected",{detail:{imageData:t,input:e,value:r,config:n,formatted:this._createFormattedResult(t,n)},bubbles:!0})),this.eventManager.emit("autoInputs:imageSelected",{input:e,imageData:t,value:r,config:n})}catch(r){console.error("Error handling image selection:",r),e.dispatchEvent(new CustomEvent("limbo:error",{detail:{error:r.message,input:e,imageData:t,config:n},bubbles:!0})),this._handleImageSelectionLegacy(e,t)}}_handleImageSelectionLegacy(e,t){const n=this._getInputConfig(e),r=this._formatImageData(t,n);!1!==n.autoAssign&&(e.value=r),e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:imageSelected",{detail:{imageData:t,input:e,value:r,config:n,formatted:this._createFormattedResult(t,n)},bubbles:!0})),this.eventManager.emit("autoInputs:imageSelected",{input:e,imageData:t,value:r,config:n})}_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){switch((t||{}).return||this.config.return||"url"){case"url":return e.url||e.path||"";case"base64":return e.base64||e.dataUrl||"";case"assetId":return e.assetId||e.id||"";case"fileName":return e.fileName||e.filename||"";case"object":return 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,created:e.created_at||e.created});default:return 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})}}_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||"medium",title:e.description||this.config.title||"Seleccionar imagen",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:{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},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;if(!t||"none"===t||"false"===t)return null;if("free"===t)return{aspectRatio:null,quality:e.quality||this.config.quality,format:e.format||this.config.format};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{aspectRatio:n[t],quality:e.quality||this.config.quality,format:e.format||this.config.format,minCropBoxWidth:e.minWidth||this.config.minWidth,minCropBoxHeight:e.minHeight||this.config.minHeight};if("string"==typeof t&&t.includes(":")){const[n,r]=t.split(":").map(Number);if(!isNaN(n)&&!isNaN(r)&&0!==r)return{aspectRatio:n/r,quality:e.quality||this.config.quality,format:e.format||this.config.format}}const r=parseFloat(t);return!isNaN(r)&&r>0?{aspectRatio:r,quality:e.quality||this.config.quality,format:e.format||this.config.format}:"object"==typeof t?{quality:e.quality||this.config.quality,format:e.format||this.config.format,...t}:null}_shouldShowTabs(e){const t=e.modeUI||this.config.modeUI||"full",n=e.features||this.config.features;return!["gallery-only","upload-only","crop-only","ia-only"].includes(t)&&(n&&n.length>1)}_getUIActions(e){const t=e.modeUI||this.config.modeUI||"full",n=e.features||this.config.features;let r=[];switch(t){case"gallery-only":case"upload-only":r=["select"];break;case"crop-only":r=["select","crop"];break;default:r=["select"],n.includes("cropper")&&r.push("crop"),n.includes("gallery")&&(r.push("download","copy"),this.config.allowDelete&&r.push("delete"))}return r}_getInputId(e){return e.id||e.name||`limbo-auto-${Date.now()}-${Math.random()}`}_validateInput(e){return e instanceof HTMLInputElement}_getInputConfig(e){const t=e=>e?e.split(",").map(e=>e.trim()):null,n=e=>{if(!e)return null;const t=e.match(/^(\d+(?:\.\d+)?)(MB|KB|B)?$/i);if(!t)return null;const n=parseFloat(t[1]);switch((t[2]||"B").toUpperCase()){case"MB":return 1024*n*1024;case"KB":return 1024*n;default:return n}},r=(e,t=!1)=>null===e?t:"true"===e||"1"===e||""===e,a=e=>e?parseFloat(e):null;return{return:e.getAttribute("data-limbo-return")||this.config.return,mode:e.getAttribute("data-limbo-mode")||this.config.mode,features:t(e.getAttribute("data-limbo-features"))||this.config.features,crop:e.getAttribute("data-limbo-crop")||this.config.crop,quality:a(e.getAttribute("data-limbo-quality"))||this.config.quality,format:e.getAttribute("data-limbo-format")||this.config.format,modeUI:e.getAttribute("data-limbo-mode-ui")||this.config.modeUI,modalSize:e.getAttribute("data-limbo-modal-size")||this.config.modalSize,theme:e.getAttribute("data-limbo-theme")||this.config.theme,compact:r(e.getAttribute("data-limbo-compact"),this.config.compact),maxSize:n(e.getAttribute("data-limbo-max-size"))||n(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.getAttribute("data-limbo-button-text")||this.config.buttonText,buttonStyle:e.getAttribute("data-limbo-button-style")||this.config.buttonStyle,buttonClass:e.getAttribute("data-limbo-button-class")||this.config.buttonClass,showPreview:r(e.getAttribute("data-limbo-show-preview"),this.config.showPreview),allowMultiple:r(e.getAttribute("data-limbo-allow-multiple"),this.config.allowMultiple),autoAssign:r(e.getAttribute("data-limbo-auto-assign"),this.config.autoAssign),placeholder:e.getAttribute("data-limbo-placeholder"),description:e.getAttribute("data-limbo-description"),required:r(e.getAttribute("data-limbo-required"),!1),disabled:r(e.getAttribute("data-limbo-disabled"),!1),inputId:e.id||e.name||this._generateInputId(e),inputName:e.name,inputType:e.type}}_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=`input[${this.config.dataset}]`;e.matches&&e.matches(t)&&this._processInput(e);const n=e.querySelectorAll&&e.querySelectorAll(t);n&&n.forEach(e=>this._processInput(e))}}class pn{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 n=this.listeners.get(e);if(n){const e=n.indexOf(t);e>-1&&n.splice(e,1)}}cleanup(){this.listeners.clear()}_emitDOMEvent(e,t){const n=new CustomEvent(`limbo:${e}`,{detail:{...t,timestamp:Date.now()},bubbles:!0,cancelable:!0});(t.instance?.getContainer()||document).dispatchEvent(n)}_executeListeners(e,t){const n=this.listeners.get(e);n&&n.forEach(n=>{try{n(t)}catch(r){console.error(`Error executing listener for ${e}:`,r)}})}getStats(){const e={};return this.listeners.forEach((t,n)=>{e[n]=t.length}),e}}class fn{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 gn(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)}_handleGlobalKeydown(e){const t=this.getActiveModal();t&&("Escape"===e.key&&(e.preventDefault(),t.close()),"Tab"===e.key&&this._handleTabTrap(e,t))}_handleTabTrap(e,t){const n=t.getFocusableElements();if(0===n.length)return;const r=n[0],a=n[n.length-1];e.shiftKey?document.activeElement===r&&(e.preventDefault(),a.focus()):document.activeElement===a&&(e.preventDefault(),r.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 gn{constructor(e,t,n){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},this.manager=n,this.element=null,this.backdrop=null,this.isOpen=!1,this.previousFocus=null,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-modal limbo-modal--${this.config.size}`,this.element.id=this.id,this.element.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: 400px;",medium:e?"width: 100%; height: 100%;":"max-width: 600px;",large:e?"width: 100%; height: 100%;":"max-width: 800px;",xlarge:e?"width: 100%; height: 100%;":"max-width: 1200px;"},n=e?`\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n transform: translateY(100%);\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: 1;\n transition: transform 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 n=document.createElement("h2");if(n.id=`${this.id}-title`,n.className="limbo-modal-title",n.textContent=this.config.title,n.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(n),this.config.showCloseButton){const n=document.createElement("button");n.type="button",n.className="limbo-modal-close",n.innerHTML="✕",n.setAttribute("aria-label","Cerrar modal"),n.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 `,n.addEventListener("mouseenter",()=>{n.style.backgroundColor="#f8f9fa",n.style.color="#001978"}),n.addEventListener("mouseleave",()=>{n.style.backgroundColor="transparent",n.style.color="#6c757d"}),n.addEventListener("click",()=>this.close()),e.appendChild(n)}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&&("string"==typeof this.config.content?t.innerHTML=this.config.content: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";const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);return requestAnimationFrame(()=>{this.backdrop&&(this.backdrop.style.opacity="1"),this.element.style.opacity="1",this.element.style.transform=e?"translateY(0%)":"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);return this.backdrop&&(this.backdrop.style.opacity="0"),this.element.style.opacity="0",this.element.style.transform=e?"translateY(100%)":"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}}_cleanup(){document.body.style.overflow=this._originalBodyOverflow||"",this.previousFocus&&"function"==typeof this.previousFocus.focus&&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 bn{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 n=this._getTheme(e);if(!n)return console.warn(`Theme '${e}' not found`),!1;const r=this.currentTheme;return this._applyThemeVariables(n,t.scope),this._updateThemeAttributes(n.name),this.config.theme.storage&&!t.temporary&&this._saveThemePreference(n.name),this.currentTheme=n.name,this._triggerChangeCallbacks(n.name,r),!0}toggleTheme(e="light",t="dark"){const n=this.currentTheme===e?t:e;return this.applyTheme(n)}applyAutoTheme(){const e=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";return this.applyTheme(e)}registerTheme(e,t){const n={name:e,displayName:t.displayName||e,variables:t.variables||{},extends:t.extends||null,...t};if(n.extends){const e=this._getTheme(n.extends);e&&(n.variables={...e.variables,...n.variables})}return this.customThemes.set(e,n),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),n="ontouchstart"in window||navigator.maxTouchPoints>0;return!(!this.config.compact.forceOnMobile||!t&&!n)||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(n){console.error("Error in compact mode change callback:",n)}})}_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 n=document.querySelector(t);if(n){const t=this._extractCSSVariables(n);Object.keys(t).length>0&&(e.variables={...e.variables,...t});const r=n.getAttribute("data-theme")||n.getAttribute("class")?.match(/theme-(\w+)/)||n.getAttribute("class")?.match(/(\w+)-theme/);r&&(e.detectedName=Array.isArray(r)?r[1]:r)}}return Object.keys(e.variables).length>0?e:null}_extractCSSVariables(e){const t={},n=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 r=`--limbo-${e}`,a=n.getPropertyValue(r).trim();a&&(t[r]=a)});return["--primary-color","--background-color","--text-color","--border-color","--accent-color","--surface-color"].forEach(e=>{const r=n.getPropertyValue(e).trim();if(r){const n=this._mapGenericToLimbo(e,r);n&&Object.assign(t,n)}}),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 n=this._inheritPortalTheme();n&&(e=n),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 n="string"==typeof t?document.querySelector(t):t;n?(Object.entries(e.variables).forEach(([e,t])=>{n.style.setProperty(e,t),this.appliedStyles.add(`${n.tagName}:${e}`)}),this.themeCache.set(e.name,{theme:e,appliedAt:Date.now(),scope:n})):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 n=t.variables["--limbo-primary"]||"#3b82f6";let r=document.querySelector('meta[name="theme-color"]');r||(r=document.createElement("meta"),r.name="theme-color",document.head.appendChild(r)),r.content=n}_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),n={};return Object.keys(e.variables).forEach(e=>{n[e]=t.getPropertyValue(e).trim()}),n}_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(n=>{try{n({theme:e,previousTheme:t,themeData:this._getTheme(e),variables:this._getCurrentVariables()})}catch(r){console.error("Error in theme change callback:",r)}})}generateThemeFromColors(e,t){const n={name:e,displayName:e,variables:{}};t.primary&&(n.variables["--limbo-primary"]=t.primary,n.variables["--limbo-primary-hover"]=this._darkenColor(t.primary,10),n.variables["--limbo-primary-light"]=this._lightenColor(t.primary,40),n.variables["--limbo-primary-dark"]=this._darkenColor(t.primary,20)),t.background&&(n.variables["--limbo-bg-primary"]=t.background,n.variables["--limbo-bg-secondary"]=this._lightenColor(t.background,5),n.variables["--limbo-bg-tertiary"]=this._lightenColor(t.background,10),n.variables["--limbo-bg-card"]=t.background),t.text&&(n.variables["--limbo-text-primary"]=t.text,n.variables["--limbo-text-secondary"]=this._lightenColor(t.text,20),n.variables["--limbo-text-tertiary"]=this._lightenColor(t.text,40));const r=this._getTheme(this.config.inheritance.fallbackTheme);return r&&(n.variables={...r.variables,...n.variables}),this.registerTheme(e,n),n}_darkenColor(e,t){const n=parseInt(e.replace("#",""),16),r=Math.round(2.55*t),a=(n>>16)-r,i=(n>>8&255)-r,o=(255&n)-r;return"#"+(16777216+65536*(a<255?a<1?0:a:255)+256*(i<255?i<1?0:i:255)+(o<255?o<1?0:o:255)).toString(16).slice(1)}_lightenColor(e,t){const n=parseInt(e.replace("#",""),16),r=Math.round(2.55*t),a=(n>>16)+r,i=(n>>8&255)+r,o=(255&n)+r;return"#"+(16777216+65536*(a<255?a<1?0:a:255)+256*(i<255?i<1?0:i:255)+(o<255?o<1?0:o:255)).toString(16).slice(1)}_deepMerge(e,t){const n={...e};return Object.keys(t).forEach(r=>{t[r]&&"object"==typeof t[r]&&!Array.isArray(t[r])?n[r]=this._deepMerge(e[r]||{},t[r]):n[r]=t[r]}),n}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 yn=new class{constructor(){this.config=new n,this.instances=new mn,this.autoInputs=new hn,this.events=new pn,this.modals=new fn,this.theme=new bn,this.containerQueryDetector=P,this._setupInternalListeners(),this._initializeContainerQueries()}configure(e){var t;return this.config.setGlobal(e),t={publicKey:e.publicKey,apiKey:e.apiKey,token:e.token,authMode:e.authMode||"manual",prod:e.prod||!1,mode:e.mode||"embed",callbacks:e.callbacks||null},R={...R,...t},R.authMode||(R.token?R.authMode="manual":R.authMode="session"),this.config}setToken(e){return function(e){R.token=e}(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",n=e||`[${t}]`,r=document.querySelectorAll(n);if(0===r.length)return{found:0,processed:0,skipped:0};let a=0,i=0;return r.forEach(e=>{try{this.autoInputs._processInput(e),a++}catch(t){console.warn(`⚠️ Limbo: Error procesando input ${e.id||e.name}:`,t),i++}}),this.events.emit("limbo:scanCompleted",{found:r.length,processed:a,skipped:i,inputs:Array.from(r)}),{found:r.length,processed:a,skipped:i}}_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",n=e.querySelectorAll(`[${t}]`);let r=0;return n.forEach(e=>{if(!this.autoInputs.instances.has(this.autoInputs._getInputId(e)))try{this.autoInputs._processInput(e),r++}catch(t){console.warn("⚠️ Limbo: Error procesando nuevo input:",t)}}),r}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})=>{this._handleAutoInputModalRequest({config:e,callback:t})})}_handleAutoInputModalRequest({config:e,callback:t}){const n=this.create({...e,mode:"modal",autoDestroy:!0,callbacks:{onSelect:e=>{t(e),n.close()},onClose:()=>{}}});n.open()}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"},callbacks:{onSelect:n=>{e.onSelect?.(n),!1!==e.autoClose&&t.close()}},...e});return t.open(),t}openUploader(e={}){const t=!1!==e.redirectToGallery?["upload","gallery"]:["upload"],n=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"},callbacks:{onUpload:t=>{e.onUpload?.(t),!1===e.autoClose||e.redirectToGallery||n.close()}},...e});return n.open(),n}openCropper(e,t={}){if(!e)throw new Error("Limbo.openCropper: imageUrl es requerido");const n={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()}`},r=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&&r.close()},onCropperCancelled:e=>{t.onCancelled?.(e),!1!==t.autoClose&&r.close()},onCropperError:e=>{t.onError?.(e)}},_externalImage:n,...t});return r.open(),r}createInlineGallery(e,t={}){return this.create({container:e,mode:"embed",modeUI:"gallery-only",features:["gallery"],callbacks:{onSelect:t.onSelect,onDelete:t.onDelete},...t})}createInlineUploader(e,t={}){return this.create({container:e,mode:"embed",modeUI:"upload-only",features:["upload"],callbacks:{onUpload:t.onUpload},...t})}createStandaloneCropper(e,t,n={}){if(!e)throw new Error("Limbo.createStandaloneCropper: container es requerido");if(!t)throw new Error("Limbo.createStandaloneCropper: imageUrl es requerido");const r={url:t,filename:n.filename||"image.jpg",width:n.width||1920,height:n.height||1080,mime_type:n.mimeType||"image/jpeg",id:n.assetId||`external-${Date.now()}`};return this.create({container:e,mode:"embed",modeUI:"crop-only",features:["cropper"],autoHideOnComplete:!1!==n.autoHideOnComplete,cropper:{mandatoryCrops:n.mandatoryCrops||[],allowCustomCrops:!1!==n.allowCustomCrops,enforceRequiredCrops:!1!==n.enforceRequiredCrops},callbacks:{onCropperComplete:n.onComplete,onCropperCancelled:n.onCancelled,onCropperError:n.onError},_externalImage:r,...n})}createFullSelector(e,t={}){return this.create({container:e,mode:t.mode||"embed",modeUI:"full",features:["gallery","upload","cropper"],callbacks:{onSelect:t.onSelect,onUpload:t.onUpload,onDelete:t.onDelete,onCropsSaved:t.onCropsSaved},...t})}};"undefined"!=typeof window&&(window.Limbo=yn);return"undefined"!=typeof window&&document.querySelector("#root")&&(yn.configure({prod:!1,publicKey:"pk_e464fd744106b7a8d63d453c4bd02582",authMode:"session"}),yn.create({container:"#root",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],title:"Limbo Image Manager - Development",url:!0}),yn.configureAutoInputs({dataset:"data-limbo-input-file",return:"url",features:["gallery","upload","cropper"],modeUI:"full",modalSize:"large",title:"Seleccionar imagen",crops:"free",allowDelete:!1})),yn});
3
+ Lt.$define(),Vt.$define(),Wt.$define(),qt.$define(),Dt.$define(),Ht.$define(),Ut.$define(),Jt.$define();class en{constructor(e,t,n){this.canvasRef=e,this.imageRef=t,this.selectionRef=n}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(n){return console.warn("Error moving image:",n),!1}},moveTo:(e,t)=>{if(!this.image)return!1;try{return this.image.$moveTo(e,t),!0}catch(n){return console.warn("Error moving image to position:",n),!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(n){return console.warn("Error scaling image:",n),!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,n,r,a,i)=>{if(!this.image)return!1;try{return this.image.$setTransform(e,t,n,r,a,i),!0}catch(o){return console.warn("Error setting transform:",o),!1}},resetZoom:()=>{if(!this.image)return!1;try{const e=this.image.$getTransform();if(!e)return!1;const[t,n,r,a,i,o]=e,s=Math.sqrt(t*t+n*n),l=Math.sqrt(r*r+a*a),c=t/s,u=n/s,d=r/l,m=a/l;return this.image.$setTransform(c,u,d,m,i,o),!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[n,r,a,i,o,s]=t,l=Math.sqrt(n*n+r*r),c=Math.sqrt(a*a+i*i),u=n/l*e,d=r/l*e,m=a/c*e,h=i/c*e;return this.image.$setTransform(u,d,m,h,o,s),!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,n]=e;return Math.sqrt(t*t+n*n)}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 n=this.image.querySelector("img")||this.image;if(!n?.naturalWidth||!n?.naturalHeight)return!1;const r=1-e,a=t.width*r/n.naturalWidth,i=t.height*r/n.naturalHeight,o=Math.min(a,i,1);return this.transform.setZoom(o)}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[n,r]=e.split("/").map(e=>parseFloat(e.trim()));if(isNaN(n)||isNaN(r)||0===r)return console.warn("Invalid aspect ratio format:",e),!1;t=n/r}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(n){return console.warn("Error moving selection:",n),!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,n,r,a)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$change(e,t,n,r,a),!0}catch(i){return console.warn("Error changing selection:",i),!1}},set:(e,t,n,r)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.x=e,this.selectionElement.y=t,this.selectionElement.width=n,this.selectionElement.height=r,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,n,r,a,i,o]=e;return this.transform.setTransform(-t,n,r,a,i,o)},flipVertical:()=>{const e=this.transform.getTransform();if(!e)return!1;const[t,n,r,a,i,o]=e;return this.transform.setTransform(t,n,r,-a,i,o)},setupInitialView:async(e={})=>{const{paspartuFactor:t=.85,retries:n=3,retryDelay:r=200}=e;return new Promise(e=>{const a=(i=0)=>{if(!this.isReady)return i<n?void setTimeout(()=>a(i+1),r):void e(!1);try{const o=this.canvasElement.getBoundingClientRect();let s=this.image.querySelector("img")||this.image;if(!s?.naturalWidth||!s?.naturalHeight)return i<n?void setTimeout(()=>a(i+1),r):(this.transform.center(),void e(!1));if(o.width>0&&o.height>0){const n=o.width*t/s.naturalWidth,r=o.height*t/s.naturalHeight,a=Math.min(n,r,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(o){console.warn("Error in setup:",o),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:n,onAction:r,onActionStart:a,onActionMove:i,onActionEnd:o}=e,s=[];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),s.push(()=>{this.selectionElement&&this.selectionElement.removeEventListener("change",e)})}if(n&&this.image){const e=e=>{n({matrix:e.detail.matrix,oldMatrix:e.detail.oldMatrix})};this.image.addEventListener("transform",e),s.push(()=>{this.image&&this.image.removeEventListener("transform",e)})}if(this.canvasElement){if(r){const e=e=>r(e.detail);this.canvasElement.addEventListener("action",e),s.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("action",e)})}if(a){const e=e=>a(e.detail);this.canvasElement.addEventListener("actionstart",e),s.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("actionstart",e)})}if(i){const e=e=>i(e.detail);this.canvasElement.addEventListener("actionmove",e),s.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("actionmove",e)})}if(o){const e=e=>o(e.detail);this.canvasElement.addEventListener("actionend",e),s.push(()=>{this.canvasElement&&this.canvasElement.removeEventListener("actionend",e)})}}return()=>{s.forEach(e=>e())}}}async function tn(e,t,n={}){const{format:r=null,originalFormat:a="webp",onSuccess:i=null,onError:o=null,accessibilityManager:s=null}=n;try{const n=window.limboCore?.config?.getGlobal(),o=r||n?.downloadFormat||a||"webp",l=`${t.split(".")[0]}.${o}`;if(s&&s.announce(`Descargando ${l}`),e.startsWith("data:image/"))return function(e,t){const n=document.createElement("a");n.href=e,n.download=t,n.style.display="none",document.body.appendChild(n),n.click(),setTimeout(()=>{document.body.removeChild(n)},100)}(e,l),i&&i(l),s&&s.announce(`${l} descargado correctamente`),!0;const c=await fetch(e,{mode:"cors"});if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);const u=await c.blob();let d=u;const m=u.type;m!==`image/${"jpg"===o?"jpeg":o}`&&function(e){return["webp","jpeg","jpg","png"].includes(e.toLowerCase())}(o)&&(d=await async function(e,t){return new Promise((n,r)=>{const a=new Image,i=URL.createObjectURL(e);a.onload=()=>{try{const r=document.createElement("canvas");r.width=a.width,r.height=a.height;r.getContext("2d").drawImage(a,0,0);const o=`image/${"jpg"===t?"jpeg":t}`,s="png"===t?void 0:.92;r.toBlob(t=>{URL.revokeObjectURL(i),n(t||e)},o,s)}catch(r){URL.revokeObjectURL(i),n(e)}},a.onerror=()=>{URL.revokeObjectURL(i),n(e)},a.src=i})}(u,o));const h=window.URL.createObjectURL(d),p=document.createElement("a");return p.href=h,p.download=l,p.style.display="none",document.body.appendChild(p),p.click(),setTimeout(()=>{window.URL.revokeObjectURL(h),document.body.removeChild(p)},100),i&&i(l),s&&s.announce(`${l} descargado correctamente`),!0}catch(l){return console.error("Error downloading image:",l),o&&o(l),s&&s.announce(`Error al descargar la imagen: ${l.message}`),!1}}const nn=Object.freeze(Object.defineProperty({__proto__:null,default:tn,downloadImage:tn},Symbol.toStringTag,{value:"Module"}));function rn({image:e,onSave:t,onCancel:n,onDelete:r,onError:a=null,deleting:i=!1,onVariantCreated:o=null}){const[s,l]=u.useState(!1),[c,d]=u.useState(null),[m,h]=u.useState(!1),[p,f]=u.useState(!0),[g,b]=u.useState(!0),[y,v]=u.useState({horizontal:!1,vertical:!1}),[x,w]=u.useState(!1),[k,S]=u.useState(!0),[C,E]=u.useState(!0),[N,j]=u.useState(!0),[_,$]=u.useState({current:1,percentage:100}),[z]=u.useState(()=>{const[t]=e.filename.split(".");return t}),T=u.useMemo(()=>{const e=window.limboCore?.config?.getGlobal()||{};return{mandatoryCrops:e.cropper?.mandatoryCrops||[],allowCustomCrops:!1!==e.cropper?.allowCustomCrops,showDimensionInputs:!0===e.cropper?.showDimensionInputs}},[]),[P,M]=u.useState(()=>T.mandatoryCrops.length>0?T.mandatoryCrops.map((e,t)=>({id:`crop-${t}`,label:e.label,width:e.width,height:e.height,required:!1!==e.required,isCustom:!1,confirmed:!1,savedState:null})):[{id:"crop-default-0",label:z,width:e.width||1920,height:e.height||1080,required:!1,isCustom:!0,confirmed:!1,savedState:null}]),[I,L]=u.useState(0),O=P[I],[R,D]=u.useState(!1),F=u.useMemo(()=>O&&O.width&&O.height?O.width/O.height:"",[O]),U=u.useMemo(()=>{const e=50;if(!F||""===F)return{minWidth:e,minHeight:e};if(F>=1){return{minWidth:e,minHeight:e/F}}return{minWidth:e*F,minHeight:e}},[F]),[q,B]=u.useState(!1),[H,W]=u.useState([]),[V,K]=u.useState(null),G=window.limboCore?.accessibilityManager,{createCropVariant:Q,loading:Y,error:X}=Zt(),J=((e,t={})=>{const n=u.useRef(null),r=u.useRef(null),a=u.useRef(null),i=u.useRef(null),[o,s]=u.useState(null),[l,c]=u.useState(null),[d,m]=u.useState(!1),[h,p]=u.useState(!0),[f,g]=u.useState(0),b={aspectRatio:"",shade:!0,paspartuFactor:.85,...t};u.useEffect(()=>{n.current&&r.current&&a.current&&(i.current=new en(n,r,a),m(!0))},[]),u.useEffect(()=>{if(i.current)return i.current.setupEventListeners({onSelectionChange:e=>{s(e)},onImageTransform:()=>{g(e=>e+1)}})},[d]),u.useEffect(()=>{i.current&&e&&(async()=>{i.current.selection.setAspectRatio(b.aspectRatio),i.current.canvas.setBackground(b.shade),await i.current.utils.setupInitialView({paspartuFactor:b.paspartuFactor});const e=await i.current.utils.checkExportability();p(e);const t=r.current?.querySelector("img")||r.current;t?.naturalWidth&&t?.naturalHeight&&c({naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,currentWidth:t.width,currentHeight:t.height})})()},[e,b.aspectRatio,b.shade,b.paspartuFactor]);const y=u.useCallback(()=>({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}),[]),v=u.useCallback(()=>({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=u.useCallback(()=>({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:r,selectionRef:a},state:{cropData:o,imageInfo:l,isReady:d,canExport:h,transformVersion:f},transform:y(),selection:v(),utils:x(),manager:i.current}})(e,{aspectRatio:F||null,showGrid:p,shade:g,initialCoverage:.5,paspartuFactor:.85}),{refs:Z,state:ee,transform:te,selection:ne,utils:re}=J,{canvasRef:ae,imageRef:ie,selectionRef:oe}=Z,{cropData:se,imageInfo:le,canExport:ce,transformVersion:ue}=ee,de=u.useMemo(()=>le||{naturalWidth:e.width||1920,naturalHeight:e.height||1080,currentWidth:e.width||1920,currentHeight:e.height||1080},[le,e.width,e.height]),me=u.useCallback(()=>f(e=>!e),[]),he=u.useCallback(()=>b(e=>!e),[]),pe=u.useCallback(()=>w(e=>!e),[]),fe=u.useCallback(()=>S(e=>!e),[]),ge=u.useCallback(()=>E(e=>!e),[]),be=u.useCallback(()=>j(e=>!e),[]),ye=u.useCallback(()=>te.center(),[te]),ve=u.useCallback(()=>ne.center(),[ne]),xe=u.useCallback(()=>ne.reset(),[ne]),we=u.useCallback((e,t)=>te.move(e,t),[te]),ke=u.useCallback(e=>te.zoom(e),[te]),Se=u.useCallback(e=>te.rotate(e),[te]),Ce=u.useCallback(e=>{ne.setCoverage(e)},[ne]),Ee=u.useCallback(()=>re.resetZoomOnly(),[re]),Ne=u.useCallback(()=>{v(e=>{const t=!e.horizontal;return te.flipHorizontal(),{...e,horizontal:t}})},[te]),je=u.useCallback(()=>{v(e=>{const t=!e.vertical;return te.flipVertical(),{...e,vertical:t}})},[te]),_e=u.useCallback(()=>{if(J.manager&&ee.isReady)try{const e=se?{...se}:null,t=J.manager.transform.getZoom(),n={cropData:e,transforms:{zoom:t,rotation:J.manager.transform.getRotation(),flipHorizontal:y.horizontal,flipVertical:y.vertical}};return M(e=>e.map((e,t)=>t===I?{...e,savedState:n}:e)),n}catch(e){return console.warn("Error saving crop state:",e),null}},[J.manager,ee.isReady,se,y,I]),$e=u.useCallback(e=>{if(J.manager&&ee.isReady&&e)try{const{cropData:t,transforms:n}=e;if(n&&(re.resetAll(),n.zoom&&1!==n.zoom&&J.manager.transform.setZoom(n.zoom),n.rotation&&0!==n.rotation&&J.manager.transform.setRotation(n.rotation),n.flipHorizontal&&J.manager.transform.flipHorizontal(),n.flipVertical&&J.manager.transform.flipVertical(),v({horizontal:n.flipHorizontal||!1,vertical:n.flipVertical||!1})),t){const{x:e,y:n,width:r,height:a}=t;ne.set(e,n,r,a)}}catch(t){console.warn("Error restoring crop state:",t)}},[J.manager,ee.isReady,ne,re]),ze=u.useCallback(()=>{for(let e=0;e<P.length;e++){const t=P[e];if(!t.label||""===t.label.trim())return e}return-1},[P]),Te=u.useCallback(e=>{e!==I&&(_e(),L(e),D(!0))},[I,_e]),Ae=u.useCallback(()=>{if(!T.allowCustomCrops)return void alert("No se pueden añadir recortes personalizados en este modo.");_e();const t={id:`crop-custom-${Date.now()}`,label:`Recorte ${P.length+1}`,width:e.width||1920,height:e.height||1080,required:!1,isCustom:!0,confirmed:!1,savedState:null};M(e=>[...e,t]),L(P.length),G?.announce(`Nuevo recorte personalizado añadido: ${t.label}`)},[T.allowCustomCrops,_e,P.length,e.width,e.height,G]),Pe=u.useCallback((e,t)=>{const n=parseInt(t,10);""===t||isNaN(n)||M(t=>t.map((t,r)=>r===I?{...t,[e]:n}:t))},[I]),Me=u.useCallback(e=>{const t=O[e];let n=100;if(ae.current&&le){const e=ae.current.getBoundingClientRect(),t=Math.min(e.width,e.height);n=Math.max(100,Math.round(.05*t))}const r=Math.max(n,Math.min(5e3,t));r!==t&&M(t=>t.map((t,n)=>n===I?{...t,[e]:r}:t));const a={...O,[e]:r},i=a.width/a.height,o=ne.getData?.();ne.setAspectRatio(i),o&&void 0!==o.x&&setTimeout(()=>{ne.set?.(o.x,o.y,o.width,o.height)},50)},[I,O,ne,ae,le]),Ie=u.useCallback(e=>{M(t=>t.map((t,n)=>n===I?{...t,label:e}:t))},[I]),Le=u.useCallback(e=>{const t=P[e];if(t.required)alert("No se puede eliminar un recorte obligatorio.");else if(1!==P.length){if(M(t=>t.filter((t,n)=>n!==e)),e===I){const t=Math.max(0,e-1);L(t)}else e<I&&L(e=>e-1);G?.announce(`Recorte ${t.label} eliminado`)}else alert("Debe haber al menos un recorte.")},[P,I,G]),Oe=u.useCallback(async()=>{if(!ce)return null;try{const t=await ne.toCanvas({width:800,height:600,imageSmoothingEnabled:!0,imageSmoothingQuality:"high"});return t?t.toDataURL(`image/${globalThis.downloadFormat||e.mime_type.split("/")[1]||"webp"}`,.9):null}catch(t){return console.warn("Error generating preview:",t),null}},[ce,e.mime_type,ne]),Re=u.useCallback(async()=>{if(s)return l(!1),d(null),void h(!1);if(ce){l(!0),h(!0);try{const e=await Oe();e?d(e):(l(!1),alert("No se puede exportar el recorte por restricciones de CORS en la imagen original."))}finally{h(!1)}}else alert("No se puede exportar el recorte por restricciones de CORS en la imagen original.")},[ce,Oe,s]),De=u.useCallback(async()=>{if(!ce){const e="No se puede exportar el recorte por restricciones de CORS en la imagen original.";return G?.announceError(e),void alert(e)}if(!ee.isReady){const e="El cropper aún no está inicializado. Espera un momento e inténtalo de nuevo.";return G?.announceError(e),void alert(e)}G?.announce("Creando recorte de la imagen");try{if(!se||!de)throw console.error("❌ Datos faltantes:",{cropData:se,effectiveImageInfo:de}),new Error(`No hay datos de recorte disponibles. CropData: ${!!se}, ImageInfo: ${!!de}`);if(!se.x&&0!==se.x||!se.y&&0!==se.y||!se.width||!se.height)throw console.error("❌ CropData inválido:",se),new Error("Los datos de recorte no tienen las propiedades esperadas");if(!de.naturalWidth||!de.naturalHeight)throw console.error("❌ ImageInfo inválido:",de),new Error("Los datos de imagen no tienen las dimensiones esperadas");const{x:n,y:r,width:a,height:i}=se,{naturalWidth:s,naturalHeight:l}=de,c={x:n/s,y:r/l,width:a/s,height:i/l},u=Math.min(O.width,5e3),d=Math.min(O.height,5e3),m=Date.now(),h=`${z}_${O.label||"crop"}_${m}`,p=await Q(e.id,c,{name:h,width:u,height:d,format:globalThis.downloadFormat||"webp",quality:90});p&&(G?.announceSuccess(`Recorte creado: ${h}`),o?.(e.id,p),t(p))}catch(n){console.warn("Error creating crop variant:",n);const e="No se pudo crear el recorte. Inténtalo de nuevo.";G?.announceError(e),alert(e),a?.(n)}},[ce,ee.isReady,G,se,de,z,O.label,O.width,O.height,Q,e.id,o,t,a]),Fe=u.useCallback(async()=>{const e=ze();if(-1!==e){const t=P[e];return alert(`El recorte "${t.label||t||"(sin nombre)"}" debe tener un nombre válido.`),void L(e)}if(P.length>1)return K("save"),W(P.map((e,t)=>t)),void B(!0);await De()},[ze,P,De]),Ue=u.useCallback(async()=>{if(!ce){const e="No se puede descargar el recorte por restricciones de CORS en la imagen original.";return G?.announceError(e),void alert(e)}try{G?.announce("Preparando descarga del recorte");let e=c;if(e||(e=await Oe()),!e)throw new Error("No se pudo generar la imagen para descargar");const t=O.label.replace(/\.[^/.]+$/," ").replace(" ","-").trim(),n=`${z}_${t||"crop"}`;await tn(e,n,{accessibilityManager:G,onSuccess:e=>{G?.announce(`Recorte descargado como ${e}`)},onError:e=>{G?.announceError(`Error al descargar: ${e.message}`),alert(`Error al descargar la imagen: ${e.message}`)}})}catch(e){console.error("Error downloading crop:",e),G?.announceError(`Error al descargar el recorte: ${e.message}`),alert(`Error al descargar el recorte: ${e.message}`)}},[ce,G,c,O.label,z,Oe]),qe=u.useCallback(async()=>{const e=ze();if(-1!==e){const t=P[e];return alert(`El recorte "${t.label||t||"(sin nombre)"}" debe tener un nombre válido.`),void L(e)}if(P.length>1)return K("download"),W(P.map((e,t)=>t)),void B(!0);await Ue()},[ze,P,Ue]);return u.useEffect(()=>{l(!1),d(null)},[e]),u.useEffect(()=>{J.manager&&(F&&ne.setAspectRatio(F),re.setBackground(g))},[F,g,J.manager,ne,re]),u.useEffect(()=>{if(!J.manager||!ee.isReady)return;const e=O?.savedState;e?($e(e),D(!1)):F&&(ne.setAspectRatio(F),R&&setTimeout(()=>{ne.center(),D(!1)},100))},[I,O,F,J.manager,ee.isReady,$e,ne,R]),u.useEffect(()=>{if(!le||!ee.isReady||T.mandatoryCrops.length>0)return;const e=P[0];if(e&&"crop-default-0"===e.id&&(1920===e.width||1080===e.height)){const t=Math.min(le.naturalWidth,5e3),n=Math.min(le.naturalHeight,5e3);M([{...e,width:t,height:n}]),console.log(`[CropperView] Crop por defecto actualizado a ${t}×${n}px`)}},[le,ee.isReady,T.mandatoryCrops.length,P]),u.useEffect(()=>{if(J.manager&&J.manager.utils)try{const e=J.manager.transform.getZoom(),t={current:e,isZoomedIn:e>1,isZoomedOut:e<1,percentage:Math.round(100*e)};$(t)}catch(e){console.warn("Error updating zoom info:",e)}},[ue,J.manager]),u.useEffect(()=>{if(!s||!ce)return;const e=setTimeout(async()=>{h(e=>!c&&!e||e);try{const e=await Oe();e&&d(e)}finally{h(!1)}},300);return()=>{clearTimeout(e),h(!1)}},[se,ue,s,ce,Oe,F,y,c]),u.useEffect(()=>{const e=ae.current,t=t=>{if("Delete"===t.key||"Backspace"===t.key||"Backspace"===t.key&&t.metaKey||"Backspace"===t.key&&t.ctrlKey){const n=t.target;if(e&&(n===e||n===document.body||n===document.documentElement||"CROPPER-CANVAS"===n.tagName||"CROPPER-SELECTION"===n.tagName||"CROPPER-IMAGE"===n.tagName||"CROPPER-HANDLE"===n.tagName||"CROPPER-GRID"===n.tagName||n.closest("cropper-canvas")||e.contains(n)))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)}},[ae]),e?A.jsxs("div",{className:"limbo-cropper-view px-2 border-2 border-gray-200/50 rounded-lg min-w-fit max-w-7xl mx-auto h-full min-h-full flex flex-col",children:[A.jsxs("div",{className:"limbo-cropper-header flex flex-col sm:flex-row justify-between items-start sm:items-center p-4 lg:p-6 pb-4 border-b border-gray-200 bg-white z-10 flex-shrink-0 gap-4 lg:gap-2",children:[A.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("h2",{className:"text-lg sm:text-xl font-bold text-gray-800",children:"Generar recortes"}),P.length>1&&A.jsx("span",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 text-xs font-semibold rounded",children:O.label})]}),A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("label",{className:"text-xs text-gray-500 whitespace-nowrap",children:"Nombre:"}),A.jsx("div",{className:"",children:z+"."+(globalThis.downloadFormat||e.mime_type.split("/")[1]||"webp")})]})]}),A.jsxs("div",{className:"flex flex-row self-end gap-2 w-full sm:w-auto",children:[A.jsx("button",{onClick:n,disabled:Y,className:"limbo-btn limbo-btn-secondary px-4 sm:py-1 h-min flex-1","aria-label":"Cancelar y volver",title:"Cancelar y volver",children:"Cancelar"}),A.jsx("button",{onClick:()=>r?.(e),disabled:i|Y,className:"limbo-btn limbo-btn-danger px-4 sm:py-1 h-min flex-1 sm:flex-initial","aria-label":`Eliminar imagen ${e.filename}`,title:`Eliminar imagen ${e.filename}`,children:i?"Eliminando...":"Eliminar"})]})]}),A.jsxs("div",{className:"limbo-cropper-status bg-white border-gray-100 px-4 sm:px-6 py-2 pb-0 flex-shrink-0",children:[X&&A.jsxs("div",{className:"alert alert-danger mb-2 text-sm",role:"alert",children:[A.jsx("strong",{children:"Error:"})," ",X]}),le&&A.jsxs("div",{className:"alert alert-secondary mb-2 text-sm",role:"status",children:[A.jsx("strong",{children:"Original:"})," ",le.naturalWidth," ×"," ",le.naturalHeight," px",le.currentWidth!==le.naturalWidth&&A.jsxs("span",{className:"ml-2 sm:ml-3 text-xs block sm:inline",children:["(Mostrada: ",Math.round(le.currentWidth)," ×"," ",Math.round(le.currentHeight)," px)"]})]}),!ce&&A.jsx("div",{className:"alert alert-warning mb-2 text-sm",role:"alert",children:"⚠️ No se puede exportar por restricciones CORS"}),A.jsxs("div",{className:"bg-white border-b border-gray-200 p-3 sm:p-4 flex-shrink-0 sticky top-0 z-10 mb-3 shadow-sm",children:[A.jsxs("div",{className:"flex items-center justify-between mb-3",children:[A.jsxs("h3",{className:"text-sm font-semibold text-gray-700",children:["Recortes ",P.length>1&&`(${P.length})`]}),T.allowCustomCrops&&A.jsxs("button",{onClick:Ae,disabled:Y,className:"text-xs cursor-pointer px-2 py-1 bg-green-100 hover:bg-green-200 text-green-800 rounded border border-green-300 transition-colors flex items-center gap-1",title:"Añadir recorte personalizado",children:[A.jsx("span",{className:"icon icon-add-green text-green-800 icon--xs"}),"Añadir recorte"]})]}),A.jsx("div",{className:"space-y-2 max-h-48 overflow-y-auto grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-2 justify-items-stretch items-start justify-stretch w-full",children:P.map((e,t)=>A.jsxs("label",{className:"flex items-center gap-3 p-2 rounded border cursor-pointer transition-colors "+(I===t?"bg-blue-50 border-blue-300":"bg-gray-50 border-gray-200 hover:bg-gray-100"),children:[A.jsx("input",{type:"radio",name:"active-crop",checked:I===t,onChange:()=>Te(t),disabled:Y,className:"w-4 h-4 text-blue-600 hidden"}),A.jsxs("div",{className:"flex-1 min-w-0",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("span",{className:"text-sm font-medium text-gray-800 truncate",children:O.label===e.label&&!1===e.required?A.jsx("input",{type:"text",value:e.label,onChange:e=>Ie(e.target.value),disabled:Y||e.required,className:"w-full text-sm px-2 py-1.5 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:bg-gray-100 disabled:cursor-not-allowed",placeholder:"Nombre del recorte",required:!0,maxLength:25}):e.label}),e.required&&A.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-red-100 text-red-700 rounded",children:"Obligatorio"}),e.isCustom&&A.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-purple-100 text-purple-700 rounded",children:"Personalizado"})]}),A.jsxs("span",{className:"text-xs text-gray-500",children:[e.width," × ",e.height," px"]})]}),!e.required&&P.length>1&&A.jsx("button",{onClick:e=>{e.preventDefault(),Le(t)},className:"flex items-stretch group max-h-fit hover:bg-red-500/50 text-red-500 hover:text-red-700 p-1 rounded-full aspect-square cursor-pointer",title:"Eliminar recorte",children:A.jsx("span",{className:"group-hover:bg-gray-transparent-50 icon icon-close-small icon--xs"})})]},e.id))}),O&&A.jsx("div",{className:"mt-4 pt-4 border-t border-gray-200 space-y-3",children:A.jsxs("div",{children:[A.jsx("label",{className:"text-xs font-medium text-gray-700 block mb-1",children:"Dimensiones (px)"}),A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("input",{type:"number",min:"100",max:"5000",value:O.width,onChange:e=>Pe("width",e.target.value),onBlur:()=>Me("width"),disabled:Y,className:"flex-1 text-sm px-2 py-1.5 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Ancho"}),A.jsx("span",{className:"text-gray-400 font-bold",children:"×"}),A.jsx("input",{type:"number",min:"100",max:"5000",value:O.height,onChange:e=>Pe("height",e.target.value),onBlur:()=>Me("height"),disabled:Y,className:"flex-1 text-sm px-2 py-1.5 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Alto"})]}),A.jsxs("div",{className:"flex items-center justify-between mt-1",children:[A.jsxs("span",{className:"text-xs text-gray-500",children:["Proporción:"," ",F?F.toFixed(2):"N/A"]}),A.jsx("span",{className:"text-xs text-gray-400",children:"Min: 100px | Max: 5000px"})]})]})})]})]}),A.jsxs("div",{className:"cropper-main-content-area flex flex-col lg:flex-row flex-1 overflow-hidden rounded-lg gap-4 md:gap-0 aspect-auto lg:aspect-square xl:aspect-auto w-full max-w-[95%] lg:max-w-full self-center lg:max-h-[50rem]",children:[A.jsx("div",{className:"flex-1 relative min-w-0 order-1",children:A.jsxs("div",{className:"limbo-cropper-container lg:absolute inset-2 sm:inset-4 bg-white rounded-lg border-2 border-gray-200 shadow-lg overflow-hidden",children:[s&&A.jsxs("div",{className:"absolute top-2 sm:top-4 right-2 sm:right-4 bg-white rounded-lg border border-gray-300 p-2 sm:p-3 z-50 shadow-xl w-48 sm:w-64 max-w-[calc(50%-1rem)] sm:max-w-[calc(50%-2rem)] md:min-w-1/4",children:[A.jsxs("div",{className:"flex justify-between items-center mb-2",children:[A.jsx("h3",{className:"text-xs font-semibold text-gray-700",children:"Vista previa"}),A.jsx("button",{onClick:()=>{l(!1),d(null)},className:"text-gray-400 hover:text-gray-600 p-1 -m-1","aria-label":"Cerrar vista previa",children:A.jsx("span",{className:"icon icon-close-small text-xs"})})]}),A.jsx("div",{className:"bg-gray-50 rounded p-2 flex justify-center items-center min-h-[80px] relative",children:c?A.jsxs("div",{className:"relative w-full h-full flex justify-center items-center",children:[A.jsx("img",{src:c,alt:"Vista previa del recorte",className:"max-w-full max-h-80 object-contain rounded shadow-sm"}),m&&A.jsx("div",{className:"absolute top-1 right-1 bg-blue-500 rounded-full p-1",children:A.jsx("div",{className:"animate-spin w-3 h-3 border border-white border-t-transparent rounded-full"})})]}):A.jsxs("div",{className:"flex flex-col items-center justify-center",children:[A.jsx("div",{className:"animate-spin w-6 h-6 border-2 border-blue-500 border-t-transparent rounded-full mb-2"}),A.jsx("span",{className:"text-xs text-gray-500",children:"Generando..."})]})})]}),A.jsxs("cropper-canvas",{ref:ae,style:{width:"100%",height:"100%",display:"block"},background:!!g||void 0,id:"limbo-cropperjs-canvas",tabindex:"-1",onKeyDown:e=>{"Delete"!==e.key&&"Backspace"!==e.key||(e.preventDefault(),e.stopPropagation())},children:[A.jsx("cropper-image",{ref:ie,src:e.url||e.path,alt:e.filename,id:"limbo-cropperjs-image",action:"move",crossOrigin:"anonymous",rotatable:!0,scalable:!0,skewable:!0,translatable:!0}),A.jsxs("cropper-selection",{ref:oe,"initial-coverage":"0.5",movable:!0,resizable:!0,keyboard:"true",action:"move",style:{cursor:"move",minWidth:`${U.minWidth}px`,minHeight:`${U.minHeight}px`},"data-prevent-delete":"true",tabindex:"-1",children:[p&&A.jsx("cropper-grid",{role:"grid",action:"move",covered:!0,bordered:!0}),A.jsx("cropper-handle",{action:"move",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"32px",height:"32px",zIndex:"10"}}),A.jsx("cropper-handle",{action:"n-resize"}),A.jsx("cropper-handle",{action:"e-resize"}),A.jsx("cropper-handle",{action:"s-resize"}),A.jsx("cropper-handle",{action:"w-resize"}),A.jsx("cropper-handle",{action:"ne-resize"}),A.jsx("cropper-handle",{action:"nw-resize"}),A.jsx("cropper-handle",{action:"se-resize"}),A.jsx("cropper-handle",{action:"sw-resize"})]})]})]})}),A.jsx("div",{className:"flex limbo-cropper-controls w-full lg:w-80 h-full bg-white border-t md:border-t-0 md:border-l border-gray-200 lg:overflow-y-auto flex-shrink-0 order-1 max-h-none",children:A.jsxs("div",{className:"p-3 min-h-full sm:p-4 space-y-3 sm:space-y-4 relative w-full grid grid-cols-1 lg:flex lg:flex-col",children:[A.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:[A.jsx("button",{onClick:fe,className:"w-full p-2 my-1 cursor-pointer hover:bg-neutral-gray-050/50 transition-colors rounded-md","aria-expanded":k,"aria-label":"Mostrar/ocultar opciones de visualizción",children:A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Visualización"}),A.jsx("div",{className:"text-center",children:A.jsx("span",{className:`icon ${k?"icon-chevron-up":"icon-chevron-down"} text-center icon--xs`})})]})}),k&&A.jsxs("div",{className:"pb-2 space-y-2",children:[A.jsxs("button",{onClick:me,className:"w-full flex cursor-pointer items-center justify-between p-2 rounded transition-colors "+(p?"bg-blue-100 border border-blue-300 text-blue-800":"bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200"),disabled:Y,"aria-pressed":p,title:"Mostrar/ocultar cuadrícula de la regla de los tercios en el selector","aria-label":"Activar/desactivar grid",children:[A.jsxs("span",{className:"text-sm flex items-center",children:[A.jsx("span",{className:"icon icon-area-blue me-1"})," ","Cuadrícula"]}),A.jsx("span",{className:"text-xs",children:p?A.jsxs(A.Fragment,{children:[A.jsx("span",{className:"icon icon-tick icon--xs align-[middle!important] -mt-0.5"})," ","Activo"]}):"Inactivo"})]}),A.jsxs("button",{onClick:he,className:"w-full flex cursor-pointer items-center justify-between p-2 rounded transition-colors "+(g?"bg-blue-100 border border-blue-300 text-blue-800":"bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200"),disabled:Y,"aria-pressed":g,"aria-label":"Activar/desactivar sombreado",children:[A.jsxs("span",{className:"text-sm flex items-center",children:[A.jsx("span",{className:"icon icon-comparison-blue me-1"})," ","Tablero"]}),A.jsx("span",{className:"text-xs",children:g?A.jsxs(A.Fragment,{children:[A.jsx("span",{className:"icon icon-tick icon--xs align-[middle!important] -mt-0.5"})," ","Activo"]}):"Inactivo"})]})]})]}),A.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 p-4"+(C?"":" bg-neutral-gray-50/50"),children:[A.jsx("button",{onClick:ge,className:"w-full p-2 my-1 cursor-pointer hover:bg-neutral-gray-050/50 transition-colors rounded-md","aria-expanded":C,"aria-label":"Mostrar/ocultar opciones de visualizción",children:A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Ajustes del selector"}),A.jsx("div",{className:"text-center",children:A.jsx("span",{className:`icon ${C?"icon-chevron-up":"icon-chevron-down"} text-center icon--xs`})})]})}),C&&A.jsxs("div",{children:[A.jsx("div",{className:"mt-3",children:A.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[A.jsx("button",{onClick:()=>Ce(.5),className:"p-2 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",disabled:Y,"aria-label":"Selección 50%",title:"Tamaño de selector 50%",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{children:"50%"})})}),A.jsx("button",{onClick:()=>Ce(.7),className:"p-2 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",disabled:Y,"aria-label":"Selección 70%",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{children:"70%"})})}),A.jsx("button",{onClick:()=>Ce(.9),className:"p-2 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",disabled:Y,"aria-label":"Selección 90%",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{children:"90%"})})}),A.jsx("button",{onClick:()=>Ce(1),className:"p-2 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",disabled:Y,"aria-label":"Selección completa",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{children:"100%"})})})]})}),A.jsxs("div",{className:"space-y-2 pt-2",children:[A.jsx("button",{onClick:ve,className:"w-full p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Centrar selección",disabled:Y,"aria-label":"Centrar área de selección",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsxs("span",{children:[A.jsx("span",{className:"icon icon-radio-button icon--sm align-[middle!important] "})," ","Centrar selección"]})})}),A.jsx("button",{onClick:xe,className:"w-full p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Reiniciar selección",disabled:Y,"aria-label":"Reiniciar área de selección",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsxs("span",{children:[A.jsx("span",{className:"icon icon-refresh icon--sm lign-[middle!important] "})," ","Reset selección"]})})})]})]})]}),A.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:[A.jsx("button",{onClick:be,className:"w-full p-2 my-1 cursor-pointer hover:bg-neutral-gray-050/50 transition-colors rounded-md","aria-expanded":N,"aria-label":"Mostrar/ocultar opciones de visualizción",children:A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Transformar imagen"}),A.jsx("div",{className:"text-center",children:A.jsx("span",{className:`icon ${N?"icon-chevron-up":"icon-chevron-down"} text-center icon--xs`})})]})}),N&&A.jsxs(A.Fragment,{children:[A.jsxs("div",{className:"mb-4 hidden lg:block",children:[A.jsx("p",{className:"text-xs text-gray-600 mb-2",children:"Mover imagen"}),A.jsxs("div",{className:"grid grid-cols-3 gap-1",children:[A.jsx("div",{}),A.jsx("button",{onClick:()=>we(0,-10),className:"p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Mover arriba",disabled:Y,"aria-label":"Mover imagen hacia arriba",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-up-blue"})})}),A.jsx("div",{}),A.jsx("button",{onClick:()=>we(-10,0),className:"p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Mover izquierda",disabled:Y,"aria-label":"Mover imagen hacia la izquierda",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-left-blue"})})}),A.jsx("button",{onClick:ye,className:"p-2 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Centrar y ajustar imagen",disabled:Y,"aria-label":"Centrar y ajustar imagen",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-radio-button-blue icon-md"})})}),A.jsx("button",{onClick:()=>we(10,0),className:"p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Mover derecha",disabled:Y,"aria-label":"Mover imagen hacia la derecha",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-right-blue"})})}),A.jsx("div",{}),A.jsx("button",{onClick:()=>we(0,10),className:"p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Mover abajo",disabled:Y,"aria-label":"Mover imagen hacia abajo",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-down-blue"})})}),A.jsx("div",{})]})]}),A.jsxs("div",{className:"mb-4",children:[A.jsxs("p",{className:"text-xs text-gray-600 mb-2",children:["Zoom ",_?_.percentage+"%":""]}),A.jsxs("div",{className:"flex gap-1",children:[A.jsx("button",{onClick:()=>ke(-.2),className:"flex-1 p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Alejar 20%",disabled:Y,"aria-label":"Alejar imagen",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-zoom-out-blue"})})}),A.jsx("button",{onClick:Ee,className:"flex-1 p-2 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Restablecer zoom original",disabled:Y,"aria-label":"Restablecer el zoom para que la imagen se vea con su resolución original",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-screenshot-blue"})})}),A.jsx("button",{onClick:()=>ke(.2),className:"flex-1 p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Acercar 20%",disabled:Y,"aria-label":"Acercar imagen",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-zoom-in-blue"})})})]})]}),A.jsxs("div",{className:"mb-4",children:[A.jsx("p",{className:"text-xs text-gray-600 mb-2",children:"Rotación"}),A.jsxs("div",{className:"flex gap-1 *:text-brand-blue-1000 *:text-sm",children:[A.jsx("button",{onClick:()=>Se(-90),className:"flex-1 p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Rotar -90°",disabled:Y,"aria-label":"Rotar imagen 90 grados a la izquierda",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-reply-blue"})})}),A.jsx("button",{onClick:()=>Se(-45),className:"flex-1 p-2 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Rotar -45°",disabled:Y,"aria-label":"Rotar imagen 45 grados a la izquierda",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{children:"-45°"})})}),A.jsx("button",{onClick:()=>Se(45),className:"flex-1 p-2 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Rotar +45°",disabled:Y,"aria-label":"Rotar imagen 45 grados a la derecha",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{children:"+45°"})})}),A.jsx("button",{onClick:()=>Se(90),className:"flex-1 p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Rotar +90°",disabled:Y,"aria-label":"Rotar imagen 90 grados a la derecha",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-send-arrow-blue"})})})]})]}),A.jsxs("div",{className:"mb-4",children:[A.jsx("p",{className:"text-xs text-gray-600 mb-2",children:"Voltear"}),A.jsxs("div",{className:"flex gap-1",children:[A.jsx("button",{onClick:Ne,className:"flex-1 p-2 rounded cursor-pointer transition-colors text-sm "+(y.horizontal?"bg-blue-100 border border-blue-300 text-blue-800":"bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200"),title:"Voltear horizontalmente "+(y.horizontal?"(activo)":""),disabled:Y,"aria-label":"Voltear imagen horizontalmente","aria-pressed":y.horizontal,children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-left-right-blue border border-brand-blue-1000 rounded"})})}),A.jsx("button",{onClick:je,className:"flex-1 p-2 cursor-pointer rounded transition-colors text-sm "+(y.vertical?"bg-blue-100 border border-blue-300 text-blue-800":"bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200"),title:"Voltear verticalmente "+(y.vertical?"(activo)":""),disabled:Y,"aria-label":"Voltear imagen verticalmente","aria-pressed":y.vertical,children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-up-down-blue border border-brand-blue-1000 rounded"})})})]})]}),A.jsx("button",{onClick:()=>{te.reset(),v({horizontal:!1,vertical:!1})},className:"w-full p-2 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",title:"Reiniciar transformaciones",disabled:Y,"aria-label":"Reiniciar todas las transformaciones de la imagen",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsxs("span",{children:[A.jsx("span",{className:"icon icon-refresh-blue icon--sm align-[middle!important] "})," ","Reiniciar ajustes"]})})})]})]}),A.jsxs("div",{className:"bg-gradient-to-br from-brand-blue-50 to-green-50 rounded-lg border border-blue-200 shadow-sm hidden lg:block",children:[A.jsxs("button",{onClick:pe,className:"w-full p-4 flex items-center justify-between cursor-pointer hover:bg-blue-100/50 transition-colors rounded-t-lg","aria-expanded":x,"aria-label":"Mostrar/ocultar guía de uso",children:[A.jsxs("h3",{className:"text-lg font-semibold text-blue-800 flex items-center",children:[A.jsx("span",{className:"icon icon-lightbulb text-yellow-500 mr-2"}),"Guía de uso"]}),A.jsx("span",{className:"icon icon-arrow-down-blue transition-transform duration-200 "+(x?"rotate-180":"")})]}),x&&A.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[A.jsxs("div",{className:"bg-white/60 rounded-md p-3 border-l-4 border-blue-400",children:[A.jsx("h4",{className:"font-semibold text-blue-700 mb-2 text-sm",children:"🖱️ Navegación básica"}),A.jsxs("div",{className:"text-sm text-blue-600 space-y-1",children:[A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Arrastra la imagen:"})," Haz clic sobre la imagen del área de selección y arrastra"]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Zoom:"})," Usa la rueda del ratón (fuera del área de selección)"]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Vista completa:"}),' Botón "Reset zoom" para ajustar al tamaño óptimo']})]})]}),A.jsxs("div",{className:"bg-white/60 rounded-md p-3 border-l-4 border-green-400",children:[A.jsx("h4",{className:"font-semibold text-green-700 mb-2 text-sm",children:"✂️ Área de selección"}),A.jsxs("div",{className:"text-sm text-green-600 space-y-1",children:[A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Mover selección:"})," Arrastra desde el centro",A.jsx("span",{className:"icon bg-white icon-move align-[middle!important] mx-1 border border-green-600 rounded-full"})]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Redimensionar:"})," Arrastra desde las esquinas o bordes"]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Tamaños rápidos:"})," Usa los botones 50%, 70%, 90%, 100%"]})]})]}),A.jsxs("div",{className:"bg-white/60 rounded-md p-3 border-l-4 border-purple-400",children:[A.jsx("h4",{className:"font-semibold text-purple-700 mb-2 text-sm",children:"⌨️ Atajos de teclado"}),A.jsxs("div",{className:"text-sm text-purple-600 space-y-1",children:[A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Flechas:"}),A.jsx("span",{className:"icon icon-arrow-right-box rotate-180 mx-1"}),A.jsx("span",{className:"icon icon-arrow-right-box mx-1"}),A.jsx("span",{className:"icon icon-arrow-right-box -rotate-90 mx-1"}),A.jsx("span",{className:"icon icon-arrow-right-box rotate-90 mx-1"}),"Mueven la selección (10px)"]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Shift + Arrastrar:"})," Mantiene proporciones al redimensionar"]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Ctrl + Rueda:"})," Zoom más preciso"]})]})]}),A.jsxs("div",{className:"bg-white/60 rounded-md p-3 border-l-4 border-amber-400",children:[A.jsx("h4",{className:"font-semibold text-amber-700 mb-2 text-sm",children:"💡 Consejos profesionales"}),A.jsxs("div",{className:"text-sm text-amber-600 space-y-1",children:[A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Vista previa:"}),' Usa el botón "Vista previa" antes de guardar']}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Cuadricula:"})," Actívalo para aplicar la regla de los tercios"]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Tablero:"})," Actívalo para cuadrar medjor las medidas o como ayuda visual para imagenes con transparencia"]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Transformaciones:"})," Rota y voltea antes de hacer el recorte final"]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Calidad:"})," Las imágenes se exportan en alta calidad (JPEG 90%)"]})]})]}),A.jsxs("div",{className:"bg-white/60 rounded-md p-3 border-l-4 border-orange-600",children:[A.jsx("h4",{className:"font-semibold text-orange-700 mb-2 text-sm",children:"⚠️ Advertencias"}),A.jsxs("div",{className:"text-sm text-orange-600 space-y-1",children:[A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Recortes grandes:"})," Pueden tardar más en procesarse"]}),A.jsxs("div",{children:["• ",A.jsx("strong",{children:"Calidad de imagen:"})," La calidad puede verse afectada al escalar"]})]})]})]})]})]})})]}),A.jsx("div",{className:"limbo-cropper-footer flex-shrink-0 border-t border-gray-200 bg-white p-4",children:A.jsxs("div",{className:"flex flex-row gap-2 sm:gap-3 items-stretch sm:items-center justify-end max-w-7xl mx-auto",children:[A.jsx("button",{onClick:Re,disabled:Y||!ce,className:"px-6 py-2.5 min-h-[44px] transition-colors order-2 "+(s?"limbo-btn limbo-btn-danger":"limbo-btn limbo-btn-info"),"aria-label":"Generar vista previa del recorte",title:"Mostar/Ocultar vista previa del recorte",children:A.jsxs("div",{className:"flex items-center justify-center",children:[A.jsx("span",{className:"icon md:mr-1 icon-search-white"}),A.jsx("span",{className:"hidden md:block text-nowrap",children:s?"Cerrar previa":"Vista previa"})]})}),A.jsx("button",{onClick:qe,disabled:Y||!ce,className:"limbo-btn limbo-btn-primary px-6 py-2.5 min-h-[44px] order-3","aria-label":"Descargar recorte sin guardar",title:"Descargar recorte sin guardar",children:A.jsxs("div",{className:"flex items-center justify-center",children:[A.jsx("span",{className:"icon icon-download-white md:mr-1"}),A.jsx("span",{className:"hidden md:block text-nowrap",children:"Descargar"})]})}),A.jsx("button",{onClick:Fe,disabled:Y||!se||!de||!ce||!ee.isReady,className:"limbo-btn limbo-btn-success px-6 py-2.5 min-h-[44px] order-4","aria-label":"Guardar imagen recortada",title:"Guardar imagen recortada",children:A.jsx("div",{className:"flex items-center justify-center",children:Y?A.jsxs(A.Fragment,{children:[A.jsx("span",{className:"hidden md:block text-nowrap icon icon-save-white md:mr-1"}),"Guardando..."]}):A.jsxs(A.Fragment,{children:[A.jsx("span",{className:"icon icon-save-white md:mr-1"}),A.jsx("span",{className:"hidden md:block text-nowrap",children:"Guardar recorte"})]})})})]})}),q&&A.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] p-4",children:A.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] overflow-hidden flex flex-col",children:[A.jsxs("div",{className:"px-6 py-4 border-b border-gray-200",children:[A.jsx("h3",{className:"text-lg font-semibold text-gray-800",children:"save"===V?"Seleccionar recortes a guardar":"Seleccionar recortes a descargar"}),A.jsxs("p",{className:"text-sm text-gray-600 mt-1",children:["Marca los recortes que deseas ","save"===V?"guardar":"descargar"]})]}),A.jsx("div",{className:"px-6 py-4 overflow-y-auto flex-1",children:A.jsx("div",{className:"space-y-2",children:P.map((e,t)=>A.jsxs("label",{className:`flex items-center gap-3 p-3 rounded border cursor-pointer transition-colors ${H.includes(t)?"bg-blue-50 border-blue-300":"bg-gray-50 border-gray-200 hover:bg-gray-100"} ${e.required?"opacity-75":""}`,children:[A.jsx("input",{type:"checkbox",checked:H.includes(t),disabled:e.required,onChange:e=>{e.target.checked?W(e=>[...e,t]):W(e=>e.filter(e=>e!==t))},className:"w-4 h-4 text-blue-600"}),A.jsxs("div",{className:"flex-1 min-w-0",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("span",{className:"text-sm font-medium text-gray-800 truncate",children:e.label}),e.required&&A.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-red-100 text-red-700 rounded",children:"Obligatorio"})]}),A.jsxs("span",{className:"text-xs text-gray-500",children:[e.width," × ",e.height," px"]})]})]},e.id))})}),A.jsxs("div",{className:"px-6 py-4 border-t border-gray-200 flex gap-3 justify-end",children:[A.jsx("button",{onClick:()=>{B(!1),K(null),W([])},className:"limbo-btn limbo-btn-secondary px-4 py-2",children:"Cancelar"}),A.jsxs("button",{onClick:async()=>{B(!1),"save"===V?await De():await Ue(),K(null),W([])},disabled:0===H.length,className:"limbo-btn limbo-btn-primary px-4 py-2 disabled:opacity-50 disabled:cursor-not-allowed",children:["save"===V?"Guardar":"Descargar"," (",H.length,")"]})]})]})})]}):null}function an({currentPage:e,totalPages:t,onPageChange:n,disabled:r=!1}){if(!t||t<=1)return null;const a=(()=>{const n=[],r=[],a=Math.max(1,e-2),i=Math.min(t,e+2);for(let e=a;e<=i;e++)n.push(e);return a>1&&(r.push(1),a>2&&r.push("...")),r.push(...n),i<t&&(i<t-1&&r.push("..."),r.push(t)),r})();return A.jsxs("div",{className:"flex items-center justify-center space-x-2 py-4",children:[A.jsxs("button",{onClick:()=>{e>1&&n(e-1)},disabled:r||e<=1,className:`\n px-3 py-2 text-sm font-medium rounded-md transition-colors disabled:cursor-default cursor-pointer\n ${r||e<=1?"text-gray-400 bg-gray-100 cursor-not-allowed":"text-gray-700 bg-white border border-gray-300 hover:bg-gray-50 focus:ring-2 focus:ring-blue-500"}\n `,children:[A.jsx("span",{className:"icon icon-arrow-left-white icon--sm"})," Anterior"]}),A.jsx("div",{className:"flex space-x-1",children:a.map((t,a)=>A.jsx(d.Fragment,{children:"..."===t?A.jsx("span",{className:"px-3 py-2 text-sm text-gray-500",children:"..."}):A.jsx("button",{onClick:()=>(t=>{t!==e&&n(t)})(t),disabled:r,className:`\n px-3 py-2 text-sm font-medium rounded-md transition-colors disabled:cursor-default cursor-pointer\n ${t===e?"bg-blue-600 text-white border border-blue-600":r?"text-gray-400 bg-gray-100 cursor-not-allowed":"text-gray-700 bg-white border border-gray-300 hover:bg-gray-50 focus:ring-2 focus:ring-blue-500"}\n `,children:t})},`page-${t}-${a}`))}),A.jsxs("button",{onClick:()=>{e<t&&n(e+1)},disabled:r||e>=t,className:`\n px-3 py-2 text-sm font-medium rounded-md transition-colors disabled:cursor-default cursor-pointer\n ${r||e>=t?"text-gray-400 bg-gray-100 cursor-not-allowed":"text-gray-700 bg-white border border-gray-300 hover:bg-gray-50 focus:ring-2 focus:ring-blue-500"}\n `,children:["Siguiente ",A.jsx("span",{className:"icon icon-arrow-right-white icon--sm"})]}),A.jsxs("div",{className:"text-sm text-gray-500 ml-4",children:["Página ",e," de ",t]})]})}function on({isOpen:e,onClose:t}){return e?A.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",style:{zIndex:9999},children:A.jsxs("div",{className:"bg-white rounded-lg p-6 max-w-md mx-4 shadow-xl",children:[A.jsxs("div",{className:"flex items-center mb-4",children:[A.jsx("svg",{className:"w-6 h-6 text-red-600 mr-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:A.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-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"})}),A.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Sesión Expirada"})]}),A.jsxs("div",{className:"mb-6",children:[A.jsx("p",{className:"text-gray-600 mb-2",children:"Su sesión ha expirado por seguridad."}),A.jsx("p",{className:"text-gray-600",children:"Es necesario recargar la página para obtener un nuevo token de acceso."})]}),A.jsx("div",{className:"flex justify-end space-x-3",children:A.jsx("button",{onClick:t,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors",children:"Recargar Página"})})]})}):null}function sn(){const[e,t]=u.useState(!1),[n,r]=u.useState(null);return{deleteImg:async e=>{if(!e)return r("ID de imagen no proporcionado"),!1;t(!0),r(null);try{const t=await async function(e){try{return await F({endpoint:`/assets/${e}`,method:"DELETE",basePath:V,useJWT:!0})}catch(n){throw W(n)}}(e);return!1!==t.success}catch(a){return r(a.message),!1}finally{t(!1)}},loading:e,error:n,reset:()=>{r(null)}}}const ln=new Map;function cn(e,t=500){const[n,r]=u.useState(e);return u.useEffect(()=>{const n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n}function un({apiKey:e,prod:t=!1,url:n=!0,features:r=["gallery","upload","cropper"],modeUI:a="full",ui:i={showActions:["select","download","copy","delete","crop","variants"],hideActions:[],theme:"light",language:"es",compactMode:!1,showTabs:!0},callbacks:o={},instanceId:s=null,itemsPerPage:l=10,_externalImage:c=null}){sessionStorage.removeItem("limbo_stock_selectedService"),sessionStorage.removeItem("limbo_stock_dynamicForm"),sessionStorage.removeItem("limbo_stock_stockImages"),sessionStorage.removeItem("limbo_stock_currentPage"),sessionStorage.removeItem("limbo_stock_paginationInfo"),sessionStorage.removeItem("limbo_portals_searchName"),sessionStorage.removeItem("limbo_portals_limit"),sessionStorage.removeItem("limbo_portals_currentPage"),sessionStorage.removeItem("limbo_portals_images"),sessionStorage.removeItem("limbo_portals_portalResults"),sessionStorage.removeItem("limbo_portals_paginationInfo");const[d,m]=u.useState({name:"",uploadedBy:"",dateFrom:"",dateTo:""}),h=cn(d.name,500),p=cn(d.uploadedBy,500),f=(()=>{switch(a){case"gallery-only":return["gallery"];case"upload-only":return["upload"];case"crop-only":return["cropper"];case"ia-only":return["ia"];default:return r}})(),[g,b]=u.useState(f.includes("gallery")?"gallery":f.includes("upload")?"upload":f.includes("cropper")?"cropper":f.includes("ia")?"ia":f[0]||"gallery"),[y,v]=u.useState(null);u.useEffect(()=>{c&&(console.log("📸 Imagen externa detectada:",c),v(c),b("cropper"))},[c]);const[x,w]=u.useState(1),{isTokenExpired:k,handleTokenExpiredClose:S}=function(){const[e,t]=u.useState(!1),n=u.useCallback(e=>{if(401===e?.response?.status){const n=e.response.data;if("token_expired"===n?.error||n?.message?.includes("expired")||n?.message?.includes("caducado")||n?.error?.includes("expired"))return t(!0),!0}return!1},[]),r=u.useCallback(()=>{t(!1),alert("El token ha expirado. La página se recargará para obtener un nuevo token."),window.location.reload()},[]);return u.useEffect(()=>{const e=e=>{e.detail&&e.detail.error&&n(e.detail.error)};return window.addEventListener("tokenExpiredError",e),()=>{window.removeEventListener("tokenExpiredError",e)}},[n]),{isTokenExpired:e,checkTokenExpiration:n,handleTokenExpiredClose:r}}(),{upload:C,loading:E,error:N,uploadedImage:j,reset:_}=function(){const[e,t]=u.useState(!1),[n,r]=u.useState(null),[a,i]=u.useState(null);return{upload:async(e,n=null)=>{if(!e)return r("No se ha proporcionado ningún archivo"),null;t(!0),r(null),i(null);try{const t=await G(e,n,!1),r=t.result||t;return i(r),r}catch(a){return r(a.message),null}finally{t(!1)}},loading:e,error:n,uploadedImage:a,reset:()=>{r(null),i(null)}}}(),{deleteImg:$,loading:z,error:T,reset:P}=sn(),M={limit:l,page:x,...h&&{name:h},...p&&{uploadedBy:p},...d.dateFrom&&{dateFrom:d.dateFrom},...d.dateTo&&{dateTo:d.dateTo}},{images:L,loading:O,error:R,pagination:D,invalidateCache:F,setImages:U}=function(e,t=!1,n={}){const[r,a]=u.useState([]),[i,o]=u.useState(!0),[s,l]=u.useState(null),[c,d]=u.useState(null),[m,h]=u.useState(0),p=u.useMemo(()=>JSON.stringify(n),[n]);return u.useEffect(()=>{const e=`${p}`,t=ln.get(e),r=Date.now();if(t&&r-t.timestamp<6e5)return a(t.data),d(t.pagination||null),void o(!1);let i=!0;return(async()=>{if(m>=3)i&&(l("Error de autenticación: Verifica tus credenciales API"),o(!1));else try{const t=await K(n);if(!i)return;const o=t.result||t.data||[],s=t.pagination||null;a(o),d(s),l(null),h(0),ln.set(e,{data:o,pagination:s,timestamp:r})}catch(t){i&&(l(t.message),h(e=>e+1))}finally{i&&o(!1)}})(),()=>{i=!1}},[e,t,p,m,n]),{images:r,loading:i,error:s,pagination:c,setImages:a,invalidateCache:()=>{ln.delete(`${p}`)}}}(e,t,M),{refreshVariants:q}=Y(),B=e=>!i.hideActions?.includes(e)&&(!!i.showActions?.includes(e)||!(i.showActions?.length>0)),H=[{id:"gallery",label:"Galería",feature:"gallery"},{id:"upload",label:"Subir nueva",feature:"upload"},{id:"cropper",label:"Recortador",hideNonActive:!0,feature:"cropper"}].filter(e=>f.includes(e.feature)),W=async e=>{if(!confirm("¿Estás seguro de que deseas eliminar esta imagen? Esta acción también eliminará todos sus recortes."))return;await $(e)&&(F(),w(1),U(t=>t.filter(t=>t.id!==e)),y&&y.id===e&&(v(null),b("gallery")))},V=()=>"crop-only"===a||1===f.length&&"cropper"===f[0]?"crop-only":f.includes("gallery")?"with-gallery":f.includes("upload")&&!f.includes("gallery")?"upload-only":"with-gallery";return A.jsxs("div",{className:"limbo-card-parent max-w-7xl mx-auto my-8 p-6 shadow-xs w-full",children:[i.showTabs&&"cropper"!=g&&A.jsx(I,{tabs:H,active:g,onChange:e=>{b(e),"upload"!==e&&_(),"gallery"!==e&&P()}}),R&&A.jsxs("div",{className:"alert alert-danger",children:["Error al cargar imágenes: ",R]}),T&&A.jsxs("div",{className:"alert alert-danger",children:["Error al eliminar imagen: ",T]}),"gallery"===g&&A.jsxs(A.Fragment,{children:[z&&A.jsx(ee,{text:"Eliminando imagen..."}),A.jsx(te,{onSelect:e=>{o.onSelect&&o.onSelect({assetId:e.id,url:e.url,fileName:e.filename,mime:e.mime_type,width:e.width,height:e.height,instanceId:s})},onCrop:e=>{v(e),f.includes("cropper")&&b("cropper")},onDelete:B("delete")?W:null,deletingId:z,images:L,loading:O,error:R,filters:d,onFiltersChange:e=>{m(e),w(1)},filterConfig:i.galleryFilters||{},loadingConfig:i.galleryLoading||{},allowedActions:{select:B("select"),download:B("download"),copy:B("copy"),delete:B("delete"),crop:B("crop")}}),D&&!O&&A.jsx(an,{currentPage:D.page||x,totalPages:D.pages||1,onPageChange:e=>{w(e)},disabled:O||z})]}),"upload"===g&&A.jsxs("div",{children:[E&&A.jsx(ee,{text:"Subiendo imagen..."}),N&&A.jsxs("div",{className:"alert alert-danger",children:["Error al subir imagen: ",N]}),j&&A.jsxs("div",{className:"alert alert-success",children:["✅ Imagen subida correctamente: ",j.filename]}),A.jsx(ve,{onUpload:async e=>{const t=await C(e);t&&(F(),w(1),U(e=>[t,...e]),b("gallery"),o.onUpload&&o.onUpload({assetId:t.id,url:t.url,fileName:t.filename,mime:t.mime_type,width:t.width,height:t.height,instanceId:s}))},disabled:E,apiKey:e,prod:t})]}),"cropper"===g&&A.jsx(rn,{image:y,onSave:e=>{const t=V(),n=window.limboCore?.config?.getGlobal()||{},r=n.mode||"embed",a=n.autoHideOnComplete||!1,i=Array.isArray(e)?e:[e];switch("with-gallery"===t&&F(),o.onCropsSaved&&o.onCropsSaved({crops:i,assetId:y?.id,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropsSaved",{crops:i,assetId:y?.id,instanceId:s}),t){case"with-gallery":v(null),b("gallery");break;case"upload-only":"modal"===r?window.limboCore?.modals?.closeAllModals():(v(null),b("upload"));break;case"crop-only":if("modal"===r)o.onCropperComplete&&o.onCropperComplete({crops:i,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropperComplete",{crops:i,instanceId:s}),window.limboCore?.modals?.closeAllModals();else if(o.onCropperComplete&&o.onCropperComplete({crops:i,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropperComplete",{crops:i,instanceId:s}),a){const e=document.querySelector(`#limbo-instance-${s}`);e&&(e.style.display="none")}}},onCancel:()=>{const e=V(),t=(window.limboCore?.config?.getGlobal()||{}).mode||"embed";switch(o.onCropperCancelled&&o.onCropperCancelled({assetId:y?.id,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropperCancelled",{assetId:y?.id,instanceId:s}),e){case"with-gallery":v(null),b("gallery");break;case"upload-only":"modal"===t?window.limboCore?.modals?.closeAllModals():(v(null),b("upload"));break;case"crop-only":"modal"===t?window.limboCore?.modals?.closeAllModals():window.limboCore?.events&&window.limboCore.events.emit("cropperClosed",{instanceId:s,reason:"cancelled"})}},onDelete:()=>W(y?.id),onError:e=>{o.onCropperError&&o.onCropperError(e,s),window.limboCore?.events&&window.limboCore.events.emit("cropperError",{error:e,assetId:y?.id,instanceId:s}),console.error("Cropper error:",e)},deleting:z,onVariantCreated:(e,t)=>{q(e)}}),A.jsx(on,{isOpen:k,onClose:S})]})}class dn{constructor(e,t,n,r){this.id=e,this.config=t,this.eventManager=n,this.modalManager=r,this.root=null,this.container=null,this.modal=null,this.mounted=!1,this.destroyed=!1,this.button=null,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=$.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.modal.close(),this.eventManager.emit("modal:close",{instance:this})),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||"large",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=$.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 d.createElement("div",{id:`limbo-component-container-${this.id}`,className:"limbo-instance limbo-component-container-wrapper py-3","data-limbo-id":this.id,"data-limbo-mode":this.config.mode,"data-limbo-version":"2.0","data-limbo-isolated":"true","aria-label":"Limbo Image Manager",role:"region"},d.createElement(un,{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"}))}_createCallbacks(){return{onSelect:e=>{const t=this._createStandardPayload(e,"select");this.config.callbacks?.onSelect&&this.config.callbacks.onSelect(t),this._emitDOMEvent("select",t)},onUpload:e=>{const t=this._createStandardPayload(e,"upload");this.config.callbacks?.onUpload&&this.config.callbacks.onUpload(t),this._emitDOMEvent("upload",t)},onError:e=>{const t={instance:this,error:{message:e.message||"Unknown error",code:e.code||"UNKNOWN",timestamp:Date.now()}};this.config.callbacks?.onError&&this.config.callbacks.onError(t.error),this._emitDOMEvent("error",t)},onClose:()=>{const e={instance:this,timestamp:Date.now()};this.config.callbacks?.onClose&&this.config.callbacks.onClose(),this._emitDOMEvent("close",e)}}}_createStandardPayload(e,t){const n={instance:this,eventType:t,timestamp:Date.now(),instanceId:this.id,mode:this.config.mode,features:this.config.features};return e&&(e.assetId||e.id?(n.assetId=e.assetId||e.id,n.variants=e.variants||[],n.master=e.master||{urlSigned:e.url||e.urlSigned,width:e.width,height:e.height,mime:e.mime||e.mimeType},n.fileName=e.fileName||e.name,n.mime=e.mime||e.mimeType,n.width=e.width,n.height=e.height,n.fileBlob=e.fileBlob||e.file,n.metadata={uploadedBy:e.uploadedBy,uploadedAt:e.uploadedAt||e.timestamp,size:e.size,...e.metadata}):Object.assign(n,e)),n}_emitDOMEvent(e,t){const n=new CustomEvent(`limbo:${e}`,{detail:t,bubbles:!0,cancelable:!0});(this.getContainer()||document).dispatchEvent(n),this.eventManager.emit(e,t)}_validateConfig(){if(!(this.config.auth?.apiKey||this.config.auth?.publicKey||this.config.auth?.token||this.config.apiKey||this.config.publicKey||this.config.token))throw new Error(`LimboInstance ${this.id}: Authentication is required. Provide either auth.publicKey (recommended) or auth.apiKey (for server-side only)`);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 mn{constructor(){this.instances=new Map,this.counter=0}create(e,t,n){const r="limbo-"+ ++this.counter,a=new dn(r,e,t,n);return this.instances.set(r,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,n)=>{t.isContainerInDOM()||e.push(n)}),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 hn{constructor(){this.config=null,this.instances=new Map,this.observer=null,this.initialized=!1}configure(e,t,n){return this.config={dataset:e.dataset||"data-limbo-input-file",return:e.return||"url",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||"medium",theme:e.theme||"light",compact:e.compact||!1,maxSize:e.maxSize||"10MB",formats:e.formats||["jpg","jpeg","png","webp"],minWidth:e.minWidth||null,minHeight:e.minHeight||null,maxWidth:e.maxWidth||null,maxHeight:e.maxHeight||null,buttonText:e.buttonText||"Seleccionar Imagen",buttonClass:e.buttonClass||"limbo-auto-button",buttonStyle:e.buttonStyle||"primary",showPreview:!1!==e.showPreview,allowMultiple:e.allowMultiple||!1,autoAssign:!1!==e.autoAssign,...e},this.configManager=t,this.eventManager=n,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=`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 n=this._createButton(e);this._hideInput(e),this._insertButton(e,n),this.instances.set(t,{input:e,button:n,config:this._getInputConfig(e)}),this.eventManager.emit("autoInputs:processed",{inputId:t,input:e,button:n})}_createButton(e){const t=document.createElement("button"),n=this._getInputConfig(e);t.type="button",t.textContent=n.buttonText||this.config.buttonText;const r=[this.config.buttonClass];return n.buttonClass&&n.buttonClass!==this.config.buttonClass&&r.push(n.buttonClass),t.className=r.join(" "),this._styleButton(t,n),this._attachButtonEvents(t,e),t.setAttribute("aria-label",n.buttonText||this.config.buttonText),t.setAttribute("data-limbo-trigger","true"),t.setAttribute("data-limbo-input-id",n.inputId),n.disabled&&(t.disabled=!0),t}_styleButton(e,t){const n=t.buttonStyle||this.config.buttonStyle,r=t.theme||this.config.theme,a=t.compact||this.config.compact,i={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"},o={primary:{backgroundColor:"dark"===r?"#3b82f6":"#001978",color:"white",hoverBg:"dark"===r?"#2563eb":"#334793"},secondary:{backgroundColor:"dark"===r?"#374151":"#f3f4f6",color:"dark"===r?"#f9fafb":"#374151",border:"1px solid "+("dark"===r?"#4b5563":"#d1d5db"),hoverBg:"dark"===r?"#4b5563":"#e5e7eb"},outline:{backgroundColor:"transparent",color:"dark"===r?"#3b82f6":"#001978",border:"2px solid "+("dark"===r?"#3b82f6":"#001978"),hoverBg:"dark"===r?"#3b82f6":"#001978",hoverColor:"white"},ghost:{backgroundColor:"transparent",color:"dark"===r?"#f9fafb":"#374151",hoverBg:"dark"===r?"#374151":"#f3f4f6"}},s=o[n]||o.primary;Object.assign(e.style,{...i,...s});const l=s.backgroundColor,c=s.color;e.addEventListener("mouseenter",()=>{e.style.backgroundColor=s.hoverBg||s.backgroundColor,s.hoverColor&&(e.style.color=s.hoverColor),e.style.transform="translateY(-1px)",e.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor=l,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),n=this._createModalConfig(t);this.eventManager.emit("autoInputs:modalRequest",{input:e,config:n,callback:async t=>await this._handleImageSelection(e,t)})}async _handleImageSelection(e,t){const n=this._getInputConfig(e);try{const r=await this._formatImageData(t,n);!1!==n.autoAssign&&(e.value=r),e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:resultReady",{detail:{imageData:t,input:e,value:r,config:n,assignment:{format:n.return,smartAssign:!1!==n.smartAssign,autoAssign:!1!==n.autoAssign},legacy:{imageData:t,formatted:this._createFormattedResult(t,n)}},bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:imageSelected",{detail:{imageData:t,input:e,value:r,config:n,formatted:this._createFormattedResult(t,n)},bubbles:!0})),this.eventManager.emit("autoInputs:imageSelected",{input:e,imageData:t,value:r,config:n})}catch(r){console.error("Error handling image selection:",r),e.dispatchEvent(new CustomEvent("limbo:error",{detail:{error:r.message,input:e,imageData:t,config:n},bubbles:!0})),this._handleImageSelectionLegacy(e,t)}}_handleImageSelectionLegacy(e,t){const n=this._getInputConfig(e),r=this._formatImageData(t,n);!1!==n.autoAssign&&(e.value=r),e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:imageSelected",{detail:{imageData:t,input:e,value:r,config:n,formatted:this._createFormattedResult(t,n)},bubbles:!0})),this.eventManager.emit("autoInputs:imageSelected",{input:e,imageData:t,value:r,config:n})}_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){switch((t||{}).return||this.config.return||"url"){case"url":return e.url||e.path||"";case"base64":return e.base64||e.dataUrl||"";case"assetId":return e.assetId||e.id||"";case"fileName":return e.fileName||e.filename||"";case"object":return 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,created:e.created_at||e.created});default:return 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})}}_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||"medium",title:e.description||this.config.title||"Seleccionar imagen",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:{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},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;if(!t||"none"===t||"false"===t)return null;if("free"===t)return{aspectRatio:null,quality:e.quality||this.config.quality,format:e.format||this.config.format};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{aspectRatio:n[t],quality:e.quality||this.config.quality,format:e.format||this.config.format,minCropBoxWidth:e.minWidth||this.config.minWidth,minCropBoxHeight:e.minHeight||this.config.minHeight};if("string"==typeof t&&t.includes(":")){const[n,r]=t.split(":").map(Number);if(!isNaN(n)&&!isNaN(r)&&0!==r)return{aspectRatio:n/r,quality:e.quality||this.config.quality,format:e.format||this.config.format}}const r=parseFloat(t);return!isNaN(r)&&r>0?{aspectRatio:r,quality:e.quality||this.config.quality,format:e.format||this.config.format}:"object"==typeof t?{quality:e.quality||this.config.quality,format:e.format||this.config.format,...t}:null}_shouldShowTabs(e){const t=e.modeUI||this.config.modeUI||"full",n=e.features||this.config.features;return!["gallery-only","upload-only","crop-only","ia-only"].includes(t)&&(n&&n.length>1)}_getUIActions(e){const t=e.modeUI||this.config.modeUI||"full",n=e.features||this.config.features;let r=[];switch(t){case"gallery-only":case"upload-only":r=["select"];break;case"crop-only":r=["select","crop"];break;default:r=["select"],n.includes("cropper")&&r.push("crop"),n.includes("gallery")&&(r.push("download","copy"),this.config.allowDelete&&r.push("delete"))}return r}_getInputId(e){return e.id||e.name||`limbo-auto-${Date.now()}-${Math.random()}`}_validateInput(e){return e instanceof HTMLInputElement}_getInputConfig(e){const t=e=>e?e.split(",").map(e=>e.trim()):null,n=e=>{if(!e)return null;const t=e.match(/^(\d+(?:\.\d+)?)(MB|KB|B)?$/i);if(!t)return null;const n=parseFloat(t[1]);switch((t[2]||"B").toUpperCase()){case"MB":return 1024*n*1024;case"KB":return 1024*n;default:return n}},r=(e,t=!1)=>null===e?t:"true"===e||"1"===e||""===e,a=e=>e?parseFloat(e):null;return{return:e.getAttribute("data-limbo-return")||this.config.return,mode:e.getAttribute("data-limbo-mode")||this.config.mode,features:t(e.getAttribute("data-limbo-features"))||this.config.features,crop:e.getAttribute("data-limbo-crop")||this.config.crop,quality:a(e.getAttribute("data-limbo-quality"))||this.config.quality,format:e.getAttribute("data-limbo-format")||this.config.format,modeUI:e.getAttribute("data-limbo-mode-ui")||this.config.modeUI,modalSize:e.getAttribute("data-limbo-modal-size")||this.config.modalSize,theme:e.getAttribute("data-limbo-theme")||this.config.theme,compact:r(e.getAttribute("data-limbo-compact"),this.config.compact),maxSize:n(e.getAttribute("data-limbo-max-size"))||n(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.getAttribute("data-limbo-button-text")||this.config.buttonText,buttonStyle:e.getAttribute("data-limbo-button-style")||this.config.buttonStyle,buttonClass:e.getAttribute("data-limbo-button-class")||this.config.buttonClass,showPreview:r(e.getAttribute("data-limbo-show-preview"),this.config.showPreview),allowMultiple:r(e.getAttribute("data-limbo-allow-multiple"),this.config.allowMultiple),autoAssign:r(e.getAttribute("data-limbo-auto-assign"),this.config.autoAssign),placeholder:e.getAttribute("data-limbo-placeholder"),description:e.getAttribute("data-limbo-description"),required:r(e.getAttribute("data-limbo-required"),!1),disabled:r(e.getAttribute("data-limbo-disabled"),!1),inputId:e.id||e.name||this._generateInputId(e),inputName:e.name,inputType:e.type}}_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=`input[${this.config.dataset}]`;e.matches&&e.matches(t)&&this._processInput(e);const n=e.querySelectorAll&&e.querySelectorAll(t);n&&n.forEach(e=>this._processInput(e))}}class pn{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 n=this.listeners.get(e);if(n){const e=n.indexOf(t);e>-1&&n.splice(e,1)}}cleanup(){this.listeners.clear()}_emitDOMEvent(e,t){const n=new CustomEvent(`limbo:${e}`,{detail:{...t,timestamp:Date.now()},bubbles:!0,cancelable:!0});(t.instance?.getContainer()||document).dispatchEvent(n)}_executeListeners(e,t){const n=this.listeners.get(e);n&&n.forEach(n=>{try{n(t)}catch(r){console.error(`Error executing listener for ${e}:`,r)}})}getStats(){const e={};return this.listeners.forEach((t,n)=>{e[n]=t.length}),e}}class fn{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 gn(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)}_handleGlobalKeydown(e){const t=this.getActiveModal();t&&("Escape"===e.key&&(e.preventDefault(),t.close()),"Tab"===e.key&&this._handleTabTrap(e,t))}_handleTabTrap(e,t){const n=t.getFocusableElements();if(0===n.length)return;const r=n[0],a=n[n.length-1];e.shiftKey?document.activeElement===r&&(e.preventDefault(),a.focus()):document.activeElement===a&&(e.preventDefault(),r.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 gn{constructor(e,t,n){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},this.manager=n,this.element=null,this.backdrop=null,this.isOpen=!1,this.previousFocus=null,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-modal limbo-modal--${this.config.size}`,this.element.id=this.id,this.element.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: 400px;",medium:e?"width: 100%; height: 100%;":"max-width: 600px;",large:e?"width: 100%; height: 100%;":"max-width: 800px;",xlarge:e?"width: 100%; height: 100%;":"max-width: 1200px;"},n=e?`\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n transform: translateY(100%);\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: 1;\n transition: transform 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 n=document.createElement("h2");if(n.id=`${this.id}-title`,n.className="limbo-modal-title",n.textContent=this.config.title,n.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(n),this.config.showCloseButton){const n=document.createElement("button");n.type="button",n.className="limbo-modal-close",n.innerHTML="✕",n.setAttribute("aria-label","Cerrar modal"),n.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 `,n.addEventListener("mouseenter",()=>{n.style.backgroundColor="#f8f9fa",n.style.color="#001978"}),n.addEventListener("mouseleave",()=>{n.style.backgroundColor="transparent",n.style.color="#6c757d"}),n.addEventListener("click",()=>this.close()),e.appendChild(n)}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&&("string"==typeof this.config.content?t.innerHTML=this.config.content: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";const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);return requestAnimationFrame(()=>{this.backdrop&&(this.backdrop.style.opacity="1"),this.element.style.opacity="1",this.element.style.transform=e?"translateY(0%)":"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);return this.backdrop&&(this.backdrop.style.opacity="0"),this.element.style.opacity="0",this.element.style.transform=e?"translateY(100%)":"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}}_cleanup(){document.body.style.overflow=this._originalBodyOverflow||"",this.previousFocus&&"function"==typeof this.previousFocus.focus&&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 bn{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 n=this._getTheme(e);if(!n)return console.warn(`Theme '${e}' not found`),!1;const r=this.currentTheme;return this._applyThemeVariables(n,t.scope),this._updateThemeAttributes(n.name),this.config.theme.storage&&!t.temporary&&this._saveThemePreference(n.name),this.currentTheme=n.name,this._triggerChangeCallbacks(n.name,r),!0}toggleTheme(e="light",t="dark"){const n=this.currentTheme===e?t:e;return this.applyTheme(n)}applyAutoTheme(){const e=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";return this.applyTheme(e)}registerTheme(e,t){const n={name:e,displayName:t.displayName||e,variables:t.variables||{},extends:t.extends||null,...t};if(n.extends){const e=this._getTheme(n.extends);e&&(n.variables={...e.variables,...n.variables})}return this.customThemes.set(e,n),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),n="ontouchstart"in window||navigator.maxTouchPoints>0;return!(!this.config.compact.forceOnMobile||!t&&!n)||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(n){console.error("Error in compact mode change callback:",n)}})}_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 n=document.querySelector(t);if(n){const t=this._extractCSSVariables(n);Object.keys(t).length>0&&(e.variables={...e.variables,...t});const r=n.getAttribute("data-theme")||n.getAttribute("class")?.match(/theme-(\w+)/)||n.getAttribute("class")?.match(/(\w+)-theme/);r&&(e.detectedName=Array.isArray(r)?r[1]:r)}}return Object.keys(e.variables).length>0?e:null}_extractCSSVariables(e){const t={},n=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 r=`--limbo-${e}`,a=n.getPropertyValue(r).trim();a&&(t[r]=a)});return["--primary-color","--background-color","--text-color","--border-color","--accent-color","--surface-color"].forEach(e=>{const r=n.getPropertyValue(e).trim();if(r){const n=this._mapGenericToLimbo(e,r);n&&Object.assign(t,n)}}),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 n=this._inheritPortalTheme();n&&(e=n),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 n="string"==typeof t?document.querySelector(t):t;n?(Object.entries(e.variables).forEach(([e,t])=>{n.style.setProperty(e,t),this.appliedStyles.add(`${n.tagName}:${e}`)}),this.themeCache.set(e.name,{theme:e,appliedAt:Date.now(),scope:n})):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 n=t.variables["--limbo-primary"]||"#3b82f6";let r=document.querySelector('meta[name="theme-color"]');r||(r=document.createElement("meta"),r.name="theme-color",document.head.appendChild(r)),r.content=n}_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),n={};return Object.keys(e.variables).forEach(e=>{n[e]=t.getPropertyValue(e).trim()}),n}_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(n=>{try{n({theme:e,previousTheme:t,themeData:this._getTheme(e),variables:this._getCurrentVariables()})}catch(r){console.error("Error in theme change callback:",r)}})}generateThemeFromColors(e,t){const n={name:e,displayName:e,variables:{}};t.primary&&(n.variables["--limbo-primary"]=t.primary,n.variables["--limbo-primary-hover"]=this._darkenColor(t.primary,10),n.variables["--limbo-primary-light"]=this._lightenColor(t.primary,40),n.variables["--limbo-primary-dark"]=this._darkenColor(t.primary,20)),t.background&&(n.variables["--limbo-bg-primary"]=t.background,n.variables["--limbo-bg-secondary"]=this._lightenColor(t.background,5),n.variables["--limbo-bg-tertiary"]=this._lightenColor(t.background,10),n.variables["--limbo-bg-card"]=t.background),t.text&&(n.variables["--limbo-text-primary"]=t.text,n.variables["--limbo-text-secondary"]=this._lightenColor(t.text,20),n.variables["--limbo-text-tertiary"]=this._lightenColor(t.text,40));const r=this._getTheme(this.config.inheritance.fallbackTheme);return r&&(n.variables={...r.variables,...n.variables}),this.registerTheme(e,n),n}_darkenColor(e,t){const n=parseInt(e.replace("#",""),16),r=Math.round(2.55*t),a=(n>>16)-r,i=(n>>8&255)-r,o=(255&n)-r;return"#"+(16777216+65536*(a<255?a<1?0:a:255)+256*(i<255?i<1?0:i:255)+(o<255?o<1?0:o:255)).toString(16).slice(1)}_lightenColor(e,t){const n=parseInt(e.replace("#",""),16),r=Math.round(2.55*t),a=(n>>16)+r,i=(n>>8&255)+r,o=(255&n)+r;return"#"+(16777216+65536*(a<255?a<1?0:a:255)+256*(i<255?i<1?0:i:255)+(o<255?o<1?0:o:255)).toString(16).slice(1)}_deepMerge(e,t){const n={...e};return Object.keys(t).forEach(r=>{t[r]&&"object"==typeof t[r]&&!Array.isArray(t[r])?n[r]=this._deepMerge(e[r]||{},t[r]):n[r]=t[r]}),n}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 yn=new class{constructor(){this.config=new n,this.instances=new mn,this.autoInputs=new hn,this.events=new pn,this.modals=new fn,this.theme=new bn,this.containerQueryDetector=P,this._setupInternalListeners(),this._initializeContainerQueries()}configure(e){var t;return this.config.setGlobal(e),t={publicKey:e.publicKey,apiKey:e.apiKey,token:e.token,authMode:e.authMode||"manual",prod:e.prod||!1,mode:e.mode||"embed",callbacks:e.callbacks||null},R={...R,...t},R.authMode||(R.token?R.authMode="manual":R.authMode="session"),this.config}setToken(e){return function(e){R.token=e}(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",n=e||`[${t}]`,r=document.querySelectorAll(n);if(0===r.length)return{found:0,processed:0,skipped:0};let a=0,i=0;return r.forEach(e=>{try{this.autoInputs._processInput(e),a++}catch(t){console.warn(`⚠️ Limbo: Error procesando input ${e.id||e.name}:`,t),i++}}),this.events.emit("limbo:scanCompleted",{found:r.length,processed:a,skipped:i,inputs:Array.from(r)}),{found:r.length,processed:a,skipped:i}}_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",n=e.querySelectorAll(`[${t}]`);let r=0;return n.forEach(e=>{if(!this.autoInputs.instances.has(this.autoInputs._getInputId(e)))try{this.autoInputs._processInput(e),r++}catch(t){console.warn("⚠️ Limbo: Error procesando nuevo input:",t)}}),r}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})=>{this._handleAutoInputModalRequest({config:e,callback:t})})}_handleAutoInputModalRequest({config:e,callback:t}){const n=this.create({...e,mode:"modal",autoDestroy:!0,callbacks:{onSelect:e=>{t(e),n.close()},onClose:()=>{}}});n.open()}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"},callbacks:{onSelect:n=>{e.onSelect?.(n),!1!==e.autoClose&&t.close()}},...e});return t.open(),t}openUploader(e={}){const t=!1!==e.redirectToGallery?["upload","gallery"]:["upload"],n=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"},callbacks:{onUpload:t=>{e.onUpload?.(t),!1===e.autoClose||e.redirectToGallery||n.close()}},...e});return n.open(),n}openCropper(e,t={}){if(!e)throw new Error("Limbo.openCropper: imageUrl es requerido");const n={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()}`},r=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&&r.close()},onCropperCancelled:e=>{t.onCancelled?.(e),!1!==t.autoClose&&r.close()},onCropperError:e=>{t.onError?.(e)}},_externalImage:n,...t});return r.open(),r}createInlineGallery(e,t={}){return this.create({container:e,mode:"embed",modeUI:"gallery-only",features:["gallery"],callbacks:{onSelect:t.onSelect,onDelete:t.onDelete},...t})}createInlineUploader(e,t={}){return this.create({container:e,mode:"embed",modeUI:"upload-only",features:["upload"],callbacks:{onUpload:t.onUpload},...t})}createStandaloneCropper(e,t,n={}){if(!e)throw new Error("Limbo.createStandaloneCropper: container es requerido");if(!t)throw new Error("Limbo.createStandaloneCropper: imageUrl es requerido");const r={url:t,filename:n.filename||"image.jpg",width:n.width||1920,height:n.height||1080,mime_type:n.mimeType||"image/jpeg",id:n.assetId||`external-${Date.now()}`};return this.create({container:e,mode:"embed",modeUI:"crop-only",features:["cropper"],autoHideOnComplete:!1!==n.autoHideOnComplete,cropper:{mandatoryCrops:n.mandatoryCrops||[],allowCustomCrops:!1!==n.allowCustomCrops,enforceRequiredCrops:!1!==n.enforceRequiredCrops},callbacks:{onCropperComplete:n.onComplete,onCropperCancelled:n.onCancelled,onCropperError:n.onError},_externalImage:r,...n})}createFullSelector(e,t={}){return this.create({container:e,mode:t.mode||"embed",modeUI:"full",features:["gallery","upload","cropper"],callbacks:{onSelect:t.onSelect,onUpload:t.onUpload,onDelete:t.onDelete,onCropsSaved:t.onCropsSaved},...t})}};"undefined"!=typeof window&&(window.Limbo=yn);return"undefined"!=typeof window&&document.querySelector("#root")&&(yn.configure({prod:!1,publicKey:"pk_e464fd744106b7a8d63d453c4bd02582",authMode:"session"}),yn.create({container:"#root",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],title:"Limbo Image Manager - Development",url:!0}),yn.configureAutoInputs({dataset:"data-limbo-input-file",return:"url",features:["gallery","upload","cropper"],modeUI:"full",modalSize:"large",title:"Seleccionar imagen",crops:"free",allowDelete:!1})),yn});
4
4
  //# sourceMappingURL=limbo.umd.map