limbo-component 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/limbo.cjs.js +3 -3
- package/dist/limbo.cjs.map +1 -1
- package/dist/limbo.css +1 -1
- package/dist/limbo.es.js +156 -310
- package/dist/limbo.es.map +1 -1
- package/dist/limbo.min.js +2 -2
- package/dist/limbo.min.js.map +1 -1
- package/dist/limbo.umd.js +2 -2
- 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/components/ImageCard.d.ts.map +1 -1
- package/dist/types/components/ImageVariantsModal.d.ts.map +1 -1
- package/dist/types/components/Pagination.d.ts +1 -1
- package/dist/types/components/Pagination.d.ts.map +1 -1
- package/dist/types/components/TabAI.d.ts +1 -2
- package/dist/types/components/TabAI.d.ts.map +1 -1
- package/dist/types/components/TabPortals.d.ts.map +1 -1
- package/dist/types/components/TabStock.d.ts +1 -2
- package/dist/types/components/TabStock.d.ts.map +1 -1
- package/dist/types/components/Tabs.d.ts.map +1 -1
- package/dist/types/components/UploadForm.d.ts +1 -3
- package/dist/types/components/UploadForm.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/types/components/Breadcrumb.d.ts +0 -14
- package/dist/types/components/Breadcrumb.d.ts.map +0 -1
package/dist/limbo.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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}}var r,a,i={exports:{}},o={};function s(){return a||(a=1,i.exports=function(){if(r)return o;r=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.iterator,p={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},f=Object.assign,g={};function b(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||p}function y(){}function v(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||p}b.prototype.isReactComponent={},b.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},b.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},y.prototype=b.prototype;var x=v.prototype=new y;x.constructor=v,f(x,b.prototype),x.isPureReactComponent=!0;var w=Array.isArray,k={H:null,A:null,T:null,S:null,V:null},C=Object.prototype.hasOwnProperty;function S(t,n,r,a,i,o){return r=o.ref,{$$typeof:e,type:t,key:n,ref:void 0!==r?r:null,props:o}}function N(t){return"object"==typeof t&&null!==t&&t.$$typeof===e}var j=/\/+/g;function E(e,t){return"object"==typeof e&&null!==e&&null!=e.key?(n=""+e.key,r={"=":"=0",":":"=2"},"$"+n.replace(/[=:]/g,function(e){return r[e]})):t.toString(36);var n,r}function $(){}function _(n,r,a,i,o){var s=typeof n;"undefined"!==s&&"boolean"!==s||(n=null);var l,c,u=!1;if(null===n)u=!0;else switch(s){case"bigint":case"string":case"number":u=!0;break;case"object":switch(n.$$typeof){case e:case t:u=!0;break;case m:return _((u=n._init)(n._payload),r,a,i,o)}}if(u)return o=o(n),u=""===i?"."+E(n,0):i,w(o)?(a="",null!=u&&(a=u.replace(j,"$&/")+"/"),_(o,r,a,"",function(e){return e})):null!=o&&(N(o)&&(l=o,c=a+(null==o.key||n&&n.key===o.key?"":(""+o.key).replace(j,"$&/")+"/")+u,o=S(l.type,c,void 0,0,0,l.props)),r.push(o)),1;u=0;var d,p=""===i?".":i+":";if(w(n))for(var f=0;f<n.length;f++)u+=_(i=n[f],r,a,s=p+E(i,f),o);else if("function"==typeof(f=null===(d=n)||"object"!=typeof d?null:"function"==typeof(d=h&&d[h]||d["@@iterator"])?d:null))for(n=f.call(n),f=0;!(i=n.next()).done;)u+=_(i=i.value,r,a,s=p+E(i,f++),o);else if("object"===s){if("function"==typeof n.then)return _(function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch("string"==typeof e.status?e.then($,$):(e.status="pending",e.then(function(t){"pending"===e.status&&(e.status="fulfilled",e.value=t)},function(t){"pending"===e.status&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}(n),r,a,i,o);throw r=String(n),Error("Objects are not valid as a React child (found: "+("[object Object]"===r?"object with keys {"+Object.keys(n).join(", ")+"}":r)+"). If you meant to render a collection of children, use an array instead.")}return u}function z(e,t,n){if(null==e)return e;var r=[],a=0;return _(e,r,"","",function(e){return t.call(n,e,a++)}),r}function T(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var 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)};function A(){}return o.Children={map:z,forEach:function(e,t,n){z(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return z(e,function(){t++}),t},toArray:function(e){return z(e,function(e){return e})||[]},only:function(e){if(!N(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},o.Component=b,o.Fragment=n,o.Profiler=i,o.PureComponent=v,o.StrictMode=a,o.Suspense=u,o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=k,o.__COMPILER_RUNTIME={__proto__:null,c:function(e){return k.H.useMemoCache(e)}},o.cache=function(e){return function(){return e.apply(null,arguments)}},o.cloneElement=function(e,t,n){if(null==e)throw Error("The argument must be a React element, but you passed "+e+".");var r=f({},e.props),a=e.key;if(null!=t)for(i in t.ref,void 0!==t.key&&(a=""+t.key),t)!C.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 S(e.type,a,void 0,0,0,r)},o.createContext=function(e){return(e={$$typeof:l,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider=e,e.Consumer={$$typeof:s,_context:e},e},o.createElement=function(e,t,n){var r,a={},i=null;if(null!=t)for(r in void 0!==t.key&&(i=""+t.key),t)C.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 S(e,i,void 0,0,0,a)},o.createRef=function(){return{current:null}},o.forwardRef=function(e){return{$$typeof:c,render:e}},o.isValidElement=N,o.lazy=function(e){return{$$typeof:m,_payload:{_status:-1,_result:e},_init:T}},o.memo=function(e,t){return{$$typeof:d,type:e,compare:void 0===t?null:t}},o.startTransition=function(e){var t=k.T,n={};k.T=n;try{var r=e(),a=k.S;null!==a&&a(n,r),"object"==typeof r&&null!==r&&"function"==typeof r.then&&r.then(A,P)}catch(e){P(e)}finally{k.T=t}},o.unstable_useCacheRefresh=function(){return k.H.useCacheRefresh()},o.use=function(e){return k.H.use(e)},o.useActionState=function(e,t,n){return k.H.useActionState(e,t,n)},o.useCallback=function(e,t){return k.H.useCallback(e,t)},o.useContext=function(e){return k.H.useContext(e)},o.useDebugValue=function(){},o.useDeferredValue=function(e,t){return k.H.useDeferredValue(e,t)},o.useEffect=function(e,t,n){var r=k.H;if("function"==typeof n)throw Error("useEffect CRUD overload is not enabled in this build of React.");return r.useEffect(e,t)},o.useId=function(){return k.H.useId()},o.useImperativeHandle=function(e,t,n){return k.H.useImperativeHandle(e,t,n)},o.useInsertionEffect=function(e,t){return k.H.useInsertionEffect(e,t)},o.useLayoutEffect=function(e,t){return k.H.useLayoutEffect(e,t)},o.useMemo=function(e,t){return k.H.useMemo(e,t)},o.useOptimistic=function(e,t){return k.H.useOptimistic(e,t)},o.useReducer=function(e,t,n){return k.H.useReducer(e,t,n)},o.useRef=function(e){return k.H.useRef(e)},o.useState=function(e){return k.H.useState(e)},o.useSyncExternalStore=function(e,t,n){return k.H.useSyncExternalStore(e,t,n)},o.useTransition=function(){return k.H.useTransition()},o.version="19.1.1",o}()),i.exports}var l=s();const c=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(l);var u,d,m={exports:{}},h={},p={exports:{}},f={};function g(){return d||(d=1,p.exports=(u||(u=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,C||(C=!0,k());else{var t=n(c);null!==t&&T(w,t.startTime-e)}}var k,C=!1,S=-1,N=5,j=-1;function E(){return!(!g&&e.unstable_now()-j<N)}function $(){if(g=!1,C){var t=e.unstable_now();j=t;var a=!0;try{e:{p=!1,f&&(f=!1,y(S),S=-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():C=!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){S=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"):N=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(S),S=-1):f=!0,T(w,i-o))):(r.sortIndex=s,t(l,r),p||h||(p=!0,C||(C=!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}}}}(f)),f)),p.exports}var b,y,v,x,w={exports:{}},k={};function C(){if(b)return k;b=1;var e=s();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"),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 k.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,k.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)},k.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()}},k.preconnect=function(e,t){"string"==typeof e&&(t=t?"string"==typeof(t=t.crossOrigin)?"use-credentials"===t?t:"":void 0:null,r.d.C(e,t))},k.prefetchDNS=function(e){"string"==typeof e&&r.d.D(e)},k.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})}},k.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)},k.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})}},k.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)},k.requestFormReset=function(e){r.d.r(e)},k.unstable_batchedUpdates=function(e,t){return e(t)},k.useFormState=function(e,t,n){return i.H.useFormState(e,t,n)},k.useFormStatus=function(){return i.H.useHostTransitionStatus()},k.version="19.1.1",k}var S,N,j=(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(e){console.error(e)}}(),m.exports=function(){if(v)return h;v=1;var e=g(),t=s(),n=(y||(y=1,function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}(),w.exports=C()),w.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 l(e){if(i(e)!==e)throw Error(r(188))}function c(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=c(e)))return t;e=e.sibling}return null}var u=Object.assign,d=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),k=Symbol.for("react.provider"),S=Symbol.for("react.consumer"),N=Symbol.for("react.context"),j=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"),P=Symbol.for("react.memo_cache_sentinel"),A=Symbol.iterator;function M(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=A&&e[A]||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 f:return"Fragment";case x: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 N:return(e.displayName||"Context")+".Provider";case S:return(e._context.displayName||"Context")+".Consumer";case j: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(e){}}return null}var O=Array.isArray,R=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},U=[],q=-1;function B(e){return{current:e}}function H(e){0>q||(e.current=U[q],U[q]=null,q--)}function W(e,t){q++,U[q]=e.current,e.current=t}var V=B(null),K=B(null),G=B(null),Q=B(null);function Y(e,t){switch(W(G,t),W(K,e),W(V,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?ld(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)e=cd(t=ld(t),e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}H(V),W(V,e)}function X(){H(V),H(K),H(G)}function J(e){null!==e.memoizedState&&W(Q,e);var t=V.current,n=cd(t,e.type);t!==n&&(W(K,e),W(V,n))}function Z(e){K.current===e&&(H(V),H(K)),Q.current===e&&(H(Q),Jd._currentValue=F)}var ee=Object.prototype.hasOwnProperty,te=e.unstable_scheduleCallback,ne=e.unstable_cancelCallback,re=e.unstable_shouldYield,ae=e.unstable_requestPaint,ie=e.unstable_now,oe=e.unstable_getCurrentPriorityLevel,se=e.unstable_ImmediatePriority,le=e.unstable_UserBlockingPriority,ce=e.unstable_NormalPriority,ue=e.unstable_LowPriority,de=e.unstable_IdlePriority,me=e.log,he=e.unstable_setDisableYieldValue,pe=null,fe=null;function ge(e){if("function"==typeof me&&he(e),fe&&"function"==typeof fe.setStrictMode)try{fe.setStrictMode(pe,e)}catch(e){}}var be=Math.clz32?Math.clz32:function(e){return 0==(e>>>=0)?32:31-(ye(e)/ve|0)|0},ye=Math.log,ve=Math.LN2,xe=256,we=4194304;function ke(e){var t=42&e;if(0!==t)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return 4194048&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Ce(e,t,n){var r=e.pendingLanes;if(0===r)return 0;var a=0,i=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=134217727&r;return 0!==s?0!==(r=s&~i)?a=ke(r):0!==(o&=s)?a=ke(o):n||0!==(n=s&~e)&&(a=ke(n)):0!==(s=r&~i)?a=ke(s):0!==o?a=ke(o):n||0!==(n=r&~e)&&(a=ke(n)),0===a?0:0!==t&&t!==a&&0===(t&i)&&((i=a&-a)>=(n=t&-t)||32===i&&4194048&n)?t:a}function Se(e,t){return 0===(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)}function Ne(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 je(){var e=xe;return!(4194048&(xe<<=1))&&(xe=256),e}function Ee(){var e=we;return!(62914560&(we<<=1))&&(we=4194304),e}function $e(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function _e(e,t){e.pendingLanes|=t,268435456!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ze(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-be(t);e.entangledLanes|=t,e.entanglements[r]=1073741824|e.entanglements[r]|4194090&n}function Te(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-be(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}function Pe(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 Ae(e){return 2<(e&=-e)?8<e?134217727&e?32:268435456:8:2}function Me(){var e=D.p;return 0!==e?e:void 0===(e=window.event)?32:hm(e.type)}var Ie=Math.random().toString(36).slice(2),Le="__reactFiber$"+Ie,Oe="__reactProps$"+Ie,Re="__reactContainer$"+Ie,De="__reactEvents$"+Ie,Fe="__reactListeners$"+Ie,Ue="__reactHandles$"+Ie,qe="__reactResources$"+Ie,Be="__reactMarker$"+Ie;function He(e){delete e[Le],delete e[Oe],delete e[De],delete e[Fe],delete e[Ue]}function We(e){var t=e[Le];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Re]||n[Le]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=Cd(e);null!==e;){if(n=e[Le])return n;e=Cd(e)}return t}n=(e=n).parentNode}return null}function Ve(e){if(e=e[Le]||e[Re]){var t=e.tag;if(5===t||6===t||13===t||26===t||27===t||3===t)return e}return null}function Ke(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e.stateNode;throw Error(r(33))}function Ge(e){var t=e[qe];return t||(t=e[qe]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Qe(e){e[Be]=!0}var Ye=new Set,Xe={};function Je(e,t){Ze(e,t),Ze(e+"Capture",t)}function Ze(e,t){for(Xe[e]=t,e=0;e<t.length;e++)Ye.add(t[e])}var et,tt,nt=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),rt={},at={};function it(e,t,n){if(a=t,ee.call(at,a)||!ee.call(rt,a)&&(nt.test(a)?at[a]=!0:(rt[a]=!0,0)))if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":return void e.removeAttribute(t);case"boolean":var r=t.toLowerCase().slice(0,5);if("data-"!==r&&"aria-"!==r)return void e.removeAttribute(t)}e.setAttribute(t,""+n)}var a}function ot(e,t,n){if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(t)}e.setAttribute(t,""+n)}}function st(e,t,n,r){if(null===r)e.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(n)}e.setAttributeNS(t,n,""+r)}}function lt(e){if(void 0===et)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);et=t&&t[1]||"",tt=-1<e.stack.indexOf("\n at")?" (<anonymous>)":-1<e.stack.indexOf("@")?"@unknown:0:0":""}return"\n"+et+e+tt}var ct=!1;function ut(e,t){if(!e||ct)return"";ct=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&"function"==typeof n.catch&&n.catch(function(){})}}catch(e){if(e&&r&&"string"==typeof e.stack)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var a=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,"name");a&&a.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var i=r.DetermineComponentFrameRoot(),o=i[0],s=i[1];if(o&&s){var l=o.split("\n"),c=s.split("\n");for(a=r=0;r<l.length&&!l[r].includes("DetermineComponentFrameRoot");)r++;for(;a<c.length&&!c[a].includes("DetermineComponentFrameRoot");)a++;if(r===l.length||a===c.length)for(r=l.length-1,a=c.length-1;1<=r&&0<=a&&l[r]!==c[a];)a--;for(;1<=r&&0<=a;r--,a--)if(l[r]!==c[a]){if(1!==r||1!==a)do{if(r--,0>--a||l[r]!==c[a]){var u="\n"+l[r].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}}while(1<=r&&0<=a);break}}}finally{ct=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?lt(n):""}function dt(e){switch(e.tag){case 26:case 27:case 5:return lt(e.type);case 16:return lt("Lazy");case 13:return lt("Suspense");case 19:return lt("SuspenseList");case 0:case 15:return ut(e.type,!1);case 11:return ut(e.type.render,!1);case 1:return ut(e.type,!0);case 31:return lt("Activity");default:return""}}function mt(e){try{var t="";do{t+=dt(e),e=e.return}while(e);return t}catch(e){return"\nError generating stack: "+e.message+"\n"+e.stack}}function ht(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function pt(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function ft(e){e._valueTracker||(e._valueTracker=function(e){var t=pt(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&void 0!==n&&"function"==typeof n.get&&"function"==typeof n.set){var a=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(e){r=""+e,i.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e))}function gt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=pt(e)?e.checked?"true":"false":e.value),(e=r)!==n&&(t.setValue(e),!0)}function bt(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}var yt=/[\n"\\]/g;function vt(e){return e.replace(yt,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function xt(e,t,n,r,a,i,o,s){e.name="",null!=o&&"function"!=typeof o&&"symbol"!=typeof o&&"boolean"!=typeof o?e.type=o:e.removeAttribute("type"),null!=t?"number"===o?(0===t&&""===e.value||e.value!=t)&&(e.value=""+ht(t)):e.value!==""+ht(t)&&(e.value=""+ht(t)):"submit"!==o&&"reset"!==o||e.removeAttribute("value"),null!=t?kt(e,o,ht(t)):null!=n?kt(e,o,ht(n)):null!=r&&e.removeAttribute("value"),null==a&&null!=i&&(e.defaultChecked=!!i),null!=a&&(e.checked=a&&"function"!=typeof a&&"symbol"!=typeof a),null!=s&&"function"!=typeof s&&"symbol"!=typeof s&&"boolean"!=typeof s?e.name=""+ht(s):e.removeAttribute("name")}function wt(e,t,n,r,a,i,o,s){if(null!=i&&"function"!=typeof i&&"symbol"!=typeof i&&"boolean"!=typeof i&&(e.type=i),null!=t||null!=n){if(("submit"===i||"reset"===i)&&null==t)return;n=null!=n?""+ht(n):"",t=null!=t?""+ht(t):n,s||t===e.value||(e.value=t),e.defaultValue=t}r="function"!=typeof(r=null!=r?r:a)&&"symbol"!=typeof r&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,null!=o&&"function"!=typeof o&&"symbol"!=typeof o&&"boolean"!=typeof o&&(e.name=o)}function kt(e,t,n){"number"===t&&bt(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function Ct(e,t,n,r){if(e=e.options,t){t={};for(var a=0;a<n.length;a++)t["$"+n[a]]=!0;for(n=0;n<e.length;n++)a=t.hasOwnProperty("$"+e[n].value),e[n].selected!==a&&(e[n].selected=a),a&&r&&(e[n].defaultSelected=!0)}else{for(n=""+ht(n),t=null,a=0;a<e.length;a++){if(e[a].value===n)return e[a].selected=!0,void(r&&(e[a].defaultSelected=!0));null!==t||e[a].disabled||(t=e[a])}null!==t&&(t.selected=!0)}}function St(e,t,n){null==t||((t=""+ht(t))!==e.value&&(e.value=t),null!=n)?e.defaultValue=null!=n?""+ht(n):"":e.defaultValue!==t&&(e.defaultValue=t)}function Nt(e,t,n,a){if(null==t){if(null!=a){if(null!=n)throw Error(r(92));if(O(a)){if(1<a.length)throw Error(r(93));a=a[0]}n=a}null==n&&(n=""),t=n}n=ht(t),e.defaultValue=n,(a=e.textContent)===n&&""!==a&&null!==a&&(e.value=a)}function jt(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 Et=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function $t(e,t,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||Et.has(t)?"float"===t?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function _t(e,t,n){if(null!=t&&"object"!=typeof t)throw Error(r(62));if(e=e.style,null!=n){for(var a in n)!n.hasOwnProperty(a)||null!=t&&t.hasOwnProperty(a)||(0===a.indexOf("--")?e.setProperty(a,""):"float"===a?e.cssFloat="":e[a]="");for(var i in t)a=t[i],t.hasOwnProperty(i)&&n[i]!==a&&$t(e,i,a)}else for(var o in t)t.hasOwnProperty(o)&&$t(e,o,t[o])}function zt(e){if(-1===e.indexOf("-"))return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Tt=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Pt=/^[\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 At(e){return Pt.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}var Mt=null;function It(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var Lt=null,Ot=null;function Rt(e){var t=Ve(e);if(t&&(e=t.stateNode)){var n=e[Oe]||null;e:switch(e=t.stateNode,t.type){case"input":if(xt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,"radio"===n.type&&null!=t){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+vt(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var a=n[t];if(a!==e&&a.form===e.form){var i=a[Oe]||null;if(!i)throw Error(r(90));xt(a,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name)}}for(t=0;t<n.length;t++)(a=n[t]).form===e.form&>(a)}break e;case"textarea":St(e,n.value,n.defaultValue);break e;case"select":null!=(t=n.value)&&Ct(e,!!n.multiple,t,!1)}}}var Dt=!1;function Ft(e,t,n){if(Dt)return e(t,n);Dt=!0;try{return e(t)}finally{if(Dt=!1,(null!==Lt||null!==Ot)&&(Wc(),Lt&&(t=Lt,e=Ot,Ot=Lt=null,Rt(t),e)))for(t=0;t<e.length;t++)Rt(e[t])}}function Ut(e,t){var n=e.stateNode;if(null===n)return null;var a=n[Oe]||null;if(null===a)return null;n=a[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(a=!a.disabled)||(a=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!a;break e;default:e=!1}if(e)return null;if(n&&"function"!=typeof n)throw Error(r(231,t,typeof n));return n}var qt=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),Bt=!1;if(qt)try{var Ht={};Object.defineProperty(Ht,"passive",{get:function(){Bt=!0}}),window.addEventListener("test",Ht,Ht),window.removeEventListener("test",Ht,Ht)}catch(e){Bt=!1}var Wt=null,Vt=null,Kt=null;function Gt(){if(Kt)return Kt;var e,t,n=Vt,r=n.length,a="value"in Wt?Wt.value:Wt.textContent,i=a.length;for(e=0;e<r&&n[e]===a[e];e++);var o=r-e;for(t=1;t<=o&&n[r-t]===a[i-t];t++);return Kt=a.slice(e,1<t?1-t:void 0)}function Qt(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function Yt(){return!0}function Xt(){return!1}function Jt(e){function t(t,n,r,a,i){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=a,this.target=i,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(a):a[o]);return this.isDefaultPrevented=(null!=a.defaultPrevented?a.defaultPrevented:!1===a.returnValue)?Yt:Xt,this.isPropagationStopped=Xt,this}return u(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=Yt)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=Yt)},persist:function(){},isPersistent:Yt}),t}var Zt,en,tn,nn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},rn=Jt(nn),an=u({},nn,{view:0,detail:0}),on=Jt(an),sn=u({},an,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:yn,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==tn&&(tn&&"mousemove"===e.type?(Zt=e.screenX-tn.screenX,en=e.screenY-tn.screenY):en=Zt=0,tn=e),Zt)},movementY:function(e){return"movementY"in e?e.movementY:en}}),ln=Jt(sn),cn=Jt(u({},sn,{dataTransfer:0})),un=Jt(u({},an,{relatedTarget:0})),dn=Jt(u({},nn,{animationName:0,elapsedTime:0,pseudoElement:0})),mn=Jt(u({},nn,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}})),hn=Jt(u({},nn,{data:0})),pn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},fn={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},gn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function bn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=gn[e])&&!!t[e]}function yn(){return bn}var vn=Jt(u({},an,{key:function(e){if(e.key){var t=pn[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=Qt(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?fn[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:yn,charCode:function(e){return"keypress"===e.type?Qt(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?Qt(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}})),xn=Jt(u({},sn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),wn=Jt(u({},an,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:yn})),kn=Jt(u({},nn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Cn=Jt(u({},sn,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Sn=Jt(u({},nn,{newState:0,oldState:0})),Nn=[9,13,27,32],jn=qt&&"CompositionEvent"in window,En=null;qt&&"documentMode"in document&&(En=document.documentMode);var $n=qt&&"TextEvent"in window&&!En,_n=qt&&(!jn||En&&8<En&&11>=En),zn=String.fromCharCode(32),Tn=!1;function Pn(e,t){switch(e){case"keyup":return-1!==Nn.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function An(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Mn=!1,In={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Ln(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!In[e.type]:"textarea"===t}function On(e,t,n,r){Lt?Ot?Ot.push(r):Ot=[r]:Lt=r,0<(t=Gu(t,"onChange")).length&&(n=new rn("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Rn=null,Dn=null;function Fn(e){Fu(e,0)}function Un(e){if(gt(Ke(e)))return e}function qn(e,t){if("change"===e)return t}var Bn=!1;if(qt){var Hn;if(qt){var Wn="oninput"in document;if(!Wn){var Vn=document.createElement("div");Vn.setAttribute("oninput","return;"),Wn="function"==typeof Vn.oninput}Hn=Wn}else Hn=!1;Bn=Hn&&(!document.documentMode||9<document.documentMode)}function Kn(){Rn&&(Rn.detachEvent("onpropertychange",Gn),Dn=Rn=null)}function Gn(e){if("value"===e.propertyName&&Un(Dn)){var t=[];On(t,Dn,e,It(e)),Ft(Fn,t)}}function Qn(e,t,n){"focusin"===e?(Kn(),Dn=n,(Rn=t).attachEvent("onpropertychange",Gn)):"focusout"===e&&Kn()}function Yn(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Un(Dn)}function Xn(e,t){if("click"===e)return Un(t)}function Jn(e,t){if("input"===e||"change"===e)return Un(t)}var Zn="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t};function er(e,t){if(Zn(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var a=n[r];if(!ee.call(t,a)||!Zn(e[a],t[a]))return!1}return!0}function tr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function nr(e,t){var n,r=tr(e);for(e=0;r;){if(3===r.nodeType){if(n=e+r.textContent.length,e<=t&&n>=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=tr(r)}}function rr(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?rr(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function ar(e){for(var t=bt((e=null!=e&&null!=e.ownerDocument&&null!=e.ownerDocument.defaultView?e.ownerDocument.defaultView:window).document);t instanceof e.HTMLIFrameElement;){try{var n="string"==typeof t.contentWindow.location.href}catch(e){n=!1}if(!n)break;t=bt((e=t.contentWindow).document)}return t}function ir(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}var or=qt&&"documentMode"in document&&11>=document.documentMode,sr=null,lr=null,cr=null,ur=!1;function dr(e,t,n){var r=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;ur||null==sr||sr!==bt(r)||(r="selectionStart"in(r=sr)&&ir(r)?{start:r.selectionStart,end:r.selectionEnd}:{anchorNode:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset},cr&&er(cr,r)||(cr=r,0<(r=Gu(lr,"onSelect")).length&&(t=new rn("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=sr)))}function mr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var hr={animationend:mr("Animation","AnimationEnd"),animationiteration:mr("Animation","AnimationIteration"),animationstart:mr("Animation","AnimationStart"),transitionrun:mr("Transition","TransitionRun"),transitionstart:mr("Transition","TransitionStart"),transitioncancel:mr("Transition","TransitionCancel"),transitionend:mr("Transition","TransitionEnd")},pr={},fr={};function gr(e){if(pr[e])return pr[e];if(!hr[e])return e;var t,n=hr[e];for(t in n)if(n.hasOwnProperty(t)&&t in fr)return pr[e]=n[t];return e}qt&&(fr=document.createElement("div").style,"AnimationEvent"in window||(delete hr.animationend.animation,delete hr.animationiteration.animation,delete hr.animationstart.animation),"TransitionEvent"in window||delete hr.transitionend.transition);var br=gr("animationend"),yr=gr("animationiteration"),vr=gr("animationstart"),xr=gr("transitionrun"),wr=gr("transitionstart"),kr=gr("transitioncancel"),Cr=gr("transitionend"),Sr=new Map,Nr="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 jr(e,t){Sr.set(e,t),Je(t,[e])}Nr.push("scrollEnd");var Er=new WeakMap;function $r(e,t){if("object"==typeof e&&null!==e){var n=Er.get(e);return void 0!==n?n:(t={value:e,source:t,stack:mt(t)},Er.set(e,t),t)}return{value:e,source:t,stack:mt(t)}}var _r=[],zr=0,Tr=0;function Pr(){for(var e=zr,t=Tr=zr=0;t<e;){var n=_r[t];_r[t++]=null;var r=_r[t];_r[t++]=null;var a=_r[t];_r[t++]=null;var i=_r[t];if(_r[t++]=null,null!==r&&null!==a){var o=r.pending;null===o?a.next=a:(a.next=o.next,o.next=a),r.pending=a}0!==i&&Lr(n,a,i)}}function Ar(e,t,n,r){_r[zr++]=e,_r[zr++]=t,_r[zr++]=n,_r[zr++]=r,Tr|=r,e.lanes|=r,null!==(e=e.alternate)&&(e.lanes|=r)}function Mr(e,t,n,r){return Ar(e,t,n,r),Or(e)}function Ir(e,t){return Ar(e,null,null,t),Or(e)}function Lr(e,t,n){e.lanes|=n;var r=e.alternate;null!==r&&(r.lanes|=n);for(var a=!1,i=e.return;null!==i;)i.childLanes|=n,null!==(r=i.alternate)&&(r.childLanes|=n),22===i.tag&&(null===(e=i.stateNode)||1&e._visibility||(a=!0)),e=i,i=i.return;return 3===e.tag?(i=e.stateNode,a&&null!==t&&(a=31-be(n),null===(r=(e=i.hiddenUpdates)[a])?e[a]=[t]:r.push(t),t.lane=536870912|n),i):null}function Or(e){if(50<Lc)throw Lc=0,Oc=null,Error(r(185));for(var t=e.return;null!==t;)t=(e=t).return;return 3===e.tag?e.stateNode:null}var Rr={};function Dr(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Fr(e,t,n,r){return new Dr(e,t,n,r)}function Ur(e){return!(!(e=e.prototype)||!e.isReactComponent)}function qr(e,t){var n=e.alternate;return null===n?((n=Fr(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=65011712&e.flags,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Br(e,t){e.flags&=65011714;var n=e.alternate;return null===n?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Hr(e,t,n,a,i,o){var s=0;if(a=e,"function"==typeof e)Ur(e)&&(s=1);else if("string"==typeof e)s=function(e,t,n){if(1===n||null!=t.itemProp)return!1;switch(e){case"meta":case"title":return!0;case"style":if("string"!=typeof t.precedence||"string"!=typeof t.href||""===t.href)break;return!0;case"link":if("string"!=typeof t.rel||"string"!=typeof t.href||""===t.href||t.onLoad||t.onError)break;return"stylesheet"!==t.rel||(e=t.disabled,"string"==typeof t.precedence&&null==e);case"script":if(t.async&&"function"!=typeof t.async&&"symbol"!=typeof t.async&&!t.onLoad&&!t.onError&&t.src&&"string"==typeof t.src)return!0}return!1}(e,n,V.current)?26:"html"===e||"head"===e||"body"===e?27:5;else e:switch(e){case T:return(e=Fr(31,n,t,i)).elementType=T,e.lanes=o,e;case f:return Wr(n.children,i,o,t);case b:s=8,i|=24;break;case x:return(e=Fr(12,n,t,2|i)).elementType=x,e.lanes=o,e;case E:return(e=Fr(13,n,t,i)).elementType=E,e.lanes=o,e;case $:return(e=Fr(19,n,t,i)).elementType=$,e.lanes=o,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case k:case N:s=10;break e;case S:s=9;break e;case j:s=11;break e;case _:s=14;break e;case z:s=16,a=null;break e}s=29,n=Error(r(130,null===e?"null":typeof e,"")),a=null}return(t=Fr(s,n,t,i)).elementType=e,t.type=a,t.lanes=o,t}function Wr(e,t,n,r){return(e=Fr(7,e,r,t)).lanes=n,e}function Vr(e,t,n){return(e=Fr(6,e,null,t)).lanes=n,e}function Kr(e,t,n){return(t=Fr(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Gr=[],Qr=0,Yr=null,Xr=0,Jr=[],Zr=0,ea=null,ta=1,na="";function ra(e,t){Gr[Qr++]=Xr,Gr[Qr++]=Yr,Yr=e,Xr=t}function aa(e,t,n){Jr[Zr++]=ta,Jr[Zr++]=na,Jr[Zr++]=ea,ea=e;var r=ta;e=na;var a=32-be(r)-1;r&=~(1<<a),n+=1;var i=32-be(t)+a;if(30<i){var o=a-a%5;i=(r&(1<<o)-1).toString(32),r>>=o,a-=o,ta=1<<32-be(t)+a|n<<a|r,na=i+e}else ta=1<<i|n<<a|r,na=e}function ia(e){null!==e.return&&(ra(e,1),aa(e,1,0))}function oa(e){for(;e===Yr;)Yr=Gr[--Qr],Gr[Qr]=null,Xr=Gr[--Qr],Gr[Qr]=null;for(;e===ea;)ea=Jr[--Zr],Jr[Zr]=null,na=Jr[--Zr],Jr[Zr]=null,ta=Jr[--Zr],Jr[Zr]=null}var sa=null,la=null,ca=!1,ua=null,da=!1,ma=Error(r(519));function ha(e){throw va($r(Error(r(418,"")),e)),ma}function pa(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[Le]=e,t[Oe]=r,n){case"dialog":Uu("cancel",t),Uu("close",t);break;case"iframe":case"object":case"embed":Uu("load",t);break;case"video":case"audio":for(n=0;n<Ru.length;n++)Uu(Ru[n],t);break;case"source":Uu("error",t);break;case"img":case"image":case"link":Uu("error",t),Uu("load",t);break;case"details":Uu("toggle",t);break;case"input":Uu("invalid",t),wt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0),ft(t);break;case"select":Uu("invalid",t);break;case"textarea":Uu("invalid",t),Nt(t,r.value,r.defaultValue,r.children),ft(t)}"string"!=typeof(n=r.children)&&"number"!=typeof n&&"bigint"!=typeof n||t.textContent===""+n||!0===r.suppressHydrationWarning||ed(t.textContent,n)?(null!=r.popover&&(Uu("beforetoggle",t),Uu("toggle",t)),null!=r.onScroll&&Uu("scroll",t),null!=r.onScrollEnd&&Uu("scrollend",t),null!=r.onClick&&(t.onclick=td),t=!0):t=!1,t||ha(e)}function fa(e){for(sa=e.return;sa;)switch(sa.tag){case 5:case 13:return void(da=!1);case 27:case 3:return void(da=!0);default:sa=sa.return}}function ga(e){if(e!==sa)return!1;if(!ca)return fa(e),ca=!0,!1;var t,n=e.tag;if((t=3!==n&&27!==n)&&((t=5===n)&&(t=!("form"!==(t=e.type)&&"button"!==t)||ud(e.type,e.memoizedProps)),t=!t),t&&la&&ha(e),fa(e),13===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(r(317));e:{for(e=e.nextSibling,n=0;e;){if(8===e.nodeType)if("/$"===(t=e.data)){if(0===n){la=wd(e.nextSibling);break e}n--}else"$"!==t&&"$!"!==t&&"$?"!==t||n++;e=e.nextSibling}la=null}}else 27===n?(n=la,bd(e.type)?(e=kd,kd=null,la=e):la=n):la=sa?wd(e.stateNode.nextSibling):null;return!0}function ba(){la=sa=null,ca=!1}function ya(){var e=ua;return null!==e&&(null===Cc?Cc=e:Cc.push.apply(Cc,e),ua=null),e}function va(e){null===ua?ua=[e]:ua.push(e)}var xa=B(null),wa=null,ka=null;function Ca(e,t,n){W(xa,t._currentValue),t._currentValue=n}function Sa(e){e._currentValue=xa.current,H(xa)}function Na(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 ja(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),Na(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),Na(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 Ea(e,t,n,a){e=null;for(var i=t,o=!1;null!==i;){if(!o)if(524288&i.flags)o=!0;else if(262144&i.flags)break;if(10===i.tag){var s=i.alternate;if(null===s)throw Error(r(387));if(null!==(s=s.memoizedProps)){var l=i.type;Zn(i.pendingProps.value,s.value)||(null!==e?e.push(l):e=[l])}}else if(i===Q.current){if(null===(s=i.alternate))throw Error(r(387));s.memoizedState.memoizedState!==i.memoizedState.memoizedState&&(null!==e?e.push(Jd):e=[Jd])}i=i.return}null!==e&&ja(t,e,n,a),t.flags|=262144}function $a(e){for(e=e.firstContext;null!==e;){if(!Zn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function _a(e){wa=e,ka=null,null!==(e=e.dependencies)&&(e.firstContext=null)}function za(e){return Pa(wa,e)}function Ta(e,t){return null===wa&&_a(e),Pa(e,t)}function Pa(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},null===ka){if(null===e)throw Error(r(308));ka=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else ka=ka.next=t;return n}var Aa="undefined"!=typeof AbortController?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Ma=e.unstable_scheduleCallback,Ia=e.unstable_NormalPriority,La={$$typeof:N,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Oa(){return{controller:new Aa,data:new Map,refCount:0}}function Ra(e){e.refCount--,0===e.refCount&&Ma(Ia,function(){e.controller.abort()})}var Da=null,Fa=0,Ua=0,qa=null;function Ba(){if(0===--Fa&&null!==Da){null!==qa&&(qa.status="fulfilled");var e=Da;Da=null,Ua=0,qa=null;for(var t=0;t<e.length;t++)(0,e[t])()}}var Ha=R.S;R.S=function(e,t){"object"==typeof t&&null!==t&&"function"==typeof t.then&&function(e,t){if(null===Da){var n=Da=[];Fa=0,Ua=Au(),qa={status:"pending",value:void 0,then:function(e){n.push(e)}}}Fa++,t.then(Ba,Ba)}(0,t),null!==Ha&&Ha(e,t)};var Wa=B(null);function Va(){var e=Wa.current;return null!==e?e:sc.pooledCache}function Ka(e,t){W(Wa,null===t?Wa.current:t.pool)}function Ga(){var e=Va();return null===e?null:{parent:La._currentValue,pool:e}}var Qa=Error(r(460)),Ya=Error(r(474)),Xa=Error(r(542)),Ja={then:function(){}};function Za(e){return"fulfilled"===(e=e.status)||"rejected"===e}function ei(){}function ti(e,t,n){switch(void 0===(n=e[n])?e.push(t):n!==t&&(t.then(ei,ei),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw ai(e=t.reason),e;default:if("string"==typeof t.status)t.then(ei,ei);else{if(null!==(e=sc)&&100<e.shellSuspendCounter)throw Error(r(482));(e=t).status="pending",e.then(function(e){if("pending"===t.status){var n=t;n.status="fulfilled",n.value=e}},function(e){if("pending"===t.status){var n=t;n.status="rejected",n.reason=e}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw ai(e=t.reason),e}throw ni=t,Qa}}var ni=null;function ri(){if(null===ni)throw Error(r(459));var e=ni;return ni=null,e}function ai(e){if(e===Qa||e===Xa)throw Error(r(483))}var ii=!1;function oi(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function si(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function li(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ci(e,t,n){var r=e.updateQueue;if(null===r)return null;if(r=r.shared,2&oc){var a=r.pending;return null===a?t.next=t:(t.next=a.next,a.next=t),r.pending=t,t=Or(e),Lr(e,null,n),t}return Ar(e,r,t,n),Or(e)}function ui(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,4194048&n)){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,Te(e,n)}}function di(e,t){var n=e.updateQueue,r=e.alternate;if(null!==r&&n===(r=r.updateQueue)){var a=null,i=null;if(null!==(n=n.firstBaseUpdate)){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};null===i?a=i=o:i=i.next=o,n=n.next}while(null!==n);null===i?a=i=t:i=i.next=t}else a=i=t;return n={baseState:r.baseState,firstBaseUpdate:a,lastBaseUpdate:i,shared:r.shared,callbacks:r.callbacks},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var mi=!1;function hi(){if(mi&&null!==qa)throw qa}function pi(e,t,n,r){mi=!1;var a=e.updateQueue;ii=!1;var i=a.firstBaseUpdate,o=a.lastBaseUpdate,s=a.shared.pending;if(null!==s){a.shared.pending=null;var l=s,c=l.next;l.next=null,null===o?i=c:o.next=c,o=l;var d=e.alternate;null!==d&&(s=(d=d.updateQueue).lastBaseUpdate)!==o&&(null===s?d.firstBaseUpdate=c:s.next=c,d.lastBaseUpdate=l)}if(null!==i){var m=a.baseState;for(o=0,d=c=l=null,s=i;;){var h=-536870913&s.lane,p=h!==s.lane;if(p?(cc&h)===h:(r&h)===h){0!==h&&h===Ua&&(mi=!0),null!==d&&(d=d.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});e:{var f=e,g=s;h=t;var b=n;switch(g.tag){case 1:if("function"==typeof(f=g.payload)){m=f.call(b,m,h);break e}m=f;break e;case 3:f.flags=-65537&f.flags|128;case 0:if(null==(h="function"==typeof(f=g.payload)?f.call(b,m,h):f))break e;m=u({},m,h);break e;case 2:ii=!0}}null!==(h=s.callback)&&(e.flags|=64,p&&(e.flags|=8192),null===(p=a.callbacks)?a.callbacks=[h]:p.push(h))}else p={lane:h,tag:s.tag,payload:s.payload,callback:s.callback,next:null},null===d?(c=d=p,l=m):d=d.next=p,o|=h;if(null===(s=s.next)){if(null===(s=a.shared.pending))break;s=(p=s).next,p.next=null,a.lastBaseUpdate=p,a.shared.pending=null}}null===d&&(l=m),a.baseState=l,a.firstBaseUpdate=c,a.lastBaseUpdate=d,null===i&&(a.shared.lanes=0),bc|=o,e.lanes=o,e.memoizedState=m}}function fi(e,t){if("function"!=typeof e)throw Error(r(191,e));e.call(t)}function gi(e,t){var n=e.callbacks;if(null!==n)for(e.callbacks=null,e=0;e<n.length;e++)fi(n[e],t)}var bi=B(null),yi=B(0);function vi(e,t){W(yi,e=fc),W(bi,t),fc=e|t.baseLanes}function xi(){W(yi,fc),W(bi,bi.current)}function wi(){fc=yi.current,H(bi),H(yi)}var ki=0,Ci=null,Si=null,Ni=null,ji=!1,Ei=!1,$i=!1,_i=0,zi=0,Ti=null,Pi=0;function Ai(){throw Error(r(321))}function Mi(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Zn(e[n],t[n]))return!1;return!0}function Ii(e,t,n,r,a,i){return ki=i,Ci=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,R.H=null===e||null===e.memoizedState?Yo:Xo,$i=!1,i=n(r,a),$i=!1,Ei&&(i=Oi(t,n,r,a)),Li(e),i}function Li(e){R.H=Qo;var t=null!==Si&&null!==Si.next;if(ki=0,Ni=Si=Ci=null,ji=!1,zi=0,Ti=null,t)throw Error(r(300));null===e||Ts||null!==(e=e.dependencies)&&$a(e)&&(Ts=!0)}function Oi(e,t,n,a){Ci=e;var i=0;do{if(Ei&&(Ti=null),zi=0,Ei=!1,25<=i)throw Error(r(301));if(i+=1,Ni=Si=null,null!=e.updateQueue){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,null!=o.memoCache&&(o.memoCache.index=0)}R.H=Jo,o=t(n,a)}while(Ei);return o}function Ri(){var e=R.H,t=e.useState()[0];return t="function"==typeof t.then?Hi(t):t,e=e.useState()[0],(null!==Si?Si.memoizedState:null)!==e&&(Ci.flags|=1024),t}function Di(){var e=0!==_i;return _i=0,e}function Fi(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Ui(e){if(ji){for(e=e.memoizedState;null!==e;){var t=e.queue;null!==t&&(t.pending=null),e=e.next}ji=!1}ki=0,Ni=Si=Ci=null,Ei=!1,zi=_i=0,Ti=null}function qi(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===Ni?Ci.memoizedState=Ni=e:Ni=Ni.next=e,Ni}function Bi(){if(null===Si){var e=Ci.alternate;e=null!==e?e.memoizedState:null}else e=Si.next;var t=null===Ni?Ci.memoizedState:Ni.next;if(null!==t)Ni=t,Si=e;else{if(null===e){if(null===Ci.alternate)throw Error(r(467));throw Error(r(310))}e={memoizedState:(Si=e).memoizedState,baseState:Si.baseState,baseQueue:Si.baseQueue,queue:Si.queue,next:null},null===Ni?Ci.memoizedState=Ni=e:Ni=Ni.next=e}return Ni}function Hi(e){var t=zi;return zi+=1,null===Ti&&(Ti=[]),e=ti(Ti,e,t),t=Ci,null===(null===Ni?t.memoizedState:Ni.next)&&(t=t.alternate,R.H=null===t||null===t.memoizedState?Yo:Xo),e}function Wi(e){if(null!==e&&"object"==typeof e){if("function"==typeof e.then)return Hi(e);if(e.$$typeof===N)return za(e)}throw Error(r(438,String(e)))}function Vi(e){var t=null,n=Ci.updateQueue;if(null!==n&&(t=n.memoCache),null==t){var r=Ci.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},Ci.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]=P;return t.index++,n}function Ki(e,t){return"function"==typeof t?t(e):t}function Gi(e){return Qi(Bi(),Si,e)}function Qi(e,t,n){var a=e.queue;if(null===a)throw Error(r(311));a.lastRenderedReducer=n;var i=e.baseQueue,o=a.pending;if(null!==o){if(null!==i){var s=i.next;i.next=o.next,o.next=s}t.baseQueue=i=o,a.pending=null}if(o=e.baseState,null===i)e.memoizedState=o;else{var l=s=null,c=null,u=t=i.next,d=!1;do{var m=-536870913&u.lane;if(m!==u.lane?(cc&m)===m:(ki&m)===m){var h=u.revertLane;if(0===h)null!==c&&(c=c.next={lane:0,revertLane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),m===Ua&&(d=!0);else{if((ki&h)===h){u=u.next,h===Ua&&(d=!0);continue}m={lane:0,revertLane:u.revertLane,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(l=c=m,s=o):c=c.next=m,Ci.lanes|=h,bc|=h}m=u.action,$i&&n(o,m),o=u.hasEagerState?u.eagerState:n(o,m)}else h={lane:m,revertLane:u.revertLane,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(l=c=h,s=o):c=c.next=h,Ci.lanes|=m,bc|=m;u=u.next}while(null!==u&&u!==t);if(null===c?s=o:c.next=l,!Zn(o,e.memoizedState)&&(Ts=!0,d&&null!==(n=qa)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=c,a.lastRenderedState=o}return null===i&&(a.lanes=0),[e.memoizedState,a.dispatch]}function Yi(e){var t=Bi(),n=t.queue;if(null===n)throw Error(r(311));n.lastRenderedReducer=e;var a=n.dispatch,i=n.pending,o=t.memoizedState;if(null!==i){n.pending=null;var s=i=i.next;do{o=e(o,s.action),s=s.next}while(s!==i);Zn(o,t.memoizedState)||(Ts=!0),t.memoizedState=o,null===t.baseQueue&&(t.baseState=o),n.lastRenderedState=o}return[o,a]}function Xi(e,t,n){var a=Ci,i=Bi(),o=ca;if(o){if(void 0===n)throw Error(r(407));n=n()}else n=t();var s=!Zn((Si||i).memoizedState,n);if(s&&(i.memoizedState=n,Ts=!0),i=i.queue,wo(2048,8,eo.bind(null,a,i,e),[e]),i.getSnapshot!==t||s||null!==Ni&&1&Ni.memoizedState.tag){if(a.flags|=2048,yo(9,{destroy:void 0,resource:void 0},Zi.bind(null,a,i,n,t),null),null===sc)throw Error(r(349));o||124&ki||Ji(a,t,n)}return n}function Ji(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=Ci.updateQueue)?(t={lastEffect:null,events:null,stores:null,memoCache:null},Ci.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function Zi(e,t,n,r){t.value=n,t.getSnapshot=r,to(t)&&no(e)}function eo(e,t,n){return n(function(){to(t)&&no(e)})}function to(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Zn(e,n)}catch(e){return!0}}function no(e){var t=Ir(e,2);null!==t&&Fc(t,e,2)}function ro(e){var t=qi();if("function"==typeof e){var n=e;if(e=n(),$i){ge(!0);try{n()}finally{ge(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ki,lastRenderedState:e},t}function ao(e,t,n,r){return e.baseState=n,Qi(e,Si,"function"==typeof r?r:Ki)}function io(e,t,n,a,i){if(Vo(e))throw Error(r(485));if(null!==(e=t.action)){var o={payload:i,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};null!==R.T?n(!0):o.isTransition=!1,a(o),null===(n=t.pending)?(o.next=t.pending=o,oo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function oo(e,t){var n=t.action,r=t.payload,a=e.state;if(t.isTransition){var i=R.T,o={};R.T=o;try{var s=n(a,r),l=R.S;null!==l&&l(o,s),so(e,t,s)}catch(n){co(e,t,n)}finally{R.T=i}}else try{so(e,t,i=n(a,r))}catch(n){co(e,t,n)}}function so(e,t,n){null!==n&&"object"==typeof n&&"function"==typeof n.then?n.then(function(n){lo(e,t,n)},function(n){return co(e,t,n)}):lo(e,t,n)}function lo(e,t,n){t.status="fulfilled",t.value=n,uo(t),e.state=n,null!==(t=e.pending)&&((n=t.next)===t?e.pending=null:(n=n.next,t.next=n,oo(e,n)))}function co(e,t,n){var r=e.pending;if(e.pending=null,null!==r){r=r.next;do{t.status="rejected",t.reason=n,uo(t),t=t.next}while(t!==r)}e.action=null}function uo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function mo(e,t){return t}function ho(e,t){if(ca){var n=sc.formState;if(null!==n){e:{var r=Ci;if(ca){if(la){t:{for(var a=la,i=da;8!==a.nodeType;){if(!i){a=null;break t}if(null===(a=wd(a.nextSibling))){a=null;break t}}a="F!"===(i=a.data)||"F"===i?a:null}if(a){la=wd(a.nextSibling),r="F!"===a.data;break e}}ha(r)}r=!1}r&&(t=n[0])}}return(n=qi()).memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:mo,lastRenderedState:t},n.queue=r,n=Bo.bind(null,Ci,r),r.dispatch=n,r=ro(!1),i=Wo.bind(null,Ci,!1,r.queue),a={state:t,dispatch:null,action:e,pending:null},(r=qi()).queue=a,n=io.bind(null,Ci,a,i,n),a.dispatch=n,r.memoizedState=e,[t,n,!1]}function po(e){return fo(Bi(),Si,e)}function fo(e,t,n){if(t=Qi(e,t,mo)[0],e=Gi(Ki)[0],"object"==typeof t&&null!==t&&"function"==typeof t.then)try{var r=Hi(t)}catch(e){if(e===Qa)throw Xa;throw e}else r=t;var a=(t=Bi()).queue,i=a.dispatch;return n!==t.memoizedState&&(Ci.flags|=2048,yo(9,{destroy:void 0,resource:void 0},go.bind(null,a,n),null)),[r,i,e]}function go(e,t){e.action=t}function bo(e){var t=Bi(),n=Si;if(null!==n)return fo(t,n,e);Bi(),t=t.memoizedState;var r=(n=Bi()).queue.dispatch;return n.memoizedState=e,[t,r,!1]}function yo(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},null===(t=Ci.updateQueue)&&(t={lastEffect:null,events:null,stores:null,memoCache:null},Ci.updateQueue=t),null===(n=t.lastEffect)?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function vo(){return Bi().memoizedState}function xo(e,t,n,r){var a=qi();r=void 0===r?null:r,Ci.flags|=e,a.memoizedState=yo(1|t,{destroy:void 0,resource:void 0},n,r)}function wo(e,t,n,r){var a=Bi();r=void 0===r?null:r;var i=a.memoizedState.inst;null!==Si&&null!==r&&Mi(r,Si.memoizedState.deps)?a.memoizedState=yo(t,i,n,r):(Ci.flags|=e,a.memoizedState=yo(1|t,i,n,r))}function ko(e,t){xo(8390656,8,e,t)}function Co(e,t){wo(2048,8,e,t)}function So(e,t){return wo(4,2,e,t)}function No(e,t){return wo(4,4,e,t)}function jo(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 Eo(e,t,n){n=null!=n?n.concat([e]):null,wo(4,4,jo.bind(null,t,e),n)}function $o(){}function _o(e,t){var n=Bi();t=void 0===t?null:t;var r=n.memoizedState;return null!==t&&Mi(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function zo(e,t){var n=Bi();t=void 0===t?null:t;var r=n.memoizedState;if(null!==t&&Mi(t,r[1]))return r[0];if(r=e(),$i){ge(!0);try{e()}finally{ge(!1)}}return n.memoizedState=[r,t],r}function To(e,t,n){return void 0===n||1073741824&ki?e.memoizedState=t:(e.memoizedState=n,e=Dc(),Ci.lanes|=e,bc|=e,n)}function Po(e,t,n,r){return Zn(n,t)?n:null!==bi.current?(e=To(e,n,r),Zn(e,t)||(Ts=!0),e):42&ki?(e=Dc(),Ci.lanes|=e,bc|=e,t):(Ts=!0,e.memoizedState=n)}function Ao(e,t,n,r,a){var i=D.p;D.p=0!==i&&8>i?i:8;var o,s,l,c=R.T,u={};R.T=u,Wo(e,!1,t,n);try{var d=a(),m=R.S;null!==m&&m(u,d),null!==d&&"object"==typeof d&&"function"==typeof d.then?Ho(e,t,(o=r,s=[],l={status:"pending",value:null,reason:null,then:function(e){s.push(e)}},d.then(function(){l.status="fulfilled",l.value=o;for(var e=0;e<s.length;e++)(0,s[e])(o)},function(e){for(l.status="rejected",l.reason=e,e=0;e<s.length;e++)(0,s[e])(void 0)}),l),Rc()):Ho(e,t,r,Rc())}catch(n){Ho(e,t,{then:function(){},status:"rejected",reason:n},Rc())}finally{D.p=i,R.T=c}}function Mo(){}function Io(e,t,n,a){if(5!==e.tag)throw Error(r(476));var i=Lo(e).queue;Ao(e,i,t,F,null===n?Mo:function(){return Oo(e),n(a)})}function Lo(e){var t=e.memoizedState;if(null!==t)return t;var n={};return(t={memoizedState:F,baseState:F,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ki,lastRenderedState:F},next:null}).next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ki,lastRenderedState:n},next:null},e.memoizedState=t,null!==(e=e.alternate)&&(e.memoizedState=t),t}function Oo(e){Ho(e,Lo(e).next.queue,{},Rc())}function Ro(){return za(Jd)}function Do(){return Bi().memoizedState}function Fo(){return Bi().memoizedState}function Uo(e){for(var t=e.return;null!==t;){switch(t.tag){case 24:case 3:var n=Rc(),r=ci(t,e=li(n),n);return null!==r&&(Fc(r,t,n),ui(r,t,n)),t={cache:Oa()},void(e.payload=t)}t=t.return}}function qo(e,t,n){var r=Rc();n={lane:r,revertLane:0,action:n,hasEagerState:!1,eagerState:null,next:null},Vo(e)?Ko(t,n):null!==(n=Mr(e,t,n,r))&&(Fc(n,e,r),Go(n,t,r))}function Bo(e,t,n){Ho(e,t,n,Rc())}function Ho(e,t,n,r){var a={lane:r,revertLane:0,action:n,hasEagerState:!1,eagerState:null,next:null};if(Vo(e))Ko(t,a);else{var i=e.alternate;if(0===e.lanes&&(null===i||0===i.lanes)&&null!==(i=t.lastRenderedReducer))try{var o=t.lastRenderedState,s=i(o,n);if(a.hasEagerState=!0,a.eagerState=s,Zn(s,o))return Ar(e,t,a,0),null===sc&&Pr(),!1}catch(e){}if(null!==(n=Mr(e,t,a,r)))return Fc(n,e,r),Go(n,t,r),!0}return!1}function Wo(e,t,n,a){if(a={lane:2,revertLane:Au(),action:a,hasEagerState:!1,eagerState:null,next:null},Vo(e)){if(t)throw Error(r(479))}else null!==(t=Mr(e,n,a,2))&&Fc(t,e,2)}function Vo(e){var t=e.alternate;return e===Ci||null!==t&&t===Ci}function Ko(e,t){Ei=ji=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Go(e,t,n){if(4194048&n){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,Te(e,n)}}var Qo={readContext:za,use:Wi,useCallback:Ai,useContext:Ai,useEffect:Ai,useImperativeHandle:Ai,useLayoutEffect:Ai,useInsertionEffect:Ai,useMemo:Ai,useReducer:Ai,useRef:Ai,useState:Ai,useDebugValue:Ai,useDeferredValue:Ai,useTransition:Ai,useSyncExternalStore:Ai,useId:Ai,useHostTransitionStatus:Ai,useFormState:Ai,useActionState:Ai,useOptimistic:Ai,useMemoCache:Ai,useCacheRefresh:Ai},Yo={readContext:za,use:Wi,useCallback:function(e,t){return qi().memoizedState=[e,void 0===t?null:t],e},useContext:za,useEffect:ko,useImperativeHandle:function(e,t,n){n=null!=n?n.concat([e]):null,xo(4194308,4,jo.bind(null,t,e),n)},useLayoutEffect:function(e,t){return xo(4194308,4,e,t)},useInsertionEffect:function(e,t){xo(4,2,e,t)},useMemo:function(e,t){var n=qi();t=void 0===t?null:t;var r=e();if($i){ge(!0);try{e()}finally{ge(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=qi();if(void 0!==n){var a=n(t);if($i){ge(!0);try{n(t)}finally{ge(!1)}}}else a=t;return r.memoizedState=r.baseState=a,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:a},r.queue=e,e=e.dispatch=qo.bind(null,Ci,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},qi().memoizedState=e},useState:function(e){var t=(e=ro(e)).queue,n=Bo.bind(null,Ci,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:$o,useDeferredValue:function(e,t){return To(qi(),e,t)},useTransition:function(){var e=ro(!1);return e=Ao.bind(null,Ci,e.queue,!0,!1),qi().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var a=Ci,i=qi();if(ca){if(void 0===n)throw Error(r(407));n=n()}else{if(n=t(),null===sc)throw Error(r(349));124&cc||Ji(a,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,ko(eo.bind(null,a,o,e),[e]),a.flags|=2048,yo(9,{destroy:void 0,resource:void 0},Zi.bind(null,a,o,n,t),null),n},useId:function(){var e=qi(),t=sc.identifierPrefix;if(ca){var n=na;t="«"+t+"R"+(n=(ta&~(1<<32-be(ta)-1)).toString(32)+n),0<(n=_i++)&&(t+="H"+n.toString(32)),t+="»"}else t="«"+t+"r"+(n=Pi++).toString(32)+"»";return e.memoizedState=t},useHostTransitionStatus:Ro,useFormState:ho,useActionState:ho,useOptimistic:function(e){var t=qi();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Wo.bind(null,Ci,!0,n),n.dispatch=t,[e,t]},useMemoCache:Vi,useCacheRefresh:function(){return qi().memoizedState=Uo.bind(null,Ci)}},Xo={readContext:za,use:Wi,useCallback:_o,useContext:za,useEffect:Co,useImperativeHandle:Eo,useInsertionEffect:So,useLayoutEffect:No,useMemo:zo,useReducer:Gi,useRef:vo,useState:function(){return Gi(Ki)},useDebugValue:$o,useDeferredValue:function(e,t){return Po(Bi(),Si.memoizedState,e,t)},useTransition:function(){var e=Gi(Ki)[0],t=Bi().memoizedState;return["boolean"==typeof e?e:Hi(e),t]},useSyncExternalStore:Xi,useId:Do,useHostTransitionStatus:Ro,useFormState:po,useActionState:po,useOptimistic:function(e,t){return ao(Bi(),0,e,t)},useMemoCache:Vi,useCacheRefresh:Fo},Jo={readContext:za,use:Wi,useCallback:_o,useContext:za,useEffect:Co,useImperativeHandle:Eo,useInsertionEffect:So,useLayoutEffect:No,useMemo:zo,useReducer:Yi,useRef:vo,useState:function(){return Yi(Ki)},useDebugValue:$o,useDeferredValue:function(e,t){var n=Bi();return null===Si?To(n,e,t):Po(n,Si.memoizedState,e,t)},useTransition:function(){var e=Yi(Ki)[0],t=Bi().memoizedState;return["boolean"==typeof e?e:Hi(e),t]},useSyncExternalStore:Xi,useId:Do,useHostTransitionStatus:Ro,useFormState:bo,useActionState:bo,useOptimistic:function(e,t){var n=Bi();return null!==Si?ao(n,0,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:Vi,useCacheRefresh:Fo},Zo=null,es=0;function ts(e){var t=es;return es+=1,null===Zo&&(Zo=[]),ti(Zo,e,t)}function ns(e,t){t=t.props.ref,e.ref=void 0!==t?t:null}function rs(e,t){if(t.$$typeof===d)throw Error(r(525));throw e=Object.prototype.toString.call(t),Error(r(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function as(e){return(0,e._init)(e._payload)}function is(e){function t(t,n){if(e){var r=t.deletions;null===r?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;null!==r;)t(n,r),r=r.sibling;return null}function a(e){for(var t=new Map;null!==e;)null!==e.key?t.set(e.key,e):t.set(e.index,e),e=e.sibling;return t}function i(e,t){return(e=qr(e,t)).index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?null!==(r=t.alternate)?(r=r.index)<n?(t.flags|=67108866,n):r:(t.flags|=67108866,n):(t.flags|=1048576,n)}function s(t){return e&&null===t.alternate&&(t.flags|=67108866),t}function l(e,t,n,r){return null===t||6!==t.tag?((t=Vr(n,e.mode,r)).return=e,t):((t=i(t,n)).return=e,t)}function c(e,t,n,r){var a=n.type;return a===f?d(e,t,n.props.children,r,n.key):null!==t&&(t.elementType===a||"object"==typeof a&&null!==a&&a.$$typeof===z&&as(a)===t.type)?(ns(t=i(t,n.props),n),t.return=e,t):(ns(t=Hr(n.type,n.key,n.props,null,e.mode,r),n),t.return=e,t)}function u(e,t,n,r){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=Kr(n,e.mode,r)).return=e,t):((t=i(t,n.children||[])).return=e,t)}function d(e,t,n,r,a){return null===t||7!==t.tag?((t=Wr(n,e.mode,r,a)).return=e,t):((t=i(t,n)).return=e,t)}function h(e,t,n){if("string"==typeof t&&""!==t||"number"==typeof t||"bigint"==typeof t)return(t=Vr(""+t,e.mode,n)).return=e,t;if("object"==typeof t&&null!==t){switch(t.$$typeof){case m:return ns(n=Hr(t.type,t.key,t.props,null,e.mode,n),t),n.return=e,n;case p:return(t=Kr(t,e.mode,n)).return=e,t;case z:return h(e,t=(0,t._init)(t._payload),n)}if(O(t)||M(t))return(t=Wr(t,e.mode,n,null)).return=e,t;if("function"==typeof t.then)return h(e,ts(t),n);if(t.$$typeof===N)return h(e,Ta(e,t),n);rs(e,t)}return null}function g(e,t,n,r){var a=null!==t?t.key:null;if("string"==typeof n&&""!==n||"number"==typeof n||"bigint"==typeof n)return null!==a?null:l(e,t,""+n,r);if("object"==typeof n&&null!==n){switch(n.$$typeof){case m:return n.key===a?c(e,t,n,r):null;case p:return n.key===a?u(e,t,n,r):null;case z:return g(e,t,n=(a=n._init)(n._payload),r)}if(O(n)||M(n))return null!==a?null:d(e,t,n,r,null);if("function"==typeof n.then)return g(e,t,ts(n),r);if(n.$$typeof===N)return g(e,t,Ta(e,n),r);rs(e,n)}return null}function b(e,t,n,r,a){if("string"==typeof r&&""!==r||"number"==typeof r||"bigint"==typeof r)return l(t,e=e.get(n)||null,""+r,a);if("object"==typeof r&&null!==r){switch(r.$$typeof){case m:return c(t,e=e.get(null===r.key?n:r.key)||null,r,a);case p:return u(t,e=e.get(null===r.key?n:r.key)||null,r,a);case z:return b(e,t,n,r=(0,r._init)(r._payload),a)}if(O(r)||M(r))return d(t,e=e.get(n)||null,r,a,null);if("function"==typeof r.then)return b(e,t,n,ts(r),a);if(r.$$typeof===N)return b(e,t,n,Ta(t,r),a);rs(t,r)}return null}function y(l,c,u,d){if("object"==typeof u&&null!==u&&u.type===f&&null===u.key&&(u=u.props.children),"object"==typeof u&&null!==u){switch(u.$$typeof){case m:e:{for(var v=u.key;null!==c;){if(c.key===v){if((v=u.type)===f){if(7===c.tag){n(l,c.sibling),(d=i(c,u.props.children)).return=l,l=d;break e}}else if(c.elementType===v||"object"==typeof v&&null!==v&&v.$$typeof===z&&as(v)===c.type){n(l,c.sibling),ns(d=i(c,u.props),u),d.return=l,l=d;break e}n(l,c);break}t(l,c),c=c.sibling}u.type===f?((d=Wr(u.props.children,l.mode,d,u.key)).return=l,l=d):(ns(d=Hr(u.type,u.key,u.props,null,l.mode,d),u),d.return=l,l=d)}return s(l);case 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=Kr(u,l.mode,d)).return=l,l=d}return s(l);case z:return y(l,c,u=(v=u._init)(u._payload),d)}if(O(u))return function(r,i,s,l){for(var c=null,u=null,d=i,m=i=0,p=null;null!==d&&m<s.length;m++){d.index>m?(p=d,d=null):p=d.sibling;var f=g(r,d,s[m],l);if(null===f){null===d&&(d=p);break}e&&d&&null===f.alternate&&t(r,d),i=o(f,i,m),null===u?c=f:u.sibling=f,u=f,d=p}if(m===s.length)return n(r,d),ca&&ra(r,m),c;if(null===d){for(;m<s.length;m++)null!==(d=h(r,s[m],l))&&(i=o(d,i,m),null===u?c=d:u.sibling=d,u=d);return ca&&ra(r,m),c}for(d=a(d);m<s.length;m++)null!==(p=b(d,r,m,s[m],l))&&(e&&null!==p.alternate&&d.delete(null===p.key?m:p.key),i=o(p,i,m),null===u?c=p:u.sibling=p,u=p);return e&&d.forEach(function(e){return t(r,e)}),ca&&ra(r,m),c}(l,c,u,d);if(M(u)){if("function"!=typeof(v=M(u)))throw Error(r(150));return function(i,s,l,c){if(null==l)throw Error(r(151));for(var u=null,d=null,m=s,p=s=0,f=null,y=l.next();null!==m&&!y.done;p++,y=l.next()){m.index>p?(f=m,m=null):f=m.sibling;var v=g(i,m,y.value,c);if(null===v){null===m&&(m=f);break}e&&m&&null===v.alternate&&t(i,m),s=o(v,s,p),null===d?u=v:d.sibling=v,d=v,m=f}if(y.done)return n(i,m),ca&&ra(i,p),u;if(null===m){for(;!y.done;p++,y=l.next())null!==(y=h(i,y.value,c))&&(s=o(y,s,p),null===d?u=y:d.sibling=y,d=y);return ca&&ra(i,p),u}for(m=a(m);!y.done;p++,y=l.next())null!==(y=b(m,i,p,y.value,c))&&(e&&null!==y.alternate&&m.delete(null===y.key?p:y.key),s=o(y,s,p),null===d?u=y:d.sibling=y,d=y);return e&&m.forEach(function(e){return t(i,e)}),ca&&ra(i,p),u}(l,c,u=v.call(u),d)}if("function"==typeof u.then)return y(l,c,ts(u),d);if(u.$$typeof===N)return y(l,c,Ta(l,u),d);rs(l,u)}return"string"==typeof u&&""!==u||"number"==typeof u||"bigint"==typeof u?(u=""+u,null!==c&&6===c.tag?(n(l,c.sibling),(d=i(c,u)).return=l,l=d):(n(l,c),(d=Vr(u,l.mode,d)).return=l,l=d),s(l)):n(l,c)}return function(e,t,n,r){try{es=0;var a=y(e,t,n,r);return Zo=null,a}catch(t){if(t===Qa||t===Xa)throw t;var i=Fr(29,t,null,e.mode);return i.lanes=r,i.return=e,i}}}var os=is(!0),ss=is(!1),ls=B(null),cs=null;function us(e){var t=e.alternate;W(ps,1&ps.current),W(ls,e),null===cs&&(null===t||null!==bi.current||null!==t.memoizedState)&&(cs=e)}function ds(e){if(22===e.tag){if(W(ps,ps.current),W(ls,e),null===cs){var t=e.alternate;null!==t&&null!==t.memoizedState&&(cs=e)}}else ms()}function ms(){W(ps,ps.current),W(ls,ls.current)}function hs(e){H(ls),cs===e&&(cs=null),H(ps)}var ps=B(0);function fs(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||"$?"===n.data||xd(n)))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(128&t.flags)return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}function gs(e,t,n,r){n=null==(n=n(r,t=e.memoizedState))?t:u({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}var bs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Rc(),a=li(r);a.payload=t,null!=n&&(a.callback=n),null!==(t=ci(e,a,r))&&(Fc(t,e,r),ui(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Rc(),a=li(r);a.tag=1,a.payload=t,null!=n&&(a.callback=n),null!==(t=ci(e,a,r))&&(Fc(t,e,r),ui(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Rc(),r=li(n);r.tag=2,null!=t&&(r.callback=t),null!==(t=ci(e,r,n))&&(Fc(t,e,n),ui(t,e,n))}};function ys(e,t,n,r,a,i,o){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,i,o):!(t.prototype&&t.prototype.isPureReactComponent&&er(n,r)&&er(a,i))}function vs(e,t,n,r){e=t.state,"function"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,r),"function"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&bs.enqueueReplaceState(t,t.state,null)}function xs(e,t){var n=t;if("ref"in t)for(var r in n={},t)"ref"!==r&&(n[r]=t[r]);if(e=e.defaultProps)for(var a in n===t&&(n=u({},n)),e)void 0===n[a]&&(n[a]=e[a]);return n}var ws="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)};function ks(e){ws(e)}function Cs(e){console.error(e)}function Ss(e){ws(e)}function Ns(e,t){try{(0,e.onUncaughtError)(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function js(e,t,n){try{(0,e.onCaughtError)(n.value,{componentStack:n.stack,errorBoundary:1===t.tag?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Es(e,t,n){return(n=li(n)).tag=3,n.payload={element:null},n.callback=function(){Ns(e,t)},n}function $s(e){return(e=li(e)).tag=3,e}function _s(e,t,n,r){var a=n.type.getDerivedStateFromError;if("function"==typeof a){var i=r.value;e.payload=function(){return a(i)},e.callback=function(){js(t,n,r)}}var o=n.stateNode;null!==o&&"function"==typeof o.componentDidCatch&&(e.callback=function(){js(t,n,r),"function"!=typeof a&&(null===$c?$c=new Set([this]):$c.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:null!==e?e:""})})}var zs=Error(r(461)),Ts=!1;function Ps(e,t,n,r){t.child=null===e?ss(t,null,n,r):os(t,e.child,n,r)}function As(e,t,n,r,a){n=n.render;var i=t.ref;if("ref"in r){var o={};for(var s in r)"ref"!==s&&(o[s]=r[s])}else o=r;return _a(t),r=Ii(e,t,n,o,i,a),s=Di(),null===e||Ts?(ca&&s&&ia(t),t.flags|=1,Ps(e,t,r,a),t.child):(Fi(e,t,a),Zs(e,t,a))}function Ms(e,t,n,r,a){if(null===e){var i=n.type;return"function"!=typeof i||Ur(i)||void 0!==i.defaultProps||null!==n.compare?((e=Hr(n.type,null,r,t,t.mode,a)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=i,Is(e,t,i,r,a))}if(i=e.child,!el(e,a)){var o=i.memoizedProps;if((n=null!==(n=n.compare)?n:er)(o,r)&&e.ref===t.ref)return Zs(e,t,a)}return t.flags|=1,(e=qr(i,r)).ref=t.ref,e.return=t,t.child=e}function Is(e,t,n,r,a){if(null!==e){var i=e.memoizedProps;if(er(i,r)&&e.ref===t.ref){if(Ts=!1,t.pendingProps=r=i,!el(e,a))return t.lanes=e.lanes,Zs(e,t,a);131072&e.flags&&(Ts=!0)}}return Ds(e,t,n,r,a)}function Ls(e,t,n){var r=t.pendingProps,a=r.children,i=null!==e?e.memoizedState:null;if("hidden"===r.mode){if(128&t.flags){if(r=null!==i?i.baseLanes|n:n,null!==e){for(a=t.child=e.child,i=0;null!==a;)i=i|a.lanes|a.childLanes,a=a.sibling;t.childLanes=i&~r}else t.childLanes=0,t.child=null;return Os(e,t,r,n)}if(!(536870912&n))return t.lanes=t.childLanes=536870912,Os(e,t,null!==i?i.baseLanes|n:n,n);t.memoizedState={baseLanes:0,cachePool:null},null!==e&&Ka(0,null!==i?i.cachePool:null),null!==i?vi(t,i):xi(),ds(t)}else null!==i?(Ka(0,i.cachePool),vi(t,i),ms(),t.memoizedState=null):(null!==e&&Ka(0,null),xi(),ms());return Ps(e,t,a,n),t.child}function Os(e,t,n,r){var a=Va();return a=null===a?null:{parent:La._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},null!==e&&Ka(0,null),xi(),ds(t),null!==e&&Ea(e,t,r,!0),null}function Rs(e,t){var n=t.ref;if(null===n)null!==e&&null!==e.ref&&(t.flags|=4194816);else{if("function"!=typeof n&&"object"!=typeof n)throw Error(r(284));null!==e&&e.ref===n||(t.flags|=4194816)}}function Ds(e,t,n,r,a){return _a(t),n=Ii(e,t,n,r,void 0,a),r=Di(),null===e||Ts?(ca&&r&&ia(t),t.flags|=1,Ps(e,t,n,a),t.child):(Fi(e,t,a),Zs(e,t,a))}function Fs(e,t,n,r,a,i){return _a(t),t.updateQueue=null,n=Oi(t,r,n,a),Li(e),r=Di(),null===e||Ts?(ca&&r&&ia(t),t.flags|=1,Ps(e,t,n,i),t.child):(Fi(e,t,i),Zs(e,t,i))}function Us(e,t,n,r,a){if(_a(t),null===t.stateNode){var i=Rr,o=n.contextType;"object"==typeof o&&null!==o&&(i=za(o)),i=new n(r,i),t.memoizedState=null!==i.state&&void 0!==i.state?i.state:null,i.updater=bs,t.stateNode=i,i._reactInternals=t,(i=t.stateNode).props=r,i.state=t.memoizedState,i.refs={},oi(t),o=n.contextType,i.context="object"==typeof o&&null!==o?za(o):Rr,i.state=t.memoizedState,"function"==typeof(o=n.getDerivedStateFromProps)&&(gs(t,n,o,r),i.state=t.memoizedState),"function"==typeof n.getDerivedStateFromProps||"function"==typeof i.getSnapshotBeforeUpdate||"function"!=typeof i.UNSAFE_componentWillMount&&"function"!=typeof i.componentWillMount||(o=i.state,"function"==typeof i.componentWillMount&&i.componentWillMount(),"function"==typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount(),o!==i.state&&bs.enqueueReplaceState(i,i.state,null),pi(t,r,i,a),hi(),i.state=t.memoizedState),"function"==typeof i.componentDidMount&&(t.flags|=4194308),r=!0}else if(null===e){i=t.stateNode;var s=t.memoizedProps,l=xs(n,s);i.props=l;var c=i.context,u=n.contextType;o=Rr,"object"==typeof u&&null!==u&&(o=za(u));var d=n.getDerivedStateFromProps;u="function"==typeof d||"function"==typeof i.getSnapshotBeforeUpdate,s=t.pendingProps!==s,u||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(s||c!==o)&&vs(t,i,r,o),ii=!1;var m=t.memoizedState;i.state=m,pi(t,r,i,a),hi(),c=t.memoizedState,s||m!==c||ii?("function"==typeof d&&(gs(t,n,d,r),c=t.memoizedState),(l=ii||ys(t,n,l,r,m,c,o))?(u||"function"!=typeof i.UNSAFE_componentWillMount&&"function"!=typeof i.componentWillMount||("function"==typeof i.componentWillMount&&i.componentWillMount(),"function"==typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount()),"function"==typeof i.componentDidMount&&(t.flags|=4194308)):("function"==typeof i.componentDidMount&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),i.props=r,i.state=c,i.context=o,r=l):("function"==typeof i.componentDidMount&&(t.flags|=4194308),r=!1)}else{i=t.stateNode,si(e,t),u=xs(n,o=t.memoizedProps),i.props=u,d=t.pendingProps,m=i.context,c=n.contextType,l=Rr,"object"==typeof c&&null!==c&&(l=za(c)),(c="function"==typeof(s=n.getDerivedStateFromProps)||"function"==typeof i.getSnapshotBeforeUpdate)||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(o!==d||m!==l)&&vs(t,i,r,l),ii=!1,m=t.memoizedState,i.state=m,pi(t,r,i,a),hi();var h=t.memoizedState;o!==d||m!==h||ii||null!==e&&null!==e.dependencies&&$a(e.dependencies)?("function"==typeof s&&(gs(t,n,s,r),h=t.memoizedState),(u=ii||ys(t,n,u,r,m,h,l)||null!==e&&null!==e.dependencies&&$a(e.dependencies))?(c||"function"!=typeof i.UNSAFE_componentWillUpdate&&"function"!=typeof i.componentWillUpdate||("function"==typeof i.componentWillUpdate&&i.componentWillUpdate(r,h,l),"function"==typeof i.UNSAFE_componentWillUpdate&&i.UNSAFE_componentWillUpdate(r,h,l)),"function"==typeof i.componentDidUpdate&&(t.flags|=4),"function"==typeof i.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!=typeof i.componentDidUpdate||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),"function"!=typeof i.getSnapshotBeforeUpdate||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=h),i.props=r,i.state=h,i.context=l,r=u):("function"!=typeof i.componentDidUpdate||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),"function"!=typeof i.getSnapshotBeforeUpdate||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),r=!1)}return i=r,Rs(e,t),r=!!(128&t.flags),i||r?(i=t.stateNode,n=r&&"function"!=typeof n.getDerivedStateFromError?null:i.render(),t.flags|=1,null!==e&&r?(t.child=os(t,e.child,null,a),t.child=os(t,null,n,a)):Ps(e,t,n,a),t.memoizedState=i.state,e=t.child):e=Zs(e,t,a),e}function qs(e,t,n,r){return ba(),t.flags|=256,Ps(e,t,n,r),t.child}var Bs={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Hs(e){return{baseLanes:e,cachePool:Ga()}}function Ws(e,t,n){return e=null!==e?e.childLanes&~n:0,t&&(e|=xc),e}function Vs(e,t,n){var a,i=t.pendingProps,o=!1,s=!!(128&t.flags);if((a=s)||(a=(null===e||null!==e.memoizedState)&&!!(2&ps.current)),a&&(o=!0,t.flags&=-129),a=!!(32&t.flags),t.flags&=-33,null===e){if(ca){if(o?us(t):ms(),ca){var l,c=la;if(l=c){e:{for(l=c,c=da;8!==l.nodeType;){if(!c){c=null;break e}if(null===(l=wd(l.nextSibling))){c=null;break e}}c=l}null!==c?(t.memoizedState={dehydrated:c,treeContext:null!==ea?{id:ta,overflow:na}:null,retryLane:536870912,hydrationErrors:null},(l=Fr(18,null,null,0)).stateNode=c,l.return=t,t.child=l,sa=t,la=null,l=!0):l=!1}l||ha(t)}if(null!==(c=t.memoizedState)&&null!==(c=c.dehydrated))return xd(c)?t.lanes=32:t.lanes=536870912,null;hs(t)}return c=i.children,i=i.fallback,o?(ms(),c=Gs({mode:"hidden",children:c},o=t.mode),i=Wr(i,o,n,null),c.return=t,i.return=t,c.sibling=i,t.child=c,(o=t.child).memoizedState=Hs(n),o.childLanes=Ws(e,a,n),t.memoizedState=Bs,i):(us(t),Ks(t,c))}if(null!==(l=e.memoizedState)&&null!==(c=l.dehydrated)){if(s)256&t.flags?(us(t),t.flags&=-257,t=Qs(e,t,n)):null!==t.memoizedState?(ms(),t.child=e.child,t.flags|=128,t=null):(ms(),o=i.fallback,c=t.mode,i=Gs({mode:"visible",children:i.children},c),(o=Wr(o,c,n,null)).flags|=2,i.return=t,o.return=t,i.sibling=o,t.child=i,os(t,e.child,null,n),(i=t.child).memoizedState=Hs(n),i.childLanes=Ws(e,a,n),t.memoizedState=Bs,t=o);else if(us(t),xd(c)){if(a=c.nextSibling&&c.nextSibling.dataset)var u=a.dgst;a=u,(i=Error(r(419))).stack="",i.digest=a,va({value:i,source:null,stack:null}),t=Qs(e,t,n)}else if(Ts||Ea(e,t,n,!1),a=0!==(n&e.childLanes),Ts||a){if(null!==(a=sc)&&0!==(i=0!==((i=42&(i=n&-n)?1:Pe(i))&(a.suspendedLanes|n))?0:i)&&i!==l.retryLane)throw l.retryLane=i,Ir(e,i),Fc(a,e,i),zs;"$?"===c.data||Xc(),t=Qs(e,t,n)}else"$?"===c.data?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,la=wd(c.nextSibling),sa=t,ca=!0,ua=null,da=!1,null!==e&&(Jr[Zr++]=ta,Jr[Zr++]=na,Jr[Zr++]=ea,ta=e.id,na=e.overflow,ea=t),(t=Ks(t,i.children)).flags|=4096);return t}return o?(ms(),o=i.fallback,c=t.mode,u=(l=e.child).sibling,(i=qr(l,{mode:"hidden",children:i.children})).subtreeFlags=65011712&l.subtreeFlags,null!==u?o=qr(u,o):(o=Wr(o,c,n,null)).flags|=2,o.return=t,i.return=t,i.sibling=o,t.child=i,i=o,o=t.child,null===(c=e.child.memoizedState)?c=Hs(n):(null!==(l=c.cachePool)?(u=La._currentValue,l=l.parent!==u?{parent:u,pool:u}:l):l=Ga(),c={baseLanes:c.baseLanes|n,cachePool:l}),o.memoizedState=c,o.childLanes=Ws(e,a,n),t.memoizedState=Bs,i):(us(t),e=(n=e.child).sibling,(n=qr(n,{mode:"visible",children:i.children})).return=t,n.sibling=null,null!==e&&(null===(a=t.deletions)?(t.deletions=[e],t.flags|=16):a.push(e)),t.child=n,t.memoizedState=null,n)}function Ks(e,t){return(t=Gs({mode:"visible",children:t},e.mode)).return=e,e.child=t}function Gs(e,t){return(e=Fr(22,e,null,t)).lanes=0,e.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null},e}function Qs(e,t,n){return os(t,e.child,null,n),(e=Ks(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function Ys(e,t,n){e.lanes|=t;var r=e.alternate;null!==r&&(r.lanes|=t),Na(e.return,t,n)}function Xs(e,t,n,r,a){var i=e.memoizedState;null===i?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:a}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=a)}function Js(e,t,n){var r=t.pendingProps,a=r.revealOrder,i=r.tail;if(Ps(e,t,r.children,n),2&(r=ps.current))r=1&r|2,t.flags|=128;else{if(null!==e&&128&e.flags)e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&Ys(e,n,t);else if(19===e.tag)Ys(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}switch(W(ps,r),a){case"forwards":for(n=t.child,a=null;null!==n;)null!==(e=n.alternate)&&null===fs(e)&&(a=n),n=n.sibling;null===(n=a)?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),Xs(t,!1,a,n,i);break;case"backwards":for(n=null,a=t.child,t.child=null;null!==a;){if(null!==(e=a.alternate)&&null===fs(e)){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}Xs(t,!0,n,null,i);break;case"together":Xs(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Zs(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),bc|=t.lanes,0===(n&t.childLanes)){if(null===e)return null;if(Ea(e,t,n,!1),0===(n&t.childLanes))return null}if(null!==e&&t.child!==e.child)throw Error(r(153));if(null!==t.child){for(n=qr(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=qr(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function el(e,t){return 0!==(e.lanes&t)||!(null===(e=e.dependencies)||!$a(e))}function tl(e,t,n){if(null!==e)if(e.memoizedProps!==t.pendingProps)Ts=!0;else{if(!(el(e,n)||128&t.flags))return Ts=!1,function(e,t,n){switch(t.tag){case 3:Y(t,t.stateNode.containerInfo),Ca(0,La,e.memoizedState.cache),ba();break;case 27:case 5:J(t);break;case 4:Y(t,t.stateNode.containerInfo);break;case 10:Ca(0,t.type,t.memoizedProps.value);break;case 13:var r=t.memoizedState;if(null!==r)return null!==r.dehydrated?(us(t),t.flags|=128,null):0!==(n&t.child.childLanes)?Vs(e,t,n):(us(t),null!==(e=Zs(e,t,n))?e.sibling:null);us(t);break;case 19:var a=!!(128&e.flags);if((r=0!==(n&t.childLanes))||(Ea(e,t,n,!1),r=0!==(n&t.childLanes)),a){if(r)return Js(e,t,n);t.flags|=128}if(null!==(a=t.memoizedState)&&(a.rendering=null,a.tail=null,a.lastEffect=null),W(ps,ps.current),r)break;return null;case 22:case 23:return t.lanes=0,Ls(e,t,n);case 24:Ca(0,La,e.memoizedState.cache)}return Zs(e,t,n)}(e,t,n);Ts=!!(131072&e.flags)}else Ts=!1,ca&&1048576&t.flags&&aa(t,Xr,t.index);switch(t.lanes=0,t.tag){case 16:e:{e=t.pendingProps;var a=t.elementType,i=a._init;if(a=i(a._payload),t.type=a,"function"!=typeof a){if(null!=a){if((i=a.$$typeof)===j){t.tag=11,t=As(null,t,a,e,n);break e}if(i===_){t.tag=14,t=Ms(null,t,a,e,n);break e}}throw t=L(a)||a,Error(r(306,t,""))}Ur(a)?(e=xs(a,e),t.tag=1,t=Us(null,t,a,e,n)):(t.tag=0,t=Ds(null,t,a,e,n))}return t;case 0:return Ds(e,t,t.type,t.pendingProps,n);case 1:return Us(e,t,a=t.type,i=xs(a,t.pendingProps),n);case 3:e:{if(Y(t,t.stateNode.containerInfo),null===e)throw Error(r(387));a=t.pendingProps;var o=t.memoizedState;i=o.element,si(e,t),pi(t,a,null,n);var s=t.memoizedState;if(a=s.cache,Ca(0,La,a),a!==o.cache&&ja(t,[La],n,!0),hi(),a=s.element,o.isDehydrated){if(o={element:a,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,256&t.flags){t=qs(e,t,a,n);break e}if(a!==i){va(i=$r(Error(r(424)),t)),t=qs(e,t,a,n);break e}for(e=9===(e=t.stateNode.containerInfo).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,la=wd(e.firstChild),sa=t,ca=!0,ua=null,da=!0,n=ss(t,null,a,n),t.child=n;n;)n.flags=-3&n.flags|4096,n=n.sibling}else{if(ba(),a===i){t=Zs(e,t,n);break e}Ps(e,t,a,n)}t=t.child}return t;case 26:return Rs(e,t),null===e?(n=Pd(t.type,null,t.pendingProps,null))?t.memoizedState=n:ca||(n=t.type,e=t.pendingProps,(a=sd(G.current).createElement(n))[Le]=t,a[Oe]=e,ad(a,n,e),Qe(a),t.stateNode=a):t.memoizedState=Pd(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return J(t),null===e&&ca&&(a=t.stateNode=Sd(t.type,t.pendingProps,G.current),sa=t,da=!0,i=la,bd(t.type)?(kd=i,la=wd(a.firstChild)):la=i),Ps(e,t,t.pendingProps.children,n),Rs(e,t),null===e&&(t.flags|=4194304),t.child;case 5:return null===e&&ca&&((i=a=la)&&(null!==(a=function(e,t,n,r){for(;1===e.nodeType;){var a=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&("INPUT"!==e.nodeName||"hidden"!==e.type))break}else if(r){if(!e[Be])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if("stylesheet"===(i=e.getAttribute("rel"))&&e.hasAttribute("data-precedence"))break;if(i!==a.rel||e.getAttribute("href")!==(null==a.href||""===a.href?null:a.href)||e.getAttribute("crossorigin")!==(null==a.crossOrigin?null:a.crossOrigin)||e.getAttribute("title")!==(null==a.title?null:a.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(((i=e.getAttribute("src"))!==(null==a.src?null:a.src)||e.getAttribute("type")!==(null==a.type?null:a.type)||e.getAttribute("crossorigin")!==(null==a.crossOrigin?null:a.crossOrigin))&&i&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else{if("input"!==t||"hidden"!==e.type)return e;var i=null==a.name?null:""+a.name;if("hidden"===a.type&&e.getAttribute("name")===i)return e}if(null===(e=wd(e.nextSibling)))break}return null}(a,t.type,t.pendingProps,da))?(t.stateNode=a,sa=t,la=wd(a.firstChild),da=!1,i=!0):i=!1),i||ha(t)),J(t),i=t.type,o=t.pendingProps,s=null!==e?e.memoizedProps:null,a=o.children,ud(i,o)?a=null:null!==s&&ud(i,s)&&(t.flags|=32),null!==t.memoizedState&&(i=Ii(e,t,Ri,null,null,n),Jd._currentValue=i),Rs(e,t),Ps(e,t,a,n),t.child;case 6:return null===e&&ca&&((e=n=la)&&(null!==(n=function(e,t,n){if(""===t)return null;for(;3!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!n)return null;if(null===(e=wd(e.nextSibling)))return null}return e}(n,t.pendingProps,da))?(t.stateNode=n,sa=t,la=null,e=!0):e=!1),e||ha(t)),null;case 13:return Vs(e,t,n);case 4:return Y(t,t.stateNode.containerInfo),a=t.pendingProps,null===e?t.child=os(t,null,a,n):Ps(e,t,a,n),t.child;case 11:return As(e,t,t.type,t.pendingProps,n);case 7:return Ps(e,t,t.pendingProps,n),t.child;case 8:case 12:return Ps(e,t,t.pendingProps.children,n),t.child;case 10:return a=t.pendingProps,Ca(0,t.type,a.value),Ps(e,t,a.children,n),t.child;case 9:return i=t.type._context,a=t.pendingProps.children,_a(t),a=a(i=za(i)),t.flags|=1,Ps(e,t,a,n),t.child;case 14:return Ms(e,t,t.type,t.pendingProps,n);case 15:return Is(e,t,t.type,t.pendingProps,n);case 19:return Js(e,t,n);case 31:return a=t.pendingProps,n=t.mode,a={mode:a.mode,children:a.children},null===e?((n=Gs(a,n)).ref=t.ref,t.child=n,n.return=t,t=n):((n=qr(e.child,a)).ref=t.ref,t.child=n,n.return=t,t=n),t;case 22:return Ls(e,t,n);case 24:return _a(t),a=za(La),null===e?(null===(i=Va())&&(i=sc,o=Oa(),i.pooledCache=o,o.refCount++,null!==o&&(i.pooledCacheLanes|=n),i=o),t.memoizedState={parent:a,cache:i},oi(t),Ca(0,La,i)):(0!==(e.lanes&n)&&(si(e,t),pi(t,null,null,n),hi()),i=e.memoizedState,o=t.memoizedState,i.parent!==a?(i={parent:a,cache:a},t.memoizedState=i,0===t.lanes&&(t.memoizedState=t.updateQueue.baseState=i),Ca(0,La,a)):(a=o.cache,Ca(0,La,a),a!==i.cache&&ja(t,[La],n,!0))),Ps(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function nl(e){e.flags|=4}function rl(e,t){if("stylesheet"!==t.type||4&t.state.loading)e.flags&=-16777217;else if(e.flags|=16777216,!Wd(t)){if(null!==(t=ls.current)&&((4194048&cc)===cc?null!==cs:(62914560&cc)!==cc&&!(536870912&cc)||t!==cs))throw ni=Ja,Ya;e.flags|=8192}}function al(e,t){null!==t&&(e.flags|=4),16384&e.flags&&(t=22!==e.tag?Ee():536870912,e.lanes|=t,wc|=t)}function il(e,t){if(!ca)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;null!==n;)null!==n.alternate&&(r=n),n=n.sibling;null===r?t||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function ol(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,r=0;if(t)for(var a=e.child;null!==a;)n|=a.lanes|a.childLanes,r|=65011712&a.subtreeFlags,r|=65011712&a.flags,a.return=e,a=a.sibling;else for(a=e.child;null!==a;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags,r|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function sl(e,t,n){var a=t.pendingProps;switch(oa(t),t.tag){case 31:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 1:return ol(t),null;case 3:return n=t.stateNode,a=null,null!==e&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Sa(La),X(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),null!==e&&null!==e.child||(ga(t)?nl(t):null===e||e.memoizedState.isDehydrated&&!(256&t.flags)||(t.flags|=1024,ya())),ol(t),null;case 26:return n=t.memoizedState,null===e?(nl(t),null!==n?(ol(t),rl(t,n)):(ol(t),t.flags&=-16777217)):n?n!==e.memoizedState?(nl(t),ol(t),rl(t,n)):(ol(t),t.flags&=-16777217):(e.memoizedProps!==a&&nl(t),ol(t),t.flags&=-16777217),null;case 27:Z(t),n=G.current;var i=t.type;if(null!==e&&null!=t.stateNode)e.memoizedProps!==a&&nl(t);else{if(!a){if(null===t.stateNode)throw Error(r(166));return ol(t),null}e=V.current,ga(t)?pa(t):(e=Sd(i,a,n),t.stateNode=e,nl(t))}return ol(t),null;case 5:if(Z(t),n=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==a&&nl(t);else{if(!a){if(null===t.stateNode)throw Error(r(166));return ol(t),null}if(e=V.current,ga(t))pa(t);else{switch(i=sd(G.current),e){case 1:e=i.createElementNS("http://www.w3.org/2000/svg",n);break;case 2:e=i.createElementNS("http://www.w3.org/1998/Math/MathML",n);break;default:switch(n){case"svg":e=i.createElementNS("http://www.w3.org/2000/svg",n);break;case"math":e=i.createElementNS("http://www.w3.org/1998/Math/MathML",n);break;case"script":(e=i.createElement("div")).innerHTML="<script><\/script>",e=e.removeChild(e.firstChild);break;case"select":e="string"==typeof a.is?i.createElement("select",{is:a.is}):i.createElement("select"),a.multiple?e.multiple=!0:a.size&&(e.size=a.size);break;default:e="string"==typeof a.is?i.createElement(n,{is:a.is}):i.createElement(n)}}e[Le]=t,e[Oe]=a;e:for(i=t.child;null!==i;){if(5===i.tag||6===i.tag)e.appendChild(i.stateNode);else if(4!==i.tag&&27!==i.tag&&null!==i.child){i.child.return=i,i=i.child;continue}if(i===t)break e;for(;null===i.sibling;){if(null===i.return||i.return===t)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}t.stateNode=e;e:switch(ad(e,n,a),n){case"button":case"input":case"select":case"textarea":e=!!a.autoFocus;break e;case"img":e=!0;break e;default:e=!1}e&&nl(t)}}return ol(t),t.flags&=-16777217,null;case 6:if(e&&null!=t.stateNode)e.memoizedProps!==a&&nl(t);else{if("string"!=typeof a&&null===t.stateNode)throw Error(r(166));if(e=G.current,ga(t)){if(e=t.stateNode,n=t.memoizedProps,a=null,null!==(i=sa))switch(i.tag){case 27:case 5:a=i.memoizedProps}e[Le]=t,(e=!!(e.nodeValue===n||null!==a&&!0===a.suppressHydrationWarning||ed(e.nodeValue,n)))||ha(t)}else(e=sd(e).createTextNode(a))[Le]=t,t.stateNode=e}return ol(t),null;case 13:if(a=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(i=ga(t),null!==a&&null!==a.dehydrated){if(null===e){if(!i)throw Error(r(318));if(!(i=null!==(i=t.memoizedState)?i.dehydrated:null))throw Error(r(317));i[Le]=t}else ba(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;ol(t),i=!1}else i=ya(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return 256&t.flags?(hs(t),t):(hs(t),null)}if(hs(t),128&t.flags)return t.lanes=n,t;if(n=null!==a,e=null!==e&&null!==e.memoizedState,n){i=null,null!==(a=t.child).alternate&&null!==a.alternate.memoizedState&&null!==a.alternate.memoizedState.cachePool&&(i=a.alternate.memoizedState.cachePool.pool);var o=null;null!==a.memoizedState&&null!==a.memoizedState.cachePool&&(o=a.memoizedState.cachePool.pool),o!==i&&(a.flags|=2048)}return n!==e&&n&&(t.child.flags|=8192),al(t,t.updateQueue),ol(t),null;case 4:return X(),null===e&&Hu(t.stateNode.containerInfo),ol(t),null;case 10:return Sa(t.type),ol(t),null;case 19:if(H(ps),null===(i=t.memoizedState))return ol(t),null;if(a=!!(128&t.flags),null===(o=i.rendering))if(a)il(i,!1);else{if(0!==gc||null!==e&&128&e.flags)for(e=t.child;null!==e;){if(null!==(o=fs(e))){for(t.flags|=128,il(i,!1),e=o.updateQueue,t.updateQueue=e,al(t,e),t.subtreeFlags=0,e=n,n=t.child;null!==n;)Br(n,e),n=n.sibling;return W(ps,1&ps.current|2),t.child}e=e.sibling}null!==i.tail&&ie()>jc&&(t.flags|=128,a=!0,il(i,!1),t.lanes=4194304)}else{if(!a)if(null!==(e=fs(o))){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,al(t,e),il(i,!0),null===i.tail&&"hidden"===i.tailMode&&!o.alternate&&!ca)return ol(t),null}else 2*ie()-i.renderingStartTime>jc&&536870912!==n&&(t.flags|=128,a=!0,il(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(null!==(e=i.last)?e.sibling=o:t.child=o,i.last=o)}return null!==i.tail?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=ie(),t.sibling=null,e=ps.current,W(ps,a?1&e|2:1&e),t):(ol(t),null);case 22:case 23:return hs(t),wi(),a=null!==t.memoizedState,null!==e?null!==e.memoizedState!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?!!(536870912&n)&&!(128&t.flags)&&(ol(t),6&t.subtreeFlags&&(t.flags|=8192)):ol(t),null!==(n=t.updateQueue)&&al(t,n.retryQueue),n=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),a=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(a=t.memoizedState.cachePool.pool),a!==n&&(t.flags|=2048),null!==e&&H(Wa),null;case 24:return n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Sa(La),ol(t),null;case 25:case 30:return null}throw Error(r(156,t.tag))}function ll(e,t){switch(oa(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return Sa(La),X(),65536&(e=t.flags)&&!(128&e)?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return Z(t),null;case 13:if(hs(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(r(340));ba()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return H(ps),null;case 4:return X(),null;case 10:return Sa(t.type),null;case 22:case 23:return hs(t),wi(),null!==e&&H(Wa),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return Sa(La),null;default:return null}}function cl(e,t){switch(oa(t),t.tag){case 3:Sa(La),X();break;case 26:case 27:case 5:Z(t);break;case 4:X();break;case 13:hs(t);break;case 19:H(ps);break;case 10:Sa(t.type);break;case 22:case 23:hs(t),wi(),null!==e&&H(Wa);break;case 24:Sa(La)}}function ul(e,t){try{var n=t.updateQueue,r=null!==n?n.lastEffect:null;if(null!==r){var a=r.next;n=a;do{if((n.tag&e)===e){r=void 0;var i=n.create,o=n.inst;r=i(),o.destroy=r}n=n.next}while(n!==a)}}catch(e){pu(t,t.return,e)}}function dl(e,t,n){try{var r=t.updateQueue,a=null!==r?r.lastEffect:null;if(null!==a){var i=a.next;r=i;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(void 0!==s){o.destroy=void 0,a=t;var l=n,c=s;try{c()}catch(e){pu(a,l,e)}}}r=r.next}while(r!==i)}}catch(e){pu(t,t.return,e)}}function ml(e){var t=e.updateQueue;if(null!==t){var n=e.stateNode;try{gi(t,n)}catch(t){pu(e,e.return,t)}}}function hl(e,t,n){n.props=xs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){pu(e,t,n)}}function pl(e,t){try{var n=e.ref;if(null!==n){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;default:r=e.stateNode}"function"==typeof n?e.refCleanup=n(r):n.current=r}}catch(n){pu(e,t,n)}}function fl(e,t){var n=e.ref,r=e.refCleanup;if(null!==n)if("function"==typeof r)try{r()}catch(n){pu(e,t,n)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof n)try{n(null)}catch(n){pu(e,t,n)}else n.current=null}function gl(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&r.focus();break e;case"img":n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){pu(e,e.return,t)}}function bl(e,t,n){try{var a=e.stateNode;!function(e,t,n,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var i=null,o=null,s=null,l=null,c=null,u=null,d=null;for(p in n){var m=n[p];if(n.hasOwnProperty(p)&&null!=m)switch(p){case"checked":case"value":break;case"defaultValue":c=m;default:a.hasOwnProperty(p)||nd(e,t,p,null,a,m)}}for(var h in a){var p=a[h];if(m=n[h],a.hasOwnProperty(h)&&(null!=p||null!=m))switch(h){case"type":o=p;break;case"name":i=p;break;case"checked":u=p;break;case"defaultChecked":d=p;break;case"value":s=p;break;case"defaultValue":l=p;break;case"children":case"dangerouslySetInnerHTML":if(null!=p)throw Error(r(137,t));break;default:p!==m&&nd(e,t,h,p,a,m)}}return void xt(e,s,l,c,u,d,o,i);case"select":for(o in p=s=l=h=null,n)if(c=n[o],n.hasOwnProperty(o)&&null!=c)switch(o){case"value":break;case"multiple":p=c;default:a.hasOwnProperty(o)||nd(e,t,o,null,a,c)}for(i in a)if(o=a[i],c=n[i],a.hasOwnProperty(i)&&(null!=o||null!=c))switch(i){case"value":h=o;break;case"defaultValue":l=o;break;case"multiple":s=o;default:o!==c&&nd(e,t,i,o,a,c)}return t=l,n=s,a=p,void(null!=h?Ct(e,!!n,h,!1):!!a!=!!n&&(null!=t?Ct(e,!!n,t,!0):Ct(e,!!n,n?[]:"",!1)));case"textarea":for(l in p=h=null,n)if(i=n[l],n.hasOwnProperty(l)&&null!=i&&!a.hasOwnProperty(l))switch(l){case"value":case"children":break;default:nd(e,t,l,null,a,i)}for(s in a)if(i=a[s],o=n[s],a.hasOwnProperty(s)&&(null!=i||null!=o))switch(s){case"value":h=i;break;case"defaultValue":p=i;break;case"children":break;case"dangerouslySetInnerHTML":if(null!=i)throw Error(r(91));break;default:i!==o&&nd(e,t,s,i,a,o)}return void St(e,h,p);case"option":for(var f in n)h=n[f],n.hasOwnProperty(f)&&null!=h&&!a.hasOwnProperty(f)&&("selected"===f?e.selected=!1:nd(e,t,f,null,a,h));for(c in a)h=a[c],p=n[c],!a.hasOwnProperty(c)||h===p||null==h&&null==p||("selected"===c?e.selected=h&&"function"!=typeof h&&"symbol"!=typeof h:nd(e,t,c,h,a,p));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var g in n)h=n[g],n.hasOwnProperty(g)&&null!=h&&!a.hasOwnProperty(g)&&nd(e,t,g,null,a,h);for(u in a)if(h=a[u],p=n[u],a.hasOwnProperty(u)&&h!==p&&(null!=h||null!=p))switch(u){case"children":case"dangerouslySetInnerHTML":if(null!=h)throw Error(r(137,t));break;default:nd(e,t,u,h,a,p)}return;default:if(zt(t)){for(var b in n)h=n[b],n.hasOwnProperty(b)&&void 0!==h&&!a.hasOwnProperty(b)&&rd(e,t,b,void 0,a,h);for(d in a)h=a[d],p=n[d],!a.hasOwnProperty(d)||h===p||void 0===h&&void 0===p||rd(e,t,d,h,a,p);return}}for(var y in n)h=n[y],n.hasOwnProperty(y)&&null!=h&&!a.hasOwnProperty(y)&&nd(e,t,y,null,a,h);for(m in a)h=a[m],p=n[m],!a.hasOwnProperty(m)||h===p||null==h&&null==p||nd(e,t,m,h,a,p)}(a,e.type,n,t),a[Oe]=t}catch(t){pu(e,e.return,t)}}function yl(e){return 5===e.tag||3===e.tag||26===e.tag||27===e.tag&&bd(e.type)||4===e.tag}function vl(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||yl(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(27===e.tag&&bd(e.type))continue e;if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function xl(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?(9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).insertBefore(e,t):((t=9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=td));else if(4!==r&&(27===r&&bd(e.type)&&(n=e.stateNode,t=null),null!==(e=e.child)))for(xl(e,t,n),e=e.sibling;null!==e;)xl(e,t,n),e=e.sibling}function wl(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==r&&(27===r&&bd(e.type)&&(n=e.stateNode),null!==(e=e.child)))for(wl(e,t,n),e=e.sibling;null!==e;)wl(e,t,n),e=e.sibling}function kl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,a=t.attributes;a.length;)t.removeAttributeNode(a[0]);ad(t,r,n),t[Le]=e,t[Oe]=n}catch(t){pu(e,e.return,t)}}var Cl=!1,Sl=!1,Nl=!1,jl="function"==typeof WeakSet?WeakSet:Set,El=null;function $l(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Ul(e,n),4&r&&ul(5,n);break;case 1:if(Ul(e,n),4&r)if(e=n.stateNode,null===t)try{e.componentDidMount()}catch(e){pu(n,n.return,e)}else{var a=xs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(a,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){pu(n,n.return,e)}}64&r&&ml(n),512&r&&pl(n,n.return);break;case 3:if(Ul(e,n),64&r&&null!==(e=n.updateQueue)){if(t=null,null!==n.child)switch(n.child.tag){case 27:case 5:case 1:t=n.child.stateNode}try{gi(e,t)}catch(e){pu(n,n.return,e)}}break;case 27:null===t&&4&r&&kl(n);case 26:case 5:Ul(e,n),null===t&&4&r&&gl(n),512&r&&pl(n,n.return);break;case 12:Ul(e,n);break;case 13:Ul(e,n),4&r&&Ml(e,n),64&r&&null!==(e=n.memoizedState)&&null!==(e=e.dehydrated)&&function(e,t){var n=e.ownerDocument;if("$?"!==e.data||"complete"===n.readyState)t();else{var r=function(){t(),n.removeEventListener("DOMContentLoaded",r)};n.addEventListener("DOMContentLoaded",r),e._reactRetry=r}}(e,n=yu.bind(null,n));break;case 22:if(!(r=null!==n.memoizedState||Cl)){t=null!==t&&null!==t.memoizedState||Sl,a=Cl;var i=Sl;Cl=r,(Sl=t)&&!i?Bl(e,n,!!(8772&n.subtreeFlags)):Ul(e,n),Cl=a,Sl=i}break;case 30:break;default:Ul(e,n)}}function _l(e){var t=e.alternate;null!==t&&(e.alternate=null,_l(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&null!==(t=e.stateNode)&&He(t),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var zl=null,Tl=!1;function Pl(e,t,n){for(n=n.child;null!==n;)Al(e,t,n),n=n.sibling}function Al(e,t,n){if(fe&&"function"==typeof fe.onCommitFiberUnmount)try{fe.onCommitFiberUnmount(pe,n)}catch(e){}switch(n.tag){case 26:Sl||fl(n,t),Pl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode).parentNode.removeChild(n);break;case 27:Sl||fl(n,t);var r=zl,a=Tl;bd(n.type)&&(zl=n.stateNode,Tl=!1),Pl(e,t,n),Nd(n.stateNode),zl=r,Tl=a;break;case 5:Sl||fl(n,t);case 6:if(r=zl,a=Tl,zl=null,Pl(e,t,n),Tl=a,null!==(zl=r))if(Tl)try{(9===zl.nodeType?zl.body:"HTML"===zl.nodeName?zl.ownerDocument.body:zl).removeChild(n.stateNode)}catch(e){pu(n,t,e)}else try{zl.removeChild(n.stateNode)}catch(e){pu(n,t,e)}break;case 18:null!==zl&&(Tl?(yd(9===(e=zl).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,n.stateNode),Tm(e)):yd(zl,n.stateNode));break;case 4:r=zl,a=Tl,zl=n.stateNode.containerInfo,Tl=!0,Pl(e,t,n),zl=r,Tl=a;break;case 0:case 11:case 14:case 15:Sl||dl(2,n,t),Sl||dl(4,n,t),Pl(e,t,n);break;case 1:Sl||(fl(n,t),"function"==typeof(r=n.stateNode).componentWillUnmount&&hl(n,t,r)),Pl(e,t,n);break;case 21:Pl(e,t,n);break;case 22:Sl=(r=Sl)||null!==n.memoizedState,Pl(e,t,n),Sl=r;break;default:Pl(e,t,n)}}function Ml(e,t){if(null===t.memoizedState&&null!==(e=t.alternate)&&null!==(e=e.memoizedState)&&null!==(e=e.dehydrated))try{Tm(e)}catch(e){pu(t,t.return,e)}}function Il(e,t){var n=function(e){switch(e.tag){case 13:case 19:var t=e.stateNode;return null===t&&(t=e.stateNode=new jl),t;case 22:return null===(t=(e=e.stateNode)._retryCache)&&(t=e._retryCache=new jl),t;default:throw Error(r(435,e.tag))}}(e);t.forEach(function(t){var r=vu.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}function Ll(e,t){var n=t.deletions;if(null!==n)for(var a=0;a<n.length;a++){var i=n[a],o=e,s=t,l=s;e:for(;null!==l;){switch(l.tag){case 27:if(bd(l.type)){zl=l.stateNode,Tl=!1;break e}break;case 5:zl=l.stateNode,Tl=!1;break e;case 3:case 4:zl=l.stateNode.containerInfo,Tl=!0;break e}l=l.return}if(null===zl)throw Error(r(160));Al(o,s,i),zl=null,Tl=!1,null!==(o=i.alternate)&&(o.return=null),i.return=null}if(13878&t.subtreeFlags)for(t=t.child;null!==t;)Rl(t,e),t=t.sibling}var Ol=null;function Rl(e,t){var n=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Ll(t,e),Dl(e),4&a&&(dl(3,e,e.return),ul(3,e),dl(5,e,e.return));break;case 1:Ll(t,e),Dl(e),512&a&&(Sl||null===n||fl(n,n.return)),64&a&&Cl&&null!==(e=e.updateQueue)&&null!==(a=e.callbacks)&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=null===n?a:n.concat(a));break;case 26:var i=Ol;if(Ll(t,e),Dl(e),512&a&&(Sl||null===n||fl(n,n.return)),4&a){var o=null!==n?n.memoizedState:null;if(a=e.memoizedState,null===n)if(null===a)if(null===e.stateNode){e:{a=e.type,n=e.memoizedProps,i=i.ownerDocument||i;t:switch(a){case"title":(!(o=i.getElementsByTagName("title")[0])||o[Be]||o[Le]||"http://www.w3.org/2000/svg"===o.namespaceURI||o.hasAttribute("itemprop"))&&(o=i.createElement(a),i.head.insertBefore(o,i.querySelector("head > title"))),ad(o,a,n),o[Le]=e,Qe(o),a=o;break e;case"link":var s=Bd("link","href",i).get(a+(n.href||""));if(s)for(var l=0;l<s.length;l++)if((o=s[l]).getAttribute("href")===(null==n.href||""===n.href?null:n.href)&&o.getAttribute("rel")===(null==n.rel?null:n.rel)&&o.getAttribute("title")===(null==n.title?null:n.title)&&o.getAttribute("crossorigin")===(null==n.crossOrigin?null:n.crossOrigin)){s.splice(l,1);break t}ad(o=i.createElement(a),a,n),i.head.appendChild(o);break;case"meta":if(s=Bd("meta","content",i).get(a+(n.content||"")))for(l=0;l<s.length;l++)if((o=s[l]).getAttribute("content")===(null==n.content?null:""+n.content)&&o.getAttribute("name")===(null==n.name?null:n.name)&&o.getAttribute("property")===(null==n.property?null:n.property)&&o.getAttribute("http-equiv")===(null==n.httpEquiv?null:n.httpEquiv)&&o.getAttribute("charset")===(null==n.charSet?null:n.charSet)){s.splice(l,1);break t}ad(o=i.createElement(a),a,n),i.head.appendChild(o);break;default:throw Error(r(468,a))}o[Le]=e,Qe(o),a=o}e.stateNode=a}else Hd(i,e.type,e.stateNode);else e.stateNode=Rd(i,a,e.memoizedProps);else o!==a?(null===o?null!==n.stateNode&&(n=n.stateNode).parentNode.removeChild(n):o.count--,null===a?Hd(i,e.type,e.stateNode):Rd(i,a,e.memoizedProps)):null===a&&null!==e.stateNode&&bl(e,e.memoizedProps,n.memoizedProps)}break;case 27:Ll(t,e),Dl(e),512&a&&(Sl||null===n||fl(n,n.return)),null!==n&&4&a&&bl(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Ll(t,e),Dl(e),512&a&&(Sl||null===n||fl(n,n.return)),32&e.flags){i=e.stateNode;try{jt(i,"")}catch(t){pu(e,e.return,t)}}4&a&&null!=e.stateNode&&bl(e,i=e.memoizedProps,null!==n?n.memoizedProps:i),1024&a&&(Nl=!0);break;case 6:if(Ll(t,e),Dl(e),4&a){if(null===e.stateNode)throw Error(r(162));a=e.memoizedProps,n=e.stateNode;try{n.nodeValue=a}catch(t){pu(e,e.return,t)}}break;case 3:if(qd=null,i=Ol,Ol=$d(t.containerInfo),Ll(t,e),Ol=i,Dl(e),4&a&&null!==n&&n.memoizedState.isDehydrated)try{Tm(t.containerInfo)}catch(t){pu(e,e.return,t)}Nl&&(Nl=!1,Fl(e));break;case 4:a=Ol,Ol=$d(e.stateNode.containerInfo),Ll(t,e),Dl(e),Ol=a;break;case 12:default:Ll(t,e),Dl(e);break;case 13:Ll(t,e),Dl(e),8192&e.child.flags&&null!==e.memoizedState!=(null!==n&&null!==n.memoizedState)&&(Nc=ie()),4&a&&null!==(a=e.updateQueue)&&(e.updateQueue=null,Il(e,a));break;case 22:i=null!==e.memoizedState;var c=null!==n&&null!==n.memoizedState,u=Cl,d=Sl;if(Cl=u||i,Sl=d||c,Ll(t,e),Sl=d,Cl=u,Dl(e),8192&a)e:for(t=e.stateNode,t._visibility=i?-2&t._visibility:1|t._visibility,i&&(null===n||c||Cl||Sl||ql(e)),n=null,t=e;;){if(5===t.tag||26===t.tag){if(null===n){c=n=t;try{if(o=c.stateNode,i)"function"==typeof(s=o.style).setProperty?s.setProperty("display","none","important"):s.display="none";else{l=c.stateNode;var m=c.memoizedProps.style,h=null!=m&&m.hasOwnProperty("display")?m.display:null;l.style.display=null==h||"boolean"==typeof h?"":(""+h).trim()}}catch(e){pu(c,c.return,e)}}}else if(6===t.tag){if(null===n){c=t;try{c.stateNode.nodeValue=i?"":c.memoizedProps}catch(e){pu(c,c.return,e)}}}else if((22!==t.tag&&23!==t.tag||null===t.memoizedState||t===e)&&null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;null===t.sibling;){if(null===t.return||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}4&a&&null!==(a=e.updateQueue)&&null!==(n=a.retryQueue)&&(a.retryQueue=null,Il(e,n));break;case 19:Ll(t,e),Dl(e),4&a&&null!==(a=e.updateQueue)&&(e.updateQueue=null,Il(e,a));case 30:case 21:}}function Dl(e){var t=e.flags;if(2&t){try{for(var n,a=e.return;null!==a;){if(yl(a)){n=a;break}a=a.return}if(null==n)throw Error(r(160));switch(n.tag){case 27:var i=n.stateNode;wl(e,vl(e),i);break;case 5:var o=n.stateNode;32&n.flags&&(jt(o,""),n.flags&=-33),wl(e,vl(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;xl(e,vl(e),s);break;default:throw Error(r(161))}}catch(t){pu(e,e.return,t)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function Fl(e){if(1024&e.subtreeFlags)for(e=e.child;null!==e;){var t=e;Fl(t),5===t.tag&&1024&t.flags&&t.stateNode.reset(),e=e.sibling}}function Ul(e,t){if(8772&t.subtreeFlags)for(t=t.child;null!==t;)$l(e,t.alternate,t),t=t.sibling}function ql(e){for(e=e.child;null!==e;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:dl(4,t,t.return),ql(t);break;case 1:fl(t,t.return);var n=t.stateNode;"function"==typeof n.componentWillUnmount&&hl(t,t.return,n),ql(t);break;case 27:Nd(t.stateNode);case 26:case 5:fl(t,t.return),ql(t);break;case 22:null===t.memoizedState&&ql(t);break;default:ql(t)}e=e.sibling}}function Bl(e,t,n){for(n=n&&!!(8772&t.subtreeFlags),t=t.child;null!==t;){var r=t.alternate,a=e,i=t,o=i.flags;switch(i.tag){case 0:case 11:case 15:Bl(a,i,n),ul(4,i);break;case 1:if(Bl(a,i,n),"function"==typeof(a=(r=i).stateNode).componentDidMount)try{a.componentDidMount()}catch(e){pu(r,r.return,e)}if(null!==(a=(r=i).updateQueue)){var s=r.stateNode;try{var l=a.shared.hiddenCallbacks;if(null!==l)for(a.shared.hiddenCallbacks=null,a=0;a<l.length;a++)fi(l[a],s)}catch(e){pu(r,r.return,e)}}n&&64&o&&ml(i),pl(i,i.return);break;case 27:kl(i);case 26:case 5:Bl(a,i,n),n&&null===r&&4&o&&gl(i),pl(i,i.return);break;case 12:Bl(a,i,n);break;case 13:Bl(a,i,n),n&&4&o&&Ml(a,i);break;case 22:null===i.memoizedState&&Bl(a,i,n),pl(i,i.return);break;case 30:break;default:Bl(a,i,n)}t=t.sibling}}function Hl(e,t){var n=null;null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),e=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(e=t.memoizedState.cachePool.pool),e!==n&&(null!=e&&e.refCount++,null!=n&&Ra(n))}function Wl(e,t){e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Ra(e))}function Vl(e,t,n,r){if(10256&t.subtreeFlags)for(t=t.child;null!==t;)Kl(e,t,n,r),t=t.sibling}function Kl(e,t,n,r){var a=t.flags;switch(t.tag){case 0:case 11:case 15:Vl(e,t,n,r),2048&a&&ul(9,t);break;case 1:case 13:default:Vl(e,t,n,r);break;case 3:Vl(e,t,n,r),2048&a&&(e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Ra(e)));break;case 12:if(2048&a){Vl(e,t,n,r),e=t.stateNode;try{var i=t.memoizedProps,o=i.id,s=i.onPostCommit;"function"==typeof s&&s(o,null===t.alternate?"mount":"update",e.passiveEffectDuration,-0)}catch(e){pu(t,t.return,e)}}else Vl(e,t,n,r);break;case 23:break;case 22:i=t.stateNode,o=t.alternate,null!==t.memoizedState?2&i._visibility?Vl(e,t,n,r):Ql(e,t):2&i._visibility?Vl(e,t,n,r):(i._visibility|=2,Gl(e,t,n,r,!!(10256&t.subtreeFlags))),2048&a&&Hl(o,t);break;case 24:Vl(e,t,n,r),2048&a&&Wl(t.alternate,t)}}function Gl(e,t,n,r,a){for(a=a&&!!(10256&t.subtreeFlags),t=t.child;null!==t;){var i=e,o=t,s=n,l=r,c=o.flags;switch(o.tag){case 0:case 11:case 15:Gl(i,o,s,l,a),ul(8,o);break;case 23:break;case 22:var u=o.stateNode;null!==o.memoizedState?2&u._visibility?Gl(i,o,s,l,a):Ql(i,o):(u._visibility|=2,Gl(i,o,s,l,a)),a&&2048&c&&Hl(o.alternate,o);break;case 24:Gl(i,o,s,l,a),a&&2048&c&&Wl(o.alternate,o);break;default:Gl(i,o,s,l,a)}t=t.sibling}}function Ql(e,t){if(10256&t.subtreeFlags)for(t=t.child;null!==t;){var n=e,r=t,a=r.flags;switch(r.tag){case 22:Ql(n,r),2048&a&&Hl(r.alternate,r);break;case 24:Ql(n,r),2048&a&&Wl(r.alternate,r);break;default:Ql(n,r)}t=t.sibling}}var Yl=8192;function Xl(e){if(e.subtreeFlags&Yl)for(e=e.child;null!==e;)Jl(e),e=e.sibling}function Jl(e){switch(e.tag){case 26:Xl(e),e.flags&Yl&&null!==e.memoizedState&&function(e,t,n){if(null===Vd)throw Error(r(475));var a=Vd;if(!("stylesheet"!==t.type||"string"==typeof n.media&&!1===matchMedia(n.media).matches||4&t.state.loading)){if(null===t.instance){var i=Ad(n.href),o=e.querySelector(Md(i));if(o)return null!==(e=o._p)&&"object"==typeof e&&"function"==typeof e.then&&(a.count++,a=Gd.bind(a),e.then(a,a)),t.state.loading|=4,t.instance=o,void Qe(o);o=e.ownerDocument||e,n=Id(n),(i=jd.get(i))&&Fd(n,i),Qe(o=o.createElement("link"));var s=o;s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),ad(o,"link",n),t.instance=o}null===a.stylesheets&&(a.stylesheets=new Map),a.stylesheets.set(t,e),(e=t.state.preload)&&!(3&t.state.loading)&&(a.count++,t=Gd.bind(a),e.addEventListener("load",t),e.addEventListener("error",t))}}(Ol,e.memoizedState,e.memoizedProps);break;case 5:default:Xl(e);break;case 3:case 4:var t=Ol;Ol=$d(e.stateNode.containerInfo),Xl(e),Ol=t;break;case 22:null===e.memoizedState&&(null!==(t=e.alternate)&&null!==t.memoizedState?(t=Yl,Yl=16777216,Xl(e),Yl=t):Xl(e))}}function Zl(e){var t=e.alternate;if(null!==t&&null!==(e=t.child)){t.child=null;do{t=e.sibling,e.sibling=null,e=t}while(null!==e)}}function ec(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var r=t[n];El=r,rc(r,e)}Zl(e)}if(10256&e.subtreeFlags)for(e=e.child;null!==e;)tc(e),e=e.sibling}function tc(e){switch(e.tag){case 0:case 11:case 15:ec(e),2048&e.flags&&dl(9,e,e.return);break;case 3:case 12:default:ec(e);break;case 22:var t=e.stateNode;null!==e.memoizedState&&2&t._visibility&&(null===e.return||13!==e.return.tag)?(t._visibility&=-3,nc(e)):ec(e)}}function nc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var r=t[n];El=r,rc(r,e)}Zl(e)}for(e=e.child;null!==e;){switch((t=e).tag){case 0:case 11:case 15:dl(8,t,t.return),nc(t);break;case 22:2&(n=t.stateNode)._visibility&&(n._visibility&=-3,nc(t));break;default:nc(t)}e=e.sibling}}function rc(e,t){for(;null!==El;){var n=El;switch(n.tag){case 0:case 11:case 15:dl(8,n,t);break;case 23:case 22:if(null!==n.memoizedState&&null!==n.memoizedState.cachePool){var r=n.memoizedState.cachePool.pool;null!=r&&r.refCount++}break;case 24:Ra(n.memoizedState.cache)}if(null!==(r=n.child))r.return=n,El=r;else e:for(n=e;null!==El;){var a=(r=El).sibling,i=r.return;if(_l(r),r===n){El=null;break e}if(null!==a){a.return=i,El=a;break e}El=i}}}var ac={getCacheForType:function(e){var t=za(La),n=t.data.get(e);return void 0===n&&(n=e(),t.data.set(e,n)),n}},ic="function"==typeof WeakMap?WeakMap:Map,oc=0,sc=null,lc=null,cc=0,uc=0,dc=null,mc=!1,hc=!1,pc=!1,fc=0,gc=0,bc=0,yc=0,vc=0,xc=0,wc=0,kc=null,Cc=null,Sc=!1,Nc=0,jc=1/0,Ec=null,$c=null,_c=0,zc=null,Tc=null,Pc=0,Ac=0,Mc=null,Ic=null,Lc=0,Oc=null;function Rc(){return 2&oc&&0!==cc?cc&-cc:null!==R.T?0!==Ua?Ua:Au():Me()}function Dc(){0===xc&&(xc=536870912&cc&&!ca?536870912:je());var e=ls.current;return null!==e&&(e.flags|=32),xc}function Fc(e,t,n){(e!==sc||2!==uc&&9!==uc)&&null===e.cancelPendingCommit||(Kc(e,0),Hc(e,cc,xc,!1)),_e(e,n),2&oc&&e===sc||(e===sc&&(!(2&oc)&&(yc|=n),4===gc&&Hc(e,cc,xc,!1)),ju(e))}function Uc(e,t,n){if(6&oc)throw Error(r(327));for(var a=!n&&!(124&t)&&0===(t&e.expiredLanes)||Se(e,t),i=a?function(e,t){var n=oc;oc|=2;var a=Qc(),i=Yc();sc!==e||cc!==t?(Ec=null,jc=ie()+500,Kc(e,t)):hc=Se(e,t);e:for(;;)try{if(0!==uc&&null!==lc){t=lc;var o=dc;t:switch(uc){case 1:uc=0,dc=null,ru(e,t,o,1);break;case 2:case 9:if(Za(o)){uc=0,dc=null,nu(t);break}t=function(){2!==uc&&9!==uc||sc!==e||(uc=7),ju(e)},o.then(t,t);break e;case 3:uc=7;break e;case 4:uc=5;break e;case 7:Za(o)?(uc=0,dc=null,nu(t)):(uc=0,dc=null,ru(e,t,o,7));break;case 5:var s=null;switch(lc.tag){case 26:s=lc.memoizedState;case 5:case 27:var l=lc;if(!s||Wd(s)){uc=0,dc=null;var c=l.sibling;if(null!==c)lc=c;else{var u=l.return;null!==u?(lc=u,au(u)):lc=null}break t}}uc=0,dc=null,ru(e,t,o,5);break;case 6:uc=0,dc=null,ru(e,t,o,6);break;case 8:Vc(),gc=6;break e;default:throw Error(r(462))}}eu();break}catch(t){Gc(e,t)}return ka=wa=null,R.H=a,R.A=i,oc=n,null!==lc?0:(sc=null,cc=0,Pr(),gc)}(e,t):Jc(e,t,!0),o=a;;){if(0===i){hc&&!a&&Hc(e,t,0,!1);break}if(n=e.current.alternate,!o||Bc(n)){if(2===i){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=0!=(s=-536870913&e.pendingLanes)?s:536870912&s?536870912:0;if(0!==s){t=s;e:{var l=e;i=kc;var c=l.current.memoizedState.isDehydrated;if(c&&(Kc(l,s).flags|=256),2!==(s=Jc(l,s,!1))){if(pc&&!c){l.errorRecoveryDisabledLanes|=o,yc|=o,i=4;break e}o=Cc,Cc=i,null!==o&&(null===Cc?Cc=o:Cc.push.apply(Cc,o))}i=s}if(o=!1,2!==i)continue}}if(1===i){Kc(e,0),Hc(e,t,0,!0);break}e:{switch(a=e,o=i){case 0:case 1:throw Error(r(345));case 4:if((4194048&t)!==t)break;case 6:Hc(a,t,xc,!mc);break e;case 2:Cc=null;break;case 3:case 5:break;default:throw Error(r(329))}if((62914560&t)===t&&10<(i=Nc+300-ie())){if(Hc(a,t,xc,!mc),0!==Ce(a,0,!0))break e;a.timeoutHandle=md(qc.bind(null,a,n,Cc,Ec,Sc,t,xc,yc,wc,mc,o,2,-0,0),i)}else qc(a,n,Cc,Ec,Sc,t,xc,yc,wc,mc,o,0,-0,0)}break}i=Jc(e,t,!1),o=!1}ju(e)}function qc(e,t,n,a,i,o,s,l,c,u,d,m,h,p){if(e.timeoutHandle=-1,(8192&(m=t.subtreeFlags)||!(16785408&~m))&&(Vd={stylesheets:null,count:0,unsuspend:Kd},Jl(t),null!==(m=function(){if(null===Vd)throw Error(r(475));var e=Vd;return e.stylesheets&&0===e.count&&Yd(e,e.stylesheets),0<e.count?function(t){var n=setTimeout(function(){if(e.stylesheets&&Yd(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4);return e.unsuspend=t,function(){e.unsuspend=null,clearTimeout(n)}}:null}())))return e.cancelPendingCommit=m(ou.bind(null,e,t,o,n,a,i,s,l,c,d,1,h,p)),void Hc(e,o,s,!u);ou(e,t,o,n,a,i,s,l,c)}function Bc(e){for(var t=e;;){var n=t.tag;if((0===n||11===n||15===n)&&16384&t.flags&&null!==(n=t.updateQueue)&&null!==(n=n.stores))for(var r=0;r<n.length;r++){var a=n[r],i=a.getSnapshot;a=a.value;try{if(!Zn(i(),a))return!1}catch(e){return!1}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Hc(e,t,n,r){t&=~vc,t&=~yc,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var a=t;0<a;){var i=31-be(a),o=1<<i;r[i]=-1,a&=~o}0!==n&&ze(e,n,t)}function Wc(){return!!(6&oc)||(Eu(0),!1)}function Vc(){if(null!==lc){if(0===uc)var e=lc.return;else ka=wa=null,Ui(e=lc),Zo=null,es=0,e=lc;for(;null!==e;)cl(e.alternate,e),e=e.return;lc=null}}function Kc(e,t){var n=e.timeoutHandle;-1!==n&&(e.timeoutHandle=-1,hd(n)),null!==(n=e.cancelPendingCommit)&&(e.cancelPendingCommit=null,n()),Vc(),sc=e,lc=n=qr(e.current,null),cc=t,uc=0,dc=null,mc=!1,hc=Se(e,t),pc=!1,wc=xc=vc=yc=bc=gc=0,Cc=kc=null,Sc=!1,8&t&&(t|=32&t);var r=e.entangledLanes;if(0!==r)for(e=e.entanglements,r&=t;0<r;){var a=31-be(r),i=1<<a;t|=e[a],r&=~i}return fc=t,Pr(),n}function Gc(e,t){Ci=null,R.H=Qo,t===Qa||t===Xa?(t=ri(),uc=3):t===Ya?(t=ri(),uc=4):uc=t===zs?8:null!==t&&"object"==typeof t&&"function"==typeof t.then?6:1,dc=t,null===lc&&(gc=1,Ns(e,$r(t,e.current)))}function Qc(){var e=R.H;return R.H=Qo,null===e?Qo:e}function Yc(){var e=R.A;return R.A=ac,e}function Xc(){gc=4,mc||(4194048&cc)!==cc&&null!==ls.current||(hc=!0),!(134217727&bc)&&!(134217727&yc)||null===sc||Hc(sc,cc,xc,!1)}function Jc(e,t,n){var r=oc;oc|=2;var a=Qc(),i=Yc();sc===e&&cc===t||(Ec=null,Kc(e,t)),t=!1;var o=gc;e:for(;;)try{if(0!==uc&&null!==lc){var s=lc,l=dc;switch(uc){case 8:Vc(),o=6;break e;case 3:case 2:case 9:case 6:null===ls.current&&(t=!0);var c=uc;if(uc=0,dc=null,ru(e,s,l,c),n&&hc){o=0;break e}break;default:c=uc,uc=0,dc=null,ru(e,s,l,c)}}Zc(),o=gc;break}catch(t){Gc(e,t)}return t&&e.shellSuspendCounter++,ka=wa=null,oc=r,R.H=a,R.A=i,null===lc&&(sc=null,cc=0,Pr()),o}function Zc(){for(;null!==lc;)tu(lc)}function eu(){for(;null!==lc&&!re();)tu(lc)}function tu(e){var t=tl(e.alternate,e,fc);e.memoizedProps=e.pendingProps,null===t?au(e):lc=t}function nu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Fs(n,t,t.pendingProps,t.type,void 0,cc);break;case 11:t=Fs(n,t,t.pendingProps,t.type.render,t.ref,cc);break;case 5:Ui(t);default:cl(n,t),t=tl(n,t=lc=Br(t,fc),fc)}e.memoizedProps=e.pendingProps,null===t?au(e):lc=t}function ru(e,t,n,a){ka=wa=null,Ui(t),Zo=null,es=0;var i=t.return;try{if(function(e,t,n,a,i){if(n.flags|=32768,null!==a&&"object"==typeof a&&"function"==typeof a.then){if(null!==(t=n.alternate)&&Ea(t,n,i,!0),null!==(n=ls.current)){switch(n.tag){case 13:return null===cs?Xc():null===n.alternate&&0===gc&&(gc=3),n.flags&=-257,n.flags|=65536,n.lanes=i,a===Ja?n.flags|=16384:(null===(t=n.updateQueue)?n.updateQueue=new Set([a]):t.add(a),fu(e,a,i)),!1;case 22:return n.flags|=65536,a===Ja?n.flags|=16384:(null===(t=n.updateQueue)?(t={transitions:null,markerInstances:null,retryQueue:new Set([a])},n.updateQueue=t):null===(n=t.retryQueue)?t.retryQueue=new Set([a]):n.add(a),fu(e,a,i)),!1}throw Error(r(435,n.tag))}return fu(e,a,i),Xc(),!1}if(ca)return null!==(t=ls.current)?(!(65536&t.flags)&&(t.flags|=256),t.flags|=65536,t.lanes=i,a!==ma&&va($r(e=Error(r(422),{cause:a}),n))):(a!==ma&&va($r(t=Error(r(423),{cause:a}),n)),(e=e.current.alternate).flags|=65536,i&=-i,e.lanes|=i,a=$r(a,n),di(e,i=Es(e.stateNode,a,i)),4!==gc&&(gc=2)),!1;var o=Error(r(520),{cause:a});if(o=$r(o,n),null===kc?kc=[o]:kc.push(o),4!==gc&&(gc=2),null===t)return!0;a=$r(a,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,di(n,e=Es(n.stateNode,a,e)),!1;case 1:if(t=n.type,o=n.stateNode,!(128&n.flags||"function"!=typeof t.getDerivedStateFromError&&(null===o||"function"!=typeof o.componentDidCatch||null!==$c&&$c.has(o))))return n.flags|=65536,i&=-i,n.lanes|=i,_s(i=$s(i),e,n,a),di(n,i),!1}n=n.return}while(null!==n);return!1}(e,i,t,n,cc))return gc=1,Ns(e,$r(n,e.current)),void(lc=null)}catch(t){if(null!==i)throw lc=i,t;return gc=1,Ns(e,$r(n,e.current)),void(lc=null)}32768&t.flags?(ca||1===a?e=!0:hc||536870912&cc?e=!1:(mc=e=!0,(2===a||9===a||3===a||6===a)&&null!==(a=ls.current)&&13===a.tag&&(a.flags|=16384)),iu(t,e)):au(t)}function au(e){var t=e;do{if(32768&t.flags)return void iu(t,mc);e=t.return;var n=sl(t.alternate,t,fc);if(null!==n)return void(lc=n);if(null!==(t=t.sibling))return void(lc=t);lc=t=e}while(null!==t);0===gc&&(gc=5)}function iu(e,t){do{var n=ll(e.alternate,e);if(null!==n)return n.flags&=32767,void(lc=n);if(null!==(n=e.return)&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&null!==(e=e.sibling))return void(lc=e);lc=e=n}while(null!==e);gc=6,lc=null}function ou(e,t,n,a,i,o,s,l,c){e.cancelPendingCommit=null;do{du()}while(0!==_c);if(6&oc)throw Error(r(327));if(null!==t){if(t===e.current)throw Error(r(177));if(o=t.lanes|t.childLanes,function(e,t,n,r,a,i){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,l=e.expirationTimes,c=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-be(n),d=1<<u;s[u]=0,l[u]=-1;var m=c[u];if(null!==m)for(c[u]=null,u=0;u<m.length;u++){var h=m[u];null!==h&&(h.lane&=-536870913)}n&=~d}0!==r&&ze(e,r,0),0!==i&&0===a&&0!==e.tag&&(e.suspendedLanes|=i&~(o&~t))}(e,n,o|=Tr,s,l,c),e===sc&&(lc=sc=null,cc=0),Tc=t,zc=e,Pc=n,Ac=o,Mc=i,Ic=a,10256&t.subtreeFlags||10256&t.flags?(e.callbackNode=null,e.callbackPriority=0,te(ce,function(){return mu(),null})):(e.callbackNode=null,e.callbackPriority=0),a=!!(13878&t.flags),13878&t.subtreeFlags||a){a=R.T,R.T=null,i=D.p,D.p=2,s=oc,oc|=4;try{!function(e,t){if(e=e.containerInfo,id=om,ir(e=ar(e))){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{var a=(n=(n=e.ownerDocument)&&n.defaultView||window).getSelection&&n.getSelection();if(a&&0!==a.rangeCount){n=a.anchorNode;var i=a.anchorOffset,o=a.focusNode;a=a.focusOffset;try{n.nodeType,o.nodeType}catch(e){n=null;break e}var s=0,l=-1,c=-1,u=0,d=0,m=e,h=null;t:for(;;){for(var p;m!==n||0!==i&&3!==m.nodeType||(l=s+i),m!==o||0!==a&&3!==m.nodeType||(c=s+a),3===m.nodeType&&(s+=m.nodeValue.length),null!==(p=m.firstChild);)h=m,m=p;for(;;){if(m===e)break t;if(h===n&&++u===i&&(l=s),h===o&&++d===a&&(c=s),null!==(p=m.nextSibling))break;h=(m=h).parentNode}m=p}n=-1===l||-1===c?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(od={focusedElem:e,selectionRange:n},om=!1,El=t;null!==El;)if(e=(t=El).child,1024&t.subtreeFlags&&null!==e)e.return=t,El=e;else for(;null!==El;){switch(o=(t=El).alternate,e=t.flags,t.tag){case 0:case 11:case 15:case 5:case 26:case 27:case 6:case 4:case 17:break;case 1:if(1024&e&&null!==o){e=void 0,n=t,i=o.memoizedProps,o=o.memoizedState,a=n.stateNode;try{var f=xs(n.type,i,(n.elementType,n.type));e=a.getSnapshotBeforeUpdate(f,o),a.__reactInternalSnapshotBeforeUpdate=e}catch(e){pu(n,n.return,e)}}break;case 3:if(1024&e)if(9===(n=(e=t.stateNode.containerInfo).nodeType))vd(e);else if(1===n)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":vd(e);break;default:e.textContent=""}break;default:if(1024&e)throw Error(r(163))}if(null!==(e=t.sibling)){e.return=t.return,El=e;break}El=t.return}}(e,t)}finally{oc=s,D.p=i,R.T=a}}_c=1,su(),lu(),cu()}}function su(){if(1===_c){_c=0;var e=zc,t=Tc,n=!!(13878&t.flags);if(13878&t.subtreeFlags||n){n=R.T,R.T=null;var r=D.p;D.p=2;var a=oc;oc|=4;try{Rl(t,e);var i=od,o=ar(e.containerInfo),s=i.focusedElem,l=i.selectionRange;if(o!==s&&s&&s.ownerDocument&&rr(s.ownerDocument.documentElement,s)){if(null!==l&&ir(s)){var c=l.start,u=l.end;if(void 0===u&&(u=c),"selectionStart"in s)s.selectionStart=c,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,m=d&&d.defaultView||window;if(m.getSelection){var h=m.getSelection(),p=s.textContent.length,f=Math.min(l.start,p),g=void 0===l.end?f:Math.min(l.end,p);!h.extend&&f>g&&(o=g,g=f,f=o);var b=nr(s,f),y=nr(s,g);if(b&&y&&(1!==h.rangeCount||h.anchorNode!==b.node||h.anchorOffset!==b.offset||h.focusNode!==y.node||h.focusOffset!==y.offset)){var v=d.createRange();v.setStart(b.node,b.offset),h.removeAllRanges(),f>g?(h.addRange(v),h.extend(y.node,y.offset)):(v.setEnd(y.node,y.offset),h.addRange(v))}}}}for(d=[],h=s;h=h.parentNode;)1===h.nodeType&&d.push({element:h,left:h.scrollLeft,top:h.scrollTop});for("function"==typeof s.focus&&s.focus(),s=0;s<d.length;s++){var x=d[s];x.element.scrollLeft=x.left,x.element.scrollTop=x.top}}om=!!id,od=id=null}finally{oc=a,D.p=r,R.T=n}}e.current=t,_c=2}}function lu(){if(2===_c){_c=0;var e=zc,t=Tc,n=!!(8772&t.flags);if(8772&t.subtreeFlags||n){n=R.T,R.T=null;var r=D.p;D.p=2;var a=oc;oc|=4;try{$l(e,t.alternate,t)}finally{oc=a,D.p=r,R.T=n}}_c=3}}function cu(){if(4===_c||3===_c){_c=0,ae();var e=zc,t=Tc,n=Pc,r=Ic;10256&t.subtreeFlags||10256&t.flags?_c=5:(_c=0,Tc=zc=null,uu(e,e.pendingLanes));var a=e.pendingLanes;if(0===a&&($c=null),Ae(n),t=t.stateNode,fe&&"function"==typeof fe.onCommitFiberRoot)try{fe.onCommitFiberRoot(pe,t,void 0,!(128&~t.current.flags))}catch(e){}if(null!==r){t=R.T,a=D.p,D.p=2,R.T=null;try{for(var i=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];i(s.value,{componentStack:s.stack})}}finally{R.T=t,D.p=a}}3&Pc&&du(),ju(e),a=e.pendingLanes,4194090&n&&42&a?e===Oc?Lc++:(Lc=0,Oc=e):Lc=0,Eu(0)}}function uu(e,t){0===(e.pooledCacheLanes&=t)&&null!=(t=e.pooledCache)&&(e.pooledCache=null,Ra(t))}function du(e){return su(),lu(),cu(),mu()}function mu(){if(5!==_c)return!1;var e=zc,t=Ac;Ac=0;var n=Ae(Pc),a=R.T,i=D.p;try{D.p=32>n?32:n,R.T=null,n=Mc,Mc=null;var o=zc,s=Pc;if(_c=0,Tc=zc=null,Pc=0,6&oc)throw Error(r(331));var l=oc;if(oc|=4,tc(o.current),Kl(o,o.current,s,n),oc=l,Eu(0,!1),fe&&"function"==typeof fe.onPostCommitFiberRoot)try{fe.onPostCommitFiberRoot(pe,o)}catch(e){}return!0}finally{D.p=i,R.T=a,uu(e,t)}}function hu(e,t,n){t=$r(n,t),null!==(e=ci(e,t=Es(e.stateNode,t,2),2))&&(_e(e,2),ju(e))}function pu(e,t,n){if(3===e.tag)hu(e,e,n);else for(;null!==t;){if(3===t.tag){hu(t,e,n);break}if(1===t.tag){var r=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===$c||!$c.has(r))){e=$r(n,e),null!==(r=ci(t,n=$s(2),2))&&(_s(n,r,t,e),_e(r,2),ju(r));break}}t=t.return}}function fu(e,t,n){var r=e.pingCache;if(null===r){r=e.pingCache=new ic;var a=new Set;r.set(t,a)}else void 0===(a=r.get(t))&&(a=new Set,r.set(t,a));a.has(n)||(pc=!0,a.add(n),e=gu.bind(null,e,t,n),t.then(e,e))}function gu(e,t,n){var r=e.pingCache;null!==r&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,sc===e&&(cc&n)===n&&(4===gc||3===gc&&(62914560&cc)===cc&&300>ie()-Nc?!(2&oc)&&Kc(e,0):vc|=n,wc===cc&&(wc=0)),ju(e)}function bu(e,t){0===t&&(t=Ee()),null!==(e=Ir(e,t))&&(_e(e,t),ju(e))}function yu(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),bu(e,n)}function vu(e,t){var n=0;switch(e.tag){case 13:var a=e.stateNode,i=e.memoizedState;null!==i&&(n=i.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(r(314))}null!==a&&a.delete(t),bu(e,n)}var xu=null,wu=null,ku=!1,Cu=!1,Su=!1,Nu=0;function ju(e){e!==wu&&null===e.next&&(null===wu?xu=wu=e:wu=wu.next=e),Cu=!0,ku||(ku=!0,fd(function(){6&oc?te(se,$u):_u()}))}function Eu(e,t){if(!Su&&Cu){Su=!0;do{for(var n=!1,r=xu;null!==r;){if(0!==e){var a=r.pendingLanes;if(0===a)var i=0;else{var o=r.suspendedLanes,s=r.pingedLanes;i=(1<<31-be(42|e)+1)-1,i=201326741&(i&=a&~(o&~s))?201326741&i|1:i?2|i:0}0!==i&&(n=!0,Pu(r,i))}else i=cc,!(3&(i=Ce(r,r===sc?i:0,null!==r.cancelPendingCommit||-1!==r.timeoutHandle)))||Se(r,i)||(n=!0,Pu(r,i));r=r.next}}while(n);Su=!1}}function $u(){_u()}function _u(){Cu=ku=!1;var e=0;0!==Nu&&(function(){var e=window.event;return e&&"popstate"===e.type?e!==dd&&(dd=e,!0):(dd=null,!1)}()&&(e=Nu),Nu=0);for(var t=ie(),n=null,r=xu;null!==r;){var a=r.next,i=zu(r,t);0===i?(r.next=null,null===n?xu=a:n.next=a,null===a&&(wu=n)):(n=r,(0!==e||3&i)&&(Cu=!0)),r=a}Eu(e)}function zu(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,i=-62914561&e.pendingLanes;0<i;){var o=31-be(i),s=1<<o,l=a[o];-1===l?0!==(s&n)&&0===(s&r)||(a[o]=Ne(s,t)):l<=t&&(e.expiredLanes|=s),i&=~s}if(n=cc,n=Ce(e,e===(t=sc)?n:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle),r=e.callbackNode,0===n||e===t&&(2===uc||9===uc)||null!==e.cancelPendingCommit)return null!==r&&null!==r&&ne(r),e.callbackNode=null,e.callbackPriority=0;if(!(3&n)||Se(e,n)){if((t=n&-n)===e.callbackPriority)return t;switch(null!==r&&ne(r),Ae(n)){case 2:case 8:n=le;break;case 32:default:n=ce;break;case 268435456:n=de}return r=Tu.bind(null,e),n=te(n,r),e.callbackPriority=t,e.callbackNode=n,t}return null!==r&&null!==r&&ne(r),e.callbackPriority=2,e.callbackNode=null,2}function Tu(e,t){if(0!==_c&&5!==_c)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(du()&&e.callbackNode!==n)return null;var r=cc;return 0===(r=Ce(e,e===sc?r:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle))?null:(Uc(e,r,t),zu(e,ie()),null!=e.callbackNode&&e.callbackNode===n?Tu.bind(null,e):null)}function Pu(e,t){if(du())return null;Uc(e,t,!0)}function Au(){return 0===Nu&&(Nu=je()),Nu}function Mu(e){return null==e||"symbol"==typeof e||"boolean"==typeof e?null:"function"==typeof e?e:At(""+e)}function Iu(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}for(var Lu=0;Lu<Nr.length;Lu++){var Ou=Nr[Lu];jr(Ou.toLowerCase(),"on"+(Ou[0].toUpperCase()+Ou.slice(1)))}jr(br,"onAnimationEnd"),jr(yr,"onAnimationIteration"),jr(vr,"onAnimationStart"),jr("dblclick","onDoubleClick"),jr("focusin","onFocus"),jr("focusout","onBlur"),jr(xr,"onTransitionRun"),jr(wr,"onTransitionStart"),jr(kr,"onTransitionCancel"),jr(Cr,"onTransitionEnd"),Ze("onMouseEnter",["mouseout","mouseover"]),Ze("onMouseLeave",["mouseout","mouseover"]),Ze("onPointerEnter",["pointerout","pointerover"]),Ze("onPointerLeave",["pointerout","pointerover"]),Je("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Je("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Je("onBeforeInput",["compositionend","keypress","textInput","paste"]),Je("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Je("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Je("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ru="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Du=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ru));function Fu(e,t){t=!!(4&t);for(var n=0;n<e.length;n++){var r=e[n],a=r.event;r=r.listeners;e:{var i=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],l=s.instance,c=s.currentTarget;if(s=s.listener,l!==i&&a.isPropagationStopped())break e;i=s,a.currentTarget=c;try{i(a)}catch(e){ws(e)}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(e){ws(e)}a.currentTarget=null,i=l}}}}function Uu(e,t){var n=t[De];void 0===n&&(n=t[De]=new Set);var r=e+"__bubble";n.has(r)||(Wu(t,e,2,!1),n.add(r))}function qu(e,t,n){var r=0;t&&(r|=4),Wu(n,e,r,t)}var Bu="_reactListening"+Math.random().toString(36).slice(2);function Hu(e){if(!e[Bu]){e[Bu]=!0,Ye.forEach(function(t){"selectionchange"!==t&&(Du.has(t)||qu(t,!1,e),qu(t,!0,e))});var t=9===e.nodeType?e:e.ownerDocument;null===t||t[Bu]||(t[Bu]=!0,qu("selectionchange",!1,t))}}function Wu(e,t,n,r){switch(hm(t)){case 2:var a=sm;break;case 8:a=lm;break;default:a=cm}n=a.bind(null,t,n,e),a=void 0,!Bt||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(a=!0),r?void 0!==a?e.addEventListener(t,n,{capture:!0,passive:a}):e.addEventListener(t,n,!0):void 0!==a?e.addEventListener(t,n,{passive:a}):e.addEventListener(t,n,!1)}function Vu(e,t,n,r,a){var o=r;if(!(1&t||2&t||null===r))e:for(;;){if(null===r)return;var s=r.tag;if(3===s||4===s){var l=r.stateNode.containerInfo;if(l===a)break;if(4===s)for(s=r.return;null!==s;){var c=s.tag;if((3===c||4===c)&&s.stateNode.containerInfo===a)return;s=s.return}for(;null!==l;){if(null===(s=We(l)))return;if(5===(c=s.tag)||6===c||26===c||27===c){r=o=s;continue e}l=l.parentNode}}r=r.return}Ft(function(){var r=o,a=It(n),s=[];e:{var l=Sr.get(e);if(void 0!==l){var c=rn,u=e;switch(e){case"keypress":if(0===Qt(n))break e;case"keydown":case"keyup":c=vn;break;case"focusin":u="focus",c=un;break;case"focusout":u="blur",c=un;break;case"beforeblur":case"afterblur":c=un;break;case"click":if(2===n.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":c=ln;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":c=cn;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":c=wn;break;case br:case yr:case vr:c=dn;break;case Cr:c=kn;break;case"scroll":case"scrollend":c=on;break;case"wheel":c=Cn;break;case"copy":case"cut":case"paste":c=mn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=xn;break;case"toggle":case"beforetoggle":c=Sn}var d=!!(4&t),m=!d&&("scroll"===e||"scrollend"===e),h=d?null!==l?l+"Capture":null:l;d=[];for(var p,f=r;null!==f;){var g=f;if(p=g.stateNode,5!==(g=g.tag)&&26!==g&&27!==g||null===p||null===h||null!=(g=Ut(f,h))&&d.push(Ku(f,g,p)),m)break;f=f.return}0<d.length&&(l=new c(l,u,null,n,a),s.push({event:l,listeners:d}))}}if(!(7&t)){if(c="mouseout"===e||"pointerout"===e,(!(l="mouseover"===e||"pointerover"===e)||n===Mt||!(u=n.relatedTarget||n.fromElement)||!We(u)&&!u[Re])&&(c||l)&&(l=a.window===a?a:(l=a.ownerDocument)?l.defaultView||l.parentWindow:window,c?(c=r,null!==(u=(u=n.relatedTarget||n.toElement)?We(u):null)&&(m=i(u),d=u.tag,u!==m||5!==d&&27!==d&&6!==d)&&(u=null)):(c=null,u=r),c!==u)){if(d=ln,g="onMouseLeave",h="onMouseEnter",f="mouse","pointerout"!==e&&"pointerover"!==e||(d=xn,g="onPointerLeave",h="onPointerEnter",f="pointer"),m=null==c?l:Ke(c),p=null==u?l:Ke(u),(l=new d(g,f+"leave",c,n,a)).target=m,l.relatedTarget=p,g=null,We(a)===r&&((d=new d(h,f+"enter",u,n,a)).target=p,d.relatedTarget=m,g=d),m=g,c&&u)e:{for(h=u,f=0,p=d=c;p;p=Qu(p))f++;for(p=0,g=h;g;g=Qu(g))p++;for(;0<f-p;)d=Qu(d),f--;for(;0<p-f;)h=Qu(h),p--;for(;f--;){if(d===h||null!==h&&d===h.alternate)break e;d=Qu(d),h=Qu(h)}d=null}else d=null;null!==c&&Yu(s,l,c,d,!1),null!==u&&null!==m&&Yu(s,m,u,d,!0)}if("select"===(c=(l=r?Ke(r):window).nodeName&&l.nodeName.toLowerCase())||"input"===c&&"file"===l.type)var b=qn;else if(Ln(l))if(Bn)b=Jn;else{b=Yn;var y=Qn}else!(c=l.nodeName)||"input"!==c.toLowerCase()||"checkbox"!==l.type&&"radio"!==l.type?r&&zt(r.elementType)&&(b=qn):b=Xn;switch(b&&(b=b(e,r))?On(s,b,n,a):(y&&y(e,l,r),"focusout"===e&&r&&"number"===l.type&&null!=r.memoizedProps.value&&kt(l,"number",l.value)),y=r?Ke(r):window,e){case"focusin":(Ln(y)||"true"===y.contentEditable)&&(sr=y,lr=r,cr=null);break;case"focusout":cr=lr=sr=null;break;case"mousedown":ur=!0;break;case"contextmenu":case"mouseup":case"dragend":ur=!1,dr(s,n,a);break;case"selectionchange":if(or)break;case"keydown":case"keyup":dr(s,n,a)}var v;if(jn)e:{switch(e){case"compositionstart":var x="onCompositionStart";break e;case"compositionend":x="onCompositionEnd";break e;case"compositionupdate":x="onCompositionUpdate";break e}x=void 0}else Mn?Pn(e,n)&&(x="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(x="onCompositionStart");x&&(_n&&"ko"!==n.locale&&(Mn||"onCompositionStart"!==x?"onCompositionEnd"===x&&Mn&&(v=Gt()):(Vt="value"in(Wt=a)?Wt.value:Wt.textContent,Mn=!0)),0<(y=Gu(r,x)).length&&(x=new hn(x,e,null,n,a),s.push({event:x,listeners:y}),(v||null!==(v=An(n)))&&(x.data=v))),(v=$n?function(e,t){switch(e){case"compositionend":return An(t);case"keypress":return 32!==t.which?null:(Tn=!0,zn);case"textInput":return(e=t.data)===zn&&Tn?null:e;default:return null}}(e,n):function(e,t){if(Mn)return"compositionend"===e||!jn&&Pn(e,t)?(e=Gt(),Kt=Vt=Wt=null,Mn=!1,e):null;switch(e){case"paste":default:return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return _n&&"ko"!==t.locale?null:t.data}}(e,n))&&0<(x=Gu(r,"onBeforeInput")).length&&(y=new hn("onBeforeInput","beforeinput",null,n,a),s.push({event:y,listeners:x}),y.data=v),function(e,t,n,r,a){if("submit"===t&&n&&n.stateNode===a){var i=Mu((a[Oe]||null).action),o=r.submitter;o&&null!==(t=(t=o[Oe]||null)?Mu(t.formAction):o.getAttribute("formAction"))&&(i=t,o=null);var s=new rn("action","action",null,r,a);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(0!==Nu){var e=o?Iu(a,o):new FormData(a);Io(n,{pending:!0,data:e,method:a.method,action:i},null,e)}}else"function"==typeof i&&(s.preventDefault(),e=o?Iu(a,o):new FormData(a),Io(n,{pending:!0,data:e,method:a.method,action:i},i,e))},currentTarget:a}]})}}(s,e,r,n,a)}Fu(s,t)})}function Ku(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Gu(e,t){for(var n=t+"Capture",r=[];null!==e;){var a=e,i=a.stateNode;if(5!==(a=a.tag)&&26!==a&&27!==a||null===i||(null!=(a=Ut(e,n))&&r.unshift(Ku(e,a,i)),null!=(a=Ut(e,t))&&r.push(Ku(e,a,i))),3===e.tag)return r;e=e.return}return[]}function Qu(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag&&27!==e.tag);return e||null}function Yu(e,t,n,r,a){for(var i=t._reactName,o=[];null!==n&&n!==r;){var s=n,l=s.alternate,c=s.stateNode;if(s=s.tag,null!==l&&l===r)break;5!==s&&26!==s&&27!==s||null===c||(l=c,a?null!=(c=Ut(n,i))&&o.unshift(Ku(n,c,l)):a||null!=(c=Ut(n,i))&&o.push(Ku(n,c,l))),n=n.return}0!==o.length&&e.push({event:t,listeners:o})}var Xu=/\r\n?/g,Ju=/\u0000|\uFFFD/g;function Zu(e){return("string"==typeof e?e:""+e).replace(Xu,"\n").replace(Ju,"")}function ed(e,t){return t=Zu(t),Zu(e)===t}function td(){}function nd(e,t,n,a,i,o){switch(n){case"children":"string"==typeof a?"body"===t||"textarea"===t&&""===a||jt(e,a):("number"==typeof a||"bigint"==typeof a)&&"body"!==t&&jt(e,""+a);break;case"className":ot(e,"class",a);break;case"tabIndex":ot(e,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":ot(e,n,a);break;case"style":_t(e,a,o);break;case"data":if("object"!==t){ot(e,"data",a);break}case"src":case"href":if(""===a&&("a"!==t||"href"!==n)){e.removeAttribute(n);break}if(null==a||"function"==typeof a||"symbol"==typeof a||"boolean"==typeof a){e.removeAttribute(n);break}a=At(""+a),e.setAttribute(n,a);break;case"action":case"formAction":if("function"==typeof a){e.setAttribute(n,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}if("function"==typeof o&&("formAction"===n?("input"!==t&&nd(e,t,"name",i.name,i,null),nd(e,t,"formEncType",i.formEncType,i,null),nd(e,t,"formMethod",i.formMethod,i,null),nd(e,t,"formTarget",i.formTarget,i,null)):(nd(e,t,"encType",i.encType,i,null),nd(e,t,"method",i.method,i,null),nd(e,t,"target",i.target,i,null))),null==a||"symbol"==typeof a||"boolean"==typeof a){e.removeAttribute(n);break}a=At(""+a),e.setAttribute(n,a);break;case"onClick":null!=a&&(e.onclick=td);break;case"onScroll":null!=a&&Uu("scroll",e);break;case"onScrollEnd":null!=a&&Uu("scrollend",e);break;case"dangerouslySetInnerHTML":if(null!=a){if("object"!=typeof a||!("__html"in a))throw Error(r(61));if(null!=(n=a.__html)){if(null!=i.children)throw Error(r(60));e.innerHTML=n}}break;case"multiple":e.multiple=a&&"function"!=typeof a&&"symbol"!=typeof a;break;case"muted":e.muted=a&&"function"!=typeof a&&"symbol"!=typeof a;break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":case"autoFocus":break;case"xlinkHref":if(null==a||"function"==typeof a||"boolean"==typeof a||"symbol"==typeof a){e.removeAttribute("xlink:href");break}n=At(""+a),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":null!=a&&"function"!=typeof a&&"symbol"!=typeof a?e.setAttribute(n,""+a):e.removeAttribute(n);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":a&&"function"!=typeof a&&"symbol"!=typeof a?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":!0===a?e.setAttribute(n,""):!1!==a&&null!=a&&"function"!=typeof a&&"symbol"!=typeof a?e.setAttribute(n,a):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":null!=a&&"function"!=typeof a&&"symbol"!=typeof a&&!isNaN(a)&&1<=a?e.setAttribute(n,a):e.removeAttribute(n);break;case"rowSpan":case"start":null==a||"function"==typeof a||"symbol"==typeof a||isNaN(a)?e.removeAttribute(n):e.setAttribute(n,a);break;case"popover":Uu("beforetoggle",e),Uu("toggle",e),it(e,"popover",a);break;case"xlinkActuate":st(e,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":st(e,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":st(e,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":st(e,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":st(e,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":st(e,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":st(e,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":st(e,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":st(e,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":it(e,"is",a);break;case"innerText":case"textContent":break;default:(!(2<n.length)||"o"!==n[0]&&"O"!==n[0]||"n"!==n[1]&&"N"!==n[1])&&it(e,n=Tt.get(n)||n,a)}}function rd(e,t,n,a,i,o){switch(n){case"style":_t(e,a,o);break;case"dangerouslySetInnerHTML":if(null!=a){if("object"!=typeof a||!("__html"in a))throw Error(r(61));if(null!=(n=a.__html)){if(null!=i.children)throw Error(r(60));e.innerHTML=n}}break;case"children":"string"==typeof a?jt(e,a):("number"==typeof a||"bigint"==typeof a)&&jt(e,""+a);break;case"onScroll":null!=a&&Uu("scroll",e);break;case"onScrollEnd":null!=a&&Uu("scrollend",e);break;case"onClick":null!=a&&(e.onclick=td);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":case"innerText":case"textContent":break;default:Xe.hasOwnProperty(n)||("o"!==n[0]||"n"!==n[1]||(i=n.endsWith("Capture"),t=n.slice(2,i?n.length-7:void 0),"function"==typeof(o=null!=(o=e[Oe]||null)?o[n]:null)&&e.removeEventListener(t,o,i),"function"!=typeof a)?n in e?e[n]=a:!0===a?e.setAttribute(n,""):it(e,n,a):("function"!=typeof o&&null!==o&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,a,i)))}}function ad(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Uu("error",e),Uu("load",e);var a,i=!1,o=!1;for(a in n)if(n.hasOwnProperty(a)){var s=n[a];if(null!=s)switch(a){case"src":i=!0;break;case"srcSet":o=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:nd(e,t,a,s,n,null)}}return o&&nd(e,t,"srcSet",n.srcSet,n,null),void(i&&nd(e,t,"src",n.src,n,null));case"input":Uu("invalid",e);var l=a=s=o=null,c=null,u=null;for(i in n)if(n.hasOwnProperty(i)){var d=n[i];if(null!=d)switch(i){case"name":o=d;break;case"type":s=d;break;case"checked":c=d;break;case"defaultChecked":u=d;break;case"value":a=d;break;case"defaultValue":l=d;break;case"children":case"dangerouslySetInnerHTML":if(null!=d)throw Error(r(137,t));break;default:nd(e,t,i,d,n,null)}}return wt(e,a,l,c,u,s,o,!1),void ft(e);case"select":for(o in Uu("invalid",e),i=s=a=null,n)if(n.hasOwnProperty(o)&&null!=(l=n[o]))switch(o){case"value":a=l;break;case"defaultValue":s=l;break;case"multiple":i=l;default:nd(e,t,o,l,n,null)}return t=a,n=s,e.multiple=!!i,void(null!=t?Ct(e,!!i,t,!1):null!=n&&Ct(e,!!i,n,!0));case"textarea":for(s in Uu("invalid",e),a=o=i=null,n)if(n.hasOwnProperty(s)&&null!=(l=n[s]))switch(s){case"value":i=l;break;case"defaultValue":o=l;break;case"children":a=l;break;case"dangerouslySetInnerHTML":if(null!=l)throw Error(r(91));break;default:nd(e,t,s,l,n,null)}return Nt(e,i,o,a),void ft(e);case"option":for(c in n)n.hasOwnProperty(c)&&null!=(i=n[c])&&("selected"===c?e.selected=i&&"function"!=typeof i&&"symbol"!=typeof i:nd(e,t,c,i,n,null));return;case"dialog":Uu("beforetoggle",e),Uu("toggle",e),Uu("cancel",e),Uu("close",e);break;case"iframe":case"object":Uu("load",e);break;case"video":case"audio":for(i=0;i<Ru.length;i++)Uu(Ru[i],e);break;case"image":Uu("error",e),Uu("load",e);break;case"details":Uu("toggle",e);break;case"embed":case"source":case"link":Uu("error",e),Uu("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(u in n)if(n.hasOwnProperty(u)&&null!=(i=n[u]))switch(u){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:nd(e,t,u,i,n,null)}return;default:if(zt(t)){for(d in n)n.hasOwnProperty(d)&&void 0!==(i=n[d])&&rd(e,t,d,i,n,void 0);return}}for(l in n)n.hasOwnProperty(l)&&null!=(i=n[l])&&nd(e,t,l,i,n,null)}var id=null,od=null;function sd(e){return 9===e.nodeType?e:e.ownerDocument}function ld(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function cd(e,t){if(0===e)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return 1===e&&"foreignObject"===t?0:e}function ud(e,t){return"textarea"===e||"noscript"===e||"string"==typeof t.children||"number"==typeof t.children||"bigint"==typeof t.children||"object"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var dd=null,md="function"==typeof setTimeout?setTimeout:void 0,hd="function"==typeof clearTimeout?clearTimeout:void 0,pd="function"==typeof Promise?Promise:void 0,fd="function"==typeof queueMicrotask?queueMicrotask:void 0!==pd?function(e){return pd.resolve(null).then(e).catch(gd)}:md;function gd(e){setTimeout(function(){throw e})}function bd(e){return"head"===e}function yd(e,t){var n=t,r=0,a=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&8===i.nodeType)if("/$"===(n=i.data)){if(0<r&&8>r){n=r;var o=e.ownerDocument;if(1&n&&Nd(o.documentElement),2&n&&Nd(o.body),4&n)for(Nd(n=o.head),o=n.firstChild;o;){var s=o.nextSibling,l=o.nodeName;o[Be]||"SCRIPT"===l||"STYLE"===l||"LINK"===l&&"stylesheet"===o.rel.toLowerCase()||n.removeChild(o),o=s}}if(0===a)return e.removeChild(i),void Tm(t);a--}else"$"===n||"$?"===n||"$!"===n?a++:r=n.charCodeAt(0)-48;else r=0;n=i}while(n);Tm(t)}function vd(e){var t=e.firstChild;for(t&&10===t.nodeType&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":vd(n),He(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if("stylesheet"===n.rel.toLowerCase())continue}e.removeChild(n)}}function xd(e){return"$!"===e.data||"$?"===e.data&&"complete"===e.ownerDocument.readyState}function wd(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t||"F!"===t||"F"===t)break;if("/$"===t)return null}}return e}var kd=null;function Cd(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n){if(0===t)return e;t--}else"/$"===n&&t++}e=e.previousSibling}return null}function Sd(e,t,n){switch(t=sd(n),e){case"html":if(!(e=t.documentElement))throw Error(r(452));return e;case"head":if(!(e=t.head))throw Error(r(453));return e;case"body":if(!(e=t.body))throw Error(r(454));return e;default:throw Error(r(451))}}function Nd(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);He(e)}var jd=new Map,Ed=new Set;function $d(e){return"function"==typeof e.getRootNode?e.getRootNode():9===e.nodeType?e:e.ownerDocument}var _d=D.d;D.d={f:function(){var e=_d.f(),t=Wc();return e||t},r:function(e){var t=Ve(e);null!==t&&5===t.tag&&"form"===t.type?Oo(t):_d.r(e)},D:function(e){_d.D(e),Td("dns-prefetch",e,null)},C:function(e,t){_d.C(e,t),Td("preconnect",e,t)},L:function(e,t,n){_d.L(e,t,n);var r=zd;if(r&&e&&t){var a='link[rel="preload"][as="'+vt(t)+'"]';"image"===t&&n&&n.imageSrcSet?(a+='[imagesrcset="'+vt(n.imageSrcSet)+'"]',"string"==typeof n.imageSizes&&(a+='[imagesizes="'+vt(n.imageSizes)+'"]')):a+='[href="'+vt(e)+'"]';var i=a;switch(t){case"style":i=Ad(e);break;case"script":i=Ld(e)}jd.has(i)||(e=u({rel:"preload",href:"image"===t&&n&&n.imageSrcSet?void 0:e,as:t},n),jd.set(i,e),null!==r.querySelector(a)||"style"===t&&r.querySelector(Md(i))||"script"===t&&r.querySelector(Od(i))||(ad(t=r.createElement("link"),"link",e),Qe(t),r.head.appendChild(t)))}},m:function(e,t){_d.m(e,t);var n=zd;if(n&&e){var r=t&&"string"==typeof t.as?t.as:"script",a='link[rel="modulepreload"][as="'+vt(r)+'"][href="'+vt(e)+'"]',i=a;switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":i=Ld(e)}if(!jd.has(i)&&(e=u({rel:"modulepreload",href:e},t),jd.set(i,e),null===n.querySelector(a))){switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(Od(i)))return}ad(r=n.createElement("link"),"link",e),Qe(r),n.head.appendChild(r)}}},X:function(e,t){_d.X(e,t);var n=zd;if(n&&e){var r=Ge(n).hoistableScripts,a=Ld(e),i=r.get(a);i||((i=n.querySelector(Od(a)))||(e=u({src:e,async:!0},t),(t=jd.get(a))&&Ud(e,t),Qe(i=n.createElement("script")),ad(i,"link",e),n.head.appendChild(i)),i={type:"script",instance:i,count:1,state:null},r.set(a,i))}},S:function(e,t,n){_d.S(e,t,n);var r=zd;if(r&&e){var a=Ge(r).hoistableStyles,i=Ad(e);t=t||"default";var o=a.get(i);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Md(i)))s.loading=5;else{e=u({rel:"stylesheet",href:e,"data-precedence":t},n),(n=jd.get(i))&&Fd(e,n);var l=o=r.createElement("link");Qe(l),ad(l,"link",e),l._p=new Promise(function(e,t){l.onload=e,l.onerror=t}),l.addEventListener("load",function(){s.loading|=1}),l.addEventListener("error",function(){s.loading|=2}),s.loading|=4,Dd(o,t,r)}o={type:"stylesheet",instance:o,count:1,state:s},a.set(i,o)}}},M:function(e,t){_d.M(e,t);var n=zd;if(n&&e){var r=Ge(n).hoistableScripts,a=Ld(e),i=r.get(a);i||((i=n.querySelector(Od(a)))||(e=u({src:e,async:!0,type:"module"},t),(t=jd.get(a))&&Ud(e,t),Qe(i=n.createElement("script")),ad(i,"link",e),n.head.appendChild(i)),i={type:"script",instance:i,count:1,state:null},r.set(a,i))}}};var zd="undefined"==typeof document?null:document;function Td(e,t,n){var r=zd;if(r&&"string"==typeof t&&t){var a=vt(t);a='link[rel="'+e+'"][href="'+a+'"]',"string"==typeof n&&(a+='[crossorigin="'+n+'"]'),Ed.has(a)||(Ed.add(a),e={rel:e,crossOrigin:n,href:t},null===r.querySelector(a)&&(ad(t=r.createElement("link"),"link",e),Qe(t),r.head.appendChild(t)))}}function Pd(e,t,n,a){var i,o,s,l,c=(c=G.current)?$d(c):null;if(!c)throw Error(r(446));switch(e){case"meta":case"title":return null;case"style":return"string"==typeof n.precedence&&"string"==typeof n.href?(t=Ad(n.href),(a=(n=Ge(c).hoistableStyles).get(t))||(a={type:"style",instance:null,count:0,state:null},n.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if("stylesheet"===n.rel&&"string"==typeof n.href&&"string"==typeof n.precedence){e=Ad(n.href);var u=Ge(c).hoistableStyles,d=u.get(e);if(d||(c=c.ownerDocument||c,d={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,d),(u=c.querySelector(Md(e)))&&!u._p&&(d.instance=u,d.state.loading=5),jd.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},jd.set(e,n),u||(i=c,o=e,s=n,l=d.state,i.querySelector('link[rel="preload"][as="style"]['+o+"]")?l.loading=1:(o=i.createElement("link"),l.preload=o,o.addEventListener("load",function(){return l.loading|=1}),o.addEventListener("error",function(){return l.loading|=2}),ad(o,"link",s),Qe(o),i.head.appendChild(o))))),t&&null===a)throw Error(r(528,""));return d}if(t&&null!==a)throw Error(r(529,""));return null;case"script":return t=n.async,"string"==typeof(n=n.src)&&t&&"function"!=typeof t&&"symbol"!=typeof t?(t=Ld(n),(a=(n=Ge(c).hoistableScripts).get(t))||(a={type:"script",instance:null,count:0,state:null},n.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,e))}}function Ad(e){return'href="'+vt(e)+'"'}function Md(e){return'link[rel="stylesheet"]['+e+"]"}function Id(e){return u({},e,{"data-precedence":e.precedence,precedence:null})}function Ld(e){return'[src="'+vt(e)+'"]'}function Od(e){return"script[async]"+e}function Rd(e,t,n){if(t.count++,null===t.instance)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+vt(n.href)+'"]');if(a)return t.instance=a,Qe(a),a;var i=u({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return Qe(a=(e.ownerDocument||e).createElement("style")),ad(a,"style",i),Dd(a,n.precedence,e),t.instance=a;case"stylesheet":i=Ad(n.href);var o=e.querySelector(Md(i));if(o)return t.state.loading|=4,t.instance=o,Qe(o),o;a=Id(n),(i=jd.get(i))&&Fd(a,i),Qe(o=(e.ownerDocument||e).createElement("link"));var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),ad(o,"link",a),t.state.loading|=4,Dd(o,n.precedence,e),t.instance=o;case"script":return o=Ld(n.src),(i=e.querySelector(Od(o)))?(t.instance=i,Qe(i),i):(a=n,(i=jd.get(o))&&Ud(a=u({},n),i),Qe(i=(e=e.ownerDocument||e).createElement("script")),ad(i,"link",a),e.head.appendChild(i),t.instance=i);case"void":return null;default:throw Error(r(443,t.type))}else"stylesheet"===t.type&&!(4&t.state.loading)&&(a=t.instance,t.state.loading|=4,Dd(a,n.precedence,e));return t.instance}function Dd(e,t,n){for(var r=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),a=r.length?r[r.length-1]:null,i=a,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)i=s;else if(i!==a)break}i?i.parentNode.insertBefore(e,i.nextSibling):(t=9===n.nodeType?n.head:n).insertBefore(e,t.firstChild)}function Fd(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.title&&(e.title=t.title)}function Ud(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.integrity&&(e.integrity=t.integrity)}var qd=null;function Bd(e,t,n){if(null===qd){var r=new Map,a=qd=new Map;a.set(n,r)}else(r=(a=qd).get(n))||(r=new Map,a.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),a=0;a<n.length;a++){var i=n[a];if(!(i[Be]||i[Le]||"link"===e&&"stylesheet"===i.getAttribute("rel"))&&"http://www.w3.org/2000/svg"!==i.namespaceURI){var o=i.getAttribute(t)||"";o=e+o;var s=r.get(o);s?s.push(i):r.set(o,[i])}}return r}function Hd(e,t,n){(e=e.ownerDocument||e).head.insertBefore(n,"title"===t?e.querySelector("head > title"):null)}function Wd(e){return!!("stylesheet"!==e.type||3&e.state.loading)}var Vd=null;function Kd(){}function Gd(){if(this.count--,0===this.count)if(this.stylesheets)Yd(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}var Qd=null;function Yd(e,t){e.stylesheets=null,null!==e.unsuspend&&(e.count++,Qd=new Map,t.forEach(Xd,e),Qd=null,Gd.call(e))}function Xd(e,t){if(!(4&t.state.loading)){var n=Qd.get(e);if(n)var r=n.get(null);else{n=new Map,Qd.set(e,n);for(var a=e.querySelectorAll("link[data-precedence],style[data-precedence]"),i=0;i<a.length;i++){var o=a[i];"LINK"!==o.nodeName&&"not all"===o.getAttribute("media")||(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}o=(a=t.instance).getAttribute("data-precedence"),(i=n.get(o)||r)===r&&n.set(null,a),n.set(o,a),this.count++,r=Gd.bind(this),a.addEventListener("load",r),a.addEventListener("error",r),i?i.parentNode.insertBefore(a,i.nextSibling):(e=9===e.nodeType?e.head:e).insertBefore(a,e.firstChild),t.state.loading|=4}}var Jd={$$typeof:N,Provider:null,Consumer:null,_currentValue:F,_currentValue2:F,_threadCount:0};function Zd(e,t,n,r,a,i,o,s){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=$e(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=$e(0),this.hiddenUpdates=$e(null),this.identifierPrefix=r,this.onUncaughtError=a,this.onCaughtError=i,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=s,this.incompleteTransitions=new Map}function em(e,t,n,r,a,i,o,s,l,c,u,d){return e=new Zd(e,t,n,o,s,l,c,d),t=1,!0===i&&(t|=24),i=Fr(3,null,null,t),e.current=i,i.stateNode=e,(t=Oa()).refCount++,e.pooledCache=t,t.refCount++,i.memoizedState={element:r,isDehydrated:n,cache:t},oi(i),e}function tm(e){return e?e=Rr:Rr}function nm(e,t,n,r,a,i){a=tm(a),null===r.context?r.context=a:r.pendingContext=a,(r=li(t)).payload={element:n},null!==(i=void 0===i?null:i)&&(r.callback=i),null!==(n=ci(e,r,t))&&(Fc(n,0,t),ui(n,e,t))}function rm(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function am(e,t){rm(e,t),(e=e.alternate)&&rm(e,t)}function im(e){if(13===e.tag){var t=Ir(e,67108864);null!==t&&Fc(t,0,67108864),am(e,67108864)}}var om=!0;function sm(e,t,n,r){var a=R.T;R.T=null;var i=D.p;try{D.p=2,cm(e,t,n,r)}finally{D.p=i,R.T=a}}function lm(e,t,n,r){var a=R.T;R.T=null;var i=D.p;try{D.p=8,cm(e,t,n,r)}finally{D.p=i,R.T=a}}function cm(e,t,n,r){if(om){var a=um(r);if(null===a)Vu(e,t,r,dm,n),km(e,r);else if(function(e,t,n,r,a){switch(t){case"focusin":return fm=Cm(fm,e,t,n,r,a),!0;case"dragenter":return gm=Cm(gm,e,t,n,r,a),!0;case"mouseover":return bm=Cm(bm,e,t,n,r,a),!0;case"pointerover":var i=a.pointerId;return ym.set(i,Cm(ym.get(i)||null,e,t,n,r,a)),!0;case"gotpointercapture":return i=a.pointerId,vm.set(i,Cm(vm.get(i)||null,e,t,n,r,a)),!0}return!1}(a,e,t,n,r))r.stopPropagation();else if(km(e,r),4&t&&-1<wm.indexOf(e)){for(;null!==a;){var i=Ve(a);if(null!==i)switch(i.tag){case 3:if((i=i.stateNode).current.memoizedState.isDehydrated){var o=ke(i.pendingLanes);if(0!==o){var s=i;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var l=1<<31-be(o);s.entanglements[1]|=l,o&=~l}ju(i),!(6&oc)&&(jc=ie()+500,Eu(0))}}break;case 13:null!==(s=Ir(i,2))&&Fc(s,0,2),Wc(),am(i,2)}if(null===(i=um(r))&&Vu(e,t,r,dm,n),i===a)break;a=i}null!==a&&r.stopPropagation()}else Vu(e,t,r,null,n)}}function um(e){return mm(e=It(e))}var dm=null;function mm(e){if(dm=null,null!==(e=We(e))){var t=i(e);if(null===t)e=null;else{var n=t.tag;if(13===n){if(null!==(e=o(t)))return e;e=null}else if(3===n){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return dm=e,null}function hm(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(oe()){case se:return 2;case le:return 8;case ce:case ue:return 32;case de:return 268435456;default:return 32}default:return 32}}var pm=!1,fm=null,gm=null,bm=null,ym=new Map,vm=new Map,xm=[],wm="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function km(e,t){switch(e){case"focusin":case"focusout":fm=null;break;case"dragenter":case"dragleave":gm=null;break;case"mouseover":case"mouseout":bm=null;break;case"pointerover":case"pointerout":ym.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":vm.delete(t.pointerId)}}function Cm(e,t,n,r,a,i){return null===e||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[a]},null!==t&&null!==(t=Ve(t))&&im(t),e):(e.eventSystemFlags|=r,t=e.targetContainers,null!==a&&-1===t.indexOf(a)&&t.push(a),e)}function Sm(e){var t=We(e.target);if(null!==t){var n=i(t);if(null!==n)if(13===(t=n.tag)){if(null!==(t=o(n)))return e.blockedOn=t,void function(e,t){var n=D.p;try{return D.p=e,t()}finally{D.p=n}}(e.priority,function(){if(13===n.tag){var e=Rc();e=Pe(e);var t=Ir(n,e);null!==t&&Fc(t,0,e),am(n,e)}})}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function Nm(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=um(e.nativeEvent);if(null!==n)return null!==(t=Ve(n))&&im(t),e.blockedOn=n,!1;var r=new(n=e.nativeEvent).constructor(n.type,n);Mt=r,n.target.dispatchEvent(r),Mt=null,t.shift()}return!0}function jm(e,t,n){Nm(e)&&n.delete(t)}function Em(){pm=!1,null!==fm&&Nm(fm)&&(fm=null),null!==gm&&Nm(gm)&&(gm=null),null!==bm&&Nm(bm)&&(bm=null),ym.forEach(jm),vm.forEach(jm)}function $m(t,n){t.blockedOn===n&&(t.blockedOn=null,pm||(pm=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Em)))}var _m=null;function zm(t){_m!==t&&(_m=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){_m===t&&(_m=null);for(var e=0;e<t.length;e+=3){var n=t[e],r=t[e+1],a=t[e+2];if("function"!=typeof r){if(null===mm(r||n))continue;break}var i=Ve(n);null!==i&&(t.splice(e,3),e-=3,Io(i,{pending:!0,data:a,method:n.method,action:r},r,a))}}))}function Tm(e){function t(t){return $m(t,e)}null!==fm&&$m(fm,e),null!==gm&&$m(gm,e),null!==bm&&$m(bm,e),ym.forEach(t),vm.forEach(t);for(var n=0;n<xm.length;n++){var r=xm[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<xm.length&&null===(n=xm[0]).blockedOn;)Sm(n),null===n.blockedOn&&xm.shift();if(null!=(n=(e.ownerDocument||e).$$reactFormReplay))for(r=0;r<n.length;r+=3){var a=n[r],i=n[r+1],o=a[Oe]||null;if("function"==typeof i)o||zm(n);else if(o){var s=null;if(i&&i.hasAttribute("formAction")){if(a=i,o=i[Oe]||null)s=o.formAction;else if(null!==mm(a))continue}else s=o.action;"function"==typeof s?n[r+1]=s:(n.splice(r,3),r-=3),zm(n)}}}function Pm(e){this._internalRoot=e}function Am(e){this._internalRoot=e}Am.prototype.render=Pm.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(r(409));nm(t.current,Rc(),e,t,null,null)},Am.prototype.unmount=Pm.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;nm(e.current,2,null,e,null,null),Wc(),t[Re]=null}},Am.prototype.unstable_scheduleHydration=function(e){if(e){var t=Me();e={blockedOn:null,target:e,priority:t};for(var n=0;n<xm.length&&0!==t&&t<xm[n].priority;n++);xm.splice(n,0,e),0===n&&Sm(e)}};var Mm=t.version;if("19.1.1"!==Mm)throw Error(r(527,Mm,"19.1.1"));D.findDOMNode=function(e){var t=e._reactInternals;if(void 0===t){if("function"==typeof e.render)throw Error(r(188));throw e=Object.keys(e).join(","),Error(r(268,e))}return e=function(e){var t=e.alternate;if(!t){if(null===(t=i(e)))throw Error(r(188));return t!==e?null:e}for(var n=e,a=t;;){var o=n.return;if(null===o)break;var 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),null===(e=null!==e?c(e):null)?null:e.stateNode};var Im={bundleType:0,version:"19.1.1",rendererPackageName:"react-dom",currentDispatcherRef:R,reconcilerVersion:"19.1.1"};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var Lm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Lm.isDisabled&&Lm.supportsFiber)try{pe=Lm.inject(Im),fe=Lm}catch(e){}}return h.createRoot=function(e,t){if(!a(e))throw Error(r(299));var n=!1,i="",o=ks,s=Cs,l=Ss;return null!=t&&(!0===t.unstable_strictMode&&(n=!0),void 0!==t.identifierPrefix&&(i=t.identifierPrefix),void 0!==t.onUncaughtError&&(o=t.onUncaughtError),void 0!==t.onCaughtError&&(s=t.onCaughtError),void 0!==t.onRecoverableError&&(l=t.onRecoverableError),void 0!==t.unstable_transitionCallbacks&&t.unstable_transitionCallbacks),t=em(e,1,!1,null,0,n,i,o,s,l,0,null),e[Re]=t.current,Hu(e),new Pm(t)},h.hydrateRoot=function(e,t,n){if(!a(e))throw Error(r(299));var i=!1,o="",s=ks,l=Cs,c=Ss,u=null;return null!=n&&(!0===n.unstable_strictMode&&(i=!0),void 0!==n.identifierPrefix&&(o=n.identifierPrefix),void 0!==n.onUncaughtError&&(s=n.onUncaughtError),void 0!==n.onCaughtError&&(l=n.onCaughtError),void 0!==n.onRecoverableError&&(c=n.onRecoverableError),void 0!==n.unstable_transitionCallbacks&&n.unstable_transitionCallbacks,void 0!==n.formState&&(u=n.formState)),(t=em(e,1,!0,t,0,i,o,s,l,c,0,u)).context=tm(null),n=t.current,(o=li(i=Pe(i=Rc()))).callback=null,ci(n,o,i),n=i,t.current.lanes=n,_e(t,n),ju(t),e[Re]=t.current,Hu(e),new Am(t)},h.version="19.1.1",h}()),m.exports),E={exports:{}},$={},_=(N||(N=1,E.exports=function(){if(S)return $;S=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 $.Fragment=t,$.jsx=n,$.jsxs=n,$}()),E.exports);const z=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 T(e={}){const{useContainerQuery:t=!1,containerElement:n=null}=e,[r,a]=l.useState(()=>{const e=t&&n?z.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:z.supportsContainerQueries}}});l.useEffect(()=>{if("undefined"==typeof window)return;const e=()=>{const e=window.innerWidth,r=window.innerHeight,i=t&&n?z.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:z.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 P({tabs:e,active:t,onChange:n}){const{isMobile:r,isTouch:a}=T();return _.jsx("div",{className:"limbo-tabs "+(r?"limbo-tabs--mobile":""),role:"tablist","aria-label":"Opciones de navegación",style:{...r&&{overflowX:"auto",WebkitOverflowScrolling:"touch",scrollbarWidth:"none",msOverflowStyle:"none"}},children:e.map(i=>{const o=t===i.id;return!o&&i.hideNonActive?null:_.jsx("button",{"data-tab-id":i.id,onClick:()=>n(i.id),onKeyDown:t=>((t,r)=>{const a=e.findIndex(e=>e.id===r);let i=a;switch(t.key){case"ArrowLeft":case"ArrowUp":t.preventDefault(),i=a>0?a-1:e.length-1;break;case"ArrowRight":case"ArrowDown":t.preventDefault(),i=a<e.length-1?a+1:0;break;case"Home":t.preventDefault(),i=0;break;case"End":t.preventDefault(),i=e.length-1;break;case"Enter":case" ":return t.preventDefault(),void n(r);default:return}const o=e[i];o&&!o.hideNonActive&&(n(o.id),setTimeout(()=>{const e=document.querySelector(`[data-tab-id="${o.id}"]`);e&&e.focus()},0))})(t,i.id),className:`limbo-tab ${o?"active":""} ${r?"limbo-tab--mobile":""}`,role:"tab","aria-selected":o,"aria-controls":`tabpanel-${i.id}`,tabIndex:o?0:-1,id:`tab-${i.id}`,style:{...r&&{minWidth:"120px",minHeight:"44px",padding:"12px 16px",flexShrink:0,fontSize:"16px"},...a&&{touchAction:"manipulation",WebkitTapHighlightColor:"transparent"}},children:i.label},i.id)})})}let A={publicKey:null,token:null,authMode:null,tokenEndpoint:null,tokenProvider:null,prod:!1};function M({prod:e=!1}={}){return e?"https://limbo.lefebvre.com":"https://led-dev-limbo-dev.eu.els.local"}async function I({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||A.prod,c=await async function({isFormData:e=!1,useJWT:t=!0,customHeaders:n={}}={}){const r={"Access-Control-Allow-Origin":"*"};e||(r["Content-Type"]="application/json");let a=A.token;if(t){if("jwt"===A.authMode&&A.tokenProvider&&!a)try{console.log("🔑 Calling tokenProvider..."),a=await A.tokenProvider(),console.log("✅ Token obtained from tokenProvider"),A.token=a}catch(e){throw console.error("❌ tokenProvider failed:",e),new Error("Failed to obtain token from tokenProvider: "+e.message)}else if("session"===A.authMode&&!a)try{const e=M(A),t=A.tokenEndpoint||"/auth/token",n=await fetch(`${e}${t}`,{method:"POST",headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":"*"},body:JSON.stringify({public_key:A.publicKey}),credentials:"include"});if(!n.ok)throw new Error(`Session auth failed: ${n.status}`);a=(await n.json()).token,A.token=a}catch(e){throw console.error("❌ Session authentication failed:",e),new Error("Failed to authenticate with session. User must be logged in.")}a?r.Authorization=`Bearer ${a}`:console.warn("⚠️ No JWT token available:",{authMode:A.authMode,hasPublicKey:!!A.publicKey,hasTokenProvider:!!A.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(`${M({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(e){throw new Error(`API Error: ${e.message}`)}}function L(){const e={...A};return e?.prod?"https://limbo.lefebvre.com":"http://localhost"}function O(e){return e?.id?`${L()}/api/assets/${e.id}/download`:null}function R(e){return e?e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/")?`${L()}${e}`:e:null}function D(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:R(e.url),expires_at:e.expires_at,created_at:e.created_at})):[]}function F(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 U="/api";async function q(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&&(D(e.variants)||D(e.image_variants))||[],url:R(e.master_url||e.master?.url_signed||e.urls?.original||e.url)||O(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 I({endpoint:n,method:"GET",basePath:U,useJWT:!0}))}catch(e){throw F(e)}}async function B(e,t=null,n=!1){try{const r=new FormData;return r.append("file",e),t&&r.append("uploaded_by",t),n&&r.append("store_original",n.toString()),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:R(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 I({endpoint:"/assets",method:"POST",body:r,basePath:U,isFormData:!0,useJWT:!0}))}catch(e){throw F(e)}}async function H(e,{variant_name:t,width:n,height:r,crop_params:a,preset_aspect:i=null,preset_size:o=null,output_format:s="webp"}){try{const l=[{name:t,width:n,height:r,output_format:s,crop_params:a}];return i&&(l[0].preset_aspect=i),o&&(l[0].preset_size=o),function(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}))}}}(await I({endpoint:`/assets/${e}/variants`,method:"POST",body:{variants:l,async:!1},basePath:U,useJWT:!0}))}catch(e){throw F(e)}}function W(){const[e,t]=l.useState({}),[n,r]=l.useState({}),[a,i]=l.useState({}),o=l.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 async function(e){try{const n=await I({endpoint:`/assets/${e}/variants`,method:"GET",basePath:U,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:R(e.master_url||e.master?.url_signed||e.urls?.original||e.url)||O(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(e){throw F(e)}var t}(a),n=e?.result||[];return t(e=>({...e,[a]:n})),n}catch(e){return console.error("Error loading variants:",e),i(t=>({...t,[a]:e.message})),[]}finally{r(e=>({...e,[a]:!1}))}}},[e,n]),s=l.useCallback(t=>e[t]||[],[e]),c=l.useCallback(e=>n[e]||!1,[n]),u=l.useCallback(e=>a[e]||null,[a]),d=l.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=l.useCallback(async e=>(d(e),await o(e)),[d,o]),h=l.useCallback(async(e,n)=>{try{return await async function(e,t){try{return await I({endpoint:`/assets/${e}/variants/${t}`,method:"DELETE",basePath:U,useJWT:!0})}catch(e){throw F(e)}}(e,n),t(t=>{const r=t[e]||[];return{...t,[e]:r.filter(e=>e.id!==n)}}),{success:!0}}catch(e){return console.error("Error deleting variant:",e),{success:!1,error:e.message}}},[]);return{loadVariants:o,getVariants:s,isLoading:c,getError:u,clearVariants:d,refreshVariants:m,removeVariant:h}}function V({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:u,getVariants:d,isLoading:m,getError:h,removeVariant:p}=W(),f=window.limboCore?.accessibilityManager,[g,b]=c.useState(null),[y,v]=c.useState(null),x=(window.limboCore?.config?.getGlobal()||{}).interaction||{allowSelection:!1,allowCropping:!0},w=x.allowSelection&&s.select&&r,k=x.allowCropping&&s.crop&&i,C=s.copy,S=s.download,N=s.delete,[j,E]=c.useState(new Set),$=c.useMemo(()=>e?.variants||[],[e?.variants]),z=d(e?.id),T=$.length>0?$:z,P=0===$.length&&m(e?.id),A=0===$.length?h(e?.id):null;return l.useEffect(()=>{!t||!e?.id||e?.variants&&0!==e.variants.length||u(e.id)},[t,e?.id,e?.variants,u]),c.useEffect(()=>{t&&E(new Set)},[t]),t?_.jsx("div",{className:"limbo-modal-overlay",onClick:n,role:"dialog","aria-modal":"true","aria-labelledby":"variants-modal-title",children:_.jsxs("div",{className:"limbo-modal-content limbo-variants-modal",onClick:e=>e.stopPropagation(),children:[_.jsxs("div",{className:"limbo-modal-header",children:[_.jsxs("h2",{id:"variants-modal-title",children:["Recortes de ",e?.filename]}),_.jsx("button",{className:"limbo-modal-close",onClick:n,"aria-label":"Cerrar modal de recortes",children:"✕"})]}),g&&_.jsx("div",{className:`limbo-variants-message limbo-variants-message--${y} mt-1`,role:"alert",style:{padding:"12px 20px",margin:"0 20px 15px 20px",borderRadius:"4px",backgroundColor:"success"===y?"#d4edda":"#f8d7da",color:"success"===y?"#155724":"#721c24",border:"1px solid "+("success"===y?"#c3e6cb":"#f5c6cb")},children:g}),_.jsx("div",{className:"limbo-modal-body",children:P?_.jsxs("div",{className:"limbo-variants-loading",children:[_.jsx("div",{className:"limbo-loader"}),_.jsx("p",{children:"Cargando recortes..."})]}):A?_.jsxs("div",{className:"limbo-variants-error",children:[_.jsxs("p",{children:["Error al cargar recortes: ",A]}),_.jsx("button",{onClick:()=>u(e.id),className:"btn btn-primary",children:"Reintentar"})]}):0===T.length?_.jsxs("div",{className:"limbo-variants-empty",children:[_.jsx("p",{children:"Esta imagen no tiene recortes aún."}),_.jsx("small",{children:"Los recortes aparecerán aquí después de hacer recortes o redimensionados."})]}):_.jsxs(_.Fragment,{children:[_.jsxs("div",{className:"limbo-variant-section",children:[_.jsx("h3",{children:"Imagen original"}),_.jsxs("div",{onClick:()=>{f?.announce(`Abriendo imagen original ${e.filename} en nueva pestaña`),window.open(e.url,"_blank")},className:"limbo-variant-card limbo-variant-original cursor-pointer",children:[_.jsx("div",{className:"limbo-variant-preview",children:_.jsx("img",{src:e.url,alt:e.filename,loading:"lazy"})}),_.jsxs("div",{className:"limbo-variant-info",children:[_.jsx("div",{className:"limbo-variant-name",children:e.filename}),_.jsxs("div",{className:"limbo-variant-meta",children:[_.jsxs("span",{children:[e.width,"×",e.height]}),_.jsxs("span",{children:[Math.round(e.file_size/1024)," KB"]})]})]}),_.jsxs("div",{className:"limbo-variant-actions",children:[w&&_.jsx("button",{className:"btn btn-success btn-sm",onClick:t=>{t.stopPropagation(),r?.(e),n?.()},title:"Seleccionar original",children:"Seleccionar"}),k&&_.jsx("button",{className:"btn btn-crop btn-sm",onClick:t=>{t.stopPropagation(),i&&(f?.announce(`Abriendo herramienta de recorte para ${e.filename}`),i(e),n?.())},title:"Recortar imagen",children:_.jsx("span",{className:"icon icon-scissors-white icon--sm"})}),C&&_.jsx("button",{className:"btn btn-secondary btn-sm",onClick:t=>{t.stopPropagation(),(async()=>{try{await navigator.clipboard.writeText(e.url),f?.announce("URL de imagen original copiada")}catch(e){console.error("Error copying original URL:",e),f?.announceError("Error al copiar URL")}})()},title:"Copiar URL",children:_.jsx("span",{className:"icon icon-copy-white icon--sm"})}),S&&_.jsx("button",{className:"btn btn-primary btn-sm",onClick:t=>{t.stopPropagation(),(async()=>{const{downloadImage:t}=await Promise.resolve().then(()=>Qt);await t(e.url||e.path,e.filename||"limbo-image",{originalFormat:e.format,accessibilityManager:f})})()},title:"Descargar",children:_.jsx("span",{className:"icon icon-download-white icon--sm"})}),N&&a&&_.jsx("button",{className:"btn btn-danger btn-sm",onClick:t=>{t.stopPropagation(),(async()=>{a&&window.confirm(`¿Estás seguro de que deseas eliminar "${e.filename}"? Esta acción también eliminará todos sus recortes.`)&&(f?.announce(`Eliminando imagen ${e.filename}`),await a(e.id),n?.())})()},title:"Eliminar imagen",children:_.jsx("span",{className:"icon icon-close-small-white icon--sm m-[0!important]"})})]})]})]}),_.jsxs("div",{className:"limbo-variant-section",children:[_.jsxs("h3",{children:["Recortes (",T.length,")"]}),_.jsx("div",{className:"limbo-variants-grid",children:T.map(t=>{const a=j.has(t.id);return _.jsxs("div",{className:"limbo-variant-card "+(a?"":"cursor-pointer"),onClick:a?void 0:()=>(e=>{f?.announce(`Abriendo recorte ${e.name} en nueva pestaña`),window.open(e.url,"_blank")})(t),children:[_.jsxs("div",{className:"limbo-variant-preview",children:[_.jsx("img",{src:t.url,alt:t.name||t.filename||`Variante ${t.id}`,loading:"eager",onError:()=>{return e=t.id,void E(t=>new Set([...t,e]));var e},style:{display:a?"none":"block"}}),a&&_.jsx("div",{className:"limbo-variant-error",style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100px",backgroundColor:"#f5f5f5",color:"#666"},children:_.jsx("span",{children:"Error al cargar preview"})})]}),_.jsxs("div",{className:"limbo-variant-info",children:[_.jsx("div",{className:"limbo-variant-name",children:t.name||t.filename||`Variante ${t.id}`}),_.jsxs("div",{className:"limbo-variant-meta",children:[_.jsxs("span",{children:[t.width,"×",t.height]}),_.jsx("span",{children:(t.format||"jpg").toUpperCase()}),_.jsxs("span",{children:[Math.round((t.file_size||0)/1024)," KB"]})]}),t.crop_params&&_.jsxs("div",{className:"limbo-variant-crop-badge",children:[_.jsx("span",{className:"icon icon-scissors icon--xs"})," ","Recortada"]})]}),_.jsxs("div",{className:"limbo-variant-actions",children:[w&&_.jsx("button",{className:"btn btn-success btn-sm",onClick:a=>{a.stopPropagation(),(t=>{const a={id:t.id,filename:`${e.filename}_${t.name}`,url:t.url,width:t.width,height:t.height,mime_type:`image/${t.format}`,file_size:t.file_size,upload_date:t.created_at,processing_status:"completed",is_variant:!0,parent_asset_id:e.id,variant_info:t};f?.announce(`Recorte seleccionado: ${t.name}`),r?.(a),n?.()})(t)},title:`Seleccionar variante ${t.name||t.filename||t.id}`,children:"Seleccionar"}),C&&_.jsx("button",{className:"btn btn-secondary btn-sm",onClick:e=>{e.stopPropagation(),(async e=>{try{await navigator.clipboard.writeText(e.url),f?.announce(`URL de recorte ${e.name} copiada`)}catch(e){console.error("Error copying variant URL:",e),f?.announceError("Error al copiar URL de recorte")}})(t)},title:"Copiar URL",children:_.jsx("span",{className:"icon icon-copy-white icon--sm"})}),S&&_.jsx("button",{className:"btn btn-primary btn-sm",onClick:e=>{e.stopPropagation(),(async e=>{const{downloadImage:t}=await Promise.resolve().then(()=>Qt);await t(e.url,e.name||"limbo-variant",{originalFormat:e.format||e.output_format,accessibilityManager:f})})(t)},title:"Descargar",children:_.jsx("span",{className:"icon icon-download-white icon--sm"})}),N&&_.jsx("button",{className:"btn btn-danger btn-sm",onClick:n=>{n.stopPropagation(),(async t=>{if(window.confirm(`¿Estás seguro de que deseas eliminar el recorte "${t.name||t.filename}"?`)){f?.announce(`Eliminando recorte ${t.name||t.filename}`);const n=await p(e.id,t.id);n.success?(b("Recorte eliminado correctamente"),v("success"),f?.announce("Recorte eliminado correctamente"),o?.(),setTimeout(()=>{b(null),v(null)},3e3)):(b(`Error al eliminar recorte: ${n.error}`),v("error"),f?.announceError(`Error al eliminar recorte: ${n.error}`),setTimeout(()=>{b(null),v(null)},5e3))}})(t)},title:"Eliminar variante",children:_.jsx("span",{className:"icon icon-close-small-white icon--sm m-[0!important]"})})]})]},t.id)})})]})]})})]})}):null}function K({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,u]=l.useState(!1),[d,m]=l.useState(!1),[h,p]=l.useState(e.variants_count||0),{isMobile:f,isTouch:g}=T(),b=window.limboCore?.accessibilityManager,y=(window.limboCore?.config?.getGlobal()||{}).interaction||{allowSelection:!1,allowCropping:!0},v=n=>{n.stopPropagation(),b?.announce(`Eliminando imagen ${e.filename}`,"assertive"),t?.(e)},x=async t=>{t.stopPropagation();let n=e.url||e.path;try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(n);else{const e=document.createElement("textarea");e.value=n,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),document.body.removeChild(e)}u(!0),b?.announce(`URL de ${e.filename} copiada al portapapeles. Nota: La URL puede tener un tiempo de validez limitado.`),setTimeout(()=>u(!1),2e3)}catch(t){console.error("Error al copiar URL:",t),b?.announce(`Error al copiar URL de ${e.filename}. Inténtalo de nuevo.`),alert(`Error al copiar URL de ${e.filename}. Por favor, inténtalo de nuevo.`)}},w=async t=>{t.preventDefault(),t.stopPropagation();const{downloadImage:n}=await Promise.resolve().then(()=>Qt);await n(e.url||e.path,e.filename||"limbo-image",{originalFormat:e.format,accessibilityManager:b})},k=t=>{t.stopPropagation(),b?.announce(`Editando imagen ${e.filename}`),n?.(e)},C=e.variants&&e.variants.length>0||h>0,S=h,N=c.useCallback(()=>{p(e=>Math.max(0,e-1))},[]);c.useEffect(()=>{p(e.variants_count||0)},[e.variants_count]);const j=t=>{t.stopPropagation(),b?.announce(`Mostrando recortes de ${e.filename}`),m(!0)},E=y.allowSelection&&o.select&&r,$=y.allowCropping&&o.crop&&n,z=C&&!1!==o.variants,P=()=>{window.open(e.url||e.path,"_blank")};return _.jsxs(_.Fragment,{children:[_.jsxs("div",{className:`limbo-image-card flex flex-col items-center cursor-pointer relative transition ${i?"opacity-50":""} ${f?"limbo-image-card--mobile":""}`,onClick:P,onKeyDown:e=>{switch(e.key){case"Enter":case" ":e.preventDefault(),P();break;case"d":case"D":o.download&&(e.preventDefault(),w(e));break;case"c":case"C":o.copy&&(e.preventDefault(),x(e));break;case"Delete":case"Backspace":o.delete&&t&&(e.preventDefault(),v(e));break;case"x":case"X":o.crop&&n&&(e.preventDefault(),k(e));break;case"v":case"V":o.variants&&(e.preventDefault(),j(e))}},title:f?"Toque para ver imagen":"Haga click en la imagen para ver preview en nueva pestaña",role:"button",tabIndex:0,"aria-label":`Imagen ${e.filename}. ${e.width}x${e.height} px`,style:{...g&&{touchAction:"manipulation",WebkitTapHighlightColor:"transparent"}},children:[_.jsxs("div",{className:"limbo-image-actions "+(f?"limbo-image-actions--mobile":""),children:[z&&_.jsxs("button",{type:"button",title:`Ver ${S} recorte${1!==S?"s":""}`,className:"btn btn-variants border border-brand-blue-050/50 "+(f?"btn--touch":""),onClick:j,tabIndex:-1,style:{...f&&{width:"40px",height:"40px"},position:"relative"},children:[_.jsx("span",{className:"icon icon-album-menu-white icon--sm","aria-hidden":"true"}),S>0&&_.jsx("span",{className:"variants-count-badge",style:{position:"absolute",top:"-8px",right:"-8px",background:"#dc2626",color:"white",borderRadius:"50%",minWidth:"20px",height:"20px",fontSize:"12px",fontWeight:"700",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:"1",border:"2px solid white",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.4)",zIndex:"999"},children:S})]}),E&&_.jsx("button",{type:"button",title:"Seleccionar imagen",className:"btn btn-success border border-brand-blue-050/50 "+(f?"btn--touch":""),onClick:t=>{t.stopPropagation(),b?.announce(`Seleccionando ${e.filename} para el portal`),r?.(e)},tabIndex:-1,style:{...f&&{width:"40px",height:"40px"}},children:_.jsx("span",{className:"icon icon-tick-white icon--sm","aria-hidden":"true"})}),$&&_.jsx("button",{type:"button",title:"Editar imagen",className:"btn btn-crop border border-brand-blue-050/50 "+(f?"btn--touch":""),onClick:k,tabIndex:-1,style:{...f&&{width:"40px",height:"40px"}},children:_.jsx("span",{className:"icon icon-scissors-white icon--sm","aria-hidden":"true"})}),o.copy&&_.jsx("button",{type:"button",title:s?"¡Copiado!":"Copiar URL",className:"btn btn-copy border border-brand-blue-050/50 "+(f?"btn--touch":""),onClick:x,tabIndex:-1,style:{...f&&{width:"40px",height:"40px"}},children:_.jsx("span",{className:`icon ${s?"icon-copied-white":"icon-copy-white"} icon--sm`,"aria-hidden":"true"})}),o.download&&_.jsx("button",{type:"button",title:"Descargar",className:"btn btn-download border border-brand-blue-050/50 "+(f?"btn--touch":""),onClick:w,tabIndex:-1,style:{...f&&{width:"40px",height:"40px"}},children:_.jsx("span",{className:"icon icon-download-white icon--sm","aria-hidden":"true"})}),o.delete&&t&&_.jsx("button",{onClick:v,disabled:i,className:"btn btn-delete border border-brand-blue-050/50 "+(f?"btn--touch":""),title:"Eliminar imagen",tabIndex:-1,style:{...f&&{width:"40px",height:"40px"}},children:i?"…":_.jsx("span",{className:"icon icon-close-small-white icon--sm","aria-hidden":"true"})})]}),_.jsx("img",{src:e.url||e.path,loading:"eager",alt:e.filename.split(".")[0]??e.filename,className:"w-full object-cover rounded aspect-square",sizes:`height: ${6*a}px,width: ${6*a}px`,draggable:!1,style:{...f&&{minHeight:`${Math.max(3*a,80)}px`,height:"auto",aspectRatio:"1 / 1",objectFit:"cover"}}}),_.jsx("span",{className:"text-xs mt-1 truncate w-full text-center limbo-image-card-name "+(f?"limbo-image-card-name--mobile":""),style:{...f&&{fontSize:"0.75rem",lineHeight:"1.2",maxWidth:"100%",padding:"2px 4px",backgroundColor:"rgba(255, 255, 255, 0.9)",borderRadius:"4px",color:"#333",fontWeight:"500"}},children:e.filename.split(".")[0]??e.filename})]}),_.jsx(V,{image:e,isOpen:d,onClose:()=>m(!1),onSelect:r,onDelete:t,onCrop:n,onVariantDeleted:N,allowedActions:{select:o.select,download:o.download,copy:o.copy,delete:o.delete,crop:o.crop}})]})}function G(){return _.jsxs("div",{className:"limbo-image-card animate-pulse",role:"status","aria-label":"Cargando imagen...",children:[_.jsx("div",{className:"w-full aspect-square bg-neutral-gray-200 rounded-md flex items-center justify-center",children:_.jsx("svg",{className:"w-12 h-12 text-neutral-gray-300",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:_.jsx("path",{fillRule:"evenodd",d:"M4 3a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V5a2 2 0 00-2-2H4zm12 12H4l4-8 3 6 2-4 3 6z",clipRule:"evenodd"})})}),_.jsx("div",{className:"limbo-image-card-name opacity-100 position-relative bottom-0 p-2",children:_.jsx("div",{className:"h-4 bg-neutral-gray-200 rounded w-3/4"})}),_.jsx("span",{className:"limbo-sr-only",children:"Cargando imagen..."})]})}function Q({text:e="Cargando..."}){return _.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-gray-600",role:"status","aria-live":"polite","aria-label":e,children:[_.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:[_.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),_.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8H4z"})]}),_.jsx("p",{className:"text-sm",id:"loader-text",children:e})]})}function Y({onSelect:e,onCrop:t,onDelete:n,deletingId:r,images:a,loading:i,error:o,filters:s={name:"",dateFrom:"",dateTo:"",uploadedBy:""},onFiltersChange:c,filterConfig:u={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!==u.showNameFilter,p=!0===u.showUploadedByFilter,f=!1!==u.showDateFilter,g=l.useRef(null),b=window.limboCore?.accessibilityManager;l.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]),l.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;c&&c({...s,[t]:n})};return _.jsxs("div",{className:"w-full px-4 py-4",children:[_.jsx("div",{className:"p-2 mb-2",children:_.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&&_.jsxs("div",{className:"flex flex-col w-full sm:min-w-[180px] sm:flex-1",children:[_.jsx("label",{htmlFor:"name",className:"form-label mb-1",children:"Nombre"}),_.jsx("input",{type:"text",name:"name",id:"name",placeholder:"Buscar por nombre...",value:s.name,onChange:y,className:"form-control",autoComplete:"off"})]}),_.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&&_.jsxs(_.Fragment,{children:[_.jsxs("div",{className:"flex flex-col w-full sm:w-auto",children:[_.jsx("label",{htmlFor:"dateFrom",className:"form-label mb-1",children:"Desde"}),_.jsx("input",{type:"date",name:"dateFrom",id:"dateFrom",value:s.dateFrom,onChange:y,className:"form-control"})]}),_.jsxs("div",{className:"flex flex-col w-full sm:w-auto",children:[_.jsx("label",{htmlFor:"dateTo",className:"form-label mb-1",children:"Hasta"}),_.jsx("input",{type:"date",name:"dateTo",id:"dateTo",value:s.dateTo,onChange:y,className:"form-control"})]})]}),p&&_.jsxs("div",{className:"flex flex-col w-full sm:w-auto",children:[_.jsx("label",{htmlFor:"uploadedBy",className:"form-label mb-1",children:"Subido por"}),_.jsx("input",{type:"text",name:"uploadedBy",id:"uploadedBy",placeholder:"Subido por",value:s.uploadedBy,onChange:y,className:"form-control"})]})]})]})}),i?d.showPlaceholders?_.jsx("div",{ref:g,className:"limbo-gallery","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)=>_.jsx("div",{role:"gridcell","aria-posinset":t+1,"aria-setsize":d.placeholderCount,children:_.jsx(G,{})},`skeleton-${t}`))}):d.showSpinner?_.jsx(Q,{text:"Cargando imágenes..."}):null:o?_.jsx("div",{className:"alert alert-danger text-center",children:o}):_.jsx("div",{ref:g,className:"limbo-gallery","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)=>_.jsx("div",{role:"gridcell","aria-posinset":o+1,"aria-setsize":a.length,children:_.jsx(K,{image:i,onSelect:e,onCrop:t,onDelete:m.delete&&n?()=>n(i.id):null,thumbnailSize:32,isDeleting:r===i.id,allowedActions:m})},i.id)):_.jsx("div",{className:"col-span-full text-center text-gray-500 py-8",role:"status","aria-live":"polite",children:_.jsx("p",{children:"No se han encontrado imágenes"})})})]})}function X({image:e,onDiscard:t,onRetry:n,onDownload:r,onSelect:a,showRetry:i=!1,disabled:o=!1}){const[s,c]=l.useState(null),[u,d]=l.useState({name:"",size:"",type:""}),[m,h]=l.useState(!1);l.useEffect(()=>{if(!e)return void c(null);const t=URL.createObjectURL(e);return c(t),d({name:e.name||"imagen.webp",size:p(e.size||0),type:e.type||"image/webp"}),()=>{URL.revokeObjectURL(t)}},[e]),l.useEffect(()=>{if(!m)return;const e=e=>{"Escape"===e.key&&h(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[m]);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?_.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:[_.jsxs("div",{className:"flex items-center justify-between mb-4 px-1",children:[_.jsx("h3",{className:"text-sm font-medium text-gray-700",children:"Vista previa de imagen"}),_.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:_.jsx("span",{className:"icon icon-close-small icon--md"})})]}),_.jsxs("div",{className:"flex flex-col justify-center md:flex-row gap-2 md:gap-6",children:[_.jsxs("div",{className:"flex-1 md:flex-[0.4] flex flex-col items-center justify-center",children:[_.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:[_.jsx("img",{src:s,alt:"Vista previa",className:"absolute inset-0 w-full h-full object-contain"}),_.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:[_.jsx("span",{className:"icon icon-search-white icon--xs"}),_.jsx("span",{className:"hidden sm:inline",children:"Ampliar"})]})]}),_.jsx("div",{className:"mt-3 text-center space-y-1 w-full",children:_.jsxs("div",{className:"rounded-sm w-fit gap-0.5 p-0.5 min-w-fit mx-auto",children:[_.jsxs("label",{htmlFor:"uploadImageId",className:"flex items-center w-fit",children:[_.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:_.jsx("span",{className:"icon icon-edit-white icon--sm"})}),_.jsx("input",{id:"uploadImageId",onChange:e=>(e=>{const t=e.target.value,n=u.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 truncate focus:outline focus:outline-neutral-gray-100 focus:transform-none focus:shadow-none focus:opacity-100",defaultValue:u.name.split(".")[0],title:"Renombra la imagen a tu gusto"})]}),_.jsxs("div",{className:"flex items-center justify-center gap-3 text-xs text-gray-500",children:[_.jsx("span",{children:u.size}),_.jsx("span",{children:"•"}),_.jsx("span",{children:u.type.split("/")[1]?.toUpperCase()||"IMAGE"})]})]})})]}),_.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&&_.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:[_.jsx("span",{className:"icon icon-refresh icon--sm"}),_.jsx("span",{className:"hidden sm:inline",children:"Reintentar"}),_.jsx("span",{className:"sm:hidden",children:"Retry"})]}),_.jsxs("button",{type:"button",onClick:()=>{if(!s||o)return;const e=document.createElement("a");e.href=s,e.download=u.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:[_.jsx("span",{className:"icon icon-download icon--sm"}),_.jsx("span",{children:"Descargar"})]}),_.jsxs("button",{type:"button",onClick:()=>a&&a(u.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:[_.jsx("span",{className:"icon icon-tick-white icon--sm"}),_.jsx("span",{children:"Seleccionar"})]})]})]}),m&&_.jsxs("div",{className:"fixed inset-0 bg-black/90 z-[10000] flex items-center justify-center p-4",onClick:()=>h(!1),role:"dialog","aria-modal":"true","aria-label":"Vista de imagen en tamaño completo",children:[_.jsx("button",{onClick:()=>h(!1),className:"absolute top-4 right-4 p-2 bg-white/10 hover:bg-white/20 rounded-full transition-colors cursor-pointer z-10","aria-label":"Cerrar vista ampliada",title:"Cerrar (Esc)",children:_.jsx("span",{className:"icon icon-close-small-white icon--lg"})}),_.jsxs("div",{className:"absolute top-4 left-4 bg-black/50 text-white px-4 py-2 rounded-lg text-sm",children:[_.jsx("p",{className:"font-medium",children:u.name}),_.jsxs("p",{className:"text-xs text-gray-300 mt-1",children:[u.size," • ",u.type.split("/")[1]?.toUpperCase()]})]}),_.jsx("div",{className:"relative max-w-7xl max-h-[90vh] w-full h-full flex items-center justify-center",onClick:e=>e.stopPropagation(),children:_.jsx("img",{src:s,alt:"Vista completa",className:"max-w-full max-h-full object-contain rounded-lg shadow-2xl"})}),_.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 bg-black/50 text-white px-4 py-2 rounded-lg text-xs text-center",children:"Click fuera de la imagen o presiona ESC para cerrar"})]})]}):null}function J({file:e,setFile:t,previewUrl:n,setPreviewUrl:r,fileInputRef:a,onSelect:i,disabled:o}){return _.jsxs("div",{className:"flex flex-col items-center gap-6","aria-label":"Subir imagen desde dispositivo",children:[_.jsxs("label",{htmlFor:"file-input",className:"w-fit md:w-full flex flex-col items-center justify-center border-2 border-dashed border-brand-blue-200 rounded-xl p-8 cursor-pointer hover:border-brand-blue-1000 hover:to-bright-blue-200 hover:from-brand-blue-050 focus-within:border-brand-blue-800 from-bright-blue-050 to-brand-blue-050 bg-linear-to-br transition",tabIndex:0,style:{outline:"none"},children:[_.jsx("span",{className:"icon icon-upload icon--lg mb-2","aria-hidden":"true"}),_.jsx("span",{className:"font-medium text-brand-blue-1000 mb-1",children:"Haz clic o arrastra una imagen aquí"}),_.jsx("span",{className:"text-sm text-neutral-700",children:"Formatos permitidos: JPG, PNG, GIF, SVG, WebP"}),_.jsx("input",{id:"file-input",ref:a,type:"file",accept:"image/jpeg,image/png,image/svg,image/webp,image/gif",onChange:e=>{const n=e.target.files[0];if(t(n),n){const e=URL.createObjectURL(n);r(e)}else r(null)},disabled:o,className:"sr-only","aria-label":"Seleccionar imagen"})]}),e&&_.jsx(X,{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 Z="/api",ee=new Map;const te=new Map;function ne(e=!1){const[t,n]=l.useState(null),[r,a]=l.useState(!1),[i,o]=l.useState(null);return{params:t,loading:r,error:i,fetchParams:async t=>{a(!0),o(null);const r=`${e}-${t}`,i=Date.now(),s=te.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),I({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),te.set(r,{data:o,timestamp:i}),o}catch(e){return o(e.message),n(null),null}finally{a(!1)}},reset:()=>{o(null),n(null)}}}function re({show:e=!1,message:t="Cargando...",className:n=""}){return e?_.jsx("div",{className:`absolute inset-0 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:_.jsxs("div",{className:"flex flex-col items-center gap-4",children:[_.jsxs("div",{className:"relative w-16 h-16",children:[_.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-200 rounded-full"}),_.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-600 rounded-full border-t-transparent animate-spin"})]}),_.jsx("p",{className:"text-brand-blue-900 font-medium text-lg",children:t})]})}):null}function ae({prod:e,disabled:t,onSelect:n,onServiceChange:r}){const a=function(e=!1){const[t,n]=l.useState([]),[r,a]=l.useState(!0),[i,o]=l.useState(null);return l.useEffect(()=>{const t=`ai-services-${e}`,r=ee.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 I({endpoint:"/ai/services",prod:e,basePath:Z})}(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})):Object.entries(a).map(([e,t])=>({label:e,slug:t,type:"image_generation",description:null,image:null}));n(o),ee.set(t,{data:o,timestamp:i})}catch(e){s&&o(e.message)}finally{s&&a(!1)}})(),()=>{s=!1}},[e]),{services:t,loading:r,error:i,invalidateCache:()=>{ee.delete(`ai-services-${e}`)}}}(e),i=ne(e),[o,s]=l.useState(""),[u,d]=l.useState(""),[m,h]=l.useState({}),[p,f]=l.useState(!1),[g,b]=l.useState(null),[y,v]=l.useState(null),[x,w]=l.useState(null),[k,C]=l.useState(!0),[S,N]=l.useState(!1);c.useEffect(()=>{r&&u&&r(u)},[u]),c.useEffect(()=>{if(!a.loading&&1===a.services.length){const e=a.services[0];d(e.slug),C(!1),i.fetchParams(e.slug,!0)}},[a.loading,a.services]),c.useEffect(()=>{if(!u)return;const e=i.params?.[u]?.parameters;if(e){const t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default??""]));t.service=u,h(t)}},[u,i.params]);const j=e=>{const{name:t,value:n}=e.target;h(e=>({...e,[t]:n}))},E=async(t,n=!1)=>{t.preventDefault(),f(!0),b(null),v(null);try{n?m.prompt=o:s(m.prompt||"");const t=await function(e,t=!1){return I({endpoint:"/ai/generate",method:"POST",body:e,prod:t,basePath:Z})}(m,e);let r=null;if(t?.data?.images&&Array.isArray(t.data.images)&&t.data.images.length>0?r=t.data.images[0]:t?.result?.images&&Array.isArray(t.result.images)&&t.result.images.length>0?r=t.result.images[0]:Array.isArray(t)&&t.length>0?r=t[0]:"string"==typeof t&&(r=t),!r)throw new Error("No se pudo extraer la imagen de la respuesta");if(r.startsWith("http"))try{const e=`${window.limboCore?.config?.getGlobal()?.prod?"https://limbo.lefebvre.com":"http://localhost"}/api/atenea/proxy?url=${encodeURIComponent(r)}`,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(),a=new File([n],"ai-image.webp",{type:n.type||"image/webp"});w(a)}catch(e){throw new Error(`Error downloading image via proxy: ${e.message}`)}else{const e=r.replace(/^data:image\/\w+;base64,/,""),t=atob(e),n=new Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);const a=new Uint8Array(n),i=new File([a],"ai-image.webp",{type:"image/webp"});w(i)}v(t?.data?.images||t?.result?.images||null)}catch(e){b(e.message||"Error al generar la imagen")}finally{f(!1)}};return a.loading?_.jsxs("div",{className:"flex items-center justify-center py-8",children:[_.jsx("span",{className:"limbo-loader mr-2"})," Cargando servicios IA..."]}):a.services.length?_.jsx("div",{className:"flex flex-col mx-4 pb-2",children:k?_.jsxs(_.Fragment,{children:[_.jsx("h3",{id:"aiSelectDescription",className:"text-2xl font-semibold text-brand-blue-1000",children:"Selecciona el modelo IA"}),a.error&&_.jsx("div",{className:"alert alert-danger",children:a.error}),_.jsx("div",{className:"flex flex-wrap justify-around items-stretch justify-items-stretch content-stretch gap-3 w-full max-w-7xl",children:a.services.map(e=>_.jsxs("button",{type:"button",onClick:()=>{d(e.slug),C(!1),h({}),v(null),b(null),w(null),i.fetchParams(e.slug,!0)},disabled:a.loading||t,className:`\n group relative p-4 rounded-lg border-2 transition-all duration-200 overflow-hidden\n flex flex-col items-center justify-center min-h-[120px] grow-1 basis-sm min-w-70\n border-gray-200 hover:border-brand-blue-300 hover:shadow-md\n ${a.loading||t?"opacity-50 cursor-not-allowed":"cursor-pointer"}\n `,style:{position:"relative"},children:[e.image&&_.jsx("div",{className:"absolute inset-0 bg-cover bg-center transition-opacity duration-200 group-hover:opacity-20",style:{backgroundImage:`url(${e.image})`,opacity:.1}}),_.jsxs("div",{className:"relative z-10 flex flex-col items-center justify-center gap-2 text-center",children:[_.jsx("span",{className:"text-base font-semibold text-gray-800",children:e.label}),e.description&&_.jsx("span",{className:"text-xs text-neutral-gray-800 line-clamp-2 drop-shadow drop-shadow-neutral-white-000",children:e.description})]})]},e.slug))})]}):_.jsxs(_.Fragment,{children:[_.jsx("h3",{className:"text-2xl font-semibold text-brand-blue-1000",children:a.services.find(e=>e.slug===u)?.label||"Generación IA"}),i.loading&&_.jsx("div",{children:"Cargando parámetros..."}),i.error&&_.jsx("div",{className:"alert alert-danger",children:i.error}),u&&(()=>{const e=i.params?.[u]?.parameters;if(!e)return null;const n=Object.entries(e).filter(([e,t])=>!t.hidden),r=n.filter(([e])=>e.toLowerCase().includes("prompt")||e.toLowerCase().includes("query")),o=n.filter(([e])=>!e.toLowerCase().includes("prompt")&&!e.toLowerCase().includes("query")),s=(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 _.jsxs("div",{className:"flex flex-col gap-1",children:[_.jsxs("label",{htmlFor:`ai-${e}`,className:"text-xs font-medium text-brand-blue-900",children:[n.label||e,n.required&&_.jsx("span",{className:"text-red-600 ml-1",children:"*"})]}),n.options?_.jsx("select",{id:`ai-${e}`,name:e,value:m[e]??"",onChange:j,className:"limbo-input",disabled:t,title:n.label||e,children:n.options.map(e=>_.jsx("option",{value:e,children:e},e))}):a?_.jsx("textarea",{id:`ai-${e}`,name:e,value:m[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`}}):_.jsx("input",{id:`ai-${e}`,type:"integer"===n.type?"number":"text",name:e,value:m[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 _.jsxs("div",{className:"h-fit w-full",children:[a.services.length>1&&_.jsxs("button",{type:"button",onClick:()=>{C(!0),d(""),h({}),v(null),b(null),w(null)},className:"flex cursor-pointer items-center gap-2 text-brand-blue-600 hover:text-brand-blue-700 mb-4 font-medium",children:[_.jsx("span",{className:"icon icon-arrow-left"}),"Volver al menú de servicios"]}),_.jsxs("div",{className:"relative",children:[_.jsxs("form",{onSubmit:E,"data-type":"ai",className:"flex flex-col gap-3 mt-4 border-t-1 pt-4 border-brand-blue-200","aria-label":"Formulario generación IA",children:[_.jsx("div",{className:"flex flex-col gap-3",children:r.map(([e,t])=>s(e,t))}),o.length>0&&_.jsxs("div",{className:"border-t border-gray-200 pt-3",children:[_.jsxs("button",{type:"button",onClick:()=>N(!S),className:"flex items-center gap-2 text-sm font-medium text-brand-blue-700 hover:text-brand-blue-900 mb-3 transition-colors",children:[_.jsx("svg",{className:"w-4 h-4 transition-transform "+(S?"rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:_.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"Opciones avanzadas",!S&&_.jsxs("span",{className:"text-xs text-gray-500",children:["(",o.length," opciones)"]})]}),S&&_.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3 animate-fadeIn",children:o.map(([e,t])=>s(e,t))})]}),_.jsx("button",{type:"submit",disabled:p||t,title:p?"Generando imagen...":x?"Generar otra imagen":"Generar imagen",className:"limbo-btn w-full mt-2 "+(p?"cursor-not-allowed limbo-btn-disabled":"limbo-btn-primary"),style:{minHeight:44},children:p?"Generando imagen...":x?"Generar otra imagen":"Generar imagen"})]}),_.jsx(re,{show:p,message:"Generando imagen con IA..."})]})]})})(),g&&_.jsx("div",{className:"alert alert-danger mt-4",children:g}),x&&_.jsx("div",{className:"mt-6 md:w-full mx-auto",children:_.jsx(X,{image:x,onDiscard:()=>{w(null),v(null),b(null)},onRetry:e=>E(e,!0),onDownload:()=>{},onSelect:e=>{if(n){const t=x||y;if(e&&t&&e!==t.name){const r=new File([t],e,{type:t.type});n(r)}else n(t)}},showRetry:!0,disabled:p||t})})]})}):_.jsx("div",{className:"alert alert-warning",children:"No hay servicios IA disponibles."})}const ie="/api",oe=new Map;function se({prod:e,disabled:t,onSelect:n,onServiceChange:r}){const a=c.useRef(null),i=function(e=!1){const[t,n]=l.useState([]),[r,a]=l.useState(!0),[i,o]=l.useState(null);return l.useEffect(()=>{const t=`stock-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 I({endpoint:"/stock/services",prod:e,basePath:ie})}(e);if(!s)return;if(204===r?.httpCode||null===r?.data)return n([]),o("No hay servicios de stock disponibles en este momento"),void oe.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),oe.set(t,{data:l,timestamp:i})}catch(e){s&&o(e.message)}finally{s&&a(!1)}})(),()=>{s=!1}},[e]),{services:t,loading:r,error:i,invalidateCache:()=>{oe.delete(`stock-services-${e}`)}}}(e),o=(e,t)=>{try{const n=sessionStorage.getItem(`limbo_stock_${e}`);return n?JSON.parse(n):t}catch{return t}},[s,u]=l.useState(()=>o("selectedService","")),[d,m]=l.useState(()=>o("dynamicForm",{})),[h,p]=l.useState(()=>o("stockImages",[])),[f,g]=l.useState(()=>o("currentPage",1)),[b,y]=l.useState(()=>o("paginationInfo",null)),[v,x]=l.useState(null),w=ne(e),[k,C]=l.useState(!1),[S,N]=l.useState(null),[j,E]=l.useState(null),[$,z]=l.useState(!0),[T,P]=l.useState(!1),[A,M]=l.useState(null);c.useEffect(()=>{sessionStorage.setItem("limbo_stock_selectedService",JSON.stringify(s))},[s]),c.useEffect(()=>{sessionStorage.setItem("limbo_stock_dynamicForm",JSON.stringify(d))},[d]),c.useEffect(()=>{sessionStorage.setItem("limbo_stock_stockImages",JSON.stringify(h))},[h]),c.useEffect(()=>{sessionStorage.setItem("limbo_stock_currentPage",JSON.stringify(f))},[f]),c.useEffect(()=>{sessionStorage.setItem("limbo_stock_paginationInfo",JSON.stringify(b))},[b]),c.useEffect(()=>{if(!i.loading&&1===i.services.length){const e=i.services[0];u(e.slug),z(!1),w.fetchParams(e.slug,!0)}},[i.loading,i.services]),c.useEffect(()=>{if(!s)return;const e=w.params?.[s]?.parameters;if(e){const t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.default??""]));t.service=s,m(t)}},[s,w.params]),c.useEffect(()=>{r&&s&&r(s)},[s]);const L=e=>{const{name:t,value:n}=e.target;m(e=>({...e,[t]:n}))},O=async(t=1)=>{C(!0),N(null),1===t&&p([]);try{let n;if(1===t){const e=w.params?.[s]?.parameters,r={...d};Object.entries(e||{}).forEach(([e,t])=>{e in r||(r[e]=t.default??"")}),r.per_page=parseInt(r.per_page),r.service=s,r.page=t,n=r,a.current={...r}}else n={...a.current,page:t};const r=await function(e,t=!1){return I({endpoint:"/stock/search",method:"POST",body:e,prod:t,basePath:ie})}(n,e),i=r?.data?.images||[];let o=r?.data?.pagination||null,l=null;o&&(l={total:o.total_count??o.total??i.length,per_page:o.per_page??(Array.isArray(i)?i.length:0),current_page:o.page??o.current_page??t}),p(R(Array.isArray(i)?i:[])),y(l),g(l?.current_page||t)}catch(e){N(e.message||"Error al buscar imágenes")}finally{C(!1)}},R=e=>{const t=new Set,n=[];return(e||[]).forEach((e,r)=>{const a=e.url||e.preview_url||e.full||e.preview;a&&!t.has(a)&&(t.add(a),n.push({...e,preview:e.preview_url||e.preview||e.url||e.full,full:e.url||e.full||e.preview_url,id:e.id||r,title:e.title||e.filename||`Imagen ${r+1}`,source:e.service||s,sourceTitle:i.services.find(e=>e.slug===s)?.label||s}))}),n},D=async e=>{e.preventDefault();const t=d.query||d.search||d.term||"";t.trim().length<5?N("La búsqueda debe tener al menos 5 caracteres"):(x(t),await O(1))},F=e=>{e<1||O(e)},U=async t=>{E(t.id),N(null);try{const n={service:s,image_id:t.id},r=await function(e,t=!1){return I({endpoint:"/stock/download",method:"POST",body:e,prod:t,basePath:ie})}(n,e);if(!r?.result?.url&&!r?.result?.download_url)throw new Error("No se pudo obtener la URL de descarga");{const e=r.result.url||r.result.download_url,n=await fetch(e),a=await n.blob(),i=r.result.filename||`stock-${t.id}.jpg`,o=new File([a],i,{type:a.type||"image/jpeg"});M(o)}}catch(e){N(e.message||"No se pudo recuperar la imagen seleccionada")}finally{E(null)}};return i.loading?_.jsxs("div",{className:"flex items-center justify-center py-8",children:[_.jsx("span",{className:"limbo-loader mr-2"})," Cargando servicios de Stock..."]}):i.services.length?_.jsx("div",{className:"flex flex-col mx-4 pb-2",children:$?_.jsxs(_.Fragment,{children:[_.jsx("h3",{className:"text-2xl font-semibold text-brand-blue-1000",children:"Selecciona el servicio de Stock"}),i.error&&_.jsx("div",{className:"alert alert-danger",children:i.error}),_.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:i.services.map(e=>_.jsxs("button",{type:"button",onClick:()=>{u(e.slug),z(!1),m({}),p([]),g(1),y(null),N(null),w.fetchParams(e.slug,!0)},disabled:i.loading||t,className:`\n group relative p-4 rounded-lg border-2 transition-all duration-200 overflow-hidden\n flex flex-col items-center justify-center min-h-[120px]\n border-gray-200 hover:border-brand-blue-300 hover:shadow-md\n ${i.loading||t?"opacity-50 cursor-not-allowed":"cursor-pointer"}\n `,style:{position:"relative"},children:[e.image&&_.jsx("div",{className:"absolute inset-0 bg-cover bg-center transition-opacity duration-200 group-hover:opacity-20",style:{backgroundImage:`url(${e.image})`,opacity:.1}}),_.jsxs("div",{className:"relative z-10 flex flex-col items-center justify-center gap-2 text-center",children:[_.jsx("span",{className:"text-base font-semibold text-gray-800",children:e.label}),e.description&&_.jsx("span",{className:"text-xs text-gray-600 line-clamp-2",children:e.description})]})]},e.slug))})]}):_.jsxs(_.Fragment,{children:[_.jsx("h3",{className:"text-2xl font-semibold text-brand-blue-1000",children:i.services.find(e=>e.slug===s)?.label||"Búsqueda Stock"}),w.loading&&_.jsx("div",{children:"Cargando parámetros..."}),w.error&&_.jsx("div",{className:"alert alert-danger",children:w.error}),s&&(()=>{const e=w.params?.[s]?.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")),a=n.filter(([e])=>!e.toLowerCase().includes("query")&&!e.toLowerCase().includes("search")&&!e.toLowerCase().includes("term")),o=(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 _.jsxs("div",{className:"flex flex-col gap-1",children:[_.jsxs("label",{htmlFor:`stock-${e}`,className:"text-xs font-medium text-brand-blue-900",children:[n.label||e,n.required&&_.jsx("span",{className:"text-red-600 ml-1",children:"*"})]}),n.options&&n.multiple?_.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=>_.jsxs("label",{className:"flex items-center gap-1",children:[_.jsx("input",{type:"checkbox",name:`stock-${e}`,value:n,checked:Array.isArray(d[e])&&d[e].includes(n),onChange:()=>((e,t)=>{m(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}),_.jsx("span",{className:"text-xs",children:n})]},n))}):n.options?_.jsx("select",{id:`stock-${e}`,name:e,value:d[e]??"",onChange:L,className:"limbo-input",disabled:t,title:n.label||e,children:n.options.map(e=>_.jsx("option",{value:e,children:e},e))}):a?_.jsx("textarea",{id:`stock-${e}`,name:e,value:d[e]??"",onChange:L,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`}}):_.jsx("input",{id:`stock-${e}`,type:"integer"===n.type?"number":"text",name:e,value:d[e]??"",onChange:L,className:"limbo-input",disabled:t,required:n.required,min:n.minValue,max:n.maxValue,placeholder:r,title:n.label||e})]},e)};return _.jsxs("div",{children:[i.services.length>1&&_.jsxs("button",{type:"button",onClick:()=>{z(!0),u(""),m({}),p([]),g(1),y(null),N(null)},className:"flex cursor-pointer items-center gap-2 text-brand-blue-600 hover:text-brand-blue-700 mb-4 font-medium",children:[_.jsx("span",{className:"icon icon-arrow-left"}),"Volver al menú de servicios"]}),_.jsxs("div",{className:"relative",children:[_.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:[_.jsx("div",{className:"flex flex-col gap-3",children:r.map(([e,t])=>o(e,t))}),a.length>0&&_.jsxs("div",{className:"border-t border-gray-200 pt-3",children:[_.jsxs("button",{type:"button",onClick:()=>P(!T),className:"flex items-center gap-2 text-sm font-medium text-brand-blue-700 hover:text-brand-blue-900 mb-3 transition-colors",children:[_.jsx("svg",{className:"w-4 h-4 transition-transform "+(T?"rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:_.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"Opciones avanzadas",!T&&_.jsxs("span",{className:"text-xs text-gray-500",children:["(",a.length," opciones)"]})]}),T&&_.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 animate-fadeIn",children:a.map(([e,t])=>o(e,t))})]}),_.jsx("button",{type:"submit",disabled:k||t,className:"limbo-btn w-full mt-2 "+(k?"cursor-not-allowed limbo-btn-disabled":"limbo-btn-primary"),style:{minHeight:44},children:k?"Buscando...":"Buscar imágenes"})]}),_.jsx(re,{show:k&&!h.length,message:"Buscando imágenes..."})]})]})})(),S&&_.jsx("div",{className:"alert alert-danger mt-4",children:S}),A&&_.jsx("div",{className:"mt-6 md:w-full mx-auto",children:_.jsx(X,{image:A,onDiscard:()=>{M(null),N(null)},onDownload:()=>{},onSelect:e=>{if(n)if(e&&A&&e!==A.name){const t=new File([A],e,{type:A.type});n(t)}else n(A)},showRetry:!1,disabled:t})}),!A&&h.length>0&&_.jsxs(_.Fragment,{children:[_.jsxs("div",{className:"mt-6 grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-1 relative","aria-live":"polite",children:[_.jsx(re,{show:k,message:"Cargando imágenes..."}),h.map((e,n)=>_.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&&!k&&!t&&U(e),children:_.jsxs("div",{className:"relative aspect-video bg-neutral-100",children:[_.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?_.jsxs("div",{className:"absolute inset-0 bg-white/90 flex flex-col items-center justify-center gap-2",children:[_.jsxs("div",{className:"relative w-10 h-10",children:[_.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-200 rounded-full"}),_.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-600 rounded-full border-t-transparent animate-spin"})]}),_.jsx("span",{className:"text-sm font-medium text-brand-blue-900",children:"Descargando..."})]}):_.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:[_.jsx("span",{className:"icon icon-round-check-filled icon--2xl max-w-full max-h-full opacity-0 group-hover:opacity-100 transition-opacity duration-200"}),_.jsx("span",{style:{textShadow:"1px 0 #0d542b, -1px 0 #0d542b, 0 1px #0d542b, 0 -0.5px #0d542b, 0.5px 0.5px #0d542b, -1px -1px #0d542b, 1px -1px #0d542b, -1px 1px #0d542b"},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))]}),b&&_.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2",children:[_.jsxs("button",{onClick:()=>F(b.current_page-1),disabled:b.current_page<=1||k,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(b.current_page<=1||k?" pointer-events-none cursor-default":" limbo-btn-primary"),children:[_.jsx("span",{className:"icon icon-arrow-left-white icon--sm"})," ","Anterior"]}),_.jsxs("span",{className:"px-4 py-2 text-sm text-neutral-700",children:["Página ",b.current_page," de"," ",Math.max(1,Math.ceil(b.total/b.per_page)),_.jsxs("span",{className:"text-xs text-neutral-500 block",children:["(",b.total," imágenes totales)"]})]}),_.jsxs("button",{onClick:()=>F(b.current_page+1),disabled:k||b.current_page>=Math.ceil(b.total/b.per_page),className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(k||b.current_page>=Math.ceil(b.total/b.per_page)?" pointer-events-none cursor-default":" limbo-btn-primary"),children:["Siguiente"," ",_.jsx("span",{className:"icon icon-arrow-right-white icon--sm"})]})]})]}),!k&&0===h.length&&s&&v&&_.jsxs("div",{className:"mt-6 text-center text-neutral-600 py-8 bg-neutral-50 rounded-lg",children:[_.jsx("span",{className:"icon icon-search icon--lg mb-2"}),_.jsxs("p",{children:['No se encontraron imágenes para "',d.query,'"']}),_.jsx("p",{className:"text-sm mt-1",children:"Intenta con otros términos de búsqueda"})]})]})}):_.jsx("div",{className:"alert alert-warning",children:"No hay servicios de Stock disponibles."})}const le="/api",ce=new Map;const ue=({src:e,alt:t,className:n,onError:r})=>{const[a,i]=c.useState("loading");return"error"===a?null:_.jsx("img",{src:e,alt:t,className:n,loading:"lazy",onLoad:()=>{i("loaded")},onError:()=>{i("error"),r&&r()}})};function de({prod:e,disabled:t,onSelect:n}){const r=c.useRef(null),a=function(e=!1){const[t,n]=l.useState([]),[r,a]=l.useState(!0),[i,o]=l.useState(null);return l.useEffect(()=>{const t=`portal-sources-${e}`,r=ce.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 I({endpoint:"/external/sources",prod:e,basePath:le})}(e);if(!s)return;const a=r?.data?.sources||{},o=Object.entries(a).map(([e,t])=>({id:e,...t}));n(o),ce.set(t,{data:o,timestamp:i})}catch(e){s&&o(e.message)}finally{s&&a(!1)}})(),()=>{s=!1}},[e]),{sources:t,loading:r,error:i,invalidateCache:()=>{ce.delete(`portal-sources-${e}`)}}}(e),i=(e,t)=>{try{const n=sessionStorage.getItem(`limbo_portals_${e}`);return n?JSON.parse(n):t}catch{return t}},[o,s]=l.useState(()=>i("selectedPortals",[])),[u,d]=l.useState(()=>i("searchName","")),[m,h]=l.useState(()=>i("limit",20)),[p,f]=l.useState(()=>i("currentPage",1)),[g,b]=l.useState(!1),[y,v]=l.useState(null),[x,w]=l.useState(()=>i("images",[])),[k,C]=l.useState(()=>i("portalResults",{})),[S,N]=l.useState(()=>i("paginationInfo",null)),[j,E]=l.useState(null),[$,z]=l.useState(null),T=l.useRef({}),[P,A]=l.useState(new Set);c.useEffect(()=>{sessionStorage.setItem("limbo_portals_selectedPortals",JSON.stringify(o))},[o]),c.useEffect(()=>{sessionStorage.setItem("limbo_portals_searchName",JSON.stringify(u))},[u]),c.useEffect(()=>{sessionStorage.setItem("limbo_portals_limit",JSON.stringify(m))},[m]),c.useEffect(()=>{sessionStorage.setItem("limbo_portals_currentPage",JSON.stringify(p))},[p]),c.useEffect(()=>{sessionStorage.setItem("limbo_portals_images",JSON.stringify(x))},[x]),c.useEffect(()=>{sessionStorage.setItem("limbo_portals_portalResults",JSON.stringify(k))},[k]),c.useEffect(()=>{sessionStorage.setItem("limbo_portals_paginationInfo",JSON.stringify(S))},[S]);const L=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,u.trim(),m,t),a=T.current[n];if(a)return w(a.images),C(a.portalResults),N(a.paginationInfo),f(t),void v(null);b(!0),v(null),1===t&&(w([]),C({}),N(null));try{let a;1===t?(a={sources:o,limit:m,page:t,name:u.trim()},r.current={...a}):a={...r.current,page:t};const i=await function(e,t=!1){return I({endpoint:"/external/search",method:"POST",body:e,prod:t,basePath:le})}(a,e),s=i?.data?.sources||{},l=[],c={},d=new Set;let h=null;Object.entries(s).forEach(([e,t])=>{c[e]={title:t.meta?.title||e,status:200,response:"OK",count:t.images?.length||0},Array.isArray(t.images)&&(t.images.forEach(n=>{const r=n.url||n.thumbnail;r&&!d.has(r)&&(d.add(r),l.push({...n,source:e,sourceTitle:t.meta?.title||e,preview:n.thumbnail||n.url,full:n.url}))}),!h&&t.pagination&&(h=t.pagination))}),T.current[n]={images:l,portalResults:c,paginationInfo:h},w(l),C(c),N(h),f(t),A(new Set),0!==l.length||i?.result?.success||v(i?.result?.message||"No se encontraron imágenes")}catch(e){v(e.message||"Error al buscar imágenes en portales")}finally{b(!1)}},O=e=>{e<1||L(e)};return a.loading?_.jsxs("div",{className:"flex items-center justify-center py-8",children:[_.jsx("span",{className:"limbo-loader mr-2"})," Cargando portales disponibles..."]}):a.sources.length?_.jsxs("div",{className:"flex flex-col gap-2",children:[_.jsx("h3",{className:"text-lg font-semibold text-brand-blue-1000",children:"Buscar en Portales Externos"}),_.jsxs("form",{onSubmit:e=>{e.preventDefault(),L(1)},className:"flex flex-col gap-4 border-t-1 pt-4 border-brand-blue-200",children:[_.jsxs("div",{className:"flex flex-col gap-3",children:[_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsxs("h3",{className:"text-lg font-semibold text-brand-blue-1000",children:["Selecciona portales (",o.length," seleccionados)"]}),_.jsx("button",{type:"button",onClick:()=>{o.length===a.sources.length?s([]):s(a.sources.map(e=>e.id))},className:"text-sm text-brand-blue-700 hover:text-brand-blue-900 font-medium transition-colors",children:o.length===a.sources.length?"Deseleccionar todos":"Seleccionar todos"})]}),_.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 _.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:`\n relative p-4 rounded-lg border-2 transition-all duration-200 flex flex-col items-center justify-center min-h-[100px] gap-2 max-h-[110px] box-border ${n?"border-brand-blue-600 bg-brand-blue-50":"border-gray-200 bg-white hover:border-brand-blue-300"}\n ${t?"opacity-50 cursor-not-allowed":"cursor-pointer"}\n hover:shadow-md\n `,children:[n&&_.jsx("div",{className:"absolute top-2 right-2 w-6 h-6 bg-brand-blue-600 rounded-full flex items-center justify-center bg-black",children:_.jsx("span",{className:"icon icon-tick-white icon--sm"})}),_.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)})})]}),_.jsxs("div",{className:"flex flex-col gap-1",children:[_.jsx("label",{htmlFor:"portal-search-name",className:"text-sm font-medium text-brand-blue-1000",children:"Buscar por nombre (opcional)"}),_.jsx("input",{id:"portal-search-name",type:"text",value:u,onChange:e=>d(e.target.value),className:"limbo-input",placeholder:"Deja vacío para ver todas las imágenes",disabled:t})]}),_.jsxs("div",{className:"flex-col gap-1 hidden",children:[_.jsx("label",{htmlFor:"portal-limit",className:"text-sm font-medium text-brand-blue-1000",children:"Imágenes por página"}),_.jsxs("select",{id:"portal-limit",value:10,onChange:e=>h(Number(e.target.value)),className:"limbo-input",disabled:t,children:[_.jsx("option",{value:10,children:"10"}),_.jsx("option",{value:20,children:"20"}),_.jsx("option",{value:50,children:"50"}),_.jsx("option",{value:100,children:"100"})]})]}),_.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&&_.jsx("div",{className:"alert alert-danger",children:a.error}),y&&_.jsx("div",{className:"alert alert-danger",children:y}),Object.keys(k).length>0&&_.jsxs("div",{className:"bg-neutral-50 rounded-lg p-3",children:[_.jsx("h4",{className:"text-sm font-semibold mb-2",children:"Resultados por portal:"}),_.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2 text-sm",children:Object.entries(k).map(([e,t])=>_.jsxs("div",{className:"flex items-center justify-between p-2 rounded "+(200===t.status?"bg-green-50":"bg-red-50"),children:[t.image?_.jsx("img",{src:t.image,alt:t.title,className:"w-10 h-10 object-cover rounded"}):_.jsx("span",{className:"font-medium",children:t.title}),_.jsx("span",{className:200===t.status?"text-green-700":"text-red-700",children:200===t.status?`${t.count} imágenes`:t.response})]},e))})]}),$&&_.jsx("div",{className:"mt-6 md:w-full mx-auto",children:_.jsx(X,{image:$,onDiscard:()=>{z(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)&&_.jsxs(_.Fragment,{children:[_.jsxs("div",{className:"mt-6 relative","aria-live":"polite",children:[g&&_.jsx("div",{className:"absolute inset-0 bg-white/80 z-10 flex items-center justify-center rounded-lg",children:_.jsxs("div",{className:"flex flex-col items-center gap-2",children:[_.jsx("span",{className:"limbo-loader"}),_.jsx("span",{className:"text-sm text-brand-blue-800",children:"Buscando imágenes..."})]})}),_.jsxs("div",{className:"relative grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2",children:[_.jsx(re,{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 P.has(a)?null:_.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:()=>!j&&!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=`${M({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"});z(s)}catch(e){v(e.message||"No se pudo recuperar la imagen del portal")}finally{E(null)}})(n),children:[_.jsxs("div",{className:"relative aspect-video bg-neutral-100",children:[_.jsx(ue,{src:i,alt:n.title||n.filename||`Imagen ${r+1}`,className:"object-cover w-full h-full",onError:()=>{A(e=>{const t=new Set(e);return t.add(a),t})}}),_.jsx("span",{className:"absolute top-1 left-1 bg-black/60 text-white text-xs px-2 py-1 rounded",children:n.sourceTitle}),j===(n.url||n.full)?_.jsxs("div",{className:"absolute inset-0 bg-white/90 flex flex-col items-center justify-center gap-2",children:[_.jsxs("div",{className:"relative w-10 h-10",children:[_.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-200 rounded-full"}),_.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-600 rounded-full border-t-transparent animate-spin"})]}),_.jsx("span",{className:"text-sm font-medium text-brand-blue-900",children:"Descargando..."})]}):_.jsx("div",{className:"absolute inset-0 bg-brand-blue-600/0 group-hover:bg-brand-blue-600/20 transition-colors duration-200 flex items-center justify-center",children:_.jsx("svg",{className:"w-12 h-12 text-white opacity-0 group-hover:opacity-100 transition-opacity duration-200",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:_.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})})]}),n.title&&_.jsx("div",{className:"px-2 pb-2 pt-1",children:_.jsx("p",{className:"text-xs text-gray-600 truncate",title:n.title,children:n.title})})]},a)})]})]}),_.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2",children:[_.jsxs("button",{onClick:()=>O(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:[_.jsx("span",{className:"icon icon-arrow-left-white icon--sm"})," ","Anterior"]}),_.jsxs("span",{className:"px-4 py-2 text-sm text-neutral-700",children:["Página ",p,S&&_.jsxs(_.Fragment,{children:[" ","de ",S.pages,_.jsxs("span",{className:"text-xs text-neutral-500 block",children:["(",S.total," imágenes totales)"]})]})]}),_.jsxs("button",{onClick:()=>O(p+1),disabled:g||S&&p>=S.pages,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(g||S&&p>=S.pages?" pointer-events-none cursor-default":" limbo-btn-primary"),children:["Siguiente"," ",_.jsx("span",{className:"icon icon-arrow-right-white icon--sm"})]})]})]}),!g&&0===x.length&&Object.keys(k).length>0&&_.jsxs("div",{className:"mt-6 text-center text-neutral-600 py-8 bg-neutral-50 rounded-lg",children:[_.jsx("span",{className:"icon icon-search icon--lg mb-2"}),_.jsx("p",{children:"No se encontraron imágenes en los portales seleccionados"}),u&&_.jsx("p",{className:"text-sm mt-1",children:"Intenta con otros términos o sin filtro de nombre"})]})]}):_.jsx("div",{className:"alert alert-warning",children:"No hay portales externos disponibles."})}const me=[{id:"upload",label:"Subir archivo"},{id:"ai",label:"Generar con IA"},{id:"stock",label:"Buscar en Stock"},{id:"portals",label:"Otros portales"}];function he({onSelect:e,onSubTabChange:t=null,onServiceChange:n=null,disabled:r=!1,apiKey:a,prod:i=!1}){const[o,s]=l.useState("upload"),[u,d]=l.useState(null),[m,h]=l.useState(null),p=l.useRef();c.useEffect(()=>{t&&t(o)},[o,t]);const f=e=>{n&&e&&n(o,e)};return _.jsxs("div",{className:"limbo-upload-form py-4 min-w-fit max-w-7xl mx-auto",children:[_.jsx("div",{className:"limbo-tabs-container",children:_.jsx("div",{className:"limbo-tabs mb-1 min-w-fit",role:"tablist","aria-label":"Opciones de subida de imagen",children:me.map(e=>_.jsx("button",{type:"button","data-upload-tab-id":e.id,className:"text-nowrap limbo-tab"+(o===e.id?" active":""),"aria-current":o===e.id?"page":void 0,"aria-selected":o===e.id,role:"tab",tabIndex:o===e.id?0:-1,onClick:()=>s(e.id),onKeyDown:t=>((e,t)=>{const n=me.findIndex(e=>e.id===t);let r=n;switch(e.key){case"ArrowLeft":e.preventDefault(),r=n>0?n-1:me.length-1;break;case"ArrowRight":e.preventDefault(),r=n<me.length-1?n+1:0;break;case"Home":e.preventDefault(),r=0;break;case"End":e.preventDefault(),r=me.length-1;break;case"Enter":case" ":return e.preventDefault(),void s(t);default:return}const a=me[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}`,children:e.label},e.id))})}),_.jsxs("div",{className:"limbo-tab-content px-2 py-2",role:"tabpanel",id:`upload-tabpanel-${o}`,"aria-labelledby":`upload-tab-${o}`,children:["upload"===o&&_.jsx(J,{file:u,setFile:d,previewUrl:m,setPreviewUrl:h,fileInputRef:p,onSelect:e,disabled:r}),"ai"===o&&_.jsx(ae,{apiKey:a,prod:i,disabled:r,onSelect:e,onServiceChange:f}),"stock"===o&&_.jsx(se,{apiKey:a,prod:i,disabled:r,onSelect:e,onServiceChange:f}),"portals"===o&&_.jsx(de,{apiKey:a,prod:i,disabled:r,onSelect:e})]})]})}const pe="undefined"!=typeof window&&void 0!==window.document,fe=pe?window:{},ge=!!pe&&"ontouchstart"in fe.document.documentElement,be=!!pe&&"PointerEvent"in fe,ye="cropper",ve=`${ye}-canvas`,xe=`${ye}-crosshair`,we=`${ye}-grid`,ke=`${ye}-handle`,Ce=`${ye}-image`,Se=`${ye}-selection`,Ne=`${ye}-shade`,je=`${ye}-viewer`,Ee="select",$e="move",_e="scale",ze="rotate",Te="transform",Pe="none",Ae="n-resize",Me="e-resize",Ie="s-resize",Le="w-resize",Oe="ne-resize",Re="nw-resize",De="se-resize",Fe="sw-resize",Ue=be?"pointerdown":ge?"touchstart":"mousedown",qe=be?"pointermove":ge?"touchmove":"mousemove",Be=be?"pointerup pointercancel":ge?"touchend touchcancel":"mouseup",He="error",We="keydown",Ve="load",Ke="wheel",Ge="action",Qe="actionend",Ye="actionstart",Xe="change",Je="transform",Ze=Number.isNaN||fe.isNaN;function et(e){return"number"==typeof e&&!Ze(e)}function tt(e){return et(e)&&e>0&&e<1/0}function nt(e){return"object"==typeof e&&null!==e}const{hasOwnProperty:rt}=Object.prototype;function at(e){if(!nt(e))return!1;try{const{constructor:t}=e,{prototype:n}=t;return t&&n&&rt.call(n,"isPrototypeOf")}catch(e){return!1}}function it(e){return"function"==typeof e}function ot(e){return"object"==typeof e&&null!==e&&1===e.nodeType}const st=/([a-z\d])([A-Z])/g;function lt(e){return String(e).replace(st,"$1-$2").toLowerCase()}const ct=/-[A-z\d]/g;function ut(e){return e.replace(ct,e=>e.slice(1).toUpperCase())}const dt=/\s\s*/;function mt(e,t,n,r){t.trim().split(dt).forEach(t=>{e.removeEventListener(t,n,r)})}function ht(e,t,n,r){t.trim().split(dt).forEach(t=>{e.addEventListener(t,n,r)})}function pt(e,t,n,r){ht(e,t,n,Object.assign(Object.assign({},r),{once:!0}))}const ft={bubbles:!0,cancelable:!0,composed:!0},gt=Promise.resolve();function bt(e){const{documentElement:t}=e.ownerDocument,n=e.getBoundingClientRect();return{left:n.left+(fe.pageXOffset-t.clientLeft),top:n.top+(fe.pageYOffset-t.clientTop)}}const yt=/deg|g?rad|turn$/i;function vt(e){const t=parseFloat(e)||0;if(0!==t){const[n="rad"]=String(e).match(yt)||[];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 xt="contain";function wt(e,t=xt){const{aspectRatio:n}=e;let{width:r,height:a}=e;const i=tt(r),o=tt(a);if(i&&o){const e=a*n;t===xt&&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 kt(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 kt(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 Ct=/left|top|width|height/i,St="open",Nt=new WeakMap,jt=new WeakMap,Et=new Map,$t=fe.document&&Array.isArray(fe.document.adoptedStyleSheets)&&"replaceSync"in fe.CSSStyleSheet.prototype;class _t extends HTMLElement{get $sharedStyle(){return(this.themeColor?`:host{--theme-color: ${this.themeColor};}`:"")+":host([hidden]){display:none!important}"}constructor(){var e,t;super(),this.shadowRootMode=St,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&&Et.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=ut(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=jt.get(this),t=this.$sharedStyle;e&&t&&($t?e.replaceSync(t):e.textContent=t);break}}}$propertyChangedCallback(e,t,n){if(!Object.is(n,t))switch(e=lt(e),typeof n){case"boolean":!0===n?this.hasAttribute(e)||this.setAttribute(e,""):this.removeAttribute(e);break;case"number":n=Ze(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=ut(e);let n=this[t];(function(e){return void 0===e})(n)||this.$propertyChangedCallback(t,void 0,n),Object.defineProperty(this,t,{enumerable:!0,configurable:!0,get:()=>n,set(e){const r=n;n=e,this.$propertyChangedCallback(t,r,e)}})});const e=this.attachShadow({mode:this.shadowRootMode||St});if(this.shadowRoot||Nt.set(this,e),jt.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(){jt.has(this)&&jt.delete(this),Nt.has(this)&&Nt.delete(this)}$getTagNameOf(e){var t;return null!==(t=Et.get(e))&&void 0!==t?t:e}$setStyles(e){return Object.keys(e).forEach(t=>{let n=e[t];et(n)&&(n=0!==n&&Ct.test(t)?`${n}px`:String(n)),this.style[t]=n}),this}$getShadowRoot(){return this.shadowRoot||Nt.get(this)}$addStyles(e){let t;const n=this.$getShadowRoot();return $t?(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({},ft),{detail:n}),r)))}(this,e,t,n)}$nextTick(e){return function(e,t){return t?gt.then(e?t.bind(e):t):gt}(this,e)}static $define(e,t){nt(e)&&(t=e,e=""),e||(e=this.$name||this.name),e=lt(e),pe&&fe.customElements&&!fe.customElements.get(e)&&customElements.define(e,this,t)}}_t.$version="2.0.0";class zt extends _t{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=Pe,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){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),ht(this,Ue,this.$onPointerDown)),this.$onPointerMove||(this.$onPointerMove=this.$handlePointerMove.bind(this),ht(this.ownerDocument,qe,this.$onPointerMove)),this.$onPointerUp||(this.$onPointerUp=this.$handlePointerUp.bind(this),ht(this.ownerDocument,Be,this.$onPointerUp)),this.$onWheel||(this.$onWheel=this.$handleWheel.bind(this),ht(this,Ke,this.$onWheel,{passive:!1,capture:!0}))}$unbind(){this.$onPointerDown&&(mt(this,Ue,this.$onPointerDown),this.$onPointerDown=null),this.$onPointerMove&&(mt(this.ownerDocument,qe,this.$onPointerMove),this.$onPointerMove=null),this.$onPointerUp&&(mt(this.ownerDocument,Be,this.$onPointerUp),this.$onPointerUp=null),this.$onWheel&&(mt(this,Ke,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)&&(et(t)&&1!==t||et(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=Te:ot(e.target)&&(i=e.target.action||e.target.getAttribute("action")||""),!1!==this.$emit(Ye,{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===Pe||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===Te){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=ze,r.rotate=o,r.centerX=l,r.centerY=c):d?(r.action=_e,r.scale=s,r.centerX=l,r.centerY=c):r.action=Pe}else{const[e]=Array.from(n.values());Object.assign(r,e)}n.forEach(e=>{e.startX=e.endX,e.startY=e.endY}),r.action!==Pe&&this.$emit(Ge,r,{cancelable:!1})}$handlePointerUp(e){const{$action:t,$pointers:n}=this;if(!this.disabled&&t!==Pe&&!1!==this.$emit(Qe,{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=Pe)}}$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(Ge,{action:_e,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;at(e)&&(tt(e.width)||tt(e.height))&&(({width:a,height:i}=wt({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(Ce));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),at(e)&&it(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)})}}zt.$name=ve,zt.$version="2.0.0";const Tt=new WeakMap,Pt=["alt","crossorigin","decoding","importance","loading","referrerpolicy","sizes","src","srcset"];class At extends _t{constructor(){super(...arguments),this.$matrix=[1,0,0,1,0,0],this.$onLoad=null,this.$onCanvasAction=null,this.$onCanvasActionEnd=null,this.$onCanvasActionStart=null,this.$actionStartTarget=null,this.$style=":host{display:inline-block}img{display:block;height:100%;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;width:100%}",this.$image=new Image,this.initialCenterSize="contain",this.rotatable=!1,this.scalable=!1,this.skewable=!1,this.slottable=!1,this.translatable=!1}set $canvas(e){Tt.set(this,e)}get $canvas(){return Tt.get(this)}static get observedAttributes(){return super.observedAttributes.concat(Pt,["initial-center-size","rotatable","scalable","skewable","translatable"])}attributeChangedCallback(e,t,n){Object.is(n,t)||(super.attributeChangedCallback(e,t,n),Pt.includes(e)&&this.$image.setAttribute(e,n))}$propertyChangedCallback(e,t,n){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(ve));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),ht(t,Ye,this.$onCanvasActionStart),ht(t,Qe,this.$onCanvasActionEnd),ht(t,Ge,this.$onCanvasAction)),this.$onLoad=this.$handleLoad.bind(this),ht(e,Ve,this.$onLoad),this.$getShadowRoot().appendChild(e)}disconnectedCallback(){const{$image:e,$canvas:t}=this;t&&(this.$onCanvasActionStart&&(mt(t,Ye,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(mt(t,Qe,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(mt(t,Ge,this.$onCanvasAction),this.$onCanvasAction=null)),e&&this.$onLoad&&(mt(e,Ve,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!==Te||this.rotatable&&this.scalable||(r=this.rotatable?ze:this.scalable?_e:Pe),r){case $e:if(this.translatable){let r=null;e&&(r=e.target.closest(this.$getTagNameOf(Se))),r||(r=t.querySelector(this.$getTagNameOf(Se))),r&&r.multiple&&!r.active&&(r=t.querySelector(`${this.$getTagNameOf(Se)}[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 ze: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 _e:if(this.scalable)if(e){const t=e.target.closest(this.$getTagNameOf(Se));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 Te: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=()=>{mt(t,He,i),e(t)},i=()=>{mt(t,Ve,a),n(r)};pt(t,Ve,a),pt(t,He,i)}});return it(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&&et(e)&&et(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&&et(e)&&et(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=vt(e),a=Math.cos(r),i=Math.sin(r),[o,s,l,c]=[a,i,-i,a];if(et(t)&&et(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,et(t)&&et(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=vt(e),r=vt(t);this.$transform(1,Math.tan(r),Math.tan(n),1,0,0)}return this}$translate(e,t=e){return this.translatable&&et(e)&&et(t)&&this.$transform(1,0,0,1,e,t),this}$transform(e,t,n,r,a,i){return et(e)&&et(t)&&et(n)&&et(r)&&et(a)&&et(i)?this.$setTransform(kt(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),et(e)&&et(t)&&et(n)&&et(r)&&et(a)&&et(i))){const o=[...this.$matrix],s=[e,t,n,r,a,i];if(!1===this.$emit(Je,{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])}}At.$name=Ce,At.$version="2.0.0";const Mt=new WeakMap;class It extends _t{constructor(){super(...arguments),this.$onCanvasChange=null,this.$onCanvasActionEnd=null,this.$onCanvasActionStart=null,this.$style=":host{display:block;height:0;left:0;outline:var(--theme-color) solid 1px;position:relative;top:0;width:0}:host([transparent]){outline-color:transparent}",this.x=0,this.y=0,this.width=0,this.height=0,this.slottable=!1,this.themeColor="rgba(0, 0, 0, 0.65)"}set $canvas(e){Mt.set(this,e)}get $canvas(){return Mt.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["height","width","x","y"])}connectedCallback(){super.connectedCallback();const e=this.closest(this.$getTagNameOf(ve));if(e){this.$canvas=e,this.style.position="absolute";const t=e.querySelector(this.$getTagNameOf(Se));t&&(this.$onCanvasActionStart=e=>{t.hidden&&e.detail.action===Ee&&(this.hidden=!1)},this.$onCanvasActionEnd=e=>{t.hidden&&e.detail.action===Ee&&(this.hidden=!0)},this.$onCanvasChange=e=>{const{x:n,y:r,width:a,height:i}=e.detail;this.$change(n,r,a,i),(t.hidden||0===n&&0===r&&0===a&&0===i)&&(this.hidden=!0)},ht(e,Ye,this.$onCanvasActionStart),ht(e,Qe,this.$onCanvasActionEnd),ht(e,Xe,this.$onCanvasChange))}this.$render()}disconnectedCallback(){const{$canvas:e}=this;e&&(this.$onCanvasActionStart&&(mt(e,Ye,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(mt(e,Qe,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasChange&&(mt(e,Xe,this.$onCanvasChange),this.$onCanvasChange=null)),super.disconnectedCallback()}$change(e,t,n=this.width,r=this.height){return et(e)&&et(t)&&et(n)&&et(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:fe.innerWidth})}}It.$name=Ne,It.$version="2.0.0";class Lt extends _t{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=Pe,this.plain=!1,this.slottable=!1,this.themeColor="rgba(51, 153, 255, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["action","plain"])}}Lt.$name=ke,Lt.$version="2.0.0";const Ot=new WeakMap;class Rt extends _t{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){Ot.set(this,e)}get $canvas(){return Ot.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(()=>{tt(n)&&n<=1&&this.$initSelection(!0,!0)});break;case"keyboard":this.$nextTick(()=>{this.$canvas&&(n?this.$onDocumentKeyDown||(this.$onDocumentKeyDown=this.$handleKeyDown.bind(this),ht(this.ownerDocument,We,this.$onDocumentKeyDown)):this.$onDocumentKeyDown&&(mt(this.ownerDocument,We,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(Xe,{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(ve));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),ht(e,Ye,this.$onCanvasActionStart),ht(e,Qe,this.$onCanvasActionEnd),ht(e,Ge,this.$onCanvasAction)):this.$render()}disconnectedCallback(){const{$canvas:e}=this;e&&(this.$onCanvasActionStart&&(mt(e,Ye,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(mt(e,Qe,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(mt(e,Ge,this.$onCanvasAction),this.$onCanvasAction=null)),super.disconnectedCallback()}$getSelections(){let e=[];return this.parentElement&&(e=Array.from(this.parentElement.querySelectorAll(this.$getTagNameOf(Se)))),e}$initSelection(e=!1,t=!1){const{initialCoverage:n,parentElement:r}=this;if(tt(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;tt(a)&&({width:i,height:o}=wt({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(Xe,{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(Xe,{x:this.x,y:this.y,width:this.width,height:this.height}))}$handleAction(e){const{currentTarget:t,detail:n}=e;if(!t||!n)return;const{relatedEvent:r}=n;let{action:a}=n;if(!a&&this.multiple&&(a=this.$action||(null==r?void 0:r.target.action),this.$action=a),!a||this.hidden&&a!==Ee||this.multiple&&!this.active&&a!==_e)return;const i=n.endX-n.startX,o=n.endY-n.startY,{width:s,height:l}=this;let{aspectRatio:c}=this;switch(!tt(c)&&r.shiftKey&&(c=tt(s)&&tt(l)?s/l:1),a){case Ee:if(0!==i&&0!==o){const{$canvas:e}=this,r=bt(t);(this.multiple&&!this.hidden?this.$createSelection():this).$change(n.startX-r.left,n.startY-r.top,Math.abs(i),Math.abs(o),c),i<0?o<0?a=Re:o>0&&(a=Fe):i>0&&(o<0?a=Oe:o>0&&(a=De)),e&&(e.$action=a)}break;case $e:this.movable&&(this.dynamic||this.$actionStartTarget&&this.contains(this.$actionStartTarget))&&this.$move(i,o);break;case _e:if(r&&this.zoomable&&(this.dynamic||this.contains(r.target))){const e=bt(t);this.$zoom(n.scale,r.pageX-e.left,r.pageY-e.top)}break;default:this.$resize(a,i,o,c)}}$handleActionEnd(){this.$action="",this.$actionStartTarget=null}$handleKeyDown(e){if(this.hidden||!this.keyboard||this.multiple&&!this.active||e.defaultPrevented)return;const{activeElement:t}=document;if(!t||!["INPUT","TEXTAREA"].includes(t.tagName)&&!["true","plaintext-only"].includes(t.contentEditable))switch(e.key){case"Backspace":e.metaKey&&(e.preventDefault(),this.$removeSelection());break;case"Delete":e.preventDefault(),this.$removeSelection();break;case"ArrowLeft":e.preventDefault(),this.$move(-1,0);break;case"ArrowRight":e.preventDefault(),this.$move(1,0);break;case"ArrowUp":e.preventDefault(),this.$move(0,-1);break;case"ArrowDown":e.preventDefault(),this.$move(0,1);break;case"+":e.preventDefault(),this.$zoom(.1);break;case"-":e.preventDefault(),this.$zoom(-.1)}}$center(){const{parentElement:e}=this;if(!e)return this;const t=(e.offsetWidth-this.width)/2,n=(e.offsetHeight-this.height)/2;return this.$change(t,n)}$move(e,t=e){return this.$moveTo(this.x+e,this.y+t)}$moveTo(e,t=e){return this.movable?this.$change(e,t):this}$resize(e,t=0,n=0,r=this.aspectRatio){if(!this.resizable)return this;const a=tt(r),{$canvas:i}=this;let{x:o,y:s,width:l,height:c}=this;switch(e){case Ae:s+=n,c-=n,c<0&&(e=Ie,c=-c,s-=c),a&&(o+=(t=n*r)/2,l-=t,l<0&&(l=-l,o-=l));break;case Me:l+=t,l<0&&(e=Le,l=-l,o-=l),a&&(s-=(n=t/r)/2,c+=n,c<0&&(c=-c,s-=c));break;case Ie:c+=n,c<0&&(e=Ae,c=-c,s-=c),a&&(o-=(t=n*r)/2,l+=t,l<0&&(l=-l,o-=l));break;case Le:o+=t,l-=t,l<0&&(e=Me,l=-l,o-=l),a&&(s+=(n=t/r)/2,c-=n,c<0&&(c=-c,s-=c));break;case Oe:a&&(n=-t/r),s+=n,c-=n,l+=t,l<0&&c<0?(e=Fe,l=-l,c=-c,o-=l,s-=c):l<0?(e=Re,l=-l,o-=l):c<0&&(e=De,c=-c,s-=c);break;case Re:a&&(n=t/r),o+=t,s+=n,l-=t,c-=n,l<0&&c<0?(e=De,l=-l,c=-c,o-=l,s-=c):l<0?(e=Oe,l=-l,o-=l):c<0&&(e=Fe,c=-c,s-=c);break;case De:a&&(n=t/r),l+=t,c+=n,l<0&&c<0?(e=Re,l=-l,c=-c,o-=l,s-=c):l<0?(e=Fe,l=-l,o-=l):c<0&&(e=Oe,c=-c,s-=c);break;case Fe:a&&(n=-t/r),o+=t,l-=t,c+=n,l<0&&c<0?(e=Oe,l=-l,c=-c,o-=l,s-=c):l<0?(e=De,l=-l,o-=l):c<0&&(e=Re,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 et(t)&&et(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||!et(e)||!et(t)||!et(n)||!et(r)||n<0||r<0?this:(tt(a)&&({width:n,height:r}=wt({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(Xe,{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(at(e)&&(tt(e.width)||tt(e.height))&&(({width:a,height:i}=wt({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(Ce));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,C=w/2;l.fillStyle="transparent",l.fillRect(0,0,a,i),at(e)&&it(e.beforeDraw)&&e.beforeDraw.call(this,l,r),l.save(),l.translate(k,C),l.transform(t,c,u,d,y,v),l.translate(-k,-C),l.drawImage(n,0,0,x,w),l.restore()}t(r)}).catch(n):t(r)})}}Rt.$name=Se,Rt.$version="2.0.0";class Dt extends _t{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 e=0;e<this.rows;e+=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))}}Dt.$name=we,Dt.$version="2.0.0";class Ft extends _t{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"])}}Ft.$name=xe,Ft.$version="2.0.0";const Ut=new WeakMap,qt=new WeakMap,Bt=new WeakMap,Ht=new WeakMap,Wt="vertical";class Vt extends _t{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=Wt,this.selection="",this.slottable=!1}set $image(e){qt.set(this,e)}get $image(){return qt.get(this)}set $sourceImage(e){Ht.set(this,e)}get $sourceImage(){return Ht.get(this)}set $canvas(e){Ut.set(this,e)}get $canvas(){return Ut.get(this)}set $selection(e){Bt.set(this,e)}get $selection(){return Bt.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["resize","selection"])}connectedCallback(){super.connectedCallback();let e=null;if(e=this.selection?this.ownerDocument.querySelector(this.selection):this.closest(this.$getTagNameOf(Se)),ot(e)){this.$selection=e,this.$onSelectionChange=this.$handleSelectionChange.bind(this),ht(e,Xe,this.$onSelectionChange);const t=e.closest(this.$getTagNameOf(ve));if(t){this.$canvas=t;const e=t.querySelector(this.$getTagNameOf(Ce));e&&(this.$sourceImage=e,this.$image=e.cloneNode(!0),this.$getShadowRoot().appendChild(this.$image),this.$onSourceImageLoad=this.$handleSourceImageLoad.bind(this),this.$onSourceImageTransform=this.$handleSourceImageTransform.bind(this),ht(e.$image,Ve,this.$onSourceImageLoad),ht(e,Je,this.$onSourceImageTransform))}this.$render()}}disconnectedCallback(){const{$selection:e,$sourceImage:t}=this;e&&this.$onSelectionChange&&(mt(e,Xe,this.$onSelectionChange),this.$onSelectionChange=null),t&&this.$onSourceImageLoad&&(mt(t.$image,Ve,this.$onSourceImageLoad),this.$onSourceImageLoad=null),t&&this.$onSourceImageTransform&&(mt(t,Je,this.$onSourceImageTransform),this.$onSourceImageTransform=null),super.disconnectedCallback()}$handleSelectionChange(e){this.$render(e.detail)}$handleSourceImageLoad(){const{$image:e,$sourceImage:t}=this,n=e.getAttribute("src"),r=t.getAttribute("src");r&&r!==n&&(e.setAttribute("src",r),e.$ready(()=>{setTimeout(()=>{this.$render()},50)}))}$handleSourceImageTransform(e){this.$render(void 0,e.detail.matrix)}$render(e,t){const{$canvas:n,$selection:r}=this;e||r.hidden||(e=r),(!e||0===e.x&&0===e.y&&0===e.width&&0===e.height)&&(e={x:0,y:0,width:n.offsetWidth,height:n.offsetHeight});const{x:a,y:i,width:o,height:s}=e,l={},{clientWidth:c,clientHeight:u}=this;let d=c,m=u,h=NaN;switch(this.resize){case"both":h=1,d=o,m=s,l.width=o,l.height=s;break;case"horizontal":h=s>0?u/s:0,d=o*h,l.width=d;break;case Wt:h=o>0?c/o:0,m=s*h,l.height=m;break;default:c>0?h=o>0?c/o:0:u>0&&(h=s>0?u/s:0)}this.$scale=h,this.$setStyles(l),this.$sourceImage&&this.$transformImageByOffset(null!=t?t:this.$sourceImage.$getTransform(),-a,-i)}$transformImageByOffset(e,t,n){const{$image:r,$scale:a,$sourceImage:i}=this;if(i&&r&&a>=0){const[i,o,s,l,c,u]=e,d=(t*l-s*n)/(i*l-s*o),m=(n*i-o*t)/(i*l-s*o),h=i*d+s*m+c,p=o*d+l*m+u;r.$ready(e=>{this.$setStyles.call(r,{width:e.naturalWidth*a,height:e.naturalHeight*a})}),r.$setTransform(i,o,s,l,h*a,p*a)}}}Vt.$name=je,Vt.$version="2.0.0",
|
|
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}}var r,a,i={exports:{}},o={};function s(){return a||(a=1,i.exports=function(){if(r)return o;r=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.iterator,p={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},f=Object.assign,g={};function b(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||p}function y(){}function v(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||p}b.prototype.isReactComponent={},b.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},b.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},y.prototype=b.prototype;var x=v.prototype=new y;x.constructor=v,f(x,b.prototype),x.isPureReactComponent=!0;var w=Array.isArray,k={H:null,A:null,T:null,S:null,V:null},C=Object.prototype.hasOwnProperty;function S(t,n,r,a,i,o){return r=o.ref,{$$typeof:e,type:t,key:n,ref:void 0!==r?r:null,props:o}}function N(t){return"object"==typeof t&&null!==t&&t.$$typeof===e}var j=/\/+/g;function E(e,t){return"object"==typeof e&&null!==e&&null!=e.key?(n=""+e.key,r={"=":"=0",":":"=2"},"$"+n.replace(/[=:]/g,function(e){return r[e]})):t.toString(36);var n,r}function $(){}function _(n,r,a,i,o){var s=typeof n;"undefined"!==s&&"boolean"!==s||(n=null);var l,c,u=!1;if(null===n)u=!0;else switch(s){case"bigint":case"string":case"number":u=!0;break;case"object":switch(n.$$typeof){case e:case t:u=!0;break;case m:return _((u=n._init)(n._payload),r,a,i,o)}}if(u)return o=o(n),u=""===i?"."+E(n,0):i,w(o)?(a="",null!=u&&(a=u.replace(j,"$&/")+"/"),_(o,r,a,"",function(e){return e})):null!=o&&(N(o)&&(l=o,c=a+(null==o.key||n&&n.key===o.key?"":(""+o.key).replace(j,"$&/")+"/")+u,o=S(l.type,c,void 0,0,0,l.props)),r.push(o)),1;u=0;var d,p=""===i?".":i+":";if(w(n))for(var f=0;f<n.length;f++)u+=_(i=n[f],r,a,s=p+E(i,f),o);else if("function"==typeof(f=null===(d=n)||"object"!=typeof d?null:"function"==typeof(d=h&&d[h]||d["@@iterator"])?d:null))for(n=f.call(n),f=0;!(i=n.next()).done;)u+=_(i=i.value,r,a,s=p+E(i,f++),o);else if("object"===s){if("function"==typeof n.then)return _(function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch("string"==typeof e.status?e.then($,$):(e.status="pending",e.then(function(t){"pending"===e.status&&(e.status="fulfilled",e.value=t)},function(t){"pending"===e.status&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}(n),r,a,i,o);throw r=String(n),Error("Objects are not valid as a React child (found: "+("[object Object]"===r?"object with keys {"+Object.keys(n).join(", ")+"}":r)+"). If you meant to render a collection of children, use an array instead.")}return u}function z(e,t,n){if(null==e)return e;var r=[],a=0;return _(e,r,"","",function(e){return t.call(n,e,a++)}),r}function T(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var 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)};function A(){}return o.Children={map:z,forEach:function(e,t,n){z(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return z(e,function(){t++}),t},toArray:function(e){return z(e,function(e){return e})||[]},only:function(e){if(!N(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},o.Component=b,o.Fragment=n,o.Profiler=i,o.PureComponent=v,o.StrictMode=a,o.Suspense=u,o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=k,o.__COMPILER_RUNTIME={__proto__:null,c:function(e){return k.H.useMemoCache(e)}},o.cache=function(e){return function(){return e.apply(null,arguments)}},o.cloneElement=function(e,t,n){if(null==e)throw Error("The argument must be a React element, but you passed "+e+".");var r=f({},e.props),a=e.key;if(null!=t)for(i in t.ref,void 0!==t.key&&(a=""+t.key),t)!C.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 S(e.type,a,void 0,0,0,r)},o.createContext=function(e){return(e={$$typeof:l,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider=e,e.Consumer={$$typeof:s,_context:e},e},o.createElement=function(e,t,n){var r,a={},i=null;if(null!=t)for(r in void 0!==t.key&&(i=""+t.key),t)C.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 S(e,i,void 0,0,0,a)},o.createRef=function(){return{current:null}},o.forwardRef=function(e){return{$$typeof:c,render:e}},o.isValidElement=N,o.lazy=function(e){return{$$typeof:m,_payload:{_status:-1,_result:e},_init:T}},o.memo=function(e,t){return{$$typeof:d,type:e,compare:void 0===t?null:t}},o.startTransition=function(e){var t=k.T,n={};k.T=n;try{var r=e(),a=k.S;null!==a&&a(n,r),"object"==typeof r&&null!==r&&"function"==typeof r.then&&r.then(A,P)}catch(e){P(e)}finally{k.T=t}},o.unstable_useCacheRefresh=function(){return k.H.useCacheRefresh()},o.use=function(e){return k.H.use(e)},o.useActionState=function(e,t,n){return k.H.useActionState(e,t,n)},o.useCallback=function(e,t){return k.H.useCallback(e,t)},o.useContext=function(e){return k.H.useContext(e)},o.useDebugValue=function(){},o.useDeferredValue=function(e,t){return k.H.useDeferredValue(e,t)},o.useEffect=function(e,t,n){var r=k.H;if("function"==typeof n)throw Error("useEffect CRUD overload is not enabled in this build of React.");return r.useEffect(e,t)},o.useId=function(){return k.H.useId()},o.useImperativeHandle=function(e,t,n){return k.H.useImperativeHandle(e,t,n)},o.useInsertionEffect=function(e,t){return k.H.useInsertionEffect(e,t)},o.useLayoutEffect=function(e,t){return k.H.useLayoutEffect(e,t)},o.useMemo=function(e,t){return k.H.useMemo(e,t)},o.useOptimistic=function(e,t){return k.H.useOptimistic(e,t)},o.useReducer=function(e,t,n){return k.H.useReducer(e,t,n)},o.useRef=function(e){return k.H.useRef(e)},o.useState=function(e){return k.H.useState(e)},o.useSyncExternalStore=function(e,t,n){return k.H.useSyncExternalStore(e,t,n)},o.useTransition=function(){return k.H.useTransition()},o.version="19.1.1",o}()),i.exports}var l=s();const c=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(l);var u,d,m={exports:{}},h={},p={exports:{}},f={};function g(){return d||(d=1,p.exports=(u||(u=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,C||(C=!0,k());else{var t=n(c);null!==t&&T(w,t.startTime-e)}}var k,C=!1,S=-1,N=5,j=-1;function E(){return!(!g&&e.unstable_now()-j<N)}function $(){if(g=!1,C){var t=e.unstable_now();j=t;var a=!0;try{e:{p=!1,f&&(f=!1,y(S),S=-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():C=!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){S=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"):N=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(S),S=-1):f=!0,T(w,i-o))):(r.sortIndex=s,t(l,r),p||h||(p=!0,C||(C=!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}}}}(f)),f)),p.exports}var b,y,v,x,w={exports:{}},k={};function C(){if(b)return k;b=1;var e=s();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"),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 k.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,k.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)},k.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()}},k.preconnect=function(e,t){"string"==typeof e&&(t=t?"string"==typeof(t=t.crossOrigin)?"use-credentials"===t?t:"":void 0:null,r.d.C(e,t))},k.prefetchDNS=function(e){"string"==typeof e&&r.d.D(e)},k.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})}},k.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)},k.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})}},k.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)},k.requestFormReset=function(e){r.d.r(e)},k.unstable_batchedUpdates=function(e,t){return e(t)},k.useFormState=function(e,t,n){return i.H.useFormState(e,t,n)},k.useFormStatus=function(){return i.H.useHostTransitionStatus()},k.version="19.1.1",k}var S,N,j=(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(e){console.error(e)}}(),m.exports=function(){if(v)return h;v=1;var e=g(),t=s(),n=(y||(y=1,function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}(),w.exports=C()),w.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 l(e){if(i(e)!==e)throw Error(r(188))}function c(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=c(e)))return t;e=e.sibling}return null}var u=Object.assign,d=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),k=Symbol.for("react.provider"),S=Symbol.for("react.consumer"),N=Symbol.for("react.context"),j=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"),P=Symbol.for("react.memo_cache_sentinel"),A=Symbol.iterator;function M(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=A&&e[A]||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 f:return"Fragment";case x: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 N:return(e.displayName||"Context")+".Provider";case S:return(e._context.displayName||"Context")+".Consumer";case j: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(e){}}return null}var O=Array.isArray,R=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},U=[],q=-1;function B(e){return{current:e}}function H(e){0>q||(e.current=U[q],U[q]=null,q--)}function W(e,t){q++,U[q]=e.current,e.current=t}var V=B(null),K=B(null),G=B(null),Q=B(null);function Y(e,t){switch(W(G,t),W(K,e),W(V,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?ld(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)e=cd(t=ld(t),e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}H(V),W(V,e)}function X(){H(V),H(K),H(G)}function J(e){null!==e.memoizedState&&W(Q,e);var t=V.current,n=cd(t,e.type);t!==n&&(W(K,e),W(V,n))}function Z(e){K.current===e&&(H(V),H(K)),Q.current===e&&(H(Q),Jd._currentValue=F)}var ee=Object.prototype.hasOwnProperty,te=e.unstable_scheduleCallback,ne=e.unstable_cancelCallback,re=e.unstable_shouldYield,ae=e.unstable_requestPaint,ie=e.unstable_now,oe=e.unstable_getCurrentPriorityLevel,se=e.unstable_ImmediatePriority,le=e.unstable_UserBlockingPriority,ce=e.unstable_NormalPriority,ue=e.unstable_LowPriority,de=e.unstable_IdlePriority,me=e.log,he=e.unstable_setDisableYieldValue,pe=null,fe=null;function ge(e){if("function"==typeof me&&he(e),fe&&"function"==typeof fe.setStrictMode)try{fe.setStrictMode(pe,e)}catch(e){}}var be=Math.clz32?Math.clz32:function(e){return 0==(e>>>=0)?32:31-(ye(e)/ve|0)|0},ye=Math.log,ve=Math.LN2,xe=256,we=4194304;function ke(e){var t=42&e;if(0!==t)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return 4194048&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Ce(e,t,n){var r=e.pendingLanes;if(0===r)return 0;var a=0,i=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=134217727&r;return 0!==s?0!==(r=s&~i)?a=ke(r):0!==(o&=s)?a=ke(o):n||0!==(n=s&~e)&&(a=ke(n)):0!==(s=r&~i)?a=ke(s):0!==o?a=ke(o):n||0!==(n=r&~e)&&(a=ke(n)),0===a?0:0!==t&&t!==a&&0===(t&i)&&((i=a&-a)>=(n=t&-t)||32===i&&4194048&n)?t:a}function Se(e,t){return 0===(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)}function Ne(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 je(){var e=xe;return!(4194048&(xe<<=1))&&(xe=256),e}function Ee(){var e=we;return!(62914560&(we<<=1))&&(we=4194304),e}function $e(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function _e(e,t){e.pendingLanes|=t,268435456!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ze(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-be(t);e.entangledLanes|=t,e.entanglements[r]=1073741824|e.entanglements[r]|4194090&n}function Te(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-be(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}function Pe(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 Ae(e){return 2<(e&=-e)?8<e?134217727&e?32:268435456:8:2}function Me(){var e=D.p;return 0!==e?e:void 0===(e=window.event)?32:hm(e.type)}var Ie=Math.random().toString(36).slice(2),Le="__reactFiber$"+Ie,Oe="__reactProps$"+Ie,Re="__reactContainer$"+Ie,De="__reactEvents$"+Ie,Fe="__reactListeners$"+Ie,Ue="__reactHandles$"+Ie,qe="__reactResources$"+Ie,Be="__reactMarker$"+Ie;function He(e){delete e[Le],delete e[Oe],delete e[De],delete e[Fe],delete e[Ue]}function We(e){var t=e[Le];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Re]||n[Le]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=Cd(e);null!==e;){if(n=e[Le])return n;e=Cd(e)}return t}n=(e=n).parentNode}return null}function Ve(e){if(e=e[Le]||e[Re]){var t=e.tag;if(5===t||6===t||13===t||26===t||27===t||3===t)return e}return null}function Ke(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e.stateNode;throw Error(r(33))}function Ge(e){var t=e[qe];return t||(t=e[qe]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Qe(e){e[Be]=!0}var Ye=new Set,Xe={};function Je(e,t){Ze(e,t),Ze(e+"Capture",t)}function Ze(e,t){for(Xe[e]=t,e=0;e<t.length;e++)Ye.add(t[e])}var et,tt,nt=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),rt={},at={};function it(e,t,n){if(a=t,ee.call(at,a)||!ee.call(rt,a)&&(nt.test(a)?at[a]=!0:(rt[a]=!0,0)))if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":return void e.removeAttribute(t);case"boolean":var r=t.toLowerCase().slice(0,5);if("data-"!==r&&"aria-"!==r)return void e.removeAttribute(t)}e.setAttribute(t,""+n)}var a}function ot(e,t,n){if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(t)}e.setAttribute(t,""+n)}}function st(e,t,n,r){if(null===r)e.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(n)}e.setAttributeNS(t,n,""+r)}}function lt(e){if(void 0===et)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);et=t&&t[1]||"",tt=-1<e.stack.indexOf("\n at")?" (<anonymous>)":-1<e.stack.indexOf("@")?"@unknown:0:0":""}return"\n"+et+e+tt}var ct=!1;function ut(e,t){if(!e||ct)return"";ct=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&"function"==typeof n.catch&&n.catch(function(){})}}catch(e){if(e&&r&&"string"==typeof e.stack)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var a=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,"name");a&&a.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var i=r.DetermineComponentFrameRoot(),o=i[0],s=i[1];if(o&&s){var l=o.split("\n"),c=s.split("\n");for(a=r=0;r<l.length&&!l[r].includes("DetermineComponentFrameRoot");)r++;for(;a<c.length&&!c[a].includes("DetermineComponentFrameRoot");)a++;if(r===l.length||a===c.length)for(r=l.length-1,a=c.length-1;1<=r&&0<=a&&l[r]!==c[a];)a--;for(;1<=r&&0<=a;r--,a--)if(l[r]!==c[a]){if(1!==r||1!==a)do{if(r--,0>--a||l[r]!==c[a]){var u="\n"+l[r].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}}while(1<=r&&0<=a);break}}}finally{ct=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?lt(n):""}function dt(e){switch(e.tag){case 26:case 27:case 5:return lt(e.type);case 16:return lt("Lazy");case 13:return lt("Suspense");case 19:return lt("SuspenseList");case 0:case 15:return ut(e.type,!1);case 11:return ut(e.type.render,!1);case 1:return ut(e.type,!0);case 31:return lt("Activity");default:return""}}function mt(e){try{var t="";do{t+=dt(e),e=e.return}while(e);return t}catch(e){return"\nError generating stack: "+e.message+"\n"+e.stack}}function ht(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function pt(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function ft(e){e._valueTracker||(e._valueTracker=function(e){var t=pt(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&void 0!==n&&"function"==typeof n.get&&"function"==typeof n.set){var a=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(e){r=""+e,i.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e))}function gt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=pt(e)?e.checked?"true":"false":e.value),(e=r)!==n&&(t.setValue(e),!0)}function bt(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}var yt=/[\n"\\]/g;function vt(e){return e.replace(yt,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function xt(e,t,n,r,a,i,o,s){e.name="",null!=o&&"function"!=typeof o&&"symbol"!=typeof o&&"boolean"!=typeof o?e.type=o:e.removeAttribute("type"),null!=t?"number"===o?(0===t&&""===e.value||e.value!=t)&&(e.value=""+ht(t)):e.value!==""+ht(t)&&(e.value=""+ht(t)):"submit"!==o&&"reset"!==o||e.removeAttribute("value"),null!=t?kt(e,o,ht(t)):null!=n?kt(e,o,ht(n)):null!=r&&e.removeAttribute("value"),null==a&&null!=i&&(e.defaultChecked=!!i),null!=a&&(e.checked=a&&"function"!=typeof a&&"symbol"!=typeof a),null!=s&&"function"!=typeof s&&"symbol"!=typeof s&&"boolean"!=typeof s?e.name=""+ht(s):e.removeAttribute("name")}function wt(e,t,n,r,a,i,o,s){if(null!=i&&"function"!=typeof i&&"symbol"!=typeof i&&"boolean"!=typeof i&&(e.type=i),null!=t||null!=n){if(("submit"===i||"reset"===i)&&null==t)return;n=null!=n?""+ht(n):"",t=null!=t?""+ht(t):n,s||t===e.value||(e.value=t),e.defaultValue=t}r="function"!=typeof(r=null!=r?r:a)&&"symbol"!=typeof r&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,null!=o&&"function"!=typeof o&&"symbol"!=typeof o&&"boolean"!=typeof o&&(e.name=o)}function kt(e,t,n){"number"===t&&bt(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function Ct(e,t,n,r){if(e=e.options,t){t={};for(var a=0;a<n.length;a++)t["$"+n[a]]=!0;for(n=0;n<e.length;n++)a=t.hasOwnProperty("$"+e[n].value),e[n].selected!==a&&(e[n].selected=a),a&&r&&(e[n].defaultSelected=!0)}else{for(n=""+ht(n),t=null,a=0;a<e.length;a++){if(e[a].value===n)return e[a].selected=!0,void(r&&(e[a].defaultSelected=!0));null!==t||e[a].disabled||(t=e[a])}null!==t&&(t.selected=!0)}}function St(e,t,n){null==t||((t=""+ht(t))!==e.value&&(e.value=t),null!=n)?e.defaultValue=null!=n?""+ht(n):"":e.defaultValue!==t&&(e.defaultValue=t)}function Nt(e,t,n,a){if(null==t){if(null!=a){if(null!=n)throw Error(r(92));if(O(a)){if(1<a.length)throw Error(r(93));a=a[0]}n=a}null==n&&(n=""),t=n}n=ht(t),e.defaultValue=n,(a=e.textContent)===n&&""!==a&&null!==a&&(e.value=a)}function jt(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 Et=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function $t(e,t,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||Et.has(t)?"float"===t?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function _t(e,t,n){if(null!=t&&"object"!=typeof t)throw Error(r(62));if(e=e.style,null!=n){for(var a in n)!n.hasOwnProperty(a)||null!=t&&t.hasOwnProperty(a)||(0===a.indexOf("--")?e.setProperty(a,""):"float"===a?e.cssFloat="":e[a]="");for(var i in t)a=t[i],t.hasOwnProperty(i)&&n[i]!==a&&$t(e,i,a)}else for(var o in t)t.hasOwnProperty(o)&&$t(e,o,t[o])}function zt(e){if(-1===e.indexOf("-"))return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Tt=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Pt=/^[\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 At(e){return Pt.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}var Mt=null;function It(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var Lt=null,Ot=null;function Rt(e){var t=Ve(e);if(t&&(e=t.stateNode)){var n=e[Oe]||null;e:switch(e=t.stateNode,t.type){case"input":if(xt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,"radio"===n.type&&null!=t){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+vt(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var a=n[t];if(a!==e&&a.form===e.form){var i=a[Oe]||null;if(!i)throw Error(r(90));xt(a,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name)}}for(t=0;t<n.length;t++)(a=n[t]).form===e.form&>(a)}break e;case"textarea":St(e,n.value,n.defaultValue);break e;case"select":null!=(t=n.value)&&Ct(e,!!n.multiple,t,!1)}}}var Dt=!1;function Ft(e,t,n){if(Dt)return e(t,n);Dt=!0;try{return e(t)}finally{if(Dt=!1,(null!==Lt||null!==Ot)&&(Wc(),Lt&&(t=Lt,e=Ot,Ot=Lt=null,Rt(t),e)))for(t=0;t<e.length;t++)Rt(e[t])}}function Ut(e,t){var n=e.stateNode;if(null===n)return null;var a=n[Oe]||null;if(null===a)return null;n=a[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(a=!a.disabled)||(a=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!a;break e;default:e=!1}if(e)return null;if(n&&"function"!=typeof n)throw Error(r(231,t,typeof n));return n}var qt=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),Bt=!1;if(qt)try{var Ht={};Object.defineProperty(Ht,"passive",{get:function(){Bt=!0}}),window.addEventListener("test",Ht,Ht),window.removeEventListener("test",Ht,Ht)}catch(e){Bt=!1}var Wt=null,Vt=null,Kt=null;function Gt(){if(Kt)return Kt;var e,t,n=Vt,r=n.length,a="value"in Wt?Wt.value:Wt.textContent,i=a.length;for(e=0;e<r&&n[e]===a[e];e++);var o=r-e;for(t=1;t<=o&&n[r-t]===a[i-t];t++);return Kt=a.slice(e,1<t?1-t:void 0)}function Qt(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function Yt(){return!0}function Xt(){return!1}function Jt(e){function t(t,n,r,a,i){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=a,this.target=i,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(a):a[o]);return this.isDefaultPrevented=(null!=a.defaultPrevented?a.defaultPrevented:!1===a.returnValue)?Yt:Xt,this.isPropagationStopped=Xt,this}return u(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=Yt)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=Yt)},persist:function(){},isPersistent:Yt}),t}var Zt,en,tn,nn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},rn=Jt(nn),an=u({},nn,{view:0,detail:0}),on=Jt(an),sn=u({},an,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:yn,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==tn&&(tn&&"mousemove"===e.type?(Zt=e.screenX-tn.screenX,en=e.screenY-tn.screenY):en=Zt=0,tn=e),Zt)},movementY:function(e){return"movementY"in e?e.movementY:en}}),ln=Jt(sn),cn=Jt(u({},sn,{dataTransfer:0})),un=Jt(u({},an,{relatedTarget:0})),dn=Jt(u({},nn,{animationName:0,elapsedTime:0,pseudoElement:0})),mn=Jt(u({},nn,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}})),hn=Jt(u({},nn,{data:0})),pn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},fn={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},gn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function bn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=gn[e])&&!!t[e]}function yn(){return bn}var vn=Jt(u({},an,{key:function(e){if(e.key){var t=pn[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=Qt(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?fn[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:yn,charCode:function(e){return"keypress"===e.type?Qt(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?Qt(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}})),xn=Jt(u({},sn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),wn=Jt(u({},an,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:yn})),kn=Jt(u({},nn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Cn=Jt(u({},sn,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Sn=Jt(u({},nn,{newState:0,oldState:0})),Nn=[9,13,27,32],jn=qt&&"CompositionEvent"in window,En=null;qt&&"documentMode"in document&&(En=document.documentMode);var $n=qt&&"TextEvent"in window&&!En,_n=qt&&(!jn||En&&8<En&&11>=En),zn=String.fromCharCode(32),Tn=!1;function Pn(e,t){switch(e){case"keyup":return-1!==Nn.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function An(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Mn=!1,In={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Ln(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!In[e.type]:"textarea"===t}function On(e,t,n,r){Lt?Ot?Ot.push(r):Ot=[r]:Lt=r,0<(t=Gu(t,"onChange")).length&&(n=new rn("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Rn=null,Dn=null;function Fn(e){Fu(e,0)}function Un(e){if(gt(Ke(e)))return e}function qn(e,t){if("change"===e)return t}var Bn=!1;if(qt){var Hn;if(qt){var Wn="oninput"in document;if(!Wn){var Vn=document.createElement("div");Vn.setAttribute("oninput","return;"),Wn="function"==typeof Vn.oninput}Hn=Wn}else Hn=!1;Bn=Hn&&(!document.documentMode||9<document.documentMode)}function Kn(){Rn&&(Rn.detachEvent("onpropertychange",Gn),Dn=Rn=null)}function Gn(e){if("value"===e.propertyName&&Un(Dn)){var t=[];On(t,Dn,e,It(e)),Ft(Fn,t)}}function Qn(e,t,n){"focusin"===e?(Kn(),Dn=n,(Rn=t).attachEvent("onpropertychange",Gn)):"focusout"===e&&Kn()}function Yn(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Un(Dn)}function Xn(e,t){if("click"===e)return Un(t)}function Jn(e,t){if("input"===e||"change"===e)return Un(t)}var Zn="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t};function er(e,t){if(Zn(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var a=n[r];if(!ee.call(t,a)||!Zn(e[a],t[a]))return!1}return!0}function tr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function nr(e,t){var n,r=tr(e);for(e=0;r;){if(3===r.nodeType){if(n=e+r.textContent.length,e<=t&&n>=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=tr(r)}}function rr(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?rr(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function ar(e){for(var t=bt((e=null!=e&&null!=e.ownerDocument&&null!=e.ownerDocument.defaultView?e.ownerDocument.defaultView:window).document);t instanceof e.HTMLIFrameElement;){try{var n="string"==typeof t.contentWindow.location.href}catch(e){n=!1}if(!n)break;t=bt((e=t.contentWindow).document)}return t}function ir(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}var or=qt&&"documentMode"in document&&11>=document.documentMode,sr=null,lr=null,cr=null,ur=!1;function dr(e,t,n){var r=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;ur||null==sr||sr!==bt(r)||(r="selectionStart"in(r=sr)&&ir(r)?{start:r.selectionStart,end:r.selectionEnd}:{anchorNode:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset},cr&&er(cr,r)||(cr=r,0<(r=Gu(lr,"onSelect")).length&&(t=new rn("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=sr)))}function mr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var hr={animationend:mr("Animation","AnimationEnd"),animationiteration:mr("Animation","AnimationIteration"),animationstart:mr("Animation","AnimationStart"),transitionrun:mr("Transition","TransitionRun"),transitionstart:mr("Transition","TransitionStart"),transitioncancel:mr("Transition","TransitionCancel"),transitionend:mr("Transition","TransitionEnd")},pr={},fr={};function gr(e){if(pr[e])return pr[e];if(!hr[e])return e;var t,n=hr[e];for(t in n)if(n.hasOwnProperty(t)&&t in fr)return pr[e]=n[t];return e}qt&&(fr=document.createElement("div").style,"AnimationEvent"in window||(delete hr.animationend.animation,delete hr.animationiteration.animation,delete hr.animationstart.animation),"TransitionEvent"in window||delete hr.transitionend.transition);var br=gr("animationend"),yr=gr("animationiteration"),vr=gr("animationstart"),xr=gr("transitionrun"),wr=gr("transitionstart"),kr=gr("transitioncancel"),Cr=gr("transitionend"),Sr=new Map,Nr="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 jr(e,t){Sr.set(e,t),Je(t,[e])}Nr.push("scrollEnd");var Er=new WeakMap;function $r(e,t){if("object"==typeof e&&null!==e){var n=Er.get(e);return void 0!==n?n:(t={value:e,source:t,stack:mt(t)},Er.set(e,t),t)}return{value:e,source:t,stack:mt(t)}}var _r=[],zr=0,Tr=0;function Pr(){for(var e=zr,t=Tr=zr=0;t<e;){var n=_r[t];_r[t++]=null;var r=_r[t];_r[t++]=null;var a=_r[t];_r[t++]=null;var i=_r[t];if(_r[t++]=null,null!==r&&null!==a){var o=r.pending;null===o?a.next=a:(a.next=o.next,o.next=a),r.pending=a}0!==i&&Lr(n,a,i)}}function Ar(e,t,n,r){_r[zr++]=e,_r[zr++]=t,_r[zr++]=n,_r[zr++]=r,Tr|=r,e.lanes|=r,null!==(e=e.alternate)&&(e.lanes|=r)}function Mr(e,t,n,r){return Ar(e,t,n,r),Or(e)}function Ir(e,t){return Ar(e,null,null,t),Or(e)}function Lr(e,t,n){e.lanes|=n;var r=e.alternate;null!==r&&(r.lanes|=n);for(var a=!1,i=e.return;null!==i;)i.childLanes|=n,null!==(r=i.alternate)&&(r.childLanes|=n),22===i.tag&&(null===(e=i.stateNode)||1&e._visibility||(a=!0)),e=i,i=i.return;return 3===e.tag?(i=e.stateNode,a&&null!==t&&(a=31-be(n),null===(r=(e=i.hiddenUpdates)[a])?e[a]=[t]:r.push(t),t.lane=536870912|n),i):null}function Or(e){if(50<Lc)throw Lc=0,Oc=null,Error(r(185));for(var t=e.return;null!==t;)t=(e=t).return;return 3===e.tag?e.stateNode:null}var Rr={};function Dr(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Fr(e,t,n,r){return new Dr(e,t,n,r)}function Ur(e){return!(!(e=e.prototype)||!e.isReactComponent)}function qr(e,t){var n=e.alternate;return null===n?((n=Fr(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=65011712&e.flags,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Br(e,t){e.flags&=65011714;var n=e.alternate;return null===n?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Hr(e,t,n,a,i,o){var s=0;if(a=e,"function"==typeof e)Ur(e)&&(s=1);else if("string"==typeof e)s=function(e,t,n){if(1===n||null!=t.itemProp)return!1;switch(e){case"meta":case"title":return!0;case"style":if("string"!=typeof t.precedence||"string"!=typeof t.href||""===t.href)break;return!0;case"link":if("string"!=typeof t.rel||"string"!=typeof t.href||""===t.href||t.onLoad||t.onError)break;return"stylesheet"!==t.rel||(e=t.disabled,"string"==typeof t.precedence&&null==e);case"script":if(t.async&&"function"!=typeof t.async&&"symbol"!=typeof t.async&&!t.onLoad&&!t.onError&&t.src&&"string"==typeof t.src)return!0}return!1}(e,n,V.current)?26:"html"===e||"head"===e||"body"===e?27:5;else e:switch(e){case T:return(e=Fr(31,n,t,i)).elementType=T,e.lanes=o,e;case f:return Wr(n.children,i,o,t);case b:s=8,i|=24;break;case x:return(e=Fr(12,n,t,2|i)).elementType=x,e.lanes=o,e;case E:return(e=Fr(13,n,t,i)).elementType=E,e.lanes=o,e;case $:return(e=Fr(19,n,t,i)).elementType=$,e.lanes=o,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case k:case N:s=10;break e;case S:s=9;break e;case j:s=11;break e;case _:s=14;break e;case z:s=16,a=null;break e}s=29,n=Error(r(130,null===e?"null":typeof e,"")),a=null}return(t=Fr(s,n,t,i)).elementType=e,t.type=a,t.lanes=o,t}function Wr(e,t,n,r){return(e=Fr(7,e,r,t)).lanes=n,e}function Vr(e,t,n){return(e=Fr(6,e,null,t)).lanes=n,e}function Kr(e,t,n){return(t=Fr(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Gr=[],Qr=0,Yr=null,Xr=0,Jr=[],Zr=0,ea=null,ta=1,na="";function ra(e,t){Gr[Qr++]=Xr,Gr[Qr++]=Yr,Yr=e,Xr=t}function aa(e,t,n){Jr[Zr++]=ta,Jr[Zr++]=na,Jr[Zr++]=ea,ea=e;var r=ta;e=na;var a=32-be(r)-1;r&=~(1<<a),n+=1;var i=32-be(t)+a;if(30<i){var o=a-a%5;i=(r&(1<<o)-1).toString(32),r>>=o,a-=o,ta=1<<32-be(t)+a|n<<a|r,na=i+e}else ta=1<<i|n<<a|r,na=e}function ia(e){null!==e.return&&(ra(e,1),aa(e,1,0))}function oa(e){for(;e===Yr;)Yr=Gr[--Qr],Gr[Qr]=null,Xr=Gr[--Qr],Gr[Qr]=null;for(;e===ea;)ea=Jr[--Zr],Jr[Zr]=null,na=Jr[--Zr],Jr[Zr]=null,ta=Jr[--Zr],Jr[Zr]=null}var sa=null,la=null,ca=!1,ua=null,da=!1,ma=Error(r(519));function ha(e){throw va($r(Error(r(418,"")),e)),ma}function pa(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[Le]=e,t[Oe]=r,n){case"dialog":Uu("cancel",t),Uu("close",t);break;case"iframe":case"object":case"embed":Uu("load",t);break;case"video":case"audio":for(n=0;n<Ru.length;n++)Uu(Ru[n],t);break;case"source":Uu("error",t);break;case"img":case"image":case"link":Uu("error",t),Uu("load",t);break;case"details":Uu("toggle",t);break;case"input":Uu("invalid",t),wt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0),ft(t);break;case"select":Uu("invalid",t);break;case"textarea":Uu("invalid",t),Nt(t,r.value,r.defaultValue,r.children),ft(t)}"string"!=typeof(n=r.children)&&"number"!=typeof n&&"bigint"!=typeof n||t.textContent===""+n||!0===r.suppressHydrationWarning||ed(t.textContent,n)?(null!=r.popover&&(Uu("beforetoggle",t),Uu("toggle",t)),null!=r.onScroll&&Uu("scroll",t),null!=r.onScrollEnd&&Uu("scrollend",t),null!=r.onClick&&(t.onclick=td),t=!0):t=!1,t||ha(e)}function fa(e){for(sa=e.return;sa;)switch(sa.tag){case 5:case 13:return void(da=!1);case 27:case 3:return void(da=!0);default:sa=sa.return}}function ga(e){if(e!==sa)return!1;if(!ca)return fa(e),ca=!0,!1;var t,n=e.tag;if((t=3!==n&&27!==n)&&((t=5===n)&&(t=!("form"!==(t=e.type)&&"button"!==t)||ud(e.type,e.memoizedProps)),t=!t),t&&la&&ha(e),fa(e),13===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(r(317));e:{for(e=e.nextSibling,n=0;e;){if(8===e.nodeType)if("/$"===(t=e.data)){if(0===n){la=wd(e.nextSibling);break e}n--}else"$"!==t&&"$!"!==t&&"$?"!==t||n++;e=e.nextSibling}la=null}}else 27===n?(n=la,bd(e.type)?(e=kd,kd=null,la=e):la=n):la=sa?wd(e.stateNode.nextSibling):null;return!0}function ba(){la=sa=null,ca=!1}function ya(){var e=ua;return null!==e&&(null===Cc?Cc=e:Cc.push.apply(Cc,e),ua=null),e}function va(e){null===ua?ua=[e]:ua.push(e)}var xa=B(null),wa=null,ka=null;function Ca(e,t,n){W(xa,t._currentValue),t._currentValue=n}function Sa(e){e._currentValue=xa.current,H(xa)}function Na(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 ja(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),Na(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),Na(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 Ea(e,t,n,a){e=null;for(var i=t,o=!1;null!==i;){if(!o)if(524288&i.flags)o=!0;else if(262144&i.flags)break;if(10===i.tag){var s=i.alternate;if(null===s)throw Error(r(387));if(null!==(s=s.memoizedProps)){var l=i.type;Zn(i.pendingProps.value,s.value)||(null!==e?e.push(l):e=[l])}}else if(i===Q.current){if(null===(s=i.alternate))throw Error(r(387));s.memoizedState.memoizedState!==i.memoizedState.memoizedState&&(null!==e?e.push(Jd):e=[Jd])}i=i.return}null!==e&&ja(t,e,n,a),t.flags|=262144}function $a(e){for(e=e.firstContext;null!==e;){if(!Zn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function _a(e){wa=e,ka=null,null!==(e=e.dependencies)&&(e.firstContext=null)}function za(e){return Pa(wa,e)}function Ta(e,t){return null===wa&&_a(e),Pa(e,t)}function Pa(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},null===ka){if(null===e)throw Error(r(308));ka=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else ka=ka.next=t;return n}var Aa="undefined"!=typeof AbortController?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Ma=e.unstable_scheduleCallback,Ia=e.unstable_NormalPriority,La={$$typeof:N,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Oa(){return{controller:new Aa,data:new Map,refCount:0}}function Ra(e){e.refCount--,0===e.refCount&&Ma(Ia,function(){e.controller.abort()})}var Da=null,Fa=0,Ua=0,qa=null;function Ba(){if(0===--Fa&&null!==Da){null!==qa&&(qa.status="fulfilled");var e=Da;Da=null,Ua=0,qa=null;for(var t=0;t<e.length;t++)(0,e[t])()}}var Ha=R.S;R.S=function(e,t){"object"==typeof t&&null!==t&&"function"==typeof t.then&&function(e,t){if(null===Da){var n=Da=[];Fa=0,Ua=Au(),qa={status:"pending",value:void 0,then:function(e){n.push(e)}}}Fa++,t.then(Ba,Ba)}(0,t),null!==Ha&&Ha(e,t)};var Wa=B(null);function Va(){var e=Wa.current;return null!==e?e:sc.pooledCache}function Ka(e,t){W(Wa,null===t?Wa.current:t.pool)}function Ga(){var e=Va();return null===e?null:{parent:La._currentValue,pool:e}}var Qa=Error(r(460)),Ya=Error(r(474)),Xa=Error(r(542)),Ja={then:function(){}};function Za(e){return"fulfilled"===(e=e.status)||"rejected"===e}function ei(){}function ti(e,t,n){switch(void 0===(n=e[n])?e.push(t):n!==t&&(t.then(ei,ei),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw ai(e=t.reason),e;default:if("string"==typeof t.status)t.then(ei,ei);else{if(null!==(e=sc)&&100<e.shellSuspendCounter)throw Error(r(482));(e=t).status="pending",e.then(function(e){if("pending"===t.status){var n=t;n.status="fulfilled",n.value=e}},function(e){if("pending"===t.status){var n=t;n.status="rejected",n.reason=e}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw ai(e=t.reason),e}throw ni=t,Qa}}var ni=null;function ri(){if(null===ni)throw Error(r(459));var e=ni;return ni=null,e}function ai(e){if(e===Qa||e===Xa)throw Error(r(483))}var ii=!1;function oi(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function si(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function li(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ci(e,t,n){var r=e.updateQueue;if(null===r)return null;if(r=r.shared,2&oc){var a=r.pending;return null===a?t.next=t:(t.next=a.next,a.next=t),r.pending=t,t=Or(e),Lr(e,null,n),t}return Ar(e,r,t,n),Or(e)}function ui(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,4194048&n)){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,Te(e,n)}}function di(e,t){var n=e.updateQueue,r=e.alternate;if(null!==r&&n===(r=r.updateQueue)){var a=null,i=null;if(null!==(n=n.firstBaseUpdate)){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};null===i?a=i=o:i=i.next=o,n=n.next}while(null!==n);null===i?a=i=t:i=i.next=t}else a=i=t;return n={baseState:r.baseState,firstBaseUpdate:a,lastBaseUpdate:i,shared:r.shared,callbacks:r.callbacks},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var mi=!1;function hi(){if(mi&&null!==qa)throw qa}function pi(e,t,n,r){mi=!1;var a=e.updateQueue;ii=!1;var i=a.firstBaseUpdate,o=a.lastBaseUpdate,s=a.shared.pending;if(null!==s){a.shared.pending=null;var l=s,c=l.next;l.next=null,null===o?i=c:o.next=c,o=l;var d=e.alternate;null!==d&&(s=(d=d.updateQueue).lastBaseUpdate)!==o&&(null===s?d.firstBaseUpdate=c:s.next=c,d.lastBaseUpdate=l)}if(null!==i){var m=a.baseState;for(o=0,d=c=l=null,s=i;;){var h=-536870913&s.lane,p=h!==s.lane;if(p?(cc&h)===h:(r&h)===h){0!==h&&h===Ua&&(mi=!0),null!==d&&(d=d.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});e:{var f=e,g=s;h=t;var b=n;switch(g.tag){case 1:if("function"==typeof(f=g.payload)){m=f.call(b,m,h);break e}m=f;break e;case 3:f.flags=-65537&f.flags|128;case 0:if(null==(h="function"==typeof(f=g.payload)?f.call(b,m,h):f))break e;m=u({},m,h);break e;case 2:ii=!0}}null!==(h=s.callback)&&(e.flags|=64,p&&(e.flags|=8192),null===(p=a.callbacks)?a.callbacks=[h]:p.push(h))}else p={lane:h,tag:s.tag,payload:s.payload,callback:s.callback,next:null},null===d?(c=d=p,l=m):d=d.next=p,o|=h;if(null===(s=s.next)){if(null===(s=a.shared.pending))break;s=(p=s).next,p.next=null,a.lastBaseUpdate=p,a.shared.pending=null}}null===d&&(l=m),a.baseState=l,a.firstBaseUpdate=c,a.lastBaseUpdate=d,null===i&&(a.shared.lanes=0),bc|=o,e.lanes=o,e.memoizedState=m}}function fi(e,t){if("function"!=typeof e)throw Error(r(191,e));e.call(t)}function gi(e,t){var n=e.callbacks;if(null!==n)for(e.callbacks=null,e=0;e<n.length;e++)fi(n[e],t)}var bi=B(null),yi=B(0);function vi(e,t){W(yi,e=fc),W(bi,t),fc=e|t.baseLanes}function xi(){W(yi,fc),W(bi,bi.current)}function wi(){fc=yi.current,H(bi),H(yi)}var ki=0,Ci=null,Si=null,Ni=null,ji=!1,Ei=!1,$i=!1,_i=0,zi=0,Ti=null,Pi=0;function Ai(){throw Error(r(321))}function Mi(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Zn(e[n],t[n]))return!1;return!0}function Ii(e,t,n,r,a,i){return ki=i,Ci=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,R.H=null===e||null===e.memoizedState?Yo:Xo,$i=!1,i=n(r,a),$i=!1,Ei&&(i=Oi(t,n,r,a)),Li(e),i}function Li(e){R.H=Qo;var t=null!==Si&&null!==Si.next;if(ki=0,Ni=Si=Ci=null,ji=!1,zi=0,Ti=null,t)throw Error(r(300));null===e||Ts||null!==(e=e.dependencies)&&$a(e)&&(Ts=!0)}function Oi(e,t,n,a){Ci=e;var i=0;do{if(Ei&&(Ti=null),zi=0,Ei=!1,25<=i)throw Error(r(301));if(i+=1,Ni=Si=null,null!=e.updateQueue){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,null!=o.memoCache&&(o.memoCache.index=0)}R.H=Jo,o=t(n,a)}while(Ei);return o}function Ri(){var e=R.H,t=e.useState()[0];return t="function"==typeof t.then?Hi(t):t,e=e.useState()[0],(null!==Si?Si.memoizedState:null)!==e&&(Ci.flags|=1024),t}function Di(){var e=0!==_i;return _i=0,e}function Fi(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Ui(e){if(ji){for(e=e.memoizedState;null!==e;){var t=e.queue;null!==t&&(t.pending=null),e=e.next}ji=!1}ki=0,Ni=Si=Ci=null,Ei=!1,zi=_i=0,Ti=null}function qi(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===Ni?Ci.memoizedState=Ni=e:Ni=Ni.next=e,Ni}function Bi(){if(null===Si){var e=Ci.alternate;e=null!==e?e.memoizedState:null}else e=Si.next;var t=null===Ni?Ci.memoizedState:Ni.next;if(null!==t)Ni=t,Si=e;else{if(null===e){if(null===Ci.alternate)throw Error(r(467));throw Error(r(310))}e={memoizedState:(Si=e).memoizedState,baseState:Si.baseState,baseQueue:Si.baseQueue,queue:Si.queue,next:null},null===Ni?Ci.memoizedState=Ni=e:Ni=Ni.next=e}return Ni}function Hi(e){var t=zi;return zi+=1,null===Ti&&(Ti=[]),e=ti(Ti,e,t),t=Ci,null===(null===Ni?t.memoizedState:Ni.next)&&(t=t.alternate,R.H=null===t||null===t.memoizedState?Yo:Xo),e}function Wi(e){if(null!==e&&"object"==typeof e){if("function"==typeof e.then)return Hi(e);if(e.$$typeof===N)return za(e)}throw Error(r(438,String(e)))}function Vi(e){var t=null,n=Ci.updateQueue;if(null!==n&&(t=n.memoCache),null==t){var r=Ci.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},Ci.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]=P;return t.index++,n}function Ki(e,t){return"function"==typeof t?t(e):t}function Gi(e){return Qi(Bi(),Si,e)}function Qi(e,t,n){var a=e.queue;if(null===a)throw Error(r(311));a.lastRenderedReducer=n;var i=e.baseQueue,o=a.pending;if(null!==o){if(null!==i){var s=i.next;i.next=o.next,o.next=s}t.baseQueue=i=o,a.pending=null}if(o=e.baseState,null===i)e.memoizedState=o;else{var l=s=null,c=null,u=t=i.next,d=!1;do{var m=-536870913&u.lane;if(m!==u.lane?(cc&m)===m:(ki&m)===m){var h=u.revertLane;if(0===h)null!==c&&(c=c.next={lane:0,revertLane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),m===Ua&&(d=!0);else{if((ki&h)===h){u=u.next,h===Ua&&(d=!0);continue}m={lane:0,revertLane:u.revertLane,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(l=c=m,s=o):c=c.next=m,Ci.lanes|=h,bc|=h}m=u.action,$i&&n(o,m),o=u.hasEagerState?u.eagerState:n(o,m)}else h={lane:m,revertLane:u.revertLane,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},null===c?(l=c=h,s=o):c=c.next=h,Ci.lanes|=m,bc|=m;u=u.next}while(null!==u&&u!==t);if(null===c?s=o:c.next=l,!Zn(o,e.memoizedState)&&(Ts=!0,d&&null!==(n=qa)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=c,a.lastRenderedState=o}return null===i&&(a.lanes=0),[e.memoizedState,a.dispatch]}function Yi(e){var t=Bi(),n=t.queue;if(null===n)throw Error(r(311));n.lastRenderedReducer=e;var a=n.dispatch,i=n.pending,o=t.memoizedState;if(null!==i){n.pending=null;var s=i=i.next;do{o=e(o,s.action),s=s.next}while(s!==i);Zn(o,t.memoizedState)||(Ts=!0),t.memoizedState=o,null===t.baseQueue&&(t.baseState=o),n.lastRenderedState=o}return[o,a]}function Xi(e,t,n){var a=Ci,i=Bi(),o=ca;if(o){if(void 0===n)throw Error(r(407));n=n()}else n=t();var s=!Zn((Si||i).memoizedState,n);if(s&&(i.memoizedState=n,Ts=!0),i=i.queue,wo(2048,8,eo.bind(null,a,i,e),[e]),i.getSnapshot!==t||s||null!==Ni&&1&Ni.memoizedState.tag){if(a.flags|=2048,yo(9,{destroy:void 0,resource:void 0},Zi.bind(null,a,i,n,t),null),null===sc)throw Error(r(349));o||124&ki||Ji(a,t,n)}return n}function Ji(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=Ci.updateQueue)?(t={lastEffect:null,events:null,stores:null,memoCache:null},Ci.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function Zi(e,t,n,r){t.value=n,t.getSnapshot=r,to(t)&&no(e)}function eo(e,t,n){return n(function(){to(t)&&no(e)})}function to(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Zn(e,n)}catch(e){return!0}}function no(e){var t=Ir(e,2);null!==t&&Fc(t,e,2)}function ro(e){var t=qi();if("function"==typeof e){var n=e;if(e=n(),$i){ge(!0);try{n()}finally{ge(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ki,lastRenderedState:e},t}function ao(e,t,n,r){return e.baseState=n,Qi(e,Si,"function"==typeof r?r:Ki)}function io(e,t,n,a,i){if(Vo(e))throw Error(r(485));if(null!==(e=t.action)){var o={payload:i,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};null!==R.T?n(!0):o.isTransition=!1,a(o),null===(n=t.pending)?(o.next=t.pending=o,oo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function oo(e,t){var n=t.action,r=t.payload,a=e.state;if(t.isTransition){var i=R.T,o={};R.T=o;try{var s=n(a,r),l=R.S;null!==l&&l(o,s),so(e,t,s)}catch(n){co(e,t,n)}finally{R.T=i}}else try{so(e,t,i=n(a,r))}catch(n){co(e,t,n)}}function so(e,t,n){null!==n&&"object"==typeof n&&"function"==typeof n.then?n.then(function(n){lo(e,t,n)},function(n){return co(e,t,n)}):lo(e,t,n)}function lo(e,t,n){t.status="fulfilled",t.value=n,uo(t),e.state=n,null!==(t=e.pending)&&((n=t.next)===t?e.pending=null:(n=n.next,t.next=n,oo(e,n)))}function co(e,t,n){var r=e.pending;if(e.pending=null,null!==r){r=r.next;do{t.status="rejected",t.reason=n,uo(t),t=t.next}while(t!==r)}e.action=null}function uo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function mo(e,t){return t}function ho(e,t){if(ca){var n=sc.formState;if(null!==n){e:{var r=Ci;if(ca){if(la){t:{for(var a=la,i=da;8!==a.nodeType;){if(!i){a=null;break t}if(null===(a=wd(a.nextSibling))){a=null;break t}}a="F!"===(i=a.data)||"F"===i?a:null}if(a){la=wd(a.nextSibling),r="F!"===a.data;break e}}ha(r)}r=!1}r&&(t=n[0])}}return(n=qi()).memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:mo,lastRenderedState:t},n.queue=r,n=Bo.bind(null,Ci,r),r.dispatch=n,r=ro(!1),i=Wo.bind(null,Ci,!1,r.queue),a={state:t,dispatch:null,action:e,pending:null},(r=qi()).queue=a,n=io.bind(null,Ci,a,i,n),a.dispatch=n,r.memoizedState=e,[t,n,!1]}function po(e){return fo(Bi(),Si,e)}function fo(e,t,n){if(t=Qi(e,t,mo)[0],e=Gi(Ki)[0],"object"==typeof t&&null!==t&&"function"==typeof t.then)try{var r=Hi(t)}catch(e){if(e===Qa)throw Xa;throw e}else r=t;var a=(t=Bi()).queue,i=a.dispatch;return n!==t.memoizedState&&(Ci.flags|=2048,yo(9,{destroy:void 0,resource:void 0},go.bind(null,a,n),null)),[r,i,e]}function go(e,t){e.action=t}function bo(e){var t=Bi(),n=Si;if(null!==n)return fo(t,n,e);Bi(),t=t.memoizedState;var r=(n=Bi()).queue.dispatch;return n.memoizedState=e,[t,r,!1]}function yo(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},null===(t=Ci.updateQueue)&&(t={lastEffect:null,events:null,stores:null,memoCache:null},Ci.updateQueue=t),null===(n=t.lastEffect)?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function vo(){return Bi().memoizedState}function xo(e,t,n,r){var a=qi();r=void 0===r?null:r,Ci.flags|=e,a.memoizedState=yo(1|t,{destroy:void 0,resource:void 0},n,r)}function wo(e,t,n,r){var a=Bi();r=void 0===r?null:r;var i=a.memoizedState.inst;null!==Si&&null!==r&&Mi(r,Si.memoizedState.deps)?a.memoizedState=yo(t,i,n,r):(Ci.flags|=e,a.memoizedState=yo(1|t,i,n,r))}function ko(e,t){xo(8390656,8,e,t)}function Co(e,t){wo(2048,8,e,t)}function So(e,t){return wo(4,2,e,t)}function No(e,t){return wo(4,4,e,t)}function jo(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 Eo(e,t,n){n=null!=n?n.concat([e]):null,wo(4,4,jo.bind(null,t,e),n)}function $o(){}function _o(e,t){var n=Bi();t=void 0===t?null:t;var r=n.memoizedState;return null!==t&&Mi(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function zo(e,t){var n=Bi();t=void 0===t?null:t;var r=n.memoizedState;if(null!==t&&Mi(t,r[1]))return r[0];if(r=e(),$i){ge(!0);try{e()}finally{ge(!1)}}return n.memoizedState=[r,t],r}function To(e,t,n){return void 0===n||1073741824&ki?e.memoizedState=t:(e.memoizedState=n,e=Dc(),Ci.lanes|=e,bc|=e,n)}function Po(e,t,n,r){return Zn(n,t)?n:null!==bi.current?(e=To(e,n,r),Zn(e,t)||(Ts=!0),e):42&ki?(e=Dc(),Ci.lanes|=e,bc|=e,t):(Ts=!0,e.memoizedState=n)}function Ao(e,t,n,r,a){var i=D.p;D.p=0!==i&&8>i?i:8;var o,s,l,c=R.T,u={};R.T=u,Wo(e,!1,t,n);try{var d=a(),m=R.S;null!==m&&m(u,d),null!==d&&"object"==typeof d&&"function"==typeof d.then?Ho(e,t,(o=r,s=[],l={status:"pending",value:null,reason:null,then:function(e){s.push(e)}},d.then(function(){l.status="fulfilled",l.value=o;for(var e=0;e<s.length;e++)(0,s[e])(o)},function(e){for(l.status="rejected",l.reason=e,e=0;e<s.length;e++)(0,s[e])(void 0)}),l),Rc()):Ho(e,t,r,Rc())}catch(n){Ho(e,t,{then:function(){},status:"rejected",reason:n},Rc())}finally{D.p=i,R.T=c}}function Mo(){}function Io(e,t,n,a){if(5!==e.tag)throw Error(r(476));var i=Lo(e).queue;Ao(e,i,t,F,null===n?Mo:function(){return Oo(e),n(a)})}function Lo(e){var t=e.memoizedState;if(null!==t)return t;var n={};return(t={memoizedState:F,baseState:F,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ki,lastRenderedState:F},next:null}).next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ki,lastRenderedState:n},next:null},e.memoizedState=t,null!==(e=e.alternate)&&(e.memoizedState=t),t}function Oo(e){Ho(e,Lo(e).next.queue,{},Rc())}function Ro(){return za(Jd)}function Do(){return Bi().memoizedState}function Fo(){return Bi().memoizedState}function Uo(e){for(var t=e.return;null!==t;){switch(t.tag){case 24:case 3:var n=Rc(),r=ci(t,e=li(n),n);return null!==r&&(Fc(r,t,n),ui(r,t,n)),t={cache:Oa()},void(e.payload=t)}t=t.return}}function qo(e,t,n){var r=Rc();n={lane:r,revertLane:0,action:n,hasEagerState:!1,eagerState:null,next:null},Vo(e)?Ko(t,n):null!==(n=Mr(e,t,n,r))&&(Fc(n,e,r),Go(n,t,r))}function Bo(e,t,n){Ho(e,t,n,Rc())}function Ho(e,t,n,r){var a={lane:r,revertLane:0,action:n,hasEagerState:!1,eagerState:null,next:null};if(Vo(e))Ko(t,a);else{var i=e.alternate;if(0===e.lanes&&(null===i||0===i.lanes)&&null!==(i=t.lastRenderedReducer))try{var o=t.lastRenderedState,s=i(o,n);if(a.hasEagerState=!0,a.eagerState=s,Zn(s,o))return Ar(e,t,a,0),null===sc&&Pr(),!1}catch(e){}if(null!==(n=Mr(e,t,a,r)))return Fc(n,e,r),Go(n,t,r),!0}return!1}function Wo(e,t,n,a){if(a={lane:2,revertLane:Au(),action:a,hasEagerState:!1,eagerState:null,next:null},Vo(e)){if(t)throw Error(r(479))}else null!==(t=Mr(e,n,a,2))&&Fc(t,e,2)}function Vo(e){var t=e.alternate;return e===Ci||null!==t&&t===Ci}function Ko(e,t){Ei=ji=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Go(e,t,n){if(4194048&n){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,Te(e,n)}}var Qo={readContext:za,use:Wi,useCallback:Ai,useContext:Ai,useEffect:Ai,useImperativeHandle:Ai,useLayoutEffect:Ai,useInsertionEffect:Ai,useMemo:Ai,useReducer:Ai,useRef:Ai,useState:Ai,useDebugValue:Ai,useDeferredValue:Ai,useTransition:Ai,useSyncExternalStore:Ai,useId:Ai,useHostTransitionStatus:Ai,useFormState:Ai,useActionState:Ai,useOptimistic:Ai,useMemoCache:Ai,useCacheRefresh:Ai},Yo={readContext:za,use:Wi,useCallback:function(e,t){return qi().memoizedState=[e,void 0===t?null:t],e},useContext:za,useEffect:ko,useImperativeHandle:function(e,t,n){n=null!=n?n.concat([e]):null,xo(4194308,4,jo.bind(null,t,e),n)},useLayoutEffect:function(e,t){return xo(4194308,4,e,t)},useInsertionEffect:function(e,t){xo(4,2,e,t)},useMemo:function(e,t){var n=qi();t=void 0===t?null:t;var r=e();if($i){ge(!0);try{e()}finally{ge(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=qi();if(void 0!==n){var a=n(t);if($i){ge(!0);try{n(t)}finally{ge(!1)}}}else a=t;return r.memoizedState=r.baseState=a,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:a},r.queue=e,e=e.dispatch=qo.bind(null,Ci,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},qi().memoizedState=e},useState:function(e){var t=(e=ro(e)).queue,n=Bo.bind(null,Ci,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:$o,useDeferredValue:function(e,t){return To(qi(),e,t)},useTransition:function(){var e=ro(!1);return e=Ao.bind(null,Ci,e.queue,!0,!1),qi().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var a=Ci,i=qi();if(ca){if(void 0===n)throw Error(r(407));n=n()}else{if(n=t(),null===sc)throw Error(r(349));124&cc||Ji(a,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,ko(eo.bind(null,a,o,e),[e]),a.flags|=2048,yo(9,{destroy:void 0,resource:void 0},Zi.bind(null,a,o,n,t),null),n},useId:function(){var e=qi(),t=sc.identifierPrefix;if(ca){var n=na;t="«"+t+"R"+(n=(ta&~(1<<32-be(ta)-1)).toString(32)+n),0<(n=_i++)&&(t+="H"+n.toString(32)),t+="»"}else t="«"+t+"r"+(n=Pi++).toString(32)+"»";return e.memoizedState=t},useHostTransitionStatus:Ro,useFormState:ho,useActionState:ho,useOptimistic:function(e){var t=qi();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Wo.bind(null,Ci,!0,n),n.dispatch=t,[e,t]},useMemoCache:Vi,useCacheRefresh:function(){return qi().memoizedState=Uo.bind(null,Ci)}},Xo={readContext:za,use:Wi,useCallback:_o,useContext:za,useEffect:Co,useImperativeHandle:Eo,useInsertionEffect:So,useLayoutEffect:No,useMemo:zo,useReducer:Gi,useRef:vo,useState:function(){return Gi(Ki)},useDebugValue:$o,useDeferredValue:function(e,t){return Po(Bi(),Si.memoizedState,e,t)},useTransition:function(){var e=Gi(Ki)[0],t=Bi().memoizedState;return["boolean"==typeof e?e:Hi(e),t]},useSyncExternalStore:Xi,useId:Do,useHostTransitionStatus:Ro,useFormState:po,useActionState:po,useOptimistic:function(e,t){return ao(Bi(),0,e,t)},useMemoCache:Vi,useCacheRefresh:Fo},Jo={readContext:za,use:Wi,useCallback:_o,useContext:za,useEffect:Co,useImperativeHandle:Eo,useInsertionEffect:So,useLayoutEffect:No,useMemo:zo,useReducer:Yi,useRef:vo,useState:function(){return Yi(Ki)},useDebugValue:$o,useDeferredValue:function(e,t){var n=Bi();return null===Si?To(n,e,t):Po(n,Si.memoizedState,e,t)},useTransition:function(){var e=Yi(Ki)[0],t=Bi().memoizedState;return["boolean"==typeof e?e:Hi(e),t]},useSyncExternalStore:Xi,useId:Do,useHostTransitionStatus:Ro,useFormState:bo,useActionState:bo,useOptimistic:function(e,t){var n=Bi();return null!==Si?ao(n,0,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:Vi,useCacheRefresh:Fo},Zo=null,es=0;function ts(e){var t=es;return es+=1,null===Zo&&(Zo=[]),ti(Zo,e,t)}function ns(e,t){t=t.props.ref,e.ref=void 0!==t?t:null}function rs(e,t){if(t.$$typeof===d)throw Error(r(525));throw e=Object.prototype.toString.call(t),Error(r(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function as(e){return(0,e._init)(e._payload)}function is(e){function t(t,n){if(e){var r=t.deletions;null===r?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;null!==r;)t(n,r),r=r.sibling;return null}function a(e){for(var t=new Map;null!==e;)null!==e.key?t.set(e.key,e):t.set(e.index,e),e=e.sibling;return t}function i(e,t){return(e=qr(e,t)).index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?null!==(r=t.alternate)?(r=r.index)<n?(t.flags|=67108866,n):r:(t.flags|=67108866,n):(t.flags|=1048576,n)}function s(t){return e&&null===t.alternate&&(t.flags|=67108866),t}function l(e,t,n,r){return null===t||6!==t.tag?((t=Vr(n,e.mode,r)).return=e,t):((t=i(t,n)).return=e,t)}function c(e,t,n,r){var a=n.type;return a===f?d(e,t,n.props.children,r,n.key):null!==t&&(t.elementType===a||"object"==typeof a&&null!==a&&a.$$typeof===z&&as(a)===t.type)?(ns(t=i(t,n.props),n),t.return=e,t):(ns(t=Hr(n.type,n.key,n.props,null,e.mode,r),n),t.return=e,t)}function u(e,t,n,r){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=Kr(n,e.mode,r)).return=e,t):((t=i(t,n.children||[])).return=e,t)}function d(e,t,n,r,a){return null===t||7!==t.tag?((t=Wr(n,e.mode,r,a)).return=e,t):((t=i(t,n)).return=e,t)}function h(e,t,n){if("string"==typeof t&&""!==t||"number"==typeof t||"bigint"==typeof t)return(t=Vr(""+t,e.mode,n)).return=e,t;if("object"==typeof t&&null!==t){switch(t.$$typeof){case m:return ns(n=Hr(t.type,t.key,t.props,null,e.mode,n),t),n.return=e,n;case p:return(t=Kr(t,e.mode,n)).return=e,t;case z:return h(e,t=(0,t._init)(t._payload),n)}if(O(t)||M(t))return(t=Wr(t,e.mode,n,null)).return=e,t;if("function"==typeof t.then)return h(e,ts(t),n);if(t.$$typeof===N)return h(e,Ta(e,t),n);rs(e,t)}return null}function g(e,t,n,r){var a=null!==t?t.key:null;if("string"==typeof n&&""!==n||"number"==typeof n||"bigint"==typeof n)return null!==a?null:l(e,t,""+n,r);if("object"==typeof n&&null!==n){switch(n.$$typeof){case m:return n.key===a?c(e,t,n,r):null;case p:return n.key===a?u(e,t,n,r):null;case z:return g(e,t,n=(a=n._init)(n._payload),r)}if(O(n)||M(n))return null!==a?null:d(e,t,n,r,null);if("function"==typeof n.then)return g(e,t,ts(n),r);if(n.$$typeof===N)return g(e,t,Ta(e,n),r);rs(e,n)}return null}function b(e,t,n,r,a){if("string"==typeof r&&""!==r||"number"==typeof r||"bigint"==typeof r)return l(t,e=e.get(n)||null,""+r,a);if("object"==typeof r&&null!==r){switch(r.$$typeof){case m:return c(t,e=e.get(null===r.key?n:r.key)||null,r,a);case p:return u(t,e=e.get(null===r.key?n:r.key)||null,r,a);case z:return b(e,t,n,r=(0,r._init)(r._payload),a)}if(O(r)||M(r))return d(t,e=e.get(n)||null,r,a,null);if("function"==typeof r.then)return b(e,t,n,ts(r),a);if(r.$$typeof===N)return b(e,t,n,Ta(t,r),a);rs(t,r)}return null}function y(l,c,u,d){if("object"==typeof u&&null!==u&&u.type===f&&null===u.key&&(u=u.props.children),"object"==typeof u&&null!==u){switch(u.$$typeof){case m:e:{for(var v=u.key;null!==c;){if(c.key===v){if((v=u.type)===f){if(7===c.tag){n(l,c.sibling),(d=i(c,u.props.children)).return=l,l=d;break e}}else if(c.elementType===v||"object"==typeof v&&null!==v&&v.$$typeof===z&&as(v)===c.type){n(l,c.sibling),ns(d=i(c,u.props),u),d.return=l,l=d;break e}n(l,c);break}t(l,c),c=c.sibling}u.type===f?((d=Wr(u.props.children,l.mode,d,u.key)).return=l,l=d):(ns(d=Hr(u.type,u.key,u.props,null,l.mode,d),u),d.return=l,l=d)}return s(l);case 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=Kr(u,l.mode,d)).return=l,l=d}return s(l);case z:return y(l,c,u=(v=u._init)(u._payload),d)}if(O(u))return function(r,i,s,l){for(var c=null,u=null,d=i,m=i=0,p=null;null!==d&&m<s.length;m++){d.index>m?(p=d,d=null):p=d.sibling;var f=g(r,d,s[m],l);if(null===f){null===d&&(d=p);break}e&&d&&null===f.alternate&&t(r,d),i=o(f,i,m),null===u?c=f:u.sibling=f,u=f,d=p}if(m===s.length)return n(r,d),ca&&ra(r,m),c;if(null===d){for(;m<s.length;m++)null!==(d=h(r,s[m],l))&&(i=o(d,i,m),null===u?c=d:u.sibling=d,u=d);return ca&&ra(r,m),c}for(d=a(d);m<s.length;m++)null!==(p=b(d,r,m,s[m],l))&&(e&&null!==p.alternate&&d.delete(null===p.key?m:p.key),i=o(p,i,m),null===u?c=p:u.sibling=p,u=p);return e&&d.forEach(function(e){return t(r,e)}),ca&&ra(r,m),c}(l,c,u,d);if(M(u)){if("function"!=typeof(v=M(u)))throw Error(r(150));return function(i,s,l,c){if(null==l)throw Error(r(151));for(var u=null,d=null,m=s,p=s=0,f=null,y=l.next();null!==m&&!y.done;p++,y=l.next()){m.index>p?(f=m,m=null):f=m.sibling;var v=g(i,m,y.value,c);if(null===v){null===m&&(m=f);break}e&&m&&null===v.alternate&&t(i,m),s=o(v,s,p),null===d?u=v:d.sibling=v,d=v,m=f}if(y.done)return n(i,m),ca&&ra(i,p),u;if(null===m){for(;!y.done;p++,y=l.next())null!==(y=h(i,y.value,c))&&(s=o(y,s,p),null===d?u=y:d.sibling=y,d=y);return ca&&ra(i,p),u}for(m=a(m);!y.done;p++,y=l.next())null!==(y=b(m,i,p,y.value,c))&&(e&&null!==y.alternate&&m.delete(null===y.key?p:y.key),s=o(y,s,p),null===d?u=y:d.sibling=y,d=y);return e&&m.forEach(function(e){return t(i,e)}),ca&&ra(i,p),u}(l,c,u=v.call(u),d)}if("function"==typeof u.then)return y(l,c,ts(u),d);if(u.$$typeof===N)return y(l,c,Ta(l,u),d);rs(l,u)}return"string"==typeof u&&""!==u||"number"==typeof u||"bigint"==typeof u?(u=""+u,null!==c&&6===c.tag?(n(l,c.sibling),(d=i(c,u)).return=l,l=d):(n(l,c),(d=Vr(u,l.mode,d)).return=l,l=d),s(l)):n(l,c)}return function(e,t,n,r){try{es=0;var a=y(e,t,n,r);return Zo=null,a}catch(t){if(t===Qa||t===Xa)throw t;var i=Fr(29,t,null,e.mode);return i.lanes=r,i.return=e,i}}}var os=is(!0),ss=is(!1),ls=B(null),cs=null;function us(e){var t=e.alternate;W(ps,1&ps.current),W(ls,e),null===cs&&(null===t||null!==bi.current||null!==t.memoizedState)&&(cs=e)}function ds(e){if(22===e.tag){if(W(ps,ps.current),W(ls,e),null===cs){var t=e.alternate;null!==t&&null!==t.memoizedState&&(cs=e)}}else ms()}function ms(){W(ps,ps.current),W(ls,ls.current)}function hs(e){H(ls),cs===e&&(cs=null),H(ps)}var ps=B(0);function fs(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||"$?"===n.data||xd(n)))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(128&t.flags)return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}function gs(e,t,n,r){n=null==(n=n(r,t=e.memoizedState))?t:u({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}var bs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Rc(),a=li(r);a.payload=t,null!=n&&(a.callback=n),null!==(t=ci(e,a,r))&&(Fc(t,e,r),ui(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Rc(),a=li(r);a.tag=1,a.payload=t,null!=n&&(a.callback=n),null!==(t=ci(e,a,r))&&(Fc(t,e,r),ui(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Rc(),r=li(n);r.tag=2,null!=t&&(r.callback=t),null!==(t=ci(e,r,n))&&(Fc(t,e,n),ui(t,e,n))}};function ys(e,t,n,r,a,i,o){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,i,o):!(t.prototype&&t.prototype.isPureReactComponent&&er(n,r)&&er(a,i))}function vs(e,t,n,r){e=t.state,"function"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,r),"function"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&bs.enqueueReplaceState(t,t.state,null)}function xs(e,t){var n=t;if("ref"in t)for(var r in n={},t)"ref"!==r&&(n[r]=t[r]);if(e=e.defaultProps)for(var a in n===t&&(n=u({},n)),e)void 0===n[a]&&(n[a]=e[a]);return n}var ws="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)};function ks(e){ws(e)}function Cs(e){console.error(e)}function Ss(e){ws(e)}function Ns(e,t){try{(0,e.onUncaughtError)(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function js(e,t,n){try{(0,e.onCaughtError)(n.value,{componentStack:n.stack,errorBoundary:1===t.tag?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Es(e,t,n){return(n=li(n)).tag=3,n.payload={element:null},n.callback=function(){Ns(e,t)},n}function $s(e){return(e=li(e)).tag=3,e}function _s(e,t,n,r){var a=n.type.getDerivedStateFromError;if("function"==typeof a){var i=r.value;e.payload=function(){return a(i)},e.callback=function(){js(t,n,r)}}var o=n.stateNode;null!==o&&"function"==typeof o.componentDidCatch&&(e.callback=function(){js(t,n,r),"function"!=typeof a&&(null===$c?$c=new Set([this]):$c.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:null!==e?e:""})})}var zs=Error(r(461)),Ts=!1;function Ps(e,t,n,r){t.child=null===e?ss(t,null,n,r):os(t,e.child,n,r)}function As(e,t,n,r,a){n=n.render;var i=t.ref;if("ref"in r){var o={};for(var s in r)"ref"!==s&&(o[s]=r[s])}else o=r;return _a(t),r=Ii(e,t,n,o,i,a),s=Di(),null===e||Ts?(ca&&s&&ia(t),t.flags|=1,Ps(e,t,r,a),t.child):(Fi(e,t,a),Zs(e,t,a))}function Ms(e,t,n,r,a){if(null===e){var i=n.type;return"function"!=typeof i||Ur(i)||void 0!==i.defaultProps||null!==n.compare?((e=Hr(n.type,null,r,t,t.mode,a)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=i,Is(e,t,i,r,a))}if(i=e.child,!el(e,a)){var o=i.memoizedProps;if((n=null!==(n=n.compare)?n:er)(o,r)&&e.ref===t.ref)return Zs(e,t,a)}return t.flags|=1,(e=qr(i,r)).ref=t.ref,e.return=t,t.child=e}function Is(e,t,n,r,a){if(null!==e){var i=e.memoizedProps;if(er(i,r)&&e.ref===t.ref){if(Ts=!1,t.pendingProps=r=i,!el(e,a))return t.lanes=e.lanes,Zs(e,t,a);131072&e.flags&&(Ts=!0)}}return Ds(e,t,n,r,a)}function Ls(e,t,n){var r=t.pendingProps,a=r.children,i=null!==e?e.memoizedState:null;if("hidden"===r.mode){if(128&t.flags){if(r=null!==i?i.baseLanes|n:n,null!==e){for(a=t.child=e.child,i=0;null!==a;)i=i|a.lanes|a.childLanes,a=a.sibling;t.childLanes=i&~r}else t.childLanes=0,t.child=null;return Os(e,t,r,n)}if(!(536870912&n))return t.lanes=t.childLanes=536870912,Os(e,t,null!==i?i.baseLanes|n:n,n);t.memoizedState={baseLanes:0,cachePool:null},null!==e&&Ka(0,null!==i?i.cachePool:null),null!==i?vi(t,i):xi(),ds(t)}else null!==i?(Ka(0,i.cachePool),vi(t,i),ms(),t.memoizedState=null):(null!==e&&Ka(0,null),xi(),ms());return Ps(e,t,a,n),t.child}function Os(e,t,n,r){var a=Va();return a=null===a?null:{parent:La._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},null!==e&&Ka(0,null),xi(),ds(t),null!==e&&Ea(e,t,r,!0),null}function Rs(e,t){var n=t.ref;if(null===n)null!==e&&null!==e.ref&&(t.flags|=4194816);else{if("function"!=typeof n&&"object"!=typeof n)throw Error(r(284));null!==e&&e.ref===n||(t.flags|=4194816)}}function Ds(e,t,n,r,a){return _a(t),n=Ii(e,t,n,r,void 0,a),r=Di(),null===e||Ts?(ca&&r&&ia(t),t.flags|=1,Ps(e,t,n,a),t.child):(Fi(e,t,a),Zs(e,t,a))}function Fs(e,t,n,r,a,i){return _a(t),t.updateQueue=null,n=Oi(t,r,n,a),Li(e),r=Di(),null===e||Ts?(ca&&r&&ia(t),t.flags|=1,Ps(e,t,n,i),t.child):(Fi(e,t,i),Zs(e,t,i))}function Us(e,t,n,r,a){if(_a(t),null===t.stateNode){var i=Rr,o=n.contextType;"object"==typeof o&&null!==o&&(i=za(o)),i=new n(r,i),t.memoizedState=null!==i.state&&void 0!==i.state?i.state:null,i.updater=bs,t.stateNode=i,i._reactInternals=t,(i=t.stateNode).props=r,i.state=t.memoizedState,i.refs={},oi(t),o=n.contextType,i.context="object"==typeof o&&null!==o?za(o):Rr,i.state=t.memoizedState,"function"==typeof(o=n.getDerivedStateFromProps)&&(gs(t,n,o,r),i.state=t.memoizedState),"function"==typeof n.getDerivedStateFromProps||"function"==typeof i.getSnapshotBeforeUpdate||"function"!=typeof i.UNSAFE_componentWillMount&&"function"!=typeof i.componentWillMount||(o=i.state,"function"==typeof i.componentWillMount&&i.componentWillMount(),"function"==typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount(),o!==i.state&&bs.enqueueReplaceState(i,i.state,null),pi(t,r,i,a),hi(),i.state=t.memoizedState),"function"==typeof i.componentDidMount&&(t.flags|=4194308),r=!0}else if(null===e){i=t.stateNode;var s=t.memoizedProps,l=xs(n,s);i.props=l;var c=i.context,u=n.contextType;o=Rr,"object"==typeof u&&null!==u&&(o=za(u));var d=n.getDerivedStateFromProps;u="function"==typeof d||"function"==typeof i.getSnapshotBeforeUpdate,s=t.pendingProps!==s,u||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(s||c!==o)&&vs(t,i,r,o),ii=!1;var m=t.memoizedState;i.state=m,pi(t,r,i,a),hi(),c=t.memoizedState,s||m!==c||ii?("function"==typeof d&&(gs(t,n,d,r),c=t.memoizedState),(l=ii||ys(t,n,l,r,m,c,o))?(u||"function"!=typeof i.UNSAFE_componentWillMount&&"function"!=typeof i.componentWillMount||("function"==typeof i.componentWillMount&&i.componentWillMount(),"function"==typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount()),"function"==typeof i.componentDidMount&&(t.flags|=4194308)):("function"==typeof i.componentDidMount&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),i.props=r,i.state=c,i.context=o,r=l):("function"==typeof i.componentDidMount&&(t.flags|=4194308),r=!1)}else{i=t.stateNode,si(e,t),u=xs(n,o=t.memoizedProps),i.props=u,d=t.pendingProps,m=i.context,c=n.contextType,l=Rr,"object"==typeof c&&null!==c&&(l=za(c)),(c="function"==typeof(s=n.getDerivedStateFromProps)||"function"==typeof i.getSnapshotBeforeUpdate)||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(o!==d||m!==l)&&vs(t,i,r,l),ii=!1,m=t.memoizedState,i.state=m,pi(t,r,i,a),hi();var h=t.memoizedState;o!==d||m!==h||ii||null!==e&&null!==e.dependencies&&$a(e.dependencies)?("function"==typeof s&&(gs(t,n,s,r),h=t.memoizedState),(u=ii||ys(t,n,u,r,m,h,l)||null!==e&&null!==e.dependencies&&$a(e.dependencies))?(c||"function"!=typeof i.UNSAFE_componentWillUpdate&&"function"!=typeof i.componentWillUpdate||("function"==typeof i.componentWillUpdate&&i.componentWillUpdate(r,h,l),"function"==typeof i.UNSAFE_componentWillUpdate&&i.UNSAFE_componentWillUpdate(r,h,l)),"function"==typeof i.componentDidUpdate&&(t.flags|=4),"function"==typeof i.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!=typeof i.componentDidUpdate||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),"function"!=typeof i.getSnapshotBeforeUpdate||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=h),i.props=r,i.state=h,i.context=l,r=u):("function"!=typeof i.componentDidUpdate||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),"function"!=typeof i.getSnapshotBeforeUpdate||o===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),r=!1)}return i=r,Rs(e,t),r=!!(128&t.flags),i||r?(i=t.stateNode,n=r&&"function"!=typeof n.getDerivedStateFromError?null:i.render(),t.flags|=1,null!==e&&r?(t.child=os(t,e.child,null,a),t.child=os(t,null,n,a)):Ps(e,t,n,a),t.memoizedState=i.state,e=t.child):e=Zs(e,t,a),e}function qs(e,t,n,r){return ba(),t.flags|=256,Ps(e,t,n,r),t.child}var Bs={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Hs(e){return{baseLanes:e,cachePool:Ga()}}function Ws(e,t,n){return e=null!==e?e.childLanes&~n:0,t&&(e|=xc),e}function Vs(e,t,n){var a,i=t.pendingProps,o=!1,s=!!(128&t.flags);if((a=s)||(a=(null===e||null!==e.memoizedState)&&!!(2&ps.current)),a&&(o=!0,t.flags&=-129),a=!!(32&t.flags),t.flags&=-33,null===e){if(ca){if(o?us(t):ms(),ca){var l,c=la;if(l=c){e:{for(l=c,c=da;8!==l.nodeType;){if(!c){c=null;break e}if(null===(l=wd(l.nextSibling))){c=null;break e}}c=l}null!==c?(t.memoizedState={dehydrated:c,treeContext:null!==ea?{id:ta,overflow:na}:null,retryLane:536870912,hydrationErrors:null},(l=Fr(18,null,null,0)).stateNode=c,l.return=t,t.child=l,sa=t,la=null,l=!0):l=!1}l||ha(t)}if(null!==(c=t.memoizedState)&&null!==(c=c.dehydrated))return xd(c)?t.lanes=32:t.lanes=536870912,null;hs(t)}return c=i.children,i=i.fallback,o?(ms(),c=Gs({mode:"hidden",children:c},o=t.mode),i=Wr(i,o,n,null),c.return=t,i.return=t,c.sibling=i,t.child=c,(o=t.child).memoizedState=Hs(n),o.childLanes=Ws(e,a,n),t.memoizedState=Bs,i):(us(t),Ks(t,c))}if(null!==(l=e.memoizedState)&&null!==(c=l.dehydrated)){if(s)256&t.flags?(us(t),t.flags&=-257,t=Qs(e,t,n)):null!==t.memoizedState?(ms(),t.child=e.child,t.flags|=128,t=null):(ms(),o=i.fallback,c=t.mode,i=Gs({mode:"visible",children:i.children},c),(o=Wr(o,c,n,null)).flags|=2,i.return=t,o.return=t,i.sibling=o,t.child=i,os(t,e.child,null,n),(i=t.child).memoizedState=Hs(n),i.childLanes=Ws(e,a,n),t.memoizedState=Bs,t=o);else if(us(t),xd(c)){if(a=c.nextSibling&&c.nextSibling.dataset)var u=a.dgst;a=u,(i=Error(r(419))).stack="",i.digest=a,va({value:i,source:null,stack:null}),t=Qs(e,t,n)}else if(Ts||Ea(e,t,n,!1),a=0!==(n&e.childLanes),Ts||a){if(null!==(a=sc)&&0!==(i=0!==((i=42&(i=n&-n)?1:Pe(i))&(a.suspendedLanes|n))?0:i)&&i!==l.retryLane)throw l.retryLane=i,Ir(e,i),Fc(a,e,i),zs;"$?"===c.data||Xc(),t=Qs(e,t,n)}else"$?"===c.data?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,la=wd(c.nextSibling),sa=t,ca=!0,ua=null,da=!1,null!==e&&(Jr[Zr++]=ta,Jr[Zr++]=na,Jr[Zr++]=ea,ta=e.id,na=e.overflow,ea=t),(t=Ks(t,i.children)).flags|=4096);return t}return o?(ms(),o=i.fallback,c=t.mode,u=(l=e.child).sibling,(i=qr(l,{mode:"hidden",children:i.children})).subtreeFlags=65011712&l.subtreeFlags,null!==u?o=qr(u,o):(o=Wr(o,c,n,null)).flags|=2,o.return=t,i.return=t,i.sibling=o,t.child=i,i=o,o=t.child,null===(c=e.child.memoizedState)?c=Hs(n):(null!==(l=c.cachePool)?(u=La._currentValue,l=l.parent!==u?{parent:u,pool:u}:l):l=Ga(),c={baseLanes:c.baseLanes|n,cachePool:l}),o.memoizedState=c,o.childLanes=Ws(e,a,n),t.memoizedState=Bs,i):(us(t),e=(n=e.child).sibling,(n=qr(n,{mode:"visible",children:i.children})).return=t,n.sibling=null,null!==e&&(null===(a=t.deletions)?(t.deletions=[e],t.flags|=16):a.push(e)),t.child=n,t.memoizedState=null,n)}function Ks(e,t){return(t=Gs({mode:"visible",children:t},e.mode)).return=e,e.child=t}function Gs(e,t){return(e=Fr(22,e,null,t)).lanes=0,e.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null},e}function Qs(e,t,n){return os(t,e.child,null,n),(e=Ks(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function Ys(e,t,n){e.lanes|=t;var r=e.alternate;null!==r&&(r.lanes|=t),Na(e.return,t,n)}function Xs(e,t,n,r,a){var i=e.memoizedState;null===i?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:a}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=a)}function Js(e,t,n){var r=t.pendingProps,a=r.revealOrder,i=r.tail;if(Ps(e,t,r.children,n),2&(r=ps.current))r=1&r|2,t.flags|=128;else{if(null!==e&&128&e.flags)e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&Ys(e,n,t);else if(19===e.tag)Ys(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}switch(W(ps,r),a){case"forwards":for(n=t.child,a=null;null!==n;)null!==(e=n.alternate)&&null===fs(e)&&(a=n),n=n.sibling;null===(n=a)?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),Xs(t,!1,a,n,i);break;case"backwards":for(n=null,a=t.child,t.child=null;null!==a;){if(null!==(e=a.alternate)&&null===fs(e)){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}Xs(t,!0,n,null,i);break;case"together":Xs(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Zs(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),bc|=t.lanes,0===(n&t.childLanes)){if(null===e)return null;if(Ea(e,t,n,!1),0===(n&t.childLanes))return null}if(null!==e&&t.child!==e.child)throw Error(r(153));if(null!==t.child){for(n=qr(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=qr(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function el(e,t){return 0!==(e.lanes&t)||!(null===(e=e.dependencies)||!$a(e))}function tl(e,t,n){if(null!==e)if(e.memoizedProps!==t.pendingProps)Ts=!0;else{if(!(el(e,n)||128&t.flags))return Ts=!1,function(e,t,n){switch(t.tag){case 3:Y(t,t.stateNode.containerInfo),Ca(0,La,e.memoizedState.cache),ba();break;case 27:case 5:J(t);break;case 4:Y(t,t.stateNode.containerInfo);break;case 10:Ca(0,t.type,t.memoizedProps.value);break;case 13:var r=t.memoizedState;if(null!==r)return null!==r.dehydrated?(us(t),t.flags|=128,null):0!==(n&t.child.childLanes)?Vs(e,t,n):(us(t),null!==(e=Zs(e,t,n))?e.sibling:null);us(t);break;case 19:var a=!!(128&e.flags);if((r=0!==(n&t.childLanes))||(Ea(e,t,n,!1),r=0!==(n&t.childLanes)),a){if(r)return Js(e,t,n);t.flags|=128}if(null!==(a=t.memoizedState)&&(a.rendering=null,a.tail=null,a.lastEffect=null),W(ps,ps.current),r)break;return null;case 22:case 23:return t.lanes=0,Ls(e,t,n);case 24:Ca(0,La,e.memoizedState.cache)}return Zs(e,t,n)}(e,t,n);Ts=!!(131072&e.flags)}else Ts=!1,ca&&1048576&t.flags&&aa(t,Xr,t.index);switch(t.lanes=0,t.tag){case 16:e:{e=t.pendingProps;var a=t.elementType,i=a._init;if(a=i(a._payload),t.type=a,"function"!=typeof a){if(null!=a){if((i=a.$$typeof)===j){t.tag=11,t=As(null,t,a,e,n);break e}if(i===_){t.tag=14,t=Ms(null,t,a,e,n);break e}}throw t=L(a)||a,Error(r(306,t,""))}Ur(a)?(e=xs(a,e),t.tag=1,t=Us(null,t,a,e,n)):(t.tag=0,t=Ds(null,t,a,e,n))}return t;case 0:return Ds(e,t,t.type,t.pendingProps,n);case 1:return Us(e,t,a=t.type,i=xs(a,t.pendingProps),n);case 3:e:{if(Y(t,t.stateNode.containerInfo),null===e)throw Error(r(387));a=t.pendingProps;var o=t.memoizedState;i=o.element,si(e,t),pi(t,a,null,n);var s=t.memoizedState;if(a=s.cache,Ca(0,La,a),a!==o.cache&&ja(t,[La],n,!0),hi(),a=s.element,o.isDehydrated){if(o={element:a,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,256&t.flags){t=qs(e,t,a,n);break e}if(a!==i){va(i=$r(Error(r(424)),t)),t=qs(e,t,a,n);break e}for(e=9===(e=t.stateNode.containerInfo).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,la=wd(e.firstChild),sa=t,ca=!0,ua=null,da=!0,n=ss(t,null,a,n),t.child=n;n;)n.flags=-3&n.flags|4096,n=n.sibling}else{if(ba(),a===i){t=Zs(e,t,n);break e}Ps(e,t,a,n)}t=t.child}return t;case 26:return Rs(e,t),null===e?(n=Pd(t.type,null,t.pendingProps,null))?t.memoizedState=n:ca||(n=t.type,e=t.pendingProps,(a=sd(G.current).createElement(n))[Le]=t,a[Oe]=e,ad(a,n,e),Qe(a),t.stateNode=a):t.memoizedState=Pd(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return J(t),null===e&&ca&&(a=t.stateNode=Sd(t.type,t.pendingProps,G.current),sa=t,da=!0,i=la,bd(t.type)?(kd=i,la=wd(a.firstChild)):la=i),Ps(e,t,t.pendingProps.children,n),Rs(e,t),null===e&&(t.flags|=4194304),t.child;case 5:return null===e&&ca&&((i=a=la)&&(null!==(a=function(e,t,n,r){for(;1===e.nodeType;){var a=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&("INPUT"!==e.nodeName||"hidden"!==e.type))break}else if(r){if(!e[Be])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if("stylesheet"===(i=e.getAttribute("rel"))&&e.hasAttribute("data-precedence"))break;if(i!==a.rel||e.getAttribute("href")!==(null==a.href||""===a.href?null:a.href)||e.getAttribute("crossorigin")!==(null==a.crossOrigin?null:a.crossOrigin)||e.getAttribute("title")!==(null==a.title?null:a.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(((i=e.getAttribute("src"))!==(null==a.src?null:a.src)||e.getAttribute("type")!==(null==a.type?null:a.type)||e.getAttribute("crossorigin")!==(null==a.crossOrigin?null:a.crossOrigin))&&i&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else{if("input"!==t||"hidden"!==e.type)return e;var i=null==a.name?null:""+a.name;if("hidden"===a.type&&e.getAttribute("name")===i)return e}if(null===(e=wd(e.nextSibling)))break}return null}(a,t.type,t.pendingProps,da))?(t.stateNode=a,sa=t,la=wd(a.firstChild),da=!1,i=!0):i=!1),i||ha(t)),J(t),i=t.type,o=t.pendingProps,s=null!==e?e.memoizedProps:null,a=o.children,ud(i,o)?a=null:null!==s&&ud(i,s)&&(t.flags|=32),null!==t.memoizedState&&(i=Ii(e,t,Ri,null,null,n),Jd._currentValue=i),Rs(e,t),Ps(e,t,a,n),t.child;case 6:return null===e&&ca&&((e=n=la)&&(null!==(n=function(e,t,n){if(""===t)return null;for(;3!==e.nodeType;){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!n)return null;if(null===(e=wd(e.nextSibling)))return null}return e}(n,t.pendingProps,da))?(t.stateNode=n,sa=t,la=null,e=!0):e=!1),e||ha(t)),null;case 13:return Vs(e,t,n);case 4:return Y(t,t.stateNode.containerInfo),a=t.pendingProps,null===e?t.child=os(t,null,a,n):Ps(e,t,a,n),t.child;case 11:return As(e,t,t.type,t.pendingProps,n);case 7:return Ps(e,t,t.pendingProps,n),t.child;case 8:case 12:return Ps(e,t,t.pendingProps.children,n),t.child;case 10:return a=t.pendingProps,Ca(0,t.type,a.value),Ps(e,t,a.children,n),t.child;case 9:return i=t.type._context,a=t.pendingProps.children,_a(t),a=a(i=za(i)),t.flags|=1,Ps(e,t,a,n),t.child;case 14:return Ms(e,t,t.type,t.pendingProps,n);case 15:return Is(e,t,t.type,t.pendingProps,n);case 19:return Js(e,t,n);case 31:return a=t.pendingProps,n=t.mode,a={mode:a.mode,children:a.children},null===e?((n=Gs(a,n)).ref=t.ref,t.child=n,n.return=t,t=n):((n=qr(e.child,a)).ref=t.ref,t.child=n,n.return=t,t=n),t;case 22:return Ls(e,t,n);case 24:return _a(t),a=za(La),null===e?(null===(i=Va())&&(i=sc,o=Oa(),i.pooledCache=o,o.refCount++,null!==o&&(i.pooledCacheLanes|=n),i=o),t.memoizedState={parent:a,cache:i},oi(t),Ca(0,La,i)):(0!==(e.lanes&n)&&(si(e,t),pi(t,null,null,n),hi()),i=e.memoizedState,o=t.memoizedState,i.parent!==a?(i={parent:a,cache:a},t.memoizedState=i,0===t.lanes&&(t.memoizedState=t.updateQueue.baseState=i),Ca(0,La,a)):(a=o.cache,Ca(0,La,a),a!==i.cache&&ja(t,[La],n,!0))),Ps(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function nl(e){e.flags|=4}function rl(e,t){if("stylesheet"!==t.type||4&t.state.loading)e.flags&=-16777217;else if(e.flags|=16777216,!Wd(t)){if(null!==(t=ls.current)&&((4194048&cc)===cc?null!==cs:(62914560&cc)!==cc&&!(536870912&cc)||t!==cs))throw ni=Ja,Ya;e.flags|=8192}}function al(e,t){null!==t&&(e.flags|=4),16384&e.flags&&(t=22!==e.tag?Ee():536870912,e.lanes|=t,wc|=t)}function il(e,t){if(!ca)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;null!==n;)null!==n.alternate&&(r=n),n=n.sibling;null===r?t||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function ol(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,r=0;if(t)for(var a=e.child;null!==a;)n|=a.lanes|a.childLanes,r|=65011712&a.subtreeFlags,r|=65011712&a.flags,a.return=e,a=a.sibling;else for(a=e.child;null!==a;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags,r|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function sl(e,t,n){var a=t.pendingProps;switch(oa(t),t.tag){case 31:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 1:return ol(t),null;case 3:return n=t.stateNode,a=null,null!==e&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Sa(La),X(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),null!==e&&null!==e.child||(ga(t)?nl(t):null===e||e.memoizedState.isDehydrated&&!(256&t.flags)||(t.flags|=1024,ya())),ol(t),null;case 26:return n=t.memoizedState,null===e?(nl(t),null!==n?(ol(t),rl(t,n)):(ol(t),t.flags&=-16777217)):n?n!==e.memoizedState?(nl(t),ol(t),rl(t,n)):(ol(t),t.flags&=-16777217):(e.memoizedProps!==a&&nl(t),ol(t),t.flags&=-16777217),null;case 27:Z(t),n=G.current;var i=t.type;if(null!==e&&null!=t.stateNode)e.memoizedProps!==a&&nl(t);else{if(!a){if(null===t.stateNode)throw Error(r(166));return ol(t),null}e=V.current,ga(t)?pa(t):(e=Sd(i,a,n),t.stateNode=e,nl(t))}return ol(t),null;case 5:if(Z(t),n=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==a&&nl(t);else{if(!a){if(null===t.stateNode)throw Error(r(166));return ol(t),null}if(e=V.current,ga(t))pa(t);else{switch(i=sd(G.current),e){case 1:e=i.createElementNS("http://www.w3.org/2000/svg",n);break;case 2:e=i.createElementNS("http://www.w3.org/1998/Math/MathML",n);break;default:switch(n){case"svg":e=i.createElementNS("http://www.w3.org/2000/svg",n);break;case"math":e=i.createElementNS("http://www.w3.org/1998/Math/MathML",n);break;case"script":(e=i.createElement("div")).innerHTML="<script><\/script>",e=e.removeChild(e.firstChild);break;case"select":e="string"==typeof a.is?i.createElement("select",{is:a.is}):i.createElement("select"),a.multiple?e.multiple=!0:a.size&&(e.size=a.size);break;default:e="string"==typeof a.is?i.createElement(n,{is:a.is}):i.createElement(n)}}e[Le]=t,e[Oe]=a;e:for(i=t.child;null!==i;){if(5===i.tag||6===i.tag)e.appendChild(i.stateNode);else if(4!==i.tag&&27!==i.tag&&null!==i.child){i.child.return=i,i=i.child;continue}if(i===t)break e;for(;null===i.sibling;){if(null===i.return||i.return===t)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}t.stateNode=e;e:switch(ad(e,n,a),n){case"button":case"input":case"select":case"textarea":e=!!a.autoFocus;break e;case"img":e=!0;break e;default:e=!1}e&&nl(t)}}return ol(t),t.flags&=-16777217,null;case 6:if(e&&null!=t.stateNode)e.memoizedProps!==a&&nl(t);else{if("string"!=typeof a&&null===t.stateNode)throw Error(r(166));if(e=G.current,ga(t)){if(e=t.stateNode,n=t.memoizedProps,a=null,null!==(i=sa))switch(i.tag){case 27:case 5:a=i.memoizedProps}e[Le]=t,(e=!!(e.nodeValue===n||null!==a&&!0===a.suppressHydrationWarning||ed(e.nodeValue,n)))||ha(t)}else(e=sd(e).createTextNode(a))[Le]=t,t.stateNode=e}return ol(t),null;case 13:if(a=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(i=ga(t),null!==a&&null!==a.dehydrated){if(null===e){if(!i)throw Error(r(318));if(!(i=null!==(i=t.memoizedState)?i.dehydrated:null))throw Error(r(317));i[Le]=t}else ba(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;ol(t),i=!1}else i=ya(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return 256&t.flags?(hs(t),t):(hs(t),null)}if(hs(t),128&t.flags)return t.lanes=n,t;if(n=null!==a,e=null!==e&&null!==e.memoizedState,n){i=null,null!==(a=t.child).alternate&&null!==a.alternate.memoizedState&&null!==a.alternate.memoizedState.cachePool&&(i=a.alternate.memoizedState.cachePool.pool);var o=null;null!==a.memoizedState&&null!==a.memoizedState.cachePool&&(o=a.memoizedState.cachePool.pool),o!==i&&(a.flags|=2048)}return n!==e&&n&&(t.child.flags|=8192),al(t,t.updateQueue),ol(t),null;case 4:return X(),null===e&&Hu(t.stateNode.containerInfo),ol(t),null;case 10:return Sa(t.type),ol(t),null;case 19:if(H(ps),null===(i=t.memoizedState))return ol(t),null;if(a=!!(128&t.flags),null===(o=i.rendering))if(a)il(i,!1);else{if(0!==gc||null!==e&&128&e.flags)for(e=t.child;null!==e;){if(null!==(o=fs(e))){for(t.flags|=128,il(i,!1),e=o.updateQueue,t.updateQueue=e,al(t,e),t.subtreeFlags=0,e=n,n=t.child;null!==n;)Br(n,e),n=n.sibling;return W(ps,1&ps.current|2),t.child}e=e.sibling}null!==i.tail&&ie()>jc&&(t.flags|=128,a=!0,il(i,!1),t.lanes=4194304)}else{if(!a)if(null!==(e=fs(o))){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,al(t,e),il(i,!0),null===i.tail&&"hidden"===i.tailMode&&!o.alternate&&!ca)return ol(t),null}else 2*ie()-i.renderingStartTime>jc&&536870912!==n&&(t.flags|=128,a=!0,il(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(null!==(e=i.last)?e.sibling=o:t.child=o,i.last=o)}return null!==i.tail?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=ie(),t.sibling=null,e=ps.current,W(ps,a?1&e|2:1&e),t):(ol(t),null);case 22:case 23:return hs(t),wi(),a=null!==t.memoizedState,null!==e?null!==e.memoizedState!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?!!(536870912&n)&&!(128&t.flags)&&(ol(t),6&t.subtreeFlags&&(t.flags|=8192)):ol(t),null!==(n=t.updateQueue)&&al(t,n.retryQueue),n=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),a=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(a=t.memoizedState.cachePool.pool),a!==n&&(t.flags|=2048),null!==e&&H(Wa),null;case 24:return n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Sa(La),ol(t),null;case 25:case 30:return null}throw Error(r(156,t.tag))}function ll(e,t){switch(oa(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return Sa(La),X(),65536&(e=t.flags)&&!(128&e)?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return Z(t),null;case 13:if(hs(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(r(340));ba()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return H(ps),null;case 4:return X(),null;case 10:return Sa(t.type),null;case 22:case 23:return hs(t),wi(),null!==e&&H(Wa),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return Sa(La),null;default:return null}}function cl(e,t){switch(oa(t),t.tag){case 3:Sa(La),X();break;case 26:case 27:case 5:Z(t);break;case 4:X();break;case 13:hs(t);break;case 19:H(ps);break;case 10:Sa(t.type);break;case 22:case 23:hs(t),wi(),null!==e&&H(Wa);break;case 24:Sa(La)}}function ul(e,t){try{var n=t.updateQueue,r=null!==n?n.lastEffect:null;if(null!==r){var a=r.next;n=a;do{if((n.tag&e)===e){r=void 0;var i=n.create,o=n.inst;r=i(),o.destroy=r}n=n.next}while(n!==a)}}catch(e){pu(t,t.return,e)}}function dl(e,t,n){try{var r=t.updateQueue,a=null!==r?r.lastEffect:null;if(null!==a){var i=a.next;r=i;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(void 0!==s){o.destroy=void 0,a=t;var l=n,c=s;try{c()}catch(e){pu(a,l,e)}}}r=r.next}while(r!==i)}}catch(e){pu(t,t.return,e)}}function ml(e){var t=e.updateQueue;if(null!==t){var n=e.stateNode;try{gi(t,n)}catch(t){pu(e,e.return,t)}}}function hl(e,t,n){n.props=xs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){pu(e,t,n)}}function pl(e,t){try{var n=e.ref;if(null!==n){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;default:r=e.stateNode}"function"==typeof n?e.refCleanup=n(r):n.current=r}}catch(n){pu(e,t,n)}}function fl(e,t){var n=e.ref,r=e.refCleanup;if(null!==n)if("function"==typeof r)try{r()}catch(n){pu(e,t,n)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof n)try{n(null)}catch(n){pu(e,t,n)}else n.current=null}function gl(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&r.focus();break e;case"img":n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){pu(e,e.return,t)}}function bl(e,t,n){try{var a=e.stateNode;!function(e,t,n,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var i=null,o=null,s=null,l=null,c=null,u=null,d=null;for(p in n){var m=n[p];if(n.hasOwnProperty(p)&&null!=m)switch(p){case"checked":case"value":break;case"defaultValue":c=m;default:a.hasOwnProperty(p)||nd(e,t,p,null,a,m)}}for(var h in a){var p=a[h];if(m=n[h],a.hasOwnProperty(h)&&(null!=p||null!=m))switch(h){case"type":o=p;break;case"name":i=p;break;case"checked":u=p;break;case"defaultChecked":d=p;break;case"value":s=p;break;case"defaultValue":l=p;break;case"children":case"dangerouslySetInnerHTML":if(null!=p)throw Error(r(137,t));break;default:p!==m&&nd(e,t,h,p,a,m)}}return void xt(e,s,l,c,u,d,o,i);case"select":for(o in p=s=l=h=null,n)if(c=n[o],n.hasOwnProperty(o)&&null!=c)switch(o){case"value":break;case"multiple":p=c;default:a.hasOwnProperty(o)||nd(e,t,o,null,a,c)}for(i in a)if(o=a[i],c=n[i],a.hasOwnProperty(i)&&(null!=o||null!=c))switch(i){case"value":h=o;break;case"defaultValue":l=o;break;case"multiple":s=o;default:o!==c&&nd(e,t,i,o,a,c)}return t=l,n=s,a=p,void(null!=h?Ct(e,!!n,h,!1):!!a!=!!n&&(null!=t?Ct(e,!!n,t,!0):Ct(e,!!n,n?[]:"",!1)));case"textarea":for(l in p=h=null,n)if(i=n[l],n.hasOwnProperty(l)&&null!=i&&!a.hasOwnProperty(l))switch(l){case"value":case"children":break;default:nd(e,t,l,null,a,i)}for(s in a)if(i=a[s],o=n[s],a.hasOwnProperty(s)&&(null!=i||null!=o))switch(s){case"value":h=i;break;case"defaultValue":p=i;break;case"children":break;case"dangerouslySetInnerHTML":if(null!=i)throw Error(r(91));break;default:i!==o&&nd(e,t,s,i,a,o)}return void St(e,h,p);case"option":for(var f in n)h=n[f],n.hasOwnProperty(f)&&null!=h&&!a.hasOwnProperty(f)&&("selected"===f?e.selected=!1:nd(e,t,f,null,a,h));for(c in a)h=a[c],p=n[c],!a.hasOwnProperty(c)||h===p||null==h&&null==p||("selected"===c?e.selected=h&&"function"!=typeof h&&"symbol"!=typeof h:nd(e,t,c,h,a,p));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var g in n)h=n[g],n.hasOwnProperty(g)&&null!=h&&!a.hasOwnProperty(g)&&nd(e,t,g,null,a,h);for(u in a)if(h=a[u],p=n[u],a.hasOwnProperty(u)&&h!==p&&(null!=h||null!=p))switch(u){case"children":case"dangerouslySetInnerHTML":if(null!=h)throw Error(r(137,t));break;default:nd(e,t,u,h,a,p)}return;default:if(zt(t)){for(var b in n)h=n[b],n.hasOwnProperty(b)&&void 0!==h&&!a.hasOwnProperty(b)&&rd(e,t,b,void 0,a,h);for(d in a)h=a[d],p=n[d],!a.hasOwnProperty(d)||h===p||void 0===h&&void 0===p||rd(e,t,d,h,a,p);return}}for(var y in n)h=n[y],n.hasOwnProperty(y)&&null!=h&&!a.hasOwnProperty(y)&&nd(e,t,y,null,a,h);for(m in a)h=a[m],p=n[m],!a.hasOwnProperty(m)||h===p||null==h&&null==p||nd(e,t,m,h,a,p)}(a,e.type,n,t),a[Oe]=t}catch(t){pu(e,e.return,t)}}function yl(e){return 5===e.tag||3===e.tag||26===e.tag||27===e.tag&&bd(e.type)||4===e.tag}function vl(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||yl(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(27===e.tag&&bd(e.type))continue e;if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function xl(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?(9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).insertBefore(e,t):((t=9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=td));else if(4!==r&&(27===r&&bd(e.type)&&(n=e.stateNode,t=null),null!==(e=e.child)))for(xl(e,t,n),e=e.sibling;null!==e;)xl(e,t,n),e=e.sibling}function wl(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==r&&(27===r&&bd(e.type)&&(n=e.stateNode),null!==(e=e.child)))for(wl(e,t,n),e=e.sibling;null!==e;)wl(e,t,n),e=e.sibling}function kl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,a=t.attributes;a.length;)t.removeAttributeNode(a[0]);ad(t,r,n),t[Le]=e,t[Oe]=n}catch(t){pu(e,e.return,t)}}var Cl=!1,Sl=!1,Nl=!1,jl="function"==typeof WeakSet?WeakSet:Set,El=null;function $l(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Ul(e,n),4&r&&ul(5,n);break;case 1:if(Ul(e,n),4&r)if(e=n.stateNode,null===t)try{e.componentDidMount()}catch(e){pu(n,n.return,e)}else{var a=xs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(a,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){pu(n,n.return,e)}}64&r&&ml(n),512&r&&pl(n,n.return);break;case 3:if(Ul(e,n),64&r&&null!==(e=n.updateQueue)){if(t=null,null!==n.child)switch(n.child.tag){case 27:case 5:case 1:t=n.child.stateNode}try{gi(e,t)}catch(e){pu(n,n.return,e)}}break;case 27:null===t&&4&r&&kl(n);case 26:case 5:Ul(e,n),null===t&&4&r&&gl(n),512&r&&pl(n,n.return);break;case 12:Ul(e,n);break;case 13:Ul(e,n),4&r&&Ml(e,n),64&r&&null!==(e=n.memoizedState)&&null!==(e=e.dehydrated)&&function(e,t){var n=e.ownerDocument;if("$?"!==e.data||"complete"===n.readyState)t();else{var r=function(){t(),n.removeEventListener("DOMContentLoaded",r)};n.addEventListener("DOMContentLoaded",r),e._reactRetry=r}}(e,n=yu.bind(null,n));break;case 22:if(!(r=null!==n.memoizedState||Cl)){t=null!==t&&null!==t.memoizedState||Sl,a=Cl;var i=Sl;Cl=r,(Sl=t)&&!i?Bl(e,n,!!(8772&n.subtreeFlags)):Ul(e,n),Cl=a,Sl=i}break;case 30:break;default:Ul(e,n)}}function _l(e){var t=e.alternate;null!==t&&(e.alternate=null,_l(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&null!==(t=e.stateNode)&&He(t),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var zl=null,Tl=!1;function Pl(e,t,n){for(n=n.child;null!==n;)Al(e,t,n),n=n.sibling}function Al(e,t,n){if(fe&&"function"==typeof fe.onCommitFiberUnmount)try{fe.onCommitFiberUnmount(pe,n)}catch(e){}switch(n.tag){case 26:Sl||fl(n,t),Pl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode).parentNode.removeChild(n);break;case 27:Sl||fl(n,t);var r=zl,a=Tl;bd(n.type)&&(zl=n.stateNode,Tl=!1),Pl(e,t,n),Nd(n.stateNode),zl=r,Tl=a;break;case 5:Sl||fl(n,t);case 6:if(r=zl,a=Tl,zl=null,Pl(e,t,n),Tl=a,null!==(zl=r))if(Tl)try{(9===zl.nodeType?zl.body:"HTML"===zl.nodeName?zl.ownerDocument.body:zl).removeChild(n.stateNode)}catch(e){pu(n,t,e)}else try{zl.removeChild(n.stateNode)}catch(e){pu(n,t,e)}break;case 18:null!==zl&&(Tl?(yd(9===(e=zl).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,n.stateNode),Tm(e)):yd(zl,n.stateNode));break;case 4:r=zl,a=Tl,zl=n.stateNode.containerInfo,Tl=!0,Pl(e,t,n),zl=r,Tl=a;break;case 0:case 11:case 14:case 15:Sl||dl(2,n,t),Sl||dl(4,n,t),Pl(e,t,n);break;case 1:Sl||(fl(n,t),"function"==typeof(r=n.stateNode).componentWillUnmount&&hl(n,t,r)),Pl(e,t,n);break;case 21:Pl(e,t,n);break;case 22:Sl=(r=Sl)||null!==n.memoizedState,Pl(e,t,n),Sl=r;break;default:Pl(e,t,n)}}function Ml(e,t){if(null===t.memoizedState&&null!==(e=t.alternate)&&null!==(e=e.memoizedState)&&null!==(e=e.dehydrated))try{Tm(e)}catch(e){pu(t,t.return,e)}}function Il(e,t){var n=function(e){switch(e.tag){case 13:case 19:var t=e.stateNode;return null===t&&(t=e.stateNode=new jl),t;case 22:return null===(t=(e=e.stateNode)._retryCache)&&(t=e._retryCache=new jl),t;default:throw Error(r(435,e.tag))}}(e);t.forEach(function(t){var r=vu.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}function Ll(e,t){var n=t.deletions;if(null!==n)for(var a=0;a<n.length;a++){var i=n[a],o=e,s=t,l=s;e:for(;null!==l;){switch(l.tag){case 27:if(bd(l.type)){zl=l.stateNode,Tl=!1;break e}break;case 5:zl=l.stateNode,Tl=!1;break e;case 3:case 4:zl=l.stateNode.containerInfo,Tl=!0;break e}l=l.return}if(null===zl)throw Error(r(160));Al(o,s,i),zl=null,Tl=!1,null!==(o=i.alternate)&&(o.return=null),i.return=null}if(13878&t.subtreeFlags)for(t=t.child;null!==t;)Rl(t,e),t=t.sibling}var Ol=null;function Rl(e,t){var n=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Ll(t,e),Dl(e),4&a&&(dl(3,e,e.return),ul(3,e),dl(5,e,e.return));break;case 1:Ll(t,e),Dl(e),512&a&&(Sl||null===n||fl(n,n.return)),64&a&&Cl&&null!==(e=e.updateQueue)&&null!==(a=e.callbacks)&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=null===n?a:n.concat(a));break;case 26:var i=Ol;if(Ll(t,e),Dl(e),512&a&&(Sl||null===n||fl(n,n.return)),4&a){var o=null!==n?n.memoizedState:null;if(a=e.memoizedState,null===n)if(null===a)if(null===e.stateNode){e:{a=e.type,n=e.memoizedProps,i=i.ownerDocument||i;t:switch(a){case"title":(!(o=i.getElementsByTagName("title")[0])||o[Be]||o[Le]||"http://www.w3.org/2000/svg"===o.namespaceURI||o.hasAttribute("itemprop"))&&(o=i.createElement(a),i.head.insertBefore(o,i.querySelector("head > title"))),ad(o,a,n),o[Le]=e,Qe(o),a=o;break e;case"link":var s=Bd("link","href",i).get(a+(n.href||""));if(s)for(var l=0;l<s.length;l++)if((o=s[l]).getAttribute("href")===(null==n.href||""===n.href?null:n.href)&&o.getAttribute("rel")===(null==n.rel?null:n.rel)&&o.getAttribute("title")===(null==n.title?null:n.title)&&o.getAttribute("crossorigin")===(null==n.crossOrigin?null:n.crossOrigin)){s.splice(l,1);break t}ad(o=i.createElement(a),a,n),i.head.appendChild(o);break;case"meta":if(s=Bd("meta","content",i).get(a+(n.content||"")))for(l=0;l<s.length;l++)if((o=s[l]).getAttribute("content")===(null==n.content?null:""+n.content)&&o.getAttribute("name")===(null==n.name?null:n.name)&&o.getAttribute("property")===(null==n.property?null:n.property)&&o.getAttribute("http-equiv")===(null==n.httpEquiv?null:n.httpEquiv)&&o.getAttribute("charset")===(null==n.charSet?null:n.charSet)){s.splice(l,1);break t}ad(o=i.createElement(a),a,n),i.head.appendChild(o);break;default:throw Error(r(468,a))}o[Le]=e,Qe(o),a=o}e.stateNode=a}else Hd(i,e.type,e.stateNode);else e.stateNode=Rd(i,a,e.memoizedProps);else o!==a?(null===o?null!==n.stateNode&&(n=n.stateNode).parentNode.removeChild(n):o.count--,null===a?Hd(i,e.type,e.stateNode):Rd(i,a,e.memoizedProps)):null===a&&null!==e.stateNode&&bl(e,e.memoizedProps,n.memoizedProps)}break;case 27:Ll(t,e),Dl(e),512&a&&(Sl||null===n||fl(n,n.return)),null!==n&&4&a&&bl(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Ll(t,e),Dl(e),512&a&&(Sl||null===n||fl(n,n.return)),32&e.flags){i=e.stateNode;try{jt(i,"")}catch(t){pu(e,e.return,t)}}4&a&&null!=e.stateNode&&bl(e,i=e.memoizedProps,null!==n?n.memoizedProps:i),1024&a&&(Nl=!0);break;case 6:if(Ll(t,e),Dl(e),4&a){if(null===e.stateNode)throw Error(r(162));a=e.memoizedProps,n=e.stateNode;try{n.nodeValue=a}catch(t){pu(e,e.return,t)}}break;case 3:if(qd=null,i=Ol,Ol=$d(t.containerInfo),Ll(t,e),Ol=i,Dl(e),4&a&&null!==n&&n.memoizedState.isDehydrated)try{Tm(t.containerInfo)}catch(t){pu(e,e.return,t)}Nl&&(Nl=!1,Fl(e));break;case 4:a=Ol,Ol=$d(e.stateNode.containerInfo),Ll(t,e),Dl(e),Ol=a;break;case 12:default:Ll(t,e),Dl(e);break;case 13:Ll(t,e),Dl(e),8192&e.child.flags&&null!==e.memoizedState!=(null!==n&&null!==n.memoizedState)&&(Nc=ie()),4&a&&null!==(a=e.updateQueue)&&(e.updateQueue=null,Il(e,a));break;case 22:i=null!==e.memoizedState;var c=null!==n&&null!==n.memoizedState,u=Cl,d=Sl;if(Cl=u||i,Sl=d||c,Ll(t,e),Sl=d,Cl=u,Dl(e),8192&a)e:for(t=e.stateNode,t._visibility=i?-2&t._visibility:1|t._visibility,i&&(null===n||c||Cl||Sl||ql(e)),n=null,t=e;;){if(5===t.tag||26===t.tag){if(null===n){c=n=t;try{if(o=c.stateNode,i)"function"==typeof(s=o.style).setProperty?s.setProperty("display","none","important"):s.display="none";else{l=c.stateNode;var m=c.memoizedProps.style,h=null!=m&&m.hasOwnProperty("display")?m.display:null;l.style.display=null==h||"boolean"==typeof h?"":(""+h).trim()}}catch(e){pu(c,c.return,e)}}}else if(6===t.tag){if(null===n){c=t;try{c.stateNode.nodeValue=i?"":c.memoizedProps}catch(e){pu(c,c.return,e)}}}else if((22!==t.tag&&23!==t.tag||null===t.memoizedState||t===e)&&null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;null===t.sibling;){if(null===t.return||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}4&a&&null!==(a=e.updateQueue)&&null!==(n=a.retryQueue)&&(a.retryQueue=null,Il(e,n));break;case 19:Ll(t,e),Dl(e),4&a&&null!==(a=e.updateQueue)&&(e.updateQueue=null,Il(e,a));case 30:case 21:}}function Dl(e){var t=e.flags;if(2&t){try{for(var n,a=e.return;null!==a;){if(yl(a)){n=a;break}a=a.return}if(null==n)throw Error(r(160));switch(n.tag){case 27:var i=n.stateNode;wl(e,vl(e),i);break;case 5:var o=n.stateNode;32&n.flags&&(jt(o,""),n.flags&=-33),wl(e,vl(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;xl(e,vl(e),s);break;default:throw Error(r(161))}}catch(t){pu(e,e.return,t)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function Fl(e){if(1024&e.subtreeFlags)for(e=e.child;null!==e;){var t=e;Fl(t),5===t.tag&&1024&t.flags&&t.stateNode.reset(),e=e.sibling}}function Ul(e,t){if(8772&t.subtreeFlags)for(t=t.child;null!==t;)$l(e,t.alternate,t),t=t.sibling}function ql(e){for(e=e.child;null!==e;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:dl(4,t,t.return),ql(t);break;case 1:fl(t,t.return);var n=t.stateNode;"function"==typeof n.componentWillUnmount&&hl(t,t.return,n),ql(t);break;case 27:Nd(t.stateNode);case 26:case 5:fl(t,t.return),ql(t);break;case 22:null===t.memoizedState&&ql(t);break;default:ql(t)}e=e.sibling}}function Bl(e,t,n){for(n=n&&!!(8772&t.subtreeFlags),t=t.child;null!==t;){var r=t.alternate,a=e,i=t,o=i.flags;switch(i.tag){case 0:case 11:case 15:Bl(a,i,n),ul(4,i);break;case 1:if(Bl(a,i,n),"function"==typeof(a=(r=i).stateNode).componentDidMount)try{a.componentDidMount()}catch(e){pu(r,r.return,e)}if(null!==(a=(r=i).updateQueue)){var s=r.stateNode;try{var l=a.shared.hiddenCallbacks;if(null!==l)for(a.shared.hiddenCallbacks=null,a=0;a<l.length;a++)fi(l[a],s)}catch(e){pu(r,r.return,e)}}n&&64&o&&ml(i),pl(i,i.return);break;case 27:kl(i);case 26:case 5:Bl(a,i,n),n&&null===r&&4&o&&gl(i),pl(i,i.return);break;case 12:Bl(a,i,n);break;case 13:Bl(a,i,n),n&&4&o&&Ml(a,i);break;case 22:null===i.memoizedState&&Bl(a,i,n),pl(i,i.return);break;case 30:break;default:Bl(a,i,n)}t=t.sibling}}function Hl(e,t){var n=null;null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),e=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(e=t.memoizedState.cachePool.pool),e!==n&&(null!=e&&e.refCount++,null!=n&&Ra(n))}function Wl(e,t){e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Ra(e))}function Vl(e,t,n,r){if(10256&t.subtreeFlags)for(t=t.child;null!==t;)Kl(e,t,n,r),t=t.sibling}function Kl(e,t,n,r){var a=t.flags;switch(t.tag){case 0:case 11:case 15:Vl(e,t,n,r),2048&a&&ul(9,t);break;case 1:case 13:default:Vl(e,t,n,r);break;case 3:Vl(e,t,n,r),2048&a&&(e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Ra(e)));break;case 12:if(2048&a){Vl(e,t,n,r),e=t.stateNode;try{var i=t.memoizedProps,o=i.id,s=i.onPostCommit;"function"==typeof s&&s(o,null===t.alternate?"mount":"update",e.passiveEffectDuration,-0)}catch(e){pu(t,t.return,e)}}else Vl(e,t,n,r);break;case 23:break;case 22:i=t.stateNode,o=t.alternate,null!==t.memoizedState?2&i._visibility?Vl(e,t,n,r):Ql(e,t):2&i._visibility?Vl(e,t,n,r):(i._visibility|=2,Gl(e,t,n,r,!!(10256&t.subtreeFlags))),2048&a&&Hl(o,t);break;case 24:Vl(e,t,n,r),2048&a&&Wl(t.alternate,t)}}function Gl(e,t,n,r,a){for(a=a&&!!(10256&t.subtreeFlags),t=t.child;null!==t;){var i=e,o=t,s=n,l=r,c=o.flags;switch(o.tag){case 0:case 11:case 15:Gl(i,o,s,l,a),ul(8,o);break;case 23:break;case 22:var u=o.stateNode;null!==o.memoizedState?2&u._visibility?Gl(i,o,s,l,a):Ql(i,o):(u._visibility|=2,Gl(i,o,s,l,a)),a&&2048&c&&Hl(o.alternate,o);break;case 24:Gl(i,o,s,l,a),a&&2048&c&&Wl(o.alternate,o);break;default:Gl(i,o,s,l,a)}t=t.sibling}}function Ql(e,t){if(10256&t.subtreeFlags)for(t=t.child;null!==t;){var n=e,r=t,a=r.flags;switch(r.tag){case 22:Ql(n,r),2048&a&&Hl(r.alternate,r);break;case 24:Ql(n,r),2048&a&&Wl(r.alternate,r);break;default:Ql(n,r)}t=t.sibling}}var Yl=8192;function Xl(e){if(e.subtreeFlags&Yl)for(e=e.child;null!==e;)Jl(e),e=e.sibling}function Jl(e){switch(e.tag){case 26:Xl(e),e.flags&Yl&&null!==e.memoizedState&&function(e,t,n){if(null===Vd)throw Error(r(475));var a=Vd;if(!("stylesheet"!==t.type||"string"==typeof n.media&&!1===matchMedia(n.media).matches||4&t.state.loading)){if(null===t.instance){var i=Ad(n.href),o=e.querySelector(Md(i));if(o)return null!==(e=o._p)&&"object"==typeof e&&"function"==typeof e.then&&(a.count++,a=Gd.bind(a),e.then(a,a)),t.state.loading|=4,t.instance=o,void Qe(o);o=e.ownerDocument||e,n=Id(n),(i=jd.get(i))&&Fd(n,i),Qe(o=o.createElement("link"));var s=o;s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),ad(o,"link",n),t.instance=o}null===a.stylesheets&&(a.stylesheets=new Map),a.stylesheets.set(t,e),(e=t.state.preload)&&!(3&t.state.loading)&&(a.count++,t=Gd.bind(a),e.addEventListener("load",t),e.addEventListener("error",t))}}(Ol,e.memoizedState,e.memoizedProps);break;case 5:default:Xl(e);break;case 3:case 4:var t=Ol;Ol=$d(e.stateNode.containerInfo),Xl(e),Ol=t;break;case 22:null===e.memoizedState&&(null!==(t=e.alternate)&&null!==t.memoizedState?(t=Yl,Yl=16777216,Xl(e),Yl=t):Xl(e))}}function Zl(e){var t=e.alternate;if(null!==t&&null!==(e=t.child)){t.child=null;do{t=e.sibling,e.sibling=null,e=t}while(null!==e)}}function ec(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var r=t[n];El=r,rc(r,e)}Zl(e)}if(10256&e.subtreeFlags)for(e=e.child;null!==e;)tc(e),e=e.sibling}function tc(e){switch(e.tag){case 0:case 11:case 15:ec(e),2048&e.flags&&dl(9,e,e.return);break;case 3:case 12:default:ec(e);break;case 22:var t=e.stateNode;null!==e.memoizedState&&2&t._visibility&&(null===e.return||13!==e.return.tag)?(t._visibility&=-3,nc(e)):ec(e)}}function nc(e){var t=e.deletions;if(16&e.flags){if(null!==t)for(var n=0;n<t.length;n++){var r=t[n];El=r,rc(r,e)}Zl(e)}for(e=e.child;null!==e;){switch((t=e).tag){case 0:case 11:case 15:dl(8,t,t.return),nc(t);break;case 22:2&(n=t.stateNode)._visibility&&(n._visibility&=-3,nc(t));break;default:nc(t)}e=e.sibling}}function rc(e,t){for(;null!==El;){var n=El;switch(n.tag){case 0:case 11:case 15:dl(8,n,t);break;case 23:case 22:if(null!==n.memoizedState&&null!==n.memoizedState.cachePool){var r=n.memoizedState.cachePool.pool;null!=r&&r.refCount++}break;case 24:Ra(n.memoizedState.cache)}if(null!==(r=n.child))r.return=n,El=r;else e:for(n=e;null!==El;){var a=(r=El).sibling,i=r.return;if(_l(r),r===n){El=null;break e}if(null!==a){a.return=i,El=a;break e}El=i}}}var ac={getCacheForType:function(e){var t=za(La),n=t.data.get(e);return void 0===n&&(n=e(),t.data.set(e,n)),n}},ic="function"==typeof WeakMap?WeakMap:Map,oc=0,sc=null,lc=null,cc=0,uc=0,dc=null,mc=!1,hc=!1,pc=!1,fc=0,gc=0,bc=0,yc=0,vc=0,xc=0,wc=0,kc=null,Cc=null,Sc=!1,Nc=0,jc=1/0,Ec=null,$c=null,_c=0,zc=null,Tc=null,Pc=0,Ac=0,Mc=null,Ic=null,Lc=0,Oc=null;function Rc(){return 2&oc&&0!==cc?cc&-cc:null!==R.T?0!==Ua?Ua:Au():Me()}function Dc(){0===xc&&(xc=536870912&cc&&!ca?536870912:je());var e=ls.current;return null!==e&&(e.flags|=32),xc}function Fc(e,t,n){(e!==sc||2!==uc&&9!==uc)&&null===e.cancelPendingCommit||(Kc(e,0),Hc(e,cc,xc,!1)),_e(e,n),2&oc&&e===sc||(e===sc&&(!(2&oc)&&(yc|=n),4===gc&&Hc(e,cc,xc,!1)),ju(e))}function Uc(e,t,n){if(6&oc)throw Error(r(327));for(var a=!n&&!(124&t)&&0===(t&e.expiredLanes)||Se(e,t),i=a?function(e,t){var n=oc;oc|=2;var a=Qc(),i=Yc();sc!==e||cc!==t?(Ec=null,jc=ie()+500,Kc(e,t)):hc=Se(e,t);e:for(;;)try{if(0!==uc&&null!==lc){t=lc;var o=dc;t:switch(uc){case 1:uc=0,dc=null,ru(e,t,o,1);break;case 2:case 9:if(Za(o)){uc=0,dc=null,nu(t);break}t=function(){2!==uc&&9!==uc||sc!==e||(uc=7),ju(e)},o.then(t,t);break e;case 3:uc=7;break e;case 4:uc=5;break e;case 7:Za(o)?(uc=0,dc=null,nu(t)):(uc=0,dc=null,ru(e,t,o,7));break;case 5:var s=null;switch(lc.tag){case 26:s=lc.memoizedState;case 5:case 27:var l=lc;if(!s||Wd(s)){uc=0,dc=null;var c=l.sibling;if(null!==c)lc=c;else{var u=l.return;null!==u?(lc=u,au(u)):lc=null}break t}}uc=0,dc=null,ru(e,t,o,5);break;case 6:uc=0,dc=null,ru(e,t,o,6);break;case 8:Vc(),gc=6;break e;default:throw Error(r(462))}}eu();break}catch(t){Gc(e,t)}return ka=wa=null,R.H=a,R.A=i,oc=n,null!==lc?0:(sc=null,cc=0,Pr(),gc)}(e,t):Jc(e,t,!0),o=a;;){if(0===i){hc&&!a&&Hc(e,t,0,!1);break}if(n=e.current.alternate,!o||Bc(n)){if(2===i){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=0!=(s=-536870913&e.pendingLanes)?s:536870912&s?536870912:0;if(0!==s){t=s;e:{var l=e;i=kc;var c=l.current.memoizedState.isDehydrated;if(c&&(Kc(l,s).flags|=256),2!==(s=Jc(l,s,!1))){if(pc&&!c){l.errorRecoveryDisabledLanes|=o,yc|=o,i=4;break e}o=Cc,Cc=i,null!==o&&(null===Cc?Cc=o:Cc.push.apply(Cc,o))}i=s}if(o=!1,2!==i)continue}}if(1===i){Kc(e,0),Hc(e,t,0,!0);break}e:{switch(a=e,o=i){case 0:case 1:throw Error(r(345));case 4:if((4194048&t)!==t)break;case 6:Hc(a,t,xc,!mc);break e;case 2:Cc=null;break;case 3:case 5:break;default:throw Error(r(329))}if((62914560&t)===t&&10<(i=Nc+300-ie())){if(Hc(a,t,xc,!mc),0!==Ce(a,0,!0))break e;a.timeoutHandle=md(qc.bind(null,a,n,Cc,Ec,Sc,t,xc,yc,wc,mc,o,2,-0,0),i)}else qc(a,n,Cc,Ec,Sc,t,xc,yc,wc,mc,o,0,-0,0)}break}i=Jc(e,t,!1),o=!1}ju(e)}function qc(e,t,n,a,i,o,s,l,c,u,d,m,h,p){if(e.timeoutHandle=-1,(8192&(m=t.subtreeFlags)||!(16785408&~m))&&(Vd={stylesheets:null,count:0,unsuspend:Kd},Jl(t),null!==(m=function(){if(null===Vd)throw Error(r(475));var e=Vd;return e.stylesheets&&0===e.count&&Yd(e,e.stylesheets),0<e.count?function(t){var n=setTimeout(function(){if(e.stylesheets&&Yd(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4);return e.unsuspend=t,function(){e.unsuspend=null,clearTimeout(n)}}:null}())))return e.cancelPendingCommit=m(ou.bind(null,e,t,o,n,a,i,s,l,c,d,1,h,p)),void Hc(e,o,s,!u);ou(e,t,o,n,a,i,s,l,c)}function Bc(e){for(var t=e;;){var n=t.tag;if((0===n||11===n||15===n)&&16384&t.flags&&null!==(n=t.updateQueue)&&null!==(n=n.stores))for(var r=0;r<n.length;r++){var a=n[r],i=a.getSnapshot;a=a.value;try{if(!Zn(i(),a))return!1}catch(e){return!1}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Hc(e,t,n,r){t&=~vc,t&=~yc,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var a=t;0<a;){var i=31-be(a),o=1<<i;r[i]=-1,a&=~o}0!==n&&ze(e,n,t)}function Wc(){return!!(6&oc)||(Eu(0),!1)}function Vc(){if(null!==lc){if(0===uc)var e=lc.return;else ka=wa=null,Ui(e=lc),Zo=null,es=0,e=lc;for(;null!==e;)cl(e.alternate,e),e=e.return;lc=null}}function Kc(e,t){var n=e.timeoutHandle;-1!==n&&(e.timeoutHandle=-1,hd(n)),null!==(n=e.cancelPendingCommit)&&(e.cancelPendingCommit=null,n()),Vc(),sc=e,lc=n=qr(e.current,null),cc=t,uc=0,dc=null,mc=!1,hc=Se(e,t),pc=!1,wc=xc=vc=yc=bc=gc=0,Cc=kc=null,Sc=!1,8&t&&(t|=32&t);var r=e.entangledLanes;if(0!==r)for(e=e.entanglements,r&=t;0<r;){var a=31-be(r),i=1<<a;t|=e[a],r&=~i}return fc=t,Pr(),n}function Gc(e,t){Ci=null,R.H=Qo,t===Qa||t===Xa?(t=ri(),uc=3):t===Ya?(t=ri(),uc=4):uc=t===zs?8:null!==t&&"object"==typeof t&&"function"==typeof t.then?6:1,dc=t,null===lc&&(gc=1,Ns(e,$r(t,e.current)))}function Qc(){var e=R.H;return R.H=Qo,null===e?Qo:e}function Yc(){var e=R.A;return R.A=ac,e}function Xc(){gc=4,mc||(4194048&cc)!==cc&&null!==ls.current||(hc=!0),!(134217727&bc)&&!(134217727&yc)||null===sc||Hc(sc,cc,xc,!1)}function Jc(e,t,n){var r=oc;oc|=2;var a=Qc(),i=Yc();sc===e&&cc===t||(Ec=null,Kc(e,t)),t=!1;var o=gc;e:for(;;)try{if(0!==uc&&null!==lc){var s=lc,l=dc;switch(uc){case 8:Vc(),o=6;break e;case 3:case 2:case 9:case 6:null===ls.current&&(t=!0);var c=uc;if(uc=0,dc=null,ru(e,s,l,c),n&&hc){o=0;break e}break;default:c=uc,uc=0,dc=null,ru(e,s,l,c)}}Zc(),o=gc;break}catch(t){Gc(e,t)}return t&&e.shellSuspendCounter++,ka=wa=null,oc=r,R.H=a,R.A=i,null===lc&&(sc=null,cc=0,Pr()),o}function Zc(){for(;null!==lc;)tu(lc)}function eu(){for(;null!==lc&&!re();)tu(lc)}function tu(e){var t=tl(e.alternate,e,fc);e.memoizedProps=e.pendingProps,null===t?au(e):lc=t}function nu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Fs(n,t,t.pendingProps,t.type,void 0,cc);break;case 11:t=Fs(n,t,t.pendingProps,t.type.render,t.ref,cc);break;case 5:Ui(t);default:cl(n,t),t=tl(n,t=lc=Br(t,fc),fc)}e.memoizedProps=e.pendingProps,null===t?au(e):lc=t}function ru(e,t,n,a){ka=wa=null,Ui(t),Zo=null,es=0;var i=t.return;try{if(function(e,t,n,a,i){if(n.flags|=32768,null!==a&&"object"==typeof a&&"function"==typeof a.then){if(null!==(t=n.alternate)&&Ea(t,n,i,!0),null!==(n=ls.current)){switch(n.tag){case 13:return null===cs?Xc():null===n.alternate&&0===gc&&(gc=3),n.flags&=-257,n.flags|=65536,n.lanes=i,a===Ja?n.flags|=16384:(null===(t=n.updateQueue)?n.updateQueue=new Set([a]):t.add(a),fu(e,a,i)),!1;case 22:return n.flags|=65536,a===Ja?n.flags|=16384:(null===(t=n.updateQueue)?(t={transitions:null,markerInstances:null,retryQueue:new Set([a])},n.updateQueue=t):null===(n=t.retryQueue)?t.retryQueue=new Set([a]):n.add(a),fu(e,a,i)),!1}throw Error(r(435,n.tag))}return fu(e,a,i),Xc(),!1}if(ca)return null!==(t=ls.current)?(!(65536&t.flags)&&(t.flags|=256),t.flags|=65536,t.lanes=i,a!==ma&&va($r(e=Error(r(422),{cause:a}),n))):(a!==ma&&va($r(t=Error(r(423),{cause:a}),n)),(e=e.current.alternate).flags|=65536,i&=-i,e.lanes|=i,a=$r(a,n),di(e,i=Es(e.stateNode,a,i)),4!==gc&&(gc=2)),!1;var o=Error(r(520),{cause:a});if(o=$r(o,n),null===kc?kc=[o]:kc.push(o),4!==gc&&(gc=2),null===t)return!0;a=$r(a,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,di(n,e=Es(n.stateNode,a,e)),!1;case 1:if(t=n.type,o=n.stateNode,!(128&n.flags||"function"!=typeof t.getDerivedStateFromError&&(null===o||"function"!=typeof o.componentDidCatch||null!==$c&&$c.has(o))))return n.flags|=65536,i&=-i,n.lanes|=i,_s(i=$s(i),e,n,a),di(n,i),!1}n=n.return}while(null!==n);return!1}(e,i,t,n,cc))return gc=1,Ns(e,$r(n,e.current)),void(lc=null)}catch(t){if(null!==i)throw lc=i,t;return gc=1,Ns(e,$r(n,e.current)),void(lc=null)}32768&t.flags?(ca||1===a?e=!0:hc||536870912&cc?e=!1:(mc=e=!0,(2===a||9===a||3===a||6===a)&&null!==(a=ls.current)&&13===a.tag&&(a.flags|=16384)),iu(t,e)):au(t)}function au(e){var t=e;do{if(32768&t.flags)return void iu(t,mc);e=t.return;var n=sl(t.alternate,t,fc);if(null!==n)return void(lc=n);if(null!==(t=t.sibling))return void(lc=t);lc=t=e}while(null!==t);0===gc&&(gc=5)}function iu(e,t){do{var n=ll(e.alternate,e);if(null!==n)return n.flags&=32767,void(lc=n);if(null!==(n=e.return)&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&null!==(e=e.sibling))return void(lc=e);lc=e=n}while(null!==e);gc=6,lc=null}function ou(e,t,n,a,i,o,s,l,c){e.cancelPendingCommit=null;do{du()}while(0!==_c);if(6&oc)throw Error(r(327));if(null!==t){if(t===e.current)throw Error(r(177));if(o=t.lanes|t.childLanes,function(e,t,n,r,a,i){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,l=e.expirationTimes,c=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-be(n),d=1<<u;s[u]=0,l[u]=-1;var m=c[u];if(null!==m)for(c[u]=null,u=0;u<m.length;u++){var h=m[u];null!==h&&(h.lane&=-536870913)}n&=~d}0!==r&&ze(e,r,0),0!==i&&0===a&&0!==e.tag&&(e.suspendedLanes|=i&~(o&~t))}(e,n,o|=Tr,s,l,c),e===sc&&(lc=sc=null,cc=0),Tc=t,zc=e,Pc=n,Ac=o,Mc=i,Ic=a,10256&t.subtreeFlags||10256&t.flags?(e.callbackNode=null,e.callbackPriority=0,te(ce,function(){return mu(),null})):(e.callbackNode=null,e.callbackPriority=0),a=!!(13878&t.flags),13878&t.subtreeFlags||a){a=R.T,R.T=null,i=D.p,D.p=2,s=oc,oc|=4;try{!function(e,t){if(e=e.containerInfo,id=om,ir(e=ar(e))){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{var a=(n=(n=e.ownerDocument)&&n.defaultView||window).getSelection&&n.getSelection();if(a&&0!==a.rangeCount){n=a.anchorNode;var i=a.anchorOffset,o=a.focusNode;a=a.focusOffset;try{n.nodeType,o.nodeType}catch(e){n=null;break e}var s=0,l=-1,c=-1,u=0,d=0,m=e,h=null;t:for(;;){for(var p;m!==n||0!==i&&3!==m.nodeType||(l=s+i),m!==o||0!==a&&3!==m.nodeType||(c=s+a),3===m.nodeType&&(s+=m.nodeValue.length),null!==(p=m.firstChild);)h=m,m=p;for(;;){if(m===e)break t;if(h===n&&++u===i&&(l=s),h===o&&++d===a&&(c=s),null!==(p=m.nextSibling))break;h=(m=h).parentNode}m=p}n=-1===l||-1===c?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(od={focusedElem:e,selectionRange:n},om=!1,El=t;null!==El;)if(e=(t=El).child,1024&t.subtreeFlags&&null!==e)e.return=t,El=e;else for(;null!==El;){switch(o=(t=El).alternate,e=t.flags,t.tag){case 0:case 11:case 15:case 5:case 26:case 27:case 6:case 4:case 17:break;case 1:if(1024&e&&null!==o){e=void 0,n=t,i=o.memoizedProps,o=o.memoizedState,a=n.stateNode;try{var f=xs(n.type,i,(n.elementType,n.type));e=a.getSnapshotBeforeUpdate(f,o),a.__reactInternalSnapshotBeforeUpdate=e}catch(e){pu(n,n.return,e)}}break;case 3:if(1024&e)if(9===(n=(e=t.stateNode.containerInfo).nodeType))vd(e);else if(1===n)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":vd(e);break;default:e.textContent=""}break;default:if(1024&e)throw Error(r(163))}if(null!==(e=t.sibling)){e.return=t.return,El=e;break}El=t.return}}(e,t)}finally{oc=s,D.p=i,R.T=a}}_c=1,su(),lu(),cu()}}function su(){if(1===_c){_c=0;var e=zc,t=Tc,n=!!(13878&t.flags);if(13878&t.subtreeFlags||n){n=R.T,R.T=null;var r=D.p;D.p=2;var a=oc;oc|=4;try{Rl(t,e);var i=od,o=ar(e.containerInfo),s=i.focusedElem,l=i.selectionRange;if(o!==s&&s&&s.ownerDocument&&rr(s.ownerDocument.documentElement,s)){if(null!==l&&ir(s)){var c=l.start,u=l.end;if(void 0===u&&(u=c),"selectionStart"in s)s.selectionStart=c,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,m=d&&d.defaultView||window;if(m.getSelection){var h=m.getSelection(),p=s.textContent.length,f=Math.min(l.start,p),g=void 0===l.end?f:Math.min(l.end,p);!h.extend&&f>g&&(o=g,g=f,f=o);var b=nr(s,f),y=nr(s,g);if(b&&y&&(1!==h.rangeCount||h.anchorNode!==b.node||h.anchorOffset!==b.offset||h.focusNode!==y.node||h.focusOffset!==y.offset)){var v=d.createRange();v.setStart(b.node,b.offset),h.removeAllRanges(),f>g?(h.addRange(v),h.extend(y.node,y.offset)):(v.setEnd(y.node,y.offset),h.addRange(v))}}}}for(d=[],h=s;h=h.parentNode;)1===h.nodeType&&d.push({element:h,left:h.scrollLeft,top:h.scrollTop});for("function"==typeof s.focus&&s.focus(),s=0;s<d.length;s++){var x=d[s];x.element.scrollLeft=x.left,x.element.scrollTop=x.top}}om=!!id,od=id=null}finally{oc=a,D.p=r,R.T=n}}e.current=t,_c=2}}function lu(){if(2===_c){_c=0;var e=zc,t=Tc,n=!!(8772&t.flags);if(8772&t.subtreeFlags||n){n=R.T,R.T=null;var r=D.p;D.p=2;var a=oc;oc|=4;try{$l(e,t.alternate,t)}finally{oc=a,D.p=r,R.T=n}}_c=3}}function cu(){if(4===_c||3===_c){_c=0,ae();var e=zc,t=Tc,n=Pc,r=Ic;10256&t.subtreeFlags||10256&t.flags?_c=5:(_c=0,Tc=zc=null,uu(e,e.pendingLanes));var a=e.pendingLanes;if(0===a&&($c=null),Ae(n),t=t.stateNode,fe&&"function"==typeof fe.onCommitFiberRoot)try{fe.onCommitFiberRoot(pe,t,void 0,!(128&~t.current.flags))}catch(e){}if(null!==r){t=R.T,a=D.p,D.p=2,R.T=null;try{for(var i=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];i(s.value,{componentStack:s.stack})}}finally{R.T=t,D.p=a}}3&Pc&&du(),ju(e),a=e.pendingLanes,4194090&n&&42&a?e===Oc?Lc++:(Lc=0,Oc=e):Lc=0,Eu(0)}}function uu(e,t){0===(e.pooledCacheLanes&=t)&&null!=(t=e.pooledCache)&&(e.pooledCache=null,Ra(t))}function du(e){return su(),lu(),cu(),mu()}function mu(){if(5!==_c)return!1;var e=zc,t=Ac;Ac=0;var n=Ae(Pc),a=R.T,i=D.p;try{D.p=32>n?32:n,R.T=null,n=Mc,Mc=null;var o=zc,s=Pc;if(_c=0,Tc=zc=null,Pc=0,6&oc)throw Error(r(331));var l=oc;if(oc|=4,tc(o.current),Kl(o,o.current,s,n),oc=l,Eu(0,!1),fe&&"function"==typeof fe.onPostCommitFiberRoot)try{fe.onPostCommitFiberRoot(pe,o)}catch(e){}return!0}finally{D.p=i,R.T=a,uu(e,t)}}function hu(e,t,n){t=$r(n,t),null!==(e=ci(e,t=Es(e.stateNode,t,2),2))&&(_e(e,2),ju(e))}function pu(e,t,n){if(3===e.tag)hu(e,e,n);else for(;null!==t;){if(3===t.tag){hu(t,e,n);break}if(1===t.tag){var r=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===$c||!$c.has(r))){e=$r(n,e),null!==(r=ci(t,n=$s(2),2))&&(_s(n,r,t,e),_e(r,2),ju(r));break}}t=t.return}}function fu(e,t,n){var r=e.pingCache;if(null===r){r=e.pingCache=new ic;var a=new Set;r.set(t,a)}else void 0===(a=r.get(t))&&(a=new Set,r.set(t,a));a.has(n)||(pc=!0,a.add(n),e=gu.bind(null,e,t,n),t.then(e,e))}function gu(e,t,n){var r=e.pingCache;null!==r&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,sc===e&&(cc&n)===n&&(4===gc||3===gc&&(62914560&cc)===cc&&300>ie()-Nc?!(2&oc)&&Kc(e,0):vc|=n,wc===cc&&(wc=0)),ju(e)}function bu(e,t){0===t&&(t=Ee()),null!==(e=Ir(e,t))&&(_e(e,t),ju(e))}function yu(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),bu(e,n)}function vu(e,t){var n=0;switch(e.tag){case 13:var a=e.stateNode,i=e.memoizedState;null!==i&&(n=i.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(r(314))}null!==a&&a.delete(t),bu(e,n)}var xu=null,wu=null,ku=!1,Cu=!1,Su=!1,Nu=0;function ju(e){e!==wu&&null===e.next&&(null===wu?xu=wu=e:wu=wu.next=e),Cu=!0,ku||(ku=!0,fd(function(){6&oc?te(se,$u):_u()}))}function Eu(e,t){if(!Su&&Cu){Su=!0;do{for(var n=!1,r=xu;null!==r;){if(0!==e){var a=r.pendingLanes;if(0===a)var i=0;else{var o=r.suspendedLanes,s=r.pingedLanes;i=(1<<31-be(42|e)+1)-1,i=201326741&(i&=a&~(o&~s))?201326741&i|1:i?2|i:0}0!==i&&(n=!0,Pu(r,i))}else i=cc,!(3&(i=Ce(r,r===sc?i:0,null!==r.cancelPendingCommit||-1!==r.timeoutHandle)))||Se(r,i)||(n=!0,Pu(r,i));r=r.next}}while(n);Su=!1}}function $u(){_u()}function _u(){Cu=ku=!1;var e=0;0!==Nu&&(function(){var e=window.event;return e&&"popstate"===e.type?e!==dd&&(dd=e,!0):(dd=null,!1)}()&&(e=Nu),Nu=0);for(var t=ie(),n=null,r=xu;null!==r;){var a=r.next,i=zu(r,t);0===i?(r.next=null,null===n?xu=a:n.next=a,null===a&&(wu=n)):(n=r,(0!==e||3&i)&&(Cu=!0)),r=a}Eu(e)}function zu(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,i=-62914561&e.pendingLanes;0<i;){var o=31-be(i),s=1<<o,l=a[o];-1===l?0!==(s&n)&&0===(s&r)||(a[o]=Ne(s,t)):l<=t&&(e.expiredLanes|=s),i&=~s}if(n=cc,n=Ce(e,e===(t=sc)?n:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle),r=e.callbackNode,0===n||e===t&&(2===uc||9===uc)||null!==e.cancelPendingCommit)return null!==r&&null!==r&&ne(r),e.callbackNode=null,e.callbackPriority=0;if(!(3&n)||Se(e,n)){if((t=n&-n)===e.callbackPriority)return t;switch(null!==r&&ne(r),Ae(n)){case 2:case 8:n=le;break;case 32:default:n=ce;break;case 268435456:n=de}return r=Tu.bind(null,e),n=te(n,r),e.callbackPriority=t,e.callbackNode=n,t}return null!==r&&null!==r&&ne(r),e.callbackPriority=2,e.callbackNode=null,2}function Tu(e,t){if(0!==_c&&5!==_c)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(du()&&e.callbackNode!==n)return null;var r=cc;return 0===(r=Ce(e,e===sc?r:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle))?null:(Uc(e,r,t),zu(e,ie()),null!=e.callbackNode&&e.callbackNode===n?Tu.bind(null,e):null)}function Pu(e,t){if(du())return null;Uc(e,t,!0)}function Au(){return 0===Nu&&(Nu=je()),Nu}function Mu(e){return null==e||"symbol"==typeof e||"boolean"==typeof e?null:"function"==typeof e?e:At(""+e)}function Iu(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}for(var Lu=0;Lu<Nr.length;Lu++){var Ou=Nr[Lu];jr(Ou.toLowerCase(),"on"+(Ou[0].toUpperCase()+Ou.slice(1)))}jr(br,"onAnimationEnd"),jr(yr,"onAnimationIteration"),jr(vr,"onAnimationStart"),jr("dblclick","onDoubleClick"),jr("focusin","onFocus"),jr("focusout","onBlur"),jr(xr,"onTransitionRun"),jr(wr,"onTransitionStart"),jr(kr,"onTransitionCancel"),jr(Cr,"onTransitionEnd"),Ze("onMouseEnter",["mouseout","mouseover"]),Ze("onMouseLeave",["mouseout","mouseover"]),Ze("onPointerEnter",["pointerout","pointerover"]),Ze("onPointerLeave",["pointerout","pointerover"]),Je("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Je("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Je("onBeforeInput",["compositionend","keypress","textInput","paste"]),Je("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Je("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Je("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ru="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Du=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ru));function Fu(e,t){t=!!(4&t);for(var n=0;n<e.length;n++){var r=e[n],a=r.event;r=r.listeners;e:{var i=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],l=s.instance,c=s.currentTarget;if(s=s.listener,l!==i&&a.isPropagationStopped())break e;i=s,a.currentTarget=c;try{i(a)}catch(e){ws(e)}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(e){ws(e)}a.currentTarget=null,i=l}}}}function Uu(e,t){var n=t[De];void 0===n&&(n=t[De]=new Set);var r=e+"__bubble";n.has(r)||(Wu(t,e,2,!1),n.add(r))}function qu(e,t,n){var r=0;t&&(r|=4),Wu(n,e,r,t)}var Bu="_reactListening"+Math.random().toString(36).slice(2);function Hu(e){if(!e[Bu]){e[Bu]=!0,Ye.forEach(function(t){"selectionchange"!==t&&(Du.has(t)||qu(t,!1,e),qu(t,!0,e))});var t=9===e.nodeType?e:e.ownerDocument;null===t||t[Bu]||(t[Bu]=!0,qu("selectionchange",!1,t))}}function Wu(e,t,n,r){switch(hm(t)){case 2:var a=sm;break;case 8:a=lm;break;default:a=cm}n=a.bind(null,t,n,e),a=void 0,!Bt||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(a=!0),r?void 0!==a?e.addEventListener(t,n,{capture:!0,passive:a}):e.addEventListener(t,n,!0):void 0!==a?e.addEventListener(t,n,{passive:a}):e.addEventListener(t,n,!1)}function Vu(e,t,n,r,a){var o=r;if(!(1&t||2&t||null===r))e:for(;;){if(null===r)return;var s=r.tag;if(3===s||4===s){var l=r.stateNode.containerInfo;if(l===a)break;if(4===s)for(s=r.return;null!==s;){var c=s.tag;if((3===c||4===c)&&s.stateNode.containerInfo===a)return;s=s.return}for(;null!==l;){if(null===(s=We(l)))return;if(5===(c=s.tag)||6===c||26===c||27===c){r=o=s;continue e}l=l.parentNode}}r=r.return}Ft(function(){var r=o,a=It(n),s=[];e:{var l=Sr.get(e);if(void 0!==l){var c=rn,u=e;switch(e){case"keypress":if(0===Qt(n))break e;case"keydown":case"keyup":c=vn;break;case"focusin":u="focus",c=un;break;case"focusout":u="blur",c=un;break;case"beforeblur":case"afterblur":c=un;break;case"click":if(2===n.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":c=ln;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":c=cn;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":c=wn;break;case br:case yr:case vr:c=dn;break;case Cr:c=kn;break;case"scroll":case"scrollend":c=on;break;case"wheel":c=Cn;break;case"copy":case"cut":case"paste":c=mn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=xn;break;case"toggle":case"beforetoggle":c=Sn}var d=!!(4&t),m=!d&&("scroll"===e||"scrollend"===e),h=d?null!==l?l+"Capture":null:l;d=[];for(var p,f=r;null!==f;){var g=f;if(p=g.stateNode,5!==(g=g.tag)&&26!==g&&27!==g||null===p||null===h||null!=(g=Ut(f,h))&&d.push(Ku(f,g,p)),m)break;f=f.return}0<d.length&&(l=new c(l,u,null,n,a),s.push({event:l,listeners:d}))}}if(!(7&t)){if(c="mouseout"===e||"pointerout"===e,(!(l="mouseover"===e||"pointerover"===e)||n===Mt||!(u=n.relatedTarget||n.fromElement)||!We(u)&&!u[Re])&&(c||l)&&(l=a.window===a?a:(l=a.ownerDocument)?l.defaultView||l.parentWindow:window,c?(c=r,null!==(u=(u=n.relatedTarget||n.toElement)?We(u):null)&&(m=i(u),d=u.tag,u!==m||5!==d&&27!==d&&6!==d)&&(u=null)):(c=null,u=r),c!==u)){if(d=ln,g="onMouseLeave",h="onMouseEnter",f="mouse","pointerout"!==e&&"pointerover"!==e||(d=xn,g="onPointerLeave",h="onPointerEnter",f="pointer"),m=null==c?l:Ke(c),p=null==u?l:Ke(u),(l=new d(g,f+"leave",c,n,a)).target=m,l.relatedTarget=p,g=null,We(a)===r&&((d=new d(h,f+"enter",u,n,a)).target=p,d.relatedTarget=m,g=d),m=g,c&&u)e:{for(h=u,f=0,p=d=c;p;p=Qu(p))f++;for(p=0,g=h;g;g=Qu(g))p++;for(;0<f-p;)d=Qu(d),f--;for(;0<p-f;)h=Qu(h),p--;for(;f--;){if(d===h||null!==h&&d===h.alternate)break e;d=Qu(d),h=Qu(h)}d=null}else d=null;null!==c&&Yu(s,l,c,d,!1),null!==u&&null!==m&&Yu(s,m,u,d,!0)}if("select"===(c=(l=r?Ke(r):window).nodeName&&l.nodeName.toLowerCase())||"input"===c&&"file"===l.type)var b=qn;else if(Ln(l))if(Bn)b=Jn;else{b=Yn;var y=Qn}else!(c=l.nodeName)||"input"!==c.toLowerCase()||"checkbox"!==l.type&&"radio"!==l.type?r&&zt(r.elementType)&&(b=qn):b=Xn;switch(b&&(b=b(e,r))?On(s,b,n,a):(y&&y(e,l,r),"focusout"===e&&r&&"number"===l.type&&null!=r.memoizedProps.value&&kt(l,"number",l.value)),y=r?Ke(r):window,e){case"focusin":(Ln(y)||"true"===y.contentEditable)&&(sr=y,lr=r,cr=null);break;case"focusout":cr=lr=sr=null;break;case"mousedown":ur=!0;break;case"contextmenu":case"mouseup":case"dragend":ur=!1,dr(s,n,a);break;case"selectionchange":if(or)break;case"keydown":case"keyup":dr(s,n,a)}var v;if(jn)e:{switch(e){case"compositionstart":var x="onCompositionStart";break e;case"compositionend":x="onCompositionEnd";break e;case"compositionupdate":x="onCompositionUpdate";break e}x=void 0}else Mn?Pn(e,n)&&(x="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(x="onCompositionStart");x&&(_n&&"ko"!==n.locale&&(Mn||"onCompositionStart"!==x?"onCompositionEnd"===x&&Mn&&(v=Gt()):(Vt="value"in(Wt=a)?Wt.value:Wt.textContent,Mn=!0)),0<(y=Gu(r,x)).length&&(x=new hn(x,e,null,n,a),s.push({event:x,listeners:y}),(v||null!==(v=An(n)))&&(x.data=v))),(v=$n?function(e,t){switch(e){case"compositionend":return An(t);case"keypress":return 32!==t.which?null:(Tn=!0,zn);case"textInput":return(e=t.data)===zn&&Tn?null:e;default:return null}}(e,n):function(e,t){if(Mn)return"compositionend"===e||!jn&&Pn(e,t)?(e=Gt(),Kt=Vt=Wt=null,Mn=!1,e):null;switch(e){case"paste":default:return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return _n&&"ko"!==t.locale?null:t.data}}(e,n))&&0<(x=Gu(r,"onBeforeInput")).length&&(y=new hn("onBeforeInput","beforeinput",null,n,a),s.push({event:y,listeners:x}),y.data=v),function(e,t,n,r,a){if("submit"===t&&n&&n.stateNode===a){var i=Mu((a[Oe]||null).action),o=r.submitter;o&&null!==(t=(t=o[Oe]||null)?Mu(t.formAction):o.getAttribute("formAction"))&&(i=t,o=null);var s=new rn("action","action",null,r,a);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(0!==Nu){var e=o?Iu(a,o):new FormData(a);Io(n,{pending:!0,data:e,method:a.method,action:i},null,e)}}else"function"==typeof i&&(s.preventDefault(),e=o?Iu(a,o):new FormData(a),Io(n,{pending:!0,data:e,method:a.method,action:i},i,e))},currentTarget:a}]})}}(s,e,r,n,a)}Fu(s,t)})}function Ku(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Gu(e,t){for(var n=t+"Capture",r=[];null!==e;){var a=e,i=a.stateNode;if(5!==(a=a.tag)&&26!==a&&27!==a||null===i||(null!=(a=Ut(e,n))&&r.unshift(Ku(e,a,i)),null!=(a=Ut(e,t))&&r.push(Ku(e,a,i))),3===e.tag)return r;e=e.return}return[]}function Qu(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag&&27!==e.tag);return e||null}function Yu(e,t,n,r,a){for(var i=t._reactName,o=[];null!==n&&n!==r;){var s=n,l=s.alternate,c=s.stateNode;if(s=s.tag,null!==l&&l===r)break;5!==s&&26!==s&&27!==s||null===c||(l=c,a?null!=(c=Ut(n,i))&&o.unshift(Ku(n,c,l)):a||null!=(c=Ut(n,i))&&o.push(Ku(n,c,l))),n=n.return}0!==o.length&&e.push({event:t,listeners:o})}var Xu=/\r\n?/g,Ju=/\u0000|\uFFFD/g;function Zu(e){return("string"==typeof e?e:""+e).replace(Xu,"\n").replace(Ju,"")}function ed(e,t){return t=Zu(t),Zu(e)===t}function td(){}function nd(e,t,n,a,i,o){switch(n){case"children":"string"==typeof a?"body"===t||"textarea"===t&&""===a||jt(e,a):("number"==typeof a||"bigint"==typeof a)&&"body"!==t&&jt(e,""+a);break;case"className":ot(e,"class",a);break;case"tabIndex":ot(e,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":ot(e,n,a);break;case"style":_t(e,a,o);break;case"data":if("object"!==t){ot(e,"data",a);break}case"src":case"href":if(""===a&&("a"!==t||"href"!==n)){e.removeAttribute(n);break}if(null==a||"function"==typeof a||"symbol"==typeof a||"boolean"==typeof a){e.removeAttribute(n);break}a=At(""+a),e.setAttribute(n,a);break;case"action":case"formAction":if("function"==typeof a){e.setAttribute(n,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}if("function"==typeof o&&("formAction"===n?("input"!==t&&nd(e,t,"name",i.name,i,null),nd(e,t,"formEncType",i.formEncType,i,null),nd(e,t,"formMethod",i.formMethod,i,null),nd(e,t,"formTarget",i.formTarget,i,null)):(nd(e,t,"encType",i.encType,i,null),nd(e,t,"method",i.method,i,null),nd(e,t,"target",i.target,i,null))),null==a||"symbol"==typeof a||"boolean"==typeof a){e.removeAttribute(n);break}a=At(""+a),e.setAttribute(n,a);break;case"onClick":null!=a&&(e.onclick=td);break;case"onScroll":null!=a&&Uu("scroll",e);break;case"onScrollEnd":null!=a&&Uu("scrollend",e);break;case"dangerouslySetInnerHTML":if(null!=a){if("object"!=typeof a||!("__html"in a))throw Error(r(61));if(null!=(n=a.__html)){if(null!=i.children)throw Error(r(60));e.innerHTML=n}}break;case"multiple":e.multiple=a&&"function"!=typeof a&&"symbol"!=typeof a;break;case"muted":e.muted=a&&"function"!=typeof a&&"symbol"!=typeof a;break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":case"autoFocus":break;case"xlinkHref":if(null==a||"function"==typeof a||"boolean"==typeof a||"symbol"==typeof a){e.removeAttribute("xlink:href");break}n=At(""+a),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":null!=a&&"function"!=typeof a&&"symbol"!=typeof a?e.setAttribute(n,""+a):e.removeAttribute(n);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":a&&"function"!=typeof a&&"symbol"!=typeof a?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":!0===a?e.setAttribute(n,""):!1!==a&&null!=a&&"function"!=typeof a&&"symbol"!=typeof a?e.setAttribute(n,a):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":null!=a&&"function"!=typeof a&&"symbol"!=typeof a&&!isNaN(a)&&1<=a?e.setAttribute(n,a):e.removeAttribute(n);break;case"rowSpan":case"start":null==a||"function"==typeof a||"symbol"==typeof a||isNaN(a)?e.removeAttribute(n):e.setAttribute(n,a);break;case"popover":Uu("beforetoggle",e),Uu("toggle",e),it(e,"popover",a);break;case"xlinkActuate":st(e,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":st(e,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":st(e,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":st(e,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":st(e,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":st(e,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":st(e,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":st(e,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":st(e,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":it(e,"is",a);break;case"innerText":case"textContent":break;default:(!(2<n.length)||"o"!==n[0]&&"O"!==n[0]||"n"!==n[1]&&"N"!==n[1])&&it(e,n=Tt.get(n)||n,a)}}function rd(e,t,n,a,i,o){switch(n){case"style":_t(e,a,o);break;case"dangerouslySetInnerHTML":if(null!=a){if("object"!=typeof a||!("__html"in a))throw Error(r(61));if(null!=(n=a.__html)){if(null!=i.children)throw Error(r(60));e.innerHTML=n}}break;case"children":"string"==typeof a?jt(e,a):("number"==typeof a||"bigint"==typeof a)&&jt(e,""+a);break;case"onScroll":null!=a&&Uu("scroll",e);break;case"onScrollEnd":null!=a&&Uu("scrollend",e);break;case"onClick":null!=a&&(e.onclick=td);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":case"innerText":case"textContent":break;default:Xe.hasOwnProperty(n)||("o"!==n[0]||"n"!==n[1]||(i=n.endsWith("Capture"),t=n.slice(2,i?n.length-7:void 0),"function"==typeof(o=null!=(o=e[Oe]||null)?o[n]:null)&&e.removeEventListener(t,o,i),"function"!=typeof a)?n in e?e[n]=a:!0===a?e.setAttribute(n,""):it(e,n,a):("function"!=typeof o&&null!==o&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,a,i)))}}function ad(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Uu("error",e),Uu("load",e);var a,i=!1,o=!1;for(a in n)if(n.hasOwnProperty(a)){var s=n[a];if(null!=s)switch(a){case"src":i=!0;break;case"srcSet":o=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:nd(e,t,a,s,n,null)}}return o&&nd(e,t,"srcSet",n.srcSet,n,null),void(i&&nd(e,t,"src",n.src,n,null));case"input":Uu("invalid",e);var l=a=s=o=null,c=null,u=null;for(i in n)if(n.hasOwnProperty(i)){var d=n[i];if(null!=d)switch(i){case"name":o=d;break;case"type":s=d;break;case"checked":c=d;break;case"defaultChecked":u=d;break;case"value":a=d;break;case"defaultValue":l=d;break;case"children":case"dangerouslySetInnerHTML":if(null!=d)throw Error(r(137,t));break;default:nd(e,t,i,d,n,null)}}return wt(e,a,l,c,u,s,o,!1),void ft(e);case"select":for(o in Uu("invalid",e),i=s=a=null,n)if(n.hasOwnProperty(o)&&null!=(l=n[o]))switch(o){case"value":a=l;break;case"defaultValue":s=l;break;case"multiple":i=l;default:nd(e,t,o,l,n,null)}return t=a,n=s,e.multiple=!!i,void(null!=t?Ct(e,!!i,t,!1):null!=n&&Ct(e,!!i,n,!0));case"textarea":for(s in Uu("invalid",e),a=o=i=null,n)if(n.hasOwnProperty(s)&&null!=(l=n[s]))switch(s){case"value":i=l;break;case"defaultValue":o=l;break;case"children":a=l;break;case"dangerouslySetInnerHTML":if(null!=l)throw Error(r(91));break;default:nd(e,t,s,l,n,null)}return Nt(e,i,o,a),void ft(e);case"option":for(c in n)n.hasOwnProperty(c)&&null!=(i=n[c])&&("selected"===c?e.selected=i&&"function"!=typeof i&&"symbol"!=typeof i:nd(e,t,c,i,n,null));return;case"dialog":Uu("beforetoggle",e),Uu("toggle",e),Uu("cancel",e),Uu("close",e);break;case"iframe":case"object":Uu("load",e);break;case"video":case"audio":for(i=0;i<Ru.length;i++)Uu(Ru[i],e);break;case"image":Uu("error",e),Uu("load",e);break;case"details":Uu("toggle",e);break;case"embed":case"source":case"link":Uu("error",e),Uu("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(u in n)if(n.hasOwnProperty(u)&&null!=(i=n[u]))switch(u){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:nd(e,t,u,i,n,null)}return;default:if(zt(t)){for(d in n)n.hasOwnProperty(d)&&void 0!==(i=n[d])&&rd(e,t,d,i,n,void 0);return}}for(l in n)n.hasOwnProperty(l)&&null!=(i=n[l])&&nd(e,t,l,i,n,null)}var id=null,od=null;function sd(e){return 9===e.nodeType?e:e.ownerDocument}function ld(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function cd(e,t){if(0===e)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return 1===e&&"foreignObject"===t?0:e}function ud(e,t){return"textarea"===e||"noscript"===e||"string"==typeof t.children||"number"==typeof t.children||"bigint"==typeof t.children||"object"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var dd=null,md="function"==typeof setTimeout?setTimeout:void 0,hd="function"==typeof clearTimeout?clearTimeout:void 0,pd="function"==typeof Promise?Promise:void 0,fd="function"==typeof queueMicrotask?queueMicrotask:void 0!==pd?function(e){return pd.resolve(null).then(e).catch(gd)}:md;function gd(e){setTimeout(function(){throw e})}function bd(e){return"head"===e}function yd(e,t){var n=t,r=0,a=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&8===i.nodeType)if("/$"===(n=i.data)){if(0<r&&8>r){n=r;var o=e.ownerDocument;if(1&n&&Nd(o.documentElement),2&n&&Nd(o.body),4&n)for(Nd(n=o.head),o=n.firstChild;o;){var s=o.nextSibling,l=o.nodeName;o[Be]||"SCRIPT"===l||"STYLE"===l||"LINK"===l&&"stylesheet"===o.rel.toLowerCase()||n.removeChild(o),o=s}}if(0===a)return e.removeChild(i),void Tm(t);a--}else"$"===n||"$?"===n||"$!"===n?a++:r=n.charCodeAt(0)-48;else r=0;n=i}while(n);Tm(t)}function vd(e){var t=e.firstChild;for(t&&10===t.nodeType&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":vd(n),He(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if("stylesheet"===n.rel.toLowerCase())continue}e.removeChild(n)}}function xd(e){return"$!"===e.data||"$?"===e.data&&"complete"===e.ownerDocument.readyState}function wd(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t||"F!"===t||"F"===t)break;if("/$"===t)return null}}return e}var kd=null;function Cd(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n){if(0===t)return e;t--}else"/$"===n&&t++}e=e.previousSibling}return null}function Sd(e,t,n){switch(t=sd(n),e){case"html":if(!(e=t.documentElement))throw Error(r(452));return e;case"head":if(!(e=t.head))throw Error(r(453));return e;case"body":if(!(e=t.body))throw Error(r(454));return e;default:throw Error(r(451))}}function Nd(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);He(e)}var jd=new Map,Ed=new Set;function $d(e){return"function"==typeof e.getRootNode?e.getRootNode():9===e.nodeType?e:e.ownerDocument}var _d=D.d;D.d={f:function(){var e=_d.f(),t=Wc();return e||t},r:function(e){var t=Ve(e);null!==t&&5===t.tag&&"form"===t.type?Oo(t):_d.r(e)},D:function(e){_d.D(e),Td("dns-prefetch",e,null)},C:function(e,t){_d.C(e,t),Td("preconnect",e,t)},L:function(e,t,n){_d.L(e,t,n);var r=zd;if(r&&e&&t){var a='link[rel="preload"][as="'+vt(t)+'"]';"image"===t&&n&&n.imageSrcSet?(a+='[imagesrcset="'+vt(n.imageSrcSet)+'"]',"string"==typeof n.imageSizes&&(a+='[imagesizes="'+vt(n.imageSizes)+'"]')):a+='[href="'+vt(e)+'"]';var i=a;switch(t){case"style":i=Ad(e);break;case"script":i=Ld(e)}jd.has(i)||(e=u({rel:"preload",href:"image"===t&&n&&n.imageSrcSet?void 0:e,as:t},n),jd.set(i,e),null!==r.querySelector(a)||"style"===t&&r.querySelector(Md(i))||"script"===t&&r.querySelector(Od(i))||(ad(t=r.createElement("link"),"link",e),Qe(t),r.head.appendChild(t)))}},m:function(e,t){_d.m(e,t);var n=zd;if(n&&e){var r=t&&"string"==typeof t.as?t.as:"script",a='link[rel="modulepreload"][as="'+vt(r)+'"][href="'+vt(e)+'"]',i=a;switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":i=Ld(e)}if(!jd.has(i)&&(e=u({rel:"modulepreload",href:e},t),jd.set(i,e),null===n.querySelector(a))){switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(Od(i)))return}ad(r=n.createElement("link"),"link",e),Qe(r),n.head.appendChild(r)}}},X:function(e,t){_d.X(e,t);var n=zd;if(n&&e){var r=Ge(n).hoistableScripts,a=Ld(e),i=r.get(a);i||((i=n.querySelector(Od(a)))||(e=u({src:e,async:!0},t),(t=jd.get(a))&&Ud(e,t),Qe(i=n.createElement("script")),ad(i,"link",e),n.head.appendChild(i)),i={type:"script",instance:i,count:1,state:null},r.set(a,i))}},S:function(e,t,n){_d.S(e,t,n);var r=zd;if(r&&e){var a=Ge(r).hoistableStyles,i=Ad(e);t=t||"default";var o=a.get(i);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Md(i)))s.loading=5;else{e=u({rel:"stylesheet",href:e,"data-precedence":t},n),(n=jd.get(i))&&Fd(e,n);var l=o=r.createElement("link");Qe(l),ad(l,"link",e),l._p=new Promise(function(e,t){l.onload=e,l.onerror=t}),l.addEventListener("load",function(){s.loading|=1}),l.addEventListener("error",function(){s.loading|=2}),s.loading|=4,Dd(o,t,r)}o={type:"stylesheet",instance:o,count:1,state:s},a.set(i,o)}}},M:function(e,t){_d.M(e,t);var n=zd;if(n&&e){var r=Ge(n).hoistableScripts,a=Ld(e),i=r.get(a);i||((i=n.querySelector(Od(a)))||(e=u({src:e,async:!0,type:"module"},t),(t=jd.get(a))&&Ud(e,t),Qe(i=n.createElement("script")),ad(i,"link",e),n.head.appendChild(i)),i={type:"script",instance:i,count:1,state:null},r.set(a,i))}}};var zd="undefined"==typeof document?null:document;function Td(e,t,n){var r=zd;if(r&&"string"==typeof t&&t){var a=vt(t);a='link[rel="'+e+'"][href="'+a+'"]',"string"==typeof n&&(a+='[crossorigin="'+n+'"]'),Ed.has(a)||(Ed.add(a),e={rel:e,crossOrigin:n,href:t},null===r.querySelector(a)&&(ad(t=r.createElement("link"),"link",e),Qe(t),r.head.appendChild(t)))}}function Pd(e,t,n,a){var i,o,s,l,c=(c=G.current)?$d(c):null;if(!c)throw Error(r(446));switch(e){case"meta":case"title":return null;case"style":return"string"==typeof n.precedence&&"string"==typeof n.href?(t=Ad(n.href),(a=(n=Ge(c).hoistableStyles).get(t))||(a={type:"style",instance:null,count:0,state:null},n.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if("stylesheet"===n.rel&&"string"==typeof n.href&&"string"==typeof n.precedence){e=Ad(n.href);var u=Ge(c).hoistableStyles,d=u.get(e);if(d||(c=c.ownerDocument||c,d={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,d),(u=c.querySelector(Md(e)))&&!u._p&&(d.instance=u,d.state.loading=5),jd.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},jd.set(e,n),u||(i=c,o=e,s=n,l=d.state,i.querySelector('link[rel="preload"][as="style"]['+o+"]")?l.loading=1:(o=i.createElement("link"),l.preload=o,o.addEventListener("load",function(){return l.loading|=1}),o.addEventListener("error",function(){return l.loading|=2}),ad(o,"link",s),Qe(o),i.head.appendChild(o))))),t&&null===a)throw Error(r(528,""));return d}if(t&&null!==a)throw Error(r(529,""));return null;case"script":return t=n.async,"string"==typeof(n=n.src)&&t&&"function"!=typeof t&&"symbol"!=typeof t?(t=Ld(n),(a=(n=Ge(c).hoistableScripts).get(t))||(a={type:"script",instance:null,count:0,state:null},n.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,e))}}function Ad(e){return'href="'+vt(e)+'"'}function Md(e){return'link[rel="stylesheet"]['+e+"]"}function Id(e){return u({},e,{"data-precedence":e.precedence,precedence:null})}function Ld(e){return'[src="'+vt(e)+'"]'}function Od(e){return"script[async]"+e}function Rd(e,t,n){if(t.count++,null===t.instance)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+vt(n.href)+'"]');if(a)return t.instance=a,Qe(a),a;var i=u({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return Qe(a=(e.ownerDocument||e).createElement("style")),ad(a,"style",i),Dd(a,n.precedence,e),t.instance=a;case"stylesheet":i=Ad(n.href);var o=e.querySelector(Md(i));if(o)return t.state.loading|=4,t.instance=o,Qe(o),o;a=Id(n),(i=jd.get(i))&&Fd(a,i),Qe(o=(e.ownerDocument||e).createElement("link"));var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),ad(o,"link",a),t.state.loading|=4,Dd(o,n.precedence,e),t.instance=o;case"script":return o=Ld(n.src),(i=e.querySelector(Od(o)))?(t.instance=i,Qe(i),i):(a=n,(i=jd.get(o))&&Ud(a=u({},n),i),Qe(i=(e=e.ownerDocument||e).createElement("script")),ad(i,"link",a),e.head.appendChild(i),t.instance=i);case"void":return null;default:throw Error(r(443,t.type))}else"stylesheet"===t.type&&!(4&t.state.loading)&&(a=t.instance,t.state.loading|=4,Dd(a,n.precedence,e));return t.instance}function Dd(e,t,n){for(var r=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),a=r.length?r[r.length-1]:null,i=a,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)i=s;else if(i!==a)break}i?i.parentNode.insertBefore(e,i.nextSibling):(t=9===n.nodeType?n.head:n).insertBefore(e,t.firstChild)}function Fd(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.title&&(e.title=t.title)}function Ud(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.integrity&&(e.integrity=t.integrity)}var qd=null;function Bd(e,t,n){if(null===qd){var r=new Map,a=qd=new Map;a.set(n,r)}else(r=(a=qd).get(n))||(r=new Map,a.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),a=0;a<n.length;a++){var i=n[a];if(!(i[Be]||i[Le]||"link"===e&&"stylesheet"===i.getAttribute("rel"))&&"http://www.w3.org/2000/svg"!==i.namespaceURI){var o=i.getAttribute(t)||"";o=e+o;var s=r.get(o);s?s.push(i):r.set(o,[i])}}return r}function Hd(e,t,n){(e=e.ownerDocument||e).head.insertBefore(n,"title"===t?e.querySelector("head > title"):null)}function Wd(e){return!!("stylesheet"!==e.type||3&e.state.loading)}var Vd=null;function Kd(){}function Gd(){if(this.count--,0===this.count)if(this.stylesheets)Yd(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}var Qd=null;function Yd(e,t){e.stylesheets=null,null!==e.unsuspend&&(e.count++,Qd=new Map,t.forEach(Xd,e),Qd=null,Gd.call(e))}function Xd(e,t){if(!(4&t.state.loading)){var n=Qd.get(e);if(n)var r=n.get(null);else{n=new Map,Qd.set(e,n);for(var a=e.querySelectorAll("link[data-precedence],style[data-precedence]"),i=0;i<a.length;i++){var o=a[i];"LINK"!==o.nodeName&&"not all"===o.getAttribute("media")||(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}o=(a=t.instance).getAttribute("data-precedence"),(i=n.get(o)||r)===r&&n.set(null,a),n.set(o,a),this.count++,r=Gd.bind(this),a.addEventListener("load",r),a.addEventListener("error",r),i?i.parentNode.insertBefore(a,i.nextSibling):(e=9===e.nodeType?e.head:e).insertBefore(a,e.firstChild),t.state.loading|=4}}var Jd={$$typeof:N,Provider:null,Consumer:null,_currentValue:F,_currentValue2:F,_threadCount:0};function Zd(e,t,n,r,a,i,o,s){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=$e(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=$e(0),this.hiddenUpdates=$e(null),this.identifierPrefix=r,this.onUncaughtError=a,this.onCaughtError=i,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=s,this.incompleteTransitions=new Map}function em(e,t,n,r,a,i,o,s,l,c,u,d){return e=new Zd(e,t,n,o,s,l,c,d),t=1,!0===i&&(t|=24),i=Fr(3,null,null,t),e.current=i,i.stateNode=e,(t=Oa()).refCount++,e.pooledCache=t,t.refCount++,i.memoizedState={element:r,isDehydrated:n,cache:t},oi(i),e}function tm(e){return e?e=Rr:Rr}function nm(e,t,n,r,a,i){a=tm(a),null===r.context?r.context=a:r.pendingContext=a,(r=li(t)).payload={element:n},null!==(i=void 0===i?null:i)&&(r.callback=i),null!==(n=ci(e,r,t))&&(Fc(n,0,t),ui(n,e,t))}function rm(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function am(e,t){rm(e,t),(e=e.alternate)&&rm(e,t)}function im(e){if(13===e.tag){var t=Ir(e,67108864);null!==t&&Fc(t,0,67108864),am(e,67108864)}}var om=!0;function sm(e,t,n,r){var a=R.T;R.T=null;var i=D.p;try{D.p=2,cm(e,t,n,r)}finally{D.p=i,R.T=a}}function lm(e,t,n,r){var a=R.T;R.T=null;var i=D.p;try{D.p=8,cm(e,t,n,r)}finally{D.p=i,R.T=a}}function cm(e,t,n,r){if(om){var a=um(r);if(null===a)Vu(e,t,r,dm,n),km(e,r);else if(function(e,t,n,r,a){switch(t){case"focusin":return fm=Cm(fm,e,t,n,r,a),!0;case"dragenter":return gm=Cm(gm,e,t,n,r,a),!0;case"mouseover":return bm=Cm(bm,e,t,n,r,a),!0;case"pointerover":var i=a.pointerId;return ym.set(i,Cm(ym.get(i)||null,e,t,n,r,a)),!0;case"gotpointercapture":return i=a.pointerId,vm.set(i,Cm(vm.get(i)||null,e,t,n,r,a)),!0}return!1}(a,e,t,n,r))r.stopPropagation();else if(km(e,r),4&t&&-1<wm.indexOf(e)){for(;null!==a;){var i=Ve(a);if(null!==i)switch(i.tag){case 3:if((i=i.stateNode).current.memoizedState.isDehydrated){var o=ke(i.pendingLanes);if(0!==o){var s=i;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var l=1<<31-be(o);s.entanglements[1]|=l,o&=~l}ju(i),!(6&oc)&&(jc=ie()+500,Eu(0))}}break;case 13:null!==(s=Ir(i,2))&&Fc(s,0,2),Wc(),am(i,2)}if(null===(i=um(r))&&Vu(e,t,r,dm,n),i===a)break;a=i}null!==a&&r.stopPropagation()}else Vu(e,t,r,null,n)}}function um(e){return mm(e=It(e))}var dm=null;function mm(e){if(dm=null,null!==(e=We(e))){var t=i(e);if(null===t)e=null;else{var n=t.tag;if(13===n){if(null!==(e=o(t)))return e;e=null}else if(3===n){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return dm=e,null}function hm(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(oe()){case se:return 2;case le:return 8;case ce:case ue:return 32;case de:return 268435456;default:return 32}default:return 32}}var pm=!1,fm=null,gm=null,bm=null,ym=new Map,vm=new Map,xm=[],wm="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function km(e,t){switch(e){case"focusin":case"focusout":fm=null;break;case"dragenter":case"dragleave":gm=null;break;case"mouseover":case"mouseout":bm=null;break;case"pointerover":case"pointerout":ym.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":vm.delete(t.pointerId)}}function Cm(e,t,n,r,a,i){return null===e||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[a]},null!==t&&null!==(t=Ve(t))&&im(t),e):(e.eventSystemFlags|=r,t=e.targetContainers,null!==a&&-1===t.indexOf(a)&&t.push(a),e)}function Sm(e){var t=We(e.target);if(null!==t){var n=i(t);if(null!==n)if(13===(t=n.tag)){if(null!==(t=o(n)))return e.blockedOn=t,void function(e,t){var n=D.p;try{return D.p=e,t()}finally{D.p=n}}(e.priority,function(){if(13===n.tag){var e=Rc();e=Pe(e);var t=Ir(n,e);null!==t&&Fc(t,0,e),am(n,e)}})}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function Nm(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=um(e.nativeEvent);if(null!==n)return null!==(t=Ve(n))&&im(t),e.blockedOn=n,!1;var r=new(n=e.nativeEvent).constructor(n.type,n);Mt=r,n.target.dispatchEvent(r),Mt=null,t.shift()}return!0}function jm(e,t,n){Nm(e)&&n.delete(t)}function Em(){pm=!1,null!==fm&&Nm(fm)&&(fm=null),null!==gm&&Nm(gm)&&(gm=null),null!==bm&&Nm(bm)&&(bm=null),ym.forEach(jm),vm.forEach(jm)}function $m(t,n){t.blockedOn===n&&(t.blockedOn=null,pm||(pm=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Em)))}var _m=null;function zm(t){_m!==t&&(_m=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){_m===t&&(_m=null);for(var e=0;e<t.length;e+=3){var n=t[e],r=t[e+1],a=t[e+2];if("function"!=typeof r){if(null===mm(r||n))continue;break}var i=Ve(n);null!==i&&(t.splice(e,3),e-=3,Io(i,{pending:!0,data:a,method:n.method,action:r},r,a))}}))}function Tm(e){function t(t){return $m(t,e)}null!==fm&&$m(fm,e),null!==gm&&$m(gm,e),null!==bm&&$m(bm,e),ym.forEach(t),vm.forEach(t);for(var n=0;n<xm.length;n++){var r=xm[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<xm.length&&null===(n=xm[0]).blockedOn;)Sm(n),null===n.blockedOn&&xm.shift();if(null!=(n=(e.ownerDocument||e).$$reactFormReplay))for(r=0;r<n.length;r+=3){var a=n[r],i=n[r+1],o=a[Oe]||null;if("function"==typeof i)o||zm(n);else if(o){var s=null;if(i&&i.hasAttribute("formAction")){if(a=i,o=i[Oe]||null)s=o.formAction;else if(null!==mm(a))continue}else s=o.action;"function"==typeof s?n[r+1]=s:(n.splice(r,3),r-=3),zm(n)}}}function Pm(e){this._internalRoot=e}function Am(e){this._internalRoot=e}Am.prototype.render=Pm.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(r(409));nm(t.current,Rc(),e,t,null,null)},Am.prototype.unmount=Pm.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;nm(e.current,2,null,e,null,null),Wc(),t[Re]=null}},Am.prototype.unstable_scheduleHydration=function(e){if(e){var t=Me();e={blockedOn:null,target:e,priority:t};for(var n=0;n<xm.length&&0!==t&&t<xm[n].priority;n++);xm.splice(n,0,e),0===n&&Sm(e)}};var Mm=t.version;if("19.1.1"!==Mm)throw Error(r(527,Mm,"19.1.1"));D.findDOMNode=function(e){var t=e._reactInternals;if(void 0===t){if("function"==typeof e.render)throw Error(r(188));throw e=Object.keys(e).join(","),Error(r(268,e))}return e=function(e){var t=e.alternate;if(!t){if(null===(t=i(e)))throw Error(r(188));return t!==e?null:e}for(var n=e,a=t;;){var o=n.return;if(null===o)break;var 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),null===(e=null!==e?c(e):null)?null:e.stateNode};var Im={bundleType:0,version:"19.1.1",rendererPackageName:"react-dom",currentDispatcherRef:R,reconcilerVersion:"19.1.1"};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var Lm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Lm.isDisabled&&Lm.supportsFiber)try{pe=Lm.inject(Im),fe=Lm}catch(e){}}return h.createRoot=function(e,t){if(!a(e))throw Error(r(299));var n=!1,i="",o=ks,s=Cs,l=Ss;return null!=t&&(!0===t.unstable_strictMode&&(n=!0),void 0!==t.identifierPrefix&&(i=t.identifierPrefix),void 0!==t.onUncaughtError&&(o=t.onUncaughtError),void 0!==t.onCaughtError&&(s=t.onCaughtError),void 0!==t.onRecoverableError&&(l=t.onRecoverableError),void 0!==t.unstable_transitionCallbacks&&t.unstable_transitionCallbacks),t=em(e,1,!1,null,0,n,i,o,s,l,0,null),e[Re]=t.current,Hu(e),new Pm(t)},h.hydrateRoot=function(e,t,n){if(!a(e))throw Error(r(299));var i=!1,o="",s=ks,l=Cs,c=Ss,u=null;return null!=n&&(!0===n.unstable_strictMode&&(i=!0),void 0!==n.identifierPrefix&&(o=n.identifierPrefix),void 0!==n.onUncaughtError&&(s=n.onUncaughtError),void 0!==n.onCaughtError&&(l=n.onCaughtError),void 0!==n.onRecoverableError&&(c=n.onRecoverableError),void 0!==n.unstable_transitionCallbacks&&n.unstable_transitionCallbacks,void 0!==n.formState&&(u=n.formState)),(t=em(e,1,!0,t,0,i,o,s,l,c,0,u)).context=tm(null),n=t.current,(o=li(i=Pe(i=Rc()))).callback=null,ci(n,o,i),n=i,t.current.lanes=n,_e(t,n),ju(t),e[Re]=t.current,Hu(e),new Am(t)},h.version="19.1.1",h}()),m.exports),E={exports:{}},$={},_=(N||(N=1,E.exports=function(){if(S)return $;S=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 $.Fragment=t,$.jsx=n,$.jsxs=n,$}()),E.exports);const z=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 T(e={}){const{useContainerQuery:t=!1,containerElement:n=null}=e,[r,a]=l.useState(()=>{const e=t&&n?z.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:z.supportsContainerQueries}}});l.useEffect(()=>{if("undefined"==typeof window)return;const e=()=>{const e=window.innerWidth,r=window.innerHeight,i=t&&n?z.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:z.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 P({tabs:e,active:t,onChange:n}){const{isMobile:r,isTouch:a}=T();return _.jsx("div",{className:"limbo-tabs "+(r?"limbo-tabs--mobile":""),role:"tablist","aria-label":"Opciones de navegación",style:{...r&&{overflowX:"auto",WebkitOverflowScrolling:"touch",scrollbarWidth:"none",msOverflowStyle:"none"}},children:e.map(i=>{const o=t===i.id;return!o&&i.hideNonActive?null:_.jsx("button",{"data-tab-id":i.id,onClick:()=>n(i.id),onKeyDown:t=>((t,r)=>{const a=e.findIndex(e=>e.id===r);let i=a;switch(t.key){case"ArrowLeft":case"ArrowUp":t.preventDefault(),i=a>0?a-1:e.length-1;break;case"ArrowRight":case"ArrowDown":t.preventDefault(),i=a<e.length-1?a+1:0;break;case"Home":t.preventDefault(),i=0;break;case"End":t.preventDefault(),i=e.length-1;break;case"Enter":case" ":return t.preventDefault(),void n(r);default:return}const o=e[i];o&&!o.hideNonActive&&(n(o.id),setTimeout(()=>{const e=document.querySelector(`[data-tab-id="${o.id}"]`);e&&e.focus()},0))})(t,i.id),className:`limbo-tab ${o?"limbo-active":""} ${r?"limbo-tab--mobile":""}`,role:"tab","aria-selected":o,"aria-controls":`tabpanel-${i.id}`,tabIndex:o?0:-1,id:`tab-${i.id}`,style:{...r&&{minWidth:"120px",minHeight:"44px",padding:"12px 16px",flexShrink:0,fontSize:"16px"},...a&&{touchAction:"manipulation",WebkitTapHighlightColor:"transparent"}},children:i.label},i.id)})})}let A={publicKey:null,token:null,authMode:null,tokenEndpoint:null,tokenProvider:null,prod:!1};function M({prod:e=!1}={}){return e?"https://limbo.lefebvre.com":"http://localhost"}async function I({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||A.prod,c=await async function({isFormData:e=!1,useJWT:t=!0,customHeaders:n={}}={}){const r={"Access-Control-Allow-Origin":"*"};e||(r["Content-Type"]="application/json");let a=A.token;if(t){if("jwt"===A.authMode&&A.tokenProvider&&!a)try{console.log("🔑 Calling tokenProvider..."),a=await A.tokenProvider(),console.log("✅ Token obtained from tokenProvider"),A.token=a}catch(e){throw console.error("❌ tokenProvider failed:",e),new Error("Failed to obtain token from tokenProvider: "+e.message)}else if("session"===A.authMode&&!a)try{const e=M(A),t=A.tokenEndpoint||"/auth/token",n=await fetch(`${e}${t}`,{method:"POST",headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":"*"},body:JSON.stringify({public_key:A.publicKey}),credentials:"include"});if(!n.ok)throw new Error(`Session auth failed: ${n.status}`);a=(await n.json()).token,A.token=a}catch(e){throw console.error("❌ Session authentication failed:",e),new Error("Failed to authenticate with session. User must be logged in.")}a?r.Authorization=`Bearer ${a}`:console.warn("⚠️ No JWT token available:",{authMode:A.authMode,hasPublicKey:!!A.publicKey,hasTokenProvider:!!A.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(`${M({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(e){throw new Error(`API Error: ${e.message}`)}}function L(){const e={...A};return e?.prod?"https://limbo.lefebvre.com":"http://localhost"}function O(e){return e?.id?`${L()}/api/assets/${e.id}/download`:null}function R(e){return e?e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/")?`${L()}${e}`:e:null}function D(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:R(e.url),expires_at:e.expires_at,created_at:e.created_at})):[]}function F(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 U="/api";async function q(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&&(D(e.variants)||D(e.image_variants))||[],url:R(e.master_url||e.master?.url_signed||e.urls?.original||e.url)||O(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 I({endpoint:n,method:"GET",basePath:U,useJWT:!0}))}catch(e){throw F(e)}}async function B(e,t=null,n=!1){try{const r=new FormData;return r.append("file",e),t&&r.append("uploaded_by",t),n&&r.append("store_original",n.toString()),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:R(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 I({endpoint:"/assets",method:"POST",body:r,basePath:U,isFormData:!0,useJWT:!0}))}catch(e){throw F(e)}}async function H(e,{variant_name:t,width:n,height:r,crop_params:a,preset_aspect:i=null,preset_size:o=null,output_format:s="webp"}){try{const l=[{name:t,width:n,height:r,output_format:s,crop_params:a}];return i&&(l[0].preset_aspect=i),o&&(l[0].preset_size=o),function(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}))}}}(await I({endpoint:`/assets/${e}/variants`,method:"POST",body:{variants:l,async:!1},basePath:U,useJWT:!0}))}catch(e){throw F(e)}}function W(){const[e,t]=l.useState({}),[n,r]=l.useState({}),[a,i]=l.useState({}),o=l.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 async function(e){try{const n=await I({endpoint:`/assets/${e}/variants`,method:"GET",basePath:U,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:R(e.master_url||e.master?.url_signed||e.urls?.original||e.url)||O(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(e){throw F(e)}var t}(a),n=e?.result||[];return t(e=>({...e,[a]:n})),n}catch(e){return console.error("Error loading variants:",e),i(t=>({...t,[a]:e.message})),[]}finally{r(e=>({...e,[a]:!1}))}}},[e,n]),s=l.useCallback(t=>e[t]||[],[e]),c=l.useCallback(e=>n[e]||!1,[n]),u=l.useCallback(e=>a[e]||null,[a]),d=l.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=l.useCallback(async e=>(d(e),await o(e)),[d,o]),h=l.useCallback(async(e,n)=>{try{return await async function(e,t){try{return await I({endpoint:`/assets/${e}/variants/${t}`,method:"DELETE",basePath:U,useJWT:!0})}catch(e){throw F(e)}}(e,n),t(t=>{const r=t[e]||[];return{...t,[e]:r.filter(e=>e.id!==n)}}),{success:!0}}catch(e){return console.error("Error deleting variant:",e),{success:!1,error:e.message}}},[]);return{loadVariants:o,getVariants:s,isLoading:c,getError:u,clearVariants:d,refreshVariants:m,removeVariant:h}}function V({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:u,getVariants:d,isLoading:m,getError:h,removeVariant:p}=W(),f=window.limboCore?.accessibilityManager,[g,b]=c.useState(null),[y,v]=c.useState(null),x=(window.limboCore?.config?.getGlobal()||{}).interaction||{allowSelection:!1,allowCropping:!0},w=x.allowSelection&&s.select&&r,k=x.allowCropping&&s.crop&&i,C=s.copy,S=s.download,N=s.delete,[j,E]=c.useState(new Set),$=c.useMemo(()=>e?.variants||[],[e?.variants]),z=d(e?.id),T=$.length>0?$:z,P=0===$.length&&m(e?.id),A=0===$.length?h(e?.id):null;return l.useEffect(()=>{!t||!e?.id||e?.variants&&0!==e.variants.length||u(e.id)},[t,e?.id,e?.variants,u]),c.useEffect(()=>{t&&E(new Set)},[t]),t?_.jsx("div",{className:"limbo-modal-overlay",onClick:n,role:"dialog","aria-modal":"true","aria-labelledby":"variants-modal-title",children:_.jsxs("div",{className:"limbo-modal-content limbo-variants-modal",onClick:e=>e.stopPropagation(),children:[_.jsxs("div",{className:"limbo-modal-header",children:[_.jsxs("h2",{id:"variants-modal-title",children:["Recortes de ",e?.filename]}),_.jsx("button",{className:"limbo-modal-close",onClick:n,"aria-label":"Cerrar modal de recortes",children:"✕"})]}),g&&_.jsx("div",{className:`limbo-variants-message limbo-variants-message--${y} mt-1`,role:"alert",style:{padding:"12px 20px",margin:"0 20px 15px 20px",borderRadius:"4px",backgroundColor:"success"===y?"#d4edda":"#f8d7da",color:"success"===y?"#155724":"#721c24",border:"1px solid "+("success"===y?"#c3e6cb":"#f5c6cb")},children:g}),_.jsx("div",{className:"limbo-modal-body",children:P?_.jsxs("div",{className:"limbo-variants-loading",children:[_.jsx("div",{className:"limbo-loader"}),_.jsx("p",{children:"Cargando recortes..."})]}):A?_.jsxs("div",{className:"limbo-variants-error",children:[_.jsxs("p",{children:["Error al cargar recortes: ",A]}),_.jsx("button",{onClick:()=>u(e.id),className:"btn btn-primary",children:"Reintentar"})]}):0===T.length?_.jsxs("div",{className:"limbo-variants-empty",children:[_.jsx("p",{children:"Esta imagen no tiene recortes aún."}),_.jsx("small",{children:"Los recortes aparecerán aquí después de hacer recortes o redimensionados."})]}):_.jsxs(_.Fragment,{children:[_.jsxs("div",{className:"limbo-variant-section",children:[_.jsx("h3",{children:"Imagen original"}),_.jsxs("div",{onClick:()=>{f?.announce(`Abriendo imagen original ${e.filename} en nueva pestaña`),window.open(e.url,"_blank")},className:"limbo-variant-card limbo-variant-original cursor-pointer",children:[_.jsx("div",{className:"limbo-variant-preview",children:_.jsx("img",{src:e.url,alt:e.filename,loading:"lazy"})}),_.jsxs("div",{className:"limbo-variant-info",children:[_.jsx("div",{className:"limbo-variant-name",children:e.filename}),_.jsxs("div",{className:"limbo-variant-meta",children:[_.jsxs("span",{children:[e.width,"×",e.height]}),_.jsxs("span",{children:[Math.round(e.file_size/1024)," KB"]})]})]}),_.jsxs("div",{className:"limbo-variant-actions",children:[w&&_.jsx("button",{className:"btn btn-success btn-sm",onClick:t=>{t.stopPropagation(),r?.(e),n?.()},title:"Seleccionar original",children:"Seleccionar"}),k&&_.jsx("button",{className:"btn btn-crop btn-sm",onClick:t=>{t.stopPropagation(),i&&(f?.announce(`Abriendo herramienta de recorte para ${e.filename}`),i(e),n?.())},title:"Recortar imagen",children:_.jsx("span",{className:"icon icon-scissors-white icon--sm"})}),C&&_.jsx("button",{className:"btn btn-secondary btn-sm",onClick:t=>{t.stopPropagation(),(async()=>{try{await navigator.clipboard.writeText(e.url),f?.announce("URL de imagen original copiada")}catch(e){console.error("Error copying original URL:",e),f?.announceError("Error al copiar URL")}})()},title:"Copiar URL",children:_.jsx("span",{className:"icon icon-copy-white icon--sm"})}),S&&_.jsx("button",{className:"btn btn-primary btn-sm",onClick:t=>{t.stopPropagation(),(async()=>{const{downloadImage:t}=await Promise.resolve().then(()=>Qt);await t(e.url||e.path,e.filename||"limbo-image",{originalFormat:e.format,accessibilityManager:f})})()},title:"Descargar",children:_.jsx("span",{className:"icon icon-download-white icon--sm"})}),N&&a&&_.jsx("button",{className:"btn btn-danger btn-sm",onClick:t=>{t.stopPropagation(),(async()=>{a&&window.confirm(`¿Estás seguro de que deseas eliminar "${e.filename}"? Esta acción también eliminará todos sus recortes.`)&&(f?.announce(`Eliminando imagen ${e.filename}`),await a(e.id),n?.())})()},title:"Eliminar imagen",children:_.jsx("span",{className:"icon icon-close-small-white icon--sm m-[0!important]"})})]})]})]}),_.jsxs("div",{className:"limbo-variant-section",children:[_.jsxs("h3",{children:["Recortes (",T.length,")"]}),_.jsx("div",{className:"limbo-variants-grid",children:T.map(t=>{const a=j.has(t.id);return _.jsxs("div",{className:"limbo-variant-card "+(a?"":"cursor-pointer"),onClick:a?void 0:()=>(e=>{f?.announce(`Abriendo recorte ${e.name} en nueva pestaña`),window.open(e.url,"_blank")})(t),children:[_.jsxs("div",{className:"limbo-variant-preview",children:[_.jsx("img",{src:t.url,alt:t.name||t.filename||`Variante ${t.id}`,loading:"eager",onError:()=>{return e=t.id,void E(t=>new Set([...t,e]));var e},style:{display:a?"none":"block"}}),a&&_.jsx("div",{className:"limbo-variant-error",style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100px",backgroundColor:"#f5f5f5",color:"#666"},children:_.jsx("span",{children:"Error al cargar preview"})})]}),_.jsxs("div",{className:"limbo-variant-info",children:[_.jsx("div",{className:"limbo-variant-name",children:t.name||t.filename||`Variante ${t.id}`}),_.jsxs("div",{className:"limbo-variant-meta",children:[_.jsxs("span",{children:[t.width,"×",t.height]}),_.jsx("span",{children:(t.format||"jpg").toUpperCase()}),_.jsxs("span",{children:[Math.round((t.file_size||0)/1024)," KB"]})]}),t.crop_params&&_.jsxs("div",{className:"limbo-variant-crop-badge",children:[_.jsx("span",{className:"icon icon-scissors icon--xs"})," ","Recortada"]})]}),_.jsxs("div",{className:"limbo-variant-actions",children:[w&&_.jsx("button",{className:"btn btn-success btn-sm",onClick:a=>{a.stopPropagation(),(t=>{const a={id:t.id,filename:`${e.filename}_${t.name}`,url:t.url,width:t.width,height:t.height,mime_type:`image/${t.format}`,file_size:t.file_size,upload_date:t.created_at,processing_status:"completed",is_variant:!0,parent_asset_id:e.id,variant_info:t};f?.announce(`Recorte seleccionado: ${t.name}`),r?.(a),n?.()})(t)},title:`Seleccionar variante ${t.name||t.filename||t.id}`,children:"Seleccionar"}),C&&_.jsx("button",{className:"btn btn-secondary btn-sm",onClick:e=>{e.stopPropagation(),(async e=>{try{await navigator.clipboard.writeText(e.url),f?.announce(`URL de recorte ${e.name} copiada`)}catch(e){console.error("Error copying variant URL:",e),f?.announceError("Error al copiar URL de recorte")}})(t)},title:"Copiar URL",children:_.jsx("span",{className:"icon icon-copy-white icon--sm"})}),S&&_.jsx("button",{className:"btn btn-primary btn-sm",onClick:e=>{e.stopPropagation(),(async e=>{const{downloadImage:t}=await Promise.resolve().then(()=>Qt);await t(e.url,e.name||"limbo-variant",{originalFormat:e.format||e.output_format,accessibilityManager:f})})(t)},title:"Descargar",children:_.jsx("span",{className:"icon icon-download-white icon--sm"})}),N&&_.jsx("button",{className:"btn btn-danger btn-sm",onClick:n=>{n.stopPropagation(),(async t=>{if(window.confirm(`¿Estás seguro de que deseas eliminar el recorte "${t.name||t.filename}"?`)){f?.announce(`Eliminando recorte ${t.name||t.filename}`);const n=await p(e.id,t.id);n.success?(b("Recorte eliminado correctamente"),v("success"),f?.announce("Recorte eliminado correctamente"),o?.(),setTimeout(()=>{b(null),v(null)},3e3)):(b(`Error al eliminar recorte: ${n.error}`),v("error"),f?.announceError(`Error al eliminar recorte: ${n.error}`),setTimeout(()=>{b(null),v(null)},5e3))}})(t)},title:"Eliminar variante",children:_.jsx("span",{className:"icon icon-close-small-white icon--sm m-[0!important]"})})]})]},t.id)})})]})]})})]})}):null}function K({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,u]=l.useState(!1),[d,m]=l.useState(!1),[h,p]=l.useState(e.variants_count||0),{isMobile:f,isTouch:g}=T(),b=window.limboCore?.accessibilityManager,y=(window.limboCore?.config?.getGlobal()||{}).interaction||{allowSelection:!1,allowCropping:!0},v=n=>{n.stopPropagation(),b?.announce(`Eliminando imagen ${e.filename}`,"assertive"),t?.(e)},x=async t=>{t.stopPropagation();let n=e.url||e.path;try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(n);else{const e=document.createElement("textarea");e.value=n,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),document.body.removeChild(e)}u(!0),b?.announce(`URL de ${e.filename} copiada al portapapeles. Nota: La URL puede tener un tiempo de validez limitado.`),setTimeout(()=>u(!1),2e3)}catch(t){console.error("Error al copiar URL:",t),b?.announce(`Error al copiar URL de ${e.filename}. Inténtalo de nuevo.`),alert(`Error al copiar URL de ${e.filename}. Por favor, inténtalo de nuevo.`)}},w=async t=>{t.preventDefault(),t.stopPropagation();const{downloadImage:n}=await Promise.resolve().then(()=>Qt);await n(e.url||e.path,e.filename||"limbo-image",{originalFormat:e.format,accessibilityManager:b})},k=t=>{t.stopPropagation(),b?.announce(`Editando imagen ${e.filename}`),n?.(e)},C=e.variants&&e.variants.length>0||h>0,S=h,N=c.useCallback(()=>{p(e=>Math.max(0,e-1))},[]);c.useEffect(()=>{p(e.variants_count||0)},[e.variants_count]);const j=t=>{t.stopPropagation(),b?.announce(`Mostrando recortes de ${e.filename}`),m(!0)},E=y.allowSelection&&o.select&&r,$=y.allowCropping&&o.crop&&n,z=C&&!1!==o.variants,P=()=>{window.open(e.url||e.path,"_blank")};return _.jsxs(_.Fragment,{children:[_.jsxs("div",{className:`limbo-image-card flex flex-col items-center cursor-pointer relative transition ${i?"opacity-50":""} ${f?"limbo-image-card--mobile":""}`,onClick:P,onKeyDown:e=>{switch(e.key){case"Enter":case" ":e.preventDefault(),P();break;case"d":case"D":o.download&&(e.preventDefault(),w(e));break;case"c":case"C":o.copy&&(e.preventDefault(),x(e));break;case"Delete":case"Backspace":o.delete&&t&&(e.preventDefault(),v(e));break;case"x":case"X":o.crop&&n&&(e.preventDefault(),k(e));break;case"v":case"V":o.variants&&(e.preventDefault(),j(e))}},title:f?"Toque para ver imagen":"Haga click en la imagen para ver preview en nueva pestaña",role:"button",tabIndex:0,"aria-label":`Imagen ${e.filename}. ${e.width}x${e.height} px`,style:{...g&&{touchAction:"manipulation",WebkitTapHighlightColor:"transparent"}},children:[_.jsxs("div",{className:"limbo-image-actions "+(f?"limbo-image-actions--mobile":""),children:[z&&_.jsxs("button",{type:"button",title:`Ver ${S} recorte${1!==S?"s":""}`,className:"btn btn-variants border border-brand-blue-050/50 "+(f?"btn--touch":""),onClick:j,tabIndex:-1,style:{...f&&{width:"40px",height:"40px"},position:"relative"},children:[_.jsx("span",{className:"icon icon-album-menu-white icon--sm","aria-hidden":"true"}),S>0&&_.jsx("span",{className:"limbo-variants-count-badge",style:{position:"absolute",top:"-8px",right:"-8px",background:"#dc2626",color:"white",borderRadius:"50%",minWidth:"20px",height:"20px",fontSize:"12px",fontWeight:"700",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:"1",border:"2px solid white",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.4)",zIndex:"999"},children:S})]}),E&&_.jsx("button",{type:"button",title:"Seleccionar imagen",className:"btn btn-success border border-brand-blue-050/50 "+(f?"btn--touch":""),onClick:t=>{t.stopPropagation(),b?.announce(`Seleccionando ${e.filename} para el portal`),r?.(e)},tabIndex:-1,style:{...f&&{width:"40px",height:"40px"}},children:_.jsx("span",{className:"icon icon-tick-white icon--sm","aria-hidden":"true"})}),$&&_.jsx("button",{type:"button",title:"Editar imagen",className:"btn btn-crop border border-brand-blue-050/50 "+(f?"btn--touch":""),onClick:k,tabIndex:-1,style:{...f&&{width:"40px",height:"40px"}},children:_.jsx("span",{className:"icon icon-scissors-white icon--sm","aria-hidden":"true"})}),o.copy&&_.jsx("button",{type:"button",title:s?"¡Copiado!":"Copiar URL",className:"btn btn-copy border border-brand-blue-050/50 "+(f?"btn--touch":""),onClick:x,tabIndex:-1,style:{...f&&{width:"40px",height:"40px"}},children:_.jsx("span",{className:`icon ${s?"icon-copied-white":"icon-copy-white"} icon--sm`,"aria-hidden":"true"})}),o.download&&_.jsx("button",{type:"button",title:"Descargar",className:"btn btn-download border border-brand-blue-050/50 "+(f?"btn--touch":""),onClick:w,tabIndex:-1,style:{...f&&{width:"40px",height:"40px"}},children:_.jsx("span",{className:"icon icon-download-white icon--sm","aria-hidden":"true"})}),o.delete&&t&&_.jsx("button",{onClick:v,disabled:i,className:"btn btn-delete border border-brand-blue-050/50 "+(f?"btn--touch":""),title:"Eliminar imagen",tabIndex:-1,style:{...f&&{width:"40px",height:"40px"}},children:i?"…":_.jsx("span",{className:"icon icon-close-small-white icon--sm","aria-hidden":"true"})})]}),_.jsx("img",{src:e.url||e.path,loading:"eager",alt:e.filename.split(".")[0]??e.filename,className:"w-full object-cover rounded aspect-square",sizes:`height: ${6*a}px,width: ${6*a}px`,draggable:!1,style:{...f&&{minHeight:`${Math.max(3*a,80)}px`,height:"auto",aspectRatio:"1 / 1",objectFit:"cover"}}}),_.jsx("span",{className:"text-xs mt-1 limbo-truncate w-full text-center limbo-image-card-name "+(f?"limbo-image-card-name--mobile":""),style:{...f&&{fontSize:"0.75rem",lineHeight:"1.2",maxWidth:"100%",padding:"2px 4px",backgroundColor:"rgba(255, 255, 255, 0.9)",borderRadius:"4px",color:"#333",fontWeight:"500"}},children:e.filename.split(".")[0]??e.filename})]}),_.jsx(V,{image:e,isOpen:d,onClose:()=>m(!1),onSelect:r,onDelete:t,onCrop:n,onVariantDeleted:N,allowedActions:{select:o.select,download:o.download,copy:o.copy,delete:o.delete,crop:o.crop}})]})}function G(){return _.jsxs("div",{className:"limbo-image-card animate-pulse",role:"status","aria-label":"Cargando imagen...",children:[_.jsx("div",{className:"w-full aspect-square bg-neutral-gray-200 rounded-md flex items-center justify-center",children:_.jsx("svg",{className:"w-12 h-12 text-neutral-gray-300",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:_.jsx("path",{fillRule:"evenodd",d:"M4 3a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V5a2 2 0 00-2-2H4zm12 12H4l4-8 3 6 2-4 3 6z",clipRule:"evenodd"})})}),_.jsx("div",{className:"limbo-image-card-name opacity-100 position-relative bottom-0 p-2",children:_.jsx("div",{className:"h-4 bg-neutral-gray-200 rounded w-3/4"})}),_.jsx("span",{className:"sr-only",children:"Cargando imagen..."})]})}function Q({text:e="Cargando..."}){return _.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-gray-600",role:"status","aria-live":"polite","aria-label":e,children:[_.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:[_.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),_.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8H4z"})]}),_.jsx("p",{className:"text-sm",id:"loader-text",children:e})]})}function Y({onSelect:e,onCrop:t,onDelete:n,deletingId:r,images:a,loading:i,error:o,filters:s={name:"",dateFrom:"",dateTo:"",uploadedBy:""},onFiltersChange:c,filterConfig:u={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!==u.showNameFilter,p=!0===u.showUploadedByFilter,f=!1!==u.showDateFilter,g=l.useRef(null),b=window.limboCore?.accessibilityManager;l.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]),l.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;c&&c({...s,[t]:n})};return _.jsxs("div",{className:"w-full px-4 py-4",children:[_.jsx("div",{className:"p-2 mb-2",children:_.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&&_.jsxs("div",{className:"flex flex-col w-full sm:min-w-[180px] sm:flex-1",children:[_.jsx("label",{htmlFor:"name",className:"limbo-form-label mb-1",children:"Nombre"}),_.jsx("input",{type:"text",name:"name",id:"name",placeholder:"Buscar por nombre...",value:s.name,onChange:y,className:"limbo-form-control",autoComplete:"off"})]}),_.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&&_.jsxs(_.Fragment,{children:[_.jsxs("div",{className:"flex flex-col w-full sm:w-auto",children:[_.jsx("label",{htmlFor:"dateFrom",className:"limbo-form-label mb-1",children:"Desde"}),_.jsx("input",{type:"date",name:"dateFrom",id:"dateFrom",value:s.dateFrom,onChange:y,className:"limbo-form-control"})]}),_.jsxs("div",{className:"flex flex-col w-full sm:w-auto",children:[_.jsx("label",{htmlFor:"dateTo",className:"limbo-form-label mb-1",children:"Hasta"}),_.jsx("input",{type:"date",name:"dateTo",id:"dateTo",value:s.dateTo,onChange:y,className:"limbo-form-control"})]})]}),p&&_.jsxs("div",{className:"flex flex-col w-full sm:w-auto",children:[_.jsx("label",{htmlFor:"uploadedBy",className:"limbo-form-label mb-1",children:"Subido por"}),_.jsx("input",{type:"text",name:"uploadedBy",id:"uploadedBy",placeholder:"Subido por",value:s.uploadedBy,onChange:y,className:"limbo-form-control"})]})]})]})}),i?d.showPlaceholders?_.jsx("div",{ref:g,className:"limbo-gallery","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)=>_.jsx("div",{role:"gridcell","aria-posinset":t+1,"aria-setsize":d.placeholderCount,children:_.jsx(G,{})},`skeleton-${t}`))}):d.showSpinner?_.jsx(Q,{text:"Cargando imágenes..."}):null:o?_.jsx("div",{className:"alert alert-danger text-center",children:o}):_.jsx("div",{ref:g,className:"limbo-gallery","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)=>_.jsx("div",{role:"gridcell","aria-posinset":o+1,"aria-setsize":a.length,children:_.jsx(K,{image:i,onSelect:e,onCrop:t,onDelete:m.delete&&n?()=>n(i.id):null,thumbnailSize:32,isDeleting:r===i.id,allowedActions:m})},i.id)):_.jsx("div",{className:"col-span-full text-center text-gray-500 py-8",role:"status","aria-live":"polite",children:_.jsx("p",{children:"No se han encontrado imágenes"})})})]})}function X({image:e,onDiscard:t,onRetry:n,onDownload:r,onSelect:a,showRetry:i=!1,disabled:o=!1}){const[s,c]=l.useState(null),[u,d]=l.useState({name:"",size:"",type:""}),[m,h]=l.useState(!1);l.useEffect(()=>{if(!e)return void c(null);const t=URL.createObjectURL(e);return c(t),d({name:e.name||"imagen.webp",size:p(e.size||0),type:e.type||"image/webp"}),()=>{URL.revokeObjectURL(t)}},[e]),l.useEffect(()=>{if(!m)return;const e=e=>{"Escape"===e.key&&h(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[m]);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?_.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:[_.jsxs("div",{className:"flex items-center justify-between mb-4 px-1",children:[_.jsx("h3",{className:"text-sm font-medium text-gray-700",children:"Vista previa de imagen"}),_.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:_.jsx("span",{className:"icon icon-close-small icon--md"})})]}),_.jsxs("div",{className:"flex flex-col justify-center md:flex-row gap-2 md:gap-6",children:[_.jsxs("div",{className:"flex-1 md:flex-[0.4] flex flex-col items-center justify-center",children:[_.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:[_.jsx("img",{src:s,alt:"Vista previa",className:"absolute inset-0 w-full h-full object-contain"}),_.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:[_.jsx("span",{className:"icon icon-search-white icon--xs"}),_.jsx("span",{className:"hidden sm:inline",children:"Ampliar"})]})]}),_.jsx("div",{className:"mt-3 text-center space-y-1 w-full",children:_.jsxs("div",{className:"rounded-sm w-fit gap-0.5 p-0.5 min-w-fit mx-auto",children:[_.jsxs("label",{htmlFor:"uploadImageId",className:"flex items-center w-fit",children:[_.jsx("div",{className:"rounded-full bg-brand-blue-1000 min-w-6 min-h-6 flex items-center align-middle content-center justify-center limbo-me-1",children:_.jsx("span",{className:"icon icon-edit-white icon--sm"})}),_.jsx("input",{id:"uploadImageId",onChange:e=>(e=>{const t=e.target.value,n=u.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:u.name.split(".")[0],title:"Renombra la imagen a tu gusto"})]}),_.jsxs("div",{className:"flex items-center justify-center gap-3 text-xs text-gray-500",children:[_.jsx("span",{children:u.size}),_.jsx("span",{children:"•"}),_.jsx("span",{children:u.type.split("/")[1]?.toUpperCase()||"IMAGE"})]})]})})]}),_.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&&_.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:[_.jsx("span",{className:"icon icon-refresh icon--sm"}),_.jsx("span",{className:"hidden sm:inline",children:"Reintentar"}),_.jsx("span",{className:"sm:hidden",children:"Retry"})]}),_.jsxs("button",{type:"button",onClick:()=>{if(!s||o)return;const e=document.createElement("a");e.href=s,e.download=u.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:[_.jsx("span",{className:"icon icon-download icon--sm"}),_.jsx("span",{children:"Descargar"})]}),_.jsxs("button",{type:"button",onClick:()=>a&&a(u.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:[_.jsx("span",{className:"icon icon-tick-white icon--sm"}),_.jsx("span",{children:"Seleccionar"})]})]})]}),m&&_.jsxs("div",{className:"fixed inset-0 bg-black/90 z-[10000] flex items-center justify-center p-4",onClick:()=>h(!1),role:"dialog","aria-modal":"true","aria-label":"Vista de imagen en tamaño completo",children:[_.jsx("button",{onClick:()=>h(!1),className:"absolute top-4 right-4 p-2 bg-white/10 hover:bg-white/20 rounded-full transition-colors cursor-pointer z-10","aria-label":"Cerrar vista ampliada",title:"Cerrar (Esc)",children:_.jsx("span",{className:"icon icon-close-small-white icon--lg"})}),_.jsxs("div",{className:"absolute top-4 left-4 bg-black/50 text-white px-4 py-2 rounded-lg text-sm",children:[_.jsx("p",{className:"font-medium",children:u.name}),_.jsxs("p",{className:"text-xs text-gray-300 mt-1",children:[u.size," • ",u.type.split("/")[1]?.toUpperCase()]})]}),_.jsx("div",{className:"relative max-w-7xl max-h-[90vh] w-full h-full flex items-center justify-center",onClick:e=>e.stopPropagation(),children:_.jsx("img",{src:s,alt:"Vista completa",className:"max-w-full max-h-full object-contain rounded-lg shadow-2xl"})}),_.jsx("div",{className:"absolute bottom-4 left-1/2 limbo--translate-x-1/2 bg-black/50 text-white px-4 py-2 rounded-lg text-xs text-center",children:"Click fuera de la imagen o presiona ESC para cerrar"})]})]}):null}function J({file:e,setFile:t,previewUrl:n,setPreviewUrl:r,fileInputRef:a,onSelect:i,disabled:o}){return _.jsxs("div",{className:"flex flex-col items-center gap-6","aria-label":"Subir imagen desde dispositivo",children:[_.jsxs("label",{htmlFor:"file-input",className:"w-fit md:w-full flex flex-col items-center justify-center border-2 border-dashed border-brand-blue-200 rounded-xl p-8 cursor-pointer hover:border-brand-blue-1000 hover:to-bright-blue-200 hover:from-brand-blue-050 focus-within:border-brand-blue-800 from-bright-blue-050 to-brand-blue-050 bg-linear-to-br transition",tabIndex:0,style:{outline:"none"},children:[_.jsx("span",{className:"icon icon-upload icon--lg mb-2","aria-hidden":"true"}),_.jsx("span",{className:"font-medium text-brand-blue-1000 mb-1",children:"Haz clic o arrastra una imagen aquí"}),_.jsx("span",{className:"text-sm text-neutral-700",children:"Formatos permitidos: JPG, PNG, GIF, SVG, WebP"}),_.jsx("input",{id:"file-input",ref:a,type:"file",accept:"image/jpeg,image/png,image/svg,image/webp,image/gif",onChange:e=>{const n=e.target.files[0];if(t(n),n){const e=URL.createObjectURL(n);r(e)}else r(null)},disabled:o,className:"sr-only","aria-label":"Seleccionar imagen"})]}),e&&_.jsx(X,{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 Z="/api",ee=new Map;const te=new Map;function ne(e=!1){const[t,n]=l.useState(null),[r,a]=l.useState(!1),[i,o]=l.useState(null);return{params:t,loading:r,error:i,fetchParams:async t=>{a(!0),o(null);const r=`${e}-${t}`,i=Date.now(),s=te.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),I({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),te.set(r,{data:o,timestamp:i}),o}catch(e){return o(e.message),n(null),null}finally{a(!1)}},reset:()=>{o(null),n(null)}}}function re({show:e=!1,message:t="Cargando...",className:n=""}){return e?_.jsx("div",{className:`absolute inset-0 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:_.jsxs("div",{className:"flex flex-col items-center gap-4",children:[_.jsxs("div",{className:"relative w-16 h-16",children:[_.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-200 rounded-full"}),_.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-600 rounded-full border-t-transparent animate-spin"})]}),_.jsx("p",{className:"text-brand-blue-900 font-medium text-lg",children:t})]})}):null}function ae({prod:e,disabled:t,onSelect:n}){const r=function(e=!1){const[t,n]=l.useState([]),[r,a]=l.useState(!0),[i,o]=l.useState(null);return l.useEffect(()=>{const t=`ai-services-${e}`,r=ee.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 I({endpoint:"/ai/services",prod:e,basePath:Z})}(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})):Object.entries(a).map(([e,t])=>({label:e,slug:t,type:"image_generation",description:null,image:null}));n(o),ee.set(t,{data:o,timestamp:i})}catch(e){s&&o(e.message)}finally{s&&a(!1)}})(),()=>{s=!1}},[e]),{services:t,loading:r,error:i,invalidateCache:()=>{ee.delete(`ai-services-${e}`)}}}(e),a=ne(e),[i,o]=l.useState(""),[s,u]=l.useState(""),[d,m]=l.useState({}),[h,p]=l.useState(!1),[f,g]=l.useState(null),[b,y]=l.useState(null),[v,x]=l.useState(null),[w,k]=l.useState(!0),[C,S]=l.useState(!1);c.useEffect(()=>{if(!r.loading&&1===r.services.length){const e=r.services[0];u(e.slug),k(!1),a.fetchParams(e.slug,!0)}},[r.loading,r.services]),c.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 N=e=>{const{name:t,value:n}=e.target;m(e=>({...e,[t]:n}))},j=async(t,n=!1)=>{t.preventDefault(),p(!0),g(null),y(null);try{n?d.prompt=i:o(d.prompt||"");const t=await function(e,t=!1){return I({endpoint:"/ai/generate",method:"POST",body:e,prod:t,basePath:Z})}(d,e);let r=null;if(t?.data?.images&&Array.isArray(t.data.images)&&t.data.images.length>0?r=t.data.images[0]:t?.result?.images&&Array.isArray(t.result.images)&&t.result.images.length>0?r=t.result.images[0]:Array.isArray(t)&&t.length>0?r=t[0]:"string"==typeof t&&(r=t),!r)throw new Error("No se pudo extraer la imagen de la respuesta");if(r.startsWith("http"))try{const e=`${window.limboCore?.config?.getGlobal()?.prod?"https://limbo.lefebvre.com":"http://localhost"}/api/atenea/proxy?url=${encodeURIComponent(r)}`,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(),a=new File([n],"ai-image.webp",{type:n.type||"image/webp"});x(a)}catch(e){throw new Error(`Error downloading image via proxy: ${e.message}`)}else{const e=r.replace(/^data:image\/\w+;base64,/,""),t=atob(e),n=new Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);const a=new Uint8Array(n),i=new File([a],"ai-image.webp",{type:"image/webp"});x(i)}y(t?.data?.images||t?.result?.images||null)}catch(e){g(e.message||"Error al generar la imagen")}finally{p(!1)}};return r.loading?_.jsxs("div",{className:"flex items-center justify-center py-8",children:[_.jsx("span",{className:"limbo-loader mr-2"})," Cargando servicios IA..."]}):r.services.length?_.jsx("div",{className:"flex flex-col mx-4 pb-2",children:w?_.jsxs(_.Fragment,{children:[_.jsx("h3",{id:"aiSelectDescription",className:"text-2xl font-semibold text-brand-blue-1000",children:"Selecciona el modelo IA"}),r.error&&_.jsx("div",{className:"alert alert-danger",children:r.error}),_.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=>_.jsxs("button",{type:"button",onClick:()=>{u(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-[120px] grow-1 basis-sm min-w-70 border-gray-200 hover:border-brand-blue-300 hover:shadow-md ${r.loading||t?"opacity-50 cursor-not-allowed":"cursor-pointer"} `,style:{position:"relative"},children:[e.image&&_.jsx("div",{className:"absolute inset-0 bg-cover bg-center transition-opacity duration-200 group-hover:opacity-20",style:{backgroundImage:`url(${e.image})`,opacity:.1}}),_.jsxs("div",{className:"relative z-10 flex flex-col items-center justify-center gap-2 text-center",children:[_.jsx("span",{className:"text-base font-semibold text-gray-800",children:e.label}),e.description&&_.jsx("span",{className:"text-xs text-neutral-gray-800 limbo-line-clamp-2 drop-shadow drop-shadow-neutral-white-000",children:e.description})]})]},e.slug))})]}):_.jsxs(_.Fragment,{children:[_.jsx("h3",{className:"text-2xl font-semibold text-brand-blue-1000",children:r.services.find(e=>e.slug===s)?.label||"Generación IA"}),a.loading&&_.jsx("div",{children:"Cargando parámetros..."}),a.error&&_.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")),l=(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 _.jsxs("div",{className:"flex flex-col gap-1",children:[_.jsxs("label",{htmlFor:`ai-${e}`,className:"text-xs font-medium text-brand-blue-900",children:[n.label||e,n.required&&_.jsx("span",{className:"text-red-600 ml-1",children:"*"})]}),n.options?_.jsx("select",{id:`ai-${e}`,name:e,value:d[e]??"",onChange:N,className:"limbo-input",disabled:t,title:n.label||e,children:n.options.map(e=>_.jsx("option",{value:e,children:e},e))}):a?_.jsx("textarea",{id:`ai-${e}`,name:e,value:d[e]??"",onChange:N,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`}}):_.jsx("input",{id:`ai-${e}`,type:"integer"===n.type?"number":"text",name:e,value:d[e]??"",onChange:N,className:"limbo-input",disabled:t,required:n.required,min:n.minValue,max:n.maxValue,placeholder:r,title:n.label||e})]},e)};return _.jsxs("div",{className:"h-fit w-full",children:[r.services.length>1&&_.jsxs("button",{type:"button",onClick:()=>{k(!0),u(""),m({}),y(null),g(null),x(null)},className:"flex cursor-pointer items-center gap-2 text-brand-blue-600 hover:text-brand-blue-700 mb-4 font-medium",children:[_.jsx("span",{className:"icon icon-arrow-left"}),"Volver al menú de servicios"]}),_.jsxs("div",{className:"relative",children:[_.jsxs("form",{onSubmit:j,"data-type":"ai",className:"flex flex-col gap-3 mt-4 border-t-1 pt-4 border-brand-blue-200","aria-label":"Formulario generación IA",children:[_.jsx("div",{className:"flex flex-col gap-3",children:i.map(([e,t])=>l(e,t))}),o.length>0&&_.jsxs("div",{className:"border-t border-gray-200 pt-3",children:[_.jsxs("button",{type:"button",onClick:()=>S(!C),className:"flex items-center gap-2 text-sm font-medium text-brand-blue-700 hover:text-brand-blue-900 mb-3 transition-colors",children:[_.jsx("svg",{className:"w-4 h-4 transition-transform "+(C?"rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:_.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"Opciones avanzadas",!C&&_.jsxs("span",{className:"text-xs text-gray-500",children:["(",o.length," opciones)"]})]}),C&&_.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3 animate-fadeIn",children:o.map(([e,t])=>l(e,t))})]}),_.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"})]}),_.jsx(re,{show:h,message:"Generando imagen con IA..."})]})]})})(),f&&_.jsx("div",{className:"alert alert-danger mt-4",children:f}),v&&_.jsx("div",{className:"mt-6 md:w-full mx-auto",children:_.jsx(X,{image:v,onDiscard:()=>{x(null),y(null),g(null)},onRetry:e=>j(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})})]})}):_.jsx("div",{className:"alert alert-warning",children:"No hay servicios IA disponibles."})}const ie="/api",oe=new Map;function se({prod:e,disabled:t,onSelect:n}){const r=c.useRef(null),a=function(e=!1){const[t,n]=l.useState([]),[r,a]=l.useState(!0),[i,o]=l.useState(null);return l.useEffect(()=>{const t=`stock-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 I({endpoint:"/stock/services",prod:e,basePath:ie})}(e);if(!s)return;if(204===r?.httpCode||null===r?.data)return n([]),o("No hay servicios de stock disponibles en este momento"),void oe.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),oe.set(t,{data:l,timestamp:i})}catch(e){s&&o(e.message)}finally{s&&a(!1)}})(),()=>{s=!1}},[e]),{services:t,loading:r,error:i,invalidateCache:()=>{oe.delete(`stock-services-${e}`)}}}(e),i=(e,t)=>{try{const n=sessionStorage.getItem(`limbo_stock_${e}`);return n?JSON.parse(n):t}catch{return t}},[o,s]=l.useState(()=>i("selectedService","")),[u,d]=l.useState(()=>i("dynamicForm",{})),[m,h]=l.useState(()=>i("stockImages",[])),[p,f]=l.useState(()=>i("currentPage",1)),[g,b]=l.useState(()=>i("paginationInfo",null)),[y,v]=l.useState(null),x=ne(e),[w,k]=l.useState(!1),[C,S]=l.useState(null),[N,j]=l.useState(null),[E,$]=l.useState(!0),[z,T]=l.useState(!1),[P,A]=l.useState(null);c.useEffect(()=>{sessionStorage.setItem("limbo_stock_selectedService",JSON.stringify(o))},[o]),c.useEffect(()=>{sessionStorage.setItem("limbo_stock_dynamicForm",JSON.stringify(u))},[u]),c.useEffect(()=>{sessionStorage.setItem("limbo_stock_stockImages",JSON.stringify(m))},[m]),c.useEffect(()=>{sessionStorage.setItem("limbo_stock_currentPage",JSON.stringify(p))},[p]),c.useEffect(()=>{sessionStorage.setItem("limbo_stock_paginationInfo",JSON.stringify(g))},[g]),c.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]),c.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,d(t)}},[o,x.params]);const M=e=>{const{name:t,value:n}=e.target;d(e=>({...e,[t]:n}))},L=async(t=1)=>{k(!0),S(null),1===t&&h([]);try{let n;if(1===t){const e=x.params?.[o]?.parameters,a={...u};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 I({endpoint:"/stock/search",method:"POST",body:e,prod:t,basePath:ie})}(n,e),i=a?.data?.images||[];let s=a?.data?.pagination||null,l=null;s&&(l={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(O(Array.isArray(i)?i:[])),b(l),f(l?.current_page||t)}catch(e){S(e.message||"Error al buscar imágenes")}finally{k(!1)}},O=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},R=async e=>{e.preventDefault();const t=u.query||u.search||u.term||"";t.trim().length<5?S("La búsqueda debe tener al menos 5 caracteres"):(v(t),await L(1))},D=e=>{e<1||L(e)},F=async t=>{j(t.id),S(null);try{const n={service:o,image_id:t.id},r=await function(e,t=!1){return I({endpoint:"/stock/download",method:"POST",body:e,prod:t,basePath:ie})}(n,e);if(!r?.result?.url&&!r?.result?.download_url)throw new Error("No se pudo obtener la URL de descarga");{const e=r.result.url||r.result.download_url,n=await fetch(e),a=await n.blob(),i=r.result.filename||`stock-${t.id}.jpg`,o=new File([a],i,{type:a.type||"image/jpeg"});A(o)}}catch(e){S(e.message||"No se pudo recuperar la imagen seleccionada")}finally{j(null)}};return a.loading?_.jsxs("div",{className:"flex items-center justify-center py-8",children:[_.jsx("span",{className:"limbo-loader mr-2"})," Cargando servicios de Stock..."]}):a.services.length?_.jsx("div",{className:"flex flex-col mx-4 pb-2",children:E?_.jsxs(_.Fragment,{children:[_.jsx("h3",{className:"text-2xl font-semibold text-brand-blue-1000",children:"Selecciona el servicio de Stock"}),a.error&&_.jsx("div",{className:"alert alert-danger",children:a.error}),_.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:a.services.map(e=>_.jsxs("button",{type:"button",onClick:()=>{s(e.slug),$(!1),d({}),h([]),f(1),b(null),S(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-[120px] 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&&_.jsx("div",{className:"absolute inset-0 bg-cover bg-center transition-opacity duration-200 group-hover:opacity-20",style:{backgroundImage:`url(${e.image})`,opacity:.1}}),_.jsxs("div",{className:"relative z-10 flex flex-col items-center justify-center gap-2 text-center",children:[_.jsx("span",{className:"text-base font-semibold text-gray-800",children:e.label}),e.description&&_.jsx("span",{className:"text-xs text-gray-600 limbo-line-clamp-2",children:e.description})]})]},e.slug))})]}):_.jsxs(_.Fragment,{children:[_.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&&_.jsx("div",{children:"Cargando parámetros..."}),x.error&&_.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")),l=(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 _.jsxs("div",{className:"flex flex-col gap-1",children:[_.jsxs("label",{htmlFor:`stock-${e}`,className:"text-xs font-medium text-brand-blue-900",children:[n.label||e,n.required&&_.jsx("span",{className:"text-red-600 ml-1",children:"*"})]}),n.options&&n.multiple?_.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=>_.jsxs("label",{className:"flex items-center gap-1",children:[_.jsx("input",{type:"checkbox",name:`stock-${e}`,value:n,checked:Array.isArray(u[e])&&u[e].includes(n),onChange:()=>((e,t)=>{d(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}),_.jsx("span",{className:"text-xs",children:n})]},n))}):n.options?_.jsx("select",{id:`stock-${e}`,name:e,value:u[e]??"",onChange:M,className:"limbo-input",disabled:t,title:n.label||e,children:n.options.map(e=>_.jsx("option",{value:e,children:e},e))}):a?_.jsx("textarea",{id:`stock-${e}`,name:e,value:u[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`}}):_.jsx("input",{id:`stock-${e}`,type:"integer"===n.type?"number":"text",name:e,value:u[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 _.jsxs("div",{children:[a.services.length>1&&_.jsxs("button",{type:"button",onClick:()=>{$(!0),s(""),d({}),h([]),f(1),b(null),S(null)},className:"flex cursor-pointer items-center gap-2 text-brand-blue-600 hover:text-brand-blue-700 mb-4 font-medium",children:[_.jsx("span",{className:"icon icon-arrow-left"}),"Volver al menú de servicios"]}),_.jsxs("div",{className:"relative",children:[_.jsxs("form",{onSubmit:R,"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:[_.jsx("div",{className:"flex flex-col gap-3",children:r.map(([e,t])=>l(e,t))}),i.length>0&&_.jsxs("div",{className:"border-t border-gray-200 pt-3",children:[_.jsxs("button",{type:"button",onClick:()=>T(!z),className:"flex items-center gap-2 text-sm font-medium text-brand-blue-700 hover:text-brand-blue-900 mb-3 transition-colors",children:[_.jsx("svg",{className:"w-4 h-4 transition-transform "+(z?"rotate-90":""),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:_.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"Opciones avanzadas",!z&&_.jsxs("span",{className:"text-xs text-gray-500",children:["(",i.length," opciones)"]})]}),z&&_.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 animate-fadeIn",children:i.map(([e,t])=>l(e,t))})]}),_.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"})]}),_.jsx(re,{show:w&&!m.length,message:"Buscando imágenes..."})]})]})})(),C&&_.jsx("div",{className:"alert alert-danger mt-4",children:C}),P&&_.jsx("div",{className:"mt-6 md:w-full mx-auto",children:_.jsx(X,{image:P,onDiscard:()=>{A(null),S(null)},onDownload:()=>{},onSelect:e=>{if(n)if(e&&P&&e!==P.name){const t=new File([P],e,{type:P.type});n(t)}else n(P)},showRetry:!1,disabled:t})}),!P&&m.length>0&&_.jsxs(_.Fragment,{children:[_.jsxs("div",{className:"mt-6 grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-1 relative","aria-live":"polite",children:[_.jsx(re,{show:w,message:"Cargando imágenes..."}),m.map((e,n)=>_.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:()=>!N&&!w&&!t&&F(e),children:_.jsxs("div",{className:"relative aspect-video bg-neutral-100",children:[_.jsx("img",{src:e.preview||e.thumbnail||e.url,alt:e.title||`Resultado ${n+1}`,className:"object-cover w-full h-full",loading:"lazy"}),N===e.id?_.jsxs("div",{className:"absolute inset-0 bg-white/90 flex flex-col items-center justify-center gap-2",children:[_.jsxs("div",{className:"relative w-10 h-10",children:[_.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-200 rounded-full"}),_.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-600 rounded-full border-t-transparent animate-spin"})]}),_.jsx("span",{className:"text-sm font-medium text-brand-blue-900",children:"Descargando..."})]}):_.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:[_.jsx("span",{className:"icon icon-round-check-filled icon--2xl max-w-full max-h-full opacity-0 group-hover:opacity-100 transition-opacity duration-200"}),_.jsx("span",{style:{textShadow:"1px 0 #0d542b, -1px 0 #0d542b, 0 1px #0d542b, 0 -0.5px #0d542b, 0.5px 0.5px #0d542b, -1px -1px #0d542b, 1px -1px #0d542b, -1px 1px #0d542b"},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&&_.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2",children:[_.jsxs("button",{onClick:()=>D(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:[_.jsx("span",{className:"icon icon-arrow-left-white icon--sm"})," ","Anterior"]}),_.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)),_.jsxs("span",{className:"text-xs text-neutral-500 block",children:["(",g.total," imágenes totales)"]})]}),_.jsxs("button",{onClick:()=>D(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"," ",_.jsx("span",{className:"icon icon-arrow-right-white icon--sm"})]})]})]}),!w&&0===m.length&&o&&y&&_.jsxs("div",{className:"mt-6 text-center text-neutral-600 py-8 bg-neutral-50 rounded-lg",children:[_.jsx("span",{className:"icon icon-search icon--lg mb-2"}),_.jsxs("p",{children:['No se encontraron imágenes para "',u.query,'"']}),_.jsx("p",{className:"text-sm mt-1",children:"Intenta con otros términos de búsqueda"})]})]})}):_.jsx("div",{className:"alert alert-warning",children:"No hay servicios de Stock disponibles."})}const le="/api",ce=new Map;const ue=({src:e,alt:t,className:n,onError:r})=>{const[a,i]=c.useState("loading");return"error"===a?null:_.jsx("img",{src:e,alt:t,className:n,loading:"lazy",onLoad:()=>{i("loaded")},onError:()=>{i("error"),r&&r()}})};function de({prod:e,disabled:t,onSelect:n}){const r=c.useRef(null),a=function(e=!1){const[t,n]=l.useState([]),[r,a]=l.useState(!0),[i,o]=l.useState(null);return l.useEffect(()=>{const t=`portal-sources-${e}`,r=ce.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 I({endpoint:"/external/sources",prod:e,basePath:le})}(e);if(!s)return;const a=r?.data?.sources||{},o=Object.entries(a).map(([e,t])=>({id:e,...t}));n(o),ce.set(t,{data:o,timestamp:i})}catch(e){s&&o(e.message)}finally{s&&a(!1)}})(),()=>{s=!1}},[e]),{sources:t,loading:r,error:i,invalidateCache:()=>{ce.delete(`portal-sources-${e}`)}}}(e),i=(e,t)=>{try{const n=sessionStorage.getItem(`limbo_portals_${e}`);return n?JSON.parse(n):t}catch{return t}},[o,s]=l.useState(()=>i("selectedPortals",[])),[u,d]=l.useState(()=>i("searchName","")),[m,h]=l.useState(()=>i("limit",20)),[p,f]=l.useState(()=>i("currentPage",1)),[g,b]=l.useState(!1),[y,v]=l.useState(null),[x,w]=l.useState(()=>i("images",[])),[k,C]=l.useState(()=>i("portalResults",{})),[S,N]=l.useState(()=>i("paginationInfo",null)),[j,E]=l.useState(null),[$,z]=l.useState(null),T=l.useRef({}),[P,A]=l.useState(new Set);c.useEffect(()=>{sessionStorage.setItem("limbo_portals_selectedPortals",JSON.stringify(o))},[o]),c.useEffect(()=>{sessionStorage.setItem("limbo_portals_searchName",JSON.stringify(u))},[u]),c.useEffect(()=>{sessionStorage.setItem("limbo_portals_limit",JSON.stringify(m))},[m]),c.useEffect(()=>{sessionStorage.setItem("limbo_portals_currentPage",JSON.stringify(p))},[p]),c.useEffect(()=>{sessionStorage.setItem("limbo_portals_images",JSON.stringify(x))},[x]),c.useEffect(()=>{sessionStorage.setItem("limbo_portals_portalResults",JSON.stringify(k))},[k]),c.useEffect(()=>{sessionStorage.setItem("limbo_portals_paginationInfo",JSON.stringify(S))},[S]);const L=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,u.trim(),m,t),a=T.current[n];if(a)return w(a.images),C(a.portalResults),N(a.paginationInfo),f(t),void v(null);b(!0),v(null),1===t&&(w([]),C({}),N(null));try{let a;1===t?(a={sources:o,limit:m,page:t,name:u.trim()},r.current={...a}):a={...r.current,page:t};const i=await function(e,t=!1){return I({endpoint:"/external/search",method:"POST",body:e,prod:t,basePath:le})}(a,e),s=i?.data?.sources||{},l=[],c={},d=new Set;let h=null;Object.entries(s).forEach(([e,t])=>{c[e]={title:t.meta?.title||e,status:200,response:"OK",count:t.images?.length||0},Array.isArray(t.images)&&(t.images.forEach(n=>{const r=n.url||n.thumbnail;r&&!d.has(r)&&(d.add(r),l.push({...n,source:e,sourceTitle:t.meta?.title||e,preview:n.thumbnail||n.url,full:n.url}))}),!h&&t.pagination&&(h=t.pagination))}),T.current[n]={images:l,portalResults:c,paginationInfo:h},w(l),C(c),N(h),f(t),A(new Set),0!==l.length||i?.result?.success||v(i?.result?.message||"No se encontraron imágenes")}catch(e){v(e.message||"Error al buscar imágenes en portales")}finally{b(!1)}},O=e=>{e<1||L(e)};return a.loading?_.jsxs("div",{className:"flex items-center justify-center py-8",children:[_.jsx("span",{className:"limbo-loader mr-2"})," Cargando portales disponibles..."]}):a.sources.length?_.jsxs("div",{className:"flex flex-col gap-2",children:[_.jsx("h3",{className:"text-lg font-semibold text-brand-blue-1000",children:"Buscar en Portales Externos"}),_.jsxs("form",{onSubmit:e=>{e.preventDefault(),L(1)},className:"flex flex-col gap-4 border-t-1 pt-4 border-brand-blue-200",children:[_.jsxs("div",{className:"flex flex-col gap-3",children:[_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsxs("h3",{className:"text-lg font-semibold text-brand-blue-1000",children:["Selecciona portales (",o.length," seleccionados)"]}),_.jsx("button",{type:"button",onClick:()=>{o.length===a.sources.length?s([]):s(a.sources.map(e=>e.id))},className:"text-sm text-brand-blue-700 hover:text-brand-blue-900 font-medium transition-colors",children:o.length===a.sources.length?"Deseleccionar todos":"Seleccionar todos"})]}),_.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 _.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-[100px] gap-2 max-h-[110px] box-border ${n?"border-brand-blue-600 bg-brand-blue-50":"border-gray-200 bg-white hover:border-brand-blue-300"} ${t?"opacity-50 cursor-not-allowed":"cursor-pointer"} hover:shadow-md `,children:[n&&_.jsx("div",{className:"absolute top-2 right-2 w-6 h-6 bg-brand-blue-600 rounded-full flex items-center justify-center bg-black",children:_.jsx("span",{className:"icon icon-tick-white icon--sm"})}),_.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)})})]}),_.jsxs("div",{className:"flex flex-col gap-1",children:[_.jsx("label",{htmlFor:"portal-search-name",className:"text-sm font-medium text-brand-blue-1000",children:"Buscar por nombre (opcional)"}),_.jsx("input",{id:"portal-search-name",type:"text",value:u,onChange:e=>d(e.target.value),className:"limbo-input",placeholder:"Deja vacío para ver todas las imágenes",disabled:t})]}),_.jsxs("div",{className:"flex-col gap-1 hidden",children:[_.jsx("label",{htmlFor:"portal-limit",className:"text-sm font-medium text-brand-blue-1000",children:"Imágenes por página"}),_.jsxs("select",{id:"portal-limit",value:10,onChange:e=>h(Number(e.target.value)),className:"limbo-input",disabled:t,children:[_.jsx("option",{value:10,children:"10"}),_.jsx("option",{value:20,children:"20"}),_.jsx("option",{value:50,children:"50"}),_.jsx("option",{value:100,children:"100"})]})]}),_.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&&_.jsx("div",{className:"alert alert-danger",children:a.error}),y&&_.jsx("div",{className:"alert alert-danger",children:y}),Object.keys(k).length>0&&_.jsxs("div",{className:"bg-neutral-50 rounded-lg p-3",children:[_.jsx("h4",{className:"text-sm font-semibold mb-2",children:"Resultados por portal:"}),_.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2 text-sm",children:Object.entries(k).map(([e,t])=>_.jsxs("div",{className:"flex items-center justify-between p-2 rounded "+(200===t.status?"bg-green-50":"bg-red-50"),children:[t.image?_.jsx("img",{src:t.image,alt:t.title,className:"w-10 h-10 object-cover rounded"}):_.jsx("span",{className:"font-medium",children:t.title}),_.jsx("span",{className:200===t.status?"text-green-700":"text-red-700",children:200===t.status?`${t.count} imágenes`:t.response})]},e))})]}),$&&_.jsx("div",{className:"mt-6 md:w-full mx-auto",children:_.jsx(X,{image:$,onDiscard:()=>{z(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)&&_.jsxs(_.Fragment,{children:[_.jsxs("div",{className:"mt-6 relative","aria-live":"polite",children:[g&&_.jsx("div",{className:"absolute inset-0 bg-white/80 z-10 flex items-center justify-center rounded-lg",children:_.jsxs("div",{className:"flex flex-col items-center gap-2",children:[_.jsx("span",{className:"limbo-loader"}),_.jsx("span",{className:"text-sm text-brand-blue-800",children:"Buscando imágenes..."})]})}),_.jsxs("div",{className:"relative grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2",children:[_.jsx(re,{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 P.has(a)?null:_.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:()=>!j&&!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=`${M({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"});z(s)}catch(e){v(e.message||"No se pudo recuperar la imagen del portal")}finally{E(null)}})(n),children:[_.jsxs("div",{className:"relative aspect-video bg-neutral-100",children:[_.jsx(ue,{src:i,alt:n.title||n.filename||`Imagen ${r+1}`,className:"object-cover w-full h-full",onError:()=>{A(e=>{const t=new Set(e);return t.add(a),t})}}),_.jsx("span",{className:"absolute top-1 left-1 bg-black/60 text-white text-xs px-2 py-1 rounded",children:n.sourceTitle}),j===(n.url||n.full)?_.jsxs("div",{className:"absolute inset-0 bg-white/90 flex flex-col items-center justify-center gap-2",children:[_.jsxs("div",{className:"relative w-10 h-10",children:[_.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-200 rounded-full"}),_.jsx("div",{className:"absolute inset-0 border-4 border-brand-blue-600 rounded-full border-t-transparent animate-spin"})]}),_.jsx("span",{className:"text-sm font-medium text-brand-blue-900",children:"Descargando..."})]}):_.jsx("div",{className:"absolute inset-0 bg-brand-blue-600/0 group-hover:bg-brand-blue-600/20 transition-colors duration-200 flex items-center justify-center",children:_.jsx("svg",{className:"w-12 h-12 text-white opacity-0 group-hover:opacity-100 transition-opacity duration-200",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:_.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})})]}),n.title&&_.jsx("div",{className:"px-2 pb-2 pt-1",children:_.jsx("p",{className:"text-xs text-gray-600 limbo-truncate",title:n.title,children:n.title})})]},a)})]})]}),_.jsxs("div",{className:"mt-6 flex items-center justify-center gap-2",children:[_.jsxs("button",{onClick:()=>O(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:[_.jsx("span",{className:"icon icon-arrow-left-white icon--sm"})," ","Anterior"]}),_.jsxs("span",{className:"px-4 py-2 text-sm text-neutral-700",children:["Página ",p,S&&_.jsxs(_.Fragment,{children:[" ","de ",S.pages,_.jsxs("span",{className:"text-xs text-neutral-500 block",children:["(",S.total," imágenes totales)"]})]})]}),_.jsxs("button",{onClick:()=>O(p+1),disabled:g||S&&p>=S.pages,className:"limbo-btn limbo-btn-secondary px-4 py-2 disabled:opacity-25"+(g||S&&p>=S.pages?" pointer-events-none cursor-default":" limbo-btn-primary"),children:["Siguiente"," ",_.jsx("span",{className:"icon icon-arrow-right-white icon--sm"})]})]})]}),!g&&0===x.length&&Object.keys(k).length>0&&_.jsxs("div",{className:"mt-6 text-center text-neutral-600 py-8 bg-neutral-50 rounded-lg",children:[_.jsx("span",{className:"icon icon-search icon--lg mb-2"}),_.jsx("p",{children:"No se encontraron imágenes en los portales seleccionados"}),u&&_.jsx("p",{className:"text-sm mt-1",children:"Intenta con otros términos o sin filtro de nombre"})]})]}):_.jsx("div",{className:"alert alert-warning",children:"No hay portales externos disponibles."})}const me=[{id:"upload",label:"Subir archivo"},{id:"ai",label:"Generar con IA"},{id:"stock",label:"Buscar en Stock"},{id:"portals",label:"Otros portales"}];function he({onSelect:e,disabled:t=!1,apiKey:n,prod:r=!1}){const[a,i]=l.useState("upload"),[o,s]=l.useState(null),[c,u]=l.useState(null),d=l.useRef();return _.jsxs("div",{className:"limbo-upload-form py-4 min-w-fit max-w-7xl mx-auto",children:[_.jsx("div",{className:"limbo-tabs-container",children:_.jsx("div",{className:"limbo-tabs mb-1 min-w-fit",role:"tablist","aria-label":"Opciones de subida de imagen",children:me.map(e=>_.jsx("button",{type:"button","data-upload-tab-id":e.id,className:"text-nowrap limbo-tab"+(a===e.id?" limbo-active":""),"aria-current":a===e.id?"page":void 0,"aria-selected":a===e.id,role:"tab",tabIndex:a===e.id?0:-1,onClick:()=>i(e.id),onKeyDown:t=>((e,t)=>{const n=me.findIndex(e=>e.id===t);let r=n;switch(e.key){case"ArrowLeft":e.preventDefault(),r=n>0?n-1:me.length-1;break;case"ArrowRight":e.preventDefault(),r=n<me.length-1?n+1:0;break;case"Home":e.preventDefault(),r=0;break;case"End":e.preventDefault(),r=me.length-1;break;case"Enter":case" ":return e.preventDefault(),void i(t);default:return}const a=me[r];a&&(i(a.id),setTimeout(()=>{const e=document.querySelector(`[data-upload-tab-id="${a.id}"]`);e&&e.focus()},0))})(t,e.id),id:`upload-tab-${e.id}`,"aria-controls":`upload-tabpanel-${e.id}`,children:e.label},e.id))})}),_.jsxs("div",{className:"limbo-tab-content px-2 py-2",role:"tabpanel",id:`upload-tabpanel-${a}`,"aria-labelledby":`upload-tab-${a}`,children:["upload"===a&&_.jsx(J,{file:o,setFile:s,previewUrl:c,setPreviewUrl:u,fileInputRef:d,onSelect:e,disabled:t}),"ai"===a&&_.jsx(ae,{apiKey:n,prod:r,disabled:t,onSelect:e}),"stock"===a&&_.jsx(se,{apiKey:n,prod:r,disabled:t,onSelect:e}),"portals"===a&&_.jsx(de,{apiKey:n,prod:r,disabled:t,onSelect:e})]})]})}const pe="undefined"!=typeof window&&void 0!==window.document,fe=pe?window:{},ge=!!pe&&"ontouchstart"in fe.document.documentElement,be=!!pe&&"PointerEvent"in fe,ye="cropper",ve=`${ye}-canvas`,xe=`${ye}-crosshair`,we=`${ye}-grid`,ke=`${ye}-handle`,Ce=`${ye}-image`,Se=`${ye}-selection`,Ne=`${ye}-shade`,je=`${ye}-viewer`,Ee="select",$e="move",_e="scale",ze="rotate",Te="transform",Pe="none",Ae="n-resize",Me="e-resize",Ie="s-resize",Le="w-resize",Oe="ne-resize",Re="nw-resize",De="se-resize",Fe="sw-resize",Ue=be?"pointerdown":ge?"touchstart":"mousedown",qe=be?"pointermove":ge?"touchmove":"mousemove",Be=be?"pointerup pointercancel":ge?"touchend touchcancel":"mouseup",He="error",We="keydown",Ve="load",Ke="wheel",Ge="action",Qe="actionend",Ye="actionstart",Xe="change",Je="transform",Ze=Number.isNaN||fe.isNaN;function et(e){return"number"==typeof e&&!Ze(e)}function tt(e){return et(e)&&e>0&&e<1/0}function nt(e){return"object"==typeof e&&null!==e}const{hasOwnProperty:rt}=Object.prototype;function at(e){if(!nt(e))return!1;try{const{constructor:t}=e,{prototype:n}=t;return t&&n&&rt.call(n,"isPrototypeOf")}catch(e){return!1}}function it(e){return"function"==typeof e}function ot(e){return"object"==typeof e&&null!==e&&1===e.nodeType}const st=/([a-z\d])([A-Z])/g;function lt(e){return String(e).replace(st,"$1-$2").toLowerCase()}const ct=/-[A-z\d]/g;function ut(e){return e.replace(ct,e=>e.slice(1).toUpperCase())}const dt=/\s\s*/;function mt(e,t,n,r){t.trim().split(dt).forEach(t=>{e.removeEventListener(t,n,r)})}function ht(e,t,n,r){t.trim().split(dt).forEach(t=>{e.addEventListener(t,n,r)})}function pt(e,t,n,r){ht(e,t,n,Object.assign(Object.assign({},r),{once:!0}))}const ft={bubbles:!0,cancelable:!0,composed:!0},gt=Promise.resolve();function bt(e){const{documentElement:t}=e.ownerDocument,n=e.getBoundingClientRect();return{left:n.left+(fe.pageXOffset-t.clientLeft),top:n.top+(fe.pageYOffset-t.clientTop)}}const yt=/deg|g?rad|turn$/i;function vt(e){const t=parseFloat(e)||0;if(0!==t){const[n="rad"]=String(e).match(yt)||[];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 xt="contain";function wt(e,t=xt){const{aspectRatio:n}=e;let{width:r,height:a}=e;const i=tt(r),o=tt(a);if(i&&o){const e=a*n;t===xt&&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 kt(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 kt(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 Ct=/left|top|width|height/i,St="open",Nt=new WeakMap,jt=new WeakMap,Et=new Map,$t=fe.document&&Array.isArray(fe.document.adoptedStyleSheets)&&"replaceSync"in fe.CSSStyleSheet.prototype;class _t extends HTMLElement{get $sharedStyle(){return(this.themeColor?`:host{--theme-color: ${this.themeColor};}`:"")+":host([hidden]){display:none!important}"}constructor(){var e,t;super(),this.shadowRootMode=St,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&&Et.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=ut(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=jt.get(this),t=this.$sharedStyle;e&&t&&($t?e.replaceSync(t):e.textContent=t);break}}}$propertyChangedCallback(e,t,n){if(!Object.is(n,t))switch(e=lt(e),typeof n){case"boolean":!0===n?this.hasAttribute(e)||this.setAttribute(e,""):this.removeAttribute(e);break;case"number":n=Ze(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=ut(e);let n=this[t];(function(e){return void 0===e})(n)||this.$propertyChangedCallback(t,void 0,n),Object.defineProperty(this,t,{enumerable:!0,configurable:!0,get:()=>n,set(e){const r=n;n=e,this.$propertyChangedCallback(t,r,e)}})});const e=this.attachShadow({mode:this.shadowRootMode||St});if(this.shadowRoot||Nt.set(this,e),jt.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(){jt.has(this)&&jt.delete(this),Nt.has(this)&&Nt.delete(this)}$getTagNameOf(e){var t;return null!==(t=Et.get(e))&&void 0!==t?t:e}$setStyles(e){return Object.keys(e).forEach(t=>{let n=e[t];et(n)&&(n=0!==n&&Ct.test(t)?`${n}px`:String(n)),this.style[t]=n}),this}$getShadowRoot(){return this.shadowRoot||Nt.get(this)}$addStyles(e){let t;const n=this.$getShadowRoot();return $t?(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({},ft),{detail:n}),r)))}(this,e,t,n)}$nextTick(e){return function(e,t){return t?gt.then(e?t.bind(e):t):gt}(this,e)}static $define(e,t){nt(e)&&(t=e,e=""),e||(e=this.$name||this.name),e=lt(e),pe&&fe.customElements&&!fe.customElements.get(e)&&customElements.define(e,this,t)}}_t.$version="2.0.0";class zt extends _t{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=Pe,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){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),ht(this,Ue,this.$onPointerDown)),this.$onPointerMove||(this.$onPointerMove=this.$handlePointerMove.bind(this),ht(this.ownerDocument,qe,this.$onPointerMove)),this.$onPointerUp||(this.$onPointerUp=this.$handlePointerUp.bind(this),ht(this.ownerDocument,Be,this.$onPointerUp)),this.$onWheel||(this.$onWheel=this.$handleWheel.bind(this),ht(this,Ke,this.$onWheel,{passive:!1,capture:!0}))}$unbind(){this.$onPointerDown&&(mt(this,Ue,this.$onPointerDown),this.$onPointerDown=null),this.$onPointerMove&&(mt(this.ownerDocument,qe,this.$onPointerMove),this.$onPointerMove=null),this.$onPointerUp&&(mt(this.ownerDocument,Be,this.$onPointerUp),this.$onPointerUp=null),this.$onWheel&&(mt(this,Ke,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)&&(et(t)&&1!==t||et(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=Te:ot(e.target)&&(i=e.target.action||e.target.getAttribute("action")||""),!1!==this.$emit(Ye,{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===Pe||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===Te){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=ze,r.rotate=o,r.centerX=l,r.centerY=c):d?(r.action=_e,r.scale=s,r.centerX=l,r.centerY=c):r.action=Pe}else{const[e]=Array.from(n.values());Object.assign(r,e)}n.forEach(e=>{e.startX=e.endX,e.startY=e.endY}),r.action!==Pe&&this.$emit(Ge,r,{cancelable:!1})}$handlePointerUp(e){const{$action:t,$pointers:n}=this;if(!this.disabled&&t!==Pe&&!1!==this.$emit(Qe,{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=Pe)}}$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(Ge,{action:_e,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;at(e)&&(tt(e.width)||tt(e.height))&&(({width:a,height:i}=wt({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(Ce));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),at(e)&&it(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)})}}zt.$name=ve,zt.$version="2.0.0";const Tt=new WeakMap,Pt=["alt","crossorigin","decoding","importance","loading","referrerpolicy","sizes","src","srcset"];class At extends _t{constructor(){super(...arguments),this.$matrix=[1,0,0,1,0,0],this.$onLoad=null,this.$onCanvasAction=null,this.$onCanvasActionEnd=null,this.$onCanvasActionStart=null,this.$actionStartTarget=null,this.$style=":host{display:inline-block}img{display:block;height:100%;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;width:100%}",this.$image=new Image,this.initialCenterSize="contain",this.rotatable=!1,this.scalable=!1,this.skewable=!1,this.slottable=!1,this.translatable=!1}set $canvas(e){Tt.set(this,e)}get $canvas(){return Tt.get(this)}static get observedAttributes(){return super.observedAttributes.concat(Pt,["initial-center-size","rotatable","scalable","skewable","translatable"])}attributeChangedCallback(e,t,n){Object.is(n,t)||(super.attributeChangedCallback(e,t,n),Pt.includes(e)&&this.$image.setAttribute(e,n))}$propertyChangedCallback(e,t,n){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(ve));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),ht(t,Ye,this.$onCanvasActionStart),ht(t,Qe,this.$onCanvasActionEnd),ht(t,Ge,this.$onCanvasAction)),this.$onLoad=this.$handleLoad.bind(this),ht(e,Ve,this.$onLoad),this.$getShadowRoot().appendChild(e)}disconnectedCallback(){const{$image:e,$canvas:t}=this;t&&(this.$onCanvasActionStart&&(mt(t,Ye,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(mt(t,Qe,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(mt(t,Ge,this.$onCanvasAction),this.$onCanvasAction=null)),e&&this.$onLoad&&(mt(e,Ve,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!==Te||this.rotatable&&this.scalable||(r=this.rotatable?ze:this.scalable?_e:Pe),r){case $e:if(this.translatable){let r=null;e&&(r=e.target.closest(this.$getTagNameOf(Se))),r||(r=t.querySelector(this.$getTagNameOf(Se))),r&&r.multiple&&!r.active&&(r=t.querySelector(`${this.$getTagNameOf(Se)}[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 ze: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 _e:if(this.scalable)if(e){const t=e.target.closest(this.$getTagNameOf(Se));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 Te: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=()=>{mt(t,He,i),e(t)},i=()=>{mt(t,Ve,a),n(r)};pt(t,Ve,a),pt(t,He,i)}});return it(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&&et(e)&&et(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&&et(e)&&et(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=vt(e),a=Math.cos(r),i=Math.sin(r),[o,s,l,c]=[a,i,-i,a];if(et(t)&&et(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,et(t)&&et(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=vt(e),r=vt(t);this.$transform(1,Math.tan(r),Math.tan(n),1,0,0)}return this}$translate(e,t=e){return this.translatable&&et(e)&&et(t)&&this.$transform(1,0,0,1,e,t),this}$transform(e,t,n,r,a,i){return et(e)&&et(t)&&et(n)&&et(r)&&et(a)&&et(i)?this.$setTransform(kt(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),et(e)&&et(t)&&et(n)&&et(r)&&et(a)&&et(i))){const o=[...this.$matrix],s=[e,t,n,r,a,i];if(!1===this.$emit(Je,{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])}}At.$name=Ce,At.$version="2.0.0";const Mt=new WeakMap;class It extends _t{constructor(){super(...arguments),this.$onCanvasChange=null,this.$onCanvasActionEnd=null,this.$onCanvasActionStart=null,this.$style=":host{display:block;height:0;left:0;outline:var(--theme-color) solid 1px;position:relative;top:0;width:0}:host([transparent]){outline-color:transparent}",this.x=0,this.y=0,this.width=0,this.height=0,this.slottable=!1,this.themeColor="rgba(0, 0, 0, 0.65)"}set $canvas(e){Mt.set(this,e)}get $canvas(){return Mt.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["height","width","x","y"])}connectedCallback(){super.connectedCallback();const e=this.closest(this.$getTagNameOf(ve));if(e){this.$canvas=e,this.style.position="absolute";const t=e.querySelector(this.$getTagNameOf(Se));t&&(this.$onCanvasActionStart=e=>{t.hidden&&e.detail.action===Ee&&(this.hidden=!1)},this.$onCanvasActionEnd=e=>{t.hidden&&e.detail.action===Ee&&(this.hidden=!0)},this.$onCanvasChange=e=>{const{x:n,y:r,width:a,height:i}=e.detail;this.$change(n,r,a,i),(t.hidden||0===n&&0===r&&0===a&&0===i)&&(this.hidden=!0)},ht(e,Ye,this.$onCanvasActionStart),ht(e,Qe,this.$onCanvasActionEnd),ht(e,Xe,this.$onCanvasChange))}this.$render()}disconnectedCallback(){const{$canvas:e}=this;e&&(this.$onCanvasActionStart&&(mt(e,Ye,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(mt(e,Qe,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasChange&&(mt(e,Xe,this.$onCanvasChange),this.$onCanvasChange=null)),super.disconnectedCallback()}$change(e,t,n=this.width,r=this.height){return et(e)&&et(t)&&et(n)&&et(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:fe.innerWidth})}}It.$name=Ne,It.$version="2.0.0";class Lt extends _t{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=Pe,this.plain=!1,this.slottable=!1,this.themeColor="rgba(51, 153, 255, 0.5)"}static get observedAttributes(){return super.observedAttributes.concat(["action","plain"])}}Lt.$name=ke,Lt.$version="2.0.0";const Ot=new WeakMap;class Rt extends _t{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){Ot.set(this,e)}get $canvas(){return Ot.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(()=>{tt(n)&&n<=1&&this.$initSelection(!0,!0)});break;case"keyboard":this.$nextTick(()=>{this.$canvas&&(n?this.$onDocumentKeyDown||(this.$onDocumentKeyDown=this.$handleKeyDown.bind(this),ht(this.ownerDocument,We,this.$onDocumentKeyDown)):this.$onDocumentKeyDown&&(mt(this.ownerDocument,We,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(Xe,{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(ve));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),ht(e,Ye,this.$onCanvasActionStart),ht(e,Qe,this.$onCanvasActionEnd),ht(e,Ge,this.$onCanvasAction)):this.$render()}disconnectedCallback(){const{$canvas:e}=this;e&&(this.$onCanvasActionStart&&(mt(e,Ye,this.$onCanvasActionStart),this.$onCanvasActionStart=null),this.$onCanvasActionEnd&&(mt(e,Qe,this.$onCanvasActionEnd),this.$onCanvasActionEnd=null),this.$onCanvasAction&&(mt(e,Ge,this.$onCanvasAction),this.$onCanvasAction=null)),super.disconnectedCallback()}$getSelections(){let e=[];return this.parentElement&&(e=Array.from(this.parentElement.querySelectorAll(this.$getTagNameOf(Se)))),e}$initSelection(e=!1,t=!1){const{initialCoverage:n,parentElement:r}=this;if(tt(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;tt(a)&&({width:i,height:o}=wt({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(Xe,{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(Xe,{x:this.x,y:this.y,width:this.width,height:this.height}))}$handleAction(e){const{currentTarget:t,detail:n}=e;if(!t||!n)return;const{relatedEvent:r}=n;let{action:a}=n;if(!a&&this.multiple&&(a=this.$action||(null==r?void 0:r.target.action),this.$action=a),!a||this.hidden&&a!==Ee||this.multiple&&!this.active&&a!==_e)return;const i=n.endX-n.startX,o=n.endY-n.startY,{width:s,height:l}=this;let{aspectRatio:c}=this;switch(!tt(c)&&r.shiftKey&&(c=tt(s)&&tt(l)?s/l:1),a){case Ee:if(0!==i&&0!==o){const{$canvas:e}=this,r=bt(t);(this.multiple&&!this.hidden?this.$createSelection():this).$change(n.startX-r.left,n.startY-r.top,Math.abs(i),Math.abs(o),c),i<0?o<0?a=Re:o>0&&(a=Fe):i>0&&(o<0?a=Oe:o>0&&(a=De)),e&&(e.$action=a)}break;case $e:this.movable&&(this.dynamic||this.$actionStartTarget&&this.contains(this.$actionStartTarget))&&this.$move(i,o);break;case _e:if(r&&this.zoomable&&(this.dynamic||this.contains(r.target))){const e=bt(t);this.$zoom(n.scale,r.pageX-e.left,r.pageY-e.top)}break;default:this.$resize(a,i,o,c)}}$handleActionEnd(){this.$action="",this.$actionStartTarget=null}$handleKeyDown(e){if(this.hidden||!this.keyboard||this.multiple&&!this.active||e.defaultPrevented)return;const{activeElement:t}=document;if(!t||!["INPUT","TEXTAREA"].includes(t.tagName)&&!["true","plaintext-only"].includes(t.contentEditable))switch(e.key){case"Backspace":e.metaKey&&(e.preventDefault(),this.$removeSelection());break;case"Delete":e.preventDefault(),this.$removeSelection();break;case"ArrowLeft":e.preventDefault(),this.$move(-1,0);break;case"ArrowRight":e.preventDefault(),this.$move(1,0);break;case"ArrowUp":e.preventDefault(),this.$move(0,-1);break;case"ArrowDown":e.preventDefault(),this.$move(0,1);break;case"+":e.preventDefault(),this.$zoom(.1);break;case"-":e.preventDefault(),this.$zoom(-.1)}}$center(){const{parentElement:e}=this;if(!e)return this;const t=(e.offsetWidth-this.width)/2,n=(e.offsetHeight-this.height)/2;return this.$change(t,n)}$move(e,t=e){return this.$moveTo(this.x+e,this.y+t)}$moveTo(e,t=e){return this.movable?this.$change(e,t):this}$resize(e,t=0,n=0,r=this.aspectRatio){if(!this.resizable)return this;const a=tt(r),{$canvas:i}=this;let{x:o,y:s,width:l,height:c}=this;switch(e){case Ae:s+=n,c-=n,c<0&&(e=Ie,c=-c,s-=c),a&&(o+=(t=n*r)/2,l-=t,l<0&&(l=-l,o-=l));break;case Me:l+=t,l<0&&(e=Le,l=-l,o-=l),a&&(s-=(n=t/r)/2,c+=n,c<0&&(c=-c,s-=c));break;case Ie:c+=n,c<0&&(e=Ae,c=-c,s-=c),a&&(o-=(t=n*r)/2,l+=t,l<0&&(l=-l,o-=l));break;case Le:o+=t,l-=t,l<0&&(e=Me,l=-l,o-=l),a&&(s+=(n=t/r)/2,c-=n,c<0&&(c=-c,s-=c));break;case Oe:a&&(n=-t/r),s+=n,c-=n,l+=t,l<0&&c<0?(e=Fe,l=-l,c=-c,o-=l,s-=c):l<0?(e=Re,l=-l,o-=l):c<0&&(e=De,c=-c,s-=c);break;case Re:a&&(n=t/r),o+=t,s+=n,l-=t,c-=n,l<0&&c<0?(e=De,l=-l,c=-c,o-=l,s-=c):l<0?(e=Oe,l=-l,o-=l):c<0&&(e=Fe,c=-c,s-=c);break;case De:a&&(n=t/r),l+=t,c+=n,l<0&&c<0?(e=Re,l=-l,c=-c,o-=l,s-=c):l<0?(e=Fe,l=-l,o-=l):c<0&&(e=Oe,c=-c,s-=c);break;case Fe:a&&(n=-t/r),o+=t,l-=t,c+=n,l<0&&c<0?(e=Oe,l=-l,c=-c,o-=l,s-=c):l<0?(e=De,l=-l,o-=l):c<0&&(e=Re,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 et(t)&&et(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||!et(e)||!et(t)||!et(n)||!et(r)||n<0||r<0?this:(tt(a)&&({width:n,height:r}=wt({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(Xe,{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(at(e)&&(tt(e.width)||tt(e.height))&&(({width:a,height:i}=wt({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(Ce));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,C=w/2;l.fillStyle="transparent",l.fillRect(0,0,a,i),at(e)&&it(e.beforeDraw)&&e.beforeDraw.call(this,l,r),l.save(),l.translate(k,C),l.transform(t,c,u,d,y,v),l.translate(-k,-C),l.drawImage(n,0,0,x,w),l.restore()}t(r)}).catch(n):t(r)})}}Rt.$name=Se,Rt.$version="2.0.0";class Dt extends _t{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 e=0;e<this.rows;e+=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))}}Dt.$name=we,Dt.$version="2.0.0";class Ft extends _t{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"])}}Ft.$name=xe,Ft.$version="2.0.0";const Ut=new WeakMap,qt=new WeakMap,Bt=new WeakMap,Ht=new WeakMap,Wt="vertical";class Vt extends _t{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=Wt,this.selection="",this.slottable=!1}set $image(e){qt.set(this,e)}get $image(){return qt.get(this)}set $sourceImage(e){Ht.set(this,e)}get $sourceImage(){return Ht.get(this)}set $canvas(e){Ut.set(this,e)}get $canvas(){return Ut.get(this)}set $selection(e){Bt.set(this,e)}get $selection(){return Bt.get(this)}static get observedAttributes(){return super.observedAttributes.concat(["resize","selection"])}connectedCallback(){super.connectedCallback();let e=null;if(e=this.selection?this.ownerDocument.querySelector(this.selection):this.closest(this.$getTagNameOf(Se)),ot(e)){this.$selection=e,this.$onSelectionChange=this.$handleSelectionChange.bind(this),ht(e,Xe,this.$onSelectionChange);const t=e.closest(this.$getTagNameOf(ve));if(t){this.$canvas=t;const e=t.querySelector(this.$getTagNameOf(Ce));e&&(this.$sourceImage=e,this.$image=e.cloneNode(!0),this.$getShadowRoot().appendChild(this.$image),this.$onSourceImageLoad=this.$handleSourceImageLoad.bind(this),this.$onSourceImageTransform=this.$handleSourceImageTransform.bind(this),ht(e.$image,Ve,this.$onSourceImageLoad),ht(e,Je,this.$onSourceImageTransform))}this.$render()}}disconnectedCallback(){const{$selection:e,$sourceImage:t}=this;e&&this.$onSelectionChange&&(mt(e,Xe,this.$onSelectionChange),this.$onSelectionChange=null),t&&this.$onSourceImageLoad&&(mt(t.$image,Ve,this.$onSourceImageLoad),this.$onSourceImageLoad=null),t&&this.$onSourceImageTransform&&(mt(t,Je,this.$onSourceImageTransform),this.$onSourceImageTransform=null),super.disconnectedCallback()}$handleSelectionChange(e){this.$render(e.detail)}$handleSourceImageLoad(){const{$image:e,$sourceImage:t}=this,n=e.getAttribute("src"),r=t.getAttribute("src");r&&r!==n&&(e.setAttribute("src",r),e.$ready(()=>{setTimeout(()=>{this.$render()},50)}))}$handleSourceImageTransform(e){this.$render(void 0,e.detail.matrix)}$render(e,t){const{$canvas:n,$selection:r}=this;e||r.hidden||(e=r),(!e||0===e.x&&0===e.y&&0===e.width&&0===e.height)&&(e={x:0,y:0,width:n.offsetWidth,height:n.offsetHeight});const{x:a,y:i,width:o,height:s}=e,l={},{clientWidth:c,clientHeight:u}=this;let d=c,m=u,h=NaN;switch(this.resize){case"both":h=1,d=o,m=s,l.width=o,l.height=s;break;case"horizontal":h=s>0?u/s:0,d=o*h,l.width=d;break;case Wt:h=o>0?c/o:0,m=s*h,l.height=m;break;default:c>0?h=o>0?c/o:0:u>0&&(h=s>0?u/s:0)}this.$scale=h,this.$setStyles(l),this.$sourceImage&&this.$transformImageByOffset(null!=t?t:this.$sourceImage.$getTransform(),-a,-i)}$transformImageByOffset(e,t,n){const{$image:r,$scale:a,$sourceImage:i}=this;if(i&&r&&a>=0){const[i,o,s,l,c,u]=e,d=(t*l-s*n)/(i*l-s*o),m=(n*i-o*t)/(i*l-s*o),h=i*d+s*m+c,p=o*d+l*m+u;r.$ready(e=>{this.$setStyles.call(r,{width:e.naturalWidth*a,height:e.naturalHeight*a})}),r.$setTransform(i,o,s,l,h*a,p*a)}}}Vt.$name=je,Vt.$version="2.0.0",
|
|
2
2
|
/*! Cropper.js v2.0.0 | (c) 2015-present Chen Fengyuan | MIT */
|
|
3
|
-
zt.$define(),Ft.$define(),Dt.$define(),Lt.$define(),At.$define(),Rt.$define(),It.$define(),Vt.$define();class Kt{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(e){return console.warn("Error moving image:",e),!1}},moveTo:(e,t)=>{if(!this.image)return!1;try{return this.image.$moveTo(e,t),!0}catch(e){return console.warn("Error moving image to position:",e),!1}},zoom:e=>{if(!this.image)return!1;try{return this.image.$zoom(e),!0}catch(e){return console.warn("Error zooming image:",e),!1}},rotate:e=>{if(!this.image)return!1;try{const t=e*Math.PI/180;return this.image.$rotate(t),!0}catch(e){return console.warn("Error rotating image:",e),!1}},scale:(e,t=e)=>{if(!this.image)return!1;try{return this.image.$scale(e,t),!0}catch(e){return console.warn("Error scaling image:",e),!1}},center:(e="contain")=>{if(!this.image)return!1;try{return this.image.$center(e),!0}catch(e){return console.warn("Error centering image:",e),!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(e){return console.warn("Error setting transform:",e),!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(e){return console.warn("Error setting zoom level:",e),!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(e){return console.warn("Error fitting to canvas:",e),!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(e){return console.warn("Error setting coverage:",e),!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(e){return console.warn("Error setting aspect ratio:",e),!1}},move:(e,t)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$move(e,t),!0}catch(e){return console.warn("Error moving selection:",e),!1}},zoom:e=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$zoom(e),!0}catch(e){return console.warn("Error zooming selection:",e),!1}},change:(e,t,n,r,a)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$change(e,t,n,r,a),!0}catch(e){return console.warn("Error changing selection:",e),!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(e){return console.warn("Error setting selection:",e),!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(e){return console.warn("Error exporting to canvas:",e),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(e){return console.warn("Error setting background:",e),!1}},setScaleStep:e=>{if(!this.canvasElement)return!1;try{return this.canvasElement.scaleStep=e,!0}catch(e){return console.warn("Error setting scale step:",e),!1}},setDisabled:e=>{if(!this.canvasElement)return!1;try{return this.canvasElement.disabled=e,!0}catch(e){return console.warn("Error setting disabled state:",e),!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(t){console.warn("Error in setup:",t),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 Gt(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;u.type!==`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(t){URL.revokeObjectURL(i),n(e)}},a.onerror=()=>{URL.revokeObjectURL(i),n(e)},a.src=i})}(u,o));const m=window.URL.createObjectURL(d),h=document.createElement("a");return h.href=m,h.download=l,h.style.display="none",document.body.appendChild(h),h.click(),setTimeout(()=>{window.URL.revokeObjectURL(m),document.body.removeChild(h)},100),i&&i(l),s&&s.announce(`${l} descargado correctamente`),!0}catch(e){return console.error("Error downloading image:",e),o&&o(e),s&&s.announce(`Error al descargar la imagen: ${e.message}`),!1}}const Qt=Object.freeze(Object.defineProperty({__proto__:null,default:Gt,downloadImage:Gt},Symbol.toStringTag,{value:"Module"}));function Yt({image:e,onSave:t,onCancel:n,onDelete:r,onError:a=null,deleting:i=!1,onVariantCreated:o=null,onUpload:s=null,uploading:c=!1}){const[u,d]=l.useState(!1),[m,h]=l.useState(null),[p,f]=l.useState(!1),[g,b]=l.useState(!0),[y,v]=l.useState(!0),[x,w]=l.useState({x:20,y:100}),[k,C]=l.useState(!1),[S,N]=l.useState({x:0,y:0}),[j,E]=l.useState(!1),[$,z]=l.useState(!0),[T,P]=l.useState(!1),[A,M]=l.useState({horizontal:!1,vertical:!1}),[I,L]=l.useState(!1),[O,R]=l.useState(!1),[D,F]=l.useState(!1),[U,q]=l.useState(!1),[B]=l.useState(()=>{if(!e||!e.filename)return"image";const[t]=e.filename.split(".");return t}),W=l.useMemo(()=>{const e=window.limboCore?.config?.getGlobal()||{};return{mandatoryCrops:e.cropper?.mandatoryCrops||[],allowCustomCrops:!1!==e.cropper?.allowCustomCrops,showDimensionInputs:!0===e.cropper?.showDimensionInputs}},[]),[V,K]=l.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,savedState:null})):[{id:"crop-default-0",label:B,width:e.width||1920,height:e.height||1080,required:!1,isCustom:!0,confirmed:!1,savedState:null}]),[G,Q]=l.useState(0),Y=V[G],X=l.useMemo(()=>Y&&Y.width&&Y.height?Y.width/Y.height:"",[Y]),J=l.useMemo(()=>{const e=50;return X&&""!==X?X>=1?{minWidth:e,minHeight:e/X}:{minWidth:e*X,minHeight:e}:{minWidth:e,minHeight:e}},[X]),[Z,ee]=l.useState(!1),[te,ne]=l.useState([]),[ae,ie]=l.useState(null),oe=window.limboCore?.accessibilityManager,{createCropVariant:se,loading:le,error:ce}=function(){const[e,t]=l.useState(!1),[n,r]=l.useState(null),[a,i]=l.useState(null),o=async(e,n)=>{if(!e||!n)return r("ID de asset y configuración de variante son requeridos"),null;t(!0),r(null),i(null);try{const t=await H(e,{variant_name:n.name,width:n.width,height:n.height,crop_params:n.crop_params,preset_aspect:n.preset_aspect,preset_size:n.preset_size,output_format:n.output_format});if(t?.result)return i(t.result),t.result;throw new Error("No se pudo crear la variante")}catch(e){return console.error("Error creating variant:",e),r(e.message||"Error desconocido al crear variante"),null}finally{t(!1)}};return{createVariant:o,createCropVariant:async(e,t,n={})=>{const r={name:n.name||`crop_${Date.now()}`,width:n.width||800,height:n.height||600,output_format:n.format||"webp",crop_params:{x:t.x||0,y:t.y||0,width:t.width||1,height:t.height||1}};return await o(e,r)},loading:e,error:n,createdVariant:a,reset:()=>{r(null),i(null)}}}(),ue=((e,t={})=>{const n=l.useRef(null),r=l.useRef(null),a=l.useRef(null),i=l.useRef(null),[o,s]=l.useState(null),[c,u]=l.useState(null),[d,m]=l.useState(!1),[h,p]=l.useState(!0),[f,g]=l.useState(0),b={aspectRatio:"",shade:!0,paspartuFactor:.85,...t};l.useEffect(()=>{n.current&&r.current&&a.current&&(i.current=new Kt(n,r,a),m(!0))},[]),l.useEffect(()=>{if(i.current)return i.current.setupEventListeners({onSelectionChange:e=>{s(e)},onImageTransform:()=>{g(e=>e+1)}})},[d]),l.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&&u({naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,currentWidth:t.width,currentHeight:t.height})})()},[e]),l.useEffect(()=>{i.current&&d&&i.current.selection.setAspectRatio(b.aspectRatio)},[b.aspectRatio,d]),l.useEffect(()=>{i.current&&d&&i.current.canvas.setBackground(b.shade)},[b.shade,d]);const y=l.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=l.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=l.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:c,isReady:d,canExport:h,transformVersion:f},transform:y(),selection:v(),utils:x(),manager:i.current}})(e,{aspectRatio:X||null,showGrid:g,shade:y,initialCoverage:.5,paspartuFactor:.85}),{refs:de,state:me,transform:he,selection:pe,utils:fe}=ue,{canvasRef:ge,imageRef:be,selectionRef:ye}=de,{cropData:ve,imageInfo:xe,canExport:we,transformVersion:ke}=me,Ce=l.useMemo(()=>xe||{naturalWidth:e.width||1920,naturalHeight:e.height||1080,currentWidth:e.width||1920,currentHeight:e.height||1080},[xe,e.width,e.height]),Se=l.useCallback(()=>b(e=>!e),[]),Ne=l.useCallback(()=>v(e=>!e),[]),je=l.useCallback(()=>R(e=>!e),[]),Ee=l.useCallback(()=>F(e=>!e),[]),$e=l.useCallback(()=>q(e=>!e),[]),_e=l.useCallback(()=>he.center(),[he]),ze=l.useCallback(()=>pe.center(),[pe]),Te=l.useCallback(()=>pe.reset(),[pe]),Pe=l.useCallback((e,t)=>he.move(e,t),[he]),Ae=l.useCallback(e=>he.zoom(e),[he]),Me=l.useCallback(e=>he.rotate(e),[he]),Ie=l.useCallback(e=>{pe.setCoverage(e)},[pe]),Le=l.useCallback(()=>{M(e=>{const t=!e.horizontal;return he.flipHorizontal(),{...e,horizontal:t}})},[he]),Oe=l.useCallback(()=>{M(e=>{const t=!e.vertical;return he.flipVertical(),{...e,vertical:t}})},[he]),Re=l.useCallback(()=>{if(!ue.manager||!me.isReady)return null;try{const e=ve?{...ve}:null;let t=null;if(ye.current){const e=ye.current;t={x:e.x??0,y:e.y??0,width:e.width??0,height:e.height??0}}let n=null;if(be.current){const e=be.current.$getTransform?.();e&&Array.isArray(e)&&(n=[...e])}const r={cropData:e,selectorState:t,imageTransform:n,flipState:{horizontal:A.horizontal,vertical:A.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}},[ue.manager,me.isReady,ve,A,G,be,ye]),De=l.useCallback(e=>{const t=V[e];if(!t||!t.savedState)return console.log(`[CropperView] ℹ️ No hay estado guardado para crop ${e}, centrando...`),void setTimeout(()=>{_e(),setTimeout(()=>ze(),100)},100);if(ue.manager&&me.isReady)try{const{savedState:n}=t;if(console.log(`[CropperView] ♻️ Restaurando estado del crop ${e}:`,n),n.imageTransform&&be.current&&Array.isArray(n.imageTransform)&&setTimeout(()=>{if(be.current&&be.current.$setTransform){const[e,t,r,a,i,o]=n.imageTransform;be.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&&ye.current){const{x:e,y:t,width:r,height:a}=n.selectorState;setTimeout(()=>{ye.current&&(ye.current.x=e,ye.current.y=t,ye.current.width=r,ye.current.height=a,ye.current.$render&&ye.current.$render(),console.log(`[CropperView] ✅ Selector restaurado: ${r}×${a} en (${e}, ${t})`))},150)}n.flipState&&M({horizontal:n.flipState.horizontal??!1,vertical:n.flipState.vertical??!1}),console.log("[CropperView] ✨ Estado restaurado completamente")}catch(e){console.error("Error restoring crop state:",e),setTimeout(()=>{_e(),setTimeout(()=>ze(),100)},100)}else console.warn("Cropper not ready for state restoration")},[V,ue.manager,me.isReady,_e,ze,ye,be]),Fe=l.useCallback(()=>{for(let e=0;e<V.length;e++){const t=V[e];if(!t.label||""===t.label.trim())return e}return-1},[V]),Ue=l.useCallback(async e=>{e!==G&&(P(!0),Re(),await new Promise(e=>setTimeout(e,100)),Q(e),await new Promise(e=>setTimeout(e,250)),De(e),await new Promise(e=>setTimeout(e,200)),P(!1))},[G,Re,De]),qe=l.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]),Be=l.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=l.useCallback(e=>{const t=Y[e];let n=100;if(ge.current&&xe){const e=ge.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=pe.getData?.();pe.setAspectRatio(i),o&&void 0!==o.x&&setTimeout(()=>{pe.set?.(o.x,o.y,o.width,o.height)},50)},[G,Y,pe,ge,xe]),We=l.useCallback(e=>{K(t=>t.map((t,n)=>n===G?{...t,label:e}:t))},[G]),Ve=l.useCallback((e,t=null)=>{if(t=t||V[e].label,!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]),Ke=l.useCallback(async()=>{if(!we)return null;try{const t=await pe.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(e){return console.warn("Error generating preview:",e),null}},[we,e.mime_type,pe]),Ge=l.useCallback(async()=>{if(u)return d(!1),h(null),void f(!1);if(we){d(!0),f(!0);try{const e=await Ke();e?h(e):(d(!1),alert("No se puede exportar el recorte por restricciones de CORS en la imagen original."))}finally{f(!1)}}else alert("No se puede exportar el recorte por restricciones de CORS en la imagen original.")},[we,Ke,u]),Qe=l.useCallback(e=>{e.target.closest(".preview-modal-header")&&(C(!0),N({x:e.clientX-x.x,y:e.clientY-x.y}))},[x]),Ye=l.useCallback(e=>{k&&(e.preventDefault(),w({x:e.clientX-S.x,y:e.clientY-S.y}))},[k,S]),Xe=l.useCallback(()=>{C(!1)},[]),Je=l.useCallback(e=>{if(!e.target.closest(".preview-modal-header"))return;const t=e.touches[0];C(!0),N({x:t.clientX-x.x,y:t.clientY-x.y})},[x]),Ze=l.useCallback(e=>{if(!k)return;e.preventDefault();const t=e.touches[0];w({x:t.clientX-S.x,y:t.clientY-S.y})},[k,S]),et=l.useCallback(()=>{C(!1)},[]);l.useEffect(()=>{if(k)return document.addEventListener("mousemove",Ye),document.addEventListener("mouseup",Xe),document.addEventListener("touchmove",Ze,{passive:!1}),document.addEventListener("touchend",et),()=>{document.removeEventListener("mousemove",Ye),document.removeEventListener("mouseup",Xe),document.removeEventListener("touchmove",Ze),document.removeEventListener("touchend",et)}},[k,Ye,Xe,Ze,et]),l.useEffect(()=>{if(!j)return;const e=e=>{"Escape"===e.key&&E(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[j]);const tt=l.useCallback(async(t,n=null)=>{const r=V[t];if(!r)throw new Error(`Crop ${t} no encontrado`);let a;if(r.savedState&&r.savedState.cropData)a=r.savedState.cropData,console.log(`[CropperView] Usando savedState para crop ${t}:`,a);else{if(t!==G||!ve)throw new Error(`No hay datos de recorte para el crop "${r.label}". Ajusta el recorte antes de guardar.`);a=ve,console.log(`[CropperView] Usando cropData actual para crop activo ${t}:`,a)}if(!a.x&&0!==a.x||!a.y&&0!==a.y||!a.width||!a.height)throw new Error(`Datos de recorte inválidos para "${r.label}"`);if(!Ce?.naturalWidth||!Ce?.naturalHeight)throw new Error("Información de imagen no disponible");const{x:i,y:s,width:l,height:c}=a,{naturalWidth:u,naturalHeight:d}=Ce,m={x:i/u,y:s/d,width:l/u,height:c/d},h=Math.min(r.width,5e3),p=Math.min(r.height,5e3),f=`${r.label||"crop"}_${h}_${p}`,g=n||e.id,b=await se(g,m,{name:f,width:h,height:p,format:globalThis.downloadFormat||"webp",quality:90});if(b)return oe?.announceSuccess(`Recorte creado: ${f}`),o?.(g,b),b;throw new Error("No se pudo crear la variante")},[V,G,ve,Ce,B,se,e.id,o,oe]),nt=l.useCallback(async()=>{if(!we){const e="No se puede exportar el recorte por restricciones de CORS en la imagen original.";return oe?.announceError(e),void alert(e)}if(!me.isReady){const e="El cropper aún no está inicializado. Espera un momento e inténtalo de nuevo.";return oe?.announceError(e),void alert(e)}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 tt(G,n);a&&t(r?{crops:[a],asset:r}:a)}catch(e){console.warn("Error creating crop variant:",e);const t=e.message||"No se pudo crear el recorte. Inténtalo de nuevo.";oe?.announceError(t),alert(t),a?.(e)}},[we,me.isReady,oe,Re,tt,G,t,a,e.file,e.id,s]),rt=l.useCallback(async n=>{Re(),oe?.announce(`Guardando ${n.length} recortes...`);try{let r=e.id,a=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");r=t.id,a=t,oe?.announceSuccess("Imagen subida correctamente")}const i=[],o=[];for(const e of n)try{const t=await tt(e,r);t&&i.push(t)}catch(t){o.push({crop:V[e]?.label||`Crop ${e}`,error:t.message})}if(i.length>0&&(oe?.announceSuccess(`${i.length} recorte(s) guardado(s) correctamente`),t(a?{crops:i,asset:a}:i)),o.length>0){const e=`Errores al guardar algunos recortes:\n${o.map(e=>`- ${e.crop}: ${e.error}`).join("\n")}`;oe?.announceError(e),alert(e)}}catch(e){const t=e.message||"Error al procesar los recortes";oe?.announceError(t),alert(t),a?.(e)}},[Re,tt,V,oe,t,e.file,e.id,s,a]),at=l.useCallback(async()=>{const e=Fe();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 ne(e),void ee(!0)}await nt()},[Fe,V,nt,G]),it=l.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:be.current?.$getTransform?.(),selectorState:ye.current?{x:ye.current.x,y:ye.current.y,width:ye.current.width,height:ye.current.height}:null};try{if(t!==G&&n.savedState){if(console.log(`[CropperView] 🔄 Restaurando temporalmente crop ${t} para descarga...`),n.savedState.imageTransform&&be.current?.$setTransform){const[e,t,r,a,i,o]=n.savedState.imageTransform;be.current.$setTransform(e,t,r,a,i,o)}if(n.savedState.selectorState&&ye.current){const{x:e,y:t,width:r,height:a}=n.savedState.selectorState;ye.current.x=e,ye.current.y=t,ye.current.width=r,ye.current.height=a,ye.current.$render?.()}await new Promise(e=>setTimeout(e,100))}const r=await pe.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 Gt(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&&be.current?.$setTransform){console.log(`[CropperView] ↩️ Restaurando estado original del crop ${r.index}...`);const[e,t,n,a,i,o]=r.imageTransform;if(be.current.$setTransform(e,t,n,a,i,o),r.selectorState&&ye.current){const{x:e,y:t,width:n,height:a}=r.selectorState;ye.current.x=e,ye.current.y=t,ye.current.width=n,ye.current.height=a,ye.current.$render?.()}}}},[V,G,pe,e.mime_type,B,oe,be,ye]),ot=l.useCallback(async e=>{Re(),oe?.announce(`Descargando ${e.length} recortes...`);const t=[],n=[];for(const r of e)try{const e=await it(r);e&&t.push(e)}catch(e){n.push({crop:V[r]?.label||`Crop ${r}`,error:e.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,it,V,oe]),st=l.useCallback(async()=>{if(!we){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 it(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)}},[we,oe,Re,it,G]),lt=l.useCallback(async()=>{const e=Fe();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 ne(e),void ee(!0)}await st()},[Fe,V,st,G]),ct=l.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(e){console.error("Error guardando imagen original:",e);const t=e.message||"No se pudo guardar la imagen. Inténtalo de nuevo.";oe?.announceError(t),alert(t),a?.(e)}else n()},[e.file,s,n,t,a,oe]);return l.useEffect(()=>{d(!1),h(null)},[e]),l.useEffect(()=>{ue.manager&&me.isReady&&$&&(console.log("[CropperView] Carga inicial completada, centrando imagen y selector..."),setTimeout(()=>{_e(),setTimeout(()=>{ze(),z(!1),console.log("[CropperView] Carga inicial finalizada")},100)},50))},[ue.manager,me.isReady,$,_e,ze]),l.useEffect(()=>{ue.manager&&me.isReady&&(X&&pe.setAspectRatio(X),fe.setBackground(y))},[X,y,ue.manager,me.isReady,pe,fe]),l.useEffect(()=>{if(!xe||!me.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(xe.naturalWidth,5e3),n=Math.min(xe.naturalHeight,5e3);K([{...e,width:t,height:n}]),console.log(`[CropperView] Crop por defecto actualizado a ${t}×${n}px`)}},[xe,me.isReady,W.mandatoryCrops.length,V]),l.useEffect(()=>{if(!u||!we)return;const e=setTimeout(async()=>{f(e=>!m&&!e||e);try{const e=await Ke();e&&h(e)}finally{f(!1)}},300);return()=>{clearTimeout(e),f(!1)}},[ve,ke,u,we,Ke,X,A,m]),l.useEffect(()=>{const e=ge.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)}},[ge]),e?_.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:[_.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 flex-shrink-0 lg:gap-2",children:[_.jsxs("div",{className:"flex-1 min-w-fit space-y-2 max-w-fit",children:[_.jsxs("div",{className:"flex items-center gap-2",children:[_.jsx("h2",{className:"text-lg sm:text-xl font-bold text-gray-800",children:"Generar recortes"}),V.length>1&&_.jsx("span",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 text-xs font-semibold rounded",children:Y.label})]}),_.jsxs("div",{className:"flex items-center gap-2",children:[_.jsx("label",{className:"text-xs text-gray-500 whitespace-nowrap",children:"Nombre:"}),_.jsx("div",{className:"",children:B+"."+(globalThis.downloadFormat||e.mime_type.split("/")[1]||"webp")})]})]}),_.jsxs("div",{className:"flex flex-row self-end gap-2 w-full max-w-fit sm:w-auto flex-wrap",children:[_.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:[_.jsx("span",{className:"icon icon-arrow-left-white icon--sm m-0 p-0"})," ","Cancelar"]}),r&&_.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-700 hover:bg-red-900 transition-colors text-white disabled:opacity-50 disabled:cursor-not-allowed","aria-label":`Eliminar imagen ${e.filename}`,title:`Eliminar imagen ${e.filename}`,children:[_.jsx("span",{className:"icon icon-close-small-white icon--sm m-0 p-0"}),i?"Eliminando...":"Eliminar"]})]})]}),_.jsxs("div",{className:"limbo-cropper-status bg-white border-gray-100 py-0 pb-0 flex-shrink-0",children:[ce&&_.jsxs("div",{className:"alert alert-danger mb-2 text-sm",role:"alert",children:[_.jsx("strong",{children:"Error:"})," ",ce]}),xe&&_.jsxs("div",{className:"alert alert-secondary mb-2 text-sm",role:"status",children:[_.jsx("strong",{children:"Original:"})," ",xe.naturalWidth," ×"," ",xe.naturalHeight," px",xe.currentWidth!==xe.naturalWidth&&_.jsxs("span",{className:"ml-2 sm:ml-3 text-xs block sm:inline",children:["(Mostrada: ",Math.round(xe.currentWidth)," ×"," ",Math.round(xe.currentHeight)," px)"]})]}),!we&&_.jsx("div",{className:"alert alert-warning mb-2 text-sm",role:"alert",children:"⚠️ No se puede exportar por restricciones CORS"}),_.jsxs("div",{className:"bg-white border-b border-gray-200 py-2 mx-2 flex-shrink-0 sticky top-0 z-10 mb-1",children:[_.jsxs("div",{className:"flex items-center justify-between mb-2",children:[_.jsxs("h3",{className:"text-sm font-semibold text-gray-700",children:["Recortes ",V.length>1&&`(${V.length})`]}),W.allowCustomCrops&&_.jsxs("button",{onClick:qe,disabled:le,className:"text-xs cursor-pointer px-2 py-1 bg-green-100 hover:bg-green-200 text-green-800 rounded border border-green-300 transition-colors flex items-center gap-1",title:"Añadir recorte personalizado",children:[_.jsx("span",{className:"icon icon-add-green text-green-800 icon--sm"}),"Añadir recorte"]})]}),_.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 _.jsxs("label",{className:"flex flex-col p-1.5 rounded border cursor-pointer transition-colors min-h-[70px] "+(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:[_.jsx("input",{type:"radio",name:"active-crop",checked:G===t,onChange:()=>Ue(t),disabled:le,className:"hidden"}),_.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[_.jsx("div",{className:"flex-1 min-w-0",children:_.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[G!==t||e.required?_.jsx("span",{className:"text-xs font-medium text-gray-800 truncate",children:e.label}):_.jsx("input",{type:"text",value:e.label,onChange:e=>We(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",placeholder:"Nombre",maxLength:25,onClick:e=>e.stopPropagation()}),e.required&&_.jsx("span",{className:"text-[10px] px-1 py-0.5 bg-red-100 text-red-700 rounded whitespace-nowrap",children:"Oblig."}),e.isCustom&&G!==t&&_.jsx("span",{className:"text-[10px] px-1 py-0.5 bg-purple-100 text-purple-700 rounded whitespace-nowrap",children:"Custom"})]})}),!e.required&&V.length>1&&_.jsx("button",{onClick:n=>{n.preventDefault(),n.stopPropagation(),Ve(t,e.label)},className:"flex-shrink-0 hover:bg-red-500/50 text-red-500 p-1 rounded max-h-fit aspect-square cursor-pointer flex",title:"Eliminar",children:_.jsx("span",{className:"icon icon-close-small icon--xs"})})]}),_.jsx("div",{className:"flex items-center gap-1 mt-auto",children:G===t?_.jsxs(_.Fragment,{children:[_.jsx("input",{type:"number",min:"100",max:"5000",value:e.width,onChange:e=>Be("width",e.target.value),onBlur:()=>He("width"),disabled:le,className:"flex-1 text-xs px-1 py-0.5 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"W",onClick:e=>e.stopPropagation()}),_.jsx("span",{className:"text-gray-400 text-xs",children:"×"}),_.jsx("input",{type:"number",min:"100",max:"5000",value:e.height,onChange:e=>Be("height",e.target.value),onBlur:()=>He("height"),disabled:le,className:"flex-1 text-xs px-1 py-0.5 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"H",onClick:e=>e.stopPropagation()})]}):_.jsxs("span",{className:"text-[10px] text-gray-500",children:[e.width," × ",e.height," px"]})}),!n&&_.jsx("div",{className:"text-[9px] px-1 py-0.5 bg-orange-200 text-orange-800 rounded text-center mt-1",children:"Sin configurar"})]},e.id)})})]})]}),_.jsxs("div",{className:"flex flex-col lg:flex-row flex-1 w-full overflow-hidden lg:max-h-130 mx-2 py-1",children:[_.jsx("div",{className:"relative flex-1 lg:flex-[2] h-full flex-shrink-0 flex-grow-1 order-0 min-h-100 lg:min-h-130",children:_.jsxs("div",{className:"absolute inset-0 bg-white rounded-lg border-2 border-gray-200 overflow-hidden",children:[_.jsx(re,{show:$,message:"Cargando recortador..."}),_.jsx(re,{show:T,message:`Cambiando a: ${V[G]?.label||"recorte"}...`}),_.jsxs("cropper-canvas",{ref:ge,style:{width:"100%",height:"100%",display:"block"},background:!!y||void 0,id:"limbo-cropperjs-canvas",tabindex:"-1",onKeyDown:e=>{"Delete"!==e.key&&"Backspace"!==e.key||(e.preventDefault(),e.stopPropagation())},children:[_.jsx("cropper-image",{ref:be,src:e.url||e.path,alt:e.filename,id:"limbo-cropperjs-image",action:"move",crossOrigin:"anonymous",rotatable:!0,scalable:!0,skewable:!0,translatable:!0}),_.jsxs("cropper-selection",{ref:ye,"initial-coverage":"0.5",movable:!0,resizable:!0,keyboard:"true",action:"move",style:{cursor:"move",minWidth:`${J.minWidth}px`,minHeight:`${J.minHeight}px`},"data-prevent-delete":"true",tabindex:"-1",children:[g&&_.jsx("cropper-grid",{role:"grid",action:"move",covered:!0,bordered:!0}),_.jsx("cropper-handle",{action:"move",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"32px",height:"32px",zIndex:"10"}}),_.jsx("cropper-handle",{action:"n-resize"}),_.jsx("cropper-handle",{action:"e-resize"}),_.jsx("cropper-handle",{action:"s-resize"}),_.jsx("cropper-handle",{action:"w-resize"}),_.jsx("cropper-handle",{action:"ne-resize"}),_.jsx("cropper-handle",{action:"nw-resize"}),_.jsx("cropper-handle",{action:"se-resize"}),_.jsx("cropper-handle",{action:"sw-resize"})]})]})]})}),_.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:_.jsxs("div",{className:"h-full mt-2 lg:my-0 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:[_.jsxs("div",{className:"bg-white rounded border w-full border-gray-200 mb-2",children:[_.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":U,"aria-label":"Mostrar/ocultar opciones de visualización",children:_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Transformar imagen"}),_.jsx("div",{className:"text-center",children:_.jsx("span",{className:`icon ${U?"icon-chevron-up":"icon-chevron-down"} text-center icon--xs`})})]})}),_.jsxs("div",{className:"p-2 space-y-2 justify-items-stretch static "+(U?"block":"sm:hidden"),children:[_.jsx("div",{className:"mb-3 block",children:_.jsxs("div",{className:"grid grid-cols-5 gap-1 content-center h-fit mx-auto",children:[_.jsx("button",{onClick:()=>Ae(-.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-zoom-out-blue"})})}),_.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-arrow-up-blue icon--md -rotate-45"})})}),_.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-arrow-up-blue icon--md"})})}),_.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-arrow-up-blue icon--md rotate-45"})})}),_.jsx("button",{onClick:()=>Ae(.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-zoom-in-blue"})})}),_.jsx("button",{onClick:()=>Me(-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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"text-brand-blue-1000 font-medium",children:"-45°"})})}),_.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-arrow-left-blue"})})}),_.jsx("button",{onClick:_e,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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-radio-button-blue icon-md"})})}),_.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-arrow-right-blue"})})}),_.jsx("button",{onClick:()=>Me(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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"text-brand-blue-1000 font-medium",children:"+45°"})})}),_.jsx("button",{onClick:Le,className:"px-0 rounded cursor-pointer transition-colors text-sm aspect-square "+(A.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 "+(A.horizontal?"(activo)":""),disabled:le,"aria-label":"Voltear imagen horizontalmente","aria-pressed":A.horizontal,children:_.jsx("div",{className:"flex items-center justify-center gap-2",children:_.jsx("span",{className:"icon icon-arrow-left-right-blue border border-brand-blue-1000 rounded"})})}),_.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-arrow-up-blue icon--md -rotate-145"})})}),_.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-arrow-down-blue"})})}),_.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-arrow-up-blue icon--md rotate-145"})})}),_.jsx("button",{onClick:Oe,className:"px-0 rounded cursor-pointer transition-colors aspect-square text-sm "+(A.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 "+(A.vertical?"(activo)":""),disabled:le,"aria-label":"Voltear imagen verticalmente","aria-pressed":A.vertical,children:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-arrow-up-down-blue border border-brand-blue-1000 rounded"})})})]})}),_.jsx("div",{className:"flex flex-col gap-2",children:_.jsx("button",{onClick:()=>{he.reset(),M({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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsxs("span",{children:[_.jsx("span",{className:"icon icon-refresh-blue icon--sm align-[middle!important] "})," ","Reiniciar ajustes"]})})})})]})]}),_.jsxs("div",{className:"bg-white rounded border border-gray-200 w-full"+(D?"":" bg-neutral-gray-50/50"),children:[_.jsx("button",{onClick:Ee,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":D,"aria-label":"Mostrar/ocultar opciones de visualizción",children:_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Ajustes del selector"}),_.jsx("div",{className:"text-center",children:_.jsx("span",{className:`icon ${D?"icon-chevron-up":"icon-chevron-down"} text-center icon--xs`})})]})}),_.jsxs("div",{className:"p-2 space-y-2 justify-items-stretch static "+(D?"block":"sm:hidden"),children:[_.jsx("div",{children:_.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[_.jsx("button",{onClick:()=>Ie(.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{children:"50%"})})}),_.jsx("button",{onClick:()=>Ie(.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{children:"70%"})})}),_.jsx("button",{onClick:()=>Ie(.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{children:"90%"})})}),_.jsx("button",{onClick:()=>Ie(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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{children:"100%"})})})]})}),_.jsxs("div",{className:"space-y-2 pt-2",children:[_.jsx("button",{onClick:ze,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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsxs("span",{children:[_.jsx("span",{className:"icon icon-radio-button icon--sm align-[middle!important] "})," ","Centrar selección"]})})}),_.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:"Reiniciar selección",disabled:le,"aria-label":"Reiniciar área de selección",children:_.jsx("div",{className:"flex items-center justify-center",children:_.jsxs("span",{children:[_.jsx("span",{className:"icon icon-refresh icon--sm lign-[middle!important] "})," ","Reset selección"]})})})]})]})]}),_.jsxs("div",{className:"bg-white rounded border border-gray-200 w-full",children:[_.jsx("button",{onClick:je,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:_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Visualización"}),_.jsx("div",{className:"text-center",children:_.jsx("span",{className:`icon ${O?"icon-chevron-up":"icon-chevron-down"} text-center icon--xs`})})]})}),_.jsxs("div",{className:"py-2 space-y-2 justify-items-stretch static "+(O?"block":"sm:hidden"),children:[_.jsxs("button",{onClick:Se,className:"w-auto flex cursor-pointer items-center justify-between mx-2 p-1 rounded transition-colors "+(g?"bg-blue-100 border border-blue-300 text-blue-800":"bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200"),disabled:le,"aria-pressed":g,title:"Mostrar/ocultar cuadrícula de la regla de los tercios en el selector","aria-label":"Activar/desactivar grid",children:[_.jsxs("span",{className:"text-sm flex items-center",children:[_.jsx("span",{className:"icon icon-area-blue me-1"})," ","Cuadrícula"]}),_.jsx("span",{className:"text-xs",children:g?_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"icon icon-tick icon--xs align-[middle!important] -mt-0.5"})," ","Activo"]}):"Inactivo"})]}),_.jsxs("button",{onClick:Ne,className:"w-auto flex cursor-pointer items-center justify-between mx-2 p-1 rounded transition-colors "+(y?"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":y,"aria-label":"Activar/desactivar sombreado",children:[_.jsxs("span",{className:"text-sm flex items-center",children:[_.jsx("span",{className:"icon icon-comparison-blue me-1"})," ","Tablero"]}),_.jsx("span",{className:"text-xs",children:y?_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"icon icon-tick icon--xs align-[middle!important] -mt-0.5"})," ","Activo"]}):"Inactivo"})]})]})]})]})})]}),_.jsxs("div",{className:"flex justify-between flex-shrink-0 border-t border-gray-200 bg-white mx-2 mt-1 py-2 lg:gap-0",children:[_.jsxs("button",{onClick:()=>L(!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:[_.jsx("span",{className:"icon icon-lightbulb text-yellow-500"}),_.jsx("span",{className:"text-sm font-semibold text-blue-800",children:"Guía de uso"}),_.jsx("span",{className:"icon icon-arrow-down scale-75 -rotate-145"})]}),_.jsx("button",{onClick:Ge,disabled:le||!we,className:`px-3 cursor-pointer py-1.5 text-sm rounded transition-colors ${u?"bg-red-600 hover:bg-red-700 text-white":"bg-blue-600 hover:bg-blue-700 text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,"aria-label":"Vista previa",title:"Mostrar/Ocultar vista previa",children:_.jsxs("div",{className:"flex items-center gap-1",children:[_.jsx("span",{className:"icon icon-search-white icon--sm"}),_.jsx("span",{className:"hidden sm:inline whitespace-nowrap",children:u?"Cerrar previa":"Vista previa"})]})}),_.jsxs("div",{className:"flex flex-row gap-1 lg:gap-2 items-center justify-end",children:[_.jsx("button",{onClick:lt,disabled:le||!we,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:_.jsxs("div",{className:"flex items-center gap-1",children:[_.jsx("span",{className:"icon icon-download-white icon--sm"}),_.jsx("span",{className:"hidden md:inline whitespace-nowrap",children:"Descargar"})]})}),e.file&&_.jsx("button",{onClick:ct,disabled:le||c,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:_.jsxs("div",{className:"flex items-center gap-1",children:[_.jsx("span",{className:"icon icon-tick-white icon--sm"}),_.jsx("span",{className:"hidden md:inline whitespace-nowrap",children:"Conservar original"})]})}),_.jsx("button",{onClick:at,disabled:le||!ve||!Ce||!we||!me.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:_.jsx("div",{className:"flex items-center gap-1",children:le?_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"icon icon-save-white icon--sm"}),_.jsx("span",{children:"Guardando..."})]}):_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"icon icon-save-white icon--sm"}),_.jsx("span",{className:"hidden md:inline whitespace-nowrap",children:"Guardar recorte"})]})})})]})]}),Z&&_.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] p-4",children:_.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] overflow-hidden flex flex-col",children:[_.jsxs("div",{className:"px-6 py-4 border-b border-gray-200",children:[_.jsx("h3",{className:"text-lg font-semibold text-gray-800",children:"save"===ae?"Seleccionar recortes a guardar":"Seleccionar recortes a descargar"}),_.jsxs("p",{className:"text-sm text-gray-600 mt-1",children:["Marca los recortes que deseas"," ","save"===ae?"guardar":"descargar"]})]}),_.jsx("div",{className:"px-6 py-4 overflow-y-auto flex-1",children:_.jsx("div",{className:"space-y-2",children:V.map((e,t)=>{const n=e.savedState||t===G,r=!e.required&&!n;return _.jsxs("label",{className:`flex items-center gap-3 p-3 rounded border transition-colors ${te.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:[_.jsx("input",{type:"checkbox",checked:te.includes(t),disabled:r,onChange:e=>{e.target.checked?ne(e=>[...e,t]):ne(e=>e.filter(e=>e!==t))},className:"w-4 h-4 text-blue-600"}),_.jsxs("div",{className:"flex-1 min-w-0",children:[_.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[_.jsx("span",{className:"text-sm font-medium text-gray-800 truncate",children:e.label}),e.required&&_.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-red-100 text-red-700 rounded whitespace-nowrap",children:"Obligatorio"}),!n&&!e.required&&_.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-orange-100 text-orange-700 rounded whitespace-nowrap",children:"Sin configurar"})]}),_.jsxs("span",{className:"text-xs text-gray-500",children:[e.width," × ",e.height," px"]})]})]},e.id)})})}),_.jsxs("div",{className:"px-6 py-4 border-t border-gray-200 flex gap-3 justify-end",children:[_.jsx("button",{onClick:()=>{ee(!1),ie(null),ne([])},className:"limbo-btn limbo-btn-secondary px-4 py-2",children:"Cancelar"}),_.jsxs("button",{onClick:async()=>{if(ee(!1),"save"===ae)if(1===te.length){const e=G;Q(te[0]),await new Promise(e=>setTimeout(e,100)),await nt(),Q(e)}else await rt(te);else if(1===te.length){const e=G;Q(te[0]),await new Promise(e=>setTimeout(e,100)),await st(),Q(e)}else await ot(te);ie(null),ne([])},disabled:0===te.length,className:"limbo-btn limbo-btn-primary px-4 py-2 disabled:opacity-50 disabled:cursor-not-allowed",children:["save"===ae?"Guardar":"Descargar"," (",te.length,")"]})]})]})}),I&&_.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] p-4",children:_.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-3xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[_.jsx("div",{className:"px-6 py-4 border-b border-gray-200 bg-gradient-to-r from-brand-blue-50 to-green-50",children:_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsxs("h3",{className:"text-xl font-semibold text-blue-800 flex items-center gap-2",children:[_.jsx("span",{className:"icon icon-lightbulb text-yellow-500"}),"Guía de uso del Cropper"]}),_.jsx("button",{onClick:()=>L(!1),className:"text-gray-400 hover:text-gray-600 p-1 rounded-full hover:bg-gray-100 transition-colors","aria-label":"Cerrar modal",children:_.jsx("span",{className:"icon icon-close-small icon--lg"})})]})}),_.jsxs("div",{className:"px-6 py-4 overflow-y-auto flex-1 space-y-4",children:[_.jsxs("div",{className:"bg-blue-50 rounded-lg p-4 border-l-4 border-blue-400",children:[_.jsx("h4",{className:"font-semibold text-blue-800 mb-3 text-base flex items-center gap-2",children:"🖱️ Navegación básica"}),_.jsxs("div",{className:"text-sm text-blue-700 space-y-2",children:[_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Arrastra la imagen:"})," Haz clic sobre la imagen dentro del área de selección y arrástrala para reposicionarla"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Zoom:"})," Usa la rueda del ratón sobre el canvas (fuera del área de selección) para hacer zoom"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Vista completa:"}),' Botón "Reset zoom" para ajustar automáticamente al tamaño óptimo']})]})]})]}),_.jsxs("div",{className:"bg-green-50 rounded-lg p-4 border-l-4 border-green-400",children:[_.jsx("h4",{className:"font-semibold text-green-800 mb-3 text-base flex items-center gap-2",children:"✂️ Área de selección"}),_.jsxs("div",{className:"text-sm text-green-700 space-y-2",children:[_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Mover selección:"})," Arrastra desde el centro",_.jsx("span",{className:"icon bg-white icon-move inline-block mx-1 align-middle border border-green-600 rounded-full"}),"para reposicionar el área de recorte"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Redimensionar:"})," Arrastra desde las esquinas o bordes para cambiar el tamaño del área"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Tamaños rápidos:"})," Usa los botones de porcentaje (50%, 70%, 90%, 100%) para ajustar rápidamente el tamaño"]})]})]})]}),_.jsxs("div",{className:"bg-purple-50 rounded-lg p-4 border-l-4 border-purple-400",children:[_.jsx("h4",{className:"font-semibold text-purple-800 mb-3 text-base flex items-center gap-2",children:"⌨️ Atajos de teclado"}),_.jsxs("div",{className:"text-sm text-purple-700 space-y-2",children:[_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Flechas:"}),_.jsxs("span",{className:"inline-flex gap-1 mx-1",children:[_.jsx("span",{className:"icon icon-arrow-right-box rotate-180 icon--sm"}),_.jsx("span",{className:"icon icon-arrow-right-box icon--sm"}),_.jsx("span",{className:"icon icon-arrow-right-box -rotate-90 icon--sm"}),_.jsx("span",{className:"icon icon-arrow-right-box rotate-90 icon--sm"})]}),"Mueven la selección en incrementos de 10px"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Shift + Arrastrar:"})," Mantiene las proporciones al redimensionar el área de selección"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Ctrl + Rueda:"})," Control de zoom más preciso y fino"]})]})]})]}),_.jsxs("div",{className:"bg-cyan-50 rounded-lg p-4 border-l-4 border-cyan-400",children:[_.jsx("h4",{className:"font-semibold text-cyan-800 mb-3 text-base flex items-center gap-2",children:"👁️ Opciones de visualización"}),_.jsxs("div",{className:"text-sm text-cyan-700 space-y-2",children:[_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Cuadrícula:"})," Muestra la regla de los tercios para mejorar la composición de tus recortes"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Tablero:"})," Patrón de cuadros para alinear mejor las medidas o ver imágenes con transparencia"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Vista previa:"})," Muestra cómo quedará el recorte final antes de guardarlo"]})]})]})]}),_.jsxs("div",{className:"bg-amber-50 rounded-lg p-4 border-l-4 border-amber-400",children:[_.jsx("h4",{className:"font-semibold text-amber-800 mb-3 text-base flex items-center gap-2",children:"💡 Consejos profesionales"}),_.jsxs("div",{className:"text-sm text-amber-700 space-y-2",children:[_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Orden de trabajo:"})," Primero aplica transformaciones (rotar, voltear), luego haz el recorte final"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Múltiples recortes:"})," Si tienes varios recortes configurados, revisa cada uno antes de guardar"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Calidad:"})," Las imágenes se exportan en alta calidad (JPEG 90%) manteniendo la mayor nitidez posible"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Proporciones:"})," Usa Shift al redimensionar para mantener el aspecto ratio original"]})]})]})]}),_.jsxs("div",{className:"bg-orange-50 rounded-lg p-4 border-l-4 border-orange-500",children:[_.jsx("h4",{className:"font-semibold text-orange-800 mb-3 text-base flex items-center gap-2",children:"⚠️ Notas importantes"}),_.jsxs("div",{className:"text-sm text-orange-700 space-y-2",children:[_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Recortes grandes:"})," Imágenes de alta resolución pueden tardar más en procesarse"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Calidad de escala:"})," Evita ampliar demasiado áreas pequeñas, ya que puede afectar la nitidez"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Cambios pendientes:"})," Recuerda guardar tus cambios antes de cerrar o cambiar de imagen"]})]})]})]})]}),_.jsx("div",{className:"px-6 py-4 border-t border-gray-200 bg-gray-50",children:_.jsx("button",{onClick:()=>L(!1),className:"limbo-btn limbo-btn-primary w-full",children:"Entendido"})})]})}),u&&_.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&&(d(!1),h(null))},children:_.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:`${x.x}px`,top:`${x.y}px`,width:"420px",cursor:k?"grabbing":"default"}:{}},onMouseDown:Qe,onTouchStart:Je,children:[_.jsxs("div",{className:"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:k?"grabbing":"grab"},children:[_.jsxs("div",{className:"flex items-center gap-2",children:[_.jsx("span",{className:"icon icon-search-white icon--sm"}),_.jsx("h3",{className:"text-sm font-semibold",children:"Vista previa"})]}),_.jsx("button",{onClick:()=>{d(!1),h(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:_.jsx("span",{className:"icon icon-close-small-white icon--sm p-0 m-0 py-auto my-auto mx-auto"})})]}),_.jsx("div",{className:"flex-1 overflow-auto bg-gray-50 p-4",children:p?_.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",children:_.jsxs("div",{className:"text-center",children:[_.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-3"}),_.jsx("p",{className:"text-sm text-gray-600",children:"Generando vista previa..."})]})}):m?_.jsxs("div",{className:"flex flex-col items-center gap-3",children:[_.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:()=>E(!0),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),E(!0))},"aria-label":"Click para ver recorte en tamaño completo",title:"Click para ampliar",children:[_.jsx("img",{src:m,alt:"Vista previa del recorte",className:"w-full h-auto object-contain max-h-[400px]"}),_.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:[_.jsx("span",{className:"icon icon-search-white icon--xs"}),_.jsx("span",{children:"Ampliar"})]})]}),_.jsxs("div",{className:"text-center text-xs text-gray-500",children:[_.jsx("p",{className:"font-medium text-gray-700 mb-1",children:Y?.label||"Recorte"}),_.jsxs("p",{children:[Y?.width," × ",Y?.height," px"]})]})]}):_.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",children:_.jsx("p",{className:"text-sm text-gray-500",children:"No se pudo generar la vista previa"})})}),_.jsx("div",{className:"px-4 py-2 bg-gray-100 border-t border-gray-200",children:_.jsxs("p",{className:"text-xs text-gray-600 text-center",children:[_.jsxs("span",{className:"hidden md:inline",children:["Arrastra desde el título para mover •"," "]}),"Actualización automática al editar"]})})]})}),j&&m&&_.jsxs("div",{className:"fixed inset-0 bg-black/95 z-[10001] flex items-center justify-center p-4",onClick:()=>E(!1),role:"dialog","aria-modal":"true","aria-label":"Vista de recorte en tamaño completo",children:[_.jsx("button",{onClick:()=>E(!1),className:"absolute top-4 right-4 p-3 bg-white/10 hover:bg-white/20 rounded-full transition-colors cursor-pointer z-10","aria-label":"Cerrar vista ampliada",title:"Cerrar (Esc)",children:_.jsx("span",{className:"icon icon-close-small-white icon--lg"})}),_.jsxs("div",{className:"absolute top-4 left-4 bg-black/60 text-white px-4 py-3 rounded-lg text-sm backdrop-blur-sm",children:[_.jsx("p",{className:"font-semibold text-base mb-1",children:Y?.label||"Recorte"}),_.jsxs("p",{className:"text-xs text-gray-300",children:[Y?.width," × ",Y?.height," px"]})]}),_.jsx("div",{className:"relative max-w-[95vw] max-h-[95vh] w-full h-full flex items-center justify-center",onClick:e=>e.stopPropagation(),children:_.jsx("img",{src:m,alt:"Vista completa del recorte",className:"max-w-full max-h-full object-contain rounded-lg shadow-2xl"})}),_.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 bg-black/60 text-white px-4 py-2 rounded-lg text-xs text-center backdrop-blur-sm",children:"Click fuera de la imagen o presiona ESC para cerrar"})]})]}):null}function Xt({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 _.jsxs("div",{className:"flex items-center justify-center space-x-2 py-4",children:[_.jsxs("button",{onClick:()=>{e>1&&n(e-1)},disabled:r||e<=1,className:`\n px-3 py-2 text-sm font-medium rounded-md transition-colors disabled:cursor-default cursor-pointer\n ${r||e<=1?"text-gray-400 bg-gray-100 cursor-not-allowed":"text-gray-700 bg-white border border-gray-300 hover:bg-gray-50 focus:ring-2 focus:ring-blue-500"}\n `,children:[_.jsx("span",{className:"icon icon-arrow-left-white icon--sm"})," Anterior"]}),_.jsx("div",{className:"flex space-x-1",children:a.map((t,a)=>_.jsx(c.Fragment,{children:"..."===t?_.jsx("span",{className:"px-3 py-2 text-sm text-gray-500",children:"..."}):_.jsx("button",{onClick:()=>(t=>{t!==e&&n(t)})(t),disabled:r,className:`\n px-3 py-2 text-sm font-medium rounded-md transition-colors disabled:cursor-default cursor-pointer\n ${t===e?"bg-blue-600 text-white border border-blue-600":r?"text-gray-400 bg-gray-100 cursor-not-allowed":"text-gray-700 bg-white border border-gray-300 hover:bg-gray-50 focus:ring-2 focus:ring-blue-500"}\n `,children:t})},`page-${t}-${a}`))}),_.jsxs("button",{onClick:()=>{e<t&&n(e+1)},disabled:r||e>=t,className:`\n px-3 py-2 text-sm font-medium rounded-md transition-colors disabled:cursor-default cursor-pointer\n ${r||e>=t?"text-gray-400 bg-gray-100 cursor-not-allowed":"text-gray-700 bg-white border border-gray-300 hover:bg-gray-50 focus:ring-2 focus:ring-blue-500"}\n `,children:["Siguiente ",_.jsx("span",{className:"icon icon-arrow-right-white icon--sm"})]}),_.jsxs("div",{className:"text-sm text-gray-500 ml-4",children:["Página ",e," de ",t]})]})}function Jt({isOpen:e,onClose:t}){return e?_.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",style:{zIndex:9999},children:_.jsxs("div",{className:"bg-white rounded-lg p-6 max-w-md mx-4 shadow-xl",children:[_.jsxs("div",{className:"flex items-center mb-4",children:[_.jsx("svg",{className:"w-6 h-6 text-red-600 mr-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:_.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"})}),_.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Sesión Expirada"})]}),_.jsxs("div",{className:"mb-6",children:[_.jsx("p",{className:"text-gray-600 mb-2",children:"Su sesión ha expirado por seguridad."}),_.jsx("p",{className:"text-gray-600",children:"Es necesario recargar la página para obtener un nuevo token de acceso."})]}),_.jsx("div",{className:"flex justify-end space-x-3",children:_.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 Zt({items:e=[],currentLabel:t}){return e.length||t?_.jsx("nav",{"aria-label":"Breadcrumb",className:"mb-4",children:_.jsxs("ol",{className:"flex items-center gap-2 text-sm flex-wrap px-4 pt-2 pb-0",children:[e.map((e,t)=>_.jsxs("li",{className:"flex items-center gap-2",children:[_.jsx("button",{type:"button",onClick:e.onClick,className:"text-brand-blue-800 hover:text-brand-blue-1000 hover:underline cursor-pointer transition-colors font-medium","aria-label":`Ir a ${e.label}`,children:e.label}),_.jsx("span",{className:"text-gray-400","aria-hidden":"true",children:"/"})]},t)),t&&_.jsx("li",{className:"text-gray-700 font-medium","aria-current":"page",children:t})]})}):null}function en(){const[e,t]=l.useState(!1),[n,r]=l.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 I({endpoint:`/assets/${e}`,method:"DELETE",basePath:U,useJWT:!0})}catch(e){throw F(e)}}(e);return!1!==t.success}catch(e){return r(e.message),!1}finally{t(!1)}},loading:e,error:n,reset:()=>{r(null)}}}const tn=new Map;function nn(e,t=500){const[n,r]=l.useState(e);return l.useEffect(()=>{const n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n}function rn({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:c=10,_externalImage:u=null}){sessionStorage.removeItem("limbo_stock_selectedService"),sessionStorage.removeItem("limbo_stock_dynamicForm"),sessionStorage.removeItem("limbo_stock_stockImages"),sessionStorage.removeItem("limbo_stock_currentPage"),sessionStorage.removeItem("limbo_stock_paginationInfo"),sessionStorage.removeItem("limbo_portals_searchName"),sessionStorage.removeItem("limbo_portals_limit"),sessionStorage.removeItem("limbo_portals_currentPage"),sessionStorage.removeItem("limbo_portals_images"),sessionStorage.removeItem("limbo_portals_portalResults"),sessionStorage.removeItem("limbo_portals_paginationInfo");const[d,m]=l.useState({name:"",uploadedBy:"",dateFrom:"",dateTo:""}),h=nn(d.name,500),p=nn(d.uploadedBy,500),f=(()=>{switch(a){case"gallery-only":return["gallery"];case"upload-only":return["upload"];case"crop-only":return["cropper"];case"ia-only":return["ia"];default:return r}})(),g=e=>{if(e&&e.includes(":")&&3===e.split(":").length){const t=e.split(":")[2];return t.charAt(0).toUpperCase()+t.slice(1)}return{gallery:"Galería",upload:"Subir",cropper:"Recortar","upload:upload":"Subir archivo","upload:ai":"Generar con IA","upload:stock":"Buscar en Stock","upload:portals":"Otros portales"}[e]||e},b=()=>f.includes("gallery")?"gallery":f.includes("upload")?"upload":f.includes("cropper")?"cropper":f.includes("ia")?"ia":f[0]||"gallery",[y,v]=l.useState(b()),[x,w]=l.useState(null),[k,C]=l.useState([{tab:b(),label:g(b())}]),S=e=>{C(t=>{const n=t.findIndex(t=>t.tab===e);if(-1!==n)return n===t.length-1?t:t.slice(0,n+1);if((r=e)&&r.startsWith("upload:")&&3===r.split(":").length){const n=e.split(":"),r=`${n[0]}:${n[1]}`,a=t.findIndex(e=>e.tab===r);let i;if(-1===a){const e=t.findIndex(e=>"upload"===e.tab);i=-1===e?[...t,{tab:"upload",label:g("upload")},{tab:r,label:g(r)}]:[...t.slice(0,e+1),{tab:r,label:g(r)}]}else i=t.slice(0,a+1);i.push({tab:e,label:g(e)});const o=5;return i.length>o?i.slice(i.length-o):i}var r;if((e=>e&&e.startsWith("upload:")&&2===e.split(":").length)(e)){const n=t.findIndex(e=>"upload"===e.tab);let r;r=-1===n?[...t,{tab:"upload",label:g("upload")}]:t.slice(0,n+1),r.push({tab:e,label:g(e)});const a=5;return r.length>a?r.slice(r.length-a):r}if("upload"===e){const e=t.findIndex(e=>"upload"===e.tab);if(-1!==e)return t.slice(0,e+1)}const a=[...t,{tab:e,label:g(e)}];return a.length>5?a.slice(a.length-5):a})};l.useEffect(()=>{u&&(console.log("📸 Imagen externa detectada:",u),w(u),v("cropper"))},[u]);const[N,j]=l.useState(1),{isTokenExpired:E,handleTokenExpiredClose:$}=function(){const[e,t]=l.useState(!1),n=l.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=l.useCallback(()=>{t(!1),alert("El token ha expirado. La página se recargará para obtener un nuevo token."),window.location.reload()},[]);return l.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:z,loading:T,error:A,uploadedImage:M,reset:I}=function(){const[e,t]=l.useState(!1),[n,r]=l.useState(null),[a,i]=l.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 B(e,n,!1),r=t.result||t;return i(r),r}catch(e){return r(e.message),null}finally{t(!1)}},loading:e,error:n,uploadedImage:a,reset:()=>{r(null),i(null)}}}(),{deleteImg:L,loading:O,error:R,reset:D}=en(),F={limit:c,page:N,...h&&{name:h},...p&&{uploadedBy:p},...d.dateFrom&&{dateFrom:d.dateFrom},...d.dateTo&&{dateTo:d.dateTo}},U=f.includes("gallery"),{images:H,loading:V,error:K,pagination:G,invalidateCache:X,setImages:J}=function(e,t=!1,n={},r=!0){const[a,i]=l.useState([]),[o,s]=l.useState(r),[c,u]=l.useState(null),[d,m]=l.useState(null),[h,p]=l.useState(0),f=l.useMemo(()=>JSON.stringify(n),[n]);return l.useEffect(()=>{if(!r)return void s(!1);const e=`${f}`,t=tn.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&&(u("Error de autenticación: Verifica tus credenciales API"),s(!1));else try{const t=await q(n);if(!o)return;const r=t.result||t.data||[],s=t.pagination||null;i(r),m(s),u(null),p(0),tn.set(e,{data:r,pagination:s,timestamp:a})}catch(e){o&&(u(e.message),p(e=>e+1))}finally{o&&s(!1)}})(),()=>{o=!1}},[e,t,f,h,n,r]),{images:a,loading:o,error:c,pagination:d,setImages:i,invalidateCache:()=>{tn.delete(`${f}`)}}}(e,t,F,U),{refreshVariants:Z}=W(),ee=e=>!(i.hideActions?.includes(e)||!i.showActions?.includes(e)&&i.showActions?.length>0),te=[{id:"gallery",label:"Galería",feature:"gallery"},{id:"upload",label:"Subir nueva",feature:"upload"},{id:"cropper",label:"Recortador",hideNonActive:!0,feature:"cropper"}].filter(e=>f.includes(e.feature)),ne=async e=>{confirm("¿Estás seguro de que deseas eliminar esta imagen? Esta acción también eliminará todos sus recortes.")&&await L(e)&&(X(),j(1),J(t=>t.filter(t=>t.id!==e)),x&&x.id===e&&(w(null),v("gallery")))},re=()=>"crop-only"===a||1===f.length&&"cropper"===f[0]?"crop-only":f.includes("gallery")?"with-gallery":f.includes("upload")&&!f.includes("gallery")?"upload-only":"with-gallery",ae=k.length<=1?null:{items:k.slice(0,-1).map((e,t)=>({label:e.label,onClick:"subir"!==e.tab||"upload"!==e.tab?()=>(e=>{const t=k[e];t&&("cropper"!==t.tab&&w(null),v(t.tab),C(t=>t.slice(0,e+1)))})(t):void 0})),current:k[k.length-1].label};return _.jsxs(_.Fragment,{children:[ae&&_.jsx(Zt,{items:ae.items,currentLabel:ae.current}),i.showTabs&&"cropper"!=y&&_.jsx(P,{tabs:te,active:y,onChange:e=>{v(e),"upload"!==e&&I(),"gallery"!==e&&D(),S(e)}}),K&&_.jsxs("div",{className:"alert alert-danger",children:["Error al cargar imágenes: ",K]}),R&&_.jsxs("div",{className:"alert alert-danger",children:["Error al eliminar imagen: ",R]}),"gallery"===y&&_.jsxs(_.Fragment,{children:[O&&_.jsx(Q,{text:"Eliminando imagen..."}),_.jsx(Y,{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=>{w(e),f.includes("cropper")&&(v("cropper"),S("cropper"))},onDelete:ee("delete")?ne:null,deletingId:O,images:H,loading:V,error:K,filters:d,onFiltersChange:e=>{m(e),j(1)},filterConfig:i.galleryFilters||{},loadingConfig:i.galleryLoading||{},allowedActions:{select:ee("select"),download:ee("download"),copy:ee("copy"),delete:ee("delete"),crop:ee("crop")}}),G&&!V&&_.jsx(Xt,{currentPage:G.page||N,totalPages:G.pages||1,onPageChange:e=>{j(e)},disabled:V||O})]}),"upload"===y&&_.jsxs("div",{children:[T&&_.jsx(Q,{text:"Subiendo imagen..."}),A&&_.jsxs("div",{className:"alert alert-danger",children:["Error al subir imagen: ",A]}),M&&_.jsxs("div",{className:"alert alert-success absolute top-0 right-0 m-4",children:["✅ Imagen subida correctamente: ",M.filename]}),_.jsx(he,{onSelect: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(w(r),f.includes("cropper"))v("cropper"),S("cropper");else{const t=await z(e);t&&(X(),j(1),J(e=>[t,...e]),v("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}))}},onSubTabChange:e=>{S(`upload:${e}`)},onServiceChange:(e,t)=>{S(`upload:${e}:${t}`)},disabled:T,apiKey:e,prod:t})]}),"cropper"===y&&x&&_.jsx(Yt,{image:x,onSave:e=>{const t=re(),n=window.limboCore?.config?.getGlobal()||{},r=n.mode||"embed",a=n.autoHideOnComplete||!1;let i=[],l=null;switch(e.crops&&e.asset?(i=e.crops,l=e.asset):i=Array.isArray(e)?e:[e],l&&"with-gallery"===t&&(J(e=>[l,...e]),j(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&&X(),o.onCropsSaved&&o.onCropsSaved({crops:i,assetId:l?.id||x?.id,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropsSaved",{crops:i,assetId:l?.id||x?.id,instanceId:s}),t){case"with-gallery":w(null),v("gallery");break;case"upload-only":"modal"===r?window.limboCore?.modals?.closeAllModals():(w(null),v("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=re(),t=(window.limboCore?.config?.getGlobal()||{}).mode||"embed";switch(o.onCropperCancelled&&o.onCropperCancelled({assetId:x?.id,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropperCancelled",{assetId:x?.id,instanceId:s}),e){case"with-gallery":w(null),v("gallery");break;case"upload-only":"modal"===t?window.limboCore?.modals?.closeAllModals():(w(null),v("upload"));break;case"crop-only":"modal"===t?window.limboCore?.modals?.closeAllModals():window.limboCore?.events&&window.limboCore.events.emit("cropperClosed",{instanceId:s,reason:"cancelled"})}},onDelete:x?.id?()=>ne(x.id):null,onError:e=>{o.onCropperError&&o.onCropperError(e,s),window.limboCore?.events&&window.limboCore.events.emit("cropperError",{error:e,assetId:x?.id,instanceId:s}),console.error("Cropper error:",e)},deleting:O,onVariantCreated:(e,t)=>{Z(e)},onUpload:z,uploading:T}),"cropper"===y&&!x&&_.jsx("div",{className:"limbo-empty-state",children:_.jsx("p",{children:"Selecciona una imagen de la galería para comenzar a recortar."})}),_.jsx(Jt,{isOpen:E,onClose:$})]})}class an{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=j.createRoot(this.container),this.root.render(this._renderApp()),this.mounted=!0,this.eventManager.emit("ready",{instance:this})}catch(e){this.eventManager.emit("error",{instanceId:this.id,error:e.message})}return this}unmount(){return this.mounted?(this.root&&(this.root.unmount(),this.root=null),"button"===this.config.mode&&this.button,this.mounted=!1,this):this}open(){return"modal"!==this.config.mode&&"button"!==this.config.mode||(this.modal||this._createModal(),this.modal&&!this.modal.isOpened()&&(this.modal.open(),this.eventManager.emit("modal:open",{instance:this}))),this}close(){return this.modal&&this.modal.isOpened()&&(this.modal.close(),this.eventManager.emit("modal:close",{instance:this})),this}updateConfig(e){return this.config={...this.config,...e},this.mounted&&this.root.render(this._renderApp()),this.eventManager.emit("config:updated",{instance:this,newConfig:e}),this}destroy(){this.destroyed||(this.unmount(),this.modal&&(this.modal.destroy(),this.modal=null),this.button&&this.button.parentNode&&(this.button.parentNode.removeChild(this.button),this.button=null),this.eventManager.emit("destroy",{instance:this}),this.container=null,this.config=null,this.eventManager=null,this.modalManager=null,this.destroyed=!0)}getId(){return this.id}getMode(){return this.config.mode}isMounted(){return this.mounted}isDestroyed(){return this.destroyed}getContainer(){return this.container}getConfig(){return{...this.config}}isContainerInDOM(){return this.container&&document.contains(this.container)}_createModal(){if(this.modalManager&&"modal"===this.config.mode&&(this.modal=this.modalManager.createModal({title:this.config.title||"Limbo Image Manager",size:this.config.modalSize||"large",onOpen:()=>{const e={instance:this,mode:"modal",timestamp:Date.now()};this._emitDOMEvent("modal:open",e),this.config.callbacks?.onOpen&&this.config.callbacks.onOpen(e)},onClose:()=>{const e={instance:this,mode:"modal",timestamp:Date.now()};this._emitDOMEvent("modal:close",e),this.config.callbacks?.onClose&&this.config.callbacks.onClose(e),this.config.autoDestroy&&this.destroy()},onDestroy:()=>{this.modal=null}}),this.modal)){const e=this.modal.getBodyContainer();this.root=j.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 c.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"},c.createElement(rn,{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}))}_createCallbacks(){return{onSelect:e=>{const t=this._createStandardPayload(e,"select");this.config.callbacks?.onSelect&&this.config.callbacks.onSelect(t),this._emitDOMEvent("select",t)},onUpload:e=>{const t=this._createStandardPayload(e,"upload");this.config.callbacks?.onUpload&&this.config.callbacks.onUpload(t),this._emitDOMEvent("upload",t)},onError:e=>{const t={instance:this,error:{message:e.message||"Unknown error",code:e.code||"UNKNOWN",timestamp:Date.now()}};this.config.callbacks?.onError&&this.config.callbacks.onError(t.error),this._emitDOMEvent("error",t)},onClose:()=>{const e={instance:this,timestamp:Date.now()};this.config.callbacks?.onClose&&this.config.callbacks.onClose(),this._emitDOMEvent("close",e)}}}_createStandardPayload(e,t){const n={instance:this,eventType:t,timestamp:Date.now(),instanceId:this.id,mode:this.config.mode,features:this.config.features};return e&&(e.assetId||e.id?(n.assetId=e.assetId||e.id,n.variants=e.variants||[],n.master=e.master||{urlSigned:e.url||e.urlSigned,width:e.width,height:e.height,mime:e.mime||e.mimeType},n.fileName=e.fileName||e.name,n.mime=e.mime||e.mimeType,n.width=e.width,n.height=e.height,n.fileBlob=e.fileBlob||e.file,n.metadata={uploadedBy:e.uploadedBy,uploadedAt:e.uploadedAt||e.timestamp,size:e.size,...e.metadata}):Object.assign(n,e)),n}_emitDOMEvent(e,t){const n=new CustomEvent(`limbo:${e}`,{detail:t,bubbles:!0,cancelable:!0});(this.getContainer()||document).dispatchEvent(n),this.eventManager.emit(e,t)}_validateConfig(){if(!(this.config.auth?.apiKey||this.config.auth?.publicKey||this.config.auth?.token||this.config.apiKey||this.config.publicKey||this.config.token))throw new Error(`LimboInstance ${this.id}: Authentication is required. Provide either auth.publicKey (recommended) or auth.apiKey (for server-side only)`);if((this.config.auth?.apiKey||this.config.apiKey)&&"undefined"!=typeof window&&console.warn("⚠️ SECURITY WARNING: API Key detected in client-side code.\nThis is a security risk! Use publicKey instead for client applications.\nAPI Keys should only be used in server-side environments."),!["embed","modal","button"].includes(this.config.mode))throw new Error(`LimboInstance ${this.id}: invalid mode ${this.config.mode}`);if("embed"===this.config.mode&&!this.config.container)throw new Error(`LimboInstance ${this.id}: container is required for embed mode`);if("button"===this.config.mode&&!this.config.container)throw new Error(`LimboInstance ${this.id}: container is required for button mode`)}}class on{constructor(){this.instances=new Map,this.counter=0}create(e,t,n){const r="limbo-"+ ++this.counter,a=new an(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 sn{constructor(){this.config=null,this.instances=new Map,this.observer=null,this.initialized=!1}configure(e,t,n){return this.config={dataset:e.dataset||"data-limbo-input-file",return:e.return||"url",mode:e.mode||"modal",features:e.features||["gallery","upload","cropper"],crop:e.crop||"free",quality:e.quality||.9,format:e.format||"webp",modeUI:e.modeUI||"full",modalSize:e.modalSize||"medium",theme:e.theme||"light",compact:e.compact||!1,maxSize:e.maxSize||"10MB",formats:e.formats||["jpg","jpeg","png","webp"],minWidth:e.minWidth||null,minHeight:e.minHeight||null,maxWidth:e.maxWidth||null,maxHeight:e.maxHeight||null,buttonText:e.buttonText||"Seleccionar Imagen",buttonClass:e.buttonClass||"limbo-auto-button",buttonStyle:e.buttonStyle||"primary",showPreview:!1!==e.showPreview,allowMultiple:e.allowMultiple||!1,autoAssign:!1!==e.autoAssign,...e},this.configManager=t,this.eventManager=n,this._initialize(),this}cleanup(){this.observer&&(this.observer.disconnect(),this.observer=null),this.instances.forEach(({input:e,button:t})=>{this._restoreInput(e,t)}),this.instances.clear(),this.config=null,this.initialized=!1}getStats(){return{configured:null!==this.config,totalInputs:this.instances.size,dataset:this.config?.dataset,returnType:this.config?.return}}_initialize(){this.initialized||(this._scanExistingInputs(),this._setupObserver(),this.initialized=!0,this.eventManager.emit("autoInputs:initialized",{config:this.config,inputsFound:this.instances.size}))}_scanExistingInputs(){const e=`input[${this.config.dataset}]`;document.querySelectorAll(e).forEach(e=>this._processInput(e))}_processInput(e){const t=this._getInputId(e);if(this.instances.has(t))return;if(!this._validateInput(e))return;const n=this._createButton(e);this._hideInput(e),this._insertButton(e,n),this.instances.set(t,{input:e,button:n,config:this._getInputConfig(e)}),this.eventManager.emit("autoInputs:processed",{inputId:t,input:e,button:n})}_createButton(e){const t=document.createElement("button"),n=this._getInputConfig(e);t.type="button",t.textContent=n.buttonText||this.config.buttonText;const r=[this.config.buttonClass];return n.buttonClass&&n.buttonClass!==this.config.buttonClass&&r.push(n.buttonClass),t.className=r.join(" "),this._styleButton(t,n),this._attachButtonEvents(t,e),t.setAttribute("aria-label",n.buttonText||this.config.buttonText),t.setAttribute("data-limbo-trigger","true"),t.setAttribute("data-limbo-input-id",n.inputId),n.disabled&&(t.disabled=!0),t}_styleButton(e,t){const n=t.buttonStyle||this.config.buttonStyle,r=t.theme||this.config.theme,a=t.compact||this.config.compact,i={border:"none",borderRadius:"8px",cursor:"pointer",fontFamily:"inherit",fontSize:a?"12px":"14px",fontWeight:"500",transition:"all 0.2s ease",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:a?"6px 12px":"8px 16px",textDecoration:"none",userSelect:"none"},o={primary:{backgroundColor:"dark"===r?"#3b82f6":"#001978",color:"white",hoverBg:"dark"===r?"#2563eb":"#334793"},secondary:{backgroundColor:"dark"===r?"#374151":"#f3f4f6",color:"dark"===r?"#f9fafb":"#374151",border:"1px solid "+("dark"===r?"#4b5563":"#d1d5db"),hoverBg:"dark"===r?"#4b5563":"#e5e7eb"},outline:{backgroundColor:"transparent",color:"dark"===r?"#3b82f6":"#001978",border:"2px solid "+("dark"===r?"#3b82f6":"#001978"),hoverBg:"dark"===r?"#3b82f6":"#001978",hoverColor:"white"},ghost:{backgroundColor:"transparent",color:"dark"===r?"#f9fafb":"#374151",hoverBg:"dark"===r?"#374151":"#f3f4f6"}},s=o[n]||o.primary;Object.assign(e.style,{...i,...s});const l=s.backgroundColor,c=s.color;e.addEventListener("mouseenter",()=>{e.style.backgroundColor=s.hoverBg||s.backgroundColor,s.hoverColor&&(e.style.color=s.hoverColor),e.style.transform="translateY(-1px)",e.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor=l,e.style.color=c,e.style.transform="translateY(0)",e.style.boxShadow="none"}),t.disabled&&(e.style.opacity="0.5",e.style.cursor="not-allowed")}_attachButtonEvents(e,t){e.addEventListener("click",e=>{e.preventDefault(),this._handleButtonClick(t)})}_handleButtonClick(e){const t=this._getInputConfig(e),n=this._createModalConfig(t);this.eventManager.emit("autoInputs:modalRequest",{input:e,config:n,callback:async t=>await this._handleImageSelection(e,t)})}async _handleImageSelection(e,t){const n=this._getInputConfig(e);try{const r=await this._formatImageData(t,n);!1!==n.autoAssign&&(e.value=r),e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:resultReady",{detail:{imageData:t,input:e,value:r,config:n,assignment:{format:n.return,smartAssign:!1!==n.smartAssign,autoAssign:!1!==n.autoAssign},legacy:{imageData:t,formatted:this._createFormattedResult(t,n)}},bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:imageSelected",{detail:{imageData:t,input:e,value:r,config:n,formatted:this._createFormattedResult(t,n)},bubbles:!0})),this.eventManager.emit("autoInputs:imageSelected",{input:e,imageData:t,value:r,config:n})}catch(r){console.error("Error handling image selection:",r),e.dispatchEvent(new CustomEvent("limbo:error",{detail:{error:r.message,input:e,imageData:t,config:n},bubbles:!0})),this._handleImageSelectionLegacy(e,t)}}_handleImageSelectionLegacy(e,t){const n=this._getInputConfig(e),r=this._formatImageData(t,n);!1!==n.autoAssign&&(e.value=r),e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:imageSelected",{detail:{imageData:t,input:e,value:r,config:n,formatted:this._createFormattedResult(t,n)},bubbles:!0})),this.eventManager.emit("autoInputs:imageSelected",{input:e,imageData:t,value:r,config:n})}_createFormattedResult(e,t){return{url:e.url||e.path||"",base64:e.base64||e.dataUrl||"",assetId:e.assetId||e.id||"",fileName:e.fileName||e.filename||"",object:{url:e.url||e.path,assetId:e.assetId||e.id,fileName:e.fileName||e.filename,mime:e.mime||e.mime_type,width:e.width,height:e.height,size:e.size||e.file_size,created:e.created_at||e.created,metadata:e.metadata||{}},json:JSON.stringify({url:e.url||e.path,assetId:e.assetId||e.id,fileName:e.fileName||e.filename,mime:e.mime||e.mime_type,width:e.width,height:e.height,size:e.size||e.file_size}),metadata:{width:e.width,height:e.height,size:e.size||e.file_size,format:e.format||e.mime_type,quality:t.quality||this.config.quality,aspectRatio:e.width&&e.height?e.width/e.height:null}}}async _formatImageData(e,t=null){switch((t||{}).return||this.config.return||"url"){case"url":return e.url||e.path||"";case"base64":return e.base64||e.dataUrl||"";case"assetId":return e.assetId||e.id||"";case"fileName":return e.fileName||e.filename||"";case"object":return JSON.stringify({url:e.url||e.path,assetId:e.assetId||e.id,fileName:e.fileName||e.filename,mime:e.mime||e.mime_type,width:e.width,height:e.height,size:e.size||e.file_size,created:e.created_at||e.created});default:return JSON.stringify({url:e.url||e.path,assetId:e.assetId||e.id,fileName:e.fileName||e.filename,mime:e.mime||e.mime_type,width:e.width,height:e.height,size:e.size||e.file_size})}}_createModalConfig(e){return{mode:e.mode||this.config.mode||"modal",modeUI:e.modeUI||this.config.modeUI||"full",features:e.features||this.config.features,modalSize:e.modalSize||this.config.modalSize||"medium",title:e.description||this.config.title||"Seleccionar imagen",cropper:this._getCropperConfig(e),ui:{showActions:this._getUIActions(e),hideActions:[],showTabs:this._shouldShowTabs(e),theme:e.theme||this.config.theme,compact:e.compact||this.config.compact,showPreview:void 0!==e.showPreview?e.showPreview:this.config.showPreview},validation:{maxSize:e.maxSize||this.config.maxSize,formats:e.formats||this.config.formats,minWidth:e.minWidth||this.config.minWidth,minHeight:e.minHeight||this.config.minHeight,maxWidth:e.maxWidth||this.config.maxWidth,maxHeight:e.maxHeight||this.config.maxHeight,required:e.required||!1},behavior:{allowMultiple:e.allowMultiple||this.config.allowMultiple,closeOnSelect:!0,autoAssign:void 0!==e.autoAssign?e.autoAssign:this.config.autoAssign},returnConfig:{format:e.return||this.config.return,quality:e.quality||this.config.quality,outputFormat:e.format||this.config.format},inputMeta:{inputId:e.inputId,inputName:e.inputName,inputType:e.inputType,placeholder:e.placeholder}}}_getCropperConfig(e){const t=e.crop||this.config.crop;if(!t||"none"===t||"false"===t)return null;if("free"===t)return{aspectRatio:null,quality:e.quality||this.config.quality,format:e.format||this.config.format};const n={"1:1":1,"16:9":16/9,"4:3":4/3,"3:2":1.5,"2:1":2,square:1,landscape:16/9,portrait:3/4};if(n[t])return{aspectRatio:n[t],quality:e.quality||this.config.quality,format:e.format||this.config.format,minCropBoxWidth:e.minWidth||this.config.minWidth,minCropBoxHeight:e.minHeight||this.config.minHeight};if("string"==typeof t&&t.includes(":")){const[n,r]=t.split(":").map(Number);if(!isNaN(n)&&!isNaN(r)&&0!==r)return{aspectRatio:n/r,quality:e.quality||this.config.quality,format:e.format||this.config.format}}const r=parseFloat(t);return!isNaN(r)&&r>0?{aspectRatio:r,quality:e.quality||this.config.quality,format:e.format||this.config.format}:"object"==typeof t?{quality:e.quality||this.config.quality,format:e.format||this.config.format,...t}:null}_shouldShowTabs(e){const t=e.modeUI||this.config.modeUI||"full",n=e.features||this.config.features;return!["gallery-only","upload-only","crop-only","ia-only"].includes(t)&&n&&n.length>1}_getUIActions(e){const t=e.modeUI||this.config.modeUI||"full",n=e.features||this.config.features;let r=[];switch(t){case"gallery-only":case"upload-only":r=["select"];break;case"crop-only":r=["select","crop"];break;default:r=["select"],n.includes("cropper")&&r.push("crop"),n.includes("gallery")&&(r.push("download","copy"),this.config.allowDelete&&r.push("delete"))}return r}_getInputId(e){return e.id||e.name||`limbo-auto-${Date.now()}-${Math.random()}`}_validateInput(e){return e instanceof HTMLInputElement}_getInputConfig(e){const t=e=>e?e.split(",").map(e=>e.trim()):null,n=e=>{if(!e)return null;const t=e.match(/^(\d+(?:\.\d+)?)(MB|KB|B)?$/i);if(!t)return null;const n=parseFloat(t[1]);switch((t[2]||"B").toUpperCase()){case"MB":return 1024*n*1024;case"KB":return 1024*n;default:return n}},r=(e,t=!1)=>null===e?t:"true"===e||"1"===e||""===e,a=e=>e?parseFloat(e):null;return{return:e.getAttribute("data-limbo-return")||this.config.return,mode:e.getAttribute("data-limbo-mode")||this.config.mode,features:t(e.getAttribute("data-limbo-features"))||this.config.features,crop:e.getAttribute("data-limbo-crop")||this.config.crop,quality:a(e.getAttribute("data-limbo-quality"))||this.config.quality,format:e.getAttribute("data-limbo-format")||this.config.format,modeUI:e.getAttribute("data-limbo-mode-ui")||this.config.modeUI,modalSize:e.getAttribute("data-limbo-modal-size")||this.config.modalSize,theme:e.getAttribute("data-limbo-theme")||this.config.theme,compact:r(e.getAttribute("data-limbo-compact"),this.config.compact),maxSize:n(e.getAttribute("data-limbo-max-size"))||n(this.config.maxSize),formats:t(e.getAttribute("data-limbo-formats"))||this.config.formats,minWidth:a(e.getAttribute("data-limbo-min-width"))||this.config.minWidth,minHeight:a(e.getAttribute("data-limbo-min-height"))||this.config.minHeight,maxWidth:a(e.getAttribute("data-limbo-max-width"))||this.config.maxWidth,maxHeight:a(e.getAttribute("data-limbo-max-height"))||this.config.maxHeight,buttonText:e.getAttribute("data-limbo-button-text")||this.config.buttonText,buttonStyle:e.getAttribute("data-limbo-button-style")||this.config.buttonStyle,buttonClass:e.getAttribute("data-limbo-button-class")||this.config.buttonClass,showPreview:r(e.getAttribute("data-limbo-show-preview"),this.config.showPreview),allowMultiple:r(e.getAttribute("data-limbo-allow-multiple"),this.config.allowMultiple),autoAssign:r(e.getAttribute("data-limbo-auto-assign"),this.config.autoAssign),placeholder:e.getAttribute("data-limbo-placeholder"),description:e.getAttribute("data-limbo-description"),required:r(e.getAttribute("data-limbo-required"),!1),disabled:r(e.getAttribute("data-limbo-disabled"),!1),inputId:e.id||e.name||this._generateInputId(e),inputName:e.name,inputType:e.type}}_generateInputId(){return`limbo-auto-input-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}_hideInput(e){e.style.display="none"}_insertButton(e,t){e.parentNode.insertBefore(t,e.nextSibling)}_restoreInput(e,t){e.style.display="",t&&t.parentNode&&t.parentNode.removeChild(t)}_setupObserver(){this.observer=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&this._scanNodeForInputs(e)})})}),this.observer.observe(document.body,{childList:!0,subtree:!0})}_scanNodeForInputs(e){const t=`input[${this.config.dataset}]`;e.matches&&e.matches(t)&&this._processInput(e);const n=e.querySelectorAll&&e.querySelectorAll(t);n&&n.forEach(e=>this._processInput(e))}}class ln{constructor(){this.listeners=new Map}emit(e,t={}){this._emitDOMEvent(e,t),this._executeListeners(e,t)}on(e,t){return this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),()=>this.off(e,t)}off(e,t){const 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(t){console.error(`Error executing listener for ${e}:`,t)}})}getStats(){const e={};return this.listeners.forEach((t,n)=>{e[n]=t.length}),e}}class cn{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 un(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 un{constructor(e,t,n){this.id=e,this.config={title:t.title||"Limbo",content:t.content||null,showCloseButton:!1!==t.showCloseButton,backdrop:!1!==t.backdrop,keyboard:!1!==t.keyboard,focus:!1!==t.focus,animation:!1!==t.animation,size:t.size||"large",onOpen:t.onOpen||null,onClose:t.onClose||null,onDestroy:t.onDestroy||null,...t},this.manager=n,this.element=null,this.backdrop=null,this.isOpen=!1,this.previousFocus=null,this._create()}_create(){this._createBackdrop(),this._createModal(),this._attachEvents()}_createBackdrop(){this.config.backdrop&&(this.backdrop=document.createElement("div"),this.backdrop.className="limbo-modal-backdrop",this.backdrop.style.cssText=`\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.5);\n z-index: ${this.manager._getNextZIndex()};\n opacity: 0;\n transition: opacity 0.3s ease;\n `,this.backdrop.addEventListener("click",e=>{e.target===this.backdrop&&this.close()}))}_createModal(){this.element=document.createElement("div"),this.element.className=`limbo-modal limbo-modal--${this.config.size}`,this.element.id=this.id,this.element.role="dialog",this.element.setAttribute("aria-modal","true"),this.element.setAttribute("aria-labelledby",`${this.id}-title`),this.element.tabIndex=-1;const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t={small:e?"width: 100%; height: 100%;":"max-width: 400px;",medium:e?"width: 100%; height: 100%;":"max-width: 600px;",large:e?"width: 100%; height: 100%;":"max-width: 1300px;",xlarge:e?"width: 100%; height: 100%;":"max-width: 90dvw;"},n=e?`\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n transform: translateY(100%);\n width: 100%;\n height: 100%;\n max-width: none;\n max-height: none;\n border-radius: 0;\n background: white;\n z-index: ${this.manager._getNextZIndex()+1};\n opacity: 1;\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n padding-top: env(safe-area-inset-top);\n padding-left: env(safe-area-inset-left);\n padding-right: env(safe-area-inset-right);\n padding-bottom: env(safe-area-inset-bottom);\n `:`\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%) scale(0.8);\n ${t[this.config.size]}\n width: 90%;\n max-height: 90vh;\n background: white;\n border-radius: 16px;\n box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);\n z-index: ${this.manager._getNextZIndex()+1};\n opacity: 0;\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n `;this.element.style.cssText=n,this._createHeader(),this._createBody(),document.body.appendChild(this.backdrop),document.body.appendChild(this.element)}_createHeader(){const e=document.createElement("div");e.className="limbo-modal-header";const t=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e.style.cssText=`\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: ${t?"16px 20px":"20px 24px"};\n border-bottom: 1px solid #e9ecef;\n background: #f8f9fa;\n ${t?"position: sticky; top: 0; z-index: 10;":""}\n min-height: ${t?"60px":"auto"};\n `;const n=document.createElement("h2");if(n.id=`${this.id}-title`,n.className="limbo-modal-title",n.textContent=this.config.title,n.style.cssText="\n margin: 0;\n font-size: 18px;\n font-weight: 600;\n color: #001978;\n flex: 1;\n margin-right: 16px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n ",e.appendChild(n),this.config.showCloseButton){const n=document.createElement("button");n.type="button",n.className="limbo-modal-close",n.innerHTML="✕",n.setAttribute("aria-label","Cerrar modal"),n.style.cssText=`\n background: none;\n border: none;\n font-size: ${t?"28px":"24px"};\n color: #6c757d;\n cursor: pointer;\n padding: ${t?"8px":"4px"};\n border-radius: 4px;\n transition: all 0.2s ease;\n min-width: ${t?"44px":"auto"};\n min-height: ${t?"44px":"auto"};\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n `,n.addEventListener("mouseenter",()=>{n.style.backgroundColor="#f8f9fa",n.style.color="#001978"}),n.addEventListener("mouseleave",()=>{n.style.backgroundColor="transparent",n.style.color="#6c757d"}),n.addEventListener("click",()=>this.close()),e.appendChild(n)}this.element.appendChild(e)}_createBody(){const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t=document.createElement("div");t.className="limbo-modal-body",t.id=`${this.id}-body`,t.style.cssText=`\n flex: 1;\n overflow-y: auto;\n padding: 0;\n -webkit-overflow-scrolling: touch;\n ${e?"height: 100%; overscroll-behavior: contain;":""}\n `,this.config.content&&("string"==typeof this.config.content?t.innerHTML=this.config.content:this.config.content instanceof Element&&t.appendChild(this.config.content)),this.element.appendChild(t)}_attachEvents(){this._originalBodyOverflow=document.body.style.overflow}open(){if(this.isOpen)return this;window.limbo&&window.limbo.core&&window.limbo.core.keyboard?(window.limbo.core.keyboard.pushFocus(document.activeElement),window.limbo.core.keyboard.setActiveModal(this.element)):this.previousFocus=document.activeElement,document.body.style.overflow="hidden";const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);return requestAnimationFrame(()=>{this.backdrop&&(this.backdrop.style.opacity="1"),this.element.style.opacity="1",this.element.style.transform=e?"translateY(0%)":"translate(-50%, -50%) scale(1)"}),this.isOpen=!0,this.config.focus&&setTimeout(()=>{if(window.limbo&&window.limbo.core&&window.limbo.core.keyboard)window.limbo.core.keyboard.focusFirst(this.element);else{const e=this.getFocusableElements()[0];e&&e.focus()}},300),this.config.onOpen&&this.config.onOpen(this),this}close(){if(!this.isOpen)return this;const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);return this.backdrop&&(this.backdrop.style.opacity="0"),this.element.style.opacity="0",this.element.style.transform=e?"translateY(100%)":"translate(-50%, -50%) scale(0.8)",setTimeout(()=>{this._cleanup()},300),this.isOpen=!1,window.limbo&&window.limbo.core&&window.limbo.core.keyboard&&(window.limbo.core.keyboard.setActiveModal(null),window.limbo.core.keyboard.releaseFocus()),this.config.onClose&&this.config.onClose(this),this}destroy(){this.close(),this.manager._removeModal(this),this.config.onDestroy&&this.config.onDestroy(this)}getBodyContainer(){return this.element.querySelector(".limbo-modal-body")}getFocusableElements(){return Array.from(this.element.querySelectorAll(this.manager.focusableSelectors))}getId(){return this.id}isOpened(){return this.isOpen}getConfig(){return{...this.config}}_cleanup(){document.body.style.overflow=this._originalBodyOverflow||"",this.previousFocus&&"function"==typeof this.previousFocus.focus&&this.previousFocus.focus(),this.backdrop&&this.backdrop.parentNode&&this.backdrop.parentNode.removeChild(this.backdrop),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class dn{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(e){console.warn("Could not save compact preference:",e)}}_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(e){console.error("Error in compact mode change callback:",e)}})}_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);return["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)}),["--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(e){console.warn("Could not save theme preference:",e)}}_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(e){console.error("Error in theme change callback:",e)}})}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 mn=new class{constructor(){this.config=new n,this.instances=new on,this.autoInputs=new sn,this.events=new ln,this.modals=new cn,this.theme=new dn,this.containerQueryDetector=z,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},A={...A,...t},A.authMode||(A.token?A.authMode="manual":A.authMode="session"),this.config}setToken(e){return function(e){A.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(e){console.warn("⚠️ Limbo: Error procesando nuevo input:",e)}}),r}init(e){const t=this._mapLegacyOptions(e);return this.create(t)}getInstances(){return this.instances.getAll()}destroy(){this.instances.destroyAll(),this.autoInputs.cleanup(),this.events.cleanup(),this.theme.removeTheme()}_mapLegacyOptions(e){return{container:e.container||"#image-manager",mode:"embed",features:["gallery","upload","cropper"],apiKey:e.apiKey,prod:e.prod||!1,url:void 0===e.url||e.url}}_setupInternalListeners(){this.events.on("autoInputs:modalRequest",({config:e,callback:t})=>{this._handleAutoInputModalRequest({config:e,callback:t})})}_handleAutoInputModalRequest({config:e,callback:t}){const n=this.create({...e,mode:"modal",autoDestroy:!0,callbacks:{onSelect:e=>{t(e),n.close()},onClose:()=>{}}});n.open()}openGallery(e={}){const t=this.create({mode:"modal",modeUI:"gallery-only",features:["gallery"],autoDestroy:!0,modal:{title:e.title||"Seleccionar Imagen",size:e.size||"large"},callbacks:{onSelect:n=>{e.onSelect?.(n),!1!==e.autoClose&&t.close()}},...e});return t.open(),t}openUploader(e={}){const t=!1!==e.redirectToGallery?["upload","gallery"]:["upload"],n=this.create({mode:"modal",modeUI:!1!==e.redirectToGallery?"full":"upload-only",features:t,autoDestroy:!0,modal:{title:e.title||"Subir Imagen",size:e.size||"medium"},callbacks:{onUpload:t=>{e.onUpload?.(t),!1===e.autoClose||e.redirectToGallery||n.close()}},...e});return n.open(),n}openCropper(e,t={}){if(!e)throw new Error("Limbo.openCropper: imageUrl es requerido");const n={url:e,filename:t.filename||"image.jpg",width:t.width||1920,height:t.height||1080,mime_type:t.mimeType||"image/jpeg",id:t.assetId||`external-${Date.now()}`},r=this.create({mode:"modal",modeUI:"crop-only",features:["cropper"],autoDestroy:!0,modal:{title:t.title||"Recortar Imagen",size:"xlarge"},cropper:{mandatoryCrops:t.mandatoryCrops||[],allowCustomCrops:!1!==t.allowCustomCrops,enforceRequiredCrops:!1!==t.enforceRequiredCrops},callbacks:{onCropperComplete:e=>{t.onComplete?.(e),!1!==t.autoClose&&r.close()},onCropperCancelled:e=>{t.onCancelled?.(e),!1!==t.autoClose&&r.close()},onCropperError:e=>{t.onError?.(e)}},_externalImage:n,...t});return r.open(),r}createInlineGallery(e,t={}){return this.create({container:e,mode:"embed",modeUI:"gallery-only",features:["gallery"],callbacks:{onSelect:t.onSelect,onDelete:t.onDelete},...t})}createInlineUploader(e,t={}){return this.create({container:e,mode:"embed",modeUI:"upload-only",features:["upload"],callbacks:{onUpload:t.onUpload},...t})}createStandaloneCropper(e,t,n={}){if(!e)throw new Error("Limbo.createStandaloneCropper: container es requerido");if(!t)throw new Error("Limbo.createStandaloneCropper: imageUrl es requerido");const r={url:t,filename:n.filename||"image.jpg",width:n.width||1920,height:n.height||1080,mime_type:n.mimeType||"image/jpeg",id:n.assetId||`external-${Date.now()}`};return this.create({container:e,mode:"embed",modeUI:"crop-only",features:["cropper"],autoHideOnComplete:!1!==n.autoHideOnComplete,cropper:{mandatoryCrops:n.mandatoryCrops||[],allowCustomCrops:!1!==n.allowCustomCrops,enforceRequiredCrops:!1!==n.enforceRequiredCrops},callbacks:{onCropperComplete:n.onComplete,onCropperCancelled:n.onCancelled,onCropperError:n.onError},_externalImage:r,...n})}createFullSelector(e,t={}){return this.create({container:e,mode:t.mode||"embed",modeUI:"full",features:["gallery","upload","cropper"],callbacks:{onSelect:t.onSelect,onUpload:t.onUpload,onDelete:t.onDelete,onCropsSaved:t.onCropsSaved},...t})}};return"undefined"!=typeof window&&(window.Limbo=mn),"undefined"!=typeof window&&document.querySelector("#root")&&(mn.configure({prod:!1,publicKey:"pk_e464fd744106b7a8d63d453c4bd02582",authMode:"session"}),mn.create({container:"#root",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],title:"Limbo Image Manager - Development",url:!0}),mn.configureAutoInputs({dataset:"data-limbo-input-file",return:"url",features:["gallery","upload","cropper"],modeUI:"full",modalSize:"large",title:"Seleccionar imagen",crops:"free",allowDelete:!1})),mn});
|
|
3
|
+
zt.$define(),Ft.$define(),Dt.$define(),Lt.$define(),At.$define(),Rt.$define(),It.$define(),Vt.$define();class Kt{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(e){return console.warn("Error moving image:",e),!1}},moveTo:(e,t)=>{if(!this.image)return!1;try{return this.image.$moveTo(e,t),!0}catch(e){return console.warn("Error moving image to position:",e),!1}},zoom:e=>{if(!this.image)return!1;try{return this.image.$zoom(e),!0}catch(e){return console.warn("Error zooming image:",e),!1}},rotate:e=>{if(!this.image)return!1;try{const t=e*Math.PI/180;return this.image.$rotate(t),!0}catch(e){return console.warn("Error rotating image:",e),!1}},scale:(e,t=e)=>{if(!this.image)return!1;try{return this.image.$scale(e,t),!0}catch(e){return console.warn("Error scaling image:",e),!1}},center:(e="contain")=>{if(!this.image)return!1;try{return this.image.$center(e),!0}catch(e){return console.warn("Error centering image:",e),!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(e){return console.warn("Error setting transform:",e),!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(e){return console.warn("Error setting zoom level:",e),!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(e){return console.warn("Error fitting to canvas:",e),!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(e){return console.warn("Error setting coverage:",e),!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(e){return console.warn("Error setting aspect ratio:",e),!1}},move:(e,t)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$move(e,t),!0}catch(e){return console.warn("Error moving selection:",e),!1}},zoom:e=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$zoom(e),!0}catch(e){return console.warn("Error zooming selection:",e),!1}},change:(e,t,n,r,a)=>{if(!this.selectionElement)return!1;try{return this.selectionElement.$change(e,t,n,r,a),!0}catch(e){return console.warn("Error changing selection:",e),!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(e){return console.warn("Error setting selection:",e),!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(e){return console.warn("Error exporting to canvas:",e),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(e){return console.warn("Error setting background:",e),!1}},setScaleStep:e=>{if(!this.canvasElement)return!1;try{return this.canvasElement.scaleStep=e,!0}catch(e){return console.warn("Error setting scale step:",e),!1}},setDisabled:e=>{if(!this.canvasElement)return!1;try{return this.canvasElement.disabled=e,!0}catch(e){return console.warn("Error setting disabled state:",e),!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(t){console.warn("Error in setup:",t),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 Gt(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;u.type!==`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(t){URL.revokeObjectURL(i),n(e)}},a.onerror=()=>{URL.revokeObjectURL(i),n(e)},a.src=i})}(u,o));const m=window.URL.createObjectURL(d),h=document.createElement("a");return h.href=m,h.download=l,h.style.display="none",document.body.appendChild(h),h.click(),setTimeout(()=>{window.URL.revokeObjectURL(m),document.body.removeChild(h)},100),i&&i(l),s&&s.announce(`${l} descargado correctamente`),!0}catch(e){return console.error("Error downloading image:",e),o&&o(e),s&&s.announce(`Error al descargar la imagen: ${e.message}`),!1}}const Qt=Object.freeze(Object.defineProperty({__proto__:null,default:Gt,downloadImage:Gt},Symbol.toStringTag,{value:"Module"}));function Yt({image:e,onSave:t,onCancel:n,onDelete:r,onError:a=null,deleting:i=!1,onVariantCreated:o=null,onUpload:s=null,uploading:c=!1}){const[u,d]=l.useState(!1),[m,h]=l.useState(null),[p,f]=l.useState(!1),[g,b]=l.useState(!0),[y,v]=l.useState(!0),[x,w]=l.useState({x:20,y:100}),[k,C]=l.useState(!1),[S,N]=l.useState({x:0,y:0}),[j,E]=l.useState(!1),[$,z]=l.useState(!0),[T,P]=l.useState(!1),[A,M]=l.useState({horizontal:!1,vertical:!1}),[I,L]=l.useState(!1),[O,R]=l.useState(!1),[D,F]=l.useState(!1),[U,q]=l.useState(!1),[B]=l.useState(()=>{if(!e||!e.filename)return"image";const[t]=e.filename.split(".");return t}),W=l.useMemo(()=>{const e=window.limboCore?.config?.getGlobal()||{};return{mandatoryCrops:e.cropper?.mandatoryCrops||[],allowCustomCrops:!1!==e.cropper?.allowCustomCrops,showDimensionInputs:!0===e.cropper?.showDimensionInputs}},[]),[V,K]=l.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,savedState:null})):[{id:"crop-default-0",label:B,width:e.width||1920,height:e.height||1080,required:!1,isCustom:!0,confirmed:!1,savedState:null}]),[G,Q]=l.useState(0),Y=V[G],X=l.useMemo(()=>Y&&Y.width&&Y.height?Y.width/Y.height:"",[Y]),J=l.useMemo(()=>{const e=50;return X&&""!==X?X>=1?{minWidth:e,minHeight:e/X}:{minWidth:e*X,minHeight:e}:{minWidth:e,minHeight:e}},[X]),[Z,ee]=l.useState(!1),[te,ne]=l.useState([]),[ae,ie]=l.useState(null),oe=window.limboCore?.accessibilityManager,{createCropVariant:se,loading:le,error:ce}=function(){const[e,t]=l.useState(!1),[n,r]=l.useState(null),[a,i]=l.useState(null),o=async(e,n)=>{if(!e||!n)return r("ID de asset y configuración de variante son requeridos"),null;t(!0),r(null),i(null);try{const t=await H(e,{variant_name:n.name,width:n.width,height:n.height,crop_params:n.crop_params,preset_aspect:n.preset_aspect,preset_size:n.preset_size,output_format:n.output_format});if(t?.result)return i(t.result),t.result;throw new Error("No se pudo crear la variante")}catch(e){return console.error("Error creating variant:",e),r(e.message||"Error desconocido al crear variante"),null}finally{t(!1)}};return{createVariant:o,createCropVariant:async(e,t,n={})=>{const r={name:n.name||`crop_${Date.now()}`,width:n.width||800,height:n.height||600,output_format:n.format||"webp",crop_params:{x:t.x||0,y:t.y||0,width:t.width||1,height:t.height||1}};return await o(e,r)},loading:e,error:n,createdVariant:a,reset:()=>{r(null),i(null)}}}(),ue=((e,t={})=>{const n=l.useRef(null),r=l.useRef(null),a=l.useRef(null),i=l.useRef(null),[o,s]=l.useState(null),[c,u]=l.useState(null),[d,m]=l.useState(!1),[h,p]=l.useState(!0),[f,g]=l.useState(0),b={aspectRatio:"",shade:!0,paspartuFactor:.85,...t};l.useEffect(()=>{n.current&&r.current&&a.current&&(i.current=new Kt(n,r,a),m(!0))},[]),l.useEffect(()=>{if(i.current)return i.current.setupEventListeners({onSelectionChange:e=>{s(e)},onImageTransform:()=>{g(e=>e+1)}})},[d]),l.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&&u({naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,currentWidth:t.width,currentHeight:t.height})})()},[e]),l.useEffect(()=>{i.current&&d&&i.current.selection.setAspectRatio(b.aspectRatio)},[b.aspectRatio,d]),l.useEffect(()=>{i.current&&d&&i.current.canvas.setBackground(b.shade)},[b.shade,d]);const y=l.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=l.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=l.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:c,isReady:d,canExport:h,transformVersion:f},transform:y(),selection:v(),utils:x(),manager:i.current}})(e,{aspectRatio:X||null,showGrid:g,shade:y,initialCoverage:.5,paspartuFactor:.85}),{refs:de,state:me,transform:he,selection:pe,utils:fe}=ue,{canvasRef:ge,imageRef:be,selectionRef:ye}=de,{cropData:ve,imageInfo:xe,canExport:we,transformVersion:ke}=me,Ce=l.useMemo(()=>xe||{naturalWidth:e.width||1920,naturalHeight:e.height||1080,currentWidth:e.width||1920,currentHeight:e.height||1080},[xe,e.width,e.height]),Se=l.useCallback(()=>b(e=>!e),[]),Ne=l.useCallback(()=>v(e=>!e),[]),je=l.useCallback(()=>R(e=>!e),[]),Ee=l.useCallback(()=>F(e=>!e),[]),$e=l.useCallback(()=>q(e=>!e),[]),_e=l.useCallback(()=>he.center(),[he]),ze=l.useCallback(()=>pe.center(),[pe]),Te=l.useCallback(()=>pe.reset(),[pe]),Pe=l.useCallback((e,t)=>he.move(e,t),[he]),Ae=l.useCallback(e=>he.zoom(e),[he]),Me=l.useCallback(e=>he.rotate(e),[he]),Ie=l.useCallback(e=>{pe.setCoverage(e)},[pe]),Le=l.useCallback(()=>{M(e=>{const t=!e.horizontal;return he.flipHorizontal(),{...e,horizontal:t}})},[he]),Oe=l.useCallback(()=>{M(e=>{const t=!e.vertical;return he.flipVertical(),{...e,vertical:t}})},[he]),Re=l.useCallback(()=>{if(!ue.manager||!me.isReady)return null;try{const e=ve?{...ve}:null;let t=null;if(ye.current){const e=ye.current;t={x:e.x??0,y:e.y??0,width:e.width??0,height:e.height??0}}let n=null;if(be.current){const e=be.current.$getTransform?.();e&&Array.isArray(e)&&(n=[...e])}const r={cropData:e,selectorState:t,imageTransform:n,flipState:{horizontal:A.horizontal,vertical:A.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}},[ue.manager,me.isReady,ve,A,G,be,ye]),De=l.useCallback(e=>{const t=V[e];if(!t||!t.savedState)return console.log(`[CropperView] ℹ️ No hay estado guardado para crop ${e}, centrando...`),void setTimeout(()=>{_e(),setTimeout(()=>ze(),100)},100);if(ue.manager&&me.isReady)try{const{savedState:n}=t;if(console.log(`[CropperView] ♻️ Restaurando estado del crop ${e}:`,n),n.imageTransform&&be.current&&Array.isArray(n.imageTransform)&&setTimeout(()=>{if(be.current&&be.current.$setTransform){const[e,t,r,a,i,o]=n.imageTransform;be.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&&ye.current){const{x:e,y:t,width:r,height:a}=n.selectorState;setTimeout(()=>{ye.current&&(ye.current.x=e,ye.current.y=t,ye.current.width=r,ye.current.height=a,ye.current.$render&&ye.current.$render(),console.log(`[CropperView] ✅ Selector restaurado: ${r}×${a} en (${e}, ${t})`))},150)}n.flipState&&M({horizontal:n.flipState.horizontal??!1,vertical:n.flipState.vertical??!1}),console.log("[CropperView] ✨ Estado restaurado completamente")}catch(e){console.error("Error restoring crop state:",e),setTimeout(()=>{_e(),setTimeout(()=>ze(),100)},100)}else console.warn("Cropper not ready for state restoration")},[V,ue.manager,me.isReady,_e,ze,ye,be]),Fe=l.useCallback(()=>{for(let e=0;e<V.length;e++){const t=V[e];if(!t.label||""===t.label.trim())return e}return-1},[V]),Ue=l.useCallback(async e=>{e!==G&&(P(!0),Re(),await new Promise(e=>setTimeout(e,100)),Q(e),await new Promise(e=>setTimeout(e,250)),De(e),await new Promise(e=>setTimeout(e,200)),P(!1))},[G,Re,De]),qe=l.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]),Be=l.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=l.useCallback(e=>{const t=Y[e];let n=100;if(ge.current&&xe){const e=ge.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=pe.getData?.();pe.setAspectRatio(i),o&&void 0!==o.x&&setTimeout(()=>{pe.set?.(o.x,o.y,o.width,o.height)},50)},[G,Y,pe,ge,xe]),We=l.useCallback(e=>{K(t=>t.map((t,n)=>n===G?{...t,label:e}:t))},[G]),Ve=l.useCallback((e,t=null)=>{if(t=t||V[e].label,!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]),Ke=l.useCallback(async()=>{if(!we)return null;try{const t=await pe.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(e){return console.warn("Error generating preview:",e),null}},[we,e.mime_type,pe]),Ge=l.useCallback(async()=>{if(u)return d(!1),h(null),void f(!1);if(we){d(!0),f(!0);try{const e=await Ke();e?h(e):(d(!1),alert("No se puede exportar el recorte por restricciones de CORS en la imagen original."))}finally{f(!1)}}else alert("No se puede exportar el recorte por restricciones de CORS en la imagen original.")},[we,Ke,u]),Qe=l.useCallback(e=>{e.target.closest(".preview-modal-header")&&(C(!0),N({x:e.clientX-x.x,y:e.clientY-x.y}))},[x]),Ye=l.useCallback(e=>{k&&(e.preventDefault(),w({x:e.clientX-S.x,y:e.clientY-S.y}))},[k,S]),Xe=l.useCallback(()=>{C(!1)},[]),Je=l.useCallback(e=>{if(!e.target.closest(".preview-modal-header"))return;const t=e.touches[0];C(!0),N({x:t.clientX-x.x,y:t.clientY-x.y})},[x]),Ze=l.useCallback(e=>{if(!k)return;e.preventDefault();const t=e.touches[0];w({x:t.clientX-S.x,y:t.clientY-S.y})},[k,S]),et=l.useCallback(()=>{C(!1)},[]);l.useEffect(()=>{if(k)return document.addEventListener("mousemove",Ye),document.addEventListener("mouseup",Xe),document.addEventListener("touchmove",Ze,{passive:!1}),document.addEventListener("touchend",et),()=>{document.removeEventListener("mousemove",Ye),document.removeEventListener("mouseup",Xe),document.removeEventListener("touchmove",Ze),document.removeEventListener("touchend",et)}},[k,Ye,Xe,Ze,et]),l.useEffect(()=>{if(!j)return;const e=e=>{"Escape"===e.key&&E(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[j]);const tt=l.useCallback(async(t,n=null)=>{const r=V[t];if(!r)throw new Error(`Crop ${t} no encontrado`);let a;if(r.savedState&&r.savedState.cropData)a=r.savedState.cropData,console.log(`[CropperView] Usando savedState para crop ${t}:`,a);else{if(t!==G||!ve)throw new Error(`No hay datos de recorte para el crop "${r.label}". Ajusta el recorte antes de guardar.`);a=ve,console.log(`[CropperView] Usando cropData actual para crop activo ${t}:`,a)}if(!a.x&&0!==a.x||!a.y&&0!==a.y||!a.width||!a.height)throw new Error(`Datos de recorte inválidos para "${r.label}"`);if(!Ce?.naturalWidth||!Ce?.naturalHeight)throw new Error("Información de imagen no disponible");const{x:i,y:s,width:l,height:c}=a,{naturalWidth:u,naturalHeight:d}=Ce,m={x:i/u,y:s/d,width:l/u,height:c/d},h=Math.min(r.width,5e3),p=Math.min(r.height,5e3),f=`${r.label||"crop"}_${h}_${p}`,g=n||e.id,b=await se(g,m,{name:f,width:h,height:p,format:globalThis.downloadFormat||"webp",quality:90});if(b)return oe?.announceSuccess(`Recorte creado: ${f}`),o?.(g,b),b;throw new Error("No se pudo crear la variante")},[V,G,ve,Ce,se,e.id,o,oe]),nt=l.useCallback(async()=>{if(!we){const e="No se puede exportar el recorte por restricciones de CORS en la imagen original.";return oe?.announceError(e),void alert(e)}if(!me.isReady){const e="El cropper aún no está inicializado. Espera un momento e inténtalo de nuevo.";return oe?.announceError(e),void alert(e)}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 tt(G,n);a&&t(r?{crops:[a],asset:r}:a)}catch(e){console.warn("Error creating crop variant:",e);const t=e.message||"No se pudo crear el recorte. Inténtalo de nuevo.";oe?.announceError(t),alert(t),a?.(e)}},[we,me.isReady,oe,Re,tt,G,t,a,e.file,e.id,s]),rt=l.useCallback(async n=>{Re(),oe?.announce(`Guardando ${n.length} recortes...`);try{let r=e.id,a=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");r=t.id,a=t,oe?.announceSuccess("Imagen subida correctamente")}const i=[],o=[];for(const e of n)try{const t=await tt(e,r);t&&i.push(t)}catch(t){o.push({crop:V[e]?.label||`Crop ${e}`,error:t.message})}if(i.length>0&&(oe?.announceSuccess(`${i.length} recorte(s) guardado(s) correctamente`),t(a?{crops:i,asset:a}:i)),o.length>0){const e=`Errores al guardar algunos recortes:\n${o.map(e=>`- ${e.crop}: ${e.error}`).join("\n")}`;oe?.announceError(e),alert(e)}}catch(e){const t=e.message||"Error al procesar los recortes";oe?.announceError(t),alert(t),a?.(e)}},[Re,tt,V,oe,t,e.file,e.id,s,a]),at=l.useCallback(async()=>{const e=Fe();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 ne(e),void ee(!0)}await nt()},[Fe,V,nt,G]),it=l.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:be.current?.$getTransform?.(),selectorState:ye.current?{x:ye.current.x,y:ye.current.y,width:ye.current.width,height:ye.current.height}:null};try{if(t!==G&&n.savedState){if(console.log(`[CropperView] 🔄 Restaurando temporalmente crop ${t} para descarga...`),n.savedState.imageTransform&&be.current?.$setTransform){const[e,t,r,a,i,o]=n.savedState.imageTransform;be.current.$setTransform(e,t,r,a,i,o)}if(n.savedState.selectorState&&ye.current){const{x:e,y:t,width:r,height:a}=n.savedState.selectorState;ye.current.x=e,ye.current.y=t,ye.current.width=r,ye.current.height=a,ye.current.$render?.()}await new Promise(e=>setTimeout(e,100))}const r=await pe.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 Gt(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&&be.current?.$setTransform){console.log(`[CropperView] ↩️ Restaurando estado original del crop ${r.index}...`);const[e,t,n,a,i,o]=r.imageTransform;if(be.current.$setTransform(e,t,n,a,i,o),r.selectorState&&ye.current){const{x:e,y:t,width:n,height:a}=r.selectorState;ye.current.x=e,ye.current.y=t,ye.current.width=n,ye.current.height=a,ye.current.$render?.()}}}},[V,G,pe,e.mime_type,oe,be,ye]),ot=l.useCallback(async e=>{Re(),oe?.announce(`Descargando ${e.length} recortes...`);const t=[],n=[];for(const r of e)try{const e=await it(r);e&&t.push(e)}catch(e){n.push({crop:V[r]?.label||`Crop ${r}`,error:e.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,it,V,oe]),st=l.useCallback(async()=>{if(!we){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 it(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)}},[we,oe,Re,it,G]),lt=l.useCallback(async()=>{const e=Fe();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 ne(e),void ee(!0)}await st()},[Fe,V,st,G]),ct=l.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(e){console.error("Error guardando imagen original:",e);const t=e.message||"No se pudo guardar la imagen. Inténtalo de nuevo.";oe?.announceError(t),alert(t),a?.(e)}else n()},[e.file,s,n,t,a,oe]);return l.useEffect(()=>{d(!1),h(null)},[e]),l.useEffect(()=>{ue.manager&&me.isReady&&$&&(console.log("[CropperView] Carga inicial completada, centrando imagen y selector..."),setTimeout(()=>{_e(),setTimeout(()=>{ze(),z(!1),console.log("[CropperView] Carga inicial finalizada")},100)},50))},[ue.manager,me.isReady,$,_e,ze]),l.useEffect(()=>{ue.manager&&me.isReady&&(X&&pe.setAspectRatio(X),fe.setBackground(y))},[X,y,ue.manager,me.isReady,pe,fe]),l.useEffect(()=>{if(!xe||!me.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(xe.naturalWidth,5e3),n=Math.min(xe.naturalHeight,5e3);K([{...e,width:t,height:n}]),console.log(`[CropperView] Crop por defecto actualizado a ${t}×${n}px`)}},[xe,me.isReady,W.mandatoryCrops.length,V]),l.useEffect(()=>{if(!u||!we)return;const e=setTimeout(async()=>{f(e=>!m&&!e||e);try{const e=await Ke();e&&h(e)}finally{f(!1)}},300);return()=>{clearTimeout(e),f(!1)}},[ve,ke,u,we,Ke,X,A,m]),l.useEffect(()=>{const e=ge.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)}},[ge]),e?_.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:[_.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 flex-shrink-0 lg:gap-2",children:[_.jsxs("div",{className:"flex-1 min-w-fit space-y-2 max-w-fit",children:[_.jsxs("div",{className:"flex items-center gap-2",children:[_.jsx("h2",{className:"text-lg sm:text-xl font-bold text-gray-800",children:"Generar recortes"}),V.length>1&&_.jsx("span",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 text-xs font-semibold rounded",children:Y.label})]}),_.jsxs("div",{className:"flex items-center gap-2",children:[_.jsx("label",{className:"text-xs text-gray-500 whitespace-nowrap",children:"Nombre:"}),_.jsx("div",{className:"",children:B+"."+(globalThis.downloadFormat||e.mime_type.split("/")[1]||"webp")})]})]}),_.jsxs("div",{className:"flex flex-row self-end gap-2 w-full max-w-fit sm:w-auto flex-wrap",children:[_.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:[_.jsx("span",{className:"icon icon-arrow-left-white icon--sm m-0 p-0"})," ","Cancelar"]}),r&&_.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-700 hover:bg-red-900 transition-colors text-white disabled:opacity-50 disabled:cursor-not-allowed","aria-label":`Eliminar imagen ${e.filename}`,title:`Eliminar imagen ${e.filename}`,children:[_.jsx("span",{className:"icon icon-close-small-white icon--sm m-0 p-0"}),i?"Eliminando...":"Eliminar"]})]})]}),_.jsxs("div",{className:"limbo-cropper-status bg-white border-gray-100 py-0 pb-0 flex-shrink-0",children:[ce&&_.jsxs("div",{className:"alert alert-danger mb-2 text-sm",role:"alert",children:[_.jsx("strong",{children:"Error:"})," ",ce]}),xe&&_.jsxs("div",{className:"alert alert-secondary mb-2 text-sm",role:"status",children:[_.jsx("strong",{children:"Original:"})," ",xe.naturalWidth," ×"," ",xe.naturalHeight," px",xe.currentWidth!==xe.naturalWidth&&_.jsxs("span",{className:"ml-2 sm:ml-3 text-xs block sm:inline",children:["(Mostrada: ",Math.round(xe.currentWidth)," ×"," ",Math.round(xe.currentHeight)," px)"]})]}),!we&&_.jsx("div",{className:"alert alert-warning mb-2 text-sm",role:"alert",children:"⚠️ No se puede exportar por restricciones CORS"}),_.jsxs("div",{className:"bg-white border-b border-gray-200 py-2 mx-2 flex-shrink-0 sticky top-0 z-10 mb-1",children:[_.jsxs("div",{className:"flex items-center justify-between mb-2",children:[_.jsxs("h3",{className:"text-sm font-semibold text-gray-700",children:["Recortes ",V.length>1&&`(${V.length})`]}),W.allowCustomCrops&&_.jsxs("button",{onClick:qe,disabled:le,className:"text-xs cursor-pointer px-2 py-1 bg-green-100 hover:bg-green-200 text-green-800 rounded border border-green-300 transition-colors flex items-center gap-1",title:"Añadir recorte personalizado",children:[_.jsx("span",{className:"icon icon-add-green text-green-800 icon--sm"}),"Añadir recorte"]})]}),_.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 _.jsxs("label",{className:"flex flex-col p-1.5 rounded border cursor-pointer transition-colors min-h-[70px] "+(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:[_.jsx("input",{type:"radio",name:"active-crop",checked:G===t,onChange:()=>Ue(t),disabled:le,className:"hidden"}),_.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[_.jsx("div",{className:"flex-1 min-w-0",children:_.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[G!==t||e.required?_.jsx("span",{className:"text-xs font-medium text-gray-800 limbo-truncate",children:e.label}):_.jsx("input",{type:"text",value:e.label,onChange:e=>We(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",placeholder:"Nombre",maxLength:25,onClick:e=>e.stopPropagation()}),e.required&&_.jsx("span",{className:"text-[10px] px-1 py-0.5 bg-red-100 text-red-700 rounded whitespace-nowrap",children:"Oblig."}),e.isCustom&&G!==t&&_.jsx("span",{className:"text-[10px] px-1 py-0.5 bg-purple-100 text-purple-700 rounded whitespace-nowrap",children:"Custom"})]})}),!e.required&&V.length>1&&_.jsx("button",{onClick:n=>{n.preventDefault(),n.stopPropagation(),Ve(t,e.label)},className:"flex-shrink-0 hover:bg-red-500/50 text-red-500 p-1 rounded max-h-fit aspect-square cursor-pointer flex",title:"Eliminar",children:_.jsx("span",{className:"icon icon-close-small icon--xs"})})]}),_.jsx("div",{className:"flex items-center gap-1 mt-auto",children:G===t?_.jsxs(_.Fragment,{children:[_.jsx("input",{type:"number",min:"100",max:"5000",value:e.width,onChange:e=>Be("width",e.target.value),onBlur:()=>He("width"),disabled:le,className:"flex-1 text-xs px-1 py-0.5 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"W",onClick:e=>e.stopPropagation()}),_.jsx("span",{className:"text-gray-400 text-xs",children:"×"}),_.jsx("input",{type:"number",min:"100",max:"5000",value:e.height,onChange:e=>Be("height",e.target.value),onBlur:()=>He("height"),disabled:le,className:"flex-1 text-xs px-1 py-0.5 border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500",placeholder:"H",onClick:e=>e.stopPropagation()})]}):_.jsxs("span",{className:"text-[10px] text-gray-500",children:[e.width," × ",e.height," px"]})}),!n&&_.jsx("div",{className:"text-[9px] px-1 py-0.5 bg-orange-200 text-orange-800 rounded text-center mt-1",children:"Sin configurar"})]},e.id)})})]})]}),_.jsxs("div",{className:"flex flex-col lg:flex-row flex-1 w-full overflow-hidden lg:max-h-130 mx-2 py-1",children:[_.jsx("div",{className:"relative flex-1 lg:flex-[2] h-full flex-shrink-0 flex-grow-1 order-0 min-h-100 lg:min-h-130",children:_.jsxs("div",{className:"absolute inset-0 bg-white rounded-lg border-2 border-gray-200 overflow-hidden",children:[_.jsx(re,{show:$,message:"Cargando recortador..."}),_.jsx(re,{show:T,message:`Cambiando a: ${V[G]?.label||"recorte"}...`}),_.jsxs("cropper-canvas",{ref:ge,style:{width:"100%",height:"100%",display:"block"},background:!!y||void 0,id:"limbo-cropperjs-canvas",tabindex:"-1",onKeyDown:e=>{"Delete"!==e.key&&"Backspace"!==e.key||(e.preventDefault(),e.stopPropagation())},children:[_.jsx("cropper-image",{ref:be,src:e.url||e.path,alt:e.filename,id:"limbo-cropperjs-image",action:"move",crossOrigin:"anonymous",rotatable:!0,scalable:!0,skewable:!0,translatable:!0}),_.jsxs("cropper-selection",{ref:ye,"initial-coverage":"0.5",movable:!0,resizable:!0,keyboard:"true",action:"move",style:{cursor:"move",minWidth:`${J.minWidth}px`,minHeight:`${J.minHeight}px`},"data-prevent-delete":"true",tabindex:"-1",children:[g&&_.jsx("cropper-grid",{role:"grid",action:"move",covered:!0,bordered:!0}),_.jsx("cropper-handle",{action:"move",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"32px",height:"32px",zIndex:"10"}}),_.jsx("cropper-handle",{action:"n-resize"}),_.jsx("cropper-handle",{action:"e-resize"}),_.jsx("cropper-handle",{action:"s-resize"}),_.jsx("cropper-handle",{action:"w-resize"}),_.jsx("cropper-handle",{action:"ne-resize"}),_.jsx("cropper-handle",{action:"nw-resize"}),_.jsx("cropper-handle",{action:"se-resize"}),_.jsx("cropper-handle",{action:"sw-resize"})]})]})]})}),_.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:_.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:[_.jsxs("div",{className:"bg-white rounded border w-full border-gray-200 mb-2",children:[_.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":U,"aria-label":"Mostrar/ocultar opciones de visualización",children:_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Transformar imagen"}),_.jsx("div",{className:"text-center",children:_.jsx("span",{className:`icon ${U?"icon-chevron-up":"icon-chevron-down"} text-center icon--xs`})})]})}),_.jsxs("div",{className:"p-2 space-y-2 justify-items-stretch static "+(U?"block":"sm:hidden"),children:[_.jsx("div",{className:"mb-3 block",children:_.jsxs("div",{className:"grid grid-cols-5 gap-1 content-center h-fit mx-auto",children:[_.jsx("button",{onClick:()=>Ae(-.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-zoom-out-blue"})})}),_.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-arrow-up-blue icon--md limbo--rotate-45"})})}),_.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-arrow-up-blue icon--md"})})}),_.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-arrow-up-blue icon--md rotate-45"})})}),_.jsx("button",{onClick:()=>Ae(.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-zoom-in-blue"})})}),_.jsx("button",{onClick:()=>Me(-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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"text-brand-blue-1000 font-medium",children:"-45°"})})}),_.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-arrow-left-blue"})})}),_.jsx("button",{onClick:_e,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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-radio-button-blue icon-md"})})}),_.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-arrow-right-blue"})})}),_.jsx("button",{onClick:()=>Me(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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"text-brand-blue-1000 font-medium",children:"+45°"})})}),_.jsx("button",{onClick:Le,className:"px-0 rounded cursor-pointer transition-colors text-sm aspect-square "+(A.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 "+(A.horizontal?"(activo)":""),disabled:le,"aria-label":"Voltear imagen horizontalmente","aria-pressed":A.horizontal,children:_.jsx("div",{className:"flex items-center justify-center gap-2",children:_.jsx("span",{className:"icon icon-arrow-left-right-blue border border-brand-blue-1000 rounded"})})}),_.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-arrow-up-blue icon--md limbo--rotate-145"})})}),_.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-arrow-down-blue"})})}),_.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-arrow-up-blue icon--md rotate-145"})})}),_.jsx("button",{onClick:Oe,className:"px-0 rounded cursor-pointer transition-colors aspect-square text-sm "+(A.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 "+(A.vertical?"(activo)":""),disabled:le,"aria-label":"Voltear imagen verticalmente","aria-pressed":A.vertical,children:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{className:"icon icon-arrow-up-down-blue border border-brand-blue-1000 rounded"})})})]})}),_.jsx("div",{className:"flex flex-col gap-2",children:_.jsx("button",{onClick:()=>{he.reset(),M({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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsxs("span",{children:[_.jsx("span",{className:"icon icon-refresh-blue icon--sm align-[middle!important] "})," ","Reiniciar ajustes"]})})})})]})]}),_.jsxs("div",{className:"bg-white rounded border border-gray-200 w-full"+(D?"":" bg-neutral-gray-50/50"),children:[_.jsx("button",{onClick:Ee,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":D,"aria-label":"Mostrar/ocultar opciones de visualizción",children:_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Ajustes del selector"}),_.jsx("div",{className:"text-center",children:_.jsx("span",{className:`icon ${D?"icon-chevron-up":"icon-chevron-down"} text-center icon--xs`})})]})}),_.jsxs("div",{className:"p-2 space-y-2 justify-items-stretch static "+(D?"block":"sm:hidden"),children:[_.jsx("div",{children:_.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[_.jsx("button",{onClick:()=>Ie(.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{children:"50%"})})}),_.jsx("button",{onClick:()=>Ie(.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{children:"70%"})})}),_.jsx("button",{onClick:()=>Ie(.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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{children:"90%"})})}),_.jsx("button",{onClick:()=>Ie(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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsx("span",{children:"100%"})})})]})}),_.jsxs("div",{className:"space-y-2 pt-2",children:[_.jsx("button",{onClick:ze,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:_.jsx("div",{className:"flex items-center justify-center",children:_.jsxs("span",{children:[_.jsx("span",{className:"icon icon-radio-button icon--sm align-[middle!important] "})," ","Centrar selección"]})})}),_.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:"Reiniciar selección",disabled:le,"aria-label":"Reiniciar área de selección",children:_.jsx("div",{className:"flex items-center justify-center",children:_.jsxs("span",{children:[_.jsx("span",{className:"icon icon-refresh icon--sm limbo-lign-[middle!important] "})," ","Reset selección"]})})})]})]})]}),_.jsxs("div",{className:"bg-white rounded border border-gray-200 w-full",children:[_.jsx("button",{onClick:je,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:_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Visualización"}),_.jsx("div",{className:"text-center",children:_.jsx("span",{className:`icon ${O?"icon-chevron-up":"icon-chevron-down"} text-center icon--xs`})})]})}),_.jsxs("div",{className:"py-2 space-y-2 justify-items-stretch static "+(O?"block":"sm:hidden"),children:[_.jsxs("button",{onClick:Se,className:"w-auto flex cursor-pointer items-center justify-between mx-2 p-1 rounded transition-colors "+(g?"bg-blue-100 border border-blue-300 text-blue-800":"bg-gray-100 border border-gray-300 text-gray-700 hover:bg-gray-200"),disabled:le,"aria-pressed":g,title:"Mostrar/ocultar cuadrícula de la regla de los tercios en el selector","aria-label":"Activar/desactivar grid",children:[_.jsxs("span",{className:"text-sm flex items-center",children:[_.jsx("span",{className:"icon icon-area-blue limbo-me-1"})," ","Cuadrícula"]}),_.jsx("span",{className:"text-xs",children:g?_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"icon icon-tick icon--xs align-[middle!important] limbo--mt-0.5"})," ","Activo"]}):"Inactivo"})]}),_.jsxs("button",{onClick:Ne,className:"w-auto flex cursor-pointer items-center justify-between mx-2 p-1 rounded transition-colors "+(y?"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":y,"aria-label":"Activar/desactivar sombreado",children:[_.jsxs("span",{className:"text-sm flex items-center",children:[_.jsx("span",{className:"icon icon-comparison-blue limbo-me-1"})," ","Tablero"]}),_.jsx("span",{className:"text-xs",children:y?_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"icon icon-tick icon--xs align-[middle!important] limbo--mt-0.5"})," ","Activo"]}):"Inactivo"})]})]})]})]})})]}),_.jsxs("div",{className:"flex justify-between flex-shrink-0 border-t border-gray-200 bg-white mx-2 mt-1 py-2 lg:gap-0",children:[_.jsxs("button",{onClick:()=>L(!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:[_.jsx("span",{className:"icon icon-lightbulb text-yellow-500"}),_.jsx("span",{className:"text-sm font-semibold text-blue-800",children:"Guía de uso"}),_.jsx("span",{className:"icon icon-arrow-down scale-75 limbo--rotate-145"})]}),_.jsx("button",{onClick:Ge,disabled:le||!we,className:`px-3 cursor-pointer py-1.5 text-sm rounded transition-colors ${u?"bg-red-600 hover:bg-red-700 text-white":"bg-blue-600 hover:bg-blue-700 text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,"aria-label":"Vista previa",title:"Mostrar/Ocultar vista previa",children:_.jsxs("div",{className:"flex items-center gap-1",children:[_.jsx("span",{className:"icon icon-search-white icon--sm"}),_.jsx("span",{className:"hidden sm:inline whitespace-nowrap",children:u?"Cerrar previa":"Vista previa"})]})}),_.jsxs("div",{className:"flex flex-row gap-1 lg:gap-2 items-center justify-end",children:[_.jsx("button",{onClick:lt,disabled:le||!we,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:_.jsxs("div",{className:"flex items-center gap-1",children:[_.jsx("span",{className:"icon icon-download-white icon--sm"}),_.jsx("span",{className:"hidden md:inline whitespace-nowrap",children:"Descargar"})]})}),e.file&&_.jsx("button",{onClick:ct,disabled:le||c,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:_.jsxs("div",{className:"flex items-center gap-1",children:[_.jsx("span",{className:"icon icon-tick-white icon--sm"}),_.jsx("span",{className:"hidden md:inline whitespace-nowrap",children:"Conservar original"})]})}),_.jsx("button",{onClick:at,disabled:le||!ve||!Ce||!we||!me.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:_.jsx("div",{className:"flex items-center gap-1",children:le?_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"icon icon-save-white icon--sm"}),_.jsx("span",{children:"Guardando..."})]}):_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"icon icon-save-white icon--sm"}),_.jsx("span",{className:"hidden md:inline whitespace-nowrap",children:"Guardar recorte"})]})})})]})]}),Z&&_.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] p-4",children:_.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] overflow-hidden flex flex-col",children:[_.jsxs("div",{className:"px-6 py-4 border-b border-gray-200",children:[_.jsx("h3",{className:"text-lg font-semibold text-gray-800",children:"save"===ae?"Seleccionar recortes a guardar":"Seleccionar recortes a descargar"}),_.jsxs("p",{className:"text-sm text-gray-600 mt-1",children:["Marca los recortes que deseas"," ","save"===ae?"guardar":"descargar"]})]}),_.jsx("div",{className:"px-6 py-4 overflow-y-auto flex-1",children:_.jsx("div",{className:"space-y-2",children:V.map((e,t)=>{const n=e.savedState||t===G,r=!e.required&&!n;return _.jsxs("label",{className:`flex items-center gap-3 p-3 rounded border transition-colors ${te.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:[_.jsx("input",{type:"checkbox",checked:te.includes(t),disabled:r,onChange:e=>{e.target.checked?ne(e=>[...e,t]):ne(e=>e.filter(e=>e!==t))},className:"w-4 h-4 text-blue-600"}),_.jsxs("div",{className:"flex-1 min-w-0",children:[_.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[_.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&&_.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-red-100 text-red-700 rounded whitespace-nowrap",children:"Obligatorio"}),!n&&!e.required&&_.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-orange-100 text-orange-700 rounded whitespace-nowrap",children:"Sin configurar"})]}),_.jsxs("span",{title:"Dimensiones del recorte",className:"text-xs text-gray-500",children:[e.width," × ",e.height," px"]})]})]},e.id)})})}),_.jsxs("div",{className:"px-6 py-4 border-t border-gray-200 flex gap-3 justify-end",children:[_.jsx("button",{onClick:()=>{ee(!1),ie(null),ne([])},className:"limbo-btn limbo-btn-secondary px-4 py-2",children:"Cancelar"}),_.jsxs("button",{onClick:async()=>{if(ee(!1),"save"===ae)if(1===te.length){const e=G;Q(te[0]),await new Promise(e=>setTimeout(e,100)),await nt(),Q(e)}else await rt(te);else if(1===te.length){const e=G;Q(te[0]),await new Promise(e=>setTimeout(e,100)),await st(),Q(e)}else await ot(te);ie(null),ne([])},disabled:0===te.length,className:"limbo-btn limbo-btn-primary px-4 py-2 disabled:opacity-50 disabled:cursor-not-allowed",children:["save"===ae?"Guardar":"Descargar"," (",te.length,")"]})]})]})}),I&&_.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] p-4",children:_.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-3xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[_.jsx("div",{className:"px-6 py-4 border-b border-gray-200 bg-gradient-to-r from-brand-blue-50 to-green-50",children:_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsxs("h3",{className:"text-xl font-semibold text-blue-800 flex items-center gap-2",children:[_.jsx("span",{className:"icon icon-lightbulb text-yellow-500"}),"Guía de uso del Cropper"]}),_.jsx("button",{onClick:()=>L(!1),className:"text-gray-400 hover:text-gray-600 p-1 rounded-full hover:bg-gray-100 transition-colors","aria-label":"Cerrar modal",children:_.jsx("span",{className:"icon icon-close-small icon--lg"})})]})}),_.jsxs("div",{className:"px-6 py-4 overflow-y-auto flex-1 space-y-4",children:[_.jsxs("div",{className:"bg-blue-50 rounded-lg p-4 border-l-4 border-blue-400",children:[_.jsx("h4",{className:"font-semibold text-blue-800 mb-3 text-base flex items-center gap-2",children:"🖱️ Navegación básica"}),_.jsxs("div",{className:"text-sm text-blue-700 space-y-2",children:[_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Arrastra la imagen:"})," Haz clic sobre la imagen dentro del área de selección y arrástrala para reposicionarla"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Zoom:"})," Usa la rueda del ratón sobre el canvas (fuera del área de selección) para hacer zoom"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Vista completa:"}),' Botón "Reset zoom" para ajustar automáticamente al tamaño óptimo']})]})]})]}),_.jsxs("div",{className:"bg-green-50 rounded-lg p-4 border-l-4 border-green-400",children:[_.jsx("h4",{className:"font-semibold text-green-800 mb-3 text-base flex items-center gap-2",children:"✂️ Área de selección"}),_.jsxs("div",{className:"text-sm text-green-700 space-y-2",children:[_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Mover selección:"})," Arrastra desde el centro",_.jsx("span",{className:"icon bg-white icon-move inline-block mx-1 align-middle border border-green-600 rounded-full"}),"para reposicionar el área de recorte"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Redimensionar:"})," Arrastra desde las esquinas o bordes para cambiar el tamaño del área"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Tamaños rápidos:"})," Usa los botones de porcentaje (50%, 70%, 90%, 100%) para ajustar rápidamente el tamaño"]})]})]})]}),_.jsxs("div",{className:"bg-purple-50 rounded-lg p-4 border-l-4 border-purple-400",children:[_.jsx("h4",{className:"font-semibold text-purple-800 mb-3 text-base flex items-center gap-2",children:"⌨️ Atajos de teclado"}),_.jsxs("div",{className:"text-sm text-purple-700 space-y-2",children:[_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Flechas:"}),_.jsxs("span",{className:"inline-flex gap-1 mx-1",children:[_.jsx("span",{className:"icon icon-arrow-right-box rotate-180 icon--sm"}),_.jsx("span",{className:"icon icon-arrow-right-box icon--sm"}),_.jsx("span",{className:"icon icon-arrow-right-box limbo--rotate-90 icon--sm"}),_.jsx("span",{className:"icon icon-arrow-right-box rotate-90 icon--sm"})]}),"Mueven la selección en incrementos de 10px"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Shift + Arrastrar:"})," Mantiene las proporciones al redimensionar el área de selección"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Ctrl + Rueda:"})," Control de zoom más preciso y fino"]})]})]})]}),_.jsxs("div",{className:"bg-cyan-50 rounded-lg p-4 border-l-4 border-cyan-400",children:[_.jsx("h4",{className:"font-semibold text-cyan-800 mb-3 text-base flex items-center gap-2",children:"👁️ Opciones de visualización"}),_.jsxs("div",{className:"text-sm text-cyan-700 space-y-2",children:[_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Cuadrícula:"})," Muestra la regla de los tercios para mejorar la composición de tus recortes"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Tablero:"})," Patrón de cuadros para alinear mejor las medidas o ver imágenes con transparencia"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Vista previa:"})," Muestra cómo quedará el recorte final antes de guardarlo"]})]})]})]}),_.jsxs("div",{className:"bg-amber-50 rounded-lg p-4 border-l-4 border-amber-400",children:[_.jsx("h4",{className:"font-semibold text-amber-800 mb-3 text-base flex items-center gap-2",children:"💡 Consejos profesionales"}),_.jsxs("div",{className:"text-sm text-amber-700 space-y-2",children:[_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Orden de trabajo:"})," Primero aplica transformaciones (rotar, voltear), luego haz el recorte final"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Múltiples recortes:"})," Si tienes varios recortes configurados, revisa cada uno antes de guardar"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Calidad:"})," Las imágenes se exportan en alta calidad (JPEG 90%) manteniendo la mayor nitidez posible"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Proporciones:"})," Usa Shift al redimensionar para mantener el aspecto ratio original"]})]})]})]}),_.jsxs("div",{className:"bg-orange-50 rounded-lg p-4 border-l-4 border-orange-500",children:[_.jsx("h4",{className:"font-semibold text-orange-800 mb-3 text-base flex items-center gap-2",children:"⚠️ Notas importantes"}),_.jsxs("div",{className:"text-sm text-orange-700 space-y-2",children:[_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Recortes grandes:"})," Imágenes de alta resolución pueden tardar más en procesarse"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Calidad de escala:"})," Evita ampliar demasiado áreas pequeñas, ya que puede afectar la nitidez"]})]}),_.jsxs("div",{className:"flex items-start gap-2",children:[_.jsx("span",{className:"font-bold min-w-fit",children:"•"}),_.jsxs("div",{children:[_.jsx("strong",{children:"Cambios pendientes:"})," Recuerda guardar tus cambios antes de cerrar o cambiar de imagen"]})]})]})]})]}),_.jsx("div",{className:"px-6 py-4 border-t border-gray-200 bg-gray-50",children:_.jsx("button",{onClick:()=>L(!1),className:"limbo-btn limbo-btn-primary w-full",children:"Entendido"})})]})}),u&&_.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&&(d(!1),h(null))},children:_.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:`${x.x}px`,top:`${x.y}px`,width:"420px",cursor:k?"grabbing":"default"}:{}},onMouseDown:Qe,onTouchStart:Je,children:[_.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:k?"grabbing":"grab"},children:[_.jsxs("div",{className:"flex items-center gap-2",children:[_.jsx("span",{className:"icon icon-search-white icon--sm"}),_.jsx("h3",{className:"text-sm font-semibold",children:"Vista previa"})]}),_.jsx("button",{onClick:()=>{d(!1),h(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:_.jsx("span",{className:"icon icon-close-small-white icon--sm p-0 m-0 py-auto my-auto mx-auto"})})]}),_.jsx("div",{className:"flex-1 overflow-auto bg-gray-50 p-4",children:p?_.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",children:_.jsxs("div",{className:"text-center",children:[_.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-3"}),_.jsx("p",{className:"text-sm text-gray-600",children:"Generando vista previa..."})]})}):m?_.jsxs("div",{className:"flex flex-col items-center gap-3",children:[_.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:()=>E(!0),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),E(!0))},"aria-label":"Click para ver recorte en tamaño completo",title:"Click para ampliar",children:[_.jsx("img",{src:m,alt:"Vista previa del recorte",className:"w-full h-auto object-contain max-h-[400px]"}),_.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:[_.jsx("span",{className:"icon icon-search-white icon--xs"}),_.jsx("span",{children:"Ampliar"})]})]}),_.jsxs("div",{className:"text-center text-xs text-gray-500",children:[_.jsx("p",{className:"font-medium text-gray-700 mb-1",children:Y?.label||"Recorte"}),_.jsxs("p",{children:[Y?.width," × ",Y?.height," px"]})]})]}):_.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px]",children:_.jsx("p",{className:"text-sm text-gray-500",children:"No se pudo generar la vista previa"})})}),_.jsx("div",{className:"px-4 py-2 bg-gray-100 border-t border-gray-200",children:_.jsxs("p",{className:"text-xs text-gray-600 text-center",children:[_.jsxs("span",{className:"hidden md:inline",children:["Arrastra desde el título para mover •"," "]}),"Actualización automática al editar"]})})]})}),j&&m&&_.jsxs("div",{className:"fixed inset-0 bg-black/95 z-[10001] flex items-center justify-center p-4",onClick:()=>E(!1),role:"dialog","aria-modal":"true","aria-label":"Vista de recorte en tamaño completo",children:[_.jsx("button",{onClick:()=>E(!1),className:"absolute top-4 right-4 p-3 bg-white/10 hover:bg-white/20 rounded-full transition-colors cursor-pointer z-10","aria-label":"Cerrar vista ampliada",title:"Cerrar (Esc)",children:_.jsx("span",{className:"icon icon-close-small-white icon--lg"})}),_.jsxs("div",{className:"absolute top-4 left-4 bg-black/60 text-white px-4 py-3 rounded-lg text-sm backdrop-blur-sm",children:[_.jsx("p",{className:"font-semibold text-base mb-1",children:Y?.label||"Recorte"}),_.jsxs("p",{className:"text-xs text-gray-300",children:[Y?.width," × ",Y?.height," px"]})]}),_.jsx("div",{className:"relative max-w-[95vw] max-h-[95vh] w-full h-full flex items-center justify-center",onClick:e=>e.stopPropagation(),children:_.jsx("img",{src:m,alt:"Vista completa del recorte",className:"max-w-full max-h-full object-contain rounded-lg shadow-2xl"})}),_.jsx("div",{className:"absolute bottom-4 left-1/2 limbo--translate-x-1/2 bg-black/60 text-white px-4 py-2 rounded-lg text-xs text-center backdrop-blur-sm",children:"Click fuera de la imagen o presiona ESC para cerrar"})]})]}):null}function Xt({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 _.jsxs("div",{className:"flex items-center justify-center space-x-2 py-4",children:[_.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:[_.jsx("span",{className:"icon icon-arrow-left-white icon--sm"})," Anterior"]}),_.jsx("div",{className:"flex space-x-1",children:a.map((t,a)=>_.jsx(c.Fragment,{children:"..."===t?_.jsx("span",{className:"px-3 py-2 text-sm text-gray-500",children:"..."}):_.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}`))}),_.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 ",_.jsx("span",{className:"icon icon-arrow-right-white icon--sm"})]}),_.jsxs("div",{className:"text-sm text-gray-500 ml-4",children:["Página ",e," de ",t]})]})}function Jt({isOpen:e,onClose:t}){return e?_.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",style:{zIndex:9999},children:_.jsxs("div",{className:"bg-white rounded-lg p-6 max-w-md mx-4 shadow-xl",children:[_.jsxs("div",{className:"flex items-center mb-4",children:[_.jsx("svg",{className:"w-6 h-6 text-red-600 mr-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:_.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"})}),_.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Sesión Expirada"})]}),_.jsxs("div",{className:"mb-6",children:[_.jsx("p",{className:"text-gray-600 mb-2",children:"Su sesión ha expirado por seguridad."}),_.jsx("p",{className:"text-gray-600",children:"Es necesario recargar la página para obtener un nuevo token de acceso."})]}),_.jsx("div",{className:"flex justify-end space-x-3",children:_.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 Zt(){const[e,t]=l.useState(!1),[n,r]=l.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 I({endpoint:`/assets/${e}`,method:"DELETE",basePath:U,useJWT:!0})}catch(e){throw F(e)}}(e);return!1!==t.success}catch(e){return r(e.message),!1}finally{t(!1)}},loading:e,error:n,reset:()=>{r(null)}}}const en=new Map;function tn(e,t=500){const[n,r]=l.useState(e);return l.useEffect(()=>{const n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n}function nn({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:c=10,_externalImage:u=null}){sessionStorage.removeItem("limbo_stock_selectedService"),sessionStorage.removeItem("limbo_stock_dynamicForm"),sessionStorage.removeItem("limbo_stock_stockImages"),sessionStorage.removeItem("limbo_stock_currentPage"),sessionStorage.removeItem("limbo_stock_paginationInfo"),sessionStorage.removeItem("limbo_portals_searchName"),sessionStorage.removeItem("limbo_portals_limit"),sessionStorage.removeItem("limbo_portals_currentPage"),sessionStorage.removeItem("limbo_portals_images"),sessionStorage.removeItem("limbo_portals_portalResults"),sessionStorage.removeItem("limbo_portals_paginationInfo");const[d,m]=l.useState({name:"",uploadedBy:"",dateFrom:"",dateTo:""}),h=tn(d.name,500),p=tn(d.uploadedBy,500),f=(()=>{switch(a){case"gallery-only":return["gallery"];case"upload-only":return["upload"];case"crop-only":return["cropper"];case"ia-only":return["ia"];default:return r}})(),[g,b]=l.useState(f.includes("gallery")?"gallery":f.includes("upload")?"upload":f.includes("cropper")?"cropper":f.includes("ia")?"ia":f[0]||"gallery"),[y,v]=l.useState(null);l.useEffect(()=>{u&&(console.log("📸 Imagen externa detectada:",u),v(u),b("cropper"))},[u]);const[x,w]=l.useState(1),{isTokenExpired:k,handleTokenExpiredClose:C}=function(){const[e,t]=l.useState(!1),n=l.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=l.useCallback(()=>{t(!1),alert("El token ha expirado. La página se recargará para obtener un nuevo token."),window.location.reload()},[]);return l.useEffect(()=>{const e=e=>{e.detail&&e.detail.error&&n(e.detail.error)};return window.addEventListener("tokenExpiredError",e),()=>{window.removeEventListener("tokenExpiredError",e)}},[n]),{isTokenExpired:e,checkTokenExpiration:n,handleTokenExpiredClose:r}}(),{upload:S,loading:N,error:j,uploadedImage:E,reset:$}=function(){const[e,t]=l.useState(!1),[n,r]=l.useState(null),[a,i]=l.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 B(e,n,!1),r=t.result||t;return i(r),r}catch(e){return r(e.message),null}finally{t(!1)}},loading:e,error:n,uploadedImage:a,reset:()=>{r(null),i(null)}}}(),{deleteImg:z,loading:T,error:A,reset:M}=Zt(),I={limit:c,page:x,...h&&{name:h},...p&&{uploadedBy:p},...d.dateFrom&&{dateFrom:d.dateFrom},...d.dateTo&&{dateTo:d.dateTo}},L=f.includes("gallery"),{images:O,loading:R,error:D,pagination:F,invalidateCache:U,setImages:H}=function(e,t=!1,n={},r=!0){const[a,i]=l.useState([]),[o,s]=l.useState(r),[c,u]=l.useState(null),[d,m]=l.useState(null),[h,p]=l.useState(0),f=l.useMemo(()=>JSON.stringify(n),[n]);return l.useEffect(()=>{if(!r)return void s(!1);const e=`${f}`,t=en.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&&(u("Error de autenticación: Verifica tus credenciales API"),s(!1));else try{const t=await q(n);if(!o)return;const r=t.result||t.data||[],s=t.pagination||null;i(r),m(s),u(null),p(0),en.set(e,{data:r,pagination:s,timestamp:a})}catch(e){o&&(u(e.message),p(e=>e+1))}finally{o&&s(!1)}})(),()=>{o=!1}},[e,t,f,h,n,r]),{images:a,loading:o,error:c,pagination:d,setImages:i,invalidateCache:()=>{en.delete(`${f}`)}}}(e,t,I,L),{refreshVariants:V}=W(),K=e=>!(i.hideActions?.includes(e)||!i.showActions?.includes(e)&&i.showActions?.length>0),G=[{id:"gallery",label:"Galería",feature:"gallery"},{id:"upload",label:"Subir nueva",feature:"upload"},{id:"cropper",label:"Recortador",hideNonActive:!0,feature:"cropper"}].filter(e=>f.includes(e.feature)),X=async e=>{confirm("¿Estás seguro de que deseas eliminar esta imagen? Esta acción también eliminará todos sus recortes.")&&await z(e)&&(U(),w(1),H(t=>t.filter(t=>t.id!==e)),y&&y.id===e&&(v(null),b("gallery")))},J=()=>"crop-only"===a||1===f.length&&"cropper"===f[0]?"crop-only":f.includes("gallery")?"with-gallery":f.includes("upload")&&!f.includes("gallery")?"upload-only":"with-gallery";return _.jsxs(_.Fragment,{children:[i.showTabs&&"cropper"!=g&&_.jsx(P,{tabs:G,active:g,onChange:e=>{b(e),"upload"!==e&&$(),"gallery"!==e&&M()}}),D&&_.jsxs("div",{className:"alert alert-danger",children:["Error al cargar imágenes: ",D]}),A&&_.jsxs("div",{className:"alert alert-danger",children:["Error al eliminar imagen: ",A]}),"gallery"===g&&_.jsxs(_.Fragment,{children:[T&&_.jsx(Q,{text:"Eliminando imagen..."}),_.jsx(Y,{onSelect:e=>{o.onSelect&&o.onSelect({assetId:e.id,url:e.url,fileName:e.filename,mime:e.mime_type,width:e.width,height:e.height,instanceId:s})},onCrop:e=>{v(e),f.includes("cropper")&&b("cropper")},onDelete:K("delete")?X:null,deletingId:T,images:O,loading:R,error:D,filters:d,onFiltersChange:e=>{m(e),w(1)},filterConfig:i.galleryFilters||{},loadingConfig:i.galleryLoading||{},allowedActions:{select:K("select"),download:K("download"),copy:K("copy"),delete:K("delete"),crop:K("crop")}}),F&&!R&&_.jsx(Xt,{currentPage:F.page||x,totalPages:F.pages||1,onPageChange:e=>{w(e)},disabled:R||T})]}),"upload"===g&&_.jsxs("div",{children:[N&&_.jsx(Q,{text:"Subiendo imagen..."}),j&&_.jsxs("div",{className:"alert alert-danger",children:["Error al subir imagen: ",j]}),E&&_.jsxs("div",{className:"alert alert-success absolute top-0 right-0 m-4",children:["✅ Imagen subida correctamente: ",E.filename]}),_.jsx(he,{onSelect: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(v(r),f.includes("cropper"))b("cropper");else{const t=await S(e);t&&(U(),w(1),H(e=>[t,...e]),b("gallery"),o.onUpload&&o.onUpload({assetId:t.id,url:t.url,fileName:t.filename,mime:t.mime_type,width:t.width,height:t.height,instanceId:s}))}},disabled:N,apiKey:e,prod:t})]}),"cropper"===g&&y&&_.jsx(Yt,{image:y,onSave:e=>{const t=J(),n=window.limboCore?.config?.getGlobal()||{},r=n.mode||"embed",a=n.autoHideOnComplete||!1;let i=[],l=null;switch(e.crops&&e.asset?(i=e.crops,l=e.asset):i=Array.isArray(e)?e:[e],l&&"with-gallery"===t&&(H(e=>[l,...e]),w(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&&U(),o.onCropsSaved&&o.onCropsSaved({crops:i,assetId:l?.id||y?.id,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropsSaved",{crops:i,assetId:l?.id||y?.id,instanceId:s}),t){case"with-gallery":v(null),b("gallery");break;case"upload-only":"modal"===r?window.limboCore?.modals?.closeAllModals():(v(null),b("upload"));break;case"crop-only":if("modal"===r)o.onCropperComplete&&o.onCropperComplete({crops:i,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropperComplete",{crops:i,instanceId:s}),window.limboCore?.modals?.closeAllModals();else if(o.onCropperComplete&&o.onCropperComplete({crops:i,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropperComplete",{crops:i,instanceId:s}),a){const e=document.querySelector(`#limbo-instance-${s}`);e&&(e.style.display="none")}}},onCancel:()=>{const e=J(),t=(window.limboCore?.config?.getGlobal()||{}).mode||"embed";switch(o.onCropperCancelled&&o.onCropperCancelled({assetId:y?.id,instanceId:s}),window.limboCore?.events&&window.limboCore.events.emit("cropperCancelled",{assetId:y?.id,instanceId:s}),e){case"with-gallery":v(null),b("gallery");break;case"upload-only":"modal"===t?window.limboCore?.modals?.closeAllModals():(v(null),b("upload"));break;case"crop-only":"modal"===t?window.limboCore?.modals?.closeAllModals():window.limboCore?.events&&window.limboCore.events.emit("cropperClosed",{instanceId:s,reason:"cancelled"})}},onDelete:y?.id?()=>X(y.id):null,onError:e=>{o.onCropperError&&o.onCropperError(e,s),window.limboCore?.events&&window.limboCore.events.emit("cropperError",{error:e,assetId:y?.id,instanceId:s}),console.error("Cropper error:",e)},deleting:T,onVariantCreated:(e,t)=>{V(e)},onUpload:S,uploading:N}),"cropper"===g&&!y&&_.jsx("div",{className:"limbo-empty-state",children:_.jsx("p",{children:"Selecciona una imagen de la galería para comenzar a recortar."})}),_.jsx(Jt,{isOpen:k,onClose:C})]})}class rn{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=j.createRoot(this.container),this.root.render(this._renderApp()),this.mounted=!0,this.eventManager.emit("ready",{instance:this})}catch(e){this.eventManager.emit("error",{instanceId:this.id,error:e.message})}return this}unmount(){return this.mounted?(this.root&&(this.root.unmount(),this.root=null),"button"===this.config.mode&&this.button,this.mounted=!1,this):this}open(){return"modal"!==this.config.mode&&"button"!==this.config.mode||(this.modal||this._createModal(),this.modal&&!this.modal.isOpened()&&(this.modal.open(),this.eventManager.emit("modal:open",{instance:this}))),this}close(){return this.modal&&this.modal.isOpened()&&(this.modal.close(),this.eventManager.emit("modal:close",{instance:this})),this}updateConfig(e){return this.config={...this.config,...e},this.mounted&&this.root.render(this._renderApp()),this.eventManager.emit("config:updated",{instance:this,newConfig:e}),this}destroy(){this.destroyed||(this.unmount(),this.modal&&(this.modal.destroy(),this.modal=null),this.button&&this.button.parentNode&&(this.button.parentNode.removeChild(this.button),this.button=null),this.eventManager.emit("destroy",{instance:this}),this.container=null,this.config=null,this.eventManager=null,this.modalManager=null,this.destroyed=!0)}getId(){return this.id}getMode(){return this.config.mode}isMounted(){return this.mounted}isDestroyed(){return this.destroyed}getContainer(){return this.container}getConfig(){return{...this.config}}isContainerInDOM(){return this.container&&document.contains(this.container)}_createModal(){if(this.modalManager&&"modal"===this.config.mode&&(this.modal=this.modalManager.createModal({title:this.config.title||"Limbo Image Manager",size:this.config.modalSize||"large",onOpen:()=>{const e={instance:this,mode:"modal",timestamp:Date.now()};this._emitDOMEvent("modal:open",e),this.config.callbacks?.onOpen&&this.config.callbacks.onOpen(e)},onClose:()=>{const e={instance:this,mode:"modal",timestamp:Date.now()};this._emitDOMEvent("modal:close",e),this.config.callbacks?.onClose&&this.config.callbacks.onClose(e),this.config.autoDestroy&&this.destroy()},onDestroy:()=>{this.modal=null}}),this.modal)){const e=this.modal.getBodyContainer();this.root=j.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 c.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"},c.createElement(nn,{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}))}_createCallbacks(){return{onSelect:e=>{const t=this._createStandardPayload(e,"select");this.config.callbacks?.onSelect&&this.config.callbacks.onSelect(t),this._emitDOMEvent("select",t)},onUpload:e=>{const t=this._createStandardPayload(e,"upload");this.config.callbacks?.onUpload&&this.config.callbacks.onUpload(t),this._emitDOMEvent("upload",t)},onError:e=>{const t={instance:this,error:{message:e.message||"Unknown error",code:e.code||"UNKNOWN",timestamp:Date.now()}};this.config.callbacks?.onError&&this.config.callbacks.onError(t.error),this._emitDOMEvent("error",t)},onClose:()=>{const e={instance:this,timestamp:Date.now()};this.config.callbacks?.onClose&&this.config.callbacks.onClose(),this._emitDOMEvent("close",e)}}}_createStandardPayload(e,t){const n={instance:this,eventType:t,timestamp:Date.now(),instanceId:this.id,mode:this.config.mode,features:this.config.features};return e&&(e.assetId||e.id?(n.assetId=e.assetId||e.id,n.variants=e.variants||[],n.master=e.master||{urlSigned:e.url||e.urlSigned,width:e.width,height:e.height,mime:e.mime||e.mimeType},n.fileName=e.fileName||e.name,n.mime=e.mime||e.mimeType,n.width=e.width,n.height=e.height,n.fileBlob=e.fileBlob||e.file,n.metadata={uploadedBy:e.uploadedBy,uploadedAt:e.uploadedAt||e.timestamp,size:e.size,...e.metadata}):Object.assign(n,e)),n}_emitDOMEvent(e,t){const n=new CustomEvent(`limbo:${e}`,{detail:t,bubbles:!0,cancelable:!0});(this.getContainer()||document).dispatchEvent(n),this.eventManager.emit(e,t)}_validateConfig(){if(!(this.config.auth?.apiKey||this.config.auth?.publicKey||this.config.auth?.token||this.config.apiKey||this.config.publicKey||this.config.token))throw new Error(`LimboInstance ${this.id}: Authentication is required. Provide either auth.publicKey (recommended) or auth.apiKey (for server-side only)`);if((this.config.auth?.apiKey||this.config.apiKey)&&"undefined"!=typeof window&&console.warn("⚠️ SECURITY WARNING: API Key detected in client-side code.\nThis is a security risk! Use publicKey instead for client applications.\nAPI Keys should only be used in server-side environments."),!["embed","modal","button"].includes(this.config.mode))throw new Error(`LimboInstance ${this.id}: invalid mode ${this.config.mode}`);if("embed"===this.config.mode&&!this.config.container)throw new Error(`LimboInstance ${this.id}: container is required for embed mode`);if("button"===this.config.mode&&!this.config.container)throw new Error(`LimboInstance ${this.id}: container is required for button mode`)}}class an{constructor(){this.instances=new Map,this.counter=0}create(e,t,n){const r="limbo-"+ ++this.counter,a=new rn(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 on{constructor(){this.config=null,this.instances=new Map,this.observer=null,this.initialized=!1}configure(e,t,n){return this.config={dataset:e.dataset||"data-limbo-input-file",return:e.return||"url",mode:e.mode||"modal",features:e.features||["gallery","upload","cropper"],crop:e.crop||"free",quality:e.quality||.9,format:e.format||"webp",modeUI:e.modeUI||"full",modalSize:e.modalSize||"medium",theme:e.theme||"light",compact:e.compact||!1,maxSize:e.maxSize||"10MB",formats:e.formats||["jpg","jpeg","png","webp"],minWidth:e.minWidth||null,minHeight:e.minHeight||null,maxWidth:e.maxWidth||null,maxHeight:e.maxHeight||null,buttonText:e.buttonText||"Seleccionar Imagen",buttonClass:e.buttonClass||"limbo-auto-button",buttonStyle:e.buttonStyle||"primary",showPreview:!1!==e.showPreview,allowMultiple:e.allowMultiple||!1,autoAssign:!1!==e.autoAssign,...e},this.configManager=t,this.eventManager=n,this._initialize(),this}cleanup(){this.observer&&(this.observer.disconnect(),this.observer=null),this.instances.forEach(({input:e,button:t})=>{this._restoreInput(e,t)}),this.instances.clear(),this.config=null,this.initialized=!1}getStats(){return{configured:null!==this.config,totalInputs:this.instances.size,dataset:this.config?.dataset,returnType:this.config?.return}}_initialize(){this.initialized||(this._scanExistingInputs(),this._setupObserver(),this.initialized=!0,this.eventManager.emit("autoInputs:initialized",{config:this.config,inputsFound:this.instances.size}))}_scanExistingInputs(){const e=`input[${this.config.dataset}]`;document.querySelectorAll(e).forEach(e=>this._processInput(e))}_processInput(e){const t=this._getInputId(e);if(this.instances.has(t))return;if(!this._validateInput(e))return;const n=this._createButton(e);this._hideInput(e),this._insertButton(e,n),this.instances.set(t,{input:e,button:n,config:this._getInputConfig(e)}),this.eventManager.emit("autoInputs:processed",{inputId:t,input:e,button:n})}_createButton(e){const t=document.createElement("button"),n=this._getInputConfig(e);t.type="button",t.textContent=n.buttonText||this.config.buttonText;const r=[this.config.buttonClass];return n.buttonClass&&n.buttonClass!==this.config.buttonClass&&r.push(n.buttonClass),t.className=r.join(" "),this._styleButton(t,n),this._attachButtonEvents(t,e),t.setAttribute("aria-label",n.buttonText||this.config.buttonText),t.setAttribute("data-limbo-trigger","true"),t.setAttribute("data-limbo-input-id",n.inputId),n.disabled&&(t.disabled=!0),t}_styleButton(e,t){const n=t.buttonStyle||this.config.buttonStyle,r=t.theme||this.config.theme,a=t.compact||this.config.compact,i={border:"none",borderRadius:"8px",cursor:"pointer",fontFamily:"inherit",fontSize:a?"12px":"14px",fontWeight:"500",transition:"all 0.2s ease",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:a?"6px 12px":"8px 16px",textDecoration:"none",userSelect:"none"},o={primary:{backgroundColor:"dark"===r?"#3b82f6":"#001978",color:"white",hoverBg:"dark"===r?"#2563eb":"#334793"},secondary:{backgroundColor:"dark"===r?"#374151":"#f3f4f6",color:"dark"===r?"#f9fafb":"#374151",border:"1px solid "+("dark"===r?"#4b5563":"#d1d5db"),hoverBg:"dark"===r?"#4b5563":"#e5e7eb"},outline:{backgroundColor:"transparent",color:"dark"===r?"#3b82f6":"#001978",border:"2px solid "+("dark"===r?"#3b82f6":"#001978"),hoverBg:"dark"===r?"#3b82f6":"#001978",hoverColor:"white"},ghost:{backgroundColor:"transparent",color:"dark"===r?"#f9fafb":"#374151",hoverBg:"dark"===r?"#374151":"#f3f4f6"}},s=o[n]||o.primary;Object.assign(e.style,{...i,...s});const l=s.backgroundColor,c=s.color;e.addEventListener("mouseenter",()=>{e.style.backgroundColor=s.hoverBg||s.backgroundColor,s.hoverColor&&(e.style.color=s.hoverColor),e.style.transform="translateY(-1px)",e.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"}),e.addEventListener("mouseleave",()=>{e.style.backgroundColor=l,e.style.color=c,e.style.transform="translateY(0)",e.style.boxShadow="none"}),t.disabled&&(e.style.opacity="0.5",e.style.cursor="not-allowed")}_attachButtonEvents(e,t){e.addEventListener("click",e=>{e.preventDefault(),this._handleButtonClick(t)})}_handleButtonClick(e){const t=this._getInputConfig(e),n=this._createModalConfig(t);this.eventManager.emit("autoInputs:modalRequest",{input:e,config:n,callback:async t=>await this._handleImageSelection(e,t)})}async _handleImageSelection(e,t){const n=this._getInputConfig(e);try{const r=await this._formatImageData(t,n);!1!==n.autoAssign&&(e.value=r),e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:resultReady",{detail:{imageData:t,input:e,value:r,config:n,assignment:{format:n.return,smartAssign:!1!==n.smartAssign,autoAssign:!1!==n.autoAssign},legacy:{imageData:t,formatted:this._createFormattedResult(t,n)}},bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:imageSelected",{detail:{imageData:t,input:e,value:r,config:n,formatted:this._createFormattedResult(t,n)},bubbles:!0})),this.eventManager.emit("autoInputs:imageSelected",{input:e,imageData:t,value:r,config:n})}catch(r){console.error("Error handling image selection:",r),e.dispatchEvent(new CustomEvent("limbo:error",{detail:{error:r.message,input:e,imageData:t,config:n},bubbles:!0})),this._handleImageSelectionLegacy(e,t)}}_handleImageSelectionLegacy(e,t){const n=this._getInputConfig(e),r=this._formatImageData(t,n);!1!==n.autoAssign&&(e.value=r),e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new CustomEvent("limbo:imageSelected",{detail:{imageData:t,input:e,value:r,config:n,formatted:this._createFormattedResult(t,n)},bubbles:!0})),this.eventManager.emit("autoInputs:imageSelected",{input:e,imageData:t,value:r,config:n})}_createFormattedResult(e,t){return{url:e.url||e.path||"",base64:e.base64||e.dataUrl||"",assetId:e.assetId||e.id||"",fileName:e.fileName||e.filename||"",object:{url:e.url||e.path,assetId:e.assetId||e.id,fileName:e.fileName||e.filename,mime:e.mime||e.mime_type,width:e.width,height:e.height,size:e.size||e.file_size,created:e.created_at||e.created,metadata:e.metadata||{}},json:JSON.stringify({url:e.url||e.path,assetId:e.assetId||e.id,fileName:e.fileName||e.filename,mime:e.mime||e.mime_type,width:e.width,height:e.height,size:e.size||e.file_size}),metadata:{width:e.width,height:e.height,size:e.size||e.file_size,format:e.format||e.mime_type,quality:t.quality||this.config.quality,aspectRatio:e.width&&e.height?e.width/e.height:null}}}async _formatImageData(e,t=null){switch((t||{}).return||this.config.return||"url"){case"url":return e.url||e.path||"";case"base64":return e.base64||e.dataUrl||"";case"assetId":return e.assetId||e.id||"";case"fileName":return e.fileName||e.filename||"";case"object":return JSON.stringify({url:e.url||e.path,assetId:e.assetId||e.id,fileName:e.fileName||e.filename,mime:e.mime||e.mime_type,width:e.width,height:e.height,size:e.size||e.file_size,created:e.created_at||e.created});default:return JSON.stringify({url:e.url||e.path,assetId:e.assetId||e.id,fileName:e.fileName||e.filename,mime:e.mime||e.mime_type,width:e.width,height:e.height,size:e.size||e.file_size})}}_createModalConfig(e){return{mode:e.mode||this.config.mode||"modal",modeUI:e.modeUI||this.config.modeUI||"full",features:e.features||this.config.features,modalSize:e.modalSize||this.config.modalSize||"medium",title:e.description||this.config.title||"Seleccionar imagen",cropper:this._getCropperConfig(e),ui:{showActions:this._getUIActions(e),hideActions:[],showTabs:this._shouldShowTabs(e),theme:e.theme||this.config.theme,compact:e.compact||this.config.compact,showPreview:void 0!==e.showPreview?e.showPreview:this.config.showPreview},validation:{maxSize:e.maxSize||this.config.maxSize,formats:e.formats||this.config.formats,minWidth:e.minWidth||this.config.minWidth,minHeight:e.minHeight||this.config.minHeight,maxWidth:e.maxWidth||this.config.maxWidth,maxHeight:e.maxHeight||this.config.maxHeight,required:e.required||!1},behavior:{allowMultiple:e.allowMultiple||this.config.allowMultiple,closeOnSelect:!0,autoAssign:void 0!==e.autoAssign?e.autoAssign:this.config.autoAssign},returnConfig:{format:e.return||this.config.return,quality:e.quality||this.config.quality,outputFormat:e.format||this.config.format},inputMeta:{inputId:e.inputId,inputName:e.inputName,inputType:e.inputType,placeholder:e.placeholder}}}_getCropperConfig(e){const t=e.crop||this.config.crop;if(!t||"none"===t||"false"===t)return null;if("free"===t)return{aspectRatio:null,quality:e.quality||this.config.quality,format:e.format||this.config.format};const n={"1:1":1,"16:9":16/9,"4:3":4/3,"3:2":1.5,"2:1":2,square:1,landscape:16/9,portrait:3/4};if(n[t])return{aspectRatio:n[t],quality:e.quality||this.config.quality,format:e.format||this.config.format,minCropBoxWidth:e.minWidth||this.config.minWidth,minCropBoxHeight:e.minHeight||this.config.minHeight};if("string"==typeof t&&t.includes(":")){const[n,r]=t.split(":").map(Number);if(!isNaN(n)&&!isNaN(r)&&0!==r)return{aspectRatio:n/r,quality:e.quality||this.config.quality,format:e.format||this.config.format}}const r=parseFloat(t);return!isNaN(r)&&r>0?{aspectRatio:r,quality:e.quality||this.config.quality,format:e.format||this.config.format}:"object"==typeof t?{quality:e.quality||this.config.quality,format:e.format||this.config.format,...t}:null}_shouldShowTabs(e){const t=e.modeUI||this.config.modeUI||"full",n=e.features||this.config.features;return!["gallery-only","upload-only","crop-only","ia-only"].includes(t)&&n&&n.length>1}_getUIActions(e){const t=e.modeUI||this.config.modeUI||"full",n=e.features||this.config.features;let r=[];switch(t){case"gallery-only":case"upload-only":r=["select"];break;case"crop-only":r=["select","crop"];break;default:r=["select"],n.includes("cropper")&&r.push("crop"),n.includes("gallery")&&(r.push("download","copy"),this.config.allowDelete&&r.push("delete"))}return r}_getInputId(e){return e.id||e.name||`limbo-auto-${Date.now()}-${Math.random()}`}_validateInput(e){return e instanceof HTMLInputElement}_getInputConfig(e){const t=e=>e?e.split(",").map(e=>e.trim()):null,n=e=>{if(!e)return null;const t=e.match(/^(\d+(?:\.\d+)?)(MB|KB|B)?$/i);if(!t)return null;const n=parseFloat(t[1]);switch((t[2]||"B").toUpperCase()){case"MB":return 1024*n*1024;case"KB":return 1024*n;default:return n}},r=(e,t=!1)=>null===e?t:"true"===e||"1"===e||""===e,a=e=>e?parseFloat(e):null;return{return:e.getAttribute("data-limbo-return")||this.config.return,mode:e.getAttribute("data-limbo-mode")||this.config.mode,features:t(e.getAttribute("data-limbo-features"))||this.config.features,crop:e.getAttribute("data-limbo-crop")||this.config.crop,quality:a(e.getAttribute("data-limbo-quality"))||this.config.quality,format:e.getAttribute("data-limbo-format")||this.config.format,modeUI:e.getAttribute("data-limbo-mode-ui")||this.config.modeUI,modalSize:e.getAttribute("data-limbo-modal-size")||this.config.modalSize,theme:e.getAttribute("data-limbo-theme")||this.config.theme,compact:r(e.getAttribute("data-limbo-compact"),this.config.compact),maxSize:n(e.getAttribute("data-limbo-max-size"))||n(this.config.maxSize),formats:t(e.getAttribute("data-limbo-formats"))||this.config.formats,minWidth:a(e.getAttribute("data-limbo-min-width"))||this.config.minWidth,minHeight:a(e.getAttribute("data-limbo-min-height"))||this.config.minHeight,maxWidth:a(e.getAttribute("data-limbo-max-width"))||this.config.maxWidth,maxHeight:a(e.getAttribute("data-limbo-max-height"))||this.config.maxHeight,buttonText:e.getAttribute("data-limbo-button-text")||this.config.buttonText,buttonStyle:e.getAttribute("data-limbo-button-style")||this.config.buttonStyle,buttonClass:e.getAttribute("data-limbo-button-class")||this.config.buttonClass,showPreview:r(e.getAttribute("data-limbo-show-preview"),this.config.showPreview),allowMultiple:r(e.getAttribute("data-limbo-allow-multiple"),this.config.allowMultiple),autoAssign:r(e.getAttribute("data-limbo-auto-assign"),this.config.autoAssign),placeholder:e.getAttribute("data-limbo-placeholder"),description:e.getAttribute("data-limbo-description"),required:r(e.getAttribute("data-limbo-required"),!1),disabled:r(e.getAttribute("data-limbo-disabled"),!1),inputId:e.id||e.name||this._generateInputId(e),inputName:e.name,inputType:e.type}}_generateInputId(){return`limbo-auto-input-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}_hideInput(e){e.style.display="none"}_insertButton(e,t){e.parentNode.insertBefore(t,e.nextSibling)}_restoreInput(e,t){e.style.display="",t&&t.parentNode&&t.parentNode.removeChild(t)}_setupObserver(){this.observer=new MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&this._scanNodeForInputs(e)})})}),this.observer.observe(document.body,{childList:!0,subtree:!0})}_scanNodeForInputs(e){const t=`input[${this.config.dataset}]`;e.matches&&e.matches(t)&&this._processInput(e);const n=e.querySelectorAll&&e.querySelectorAll(t);n&&n.forEach(e=>this._processInput(e))}}class sn{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(t){console.error(`Error executing listener for ${e}:`,t)}})}getStats(){const e={};return this.listeners.forEach((t,n)=>{e[n]=t.length}),e}}class ln{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 cn(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 cn{constructor(e,t,n){this.id=e,this.config={title:t.title||"Limbo",content:t.content||null,showCloseButton:!1!==t.showCloseButton,backdrop:!1!==t.backdrop,keyboard:!1!==t.keyboard,focus:!1!==t.focus,animation:!1!==t.animation,size:t.size||"large",onOpen:t.onOpen||null,onClose:t.onClose||null,onDestroy:t.onDestroy||null,...t},this.manager=n,this.element=null,this.backdrop=null,this.isOpen=!1,this.previousFocus=null,this._create()}_create(){this._createBackdrop(),this._createModal(),this._attachEvents()}_createBackdrop(){this.config.backdrop&&(this.backdrop=document.createElement("div"),this.backdrop.className="limbo-modal-backdrop",this.backdrop.style.cssText=`\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.5);\n z-index: ${this.manager._getNextZIndex()};\n opacity: 0;\n transition: opacity 0.3s ease;\n `,this.backdrop.addEventListener("click",e=>{e.target===this.backdrop&&this.close()}))}_createModal(){this.element=document.createElement("div"),this.element.className=`limbo-modal limbo-modal--${this.config.size}`,this.element.id=this.id,this.element.role="dialog",this.element.setAttribute("aria-modal","true"),this.element.setAttribute("aria-labelledby",`${this.id}-title`),this.element.tabIndex=-1;const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t={small:e?"width: 100%; height: 100%;":"max-width: 400px;",medium:e?"width: 100%; height: 100%;":"max-width: 600px;",large:e?"width: 100%; height: 100%;":"max-width: 1300px;",xlarge:e?"width: 100%; height: 100%;":"max-width: 90dvw;"},n=e?`\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n transform: translateY(100%);\n width: 100%;\n height: 100%;\n max-width: none;\n max-height: none;\n border-radius: 0;\n background: white;\n z-index: ${this.manager._getNextZIndex()+1};\n opacity: 1;\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n padding-top: env(safe-area-inset-top);\n padding-left: env(safe-area-inset-left);\n padding-right: env(safe-area-inset-right);\n padding-bottom: env(safe-area-inset-bottom);\n `:`\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%) scale(0.8);\n ${t[this.config.size]}\n width: 90%;\n max-height: 90vh;\n background: white;\n border-radius: 16px;\n box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);\n z-index: ${this.manager._getNextZIndex()+1};\n opacity: 0;\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n overflow: hidden;\n display: flex;\n flex-direction: column;\n `;this.element.style.cssText=n,this._createHeader(),this._createBody(),document.body.appendChild(this.backdrop),document.body.appendChild(this.element)}_createHeader(){const e=document.createElement("div");e.className="limbo-modal-header";const t=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e.style.cssText=`\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: ${t?"16px 20px":"20px 24px"};\n border-bottom: 1px solid #e9ecef;\n background: #f8f9fa;\n ${t?"position: sticky; top: 0; z-index: 10;":""}\n min-height: ${t?"60px":"auto"};\n `;const n=document.createElement("h2");if(n.id=`${this.id}-title`,n.className="limbo-modal-title",n.textContent=this.config.title,n.style.cssText="\n margin: 0;\n font-size: 18px;\n font-weight: 600;\n color: #001978;\n flex: 1;\n margin-right: 16px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n ",e.appendChild(n),this.config.showCloseButton){const n=document.createElement("button");n.type="button",n.className="limbo-modal-close",n.innerHTML="✕",n.setAttribute("aria-label","Cerrar modal"),n.style.cssText=`\n background: none;\n border: none;\n font-size: ${t?"28px":"24px"};\n color: #6c757d;\n cursor: pointer;\n padding: ${t?"8px":"4px"};\n border-radius: 4px;\n transition: all 0.2s ease;\n min-width: ${t?"44px":"auto"};\n min-height: ${t?"44px":"auto"};\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n `,n.addEventListener("mouseenter",()=>{n.style.backgroundColor="#f8f9fa",n.style.color="#001978"}),n.addEventListener("mouseleave",()=>{n.style.backgroundColor="transparent",n.style.color="#6c757d"}),n.addEventListener("click",()=>this.close()),e.appendChild(n)}this.element.appendChild(e)}_createBody(){const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),t=document.createElement("div");t.className="limbo-modal-body",t.id=`${this.id}-body`,t.style.cssText=`\n flex: 1;\n overflow-y: auto;\n padding: 0;\n -webkit-overflow-scrolling: touch;\n ${e?"height: 100%; overscroll-behavior: contain;":""}\n `,this.config.content&&("string"==typeof this.config.content?t.innerHTML=this.config.content:this.config.content instanceof Element&&t.appendChild(this.config.content)),this.element.appendChild(t)}_attachEvents(){this._originalBodyOverflow=document.body.style.overflow}open(){if(this.isOpen)return this;window.limbo&&window.limbo.core&&window.limbo.core.keyboard?(window.limbo.core.keyboard.pushFocus(document.activeElement),window.limbo.core.keyboard.setActiveModal(this.element)):this.previousFocus=document.activeElement,document.body.style.overflow="hidden";const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);return requestAnimationFrame(()=>{this.backdrop&&(this.backdrop.style.opacity="1"),this.element.style.opacity="1",this.element.style.transform=e?"translateY(0%)":"translate(-50%, -50%) scale(1)"}),this.isOpen=!0,this.config.focus&&setTimeout(()=>{if(window.limbo&&window.limbo.core&&window.limbo.core.keyboard)window.limbo.core.keyboard.focusFirst(this.element);else{const e=this.getFocusableElements()[0];e&&e.focus()}},300),this.config.onOpen&&this.config.onOpen(this),this}close(){if(!this.isOpen)return this;const e=window.innerWidth<=768||/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);return this.backdrop&&(this.backdrop.style.opacity="0"),this.element.style.opacity="0",this.element.style.transform=e?"translateY(100%)":"translate(-50%, -50%) scale(0.8)",setTimeout(()=>{this._cleanup()},300),this.isOpen=!1,window.limbo&&window.limbo.core&&window.limbo.core.keyboard&&(window.limbo.core.keyboard.setActiveModal(null),window.limbo.core.keyboard.releaseFocus()),this.config.onClose&&this.config.onClose(this),this}destroy(){this.close(),this.manager._removeModal(this),this.config.onDestroy&&this.config.onDestroy(this)}getBodyContainer(){return this.element.querySelector(".limbo-modal-body")}getFocusableElements(){return Array.from(this.element.querySelectorAll(this.manager.focusableSelectors))}getId(){return this.id}isOpened(){return this.isOpen}getConfig(){return{...this.config}}_cleanup(){document.body.style.overflow=this._originalBodyOverflow||"",this.previousFocus&&"function"==typeof this.previousFocus.focus&&this.previousFocus.focus(),this.backdrop&&this.backdrop.parentNode&&this.backdrop.parentNode.removeChild(this.backdrop),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class un{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(e){console.warn("Could not save compact preference:",e)}}_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(e){console.error("Error in compact mode change callback:",e)}})}_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);return["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)}),["--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(e){console.warn("Could not save theme preference:",e)}}_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(e){console.error("Error in theme change callback:",e)}})}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 dn=new class{constructor(){this.config=new n,this.instances=new an,this.autoInputs=new on,this.events=new sn,this.modals=new ln,this.theme=new un,this.containerQueryDetector=z,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},A={...A,...t},A.authMode||(A.token?A.authMode="manual":A.authMode="session"),this.config}setToken(e){return function(e){A.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(e){console.warn("⚠️ Limbo: Error procesando nuevo input:",e)}}),r}init(e){const t=this._mapLegacyOptions(e);return this.create(t)}getInstances(){return this.instances.getAll()}destroy(){this.instances.destroyAll(),this.autoInputs.cleanup(),this.events.cleanup(),this.theme.removeTheme()}_mapLegacyOptions(e){return{container:e.container||"#image-manager",mode:"embed",features:["gallery","upload","cropper"],apiKey:e.apiKey,prod:e.prod||!1,url:void 0===e.url||e.url}}_setupInternalListeners(){this.events.on("autoInputs:modalRequest",({config:e,callback:t})=>{this._handleAutoInputModalRequest({config:e,callback:t})})}_handleAutoInputModalRequest({config:e,callback:t}){const n=this.create({...e,mode:"modal",autoDestroy:!0,callbacks:{onSelect:e=>{t(e),n.close()},onClose:()=>{}}});n.open()}openGallery(e={}){const t=this.create({mode:"modal",modeUI:"gallery-only",features:["gallery"],autoDestroy:!0,modal:{title:e.title||"Seleccionar Imagen",size:e.size||"large"},callbacks:{onSelect:n=>{e.onSelect?.(n),!1!==e.autoClose&&t.close()}},...e});return t.open(),t}openUploader(e={}){const t=!1!==e.redirectToGallery?["upload","gallery"]:["upload"],n=this.create({mode:"modal",modeUI:!1!==e.redirectToGallery?"full":"upload-only",features:t,autoDestroy:!0,modal:{title:e.title||"Subir Imagen",size:e.size||"medium"},callbacks:{onUpload:t=>{e.onUpload?.(t),!1===e.autoClose||e.redirectToGallery||n.close()}},...e});return n.open(),n}openCropper(e,t={}){if(!e)throw new Error("Limbo.openCropper: imageUrl es requerido");const n={url:e,filename:t.filename||"image.jpg",width:t.width||1920,height:t.height||1080,mime_type:t.mimeType||"image/jpeg",id:t.assetId||`external-${Date.now()}`},r=this.create({mode:"modal",modeUI:"crop-only",features:["cropper"],autoDestroy:!0,modal:{title:t.title||"Recortar Imagen",size:"xlarge"},cropper:{mandatoryCrops:t.mandatoryCrops||[],allowCustomCrops:!1!==t.allowCustomCrops,enforceRequiredCrops:!1!==t.enforceRequiredCrops},callbacks:{onCropperComplete:e=>{t.onComplete?.(e),!1!==t.autoClose&&r.close()},onCropperCancelled:e=>{t.onCancelled?.(e),!1!==t.autoClose&&r.close()},onCropperError:e=>{t.onError?.(e)}},_externalImage:n,...t});return r.open(),r}createInlineGallery(e,t={}){return this.create({container:e,mode:"embed",modeUI:"gallery-only",features:["gallery"],callbacks:{onSelect:t.onSelect,onDelete:t.onDelete},...t})}createInlineUploader(e,t={}){return this.create({container:e,mode:"embed",modeUI:"upload-only",features:["upload"],callbacks:{onUpload:t.onUpload},...t})}createStandaloneCropper(e,t,n={}){if(!e)throw new Error("Limbo.createStandaloneCropper: container es requerido");if(!t)throw new Error("Limbo.createStandaloneCropper: imageUrl es requerido");const r={url:t,filename:n.filename||"image.jpg",width:n.width||1920,height:n.height||1080,mime_type:n.mimeType||"image/jpeg",id:n.assetId||`external-${Date.now()}`};return this.create({container:e,mode:"embed",modeUI:"crop-only",features:["cropper"],autoHideOnComplete:!1!==n.autoHideOnComplete,cropper:{mandatoryCrops:n.mandatoryCrops||[],allowCustomCrops:!1!==n.allowCustomCrops,enforceRequiredCrops:!1!==n.enforceRequiredCrops},callbacks:{onCropperComplete:n.onComplete,onCropperCancelled:n.onCancelled,onCropperError:n.onError},_externalImage:r,...n})}createFullSelector(e,t={}){return this.create({container:e,mode:t.mode||"embed",modeUI:"full",features:["gallery","upload","cropper"],callbacks:{onSelect:t.onSelect,onUpload:t.onUpload,onDelete:t.onDelete,onCropsSaved:t.onCropsSaved},...t})}};return"undefined"!=typeof window&&(window.Limbo=dn),"undefined"!=typeof window&&document.querySelector("#root")&&(dn.configure({prod:!1,publicKey:"pk_d2edad56de145fee22c8b80f6ce3448f",authMode:"session"}),dn.create({container:"#root",mode:"embed",modeUI:"full",features:["gallery","upload","cropper"],title:"Limbo Image Manager - Development",url:!0}),dn.configureAutoInputs({dataset:"data-limbo-input-file",return:"url",features:["gallery","upload","cropper"],modeUI:"full",modalSize:"large",title:"Seleccionar imagen",crops:"free",allowDelete:!1})),dn});
|