limbo-component 2.3.2 → 2.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/limbo.cjs.js +1 -1
- package/dist/limbo.cjs.map +1 -1
- package/dist/limbo.es.js +5 -5
- package/dist/limbo.es.map +1 -1
- package/dist/limbo.min.js +1 -1
- package/dist/limbo.min.js.map +1 -1
- package/dist/limbo.umd.js +1 -1
- package/dist/limbo.umd.js.map +1 -1
- package/dist/types/App.d.ts.map +1 -1
- package/dist/types/components/CropperView.d.ts.map +1 -1
- package/dist/types/core/AutoInputManager.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/limbo.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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.for("react.activity"),p=Symbol.iterator;var f={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,b={};function y(e,t,n){this.props=e,this.context=t,this.refs=b,this.updater=n||f}function v(){}function x(e,t,n){this.props=e,this.context=t,this.refs=b,this.updater=n||f}y.prototype.isReactComponent={},y.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")},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},v.prototype=y.prototype;var w=x.prototype=new v;w.constructor=x,g(w,y.prototype),w.isPureReactComponent=!0;var k=Array.isArray;function S(){}var C={H:null,A:null,T:null,S:null},j=Object.prototype.hasOwnProperty;function N(t,n,r){var a=r.ref;return{$$typeof:e,type:t,key:n,ref:void 0!==a?a:null,props:r}}function E(t){return"object"==typeof t&&null!==t&&t.$$typeof===e}var $=/\/+/g;function _(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 z(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 z((u=n._init)(n._payload),r,a,i,o)}}if(u)return o=o(n),u=""===i?"."+_(n,0):i,k(o)?(a="",null!=u&&(a=u.replace($,"$&/")+"/"),z(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($,"$&/")+"/")+u,o=N(l.type,c,l.props)),r.push(o)),1;u=0;var d,h=""===i?".":i+":";if(k(n))for(var f=0;f<n.length;f++)u+=z(i=n[f],r,a,s=h+_(i,f),o);else if("function"==typeof(f=null===(d=n)||"object"!=typeof d?null:"function"==typeof(d=p&&d[p]||d["@@iterator"])?d:null))for(n=f.call(n),f=0;!(i=n.next()).done;)u+=z(i=i.value,r,a,s=h+_(i,f++),o);else if("object"===s){if("function"==typeof n.then)return z(function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch("string"==typeof e.status?e.then(S,S):(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 T(e,t,n){if(null==e)return e;var r=[],a=0;return z(e,r,"","",function(e){return t.call(n,e,a++)}),r}function A(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 P="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)},M={map:T,forEach:function(e,t,n){T(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return T(e,function(){t++}),t},toArray:function(e){return T(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}};return s.Activity=h,s.Children=M,s.Component=y,s.Fragment=n,s.Profiler=i,s.PureComponent=x,s.StrictMode=r,s.Suspense=u,s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,s.__COMPILER_RUNTIME={__proto__:null,c:function(e){return C.H.useMemoCache(e)}},s.cache=function(e){return function(){return e.apply(null,arguments)}},s.cacheSignal=function(){return null},s.cloneElement=function(e,t,n){if(null==e)throw Error("The argument must be a React element, but you passed "+e+".");var r=g({},e.props),a=e.key;if(null!=t)for(i in void 0!==t.key&&(a=""+t.key),t)!j.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 N(e.type,a,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)j.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 N(e,i,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:A}},s.memo=function(e,t){return{$$typeof:d,type:e,compare:void 0===t?null:t}},s.startTransition=function(e){var t=C.T,n={};C.T=n;try{var r=e(),a=C.S;null!==a&&a(n,r),"object"==typeof r&&null!==r&&"function"==typeof r.then&&r.then(S,P)}catch(i){P(i)}finally{null!==t&&null!==n.types&&(t.types=n.types),C.T=t}},s.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},s.use=function(e){return C.H.use(e)},s.useActionState=function(e,t,n){return C.H.useActionState(e,t,n)},s.useCallback=function(e,t){return C.H.useCallback(e,t)},s.useContext=function(e){return C.H.useContext(e)},s.useDebugValue=function(){},s.useDeferredValue=function(e,t){return C.H.useDeferredValue(e,t)},s.useEffect=function(e,t){return C.H.useEffect(e,t)},s.useEffectEvent=function(e){return C.H.useEffectEvent(e)},s.useId=function(){return C.H.useId()},s.useImperativeHandle=function(e,t,n){return C.H.useImperativeHandle(e,t,n)},s.useInsertionEffect=function(e,t){return C.H.useInsertionEffect(e,t)},s.useLayoutEffect=function(e,t){return C.H.useLayoutEffect(e,t)},s.useMemo=function(e,t){return C.H.useMemo(e,t)},s.useOptimistic=function(e,t){return C.H.useOptimistic(e,t)},s.useReducer=function(e,t,n){return C.H.useReducer(e,t,n)},s.useRef=function(e){return C.H.useRef(e)},s.useState=function(e){return C.H.useState(e)},s.useSyncExternalStore=function(e,t,n){return C.H.useSyncExternalStore(e,t,n)},s.useTransition=function(){return C.H.useTransition()},s.version="19.2.3",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,j=5,N=-1;function E(){return!(!g&&e.unstable_now()-N<j)}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&&E());){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"):j=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=E,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 j(){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.2.3",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=j()),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(31===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function l(e){if(i(e)!==e)throw Error(r(188))}function u(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=u(e)))return t;e=e.sibling}return null}var d=Object.assign,m=Symbol.for("react.element"),h=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),k=Symbol.for("react.consumer"),C=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),E=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 g:return"Fragment";case v:return"Profiler";case b:return"StrictMode";case E:return"Suspense";case $:return"SuspenseList";case T:return"Activity"}if("object"==typeof e)switch(e.$$typeof){case p:return"Portal";case C:return e.displayName||"Context";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 D=Array.isArray,O=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=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,K,G=B(null),Q=B(null),Y=B(null),X=B(null);function J(e,t){switch(W(Y,t),W(Q,e),W(G,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?wd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)e=kd(t=wd(t),e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}H(G),W(G,e)}function Z(){H(G),H(Q),H(Y)}function ee(e){null!==e.memoizedState&&W(X,e);var t=G.current,n=kd(t,e.type);t!==n&&(W(Q,e),W(G,n))}function te(e){Q.current===e&&(H(G),H(Q)),X.current===e&&(H(X),pm._currentValue=F)}function ne(e){if(void 0===V)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);V=t&&t[1]||"",K=-1<n.stack.indexOf("\n at")?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return"\n"+V+e+K}var re=!1;function ae(e,t){if(!e||re)return"";re=!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{re=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?ne(n):""}function ie(e,t){switch(e.tag){case 26:case 27:case 5:return ne(e.type);case 16:return ne("Lazy");case 13:return e.child!==t&&null!==t?ne("Suspense Fallback"):ne("Suspense");case 19:return ne("SuspenseList");case 0:case 15:return ae(e.type,!1);case 11:return ae(e.type.render,!1);case 1:return ae(e.type,!0);case 31:return ne("Activity");default:return""}}function oe(e){try{var t="",n=null;do{t+=ie(e,n),n=e,e=e.return}while(e);return t}catch(r){return"\nError generating stack: "+r.message+"\n"+r.stack}}var se=Object.prototype.hasOwnProperty,le=e.unstable_scheduleCallback,ce=e.unstable_cancelCallback,ue=e.unstable_shouldYield,de=e.unstable_requestPaint,me=e.unstable_now,he=e.unstable_getCurrentPriorityLevel,pe=e.unstable_ImmediatePriority,fe=e.unstable_UserBlockingPriority,ge=e.unstable_NormalPriority,be=e.unstable_LowPriority,ye=e.unstable_IdlePriority,ve=e.log,xe=e.unstable_setDisableYieldValue,we=null,ke=null;function Se(e){if("function"==typeof ve&&xe(e),ke&&"function"==typeof ke.setStrictMode)try{ke.setStrictMode(we,e)}catch(t){}}var Ce=Math.clz32?Math.clz32:function(e){return 0===(e>>>=0)?32:31-(je(e)/Ne|0)|0},je=Math.log,Ne=Math.LN2;var Ee=256,$e=262144,_e=4194304;function ze(e){var t=42&e;if(0!==t)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Te(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=ze(r):0!==(o&=s)?a=ze(o):n||0!==(n=s&~e)&&(a=ze(n)):0!==(s=r&~i)?a=ze(s):0!==o?a=ze(o):n||0!==(n=r&~e)&&(a=ze(n)),0===a?0:0!==t&&t!==a&&0===(t&i)&&((i=a&-a)>=(n=t&-t)||32===i&&4194048&n)?t:a}function Ae(e,t){return 0===(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)}function Pe(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 Me(){var e=_e;return!(62914560&(_e<<=1))&&(_e=4194304),e}function Ie(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Le(e,t){e.pendingLanes|=t,268435456!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function De(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Ce(t);e.entangledLanes|=t,e.entanglements[r]=1073741824|e.entanglements[r]|261930&n}function Oe(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ce(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}function Re(e,t){var n=t&-t;return 0!==((n=42&n?1:Fe(n))&(e.suspendedLanes|t))?0:n}function Fe(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 Ue(e){return 2<(e&=-e)?8<e?134217727&e?32:268435456:8:2}function qe(){var e=R.p;return 0!==e?e:void 0===(e=window.event)?32:zm(e.type)}function Be(e,t){var n=R.p;try{return R.p=e,t()}finally{R.p=n}}var He=Math.random().toString(36).slice(2),We="__reactFiber$"+He,Ve="__reactProps$"+He,Ke="__reactContainer$"+He,Ge="__reactEvents$"+He,Qe="__reactListeners$"+He,Ye="__reactHandles$"+He,Xe="__reactResources$"+He,Je="__reactMarker$"+He;function Ze(e){delete e[We],delete e[Ve],delete e[Ge],delete e[Qe],delete e[Ye]}function et(e){var t=e[We];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ke]||n[We]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=Fd(e);null!==e;){if(n=e[We])return n;e=Fd(e)}return t}n=(e=n).parentNode}return null}function tt(e){if(e=e[We]||e[Ke]){var t=e.tag;if(5===t||6===t||13===t||31===t||26===t||27===t||3===t)return e}return null}function nt(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e.stateNode;throw Error(r(33))}function rt(e){var t=e[Xe];return t||(t=e[Xe]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function at(e){e[Je]=!0}var it=new Set,ot={};function st(e,t){lt(e,t),lt(e+"Capture",t)}function lt(e,t){for(ot[e]=t,e=0;e<t.length;e++)it.add(t[e])}var ct=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]*$"),ut={},dt={};function mt(e,t,n){if(a=t,se.call(dt,a)||!se.call(ut,a)&&(ct.test(a)?dt[a]=!0:(ut[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 ht(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 pt(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 ft(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function gt(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function bt(e){if(!e._valueTracker){var t=gt(e)?"checked":"value";e._valueTracker=function(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&void 0!==r&&"function"==typeof r.get&&"function"==typeof r.set){var a=r.get,i=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(e){n=""+e,i.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e,t,""+e[t])}}function yt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=gt(e)?e.checked?"true":"false":e.value),(e=r)!==n&&(t.setValue(e),!0)}function vt(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 xt=/[\n"\\]/g;function wt(e){return e.replace(xt,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function kt(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=""+ft(t)):e.value!==""+ft(t)&&(e.value=""+ft(t)):"submit"!==o&&"reset"!==o||e.removeAttribute("value"),null!=t?Ct(e,o,ft(t)):null!=n?Ct(e,o,ft(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=""+ft(s):e.removeAttribute("name")}function St(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 void bt(e);n=null!=n?""+ft(n):"",t=null!=t?""+ft(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),bt(e)}function Ct(e,t,n){"number"===t&&vt(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function jt(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=""+ft(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 Nt(e,t,n){null==t||((t=""+ft(t))!==e.value&&(e.value=t),null!=n)?e.defaultValue=null!=n?""+ft(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(D(a)){if(1<a.length)throw Error(r(93));a=a[0]}n=a}null==n&&(n=""),t=n}n=ft(t),e.defaultValue=n,(a=e.textContent)===n&&""!==a&&null!==a&&(e.value=a),bt(e)}function $t(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 _t=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 zt(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||_t.has(t)?"float"===t?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function Tt(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&&zt(e,i,a)}else for(var o in t)t.hasOwnProperty(o)&&zt(e,o,t[o])}function At(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 Pt=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"]]),Mt=/^[\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 It(e){return Mt.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Lt(){}var Dt=null;function Ot(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var Rt=null,Ft=null;function Ut(e){var t=tt(e);if(t&&(e=t.stateNode)){var n=e[Ve]||null;e:switch(e=t.stateNode,t.type){case"input":if(kt(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="'+wt(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var a=n[t];if(a!==e&&a.form===e.form){var i=a[Ve]||null;if(!i)throw Error(r(90));kt(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&&yt(a)}break e;case"textarea":Nt(e,n.value,n.defaultValue);break e;case"select":null!=(t=n.value)&&jt(e,!!n.multiple,t,!1)}}}var qt=!1;function Bt(e,t,n){if(qt)return e(t,n);qt=!0;try{return e(t)}finally{if(qt=!1,(null!==Rt||null!==Ft)&&(ru(),Rt&&(t=Rt,e=Ft,Ft=Rt=null,Ut(t),e)))for(t=0;t<e.length;t++)Ut(e[t])}}function Ht(e,t){var n=e.stateNode;if(null===n)return null;var a=n[Ve]||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 Wt=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),Vt=!1;if(Wt)try{var Kt={};Object.defineProperty(Kt,"passive",{get:function(){Vt=!0}}),window.addEventListener("test",Kt,Kt),window.removeEventListener("test",Kt,Kt)}catch(th){Vt=!1}var Gt=null,Qt=null,Yt=null;function Xt(){if(Yt)return Yt;var e,t,n=Qt,r=n.length,a="value"in Gt?Gt.value:Gt.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 Yt=a.slice(e,1<t?1-t:void 0)}function Jt(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 Zt(){return!0}function en(){return!1}function tn(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)?Zt:en,this.isPropagationStopped=en,this}return d(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=Zt)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=Zt)},persist:function(){},isPersistent:Zt}),t}var nn,rn,an,on={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},sn=tn(on),ln=d({},on,{view:0,detail:0}),cn=tn(ln),un=d({},ln,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:wn,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!==an&&(an&&"mousemove"===e.type?(nn=e.screenX-an.screenX,rn=e.screenY-an.screenY):rn=nn=0,an=e),nn)},movementY:function(e){return"movementY"in e?e.movementY:rn}}),dn=tn(un),mn=tn(d({},un,{dataTransfer:0})),hn=tn(d({},ln,{relatedTarget:0})),pn=tn(d({},on,{animationName:0,elapsedTime:0,pseudoElement:0})),fn=tn(d({},on,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}})),gn=tn(d({},on,{data:0})),bn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},yn={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"},vn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function xn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=vn[e])&&!!t[e]}function wn(){return xn}var kn=tn(d({},ln,{key:function(e){if(e.key){var t=bn[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=Jt(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?yn[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:wn,charCode:function(e){return"keypress"===e.type?Jt(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?Jt(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}})),Sn=tn(d({},un,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Cn=tn(d({},ln,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:wn})),jn=tn(d({},on,{propertyName:0,elapsedTime:0,pseudoElement:0})),Nn=tn(d({},un,{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})),En=tn(d({},on,{newState:0,oldState:0})),$n=[9,13,27,32],_n=Wt&&"CompositionEvent"in window,zn=null;Wt&&"documentMode"in document&&(zn=document.documentMode);var Tn=Wt&&"TextEvent"in window&&!zn,An=Wt&&(!_n||zn&&8<zn&&11>=zn),Pn=String.fromCharCode(32),Mn=!1;function In(e,t){switch(e){case"keyup":return-1!==$n.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ln(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Dn=!1;var On={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 Rn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!On[e.type]:"textarea"===t}function Fn(e,t,n,r){Rt?Ft?Ft.push(r):Ft=[r]:Rt=r,0<(t=sd(t,"onChange")).length&&(n=new sn("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Un=null,qn=null;function Bn(e){Zu(e,0)}function Hn(e){if(yt(nt(e)))return e}function Wn(e,t){if("change"===e)return t}var Vn=!1;if(Wt){var Kn;if(Wt){var Gn="oninput"in document;if(!Gn){var Qn=document.createElement("div");Qn.setAttribute("oninput","return;"),Gn="function"==typeof Qn.oninput}Kn=Gn}else Kn=!1;Vn=Kn&&(!document.documentMode||9<document.documentMode)}function Yn(){Un&&(Un.detachEvent("onpropertychange",Xn),qn=Un=null)}function Xn(e){if("value"===e.propertyName&&Hn(qn)){var t=[];Fn(t,qn,e,Ot(e)),Bt(Bn,t)}}function Jn(e,t,n){"focusin"===e?(Yn(),qn=n,(Un=t).attachEvent("onpropertychange",Xn)):"focusout"===e&&Yn()}function Zn(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Hn(qn)}function er(e,t){if("click"===e)return Hn(t)}function tr(e,t){if("input"===e||"change"===e)return Hn(t)}var nr="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t};function rr(e,t){if(nr(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(!se.call(t,a)||!nr(e[a],t[a]))return!1}return!0}function ar(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ir(e,t){var n,r=ar(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=ar(r)}}function or(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?or(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function sr(e){for(var t=vt((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=vt((e=t.contentWindow).document)}return t}function lr(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 cr=Wt&&"documentMode"in document&&11>=document.documentMode,ur=null,dr=null,mr=null,hr=!1;function pr(e,t,n){var r=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;hr||null==ur||ur!==vt(r)||("selectionStart"in(r=ur)&&lr(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},mr&&rr(mr,r)||(mr=r,0<(r=sd(dr,"onSelect")).length&&(t=new sn("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=ur)))}function fr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var gr={animationend:fr("Animation","AnimationEnd"),animationiteration:fr("Animation","AnimationIteration"),animationstart:fr("Animation","AnimationStart"),transitionrun:fr("Transition","TransitionRun"),transitionstart:fr("Transition","TransitionStart"),transitioncancel:fr("Transition","TransitionCancel"),transitionend:fr("Transition","TransitionEnd")},br={},yr={};function vr(e){if(br[e])return br[e];if(!gr[e])return e;var t,n=gr[e];for(t in n)if(n.hasOwnProperty(t)&&t in yr)return br[e]=n[t];return e}Wt&&(yr=document.createElement("div").style,"AnimationEvent"in window||(delete gr.animationend.animation,delete gr.animationiteration.animation,delete gr.animationstart.animation),"TransitionEvent"in window||delete gr.transitionend.transition);var xr=vr("animationend"),wr=vr("animationiteration"),kr=vr("animationstart"),Sr=vr("transitionrun"),Cr=vr("transitionstart"),jr=vr("transitioncancel"),Nr=vr("transitionend"),Er=new Map,$r="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 _r(e,t){Er.set(e,t),st(t,[e])}$r.push("scrollEnd");var zr="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)},Tr=[],Ar=0,Pr=0;function Mr(){for(var e=Ar,t=Pr=Ar=0;t<e;){var n=Tr[t];Tr[t++]=null;var r=Tr[t];Tr[t++]=null;var a=Tr[t];Tr[t++]=null;var i=Tr[t];if(Tr[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&&Or(n,a,i)}}function Ir(e,t,n,r){Tr[Ar++]=e,Tr[Ar++]=t,Tr[Ar++]=n,Tr[Ar++]=r,Pr|=r,e.lanes|=r,null!==(e=e.alternate)&&(e.lanes|=r)}function Lr(e,t,n,r){return Ir(e,t,n,r),Rr(e)}function Dr(e,t){return Ir(e,null,null,t),Rr(e)}function Or(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-Ce(n),null===(r=(e=i.hiddenUpdates)[a])?e[a]=[t]:r.push(t),t.lane=536870912|n),i):null}function Rr(e){if(50<Gc)throw Gc=0,Qc=null,Error(r(185));for(var t=e.return;null!==t;)t=(e=t).return;return 3===e.tag?e.stateNode:null}var Fr={};function Ur(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 qr(e,t,n,r){return new Ur(e,t,n,r)}function Br(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Hr(e,t){var n=e.alternate;return null===n?((n=qr(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 Wr(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 Vr(e,t,n,a,i,o){var s=0;if(a=e,"function"==typeof e)Br(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,G.current)?26:"html"===e||"head"===e||"body"===e?27:5;else e:switch(e){case T:return(e=qr(31,n,t,i)).elementType=T,e.lanes=o,e;case g:return Kr(n.children,i,o,t);case b:s=8,i|=24;break;case v:return(e=qr(12,n,t,2|i)).elementType=v,e.lanes=o,e;case E:return(e=qr(13,n,t,i)).elementType=E,e.lanes=o,e;case $:return(e=qr(19,n,t,i)).elementType=$,e.lanes=o,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){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=qr(s,n,t,i)).elementType=e,t.type=a,t.lanes=o,t}function Kr(e,t,n,r){return(e=qr(7,e,r,t)).lanes=n,e}function Gr(e,t,n){return(e=qr(6,e,null,t)).lanes=n,e}function Qr(e){var t=qr(18,null,null,0);return t.stateNode=e,t}function Yr(e,t,n){return(t=qr(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Xr=new WeakMap;function Jr(e,t){if("object"==typeof e&&null!==e){var n=Xr.get(e);return void 0!==n?n:(t={value:e,source:t,stack:oe(t)},Xr.set(e,t),t)}return{value:e,source:t,stack:oe(t)}}var Zr=[],ea=0,ta=null,na=0,ra=[],aa=0,ia=null,oa=1,sa="";function la(e,t){Zr[ea++]=na,Zr[ea++]=ta,ta=e,na=t}function ca(e,t,n){ra[aa++]=oa,ra[aa++]=sa,ra[aa++]=ia,ia=e;var r=oa;e=sa;var a=32-Ce(r)-1;r&=~(1<<a),n+=1;var i=32-Ce(t)+a;if(30<i){var o=a-a%5;i=(r&(1<<o)-1).toString(32),r>>=o,a-=o,oa=1<<32-Ce(t)+a|n<<a|r,sa=i+e}else oa=1<<i|n<<a|r,sa=e}function ua(e){null!==e.return&&(la(e,1),ca(e,1,0))}function da(e){for(;e===ta;)ta=Zr[--ea],Zr[ea]=null,na=Zr[--ea],Zr[ea]=null;for(;e===ia;)ia=ra[--aa],ra[aa]=null,sa=ra[--aa],ra[aa]=null,oa=ra[--aa],ra[aa]=null}function ma(e,t){ra[aa++]=oa,ra[aa++]=sa,ra[aa++]=ia,oa=t.id,sa=t.overflow,ia=e}var ha=null,pa=null,fa=!1,ga=null,ba=!1,ya=Error(r(519));function va(e){throw ja(Jr(Error(r(418,1<arguments.length&&void 0!==arguments[1]&&arguments[1]?"text":"HTML","")),e)),ya}function xa(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[We]=e,t[Ve]=r,n){case"dialog":ed("cancel",t),ed("close",t);break;case"iframe":case"object":case"embed":ed("load",t);break;case"video":case"audio":for(n=0;n<Xu.length;n++)ed(Xu[n],t);break;case"source":ed("error",t);break;case"img":case"image":case"link":ed("error",t),ed("load",t);break;case"details":ed("toggle",t);break;case"input":ed("invalid",t),St(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case"select":ed("invalid",t);break;case"textarea":ed("invalid",t),Et(t,r.value,r.defaultValue,r.children)}"string"!=typeof(n=r.children)&&"number"!=typeof n&&"bigint"!=typeof n||t.textContent===""+n||!0===r.suppressHydrationWarning||hd(t.textContent,n)?(null!=r.popover&&(ed("beforetoggle",t),ed("toggle",t)),null!=r.onScroll&&ed("scroll",t),null!=r.onScrollEnd&&ed("scrollend",t),null!=r.onClick&&(t.onclick=Lt),t=!0):t=!1,t||va(e,!0)}function wa(e){for(ha=e.return;ha;)switch(ha.tag){case 5:case 31:case 13:return void(ba=!1);case 27:case 3:return void(ba=!0);default:ha=ha.return}}function ka(e){if(e!==ha)return!1;if(!fa)return wa(e),fa=!0,!1;var t,n=e.tag;if((t=3!==n&&27!==n)&&((t=5===n)&&(t=!("form"!==(t=e.type)&&"button"!==t)||Sd(e.type,e.memoizedProps)),t=!t),t&&pa&&va(e),wa(e),13===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(r(317));pa=Rd(e)}else if(31===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(r(317));pa=Rd(e)}else 27===n?(n=pa,zd(e.type)?(e=Od,Od=null,pa=e):pa=n):pa=ha?Dd(e.stateNode.nextSibling):null;return!0}function Sa(){pa=ha=null,fa=!1}function Ca(){var e=ga;return null!==e&&(null===Mc?Mc=e:Mc.push.apply(Mc,e),ga=null),e}function ja(e){null===ga?ga=[e]:ga.push(e)}var Na=B(null),Ea=null,$a=null;function _a(e,t,n){W(Na,t._currentValue),t._currentValue=n}function za(e){e._currentValue=Na.current,H(Na)}function Ta(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 Aa(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),Ta(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),Ta(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 Pa(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;nr(i.pendingProps.value,s.value)||(null!==e?e.push(l):e=[l])}}else if(i===X.current){if(null===(s=i.alternate))throw Error(r(387));s.memoizedState.memoizedState!==i.memoizedState.memoizedState&&(null!==e?e.push(pm):e=[pm])}i=i.return}null!==e&&Aa(t,e,n,a),t.flags|=262144}function Ma(e){for(e=e.firstContext;null!==e;){if(!nr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ia(e){Ea=e,$a=null,null!==(e=e.dependencies)&&(e.firstContext=null)}function La(e){return Oa(Ea,e)}function Da(e,t){return null===Ea&&Ia(e),Oa(e,t)}function Oa(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},null===$a){if(null===e)throw Error(r(308));$a=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else $a=$a.next=t;return n}var Ra="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()})}},Fa=e.unstable_scheduleCallback,Ua=e.unstable_NormalPriority,qa={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ba(){return{controller:new Ra,data:new Map,refCount:0}}function Ha(e){e.refCount--,0===e.refCount&&Fa(Ua,function(){e.controller.abort()})}var Wa=null,Va=0,Ka=0,Ga=null;function Qa(){if(0===--Va&&null!==Wa){null!==Ga&&(Ga.status="fulfilled");var e=Wa;Wa=null,Ka=0,Ga=null;for(var t=0;t<e.length;t++)(0,e[t])()}}var Ya=O.S;O.S=function(e,t){Dc=me(),"object"==typeof t&&null!==t&&"function"==typeof t.then&&function(e,t){if(null===Wa){var n=Wa=[];Va=0,Ka=Vu(),Ga={status:"pending",value:void 0,then:function(e){n.push(e)}}}Va++,t.then(Qa,Qa)}(0,t),null!==Ya&&Ya(e,t)};var Xa=B(null);function Ja(){var e=Xa.current;return null!==e?e:yc.pooledCache}function Za(e,t){W(Xa,null===t?Xa.current:t.pool)}function ei(){var e=Ja();return null===e?null:{parent:qa._currentValue,pool:e}}var ti=Error(r(460)),ni=Error(r(474)),ri=Error(r(542)),ai={then:function(){}};function ii(e){return"fulfilled"===(e=e.status)||"rejected"===e}function oi(e,t,n){switch(void 0===(n=e[n])?e.push(t):n!==t&&(t.then(Lt,Lt),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw ui(e=t.reason),e;default:if("string"==typeof t.status)t.then(Lt,Lt);else{if(null!==(e=yc)&&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 ui(e=t.reason),e}throw li=t,ti}}function si(e){try{return(0,e._init)(e._payload)}catch(t){if(null!==t&&"object"==typeof t&&"function"==typeof t.then)throw li=t,ti;throw t}}var li=null;function ci(){if(null===li)throw Error(r(459));var e=li;return li=null,e}function ui(e){if(e===ti||e===ri)throw Error(r(483))}var di=null,mi=0;function hi(e){var t=mi;return mi+=1,null===di&&(di=[]),oi(di,e,t)}function pi(e,t){t=t.props.ref,e.ref=void 0!==t?t:null}function fi(e,t){if(t.$$typeof===m)throw Error(r(525));throw e=Object.prototype.toString.call(t),Error(r(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function gi(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=Hr(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=Gr(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===g?d(e,t,n.props.children,r,n.key):null!==t&&(t.elementType===a||"object"==typeof a&&null!==a&&a.$$typeof===z&&si(a)===t.type)?(pi(t=i(t,n.props),n),t.return=e,t):(pi(t=Vr(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=Yr(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=Kr(n,e.mode,r,a)).return=e,t):((t=i(t,n)).return=e,t)}function m(e,t,n){if("string"==typeof t&&""!==t||"number"==typeof t||"bigint"==typeof t)return(t=Gr(""+t,e.mode,n)).return=e,t;if("object"==typeof t&&null!==t){switch(t.$$typeof){case h:return pi(n=Vr(t.type,t.key,t.props,null,e.mode,n),t),n.return=e,n;case p:return(t=Yr(t,e.mode,n)).return=e,t;case z:return m(e,t=si(t),n)}if(D(t)||M(t))return(t=Kr(t,e.mode,n,null)).return=e,t;if("function"==typeof t.then)return m(e,hi(t),n);if(t.$$typeof===C)return m(e,Da(e,t),n);fi(e,t)}return null}function f(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 h:return n.key===a?c(e,t,n,r):null;case p:return n.key===a?u(e,t,n,r):null;case z:return f(e,t,n=si(n),r)}if(D(n)||M(n))return null!==a?null:d(e,t,n,r,null);if("function"==typeof n.then)return f(e,t,hi(n),r);if(n.$$typeof===C)return f(e,t,Da(e,n),r);fi(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 h:return c(t,e=e.get(null===r.key?n:r.key)||null,r,a);case p:return u(t,e=e.get(null===r.key?n:r.key)||null,r,a);case z:return b(e,t,n,r=si(r),a)}if(D(r)||M(r))return d(t,e=e.get(n)||null,r,a,null);if("function"==typeof r.then)return b(e,t,n,hi(r),a);if(r.$$typeof===C)return b(e,t,n,Da(t,r),a);fi(t,r)}return null}function y(l,c,u,d){if("object"==typeof u&&null!==u&&u.type===g&&null===u.key&&(u=u.props.children),"object"==typeof u&&null!==u){switch(u.$$typeof){case h:e:{for(var v=u.key;null!==c;){if(c.key===v){if((v=u.type)===g){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&&si(v)===c.type){n(l,c.sibling),pi(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===g?((d=Kr(u.props.children,l.mode,d,u.key)).return=l,l=d):(pi(d=Vr(u.type,u.key,u.props,null,l.mode,d),u),d.return=l,l=d)}return s(l);case p: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=Yr(u,l.mode,d)).return=l,l=d}return s(l);case z:return y(l,c,u=si(u),d)}if(D(u))return function(r,i,s,l){for(var c=null,u=null,d=i,h=i=0,p=null;null!==d&&h<s.length;h++){d.index>h?(p=d,d=null):p=d.sibling;var g=f(r,d,s[h],l);if(null===g){null===d&&(d=p);break}e&&d&&null===g.alternate&&t(r,d),i=o(g,i,h),null===u?c=g:u.sibling=g,u=g,d=p}if(h===s.length)return n(r,d),fa&&la(r,h),c;if(null===d){for(;h<s.length;h++)null!==(d=m(r,s[h],l))&&(i=o(d,i,h),null===u?c=d:u.sibling=d,u=d);return fa&&la(r,h),c}for(d=a(d);h<s.length;h++)null!==(p=b(d,r,h,s[h],l))&&(e&&null!==p.alternate&&d.delete(null===p.key?h:p.key),i=o(p,i,h),null===u?c=p:u.sibling=p,u=p);return e&&d.forEach(function(e){return t(r,e)}),fa&&la(r,h),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,h=s,p=s=0,g=null,y=l.next();null!==h&&!y.done;p++,y=l.next()){h.index>p?(g=h,h=null):g=h.sibling;var v=f(i,h,y.value,c);if(null===v){null===h&&(h=g);break}e&&h&&null===v.alternate&&t(i,h),s=o(v,s,p),null===d?u=v:d.sibling=v,d=v,h=g}if(y.done)return n(i,h),fa&&la(i,p),u;if(null===h){for(;!y.done;p++,y=l.next())null!==(y=m(i,y.value,c))&&(s=o(y,s,p),null===d?u=y:d.sibling=y,d=y);return fa&&la(i,p),u}for(h=a(h);!y.done;p++,y=l.next())null!==(y=b(h,i,p,y.value,c))&&(e&&null!==y.alternate&&h.delete(null===y.key?p:y.key),s=o(y,s,p),null===d?u=y:d.sibling=y,d=y);return e&&h.forEach(function(e){return t(i,e)}),fa&&la(i,p),u}(l,c,u=v.call(u),d)}if("function"==typeof u.then)return y(l,c,hi(u),d);if(u.$$typeof===C)return y(l,c,Da(l,u),d);fi(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=Gr(u,l.mode,d)).return=l,l=d),s(l)):n(l,c)}return function(e,t,n,r){try{mi=0;var a=y(e,t,n,r);return di=null,a}catch(o){if(o===ti||o===ri)throw o;var i=qr(29,o,null,e.mode);return i.lanes=r,i.return=e,i}}}var bi=gi(!0),yi=gi(!1),vi=!1;function xi(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function wi(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 ki(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Si(e,t,n){var r=e.updateQueue;if(null===r)return null;if(r=r.shared,2&bc){var a=r.pending;return null===a?t.next=t:(t.next=a.next,a.next=t),r.pending=t,t=Rr(e),Or(e,null,n),t}return Ir(e,r,t,n),Rr(e)}function Ci(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,4194048&n)){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,Oe(e,n)}}function ji(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 Ni=!1;function Ei(){if(Ni){if(null!==Ga)throw Ga}}function $i(e,t,n,r){Ni=!1;var a=e.updateQueue;vi=!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 u=e.alternate;null!==u&&((s=(u=u.updateQueue).lastBaseUpdate)!==o&&(null===s?u.firstBaseUpdate=c:s.next=c,u.lastBaseUpdate=l))}if(null!==i){var m=a.baseState;for(o=0,u=c=l=null,s=i;;){var h=-536870913&s.lane,p=h!==s.lane;if(p?(xc&h)===h:(r&h)===h){0!==h&&h===Ka&&(Ni=!0),null!==u&&(u=u.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=d({},m,h);break e;case 2:vi=!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===u?(c=u=p,l=m):u=u.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===u&&(l=m),a.baseState=l,a.firstBaseUpdate=c,a.lastBaseUpdate=u,null===i&&(a.shared.lanes=0),$c|=o,e.lanes=o,e.memoizedState=m}}function _i(e,t){if("function"!=typeof e)throw Error(r(191,e));e.call(t)}function zi(e,t){var n=e.callbacks;if(null!==n)for(e.callbacks=null,e=0;e<n.length;e++)_i(n[e],t)}var Ti=B(null),Ai=B(0);function Pi(e,t){W(Ai,e=Nc),W(Ti,t),Nc=e|t.baseLanes}function Mi(){W(Ai,Nc),W(Ti,Ti.current)}function Ii(){Nc=Ai.current,H(Ti),H(Ai)}var Li=B(null),Di=null;function Oi(e){var t=e.alternate;W(Bi,1&Bi.current),W(Li,e),null===Di&&(null===t||null!==Ti.current||null!==t.memoizedState)&&(Di=e)}function Ri(e){W(Bi,Bi.current),W(Li,e),null===Di&&(Di=e)}function Fi(e){22===e.tag?(W(Bi,Bi.current),W(Li,e),null===Di&&(Di=e)):Ui()}function Ui(){W(Bi,Bi.current),W(Li,Li.current)}function qi(e){H(Li),Di===e&&(Di=null),H(Bi)}var Bi=B(0);function Hi(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||Id(n)||Ld(n)))return t}else if(19!==t.tag||"forwards"!==t.memoizedProps.revealOrder&&"backwards"!==t.memoizedProps.revealOrder&&"unstable_legacy-backwards"!==t.memoizedProps.revealOrder&&"together"!==t.memoizedProps.revealOrder){if(null!==t.child){t.child.return=t,t=t.child;continue}}else if(128&t.flags)return t;if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Wi=0,Vi=null,Ki=null,Gi=null,Qi=!1,Yi=!1,Xi=!1,Ji=0,Zi=0,eo=null,to=0;function no(){throw Error(r(321))}function ro(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!nr(e[n],t[n]))return!1;return!0}function ao(e,t,n,r,a,i){return Wi=i,Vi=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,O.H=null===e||null===e.memoizedState?xs:ws,Xi=!1,i=n(r,a),Xi=!1,Yi&&(i=oo(t,n,r,a)),io(e),i}function io(e){O.H=vs;var t=null!==Ki&&null!==Ki.next;if(Wi=0,Gi=Ki=Vi=null,Qi=!1,Zi=0,eo=null,t)throw Error(r(300));null===e||Ds||null!==(e=e.dependencies)&&Ma(e)&&(Ds=!0)}function oo(e,t,n,a){Vi=e;var i=0;do{if(Yi&&(eo=null),Zi=0,Yi=!1,25<=i)throw Error(r(301));if(i+=1,Gi=Ki=null,null!=e.updateQueue){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,null!=o.memoCache&&(o.memoCache.index=0)}O.H=ks,o=t(n,a)}while(Yi);return o}function so(){var e=O.H,t=e.useState()[0];return t="function"==typeof t.then?po(t):t,e=e.useState()[0],(null!==Ki?Ki.memoizedState:null)!==e&&(Vi.flags|=1024),t}function lo(){var e=0!==Ji;return Ji=0,e}function co(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function uo(e){if(Qi){for(e=e.memoizedState;null!==e;){var t=e.queue;null!==t&&(t.pending=null),e=e.next}Qi=!1}Wi=0,Gi=Ki=Vi=null,Yi=!1,Zi=Ji=0,eo=null}function mo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===Gi?Vi.memoizedState=Gi=e:Gi=Gi.next=e,Gi}function ho(){if(null===Ki){var e=Vi.alternate;e=null!==e?e.memoizedState:null}else e=Ki.next;var t=null===Gi?Vi.memoizedState:Gi.next;if(null!==t)Gi=t,Ki=e;else{if(null===e){if(null===Vi.alternate)throw Error(r(467));throw Error(r(310))}e={memoizedState:(Ki=e).memoizedState,baseState:Ki.baseState,baseQueue:Ki.baseQueue,queue:Ki.queue,next:null},null===Gi?Vi.memoizedState=Gi=e:Gi=Gi.next=e}return Gi}function po(e){var t=Zi;return Zi+=1,null===eo&&(eo=[]),e=oi(eo,e,t),t=Vi,null===(null===Gi?t.memoizedState:Gi.next)&&(t=t.alternate,O.H=null===t||null===t.memoizedState?xs:ws),e}function fo(e){if(null!==e&&"object"==typeof e){if("function"==typeof e.then)return po(e);if(e.$$typeof===C)return La(e)}throw Error(r(438,String(e)))}function go(e){var t=null,n=Vi.updateQueue;if(null!==n&&(t=n.memoCache),null==t){var r=Vi.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},Vi.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 bo(e,t){return"function"==typeof t?t(e):t}function yo(e){return vo(ho(),Ki,e)}function vo(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?(xc&m)===m:(Wi&m)===m){var h=u.revertLane;if(0===h)null!==c&&(c=c.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),m===Ka&&(d=!0);else{if((Wi&h)===h){u=u.next,h===Ka&&(d=!0);continue}m={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(l=c=m,s=o):c=c.next=m,Vi.lanes|=h,$c|=h}m=u.action,Xi&&n(o,m),o=u.hasEagerState?u.eagerState:n(o,m)}else h={lane:m,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(l=c=h,s=o):c=c.next=h,Vi.lanes|=m,$c|=m;u=u.next}while(null!==u&&u!==t);if(null===c?s=o:c.next=l,!nr(o,e.memoizedState)&&(Ds=!0,d&&null!==(n=Ga)))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 xo(e){var t=ho(),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);nr(o,t.memoizedState)||(Ds=!0),t.memoizedState=o,null===t.baseQueue&&(t.baseState=o),n.lastRenderedState=o}return[o,a]}function wo(e,t,n){var a=Vi,i=ho(),o=fa;if(o){if(void 0===n)throw Error(r(407));n=n()}else n=t();var s=!nr((Ki||i).memoizedState,n);if(s&&(i.memoizedState=n,Ds=!0),i=i.queue,Vo(Co.bind(null,a,i,e),[e]),i.getSnapshot!==t||s||null!==Gi&&1&Gi.memoizedState.tag){if(a.flags|=2048,Uo(9,{destroy:void 0},So.bind(null,a,i,n,t),null),null===yc)throw Error(r(349));o||127&Wi||ko(a,t,n)}return n}function ko(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=Vi.updateQueue)?(t={lastEffect:null,events:null,stores:null,memoCache:null},Vi.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function So(e,t,n,r){t.value=n,t.getSnapshot=r,jo(t)&&No(e)}function Co(e,t,n){return n(function(){jo(t)&&No(e)})}function jo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!nr(e,n)}catch(r){return!0}}function No(e){var t=Dr(e,2);null!==t&&Jc(t,e,2)}function Eo(e){var t=mo();if("function"==typeof e){var n=e;if(e=n(),Xi){Se(!0);try{n()}finally{Se(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:bo,lastRenderedState:e},t}function $o(e,t,n,r){return e.baseState=n,vo(e,Ki,"function"==typeof r?r:bo)}function _o(e,t,n,a,i){if(gs(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!==O.T?n(!0):o.isTransition=!1,a(o),null===(n=t.pending)?(o.next=t.pending=o,zo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function zo(e,t){var n=t.action,r=t.payload,a=e.state;if(t.isTransition){var i=O.T,o={};O.T=o;try{var s=n(a,r),l=O.S;null!==l&&l(o,s),To(e,t,s)}catch(c){Po(e,t,c)}finally{null!==i&&null!==o.types&&(i.types=o.types),O.T=i}}else try{To(e,t,i=n(a,r))}catch(u){Po(e,t,u)}}function To(e,t,n){null!==n&&"object"==typeof n&&"function"==typeof n.then?n.then(function(n){Ao(e,t,n)},function(n){return Po(e,t,n)}):Ao(e,t,n)}function Ao(e,t,n){t.status="fulfilled",t.value=n,Mo(t),e.state=n,null!==(t=e.pending)&&((n=t.next)===t?e.pending=null:(n=n.next,t.next=n,zo(e,n)))}function Po(e,t,n){var r=e.pending;if(e.pending=null,null!==r){r=r.next;do{t.status="rejected",t.reason=n,Mo(t),t=t.next}while(t!==r)}e.action=null}function Mo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Io(e,t){return t}function Lo(e,t){if(fa){var n=yc.formState;if(null!==n){e:{var r=Vi;if(fa){if(pa){t:{for(var a=pa,i=ba;8!==a.nodeType;){if(!i){a=null;break t}if(null===(a=Dd(a.nextSibling))){a=null;break t}}a="F!"===(i=a.data)||"F"===i?a:null}if(a){pa=Dd(a.nextSibling),r="F!"===a.data;break e}}va(r)}r=!1}r&&(t=n[0])}}return(n=mo()).memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Io,lastRenderedState:t},n.queue=r,n=hs.bind(null,Vi,r),r.dispatch=n,r=Eo(!1),i=fs.bind(null,Vi,!1,r.queue),a={state:t,dispatch:null,action:e,pending:null},(r=mo()).queue=a,n=_o.bind(null,Vi,a,i,n),a.dispatch=n,r.memoizedState=e,[t,n,!1]}function Do(e){return Oo(ho(),Ki,e)}function Oo(e,t,n){if(t=vo(e,t,Io)[0],e=yo(bo)[0],"object"==typeof t&&null!==t&&"function"==typeof t.then)try{var r=po(t)}catch(o){if(o===ti)throw ri;throw o}else r=t;var a=(t=ho()).queue,i=a.dispatch;return n!==t.memoizedState&&(Vi.flags|=2048,Uo(9,{destroy:void 0},Ro.bind(null,a,n),null)),[r,i,e]}function Ro(e,t){e.action=t}function Fo(e){var t=ho(),n=Ki;if(null!==n)return Oo(t,n,e);ho(),t=t.memoizedState;var r=(n=ho()).queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Uo(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},null===(t=Vi.updateQueue)&&(t={lastEffect:null,events:null,stores:null,memoCache:null},Vi.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 qo(){return ho().memoizedState}function Bo(e,t,n,r){var a=mo();Vi.flags|=e,a.memoizedState=Uo(1|t,{destroy:void 0},n,void 0===r?null:r)}function Ho(e,t,n,r){var a=ho();r=void 0===r?null:r;var i=a.memoizedState.inst;null!==Ki&&null!==r&&ro(r,Ki.memoizedState.deps)?a.memoizedState=Uo(t,i,n,r):(Vi.flags|=e,a.memoizedState=Uo(1|t,i,n,r))}function Wo(e,t){Bo(8390656,8,e,t)}function Vo(e,t){Ho(2048,8,e,t)}function Ko(e){var t=ho().memoizedState;return function(e){Vi.flags|=4;var t=Vi.updateQueue;if(null===t)t={lastEffect:null,events:null,stores:null,memoCache:null},Vi.updateQueue=t,t.events=[e];else{var n=t.events;null===n?t.events=[e]:n.push(e)}}({ref:t,nextImpl:e}),function(){if(2&bc)throw Error(r(440));return t.impl.apply(void 0,arguments)}}function Go(e,t){return Ho(4,2,e,t)}function Qo(e,t){return Ho(4,4,e,t)}function Yo(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 Xo(e,t,n){n=null!=n?n.concat([e]):null,Ho(4,4,Yo.bind(null,t,e),n)}function Jo(){}function Zo(e,t){var n=ho();t=void 0===t?null:t;var r=n.memoizedState;return null!==t&&ro(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function es(e,t){var n=ho();t=void 0===t?null:t;var r=n.memoizedState;if(null!==t&&ro(t,r[1]))return r[0];if(r=e(),Xi){Se(!0);try{e()}finally{Se(!1)}}return n.memoizedState=[r,t],r}function ts(e,t,n){return void 0===n||1073741824&Wi&&!(261930&xc)?e.memoizedState=t:(e.memoizedState=n,e=Xc(),Vi.lanes|=e,$c|=e,n)}function ns(e,t,n,r){return nr(n,t)?n:null!==Ti.current?(e=ts(e,n,r),nr(e,t)||(Ds=!0),e):42&Wi&&(!(1073741824&Wi)||261930&xc)?(e=Xc(),Vi.lanes|=e,$c|=e,t):(Ds=!0,e.memoizedState=n)}function rs(e,t,n,r,a){var i=R.p;R.p=0!==i&&8>i?i:8;var o,s,l,c=O.T,u={};O.T=u,fs(e,!1,t,n);try{var d=a(),m=O.S;if(null!==m&&m(u,d),null!==d&&"object"==typeof d&&"function"==typeof d.then)ps(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),Yc());else ps(e,t,r,Yc())}catch(h){ps(e,t,{then:function(){},status:"rejected",reason:h},Yc())}finally{R.p=i,null!==c&&null!==u.types&&(c.types=u.types),O.T=c}}function as(){}function is(e,t,n,a){if(5!==e.tag)throw Error(r(476));var i=os(e).queue;rs(e,i,t,F,null===n?as:function(){return ss(e),n(a)})}function os(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:bo,lastRenderedState:F},next:null}).next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:bo,lastRenderedState:n},next:null},e.memoizedState=t,null!==(e=e.alternate)&&(e.memoizedState=t),t}function ss(e){var t=os(e);null===t.next&&(t=e.alternate.memoizedState),ps(e,t.next.queue,{},Yc())}function ls(){return La(pm)}function cs(){return ho().memoizedState}function us(){return ho().memoizedState}function ds(e){for(var t=e.return;null!==t;){switch(t.tag){case 24:case 3:var n=Yc(),r=Si(t,e=ki(n),n);return null!==r&&(Jc(r,t,n),Ci(r,t,n)),t={cache:Ba()},void(e.payload=t)}t=t.return}}function ms(e,t,n){var r=Yc();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},gs(e)?bs(t,n):null!==(n=Lr(e,t,n,r))&&(Jc(n,e,r),ys(n,t,r))}function hs(e,t,n){ps(e,t,n,Yc())}function ps(e,t,n,r){var a={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(gs(e))bs(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,nr(s,o))return Ir(e,t,a,0),null===yc&&Mr(),!1}catch(l){}if(null!==(n=Lr(e,t,a,r)))return Jc(n,e,r),ys(n,t,r),!0}return!1}function fs(e,t,n,a){if(a={lane:2,revertLane:Vu(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},gs(e)){if(t)throw Error(r(479))}else null!==(t=Lr(e,n,a,2))&&Jc(t,e,2)}function gs(e){var t=e.alternate;return e===Vi||null!==t&&t===Vi}function bs(e,t){Yi=Qi=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ys(e,t,n){if(4194048&n){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,Oe(e,n)}}var vs={readContext:La,use:fo,useCallback:no,useContext:no,useEffect:no,useImperativeHandle:no,useLayoutEffect:no,useInsertionEffect:no,useMemo:no,useReducer:no,useRef:no,useState:no,useDebugValue:no,useDeferredValue:no,useTransition:no,useSyncExternalStore:no,useId:no,useHostTransitionStatus:no,useFormState:no,useActionState:no,useOptimistic:no,useMemoCache:no,useCacheRefresh:no};vs.useEffectEvent=no;var xs={readContext:La,use:fo,useCallback:function(e,t){return mo().memoizedState=[e,void 0===t?null:t],e},useContext:La,useEffect:Wo,useImperativeHandle:function(e,t,n){n=null!=n?n.concat([e]):null,Bo(4194308,4,Yo.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Bo(4194308,4,e,t)},useInsertionEffect:function(e,t){Bo(4,2,e,t)},useMemo:function(e,t){var n=mo();t=void 0===t?null:t;var r=e();if(Xi){Se(!0);try{e()}finally{Se(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=mo();if(void 0!==n){var a=n(t);if(Xi){Se(!0);try{n(t)}finally{Se(!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=ms.bind(null,Vi,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},mo().memoizedState=e},useState:function(e){var t=(e=Eo(e)).queue,n=hs.bind(null,Vi,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Jo,useDeferredValue:function(e,t){return ts(mo(),e,t)},useTransition:function(){var e=Eo(!1);return e=rs.bind(null,Vi,e.queue,!0,!1),mo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var a=Vi,i=mo();if(fa){if(void 0===n)throw Error(r(407));n=n()}else{if(n=t(),null===yc)throw Error(r(349));127&xc||ko(a,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,Wo(Co.bind(null,a,o,e),[e]),a.flags|=2048,Uo(9,{destroy:void 0},So.bind(null,a,o,n,t),null),n},useId:function(){var e=mo(),t=yc.identifierPrefix;if(fa){var n=sa;t="_"+t+"R_"+(n=(oa&~(1<<32-Ce(oa)-1)).toString(32)+n),0<(n=Ji++)&&(t+="H"+n.toString(32)),t+="_"}else t="_"+t+"r_"+(n=to++).toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:ls,useFormState:Lo,useActionState:Lo,useOptimistic:function(e){var t=mo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=fs.bind(null,Vi,!0,n),n.dispatch=t,[e,t]},useMemoCache:go,useCacheRefresh:function(){return mo().memoizedState=ds.bind(null,Vi)},useEffectEvent:function(e){var t=mo(),n={impl:e};return t.memoizedState=n,function(){if(2&bc)throw Error(r(440));return n.impl.apply(void 0,arguments)}}},ws={readContext:La,use:fo,useCallback:Zo,useContext:La,useEffect:Vo,useImperativeHandle:Xo,useInsertionEffect:Go,useLayoutEffect:Qo,useMemo:es,useReducer:yo,useRef:qo,useState:function(){return yo(bo)},useDebugValue:Jo,useDeferredValue:function(e,t){return ns(ho(),Ki.memoizedState,e,t)},useTransition:function(){var e=yo(bo)[0],t=ho().memoizedState;return["boolean"==typeof e?e:po(e),t]},useSyncExternalStore:wo,useId:cs,useHostTransitionStatus:ls,useFormState:Do,useActionState:Do,useOptimistic:function(e,t){return $o(ho(),0,e,t)},useMemoCache:go,useCacheRefresh:us};ws.useEffectEvent=Ko;var ks={readContext:La,use:fo,useCallback:Zo,useContext:La,useEffect:Vo,useImperativeHandle:Xo,useInsertionEffect:Go,useLayoutEffect:Qo,useMemo:es,useReducer:xo,useRef:qo,useState:function(){return xo(bo)},useDebugValue:Jo,useDeferredValue:function(e,t){var n=ho();return null===Ki?ts(n,e,t):ns(n,Ki.memoizedState,e,t)},useTransition:function(){var e=xo(bo)[0],t=ho().memoizedState;return["boolean"==typeof e?e:po(e),t]},useSyncExternalStore:wo,useId:cs,useHostTransitionStatus:ls,useFormState:Fo,useActionState:Fo,useOptimistic:function(e,t){var n=ho();return null!==Ki?$o(n,0,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:go,useCacheRefresh:us};function Ss(e,t,n,r){n=null==(n=n(r,t=e.memoizedState))?t:d({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}ks.useEffectEvent=Ko;var Cs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Yc(),a=ki(r);a.payload=t,null!=n&&(a.callback=n),null!==(t=Si(e,a,r))&&(Jc(t,e,r),Ci(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Yc(),a=ki(r);a.tag=1,a.payload=t,null!=n&&(a.callback=n),null!==(t=Si(e,a,r))&&(Jc(t,e,r),Ci(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Yc(),r=ki(n);r.tag=2,null!=t&&(r.callback=t),null!==(t=Si(e,r,n))&&(Jc(t,e,n),Ci(t,e,n))}};function js(e,t,n,r,a,i,o){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,i,o):!t.prototype||!t.prototype.isPureReactComponent||(!rr(n,r)||!rr(a,i))}function Ns(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&&Cs.enqueueReplaceState(t,t.state,null)}function Es(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=d({},n)),e)void 0===n[a]&&(n[a]=e[a]);return n}function $s(e){zr(e)}function _s(e){console.error(e)}function zs(e){zr(e)}function Ts(e,t){try{(0,e.onUncaughtError)(t.value,{componentStack:t.stack})}catch(n){setTimeout(function(){throw n})}}function As(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 Ps(e,t,n){return(n=ki(n)).tag=3,n.payload={element:null},n.callback=function(){Ts(e,t)},n}function Ms(e){return(e=ki(e)).tag=3,e}function Is(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(){As(t,n,r)}}var o=n.stateNode;null!==o&&"function"==typeof o.componentDidCatch&&(e.callback=function(){As(t,n,r),"function"!=typeof a&&(null===Fc?Fc=new Set([this]):Fc.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:null!==e?e:""})})}var Ls=Error(r(461)),Ds=!1;function Os(e,t,n,r){t.child=null===e?yi(t,null,n,r):bi(t,e.child,n,r)}function Rs(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 Ia(t),r=ao(e,t,n,o,i,a),s=lo(),null===e||Ds?(fa&&s&&ua(t),t.flags|=1,Os(e,t,r,a),t.child):(co(e,t,a),ll(e,t,a))}function Fs(e,t,n,r,a){if(null===e){var i=n.type;return"function"!=typeof i||Br(i)||void 0!==i.defaultProps||null!==n.compare?((e=Vr(n.type,null,r,t,t.mode,a)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=i,Us(e,t,i,r,a))}if(i=e.child,!cl(e,a)){var o=i.memoizedProps;if((n=null!==(n=n.compare)?n:rr)(o,r)&&e.ref===t.ref)return ll(e,t,a)}return t.flags|=1,(e=Hr(i,r)).ref=t.ref,e.return=t,t.child=e}function Us(e,t,n,r,a){if(null!==e){var i=e.memoizedProps;if(rr(i,r)&&e.ref===t.ref){if(Ds=!1,t.pendingProps=r=i,!cl(e,a))return t.lanes=e.lanes,ll(e,t,a);131072&e.flags&&(Ds=!0)}}return Gs(e,t,n,r,a)}function qs(e,t,n,r){var a=r.children,i=null!==e?e.memoizedState:null;if(null===e&&null===t.stateNode&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),"hidden"===r.mode){if(128&t.flags){if(i=null!==i?i.baseLanes|n:n,null!==e){for(r=t.child=e.child,a=0;null!==r;)a=a|r.lanes|r.childLanes,r=r.sibling;r=a&~i}else r=0,t.child=null;return Hs(e,t,i,n,r)}if(!(536870912&n))return r=t.lanes=536870912,Hs(e,t,null!==i?i.baseLanes|n:n,n,r);t.memoizedState={baseLanes:0,cachePool:null},null!==e&&Za(0,null!==i?i.cachePool:null),null!==i?Pi(t,i):Mi(),Fi(t)}else null!==i?(Za(0,i.cachePool),Pi(t,i),Ui(),t.memoizedState=null):(null!==e&&Za(0,null),Mi(),Ui());return Os(e,t,a,n),t.child}function Bs(e,t){return null!==e&&22===e.tag||null!==t.stateNode||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Hs(e,t,n,r,a){var i=Ja();return i=null===i?null:{parent:qa._currentValue,pool:i},t.memoizedState={baseLanes:n,cachePool:i},null!==e&&Za(0,null),Mi(),Fi(t),null!==e&&Pa(e,t,r,!0),t.childLanes=a,null}function Ws(e,t){return(t=rl({mode:t.mode,children:t.children},e.mode)).ref=e.ref,e.child=t,t.return=e,t}function Vs(e,t,n){return bi(t,e.child,null,n),(e=Ws(t,t.pendingProps)).flags|=2,qi(t),t.memoizedState=null,e}function Ks(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 Gs(e,t,n,r,a){return Ia(t),n=ao(e,t,n,r,void 0,a),r=lo(),null===e||Ds?(fa&&r&&ua(t),t.flags|=1,Os(e,t,n,a),t.child):(co(e,t,a),ll(e,t,a))}function Qs(e,t,n,r,a,i){return Ia(t),t.updateQueue=null,n=oo(t,r,n,a),io(e),r=lo(),null===e||Ds?(fa&&r&&ua(t),t.flags|=1,Os(e,t,n,i),t.child):(co(e,t,i),ll(e,t,i))}function Ys(e,t,n,r,a){if(Ia(t),null===t.stateNode){var i=Fr,o=n.contextType;"object"==typeof o&&null!==o&&(i=La(o)),i=new n(r,i),t.memoizedState=null!==i.state&&void 0!==i.state?i.state:null,i.updater=Cs,t.stateNode=i,i._reactInternals=t,(i=t.stateNode).props=r,i.state=t.memoizedState,i.refs={},xi(t),o=n.contextType,i.context="object"==typeof o&&null!==o?La(o):Fr,i.state=t.memoizedState,"function"==typeof(o=n.getDerivedStateFromProps)&&(Ss(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&&Cs.enqueueReplaceState(i,i.state,null),$i(t,r,i,a),Ei(),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=Es(n,s);i.props=l;var c=i.context,u=n.contextType;o=Fr,"object"==typeof u&&null!==u&&(o=La(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)&&Ns(t,i,r,o),vi=!1;var m=t.memoizedState;i.state=m,$i(t,r,i,a),Ei(),c=t.memoizedState,s||m!==c||vi?("function"==typeof d&&(Ss(t,n,d,r),c=t.memoizedState),(l=vi||js(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,wi(e,t),u=Es(n,o=t.memoizedProps),i.props=u,d=t.pendingProps,m=i.context,c=n.contextType,l=Fr,"object"==typeof c&&null!==c&&(l=La(c)),(c="function"==typeof(s=n.getDerivedStateFromProps)||"function"==typeof i.getSnapshotBeforeUpdate)||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(o!==d||m!==l)&&Ns(t,i,r,l),vi=!1,m=t.memoizedState,i.state=m,$i(t,r,i,a),Ei();var h=t.memoizedState;o!==d||m!==h||vi||null!==e&&null!==e.dependencies&&Ma(e.dependencies)?("function"==typeof s&&(Ss(t,n,s,r),h=t.memoizedState),(u=vi||js(t,n,u,r,m,h,l)||null!==e&&null!==e.dependencies&&Ma(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,Ks(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=bi(t,e.child,null,a),t.child=bi(t,null,n,a)):Os(e,t,n,a),t.memoizedState=i.state,e=t.child):e=ll(e,t,a),e}function Xs(e,t,n,r){return Sa(),t.flags|=256,Os(e,t,n,r),t.child}var Js={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Zs(e){return{baseLanes:e,cachePool:ei()}}function el(e,t,n){return e=null!==e?e.childLanes&~n:0,t&&(e|=Tc),e}function tl(e,t,n){var a,i=t.pendingProps,o=!1,s=!!(128&t.flags);if((a=s)||(a=(null===e||null!==e.memoizedState)&&!!(2&Bi.current)),a&&(o=!0,t.flags&=-129),a=!!(32&t.flags),t.flags&=-33,null===e){if(fa){if(o?Oi(t):Ui(),(e=pa)?null!==(e=null!==(e=Md(e,ba))&&"&"!==e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==ia?{id:oa,overflow:sa}:null,retryLane:536870912,hydrationErrors:null},(n=Qr(e)).return=t,t.child=n,ha=t,pa=null):e=null,null===e)throw va(t);return Ld(e)?t.lanes=32:t.lanes=536870912,null}var l=i.children;return i=i.fallback,o?(Ui(),l=rl({mode:"hidden",children:l},o=t.mode),i=Kr(i,o,n,null),l.return=t,i.return=t,l.sibling=i,t.child=l,(i=t.child).memoizedState=Zs(n),i.childLanes=el(e,a,n),t.memoizedState=Js,Bs(null,i)):(Oi(t),nl(t,l))}var c=e.memoizedState;if(null!==c&&null!==(l=c.dehydrated)){if(s)256&t.flags?(Oi(t),t.flags&=-257,t=al(e,t,n)):null!==t.memoizedState?(Ui(),t.child=e.child,t.flags|=128,t=null):(Ui(),l=i.fallback,o=t.mode,i=rl({mode:"visible",children:i.children},o),(l=Kr(l,o,n,null)).flags|=2,i.return=t,l.return=t,i.sibling=l,t.child=i,bi(t,e.child,null,n),(i=t.child).memoizedState=Zs(n),i.childLanes=el(e,a,n),t.memoizedState=Js,t=Bs(null,i));else if(Oi(t),Ld(l)){if(a=l.nextSibling&&l.nextSibling.dataset)var u=a.dgst;a=u,(i=Error(r(419))).stack="",i.digest=a,ja({value:i,source:null,stack:null}),t=al(e,t,n)}else if(Ds||Pa(e,t,n,!1),a=0!==(n&e.childLanes),Ds||a){if(null!==(a=yc)&&(0!==(i=Re(a,n))&&i!==c.retryLane))throw c.retryLane=i,Dr(e,i),Jc(a,e,i),Ls;Id(l)||uu(),t=al(e,t,n)}else Id(l)?(t.flags|=192,t.child=e.child,t=null):(e=c.treeContext,pa=Dd(l.nextSibling),ha=t,fa=!0,ga=null,ba=!1,null!==e&&ma(t,e),(t=nl(t,i.children)).flags|=4096);return t}return o?(Ui(),l=i.fallback,o=t.mode,u=(c=e.child).sibling,(i=Hr(c,{mode:"hidden",children:i.children})).subtreeFlags=65011712&c.subtreeFlags,null!==u?l=Hr(u,l):(l=Kr(l,o,n,null)).flags|=2,l.return=t,i.return=t,i.sibling=l,t.child=i,Bs(null,i),i=t.child,null===(l=e.child.memoizedState)?l=Zs(n):(null!==(o=l.cachePool)?(c=qa._currentValue,o=o.parent!==c?{parent:c,pool:c}:o):o=ei(),l={baseLanes:l.baseLanes|n,cachePool:o}),i.memoizedState=l,i.childLanes=el(e,a,n),t.memoizedState=Js,Bs(e.child,i)):(Oi(t),e=(n=e.child).sibling,(n=Hr(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 nl(e,t){return(t=rl({mode:"visible",children:t},e.mode)).return=e,e.child=t}function rl(e,t){return(e=qr(22,e,null,t)).lanes=0,e}function al(e,t,n){return bi(t,e.child,null,n),(e=nl(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function il(e,t,n){e.lanes|=t;var r=e.alternate;null!==r&&(r.lanes|=t),Ta(e.return,t,n)}function ol(e,t,n,r,a,i){var o=e.memoizedState;null===o?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:a,treeForkCount:i}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=a,o.treeForkCount=i)}function sl(e,t,n){var r=t.pendingProps,a=r.revealOrder,i=r.tail;r=r.children;var o=Bi.current,s=!!(2&o);if(s?(o=1&o|2,t.flags|=128):o&=1,W(Bi,o),Os(e,t,r,n),r=fa?na:0,!s&&null!==e&&128&e.flags)e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&il(e,n,t);else if(19===e.tag)il(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}switch(a){case"forwards":for(n=t.child,a=null;null!==n;)null!==(e=n.alternate)&&null===Hi(e)&&(a=n),n=n.sibling;null===(n=a)?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),ol(t,!1,a,n,i,r);break;case"backwards":case"unstable_legacy-backwards":for(n=null,a=t.child,t.child=null;null!==a;){if(null!==(e=a.alternate)&&null===Hi(e)){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}ol(t,!0,n,null,i,r);break;case"together":ol(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function ll(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),$c|=t.lanes,0===(n&t.childLanes)){if(null===e)return null;if(Pa(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=Hr(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=Hr(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function cl(e,t){return 0!==(e.lanes&t)||!(null===(e=e.dependencies)||!Ma(e))}function ul(e,t,n){if(null!==e)if(e.memoizedProps!==t.pendingProps)Ds=!0;else{if(!(cl(e,n)||128&t.flags))return Ds=!1,function(e,t,n){switch(t.tag){case 3:J(t,t.stateNode.containerInfo),_a(0,qa,e.memoizedState.cache),Sa();break;case 27:case 5:ee(t);break;case 4:J(t,t.stateNode.containerInfo);break;case 10:_a(0,t.type,t.memoizedProps.value);break;case 31:if(null!==t.memoizedState)return t.flags|=128,Ri(t),null;break;case 13:var r=t.memoizedState;if(null!==r)return null!==r.dehydrated?(Oi(t),t.flags|=128,null):0!==(n&t.child.childLanes)?tl(e,t,n):(Oi(t),null!==(e=ll(e,t,n))?e.sibling:null);Oi(t);break;case 19:var a=!!(128&e.flags);if((r=0!==(n&t.childLanes))||(Pa(e,t,n,!1),r=0!==(n&t.childLanes)),a){if(r)return sl(e,t,n);t.flags|=128}if(null!==(a=t.memoizedState)&&(a.rendering=null,a.tail=null,a.lastEffect=null),W(Bi,Bi.current),r)break;return null;case 22:return t.lanes=0,qs(e,t,n,t.pendingProps);case 24:_a(0,qa,e.memoizedState.cache)}return ll(e,t,n)}(e,t,n);Ds=!!(131072&e.flags)}else Ds=!1,fa&&1048576&t.flags&&ca(t,na,t.index);switch(t.lanes=0,t.tag){case 16:e:{var a=t.pendingProps;if(e=si(t.elementType),t.type=e,"function"!=typeof e){if(null!=e){var i=e.$$typeof;if(i===N){t.tag=11,t=Rs(null,t,e,a,n);break e}if(i===_){t.tag=14,t=Fs(null,t,e,a,n);break e}}throw t=L(e)||e,Error(r(306,t,""))}Br(e)?(a=Es(e,a),t.tag=1,t=Ys(null,t,e,a,n)):(t.tag=0,t=Gs(null,t,e,a,n))}return t;case 0:return Gs(e,t,t.type,t.pendingProps,n);case 1:return Ys(e,t,a=t.type,i=Es(a,t.pendingProps),n);case 3:e:{if(J(t,t.stateNode.containerInfo),null===e)throw Error(r(387));a=t.pendingProps;var o=t.memoizedState;i=o.element,wi(e,t),$i(t,a,null,n);var s=t.memoizedState;if(a=s.cache,_a(0,qa,a),a!==o.cache&&Aa(t,[qa],n,!0),Ei(),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=Xs(e,t,a,n);break e}if(a!==i){ja(i=Jr(Error(r(424)),t)),t=Xs(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(pa=Dd(e.firstChild),ha=t,fa=!0,ga=null,ba=!0,n=yi(t,null,a,n),t.child=n;n;)n.flags=-3&n.flags|4096,n=n.sibling}else{if(Sa(),a===i){t=ll(e,t,n);break e}Os(e,t,a,n)}t=t.child}return t;case 26:return Ks(e,t),null===e?(n=Qd(t.type,null,t.pendingProps,null))?t.memoizedState=n:fa||(n=t.type,e=t.pendingProps,(a=xd(Y.current).createElement(n))[We]=t,a[Ve]=e,gd(a,n,e),at(a),t.stateNode=a):t.memoizedState=Qd(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ee(t),null===e&&fa&&(a=t.stateNode=Ud(t.type,t.pendingProps,Y.current),ha=t,ba=!0,i=pa,zd(t.type)?(Od=i,pa=Dd(a.firstChild)):pa=i),Os(e,t,t.pendingProps.children,n),Ks(e,t),null===e&&(t.flags|=4194304),t.child;case 5:return null===e&&fa&&((i=a=pa)&&(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[Je])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=Dd(e.nextSibling)))break}return null}(a,t.type,t.pendingProps,ba))?(t.stateNode=a,ha=t,pa=Dd(a.firstChild),ba=!1,i=!0):i=!1),i||va(t)),ee(t),i=t.type,o=t.pendingProps,s=null!==e?e.memoizedProps:null,a=o.children,Sd(i,o)?a=null:null!==s&&Sd(i,s)&&(t.flags|=32),null!==t.memoizedState&&(i=ao(e,t,so,null,null,n),pm._currentValue=i),Ks(e,t),Os(e,t,a,n),t.child;case 6:return null===e&&fa&&((e=n=pa)&&(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=Dd(e.nextSibling)))return null}return e}(n,t.pendingProps,ba))?(t.stateNode=n,ha=t,pa=null,e=!0):e=!1),e||va(t)),null;case 13:return tl(e,t,n);case 4:return J(t,t.stateNode.containerInfo),a=t.pendingProps,null===e?t.child=bi(t,null,a,n):Os(e,t,a,n),t.child;case 11:return Rs(e,t,t.type,t.pendingProps,n);case 7:return Os(e,t,t.pendingProps,n),t.child;case 8:case 12:return Os(e,t,t.pendingProps.children,n),t.child;case 10:return a=t.pendingProps,_a(0,t.type,a.value),Os(e,t,a.children,n),t.child;case 9:return i=t.type._context,a=t.pendingProps.children,Ia(t),a=a(i=La(i)),t.flags|=1,Os(e,t,a,n),t.child;case 14:return Fs(e,t,t.type,t.pendingProps,n);case 15:return Us(e,t,t.type,t.pendingProps,n);case 19:return sl(e,t,n);case 31:return function(e,t,n){var a=t.pendingProps,i=!!(128&t.flags);if(t.flags&=-129,null===e){if(fa){if("hidden"===a.mode)return e=Ws(t,a),t.lanes=536870912,Bs(null,e);if(Ri(t),(e=pa)?null!==(e=null!==(e=Md(e,ba))&&"&"===e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==ia?{id:oa,overflow:sa}:null,retryLane:536870912,hydrationErrors:null},(n=Qr(e)).return=t,t.child=n,ha=t,pa=null):e=null,null===e)throw va(t);return t.lanes=536870912,null}return Ws(t,a)}var o=e.memoizedState;if(null!==o){var s=o.dehydrated;if(Ri(t),i)if(256&t.flags)t.flags&=-257,t=Vs(e,t,n);else{if(null===t.memoizedState)throw Error(r(558));t.child=e.child,t.flags|=128,t=null}else if(Ds||Pa(e,t,n,!1),i=0!==(n&e.childLanes),Ds||i){if(null!==(a=yc)&&0!==(s=Re(a,n))&&s!==o.retryLane)throw o.retryLane=s,Dr(e,s),Jc(a,e,s),Ls;uu(),t=Vs(e,t,n)}else e=o.treeContext,pa=Dd(s.nextSibling),ha=t,fa=!0,ga=null,ba=!1,null!==e&&ma(t,e),(t=Ws(t,a)).flags|=4096;return t}return(e=Hr(e.child,{mode:a.mode,children:a.children})).ref=t.ref,t.child=e,e.return=t,e}(e,t,n);case 22:return qs(e,t,n,t.pendingProps);case 24:return Ia(t),a=La(qa),null===e?(null===(i=Ja())&&(i=yc,o=Ba(),i.pooledCache=o,o.refCount++,null!==o&&(i.pooledCacheLanes|=n),i=o),t.memoizedState={parent:a,cache:i},xi(t),_a(0,qa,i)):(0!==(e.lanes&n)&&(wi(e,t),$i(t,null,null,n),Ei()),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),_a(0,qa,a)):(a=o.cache,_a(0,qa,a),a!==i.cache&&Aa(t,[qa],n,!0))),Os(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function dl(e){e.flags|=4}function ml(e,t,n,r,a){if((t=!!(32&e.mode))&&(t=!1),t){if(e.flags|=16777216,(335544128&a)===a)if(e.stateNode.complete)e.flags|=8192;else{if(!su())throw li=ai,ni;e.flags|=8192}}else e.flags&=-16777217}function hl(e,t){if("stylesheet"!==t.type||4&t.state.loading)e.flags&=-16777217;else if(e.flags|=16777216,!lm(t)){if(!su())throw li=ai,ni;e.flags|=8192}}function pl(e,t){null!==t&&(e.flags|=4),16384&e.flags&&(t=22!==e.tag?Me():536870912,e.lanes|=t,Ac|=t)}function fl(e,t){if(!fa)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 gl(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 bl(e,t,n){var a=t.pendingProps;switch(da(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 1:return gl(t),null;case 3:return n=t.stateNode,a=null,null!==e&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),za(qa),Z(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),null!==e&&null!==e.child||(ka(t)?dl(t):null===e||e.memoizedState.isDehydrated&&!(256&t.flags)||(t.flags|=1024,Ca())),gl(t),null;case 26:var i=t.type,o=t.memoizedState;return null===e?(dl(t),null!==o?(gl(t),hl(t,o)):(gl(t),ml(t,i,0,0,n))):o?o!==e.memoizedState?(dl(t),gl(t),hl(t,o)):(gl(t),t.flags&=-16777217):((e=e.memoizedProps)!==a&&dl(t),gl(t),ml(t,i,0,0,n)),null;case 27:if(te(t),n=Y.current,i=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==a&&dl(t);else{if(!a){if(null===t.stateNode)throw Error(r(166));return gl(t),null}e=G.current,ka(t)?xa(t):(e=Ud(i,a,n),t.stateNode=e,dl(t))}return gl(t),null;case 5:if(te(t),i=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==a&&dl(t);else{if(!a){if(null===t.stateNode)throw Error(r(166));return gl(t),null}if(o=G.current,ka(t))xa(t);else{var s=xd(Y.current);switch(o){case 1:o=s.createElementNS("http://www.w3.org/2000/svg",i);break;case 2:o=s.createElementNS("http://www.w3.org/1998/Math/MathML",i);break;default:switch(i){case"svg":o=s.createElementNS("http://www.w3.org/2000/svg",i);break;case"math":o=s.createElementNS("http://www.w3.org/1998/Math/MathML",i);break;case"script":(o=s.createElement("div")).innerHTML="<script><\/script>",o=o.removeChild(o.firstChild);break;case"select":o="string"==typeof a.is?s.createElement("select",{is:a.is}):s.createElement("select"),a.multiple?o.multiple=!0:a.size&&(o.size=a.size);break;default:o="string"==typeof a.is?s.createElement(i,{is:a.is}):s.createElement(i)}}o[We]=t,o[Ve]=a;e:for(s=t.child;null!==s;){if(5===s.tag||6===s.tag)o.appendChild(s.stateNode);else if(4!==s.tag&&27!==s.tag&&null!==s.child){s.child.return=s,s=s.child;continue}if(s===t)break e;for(;null===s.sibling;){if(null===s.return||s.return===t)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;e:switch(gd(o,i,a),i){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}a&&dl(t)}}return gl(t),ml(t,t.type,null===e||e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&null!=t.stateNode)e.memoizedProps!==a&&dl(t);else{if("string"!=typeof a&&null===t.stateNode)throw Error(r(166));if(e=Y.current,ka(t)){if(e=t.stateNode,n=t.memoizedProps,a=null,null!==(i=ha))switch(i.tag){case 27:case 5:a=i.memoizedProps}e[We]=t,(e=!!(e.nodeValue===n||null!==a&&!0===a.suppressHydrationWarning||hd(e.nodeValue,n)))||va(t,!0)}else(e=xd(e).createTextNode(a))[We]=t,t.stateNode=e}return gl(t),null;case 31:if(n=t.memoizedState,null===e||null!==e.memoizedState){if(a=ka(t),null!==n){if(null===e){if(!a)throw Error(r(318));if(!(e=null!==(e=t.memoizedState)?e.dehydrated:null))throw Error(r(557));e[We]=t}else Sa(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;gl(t),e=!1}else n=Ca(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return 256&t.flags?(qi(t),t):(qi(t),null);if(128&t.flags)throw Error(r(558))}return gl(t),null;case 13:if(a=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(i=ka(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[We]=t}else Sa(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;gl(t),i=!1}else i=Ca(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return 256&t.flags?(qi(t),t):(qi(t),null)}return qi(t),128&t.flags?(t.lanes=n,t):(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),o=null,null!==a.memoizedState&&null!==a.memoizedState.cachePool&&(o=a.memoizedState.cachePool.pool),o!==i&&(a.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),pl(t,t.updateQueue),gl(t),null);case 4:return Z(),null===e&&rd(t.stateNode.containerInfo),gl(t),null;case 10:return za(t.type),gl(t),null;case 19:if(H(Bi),null===(a=t.memoizedState))return gl(t),null;if(i=!!(128&t.flags),null===(o=a.rendering))if(i)fl(a,!1);else{if(0!==Ec||null!==e&&128&e.flags)for(e=t.child;null!==e;){if(null!==(o=Hi(e))){for(t.flags|=128,fl(a,!1),e=o.updateQueue,t.updateQueue=e,pl(t,e),t.subtreeFlags=0,e=n,n=t.child;null!==n;)Wr(n,e),n=n.sibling;return W(Bi,1&Bi.current|2),fa&&la(t,a.treeForkCount),t.child}e=e.sibling}null!==a.tail&&me()>Oc&&(t.flags|=128,i=!0,fl(a,!1),t.lanes=4194304)}else{if(!i)if(null!==(e=Hi(o))){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,pl(t,e),fl(a,!0),null===a.tail&&"hidden"===a.tailMode&&!o.alternate&&!fa)return gl(t),null}else 2*me()-a.renderingStartTime>Oc&&536870912!==n&&(t.flags|=128,i=!0,fl(a,!1),t.lanes=4194304);a.isBackwards?(o.sibling=t.child,t.child=o):(null!==(e=a.last)?e.sibling=o:t.child=o,a.last=o)}return null!==a.tail?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=me(),e.sibling=null,n=Bi.current,W(Bi,i?1&n|2:1&n),fa&&la(t,a.treeForkCount),e):(gl(t),null);case 22:case 23:return qi(t),Ii(),a=null!==t.memoizedState,null!==e?null!==e.memoizedState!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?!!(536870912&n)&&!(128&t.flags)&&(gl(t),6&t.subtreeFlags&&(t.flags|=8192)):gl(t),null!==(n=t.updateQueue)&&pl(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(Xa),null;case 24:return n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),za(qa),gl(t),null;case 25:case 30:return null}throw Error(r(156,t.tag))}function yl(e,t){switch(da(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return za(qa),Z(),65536&(e=t.flags)&&!(128&e)?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return te(t),null;case 31:if(null!==t.memoizedState){if(qi(t),null===t.alternate)throw Error(r(340));Sa()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 13:if(qi(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(r(340));Sa()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return H(Bi),null;case 4:return Z(),null;case 10:return za(t.type),null;case 22:case 23:return qi(t),Ii(),null!==e&&H(Xa),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return za(qa),null;default:return null}}function vl(e,t){switch(da(t),t.tag){case 3:za(qa),Z();break;case 26:case 27:case 5:te(t);break;case 4:Z();break;case 31:null!==t.memoizedState&&qi(t);break;case 13:qi(t);break;case 19:H(Bi);break;case 10:za(t.type);break;case 22:case 23:qi(t),Ii(),null!==e&&H(Xa);break;case 24:za(qa)}}function xl(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){Eu(t,t.return,s)}}function wl(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){Eu(a,l,u)}}}r=r.next}while(r!==i)}}catch(u){Eu(t,t.return,u)}}function kl(e){var t=e.updateQueue;if(null!==t){var n=e.stateNode;try{zi(t,n)}catch(r){Eu(e,e.return,r)}}}function Sl(e,t,n){n.props=Es(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(r){Eu(e,t,r)}}function Cl(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){Eu(e,t,a)}}function jl(e,t){var n=e.ref,r=e.refCleanup;if(null!==n)if("function"==typeof r)try{r()}catch(a){Eu(e,t,a)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof n)try{n(null)}catch(i){Eu(e,t,i)}else n.current=null}function Nl(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){Eu(e,e.return,a)}}function El(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)||pd(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&&pd(e,t,h,p,a,m)}}return void kt(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)||pd(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&&pd(e,t,i,o,a,c)}return t=l,n=s,a=p,void(null!=h?jt(e,!!n,h,!1):!!a!=!!n&&(null!=t?jt(e,!!n,t,!0):jt(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:pd(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&&pd(e,t,s,i,a,o)}return void Nt(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 pd(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 pd(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)&&pd(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:pd(e,t,u,h,a,p)}return;default:if(At(t)){for(var b in n)h=n[b],n.hasOwnProperty(b)&&void 0!==h&&!a.hasOwnProperty(b)&&fd(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||fd(e,t,d,h,a,p);return}}for(var y in n)h=n[y],n.hasOwnProperty(y)&&null!=h&&!a.hasOwnProperty(y)&&pd(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||pd(e,t,m,h,a,p)}(a,e.type,n,t),a[Ve]=t}catch(i){Eu(e,e.return,i)}}function $l(e){return 5===e.tag||3===e.tag||26===e.tag||27===e.tag&&zd(e.type)||4===e.tag}function _l(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||$l(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&&zd(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 zl(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=Lt));else if(4!==r&&(27===r&&zd(e.type)&&(n=e.stateNode,t=null),null!==(e=e.child)))for(zl(e,t,n),e=e.sibling;null!==e;)zl(e,t,n),e=e.sibling}function Tl(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&&zd(e.type)&&(n=e.stateNode),null!==(e=e.child)))for(Tl(e,t,n),e=e.sibling;null!==e;)Tl(e,t,n),e=e.sibling}function Al(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,a=t.attributes;a.length;)t.removeAttributeNode(a[0]);gd(t,r,n),t[We]=e,t[Ve]=n}catch(i){Eu(e,e.return,i)}}var Pl=!1,Ml=!1,Il=!1,Ll="function"==typeof WeakSet?WeakSet:Set,Dl=null;function Ol(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Jl(e,n),4&r&&xl(5,n);break;case 1:if(Jl(e,n),4&r)if(e=n.stateNode,null===t)try{e.componentDidMount()}catch(o){Eu(n,n.return,o)}else{var a=Es(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(a,t,e.__reactInternalSnapshotBeforeUpdate)}catch(s){Eu(n,n.return,s)}}64&r&&kl(n),512&r&&Cl(n,n.return);break;case 3:if(Jl(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{zi(e,t)}catch(o){Eu(n,n.return,o)}}break;case 27:null===t&&4&r&&Al(n);case 26:case 5:Jl(e,n),null===t&&4&r&&Nl(n),512&r&&Cl(n,n.return);break;case 12:Jl(e,n);break;case 31:Jl(e,n),4&r&&Hl(e,n);break;case 13:Jl(e,n),4&r&&Wl(e,n),64&r&&(null!==(e=n.memoizedState)&&(null!==(e=e.dehydrated)&&function(e,t){var n=e.ownerDocument;if("$~"===e.data)e._reactRetry=t;else if("$?"!==e.data||"loading"!==n.readyState)t();else{var r=function(){t(),n.removeEventListener("DOMContentLoaded",r)};n.addEventListener("DOMContentLoaded",r),e._reactRetry=r}}(e,n=Tu.bind(null,n))));break;case 22:if(!(r=null!==n.memoizedState||Pl)){t=null!==t&&null!==t.memoizedState||Ml,a=Pl;var i=Ml;Pl=r,(Ml=t)&&!i?ec(e,n,!!(8772&n.subtreeFlags)):Jl(e,n),Pl=a,Ml=i}break;case 30:break;default:Jl(e,n)}}function Rl(e){var t=e.alternate;null!==t&&(e.alternate=null,Rl(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&Ze(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 Fl=null,Ul=!1;function ql(e,t,n){for(n=n.child;null!==n;)Bl(e,t,n),n=n.sibling}function Bl(e,t,n){if(ke&&"function"==typeof ke.onCommitFiberUnmount)try{ke.onCommitFiberUnmount(we,n)}catch(i){}switch(n.tag){case 26:Ml||jl(n,t),ql(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode).parentNode.removeChild(n);break;case 27:Ml||jl(n,t);var r=Fl,a=Ul;zd(n.type)&&(Fl=n.stateNode,Ul=!1),ql(e,t,n),qd(n.stateNode),Fl=r,Ul=a;break;case 5:Ml||jl(n,t);case 6:if(r=Fl,a=Ul,Fl=null,ql(e,t,n),Ul=a,null!==(Fl=r))if(Ul)try{(9===Fl.nodeType?Fl.body:"HTML"===Fl.nodeName?Fl.ownerDocument.body:Fl).removeChild(n.stateNode)}catch(o){Eu(n,t,o)}else try{Fl.removeChild(n.stateNode)}catch(o){Eu(n,t,o)}break;case 18:null!==Fl&&(Ul?(Td(9===(e=Fl).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,n.stateNode),Gm(e)):Td(Fl,n.stateNode));break;case 4:r=Fl,a=Ul,Fl=n.stateNode.containerInfo,Ul=!0,ql(e,t,n),Fl=r,Ul=a;break;case 0:case 11:case 14:case 15:wl(2,n,t),Ml||wl(4,n,t),ql(e,t,n);break;case 1:Ml||(jl(n,t),"function"==typeof(r=n.stateNode).componentWillUnmount&&Sl(n,t,r)),ql(e,t,n);break;case 21:ql(e,t,n);break;case 22:Ml=(r=Ml)||null!==n.memoizedState,ql(e,t,n),Ml=r;break;default:ql(e,t,n)}}function Hl(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&null!==(e=e.memoizedState))){e=e.dehydrated;try{Gm(e)}catch(n){Eu(t,t.return,n)}}}function Wl(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&(null!==(e=e.memoizedState)&&null!==(e=e.dehydrated))))try{Gm(e)}catch(n){Eu(t,t.return,n)}}function Vl(e,t){var n=function(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return null===t&&(t=e.stateNode=new Ll),t;case 22:return null===(t=(e=e.stateNode)._retryCache)&&(t=e._retryCache=new Ll),t;default:throw Error(r(435,e.tag))}}(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Au.bind(null,e,t);t.then(r,r)}})}function Kl(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(zd(l.type)){Fl=l.stateNode,Ul=!1;break e}break;case 5:Fl=l.stateNode,Ul=!1;break e;case 3:case 4:Fl=l.stateNode.containerInfo,Ul=!0;break e}l=l.return}if(null===Fl)throw Error(r(160));Bl(o,s,i),Fl=null,Ul=!1,null!==(o=i.alternate)&&(o.return=null),i.return=null}if(13886&t.subtreeFlags)for(t=t.child;null!==t;)Ql(t,e),t=t.sibling}var Gl=null;function Ql(e,t){var n=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Kl(t,e),Yl(e),4&a&&(wl(3,e,e.return),xl(3,e),wl(5,e,e.return));break;case 1:Kl(t,e),Yl(e),512&a&&(Ml||null===n||jl(n,n.return)),64&a&&Pl&&(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=Gl;if(Kl(t,e),Yl(e),512&a&&(Ml||null===n||jl(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[Je]||o[We]||"http://www.w3.org/2000/svg"===o.namespaceURI||o.hasAttribute("itemprop"))&&(o=i.createElement(a),i.head.insertBefore(o,i.querySelector("head > title"))),gd(o,a,n),o[We]=e,at(o),a=o;break e;case"link":var s=om("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}gd(o=i.createElement(a),a,n),i.head.appendChild(o);break;case"meta":if(s=om("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}gd(o=i.createElement(a),a,n),i.head.appendChild(o);break;default:throw Error(r(468,a))}o[We]=e,at(o),a=o}e.stateNode=a}else sm(i,e.type,e.stateNode);else e.stateNode=tm(i,a,e.memoizedProps);else o!==a?(null===o?null!==n.stateNode&&(n=n.stateNode).parentNode.removeChild(n):o.count--,null===a?sm(i,e.type,e.stateNode):tm(i,a,e.memoizedProps)):null===a&&null!==e.stateNode&&El(e,e.memoizedProps,n.memoizedProps)}break;case 27:Kl(t,e),Yl(e),512&a&&(Ml||null===n||jl(n,n.return)),null!==n&&4&a&&El(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Kl(t,e),Yl(e),512&a&&(Ml||null===n||jl(n,n.return)),32&e.flags){i=e.stateNode;try{$t(i,"")}catch(f){Eu(e,e.return,f)}}4&a&&null!=e.stateNode&&El(e,i=e.memoizedProps,null!==n?n.memoizedProps:i),1024&a&&(Il=!0);break;case 6:if(Kl(t,e),Yl(e),4&a){if(null===e.stateNode)throw Error(r(162));a=e.memoizedProps,n=e.stateNode;try{n.nodeValue=a}catch(f){Eu(e,e.return,f)}}break;case 3:if(im=null,i=Gl,Gl=Wd(t.containerInfo),Kl(t,e),Gl=i,Yl(e),4&a&&null!==n&&n.memoizedState.isDehydrated)try{Gm(t.containerInfo)}catch(f){Eu(e,e.return,f)}Il&&(Il=!1,Xl(e));break;case 4:a=Gl,Gl=Wd(e.stateNode.containerInfo),Kl(t,e),Yl(e),Gl=a;break;case 12:default:Kl(t,e),Yl(e);break;case 31:case 19:Kl(t,e),Yl(e),4&a&&(null!==(a=e.updateQueue)&&(e.updateQueue=null,Vl(e,a)));break;case 13:Kl(t,e),Yl(e),8192&e.child.flags&&null!==e.memoizedState!=(null!==n&&null!==n.memoizedState)&&(Lc=me()),4&a&&(null!==(a=e.updateQueue)&&(e.updateQueue=null,Vl(e,a)));break;case 22:i=null!==e.memoizedState;var c=null!==n&&null!==n.memoizedState,u=Pl,d=Ml;if(Pl=u||i,Ml=d||c,Kl(t,e),Ml=d,Pl=u,Yl(e),8192&a)e:for(t=e.stateNode,t._visibility=i?-2&t._visibility:1|t._visibility,i&&(null===n||c||Pl||Ml||Zl(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(f){Eu(c,c.return,f)}}}else if(6===t.tag){if(null===n){c=t;try{c.stateNode.nodeValue=i?"":c.memoizedProps}catch(f){Eu(c,c.return,f)}}}else if(18===t.tag){if(null===n){c=t;try{var p=c.stateNode;i?Ad(p,!0):Ad(c.stateNode,!1)}catch(f){Eu(c,c.return,f)}}}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,Vl(e,n))));case 30:case 21:}}function Yl(e){var t=e.flags;if(2&t){try{for(var n,a=e.return;null!==a;){if($l(a)){n=a;break}a=a.return}if(null==n)throw Error(r(160));switch(n.tag){case 27:var i=n.stateNode;Tl(e,_l(e),i);break;case 5:var o=n.stateNode;32&n.flags&&($t(o,""),n.flags&=-33),Tl(e,_l(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;zl(e,_l(e),s);break;default:throw Error(r(161))}}catch(l){Eu(e,e.return,l)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function Xl(e){if(1024&e.subtreeFlags)for(e=e.child;null!==e;){var t=e;Xl(t),5===t.tag&&1024&t.flags&&t.stateNode.reset(),e=e.sibling}}function Jl(e,t){if(8772&t.subtreeFlags)for(t=t.child;null!==t;)Ol(e,t.alternate,t),t=t.sibling}function Zl(e){for(e=e.child;null!==e;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:wl(4,t,t.return),Zl(t);break;case 1:jl(t,t.return);var n=t.stateNode;"function"==typeof n.componentWillUnmount&&Sl(t,t.return,n),Zl(t);break;case 27:qd(t.stateNode);case 26:case 5:jl(t,t.return),Zl(t);break;case 22:null===t.memoizedState&&Zl(t);break;default:Zl(t)}e=e.sibling}}function ec(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:ec(a,i,n),xl(4,i);break;case 1:if(ec(a,i,n),"function"==typeof(a=(r=i).stateNode).componentDidMount)try{a.componentDidMount()}catch(c){Eu(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++)_i(l[a],s)}catch(c){Eu(r,r.return,c)}}n&&64&o&&kl(i),Cl(i,i.return);break;case 27:Al(i);case 26:case 5:ec(a,i,n),n&&null===r&&4&o&&Nl(i),Cl(i,i.return);break;case 12:ec(a,i,n);break;case 31:ec(a,i,n),n&&4&o&&Hl(a,i);break;case 13:ec(a,i,n),n&&4&o&&Wl(a,i);break;case 22:null===i.memoizedState&&ec(a,i,n),Cl(i,i.return);break;case 30:break;default:ec(a,i,n)}t=t.sibling}}function tc(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&&Ha(n))}function nc(e,t){e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Ha(e))}function rc(e,t,n,r){if(10256&t.subtreeFlags)for(t=t.child;null!==t;)ac(e,t,n,r),t=t.sibling}function ac(e,t,n,r){var a=t.flags;switch(t.tag){case 0:case 11:case 15:rc(e,t,n,r),2048&a&&xl(9,t);break;case 1:case 31:case 13:default:rc(e,t,n,r);break;case 3:rc(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&&Ha(e)));break;case 12:if(2048&a){rc(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){Eu(t,t.return,l)}}else rc(e,t,n,r);break;case 23:break;case 22:i=t.stateNode,o=t.alternate,null!==t.memoizedState?2&i._visibility?rc(e,t,n,r):oc(e,t):2&i._visibility?rc(e,t,n,r):(i._visibility|=2,ic(e,t,n,r,!!(10256&t.subtreeFlags)||!1)),2048&a&&tc(o,t);break;case 24:rc(e,t,n,r),2048&a&&nc(t.alternate,t)}}function ic(e,t,n,r,a){for(a=a&&(!!(10256&t.subtreeFlags)||!1),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:ic(i,o,s,l,a),xl(8,o);break;case 23:break;case 22:var u=o.stateNode;null!==o.memoizedState?2&u._visibility?ic(i,o,s,l,a):oc(i,o):(u._visibility|=2,ic(i,o,s,l,a)),a&&2048&c&&tc(o.alternate,o);break;case 24:ic(i,o,s,l,a),a&&2048&c&&nc(o.alternate,o);break;default:ic(i,o,s,l,a)}t=t.sibling}}function oc(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:oc(n,r),2048&a&&tc(r.alternate,r);break;case 24:oc(n,r),2048&a&&nc(r.alternate,r);break;default:oc(n,r)}t=t.sibling}}var sc=8192;function lc(e,t,n){if(e.subtreeFlags&sc)for(e=e.child;null!==e;)cc(e,t,n),e=e.sibling}function cc(e,t,n){switch(e.tag){case 26:lc(e,t,n),e.flags&sc&&null!==e.memoizedState&&function(e,t,n,r){if(!("stylesheet"!==n.type||"string"==typeof r.media&&!1===matchMedia(r.media).matches||4&n.state.loading)){if(null===n.instance){var a=Yd(r.href),i=t.querySelector(Xd(a));if(i)return null!==(t=i._p)&&"object"==typeof t&&"function"==typeof t.then&&(e.count++,e=um.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=i,void at(i);i=t.ownerDocument||t,r=Jd(r),(a=Bd.get(a))&&rm(r,a),at(i=i.createElement("link"));var o=i;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),gd(i,"link",r),n.instance=i}null===e.stylesheets&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(3&n.state.loading)&&(e.count++,n=um.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}(n,Gl,e.memoizedState,e.memoizedProps);break;case 5:default:lc(e,t,n);break;case 3:case 4:var r=Gl;Gl=Wd(e.stateNode.containerInfo),lc(e,t,n),Gl=r;break;case 22:null===e.memoizedState&&(null!==(r=e.alternate)&&null!==r.memoizedState?(r=sc,sc=16777216,lc(e,t,n),sc=r):lc(e,t,n))}}function uc(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 dc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var r=t[n];Dl=r,pc(r,e)}uc(e)}if(10256&e.subtreeFlags)for(e=e.child;null!==e;)mc(e),e=e.sibling}function mc(e){switch(e.tag){case 0:case 11:case 15:dc(e),2048&e.flags&&wl(9,e,e.return);break;case 3:case 12:default:dc(e);break;case 22:var t=e.stateNode;null!==e.memoizedState&&2&t._visibility&&(null===e.return||13!==e.return.tag)?(t._visibility&=-3,hc(e)):dc(e)}}function hc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var r=t[n];Dl=r,pc(r,e)}uc(e)}for(e=e.child;null!==e;){switch((t=e).tag){case 0:case 11:case 15:wl(8,t,t.return),hc(t);break;case 22:2&(n=t.stateNode)._visibility&&(n._visibility&=-3,hc(t));break;default:hc(t)}e=e.sibling}}function pc(e,t){for(;null!==Dl;){var n=Dl;switch(n.tag){case 0:case 11:case 15:wl(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:Ha(n.memoizedState.cache)}if(null!==(r=n.child))r.return=n,Dl=r;else e:for(n=e;null!==Dl;){var a=(r=Dl).sibling,i=r.return;if(Rl(r),r===n){Dl=null;break e}if(null!==a){a.return=i,Dl=a;break e}Dl=i}}}var fc={getCacheForType:function(e){var t=La(qa),n=t.data.get(e);return void 0===n&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return La(qa).controller.signal}},gc="function"==typeof WeakMap?WeakMap:Map,bc=0,yc=null,vc=null,xc=0,wc=0,kc=null,Sc=!1,Cc=!1,jc=!1,Nc=0,Ec=0,$c=0,_c=0,zc=0,Tc=0,Ac=0,Pc=null,Mc=null,Ic=!1,Lc=0,Dc=0,Oc=1/0,Rc=null,Fc=null,Uc=0,qc=null,Bc=null,Hc=0,Wc=0,Vc=null,Kc=null,Gc=0,Qc=null;function Yc(){return 2&bc&&0!==xc?xc&-xc:null!==O.T?Vu():qe()}function Xc(){if(0===Tc)if(536870912&xc&&!fa)Tc=536870912;else{var e=$e;!(3932160&($e<<=1))&&($e=262144),Tc=e}return null!==(e=Li.current)&&(e.flags|=32),Tc}function Jc(e,t,n){(e!==yc||2!==wc&&9!==wc)&&null===e.cancelPendingCommit||(iu(e,0),nu(e,xc,Tc,!1)),Le(e,n),2&bc&&e===yc||(e===yc&&(!(2&bc)&&(_c|=n),4===Ec&&nu(e,xc,Tc,!1)),Ru(e))}function Zc(e,t,n){if(6&bc)throw Error(r(327));for(var a=!n&&!(127&t)&&0===(t&e.expiredLanes)||Ae(e,t),i=a?function(e,t){var n=bc;bc|=2;var a=lu(),i=cu();yc!==e||xc!==t?(Rc=null,Oc=me()+500,iu(e,t)):Cc=Ae(e,t);e:for(;;)try{if(0!==wc&&null!==vc){t=vc;var o=kc;t:switch(wc){case 1:wc=0,kc=null,gu(e,t,o,1);break;case 2:case 9:if(ii(o)){wc=0,kc=null,fu(t);break}t=function(){2!==wc&&9!==wc||yc!==e||(wc=7),Ru(e)},o.then(t,t);break e;case 3:wc=7;break e;case 4:wc=5;break e;case 7:ii(o)?(wc=0,kc=null,fu(t)):(wc=0,kc=null,gu(e,t,o,7));break;case 5:var s=null;switch(vc.tag){case 26:s=vc.memoizedState;case 5:case 27:var l=vc;if(s?lm(s):l.stateNode.complete){wc=0,kc=null;var c=l.sibling;if(null!==c)vc=c;else{var u=l.return;null!==u?(vc=u,bu(u)):vc=null}break t}}wc=0,kc=null,gu(e,t,o,5);break;case 6:wc=0,kc=null,gu(e,t,o,6);break;case 8:au(),Ec=6;break e;default:throw Error(r(462))}}hu();break}catch(d){ou(e,d)}return $a=Ea=null,O.H=a,O.A=i,bc=n,null!==vc?0:(yc=null,xc=0,Mr(),Ec)}(e,t):du(e,t,!0),o=a;;){if(0===i){Cc&&!a&&nu(e,t,0,!1);break}if(n=e.current.alternate,!o||tu(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=Pc;var c=l.current.memoizedState.isDehydrated;if(c&&(iu(l,s).flags|=256),2!==(s=du(l,s,!1))){if(jc&&!c){l.errorRecoveryDisabledLanes|=o,_c|=o,i=4;break e}o=Mc,Mc=i,null!==o&&(null===Mc?Mc=o:Mc.push.apply(Mc,o))}i=s}if(o=!1,2!==i)continue}}if(1===i){iu(e,0),nu(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:nu(a,t,Tc,!Sc);break e;case 2:Mc=null;break;case 3:case 5:break;default:throw Error(r(329))}if((62914560&t)===t&&10<(i=Lc+300-me())){if(nu(a,t,Tc,!Sc),0!==Te(a,0,!0))break e;Hc=t,a.timeoutHandle=jd(eu.bind(null,a,n,Mc,Rc,Ic,t,Tc,_c,Ac,Sc,o,"Throttled",-0,0),i)}else eu(a,n,Mc,Rc,Ic,t,Tc,_c,Ac,Sc,o,null,-0,0)}break}i=du(e,t,!1),o=!1}Ru(e)}function eu(e,t,n,r,a,i,o,s,l,c,u,d,m,h){if(e.timeoutHandle=-1,8192&(d=t.subtreeFlags)||!(16785408&~d)){cc(t,i,d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Lt});var p=(62914560&i)===i?Lc-me():(4194048&i)===i?Dc-me():0;if(null!==(p=function(e,t){return e.stylesheets&&0===e.count&&mm(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&mm(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&0===cm&&(cm=62500*function(){if("function"==typeof performance.getEntriesByType){for(var e=0,t=0,n=performance.getEntriesByType("resource"),r=0;r<n.length;r++){var a=n[r],i=a.transferSize,o=a.initiatorType,s=a.duration;if(i&&s&&bd(o)){for(o=0,s=a.responseEnd,r+=1;r<n.length;r++){var l=n[r],c=l.startTime;if(c>s)break;var u=l.transferSize,d=l.initiatorType;u&&bd(d)&&(o+=u*((l=l.responseEnd)<s?1:(s-c)/(l-c)))}if(--r,t+=8*(i+o)/(a.duration/1e3),10<++e)break}}if(0<e)return t/e/1e6}return navigator.connection&&"number"==typeof(e=navigator.connection.downlink)?e:5}());var a=setTimeout(function(){if(e.waitingForImages=!1,0===e.count&&(e.stylesheets&&mm(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>cm?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(a)}}:null}(d,p)))return Hc=i,e.cancelPendingCommit=p(vu.bind(null,e,t,i,n,r,a,o,s,l,u,d,null,m,h)),void nu(e,i,o,!c)}vu(e,t,i,n,r,a,o,s,l)}function tu(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(!nr(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 nu(e,t,n,r){t&=~zc,t&=~_c,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var a=t;0<a;){var i=31-Ce(a),o=1<<i;r[i]=-1,a&=~o}0!==n&&De(e,n,t)}function ru(){return!!(6&bc)||(Fu(0),!1)}function au(){if(null!==vc){if(0===wc)var e=vc.return;else $a=Ea=null,uo(e=vc),di=null,mi=0,e=vc;for(;null!==e;)vl(e.alternate,e),e=e.return;vc=null}}function iu(e,t){var n=e.timeoutHandle;-1!==n&&(e.timeoutHandle=-1,Nd(n)),null!==(n=e.cancelPendingCommit)&&(e.cancelPendingCommit=null,n()),Hc=0,au(),yc=e,vc=n=Hr(e.current,null),xc=t,wc=0,kc=null,Sc=!1,Cc=Ae(e,t),jc=!1,Ac=Tc=zc=_c=$c=Ec=0,Mc=Pc=null,Ic=!1,8&t&&(t|=32&t);var r=e.entangledLanes;if(0!==r)for(e=e.entanglements,r&=t;0<r;){var a=31-Ce(r),i=1<<a;t|=e[a],r&=~i}return Nc=t,Mr(),n}function ou(e,t){Vi=null,O.H=vs,t===ti||t===ri?(t=ci(),wc=3):t===ni?(t=ci(),wc=4):wc=t===Ls?8:null!==t&&"object"==typeof t&&"function"==typeof t.then?6:1,kc=t,null===vc&&(Ec=1,Ts(e,Jr(t,e.current)))}function su(){var e=Li.current;return null===e||((4194048&xc)===xc?null===Di:!!((62914560&xc)===xc||536870912&xc)&&e===Di)}function lu(){var e=O.H;return O.H=vs,null===e?vs:e}function cu(){var e=O.A;return O.A=fc,e}function uu(){Ec=4,Sc||(4194048&xc)!==xc&&null!==Li.current||(Cc=!0),!(134217727&$c)&&!(134217727&_c)||null===yc||nu(yc,xc,Tc,!1)}function du(e,t,n){var r=bc;bc|=2;var a=lu(),i=cu();yc===e&&xc===t||(Rc=null,iu(e,t)),t=!1;var o=Ec;e:for(;;)try{if(0!==wc&&null!==vc){var s=vc,l=kc;switch(wc){case 8:au(),o=6;break e;case 3:case 2:case 9:case 6:null===Li.current&&(t=!0);var c=wc;if(wc=0,kc=null,gu(e,s,l,c),n&&Cc){o=0;break e}break;default:c=wc,wc=0,kc=null,gu(e,s,l,c)}}mu(),o=Ec;break}catch(u){ou(e,u)}return t&&e.shellSuspendCounter++,$a=Ea=null,bc=r,O.H=a,O.A=i,null===vc&&(yc=null,xc=0,Mr()),o}function mu(){for(;null!==vc;)pu(vc)}function hu(){for(;null!==vc&&!ue();)pu(vc)}function pu(e){var t=ul(e.alternate,e,Nc);e.memoizedProps=e.pendingProps,null===t?bu(e):vc=t}function fu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Qs(n,t,t.pendingProps,t.type,void 0,xc);break;case 11:t=Qs(n,t,t.pendingProps,t.type.render,t.ref,xc);break;case 5:uo(t);default:vl(n,t),t=ul(n,t=vc=Wr(t,Nc),Nc)}e.memoizedProps=e.pendingProps,null===t?bu(e):vc=t}function gu(e,t,n,a){$a=Ea=null,uo(t),di=null,mi=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)&&Pa(t,n,i,!0),null!==(n=Li.current)){switch(n.tag){case 31:case 13:return null===Di?uu():null===n.alternate&&0===Ec&&(Ec=3),n.flags&=-257,n.flags|=65536,n.lanes=i,a===ai?n.flags|=16384:(null===(t=n.updateQueue)?n.updateQueue=new Set([a]):t.add(a),$u(e,a,i)),!1;case 22:return n.flags|=65536,a===ai?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),$u(e,a,i)),!1}throw Error(r(435,n.tag))}return $u(e,a,i),uu(),!1}if(fa)return null!==(t=Li.current)?(!(65536&t.flags)&&(t.flags|=256),t.flags|=65536,t.lanes=i,a!==ya&&ja(Jr(e=Error(r(422),{cause:a}),n))):(a!==ya&&ja(Jr(t=Error(r(423),{cause:a}),n)),(e=e.current.alternate).flags|=65536,i&=-i,e.lanes|=i,a=Jr(a,n),ji(e,i=Ps(e.stateNode,a,i)),4!==Ec&&(Ec=2)),!1;var o=Error(r(520),{cause:a});if(o=Jr(o,n),null===Pc?Pc=[o]:Pc.push(o),4!==Ec&&(Ec=2),null===t)return!0;a=Jr(a,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,ji(n,e=Ps(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!==Fc&&Fc.has(o))))return n.flags|=65536,i&=-i,n.lanes|=i,Is(i=Ms(i),e,n,a),ji(n,i),!1}n=n.return}while(null!==n);return!1}(e,i,t,n,xc))return Ec=1,Ts(e,Jr(n,e.current)),void(vc=null)}catch(o){if(null!==i)throw vc=i,o;return Ec=1,Ts(e,Jr(n,e.current)),void(vc=null)}32768&t.flags?(fa||1===a?e=!0:Cc||536870912&xc?e=!1:(Sc=e=!0,(2===a||9===a||3===a||6===a)&&(null!==(a=Li.current)&&13===a.tag&&(a.flags|=16384))),yu(t,e)):bu(t)}function bu(e){var t=e;do{if(32768&t.flags)return void yu(t,Sc);e=t.return;var n=bl(t.alternate,t,Nc);if(null!==n)return void(vc=n);if(null!==(t=t.sibling))return void(vc=t);vc=t=e}while(null!==t);0===Ec&&(Ec=5)}function yu(e,t){do{var n=yl(e.alternate,e);if(null!==n)return n.flags&=32767,void(vc=n);if(null!==(n=e.return)&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&null!==(e=e.sibling))return void(vc=e);vc=e=n}while(null!==e);Ec=6,vc=null}function vu(e,t,n,a,i,o,s,l,c){e.cancelPendingCommit=null;do{Cu()}while(0!==Uc);if(6&bc)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-Ce(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&&De(e,r,0),0!==i&&0===a&&0!==e.tag&&(e.suspendedLanes|=i&~(o&~t))}(e,n,o|=Pr,s,l,c),e===yc&&(vc=yc=null,xc=0),Bc=t,qc=e,Hc=n,Wc=o,Vc=i,Kc=a,10256&t.subtreeFlags||10256&t.flags?(e.callbackNode=null,e.callbackPriority=0,le(ge,function(){return ju(),null})):(e.callbackNode=null,e.callbackPriority=0),a=!!(13878&t.flags),13878&t.subtreeFlags||a){a=O.T,O.T=null,i=R.p,R.p=2,s=bc,bc|=4;try{!function(e,t){if(e=e.containerInfo,yd=Sm,lr(e=sr(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(vd={focusedElem:e,selectionRange:n},Sm=!1,Dl=t;null!==Dl;)if(e=(t=Dl).child,1028&t.subtreeFlags&&null!==e)e.return=t,Dl=e;else for(;null!==Dl;){switch(o=(t=Dl).alternate,e=t.flags,t.tag){case 0:if(4&e&&null!==(e=null!==(e=t.updateQueue)?e.events:null))for(n=0;n<e.length;n++)(i=e[n]).ref.impl=i.nextImpl;break;case 11:case 15:case 5:case 26:case 27:case 6:case 4:case 17:break;case 1:if(1024&e&&null!==o){e=void 0,n=t,i=o.memoizedProps,o=o.memoizedState,a=n.stateNode;try{var f=Es(n.type,i);e=a.getSnapshotBeforeUpdate(f,o),a.__reactInternalSnapshotBeforeUpdate=e}catch(b){Eu(n,n.return,b)}}break;case 3:if(1024&e)if(9===(n=(e=t.stateNode.containerInfo).nodeType))Pd(e);else if(1===n)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Pd(e);break;default:e.textContent=""}break;default:if(1024&e)throw Error(r(163))}if(null!==(e=t.sibling)){e.return=t.return,Dl=e;break}Dl=t.return}}(e,t)}finally{bc=s,R.p=i,O.T=a}}Uc=1,xu(),wu(),ku()}}function xu(){if(1===Uc){Uc=0;var e=qc,t=Bc,n=!!(13878&t.flags);if(13878&t.subtreeFlags||n){n=O.T,O.T=null;var r=R.p;R.p=2;var a=bc;bc|=4;try{Ql(t,e);var i=vd,o=sr(e.containerInfo),s=i.focusedElem,l=i.selectionRange;if(o!==s&&s&&s.ownerDocument&&or(s.ownerDocument.documentElement,s)){if(null!==l&&lr(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=ir(s,f),y=ir(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}}Sm=!!yd,vd=yd=null}finally{bc=a,R.p=r,O.T=n}}e.current=t,Uc=2}}function wu(){if(2===Uc){Uc=0;var e=qc,t=Bc,n=!!(8772&t.flags);if(8772&t.subtreeFlags||n){n=O.T,O.T=null;var r=R.p;R.p=2;var a=bc;bc|=4;try{Ol(e,t.alternate,t)}finally{bc=a,R.p=r,O.T=n}}Uc=3}}function ku(){if(4===Uc||3===Uc){Uc=0,de();var e=qc,t=Bc,n=Hc,r=Kc;10256&t.subtreeFlags||10256&t.flags?Uc=5:(Uc=0,Bc=qc=null,Su(e,e.pendingLanes));var a=e.pendingLanes;if(0===a&&(Fc=null),Ue(n),t=t.stateNode,ke&&"function"==typeof ke.onCommitFiberRoot)try{ke.onCommitFiberRoot(we,t,void 0,!(128&~t.current.flags))}catch(l){}if(null!==r){t=O.T,a=R.p,R.p=2,O.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{O.T=t,R.p=a}}3&Hc&&Cu(),Ru(e),a=e.pendingLanes,261930&n&&42&a?e===Qc?Gc++:(Gc=0,Qc=e):Gc=0,Fu(0)}}function Su(e,t){0===(e.pooledCacheLanes&=t)&&(null!=(t=e.pooledCache)&&(e.pooledCache=null,Ha(t)))}function Cu(){return xu(),wu(),ku(),ju()}function ju(){if(5!==Uc)return!1;var e=qc,t=Wc;Wc=0;var n=Ue(Hc),a=O.T,i=R.p;try{R.p=32>n?32:n,O.T=null,n=Vc,Vc=null;var o=qc,s=Hc;if(Uc=0,Bc=qc=null,Hc=0,6&bc)throw Error(r(331));var l=bc;if(bc|=4,mc(o.current),ac(o,o.current,s,n),bc=l,Fu(0,!1),ke&&"function"==typeof ke.onPostCommitFiberRoot)try{ke.onPostCommitFiberRoot(we,o)}catch(c){}return!0}finally{R.p=i,O.T=a,Su(e,t)}}function Nu(e,t,n){t=Jr(n,t),null!==(e=Si(e,t=Ps(e.stateNode,t,2),2))&&(Le(e,2),Ru(e))}function Eu(e,t,n){if(3===e.tag)Nu(e,e,n);else for(;null!==t;){if(3===t.tag){Nu(t,e,n);break}if(1===t.tag){var r=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===Fc||!Fc.has(r))){e=Jr(n,e),null!==(r=Si(t,n=Ms(2),2))&&(Is(n,r,t,e),Le(r,2),Ru(r));break}}t=t.return}}function $u(e,t,n){var r=e.pingCache;if(null===r){r=e.pingCache=new gc;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)||(jc=!0,a.add(n),e=_u.bind(null,e,t,n),t.then(e,e))}function _u(e,t,n){var r=e.pingCache;null!==r&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,yc===e&&(xc&n)===n&&(4===Ec||3===Ec&&(62914560&xc)===xc&&300>me()-Lc?!(2&bc)&&iu(e,0):zc|=n,Ac===xc&&(Ac=0)),Ru(e)}function zu(e,t){0===t&&(t=Me()),null!==(e=Dr(e,t))&&(Le(e,t),Ru(e))}function Tu(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),zu(e,n)}function Au(e,t){var n=0;switch(e.tag){case 31: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),zu(e,n)}var Pu=null,Mu=null,Iu=!1,Lu=!1,Du=!1,Ou=0;function Ru(e){e!==Mu&&null===e.next&&(null===Mu?Pu=Mu=e:Mu=Mu.next=e),Lu=!0,Iu||(Iu=!0,$d(function(){6&bc?le(pe,Uu):qu()}))}function Fu(e,t){if(!Du&&Lu){Du=!0;do{for(var n=!1,r=Pu;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-Ce(42|e)+1)-1,i=201326741&(i&=a&~(o&~s))?201326741&i|1:i?2|i:0}0!==i&&(n=!0,Wu(r,i))}else i=xc,!(3&(i=Te(r,r===yc?i:0,null!==r.cancelPendingCommit||-1!==r.timeoutHandle)))||Ae(r,i)||(n=!0,Wu(r,i));r=r.next}}while(n);Du=!1}}function Uu(){qu()}function qu(){Lu=Iu=!1;var e=0;0!==Ou&&function(){var e=window.event;if(e&&"popstate"===e.type)return e!==Cd&&(Cd=e,!0);return Cd=null,!1}()&&(e=Ou);for(var t=me(),n=null,r=Pu;null!==r;){var a=r.next,i=Bu(r,t);0===i?(r.next=null,null===n?Pu=a:n.next=a,null===a&&(Mu=n)):(n=r,(0!==e||3&i)&&(Lu=!0)),r=a}0!==Uc&&5!==Uc||Fu(e),0!==Ou&&(Ou=0)}function Bu(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,i=-62914561&e.pendingLanes;0<i;){var o=31-Ce(i),s=1<<o,l=a[o];-1===l?0!==(s&n)&&0===(s&r)||(a[o]=Pe(s,t)):l<=t&&(e.expiredLanes|=s),i&=~s}if(n=xc,n=Te(e,e===(t=yc)?n:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle),r=e.callbackNode,0===n||e===t&&(2===wc||9===wc)||null!==e.cancelPendingCommit)return null!==r&&null!==r&&ce(r),e.callbackNode=null,e.callbackPriority=0;if(!(3&n)||Ae(e,n)){if((t=n&-n)===e.callbackPriority)return t;switch(null!==r&&ce(r),Ue(n)){case 2:case 8:n=fe;break;case 32:default:n=ge;break;case 268435456:n=ye}return r=Hu.bind(null,e),n=le(n,r),e.callbackPriority=t,e.callbackNode=n,t}return null!==r&&null!==r&&ce(r),e.callbackPriority=2,e.callbackNode=null,2}function Hu(e,t){if(0!==Uc&&5!==Uc)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Cu()&&e.callbackNode!==n)return null;var r=xc;return 0===(r=Te(e,e===yc?r:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle))?null:(Zc(e,r,t),Bu(e,me()),null!=e.callbackNode&&e.callbackNode===n?Hu.bind(null,e):null)}function Wu(e,t){if(Cu())return null;Zc(e,t,!0)}function Vu(){if(0===Ou){var e=Ka;0===e&&(e=Ee,!(261888&(Ee<<=1))&&(Ee=256)),Ou=e}return Ou}function Ku(e){return null==e||"symbol"==typeof e||"boolean"==typeof e?null:"function"==typeof e?e:It(""+e)}function Gu(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 Qu=0;Qu<$r.length;Qu++){var Yu=$r[Qu];_r(Yu.toLowerCase(),"on"+(Yu[0].toUpperCase()+Yu.slice(1)))}_r(xr,"onAnimationEnd"),_r(wr,"onAnimationIteration"),_r(kr,"onAnimationStart"),_r("dblclick","onDoubleClick"),_r("focusin","onFocus"),_r("focusout","onBlur"),_r(Sr,"onTransitionRun"),_r(Cr,"onTransitionStart"),_r(jr,"onTransitionCancel"),_r(Nr,"onTransitionEnd"),lt("onMouseEnter",["mouseout","mouseover"]),lt("onMouseLeave",["mouseout","mouseover"]),lt("onPointerEnter",["pointerout","pointerover"]),lt("onPointerLeave",["pointerout","pointerover"]),st("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),st("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),st("onBeforeInput",["compositionend","keypress","textInput","paste"]),st("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),st("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),st("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Xu="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(" "),Ju=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Xu));function Zu(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){zr(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){zr(u)}a.currentTarget=null,i=l}}}}function ed(e,t){var n=t[Ge];void 0===n&&(n=t[Ge]=new Set);var r=e+"__bubble";n.has(r)||(ad(t,e,2,!1),n.add(r))}function td(e,t,n){var r=0;t&&(r|=4),ad(n,e,r,t)}var nd="_reactListening"+Math.random().toString(36).slice(2);function rd(e){if(!e[nd]){e[nd]=!0,it.forEach(function(t){"selectionchange"!==t&&(Ju.has(t)||td(t,!1,e),td(t,!0,e))});var t=9===e.nodeType?e:e.ownerDocument;null===t||t[nd]||(t[nd]=!0,td("selectionchange",!1,t))}}function ad(e,t,n,r){switch(zm(t)){case 2:var a=Cm;break;case 8:a=jm;break;default:a=Nm}n=a.bind(null,t,n,e),a=void 0,!Vt||"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 id(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=et(l)))return;if(5===(c=s.tag)||6===c||26===c||27===c){r=o=s;continue e}l=l.parentNode}}r=r.return}Bt(function(){var r=o,a=Ot(n),s=[];e:{var l=Er.get(e);if(void 0!==l){var c=sn,u=e;switch(e){case"keypress":if(0===Jt(n))break e;case"keydown":case"keyup":c=kn;break;case"focusin":u="focus",c=hn;break;case"focusout":u="blur",c=hn;break;case"beforeblur":case"afterblur":c=hn;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=dn;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":c=mn;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":c=Cn;break;case xr:case wr:case kr:c=pn;break;case Nr:c=jn;break;case"scroll":case"scrollend":c=cn;break;case"wheel":c=Nn;break;case"copy":case"cut":case"paste":c=fn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=Sn;break;case"toggle":case"beforetoggle":c=En}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=Ht(f,h))&&d.push(od(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===Dt||!(u=n.relatedTarget||n.fromElement)||!et(u)&&!u[Ke])&&(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)?et(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=dn,g="onMouseLeave",h="onMouseEnter",f="mouse","pointerout"!==e&&"pointerover"!==e||(d=Sn,g="onPointerLeave",h="onPointerEnter",f="pointer"),m=null==c?l:nt(c),p=null==u?l:nt(u),(l=new d(g,f+"leave",c,n,a)).target=m,l.relatedTarget=p,g=null,et(a)===r&&((d=new d(h,f+"enter",u,n,a)).target=p,d.relatedTarget=m,g=d),m=g,c&&u)e:{for(d=ld,f=u,p=0,g=h=c;g;g=d(g))p++;g=0;for(var b=f;b;b=d(b))g++;for(;0<p-g;)h=d(h),p--;for(;0<g-p;)f=d(f),g--;for(;p--;){if(h===f||null!==f&&h===f.alternate){d=h;break e}h=d(h),f=d(f)}d=null}else d=null;null!==c&&cd(s,l,c,d,!1),null!==u&&null!==m&&cd(s,m,u,d,!0)}if("select"===(c=(l=r?nt(r):window).nodeName&&l.nodeName.toLowerCase())||"input"===c&&"file"===l.type)var y=Wn;else if(Rn(l))if(Vn)y=tr;else{y=Zn;var v=Jn}else!(c=l.nodeName)||"input"!==c.toLowerCase()||"checkbox"!==l.type&&"radio"!==l.type?r&&At(r.elementType)&&(y=Wn):y=er;switch(y&&(y=y(e,r))?Fn(s,y,n,a):(v&&v(e,l,r),"focusout"===e&&r&&"number"===l.type&&null!=r.memoizedProps.value&&Ct(l,"number",l.value)),v=r?nt(r):window,e){case"focusin":(Rn(v)||"true"===v.contentEditable)&&(ur=v,dr=r,mr=null);break;case"focusout":mr=dr=ur=null;break;case"mousedown":hr=!0;break;case"contextmenu":case"mouseup":case"dragend":hr=!1,pr(s,n,a);break;case"selectionchange":if(cr)break;case"keydown":case"keyup":pr(s,n,a)}var x;if(_n)e:{switch(e){case"compositionstart":var w="onCompositionStart";break e;case"compositionend":w="onCompositionEnd";break e;case"compositionupdate":w="onCompositionUpdate";break e}w=void 0}else Dn?In(e,n)&&(w="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(w="onCompositionStart");w&&(An&&"ko"!==n.locale&&(Dn||"onCompositionStart"!==w?"onCompositionEnd"===w&&Dn&&(x=Xt()):(Qt="value"in(Gt=a)?Gt.value:Gt.textContent,Dn=!0)),0<(v=sd(r,w)).length&&(w=new gn(w,e,null,n,a),s.push({event:w,listeners:v}),x?w.data=x:null!==(x=Ln(n))&&(w.data=x))),(x=Tn?function(e,t){switch(e){case"compositionend":return Ln(t);case"keypress":return 32!==t.which?null:(Mn=!0,Pn);case"textInput":return(e=t.data)===Pn&&Mn?null:e;default:return null}}(e,n):function(e,t){if(Dn)return"compositionend"===e||!_n&&In(e,t)?(e=Xt(),Yt=Qt=Gt=null,Dn=!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 An&&"ko"!==t.locale?null:t.data}}(e,n))&&(0<(w=sd(r,"onBeforeInput")).length&&(v=new gn("onBeforeInput","beforeinput",null,n,a),s.push({event:v,listeners:w}),v.data=x)),function(e,t,n,r,a){if("submit"===t&&n&&n.stateNode===a){var i=Ku((a[Ve]||null).action),o=r.submitter;o&&null!==(t=(t=o[Ve]||null)?Ku(t.formAction):o.getAttribute("formAction"))&&(i=t,o=null);var s=new sn("action","action",null,r,a);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(0!==Ou){var e=o?Gu(a,o):new FormData(a);is(n,{pending:!0,data:e,method:a.method,action:i},null,e)}}else"function"==typeof i&&(s.preventDefault(),e=o?Gu(a,o):new FormData(a),is(n,{pending:!0,data:e,method:a.method,action:i},i,e))},currentTarget:a}]})}}(s,e,r,n,a)}Zu(s,t)})}function od(e,t,n){return{instance:e,listener:t,currentTarget:n}}function sd(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=Ht(e,n))&&r.unshift(od(e,a,i)),null!=(a=Ht(e,t))&&r.push(od(e,a,i))),3===e.tag)return r;e=e.return}return[]}function ld(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag&&27!==e.tag);return e||null}function cd(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=Ht(n,i))&&o.unshift(od(n,c,l)):a||null!=(c=Ht(n,i))&&o.push(od(n,c,l))),n=n.return}0!==o.length&&e.push({event:t,listeners:o})}var ud=/\r\n?/g,dd=/\u0000|\uFFFD/g;function md(e){return("string"==typeof e?e:""+e).replace(ud,"\n").replace(dd,"")}function hd(e,t){return t=md(t),md(e)===t}function pd(e,t,n,a,i,o){switch(n){case"children":"string"==typeof a?"body"===t||"textarea"===t&&""===a||$t(e,a):("number"==typeof a||"bigint"==typeof a)&&"body"!==t&&$t(e,""+a);break;case"className":ht(e,"class",a);break;case"tabIndex":ht(e,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":ht(e,n,a);break;case"style":Tt(e,a,o);break;case"data":if("object"!==t){ht(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=It(""+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&&pd(e,t,"name",i.name,i,null),pd(e,t,"formEncType",i.formEncType,i,null),pd(e,t,"formMethod",i.formMethod,i,null),pd(e,t,"formTarget",i.formTarget,i,null)):(pd(e,t,"encType",i.encType,i,null),pd(e,t,"method",i.method,i,null),pd(e,t,"target",i.target,i,null))),null==a||"symbol"==typeof a||"boolean"==typeof a){e.removeAttribute(n);break}a=It(""+a),e.setAttribute(n,a);break;case"onClick":null!=a&&(e.onclick=Lt);break;case"onScroll":null!=a&&ed("scroll",e);break;case"onScrollEnd":null!=a&&ed("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=It(""+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":ed("beforetoggle",e),ed("toggle",e),mt(e,"popover",a);break;case"xlinkActuate":pt(e,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":pt(e,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":pt(e,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":pt(e,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":pt(e,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":pt(e,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":pt(e,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":pt(e,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":pt(e,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":mt(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])&&mt(e,n=Pt.get(n)||n,a)}}function fd(e,t,n,a,i,o){switch(n){case"style":Tt(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?$t(e,a):("number"==typeof a||"bigint"==typeof a)&&$t(e,""+a);break;case"onScroll":null!=a&&ed("scroll",e);break;case"onScrollEnd":null!=a&&ed("scrollend",e);break;case"onClick":null!=a&&(e.onclick=Lt);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":case"innerText":case"textContent":break;default:ot.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[Ve]||null)?o[n]:null)&&e.removeEventListener(t,o,i),"function"!=typeof a)?n in e?e[n]=a:!0===a?e.setAttribute(n,""):mt(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 gd(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ed("error",e),ed("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:pd(e,t,a,s,n,null)}}return o&&pd(e,t,"srcSet",n.srcSet,n,null),void(i&&pd(e,t,"src",n.src,n,null));case"input":ed("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:pd(e,t,i,d,n,null)}}return void St(e,a,l,c,u,s,o,!1);case"select":for(o in ed("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:pd(e,t,o,l,n,null)}return t=a,n=s,e.multiple=!!i,void(null!=t?jt(e,!!i,t,!1):null!=n&&jt(e,!!i,n,!0));case"textarea":for(s in ed("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:pd(e,t,s,l,n,null)}return void Et(e,i,o,a);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 pd(e,t,c,i,n,null);return;case"dialog":ed("beforetoggle",e),ed("toggle",e),ed("cancel",e),ed("close",e);break;case"iframe":case"object":ed("load",e);break;case"video":case"audio":for(i=0;i<Xu.length;i++)ed(Xu[i],e);break;case"image":ed("error",e),ed("load",e);break;case"details":ed("toggle",e);break;case"embed":case"source":case"link":ed("error",e),ed("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:pd(e,t,u,i,n,null)}return;default:if(At(t)){for(d in n)n.hasOwnProperty(d)&&(void 0!==(i=n[d])&&fd(e,t,d,i,n,void 0));return}}for(l in n)n.hasOwnProperty(l)&&(null!=(i=n[l])&&pd(e,t,l,i,n,null))}function bd(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}var yd=null,vd=null;function xd(e){return 9===e.nodeType?e:e.ownerDocument}function wd(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 kd(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 Sd(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 Cd=null;var jd="function"==typeof setTimeout?setTimeout:void 0,Nd="function"==typeof clearTimeout?clearTimeout:void 0,Ed="function"==typeof Promise?Promise:void 0,$d="function"==typeof queueMicrotask?queueMicrotask:void 0!==Ed?function(e){return Ed.resolve(null).then(e).catch(_d)}:jd;function _d(e){setTimeout(function(){throw e})}function zd(e){return"head"===e}function Td(e,t){var n=t,r=0;do{var a=n.nextSibling;if(e.removeChild(n),a&&8===a.nodeType)if("/$"===(n=a.data)||"/&"===n){if(0===r)return e.removeChild(a),void Gm(t);r--}else if("$"===n||"$?"===n||"$~"===n||"$!"===n||"&"===n)r++;else if("html"===n)qd(e.ownerDocument.documentElement);else if("head"===n){qd(n=e.ownerDocument.head);for(var i=n.firstChild;i;){var o=i.nextSibling,s=i.nodeName;i[Je]||"SCRIPT"===s||"STYLE"===s||"LINK"===s&&"stylesheet"===i.rel.toLowerCase()||n.removeChild(i),i=o}}else"body"===n&&qd(e.ownerDocument.body);n=a}while(n);Gm(t)}function Ad(e,t){var n=e;e=0;do{var r=n.nextSibling;if(1===n.nodeType?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",""===n.getAttribute("style")&&n.removeAttribute("style")):3===n.nodeType&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),r&&8===r.nodeType)if("/$"===(n=r.data)){if(0===e)break;e--}else"$"!==n&&"$?"!==n&&"$~"!==n&&"$!"!==n||e++;n=r}while(n)}function Pd(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":Pd(n),Ze(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if("stylesheet"===n.rel.toLowerCase())continue}e.removeChild(n)}}function Md(e,t){for(;8!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!t)return null;if(null===(e=Dd(e.nextSibling)))return null}return e}function Id(e){return"$?"===e.data||"$~"===e.data}function Ld(e){return"$!"===e.data||"$?"===e.data&&"loading"!==e.ownerDocument.readyState}function Dd(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t||"$~"===t||"&"===t||"F!"===t||"F"===t)break;if("/$"===t||"/&"===t)return null}}return e}var Od=null;function Rd(e){e=e.nextSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("/$"===n||"/&"===n){if(0===t)return Dd(e.nextSibling);t--}else"$"!==n&&"$!"!==n&&"$?"!==n&&"$~"!==n&&"&"!==n||t++}e=e.nextSibling}return null}function Fd(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n||"$~"===n||"&"===n){if(0===t)return e;t--}else"/$"!==n&&"/&"!==n||t++}e=e.previousSibling}return null}function Ud(e,t,n){switch(t=xd(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 qd(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Ze(e)}var Bd=new Map,Hd=new Set;function Wd(e){return"function"==typeof e.getRootNode?e.getRootNode():9===e.nodeType?e:e.ownerDocument}var Vd=R.d;R.d={f:function(){var e=Vd.f(),t=ru();return e||t},r:function(e){var t=tt(e);null!==t&&5===t.tag&&"form"===t.type?ss(t):Vd.r(e)},D:function(e){Vd.D(e),Gd("dns-prefetch",e,null)},C:function(e,t){Vd.C(e,t),Gd("preconnect",e,t)},L:function(e,t,n){Vd.L(e,t,n);var r=Kd;if(r&&e&&t){var a='link[rel="preload"][as="'+wt(t)+'"]';"image"===t&&n&&n.imageSrcSet?(a+='[imagesrcset="'+wt(n.imageSrcSet)+'"]',"string"==typeof n.imageSizes&&(a+='[imagesizes="'+wt(n.imageSizes)+'"]')):a+='[href="'+wt(e)+'"]';var i=a;switch(t){case"style":i=Yd(e);break;case"script":i=Zd(e)}Bd.has(i)||(e=d({rel:"preload",href:"image"===t&&n&&n.imageSrcSet?void 0:e,as:t},n),Bd.set(i,e),null!==r.querySelector(a)||"style"===t&&r.querySelector(Xd(i))||"script"===t&&r.querySelector(em(i))||(gd(t=r.createElement("link"),"link",e),at(t),r.head.appendChild(t)))}},m:function(e,t){Vd.m(e,t);var n=Kd;if(n&&e){var r=t&&"string"==typeof t.as?t.as:"script",a='link[rel="modulepreload"][as="'+wt(r)+'"][href="'+wt(e)+'"]',i=a;switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":i=Zd(e)}if(!Bd.has(i)&&(e=d({rel:"modulepreload",href:e},t),Bd.set(i,e),null===n.querySelector(a))){switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(em(i)))return}gd(r=n.createElement("link"),"link",e),at(r),n.head.appendChild(r)}}},X:function(e,t){Vd.X(e,t);var n=Kd;if(n&&e){var r=rt(n).hoistableScripts,a=Zd(e),i=r.get(a);i||((i=n.querySelector(em(a)))||(e=d({src:e,async:!0},t),(t=Bd.get(a))&&am(e,t),at(i=n.createElement("script")),gd(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){Vd.S(e,t,n);var r=Kd;if(r&&e){var a=rt(r).hoistableStyles,i=Yd(e);t=t||"default";var o=a.get(i);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Xd(i)))s.loading=5;else{e=d({rel:"stylesheet",href:e,"data-precedence":t},n),(n=Bd.get(i))&&rm(e,n);var l=o=r.createElement("link");at(l),gd(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,nm(o,t,r)}o={type:"stylesheet",instance:o,count:1,state:s},a.set(i,o)}}},M:function(e,t){Vd.M(e,t);var n=Kd;if(n&&e){var r=rt(n).hoistableScripts,a=Zd(e),i=r.get(a);i||((i=n.querySelector(em(a)))||(e=d({src:e,async:!0,type:"module"},t),(t=Bd.get(a))&&am(e,t),at(i=n.createElement("script")),gd(i,"link",e),n.head.appendChild(i)),i={type:"script",instance:i,count:1,state:null},r.set(a,i))}}};var Kd="undefined"==typeof document?null:document;function Gd(e,t,n){var r=Kd;if(r&&"string"==typeof t&&t){var a=wt(t);a='link[rel="'+e+'"][href="'+a+'"]',"string"==typeof n&&(a+='[crossorigin="'+n+'"]'),Hd.has(a)||(Hd.add(a),e={rel:e,crossOrigin:n,href:t},null===r.querySelector(a)&&(gd(t=r.createElement("link"),"link",e),at(t),r.head.appendChild(t)))}}function Qd(e,t,n,a){var i,o,s,l,c=(c=Y.current)?Wd(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=Yd(n.href),(a=(n=rt(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=Yd(n.href);var u=rt(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(Xd(e)))&&!u._p&&(d.instance=u,d.state.loading=5),Bd.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},Bd.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}),gd(o,"link",s),at(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=Zd(n),(a=(n=rt(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 Yd(e){return'href="'+wt(e)+'"'}function Xd(e){return'link[rel="stylesheet"]['+e+"]"}function Jd(e){return d({},e,{"data-precedence":e.precedence,precedence:null})}function Zd(e){return'[src="'+wt(e)+'"]'}function em(e){return"script[async]"+e}function tm(e,t,n){if(t.count++,null===t.instance)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+wt(n.href)+'"]');if(a)return t.instance=a,at(a),a;var i=d({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return at(a=(e.ownerDocument||e).createElement("style")),gd(a,"style",i),nm(a,n.precedence,e),t.instance=a;case"stylesheet":i=Yd(n.href);var o=e.querySelector(Xd(i));if(o)return t.state.loading|=4,t.instance=o,at(o),o;a=Jd(n),(i=Bd.get(i))&&rm(a,i),at(o=(e.ownerDocument||e).createElement("link"));var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),gd(o,"link",a),t.state.loading|=4,nm(o,n.precedence,e),t.instance=o;case"script":return o=Zd(n.src),(i=e.querySelector(em(o)))?(t.instance=i,at(i),i):(a=n,(i=Bd.get(o))&&am(a=d({},n),i),at(i=(e=e.ownerDocument||e).createElement("script")),gd(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,nm(a,n.precedence,e));return t.instance}function nm(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 rm(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.title&&(e.title=t.title)}function am(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.integrity&&(e.integrity=t.integrity)}var im=null;function om(e,t,n){if(null===im){var r=new Map,a=im=new Map;a.set(n,r)}else(r=(a=im).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[Je]||i[We]||"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 sm(e,t,n){(e=e.ownerDocument||e).head.insertBefore(n,"title"===t?e.querySelector("head > title"):null)}function lm(e){return!!("stylesheet"!==e.type||3&e.state.loading)}var cm=0;function um(){if(this.count--,0===this.count&&(0===this.imgCount||!this.waitingForImages))if(this.stylesheets)mm(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}var dm=null;function mm(e,t){e.stylesheets=null,null!==e.unsuspend&&(e.count++,dm=new Map,t.forEach(hm,e),dm=null,um.call(e))}function hm(e,t){if(!(4&t.state.loading)){var n=dm.get(e);if(n)var r=n.get(null);else{n=new Map,dm.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=um.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 pm={$$typeof:C,Provider:null,Consumer:null,_currentValue:F,_currentValue2:F,_threadCount:0};function fm(e,t,n,r,a,i,o,s,l){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=Ie(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ie(0),this.hiddenUpdates=Ie(null),this.identifierPrefix=r,this.onUncaughtError=a,this.onCaughtError=i,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=l,this.incompleteTransitions=new Map}function gm(e,t,n,r,a,i,o,s,l,c,u,d){return e=new fm(e,t,n,o,l,c,u,d,s),t=1,!0===i&&(t|=24),i=qr(3,null,null,t),e.current=i,i.stateNode=e,(t=Ba()).refCount++,e.pooledCache=t,t.refCount++,i.memoizedState={element:r,isDehydrated:n,cache:t},xi(i),e}function bm(e){return e?e=Fr:Fr}function ym(e,t,n,r,a,i){a=bm(a),null===r.context?r.context=a:r.pendingContext=a,(r=ki(t)).payload={element:n},null!==(i=void 0===i?null:i)&&(r.callback=i),null!==(n=Si(e,r,t))&&(Jc(n,0,t),Ci(n,e,t))}function vm(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function xm(e,t){vm(e,t),(e=e.alternate)&&vm(e,t)}function wm(e){if(13===e.tag||31===e.tag){var t=Dr(e,67108864);null!==t&&Jc(t,0,67108864),xm(e,67108864)}}function km(e){if(13===e.tag||31===e.tag){var t=Yc(),n=Dr(e,t=Fe(t));null!==n&&Jc(n,0,t),xm(e,t)}}var Sm=!0;function Cm(e,t,n,r){var a=O.T;O.T=null;var i=R.p;try{R.p=2,Nm(e,t,n,r)}finally{R.p=i,O.T=a}}function jm(e,t,n,r){var a=O.T;O.T=null;var i=R.p;try{R.p=8,Nm(e,t,n,r)}finally{R.p=i,O.T=a}}function Nm(e,t,n,r){if(Sm){var a=Em(r);if(null===a)id(e,t,r,$m,n),Rm(e,r);else if(function(e,t,n,r,a){switch(t){case"focusin":return Am=Fm(Am,e,t,n,r,a),!0;case"dragenter":return Pm=Fm(Pm,e,t,n,r,a),!0;case"mouseover":return Mm=Fm(Mm,e,t,n,r,a),!0;case"pointerover":var i=a.pointerId;return Im.set(i,Fm(Im.get(i)||null,e,t,n,r,a)),!0;case"gotpointercapture":return i=a.pointerId,Lm.set(i,Fm(Lm.get(i)||null,e,t,n,r,a)),!0}return!1}(a,e,t,n,r))r.stopPropagation();else if(Rm(e,r),4&t&&-1<Om.indexOf(e)){for(;null!==a;){var i=tt(a);if(null!==i)switch(i.tag){case 3:if((i=i.stateNode).current.memoizedState.isDehydrated){var o=ze(i.pendingLanes);if(0!==o){var s=i;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var l=1<<31-Ce(o);s.entanglements[1]|=l,o&=~l}Ru(i),!(6&bc)&&(Oc=me()+500,Fu(0))}}break;case 31:case 13:null!==(s=Dr(i,2))&&Jc(s,0,2),ru(),xm(i,2)}if(null===(i=Em(r))&&id(e,t,r,$m,n),i===a)break;a=i}null!==a&&r.stopPropagation()}else id(e,t,r,null,n)}}function Em(e){return _m(e=Ot(e))}var $m=null;function _m(e){if($m=null,null!==(e=et(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(31===n){if(null!==(e=s(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 $m=e,null}function zm(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(he()){case pe:return 2;case fe:return 8;case ge:case be:return 32;case ye:return 268435456;default:return 32}default:return 32}}var Tm=!1,Am=null,Pm=null,Mm=null,Im=new Map,Lm=new Map,Dm=[],Om="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 Rm(e,t){switch(e){case"focusin":case"focusout":Am=null;break;case"dragenter":case"dragleave":Pm=null;break;case"mouseover":case"mouseout":Mm=null;break;case"pointerover":case"pointerout":Im.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Lm.delete(t.pointerId)}}function Fm(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=tt(t))&&wm(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,null!==a&&-1===t.indexOf(a)&&t.push(a),e)}function Um(e){var t=et(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 Be(e.priority,function(){km(n)})}else if(31===t){if(null!==(t=s(n)))return e.blockedOn=t,void Be(e.priority,function(){km(n)})}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function qm(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=Em(e.nativeEvent);if(null!==n)return null!==(t=tt(n))&&wm(t),e.blockedOn=n,!1;var r=new(n=e.nativeEvent).constructor(n.type,n);Dt=r,n.target.dispatchEvent(r),Dt=null,t.shift()}return!0}function Bm(e,t,n){qm(e)&&n.delete(t)}function Hm(){Tm=!1,null!==Am&&qm(Am)&&(Am=null),null!==Pm&&qm(Pm)&&(Pm=null),null!==Mm&&qm(Mm)&&(Mm=null),Im.forEach(Bm),Lm.forEach(Bm)}function Wm(t,n){t.blockedOn===n&&(t.blockedOn=null,Tm||(Tm=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Hm)))}var Vm=null;function Km(t){Vm!==t&&(Vm=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Vm===t&&(Vm=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===_m(r||n))continue;break}var i=tt(n);null!==i&&(t.splice(e,3),e-=3,is(i,{pending:!0,data:a,method:n.method,action:r},r,a))}}))}function Gm(e){function t(t){return Wm(t,e)}null!==Am&&Wm(Am,e),null!==Pm&&Wm(Pm,e),null!==Mm&&Wm(Mm,e),Im.forEach(t),Lm.forEach(t);for(var n=0;n<Dm.length;n++){var r=Dm[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Dm.length&&null===(n=Dm[0]).blockedOn;)Um(n),null===n.blockedOn&&Dm.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[Ve]||null;if("function"==typeof i)o||Km(n);else if(o){var s=null;if(i&&i.hasAttribute("formAction")){if(a=i,o=i[Ve]||null)s=o.formAction;else if(null!==_m(a))continue}else s=o.action;"function"==typeof s?n[r+1]=s:(n.splice(r,3),r-=3),Km(n)}}}function Qm(){function e(e){e.canIntercept&&"react-transition"===e.info&&e.intercept({handler:function(){return new Promise(function(e){return a=e})},focusReset:"manual",scroll:"manual"})}function t(){null!==a&&(a(),a=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&null!=e.url&&navigation.navigate(e.url,{state:e.getState(),info:"react-transition",history:"replace"})}}if("object"==typeof navigation){var r=!1,a=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),null!==a&&(a(),a=null)}}}function Ym(e){this._internalRoot=e}function Xm(e){this._internalRoot=e}Xm.prototype.render=Ym.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(r(409));ym(t.current,Yc(),e,t,null,null)},Xm.prototype.unmount=Ym.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;ym(e.current,2,null,e,null,null),ru(),t[Ke]=null}},Xm.prototype.unstable_scheduleHydration=function(e){if(e){var t=qe();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Dm.length&&0!==t&&t<Dm[n].priority;n++);Dm.splice(n,0,e),0===n&&Um(e)}};var Jm=t.version;if("19.2.3"!==Jm)throw Error(r(527,Jm,"19.2.3"));R.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 s=o.alternate;if(null===s){if(null!==(a=o.return)){n=a;continue}break}if(o.child===s.child){for(s=o.child;s;){if(s===n)return l(o),e;if(s===a)return l(o),t;s=s.sibling}throw Error(r(188))}if(n.return!==a.return)n=o,a=s;else{for(var c=!1,u=o.child;u;){if(u===n){c=!0,n=o,a=s;break}if(u===a){c=!0,a=o,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,a=o;break}if(u===a){c=!0,a=s,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?u(e):null)?null:e.stateNode};var Zm={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:O,reconcilerVersion:"19.2.3"};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var eh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!eh.isDisabled&&eh.supportsFiber)try{we=eh.inject(Zm),ke=eh}catch(nh){}}return f.createRoot=function(e,t){if(!a(e))throw Error(r(299));var n=!1,i="",o=$s,s=_s,l=zs;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)),t=gm(e,1,!1,null,0,n,i,null,o,s,l,Qm),e[Ke]=t.current,rd(e),new Ym(t)},f.hydrateRoot=function(e,t,n){if(!a(e))throw Error(r(299));var i=!1,o="",s=$s,l=_s,c=zs,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.formState&&(u=n.formState)),(t=gm(e,1,!0,t,0,i,o,u,s,l,c,Qm)).context=bm(null),n=t.current,(o=ki(i=Fe(i=Yc()))).callback=null,Si(n,o,i),n=i,t.current.lanes=n,Le(t,n),Ru(t),e[Ke]=t.current,rd(e),new Xm(t)},f.version="19.2.3",f}var E,$,_=(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(E)return T;E=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(),i=["limbo-tabs","flex","gap-4","border-b-2","border-brand-blue-200","mb-6",r&&"overflow-x-auto scrollbar-none"].filter(Boolean).join(" "),o=e=>{const t=["limbo-tab","relative","px-6","py-2","font-medium","text-brand-blue-1000","bg-transparent","border-0","border-b-2","cursor-pointer","transition-all","duration-200","hover:text-pink-1000","focus:outline-none","focus-visible:ring-2","focus-visible:ring-brand-blue-400","focus-visible:ring-offset-2"];return e?t.push("border-b-brand-blue-1000","font-semibold","limbo-active"):t.push("border-b-transparent"),r&&t.push("min-w-[120px]","min-h-[44px]","text-base","shrink-0"),a&&t.push("touch-manipulation"),t.join(" ")};return A.jsx("div",{className:i,role:"tablist","aria-label":"Opciones de navegación",style:r?{WebkitOverflowScrolling:"touch",scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,children:e.map(r=>{const i=t===r.id;return!i&&r.hideNonActive?null:A.jsx("button",{"data-tab-id":r.id,onClick:()=>n(r.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,r.id),className:o(i),role:"tab","aria-selected":i,"aria-controls":`tabpanel-${r.id}`,tabIndex:i?0:-1,id:`tab-${r.id}`,style:a?{WebkitTapHighlightColor:"transparent"}:void 0,children:r.label},r.id)})})}const L="https://led-dev-limbo-dev.eu.els.local",D="https://limbo.lefebvre.es";let O={publicKey:null,token:null,authMode:null,tokenEndpoint:null,tokenProvider:null,prod:!1};function R({prod:e=!1}={}){return e?D: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||O.prod,c=await async function({isFormData:e=!1,useJWT:t=!0,customHeaders:n={}}={}){const r={"Access-Control-Allow-Origin":`${window.location.hostname||"*"}`};e||(r["Content-Type"]="application/json");let a=O.token;if(t){if("jwt"===O.authMode&&O.tokenProvider&&!a)try{console.log("🔑 Calling tokenProvider..."),a=await O.tokenProvider(),console.log("✅ Token obtained from tokenProvider"),O.token=a}catch(i){throw console.error("❌ tokenProvider failed:",i),new Error("Failed to obtain token from tokenProvider: "+i.message)}else if("session"===O.authMode&&!a)try{const e=R(O),t=O.tokenEndpoint||"/auth/token",n=await fetch(`${e}${t}`,{method:"POST",headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":`${window.location.hostname||"*"}`},body:JSON.stringify({public_key:O.publicKey}),credentials:"include"});if(!n.ok)throw new Error(`Session auth failed: ${n.status}`);a=(await n.json()).token,O.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:O.authMode,hasPublicKey:!!O.publicKey,hasTokenProvider:!!O.tokenProvider})}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(`${R({prod:l})}${a}${e}`,{method:t,headers:c,body:n?o?n:JSON.stringify(n):void 0,credentials:"include"});if(204===u.status)return{success:!0,data:null,message:"No content",httpCode:204,timestamp:(new Date).toISOString()};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={...O};return e?.prod||!1?"https://limbo.lefebvre.es":"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?.success||!e?.data)return{result:null};const t=e.data;if("sync"===t.processing_mode&&t.variants&&t.variants.length>0){const e=t.variants[0];return{result:{id:e.id||null,name:e.name,width:parseInt(e.size?.split("x")[0])||e.width,height:parseInt(e.size?.split("x")[1])||e.height,format:e.format,file_size:e.file_size,url:e.url,status:e.status,asset_id:t.asset_id,created_at:e.created_at||(new Date).toISOString(),all_variants:t.variants}}}return{result:{job_id:t.job_id,asset_id:t.asset_id,variants_requested:t.variants_requested||[],processing_mode:t.processing_mode||"async",estimated_completion:t.estimated_completion,variant_statuses:(t.variant_statuses||t.variants||[]).map(e=>({name:e.name,status:e.status,size:e.expected_size||e.size,format:e.format}))}}}function V(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 K="/api";async function G(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:K,useJWT:!0}))}catch(t){throw V(t)}}async function Q(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:K,isFormData:!0,useJWT:!0}))}catch(r){throw V(r)}}async function Y(e){try{const n=await F({endpoint:`/assets/${e}/variants`,method:"GET",basePath:K,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 V(n)}var t}function X(){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 Y(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:K,useJWT:!0})}catch(n){throw V(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 J({src:e,alt:t="Imagen",title:n="",subtitle:r="",onClose:a,isOpen:i=!1}){const[o,s]=u.useState(1),[l,c]=u.useState({x:0,y:0}),[d,m]=u.useState(!1),[h,p]=u.useState(!1),[f,g]=u.useState({x:0,y:0}),[b,y]=u.useState(!1),[v,x]=u.useState(!1),w=u.useRef(null),k=u.useRef(null);u.useEffect(()=>{i&&(s(1),c({x:0,y:0}),y(!1),x(!1))},[i]);const S=u.useCallback(()=>{s(e=>Math.min(e+.25,5)),c({x:0,y:0})},[]),C=u.useCallback(()=>{s(e=>Math.max(e-.25,.25)),c({x:0,y:0})},[]),j=u.useCallback(()=>{s(1),c({x:0,y:0})},[]),N=u.useCallback(()=>{s(1),c({x:0,y:0})},[]),E=u.useCallback(e=>{if("Escape"===e.key)return e.preventDefault(),void a?.();if((e.ctrlKey||e.metaKey)&&("+"===e.key||"="===e.key))return e.preventDefault(),void S();if((e.ctrlKey||e.metaKey)&&"-"===e.key)return e.preventDefault(),void C();if((e.ctrlKey||e.metaKey)&&"0"===e.key)return e.preventDefault(),void j();if(o>1){const t=50;switch(e.key){case"ArrowUp":e.preventDefault(),c(e=>({...e,y:e.y+t}));break;case"ArrowDown":e.preventDefault(),c(e=>({...e,y:e.y-t}));break;case"ArrowLeft":e.preventDefault(),c(e=>({...e,x:e.x+t}));break;case"ArrowRight":e.preventDefault(),c(e=>({...e,x:e.x-t}))}}},[a,S,C,j,o]),$=u.useCallback(e=>{(e.ctrlKey||e.metaKey)&&(e.preventDefault(),e.deltaY<0?S():C())},[S,C]),_=u.useCallback(e=>{o>1&&0===e.button&&(e.preventDefault(),m(!0),p(!1),g({x:e.clientX-l.x,y:e.clientY-l.y}))},[o,l]),z=u.useCallback(e=>{d&&(p(!0),c({x:e.clientX-f.x,y:e.clientY-f.y}))},[d,f]),T=u.useCallback(()=>{m(!1)},[]),P=u.useCallback(e=>{e.stopPropagation(),1!==o||h||(s(2),c({x:0,y:0})),p(!1)},[o,h]),M=u.useCallback(e=>{e.stopPropagation(),1===o?(s(2),c({x:0,y:0})):j()},[o,j]);if(u.useEffect(()=>{if(!i)return;document.addEventListener("keydown",E),document.addEventListener("mouseup",T),document.addEventListener("mousemove",z);const e=e=>{!e.ctrlKey&&!e.metaKey||"+"!==e.key&&"-"!==e.key&&"="!==e.key&&"0"!==e.key||e.preventDefault()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",E),document.removeEventListener("mouseup",T),document.removeEventListener("mousemove",z),document.removeEventListener("keydown",e)}},[i,E,T,z]),u.useEffect(()=>(document.body.style.overflow=i?"hidden":"",()=>{document.body.style.overflow=""}),[i]),!i)return null;const I=Math.round(100*o);return A.jsxs("div",{className:"fixed inset-0 bg-black/95 z-[10000] flex flex-col",role:"dialog","aria-modal":"true","aria-label":"Visor de imagen",children:[A.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-black/50 backdrop-blur-sm",children:[A.jsxs("div",{className:"flex-1 min-w-0",children:[n&&A.jsx("h2",{className:"text-white font-medium text-sm truncate",children:n.split(".")[0]}),r&&A.jsx("p",{className:"text-gray-400 text-xs mt-0.5 truncate",children:r})]}),A.jsxs("div",{className:"flex items-center gap-2 mx-4",children:[A.jsx("button",{type:"button",onClick:C,disabled:o<=.25,className:"w-8 h-8 flex items-center justify-center rounded-lg bg-white/10 hover:bg-white/20 text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors","aria-label":"Reducir zoom",title:"Reducir zoom (Ctrl -)",children:A.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})}),A.jsxs("div",{className:"w-20 text-center text-white text-sm font-medium bg-white/10 rounded-lg px-2 py-1.5 cursor-pointer hover:bg-white/20 transition-colors",onClick:j,title:"Click para restablecer zoom",role:"button",tabIndex:0,onKeyDown:e=>"Enter"===e.key&&j(),children:[I,"%"]}),A.jsx("button",{type:"button",onClick:S,disabled:o>=5,className:"w-8 h-8 flex items-center justify-center rounded-lg bg-white/10 hover:bg-white/20 text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors","aria-label":"Aumentar zoom",title:"Aumentar zoom (Ctrl +)",children:A.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),A.jsx("button",{type:"button",onClick:N,className:"w-8 h-8 flex items-center justify-center rounded-lg bg-white/10 hover:bg-white/20 text-white transition-colors ml-2","aria-label":"Ajustar a pantalla",title:"Ajustar a pantalla (Ctrl 0)",children:A.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})})]}),A.jsx("button",{type:"button",onClick:a,className:"w-10 h-10 flex items-center justify-center rounded-lg bg-white/10 hover:bg-red-1000/80 text-white transition-colors","aria-label":"Cerrar visor (ESC)",title:"Cerrar (ESC)",children:A.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),A.jsxs("div",{ref:w,className:`flex-1 overflow-hidden flex items-center justify-center ${o>1?"cursor-grab":"cursor-zoom-in"} ${d?"cursor-grabbing":""}`,onClick:e=>{e.target===w.current&&a?.()},onWheel:$,onMouseDown:_,children:[!b&&!v&&A.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:A.jsx("div",{className:"w-12 h-12 border-4 border-white/20 border-t-white rounded-full animate-spin"})}),v&&A.jsxs("div",{className:"text-center text-white",children:[A.jsx("svg",{className:"w-16 h-16 mx-auto mb-4 text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",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-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),A.jsx("p",{className:"text-lg font-medium",children:"Error al cargar la imagen"}),A.jsx("p",{className:"text-gray-400 text-sm mt-2",children:"No se pudo cargar la imagen"})]}),A.jsx("img",{ref:k,src:e,alt:t,className:"max-w-full max-h-full object-contain transition-opacity duration-200 select-none "+(b?"opacity-100":"opacity-0"),style:{transform:`scale(${o}) translate(${l.x/o}px, ${l.y/o}px)`,transition:d?"none":"transform 0.2s ease-out"},onLoad:()=>y(!0),onError:()=>x(!0),onClick:P,onDoubleClick:M,draggable:!1})]}),A.jsx("div",{className:"px-4 py-2 bg-black/50 backdrop-blur-sm text-center",children:A.jsxs("p",{className:"text-gray-400 text-xs",children:[A.jsxs("span",{className:"hidden sm:inline",children:[A.jsx("kbd",{className:"px-1.5 py-0.5 bg-white/10 rounded text-white",children:"Ctrl"})," + rueda para zoom •"," ",A.jsx("kbd",{className:"px-1.5 py-0.5 bg-white/10 rounded text-white",children:"Ctrl"})," +"," ",A.jsx("kbd",{className:"px-1.5 py-0.5 bg-white/10 rounded text-white",children:"+"})," /"," ",A.jsx("kbd",{className:"px-1.5 py-0.5 bg-white/10 rounded text-white",children:"-"})," ","zoom •"," ","Doble click para ampliar/restablecer •"," ","Flechas para mover •"," ",A.jsx("kbd",{className:"px-1.5 py-0.5 bg-white/10 rounded text-white",children:"ESC"})," cerrar"]}),A.jsx("span",{className:"sm:hidden",children:"Click para zoom • Doble click para restablecer • ESC para cerrar"})]})})]})}function Z({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}=X(),f=window.limboCore?.accessibilityManager,[g,b]=d.useState(null),[y,v]=d.useState(null),[x,w]=u.useState(null),k=(window.limboCore?.config?.getGlobal()||{}).interaction||{allowSelection:!1,allowCropping:!0},S=k.allowSelection&&s.select&&r,C=k.allowCropping&&s.crop&&i,j=s.download,N=s.delete,[E,$]=d.useState(new Set),[_,z]=d.useState(new Set),T=u.useRef(null),P=u.useRef(null),M=u.useCallback(e=>{if("Escape"===e.key){if(x)return;e.preventDefault(),n?.()}if("Tab"===e.key&&T.current){const t=T.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):e.shiftKey||document.activeElement!==r||(e.preventDefault(),n?.focus())}},[n,x]);u.useEffect(()=>{if(t)return P.current?.focus(),document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[t,M]);const I=d.useMemo(()=>e?.variants||[],[e?.variants]),L=c(e?.id),D=(I.length>0?I:L).filter(e=>!_.has(e.id)),O=0===I.length&&m(e?.id),R=0===I.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&&($(new Set),z(new Set))},[t]);if(!t)return null;const F=[{...e,isOriginal:!0},...D.map(e=>({...e,isOriginal:!1}))];return A.jsxs("div",{className:"fixed inset-0 bg-black/85 flex items-center justify-center z-[1000] p-4",onClick:()=>{x||n?.()},role:"dialog","aria-modal":"true","aria-labelledby":"variants-modal-title","aria-describedby":"variants-modal-description",children:[A.jsxs("div",{ref:T,className:"bg-white rounded-xl max-w-[95vw] max-h-[90vh] overflow-hidden shadow-2xl flex flex-col w-[900px]",onClick:e=>e.stopPropagation(),children:[A.jsxs("div",{className:"px-5 py-4 border-b border-gray-200 flex justify-between items-center bg-gray-50",children:[A.jsxs("div",{className:"flex-1 min-w-0 pr-4",children:[A.jsx("h2",{id:"variants-modal-title",className:"m-0 text-lg font-semibold text-gray-900 truncate",children:e?.filename}),A.jsxs("p",{id:"variants-modal-description",className:"text-sm text-gray-500 mt-1",children:["Imagen original y ",D.length," recorte",1!==D.length?"s":""," disponible",1!==D.length?"s":""]})]}),A.jsx("button",{ref:P,className:"w-10 h-10 flex items-center justify-center rounded-lg bg-gray-100 hover:bg-red-200 text-gray-500 hover:text-red-1000 transition-colors focus:outline-none focus:ring-2 focus:ring-brand-blue-400",onClick:n,"aria-label":"Cerrar modal (ESC)",title:"Cerrar (ESC)",children:A.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),g&&A.jsx("div",{className:"mx-2 mt-2 px-2 py-1.5 rounded text-xs "+("success"===y?"bg-green-50 text-green-1000":"bg-red-50 text-red-1000"),role:"alert",children:g}),A.jsx("div",{className:"p-5 overflow-y-auto flex-1 bg-gray-50/50",children:O?A.jsxs("div",{className:"text-center py-16 text-gray-500",role:"status","aria-live":"polite",children:[A.jsx("div",{className:"w-12 h-12 border-4 border-gray-200 border-t-brand-blue-800 rounded-full animate-spin mx-auto mb-4"}),A.jsx("p",{className:"text-base",children:"Cargando variantes..."})]}):R?A.jsxs("div",{className:"text-center py-16 text-red-1000",role:"alert",children:[A.jsx("svg",{className:"w-12 h-12 mx-auto mb-4 text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",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-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),A.jsxs("p",{className:"text-base font-medium",children:["Error: ",R]}),A.jsx("button",{onClick:()=>l(e.id),className:"mt-4 text-sm px-5 py-2.5 rounded-lg bg-brand-blue-800 text-white hover:bg-brand-blue-1000 focus:outline-none focus:ring-2 focus:ring-brand-blue-400 focus:ring-offset-2",children:"Reintentar"})]}):0===D.length?A.jsxs("div",{className:"text-center py-16 text-gray-500",children:[A.jsx("svg",{className:"w-12 h-12 mx-auto mb-4 text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),A.jsx("p",{className:"text-base",children:"No hay recortes disponibles"})]}):A.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-5",role:"list","aria-label":"Lista de imágenes",children:F.map((t,s)=>{const l=t.isOriginal,c=!l&&E.has(t.id),u=t.url,d=l?"Original":t.name||t.filename||`Recorte ${s}`,m=l?e.width:t.width,h=l?e.height:t.height,g=l?e.file_size:t.file_size||0;return A.jsxs("article",{role:"listitem","aria-label":`${d} - ${m}×${h} píxeles`,className:`rounded-xl overflow-hidden transition-all shadow-sm hover:shadow-lg ${l?"ring-2 ring-brand-blue-800 ring-offset-2 bg-white":"border border-gray-200 bg-white hover:border-brand-blue-400"} focus-within:ring-2 focus-within:ring-brand-blue-400`,children:[A.jsxs("button",{type:"button",title:"Click para ampliar con zoom",className:"relative w-full cursor-pointer aspect-square flex items-center justify-center overflow-hidden bg-gray-100 focus:outline-none group",onClick:c?void 0:()=>{return l?(f?.announce(`Abriendo visor de imagen: ${e.filename}`),void w({src:e.url,title:e.filename||"Original",subtitle:`${e.width}×${e.height} · ${Math.round((e.file_size||0)/1024)}KB`})):(n=t,f?.announce(`Abriendo visor de imagen: ${n.name}`),void w({src:n.url,title:n.name||n.filename||"Recorte",subtitle:`${n.width}×${n.height} · ${Math.round((n.file_size||0)/1024)}KB`}));var n},"aria-label":`Ver ${d} en tamaño completo con zoom`,disabled:c,children:[c?A.jsxs("div",{className:"text-center text-gray-400",children:[A.jsx("svg",{className:"w-10 h-10 mx-auto mb-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),A.jsx("span",{className:"text-sm",children:"Error al cargar"})]}):A.jsxs(A.Fragment,{children:[A.jsx("img",{src:u,alt:`${d} - ${m}×${h}px`,loading:l?"eager":"lazy",onError:l?void 0:()=>{return e=t.id,void $(t=>new Set([...t,e]));var e},className:"w-full h-full object-contain p-3 transition-transform group-hover:scale-105"}),A.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/10 transition-colors flex items-center justify-center",children:A.jsxs("span",{className:"opacity-0 group-hover:opacity-100 transition-opacity bg-black/60 text-white px-3 py-1.5 rounded-full text-xs font-medium flex items-center gap-1.5",children:[A.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})}),"Ampliar"]})})]}),l&&A.jsx("span",{className:"absolute top-3 left-3 bg-brand-blue-800 text-white text-xs font-bold px-3 py-1.5 rounded-lg shadow-lg",children:"ORIGINAL"})]}),A.jsxs("div",{className:"px-4 py-3 border-t border-gray-100 bg-white",children:[A.jsx("h3",{className:"text-sm font-semibold text-gray-900 truncate mb-2",title:d,children:d}),A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsxs("span",{className:"text-xs text-gray-500 font-medium",children:[m,"×",h," ·"," ",Math.round(g/1024),"KB"]}),A.jsxs("div",{className:"flex gap-2",role:"group","aria-label":`Acciones para ${d}`,children:[l&&C&&A.jsx("button",{type:"button",className:"w-8 h-8 rounded-lg bg-brand-blue-400 hover:bg-brand-blue-800 cursor-pointer text-white flex items-center justify-center focus:outline-none focus:ring-2 focus:ring-brand-blue-400 focus:ring-offset-1 transition-colors shadow-sm",onClick:t=>{t.stopPropagation(),i&&(f?.announce(`Abriendo herramienta de recorte para ${e.filename}`),i(e),n?.())},"aria-label":"Crear nuevo recorte",title:"Recortar",children:A.jsx("span",{className:"icon icon-scissors-white icon--sm"})}),j&&A.jsx("button",{type:"button",className:"w-8 h-8 rounded-lg bg-brand-blue-400 hover:bg-brand-blue-800 cursor-pointer text-white flex items-center justify-center focus:outline-none focus:ring-2 focus:ring-brand-blue-400 focus:ring-offset-1 transition-colors shadow-sm",onClick:n=>{n.stopPropagation(),l?(async()=>{const{downloadImage:t}=await Promise.resolve().then(()=>on);await t(e.url||e.path,e.filename||"limbo-image",{originalFormat:e.format,accessibilityManager:f})})():(async e=>{const{downloadImage:t}=await Promise.resolve().then(()=>on);await t(e.url,e.name||"limbo-variant",{originalFormat:e.format||e.output_format,accessibilityManager:f})})(t)},"aria-label":`Descargar ${d}`,title:"Descargar",children:A.jsx("span",{className:"icon icon-download-white icon--sm"})}),N&&(!l||a)&&A.jsx("button",{type:"button",className:"w-8 h-8 rounded-lg bg-red-1000 hover:bg-red-800 cursor-pointer text-white flex items-center justify-center focus:outline-none focus:ring-2 focus:ring-red-800 focus:ring-offset-1 transition-colors shadow-sm",onClick:r=>{r.stopPropagation(),l?(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?.())})():(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?(z(e=>new Set([...e,t.id])),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)},"aria-label":`Eliminar ${d}`,title:"Eliminar",children:A.jsx("span",{className:"icon icon-close-small-white icon--sm"})}),S&&A.jsx("button",{type:"button",className:"w-8 h-8 cursor-pointer rounded-lg bg-brand-blue-1000 text-white hover:bg-brand-blue-800 flex items-center justify-center focus:outline-none focus:ring-2 focus:ring-brand-blue-400 focus:ring-offset-1 transition-colors shadow-sm",onClick:a=>{a.stopPropagation(),l?(r?.(e),n?.()):(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)},"aria-label":`Seleccionar ${d}`,title:"Seleccionar",children:A.jsx("span",{className:"icon icon-tick-white icon--sm"})})]})]})]})]},l?"original":t.id)})})})]}),A.jsx(J,{isOpen:!!x,src:x?.src||"",alt:x?.title||"Imagen",title:x?.title,subtitle:x?.subtitle,onClose:()=>w(null)})]})}function ee({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(!1),[f,g]=u.useState(e.variants_count||0),[b,y]=u.useState(!0),[v,x]=u.useState(!1),{isMobile:w,isTouch:k}=M(),S=window.limboCore?.accessibilityManager,C=(window.limboCore?.config?.getGlobal()||{}).interaction||{allowSelection:!1,allowCropping:!0},j=n=>{n.stopPropagation(),S?.announce(`Eliminando imagen ${e.filename}`,"assertive"),t?.(e)},N=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),S?.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),S?.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.`)}},E=async t=>{t.preventDefault(),t.stopPropagation();const{downloadImage:n}=await Promise.resolve().then(()=>on);await n(e.url||e.path,e.filename||"limbo-image",{originalFormat:e.format,accessibilityManager:S})},$=t=>{t.stopPropagation(),S?.announce(`Editando imagen ${e.filename}`),n?.(e)},_=e.variants&&e.variants.length>0||f>0,z=f,T=d.useCallback(()=>{g(e=>Math.max(0,e-1))},[]);d.useEffect(()=>{g(e.variants_count||0)},[e.variants_count]),d.useEffect(()=>{y(!0),x(!1)},[e.url,e.path]);const P=C.allowSelection&&o.select&&r,I=C.allowCropping&&o.crop&&n,L=()=>{_?(S?.announce(`Mostrando recortes de ${e.filename}`),m(!0)):(S?.announce(`Abriendo visor de ${e.filename}`),p(!0))};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":""} ${w?"limbo-image-card--mobile":""}`,onClick:L,onKeyDown:r=>{switch(r.key){case"Enter":case" ":r.preventDefault(),L();break;case"d":case"D":o.download&&(r.preventDefault(),E(r));break;case"c":case"C":o.copy&&(r.preventDefault(),N(r));break;case"Delete":case"Backspace":o.delete&&t&&(r.preventDefault(),j(r));break;case"x":case"X":o.crop&&n&&(r.preventDefault(),$(r));break;case"v":case"V":o.variants&&(r.preventDefault(),(t=>{t.stopPropagation(),S?.announce(`Mostrando recortes de ${e.filename}`),m(!0)})(r))}},title:_?`Ver ${z} recorte${1!==z?"s":""} de ${e.filename}`:w?"Toque para ampliar imagen":"Click para ampliar imagen con zoom",role:"button",tabIndex:0,"aria-label":`Imagen ${e.filename}. ${e.width}x${e.height} px`,style:{...k&&{touchAction:"manipulation",WebkitTapHighlightColor:"transparent"}},children:[A.jsxs("div",{className:"limbo-image-actions "+(w?"limbo-image-actions--mobile":""),children:[!_&&P&&A.jsx("button",{type:"button",title:"Seleccionar imagen",className:"btn btn-success bg-brand-blue-800 hover:bg-brand-blue-1000 border border-brand-blue-1000 "+(w?"btn--touch":""),onClick:t=>{t.stopPropagation(),S?.announce(`Seleccionando ${e.filename} para el portal`),r?.(e)},tabIndex:-1,style:{...w&&{width:"40px",height:"40px"}},children:A.jsx("span",{className:"icon icon-tick-white icon--sm","aria-hidden":"true"})}),I&&A.jsx("button",{type:"button",title:"Editar imagen",className:"btn btn-crop bg-brand-blue-400 hover:bg-brand-blue-800 border border-brand-blue-1000 "+(w?"btn--touch":""),onClick:$,tabIndex:-1,style:{...w&&{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 bg-brand-blue-400 hover:bg-brand-blue-800 border border-brand-blue-1000 "+(w?"btn--touch":""),onClick:N,tabIndex:-1,style:{...w&&{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 bg-brand-blue-400 hover:bg-brand-blue-800 border border-brand-blue-1000 "+(w?"btn--touch":""),onClick:E,tabIndex:-1,style:{...w&&{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:j,disabled:i,className:"btn btn-delete bg-red-1000 hover:bg-red-800 border border-red-1000/50 "+(w?"btn--touch":""),title:"Eliminar imagen",tabIndex:-1,style:{...w&&{width:"40px",height:"40px"}},children:i?"…":A.jsx("span",{className:"icon icon-close-small-white icon--sm","aria-hidden":"true"})})]}),b&&!v&&A.jsx("div",{className:"w-full aspect-square rounded bg-neutral-200 animate-pulse flex items-center justify-center "+(_?"ring-2 ring-brand-blue-400 ring-offset-2":""),style:{...w&&{minHeight:`${Math.max(3*a,80)}px`}},children:A.jsx("span",{className:"icon icon-spinner w-8 h-8 animate-spin"})}),v&&A.jsxs("div",{className:"w-full aspect-square rounded bg-neutral-100 flex flex-col items-center justify-center text-neutral-400",style:{...w&&{minHeight:`${Math.max(3*a,80)}px`}},children:[A.jsx("span",{className:"icon icon-close icon--lg mb-1","aria-hidden":"true"}),A.jsx("span",{className:"text-xs",children:"Error al cargar"})]}),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 ${_?"ring-2 ring-brand-blue-400 ring-offset-2":""} ${b||v?"hidden":""}`,sizes:`height: ${6*a}px,width: ${6*a}px`,draggable:!1,onLoad:()=>y(!1),onError:()=>{y(!1),x(!0)},style:{...w&&{minHeight:`${Math.max(3*a,80)}px`,height:"auto",aspectRatio:"1 / 1",objectFit:"cover"}}}),A.jsxs("span",{className:"text-xs mt-1 limbo-truncate w-full text-center limbo-image-card-name "+(w?"limbo-image-card-name--mobile":""),style:{...w&&{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("span",{className:"limbo-variants-indicator",style:{marginLeft:"4px",padding:"1px 6px",backgroundColor:"#dc2626",color:"white",borderRadius:"10px",fontSize:"10px",fontWeight:"700",display:"inline-block"},title:`${z} recorte${1!==z?"s":""}`,children:z})]})]}),A.jsx(Z,{image:e,isOpen:c,onClose:()=>m(!1),onSelect:r,onDelete:t,onCrop:n,onVariantDeleted:T,allowedActions:{select:o.select,download:o.download,copy:o.copy,delete:o.delete,crop:o.crop}}),A.jsx(J,{isOpen:h,src:e.url||e.path,alt:e.filename,title:e.filename,subtitle:`${e.width}×${e.height} · ${Math.round((e.file_size||0)/1024)}KB`,onClose:()=>p(!1)})]})}function te(){return A.jsxs("div",{className:"limbo-image-card animate-pulse",role:"status","aria-label":"Cargando imágen...",children:[A.jsx("div",{className:"w-full aspect-square bg-neutral-gray-200 rounded-md flex items-center justify-center",children:A.jsx("span",{className:"icon icon-spinner"})}),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:"sr-only",children:"Cargando imágen..."})]})}function ne({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 py-4",children:[A.jsx("div",{className:"p-2 px-4 mb-2",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-45 sm:flex-1",children:[A.jsx("label",{htmlFor:"name",className:"limbo-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:"limbo-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:"limbo-form-label mb-1",children:"Desde"}),A.jsx("input",{type:"date",name:"dateFrom",id:"dateFrom",value:s.dateFrom,onChange:y,className:"limbo-form-control"})]}),A.jsxs("div",{className:"flex flex-col w-full sm:w-auto",children:[A.jsx("label",{htmlFor:"dateTo",className:"limbo-form-label mb-1",children:"Hasta"}),A.jsx("input",{type:"date",name:"dateTo",id:"dateTo",value:s.dateTo,onChange:y,className:"limbo-form-control"})]})]}),p&&A.jsxs("div",{className:"flex flex-col w-full sm:w-auto",children:[A.jsx("label",{htmlFor:"uploadedBy",className:"limbo-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:"limbo-form-control"})]})]})]})}),i?A.jsxs("div",{className:"relative",children:[A.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-white/80 z-10 min-h-75",children:A.jsxs("div",{className:"flex flex-col items-center gap-3",children:[A.jsx("span",{className:"icon icon-spinner p-4 animate-spin"}),A.jsx("span",{className:"text-sm text-gray-600 font-medium",children:"Cargando imágenes..."})]})}),d.showPlaceholders&&A.jsx("div",{ref:g,className:"limbo-gallery opacity-30","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(te,{})},`skeleton-${t}`))})]}):o?A.jsx("div",{className:"alert alert-danger text-center",children:o}):A.jsx("div",{ref:g,className:"limbo-gallery px-3","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(ee,{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 re({image:e,onDiscard:t,onRetry:n,onDownload:r,onSelect:a,showRetry:i=!1,disabled:o=!1}){const[s,l]=u.useState(null),[c,d]=u.useState({name:"",size:"",type:""}),[m,h]=u.useState(!1);u.useEffect(()=>{if(!e)return void l(null);const t=URL.createObjectURL(e);return l(t),d({name:e.name||"imagen.webp",size:p(e.size||0),type:e.type||"image/webp"}),()=>{URL.revokeObjectURL(t)}},[e]);const p=e=>{if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return Math.round(e/Math.pow(1024,t)*100)/100+" "+["Bytes","KB","MB","GB"][t]};return e&&s?A.jsxs("div",{className:"w-fit md:w-full bg-white border border-gray-200 rounded-lg px-1 sm:px-3 py-2 m-0 shadow-sm",children:[A.jsxs("div",{className:"flex items-center justify-between mb-4 px-1",children:[A.jsx("h3",{className:"text-sm font-medium text-gray-700",children:"Vista previa de imagen"}),A.jsx("button",{type:"button",onClick:t,disabled:o,className:"p-1.5 text-gray-400 cursor-pointer hover:text-gray-600 hover:bg-red-300 rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed","aria-label":"Descartar imagen",title:"Descartar imagen",children:A.jsx("span",{className:"icon icon-close-small icon--md"})})]}),A.jsxs("div",{className:"flex flex-col justify-center md:flex-row gap-2 md:gap-6",children:[A.jsxs("div",{className:"flex-1 md:flex-[0.4] flex flex-col items-center justify-center",children:[A.jsxs("div",{className:"relative w-full max-w-md aspect-video bg-gray-100 rounded-lg overflow-hidden cursor-zoom-in hover:ring-2 hover:ring-brand-blue-800 transition-all",onClick:()=>h(!0),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),h(!0))},"aria-label":"Click para ver imagen en tamaño completo",title:"Click para ver en tamaño completo",children:[A.jsx("img",{src:s,alt:"Vista previa",className:"absolute inset-0 w-full h-full object-contain"}),A.jsxs("div",{className:"absolute top-2 right-2 bg-black/50 text-white px-2 py-1 rounded text-xs flex items-center gap-1",children:[A.jsx("span",{className:"icon icon-search-white icon--xs"}),A.jsx("span",{className:"hidden sm:inline",children:"Ampliar"})]})]}),A.jsx("div",{className:"mt-3 text-center space-y-1 w-full",children:A.jsxs("div",{className:"rounded-sm w-fit gap-0.5 p-0.5 min-w-fit mx-auto",children:[A.jsxs("label",{htmlFor:"uploadImageId",className:"flex items-center w-fit",children:[A.jsx("div",{className:"rounded-full bg-brand-blue-1000 min-w-6 min-h-6 flex items-center align-middle content-center justify-center me-1",children:A.jsx("span",{className:"icon icon-edit-white icon--sm"})}),A.jsx("input",{id:"uploadImageId",onChange:e=>(e=>{const t=e.target.value,n=c.name,r=n.lastIndexOf("."),a=-1!==r?n.substring(r):".webp";d(e=>({...e,name:t+a}))})(e),className:"w-fit px-1 text-sm font-medium text-gray-800 border border-gray-300 rounded limbo-truncate focus:outline focus:outline-neutral-gray-100 focus:limbo-transform-none focus:shadow-none focus:opacity-100",defaultValue:c.name.split(".")[0],title:"Renombra la imagen a tu gusto"})]}),A.jsxs("div",{className:"flex items-center justify-center gap-3 text-xs text-gray-500",children:[A.jsx("span",{children:c.size}),A.jsx("span",{children:"•"}),A.jsx("span",{children:c.type.split("/")[1]?.toUpperCase()||"IMAGE"})]})]})})]}),A.jsxs("div",{className:"flex flex-row md:flex-col gap-2 justify-items-stretch justify-center md:justify-start items-stretch md:min-w-[140px]",children:[i&&n&&A.jsxs("button",{type:"button",onClick:n,disabled:o,className:"flex-1 md:flex-none flex items-center justify-center gap-2 px-4 py-2.5 bg-white border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 cursor-pointer hover:border-gray-400 transition-colors disabled:opacity-50 disabled:cursor-not-allowed text-sm font-medium","aria-label":"Intentarlo de nuevo",title:"Generar de nuevo con el mismo prompt",children:[A.jsx("span",{className:"icon icon-refresh icon--sm"}),A.jsx("span",{className:"hidden sm:inline",children:"Reintentar"}),A.jsx("span",{className:"sm:hidden",children:"Retry"})]}),A.jsxs("button",{type:"button",onClick:()=>{if(!s||o)return;const e=document.createElement("a");e.href=s,e.download=c.name,document.body.appendChild(e),e.click(),document.body.removeChild(e),r&&r()},disabled:o,className:"flex-1 cursor-pointer md:flex-none flex items-center justify-center gap-2 px-4 py-2.5 bg-white border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 hover:border-gray-400 transition-colors disabled:opacity-50 disabled:cursor-not-allowed text-sm font-medium","aria-label":"Descargar imagen",children:[A.jsx("span",{className:"icon icon-download icon--sm"}),A.jsx("span",{children:"Descargar"})]}),A.jsxs("button",{type:"button",onClick:()=>a&&a(c.name),disabled:o,className:"flex-1 md:flex-none flex items-center justify-center gap-2 px-4 py-2.5 bg-brand-blue-800 border border-brand-blue-800 text-white rounded-lg hover:bg-brand-blue-1000 cursor-pointer hover:border-brand-blue-1000 transition-colors disabled:opacity-50 disabled:cursor-not-allowed text-sm font-medium shadow-sm","aria-label":"Seleccionar imagen para recortar",children:[A.jsx("span",{className:"icon icon-tick-white icon--sm"}),A.jsx("span",{children:"Seleccionar"})]})]})]}),A.jsx(J,{isOpen:m,src:s,alt:c.name,title:c.name,subtitle:`${c.size} • ${c.type.split("/")[1]?.toUpperCase()||"IMAGE"}`,onClose:()=>h(!1)})]}):null}function ae({file:e,setFile:t,previewUrl:n,setPreviewUrl:r,fileInputRef:a,onSelect:i,disabled:o}){const[s,l]=u.useState(!1),c=e=>{if(t(e),e){const t=URL.createObjectURL(e);r(t)}else r(null)};return A.jsxs("div",{className:"flex flex-col items-center gap-6","aria-label":"Subir imagen desde dispositivo",children:[A.jsxs("label",{htmlFor:"file-input",className:"w-fit md:w-full flex flex-col items-center justify-center border-2 border-dashed rounded-xl p-8 cursor-pointer transition "+(s?"border-brand-blue-1000 bg-brand-blue-100 scale-[1.02]":"border-brand-blue-200 hover:border-brand-blue-1000 hover:to-bright-blue-200 hover:from-brand-blue-50 focus-within:border-brand-blue-800 from-bright-blue-50 to-brand-blue-50 bg-linear-to-br"),tabIndex:0,style:{outline:"none"},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),o||l(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),e.currentTarget.contains(e.relatedTarget)||l(!1)},onDrop:e=>{if(e.preventDefault(),e.stopPropagation(),l(!1),o)return;const t=e.dataTransfer?.files;if(t&&t.length>0){const e=t[0];e.type.startsWith("image/")&&c(e)}},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 t=e.target.files[0];c(t)},disabled:o,className:"sr-only","aria-label":"Seleccionar imagen"})]}),e&&A.jsx(re,{image:e,onDiscard:()=>{t(null),r(null),a.current&&(a.current.value="")},onDownload:()=>{},onSelect:t=>{if(e&&!o&&i)if(t&&t!==e.name){const n=new File([e],t,{type:e.type});i(n)}else i(e)},showRetry:!1,disabled:o})]})}const ie="/api";const oe=new Map;function se(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=oe.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:ie})}(e);if(!s)return;const a=r?.data||r?.result||[],o=Array.isArray(a)?a.map(e=>({label:e.name||e.label,slug:e.slug,type:e.type,description:e.description,image:e.image,costInfo:e.cost_info||null})):Object.entries(a).map(([e,t])=>({label:e,slug:t,type:"image_generation",description:null,image:null,costInfo:null}));n(o),oe.set(t,{data:o,timestamp:i})}catch(r){s&&o(r.message)}finally{s&&a(!1)}})(),()=>{s=!1}},[e]);return{services:t,loading:r,error:i,invalidateCache:()=>{oe.delete(`ai-services-${e}`)}}}const le=new Map;function ce(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=le.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),le.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 ue({show:e=!1,message:t="Cargando...",className:n=""}){return e?A.jsx("div",{className:`absolute inset-0 min-h-50 bg-white/80 backdrop-blur-sm z-50 flex flex-col items-center justify-center ${n}`,"aria-live":"polite","aria-busy":"true",role:"status",children:A.jsxs("div",{className:"flex flex-col items-center gap-4",children:[A.jsx("span",{className:"icon icon-spinner p-4 animate-spin"}),A.jsx("p",{className:"text-brand-blue-1000 font-medium text-lg",children:t})]})}):null}function de({prod:e,disabled:t,onSelect:n}){const r=se(e),a=ce(e),[i,o]=u.useState(""),[s,l]=u.useState(""),[c,m]=u.useState({}),[h,p]=u.useState(!1),[f,g]=u.useState(null),[b,y]=u.useState(null),[v,x]=u.useState(null),[w,k]=u.useState(!0),[S,C]=u.useState(!1);d.useEffect(()=>{if(!r.loading&&1===r.services.length){const e=r.services[0];l(e.slug),k(!1),a.fetchParams(e.slug,!0)}},[r.loading,r.services]),d.useEffect(()=>{if(!s)return;const e=a.params?.[s]?.parameters;if(e){const t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default??""]));t.service=s,m(t)}},[s,a.params]);const j=e=>{const{name:t,value:n}=e.target;m(e=>({...e,[t]:n}))},N=async(t,n=!1)=>{t.preventDefault(),p(!0),g(null),y(null);try{n?c.prompt=i:o(c.prompt||"");const t=await function(e,t=!1){return F({endpoint:"/ai/generate",method:"POST",body:e,prod:t,basePath:ie})}(c,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)throw new Error("No se pudo extraer la imagen de la respuesta");if(a.startsWith("http"))try{const e=`${window.limboCore?.config?.getGlobal()?.prod?"https://limbo.lefebvre.es":"https://led-dev-limbo-dev.eu.els.local"}/api/atenea/proxy?url=${encodeURIComponent(a)}`,t=await fetch(e,{credentials:"include",headers:{Authorization:`Bearer ${window.limboCore?.apiClient?.token||""}`}});if(!t.ok)throw new Error(`Failed to download image: ${t.status}`);const n=await t.blob(),r=new File([n],"ai-image.webp",{type:n.type||"image/webp"});x(r)}catch(r){throw new Error(`Error downloading image via proxy: ${r.message}`)}else{const e=a.replace(/^data:image\/\w+;base64,/,""),t=atob(e),n=new Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);const r=new Uint8Array(n),i=new File([r],"ai-image.webp",{type:"image/webp"});x(i)}y(t?.data?.images||t?.result?.images||null)}catch(a){g(a.message||"Error al generar la imagen")}finally{p(!1)}};return r.loading?A.jsxs("div",{className:"flex items-center justify-center py-8",children:[A.jsx("span",{className:"limbo-loader mr-2"})," Cargando servicios IA..."]}):r.services.length?A.jsx("div",{className:"flex flex-col mx-4 pb-2",children:w?A.jsxs(A.Fragment,{children:[A.jsx("h3",{id:"aiSelectDescription",className:"text-2xl font-semibold text-brand-blue-1000 mb-3",children:"Selecciona el modelo IA"}),r.error&&A.jsx("div",{className:"alert alert-danger",children:r.error}),A.jsx("div",{className:"flex flex-wrap justify-around items-stretch justify-items-stretch content-stretch gap-3 w-full max-w-7xl",children:r.services.map(e=>A.jsxs("button",{type:"button",onClick:()=>{l(e.slug),k(!1),m({}),y(null),g(null),x(null),a.fetchParams(e.slug,!0)},disabled:r.loading||t,className:`group relative p-4 rounded-lg border-2 transition-all duration-200 overflow-hidden flex flex-col items-center justify-center min-h-30 grow basis-sm min-w-70 border-gray-200 hover:border-brand-blue-800 hover:shadow-md hover:text-black ${r.loading||t?"opacity-50 cursor-not-allowed":"cursor-pointer"} `,style:{position:"relative"},children:[e.image&&A.jsx("div",{className:"absolute inset-0 bg-cover bg-center transition-opacity duration-200 group-hover:opacity-40",style:{backgroundImage:`url(${e.image})`,opacity:.2}}),A.jsxs("div",{className:"relative z-10 flex flex-col items-center justify-center gap-2 text-center",children:[A.jsx("span",{className:"text-base font-semibold text-gray-800",children:e.label}),e.description&&A.jsx("span",{className:"text-xs text-neutral-gray-800 limbo-line-clamp-2 drop-shadow drop-shadow-neutral-white-000",children:e.description})]}),e.costInfo&&A.jsx("span",{className:"absolute top-0 left-1 inline-flex items-center gap-1 py-0 px-1 mt-1 text-xs font-medium text-warning-1000 rounded-md group-hover:bg-white/90",style:{zoom:"82%"},children:e.costInfo})]},e.slug))})]}):A.jsxs(A.Fragment,{children:[A.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-2",children:[A.jsx("h3",{className:"text-2xl font-semibold text-brand-blue-1000",children:r.services.find(e=>e.slug===s)?.label||"Generación IA"}),r.services.find(e=>e.slug===s)?.costInfo&&A.jsxs("div",{title:"Coste estimado por imagen que le cuesta a la empresa, este coste depende de la calidad de la imagen generada y puede variar según el proveedor IA, ten en cuenta este coste para hacer un uso más responsable del servicio IA",className:"flex items-center gap-1","aria-description":"Coste estimado por imagen que le cuesta a la empresa, este coste depende de la calidad de la imagen generada y puede variar según el proveedor IA, ten en cuenta este coste para hacer un uso más responsable del servicio IA",children:[A.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium text-warning-1000 bg-yellow-200/60 rounded-full border border-warning-1000 select-none",children:[A.jsx("span",{className:"icon icon-euro-blue icon--2sm icon--warning",style:{filter:"var(--icon-warning-dark)"}}),"Coste:"," ",r.services.find(e=>e.slug===s)?.costInfo]}),A.jsx("span",{className:"icon icon-info cursor-help"})]})]}),a.loading&&A.jsx("div",{children:"Cargando parámetros..."}),a.error&&A.jsx("div",{className:"alert alert-danger",children:a.error}),s&&(()=>{const e=a.params?.[s]?.parameters;if(!e)return null;const n=Object.entries(e).filter(([e,t])=>!t.hidden),i=n.filter(([e])=>e.toLowerCase().includes("prompt")||e.toLowerCase().includes("query")),o=n.filter(([e])=>!e.toLowerCase().includes("prompt")&&!e.toLowerCase().includes("query")),u=(e,n)=>{let r=n.placeholder||"";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()}`);const a=e.toLowerCase().includes("prompt")||e.toLowerCase().includes("query");return A.jsxs("div",{className:"flex flex-col gap-1",children:[A.jsxs("label",{htmlFor:`ai-${e}`,className:"text-xs font-medium text-brand-blue-1000",children:[n.label||e,n.required&&A.jsx("span",{className:"text-red-1000 ml-1",children:"*"})]}),n.options?A.jsx("select",{id:`ai-${e}`,name:e,value:c[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?A.jsx("textarea",{id:`ai-${e}`,name:e,value:c[e]??"",onChange:j,className:"limbo-input resize-none overflow-y-auto",disabled:t,required:n.required,placeholder:r,title:n.label||e,rows:3,style:{maxHeight:"9rem",minHeight:"3rem"},onInput:e=>{e.target.style.height="auto";const t=Math.min(e.target.scrollHeight,144);e.target.style.height=`${t}px`}}):A.jsx("input",{id:`ai-${e}`,type:"integer"===n.type?"number":"text",name:e,value:c[e]??"",onChange:j,className:"limbo-input",disabled:t,required:n.required,min:n.minValue,max:n.maxValue,placeholder:r,title:n.label||e})]},e)};return A.jsxs("div",{className:"h-fit w-full",children:[r.services.length>1&&A.jsxs("button",{type:"button",onClick:()=>{k(!0),l(""),m({}),y(null),g(null),x(null)},className:"flex cursor-pointer items-center gap-2 text-brand-blue-800 hover:text-brand-blue-1000 mb-4 font-medium",children:[A.jsx("span",{className:"icon icon-arrow-left"}),"Volver al menú de servicios"]}),A.jsxs("div",{className:"relative",children:[A.jsxs("form",{onSubmit:N,"data-type":"ai",className:"flex flex-col gap-3 mt-4 border-t pt-4 border-brand-blue-200","aria-label":"Formulario generación IA",children:[A.jsx("div",{className:"flex flex-col gap-3",children:i.map(([e,t])=>u(e,t))}),o.length>0&&A.jsxs("div",{className:"border-t border-gray-200 pt-3",children:[A.jsxs("button",{type:"button",onClick:()=>C(!S),className:"flex items-center gap-2 text-sm font-medium text-brand-blue-800 hover:text-brand-blue-1000 mb-3 transition-colors",children:[A.jsx("svg",{className:"w-4 h-4 transition-transform "+(S?"rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"Opciones avanzadas",!S&&A.jsxs("span",{className:"text-xs text-gray-500",children:["(",o.length," opciones)"]})]}),S&&A.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3 animate-fadeIn",children:o.map(([e,t])=>u(e,t))})]}),A.jsx("button",{type:"submit",disabled:h||t,title:h?"Generando imagen...":v?"Generar otra imagen":"Generar imagen",className:"limbo-btn w-full mt-2 "+(h?"cursor-not-allowed limbo-btn-disabled":"limbo-btn-primary"),style:{minHeight:44},children:h?"Generando imagen...":v?"Generar otra imagen":"Generar imagen"})]}),A.jsx(ue,{show:h,message:"Generando imagen con IA..."})]})]})})(),f&&A.jsx("div",{className:"alert alert-danger mt-4",children:f}),v&&A.jsx("div",{className:"mt-6 md:w-full mx-auto",children:A.jsx(re,{image:v,onDiscard:()=>{x(null),y(null),g(null)},onRetry:e=>N(e,!0),onDownload:()=>{},onSelect:e=>{if(n){const t=v||b;if(e&&t&&e!==t.name){const r=new File([t],e,{type:t.type});n(r)}else n(t)}},showRetry:!0,disabled:h||t})})]})}):A.jsx("div",{className:"alert alert-warning",children:"No hay servicios IA disponibles."})}const me="/api";const he=new Map;function pe(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=he.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:me})}(e);if(!s)return;if(204===r?.httpCode||null===r?.data)return n([]),o("No hay servicios de stock disponibles en este momento"),void he.set(t,{data:[],timestamp:i});const a=r?.data||r?.result||[],l=Array.isArray(a)?a.map(e=>({label:e.name||e.label,slug:e.slug,type:e.type,description:e.description,image:e.image})):Object.entries(a).map(([e,t])=>({label:e,slug:t,type:"stock_image",description:null,image:null}));n(l),he.set(t,{data:l,timestamp:i})}catch(r){s&&o(r.message)}finally{s&&a(!1)}})(),()=>{s=!1}},[e]);return{services:t,loading:r,error:i,invalidateCache:()=>{he.delete(`stock-services-${e}`)}}}function fe({prod:e,disabled:t,onSelect:n}){const r=d.useRef(null),a=pe(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,v]=u.useState(null),x=ce(e),[w,k]=u.useState(!1),[S,C]=u.useState(null),[j,N]=u.useState(null),[E,$]=u.useState(!0),[_,z]=u.useState(!1),[T,P]=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]),d.useEffect(()=>{if(!a.loading&&1===a.services.length){const e=a.services[0];s(e.slug),$(!1),x.fetchParams(e.slug,!0)}},[a.loading,a.services]),d.useEffect(()=>{if(!o)return;const e=x.params?.[o]?.parameters;if(e){const t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default??""]));t.service=o,c(t)}},[o,x.params]);const M=e=>{const{name:t,value:n}=e.target;c(e=>({...e,[t]:n}))},I=async(t=1)=>{k(!0),C(null),1===t&&h([]);try{let n;if(1===t){const e=x.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:me})}(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(L(Array.isArray(i)?i:[])),b(c),f(c?.current_page||t)}catch(n){C(n.message||"Error al buscar imágenes")}finally{k(!1)}},L=e=>{const t=new Set,n=[];return(e||[]).forEach((e,r)=>{const i=e.url||e.preview_url||e.full||e.preview;i&&!t.has(i)&&(t.add(i),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:a.services.find(e=>e.slug===o)?.label||o}))}),n},D=async e=>{e.preventDefault();const t=l.query||l.search||l.term||"";t.trim().length<5?C("La búsqueda debe tener al menos 5 caracteres"):(v(t),await I(1))},O=e=>{e<1||I(e)},R=async t=>{N(t.id),C(null);try{const n={service:o,image_id:t.id},r=await function(e,t=!1){return F({endpoint:"/stock/download",method:"POST",body:e,prod:t,basePath:me})}(n,e),a=r?.result?.url||r?.result?.download_url||r?.data?.images?.url||r?.data?.url||r?.images?.url||r?.url;if(!a)throw console.error("Download response structure:",r),new Error("No se pudo obtener la URL de descarga");{const e=await fetch(a),n=await e.blob(),i=r?.result?.filename||r?.data?.images?.filename||r?.data?.filename||`stock-${t.id}.jpg`,o=new File([n],i,{type:n.type||"image/jpeg"});P(o)}}catch(n){C(n.message||"No se pudo recuperar la imagen seleccionada")}finally{N(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.jsx("div",{className:"flex flex-col mx-4 pb-2",children:E?A.jsxs(A.Fragment,{children:[A.jsx("h3",{className:"text-2xl font-semibold text-brand-blue-1000 mb-3",children:"Selecciona el servicio de Stock"}),a.error&&A.jsx("div",{className:"alert alert-danger",children:a.error}),A.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:a.services.map(e=>A.jsxs("button",{type:"button",onClick:()=>{s(e.slug),$(!1),c({}),h([]),f(1),b(null),C(null),x.fetchParams(e.slug,!0)},disabled:a.loading||t,className:`group relative p-4 rounded-lg border-2 transition-all duration-200 overflow-hidden flex flex-col items-center justify-center min-h-30 border-gray-200 hover:border-brand-blue-300 hover:shadow-md ${a.loading||t?"opacity-50 cursor-not-allowed":"cursor-pointer"} `,style:{position:"relative"},children:[e.image&&A.jsx("div",{className:"absolute inset-0 bg-cover bg-center transition-opacity duration-200 group-hover:opacity-40",style:{backgroundImage:`url(${e.image})`,opacity:.2}}),A.jsxs("div",{className:"relative z-10 flex flex-col items-center justify-center gap-2 text-center",children:[A.jsx("span",{className:"text-base font-semibold text-gray-800",children:e.label}),e.description&&A.jsx("span",{className:"text-xs text-gray-600 limbo-line-clamp-2",children:e.description})]})]},e.slug))})]}):A.jsxs(A.Fragment,{children:[A.jsx("h3",{className:"text-2xl font-semibold text-brand-blue-1000",children:a.services.find(e=>e.slug===o)?.label||"Búsqueda Stock"}),x.loading&&A.jsx("div",{children:"Cargando parámetros..."}),x.error&&A.jsx("div",{className:"alert alert-danger",children:x.error}),o&&(()=>{const e=x.params?.[o]?.parameters;if(!e)return null;const n=Object.entries(e).filter(([,e])=>!e.hidden),r=n.filter(([e])=>e.toLowerCase().includes("query")||e.toLowerCase().includes("search")||e.toLowerCase().includes("term")),i=n.filter(([e])=>!e.toLowerCase().includes("query")&&!e.toLowerCase().includes("search")&&!e.toLowerCase().includes("term")),u=(e,n)=>{let r=n.placeholder||"";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()}`);const a=e.toLowerCase().includes("query")||e.toLowerCase().includes("search")||e.toLowerCase().includes("term");return A.jsxs("div",{className:"flex flex-col gap-1",children:[A.jsxs("label",{htmlFor:`stock-${e}`,className:"text-xs font-medium text-brand-blue-1000",children:[n.label||e,n.required&&A.jsx("span",{className:"text-red-1000 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:M,className:"limbo-input",disabled:t,title:n.label||e,children:n.options.map(e=>A.jsx("option",{value:e,children:e},e))}):a?A.jsx("textarea",{id:`stock-${e}`,name:e,value:l[e]??"",onChange:M,className:"limbo-input resize-none overflow-y-auto",disabled:t,required:n.required,placeholder:r,title:n.label||e,rows:3,style:{maxHeight:"9rem",minHeight:"3rem"},onInput:e=>{e.target.style.height="auto";const t=Math.min(e.target.scrollHeight,144);e.target.style.height=`${t}px`}}):A.jsx("input",{id:`stock-${e}`,type:"integer"===n.type?"number":"text",name:e,value:l[e]??"",onChange:M,className:"limbo-input",disabled:t,required:n.required,min:n.minValue,max:n.maxValue,placeholder:r,title:n.label||e})]},e)};return A.jsxs("div",{children:[a.services.length>1&&A.jsxs("button",{type:"button",onClick:()=>{$(!0),s(""),c({}),h([]),f(1),b(null),C(null)},className:"flex cursor-pointer items-center gap-2 text-brand-blue-800 hover:text-brand-blue-1000 mb-4 font-medium",children:[A.jsx("span",{className:"icon icon-arrow-left"}),"Volver al menú de servicios"]}),A.jsxs("div",{className:"relative",children:[A.jsxs("form",{onSubmit:D,"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:"flex flex-col gap-3",children:r.map(([e,t])=>u(e,t))}),i.length>0&&A.jsxs("div",{className:"border-t border-gray-200 pt-3",children:[A.jsxs("button",{type:"button",onClick:()=>z(!_),className:"flex items-center gap-2 text-sm font-medium text-brand-blue-800 hover:text-brand-blue-1000 mb-3 transition-colors",children:[A.jsx("svg",{className:"w-4 h-4 transition-transform "+(_?"rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"Opciones avanzadas",!_&&A.jsxs("span",{className:"text-xs text-gray-500",children:["(",i.length," opciones)"]})]}),_&&A.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 animate-fadeIn",children:i.map(([e,t])=>u(e,t))})]}),A.jsx("button",{type:"submit",disabled:w||t,className:"limbo-btn w-full mt-2 "+(w?"cursor-not-allowed limbo-btn-disabled":"limbo-btn-primary"),style:{minHeight:44},children:w?"Buscando...":"Buscar imágenes"})]}),A.jsx(ue,{show:w&&!m.length,message:"Buscando imágenes..."})]})]})})(),S&&A.jsx("div",{className:"alert alert-danger mt-4",children:S}),T&&A.jsx("div",{className:"mt-6 md:w-full mx-auto",children:A.jsx(re,{image:T,onDiscard:()=>{P(null),C(null)},onDownload:()=>{},onSelect:e=>{if(n)if(e&&T&&e!==T.name){const t=new File([T],e,{type:T.type});n(t)}else n(T)},showRetry:!1,disabled:t})}),!T&&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-1 relative","aria-live":"polite",children:[A.jsx(ue,{show:w,message:"Cargando imágenes..."}),m.map((e,n)=>A.jsx("div",{className:"group border border-brand-blue-200 rounded-sm overflow-hidden bg-white shadow-sm hover:shadow-md transition-all duration-200 cursor-pointer",title:"Seleccionar imagen",onClick:()=>!j&&!w&&!t&&R(e),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"}),j===e.id?A.jsxs("div",{className:"absolute inset-0 bg-white/90 flex flex-col items-center justify-center gap-2",children:[A.jsxs("div",{className:"relative w-10 h-10",children:[A.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-200 rounded-full"}),A.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-800 rounded-full border-t-transparent animate-spin"})]}),A.jsx("span",{className:"text-sm font-medium text-brand-blue-1000",children:"Descargando..."})]}):A.jsxs("div",{className:"absolute inset-0 bg-brand-blue-800/0 group-hover:bg-brand-blue-800/50 transition-colors duration-200 flex items-center justify-center flex-col",children:[A.jsx("span",{className:"icon icon-round-check-filled-blue icon--2xl max-w-full max-h-full opacity-0 group-hover:opacity-100 transition-opacity duration-200"}),A.jsx("span",{style:{textShadow:"1px 0 #001978, -1px 0 #001978, 0 1px #001978, 0 -0.5px #001978, 0.5px 0.5px #001978, -1px -1px #001978, 1px -1px #001978, -1px 1px #001978"},className:"max-w-full max-h-full opacity-0 group-hover:opacity-100 transition-opacity duration-200 text-neutral-white-000",children:"Seleccionar"})]})]})},e.id||n))]}),g&&A.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2",children:[A.jsxs("button",{onClick:()=>O(g.current_page-1),disabled:g.current_page<=1||w,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(g.current_page<=1||w?" 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:()=>O(g.current_page+1),disabled:w||g.current_page>=Math.ceil(g.total/g.per_page),className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(w||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"})]})]})]}),!w&&0===m.length&&o&&y&&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 ge="/api";const be=new Map;function ye(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=be.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,t=!0){const n=new URLSearchParams;return n.set("active",t?"true":"false"),F({endpoint:`/external/portals?${n.toString()}`,method:"GET",prod:e,basePath:ge})}(e,!0);if(!s)return;let a=r?.data?.sources?.portals||r?.data?.portals||r?.data||[];Array.isArray(a)||(a=[]);const o=a.map(e=>({id:e.slug||e.id,numericId:e.id,name:e.name,title:e.name,slug:e.slug,url:e.website_url,image:e.logo_url,isActive:e.is_active}));n(o),be.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:()=>{be.delete(`portal-sources-${e}`)}}}const ve=({src:e,fallbackSrc:t,alt:n,className:r,onError:a})=>{const[i,o]=d.useState("loading"),[s,l]=d.useState(e),[c,u]=d.useState(!1);return"error"===i?null:A.jsxs("div",{className:"relative w-full h-full",children:["loading"===i&&A.jsx("div",{className:"absolute inset-0 bg-linear-to-r from-gray-200 via-gray-100 to-gray-200 animate-pulse flex items-center justify-center",children:A.jsx("div",{className:"flex flex-col items-center gap-2",children:A.jsx("span",{className:"icon icon-spinner w-8 h-8 text-gray-400 animate-spin"})})}),A.jsx("img",{src:s,alt:n,className:`${r} ${"loading"===i?"opacity-0":"opacity-100"} transition-opacity duration-300`,loading:"lazy",onLoad:()=>{o("loaded")},onError:()=>{t&&!c?(u(!0),l(t),o("loading")):(o("error"),a&&a())}})]})};function xe({prod:e,disabled:t,onSelect:n}){const r=d.useRef(null),a=ye(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,j]=u.useState(()=>i("paginationInfo",null)),[N,E]=u.useState(null),[$,_]=u.useState(null),z=u.useRef({}),[T,P]=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 M=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),i=z.current[n];if(i)return w(i.images),S(i.portalResults),j(i.paginationInfo),f(t),void v(null);b(!0),v(null),1===t&&(w([]),S({}),j(null));try{let i;if(1===t){i={sources:o,totalPortals:a.sources.length,page:t,withImage:!0};const e=l.trim();e&&(i.name=e),m&&50!==m&&(i.limit=m),r.current={...i}}else i={...r.current,page:t};const s=await function(e,t=!1){const n=new URLSearchParams,r=e.sources||[];e.portal?n.set("portal",e.portal):r.length>0&&n.set("portals",r.join(","));const a=e.q||e.name||e.search;if(a&&n.set("q",a),!0===e.withImage&&n.set("withImage","1"),e.limit&&n.set("limit",String(e.limit)),void 0!==e.offset)n.set("offset",String(e.offset));else if(e.page&&e.limit){const t=(e.page-1)*e.limit;n.set("offset",String(t))}return F({endpoint:`/external/articles?${n.toString()}`,method:"GET",prod:t,basePath:ge})}(i,e),c=s?.data||{},u=c?.articles||c||[],d=c?.total||u.length,h=c?.limit||m,p=c?.offset||0,g={total:d,pages:Math.ceil(d/h),current_page:Math.floor(p/h)+1,per_page:h},b=[],y={};u.forEach(t=>{const n=t.portal?.id||"unknown",r=a.sources.find(e=>e.id===n||e.slug===n),i=r?.title||r?.name||t.portal?.name||n;if(y[n]||(y[n]={title:i,status:200,response:"OK",count:0}),t.image_url){const r=t.image_url;y[n].count++;const a=`${R({prod:e})}/api/atenea/proxy?url=${encodeURIComponent(r)}`;b.push({id:t.id,title:t.title,excerpt:t.excerpt,url:r,full:r,preview:r,thumbnail:r,proxiedUrl:a,filename:`${t.title}.jpg`,source:n,sourceTitle:i,author:t.author,categories:t.categories,published_at:t.published_at,article_url:t.url})}}),z.current[n]={images:b,portalResults:y,paginationInfo:g},w(b),S(y),j(g),f(t),P(new Set),0!==b.length||s?.result?.success||v(s?.result?.message||"No se encontraron imágenes")}catch(s){v(s.message||"Error al buscar imágenes en portales")}finally{b(!1)}},I=e=>{e<1||M(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-2",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(),M(1)},className:"flex flex-col gap-4 border-t pt-4 border-brand-blue-200",children:[A.jsxs("div",{className:"flex flex-col gap-3",children:[A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsxs("h3",{className:"text-lg font-semibold text-brand-blue-1000",children:["Selecciona 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-sm text-brand-blue-800 hover:text-brand-blue-1000 font-medium transition-colors",children:o.length===a.sources.length?"Deseleccionar todos":"Seleccionar todos"})]}),A.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:a.sources.map(e=>{const n=o.includes(e.id);return A.jsxs("button",{type:"button",onClick:()=>{return t=e.id,void s(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]);var t},disabled:t,className:` relative p-4 rounded-lg border-2 transition-all duration-200 flex flex-col items-center justify-center min-h-25 gap-2 max-h-27.5 box-border ${n?"border-brand-blue-800 bg-brand-blue-50":"border-gray-200 bg-white hover:border-brand-blue-350"} ${t?"opacity-50 cursor-not-allowed":"cursor-pointer"} hover:shadow-md `,children:[n&&A.jsx("div",{className:"absolute top-2 right-2 w-6 h-6 bg-brand-blue-800 rounded-full flex items-center justify-center",children:A.jsx("span",{className:"icon icon-tick-white icon--sm"})}),A.jsx("img",{className:"object-auto bg-no-repeat bg-center max-w-9/12 max-h-9/12",src:e.image,alt: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-col gap-1 hidden",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:10,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:[t.image?A.jsx("img",{src:t.image,alt:t.title,className:"w-10 h-10 object-cover rounded"}):A.jsx("span",{className:"font-medium",children:t.title}),A.jsx("span",{className:200===t.status?"text-green-1000":"text-red-1000",children:200===t.status?`${t.count} imágenes`:t.response})]},e))})]}),$&&A.jsx("div",{className:"mt-6 md:w-full mx-auto",children:A.jsx(re,{image:$,onDiscard:()=>{_(null),v(null)},onDownload:()=>{},onSelect:e=>{if(n)if(e&&$&&e!==$.name){const t=new File([$],e,{type:$.type});n(t)}else n($)},showRetry:!1,disabled:t})}),!$&&(x.length>0||g)&&A.jsxs(A.Fragment,{children:[A.jsxs("div",{className:"mt-6 relative min-h-50","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.jsxs("div",{className:"relative grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2",children:[A.jsx(ue,{show:g,message:"Cargando imágenes..."}),x.map((n,r)=>{const a=`${n.source}-${n.id||r}`,i=n.preview||n.thumbnail||n.url||n.full;return T.has(a)?null:A.jsxs("div",{className:"group border border-brand-blue-200 rounded-lg overflow-hidden bg-white shadow-sm hover:shadow-md transition-all duration-200 cursor-pointer",onClick:()=>!N&&!g&&!t&&(async t=>{E(t.url||t.full),v(null);try{const n=t.full||t.url||t.preview;if(!n)throw new Error("No se encontró URL de la imagen");const r=`${R({prod:e})}/api/atenea/proxy?url=${encodeURIComponent(n)}`,a=await fetch(r);if(!a.ok)throw new Error(`Error al descargar: ${a.status}`);const i=await a.blob(),o=t.filename||t.title||`portal-${t.id||Date.now()}.jpg`,s=new File([i],o,{type:i.type||"image/jpeg"});_(s)}catch(n){v(n.message||"No se pudo recuperar la imagen del portal")}finally{E(null)}})(n),children:[A.jsxs("div",{className:"relative aspect-video bg-neutral-100",children:[A.jsx(ve,{src:i,fallbackSrc:n.proxiedUrl,alt:n.title||n.filename||`Imagen ${r+1}`,className:"object-cover w-full h-full",onError:()=>{P(e=>{const t=new Set(e);return t.add(a),t})}}),A.jsx("span",{className:"absolute top-1 left-1 bg-black/60 text-white text-xs px-2 py-1 rounded",children:n.sourceTitle}),N===(n.url||n.full)?A.jsxs("div",{className:"absolute inset-0 bg-white/90 flex flex-col items-center justify-center gap-2",children:[A.jsxs("div",{className:"relative w-10 h-10",children:[A.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-200 rounded-full"}),A.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-800 rounded-full border-t-transparent animate-spin"})]}),A.jsx("span",{className:"text-sm font-medium text-brand-blue-1000",children:"Descargando..."})]}):A.jsxs("div",{className:"absolute inset-0 bg-brand-blue-800/0 group-hover:bg-brand-blue-800/50 transition-colors duration-200 flex items-center justify-center flex-col",children:[A.jsx("span",{className:"icon icon-round-check-filled-blue icon--2xl max-w-full max-h-full opacity-0 group-hover:opacity-100 transition-opacity duration-200"}),A.jsx("span",{style:{textShadow:"1px 0 #001978, -1px 0 #001978, 0 1px #001978, 0 -0.5px #001978, 0.5px 0.5px #001978, -1px -1px #001978, 1px -1px #001978, -1px 1px #001978"},className:"max-w-full max-h-full opacity-0 group-hover:opacity-100 transition-opacity duration-200 text-neutral-white-000",children:"Seleccionar"})]})]}),n.title&&A.jsx("div",{className:"px-2 pb-2 pt-1",children:A.jsx("p",{className:"text-xs text-gray-600 limbo-truncate",title:n.title,children:n.title})})]},a)})]})]}),A.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2",children:[A.jsxs("button",{onClick:()=>I(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:()=>I(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 we=[{id:"upload",label:"Subir archivo"},{id:"ai",label:"Generar con IA"},{id:"stock",label:"Buscar en Stock"},{id:"portals",label:"Otros portales"}];function ke({onSelect:e,disabled:t=!1,apiKey:n,prod:r=!1}){const{isMobile:a,isTouch:i}=M(),[o,s]=u.useState("upload"),[l,c]=u.useState(null),[d,m]=u.useState(null),h=u.useRef(),p=["limbo-tabs","flex","gap-4","border-b-2","border-brand-blue-200","mb-4",a&&"overflow-x-auto scrollbar-none"].filter(Boolean).join(" "),f=e=>{const t=["limbo-tab","relative","px-4","py-2","font-medium","text-brand-blue-1000","bg-transparent","border-0","border-b-2","cursor-pointer","transition-all","duration-200","hover:text-pink-1000","focus:outline-none","focus-visible:ring-2","focus-visible:ring-brand-blue-400","focus-visible:ring-offset-2","text-nowrap"];return e?t.push("border-b-brand-blue-1000","font-semibold","limbo-active"):t.push("border-b-transparent"),a&&t.push("min-w-[100px]","min-h-[44px]","text-sm","shrink-0"),i&&t.push("touch-manipulation"),t.join(" ")};return A.jsxs("div",{className:"limbo-upload-form py-4 min-w-fit max-w-7xl mx-auto",children:[A.jsx("div",{className:p,role:"tablist","aria-label":"Opciones de subida de imagen",style:a?{WebkitOverflowScrolling:"touch",scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,children:we.map(e=>{const t=o===e.id;return A.jsx("button",{type:"button","data-upload-tab-id":e.id,className:f(t),"aria-current":t?"page":void 0,"aria-selected":t,role:"tab",tabIndex:t?0:-1,onClick:()=>s(e.id),onKeyDown:t=>((e,t)=>{const n=we.findIndex(e=>e.id===t);let r=n;switch(e.key){case"ArrowLeft":e.preventDefault(),r=n>0?n-1:we.length-1;break;case"ArrowRight":e.preventDefault(),r=n<we.length-1?n+1:0;break;case"Home":e.preventDefault(),r=0;break;case"End":e.preventDefault(),r=we.length-1;break;case"Enter":case" ":return e.preventDefault(),void s(t);default:return}const a=we[r];a&&(s(a.id),setTimeout(()=>{const e=document.querySelector(`[data-upload-tab-id="${a.id}"]`);e&&e.focus()},0))})(t,e.id),id:`upload-tab-${e.id}`,"aria-controls":`upload-tabpanel-${e.id}`,style:i?{WebkitTapHighlightColor:"transparent"}:void 0,children:e.label},e.id)})}),A.jsxs("div",{className:"limbo-tab-content px-2 py-2",role:"tabpanel",id:`upload-tabpanel-${o}`,"aria-labelledby":`upload-tab-${o}`,children:["upload"===o&&A.jsx(ae,{file:l,setFile:c,previewUrl:d,setPreviewUrl:m,fileInputRef:h,onSelect:e,disabled:t}),"ai"===o&&A.jsx(de,{apiKey:n,prod:r,disabled:t,onSelect:e}),"stock"===o&&A.jsx(fe,{apiKey:n,prod:r,disabled:t,onSelect:e}),"portals"===o&&A.jsx(xe,{apiKey:n,prod:r,disabled:t,onSelect:e})]})]})}const Se="undefined"!=typeof window&&void 0!==window.document,Ce=Se?window:{},je=!!Se&&"ontouchstart"in Ce.document.documentElement,Ne=!!Se&&"PointerEvent"in Ce,Ee="cropper",$e=`${Ee}-canvas`,_e=`${Ee}-crosshair`,ze=`${Ee}-grid`,Te=`${Ee}-handle`,Ae=`${Ee}-image`,Pe=`${Ee}-selection`,Me=`${Ee}-shade`,Ie=`${Ee}-viewer`,Le="select",De="move",Oe="scale",Re="rotate",Fe="transform",Ue="none",qe="n-resize",Be="e-resize",He="s-resize",We="w-resize",Ve="ne-resize",Ke="nw-resize",Ge="se-resize",Qe="sw-resize",Ye=Ne?"pointerdown":je?"touchstart":"mousedown",Xe=Ne?"pointermove":je?"touchmove":"mousemove",Je=Ne?"pointerup pointercancel":je?"touchend touchcancel":"mouseup",Ze="error",et="keydown",tt="load",nt="wheel",rt="action",at="actionend",it="actionstart",ot="change",st="transform";const lt=Number.isNaN||Ce.isNaN;function ct(e){return"number"==typeof e&&!lt(e)}function ut(e){return ct(e)&&e>0&&e<1/0}function dt(e){return"object"==typeof e&&null!==e}const{hasOwnProperty:mt}=Object.prototype;function ht(e){if(!dt(e))return!1;try{const{constructor:t}=e,{prototype:n}=t;return t&&n&&mt.call(n,"isPrototypeOf")}catch(t){return!1}}function pt(e){return"function"==typeof e}function ft(e){return"object"==typeof e&&null!==e&&1===e.nodeType}const gt=/([a-z\d])([A-Z])/g;function bt(e){return String(e).replace(gt,"$1-$2").toLowerCase()}const yt=/-[A-z\d]/g;function vt(e){return e.replace(yt,e=>e.slice(1).toUpperCase())}const xt=/\s\s*/;function wt(e,t,n,r){t.trim().split(xt).forEach(t=>{e.removeEventListener(t,n,r)})}function kt(e,t,n,r){t.trim().split(xt).forEach(t=>{e.addEventListener(t,n,r)})}function St(e,t,n,r){kt(e,t,n,Object.assign(Object.assign({},r),{once:!0}))}const Ct={bubbles:!0,cancelable:!0,composed:!0};const jt=Promise.resolve();function Nt(e){const{documentElement:t}=e.ownerDocument,n=e.getBoundingClientRect();return{left:n.left+(Ce.pageXOffset-t.clientLeft),top:n.top+(Ce.pageYOffset-t.clientTop)}}const Et=/deg|g?rad|turn$/i;function $t(e){const t=parseFloat(e)||0;if(0!==t){const[n="rad"]=String(e).match(Et)||[];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 _t="contain";function zt(e,t=_t){const{aspectRatio:n}=e;let{width:r,height:a}=e;const i=ut(r),o=ut(a);if(i&&o){const e=a*n;t===_t&&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 Tt(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 Tt(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 At=/left|top|width|height/i,Pt="open",Mt=new WeakMap,It=new WeakMap,Lt=new Map,Dt=Ce.document&&Array.isArray(Ce.document.adoptedStyleSheets)&&"replaceSync"in Ce.CSSStyleSheet.prototype;class Ot extends HTMLElement{get $sharedStyle(){return(this.themeColor?`:host{--theme-color: ${this.themeColor};}`:"")+":host([hidden]){display:none!important}"}constructor(){var e,t;super(),this.shadowRootMode=Pt,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&&Lt.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=vt(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=It.get(this),t=this.$sharedStyle;e&&t&&(Dt?e.replaceSync(t):e.textContent=t);break}}}$propertyChangedCallback(e,t,n){if(!Object.is(n,t))switch(e=bt(e),typeof n){case"boolean":!0===n?this.hasAttribute(e)||this.setAttribute(e,""):this.removeAttribute(e);break;case"number":n=lt(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=vt(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.shadowRoot||this.attachShadow({mode:this.shadowRootMode||Pt});if(Mt.set(this,e),It.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(){It.has(this)&&It.delete(this),Mt.has(this)&&Mt.delete(this)}$getTagNameOf(e){var t;return null!==(t=Lt.get(e))&&void 0!==t?t:e}$setStyles(e){return Object.keys(e).forEach(t=>{let n=e[t];ct(n)&&(n=0!==n&&At.test(t)?`${n}px`:String(n)),this.style[t]=n}),this}$getShadowRoot(){return this.shadowRoot||Mt.get(this)}$addStyles(e){let t;const n=this.$getShadowRoot();return Dt?(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({},Ct),{detail:n}),r)))}(this,e,t,n)}$nextTick(e){return function(e,t){return t?jt.then(e?t.bind(e):t):jt}(this,e)}static $define(e,t){dt(e)&&(t=e,e=""),e||(e=this.$name||this.name),e=bt(e),Se&&Ce.customElements&&!Ce.customElements.get(e)&&customElements.define(e,this,t)}}Ot.$version="2.1.0";class Rt extends Ot{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=Ue,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),kt(this,Ye,this.$onPointerDown)),this.$onPointerMove||(this.$onPointerMove=this.$handlePointerMove.bind(this),kt(this.ownerDocument,Xe,this.$onPointerMove)),this.$onPointerUp||(this.$onPointerUp=this.$handlePointerUp.bind(this),kt(this.ownerDocument,Je,this.$onPointerUp)),this.$onWheel||(this.$onWheel=this.$handleWheel.bind(this),kt(this,nt,this.$onWheel,{passive:!1,capture:!0}))}$unbind(){this.$onPointerDown&&(wt(this,Ye,this.$onPointerDown),this.$onPointerDown=null),this.$onPointerMove&&(wt(this.ownerDocument,Xe,this.$onPointerMove),this.$onPointerMove=null),this.$onPointerUp&&(wt(this.ownerDocument,Je,this.$onPointerUp),this.$onPointerUp=null),this.$onWheel&&(wt(this,nt,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)&&(ct(t)&&1!==t||ct(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=Fe:ft(e.target)&&(i=e.target.action||e.target.getAttribute("action")||""),!1!==this.$emit(it,{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===Ue||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===Fe){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=Re,r.rotate=o,r.centerX=l,r.centerY=c):d?(r.action=Oe,r.scale=s,r.centerX=l,r.centerY=c):r.action=Ue}else{const[e]=Array.from(n.values());Object.assign(r,e)}n.forEach(e=>{e.startX=e.endX,e.startY=e.endY}),r.action!==Ue&&this.$emit(rt,r,{cancelable:!1})}$handlePointerUp(e){const{$action:t,$pointers:n}=this;if(!this.disabled&&t!==Ue&&!1!==this.$emit(at,{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=Ue)}}$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(rt,{action:Oe,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;ht(e)&&(ut(e.width)||ut(e.height))&&(({width:a,height:i}=zt({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(Ae));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),ht(e)&&pt(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)})}}Rt.$name=$e,Rt.$version="2.1.0";const Ft=new WeakMap,Ut=["alt","crossorigin","decoding","elementtiming","fetchpriority","loading","referrerpolicy","sizes","src","srcset"];class qt extends Ot{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,this.alt="",this.crossorigin="",this.decoding="",this.elementtiming="",this.fetchpriority="",this.loading="",this.referrerpolicy="",this.sizes="",this.src="",this.srcset=""}set $canvas(e){Ft.set(this,e)}get $canvas(){return Ft.get(this)}static get observedAttributes(){return super.observedAttributes.concat(Ut,["initial-center-size","rotatable","scalable","skewable","translatable"])}attributeChangedCallback(e,t,n){Object.is(n,t)||(super.attributeChangedCallback(e,t,n),Ut.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($e));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),kt(t,it,this.$onCanvasActionStart),kt(t,at,this.$onCanvasActionEnd),kt(t,rt,this.$onCanvasAction)),this.$onLoad=this.$handleLoad.bind(this),kt(e,tt,this.$onLoad),this.$getShadowRoot().appendChild(e)}disconnectedCallback(){const{$image:e,$canvas:t}=this;t&&(this.$onCanvasActionStart&&(wt(t,it,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(wt(t,at,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(wt(t,rt,this.$onCanvasAction),this.$onCanvasAction=null)),e&&this.$onLoad&&(wt(e,tt,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!==Fe||this.rotatable&&this.scalable||(r=this.rotatable?Re:this.scalable?Oe:Ue),r){case De:if(this.translatable){let r=null;e&&(r=e.target.closest(this.$getTagNameOf(Pe))),r||(r=t.querySelector(this.$getTagNameOf(Pe))),r&&r.multiple&&!r.active&&(r=t.querySelector(`${this.$getTagNameOf(Pe)}[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 Re: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 Oe:if(this.scalable)if(e){const t=e.target.closest(this.$getTagNameOf(Pe));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 Fe: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=()=>{wt(t,Ze,i),setTimeout(()=>{e(t)})},i=()=>{wt(t,tt,a),n(r)};St(t,tt,a),St(t,Ze,i)}});return pt(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&&ct(e)&&ct(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&&ct(e)&&ct(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=$t(e),a=Math.cos(r),i=Math.sin(r),[o,s,l,c]=[a,i,-i,a];if(ct(t)&&ct(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,ct(t)&&ct(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=$t(e),r=$t(t);this.$transform(1,Math.tan(r),Math.tan(n),1,0,0)}return this}$translate(e,t=e){return this.translatable&&ct(e)&&ct(t)&&this.$transform(1,0,0,1,e,t),this}$transform(e,t,n,r,a,i){return ct(e)&&ct(t)&&ct(n)&&ct(r)&&ct(a)&&ct(i)?this.$setTransform(Tt(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),ct(e)&&ct(t)&&ct(n)&&ct(r)&&ct(a)&&ct(i))){const o=[...this.$matrix],s=[e,t,n,r,a,i];if(!1===this.$emit(st,{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])}}qt.$name=Ae,qt.$version="2.1.0";const Bt=new WeakMap;class Ht extends Ot{constructor(){super(...arguments),this.$onCanvasActionEnd=null,this.$onCanvasActionStart=null,this.$onSelectionChange=null,this.$style=":host{display:block;height:0;left:0;outline:var(--theme-color) solid 1px;position:relative;top:0;width:0}:host([transparent]){outline-color:transparent}",this.x=0,this.y=0,this.width=0,this.height=0,this.slottable=!1,this.themeColor="rgba(0, 0, 0, 0.65)"}set $canvas(e){Bt.set(this,e)}get $canvas(){return Bt.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["height","width","x","y"])}connectedCallback(){super.connectedCallback();const e=this.closest(this.$getTagNameOf($e));if(e){this.$canvas=e,this.style.position="absolute";const t=e.querySelector(this.$getTagNameOf(Pe));t&&(this.$onCanvasActionStart=e=>{t.hidden&&e.detail.action===Le&&(this.hidden=!1)},this.$onCanvasActionEnd=e=>{t.hidden&&e.detail.action===Le&&(this.hidden=!0)},this.$onSelectionChange=e=>{const{x:n,y:r,width:a,height:i}=e.defaultPrevented?t:e.detail;this.$change(n,r,a,i),(t.hidden||0===n&&0===r&&0===a&&0===i)&&(this.hidden=!0)},kt(e,it,this.$onCanvasActionStart),kt(e,at,this.$onCanvasActionEnd),kt(e,ot,this.$onSelectionChange))}this.$render()}disconnectedCallback(){const{$canvas:e}=this;e&&(this.$onCanvasActionStart&&(wt(e,it,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(wt(e,at,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onSelectionChange&&(wt(e,ot,this.$onSelectionChange),this.$onSelectionChange=null)),super.disconnectedCallback()}$change(e,t,n=this.width,r=this.height){return ct(e)&&ct(t)&&ct(n)&&ct(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:Ce.innerWidth})}}Ht.$name=Me,Ht.$version="2.1.0";class Wt extends Ot{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=Ue,this.plain=!1,this.slottable=!1,this.themeColor="rgba(51, 153, 255, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["action","plain"])}}Wt.$name=Te,Wt.$version="2.1.0";const Vt=new WeakMap;class Kt extends Ot{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){Vt.set(this,e)}get $canvas(){return Vt.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(()=>{ut(n)&&n<=1&&this.$initSelection(!0,!0)});break;case"keyboard":this.$nextTick(()=>{this.$canvas&&(n?this.$onDocumentKeyDown||(this.$onDocumentKeyDown=this.$handleKeyDown.bind(this),kt(this.ownerDocument,et,this.$onDocumentKeyDown)):this.$onDocumentKeyDown&&(wt(this.ownerDocument,et,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(ot,{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($e));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),kt(e,it,this.$onCanvasActionStart),kt(e,at,this.$onCanvasActionEnd),kt(e,rt,this.$onCanvasAction)):this.$render()}disconnectedCallback(){const{$canvas:e}=this;e&&(this.$onCanvasActionStart&&(wt(e,it,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(wt(e,at,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(wt(e,rt,this.$onCanvasAction),this.$onCanvasAction=null)),super.disconnectedCallback()}$getSelections(){let e=[];return this.parentElement&&(e=Array.from(this.parentElement.querySelectorAll(this.$getTagNameOf(Pe)))),e}$initSelection(e=!1,t=!1){const{initialCoverage:n,parentElement:r}=this;if(ut(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;ut(a)&&({width:i,height:o}=zt({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(ot,{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(ot,{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;const i=r?function(e){if("function"==typeof e.composedPath)return e.composedPath().find(ft)||e.target;return e.target}(r):null;if(!a&&this.multiple&&(a=this.$action||(null==i?void 0:i.action),this.$action=a),!a||this.hidden&&a!==Le||this.multiple&&!this.active&&a!==Oe)return;const{width:o,height:s}=this;let l=n.endX-n.startX,c=n.endY-n.startY,{aspectRatio:u}=this;switch(!ut(u)&&r.shiftKey&&(u=ut(o)&&ut(s)?o/s:1),a){case Le:if(0!==l||0!==c){0===l?l=c:0===c&&(c=l);const{$canvas:e}=this,r=Nt(t);(this.multiple&&!this.hidden?this.$createSelection():this).$change(n.startX-r.left,n.startY-r.top,Math.abs(l),Math.abs(c),u),l<0?c<0?a=Ke:c>0&&(a=Qe):l>0&&(c<0?a=Ve:c>0&&(a=Ge)),e&&(e.$action=a)}break;case De:this.movable&&(this.dynamic||this.$actionStartTarget&&this.contains(this.$actionStartTarget))&&this.$move(l,c);break;case Oe:if(r&&this.zoomable&&(this.dynamic||this.contains(r.target))){const e=Nt(t);this.$zoom(n.scale,r.pageX-e.left,r.pageY-e.top)}break;default:this.$resize(a,l,c,u)}}$handleActionEnd(){this.$action="",this.$actionStartTarget=null}$handleKeyDown(e){if(this.hidden||!this.keyboard||this.multiple&&!this.active||e.defaultPrevented)return;const{activeElement:t}=document;if(!t||!["INPUT","TEXTAREA"].includes(t.tagName)&&!["true","plaintext-only"].includes(t.contentEditable))switch(e.key){case"Backspace":e.metaKey&&(e.preventDefault(),this.$removeSelection());break;case"Delete":e.preventDefault(),this.$removeSelection();break;case"ArrowLeft":e.preventDefault(),this.$move(-1,0);break;case"ArrowRight":e.preventDefault(),this.$move(1,0);break;case"ArrowUp":e.preventDefault(),this.$move(0,-1);break;case"ArrowDown":e.preventDefault(),this.$move(0,1);break;case"+":e.preventDefault(),this.$zoom(.1);break;case"-":e.preventDefault(),this.$zoom(-.1)}}$center(){const{parentElement:e}=this;if(!e)return this;const t=(e.offsetWidth-this.width)/2,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=ut(r),{$canvas:i}=this;let{x:o,y:s,width:l,height:c}=this;switch(e){case qe:s+=n,c-=n,c<0&&(e=He,c=-c,s-=c),a&&(o+=(t=n*r)/2,l-=t,l<0&&(l=-l,o-=l));break;case Be:l+=t,l<0&&(e=We,l=-l,o-=l),a&&(s-=(n=t/r)/2,c+=n,c<0&&(c=-c,s-=c));break;case He:c+=n,c<0&&(e=qe,c=-c,s-=c),a&&(o-=(t=n*r)/2,l+=t,l<0&&(l=-l,o-=l));break;case We:o+=t,l-=t,l<0&&(e=Be,l=-l,o-=l),a&&(s+=(n=t/r)/2,c-=n,c<0&&(c=-c,s-=c));break;case Ve:a&&(n=-t/r),s+=n,c-=n,l+=t,l<0&&c<0?(e=Qe,l=-l,c=-c,o-=l,s-=c):l<0?(e=Ke,l=-l,o-=l):c<0&&(e=Ge,c=-c,s-=c);break;case Ke:a&&(n=t/r),o+=t,s+=n,l-=t,c-=n,l<0&&c<0?(e=Ge,l=-l,c=-c,o-=l,s-=c):l<0?(e=Ve,l=-l,o-=l):c<0&&(e=Qe,c=-c,s-=c);break;case Ge:a&&(n=t/r),l+=t,c+=n,l<0&&c<0?(e=Ke,l=-l,c=-c,o-=l,s-=c):l<0?(e=Qe,l=-l,o-=l):c<0&&(e=Ve,c=-c,s-=c);break;case Qe:a&&(n=-t/r),o+=t,l-=t,c+=n,l<0&&c<0?(e=Ve,l=-l,c=-c,o-=l,s-=c):l<0?(e=Ge,l=-l,o-=l):c<0&&(e=Ke,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 ct(t)&&ct(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||!ct(e)||!ct(t)||!ct(n)||!ct(r)||n<0||r<0?this:(ut(a)&&({width:n,height:r}=zt({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(ot,{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(ht(e)&&(ut(e.width)||ut(e.height))&&(({width:a,height:i}=zt({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(Ae));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),ht(e)&&pt(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)})}}Kt.$name=Pe,Kt.$version="2.1.0";class Gt extends Ot{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))}}Gt.$name=ze,Gt.$version="2.1.0";class Qt extends Ot{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"])}}Qt.$name=_e,Qt.$version="2.1.0";const Yt=new WeakMap,Xt=new WeakMap,Jt=new WeakMap,Zt=new WeakMap,en="vertical";class tn extends Ot{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=en,this.selection="",this.slottable=!1}set $image(e){Xt.set(this,e)}get $image(){return Xt.get(this)}set $sourceImage(e){Zt.set(this,e)}get $sourceImage(){return Zt.get(this)}set $canvas(e){Yt.set(this,e)}get $canvas(){return Yt.get(this)}set $selection(e){Jt.set(this,e)}get $selection(){return Jt.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["resize","selection"])}connectedCallback(){var e,t;super.connectedCallback();let n=null;if(n=this.selection?null!==(t=null===(e=function(e){const t=e.getRootNode();switch(t.nodeType){case 1:return t.ownerDocument;case 9:case 11:return t}return null}(this))||void 0===e?void 0:e.querySelector(this.selection))&&void 0!==t?t:null:this.closest(this.$getTagNameOf(Pe)),ft(n)){this.$selection=n,this.$onSelectionChange=this.$handleSelectionChange.bind(this),kt(n,ot,this.$onSelectionChange);const e=n.closest(this.$getTagNameOf($e));if(e){this.$canvas=e;const t=e.querySelector(this.$getTagNameOf(Ae));t&&(this.$sourceImage=t,this.$image=t.cloneNode(!0),this.$getShadowRoot().appendChild(this.$image),this.$onSourceImageLoad=this.$handleSourceImageLoad.bind(this),this.$onSourceImageTransform=this.$handleSourceImageTransform.bind(this),kt(t.$image,tt,this.$onSourceImageLoad),kt(t,st,this.$onSourceImageTransform))}this.$render()}}disconnectedCallback(){const{$selection:e,$sourceImage:t}=this;e&&this.$onSelectionChange&&(wt(e,ot,this.$onSelectionChange),this.$onSelectionChange=null),t&&this.$onSourceImageLoad&&(wt(t.$image,tt,this.$onSourceImageLoad),this.$onSourceImageLoad=null),t&&this.$onSourceImageTransform&&(wt(t,st,this.$onSourceImageTransform),this.$onSourceImageTransform=null),super.disconnectedCallback()}$handleSelectionChange(e){this.$render(e.defaultPrevented?this.$selection: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(()=>{this.$render()}))}$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 en: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&&setTimeout(()=>{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 nn(){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),W(await F({endpoint:`/assets/${e}/variants`,method:"POST",body:{variants:n,async:!1},basePath:K,useJWT:!0}))}catch(n){throw V(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)},createVariantFromBlob:async(e,a,o={})=>{if(!e||!a)return r("ID de asset y blob son requeridos"),null;t(!0),r(null),i(null);try{const t=await async function(e,t,r={}){try{const n=new FormData,a=r.format||"webp",i=`${r.name||"variant"}.${a}`;return n.append("file",t,i),n.append("variant_name",r.name||"variant"),n.append("width",String(r.width||0)),n.append("height",String(r.height||0)),n.append("output_format",r.format||"webp"),W(await F({endpoint:`/assets/${e}/variants/upload`,method:"POST",body:n,basePath:K,isFormData:!0,useJWT:!0}))}catch(n){throw V(n)}}(e,a,{name:o.name||`crop_${Date.now()}`,width:o.width||0,height:o.height||0,format:o.format||"webp"});if(t?.result)return i(t.result),t.result;throw new Error("No se pudo crear la variante")}catch(s){return console.error("Error creating variant from blob:",s),r(s.message||"Error desconocido al crear variante"),null}finally{t(!1)}},loading:e,error:n,createdVariant:a,reset:()=>{r(null),i(null)}}}tn.$name=Ie,tn.$version="2.1.0",Rt.$define(),Qt.$define(),Gt.$define(),Wt.$define(),qt.$define(),Kt.$define(),Ht.$define(),tn.$define();class rn{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 an(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 on=Object.freeze(Object.defineProperty({__proto__:null,default:an,downloadImage:an},Symbol.toStringTag,{value:"Module"}));function sn({image:e,onSave:t,onCancel:n,onDelete:r,onError:a=null,deleting:i=!1,onVariantCreated:o=null,onUpload:s=null,uploading:l=!1,cropperConfig:c=null}){const[d,m]=u.useState(!1),[h,p]=u.useState(null),[f,g]=u.useState(!1),[b,y]=u.useState(!0),[v,x]=u.useState(!0),[w,k]=u.useState({x:20,y:100}),[S,C]=u.useState(!1),[j,N]=u.useState({x:0,y:0}),[E,$]=u.useState(!1),[_,z]=u.useState(!0),[T,P]=u.useState(!1),[M,I]=u.useState({horizontal:!1,vertical:!1}),[L,D]=u.useState(!1),[O,R]=u.useState(!1),[F,U]=u.useState(!1),[q,B]=u.useState(!1),[H]=u.useState(()=>{if(!e||!e.filename)return"image";const[t]=e.filename.split(".");return t}),W=u.useMemo(()=>{if(c)return{mandatoryCrops:c.mandatoryCrops||[],allowCustomCrops:!1!==c.allowAdditionalCrops,showDimensionInputs:!0===c.showDimensionInputs,maxCrops:c.maxCrops||null};const e=window.limboCore?.config?.getGlobal()||{};return{mandatoryCrops:e.cropper?.mandatoryCrops||[],allowCustomCrops:!1!==e.cropper?.allowCustomCrops,showDimensionInputs:!0===e.cropper?.showDimensionInputs,maxCrops:e.cropper?.maxCrops||null}},[c]),[V,K]=u.useState(()=>W.mandatoryCrops.length>0?W.mandatoryCrops.map((e,t)=>({id:`crop-${t}`,label:e.label,width:e.width,height:e.height,required:!1!==e.required,isCustom:!1,confirmed:!1,lockDimensions:!(!e.width||!e.height),savedState:null})):[{id:"crop-default-0",label:H,width:e.width||1920,height:e.height||1080,required:!1,isCustom:!0,confirmed:!1,savedState:null}]),[G,Q]=u.useState(0),Y=V[G],X=u.useMemo(()=>Y&&Y.width&&Y.height?Y.width/Y.height:"",[Y]),Z=u.useMemo(()=>{const e=50;if(!X||""===X)return{minWidth:e,minHeight:e};if(X>=1){return{minWidth:e,minHeight:e/X}}return{minWidth:e*X,minHeight:e}},[X]),[ee,te]=u.useState(!1),[ne,re]=u.useState([]),[ae,ie]=u.useState(null),oe=window.limboCore?.accessibilityManager,{createVariantFromBlob:se,loading:le,error:ce}=nn(),de=((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 rn(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]),u.useEffect(()=>{i.current&&d&&i.current.selection.setAspectRatio(b.aspectRatio)},[b.aspectRatio,d]),u.useEffect(()=>{i.current&&d&&i.current.canvas.setBackground(b.shade)},[b.shade,d]);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:X||null,showGrid:b,shade:v,initialCoverage:.5,paspartuFactor:.85}),{refs:me,state:he,transform:pe,selection:fe,utils:ge}=de,{canvasRef:be,imageRef:ye,selectionRef:ve}=me,{cropData:xe,imageInfo:we,canExport:ke,transformVersion:Se}=he,Ce=u.useMemo(()=>we||{naturalWidth:e.width||1920,naturalHeight:e.height||1080,currentWidth:e.width||1920,currentHeight:e.height||1080},[we,e.width,e.height]),je=u.useCallback(()=>y(e=>!e),[]),Ne=u.useCallback(()=>x(e=>!e),[]),Ee=u.useCallback(()=>R(e=>!e),[]),$e=u.useCallback(()=>U(e=>!e),[]),_e=u.useCallback(()=>B(e=>!e),[]),ze=u.useCallback(()=>pe.center(),[pe]),Te=u.useCallback(()=>fe.center(),[fe]),Ae=u.useCallback(()=>fe.reset(),[fe]),Pe=u.useCallback((e,t)=>pe.move(e,t),[pe]),Me=u.useCallback(e=>pe.zoom(e),[pe]),Ie=u.useCallback(e=>pe.rotate(e),[pe]),Le=u.useCallback(e=>{fe.setCoverage(e)},[fe]),De=u.useCallback(()=>{I(e=>{const t=!e.horizontal;return pe.flipHorizontal(),{...e,horizontal:t}})},[pe]),Oe=u.useCallback(()=>{I(e=>{const t=!e.vertical;return pe.flipVertical(),{...e,vertical:t}})},[pe]),Re=u.useCallback(()=>{if(!de.manager||!he.isReady)return null;try{const e=xe?{...xe}:null;let t=null;if(ve.current){const e=ve.current;t={x:e.x??0,y:e.y??0,width:e.width??0,height:e.height??0}}let n=null;if(ye.current){const e=ye.current.$getTransform?.();e&&Array.isArray(e)&&(n=[...e])}const r={cropData:e,selectorState:t,imageTransform:n,flipState:{horizontal:M.horizontal,vertical:M.vertical}};return console.log(`[CropperView] 💾 Guardando estado del crop ${G}:`,r),K(e=>e.map((e,t)=>t===G?{...e,savedState:r}:e)),r}catch(e){return console.warn("Error saving crop state:",e),null}},[de.manager,he.isReady,xe,M,G,ye,ve]),Fe=u.useCallback(e=>{const t=V[e];if(!t||!t.savedState)return console.log(`[CropperView] ℹ️ No hay estado guardado para crop ${e}, centrando...`),void setTimeout(()=>{ze(),setTimeout(()=>Te(),100)},100);if(de.manager&&he.isReady)try{const{savedState:n}=t;if(console.log(`[CropperView] ♻️ Restaurando estado del crop ${e}:`,n),n.imageTransform&&ye.current&&Array.isArray(n.imageTransform)&&setTimeout(()=>{if(ye.current&&ye.current.$setTransform){const[e,t,r,a,i,o]=n.imageTransform;ye.current.$setTransform(e,t,r,a,i,o),console.log(`[CropperView] ✅ Imagen restaurada: transform(${e.toFixed(2)}, ${t.toFixed(2)}, ${r.toFixed(2)}, ${a.toFixed(2)}, ${i.toFixed(0)}, ${o.toFixed(0)})`)}},100),n.selectorState&&ve.current){const{x:e,y:t,width:r,height:a}=n.selectorState;setTimeout(()=>{ve.current&&(ve.current.x=e,ve.current.y=t,ve.current.width=r,ve.current.height=a,ve.current.$render&&ve.current.$render(),console.log(`[CropperView] ✅ Selector restaurado: ${r}×${a} en (${e}, ${t})`))},150)}n.flipState&&I({horizontal:n.flipState.horizontal??!1,vertical:n.flipState.vertical??!1}),console.log("[CropperView] ✨ Estado restaurado completamente")}catch(n){console.error("Error restoring crop state:",n),setTimeout(()=>{ze(),setTimeout(()=>Te(),100)},100)}else console.warn("Cropper not ready for state restoration")},[V,de.manager,he.isReady,ze,Te,ve,ye]),Ue=u.useCallback(()=>{for(let e=0;e<V.length;e++){const t=V[e];if(!t.label||""===t.label.trim())return e}return-1},[V]),qe=u.useCallback(async e=>{e!==G&&(P(!0),Re(),await new Promise(e=>setTimeout(e,100)),Q(e),await new Promise(e=>setTimeout(e,250)),Fe(e),await new Promise(e=>setTimeout(e,200)),P(!1))},[G,Re,Fe]),Be=u.useCallback(()=>{if(!W.allowCustomCrops)return void alert("No se pueden añadir recortes personalizados en este modo.");const t={id:`crop-custom-${Date.now()}`,label:`Recorte ${V.length+1}`,width:e.width||1920,height:e.height||1080,required:!1,isCustom:!0,confirmed:!1,savedState:null};K(e=>[...e,t]),oe?.announce(`Nuevo recorte personalizado añadido: ${t.label}. Selecciónalo para editarlo.`)},[W.allowCustomCrops,V.length,e.width,e.height,oe]),He=u.useCallback((e,t)=>{const n=parseInt(t,10);""===t||isNaN(n)||K(t=>t.map((t,r)=>r===G?{...t,[e]:n}:t))},[G]),We=u.useCallback(e=>{const t=Y[e];let n=100;if(be.current&&we){const e=be.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&&K(t=>t.map((t,n)=>n===G?{...t,[e]:r}:t));const a={...Y,[e]:r},i=a.width/a.height,o=fe.getData?.();fe.setAspectRatio(i),o&&void 0!==o.x&&setTimeout(()=>{fe.set?.(o.x,o.y,o.width,o.height)},50)},[G,Y,fe,be,we]),Ve=u.useCallback(e=>{K(t=>t.map((t,n)=>n===G?{...t,label:e}:t))},[G]),Ke=u.useCallback((e,t=null)=>{t=t||V[e].label;if(!window.confirm(`¿Estás seguro de que deseas eliminar "${t||"este recorte"}"? Esta acción también eliminará todos sus recortes.`))return;const n=V[e];if(n.required)alert("No se puede eliminar un recorte obligatorio.");else if(1!==V.length){if(K(t=>t.filter((t,n)=>n!==e)),e===G){const t=Math.max(0,e-1);Q(t)}else e<G&&Q(e=>e-1);oe?.announce(`Recorte ${n.label} eliminado`)}else alert("Debe haber al menos un recorte.")},[V,G,oe]),Ge=u.useCallback(async()=>{if(!ke)return null;try{const t=await fe.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}},[ke,e.mime_type,fe]),Qe=u.useCallback(async()=>{if(d)return m(!1),p(null),void g(!1);if(ke){m(!0),g(!0);try{const e=await Ge();e?p(e):(m(!1),alert("No se puede exportar el recorte por restricciones de CORS en la imagen original."))}finally{g(!1)}}else alert("No se puede exportar el recorte por restricciones de CORS en la imagen original.")},[ke,Ge,d]),Ye=u.useCallback(e=>{e.target.closest(".limbo-preview-modal-header")&&(C(!0),N({x:e.clientX-w.x,y:e.clientY-w.y}))},[w]),Xe=u.useCallback(e=>{S&&(e.preventDefault(),k({x:e.clientX-j.x,y:e.clientY-j.y}))},[S,j]),Je=u.useCallback(()=>{C(!1)},[]),Ze=u.useCallback(e=>{if(!e.target.closest(".limbo-preview-modal-header"))return;const t=e.touches[0];C(!0),N({x:t.clientX-w.x,y:t.clientY-w.y})},[w]),et=u.useCallback(e=>{if(!S)return;e.preventDefault();const t=e.touches[0];k({x:t.clientX-j.x,y:t.clientY-j.y})},[S,j]),tt=u.useCallback(()=>{C(!1)},[]);u.useEffect(()=>{if(S)return document.addEventListener("mousemove",Xe),document.addEventListener("mouseup",Je),document.addEventListener("touchmove",et,{passive:!1}),document.addEventListener("touchend",tt),()=>{document.removeEventListener("mousemove",Xe),document.removeEventListener("mouseup",Je),document.removeEventListener("touchmove",et),document.removeEventListener("touchend",tt)}},[S,Xe,Je,et,tt]),u.useEffect(()=>{if(!E)return;const e=e=>{"Escape"===e.key&&$(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[E]);const nt=u.useCallback(async(t,n=null)=>{const r=V[t];if(!r)throw new Error(`Crop ${t} no encontrado`);if(!r.savedState&&t!==G)throw new Error(`El recorte "${r.label}" aún no ha sido configurado`);const a={index:G,imageTransform:ye.current?.$getTransform?.(),selectorState:ve.current?{x:ve.current.x,y:ve.current.y,width:ve.current.width,height:ve.current.height}:null};try{if(t!==G&&r.savedState){if(console.log(`[CropperView] 🔄 Restaurando temporalmente crop ${t} para guardado...`),r.savedState.imageTransform&&ye.current?.$setTransform){const[e,t,n,a,i,o]=r.savedState.imageTransform;ye.current.$setTransform(e,t,n,a,i,o)}if(r.savedState.selectorState&&ve.current){const{x:e,y:t,width:n,height:a}=r.savedState.selectorState;ve.current.x=e,ve.current.y=t,ve.current.width=n,ve.current.height=a,ve.current.$render?.()}await new Promise(e=>setTimeout(e,100))}const a=Math.min(r.width,5e3),i=Math.min(r.height,5e3),s=await fe.toCanvas({width:a,height:i,imageSmoothingEnabled:!0,imageSmoothingQuality:"high"});if(!s)throw new Error(`No se pudo generar el canvas para "${r.label}"`);const l=globalThis.downloadFormat||"webp",c="webp"===l?"image/webp":"png"===l?"image/png":"image/jpeg",u=.9,d=await new Promise((e,t)=>{s.toBlob(n=>{n?e(n):t(new Error("No se pudo convertir el canvas a blob"))},c,u)});console.log("[CropperView] Canvas convertido a blob:",{size:d.size,type:d.type,dimensions:`${a}x${i}`});const m=`${r.label||"crop"}_${a}_${i}`,h=n||e.id,p=await se(h,d,{name:m,width:a,height:i,format:l});if(p)return oe?.announceSuccess(`Recorte creado: ${m}`),o?.(h,p),p;throw new Error("No se pudo crear la variante")}finally{if(t!==G&&a.imageTransform&&ye.current?.$setTransform){console.log(`[CropperView] ↩️ Restaurando estado original del crop ${a.index}...`);const[e,t,n,r,i,o]=a.imageTransform;if(ye.current.$setTransform(e,t,n,r,i,o),a.selectorState&&ve.current){const{x:e,y:t,width:n,height:r}=a.selectorState;ve.current.x=e,ve.current.y=t,ve.current.width=n,ve.current.height=r,ve.current.$render?.()}}}},[V,G,fe,se,e.id,o,oe,ye,ve]),rt=u.useCallback(async()=>{if(!ke){const e="No se puede exportar el recorte por restricciones de CORS en la imagen original.";return oe?.announceError(e),void alert(e)}if(!he.isReady){const e="El cropper aún no está inicializado. Espera un momento e inténtalo de nuevo.";return oe?.announceError(e),void alert(e)}Re(),oe?.announce("Creando recorte de la imagen");try{let n=e.id,r=null;if(e.file&&s){oe?.announce("Subiendo imagen...");const t=await s(e.file);if(!t||!t.id)throw new Error("No se pudo subir la imagen al servidor");n=t.id,r=t,oe?.announceSuccess("Imagen subida correctamente")}const a=await nt(G,n);a&&t(r?{crops:[a],asset:r}:a)}catch(n){console.warn("Error creating crop variant:",n);const e=n.message||"No se pudo crear el recorte. Inténtalo de nuevo.";oe?.announceError(e),alert(e),a?.(n)}},[ke,he.isReady,oe,Re,nt,G,t,a,e.file,e.id,s]),at=u.useCallback(async n=>{Re(),oe?.announce(`Guardando ${n.length} recortes...`);try{let a=e.id,i=null;if(e.file&&s){oe?.announce("Subiendo imagen...");const t=await s(e.file);if(!t||!t.id)throw new Error("No se pudo subir la imagen al servidor");a=t.id,i=t,oe?.announceSuccess("Imagen subida correctamente")}const o=[],l=[];for(const e of n)try{const t=await nt(e,a);t&&o.push(t)}catch(r){l.push({crop:V[e]?.label||`Crop ${e}`,error:r.message})}if(o.length>0&&(oe?.announceSuccess(`${o.length} recorte(s) guardado(s) correctamente`),t(i?{crops:o,asset:i}:o)),l.length>0){const e=`Errores al guardar algunos recortes:\n${l.map(e=>`- ${e.crop}: ${e.error}`).join("\n")}`;oe?.announceError(e),alert(e)}}catch(r){const e=r.message||"Error al procesar los recortes";oe?.announceError(e),alert(e),a?.(r)}},[Re,nt,V,oe,t,e.file,e.id,s,a]),it=u.useCallback(async()=>{const e=Ue();if(-1!==e){const t=V[e];return alert(`El recorte "${t.label||t||"(sin nombre)"}" debe tener un nombre válido.`),void Q(e)}if(V.length>1){ie("save");const e=V.map((e,t)=>({crop:e,index:t})).filter(({crop:e,index:t})=>e.required||e.savedState||t===G).map(({index:e})=>e);return re(e),void te(!0)}await rt()},[Ue,V,rt,G]),ot=u.useCallback(async t=>{const n=V[t];if(!n)throw new Error(`Crop ${t} no encontrado`);if(!n.savedState&&t!==G)throw new Error(`El recorte "${n.label}" aún no ha sido configurado`);const r={index:G,imageTransform:ye.current?.$getTransform?.(),selectorState:ve.current?{x:ve.current.x,y:ve.current.y,width:ve.current.width,height:ve.current.height}:null};try{if(t!==G&&n.savedState){if(console.log(`[CropperView] 🔄 Restaurando temporalmente crop ${t} para descarga...`),n.savedState.imageTransform&&ye.current?.$setTransform){const[e,t,r,a,i,o]=n.savedState.imageTransform;ye.current.$setTransform(e,t,r,a,i,o)}if(n.savedState.selectorState&&ve.current){const{x:e,y:t,width:r,height:a}=n.savedState.selectorState;ve.current.x=e,ve.current.y=t,ve.current.width=r,ve.current.height=a,ve.current.$render?.()}await new Promise(e=>setTimeout(e,100))}const r=await fe.toCanvas({width:n.width,height:n.height,imageSmoothingEnabled:!0,imageSmoothingQuality:"high"});if(!r)throw new Error(`No se pudo generar el canvas para "${n.label}"`);const a=r.toDataURL(`image/${globalThis.downloadFormat||e.mime_type.split("/")[1]||"webp"}`,.9),i=`${(n.label||"crop").replace(/\.[^/.]+$/,"").replace(/\s+/g,"-").trim()}_${n.width}_${n.height}`;return await an(a,i,{accessibilityManager:oe,onSuccess:e=>{console.log(`✅ Descargado: ${e}`)},onError:e=>{throw new Error(`Error al descargar "${n.label}": ${e.message}`)}}),{crop:n.label,filename:i}}finally{if(t!==G&&r.imageTransform&&ye.current?.$setTransform){console.log(`[CropperView] ↩️ Restaurando estado original del crop ${r.index}...`);const[e,t,n,a,i,o]=r.imageTransform;if(ye.current.$setTransform(e,t,n,a,i,o),r.selectorState&&ve.current){const{x:e,y:t,width:n,height:a}=r.selectorState;ve.current.x=e,ve.current.y=t,ve.current.width=n,ve.current.height=a,ve.current.$render?.()}}}},[V,G,fe,e.mime_type,oe,ye,ve]),st=u.useCallback(async e=>{Re(),oe?.announce(`Descargando ${e.length} recortes...`);const t=[],n=[];for(const a of e)try{const e=await ot(a);e&&t.push(e)}catch(r){n.push({crop:V[a]?.label||`Crop ${a}`,error:r.message})}if(t.length>0&&oe?.announceSuccess(`${t.length} recorte(s) descargado(s) correctamente`),n.length>0){const e=`Errores al descargar algunos recortes:\n${n.map(e=>`- ${e.crop}: ${e.error}`).join("\n")}`;oe?.announceError(e),alert(e)}},[Re,ot,V,oe]),lt=u.useCallback(async()=>{if(!ke){const e="No se puede descargar el recorte por restricciones de CORS en la imagen original.";return oe?.announceError(e),void alert(e)}Re(),oe?.announce("Preparando descarga del recorte");try{await ot(G),oe?.announceSuccess("Recorte descargado correctamente")}catch(e){console.error("Error downloading crop:",e);const t=e.message||"Error al descargar el recorte";oe?.announceError(t),alert(t)}},[ke,oe,Re,ot,G]),ct=u.useCallback(async()=>{const e=Ue();if(-1!==e){const t=V[e];return alert(`El recorte "${t.label||t||"(sin nombre)"}" debe tener un nombre válido.`),void Q(e)}if(V.length>1){ie("download");const e=V.map((e,t)=>({crop:e,index:t})).filter(({crop:e,index:t})=>e.savedState||t===G).map(({index:e})=>e);return re(e),void te(!0)}await lt()},[Ue,V,lt,G]),ut=u.useCallback(async()=>{if(e.file&&s)try{oe?.announce("Subiendo imagen original...");const n=await s(e.file);if(!n||!n.id)throw new Error("No se pudo subir la imagen al servidor");oe?.announceSuccess("Imagen guardada correctamente"),t({asset:n,crops:[]})}catch(r){console.error("Error guardando imagen original:",r);const e=r.message||"No se pudo guardar la imagen. Inténtalo de nuevo.";oe?.announceError(e),alert(e),a?.(r)}else n()},[e.file,s,n,t,a,oe]);return u.useEffect(()=>{m(!1),p(null)},[e]),u.useEffect(()=>{de.manager&&he.isReady&&_&&(console.log("[CropperView] Carga inicial completada, centrando imagen y selector..."),setTimeout(()=>{ze(),setTimeout(()=>{Te(),z(!1),console.log("[CropperView] Carga inicial finalizada")},100)},50))},[de.manager,he.isReady,_,ze,Te]),u.useEffect(()=>{de.manager&&he.isReady&&(X&&fe.setAspectRatio(X),ge.setBackground(v))},[X,v,de.manager,he.isReady,fe,ge]),u.useEffect(()=>{if(!we||!he.isReady||W.mandatoryCrops.length>0)return;const e=V[0];if(e&&"crop-default-0"===e.id&&(1920===e.width||1080===e.height)){const t=Math.min(we.naturalWidth,5e3),n=Math.min(we.naturalHeight,5e3);K([{...e,width:t,height:n}]),console.log(`[CropperView] Crop por defecto actualizado a ${t}×${n}px`)}},[we,he.isReady,W.mandatoryCrops.length,V]),u.useEffect(()=>{if(!d||!ke)return;const e=setTimeout(async()=>{g(e=>!h&&!e||e);try{const e=await Ge();e&&p(e)}finally{g(!1)}},300);return()=>{clearTimeout(e),g(!1)}},[xe,Se,d,ke,Ge,X,M,h]),u.useEffect(()=>{const e=be.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)}},[be]),e?A.jsxs("div",{className:"limbo-cropper-view px-2 border-2 border-gray-200/50 rounded-lg max-w-7xl mx-auto w-full min-w-full h-full min-h-full flex flex-col",children:[A.jsxs("div",{className:"limbo-cropper-header flex flex-row justify-between items-start flex-wrap mx-2 py-2 border-b border-gray-200 bg-white z-10 shrink-0 lg:gap-2",children:[A.jsxs("div",{className:"flex-1 min-w-fit space-y-2 max-w-fit",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("h2",{className:"text-lg sm:text-xl font-extrabold text-gray-800",children:"Generar recortes"}),V.length>1&&A.jsx("span",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 text-xs font-semibold rounded",children:Y.label})]}),A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("label",{className:"text-xs text-gray-500 whitespace-nowrap w-fit",children:"Nombre:"}),A.jsx("div",{className:"",children:H+"."+(globalThis.downloadFormat||e.mime_type.split("/")[1]||"webp")})]})]}),A.jsxs("div",{className:"flex flex-row self-end gap-2 w-full max-w-fit sm:w-auto flex-wrap",children:[A.jsxs("button",{onClick:n,disabled:le,className:"flex flex-row items-center gap-1 self-end w-full max-w-fit sm:w-auto px-3 cursor-pointer py-1.5 text-sm rounded bg-neutral-gray-500 hover:bg-neutral-gray-700 transition-colors text-white disabled:opacity-50 disabled:cursor-not-allowed","aria-label":"Cancelar y volver",title:"Cancelar y volver",children:[A.jsx("span",{className:"icon icon-arrow-left-white icon--sm m-0 p-0"})," ","Cancelar"]}),r&&A.jsxs("button",{onClick:()=>r(e),disabled:i|le,className:"flex flex-row items-center gap-1 self-end w-full max-w-fit sm:w-auto px-3 cursor-pointer py-1.5 text-sm rounded bg-red-800 hover:bg-red-1000 transition-colors text-white disabled:opacity-50 disabled:cursor-not-allowed","aria-label":`Eliminar imagen ${e.filename}`,title:`Eliminar imagen ${e.filename}`,children:[A.jsx("span",{className:"icon icon-close-small-white icon--sm m-0 p-0"}),i?"Eliminando...":"Eliminar"]})]})]}),A.jsxs("div",{className:"limbo-cropper-status bg-white border-gray-100 py-0 pb-0 flex-shrink-0",children:[ce&&A.jsxs("div",{className:"alert alert-danger mb-2 text-sm",role:"alert",children:[A.jsx("strong",{children:"Error:"})," ",ce]}),we&&A.jsxs("div",{className:"alert alert-secondary mb-2 text-sm",role:"status",children:[A.jsx("strong",{children:"Original:"})," ",we.naturalWidth," ×"," ",we.naturalHeight," px",we.currentWidth!==we.naturalWidth&&A.jsxs("span",{className:"ml-2 sm:ml-3 text-xs block sm:inline",children:["(Mostrada: ",Math.round(we.currentWidth)," ×"," ",Math.round(we.currentHeight)," px)"]})]}),!ke&&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 py-2 mx-2 shrink-0 sticky top-0 z-10 mb-1",children:[A.jsxs("div",{className:"flex items-center justify-between mb-2",children:[A.jsxs("h3",{className:"text-sm font-semibold text-gray-700",children:["Recortes ",V.length>1&&`(${V.length})`]}),W.allowCustomCrops&&A.jsxs("button",{onClick:Be,disabled:le,className:"text-xs cursor-pointer px-2 py-1 bg-brand-blue-50 hover:bg-brand-blue-200 text-brand-blue-1000 rounded border border-brand-blue-200 transition-colors flex items-center gap-1",title:"Añadir recorte personalizado",children:[A.jsx("span",{className:"icon icon-add icon--sm",style:{filter:"var(--icon-blue)"}}),"Añadir recorte"]})]}),A.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-1.5 max-h-48 overflow-y-auto",children:V.map((e,t)=>{const n=e.savedState||t===G;return A.jsxs("label",{className:"h-fit flex flex-col p-1.5 rounded border cursor-pointer transition-colors min-h-17.5 w-full "+(G===t?"bg-blue-50 border-blue-300":n?"bg-gray-50 border-gray-200 hover:bg-gray-100":"bg-orange-50 border-orange-300 hover:bg-orange-100"),children:[A.jsx("input",{type:"radio",name:"active-crop",checked:G===t,onChange:()=>qe(t),disabled:le,className:"hidden"}),A.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[A.jsx("div",{className:"flex-1 min-w-0",children:A.jsxs("div",{className:"flex flex-wrap items-center gap-1 min-h-",children:[G!==t||e.required?A.jsx("span",{className:"text-xs font-medium text-gray-800 limbo-truncate",children:e.label}):A.jsx("input",{type:"text",value:e.label,onChange:e=>Ve(e.target.value),disabled:le,className:"w-full text-xs px-1 py-0.5 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500 min-h-5",placeholder:"Nombre",maxLength:25,onClick:e=>e.stopPropagation()}),e.required&&A.jsx("span",{className:"text-[10px] px-1 py-0.5 bg-red-200 text-red-1000 rounded whitespace-nowrap truncate",children:"Obligatorio"})]})}),!e.required&&V.length>1&&A.jsx("button",{onClick:n=>{n.preventDefault(),n.stopPropagation(),Ke(t,e.label)},className:"shrink-0 hover:bg-red-500/70 text-red-1000 p-1 rounded max-h-fit aspect-square cursor-pointer flex",title:"Eliminar",children:A.jsx("span",{className:"icon icon-close-small icon--xs"})})]}),A.jsx("div",{className:"flex items-center gap-1 mt-auto",children:G===t?A.jsxs(A.Fragment,{children:[A.jsx("input",{type:"number",min:"100",max:"5000",value:e.width,onChange:e=>He("width",e.target.value),onBlur:()=>We("width"),disabled:le||e.lockDimensions,className:"max-h-fit flex-1 text-xs px-1 py-0.5 border rounded focus:outline-none focus:ring-1 focus:ring-blue-500 "+(e.lockDimensions?"border-gray-200 bg-gray-100 text-gray-500 cursor-not-allowed":"border-gray-300"),placeholder:"W",onClick:e=>e.stopPropagation(),title:e.lockDimensions?"Dimensiones bloqueadas (recorte obligatorio)":"Ancho en píxeles"}),A.jsx("span",{className:"text-gray-400 text-xs",children:"×"}),A.jsx("input",{type:"number",min:"100",max:"5000",value:e.height,onChange:e=>He("height",e.target.value),onBlur:()=>We("height"),disabled:le||e.lockDimensions,className:"max-h-fit flex-1 text-xs px-1 py-0.5 border rounded focus:outline-none focus:ring-1 focus:ring-blue-500 "+(e.lockDimensions?"border-gray-200 bg-gray-100 text-gray-500 cursor-not-allowed":"border-gray-300"),placeholder:"H",onClick:e=>e.stopPropagation(),title:e.lockDimensions?"Dimensiones bloqueadas (recorte obligatorio)":"Alto en píxeles"})]}):A.jsxs("span",{className:"text-xs text-gray-500",children:[e.width," × ",e.height," px"]})}),!n&&A.jsx("div",{className:"text-xs px-1 py-0.5 bg-orange-300 text-neutral-gray-25 text-shadow-xs font-semibold rounded text-center mt-1",children:"Sin configurar"})]},e.id)})})]})]}),A.jsxs("div",{className:"flex flex-col lg:flex-row flex-1 w-full overflow-hidden lg:max-h-130 mx-2 py-1",children:[A.jsx("div",{className:"relative flex-1 lg:flex-2 h-full shrink-0 grow-1 order-0 min-h-100 lg:min-h-130",children:A.jsxs("div",{className:"absolute inset-0 bg-white rounded-lg border-2 border-gray-200 overflow-hidden",children:[A.jsx(ue,{show:_,message:"Cargando recortador..."}),A.jsx(ue,{show:T,message:`Cambiando a: ${V[G]?.label||"recorte"}...`}),A.jsxs("cropper-canvas",{ref:be,style:{width:"100%",height:"100%",display:"block"},background:!!v||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:ye,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:ve,"initial-coverage":"0.5",movable:!0,resizable:!0,keyboard:"true",action:"move",style:{cursor:"move",minWidth:`${Z.minWidth}px`,minHeight:`${Z.minHeight}px`},"data-prevent-delete":"true",tabindex:"-1",children:[b&&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:"w-full lg:max-w-80 mt-2 lg:my-0 overflow-y-auto bg-white border-t lg:border-t-0 lg:border-l border-gray-200 flex-shrink-0",children:A.jsxs("div",{className:"h-full mt-2 lg:my-0 limbo-me-2 lg:mx-2 space-y-2 grid grid-cols-2 md:grid-cols-3 flex-wrap md:flex-nowrap items-start flex-row gap-2 lg:gap-0 lg:block",children:[A.jsxs("div",{className:"bg-white rounded border w-full border-gray-200 mb-2",children:[A.jsx("button",{onClick:_e,className:"hidden sm:block w-full p-2 mb-05 cursor-pointer hover:bg-neutral-gray-050/50 transition-colors rounded-t-sm","aria-expanded":q,"aria-label":"Mostrar/ocultar opciones de visualizació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 ${q?"icon-chevron-up":"icon-chevron-down"} text-center icon--xs`})})]})}),A.jsxs("div",{className:"p-2 space-y-2 justify-items-stretch static "+(q?"block":"sm:hidden"),children:[A.jsx("div",{className:"mb-3 block",children:A.jsxs("div",{className:"grid grid-cols-5 gap-1 content-center h-fit mx-auto",children:[A.jsx("button",{onClick:()=>Me(-.2),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Alejar",disabled:le,"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:()=>Pe(-10,-10),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Mover arriba-izquierda",disabled:le,"aria-label":"Mover imagen hacia arriba-izquierda",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-up-blue icon--md -rotate-45"})})}),A.jsx("button",{onClick:()=>Pe(0,-10),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Mover arriba",disabled:le,"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 icon--md"})})}),A.jsx("button",{onClick:()=>Pe(10,-10),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Mover arriba-derecha",disabled:le,"aria-label":"Mover imagen hacia arriba-derecha",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-up-blue icon--md rotate-45"})})}),A.jsx("button",{onClick:()=>Me(.2),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Acercar 20%",disabled:le,"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.jsx("button",{onClick:()=>Ie(-45),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Rotar -45°",disabled:le,"aria-label":"Rotar imagen 45 grados a la izquierda",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"text-brand-blue-1000 font-medium",children:"-45°"})})}),A.jsx("button",{onClick:()=>Pe(-10,0),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Mover izquierda",disabled:le,"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:ze,className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Centrar y ajustar imagen",disabled:le,"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:()=>Pe(10,0),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Mover derecha",disabled:le,"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("button",{onClick:()=>Ie(45),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Rotar +45°",disabled:le,"aria-label":"Rotar imagen 45 grados a la derecha",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"text-brand-blue-1000 font-medium",children:"+45°"})})}),A.jsx("button",{onClick:De,className:"px-0 rounded cursor-pointer transition-colors text-sm aspect-square "+(M.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 "+(M.horizontal?"(activo)":""),disabled:le,"aria-label":"Voltear imagen horizontalmente","aria-pressed":M.horizontal,children:A.jsx("div",{className:"flex items-center justify-center gap-2",children:A.jsx("span",{className:"icon icon-arrow-left-right-blue border border-brand-blue-1000 rounded"})})}),A.jsx("button",{onClick:()=>Pe(-10,10),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Mover abajo-izquierda",disabled:le,"aria-label":"Mover imagen hacia abajo-izquierda",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-up-blue icon--md -rotate-145"})})}),A.jsx("button",{onClick:()=>Pe(0,10),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Mover abajo",disabled:le,"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("button",{onClick:()=>Pe(10,10),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Mover abajo-derecha",disabled:le,"aria-label":"Mover imagen hacia abajo-derecha",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-up-blue icon--md rotate-145"})})}),A.jsx("button",{onClick:Oe,className:"px-0 rounded cursor-pointer transition-colors aspect-square text-sm "+(M.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 "+(M.vertical?"(activo)":""),disabled:le,"aria-label":"Voltear imagen verticalmente","aria-pressed":M.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("div",{className:"flex flex-col gap-2",children:A.jsx("button",{onClick:()=>{pe.reset(),I({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:le,"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-white rounded border border-gray-200 w-full"+(F?"":" bg-neutral-gray-50/50"),children:[A.jsx("button",{onClick:$e,className:"hidden sm:block w-full cursor-pointer hover:bg-neutral-gray-050/50 p-2 mb-05 transition-colors rounded-t-sm","aria-expanded":F,"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 ${F?"icon-chevron-up":"icon-chevron-down"} text-center icon--xs`})})]})}),A.jsxs("div",{className:"p-2 space-y-2 justify-items-stretch static "+(F?"block":"sm:hidden"),children:[A.jsx("div",{children:A.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[A.jsx("button",{onClick:()=>Le(.5),className:"p-1 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",disabled:le,"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:()=>Le(.7),className:"p-1 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",disabled:le,"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:()=>Le(.9),className:"p-1 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",disabled:le,"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:()=>Le(1),className:"p-1 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",disabled:le,"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:Te,className:"w-full p-1 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:le,"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:Ae,className:"w-full p-1 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:le,"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 limbo-lign-[middle!important] "})," ","Reset selección"]})})})]})]})]}),A.jsxs("div",{className:"bg-white rounded border border-gray-200 w-full",children:[A.jsx("button",{onClick:Ee,className:"hidden sm:block w-full cursor-pointer hover:bg-neutral-gray-050/50 transition-colors rounded-t-sm mb-05 p-2","aria-expanded":O,"aria-label":"Mostrar/ocultar opciones de visualizació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 ${O?"icon-chevron-up":"icon-chevron-down"} text-center icon--xs`})})]})}),A.jsxs("div",{className:"py-2 space-y-2 justify-items-stretch static "+(O?"block":"sm:hidden"),children:[A.jsxs("button",{onClick:je,className:"w-auto flex cursor-pointer items-center justify-between mx-2 p-1 rounded transition-colors "+(b?"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:le,"aria-pressed":b,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 limbo-me-1"})," ","Cuadrícula"]}),A.jsx("span",{className:"text-xs",children:b?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:Ne,className:"w-auto flex cursor-pointer items-center justify-between mx-2 p-1 rounded transition-colors "+(v?"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:le,"aria-pressed":v,"aria-label":"Activar/desactivar sombreado",children:[A.jsxs("span",{className:"text-sm flex items-center",children:[A.jsx("span",{className:"icon icon-comparison-blue limbo-me-1"})," ","Tablero"]}),A.jsx("span",{className:"text-xs",children:v?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:"flex justify-between shrink-0 border-t border-gray-200 bg-white mx-2 mt-1 py-2 lg:gap-0",children:[A.jsxs("button",{onClick:()=>D(!0),className:"text-nowrap block cursor-pointer lg:flex items-center gap-2 px-2 py-1 bg-gradient-to-br from-brand-blue-50 to-green-50 hover:from-brand-blue-100 hover:to-green-100 border border-blue-200 rounded-lg shadow-sm transition-colors","aria-label":"Abrir guía de uso",children:[A.jsx("span",{className:"icon icon-lightbulb text-yellow-500"}),A.jsx("span",{className:"text-sm font-semibold text-blue-800",children:"Guía de uso"}),A.jsx("span",{className:"icon icon-arrow-down scale-75 -rotate-145"})]}),A.jsx("button",{onClick:Qe,disabled:le||!ke,className:`px-3 cursor-pointer py-1.5 text-sm rounded transition-colors ${d?"bg-red-1000 hover:bg-red-800 text-white":"bg-brand-blue-800 hover:bg-brand-blue-1000 text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,"aria-label":"Vista previa",title:"Mostrar/Ocultar vista previa",children:A.jsxs("div",{className:"flex items-center gap-1",children:[A.jsx("span",{className:"icon icon-search-white icon--sm"}),A.jsx("span",{className:"hidden sm:inline whitespace-nowrap",children:d?"Cerrar previa":"Vista previa"})]})}),A.jsxs("div",{className:"flex flex-row gap-1 lg:gap-2 items-center justify-end",children:[A.jsx("button",{onClick:ct,disabled:le||!ke,className:"cursor-pointer px-3 py-1.5 text-sm rounded bg-brand-blue-800 hover:bg-brand-blue-1000 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed","aria-label":"Descargar",title:"Descargar recorte sin guardar",children:A.jsxs("div",{className:"flex items-center gap-1",children:[A.jsx("span",{className:"icon icon-download-white icon--sm"}),A.jsx("span",{className:"hidden md:inline whitespace-nowrap",children:"Descargar"})]})}),e.file&&A.jsx("button",{onClick:ut,disabled:le||l,className:"px-3 cursor-pointer py-1.5 text-sm rounded bg-teal-600 hover:bg-teal-700 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed","aria-label":"Conservar solo imagen original sin crear recortes",title:"Subir y guardar la imagen original sin crear recortes",children:A.jsxs("div",{className:"flex items-center gap-1",children:[A.jsx("span",{className:"icon icon-tick-white icon--sm"}),A.jsx("span",{className:"hidden md:inline whitespace-nowrap",children:"Conservar original"})]})}),A.jsx("button",{onClick:it,disabled:le||!xe||!Ce||!ke||!he.isReady,className:"px-3 cursor-pointer py-1.5 text-sm rounded bg-green-600 hover:bg-green-700 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Guardar imagen recortada",children:A.jsx("div",{className:"flex items-center gap-1",children:le?A.jsxs(A.Fragment,{children:[A.jsx("span",{className:"icon icon-save-white icon--sm"}),A.jsx("span",{children:"Guardando..."})]}):A.jsxs(A.Fragment,{children:[A.jsx("span",{className:"icon icon-save-white icon--sm"}),A.jsx("span",{className:"hidden md:inline whitespace-nowrap",children:"Guardar recorte"})]})})})]})]}),ee&&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"===ae?"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"===ae?"guardar":"descargar"]})]}),A.jsx("div",{className:"px-6 py-4 overflow-y-auto flex-1",children:A.jsx("div",{className:"space-y-2",children:V.map((e,t)=>{const n=e.savedState||t===G,r=!e.required&&!n;return A.jsxs("label",{className:`flex items-center gap-3 p-3 rounded border transition-colors ${ne.includes(t)?"bg-blue-50 border-blue-300":r?"bg-gray-100 border-gray-300 opacity-60":"bg-gray-50 border-gray-200 hover:bg-gray-100"} ${r?"cursor-not-allowed":"cursor-pointer"}`,children:[A.jsx("input",{type:"checkbox",checked:ne.includes(t),disabled:r,onChange:e=>{e.target.checked?re(e=>[...e,t]):re(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 flex-wrap",children:[A.jsxs("span",{title:"Nombre del archivo a descargar",className:"text-sm font-medium text-gray-800 truncate",children:[e.label,"_",e.width,"_",e.height]}),e.required&&A.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-red-200 text-red-1000 rounded whitespace-nowrap",children:"Obligatorio"}),!n&&!e.required&&A.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-orange-100 text-orange-700 rounded whitespace-nowrap",children:"Sin configurar"})]}),A.jsxs("span",{title:"Dimensiones del recorte",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:()=>{te(!1),ie(null),re([])},className:"limbo-btn limbo-btn-secondary px-4 py-2",children:"Cancelar"}),A.jsxs("button",{onClick:async()=>{if(te(!1),"save"===ae)if(1===ne.length){const e=G;Q(ne[0]),await new Promise(e=>setTimeout(e,100)),await rt(),Q(e)}else await at(ne);else if(1===ne.length){const e=G;Q(ne[0]),await new Promise(e=>setTimeout(e,100)),await lt(),Q(e)}else await st(ne);ie(null),re([])},disabled:0===ne.length,className:"limbo-btn limbo-btn-primary px-4 py-2 disabled:opacity-50 disabled:cursor-not-allowed",children:["save"===ae?"Guardar":"Descargar"," (",ne.length,")"]})]})]})}),L&&A.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[9999] p-4",children:A.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-5xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[A.jsx("div",{className:"px-6 py-4 border-b border-gray-200 bg-brand-blue-50",children:A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsxs("h3",{className:"text-xl font-semibold text-brand-blue-1000 flex items-center gap-2",children:[A.jsx("span",{className:"icon icon-lightbulb text-yellow-500"}),"Guía de uso del Cropper"]}),A.jsx("button",{onClick:()=>D(!1),className:"text-gray-400 hover:text-gray-600 p-1 rounded-full hover:bg-gray-100 transition-colors","aria-label":"Cerrar modal",children:A.jsx("span",{className:"icon icon-close-small icon--lg"})})]})}),A.jsxs("div",{className:"px-6 py-4 overflow-y-auto flex-1 space-y-4",children:[A.jsxs("div",{className:"bg-brand-blue-50 rounded-lg p-4 border-l-4 border-brand-blue-400",children:[A.jsx("h4",{className:"font-semibold text-brand-blue-1000 mb-3 text-base flex items-center gap-2",children:"🖱️ Navegación básica"}),A.jsxs("div",{className:"text-sm text-brand-blue-800 space-y-2",children:[A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Arrastra la imagen:"})," Haz clic sobre la imagen dentro del área de selección y arrástrala para reposicionarla"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Zoom:"})," Usa la rueda del ratón sobre el canvas (fuera del área de selección) para hacer zoom"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Vista completa:"}),' Botón "Reset zoom" para ajustar automáticamente al tamaño óptimo']})]})]})]}),A.jsxs("div",{className:"bg-brand-blue-50 rounded-lg p-4 border-l-4 border-brand-blue-400",children:[A.jsx("h4",{className:"font-semibold text-brand-blue-1000 mb-3 text-base flex items-center gap-2",children:"✂️ Área de selección"}),A.jsxs("div",{className:"text-sm text-brand-blue-800 space-y-2",children:[A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",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 inline-block mx-1 align-middle border border-brand-blue-400 rounded-full"}),"para reposicionar el área de recorte"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Redimensionar:"})," Arrastra desde las esquinas o bordes para cambiar el tamaño del área"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Tamaños rápidos:"})," Usa los botones de porcentaje (50%, 70%, 90%, 100%) para ajustar rápidamente el tamaño"]})]})]})]}),A.jsxs("div",{className:"bg-brand-blue-50 rounded-lg p-4 border-l-4 border-brand-blue-400",children:[A.jsx("h4",{className:"font-semibold text-brand-blue-1000 mb-3 text-base flex items-center gap-2",children:"⌨️ Atajos de teclado"}),A.jsxs("div",{className:"text-sm text-brand-blue-800 space-y-2",children:[A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Flechas:"}),A.jsxs("span",{className:"inline-flex gap-1 mx-1",children:[A.jsx("span",{className:"icon icon-arrow-right-box rotate-180 icon--sm"}),A.jsx("span",{className:"icon icon-arrow-right-box icon--sm"}),A.jsx("span",{className:"icon icon-arrow-right-box -rotate-90 icon--sm"}),A.jsx("span",{className:"icon icon-arrow-right-box rotate-90 icon--sm"})]}),"Mueven la selección en incrementos de 10px"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Shift + Arrastrar:"})," Mantiene las proporciones al redimensionar el área de selección"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Ctrl + Rueda:"})," Control de zoom más preciso y fino"]})]})]})]}),A.jsxs("div",{className:"bg-teal-50 rounded-lg p-4 border-l-4 border-teal-800",children:[A.jsx("h4",{className:"font-semibold text-teal-1000 mb-3 text-base flex items-center gap-2",children:"👁️ Opciones de visualización"}),A.jsxs("div",{className:"text-sm text-teal-800 space-y-2",children:[A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Cuadrícula:"})," Muestra la regla de los tercios para mejorar la composición de tus recortes"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Tablero:"})," Patrón de cuadros para alinear mejor las medidas o ver imágenes con transparencia"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Vista previa:"})," Muestra cómo quedará el recorte final antes de guardarlo"]})]})]})]}),A.jsxs("div",{className:"bg-amber-50 rounded-lg p-4 border-l-4 border-amber-400",children:[A.jsx("h4",{className:"font-semibold text-amber-800 mb-3 text-base flex items-center gap-2",children:"💡 Consejos profesionales"}),A.jsxs("div",{className:"text-sm text-amber-700 space-y-2",children:[A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Orden de trabajo:"})," Primero aplica transformaciones (rotar, voltear), luego haz el recorte final"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Múltiples recortes:"})," Si tienes varios recortes configurados, revisa cada uno antes de guardar"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Calidad:"})," Las imágenes se exportan en alta calidad (JPEG 90%) manteniendo la mayor nitidez posible"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Proporciones:"})," Usa Shift al redimensionar para mantener el aspecto ratio original"]})]})]})]}),A.jsxs("div",{className:"bg-orange-50 rounded-lg p-4 border-l-4 border-orange-500",children:[A.jsx("h4",{className:"font-semibold text-orange-800 mb-3 text-base flex items-center gap-2",children:"⚠️ Notas importantes"}),A.jsxs("div",{className:"text-sm text-orange-700 space-y-2",children:[A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Recortes grandes:"})," Imágenes de alta resolución pueden tardar más en procesarse"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Calidad de escala:"})," Evita ampliar demasiado áreas pequeñas, ya que puede afectar la nitidez"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Cambios pendientes:"})," Recuerda guardar tus cambios antes de cerrar o cambiar de imagen"]})]})]})]})]}),A.jsx("div",{className:"px-6 py-4 border-t border-gray-200 bg-gray-50",children:A.jsx("button",{onClick:()=>D(!1),className:"limbo-btn limbo-btn-primary w-full",children:"Entendido"})})]})}),d&&A.jsx("div",{className:"min-w-[90%] fixed md:absolute inset-0 md:inset-auto bg-black/50 md:bg-transparent flex items-center justify-center md:block z-[9999] md:z-50 pointer-events-none",onClick:e=>{e.target===e.currentTarget&&window.innerWidth<768&&(m(!1),p(null))},children:A.jsxs("div",{className:"pointer-events-auto bg-white rounded-lg shadow-2xl border-2 border-brand-blue-800 overflow-hidden flex flex-col max-w-md w-full mx-4 md:mx-0 max-h-[80vh] md:max-h-[600px]",style:{...window.innerWidth>=768?{position:"absolute",left:`${w.x}px`,top:`${w.y}px`,width:"420px",cursor:S?"grabbing":"default"}:{}},onMouseDown:Ye,onTouchStart:Ze,children:[A.jsxs("div",{className:"limbo-preview-modal-header px-4 py-3 bg-gradient-to-r from-brand-blue-800 to-brand-blue-1000 text-white flex items-center justify-between cursor-grab active:cursor-grabbing select-none",style:{cursor:S?"grabbing":"grab"},children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("span",{className:"icon icon-search-white icon--sm"}),A.jsx("h3",{className:"text-sm font-semibold",children:"Vista previa"})]}),A.jsx("button",{onClick:()=>{m(!1),p(null)},className:"flex p-1 hover:bg-white/20 rounded transition-colors cursor-pointer aspect-square min-w-fit min-h-fit","aria-label":"Cerrar vista previa",title:"Cerrar vista previa",children:A.jsx("span",{className:"icon icon-close-small-white icon--sm p-0 m-0 py-auto my-auto mx-auto"})})]}),A.jsx("div",{className:"flex-1 overflow-auto bg-gray-50 p-4",children:f?A.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",children:A.jsxs("div",{className:"text-center",children:[A.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-3"}),A.jsx("p",{className:"text-sm text-gray-600",children:"Generando vista previa..."})]})}):h?A.jsxs("div",{className:"flex flex-col items-center gap-3",children:[A.jsxs("div",{className:"relative w-full bg-white rounded-lg border border-gray-200 overflow-hidden shadow-sm cursor-zoom-in hover:ring-2 hover:ring-brand-blue-800 transition-all",onClick:()=>$(!0),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),$(!0))},"aria-label":"Click para ver recorte en tamaño completo",title:"Click para ampliar",children:[A.jsx("img",{src:h,alt:"Vista previa del recorte",className:"w-full h-auto object-contain max-h-[400px]"}),A.jsxs("div",{className:"absolute top-2 right-2 bg-black/60 text-white px-2 py-1 rounded text-xs flex items-center gap-1",children:[A.jsx("span",{className:"icon icon-search-white icon--xs"}),A.jsx("span",{children:"Ampliar"})]})]}),A.jsxs("div",{className:"text-center text-xs text-gray-500",children:[A.jsx("p",{className:"font-medium text-gray-700 mb-1",children:Y?.label||"Recorte"}),A.jsxs("p",{children:[Y?.width," × ",Y?.height," px"]})]})]}):A.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",children:A.jsx("p",{className:"text-sm text-gray-500",children:"No se pudo generar la vista previa"})})}),A.jsx("div",{className:"px-4 py-2 bg-gray-100 border-t border-gray-200",children:A.jsxs("p",{className:"text-xs text-gray-600 text-center",children:[A.jsxs("span",{className:"hidden md:inline",children:["Arrastra desde el título para mover •"," "]}),"Actualización automática al editar"]})})]})}),A.jsx(J,{src:h,alt:"Vista previa del recorte",title:Y?.label||"Recorte",subtitle:`${Y?.width||0} × ${Y?.height||0} px`,isOpen:E&&!!h,onClose:()=>$(!1)})]}):null}function ln({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:` px-3 py-2 text-sm font-medium rounded-md transition-colors disabled:cursor-default cursor-pointer ${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"} `,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:` px-3 py-2 text-sm font-medium rounded-md transition-colors disabled:cursor-default cursor-pointer ${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"} `,children:t})},`page-${t}-${a}`))}),A.jsxs("button",{onClick:()=>{e<t&&n(e+1)},disabled:r||e>=t,className:` px-3 py-2 text-sm font-medium rounded-md transition-colors disabled:cursor-default cursor-pointer ${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"} `,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 cn({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 un({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-1000 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 dn(){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:K,useJWT:!0})}catch(n){throw V(n)}}(e);return!1!==t.success}catch(a){return r(a.message),!1}finally{t(!1)}},loading:e,error:n,reset:()=>{r(null)}}}const mn=new Map;function hn(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 pn({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,cropperConfig:d=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[m,h]=u.useState({name:"",uploadedBy:"",dateFrom:"",dateTo:""}),p=hn(m.name,500),f=hn(m.uploadedBy,500),g=(()=>{switch(a){case"gallery-only":return["gallery"];case"upload-only":return["upload","cropper"];case"crop-only":return["cropper"];case"ia-only":return["ia"];default:return r}})(),[b,y]=u.useState(g.includes("gallery")?"gallery":g.includes("upload")?"upload":g.includes("cropper")?"cropper":g.includes("ia")?"ia":g[0]||"gallery"),[v,x]=u.useState(null);u.useEffect(()=>{c&&(console.log("📸 Imagen externa detectada:",c),x(c),y("cropper"))},[c]);const[w,k]=u.useState(1),{isTokenExpired:S,handleTokenExpiredClose:C}=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:j,loading:N,error:E,uploadedImage:$,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 Q(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:z,loading:T,error:P,reset:M}=dn(),L={limit:l,page:w,...p&&{name:p},...f&&{uploadedBy:f},...m.dateFrom&&{dateFrom:m.dateFrom},...m.dateTo&&{dateTo:m.dateTo}},D=g.includes("gallery"),{images:O,loading:R,error:F,pagination:U,invalidateCache:q,setImages:B}=function(e,t=!1,n={},r=!0){const[a,i]=u.useState([]),[o,s]=u.useState(r),[l,c]=u.useState(null),[d,m]=u.useState(null),[h,p]=u.useState(0),f=u.useMemo(()=>JSON.stringify(n),[n]);return u.useEffect(()=>{if(!r)return void s(!1);const e=`${f}`,t=mn.get(e),a=Date.now();if(t&&a-t.timestamp<6e5)return i(t.data),m(t.pagination||null),void s(!1);let o=!0;return(async()=>{if(h>=3)o&&(c("Error de autenticación: Verifica tus credenciales API"),s(!1));else try{const t=await G(n);if(!o)return;const r=t.result||t.data||[],s=t.pagination||null;i(r),m(s),c(null),p(0),mn.set(e,{data:r,pagination:s,timestamp:a})}catch(t){o&&(c(t.message),p(e=>e+1))}finally{o&&s(!1)}})(),()=>{o=!1}},[e,t,f,h,n,r]),{images:a,loading:o,error:l,pagination:d,setImages:i,invalidateCache:()=>{mn.delete(`${f}`)}}}(e,t,L,D),{refreshVariants:H}=X(),W=e=>!i.hideActions?.includes(e)&&(!!i.showActions?.includes(e)||!(i.showActions?.length>0)),V=[{id:"gallery",label:"Galería",feature:"gallery"},{id:"upload",label:"Subir nueva",feature:"upload"},{id:"cropper",label:"Recortador",hideNonActive:!0,feature:"cropper"}].filter(e=>g.includes(e.feature)),K=async e=>{const t=URL.createObjectURL(e),n=await new Promise(e=>{const n=new Image;n.onload=()=>{e({width:n.naturalWidth,height:n.naturalHeight}),URL.revokeObjectURL(t)},n.onerror=()=>{e({width:1920,height:1080}),URL.revokeObjectURL(t)},n.src=t}),r={file:e,filename:e.name,mime_type:e.type,url:URL.createObjectURL(e),width:n.width,height:n.height};if(x(r),g.includes("cropper"))y("cropper");else{const t=await j(e);t&&(q(),k(1),B(e=>[t,...e]),y("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}))}},Y=async e=>{if(!confirm("¿Estás seguro de que deseas eliminar esta imagen? Esta acción también eliminará todos sus recortes."))return;await z(e)&&(q(),k(1),B(t=>t.filter(t=>t.id!==e)),v&&v.id===e&&(x(null),y("gallery")))},J=()=>"crop-only"===a||1===g.length&&"cropper"===g[0]?"crop-only":g.includes("gallery")?"with-gallery":g.includes("upload")&&!g.includes("gallery")?"upload-only":"with-gallery";return A.jsxs(A.Fragment,{children:[i.showTabs&&"cropper"!=b&&A.jsx(I,{tabs:V,active:b,onChange:e=>{y(e),"upload"!==e&&_(),"gallery"!==e&&M()}}),F&&A.jsxs("div",{className:"alert alert-danger",children:["Error al cargar imágenes: ",F]}),P&&A.jsxs("div",{className:"alert alert-danger",children:["Error al eliminar imagen: ",P]}),"gallery"===b&&A.jsxs(A.Fragment,{children:[T&&A.jsx(cn,{text:"Eliminando imagen..."}),$&&A.jsxs("div",{className:"alert alert-success absolute top-0 right-[50px] m-4",children:["✅ Imagen subida correctamente: ",$.filename]}),A.jsx(ne,{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=>{x(e),g.includes("cropper")&&y("cropper")},onDelete:W("delete")?Y:null,deletingId:T,images:O,loading:R,error:F,filters:m,onFiltersChange:e=>{h(e),k(1)},filterConfig:i.galleryFilters||{},loadingConfig:i.galleryLoading||{},allowedActions:{select:W("select"),download:W("download"),copy:W("copy"),delete:W("delete"),crop:W("crop")}}),U&&!R&&A.jsx(ln,{currentPage:U.page||w,totalPages:U.pages||1,onPageChange:e=>{k(e)},disabled:R||T})]}),"upload"===b&&A.jsxs("div",{children:[N&&A.jsx(cn,{text:"Subiendo imagen..."}),E&&A.jsxs("div",{className:"alert alert-danger",children:["Error al subir imagen: ",E]}),$&&A.jsxs("div",{className:"alert alert-success absolute top-0 right-[50px] m-4",children:["✅ Imagen subida correctamente: ",$.filename]}),A.jsx(ke,{onSelect:K,disabled:N,apiKey:e,prod:t})]}),"cropper"===b&&v&&A.jsx(sn,{image:v,onSave:e=>{const t=J(),n=window.limboCore?.config?.getGlobal()||{},r=n.mode||"embed",a=n.autoHideOnComplete||!1;let i=[],l=null;e.crops&&e.asset?(i=e.crops,l=e.asset):i=Array.isArray(e)?e:[e],l&&"with-gallery"===t&&(B(e=>[l,...e]),k(1),o.onUpload&&o.onUpload({assetId:l.id,url:l.url,fileName:l.filename,mime:l.mime_type,width:l.width,height:l.height,instanceId:s})),"with-gallery"===t&&q();const c=l||v,u={crops:i,assetId:c?.id,instanceId:s,asset:c?{id:c.id,url:c.url||c.urlSigned,width:c.width,height:c.height,filename:c.filename,mime_type:c.mime_type}:null};switch(o.onCropsSaved&&o.onCropsSaved(u),window.limboCore?.events&&window.limboCore.events.emit("cropsSaved",u),t){case"with-gallery":x(null),y("gallery");break;case"upload-only":"modal"===r?window.limboCore?.modals?.closeAllModals():(x(null),y("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=J(),t=(window.limboCore?.config?.getGlobal()||{}).mode||"embed";switch(o.onCropperCancelled&&o.onCropperCancelled({assetId:v?.id,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropperCancelled",{assetId:v?.id,instanceId:s}),e){case"with-gallery":x(null),y("gallery");break;case"upload-only":"modal"===t?window.limboCore?.modals?.closeAllModals():(x(null),y("upload"));break;case"crop-only":"modal"===t?window.limboCore?.modals?.closeAllModals():window.limboCore?.events&&window.limboCore.events.emit("cropperClosed",{instanceId:s,reason:"cancelled"})}},onDelete:v?.id&&W("delete")?()=>Y(v.id):null,onError:e=>{o.onCropperError&&o.onCropperError(e,s),window.limboCore?.events&&window.limboCore.events.emit("cropperError",{error:e,assetId:v?.id,instanceId:s}),console.error("Cropper error:",e)},deleting:T,onVariantCreated:(e,t)=>{H(e)},onUpload:j,uploading:N,cropperConfig:d}),"cropper"===b&&!v&&("crop-only"===a?A.jsxs("div",{children:[N&&A.jsx(cn,{text:"Subiendo imagen..."}),E&&A.jsxs("div",{className:"alert alert-danger",children:["Error al subir imagen: ",E]}),A.jsx(ke,{onSelect:K,disabled:N,apiKey:e,prod:t})]}):A.jsxs("div",{className:"limbo-empty-state flex flex-col items-center justify-center py-12 px-6 text-center",children:[A.jsx("div",{className:"text-gray-400 mb-4",children:A.jsx("svg",{className:"w-16 h-16 mx-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),A.jsx("p",{className:"text-gray-600 mb-4",children:"Selecciona una imagen de la galería para comenzar a recortar."})]})),A.jsx(un,{isOpen:S,onClose:C})]})}class fn{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.eventManager?.emit("modal:close",{instance:this}),this.modal.close()),this}updateConfig(e){return this.config={...this.config,...e},this.mounted&&this.root.render(this._renderApp()),this.eventManager.emit("config:updated",{instance:this,newConfig:e}),this}destroy(){this.destroyed||(this.unmount(),this.modal&&(this.modal.destroy(),this.modal=null),this.button&&this.button.parentNode&&(this.button.parentNode.removeChild(this.button),this.button=null),this.eventManager.emit("destroy",{instance:this}),this.container=null,this.config=null,this.eventManager=null,this.modalManager=null,this.destroyed=!0)}getId(){return this.id}getMode(){return this.config.mode}isMounted(){return this.mounted}isDestroyed(){return this.destroyed}getContainer(){return this.container}getConfig(){return{...this.config}}isContainerInDOM(){return this.container&&document.contains(this.container)}_createModal(){if(this.modalManager&&"modal"===this.config.mode&&(this.modal=this.modalManager.createModal({title:this.config.title||"Limbo Image Manager",size:this.config.modalSize||"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 h-full w-full py-2 bg-white rounded-md","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(pn,{apiKey:this.config.apiKey||null,publicKey:this.config.publicKey||null,token:this.config.token||null,prod:this.config.prod||!1,url:this.config.url,features:this.config.features,modeUI:this.config.modeUI||"full",ui:this.config.ui,callbacks:this._createCallbacks(),instanceId:this.id,authMode:this.config.authMode||this.config.publicKey?"session":"manual",_externalImage:this.config._externalImage||null,cropperConfig:this.config.cropper||null}))}_createCallbacks(){return{onSelect:e=>{const t=this.config?.callbacks?.onSelect,n=this._createStandardPayload(e,"select");t&&t(n),this.destroyed||this._emitDOMEvent("select",n)},onUpload:e=>{const t=this.config?.callbacks?.onUpload,n=this._createStandardPayload(e,"upload");t&&t(n),this.destroyed||this._emitDOMEvent("upload",n)},onError:e=>{const t=this.config?.callbacks?.onError,n={instance:this,error:{message:e.message||"Unknown error",code:e.code||"UNKNOWN",timestamp:Date.now()}};t&&t(n.error),this.destroyed||this._emitDOMEvent("error",n)},onClose:()=>{const e=this.config?.callbacks?.onClose,t={instance:this,timestamp:Date.now()};e&&e(),this.destroyed||this._emitDOMEvent("close",t)}}}_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){if(this.destroyed)return;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 gn{constructor(){this.instances=new Map,this.counter=0}create(e,t,n){const r="limbo-"+ ++this.counter,a=new fn(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 bn{constructor(){this.config=null,this.instances=new Map,this.observer=null,this.initialized=!1}configure(e,t,n){return this.config={selector:e.selector||null,dataset:e.dataset||"data-limbo-input-file",return:e.return||e.returnType||"json",mode:e.mode||"modal",features:e.features||["gallery","upload","cropper"],crop:e.crop||"free",quality:e.quality||.9,format:e.format||"webp",modeUI:e.modeUI||"full",modalSize:e.modalSize||"fullscreen",theme:e.theme||"light",compact:e.compact||!1,maxSize:e.maxSize||"10MB",formats:e.formats||["jpg","jpeg","png","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=this.config.selector||`input[${this.config.dataset}]`;document.querySelectorAll(e).forEach(e=>this._processInput(e))}_processInput(e){const t=this._getInputId(e);if(this.instances.has(t))return;if(!this._validateInput(e))return;const 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){const n=(t||{}).return||this.config.return||"json",r=void 0!==e.original;switch(n){case"url":return r?e.images?.[0]?.url||e.original?.url||"":e.url||e.path||"";case"base64":return e.base64||e.dataUrl||"";case"assetId":return r?e.original?.assetId||"":e.assetId||e.id||"";case"fileName":return e.fileName||e.filename||"";default:return r?JSON.stringify(e):JSON.stringify({original:{url:e.url||e.path,width:e.width,height:e.height,assetId:e.assetId||e.id}})}}_createModalConfig(e){return{mode:e.mode||this.config.mode||"modal",modeUI:e.modeUI||this.config.modeUI||"full",features:e.features||this.config.features,modalSize:e.modalSize||this.config.modalSize||"fullscreen",title:e.description||this.config.title||"Seleccionar 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,allowSelectNew:!1!==e.allowSelectNew},initialImageUrl:e.initialImageUrl||null,returnConfig:{format:e.return||this.config.return,quality:e.quality||this.config.quality,outputFormat:e.format||this.config.format},inputMeta:{inputId:e.inputId,inputName:e.inputName,inputType:e.inputType,placeholder:e.placeholder}}}_getCropperConfig(e){const t=e.crop||this.config.crop,n={quality:e.quality||this.config.quality,format:e.format||this.config.format,mandatoryCrops:e.mandatoryCrops||[],allowAdditionalCrops:!1!==e.allowAdditionalCrops,maxCrops:e.maxCrops||null};if(e.mandatoryCrops&&e.mandatoryCrops.length>0)return{...n,aspectRatio:null};if(!t||"none"===t||"false"===t)return null;if("free"===t)return{...n,aspectRatio:null};const r={"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(r[t])return{...n,aspectRatio:r[t],minCropBoxWidth:e.minWidth||this.config.minWidth,minCropBoxHeight:e.minHeight||this.config.minHeight};if("string"==typeof t&&t.includes(":")){const[e,r]=t.split(":").map(Number);if(!isNaN(e)&&!isNaN(r)&&0!==r)return{...n,aspectRatio:e/r}}const a=parseFloat(t);return!isNaN(a)&&a>0?{...n,aspectRatio:a}:"object"==typeof t?{...n,...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,i=e=>{if(!e)return null;try{return JSON.parse(e)}catch(t){return console.warn("[Limbo AutoInputManager] Error parsing JSON attribute:",t),null}},o=i(e.dataset.mandatorycrops)||i(e.dataset.mandatoryCrops)||i(e.getAttribute("data-mandatory-crops"))||i(e.getAttribute("data-limbo-mandatory-crops"))||null;return{return:e.dataset.returntype||e.getAttribute("data-limbo-return")||this.config.return,mode:e.dataset.mode||e.getAttribute("data-limbo-mode")||this.config.mode,features:t(e.dataset.features)||t(e.getAttribute("data-limbo-features"))||this.config.features,crop:e.dataset.crop||e.getAttribute("data-limbo-crop")||this.config.crop,quality:a(e.dataset.quality)||a(e.getAttribute("data-limbo-quality"))||this.config.quality,format:e.dataset.format||e.getAttribute("data-limbo-format")||this.config.format,modeUI:e.dataset.modeui||e.dataset.modeUI||e.getAttribute("data-limbo-mode-ui")||this.config.modeUI,modalSize:e.dataset.modalsize||e.getAttribute("data-limbo-modal-size")||this.config.modalSize,theme:e.dataset.theme||e.getAttribute("data-limbo-theme")||this.config.theme,compact:r(e.dataset.compact,null)??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,mandatoryCrops:o,allowAdditionalCrops:r(e.getAttribute("data-limbo-allow-additional-crops"),!0),maxCrops:a(e.getAttribute("data-limbo-max-crops"))||null,allowSelectNew:r(e.dataset.allowselectnew,null)??r(e.getAttribute("data-limbo-allow-select-new"),!0),initialImageUrl:e.value||null}}_generateInputId(){return`limbo-auto-input-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}_hideInput(e){e.style.display="none"}_insertButton(e,t){e.parentNode.insertBefore(t,e.nextSibling)}_restoreInput(e,t){e.style.display="",t&&t.parentNode&&t.parentNode.removeChild(t)}_setupObserver(){this.observer=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&this._scanNodeForInputs(e)})})}),this.observer.observe(document.body,{childList:!0,subtree:!0})}_scanNodeForInputs(e){const t=this.config.selector||`input[${this.config.dataset}]`;e.matches&&e.matches(t)&&this._processInput(e);const n=e.querySelectorAll&&e.querySelectorAll(t);n&&n.forEach(e=>this._processInput(e))}}class yn{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 vn{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 xn(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 xn{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: 500px; min-height: 400px;",medium:e?"width: 100%; height: 100%;":"max-width: 800px; min-height: 500px;",large:e?"width: 100%; height: 100%;":"max-width: 1400px; min-height: 700px;",xlarge:e?"width: 100%; height: 100%;":"max-width: 95dvw; min-height: 85vh;",fullscreen:"width: 100%; height: 100%; max-width: 100%; max-height: 100%; border-radius: 0;"},n="fullscreen"===this.config.size,r=e||n?`\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n transform: ${e?"translateY(100%)":"scale(0.95)"};\n width: 100%;\n height: 100%;\n max-width: none;\n max-height: none;\n border-radius: 0;\n background: white;\n z-index: ${this.manager._getNextZIndex()+1};\n opacity: ${e?"1":"0"};\n transition: ${e?"transform":"all"} 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n padding-top: env(safe-area-inset-top);\n padding-left: env(safe-area-inset-left);\n padding-right: env(safe-area-inset-right);\n padding-bottom: env(safe-area-inset-bottom);\n `:`\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%) scale(0.8);\n ${t[this.config.size]}\n width: 90%;\n max-height: 90vh;\n background: white;\n border-radius: 16px;\n box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);\n z-index: ${this.manager._getNextZIndex()+1};\n opacity: 0;\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n `;this.element.style.cssText=r,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),t="fullscreen"===this.config.size;return requestAnimationFrame(()=>{this.backdrop&&(this.backdrop.style.opacity="1"),this.element.style.opacity="1",this.element.style.transform=e?"translateY(0%)":t?"scale(1)":"translate(-50%, -50%) scale(1)"}),this.isOpen=!0,this.config.focus&&setTimeout(()=>{if(window.limbo&&window.limbo.core&&window.limbo.core.keyboard)window.limbo.core.keyboard.focusFirst(this.element);else{const e=this.getFocusableElements()[0];e&&e.focus()}},300),this.config.onOpen&&this.config.onOpen(this),this}close(){if(!this.isOpen)return this;const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t="fullscreen"===this.config.size;return this.backdrop&&(this.backdrop.style.opacity="0"),this.element.style.opacity="0",this.element.style.transform=e?"translateY(100%)":t?"scale(0.95)":"translate(-50%, -50%) scale(0.8)",setTimeout(()=>{this._cleanup()},300),this.isOpen=!1,window.limbo&&window.limbo.core&&window.limbo.core.keyboard&&(window.limbo.core.keyboard.setActiveModal(null),window.limbo.core.keyboard.releaseFocus()),this.config.onClose&&this.config.onClose(this),this}destroy(){this.close(),this.manager._removeModal(this),this.config.onDestroy&&this.config.onDestroy(this)}getBodyContainer(){return this.element.querySelector(".limbo-modal-body")}getFocusableElements(){return Array.from(this.element.querySelectorAll(this.manager.focusableSelectors))}getId(){return this.id}isOpened(){return this.isOpen}getConfig(){return{...this.config}}_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 wn{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 kn=new class{constructor(){this.config=new n,this.instances=new gn,this.autoInputs=new bn,this.events=new yn,this.modals=new vn,this.theme=new wn,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",tokenProvider:e.tokenProvider,prod:e.prod||!1,mode:e.mode||"embed",callbacks:e.callbacks||null},O={...O,...t},O.authMode||(O.token?O.authMode="manual":O.authMode="session"),this.config}setToken(e){return function(e){O.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=e=>{let n={};if(e.crops&&e.crops.length>0){const t=e.asset||e.original;n.original={url:t?.url||t?.urlSigned||e.originalUrl,width:t?.width||e.originalWidth,height:t?.height||e.originalHeight,assetId:t?.id||e.assetId},n.images=e.crops.map(e=>({url:e.url||e.urlSigned,width:e.width,height:e.height,name:e.name||e.filename}))}else e.asset?n.original={url:e.asset.url||e.asset.urlSigned,width:e.asset.width,height:e.asset.height,assetId:e.asset.id}:e.master?.urlSigned||e.master?.url?n.original={url:e.master.urlSigned||e.master.url,width:e.master.width||e.width,height:e.master.height||e.height,assetId:e.assetId}:e.url||e.urlSigned?n.original={url:e.url||e.urlSigned,width:e.width,height:e.height,assetId:e.assetId||e.id}:(console.warn("[Limbo] handleResult: formato de datos no reconocido",e),n=e);t(n),a.close()},r={...e,mode:"modal",autoDestroy:!0,interaction:{allowSelection:!0,allowCropping:!0,...e.interaction},callbacks:{onSelect:e=>{n(e)},onCropsSaved:e=>{n(e)},onCropperComplete:e=>{n(e)},onUpload:t=>{"upload-only"!==e.modeUI||e.features?.includes("cropper")||n(t)},onClose:()=>{}}};if(e.initialImageUrl){const t=this._extractAssetIdFromUrl(e.initialImageUrl);r._externalImage={url:e.initialImageUrl,filename:e.initialImageUrl.split("/").pop()?.split("?")[0]||"image.jpg",width:1920,height:1080,mime_type:"image/jpeg",id:t}}e.cropper&&(r.cropper=e.cropper),this.config.setGlobal({interaction:{allowSelection:!0,allowCropping:!0,...e.interaction}});const a=this.create(r);a.open()}_extractAssetIdFromUrl(e){if(!e)return null;try{const t=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,n=e.match(t);return n&&n.length>=2?n[1]:n&&1===n.length?n[0]:null}catch(t){return console.warn("Error extracting asset ID from URL:",t),null}}openGallery(e={}){const t=this.create({mode:"modal",modeUI:"gallery-only",features:["gallery"],autoDestroy:!0,modal:{title:e.title||"Seleccionar Imagen",size:e.size||"large"},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=kn,window.limboCore=kn);return"undefined"!=typeof window&&document.querySelector("#root")&&(kn.configure({prod:!1,publicKey:"pk_e464fd744106b7a8d63d453c4bd02582",authMode:"session"}),kn.create({container:"#root",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],title:"Limbo Image Manager - Development",url:!0}),kn.configureAutoInputs({dataset:"data-limbo-input-file",return:"json",features:["gallery","upload","cropper"],modeUI:"full",modalSize:"large",title:"Seleccionar imagen",crops:"free",allowDelete:!1})),kn});
|
|
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.for("react.activity"),p=Symbol.iterator;var f={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,b={};function y(e,t,n){this.props=e,this.context=t,this.refs=b,this.updater=n||f}function v(){}function x(e,t,n){this.props=e,this.context=t,this.refs=b,this.updater=n||f}y.prototype.isReactComponent={},y.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")},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},v.prototype=y.prototype;var w=x.prototype=new v;w.constructor=x,g(w,y.prototype),w.isPureReactComponent=!0;var k=Array.isArray;function S(){}var C={H:null,A:null,T:null,S:null},j=Object.prototype.hasOwnProperty;function N(t,n,r){var a=r.ref;return{$$typeof:e,type:t,key:n,ref:void 0!==a?a:null,props:r}}function E(t){return"object"==typeof t&&null!==t&&t.$$typeof===e}var $=/\/+/g;function _(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 z(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 z((u=n._init)(n._payload),r,a,i,o)}}if(u)return o=o(n),u=""===i?"."+_(n,0):i,k(o)?(a="",null!=u&&(a=u.replace($,"$&/")+"/"),z(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($,"$&/")+"/")+u,o=N(l.type,c,l.props)),r.push(o)),1;u=0;var d,h=""===i?".":i+":";if(k(n))for(var f=0;f<n.length;f++)u+=z(i=n[f],r,a,s=h+_(i,f),o);else if("function"==typeof(f=null===(d=n)||"object"!=typeof d?null:"function"==typeof(d=p&&d[p]||d["@@iterator"])?d:null))for(n=f.call(n),f=0;!(i=n.next()).done;)u+=z(i=i.value,r,a,s=h+_(i,f++),o);else if("object"===s){if("function"==typeof n.then)return z(function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch("string"==typeof e.status?e.then(S,S):(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 T(e,t,n){if(null==e)return e;var r=[],a=0;return z(e,r,"","",function(e){return t.call(n,e,a++)}),r}function A(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 P="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)},M={map:T,forEach:function(e,t,n){T(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return T(e,function(){t++}),t},toArray:function(e){return T(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}};return s.Activity=h,s.Children=M,s.Component=y,s.Fragment=n,s.Profiler=i,s.PureComponent=x,s.StrictMode=r,s.Suspense=u,s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,s.__COMPILER_RUNTIME={__proto__:null,c:function(e){return C.H.useMemoCache(e)}},s.cache=function(e){return function(){return e.apply(null,arguments)}},s.cacheSignal=function(){return null},s.cloneElement=function(e,t,n){if(null==e)throw Error("The argument must be a React element, but you passed "+e+".");var r=g({},e.props),a=e.key;if(null!=t)for(i in void 0!==t.key&&(a=""+t.key),t)!j.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 N(e.type,a,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)j.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 N(e,i,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:A}},s.memo=function(e,t){return{$$typeof:d,type:e,compare:void 0===t?null:t}},s.startTransition=function(e){var t=C.T,n={};C.T=n;try{var r=e(),a=C.S;null!==a&&a(n,r),"object"==typeof r&&null!==r&&"function"==typeof r.then&&r.then(S,P)}catch(i){P(i)}finally{null!==t&&null!==n.types&&(t.types=n.types),C.T=t}},s.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},s.use=function(e){return C.H.use(e)},s.useActionState=function(e,t,n){return C.H.useActionState(e,t,n)},s.useCallback=function(e,t){return C.H.useCallback(e,t)},s.useContext=function(e){return C.H.useContext(e)},s.useDebugValue=function(){},s.useDeferredValue=function(e,t){return C.H.useDeferredValue(e,t)},s.useEffect=function(e,t){return C.H.useEffect(e,t)},s.useEffectEvent=function(e){return C.H.useEffectEvent(e)},s.useId=function(){return C.H.useId()},s.useImperativeHandle=function(e,t,n){return C.H.useImperativeHandle(e,t,n)},s.useInsertionEffect=function(e,t){return C.H.useInsertionEffect(e,t)},s.useLayoutEffect=function(e,t){return C.H.useLayoutEffect(e,t)},s.useMemo=function(e,t){return C.H.useMemo(e,t)},s.useOptimistic=function(e,t){return C.H.useOptimistic(e,t)},s.useReducer=function(e,t,n){return C.H.useReducer(e,t,n)},s.useRef=function(e){return C.H.useRef(e)},s.useState=function(e){return C.H.useState(e)},s.useSyncExternalStore=function(e,t,n){return C.H.useSyncExternalStore(e,t,n)},s.useTransition=function(){return C.H.useTransition()},s.version="19.2.3",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,j=5,N=-1;function E(){return!(!g&&e.unstable_now()-N<j)}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&&E());){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"):j=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=E,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 j(){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.2.3",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=j()),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(31===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function l(e){if(i(e)!==e)throw Error(r(188))}function u(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=u(e)))return t;e=e.sibling}return null}var d=Object.assign,m=Symbol.for("react.element"),h=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),k=Symbol.for("react.consumer"),C=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),E=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 g:return"Fragment";case v:return"Profiler";case b:return"StrictMode";case E:return"Suspense";case $:return"SuspenseList";case T:return"Activity"}if("object"==typeof e)switch(e.$$typeof){case p:return"Portal";case C:return e.displayName||"Context";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 D=Array.isArray,O=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=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 W(e){0>q||(e.current=U[q],U[q]=null,q--)}function H(e,t){q++,U[q]=e.current,e.current=t}var V,K,G=B(null),Q=B(null),Y=B(null),X=B(null);function J(e,t){switch(H(Y,t),H(Q,e),H(G,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?wd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)e=kd(t=wd(t),e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}W(G),H(G,e)}function Z(){W(G),W(Q),W(Y)}function ee(e){null!==e.memoizedState&&H(X,e);var t=G.current,n=kd(t,e.type);t!==n&&(H(Q,e),H(G,n))}function te(e){Q.current===e&&(W(G),W(Q)),X.current===e&&(W(X),pm._currentValue=F)}function ne(e){if(void 0===V)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);V=t&&t[1]||"",K=-1<n.stack.indexOf("\n at")?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return"\n"+V+e+K}var re=!1;function ae(e,t){if(!e||re)return"";re=!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{re=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?ne(n):""}function ie(e,t){switch(e.tag){case 26:case 27:case 5:return ne(e.type);case 16:return ne("Lazy");case 13:return e.child!==t&&null!==t?ne("Suspense Fallback"):ne("Suspense");case 19:return ne("SuspenseList");case 0:case 15:return ae(e.type,!1);case 11:return ae(e.type.render,!1);case 1:return ae(e.type,!0);case 31:return ne("Activity");default:return""}}function oe(e){try{var t="",n=null;do{t+=ie(e,n),n=e,e=e.return}while(e);return t}catch(r){return"\nError generating stack: "+r.message+"\n"+r.stack}}var se=Object.prototype.hasOwnProperty,le=e.unstable_scheduleCallback,ce=e.unstable_cancelCallback,ue=e.unstable_shouldYield,de=e.unstable_requestPaint,me=e.unstable_now,he=e.unstable_getCurrentPriorityLevel,pe=e.unstable_ImmediatePriority,fe=e.unstable_UserBlockingPriority,ge=e.unstable_NormalPriority,be=e.unstable_LowPriority,ye=e.unstable_IdlePriority,ve=e.log,xe=e.unstable_setDisableYieldValue,we=null,ke=null;function Se(e){if("function"==typeof ve&&xe(e),ke&&"function"==typeof ke.setStrictMode)try{ke.setStrictMode(we,e)}catch(t){}}var Ce=Math.clz32?Math.clz32:function(e){return 0===(e>>>=0)?32:31-(je(e)/Ne|0)|0},je=Math.log,Ne=Math.LN2;var Ee=256,$e=262144,_e=4194304;function ze(e){var t=42&e;if(0!==t)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Te(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=ze(r):0!==(o&=s)?a=ze(o):n||0!==(n=s&~e)&&(a=ze(n)):0!==(s=r&~i)?a=ze(s):0!==o?a=ze(o):n||0!==(n=r&~e)&&(a=ze(n)),0===a?0:0!==t&&t!==a&&0===(t&i)&&((i=a&-a)>=(n=t&-t)||32===i&&4194048&n)?t:a}function Ae(e,t){return 0===(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)}function Pe(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 Me(){var e=_e;return!(62914560&(_e<<=1))&&(_e=4194304),e}function Ie(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Le(e,t){e.pendingLanes|=t,268435456!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function De(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Ce(t);e.entangledLanes|=t,e.entanglements[r]=1073741824|e.entanglements[r]|261930&n}function Oe(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ce(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}function Re(e,t){var n=t&-t;return 0!==((n=42&n?1:Fe(n))&(e.suspendedLanes|t))?0:n}function Fe(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 Ue(e){return 2<(e&=-e)?8<e?134217727&e?32:268435456:8:2}function qe(){var e=R.p;return 0!==e?e:void 0===(e=window.event)?32:zm(e.type)}function Be(e,t){var n=R.p;try{return R.p=e,t()}finally{R.p=n}}var We=Math.random().toString(36).slice(2),He="__reactFiber$"+We,Ve="__reactProps$"+We,Ke="__reactContainer$"+We,Ge="__reactEvents$"+We,Qe="__reactListeners$"+We,Ye="__reactHandles$"+We,Xe="__reactResources$"+We,Je="__reactMarker$"+We;function Ze(e){delete e[He],delete e[Ve],delete e[Ge],delete e[Qe],delete e[Ye]}function et(e){var t=e[He];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ke]||n[He]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=Fd(e);null!==e;){if(n=e[He])return n;e=Fd(e)}return t}n=(e=n).parentNode}return null}function tt(e){if(e=e[He]||e[Ke]){var t=e.tag;if(5===t||6===t||13===t||31===t||26===t||27===t||3===t)return e}return null}function nt(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e.stateNode;throw Error(r(33))}function rt(e){var t=e[Xe];return t||(t=e[Xe]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function at(e){e[Je]=!0}var it=new Set,ot={};function st(e,t){lt(e,t),lt(e+"Capture",t)}function lt(e,t){for(ot[e]=t,e=0;e<t.length;e++)it.add(t[e])}var ct=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]*$"),ut={},dt={};function mt(e,t,n){if(a=t,se.call(dt,a)||!se.call(ut,a)&&(ct.test(a)?dt[a]=!0:(ut[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 ht(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 pt(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 ft(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function gt(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function bt(e){if(!e._valueTracker){var t=gt(e)?"checked":"value";e._valueTracker=function(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&void 0!==r&&"function"==typeof r.get&&"function"==typeof r.set){var a=r.get,i=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(e){n=""+e,i.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e,t,""+e[t])}}function yt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=gt(e)?e.checked?"true":"false":e.value),(e=r)!==n&&(t.setValue(e),!0)}function vt(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 xt=/[\n"\\]/g;function wt(e){return e.replace(xt,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function kt(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=""+ft(t)):e.value!==""+ft(t)&&(e.value=""+ft(t)):"submit"!==o&&"reset"!==o||e.removeAttribute("value"),null!=t?Ct(e,o,ft(t)):null!=n?Ct(e,o,ft(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=""+ft(s):e.removeAttribute("name")}function St(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 void bt(e);n=null!=n?""+ft(n):"",t=null!=t?""+ft(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),bt(e)}function Ct(e,t,n){"number"===t&&vt(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function jt(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=""+ft(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 Nt(e,t,n){null==t||((t=""+ft(t))!==e.value&&(e.value=t),null!=n)?e.defaultValue=null!=n?""+ft(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(D(a)){if(1<a.length)throw Error(r(93));a=a[0]}n=a}null==n&&(n=""),t=n}n=ft(t),e.defaultValue=n,(a=e.textContent)===n&&""!==a&&null!==a&&(e.value=a),bt(e)}function $t(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 _t=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 zt(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||_t.has(t)?"float"===t?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function Tt(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&&zt(e,i,a)}else for(var o in t)t.hasOwnProperty(o)&&zt(e,o,t[o])}function At(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 Pt=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"]]),Mt=/^[\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 It(e){return Mt.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Lt(){}var Dt=null;function Ot(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var Rt=null,Ft=null;function Ut(e){var t=tt(e);if(t&&(e=t.stateNode)){var n=e[Ve]||null;e:switch(e=t.stateNode,t.type){case"input":if(kt(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="'+wt(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var a=n[t];if(a!==e&&a.form===e.form){var i=a[Ve]||null;if(!i)throw Error(r(90));kt(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&&yt(a)}break e;case"textarea":Nt(e,n.value,n.defaultValue);break e;case"select":null!=(t=n.value)&&jt(e,!!n.multiple,t,!1)}}}var qt=!1;function Bt(e,t,n){if(qt)return e(t,n);qt=!0;try{return e(t)}finally{if(qt=!1,(null!==Rt||null!==Ft)&&(ru(),Rt&&(t=Rt,e=Ft,Ft=Rt=null,Ut(t),e)))for(t=0;t<e.length;t++)Ut(e[t])}}function Wt(e,t){var n=e.stateNode;if(null===n)return null;var a=n[Ve]||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 Ht=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),Vt=!1;if(Ht)try{var Kt={};Object.defineProperty(Kt,"passive",{get:function(){Vt=!0}}),window.addEventListener("test",Kt,Kt),window.removeEventListener("test",Kt,Kt)}catch(th){Vt=!1}var Gt=null,Qt=null,Yt=null;function Xt(){if(Yt)return Yt;var e,t,n=Qt,r=n.length,a="value"in Gt?Gt.value:Gt.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 Yt=a.slice(e,1<t?1-t:void 0)}function Jt(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 Zt(){return!0}function en(){return!1}function tn(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)?Zt:en,this.isPropagationStopped=en,this}return d(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=Zt)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=Zt)},persist:function(){},isPersistent:Zt}),t}var nn,rn,an,on={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},sn=tn(on),ln=d({},on,{view:0,detail:0}),cn=tn(ln),un=d({},ln,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:wn,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!==an&&(an&&"mousemove"===e.type?(nn=e.screenX-an.screenX,rn=e.screenY-an.screenY):rn=nn=0,an=e),nn)},movementY:function(e){return"movementY"in e?e.movementY:rn}}),dn=tn(un),mn=tn(d({},un,{dataTransfer:0})),hn=tn(d({},ln,{relatedTarget:0})),pn=tn(d({},on,{animationName:0,elapsedTime:0,pseudoElement:0})),fn=tn(d({},on,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}})),gn=tn(d({},on,{data:0})),bn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},yn={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"},vn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function xn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=vn[e])&&!!t[e]}function wn(){return xn}var kn=tn(d({},ln,{key:function(e){if(e.key){var t=bn[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=Jt(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?yn[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:wn,charCode:function(e){return"keypress"===e.type?Jt(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?Jt(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}})),Sn=tn(d({},un,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Cn=tn(d({},ln,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:wn})),jn=tn(d({},on,{propertyName:0,elapsedTime:0,pseudoElement:0})),Nn=tn(d({},un,{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})),En=tn(d({},on,{newState:0,oldState:0})),$n=[9,13,27,32],_n=Ht&&"CompositionEvent"in window,zn=null;Ht&&"documentMode"in document&&(zn=document.documentMode);var Tn=Ht&&"TextEvent"in window&&!zn,An=Ht&&(!_n||zn&&8<zn&&11>=zn),Pn=String.fromCharCode(32),Mn=!1;function In(e,t){switch(e){case"keyup":return-1!==$n.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ln(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Dn=!1;var On={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 Rn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!On[e.type]:"textarea"===t}function Fn(e,t,n,r){Rt?Ft?Ft.push(r):Ft=[r]:Rt=r,0<(t=sd(t,"onChange")).length&&(n=new sn("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Un=null,qn=null;function Bn(e){Zu(e,0)}function Wn(e){if(yt(nt(e)))return e}function Hn(e,t){if("change"===e)return t}var Vn=!1;if(Ht){var Kn;if(Ht){var Gn="oninput"in document;if(!Gn){var Qn=document.createElement("div");Qn.setAttribute("oninput","return;"),Gn="function"==typeof Qn.oninput}Kn=Gn}else Kn=!1;Vn=Kn&&(!document.documentMode||9<document.documentMode)}function Yn(){Un&&(Un.detachEvent("onpropertychange",Xn),qn=Un=null)}function Xn(e){if("value"===e.propertyName&&Wn(qn)){var t=[];Fn(t,qn,e,Ot(e)),Bt(Bn,t)}}function Jn(e,t,n){"focusin"===e?(Yn(),qn=n,(Un=t).attachEvent("onpropertychange",Xn)):"focusout"===e&&Yn()}function Zn(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Wn(qn)}function er(e,t){if("click"===e)return Wn(t)}function tr(e,t){if("input"===e||"change"===e)return Wn(t)}var nr="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t};function rr(e,t){if(nr(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(!se.call(t,a)||!nr(e[a],t[a]))return!1}return!0}function ar(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ir(e,t){var n,r=ar(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=ar(r)}}function or(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?or(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function sr(e){for(var t=vt((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=vt((e=t.contentWindow).document)}return t}function lr(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 cr=Ht&&"documentMode"in document&&11>=document.documentMode,ur=null,dr=null,mr=null,hr=!1;function pr(e,t,n){var r=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;hr||null==ur||ur!==vt(r)||("selectionStart"in(r=ur)&&lr(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},mr&&rr(mr,r)||(mr=r,0<(r=sd(dr,"onSelect")).length&&(t=new sn("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=ur)))}function fr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var gr={animationend:fr("Animation","AnimationEnd"),animationiteration:fr("Animation","AnimationIteration"),animationstart:fr("Animation","AnimationStart"),transitionrun:fr("Transition","TransitionRun"),transitionstart:fr("Transition","TransitionStart"),transitioncancel:fr("Transition","TransitionCancel"),transitionend:fr("Transition","TransitionEnd")},br={},yr={};function vr(e){if(br[e])return br[e];if(!gr[e])return e;var t,n=gr[e];for(t in n)if(n.hasOwnProperty(t)&&t in yr)return br[e]=n[t];return e}Ht&&(yr=document.createElement("div").style,"AnimationEvent"in window||(delete gr.animationend.animation,delete gr.animationiteration.animation,delete gr.animationstart.animation),"TransitionEvent"in window||delete gr.transitionend.transition);var xr=vr("animationend"),wr=vr("animationiteration"),kr=vr("animationstart"),Sr=vr("transitionrun"),Cr=vr("transitionstart"),jr=vr("transitioncancel"),Nr=vr("transitionend"),Er=new Map,$r="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 _r(e,t){Er.set(e,t),st(t,[e])}$r.push("scrollEnd");var zr="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)},Tr=[],Ar=0,Pr=0;function Mr(){for(var e=Ar,t=Pr=Ar=0;t<e;){var n=Tr[t];Tr[t++]=null;var r=Tr[t];Tr[t++]=null;var a=Tr[t];Tr[t++]=null;var i=Tr[t];if(Tr[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&&Or(n,a,i)}}function Ir(e,t,n,r){Tr[Ar++]=e,Tr[Ar++]=t,Tr[Ar++]=n,Tr[Ar++]=r,Pr|=r,e.lanes|=r,null!==(e=e.alternate)&&(e.lanes|=r)}function Lr(e,t,n,r){return Ir(e,t,n,r),Rr(e)}function Dr(e,t){return Ir(e,null,null,t),Rr(e)}function Or(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-Ce(n),null===(r=(e=i.hiddenUpdates)[a])?e[a]=[t]:r.push(t),t.lane=536870912|n),i):null}function Rr(e){if(50<Gc)throw Gc=0,Qc=null,Error(r(185));for(var t=e.return;null!==t;)t=(e=t).return;return 3===e.tag?e.stateNode:null}var Fr={};function Ur(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 qr(e,t,n,r){return new Ur(e,t,n,r)}function Br(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Wr(e,t){var n=e.alternate;return null===n?((n=qr(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 Hr(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 Vr(e,t,n,a,i,o){var s=0;if(a=e,"function"==typeof e)Br(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,G.current)?26:"html"===e||"head"===e||"body"===e?27:5;else e:switch(e){case T:return(e=qr(31,n,t,i)).elementType=T,e.lanes=o,e;case g:return Kr(n.children,i,o,t);case b:s=8,i|=24;break;case v:return(e=qr(12,n,t,2|i)).elementType=v,e.lanes=o,e;case E:return(e=qr(13,n,t,i)).elementType=E,e.lanes=o,e;case $:return(e=qr(19,n,t,i)).elementType=$,e.lanes=o,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){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=qr(s,n,t,i)).elementType=e,t.type=a,t.lanes=o,t}function Kr(e,t,n,r){return(e=qr(7,e,r,t)).lanes=n,e}function Gr(e,t,n){return(e=qr(6,e,null,t)).lanes=n,e}function Qr(e){var t=qr(18,null,null,0);return t.stateNode=e,t}function Yr(e,t,n){return(t=qr(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Xr=new WeakMap;function Jr(e,t){if("object"==typeof e&&null!==e){var n=Xr.get(e);return void 0!==n?n:(t={value:e,source:t,stack:oe(t)},Xr.set(e,t),t)}return{value:e,source:t,stack:oe(t)}}var Zr=[],ea=0,ta=null,na=0,ra=[],aa=0,ia=null,oa=1,sa="";function la(e,t){Zr[ea++]=na,Zr[ea++]=ta,ta=e,na=t}function ca(e,t,n){ra[aa++]=oa,ra[aa++]=sa,ra[aa++]=ia,ia=e;var r=oa;e=sa;var a=32-Ce(r)-1;r&=~(1<<a),n+=1;var i=32-Ce(t)+a;if(30<i){var o=a-a%5;i=(r&(1<<o)-1).toString(32),r>>=o,a-=o,oa=1<<32-Ce(t)+a|n<<a|r,sa=i+e}else oa=1<<i|n<<a|r,sa=e}function ua(e){null!==e.return&&(la(e,1),ca(e,1,0))}function da(e){for(;e===ta;)ta=Zr[--ea],Zr[ea]=null,na=Zr[--ea],Zr[ea]=null;for(;e===ia;)ia=ra[--aa],ra[aa]=null,sa=ra[--aa],ra[aa]=null,oa=ra[--aa],ra[aa]=null}function ma(e,t){ra[aa++]=oa,ra[aa++]=sa,ra[aa++]=ia,oa=t.id,sa=t.overflow,ia=e}var ha=null,pa=null,fa=!1,ga=null,ba=!1,ya=Error(r(519));function va(e){throw ja(Jr(Error(r(418,1<arguments.length&&void 0!==arguments[1]&&arguments[1]?"text":"HTML","")),e)),ya}function xa(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[He]=e,t[Ve]=r,n){case"dialog":ed("cancel",t),ed("close",t);break;case"iframe":case"object":case"embed":ed("load",t);break;case"video":case"audio":for(n=0;n<Xu.length;n++)ed(Xu[n],t);break;case"source":ed("error",t);break;case"img":case"image":case"link":ed("error",t),ed("load",t);break;case"details":ed("toggle",t);break;case"input":ed("invalid",t),St(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case"select":ed("invalid",t);break;case"textarea":ed("invalid",t),Et(t,r.value,r.defaultValue,r.children)}"string"!=typeof(n=r.children)&&"number"!=typeof n&&"bigint"!=typeof n||t.textContent===""+n||!0===r.suppressHydrationWarning||hd(t.textContent,n)?(null!=r.popover&&(ed("beforetoggle",t),ed("toggle",t)),null!=r.onScroll&&ed("scroll",t),null!=r.onScrollEnd&&ed("scrollend",t),null!=r.onClick&&(t.onclick=Lt),t=!0):t=!1,t||va(e,!0)}function wa(e){for(ha=e.return;ha;)switch(ha.tag){case 5:case 31:case 13:return void(ba=!1);case 27:case 3:return void(ba=!0);default:ha=ha.return}}function ka(e){if(e!==ha)return!1;if(!fa)return wa(e),fa=!0,!1;var t,n=e.tag;if((t=3!==n&&27!==n)&&((t=5===n)&&(t=!("form"!==(t=e.type)&&"button"!==t)||Sd(e.type,e.memoizedProps)),t=!t),t&&pa&&va(e),wa(e),13===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(r(317));pa=Rd(e)}else if(31===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(r(317));pa=Rd(e)}else 27===n?(n=pa,zd(e.type)?(e=Od,Od=null,pa=e):pa=n):pa=ha?Dd(e.stateNode.nextSibling):null;return!0}function Sa(){pa=ha=null,fa=!1}function Ca(){var e=ga;return null!==e&&(null===Mc?Mc=e:Mc.push.apply(Mc,e),ga=null),e}function ja(e){null===ga?ga=[e]:ga.push(e)}var Na=B(null),Ea=null,$a=null;function _a(e,t,n){H(Na,t._currentValue),t._currentValue=n}function za(e){e._currentValue=Na.current,W(Na)}function Ta(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 Aa(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),Ta(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),Ta(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 Pa(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;nr(i.pendingProps.value,s.value)||(null!==e?e.push(l):e=[l])}}else if(i===X.current){if(null===(s=i.alternate))throw Error(r(387));s.memoizedState.memoizedState!==i.memoizedState.memoizedState&&(null!==e?e.push(pm):e=[pm])}i=i.return}null!==e&&Aa(t,e,n,a),t.flags|=262144}function Ma(e){for(e=e.firstContext;null!==e;){if(!nr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ia(e){Ea=e,$a=null,null!==(e=e.dependencies)&&(e.firstContext=null)}function La(e){return Oa(Ea,e)}function Da(e,t){return null===Ea&&Ia(e),Oa(e,t)}function Oa(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},null===$a){if(null===e)throw Error(r(308));$a=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else $a=$a.next=t;return n}var Ra="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()})}},Fa=e.unstable_scheduleCallback,Ua=e.unstable_NormalPriority,qa={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ba(){return{controller:new Ra,data:new Map,refCount:0}}function Wa(e){e.refCount--,0===e.refCount&&Fa(Ua,function(){e.controller.abort()})}var Ha=null,Va=0,Ka=0,Ga=null;function Qa(){if(0===--Va&&null!==Ha){null!==Ga&&(Ga.status="fulfilled");var e=Ha;Ha=null,Ka=0,Ga=null;for(var t=0;t<e.length;t++)(0,e[t])()}}var Ya=O.S;O.S=function(e,t){Dc=me(),"object"==typeof t&&null!==t&&"function"==typeof t.then&&function(e,t){if(null===Ha){var n=Ha=[];Va=0,Ka=Vu(),Ga={status:"pending",value:void 0,then:function(e){n.push(e)}}}Va++,t.then(Qa,Qa)}(0,t),null!==Ya&&Ya(e,t)};var Xa=B(null);function Ja(){var e=Xa.current;return null!==e?e:yc.pooledCache}function Za(e,t){H(Xa,null===t?Xa.current:t.pool)}function ei(){var e=Ja();return null===e?null:{parent:qa._currentValue,pool:e}}var ti=Error(r(460)),ni=Error(r(474)),ri=Error(r(542)),ai={then:function(){}};function ii(e){return"fulfilled"===(e=e.status)||"rejected"===e}function oi(e,t,n){switch(void 0===(n=e[n])?e.push(t):n!==t&&(t.then(Lt,Lt),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw ui(e=t.reason),e;default:if("string"==typeof t.status)t.then(Lt,Lt);else{if(null!==(e=yc)&&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 ui(e=t.reason),e}throw li=t,ti}}function si(e){try{return(0,e._init)(e._payload)}catch(t){if(null!==t&&"object"==typeof t&&"function"==typeof t.then)throw li=t,ti;throw t}}var li=null;function ci(){if(null===li)throw Error(r(459));var e=li;return li=null,e}function ui(e){if(e===ti||e===ri)throw Error(r(483))}var di=null,mi=0;function hi(e){var t=mi;return mi+=1,null===di&&(di=[]),oi(di,e,t)}function pi(e,t){t=t.props.ref,e.ref=void 0!==t?t:null}function fi(e,t){if(t.$$typeof===m)throw Error(r(525));throw e=Object.prototype.toString.call(t),Error(r(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function gi(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=Wr(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=Gr(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===g?d(e,t,n.props.children,r,n.key):null!==t&&(t.elementType===a||"object"==typeof a&&null!==a&&a.$$typeof===z&&si(a)===t.type)?(pi(t=i(t,n.props),n),t.return=e,t):(pi(t=Vr(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=Yr(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=Kr(n,e.mode,r,a)).return=e,t):((t=i(t,n)).return=e,t)}function m(e,t,n){if("string"==typeof t&&""!==t||"number"==typeof t||"bigint"==typeof t)return(t=Gr(""+t,e.mode,n)).return=e,t;if("object"==typeof t&&null!==t){switch(t.$$typeof){case h:return pi(n=Vr(t.type,t.key,t.props,null,e.mode,n),t),n.return=e,n;case p:return(t=Yr(t,e.mode,n)).return=e,t;case z:return m(e,t=si(t),n)}if(D(t)||M(t))return(t=Kr(t,e.mode,n,null)).return=e,t;if("function"==typeof t.then)return m(e,hi(t),n);if(t.$$typeof===C)return m(e,Da(e,t),n);fi(e,t)}return null}function f(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 h:return n.key===a?c(e,t,n,r):null;case p:return n.key===a?u(e,t,n,r):null;case z:return f(e,t,n=si(n),r)}if(D(n)||M(n))return null!==a?null:d(e,t,n,r,null);if("function"==typeof n.then)return f(e,t,hi(n),r);if(n.$$typeof===C)return f(e,t,Da(e,n),r);fi(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 h:return c(t,e=e.get(null===r.key?n:r.key)||null,r,a);case p:return u(t,e=e.get(null===r.key?n:r.key)||null,r,a);case z:return b(e,t,n,r=si(r),a)}if(D(r)||M(r))return d(t,e=e.get(n)||null,r,a,null);if("function"==typeof r.then)return b(e,t,n,hi(r),a);if(r.$$typeof===C)return b(e,t,n,Da(t,r),a);fi(t,r)}return null}function y(l,c,u,d){if("object"==typeof u&&null!==u&&u.type===g&&null===u.key&&(u=u.props.children),"object"==typeof u&&null!==u){switch(u.$$typeof){case h:e:{for(var v=u.key;null!==c;){if(c.key===v){if((v=u.type)===g){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&&si(v)===c.type){n(l,c.sibling),pi(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===g?((d=Kr(u.props.children,l.mode,d,u.key)).return=l,l=d):(pi(d=Vr(u.type,u.key,u.props,null,l.mode,d),u),d.return=l,l=d)}return s(l);case p: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=Yr(u,l.mode,d)).return=l,l=d}return s(l);case z:return y(l,c,u=si(u),d)}if(D(u))return function(r,i,s,l){for(var c=null,u=null,d=i,h=i=0,p=null;null!==d&&h<s.length;h++){d.index>h?(p=d,d=null):p=d.sibling;var g=f(r,d,s[h],l);if(null===g){null===d&&(d=p);break}e&&d&&null===g.alternate&&t(r,d),i=o(g,i,h),null===u?c=g:u.sibling=g,u=g,d=p}if(h===s.length)return n(r,d),fa&&la(r,h),c;if(null===d){for(;h<s.length;h++)null!==(d=m(r,s[h],l))&&(i=o(d,i,h),null===u?c=d:u.sibling=d,u=d);return fa&&la(r,h),c}for(d=a(d);h<s.length;h++)null!==(p=b(d,r,h,s[h],l))&&(e&&null!==p.alternate&&d.delete(null===p.key?h:p.key),i=o(p,i,h),null===u?c=p:u.sibling=p,u=p);return e&&d.forEach(function(e){return t(r,e)}),fa&&la(r,h),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,h=s,p=s=0,g=null,y=l.next();null!==h&&!y.done;p++,y=l.next()){h.index>p?(g=h,h=null):g=h.sibling;var v=f(i,h,y.value,c);if(null===v){null===h&&(h=g);break}e&&h&&null===v.alternate&&t(i,h),s=o(v,s,p),null===d?u=v:d.sibling=v,d=v,h=g}if(y.done)return n(i,h),fa&&la(i,p),u;if(null===h){for(;!y.done;p++,y=l.next())null!==(y=m(i,y.value,c))&&(s=o(y,s,p),null===d?u=y:d.sibling=y,d=y);return fa&&la(i,p),u}for(h=a(h);!y.done;p++,y=l.next())null!==(y=b(h,i,p,y.value,c))&&(e&&null!==y.alternate&&h.delete(null===y.key?p:y.key),s=o(y,s,p),null===d?u=y:d.sibling=y,d=y);return e&&h.forEach(function(e){return t(i,e)}),fa&&la(i,p),u}(l,c,u=v.call(u),d)}if("function"==typeof u.then)return y(l,c,hi(u),d);if(u.$$typeof===C)return y(l,c,Da(l,u),d);fi(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=Gr(u,l.mode,d)).return=l,l=d),s(l)):n(l,c)}return function(e,t,n,r){try{mi=0;var a=y(e,t,n,r);return di=null,a}catch(o){if(o===ti||o===ri)throw o;var i=qr(29,o,null,e.mode);return i.lanes=r,i.return=e,i}}}var bi=gi(!0),yi=gi(!1),vi=!1;function xi(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function wi(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 ki(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Si(e,t,n){var r=e.updateQueue;if(null===r)return null;if(r=r.shared,2&bc){var a=r.pending;return null===a?t.next=t:(t.next=a.next,a.next=t),r.pending=t,t=Rr(e),Or(e,null,n),t}return Ir(e,r,t,n),Rr(e)}function Ci(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,4194048&n)){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,Oe(e,n)}}function ji(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 Ni=!1;function Ei(){if(Ni){if(null!==Ga)throw Ga}}function $i(e,t,n,r){Ni=!1;var a=e.updateQueue;vi=!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 u=e.alternate;null!==u&&((s=(u=u.updateQueue).lastBaseUpdate)!==o&&(null===s?u.firstBaseUpdate=c:s.next=c,u.lastBaseUpdate=l))}if(null!==i){var m=a.baseState;for(o=0,u=c=l=null,s=i;;){var h=-536870913&s.lane,p=h!==s.lane;if(p?(xc&h)===h:(r&h)===h){0!==h&&h===Ka&&(Ni=!0),null!==u&&(u=u.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=d({},m,h);break e;case 2:vi=!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===u?(c=u=p,l=m):u=u.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===u&&(l=m),a.baseState=l,a.firstBaseUpdate=c,a.lastBaseUpdate=u,null===i&&(a.shared.lanes=0),$c|=o,e.lanes=o,e.memoizedState=m}}function _i(e,t){if("function"!=typeof e)throw Error(r(191,e));e.call(t)}function zi(e,t){var n=e.callbacks;if(null!==n)for(e.callbacks=null,e=0;e<n.length;e++)_i(n[e],t)}var Ti=B(null),Ai=B(0);function Pi(e,t){H(Ai,e=Nc),H(Ti,t),Nc=e|t.baseLanes}function Mi(){H(Ai,Nc),H(Ti,Ti.current)}function Ii(){Nc=Ai.current,W(Ti),W(Ai)}var Li=B(null),Di=null;function Oi(e){var t=e.alternate;H(Bi,1&Bi.current),H(Li,e),null===Di&&(null===t||null!==Ti.current||null!==t.memoizedState)&&(Di=e)}function Ri(e){H(Bi,Bi.current),H(Li,e),null===Di&&(Di=e)}function Fi(e){22===e.tag?(H(Bi,Bi.current),H(Li,e),null===Di&&(Di=e)):Ui()}function Ui(){H(Bi,Bi.current),H(Li,Li.current)}function qi(e){W(Li),Di===e&&(Di=null),W(Bi)}var Bi=B(0);function Wi(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||Id(n)||Ld(n)))return t}else if(19!==t.tag||"forwards"!==t.memoizedProps.revealOrder&&"backwards"!==t.memoizedProps.revealOrder&&"unstable_legacy-backwards"!==t.memoizedProps.revealOrder&&"together"!==t.memoizedProps.revealOrder){if(null!==t.child){t.child.return=t,t=t.child;continue}}else if(128&t.flags)return t;if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Hi=0,Vi=null,Ki=null,Gi=null,Qi=!1,Yi=!1,Xi=!1,Ji=0,Zi=0,eo=null,to=0;function no(){throw Error(r(321))}function ro(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!nr(e[n],t[n]))return!1;return!0}function ao(e,t,n,r,a,i){return Hi=i,Vi=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,O.H=null===e||null===e.memoizedState?xs:ws,Xi=!1,i=n(r,a),Xi=!1,Yi&&(i=oo(t,n,r,a)),io(e),i}function io(e){O.H=vs;var t=null!==Ki&&null!==Ki.next;if(Hi=0,Gi=Ki=Vi=null,Qi=!1,Zi=0,eo=null,t)throw Error(r(300));null===e||Ds||null!==(e=e.dependencies)&&Ma(e)&&(Ds=!0)}function oo(e,t,n,a){Vi=e;var i=0;do{if(Yi&&(eo=null),Zi=0,Yi=!1,25<=i)throw Error(r(301));if(i+=1,Gi=Ki=null,null!=e.updateQueue){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,null!=o.memoCache&&(o.memoCache.index=0)}O.H=ks,o=t(n,a)}while(Yi);return o}function so(){var e=O.H,t=e.useState()[0];return t="function"==typeof t.then?po(t):t,e=e.useState()[0],(null!==Ki?Ki.memoizedState:null)!==e&&(Vi.flags|=1024),t}function lo(){var e=0!==Ji;return Ji=0,e}function co(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function uo(e){if(Qi){for(e=e.memoizedState;null!==e;){var t=e.queue;null!==t&&(t.pending=null),e=e.next}Qi=!1}Hi=0,Gi=Ki=Vi=null,Yi=!1,Zi=Ji=0,eo=null}function mo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===Gi?Vi.memoizedState=Gi=e:Gi=Gi.next=e,Gi}function ho(){if(null===Ki){var e=Vi.alternate;e=null!==e?e.memoizedState:null}else e=Ki.next;var t=null===Gi?Vi.memoizedState:Gi.next;if(null!==t)Gi=t,Ki=e;else{if(null===e){if(null===Vi.alternate)throw Error(r(467));throw Error(r(310))}e={memoizedState:(Ki=e).memoizedState,baseState:Ki.baseState,baseQueue:Ki.baseQueue,queue:Ki.queue,next:null},null===Gi?Vi.memoizedState=Gi=e:Gi=Gi.next=e}return Gi}function po(e){var t=Zi;return Zi+=1,null===eo&&(eo=[]),e=oi(eo,e,t),t=Vi,null===(null===Gi?t.memoizedState:Gi.next)&&(t=t.alternate,O.H=null===t||null===t.memoizedState?xs:ws),e}function fo(e){if(null!==e&&"object"==typeof e){if("function"==typeof e.then)return po(e);if(e.$$typeof===C)return La(e)}throw Error(r(438,String(e)))}function go(e){var t=null,n=Vi.updateQueue;if(null!==n&&(t=n.memoCache),null==t){var r=Vi.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},Vi.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 bo(e,t){return"function"==typeof t?t(e):t}function yo(e){return vo(ho(),Ki,e)}function vo(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?(xc&m)===m:(Hi&m)===m){var h=u.revertLane;if(0===h)null!==c&&(c=c.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),m===Ka&&(d=!0);else{if((Hi&h)===h){u=u.next,h===Ka&&(d=!0);continue}m={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(l=c=m,s=o):c=c.next=m,Vi.lanes|=h,$c|=h}m=u.action,Xi&&n(o,m),o=u.hasEagerState?u.eagerState:n(o,m)}else h={lane:m,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(l=c=h,s=o):c=c.next=h,Vi.lanes|=m,$c|=m;u=u.next}while(null!==u&&u!==t);if(null===c?s=o:c.next=l,!nr(o,e.memoizedState)&&(Ds=!0,d&&null!==(n=Ga)))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 xo(e){var t=ho(),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);nr(o,t.memoizedState)||(Ds=!0),t.memoizedState=o,null===t.baseQueue&&(t.baseState=o),n.lastRenderedState=o}return[o,a]}function wo(e,t,n){var a=Vi,i=ho(),o=fa;if(o){if(void 0===n)throw Error(r(407));n=n()}else n=t();var s=!nr((Ki||i).memoizedState,n);if(s&&(i.memoizedState=n,Ds=!0),i=i.queue,Vo(Co.bind(null,a,i,e),[e]),i.getSnapshot!==t||s||null!==Gi&&1&Gi.memoizedState.tag){if(a.flags|=2048,Uo(9,{destroy:void 0},So.bind(null,a,i,n,t),null),null===yc)throw Error(r(349));o||127&Hi||ko(a,t,n)}return n}function ko(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=Vi.updateQueue)?(t={lastEffect:null,events:null,stores:null,memoCache:null},Vi.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function So(e,t,n,r){t.value=n,t.getSnapshot=r,jo(t)&&No(e)}function Co(e,t,n){return n(function(){jo(t)&&No(e)})}function jo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!nr(e,n)}catch(r){return!0}}function No(e){var t=Dr(e,2);null!==t&&Jc(t,e,2)}function Eo(e){var t=mo();if("function"==typeof e){var n=e;if(e=n(),Xi){Se(!0);try{n()}finally{Se(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:bo,lastRenderedState:e},t}function $o(e,t,n,r){return e.baseState=n,vo(e,Ki,"function"==typeof r?r:bo)}function _o(e,t,n,a,i){if(gs(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!==O.T?n(!0):o.isTransition=!1,a(o),null===(n=t.pending)?(o.next=t.pending=o,zo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function zo(e,t){var n=t.action,r=t.payload,a=e.state;if(t.isTransition){var i=O.T,o={};O.T=o;try{var s=n(a,r),l=O.S;null!==l&&l(o,s),To(e,t,s)}catch(c){Po(e,t,c)}finally{null!==i&&null!==o.types&&(i.types=o.types),O.T=i}}else try{To(e,t,i=n(a,r))}catch(u){Po(e,t,u)}}function To(e,t,n){null!==n&&"object"==typeof n&&"function"==typeof n.then?n.then(function(n){Ao(e,t,n)},function(n){return Po(e,t,n)}):Ao(e,t,n)}function Ao(e,t,n){t.status="fulfilled",t.value=n,Mo(t),e.state=n,null!==(t=e.pending)&&((n=t.next)===t?e.pending=null:(n=n.next,t.next=n,zo(e,n)))}function Po(e,t,n){var r=e.pending;if(e.pending=null,null!==r){r=r.next;do{t.status="rejected",t.reason=n,Mo(t),t=t.next}while(t!==r)}e.action=null}function Mo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Io(e,t){return t}function Lo(e,t){if(fa){var n=yc.formState;if(null!==n){e:{var r=Vi;if(fa){if(pa){t:{for(var a=pa,i=ba;8!==a.nodeType;){if(!i){a=null;break t}if(null===(a=Dd(a.nextSibling))){a=null;break t}}a="F!"===(i=a.data)||"F"===i?a:null}if(a){pa=Dd(a.nextSibling),r="F!"===a.data;break e}}va(r)}r=!1}r&&(t=n[0])}}return(n=mo()).memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Io,lastRenderedState:t},n.queue=r,n=hs.bind(null,Vi,r),r.dispatch=n,r=Eo(!1),i=fs.bind(null,Vi,!1,r.queue),a={state:t,dispatch:null,action:e,pending:null},(r=mo()).queue=a,n=_o.bind(null,Vi,a,i,n),a.dispatch=n,r.memoizedState=e,[t,n,!1]}function Do(e){return Oo(ho(),Ki,e)}function Oo(e,t,n){if(t=vo(e,t,Io)[0],e=yo(bo)[0],"object"==typeof t&&null!==t&&"function"==typeof t.then)try{var r=po(t)}catch(o){if(o===ti)throw ri;throw o}else r=t;var a=(t=ho()).queue,i=a.dispatch;return n!==t.memoizedState&&(Vi.flags|=2048,Uo(9,{destroy:void 0},Ro.bind(null,a,n),null)),[r,i,e]}function Ro(e,t){e.action=t}function Fo(e){var t=ho(),n=Ki;if(null!==n)return Oo(t,n,e);ho(),t=t.memoizedState;var r=(n=ho()).queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Uo(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},null===(t=Vi.updateQueue)&&(t={lastEffect:null,events:null,stores:null,memoCache:null},Vi.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 qo(){return ho().memoizedState}function Bo(e,t,n,r){var a=mo();Vi.flags|=e,a.memoizedState=Uo(1|t,{destroy:void 0},n,void 0===r?null:r)}function Wo(e,t,n,r){var a=ho();r=void 0===r?null:r;var i=a.memoizedState.inst;null!==Ki&&null!==r&&ro(r,Ki.memoizedState.deps)?a.memoizedState=Uo(t,i,n,r):(Vi.flags|=e,a.memoizedState=Uo(1|t,i,n,r))}function Ho(e,t){Bo(8390656,8,e,t)}function Vo(e,t){Wo(2048,8,e,t)}function Ko(e){var t=ho().memoizedState;return function(e){Vi.flags|=4;var t=Vi.updateQueue;if(null===t)t={lastEffect:null,events:null,stores:null,memoCache:null},Vi.updateQueue=t,t.events=[e];else{var n=t.events;null===n?t.events=[e]:n.push(e)}}({ref:t,nextImpl:e}),function(){if(2&bc)throw Error(r(440));return t.impl.apply(void 0,arguments)}}function Go(e,t){return Wo(4,2,e,t)}function Qo(e,t){return Wo(4,4,e,t)}function Yo(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 Xo(e,t,n){n=null!=n?n.concat([e]):null,Wo(4,4,Yo.bind(null,t,e),n)}function Jo(){}function Zo(e,t){var n=ho();t=void 0===t?null:t;var r=n.memoizedState;return null!==t&&ro(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function es(e,t){var n=ho();t=void 0===t?null:t;var r=n.memoizedState;if(null!==t&&ro(t,r[1]))return r[0];if(r=e(),Xi){Se(!0);try{e()}finally{Se(!1)}}return n.memoizedState=[r,t],r}function ts(e,t,n){return void 0===n||1073741824&Hi&&!(261930&xc)?e.memoizedState=t:(e.memoizedState=n,e=Xc(),Vi.lanes|=e,$c|=e,n)}function ns(e,t,n,r){return nr(n,t)?n:null!==Ti.current?(e=ts(e,n,r),nr(e,t)||(Ds=!0),e):42&Hi&&(!(1073741824&Hi)||261930&xc)?(e=Xc(),Vi.lanes|=e,$c|=e,t):(Ds=!0,e.memoizedState=n)}function rs(e,t,n,r,a){var i=R.p;R.p=0!==i&&8>i?i:8;var o,s,l,c=O.T,u={};O.T=u,fs(e,!1,t,n);try{var d=a(),m=O.S;if(null!==m&&m(u,d),null!==d&&"object"==typeof d&&"function"==typeof d.then)ps(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),Yc());else ps(e,t,r,Yc())}catch(h){ps(e,t,{then:function(){},status:"rejected",reason:h},Yc())}finally{R.p=i,null!==c&&null!==u.types&&(c.types=u.types),O.T=c}}function as(){}function is(e,t,n,a){if(5!==e.tag)throw Error(r(476));var i=os(e).queue;rs(e,i,t,F,null===n?as:function(){return ss(e),n(a)})}function os(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:bo,lastRenderedState:F},next:null}).next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:bo,lastRenderedState:n},next:null},e.memoizedState=t,null!==(e=e.alternate)&&(e.memoizedState=t),t}function ss(e){var t=os(e);null===t.next&&(t=e.alternate.memoizedState),ps(e,t.next.queue,{},Yc())}function ls(){return La(pm)}function cs(){return ho().memoizedState}function us(){return ho().memoizedState}function ds(e){for(var t=e.return;null!==t;){switch(t.tag){case 24:case 3:var n=Yc(),r=Si(t,e=ki(n),n);return null!==r&&(Jc(r,t,n),Ci(r,t,n)),t={cache:Ba()},void(e.payload=t)}t=t.return}}function ms(e,t,n){var r=Yc();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},gs(e)?bs(t,n):null!==(n=Lr(e,t,n,r))&&(Jc(n,e,r),ys(n,t,r))}function hs(e,t,n){ps(e,t,n,Yc())}function ps(e,t,n,r){var a={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(gs(e))bs(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,nr(s,o))return Ir(e,t,a,0),null===yc&&Mr(),!1}catch(l){}if(null!==(n=Lr(e,t,a,r)))return Jc(n,e,r),ys(n,t,r),!0}return!1}function fs(e,t,n,a){if(a={lane:2,revertLane:Vu(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},gs(e)){if(t)throw Error(r(479))}else null!==(t=Lr(e,n,a,2))&&Jc(t,e,2)}function gs(e){var t=e.alternate;return e===Vi||null!==t&&t===Vi}function bs(e,t){Yi=Qi=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ys(e,t,n){if(4194048&n){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,Oe(e,n)}}var vs={readContext:La,use:fo,useCallback:no,useContext:no,useEffect:no,useImperativeHandle:no,useLayoutEffect:no,useInsertionEffect:no,useMemo:no,useReducer:no,useRef:no,useState:no,useDebugValue:no,useDeferredValue:no,useTransition:no,useSyncExternalStore:no,useId:no,useHostTransitionStatus:no,useFormState:no,useActionState:no,useOptimistic:no,useMemoCache:no,useCacheRefresh:no};vs.useEffectEvent=no;var xs={readContext:La,use:fo,useCallback:function(e,t){return mo().memoizedState=[e,void 0===t?null:t],e},useContext:La,useEffect:Ho,useImperativeHandle:function(e,t,n){n=null!=n?n.concat([e]):null,Bo(4194308,4,Yo.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Bo(4194308,4,e,t)},useInsertionEffect:function(e,t){Bo(4,2,e,t)},useMemo:function(e,t){var n=mo();t=void 0===t?null:t;var r=e();if(Xi){Se(!0);try{e()}finally{Se(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=mo();if(void 0!==n){var a=n(t);if(Xi){Se(!0);try{n(t)}finally{Se(!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=ms.bind(null,Vi,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},mo().memoizedState=e},useState:function(e){var t=(e=Eo(e)).queue,n=hs.bind(null,Vi,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Jo,useDeferredValue:function(e,t){return ts(mo(),e,t)},useTransition:function(){var e=Eo(!1);return e=rs.bind(null,Vi,e.queue,!0,!1),mo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var a=Vi,i=mo();if(fa){if(void 0===n)throw Error(r(407));n=n()}else{if(n=t(),null===yc)throw Error(r(349));127&xc||ko(a,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,Ho(Co.bind(null,a,o,e),[e]),a.flags|=2048,Uo(9,{destroy:void 0},So.bind(null,a,o,n,t),null),n},useId:function(){var e=mo(),t=yc.identifierPrefix;if(fa){var n=sa;t="_"+t+"R_"+(n=(oa&~(1<<32-Ce(oa)-1)).toString(32)+n),0<(n=Ji++)&&(t+="H"+n.toString(32)),t+="_"}else t="_"+t+"r_"+(n=to++).toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:ls,useFormState:Lo,useActionState:Lo,useOptimistic:function(e){var t=mo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=fs.bind(null,Vi,!0,n),n.dispatch=t,[e,t]},useMemoCache:go,useCacheRefresh:function(){return mo().memoizedState=ds.bind(null,Vi)},useEffectEvent:function(e){var t=mo(),n={impl:e};return t.memoizedState=n,function(){if(2&bc)throw Error(r(440));return n.impl.apply(void 0,arguments)}}},ws={readContext:La,use:fo,useCallback:Zo,useContext:La,useEffect:Vo,useImperativeHandle:Xo,useInsertionEffect:Go,useLayoutEffect:Qo,useMemo:es,useReducer:yo,useRef:qo,useState:function(){return yo(bo)},useDebugValue:Jo,useDeferredValue:function(e,t){return ns(ho(),Ki.memoizedState,e,t)},useTransition:function(){var e=yo(bo)[0],t=ho().memoizedState;return["boolean"==typeof e?e:po(e),t]},useSyncExternalStore:wo,useId:cs,useHostTransitionStatus:ls,useFormState:Do,useActionState:Do,useOptimistic:function(e,t){return $o(ho(),0,e,t)},useMemoCache:go,useCacheRefresh:us};ws.useEffectEvent=Ko;var ks={readContext:La,use:fo,useCallback:Zo,useContext:La,useEffect:Vo,useImperativeHandle:Xo,useInsertionEffect:Go,useLayoutEffect:Qo,useMemo:es,useReducer:xo,useRef:qo,useState:function(){return xo(bo)},useDebugValue:Jo,useDeferredValue:function(e,t){var n=ho();return null===Ki?ts(n,e,t):ns(n,Ki.memoizedState,e,t)},useTransition:function(){var e=xo(bo)[0],t=ho().memoizedState;return["boolean"==typeof e?e:po(e),t]},useSyncExternalStore:wo,useId:cs,useHostTransitionStatus:ls,useFormState:Fo,useActionState:Fo,useOptimistic:function(e,t){var n=ho();return null!==Ki?$o(n,0,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:go,useCacheRefresh:us};function Ss(e,t,n,r){n=null==(n=n(r,t=e.memoizedState))?t:d({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}ks.useEffectEvent=Ko;var Cs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Yc(),a=ki(r);a.payload=t,null!=n&&(a.callback=n),null!==(t=Si(e,a,r))&&(Jc(t,e,r),Ci(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Yc(),a=ki(r);a.tag=1,a.payload=t,null!=n&&(a.callback=n),null!==(t=Si(e,a,r))&&(Jc(t,e,r),Ci(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Yc(),r=ki(n);r.tag=2,null!=t&&(r.callback=t),null!==(t=Si(e,r,n))&&(Jc(t,e,n),Ci(t,e,n))}};function js(e,t,n,r,a,i,o){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,i,o):!t.prototype||!t.prototype.isPureReactComponent||(!rr(n,r)||!rr(a,i))}function Ns(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&&Cs.enqueueReplaceState(t,t.state,null)}function Es(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=d({},n)),e)void 0===n[a]&&(n[a]=e[a]);return n}function $s(e){zr(e)}function _s(e){console.error(e)}function zs(e){zr(e)}function Ts(e,t){try{(0,e.onUncaughtError)(t.value,{componentStack:t.stack})}catch(n){setTimeout(function(){throw n})}}function As(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 Ps(e,t,n){return(n=ki(n)).tag=3,n.payload={element:null},n.callback=function(){Ts(e,t)},n}function Ms(e){return(e=ki(e)).tag=3,e}function Is(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(){As(t,n,r)}}var o=n.stateNode;null!==o&&"function"==typeof o.componentDidCatch&&(e.callback=function(){As(t,n,r),"function"!=typeof a&&(null===Fc?Fc=new Set([this]):Fc.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:null!==e?e:""})})}var Ls=Error(r(461)),Ds=!1;function Os(e,t,n,r){t.child=null===e?yi(t,null,n,r):bi(t,e.child,n,r)}function Rs(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 Ia(t),r=ao(e,t,n,o,i,a),s=lo(),null===e||Ds?(fa&&s&&ua(t),t.flags|=1,Os(e,t,r,a),t.child):(co(e,t,a),ll(e,t,a))}function Fs(e,t,n,r,a){if(null===e){var i=n.type;return"function"!=typeof i||Br(i)||void 0!==i.defaultProps||null!==n.compare?((e=Vr(n.type,null,r,t,t.mode,a)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=i,Us(e,t,i,r,a))}if(i=e.child,!cl(e,a)){var o=i.memoizedProps;if((n=null!==(n=n.compare)?n:rr)(o,r)&&e.ref===t.ref)return ll(e,t,a)}return t.flags|=1,(e=Wr(i,r)).ref=t.ref,e.return=t,t.child=e}function Us(e,t,n,r,a){if(null!==e){var i=e.memoizedProps;if(rr(i,r)&&e.ref===t.ref){if(Ds=!1,t.pendingProps=r=i,!cl(e,a))return t.lanes=e.lanes,ll(e,t,a);131072&e.flags&&(Ds=!0)}}return Gs(e,t,n,r,a)}function qs(e,t,n,r){var a=r.children,i=null!==e?e.memoizedState:null;if(null===e&&null===t.stateNode&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),"hidden"===r.mode){if(128&t.flags){if(i=null!==i?i.baseLanes|n:n,null!==e){for(r=t.child=e.child,a=0;null!==r;)a=a|r.lanes|r.childLanes,r=r.sibling;r=a&~i}else r=0,t.child=null;return Ws(e,t,i,n,r)}if(!(536870912&n))return r=t.lanes=536870912,Ws(e,t,null!==i?i.baseLanes|n:n,n,r);t.memoizedState={baseLanes:0,cachePool:null},null!==e&&Za(0,null!==i?i.cachePool:null),null!==i?Pi(t,i):Mi(),Fi(t)}else null!==i?(Za(0,i.cachePool),Pi(t,i),Ui(),t.memoizedState=null):(null!==e&&Za(0,null),Mi(),Ui());return Os(e,t,a,n),t.child}function Bs(e,t){return null!==e&&22===e.tag||null!==t.stateNode||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Ws(e,t,n,r,a){var i=Ja();return i=null===i?null:{parent:qa._currentValue,pool:i},t.memoizedState={baseLanes:n,cachePool:i},null!==e&&Za(0,null),Mi(),Fi(t),null!==e&&Pa(e,t,r,!0),t.childLanes=a,null}function Hs(e,t){return(t=rl({mode:t.mode,children:t.children},e.mode)).ref=e.ref,e.child=t,t.return=e,t}function Vs(e,t,n){return bi(t,e.child,null,n),(e=Hs(t,t.pendingProps)).flags|=2,qi(t),t.memoizedState=null,e}function Ks(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 Gs(e,t,n,r,a){return Ia(t),n=ao(e,t,n,r,void 0,a),r=lo(),null===e||Ds?(fa&&r&&ua(t),t.flags|=1,Os(e,t,n,a),t.child):(co(e,t,a),ll(e,t,a))}function Qs(e,t,n,r,a,i){return Ia(t),t.updateQueue=null,n=oo(t,r,n,a),io(e),r=lo(),null===e||Ds?(fa&&r&&ua(t),t.flags|=1,Os(e,t,n,i),t.child):(co(e,t,i),ll(e,t,i))}function Ys(e,t,n,r,a){if(Ia(t),null===t.stateNode){var i=Fr,o=n.contextType;"object"==typeof o&&null!==o&&(i=La(o)),i=new n(r,i),t.memoizedState=null!==i.state&&void 0!==i.state?i.state:null,i.updater=Cs,t.stateNode=i,i._reactInternals=t,(i=t.stateNode).props=r,i.state=t.memoizedState,i.refs={},xi(t),o=n.contextType,i.context="object"==typeof o&&null!==o?La(o):Fr,i.state=t.memoizedState,"function"==typeof(o=n.getDerivedStateFromProps)&&(Ss(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&&Cs.enqueueReplaceState(i,i.state,null),$i(t,r,i,a),Ei(),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=Es(n,s);i.props=l;var c=i.context,u=n.contextType;o=Fr,"object"==typeof u&&null!==u&&(o=La(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)&&Ns(t,i,r,o),vi=!1;var m=t.memoizedState;i.state=m,$i(t,r,i,a),Ei(),c=t.memoizedState,s||m!==c||vi?("function"==typeof d&&(Ss(t,n,d,r),c=t.memoizedState),(l=vi||js(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,wi(e,t),u=Es(n,o=t.memoizedProps),i.props=u,d=t.pendingProps,m=i.context,c=n.contextType,l=Fr,"object"==typeof c&&null!==c&&(l=La(c)),(c="function"==typeof(s=n.getDerivedStateFromProps)||"function"==typeof i.getSnapshotBeforeUpdate)||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(o!==d||m!==l)&&Ns(t,i,r,l),vi=!1,m=t.memoizedState,i.state=m,$i(t,r,i,a),Ei();var h=t.memoizedState;o!==d||m!==h||vi||null!==e&&null!==e.dependencies&&Ma(e.dependencies)?("function"==typeof s&&(Ss(t,n,s,r),h=t.memoizedState),(u=vi||js(t,n,u,r,m,h,l)||null!==e&&null!==e.dependencies&&Ma(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,Ks(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=bi(t,e.child,null,a),t.child=bi(t,null,n,a)):Os(e,t,n,a),t.memoizedState=i.state,e=t.child):e=ll(e,t,a),e}function Xs(e,t,n,r){return Sa(),t.flags|=256,Os(e,t,n,r),t.child}var Js={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Zs(e){return{baseLanes:e,cachePool:ei()}}function el(e,t,n){return e=null!==e?e.childLanes&~n:0,t&&(e|=Tc),e}function tl(e,t,n){var a,i=t.pendingProps,o=!1,s=!!(128&t.flags);if((a=s)||(a=(null===e||null!==e.memoizedState)&&!!(2&Bi.current)),a&&(o=!0,t.flags&=-129),a=!!(32&t.flags),t.flags&=-33,null===e){if(fa){if(o?Oi(t):Ui(),(e=pa)?null!==(e=null!==(e=Md(e,ba))&&"&"!==e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==ia?{id:oa,overflow:sa}:null,retryLane:536870912,hydrationErrors:null},(n=Qr(e)).return=t,t.child=n,ha=t,pa=null):e=null,null===e)throw va(t);return Ld(e)?t.lanes=32:t.lanes=536870912,null}var l=i.children;return i=i.fallback,o?(Ui(),l=rl({mode:"hidden",children:l},o=t.mode),i=Kr(i,o,n,null),l.return=t,i.return=t,l.sibling=i,t.child=l,(i=t.child).memoizedState=Zs(n),i.childLanes=el(e,a,n),t.memoizedState=Js,Bs(null,i)):(Oi(t),nl(t,l))}var c=e.memoizedState;if(null!==c&&null!==(l=c.dehydrated)){if(s)256&t.flags?(Oi(t),t.flags&=-257,t=al(e,t,n)):null!==t.memoizedState?(Ui(),t.child=e.child,t.flags|=128,t=null):(Ui(),l=i.fallback,o=t.mode,i=rl({mode:"visible",children:i.children},o),(l=Kr(l,o,n,null)).flags|=2,i.return=t,l.return=t,i.sibling=l,t.child=i,bi(t,e.child,null,n),(i=t.child).memoizedState=Zs(n),i.childLanes=el(e,a,n),t.memoizedState=Js,t=Bs(null,i));else if(Oi(t),Ld(l)){if(a=l.nextSibling&&l.nextSibling.dataset)var u=a.dgst;a=u,(i=Error(r(419))).stack="",i.digest=a,ja({value:i,source:null,stack:null}),t=al(e,t,n)}else if(Ds||Pa(e,t,n,!1),a=0!==(n&e.childLanes),Ds||a){if(null!==(a=yc)&&(0!==(i=Re(a,n))&&i!==c.retryLane))throw c.retryLane=i,Dr(e,i),Jc(a,e,i),Ls;Id(l)||uu(),t=al(e,t,n)}else Id(l)?(t.flags|=192,t.child=e.child,t=null):(e=c.treeContext,pa=Dd(l.nextSibling),ha=t,fa=!0,ga=null,ba=!1,null!==e&&ma(t,e),(t=nl(t,i.children)).flags|=4096);return t}return o?(Ui(),l=i.fallback,o=t.mode,u=(c=e.child).sibling,(i=Wr(c,{mode:"hidden",children:i.children})).subtreeFlags=65011712&c.subtreeFlags,null!==u?l=Wr(u,l):(l=Kr(l,o,n,null)).flags|=2,l.return=t,i.return=t,i.sibling=l,t.child=i,Bs(null,i),i=t.child,null===(l=e.child.memoizedState)?l=Zs(n):(null!==(o=l.cachePool)?(c=qa._currentValue,o=o.parent!==c?{parent:c,pool:c}:o):o=ei(),l={baseLanes:l.baseLanes|n,cachePool:o}),i.memoizedState=l,i.childLanes=el(e,a,n),t.memoizedState=Js,Bs(e.child,i)):(Oi(t),e=(n=e.child).sibling,(n=Wr(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 nl(e,t){return(t=rl({mode:"visible",children:t},e.mode)).return=e,e.child=t}function rl(e,t){return(e=qr(22,e,null,t)).lanes=0,e}function al(e,t,n){return bi(t,e.child,null,n),(e=nl(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function il(e,t,n){e.lanes|=t;var r=e.alternate;null!==r&&(r.lanes|=t),Ta(e.return,t,n)}function ol(e,t,n,r,a,i){var o=e.memoizedState;null===o?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:a,treeForkCount:i}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=a,o.treeForkCount=i)}function sl(e,t,n){var r=t.pendingProps,a=r.revealOrder,i=r.tail;r=r.children;var o=Bi.current,s=!!(2&o);if(s?(o=1&o|2,t.flags|=128):o&=1,H(Bi,o),Os(e,t,r,n),r=fa?na:0,!s&&null!==e&&128&e.flags)e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&il(e,n,t);else if(19===e.tag)il(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}switch(a){case"forwards":for(n=t.child,a=null;null!==n;)null!==(e=n.alternate)&&null===Wi(e)&&(a=n),n=n.sibling;null===(n=a)?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),ol(t,!1,a,n,i,r);break;case"backwards":case"unstable_legacy-backwards":for(n=null,a=t.child,t.child=null;null!==a;){if(null!==(e=a.alternate)&&null===Wi(e)){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}ol(t,!0,n,null,i,r);break;case"together":ol(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function ll(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),$c|=t.lanes,0===(n&t.childLanes)){if(null===e)return null;if(Pa(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=Wr(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=Wr(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function cl(e,t){return 0!==(e.lanes&t)||!(null===(e=e.dependencies)||!Ma(e))}function ul(e,t,n){if(null!==e)if(e.memoizedProps!==t.pendingProps)Ds=!0;else{if(!(cl(e,n)||128&t.flags))return Ds=!1,function(e,t,n){switch(t.tag){case 3:J(t,t.stateNode.containerInfo),_a(0,qa,e.memoizedState.cache),Sa();break;case 27:case 5:ee(t);break;case 4:J(t,t.stateNode.containerInfo);break;case 10:_a(0,t.type,t.memoizedProps.value);break;case 31:if(null!==t.memoizedState)return t.flags|=128,Ri(t),null;break;case 13:var r=t.memoizedState;if(null!==r)return null!==r.dehydrated?(Oi(t),t.flags|=128,null):0!==(n&t.child.childLanes)?tl(e,t,n):(Oi(t),null!==(e=ll(e,t,n))?e.sibling:null);Oi(t);break;case 19:var a=!!(128&e.flags);if((r=0!==(n&t.childLanes))||(Pa(e,t,n,!1),r=0!==(n&t.childLanes)),a){if(r)return sl(e,t,n);t.flags|=128}if(null!==(a=t.memoizedState)&&(a.rendering=null,a.tail=null,a.lastEffect=null),H(Bi,Bi.current),r)break;return null;case 22:return t.lanes=0,qs(e,t,n,t.pendingProps);case 24:_a(0,qa,e.memoizedState.cache)}return ll(e,t,n)}(e,t,n);Ds=!!(131072&e.flags)}else Ds=!1,fa&&1048576&t.flags&&ca(t,na,t.index);switch(t.lanes=0,t.tag){case 16:e:{var a=t.pendingProps;if(e=si(t.elementType),t.type=e,"function"!=typeof e){if(null!=e){var i=e.$$typeof;if(i===N){t.tag=11,t=Rs(null,t,e,a,n);break e}if(i===_){t.tag=14,t=Fs(null,t,e,a,n);break e}}throw t=L(e)||e,Error(r(306,t,""))}Br(e)?(a=Es(e,a),t.tag=1,t=Ys(null,t,e,a,n)):(t.tag=0,t=Gs(null,t,e,a,n))}return t;case 0:return Gs(e,t,t.type,t.pendingProps,n);case 1:return Ys(e,t,a=t.type,i=Es(a,t.pendingProps),n);case 3:e:{if(J(t,t.stateNode.containerInfo),null===e)throw Error(r(387));a=t.pendingProps;var o=t.memoizedState;i=o.element,wi(e,t),$i(t,a,null,n);var s=t.memoizedState;if(a=s.cache,_a(0,qa,a),a!==o.cache&&Aa(t,[qa],n,!0),Ei(),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=Xs(e,t,a,n);break e}if(a!==i){ja(i=Jr(Error(r(424)),t)),t=Xs(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(pa=Dd(e.firstChild),ha=t,fa=!0,ga=null,ba=!0,n=yi(t,null,a,n),t.child=n;n;)n.flags=-3&n.flags|4096,n=n.sibling}else{if(Sa(),a===i){t=ll(e,t,n);break e}Os(e,t,a,n)}t=t.child}return t;case 26:return Ks(e,t),null===e?(n=Qd(t.type,null,t.pendingProps,null))?t.memoizedState=n:fa||(n=t.type,e=t.pendingProps,(a=xd(Y.current).createElement(n))[He]=t,a[Ve]=e,gd(a,n,e),at(a),t.stateNode=a):t.memoizedState=Qd(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ee(t),null===e&&fa&&(a=t.stateNode=Ud(t.type,t.pendingProps,Y.current),ha=t,ba=!0,i=pa,zd(t.type)?(Od=i,pa=Dd(a.firstChild)):pa=i),Os(e,t,t.pendingProps.children,n),Ks(e,t),null===e&&(t.flags|=4194304),t.child;case 5:return null===e&&fa&&((i=a=pa)&&(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[Je])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=Dd(e.nextSibling)))break}return null}(a,t.type,t.pendingProps,ba))?(t.stateNode=a,ha=t,pa=Dd(a.firstChild),ba=!1,i=!0):i=!1),i||va(t)),ee(t),i=t.type,o=t.pendingProps,s=null!==e?e.memoizedProps:null,a=o.children,Sd(i,o)?a=null:null!==s&&Sd(i,s)&&(t.flags|=32),null!==t.memoizedState&&(i=ao(e,t,so,null,null,n),pm._currentValue=i),Ks(e,t),Os(e,t,a,n),t.child;case 6:return null===e&&fa&&((e=n=pa)&&(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=Dd(e.nextSibling)))return null}return e}(n,t.pendingProps,ba))?(t.stateNode=n,ha=t,pa=null,e=!0):e=!1),e||va(t)),null;case 13:return tl(e,t,n);case 4:return J(t,t.stateNode.containerInfo),a=t.pendingProps,null===e?t.child=bi(t,null,a,n):Os(e,t,a,n),t.child;case 11:return Rs(e,t,t.type,t.pendingProps,n);case 7:return Os(e,t,t.pendingProps,n),t.child;case 8:case 12:return Os(e,t,t.pendingProps.children,n),t.child;case 10:return a=t.pendingProps,_a(0,t.type,a.value),Os(e,t,a.children,n),t.child;case 9:return i=t.type._context,a=t.pendingProps.children,Ia(t),a=a(i=La(i)),t.flags|=1,Os(e,t,a,n),t.child;case 14:return Fs(e,t,t.type,t.pendingProps,n);case 15:return Us(e,t,t.type,t.pendingProps,n);case 19:return sl(e,t,n);case 31:return function(e,t,n){var a=t.pendingProps,i=!!(128&t.flags);if(t.flags&=-129,null===e){if(fa){if("hidden"===a.mode)return e=Hs(t,a),t.lanes=536870912,Bs(null,e);if(Ri(t),(e=pa)?null!==(e=null!==(e=Md(e,ba))&&"&"===e.data?e:null)&&(t.memoizedState={dehydrated:e,treeContext:null!==ia?{id:oa,overflow:sa}:null,retryLane:536870912,hydrationErrors:null},(n=Qr(e)).return=t,t.child=n,ha=t,pa=null):e=null,null===e)throw va(t);return t.lanes=536870912,null}return Hs(t,a)}var o=e.memoizedState;if(null!==o){var s=o.dehydrated;if(Ri(t),i)if(256&t.flags)t.flags&=-257,t=Vs(e,t,n);else{if(null===t.memoizedState)throw Error(r(558));t.child=e.child,t.flags|=128,t=null}else if(Ds||Pa(e,t,n,!1),i=0!==(n&e.childLanes),Ds||i){if(null!==(a=yc)&&0!==(s=Re(a,n))&&s!==o.retryLane)throw o.retryLane=s,Dr(e,s),Jc(a,e,s),Ls;uu(),t=Vs(e,t,n)}else e=o.treeContext,pa=Dd(s.nextSibling),ha=t,fa=!0,ga=null,ba=!1,null!==e&&ma(t,e),(t=Hs(t,a)).flags|=4096;return t}return(e=Wr(e.child,{mode:a.mode,children:a.children})).ref=t.ref,t.child=e,e.return=t,e}(e,t,n);case 22:return qs(e,t,n,t.pendingProps);case 24:return Ia(t),a=La(qa),null===e?(null===(i=Ja())&&(i=yc,o=Ba(),i.pooledCache=o,o.refCount++,null!==o&&(i.pooledCacheLanes|=n),i=o),t.memoizedState={parent:a,cache:i},xi(t),_a(0,qa,i)):(0!==(e.lanes&n)&&(wi(e,t),$i(t,null,null,n),Ei()),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),_a(0,qa,a)):(a=o.cache,_a(0,qa,a),a!==i.cache&&Aa(t,[qa],n,!0))),Os(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function dl(e){e.flags|=4}function ml(e,t,n,r,a){if((t=!!(32&e.mode))&&(t=!1),t){if(e.flags|=16777216,(335544128&a)===a)if(e.stateNode.complete)e.flags|=8192;else{if(!su())throw li=ai,ni;e.flags|=8192}}else e.flags&=-16777217}function hl(e,t){if("stylesheet"!==t.type||4&t.state.loading)e.flags&=-16777217;else if(e.flags|=16777216,!lm(t)){if(!su())throw li=ai,ni;e.flags|=8192}}function pl(e,t){null!==t&&(e.flags|=4),16384&e.flags&&(t=22!==e.tag?Me():536870912,e.lanes|=t,Ac|=t)}function fl(e,t){if(!fa)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 gl(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 bl(e,t,n){var a=t.pendingProps;switch(da(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 1:return gl(t),null;case 3:return n=t.stateNode,a=null,null!==e&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),za(qa),Z(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),null!==e&&null!==e.child||(ka(t)?dl(t):null===e||e.memoizedState.isDehydrated&&!(256&t.flags)||(t.flags|=1024,Ca())),gl(t),null;case 26:var i=t.type,o=t.memoizedState;return null===e?(dl(t),null!==o?(gl(t),hl(t,o)):(gl(t),ml(t,i,0,0,n))):o?o!==e.memoizedState?(dl(t),gl(t),hl(t,o)):(gl(t),t.flags&=-16777217):((e=e.memoizedProps)!==a&&dl(t),gl(t),ml(t,i,0,0,n)),null;case 27:if(te(t),n=Y.current,i=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==a&&dl(t);else{if(!a){if(null===t.stateNode)throw Error(r(166));return gl(t),null}e=G.current,ka(t)?xa(t):(e=Ud(i,a,n),t.stateNode=e,dl(t))}return gl(t),null;case 5:if(te(t),i=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==a&&dl(t);else{if(!a){if(null===t.stateNode)throw Error(r(166));return gl(t),null}if(o=G.current,ka(t))xa(t);else{var s=xd(Y.current);switch(o){case 1:o=s.createElementNS("http://www.w3.org/2000/svg",i);break;case 2:o=s.createElementNS("http://www.w3.org/1998/Math/MathML",i);break;default:switch(i){case"svg":o=s.createElementNS("http://www.w3.org/2000/svg",i);break;case"math":o=s.createElementNS("http://www.w3.org/1998/Math/MathML",i);break;case"script":(o=s.createElement("div")).innerHTML="<script><\/script>",o=o.removeChild(o.firstChild);break;case"select":o="string"==typeof a.is?s.createElement("select",{is:a.is}):s.createElement("select"),a.multiple?o.multiple=!0:a.size&&(o.size=a.size);break;default:o="string"==typeof a.is?s.createElement(i,{is:a.is}):s.createElement(i)}}o[He]=t,o[Ve]=a;e:for(s=t.child;null!==s;){if(5===s.tag||6===s.tag)o.appendChild(s.stateNode);else if(4!==s.tag&&27!==s.tag&&null!==s.child){s.child.return=s,s=s.child;continue}if(s===t)break e;for(;null===s.sibling;){if(null===s.return||s.return===t)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;e:switch(gd(o,i,a),i){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}a&&dl(t)}}return gl(t),ml(t,t.type,null===e||e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&null!=t.stateNode)e.memoizedProps!==a&&dl(t);else{if("string"!=typeof a&&null===t.stateNode)throw Error(r(166));if(e=Y.current,ka(t)){if(e=t.stateNode,n=t.memoizedProps,a=null,null!==(i=ha))switch(i.tag){case 27:case 5:a=i.memoizedProps}e[He]=t,(e=!!(e.nodeValue===n||null!==a&&!0===a.suppressHydrationWarning||hd(e.nodeValue,n)))||va(t,!0)}else(e=xd(e).createTextNode(a))[He]=t,t.stateNode=e}return gl(t),null;case 31:if(n=t.memoizedState,null===e||null!==e.memoizedState){if(a=ka(t),null!==n){if(null===e){if(!a)throw Error(r(318));if(!(e=null!==(e=t.memoizedState)?e.dehydrated:null))throw Error(r(557));e[He]=t}else Sa(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;gl(t),e=!1}else n=Ca(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return 256&t.flags?(qi(t),t):(qi(t),null);if(128&t.flags)throw Error(r(558))}return gl(t),null;case 13:if(a=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(i=ka(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[He]=t}else Sa(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;gl(t),i=!1}else i=Ca(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return 256&t.flags?(qi(t),t):(qi(t),null)}return qi(t),128&t.flags?(t.lanes=n,t):(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),o=null,null!==a.memoizedState&&null!==a.memoizedState.cachePool&&(o=a.memoizedState.cachePool.pool),o!==i&&(a.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),pl(t,t.updateQueue),gl(t),null);case 4:return Z(),null===e&&rd(t.stateNode.containerInfo),gl(t),null;case 10:return za(t.type),gl(t),null;case 19:if(W(Bi),null===(a=t.memoizedState))return gl(t),null;if(i=!!(128&t.flags),null===(o=a.rendering))if(i)fl(a,!1);else{if(0!==Ec||null!==e&&128&e.flags)for(e=t.child;null!==e;){if(null!==(o=Wi(e))){for(t.flags|=128,fl(a,!1),e=o.updateQueue,t.updateQueue=e,pl(t,e),t.subtreeFlags=0,e=n,n=t.child;null!==n;)Hr(n,e),n=n.sibling;return H(Bi,1&Bi.current|2),fa&&la(t,a.treeForkCount),t.child}e=e.sibling}null!==a.tail&&me()>Oc&&(t.flags|=128,i=!0,fl(a,!1),t.lanes=4194304)}else{if(!i)if(null!==(e=Wi(o))){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,pl(t,e),fl(a,!0),null===a.tail&&"hidden"===a.tailMode&&!o.alternate&&!fa)return gl(t),null}else 2*me()-a.renderingStartTime>Oc&&536870912!==n&&(t.flags|=128,i=!0,fl(a,!1),t.lanes=4194304);a.isBackwards?(o.sibling=t.child,t.child=o):(null!==(e=a.last)?e.sibling=o:t.child=o,a.last=o)}return null!==a.tail?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=me(),e.sibling=null,n=Bi.current,H(Bi,i?1&n|2:1&n),fa&&la(t,a.treeForkCount),e):(gl(t),null);case 22:case 23:return qi(t),Ii(),a=null!==t.memoizedState,null!==e?null!==e.memoizedState!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?!!(536870912&n)&&!(128&t.flags)&&(gl(t),6&t.subtreeFlags&&(t.flags|=8192)):gl(t),null!==(n=t.updateQueue)&&pl(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&&W(Xa),null;case 24:return n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),za(qa),gl(t),null;case 25:case 30:return null}throw Error(r(156,t.tag))}function yl(e,t){switch(da(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return za(qa),Z(),65536&(e=t.flags)&&!(128&e)?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return te(t),null;case 31:if(null!==t.memoizedState){if(qi(t),null===t.alternate)throw Error(r(340));Sa()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 13:if(qi(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(r(340));Sa()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return W(Bi),null;case 4:return Z(),null;case 10:return za(t.type),null;case 22:case 23:return qi(t),Ii(),null!==e&&W(Xa),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return za(qa),null;default:return null}}function vl(e,t){switch(da(t),t.tag){case 3:za(qa),Z();break;case 26:case 27:case 5:te(t);break;case 4:Z();break;case 31:null!==t.memoizedState&&qi(t);break;case 13:qi(t);break;case 19:W(Bi);break;case 10:za(t.type);break;case 22:case 23:qi(t),Ii(),null!==e&&W(Xa);break;case 24:za(qa)}}function xl(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){Eu(t,t.return,s)}}function wl(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){Eu(a,l,u)}}}r=r.next}while(r!==i)}}catch(u){Eu(t,t.return,u)}}function kl(e){var t=e.updateQueue;if(null!==t){var n=e.stateNode;try{zi(t,n)}catch(r){Eu(e,e.return,r)}}}function Sl(e,t,n){n.props=Es(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(r){Eu(e,t,r)}}function Cl(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){Eu(e,t,a)}}function jl(e,t){var n=e.ref,r=e.refCleanup;if(null!==n)if("function"==typeof r)try{r()}catch(a){Eu(e,t,a)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof n)try{n(null)}catch(i){Eu(e,t,i)}else n.current=null}function Nl(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){Eu(e,e.return,a)}}function El(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)||pd(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&&pd(e,t,h,p,a,m)}}return void kt(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)||pd(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&&pd(e,t,i,o,a,c)}return t=l,n=s,a=p,void(null!=h?jt(e,!!n,h,!1):!!a!=!!n&&(null!=t?jt(e,!!n,t,!0):jt(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:pd(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&&pd(e,t,s,i,a,o)}return void Nt(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 pd(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 pd(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)&&pd(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:pd(e,t,u,h,a,p)}return;default:if(At(t)){for(var b in n)h=n[b],n.hasOwnProperty(b)&&void 0!==h&&!a.hasOwnProperty(b)&&fd(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||fd(e,t,d,h,a,p);return}}for(var y in n)h=n[y],n.hasOwnProperty(y)&&null!=h&&!a.hasOwnProperty(y)&&pd(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||pd(e,t,m,h,a,p)}(a,e.type,n,t),a[Ve]=t}catch(i){Eu(e,e.return,i)}}function $l(e){return 5===e.tag||3===e.tag||26===e.tag||27===e.tag&&zd(e.type)||4===e.tag}function _l(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||$l(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&&zd(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 zl(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=Lt));else if(4!==r&&(27===r&&zd(e.type)&&(n=e.stateNode,t=null),null!==(e=e.child)))for(zl(e,t,n),e=e.sibling;null!==e;)zl(e,t,n),e=e.sibling}function Tl(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&&zd(e.type)&&(n=e.stateNode),null!==(e=e.child)))for(Tl(e,t,n),e=e.sibling;null!==e;)Tl(e,t,n),e=e.sibling}function Al(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,a=t.attributes;a.length;)t.removeAttributeNode(a[0]);gd(t,r,n),t[He]=e,t[Ve]=n}catch(i){Eu(e,e.return,i)}}var Pl=!1,Ml=!1,Il=!1,Ll="function"==typeof WeakSet?WeakSet:Set,Dl=null;function Ol(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Jl(e,n),4&r&&xl(5,n);break;case 1:if(Jl(e,n),4&r)if(e=n.stateNode,null===t)try{e.componentDidMount()}catch(o){Eu(n,n.return,o)}else{var a=Es(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(a,t,e.__reactInternalSnapshotBeforeUpdate)}catch(s){Eu(n,n.return,s)}}64&r&&kl(n),512&r&&Cl(n,n.return);break;case 3:if(Jl(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{zi(e,t)}catch(o){Eu(n,n.return,o)}}break;case 27:null===t&&4&r&&Al(n);case 26:case 5:Jl(e,n),null===t&&4&r&&Nl(n),512&r&&Cl(n,n.return);break;case 12:Jl(e,n);break;case 31:Jl(e,n),4&r&&Wl(e,n);break;case 13:Jl(e,n),4&r&&Hl(e,n),64&r&&(null!==(e=n.memoizedState)&&(null!==(e=e.dehydrated)&&function(e,t){var n=e.ownerDocument;if("$~"===e.data)e._reactRetry=t;else if("$?"!==e.data||"loading"!==n.readyState)t();else{var r=function(){t(),n.removeEventListener("DOMContentLoaded",r)};n.addEventListener("DOMContentLoaded",r),e._reactRetry=r}}(e,n=Tu.bind(null,n))));break;case 22:if(!(r=null!==n.memoizedState||Pl)){t=null!==t&&null!==t.memoizedState||Ml,a=Pl;var i=Ml;Pl=r,(Ml=t)&&!i?ec(e,n,!!(8772&n.subtreeFlags)):Jl(e,n),Pl=a,Ml=i}break;case 30:break;default:Jl(e,n)}}function Rl(e){var t=e.alternate;null!==t&&(e.alternate=null,Rl(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&Ze(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 Fl=null,Ul=!1;function ql(e,t,n){for(n=n.child;null!==n;)Bl(e,t,n),n=n.sibling}function Bl(e,t,n){if(ke&&"function"==typeof ke.onCommitFiberUnmount)try{ke.onCommitFiberUnmount(we,n)}catch(i){}switch(n.tag){case 26:Ml||jl(n,t),ql(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode).parentNode.removeChild(n);break;case 27:Ml||jl(n,t);var r=Fl,a=Ul;zd(n.type)&&(Fl=n.stateNode,Ul=!1),ql(e,t,n),qd(n.stateNode),Fl=r,Ul=a;break;case 5:Ml||jl(n,t);case 6:if(r=Fl,a=Ul,Fl=null,ql(e,t,n),Ul=a,null!==(Fl=r))if(Ul)try{(9===Fl.nodeType?Fl.body:"HTML"===Fl.nodeName?Fl.ownerDocument.body:Fl).removeChild(n.stateNode)}catch(o){Eu(n,t,o)}else try{Fl.removeChild(n.stateNode)}catch(o){Eu(n,t,o)}break;case 18:null!==Fl&&(Ul?(Td(9===(e=Fl).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,n.stateNode),Gm(e)):Td(Fl,n.stateNode));break;case 4:r=Fl,a=Ul,Fl=n.stateNode.containerInfo,Ul=!0,ql(e,t,n),Fl=r,Ul=a;break;case 0:case 11:case 14:case 15:wl(2,n,t),Ml||wl(4,n,t),ql(e,t,n);break;case 1:Ml||(jl(n,t),"function"==typeof(r=n.stateNode).componentWillUnmount&&Sl(n,t,r)),ql(e,t,n);break;case 21:ql(e,t,n);break;case 22:Ml=(r=Ml)||null!==n.memoizedState,ql(e,t,n),Ml=r;break;default:ql(e,t,n)}}function Wl(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&null!==(e=e.memoizedState))){e=e.dehydrated;try{Gm(e)}catch(n){Eu(t,t.return,n)}}}function Hl(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&(null!==(e=e.memoizedState)&&null!==(e=e.dehydrated))))try{Gm(e)}catch(n){Eu(t,t.return,n)}}function Vl(e,t){var n=function(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return null===t&&(t=e.stateNode=new Ll),t;case 22:return null===(t=(e=e.stateNode)._retryCache)&&(t=e._retryCache=new Ll),t;default:throw Error(r(435,e.tag))}}(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Au.bind(null,e,t);t.then(r,r)}})}function Kl(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(zd(l.type)){Fl=l.stateNode,Ul=!1;break e}break;case 5:Fl=l.stateNode,Ul=!1;break e;case 3:case 4:Fl=l.stateNode.containerInfo,Ul=!0;break e}l=l.return}if(null===Fl)throw Error(r(160));Bl(o,s,i),Fl=null,Ul=!1,null!==(o=i.alternate)&&(o.return=null),i.return=null}if(13886&t.subtreeFlags)for(t=t.child;null!==t;)Ql(t,e),t=t.sibling}var Gl=null;function Ql(e,t){var n=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Kl(t,e),Yl(e),4&a&&(wl(3,e,e.return),xl(3,e),wl(5,e,e.return));break;case 1:Kl(t,e),Yl(e),512&a&&(Ml||null===n||jl(n,n.return)),64&a&&Pl&&(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=Gl;if(Kl(t,e),Yl(e),512&a&&(Ml||null===n||jl(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[Je]||o[He]||"http://www.w3.org/2000/svg"===o.namespaceURI||o.hasAttribute("itemprop"))&&(o=i.createElement(a),i.head.insertBefore(o,i.querySelector("head > title"))),gd(o,a,n),o[He]=e,at(o),a=o;break e;case"link":var s=om("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}gd(o=i.createElement(a),a,n),i.head.appendChild(o);break;case"meta":if(s=om("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}gd(o=i.createElement(a),a,n),i.head.appendChild(o);break;default:throw Error(r(468,a))}o[He]=e,at(o),a=o}e.stateNode=a}else sm(i,e.type,e.stateNode);else e.stateNode=tm(i,a,e.memoizedProps);else o!==a?(null===o?null!==n.stateNode&&(n=n.stateNode).parentNode.removeChild(n):o.count--,null===a?sm(i,e.type,e.stateNode):tm(i,a,e.memoizedProps)):null===a&&null!==e.stateNode&&El(e,e.memoizedProps,n.memoizedProps)}break;case 27:Kl(t,e),Yl(e),512&a&&(Ml||null===n||jl(n,n.return)),null!==n&&4&a&&El(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Kl(t,e),Yl(e),512&a&&(Ml||null===n||jl(n,n.return)),32&e.flags){i=e.stateNode;try{$t(i,"")}catch(f){Eu(e,e.return,f)}}4&a&&null!=e.stateNode&&El(e,i=e.memoizedProps,null!==n?n.memoizedProps:i),1024&a&&(Il=!0);break;case 6:if(Kl(t,e),Yl(e),4&a){if(null===e.stateNode)throw Error(r(162));a=e.memoizedProps,n=e.stateNode;try{n.nodeValue=a}catch(f){Eu(e,e.return,f)}}break;case 3:if(im=null,i=Gl,Gl=Hd(t.containerInfo),Kl(t,e),Gl=i,Yl(e),4&a&&null!==n&&n.memoizedState.isDehydrated)try{Gm(t.containerInfo)}catch(f){Eu(e,e.return,f)}Il&&(Il=!1,Xl(e));break;case 4:a=Gl,Gl=Hd(e.stateNode.containerInfo),Kl(t,e),Yl(e),Gl=a;break;case 12:default:Kl(t,e),Yl(e);break;case 31:case 19:Kl(t,e),Yl(e),4&a&&(null!==(a=e.updateQueue)&&(e.updateQueue=null,Vl(e,a)));break;case 13:Kl(t,e),Yl(e),8192&e.child.flags&&null!==e.memoizedState!=(null!==n&&null!==n.memoizedState)&&(Lc=me()),4&a&&(null!==(a=e.updateQueue)&&(e.updateQueue=null,Vl(e,a)));break;case 22:i=null!==e.memoizedState;var c=null!==n&&null!==n.memoizedState,u=Pl,d=Ml;if(Pl=u||i,Ml=d||c,Kl(t,e),Ml=d,Pl=u,Yl(e),8192&a)e:for(t=e.stateNode,t._visibility=i?-2&t._visibility:1|t._visibility,i&&(null===n||c||Pl||Ml||Zl(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(f){Eu(c,c.return,f)}}}else if(6===t.tag){if(null===n){c=t;try{c.stateNode.nodeValue=i?"":c.memoizedProps}catch(f){Eu(c,c.return,f)}}}else if(18===t.tag){if(null===n){c=t;try{var p=c.stateNode;i?Ad(p,!0):Ad(c.stateNode,!1)}catch(f){Eu(c,c.return,f)}}}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,Vl(e,n))));case 30:case 21:}}function Yl(e){var t=e.flags;if(2&t){try{for(var n,a=e.return;null!==a;){if($l(a)){n=a;break}a=a.return}if(null==n)throw Error(r(160));switch(n.tag){case 27:var i=n.stateNode;Tl(e,_l(e),i);break;case 5:var o=n.stateNode;32&n.flags&&($t(o,""),n.flags&=-33),Tl(e,_l(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;zl(e,_l(e),s);break;default:throw Error(r(161))}}catch(l){Eu(e,e.return,l)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function Xl(e){if(1024&e.subtreeFlags)for(e=e.child;null!==e;){var t=e;Xl(t),5===t.tag&&1024&t.flags&&t.stateNode.reset(),e=e.sibling}}function Jl(e,t){if(8772&t.subtreeFlags)for(t=t.child;null!==t;)Ol(e,t.alternate,t),t=t.sibling}function Zl(e){for(e=e.child;null!==e;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:wl(4,t,t.return),Zl(t);break;case 1:jl(t,t.return);var n=t.stateNode;"function"==typeof n.componentWillUnmount&&Sl(t,t.return,n),Zl(t);break;case 27:qd(t.stateNode);case 26:case 5:jl(t,t.return),Zl(t);break;case 22:null===t.memoizedState&&Zl(t);break;default:Zl(t)}e=e.sibling}}function ec(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:ec(a,i,n),xl(4,i);break;case 1:if(ec(a,i,n),"function"==typeof(a=(r=i).stateNode).componentDidMount)try{a.componentDidMount()}catch(c){Eu(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++)_i(l[a],s)}catch(c){Eu(r,r.return,c)}}n&&64&o&&kl(i),Cl(i,i.return);break;case 27:Al(i);case 26:case 5:ec(a,i,n),n&&null===r&&4&o&&Nl(i),Cl(i,i.return);break;case 12:ec(a,i,n);break;case 31:ec(a,i,n),n&&4&o&&Wl(a,i);break;case 13:ec(a,i,n),n&&4&o&&Hl(a,i);break;case 22:null===i.memoizedState&&ec(a,i,n),Cl(i,i.return);break;case 30:break;default:ec(a,i,n)}t=t.sibling}}function tc(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&&Wa(n))}function nc(e,t){e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Wa(e))}function rc(e,t,n,r){if(10256&t.subtreeFlags)for(t=t.child;null!==t;)ac(e,t,n,r),t=t.sibling}function ac(e,t,n,r){var a=t.flags;switch(t.tag){case 0:case 11:case 15:rc(e,t,n,r),2048&a&&xl(9,t);break;case 1:case 31:case 13:default:rc(e,t,n,r);break;case 3:rc(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&&Wa(e)));break;case 12:if(2048&a){rc(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){Eu(t,t.return,l)}}else rc(e,t,n,r);break;case 23:break;case 22:i=t.stateNode,o=t.alternate,null!==t.memoizedState?2&i._visibility?rc(e,t,n,r):oc(e,t):2&i._visibility?rc(e,t,n,r):(i._visibility|=2,ic(e,t,n,r,!!(10256&t.subtreeFlags)||!1)),2048&a&&tc(o,t);break;case 24:rc(e,t,n,r),2048&a&&nc(t.alternate,t)}}function ic(e,t,n,r,a){for(a=a&&(!!(10256&t.subtreeFlags)||!1),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:ic(i,o,s,l,a),xl(8,o);break;case 23:break;case 22:var u=o.stateNode;null!==o.memoizedState?2&u._visibility?ic(i,o,s,l,a):oc(i,o):(u._visibility|=2,ic(i,o,s,l,a)),a&&2048&c&&tc(o.alternate,o);break;case 24:ic(i,o,s,l,a),a&&2048&c&&nc(o.alternate,o);break;default:ic(i,o,s,l,a)}t=t.sibling}}function oc(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:oc(n,r),2048&a&&tc(r.alternate,r);break;case 24:oc(n,r),2048&a&&nc(r.alternate,r);break;default:oc(n,r)}t=t.sibling}}var sc=8192;function lc(e,t,n){if(e.subtreeFlags&sc)for(e=e.child;null!==e;)cc(e,t,n),e=e.sibling}function cc(e,t,n){switch(e.tag){case 26:lc(e,t,n),e.flags&sc&&null!==e.memoizedState&&function(e,t,n,r){if(!("stylesheet"!==n.type||"string"==typeof r.media&&!1===matchMedia(r.media).matches||4&n.state.loading)){if(null===n.instance){var a=Yd(r.href),i=t.querySelector(Xd(a));if(i)return null!==(t=i._p)&&"object"==typeof t&&"function"==typeof t.then&&(e.count++,e=um.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=i,void at(i);i=t.ownerDocument||t,r=Jd(r),(a=Bd.get(a))&&rm(r,a),at(i=i.createElement("link"));var o=i;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),gd(i,"link",r),n.instance=i}null===e.stylesheets&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(3&n.state.loading)&&(e.count++,n=um.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}(n,Gl,e.memoizedState,e.memoizedProps);break;case 5:default:lc(e,t,n);break;case 3:case 4:var r=Gl;Gl=Hd(e.stateNode.containerInfo),lc(e,t,n),Gl=r;break;case 22:null===e.memoizedState&&(null!==(r=e.alternate)&&null!==r.memoizedState?(r=sc,sc=16777216,lc(e,t,n),sc=r):lc(e,t,n))}}function uc(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 dc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var r=t[n];Dl=r,pc(r,e)}uc(e)}if(10256&e.subtreeFlags)for(e=e.child;null!==e;)mc(e),e=e.sibling}function mc(e){switch(e.tag){case 0:case 11:case 15:dc(e),2048&e.flags&&wl(9,e,e.return);break;case 3:case 12:default:dc(e);break;case 22:var t=e.stateNode;null!==e.memoizedState&&2&t._visibility&&(null===e.return||13!==e.return.tag)?(t._visibility&=-3,hc(e)):dc(e)}}function hc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var r=t[n];Dl=r,pc(r,e)}uc(e)}for(e=e.child;null!==e;){switch((t=e).tag){case 0:case 11:case 15:wl(8,t,t.return),hc(t);break;case 22:2&(n=t.stateNode)._visibility&&(n._visibility&=-3,hc(t));break;default:hc(t)}e=e.sibling}}function pc(e,t){for(;null!==Dl;){var n=Dl;switch(n.tag){case 0:case 11:case 15:wl(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:Wa(n.memoizedState.cache)}if(null!==(r=n.child))r.return=n,Dl=r;else e:for(n=e;null!==Dl;){var a=(r=Dl).sibling,i=r.return;if(Rl(r),r===n){Dl=null;break e}if(null!==a){a.return=i,Dl=a;break e}Dl=i}}}var fc={getCacheForType:function(e){var t=La(qa),n=t.data.get(e);return void 0===n&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return La(qa).controller.signal}},gc="function"==typeof WeakMap?WeakMap:Map,bc=0,yc=null,vc=null,xc=0,wc=0,kc=null,Sc=!1,Cc=!1,jc=!1,Nc=0,Ec=0,$c=0,_c=0,zc=0,Tc=0,Ac=0,Pc=null,Mc=null,Ic=!1,Lc=0,Dc=0,Oc=1/0,Rc=null,Fc=null,Uc=0,qc=null,Bc=null,Wc=0,Hc=0,Vc=null,Kc=null,Gc=0,Qc=null;function Yc(){return 2&bc&&0!==xc?xc&-xc:null!==O.T?Vu():qe()}function Xc(){if(0===Tc)if(536870912&xc&&!fa)Tc=536870912;else{var e=$e;!(3932160&($e<<=1))&&($e=262144),Tc=e}return null!==(e=Li.current)&&(e.flags|=32),Tc}function Jc(e,t,n){(e!==yc||2!==wc&&9!==wc)&&null===e.cancelPendingCommit||(iu(e,0),nu(e,xc,Tc,!1)),Le(e,n),2&bc&&e===yc||(e===yc&&(!(2&bc)&&(_c|=n),4===Ec&&nu(e,xc,Tc,!1)),Ru(e))}function Zc(e,t,n){if(6&bc)throw Error(r(327));for(var a=!n&&!(127&t)&&0===(t&e.expiredLanes)||Ae(e,t),i=a?function(e,t){var n=bc;bc|=2;var a=lu(),i=cu();yc!==e||xc!==t?(Rc=null,Oc=me()+500,iu(e,t)):Cc=Ae(e,t);e:for(;;)try{if(0!==wc&&null!==vc){t=vc;var o=kc;t:switch(wc){case 1:wc=0,kc=null,gu(e,t,o,1);break;case 2:case 9:if(ii(o)){wc=0,kc=null,fu(t);break}t=function(){2!==wc&&9!==wc||yc!==e||(wc=7),Ru(e)},o.then(t,t);break e;case 3:wc=7;break e;case 4:wc=5;break e;case 7:ii(o)?(wc=0,kc=null,fu(t)):(wc=0,kc=null,gu(e,t,o,7));break;case 5:var s=null;switch(vc.tag){case 26:s=vc.memoizedState;case 5:case 27:var l=vc;if(s?lm(s):l.stateNode.complete){wc=0,kc=null;var c=l.sibling;if(null!==c)vc=c;else{var u=l.return;null!==u?(vc=u,bu(u)):vc=null}break t}}wc=0,kc=null,gu(e,t,o,5);break;case 6:wc=0,kc=null,gu(e,t,o,6);break;case 8:au(),Ec=6;break e;default:throw Error(r(462))}}hu();break}catch(d){ou(e,d)}return $a=Ea=null,O.H=a,O.A=i,bc=n,null!==vc?0:(yc=null,xc=0,Mr(),Ec)}(e,t):du(e,t,!0),o=a;;){if(0===i){Cc&&!a&&nu(e,t,0,!1);break}if(n=e.current.alternate,!o||tu(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=Pc;var c=l.current.memoizedState.isDehydrated;if(c&&(iu(l,s).flags|=256),2!==(s=du(l,s,!1))){if(jc&&!c){l.errorRecoveryDisabledLanes|=o,_c|=o,i=4;break e}o=Mc,Mc=i,null!==o&&(null===Mc?Mc=o:Mc.push.apply(Mc,o))}i=s}if(o=!1,2!==i)continue}}if(1===i){iu(e,0),nu(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:nu(a,t,Tc,!Sc);break e;case 2:Mc=null;break;case 3:case 5:break;default:throw Error(r(329))}if((62914560&t)===t&&10<(i=Lc+300-me())){if(nu(a,t,Tc,!Sc),0!==Te(a,0,!0))break e;Wc=t,a.timeoutHandle=jd(eu.bind(null,a,n,Mc,Rc,Ic,t,Tc,_c,Ac,Sc,o,"Throttled",-0,0),i)}else eu(a,n,Mc,Rc,Ic,t,Tc,_c,Ac,Sc,o,null,-0,0)}break}i=du(e,t,!1),o=!1}Ru(e)}function eu(e,t,n,r,a,i,o,s,l,c,u,d,m,h){if(e.timeoutHandle=-1,8192&(d=t.subtreeFlags)||!(16785408&~d)){cc(t,i,d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Lt});var p=(62914560&i)===i?Lc-me():(4194048&i)===i?Dc-me():0;if(null!==(p=function(e,t){return e.stylesheets&&0===e.count&&mm(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&mm(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&0===cm&&(cm=62500*function(){if("function"==typeof performance.getEntriesByType){for(var e=0,t=0,n=performance.getEntriesByType("resource"),r=0;r<n.length;r++){var a=n[r],i=a.transferSize,o=a.initiatorType,s=a.duration;if(i&&s&&bd(o)){for(o=0,s=a.responseEnd,r+=1;r<n.length;r++){var l=n[r],c=l.startTime;if(c>s)break;var u=l.transferSize,d=l.initiatorType;u&&bd(d)&&(o+=u*((l=l.responseEnd)<s?1:(s-c)/(l-c)))}if(--r,t+=8*(i+o)/(a.duration/1e3),10<++e)break}}if(0<e)return t/e/1e6}return navigator.connection&&"number"==typeof(e=navigator.connection.downlink)?e:5}());var a=setTimeout(function(){if(e.waitingForImages=!1,0===e.count&&(e.stylesheets&&mm(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>cm?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(a)}}:null}(d,p)))return Wc=i,e.cancelPendingCommit=p(vu.bind(null,e,t,i,n,r,a,o,s,l,u,d,null,m,h)),void nu(e,i,o,!c)}vu(e,t,i,n,r,a,o,s,l)}function tu(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(!nr(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 nu(e,t,n,r){t&=~zc,t&=~_c,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var a=t;0<a;){var i=31-Ce(a),o=1<<i;r[i]=-1,a&=~o}0!==n&&De(e,n,t)}function ru(){return!!(6&bc)||(Fu(0),!1)}function au(){if(null!==vc){if(0===wc)var e=vc.return;else $a=Ea=null,uo(e=vc),di=null,mi=0,e=vc;for(;null!==e;)vl(e.alternate,e),e=e.return;vc=null}}function iu(e,t){var n=e.timeoutHandle;-1!==n&&(e.timeoutHandle=-1,Nd(n)),null!==(n=e.cancelPendingCommit)&&(e.cancelPendingCommit=null,n()),Wc=0,au(),yc=e,vc=n=Wr(e.current,null),xc=t,wc=0,kc=null,Sc=!1,Cc=Ae(e,t),jc=!1,Ac=Tc=zc=_c=$c=Ec=0,Mc=Pc=null,Ic=!1,8&t&&(t|=32&t);var r=e.entangledLanes;if(0!==r)for(e=e.entanglements,r&=t;0<r;){var a=31-Ce(r),i=1<<a;t|=e[a],r&=~i}return Nc=t,Mr(),n}function ou(e,t){Vi=null,O.H=vs,t===ti||t===ri?(t=ci(),wc=3):t===ni?(t=ci(),wc=4):wc=t===Ls?8:null!==t&&"object"==typeof t&&"function"==typeof t.then?6:1,kc=t,null===vc&&(Ec=1,Ts(e,Jr(t,e.current)))}function su(){var e=Li.current;return null===e||((4194048&xc)===xc?null===Di:!!((62914560&xc)===xc||536870912&xc)&&e===Di)}function lu(){var e=O.H;return O.H=vs,null===e?vs:e}function cu(){var e=O.A;return O.A=fc,e}function uu(){Ec=4,Sc||(4194048&xc)!==xc&&null!==Li.current||(Cc=!0),!(134217727&$c)&&!(134217727&_c)||null===yc||nu(yc,xc,Tc,!1)}function du(e,t,n){var r=bc;bc|=2;var a=lu(),i=cu();yc===e&&xc===t||(Rc=null,iu(e,t)),t=!1;var o=Ec;e:for(;;)try{if(0!==wc&&null!==vc){var s=vc,l=kc;switch(wc){case 8:au(),o=6;break e;case 3:case 2:case 9:case 6:null===Li.current&&(t=!0);var c=wc;if(wc=0,kc=null,gu(e,s,l,c),n&&Cc){o=0;break e}break;default:c=wc,wc=0,kc=null,gu(e,s,l,c)}}mu(),o=Ec;break}catch(u){ou(e,u)}return t&&e.shellSuspendCounter++,$a=Ea=null,bc=r,O.H=a,O.A=i,null===vc&&(yc=null,xc=0,Mr()),o}function mu(){for(;null!==vc;)pu(vc)}function hu(){for(;null!==vc&&!ue();)pu(vc)}function pu(e){var t=ul(e.alternate,e,Nc);e.memoizedProps=e.pendingProps,null===t?bu(e):vc=t}function fu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Qs(n,t,t.pendingProps,t.type,void 0,xc);break;case 11:t=Qs(n,t,t.pendingProps,t.type.render,t.ref,xc);break;case 5:uo(t);default:vl(n,t),t=ul(n,t=vc=Hr(t,Nc),Nc)}e.memoizedProps=e.pendingProps,null===t?bu(e):vc=t}function gu(e,t,n,a){$a=Ea=null,uo(t),di=null,mi=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)&&Pa(t,n,i,!0),null!==(n=Li.current)){switch(n.tag){case 31:case 13:return null===Di?uu():null===n.alternate&&0===Ec&&(Ec=3),n.flags&=-257,n.flags|=65536,n.lanes=i,a===ai?n.flags|=16384:(null===(t=n.updateQueue)?n.updateQueue=new Set([a]):t.add(a),$u(e,a,i)),!1;case 22:return n.flags|=65536,a===ai?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),$u(e,a,i)),!1}throw Error(r(435,n.tag))}return $u(e,a,i),uu(),!1}if(fa)return null!==(t=Li.current)?(!(65536&t.flags)&&(t.flags|=256),t.flags|=65536,t.lanes=i,a!==ya&&ja(Jr(e=Error(r(422),{cause:a}),n))):(a!==ya&&ja(Jr(t=Error(r(423),{cause:a}),n)),(e=e.current.alternate).flags|=65536,i&=-i,e.lanes|=i,a=Jr(a,n),ji(e,i=Ps(e.stateNode,a,i)),4!==Ec&&(Ec=2)),!1;var o=Error(r(520),{cause:a});if(o=Jr(o,n),null===Pc?Pc=[o]:Pc.push(o),4!==Ec&&(Ec=2),null===t)return!0;a=Jr(a,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,ji(n,e=Ps(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!==Fc&&Fc.has(o))))return n.flags|=65536,i&=-i,n.lanes|=i,Is(i=Ms(i),e,n,a),ji(n,i),!1}n=n.return}while(null!==n);return!1}(e,i,t,n,xc))return Ec=1,Ts(e,Jr(n,e.current)),void(vc=null)}catch(o){if(null!==i)throw vc=i,o;return Ec=1,Ts(e,Jr(n,e.current)),void(vc=null)}32768&t.flags?(fa||1===a?e=!0:Cc||536870912&xc?e=!1:(Sc=e=!0,(2===a||9===a||3===a||6===a)&&(null!==(a=Li.current)&&13===a.tag&&(a.flags|=16384))),yu(t,e)):bu(t)}function bu(e){var t=e;do{if(32768&t.flags)return void yu(t,Sc);e=t.return;var n=bl(t.alternate,t,Nc);if(null!==n)return void(vc=n);if(null!==(t=t.sibling))return void(vc=t);vc=t=e}while(null!==t);0===Ec&&(Ec=5)}function yu(e,t){do{var n=yl(e.alternate,e);if(null!==n)return n.flags&=32767,void(vc=n);if(null!==(n=e.return)&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&null!==(e=e.sibling))return void(vc=e);vc=e=n}while(null!==e);Ec=6,vc=null}function vu(e,t,n,a,i,o,s,l,c){e.cancelPendingCommit=null;do{Cu()}while(0!==Uc);if(6&bc)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-Ce(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&&De(e,r,0),0!==i&&0===a&&0!==e.tag&&(e.suspendedLanes|=i&~(o&~t))}(e,n,o|=Pr,s,l,c),e===yc&&(vc=yc=null,xc=0),Bc=t,qc=e,Wc=n,Hc=o,Vc=i,Kc=a,10256&t.subtreeFlags||10256&t.flags?(e.callbackNode=null,e.callbackPriority=0,le(ge,function(){return ju(),null})):(e.callbackNode=null,e.callbackPriority=0),a=!!(13878&t.flags),13878&t.subtreeFlags||a){a=O.T,O.T=null,i=R.p,R.p=2,s=bc,bc|=4;try{!function(e,t){if(e=e.containerInfo,yd=Sm,lr(e=sr(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(vd={focusedElem:e,selectionRange:n},Sm=!1,Dl=t;null!==Dl;)if(e=(t=Dl).child,1028&t.subtreeFlags&&null!==e)e.return=t,Dl=e;else for(;null!==Dl;){switch(o=(t=Dl).alternate,e=t.flags,t.tag){case 0:if(4&e&&null!==(e=null!==(e=t.updateQueue)?e.events:null))for(n=0;n<e.length;n++)(i=e[n]).ref.impl=i.nextImpl;break;case 11:case 15:case 5:case 26:case 27:case 6:case 4:case 17:break;case 1:if(1024&e&&null!==o){e=void 0,n=t,i=o.memoizedProps,o=o.memoizedState,a=n.stateNode;try{var f=Es(n.type,i);e=a.getSnapshotBeforeUpdate(f,o),a.__reactInternalSnapshotBeforeUpdate=e}catch(b){Eu(n,n.return,b)}}break;case 3:if(1024&e)if(9===(n=(e=t.stateNode.containerInfo).nodeType))Pd(e);else if(1===n)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Pd(e);break;default:e.textContent=""}break;default:if(1024&e)throw Error(r(163))}if(null!==(e=t.sibling)){e.return=t.return,Dl=e;break}Dl=t.return}}(e,t)}finally{bc=s,R.p=i,O.T=a}}Uc=1,xu(),wu(),ku()}}function xu(){if(1===Uc){Uc=0;var e=qc,t=Bc,n=!!(13878&t.flags);if(13878&t.subtreeFlags||n){n=O.T,O.T=null;var r=R.p;R.p=2;var a=bc;bc|=4;try{Ql(t,e);var i=vd,o=sr(e.containerInfo),s=i.focusedElem,l=i.selectionRange;if(o!==s&&s&&s.ownerDocument&&or(s.ownerDocument.documentElement,s)){if(null!==l&&lr(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=ir(s,f),y=ir(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}}Sm=!!yd,vd=yd=null}finally{bc=a,R.p=r,O.T=n}}e.current=t,Uc=2}}function wu(){if(2===Uc){Uc=0;var e=qc,t=Bc,n=!!(8772&t.flags);if(8772&t.subtreeFlags||n){n=O.T,O.T=null;var r=R.p;R.p=2;var a=bc;bc|=4;try{Ol(e,t.alternate,t)}finally{bc=a,R.p=r,O.T=n}}Uc=3}}function ku(){if(4===Uc||3===Uc){Uc=0,de();var e=qc,t=Bc,n=Wc,r=Kc;10256&t.subtreeFlags||10256&t.flags?Uc=5:(Uc=0,Bc=qc=null,Su(e,e.pendingLanes));var a=e.pendingLanes;if(0===a&&(Fc=null),Ue(n),t=t.stateNode,ke&&"function"==typeof ke.onCommitFiberRoot)try{ke.onCommitFiberRoot(we,t,void 0,!(128&~t.current.flags))}catch(l){}if(null!==r){t=O.T,a=R.p,R.p=2,O.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{O.T=t,R.p=a}}3&Wc&&Cu(),Ru(e),a=e.pendingLanes,261930&n&&42&a?e===Qc?Gc++:(Gc=0,Qc=e):Gc=0,Fu(0)}}function Su(e,t){0===(e.pooledCacheLanes&=t)&&(null!=(t=e.pooledCache)&&(e.pooledCache=null,Wa(t)))}function Cu(){return xu(),wu(),ku(),ju()}function ju(){if(5!==Uc)return!1;var e=qc,t=Hc;Hc=0;var n=Ue(Wc),a=O.T,i=R.p;try{R.p=32>n?32:n,O.T=null,n=Vc,Vc=null;var o=qc,s=Wc;if(Uc=0,Bc=qc=null,Wc=0,6&bc)throw Error(r(331));var l=bc;if(bc|=4,mc(o.current),ac(o,o.current,s,n),bc=l,Fu(0,!1),ke&&"function"==typeof ke.onPostCommitFiberRoot)try{ke.onPostCommitFiberRoot(we,o)}catch(c){}return!0}finally{R.p=i,O.T=a,Su(e,t)}}function Nu(e,t,n){t=Jr(n,t),null!==(e=Si(e,t=Ps(e.stateNode,t,2),2))&&(Le(e,2),Ru(e))}function Eu(e,t,n){if(3===e.tag)Nu(e,e,n);else for(;null!==t;){if(3===t.tag){Nu(t,e,n);break}if(1===t.tag){var r=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===Fc||!Fc.has(r))){e=Jr(n,e),null!==(r=Si(t,n=Ms(2),2))&&(Is(n,r,t,e),Le(r,2),Ru(r));break}}t=t.return}}function $u(e,t,n){var r=e.pingCache;if(null===r){r=e.pingCache=new gc;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)||(jc=!0,a.add(n),e=_u.bind(null,e,t,n),t.then(e,e))}function _u(e,t,n){var r=e.pingCache;null!==r&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,yc===e&&(xc&n)===n&&(4===Ec||3===Ec&&(62914560&xc)===xc&&300>me()-Lc?!(2&bc)&&iu(e,0):zc|=n,Ac===xc&&(Ac=0)),Ru(e)}function zu(e,t){0===t&&(t=Me()),null!==(e=Dr(e,t))&&(Le(e,t),Ru(e))}function Tu(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),zu(e,n)}function Au(e,t){var n=0;switch(e.tag){case 31: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),zu(e,n)}var Pu=null,Mu=null,Iu=!1,Lu=!1,Du=!1,Ou=0;function Ru(e){e!==Mu&&null===e.next&&(null===Mu?Pu=Mu=e:Mu=Mu.next=e),Lu=!0,Iu||(Iu=!0,$d(function(){6&bc?le(pe,Uu):qu()}))}function Fu(e,t){if(!Du&&Lu){Du=!0;do{for(var n=!1,r=Pu;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-Ce(42|e)+1)-1,i=201326741&(i&=a&~(o&~s))?201326741&i|1:i?2|i:0}0!==i&&(n=!0,Hu(r,i))}else i=xc,!(3&(i=Te(r,r===yc?i:0,null!==r.cancelPendingCommit||-1!==r.timeoutHandle)))||Ae(r,i)||(n=!0,Hu(r,i));r=r.next}}while(n);Du=!1}}function Uu(){qu()}function qu(){Lu=Iu=!1;var e=0;0!==Ou&&function(){var e=window.event;if(e&&"popstate"===e.type)return e!==Cd&&(Cd=e,!0);return Cd=null,!1}()&&(e=Ou);for(var t=me(),n=null,r=Pu;null!==r;){var a=r.next,i=Bu(r,t);0===i?(r.next=null,null===n?Pu=a:n.next=a,null===a&&(Mu=n)):(n=r,(0!==e||3&i)&&(Lu=!0)),r=a}0!==Uc&&5!==Uc||Fu(e),0!==Ou&&(Ou=0)}function Bu(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,i=-62914561&e.pendingLanes;0<i;){var o=31-Ce(i),s=1<<o,l=a[o];-1===l?0!==(s&n)&&0===(s&r)||(a[o]=Pe(s,t)):l<=t&&(e.expiredLanes|=s),i&=~s}if(n=xc,n=Te(e,e===(t=yc)?n:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle),r=e.callbackNode,0===n||e===t&&(2===wc||9===wc)||null!==e.cancelPendingCommit)return null!==r&&null!==r&&ce(r),e.callbackNode=null,e.callbackPriority=0;if(!(3&n)||Ae(e,n)){if((t=n&-n)===e.callbackPriority)return t;switch(null!==r&&ce(r),Ue(n)){case 2:case 8:n=fe;break;case 32:default:n=ge;break;case 268435456:n=ye}return r=Wu.bind(null,e),n=le(n,r),e.callbackPriority=t,e.callbackNode=n,t}return null!==r&&null!==r&&ce(r),e.callbackPriority=2,e.callbackNode=null,2}function Wu(e,t){if(0!==Uc&&5!==Uc)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Cu()&&e.callbackNode!==n)return null;var r=xc;return 0===(r=Te(e,e===yc?r:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle))?null:(Zc(e,r,t),Bu(e,me()),null!=e.callbackNode&&e.callbackNode===n?Wu.bind(null,e):null)}function Hu(e,t){if(Cu())return null;Zc(e,t,!0)}function Vu(){if(0===Ou){var e=Ka;0===e&&(e=Ee,!(261888&(Ee<<=1))&&(Ee=256)),Ou=e}return Ou}function Ku(e){return null==e||"symbol"==typeof e||"boolean"==typeof e?null:"function"==typeof e?e:It(""+e)}function Gu(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 Qu=0;Qu<$r.length;Qu++){var Yu=$r[Qu];_r(Yu.toLowerCase(),"on"+(Yu[0].toUpperCase()+Yu.slice(1)))}_r(xr,"onAnimationEnd"),_r(wr,"onAnimationIteration"),_r(kr,"onAnimationStart"),_r("dblclick","onDoubleClick"),_r("focusin","onFocus"),_r("focusout","onBlur"),_r(Sr,"onTransitionRun"),_r(Cr,"onTransitionStart"),_r(jr,"onTransitionCancel"),_r(Nr,"onTransitionEnd"),lt("onMouseEnter",["mouseout","mouseover"]),lt("onMouseLeave",["mouseout","mouseover"]),lt("onPointerEnter",["pointerout","pointerover"]),lt("onPointerLeave",["pointerout","pointerover"]),st("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),st("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),st("onBeforeInput",["compositionend","keypress","textInput","paste"]),st("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),st("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),st("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Xu="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(" "),Ju=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Xu));function Zu(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){zr(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){zr(u)}a.currentTarget=null,i=l}}}}function ed(e,t){var n=t[Ge];void 0===n&&(n=t[Ge]=new Set);var r=e+"__bubble";n.has(r)||(ad(t,e,2,!1),n.add(r))}function td(e,t,n){var r=0;t&&(r|=4),ad(n,e,r,t)}var nd="_reactListening"+Math.random().toString(36).slice(2);function rd(e){if(!e[nd]){e[nd]=!0,it.forEach(function(t){"selectionchange"!==t&&(Ju.has(t)||td(t,!1,e),td(t,!0,e))});var t=9===e.nodeType?e:e.ownerDocument;null===t||t[nd]||(t[nd]=!0,td("selectionchange",!1,t))}}function ad(e,t,n,r){switch(zm(t)){case 2:var a=Cm;break;case 8:a=jm;break;default:a=Nm}n=a.bind(null,t,n,e),a=void 0,!Vt||"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 id(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=et(l)))return;if(5===(c=s.tag)||6===c||26===c||27===c){r=o=s;continue e}l=l.parentNode}}r=r.return}Bt(function(){var r=o,a=Ot(n),s=[];e:{var l=Er.get(e);if(void 0!==l){var c=sn,u=e;switch(e){case"keypress":if(0===Jt(n))break e;case"keydown":case"keyup":c=kn;break;case"focusin":u="focus",c=hn;break;case"focusout":u="blur",c=hn;break;case"beforeblur":case"afterblur":c=hn;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=dn;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":c=mn;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":c=Cn;break;case xr:case wr:case kr:c=pn;break;case Nr:c=jn;break;case"scroll":case"scrollend":c=cn;break;case"wheel":c=Nn;break;case"copy":case"cut":case"paste":c=fn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=Sn;break;case"toggle":case"beforetoggle":c=En}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=Wt(f,h))&&d.push(od(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===Dt||!(u=n.relatedTarget||n.fromElement)||!et(u)&&!u[Ke])&&(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)?et(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=dn,g="onMouseLeave",h="onMouseEnter",f="mouse","pointerout"!==e&&"pointerover"!==e||(d=Sn,g="onPointerLeave",h="onPointerEnter",f="pointer"),m=null==c?l:nt(c),p=null==u?l:nt(u),(l=new d(g,f+"leave",c,n,a)).target=m,l.relatedTarget=p,g=null,et(a)===r&&((d=new d(h,f+"enter",u,n,a)).target=p,d.relatedTarget=m,g=d),m=g,c&&u)e:{for(d=ld,f=u,p=0,g=h=c;g;g=d(g))p++;g=0;for(var b=f;b;b=d(b))g++;for(;0<p-g;)h=d(h),p--;for(;0<g-p;)f=d(f),g--;for(;p--;){if(h===f||null!==f&&h===f.alternate){d=h;break e}h=d(h),f=d(f)}d=null}else d=null;null!==c&&cd(s,l,c,d,!1),null!==u&&null!==m&&cd(s,m,u,d,!0)}if("select"===(c=(l=r?nt(r):window).nodeName&&l.nodeName.toLowerCase())||"input"===c&&"file"===l.type)var y=Hn;else if(Rn(l))if(Vn)y=tr;else{y=Zn;var v=Jn}else!(c=l.nodeName)||"input"!==c.toLowerCase()||"checkbox"!==l.type&&"radio"!==l.type?r&&At(r.elementType)&&(y=Hn):y=er;switch(y&&(y=y(e,r))?Fn(s,y,n,a):(v&&v(e,l,r),"focusout"===e&&r&&"number"===l.type&&null!=r.memoizedProps.value&&Ct(l,"number",l.value)),v=r?nt(r):window,e){case"focusin":(Rn(v)||"true"===v.contentEditable)&&(ur=v,dr=r,mr=null);break;case"focusout":mr=dr=ur=null;break;case"mousedown":hr=!0;break;case"contextmenu":case"mouseup":case"dragend":hr=!1,pr(s,n,a);break;case"selectionchange":if(cr)break;case"keydown":case"keyup":pr(s,n,a)}var x;if(_n)e:{switch(e){case"compositionstart":var w="onCompositionStart";break e;case"compositionend":w="onCompositionEnd";break e;case"compositionupdate":w="onCompositionUpdate";break e}w=void 0}else Dn?In(e,n)&&(w="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(w="onCompositionStart");w&&(An&&"ko"!==n.locale&&(Dn||"onCompositionStart"!==w?"onCompositionEnd"===w&&Dn&&(x=Xt()):(Qt="value"in(Gt=a)?Gt.value:Gt.textContent,Dn=!0)),0<(v=sd(r,w)).length&&(w=new gn(w,e,null,n,a),s.push({event:w,listeners:v}),x?w.data=x:null!==(x=Ln(n))&&(w.data=x))),(x=Tn?function(e,t){switch(e){case"compositionend":return Ln(t);case"keypress":return 32!==t.which?null:(Mn=!0,Pn);case"textInput":return(e=t.data)===Pn&&Mn?null:e;default:return null}}(e,n):function(e,t){if(Dn)return"compositionend"===e||!_n&&In(e,t)?(e=Xt(),Yt=Qt=Gt=null,Dn=!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 An&&"ko"!==t.locale?null:t.data}}(e,n))&&(0<(w=sd(r,"onBeforeInput")).length&&(v=new gn("onBeforeInput","beforeinput",null,n,a),s.push({event:v,listeners:w}),v.data=x)),function(e,t,n,r,a){if("submit"===t&&n&&n.stateNode===a){var i=Ku((a[Ve]||null).action),o=r.submitter;o&&null!==(t=(t=o[Ve]||null)?Ku(t.formAction):o.getAttribute("formAction"))&&(i=t,o=null);var s=new sn("action","action",null,r,a);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(0!==Ou){var e=o?Gu(a,o):new FormData(a);is(n,{pending:!0,data:e,method:a.method,action:i},null,e)}}else"function"==typeof i&&(s.preventDefault(),e=o?Gu(a,o):new FormData(a),is(n,{pending:!0,data:e,method:a.method,action:i},i,e))},currentTarget:a}]})}}(s,e,r,n,a)}Zu(s,t)})}function od(e,t,n){return{instance:e,listener:t,currentTarget:n}}function sd(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=Wt(e,n))&&r.unshift(od(e,a,i)),null!=(a=Wt(e,t))&&r.push(od(e,a,i))),3===e.tag)return r;e=e.return}return[]}function ld(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag&&27!==e.tag);return e||null}function cd(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=Wt(n,i))&&o.unshift(od(n,c,l)):a||null!=(c=Wt(n,i))&&o.push(od(n,c,l))),n=n.return}0!==o.length&&e.push({event:t,listeners:o})}var ud=/\r\n?/g,dd=/\u0000|\uFFFD/g;function md(e){return("string"==typeof e?e:""+e).replace(ud,"\n").replace(dd,"")}function hd(e,t){return t=md(t),md(e)===t}function pd(e,t,n,a,i,o){switch(n){case"children":"string"==typeof a?"body"===t||"textarea"===t&&""===a||$t(e,a):("number"==typeof a||"bigint"==typeof a)&&"body"!==t&&$t(e,""+a);break;case"className":ht(e,"class",a);break;case"tabIndex":ht(e,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":ht(e,n,a);break;case"style":Tt(e,a,o);break;case"data":if("object"!==t){ht(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=It(""+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&&pd(e,t,"name",i.name,i,null),pd(e,t,"formEncType",i.formEncType,i,null),pd(e,t,"formMethod",i.formMethod,i,null),pd(e,t,"formTarget",i.formTarget,i,null)):(pd(e,t,"encType",i.encType,i,null),pd(e,t,"method",i.method,i,null),pd(e,t,"target",i.target,i,null))),null==a||"symbol"==typeof a||"boolean"==typeof a){e.removeAttribute(n);break}a=It(""+a),e.setAttribute(n,a);break;case"onClick":null!=a&&(e.onclick=Lt);break;case"onScroll":null!=a&&ed("scroll",e);break;case"onScrollEnd":null!=a&&ed("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=It(""+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":ed("beforetoggle",e),ed("toggle",e),mt(e,"popover",a);break;case"xlinkActuate":pt(e,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":pt(e,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":pt(e,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":pt(e,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":pt(e,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":pt(e,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":pt(e,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":pt(e,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":pt(e,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":mt(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])&&mt(e,n=Pt.get(n)||n,a)}}function fd(e,t,n,a,i,o){switch(n){case"style":Tt(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?$t(e,a):("number"==typeof a||"bigint"==typeof a)&&$t(e,""+a);break;case"onScroll":null!=a&&ed("scroll",e);break;case"onScrollEnd":null!=a&&ed("scrollend",e);break;case"onClick":null!=a&&(e.onclick=Lt);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":case"innerText":case"textContent":break;default:ot.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[Ve]||null)?o[n]:null)&&e.removeEventListener(t,o,i),"function"!=typeof a)?n in e?e[n]=a:!0===a?e.setAttribute(n,""):mt(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 gd(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ed("error",e),ed("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:pd(e,t,a,s,n,null)}}return o&&pd(e,t,"srcSet",n.srcSet,n,null),void(i&&pd(e,t,"src",n.src,n,null));case"input":ed("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:pd(e,t,i,d,n,null)}}return void St(e,a,l,c,u,s,o,!1);case"select":for(o in ed("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:pd(e,t,o,l,n,null)}return t=a,n=s,e.multiple=!!i,void(null!=t?jt(e,!!i,t,!1):null!=n&&jt(e,!!i,n,!0));case"textarea":for(s in ed("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:pd(e,t,s,l,n,null)}return void Et(e,i,o,a);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 pd(e,t,c,i,n,null);return;case"dialog":ed("beforetoggle",e),ed("toggle",e),ed("cancel",e),ed("close",e);break;case"iframe":case"object":ed("load",e);break;case"video":case"audio":for(i=0;i<Xu.length;i++)ed(Xu[i],e);break;case"image":ed("error",e),ed("load",e);break;case"details":ed("toggle",e);break;case"embed":case"source":case"link":ed("error",e),ed("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:pd(e,t,u,i,n,null)}return;default:if(At(t)){for(d in n)n.hasOwnProperty(d)&&(void 0!==(i=n[d])&&fd(e,t,d,i,n,void 0));return}}for(l in n)n.hasOwnProperty(l)&&(null!=(i=n[l])&&pd(e,t,l,i,n,null))}function bd(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}var yd=null,vd=null;function xd(e){return 9===e.nodeType?e:e.ownerDocument}function wd(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 kd(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 Sd(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 Cd=null;var jd="function"==typeof setTimeout?setTimeout:void 0,Nd="function"==typeof clearTimeout?clearTimeout:void 0,Ed="function"==typeof Promise?Promise:void 0,$d="function"==typeof queueMicrotask?queueMicrotask:void 0!==Ed?function(e){return Ed.resolve(null).then(e).catch(_d)}:jd;function _d(e){setTimeout(function(){throw e})}function zd(e){return"head"===e}function Td(e,t){var n=t,r=0;do{var a=n.nextSibling;if(e.removeChild(n),a&&8===a.nodeType)if("/$"===(n=a.data)||"/&"===n){if(0===r)return e.removeChild(a),void Gm(t);r--}else if("$"===n||"$?"===n||"$~"===n||"$!"===n||"&"===n)r++;else if("html"===n)qd(e.ownerDocument.documentElement);else if("head"===n){qd(n=e.ownerDocument.head);for(var i=n.firstChild;i;){var o=i.nextSibling,s=i.nodeName;i[Je]||"SCRIPT"===s||"STYLE"===s||"LINK"===s&&"stylesheet"===i.rel.toLowerCase()||n.removeChild(i),i=o}}else"body"===n&&qd(e.ownerDocument.body);n=a}while(n);Gm(t)}function Ad(e,t){var n=e;e=0;do{var r=n.nextSibling;if(1===n.nodeType?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",""===n.getAttribute("style")&&n.removeAttribute("style")):3===n.nodeType&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),r&&8===r.nodeType)if("/$"===(n=r.data)){if(0===e)break;e--}else"$"!==n&&"$?"!==n&&"$~"!==n&&"$!"!==n||e++;n=r}while(n)}function Pd(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":Pd(n),Ze(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if("stylesheet"===n.rel.toLowerCase())continue}e.removeChild(n)}}function Md(e,t){for(;8!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!t)return null;if(null===(e=Dd(e.nextSibling)))return null}return e}function Id(e){return"$?"===e.data||"$~"===e.data}function Ld(e){return"$!"===e.data||"$?"===e.data&&"loading"!==e.ownerDocument.readyState}function Dd(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t||"$~"===t||"&"===t||"F!"===t||"F"===t)break;if("/$"===t||"/&"===t)return null}}return e}var Od=null;function Rd(e){e=e.nextSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("/$"===n||"/&"===n){if(0===t)return Dd(e.nextSibling);t--}else"$"!==n&&"$!"!==n&&"$?"!==n&&"$~"!==n&&"&"!==n||t++}e=e.nextSibling}return null}function Fd(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n||"$~"===n||"&"===n){if(0===t)return e;t--}else"/$"!==n&&"/&"!==n||t++}e=e.previousSibling}return null}function Ud(e,t,n){switch(t=xd(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 qd(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Ze(e)}var Bd=new Map,Wd=new Set;function Hd(e){return"function"==typeof e.getRootNode?e.getRootNode():9===e.nodeType?e:e.ownerDocument}var Vd=R.d;R.d={f:function(){var e=Vd.f(),t=ru();return e||t},r:function(e){var t=tt(e);null!==t&&5===t.tag&&"form"===t.type?ss(t):Vd.r(e)},D:function(e){Vd.D(e),Gd("dns-prefetch",e,null)},C:function(e,t){Vd.C(e,t),Gd("preconnect",e,t)},L:function(e,t,n){Vd.L(e,t,n);var r=Kd;if(r&&e&&t){var a='link[rel="preload"][as="'+wt(t)+'"]';"image"===t&&n&&n.imageSrcSet?(a+='[imagesrcset="'+wt(n.imageSrcSet)+'"]',"string"==typeof n.imageSizes&&(a+='[imagesizes="'+wt(n.imageSizes)+'"]')):a+='[href="'+wt(e)+'"]';var i=a;switch(t){case"style":i=Yd(e);break;case"script":i=Zd(e)}Bd.has(i)||(e=d({rel:"preload",href:"image"===t&&n&&n.imageSrcSet?void 0:e,as:t},n),Bd.set(i,e),null!==r.querySelector(a)||"style"===t&&r.querySelector(Xd(i))||"script"===t&&r.querySelector(em(i))||(gd(t=r.createElement("link"),"link",e),at(t),r.head.appendChild(t)))}},m:function(e,t){Vd.m(e,t);var n=Kd;if(n&&e){var r=t&&"string"==typeof t.as?t.as:"script",a='link[rel="modulepreload"][as="'+wt(r)+'"][href="'+wt(e)+'"]',i=a;switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":i=Zd(e)}if(!Bd.has(i)&&(e=d({rel:"modulepreload",href:e},t),Bd.set(i,e),null===n.querySelector(a))){switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(em(i)))return}gd(r=n.createElement("link"),"link",e),at(r),n.head.appendChild(r)}}},X:function(e,t){Vd.X(e,t);var n=Kd;if(n&&e){var r=rt(n).hoistableScripts,a=Zd(e),i=r.get(a);i||((i=n.querySelector(em(a)))||(e=d({src:e,async:!0},t),(t=Bd.get(a))&&am(e,t),at(i=n.createElement("script")),gd(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){Vd.S(e,t,n);var r=Kd;if(r&&e){var a=rt(r).hoistableStyles,i=Yd(e);t=t||"default";var o=a.get(i);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Xd(i)))s.loading=5;else{e=d({rel:"stylesheet",href:e,"data-precedence":t},n),(n=Bd.get(i))&&rm(e,n);var l=o=r.createElement("link");at(l),gd(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,nm(o,t,r)}o={type:"stylesheet",instance:o,count:1,state:s},a.set(i,o)}}},M:function(e,t){Vd.M(e,t);var n=Kd;if(n&&e){var r=rt(n).hoistableScripts,a=Zd(e),i=r.get(a);i||((i=n.querySelector(em(a)))||(e=d({src:e,async:!0,type:"module"},t),(t=Bd.get(a))&&am(e,t),at(i=n.createElement("script")),gd(i,"link",e),n.head.appendChild(i)),i={type:"script",instance:i,count:1,state:null},r.set(a,i))}}};var Kd="undefined"==typeof document?null:document;function Gd(e,t,n){var r=Kd;if(r&&"string"==typeof t&&t){var a=wt(t);a='link[rel="'+e+'"][href="'+a+'"]',"string"==typeof n&&(a+='[crossorigin="'+n+'"]'),Wd.has(a)||(Wd.add(a),e={rel:e,crossOrigin:n,href:t},null===r.querySelector(a)&&(gd(t=r.createElement("link"),"link",e),at(t),r.head.appendChild(t)))}}function Qd(e,t,n,a){var i,o,s,l,c=(c=Y.current)?Hd(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=Yd(n.href),(a=(n=rt(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=Yd(n.href);var u=rt(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(Xd(e)))&&!u._p&&(d.instance=u,d.state.loading=5),Bd.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},Bd.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}),gd(o,"link",s),at(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=Zd(n),(a=(n=rt(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 Yd(e){return'href="'+wt(e)+'"'}function Xd(e){return'link[rel="stylesheet"]['+e+"]"}function Jd(e){return d({},e,{"data-precedence":e.precedence,precedence:null})}function Zd(e){return'[src="'+wt(e)+'"]'}function em(e){return"script[async]"+e}function tm(e,t,n){if(t.count++,null===t.instance)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+wt(n.href)+'"]');if(a)return t.instance=a,at(a),a;var i=d({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return at(a=(e.ownerDocument||e).createElement("style")),gd(a,"style",i),nm(a,n.precedence,e),t.instance=a;case"stylesheet":i=Yd(n.href);var o=e.querySelector(Xd(i));if(o)return t.state.loading|=4,t.instance=o,at(o),o;a=Jd(n),(i=Bd.get(i))&&rm(a,i),at(o=(e.ownerDocument||e).createElement("link"));var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),gd(o,"link",a),t.state.loading|=4,nm(o,n.precedence,e),t.instance=o;case"script":return o=Zd(n.src),(i=e.querySelector(em(o)))?(t.instance=i,at(i),i):(a=n,(i=Bd.get(o))&&am(a=d({},n),i),at(i=(e=e.ownerDocument||e).createElement("script")),gd(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,nm(a,n.precedence,e));return t.instance}function nm(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 rm(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.title&&(e.title=t.title)}function am(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.integrity&&(e.integrity=t.integrity)}var im=null;function om(e,t,n){if(null===im){var r=new Map,a=im=new Map;a.set(n,r)}else(r=(a=im).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[Je]||i[He]||"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 sm(e,t,n){(e=e.ownerDocument||e).head.insertBefore(n,"title"===t?e.querySelector("head > title"):null)}function lm(e){return!!("stylesheet"!==e.type||3&e.state.loading)}var cm=0;function um(){if(this.count--,0===this.count&&(0===this.imgCount||!this.waitingForImages))if(this.stylesheets)mm(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}var dm=null;function mm(e,t){e.stylesheets=null,null!==e.unsuspend&&(e.count++,dm=new Map,t.forEach(hm,e),dm=null,um.call(e))}function hm(e,t){if(!(4&t.state.loading)){var n=dm.get(e);if(n)var r=n.get(null);else{n=new Map,dm.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=um.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 pm={$$typeof:C,Provider:null,Consumer:null,_currentValue:F,_currentValue2:F,_threadCount:0};function fm(e,t,n,r,a,i,o,s,l){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=Ie(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ie(0),this.hiddenUpdates=Ie(null),this.identifierPrefix=r,this.onUncaughtError=a,this.onCaughtError=i,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=l,this.incompleteTransitions=new Map}function gm(e,t,n,r,a,i,o,s,l,c,u,d){return e=new fm(e,t,n,o,l,c,u,d,s),t=1,!0===i&&(t|=24),i=qr(3,null,null,t),e.current=i,i.stateNode=e,(t=Ba()).refCount++,e.pooledCache=t,t.refCount++,i.memoizedState={element:r,isDehydrated:n,cache:t},xi(i),e}function bm(e){return e?e=Fr:Fr}function ym(e,t,n,r,a,i){a=bm(a),null===r.context?r.context=a:r.pendingContext=a,(r=ki(t)).payload={element:n},null!==(i=void 0===i?null:i)&&(r.callback=i),null!==(n=Si(e,r,t))&&(Jc(n,0,t),Ci(n,e,t))}function vm(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function xm(e,t){vm(e,t),(e=e.alternate)&&vm(e,t)}function wm(e){if(13===e.tag||31===e.tag){var t=Dr(e,67108864);null!==t&&Jc(t,0,67108864),xm(e,67108864)}}function km(e){if(13===e.tag||31===e.tag){var t=Yc(),n=Dr(e,t=Fe(t));null!==n&&Jc(n,0,t),xm(e,t)}}var Sm=!0;function Cm(e,t,n,r){var a=O.T;O.T=null;var i=R.p;try{R.p=2,Nm(e,t,n,r)}finally{R.p=i,O.T=a}}function jm(e,t,n,r){var a=O.T;O.T=null;var i=R.p;try{R.p=8,Nm(e,t,n,r)}finally{R.p=i,O.T=a}}function Nm(e,t,n,r){if(Sm){var a=Em(r);if(null===a)id(e,t,r,$m,n),Rm(e,r);else if(function(e,t,n,r,a){switch(t){case"focusin":return Am=Fm(Am,e,t,n,r,a),!0;case"dragenter":return Pm=Fm(Pm,e,t,n,r,a),!0;case"mouseover":return Mm=Fm(Mm,e,t,n,r,a),!0;case"pointerover":var i=a.pointerId;return Im.set(i,Fm(Im.get(i)||null,e,t,n,r,a)),!0;case"gotpointercapture":return i=a.pointerId,Lm.set(i,Fm(Lm.get(i)||null,e,t,n,r,a)),!0}return!1}(a,e,t,n,r))r.stopPropagation();else if(Rm(e,r),4&t&&-1<Om.indexOf(e)){for(;null!==a;){var i=tt(a);if(null!==i)switch(i.tag){case 3:if((i=i.stateNode).current.memoizedState.isDehydrated){var o=ze(i.pendingLanes);if(0!==o){var s=i;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var l=1<<31-Ce(o);s.entanglements[1]|=l,o&=~l}Ru(i),!(6&bc)&&(Oc=me()+500,Fu(0))}}break;case 31:case 13:null!==(s=Dr(i,2))&&Jc(s,0,2),ru(),xm(i,2)}if(null===(i=Em(r))&&id(e,t,r,$m,n),i===a)break;a=i}null!==a&&r.stopPropagation()}else id(e,t,r,null,n)}}function Em(e){return _m(e=Ot(e))}var $m=null;function _m(e){if($m=null,null!==(e=et(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(31===n){if(null!==(e=s(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 $m=e,null}function zm(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(he()){case pe:return 2;case fe:return 8;case ge:case be:return 32;case ye:return 268435456;default:return 32}default:return 32}}var Tm=!1,Am=null,Pm=null,Mm=null,Im=new Map,Lm=new Map,Dm=[],Om="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 Rm(e,t){switch(e){case"focusin":case"focusout":Am=null;break;case"dragenter":case"dragleave":Pm=null;break;case"mouseover":case"mouseout":Mm=null;break;case"pointerover":case"pointerout":Im.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Lm.delete(t.pointerId)}}function Fm(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=tt(t))&&wm(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,null!==a&&-1===t.indexOf(a)&&t.push(a),e)}function Um(e){var t=et(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 Be(e.priority,function(){km(n)})}else if(31===t){if(null!==(t=s(n)))return e.blockedOn=t,void Be(e.priority,function(){km(n)})}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function qm(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=Em(e.nativeEvent);if(null!==n)return null!==(t=tt(n))&&wm(t),e.blockedOn=n,!1;var r=new(n=e.nativeEvent).constructor(n.type,n);Dt=r,n.target.dispatchEvent(r),Dt=null,t.shift()}return!0}function Bm(e,t,n){qm(e)&&n.delete(t)}function Wm(){Tm=!1,null!==Am&&qm(Am)&&(Am=null),null!==Pm&&qm(Pm)&&(Pm=null),null!==Mm&&qm(Mm)&&(Mm=null),Im.forEach(Bm),Lm.forEach(Bm)}function Hm(t,n){t.blockedOn===n&&(t.blockedOn=null,Tm||(Tm=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Wm)))}var Vm=null;function Km(t){Vm!==t&&(Vm=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Vm===t&&(Vm=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===_m(r||n))continue;break}var i=tt(n);null!==i&&(t.splice(e,3),e-=3,is(i,{pending:!0,data:a,method:n.method,action:r},r,a))}}))}function Gm(e){function t(t){return Hm(t,e)}null!==Am&&Hm(Am,e),null!==Pm&&Hm(Pm,e),null!==Mm&&Hm(Mm,e),Im.forEach(t),Lm.forEach(t);for(var n=0;n<Dm.length;n++){var r=Dm[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Dm.length&&null===(n=Dm[0]).blockedOn;)Um(n),null===n.blockedOn&&Dm.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[Ve]||null;if("function"==typeof i)o||Km(n);else if(o){var s=null;if(i&&i.hasAttribute("formAction")){if(a=i,o=i[Ve]||null)s=o.formAction;else if(null!==_m(a))continue}else s=o.action;"function"==typeof s?n[r+1]=s:(n.splice(r,3),r-=3),Km(n)}}}function Qm(){function e(e){e.canIntercept&&"react-transition"===e.info&&e.intercept({handler:function(){return new Promise(function(e){return a=e})},focusReset:"manual",scroll:"manual"})}function t(){null!==a&&(a(),a=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&null!=e.url&&navigation.navigate(e.url,{state:e.getState(),info:"react-transition",history:"replace"})}}if("object"==typeof navigation){var r=!1,a=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),null!==a&&(a(),a=null)}}}function Ym(e){this._internalRoot=e}function Xm(e){this._internalRoot=e}Xm.prototype.render=Ym.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(r(409));ym(t.current,Yc(),e,t,null,null)},Xm.prototype.unmount=Ym.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;ym(e.current,2,null,e,null,null),ru(),t[Ke]=null}},Xm.prototype.unstable_scheduleHydration=function(e){if(e){var t=qe();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Dm.length&&0!==t&&t<Dm[n].priority;n++);Dm.splice(n,0,e),0===n&&Um(e)}};var Jm=t.version;if("19.2.3"!==Jm)throw Error(r(527,Jm,"19.2.3"));R.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 s=o.alternate;if(null===s){if(null!==(a=o.return)){n=a;continue}break}if(o.child===s.child){for(s=o.child;s;){if(s===n)return l(o),e;if(s===a)return l(o),t;s=s.sibling}throw Error(r(188))}if(n.return!==a.return)n=o,a=s;else{for(var c=!1,u=o.child;u;){if(u===n){c=!0,n=o,a=s;break}if(u===a){c=!0,a=o,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,a=o;break}if(u===a){c=!0,a=s,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?u(e):null)?null:e.stateNode};var Zm={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:O,reconcilerVersion:"19.2.3"};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var eh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!eh.isDisabled&&eh.supportsFiber)try{we=eh.inject(Zm),ke=eh}catch(nh){}}return f.createRoot=function(e,t){if(!a(e))throw Error(r(299));var n=!1,i="",o=$s,s=_s,l=zs;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)),t=gm(e,1,!1,null,0,n,i,null,o,s,l,Qm),e[Ke]=t.current,rd(e),new Ym(t)},f.hydrateRoot=function(e,t,n){if(!a(e))throw Error(r(299));var i=!1,o="",s=$s,l=_s,c=zs,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.formState&&(u=n.formState)),(t=gm(e,1,!0,t,0,i,o,u,s,l,c,Qm)).context=bm(null),n=t.current,(o=ki(i=Fe(i=Yc()))).callback=null,Si(n,o,i),n=i,t.current.lanes=n,Le(t,n),Ru(t),e[Ke]=t.current,rd(e),new Xm(t)},f.version="19.2.3",f}var E,$,_=(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(E)return T;E=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(),i=["limbo-tabs","flex","gap-4","border-b-2","border-brand-blue-200","mb-6",r&&"overflow-x-auto scrollbar-none"].filter(Boolean).join(" "),o=e=>{const t=["limbo-tab","relative","px-6","py-2","font-medium","text-brand-blue-1000","bg-transparent","border-0","border-b-2","cursor-pointer","transition-all","duration-200","hover:text-pink-1000","focus:outline-none","focus-visible:ring-2","focus-visible:ring-brand-blue-400","focus-visible:ring-offset-2"];return e?t.push("border-b-brand-blue-1000","font-semibold","limbo-active"):t.push("border-b-transparent"),r&&t.push("min-w-[120px]","min-h-[44px]","text-base","shrink-0"),a&&t.push("touch-manipulation"),t.join(" ")};return A.jsx("div",{className:i,role:"tablist","aria-label":"Opciones de navegación",style:r?{WebkitOverflowScrolling:"touch",scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,children:e.map(r=>{const i=t===r.id;return!i&&r.hideNonActive?null:A.jsx("button",{"data-tab-id":r.id,onClick:()=>n(r.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,r.id),className:o(i),role:"tab","aria-selected":i,"aria-controls":`tabpanel-${r.id}`,tabIndex:i?0:-1,id:`tab-${r.id}`,style:a?{WebkitTapHighlightColor:"transparent"}:void 0,children:r.label},r.id)})})}const L="https://led-dev-limbo-dev.eu.els.local",D="https://limbo.lefebvre.es";let O={publicKey:null,token:null,authMode:null,tokenEndpoint:null,tokenProvider:null,prod:!1};function R({prod:e=!1}={}){return e?D: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||O.prod,c=await async function({isFormData:e=!1,useJWT:t=!0,customHeaders:n={}}={}){const r={"Access-Control-Allow-Origin":`${window.location.hostname||"*"}`};e||(r["Content-Type"]="application/json");let a=O.token;if(t){if("jwt"===O.authMode&&O.tokenProvider&&!a)try{console.log("🔑 Calling tokenProvider..."),a=await O.tokenProvider(),console.log("✅ Token obtained from tokenProvider"),O.token=a}catch(i){throw console.error("❌ tokenProvider failed:",i),new Error("Failed to obtain token from tokenProvider: "+i.message)}else if("session"===O.authMode&&!a)try{const e=R(O),t=O.tokenEndpoint||"/auth/token",n=await fetch(`${e}${t}`,{method:"POST",headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":`${window.location.hostname||"*"}`},body:JSON.stringify({public_key:O.publicKey}),credentials:"include"});if(!n.ok)throw new Error(`Session auth failed: ${n.status}`);a=(await n.json()).token,O.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:O.authMode,hasPublicKey:!!O.publicKey,hasTokenProvider:!!O.tokenProvider})}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(`${R({prod:l})}${a}${e}`,{method:t,headers:c,body:n?o?n:JSON.stringify(n):void 0,credentials:"include"});if(204===u.status)return{success:!0,data:null,message:"No content",httpCode:204,timestamp:(new Date).toISOString()};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={...O};return e?.prod||!1?"https://limbo.lefebvre.es":"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 W(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 H(e){if(!e?.success||!e?.data)return{result:null};const t=e.data;if("sync"===t.processing_mode&&t.variants&&t.variants.length>0){const e=t.variants[0];return{result:{id:e.id||null,name:e.name,width:parseInt(e.size?.split("x")[0])||e.width,height:parseInt(e.size?.split("x")[1])||e.height,format:e.format,file_size:e.file_size,url:e.url,status:e.status,asset_id:t.asset_id,created_at:e.created_at||(new Date).toISOString(),all_variants:t.variants}}}return{result:{job_id:t.job_id,asset_id:t.asset_id,variants_requested:t.variants_requested||[],processing_mode:t.processing_mode||"async",estimated_completion:t.estimated_completion,variant_statuses:(t.variant_statuses||t.variants||[]).map(e=>({name:e.name,status:e.status,size:e.expected_size||e.size,format:e.format}))}}}function V(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 K="/api";async function G(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&&(W(e.variants)||W(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:K,useJWT:!0}))}catch(t){throw V(t)}}async function Q(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:K,isFormData:!0,useJWT:!0}))}catch(r){throw V(r)}}async function Y(e){try{const n=await F({endpoint:`/assets/${e}/variants`,method:"GET",basePath:K,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 V(n)}var t}function X(){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 Y(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:K,useJWT:!0})}catch(n){throw V(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 J({src:e,alt:t="Imagen",title:n="",subtitle:r="",onClose:a,isOpen:i=!1}){const[o,s]=u.useState(1),[l,c]=u.useState({x:0,y:0}),[d,m]=u.useState(!1),[h,p]=u.useState(!1),[f,g]=u.useState({x:0,y:0}),[b,y]=u.useState(!1),[v,x]=u.useState(!1),w=u.useRef(null),k=u.useRef(null);u.useEffect(()=>{i&&(s(1),c({x:0,y:0}),y(!1),x(!1))},[i]);const S=u.useCallback(()=>{s(e=>Math.min(e+.25,5)),c({x:0,y:0})},[]),C=u.useCallback(()=>{s(e=>Math.max(e-.25,.25)),c({x:0,y:0})},[]),j=u.useCallback(()=>{s(1),c({x:0,y:0})},[]),N=u.useCallback(()=>{s(1),c({x:0,y:0})},[]),E=u.useCallback(e=>{if("Escape"===e.key)return e.preventDefault(),void a?.();if((e.ctrlKey||e.metaKey)&&("+"===e.key||"="===e.key))return e.preventDefault(),void S();if((e.ctrlKey||e.metaKey)&&"-"===e.key)return e.preventDefault(),void C();if((e.ctrlKey||e.metaKey)&&"0"===e.key)return e.preventDefault(),void j();if(o>1){const t=50;switch(e.key){case"ArrowUp":e.preventDefault(),c(e=>({...e,y:e.y+t}));break;case"ArrowDown":e.preventDefault(),c(e=>({...e,y:e.y-t}));break;case"ArrowLeft":e.preventDefault(),c(e=>({...e,x:e.x+t}));break;case"ArrowRight":e.preventDefault(),c(e=>({...e,x:e.x-t}))}}},[a,S,C,j,o]),$=u.useCallback(e=>{(e.ctrlKey||e.metaKey)&&(e.preventDefault(),e.deltaY<0?S():C())},[S,C]),_=u.useCallback(e=>{o>1&&0===e.button&&(e.preventDefault(),m(!0),p(!1),g({x:e.clientX-l.x,y:e.clientY-l.y}))},[o,l]),z=u.useCallback(e=>{d&&(p(!0),c({x:e.clientX-f.x,y:e.clientY-f.y}))},[d,f]),T=u.useCallback(()=>{m(!1)},[]),P=u.useCallback(e=>{e.stopPropagation(),1!==o||h||(s(2),c({x:0,y:0})),p(!1)},[o,h]),M=u.useCallback(e=>{e.stopPropagation(),1===o?(s(2),c({x:0,y:0})):j()},[o,j]);if(u.useEffect(()=>{if(!i)return;document.addEventListener("keydown",E),document.addEventListener("mouseup",T),document.addEventListener("mousemove",z);const e=e=>{!e.ctrlKey&&!e.metaKey||"+"!==e.key&&"-"!==e.key&&"="!==e.key&&"0"!==e.key||e.preventDefault()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",E),document.removeEventListener("mouseup",T),document.removeEventListener("mousemove",z),document.removeEventListener("keydown",e)}},[i,E,T,z]),u.useEffect(()=>(document.body.style.overflow=i?"hidden":"",()=>{document.body.style.overflow=""}),[i]),!i)return null;const I=Math.round(100*o);return A.jsxs("div",{className:"fixed inset-0 bg-black/95 z-[10000] flex flex-col",role:"dialog","aria-modal":"true","aria-label":"Visor de imagen",children:[A.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-black/50 backdrop-blur-sm",children:[A.jsxs("div",{className:"flex-1 min-w-0",children:[n&&A.jsx("h2",{className:"text-white font-medium text-sm truncate",children:n.split(".")[0]}),r&&A.jsx("p",{className:"text-gray-400 text-xs mt-0.5 truncate",children:r})]}),A.jsxs("div",{className:"flex items-center gap-2 mx-4",children:[A.jsx("button",{type:"button",onClick:C,disabled:o<=.25,className:"w-8 h-8 flex items-center justify-center rounded-lg bg-white/10 hover:bg-white/20 text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors","aria-label":"Reducir zoom",title:"Reducir zoom (Ctrl -)",children:A.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})}),A.jsxs("div",{className:"w-20 text-center text-white text-sm font-medium bg-white/10 rounded-lg px-2 py-1.5 cursor-pointer hover:bg-white/20 transition-colors",onClick:j,title:"Click para restablecer zoom",role:"button",tabIndex:0,onKeyDown:e=>"Enter"===e.key&&j(),children:[I,"%"]}),A.jsx("button",{type:"button",onClick:S,disabled:o>=5,className:"w-8 h-8 flex items-center justify-center rounded-lg bg-white/10 hover:bg-white/20 text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors","aria-label":"Aumentar zoom",title:"Aumentar zoom (Ctrl +)",children:A.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),A.jsx("button",{type:"button",onClick:N,className:"w-8 h-8 flex items-center justify-center rounded-lg bg-white/10 hover:bg-white/20 text-white transition-colors ml-2","aria-label":"Ajustar a pantalla",title:"Ajustar a pantalla (Ctrl 0)",children:A.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})})]}),A.jsx("button",{type:"button",onClick:a,className:"w-10 h-10 flex items-center justify-center rounded-lg bg-white/10 hover:bg-red-1000/80 text-white transition-colors","aria-label":"Cerrar visor (ESC)",title:"Cerrar (ESC)",children:A.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),A.jsxs("div",{ref:w,className:`flex-1 overflow-hidden flex items-center justify-center ${o>1?"cursor-grab":"cursor-zoom-in"} ${d?"cursor-grabbing":""}`,onClick:e=>{e.target===w.current&&a?.()},onWheel:$,onMouseDown:_,children:[!b&&!v&&A.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:A.jsx("div",{className:"w-12 h-12 border-4 border-white/20 border-t-white rounded-full animate-spin"})}),v&&A.jsxs("div",{className:"text-center text-white",children:[A.jsx("svg",{className:"w-16 h-16 mx-auto mb-4 text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",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-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),A.jsx("p",{className:"text-lg font-medium",children:"Error al cargar la imagen"}),A.jsx("p",{className:"text-gray-400 text-sm mt-2",children:"No se pudo cargar la imagen"})]}),A.jsx("img",{ref:k,src:e,alt:t,className:"max-w-full max-h-full object-contain transition-opacity duration-200 select-none "+(b?"opacity-100":"opacity-0"),style:{transform:`scale(${o}) translate(${l.x/o}px, ${l.y/o}px)`,transition:d?"none":"transform 0.2s ease-out"},onLoad:()=>y(!0),onError:()=>x(!0),onClick:P,onDoubleClick:M,draggable:!1})]}),A.jsx("div",{className:"px-4 py-2 bg-black/50 backdrop-blur-sm text-center",children:A.jsxs("p",{className:"text-gray-400 text-xs",children:[A.jsxs("span",{className:"hidden sm:inline",children:[A.jsx("kbd",{className:"px-1.5 py-0.5 bg-white/10 rounded text-white",children:"Ctrl"})," + rueda para zoom •"," ",A.jsx("kbd",{className:"px-1.5 py-0.5 bg-white/10 rounded text-white",children:"Ctrl"})," +"," ",A.jsx("kbd",{className:"px-1.5 py-0.5 bg-white/10 rounded text-white",children:"+"})," /"," ",A.jsx("kbd",{className:"px-1.5 py-0.5 bg-white/10 rounded text-white",children:"-"})," ","zoom •"," ","Doble click para ampliar/restablecer •"," ","Flechas para mover •"," ",A.jsx("kbd",{className:"px-1.5 py-0.5 bg-white/10 rounded text-white",children:"ESC"})," cerrar"]}),A.jsx("span",{className:"sm:hidden",children:"Click para zoom • Doble click para restablecer • ESC para cerrar"})]})})]})}function Z({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}=X(),f=window.limboCore?.accessibilityManager,[g,b]=d.useState(null),[y,v]=d.useState(null),[x,w]=u.useState(null),k=(window.limboCore?.config?.getGlobal()||{}).interaction||{allowSelection:!1,allowCropping:!0},S=k.allowSelection&&s.select&&r,C=k.allowCropping&&s.crop&&i,j=s.download,N=s.delete,[E,$]=d.useState(new Set),[_,z]=d.useState(new Set),T=u.useRef(null),P=u.useRef(null),M=u.useCallback(e=>{if("Escape"===e.key){if(x)return;e.preventDefault(),n?.()}if("Tab"===e.key&&T.current){const t=T.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):e.shiftKey||document.activeElement!==r||(e.preventDefault(),n?.focus())}},[n,x]);u.useEffect(()=>{if(t)return P.current?.focus(),document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[t,M]);const I=d.useMemo(()=>e?.variants||[],[e?.variants]),L=c(e?.id),D=(I.length>0?I:L).filter(e=>!_.has(e.id)),O=0===I.length&&m(e?.id),R=0===I.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&&($(new Set),z(new Set))},[t]);if(!t)return null;const F=[{...e,isOriginal:!0},...D.map(e=>({...e,isOriginal:!1}))];return A.jsxs("div",{className:"fixed inset-0 bg-black/85 flex items-center justify-center z-[1000] p-4",onClick:()=>{x||n?.()},role:"dialog","aria-modal":"true","aria-labelledby":"variants-modal-title","aria-describedby":"variants-modal-description",children:[A.jsxs("div",{ref:T,className:"bg-white rounded-xl max-w-[95vw] max-h-[90vh] overflow-hidden shadow-2xl flex flex-col w-[900px]",onClick:e=>e.stopPropagation(),children:[A.jsxs("div",{className:"px-5 py-4 border-b border-gray-200 flex justify-between items-center bg-gray-50",children:[A.jsxs("div",{className:"flex-1 min-w-0 pr-4",children:[A.jsx("h2",{id:"variants-modal-title",className:"m-0 text-lg font-semibold text-gray-900 truncate",children:e?.filename}),A.jsxs("p",{id:"variants-modal-description",className:"text-sm text-gray-500 mt-1",children:["Imagen original y ",D.length," recorte",1!==D.length?"s":""," disponible",1!==D.length?"s":""]})]}),A.jsx("button",{ref:P,className:"w-10 h-10 flex items-center justify-center rounded-lg bg-gray-100 hover:bg-red-200 text-gray-500 hover:text-red-1000 transition-colors focus:outline-none focus:ring-2 focus:ring-brand-blue-400",onClick:n,"aria-label":"Cerrar modal (ESC)",title:"Cerrar (ESC)",children:A.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),g&&A.jsx("div",{className:"mx-2 mt-2 px-2 py-1.5 rounded text-xs "+("success"===y?"bg-green-50 text-green-1000":"bg-red-50 text-red-1000"),role:"alert",children:g}),A.jsx("div",{className:"p-5 overflow-y-auto flex-1 bg-gray-50/50",children:O?A.jsxs("div",{className:"text-center py-16 text-gray-500",role:"status","aria-live":"polite",children:[A.jsx("div",{className:"w-12 h-12 border-4 border-gray-200 border-t-brand-blue-800 rounded-full animate-spin mx-auto mb-4"}),A.jsx("p",{className:"text-base",children:"Cargando variantes..."})]}):R?A.jsxs("div",{className:"text-center py-16 text-red-1000",role:"alert",children:[A.jsx("svg",{className:"w-12 h-12 mx-auto mb-4 text-red-800",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",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-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),A.jsxs("p",{className:"text-base font-medium",children:["Error: ",R]}),A.jsx("button",{onClick:()=>l(e.id),className:"mt-4 text-sm px-5 py-2.5 rounded-lg bg-brand-blue-800 text-white hover:bg-brand-blue-1000 focus:outline-none focus:ring-2 focus:ring-brand-blue-400 focus:ring-offset-2",children:"Reintentar"})]}):0===D.length?A.jsxs("div",{className:"text-center py-16 text-gray-500",children:[A.jsx("svg",{className:"w-12 h-12 mx-auto mb-4 text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),A.jsx("p",{className:"text-base",children:"No hay recortes disponibles"})]}):A.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-5",role:"list","aria-label":"Lista de imágenes",children:F.map((t,s)=>{const l=t.isOriginal,c=!l&&E.has(t.id),u=t.url,d=l?"Original":t.name||t.filename||`Recorte ${s}`,m=l?e.width:t.width,h=l?e.height:t.height,g=l?e.file_size:t.file_size||0;return A.jsxs("article",{role:"listitem","aria-label":`${d} - ${m}×${h} píxeles`,className:`rounded-xl overflow-hidden transition-all shadow-sm hover:shadow-lg ${l?"ring-2 ring-brand-blue-800 ring-offset-2 bg-white":"border border-gray-200 bg-white hover:border-brand-blue-400"} focus-within:ring-2 focus-within:ring-brand-blue-400`,children:[A.jsxs("button",{type:"button",title:"Click para ampliar con zoom",className:"relative w-full cursor-pointer aspect-square flex items-center justify-center overflow-hidden bg-gray-100 focus:outline-none group",onClick:c?void 0:()=>{return l?(f?.announce(`Abriendo visor de imagen: ${e.filename}`),void w({src:e.url,title:e.filename||"Original",subtitle:`${e.width}×${e.height} · ${Math.round((e.file_size||0)/1024)}KB`})):(n=t,f?.announce(`Abriendo visor de imagen: ${n.name}`),void w({src:n.url,title:n.name||n.filename||"Recorte",subtitle:`${n.width}×${n.height} · ${Math.round((n.file_size||0)/1024)}KB`}));var n},"aria-label":`Ver ${d} en tamaño completo con zoom`,disabled:c,children:[c?A.jsxs("div",{className:"text-center text-gray-400",children:[A.jsx("svg",{className:"w-10 h-10 mx-auto mb-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),A.jsx("span",{className:"text-sm",children:"Error al cargar"})]}):A.jsxs(A.Fragment,{children:[A.jsx("img",{src:u,alt:`${d} - ${m}×${h}px`,loading:l?"eager":"lazy",onError:l?void 0:()=>{return e=t.id,void $(t=>new Set([...t,e]));var e},className:"w-full h-full object-contain p-3 transition-transform group-hover:scale-105"}),A.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/10 transition-colors flex items-center justify-center",children:A.jsxs("span",{className:"opacity-0 group-hover:opacity-100 transition-opacity bg-black/60 text-white px-3 py-1.5 rounded-full text-xs font-medium flex items-center gap-1.5",children:[A.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})}),"Ampliar"]})})]}),l&&A.jsx("span",{className:"absolute top-3 left-3 bg-brand-blue-800 text-white text-xs font-bold px-3 py-1.5 rounded-lg shadow-lg",children:"ORIGINAL"})]}),A.jsxs("div",{className:"px-4 py-3 border-t border-gray-100 bg-white",children:[A.jsx("h3",{className:"text-sm font-semibold text-gray-900 truncate mb-2",title:d,children:d}),A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsxs("span",{className:"text-xs text-gray-500 font-medium",children:[m,"×",h," ·"," ",Math.round(g/1024),"KB"]}),A.jsxs("div",{className:"flex gap-2",role:"group","aria-label":`Acciones para ${d}`,children:[l&&C&&A.jsx("button",{type:"button",className:"w-8 h-8 rounded-lg bg-brand-blue-400 hover:bg-brand-blue-800 cursor-pointer text-white flex items-center justify-center focus:outline-none focus:ring-2 focus:ring-brand-blue-400 focus:ring-offset-1 transition-colors shadow-sm",onClick:t=>{t.stopPropagation(),i&&(f?.announce(`Abriendo herramienta de recorte para ${e.filename}`),i(e),n?.())},"aria-label":"Crear nuevo recorte",title:"Recortar",children:A.jsx("span",{className:"icon icon-scissors-white icon--sm"})}),j&&A.jsx("button",{type:"button",className:"w-8 h-8 rounded-lg bg-brand-blue-400 hover:bg-brand-blue-800 cursor-pointer text-white flex items-center justify-center focus:outline-none focus:ring-2 focus:ring-brand-blue-400 focus:ring-offset-1 transition-colors shadow-sm",onClick:n=>{n.stopPropagation(),l?(async()=>{const{downloadImage:t}=await Promise.resolve().then(()=>on);await t(e.url||e.path,e.filename||"limbo-image",{originalFormat:e.format,accessibilityManager:f})})():(async e=>{const{downloadImage:t}=await Promise.resolve().then(()=>on);await t(e.url,e.name||"limbo-variant",{originalFormat:e.format||e.output_format,accessibilityManager:f})})(t)},"aria-label":`Descargar ${d}`,title:"Descargar",children:A.jsx("span",{className:"icon icon-download-white icon--sm"})}),N&&(!l||a)&&A.jsx("button",{type:"button",className:"w-8 h-8 rounded-lg bg-red-1000 hover:bg-red-800 cursor-pointer text-white flex items-center justify-center focus:outline-none focus:ring-2 focus:ring-red-800 focus:ring-offset-1 transition-colors shadow-sm",onClick:r=>{r.stopPropagation(),l?(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?.())})():(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?(z(e=>new Set([...e,t.id])),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)},"aria-label":`Eliminar ${d}`,title:"Eliminar",children:A.jsx("span",{className:"icon icon-close-small-white icon--sm"})}),S&&A.jsx("button",{type:"button",className:"w-8 h-8 cursor-pointer rounded-lg bg-brand-blue-1000 text-white hover:bg-brand-blue-800 flex items-center justify-center focus:outline-none focus:ring-2 focus:ring-brand-blue-400 focus:ring-offset-1 transition-colors shadow-sm",onClick:a=>{a.stopPropagation(),l?(r?.(e),n?.()):(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)},"aria-label":`Seleccionar ${d}`,title:"Seleccionar",children:A.jsx("span",{className:"icon icon-tick-white icon--sm"})})]})]})]})]},l?"original":t.id)})})})]}),A.jsx(J,{isOpen:!!x,src:x?.src||"",alt:x?.title||"Imagen",title:x?.title,subtitle:x?.subtitle,onClose:()=>w(null)})]})}function ee({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(!1),[f,g]=u.useState(e.variants_count||0),[b,y]=u.useState(!0),[v,x]=u.useState(!1),{isMobile:w,isTouch:k}=M(),S=window.limboCore?.accessibilityManager,C=(window.limboCore?.config?.getGlobal()||{}).interaction||{allowSelection:!1,allowCropping:!0},j=n=>{n.stopPropagation(),S?.announce(`Eliminando imagen ${e.filename}`,"assertive"),t?.(e)},N=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),S?.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),S?.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.`)}},E=async t=>{t.preventDefault(),t.stopPropagation();const{downloadImage:n}=await Promise.resolve().then(()=>on);await n(e.url||e.path,e.filename||"limbo-image",{originalFormat:e.format,accessibilityManager:S})},$=t=>{t.stopPropagation(),S?.announce(`Editando imagen ${e.filename}`),n?.(e)},_=e.variants&&e.variants.length>0||f>0,z=f,T=d.useCallback(()=>{g(e=>Math.max(0,e-1))},[]);d.useEffect(()=>{g(e.variants_count||0)},[e.variants_count]),d.useEffect(()=>{y(!0),x(!1)},[e.url,e.path]);const P=C.allowSelection&&o.select&&r,I=C.allowCropping&&o.crop&&n,L=()=>{_?(S?.announce(`Mostrando recortes de ${e.filename}`),m(!0)):(S?.announce(`Abriendo visor de ${e.filename}`),p(!0))};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":""} ${w?"limbo-image-card--mobile":""}`,onClick:L,onKeyDown:r=>{switch(r.key){case"Enter":case" ":r.preventDefault(),L();break;case"d":case"D":o.download&&(r.preventDefault(),E(r));break;case"c":case"C":o.copy&&(r.preventDefault(),N(r));break;case"Delete":case"Backspace":o.delete&&t&&(r.preventDefault(),j(r));break;case"x":case"X":o.crop&&n&&(r.preventDefault(),$(r));break;case"v":case"V":o.variants&&(r.preventDefault(),(t=>{t.stopPropagation(),S?.announce(`Mostrando recortes de ${e.filename}`),m(!0)})(r))}},title:_?`Ver ${z} recorte${1!==z?"s":""} de ${e.filename}`:w?"Toque para ampliar imagen":"Click para ampliar imagen con zoom",role:"button",tabIndex:0,"aria-label":`Imagen ${e.filename}. ${e.width}x${e.height} px`,style:{...k&&{touchAction:"manipulation",WebkitTapHighlightColor:"transparent"}},children:[A.jsxs("div",{className:"limbo-image-actions "+(w?"limbo-image-actions--mobile":""),children:[!_&&P&&A.jsx("button",{type:"button",title:"Seleccionar imagen",className:"btn btn-success bg-brand-blue-800 hover:bg-brand-blue-1000 border border-brand-blue-1000 "+(w?"btn--touch":""),onClick:t=>{t.stopPropagation(),S?.announce(`Seleccionando ${e.filename} para el portal`),r?.(e)},tabIndex:-1,style:{...w&&{width:"40px",height:"40px"}},children:A.jsx("span",{className:"icon icon-tick-white icon--sm","aria-hidden":"true"})}),I&&A.jsx("button",{type:"button",title:"Editar imagen",className:"btn btn-crop bg-brand-blue-400 hover:bg-brand-blue-800 border border-brand-blue-1000 "+(w?"btn--touch":""),onClick:$,tabIndex:-1,style:{...w&&{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 bg-brand-blue-400 hover:bg-brand-blue-800 border border-brand-blue-1000 "+(w?"btn--touch":""),onClick:N,tabIndex:-1,style:{...w&&{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 bg-brand-blue-400 hover:bg-brand-blue-800 border border-brand-blue-1000 "+(w?"btn--touch":""),onClick:E,tabIndex:-1,style:{...w&&{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:j,disabled:i,className:"btn btn-delete bg-red-1000 hover:bg-red-800 border border-red-1000/50 "+(w?"btn--touch":""),title:"Eliminar imagen",tabIndex:-1,style:{...w&&{width:"40px",height:"40px"}},children:i?"…":A.jsx("span",{className:"icon icon-close-small-white icon--sm","aria-hidden":"true"})})]}),b&&!v&&A.jsx("div",{className:"w-full aspect-square rounded bg-neutral-200 animate-pulse flex items-center justify-center "+(_?"ring-2 ring-brand-blue-400 ring-offset-2":""),style:{...w&&{minHeight:`${Math.max(3*a,80)}px`}},children:A.jsx("span",{className:"icon icon-spinner w-8 h-8 animate-spin"})}),v&&A.jsxs("div",{className:"w-full aspect-square rounded bg-neutral-100 flex flex-col items-center justify-center text-neutral-400",style:{...w&&{minHeight:`${Math.max(3*a,80)}px`}},children:[A.jsx("span",{className:"icon icon-close icon--lg mb-1","aria-hidden":"true"}),A.jsx("span",{className:"text-xs",children:"Error al cargar"})]}),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 ${_?"ring-2 ring-brand-blue-400 ring-offset-2":""} ${b||v?"hidden":""}`,sizes:`height: ${6*a}px,width: ${6*a}px`,draggable:!1,onLoad:()=>y(!1),onError:()=>{y(!1),x(!0)},style:{...w&&{minHeight:`${Math.max(3*a,80)}px`,height:"auto",aspectRatio:"1 / 1",objectFit:"cover"}}}),A.jsxs("span",{className:"text-xs mt-1 limbo-truncate w-full text-center limbo-image-card-name "+(w?"limbo-image-card-name--mobile":""),style:{...w&&{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("span",{className:"limbo-variants-indicator",style:{marginLeft:"4px",padding:"1px 6px",backgroundColor:"#dc2626",color:"white",borderRadius:"10px",fontSize:"10px",fontWeight:"700",display:"inline-block"},title:`${z} recorte${1!==z?"s":""}`,children:z})]})]}),A.jsx(Z,{image:e,isOpen:c,onClose:()=>m(!1),onSelect:r,onDelete:t,onCrop:n,onVariantDeleted:T,allowedActions:{select:o.select,download:o.download,copy:o.copy,delete:o.delete,crop:o.crop}}),A.jsx(J,{isOpen:h,src:e.url||e.path,alt:e.filename,title:e.filename,subtitle:`${e.width}×${e.height} · ${Math.round((e.file_size||0)/1024)}KB`,onClose:()=>p(!1)})]})}function te(){return A.jsxs("div",{className:"limbo-image-card animate-pulse",role:"status","aria-label":"Cargando imágen...",children:[A.jsx("div",{className:"w-full aspect-square bg-neutral-gray-200 rounded-md flex items-center justify-center",children:A.jsx("span",{className:"icon icon-spinner"})}),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:"sr-only",children:"Cargando imágen..."})]})}function ne({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 py-4",children:[A.jsx("div",{className:"p-2 px-4 mb-2",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-45 sm:flex-1",children:[A.jsx("label",{htmlFor:"name",className:"limbo-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:"limbo-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:"limbo-form-label mb-1",children:"Desde"}),A.jsx("input",{type:"date",name:"dateFrom",id:"dateFrom",value:s.dateFrom,onChange:y,className:"limbo-form-control"})]}),A.jsxs("div",{className:"flex flex-col w-full sm:w-auto",children:[A.jsx("label",{htmlFor:"dateTo",className:"limbo-form-label mb-1",children:"Hasta"}),A.jsx("input",{type:"date",name:"dateTo",id:"dateTo",value:s.dateTo,onChange:y,className:"limbo-form-control"})]})]}),p&&A.jsxs("div",{className:"flex flex-col w-full sm:w-auto",children:[A.jsx("label",{htmlFor:"uploadedBy",className:"limbo-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:"limbo-form-control"})]})]})]})}),i?A.jsxs("div",{className:"relative",children:[A.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-white/80 z-10 min-h-75",children:A.jsxs("div",{className:"flex flex-col items-center gap-3",children:[A.jsx("span",{className:"icon icon-spinner p-4 animate-spin"}),A.jsx("span",{className:"text-sm text-gray-600 font-medium",children:"Cargando imágenes..."})]})}),d.showPlaceholders&&A.jsx("div",{ref:g,className:"limbo-gallery opacity-30","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(te,{})},`skeleton-${t}`))})]}):o?A.jsx("div",{className:"alert alert-danger text-center",children:o}):A.jsx("div",{ref:g,className:"limbo-gallery px-3","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(ee,{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 re({image:e,onDiscard:t,onRetry:n,onDownload:r,onSelect:a,showRetry:i=!1,disabled:o=!1}){const[s,l]=u.useState(null),[c,d]=u.useState({name:"",size:"",type:""}),[m,h]=u.useState(!1);u.useEffect(()=>{if(!e)return void l(null);const t=URL.createObjectURL(e);return l(t),d({name:e.name||"imagen.webp",size:p(e.size||0),type:e.type||"image/webp"}),()=>{URL.revokeObjectURL(t)}},[e]);const p=e=>{if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return Math.round(e/Math.pow(1024,t)*100)/100+" "+["Bytes","KB","MB","GB"][t]};return e&&s?A.jsxs("div",{className:"w-fit md:w-full bg-white border border-gray-200 rounded-lg px-1 sm:px-3 py-2 m-0 shadow-sm",children:[A.jsxs("div",{className:"flex items-center justify-between mb-4 px-1",children:[A.jsx("h3",{className:"text-sm font-medium text-gray-700",children:"Vista previa de imagen"}),A.jsx("button",{type:"button",onClick:t,disabled:o,className:"p-1.5 text-gray-400 cursor-pointer hover:text-gray-600 hover:bg-red-300 rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed","aria-label":"Descartar imagen",title:"Descartar imagen",children:A.jsx("span",{className:"icon icon-close-small icon--md"})})]}),A.jsxs("div",{className:"flex flex-col justify-center md:flex-row gap-2 md:gap-6",children:[A.jsxs("div",{className:"flex-1 md:flex-[0.4] flex flex-col items-center justify-center",children:[A.jsxs("div",{className:"relative w-full max-w-md aspect-video bg-gray-100 rounded-lg overflow-hidden cursor-zoom-in hover:ring-2 hover:ring-brand-blue-800 transition-all",onClick:()=>h(!0),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),h(!0))},"aria-label":"Click para ver imagen en tamaño completo",title:"Click para ver en tamaño completo",children:[A.jsx("img",{src:s,alt:"Vista previa",className:"absolute inset-0 w-full h-full object-contain"}),A.jsxs("div",{className:"absolute top-2 right-2 bg-black/50 text-white px-2 py-1 rounded text-xs flex items-center gap-1",children:[A.jsx("span",{className:"icon icon-search-white icon--xs"}),A.jsx("span",{className:"hidden sm:inline",children:"Ampliar"})]})]}),A.jsx("div",{className:"mt-3 text-center space-y-1 w-full",children:A.jsxs("div",{className:"rounded-sm w-fit gap-0.5 p-0.5 min-w-fit mx-auto",children:[A.jsxs("label",{htmlFor:"uploadImageId",className:"flex items-center w-fit",children:[A.jsx("div",{className:"rounded-full bg-brand-blue-1000 min-w-6 min-h-6 flex items-center align-middle content-center justify-center me-1",children:A.jsx("span",{className:"icon icon-edit-white icon--sm"})}),A.jsx("input",{id:"uploadImageId",onChange:e=>(e=>{const t=e.target.value,n=c.name,r=n.lastIndexOf("."),a=-1!==r?n.substring(r):".webp";d(e=>({...e,name:t+a}))})(e),className:"w-fit px-1 text-sm font-medium text-gray-800 border border-gray-300 rounded limbo-truncate focus:outline focus:outline-neutral-gray-100 focus:limbo-transform-none focus:shadow-none focus:opacity-100",defaultValue:c.name.split(".")[0],title:"Renombra la imagen a tu gusto"})]}),A.jsxs("div",{className:"flex items-center justify-center gap-3 text-xs text-gray-500",children:[A.jsx("span",{children:c.size}),A.jsx("span",{children:"•"}),A.jsx("span",{children:c.type.split("/")[1]?.toUpperCase()||"IMAGE"})]})]})})]}),A.jsxs("div",{className:"flex flex-row md:flex-col gap-2 justify-items-stretch justify-center md:justify-start items-stretch md:min-w-[140px]",children:[i&&n&&A.jsxs("button",{type:"button",onClick:n,disabled:o,className:"flex-1 md:flex-none flex items-center justify-center gap-2 px-4 py-2.5 bg-white border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 cursor-pointer hover:border-gray-400 transition-colors disabled:opacity-50 disabled:cursor-not-allowed text-sm font-medium","aria-label":"Intentarlo de nuevo",title:"Generar de nuevo con el mismo prompt",children:[A.jsx("span",{className:"icon icon-refresh icon--sm"}),A.jsx("span",{className:"hidden sm:inline",children:"Reintentar"}),A.jsx("span",{className:"sm:hidden",children:"Retry"})]}),A.jsxs("button",{type:"button",onClick:()=>{if(!s||o)return;const e=document.createElement("a");e.href=s,e.download=c.name,document.body.appendChild(e),e.click(),document.body.removeChild(e),r&&r()},disabled:o,className:"flex-1 cursor-pointer md:flex-none flex items-center justify-center gap-2 px-4 py-2.5 bg-white border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 hover:border-gray-400 transition-colors disabled:opacity-50 disabled:cursor-not-allowed text-sm font-medium","aria-label":"Descargar imagen",children:[A.jsx("span",{className:"icon icon-download icon--sm"}),A.jsx("span",{children:"Descargar"})]}),A.jsxs("button",{type:"button",onClick:()=>a&&a(c.name),disabled:o,className:"flex-1 md:flex-none flex items-center justify-center gap-2 px-4 py-2.5 bg-brand-blue-800 border border-brand-blue-800 text-white rounded-lg hover:bg-brand-blue-1000 cursor-pointer hover:border-brand-blue-1000 transition-colors disabled:opacity-50 disabled:cursor-not-allowed text-sm font-medium shadow-sm","aria-label":"Seleccionar imagen para recortar",children:[A.jsx("span",{className:"icon icon-tick-white icon--sm"}),A.jsx("span",{children:"Seleccionar"})]})]})]}),A.jsx(J,{isOpen:m,src:s,alt:c.name,title:c.name,subtitle:`${c.size} • ${c.type.split("/")[1]?.toUpperCase()||"IMAGE"}`,onClose:()=>h(!1)})]}):null}function ae({file:e,setFile:t,previewUrl:n,setPreviewUrl:r,fileInputRef:a,onSelect:i,disabled:o}){const[s,l]=u.useState(!1),c=e=>{if(t(e),e){const t=URL.createObjectURL(e);r(t)}else r(null)};return A.jsxs("div",{className:"flex flex-col items-center gap-6","aria-label":"Subir imagen desde dispositivo",children:[A.jsxs("label",{htmlFor:"file-input",className:"w-fit md:w-full flex flex-col items-center justify-center border-2 border-dashed rounded-xl p-8 cursor-pointer transition "+(s?"border-brand-blue-1000 bg-brand-blue-100 scale-[1.02]":"border-brand-blue-200 hover:border-brand-blue-1000 hover:to-bright-blue-200 hover:from-brand-blue-50 focus-within:border-brand-blue-800 from-bright-blue-50 to-brand-blue-50 bg-linear-to-br"),tabIndex:0,style:{outline:"none"},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),o||l(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),e.currentTarget.contains(e.relatedTarget)||l(!1)},onDrop:e=>{if(e.preventDefault(),e.stopPropagation(),l(!1),o)return;const t=e.dataTransfer?.files;if(t&&t.length>0){const e=t[0];e.type.startsWith("image/")&&c(e)}},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 t=e.target.files[0];c(t)},disabled:o,className:"sr-only","aria-label":"Seleccionar imagen"})]}),e&&A.jsx(re,{image:e,onDiscard:()=>{t(null),r(null),a.current&&(a.current.value="")},onDownload:()=>{},onSelect:t=>{if(e&&!o&&i)if(t&&t!==e.name){const n=new File([e],t,{type:e.type});i(n)}else i(e)},showRetry:!1,disabled:o})]})}const ie="/api";const oe=new Map;function se(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=oe.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:ie})}(e);if(!s)return;const a=r?.data||r?.result||[],o=Array.isArray(a)?a.map(e=>({label:e.name||e.label,slug:e.slug,type:e.type,description:e.description,image:e.image,costInfo:e.cost_info||null})):Object.entries(a).map(([e,t])=>({label:e,slug:t,type:"image_generation",description:null,image:null,costInfo:null}));n(o),oe.set(t,{data:o,timestamp:i})}catch(r){s&&o(r.message)}finally{s&&a(!1)}})(),()=>{s=!1}},[e]);return{services:t,loading:r,error:i,invalidateCache:()=>{oe.delete(`ai-services-${e}`)}}}const le=new Map;function ce(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=le.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),le.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 ue({show:e=!1,message:t="Cargando...",className:n=""}){return e?A.jsx("div",{className:`absolute inset-0 min-h-50 bg-white/80 backdrop-blur-sm z-50 flex flex-col items-center justify-center ${n}`,"aria-live":"polite","aria-busy":"true",role:"status",children:A.jsxs("div",{className:"flex flex-col items-center gap-4",children:[A.jsx("span",{className:"icon icon-spinner p-4 animate-spin"}),A.jsx("p",{className:"text-brand-blue-1000 font-medium text-lg",children:t})]})}):null}function de({prod:e,disabled:t,onSelect:n}){const r=se(e),a=ce(e),[i,o]=u.useState(""),[s,l]=u.useState(""),[c,m]=u.useState({}),[h,p]=u.useState(!1),[f,g]=u.useState(null),[b,y]=u.useState(null),[v,x]=u.useState(null),[w,k]=u.useState(!0),[S,C]=u.useState(!1);d.useEffect(()=>{if(!r.loading&&1===r.services.length){const e=r.services[0];l(e.slug),k(!1),a.fetchParams(e.slug,!0)}},[r.loading,r.services]),d.useEffect(()=>{if(!s)return;const e=a.params?.[s]?.parameters;if(e){const t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default??""]));t.service=s,m(t)}},[s,a.params]);const j=e=>{const{name:t,value:n}=e.target;m(e=>({...e,[t]:n}))},N=async(t,n=!1)=>{t.preventDefault(),p(!0),g(null),y(null);try{n?c.prompt=i:o(c.prompt||"");const t=await function(e,t=!1){return F({endpoint:"/ai/generate",method:"POST",body:e,prod:t,basePath:ie})}(c,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)throw new Error("No se pudo extraer la imagen de la respuesta");if(a.startsWith("http"))try{const e=`${window.limboCore?.config?.getGlobal()?.prod?"https://limbo.lefebvre.es":"https://led-dev-limbo-dev.eu.els.local"}/api/atenea/proxy?url=${encodeURIComponent(a)}`,t=await fetch(e,{credentials:"include",headers:{Authorization:`Bearer ${window.limboCore?.apiClient?.token||""}`}});if(!t.ok)throw new Error(`Failed to download image: ${t.status}`);const n=await t.blob(),r=new File([n],"ai-image.webp",{type:n.type||"image/webp"});x(r)}catch(r){throw new Error(`Error downloading image via proxy: ${r.message}`)}else{const e=a.replace(/^data:image\/\w+;base64,/,""),t=atob(e),n=new Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);const r=new Uint8Array(n),i=new File([r],"ai-image.webp",{type:"image/webp"});x(i)}y(t?.data?.images||t?.result?.images||null)}catch(a){g(a.message||"Error al generar la imagen")}finally{p(!1)}};return r.loading?A.jsxs("div",{className:"flex items-center justify-center py-8",children:[A.jsx("span",{className:"limbo-loader mr-2"})," Cargando servicios IA..."]}):r.services.length?A.jsx("div",{className:"flex flex-col mx-4 pb-2",children:w?A.jsxs(A.Fragment,{children:[A.jsx("h3",{id:"aiSelectDescription",className:"text-2xl font-semibold text-brand-blue-1000 mb-3",children:"Selecciona el modelo IA"}),r.error&&A.jsx("div",{className:"alert alert-danger",children:r.error}),A.jsx("div",{className:"flex flex-wrap justify-around items-stretch justify-items-stretch content-stretch gap-3 w-full max-w-7xl",children:r.services.map(e=>A.jsxs("button",{type:"button",onClick:()=>{l(e.slug),k(!1),m({}),y(null),g(null),x(null),a.fetchParams(e.slug,!0)},disabled:r.loading||t,className:`group relative p-4 rounded-lg border-2 transition-all duration-200 overflow-hidden flex flex-col items-center justify-center min-h-30 grow basis-sm min-w-70 border-gray-200 hover:border-brand-blue-800 hover:shadow-md hover:text-black ${r.loading||t?"opacity-50 cursor-not-allowed":"cursor-pointer"} `,style:{position:"relative"},children:[e.image&&A.jsx("div",{className:"absolute inset-0 bg-cover bg-center transition-opacity duration-200 group-hover:opacity-40",style:{backgroundImage:`url(${e.image})`,opacity:.2}}),A.jsxs("div",{className:"relative z-10 flex flex-col items-center justify-center gap-2 text-center",children:[A.jsx("span",{className:"text-base font-semibold text-gray-800",children:e.label}),e.description&&A.jsx("span",{className:"text-xs text-neutral-gray-800 limbo-line-clamp-2 drop-shadow drop-shadow-neutral-white-000",children:e.description})]}),e.costInfo&&A.jsx("span",{className:"absolute top-0 left-1 inline-flex items-center gap-1 py-0 px-1 mt-1 text-xs font-medium text-warning-1000 rounded-md group-hover:bg-white/90",style:{zoom:"82%"},children:e.costInfo})]},e.slug))})]}):A.jsxs(A.Fragment,{children:[A.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-2",children:[A.jsx("h3",{className:"text-2xl font-semibold text-brand-blue-1000",children:r.services.find(e=>e.slug===s)?.label||"Generación IA"}),r.services.find(e=>e.slug===s)?.costInfo&&A.jsxs("div",{title:"Coste estimado por imagen que le cuesta a la empresa, este coste depende de la calidad de la imagen generada y puede variar según el proveedor IA, ten en cuenta este coste para hacer un uso más responsable del servicio IA",className:"flex items-center gap-1","aria-description":"Coste estimado por imagen que le cuesta a la empresa, este coste depende de la calidad de la imagen generada y puede variar según el proveedor IA, ten en cuenta este coste para hacer un uso más responsable del servicio IA",children:[A.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium text-warning-1000 bg-yellow-200/60 rounded-full border border-warning-1000 select-none",children:[A.jsx("span",{className:"icon icon-euro-blue icon--2sm icon--warning",style:{filter:"var(--icon-warning-dark)"}}),"Coste:"," ",r.services.find(e=>e.slug===s)?.costInfo]}),A.jsx("span",{className:"icon icon-info cursor-help"})]})]}),a.loading&&A.jsx("div",{children:"Cargando parámetros..."}),a.error&&A.jsx("div",{className:"alert alert-danger",children:a.error}),s&&(()=>{const e=a.params?.[s]?.parameters;if(!e)return null;const n=Object.entries(e).filter(([e,t])=>!t.hidden),i=n.filter(([e])=>e.toLowerCase().includes("prompt")||e.toLowerCase().includes("query")),o=n.filter(([e])=>!e.toLowerCase().includes("prompt")&&!e.toLowerCase().includes("query")),u=(e,n)=>{let r=n.placeholder||"";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()}`);const a=e.toLowerCase().includes("prompt")||e.toLowerCase().includes("query");return A.jsxs("div",{className:"flex flex-col gap-1",children:[A.jsxs("label",{htmlFor:`ai-${e}`,className:"text-xs font-medium text-brand-blue-1000",children:[n.label||e,n.required&&A.jsx("span",{className:"text-red-1000 ml-1",children:"*"})]}),n.options?A.jsx("select",{id:`ai-${e}`,name:e,value:c[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?A.jsx("textarea",{id:`ai-${e}`,name:e,value:c[e]??"",onChange:j,className:"limbo-input resize-none overflow-y-auto",disabled:t,required:n.required,placeholder:r,title:n.label||e,rows:3,style:{maxHeight:"9rem",minHeight:"3rem"},onInput:e=>{e.target.style.height="auto";const t=Math.min(e.target.scrollHeight,144);e.target.style.height=`${t}px`}}):A.jsx("input",{id:`ai-${e}`,type:"integer"===n.type?"number":"text",name:e,value:c[e]??"",onChange:j,className:"limbo-input",disabled:t,required:n.required,min:n.minValue,max:n.maxValue,placeholder:r,title:n.label||e})]},e)};return A.jsxs("div",{className:"h-fit w-full",children:[r.services.length>1&&A.jsxs("button",{type:"button",onClick:()=>{k(!0),l(""),m({}),y(null),g(null),x(null)},className:"flex cursor-pointer items-center gap-2 text-brand-blue-800 hover:text-brand-blue-1000 mb-4 font-medium",children:[A.jsx("span",{className:"icon icon-arrow-left"}),"Volver al menú de servicios"]}),A.jsxs("div",{className:"relative",children:[A.jsxs("form",{onSubmit:N,"data-type":"ai",className:"flex flex-col gap-3 mt-4 border-t pt-4 border-brand-blue-200","aria-label":"Formulario generación IA",children:[A.jsx("div",{className:"flex flex-col gap-3",children:i.map(([e,t])=>u(e,t))}),o.length>0&&A.jsxs("div",{className:"border-t border-gray-200 pt-3",children:[A.jsxs("button",{type:"button",onClick:()=>C(!S),className:"flex items-center gap-2 text-sm font-medium text-brand-blue-800 hover:text-brand-blue-1000 mb-3 transition-colors",children:[A.jsx("svg",{className:"w-4 h-4 transition-transform "+(S?"rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"Opciones avanzadas",!S&&A.jsxs("span",{className:"text-xs text-gray-500",children:["(",o.length," opciones)"]})]}),S&&A.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3 animate-fadeIn",children:o.map(([e,t])=>u(e,t))})]}),A.jsx("button",{type:"submit",disabled:h||t,title:h?"Generando imagen...":v?"Generar otra imagen":"Generar imagen",className:"limbo-btn w-full mt-2 "+(h?"cursor-not-allowed limbo-btn-disabled":"limbo-btn-primary"),style:{minHeight:44},children:h?"Generando imagen...":v?"Generar otra imagen":"Generar imagen"})]}),A.jsx(ue,{show:h,message:"Generando imagen con IA..."})]})]})})(),f&&A.jsx("div",{className:"alert alert-danger mt-4",children:f}),v&&A.jsx("div",{className:"mt-6 md:w-full mx-auto",children:A.jsx(re,{image:v,onDiscard:()=>{x(null),y(null),g(null)},onRetry:e=>N(e,!0),onDownload:()=>{},onSelect:e=>{if(n){const t=v||b;if(e&&t&&e!==t.name){const r=new File([t],e,{type:t.type});n(r)}else n(t)}},showRetry:!0,disabled:h||t})})]})}):A.jsx("div",{className:"alert alert-warning",children:"No hay servicios IA disponibles."})}const me="/api";const he=new Map;function pe(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=he.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:me})}(e);if(!s)return;if(204===r?.httpCode||null===r?.data)return n([]),o("No hay servicios de stock disponibles en este momento"),void he.set(t,{data:[],timestamp:i});const a=r?.data||r?.result||[],l=Array.isArray(a)?a.map(e=>({label:e.name||e.label,slug:e.slug,type:e.type,description:e.description,image:e.image})):Object.entries(a).map(([e,t])=>({label:e,slug:t,type:"stock_image",description:null,image:null}));n(l),he.set(t,{data:l,timestamp:i})}catch(r){s&&o(r.message)}finally{s&&a(!1)}})(),()=>{s=!1}},[e]);return{services:t,loading:r,error:i,invalidateCache:()=>{he.delete(`stock-services-${e}`)}}}function fe({prod:e,disabled:t,onSelect:n}){const r=d.useRef(null),a=pe(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,v]=u.useState(null),x=ce(e),[w,k]=u.useState(!1),[S,C]=u.useState(null),[j,N]=u.useState(null),[E,$]=u.useState(!0),[_,z]=u.useState(!1),[T,P]=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]),d.useEffect(()=>{if(!a.loading&&1===a.services.length){const e=a.services[0];s(e.slug),$(!1),x.fetchParams(e.slug,!0)}},[a.loading,a.services]),d.useEffect(()=>{if(!o)return;const e=x.params?.[o]?.parameters;if(e){const t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default??""]));t.service=o,c(t)}},[o,x.params]);const M=e=>{const{name:t,value:n}=e.target;c(e=>({...e,[t]:n}))},I=async(t=1)=>{k(!0),C(null),1===t&&h([]);try{let n;if(1===t){const e=x.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:me})}(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(L(Array.isArray(i)?i:[])),b(c),f(c?.current_page||t)}catch(n){C(n.message||"Error al buscar imágenes")}finally{k(!1)}},L=e=>{const t=new Set,n=[];return(e||[]).forEach((e,r)=>{const i=e.url||e.preview_url||e.full||e.preview;i&&!t.has(i)&&(t.add(i),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:a.services.find(e=>e.slug===o)?.label||o}))}),n},D=async e=>{e.preventDefault();const t=l.query||l.search||l.term||"";t.trim().length<5?C("La búsqueda debe tener al menos 5 caracteres"):(v(t),await I(1))},O=e=>{e<1||I(e)},R=async t=>{N(t.id),C(null);try{const n={service:o,image_id:t.id},r=await function(e,t=!1){return F({endpoint:"/stock/download",method:"POST",body:e,prod:t,basePath:me})}(n,e),a=r?.result?.url||r?.result?.download_url||r?.data?.images?.url||r?.data?.url||r?.images?.url||r?.url;if(!a)throw console.error("Download response structure:",r),new Error("No se pudo obtener la URL de descarga");{const e=await fetch(a),n=await e.blob(),i=r?.result?.filename||r?.data?.images?.filename||r?.data?.filename||`stock-${t.id}.jpg`,o=new File([n],i,{type:n.type||"image/jpeg"});P(o)}}catch(n){C(n.message||"No se pudo recuperar la imagen seleccionada")}finally{N(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.jsx("div",{className:"flex flex-col mx-4 pb-2",children:E?A.jsxs(A.Fragment,{children:[A.jsx("h3",{className:"text-2xl font-semibold text-brand-blue-1000 mb-3",children:"Selecciona el servicio de Stock"}),a.error&&A.jsx("div",{className:"alert alert-danger",children:a.error}),A.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:a.services.map(e=>A.jsxs("button",{type:"button",onClick:()=>{s(e.slug),$(!1),c({}),h([]),f(1),b(null),C(null),x.fetchParams(e.slug,!0)},disabled:a.loading||t,className:`group relative p-4 rounded-lg border-2 transition-all duration-200 overflow-hidden flex flex-col items-center justify-center min-h-30 border-gray-200 hover:border-brand-blue-300 hover:shadow-md ${a.loading||t?"opacity-50 cursor-not-allowed":"cursor-pointer"} `,style:{position:"relative"},children:[e.image&&A.jsx("div",{className:"absolute inset-0 bg-cover bg-center transition-opacity duration-200 group-hover:opacity-40",style:{backgroundImage:`url(${e.image})`,opacity:.2}}),A.jsxs("div",{className:"relative z-10 flex flex-col items-center justify-center gap-2 text-center",children:[A.jsx("span",{className:"text-base font-semibold text-gray-800",children:e.label}),e.description&&A.jsx("span",{className:"text-xs text-gray-600 limbo-line-clamp-2",children:e.description})]})]},e.slug))})]}):A.jsxs(A.Fragment,{children:[A.jsx("h3",{className:"text-2xl font-semibold text-brand-blue-1000",children:a.services.find(e=>e.slug===o)?.label||"Búsqueda Stock"}),x.loading&&A.jsx("div",{children:"Cargando parámetros..."}),x.error&&A.jsx("div",{className:"alert alert-danger",children:x.error}),o&&(()=>{const e=x.params?.[o]?.parameters;if(!e)return null;const n=Object.entries(e).filter(([,e])=>!e.hidden),r=n.filter(([e])=>e.toLowerCase().includes("query")||e.toLowerCase().includes("search")||e.toLowerCase().includes("term")),i=n.filter(([e])=>!e.toLowerCase().includes("query")&&!e.toLowerCase().includes("search")&&!e.toLowerCase().includes("term")),u=(e,n)=>{let r=n.placeholder||"";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()}`);const a=e.toLowerCase().includes("query")||e.toLowerCase().includes("search")||e.toLowerCase().includes("term");return A.jsxs("div",{className:"flex flex-col gap-1",children:[A.jsxs("label",{htmlFor:`stock-${e}`,className:"text-xs font-medium text-brand-blue-1000",children:[n.label||e,n.required&&A.jsx("span",{className:"text-red-1000 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:M,className:"limbo-input",disabled:t,title:n.label||e,children:n.options.map(e=>A.jsx("option",{value:e,children:e},e))}):a?A.jsx("textarea",{id:`stock-${e}`,name:e,value:l[e]??"",onChange:M,className:"limbo-input resize-none overflow-y-auto",disabled:t,required:n.required,placeholder:r,title:n.label||e,rows:3,style:{maxHeight:"9rem",minHeight:"3rem"},onInput:e=>{e.target.style.height="auto";const t=Math.min(e.target.scrollHeight,144);e.target.style.height=`${t}px`}}):A.jsx("input",{id:`stock-${e}`,type:"integer"===n.type?"number":"text",name:e,value:l[e]??"",onChange:M,className:"limbo-input",disabled:t,required:n.required,min:n.minValue,max:n.maxValue,placeholder:r,title:n.label||e})]},e)};return A.jsxs("div",{children:[a.services.length>1&&A.jsxs("button",{type:"button",onClick:()=>{$(!0),s(""),c({}),h([]),f(1),b(null),C(null)},className:"flex cursor-pointer items-center gap-2 text-brand-blue-800 hover:text-brand-blue-1000 mb-4 font-medium",children:[A.jsx("span",{className:"icon icon-arrow-left"}),"Volver al menú de servicios"]}),A.jsxs("div",{className:"relative",children:[A.jsxs("form",{onSubmit:D,"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:"flex flex-col gap-3",children:r.map(([e,t])=>u(e,t))}),i.length>0&&A.jsxs("div",{className:"border-t border-gray-200 pt-3",children:[A.jsxs("button",{type:"button",onClick:()=>z(!_),className:"flex items-center gap-2 text-sm font-medium text-brand-blue-800 hover:text-brand-blue-1000 mb-3 transition-colors",children:[A.jsx("svg",{className:"w-4 h-4 transition-transform "+(_?"rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"Opciones avanzadas",!_&&A.jsxs("span",{className:"text-xs text-gray-500",children:["(",i.length," opciones)"]})]}),_&&A.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 animate-fadeIn",children:i.map(([e,t])=>u(e,t))})]}),A.jsx("button",{type:"submit",disabled:w||t,className:"limbo-btn w-full mt-2 "+(w?"cursor-not-allowed limbo-btn-disabled":"limbo-btn-primary"),style:{minHeight:44},children:w?"Buscando...":"Buscar imágenes"})]}),A.jsx(ue,{show:w&&!m.length,message:"Buscando imágenes..."})]})]})})(),S&&A.jsx("div",{className:"alert alert-danger mt-4",children:S}),T&&A.jsx("div",{className:"mt-6 md:w-full mx-auto",children:A.jsx(re,{image:T,onDiscard:()=>{P(null),C(null)},onDownload:()=>{},onSelect:e=>{if(n)if(e&&T&&e!==T.name){const t=new File([T],e,{type:T.type});n(t)}else n(T)},showRetry:!1,disabled:t})}),!T&&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-1 relative","aria-live":"polite",children:[A.jsx(ue,{show:w,message:"Cargando imágenes..."}),m.map((e,n)=>A.jsx("div",{className:"group border border-brand-blue-200 rounded-sm overflow-hidden bg-white shadow-sm hover:shadow-md transition-all duration-200 cursor-pointer",title:"Seleccionar imagen",onClick:()=>!j&&!w&&!t&&R(e),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"}),j===e.id?A.jsxs("div",{className:"absolute inset-0 bg-white/90 flex flex-col items-center justify-center gap-2",children:[A.jsxs("div",{className:"relative w-10 h-10",children:[A.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-200 rounded-full"}),A.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-800 rounded-full border-t-transparent animate-spin"})]}),A.jsx("span",{className:"text-sm font-medium text-brand-blue-1000",children:"Descargando..."})]}):A.jsxs("div",{className:"absolute inset-0 bg-brand-blue-800/0 group-hover:bg-brand-blue-800/50 transition-colors duration-200 flex items-center justify-center flex-col",children:[A.jsx("span",{className:"icon icon-round-check-filled-blue icon--2xl max-w-full max-h-full opacity-0 group-hover:opacity-100 transition-opacity duration-200"}),A.jsx("span",{style:{textShadow:"1px 0 #001978, -1px 0 #001978, 0 1px #001978, 0 -0.5px #001978, 0.5px 0.5px #001978, -1px -1px #001978, 1px -1px #001978, -1px 1px #001978"},className:"max-w-full max-h-full opacity-0 group-hover:opacity-100 transition-opacity duration-200 text-neutral-white-000",children:"Seleccionar"})]})]})},e.id||n))]}),g&&A.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2",children:[A.jsxs("button",{onClick:()=>O(g.current_page-1),disabled:g.current_page<=1||w,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(g.current_page<=1||w?" 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:()=>O(g.current_page+1),disabled:w||g.current_page>=Math.ceil(g.total/g.per_page),className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(w||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"})]})]})]}),!w&&0===m.length&&o&&y&&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 ge="/api";const be=new Map;function ye(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=be.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,t=!0){const n=new URLSearchParams;return n.set("active",t?"true":"false"),F({endpoint:`/external/portals?${n.toString()}`,method:"GET",prod:e,basePath:ge})}(e,!0);if(!s)return;let a=r?.data?.sources?.portals||r?.data?.portals||r?.data||[];Array.isArray(a)||(a=[]);const o=a.map(e=>({id:e.slug||e.id,numericId:e.id,name:e.name,title:e.name,slug:e.slug,url:e.website_url,image:e.logo_url,isActive:e.is_active}));n(o),be.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:()=>{be.delete(`portal-sources-${e}`)}}}const ve=({src:e,fallbackSrc:t,alt:n,className:r,onError:a})=>{const[i,o]=d.useState("loading"),[s,l]=d.useState(e),[c,u]=d.useState(!1);return"error"===i?null:A.jsxs("div",{className:"relative w-full h-full",children:["loading"===i&&A.jsx("div",{className:"absolute inset-0 bg-linear-to-r from-gray-200 via-gray-100 to-gray-200 animate-pulse flex items-center justify-center",children:A.jsx("div",{className:"flex flex-col items-center gap-2",children:A.jsx("span",{className:"icon icon-spinner w-8 h-8 text-gray-400 animate-spin"})})}),A.jsx("img",{src:s,alt:n,className:`${r} ${"loading"===i?"opacity-0":"opacity-100"} transition-opacity duration-300`,loading:"lazy",onLoad:()=>{o("loaded")},onError:()=>{t&&!c?(u(!0),l(t),o("loading")):(o("error"),a&&a())}})]})};function xe({prod:e,disabled:t,onSelect:n}){const r=d.useRef(null),a=ye(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,j]=u.useState(()=>i("paginationInfo",null)),[N,E]=u.useState(null),[$,_]=u.useState(null),z=u.useRef({}),[T,P]=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 M=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),i=z.current[n];if(i)return w(i.images),S(i.portalResults),j(i.paginationInfo),f(t),void v(null);b(!0),v(null),1===t&&(w([]),S({}),j(null));try{let i;if(1===t){i={sources:o,totalPortals:a.sources.length,page:t,withImage:!0};const e=l.trim();e&&(i.name=e),m&&50!==m&&(i.limit=m),r.current={...i}}else i={...r.current,page:t};const s=await function(e,t=!1){const n=new URLSearchParams,r=e.sources||[];e.portal?n.set("portal",e.portal):r.length>0&&n.set("portals",r.join(","));const a=e.q||e.name||e.search;if(a&&n.set("q",a),!0===e.withImage&&n.set("withImage","1"),e.limit&&n.set("limit",String(e.limit)),void 0!==e.offset)n.set("offset",String(e.offset));else if(e.page&&e.limit){const t=(e.page-1)*e.limit;n.set("offset",String(t))}return F({endpoint:`/external/articles?${n.toString()}`,method:"GET",prod:t,basePath:ge})}(i,e),c=s?.data||{},u=c?.articles||c||[],d=c?.total||u.length,h=c?.limit||m,p=c?.offset||0,g={total:d,pages:Math.ceil(d/h),current_page:Math.floor(p/h)+1,per_page:h},b=[],y={};u.forEach(t=>{const n=t.portal?.id||"unknown",r=a.sources.find(e=>e.id===n||e.slug===n),i=r?.title||r?.name||t.portal?.name||n;if(y[n]||(y[n]={title:i,status:200,response:"OK",count:0}),t.image_url){const r=t.image_url;y[n].count++;const a=`${R({prod:e})}/api/atenea/proxy?url=${encodeURIComponent(r)}`;b.push({id:t.id,title:t.title,excerpt:t.excerpt,url:r,full:r,preview:r,thumbnail:r,proxiedUrl:a,filename:`${t.title}.jpg`,source:n,sourceTitle:i,author:t.author,categories:t.categories,published_at:t.published_at,article_url:t.url})}}),z.current[n]={images:b,portalResults:y,paginationInfo:g},w(b),S(y),j(g),f(t),P(new Set),0!==b.length||s?.result?.success||v(s?.result?.message||"No se encontraron imágenes")}catch(s){v(s.message||"Error al buscar imágenes en portales")}finally{b(!1)}},I=e=>{e<1||M(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-2",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(),M(1)},className:"flex flex-col gap-4 border-t pt-4 border-brand-blue-200",children:[A.jsxs("div",{className:"flex flex-col gap-3",children:[A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsxs("h3",{className:"text-lg font-semibold text-brand-blue-1000",children:["Selecciona 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-sm text-brand-blue-800 hover:text-brand-blue-1000 font-medium transition-colors",children:o.length===a.sources.length?"Deseleccionar todos":"Seleccionar todos"})]}),A.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:a.sources.map(e=>{const n=o.includes(e.id);return A.jsxs("button",{type:"button",onClick:()=>{return t=e.id,void s(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]);var t},disabled:t,className:` relative p-4 rounded-lg border-2 transition-all duration-200 flex flex-col items-center justify-center min-h-25 gap-2 max-h-27.5 box-border ${n?"border-brand-blue-800 bg-brand-blue-50":"border-gray-200 bg-white hover:border-brand-blue-350"} ${t?"opacity-50 cursor-not-allowed":"cursor-pointer"} hover:shadow-md `,children:[n&&A.jsx("div",{className:"absolute top-2 right-2 w-6 h-6 bg-brand-blue-800 rounded-full flex items-center justify-center",children:A.jsx("span",{className:"icon icon-tick-white icon--sm"})}),A.jsx("img",{className:"object-auto bg-no-repeat bg-center max-w-9/12 max-h-9/12",src:e.image,alt: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-col gap-1 hidden",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:10,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:[t.image?A.jsx("img",{src:t.image,alt:t.title,className:"w-10 h-10 object-cover rounded"}):A.jsx("span",{className:"font-medium",children:t.title}),A.jsx("span",{className:200===t.status?"text-green-1000":"text-red-1000",children:200===t.status?`${t.count} imágenes`:t.response})]},e))})]}),$&&A.jsx("div",{className:"mt-6 md:w-full mx-auto",children:A.jsx(re,{image:$,onDiscard:()=>{_(null),v(null)},onDownload:()=>{},onSelect:e=>{if(n)if(e&&$&&e!==$.name){const t=new File([$],e,{type:$.type});n(t)}else n($)},showRetry:!1,disabled:t})}),!$&&(x.length>0||g)&&A.jsxs(A.Fragment,{children:[A.jsxs("div",{className:"mt-6 relative min-h-50","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.jsxs("div",{className:"relative grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2",children:[A.jsx(ue,{show:g,message:"Cargando imágenes..."}),x.map((n,r)=>{const a=`${n.source}-${n.id||r}`,i=n.preview||n.thumbnail||n.url||n.full;return T.has(a)?null:A.jsxs("div",{className:"group border border-brand-blue-200 rounded-lg overflow-hidden bg-white shadow-sm hover:shadow-md transition-all duration-200 cursor-pointer",onClick:()=>!N&&!g&&!t&&(async t=>{E(t.url||t.full),v(null);try{const n=t.full||t.url||t.preview;if(!n)throw new Error("No se encontró URL de la imagen");const r=`${R({prod:e})}/api/atenea/proxy?url=${encodeURIComponent(n)}`,a=await fetch(r);if(!a.ok)throw new Error(`Error al descargar: ${a.status}`);const i=await a.blob(),o=t.filename||t.title||`portal-${t.id||Date.now()}.jpg`,s=new File([i],o,{type:i.type||"image/jpeg"});_(s)}catch(n){v(n.message||"No se pudo recuperar la imagen del portal")}finally{E(null)}})(n),children:[A.jsxs("div",{className:"relative aspect-video bg-neutral-100",children:[A.jsx(ve,{src:i,fallbackSrc:n.proxiedUrl,alt:n.title||n.filename||`Imagen ${r+1}`,className:"object-cover w-full h-full",onError:()=>{P(e=>{const t=new Set(e);return t.add(a),t})}}),A.jsx("span",{className:"absolute top-1 left-1 bg-black/60 text-white text-xs px-2 py-1 rounded",children:n.sourceTitle}),N===(n.url||n.full)?A.jsxs("div",{className:"absolute inset-0 bg-white/90 flex flex-col items-center justify-center gap-2",children:[A.jsxs("div",{className:"relative w-10 h-10",children:[A.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-200 rounded-full"}),A.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-800 rounded-full border-t-transparent animate-spin"})]}),A.jsx("span",{className:"text-sm font-medium text-brand-blue-1000",children:"Descargando..."})]}):A.jsxs("div",{className:"absolute inset-0 bg-brand-blue-800/0 group-hover:bg-brand-blue-800/50 transition-colors duration-200 flex items-center justify-center flex-col",children:[A.jsx("span",{className:"icon icon-round-check-filled-blue icon--2xl max-w-full max-h-full opacity-0 group-hover:opacity-100 transition-opacity duration-200"}),A.jsx("span",{style:{textShadow:"1px 0 #001978, -1px 0 #001978, 0 1px #001978, 0 -0.5px #001978, 0.5px 0.5px #001978, -1px -1px #001978, 1px -1px #001978, -1px 1px #001978"},className:"max-w-full max-h-full opacity-0 group-hover:opacity-100 transition-opacity duration-200 text-neutral-white-000",children:"Seleccionar"})]})]}),n.title&&A.jsx("div",{className:"px-2 pb-2 pt-1",children:A.jsx("p",{className:"text-xs text-gray-600 limbo-truncate",title:n.title,children:n.title})})]},a)})]})]}),A.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2",children:[A.jsxs("button",{onClick:()=>I(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:()=>I(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 we=[{id:"upload",label:"Subir archivo"},{id:"ai",label:"Generar con IA"},{id:"stock",label:"Buscar en Stock"},{id:"portals",label:"Otros portales"}];function ke({onSelect:e,disabled:t=!1,apiKey:n,prod:r=!1}){const{isMobile:a,isTouch:i}=M(),[o,s]=u.useState("upload"),[l,c]=u.useState(null),[d,m]=u.useState(null),h=u.useRef(),p=["limbo-tabs","flex","gap-4","border-b-2","border-brand-blue-200","mb-4",a&&"overflow-x-auto scrollbar-none"].filter(Boolean).join(" "),f=e=>{const t=["limbo-tab","relative","px-4","py-2","font-medium","text-brand-blue-1000","bg-transparent","border-0","border-b-2","cursor-pointer","transition-all","duration-200","hover:text-pink-1000","focus:outline-none","focus-visible:ring-2","focus-visible:ring-brand-blue-400","focus-visible:ring-offset-2","text-nowrap"];return e?t.push("border-b-brand-blue-1000","font-semibold","limbo-active"):t.push("border-b-transparent"),a&&t.push("min-w-[100px]","min-h-[44px]","text-sm","shrink-0"),i&&t.push("touch-manipulation"),t.join(" ")};return A.jsxs("div",{className:"limbo-upload-form py-4 min-w-fit max-w-7xl mx-auto",children:[A.jsx("div",{className:p,role:"tablist","aria-label":"Opciones de subida de imagen",style:a?{WebkitOverflowScrolling:"touch",scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,children:we.map(e=>{const t=o===e.id;return A.jsx("button",{type:"button","data-upload-tab-id":e.id,className:f(t),"aria-current":t?"page":void 0,"aria-selected":t,role:"tab",tabIndex:t?0:-1,onClick:()=>s(e.id),onKeyDown:t=>((e,t)=>{const n=we.findIndex(e=>e.id===t);let r=n;switch(e.key){case"ArrowLeft":e.preventDefault(),r=n>0?n-1:we.length-1;break;case"ArrowRight":e.preventDefault(),r=n<we.length-1?n+1:0;break;case"Home":e.preventDefault(),r=0;break;case"End":e.preventDefault(),r=we.length-1;break;case"Enter":case" ":return e.preventDefault(),void s(t);default:return}const a=we[r];a&&(s(a.id),setTimeout(()=>{const e=document.querySelector(`[data-upload-tab-id="${a.id}"]`);e&&e.focus()},0))})(t,e.id),id:`upload-tab-${e.id}`,"aria-controls":`upload-tabpanel-${e.id}`,style:i?{WebkitTapHighlightColor:"transparent"}:void 0,children:e.label},e.id)})}),A.jsxs("div",{className:"limbo-tab-content px-2 py-2",role:"tabpanel",id:`upload-tabpanel-${o}`,"aria-labelledby":`upload-tab-${o}`,children:["upload"===o&&A.jsx(ae,{file:l,setFile:c,previewUrl:d,setPreviewUrl:m,fileInputRef:h,onSelect:e,disabled:t}),"ai"===o&&A.jsx(de,{apiKey:n,prod:r,disabled:t,onSelect:e}),"stock"===o&&A.jsx(fe,{apiKey:n,prod:r,disabled:t,onSelect:e}),"portals"===o&&A.jsx(xe,{apiKey:n,prod:r,disabled:t,onSelect:e})]})]})}const Se="undefined"!=typeof window&&void 0!==window.document,Ce=Se?window:{},je=!!Se&&"ontouchstart"in Ce.document.documentElement,Ne=!!Se&&"PointerEvent"in Ce,Ee="cropper",$e=`${Ee}-canvas`,_e=`${Ee}-crosshair`,ze=`${Ee}-grid`,Te=`${Ee}-handle`,Ae=`${Ee}-image`,Pe=`${Ee}-selection`,Me=`${Ee}-shade`,Ie=`${Ee}-viewer`,Le="select",De="move",Oe="scale",Re="rotate",Fe="transform",Ue="none",qe="n-resize",Be="e-resize",We="s-resize",He="w-resize",Ve="ne-resize",Ke="nw-resize",Ge="se-resize",Qe="sw-resize",Ye=Ne?"pointerdown":je?"touchstart":"mousedown",Xe=Ne?"pointermove":je?"touchmove":"mousemove",Je=Ne?"pointerup pointercancel":je?"touchend touchcancel":"mouseup",Ze="error",et="keydown",tt="load",nt="wheel",rt="action",at="actionend",it="actionstart",ot="change",st="transform";const lt=Number.isNaN||Ce.isNaN;function ct(e){return"number"==typeof e&&!lt(e)}function ut(e){return ct(e)&&e>0&&e<1/0}function dt(e){return"object"==typeof e&&null!==e}const{hasOwnProperty:mt}=Object.prototype;function ht(e){if(!dt(e))return!1;try{const{constructor:t}=e,{prototype:n}=t;return t&&n&&mt.call(n,"isPrototypeOf")}catch(t){return!1}}function pt(e){return"function"==typeof e}function ft(e){return"object"==typeof e&&null!==e&&1===e.nodeType}const gt=/([a-z\d])([A-Z])/g;function bt(e){return String(e).replace(gt,"$1-$2").toLowerCase()}const yt=/-[A-z\d]/g;function vt(e){return e.replace(yt,e=>e.slice(1).toUpperCase())}const xt=/\s\s*/;function wt(e,t,n,r){t.trim().split(xt).forEach(t=>{e.removeEventListener(t,n,r)})}function kt(e,t,n,r){t.trim().split(xt).forEach(t=>{e.addEventListener(t,n,r)})}function St(e,t,n,r){kt(e,t,n,Object.assign(Object.assign({},r),{once:!0}))}const Ct={bubbles:!0,cancelable:!0,composed:!0};const jt=Promise.resolve();function Nt(e){const{documentElement:t}=e.ownerDocument,n=e.getBoundingClientRect();return{left:n.left+(Ce.pageXOffset-t.clientLeft),top:n.top+(Ce.pageYOffset-t.clientTop)}}const Et=/deg|g?rad|turn$/i;function $t(e){const t=parseFloat(e)||0;if(0!==t){const[n="rad"]=String(e).match(Et)||[];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 _t="contain";function zt(e,t=_t){const{aspectRatio:n}=e;let{width:r,height:a}=e;const i=ut(r),o=ut(a);if(i&&o){const e=a*n;t===_t&&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 Tt(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 Tt(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 At=/left|top|width|height/i,Pt="open",Mt=new WeakMap,It=new WeakMap,Lt=new Map,Dt=Ce.document&&Array.isArray(Ce.document.adoptedStyleSheets)&&"replaceSync"in Ce.CSSStyleSheet.prototype;class Ot extends HTMLElement{get $sharedStyle(){return(this.themeColor?`:host{--theme-color: ${this.themeColor};}`:"")+":host([hidden]){display:none!important}"}constructor(){var e,t;super(),this.shadowRootMode=Pt,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&&Lt.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=vt(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=It.get(this),t=this.$sharedStyle;e&&t&&(Dt?e.replaceSync(t):e.textContent=t);break}}}$propertyChangedCallback(e,t,n){if(!Object.is(n,t))switch(e=bt(e),typeof n){case"boolean":!0===n?this.hasAttribute(e)||this.setAttribute(e,""):this.removeAttribute(e);break;case"number":n=lt(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=vt(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.shadowRoot||this.attachShadow({mode:this.shadowRootMode||Pt});if(Mt.set(this,e),It.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(){It.has(this)&&It.delete(this),Mt.has(this)&&Mt.delete(this)}$getTagNameOf(e){var t;return null!==(t=Lt.get(e))&&void 0!==t?t:e}$setStyles(e){return Object.keys(e).forEach(t=>{let n=e[t];ct(n)&&(n=0!==n&&At.test(t)?`${n}px`:String(n)),this.style[t]=n}),this}$getShadowRoot(){return this.shadowRoot||Mt.get(this)}$addStyles(e){let t;const n=this.$getShadowRoot();return Dt?(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({},Ct),{detail:n}),r)))}(this,e,t,n)}$nextTick(e){return function(e,t){return t?jt.then(e?t.bind(e):t):jt}(this,e)}static $define(e,t){dt(e)&&(t=e,e=""),e||(e=this.$name||this.name),e=bt(e),Se&&Ce.customElements&&!Ce.customElements.get(e)&&customElements.define(e,this,t)}}Ot.$version="2.1.0";class Rt extends Ot{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=Ue,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),kt(this,Ye,this.$onPointerDown)),this.$onPointerMove||(this.$onPointerMove=this.$handlePointerMove.bind(this),kt(this.ownerDocument,Xe,this.$onPointerMove)),this.$onPointerUp||(this.$onPointerUp=this.$handlePointerUp.bind(this),kt(this.ownerDocument,Je,this.$onPointerUp)),this.$onWheel||(this.$onWheel=this.$handleWheel.bind(this),kt(this,nt,this.$onWheel,{passive:!1,capture:!0}))}$unbind(){this.$onPointerDown&&(wt(this,Ye,this.$onPointerDown),this.$onPointerDown=null),this.$onPointerMove&&(wt(this.ownerDocument,Xe,this.$onPointerMove),this.$onPointerMove=null),this.$onPointerUp&&(wt(this.ownerDocument,Je,this.$onPointerUp),this.$onPointerUp=null),this.$onWheel&&(wt(this,nt,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)&&(ct(t)&&1!==t||ct(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=Fe:ft(e.target)&&(i=e.target.action||e.target.getAttribute("action")||""),!1!==this.$emit(it,{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===Ue||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===Fe){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=Re,r.rotate=o,r.centerX=l,r.centerY=c):d?(r.action=Oe,r.scale=s,r.centerX=l,r.centerY=c):r.action=Ue}else{const[e]=Array.from(n.values());Object.assign(r,e)}n.forEach(e=>{e.startX=e.endX,e.startY=e.endY}),r.action!==Ue&&this.$emit(rt,r,{cancelable:!1})}$handlePointerUp(e){const{$action:t,$pointers:n}=this;if(!this.disabled&&t!==Ue&&!1!==this.$emit(at,{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=Ue)}}$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(rt,{action:Oe,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;ht(e)&&(ut(e.width)||ut(e.height))&&(({width:a,height:i}=zt({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(Ae));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),ht(e)&&pt(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)})}}Rt.$name=$e,Rt.$version="2.1.0";const Ft=new WeakMap,Ut=["alt","crossorigin","decoding","elementtiming","fetchpriority","loading","referrerpolicy","sizes","src","srcset"];class qt extends Ot{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,this.alt="",this.crossorigin="",this.decoding="",this.elementtiming="",this.fetchpriority="",this.loading="",this.referrerpolicy="",this.sizes="",this.src="",this.srcset=""}set $canvas(e){Ft.set(this,e)}get $canvas(){return Ft.get(this)}static get observedAttributes(){return super.observedAttributes.concat(Ut,["initial-center-size","rotatable","scalable","skewable","translatable"])}attributeChangedCallback(e,t,n){Object.is(n,t)||(super.attributeChangedCallback(e,t,n),Ut.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($e));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),kt(t,it,this.$onCanvasActionStart),kt(t,at,this.$onCanvasActionEnd),kt(t,rt,this.$onCanvasAction)),this.$onLoad=this.$handleLoad.bind(this),kt(e,tt,this.$onLoad),this.$getShadowRoot().appendChild(e)}disconnectedCallback(){const{$image:e,$canvas:t}=this;t&&(this.$onCanvasActionStart&&(wt(t,it,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(wt(t,at,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(wt(t,rt,this.$onCanvasAction),this.$onCanvasAction=null)),e&&this.$onLoad&&(wt(e,tt,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!==Fe||this.rotatable&&this.scalable||(r=this.rotatable?Re:this.scalable?Oe:Ue),r){case De:if(this.translatable){let r=null;e&&(r=e.target.closest(this.$getTagNameOf(Pe))),r||(r=t.querySelector(this.$getTagNameOf(Pe))),r&&r.multiple&&!r.active&&(r=t.querySelector(`${this.$getTagNameOf(Pe)}[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 Re: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 Oe:if(this.scalable)if(e){const t=e.target.closest(this.$getTagNameOf(Pe));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 Fe: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=()=>{wt(t,Ze,i),setTimeout(()=>{e(t)})},i=()=>{wt(t,tt,a),n(r)};St(t,tt,a),St(t,Ze,i)}});return pt(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&&ct(e)&&ct(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&&ct(e)&&ct(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=$t(e),a=Math.cos(r),i=Math.sin(r),[o,s,l,c]=[a,i,-i,a];if(ct(t)&&ct(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,ct(t)&&ct(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=$t(e),r=$t(t);this.$transform(1,Math.tan(r),Math.tan(n),1,0,0)}return this}$translate(e,t=e){return this.translatable&&ct(e)&&ct(t)&&this.$transform(1,0,0,1,e,t),this}$transform(e,t,n,r,a,i){return ct(e)&&ct(t)&&ct(n)&&ct(r)&&ct(a)&&ct(i)?this.$setTransform(Tt(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),ct(e)&&ct(t)&&ct(n)&&ct(r)&&ct(a)&&ct(i))){const o=[...this.$matrix],s=[e,t,n,r,a,i];if(!1===this.$emit(st,{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])}}qt.$name=Ae,qt.$version="2.1.0";const Bt=new WeakMap;class Wt extends Ot{constructor(){super(...arguments),this.$onCanvasActionEnd=null,this.$onCanvasActionStart=null,this.$onSelectionChange=null,this.$style=":host{display:block;height:0;left:0;outline:var(--theme-color) solid 1px;position:relative;top:0;width:0}:host([transparent]){outline-color:transparent}",this.x=0,this.y=0,this.width=0,this.height=0,this.slottable=!1,this.themeColor="rgba(0, 0, 0, 0.65)"}set $canvas(e){Bt.set(this,e)}get $canvas(){return Bt.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["height","width","x","y"])}connectedCallback(){super.connectedCallback();const e=this.closest(this.$getTagNameOf($e));if(e){this.$canvas=e,this.style.position="absolute";const t=e.querySelector(this.$getTagNameOf(Pe));t&&(this.$onCanvasActionStart=e=>{t.hidden&&e.detail.action===Le&&(this.hidden=!1)},this.$onCanvasActionEnd=e=>{t.hidden&&e.detail.action===Le&&(this.hidden=!0)},this.$onSelectionChange=e=>{const{x:n,y:r,width:a,height:i}=e.defaultPrevented?t:e.detail;this.$change(n,r,a,i),(t.hidden||0===n&&0===r&&0===a&&0===i)&&(this.hidden=!0)},kt(e,it,this.$onCanvasActionStart),kt(e,at,this.$onCanvasActionEnd),kt(e,ot,this.$onSelectionChange))}this.$render()}disconnectedCallback(){const{$canvas:e}=this;e&&(this.$onCanvasActionStart&&(wt(e,it,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(wt(e,at,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onSelectionChange&&(wt(e,ot,this.$onSelectionChange),this.$onSelectionChange=null)),super.disconnectedCallback()}$change(e,t,n=this.width,r=this.height){return ct(e)&&ct(t)&&ct(n)&&ct(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:Ce.innerWidth})}}Wt.$name=Me,Wt.$version="2.1.0";class Ht extends Ot{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=Ue,this.plain=!1,this.slottable=!1,this.themeColor="rgba(51, 153, 255, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["action","plain"])}}Ht.$name=Te,Ht.$version="2.1.0";const Vt=new WeakMap;class Kt extends Ot{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){Vt.set(this,e)}get $canvas(){return Vt.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(()=>{ut(n)&&n<=1&&this.$initSelection(!0,!0)});break;case"keyboard":this.$nextTick(()=>{this.$canvas&&(n?this.$onDocumentKeyDown||(this.$onDocumentKeyDown=this.$handleKeyDown.bind(this),kt(this.ownerDocument,et,this.$onDocumentKeyDown)):this.$onDocumentKeyDown&&(wt(this.ownerDocument,et,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(ot,{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($e));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),kt(e,it,this.$onCanvasActionStart),kt(e,at,this.$onCanvasActionEnd),kt(e,rt,this.$onCanvasAction)):this.$render()}disconnectedCallback(){const{$canvas:e}=this;e&&(this.$onCanvasActionStart&&(wt(e,it,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(wt(e,at,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(wt(e,rt,this.$onCanvasAction),this.$onCanvasAction=null)),super.disconnectedCallback()}$getSelections(){let e=[];return this.parentElement&&(e=Array.from(this.parentElement.querySelectorAll(this.$getTagNameOf(Pe)))),e}$initSelection(e=!1,t=!1){const{initialCoverage:n,parentElement:r}=this;if(ut(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;ut(a)&&({width:i,height:o}=zt({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(ot,{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(ot,{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;const i=r?function(e){if("function"==typeof e.composedPath)return e.composedPath().find(ft)||e.target;return e.target}(r):null;if(!a&&this.multiple&&(a=this.$action||(null==i?void 0:i.action),this.$action=a),!a||this.hidden&&a!==Le||this.multiple&&!this.active&&a!==Oe)return;const{width:o,height:s}=this;let l=n.endX-n.startX,c=n.endY-n.startY,{aspectRatio:u}=this;switch(!ut(u)&&r.shiftKey&&(u=ut(o)&&ut(s)?o/s:1),a){case Le:if(0!==l||0!==c){0===l?l=c:0===c&&(c=l);const{$canvas:e}=this,r=Nt(t);(this.multiple&&!this.hidden?this.$createSelection():this).$change(n.startX-r.left,n.startY-r.top,Math.abs(l),Math.abs(c),u),l<0?c<0?a=Ke:c>0&&(a=Qe):l>0&&(c<0?a=Ve:c>0&&(a=Ge)),e&&(e.$action=a)}break;case De:this.movable&&(this.dynamic||this.$actionStartTarget&&this.contains(this.$actionStartTarget))&&this.$move(l,c);break;case Oe:if(r&&this.zoomable&&(this.dynamic||this.contains(r.target))){const e=Nt(t);this.$zoom(n.scale,r.pageX-e.left,r.pageY-e.top)}break;default:this.$resize(a,l,c,u)}}$handleActionEnd(){this.$action="",this.$actionStartTarget=null}$handleKeyDown(e){if(this.hidden||!this.keyboard||this.multiple&&!this.active||e.defaultPrevented)return;const{activeElement:t}=document;if(!t||!["INPUT","TEXTAREA"].includes(t.tagName)&&!["true","plaintext-only"].includes(t.contentEditable))switch(e.key){case"Backspace":e.metaKey&&(e.preventDefault(),this.$removeSelection());break;case"Delete":e.preventDefault(),this.$removeSelection();break;case"ArrowLeft":e.preventDefault(),this.$move(-1,0);break;case"ArrowRight":e.preventDefault(),this.$move(1,0);break;case"ArrowUp":e.preventDefault(),this.$move(0,-1);break;case"ArrowDown":e.preventDefault(),this.$move(0,1);break;case"+":e.preventDefault(),this.$zoom(.1);break;case"-":e.preventDefault(),this.$zoom(-.1)}}$center(){const{parentElement:e}=this;if(!e)return this;const t=(e.offsetWidth-this.width)/2,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=ut(r),{$canvas:i}=this;let{x:o,y:s,width:l,height:c}=this;switch(e){case qe:s+=n,c-=n,c<0&&(e=We,c=-c,s-=c),a&&(o+=(t=n*r)/2,l-=t,l<0&&(l=-l,o-=l));break;case Be:l+=t,l<0&&(e=He,l=-l,o-=l),a&&(s-=(n=t/r)/2,c+=n,c<0&&(c=-c,s-=c));break;case We:c+=n,c<0&&(e=qe,c=-c,s-=c),a&&(o-=(t=n*r)/2,l+=t,l<0&&(l=-l,o-=l));break;case He:o+=t,l-=t,l<0&&(e=Be,l=-l,o-=l),a&&(s+=(n=t/r)/2,c-=n,c<0&&(c=-c,s-=c));break;case Ve:a&&(n=-t/r),s+=n,c-=n,l+=t,l<0&&c<0?(e=Qe,l=-l,c=-c,o-=l,s-=c):l<0?(e=Ke,l=-l,o-=l):c<0&&(e=Ge,c=-c,s-=c);break;case Ke:a&&(n=t/r),o+=t,s+=n,l-=t,c-=n,l<0&&c<0?(e=Ge,l=-l,c=-c,o-=l,s-=c):l<0?(e=Ve,l=-l,o-=l):c<0&&(e=Qe,c=-c,s-=c);break;case Ge:a&&(n=t/r),l+=t,c+=n,l<0&&c<0?(e=Ke,l=-l,c=-c,o-=l,s-=c):l<0?(e=Qe,l=-l,o-=l):c<0&&(e=Ve,c=-c,s-=c);break;case Qe:a&&(n=-t/r),o+=t,l-=t,c+=n,l<0&&c<0?(e=Ve,l=-l,c=-c,o-=l,s-=c):l<0?(e=Ge,l=-l,o-=l):c<0&&(e=Ke,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 ct(t)&&ct(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||!ct(e)||!ct(t)||!ct(n)||!ct(r)||n<0||r<0?this:(ut(a)&&({width:n,height:r}=zt({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(ot,{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(ht(e)&&(ut(e.width)||ut(e.height))&&(({width:a,height:i}=zt({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(Ae));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),ht(e)&&pt(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)})}}Kt.$name=Pe,Kt.$version="2.1.0";class Gt extends Ot{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))}}Gt.$name=ze,Gt.$version="2.1.0";class Qt extends Ot{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"])}}Qt.$name=_e,Qt.$version="2.1.0";const Yt=new WeakMap,Xt=new WeakMap,Jt=new WeakMap,Zt=new WeakMap,en="vertical";class tn extends Ot{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=en,this.selection="",this.slottable=!1}set $image(e){Xt.set(this,e)}get $image(){return Xt.get(this)}set $sourceImage(e){Zt.set(this,e)}get $sourceImage(){return Zt.get(this)}set $canvas(e){Yt.set(this,e)}get $canvas(){return Yt.get(this)}set $selection(e){Jt.set(this,e)}get $selection(){return Jt.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["resize","selection"])}connectedCallback(){var e,t;super.connectedCallback();let n=null;if(n=this.selection?null!==(t=null===(e=function(e){const t=e.getRootNode();switch(t.nodeType){case 1:return t.ownerDocument;case 9:case 11:return t}return null}(this))||void 0===e?void 0:e.querySelector(this.selection))&&void 0!==t?t:null:this.closest(this.$getTagNameOf(Pe)),ft(n)){this.$selection=n,this.$onSelectionChange=this.$handleSelectionChange.bind(this),kt(n,ot,this.$onSelectionChange);const e=n.closest(this.$getTagNameOf($e));if(e){this.$canvas=e;const t=e.querySelector(this.$getTagNameOf(Ae));t&&(this.$sourceImage=t,this.$image=t.cloneNode(!0),this.$getShadowRoot().appendChild(this.$image),this.$onSourceImageLoad=this.$handleSourceImageLoad.bind(this),this.$onSourceImageTransform=this.$handleSourceImageTransform.bind(this),kt(t.$image,tt,this.$onSourceImageLoad),kt(t,st,this.$onSourceImageTransform))}this.$render()}}disconnectedCallback(){const{$selection:e,$sourceImage:t}=this;e&&this.$onSelectionChange&&(wt(e,ot,this.$onSelectionChange),this.$onSelectionChange=null),t&&this.$onSourceImageLoad&&(wt(t.$image,tt,this.$onSourceImageLoad),this.$onSourceImageLoad=null),t&&this.$onSourceImageTransform&&(wt(t,st,this.$onSourceImageTransform),this.$onSourceImageTransform=null),super.disconnectedCallback()}$handleSelectionChange(e){this.$render(e.defaultPrevented?this.$selection: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(()=>{this.$render()}))}$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 en: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&&setTimeout(()=>{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 nn(){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),H(await F({endpoint:`/assets/${e}/variants`,method:"POST",body:{variants:n,async:!1},basePath:K,useJWT:!0}))}catch(n){throw V(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)},createVariantFromBlob:async(e,a,o={})=>{if(!e||!a)return r("ID de asset y blob son requeridos"),null;t(!0),r(null),i(null);try{const t=await async function(e,t,r={}){try{const n=new FormData,a=r.format||"webp",i=`${r.name||"variant"}.${a}`;return n.append("file",t,i),n.append("variant_name",r.name||"variant"),n.append("width",String(r.width||0)),n.append("height",String(r.height||0)),n.append("output_format",r.format||"webp"),H(await F({endpoint:`/assets/${e}/variants/upload`,method:"POST",body:n,basePath:K,isFormData:!0,useJWT:!0}))}catch(n){throw V(n)}}(e,a,{name:o.name||`crop_${Date.now()}`,width:o.width||0,height:o.height||0,format:o.format||"webp"});if(t?.result)return i(t.result),t.result;throw new Error("No se pudo crear la variante")}catch(s){return console.error("Error creating variant from blob:",s),r(s.message||"Error desconocido al crear variante"),null}finally{t(!1)}},loading:e,error:n,createdVariant:a,reset:()=>{r(null),i(null)}}}tn.$name=Ie,tn.$version="2.1.0",Rt.$define(),Qt.$define(),Gt.$define(),Ht.$define(),qt.$define(),Kt.$define(),Wt.$define(),tn.$define();class rn{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 an(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 on=Object.freeze(Object.defineProperty({__proto__:null,default:an,downloadImage:an},Symbol.toStringTag,{value:"Module"}));function sn({image:e,onSave:t,onCancel:n,onDelete:r,onError:a=null,deleting:i=!1,onVariantCreated:o=null,onUpload:s=null,uploading:l=!1,cropperConfig:c=null}){const[d,m]=u.useState(!1),[h,p]=u.useState(null),[f,g]=u.useState(!1),[b,y]=u.useState(!0),[v,x]=u.useState(!0),[w,k]=u.useState({x:20,y:100}),[S,C]=u.useState(!1),[j,N]=u.useState({x:0,y:0}),[E,$]=u.useState(!1),[_,z]=u.useState(!0),[T,P]=u.useState(!1),[M,I]=u.useState({horizontal:!1,vertical:!1}),[L,D]=u.useState(!1),[O,R]=u.useState(!1),[F,U]=u.useState(!1),[q,B]=u.useState(!1),[W]=u.useState(()=>{if(!e||!e.filename)return"image";const[t]=e.filename.split(".");return t}),H=u.useMemo(()=>{if(c)return{mandatoryCrops:c.mandatoryCrops||[],allowCustomCrops:!1!==c.allowAdditionalCrops,showDimensionInputs:!0===c.showDimensionInputs,maxCrops:c.maxCrops||null};const e=window.limboCore?.config?.getGlobal()||{};return{mandatoryCrops:e.cropper?.mandatoryCrops||[],allowCustomCrops:!1!==e.cropper?.allowCustomCrops,showDimensionInputs:!0===e.cropper?.showDimensionInputs,maxCrops:e.cropper?.maxCrops||null}},[c]),[V,K]=u.useState(()=>H.mandatoryCrops.length>0?H.mandatoryCrops.map((e,t)=>({id:`crop-${t}`,label:e.label,width:e.width,height:e.height,required:!1!==e.required,isCustom:!1,confirmed:!1,lockDimensions:!(!e.width||!e.height),savedState:null})):[{id:"crop-default-0",label:W,width:e.width||1920,height:e.height||1080,required:!1,isCustom:!0,confirmed:!1,savedState:null}]),[G,Q]=u.useState(0),Y=V[G],X=u.useMemo(()=>Y&&Y.width&&Y.height?Y.width/Y.height:"",[Y]),Z=u.useMemo(()=>{const e=50;if(!X||""===X)return{minWidth:e,minHeight:e};if(X>=1){return{minWidth:e,minHeight:e/X}}return{minWidth:e*X,minHeight:e}},[X]),[ee,te]=u.useState(!1),[ne,re]=u.useState([]),[ae,ie]=u.useState(null),oe=window.limboCore?.accessibilityManager,{createVariantFromBlob:se,loading:le,error:ce}=nn(),de=((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 rn(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]),u.useEffect(()=>{i.current&&d&&i.current.selection.setAspectRatio(b.aspectRatio)},[b.aspectRatio,d]),u.useEffect(()=>{i.current&&d&&i.current.canvas.setBackground(b.shade)},[b.shade,d]);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:X||null,showGrid:b,shade:v,initialCoverage:.5,paspartuFactor:.85}),{refs:me,state:he,transform:pe,selection:fe,utils:ge}=de,{canvasRef:be,imageRef:ye,selectionRef:ve}=me,{cropData:xe,imageInfo:we,canExport:ke,transformVersion:Se}=he,Ce=u.useMemo(()=>we||{naturalWidth:e.width||1920,naturalHeight:e.height||1080,currentWidth:e.width||1920,currentHeight:e.height||1080},[we,e.width,e.height]),je=u.useCallback(()=>y(e=>!e),[]),Ne=u.useCallback(()=>x(e=>!e),[]),Ee=u.useCallback(()=>R(e=>!e),[]),$e=u.useCallback(()=>U(e=>!e),[]),_e=u.useCallback(()=>B(e=>!e),[]),ze=u.useCallback(()=>pe.center(),[pe]),Te=u.useCallback(()=>fe.center(),[fe]),Ae=u.useCallback(()=>fe.reset(),[fe]),Pe=u.useCallback((e,t)=>pe.move(e,t),[pe]),Me=u.useCallback(e=>pe.zoom(e),[pe]),Ie=u.useCallback(e=>pe.rotate(e),[pe]),Le=u.useCallback(e=>{fe.setCoverage(e)},[fe]),De=u.useCallback(()=>{I(e=>{const t=!e.horizontal;return pe.flipHorizontal(),{...e,horizontal:t}})},[pe]),Oe=u.useCallback(()=>{I(e=>{const t=!e.vertical;return pe.flipVertical(),{...e,vertical:t}})},[pe]),Re=u.useCallback(()=>{if(!de.manager||!he.isReady)return null;try{const e=xe?{...xe}:null;let t=null;if(ve.current){const e=ve.current;t={x:e.x??0,y:e.y??0,width:e.width??0,height:e.height??0}}let n=null;if(ye.current){const e=ye.current.$getTransform?.();e&&Array.isArray(e)&&(n=[...e])}const r={cropData:e,selectorState:t,imageTransform:n,flipState:{horizontal:M.horizontal,vertical:M.vertical}};return console.log(`[CropperView] 💾 Guardando estado del crop ${G}:`,r),K(e=>e.map((e,t)=>t===G?{...e,savedState:r}:e)),r}catch(e){return console.warn("Error saving crop state:",e),null}},[de.manager,he.isReady,xe,M,G,ye,ve]),Fe=u.useCallback(e=>{const t=V[e];if(!t||!t.savedState)return console.log(`[CropperView] ℹ️ No hay estado guardado para crop ${e}, centrando...`),void setTimeout(()=>{ze(),setTimeout(()=>Te(),100)},100);if(de.manager&&he.isReady)try{const{savedState:n}=t;if(console.log(`[CropperView] ♻️ Restaurando estado del crop ${e}:`,n),n.imageTransform&&ye.current&&Array.isArray(n.imageTransform)&&setTimeout(()=>{if(ye.current&&ye.current.$setTransform){const[e,t,r,a,i,o]=n.imageTransform;ye.current.$setTransform(e,t,r,a,i,o),console.log(`[CropperView] ✅ Imagen restaurada: transform(${e.toFixed(2)}, ${t.toFixed(2)}, ${r.toFixed(2)}, ${a.toFixed(2)}, ${i.toFixed(0)}, ${o.toFixed(0)})`)}},100),n.selectorState&&ve.current){const{x:e,y:t,width:r,height:a}=n.selectorState;setTimeout(()=>{ve.current&&(ve.current.x=e,ve.current.y=t,ve.current.width=r,ve.current.height=a,ve.current.$render&&ve.current.$render(),console.log(`[CropperView] ✅ Selector restaurado: ${r}×${a} en (${e}, ${t})`))},150)}n.flipState&&I({horizontal:n.flipState.horizontal??!1,vertical:n.flipState.vertical??!1}),console.log("[CropperView] ✨ Estado restaurado completamente")}catch(n){console.error("Error restoring crop state:",n),setTimeout(()=>{ze(),setTimeout(()=>Te(),100)},100)}else console.warn("Cropper not ready for state restoration")},[V,de.manager,he.isReady,ze,Te,ve,ye]),Ue=u.useCallback(()=>{for(let e=0;e<V.length;e++){const t=V[e];if(!t.label||""===t.label.trim())return e}return-1},[V]),qe=u.useCallback(async e=>{e!==G&&(P(!0),Re(),await new Promise(e=>setTimeout(e,100)),Q(e),await new Promise(e=>setTimeout(e,250)),Fe(e),await new Promise(e=>setTimeout(e,200)),P(!1))},[G,Re,Fe]),Be=u.useCallback(()=>{if(!H.allowCustomCrops)return void alert("No se pueden añadir recortes personalizados en este modo.");const t={id:`crop-custom-${Date.now()}`,label:`Recorte ${V.length+1}`,width:e.width||1920,height:e.height||1080,required:!1,isCustom:!0,confirmed:!1,savedState:null};K(e=>[...e,t]),oe?.announce(`Nuevo recorte personalizado añadido: ${t.label}. Selecciónalo para editarlo.`)},[H.allowCustomCrops,V.length,e.width,e.height,oe]),We=u.useCallback((e,t)=>{const n=parseInt(t,10);""===t||isNaN(n)||K(t=>t.map((t,r)=>r===G?{...t,[e]:n}:t))},[G]),He=u.useCallback(e=>{const t=Y[e];let n=100;if(be.current&&we){const e=be.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&&K(t=>t.map((t,n)=>n===G?{...t,[e]:r}:t));const a={...Y,[e]:r},i=a.width/a.height,o=fe.getData?.();fe.setAspectRatio(i),o&&void 0!==o.x&&setTimeout(()=>{fe.set?.(o.x,o.y,o.width,o.height)},50)},[G,Y,fe,be,we]),Ve=u.useCallback(e=>{K(t=>t.map((t,n)=>n===G?{...t,label:e}:t))},[G]),Ke=u.useCallback((e,t=null)=>{t=t||V[e].label;if(!window.confirm(`¿Estás seguro de que deseas eliminar "${t||"este recorte"}"? Esta acción también eliminará todos sus recortes.`))return;const n=V[e];if(n.required)alert("No se puede eliminar un recorte obligatorio.");else if(1!==V.length){if(K(t=>t.filter((t,n)=>n!==e)),e===G){const t=Math.max(0,e-1);Q(t)}else e<G&&Q(e=>e-1);oe?.announce(`Recorte ${n.label} eliminado`)}else alert("Debe haber al menos un recorte.")},[V,G,oe]),Ge=u.useCallback(async()=>{if(!ke)return null;try{const t=await fe.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}},[ke,e.mime_type,fe]),Qe=u.useCallback(async()=>{if(d)return m(!1),p(null),void g(!1);if(ke){m(!0),g(!0);try{const e=await Ge();e?p(e):(m(!1),alert("No se puede exportar el recorte por restricciones de CORS en la imagen original."))}finally{g(!1)}}else alert("No se puede exportar el recorte por restricciones de CORS en la imagen original.")},[ke,Ge,d]),Ye=u.useCallback(e=>{e.target.closest(".limbo-preview-modal-header")&&(C(!0),N({x:e.clientX-w.x,y:e.clientY-w.y}))},[w]),Xe=u.useCallback(e=>{S&&(e.preventDefault(),k({x:e.clientX-j.x,y:e.clientY-j.y}))},[S,j]),Je=u.useCallback(()=>{C(!1)},[]),Ze=u.useCallback(e=>{if(!e.target.closest(".limbo-preview-modal-header"))return;const t=e.touches[0];C(!0),N({x:t.clientX-w.x,y:t.clientY-w.y})},[w]),et=u.useCallback(e=>{if(!S)return;e.preventDefault();const t=e.touches[0];k({x:t.clientX-j.x,y:t.clientY-j.y})},[S,j]),tt=u.useCallback(()=>{C(!1)},[]);u.useEffect(()=>{if(S)return document.addEventListener("mousemove",Xe),document.addEventListener("mouseup",Je),document.addEventListener("touchmove",et,{passive:!1}),document.addEventListener("touchend",tt),()=>{document.removeEventListener("mousemove",Xe),document.removeEventListener("mouseup",Je),document.removeEventListener("touchmove",et),document.removeEventListener("touchend",tt)}},[S,Xe,Je,et,tt]),u.useEffect(()=>{if(!E)return;const e=e=>{"Escape"===e.key&&$(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[E]);const nt=u.useCallback(async(t,n=null)=>{const r=V[t];if(!r)throw new Error(`Crop ${t} no encontrado`);if(!r.savedState&&t!==G)throw new Error(`El recorte "${r.label}" aún no ha sido configurado`);const a={index:G,imageTransform:ye.current?.$getTransform?.(),selectorState:ve.current?{x:ve.current.x,y:ve.current.y,width:ve.current.width,height:ve.current.height}:null};try{if(t!==G&&r.savedState){if(console.log(`[CropperView] 🔄 Restaurando temporalmente crop ${t} para guardado...`),r.savedState.imageTransform&&ye.current?.$setTransform){const[e,t,n,a,i,o]=r.savedState.imageTransform;ye.current.$setTransform(e,t,n,a,i,o)}if(r.savedState.selectorState&&ve.current){const{x:e,y:t,width:n,height:a}=r.savedState.selectorState;ve.current.x=e,ve.current.y=t,ve.current.width=n,ve.current.height=a,ve.current.$render?.()}await new Promise(e=>setTimeout(e,100))}const a=Math.min(r.width,5e3),i=Math.min(r.height,5e3),s=await fe.toCanvas({width:a,height:i,imageSmoothingEnabled:!0,imageSmoothingQuality:"high"});if(!s)throw new Error(`No se pudo generar el canvas para "${r.label}"`);const l=globalThis.downloadFormat||"webp",c="webp"===l?"image/webp":"png"===l?"image/png":"image/jpeg",u=.9,d=await new Promise((e,t)=>{s.toBlob(n=>{n?e(n):t(new Error("No se pudo convertir el canvas a blob"))},c,u)});console.log("[CropperView] Canvas convertido a blob:",{size:d.size,type:d.type,dimensions:`${a}x${i}`});const m=`${r.label||"crop"}_${a}_${i}`,h=n||e.id;if(!h||"string"==typeof h&&h.startsWith("external")){console.log("[CropperView] 🌐 Imagen externa detectada, generando resultado local");const e=URL.createObjectURL(d),t={id:`local-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:m,filename:`${m}.${l}`,url:e,urlSigned:e,width:a,height:i,format:l,size:d.size,mime_type:c,blob:d,isLocal:!0};return oe?.announceSuccess(`Recorte creado localmente: ${m}`),t}const p=await se(h,d,{name:m,width:a,height:i,format:l});if(p)return oe?.announceSuccess(`Recorte creado: ${m}`),o?.(h,p),p;throw new Error("No se pudo crear la variante")}finally{if(t!==G&&a.imageTransform&&ye.current?.$setTransform){console.log(`[CropperView] ↩️ Restaurando estado original del crop ${a.index}...`);const[e,t,n,r,i,o]=a.imageTransform;if(ye.current.$setTransform(e,t,n,r,i,o),a.selectorState&&ve.current){const{x:e,y:t,width:n,height:r}=a.selectorState;ve.current.x=e,ve.current.y=t,ve.current.width=n,ve.current.height=r,ve.current.$render?.()}}}},[V,G,fe,se,e.id,o,oe,ye,ve]),rt=u.useCallback(async()=>{if(!ke){const e="No se puede exportar el recorte por restricciones de CORS en la imagen original.";return oe?.announceError(e),void alert(e)}if(!he.isReady){const e="El cropper aún no está inicializado. Espera un momento e inténtalo de nuevo.";return oe?.announceError(e),void alert(e)}Re(),oe?.announce("Creando recorte de la imagen");try{let n=e.id,r=null;if(e.file&&s){oe?.announce("Subiendo imagen...");const t=await s(e.file);if(!t||!t.id)throw new Error("No se pudo subir la imagen al servidor");n=t.id,r=t,oe?.announceSuccess("Imagen subida correctamente")}const a=await nt(G,n);a&&t(r?{crops:[a],asset:r}:a)}catch(n){console.warn("Error creating crop variant:",n);const e=n.message||"No se pudo crear el recorte. Inténtalo de nuevo.";oe?.announceError(e),alert(e),a?.(n)}},[ke,he.isReady,oe,Re,nt,G,t,a,e.file,e.id,s]),at=u.useCallback(async n=>{Re(),oe?.announce(`Guardando ${n.length} recortes...`);try{let a=e.id,i=null;if(e.file&&s){oe?.announce("Subiendo imagen...");const t=await s(e.file);if(!t||!t.id)throw new Error("No se pudo subir la imagen al servidor");a=t.id,i=t,oe?.announceSuccess("Imagen subida correctamente")}const o=[],l=[];for(const e of n)try{const t=await nt(e,a);t&&o.push(t)}catch(r){l.push({crop:V[e]?.label||`Crop ${e}`,error:r.message})}if(o.length>0&&(oe?.announceSuccess(`${o.length} recorte(s) guardado(s) correctamente`),t(i?{crops:o,asset:i}:o)),l.length>0){const e=`Errores al guardar algunos recortes:\n${l.map(e=>`- ${e.crop}: ${e.error}`).join("\n")}`;oe?.announceError(e),alert(e)}}catch(r){const e=r.message||"Error al procesar los recortes";oe?.announceError(e),alert(e),a?.(r)}},[Re,nt,V,oe,t,e.file,e.id,s,a]),it=u.useCallback(async()=>{const e=Ue();if(-1!==e){const t=V[e];return alert(`El recorte "${t.label||t||"(sin nombre)"}" debe tener un nombre válido.`),void Q(e)}if(V.length>1){ie("save");const e=V.map((e,t)=>({crop:e,index:t})).filter(({crop:e,index:t})=>e.required||e.savedState||t===G).map(({index:e})=>e);return re(e),void te(!0)}await rt()},[Ue,V,rt,G]),ot=u.useCallback(async t=>{const n=V[t];if(!n)throw new Error(`Crop ${t} no encontrado`);if(!n.savedState&&t!==G)throw new Error(`El recorte "${n.label}" aún no ha sido configurado`);const r={index:G,imageTransform:ye.current?.$getTransform?.(),selectorState:ve.current?{x:ve.current.x,y:ve.current.y,width:ve.current.width,height:ve.current.height}:null};try{if(t!==G&&n.savedState){if(console.log(`[CropperView] 🔄 Restaurando temporalmente crop ${t} para descarga...`),n.savedState.imageTransform&&ye.current?.$setTransform){const[e,t,r,a,i,o]=n.savedState.imageTransform;ye.current.$setTransform(e,t,r,a,i,o)}if(n.savedState.selectorState&&ve.current){const{x:e,y:t,width:r,height:a}=n.savedState.selectorState;ve.current.x=e,ve.current.y=t,ve.current.width=r,ve.current.height=a,ve.current.$render?.()}await new Promise(e=>setTimeout(e,100))}const r=await fe.toCanvas({width:n.width,height:n.height,imageSmoothingEnabled:!0,imageSmoothingQuality:"high"});if(!r)throw new Error(`No se pudo generar el canvas para "${n.label}"`);const a=r.toDataURL(`image/${globalThis.downloadFormat||e.mime_type.split("/")[1]||"webp"}`,.9),i=`${(n.label||"crop").replace(/\.[^/.]+$/,"").replace(/\s+/g,"-").trim()}_${n.width}_${n.height}`;return await an(a,i,{accessibilityManager:oe,onSuccess:e=>{console.log(`✅ Descargado: ${e}`)},onError:e=>{throw new Error(`Error al descargar "${n.label}": ${e.message}`)}}),{crop:n.label,filename:i}}finally{if(t!==G&&r.imageTransform&&ye.current?.$setTransform){console.log(`[CropperView] ↩️ Restaurando estado original del crop ${r.index}...`);const[e,t,n,a,i,o]=r.imageTransform;if(ye.current.$setTransform(e,t,n,a,i,o),r.selectorState&&ve.current){const{x:e,y:t,width:n,height:a}=r.selectorState;ve.current.x=e,ve.current.y=t,ve.current.width=n,ve.current.height=a,ve.current.$render?.()}}}},[V,G,fe,e.mime_type,oe,ye,ve]),st=u.useCallback(async e=>{Re(),oe?.announce(`Descargando ${e.length} recortes...`);const t=[],n=[];for(const a of e)try{const e=await ot(a);e&&t.push(e)}catch(r){n.push({crop:V[a]?.label||`Crop ${a}`,error:r.message})}if(t.length>0&&oe?.announceSuccess(`${t.length} recorte(s) descargado(s) correctamente`),n.length>0){const e=`Errores al descargar algunos recortes:\n${n.map(e=>`- ${e.crop}: ${e.error}`).join("\n")}`;oe?.announceError(e),alert(e)}},[Re,ot,V,oe]),lt=u.useCallback(async()=>{if(!ke){const e="No se puede descargar el recorte por restricciones de CORS en la imagen original.";return oe?.announceError(e),void alert(e)}Re(),oe?.announce("Preparando descarga del recorte");try{await ot(G),oe?.announceSuccess("Recorte descargado correctamente")}catch(e){console.error("Error downloading crop:",e);const t=e.message||"Error al descargar el recorte";oe?.announceError(t),alert(t)}},[ke,oe,Re,ot,G]),ct=u.useCallback(async()=>{const e=Ue();if(-1!==e){const t=V[e];return alert(`El recorte "${t.label||t||"(sin nombre)"}" debe tener un nombre válido.`),void Q(e)}if(V.length>1){ie("download");const e=V.map((e,t)=>({crop:e,index:t})).filter(({crop:e,index:t})=>e.savedState||t===G).map(({index:e})=>e);return re(e),void te(!0)}await lt()},[Ue,V,lt,G]),ut=u.useMemo(()=>!!e.file||(!e.id||!("string"!=typeof e.id||!e.id.startsWith("external"))),[e.file,e.id]),dt=u.useCallback(async()=>{try{if(e.file&&s){oe?.announce("Subiendo imagen original...");const n=await s(e.file);if(!n||!n.id)throw new Error("No se pudo subir la imagen al servidor");return oe?.announceSuccess("Imagen guardada correctamente"),void t({asset:n,crops:[]})}if(ut){oe?.announce("Conservando imagen original...");const n={id:`local-original-${Date.now()}`,name:e.filename||"original",filename:e.filename||"image.jpg",url:e.url,urlSigned:e.url,width:e.width||we?.naturalWidth||1920,height:e.height||we?.naturalHeight||1080,mime_type:e.mime_type||"image/jpeg",isLocal:!0,isOriginal:!0};return oe?.announceSuccess("Imagen original conservada"),void t({crops:[n]})}n()}catch(r){console.error("Error guardando imagen original:",r);const e=r.message||"No se pudo guardar la imagen. Inténtalo de nuevo.";oe?.announceError(e),alert(e),a?.(r)}},[e,we,s,n,t,a,oe,ut]);return u.useEffect(()=>{m(!1),p(null)},[e]),u.useEffect(()=>{de.manager&&he.isReady&&_&&(console.log("[CropperView] Carga inicial completada, centrando imagen y selector..."),setTimeout(()=>{ze(),setTimeout(()=>{Te(),z(!1),console.log("[CropperView] Carga inicial finalizada")},100)},50))},[de.manager,he.isReady,_,ze,Te]),u.useEffect(()=>{de.manager&&he.isReady&&(X&&fe.setAspectRatio(X),ge.setBackground(v))},[X,v,de.manager,he.isReady,fe,ge]),u.useEffect(()=>{if(!we||!he.isReady||H.mandatoryCrops.length>0)return;const e=V[0];if(e&&"crop-default-0"===e.id&&(1920===e.width||1080===e.height)){const t=Math.min(we.naturalWidth,5e3),n=Math.min(we.naturalHeight,5e3);K([{...e,width:t,height:n}]),console.log(`[CropperView] Crop por defecto actualizado a ${t}×${n}px`)}},[we,he.isReady,H.mandatoryCrops.length,V]),u.useEffect(()=>{if(!d||!ke)return;const e=setTimeout(async()=>{g(e=>!h&&!e||e);try{const e=await Ge();e&&p(e)}finally{g(!1)}},300);return()=>{clearTimeout(e),g(!1)}},[xe,Se,d,ke,Ge,X,M,h]),u.useEffect(()=>{const e=be.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)}},[be]),e?A.jsxs("div",{className:"limbo-cropper-view px-2 border-2 border-gray-200/50 rounded-lg max-w-7xl mx-auto w-full min-w-full h-full min-h-full flex flex-col",children:[A.jsxs("div",{className:"limbo-cropper-header flex flex-row justify-between items-start flex-wrap mx-2 py-2 border-b border-gray-200 bg-white z-10 shrink-0 lg:gap-2",children:[A.jsxs("div",{className:"flex-1 min-w-fit space-y-2 max-w-fit",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("h2",{className:"text-lg sm:text-xl font-extrabold text-gray-800",children:"Generar recortes"}),V.length>1&&A.jsx("span",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 text-xs font-semibold rounded",children:Y.label})]}),A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("label",{className:"text-xs text-gray-500 whitespace-nowrap w-fit",children:"Nombre:"}),A.jsx("div",{className:"",children:W+"."+(globalThis.downloadFormat||e.mime_type.split("/")[1]||"webp")})]})]}),A.jsxs("div",{className:"flex flex-row self-end gap-2 w-full max-w-fit sm:w-auto flex-wrap",children:[A.jsxs("button",{onClick:n,disabled:le,className:"flex flex-row items-center gap-1 self-end w-full max-w-fit sm:w-auto px-3 cursor-pointer py-1.5 text-sm rounded bg-neutral-gray-500 hover:bg-neutral-gray-700 transition-colors text-white disabled:opacity-50 disabled:cursor-not-allowed","aria-label":"Cancelar y volver",title:"Cancelar y volver",children:[A.jsx("span",{className:"icon icon-arrow-left-white icon--sm m-0 p-0"})," ","Cancelar"]}),r&&A.jsxs("button",{onClick:()=>r(e),disabled:i|le,className:"flex flex-row items-center gap-1 self-end w-full max-w-fit sm:w-auto px-3 cursor-pointer py-1.5 text-sm rounded bg-red-800 hover:bg-red-1000 transition-colors text-white disabled:opacity-50 disabled:cursor-not-allowed","aria-label":`Eliminar imagen ${e.filename}`,title:`Eliminar imagen ${e.filename}`,children:[A.jsx("span",{className:"icon icon-close-small-white icon--sm m-0 p-0"}),i?"Eliminando...":"Eliminar"]})]})]}),A.jsxs("div",{className:"limbo-cropper-status bg-white border-gray-100 py-0 pb-0 flex-shrink-0",children:[ce&&A.jsxs("div",{className:"alert alert-danger mb-2 text-sm",role:"alert",children:[A.jsx("strong",{children:"Error:"})," ",ce]}),we&&A.jsxs("div",{className:"alert alert-secondary mb-2 text-sm",role:"status",children:[A.jsx("strong",{children:"Original:"})," ",we.naturalWidth," ×"," ",we.naturalHeight," px",we.currentWidth!==we.naturalWidth&&A.jsxs("span",{className:"ml-2 sm:ml-3 text-xs block sm:inline",children:["(Mostrada: ",Math.round(we.currentWidth)," ×"," ",Math.round(we.currentHeight)," px)"]})]}),!ke&&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 py-2 mx-2 shrink-0 sticky top-0 z-10 mb-1",children:[A.jsxs("div",{className:"flex items-center justify-between mb-2",children:[A.jsxs("h3",{className:"text-sm font-semibold text-gray-700",children:["Recortes ",V.length>1&&`(${V.length})`]}),H.allowCustomCrops&&A.jsxs("button",{onClick:Be,disabled:le,className:"text-xs cursor-pointer px-2 py-1 bg-brand-blue-50 hover:bg-brand-blue-200 text-brand-blue-1000 rounded border border-brand-blue-200 transition-colors flex items-center gap-1",title:"Añadir recorte personalizado",children:[A.jsx("span",{className:"icon icon-add icon--sm",style:{filter:"var(--icon-blue)"}}),"Añadir recorte"]})]}),A.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-1.5 max-h-48 overflow-y-auto",children:V.map((e,t)=>{const n=e.savedState||t===G;return A.jsxs("label",{className:"h-fit flex flex-col p-1.5 rounded border cursor-pointer transition-colors min-h-17.5 w-full "+(G===t?"bg-blue-50 border-blue-300":n?"bg-gray-50 border-gray-200 hover:bg-gray-100":"bg-orange-50 border-orange-300 hover:bg-orange-100"),children:[A.jsx("input",{type:"radio",name:"active-crop",checked:G===t,onChange:()=>qe(t),disabled:le,className:"hidden"}),A.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[A.jsx("div",{className:"flex-1 min-w-0",children:A.jsxs("div",{className:"flex flex-wrap items-center gap-1 min-h-",children:[G!==t||e.required?A.jsx("span",{className:"text-xs font-medium text-gray-800 limbo-truncate",children:e.label}):A.jsx("input",{type:"text",value:e.label,onChange:e=>Ve(e.target.value),disabled:le,className:"w-full text-xs px-1 py-0.5 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500 min-h-5",placeholder:"Nombre",maxLength:25,onClick:e=>e.stopPropagation()}),e.required&&A.jsx("span",{className:"text-[10px] px-1 py-0.5 bg-red-200 text-red-1000 rounded whitespace-nowrap truncate",children:"Obligatorio"})]})}),!e.required&&V.length>1&&A.jsx("button",{onClick:n=>{n.preventDefault(),n.stopPropagation(),Ke(t,e.label)},className:"shrink-0 hover:bg-red-500/70 text-red-1000 p-1 rounded max-h-fit aspect-square cursor-pointer flex",title:"Eliminar",children:A.jsx("span",{className:"icon icon-close-small icon--xs"})})]}),A.jsx("div",{className:"flex items-center gap-1 mt-auto",children:G===t?A.jsxs(A.Fragment,{children:[A.jsx("input",{type:"number",min:"100",max:"5000",value:e.width,onChange:e=>We("width",e.target.value),onBlur:()=>He("width"),disabled:le||e.lockDimensions,className:"max-h-fit flex-1 text-xs px-1 py-0.5 border rounded focus:outline-none focus:ring-1 focus:ring-blue-500 "+(e.lockDimensions?"border-gray-200 bg-gray-100 text-gray-500 cursor-not-allowed":"border-gray-300"),placeholder:"W",onClick:e=>e.stopPropagation(),title:e.lockDimensions?"Dimensiones bloqueadas (recorte obligatorio)":"Ancho en píxeles"}),A.jsx("span",{className:"text-gray-400 text-xs",children:"×"}),A.jsx("input",{type:"number",min:"100",max:"5000",value:e.height,onChange:e=>We("height",e.target.value),onBlur:()=>He("height"),disabled:le||e.lockDimensions,className:"max-h-fit flex-1 text-xs px-1 py-0.5 border rounded focus:outline-none focus:ring-1 focus:ring-blue-500 "+(e.lockDimensions?"border-gray-200 bg-gray-100 text-gray-500 cursor-not-allowed":"border-gray-300"),placeholder:"H",onClick:e=>e.stopPropagation(),title:e.lockDimensions?"Dimensiones bloqueadas (recorte obligatorio)":"Alto en píxeles"})]}):A.jsxs("span",{className:"text-xs text-gray-500",children:[e.width," × ",e.height," px"]})}),!n&&A.jsx("div",{className:"text-xs px-1 py-0.5 bg-orange-300 text-neutral-gray-25 text-shadow-xs font-semibold rounded text-center mt-1",children:"Sin configurar"})]},e.id)})})]})]}),A.jsxs("div",{className:"flex flex-col lg:flex-row flex-1 w-full overflow-hidden lg:max-h-130 mx-2 py-1",children:[A.jsx("div",{className:"relative flex-1 lg:flex-2 h-full shrink-0 grow-1 order-0 min-h-100 lg:min-h-130",children:A.jsxs("div",{className:"absolute inset-0 bg-white rounded-lg border-2 border-gray-200 overflow-hidden",children:[A.jsx(ue,{show:_,message:"Cargando recortador..."}),A.jsx(ue,{show:T,message:`Cambiando a: ${V[G]?.label||"recorte"}...`}),A.jsxs("cropper-canvas",{ref:be,style:{width:"100%",height:"100%",display:"block"},background:!!v||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:ye,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:ve,"initial-coverage":"0.5",movable:!0,resizable:!0,keyboard:"true",action:"move",style:{cursor:"move",minWidth:`${Z.minWidth}px`,minHeight:`${Z.minHeight}px`},"data-prevent-delete":"true",tabindex:"-1",children:[b&&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:"w-full lg:max-w-80 mt-2 lg:my-0 overflow-y-auto bg-white border-t lg:border-t-0 lg:border-l border-gray-200 flex-shrink-0",children:A.jsxs("div",{className:"h-full mt-2 lg:my-0 limbo-me-2 lg:mx-2 space-y-2 grid grid-cols-2 md:grid-cols-3 flex-wrap md:flex-nowrap items-start flex-row gap-2 lg:gap-0 lg:block",children:[A.jsxs("div",{className:"bg-white rounded border w-full border-gray-200 mb-2",children:[A.jsx("button",{onClick:_e,className:"hidden sm:block w-full p-2 mb-05 cursor-pointer hover:bg-neutral-gray-050/50 transition-colors rounded-t-sm","aria-expanded":q,"aria-label":"Mostrar/ocultar opciones de visualizació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 ${q?"icon-chevron-up":"icon-chevron-down"} text-center icon--xs`})})]})}),A.jsxs("div",{className:"p-2 space-y-2 justify-items-stretch static "+(q?"block":"sm:hidden"),children:[A.jsx("div",{className:"mb-3 block",children:A.jsxs("div",{className:"grid grid-cols-5 gap-1 content-center h-fit mx-auto",children:[A.jsx("button",{onClick:()=>Me(-.2),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Alejar",disabled:le,"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:()=>Pe(-10,-10),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Mover arriba-izquierda",disabled:le,"aria-label":"Mover imagen hacia arriba-izquierda",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-up-blue icon--md -rotate-45"})})}),A.jsx("button",{onClick:()=>Pe(0,-10),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Mover arriba",disabled:le,"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 icon--md"})})}),A.jsx("button",{onClick:()=>Pe(10,-10),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Mover arriba-derecha",disabled:le,"aria-label":"Mover imagen hacia arriba-derecha",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-up-blue icon--md rotate-45"})})}),A.jsx("button",{onClick:()=>Me(.2),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Acercar 20%",disabled:le,"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.jsx("button",{onClick:()=>Ie(-45),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Rotar -45°",disabled:le,"aria-label":"Rotar imagen 45 grados a la izquierda",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"text-brand-blue-1000 font-medium",children:"-45°"})})}),A.jsx("button",{onClick:()=>Pe(-10,0),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Mover izquierda",disabled:le,"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:ze,className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Centrar y ajustar imagen",disabled:le,"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:()=>Pe(10,0),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Mover derecha",disabled:le,"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("button",{onClick:()=>Ie(45),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Rotar +45°",disabled:le,"aria-label":"Rotar imagen 45 grados a la derecha",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"text-brand-blue-1000 font-medium",children:"+45°"})})}),A.jsx("button",{onClick:De,className:"px-0 rounded cursor-pointer transition-colors text-sm aspect-square "+(M.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 "+(M.horizontal?"(activo)":""),disabled:le,"aria-label":"Voltear imagen horizontalmente","aria-pressed":M.horizontal,children:A.jsx("div",{className:"flex items-center justify-center gap-2",children:A.jsx("span",{className:"icon icon-arrow-left-right-blue border border-brand-blue-1000 rounded"})})}),A.jsx("button",{onClick:()=>Pe(-10,10),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Mover abajo-izquierda",disabled:le,"aria-label":"Mover imagen hacia abajo-izquierda",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-up-blue icon--md -rotate-145"})})}),A.jsx("button",{onClick:()=>Pe(0,10),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Mover abajo",disabled:le,"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("button",{onClick:()=>Pe(10,10),className:"px-0 rounded cursor-pointer transition-colors text-sm bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200 aspect-square",title:"Mover abajo-derecha",disabled:le,"aria-label":"Mover imagen hacia abajo-derecha",children:A.jsx("div",{className:"flex items-center justify-center",children:A.jsx("span",{className:"icon icon-arrow-up-blue icon--md rotate-145"})})}),A.jsx("button",{onClick:Oe,className:"px-0 rounded cursor-pointer transition-colors aspect-square text-sm "+(M.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 "+(M.vertical?"(activo)":""),disabled:le,"aria-label":"Voltear imagen verticalmente","aria-pressed":M.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("div",{className:"flex flex-col gap-2",children:A.jsx("button",{onClick:()=>{pe.reset(),I({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:le,"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-white rounded border border-gray-200 w-full"+(F?"":" bg-neutral-gray-50/50"),children:[A.jsx("button",{onClick:$e,className:"hidden sm:block w-full cursor-pointer hover:bg-neutral-gray-050/50 p-2 mb-05 transition-colors rounded-t-sm","aria-expanded":F,"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 ${F?"icon-chevron-up":"icon-chevron-down"} text-center icon--xs`})})]})}),A.jsxs("div",{className:"p-2 space-y-2 justify-items-stretch static "+(F?"block":"sm:hidden"),children:[A.jsx("div",{children:A.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[A.jsx("button",{onClick:()=>Le(.5),className:"p-1 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",disabled:le,"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:()=>Le(.7),className:"p-1 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",disabled:le,"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:()=>Le(.9),className:"p-1 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",disabled:le,"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:()=>Le(1),className:"p-1 rounded cursor-pointer transition-colors text-xs bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200",disabled:le,"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:Te,className:"w-full p-1 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:le,"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:Ae,className:"w-full p-1 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:le,"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 limbo-lign-[middle!important] "})," ","Reset selección"]})})})]})]})]}),A.jsxs("div",{className:"bg-white rounded border border-gray-200 w-full",children:[A.jsx("button",{onClick:Ee,className:"hidden sm:block w-full cursor-pointer hover:bg-neutral-gray-050/50 transition-colors rounded-t-sm mb-05 p-2","aria-expanded":O,"aria-label":"Mostrar/ocultar opciones de visualizació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 ${O?"icon-chevron-up":"icon-chevron-down"} text-center icon--xs`})})]})}),A.jsxs("div",{className:"py-2 space-y-2 justify-items-stretch static "+(O?"block":"sm:hidden"),children:[A.jsxs("button",{onClick:je,className:"w-auto flex cursor-pointer items-center justify-between mx-2 p-1 rounded transition-colors "+(b?"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:le,"aria-pressed":b,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 limbo-me-1"})," ","Cuadrícula"]}),A.jsx("span",{className:"text-xs",children:b?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:Ne,className:"w-auto flex cursor-pointer items-center justify-between mx-2 p-1 rounded transition-colors "+(v?"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:le,"aria-pressed":v,"aria-label":"Activar/desactivar sombreado",children:[A.jsxs("span",{className:"text-sm flex items-center",children:[A.jsx("span",{className:"icon icon-comparison-blue limbo-me-1"})," ","Tablero"]}),A.jsx("span",{className:"text-xs",children:v?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:"flex justify-between shrink-0 border-t border-gray-200 bg-white mx-2 mt-1 py-2 lg:gap-0",children:[A.jsxs("button",{onClick:()=>D(!0),className:"text-nowrap block cursor-pointer lg:flex items-center gap-2 px-2 py-1 bg-gradient-to-br from-brand-blue-50 to-green-50 hover:from-brand-blue-100 hover:to-green-100 border border-blue-200 rounded-lg shadow-sm transition-colors","aria-label":"Abrir guía de uso",children:[A.jsx("span",{className:"icon icon-lightbulb text-yellow-500"}),A.jsx("span",{className:"text-sm font-semibold text-blue-800",children:"Guía de uso"}),A.jsx("span",{className:"icon icon-arrow-down scale-75 -rotate-145"})]}),A.jsx("button",{onClick:Qe,disabled:le||!ke,className:`px-3 cursor-pointer py-1.5 text-sm rounded transition-colors ${d?"bg-red-1000 hover:bg-red-800 text-white":"bg-brand-blue-800 hover:bg-brand-blue-1000 text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,"aria-label":"Vista previa",title:"Mostrar/Ocultar vista previa",children:A.jsxs("div",{className:"flex items-center gap-1",children:[A.jsx("span",{className:"icon icon-search-white icon--sm"}),A.jsx("span",{className:"hidden sm:inline whitespace-nowrap",children:d?"Cerrar previa":"Vista previa"})]})}),A.jsxs("div",{className:"flex flex-row gap-1 lg:gap-2 items-center justify-end",children:[A.jsx("button",{onClick:ct,disabled:le||!ke,className:"cursor-pointer px-3 py-1.5 text-sm rounded bg-brand-blue-800 hover:bg-brand-blue-1000 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed","aria-label":"Descargar",title:"Descargar recorte sin guardar",children:A.jsxs("div",{className:"flex items-center gap-1",children:[A.jsx("span",{className:"icon icon-download-white icon--sm"}),A.jsx("span",{className:"hidden md:inline whitespace-nowrap",children:"Descargar"})]})}),ut&&A.jsx("button",{onClick:dt,disabled:le||l,className:"px-3 cursor-pointer py-1.5 text-sm rounded bg-teal-600 hover:bg-teal-700 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed","aria-label":"Conservar solo imagen original sin crear recortes",title:e.file?"Subir y guardar la imagen original sin crear recortes":"Seleccionar la imagen original sin crear recortes",children:A.jsxs("div",{className:"flex items-center gap-1",children:[A.jsx("span",{className:"icon icon-tick-white icon--sm"}),A.jsx("span",{className:"hidden md:inline whitespace-nowrap",children:"Conservar original"})]})}),A.jsx("button",{onClick:it,disabled:le||!xe||!Ce||!ke||!he.isReady,className:"px-3 cursor-pointer py-1.5 text-sm rounded bg-green-600 hover:bg-green-700 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Guardar imagen recortada",children:A.jsx("div",{className:"flex items-center gap-1",children:le?A.jsxs(A.Fragment,{children:[A.jsx("span",{className:"icon icon-save-white icon--sm"}),A.jsx("span",{children:"Guardando..."})]}):A.jsxs(A.Fragment,{children:[A.jsx("span",{className:"icon icon-save-white icon--sm"}),A.jsx("span",{className:"hidden md:inline whitespace-nowrap",children:"Guardar recorte"})]})})})]})]}),ee&&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"===ae?"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"===ae?"guardar":"descargar"]})]}),A.jsx("div",{className:"px-6 py-4 overflow-y-auto flex-1",children:A.jsx("div",{className:"space-y-2",children:V.map((e,t)=>{const n=e.savedState||t===G,r=!e.required&&!n;return A.jsxs("label",{className:`flex items-center gap-3 p-3 rounded border transition-colors ${ne.includes(t)?"bg-blue-50 border-blue-300":r?"bg-gray-100 border-gray-300 opacity-60":"bg-gray-50 border-gray-200 hover:bg-gray-100"} ${r?"cursor-not-allowed":"cursor-pointer"}`,children:[A.jsx("input",{type:"checkbox",checked:ne.includes(t),disabled:r,onChange:e=>{e.target.checked?re(e=>[...e,t]):re(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 flex-wrap",children:[A.jsxs("span",{title:"Nombre del archivo a descargar",className:"text-sm font-medium text-gray-800 truncate",children:[e.label,"_",e.width,"_",e.height]}),e.required&&A.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-red-200 text-red-1000 rounded whitespace-nowrap",children:"Obligatorio"}),!n&&!e.required&&A.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-orange-100 text-orange-700 rounded whitespace-nowrap",children:"Sin configurar"})]}),A.jsxs("span",{title:"Dimensiones del recorte",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:()=>{te(!1),ie(null),re([])},className:"limbo-btn limbo-btn-secondary px-4 py-2",children:"Cancelar"}),A.jsxs("button",{onClick:async()=>{if(te(!1),"save"===ae)if(1===ne.length){const e=G;Q(ne[0]),await new Promise(e=>setTimeout(e,100)),await rt(),Q(e)}else await at(ne);else if(1===ne.length){const e=G;Q(ne[0]),await new Promise(e=>setTimeout(e,100)),await lt(),Q(e)}else await st(ne);ie(null),re([])},disabled:0===ne.length,className:"limbo-btn limbo-btn-primary px-4 py-2 disabled:opacity-50 disabled:cursor-not-allowed",children:["save"===ae?"Guardar":"Descargar"," (",ne.length,")"]})]})]})}),L&&A.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[9999] p-4",children:A.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-5xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[A.jsx("div",{className:"px-6 py-4 border-b border-gray-200 bg-brand-blue-50",children:A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsxs("h3",{className:"text-xl font-semibold text-brand-blue-1000 flex items-center gap-2",children:[A.jsx("span",{className:"icon icon-lightbulb text-yellow-500"}),"Guía de uso del Cropper"]}),A.jsx("button",{onClick:()=>D(!1),className:"text-gray-400 hover:text-gray-600 p-1 rounded-full hover:bg-gray-100 transition-colors","aria-label":"Cerrar modal",children:A.jsx("span",{className:"icon icon-close-small icon--lg"})})]})}),A.jsxs("div",{className:"px-6 py-4 overflow-y-auto flex-1 space-y-4",children:[A.jsxs("div",{className:"bg-brand-blue-50 rounded-lg p-4 border-l-4 border-brand-blue-400",children:[A.jsx("h4",{className:"font-semibold text-brand-blue-1000 mb-3 text-base flex items-center gap-2",children:"🖱️ Navegación básica"}),A.jsxs("div",{className:"text-sm text-brand-blue-800 space-y-2",children:[A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Arrastra la imagen:"})," Haz clic sobre la imagen dentro del área de selección y arrástrala para reposicionarla"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Zoom:"})," Usa la rueda del ratón sobre el canvas (fuera del área de selección) para hacer zoom"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Vista completa:"}),' Botón "Reset zoom" para ajustar automáticamente al tamaño óptimo']})]})]})]}),A.jsxs("div",{className:"bg-brand-blue-50 rounded-lg p-4 border-l-4 border-brand-blue-400",children:[A.jsx("h4",{className:"font-semibold text-brand-blue-1000 mb-3 text-base flex items-center gap-2",children:"✂️ Área de selección"}),A.jsxs("div",{className:"text-sm text-brand-blue-800 space-y-2",children:[A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",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 inline-block mx-1 align-middle border border-brand-blue-400 rounded-full"}),"para reposicionar el área de recorte"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Redimensionar:"})," Arrastra desde las esquinas o bordes para cambiar el tamaño del área"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Tamaños rápidos:"})," Usa los botones de porcentaje (50%, 70%, 90%, 100%) para ajustar rápidamente el tamaño"]})]})]})]}),A.jsxs("div",{className:"bg-brand-blue-50 rounded-lg p-4 border-l-4 border-brand-blue-400",children:[A.jsx("h4",{className:"font-semibold text-brand-blue-1000 mb-3 text-base flex items-center gap-2",children:"⌨️ Atajos de teclado"}),A.jsxs("div",{className:"text-sm text-brand-blue-800 space-y-2",children:[A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Flechas:"}),A.jsxs("span",{className:"inline-flex gap-1 mx-1",children:[A.jsx("span",{className:"icon icon-arrow-right-box rotate-180 icon--sm"}),A.jsx("span",{className:"icon icon-arrow-right-box icon--sm"}),A.jsx("span",{className:"icon icon-arrow-right-box -rotate-90 icon--sm"}),A.jsx("span",{className:"icon icon-arrow-right-box rotate-90 icon--sm"})]}),"Mueven la selección en incrementos de 10px"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Shift + Arrastrar:"})," Mantiene las proporciones al redimensionar el área de selección"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Ctrl + Rueda:"})," Control de zoom más preciso y fino"]})]})]})]}),A.jsxs("div",{className:"bg-teal-50 rounded-lg p-4 border-l-4 border-teal-800",children:[A.jsx("h4",{className:"font-semibold text-teal-1000 mb-3 text-base flex items-center gap-2",children:"👁️ Opciones de visualización"}),A.jsxs("div",{className:"text-sm text-teal-800 space-y-2",children:[A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Cuadrícula:"})," Muestra la regla de los tercios para mejorar la composición de tus recortes"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Tablero:"})," Patrón de cuadros para alinear mejor las medidas o ver imágenes con transparencia"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Vista previa:"})," Muestra cómo quedará el recorte final antes de guardarlo"]})]})]})]}),A.jsxs("div",{className:"bg-amber-50 rounded-lg p-4 border-l-4 border-amber-400",children:[A.jsx("h4",{className:"font-semibold text-amber-800 mb-3 text-base flex items-center gap-2",children:"💡 Consejos profesionales"}),A.jsxs("div",{className:"text-sm text-amber-700 space-y-2",children:[A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Orden de trabajo:"})," Primero aplica transformaciones (rotar, voltear), luego haz el recorte final"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Múltiples recortes:"})," Si tienes varios recortes configurados, revisa cada uno antes de guardar"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Calidad:"})," Las imágenes se exportan en alta calidad (JPEG 90%) manteniendo la mayor nitidez posible"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Proporciones:"})," Usa Shift al redimensionar para mantener el aspecto ratio original"]})]})]})]}),A.jsxs("div",{className:"bg-orange-50 rounded-lg p-4 border-l-4 border-orange-500",children:[A.jsx("h4",{className:"font-semibold text-orange-800 mb-3 text-base flex items-center gap-2",children:"⚠️ Notas importantes"}),A.jsxs("div",{className:"text-sm text-orange-700 space-y-2",children:[A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Recortes grandes:"})," Imágenes de alta resolución pueden tardar más en procesarse"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Calidad de escala:"})," Evita ampliar demasiado áreas pequeñas, ya que puede afectar la nitidez"]})]}),A.jsxs("div",{className:"flex items-start gap-2",children:[A.jsx("span",{className:"font-bold min-w-fit",children:"•"}),A.jsxs("div",{children:[A.jsx("strong",{children:"Cambios pendientes:"})," Recuerda guardar tus cambios antes de cerrar o cambiar de imagen"]})]})]})]})]}),A.jsx("div",{className:"px-6 py-4 border-t border-gray-200 bg-gray-50",children:A.jsx("button",{onClick:()=>D(!1),className:"limbo-btn limbo-btn-primary w-full",children:"Entendido"})})]})}),d&&A.jsx("div",{className:"min-w-[90%] fixed md:absolute inset-0 md:inset-auto bg-black/50 md:bg-transparent flex items-center justify-center md:block z-[9999] md:z-50 pointer-events-none",onClick:e=>{e.target===e.currentTarget&&window.innerWidth<768&&(m(!1),p(null))},children:A.jsxs("div",{className:"pointer-events-auto bg-white rounded-lg shadow-2xl border-2 border-brand-blue-800 overflow-hidden flex flex-col max-w-md w-full mx-4 md:mx-0 max-h-[80vh] md:max-h-[600px]",style:{...window.innerWidth>=768?{position:"absolute",left:`${w.x}px`,top:`${w.y}px`,width:"420px",cursor:S?"grabbing":"default"}:{}},onMouseDown:Ye,onTouchStart:Ze,children:[A.jsxs("div",{className:"limbo-preview-modal-header px-4 py-3 bg-gradient-to-r from-brand-blue-800 to-brand-blue-1000 text-white flex items-center justify-between cursor-grab active:cursor-grabbing select-none",style:{cursor:S?"grabbing":"grab"},children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("span",{className:"icon icon-search-white icon--sm"}),A.jsx("h3",{className:"text-sm font-semibold text-white",children:"Vista previa"})]}),A.jsx("button",{onClick:()=>{m(!1),p(null)},className:"flex p-1 hover:bg-white/20 rounded transition-colors cursor-pointer aspect-square min-w-fit min-h-fit","aria-label":"Cerrar vista previa",title:"Cerrar vista previa",children:A.jsx("span",{className:"icon icon-close-small-white icon--sm p-0 m-0 py-auto my-auto mx-auto"})})]}),A.jsx("div",{className:"flex-1 overflow-auto bg-gray-50 p-4",children:f?A.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",children:A.jsxs("div",{className:"text-center",children:[A.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-3"}),A.jsx("p",{className:"text-sm text-gray-600",children:"Generando vista previa..."})]})}):h?A.jsxs("div",{className:"flex flex-col items-center gap-3",children:[A.jsxs("div",{className:"relative w-full bg-white rounded-lg border border-gray-200 overflow-hidden shadow-sm cursor-zoom-in hover:ring-2 hover:ring-brand-blue-800 transition-all",onClick:()=>$(!0),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),$(!0))},"aria-label":"Click para ver recorte en tamaño completo",title:"Click para ampliar",children:[A.jsx("img",{src:h,alt:"Vista previa del recorte",className:"w-full h-auto object-contain max-h-[400px]"}),A.jsxs("div",{className:"absolute top-2 right-2 bg-black/60 text-white px-2 py-1 rounded text-xs flex items-center gap-1",children:[A.jsx("span",{className:"icon icon-search-white icon--xs"}),A.jsx("span",{children:"Ampliar"})]})]}),A.jsxs("div",{className:"text-center text-xs text-gray-500",children:[A.jsx("p",{className:"font-medium text-gray-700 mb-1",children:Y?.label||"Recorte"}),A.jsxs("p",{children:[Y?.width," × ",Y?.height," px"]})]})]}):A.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",children:A.jsx("p",{className:"text-sm text-gray-500",children:"No se pudo generar la vista previa"})})}),A.jsx("div",{className:"px-4 py-2 bg-gray-100 border-t border-gray-200",children:A.jsxs("p",{className:"text-xs text-gray-600 text-center",children:[A.jsxs("span",{className:"hidden md:inline",children:["Arrastra desde el título para mover •"," "]}),"Actualización automática al editar"]})})]})}),A.jsx(J,{src:h,alt:"Vista previa del recorte",title:Y?.label||"Recorte",subtitle:`${Y?.width||0} × ${Y?.height||0} px`,isOpen:E&&!!h,onClose:()=>$(!1)})]}):null}function ln({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:` px-3 py-2 text-sm font-medium rounded-md transition-colors disabled:cursor-default cursor-pointer ${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"} `,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:` px-3 py-2 text-sm font-medium rounded-md transition-colors disabled:cursor-default cursor-pointer ${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"} `,children:t})},`page-${t}-${a}`))}),A.jsxs("button",{onClick:()=>{e<t&&n(e+1)},disabled:r||e>=t,className:` px-3 py-2 text-sm font-medium rounded-md transition-colors disabled:cursor-default cursor-pointer ${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"} `,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 cn({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 un({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-1000 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 dn(){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:K,useJWT:!0})}catch(n){throw V(n)}}(e);return!1!==t.success}catch(a){return r(a.message),!1}finally{t(!1)}},loading:e,error:n,reset:()=>{r(null)}}}const mn=new Map;function hn(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 pn({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,cropperConfig:d=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[m,h]=u.useState({name:"",uploadedBy:"",dateFrom:"",dateTo:""}),p=hn(m.name,500),f=hn(m.uploadedBy,500),g=(()=>{switch(a){case"gallery-only":return["gallery"];case"upload-only":return["upload","cropper"];case"crop-only":return["cropper"];case"ia-only":return["ia"];default:return r}})(),[b,y]=u.useState(g.includes("gallery")?"gallery":g.includes("upload")?"upload":g.includes("cropper")?"cropper":g.includes("ia")?"ia":g[0]||"gallery"),[v,x]=u.useState(null);u.useEffect(()=>{c&&(console.log("📸 Imagen externa detectada:",c),x(c),y("cropper"))},[c]);const[w,k]=u.useState(1),{isTokenExpired:S,handleTokenExpiredClose:C}=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:j,loading:N,error:E,uploadedImage:$,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 Q(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:z,loading:T,error:P,reset:M}=dn(),L={limit:l,page:w,...p&&{name:p},...f&&{uploadedBy:f},...m.dateFrom&&{dateFrom:m.dateFrom},...m.dateTo&&{dateTo:m.dateTo}},D=g.includes("gallery"),{images:O,loading:R,error:F,pagination:U,invalidateCache:q,setImages:B}=function(e,t=!1,n={},r=!0){const[a,i]=u.useState([]),[o,s]=u.useState(r),[l,c]=u.useState(null),[d,m]=u.useState(null),[h,p]=u.useState(0),f=u.useMemo(()=>JSON.stringify(n),[n]);return u.useEffect(()=>{if(!r)return void s(!1);const e=`${f}`,t=mn.get(e),a=Date.now();if(t&&a-t.timestamp<6e5)return i(t.data),m(t.pagination||null),void s(!1);let o=!0;return(async()=>{if(h>=3)o&&(c("Error de autenticación: Verifica tus credenciales API"),s(!1));else try{const t=await G(n);if(!o)return;const r=t.result||t.data||[],s=t.pagination||null;i(r),m(s),c(null),p(0),mn.set(e,{data:r,pagination:s,timestamp:a})}catch(t){o&&(c(t.message),p(e=>e+1))}finally{o&&s(!1)}})(),()=>{o=!1}},[e,t,f,h,n,r]),{images:a,loading:o,error:l,pagination:d,setImages:i,invalidateCache:()=>{mn.delete(`${f}`)}}}(e,t,L,D),{refreshVariants:W}=X(),H=e=>!i.hideActions?.includes(e)&&(!!i.showActions?.includes(e)||!(i.showActions?.length>0)),V=[{id:"gallery",label:"Galería",feature:"gallery"},{id:"upload",label:"Subir nueva",feature:"upload"},{id:"cropper",label:"Recortador",hideNonActive:!0,feature:"cropper"}].filter(e=>g.includes(e.feature)),K=async e=>{const t=URL.createObjectURL(e),n=await new Promise(e=>{const n=new Image;n.onload=()=>{e({width:n.naturalWidth,height:n.naturalHeight}),URL.revokeObjectURL(t)},n.onerror=()=>{e({width:1920,height:1080}),URL.revokeObjectURL(t)},n.src=t}),r={file:e,filename:e.name,mime_type:e.type,url:URL.createObjectURL(e),width:n.width,height:n.height};if(x(r),g.includes("cropper"))y("cropper");else{const t=await j(e);t&&(q(),k(1),B(e=>[t,...e]),y("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}))}},Y=async e=>{if(!confirm("¿Estás seguro de que deseas eliminar esta imagen? Esta acción también eliminará todos sus recortes."))return;await z(e)&&(q(),k(1),B(t=>t.filter(t=>t.id!==e)),v&&v.id===e&&(x(null),y("gallery")))},J=()=>"crop-only"===a||1===g.length&&"cropper"===g[0]?"crop-only":g.includes("gallery")?"with-gallery":g.includes("upload")&&!g.includes("gallery")?"upload-only":"with-gallery";return A.jsxs(A.Fragment,{children:[i.showTabs&&"cropper"!=b&&A.jsx(I,{tabs:V,active:b,onChange:e=>{y(e),"upload"!==e&&_(),"gallery"!==e&&M()}}),F&&A.jsxs("div",{className:"alert alert-danger",children:["Error al cargar imágenes: ",F]}),P&&A.jsxs("div",{className:"alert alert-danger",children:["Error al eliminar imagen: ",P]}),"gallery"===b&&A.jsxs(A.Fragment,{children:[T&&A.jsx(cn,{text:"Eliminando imagen..."}),$&&A.jsxs("div",{className:"alert alert-success absolute top-0 right-[50px] m-4",children:["✅ Imagen subida correctamente: ",$.filename]}),A.jsx(ne,{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=>{x(e),g.includes("cropper")&&y("cropper")},onDelete:H("delete")?Y:null,deletingId:T,images:O,loading:R,error:F,filters:m,onFiltersChange:e=>{h(e),k(1)},filterConfig:i.galleryFilters||{},loadingConfig:i.galleryLoading||{},allowedActions:{select:H("select"),download:H("download"),copy:H("copy"),delete:H("delete"),crop:H("crop")}}),U&&!R&&A.jsx(ln,{currentPage:U.page||w,totalPages:U.pages||1,onPageChange:e=>{k(e)},disabled:R||T})]}),"upload"===b&&A.jsxs("div",{children:[N&&A.jsx(cn,{text:"Subiendo imagen..."}),E&&A.jsxs("div",{className:"alert alert-danger",children:["Error al subir imagen: ",E]}),$&&A.jsxs("div",{className:"alert alert-success absolute top-0 right-[50px] m-4",children:["✅ Imagen subida correctamente: ",$.filename]}),A.jsx(ke,{onSelect:K,disabled:N,apiKey:e,prod:t})]}),"cropper"===b&&v&&A.jsx(sn,{image:v,onSave:e=>{const t=J(),n=window.limboCore?.config?.getGlobal()||{},r=n.mode||"embed",a=n.autoHideOnComplete||!1;let i=[],l=null;e.crops&&e.asset?(i=e.crops,l=e.asset):i=Array.isArray(e)?e:[e],l&&"with-gallery"===t&&(B(e=>[l,...e]),k(1),o.onUpload&&o.onUpload({assetId:l.id,url:l.url,fileName:l.filename,mime:l.mime_type,width:l.width,height:l.height,instanceId:s})),"with-gallery"===t&&q();const c=l||v,u={crops:i,assetId:c?.id,instanceId:s,asset:c?{id:c.id,url:c.url||c.urlSigned,width:c.width,height:c.height,filename:c.filename,mime_type:c.mime_type}:null};switch(o.onCropsSaved&&o.onCropsSaved(u),window.limboCore?.events&&window.limboCore.events.emit("cropsSaved",u),t){case"with-gallery":"modal"===r?window.limboCore?.modals?.closeAllModals():(x(null),y("gallery"));break;case"upload-only":"modal"===r?window.limboCore?.modals?.closeAllModals():(x(null),y("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=J(),t=(window.limboCore?.config?.getGlobal()||{}).mode||"embed";switch(o.onCropperCancelled&&o.onCropperCancelled({assetId:v?.id,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropperCancelled",{assetId:v?.id,instanceId:s}),e){case"with-gallery":x(null),y("gallery");break;case"upload-only":"modal"===t?window.limboCore?.modals?.closeAllModals():(x(null),y("upload"));break;case"crop-only":"modal"===t?window.limboCore?.modals?.closeAllModals():window.limboCore?.events&&window.limboCore.events.emit("cropperClosed",{instanceId:s,reason:"cancelled"})}},onDelete:v?.id&&H("delete")?()=>Y(v.id):null,onError:e=>{o.onCropperError&&o.onCropperError(e,s),window.limboCore?.events&&window.limboCore.events.emit("cropperError",{error:e,assetId:v?.id,instanceId:s}),console.error("Cropper error:",e)},deleting:T,onVariantCreated:(e,t)=>{W(e)},onUpload:j,uploading:N,cropperConfig:d}),"cropper"===b&&!v&&("crop-only"===a?A.jsxs("div",{children:[N&&A.jsx(cn,{text:"Subiendo imagen..."}),E&&A.jsxs("div",{className:"alert alert-danger",children:["Error al subir imagen: ",E]}),A.jsx(ke,{onSelect:K,disabled:N,apiKey:e,prod:t})]}):A.jsxs("div",{className:"limbo-empty-state flex flex-col items-center justify-center py-12 px-6 text-center",children:[A.jsx("div",{className:"text-gray-400 mb-4",children:A.jsx("svg",{className:"w-16 h-16 mx-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:A.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),A.jsx("p",{className:"text-gray-600 mb-4",children:"Selecciona una imagen de la galería para comenzar a recortar."})]})),A.jsx(un,{isOpen:S,onClose:C})]})}class fn{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.eventManager?.emit("modal:close",{instance:this}),this.modal.close()),this}updateConfig(e){return this.config={...this.config,...e},this.mounted&&this.root.render(this._renderApp()),this.eventManager.emit("config:updated",{instance:this,newConfig:e}),this}destroy(){this.destroyed||(this.unmount(),this.modal&&(this.modal.destroy(),this.modal=null),this.button&&this.button.parentNode&&(this.button.parentNode.removeChild(this.button),this.button=null),this.eventManager.emit("destroy",{instance:this}),this.container=null,this.config=null,this.eventManager=null,this.modalManager=null,this.destroyed=!0)}getId(){return this.id}getMode(){return this.config.mode}isMounted(){return this.mounted}isDestroyed(){return this.destroyed}getContainer(){return this.container}getConfig(){return{...this.config}}isContainerInDOM(){return this.container&&document.contains(this.container)}_createModal(){if(this.modalManager&&"modal"===this.config.mode&&(this.modal=this.modalManager.createModal({title:this.config.title||"Limbo Image Manager",size:this.config.modalSize||"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 h-full w-full py-2 bg-white rounded-md","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(pn,{apiKey:this.config.apiKey||null,publicKey:this.config.publicKey||null,token:this.config.token||null,prod:this.config.prod||!1,url:this.config.url,features:this.config.features,modeUI:this.config.modeUI||"full",ui:this.config.ui,callbacks:this._createCallbacks(),instanceId:this.id,authMode:this.config.authMode||this.config.publicKey?"session":"manual",_externalImage:this.config._externalImage||null,cropperConfig:this.config.cropper||null}))}_createCallbacks(){return{onSelect:e=>{const t=this.config?.callbacks?.onSelect,n=this._createStandardPayload(e,"select");t&&t(n),this.destroyed||this._emitDOMEvent("select",n)},onUpload:e=>{const t=this.config?.callbacks?.onUpload,n=this._createStandardPayload(e,"upload");t&&t(n),this.destroyed||this._emitDOMEvent("upload",n)},onError:e=>{const t=this.config?.callbacks?.onError,n={instance:this,error:{message:e.message||"Unknown error",code:e.code||"UNKNOWN",timestamp:Date.now()}};t&&t(n.error),this.destroyed||this._emitDOMEvent("error",n)},onClose:()=>{const e=this.config?.callbacks?.onClose,t={instance:this,timestamp:Date.now()};e&&e(),this.destroyed||this._emitDOMEvent("close",t)}}}_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){if(this.destroyed)return;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 gn{constructor(){this.instances=new Map,this.counter=0}create(e,t,n){const r="limbo-"+ ++this.counter,a=new fn(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 bn{constructor(){this.config=null,this.instances=new Map,this.observer=null,this.initialized=!1}configure(e,t,n){return this.config={selector:e.selector||null,dataset:e.dataset||"data-limbo-input-file",return:e.return||e.returnType||"json",mode:e.mode||"modal",features:e.features||["gallery","upload","cropper"],crop:e.crop||"free",quality:e.quality||.9,format:e.format||"webp",modeUI:e.modeUI||"full",modalSize:e.modalSize||"fullscreen",theme:e.theme||"light",compact:e.compact||!1,maxSize:e.maxSize||"10MB",formats:e.formats||["jpg","jpeg","png","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=this.config.selector||`input[${this.config.dataset}]`;document.querySelectorAll(e).forEach(e=>this._processInput(e))}_processInput(e){const t=this._getInputId(e);if(this.instances.has(t))return;if(!this._validateInput(e))return;const 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){const n=(t||{}).return||this.config.return||"json",r=void 0!==e.original;switch(n){case"url":return r?e.images?.[0]?.url||e.original?.url||"":e.url||e.path||"";case"base64":return e.base64||e.dataUrl||"";case"assetId":return r?e.original?.assetId||"":e.assetId||e.id||"";case"fileName":return e.fileName||e.filename||"";default:return r?JSON.stringify(e):JSON.stringify({original:{url:e.url||e.path,width:e.width,height:e.height,assetId:e.assetId||e.id}})}}_createModalConfig(e){return{mode:e.mode||this.config.mode||"modal",modeUI:e.modeUI||this.config.modeUI||"full",features:e.features||this.config.features,modalSize:e.modalSize||this.config.modalSize||"fullscreen",title:e.description||this.config.title||"Seleccionar 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,allowSelectNew:!1!==e.allowSelectNew},initialImageUrl:e.initialImageUrl||null,returnConfig:{format:e.return||this.config.return,quality:e.quality||this.config.quality,outputFormat:e.format||this.config.format},inputMeta:{inputId:e.inputId,inputName:e.inputName,inputType:e.inputType,placeholder:e.placeholder}}}_getCropperConfig(e){const t=e.crop||this.config.crop,n={quality:e.quality||this.config.quality,format:e.format||this.config.format,mandatoryCrops:e.mandatoryCrops||[],allowAdditionalCrops:!1!==e.allowAdditionalCrops,maxCrops:e.maxCrops||null};if(e.mandatoryCrops&&e.mandatoryCrops.length>0)return{...n,aspectRatio:null};if(!t||"none"===t||"false"===t)return null;if("free"===t)return{...n,aspectRatio:null};const r={"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(r[t])return{...n,aspectRatio:r[t],minCropBoxWidth:e.minWidth||this.config.minWidth,minCropBoxHeight:e.minHeight||this.config.minHeight};if("string"==typeof t&&t.includes(":")){const[e,r]=t.split(":").map(Number);if(!isNaN(e)&&!isNaN(r)&&0!==r)return{...n,aspectRatio:e/r}}const a=parseFloat(t);return!isNaN(a)&&a>0?{...n,aspectRatio:a}:"object"==typeof t?{...n,...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,i=e=>{if(!e)return null;try{return JSON.parse(e)}catch(t){return console.warn("[Limbo AutoInputManager] Error parsing JSON attribute:",t),null}},o=i(e.dataset.mandatorycrops)||i(e.dataset.mandatoryCrops)||i(e.getAttribute("data-mandatory-crops"))||i(e.getAttribute("data-limbo-mandatory-crops"))||null;return{return:e.dataset.returntype||e.getAttribute("data-limbo-return")||this.config.return,mode:e.dataset.mode||e.getAttribute("data-limbo-mode")||this.config.mode,features:t(e.dataset.features)||t(e.getAttribute("data-limbo-features"))||this.config.features,crop:e.dataset.crop||e.getAttribute("data-limbo-crop")||this.config.crop,quality:a(e.dataset.quality)||a(e.getAttribute("data-limbo-quality"))||this.config.quality,format:e.dataset.format||e.getAttribute("data-limbo-format")||this.config.format,modeUI:e.dataset.modeui||e.dataset.modeUI||e.getAttribute("data-limbo-mode-ui")||this.config.modeUI,modalSize:e.dataset.modalsize||e.getAttribute("data-limbo-modal-size")||this.config.modalSize,theme:e.dataset.theme||e.getAttribute("data-limbo-theme")||this.config.theme,compact:r(e.dataset.compact,null)??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.dataset.buttontext||e.getAttribute("data-limbo-button-text")||this.config.buttonText,buttonStyle:e.dataset.buttonstyle||e.getAttribute("data-limbo-button-style")||this.config.buttonStyle,buttonClass:e.dataset.buttonclass||e.getAttribute("data-limbo-button-class")||this.config.buttonClass,showPreview: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,mandatoryCrops:o,allowAdditionalCrops:r(e.dataset.allowadditionalcrops,null)??r(e.getAttribute("data-limbo-allow-additional-crops"),!0),maxCrops:a(e.dataset.maxcrops)||a(e.getAttribute("data-limbo-max-crops"))||null,allowSelectNew:r(e.dataset.allowselectnew,null)??r(e.getAttribute("data-limbo-allow-select-new"),!0),initialImageUrl:e.value||null}}_generateInputId(){return`limbo-auto-input-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}_hideInput(e){e.style.display="none"}_insertButton(e,t){e.parentNode.insertBefore(t,e.nextSibling)}_restoreInput(e,t){e.style.display="",t&&t.parentNode&&t.parentNode.removeChild(t)}_setupObserver(){this.observer=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&this._scanNodeForInputs(e)})})}),this.observer.observe(document.body,{childList:!0,subtree:!0})}_scanNodeForInputs(e){const t=this.config.selector||`input[${this.config.dataset}]`;e.matches&&e.matches(t)&&this._processInput(e);const n=e.querySelectorAll&&e.querySelectorAll(t);n&&n.forEach(e=>this._processInput(e))}}class yn{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 vn{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 xn(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 xn{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: 500px; min-height: 400px;",medium:e?"width: 100%; height: 100%;":"max-width: 800px; min-height: 500px;",large:e?"width: 100%; height: 100%;":"max-width: 1400px; min-height: 700px;",xlarge:e?"width: 100%; height: 100%;":"max-width: 95dvw; min-height: 85vh;",fullscreen:"width: 100%; height: 100%; max-width: 100%; max-height: 100%; border-radius: 0;"},n="fullscreen"===this.config.size,r=e||n?`\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n transform: ${e?"translateY(100%)":"scale(0.95)"};\n width: 100%;\n height: 100%;\n max-width: none;\n max-height: none;\n border-radius: 0;\n background: white;\n z-index: ${this.manager._getNextZIndex()+1};\n opacity: ${e?"1":"0"};\n transition: ${e?"transform":"all"} 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n padding-top: env(safe-area-inset-top);\n padding-left: env(safe-area-inset-left);\n padding-right: env(safe-area-inset-right);\n padding-bottom: env(safe-area-inset-bottom);\n `:`\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%) scale(0.8);\n ${t[this.config.size]}\n width: 90%;\n max-height: 90vh;\n background: white;\n border-radius: 16px;\n box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);\n z-index: ${this.manager._getNextZIndex()+1};\n opacity: 0;\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n `;this.element.style.cssText=r,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),t="fullscreen"===this.config.size;return requestAnimationFrame(()=>{this.backdrop&&(this.backdrop.style.opacity="1"),this.element.style.opacity="1",this.element.style.transform=e?"translateY(0%)":t?"scale(1)":"translate(-50%, -50%) scale(1)"}),this.isOpen=!0,this.config.focus&&setTimeout(()=>{if(window.limbo&&window.limbo.core&&window.limbo.core.keyboard)window.limbo.core.keyboard.focusFirst(this.element);else{const e=this.getFocusableElements()[0];e&&e.focus()}},300),this.config.onOpen&&this.config.onOpen(this),this}close(){if(!this.isOpen)return this;const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t="fullscreen"===this.config.size;return this.backdrop&&(this.backdrop.style.opacity="0"),this.element.style.opacity="0",this.element.style.transform=e?"translateY(100%)":t?"scale(0.95)":"translate(-50%, -50%) scale(0.8)",setTimeout(()=>{this._cleanup()},300),this.isOpen=!1,window.limbo&&window.limbo.core&&window.limbo.core.keyboard&&(window.limbo.core.keyboard.setActiveModal(null),window.limbo.core.keyboard.releaseFocus()),this.config.onClose&&this.config.onClose(this),this}destroy(){this.close(),this.manager._removeModal(this),this.config.onDestroy&&this.config.onDestroy(this)}getBodyContainer(){return this.element.querySelector(".limbo-modal-body")}getFocusableElements(){return Array.from(this.element.querySelectorAll(this.manager.focusableSelectors))}getId(){return this.id}isOpened(){return this.isOpen}getConfig(){return{...this.config}}_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 wn{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 kn=new class{constructor(){this.config=new n,this.instances=new gn,this.autoInputs=new bn,this.events=new yn,this.modals=new vn,this.theme=new wn,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",tokenProvider:e.tokenProvider,prod:e.prod||!1,mode:e.mode||"embed",callbacks:e.callbacks||null},O={...O,...t},O.authMode||(O.token?O.authMode="manual":O.authMode="session"),this.config}setToken(e){return function(e){O.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=e=>{let n={};if(e.crops&&e.crops.length>0){const t=e.asset||e.original;n.original={url:t?.url||t?.urlSigned||e.originalUrl,width:t?.width||e.originalWidth,height:t?.height||e.originalHeight,assetId:t?.id||e.assetId},n.images=e.crops.map(e=>({url:e.url||e.urlSigned,width:e.width,height:e.height,name:e.name||e.filename}))}else e.asset?n.original={url:e.asset.url||e.asset.urlSigned,width:e.asset.width,height:e.asset.height,assetId:e.asset.id}:e.master?.urlSigned||e.master?.url?n.original={url:e.master.urlSigned||e.master.url,width:e.master.width||e.width,height:e.master.height||e.height,assetId:e.assetId}:e.url||e.urlSigned?n.original={url:e.url||e.urlSigned,width:e.width,height:e.height,assetId:e.assetId||e.id}:(console.warn("[Limbo] handleResult: formato de datos no reconocido",e),n=e);t(n),a.close()},r={...e,mode:"modal",autoDestroy:!0,interaction:{allowSelection:!0,allowCropping:!0,...e.interaction},callbacks:{onSelect:e=>{n(e)},onCropsSaved:e=>{n(e)},onCropperComplete:e=>{n(e)},onUpload:t=>{"upload-only"!==e.modeUI||e.features?.includes("cropper")||n(t)},onClose:()=>{}}};if(e.initialImageUrl){const t=this._extractAssetIdFromUrl(e.initialImageUrl);r._externalImage={url:e.initialImageUrl,filename:e.initialImageUrl.split("/").pop()?.split("?")[0]||"image.jpg",width:1920,height:1080,mime_type:"image/jpeg",id:t}}e.cropper&&(r.cropper=e.cropper),this.config.setGlobal({interaction:{allowSelection:!0,allowCropping:!0,...e.interaction}});const a=this.create(r);a.open()}_extractAssetIdFromUrl(e){if(!e)return null;try{const t=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,n=e.match(t);return n&&n.length>=2?n[1]:n&&1===n.length?n[0]:null}catch(t){return console.warn("Error extracting asset ID from URL:",t),null}}openGallery(e={}){const t=this.create({mode:"modal",modeUI:"gallery-only",features:["gallery"],autoDestroy:!0,modal:{title:e.title||"Seleccionar Imagen",size:e.size||"large"},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=kn,window.limboCore=kn);return"undefined"!=typeof window&&document.querySelector("#root")&&(kn.configure({prod:!1,publicKey:"pk_e464fd744106b7a8d63d453c4bd02582",authMode:"session"}),kn.create({container:"#root",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],title:"Limbo Image Manager - Development",url:!0}),kn.configureAutoInputs({dataset:"data-limbo-input-file",return:"json",features:["gallery","upload","cropper"],modeUI:"full",modalSize:"large",title:"Seleccionar imagen",crops:"free",allowDelete:!1})),kn});
|
|
2
2
|
//# sourceMappingURL=limbo.umd.map
|