tiny-essentials 1.28.12 → 1.28.15

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.
@@ -1 +1 @@
1
- (()=>{var e={975(e,t,r){"use strict";var i=r(606);function s(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function n(e,t){for(var r,i="",s=0,n=-1,o=0,a=0;a<=e.length;++a){if(a<e.length)r=e.charCodeAt(a);else{if(47===r)break;r=47}if(47===r){if(n===a-1||1===o);else if(n!==a-1&&2===o){if(i.length<2||2!==s||46!==i.charCodeAt(i.length-1)||46!==i.charCodeAt(i.length-2))if(i.length>2){var l=i.lastIndexOf("/");if(l!==i.length-1){-1===l?(i="",s=0):s=(i=i.slice(0,l)).length-1-i.lastIndexOf("/"),n=a,o=0;continue}}else if(2===i.length||1===i.length){i="",s=0,n=a,o=0;continue}t&&(i.length>0?i+="/..":i="..",s=2)}else i.length>0?i+="/"+e.slice(n+1,a):i=e.slice(n+1,a),s=a-n-1;n=a,o=0}else 46===r&&-1!==o?++o:o=-1}return i}var o={resolve:function(){for(var e,t="",r=!1,o=arguments.length-1;o>=-1&&!r;o--){var a;o>=0?a=arguments[o]:(void 0===e&&(e=i.cwd()),a=e),s(a),0!==a.length&&(t=a+"/"+t,r=47===a.charCodeAt(0))}return t=n(t,!r),r?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(e){if(s(e),0===e.length)return".";var t=47===e.charCodeAt(0),r=47===e.charCodeAt(e.length-1);return 0!==(e=n(e,!t)).length||t||(e="."),e.length>0&&r&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return s(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,t=0;t<arguments.length;++t){var r=arguments[t];s(r),r.length>0&&(void 0===e?e=r:e+="/"+r)}return void 0===e?".":o.normalize(e)},relative:function(e,t){if(s(e),s(t),e===t)return"";if((e=o.resolve(e))===(t=o.resolve(t)))return"";for(var r=1;r<e.length&&47===e.charCodeAt(r);++r);for(var i=e.length,n=i-r,a=1;a<t.length&&47===t.charCodeAt(a);++a);for(var l=t.length-a,u=n<l?n:l,h=-1,c=0;c<=u;++c){if(c===u){if(l>u){if(47===t.charCodeAt(a+c))return t.slice(a+c+1);if(0===c)return t.slice(a+c)}else n>u&&(47===e.charCodeAt(r+c)?h=c:0===c&&(h=0));break}var d=e.charCodeAt(r+c);if(d!==t.charCodeAt(a+c))break;47===d&&(h=c)}var m="";for(c=r+h+1;c<=i;++c)c!==i&&47!==e.charCodeAt(c)||(0===m.length?m+="..":m+="/..");return m.length>0?m+t.slice(a+h):(a+=h,47===t.charCodeAt(a)&&++a,t.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(s(e),0===e.length)return".";for(var t=e.charCodeAt(0),r=47===t,i=-1,n=!0,o=e.length-1;o>=1;--o)if(47===(t=e.charCodeAt(o))){if(!n){i=o;break}}else n=!1;return-1===i?r?"/":".":r&&1===i?"//":e.slice(0,i)},basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');s(e);var r,i=0,n=-1,o=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,l=-1;for(r=e.length-1;r>=0;--r){var u=e.charCodeAt(r);if(47===u){if(!o){i=r+1;break}}else-1===l&&(o=!1,l=r+1),a>=0&&(u===t.charCodeAt(a)?-1===--a&&(n=r):(a=-1,n=l))}return i===n?n=l:-1===n&&(n=e.length),e.slice(i,n)}for(r=e.length-1;r>=0;--r)if(47===e.charCodeAt(r)){if(!o){i=r+1;break}}else-1===n&&(o=!1,n=r+1);return-1===n?"":e.slice(i,n)},extname:function(e){s(e);for(var t=-1,r=0,i=-1,n=!0,o=0,a=e.length-1;a>=0;--a){var l=e.charCodeAt(a);if(47!==l)-1===i&&(n=!1,i=a+1),46===l?-1===t?t=a:1!==o&&(o=1):-1!==t&&(o=-1);else if(!n){r=a+1;break}}return-1===t||-1===i||0===o||1===o&&t===i-1&&t===r+1?"":e.slice(t,i)},format:function(e){if(null===e||"object"!=typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function(e,t){var r=t.dir||t.root,i=t.base||(t.name||"")+(t.ext||"");return r?r===t.root?r+i:r+"/"+i:i}(0,e)},parse:function(e){s(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;var r,i=e.charCodeAt(0),n=47===i;n?(t.root="/",r=1):r=0;for(var o=-1,a=0,l=-1,u=!0,h=e.length-1,c=0;h>=r;--h)if(47!==(i=e.charCodeAt(h)))-1===l&&(u=!1,l=h+1),46===i?-1===o?o=h:1!==c&&(c=1):-1!==o&&(c=-1);else if(!u){a=h+1;break}return-1===o||-1===l||0===c||1===c&&o===l-1&&o===a+1?-1!==l&&(t.base=t.name=0===a&&n?e.slice(1,l):e.slice(a,l)):(0===a&&n?(t.name=e.slice(1,o),t.base=e.slice(1,l)):(t.name=e.slice(a,o),t.base=e.slice(a,l)),t.ext=e.slice(o,l)),a>0?t.dir=e.slice(0,a-1):n&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};o.posix=o,e.exports=o},606(e){var t,r,i=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===s||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:s}catch(e){t=s}try{r="function"==typeof clearTimeout?clearTimeout:n}catch(e){r=n}}();var a,l=[],u=!1,h=-1;function c(){u&&a&&(u=!1,a.length?l=a.concat(l):h=-1,l.length&&d())}function d(){if(!u){var e=o(c);u=!0;for(var t=l.length;t;){for(a=l,l=[];++h<t;)a&&a[h].run();h=-1,t=l.length}a=null,u=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===n||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{return r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function p(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new m(e,t)),1!==l.length||u||o(d)},m.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=p,i.addListener=p,i.once=p,i.off=p,i.removeListener=p,i.removeAllListeners=p,i.emit=p,i.prependListener=p,i.prependOnceListener=p,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},133(){},370(){},766(){},911(){},256(e,t,r){"use strict";r.r(t),r.d(t,{ColorSafeStringify:()=>Q,FuzzySet:()=>ci,MamdaniInferenceSystem:()=>di,TinyAdvancedRaffle:()=>Or,TinyAfterScrollWatcher:()=>Ut,TinyAnalogClock:()=>ri,TinyArrayComparator:()=>oi,TinyArrayPaginator:()=>Hr,TinyClassManager:()=>pi,TinyClipboard:()=>ur,TinyColorConverter:()=>cr,TinyColorValidator:()=>ei,TinyCookieConsent:()=>Wr,TinyDayNightCycle:()=>Rr,TinyDebugger:()=>Ai,TinyDomReadyManager:()=>Nt,TinyDragDropDetector:()=>ge,TinyDragger:()=>kt,TinyElementObserver:()=>pt,TinyGamepad:()=>_r,TinyHtml:()=>It,TinyI18:()=>Jr,TinyIframeEvents:()=>Ar,TinyInventory:()=>Br,TinyInventoryTrader:()=>zr,TinyLevelUp:()=>n,TinyLoadingScreen:()=>Qr,TinyLocalStorage:()=>Er,TinyMediaPlayer:()=>ki,TinyNeedBar:()=>Gr,TinyNewWinEvents:()=>Dr,TinyNotifications:()=>Lt,TinyNotifyCenter:()=>ne,TinyPromiseQueue:()=>Z,TinyRadioFm:()=>gi,TinyRateLimiter:()=>re,TinySimpleDice:()=>Xr,TinySmartScroller:()=>ar,TinyTextDiffer:()=>si,TinyTextRangeEditor:()=>lr,TinyTextarea:()=>kr,TinyTimeout:()=>fr,TinyToastNotify:()=>ae,UltraRandomMsgGen:()=>ir,addAiMarkerShortcut:()=>J,areElsCollBottom:()=>Ye,areElsCollLeft:()=>Xe,areElsCollPerfBottom:()=>et,areElsCollPerfLeft:()=>tt,areElsCollPerfRight:()=>rt,areElsCollPerfTop:()=>Ze,areElsCollRight:()=>Qe,areElsCollTop:()=>Ge,areElsColliding:()=>it,areElsPerfColliding:()=>st,arraySortPositions:()=>u,asyncReplace:()=>V,backupFile:()=>je,breakdownDuration:()=>f,browserIs:()=>Si,calculateMarketcap:()=>z,checkObj:()=>I,clearDirectory:()=>Se,clearDirectoryAsync:()=>We,cloneObjTypeOrder:()=>S,compareMarketcap:()=>W,countObj:()=>y,createCheckDestroyed:()=>ee,createSingletonTask:()=>mr,defuzzifyCentroid:()=>li,diffArrayList:()=>l,diffObjList:()=>G,diffStrings:()=>Y,dirExists:()=>Ae,dirSize:()=>_e,dirSizeAsync:()=>Ue,documentIsFullScreen:()=>M,ensureCopyFile:()=>Ie,ensureDirectory:()=>Te,exitFullScreen:()=>L,extendObjType:()=>E,extractMediaId3Tags:()=>qt,fetchJson:()=>me,fetchText:()=>pe,fileExists:()=>xe,fileSize:()=>Le,fileSizeAsync:()=>Je,formatBytes:()=>F,formatCustomTimer:()=>d,formatDayTimer:()=>p,formatTimer:()=>m,genFibonacciSeq:()=>B,getAge:()=>H,getBrowserCssPrefix:()=>vi,getBrowserPings:()=>Ti,getDuckTyping:()=>Ei,getElsCollDetails:()=>dt,getElsCollDirDepth:()=>ct,getElsCollOverlap:()=>at,getElsCollOverlapPos:()=>lt,getElsColliding:()=>nt,getElsPerfColliding:()=>ot,getElsRelativeCenterOffset:()=>ht,getLatestBackupPath:()=>Re,getPercentage:()=>O,getRectCenter:()=>ut,getSimplePerc:()=>$,getTimeDuration:()=>c,getUserTimeFormat:()=>h,installWindowHiddenScript:()=>fe,isBrowserAgent:()=>wi,isDirEmpty:()=>Ce,isDirEmptyAsync:()=>Ve,isFullScreenMode:()=>k,isJsonObject:()=>g,isObjType:()=>A,isScreenFilled:()=>D,isValidObj:()=>b,listDirs:()=>Ne,listDirsAsync:()=>Ke,listFiles:()=>ke,listFilesAsync:()=>qe,multiplyArrayBlocks:()=>a,objType:()=>C,objTypeName:()=>x,offFullScreenChange:()=>R,onFullScreenChange:()=>j,parseMediaMetadata:()=>Kt,readBase64Blob:()=>ue,readFileBlob:()=>le,readJsonBlob:()=>he,readJsonFile:()=>ve,renameFileAddPrefixSuffix:()=>He,renameFileBatch:()=>$e,renameFileNormalizeCase:()=>Fe,renameFilePadNumbers:()=>Be,renameFileRegex:()=>Oe,reorderObjTypeOrder:()=>T,requestFullScreen:()=>N,restoreLatestBackup:()=>Pe,ruleOfThree:()=>P,safeTextTrim:()=>U,saveJsonFile:()=>ce,shuffleArray:()=>o,toTitleCase:()=>q,toTitleCaseLowerFirst:()=>K,trapezoid:()=>ui,tryDeleteFile:()=>Me,valMediaContentMetadata:()=>Wt,valMediaContentMetadataPartial:()=>Vt,waitForTrue:()=>dr,writeJsonFile:()=>Ee,writeTextFile:()=>De});var i={};r.r(i),r.d(i,{iu:()=>Ye,cq:()=>Xe,P8:()=>et,BO:()=>tt,eh:()=>rt,L2:()=>Ze,lP:()=>Qe,Kr:()=>Ge,wE:()=>it,D6:()=>st,PN:()=>dt,t_:()=>ct,aI:()=>at,ej:()=>lt,kx:()=>nt,Pd:()=>ot,NW:()=>ht,Qv:()=>ut});var s={};r.r(s),r.d(s,{areElsCollBottom:()=>Ye,areElsCollLeft:()=>Xe,areElsCollPerfBottom:()=>et,areElsCollPerfLeft:()=>tt,areElsCollPerfRight:()=>rt,areElsCollPerfTop:()=>Ze,areElsCollRight:()=>Qe,areElsCollTop:()=>Ge,areElsColliding:()=>it,areElsPerfColliding:()=>st,getElsCollDetails:()=>dt,getElsCollDirDepth:()=>ct,getElsCollOverlap:()=>at,getElsCollOverlapPos:()=>lt,getElsColliding:()=>nt,getElsPerfColliding:()=>ot,getElsRelativeCenterOffset:()=>ht,getRectCenter:()=>ut});const n=class{constructor(e,t){if("number"!=typeof e||Number.isNaN(e))throw new Error("giveExp must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("expLevel must be a valid number");this.giveExp=e,this.expLevel=t}createUser(){return{exp:0,level:1,totalExp:0}}validateUser(e){if("number"!=typeof e.exp||Number.isNaN(e.exp))throw new Error("exp must be a valid number");if("number"!=typeof e.level||Number.isNaN(e.level))throw new Error("level must be a valid number");if(e.level<1)throw new Error("level must be at least 1");if("number"!=typeof e.totalExp||Number.isNaN(e.totalExp))throw new Error("totalExp must be a valid number")}isValidUser(e){return!("number"!=typeof e.exp||Number.isNaN(e.exp)||"number"!=typeof e.level||Number.isNaN(e.level)||e.level<1||"number"!=typeof e.totalExp||Number.isNaN(e.totalExp))}getGiveExpBase(){if("number"!=typeof this.giveExp||Number.isNaN(this.giveExp))throw new Error("giveExp must be a valid number");return this.giveExp}getExpLevelBase(){if("number"!=typeof this.expLevel||Number.isNaN(this.expLevel))throw new Error("expLevel must be a valid number");return this.expLevel}expValidator(e){const t=this.getExpLevelBase();this.validateUser(e);let r=0;const i=t*e.level;return e.exp>=i&&(e.level++,r=e.exp-i,e.exp=0,r>0)?this.give(e,r,"extra"):e.exp<1&&e.level>1&&(e.level--,r=Math.abs(e.exp),e.exp=t*e.level,r>0)?this.remove(e,r,"extra"):e}getTotalExp(e){this.validateUser(e);let t=0;for(let r=1;r<=e.level;r++)t+=this.getExpLevelBase()*r;return t+=e.exp,t}expGenerator(e=1){if("number"!=typeof e||Number.isNaN(e))throw new Error("multi must be a valid number");return Math.floor(Math.random()*this.getGiveExpBase())*e}getMissingExp(e){return this.getProgress(e)-e.exp}progress(e){return this.getProgress(e)}getProgress(e){return this.validateUser(e),this.getExpLevelBase()*e.level}set(e,t){if("number"!=typeof t||Number.isNaN(t))throw new Error("value must be a valid number");return e.exp=t,this.expValidator(e),e.totalExp=this.getTotalExp(e),e}give(e,t=0,r="add",i=1){if("number"!=typeof i||Number.isNaN(i))throw new Error("multi must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("extraExp must be a valid number");if("string"!=typeof r)throw new Error("type must be a valid string");return"add"===r?e.exp+=this.expGenerator(i)+t:"extra"===r&&(e.exp+=t),this.expValidator(e),e.totalExp=this.getTotalExp(e),e}remove(e,t=0,r="add",i=1){if("number"!=typeof i||Number.isNaN(i))throw new Error("multi must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("extraExp must be a valid number");if("string"!=typeof r)throw new Error("type must be a valid string");return"add"===r?e.exp-=this.expGenerator(i)+t:"extra"===r&&(e.exp-=t),this.expValidator(e),e.totalExp=this.getTotalExp(e),e}};function o(e){if(!Array.isArray(e))throw new TypeError("Argument 'items' must be an array.");let t,r=e.length;for(;0!==r;)t=Math.floor(Math.random()*r),r--,[e[r],e[t]]=[e[t],e[r]];return e}function a(e,t){if(!Array.isArray(e))throw new TypeError("Argument 'phases' must be an array.");if(!Array.isArray(t))throw new TypeError("Argument 'counts' must be an array.");if(e.length!==t.length)throw new RangeError("The 'phases' and 'counts' arrays must have the same length.");const r=[];for(let i=0;i<e.length;i++){if("number"!=typeof t[i]||Number.isNaN(t[i]))throw new TypeError(`Element at counts[${i}] must be a valid number.`);for(let s=0;s<t[i];s++)r.push(e[i])}return r}function l(e,t){if(!Array.isArray(e))throw new TypeError("Argument 'oldItems' must be an array.");if(!Array.isArray(t))throw new TypeError("Argument 'newItems' must be an array.");const r=e.filter(e=>!t.includes(e));return{added:t.filter(t=>!e.includes(t)),removed:r}}function u(e,t=!1){if(null!=e&&"string"!=typeof e)throw new TypeError("Argument 'item' must be a string or null.");if("boolean"!=typeof t)throw new TypeError("Argument 'isReverse' must be a boolean.");return t?function(t,r){return(e?t[e]:t)>(e?r[e]:r)?-1:(e?t[e]:t)<(e?r[e]:r)?1:0}:function(t,r){return(e?t[e]:t)<(e?r[e]:r)?-1:(e?t[e]:t)>(e?r[e]:r)?1:0}}function h(){const e=new Intl.DateTimeFormat(void 0,{hour:"numeric"}).resolvedOptions().hourCycle;return e?.startsWith("h12")?12:24}function c(e=new Date,t="asSeconds",r=null){if(!(e instanceof Date))throw new TypeError("The 'timeData' argument must be an instance of Date.");if("string"!=typeof t)throw new TypeError("The 'durationType' argument must be a string.");const i=["asMilliseconds","asSeconds","asMinutes","asHours","asDays"];if(!i.includes(t))throw new RangeError(`The 'durationType' must be one of: ${i.join(", ")}.`);if(null!==r&&!(r instanceof Date))throw new TypeError("The 'now' argument must be an instance of Date or null.");const s=r instanceof Date?r:new Date,n=e.getTime()-s.getTime();switch(t){case"asMilliseconds":return n;case"asSeconds":default:return n/1e3;case"asMinutes":return n/6e4;case"asHours":return n/36e5;case"asDays":return n/864e5}}function d(e,t="seconds",r="{time}"){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'totalSeconds' argument must be a valid number.");if("string"!=typeof t)throw new TypeError("The 'level' argument must be a string.");const i=["seconds","minutes","hours","days","months","years"];if(!i.includes(t))throw new RangeError(`The 'level' must be one of: ${i.join(", ")}.`);if("string"!=typeof r)throw new TypeError("The 'format' argument must be a string.");e=Math.max(0,Math.floor(e));const s=i.indexOf(t),n=s>=5,o=s>=4,a=s>=3,l=s>=2,u=s>=1,h=s>=0,c={years:n?0:NaN,months:o?0:NaN,days:a?0:NaN,hours:l?0:NaN,minutes:u?0:NaN,seconds:h?0:NaN,total:NaN};let d=e;if(n||o||a){const e=new Date(1980,0,1),t=new Date(e.getTime()+1e3*d),r=new Date(e);if(n)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),c.years++;if(o)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),c.months++;if(a)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),c.days++;d=Math.floor((t.getTime()-r.getTime())/1e3)}l&&(c.hours=Math.floor(d/3600),d%=3600),u&&(c.minutes=Math.floor(d/60),d%=60),h&&(c.seconds=d),c.total=+e.toFixed(2).replace(/\.00$/,"");const m=e=>{const t="string"==typeof e?parseInt(e):e;return Number.isNaN(t)?"NaN":String(t).padStart(2,"0")},p=[l?m(c.hours):null,u?m(c.minutes):null,h?m(c.seconds):null].filter(e=>null!==e).join(":");return r.replace(/\{years\}/g,String(c.years)).replace(/\{months\}/g,String(c.months)).replace(/\{days\}/g,String(c.days)).replace(/\{hours\}/g,m(c.hours)).replace(/\{minutes\}/g,m(c.minutes)).replace(/\{seconds\}/g,m(c.seconds)).replace(/\{time\}/g,p).replace(/\{total\}/g,String(c.total)).trim()}function m(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'seconds' argument must be a valid number.");return d(e,"hours","{hours}:{minutes}:{seconds}")}function p(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'seconds' argument must be a valid number.");return d(e,"days","{days}d {hours}:{minutes}:{seconds}")}function f(e,t="milliseconds"){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'totalMs' argument must be a valid number.");if("string"!=typeof t)throw new TypeError("The 'level' argument must be a string.");const r=["milliseconds","seconds","minutes","hours","days","months","years"];if(!r.includes(t))throw new RangeError(`The 'level' must be one of: ${r.join(", ")}.`);e=Math.max(0,Math.floor(e));const i=r.indexOf(t),s=i>=6,n=i>=5,o=i>=4,a=i>=3,l=i>=2,u=i>=1,h=i>=0,c={years:s?0:NaN,months:n?0:NaN,days:o?0:NaN,hours:a?0:NaN,minutes:l?0:NaN,seconds:u?0:NaN,milliseconds:h?0:NaN,total:NaN};let d=e;if(s||n||o){const e=new Date(1980,0,1),t=new Date(e.getTime()+d),r=new Date(e);if(s)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),c.years++;if(n)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),c.months++;if(o)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),c.days++;d=t.getTime()-r.getTime()}return a&&(c.hours=Math.floor(d/36e5),d%=36e5),l&&(c.minutes=Math.floor(d/6e4),d%=6e4),u&&(c.seconds=Math.floor(d/1e3),d%=1e3),h&&(c.milliseconds=d),c.total=+e,c}function y(e){if(!Array.isArray(e)&&!g(e))throw new TypeError("Argument must be either an Array or a pure JSON Object.");return Array.isArray(e)?e.length:Object.keys(e).length}function g(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}function b(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}const w="undefined"!=typeof window&&void 0!==window.document,v={items:{},order:[]};function E(e,t){if("object"!=typeof e||null===e)throw new TypeError("Argument 'newItems' must be an object or an array.");if(void 0!==t&&"number"!=typeof t)throw new TypeError("Argument 'index' must be a number.");const r=[],i=Array.isArray(e)?e:Object.entries(e);for(const e of i){if(!Array.isArray(e)||e.length<2)throw new TypeError("Each item in 'newItems' array must be a [key, function] pair.");const[i,s]=e;if("string"!=typeof i)throw new TypeError("Validator key must be a string.");if("function"!=typeof s)throw new TypeError(`Validator for key '${i}' must be a function.`);if(!v.items.hasOwnProperty(i)){v.items[i]=s;let e="number"==typeof t?t:-1;if(-1===e){const t=v.order.indexOf("object");e=t>-1?t:v.order.length}e=Math.min(Math.max(0,e),v.order.length),v.order.splice(e,0,i),r.push(i)}}return r}function T(e){if(!Array.isArray(e))throw new TypeError("Argument 'newOrder' must be an array of strings.");if(!e.every(e=>"string"==typeof e))throw new TypeError("All elements in 'newOrder' must be strings.");const t=[...v.order];return!!e.every(e=>t.includes(e))&&(v.order=e.slice(),!0)}function S(){return[...v.order]}const x=e=>{if(null===e)return"null";for(const t of v.order)if("function"!=typeof v.items[t]||v.items[t](e))return t;return"unknown"};function A(e,t){if("string"!=typeof t)throw new TypeError("Argument 'type' must be a string.");return x(e)===t.toLowerCase()}function C(e,t){if(void 0===e)return null;if(void 0!==t&&"string"!=typeof t)throw new TypeError("Argument 'type' must be a string.");const r=x(e);return"string"==typeof t?r===t.toLowerCase():r}function I(e){const t={valid:null,type:null};for(const r of v.order)if("function"==typeof v.items[r]){const i=v.items[r](e);if(i){t.valid=i,t.type=r;break}}return t}E([["undefined",e=>void 0===e],["null",e=>null===e],["boolean",e=>"boolean"==typeof e],["number",e=>"number"==typeof e&&!Number.isNaN(e)],["bigint",e=>"bigint"==typeof e],["string",e=>"string"==typeof e],["symbol",e=>"symbol"==typeof e],["function",e=>"function"==typeof e],["array",e=>Array.isArray(e)]]),w&&E([["file",e=>"undefined"!=typeof File&&e instanceof File]]),E([["date",e=>e instanceof Date],["regexp",e=>e instanceof RegExp],["map",e=>e instanceof Map],["set",e=>e instanceof Set],["weakmap",e=>e instanceof WeakMap],["weakset",e=>e instanceof WeakSet],["promise",e=>e instanceof Promise]]),w&&E([["htmlelement",e=>"undefined"!=typeof HTMLElement&&e instanceof HTMLElement]]),E([["object",e=>g(e)]]);const M=()=>!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitIsFullScreen||document.mozFullScreen),D=()=>window.innerHeight===screen.height&&window.innerWidth===screen.width,k=()=>M()||D(),N=e=>new Promise(async(t,r)=>{const i=document.documentElement;try{i.requestFullscreen?await i.requestFullscreen(e):i.mozRequestFullScreen?i.mozRequestFullScreen(e):i.webkitRequestFullScreen?i.webkitRequestFullScreen(e):i.msRequestFullscreen&&i.msRequestFullscreen(e),t()}catch(e){r(e)}}),L=()=>new Promise((e,t)=>{if(document.exitFullscreen)document.exitFullscreen().then(e).catch(t);else try{if(document.mozCancelFullScreen)document.mozCancelFullScreen();else if(document.webkitCancelFullScreen)document.webkitCancelFullScreen();else{if(!document.msExitFullscreen)throw new Error("Fullscreen API is not supported");document.msExitFullscreen()}e()}catch(e){t(e)}}),_=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],j=(e,t)=>{_.forEach(r=>{document.addEventListener(r,e,t)})},R=(e,t)=>{_.forEach(r=>{document.removeEventListener(r,e,t)})};function P(e,t,r,i=!1){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("val1 must be a finite number.");if("number"!=typeof t||!Number.isFinite(t))throw new TypeError("val2 must be a finite number.");if("number"!=typeof r||!Number.isFinite(r))throw new TypeError("val3 must be a finite number.");if("boolean"!=typeof i)throw new TypeError("inverse must be a boolean.");return i?Number(e*t)/r:Number(r*t)/e}function $(e,t){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("price must be a finite number.");if("number"!=typeof t||!Number.isFinite(t))throw new TypeError("percentage must be a finite number.");return e*(t/100)}function O(e,t){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("part must be a finite number.");if("number"!=typeof t||!Number.isFinite(t))throw new TypeError("total must be a finite number.");return 0===t?0:e/t*100}function H(e=0,t=null){if("number"!=typeof e&&"string"!=typeof e&&!(e instanceof Date))throw new TypeError("timeData must be a number, string, or Date object.");if(null!==t&&!(t instanceof Date))throw new TypeError("now must be a Date object or null.");const r=new Date(e);if(Number.isNaN(r.getTime()))return null;const i=t instanceof Date?t:new Date;let s=i.getFullYear()-r.getFullYear();const n=i.getMonth(),o=r.getMonth(),a=i.getDate(),l=r.getDate();return(n<o||n===o&&a<l)&&s--,Math.abs(s)}function F(e,t=null,r=null){if("number"!=typeof e||!Number.isFinite(e)||e<0)throw new TypeError("bytes must be a positive number.");if(0===e)return{unit:"Bytes",value:0};if(null!==t&&("number"!=typeof t||!Number.isFinite(t)))throw new TypeError("decimals must be a number or null.");const i=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];if(null!==r){if("string"!=typeof r)throw new TypeError("maxUnit must be a string or null.");if(!i.includes(r))throw new RangeError(`maxUnit must be one of: ${i.join(", ")}`)}const s=r&&i.includes(r)?i.indexOf(r):i.length-1,n=Math.min(Math.floor(Math.log(e)/Math.log(1024)),s);let o=e/Math.pow(1024,n);if(null!==t){const e=t<0?0:t;o=parseFloat(o.toFixed(e))}return{unit:i[n],value:o}}function B({baseValues:e=[0,1],length:t=10,combiner:r=(e,t)=>e+t}={}){if(!Array.isArray(e)||2!==e.length||!e.every(e=>"number"==typeof e))throw new Error("baseValues must be an array of exactly two numbers.");if("number"!=typeof t||!Number.isInteger(t))throw new RangeError("length must be an integer.");if("function"!=typeof r)throw new TypeError("combiner must be a function.");const i=[...e.slice(0,2)];for(let e=2;e<t;e++){const t=r(i[e-2],i[e-1],e);i.push(t)}return i}function z(e,t){if("number"!=typeof e||Number.isNaN(e)||!Number.isFinite(e))throw new TypeError("Original market cap must be a finite number.");if("number"!=typeof t||Number.isNaN(t)||!Number.isFinite(t))throw new TypeError("Circulating supply must be a finite number.");if(t<=0)throw new RangeError("Circulating supply must be greater than zero.");return e/t}function W(e,t,r){if("number"!=typeof r||Number.isNaN(r)||!Number.isFinite(r))throw new TypeError("New market cap must be a finite number.");const i=z(e,t),s="number"==typeof r?r/t:NaN;return{originalPrice:i,newPrice:s,priceChangePercent:"number"==typeof r?(s-i)/i*100:NaN}}async function V(e,t,r){if("string"!=typeof e)throw new TypeError("Expected a string for 'str', but received "+typeof e);if(!(t instanceof RegExp))throw new TypeError("Expected a RegExp for 'regex', but received "+typeof t);if("function"!=typeof r)throw new TypeError("Expected a function for 'asyncFn', but received "+typeof r);const i=[];e.replace(t,(e,...t)=>(i.push(r(e,...t)),e));const s=await Promise.all(i);return e.replace(t,()=>s.shift())}function q(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str', but received "+typeof e);return e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase())}function K(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str', but received "+typeof e);const t=e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase());return t.charAt(0).toLowerCase()+t.slice(1)}function J({key:e="a",className:t="detect-made-by-ai"}={}){if("undefined"==typeof HTMLElement)throw new Error("[AiMarkerShortcut] Environment does not support the DOM. This function must be run in a browser.");if("string"!=typeof e)throw new TypeError("Expected a string for 'config.key', but received "+typeof e);if("string"!=typeof t)throw new TypeError("Expected a string for 'config.className', but received "+typeof t);const r=function(r){if(r.ctrlKey&&r.altKey&&r.key.toLowerCase()===e){if(r.preventDefault(),!document.body)return void console.warn("[AiMarkerShortcut] <body> element not found. Cannot toggle class. Ensure the DOM is fully loaded when using the shortcut.");document.body.classList.toggle(t)}};return document.addEventListener("keydown",r),r}function U(e,t,r=.6){if("string"!=typeof e)throw new TypeError("Expected a string for 'text', but received "+typeof e);if(!Number.isInteger(t)||t<=0)throw new TypeError(`Expected 'limit' to be a positive integer, but received ${t}`);if("number"!=typeof r||r<0||r>1)throw new TypeError(`Expected 'safeCutZone' to be a number between 0 and 1, but received ${r}`);let i=e.trim();if(i.length>t){const e=i.lastIndexOf(" ",t);return e>0&&e>=t*r?`${i.substring(0,e).trim()}...`:`${i.substring(0,t).trim()}...`}return i}function G(e,t){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("Expected an object for 'oldStrings', but received "+(null===e?"null":typeof e));if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("Expected an object for 'newStrings', but received "+(null===t?"null":typeof t));const r={added:{},removed:{},modified:{}};for(const i in e)i in t?e[i]!==t[i]&&(r.modified[i]={old:e[i],new:t[i]}):r.removed[i]=e[i];for(const i in t)i in e||(r.added[i]=t[i]);return r}const Y=G;class X{#e;static#t={default:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""},solarized:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""},monokai:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""}};constructor(e={}){this.#e={...X.#t.default,...e}}#r(e,t){const r=[];e=(e=(e=e.replace(/(?<!")\b(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b(?!")/g,`${t.number}$1${t.reset}`)).replace(/"([^"]+)":/g,(e,t)=>{const i=`___KEY${r.length}___`;return r.push({marker:i,key:t}),`${i}:`})).replace(/"(?:\\.|[^"\\])*?"/g,e=>{const r=e.slice(1,-1);return/^(https?|ftp):\/\/[^\s]+$/i.test(r)?`${t.string_url}${e}${t.reset}`:/^(true|false|null)$/.test(r)?`${t.string_bool}${e}${t.reset}`:/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(r)?`${t.string_number}${e}${t.reset}`:`${t.string}${e}${t.reset}`});for(const{marker:i,key:s}of r){const r=new RegExp(i,"g");e=e.replace(r,`${t.key}"${s}"${t.reset}`)}return(e=(e=(e=(e=e.replace(/(?<!")\b(true|false)\b(?!")/g,`${t.boolean}$1${t.reset}`)).replace(/(?<!")\bnull\b(?!")/g,`${t.null}null${t.reset}`)).replace(/\[Circular\]/g,`${t.special}[Circular]${t.reset}`)).replace(/\[undefined\]/g,`${t.special}[undefined]${t.reset}`)).replace(/"function.*?[^\\]"/gs,`${t.func}$&${t.reset}`)}colorize(e,t={}){const r={...this.#e,...t};return this.#r(e,r)}getColors(){return{...this.#e}}updateColors(e){Object.assign(this.#e,e)}resetColors(){this.#e={...X.#t.default}}loadColorPreset(e){const t=X.#t[e];if(!t)throw new Error(`Preset "${e}" not found.`);this.#e={...t}}saveColorPreset(e,t){X.#t[e]={...t}}getAvailablePresets(){return Object.keys(X.#t)}}const Q=X,Z=class{#i=[];#s=!1;#n={};#o=new Set;isRunning(){return this.#s}async#a(e){if(e&&"function"==typeof e.task&&"function"==typeof e.resolve&&"function"==typeof e.reject){const{task:t,resolve:r,reject:i,delay:s,id:n}=e;try{if(n&&this.#o.has(n))return i(new Error("The function was canceled on TinyPromiseQueue.")),this.#o.delete(n),this.#s=!1,void this.#l();s&&n&&await new Promise(e=>{const t=setTimeout(()=>{delete this.#n[n],e(null)},s);this.#n[n]=t}),r(await t())}catch(e){i(e)}finally{this.#s=!1,this.#l()}}}async#u(){const e=[];for(;this.#i.length&&"POINT_MARKER"===this.#i[0]?.marker;)e.push(this.#i.shift());if(0===e.length)return this.#s=!1,void this.#l();await Promise.all(e.map(({task:e,resolve:t,reject:r,id:i})=>new Promise(async s=>{if(i&&this.#o.has(i))return this.#o.delete(i),r(new Error("The function was canceled on TinyPromiseQueue.")),void s(!0);await e().then(t).catch(r),s(!0)}))),this.#s=!1,this.#l()}async#l(){if(!this.#s&&0!==this.#i.length)if(this.#s=!0,"string"!=typeof this.#i[0]?.marker||"POINT_MARKER"!==this.#i[0]?.marker){const e=this.#i.shift();this.#a(e)}else this.#u()}getIndexById(e){return this.#i.findIndex(t=>t.id===e)}getQueuedIds(){return this.#i.map((e,t)=>({index:t,id:e.id})).filter(e=>"string"==typeof e.id)}reorderQueue(e,t){if("number"!=typeof e||"number"!=typeof t||e<0||t<0||e>=this.#i.length||t>=this.#i.length)return;const[r]=this.#i.splice(e,1);this.#i.splice(t,0,r)}async enqueuePoint(e,t){if("function"!=typeof e)return Promise.reject(new Error("Task must be a function returning a Promise."));if(void 0!==t&&"string"!=typeof t)throw new Error('The "id" parameter must be a string.');return this.#s?new Promise((r,i)=>{this.#i.push({marker:"POINT_MARKER",task:e,resolve:r,reject:i,id:t}),this.#l()}):e()}enqueue(e,t,r){if("function"!=typeof e)return Promise.reject(new Error("Task must be a function returning a Promise."));if(void 0!==t&&("number"!=typeof t||t<0))return Promise.reject(new Error("Delay must be a positive number or undefined."));if(void 0!==r&&"string"!=typeof r)throw new Error('The "id" parameter must be a string.');return new Promise((i,s)=>{this.#i.push({task:e,resolve:i,reject:s,id:r,delay:t}),this.#l()})}cancelTask(e){if("string"!=typeof e)throw new Error('The "id" parameter must be a string.');let t=!1;e in this.#n&&(clearTimeout(this.#n[e]),delete this.#n[e],t=!0);const r=this.getIndexById(e);if(-1!==r){const[e]=this.#i.splice(r,1);e?.reject?.(new Error("The function was canceled on TinyPromiseQueue.")),t=!0}return t&&this.#o.add(e),t}},ee=e=>t=>{if(t)throw new Error(`This ${e} instance has been destroyed and can no longer be used.`)},te=ee("TinyRateLimiter"),re=class{#h=!1;get destroyed(){return this.#h}#c=null;#d=null;#m=null;#p=null;#f=null;#y=null;groupData=new Map;lastSeen=new Map;userToGroup=new Map;groupFlags=new Map;groupTTL=new Map;#g=null;setOnMemoryExceeded(e){if(te(this.#h),"function"!=typeof e)throw new Error("onMemoryExceeded must be a function");this.#g=e}clearOnMemoryExceeded(){te(this.#h),this.#g=null}#b=null;setOnGroupExpired(e){if(te(this.#h),"function"!=typeof e)throw new Error("onGroupExpired must be a function");this.#b=e}clearOnGroupExpired(){te(this.#h),this.#b=null}constructor({maxHits:e,interval:t,cleanupInterval:r,maxIdle:i=3e5,maxMemory:s=1e5}){const n=e=>"number"==typeof e&&Number.isFinite(e)&&e>=1&&Number.isInteger(e),o=n(e),a=n(t),l=n(r),u=n(i);if(!o&&!a)throw new Error("RateLimiter requires at least one valid option: 'maxHits' or 'interval'.");if(void 0!==e&&!o)throw new Error("'maxHits' must be a positive integer if defined.");if(void 0!==t&&!a)throw new Error("'interval' must be a positive integer in milliseconds if defined.");if(void 0!==r&&!l)throw new Error("'cleanupInterval' must be a positive integer in milliseconds if defined.");if(!u)throw new Error("'maxIdle' must be a positive integer in milliseconds.");if("number"==typeof s&&Number.isFinite(s)&&s>0)this.#c=Math.floor(s);else{if(null!=s)throw new Error("maxMemory must be a positive number or null");this.#c=null}this.#m=o?e:null,this.#p=a?t:null,this.#f=l?r:null,this.#y=i,null!==this.#f&&(this.#d=setInterval(()=>this._cleanup(),this.#f))}isGroupId(e){te(this.#h);const t=this.groupFlags.get(e);return"boolean"==typeof t&&t}getUsersInGroup(e){te(this.#h);const t=[];for(const[r,i]of this.userToGroup.entries())i===e&&t.push(r);return t}setGroupTTL(e,t){if(te(this.#h),"number"!=typeof t||!Number.isFinite(t)||t<=0)throw new Error("TTL must be a positive number in milliseconds");this.groupTTL.set(e,t)}getGroupTTL(e){return te(this.#h),this.groupTTL.get(e)??null}deleteGroupTTL(e){te(this.#h),this.groupTTL.delete(e)}assignToGroup(e,t){te(this.#h);const r=this.userToGroup.get(e);if(r&&r!==t)throw new Error(`User ${e} is already assigned to group ${r}`);if(r===t)return;const i=this.groupData.get(e);if(this.isGroupId(e)){for(const[r,i]of this.userToGroup.entries())i===e&&this.userToGroup.set(r,t);this.userToGroup.delete(e)}else this.userToGroup.set(e,t);if(!i)return;const s=this.groupData.get(t);if(s)for(const e of i)s.push(e);else{const e=[];for(const t of i)e.push(t);this.groupData.set(t,e)}this.lastSeen.set(t,Date.now()),this.groupFlags.delete(e),this.groupData.delete(e),this.lastSeen.delete(e),this.groupTTL.delete(e),this.groupFlags.set(t,!0)}getGroupId(e){return te(this.#h),this.userToGroup.get(e)||e}hit(e){te(this.#h);const t=this.getGroupId(e),r=Date.now();this.groupData.has(t)||(this.groupData.set(t,[]),this.groupFlags.set(t,!1));const i=this.groupData.get(t);if(!i)throw new Error(`No data found for groupId: ${t}`);if(i.push(r),this.lastSeen.set(t,r),null!==this.#p){const e=r-this.getInterval();for(;i.length&&i[0]<e;)i.shift()}null!==this.#c&&"number"==typeof this.#c&&i.length>this.#c&&(i.splice(0,i.length-this.#c),"function"==typeof this.#g&&this.#g(t))}isRateLimited(e){te(this.#h);const t=this.getGroupId(e);if(!this.groupData.has(t))return!1;const r=this.groupData.get(t);if(!r)throw new Error(`No data found for groupId: ${t}`);if(null!==this.#p){const e=Date.now()-this.getInterval();let t=0;for(let i=r.length-1;i>=0&&r[i]>e;i--)t++;return null!==this.#m?t>this.getMaxHits():t>0}return null!==this.#m&&r.length>this.getMaxHits()}resetGroup(e){te(this.#h),this.groupFlags.delete(e),this.groupData.delete(e),this.lastSeen.delete(e),this.groupTTL.delete(e)}resetUserGroup(e){te(this.#h),this.userToGroup.delete(e)}setData(e,t){if(te(this.#h),!Array.isArray(t))throw new Error("timestamps must be an array of numbers.");for(const e of t)if("number"!=typeof e||!Number.isFinite(e))throw new Error("All timestamps must be finite numbers.");this.groupData.has(e)||this.groupFlags.set(e,!1),this.groupData.set(e,t),this.lastSeen.set(e,Date.now())}hasData(e){return te(this.#h),this.groupData.has(e)}getData(e){return te(this.#h),this.groupData.get(e)||[]}getMaxIdle(){if(te(this.#h),"number"!=typeof this.#y||!Number.isFinite(this.#y)||this.#y<0)throw new Error("'maxIdle' must be a non-negative finite number.");return this.#y}setMaxIdle(e){if(te(this.#h),"number"!=typeof e||!Number.isFinite(e)||e<0)throw new Error("'maxIdle' must be a non-negative finite number.");this.#y=e}_cleanup(){const e=Date.now();for(const[t,r]of this.lastSeen.entries())e-r>(this.getGroupTTL(t)??this.getMaxIdle())&&(this.groupFlags.delete(t),this.groupData.delete(t),this.lastSeen.delete(t),this.groupTTL.delete(t),"function"==typeof this.#b&&this.#b(t))}getActiveGroups(){return te(this.#h),Array.from(this.groupData.keys())}getAllUserMappings(){return te(this.#h),Object.fromEntries(this.userToGroup)}getInterval(){if(te(this.#h),"number"!=typeof this.#p||!Number.isFinite(this.#p))throw new Error("'interval' is not a valid finite number.");return this.#p}getMaxHits(){if(te(this.#h),"number"!=typeof this.#m||!Number.isFinite(this.#m))throw new Error("'maxHits' is not a valid finite number.");return this.#m}getTotalHits(e){te(this.#h);const t=this.groupData.get(e);return Array.isArray(t)?t.length:0}getLastHit(e){te(this.#h);const t=this.groupData.get(e);return t?.length?t[t.length-1]:null}getTimeSinceLastHit(e){te(this.#h);const t=this.getLastHit(e);return null!==t?Date.now()-t:null}_calculateAverageSpacing(e){if(!Array.isArray(e)||e.length<2)return null;let t=0;for(let r=1;r<e.length;r++)t+=e[r]-e[r-1];return t/(e.length-1)}getAverageHitSpacing(e){return te(this.#h),this._calculateAverageSpacing(this.groupData.get(e))}getMetrics(e){te(this.#h);const t=this.groupData.get(e);if(!Array.isArray(t)||0===t.length)return{totalHits:0,lastHit:null,timeSinceLastHit:null,averageHitSpacing:null};const r=t.length,i=t[r-1];return{totalHits:r,lastHit:i,timeSinceLastHit:Date.now()-i,averageHitSpacing:this._calculateAverageSpacing(t)}}destroy(){this.destroyed||(this.#d&&clearInterval(this.#d),this._cleanup(),this.groupData.clear(),this.lastSeen.clear(),this.userToGroup.clear(),this.groupTTL.clear(),this.groupFlags.clear(),this.#h=!0)}},ie=ee("TinyNotifyCenter");class se{static getTemplate(){return'\n<div class="notify-overlay hidden">\n <div class="notify-center" id="notifCenter">\n <div class="header">\n <div>Notifications</div>\n <div class="options">\n <button class="clear-all" type="button">\n <svg\n xmlns="http://www.w3.org/2000/svg"\n viewBox="0 0 24 24"\n width="24"\n height="24"\n fill="currentColor"\n >\n <path\n d="M21.6 2.4a1 1 0 0 0-1.4 0L13 9.6l-1.3-1.3a1 1 0 0 0-1.4 0L3 15.6a1 1 0 0 0 0 1.4l4 4a1 1 0 0 0 1.4 0l7.3-7.3a1 1 0 0 0 0-1.4l-1.3-1.3 7.2-7.2a1 1 0 0 0 0-1.4zM6 17l3.5-3.5 1.5 1.5L7.5 18.5 6 17z"\n />\n </svg>\n </button>\n <button class="close">×</button>\n </div>\n </div>\n <div class="list"></div>\n </div>\n</div>\n\n<button class="notify-bell" aria-label="Open notifications">\n <svg\n xmlns="http://www.w3.org/2000/svg"\n width="20"\n height="20"\n fill="currentColor"\n viewBox="0 0 24 24"\n >\n <path\n d="M12 2C10.3 2 9 3.3 9 5v1.1C6.7 7.2 5 9.4 5 12v5l-1 1v1h16v-1l-1-1v-5c0-2.6-1.7-4.8-4-5.9V5c0-1.7-1.3-3-3-3zm0 20c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2z"\n />\n </svg>\n <span class="badge" id="notifBadge">0</span>\n</button>\n '}static insertTemplate(e="afterbegin"){document.body.insertAdjacentHTML(e,se.getTemplate())}#h=!1;get destroyed(){return this.#h}#w;#v;#E;#T;#S;#x=0;#A=99;#C=300;#I=!1;#M=new WeakMap;#D(e){if(this.#M.delete(e),!(e instanceof HTMLElement))throw new Error("Invalid HTMLElement to clear.");e.classList.add("removing"),setTimeout(()=>{this.markAsRead(e),e.remove()},this.#C)}#k(e){this.#x=Math.max(0,e),this.#E.setAttribute("data-value",String(this.#x)),this.#E.textContent=this.#x>this.#A?`${this.#A}+`:String(this.#x)}constructor(e={}){const{center:t=document.getElementById("notifCenter"),badge:r=document.getElementById("notifBadge"),button:i=document.querySelector(".notify-bell"),overlay:s=document.querySelector(".notify-overlay")}=e;if(!(t instanceof HTMLElement))throw new Error(`NotificationCenter: "center" must be an HTMLElement. Got: ${t}`);if(!(s instanceof HTMLElement))throw new Error(`NotificationCenter: "overlay" must be an HTMLElement. Got: ${s}`);if(!(r instanceof HTMLElement))throw new Error(`NotificationCenter: "badge" must be an HTMLElement. Got: ${r}`);if(!(i instanceof HTMLElement))throw new Error(`NotificationCenter: "button" must be an HTMLElement. Got: ${i}`);const n=t?.querySelector(".clear-all"),o=t?.querySelector(".list")??null;if(!(o instanceof HTMLElement))throw new Error(`NotificationCenter: ".list" inside center must be an HTMLElement. Got: ${o}`);this.#w=t,this.#v=o,this.#E=r,this.#T=i,this.#S=s,this.#T.addEventListener("click",()=>this.toggle()),this.#w.querySelector(".close")?.addEventListener("click",()=>this.close()),n&&n.addEventListener("click",()=>this.clear()),this.#S.addEventListener("click",e=>{e.target===this.#S&&this.close()})}setMarkAllAsReadOnClose(e){if(ie(this.#h),"boolean"!=typeof e)throw new TypeError("Expected boolean for markAllAsReadOnClose, got "+typeof e);this.#I=e}setRemoveDelay(e){if(ie(this.#h),"number"!=typeof e)throw new Error('NotificationCenter: "ms" must be an number.');this.#C=e}getItemMode(e){ie(this.#h);const t=this.getItem(e);return t?this.#M.get(t):null}getItem(e){ie(this.#h);const t=this.#v.children.item(e);if(!(t instanceof HTMLElement))throw new Error(`NotificationCenter: "item" must be an HTMLElement. Got: ${t}`);return t}hasItem(e){return ie(this.#h),e>=0&&e<this.#v.children.length}markAsRead(e){ie(this.#h);const t=e instanceof HTMLElement?e:this.getItem(e);t.classList.contains("unread")&&(t.classList.remove("unread"),this.#k(this.#x-1))}add(e,t="text"){ie(this.#h);const r=document.createElement("div");r.className="item unread";let i=null,s=null,n=null,o=null;if("object"==typeof e&&null!==e?(i=e.title,s=e.message,n=e.avatar,o=e.onClick):s=e,n){const e=document.createElement("div");e.className="avatar",e.style.backgroundImage=`url("${n}")`,r.appendChild(e)}const a=document.createElement("div");if(a.className="content",i){const e=document.createElement("div");e.className="title",e.textContent=i,a.appendChild(e)}const l=document.createElement("div");l.className="message","html"===t?l.innerHTML=s:l.textContent=s,a.appendChild(l),"function"==typeof o&&(r.classList.add("clickable"),r.addEventListener("click",e=>{e.target instanceof HTMLElement&&!e.target.closest(".notify-close")&&o(e)}));const u=document.createElement("button");u.className="notify-close",u.setAttribute("type","button"),u.innerHTML="&times;",u.addEventListener("click",e=>{e.stopPropagation(),this.#D(r)}),r.append(a,u),this.#v.prepend(r),this.#M.set(r,t),this.#k(this.#x+1)}remove(e){ie(this.#h);const t=this.getItem(e);this.#D(t)}clear(){ie(this.#h);let e=!0;for(;e;){e=!1;const t=Array.from(this.#v.children);for(const r of t)r instanceof HTMLElement&&!r.classList.contains("removing")&&(this.#D(r),e=!0)}}open(){ie(this.#h),this.#S.classList.remove("hidden"),this.#w.classList.add("open")}close(){if(ie(this.#h),this.#S.classList.add("hidden"),this.#w.classList.remove("open"),this.#I){const e=this.#v.querySelectorAll(".item.unread");for(const t of e)t instanceof HTMLElement&&this.markAsRead(t)}}toggle(){ie(this.#h),this.#w.classList.contains("open")?this.close():this.open()}recount(){ie(this.#h);const e=this.#v.querySelectorAll(".item.unread").length;this.#k(e)}get count(){return this.#x}destroy(){this.#h||(this.#T?.removeEventListener("click",this.toggle),this.#w?.querySelector(".close")?.removeEventListener("click",this.close),this.#w?.querySelector(".clear-all")?.removeEventListener("click",this.clear),this.#S?.removeEventListener("click",this.close),this.clear(),this.#w?.remove(),this.#S?.remove(),this.#T?.remove(),this.#x=0,this.#M=new WeakMap,this.#h=!0)}}const ne=se,oe=ee("TinyToastNotify"),ae=class{#N;#L;#_;#j;#R;#P;#h=!1;get destroyed(){return this.#h}constructor(e="top",t="right",r=3e3,i=50,s=300,n=".notify-container"){this.#$(e),this.#O(t),this.#H(r,"baseDuration"),this.#H(i,"extraPerChar"),this.#H(s,"fadeOutDuration"),this.#N=e,this.#L=t,this.#_=r,this.#j=i,this.#R=s;const o=document.querySelector(`${n}.${e}.${t}`);o instanceof HTMLElement?this.#P=o:(this.#P=document.createElement("div"),this.#P.className=`notify-container ${e} ${t}`,document.body.appendChild(this.#P))}getContainer(){if(oe(this.#h),!(this.#P instanceof HTMLElement))throw new Error("Container is not a valid HTMLElement.");return this.#P}#$(e){if(!["top","bottom"].includes(e))throw new Error(`Invalid vertical direction "${e}". Expected "top" or "bottom".`)}#O(e){if(!["left","right","center"].includes(e))throw new Error(`Invalid horizontal position "${e}". Expected "left", "right" or "center".`)}#H(e,t){if("number"!=typeof e||e<0||!Number.isFinite(e))throw new Error(`Invalid value for "${t}": ${e}. Must be a non-negative finite number.`)}getY(){return oe(this.#h),this.#N}setY(e){oe(this.#h),this.#$(e);const t=this.getContainer();t.classList.remove(this.#N),t.classList.add(e),this.#N=e}getX(){return oe(this.#h),this.#L}setX(e){oe(this.#h),this.#O(e);const t=this.getContainer();t.classList.remove(this.#L),t.classList.add(e),this.#L=e}getBaseDuration(){return oe(this.#h),this.#_}setBaseDuration(e){oe(this.#h),this.#H(e,"baseDuration"),this.#_=e}getExtraPerChar(){return oe(this.#h),this.#j}setExtraPerChar(e){oe(this.#h),this.#H(e,"extraPerChar"),this.#j=e}getFadeOutDuration(){return oe(this.#h),this.#R}setFadeOutDuration(e){oe(this.#h),this.#H(e,"fadeOutDuration"),this.#R=e}show(e){oe(this.#h);let t="",r="",i=null,s=!1,n=null;const o=document.createElement("div");if(o.className="notify enter","string"==typeof e)t=e;else{if("object"!=typeof e||null===e||"string"!=typeof e.message)throw new Error("Invalid argument for show(): expected string or { message: string, title?: string, onClick?: function, html?: boolean, avatar?: string }");if(t=e.message,r="string"==typeof e.title?e.title:"",s=!0===e.html,n="string"==typeof e.avatar?e.avatar:null,void 0!==e.onClick){if("function"!=typeof e.onClick)throw new Error("onClick must be a function if defined");i=e.onClick,o.classList.add("clickable")}}const a=document.createElement("button");if(a.innerHTML="&times;",a.className="close",a.setAttribute("aria-label","Close"),a.addEventListener("mouseenter",()=>{a.style.color="var(--notify-close-color-hover)"}),a.addEventListener("mouseleave",()=>{a.style.color="var(--notify-close-color)"}),n){const e=document.createElement("img");e.src=n,e.alt="avatar",e.className="avatar",o.appendChild(e)}if(r){const e=document.createElement("strong");e.textContent=r,e.style.display="block",o.appendChild(e)}if(s){const e=document.createElement("div");e.innerHTML=t,o.appendChild(e)}else o.appendChild(document.createTextNode(t));o.appendChild(a),this.getContainer().appendChild(o);const l=this.#_+t.length*this.#j+this.#R;let u=!1;const h=()=>{u||(u=!0,o.classList.remove("enter","show"),o.classList.add("exit"),setTimeout(()=>o.remove(),this.#R))};"function"==typeof i&&o.addEventListener("click",e=>{e.target!==a&&i(e,h)}),a.addEventListener("click",e=>{e.stopPropagation(),h()}),setTimeout(()=>{o.classList.remove("enter"),o.classList.add("show")},1),setTimeout(()=>h(),l)}destroy(){this.#h||this.#P instanceof HTMLElement&&(this.#P.querySelectorAll(".notify").forEach(e=>e.remove()),this.#P.parentNode&&this.#P.parentNode.removeChild(this.#P),this.#P=null,this.#h=!0)}};function le(e,t){if(!(e instanceof Blob))return Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'));const r=["readAsArrayBuffer","readAsDataURL","readAsText","readAsBinaryString"];return"string"==typeof t&&r.includes(t)?new Promise((r,i)=>{const s=new FileReader;s.onload=()=>{try{r(s.result)}catch(e){i(e)}},s.onerror=()=>{i(s.error)},s[t](e)}):Promise.reject(new TypeError(`The "method" argument must be one of: ${r.join(", ")}.`))}function ue(e,t=!1){return e instanceof Blob?"string"!=typeof t&&"boolean"!=typeof t?Promise.reject(new TypeError("The isDataUrl parameter must be a boolean or a string.")):new Promise((r,i)=>{le(e,"readAsDataURL").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const i=e.match(/^data:(.+);base64,(.*)$/);if(!i||!i[2])throw new Error("Invalid data URL format or missing Base64 content.");const[,s,n]=i;if(!/^[\w/+]+=*$/.test(n))throw new Error("Base64 content is malformed.");if("boolean"==typeof t)return r(t?e:n);if(!/^[\w-]+\/[\w.+-]+$/.test(t))throw new Error(`Invalid MIME type string: ${t}`);return r(`data:${t};base64,${n}`)}).catch(i)}):Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'))}function he(e){return e instanceof Blob?new Promise((t,r)=>le(e,"readAsText").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const r=e.trim();if(0===r.length)throw new Error("File is empty or contains only whitespace.");const i=JSON.parse(r);if("object"!=typeof i||null===i)throw new Error("Parsed content is not a valid JSON object or array.");t(i)}).catch(r)):Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'))}function ce(e,t,r=2){if("string"!=typeof e)throw new TypeError('The "filename" argument must be a string.');if("number"!=typeof r||!Number.isInteger(r)||r<0)throw new TypeError('The "spaces" argument must be a non-negative integer.');const i=JSON.stringify(t,null,r),s=new Blob([i],{type:"application/json"}),n=URL.createObjectURL(s),o=document.createElement("a");o.href=n,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}function de(e,t,r=e=>({headers:e.headers,status:e.status,statusText:e.statusText})){if(!(e instanceof Response))throw new TypeError('The "response" argument must be an instance of Response.');if("function"!=typeof t)throw new TypeError('The "onProgress" argument must be a function.');if(!e.body)return e;const i=e.headers.get("content-length"),s=i?parseInt(i,10):0;let n=0;const o=e.body.getReader(),a=new ReadableStream({async start(e){for(;;){const{done:r,value:i}=await o.read();if(r)break;n+=i.byteLength,t(n,s),e.enqueue(i)}e.close()}});return new Response(a,r(e))}async function me(e,t,r){return"string"!=typeof e?Promise.reject(new TypeError('The "url" argument must be a string.')):void 0!==t&&"object"!=typeof t?Promise.reject(new TypeError('The "options" argument must be an object.')):void 0!==r&&"function"!=typeof r?Promise.reject(new TypeError('The "onProgress" option must be a function.')):new Promise((i,s)=>{fetch(e,t??void 0).then(async e=>{const t=r?de(e,r):e,s=t.headers.get("content-type")||"";if(!s.includes("application/json"))throw new Error(`Unexpected content-type: ${s}`);const n=await t.json();if(!Array.isArray(n)&&!g(n))throw new Error("Received invalid data instead of valid JSON.");return i(n)}).catch(s)})}async function pe(e,t,r,i){return"string"!=typeof e?Promise.reject(new TypeError('The "url" argument must be a string.')):void 0===t||Array.isArray(t)?void 0!==r&&"object"!=typeof r?Promise.reject(new TypeError('The "options" argument must be an object.')):void 0!==i&&"function"!=typeof i?Promise.reject(new TypeError('The "onProgress" option must be a function.')):new Promise((s,n)=>{fetch(e,r??void 0).then(async e=>{const r=i?de(e,i):e,n=r.headers.get("content-type")||"";if(Array.isArray(t)&&t.length>0&&!t.some(e=>n.includes(e)))throw new Error(`Blocked MIME type: ${n}`);const o=await r.text();return s(o)}).catch(n)}):Promise.reject(new TypeError('The "allowedMimeTypes" argument must be an array of strings.'))}function fe(e={}){if(null===e||"object"!=typeof e)throw new TypeError('The "settings" argument must be an object.');const{element:t=document.body,hiddenClass:r="windowHidden",visibleClass:i="windowVisible",onVisible:s,onHidden:n}=e;if(!(t instanceof Element))throw new TypeError('"element" must be an instance of Element.');if("string"!=typeof r)throw new TypeError('"hiddenClass" must be a string.');if("string"!=typeof i)throw new TypeError('"visibleClass" must be a string.');if(void 0!==s&&"function"!=typeof s)throw new TypeError('"onVisible" must be a function if provided.');if(void 0!==n&&"function"!=typeof n)throw new TypeError('"onHidden" must be a function if provided.');let o="",a="";const l=()=>{t.classList.remove(r),t.classList.remove(i)};let u=null;const h=["visibilitychange","mozvisibilitychange","webkitvisibilitychange","msvisibilitychange"],c=["hidden","mozHidden","webkitHidden","msHidden"];for(let e=0;e<c.length;e++)if(c[e]in document){u=c[e];break}const d=function(e){l();const h=e?.type,c=u&&document[u];["focus","focusin","pageshow"].includes(h)?(t.classList.add(i),s?.({type:h,oldClass:a,oldType:o}),a=i):["blur","focusout","pagehide"].includes(h)||c?(t.classList.add(r),n?.({type:h,oldClass:a,oldType:o}),a=r):(t.classList.add(i),s?.({type:h,oldClass:a,oldType:o}),a=i),o=h};let m=()=>{};if(u){const e=h[c.indexOf(u)];document.addEventListener(e,d),window.addEventListener("focus",d),window.addEventListener("blur",d),m=()=>{document.removeEventListener(e,d),window.removeEventListener("focus",d),window.removeEventListener("blur",d),l()}}else"onfocusin"in document?(document.onfocusin=document.onfocusout=d,m=()=>{document.onfocusin=document.onfocusout=null,l()}):(window.onpageshow=window.onpagehide=window.onfocus=window.onblur=d,m=()=>{window.onpageshow=window.onpagehide=window.onfocus=window.onblur=null,l()});const p=new Event(u&&document[u]?"blur":"focus");return d(p),m}const ye=ee("TinyDragDropDetector"),ge=class{#F;#B;#z;#W;#V;#q;#K;#h=!1;get destroyed(){return this.#h}constructor(e,t){const{hoverClass:r="dnd-hover",onDrop:i,onEnter:s,onLeave:n}=t;if(!(e instanceof HTMLElement))throw new TypeError('The "target" option must be an instance of HTMLElement.');if("string"!=typeof r)throw new TypeError('The "hoverClass" option must be a string.');if("function"!=typeof i)throw new TypeError('The "onDrop" option must be a function.');if("function"!=typeof s)throw new TypeError('The "onEnter" option must be a function.');if("function"!=typeof n)throw new TypeError('The "onLeave" option must be a function.');this.#F=e,this.#B=r,this.#z=i||(()=>{}),this.#W=s,this.#V=n,this.#q=!1,this.#K=!1,this._handleDragEnter=this._handleDragEnter.bind(this),this._handleDragOver=this._handleDragOver.bind(this),this._handleDragLeave=this._handleDragLeave.bind(this),this._handleDrop=this._handleDrop.bind(this),this.#J()}getTarget(){return ye(this.#h),this.#F}getHoverClass(){return ye(this.#h),this.#B}isDragging(){return ye(this.#h),this.#q}bound(){return ye(this.#h),this.#K}#J(){if(this.#K)return;const e=this.getTarget();e.addEventListener("dragenter",this._handleDragEnter),e.addEventListener("dragover",this._handleDragOver),e.addEventListener("dragleave",this._handleDragLeave),e.addEventListener("drop",this._handleDrop),this.#K=!0}#U(){if(!this.#K)return;const e=this.getTarget();e.removeEventListener("dragenter",this._handleDragEnter),e.removeEventListener("dragover",this._handleDragOver),e.removeEventListener("dragleave",this._handleDragLeave),e.removeEventListener("drop",this._handleDrop),this.#K=!1}_handleDragEnter(e){if(e.preventDefault(),!this.#q){const t=this.getTarget();this.#q=!0,t.classList.add(this.#B),this.#W(e)}}_handleDragOver(e){e.preventDefault(),e.dataTransfer?e.dataTransfer.dropEffect="copy":console.warn("[TinyDragDropDetector] [handleDragOver] DragOver event missing dataTransfer.")}_handleDragLeave(e){e.preventDefault();const t=this.getTarget();null!==e.relatedTarget&&t.contains(e.relatedTarget)||(this.#q=!1,t.classList.remove(this.#B),this.#V(e))}_handleDrop(e){if(e.preventDefault(),!e.dataTransfer)return void console.warn("[TinyDragDropDetector] [handleDrop] DragOver event missing dataTransfer.");const t=this.getTarget();this.#q=!1,t.classList.remove(this.#B);const r=e.dataTransfer.files;r.length>0&&this.#z(r,e)}destroy(){this.#h||(this.#U(),this.getTarget().classList.remove(this.#B),this.#h=!0)}};var be=r(133),we=r(975);function ve(e){if(!(0,be.existsSync)(e))throw new Error(`File not found: ${e}`);const t=(0,be.readFileSync)(e,"utf-8");return JSON.parse(t)}function Ee(e,t,r=2){const i=JSON.stringify(t,null,r);(0,be.writeFileSync)(e,i,"utf-8")}function Te(e){(0,be.existsSync)(e)||(0,be.mkdirSync)(e,{recursive:!0})}function Se(e){if(!(0,be.existsSync)(e))return;const t=(0,be.readdirSync)(e);for(const r of t){const t=(0,we.join)(e,r);(0,be.lstatSync)(t).isDirectory()?(0,be.rmSync)(t,{recursive:!0,force:!0}):(0,be.unlinkSync)(t)}}function xe(e){return(0,be.existsSync)(e)&&(0,be.lstatSync)(e).isFile()}function Ae(e){return(0,be.existsSync)(e)&&(0,be.lstatSync)(e).isDirectory()}function Ce(e){return 0===(0,be.readdirSync)(e).length}function Ie(e,t,r){Te((0,we.dirname)(t)),(0,be.copyFileSync)(e,t,r)}function Me(e){return!!xe(e)&&((0,be.unlinkSync)(e),!0)}function De(e,t,r="utf-8"){Te((0,we.dirname)(e)),(0,be.writeFileSync)(e,t,r)}function ke(e,t=!1){const r={files:[],dirs:[]};if(!Ae(e))return r;const i=(0,be.readdirSync)(e);for(const s of i){const i=(0,we.join)(e,s);if((0,be.lstatSync)(i).isDirectory()){if(r.dirs.push(i),t){const e=ke(i,!0);r.files.push(...e.files),r.dirs.push(...e.dirs)}}else r.files.push(i)}return r}function Ne(e,t=!1){const r=[];if(!Ae(e))return r;const i=(0,be.readdirSync)(e);for(const s of i){const i=(0,we.join)(e,s);(0,be.lstatSync)(i).isDirectory()&&(r.push(i),t&&r.push(...Ne(i,!0)))}return r}function Le(e){return xe(e)?(0,be.statSync)(e).size:0}function _e(e){let t=0;const r=ke(e,!0).files;for(const e of r)t+=Le(e);return t}function je(e,t="bak"){xe(e)&&Ie(e,`${e}.${t}.${(new Date).toISOString().replace(/[:.]/g,"-")}`)}function Re(e,t="bak"){const r=(0,we.dirname)(e),i=(0,we.basename)(e),s=(0,be.readdirSync)(r).filter(e=>e.startsWith(`${i}.${t}.`)).sort().reverse();if(0===s.length)throw new Error(`No backups found for ${e}`);return(0,we.join)(r,s[0])}function Pe(e,t="bak"){Ie(Re(e,t),e)}function $e(e,t,r=[]){if("string"!=typeof e)throw new TypeError("dirPath must be a string");if("function"!=typeof t)throw new TypeError("renameFn must be a function");if(!Array.isArray(r))throw new TypeError("extensions must be an array of strings");if(!(0,be.existsSync)(e)||!(0,be.statSync)(e).isDirectory())throw new Error(`Directory not found or invalid: ${e}`);for(const e of r)if("string"!=typeof e||!e.startsWith("."))throw new TypeError(`Invalid extension: ${e}`);const i=ke(e).files;let s=0;for(const n of i){const i=(0,we.extname)(n);if(r.length&&!r.includes(i))continue;const o=(0,we.basename)(n),a=t(o,s++),l=(0,we.join)(e,a);o!==a&&(0,be.renameSync)(n,l)}}function Oe(e,t,r,i=[]){$e(e,e=>{const i=(0,we.extname)(e);return`${(0,we.basename)(e,i).replace(t,r)}${i}`},i)}function He(e,{prefix:t="",suffix:r=""},i=[]){$e(e,e=>{const i=(0,we.extname)(e),s=(0,we.basename)(e,i);return`${t}${s}${r}${i}`},i)}function Fe(e,t="lower",r=[],i=!1){if("string"!=typeof t||!["lower","upper","title"].includes(t))throw new Error(`Invalid mode "${t}". Must be 'lower', 'upper' or 'title'.`);$e(e,e=>{const r=e=>"lower"===t?e.toLowerCase():"upper"===t?e.toUpperCase():"title"===t?q(e):e,s=(0,we.extname)(e),n=i?r(s):s;return`${r((0,we.basename)(e,s))}${n}`},r)}function Be(e,t=3,r=[]){$e(e,e=>e.replace(/\d+/,e=>e.padStart(t,"0")),r)}var ze=r(370);async function We(e){if(!(0,be.existsSync)(e))return;const t=await(0,ze.readdir)(e),r={},i=[];for(const s of t){const t=(0,we.join)(e,s),n=(0,ze.lstat)(t);n.then(e=>(r[t]=e,e)),i.push(n)}await Promise.all(i);const s=[];for(const e in r)r[e].isDirectory()?s.push((0,ze.rm)(e,{recursive:!0,force:!0})):s.push((0,ze.unlink)(e));await Promise.all(s)}async function Ve(e){return 0===(await(0,ze.readdir)(e)).length}async function qe(e,t=!1){const r={files:[],dirs:[]};if(!Ae(e))return r;const i=await(0,ze.readdir)(e);for(const s of i){const i=(0,we.join)(e,s);if((await(0,ze.lstat)(i)).isDirectory()){if(r.dirs.push(i),t){const e=await qe(i,!0);r.files.push(...e.files),r.dirs.push(...e.dirs)}}else r.files.push(i)}return r}async function Ke(e,t=!1){const r=[];if(!Ae(e))return r;const i=await(0,ze.readdir)(e);for(const s of i){const i=(0,we.join)(e,s);(await(0,ze.lstat)(i)).isDirectory()&&(r.push(i),t&&r.push(...await Ke(i,!0)))}return r}async function Je(e){return xe(e)?(await(0,ze.stat)(e)).size:0}async function Ue(e){let t=0;const{files:r}=await qe(e,!0),i=[];for(const e of r){const r=Je(e);r.then(e=>(t+=e,e)),i.push(r)}return await Promise.all(i),t}const Ge=(e,t)=>e.bottom<t.top,Ye=(e,t)=>e.top>t.bottom,Xe=(e,t)=>e.right<t.left,Qe=(e,t)=>e.left>t.right,Ze=(e,t)=>e.bottom<=t.top,et=(e,t)=>e.top>=t.bottom,tt=(e,t)=>e.right<=t.left,rt=(e,t)=>e.left>=t.right,it=(e,t)=>!(Xe(e,t)||Qe(e,t)||Ge(e,t)||Ye(e,t)),st=(e,t)=>!(tt(e,t)||rt(e,t)||Ze(e,t)||et(e,t)),nt=(e,t)=>Xe(e,t)?"left":Qe(e,t)?"right":Ge(e,t)?"top":Ye(e,t)?"bottom":null,ot=(e,t)=>tt(e,t)?"left":rt(e,t)?"right":Ze(e,t)?"top":et(e,t)?"bottom":null,at=(e,t)=>({overlapLeft:t.right-e.left,overlapRight:e.right-t.left,overlapTop:t.bottom-e.top,overlapBottom:e.bottom-t.top}),lt=({overlapLeft:e=-1,overlapRight:t=-1,overlapTop:r=-1,overlapBottom:i=-1}={})=>({dirX:e<t?"right":"left",dirY:r<i?"bottom":"top"}),ut=e=>({x:e.left+e.width/2,y:e.top+e.height/2});function ht(e,t){const r=e.left+e.width/2,i=e.top+e.height/2;return{x:t.left+t.width/2-r,y:t.top+t.height/2-i}}function ct(e,t){if(!st(e,t))return{inDir:null,dirX:null,dirY:null,depthX:0,depthY:0};const{overlapLeft:r,overlapRight:i,overlapTop:s,overlapBottom:n}=at(e,t),{dirX:o,dirY:a}=lt({overlapLeft:r,overlapRight:i,overlapTop:s,overlapBottom:n}),l=Math.min(r,i),u=Math.min(s,n);let h;return h=l<u?o:a,{inDir:h,dirX:o,dirY:a,depthX:l,depthY:u}}function dt(e,t){const r=st(e,t),i={in:null,x:null,y:null},s={y:null,x:null},n={top:0,bottom:0,left:0,right:0},{overlapLeft:o,overlapRight:a,overlapTop:l,overlapBottom:u}=at(t,e);n.top=l,n.bottom=u,n.left=o,n.right=a;const h=Object.entries(n).filter(([,e])=>e>0).sort((e,t)=>e[1]-t[1]),{dirX:c,dirY:d}=lt({overlapLeft:a,overlapRight:o,overlapTop:u,overlapBottom:l});return i.y=d,i.x=c,n.bottom<0?s.y="bottom":n.top<0&&(s.y="top"),n.left<0?s.x="left":n.right<0&&(s.x="right"),i.in=r?n.top===n.bottom&&n.bottom===n.left&&n.left===n.right?"center":h.length?h[0][0]:"top":null,{dirs:i,depth:n,isNeg:s}}const mt=ee("TinyElementObserver"),pt=class{#h=!1;get destroyed(){return this.#h}#G;get el(){return mt(this.#h),this.#G}#Y={};get settings(){return mt(this.#h),this.#Y}set settings(e){if(mt(this.#h),"object"!=typeof e||null===e)throw new TypeError("settings must be a non-null object.");this.#Y=e}#X=null;get observer(){return mt(this.#h),this.#X}#Q=[];get detectors(){return mt(this.#h),this.#Q.map(e=>[e[0],e[1]])}set detectors(e){if(mt(this.#h),!Array.isArray(e))throw new TypeError("detectors must be an array.");const t=[];for(const[r,i]of e){if("string"!=typeof r)throw new TypeError("Detector name must be a string.");if("function"!=typeof i)throw new TypeError(`Detector handler for "${r}" must be a function.`);t.push([r,i])}this.#Q=t}get isActive(){return mt(this.#h),!!this.#X}get size(){return mt(this.#h),this.#Q.length}constructor(e,{initDetectors:t=[],initCfg:r={}}={}){this.#G=e,t.length&&(this.detectors=t),r&&(this.settings=r)}clear(){mt(this.#h),this.#Q=[]}start(){if(mt(this.#h),!this.#G)throw new Error("Cannot start observation: no target element has been set.");this.#X||(this.#X=new MutationObserver(e=>{e.forEach((e,t,r)=>this.#Q.forEach(i=>i[1](e,t,r)))}),this.#X.observe(this.#G,this.#Y))}stop(){mt(this.#h),this.#X&&(this.#X.disconnect(),this.#X=null)}add(e,t){mt(this.#h),this.#Z(e,t),this.#Q.push([e,t])}insertAtStart(e,t){mt(this.#h),this.#Z(e,t),this.#Q.unshift([e,t])}insertAt(e,t,r,i="after"){if(mt(this.#h),this.#Z(t,r),"number"!=typeof e||e<0||e>=this.#Q.length)throw new RangeError("Invalid index for insertDetectorAt.");const s="before"===i?e:e+1;this.#Q.splice(s,0,[t,r])}removeAt(e){if(mt(this.#h),"number"!=typeof e||e<0||e>=this.#Q.length)throw new RangeError("Invalid index for removeDetectorAt.");this.#Q.splice(e,1)}removeAround(e,t=0,r=0){if(mt(this.#h),"number"!=typeof e||e<0||e>=this.#Q.length)throw new RangeError("Invalid index for removeDetectorsAround.");const i=Math.max(0,e-t),s=t+1+r;this.#Q.splice(i,s)}isIndexUsed(e){return mt(this.#h),e>=0&&e<this.#Q.length}hasHandler(e){if(mt(this.#h),"function"!=typeof e)throw new TypeError("Handler must be a function.");return this.#Q.some(([t,r])=>r===e)}#Z(e,t){if("string"!=typeof e||!e.trim())throw new TypeError("Detector name must be a non-empty string.");if("function"!=typeof t)throw new TypeError(`Detector handler for "${e}" must be a function.`)}destroy(){this.#h||(this.stop(),this.clear(),this.#h=!0)}},{wE:ft,D6:yt,Kr:gt,iu:bt,cq:wt,lP:vt}=i,Et=new WeakMap,Tt=new WeakMap,St=new WeakMap,xt=new WeakMap,At={top:new WeakMap,bottom:new WeakMap,left:new WeakMap,right:new WeakMap};class Ct{static Utils={...s};static#ee=1;static get version(){return this.#ee}static#te=!1;static get elemDebug(){return Ct.#te}static set elemDebug(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value for elemDebug");Ct.#te=e}static _debugElemError(e,t){if(!Ct.#te)return;const r="[TinyHtml Debug] Element validation error";if(console.groupCollapsed(`${r}${t?" — details below":""}`),console.error(r),"undefined"!=typeof Error&&"function"==typeof Error.captureStackTrace){const e=new Error(r);Error.captureStackTrace(e,Ct._debugElemError),console.error(e.stack)}else console.trace(r);if(Array.isArray(e)){const t=e.map((e,t)=>({index:t,typeOf:null===e?"null":typeof e,constructor:e?.constructor?.name??(null===e?"null":"primitive"),summary:"undefined"!=typeof Element&&e instanceof Element?`${e.tagName?.toLowerCase?.()??"element"}#${e.id||""}.${String(e.className||"").trim().replace(/\s+/g,".")}`:e&&"object"==typeof e&&"nodeType"in e?`nodeType:${e.nodeType}`:"",value:e}));console.table(t)}else console.warn('[TinyHtml Debug] "elems" is not an array:',e);arguments.length>1&&(console.error("[TinyHtml Debug] Problematic element:",t),t&&"object"==typeof t&&console.dir(t)),console.groupEnd()}static parseStyle(e){const t={};return e.split(";").forEach(e=>{const[r,i]=e.split(":").map(e=>e&&e.trim());r&&i&&(t[r]=i)}),t}static#re="undefined"!=typeof window&&void 0!==window.document?new pt(window.document.documentElement,{initDetectors:[["tinyStyleEvent",e=>{if("attributes"!==e.type||"style"!==e.attributeName||!(e.target instanceof HTMLElement))return;const t=e.oldValue||"",r=e.target.getAttribute("style")||"",i=G(Ct.parseStyle(t),Ct.parseStyle(r));(Object.keys(i.added).length||Object.keys(i.removed).length||Object.keys(i.modified).length)&&e.target.dispatchEvent(new CustomEvent("tinyhtml.stylechanged",{detail:i}))}],["tinyClassEvent",e=>{if("attributes"!==e.type||"class"!==e.attributeName||!(e.target instanceof HTMLElement))return;const t=e.oldValue||"",r=e.target.className||"",i=l(t.split(/\s+/).filter(Boolean),r.split(/\s+/).filter(Boolean));(i.added.length||i.removed.length)&&e.target.dispatchEvent(new CustomEvent("tinyhtml.classchanged",{detail:i}))}]],initCfg:{attributeOldValue:!0,attributes:!0,subtree:!0,attributeFilter:["style","class"]}}):void 0;static get tinyObserver(){return Ct.#re}static async fetchHtmlFile(e,t={method:"GET"}){const r=await fetch(e,t),i=r.headers.get("Content-Type")||"";if(!r.ok)throw new Error(`Failed to fetch: ${r.status} ${r.statusText}`);if(!i.includes("text/html"))throw new Error(`Invalid content type: ${i} (expected text/html)`);const s=await r.text();return Ct.htmlToJson(s)}static async fetchHtmlNodes(e,t){const r=await Ct.fetchHtmlFile(e,t);return Ct.jsonToNodes(r)}static async fetchHtmlTinyElems(e,t){const r=await Ct.fetchHtmlNodes(e,t);return Ct.toTinyElm(r)}static templateToJson(e){return Ct.htmlToJson([...e.content.childNodes].map(e=>e instanceof Element?e.getHTML():e instanceof Text?e.textContent:"").join(""))}static templateToNodes(e){const t=[];return[...e.content.cloneNode(!0).childNodes].map(e=>{if(!(e instanceof Element||e instanceof Text||e instanceof Comment))throw new Error(`Expected only Element nodes in <template>, but found: ${e.constructor.name}`);e instanceof Comment||t.push(e)}),t}static templateToTinyElems(e){return Ct.toTinyElm(Ct.templateToNodes(e))}static htmlToJson(e){const t=document.createElement("div");t.innerHTML=e.trim();const r=[],i=e=>{if(e instanceof Comment)return null;if(e instanceof Text){const t=e.textContent?.trim();return t||null}if(!(e instanceof Element))return null;const t=e.tagName.toLowerCase(),r={};for(const t of e.attributes)r[Ct.getPropName(t.name)]=t.value;const s=Array.from(e.childNodes).map(i).filter(Boolean);return s.length>0?[t,r,...s]:[t,r]};for(const e of t.childNodes){const t=i(e);t&&r.push(t)}return t.innerHTML="",r}static jsonToNodes(e){const t=e=>{if("string"==typeof e)return document.createTextNode(e);if(!Array.isArray(e))return document.createTextNode("");const[r,i,...s]=e,n=document.createElement(r);for(const[e,t]of Object.entries(i))n.setAttribute(Ct.getAttrName(e),t);for(const e of s){const r=t(e);r instanceof Comment||n.appendChild(r)}return n};return e.map(t).filter(e=>!(e instanceof Comment))}static jsonToTinyElems(e){return Ct.toTinyElm(Ct.jsonToNodes(e))}static createFrom(e,t){if("string"!=typeof e)throw new TypeError('The "tagName" must be a string.');if(void 0!==t&&"object"!=typeof t)throw new TypeError('The "attrs" must be a object.');const r=Ct.createElement(e);if("object"==typeof t)for(const e in t)r.setAttr(e,t[e]);return r}static createElement(e,t){if("string"!=typeof e)throw new TypeError("[TinyHtml] createElement(): The tagName must be a string.");if(void 0!==t&&"object"!=typeof t)throw new TypeError("[TinyHtml] createElement(): The ops must be a object.");return new Ct(document.createElement(e,t))}static createTextNode(e){if("string"!=typeof e)throw new TypeError("[TinyHtml] createTextNode(): The value must be a string.");return new Ct(document.createTextNode(e))}static createElementFromHTML(e){const t=document.createElement("template");if(!(e=e.trim()).startsWith("<"))return Ct.createTextNode(e);if(t.innerHTML=e,!(t.content.firstChild instanceof Element))throw new Error("The HTML string must contain a valid HTML element.");return new Ct(t.content.firstChild)}static createFromHTML(e){const t=document.createElement("template");e=e.trim(),t.innerHTML=e;const r=Array.from(t.content.childNodes);if(!r.every(e=>e instanceof Element||e instanceof Text))throw new Error("The HTML string must contain a valid HTML element.");return new Ct(r)}static createFromHtml(e){return Ct.createFromHTML(e)}static query(e,t=document){const r=t.querySelector(e);return r?new Ct(r):null}querySelector(e){return Ct.query(e,Ct._preElem(this,"query"))}static queryAll(e,t=document){return new Ct(t.querySelectorAll(e))}querySelectorAll(e){return Ct.queryAll(e,Ct._preElem(this,"queryAll"))}static getById(e){const t=document.getElementById(e);return t?new Ct(t):null}static getByClassName(e,t=document){return new Ct(t.getElementsByClassName(e))}getElementsByClassName(e){return Ct.getByClassName(e,Ct._preElem(this,"getByClassName"))}static getByName(e){return new Ct(document.getElementsByName(e))}static getByTagNameNS(e,t="http://www.w3.org/1999/xhtml",r=document){return new Ct(r.getElementsByTagNameNS(t,e))}getElementsByTagNameNS(e,t="http://www.w3.org/1999/xhtml"){return Ct.getByTagNameNS(e,t,Ct._preElem(this,"getByTagNameNS"))}get elements(){return[...this.#G]}forEach(e){const t=this.elements.map((e,t)=>this.extract(t));for(const r in t)e(t[r],Number(r),t);return this}get(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");if(!this.#G[e])throw new Error(`No element found at index ${e}.`);return this.#G[e]}extract(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");if(!this.#G[e])throw new Error(`Cannot extract: no element exists at index ${e}.`);return new Ct(this.#G[e])}exists(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");return!!this.#G[e]}_getElement(e,t){if(!(this.#G[t]instanceof Element||this.#G[t]instanceof Window||this.#G[t]instanceof Document||this.#G[t]instanceof Text))throw Ct._debugElemError([...this.#G],this.#G[t]),new Error(`[TinyHtml] Invalid Element in ${e}().`);return this.#G[t]}_getElements(e){if(!this.#G.every(e=>e instanceof Element||e instanceof Window||e instanceof Document||e instanceof Text))throw Ct._debugElemError([...this.#G]),new Error(`[TinyHtml] Invalid Element in ${e}().`);return[...this.#G]}static _preElemsTemplate(e,t,r,i){const s=e=>{const s=[];return e.map(n=>(n instanceof Ct?n._getElements(t):[n]).map(n=>{let o=!1;for(const e of r)if(n instanceof e){o=!0;break}if(!o)throw Ct._debugElemError([...e],n),new Error(`[TinyHtml] Invalid element of the list "${i.join(",")}" in ${t}().`);return s.push(n),n})),s};return Array.isArray(e)?s(e):s([e])}_preElemsTemplate(e,t,r){return Ct._preElemsTemplate(this,e,t,r)}static _preElemTemplate(e,t,r,i,s=!1){const n=e=>{const n=e[0],o=n instanceof Ct?n._getElements(t):[n];if(o.length>1)throw Ct._debugElemError([...e]),new Error(`[TinyHtml] Invalid element amount in ${t}() (Received ${o.length}/1).`);let a=!1;for(const e of r)if(o[0]instanceof e){a=!0;break}if(!s||null!==o[0]&&void 0!==o[0]||(o[0]=null,a=!0),!a)throw Ct._debugElemError([...e],o[0]),new Error(`[TinyHtml] Invalid element of the list "${i.join(",")}" in ${t}().`);return o[0]};if(!Array.isArray(e))return n([e]);if(e.length>1)throw Ct._debugElemError([...e]),new Error(`[TinyHtml] Invalid element amount in ${t}() (Received ${e.length}/1).`);return n(e)}_preElemTemplate(e,t,r,i=!1){return Ct._preElemTemplate(this,e,t,r,i)}static _preElems(e,t){return Ct._preElemsTemplate(e,t,[Element],["Element"])}_preElems(e){return Ct._preElems(this,e)}static _preElem(e,t){return Ct._preElemTemplate(e,t,[Element],["Element"])}_preElem(e){return Ct._preElem(this,e)}static _preNodeElems(e,t){return Ct._preElemsTemplate(e,t,[Node],["Node"])}_preNodeElems(e){return Ct._preNodeElems(this,e)}static _preNodeElem(e,t){return Ct._preElemTemplate(e,t,[Node],["Node"])}_preNodeElem(e){return Ct._preNodeElem(this,e)}static _preNodeElemWithNull(e,t){return Ct._preElemTemplate(e,t,[Node],["Node"],!0)}_preNodeElemWithNull(e){return Ct._preNodeElemWithNull(this,e)}static _preHtmlElems(e,t){return Ct._preElemsTemplate(e,t,[HTMLElement],["HTMLElement"])}_preHtmlElems(e){return Ct._preHtmlElems(this,e)}static _preHtmlElem(e,t){return Ct._preElemTemplate(e,t,[HTMLElement],["HTMLElement"])}_preHtmlElem(e){return Ct._preHtmlElem(this,e)}static _preInputElems(e,t){return Ct._preElemsTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElems(e){return Ct._preInputElems(this,e)}static _preInputElem(e,t){return Ct._preElemTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElem(e){return Ct._preInputElem(this,e)}static _preEventTargetElems(e,t){return Ct._preElemsTemplate(e,t,[EventTarget],["EventTarget"])}_preEventTargetElems(e){return Ct._preEventTargetElems(this,e)}static _preEventTargetElem(e,t){return Ct._preElemTemplate(e,t,[EventTarget],["EventTarget"])}_preEventTargetElem(e){return Ct._preEventTargetElem(this,e)}static _preElemsAndWindow(e,t){return Ct._preElemsTemplate(e,t,[Element,Window],["Element","Window"])}_preElemsAndWindow(e){return Ct._preElemsAndWindow(this,e)}static _preElemAndWindow(e,t){return Ct._preElemTemplate(e,t,[Element,Window],["Element","Window"])}_preElemAndWindow(e){return Ct._preElemAndWindow(this,e)}static _preElemsAndWinAndDoc(e,t){return Ct._preElemsTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]).map(e=>e instanceof Document?e.documentElement:e)}_preElemsAndWinAndDoc(e){return Ct._preElemsAndWinAndDoc(this,e)}static _preElemAndWinAndDoc(e,t){const r=Ct._preElemTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]);return r instanceof Document?r.documentElement:r}_preElemAndWinAndDoc(e){return Ct._preElemAndWinAndDoc(this,e)}static _preElemsWithDoc(e,t){return Ct._preElemsTemplate(e,t,[Element,Document],["Element","Document"])}_preElemsWithDoc(e){return Ct._preElemsWithDoc(this,e)}static _preElemWithDoc(e,t){return Ct._preElemTemplate(e,t,[Element,Document],["Element","Document"])}_preElemWithDoc(e){return Ct._preElemWithDoc(this,e)}static toTinyElm(e){const t=e=>e.map(e=>e instanceof Ct?e:new Ct(e));return Array.isArray(e)?t(e):t([e])}static fromTinyElm(e){const t=e=>{const t=[];return e.map(e=>(e instanceof Ct?e._getElements("fromTinyElm"):[e]).map(e=>t.push(e))),t};return Array.isArray(e)?t(e):t([e])}static winnow(e,t,r,i=!1){if("boolean"!=typeof i)throw new TypeError('The "not" must be a boolean.');if("function"==typeof t)return Ct._preElems(e,r).filter((e,r)=>!!t.call(e,r,e)!==i);if(t instanceof Element)return Ct._preElems(e,r).filter(e=>e===t!==i);if(Array.isArray(t)||"string"!=typeof t&&null!=t.length)return Ct._preElems(e,r).filter(e=>t.includes(e)!==i);let s=t;return i&&(s=`:not(${s})`),Ct._preElems(e,r).filter(e=>1===e.nodeType&&e.matches(s))}static filter(e,t,r=!1){return r&&(t=`:not(${t})`),Ct._preElems(e,"filter").filter(e=>1===e.nodeType&&e.matches(t))}static filterOnly(e,t){return Ct.winnow(e,t,"filterOnly",!1)}static not(e,t){return Ct.winnow(e,t,"not",!0)}not(e){return Ct.not(this,e)}static find(e,t){const r=[];for(const i of Ct._preElems(e,"find"))r.push(...i.querySelectorAll(t));return[...new Set(r)]}find(e){return Ct.find(this,e)}static is(e,t){return Ct.winnow(e,t,"is",!1).length>0}is(e){return Ct.is(this,e)}static has(e,t){const r="string"==typeof t?[...document.querySelectorAll(t)]:Ct._preElems(t,"has");return Ct._preElems(e,"has").filter(e=>r.some(t=>e&&e.contains(t)))}has(e){return Ct.has(this,e)}static closest(e,t,r){const i=[];for(const s of Ct._preElems(e,"closest")){let e=s;for(;e&&e!==r;){if(1===e.nodeType&&("string"==typeof t?e.matches(t):e===t)){i.push(e);break}e=e.parentElement}}return[...new Set(i)]}closest(e,t){return Ct.closest(this,e,t)}static isSameDom(e,t){return Ct._preNodeElem(e,"isSameDom")===Ct._preNodeElem(t,"isSameDom")}isSameDom(e){return Ct.isSameDom(this,e)}#ie={};get _data(){return{...this.#ie}}set _data(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new Error("value must be a non-null object.");this.#ie=e}static _dataSelector={public:(e,t)=>{const r=Ct._preElem(t,e);let i=Tt.get(r);return i||(i={},Tt.set(r,i)),i},private:(e,t)=>{if(!(t instanceof Ct))throw new Error(`Element must be a TinyHtml instance to execute ${e}().`);return t.#ie}};static data(e,t,r=!1){const i=Ct._dataSelector[r?"private":"public"]("data",e);if(null==t)return{...i};if("string"!=typeof t)throw new TypeError("The key must be a string.");return i.hasOwnProperty(t)?i[t]:void 0}data(e,t){return Ct.data(this,e,t)}static setData(e,t,r,i=!1){const s=Ct._dataSelector[i?"private":"public"]("setData",e);if("string"!=typeof t)throw new TypeError("The key must be a string.");return void 0!==r?s[t]=r:Ct.removeData(e,t),e}setData(e,t,r=!1){return Ct.setData(this,e,t,r)}static hasData(e,t,r=!1){if("string"!=typeof t)throw new TypeError("The key must be a string.");const i=Ct._dataSelector[r?"private":"public"]("hasData",e);return Object.prototype.hasOwnProperty.call(i,t)}hasData(e,t=!1){return Ct.hasData(this,e,t)}static removeData(e,t,r=!1){if("string"!=typeof t)throw new TypeError("The key must be a string.");return delete Ct._dataSelector[r?"private":"public"]("removeData",e)[t]}removeData(e,t=!1){return Ct.removeData(this,e,t)}static _getSibling(e,t,r){let i=Ct._preNodeElemWithNull(e,r);for(;i&&(i=i[t])&&1!==i.nodeType;);return i instanceof Node?i:null}static _getSiblings(e,t){let r=e;const i=[];for(;r;r=r.nextSibling)1===r.nodeType&&r!==t&&i.push(r);return i}static domDir(e,t,r,i="domDir"){if("string"!=typeof t)throw new TypeError('The "direction" must be a string.');let s=Ct._preNodeElemWithNull(e,i);const n=[];for(;s&&(s=s[t]);)if(1===s.nodeType){if(r&&("string"==typeof r?s.matches(r):s===r))break;n.push(s)}return n}static parent(e){let t=Ct._preNodeElemWithNull(e,"parent");const r=t?t.parentNode:null;return r&&11!==r.nodeType?r:null}parent(){return Ct.parent(this)}static parents(e,t){return Ct.domDir(e,"parentNode",t,"parents")}parents(e){return Ct.parents(this,e)}static next(e){return Ct._getSibling(e,"nextSibling","next")}next(){return Ct.next(this)}static prev(e){return Ct._getSibling(e,"previousSibling","prev")}prev(){return Ct.prev(this)}static nextAll(e){return Ct.domDir(e,"nextSibling",void 0,"nextAll")}nextAll(){return Ct.nextAll(this)}static prevAll(e){return Ct.domDir(e,"previousSibling",void 0,"prevAll")}prevAll(){return Ct.prevAll(this)}static nextUntil(e,t){return Ct.domDir(e,"nextSibling",t,"nextUtil")}nextUntil(e){return Ct.nextUntil(this,e)}static prevUntil(e,t){return Ct.domDir(e,"previousSibling",t,"prevUtil")}prevUntil(e){return Ct.prevUntil(this,e)}static siblings(e){const t=Ct._preNodeElemWithNull(e,"siblings");return Ct._getSiblings(t&&t.parentNode?t.parentNode.firstChild:null,t)}siblings(){return Ct.siblings(this)}static children(e){const t=Ct._preNodeElemWithNull(e,"children");return Ct._getSiblings(t?t.firstChild:null)}children(){return Ct.children(this)}static contents(e){const t=Ct._preNodeElemWithNull(e,"contents");return t instanceof HTMLIFrameElement&&null!=t.contentDocument&&Object.getPrototypeOf(t.contentDocument)?[t.contentDocument]:t instanceof HTMLTemplateElement?Array.from((t.content||t).childNodes):t?Array.from(t.childNodes):[]}contents(){return Ct.contents(this)}static clone(e,t=!0){if("boolean"!=typeof t)throw new TypeError('The "deep" must be a boolean.');return Ct._preNodeElems(e,"clone").map(e=>e.cloneNode(t))}clone(e){return Ct.clone(this,e)[0]}static _appendChecker(e,...t){const r=[];for(const i of t)if(null!=i&&!1!==i)if("string"!=typeof i&&"number"!=typeof i)if(i instanceof Node||i instanceof Ct)r.push(...Ct._preNodeElems(i,e));else if(Array.isArray(i))r.push(...Ct._appendChecker(e,...i));else for(const t in i){const s=i[t];r.push(...Ct._appendChecker(e,s))}else r.push(i);return r}static append(e,...t){return Ct._preElem(e,"append").append(...Ct._appendChecker("append",...t)),e}append(...e){return Ct.append(this,...e)}static prepend(e,...t){return Ct._preElem(e,"prepend").prepend(...Ct._appendChecker("prepend",...t)),e}prepend(...e){return Ct.prepend(this,...e)}static before(e,...t){return Ct._preElem(e,"before").before(...Ct._appendChecker("before",...t)),e}before(...e){return Ct.before(this,...e)}static after(e,...t){return Ct._preElem(e,"after").after(...Ct._appendChecker("after",...t)),e}after(...e){return Ct.after(this,...e)}static replaceWith(e,...t){return Ct._preElem(e,"replaceWith").replaceWith(...Ct._appendChecker("replaceWith",...t)),e}replaceWith(...e){return Ct.replaceWith(this,...e)}static appendTo(e,t){const r=Ct._preNodeElems(e,"appendTo"),i=Ct._preNodeElems(t,"appendTo");return i.forEach((e,t)=>{r.forEach(r=>e.appendChild(t===i.length-1?r:r.cloneNode(!0)))}),e}appendTo(e){return Ct.appendTo(this,e)}static prependTo(e,t){const r=Ct._preElems(e,"prependTo"),i=Ct._preElems(t,"prependTo");return i.forEach((e,t)=>{r.slice().reverse().forEach(r=>e.prepend(t===i.length-1?r:r.cloneNode(!0)))}),e}prependTo(e){return Ct.prependTo(this,e)}static insertBefore(e,t,r=null){const i=Ct._preNodeElem(e,"insertBefore"),s=Ct._preNodeElem(t,"insertBefore"),n=Ct._preNodeElemWithNull(r,"insertBefore");if(!s.parentNode)throw new Error("The target element has no parent node to insert before.");return s.parentNode.insertBefore(i,n||s),e}insertBefore(e,t){return Ct.insertBefore(this,e,t)}static insertAfter(e,t,r=null){const i=Ct._preNodeElem(e,"insertAfter"),s=Ct._preNodeElem(t,"insertBefore"),n=Ct._preNodeElemWithNull(r,"insertBefore");if(!s.parentNode)throw new Error("The target element has no parent node to insert after.");return s.parentNode.insertBefore(i,n||s.nextSibling),e}insertAfter(e,t){return Ct.insertAfter(this,e,t)}static replaceAll(e,t){const r=Ct._preNodeElems(e,"replaceAll"),i=Ct._preNodeElems(t,"replaceAll");return i.forEach((e,t)=>{const s=e.parentNode;r.forEach(r=>{s&&s.replaceChild(t===i.length-1?r:r.cloneNode(!0),e)})}),e}replaceAll(e){return Ct.replaceAll(this,e)}#G;get size(){return this.#G.length}static _elCheck(e){for(const t of e)if(!(t instanceof Element||t instanceof Window||t instanceof Document||t instanceof Text))throw new Error("[TinyHtml] Invalid Target in constructor.")}add(e){return new Ct([...this.#G,...Ct._selector(e)])}static _selector(e){if(e instanceof Ct)throw new Error("[TinyHtml] You are trying to put a TinyHtml inside another TinyHtml in constructor.");const t=e=>Array.from(new Set(e)),r="string"!=typeof e?e:document.querySelectorAll(e);if(Array.isArray(r))return Ct._elCheck(r),t(r);if(r instanceof NodeList||r instanceof HTMLCollection){const e=[...r];return Ct._elCheck(e),t(e)}{const e=[r];return Ct._elCheck(e),t(e)}}constructor(e){this.#G=Ct._selector(e),this.#se=Ct.#ne}static isWindow(e){return null!=e&&e===e.window}static css(e){const t=Ct._preElem(e,"css");return window.getComputedStyle(t)}css(){return Ct.css(this)}static cssString(e,t){const r=Ct._preElem(e,"cssString");if("string"!=typeof t)throw new TypeError("The prop must be a string.");const i=window.getComputedStyle(r)[t];return"string"==typeof i?i:"number"==typeof i?i.toString():null}cssString(e){return Ct.cssString(this,e)}static cssList(e,t){const r=Ct._preElem(e,"cssList");if(!Array.isArray(t))throw new TypeError("The prop must be an array of strings.");const i=window.getComputedStyle(r),s={};for(const e of t)void 0!==e&&(s[e]=i.getPropertyValue(e));return s}cssList(e){return Ct.cssList(this,e)}static cssFloat(e,t){const r=Ct._preElem(e,"cssFloat");if("string"!=typeof t)throw new TypeError("The prop must be a string.");const i=window.getComputedStyle(r)[t];return parseFloat(i)||0}cssFloat(e){return Ct.cssFloat(this,e)}static cssFloats(e,t){const r=Ct._preElem(e,"cssFloats");if(!Array.isArray(t))throw new TypeError("The prop must be an array of strings.");const i=window.getComputedStyle(r),s={};for(const e of t)s[e]=parseFloat(i[e])||0;return s}cssFloats(e){return Ct.cssFloats(this,e)}static#oe={alignContent:"align-content",alignItems:"align-items",alignSelf:"align-self",animationDelay:"animation-delay",animationDirection:"animation-direction",animationDuration:"animation-duration",animationFillMode:"animation-fill-mode",animationIterationCount:"animation-iteration-count",animationName:"animation-name",animationPlayState:"animation-play-state",animationTimingFunction:"animation-timing-function",backfaceVisibility:"backface-visibility",backgroundAttachment:"background-attachment",backgroundBlendMode:"background-blend-mode",backgroundClip:"background-clip",backgroundColor:"background-color",backgroundImage:"background-image",backgroundOrigin:"background-origin",backgroundPosition:"background-position",backgroundRepeat:"background-repeat",backgroundSize:"background-size",borderBottom:"border-bottom",borderBottomColor:"border-bottom-color",borderBottomLeftRadius:"border-bottom-left-radius",borderBottomRightRadius:"border-bottom-right-radius",borderBottomStyle:"border-bottom-style",borderBottomWidth:"border-bottom-width",borderCollapse:"border-collapse",borderColor:"border-color",borderImage:"border-image",borderImageOutset:"border-image-outset",borderImageRepeat:"border-image-repeat",borderImageSlice:"border-image-slice",borderImageSource:"border-image-source",borderImageWidth:"border-image-width",borderLeft:"border-left",borderLeftColor:"border-left-color",borderLeftStyle:"border-left-style",borderLeftWidth:"border-left-width",borderRadius:"border-radius",borderRight:"border-right",borderRightColor:"border-right-color",borderRightStyle:"border-right-style",borderRightWidth:"border-right-width",borderSpacing:"border-spacing",borderStyle:"border-style",borderTop:"border-top",borderTopColor:"border-top-color",borderTopLeftRadius:"border-top-left-radius",borderTopRightRadius:"border-top-right-radius",borderTopStyle:"border-top-style",borderTopWidth:"border-top-width",borderWidth:"border-width",boxDecorationBreak:"box-decoration-break",boxShadow:"box-shadow",boxSizing:"box-sizing",breakAfter:"break-after",breakBefore:"break-before",breakInside:"break-inside",captionSide:"caption-side",caretColor:"caret-color",clipPath:"clip-path",columnCount:"column-count",columnFill:"column-fill",columnGap:"column-gap",columnRule:"column-rule",columnRuleColor:"column-rule-color",columnRuleStyle:"column-rule-style",columnRuleWidth:"column-rule-width",columnSpan:"column-span",columnWidth:"column-width",counterIncrement:"counter-increment",counterReset:"counter-reset",emptyCells:"empty-cells",flexBasis:"flex-basis",flexDirection:"flex-direction",flexFlow:"flex-flow",flexGrow:"flex-grow",flexShrink:"flex-shrink",flexWrap:"flex-wrap",fontFamily:"font-family",fontFeatureSettings:"font-feature-settings",fontKerning:"font-kerning",fontLanguageOverride:"font-language-override",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontSynthesis:"font-synthesis",fontVariant:"font-variant",fontVariantAlternates:"font-variant-alternates",fontVariantCaps:"font-variant-caps",fontVariantEastAsian:"font-variant-east-asian",fontVariantLigatures:"font-variant-ligatures",fontVariantNumeric:"font-variant-numeric",fontVariantPosition:"font-variant-position",fontWeight:"font-weight",gridArea:"grid-area",gridAutoColumns:"grid-auto-columns",gridAutoFlow:"grid-auto-flow",gridAutoRows:"grid-auto-rows",gridColumn:"grid-column",gridColumnEnd:"grid-column-end",gridColumnGap:"grid-column-gap",gridColumnStart:"grid-column-start",gridGap:"grid-gap",gridRow:"grid-row",gridRowEnd:"grid-row-end",gridRowGap:"grid-row-gap",gridRowStart:"grid-row-start",gridTemplate:"grid-template",gridTemplateAreas:"grid-template-areas",gridTemplateColumns:"grid-template-columns",gridTemplateRows:"grid-template-rows",imageRendering:"image-rendering",justifyContent:"justify-content",letterSpacing:"letter-spacing",lineBreak:"line-break",lineHeight:"line-height",listStyle:"list-style",listStyleImage:"list-style-image",listStylePosition:"list-style-position",listStyleType:"list-style-type",marginBottom:"margin-bottom",marginLeft:"margin-left",marginRight:"margin-right",marginTop:"margin-top",maskClip:"mask-clip",maskComposite:"mask-composite",maskImage:"mask-image",maskMode:"mask-mode",maskOrigin:"mask-origin",maskPosition:"mask-position",maskRepeat:"mask-repeat",maskSize:"mask-size",maskType:"mask-type",maxHeight:"max-height",maxWidth:"max-width",minHeight:"min-height",minWidth:"min-width",mixBlendMode:"mix-blend-mode",objectFit:"object-fit",objectPosition:"object-position",offsetAnchor:"offset-anchor",offsetDistance:"offset-distance",offsetPath:"offset-path",offsetRotate:"offset-rotate",outlineColor:"outline-color",outlineOffset:"outline-offset",outlineStyle:"outline-style",outlineWidth:"outline-width",overflowAnchor:"overflow-anchor",overflowWrap:"overflow-wrap",overflowX:"overflow-x",overflowY:"overflow-y",paddingBottom:"padding-bottom",paddingLeft:"padding-left",paddingRight:"padding-right",paddingTop:"padding-top",pageBreakAfter:"page-break-after",pageBreakBefore:"page-break-before",pageBreakInside:"page-break-inside",perspectiveOrigin:"perspective-origin",placeContent:"place-content",placeItems:"place-items",placeSelf:"place-self",pointerEvents:"pointer-events",rowGap:"row-gap",scrollBehavior:"scroll-behavior",scrollMargin:"scroll-margin",scrollMarginBlock:"scroll-margin-block",scrollMarginBlockEnd:"scroll-margin-block-end",scrollMarginBlockStart:"scroll-margin-block-start",scrollMarginBottom:"scroll-margin-bottom",scrollMarginInline:"scroll-margin-inline",scrollMarginInlineEnd:"scroll-margin-inline-end",scrollMarginInlineStart:"scroll-margin-inline-start",scrollMarginLeft:"scroll-margin-left",scrollMarginRight:"scroll-margin-right",scrollMarginTop:"scroll-margin-top",scrollPadding:"scroll-padding",scrollPaddingBlock:"scroll-padding-block",scrollPaddingBlockEnd:"scroll-padding-block-end",scrollPaddingBlockStart:"scroll-padding-block-start",scrollPaddingBottom:"scroll-padding-bottom",scrollPaddingInline:"scroll-padding-inline",scrollPaddingInlineEnd:"scroll-padding-inline-end",scrollPaddingInlineStart:"scroll-padding-inline-start",scrollPaddingLeft:"scroll-padding-left",scrollPaddingRight:"scroll-padding-right",scrollPaddingTop:"scroll-padding-top",scrollSnapAlign:"scroll-snap-align",scrollSnapStop:"scroll-snap-stop",scrollSnapType:"scroll-snap-type",shapeImageThreshold:"shape-image-threshold",shapeMargin:"shape-margin",shapeOutside:"shape-outside",tabSize:"tab-size",tableLayout:"table-layout",textAlign:"text-align",textAlignLast:"text-align-last",textCombineUpright:"text-combine-upright",textDecoration:"text-decoration",textDecorationColor:"text-decoration-color",textDecorationLine:"text-decoration-line",textDecorationStyle:"text-decoration-style",textIndent:"text-indent",textJustify:"text-justify",textOrientation:"text-orientation",textOverflow:"text-overflow",textShadow:"text-shadow",textTransform:"text-transform",transformBox:"transform-box",transformOrigin:"transform-origin",transformStyle:"transform-style",transitionDelay:"transition-delay",transitionDuration:"transition-duration",transitionProperty:"transition-property",transitionTimingFunction:"transition-timing-function",unicodeBidi:"unicode-bidi",userSelect:"user-select",verticalAlign:"vertical-align",whiteSpace:"white-space",willChange:"will-change",wordBreak:"word-break",wordSpacing:"word-spacing",wordWrap:"word-wrap",writingMode:"writing-mode",zIndex:"z-index",WebkitTransform:"-webkit-transform",WebkitTransition:"-webkit-transition",WebkitBoxShadow:"-webkit-box-shadow",MozBoxShadow:"-moz-box-shadow",MozTransform:"-moz-transform",MozTransition:"-moz-transition",msTransform:"-ms-transform",msTransition:"-ms-transition"};static cssPropAliases=new Proxy(Ct.#oe,{set:(e,t,r)=>(e[t]=r,Ct.cssPropRevAliases[r]=t,!0)});static cssPropRevAliases=Object.fromEntries(Object.entries(Ct.#oe).map(([e,t])=>[t,e]));static toStyleKc(e){return"string"==typeof Ct.cssPropAliases[e]?Ct.cssPropAliases[e]:e}static toStyleCc(e){return"string"==typeof Ct.cssPropRevAliases[e]?Ct.cssPropRevAliases[e]:e}static setStyle(e,t,r=null){return Ct._preHtmlElems(e,"setStyle").forEach(e=>{if("object"==typeof t)for(const[r,i]of Object.entries(t))e.style.setProperty(Ct.toStyleKc(r),"string"==typeof i?i:"number"==typeof i?`${i}px`:String(i));else e.style.setProperty(Ct.toStyleKc(t),r)}),e}setStyle(e,t){return Ct.setStyle(this,e,t)}static getStyle(e,t){return Ct._preHtmlElem(e,"getStyle").style.getPropertyValue(Ct.toStyleKc(t))}getStyle(e){return Ct.getStyle(this,e)}static style(e,{camelCase:t=!1,rawAttr:r=!1}={}){if("boolean"!=typeof t)throw new TypeError('"camelCase" must be a boolean. Received: '+typeof t);if("boolean"!=typeof r)throw new TypeError('"rawAttr" must be a boolean. Received: '+typeof r);const i=Ct._preHtmlElem(e,"style"),s={};if(r){const e=(i.getAttribute("style")||"").split(";");for(const r of e){const[e,i]=r.split(":");if(!e||!i)continue;const n=e.trim(),o=i.trim();s[t?Ct.toStyleCc(n):n]=o}}else{const e=i.style;for(let r=0;r<e.length;r++){const i=e[r],n=e.getPropertyValue(i);s[t?Ct.toStyleCc(i):i]=n}}return s}style(e){return Ct.style(this,e)}static removeStyle(e,t){return Ct._preHtmlElems(e,"removeStyle").forEach(e=>{if(Array.isArray(t))for(const r of t)e.style.removeProperty(Ct.toStyleKc(r));else e.style.removeProperty(Ct.toStyleKc(t))}),e}removeStyle(e){return Ct.removeStyle(this,e)}static toggleStyle(e,t,r,i){return Ct._preHtmlElems(e,"toggleStyle").forEach(e=>{const s=Ct.getStyle(e,t).trim()===Ct.toStyleKc(r)?i:r;Ct.setStyle(e,t,s)}),e}toggleStyle(e,t,r){return Ct.toggleStyle(this,e,t,r)}static clearStyle(e){return Ct._preElems(e,"clearStyle").forEach(e=>e.removeAttribute("style")),e}clearStyle(){return Ct.clearStyle(this)}static focus(e){return Ct._preHtmlElem(e,"focus").focus(),e}focus(){return Ct.focus(this)}static blur(e){return Ct._preHtmlElem(e,"blur").blur(),e}blur(){return Ct.blur(this)}static select(e){const t=Ct._preHtmlElem(e,"select");if(!(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement))throw new Error("Element must be an <input> or <textarea> to use select().");return t.select(),e}select(){return Ct.select(this)}static boolCheck(e){return void 0!==e&&("true"===e||"1"===e||!0===e||"on"===e||"number"==typeof e&&e>0)}static setWinScrollTop(e){if("number"!=typeof e)throw new TypeError("The value must be a number.");Ct.setScrollTop(window,e)}static setWinScrollLeft(e){if("number"!=typeof e)throw new TypeError("The value must be a number.");Ct.setScrollLeft(window,e)}static winScrollTop(){return window.scrollY||document.documentElement.scrollTop}static winScrollLeft(){return window.scrollX||document.documentElement.scrollLeft}static winInnerHeight(){return window.innerHeight||document.documentElement.clientHeight}static winInnerWidth(){return window.innerWidth||document.documentElement.clientWidth}static isPageTop(){return 0===window.scrollY}static isPageBottom(){return window.innerHeight+window.scrollY>=document.body.offsetHeight}static getDimension(e,t,r="content"){const i=Ct._preElemAndWinAndDoc(e,"getDimension");if("string"!=typeof t)throw new TypeError("The type must be a string.");if("string"!=typeof r)throw new TypeError("The extra must be a string.");const s="width"===t?"Width":"Height";if(Ct.isWindow(i))return"margin"===r?i["inner"+s]:i.document.documentElement["client"+s];const n=i;if(9===n.nodeType){const e=n.documentElement;return Math.max(n.body["scroll"+s],e["scroll"+s],n.body["offset"+s],e["offset"+s],e["client"+s])}let o=n.getBoundingClientRect()[t];function a(e){return"width"===t?Ct.cssFloat(n,e+"Left")+Ct.cssFloat(n,e+"Right"):Ct.cssFloat(n,e+"Top")+Ct.cssFloat(n,e+"Bottom")}switch(r){case"content":o-=a("padding"),o-=a("border");break;case"padding":o-=a("border");break;case"border":break;case"margin":o+=a("margin")}return o}getDimension(e,t){return Ct.getDimension(this,e,t)}static setHeight(e,t){const r=Ct._preHtmlElem(e,"setHeight");if("number"!=typeof t&&"string"!=typeof t)throw new TypeError("The value must be a string or number.");return r.style.height="number"==typeof t?`${t}px`:t,e}setHeight(e){return Ct.setHeight(this,e)}set height(e){Ct.setHeight(this,e)}static setWidth(e,t){const r=Ct._preHtmlElem(e,"setWidth");if("number"!=typeof t&&"string"!=typeof t)throw new TypeError("The value must be a string or number.");return r.style.width="number"==typeof t?`${t}px`:t,e}setWidth(e){return Ct.setWidth(this,e)}set width(e){Ct.setWidth(this,e)}static height(e){const t=Ct._preElemAndWinAndDoc(e,"height");return Ct.getDimension(t,"height","content")}get height(){return Ct.height(this)}static width(e){const t=Ct._preElemAndWinAndDoc(e,"width");return Ct.getDimension(t,"width","content")}get width(){return Ct.width(this)}static innerHeight(e){const t=Ct._preElemAndWinAndDoc(e,"innerHeight");return Ct.getDimension(t,"height","padding")}innerHeight(){return Ct.innerHeight(this)}static innerWidth(e){const t=Ct._preElemAndWinAndDoc(e,"innerWidth");return Ct.getDimension(t,"width","padding")}innerWidth(){return Ct.innerWidth(this)}static outerHeight(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=Ct._preElemAndWinAndDoc(e,"outerHeight");return Ct.getDimension(r,"height",t?"margin":"border")}outerHeight(e){return Ct.outerHeight(this,e)}static outerWidth(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=Ct._preElemAndWinAndDoc(e,"outerWidth");return Ct.getDimension(r,"width",t?"margin":"border")}outerWidth(e){return Ct.outerWidth(this,e)}#se="";get mainDisplay(){return this.#se}set mainDisplay(e){if("string"!=typeof e)throw new TypeError("mainDisplay must be a string.");this.#se=e}static#ne="block";static get defaultDisplay(){return Ct.#ne}static set defaultDisplay(e){if("string"!=typeof e)throw new TypeError("defaultDisplay must be a string.");Ct.#ne=e}static getAnimateData(e,t){let r=St.get(e);return r||(r={},St.set(e,r)),r[t]}static setAnimateData(e,t,r){if(!(e instanceof HTMLElement))throw new TypeError("setAnimateData: el must be an HTMLElement.");if("string"!=typeof t)throw new TypeError("setAnimateData: where must be a string.");if("string"!=typeof r&&"number"!=typeof r)throw new TypeError("setAnimateData: value must be a string or number.");let i=St.get(e);i||(i={},St.set(e,i)),i[t]=r}static#ae=!0;static get cancelOldStyleFx(){return Ct.#ae}static set cancelOldStyleFx(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value.");Ct.#ae=e}static#le={slow:{duration:600,easing:"ease"},fast:{duration:200,easing:"ease-out"},_default:{duration:400,easing:"linear"}};static get styleFxSpeeds(){const e={};for(const t in Ct.#le){const r=Ct.#le[t];e[t]="object"==typeof r?{...r}:r}return e}static set styleFxSpeeds(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleFxSpeeds must be an object.");for(const[t,r]of Object.entries(e))if("number"!=typeof r&&"object"!=typeof r)throw new TypeError(`styleFxSpeeds["${t}"] must be a number or KeyframeAnimationOptions.`);Ct.#le={};for(const[t,r]of Object.entries(e))Ct.setStyleFxSpeed(t,r)}static getStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=Ct.#le[e];return"object"==typeof t?{...t}:t}static setStyleFxSpeed(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("number"!=typeof t&&"object"!=typeof t)throw new TypeError("styleFxSpeed must be a number or KeyframeAnimationOptions");Ct.#le[e]="object"==typeof t?{...t}:t}static deleteStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete Ct.#le[e]}static hasStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(Ct.#le,e)}static#ue=["Top","Right","Bottom","Left"];static#he={slideDown:Ct.genStyleFx("show"),slideUp:Ct.genStyleFx("hide"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}};static get styleEffects(){return JSON.parse(JSON.stringify(Ct.#he))}static set styleEffects(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleEffects must be an object");for(const t in e)for(const[r,i]of Object.entries(e[t]))if(!("string"==typeof i||Array.isArray(i)&&i.every(e=>"string"==typeof e||"number"==typeof e)))throw new TypeError(`Invalid styleEffect["${r}"]`);Ct.#he={};for(const t in e)Ct.setStyleEffect(t,e[t])}static getStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=Ct.#he[e];return t?JSON.parse(JSON.stringify(t)):void 0}static setStyleEffect(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("styleEffect must be an object");const r={};for(const[e,i]of Object.entries(t))if("string"==typeof i)r[e]=i;else{if(!Array.isArray(i)||!i.every(e=>"string"==typeof e||"number"==typeof e))throw new TypeError(`Invalid styleEffect["${e}"]`);r[e]=[...i]}Ct.#he[e]=r}static deleteStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete Ct.#he[e]}static hasStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(Ct.#he,e)}static#ce={slideDown:"slideUp",slideUp:"slideDown",fadeIn:"fadeOut",fadeOut:"fadeIn",fadeTo:"fadeIn"};static get styleEffectInverse(){return{...Ct.#ce}}static set styleEffectInverse(e){if("object"!=typeof e||null===e)throw new TypeError("styleEffectInverse must be an object.");for(const[t,r]of Object.entries(e))if("string"!=typeof r)throw new TypeError(`styleEffectInverse["${t}"] must be a string.`);Ct.#ce={};for(const[t,r]of Object.entries(e))Ct.setStyleEffectInverse(t,r)}static getStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Ct.#ce[e]||null}static setStyleEffectInverse(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("string"!=typeof t)throw new TypeError(`styleEffectInverse["${e}"] must be a string.`);Ct.#ce[e]=t}static deleteStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete Ct.#ce[e]}static hasStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(Ct.#ce,e)}static#de={slideDown:e=>e.height[0]===e.height[1]&&(!e.width||e.width[0]===e.width[1]),slideUp:e=>e.height[0]===e.height[1]&&(!e.width||e.width[0]===e.width[1]),fadeIn:e=>Number(e.opacity[0])===Number(e.opacity[1]),fadeOut:e=>Number(e.opacity[0])===Number(e.opacity[1])};static get styleEffectsRd(){return{...Ct.#de}}static set styleEffectsRd(e){if("object"!=typeof e||null===e)throw new TypeError("styleEffectsRd must be an object.");for(const[t,r]of Object.entries(e))if("function"!=typeof r)throw new TypeError(`styleEffectsRd["${t}"] must be a function.`);Ct.#de={};for(const[t,r]of Object.entries(e))Ct.setStyleEffectRd(t,r)}static getStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Ct.#de[e]||null}static setStyleEffectRd(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("function"!=typeof t)throw new TypeError(`styleEffectsRd["${e}"] must be a function.`);Ct.#de[e]=t}static deleteStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete Ct.#de[e]}static hasStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(Ct.#de,e)}static#me={show:(e,t,r,i)=>{if("height"===r||"width"===r){const s=Ct.getAnimateData(e,`orig${r}`)||e.scrollHeight+"px";Ct.setAnimateData(e,`orig${r}`,s);const n=i[r];t[r]=[n,s]}else if(r.startsWith("margin")||r.startsWith("padding")){const s=Ct.getAnimateData(e,r)||i[r];Ct.setAnimateData(e,r,s),t[r]=["0px",s]}else if("opacity"===r){const e=i.opacity;t[r]=[e,1]}else{const s=Ct.getAnimateData(e,r)||i[r];Ct.setAnimateData(e,r,s),t[r]=[s,i[r]||1]}},hide:(e,t,r,i)=>{if("height"===r||"width"===r){const s=Ct.getAnimateData(e,`orig${r}`)||i[r];Ct.setAnimateData(e,`orig${r}`,s);const n=i[r];t[r]=[n,0]}else if(r.startsWith("margin")||r.startsWith("padding")){const s=Ct.getAnimateData(e,r)||i[r];Ct.setAnimateData(e,r,s),t[r]=[i[r],"0px"]}else if("opacity"===r){const e=i.opacity;t[r]=[e,0]}else{const s=Ct.getAnimateData(e,r)||i[r];Ct.setAnimateData(e,r,s),t[r]=[s,0]}}};static get styleEffectsProps(){return{...Ct.#me}}static set styleEffectsProps(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleEffectsProps must be an object");for(const[t,r]of Object.entries(e))if("function"!=typeof r)throw new TypeError(`styleEffectsProps["${t}"] must be a function`);Ct.#me={};for(const[t,r]of Object.entries(e))Ct.setStyleEffectProp(t,r)}static getStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Ct.#me[e]||null}static setStyleEffectProp(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("function"!=typeof t)throw new TypeError(`styleEffectsProps["${e}"] must be a function`);Ct.#me[e]=t}static deleteStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete Ct.#me[e]}static hasStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(Ct.#me,e)}static genStyleFx(e,t=!1){if("string"!=typeof e)throw new TypeError("genStyleFx: type must be a string.");if("boolean"!=typeof t)throw new TypeError("genStyleFx: includeWidth must be a boolean.");let r,i=0;const s={height:e},n=t?1:0;for(;i<4;i+=2-n)r=Ct.#ue[i],s["margin"+r]=e,s["padding"+r]=e;return t&&(s.opacity=e,s.width=e),s}static applyStyleFx(e,t,r,i){if("string"!=typeof t)throw new TypeError("applyStyleFx: id must be a string.");if("object"!=typeof r||null===r)throw new TypeError("applyStyleFx: props must be a non-null object.");if(void 0!==i&&"number"!=typeof i&&"string"!=typeof i&&("object"!=typeof i||null===i))throw new TypeError("applyStyleFx: ops must be a number, string, KeyframeAnimationOptions, or undefined.");const s=new Map;return Ct._preHtmlElems(e,"applyStyleFx").forEach(n=>{const o={};for(const[e,t]of Object.entries(r))if("string"==typeof t&&this.#me[t]){const r=getComputedStyle(n);this.#me[t](n,o,e,r)}else{if("object"!=typeof t)throw new TypeError(`applyStyleFx: invalid action for prop "${e}". Must be string or array.`);o[e]=t}if("function"==typeof Ct.#de[t]&&Ct.#de[t](o))return void s.set(n,null);const a=[],l=o[Object.keys(o)[0]].length;for(let e=0;e<l;e++){const t={};for(const r in o)t[r]=o[r][e];a.push(t)}s.set(n,Ct.animate(e,a,i,t)[0])}),s}applyStyleFx(e,t,r){return Ct.applyStyleFx(this,e,t,r)}static getCurrentAnimationId(e){if(!(e instanceof HTMLElement))throw new TypeError("Expected an HTMLElement.");return xt.get(e)?.id??void 0}static animate(e,t,r=Ct.#le._default,i=null,s=Ct.#ae){const n="string"==typeof r?Ct.#le[r]??void 0:"number"!=typeof r?{...r}:r;"object"==typeof n&&void 0===n.fill&&(n.fill="forwards");const o=[];return Ct._preHtmlElems(e,"animate").forEach(e=>{if(s){const t=xt.get(e);t&&t.animation.cancel()}const r=e.animate(t,n);o.push(r),xt.set(e,{animation:r,id:i??""}),r.addEventListener("finish",()=>{xt.get(e)?.animation===r&&xt.delete(e)})}),o}animate(e,t,r,i){return Ct.animate(this,e,t,r,i)}static stop(e){const t=[];return Ct._preHtmlElems(e,"stop").forEach(e=>{const r=xt.get(e);r?(r.animation.cancel(),xt.delete(e),t.push(!0)):t.push(!1)}),t}stop(){return Ct.stop(this)}static slideDown(e,t){return Ct.applyStyleFx(e,"slideDown",this.#he.slideDown,t??{duration:500,easing:"ease-out"})}slideDown(e){return Ct.slideDown(this,e)}static slideUp(e,t){return Ct.applyStyleFx(e,"slideUp",this.#he.slideUp,t??{duration:500,easing:"ease-out"})}slideUp(e){return Ct.slideUp(this,e)}static slideToggle(e,t){const r=Ct._preHtmlElem(e,"slideToggle"),i=getComputedStyle(r),s=Ct.getCurrentAnimationId(r),n="none"===i.display||0===r.offsetHeight;return("string"==typeof s?"slideUp"===s:n)?Ct.slideDown(e,t):Ct.slideUp(e,t)}slideToggle(e){return Ct.slideToggle(this,e)}static fadeIn(e,t){return Ct.applyStyleFx(e,"fadeIn",this.#he.fadeIn,t)}fadeIn(e){return Ct.fadeIn(this,e)}static fadeOut(e,t){return Ct.applyStyleFx(e,"fadeOut",this.#he.fadeOut,t)}fadeOut(e){return Ct.fadeOut(this,e)}static fadeToggle(e,t){const r=Ct._preHtmlElem(e,"fadeToggle"),i=getComputedStyle(r),s=Ct.getCurrentAnimationId(r),n="0"===i.opacity||null===r.offsetParent;return("string"==typeof s?"fadeOut"===s:n)?Ct.fadeIn(e,t):Ct.fadeOut(e,t)}fadeToggle(e){return Ct.fadeToggle(this,e)}static fadeTo(e,t,r,i=Ct.#ne){if("number"!=typeof t||isNaN(t)||t<0||t>1)throw new TypeError("fadeTo: opacity must be a number between 0 and 1.");if(void 0!==r&&"number"!=typeof r&&"string"!=typeof r&&("object"!=typeof r||null===r))throw new TypeError("fadeTo: ops must be a number, string, KeyframeAnimationOptions, or undefined.");const s=new Map;return Ct._preHtmlElems(e,"fadeTo").forEach(n=>{const o=getComputedStyle(n);if(!(e instanceof Element&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length))){const e=Ct.getAnimateData(n,"origdisplay");n.style.display="string"==typeof e?e:i}const a=[o.opacity,t].map(e=>({opacity:e}));s.set(n,Ct.animate(n,a,r,"fadeTo")[0])}),s}fadeTo(e,t,r=this.#se){return Ct.fadeTo(this,e,t,r)}static offset(e){const t=Ct._preElem(e,"offset").getBoundingClientRect(),r=window.scrollY||document.documentElement.scrollTop,i=window.scrollX||document.documentElement.scrollLeft;return{top:t.top+r,left:t.left+i}}offset(){return Ct.offset(this)}static position(e){const t=Ct._preHtmlElem(e,"position");let r,i,s={top:0,left:0};if("fixed"===window.getComputedStyle(t).position)i=t.getBoundingClientRect();else{i=Ct.offset(t),r=t.offsetParent||document.documentElement;const{position:e}=window.getComputedStyle(r);for(;r instanceof HTMLElement&&(r===document.body||r===document.documentElement)&&"static"===e;)r=r.parentNode;if(r instanceof HTMLElement&&r!==t&&1===r.nodeType){const{borderTopWidth:e,borderLeftWidth:t}=Ct.cssFloats(r,["borderTopWidth","borderLeftWidth"]);s=Ct.offset(r),s.top+=e,s.left+=t}}return{top:i.top-s.top-Ct.cssFloat(t,"marginTop"),left:i.left-s.left-Ct.cssFloat(t,"marginLeft")}}position(){return Ct.position(this)}static offsetParent(e){let t=Ct._preHtmlElem(e,"offsetParent").offsetParent;for(;t instanceof HTMLElement&&"static"===window.getComputedStyle(t).position;)t=t.offsetParent;return t instanceof HTMLElement?t:document.documentElement}offsetParent(){return Ct.offsetParent(this)}static scrollTop(e){const t=Ct._preElemAndWindow(e,"scrollTop");return Ct.isWindow(t)?t.pageYOffset:9===t.nodeType?t.defaultView.pageYOffset:t.scrollTop}scrollTop(){return Ct.scrollTop(this)}static scrollLeft(e){const t=Ct._preElemAndWindow(e,"scrollLeft");return Ct.isWindow(t)?t.pageXOffset:9===t.nodeType?t.defaultView.pageXOffset:t.scrollLeft}scrollLeft(){return Ct.scrollLeft(this)}static easings={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>e*(2-e),easeInOutQuad:e=>e<.5?2*e*e:(4-2*e)*e-1,easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1};static scrollToXY(e,{targetX:t,targetY:r,duration:i,easing:s,onAnimation:n}={}){if(void 0!==t&&"number"!=typeof t)throw new TypeError("`targetX` must be a number if provided.");if(void 0!==r&&"number"!=typeof r)throw new TypeError("`targetY` must be a number if provided.");if(void 0!==i&&"number"!=typeof i)throw new TypeError("`duration` must be a number if provided.");if(void 0!==s&&"string"!=typeof s)throw new TypeError("`easing` must be a string if provided.");if(void 0!==s&&"function"!=typeof Ct.easings[s])throw new TypeError(`Unknown easing function: "${s}".`);if(void 0!==n&&"function"!=typeof n)throw new TypeError("`onAnimation` must be a function if provided.");const o=(e,t,r,i)=>{if(e instanceof Window)window.scrollTo(t,r);else if(9===e.nodeType)e.defaultView.scrollTo(t,r);else{const i=e instanceof Window?window.scrollX:e.scrollLeft,s=e instanceof Window?window.scrollY:e.scrollTop;i!==t&&(e.scrollLeft=t),s!==r&&(e.scrollTop=r)}"function"==typeof n&&n({x:t,y:r,isComplete:i>=1,time:i})};return Ct._preElemsAndWindow(e,"scrollToXY").forEach(e=>{const n=e instanceof Window?window.scrollX:e.scrollLeft,a=e instanceof Window?window.scrollY:e.scrollTop,l=t??n,u=r??a,h=l-n,c=u-a,d="string"==typeof s&&Ct.easings[s]||null;if("number"!=typeof i||"function"!=typeof d)return o(e,l,u,1);const m=performance.now(),p=i??0;requestAnimationFrame(function t(r){if("function"!=typeof d)return;const i=Math.min(1,(r-m)/p),s=d(i);o(e,n+h*s,a+c*s,i),i<1&&requestAnimationFrame(t)})}),e}scrollToXY({targetX:e,targetY:t,duration:r,easing:i,onAnimation:s}={}){return Ct.scrollToXY(this,{targetX:e,targetY:t,duration:r,easing:i,onAnimation:s})}static setScrollTop(e,t){if("number"!=typeof t)throw new TypeError("ScrollTop value must be a number.");return Ct.scrollToXY(e,{targetY:t})}setScrollTop(e){return Ct.setScrollTop(this,e)}static setScrollLeft(e,t){if("number"!=typeof t)throw new TypeError("ScrollLeft value must be a number.");return Ct.scrollToXY(e,{targetX:t})}setScrollLeft(e){return Ct.setScrollLeft(this,e)}static borderWidth(e){const t=Ct._preElem(e,"borderWidth"),{borderLeftWidth:r,borderRightWidth:i,borderTopWidth:s,borderBottomWidth:n}=Ct.cssFloats(t,["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"]);return{x:r+i,y:s+n,left:r,right:i,top:s,bottom:n}}borderWidth(){return Ct.borderWidth(this)}static border(e){const t=Ct._preElem(e,"border"),{borderLeft:r,borderRight:i,borderTop:s,borderBottom:n}=Ct.cssFloats(t,["borderLeft","borderRight","borderTop","borderBottom"]);return{x:r+i,y:s+n,left:r,right:i,top:s,bottom:n}}border(){return Ct.border(this)}static margin(e){const t=Ct._preElem(e,"margin"),{marginLeft:r,marginRight:i,marginTop:s,marginBottom:n}=Ct.cssFloats(t,["marginLeft","marginRight","marginTop","marginBottom"]);return{x:r+i,y:s+n,left:r,right:i,top:s,bottom:n}}margin(){return Ct.margin(this)}static padding(e){const t=Ct._preElem(e,"padding"),{paddingLeft:r,paddingRight:i,paddingTop:s,paddingBottom:n}=Ct.cssFloats(t,["paddingLeft","paddingRight","paddingTop","paddingBottom"]);return{x:r+i,y:s+n,left:r,right:i,top:s,bottom:n}}padding(){return Ct.padding(this)}static#pe=!1;static get classCanWhitespace(){return this.#pe}static set classCanWhitespace(e){if("boolean"!=typeof e)throw new TypeError("classCanWhitespace must be a boolean");this.#pe=e}static addClass(e,...t){const r=[];for(const e of t)if(Ct.#pe){const t=e.split(" ");for(const e of t)r.push(e)}else r.push(e);return Ct._preElems(e,"addClass").forEach(e=>e.classList.add(...r)),e}addClass(...e){return Ct.addClass(this,...e)}static removeClass(e,...t){const r=[];for(const e of t)if(Ct.#pe){const t=e.split(" ");for(const e of t)r.push(e)}else r.push(e);return Ct._preElems(e,"removeClass").forEach(e=>e.classList.remove(...r)),e}removeClass(...e){return Ct.removeClass(this,...e)}static replaceClass(e,t,r){if("string"!=typeof t)throw new TypeError('The "token" parameter must be a string.');if("string"!=typeof r)throw new TypeError('The "newToken" parameter must be a string.');const i=[];return Ct._preElems(e,"replaceClass").forEach(e=>i.push(e.classList.replace(t,r))),i}replaceClass(e,t){return Ct.replaceClass(this,e,t)[0]}static classItem(e,t){const r=Ct._preElem(e,"classItem");if("number"!=typeof t)throw new TypeError('The "index" parameter must be a number.');return r.classList.item(t)}classItem(e){return Ct.classItem(this,e)}static toggleClass(e,t,r){if("string"!=typeof t)throw new TypeError('The "token" parameter must be a string.');if(void 0!==r&&"boolean"!=typeof r)throw new TypeError('The "force" parameter must be a boolean.');const i=[];return Ct._preElems(e,"toggleClass").forEach(e=>i.push(e.classList.toggle(t,r))),i}toggleClass(e,t){return Ct.toggleClass(this,e,t)[0]}static hasClass(e,t){const r=Ct._preElem(e,"hasClass");if("string"!=typeof t)throw new TypeError('The "token" parameter must be a string.');return r.classList.contains(t)}hasClass(e){return Ct.hasClass(this,e)}static classLength(e){return Ct._preElem(e,"classLength").classList.length}classLength(){return Ct.classLength(this)}static classList(e){return Ct._preElem(e,"classList").classList.values().toArray()}classList(){return Ct.classList(this)}static tagName(e){return Ct._preElem(e,"tagName").tagName}tagName(){return Ct.tagName(this)}static id(e){return Ct._preElem(e,"id").id}get id(){return Ct.id(this)}set id(e){Ct.setAttr(this,"id",e)}static toBigInt(e){const t=Ct._preElem(e,"toBigInt"),r=t.textContent?.trim();let i=null;try{i=BigInt(r??"")}catch{i=null}return i}toBigInt(){return Ct.toBigInt(this)}static setBigInt(e,t){if("bigint"!=typeof t)throw new Error("Value is not a valid BigInt.");const r=t.toString();return Ct._preElems(e,"setBigInt").forEach(e=>e.textContent=r),e}setBigInt(e){return Ct.setBigInt(this,e)}static toDate(e){const t=Ct._preElem(e,"toDate"),r=t.textContent?.trim();if(!r)return null;const i=new Date(r);return Number.isNaN(i.getTime())?null:i}toDate(){return Ct.toDate(this)}static setDate(e,t){if(!(t instanceof Date)||Number.isNaN(t.getTime()))throw new Error("Value is not a valid Date.");const r=t.toISOString();return Ct._preElems(e,"setDate").forEach(e=>e.textContent=r),e}setDate(e){return Ct.setDate(this,e)}static toJson(e){const t=Ct._preElem(e,"toJson"),r=t.textContent?.trim();if(!r)return null;try{return JSON.parse(r)}catch{return null}}toJson(){return Ct.toJson(this)}static setJson(e,t,r,i){const s=JSON.stringify(t,r,i);return Ct._preElems(e,"setJson").forEach(e=>e.textContent=s),e}setJson(e,t,r){return Ct.setJson(this,e,t,r)}static toNumber(e){const t=Ct._preElem(e,"toNumber");return"string"==typeof t.textContent?parseFloat(t.textContent.trim()):null}toNumber(){return Ct.toNumber(this)}static setNumber(e,t){if("number"!=typeof t)throw new Error("Value is not a valid number.");const r=t.toString();return Ct._preElems(e,"setNumber").forEach(e=>e.textContent=r),e}setNumber(e){return Ct.setNumber(this,e)}static toBoolean(e){const t=Ct._preElem(e,"toBoolean"),r=t.textContent?.trim();return null==r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}toBoolean(){return Ct.toBoolean(this)}static setBoolean(e,t){if("boolean"!=typeof t)throw new Error("Value is not a valid boolean.");const r=t.toString();return Ct._preElems(e,"setBoolean").forEach(e=>e.textContent=r),e}setBoolean(e){return Ct.setBoolean(this,e)}static toString(e){const t=Ct._preElem(e,"toString");return"string"==typeof t.textContent?t.textContent:null}toString(){return Ct.toString(this)}static setString(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return Ct._preElems(e,"setString").forEach(e=>e.textContent=t),e}setString(e){return Ct.setString(this,e)}static text(e){return Ct._preElem(e,"text").textContent}text(){return Ct.text(this)}static setText(e,t){const r=null!=t?String(t):"";return Ct._preElems(e,"setText").forEach(e=>e.textContent=r),e}setText(e){return Ct.setText(this,e)}static empty(e){return Ct._preElems(e,"empty").forEach(e=>e.textContent=""),e}empty(){return Ct.empty(this)}static html(e,t){return Ct._preElem(e,"html").getHTML(t)}html(e){return Ct.html(this,e)}static setHtml(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return Ct._preElems(e,"setHtml").forEach(e=>e.innerHTML=t),e}setHtml(e){return Ct.setHtml(this,e)}static _valHooks={option:{get:e=>{const t=e.getAttribute("value");return null!=t?t:e.textContent}},select:{get:e=>{const t=e.options,r=e.selectedIndex,i="select-one"===e.type,s=i?r+1:t.length,n=[];let o=r<0?s:i?r:0;for(;o<s;o++){const e=t[o],s=e.parentNode;if((e.selected||o===r)&&!e.disabled&&(!s||!s.disabled||"OPTGROUP"!==s.tagName)){const t=Ct._valHooks.option.get(e);if(i)return t;n.push(t)}}return n},set:(e,t)=>{const r=e.options,i=Array.isArray(t)?t.map(String):[String(t)];let s=!1;for(let e=0;e<r.length;e++){const t=r[e],n=Ct._valHooks.option.get(t);"string"==typeof n&&(t.selected=i.includes(n))&&(s=!0)}return s||(e.selectedIndex=-1),i}},radio:{get:e=>e.checked?"on":"off",set(e,t){if("boolean"==typeof t){const r=e.closest("label");return t&&r&&r.querySelectorAll('input[type="radio"]').forEach(t=>{t instanceof HTMLInputElement&&t!==e&&(t.checked=!1)}),e.checked=t,t}}},checkbox:{get:e=>e.checked?"on":"off",set(e,t){if("boolean"==typeof t)return e.checked=t,t}}};static setVal(e,t){return Ct._preInputElems(e,"setVal").forEach(e=>{if(1!==e.nodeType)return;let r="function"==typeof t?t(e,Ct.val(e)):t;null==r?r="":"number"==typeof r?r=String(r):Array.isArray(r)&&(r=((e,t)=>{const r=[];for(let i=0;i<e.length;i++)r.push(t(e[i]));return r})(r,e=>null==e?"":String(e)));const i=Ct._valHooks[e.type]||Ct._valHooks[e.nodeName.toLowerCase()];if(!i||"function"!=typeof i.set||void 0===i.set(e,r,"value")){if("string"!=typeof r&&"boolean"!=typeof r)throw new Error(`Invalid setValue "${typeof r}" value.`);"string"==typeof r&&(e.value=r)}}),e}setVal(e){return Ct.setVal(this,e)}static _valTypes={string:e=>e.value,date:e=>e.valueAsDate,number:e=>e.valueAsNumber};static _getValByType(e,t,r){if("string"!=typeof t)throw new TypeError('The "type" must be a string.');if("string"!=typeof r)throw new TypeError('The "where" must be a string.');if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error(`Provided element is not an HTMLInputElement in ${r}().`);if("function"!=typeof Ct._valTypes[t])throw new Error(`No handler found for type "${t}" in ${r}().`);return Ct._valTypes[t](e)}static _val(e,t,r){const i=Ct._preInputElem(e,t),s=Ct._valHooks[i.type]||Ct._valHooks[i.nodeName.toLowerCase()];if(s&&"function"==typeof s.get){const e=s.get(i,"value",r);if(void 0!==e)return"string"==typeof e?e.replace(/\r/g,""):e}return Ct._getValByType(i,r,t)}_val(e,t){return Ct._val(this,e,t)}static val(e){return Ct._val(e,"val","string")}val(){return Ct.val(this)}static valTxt(e){const t=Ct._val(e,"valTxt","string");if("string"!=typeof t&&null!==t)throw new Error("Value is not a valid string.");return null==t?"":"string"==typeof t?t.replace(/\r/g,""):t}valTxt(){return Ct.valTxt(this)}static _valArr(e,t,r){const i=Ct._val(e,t,r);if(!Array.isArray(i))throw new Error(`Value expected an array but got ${typeof i}.`);return i}_valArr(e,t){return Ct._valArr(this,e,t)}static valArr(e){return Ct._valArr(e,"valArr","string")}valArr(){return Ct.valArr(this)}static valNb(e){if(!(Ct._preInputElem(e,"valNb")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=Ct._val(e,"valNb","number");if(Number.isNaN(t))throw new Error("Value is not a valid number.");return t}valNb(){return Ct.valNb(this)}static valDate(e){if(!(Ct._preInputElem(e,"valDate")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=Ct._val(e,"valDate","date");if(!(t instanceof Date))throw new Error("Value is not a valid date.");return t}valDate(){return Ct.valDate(this)}static valBool(e){const t=Ct._preInputElem(e,"valBool");if(!(t instanceof HTMLInputElement))throw new Error("Element must be an input element.");return"on"===Ct.val(t)}valBool(){return Ct.valBool(this)}static listenForPaste(e,{onFilePaste:t,onTextPaste:r}={}){if(void 0!==t&&"function"!=typeof t)throw new TypeError("onFilePaste must be a function.");if(void 0!==r&&"function"!=typeof r)throw new TypeError("onTextPaste must be a function.");const i=e=>{if(!(e instanceof ClipboardEvent))return;const i=e.clipboardData?.items||[];for(const e of i)if("file"===e.kind){if("function"==typeof t){const r=e.getAsFile();r&&t(e,r)}}else"string"===e.kind&&"function"==typeof r&&e.getAsString(t=>r(e,t))};return Ct._preElemsWithDoc(e,"listenForPaste").forEach(e=>Ct.on(e,"paste",i)),i}listenForPaste({onFilePaste:e,onTextPaste:t}={}){return Ct.listenForPaste(this,{onFilePaste:e,onTextPaste:t})}static hasEventListener(e,t){const r=Ct._preEventTargetElem(e,"hasEventListener");if(!Et.has(r))return!1;const i=Et.get(r);return!!(i&&Array.isArray(i[t])&&i[t].length>0)}hasEventListener(e){return Ct.hasEventListener(this,e)}static hasExactEventListener(e,t,r){const i=Ct._preEventTargetElem(e,"hasExactEventListener");if("function"!=typeof r)throw new TypeError('The "handler" must be a function.');if(!Et.has(i))return!1;const s=Et.get(i);return!(!s||!Array.isArray(s[t]))&&s[t].some(e=>e.handler===r)}hasExactEventListener(e,t){return Ct.hasExactEventListener(this,e,t)}static hover(e,t,r,i){return Ct.on(e,"mouseenter",t,i),Ct.on(e,"mouseleave",r||t,i),e}hover(e,t,r){return Ct.hover(this,e,t,r)}static on(e,t,r,i){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const s of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof s)throw new TypeError("The event name must be a string.");Ct._preEventTargetElems(e,"on").forEach(e=>{e.addEventListener(s,r,i),Et.has(e)||Et.set(e,{});const t=Et.get(e);t&&(Array.isArray(t[s])||(t[s]=[]),t[s].push({handler:r,options:i}))})}return e}on(e,t,r){return Ct.on(this,e,t,r)}static once(e,t,r,i={}){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const s of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof s)throw new TypeError("The event name must be a string.");Ct._preEventTargetElems(e,"once").forEach(e=>{const t=i=>{Ct.off(e,s,t),"function"==typeof r&&r(i)};Ct.on(e,s,t,"boolean"==typeof i?i:{...i,once:!0})})}return e}once(e,t,r={}){return Ct.once(this,e,t,r)}static off(e,t,r,i){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const s of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof s)throw new TypeError("The event name must be a string.");Ct._preEventTargetElems(e,"off").forEach(e=>{e.removeEventListener(s,r,i);const t=Et.get(e);t&&t[s]&&(t[s]=t[s].filter(e=>e.handler!==r),0===t[s].length&&delete t[s])})}return e}off(e,t,r){return Ct.off(this,e,t,r)}static offAll(e,t){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const r of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof r)throw new TypeError("The event name must be a string.");Ct._preEventTargetElems(e,"offAll").forEach(e=>{const t=Et.get(e);if(t&&t[r]){for(const i of t[r])e.removeEventListener(r,i.handler,i.options);delete t[r]}})}return e}offAll(e){return Ct.offAll(this,e)}static offAllTypes(e,t=null){if(null!==t&&"function"!=typeof t)throw new TypeError('The "filterFn" must be a function.');return Ct._preEventTargetElems(e,"offAllTypes").forEach(e=>{const r=Et.get(e);if(r){for(const i in r)for(const s of r[i])("function"!=typeof t||t(s.handler,i))&&e.removeEventListener(i,s.handler,s.options);Et.delete(e)}}),e}offAllTypes(e=null){return Ct.offAllTypes(this,e)}static trigger(e,t,r={}){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const i of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof i)throw new TypeError("The event name must be a string.");Ct._preEventTargetElems(e,"trigger").forEach(e=>{const t=r instanceof Event||r instanceof CustomEvent?r:new CustomEvent(i,{bubbles:!0,cancelable:!0,detail:r});e.dispatchEvent(t)})}return e}trigger(e,t={}){return Ct.trigger(this,e,t)}static#fe={for:"htmlFor",class:"className"};static propFix=new Proxy(Ct.#fe,{set:(e,t,r)=>(e[t]=r,Ct.attrFix[r]=t,!0)});static attrFix=Object.fromEntries(Object.entries(Ct.#fe).map(([e,t])=>[t,e]));static getPropName(e){return"string"==typeof Ct.propFix[e]?Ct.propFix[e]:e}static getAttrName(e){return"string"==typeof Ct.attrFix[e]?Ct.attrFix[e]:e}static attrBigInt(e,t){const r=Ct._preElem(e,"attrBigInt").getAttribute(Ct.getAttrName(t));if(null==r)return null;try{return BigInt(r)}catch{return null}}attrBigInt(e){return Ct.attrBigInt(this,e)}static setAttrBigInt(e,t,r){if("bigint"!=typeof r)throw new Error("Value is not a valid BigInt.");return Ct.setAttr(e,t,r.toString())}setAttrBigInt(e,t){return Ct.setAttrBigInt(this,e,t)}static attrDate(e,t){const r=Ct._preElem(e,"attrDate").getAttribute(Ct.getAttrName(t));if(!r)return null;const i=new Date(r);return Number.isNaN(i.getTime())?null:i}attrDate(e){return Ct.attrDate(this,e)}static setAttrDate(e,t,r){if(!(r instanceof Date)||Number.isNaN(r.getTime()))throw new Error("Value is not a valid Date.");return Ct.setAttr(e,t,r.toISOString())}setAttrDate(e,t){return Ct.setAttrDate(this,e,t)}static attrJson(e,t){const r=Ct._preElem(e,"attrJson").getAttribute(Ct.getAttrName(t));if(!r)return null;try{return JSON.parse(r)}catch{return null}}attrJson(e){return Ct.attrJson(this,e)}static setAttrJson(e,t,r,i,s){const n=JSON.stringify(r,i,s);return Ct.setAttr(e,t,n)}setAttrJson(e,t,r,i){return Ct.setAttrJson(this,e,t,r,i)}static attrNumber(e,t){const r=Ct._preElem(e,"attrNumber").getAttribute(Ct.getAttrName(t));return null!=r?parseFloat(r):null}attrNumber(e){return Ct.attrNumber(this,e)}static setAttrNumber(e,t,r){if("number"!=typeof r)throw new Error("Value is not a valid number.");return Ct.setAttr(e,t,r.toString())}setAttrNumber(e,t){return Ct.setAttrNumber(this,e,t)}static attrBoolean(e,t){const r=Ct._preElem(e,"attrBoolean").getAttribute(Ct.getAttrName(t));return null===r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}attrBoolean(e){return Ct.attrBoolean(this,e)}static setAttrBoolean(e,t,r){if("boolean"!=typeof r)throw new Error("Value is not a valid boolean.");return Ct.setAttr(e,t,r.toString())}setAttrBoolean(e,t){return Ct.setAttrBoolean(this,e,t)}static attrString(e,t){const r=Ct._preElem(e,"attrString").getAttribute(Ct.getAttrName(t));return"string"==typeof r?r:null}attrString(e){return Ct.attrString(this,e)}static setAttrString(e,t,r){if("string"!=typeof r)throw new Error("Value is not a valid string.");return Ct.setAttr(e,t,r)}setAttrString(e,t){return Ct.setAttrString(this,e,t)}static attr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return Ct._preElem(e,"attr").getAttribute(Ct.getAttrName(t))}attr(e){return Ct.attr(this,e)}static setAttr(e,t,r=null){const i=Ct._preElems(e,"setAttr");if("object"==typeof t&&null!==t)return Object.entries(t).forEach(([e,t])=>i.forEach(r=>{null===t?r.removeAttribute(Ct.getAttrName(e)):r.setAttribute(Ct.getAttrName(e),String(t))})),e;if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return i.forEach(e=>{null===r?e.removeAttribute(Ct.getAttrName(t)):e.setAttribute(Ct.getAttrName(t),String(r))}),e}setAttr(e,t){return Ct.setAttr(this,e,t)}static removeAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return Ct._preElems(e,"removeAttr").forEach(e=>e.removeAttribute(Ct.getAttrName(t))),e}removeAttr(e){return Ct.removeAttr(this,e)}static hasAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return Ct._preElem(e,"hasAttr").hasAttribute(Ct.getAttrName(t))}hasAttr(e){return Ct.hasAttr(this,e)}static hasProp(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return!!Ct._preElem(e,"hasProp")[Ct.getPropName(t)]}hasProp(e){return Ct.hasProp(this,e)}static addProp(e,...t){return Ct._preElems(e,"addProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[Ct.getPropName(t)]=!0})}),e}addProp(...e){return Ct.addProp(this,...e)}static removeProp(e,...t){return Ct._preElems(e,"removeProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[Ct.getPropName(t)]=!1})}),e}removeProp(...e){return Ct.removeProp(this,...e)}static toggleProp(e,t,r){const i=Ct._preElems(e,"toggleProp");if(void 0!==r&&"boolean"!=typeof r)throw new TypeError('The "force" must be a boolean.');return(Array.isArray(t)?t:[t]).forEach(e=>{if("string"!=typeof e)throw new TypeError("Each property name must be a string.");i.forEach(t=>{(void 0===r?!t[Ct.getPropName(e)]:r)?Ct.addProp(t,e):Ct.removeProp(t,e)})}),e}toggleProp(e,t){return Ct.toggleProp(this,e,t)}static prop(e,t){if("string"!=typeof t)throw new TypeError('Invalid arguments passed to prop(). Expected string for "name".');return Ct._preElem(e,"prop")[t]}prop(e){return Ct.prop(this,e)}static setProp(e,t,r){if("string"!=typeof t||""===t.trim())throw new Error("Property name must be a non-empty string.");return Ct._preElems(e,"setProp").forEach(e=>{e[t]=r}),e}setProp(e,t){return Ct.setProp(this,e,t)}static remove(e){return Ct._preElems(e,"remove").forEach(e=>e.remove()),e}remove(){return Ct.remove(this)}static index(e,t=null){const r=Ct._preElem(e,"index");if(!r)return-1;if(!t)return Array.prototype.indexOf.call(r.parentNode?.children||[],r);if(t){const e="string"==typeof t?document.querySelectorAll(t):Ct._preElems(t,"index");return Array.prototype.indexOf.call(e,r)}return-1}index(e){return Ct.index(this,e)}static _getCustomRect(e,t){const r={height:0,width:0,x:0,y:0,bottom:0,left:0,right:0,top:0,toJSON:function(){throw new Error("Function not implemented.")}};for(const t in e)"number"==typeof e[t]&&(r[t]=e[t]);if("object"!=typeof t||null===t||Array.isArray(t))throw new Error("extraRect must be a non-null object.");const{height:i=0,width:s=0,top:n=0,bottom:o=0,left:a=0,right:l=0}=t;if("number"!=typeof i)throw new Error("extraRect.height must be a number.");if("number"!=typeof s)throw new Error("extraRect.width must be a number.");if("number"!=typeof n)throw new Error("extraRect.top must be a number.");if("number"!=typeof o)throw new Error("extraRect.bottom must be a number.");if("number"!=typeof a)throw new Error("extraRect.left must be a number.");if("number"!=typeof l)throw new Error("extraRect.right must be a number.");return r.height+=i,r.width+=s,r.top+=n,r.bottom+=o,r.left+=a,r.right+=l,r}static isCollWith(e,t,r={}){const i=Ct._getCustomRect(Ct._preElem(e,"isCollWith").getBoundingClientRect(),r),s=Ct._preElem(t,"isCollWith").getBoundingClientRect();return ft(i,s)}isCollWith(e,t){return Ct.isCollWith(this,e,t)}static isCollPerfWith(e,t,r={}){const i=Ct._getCustomRect(Ct._preElem(e,"isCollPerfWith").getBoundingClientRect(),r),s=Ct._preElem(t,"isCollPerfWith").getBoundingClientRect();return yt(i,s)}isCollPerfWith(e,t){return Ct.isCollPerfWith(this,e,t)}static _isCollWithLock(e,t,r,i,s){const n=At[s];if(e)return n.has(i)||n.set(i,!0),!0;if(n.has(i)){let e=!1;switch(s){case"top":e=gt(t,r);break;case"bottom":e=bt(t,r);break;case"left":e=wt(t,r);break;case"right":e=vt(t,r)}return e&&n.delete(i),n.has(i)}return!1}static isCollWithLock(e,t,r,i={}){const s=Ct._preElem(e,"isCollWithLock"),n=Ct._preElem(t,"isCollWithLock"),o=Ct._getCustomRect(s.getBoundingClientRect(),i),a=n.getBoundingClientRect(),l=ft(o,a);return Ct._isCollWithLock(l,o,a,s,r)}isCollWithLock(e,t,r){return Ct.isCollWithLock(this,e,t,r)}static isCollPerfWithLock(e,t,r,i={}){const s=Ct._preElem(e,"isCollPerfWithLock"),n=Ct._preElem(t,"isCollPerfWithLock"),o=Ct._getCustomRect(s.getBoundingClientRect(),i),a=n.getBoundingClientRect(),l=yt(o,a);return Ct._isCollWithLock(l,o,a,s,r)}isCollPerfWithLock(e,t,r){return Ct.isCollPerfWithLock(this,e,t,r)}static resetCollLock(e){const t=Ct._preElem(e,"resetCollLock");let r=!1;for(const e of["top","bottom","left","right"])At[e].has(t)&&(At[e].delete(t),r=!0);return r}resetCollLock(){return Ct.resetCollLock(this)}static resetCollLockDir(e,t){const r=Ct._preElem(e,"resetCollLockDir"),i=At[t];return!!i.has(r)&&(i.delete(r),!0)}resetCollLockDir(e){return Ct.resetCollLockDir(this,e)}static isInViewport(e){const t=Ct._preElem(e,"isInViewport");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=Ct.offset(t).top,i=r+Ct.outerHeight(t),s=Ct.scrollTop(window),n=s+Ct.height(window);return i>s&&r<n}isInViewport(){return Ct.isInViewport(this)}static isScrolledIntoView(e){const t=Ct._preElem(e,"isScrolledIntoView");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=Ct.scrollTop(window),i=r+Ct.height(window),s=Ct.offset(t).top;return s+Ct.height(t)<=i&&s>=r}isScrolledIntoView(){return Ct.isScrolledIntoView(this)}static isInContainer(e,t){const r=Ct._preElem(e,"isInContainer"),i=Ct._preElem(t,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const s=r.getBoundingClientRect(),n=i.getBoundingClientRect(),o=s.bottom>n.top&&s.top<n.bottom,a=s.right>n.left&&s.left<n.right;return o&&a}isInContainer(e){return Ct.isInContainer(this,e)}static isFullyInContainer(e,t){const r=Ct._preElem(e,"isScrolledIntoView"),i=Ct._preElem(t,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const s=r.getBoundingClientRect(),n=i.getBoundingClientRect();return s.top>=n.top&&s.bottom<=n.bottom&&s.left>=n.left&&s.right<=n.right}isFullyInContainer(e){return Ct.isFullyInContainer(this,e)}static hasScroll(e){const t=Ct._preElem(e,"hasScroll");return{v:t.scrollHeight>t.clientHeight,h:t.scrollWidth>t.clientWidth}}hasScroll(){return Ct.hasScroll(this)}}const It=Ct,Mt=ee("TinyDragger");class Dt{static Utils={...s,TinyHtml:It};#ye=!0;#h=!1;#ge=0;#be=0;#we=!0;#ve=!1;#Ee=!1;#Te=!1;#Se=!1;#xe=!1;#Ae=!1;#Ce=null;#Ie=[];#Me=null;#De={start:!1,end:!1,collide:!1,move:!1};#ke=null;#F;#Ne="drag-hidden";#Le="dragging";#_e="drag-active";#je="jail-drag-active";#Re="jail-drag-disabled";#Pe="dragging-collision";#$e=9999;constructor(e,t={}){if(!(e instanceof HTMLElement))throw new Error("TinyDragger requires a valid target HTMLElement to initialize.");if(this.#F=e,void 0!==t.jail&&!(t.jail instanceof HTMLElement))throw new Error('The "jail" option must be an HTMLElement if provided.');if(void 0!==t.defaultZIndex&&this.setDefaultZIndex(t.defaultZIndex),void 0!==t.vibration&&!1!==t.vibration&&!g(t.vibration))throw new Error('The "vibration" option must be an object or false.');const r=(e,t)=>{if(void 0!==e&&"boolean"!=typeof e)throw new Error(`The "${t}" option must be a boolean.`)},i=(e,t)=>{if(void 0!==e&&"string"!=typeof e)throw new Error(`The "${t}" option must be a string.`)};r(t.mirrorElem,"mirrorElem"),r(t.collisionByMouse,"collisionByMouse"),r(t.lockInsideJail,"lockInsideJail"),r(t.dropInJailOnly,"dropInJailOnly"),r(t.revertOnDrop,"revertOnDrop"),r(t.multiCollision,"multiCollision"),i(t.classDragging,"classDragging"),i(t.classBodyDragging,"classBodyDragging"),i(t.classJailDragging,"classJailDragging"),i(t.classJailDragDisabled,"classJailDragDisabled"),i(t.classDragCollision,"classDragCollision"),i(t.classHidden,"classHidden"),t.jail instanceof HTMLElement&&(this.#ke=t.jail),this.#De=Object.assign({start:!1,end:!1,collide:!1,move:!1},g(t.vibration)?t.vibration:{}),"string"==typeof t.classDragging&&(this.#Le=t.classDragging),"string"==typeof t.classBodyDragging&&(this.#_e=t.classBodyDragging),"string"==typeof t.classJailDragging&&(this.#je=t.classJailDragging),"string"==typeof t.classJailDragDisabled&&(this.#Re=t.classJailDragDisabled),"string"==typeof t.classHidden&&(this.#Ne=t.classHidden),"string"==typeof t.classDragCollision&&(this.#Pe=t.classDragCollision),"boolean"==typeof t.collisionByMouse&&(this.#xe=t.collisionByMouse),"boolean"==typeof t.mirrorElem&&(this.#we=t.mirrorElem),"boolean"==typeof t.revertOnDrop&&(this.#Te=t.revertOnDrop),"boolean"==typeof t.lockInsideJail&&(this.#Ee=t.lockInsideJail),"boolean"==typeof t.dropInJailOnly&&(this.#Ae=t.dropInJailOnly),"boolean"==typeof t.multiCollision&&(this.#ve=t.multiCollision),this._onMouseDown=this.#Oe.bind(this),this._onMouseMove=this.#He.bind(this),this._onMouseUp=this.#Fe.bind(this),this._onTouchStart=e=>this.#Oe(e.touches[0]),this._onTouchMove=e=>this.#He(e.touches[0]),this._onTouchEnd=e=>this.#Fe(e.changedTouches[0]),this.#F.addEventListener("mousedown",this._onMouseDown),this.#F.addEventListener("touchstart",this._onTouchStart,{passive:!1})}enable(){Mt(this.#h),this.#ke&&this.#ke.classList.add(this.#Re),this.#ye=!0}disable(){Mt(this.#h),this.#ke&&this.#ke.classList.remove(this.#Re),this.#ye=!1}addCollidable(e){if(Mt(this.#h),!(e instanceof HTMLElement))throw new Error("addCollidable expects an HTMLElement as argument.");this.#Ie.includes(e)||this.#Ie.push(e)}removeCollidable(e){if(Mt(this.#h),!(e instanceof HTMLElement))throw new Error("removeCollidable expects an HTMLElement as argument.");this.#Ie=this.#Ie.filter(t=>t!==e)}setVibrationPattern({startPattern:e=!1,endPattern:t=!1,collidePattern:r=!1,movePattern:i=!1}={}){Mt(this.#h);const s=e=>!1===e||Array.isArray(e)&&e.every(e=>"number"==typeof e);if(!s(e))throw new Error('Invalid "startPattern": must be false or an array of numbers.');if(!s(t))throw new Error('Invalid "endPattern": must be false or an array of numbers.');if(!s(r))throw new Error('Invalid "collidePattern": must be false or an array of numbers.');if(!s(i))throw new Error('Invalid "movePattern": must be false or an array of numbers.');this.#De={start:e,end:t,collide:r,move:i}}disableVibration(){Mt(this.#h),this.#De={start:!1,end:!1,collide:!1,move:!1}}getOffset(e){if(Mt(this.#h),!(e instanceof MouseEvent||e instanceof Touch)||"number"!=typeof e.clientX||"number"!=typeof e.clientY)throw new Error("getOffset expects an event with valid clientX and clientY coordinates.");const t=this.#F.getBoundingClientRect(),{left:r,top:i}=It.borderWidth(this.#F);return{x:e.clientX-t.left+r,y:e.clientY-t.top+i}}#Oe(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#h||!this.#ye||!this.#F.parentElement)return;if(this.#we){const e=this.#F.cloneNode(!0);if(!(e instanceof HTMLElement))throw new Error("[TinyDragger] INVALID DRAG ELEMENT!");this.#Me=e}else this.#Me=this.#F;this.#Se=!0;const t=this.#F.getBoundingClientRect();Object.assign(this.#Me.style,{position:"absolute",pointerEvents:"none",left:`${this.#F.offsetLeft}px`,top:`${this.#F.offsetTop}px`,width:`${t.width}px`,height:`${t.height}px`,zIndex:this.#$e}),this.#we&&(this.#F.classList.add(this.#Ne),this.#F.parentElement.appendChild(this.#Me));const{x:r,y:i}=this.getOffset(e);this.#be=r,this.#ge=i,this.#Me.classList.add(this.#Le),document.body.classList.add(this.#_e),this.#ke&&this.#ke.classList.add(this.#je),document.addEventListener("mousemove",this._onMouseMove),document.addEventListener("mouseup",this._onMouseUp),document.addEventListener("touchmove",this._onTouchMove,{passive:!1}),document.addEventListener("touchend",this._onTouchEnd),navigator.vibrate&&Array.isArray(this.#De.start)&&navigator.vibrate(this.#De.start),this.checkDragCollision(e),this.#Be("drag")}#ze=[];#We(e){e&&(e.classList.add(this.#Pe),this.#ze.push(e))}#Ve(){for(;this.#ze.length>0;){const e=this.#ze.shift();e&&e.classList.remove(this.#Pe)}this.#Ce&&this.#Ce.classList.remove(this.#Pe)}checkDragCollision(e){Mt(this.#h);const{collidedElements:t}=this.execCollision(e),r=t[0]||null;this.#Ce&&!t.includes(this.#Ce)&&this.#Ve(),t.forEach(e=>this.#We(e)),this.#Ie.forEach(e=>{t.includes(e)||e.classList.remove(this.#Pe)}),navigator.vibrate&&Array.isArray(this.#De.collide)&&t.length>0&&navigator.vibrate(this.#De.collide),this.#Ce=r}#He(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#h||!this.#Se||!this.#ye||!this.#Me)return;const t=(this.#Me.offsetParent||document.body).getBoundingClientRect();let r=e.clientX-t.left-this.#be,i=e.clientY-t.top-this.#ge;if(this.#Ee&&this.#ke){const e=this.#ke.getBoundingClientRect(),s=this.#Me.getBoundingClientRect(),n=e.left-t.left,o=e.top-t.top,{x:a,y:l}=It.borderWidth(this.#ke),u=n+e.width-s.width-l,h=o+e.height-s.height-a;r=Math.max(n,Math.min(r,u)),i=Math.max(o,Math.min(i,h))}this.#Me.style.position="absolute",this.#Me.style.left=`${r}px`,this.#Me.style.top=`${i}px`,navigator.vibrate&&Array.isArray(this.#De.move)&&navigator.vibrate(this.#De.move),this.checkDragCollision(e),this.#Be("dragging")}execCollision(e){if(Mt(this.#h),this.#h||!this.#Me)return{inJail:!1,collidedElements:[]};let t=[],r=!0;const i=this.#ke?.getBoundingClientRect();if(this.#xe){const s=e.clientX,n=e.clientY;this.#Ae&&this.#ke&&i&&(r=s>=i.left&&s<=i.right&&n>=i.top&&n<=i.bottom),t=r?this.#ve?this.getAllCollidedElements(s,n):[this.getCollidedElement(s,n)].filter(Boolean):[]}else{const e=this.#Me.getBoundingClientRect();this.#Ae&&this.#ke&&i&&(r=e.left>=i.left&&e.right<=i.right&&e.top>=i.top&&e.bottom<=i.bottom),t=r?this.#ve?this.getAllCollidedElementsByRect(e):[this.getCollidedElementByRect(e)].filter(Boolean):[]}return{inJail:r,collidedElements:t}}#Fe(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#h||!this.#Se)return;if(this.#Se=!1,!this.#Me)return;this.#F.classList.remove(this.#Le),document.body.classList.remove(this.#_e),this.#ke&&this.#ke.classList.remove(this.#je),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd);const{collidedElements:t}=this.execCollision(e);navigator.vibrate&&Array.isArray(this.#De.end)&&navigator.vibrate(this.#De.end);const r=this.#Me.style.left,i=this.#Me.style.top;this.#Me&&(this.#we?this.#Me.remove():Object.assign(this.#Me.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#Me=null),this.#Ce&&this.#Ve(),this.#Ce=null,this.#we&&this.#F.classList.remove(this.#Ne),this.#Te||(this.#F.style.left=r,this.#F.style.top=i);const s=new CustomEvent("drop",{detail:{targets:t,first:t[0]||null}});this.#F.dispatchEvent(s)}#qe(e,t){const r=e.getBoundingClientRect();return!(t.right<r.left||t.left>r.right||t.bottom<r.top||t.top>r.bottom)}getAllCollidedElementsByRect(e){if(Mt(this.#h),!(e instanceof DOMRect)||"number"!=typeof e.left||"number"!=typeof e.right||"number"!=typeof e.top||"number"!=typeof e.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#Ie.filter(t=>this.#qe(t,e))}getCollidedElementByRect(e){if(Mt(this.#h),!(e instanceof DOMRect)||"number"!=typeof e.left||"number"!=typeof e.right||"number"!=typeof e.top||"number"!=typeof e.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#Ie.find(t=>this.#qe(t,e))||null}#Ke(e,t,r){const i=e.getBoundingClientRect();return t>=i.left&&t<=i.right&&r>=i.top&&r<=i.bottom}getAllCollidedElements(e,t){if(Mt(this.#h),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Ie.filter(r=>this.#Ke(r,e,t))}getCollidedElement(e,t){if(Mt(this.#h),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Ie.find(r=>this.#Ke(r,e,t))||null}#Be(e){const t=new CustomEvent(e);this.#F.dispatchEvent(t)}getDragging(){return Mt(this.#h),this.#Se}getLockInsideJail(){return Mt(this.#h),this.#Ee}setLockInsideJail(e){if(Mt(this.#h),"boolean"!=typeof e)throw new Error("lockInsideJail must be a boolean.");this.#Ee=e}getRevertOnDrop(){return Mt(this.#h),this.#Te}setRevertOnDrop(e){if(Mt(this.#h),"boolean"!=typeof e)throw new Error("revertOnDrop must be a boolean.");this.#Te=e}getCollisionByMouse(){return Mt(this.#h),this.#xe}setCollisionByMouse(e){if(Mt(this.#h),"boolean"!=typeof e)throw new Error("collisionByMouse must be a boolean.");this.#xe=e}getDropInJailOnly(){return Mt(this.#h),this.#Ae}setDropInJailOnly(e){if(Mt(this.#h),"boolean"!=typeof e)throw new Error("dropInJailOnly must be a boolean.");this.#Ae=e}getDefaultZIndex(){return Mt(this.#h),this.#$e}setDefaultZIndex(e){if(Mt(this.#h),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("Z-index must be a finite number.");this.#$e=e}isMirrorEnabled(){return Mt(this.#h),this.#we}setMirrorEnabled(e){if(Mt(this.#h),"boolean"!=typeof e)throw new TypeError("Mirror setting must be a boolean.");this.#we=e}getTarget(){return Mt(this.#h),this.#F}getJail(){return Mt(this.#h),this.#ke}getDragProxy(){return Mt(this.#h),this.#Me}getLastCollision(){return Mt(this.#h),this.#Ce}getCollidables(){return Mt(this.#h),[...this.#Ie]}getDragHiddenClass(){return Mt(this.#h),this.#Ne}getClassDragging(){return Mt(this.#h),this.#Le}getClassBodyDragging(){return Mt(this.#h),this.#_e}getClassJailDragging(){return Mt(this.#h),this.#je}getClassJailDragDisabled(){return Mt(this.#h),this.#Re}getClassDragCollision(){return Mt(this.#h),this.#Pe}getVibrations(){return Mt(this.#h),{...this.#De}}getStartVibration(){return Mt(this.#h),this.#De.start}getEndVibration(){return Mt(this.#h),this.#De.end}getCollideVibration(){return Mt(this.#h),this.#De.collide}getMoveVibration(){return Mt(this.#h),this.#De.move}isEnabled(){return Mt(this.#h),this.#ye}destroy(){this.#h||(this.disable(),this.#F.removeEventListener("mousedown",this._onMouseDown),this.#F.removeEventListener("touchstart",this._onTouchStart),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd),this.#Ce&&this.#Ve(),this.#Me&&(this.#we?this.#Me.remove():Object.assign(this.#Me.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#Me=null),this.#Ie=[],this.#Se=!1,this.#Ce=null,this.#we&&this.#F.classList.remove(this.#Ne),this.#F.classList.remove(this.#Le),document.body.classList.remove(this.#_e),this.#ke&&this.#ke.classList.remove(this.#je,this.#Re),this.#h=!0)}}const kt=Dt,Nt=class{#Je=[];#Ue=!1;#Ge=!1;#Ye=[];#Xe(){this.#Ue&&Promise.all(this.#Ye).then(()=>{this.#Ge=!0,this.#Qe(!1)}).catch(e=>{console.error("[TinyDomReadyManager] Promise rejected:",e)})}#Qe(e){this.#Je.filter(t=>t.domOnly===e).sort((e,t)=>t.priority-e.priority).forEach(e=>this.#Ze(e)),this.#Je=this.#Je.filter(t=>!(t.once&&(!e||t.domOnly)))}#Ze(e){if("function"==typeof e.filter)try{if(!e.filter())return}catch(e){return void console.warn("[TinyDomReadyManager] Filter error:",e)}try{e.fn()}catch(e){console.error("[TinyDomReadyManager] Handler error:",e)}}_markDomReady(){this.#Ue=!0,this.#Qe(!0),this.#Xe()}init(){if(this.#Ue)throw new Error("[TinyDomReadyManager] init() has already been called.");"interactive"===document.readyState||"complete"===document.readyState?this._markDomReady():document.addEventListener("DOMContentLoaded",()=>this._markDomReady())}addPromise(e){if(!(e instanceof Promise))throw new TypeError("[TinyDomReadyManager] promise must be a valid Promise.");this.#Ge||(this.#Ye.push(e),this.#Ue&&this.#Xe())}onReady(e,{once:t=!0,priority:r=0,filter:i=null,domOnly:s=!1}={}){if("function"!=typeof e)throw new TypeError("[TinyDomReadyManager] fn must be a function.");const n={fn:e,once:t,priority:r,filter:i,domOnly:s};if(s&&this.#Ue)return this.#Ze(n),void(t||this.#Je.push(n));!s&&this.#Ge?this.#Ze(n):this.#Je.push(n)}isReady(){return this.#Ge}isDomReady(){return this.#Ue}},Lt=class{#et=!1;#tt=!1;#rt=null;#it=100;#st=null;#nt;constructor({audio:e=null,defaultIcon:t=null,bodyLimit:r=100,defaultOnClick:i=function(e){e.preventDefault(),window.focus&&window.focus(),this.close()}}={}){if(!(e instanceof HTMLAudioElement)&&"string"!=typeof e&&null!==e)throw new TypeError("audio must be an instance of HTMLAudioElement or null.");if(null!==t&&"string"!=typeof t)throw new TypeError("defaultIcon must be a string or null.");if(!Number.isFinite(r)||r<0)throw new TypeError("bodyLimit must be a non-negative number.");if("function"!=typeof i)throw new TypeError("defaultOnClick must be a function.");this.#rt="string"!=typeof e?e:new Audio(e),this.#st=t,this.#it=r,this.#nt=i}requestPerm(){const e=this;return new Promise((t,r)=>{e.isCompatible()?"default"===Notification.permission?Notification.requestPermission().then(r=>{this.#tt=!0,e.#et="granted"===r,t(e.#et)}).catch(r):(this.#tt=!0,e.#et="granted"===Notification.permission,t(e.#et)):(this.#tt=!0,e.#et=!1,t(!1))})}isCompatible(){return"Notification"in window}send(e,t={}){if(!this.#tt)throw new Error("You must call requestPerm() before sending a notification.");if("string"!=typeof e)throw new TypeError("title must be a string.");if("object"!=typeof t||null===t)throw new TypeError("config must be a non-null object.");if(!this.#et)return null;const{icon:r=this.#st||void 0,vibrate:i=[200,100,200]}=t,s={...t};"string"==typeof r&&(s.icon=r),Array.isArray(i)&&(s.vibrate=i),"string"==typeof s.body&&(s.body=U(s.body,this.#it));const n=new Notification(e,s);return n.addEventListener("show",()=>{this.#rt instanceof HTMLAudioElement&&(this.#rt.currentTime=0,this.#rt.play().catch(e=>console.error(e)))}),"function"==typeof this.#nt&&n.addEventListener("click",this.#nt),n}wasPermissionRequested(){return this.#tt}isAllowed(){return this.#et}getAudio(){return this.#rt}setAudio(e){if(!(e instanceof HTMLAudioElement)&&"string"!=typeof e&&null!==e)throw new TypeError("sound must be an instance of HTMLAudioElement or null.");this.#rt="string"!=typeof e?e:new Audio(e)}getBodyLimit(){return this.#it}setBodyLimit(e){if(!Number.isFinite(e)||e<0)throw new TypeError("bodyLimit must be a non-negative number.");this.#it=e}getDefaultAvatar(){return this.#st}setDefaultAvatar(e){if("string"!=typeof e&&null!==e)throw new TypeError("defaultIcon must be a string or null.");this.#st=e}getDefaultOnClick(){return this.#nt}setDefaultOnClick(e){if("function"!=typeof e)throw new TypeError("defaultOnClick must be a function.");this.#nt=e}},_t=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');if("string"!=typeof e)throw new TypeError(`Expected "${t}" to be a string, but received ${typeof e}.`)},jt=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');if("function"!=typeof e)throw new TypeError(`Expected "${t}" to be a function, but received ${typeof e}.`)},Rt=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError(`Expected "${t}" to be a plain object, but received ${null===e?"null":Array.isArray(e)?"array":typeof e}.`)},Pt=new Map;class $t extends Error{constructor(e,t,r){if(_t(e,"message"),_t(t,"url"),"string"!=typeof r)throw new TypeError(`Expected "stage" to be a string, but received ${typeof r}.`);super(e),this.name="MediaLoadingError",this.url=t,this.stage=r}}const Ot=async e=>{_t(e,"str");const t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-1",t);return Array.from(new Uint8Array(r)).map(e=>e.toString(16).padStart(2,"0")).join("").substring(0,8)},Ht=(e,t="image/jpeg")=>{if(!(e instanceof Uint8Array)&&"string"!=typeof e)throw new TypeError(`Expected "data" to be an instance of Uint8Array or a string, but received ${typeof e}.`);_t(t,"format");const r=e=>{const t=URL.createObjectURL(e),r=Pt.get(t);return Pt.set(t,"number"==typeof r?r+1:1),t};if(e instanceof Uint8Array)return r(new Blob([e],{type:t}));if("string"==typeof e&&e.startsWith("data:")){const i=e.split(",")[1],s=atob(i),n=new Uint8Array(s.length);for(let e=0;e<s.length;e++)n[e]=s.charCodeAt(e);return r(new Blob([n],{type:t}))}return"string"==typeof e?e:""},Ft=async e=>{if(_t(e,"url"),!e.startsWith("blob:"))return e;try{const t=await fetch(e),r=await t.blob();return await new Promise((e,t)=>{const i=new FileReader;i.onloadend=()=>e(String(i.result)),i.onerror=t,i.readAsDataURL(r)})}catch(t){return console.warn(`[TinyAudioUtils] Failed to convert Blob URL to Base64 on export: ${e}`,t),e}},Bt=e=>{Rt(e,"content"),e&&Array.isArray(e.picture)&&e.picture.forEach(e=>{if("string"==typeof e.data&&e.data.startsWith("blob:")){const t=Pt.get(e.data)??0;t>1?Pt.set(e.data,t-1):Pt.delete(e.data),t<=1&&URL.revokeObjectURL(e.data)}})},zt=(e,t)=>{if(Rt(e,"common"),"boolean"!=typeof t)throw new TypeError('Expected "isPartial" to be a boolean.');const r=e=>t&&void 0===e,i=e=>r(e)||"string"==typeof e||null===e,s=(e,t)=>(jt(t,"valueValidator"),!!r(e)||!(!Array.isArray(e)||!e.every(t)));if(!i(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!i(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!i(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!i(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(n=e.year,!r(n)&&"number"!=typeof n&&null!==n)throw new TypeError('Invalid metadata: "year" must be a number or null.');var n;if(!s(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!s(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!s(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!s(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!s(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!s(e.picture,e=>e&&"object"==typeof e&&(void 0===e.description||"string"==typeof e.description)&&(void 0===e.name||"string"==typeof e.name)&&(void 0===e.type||"string"==typeof e.type)&&"string"==typeof e.format&&(e.data instanceof Uint8Array||"string"==typeof e.data)))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');const o=(e,t)=>{if(_t(e,"name"),!r(t)){if(null==t)throw new TypeError(`Invalid metadata: "${e}" is required.`);if("object"!=typeof t)throw new TypeError(`Invalid metadata: "${e}" must be an object or null.`);if("number"!=typeof t.no&&null!==t.no)throw new TypeError(`Invalid metadata: "${e}.no" must be a number or null.`);if("number"!=typeof t.of&&null!==t.of)throw new TypeError(`Invalid metadata: "${e}.of" must be a number or null.`)}};o("disk",e.disk),o("track",e.track)},Wt=e=>(Rt(e,"common"),zt(e,!1)),Vt=e=>(Rt(e,"common"),zt(e,!0)),qt=async(e,t,r=!0)=>{_t(e,"url"),jt(t,"parseFile");try{const i=await fetch(e);if(!i.ok)throw new Error(`Failed to fetch audio file: ${i.status} ${i.statusText}`);const s=await i.blob(),n=await t(s);if(!n||"object"!=typeof n.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const o=n.common;return Vt(o),{title:o?.title??null,album:o?.album??null,albumartist:o?.albumartist??null,albumartists:o?.albumartists??[],genre:o?.genre??[],label:o?.label??[],composer:o?.composer??[],year:o?.year??null,artist:o?.artist??null,artists:o?.artists??[],disk:o?.disk?{no:o.disk.no,of:o.disk.of}:{no:null,of:null},track:o?.track?{no:o.track.no,of:o.track.of}:{no:null,of:null},picture:o?.picture?.map(e=>({...e,data:r?Ht(e.data,e.format):e.data}))??[]}}catch(e){throw e}},Kt=async(e,t={},r={},i=e=>{if(!(e instanceof Blob))throw new TypeError('Expected "data" to be a Blob.');return new Promise((e,t)=>t(new TypeError("parseFile library not found.")))},s={},n=!0,o="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(Rt(t,"defaultMetadata"),Rt(r,"metadata"),jt(i,"parseFile"),Rt(s,"callbacks"),s.onProgress&&"function"!=typeof s.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(s.onError&&"function"!=typeof s.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof o&&"function"!=typeof o)throw new TypeError("unknownArtist must be a string or a function returning a string.");let a,l="";const u=(t,r)=>{if(_t(t,"stage"),void 0!==r&&!(r instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');s.onProgress&&s.onProgress({event:r,status:"loading",stage:t,url:l||(e instanceof HTMLMediaElement?e.src:"unknown")})},h=(t,r)=>{if(!(t instanceof Error))throw new TypeError('Expected "error" to be an Error.');_t(r,"stage"),s.onError&&s.onError({error:t,url:l||(e instanceof HTMLMediaElement?e.src:"unknown"),stage:r})};try{u("INITIALIZING"),"string"==typeof e?(l=e,a=new Audio(l)):(a=e,l=a.src);try{await new Promise((e,t)=>{const r=e=>u("DOWNLOADING",e),i=()=>{n(),e(void 0)},s=e=>{n(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},n=()=>{a.removeEventListener("progress",r),a.removeEventListener("loadedmetadata",i),a.removeEventListener("error",s)};a.addEventListener("progress",r),a.addEventListener("loadedmetadata",i),a.addEventListener("error",s),a.readyState>=1&&(n(),e(void 0))}),u("METADATA_LOADED")}catch(e){throw new $t(e instanceof Error?e.message:"UNKNOWN ERROR",l,"METADATA")}const c={id:r.id||await Ot(l),duration:Math.floor(1e3*a.duration),url:l,weight:r.weight??1};let d={};u("EXTRACTING_ID3");try{d=await qt(l,i,n)}catch(e){h(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${l}. Falling back to filename.`)}const m=e=>{_t(e,"url");try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},p={...c,...t,...d,...r,title:d.title||r.title||m(l),artist:d.artist||r.artist||("string"==typeof o?o:String(o()))};return s.onProgress&&s.onProgress({status:"success",stage:"COMPLETE",url:l}),p}catch(e){if(e instanceof $t)throw e;{const t=new $t(e instanceof Error?e.message:"UNKNOWN ERROR",l,"INITIALIZING");throw h(t,"INITIALIZING"),t}}},Jt=ee("TinyAfterScrollWatcher"),Ut=class{#ot;get scrollTarget(){return Jt(this.#h),this.#ot}#at=null;#lt=[];get afterScrollQueueSize(){return Jt(this.#h),this.#lt.length}#ut=100;#ht=new Set;#ct=new Set;#h=!1;get destroyed(){return this.#h}constructor(e,t=100){if(!(e instanceof Element||e instanceof Window))throw new TypeError("scrollTarget must be an Element or the Window object.");this.#ot=e,this._checkTimer=this._checkTimer.bind(this),this.#ot.addEventListener("scroll",this._checkTimer),this.#ut=t}_checkTimer=()=>{this.#at&&clearTimeout(this.#at),this.#at=setTimeout(()=>{this.#at=null,this.#dt()},this.#ut)};get inactivityTime(){return Jt(this.#h),this.#ut}set inactivityTime(e){if(Jt(this.#h),"number"!=typeof e||e<=0||!Number.isFinite(e))throw new Error("inactivityTime must be a positive number in milliseconds.");this.#ut=e}#dt(){if(!this.#h){for(const e of this.#ct)"function"==typeof e&&e();for(;this.#lt.length;){const e=this.#lt.pop();"function"==typeof e&&e()}}}doAfterScroll(e){if(Jt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.lastScrollTime=Date.now(),this.#lt.push(e)}onStop(e){if(Jt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ct.add(e)}offStop(e){if(Jt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ct.delete(e)}onScroll(e){if(Jt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ot.addEventListener("scroll",e),this.#ht.add(e)}offScroll(e){if(Jt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ht.has(e)&&(this.#ot.removeEventListener("scroll",e),this.#ht.delete(e))}destroy(){if(!this.#h){this.#ot.removeEventListener("scroll",this._checkTimer);for(const e of this.#ht)this.#ot.removeEventListener("scroll",e);this.#ht.clear(),this.#ct.clear(),this.#h=!0}}},Gt=ee("UltraRandomMsgGen"),Yt=["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","sed","do","eiusmod","tempor","incididunt","ut","labore","et","dolore","magna","aliqua"],Xt=["😂","🌈","🤖","💥","🐸","🍕","🦄","🧠","🧬","🚀","🫠","💫","🍩","👾","🎉","🥴","🐙","🧃","🪐","🎈","🧸","👻","🥳","🍭","💖","😺","🌮","🪅","🎮","🥓","🍮","🍬","🍓","🍒","🥝","🥑","🍄","🌊","☁️","🌟","🌙","🧚","🐾","🐥","🐼","🐨","🐳","✨","🧁","🌸","🍃","💎","🎐","🎀","🫧","☄️","🛸","🔮"],Qt=["pudding","bean","snuggle","bloop","jelly","unicorn","floof","giggle","bubble","muffin","puff","pickle","goblin","waffle","sprinkle","cupcake","fizzle","marshmallow","duckling","sock","cloud","teacup","nugget","gnome","hug","moonbean","crayon","jiggle","glitter","carrot","goober"],Zt=["wiggles","bounces","flies","splats","scoots","giggles","wigglesnacks","twirls","boops","pops","sings","hugs","floats","glows","flaps","mlems","dances","puddles","nomnoms","wigglejumps","sniffs","tumbles","slides","chirps","burps","sparkles","waddles","rambles","blinks","mews"],er=["fluffy","silly","yummy","squishy","wobbly","magical","tiny","sleepy","wiggly","bubbly","glittery","fuzzy","jiggly","sparkly","giggly","crunchy","goofy","soft","mushy","sweet","loopy","floaty","bonkers","chewy","ticklish","dreamy","pastel","cozy","teensy","grumbly"],tr=["Boop!","Wiggle achieved.","Oops, {noun} everywhere!","Tiny {adj} {noun}, big {adj} {noun}.","Snuggle initiated with a {adj} {noun}.","{adj} vibes only, powered by {noun}.","No {noun}, no {noun}.","Bounce first, {verb} later.","Mlem. {verb}. {noun}.","{noun} go brrr and {verb}.","Why not? {noun} did. Then {noun} followed.","A {adj} {noun} just {verb} near the {adj} window.","That {adj} {noun} stole my {noun}!","Look, a {adj} {noun} trying to {verb} again!","Every {noun} deserves a {adj} nap.","The {adj} {noun} is my {adj} spirit animal.","Someone call the {noun}, it’s {verb}ing and {verb}ing again!","Don’t touch the {adj} {noun}. It {verb}s loudly.","{noun} forgot how {noun}s work and just {verb}ed.","There once was a {adj} {noun} who loved to {verb} with a {adj} {noun} all day.","Apparently, {noun}s are banned from {verb}ing and {verb}ing in the {noun} library.","That {adj} noise? Just a {noun} learning to {verb} on a {adj} {noun}.","I saw a {adj} {noun} {verb} so hard, it became a {adj} muffin.","The {adj} {noun} met a {adj} pickle and everything {verb}ed.","{noun}s are like {noun}: {adj}, unpredictable, and wiggly.","Don’t judge a {adj} {noun} by its ability to {verb}, or by its {adj} hat.","All I wanted was peace, but a {adj} {noun} with a {adj} {noun} had other plans.","One {adj} morning, a {adj} {noun} decided it was finally time to {verb}, but halfway through, it tripped on a {noun} and turned into a {adj} marshmallow.","I tried to be {adj} today, but then a {noun} {verb}ed across my {noun} and typed “asdfgh{noun}” repeatedly.","If you think you’ve seen everything, wait until a {adj} {noun} {verb}s on a {noun} wearing {adj} socks with tiny {noun}s.","No one ever believed the stories about the ancient {adj} {noun} who could {verb} with such {adj} grace that entire {noun}s turned pink out of embarrassment.","A curious {adj} {noun} wandered into a {noun} shop, not knowing that its destiny involved twelve {adj} {noun}s, one rubber {noun}, and a suspiciously quiet {adj} llama.","In a land where every {adj} {noun} was made of pudding and the sky was {adj} whipped cream, one brave {adj} {noun} set out to discover the legendary Spoon of {noun}s, facing obstacles like bouncing {noun}s, sassy {noun}s, and the Great Wobble of the {noun}.","Once upon a {adj} time, long before the {noun}s learned to {verb}, there existed a tiny {adj} {noun} who dreamed of swimming in a pool made entirely of {adj} glitter pudding while {verb}ing off-key lullabies to passing {noun}s with monocles.","The Council of {noun}s gathered in {adj} secret when the sacred {adj} {noun} started to {verb} uncontrollably, threatening the entire {adj} dessert-based civilization with spontaneous {noun} jiggles and uncontainable {noun} fits across the {noun}.","Hey... do you ever wonder if {noun}s dream of {noun}s?","Okay but hear me out: what if the {adj} {noun} could actually {verb} backwards?","Can we talk about the {noun} that just {verb}ed and vanished?","So I was talking to a {noun}, and it told me to stop being {adj}. Rude.","Not to alarm you, but there’s a {adj} {noun} behind you doing the {verb}.","Why does this {noun} keep staring at me like I owe it pudding?","Is this a safe space to admit I accidentally {verb}ed a {noun}?","I just walked into the room and someone shouted “{adj} {noun}!” — what did I miss?","Wait... we were supposed to bring a {noun}? No one told me!","Okay but what if the {adj} {noun} has feelings too?","Be honest, do I look like a {noun} that forgot how to {verb}?",'If I say "oops", do I still have to explain why the {noun} is glowing?',"I don’t know what’s going on but I brought snacks and a confused {noun}.","Do you think pudding knows it’s pudding? Just a thought.","Is this about the time I {verb}ed the {adj} {noun} by accident? Because I can explain.","Wait, are we talking about {noun}s or am I on the wrong chat again?",'What is this group even about? I just saw "pudding" and joined.',"Hi! I have no idea what’s happening but I’m here and I brought a {noun}.","I blinked and now there’s a {adj} {noun} in charge of everything.","Can someone please explain why the {noun} is floating and chanting?","Okay who gave the {noun} access to glitter and emotional support pickles?","I came for a calm discussion and now there’s a {adj} battle between {noun}s.","Not sure if I’m early, late, or inside a {noun} dream.","I was gone for 3 minutes and now someone’s riding a {noun} into the pudding realm.","This isn’t the pudding appreciation group, is it? ...oh no.","So... who summoned the {adj} {noun} this time? Be honest.","I came here for vibes and stayed for the {noun}s.","Does anyone else hear faint giggling or is that just the {adj} {noun} again?","I feel like I missed step one, two, and also three of this conversation.","All I asked was “what’s up?” and now I’m emotionally attached to a {noun}.",'Me: "I’ll be normal today." Also me: *{verb}s into a meeting riding a {adj} {noun}*','"It’s just pudding," they said. "It can’t hurt you," they said. They were wrong.',"I said one nice thing to a {noun} and now it follows me everywhere.","Can we take a moment to appreciate how the {adj} {noun} is just vibing?","Who put a tiny hat on the {noun}? Because that’s adorable.","My life has been different ever since the {noun} started {verb}ing.","Raise your hand if you’ve ever been personally attacked by a {adj} {noun}.",'"Don’t be weird," they said. So I became a {noun} instead.',"Do {noun}s have feelings? Asking for a {adj} friend.","I trusted the {noun} and all I got was a glitter-covered sock.","Plot twist: the {adj} {noun} was inside us all along.","In the glow of the {adj} moon, the {noun} began to {verb}.","A sprinkle of {adj} dust made the {noun} {verb} through the air.","The {noun} whispered a {adj} secret that made everyone {verb}.","Everything felt {adj} and {adj}, especially when the {noun} {verb}ed.","The {noun} is {verb}ing! The {noun} is {verb}ing! AAAAA!","Glitch in the {noun}: the {adj} {noun} just {verb}ed out of existence.","The {adj} {noun} {verb} and {verb} all over the {adj} {noun}!","Oops! {noun}s {verb}ed into the {adj} {noun} while {verb}ing crazily.","{adj}, {adj}, and more {adj} {noun}s just {verb}ed by!","Why does the {adj} {noun} keep {verb}ing and {verb}ing without stopping?","Look! A {adj} {noun}, a {adj} {noun}, and a {noun} all {verb}ing together!","Sometimes, the {noun} just {verb}s, then {verb}s again, and never stops being {adj}.","{noun}, {noun}, and {noun} — all {verb}ing and {verb}ing in a {adj} {noun}.","I saw a {adj} {noun} {verb}, then another {noun} {verb}ing with a {adj} {noun}.","The {noun} {verb}s {verb} while the {adj} {noun} {verb}s and the {noun} just {verb}s.","Can a {adj} {noun} {verb} {verb} without a {adj} {noun} watching?","Whoa! The {adj} {noun} just {verb}ed... and then {verb}ed again!","Hey... did you see that {adj} {noun} {verb} over there?","Umm, the {noun} is {verb}ing but also {verb}ing and {verb}ing!","Lol! {noun}s {verb} so {adj}ly, it’s impossible not to giggle.",'"Hey! What’s up?" asked the {adj} {noun}, who {verb}ed loudly.','"I’m just a {adj} {noun} trying to {verb}, you know?"','"Did you see the {adj} {noun} that just {verb}ed in the pudding?"','"No way! The {noun} {verb}s better than me!"','"Wait, the {adj} {noun} said it would {verb}, but it {verb}ed instead!"',"Once upon a {adj} {noun}, a group of {adj} {noun}s {verb}ed through the {adj} forest, singing {adj} songs and eating {noun}s made of pudding.","The legend tells of a {adj} {noun} who could {verb} faster than any {noun} ever seen, leaving trails of {adj} sparkles behind.","Every day, the {adj} {noun} would {verb} around the {adj} meadow, trying to convince the {noun}s to join the grand pudding party.","No one knows why the {adj} {noun} suddenly {verb}ed and then {verb}ed again, but everyone agrees it was the cutest thing they ever saw.","In the kingdom of {adj} {noun}s, only the bravest {noun} dared to {verb} the giant pudding monster, armed with nothing but {adj} smiles and jellybeans.","{adj} {noun} {verb} {verb} {verb} {noun} {verb} {adj} {noun} {verb} {noun}!","{noun} {noun} {verb} {adj} {noun} and then {verb} {verb} the {adj} {noun}.","{verb} the {adj} {noun}, then {verb} the {noun} while {verb}ing {adj}ly.","Can the {adj} {noun} {verb} and {verb} the {adj} {noun} at the same time?","{noun} {verb} {noun} {verb}, but the {adj} {noun} {verb}s better.","Boop! The {adj} {noun} just {verb}ed in the pudding.","Bloop bloop, the {noun} is {verb}ing all over again!","Mlem mlem, a {adj} {noun} {verb}s quietly in the corner.","Splat! {noun} {verb}ed right on the {adj} {noun}.","Yum! A {adj} {noun} just {verb}ed in my mouth.","Do {noun}s really {verb} when nobody’s watching?","Why does the {adj} {noun} always {verb} at midnight?","Can a {noun} be too {adj} to {verb} properly?","Is it normal for a {adj} {noun} to {verb} three times in a row?","Who taught the {noun} to {verb} like that?","Wait, did the {adj} {noun} just {verb} itself?","I can’t believe the {noun} {verb}ed into a {adj} {noun}!","Suddenly, a {adj} {noun} appeared and started to {verb} wildly.","That {noun} was {verb}ing so {adj}ly it broke the pudding meter.","Everyone’s talking about the {adj} {noun} that {verb}ed out of nowhere."];class rr{static#mt=Yt;static#pt=Xt;static#ft=Qt;static#yt=Zt;static#gt=er;static#bt=tr;static#wt(e,t){if(!Array.isArray(e))throw new TypeError(`${t} must be an array of strings`);if(!e.every(e=>"string"==typeof e))throw new TypeError(`${t} must contain only strings`);if(0===e.length)throw new Error(`${t} cannot be empty`)}static get defaultWords(){return[...this.#mt]}static set defaultWords(e){this.#wt(e,"defaultWords"),this.#mt=[...e]}static get defaultEmojis(){return[...this.#pt]}static set defaultEmojis(e){this.#wt(e,"defaultEmojis"),this.#pt=[...e]}static get defaultNouns(){return[...this.#ft]}static set defaultNouns(e){this.#wt(e,"defaultNouns"),this.#ft=[...e]}static get defaultVerbs(){return[...this.#yt]}static set defaultVerbs(e){this.#wt(e,"defaultVerbs"),this.#yt=[...e]}static get defaultAdjectives(){return[...this.#gt]}static set defaultAdjectives(e){this.#wt(e,"defaultAdjectives"),this.#gt=[...e]}static get defaultTemplates(){return[...this.#bt]}static set defaultTemplates(e){this.#wt(e,"defaultTemplates"),this.#bt=[...e]}#h=!1;get destroyed(){return this.#h}#vt={minLength:10,maxLength:300,readable:!0,useEmojis:!0,includeNumbers:!0,includeSymbols:!0,allowWeirdSpacing:!1,emojiSet:[],wordSet:[],mode:"mixed",grammar:{templates:[],nouns:[],verbs:[],adjectives:[]},repeatWords:!0,emojiPlacement:"inline",line:{minLength:20,maxLength:120,emojiChance:.3}};get config(){return Gt(this.#h),structuredClone(this.#vt)}#Et="!@#$%^&*()-_=+[]{}|;:,.<>?/\\~".split("");get symbols(){return Gt(this.#h),structuredClone(this.#Et)}constructor(e={}){const{minLength:t,maxLength:r,readable:i,useEmojis:s,includeNumbers:n,includeSymbols:o,allowWeirdSpacing:a,emojiSet:l,wordSet:u,mode:h,grammar:c,repeatWords:d,emojiPlacement:m,paragraphs:p,line:f}=e;if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.minLength must be an integer >= 1");if(void 0!==r&&(!Number.isInteger(r)||r<1))throw new TypeError("config.maxLength must be an integer >= 1");if(void 0!==t&&void 0!==r&&t>r)throw new RangeError("config.minLength cannot be greater than config.maxLength");if(void 0!==i&&"boolean"!=typeof i)throw new TypeError("config.readable must be a boolean");if(void 0!==s&&"boolean"!=typeof s)throw new TypeError("config.useEmojis must be a boolean");if(void 0!==n&&"boolean"!=typeof n)throw new TypeError("config.includeNumbers must be a boolean");if(void 0!==o&&"boolean"!=typeof o)throw new TypeError("config.includeSymbols must be a boolean");if(void 0!==a&&"boolean"!=typeof a)throw new TypeError("config.allowWeirdSpacing must be a boolean");if(void 0!==l&&!Array.isArray(l))throw new TypeError("config.emojiSet must be an array of strings");if(void 0!==u&&!Array.isArray(u))throw new TypeError("config.wordSet must be an array of strings");if(void 0!==h&&!["mixed","readable","chaotic","natural"].includes(h))throw new RangeError('config.mode must be one of: "mixed", "readable", "chaotic", "natural');if(void 0!==c){if("object"!=typeof c||null===c)throw new TypeError("config.grammar must be an object");const{templates:e,nouns:t,verbs:r,adjectives:i}=c;if(void 0!==e&&!Array.isArray(e))throw new TypeError("config.grammar.templates must be an array of strings");if(void 0!==t&&!Array.isArray(t))throw new TypeError("config.grammar.nouns must be an array of strings");if(void 0!==r&&!Array.isArray(r))throw new TypeError("config.grammar.verbs must be an array of strings");if(void 0!==i&&!Array.isArray(i))throw new TypeError("config.grammar.adjectives must be an array of strings")}if(void 0!==d&&"boolean"!=typeof d)throw new TypeError("config.repeatWords must be a boolean");if(void 0!==m&&!["inline","end","none"].includes(m))throw new RangeError('config.emojiPlacement must be one of: "inline", "end", "none"');if(void 0!==p){if("object"!=typeof p)throw new TypeError("config.paragraphs must be an object or null");const{min:e,max:t}=p;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.paragraphs.min must be an integer >= 1");if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.paragraphs.max must be an integer >= 1");if(void 0!==e&&void 0!==t&&e>t)throw new RangeError("config.paragraphs.min cannot be greater than config.paragraphs.max")}if(void 0!==f){if("object"!=typeof f||null===f)throw new TypeError("config.line must be an object");const{minLength:e,maxLength:t,emojiChance:r}=f;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.line.minLength must be an integer >= 1");if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.line.maxLength must be an integer >= 1");if(void 0!==e&&void 0!==t&&e>t)throw new RangeError("config.line.minLength cannot be greater than config.line.maxLength");if(void 0!==r&&("number"!=typeof r||r<0||r>1))throw new RangeError("config.line.emojiChance must be a number between 0 and 1")}this.#vt.emojiSet=[...rr.#pt],this.#vt.wordSet=[...rr.#mt],this.#vt.grammar.templates=[...rr.#bt],this.#vt.grammar.nouns=[...rr.#ft],this.#vt.grammar.verbs=[...rr.#yt],this.#vt.grammar.adjectives=[...rr.#gt],Object.assign(this.#vt,e)}configure(e={}){return Gt(this.#h),Object.assign(this.#vt,e),this}setGrammarTemplates(...e){return Gt(this.#h),this.#vt.grammar.templates=e.flat(),this}addGrammarTemplates(...e){return Gt(this.#h),this.#vt.grammar.templates.push(...e.flat()),this}setGrammarNouns(...e){return Gt(this.#h),this.#vt.grammar.nouns=e.flat(),this}addGrammarNouns(...e){return Gt(this.#h),this.#vt.grammar.nouns.push(...e.flat()),this}setGrammarVerbs(...e){return Gt(this.#h),this.#vt.grammar.verbs=e.flat(),this}addGrammarVerbs(...e){return Gt(this.#h),this.#vt.grammar.verbs.push(...e.flat()),this}setGrammarAdjectives(...e){return Gt(this.#h),this.#vt.grammar.adjectives=e.flat(),this}addGrammarAdjectives(...e){return Gt(this.#h),this.#vt.grammar.adjectives.push(...e.flat()),this}removeGrammarTemplates(...e){Gt(this.#h);const t=new Set(e.flat());return this.#vt.grammar.templates=this.#vt.grammar.templates.filter(e=>!t.has(e)),this}removeGrammarNouns(...e){Gt(this.#h);const t=new Set(e.flat());return this.#vt.grammar.nouns=this.#vt.grammar.nouns.filter(e=>!t.has(e)),this}removeGrammarVerbs(...e){Gt(this.#h);const t=new Set(e.flat());return this.#vt.grammar.verbs=this.#vt.grammar.verbs.filter(e=>!t.has(e)),this}removeGrammarAdjectives(...e){Gt(this.#h);const t=new Set(e.flat());return this.#vt.grammar.adjectives=this.#vt.grammar.adjectives.filter(e=>!t.has(e)),this}setWords(...e){return Gt(this.#h),this.#vt.wordSet=e.flat(),this}addWords(...e){return Gt(this.#h),this.#vt.wordSet.push(...e.flat()),this}removeWords(...e){Gt(this.#h);const t=new Set(e.flat());return this.#vt.wordSet=this.#vt.wordSet.filter(e=>!t.has(e)),this}setEmojis(...e){return Gt(this.#h),this.#vt.emojiSet=e.flat(),this}addEmojis(...e){return Gt(this.#h),this.#vt.emojiSet.push(...e.flat()),this}removeEmojis(...e){Gt(this.#h);const t=new Set(e.flat());return this.#vt.emojiSet=this.#vt.emojiSet.filter(e=>!t.has(e)),this}_getRandomItem(e){return e[Math.floor(Math.random()*e.length)]}_generateChunk(){const{wordSet:e,emojiSet:t,includeNumbers:r,includeSymbols:i,useEmojis:s,readable:n,mode:o,emojiPlacement:a}=this.#vt;if("natural"===o)return this._generateNaturalSentence();const l=[];return(n||"readable"===o||"mixed"===o)&&l.push(this._getRandomItem(e)),"chaotic"!==o&&"mixed"!==o||l.push(Math.random().toString(36).slice(2)),r&&l.push(Math.floor(99999*Math.random()).toString()),i&&l.push(this._getRandomItem(this.#Et)),"inline"===a&&s&&t.length&&l.push(this._getRandomItem(t)),this._getRandomItem(l)}_generateNaturalSentence(){const{templates:e,nouns:t,verbs:r,adjectives:i}=this.#vt.grammar;return this._getRandomItem(e).replace(/{noun}/g,()=>this._getRandomItem(t)).replace(/{verb}/g,()=>this._getRandomItem(r)).replace(/{adj}/g,()=>this._getRandomItem(i))}_generateLine(e,t){const{allowWeirdSpacing:r,repeatWords:i,readable:s,emojiSet:n,useEmojis:o,emojiPlacement:a,line:l}=this.#vt,u=[];for(t??=new Set;u.join(" ").length<e;){let e=this._generateChunk();!i&&t.has(e)||(t.add(e),r&&(Math.random()<.1&&(e="\n"+e),Math.random()<.1&&(e=" "+e),Math.random()<.05&&(e=e.toUpperCase())),u.push(e))}let h=u.join(s?" ":"");return"end"===a&&o&&n.length&&Math.random()<(l?.emojiChance||0)&&(h+=" "+this._getRandomItem(n)),h}_generateParagraphLines(e){const{line:t}=this.#vt,r=[],i=new Set;let s=0;for(;s<e;){const n=Math.floor(Math.random()*(t.maxLength-t.minLength+1)+t.minLength),o=Math.min(n,e-s);r.push(this._generateLine(o,i)),s+=o}return r}generate(){Gt(this.#h);const{minLength:e,maxLength:t,paragraphs:r}=this.#vt,i=Math.floor(Math.random()*(t-e+1))+e;if(r&&"object"==typeof r){const e=Math.floor(Math.random()*(r.max-r.min+1))+r.min,t=Math.floor(i/e),s=[];for(let r=0;r<e;r++){const e=this._generateParagraphLines(t);s.push(e.join("\n"))}return s.join("\n\n")}return this._generateParagraphLines(i).join("\n")}destroy(){this.destroyed||(this.#Et=[],this.#vt.emojiSet=[],this.#vt.wordSet=[],this.#vt.grammar.templates=[],this.#vt.grammar.nouns=[],this.#vt.grammar.verbs=[],this.#vt.grammar.adjectives=[],this.#h=!0)}}const ir=rr;var sr=r.cjs(function(e,t){var r,i="object"==typeof Reflect?Reflect:null,s=i&&"function"==typeof i.apply?i.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var n=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise(function(r,i){function s(r){e.removeListener(t,n),i(r)}function n(){"function"==typeof e.removeListener&&e.removeListener("error",s),r([].slice.call(arguments))}y(e,t,n,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&y(e,"error",t,{once:!0})}(e,s)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var a=10;function l(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function h(e,t,r,i){var s,n,o,a;if(l(r),void 0===(n=e._events)?(n=e._events=Object.create(null),e._eventsCount=0):(void 0!==n.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),n=e._events),o=n[t]),void 0===o)o=n[t]=r,++e._eventsCount;else if("function"==typeof o?o=n[t]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(s=u(e))>0&&o.length>s&&!o.warned){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=o.length,a=h,console&&console.warn&&console.warn(a)}return e}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},s=c.bind(i);return s.listener=r,i.wrapFn=s,s}function m(e,t,r){var i=e._events;if(void 0===i)return[];var s=i[t];return void 0===s?[]:"function"==typeof s?r?[s.listener||s]:[s]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(s):f(s,s.length)}function p(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function f(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}function y(e,t,r,i){if("function"==typeof e.on)i.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function s(n){i.once&&e.removeEventListener(t,s),r(n)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,n=this._events;if(void 0!==n)i=i&&void 0===n.error;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var l=n[e];if(void 0===l)return!1;if("function"==typeof l)s(l,this,t);else{var u=l.length,h=f(l,u);for(r=0;r<u;++r)s(h[r],this,t)}return!0},o.prototype.addListener=function(e,t){return h(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return h(this,e,t,!0)},o.prototype.once=function(e,t){return l(t),this.on(e,d(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,d(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,i,s,n,o;if(l(t),void 0===(i=this._events))return this;if(void 0===(r=i[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(s=-1,n=r.length-1;n>=0;n--)if(r[n]===t||r[n].listener===t){o=r[n].listener,s=n;break}if(s<0)return this;0===s?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,s),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,o||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,i;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var s,n=Object.keys(r);for(i=0;i<n.length;++i)"removeListener"!==(s=n[i])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},o.prototype.listeners=function(e){return m(this,e,!0)},o.prototype.rawListeners=function(e){return m(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}});const nr=ee("TinySmartScroller");class or extends sr.EventEmitter{static Utils={...s,TinyHtml:It};#Tt=new WeakMap;#St=new WeakMap;#xt=new WeakMap;#At=new WeakMap;#Ct=new WeakMap;#It=new WeakMap;#Mt=null;#Dt=null;#kt=new Set(["IMG","IFRAME","VIDEO"]);#Nt=null;#Lt=!1;#_t=!1;#jt=!1;#Rt=!1;#Pt=!1;#$t=!1;#Ot=!1;#Ht=!1;#Ft="";#Bt=!1;#h=!1;#zt=!1;#Wt=!1;#Vt=!1;#qt=!1;#Kt=0;#Jt=0;#Ut=0;#Gt=0;#Yt=0;#Xt;#Qt;#F;#Zt=new Set;constructor(e,{extraScrollBoundary:t=0,autoScrollBottom:r=!0,observeMutations:i=!0,preserveScrollOnLayoutShift:s=!0,debounceTime:n=100,querySelector:o=null,attributeFilter:a=["class","style","src","data-*","height","width"]}={}){if(super(),!(e instanceof Element||e===window))throw new TypeError("TinySmartScroller: 'target' must be a DOM Element or 'window', but got "+typeof e);if("number"!=typeof t||Number.isNaN(t))throw new TypeError(`TinySmartScroller: 'extraScrollBoundary' must be a valid number, received ${t}`);if("boolean"!=typeof r)throw new TypeError("TinySmartScroller: 'autoScrollBottom' must be a boolean, received "+typeof r);if("boolean"!=typeof i)throw new TypeError("TinySmartScroller: 'observeMutations' must be a boolean, received "+typeof i);if("boolean"!=typeof s)throw new TypeError("TinySmartScroller: 'preserveScrollOnLayoutShift' must be a boolean, received "+typeof s);if("number"!=typeof n||n<0||Number.isNaN(n))throw new TypeError(`TinySmartScroller: 'debounceTime' must be a non-negative number, received ${n}`);if(null!==o&&"string"!=typeof o)throw new TypeError("TinySmartScroller: 'querySelector' must be a string or null, received "+typeof o);if(!(null===a||Array.isArray(a)||a instanceof Set))throw new TypeError("TinySmartScroller: 'attributeFilter' must be an array, Set, or null. Got "+typeof a);let l;this.#F=e,this.#Qt=e instanceof Window?document.documentElement:e,this.#Bt=e instanceof Window,this.#Wt=r,this.#Vt=i,this.#qt=s,this.#Kt=n,this.#Yt=t,this.#Ft=o||"",this.#Xt=new Set(a||void 0),this.#Nt=()=>{this._scrollDataUpdater(),clearTimeout(l),l=setTimeout(()=>this._onScroll(),this.#Kt)},(this.#Bt?window:this.#Qt).addEventListener("scroll",this.#Nt,{passive:!0}),this.#Vt&&(this._observeMutations(),this._observeResizes(this.#Qt.children)),this._scrollDataUpdater()}getSimpleOnHeight(e=[]){if(nr(this.#h),!Array.isArray(e))throw new TypeError("getSimpleOnHeight(filter): filter must be an array of tag names");return(t,r,i)=>{if(e.length>0&&!e.includes(t.tagName)||i.now!==i.old)return;const s=r.old;return{height:r.now.height-s.height,width:0}}}addSimpleOnHeight(e){if(nr(this.#h),!Array.isArray(e))throw new TypeError("addSimpleOnHeight(filter): filter must be an array of tag names");const t=this.getSimpleOnHeight(e);return this.onSize(t),t}getLoadTags(){return nr(this.#h),Array.from(this.#kt)}addLoadTag(e){if(nr(this.#h),"string"!=typeof e)throw new TypeError("addLoadTag(tag): tag must be a string");this.#kt.add(e.toUpperCase())}removeLoadTag(e){if(nr(this.#h),"string"!=typeof e)throw new TypeError("removeLoadTag(tag): tag must be a string");this.#kt.delete(e.toUpperCase())}hasLoadTag(e){if(nr(this.#h),"string"!=typeof e)throw new TypeError("hasLoadTag(tag): tag must be a string");return this.#kt.has(e.toUpperCase())}resetLoadTags(e=!1){if(nr(this.#h),"boolean"!=typeof e)throw new TypeError("resetLoadTags(addDefault): addDefault must be a boolean");this.#kt.clear(),e&&(this.#kt.add("IMG"),this.#kt.add("IFRAME"),this.#kt.add("VIDEO"))}getAttributeFilters(){return nr(this.#h),Array.from(this.#Xt)}addAttributeFilter(e){if(nr(this.#h),"string"!=typeof e)throw new TypeError("addAttributeFilter(attr): attr must be a string");this.#Xt.add(e)}removeAttributeFilter(e){if(nr(this.#h),"string"!=typeof e)throw new TypeError("removeAttributeFilter(attr): attr must be a string");this.#Xt.delete(e)}hasAttributeFilter(e){if(nr(this.#h),"string"!=typeof e)throw new TypeError("hasAttributeFilter(attr): attr must be a string");return this.#Xt.has(e)}resetAttributeFilters(e=!1){if(nr(this.#h),"boolean"!=typeof e)throw new TypeError("resetAttributeFilters(addDefault): addDefault must be a boolean");this.#Xt.clear(),e&&["class","style","src","data-*","height","width"].forEach(e=>this.#Xt.add(e))}onSize(e){if(nr(this.#h),"function"!=typeof e)throw new TypeError("onSize(handler): handler must be a function");this.#Zt.add(e)}offSize(e){if(nr(this.#h),"function"!=typeof e)throw new TypeError("offSize(handler): handler must be a function");this.#Zt.delete(e)}_scrollDataUpdater(){const e=new Map;return this.#Qt.querySelectorAll(this.#Ft||"*").forEach(t=>{const r=this.#xt.get(t)??!1;this.#At.set(t,r);const i=It.isInContainer(this.#Qt,t);this.#xt.set(t,i),e.set(t,{oldIsVisible:r,isVisible:i})}),e}_onScroll(){if(this.#h)return;const e=this._scrollDataUpdater(),t=this.#Qt,r=t.scrollTop,i=t.scrollHeight,s=t.clientHeight,n={scrollTop:r,scrollHeight:i,clientHeight:s};let o=null,a=null;const l=0===r,u=r+s>=i-1,h=r<=0+this.#Yt,c=r+s>=i-1-this.#Yt;l&&u?o="all":l?o="top":u&&(o="bottom"),h&&c?a="all":h?a="top":c&&(a="bottom"),this.#_t=this.#$t??!1,this.#Lt=this.#Pt??!1,this.#jt=this.#Ot??!1,this.#Rt=this.#Ht??!1,this.#$t=l,this.#Pt=u,this.#Ot=h,this.#Ht=c,this.#zt=!(this.#Wt&&this.#Pt),this.#Gt=i-r-s,this.emit("onScrollBoundary",{status:o,...n,scrollCache:e}),this.emit("onExtraScrollBoundary",{status:a,...n,scrollCache:e}),this.#zt?this.emit("onScrollPause",{...n,scrollCache:e}):this.emit("onAutoScroll",{...n,scrollCache:e})}_fixScroll(e=[]){if(this.#h)return;if(!Array.isArray(e))throw new TypeError("_fixScroll: targets must be an array of Elements");const t=this.#Qt.scrollHeight,r=this.#Qt.scrollTop,i=this.#Qt.scrollHeight-this.#Qt.scrollTop-this.#Qt.clientHeight,s=this.#Qt.scrollHeight-t,n=()=>{const t={height:0,width:0};for(const r of e){const e=this.#Tt.get(r)||{height:0,width:0},i=this.#St.get(r)||{height:0,width:0};this.#Zt.forEach(s=>{const n=s(r,{old:e,now:i},{old:this.#Ut,now:this.#Jt});if(this.#xt.get(r)||this.#Ct.get(r)){if(void 0!==n&&"object"!=typeof n)throw new Error("_fixScroll: size filter must return an object or undefined");if(void 0===n)return;t.height=n.height,t.width=n.width}})}if("number"!=typeof t.height&&t.height<0)throw new Error("_fixScroll: invalid scrollSize.height value");if("number"!=typeof t.width&&t.width<0)throw new Error("_fixScroll: invalid scrollSize.width value");if(0!==t.height||0!==t.width)for(const t of e)this.#Ct.set(t,this.#xt.get(t)??!1),this.#It.set(t,this.#At.get(t)??!1);return t};if(this.#Ut>0&&It.hasScroll(this.#Qt).v&&this.#Wt&&this.#qt&&!this.#Pt&&!this.#$t){const e=n();this.#Qt.scrollTop=r+s+e.height,e.width>0&&(this.#Qt.scrollLeft=this.#Qt.scrollLeft+e.width)}else!this.#zt&&this.#Wt?(n(),this.scrollToBottom()):this.#Wt||this.#Pt||(n(),this.#Qt.scrollTop=this.#Qt.scrollHeight-this.#Qt.clientHeight-i)}_observeMutations(){this.#Dt=new MutationObserver(e=>{this.#h||(this._scrollDataUpdater(),this.#Ut=this.#Jt,this.#Jt=this.#Qt.childElementCount,e.forEach(e=>{e.addedNodes.forEach(e=>{if(e instanceof Element&&1===e.nodeType&&(this._observeResizes([e]),this._listenLoadEvents(e),this.#Ft)){const t=e.querySelectorAll(this.#Ft);this._observeResizes(t),this._listenLoadEvents(t)}})}),this._fixScroll())}),this.#Dt.observe(this.#Qt,{childList:!0,subtree:!0,attributes:!0,attributeFilter:this.#Xt.size>0?Array.from(this.#Xt):void 0})}_observeResizes(e){this.#Mt||(this.#Mt=new ResizeObserver(e=>{if(this.#h)return;this._scrollDataUpdater();const t=[];for(const r of e){const e=r.target,i=this.#St.get(e);i&&this.#Tt.set(e,i);const{width:s,height:n}=r.contentRect;this.#St.set(e,{width:s,height:n}),t.push(e)}this._fixScroll(t)})),Array.from(e).forEach(e=>{if(!this.#Mt)throw new Error("_observeResizes: ResizeObserver instance is not initialized");this.#Mt.observe(e)})}_listenLoadEvents(e){this.#h||(e instanceof NodeList?Array.from(e):[e]).forEach(e=>{this.#kt.has(e.tagName)&&(e.complete||e.addEventListener("load",()=>{this._scrollDataUpdater(),!this.#zt&&this.#Wt&&this.scrollToBottom()}))})}get target(){return this.#F}get targetElement(){return this.#Qt}getOldSize(e){return nr(this.#h),this.#Tt.get(e)??null}getNewSize(e){return nr(this.#h),this.#St.get(e)??null}wasVisible(e){return nr(this.#h),this.#At.get(e)??!1}isVisible(e){return nr(this.#h),this.#xt.get(e)??!1}wasTimedVisible(e){return nr(this.#h),this.#It.get(e)??!1}isTimedVisible(e){return nr(this.#h),this.#Ct.get(e)??!1}setExtraScrollBoundary(e){if(nr(this.#h),"number"!=typeof e||Number.isNaN(e))throw new TypeError("setExtraScrollBoundary(value): value must be a valid number");this.#Yt=e}getExtraScrollBoundary(){return nr(this.#h),this.#Yt}getLastKnownScrollBottomOffset(){return nr(this.#h),this.#Gt}scrollToBottom(){nr(this.#h),this.#Qt.scrollTop=this.#Qt.scrollHeight}scrollToTop(){nr(this.#h),this.#Qt.scrollTop=0}isAtCustomBottom(){return nr(this.#h),this.#Ht}isAtCustomTop(){return nr(this.#h),this.#Ot}isAtBottom(){return nr(this.#h),this.#Pt}isAtTop(){return nr(this.#h),this.#$t}isPastAtBottom(){return nr(this.#h),this.#Lt}isPastAtTop(){return nr(this.#h),this.#_t}isPastAtCustomTop(){return nr(this.#h),this.#jt}isPastAtCustomBottom(){return nr(this.#h),this.#Rt}isScrollPaused(){return nr(this.#h),this.#zt}isWindow(){return nr(this.#h),this.#Bt}isDestroyed(){return this.#h}getAutoScrollBottom(){return nr(this.#h),this.#Wt}getObserveMutations(){return nr(this.#h),this.#Vt}getPreserveScrollOnLayoutShift(){return nr(this.#h),this.#qt}getDebounceTime(){return nr(this.#h),this.#Kt}getElemAmount(){return nr(this.#h),this.#Jt}getPrevElemAmount(){return nr(this.#h),this.#Ut}getQuerySelector(){return nr(this.#h),this.#Ft}destroy(){if(this.#h)return;this.#Dt&&(this.#Dt.disconnect(),this.#Dt=null),this.#Mt&&(this.#Mt.disconnect(),this.#Mt=null);const e=this.#Bt?window:this.#Qt;this.#Nt&&e.removeEventListener("scroll",this.#Nt),this.#Tt=new WeakMap,this.#St=new WeakMap,this.#xt=new WeakMap,this.#At=new WeakMap,this.#Ct=new WeakMap,this.#It=new WeakMap,this.removeAllListeners(),this.#Zt.clear(),this.#kt.clear(),this.#h=!0}}const ar=or,lr=class{#G;#er;#tr;constructor(e,{openTag:t="[",closeTag:r="]"}={}){if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new TypeError("Element must be an input or textarea.");if("string"!=typeof t)throw new TypeError("openTag must be a string.");if("string"!=typeof r)throw new TypeError("closeTag must be a string.");this.#G=e,this.#er=t,this.#tr=r}getOpenTag(){return this.#er}getCloseTag(){return this.#tr}setOpenTag(e){if("string"!=typeof e)throw new TypeError("Open tag must be a string.");this.#er=e}setCloseTag(e){if("string"!=typeof e)throw new TypeError("Close tag must be a string.");this.#tr=e}ensureFocus(){return document.activeElement!==this.#G&&this.#G.focus(),this}focus(){return this.#G.focus(),this}getSelectionRange(){return{start:this.#G.selectionStart??NaN,end:this.#G.selectionEnd??NaN}}setSelectionRange(e,t,r=!0){if("number"!=typeof e||"number"!=typeof t)throw new TypeError("start and end must be numbers.");if("boolean"!=typeof r)throw new TypeError("preserveScroll must be a boolean.");const i=this.#G.scrollTop,s=this.#G.scrollLeft;return this.#G.setSelectionRange(e,t),r&&(this.#G.scrollTop=i,this.#G.scrollLeft=s),this}getValue(){return this.#G.value}setValue(e){if("string"!=typeof e)throw new TypeError("Value must be a string.");return this.#G.value=e,this}getSelectedText(){const{start:e,end:t}=this.getSelectionRange();return this.#G.value.slice(e,t)}insertText(e,{newCursor:t="end",autoSpacing:r=!1,autoSpaceLeft:i=r,autoSpaceRight:s=r}={}){if("string"!=typeof e)throw new TypeError("Text must be a string.");if(!["start","end","preserve"].includes(t))throw new TypeError("newCursor must be one of 'start', 'end', or 'preserve'.");if("boolean"!=typeof r)throw new TypeError("autoSpacing must be a boolean.");if("boolean"!=typeof i)throw new TypeError("autoSpaceLeft must be a boolean.");if("boolean"!=typeof s)throw new TypeError("autoSpaceRight must be a boolean.");const{start:n,end:o}=this.getSelectionRange(),a=this.#G.value,l=a[n-1]||"",u=a[o]||"",h=`${i&&l&&!/\s/.test(l)?" ":""}${e}${s&&u&&!/\s/.test(u)?" ":""}`,c=a.slice(0,n)+h+a.slice(o);this.setValue(c);let d=n;return"end"===t?d=n+h.length:"preserve"===t&&(d=n),this.setSelectionRange(d,d),this}deleteSelection(){return this.insertText(""),this}transformSelection(e){if("function"!=typeof e)throw new TypeError("transformer must be a function.");const{start:t}=this.getSelectionRange(),r=e(this.getSelectedText());return this.insertText(r),this.setSelectionRange(t,t+r.length),this}surroundSelection(e,t){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("prefix and suffix must be strings.");const r=this.getSelectedText();return this.insertText(`${e}${r}${t}`),this}moveCaret(e){if("number"!=typeof e)throw new TypeError("offset must be a number.");const{start:t}=this.getSelectionRange(),r=Math.max(0,t+e);return this.setSelectionRange(r,r),this}selectAll(){return this.setSelectionRange(0,this.#G.value.length),this}expandSelection(e,t){if("number"!=typeof e||"number"!=typeof t)throw new TypeError("before and after must be numbers.");const{start:r,end:i}=this.getSelectionRange(),s=Math.max(0,r-e),n=Math.min(this.#G.value.length,i+t);return this.setSelectionRange(s,n),this}replaceAll(e,t){if(!(e instanceof RegExp))throw new TypeError("regex must be a RegExp.");if("function"!=typeof t)throw new TypeError("replacer must be a function.");const r=this.#G.value.replace(e,t);return this.setValue(r),this}replaceInSelection(e,t){if(!(e instanceof RegExp))throw new TypeError("regex must be a RegExp.");if("function"!=typeof t)throw new TypeError("replacer must be a function.");const{start:r,end:i}=this.getSelectionRange(),s=this.#G.value,n=s.slice(r,i).replace(e,t),o=s.slice(0,r)+n+s.slice(i);return this.setValue(o),this.setSelectionRange(r,r+n.length),this}toggleCode(e){if("string"!=typeof e)throw new TypeError("codeName must be a string.");const t=this.getSelectedText();if(t.startsWith(e)&&t.endsWith(e)){const r=t.slice(e.length,t.length-e.length);this.insertText(r)}else this.insertText(`${e}${t}${e}`);return this}_insertAttr(e){let t="";if(Array.isArray(e)){if(!e.every(e=>"string"==typeof e))throw new TypeError("All entries in attributes array must be strings.");t=e.map(e=>`${e}`).join(" ")}else{if("object"!=typeof e||null===e)throw new TypeError("attributes must be an object or an array of strings.");t=Object.entries(e).map(([e,t])=>{if("string"!=typeof t)throw new TypeError("All entries in attributes object must be strings.");return`${e}${t.length>0?`="${t}"`:""}`}).join(" ")}return t}wrapWithTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this._insertAttr(t),i=r?`${this.#er}${e} ${r}${this.#tr}`:`${this.#er}${e}${this.#tr}`,s=`${this.#er}/${e}${this.#tr}`;return this.surroundSelection(i,s),this}insertTag(e,t="",r={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");if("string"!=typeof t)throw new TypeError("content must be a string.");const i=this._insertAttr(r),s=i?`${this.#er}${e} ${i}${this.#tr}`:`${this.#er}${e}${this.#tr}`,n=`${this.#er}/${e}${this.#tr}`;return this.insertText(`${s}${t}${n}`),this}insertSelfClosingTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this._insertAttr(t),i=r?`${this.#er}${e} ${r}${this.#tr}`:`${this.#er}${e}${this.#tr}`;return this.insertText(i),this}toggleTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this.getSelectedText(),i=new RegExp(`^\\[${e}(\\s+[^\\]]*)?\\]`),s=new RegExp(`\\[/${e}\\]$`),n=i.test(r),o=s.test(r);if(n&&o){const e=r.replace(i,"").replace(s,"");this.insertText(e)}else{const i=this._insertAttr(t),s=i?`${this.#er}${e} ${i}${this.#tr}`:`${this.#er}${e}${this.#tr}`,n=`${this.#er}/${e}${this.#tr}`;this.insertText(`${s}${r}${n}`)}return this}},ur=class{#rr=!1;#ir=!1;#sr=null;#nr=null;constructor(){void 0!==navigator.clipboard&&null!==navigator.clipboard&&(this.#ir=!0,this.#sr=e=>navigator.clipboard.writeText(e),this.#nr=e=>navigator.clipboard.write([new ClipboardItem({[e.type]:e})])),this.#rr=void 0!==document.execCommand&&null!==document.execCommand}setCopyText(e){if("function"!=typeof e)throw new TypeError("setCopyText expected a function that returns Promise<void>.");this.#sr=e}setCopyBlob(e){if("function"!=typeof e)throw new TypeError("setCopyBlob expected a function that returns Promise<void>.");this.#nr=e}copyText(e){if("string"!=typeof e)throw new TypeError("copyText expected a string.");if(this.#sr)return this.#sr(e);if(this.#rr){const t=document.body,r=document.createElement("input");return r.style.position="fixed",r.style.opacity="0",r.value=e,t.append(r),r.select(),r.setSelectionRange(0,99999),document.execCommand("Copy"),r.remove(),new Promise(e=>e(void 0))}throw new Error("Clipboard API not found!")}copyBlob(e){if(!(e instanceof Blob))throw new TypeError("copyBlob expected a Blob instance.");return new Promise((t,r)=>{if(this.#nr)return this.#nr(e).then(t).catch(r);throw new Error("Clipboard API not found!")})}_handleBlob(e,t){return t.getType(e)}_handleText(e,t){return this._handleBlob(e,t).then(e=>e.text())}_readData(e=0,t=null,r=null,i=!1){return new Promise((s,n)=>{this._read(e).then(o=>{if(!o)return s(null);const a=[];let l=!0;const u=async(e,s)=>{if(l)if(null!==t&&"custom"!==t||"string"!=typeof r||!(!i&&e.startsWith(r)||i&&e===r))if(null!==t&&"text"!==t||"text/plain"!==e){if(null===t){l=!1;const t=await this._handleBlob(e,s);t&&a.push(t)}}else{l=!1;const t=await this._handleText(e,s);t&&a.push(t)}else{l=!1;const t=await this._handleBlob(e,s);t&&a.push(t)}},h=[],c=e=>{if(!(e instanceof ClipboardItem))throw new Error("Expected ClipboardItem when reading data.");for(const t in e.types)h.push(u(e.types[t],e))};if("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)&&e>-1)c(o),Promise.all(h).then(()=>{a[0]?s(a[0]):s(null)}).catch(n);else if(Array.isArray(o)){for(const e in o)c(o[e]);Promise.all(h).then(()=>s(a)).catch(n)}}).catch(n)})}async readText(e=0){const t=await this._readData(e,"text");if("string"!=typeof t)throw new Error("Failed to read text: expected string result.");return t}async readCustom(e=null,t=!1,r=0){const i=await this._readData(r,"custom",e,t);if(!(i instanceof Blob))throw new Error("Failed to read custom data: expected Blob.");return i}async readAllTexts(){const e=await this._readData(null,"text");if(!Array.isArray(e))throw new Error("Expected array of strings when reading all texts.");if(!e.every(e=>"string"==typeof e))throw new Error("Some values returned were not strings.");return e}async readAllCustom(e=null,t=!1){const r=await this._readData(null,"custom",e,t);if(!Array.isArray(r))throw new Error("Expected array of blobs when reading all custom items.");if(!r.every(e=>e instanceof Blob))throw new Error("Some values returned were not Blob instances.");return r}async readAllData(e=null,t=null){const r=await this._readData(null,e,t);if(!Array.isArray(r))throw new Error("Expected array result when reading all data.");return r}_read(e){return new Promise((t,r)=>{this.#ir||r(new Error("Clipboard API not found!")),navigator.clipboard.read().then(r=>{if("number"==typeof e){if(Number.isNaN(e)||!Number.isFinite(e)||e<0)throw new Error(`Invalid index value: ${e}`);r[e]?t(r[e]):t(null)}t(r)}).catch(r)})}async readIndex(e){const t=await this._read(e);if(null!==t&&!(t instanceof ClipboardItem))throw new Error(`Value at index ${e} is not a ClipboardItem.`);return t}async readAll(){const e=await this._read(null);if(!Array.isArray(e))throw new Error("Expected array result from clipboard read.");for(const t of e)if(!(t instanceof ClipboardItem))throw new Error("Invalid item type found in clipboard result.");return e}isExecCommandAvailable(){return this.#rr}isNavigatorClipboardAvailable(){return this.#ir}getCopyTextFunc(){return this.#sr}getCopyBlobFunc(){return this.#nr}};class hr{static _rca(e,t,r){let i=127,s=128;void 0===e&&(e=24),void 0===t&&(t="rgb"),!0===r&&(i=55,s=200);const n=2*Math.PI/e,o=[];for(let r=0;r<e;++r){const e=Math.sin(n*r+2)*i+s,a=Math.sin(n*r+0)*i+s,l=Math.sin(n*r+4)*i+s;switch(t){case"hex":o.push({hex:this.rgbToHex(Math.round(e),Math.round(a),Math.round(l))});break;case"rgb":o.push({r:e,g:a,b:l});break;case"hsl":const[t,r,i]=this.rgbaToHsl(Math.round(e),Math.round(a),Math.round(l));o.push({h:t,s:r,l:i})}}return o}static rcaRgb(e,t){return hr._rca(e,"rgb",t)}static rcaHsl(e,t){return hr._rca(e,"hsl",t)}static rcaHex(e,t){return hr._rca(e,"hex",t)}static randomColor(){return`#${Math.floor(16777216*Math.random()).toString(16).padStart(6,"0")}`}static parseInput(e,t){if("string"==typeof e){if((e=e.trim().toLowerCase()).startsWith("#"))return this.hexToRgba(e);if(e.startsWith("rgb"))return this.rgbStringToRgbaArray(e);if(e.startsWith("hsl"))return this.hslStringToRgbaArray(e)}if("number"==typeof e)return this.intToRgba(e);if(Array.isArray(e)&&(3===e.length||4===e.length)&&e.every(e=>"number"==typeof e)){if(t){const[t,r,i,s]=e;if(t<=360&&r<=100&&i<=100)return this.hslToRgba(t,r,i,s)}return[...e,1].slice(0,4)}throw new Error("Unsupported color format.")}static hslToInt(e,t,r){const[i,s,n]=hr.hslToRgba(e,t,r);return hr.rgbToInt(i,s,n)}static hslToHex(e,t,r){const[i,s,n]=hr.hslToRgba(e,t,r);return hr.rgbToHex(i,s,n)}static hslStringToRgbaArray(e){const t=e.match(/[\d.]+/g)?.map(Number);if(!t||t.length<3)return[0,0,0,1];const[r,i,s,n=1]=t;return this.hslToRgba(r,i,s,n)}static hslToRgba(e,t,r,i=1){r/=100;const s=t=>(t+e/30)%12,n=(t/=100)*Math.min(r,1-r),o=e=>r-n*Math.max(-1,Math.min(s(e)-3,Math.min(9-s(e),1)));return[Math.round(255*o(0)),Math.round(255*o(8)),Math.round(255*o(4)),i]}static hslToRgb(e,t,r,i=1){return hr.hslToRgba(e,t,r,i).slice(0,3)}static hexToInt(e){return parseInt(e.replace(/^#/,""),16)}static hexToHsl(e){const[t,r,i,s]=hr.hexToRgba(e);return hr.rgbaToHsl(t,r,i,s)}static hexToHsla(e){const[t,r,i,s]=hr.hexToRgba(e);return hr.rgbaToHsla(t,r,i,s)}static hexToRgba(e){3===(e=e.replace(/^#/,"")).length&&(e=e.split("").map(e=>e+e).join(""));const t=parseInt(e,16);return[t>>16&255,t>>8&255,255&t,1]}static hexToRgb(e){return this.hexToRgba(e).slice(0,3)}static rgbToHex(e,t,r){return"#"+[e,t,r].map(e=>e.toString(16).padStart(2,"0")).join("")}static rgbToInt(e,t,r){return e<<16|t<<8|r}static rgbaToHsla(e,t,r,i=1){e/=255,t/=255,r/=255;const s=Math.max(e,t,r),n=Math.min(e,t,r);let o=0,a=0,l=(s+n)/2;const u=s-n;if(0!==u){switch(a=u/(1-Math.abs(2*l-1)),s){case e:o=(t-r)/u+(t<r?6:0);break;case t:o=(r-e)/u+2;break;case r:o=(e-t)/u+4}o*=60}return[Math.round(o),Math.round(100*a),Math.round(100*l),i]}static rgbaToHsl(e,t,r,i){return this.rgbaToHsla(e,t,r,i).slice(0,3)}static rgbStringToRgbaArray(e){const t=e.match(/[\d.]+/g)?.map(Number);return t?[...t,1].slice(0,4):[]}static intToHsl(e){const[t,r,i,s]=hr.intToRgba(e);return hr.rgbaToHsl(t,r,i,s)}static intToHsla(e){const[t,r,i,s]=hr.intToRgba(e);return hr.rgbaToHsla(t,r,i,s)}static intToHex(e){return"#"+e.toString(16).padStart(6,"0")}static intToRgba(e){return[e>>16&255,e>>8&255,255&e,1]}#or="#000000";#ar=[0,0,0,0];#lr;constructor(e=null,t=!1){this.#lr=t,null!=e&&this.setColor(e)}setColor(e){this.#or=e;const t=this.#lr&&Array.isArray(e)&&e[0]<=360&&e[1]<=100&&e[2]<=100;this.#ar=hr.parseInput(e,t)}toHslaArray(){const[e,t,r,i]=this.#ar;return hr.rgbaToHsla(e,t,r,i)}toHslString(){const[e,t,r]=this.#ar,[i,s,n]=hr.rgbaToHsl(e,t,r);return`hsl(${i}, ${s}%, ${n}%)`}toHslaString(){const[e,t,r,i]=this.#ar,[s,n,o,a]=hr.rgbaToHsla(e,t,r,i);return`hsla(${s}, ${n}%, ${o}%, ${a??1})`}toRgbaArray(){return[...this.#ar]}toRgbString(){const[e,t,r]=this.#ar;return`rgb(${e}, ${t}, ${r})`}toRgbaString(){const[e,t,r,i]=this.#ar;return`rgba(${e}, ${t}, ${r}, ${i??1})`}toHex(){const[e,t,r]=this.#ar;return hr.rgbToHex(e,t,r)}toInt(){const[e,t,r]=this.#ar;return hr.rgbToInt(e,t,r)}getOriginal(){return this.#or}}const cr=hr,dr=(e,t=100)=>{if("function"!=typeof e)throw new TypeError("Expected 'getValue' to be a function.");if(!Number.isFinite(t)||t<=0)throw new TypeError("Expected 'checkInterval' to be a positive number.");return new Promise(r=>{const i=setInterval(()=>{e()&&(clearInterval(i),r())},t)})},mr=e=>{if("function"!=typeof e)throw new TypeError('The argument "baseFunction" must be a function.');let t=null;return{callback:async(...r)=>(null!==t||(t=(async()=>{try{const i=await e(...r);return t=null,i}catch(e){throw t=null,e}})()),t),getActivePromise:()=>t,resetActivePromise:()=>{t=null}}},pr=ee("TinyTimeout"),fr=class{#ur=!1;#hr;#cr;#dr=null;#mr=new Map;constructor({cooldownWatcherTime:e=5e3,allowAutoConfigChange:t=!1}={}){if(!Number.isFinite(e)||e<=0)throw new TypeError("Expected 'cooldownWatcherTime' to be a positive number.");if("boolean"!=typeof t)throw new TypeError("Expected 'allowAutoConfigChange' to be a boolean.");this.#cr=e,this.#hr=t,this.setCooldownWatcherTime(e)}isDestroyed(){return this.#ur}getAllowAutoConfigChange(){return pr(this.#ur),this.#hr}getCooldownWatcherTime(){return pr(this.#ur),this.#cr}setAllowAutoConfigChange(e){if(pr(this.#ur),"boolean"!=typeof e)throw new TypeError("Expected 'value' to be a boolean.");this.#hr=e}setCooldownWatcherTime(e){if(pr(this.#ur),this.#ur)throw new Error("TinyTimeout has been destroyed.");if(!Number.isFinite(e)||e<=0)throw new TypeError("Expected 'value' to be a positive number.");this.#cr=e,this.#dr&&clearInterval(this.#dr),this.#dr=setInterval(()=>{this.#mr.forEach(e=>{e.now>0&&e.now--})},this.#cr)}set(e,t,r,i=null){if(pr(this.#ur),this.#ur)throw new Error("TinyTimeout has been destroyed.");if("string"!=typeof e||""===e.trim())throw new TypeError("Expected 'id' to be a non-empty string.");if("function"!=typeof t)throw new TypeError("Expected 'callback' to be a function.");if(!Number.isFinite(r)||r<0)throw new TypeError("Expected 'value' to be a non-negative number.");if(null!==i&&(!Number.isFinite(i)||i<0))throw new TypeError("Expected 'limit' to be null or a non-negative number.");let s=this.#mr.get(e);(!s||this.#hr&&r!==s.value)&&(s={value:r,now:0},this.#mr.set(e,s));const n=s.value*s.now;return s.now++,setTimeout(t,"number"==typeof i?Math.min(n,i):n)}static waitForTrue(e,t=100){return dr(e,t)}waitForTrue(e,t=100){if(pr(this.#ur),this.#ur)throw new Error("TinyTimeout has been destroyed.");if("function"!=typeof e)throw new TypeError("Expected 'getValue' to be a function.");if(null!==t&&(!Number.isFinite(t)||t<=0))throw new TypeError("Expected 'checkInterval' to be null or a positive number.");return dr(e,t??this.#cr)}destroy(){this.#ur||(this.#dr&&clearInterval(this.#dr),this.#dr=null,this.#mr.clear(),this.#ur=!0)}},yr=ee("TinyLocalStorage"),gr=new Map,br=new Map,wr=new Set(["string","boolean","object","array",String,Boolean,Number,Object,Array,BigInt,Symbol]);class vr extends sr.EventEmitter{static hasJsonType(e){return gr.has(e)&&br.has(e)||wr.has(e)}static registerJsonType(e,t,r,i=!1){if(wr.has(e))throw new Error(`Cannot register type "${e}" because it is frozen.`);gr.set(e,t),br.set(e,r),i&&wr.add(e)}static deleteJsonType(e){if(wr.has(e))throw new Error(`Cannot remove type "${e}" because it is frozen.`);let t=!1;return gr.delete(e)&&(t=!0),br.delete(e)&&(t=!0),t}static encodeSpecialJson(e){if(void 0===e)return{__undefined__:!0};if(null===e)return{__null__:!0};for(const[t,r]of gr.entries())if("string"!=typeof t&&e instanceof t||typeof e===t)return r(e,vr.encodeSpecialJson);if(Array.isArray(e))return e.map(vr.encodeSpecialJson);if(g(e)){const t={};for(const r in e)t[r]=vr.encodeSpecialJson(e[r]);return t}return e}static decodeSpecialJson(e){const t=g(e);if(t){if(e.__undefined__)return;if(e.__null__)return null}if(Array.isArray(e))return e.map(vr.decodeSpecialJson);if(t){for(const[t,r]of br.entries())if(r.check&&r.check(e))return r.decode(e,vr.decodeSpecialJson);const t={};for(const r in e)t[r]=vr.decodeSpecialJson(e[r]);return t}return e}#h=!1;get destroyed(){return this.#h}#pr=window.localStorage;#fr=null;#ee=0;#yr=e=>this.emit("storage",e);constructor(e){if(super(),void 0!==e&&"string"!=typeof e)throw new TypeError("TinyLocalStorage: dbName must be a string if provided.");"string"==typeof e&&(this.#fr=`LSDB::${e}`),window.addEventListener("storage",this.#yr)}#gr(e){if("string"==typeof e&&e.startsWith("LSDB::"))throw new Error(`TinyLocalStorage: Key "${e}" may conflict with reserved dbKeys.`)}updateStorageVersion(e,t){if(yr(this.#h),"string"!=typeof this.#fr)throw new Error("TinyLocalStorage: Database key is not initialized. Set a valid dbName in the constructor.");if("number"!=typeof e||Number.isNaN(e)||e<1)throw new TypeError("TinyLocalStorage: version must be a positive number.");if("function"!=typeof t)throw new TypeError("TinyLocalStorage: onUpgrade must be a function.");const r=parseInt(localStorage.getItem(this.#fr),10)||0;if("number"!=typeof r||Number.isNaN(r)||r<0)throw new TypeError("TinyLocalStorage: saved version in localStorage is not a valid number.");if(e<r)throw new Error(`TinyLocalStorage: Cannot downgrade database version from ${r} to ${e}.`);e>r&&(t(r,e),localStorage.setItem(this.#fr,String(e)),this.#ee=e)}getDbKey(){return yr(this.#h),this.#fr}getVersion(){return yr(this.#h),this.#ee}setLocalStorage(e){if(yr(this.#h),!(e instanceof Storage))throw new TypeError("Argument must be a valid instance of Storage.");this.#pr=e}localStorageExists(){return yr(this.#h),this.#pr instanceof Storage}#br(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return vr.encodeSpecialJson(t)}setJson(e,t){if(yr(this.#h),this.#gr(e),!(g(t)||Array.isArray(t)||t instanceof Map||t instanceof Set))throw new TypeError("The storage value is not a valid JSON-compatible structure.");const r=this.#br(e,t);return this.emit("setJson",e,t),this.#pr.setItem(e,JSON.stringify(r))}#wr(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const r=this.#pr.getItem(e),i={obj:()=>({}),array:()=>[],map:()=>new Map,set:()=>new Set},s="function"==typeof i[t]?i[t]():null;let n;try{n=JSON.parse(r)}catch{return s}return{decoded:vr.decodeSpecialJson(n),fallback:s}}getJson(e,t){yr(this.#h);const{decoded:r,fallback:i}=this.#wr(e,t);return r instanceof Map||r instanceof Set||Array.isArray(r)||g(r)?r:i}setDate(e,t){if(yr(this.#h),this.#gr(e),!(t instanceof Date))throw new TypeError("Value must be a Date.");const r=this.#br(e,t);return this.emit("setDate",e,t),this.#pr.setItem(e,JSON.stringify(r))}getDate(e){yr(this.#h);const t=this.#wr(e).decoded;return t instanceof Date?t:null}setRegExp(e,t){if(yr(this.#h),this.#gr(e),!(t instanceof RegExp))throw new TypeError("Value must be a RegExp.");const r=this.#br(e,t);return this.emit("setRegExp",e,t),this.#pr.setItem(e,JSON.stringify(r))}getRegExp(e){yr(this.#h);const t=this.#wr(e).decoded;return t instanceof RegExp?t:null}setBigInt(e,t){if(yr(this.#h),this.#gr(e),"bigint"!=typeof t)throw new TypeError("Value must be a BigInt.");const r=this.#br(e,t);return this.emit("setBigInt",e,t),this.#pr.setItem(e,JSON.stringify(r))}getBigInt(e){yr(this.#h);const t=this.#wr(e).decoded;return"bigint"==typeof t?t:null}setSymbol(e,t){if(yr(this.#h),this.#gr(e),"symbol"!=typeof t)throw new TypeError("Value must be a Symbol.");const r=this.#br(e,t);return this.emit("setSymbol",e,t),this.#pr.setItem(e,JSON.stringify(r))}getSymbol(e){yr(this.#h);const t=this.#wr(e).decoded;return"symbol"==typeof t?t:null}getValue(e){return yr(this.#h),this.#wr(e).decoded??null}setItem(e,t){if(yr(this.#h),this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("setItem",e,t),this.#pr.setItem(e,t)}getItem(e){if(yr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.#pr.getItem(e)}setString(e,t){if(yr(this.#h),this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("string"!=typeof t)throw new TypeError("Value must be a string.");return this.emit("setString",e,t),this.#pr.setItem(e,JSON.stringify({__string__:!0,value:t}))}getString(e){if(yr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#pr.getItem(e);try{if(t=JSON.parse(t),!g(t)||!t.__string__||"string"!=typeof t.value)return null;t=t.value}catch{t=null}return"string"==typeof t?t:null}setNumber(e,t){if(yr(this.#h),this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("number"!=typeof t)throw new TypeError("Value must be a number.");return this.emit("setNumber",e,t),this.#pr.setItem(e,String(t))}getNumber(e){if(yr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#pr.getItem(e);return"number"==typeof t||"string"==typeof t&&t.length>0&&(t=parseFloat(t),!Number.isNaN(t))?t:null}setBool(e,t){if(yr(this.#h),this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("boolean"!=typeof t)throw new TypeError("Value must be a boolean.");return this.emit("setBool",e,t),this.#pr.setItem(e,String(t))}getBool(e){if(yr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const t=this.#pr.getItem(e);if("boolean"==typeof t)return t;if("string"==typeof t){if("true"===t)return!0;if("false"===t)return!1}return null}removeItem(e){if(yr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("removeItem",e),this.#pr.removeItem(e)}clearLocalStorage(){return yr(this.#h),this.#pr.clear()}destroy(){this.#h||(window.removeEventListener("storage",this.#yr),this.removeAllListeners(),this.#h=!0)}}vr.registerJsonType(Map,(e,t)=>({__map__:!0,data:Array.from(e.entries()).map(([e,r])=>[e,t(r)])}),{check:e=>e.__map__,decode:(e,t)=>new Map(e.data.map(([e,r])=>[e,t(r)]))},!0),vr.registerJsonType(Set,(e,t)=>({__set__:!0,data:Array.from(e).map(t)}),{check:e=>e.__set__,decode:(e,t)=>new Set(e.data.map(t))},!0),vr.registerJsonType(Date,e=>({__date__:!0,value:e.toISOString()}),{check:e=>e.__date__,decode:e=>new Date(e.value)},!0),vr.registerJsonType(RegExp,e=>({__regexp__:!0,source:e.source,flags:e.flags}),{check:e=>e.__regexp__,decode:e=>new RegExp(e.source,e.flags)},!0),vr.registerJsonType("number",e=>({__number__:!0,value:e.toString()}),{check:e=>e.__number__,decode:e=>Number(e.value)},!0),vr.registerJsonType("bigint",e=>({__bigint__:!0,value:e.toString()}),{check:e=>e.__bigint__,decode:e=>BigInt(e.value)},!0),vr.registerJsonType("symbol",e=>({__symbol__:!0,key:Symbol.keyFor(e)??e.description??null}),{check:e=>e.__symbol__,decode:e=>{const t=e.key;return null!=t?Symbol.for(t):Symbol()}},!0);const Er=vr,Tr=ee("TinyIframeEvents"),Sr=new WeakMap;class xr extends sr.EventEmitter{#vr;get targetWindow(){return Tr(this.#ur),this.#vr}#Er;get targetIframeElement(){return Tr(this.#ur),this.#Er}#Tr;get targetOrigin(){return Tr(this.#ur),this.#Tr}#Sr;get selfType(){return Tr(this.#ur),this.#Sr}#ur=!1;#xr=!1;get ready(){return Tr(this.#ur),this.#xr}onReady(e){Tr(this.#ur),this.#xr?e():this.once(this.#Ar,e)}#Cr=null;#Ir=[];#Mr;#Dr;#Ar;#kr=null;constructor({targetIframe:e,targetOrigin:t=window.location.origin,secretEventName:r="__tinyIframeEvent__",handshakeEventName:i="__tinyIframeHandshake__",readyEventName:s="__tinyIframeReady__"}={}){if(super(),!(void 0===e||e instanceof HTMLIFrameElement&&e.contentWindow))throw new TypeError('[TinyIframeEvents] Invalid "targetIframe": expected HTMLIFrameElement, received '+typeof e);if("string"!=typeof t)throw new TypeError('[TinyIframeEvents] Invalid "targetOrigin": expected string, received '+typeof t);if(this.#Er=e,this.#vr=e?.contentWindow??window.parent,this.#Tr=t,this.#Sr=e?"parent":"iframe",this.#Mr=r,this.#Dr=i,this.#Ar=s,Sr.has(this.#vr))throw new Error("Duplicate window reference.");this._boundWindowMessage=this.#Nr.bind(this),this._boundPortMessage=this.#Lr.bind(this),this.#_r(),Sr.set(this.#vr,this)}get secretEventName(){return Tr(this.#ur),this.#Mr}set secretEventName(e){if(Tr(this.#ur),"string"!=typeof e)throw new TypeError("TinyIframeEvents: secretEventName must be a string.");this.#Mr=e}get handshakeEventName(){return Tr(this.#ur),this.#Dr}set handshakeEventName(e){if(Tr(this.#ur),"string"!=typeof e)throw new TypeError("TinyIframeEvents: handshakeEventName must be a string.");this.#Dr=e}get readyEventName(){return Tr(this.#ur),this.#Ar}set readyEventName(e){if(Tr(this.#ur),"string"!=typeof e)throw new TypeError("TinyIframeEvents: readyEventName must be a string.");this.#Ar=e}#_r(){"parent"===this.#Sr?(this.#kr=()=>{if(this.#ur)return;this.#Cr&&this.#Cr.close();const e=new MessageChannel;this.#Cr=e.port1,this.#Cr.onmessage=this._boundPortMessage,this.#xr=!1,this.#vr.postMessage({type:this.#Dr},this.#Tr,[e.port2])},this.#Er&&(this.#Er.addEventListener("load",this.#kr),this.#kr())):window.addEventListener("message",this._boundWindowMessage,!1)}#Nr(e){const t=e.data,r=e.ports;g(t)&&t.type===this.#Dr&&0!==r.length&&(this.#Cr=r[0],this.#Cr.onmessage=this._boundPortMessage,window.removeEventListener("message",this._boundWindowMessage),this.#Cr.postMessage({type:`${this.#Dr}_ACK`}),this.#jr())}#Lr(e){const t=e.data;if(g(t)&&t.type===`${this.#Dr}_ACK`)return void this.#jr();if(!g(t)||!t[this.#Mr])return;const r=t.eventName,i=t.payload,s=t.direction;"string"!=typeof r||"iframe"===this.#Sr&&"iframe"!==s||"parent"===this.#Sr&&"parent"!==s||this.emit(`win:${r}`,i,e)}#jr(){this.#xr||(this.#xr=!0,this.#Rr(),this.emit(this.#Ar))}#Rr(){for(;this.#Ir.length>0;){const e=this.#Ir.shift();e&&this.#Cr&&this.#Cr.postMessage(e)}}winEmit(e,t){if(Tr(this.#ur),"string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.#ur)throw new Error("Cannot emit: instance has been destroyed.");const r={[this.#Mr]:!0,eventName:e,payload:t,direction:"parent"===this.#Sr?"iframe":"parent"};this.#xr&&this.#Cr?this.#Cr.postMessage(r):this.#Ir.push(r)}isDestroyed(){return this.#ur}destroy(){this.#ur||(this.#xr=!1,window.removeEventListener("message",this._boundWindowMessage),this.#Er&&this.#kr&&this.#Er.removeEventListener("load",this.#kr),this.#Cr&&(this.#Cr.close(),this.#Cr=null),this.removeAllListeners(),this.#Ir=[],Sr.delete(this.#vr),this.#ur=!0)}}const Ar=xr,Cr=ee("TinyNewWinEvents"),Ir=new WeakMap;class Mr extends sr.EventEmitter{#Pr;#Tr;#Ir=[];#xr=!1;#$r=!1;#Or=null;#Ar="__TNE_READY__";#Hr="__TNE_ROUTE__";#h=!1;get destroyed(){return this.#h}get readyEventName(){return Cr(this.#h),this.#Ar}set readyEventName(e){if(Cr(this.#h),"string"!=typeof e)throw new TypeError("TinyNewWinEvents: readyEventName must be a string.");this.#Ar=e}get routeEventName(){return Cr(this.#h),this.#Hr}set routeEventName(e){if(Cr(this.#h),"string"!=typeof e)throw new TypeError("TinyNewWinEvents: routeEventName must be a string.");this.#Hr=e}constructor({targetOrigin:e,url:t,name:r,features:i}={}){if(super(),"string"==typeof r&&"_blank"===r)throw new Error('TinyNewWinEvents: The window name "_blank" is not supported. Please use a custom name to allow tracking.');if(void 0!==e&&"string"!=typeof e)throw new TypeError('TinyNewWinEvents: The "targetOrigin" option must be a string.');if(void 0!==t&&"string"!=typeof t)throw new TypeError('TinyNewWinEvents: The "url" option must be a string.');if(void 0!==i&&"string"!=typeof i)throw new TypeError('TinyNewWinEvents: The "features" option must be a string if provided.');if(void 0===t?this.#Pr=window.opener:(this.#Pr="string"==typeof t?window.open(t,r,i):t,this.#$r=!0),!this.#Pr||Ir.has(this.#Pr))throw new Error("Invalid or duplicate window reference.");this.#Tr=e??window.location.origin,this._handleMessage=this.#Fr.bind(this),window.addEventListener("message",this._handleMessage,!1),this.#$r||(this.#Br(this.#Ar,null),this.#zr())}getWin(){return Cr(this.#h),this.#Pr}#Fr(e){if(!e.source||this.#Pr&&e.source!==this.#Pr)return;const{type:t,route:r,payload:i}=e.data||{};if(t===this.#Ar)return this.#xr=!0,this.#Rr(),this.#zr(),void(this.#$r&&this.#Br(this.#Ar,null));t===this.#Hr&&this.emit(`win:${r}`,i,e)}#Rr(){for(;this.#Ir.length;){const e=this.#Ir.shift();if(e){const{route:t,payload:r}=e;this.winEmit(t,r)}}}#Br(e,t,r=""){this.#Pr&&this.#Pr.closed||this.#Pr?.postMessage({type:e,route:r,payload:t},this.#Tr)}close(){if(Cr(this.#h),!this.#$r)throw new Error("Only host can close the window.");this.#Pr&&!this.#Pr.closed&&this.#Pr.close()}winEmit(e,t){if(Cr(this.#h),"string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.isDestroyed())throw new Error("Cannot emit: instance has been destroyed.");this.#xr?this.#Br(this.#Hr,t,e):this.#Ir.push({route:e,payload:t})}isConnected(){return Cr(this.#h),!(!this.#xr||!this.#Pr||this.#Pr.closed)}#zr(){this.#Pr&&!this.#Or&&(this.#Or=setInterval(()=>{this.#Pr?.closed&&(this.emit("WINDOW_REF_CLOSED"),this.destroy())},500),Ir.set(this.#Pr,this.#Or))}onClose(e){Cr(this.#h),this.on("WINDOW_REF_CLOSED",e)}offClose(e){Cr(this.#h),this.off("WINDOW_REF_CLOSED",e)}isDestroyed(){return!this.#Pr}destroy(){this.#Pr&&(this.#Or&&(clearInterval(this.#Or),this.#Or=null,Ir.delete(this.#Pr)),window.removeEventListener("message",this._handleMessage),this.#Ir=[],this.#xr=!1,this.#Pr=null,this.removeAllListeners(),this.#h=!0)}}const Dr=Mr,kr=class{#h=!1;get destroyed(){return this.#h}#Wr;#Vr;#qr;#Kr=0;#Jr=0;#Ur;#Gr=null;#Yr=null;get lineHeight(){return this.#Wr}get maxRows(){return this.#Vr-1}get extraHeight(){return this.#qr}get currentHeight(){return this.#Kr}get currentRows(){return this.#Jr}get textarea(){return this.#Ur}constructor(e,t={}){if(!(e instanceof HTMLTextAreaElement))throw new Error("TinyTextarea: Provided element is not a <textarea>.");if("object"!=typeof t||null===t)throw new TypeError("TinyTextarea: Options must be an object if provided.");if("maxRows"in t&&"number"!=typeof t.maxRows)throw new TypeError("TinyTextarea: `maxRows` must be a number.");if("extraHeight"in t&&"number"!=typeof t.extraHeight)throw new TypeError("TinyTextarea: `extraHeight` must be a number.");if("onResize"in t&&"function"!=typeof t.onResize)throw new TypeError("TinyTextarea: `onResize` must be a function.");if("onInput"in t&&"function"!=typeof t.onInput)throw new TypeError("TinyTextarea: `onInput` must be a function.");this.#Ur=e,this.#Vr=(t.maxRows??5)+1,this.#qr=t.extraHeight??0,this.#Gr=t.onResize??null,this.#Yr=t.onInput??null,this.#Wr=this.#Xr(),e.style.overflowY="hidden",e.style.resize="none",this._handleInput=()=>this.#Qr(),e.addEventListener("input",this._handleInput),this.#Qr()}#Qr(){this.#Ur.style.height="auto";const e=window.getComputedStyle(this.#Ur),t=parseFloat(e.paddingTop)||0,r=parseFloat(e.paddingBottom)||0,i=(this.#Ur.value.match(/\n/g)||[]).length,s=this.#Ur.scrollHeight,n=this.#Wr*this.#Vr,o=Math.ceil(Math.min(s,n)-t-r+this.#qr),a=this.#Vr-1,l=i<a?i+1:a;this.#Ur.style.height=`${o}px`,this.#Ur.style.overflowY=s>n?"auto":"hidden",this.#Kr=o;const u={breakLines:i,rows:l,height:o,scrollHeight:s,maxHeight:n,lineHeight:this.#Wr,maxRows:a};l!==this.#Jr&&(this.#Jr=l,"function"==typeof this.#Gr&&this.#Gr({...u})),"function"==typeof this.#Yr&&this.#Yr(u)}#Xr(){const e=window.getComputedStyle(this.#Ur),t=parseFloat(e.lineHeight);return Number.isNaN(t)?1.2*parseFloat(e.fontSize):t}getData(){return{rows:this.#Jr,height:this.#Kr}}refresh(){this.#Qr()}destroy(){this.destroyed||(this.#Ur.removeEventListener("input",this._handleInput),this.#h=!0)}},Nr=ee("TinyGamepad");class Lr{#ur=!1;#Zr=new Set;#ei=new Map;#ti=new Map;#ri=null;#ii=[];#si={};#ni=[];#oi=null;#ai=null;#li;#ui;#hi;#ci;#di;#mi;#pi;#fi;#yi=[];#gi=0;#bi=0;#wi=[];#vi=0;#Ei=null;#Ti=new Set;#Si=new Set;#xi=new Map;#Ai=new Map;#Ci=new Map;static#Ii={" ":"Space","\n":"Enter","\r":"Enter","\t":"Tab","-":"Minus",_:"Minus","=":"Equal","+":"Equal","[":"BracketLeft","{":"BracketLeft","]":"BracketRight","}":"BracketRight","\\":"Backslash","|":"Backslash",";":"Semicolon",":":"Semicolon","'":"Quote",'"':"Quote",",":"Comma","<":"Comma",".":"Period",">":"Period","/":"Slash","?":"Slash","`":"Backquote","~":"Backquote"};static addSpecialKey(e,t){if("string"!=typeof e)throw new TypeError("Invalid char type: expected string, got "+typeof e);if(1!==e.length)throw new Error(`Invalid char length: "${e}" (must be exactly one character)`);if("string"!=typeof t)throw new TypeError("Invalid code type: expected string, got "+typeof t);Lr.#Ii[e]=t}static removeSpecialKey(e){if("string"!=typeof e)throw new TypeError("Invalid char type: expected string, got "+typeof e);if(1!==e.length)throw new Error(`Invalid char length: "${e}" (must be exactly one character)`);delete Lr.#Ii[e]}static getSpecialKey(e){if("string"!=typeof e)throw new TypeError("Invalid char type: expected string, got "+typeof e);if(1!==e.length)throw new Error(`Invalid char length: "${e}" (must be exactly one character)`);return Lr.#Ii[e]}static getAllSpecialKeys(){return{...Lr.#Ii}}static stringToKeys(e){if("string"!=typeof e)throw new TypeError("Invalid text type: expected string, got "+typeof e);if(!e.length)throw new Error("Invalid text: cannot be empty");return Array.from(e).map(e=>{const t=e.toUpperCase();if(t>="A"&&t<="Z")return`Key${t}`;if(t>="0"&&t<="9")return`Digit${t}`;const r=Lr.#Ii[e];if(void 0!==r)return r;throw new Error(`Unsupported character: "${e}"`)})}constructor({expectedId:e=null,inputMode:t="both",ignoreIds:r=[],deadZone:i=.1,axisActiveSensitivity:s=.3,timeoutComboKeys:n=500,allowMouse:o=!1,elementBase:a=window}={}){if(null!==e&&"string"!=typeof e)throw new TypeError('"expectedId" must be a string or null, received: '+typeof e);if(!["keyboard-only","gamepad-only","both"].includes(t))throw new TypeError(`"inputMode" must be 'keyboard-only', 'gamepad-only', or 'both', received: ${t}`);if(!Array.isArray(r)||!r.every(e=>"string"==typeof e))throw new TypeError('"ignoreIds" must be an array of strings');if("number"!=typeof i||i<0||i>1)throw new RangeError(`"deadZone" must be a number between 0 and 1, received: ${i}`);if("number"!=typeof s||s<0||s>1)throw new RangeError(`"axisActiveSensitivity" must be a number between 0 and 1, received: ${s}`);if("number"!=typeof n||n<0)throw new RangeError(`"timeoutComboKeys" must be a positive number, received: ${n}`);if("boolean"!=typeof o)throw new TypeError('"allowMouse" must be a boolean, received: '+typeof o);if(!(a instanceof Window||a instanceof Element))throw new TypeError('"elementBase" must be a Window or Element instance');this.#ci=e,this.#li=t,this.#ui=new Set(r),this.#hi=i,this.#di=o,this.#mi=a,this.#pi=n,this.#fi=s,["gamepad-only","both"].includes(this.#li)&&this.#Mi(),["keyboard-only","both"].includes(this.#li)&&this.#Di()}#ki=e=>this.#Ni(e.gamepad);#Li=e=>this.#_i(e.gamepad);#Mi(){window.addEventListener("gamepadconnected",this.#ki),window.addEventListener("gamepaddisconnected",this.#Li)}#Ni(e){this.#ur||this.#ui.has(e.id)||this.#ci&&e.id!==this.#ci||this.#ri||(this.#ri=e,this.#ci=e.id,this.#ji(),this.#Ri("connected",{id:e.id,gp:e,timestamp:e.timestamp}))}#_i(e){this.#ur||this.#ri&&e.id===this.#ri.id&&(this.#ri=null,this.#oi&&(cancelAnimationFrame(this.#oi),this.#oi=null),this.#Ri("disconnected",{id:e.id,gp:e,timestamp:e.timestamp}))}#ji(){const e=()=>{this.#ur||(this.#Pi(),this.#oi=requestAnimationFrame(e))};e()}#Pi(){if(this.#ur)return;const e=navigator.getGamepads(),t=Array.from(e).find(e=>e&&e.id===this.#ci);t&&(this.#ri=t,t.buttons.forEach((e,r)=>{const i=`Button${r}`,s=this.#ii[r]?.pressed||!1;let n,o,a=!1;e.pressed&&!s?(o=1,n="down"):!e.pressed&&s?(o=0,n="up"):e.pressed&&s&&(o=1,n="hold"),e.pressed&&e.value>0&&e.value<1&&1!==e.value&&(o=e.value,a=!0),"number"==typeof o&&"string"==typeof n&&this.#$i({key:i,source:"gamepad-button",value:o,value2:NaN,type:n,gp:t,isPressure:a,pressed:e.pressed,prevPressed:s,timestamp:t.timestamp,id:t.id}),this.#ii[r]={pressed:e.pressed,value:"number"==typeof o?o:this.#ii[r]?.value,value2:NaN}}),t.axes.forEach((e,r)=>{Math.abs(e)<this.#hi&&(e=0);const i=`Axis${r}`;e!==(this.#ni[r]??0)&&this.#$i({key:i,source:"gamepad-analog",value:e,value2:NaN,type:"change",timestamp:t.timestamp,id:t.id,gp:t}),this.#ni[r]=e}))}#Oi=e=>{if(!this.#ur){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keydown listener.");this.#Zr.has(e.code)||(this.#Zr.add(e.code),this.#$i({event:e,key:e.code,source:"keyboard",value:1,value2:NaN,type:"down",pressed:!0,prevPressed:this.#si[e.code]?.pressed??!1,id:"native_keyboard",timestamp:e.timeStamp}),this.#si[e.code]={pressed:!0})}};#Hi=e=>{if(!this.#ur){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keyup listener.");this.#Zr.has(e.code)&&(this.#Zr.delete(e.code),this.#$i({event:e,key:e.code,source:"keyboard",value:0,value2:NaN,type:"up",pressed:!1,prevPressed:this.#si[e.code]?.pressed??!1,id:"native_keyboard",timestamp:e.timeStamp}),this.#si[e.code]={pressed:!1})}};#Fi=e=>{if(this.#ur)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mousedown listener.");const t=`Mouse${e.button}`;this.#Zr.add(t),this.#$i({event:e,key:t,source:"mouse",value:1,value2:NaN,type:"down",pressed:!0,prevPressed:this.#si[t]?.pressed??!1,id:"native_mouse",timestamp:e.timeStamp}),this.#si[t]={pressed:!0}};#Bi=e=>{if(this.#ur)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mouseup listener.");const t=`Mouse${e.button}`;this.#Zr.delete(t),this.#$i({event:e,key:t,source:"mouse",value:0,value2:NaN,type:"up",pressed:!1,prevPressed:this.#si[t]?.pressed??!1,id:"native_mouse",timestamp:e.timeStamp}),this.#si[t]={pressed:!1}};#zi=e=>{if(!this.#ur){if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mousemove listener.");if(0!==e.movementX||0!==e.movementY){const t="MouseMove",r=this.#si[t]??{pressed:!1,value:0,value2:0};this.#$i({event:e,key:t,source:"mouse",value:e.movementX+(r.value??0),value2:e.movementY+(r.value??0),id:"native_mouse",type:"move",pressed:!0,prevPressed:null,timestamp:e.timeStamp}),this.#si[t]={pressed:!1,value:e.movementX,value2:e.movementY}}}};#Di(){this.#mi.addEventListener("keydown",this.#Oi),this.#mi.addEventListener("keyup",this.#Hi),this.#di&&(this.#mi.addEventListener("mousedown",this.#Fi),this.#mi.addEventListener("mouseup",this.#Bi),this.#mi.addEventListener("mousemove",this.#zi));const e=()=>{this.#ur||(this.#Zr.forEach(e=>{const t=e.startsWith("Mouse")?"mouse":"keyboard";this.#$i({key:e,source:t,id:`native_${t}`,value:1,value2:NaN,type:"hold",pressed:!0,prevPressed:this.#si[e]?.pressed??!1,timestamp:NaN})}),this.#ai=requestAnimationFrame(e))};e()}#$i(e){if(this.#ur)return;const t=this.#ti.get("input-*")||[],{pressed:r,key:i}=e,s=i.startsWith("Axis"),n="boolean"==typeof r&&r||s&&(e.value>this.#fi||e.value<-Math.abs(this.#fi)),o=s?`${i}${e.value>0?"+":e.value<0?"-":""}`:i;let a=null;if("move"!==e.type&&"hold"!==e.type){if(n){if(!s&&!this.#Ti.has(i)||s&&!this.#Ti.has(i)&&!this.#Ti.has(`${i}+`)&&!this.#Ti.has(`${i}-`)){0===this.#vi&&(this.#vi=Date.now()),this.#Ti.add(o),a=!0,this.#wi.push(o),this.#yi.length<1&&(this.#Ei&&clearTimeout(this.#Ei),this.#Ei=setTimeout(()=>this.resetComboMapped(),this.#pi));const e=this.#ti.get("mapped-key-start")??[];for(const t of e)t({key:o,activeTime:this.#vi})}}else if(!s&&this.#Ti.has(i)||s&&(this.#Ti.has(i)||this.#Ti.has(`${i}+`)||this.#Ti.has(`${i}-`))){this.#Ti.delete(i),this.#Ti.delete(`${i}+`),this.#Ti.delete(`${i}-`),a=!1;const e=this.#ti.get("mapped-key-end")??[];for(const t of e)t({key:o,activeTime:this.#vi})}for(const{sequence:e,callback:t,triggered:r}of this.#Ai.values()){const i=this.#Ai.get(e.join("+"));if(!i)continue;const s=e.every((e,t)=>this.#wi[t]===e);s&&!r?(i.triggered=!0,t(this.#vi)):!s&&r&&(i.triggered=!1)}}for(const[r,l]of this.#ei.entries()){const u=e=>"string"==typeof l&&e===l||Array.isArray(l)&&l.findIndex((t,r)=>e===l[r])>-1,h=u(o),c=s&&u(`${i}+`),d=s&&u(`${i}-`);if(h||c||d){if(n&&h){if(a||!this.#Si.has(r)){0===this.#bi&&(this.#bi=Date.now()),this.#Si.add(r),0===this.#gi&&(this.#gi=Date.now()),this.#Ei&&clearTimeout(this.#Ei),this.#yi.push(r),this.#Ei=setTimeout(()=>this.resetComboMapped(),this.#pi);const e=this.#ti.get("mapped-input-start")??[];for(const t of e)t({logicalName:r,activeTime:this.#bi,comboTime:this.#gi})}}else if(!a||this.#Si.has(r)){this.#Si.delete(r),this.#Si.size<1&&(this.#bi=0);const e=this.#ti.get("mapped-input-end")??[];for(const t of e)t({logicalName:r,activeTime:this.#bi,comboTime:this.#gi})}for(const{sequence:e,callback:t,triggered:r}of this.#xi.values()){const i=this.#xi.get(e.join("+"));if(!i)continue;const s=Array.from(this.#Si),n=e.every((e,t)=>s[t]===e);n&&!r?(i.triggered=!0,t(this.#bi)):!n&&r&&(i.triggered=!1)}}const m=[];if(s&&0===e.value){const{value:t}=this.#Ci.get(`${i}-`)??{value:0,value2:NaN},{value:r}=this.#Ci.get(`${i}+`)??{value:0,value2:NaN};e.value!==t&&m.push(`${i}-`),e.value!==r&&m.push(`${i}+`)}else m.push(o);m.forEach(i=>{if(!("*"===l||l===i||Array.isArray(l)&&l.includes(i)))return;const s=this.#ti.get(`input-${e.type}-${r}`)||[],n=this.#ti.get(`input-${r}`)||[];if(n.length<1&&s.length<1&&t.length<1)return;const o={...e,key:i,logicalName:r};for(const e of t)e(o);for(const e of n)e(o);for(const e of s)e(o);this.#Ci.set(i,{value:e.value,value2:e.value2})})}}#Ri(e,t){const r=this.#ti.get(e)||[];for(const e of r)e(t)}#Wi(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const i=r.replace("{logicalName}",e);let s=this.#ti.get(i);Array.isArray(s)||(s=[],this.#ti.set(i,s)),s.push(t)}#Vi(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const i=s=>{this.#qi(e,i,r),t(s)};this.#Wi(e,i,r)}#Ki(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const i=r.replace("{logicalName}",e),s=this.#ti.get(i)??[];s.unshift(t),this.#ti.set(i,s)}#qi(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const i=r.replace("{logicalName}",e),s=this.#ti.get(i);Array.isArray(s)&&this.#ti.set(i,s.filter(e=>e!==t))}awaitInputMapping({timeout:e=1e4,eventName:t="MappingInput",canMove:r=!1}={}){return Nr(this.#ur),new Promise((i,s)=>{if("number"!=typeof e||Number.isNaN(e)||e<0)return s(new TypeError(`Invalid "timeout": expected a positive number, got ${e}`));if("string"!=typeof t||!t.trim())return s(new TypeError(`Invalid "eventName": expected a non-empty string, got ${t}`));if("boolean"!=typeof r)return s(new TypeError(`Invalid "canMove": expected a boolean, got ${r}`));const n={key:null,source:null},o=({key:e,type:s,source:l,gp:u,value:h})=>{(r||"move"!==s)&&(n.key=e,n.source=l,n.gp=u,clearTimeout(a),this.offInputStart(t,o),this.offInputChange(t,o),r&&this.offInputMove(t,o),i(n))},a=setTimeout(()=>i(n),e);this.mapInput(t,"*"),this.onInputStart(t,o),this.onInputChange(t,o),r&&this.onInputMove(t,o)})}mapInput(e,t){if(Nr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError(`Invalid "physicalInput": expected string or array of strings, got ${JSON.stringify(t)}`);this.#ei.set(e,t)}unmapInput(e){if(Nr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);this.#ei.delete(e)}hasMappedInput(e){if(Nr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);return this.#ei.has(e)}getMappedInput(e){if(Nr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);const t=this.#ei.get(e);if(!t)throw new Error(`No physical input mapped for logicalName: "${e}"`);return t}clearMapInputs(){Nr(this.#ur),this.#ei.clear()}registerInputSequence(e,t){if(Nr(this.#ur),!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);if("function"!=typeof t)throw new TypeError("'callback' must be a function, got: "+typeof t);if(0===e.length)throw new Error("'sequence' must contain at least one input name.");const r=e.join("+");this.#xi.set(r,{sequence:e,callback:t,triggered:!1})}unregisterInputSequence(e){if(Nr(this.#ur),!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");this.#xi.delete(t)}unregisterAllInputSequences(){Nr(this.#ur),this.#xi.clear()}hasInputSequence(e){if(Nr(this.#ur),!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");return this.#xi.has(t)}registerKeySequence(e,t){if(Nr(this.#ur),!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);if("function"!=typeof t)throw new TypeError("'callback' must be a function, got: "+typeof t);if(0===e.length)throw new Error("'sequence' must contain at least one input name.");const r=e.join("+");this.#Ai.set(r,{sequence:e,callback:t,triggered:!1})}unregisterKeySequence(e){if(Nr(this.#ur),!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");this.#Ai.delete(t)}unregisterAllKeySequences(){Nr(this.#ur),this.#Ai.clear()}hasKeySequence(e){if(Nr(this.#ur),!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");return this.#Ai.has(t)}renewComboMapped(){Nr(this.#ur),this.#Ei&&(clearTimeout(this.#Ei),this.#Ei=setTimeout(()=>this.resetComboMapped(),this.#pi))}resetComboMapped(){Nr(this.#ur),this.#Ei&&clearTimeout(this.#Ei),this.#wi=[],this.#Ei=null,this.#vi=0,this.#yi=[],this.#gi=0}onMappedKeyStart(e){return Nr(this.#ur),this.#Wi("",e,"mapped-key-start")}onceMappedKeyStart(e){return Nr(this.#ur),this.#Vi("",e,"mapped-key-start")}prependMappedKeyStart(e){return Nr(this.#ur),this.#Ki("",e,"mapped-key-start")}offMappedKeyStart(e){return Nr(this.#ur),this.#qi("",e,"mapped-key-start")}offAllMappedKeyStart(){Nr(this.#ur),this.#ti.delete("mapped-key-start")}onMappedKeyEnd(e){return Nr(this.#ur),this.#Wi("",e,"mapped-key-end")}onceMappedKeyEnd(e){return Nr(this.#ur),this.#Vi("",e,"mapped-key-end")}prependMappedKeyEnd(e){return Nr(this.#ur),this.#Ki("",e,"mapped-key-end")}offMappedKeyEnd(e){return Nr(this.#ur),this.#qi("",e,"mapped-key-end")}offAllMappedKeyEnd(){Nr(this.#ur),this.#ti.delete("mapped-key-end")}onMappedInputStart(e){return Nr(this.#ur),this.#Wi("",e,"mapped-input-start")}onceMappedInputStart(e){return Nr(this.#ur),this.#Vi("",e,"mapped-input-start")}prependMappedInputStart(e){return Nr(this.#ur),this.#Ki("",e,"mapped-input-start")}offMappedInputStart(e){return Nr(this.#ur),this.#qi("",e,"mapped-input-start")}offAllMappedInputStart(){Nr(this.#ur),this.#ti.delete("mapped-input-start")}onMappedInputEnd(e){return Nr(this.#ur),this.#Wi("",e,"mapped-input-end")}onceMappedInputEnd(e){return Nr(this.#ur),this.#Vi("",e,"mapped-input-end")}prependMappedInputEnd(e){return Nr(this.#ur),this.#Ki("",e,"mapped-input-end")}offMappedInputEnd(e){return Nr(this.#ur),this.#qi("",e,"mapped-input-end")}offAllMappedInputEnd(){Nr(this.#ur),this.#ti.delete("mapped-input-end")}onInput(e,t){return Nr(this.#ur),this.#Wi(e,t,"input-{logicalName}")}onceInput(e,t){return Nr(this.#ur),this.#Vi(e,t,"input-{logicalName}")}prependInput(e,t){return Nr(this.#ur),this.#Ki(e,t,"input-{logicalName}")}offInput(e,t){return Nr(this.#ur),this.#qi(e,t,"input-{logicalName}")}onInputStart(e,t){return Nr(this.#ur),this.#Wi(e,t,"input-down-{logicalName}")}onceInputStart(e,t){return Nr(this.#ur),this.#Vi(e,t,"input-down-{logicalName}")}prependInputStart(e,t){return Nr(this.#ur),this.#Ki(e,t,"input-down-{logicalName}")}offInputStart(e,t){return Nr(this.#ur),this.#qi(e,t,"input-down-{logicalName}")}onInputEnd(e,t){return Nr(this.#ur),this.#Wi(e,t,"input-up-{logicalName}")}onceInputEnd(e,t){return Nr(this.#ur),this.#Vi(e,t,"input-up-{logicalName}")}prependInputEnd(e,t){return Nr(this.#ur),this.#Ki(e,t,"input-up-{logicalName}")}offInputEnd(e,t){return Nr(this.#ur),this.#qi(e,t,"input-up-{logicalName}")}onInputHold(e,t){return Nr(this.#ur),this.#Wi(e,t,"input-hold-{logicalName}")}onceInputHold(e,t){return Nr(this.#ur),this.#Vi(e,t,"input-hold-{logicalName}")}prependInputHold(e,t){return Nr(this.#ur),this.#Ki(e,t,"input-hold-{logicalName}")}offInputHold(e,t){return Nr(this.#ur),this.#qi(e,t,"input-hold-{logicalName}")}onInputChange(e,t){return Nr(this.#ur),this.#Wi(e,t,"input-change-{logicalName}")}onceInputChange(e,t){return Nr(this.#ur),this.#Vi(e,t,"input-change-{logicalName}")}prependInputChange(e,t){return Nr(this.#ur),this.#Ki(e,t,"input-change-{logicalName}")}offInputChange(e,t){return Nr(this.#ur),this.#qi(e,t,"input-change-{logicalName}")}onInputMove(e,t){return Nr(this.#ur),this.#Wi(e,t,"input-move-{logicalName}")}onceInputMove(e,t){return Nr(this.#ur),this.#Vi(e,t,"input-move-{logicalName}")}prependInputMove(e,t){return Nr(this.#ur),this.#Ki(e,t,"input-move-{logicalName}")}offInputMove(e,t){return Nr(this.#ur),this.#qi(e,t,"input-move-{logicalName}")}getCalls(e,t="all"){if(Nr(this.#ur),"string"!=typeof e||""===e.trim())throw new TypeError(`"logicalName" must be a non-empty string, received ${e}`);const r=["all","start","end","hold","change","move"];if(!r.includes(t))throw new TypeError(`"type" must be one of ${r.join(", ")}, received ${t}`);const i=`${{all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t]}${e}`,s=this.#ti.get(i);return Array.isArray(s)?[...s]:[]}offAllInputs(e,t="all"){if(Nr(this.#ur),"string"!=typeof e||""===e.trim())throw new TypeError(`"logicalName" must be a non-empty string, received ${e}`);const r=["all","start","end","hold","change","move"];if(!r.includes(t))throw new TypeError(`"type" must be one of ${r.join(", ")}, received ${t}`);const i={all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t];i&&this.#ti.delete(`${i}${e}`)}getCallSize(e,t="all"){if(Nr(this.#ur),"string"!=typeof e||""===e.trim())throw new TypeError(`"logicalName" must be a non-empty string, received ${e}`);const r=["all","start","end","hold","change","move"];if(!r.includes(t))throw new TypeError(`"type" must be one of ${r.join(", ")}, received ${t}`);const i={all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t],s=this.#ti.get(`${i}${e}`);return Array.isArray(s)?s.length:0}#Ji={type:"dual-rumble",params:{startDelay:0,duration:200,weakMagnitude:.5,strongMagnitude:1}};get defaultHapticEffect(){return Nr(this.#ur),{type:this.#Ji.type,params:{...this.#Ji.params}}}setDefaultHapticEffect(e,t){if(Nr(this.#ur),"string"!=typeof e)throw new TypeError(`"type" must be a valid GamepadHapticEffectType string, received ${e}`);if("object"!=typeof t||null===t)throw new TypeError(`"params" must be a non-null object, received ${t}`);this.#Ji.type=e,this.#Ji.params=t}hasHapticEffect(){Nr(this.#ur);const e=this.#ri;return!!e&&e.vibrationActuator instanceof GamepadHapticActuator}vibrate(e,t){if(Nr(this.#ur),void 0!==e&&("object"!=typeof e||null===e))throw new TypeError(`"params" must be an object if provided, received ${e}`);if(void 0!==t&&"string"!=typeof t)throw new TypeError(`"type" must be a valid GamepadHapticEffectType string if provided, received ${t}`);const r=this.#ri;if(!r)return new Promise(e=>e("complete"));const i=r.vibrationActuator;return i instanceof GamepadHapticActuator?i.playEffect(t??this.#Ji.type,{...this.#Ji.params,...e}):new Promise(e=>e("complete"))}ignoreId(e){if(Nr(this.#ur),"string"!=typeof e||""===e.trim())throw new TypeError(`"id" must be a non-empty string, received ${e}`);this.#ui.add(e)}unignoreId(e){if(Nr(this.#ur),"string"!=typeof e||""===e.trim())throw new TypeError(`"id" must be a non-empty string, received ${e}`);this.#ui.delete(e)}onConnected(e){return Nr(this.#ur),this.#Wi("",e,"connected")}onceConnected(e){return Nr(this.#ur),this.#Vi("",e,"connected")}prependConnected(e){return Nr(this.#ur),this.#Ki("",e,"connected")}offConnected(e){return Nr(this.#ur),this.#qi("",e,"connected")}offAllConnected(){Nr(this.#ur),this.#ti.delete("connected")}onDisconnected(e){return Nr(this.#ur),this.#Wi("",e,"disconnected")}onceDisconnected(e){return Nr(this.#ur),this.#Vi("",e,"disconnected")}prependDisconnected(e){return Nr(this.#ur),this.#Ki("",e,"disconnected")}offDisconnected(e){return Nr(this.#ur),this.#qi("",e,"disconnected")}offAllDisconnected(){Nr(this.#ur),this.#ti.delete("disconnected")}hasGamepad(){return Nr(this.#ur),this.#ri instanceof Gamepad}getGamepad(){if(Nr(this.#ur),!this.#ri)throw new Error("No gamepad is currently connected.");return this.#ri}hasLastButtonState(e){return Nr(this.#ur),!!this.#ii[e]}getLastButtonState(e){if(Nr(this.#ur),!this.#ii[e])throw new Error(`No last button state found for index ${e}`);return{...this.#ii[e]}}exportConfig(){return Nr(this.#ur),{expectedId:this.#ci,ignoreIds:Array.from(this.#ui),deadZone:this.#hi,timeoutComboKeys:this.#pi,axisActiveSensitivity:this.#fi,inputMap:Array.from(this.#ei.entries())}}importConfig(e){if(Nr(this.#ur),"string"!=typeof e&&("object"!=typeof e||null===e))throw new TypeError(`"json" must be a string or a non-null object, received: ${e}`);const t="string"==typeof e?JSON.parse(e):e;if(void 0!==t.expectedId&&"string"!=typeof t.expectedId&&null!==t.expectedId)throw new TypeError('"expectedId" must be a string or null if provided');if(void 0!==t.ignoreIds&&!Array.isArray(t.ignoreIds))throw new TypeError('"ignoreIds" must be an array if provided');if(void 0!==t.deadZone&&"number"!=typeof t.deadZone)throw new TypeError('"deadZone" must be a number if provided');if(void 0!==t.timeoutComboKeys&&"number"!=typeof t.timeoutComboKeys)throw new TypeError('"timeoutComboKeys" must be a number if provided');if(void 0!==t.axisActiveSensitivity&&"number"!=typeof t.axisActiveSensitivity)throw new TypeError('"axisActiveSensitivity" must be a number if provided');if(void 0!==t.inputMap&&!Array.isArray(t.inputMap))throw new TypeError('"inputMap" must be an array if provided');void 0!==t.expectedId&&(this.#ci=t.expectedId),Array.isArray(t.ignoreIds)&&(this.#ui=new Set(t.ignoreIds)),"number"==typeof t.deadZone&&(this.#hi=t.deadZone),"number"==typeof t.timeoutComboKeys&&(this.#pi=t.timeoutComboKeys),"number"==typeof t.axisActiveSensitivity&&(this.#fi=t.axisActiveSensitivity),Array.isArray(t.inputMap)&&(this.#ei=new Map(t.inputMap))}get mappedKeyStartCalls(){Nr(this.#ur);const e=this.#ti.get("mapped-key-start");return Array.isArray(e)?[...e]:[]}get mappedKeyEndCalls(){Nr(this.#ur);const e=this.#ti.get("mapped-key-end");return Array.isArray(e)?[...e]:[]}get comboMappedKeys(){return Nr(this.#ur),[...this.#wi]}get comboMappedInputs(){return Nr(this.#ur),[...this.#yi]}get keySequenceSize(){return Nr(this.#ur),this.#Ai.size}get keySequences(){Nr(this.#ur);const e=[];for(const[,t]of this.#Ai.entries())e.push(t.callback);return e}get activeMappedKeys(){return Nr(this.#ur),[...this.#Ti]}get mappedInputStartCalls(){Nr(this.#ur);const e=this.#ti.get("mapped-input-start");return Array.isArray(e)?[...e]:[]}get mappedInputEndCalls(){Nr(this.#ur);const e=this.#ti.get("mapped-input-end");return Array.isArray(e)?[...e]:[]}get inputSequenceSize(){return Nr(this.#ur),this.#xi.size}get inputSequences(){Nr(this.#ur);const e=[];for(const[,t]of this.#xi.entries())e.push(t.callback);return e}get activeMappedInputs(){return Nr(this.#ur),[...this.#Si]}get mappedInputs(){Nr(this.#ur);const e={};for(const[t,r]of this.#ei.entries())e[t]=r;return e}get mappedInputSize(){return Nr(this.#ur),this.#ei.size}get connectedCalls(){Nr(this.#ur);const e=this.#ti.get("connected");return Array.isArray(e)?[...e]:[]}get disconnectedCalls(){Nr(this.#ur);const e=this.#ti.get("disconnected");return Array.isArray(e)?[...e]:[]}get ignoredDeviceIds(){return Nr(this.#ur),[...this.#ui]}get heldKeys(){return Nr(this.#ur),[...this.#Zr]}get eventsSize(){Nr(this.#ur);let e=0;return this.#ti.forEach(t=>{e+=t.length}),e}get callSize(){return Nr(this.#ur),this.#ti.size}get connectedCallSize(){Nr(this.#ur);const e=this.#ti.get("connected");return Array.isArray(e)?e.length:0}get disconnectedCallSize(){Nr(this.#ur);const e=this.#ti.get("disconnected");return Array.isArray(e)?e.length:0}get mappedKeyStartCallSize(){Nr(this.#ur);const e=this.#ti.get("mapped-key-start");return Array.isArray(e)?e.length:0}get mappedKeyEndCallSize(){Nr(this.#ur);const e=this.#ti.get("mapped-key-end");return Array.isArray(e)?e.length:0}get mappedInputStartCallSize(){Nr(this.#ur);const e=this.#ti.get("mapped-input-start");return Array.isArray(e)?e.length:0}get mappedInputEndCallSize(){Nr(this.#ur);const e=this.#ti.get("mapped-input-end");return Array.isArray(e)?e.length:0}get lastButtonStates(){Nr(this.#ur);const e=[];return this.#ii.forEach(t=>{e.push({...t})}),e}get lastAxes(){return Nr(this.#ur),[...this.#ni]}get inputMode(){return Nr(this.#ur),this.#li}get elementBase(){return Nr(this.#ur),this.#mi}get timeComboInputs(){return Nr(this.#ur),this.#gi}get timeComboKeys(){return Nr(this.#ur),this.#vi}get timeMappedInputs(){return Nr(this.#ur),this.#bi}get timeoutComboKeys(){return Nr(this.#ur),this.#pi}set timeoutComboKeys(e){if(Nr(this.#ur),"number"!=typeof e||e<0||!Number.isFinite(e))throw new TypeError("Timeout combo keys must be a non-negative finite number.");this.#pi=e}get axisActiveSensitivity(){return Nr(this.#ur),this.#fi}set axisActiveSensitivity(e){if(Nr(this.#ur),"number"!=typeof e||e<0||e>1)throw new RangeError("Axis sensitivity must be a number between 0 and 1.");this.#fi=e}get deadZone(){return Nr(this.#ur),this.#hi}set deadZone(e){if(Nr(this.#ur),"number"!=typeof e||e<0||e>1)throw new RangeError("Dead zone must be a number between 0 and 1.");this.#hi=e}get expectedId(){return Nr(this.#ur),this.#ci}set expectedId(e){if(Nr(this.#ur),"string"!=typeof e)throw new TypeError("Expected device id be a string.");this.#ci=e}get isDestroyed(){return this.#ur}destroy(){this.#ur||(this.#oi&&cancelAnimationFrame(this.#oi),this.#ai&&cancelAnimationFrame(this.#ai),this.#oi=null,this.#ai=null,["keyboard-only","both"].includes(this.#li)&&(this.#mi.removeEventListener("keydown",this.#Oi),this.#mi.removeEventListener("keyup",this.#Hi),this.#di&&(this.#mi.removeEventListener("mousedown",this.#Fi),this.#mi.removeEventListener("mouseup",this.#Bi),this.#mi.removeEventListener("mousemove",this.#zi))),["gamepad-only","both"].includes(this.#li)&&(window.removeEventListener("gamepadconnected",this.#ki),window.removeEventListener("gamepaddisconnected",this.#Li)),this.resetComboMapped(),this.#ei.clear(),this.#ti.clear(),this.#Zr.clear(),this.#Si.clear(),this.#Ti.clear(),this.#xi.clear(),this.#Ai.clear(),this.#ui.clear(),this.#Ci.clear(),this.#ii=[],this.#ni=[],this.#si={},this.#ri=null,this.#ci=null,this.#di=!1,this.#bi=0,this.#ur=!0)}}const _r=Lr,jr=ee("TinyDayNightCycle"),Rr=class{#Ui=!0;#Gi=86400;#Yi=3600;#Xi=60;#Qi=new Map;#Zi=[];#es;#ts;#rs={main:null};#is=0;#ss=0;#ns=0;#os="";#as=1;#ls=1;#us=1;#ur=!1;#hs=[31,31,31,31,31,31,31,31,31,31,31,31];#cs={default:{},day:{},night:{},hours:{},seasons:{}};#ds={min:60,max:180};#ms=0;get daySize(){return jr(this.#ur),this.#Gi}get autoSizeAdjuste(){return jr(this.#ur),this.#Ui}set autoSizeAdjuste(e){if(jr(this.#ur),"boolean"!=typeof e)throw new TypeError("autoSizeAdjuste must be a boolean.");this.#Ui=e}set daySize(e){if(jr(this.#ur),"number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("daySize must be a positive finite number.");const t=this.#Yi/this.#Gi,r=this.#Xi/this.#Gi;this.#Gi=e,this.#Ui&&(this.#Yi=e*t,this.#Xi=e*r)}get hourSize(){return jr(this.#ur),this.#Yi}set hourSize(e){if(jr(this.#ur),"number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("hourSize must be a positive finite number.");const t=this.#Gi/this.#Yi,r=this.#Xi/this.#Yi;this.#Yi=e,this.#Ui&&(this.#Gi=e*t,this.#Xi=e*r)}get minuteSize(){return jr(this.#ur),this.#Xi}set minuteSize(e){if(jr(this.#ur),"number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("minuteSize must be a positive finite number.");const t=this.#Yi/this.#Xi,r=this.#Gi/this.#Xi;this.#Xi=e,this.#Ui&&(this.#Yi=e*t,this.#Gi=e*r)}get isDestroyed(){return this.#ur}get currentSeconds(){return jr(this.#ur),this.#is}set currentSeconds(e){if(jr(this.#ur),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentSeconds must be a finite number, received "+typeof e);if(e<0||e>=this.#Gi)throw new RangeError(`currentSeconds must be between 0 and 86399, received ${e}`);this.#is=Math.floor(e),this.#ss=Math.floor(e/this.#Xi),this.#ns=Math.floor(e/this.#Yi)}get currentMinutes(){return jr(this.#ur),this.#ss}set currentMinutes(e){if(jr(this.#ur),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentMinutes must be a finite number, received "+typeof e);if(e<0||e>=1440)throw new RangeError(`currentMinutes must be between 0 and 1439, received ${e}`);this.#ss=Math.floor(e),this.#ns=Math.floor(e/this.#Xi),this.#is=Math.floor(e*this.#Xi)}get currentHours(){return jr(this.#ur),this.#ns}set currentHours(e){if(jr(this.#ur),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentHours must be a finite number, received "+typeof e);if(e<0||e>=24)throw new RangeError(`currentHours must be between 0 and less than 24, received ${e}`);this.#ns=Math.floor(e),this.#ss=Math.floor(e*this.#Xi),this.#is=Math.floor(e*this.#Yi)}get moons(){return jr(this.#ur),this.#Zi.map(e=>this.getMoon(e))}get seasons(){return jr(this.#ur),Array.from(this.#Qi.keys())}get dayStart(){return jr(this.#ur),this.#es}get nightStart(){return jr(this.#ur),this.#ts}get weather(){return jr(this.#ur),{...this.#rs}}get currentSeason(){return jr(this.#ur),this.#os}get currentDay(){return jr(this.#ur),this.#as}get currentMonth(){return jr(this.#ur),this.#ls}get currentYear(){return jr(this.#ur),this.#us}get monthDays(){return jr(this.#ur),[...this.#hs]}get weatherDuration(){return jr(this.#ur),{...this.#ds}}get weatherTimeLeft(){return jr(this.#ur),this.#ms}set dayStart(e){if(jr(this.#ur),"number"!=typeof e||e<1)throw new TypeError("dayStart must be a positive non-zero number, received "+typeof e);this.#es=e}set nightStart(e){if(jr(this.#ur),"number"!=typeof e||e<1)throw new TypeError("nightStart must be a positive non-zero number, received "+typeof e);this.#ts=e}set weather(e){if(jr(this.#ur),"object"!=typeof e||null===e||Array.isArray(e)||!Object.values(e).every(e=>"string"==typeof e))throw new TypeError("weather must be a object with strings, received "+typeof e);this.#rs=e}set currentSeason(e){if(jr(this.#ur),"string"!=typeof e||!this.#Qi.has(e))throw new TypeError(`currentSeason must be one of ${Array.from(this.#Qi).map(e=>e[0]).join(", ")}, received ${e}`);this.#os=e}set currentDay(e){if(jr(this.#ur),"number"!=typeof e||e<1||e>this.#hs[this.#ls-1])throw new TypeError("currentDay must be a valid day number, received "+typeof e);this.#as=e}set currentMonth(e){if(jr(this.#ur),"number"!=typeof e||"number"!=typeof this.#hs[e-1])throw new TypeError("currentMonth must be a valid month number, received "+typeof e);this.#ls=e}set currentYear(e){if(jr(this.#ur),"number"!=typeof e||e<1)throw new TypeError("currentYear must be a positive number non-zero, received "+typeof e);this.#us=e}set monthDays(e){if(jr(this.#ur),!Array.isArray(e))throw new TypeError("monthDays must be a array");if(!e.every(e=>"number"==typeof e))throw new TypeError("monthDays must have number values");this.#hs=[...e]}set weatherDuration(e){if(jr(this.#ur),"object"!=typeof e||null===e)throw new TypeError("weatherDuration must be a non-null object");if("number"!=typeof e.min||"number"!=typeof e.max)throw new TypeError("weatherDuration.min and weatherDuration.max must be numbers");this.#ds={...e}}set weatherTimeLeft(e){if(jr(this.#ur),"number"!=typeof e)throw new TypeError("weatherTimeLeft must be a number, received "+typeof e);this.#ms=e}get weatherConfig(){jr(this.#ur);const e={},t={};for(const t in this.#cs.hours)e[t]={...this.#cs.hours[t]};for(const e in this.#cs.seasons)t[e]={...this.#cs.seasons[e]};return{default:{...this.#cs.default},day:{...this.#cs.day},night:{...this.#cs.night},hours:e,seasons:t}}set weatherConfig(e){if(jr(this.#ur),"object"!=typeof e||null===e)throw new TypeError(`weatherConfig must be a non-null object, received ${e}`);const t=["default","day","night","hours","seasons"];for(const r of t)if(!(r in e))throw new TypeError(`weatherConfig is missing required property "${r}".`);const r={},i={},s=(e,t)=>{if("object"!=typeof e||null===e)throw new TypeError(`${t} must be an object, received ${e}`);for(const r in e){const i=typeof e[r];if("number"!==i&&"function"!==i)throw new TypeError(`${t}["${r}"] must be a number or function, received ${i}`)}};for(const t in e.hours)s(e.hours[t],`hours["${t}"]`),r[t]={...e.hours[t]};for(const t in e.seasons)s(e.seasons[t],`seasons["${t}"]`),i[t]={...e.seasons[t]};const n=(e,t)=>(s(e,t),{...e});this.#cs={default:n(e.default,"default"),day:n(e.day,"day"),night:n(e.night,"night"),hours:r,seasons:i}}constructor(e=6,t=18){this.#es=e,this.#ts=t}addSeason(e,t){if(jr(this.#ur),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);if(!Array.isArray(t)||!t.every(e=>"number"==typeof e))throw new TypeError("Season values must be an array of numbers");this.#Qi.set(e,t)}removeSeason(e){if(jr(this.#ur),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);this.#Qi.delete(e),this.#os===e&&(this.#os="")}hasSeason(e){if(jr(this.#ur),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);return this.#Qi.has(e)}getSeason(e){if(jr(this.#ur),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);const t=this.#Qi.get(e);if(!t)throw new Error(`Season "${e}" not found`);return[...t]}setTime({hour:e=0,minute:t=0,second:r=0}){jr(this.#ur),this.currentSeconds=(e*this.#Yi+t*this.#Xi+r)%this.#Gi}addTime({hours:e=0,minutes:t=0,seconds:r=0}){jr(this.#ur);let i=this.currentSeconds+e*this.#Yi+t*this.#Xi+r;for(;i>=this.#Gi;)i-=this.#Gi,this.nextDay();for(;i<0;)i+=this.#Gi,this.prevDay();this.currentSeconds=i,this.updateWeatherTimer((e*this.#Yi+t*this.#Xi+r)/this.#Xi)}getTime({withSeconds:e=!1,hourSize:t=this.#Yi,minuteSize:r=this.#Xi}={}){jr(this.#ur);const i=Math.floor(this.currentSeconds/t),s=Math.floor(this.currentSeconds%t/r),n=this.currentSeconds%r;return{hour:i,minute:s,second:n,formatted:`${i.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`+(e?`:${n.toString().padStart(2,"0")}`:"")}}isDay(){return jr(this.#ur),this.#es<this.#ts?this.#ss>=this.#es*this.#Xi&&this.#ss<this.#ts*this.#Xi:this.#ss>=this.#es*this.#Xi||this.#ss<this.#ts*this.#Xi}minutesUntilDay(){return this.timeUntil(this.#es,"minutes")}secondsUntilDay(){return this.timeUntil(this.#es,"seconds")}hoursUntilDay(){return this.timeUntil(this.#es,"hours")}minutesUntilNight(){return this.timeUntil(this.#ts,"minutes")}secondsUntilNight(){return this.timeUntil(this.#ts,"seconds")}hoursUntilNight(){return this.timeUntil(this.#ts,"hours")}timeUntil(e,t){jr(this.#ur);let r=e*this.#Yi-this.#is;switch(r<=0&&(r+=this.#Gi),t){case"minutes":return r/this.#Xi;case"hours":return r/this.#Yi;default:return r}}setTo(e){jr(this.#ur),"day"===e?this.setTime({hour:this.#es}):"night"===e&&this.setTime({hour:this.#ts})}nextDay(e=1){jr(this.#ur);for(let t=0;t<e;t++){this.#as++;const e=this.#hs[this.#ls-1];if(Number.isNaN(e)||!Number.isFinite(e))throw new Error("Invalid month day count: monthDays must be a finite number.");this.#as>e&&(this.#as=1,this.#ls++,this.#ls>this.#hs.length&&(this.#ls=1,this.#us++)),this.updateSeason(),this.advanceMoons(1)}}prevDay(e=1){jr(this.#ur);for(let t=0;t<e;t++)this.#as--,this.#as<1&&(this.#ls--,this.#ls<1&&(this.#ls=this.#hs.length,this.#us--),this.#as=this.#hs[this.#ls-1]||30),this.updateSeason(),this.rewindMoons(1)}updateSeason(){jr(this.#ur),this.#Qi.forEach((e,t)=>{e.includes(this.#ls)&&(this.#os=t)})}setWeatherConfig(e){jr(this.#ur),this.#cs={...this.#cs,...e}}setWeatherDuration(e,t){jr(this.#ur),this.#ds.min=e,this.#ds.max=t}updateWeatherTimer(e){jr(this.#ur),this.#ms-=e,this.#ms<=0&&this.chooseNewWeather()}forceWeather({where:e="main",type:t,duration:r=null}){jr(this.#ur);const i=this.#rs;i[e]=t,this.weather=i,this.#ms=r??this._randomInRange(this.#ds.min,this.#ds.max)}chooseNewWeather({customWeather:e,where:t="main"}={}){jr(this.#ur);let r={};const i=e=>{for(const[t,i]of Object.entries(e)){let e=i;"function"==typeof e&&(e=e({hour:Math.floor(this.#ss/this.#Xi),minute:this.#ss%this.#Xi,currentMinutes:this.#ss,isDay:this.isDay(),season:this.#os,weather:this.#rs})),"number"!=typeof e||Number.isNaN(e)||(r[t]=(r[t]||0)+e)}};i(this.#cs.default||{});for(const e in this.#cs.hours){const[t,r]=e.split("-").map(e=>{const[t,r]=e.split(":").map(Number);return t*this.#Xi+(r||0)}),s=this.#ss;(t<=r?s>=t&&s<=r:s>=t||s<=r)&&i(this.#cs.hours[e])}this.isDay()&&this.#cs.day?i(this.#cs.day):!this.isDay()&&this.#cs.night&&i(this.#cs.night),this.#cs.seasons?.[this.#os]&&i(this.#cs.seasons[this.#os]),e&&"object"==typeof e&&i(e);const s=Object.entries(r).filter(([,e])=>e>0);if(!s.length)return this.#rs[t]=null,null;const n=s.reduce((e,[,t])=>e+t,0);let o=Math.random()*n;for(const[e,r]of s){if(o<r)return this.#rs[t]=e,this.#ms=this._randomInRange(this.#ds.min,this.#ds.max),e;o-=r}return this.#rs[t]=null,null}_randomInRange(e,t){return Math.floor(Math.random()*(t-e+1))+e}addMoon(e,t,r,i=0){jr(this.#ur);const s=Math.max(1,t);return this.#Zi.push({name:e,cycleLength:s,currentPhase:(i%s+s)%s,phaseNames:r}),this.#Zi.length-1}removeMoon(e){jr(this.#ur),this.#Zi=this.#Zi.filter(t=>t.name!==e)}advanceMoons(e=1){for(const t in this.#Zi)this.advanceMoon(parseInt(t),e)}rewindMoons(e=1){for(const t in this.#Zi)this.rewindMoon(parseInt(t),e)}advanceMoon(e,t=1){jr(this.#ur);const r=this.#Zi[e];if(!r)throw new RangeError(`No moon found at index ${e}`);r.currentPhase=(r.currentPhase+t)%r.cycleLength}rewindMoon(e,t=1){jr(this.#ur);const r=this.#Zi[e];if(!r)throw new RangeError(`No moon found at index ${e}`);r.currentPhase=(r.currentPhase-t+r.cycleLength)%r.cycleLength}moonExists(e){return jr(this.#ur),!!this.#Zi[e]}getMoon(e){let t;if(jr(this.#ur),"number"==typeof e){if(t=this.#Zi[e],!t)throw new RangeError(`No moon found at index ${e}`)}else{if(!e||"object"!=typeof e||"string"!=typeof e.name||"number"!=typeof e.cycleLength||"number"!=typeof e.currentPhase)throw new TypeError("Invalid moon reference. Expected a number index or a MoonRaw object, received "+typeof e);t=e}return{name:t.name,phaseIndex:t.currentPhase,phaseName:t.phaseNames?t.phaseNames[t.currentPhase]??String(t.currentPhase):String(t.currentPhase),cycleLength:t.cycleLength}}destroy(){this.#ur||(this.#Qi.clear(),this.#Zi.length=0,this.#es=0,this.#ts=0,this.#is=0,this.#ss=0,this.#ns=0,this.#as=1,this.#ls=1,this.#us=1,this.#ms=0,this.#os="",this.#rs={main:null},this.#hs=[],this.#cs.default={},this.#cs.day={},this.#cs.night={},this.#cs.hours={},this.#cs.seasons={},this.#ds={min:0,max:0},this.#ur=!0)}},Pr=ee("TinyAdvancedRaffle");class $r extends sr.EventEmitter{#ur=!1;#ps;#fs;#ys=[];#gs=[];#bs=[];#ws=new Map;#vs=new Set;#Es=new Map;#Ts;#Ss=new Map;#xs=new Map;get isDestroyed(){return this.#ur}get freq(){return Pr(this.#ur),Object.fromEntries(this.#xs)}get size(){return Pr(this.#ur),this.#Ss.size}get normalization(){return Pr(this.#ur),this.#ps}set normalization(e){if(Pr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("normalization must be a non-empty string (e.g., 'relative', 'softmax').");this.#ps=e}get seed(){return Pr(this.#ur),this.#fs}set seed(e){if(Pr(this.#ur),null!==e&&("number"!=typeof e||!Number.isFinite(e)))throw new TypeError("seed must be a finite number or null.");this.#fs=e,null!==e&&(this.#Ts=this._makeSeededRng(e))}get globalModifiers(){return Pr(this.#ur),[...this.#ys]}set globalModifiers(e){if(Pr(this.#ur),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("globalModifiers must be an array of functions (WeightsCallback).");this.#ys=e}get temporaryModifiers(){return Pr(this.#ur),[...this.#gs]}set temporaryModifiers(e){if(Pr(this.#ur),!Array.isArray(e)||!e.every(e=>e&&"function"==typeof e.fn&&Number.isInteger(e.uses)&&e.uses>0))throw new TypeError("temporaryModifiers must be an array of objects { fn: function, uses: positive integer }.");this.#gs=e}get conditionalRules(){return Pr(this.#ur),[...this.#bs]}set conditionalRules(e){if(Pr(this.#ur),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("conditionalRules must be an array of functions (WeightsCallback).");this.#bs=e}get pitySystems(){return Pr(this.#ur),Object.fromEntries(this.#ws)}set pitySystems(e){if(Pr(this.#ur),!(e instanceof Map&&[...e.values()].every(e=>e&&"number"==typeof e.threshold&&"number"==typeof e.increment&&"number"==typeof e.cap&&"number"==typeof e.counter&&"number"==typeof e.currentAdd)))throw new TypeError("pitySystems must be a Map<string, Pity> with all numeric fields.");this.#ws=e}get exclusions(){return Pr(this.#ur),Array.from(this.#vs)}set exclusions(e){if(Pr(this.#ur),!(e instanceof Set&&[...e].every(e=>"string"==typeof e)))throw new TypeError("exclusions must be a Set<string>.");this.#vs=e}get groups(){Pr(this.#ur);const e={};return this.#Es.forEach((t,r)=>e[r]=Array.from(t)),e}set groups(e){if(Pr(this.#ur),!(e instanceof Map&&[...e.values()].every(e=>e instanceof Set&&[...e].every(e=>"string"==typeof e))))throw new TypeError("groups must be a Map<string, Set<string>>.");this.#Es=e}get rng(){return Pr(this.#ur),this.#Ts}set rng(e){if(Pr(this.#ur),"function"!=typeof e||"number"!=typeof e())throw new TypeError("rng must be a function returning a number (RngGenerator).");this.#Ts=e}get items(){Pr(this.#ur);const e={};return this.#Ss.forEach((t,r)=>{e[r]={...t,groups:Array.from(t.groups)}}),e}set items(e){if(Pr(this.#ur),!(e instanceof Map&&[...e.values()].every(e=>e&&"string"==typeof e.id&&"string"==typeof e.label&&"number"==typeof e.baseWeight&&e.groups instanceof Set&&"boolean"==typeof e.locked&&"object"==typeof e.meta)))throw new TypeError("items must be a Map<string, ItemData> with valid item structures.");this.clearList(),this.#Ss=e}constructor(e={}){super();const{rng:t=null,seed:r=null,normalization:i="relative"}=e;this.#ps=i,this.#fs=r,"function"==typeof t?this.#Ts=t:null!==this.#fs?this.#Ts=this._makeSeededRng(this.#fs):this.#Ts=Math.random,this.#fs=r??null}hasItem(e){if(Pr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#Ss.has(e)}addItem(e,t={}){if(Pr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");if("object"!=typeof t||null===t)throw new TypeError("opts must be an object");let{weight:r=1,label:i=e,meta:s={},groups:n=[]}=t;if("number"!=typeof r||!Number.isFinite(r)||r<0)throw new TypeError("weight must be a non-negative number");if("string"!=typeof i)throw new TypeError("label must be a string");if("object"!=typeof s||null===s)throw new TypeError("meta must be an object");if(!(Array.isArray(n)||n instanceof Set))throw new TypeError("groups must be an array or a Set of strings");n=Array.isArray(n)?n:[...n];for(const e of n)if("string"!=typeof e)throw new TypeError("groups must contain only strings");const o={id:e,label:i,baseWeight:Math.max(0,Number(r)||0),meta:{...s},groups:new Set(n),locked:!1};this.#Ss.set(e,o);for(const t of n)this._ensureGroup(t).add(e);return this.emit("itemAdded",o),o}removeItem(e){if(Pr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");const t=this.#Ss.get(e);if(!t)return!1;for(const r of t.groups){const t=this.#Es.get(r);t&&t.delete(e)}return this.#Ss.delete(e),this.emit("itemRemoved",e),this.resetFreq(e),this.resetPity(e),!0}setBaseWeight(e,t){if(Pr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");if("number"!=typeof t||!Number.isFinite(t)||t<0)throw new TypeError("weight must be a non-negative number");const r=this.#Ss.get(e);if(!r)throw new Error("Item not found");r.baseWeight=Math.max(0,Number(t)||0),this.emit("weightChanged",{id:e,weight:r.baseWeight})}getItem(e){if(Pr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");return this.#Ss.get(e)??null}listItems(){return Pr(this.#ur),Array.from(this.#Ss.values()).map(e=>({...e}))}clearList(){Pr(this.#ur),this.#Ss.clear(),this.clearFreqs(),this.clearPities()}hasGlobalModifier(e){if(Pr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");return this.#ys.includes(e)}addGlobalModifier(e){if(Pr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");this.#ys.push(e)}removeGlobalModifier(e){if(Pr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");this.#ys=this.#ys.filter(t=>t!==e)}hasTemporaryModifier(e){if(Pr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");return this.#gs.some(t=>t.fn===e)}addTemporaryModifier(e,t=1){if(Pr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");if("number"!=typeof t||Number.isNaN(t))throw new TypeError("uses must be a number");this.#gs.push({fn:e,uses:Math.max(1,Math.floor(t))})}removeTemporaryModifier(e){if(Pr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");const t=this.#gs.length;return this.#gs=this.#gs.filter(t=>t.fn!==e),this.#gs.length!==t}hasConditionalRule(e){if(Pr(this.#ur),"function"!=typeof e)throw new TypeError("ruleFn must be a function");return this.#bs.includes(e)}addConditionalRule(e){if(Pr(this.#ur),"function"!=typeof e)throw new TypeError("ruleFn must be a function");this.#bs.push(e)}removeConditionalRule(e){if(Pr(this.#ur),"function"!=typeof e)throw new TypeError("ruleFn must be a function");const t=this.#bs.length;return this.#bs=this.#bs.filter(t=>t!==e),this.#bs.length!==t}hasPity(e){if(Pr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#ws.has(e)}configurePity(e,t){if(Pr(this.#ur),!this.#Ss.has(e))throw new Error("Item not found");if("object"!=typeof t||null===t)throw new TypeError("cfg must be an object");const{threshold:r,increment:i,cap:s=1/0}=t;if("number"!=typeof r||r<=0)throw new TypeError("threshold must be a positive number");if("number"!=typeof i)throw new TypeError("increment must be a number");if("number"!=typeof s)throw new TypeError("cap must be a number");this.#ws.set(e,{threshold:Math.max(1,r),increment:Number(i)||0,cap:Number(s)||1/0,counter:0,currentAdd:0})}resetPity(e){if(Pr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("itemId must be a non-empty string");const t=this.#ws.get(e);t&&(t.counter=0,t.currentAdd=0)}clearPities(){Pr(this.#ur),this.#ws.clear()}hasExclusion(e){if(Pr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#vs.has(e)}excludeItem(e){if(Pr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#vs.add(e)}includeItem(e){if(Pr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#vs.delete(e)}_ensureGroup(e){if(Pr(this.#ur),"string"!=typeof e)throw new TypeError("name must be a string");let t=this.#Es.get(e);return t||(t=new Set,this.#Es.set(e,t)),t}hasInGroup(e,t){if(Pr(this.#ur),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#Es.get(t);return!!r&&r.has(e)}addToGroup(e,t){if(Pr(this.#ur),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#Ss.get(e);if(!r)throw new Error("Item missing");r.groups.add(t),this._ensureGroup(t).add(e)}removeFromGroup(e,t){if(Pr(this.#ur),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#Es.get(t);r&&r.delete(e);const i=this.#Ss.get(e);i&&i.groups.delete(t)}clearFreqs(){Pr(this.#ur),this.#xs.clear()}resetFreq(e){if(Pr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#xs.delete(e)}computeEffectiveWeights(e={}){if(Pr(this.#ur),"object"!=typeof e||null===e)throw new TypeError("computeEffectiveWeights: parameter 'context' must be a non-null object, got "+typeof e);if("previousDraws"in e&&!Array.isArray(e.previousDraws))throw new TypeError("computeEffectiveWeights: context.previousDraws must be an array if provided, got "+typeof e.previousDraws);if("metadata"in e&&void 0!==e.metadata&&("object"!=typeof e.metadata||null===e.metadata))throw new TypeError("computeEffectiveWeights: context.metadata must be a non-null object if provided, got "+typeof e.metadata);const t=new Map;for(const[e,r]of this.#Ss)t.set(e,r.baseWeight);for(const r of this.#ys){const i=r(t,e);if(i instanceof Map)for(const[e,r]of i)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#gs){const i=r.fn(t,e);if(i instanceof Map)for(const[e,r]of i)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#bs){const i=r(t,e);if(i instanceof Map)for(const[e,r]of i)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const[e,r]of this.#ws)if(t.has(e)&&r.counter>r.threshold){r.currentAdd=Math.min(r.cap,r.currentAdd+r.increment);const i=t.get(e);i&&t.set(e,i+r.currentAdd)}for(const e of this.#vs)t.delete(e);for(const[e,r]of Array.from(t.entries()))r>0||t.delete(e);return t}_weightsToDistribution(e){if(!(e instanceof Map))throw new TypeError("_weightsToDistribution: parameter 'weights' must be a Map, got "+typeof e);for(const[t,r]of e){if("string"!=typeof t)throw new TypeError("_weightsToDistribution: weights Map key must be string, got "+typeof t);if("number"!=typeof r||!Number.isFinite(r)||r<0)throw new TypeError(`_weightsToDistribution: weights Map value must be finite non-negative number, got ${r} for key ${t}`)}const t=Array.from(e.entries()).map(([e,t])=>({id:e,weight:t}));if(0===t.length)return[];if("softmax"===this.#ps){const e=Math.max(...t.map(e=>e.weight)),r=t.map(t=>Math.exp(t.weight-e)),i=r.reduce((e,t)=>e+t,0);let s=0;return t.map((e,t)=>{const n=r[t]/i;return s+=n,{id:e.id,weight:e.weight,p:n,cumulative:s}})}{const e=t.reduce((e,t)=>e+t.weight,0);let r=0;return t.map(t=>{const i=t.weight/e;return r+=i,{id:t.id,weight:t.weight,p:i,cumulative:r}})}}drawOne(e={}){if(Pr(this.#ur),"object"!=typeof e||null===e)throw new TypeError("drawOne: parameter 'opts' must be a non-null object, got "+typeof e);if("previousDraws"in e&&!Array.isArray(e.previousDraws))throw new TypeError("drawOne: opts.previousDraws must be an array if provided, got "+typeof e.previousDraws);if("metadata"in e&&void 0!==e.metadata&&("object"!=typeof e.metadata||null===e.metadata))throw new TypeError("drawOne: opts.metadata must be a non-null object if provided, got "+typeof e.metadata);const t={previousDraws:e.previousDraws??[],metadata:e.metadata??{},activeModifiers:[...this.#gs]},r=this.computeEffectiveWeights(t),i=this._weightsToDistribution(r);if(!i.length)return null;const s=this.#Ts(),n=i.find(e=>s<=e.cumulative)??i[i.length-1];for(const[e,t]of this.#ws)e===n.id?(t.counter=0,t.currentAdd=0):t.counter++;this._consumeTemporaryModifiers();const o=this.#Ss.get(n.id);if(!o)return null;const a={id:o.id,label:o.label,meta:{...o.meta},prob:n.p};return this.emit("draw",a),a&&this.#xs.set(a.id,(this.#xs.get(a.id)||0)+1),a}_consumeTemporaryModifiers(){for(let e=this.#gs.length-1;e>=0;--e){const t=this.#gs[e];t.uses-=1,t.uses<=0&&this.#gs.splice(e,1)}}drawMany(e=1,t={}){if(Pr(this.#ur),!Number.isInteger(e)||e<=0)throw new TypeError(`drawMany: parameter 'count' must be a positive integer, got ${e}`);if("object"!=typeof t||null===t)throw new TypeError("drawMany: parameter 'opts' must be a non-null object, got "+typeof t);if("withReplacement"in t&&"boolean"!=typeof t.withReplacement)throw new TypeError("drawMany: opts.withReplacement must be boolean if provided, got "+typeof t.withReplacement);if("ensureUnique"in t&&"boolean"!=typeof t.ensureUnique)throw new TypeError("drawMany: opts.ensureUnique must be boolean if provided, got "+typeof t.ensureUnique);if("metadata"in t&&void 0!==t.metadata&&("object"!=typeof t.metadata||null===t.metadata))throw new TypeError("drawMany: opts.metadata must be a non-null object if provided, got "+typeof t.metadata);if("previousDraws"in t&&!Array.isArray(t.previousDraws))throw new TypeError("drawMany: opts.previousDraws must be an array if provided, got "+typeof t.previousDraws);const r=t.withReplacement??!0,i=t.ensureUnique??!1,s=[],n=t.previousDraws??[];if(!r&&i){const r=new Set;for(let i=0;i<e;++i){const e=new Set(this.#vs);for(const e of r)this.#vs.add(e);const i=this.drawOne({previousDraws:n,metadata:t.metadata});if(this.#vs=e,!i)break;s.push(i),r.add(i.id),n.push(i)}return s}for(let i=0;i<e;++i){const e=this.drawOne({previousDraws:n,metadata:t.metadata});if(!e)break;s.push(e),n.push(e),r||this.excludeItem(e.id)}if(!r)for(const e of s)this.includeItem(e.id);return s}exportToJson(){return Pr(this.#ur),{items:Array.from(this.#Ss.values()).map(e=>({id:e.id,label:e.label,baseWeight:e.baseWeight,meta:e.meta,groups:Array.from(e.groups),locked:!1})),pity:Array.from(this.#ws.entries()),exclusions:Array.from(this.#vs),normalization:this.#ps,seed:this.#fs}}loadFromJson(e){if(Pr(this.#ur),"object"!=typeof e||null===e)throw new TypeError("data must be a non-null object");if(!Array.isArray(e.items)||!Array.isArray(e.pity)||!Array.isArray(e.exclusions))throw new TypeError("data must have items, pity, and exclusions arrays");if("string"!=typeof e.normalization)throw new TypeError("data.normalization must be a string");if(void 0!==e.seed&&null!==e.seed&&"number"!=typeof e.seed)throw new TypeError("data.seed must be a number, null, or undefined");this.clearList();for(const t of e.items){if("object"!=typeof t||null===t)throw new TypeError("Each item must be a non-null object");if("string"!=typeof t.id||!t.id.trim())throw new TypeError("Each item.id must be a non-empty string");if("string"!=typeof t.label)throw new TypeError(`Item with id "${t.id}" has invalid label; must be string`);if("number"!=typeof t.baseWeight||!Number.isFinite(t.baseWeight)||t.baseWeight<0)throw new TypeError(`Item with id "${t.id}" has invalid baseWeight; must be a finite non-negative number`);if(void 0!==t.groups&&!Array.isArray(t.groups))throw new TypeError(`Item with id "${t.id}" has invalid groups; must be an array of strings`);if(t.groups&&!t.groups.every(e=>"string"==typeof e))throw new TypeError(`Item with id "${t.id}" has groups containing non-string values`);if(void 0!==t.meta&&("object"!=typeof t.meta||null===t.meta))throw new TypeError(`Item with id "${t.id}" has invalid meta; must be an object`);this.#Ss.set(t.id,{id:t.id,label:t.label,baseWeight:t.baseWeight,meta:t.meta||{},groups:new Set(t.groups||[]),locked:!1});for(const e of t.groups||[])this._ensureGroup(e).add(t.id)}this.pitySystems=new Map(e.pity||[]),this.exclusions=new Set(e.exclusions||[]),this.normalization=e.normalization,void 0!==e.seed&&(this.seed=e.seed)}clone(){Pr(this.#ur);const e=new $r;return e.#ps=this.#ps,e.#fs=this.#fs,e.#ys=[...this.#ys],e.#gs=this.#gs.map(e=>({fn:e.fn,uses:e.uses})),e.#bs=[...this.#bs],e.#ws=new Map([...this.#ws.entries()].map(([e,t])=>[e,{...t}])),e.#vs=new Set(this.#vs),e.#Es=new Map([...this.#Es.entries()].map(([e,t])=>[e,new Set(t)])),e.#Ts=this.#Ts,e.#Ss=new Map([...this.#Ss.entries()].map(([e,t])=>[e,{...t,groups:new Set(t.groups),meta:{...t.meta}}])),e.#xs=new Map(this.#xs),e}_makeSeededRng(e){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("seed must be a finite number");let t=e>>>0;return function(){t+=1831565813;let e=Math.imul(t^t>>>15,1|t);return e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}destroy(){this.#ur||(this.#ws.clear(),this.#vs.clear(),this.#Es.clear(),this.#Ss.clear(),this.#xs.clear(),this.#ys=[],this.#gs=[],this.#bs=[],this.#fs=null,this.#ur=!0)}}const Or=$r,Hr=class{#ie;get data(){return this.#ie}set data(e){if(!(Array.isArray(e)||e instanceof Set))throw new TypeError("Paginator expects an array or Set as data source.");this.#ie=e}get size(){return Array.isArray(this.#ie)?this.#ie.length:this.#ie.size}constructor(e){if(!(Array.isArray(e)||e instanceof Set))throw new TypeError("Paginator expects an array or Set as data source.");this.#ie=e}get({page:e,perPage:t,filter:r}){if(!Number.isInteger(e)||e<1)throw new RangeError("Page number must be a positive integer.");if(!Number.isInteger(t)||t<1)throw new RangeError("Items per page must be a positive integer.");const i=Array.isArray(this.#ie)?this.#ie:Array.from(this.#ie);let s=i;if(r)if("function"==typeof r)s=i.filter((e,t,i)=>r(e,t,i));else{if("object"!=typeof r)throw new TypeError("Filter must be an object or a function");s=i.filter(e=>Object.entries(r).every(([t,r])=>{const i=e[t];return r instanceof RegExp?r.test(i):i===r}))}else s=i;const n=s.length,o=Math.max(1,Math.ceil(n/t)),a=Math.min(e,o),l=(a-1)*t,u=l+t,h=a>1,c=a<o;return{items:s.slice(l,u),page:a,perPage:t,totalItems:n,totalPages:o,hasPrev:h,hasNext:c}}};class Fr{static#As=new Map;static get itemRegistry(){const e={},t=Object.fromEntries(Fr.#As);for(const r in t)e[r]={...t[r],metadata:{...t[r].metadata}};return e}static defineItem(e){if(!e||"object"!=typeof e)throw new TypeError("Config must be a valid object.");if(!e.id||"string"!=typeof e.id)throw new TypeError("Item must have a valid string 'id'.");if(void 0!==e.weight&&("number"!=typeof e.weight||e.weight<0))throw new TypeError(`weight must be a number >= 0. Received: ${e.weight}`);if(void 0!==e.maxStack&&(!Number.isInteger(e.maxStack)||e.maxStack<=0))throw new TypeError(`maxStack must be a positive integer. Received: ${e.maxStack}`);if(void 0!==e.metadata&&"object"!=typeof e.metadata)throw new TypeError("metadata must be an object.");if(void 0!==e.onUse&&null!==e.onUse&&"function"!=typeof e.onUse)throw new TypeError("onUse must be a function or null.");if(void 0!==e.type&&null!==e.type&&"string"!=typeof e.type)throw new TypeError("type must be a string or null.");Fr.#As.set(e.id,{id:e.id,weight:e.weight||0,maxStack:e.maxStack||1,metadata:e.metadata||{},type:e.type??null,onUse:"function"==typeof e.onUse?e.onUse:null})}static removeItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");return Fr.#As.delete(e)}static hasItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");return Fr.#As.has(e)}static getItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");const t=Fr.#As.get(e);if(!t)throw new Error(`Item '${e}' not defined in registry.`);return t}#Cs=new Map;#Is={add:[],remove:[],use:[],set:[]};#Ss=[];#Ms;#Ds;#ks;#Ns;get maxStack(){return this.#Ms}set maxStack(e){if(!Number.isInteger(e)||Number.isFinite(e)&&e<=0)throw new TypeError(`maxStack must be a positive integer. Received: ${e}`);this.#Ms=e}get maxSize(){return this.#Ds}set maxSize(e){if(null!==e&&(!Number.isInteger(e)||e<=0))throw new TypeError(`maxSize must be null or a positive integer. Received: ${e}`);this.#Ds=e}get maxSlots(){return this.#ks}set maxSlots(e){if(null!==e&&(!Number.isInteger(e)||e<=0))throw new TypeError(`maxSlots must be null or a positive integer. Received: ${e}`);this.#ks=e}get maxWeight(){return this.#Ns}set maxWeight(e){if(null!==e&&("number"!=typeof e||e<=0))throw new TypeError(`maxWeight must be null or a positive number. Received: ${e}`);this.#Ns=e}get events(){return{add:[...this.#Is.add],remove:[...this.#Is.remove],use:[...this.#Is.use],set:[...this.#Is.set]}}get items(){return[...this.#Ss].map(e=>e?this.#Ls(e):null)}get specialSlots(){return new Map([...this.#Cs.entries()].map(([e,t])=>[e,{type:t.type,item:t.item?this.#Ls(t.item):null}]))}get size(){const e=this.getAllItems();let t=0;for(const r of e)t+=r.quantity;return t}get slotsSize(){return this.getAllItems().length}get weight(){return this.getAllItems().reduce((e,t)=>{const r=Fr.getItem(t.id);return e+(r?.weight||0)*t.quantity},0)}_cleanNulls(){let e=this.#Ss.length-1;for(;e>=0&&null===this.#Ss[e];)e--;this.#Ss=this.#Ss.slice(0,e+1)}constructor(e={}){if("object"!=typeof e||null===e)throw new TypeError("`options` must be an object.");if(void 0!==e.maxWeight&&null!==e.maxWeight&&"number"!=typeof e.maxWeight)throw new TypeError("`maxWeight` must be a number or null.");if(void 0!==e.maxSlots&&null!==e.maxSlots&&"number"!=typeof e.maxSlots)throw new TypeError("`maxSlots` must be a number or null.");if(void 0!==e.maxSize&&null!==e.maxSize&&"number"!=typeof e.maxSize)throw new TypeError("`maxSize` must be a number or null.");if(void 0!==e.maxStack&&"number"!=typeof e.maxStack)throw new TypeError("`maxStack` must be a number.");if(void 0!==e.specialSlots&&"object"!=typeof e.specialSlots)throw new TypeError("`specialSlots` must be an object if defined.");if(this.#Ns=e.maxWeight??null,this.#ks=e.maxSlots??null,this.#Ds=e.maxSize??null,this.#Ms=e.maxStack??1/0,e.specialSlots)for(const t in e.specialSlots){const r=e.specialSlots[t];if("object"!=typeof r||null===r)throw new TypeError("Each `specialSlot` entry must be an object.");if(void 0!==r.type&&null!==r.type&&"string"!=typeof r.type)throw new TypeError("`specialSlot.type` must be a string or null.");this.#Cs.set(t,{type:r.type??null,item:null})}}hasSpace({weight:e=0,sizeLength:t=0,slotsLength:r=0}={}){if("number"!=typeof e)throw new TypeError("`weight` must be a number.");if("number"!=typeof t)throw new TypeError("`sizeLength` must be a number.");if("number"!=typeof r)throw new TypeError("`slotsLength` must be a number.");return!(this.areFull(t)||this.areFullSlots(r)||this.isHeavy(e))}isHeavy(e=0){if("number"!=typeof e)throw new TypeError("`extraWeight` must be a number.");return null!==this.#Ns&&this.weight+e>this.#Ns}areFull(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Ds&&this.size+e>this.#Ds}isFull(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Ds&&this.size+e>=this.#Ds}areFullSlots(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#ks&&this.slotsSize+e>this.#ks}isFullSlots(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#ks&&this.slotsSize+e>=this.#ks}#_s(e,t){if("string"!=typeof e)throw new TypeError("`type` must be a string.");if("object"!=typeof t||null===t)throw new TypeError("`payload` must be an object.");if(this.#Is[e])for(const r of this.#Is[e])r(t)}off(e,t){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");if("function"!=typeof t)throw new TypeError("`callback` must be a function.");if(!this.#Is[e])return;const r=this.#Is[e],i=r.indexOf(t);-1!==i&&r.splice(i,1)}offAll(e){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");this.#Is[e]&&(this.#Is[e]=[])}cloneEventCallbacks(e){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");return this.#Is[e]?[...this.#Is[e]]:[]}onAddItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Is.add.push(e)}onSetItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Is.set.push(e)}onRemoveItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Is.remove.push(e)}onUseItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Is.use.push(e)}compactInventory(){this.#Ss=this.#Ss.filter((e,t)=>{const r=null!==e;return r||this.#_s("remove",{index:t,item:null,isCollection:!0,specialSlot:null,remove:()=>{}}),r})}addItem({itemId:e,quantity:t=1,metadata:r={},forceSpace:i=!1}){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");if("number"!=typeof t||!Number.isFinite(t)||t<=0)throw new TypeError("`quantity` must be a positive number.");if("object"!=typeof r||null===r)throw new TypeError("`metadata` must be an object.");if("boolean"!=typeof i)throw new TypeError("`forceSpace` must be a boolean.");const s=Fr.getItem(e);let n=t;const o=s.maxStack<=this.#Ms?s.maxStack:this.#Ms,a=[],l=(e,t)=>JSON.stringify(e)===JSON.stringify(t);let u=!0;for(;n>0&&u;){u=!1;for(const t in this.#Ss){const h=this.#Ss[t];if(h&&h.id===e&&h.quantity<o&&l(h.metadata,r)){const e=Math.min(o-h.quantity,n);if(!i&&!this.hasSpace({weight:s.weight*e,sizeLength:e}))continue;h.quantity+=e,n-=e,u=!0;const r=Number(t),l=a.findIndex(e=>e.index===r);if(l<0?a.push({index:r,quantity:e}):a[l].quantity+=e,this.#_s("add",{item:this.#Ls(h),index:r,isCollection:!0,specialSlot:null,remove:this.#js({locationType:"normal",slotIndex:r,forceSpace:i,item:h})}),n<=0)break}}}if(n>0)for(const t in this.#Ss)if(null===this.#Ss[t]){const l=Math.min(o,n);if(!i&&!this.hasSpace({weight:s.weight*l,sizeLength:l}))continue;const u={id:e,quantity:l,metadata:r};this.#Ss[t]=u,n-=l;const h=Number(t),c=a.findIndex(e=>e.index===h);if(c<0?a.push({index:h,quantity:l}):a[c].quantity+=l,this.#_s("add",{item:this.#Ls(u),index:h,isCollection:!0,specialSlot:null,remove:this.#js({locationType:"normal",slotIndex:h,forceSpace:i,item:u})}),n<=0)break}for(;n>0;){const t=Math.min(o,n);if(!i&&!this.hasSpace({weight:s.weight*t,sizeLength:t,slotsLength:1}))break;const l={id:e,quantity:t,metadata:r};this.#Ss.push(l);const u=this.#Ss.length-1,h=a.findIndex(e=>e.index===u);h<0?a.push({index:u,quantity:t}):a[h].quantity+=t,this.#_s("add",{item:this.#Ls(l),index:u,isCollection:!0,specialSlot:null,remove:this.#js({locationType:"normal",slotIndex:u,forceSpace:i,item:l})}),n-=t}return{remaining:n,placesAdded:a}}getItemFrom(e){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if(e<0||e>=this.#Ss.length)throw new Error(`Slot index '${e}' out of bounds .`);return this.#Ss[e]?this.#Ls(this.#Ss[e]):null}setItem({slotIndex:e,item:t,forceSpace:r=!1}){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be a boolean.");const i=t&&"object"==typeof t&&"string"==typeof t.id&&"number"==typeof t.quantity&&!Number.isNaN(t.quantity)&&Number.isFinite(t.quantity)&&t.quantity>-1&&"object"==typeof t.metadata;if(null!==t&&!i)throw new Error("Invalid item type: must be null or a valid InventoryItem.");const s=t?Fr.#As.get(t.id):null;if(null!==t&&!s)throw new Error(`Item '${t?.id??"unknown"}' not defined in registry.`);if(s&&t){const e=s.maxStack<=this.#Ms?s.maxStack:this.#Ms;if(t.quantity>e)throw new Error(`Item '${t.id}' exceeds max stack size. Allowed: ${e}, got: ${t.quantity}.`)}if(null!==this.#ks&&(e<0||e>=this.#ks))throw new Error(`Slot index ${e} out of range.`);const n=this.#Ss[e]??null,o=n?Fr.#As.get(n.id)??null:null,a=(e,t)=>t?t.weight*(e?e.quantity:0):0,l=e=>e?e.quantity:0;if(!r&&!this.hasSpace({weight:a(t,s)-a(n,o),sizeLength:l(t)-l(n)}))throw new Error("Inventory is full or overweight.");for(;this.#Ss.length<=e;)this.#Ss.push(null);this.#Ss[e]=t,this._cleanNulls(),this.#_s("set",{index:e,isCollection:!0,item:t?this.#Ls(t):null,specialSlot:null,remove:t?this.#js({locationType:"normal",slotIndex:e,forceSpace:r,item:t}):()=>{}})}deleteItem(e,t=!1){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if("boolean"!=typeof t)throw new TypeError("`forceSpace` must be a boolean.");this.setItem({slotIndex:e,item:null,forceSpace:t})}moveItem(e,t,r=!1){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`fromIndex` must be an integer.");if("number"!=typeof t||!Number.isInteger(t))throw new TypeError("`toIndex` must be an integer.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be a boolean.");const i=this.#Ss[e];if(!i)throw new Error(`No item found in slot ${e}.`);this.setItem({slotIndex:t,item:i,forceSpace:r}),this.setItem({slotIndex:e,item:null,forceSpace:r})}removeItem({itemId:e,metadata:t=null,quantity:r=1}){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");if(null!==t&&"object"!=typeof t)throw new TypeError("`metadata` must be an object or null.");if("number"!=typeof r||!Number.isFinite(r)||r<=0)throw new TypeError("`quantity` must be a positive number.");let i=r;const s=(e,t)=>JSON.stringify(e)===JSON.stringify(t);for(let r=0;r<this.#Ss.length;r++){const n=this.#Ss[r];if(n&&n.id===e&&(null===t||s(n.metadata,t))){const e=Math.min(n.quantity,i);n.quantity-=e,i-=e;const t=Number(r);if(n.quantity<=0&&(this.#Ss[r]=null),i<=0)return this._cleanNulls(),this.#_s("remove",{index:t,item:this.#Ls(n),isCollection:!0,specialSlot:null,remove:this.#js({locationType:"normal",slotIndex:t,item:n})}),!0}}return this._cleanNulls(),this.#Cs.forEach((r,n)=>{if(i>0&&r.item&&r.item.id===e&&(null===t||s(r.item.metadata,t))){const e=Math.min(r.item.quantity,i);r.item.quantity-=e,r.item.quantity<0&&(r.item.quantity=0),i-=e,r.item.quantity<=0&&(r.item=null),this.#Cs.set(n,r),this.#_s("remove",{index:null,item:r.item?this.#Ls(r.item):null,isCollection:!1,specialSlot:n,remove:r.item?this.#js({locationType:"special",specialSlot:n,item:r.item}):()=>{}})}}),i<=0}#js({locationType:e,specialSlot:t,slotIndex:r,item:i,forceSpace:s=!1}){if("normal"!==e&&"special"!==e)throw new TypeError("`locationType` must be 'normal' or 'special'.");if("boolean"!=typeof s)throw new TypeError("`forceSpace` must be boolean.");if(!i||"object"!=typeof i)throw new TypeError("`item` must be an InventoryItem object.");if("special"===e&&t&&"string"!=typeof t)throw new TypeError("`specialSlot` must be a string when locationType is 'special'.");if("normal"===e&&"number"!=typeof r)throw new TypeError("`slotIndex` must be a number when locationType is 'normal'.");return(n=s)=>{if("special"===e&&t){const e=this.#Cs.get(t);if(!e?.item)throw new Error(`Special slot '${t}' is empty.`);e.item.quantity>1?(e.item.quantity-=1,this.#Cs.set(t,e)):this.setSpecialSlot({slotId:t,item:null,forceSpace:n})}else{if("number"!=typeof r)throw new Error("Invalid remove operation: no valid slotIndex or specialSlot provided.");i.quantity>1?this.setItem({slotIndex:r,item:{...i,quantity:i.quantity-1},forceSpace:n}):this.setItem({slotIndex:r,item:null,forceSpace:n})}}}useItem({slotIndex:e,specialSlot:t,forceSpace:r=!1},...i){if(void 0!==e&&("number"!=typeof e||!Number.isInteger(e)))throw new TypeError("`slotIndex` must be an integer if provided.");if(void 0!==t&&"string"!=typeof t)throw new TypeError("`specialSlot` must be a string if provided.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");let s=null,n="normal",o=null;if(t){if(!this.#Cs.has(t))throw new Error(`Special slot '${t}' not found.`);s=this.#Cs.get(t).item,n="special"}else o=this.#Ss,s=o[e??-1]??null,n="normal";if(!s)throw new Error("special"===n?`No item found in special slot '${t}'.`:`No item found in slot ${e} of inventory.`);const a=Fr.getItem(s.id);if(a.onUse){const l={inventory:this,item:this.#Ls(s),index:e??null,specialSlot:t??null,isCollection:!!o,itemDef:a,remove:this.#js({locationType:n,specialSlot:t,slotIndex:e,forceSpace:r,item:s}),...i},u=a.onUse(l);return this.#_s("use",l),u}return null}hasSpecialSlot(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");return this.#Cs.has(e)}getSpecialItem(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(!this.#Cs.has(e))throw new Error(`Special slot '${e}' does not exist.`);const t=this.#Cs.get(e);return t?.item?this.#Ls(t.item):null}getSpecialSlotType(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(!this.#Cs.has(e))throw new Error(`Special slot '${e}' does not exist.`);const t=this.#Cs.get(e);return t?.type??null}setSpecialSlot({slotId:e,item:t,forceSpace:r=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");if(!this.#Cs.has(e))throw new Error(`Special slot '${e}' not found.`);const i=t&&"object"==typeof t&&"string"==typeof t.id&&"number"==typeof t.quantity&&!Number.isNaN(t.quantity)&&Number.isFinite(t.quantity)&&t.quantity>-1&&"object"==typeof t.metadata;if(null!==t&&!i)throw new Error("Invalid item type: must be null or a valid InventoryItem.");const s=t?Fr.#As.get(t.id):null;if(null!==t&&!s)throw new Error(`Item '${t?.id??"unknown"}' not defined in registry.`);const n=this.#Cs.get(e);if(!n)throw new Error(`Special slot ${e} out of range for slot '${e}'.`);const o=n.item?Fr.#As.get(n.item.id):null,a=(e,t)=>t?t.weight*(e?1:0):0,l=e=>e?1:0;if(!r&&!this.hasSpace({weight:a(t,s)-a(n.item,o),sizeLength:l(t)-l(n.item)}))throw new Error("Inventory is full or overweight.");n.item=t,this.#_s("set",{index:null,item:t?this.#Ls(t):null,isCollection:!1,specialSlot:e,remove:t?this.#js({locationType:"special",specialSlot:e,forceSpace:r,item:t}):()=>{}})}deleteSpecialItem(e,t=!1){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if("boolean"!=typeof t)throw new TypeError("`forceSpace` must be boolean.");this.setSpecialSlot({slotId:e,item:null,forceSpace:t})}equipItem({slotId:e,slotIndex:t,quantity:r=1,forceSpace:i=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if("number"!=typeof t||!Number.isInteger(t))throw new TypeError("`slotIndex` must be an integer.");if("number"!=typeof r||!Number.isFinite(r)||r<=0)throw new TypeError("`quantity` must be a positive number.");if("boolean"!=typeof i)throw new TypeError("`forceSpace` must be boolean.");if(r<=0||!Number.isFinite(r))throw new Error(`Invalid quantity '${r}'.`);if(!this.#Cs.has(e))throw new Error(`Special slot '${e}' does not exist.`);const s=this.getItemFrom(t);if(!s)throw new Error(`No item found in inventory slot ${t}.`);if(s.quantity<r)throw new Error(`Not enough quantity of item '${s.id}' in inventory slot.`);const n=Fr.getItem(s.id),o=this.#Cs.get(e);if(!o)throw new Error(`Slot '${e}' not defined in registry.`);const a=o.type??null;if(null!==a&&n.type!==a)throw new Error(`Item '${s.id}' cannot be equipped in slot '${e}'.`);const l=Math.min(n.maxStack,this.#Ms);if(o.item&&o.item.id===s.id){const t=Math.max(0,l-o.item.quantity);if(t<=0)return r;const i=Math.min(r,t);return this.removeItem({itemId:s.id,quantity:i,metadata:null}),o.item.quantity+=i,this.#Cs.set(e,o),r-i}o.item&&this.unequipItem({slotId:e,forceSpace:i});const u=Math.min(r,l);return this.removeItem({itemId:s.id,quantity:u,metadata:null}),o.item={id:s.id,quantity:u,metadata:s.metadata},this.#Cs.set(e,o),r-u}unequipItem({slotId:e,quantity:t=null,forceSpace:r=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(null!==t&&("number"!=typeof t||!Number.isFinite(t)||t<=0))throw new TypeError("`quantity` must be a positive number or null.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");if(!this.#Cs.has(e))throw new Error(`Special slot '${e}' does not exist.`);const i=this.#Cs.get(e);if(!i)throw new Error(`Slot '${e}' not defined in registry.`);if(!i.item)return!1;const s=i.item,n=null===t?s.quantity:t;if(n<=0)throw new Error(`Invalid unequip quantity: ${n}`);if(n>s.quantity)throw new Error(`Not enough items in slot '${e}' to unequip.`);return this.addItem({itemId:s.id,quantity:n,metadata:s.metadata,forceSpace:r}),n===s.quantity?i.item=null:(s.quantity-=n,i.item=s),this.#Cs.set(e,i),!0}#Ls(e){if(!e||"object"!=typeof e)throw new TypeError("`item` must be an InventoryItem object.");if("string"!=typeof e.id)throw new TypeError("`item.id` must be a string.");if("number"!=typeof e.quantity||!Number.isFinite(e.quantity))throw new TypeError("`item.quantity` must be a finite number.");if(!e.metadata||"object"!=typeof e.metadata)throw new TypeError("`item.metadata` must be an object.");return{id:e.id,quantity:e.quantity,metadata:{...e.metadata}}}getItemList(){return[...this.#Ss].map((e,t)=>[e?this.#Ls(e):null,t]).filter(e=>null!==e[0])}getAllItems(){const e=[...this.#Ss].filter(e=>null!==e).map(this.#Ls);return this.#Cs.forEach(t=>{const r=t.item;r&&e.push(r)}),e}getItemsByMetadata(e){if("function"!=typeof e)throw new TypeError("`filterFn` must be a function.");return this.getAllItems().filter(t=>{const r=Fr.getItem(t.id);return e(r.metadata,t)})}findItem(e){if("function"!=typeof e)throw new TypeError("`predicate` must be a function.");return this.getAllItems().find(e)}findItems(e){if("function"!=typeof e)throw new TypeError("`predicate` must be a function.");return this.getAllItems().filter(e)}getItemCount(e){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");return this.getAllItems().filter(t=>t.id===e).reduce((e,t)=>e+t.quantity,0)}hasItem(e,t=1){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");if("number"!=typeof t||!Number.isFinite(t)||t<0)throw new TypeError("`quantity` must be a non-negative number.");return this.getItemCount(e)>=t}existsItemAt(e){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");return!!this.#Ss[e]}clear(){this.clearAllItems(),this.clearAllEvents()}clearAllEvents(){this.#Is={add:[],remove:[],use:[],set:[]}}clearAllItems(){this.clearItems(),this.clearSpecialItems()}clearItems(){for(let e=this.#Ss.length-1;e>=0;e--)this.#Ss[e]&&this.deleteItem(e,!0)}clearSpecialItems(){for(const e of this.#Cs.keys()){const t=this.#Cs.get(e);t?.item&&this.deleteSpecialItem(e,!0)}}clone(){const e=this.toObject();return Fr.fromObject(e)}toObject(){const e={};for(const[t,r]of this.#Cs.entries())e[t]={type:r?.type??null,item:r?.item?this.#Ls(r.item):null};return{__schema:"TinyInventory",version:1,maxWeight:this.#Ns,maxSlots:this.#ks,maxSize:this.#Ds,maxStack:this.#Ms,items:this.#Ss.map(e=>e?this.#Ls(e):null),specialSlots:e}}toJSON(e=0){if("number"!=typeof e||!Number.isFinite(e)||e<0)throw new TypeError("`space` must be a non-negative number.");return JSON.stringify(this.toObject(),null,e)}static fromObject(e){if(!e||"object"!=typeof e)throw new TypeError("Invalid state: expected object.");if("TinyInventory"!==e.__schema||"number"!=typeof e.version)throw new TypeError("Invalid or missing schema header.");if(1!==e.version)throw new TypeError(`Unsupported TinyInventory state version: ${e.version}`);const t={};if(e.specialSlots&&"object"==typeof e.specialSlots)for(const r of Object.keys(e.specialSlots))t[r]={type:e.specialSlots[r]?.type??null};const r=new Fr({maxWeight:e.maxWeight??null,maxSlots:e.maxSlots??null,maxSize:e.maxSize??null,maxStack:e.maxStack??null,specialSlots:t});if(Array.isArray(e.items))for(const t in e.items){const i=e.items[t];if(null!==i){const e={id:String(i.id),quantity:Math.max(1,Number(i.quantity)||1),metadata:i.metadata&&"object"==typeof i.metadata?i.metadata:{}};r.setItem({slotIndex:Number(t),item:e,forceSpace:!0})}else r.setItem({slotIndex:Number(t),item:null,forceSpace:!0})}if(e.specialSlots&&"object"==typeof e.specialSlots)for(const[t,i]of Object.entries(e.specialSlots)){if(!r.hasSpecialSlot(t))continue;const e=i?.item;if(e&&e.id){const i={id:String(e.id),quantity:Math.max(1,Number(e.quantity)||1),metadata:e.metadata&&"object"==typeof e.metadata?e.metadata:{}};r.setSpecialSlot({slotId:t,item:i,forceSpace:!0})}}return r}static fromJSON(e){if("string"!=typeof e)throw new TypeError("`json` must be a string.");const t=JSON.parse(e);return Fr.fromObject(t)}}const Br=Fr,zr=class{#Rs=null;#Ps=null;get sender(){return this.#Rs}get receiver(){return this.#Ps}set sender(e){if(!(e instanceof Br&&this.receiver instanceof Br))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Rs=e}set receiver(e){if(!(this.sender instanceof Br&&e instanceof Br))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Ps=e}constructor(e,t){if(e||t){if(!(e instanceof Br&&t instanceof Br))throw new Error("Both sender and receiver must be TinyInventory instances.");this.connect(e,t)}}connect(e,t){if(!(e instanceof Br&&t instanceof Br))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Rs=e,this.#Ps=t}disconnect(){this.#Rs=null,this.#Ps=null}invert(){const e=this.#Rs,t=this.#Ps;this.#Rs=t,this.#Ps=e}transferItem({slotIndex:e,specialSlot:t,quantity:r=1,receiverSlotIndex:i,forceSpace:s=!1,strict:n=!1}){if(!this.#Rs||!this.#Ps)throw new Error("Sender and receiver inventories must be connected.");let o;if(t){if(o=this.#Rs.getSpecialItem(t),!o)throw new Error(`No item found in sender special slot '${t}'.`)}else{if("number"!=typeof e)throw new Error("Must provide either slotIndex or specialSlot.");if(o=this.#Rs.getItemFrom(e),!o)throw new Error(`No item found in sender slot ${e}.`)}if(o.quantity<r)throw new Error(`Sender does not have enough quantity of '${o.id}' to transfer.`);const a={id:o.id,quantity:r,metadata:o.metadata};let l;if(n)if("number"==typeof i){const e=this.#Ps.existsItemAt(i)?this.#Ps.getItemFrom(i):null;if(e){if(e.id!==a.id)throw new Error(`Receiver slot ${i} contains a different item.`);const t=Br.getItem(e.id).maxStack-e.quantity;if(a.quantity>t)throw new Error(`Strict mode: not enough space in receiver slot ${i}.`)}}else if(this.#Ps.clone().addItem({itemId:a.id,quantity:a.quantity,metadata:a.metadata,forceSpace:s}).remaining>0)throw new Error("Strict mode: not enough space in receiver inventory.");if("number"==typeof i){const e=this.#Ps.existsItemAt(i)?this.#Ps.getItemFrom(i):null;let t=a.quantity;if(e){if(e.id!==a.id)throw new Error(`Receiver slot ${i} contains a different item.`);const r=Br.getItem(e.id).maxStack-e.quantity;t=Math.min(r,a.quantity),t>0&&this.#Ps.setItem({slotIndex:i,item:{...e,quantity:e.quantity+t},forceSpace:s})}else this.#Ps.setItem({slotIndex:i,item:a,forceSpace:s});l={remaining:a.quantity-t}}else l=this.#Ps.addItem({itemId:a.id,quantity:a.quantity,metadata:a.metadata,forceSpace:s});const u=a.quantity-l.remaining;if(u>0)if(t)this.#Rs.unequipItem({slotId:t,quantity:u,forceSpace:s});else if("number"==typeof e){const t=o.quantity-u;this.#Rs.setItem({slotIndex:e,item:t>0?{...o,quantity:t}:null,forceSpace:s})}return l}transferMultiple(e){return e.map(e=>this.transferItem(e))}},Wr=class{#$s;#vt={message:"We use cookies to improve your experience.",acceptText:"Accept All",rejectText:"Reject All",settingsText:"Manage Settings",categories:[],storageKey:"cookie-consent-preferences",onSave:e=>console.log("Preferences saved:",e),animationDuration:400,renderBar:null,renderModal:null};get preferences(){const e=localStorage.getItem(this.#vt.storageKey);return e?JSON.parse(e):{}}get config(){return{...this.#vt,categories:[...this.#vt.categories]}}set config(e){this.validateConfig(e),this.#vt=Object.assign(this.#vt,e)}constructor(e){if(!e||"object"!=typeof e)throw new TypeError("Config must be an object.");this.config=e;const t=this.loadPreferences();this.#$s=t??{},t||this.showConsentBar()}validateConfig(e){if(void 0!==e.message&&"string"!=typeof e.message)throw new TypeError("Config.message must be a string.");if(["acceptText","rejectText","settingsText","storageKey"].forEach(t=>{if(void 0!==e[t]&&"string"!=typeof e[t])throw new TypeError(`Config.${t} must be a string.`)}),void 0!==e.categories){if(!Array.isArray(e.categories))throw new TypeError("Config.categories must be an array of Category objects.");e.categories.forEach((e,t)=>this.validateCategory(e,t))}if(void 0!==e.onSave&&"function"!=typeof e.onSave)throw new TypeError("Config.onSave must be a function.");if(void 0!==e.animationDuration&&("number"!=typeof e.animationDuration||e.animationDuration<0))throw new TypeError("Config.animationDuration must be a positive number.");if(void 0!==e.renderBar&&null!==e.renderBar&&"function"!=typeof e.renderBar)throw new TypeError("Config.renderBar must be a function or null.");if(void 0!==e.renderModal&&null!==e.renderModal&&"function"!=typeof e.renderModal)throw new TypeError("Config.renderModal must be a function or null.")}validateCategory(e,t){if(!e||"object"!=typeof e)throw new TypeError(`Category at index ${t} must be an object.`);if("string"!=typeof e.label)throw new TypeError(`Category.label at index ${t} must be a string.`);if("boolean"!=typeof e.required)throw new TypeError(`Category.required at index ${t} must be a boolean.`);if("boolean"!=typeof e.default)throw new TypeError(`Category.default at index ${t} must be a boolean.`)}loadPreferences(){const e=localStorage.getItem(this.#vt.storageKey);return e?JSON.parse(e):null}removeWithAnimation(e){if(!(e instanceof HTMLElement))throw new TypeError("removeWithAnimation expects an HTMLElement.");e.classList.add("closing"),setTimeout(()=>e.remove(),this.#vt.animationDuration)}savePreferences(e){if(!e||"object"!=typeof e)throw new TypeError("Preferences must be an object.");localStorage.setItem(this.#vt.storageKey,JSON.stringify(e)),this.#vt.onSave(e)}showConsentBar(){const e=document.createElement("div");e.className="cookie-consent-bar",e.innerHTML=this.#vt.renderBar?this.#vt.renderBar(this.#vt):`\n <div><p>${this.#vt.message}</p></div>\n <div><button class="accept">${this.#vt.acceptText}</button></div>\n <div><button class="reject">${this.#vt.rejectText}</button></div>\n <div><button class="settings">${this.#vt.settingsText}</button></div>\n `,document.body.appendChild(e);const t=e.querySelector(".accept");t instanceof HTMLElement&&(t.onclick=()=>{const t={};this.#vt.categories.forEach(e=>t[e.label]=!0),this.savePreferences(t),this.removeWithAnimation(e)});const r=e.querySelector(".reject");r instanceof HTMLElement&&(r.onclick=()=>{const t={};this.#vt.categories.forEach(e=>t[e.label]=e.required),this.savePreferences(t),this.removeWithAnimation(e)});const i=e.querySelector(".settings");i instanceof HTMLElement&&(i.onclick=()=>this.showSettingsModal(e))}showSettingsModal(e){const t=document.createElement("div");t.className="cookie-consent-modal",t.innerHTML=this.#vt.renderModal?this.#vt.renderModal(this.#vt):`\n <div class="modal-content">\n <h2>Cookie Settings</h2>\n <form class="settings-form">\n ${this.#vt.categories.map(e=>`\n <label>\n <input type="checkbox" name="${e.label}" \n ${e.default?"checked":""} \n ${e.required?"disabled":""}>\n ${e.label}\n </label>\n `).join("")}\n </form>\n <button class="save">Save Preferences</button>\n </div>\n `,document.body.appendChild(t);const r=t.querySelector(".save");r instanceof HTMLElement&&(r.onclick=()=>{const r={};t.querySelectorAll("input[type=checkbox]").forEach(e=>{e instanceof HTMLInputElement&&(r[e.name]=e.checked)}),this.savePreferences(r),this.removeWithAnimation(t),e&&this.removeWithAnimation(e)})}isAllowed(e){if("string"!=typeof e)throw new TypeError("isAllowed expects a string as category.");return!!this.#$s&&!!this.#$s[e]}};var Vr=r(911),qr=r(766);const Kr=ee("TinyI18"),Jr=class{static async mergeLocaleFiles({files:e,output:t,spaces:r=0}){if("number"!=typeof r||Number.isNaN(r)||r<0)throw new TypeError('mergeLocaleFiles: "spaces" must be a non-negative number');if(!Array.isArray(e)||0===e.length)throw new TypeError('mergeLocaleFiles: "files" must be a non-empty array of file paths');if("string"!=typeof t||!t)throw new TypeError('mergeLocaleFiles: "output" must be a non-empty string path');const i={};for(const t of e){if("string"!=typeof t||!t)throw new TypeError("mergeLocaleFiles: each file path must be a non-empty string");if(!(0,qr.existsSync)(t))throw new Error(`mergeLocaleFiles: file "${t}" does not exist`);const e=await(0,Vr.readFile)(t,"utf-8");let r;try{r=JSON.parse(e)}catch(e){throw new Error(`mergeLocaleFiles: file "${t}" is not valid JSON`)}Object.assign(i,r)}await(0,Vr.writeFile)(t,JSON.stringify(i,null,r),"utf-8")}#h=!1;get destroyed(){return this.#h}#Os;#Hs;#Fs=null;#Bs;#zs=null;#Ws=new Map;#Vs=new Map;#qs=new Map;#Ks=new Map;get currentLocale(){return Kr(this.#h),this.#Fs}get defaultLocale(){return Kr(this.#h),this.#Hs}get mode(){return Kr(this.#h),this.#Os}get strict(){return Kr(this.#h),this.#Bs}get basePath(){return Kr(this.#h),this.#zs}get stats(){Kr(this.#h);const e=[];for(const t of this.#Ws.keys())e.push(this.getStatsForLocale(t));return e}get stringTables(){Kr(this.#h);const e={};for(const[t,r]of this.#Ws.entries())e[t]=this.#Js(r);return e}get patternTables(){Kr(this.#h);const e={};for(const[t,r]of this.#Vs.entries())e[t]=r.map(e=>({$pattern:new RegExp(e.$pattern.source,e.$pattern.flags),value:this.#Js(e.value),elseValue:this.#Js(e.elseValue)}));return e}get helpers(){Kr(this.#h);const e={};for(const[t,r]of this.#qs.entries())e[t]=r;return e}get regexCache(){Kr(this.#h);const e={};for(const[t,r]of this.#Ks.entries())e[t]=new RegExp(r.source,r.flags);return e}#Js(e){if(null==e||"string"==typeof e||"function"==typeof e||"number"==typeof e)return e;if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e))return e.map(e=>this.#Js(e));if("object"==typeof e){const t={};for(const[r,i]of Object.entries(e))t[r]=this.#Js(i);return t}return e}#Us(e){if(void 0!==e&&"string"!=typeof e)throw new TypeError('#resolveOrder: "forceLocale" must be a string if provided');const t=[];return e&&"string"==typeof e&&this.#Ws.has(e)?t.push(e):this.#Fs&&t.push(this.#Fs),t.push(this.#Hs),t}#Gs(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError('#resolveExact: "order" must be an array of strings');if("string"!=typeof t||!t)throw new TypeError('#resolveExact: "key" must be a non-empty string');for(const r of e){const e=this.#Ws.get(r);if(e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}}#Ys(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError('#resolveByPattern: "order" must be an array of strings');if("string"!=typeof t||!t)throw new TypeError('#resolveByPattern: "key" must be a non-empty string');for(const r of e){const e=this.#Vs.get(r)||[];for(const r of e)return r.$pattern.test(t)?r.value:r.elseValue??void 0}}#Xs(e,t){if(null==e){if(this.#Bs)throw new TypeError('#materialize: "value" cannot be null or undefined');return""}if("string"==typeof e)return this.#Qs(e,t);if("function"==typeof e)return e(t??{},this.#Zs());if(e&&"object"==typeof e&&"string"==typeof e.$fn){const r=this.#qs.get(e.$fn);if("function"!=typeof r){if(this.#Bs)throw new Error(`TinyI18: helper "${e.$fn}" is not registered`);return""}return r({...t??{},args:void 0!==e.args?e.args:void 0},this.#Zs())}if(this.#Bs)throw new Error("TinyI18: unsupported entry type");return""}#Qs(e,t){if("string"!=typeof e)throw new TypeError('#interpolate: "template" must be a string');if(void 0!==t&&(null===t||"object"!=typeof t))throw new TypeError('#interpolate: "params" must be an object if provided');return t&&"object"==typeof t?e.replace(/\{([a-zA-Z0-9_.$-]+)\}/g,(e,r)=>{const i=this.#en(t,r);return null==i?"":String(i)}):e}#en(e,t){if(!e||"object"!=typeof e)throw new TypeError('#dotGet: "obj" must be an object');if("string"!=typeof t||!t)throw new TypeError('#dotGet: "path" must be a non-empty string');const r=t.split(".");let i=e;for(const e of r){if(null==i)return;i=i[e]}return i}#Zs(){return{has:e=>this.#qs.has(e),call:(e,t,r)=>{const i=this.#qs.get(e);if("function"!=typeof i)throw new Error(`Helper "${e}" not found`);return i(t,r??{})}}}#tn(e,t){if("string"!=typeof e||!e)throw new TypeError('#ingestLocale: "locale" must be a non-empty string');if(!t||"object"!=typeof t)throw new TypeError('#ingestLocale: "raw" must be an object');if("string"!=typeof e||!e)throw new TypeError("#ingestLocale: invalid locale");if(!t||"object"!=typeof t)throw new TypeError('#ingestLocale: "raw" must be an object');const r={...this.#Ws.get(e)??{}},i=[...this.#Vs.get(e)??[]],s=(e,t)=>{if(null!=t)if("string"==typeof t||"function"==typeof t||t&&"object"==typeof t&&"string"==typeof t.$fn){if(!e)throw new TypeError("Leaf value requires a key path");r[e]=t}else if(t&&"object"==typeof t){if(t.$pattern instanceof RegExp&&Object.prototype.hasOwnProperty.call(t,"value"))return void i.push({$pattern:t.$pattern,value:t.value,elseValue:t.elseValue});for(const[r,i]of Object.entries(t))s(e?`${e}.${r}`:r,i)}};s("",t),this.#Ws.set(e,r),this.#Vs.set(e,i),this.#Ws.has(this.#Hs)||(this.#Ws.set(this.#Hs,{}),this.#Vs.set(this.#Hs,[]))}#rn(e){if("string"!=typeof e||!e)throw new TypeError('#unloadLocale: "locale" must be a non-empty string');e!==this.#Hs&&(this.#Ws.delete(e),this.#Vs.delete(e))}async#in(e){if("string"!=typeof e||!e)throw new TypeError('#loadLocaleFromFile: "locale" must be a non-empty string');if("string"!=typeof this.#zs||!this.#zs)throw new TypeError('#loadLocaleFromFile: "this.#basePath" must be a non-empty string');const t=(0,we.join)(this.#zs,`${e}.json`);let r;try{const e=await(0,Vr.readFile)(t,"utf8");r=JSON.parse(e)}catch(r){if(!(r instanceof Error))return;if(this.#Bs)throw new Error(`TinyI18: failed to load or parse ${t}: ${r.message}`);return this.#Ws.set(e,{}),void this.#Vs.set(e,[])}const i={...this.#Ws.get(e)??{}},s=[...this.#Vs.get(e)??[]],n=(e,t)=>{if(null!=t){if(t&&"object"==typeof t&&"string"==typeof t.$pattern&&Object.prototype.hasOwnProperty.call(t,"value")){const e=this.#sn(t.$pattern);return void s.push({$pattern:e,value:this.#nn(t.value),elseValue:this.#nn(t.elseValue)})}if("string"==typeof t||t&&"object"==typeof t&&"string"==typeof t.$fn){if(!e)throw new TypeError("Leaf value requires a key path");i[e]=this.#nn(t)}else if(t&&"object"==typeof t)for(const[r,i]of Object.entries(t))n(e?`${e}.${r}`:r,i)}};n("",r),this.#Ws.set(e,i),this.#Vs.set(e,s)}#sn(e){if("string"!=typeof e||!e)throw new TypeError('#safeRegExp: "src" must be a non-empty string');const t=this.#Ks.get(e);if(t)return t;try{const t=new RegExp(e);return this.#Ks.set(e,t),t}catch{if(this.#Bs)throw new Error(`TinyI18: invalid regex "${e}" in file`);return/^$/}}#nn(e){if("string"==typeof e)return e;if(e&&"object"==typeof e&&"string"==typeof e.$fn)return{$fn:String(e.$fn),args:e.args};if(this.#Bs)throw new Error("TinyI18: unsupported value in file JSON");return""}constructor(e){if(!e||"object"!=typeof e)throw new TypeError("TinyI18: options must be an object");const{mode:t,defaultLocale:r,basePath:i,localResources:s,strict:n=!0}=e;if("local"!==t&&"file"!==t)throw new TypeError('TinyI18: "mode" must be "local" or "file"');if("string"!=typeof r||!r)throw new TypeError('TinyI18: "defaultLocale" must be a non-empty string');if("boolean"!=typeof n)throw new TypeError('TinyI18: "strict" must be a boolean');if("file"===t){if("string"!=typeof i||!i)throw new TypeError('TinyI18: "basePath" is required in file mode');this.#zs=i}if(this.#Os=t,this.#Hs=r,this.#Bs=n,"local"===t&&s&&"object"==typeof s)for(const[e,t]of Object.entries(s))this.#tn(e,t);this.#Ws.has(this.#Hs)||(this.#Ws.set(this.#Hs,{}),this.#Vs.set(this.#Hs,[]))}clearRegexCache(){Kr(this.#h),this.#Ks.clear()}registerHelper(e,t){if(Kr(this.#h),"string"!=typeof e||!e)throw new TypeError('registerHelper: "name" must be non-empty string');if("function"!=typeof t)throw new TypeError('registerHelper: "fn" must be a function');this.#qs.set(e,t)}unregisterHelper(e){if(Kr(this.#h),"string"!=typeof e||!e)throw new TypeError('unregisterHelper: "name" must be non-empty string');return this.#qs.delete(e)}loadLocaleLocal(e,t){if(Kr(this.#h),"local"!==this.#Os)throw new TypeError('loadLocaleLocal is only available in "local" mode');this.#tn(e,t)}async setLocale(e){if(Kr(this.#h),null!==e&&("string"!=typeof e||!e))throw new TypeError('setLocale: "locale" must be string or null');const t=this.#Fs;null!==e&&("file"===this.#Os?await this.#in(e):this.#Ws.has(e)||(this.#Ws.set(e,{}),this.#Vs.set(e,[]))),"file"===this.#Os&&t&&t!==this.#Hs&&t!==e&&this.#rn(t),this.#Fs=e}t(e,t=void 0,r=void 0){return this.get(e,t,r)}get(e,t=void 0,r=void 0){if(Kr(this.#h),"string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:i}=r||{},s=this.#Us(i);let n=this.#Gs(s,e);if(void 0===n){if(this.#Bs)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return this.#Xs(n,t)}p(e,t){return this.resolveByPattern(e,t)}resolveByPattern(e,t){if(Kr(this.#h),"string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:r}=t||{},i=this.#Us(r);let s=this.#Ys(i,e);if(void 0===s){if(this.#Bs)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return s}resetToDefaultOnly(){if(Kr(this.#h),"file"===this.#Os)for(const e of Array.from(this.#Ws.keys()))e!==this.#Hs&&this.#rn(e);this.#Fs=null}getStatsForLocale(e){if(Kr(this.#h),"string"!=typeof e||!e)throw new TypeError('getStatsForLocale: "locale" must be a non-empty string');if(!this.#Ws.has(e))throw new Error(`getStatsForLocale: locale "${e}" is not registered`);return{locale:e,strings:Object.keys(this.#Ws.get(e)??{}).length,patterns:this.#Vs.get(e)?.length??0,isDefault:e===this.#Hs,isCurrent:e===this.#Fs}}destroy(){this.#h||(this.#Ws.clear(),this.#Vs.clear(),this.#qs.clear(),this.#Ks.clear(),this.#Fs=null,this.#zs=null,this.#h=!0)}};class Ur{#on=new Map;#an;#ln;#un;get factors(){const e={};for(let[t,r]of this.#on.entries())e[t]={...r};return e}get currentPercent(){return this.#ln/this.#an*100}set maxValue(e){if("number"!=typeof e||Number.isNaN(e)||e<=0)throw new TypeError("maxValue must be a positive number.");this.#an=e,this.#ln=Math.min(this.#ln,e)}get maxValue(){return this.#an}get currentValue(){return this.#ln}set infiniteValue(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("infiniteValue must be a number.");this.#un=e,this.#ln=Math.max(0,e),this.#ln=Math.min(this.#ln,this.#an)}get infiniteValue(){return this.#un}constructor(e=100,t=1,r=1){if("number"!=typeof e||Number.isNaN(e)||e<=0)throw new TypeError("maxValue must be a positive number.");this.#an=e,this.setFactor("main",t,r),this.#ln=e,this.#un=e}getFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");const t=this.#on.get(e);if(!t)throw new Error(`Factor with key "${e}" not found.`);return{...t}}hasFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");return this.#on.has(e)}setFactor(e,t,r=1){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");if("number"!=typeof t||Number.isNaN(t))throw new TypeError("Amount must be a valid number.");if("number"!=typeof r||Number.isNaN(r))throw new TypeError("Multiplier must be a valid number.");this.#on.set(e,{amount:t,multiplier:r})}removeFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");return this.#on.delete(e)}#hn(e){const t=this.#un;return this.#un-=e,this.#ln=Math.max(0,this.#ln-e),{prevValue:t,removedTotal:e,removedPercent:e/this.#an*100,currentPercent:this.currentPercent,remainingValue:this.#ln,infiniteRemaining:this.#un}}tick(){let e=0;for(let[t,r]of this.#on.entries())e+=r.amount*r.multiplier;return this.#hn(e)}tickWithTempFactor(e){if("object"!=typeof e||null===e)throw new TypeError("You must provide a valid factor object.");if("number"!=typeof e.amount||Number.isNaN(e.amount))throw new TypeError('Temp factor "amount" must be a valid number.');if("multiplier"in e&&("number"!=typeof e.multiplier||Number.isNaN(e.multiplier)))throw new TypeError('Temp factor "multiplier" must be a valid number if provided.');let t=0;for(let[e,r]of this.#on.entries())t+=r.amount*r.multiplier;return e&&(t+=e.amount*(e.multiplier??1)),this.#hn(t)}tickSingleFactor(e){if("object"!=typeof e||null===e)throw new TypeError("You must provide a valid factor object.");if("number"!=typeof e.amount||Number.isNaN(e.amount))throw new TypeError('Temp factor "amount" must be a valid number.');if("multiplier"in e&&("number"!=typeof e.multiplier||Number.isNaN(e.multiplier)))throw new TypeError('Temp factor "multiplier" must be a valid number if provided.');if(!e)throw new Error("You must provide a factor to apply.");const t=e.amount*(e.multiplier??1);return this.#hn(t)}toJSON(){return{maxValue:this.#an,currentValue:this.#ln,infiniteValue:this.#un,factors:this.factors}}static fromJSON(e){const t=new Ur(e.maxValue,0,0);t.infiniteValue=e.infiniteValue,t.#on.clear();for(const[r,i]of Object.entries(e.factors))t.setFactor(r,i.amount,i.multiplier);return t}clone(){return Ur.fromJSON(this.toJSON())}clearFactors(){this.#on.clear()}}const Gr=Ur;class Yr{static _safeEvaluate(e){if(!/^[\d+\-*/%.()\s^]+$/.test(e))throw new Error(`Invalid characters in expression: "${e}"`);const t=e.replace(/\^/g,"**");try{return Function(`"use strict"; return (${t})`)()}catch(t){if(!(t instanceof Error))throw new Error("Unknown Error");throw new Error(`Invalid expression "${e}": ${t.message}`)}}static replaceValues(e,t){let r=0;return e.replace(/(\d*)d(\d+)/g,(e,i)=>{const s=i?Number(i):1;let n=0;for(let e=0;e<s;e++){const e=t[r++];n+=void 0!==e?e:0}return String(n)})}static tokenizeValues(e,t){const r=Yr.replaceValues(e,t),i=[],s=/\d+|[()+\-*/]/g;let n;for(;null!==(n=s.exec(r));)/^\d+$/.test(n[0])?i.push(Number(n[0])):i.push(n[0]);return{tokens:i,text:r}}static parseString(e){if("string"!=typeof e)throw new TypeError("Input must be a string.");const t=e.split(",").map(e=>e.trim()).filter(Boolean),r=[],i=[];if(t.forEach((e,t)=>{const s=/\b(?:(\d+)?d(\d+))\b/g;let n;const o=[],a=e.replace(/\(([^()]+?\|[^()]+?)\)/g,(e,t)=>{const r="string"==typeof t?t.split("|").map(e=>e.trim()).filter(Boolean):[];if(0===r.length)throw new Error(`Invalid random-choice group: "${e}"`);return r[Math.floor(Math.random()*r.length)]});for(;null!==(n=s.exec(a));){const e=parseInt(n[1]||"1",10),r=parseInt(n[2],10);if(isNaN(r))throw new Error(`Invalid dice sides in expression "${n[0]}" at position ${t+1}.`);o.push({count:e,sides:r})}if(0===o.length&&Number.isNaN(parseFloat(a)))throw new Error(`Invalid dice expression at position ${t+1}: "${e}"`);r.push(...o),i.push({index:t,original:e,expression:a})}),0===r.length)throw new Error("Invalid dice amount.");return{sides:r,modifiers:i}}static applyModifiers(e,t){if(!Array.isArray(e)||!e.every(e=>"number"==typeof e&&!Number.isNaN(e)||g(e)&&"number"==typeof e.value&&!Number.isNaN(e.value)&&"number"==typeof e.sides&&!Number.isNaN(e.sides)))throw new TypeError("Bases must be a valid numbers.");if(!Array.isArray(t))throw new TypeError("Modifiers must be an array of modifier objects.");let r=0;const i=[],s=[...e];for(const e in t){const n=t[e];if("string"!=typeof n.expression)throw new Error("Each modifier must include an expression string.");const o=n.original,a=n.expression,l=[],u=[],h=[],c=e=>e.match(/\(\s*[^()]+\|\s*[^()]+\s*\)|\b\d*d\d+\b|[-+]?\d+(?:\.\d+)?|[+\-*/%^()]/g)||[],d=c(a),m=c(o),p=[...d],f=[],y=a.replace(/\b\d*d\d+\b/g,e=>{const t=e.split("d"),r=()=>{for(const t in d)if(d[t]===e&&f.indexOf(t)<0){f.push(t),h.push(Number(t));break}},i=e=>{if(e.value>e.sides)throw new Error(`Invalid dice roll: value (${e.value}) must be between 1 and ${e.sides}.`)};if(0===t[0].trim().length){const t=s.shift(),n="number"==typeof t?t:g(t)?t.value:0;g(t)&&i(t),l.push([n]);for(const t in p)if(p[t]===e){p[t]=String(n),u.push(Number(t));break}return r(),n}const n=[],o=Number(t[0]),a=["("];let c="(";for(let e=0;e<o;e++){const t=s.shift(),r="number"==typeof t?t:g(t)?t.value:0;g(t)&&i(t),a.push(String(r));const l=e<o-1?" + ":")";a.push(l),c+=`${r}${l}`,n.push(r)}for(const t in p){const r=Number(t);if(p[r]===e){p.splice(r,1,...a);let e=1;for(let t=0;t<o;t++)u.push(r+t+e),e++;break}}return l.push(n),r(),c});let b;try{b=Yr._safeEvaluate(y)}catch(e){if(!(e instanceof Error))throw new Error("Unknown Error");throw new Error(`Error evaluating expression "${y}" (from "${a}"): ${e.message}`)}i.push({rawTokensP:d,rawTokens:m,tokens:p,rawDiceTokenSlots:h,diceTokenSlots:u,dicesResult:l,total:b}),r+=b}return{final:r,steps:i}}static rollArrayIndex(e){const t=Array.isArray(e),r=e instanceof Set;if(!t&&!r)throw new TypeError("rollArrayIndex expects an array or Set.");return Math.floor(Math.random()*(t?e.length:e.size))}#an;#cn;get maxValue(){return this.#an}set maxValue(e){if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#an=e}get allowZero(){return this.#cn}set allowZero(e){if("boolean"!=typeof e)throw new TypeError("allowZero must be a boolean.");this.#cn=e}constructor({maxValue:e,allowZero:t=!0}){if("boolean"!=typeof t)throw new TypeError("allowZero must be an boolean.");if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#an=e,this.#cn=t}roll(){const e=this.#cn?0:1;return Math.floor(Math.random()*(this.#an-e+1))+e}}const Xr=Yr,Qr=class{#S=null;get overlay(){return this.#S}#dn=null;get messageElement(){return this.#dn}#P;get container(){return this.#P}#mn={fadeIn:null,fadeOut:null,zIndex:9999};get options(){return{...this.#mn}}set options(e){if("object"!=typeof e||null===e)throw new TypeError("options must be an object");if(void 0!==e.fadeIn&&null!==e.fadeIn&&("number"!=typeof e.fadeIn||e.fadeIn<0))throw new TypeError("fadeIn must be a non-negative number or null");if(void 0!==e.fadeOut&&null!==e.fadeOut&&("number"!=typeof e.fadeOut||e.fadeOut<0))throw new TypeError("fadeOut must be a non-negative number or null");if(void 0!==e.zIndex&&("number"!=typeof e.zIndex||!Number.isInteger(e.zIndex)))throw new TypeError("zIndex must be an integer number");this.#mn={fadeIn:e.fadeIn??null,fadeOut:e.fadeOut??null,zIndex:e.zIndex??9999}}#pn="none";get status(){return this.#pn}#fn="";get defaultMessage(){return this.#fn}set defaultMessage(e){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("defaultMessage must be a string or an HTMLElement");this.#fn=e}#yn=null;get message(){return this.#yn}#gn=!1;get allowHtmlText(){return this.#gn}set allowHtmlText(e){if("boolean"!=typeof e)throw new TypeError("allowHtmlText must be a boolean");this.#gn=e}#bn=null;get fadeInTimeout(){return null!==this.#bn}#wn=null;get fadeOutTimeout(){return null!==this.#wn}get visible(){return!!this.#S}#vn=null;get onChange(){return this.#vn}set onChange(e){if(null!==e&&"function"!=typeof e)throw new TypeError("onChange must be a function or null");this.#vn=e}_emitChange(){"function"==typeof this.#vn&&this.#vn(this.#pn)}constructor(e=document.body){if(!(e instanceof HTMLElement))throw new TypeError("container must be an HTMLElement");this.#P=e}_updateMessage(e=this.#fn){if(!this.#dn)throw new Error("messageElement is not initialized");if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");if(this.#yn=e,"string"==typeof e)this.#gn?this.#dn.innerHTML=e:this.#dn.textContent=e;else{if(!this.#gn)throw new Error("HTMLElement messages require allowHtmlText = true");this.#dn.textContent="",this.#dn.appendChild(e)}}_removeOldClasses(){this.#S?.classList.remove("active"),this.#S?.classList.remove("fadeIn"),this.#S?.classList.remove("fadeOut")}start(e=this.#fn){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");if(!this.#S){this.#S=document.createElement("div"),this.#S.classList.add("loading-overlay"),this.#S.style.zIndex=String(this.#mn.zIndex);const t=document.createElement("div");t.classList.add("loading-container");const r=document.createElement("div");r.classList.add("loading-content");const i=document.createElement("div");i.classList.add("loading-spinner"),this.#dn=document.createElement("div"),this.#dn.classList.add("loading-message"),r.appendChild(i),r.appendChild(this.#dn),t.appendChild(r),this.#S.appendChild(t),this.#P.appendChild(this.#S),this._removeOldClasses(),this.#pn="fadeIn",this.#S.classList.add("fadeIn"),this._emitChange();const s=()=>{this._removeOldClasses(),this.#bn=null,this.#pn="active",this.#S?.classList.add("active"),this._emitChange()};return"number"==typeof this.#mn.fadeIn?(this.#bn&&clearTimeout(this.#bn),this.#bn=setTimeout(s,this.#mn.fadeIn)):s(),this._updateMessage(e),!0}return this.#dn&&this._updateMessage(e),!1}update(e=this.#fn){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");return!!this.#dn&&(this._updateMessage(e),!0)}stop(){if(this.#S){this._removeOldClasses(),this.#pn="fadeOut",this.#S.classList.add("fadeOut"),this._emitChange();const e=()=>{this._removeOldClasses(),this.#wn=null,this.#pn="none",this.#S?.remove(),this.#S=null,this.#dn=null,this.#yn=null,this._emitChange()};return"number"==typeof this.#mn.fadeOut?(this.#wn&&clearTimeout(this.#wn),this.#wn=setTimeout(e,this.#mn.fadeOut)):e(),!0}return!1}};class Zr{static#En=/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;static#Tn=/^#([A-Fa-f0-9]{8})$/;static#Sn="(0|1|0?\\.\\d+)";static#xn="(0|[1-9]\\d?|1\\d{2}|2[0-4]\\d|25[0-5])";static#An="(0|[1-9]\\d?|[1-2]\\d{2}|3[0-5]\\d|360)";static#Cn="(0|[1-9]?\\d|100)";static#In=new RegExp(`^rgb\\(\\s*${Zr.#xn}\\s*,\\s*${Zr.#xn}\\s*,\\s*${Zr.#xn}\\s*\\)$`);static#Mn=new RegExp(`^rgba\\(\\s*${Zr.#xn}\\s*,\\s*${Zr.#xn}\\s*,\\s*${Zr.#xn}\\s*,\\s*${Zr.#Sn}\\s*\\)$`);static#Dn=new RegExp(`^hsl\\(\\s*${Zr.#An}\\s*,\\s*${Zr.#Cn}%\\s*,\\s*${Zr.#Cn}%\\s*\\)$`);static#kn=new RegExp(`^hsla\\(\\s*${Zr.#An}\\s*,\\s*${Zr.#Cn}%\\s*,\\s*${Zr.#Cn}%\\s*,\\s*${Zr.#Sn}\\s*\\)$`);static#Nn=new RegExp(`^hwb\\(\\s*${Zr.#An}(deg|grad|rad|turn)?\\s*${Zr.#Cn}%\\s*${Zr.#Cn}%\\s*\\)$`);static#Ln="(-?\\d+)";static#_n=new RegExp(`^lab\\(\\s*${Zr.#Cn}%?\\s*${Zr.#Ln}%?\\s*${Zr.#Ln}%?\\s*\\)$`);static#jn=new RegExp(`^lch\\(\\s*${Zr.#Cn}%?\\s*${Zr.#Cn}%?\\s*${Zr.#An}(deg|grad|rad|turn)?\\s*\\)$`);static#Rn=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);static#Pn=new Set(["transparent","currentColor"]);static getNames(){return Array.from(Zr.#Rn)}static addName(e){const t=Zr.#Rn.size;return Zr.#Rn.add(e.toLowerCase()),Zr.#Rn.size>t}static removeName(e){return Zr.#Rn.delete(e.toLowerCase())}static hasName(e){return Zr.#Rn.has(e.toLowerCase())}static getSpecialNames(){return Array.from(Zr.#Pn)}static addSpecialName(e){const t=Zr.#Pn.size;return Zr.#Pn.add(e),Zr.#Pn.size>t}static removeSpecialName(e){return Zr.#Pn.delete(e)}static hasSpecialName(e){return Zr.#Pn.has(e)}#$n;get code(){return this.#$n}#On;get type(){return this.#On}constructor(e){this.#$n=e,this.#On=Zr.isColor(this.#$n)}static isHex(e){if("string"!=typeof e)throw new TypeError("isHex: input must be a string.");return Zr.#En.test(e.trim())}isHex(){return Zr.isHex(this.#$n)}static isHexa(e){if("string"!=typeof e)throw new TypeError("isHexa: input must be a string.");return Zr.#Tn.test(e.trim())}isHexa(){return Zr.isHexa(this.#$n)}static isRgb(e){if("string"!=typeof e)throw new TypeError("isRgb: input must be a string.");return Zr.#In.test(e.trim())}isRgb(){return Zr.isRgb(this.#$n)}static isRgba(e){if("string"!=typeof e)throw new TypeError("isRgba: input must be a string.");return Zr.#Mn.test(e.trim())}isRgba(){return Zr.isRgba(this.#$n)}static isHsl(e){if("string"!=typeof e)throw new TypeError("isHsl: input must be a string.");return Zr.#Dn.test(e.trim())}isHsl(){return Zr.isHsl(this.#$n)}static isHsla(e){if("string"!=typeof e)throw new TypeError("isHsla: input must be a string.");return Zr.#kn.test(e.trim())}isHsla(){return Zr.isHsla(this.#$n)}static isHwb(e){if("string"!=typeof e)throw new TypeError("isHwb: input must be a string.");return Zr.#Nn.test(e.trim())}isHwb(){return Zr.isHwb(this.#$n)}static isLab(e){if("string"!=typeof e)throw new TypeError("isLab: input must be a string.");return Zr.#_n.test(e.trim())}isLab(){return Zr.isLab(this.#$n)}static isLch(e){if("string"!=typeof e)throw new TypeError("isLch: input must be a string.");return Zr.#jn.test(e.trim())}isLch(){return Zr.isLch(this.#$n)}static isName(e){if("string"!=typeof e)throw new TypeError("isName: input must be a string.");return Zr.#Rn.has(e.trim().toLowerCase())}isName(){return Zr.isName(this.#$n)}static isSpecialName(e){if("string"!=typeof e)throw new TypeError("isSpecialName: input must be a string.");return Zr.#Pn.has(e.trim())}isSpecialName(){return Zr.isSpecialName(this.#$n)}static isColor(e){if("string"!=typeof e)throw new TypeError("isColor: input must be a string.");return Zr.isHex(e)?"hex":Zr.isHexa(e)?"hexa":Zr.isRgb(e)?"rgb":Zr.isRgba(e)?"rgba":Zr.isHsl(e)?"hsl":Zr.isHsla(e)?"hsla":Zr.isHwb(e)?"hwb":Zr.isLab(e)?"lab":Zr.isLch(e)?"lch":Zr.isName(e)?"name":Zr.isSpecialName(e)?"specialName":null}parse(){switch(this.#On){case"hex":return Zr.parseHex(this.code);case"hexa":return Zr.parseHexa(this.code);case"rgb":return Zr.parseRgb(this.code);case"rgba":return Zr.parseRgba(this.code);case"hsl":return Zr.parseHsl(this.code);case"hsla":return Zr.parseHsla(this.code);case"hwb":return Zr.parseHwb(this.code);case"lab":return Zr.parseLab(this.code);case"lch":return Zr.parseLch(this.code);case"name":case"specialName":return this.#$n.trim().toLowerCase();default:return null}}static parseHex(e){if("string"!=typeof e)throw new TypeError("parseHex: input must be a string.");const t=new RegExp(Zr.#En,"gm").exec(e.trim());return t?t[1]:null}parseHex(){return Zr.parseHex(this.#$n)}static parseHexa(e){if("string"!=typeof e)throw new TypeError("parseHexa: input must be a string.");const t=new RegExp(Zr.#Tn,"gm").exec(e.trim());return t?t[1]:null}parseHexa(){return Zr.parseHexa(this.#$n)}static parseRgb(e){if("string"!=typeof e)throw new TypeError("parseRgb: input must be a string.");const t=new RegExp(Zr.#In,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseRgb(){return Zr.parseRgb(this.#$n)}static parseRgba(e){if("string"!=typeof e)throw new TypeError("parseRgba: input must be a string.");const t=new RegExp(Zr.#Mn,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]:null}parseRgba(){return Zr.parseRgba(this.#$n)}static parseHsl(e){if("string"!=typeof e)throw new TypeError("parseHsl: input must be a string.");const t=new RegExp(Zr.#Dn,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseHsl(){return Zr.parseHsl(this.#$n)}static parseHsla(e){if("string"!=typeof e)throw new TypeError("parseHsla: input must be a string.");const t=new RegExp(Zr.#kn,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]:null}parseHsla(){return Zr.parseHsla(this.#$n)}static parseHwb(e){if("string"!=typeof e)throw new TypeError("parseHwb: input must be a string.");const t=new RegExp(Zr.#Nn,"gm").exec(e.trim());return t?[parseFloat(t[1]),t[2]??null,parseFloat(t[3]),parseFloat(t[4])]:null}parseHwb(){return Zr.parseHwb(this.#$n)}static parseLab(e){if("string"!=typeof e)throw new TypeError("parseLab: input must be a string.");const t=new RegExp(Zr.#_n,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseLab(){return Zr.parseLab(this.#$n)}static parseLch(e){if("string"!=typeof e)throw new TypeError("parseLch: input must be a string.");const t=new RegExp(Zr.#jn,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),t[4]??null]:null}parseLch(){return Zr.parseLch(this.#$n)}}const ei=Zr,ti=ee("TinyAnalogClock"),ri=class{#Hn;#Fn;#Bn;#vt;#oi=null;#h=!1;get destroyed(){return this.#h}_getDate(){const e=new Date,t=e.getSeconds(),r=e.getMinutes(),i=e.getHours();return{now:e,s:t,m:r,h:i}}constructor(e={}){this.#vt={bgColor:"#f0f0f0",borderColor:"#333",borderWidth:8,markColor:"#333",hourHandColor:"#000",minuteHandColor:"#444",secondHandColor:"#d81c1c",textColor:"#000",skinUrl:null,showNumbers:!0,showSeconds:!0,size:800,sizeAdjust:.04,padding:45,angleDistance:.95,pwH:.008,phH:.08,pwM:.005,phM:.03,...e},this.#Hn=document.createElement("div"),this.#Hn.className="analog-clock-container",this.#Hn.style.position="relative",this.#Hn.style.borderRadius="50%",this.#Hn.style.overflow="hidden",this.#Hn.style.boxSizing="border-box",this.#Bn=document.createElement("div"),this.#Bn.style.position="absolute",this.#Bn.style.inset="0",this.#Bn.style.backgroundSize="cover",this.#Bn.style.backgroundPosition="center",this.#Bn.style.zIndex="0",this.#Fn=document.createElement("div"),this.#Fn.style.position="absolute",this.#Fn.style.inset="0",this.#Fn.style.zIndex="1",this.#Fn.style.pointerEvents="none";const t=document.createElement("div");t.style.position="absolute",t.style.inset="0",t.style.zIndex="2",t.style.pointerEvents="none",t.innerHTML='\n <div class="hand hour-hand"></div>\n <div class="hand minute-hand"></div>\n <div class="hand second-hand"></div>\n <div class="center-pin"></div>\n ',this.#Hn.appendChild(this.#Bn),this.#Hn.appendChild(this.#Fn),this.#Hn.appendChild(t);const r=document.createElement("style");r.textContent="\n .analog-clock-container .hand {\n position: absolute;\n bottom: 50%;\n left: 50%;\n transform-origin: bottom center;\n border-radius: 4px;\n transform: translateX(-50%) rotate(0deg);\n z-index: 5;\n }\n .analog-clock-container .center-pin {\n position: absolute;\n top: 50%; left: 50%;\n width: 12px; height: 12px;\n background: #333;\n border-radius: 50%;\n transform: translate(-50%, -50%);\n z-index: 10;\n }\n .analog-clock-container .clock-mark {\n position: absolute;\n top: 50%; left: 50%;\n background: currentColor;\n transform-origin: center center;\n }\n .analog-clock-container .clock-number {\n position: absolute;\n top: 50%; left: 50%;\n transform: translate(-50%, -50%);\n font-family: sans-serif;\n font-weight: bold;\n text-align: center;\n line-height: 1;\n }\n ",this.#Hn.appendChild(r),this._applyConfig(),this._renderFace(),this._startTicker()}_applyConfig(){const e=this.#Hn.style,t=this.#vt;e.width=`${t.size}px`,e.height=`${t.size}px`,e.border=`${t.borderWidth}px solid ${t.borderColor}`,e.backgroundColor=t.bgColor,t.skinUrl?(this.#Bn.style.backgroundImage=`url(${t.skinUrl})`,this.#Bn.style.display="block"):this.#Bn.style.display="none";const r=e=>{const t=this.#Hn.querySelector(e);if(!(t instanceof HTMLDivElement))throw new Error(`TinyAnalogClock: Element ${e} not found.`);return t},i=r(".hour-hand");i.style.backgroundColor=t.hourHandColor,i.style.width=.025*t.size+"px",i.style.height=.25*t.size+"px",i.style.marginLeft=.025*t.size/-2+"px",i.style.bottom="50%",i.style.left="50%",i.style.transformOrigin="bottom center";const s=r(".minute-hand");s.style.backgroundColor=t.minuteHandColor,s.style.width=.015*t.size+"px",s.style.height=.35*t.size+"px",s.style.marginLeft=.015*t.size/-2+"px";const n=r(".second-hand");t.showSeconds?(n.style.display="block",n.style.backgroundColor=t.secondHandColor,n.style.width=.005*t.size+"px",n.style.height=.4*t.size+"px",n.style.marginLeft=.005*t.size/-2+"px"):n.style.display="none",r(".center-pin").style.background=t.borderColor}_renderFace(){this.#Fn.innerHTML="";const e=this.#vt.size/2-this.#vt.borderWidth;for(let t=0;t<60;t++){const r=t%5==0,i=document.createElement("div");i.className="clock-mark";const s=r?this.#vt.size*this.#vt.pwH:this.#vt.size*this.#vt.pwM,n=r?this.#vt.size*this.#vt.phH:this.#vt.size*this.#vt.phM,o=this.#vt.markColor;i.style.width=`${s}px`,i.style.height=`${n}px`,i.style.color=o;const a=e-this.#vt.padding-n/2;i.style.transform=`translate(-50%, -50%) rotate(${6*t}deg) translate(0, -${a}px)`,this.#Fn.appendChild(i)}if(this.#vt.showNumbers)for(let t=1;t<=12;t++){const r=30*t*(Math.PI/180),i=e*this.#vt.angleDistance,s=e+Math.sin(r)*i,n=e-Math.cos(r)*i,o=document.createElement("div");o.className="clock-number",o.innerText=t.toString(),o.style.left=`${s}px`,o.style.top=`${n}px`,o.style.color=this.#vt.textColor,o.style.fontSize=this.#vt.size*this.#vt.sizeAdjust+"px",this.#Fn.appendChild(o)}}_startTicker(){if(this.#oi)return;const e=()=>{const{s:t,m:r,h:i}=this._getDate(),s=6*t,n=6*r+.1*t,o=i%12*30+.5*r,a=e=>{const t=this.#Hn.querySelector(e);if(!(t instanceof HTMLDivElement))throw new Error(`${e} not found.`);return t};this.#Hn.querySelector(".second-hand")&&(a(".second-hand").style.transform=`rotate(${s}deg)`),a(".minute-hand").style.transform=`rotate(${n}deg)`,a(".hour-hand").style.transform=`rotate(${o}deg)`,this.#oi=requestAnimationFrame(e)};e()}get element(){return ti(this.#h),this.#Hn}set size(e){if(ti(this.#h),"number"!=typeof e||e<=0||isNaN(e))throw new Error(`TinyAnalogClock: 'size' must be a positive number. Received: ${e}`);this.#vt.size=e,this._applyConfig(),this._renderFace()}get size(){return ti(this.#h),this.#vt.size}set skinUrl(e){if(ti(this.#h),null!==e&&"string"!=typeof e)throw new Error("TinyAnalogClock: 'skin' must be a URL string or null. Received type: "+typeof e);this.#vt.skinUrl=e,this._applyConfig()}get skinUrl(){return ti(this.#h),this.#vt.skinUrl}set borderColor(e){if(ti(this.#h),"string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'borderColor' must be a non-empty string. Received: ${e}`);this.#vt.borderColor=e,this._applyConfig(),this._renderFace()}get borderColor(){return ti(this.#h),this.#vt.borderColor}set markColor(e){if(ti(this.#h),"string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'markColor' must be a non-empty string. Received: ${e}`);this.#vt.markColor=e,this._applyConfig(),this._renderFace()}get markColor(){return ti(this.#h),this.#vt.markColor}set textColor(e){if(ti(this.#h),"string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'textColor' must be a non-empty string. Received: ${e}`);this.#vt.textColor=e,this._applyConfig(),this._renderFace()}get textColor(){return ti(this.#h),this.#vt.textColor}set showNumbers(e){if(ti(this.#h),"boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showNumbers' must be a boolean. Received type: "+typeof e);this.#vt.showNumbers=e,this._renderFace()}get showNumbers(){return ti(this.#h),this.#vt.showNumbers}set bgColor(e){if(ti(this.#h),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'bgColor' must be a non-empty string.");this.#vt.bgColor=e,this._applyConfig()}get bgColor(){return ti(this.#h),this.#vt.bgColor}set borderWidth(e){if(ti(this.#h),"number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'borderWidth' must be a non-negative number.");this.#vt.borderWidth=e,this._applyConfig(),this._renderFace()}get borderWidth(){return ti(this.#h),this.#vt.borderWidth}set hourHandColor(e){if(ti(this.#h),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'hourHandColor' must be a non-empty string.");this.#vt.hourHandColor=e,this._applyConfig()}get hourHandColor(){return ti(this.#h),this.#vt.hourHandColor}set minuteHandColor(e){if(ti(this.#h),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'minuteHandColor' must be a non-empty string.");this.#vt.minuteHandColor=e,this._applyConfig()}get minuteHandColor(){return ti(this.#h),this.#vt.minuteHandColor}set secondHandColor(e){if(ti(this.#h),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'secondHandColor' must be a non-empty string.");this.#vt.secondHandColor=e,this._applyConfig()}get secondHandColor(){return ti(this.#h),this.#vt.secondHandColor}set showSeconds(e){if(ti(this.#h),"boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showSeconds' must be a boolean.");this.#vt.showSeconds=e,this._applyConfig()}get showSeconds(){return ti(this.#h),this.#vt.showSeconds}set sizeAdjust(e){if(ti(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'sizeAdjust' must be a positive number.");this.#vt.sizeAdjust=e,this._renderFace()}get sizeAdjust(){return ti(this.#h),this.#vt.sizeAdjust}set padding(e){if(ti(this.#h),"number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'padding' must be a non-negative number.");this.#vt.padding=e,this._renderFace()}get padding(){return ti(this.#h),this.#vt.padding}set angleDistance(e){if(ti(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'angleDistance' must be a positive number.");this.#vt.angleDistance=e,this._renderFace()}get angleDistance(){return ti(this.#h),this.#vt.angleDistance}set pwH(e){if(ti(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwH' must be a positive number.");this.#vt.pwH=e,this._renderFace()}get pwH(){return ti(this.#h),this.#vt.pwH}set phH(e){if(ti(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phH' must be a positive number.");this.#vt.phH=e,this._renderFace()}get phH(){return ti(this.#h),this.#vt.phH}set pwM(e){if(ti(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwM' must be a positive number.");this.#vt.pwM=e,this._renderFace()}get pwM(){return ti(this.#h),this.#vt.pwM}set phM(e){if(ti(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phM' must be a positive number.");this.#vt.phM=e,this._renderFace()}get phM(){return ti(this.#h),this.#vt.phM}destroy(){this.#h||(this.#oi&&(cancelAnimationFrame(this.#oi),this.#oi=null),this.#Hn.remove(),this.#h=!0)}},ii=ee("TinyTextDiffer"),si=class{#zn=[];#h=!1;get destroyed(){return this.#h}get history(){return ii(this.#h),[...this.#zn]}set history(e){if(ii(this.#h),!Array.isArray(e))throw new TypeError("History data must be provided as an array.");if(!e.every(e=>"string"==typeof e))throw new TypeError("All items in the history array must be strings.");this.#zn=[...e]}get size(){return ii(this.#h),this.#zn.length}constructor(e=[]){this.history=e}#Wn(e){if("number"!=typeof e)throw new TypeError("The provided index must be a valid number.")}#Vn(e){if("string"!=typeof e)throw new TypeError("The provided text must be a valid string.")}get(e){if(ii(this.#h),this.#Wn(e),void 0===this.#zn[e])throw new Error(`No text version found at index ${e}.`);return this.#zn[e]}has(e){return ii(this.#h),this.#Wn(e),void 0!==this.#zn[e]}add(e){ii(this.#h),this.#Vn(e),this.#zn.push(e)}remove(){return ii(this.#h),this.#zn.pop()}addAt(e,t){ii(this.#h),this.#Wn(e),this.#Vn(t),this.#zn.splice(e,0,t)}removeAt(e){ii(this.#h),this.#Wn(e);const t=this.#zn.length;return this.#zn.splice(e,1),t!==this.#zn.length}clear(){ii(this.#h),this.#zn=[]}compare(...e){ii(this.#h);const t=e.length;if(0===t||t%2!=0)throw new Error("The compare method requires an even number of indices to form comparison pairs.");const r=[];for(let i=0;i<t;i+=2){const s=i+1;if(s>t-1)continue;this.#Wn(e[i]),this.#Wn(e[s]);const n=this.#zn[e[i]],o=this.#zn[e[s]];r.push(this._computeDiff(n,o))}return r}_computeDiff(e,t){const r=e.length,i=t.length,s=Array(r+1).fill(null).map(()=>Array(i+1).fill(0));let n=1,o=1;for(n=1;n<=r;n++)for(o=1;o<=i;o++)e[n-1]===t[o-1]?s[n][o]=s[n-1][o-1]+1:s[n][o]=Math.max(s[n-1][o],s[n][o-1]);n=r,o=i;const a=[];for(;n>0||o>0;)n>0&&o>0&&e[n-1]===t[o-1]?(a.unshift({value:e[n-1],type:"normal"}),n--,o--):o>0&&(0===n||s[n][o-1]>=s[n-1][o])?(a.unshift({value:t[o-1],type:"added"}),o--):n>0&&(0===o||s[n][o-1]<s[n-1][o])&&(a.unshift({value:e[n-1],type:"deleted"}),n--);return a.reduce((e,t)=>{const r=e.length-1;return e.length>0&&e[r].type===t.type?e[r].value+=t.value:e.push(t),e},[])}destroy(){this.#h||(this.#zn=[],this.#h=!0)}};class ni{static generateHash(e){const t="object"==typeof e?JSON.stringify(e):String(e);let r=0;for(let e=0,i=t.length;e<i;e++)r=(r<<5)-r+t.charCodeAt(e),r|=0;return r.toString(36)}#qn=[];get oldArray(){return this.#qn}set oldArray(e){if(!Array.isArray(e))throw new TypeError("The provided oldArray must be a valid Array.");this.#qn=e}constructor(e){void 0!==e&&(this.oldArray=e)}_generateHash(e){return ni.generateHash(e)}compare(e){if(!Array.isArray(e))throw new TypeError("The provided newArray must be a valid Array.");const t={oldItemsMap:new Map,affectedItems:[]};for(const e of this.#qn){const r=this._generateHash(e);t.oldItemsMap.set(r,e)}for(const r of e){const e=this._generateHash(r);t.oldItemsMap.has(e)?t.oldItemsMap.delete(e):t.affectedItems.push({item:r,status:"added"})}for(const e of t.oldItemsMap.values())t.affectedItems.push({item:e,status:"deleted"});return t.affectedItems}}const oi=ni,ai=e=>{if(!Array.isArray(e))throw new TypeError("Parameter 'sets' must be an array.");if(!e.every(e=>e instanceof ci))throw new TypeError("All elements in the array must be instances of FuzzySet.")},li=(e,t,r=.5)=>{hi(e,"object","defuzzifyCentroid.fuzzyOutput");for(const t in e)hi(e[t],"number",`fuzzyOutput['${t}']`);ai(t),hi(r,"number","defuzzifyCentroid.step");let i=0,s=0;for(let n=0;n<=100;n+=r){let r=0;t.forEach(t=>{const i=e[t.name]||0,s=Math.min(i,t.calculate(n));r=Math.max(r,s)}),i+=n*r,s+=r}return 0===s?0:i/s},ui=(e,t,r,i,s,n=!1)=>{if(n){if(e<=t||e>=s)return 0;if(e>=r&&e<=i)return 1}const o=t===r?1:(e-t)/(r-t),a=i===s?1:(s-e)/(s-i),l=Math.max(0,Math.min(o,1,a));return isNaN(l)?0:l},hi=(e,t,r)=>{if(typeof e!==t)throw new TypeError(`Parameter '${r}' must be a ${t}.`)};class ci{static trapezoid(e,t,r,i,s,n=!1){return ui(e,t,r,i,s,n)}#Kn="";#Jn=0;#Un=0;#Gn=0;#Yn=0;#Xn=!1;get name(){return this.#Kn}set name(e){hi(e,"string","FuzzySet.name"),this.#Kn=e}get a(){return this.#Jn}set a(e){hi(e,"number","FuzzySet.a"),this.#Jn=e}get b(){return this.#Un}set b(e){hi(e,"number","FuzzySet.b"),this.#Un=e}get c(){return this.#Gn}set c(e){hi(e,"number","FuzzySet.c"),this.#Gn=e}get d(){return this.#Yn}set d(e){hi(e,"number","FuzzySet.d"),this.#Yn=e}get optimize(){return this.#Xn}set optimize(e){hi(e,"boolean","FuzzySet.optimize"),this.#Xn=e}constructor(e,t,r,i,s,n=!1){this.name=e,this.a=t,this.b=r,this.c=i,this.d=s,this.optimize=n}calculate(e){return hi(e,"number","calculate.x"),ci.trapezoid(e,this.#Jn,this.#Un,this.#Gn,this.#Yn,this.#Xn)}}class di{#Qn=new Map;addVariable(e,t){hi(e,"string","addVariable.name"),ai(t),this.#Qn.set(e,t)}removeVariable(e){return hi(e,"string","removeVariable.name"),this.#Qn.delete(e)}getVariable(e){hi(e,"string","getVariable.name");const t=this.#Qn.get(e);if(!t)throw new Error(`Linguistic variable '${e}' not found in the inference system.`);return[...t]}hasVariable(e){return hi(e,"string","hasVariable.name"),this.#Qn.has(e)}fuzzify(e,t){hi(e,"string","fuzzify.varName"),hi(t,"number","fuzzify.value");const r=this.#Qn.get(e)||[],i={};return r.forEach(e=>{i[e.name]=e.calculate(t)}),i}}class mi{#Zn=new Set;get appliedPlugins(){if(this.#eo)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return[...this.#Zn]}#to=[];get appliedPluginClasses(){if(this.#eo)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return[...this.#to]}get size(){if(this.#eo)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return this.#to.length}#ro;get currentClass(){if(this.#eo)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return this.#ro}#eo=!1;get used(){return this.#eo}constructor(e,t=[]){this.#ro=e,this.#to=[...t,e]}#io(e,t,r){if(this.#eo)throw new Error("[TinyClassManager] Cannot reuse a consumed manager instance.");if(this.#Zn.has(e))throw new Error(`[TinyClassManager] Plugin conflict: "${e}" is already installed.`);for(const r of t)if(!this.#Zn.has(r))throw new Error(`[TinyClassManager] Missing Dependency: "${e}" requires "${r}" to be installed first.`);const i=new mi(r,this.#to);return this.#Zn.forEach(e=>i.#Zn.add(e)),i.#Zn.add(e),this.#eo=!0,this.#Zn.clear(),this.#to=[],i}use(e){const t=e.dependencies||[],r=e.apply(this.#ro,this.appliedPluginClasses);return this.#io(e.name,t,r)}insert(e){const t=e(this.#ro,this.appliedPluginClasses),r=t._tinyDepName;if(!r)throw new Error("[TinyClassManager] Plugin class must define a static '_tinyDepName' property.");const i=t._tinyDeps??[];if(!Array.isArray(i)||!i.every(e=>"string"==typeof e))throw new Error("[TinyClassManager] Plugin class must define a static array of strings in '_tinyDepName' property.");return this.#io(r,i,t)}build(){if(this.#eo)throw new Error("[TinyClassManager] Cannot build from an already finalized manager.");return this.#eo=!0,this.#Zn.clear(),this.#to=[],this.#ro}}const pi=mi,fi=ee("TinyRadioFm");class yi extends sr.EventEmitter{static async parseContent(e,t,r,i,s,n){return Kt(e,t,r,i,s,n,yi.#so)}static#so="Unknown Artist";static get unknownArtist(){return yi.#so}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must have an string or function.");yi.#so=e}#h=!1;get destroyed(){return this.#h}get size(){return fi(this.#h),this.#no.length+this.#oo.length}get musicSize(){return fi(this.#h),this.#no.length}get voiceSize(){return fi(this.#h),this.#oo.length}get customPosSize(){return fi(this.#h),this.#ao.length}get tasksSize(){return fi(this.#h),this.#lo.length}get cycleCacheSize(){return fi(this.#h),this.#uo.size}#no=[];get musicList(){return fi(this.#h),structuredClone(this.#no)}#oo=[];get voiceList(){return fi(this.#h),structuredClone(this.#oo)}#ao=[];get customPositions(){return fi(this.#h),structuredClone(this.#ao)}#lo=[];get scheduledTasks(){return fi(this.#h),structuredClone(this.#lo)}get allList(){return fi(this.#h),[...this.musicList,...this.voiceList]}#fs=0;get seed(){return fi(this.#h),this.#fs}set seed(e){if(fi(this.#h),"number"!=typeof e)throw new TypeError("Seed must be a number.");this.#fs=e,this.#uo.clear(),this.emit("seedChanged",{seed:e})}#ho=Date.now();get anchorDate(){return fi(this.#h),this.#ho}#uo=new Map;#vt={mode:"playlist",voiceMode:"playlist",silenceDuration:0,queryLimit:1e5,voiceAfterMusic:!0,voiceMin:0,voiceMax:1,musicMaxConsecutive:0,musicMinConsecutive:0,voiceMaxConsecutive:0,voiceMinConsecutive:0};get config(){return fi(this.#h),structuredClone(this.#vt)}set config(e){fi(this.#h),this.#co(e),this.#vt=structuredClone(e),this.#uo.clear(),this.emit("configChanged",{config:this.config})}#co(e){if("object"!=typeof e||null===e)throw new TypeError("Configuration must be a valid object.");const t=["playlist","random"];if(void 0!==e.mode&&!t.includes(e.mode))throw new TypeError(`Invalid mode: "${e.mode}". Must be one of: ${t.join(", ")}.`);if(void 0!==e.voiceMode&&!t.includes(e.voiceMode))throw new TypeError(`Invalid voiceMode: "${e.voiceMode}". Must be one of: ${t.join(", ")}.`);if(void 0!==e.silenceDuration&&("number"!=typeof e.silenceDuration||e.silenceDuration<0))throw new TypeError("silenceDuration must be a non-negative number.");if(void 0!==e.queryLimit&&("number"!=typeof e.queryLimit||e.queryLimit<=0))throw new TypeError("queryLimit must be a positive number.");if(void 0!==e.voiceAfterMusic&&"boolean"!=typeof e.voiceAfterMusic)throw new TypeError("voiceAfterMusic must be a boolean.");const r=(e,t)=>{if(void 0!==e&&("number"!=typeof e||e<0))throw new TypeError(`${t} must be a non-negative number.`)};r(e.voiceMin,"voiceMin"),r(e.voiceMax,"voiceMax"),r(e.musicMinConsecutive,"musicMinConsecutive"),r(e.musicMaxConsecutive,"musicMaxConsecutive"),r(e.voiceMinConsecutive,"voiceMinConsecutive"),r(e.voiceMaxConsecutive,"voiceMaxConsecutive");const i=e.voiceMin??this.#vt.voiceMin,s=e.voiceMax??this.#vt.voiceMax;if(s<i)throw new RangeError(`Logical error: voiceMax (${s}) cannot be less than voiceMin (${i}).`);const n=e.musicMinConsecutive??this.#vt.musicMinConsecutive,o=e.musicMaxConsecutive??this.#vt.musicMaxConsecutive;if(-1!==o&&n>o)throw new RangeError(`Logical error: musicMinConsecutive (${n}) cannot be greater than musicMaxConsecutive (${o}).`)}#do=!0;get optimizeMediaMemory(){return fi(this.#h),this.#do}set optimizeMediaMemory(e){if(fi(this.#h),"boolean"!=typeof e)throw new TypeError("optimizeMediaMemory must be a boolean.");this.#do=e}#mo=!0;get optimizePictureMemory(){return fi(this.#h),this.#mo}set optimizePictureMemory(e){if(fi(this.#h),"boolean"!=typeof e)throw new TypeError("optimizePictureMemory must be a boolean.");this.#mo=e}constructor(e=null,t=0){if(super(),null!==e&&"object"!=typeof e)throw new TypeError("initialData must be an object or null.");if("number"!=typeof t)throw new TypeError("seed must be a number.");this.#fs=t,e?this.#po(e):this.#ho=Date.now()}_ccBase64ToBlobUrl(e){this.#do&&"string"==typeof e.url&&e.url.startsWith("data:")&&(e.url=Ht(e.url)),e.picture&&Array.isArray(e.picture)&&(e.picture=e.picture.map(e=>{if(this.#mo){const t="string"==typeof e.data&&e.data.startsWith("data:"),r=e.data instanceof Uint8Array;if(t||r)return{...e,data:Ht(e.data,e.format)}}return e}))}async _rcblobUrlToBase64(e){this.#do&&"string"==typeof e.url&&e.url.startsWith("blob:")&&(e.url=await Ft(e.url)),this.#mo&&e.picture&&Array.isArray(e.picture)&&(e.picture=await Promise.all(e.picture.map(async e=>"string"==typeof e.data&&e.data.startsWith("blob:")?{...e,data:await Ft(e.data)}:e)))}add(e,t,r=!0){if(fi(this.#h),!["music","voice","custom"].includes(e))throw new TypeError('Type must be "music", "voice", or "custom".');if(!t||"string"!=typeof t.id||"number"!=typeof t.duration)throw new TypeError("Content must have a string ID and a valid numerical duration in milliseconds.");if("boolean"!=typeof r)throw new TypeError("smartQueue must be a boolean.");const i=structuredClone(t);this._ccBase64ToBlobUrl(i),"music"===e?(this.#no.push(i),this.#uo.clear()):"voice"===e?(this.#oo.push(i),this.#uo.clear()):"custom"===e&&this.#fo(i,r),this.#yo(Date.now()),this.emit("contentAdded",{type:e,data:structuredClone(i)})}scheduleTask(e,t,r,i,s=!0){if(fi(this.#h),"number"!=typeof e||isNaN(e))throw new TypeError("timestamp must be a valid number.");if(!["add","remove","move"].includes(t))throw new TypeError('action must be "add", "remove", or "move".');if(!["music","voice"].includes(r))throw new TypeError('type must be "music" or "voice".');if("boolean"!=typeof s)throw new TypeError("smartQueue must be a boolean.");if("add"===t){if("object"!=typeof i||null===i||"string"!=typeof i.id||"number"!=typeof i.duration)throw new TypeError('Payload for "add" must be a MediaContent object (id: string, duration: number).')}else if("remove"===t){if("string"!=typeof i)throw new TypeError('Payload for "remove" must be a string (the content ID).')}else if("move"===t&&("object"!=typeof i||null===i||"string"!=typeof i.id||"number"!=typeof i.newIndex))throw new TypeError('Payload for "move" must be a ScheduledMovePayload (id: string, newIndex: number).');let n=e;if(s){const t=this.#go(e,e);t&&(n=t.absoluteEnd)}const o={timestamp:n,action:t,type:r,payload:i};this.#lo.push(o),this.#yo(Date.now()),this.emit("taskScheduled",structuredClone(o))}remove(e){if(fi(this.#h),"string"!=typeof e)throw new TypeError("id must be a string.");this.#no.filter(t=>t.id===e).forEach(e=>Bt(e)),this.#oo.filter(t=>t.id===e).forEach(e=>Bt(e)),this.#ao.filter(t=>t.content?.id===e).forEach(e=>Bt(e.content));const t=t=>t.id!==e&&t.content?.id!==e;this.#no=this.#no.filter(t),this.#oo=this.#oo.filter(t),this.#ao=this.#ao.filter(t),this.#lo=this.#lo.filter(t=>"add"===t.action&&"object"==typeof t.payload&&null!==t.payload&&"id"in t.payload?t.payload.id!==e||(Bt(t.payload),!1):t.payload!==e),this.#uo.clear(),this.emit("contentRemoved",{id:e})}setConfig(e){fi(this.#h),this.#co(e);const t={...this.#vt,...e};this.#co(t),this.#vt=t,this.#uo.clear(),this.emit("configChanged",{config:this.config})}getCurrentEvent(){fi(this.#h);const e=Date.now();return this.#yo(e),this.#go(e,e)}queryTimeline(e,t=10){if(fi(this.#h),"number"!=typeof t||isNaN(t))throw new TypeError("Invalid query limit value. Ensure it is a number.");if(t>this.#vt.queryLimit||t<=0)throw new RangeError(`Invalid query limit. Ensure it is > 0 and <= ${this.#vt.queryLimit}.`);const r=new yi(JSON.parse(this._exportState())),i=[];let s=e;for(let n=0;n<t;n++){r.#yo(s);const t=r.#bo(s,e);if(!t)break;i.push(t),s=t.absoluteEnd}return r.destroy(!1),this.emit("timelineQueried",{targetDate:e,limit:t,resultCount:i.length}),i}searchCustomPositions(){return fi(this.#h),this.#yo(Date.now()),[...this.#ao]}async _processListForExport(e){return Promise.all(e.map(async e=>{const t=structuredClone(e);return await this._rcblobUrlToBase64(t),t}))}_exportState(){return JSON.stringify({music:this.#no,voice:this.#oo,custom:this.#ao,tasks:this.#lo,seed:this.#fs,anchorDate:this.#ho,config:this.#vt})}async exportState(){fi(this.#h);const e=await this._processListForExport(this.#no),t=await this._processListForExport(this.#oo),r=await Promise.all(this.#ao.map(async e=>{const t=await this._processListForExport([e.content]);return{...e,content:t[0]}})),i=await Promise.all(this.#lo.map(async e=>{if("add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload){const t=await this._processListForExport([e.payload]);return{...e,payload:t[0]}}return e}));return JSON.stringify({music:e,voice:t,custom:r,tasks:i,seed:this.#fs,anchorDate:this.#ho,config:this.#vt})}importState(e){let t;if(fi(this.#h),"string"==typeof e)try{t=JSON.parse(e)}catch{throw new TypeError("Provided string is not valid JSON.")}else{if("object"!=typeof e||null===e)throw new TypeError("Import data must be a valid JSON string or an object.");t=e}this.#po(t),this.emit("stateImported",{data:structuredClone(t)})}_prng(e){return function(){let t=e+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}#wo(e,t,r,i=0,s=0,n=null,o=0){if(0===e.length)return{items:[],lastId:n,consecutiveCount:o};if("random"!==r){const t=[...e],r=t[t.length-1];return{items:t,lastId:r.id,consecutiveCount:n===r.id?o+1:1}}const a=e.map(e=>({...e,weight:e.weight??1})),l=this._prng(t),u=[];let h=n,c=o;for(;a.length>0;){let e=null,t=-1;if(null!==h&&c<i&&(t=a.findIndex(e=>e.id===h),-1!==t?e=a[t]:u.length>0&&(e=u[u.length-1])),!e){let r=a;null!==h&&-1!==s&&c>=s&&(r=a.filter(e=>e.id!==h)),0===r.length&&(r=a);const i=r.reduce((e,t)=>e+t.weight,0);if(i<=0)e=r[0],t=a.findIndex(t=>t.id===e?.id);else{const s=l()*i;let n=0;for(let i=0;i<r.length;i++)if(n+=r[i].weight,s<=n){e=r[i],t=a.findIndex(t=>t.id===e?.id);break}}}e||(e=a[0],t=0),u.push(e),-1!==t&&a.splice(t,1),e.id===h?c++:(h=e.id,c=1)}return{items:u,lastId:h,consecutiveCount:c}}#vo(e){const t=this.#fs+e,r=this._prng(10*t);let i=null,s=0,n=null,o=0;if(e>0){const t=this.#uo.get(e-1);t&&(i=t.lastMusicId??null,s=t.musicConsecutiveCount??0,n=t.lastVoiceId??null,o=t.voiceConsecutiveCount??0)}const a=this.#wo(this.#no,t+1,this.#vt.mode,this.#vt.musicMinConsecutive,this.#vt.musicMaxConsecutive,i,s),l=a.items,u=this.#wo(this.#oo,t+2,this.#vt.voiceMode,this.#vt.voiceMinConsecutive,this.#vt.voiceMaxConsecutive,n,o),h=u.items,c=[];let d=0,m=0;for(let e=0;e<l.length;e++){const t=l[e];if(c.push({...t,cycleStart:d,cycleEnd:d+t.duration}),d+=t.duration+this.#vt.silenceDuration,this.#vt.voiceAfterMusic&&h.length>0){const e=this.#vt.voiceMax-this.#vt.voiceMin+1,t=Math.floor(r()*e)+this.#vt.voiceMin;for(let e=0;e<t;e++){const e=h[m%h.length];m++,c.push({...e,cycleStart:d,cycleEnd:d+e.duration}),d+=e.duration+this.#vt.silenceDuration}}}return{items:c,duration:d,lastMusicId:a.lastId,musicConsecutiveCount:a.consecutiveCount,lastVoiceId:u.lastId,voiceConsecutiveCount:u.consecutiveCount}}#Eo(e){if(0===this.#no.length)return null;let t=this.#ho,r=0;for(;;){if(r>this.#vt.queryLimit)throw new Error("Safety limit hit during cycle location.");let i=this.#uo.get(r);if(i||(i=this.#vo(r),this.#uo.set(r,i)),0===i.duration)return null;if(e>=t&&e<t+i.duration)return{block:i,startTimestamp:t,loopIndex:r};t+=i.duration,r++}}#bo(e,t){const r=this.#ao.filter(t=>t.intendedTimestamp+t.content.duration>e).sort((e,t)=>e.intendedTimestamp-t.intendedTimestamp)[0];let i=null;if(r){const e=Math.max(t,r.intendedTimestamp);i=this.#To(r.content,r.intendedTimestamp,e,!0)}const s=this.#So(e,t);return s||i?s?i?i.absoluteStart<=s.absoluteStart?i:(i.absoluteStart<s.absoluteEnd&&(s.absoluteEnd=i.absoluteStart,s.duration=s.absoluteEnd-s.absoluteStart,s.remainingTime=Math.max(0,s.absoluteEnd-t),s.progress=Math.min(1,s.elapsedTime/s.duration)),s):s:i:null}#So(e,t){let r=this.#Eo(e);if(!r)return null;const{block:i,startTimestamp:s}=r,n=e-s;let o,a=i.items.find(e=>e.cycleEnd>n);if(a)o=s+a.cycleStart;else{if(r=this.#Eo(s+i.duration),!r||0===r.block.items.length)return null;a=r.block.items[0],o=r.startTimestamp+a.cycleStart}const l=Math.max(t,o);return this.#To(a,o,l,!1)}#go(e,t){const r=this.#ao.find(t=>e>=t.intendedTimestamp&&e<t.intendedTimestamp+t.content.duration);if(r)return this.#To(r.content,r.intendedTimestamp,t,!0);const i=this.#Eo(e);if(!i)return null;const{block:s,startTimestamp:n}=i,o=e-n,a=s.items.find(e=>o>=e.cycleStart&&o<e.cycleEnd);return a?this.#To(a,n+a.cycleStart,t,!1):null}#To(e,t,r,i){const s=r-t;return{id:e.id,title:e.title,artist:e.artist,duration:e.duration,url:e.url,absoluteStart:t,absoluteEnd:t+e.duration,elapsedTime:s,remainingTime:e.duration-s,progress:Math.min(1,s/e.duration),isCustom:i}}#fo(e,t){let r=e.timestamp||Date.now();const i=e.duration;if(t){const e=this.#go(r,r);e&&(r=e.absoluteEnd)}const s=[...this.#ao].sort((e,t)=>e.intendedTimestamp-t.intendedTimestamp);let n=r;if(s.some(e=>r<e.intendedTimestamp+e.content.duration&&r+i>e.intendedTimestamp)){const e=[];let t=Date.now();for(const r of s)r.intendedTimestamp>t&&e.push({start:t,end:r.intendedTimestamp}),t=Math.max(t,r.intendedTimestamp+r.content.duration+this.#vt.silenceDuration);e.push({start:t,end:1/0});let o=1/0;for(const t of e)if(t.end-t.start>=i){let e=null;if(r>=t.start&&r+i<=t.end?e=r:r<t.start?e=t.start:r>t.end&&(e=t.end-i),null!==e){const t=Math.abs(r-e);t<o&&(o=t,n=e)}}}this.#ao.push({content:e,intendedTimestamp:n,originalTimestamp:e.timestamp||Date.now()})}#yo(e){const t=this.#lo.filter(t=>t.timestamp<=e);this.#lo=this.#lo.filter(t=>t.timestamp>e);const r=this.#ao.filter(t=>t.intendedTimestamp+t.content.duration<=e);this.#ao=this.#ao.filter(t=>t.intendedTimestamp+t.content.duration>e);let i=!1;r.forEach(e=>{Bt(e.content),this.#fs+=e.content.id.length,i=!0,this.emit("customPositionExpired",{contentId:e.content.id})}),t.length>0&&t.sort((e,t)=>e.timestamp-t.timestamp).forEach(e=>{const t="music"===e.type?this.#no:this.#oo;if("add"===e.action)t.push(e.payload);else if("remove"===e.action){const r=t.findIndex(t=>t.id===e.payload);if(-1!==r){const[e]=t.splice(r,1);Bt(e)}}else if("move"===e.action){const r=e.payload,i=t.findIndex(e=>e.id===r.id);if(-1!==i){const[e]=t.splice(i,1);t.splice(r.newIndex,0,e)}}this.#ho=e.timestamp,this.#fs+=1,i=!0,this.emit("taskExecuted",structuredClone(e))}),i&&this.#uo.clear()}#po(e){this.#no.forEach(e=>Bt(e)),this.#oo.forEach(e=>Bt(e)),this.#ao.forEach(e=>Bt(e.content)),this.#lo.forEach(e=>{"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload&&Bt(e.payload)});const t=e=>e.map(e=>{const t=structuredClone(e);return this._ccBase64ToBlobUrl(t),t});this.#no=t(e.music),this.#oo=t(e.voice),this.#fs=e.seed||0,this.#ho=e.anchorDate||Date.now(),this.#vt={...this.#vt,...e.config||{}},this.#ao=e.custom.map(e=>({...e,content:t([e.content])[0]})),this.#lo=e.tasks.map(e=>"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload?{...e,payload:t([e.payload])[0]}:e)}destroy(e=!0){this.#h||(e&&(this.#no.forEach(e=>Bt(e)),this.#oo.forEach(e=>Bt(e)),this.#ao.forEach(e=>Bt(e.content)),this.#lo.forEach(e=>{"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload&&Bt(e.payload)})),this.#no=[],this.#oo=[],this.#ao=[],this.#lo=[],this.#uo.clear(),this.emit("destroyed",{timestamp:Date.now()}),this.removeAllListeners(),this.#h=!0)}}const gi=yi,bi=["chrome","firefox","ie","edge","safari","opera","yandex","other"];function wi(){const e=navigator.userAgent;return-1!==e.indexOf("Chrome")?"chrome":-1!==e.indexOf("Firefox")?"firefox":-1!==e.indexOf("MSIE")?"ie":-1!==e.indexOf("Edge")?"edge":-1!==e.indexOf("Safari")?"safari":-1!==e.indexOf("Opera")?"opera":-1!==e.indexOf("YaBrowser")?"yandex":"other"}function vi(){const e=(Array.prototype.slice.call(window.getComputedStyle(document.documentElement,"")).join("").match(/-(moz|webkit|ms)-/)??["",""])[1];return"moz"===e?"gecko":"webkit"===e?"webkit":"ms"===e?"trident":"other"}function Ei(){const e=!!window.opr&&!!opr.addons||!!window.opera||navigator.userAgent.indexOf(" OPR/")>=0,t="undefined"!=typeof InstallTrigger,r=/constructor/i.test(window.HTMLElement)||"[object SafariRemoteNotification]"===(!window.safari||"undefined"!=typeof safari&&safari.pushNotification).toString(),i=!!document.documentMode,s=!i&&!!window.StyleMedia,n=!!window.chrome;return{isOpera:e,isFirefox:t,isSafari:r,isIE:i,isEdge:s,isChrome:n,isBlink:(n||e)&&!!window.CSS}}function Ti(e=[]){if(!Array.isArray(e))throw new TypeError('The "disable" argument must be an array.');for(const t of e)if(!bi.includes(t))throw new TypeError(`Invalid browser name provided in disable array: ${t}`);const t={chrome:0,firefox:0,ie:0,edge:0,safari:0,opera:0,yandex:0,other:0};t[wi()]++;const r=vi();"gecko"===r?e.indexOf("firefox")<0&&t.firefox++:"webkit"===r?(e.indexOf("chrome")<0&&t.chrome++,e.indexOf("safari")<0&&t.safari++,e.indexOf("opera")<0&&t.opera++,e.indexOf("edge")<0&&t.edge++):"trident"===r?e.indexOf("ie")<0&&t.ie++:e.indexOf("other")<0&&t.other++;const i=Ei();return i.isOpera&&e.indexOf("opera")<0&&t.opera++,i.isFirefox&&e.indexOf("firefox")<0&&t.firefox++,i.isSafari&&e.indexOf("safari")<0&&t.safari++,i.isIE&&e.indexOf("ie")<0&&t.ie++,i.isEdge&&e.indexOf("edge")<0&&t.edge++,i.isChrome&&e.indexOf("chrome")<0&&t.chrome++,t}function Si(e=[]){const t=Ti(e);return Object.keys(t).reduce((e,r)=>t[r]>t[e]?r:e)}class xi extends sr.EventEmitter{#xo;#Ao;#Co;#Io;#Mo;#Do=new Map([["log",""],["info",""],["warn",""],["error",""],["debug",""],["reset",""],["black",""],["red",""],["green",""],["yellow",""],["blue",""],["magenta",""],["cyan",""],["white",""],["gray",""]]);#ko=new Map([["log","[_log_LOG_reset_]"],["info","[_info_INFO_reset_]"],["warn","[_warn_WARN_reset_]"],["error","[_error_ERROR_reset_]"],["debug","[_debug_DEBUG_reset_]"]]);constructor({logger:e,id:t,debugMode:r,canEmitLogs:i=!1,useLogColors:s=!1}){if(super(),!b(e))throw new TypeError("Logger must be an object that implements the Console interface.");if("string"!=typeof t)throw new TypeError("Logger instance id must be a string.");if("boolean"!=typeof r)throw new TypeError("debugMode must be a boolean.");if("boolean"!=typeof i)throw new TypeError("canEmitLogs must be a boolean.");if("boolean"!=typeof s)throw new TypeError("useLogColors must be a boolean.");this.#Ao=t,this.#xo=e,this.#Io=r,this.#Co=i,this.#Mo="firefox"!==Si()&&s,this.log("info","Emit logs of debug mode set to: "+(this.#Io?"ON":"OFF")),this.log("info","Custom logger assigned.")}get logId(){return this.#Ao}get canEmitLogs(){return this.#Co}get useLogColors(){return this.#Mo}set useLogColors(e){if("boolean"!=typeof e)throw new TypeError("useLogColors must be a boolean.");this.#Mo=e,this.log("info","Log Colors usage mode set to: "+(this.#Mo?"ON":"OFF")),this.emit("setDebugMode",e)}get debugMode(){return this.#Io}set debugMode(e){if("boolean"!=typeof e)throw new TypeError("debugMode must be a boolean.");this.#Io=e,this.log("info","Debug mode set to: "+(this.#Io?"ON":"OFF")),this.emit("setDebugMode",e)}_addLogColor(e,t){this.#Do.set(e,t)}_removeLogColor(e){this.#Do.delete(e)}_addLogPrefix(e,t){this.#ko.set(e,t)}_removeLogPrefix(e){this.#ko.delete(e)}#No(e){if("string"!=typeof e)return e;let t=e;for(const[e,r]of this.#ko){const i=new RegExp(`\\:${e}\\:`,"g");t=t.replace(i,r)}for(const[e,r]of this.#Do){const i=new RegExp(`\\_${e}\\_`,"g");t=t.replace(i,this.#Mo?r:"")}return t}logClear(){if(this.#Io)return this.#Co&&this.emit("debug:clear"),this.#xo.clear?this.#xo.clear():console.clear()}logGroupEnd(){if(this.#Io)return this.#Co&&this.emit("debug:groupEnd"),this.#xo.groupEnd?this.#xo.groupEnd():console.groupEnd()}logLabel(e,t){if(!this.#Io)return;const r=["count","countReset","time","timeEnd","profile","profileEnd","timeStamp"];if(!r.includes(e))throw new TypeError(`Invalid logType. Expected one of: ${r.join(", ")}`);if(void 0!==t&&"string"!=typeof t)throw new TypeError("The label must be a string.");const i=this.#xo[e]?this.#xo[e]:console[e];if(!i)throw new TypeError(`The log type "${e}" is not supported by the provided logger or console.`);return this.#Co&&this.emit("debug:logLabel",e,t),i(t)}logTimeLabel(e,...t){if(this.#Io)return this.#Co&&this.emit("debug:timeLog",e,...t),this.#xo.timeLog?this.#xo.timeLog(e,...t):console.timeLog(e,...t)}logAssert(e,...t){if(this.#Io)return this.#Co&&this.emit("debug:assert",e,...t),this.#xo.assert?this.#xo.assert(e,...t):console.assert(e,...t)}logDir(e,t){if(this.#Io)return this.#Co&&this.emit("debug:dir",e,t),this.#xo.dir?this.#xo.dir(e,t):console.dir(e,t)}logTable(e,t){if(this.#Io){if(!(void 0===t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("Properties must be an array of strings.");return this.#Co&&this.emit("debug:table",e,t),this.#xo.table?this.#xo.table(e,t):console.table(e,t)}}log(e,t,...r){if(!this.#Io)return;const i=["log","info","warn","error","debug","dirxml","group","groupCollapsed","trace"];if(!i.includes(e))throw new TypeError(`Invalid logType. Expected one of: ${i.join(", ")}`);if("string"!=typeof t)throw new TypeError("The message must be a string.");let s=this.#Ao,n=t;s=this.#No(s),n=this.#No(n);const o=this.#xo[e]?this.#xo[e]:console[e];return o?(this.#Co&&this.emit("debug:log",s,n,...r),o(s,n,...r)):(this.#Co&&this.emit("debug:log",s,n,...r),console.log(s,n,...r))}}const Ai=xi,Ci=ee("BaseMediaAdapter");class Ii extends sr.EventEmitter{constructor(){if(new.target===Ii)throw new Error("BaseMediaAdapter is an abstract class and cannot be instantiated directly.");super()}#h=!1;get destroyed(){return this.#h}static getThumbnailUrl(e){if("string"!=typeof e||""===e.trim())throw new TypeError('The "trackId" must be a non-empty string.');return""}static canHandle(e){throw new Error('Method "canHandle" must be implemented by the subclass.')}isReady(){throw Ci(this.#h),new Error('Method "isReady" must be implemented by the subclass.')}isPaused(){throw Ci(this.#h),new Error('Method "isPaused" must be implemented by the subclass.')}isEnded(){throw Ci(this.#h),new Error('Method "isEnded" must be implemented by the subclass.')}async waitIsReady(){throw Ci(this.#h),new Error('Method "waitIsReady" must be implemented by the subclass.')}canHandle(e){return Ci(this.#h),Ii.canHandle(e)}async play(e){throw Ci(this.#h),new Error('Method "play" must be implemented by the subclass.')}async pause(){throw Ci(this.#h),new Error('Method "pause" must be implemented by the subclass.')}async stop(){throw Ci(this.#h),new Error('Method "stop" must be implemented by the subclass.')}async seek(e){throw Ci(this.#h),new Error('Method "seek" must be implemented by the subclass.')}isMuted(){throw Ci(this.#h),new Error('Method "isMuted" must be implemented by the subclass.')}async mute(){throw Ci(this.#h),new Error('Method "mute" must be implemented by the subclass.')}async unMute(){throw Ci(this.#h),new Error('Method "unMute" must be implemented by the subclass.')}getCurrentTime(){throw Ci(this.#h),new Error('Method "getCurrentTime" must be implemented by the subclass.')}getTotalDuration(){throw Ci(this.#h),new Error('Method "getTotalDuration" must be implemented by the subclass.')}getRemainingTime(){throw Ci(this.#h),new Error('Method "getRemainingTime" must be implemented by the subclass.')}getPlaybackPercentage(){throw Ci(this.#h),new Error('Method "getPlaybackPercentage" must be implemented by the subclass.')}getTimeData(){throw Ci(this.#h),new Error('Method "getTimeData" must be implemented by the subclass.')}setVolume(e){throw Ci(this.#h),new Error('Method "setVolume" must be implemented by the subclass.')}getVolume(){throw Ci(this.#h),new Error('Method "getVolume" must be implemented by the subclass.')}async getContentData(){throw Ci(this.#h),new Error('Method "getContentData" must be implemented by the subclass.')}destroy(){this.#h||(this.removeAllListeners(),this.#h=!0,this.emit("destroyed"))}}const Mi=ee("TinyMediaPlayer");class Di extends Ai{static BaseMediaAdapter=Ii;static#so="Unknown Artist";static get unknownArtist(){return Di.#so}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must be a string or a function.");Di.#so=e}static async parseContent(e,t,r,i,s,n){return Kt(e,t,r,i,s,n,Di.#so)}#h=!1;get destroyed(){return this.#h}#Lo=new Set;#_o=new WeakMap;#jo=[];#Ro=-1;#Po="NONE";#$o=!1;#Oo=!1;#Ho=!1;#Fo=1;#Bo;#zo;#Wo;#Vo=!1;#qo;#Ko;#Jo=null;#Uo=null;#Go=300;get fadeVolumeSpeed(){return Mi(this.#h),this.#Go}set fadeVolumeSpeed(e){if(Mi(this.#h),"number"!=typeof e)throw new TypeError("fadeVolumeSpeed must be a number.");if(e<0)throw new RangeError("fadeVolumeSpeed cannot be negative.");this.#Go=e,this.emit("fadeVolumeSpeedChange",this.#Go)}#Yo=2e3;get prevClickTimeoutDuration(){return Mi(this.#h),this.#Yo}set prevClickTimeoutDuration(e){if(Mi(this.#h),"number"!=typeof e)throw new TypeError("prevClickTimeoutDuration must be a number.");if(e<0)throw new RangeError("prevClickTimeoutDuration cannot be negative.");this.#Yo=e,this.emit("prevClickTimeoutDurationChange",this.#Yo)}get repeatCurrentOnPrev(){return Mi(this.#h),this.#Wo}set repeatCurrentOnPrev(e){if(Mi(this.#h),"boolean"!=typeof e)throw new TypeError("repeatCurrentOnPrev must be a boolean.");this.#Wo=e,this.emit("repeatCurrentOnPrevChange",this.#Wo)}get smoothPlayPauseVolume(){return Mi(this.#h),this.#qo}set smoothPlayPauseVolume(e){if(Mi(this.#h),"boolean"!=typeof e)throw new TypeError("smoothPlayPauseVolume must be a boolean.");this.#qo=e,this.emit("smoothPlayPauseVolumeChange",this.#qo)}get smoothStopVolume(){return Mi(this.#h),this.#Ko}set smoothStopVolume(e){if(Mi(this.#h),"boolean"!=typeof e)throw new TypeError("smoothStopVolume must be a boolean.");this.#Ko=e,this.emit("smoothStopVolumeChange",this.#Ko)}constructor(e={}){if(!b(e))throw new TypeError("Options must be a non-null object.");if(super({id:"[_blue_TinyMediaPlayer_reset_] :debug:",logger:e.logger??console,debugMode:e.debugMode??!1,useLogColors:e.useLogColors??!1}),void 0!==e.persistVolume){if("boolean"!=typeof e.persistVolume)throw new TypeError("persistVolume must be a boolean.");this.#Bo=e.persistVolume}else this.#Bo=!1;if(void 0!==e.volumeStorageKey){if("string"!=typeof e.volumeStorageKey)throw new TypeError("volumeStorageKey must be a string.");this.#zo=e.volumeStorageKey}else this.#zo="tiny_media_player_volume";if(void 0!==e.repeatCurrentOnPrev){if("boolean"!=typeof e.repeatCurrentOnPrev)throw new TypeError("repeatCurrentOnPrev must be a boolean.");this.#Wo=e.repeatCurrentOnPrev}else this.#Wo=!1;if(void 0!==e.smoothPlayPauseVolume){if("boolean"!=typeof e.smoothPlayPauseVolume)throw new TypeError("smoothPlayPauseVolume must be a boolean.");this.#qo=e.smoothPlayPauseVolume}else this.#qo=!1;if(void 0!==e.smoothStopVolume){if("boolean"!=typeof e.smoothStopVolume)throw new TypeError("smoothStopVolume must be a boolean.");this.#Ko=e.smoothStopVolume}else this.#Ko=!1;this.#Bo&&this.#Xo(),this.log("info","Instance initialized.",{options:e})}#Xo(){try{if("undefined"!=typeof window&&window.localStorage){const e=window.localStorage.getItem(this.#zo);if(null!==e){const t=parseFloat(e);!isNaN(t)&&t>=0&&t<=1&&(this.#Fo=t,this.log("info",`Volume loaded from storage: ${this.#Fo}`))}}}catch(e){console.warn("[TinyMediaPlayer] Failed to read volume from localStorage.",e)}}#Qo(){try{this.#Bo&&"undefined"!=typeof window&&window.localStorage&&(window.localStorage.setItem(this.#zo,this.#Fo.toString()),this.log("info",`Volume saved to storage: ${this.#Fo}`))}catch(e){console.warn("[TinyMediaPlayer] Failed to save volume to localStorage.",e)}}_getWeightedRandomIndex(){if(0===this.#jo.length)return-1;if(1===this.#jo.length)return 0;let e=0;for(let t=0;t<this.#jo.length;t++){if(t===this.#Ro)continue;const r=this.#jo[t];e+="number"==typeof r.weight&&r.weight>0?r.weight:1}let t=Math.random()*e;for(let e=0;e<this.#jo.length;e++){if(e===this.#Ro)continue;const r=this.#jo[e],i="number"==typeof r.weight&&r.weight>0?r.weight:1;if(t<i)return e;t-=i}return this.#Ro===this.#jo.length-1?0:this.#jo.length-1}async#Zo(e){this.#Jo&&this.#Jo.abort(),this.#Jo=new AbortController;const{signal:t}=this.#Jo,r=this.#ea();if(!r)return;const i=r.getVolume(),s=performance.now(),n=this.#Go;return this.log("info",`Starting volume fade: ${i} -> ${e}`),new Promise(o=>{const a=l=>{if(t.aborted)return this.log("info","Volume fade aborted."),o();const u=l-s,h=Math.min(u/n,1),c=i+(e-i)*h,d=Math.max(0,Math.min(1,c));r.setVolume(d),h<1?requestAnimationFrame(a):(r.setVolume(e),this.log("info",`Volume fade completed: ${e}`),o())};requestAnimationFrame(a)})}get playlist(){return Mi(this.#h),[...this.#jo]}set playlist(e){if(Mi(this.#h),!Array.isArray(e))throw new TypeError("Playlist must be an array of MediaContent objects.");e.forEach(e=>Wt(e));const t=this.#Oo;let r=null;if(-1!==this.#Ro&&this.#jo.length>0)try{r=this.#ea()}catch(e){}this.#jo=e,this.log("info",`Playlist updated. New size: ${this.#jo.length}`),this.emit("playlistUpdate",this.playlist),0===this.#jo.length?this.#Ro=-1:(this.#Ro>=this.#jo.length||-1===this.#Ro)&&(this.#Ro=0),this.emit("trackChange",this.#Ro),t&&(async()=>{try{r&&await r.stop(),-1!==this.#Ro&&await this.play()}catch(e){this.log("error","Background transition error on playlist update:",e),console.warn("[TinyMediaPlayer] Background transition error on playlist update:",e)}})()}get currentIndex(){return Mi(this.#h),this.#Ro}set currentIndex(e){if(Mi(this.#h),"number"!=typeof e)throw new TypeError("Current index must be a number.");if(e<-1||e>=this.#jo.length&&this.#jo.length>0)throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);if(this.#Ro===e)return;this.log("info",`Index change requested: ${this.#Ro} -> ${e}`);const t=this.#Oo;let r=null;if(-1!==this.#Ro&&this.#jo.length>0)try{r=this.#ea()}catch(e){}this.#Ro=e,this.emit("trackChange",this.#Ro),t&&(async()=>{try{r&&await r.stop(),-1!==this.#Ro&&await this.play()}catch(e){this.log("error","Background transition error on index update:",e),console.warn("[TinyMediaPlayer] Background transition error on index update:",e)}})()}get loopMode(){return Mi(this.#h),this.#Po}set loopMode(e){Mi(this.#h);const t=["NONE","TRACK","PLAYLIST"];if(!t.includes(e))throw new TypeError(`Loop mode must be one of: ${t.join(", ")}.`);this.#Po=e,this.log("info",`Loop mode changed to: ${this.#Po}`),this.emit("loopModeChange",this.#Po)}get isRandom(){return Mi(this.#h),this.#$o}set isRandom(e){if(Mi(this.#h),"boolean"!=typeof e)throw new TypeError("Random mode state must be a boolean.");this.#$o=e,this.log("info",`Random mode: ${this.#$o}`),this.emit("randomModeChange",this.#$o)}get isPlaying(){return Mi(this.#h),this.#Oo}get volume(){return Mi(this.#h),this.#Fo}set volume(e){if(Mi(this.#h),"number"!=typeof e)throw new TypeError("Volume must be a number.");if(e<0||e>1)throw new RangeError("Volume must be tightly constrained between 0.0 and 1.0.");if(this.#Jo&&this.#Jo.abort(),this.log("info",`Volume changed: ${this.#Fo} -> ${e}`),this.#Fo=e,this.#Qo(),this.emit("volumeChange",this.#Fo),-1!==this.#Ro&&this.#jo.length>0)try{const e=this.#ea();e&&e.setVolume(this.#Fo)}catch(e){}}get persistVolume(){return Mi(this.#h),this.#Bo}set persistVolume(e){if(Mi(this.#h),"boolean"!=typeof e)throw new TypeError("Persist volume parameter must be a boolean.");this.#Bo=e,this.log("info",`Persist volume: ${this.#Bo}`),e&&this.#Qo()}get volumeStorageKey(){return Mi(this.#h),this.#zo}set volumeStorageKey(e){if(Mi(this.#h),"string"!=typeof e)throw new TypeError("Volume storage key must be a string.");if(""===e.trim())throw new TypeError("Volume storage key cannot be an empty string.");const t=this.#zo;this.#zo=e;try{this.#Bo&&"undefined"!=typeof window&&window.localStorage&&(window.localStorage.removeItem(t),this.#Qo())}catch(e){console.warn("[TinyMediaPlayer] Failed to migrate volume storage key.",e)}}get isMuted(){return Mi(this.#h),this.#Ho}async mute(){Mi(this.#h);const e=this.#ea();e&&(await e.mute(),this.#Ho=!0,this.emit("muteChange",this.#Ho),this.log("info","Playback muted successfully."))}async unMute(){Mi(this.#h);const e=this.#ea();e&&(await e.unMute(),this.#Ho=!1,this.emit("muteChange",this.#Ho),this.log("info","Playback unmuted successfully."))}get adapters(){return Array.from(this.#Lo)}get adaptersSize(){return this.#Lo.size}static#ta=["timeupdate","ended"];static get defaultAdapterEventNames(){return structuredClone(Di.#ta)}static set defaultAdapterEventNames(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError("TinyMediaPlayer.defaultAdapterEventNames must be an array of strings.");Di.#ta=[...e]}#ra=new Set(Di.defaultAdapterEventNames);#ia(e){const t=this.#_o.get(e);t&&(this.#ra.forEach(r=>{const i=t.get(r);i&&e.off(r,i)}),t.clear(),this.#_o.delete(e))}registerAdapter(e){if(Mi(this.#h),!(e instanceof Ii))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");this.log("info","Registering new adapter:",e);const t=new Map;this.#_o.set(e,t),this.#ra.forEach(t=>{this.#sa(e,t)}),this.#Lo.add(e)}removeAdapter(e){if(Mi(this.#h),!(e instanceof Ii))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");return this.log("info","Removing adapter:",e),this.#ia(e),this.#Lo.delete(e)}destroyAdapter(e){if(Mi(this.#h),!(e instanceof Ii))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");this.log("info","Destroying adapter:",e),this.#ia(e);const t=this.#Lo.delete(e);return t&&e.destroy(),t}hasAdapter(e){if(Mi(this.#h),!(e instanceof Ii))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");return this.#Lo.has(e)}destroyAllAdapters(){Mi(this.#h),this.log("info","Destroying all adapters."),this.#Lo.forEach(e=>{this.#ia(e),e.destroy()}),this.#Lo.clear()}clearAdapters(){Mi(this.#h),this.log("info","Clearing all adapters."),this.#Lo.forEach(e=>this.#ia(e)),this.#Lo.clear()}getMediaAdapter(e){if(!b(e))throw new TypeError("Content must be a valid object.");for(const t of this.#Lo.values())if(t.canHandle(e))return t;return null}#ea(){if(-1===this.#Ro||0===this.#jo.length)return null;const e=this.#jo[this.#Ro],t=this.getMediaAdapter(e);if(t)return t;const r=`No compatible adapter found for content ID: ${e.id}.`;throw this.log("error",r),new Error(r)}addAdapterEvent(e){if(Mi(this.#h),"string"!=typeof e)throw new TypeError("Event name must be a string.");this.#ra.has(e)||(this.log("info",`Adding adapter event listener: ${e}`),this.#ra.add(e),this.#Lo.forEach(t=>{this.#sa(t,e)}))}removeAdapterEvent(e){if(Mi(this.#h),"string"!=typeof e)throw new TypeError("Event name must be a string.");this.#ra.has(e)&&(this.log("info",`Removing adapter event listener: ${e}`),this.#ra.delete(e),this.#Lo.forEach(t=>{this.#na(t,e)}))}resetAdapterEvents(){Mi(this.#h);const e=Di.defaultAdapterEventNames,t=Array.from(this.#ra);for(const r of t)e.includes(r)||this.removeAdapterEvent(r);for(const t of e)this.#ra.has(t)||this.addAdapterEvent(t)}#sa(e,t){const r=this.#_o.get(e);if(!r)return;const i=(...e)=>{this.#h||("timeupdate"!==t&&this.log("debug",`Adapter event triggered: ${t}`,...e),this.emit(t,...e))};e.on(t,i),r.set(t,i)}#na(e,t){const r=this.#_o.get(e);if(!r)return;const i=r.get(t);i&&(e.off(t,i),r.delete(t))}addTrack(e){if(Mi(this.#h),!b(e)||"string"!=typeof e.url)throw new TypeError("Track content must be a valid MediaContent object containing a URL.");const t={id:"",title:"",artist:"",url:"",duration:0,weight:1,title:null,album:null,albumartist:null,albumartists:[],genre:[],label:[],composer:[],year:null,artist:null,artists:[],disk:{no:null,of:null},track:{no:null,of:null},picture:[],...e};Wt(t);const r=this.#jo.push(t);return this.log("info",`Track added. New length: ${r}`,t),-1===this.#Ro&&(this.#Ro=0,this.emit("trackChange",this.#Ro)),this.emit("playlistUpdate",this.playlist),r}existsTrack(e){if(Mi(this.#h),"number"!=typeof e)throw new TypeError("Index must be a number.");return e>=0&&e<this.#jo.length}getTrack(e){if(Mi(this.#h),"number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);return this.#jo[e]}async removeTrack(e){if(Mi(this.#h),"number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);this.log("info",`Removing track at index: ${e}`),e===this.#Ro?(await this.stop(),this.#jo.splice(e,1),0===this.#jo.length?this.#Ro=-1:this.#Ro>=this.#jo.length&&(this.#Ro=0),this.emit("trackChange",this.#Ro)):(this.#jo.splice(e,1),e<this.#Ro&&(this.#Ro-=1,this.emit("trackChange",this.#Ro))),this.emit("playlistUpdate",this.playlist)}searchTrack(e){if(Mi(this.#h),"string"!=typeof e&&"function"!=typeof e)throw new TypeError("Search query must be a string or a boolean evaluation function.");this.log("info","Searching playlist...",{query:e});const t=[];for(let r=0;r<this.#jo.length;r++){const i=this.#jo[r];let s=!1;if("function"==typeof e)s=Boolean(e(i));else{const t=e.toLowerCase(),r=i.title&&i.title.toLowerCase().includes(t),n=i.artist&&i.artist.toLowerCase().includes(t),o=i.album&&i.album.toLowerCase().includes(t);s=Boolean(r||n||o)}s&&t.push({track:i,index:r})}return this.log("info",`Search completed. Found ${t.length} results.`),t}async clearPlaylist(){Mi(this.#h),this.log("info","Clearing entire playlist."),await this.stop(),this.#jo=[],this.#Ro=-1,this.emit("playlistUpdate",this.playlist),this.emit("trackChange",this.#Ro)}async play(){Mi(this.#h),this.log("info",`Attempting to play track at index: ${this.#Ro}`);const e=this.#ea();if(e){this.#qo?await this.#Zo(this.#Fo):e.setVolume(this.#Fo);try{await e.play(this.#jo[this.#Ro]),this.#Ho&&await e.mute(),this.#Oo=!0,this.log("info","Playback started successfully."),this.emit("play",this.#Ro)}catch(e){throw this.log("error","Failed to play track:",e),e}}else this.log("error","Failed to play track:",`Active adapter not found for track at index ${this.#Ro}.`)}async pause(){Mi(this.#h),this.log("info","Attempting to pause playback.");const e=this.#ea();e&&(this.#qo&&await this.#Zo(0),await e.pause(),this.#Oo=!1,this.log("info","Playback paused."),this.emit("pause",this.#Ro))}async stop(){Mi(this.#h),this.log("info","Attempting to stop playback.");const e=this.#ea();e&&(this.#Ko&&await this.#Zo(0),await e.stop(),this.#Oo=!1,this.log("info","Playback stopped."),this.emit("stop",this.#Ro))}async next(){if(Mi(this.#h),0!==this.#jo.length){if(this.log("info","Next track requested."),await this.stop(),"TRACK"===this.#Po)return this.log("info","Loop mode: TRACK. Repeating current track."),void await this.play();if(this.#$o)this.#Ro=this._getWeightedRandomIndex(),this.log("info",`Random mode: Selected index ${this.#Ro}`);else{let e=this.#Ro+1;if(e>=this.#jo.length){if("PLAYLIST"!==this.#Po)return void this.log("info","End of playlist reached. Stopping.");e=0,this.log("info","Loop mode: PLAYLIST. Returning to start.")}this.#Ro=e}this.emit("trackChange",this.#Ro),await this.play()}}async prev(){if(Mi(this.#h),0!==this.#jo.length){if(this.#Wo&&!this.#Vo)return this.log("info",'UX: Repeat current track on first "prev" click.'),this.#Vo=!0,this.#Uo&&clearTimeout(this.#Uo),this.#Uo=setTimeout(()=>{this.#Vo=!1,this.#Uo=null},2e3),await this.stop(),void await this.play();if(this.#Uo&&(clearTimeout(this.#Uo),this.#Uo=null),this.#Vo=!1,this.log("info","Previous track requested."),await this.stop(),this.#$o)this.#Ro=this._getWeightedRandomIndex(),this.log("info",`Random mode: Selected index ${this.#Ro}`);else{let e=this.#Ro-1;if(e<0){if("PLAYLIST"!==this.#Po)return void this.log("info","Start of playlist reached. Stopping.");e=this.#jo.length-1,this.log("info","Loop mode: PLAYLIST. Returning to end.")}this.#Ro=e}this.emit("trackChange",this.#Ro),await this.play()}}async skipTo(e){if(Mi(this.#h),"number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);this.log("info",`Skipping to index: ${e}`),await this.stop(),this.#Ro=e,this.emit("trackChange",this.#Ro),await this.play()}async seek(e){if(Mi(this.#h),"number"!=typeof e)throw new TypeError("Seek time must be a number in milliseconds.");if(e<0)throw new RangeError("Seek time cannot be negative.");this.log("info",`Seeking to: ${e}ms`);const t=this.#ea();t&&(await t.seek(e),this.emit("seek",e))}async step(e){if(Mi(this.#h),"number"!=typeof e)throw new TypeError("Step amount must be a number in milliseconds.");this.log("info",`Stepping by: ${e}ms`);const t=this.#ea();if(!t)return;let r=t.getCurrentTime()+e;r<0&&(r=0),await this.seek(r)}getCurrentTime(){Mi(this.#h);try{const e=this.#ea();return e?e.getCurrentTime():0}catch{return 0}}getTotalDuration(){Mi(this.#h);try{const e=this.#ea();return e?e.getTotalDuration():0}catch{return 0}}getRemainingTime(){Mi(this.#h);try{const e=this.#ea();return e?e.getRemainingTime():0}catch{return 0}}getPlaybackPercentage(){Mi(this.#h);try{const e=this.#ea();return e?e.getPlaybackPercentage():0}catch{return 0}}get isPaused(){Mi(this.#h);try{const e=this.#ea();return!!e&&e.isPaused()}catch{return!1}}get isEnded(){Mi(this.#h);try{const e=this.#ea();return!e||e.isEnded()}catch{return!0}}async getContentData(){Mi(this.#h);const e={id:"",createdAt:"",artistId:"",artistName:"",description:"",title:"",duration:0,avatar:"",url:""};try{const t=this.#ea();return t?t.getContentData():e}catch{return e}}async waitIsReady(){Mi(this.#h);const e=this.#ea();if(e)return e.waitIsReady()}async destroy(){if(!this.#h){this.log("info","Destroying TinyMediaPlayer instance.");try{this.#Oo&&await this.stop()}catch(e){this.log("error","Non-fatal error during playback termination:",e),console.warn("[TinyMediaPlayer] Non-fatal error during playback termination:",e)}this.#Uo&&clearTimeout(this.#Uo),this.#jo=[],this.#Ro=-1,this.#Oo=!1,this.#Vo=!1,this.destroyAllAdapters(),this.removeAllListeners(),this.#ra.clear(),this.#h=!0,this.emit("destroyed")}}}const ki=Di}};const t={};function r(i){const s=t[i];if(void 0!==s)return s.exports;const n=t[i]={exports:{}};return e[i](n,n.exports,r),n.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var i=0;i<t.length;){var s=t[i++],n=t[i++];r.o(e,s)?0===n&&i++:0===n?Object.defineProperty(e,s,{enumerable:!0,value:t[i++]}):Object.defineProperty(e,s,{enumerable:!0,get:n})}else for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.cjs=e=>{const t={exports:{}};return e.call(t.exports,t,t.exports),t.exports};let i=r(256);window.TinyEssentials=i})();
1
+ (()=>{var e={975(e,t,r){"use strict";var i=r(606);function n(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function s(e,t){for(var r,i="",n=0,s=-1,o=0,a=0;a<=e.length;++a){if(a<e.length)r=e.charCodeAt(a);else{if(47===r)break;r=47}if(47===r){if(s===a-1||1===o);else if(s!==a-1&&2===o){if(i.length<2||2!==n||46!==i.charCodeAt(i.length-1)||46!==i.charCodeAt(i.length-2))if(i.length>2){var l=i.lastIndexOf("/");if(l!==i.length-1){-1===l?(i="",n=0):n=(i=i.slice(0,l)).length-1-i.lastIndexOf("/"),s=a,o=0;continue}}else if(2===i.length||1===i.length){i="",n=0,s=a,o=0;continue}t&&(i.length>0?i+="/..":i="..",n=2)}else i.length>0?i+="/"+e.slice(s+1,a):i=e.slice(s+1,a),n=a-s-1;s=a,o=0}else 46===r&&-1!==o?++o:o=-1}return i}var o={resolve:function(){for(var e,t="",r=!1,o=arguments.length-1;o>=-1&&!r;o--){var a;o>=0?a=arguments[o]:(void 0===e&&(e=i.cwd()),a=e),n(a),0!==a.length&&(t=a+"/"+t,r=47===a.charCodeAt(0))}return t=s(t,!r),r?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(e){if(n(e),0===e.length)return".";var t=47===e.charCodeAt(0),r=47===e.charCodeAt(e.length-1);return 0!==(e=s(e,!t)).length||t||(e="."),e.length>0&&r&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return n(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,t=0;t<arguments.length;++t){var r=arguments[t];n(r),r.length>0&&(void 0===e?e=r:e+="/"+r)}return void 0===e?".":o.normalize(e)},relative:function(e,t){if(n(e),n(t),e===t)return"";if((e=o.resolve(e))===(t=o.resolve(t)))return"";for(var r=1;r<e.length&&47===e.charCodeAt(r);++r);for(var i=e.length,s=i-r,a=1;a<t.length&&47===t.charCodeAt(a);++a);for(var l=t.length-a,u=s<l?s:l,h=-1,d=0;d<=u;++d){if(d===u){if(l>u){if(47===t.charCodeAt(a+d))return t.slice(a+d+1);if(0===d)return t.slice(a+d)}else s>u&&(47===e.charCodeAt(r+d)?h=d:0===d&&(h=0));break}var c=e.charCodeAt(r+d);if(c!==t.charCodeAt(a+d))break;47===c&&(h=d)}var m="";for(d=r+h+1;d<=i;++d)d!==i&&47!==e.charCodeAt(d)||(0===m.length?m+="..":m+="/..");return m.length>0?m+t.slice(a+h):(a+=h,47===t.charCodeAt(a)&&++a,t.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(n(e),0===e.length)return".";for(var t=e.charCodeAt(0),r=47===t,i=-1,s=!0,o=e.length-1;o>=1;--o)if(47===(t=e.charCodeAt(o))){if(!s){i=o;break}}else s=!1;return-1===i?r?"/":".":r&&1===i?"//":e.slice(0,i)},basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');n(e);var r,i=0,s=-1,o=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,l=-1;for(r=e.length-1;r>=0;--r){var u=e.charCodeAt(r);if(47===u){if(!o){i=r+1;break}}else-1===l&&(o=!1,l=r+1),a>=0&&(u===t.charCodeAt(a)?-1===--a&&(s=r):(a=-1,s=l))}return i===s?s=l:-1===s&&(s=e.length),e.slice(i,s)}for(r=e.length-1;r>=0;--r)if(47===e.charCodeAt(r)){if(!o){i=r+1;break}}else-1===s&&(o=!1,s=r+1);return-1===s?"":e.slice(i,s)},extname:function(e){n(e);for(var t=-1,r=0,i=-1,s=!0,o=0,a=e.length-1;a>=0;--a){var l=e.charCodeAt(a);if(47!==l)-1===i&&(s=!1,i=a+1),46===l?-1===t?t=a:1!==o&&(o=1):-1!==t&&(o=-1);else if(!s){r=a+1;break}}return-1===t||-1===i||0===o||1===o&&t===i-1&&t===r+1?"":e.slice(t,i)},format:function(e){if(null===e||"object"!=typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function(e,t){var r=t.dir||t.root,i=t.base||(t.name||"")+(t.ext||"");return r?r===t.root?r+i:r+"/"+i:i}(0,e)},parse:function(e){n(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;var r,i=e.charCodeAt(0),s=47===i;s?(t.root="/",r=1):r=0;for(var o=-1,a=0,l=-1,u=!0,h=e.length-1,d=0;h>=r;--h)if(47!==(i=e.charCodeAt(h)))-1===l&&(u=!1,l=h+1),46===i?-1===o?o=h:1!==d&&(d=1):-1!==o&&(d=-1);else if(!u){a=h+1;break}return-1===o||-1===l||0===d||1===d&&o===l-1&&o===a+1?-1!==l&&(t.base=t.name=0===a&&s?e.slice(1,l):e.slice(a,l)):(0===a&&s?(t.name=e.slice(1,o),t.base=e.slice(1,l)):(t.name=e.slice(a,o),t.base=e.slice(a,l)),t.ext=e.slice(o,l)),a>0?t.dir=e.slice(0,a-1):s&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};o.posix=o,e.exports=o},606(e){var t,r,i=e.exports={};function n(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===n||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:n}catch(e){t=n}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var a,l=[],u=!1,h=-1;function d(){u&&a&&(u=!1,a.length?l=a.concat(l):h=-1,l.length&&c())}function c(){if(!u){var e=o(d);u=!0;for(var t=l.length;t;){for(a=l,l=[];++h<t;)a&&a[h].run();h=-1,t=l.length}a=null,u=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{return r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function p(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new m(e,t)),1!==l.length||u||o(c)},m.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=p,i.addListener=p,i.once=p,i.off=p,i.removeListener=p,i.removeAllListeners=p,i.emit=p,i.prependListener=p,i.prependOnceListener=p,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},133(){},370(){},766(){},911(){},256(e,t,r){"use strict";r.r(t),r.d(t,{ColorSafeStringify:()=>Q,FuzzySet:()=>fi,MamdaniInferenceSystem:()=>yi,TinyAdvancedRaffle:()=>zr,TinyAfterScrollWatcher:()=>Qt,TinyAnalogClock:()=>oi,TinyArrayComparator:()=>hi,TinyArrayPaginator:()=>Wr,TinyClassManager:()=>wi,TinyClipboard:()=>mr,TinyColorConverter:()=>fr,TinyColorValidator:()=>ni,TinyCookieConsent:()=>Jr,TinyDayNightCycle:()=>Hr,TinyDebugger:()=>Di,TinyDomReadyManager:()=>Nt,TinyDragDropDetector:()=>ge,TinyDragger:()=>kt,TinyElementObserver:()=>pt,TinyGamepad:()=>$r,TinyHtml:()=>It,TinyI18:()=>Xr,TinyIframeEvents:()=>Dr,TinyInventory:()=>qr,TinyInventoryTrader:()=>Kr,TinyLevelUp:()=>s,TinyLoadingScreen:()=>ri,TinyLocalStorage:()=>Ar,TinyMediaPlayer:()=>ji,TinyNeedBar:()=>Zr,TinyNewWinEvents:()=>_r,TinyNotifications:()=>Lt,TinyNotifyCenter:()=>se,TinyPromiseQueue:()=>Z,TinyRadioFm:()=>Ei,TinyRateLimiter:()=>re,TinySimpleDice:()=>ti,TinySmartScroller:()=>dr,TinyTextDiffer:()=>li,TinyTextRangeEditor:()=>cr,TinyTextarea:()=>jr,TinyTimeout:()=>br,TinyToastNotify:()=>ae,UltraRandomMsgGen:()=>ar,addAiMarkerShortcut:()=>J,areElsCollBottom:()=>Ye,areElsCollLeft:()=>Xe,areElsCollPerfBottom:()=>et,areElsCollPerfLeft:()=>tt,areElsCollPerfRight:()=>rt,areElsCollPerfTop:()=>Ze,areElsCollRight:()=>Qe,areElsCollTop:()=>Ge,areElsColliding:()=>it,areElsPerfColliding:()=>nt,arraySortPositions:()=>u,asyncReplace:()=>V,backupFile:()=>je,breakdownDuration:()=>f,browserIs:()=>Ii,calculateMarketcap:()=>z,checkObj:()=>I,clearDirectory:()=>Se,clearDirectoryAsync:()=>We,cloneObjTypeOrder:()=>S,compareMarketcap:()=>W,countObj:()=>y,createCheckDestroyed:()=>ee,createSingletonTask:()=>gr,defuzzifyCentroid:()=>ci,diffArrayList:()=>l,diffObjList:()=>G,diffStrings:()=>Y,dirExists:()=>Ae,dirSize:()=>_e,dirSizeAsync:()=>Ue,documentIsFullScreen:()=>M,ensureCopyFile:()=>Ie,ensureDirectory:()=>Te,exitFullScreen:()=>L,extendObjType:()=>E,extractMediaId3Tags:()=>Gt,fetchJson:()=>me,fetchText:()=>pe,fileExists:()=>xe,fileSize:()=>Le,fileSizeAsync:()=>Je,formatBytes:()=>F,formatCustomTimer:()=>c,formatDayTimer:()=>p,formatTimer:()=>m,genFibonacciSeq:()=>B,getAge:()=>H,getBrowserCssPrefix:()=>xi,getBrowserPings:()=>Ci,getDuckTyping:()=>Ai,getElsCollDetails:()=>ct,getElsCollDirDepth:()=>dt,getElsCollOverlap:()=>at,getElsCollOverlapPos:()=>lt,getElsColliding:()=>st,getElsPerfColliding:()=>ot,getElsRelativeCenterOffset:()=>ht,getLatestBackupPath:()=>Re,getPercentage:()=>O,getRectCenter:()=>ut,getSimplePerc:()=>$,getTimeDuration:()=>d,getUserTimeFormat:()=>h,installWindowHiddenScript:()=>fe,isBrowserAgent:()=>Si,isDirEmpty:()=>Ce,isDirEmptyAsync:()=>Ve,isFullScreenMode:()=>k,isJsonObject:()=>g,isObjType:()=>A,isScreenFilled:()=>D,isValidObj:()=>w,listDirs:()=>Ne,listDirsAsync:()=>Ke,listFiles:()=>ke,listFilesAsync:()=>qe,multiplyArrayBlocks:()=>a,objType:()=>C,objTypeName:()=>x,offFullScreenChange:()=>R,onFullScreenChange:()=>j,parseMediaMetadata:()=>Yt,readBase64Blob:()=>ue,readFileBlob:()=>le,readJsonBlob:()=>he,readJsonFile:()=>ve,renameFileAddPrefixSuffix:()=>He,renameFileBatch:()=>$e,renameFileNormalizeCase:()=>Fe,renameFilePadNumbers:()=>Be,renameFileRegex:()=>Oe,reorderObjTypeOrder:()=>T,requestFullScreen:()=>N,restoreLatestBackup:()=>Pe,ruleOfThree:()=>P,safeTextTrim:()=>U,saveJsonFile:()=>de,shuffleArray:()=>o,toTitleCase:()=>q,toTitleCaseLowerFirst:()=>K,trapezoid:()=>mi,tryDeleteFile:()=>Me,valFetchMediaContent:()=>Jt,valMediaContentMetadata:()=>Ut,waitForTrue:()=>yr,writeJsonFile:()=>Ee,writeTextFile:()=>De});var i={};r.r(i),r.d(i,{iu:()=>Ye,cq:()=>Xe,P8:()=>et,BO:()=>tt,eh:()=>rt,L2:()=>Ze,lP:()=>Qe,Kr:()=>Ge,wE:()=>it,D6:()=>nt,PN:()=>ct,t_:()=>dt,aI:()=>at,ej:()=>lt,kx:()=>st,Pd:()=>ot,NW:()=>ht,Qv:()=>ut});var n={};r.r(n),r.d(n,{areElsCollBottom:()=>Ye,areElsCollLeft:()=>Xe,areElsCollPerfBottom:()=>et,areElsCollPerfLeft:()=>tt,areElsCollPerfRight:()=>rt,areElsCollPerfTop:()=>Ze,areElsCollRight:()=>Qe,areElsCollTop:()=>Ge,areElsColliding:()=>it,areElsPerfColliding:()=>nt,getElsCollDetails:()=>ct,getElsCollDirDepth:()=>dt,getElsCollOverlap:()=>at,getElsCollOverlapPos:()=>lt,getElsColliding:()=>st,getElsPerfColliding:()=>ot,getElsRelativeCenterOffset:()=>ht,getRectCenter:()=>ut});const s=class{constructor(e,t){if("number"!=typeof e||Number.isNaN(e))throw new Error("giveExp must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("expLevel must be a valid number");this.giveExp=e,this.expLevel=t}createUser(){return{exp:0,level:1,totalExp:0}}validateUser(e){if("number"!=typeof e.exp||Number.isNaN(e.exp))throw new Error("exp must be a valid number");if("number"!=typeof e.level||Number.isNaN(e.level))throw new Error("level must be a valid number");if(e.level<1)throw new Error("level must be at least 1");if("number"!=typeof e.totalExp||Number.isNaN(e.totalExp))throw new Error("totalExp must be a valid number")}isValidUser(e){return!("number"!=typeof e.exp||Number.isNaN(e.exp)||"number"!=typeof e.level||Number.isNaN(e.level)||e.level<1||"number"!=typeof e.totalExp||Number.isNaN(e.totalExp))}getGiveExpBase(){if("number"!=typeof this.giveExp||Number.isNaN(this.giveExp))throw new Error("giveExp must be a valid number");return this.giveExp}getExpLevelBase(){if("number"!=typeof this.expLevel||Number.isNaN(this.expLevel))throw new Error("expLevel must be a valid number");return this.expLevel}expValidator(e){const t=this.getExpLevelBase();this.validateUser(e);let r=0;const i=t*e.level;return e.exp>=i&&(e.level++,r=e.exp-i,e.exp=0,r>0)?this.give(e,r,"extra"):e.exp<1&&e.level>1&&(e.level--,r=Math.abs(e.exp),e.exp=t*e.level,r>0)?this.remove(e,r,"extra"):e}getTotalExp(e){this.validateUser(e);let t=0;for(let r=1;r<=e.level;r++)t+=this.getExpLevelBase()*r;return t+=e.exp,t}expGenerator(e=1){if("number"!=typeof e||Number.isNaN(e))throw new Error("multi must be a valid number");return Math.floor(Math.random()*this.getGiveExpBase())*e}getMissingExp(e){return this.getProgress(e)-e.exp}progress(e){return this.getProgress(e)}getProgress(e){return this.validateUser(e),this.getExpLevelBase()*e.level}set(e,t){if("number"!=typeof t||Number.isNaN(t))throw new Error("value must be a valid number");return e.exp=t,this.expValidator(e),e.totalExp=this.getTotalExp(e),e}give(e,t=0,r="add",i=1){if("number"!=typeof i||Number.isNaN(i))throw new Error("multi must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("extraExp must be a valid number");if("string"!=typeof r)throw new Error("type must be a valid string");return"add"===r?e.exp+=this.expGenerator(i)+t:"extra"===r&&(e.exp+=t),this.expValidator(e),e.totalExp=this.getTotalExp(e),e}remove(e,t=0,r="add",i=1){if("number"!=typeof i||Number.isNaN(i))throw new Error("multi must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("extraExp must be a valid number");if("string"!=typeof r)throw new Error("type must be a valid string");return"add"===r?e.exp-=this.expGenerator(i)+t:"extra"===r&&(e.exp-=t),this.expValidator(e),e.totalExp=this.getTotalExp(e),e}};function o(e){if(!Array.isArray(e))throw new TypeError("Argument 'items' must be an array.");let t,r=e.length;for(;0!==r;)t=Math.floor(Math.random()*r),r--,[e[r],e[t]]=[e[t],e[r]];return e}function a(e,t){if(!Array.isArray(e))throw new TypeError("Argument 'phases' must be an array.");if(!Array.isArray(t))throw new TypeError("Argument 'counts' must be an array.");if(e.length!==t.length)throw new RangeError("The 'phases' and 'counts' arrays must have the same length.");const r=[];for(let i=0;i<e.length;i++){if("number"!=typeof t[i]||Number.isNaN(t[i]))throw new TypeError(`Element at counts[${i}] must be a valid number.`);for(let n=0;n<t[i];n++)r.push(e[i])}return r}function l(e,t){if(!Array.isArray(e))throw new TypeError("Argument 'oldItems' must be an array.");if(!Array.isArray(t))throw new TypeError("Argument 'newItems' must be an array.");const r=e.filter(e=>!t.includes(e));return{added:t.filter(t=>!e.includes(t)),removed:r}}function u(e,t=!1){if(null!=e&&"string"!=typeof e)throw new TypeError("Argument 'item' must be a string or null.");if("boolean"!=typeof t)throw new TypeError("Argument 'isReverse' must be a boolean.");return t?function(t,r){return(e?t[e]:t)>(e?r[e]:r)?-1:(e?t[e]:t)<(e?r[e]:r)?1:0}:function(t,r){return(e?t[e]:t)<(e?r[e]:r)?-1:(e?t[e]:t)>(e?r[e]:r)?1:0}}function h(){const e=new Intl.DateTimeFormat(void 0,{hour:"numeric"}).resolvedOptions().hourCycle;return e?.startsWith("h12")?12:24}function d(e=new Date,t="asSeconds",r=null){if(!(e instanceof Date))throw new TypeError("The 'timeData' argument must be an instance of Date.");if("string"!=typeof t)throw new TypeError("The 'durationType' argument must be a string.");const i=["asMilliseconds","asSeconds","asMinutes","asHours","asDays"];if(!i.includes(t))throw new RangeError(`The 'durationType' must be one of: ${i.join(", ")}.`);if(null!==r&&!(r instanceof Date))throw new TypeError("The 'now' argument must be an instance of Date or null.");const n=r instanceof Date?r:new Date,s=e.getTime()-n.getTime();switch(t){case"asMilliseconds":return s;case"asSeconds":default:return s/1e3;case"asMinutes":return s/6e4;case"asHours":return s/36e5;case"asDays":return s/864e5}}function c(e,t="seconds",r="{time}"){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'totalSeconds' argument must be a valid number.");if("string"!=typeof t)throw new TypeError("The 'level' argument must be a string.");const i=["seconds","minutes","hours","days","months","years"];if(!i.includes(t))throw new RangeError(`The 'level' must be one of: ${i.join(", ")}.`);if("string"!=typeof r)throw new TypeError("The 'format' argument must be a string.");e=Math.max(0,Math.floor(e));const n=i.indexOf(t),s=n>=5,o=n>=4,a=n>=3,l=n>=2,u=n>=1,h=n>=0,d={years:s?0:NaN,months:o?0:NaN,days:a?0:NaN,hours:l?0:NaN,minutes:u?0:NaN,seconds:h?0:NaN,total:NaN};let c=e;if(s||o||a){const e=new Date(1980,0,1),t=new Date(e.getTime()+1e3*c),r=new Date(e);if(s)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),d.years++;if(o)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),d.months++;if(a)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),d.days++;c=Math.floor((t.getTime()-r.getTime())/1e3)}l&&(d.hours=Math.floor(c/3600),c%=3600),u&&(d.minutes=Math.floor(c/60),c%=60),h&&(d.seconds=c),d.total=+e.toFixed(2).replace(/\.00$/,"");const m=e=>{const t="string"==typeof e?parseInt(e):e;return Number.isNaN(t)?"NaN":String(t).padStart(2,"0")},p=[l?m(d.hours):null,u?m(d.minutes):null,h?m(d.seconds):null].filter(e=>null!==e).join(":");return r.replace(/\{years\}/g,String(d.years)).replace(/\{months\}/g,String(d.months)).replace(/\{days\}/g,String(d.days)).replace(/\{hours\}/g,m(d.hours)).replace(/\{minutes\}/g,m(d.minutes)).replace(/\{seconds\}/g,m(d.seconds)).replace(/\{time\}/g,p).replace(/\{total\}/g,String(d.total)).trim()}function m(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'seconds' argument must be a valid number.");return c(e,"hours","{hours}:{minutes}:{seconds}")}function p(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'seconds' argument must be a valid number.");return c(e,"days","{days}d {hours}:{minutes}:{seconds}")}function f(e,t="milliseconds"){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'totalMs' argument must be a valid number.");if("string"!=typeof t)throw new TypeError("The 'level' argument must be a string.");const r=["milliseconds","seconds","minutes","hours","days","months","years"];if(!r.includes(t))throw new RangeError(`The 'level' must be one of: ${r.join(", ")}.`);e=Math.max(0,Math.floor(e));const i=r.indexOf(t),n=i>=6,s=i>=5,o=i>=4,a=i>=3,l=i>=2,u=i>=1,h=i>=0,d={years:n?0:NaN,months:s?0:NaN,days:o?0:NaN,hours:a?0:NaN,minutes:l?0:NaN,seconds:u?0:NaN,milliseconds:h?0:NaN,total:NaN};let c=e;if(n||s||o){const e=new Date(1980,0,1),t=new Date(e.getTime()+c),r=new Date(e);if(n)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),d.years++;if(s)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),d.months++;if(o)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),d.days++;c=t.getTime()-r.getTime()}return a&&(d.hours=Math.floor(c/36e5),c%=36e5),l&&(d.minutes=Math.floor(c/6e4),c%=6e4),u&&(d.seconds=Math.floor(c/1e3),c%=1e3),h&&(d.milliseconds=c),d.total=+e,d}function y(e){if(!Array.isArray(e)&&!g(e))throw new TypeError("Argument must be either an Array or a pure JSON Object.");return Array.isArray(e)?e.length:Object.keys(e).length}function g(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}function w(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}const b="undefined"!=typeof window&&void 0!==window.document,v={items:{},order:[]};function E(e,t){if("object"!=typeof e||null===e)throw new TypeError("Argument 'newItems' must be an object or an array.");if(void 0!==t&&"number"!=typeof t)throw new TypeError("Argument 'index' must be a number.");const r=[],i=Array.isArray(e)?e:Object.entries(e);for(const e of i){if(!Array.isArray(e)||e.length<2)throw new TypeError("Each item in 'newItems' array must be a [key, function] pair.");const[i,n]=e;if("string"!=typeof i)throw new TypeError("Validator key must be a string.");if("function"!=typeof n)throw new TypeError(`Validator for key '${i}' must be a function.`);if(!v.items.hasOwnProperty(i)){v.items[i]=n;let e="number"==typeof t?t:-1;if(-1===e){const t=v.order.indexOf("object");e=t>-1?t:v.order.length}e=Math.min(Math.max(0,e),v.order.length),v.order.splice(e,0,i),r.push(i)}}return r}function T(e){if(!Array.isArray(e))throw new TypeError("Argument 'newOrder' must be an array of strings.");if(!e.every(e=>"string"==typeof e))throw new TypeError("All elements in 'newOrder' must be strings.");const t=[...v.order];return!!e.every(e=>t.includes(e))&&(v.order=e.slice(),!0)}function S(){return[...v.order]}const x=e=>{if(null===e)return"null";for(const t of v.order)if("function"!=typeof v.items[t]||v.items[t](e))return t;return"unknown"};function A(e,t){if("string"!=typeof t)throw new TypeError("Argument 'type' must be a string.");return x(e)===t.toLowerCase()}function C(e,t){if(void 0===e)return null;if(void 0!==t&&"string"!=typeof t)throw new TypeError("Argument 'type' must be a string.");const r=x(e);return"string"==typeof t?r===t.toLowerCase():r}function I(e){const t={valid:null,type:null};for(const r of v.order)if("function"==typeof v.items[r]){const i=v.items[r](e);if(i){t.valid=i,t.type=r;break}}return t}E([["undefined",e=>void 0===e],["null",e=>null===e],["boolean",e=>"boolean"==typeof e],["number",e=>"number"==typeof e&&!Number.isNaN(e)],["bigint",e=>"bigint"==typeof e],["string",e=>"string"==typeof e],["symbol",e=>"symbol"==typeof e],["function",e=>"function"==typeof e],["array",e=>Array.isArray(e)]]),b&&E([["file",e=>"undefined"!=typeof File&&e instanceof File]]),E([["date",e=>e instanceof Date],["regexp",e=>e instanceof RegExp],["map",e=>e instanceof Map],["set",e=>e instanceof Set],["weakmap",e=>e instanceof WeakMap],["weakset",e=>e instanceof WeakSet],["promise",e=>e instanceof Promise]]),b&&E([["htmlelement",e=>"undefined"!=typeof HTMLElement&&e instanceof HTMLElement]]),E([["object",e=>g(e)]]);const M=()=>!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitIsFullScreen||document.mozFullScreen),D=()=>window.innerHeight===screen.height&&window.innerWidth===screen.width,k=()=>M()||D(),N=e=>new Promise(async(t,r)=>{const i=document.documentElement;try{i.requestFullscreen?await i.requestFullscreen(e):i.mozRequestFullScreen?i.mozRequestFullScreen(e):i.webkitRequestFullScreen?i.webkitRequestFullScreen(e):i.msRequestFullscreen&&i.msRequestFullscreen(e),t()}catch(e){r(e)}}),L=()=>new Promise((e,t)=>{if(document.exitFullscreen)document.exitFullscreen().then(e).catch(t);else try{if(document.mozCancelFullScreen)document.mozCancelFullScreen();else if(document.webkitCancelFullScreen)document.webkitCancelFullScreen();else{if(!document.msExitFullscreen)throw new Error("Fullscreen API is not supported");document.msExitFullscreen()}e()}catch(e){t(e)}}),_=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],j=(e,t)=>{_.forEach(r=>{document.addEventListener(r,e,t)})},R=(e,t)=>{_.forEach(r=>{document.removeEventListener(r,e,t)})};function P(e,t,r,i=!1){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("val1 must be a finite number.");if("number"!=typeof t||!Number.isFinite(t))throw new TypeError("val2 must be a finite number.");if("number"!=typeof r||!Number.isFinite(r))throw new TypeError("val3 must be a finite number.");if("boolean"!=typeof i)throw new TypeError("inverse must be a boolean.");return i?Number(e*t)/r:Number(r*t)/e}function $(e,t){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("price must be a finite number.");if("number"!=typeof t||!Number.isFinite(t))throw new TypeError("percentage must be a finite number.");return e*(t/100)}function O(e,t){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("part must be a finite number.");if("number"!=typeof t||!Number.isFinite(t))throw new TypeError("total must be a finite number.");return 0===t?0:e/t*100}function H(e=0,t=null){if("number"!=typeof e&&"string"!=typeof e&&!(e instanceof Date))throw new TypeError("timeData must be a number, string, or Date object.");if(null!==t&&!(t instanceof Date))throw new TypeError("now must be a Date object or null.");const r=new Date(e);if(Number.isNaN(r.getTime()))return null;const i=t instanceof Date?t:new Date;let n=i.getFullYear()-r.getFullYear();const s=i.getMonth(),o=r.getMonth(),a=i.getDate(),l=r.getDate();return(s<o||s===o&&a<l)&&n--,Math.abs(n)}function F(e,t=null,r=null){if("number"!=typeof e||!Number.isFinite(e)||e<0)throw new TypeError("bytes must be a positive number.");if(0===e)return{unit:"Bytes",value:0};if(null!==t&&("number"!=typeof t||!Number.isFinite(t)))throw new TypeError("decimals must be a number or null.");const i=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];if(null!==r){if("string"!=typeof r)throw new TypeError("maxUnit must be a string or null.");if(!i.includes(r))throw new RangeError(`maxUnit must be one of: ${i.join(", ")}`)}const n=r&&i.includes(r)?i.indexOf(r):i.length-1,s=Math.min(Math.floor(Math.log(e)/Math.log(1024)),n);let o=e/Math.pow(1024,s);if(null!==t){const e=t<0?0:t;o=parseFloat(o.toFixed(e))}return{unit:i[s],value:o}}function B({baseValues:e=[0,1],length:t=10,combiner:r=(e,t)=>e+t}={}){if(!Array.isArray(e)||2!==e.length||!e.every(e=>"number"==typeof e))throw new Error("baseValues must be an array of exactly two numbers.");if("number"!=typeof t||!Number.isInteger(t))throw new RangeError("length must be an integer.");if("function"!=typeof r)throw new TypeError("combiner must be a function.");const i=[...e.slice(0,2)];for(let e=2;e<t;e++){const t=r(i[e-2],i[e-1],e);i.push(t)}return i}function z(e,t){if("number"!=typeof e||Number.isNaN(e)||!Number.isFinite(e))throw new TypeError("Original market cap must be a finite number.");if("number"!=typeof t||Number.isNaN(t)||!Number.isFinite(t))throw new TypeError("Circulating supply must be a finite number.");if(t<=0)throw new RangeError("Circulating supply must be greater than zero.");return e/t}function W(e,t,r){if("number"!=typeof r||Number.isNaN(r)||!Number.isFinite(r))throw new TypeError("New market cap must be a finite number.");const i=z(e,t),n="number"==typeof r?r/t:NaN;return{originalPrice:i,newPrice:n,priceChangePercent:"number"==typeof r?(n-i)/i*100:NaN}}async function V(e,t,r){if("string"!=typeof e)throw new TypeError("Expected a string for 'str', but received "+typeof e);if(!(t instanceof RegExp))throw new TypeError("Expected a RegExp for 'regex', but received "+typeof t);if("function"!=typeof r)throw new TypeError("Expected a function for 'asyncFn', but received "+typeof r);const i=[];e.replace(t,(e,...t)=>(i.push(r(e,...t)),e));const n=await Promise.all(i);return e.replace(t,()=>n.shift())}function q(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str', but received "+typeof e);return e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase())}function K(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str', but received "+typeof e);const t=e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase());return t.charAt(0).toLowerCase()+t.slice(1)}function J({key:e="a",className:t="detect-made-by-ai"}={}){if("undefined"==typeof HTMLElement)throw new Error("[AiMarkerShortcut] Environment does not support the DOM. This function must be run in a browser.");if("string"!=typeof e)throw new TypeError("Expected a string for 'config.key', but received "+typeof e);if("string"!=typeof t)throw new TypeError("Expected a string for 'config.className', but received "+typeof t);const r=function(r){if(r.ctrlKey&&r.altKey&&r.key.toLowerCase()===e){if(r.preventDefault(),!document.body)return void console.warn("[AiMarkerShortcut] <body> element not found. Cannot toggle class. Ensure the DOM is fully loaded when using the shortcut.");document.body.classList.toggle(t)}};return document.addEventListener("keydown",r),r}function U(e,t,r=.6){if("string"!=typeof e)throw new TypeError("Expected a string for 'text', but received "+typeof e);if(!Number.isInteger(t)||t<=0)throw new TypeError(`Expected 'limit' to be a positive integer, but received ${t}`);if("number"!=typeof r||r<0||r>1)throw new TypeError(`Expected 'safeCutZone' to be a number between 0 and 1, but received ${r}`);let i=e.trim();if(i.length>t){const e=i.lastIndexOf(" ",t);return e>0&&e>=t*r?`${i.substring(0,e).trim()}...`:`${i.substring(0,t).trim()}...`}return i}function G(e,t){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("Expected an object for 'oldStrings', but received "+(null===e?"null":typeof e));if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("Expected an object for 'newStrings', but received "+(null===t?"null":typeof t));const r={added:{},removed:{},modified:{}};for(const i in e)i in t?e[i]!==t[i]&&(r.modified[i]={old:e[i],new:t[i]}):r.removed[i]=e[i];for(const i in t)i in e||(r.added[i]=t[i]);return r}const Y=G;class X{#e;static#t={default:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""},solarized:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""},monokai:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""}};constructor(e={}){this.#e={...X.#t.default,...e}}#r(e,t){const r=[];e=(e=(e=e.replace(/(?<!")\b(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b(?!")/g,`${t.number}$1${t.reset}`)).replace(/"([^"]+)":/g,(e,t)=>{const i=`___KEY${r.length}___`;return r.push({marker:i,key:t}),`${i}:`})).replace(/"(?:\\.|[^"\\])*?"/g,e=>{const r=e.slice(1,-1);return/^(https?|ftp):\/\/[^\s]+$/i.test(r)?`${t.string_url}${e}${t.reset}`:/^(true|false|null)$/.test(r)?`${t.string_bool}${e}${t.reset}`:/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(r)?`${t.string_number}${e}${t.reset}`:`${t.string}${e}${t.reset}`});for(const{marker:i,key:n}of r){const r=new RegExp(i,"g");e=e.replace(r,`${t.key}"${n}"${t.reset}`)}return(e=(e=(e=(e=e.replace(/(?<!")\b(true|false)\b(?!")/g,`${t.boolean}$1${t.reset}`)).replace(/(?<!")\bnull\b(?!")/g,`${t.null}null${t.reset}`)).replace(/\[Circular\]/g,`${t.special}[Circular]${t.reset}`)).replace(/\[undefined\]/g,`${t.special}[undefined]${t.reset}`)).replace(/"function.*?[^\\]"/gs,`${t.func}$&${t.reset}`)}colorize(e,t={}){const r={...this.#e,...t};return this.#r(e,r)}getColors(){return{...this.#e}}updateColors(e){Object.assign(this.#e,e)}resetColors(){this.#e={...X.#t.default}}loadColorPreset(e){const t=X.#t[e];if(!t)throw new Error(`Preset "${e}" not found.`);this.#e={...t}}saveColorPreset(e,t){X.#t[e]={...t}}getAvailablePresets(){return Object.keys(X.#t)}}const Q=X,Z=class{#i=[];#n=!1;#s={};#o=new Set;isRunning(){return this.#n}async#a(e){if(e&&"function"==typeof e.task&&"function"==typeof e.resolve&&"function"==typeof e.reject){const{task:t,resolve:r,reject:i,delay:n,id:s}=e;try{if(s&&this.#o.has(s))return i(new Error("The function was canceled on TinyPromiseQueue.")),this.#o.delete(s),this.#n=!1,void this.#l();n&&s&&await new Promise(e=>{const t=setTimeout(()=>{delete this.#s[s],e(null)},n);this.#s[s]=t}),r(await t())}catch(e){i(e)}finally{this.#n=!1,this.#l()}}}async#u(){const e=[];for(;this.#i.length&&"POINT_MARKER"===this.#i[0]?.marker;)e.push(this.#i.shift());if(0===e.length)return this.#n=!1,void this.#l();await Promise.all(e.map(({task:e,resolve:t,reject:r,id:i})=>new Promise(async n=>{if(i&&this.#o.has(i))return this.#o.delete(i),r(new Error("The function was canceled on TinyPromiseQueue.")),void n(!0);await e().then(t).catch(r),n(!0)}))),this.#n=!1,this.#l()}async#l(){if(!this.#n&&0!==this.#i.length)if(this.#n=!0,"string"!=typeof this.#i[0]?.marker||"POINT_MARKER"!==this.#i[0]?.marker){const e=this.#i.shift();this.#a(e)}else this.#u()}getIndexById(e){return this.#i.findIndex(t=>t.id===e)}getQueuedIds(){return this.#i.map((e,t)=>({index:t,id:e.id})).filter(e=>"string"==typeof e.id)}reorderQueue(e,t){if("number"!=typeof e||"number"!=typeof t||e<0||t<0||e>=this.#i.length||t>=this.#i.length)return;const[r]=this.#i.splice(e,1);this.#i.splice(t,0,r)}async enqueuePoint(e,t){if("function"!=typeof e)return Promise.reject(new Error("Task must be a function returning a Promise."));if(void 0!==t&&"string"!=typeof t)throw new Error('The "id" parameter must be a string.');return this.#n?new Promise((r,i)=>{this.#i.push({marker:"POINT_MARKER",task:e,resolve:r,reject:i,id:t}),this.#l()}):e()}enqueue(e,t,r){if("function"!=typeof e)return Promise.reject(new Error("Task must be a function returning a Promise."));if(void 0!==t&&("number"!=typeof t||t<0))return Promise.reject(new Error("Delay must be a positive number or undefined."));if(void 0!==r&&"string"!=typeof r)throw new Error('The "id" parameter must be a string.');return new Promise((i,n)=>{this.#i.push({task:e,resolve:i,reject:n,id:r,delay:t}),this.#l()})}cancelTask(e){if("string"!=typeof e)throw new Error('The "id" parameter must be a string.');let t=!1;e in this.#s&&(clearTimeout(this.#s[e]),delete this.#s[e],t=!0);const r=this.getIndexById(e);if(-1!==r){const[e]=this.#i.splice(r,1);e?.reject?.(new Error("The function was canceled on TinyPromiseQueue.")),t=!0}return t&&this.#o.add(e),t}},ee=e=>t=>{if(t)throw new Error(`This ${e} instance has been destroyed and can no longer be used.`)},te=ee("TinyRateLimiter"),re=class{#h=!1;get destroyed(){return this.#h}#d=null;#c=null;#m=null;#p=null;#f=null;#y=null;groupData=new Map;lastSeen=new Map;userToGroup=new Map;groupFlags=new Map;groupTTL=new Map;#g=null;setOnMemoryExceeded(e){if(te(this.#h),"function"!=typeof e)throw new Error("onMemoryExceeded must be a function");this.#g=e}clearOnMemoryExceeded(){te(this.#h),this.#g=null}#w=null;setOnGroupExpired(e){if(te(this.#h),"function"!=typeof e)throw new Error("onGroupExpired must be a function");this.#w=e}clearOnGroupExpired(){te(this.#h),this.#w=null}constructor({maxHits:e,interval:t,cleanupInterval:r,maxIdle:i=3e5,maxMemory:n=1e5}){const s=e=>"number"==typeof e&&Number.isFinite(e)&&e>=1&&Number.isInteger(e),o=s(e),a=s(t),l=s(r),u=s(i);if(!o&&!a)throw new Error("RateLimiter requires at least one valid option: 'maxHits' or 'interval'.");if(void 0!==e&&!o)throw new Error("'maxHits' must be a positive integer if defined.");if(void 0!==t&&!a)throw new Error("'interval' must be a positive integer in milliseconds if defined.");if(void 0!==r&&!l)throw new Error("'cleanupInterval' must be a positive integer in milliseconds if defined.");if(!u)throw new Error("'maxIdle' must be a positive integer in milliseconds.");if("number"==typeof n&&Number.isFinite(n)&&n>0)this.#d=Math.floor(n);else{if(null!=n)throw new Error("maxMemory must be a positive number or null");this.#d=null}this.#m=o?e:null,this.#p=a?t:null,this.#f=l?r:null,this.#y=i,null!==this.#f&&(this.#c=setInterval(()=>this._cleanup(),this.#f))}isGroupId(e){te(this.#h);const t=this.groupFlags.get(e);return"boolean"==typeof t&&t}getUsersInGroup(e){te(this.#h);const t=[];for(const[r,i]of this.userToGroup.entries())i===e&&t.push(r);return t}setGroupTTL(e,t){if(te(this.#h),"number"!=typeof t||!Number.isFinite(t)||t<=0)throw new Error("TTL must be a positive number in milliseconds");this.groupTTL.set(e,t)}getGroupTTL(e){return te(this.#h),this.groupTTL.get(e)??null}deleteGroupTTL(e){te(this.#h),this.groupTTL.delete(e)}assignToGroup(e,t){te(this.#h);const r=this.userToGroup.get(e);if(r&&r!==t)throw new Error(`User ${e} is already assigned to group ${r}`);if(r===t)return;const i=this.groupData.get(e);if(this.isGroupId(e)){for(const[r,i]of this.userToGroup.entries())i===e&&this.userToGroup.set(r,t);this.userToGroup.delete(e)}else this.userToGroup.set(e,t);if(!i)return;const n=this.groupData.get(t);if(n)for(const e of i)n.push(e);else{const e=[];for(const t of i)e.push(t);this.groupData.set(t,e)}this.lastSeen.set(t,Date.now()),this.groupFlags.delete(e),this.groupData.delete(e),this.lastSeen.delete(e),this.groupTTL.delete(e),this.groupFlags.set(t,!0)}getGroupId(e){return te(this.#h),this.userToGroup.get(e)||e}hit(e){te(this.#h);const t=this.getGroupId(e),r=Date.now();this.groupData.has(t)||(this.groupData.set(t,[]),this.groupFlags.set(t,!1));const i=this.groupData.get(t);if(!i)throw new Error(`No data found for groupId: ${t}`);if(i.push(r),this.lastSeen.set(t,r),null!==this.#p){const e=r-this.getInterval();for(;i.length&&i[0]<e;)i.shift()}null!==this.#d&&"number"==typeof this.#d&&i.length>this.#d&&(i.splice(0,i.length-this.#d),"function"==typeof this.#g&&this.#g(t))}isRateLimited(e){te(this.#h);const t=this.getGroupId(e);if(!this.groupData.has(t))return!1;const r=this.groupData.get(t);if(!r)throw new Error(`No data found for groupId: ${t}`);if(null!==this.#p){const e=Date.now()-this.getInterval();let t=0;for(let i=r.length-1;i>=0&&r[i]>e;i--)t++;return null!==this.#m?t>this.getMaxHits():t>0}return null!==this.#m&&r.length>this.getMaxHits()}resetGroup(e){te(this.#h),this.groupFlags.delete(e),this.groupData.delete(e),this.lastSeen.delete(e),this.groupTTL.delete(e)}resetUserGroup(e){te(this.#h),this.userToGroup.delete(e)}setData(e,t){if(te(this.#h),!Array.isArray(t))throw new Error("timestamps must be an array of numbers.");for(const e of t)if("number"!=typeof e||!Number.isFinite(e))throw new Error("All timestamps must be finite numbers.");this.groupData.has(e)||this.groupFlags.set(e,!1),this.groupData.set(e,t),this.lastSeen.set(e,Date.now())}hasData(e){return te(this.#h),this.groupData.has(e)}getData(e){return te(this.#h),this.groupData.get(e)||[]}getMaxIdle(){if(te(this.#h),"number"!=typeof this.#y||!Number.isFinite(this.#y)||this.#y<0)throw new Error("'maxIdle' must be a non-negative finite number.");return this.#y}setMaxIdle(e){if(te(this.#h),"number"!=typeof e||!Number.isFinite(e)||e<0)throw new Error("'maxIdle' must be a non-negative finite number.");this.#y=e}_cleanup(){const e=Date.now();for(const[t,r]of this.lastSeen.entries())e-r>(this.getGroupTTL(t)??this.getMaxIdle())&&(this.groupFlags.delete(t),this.groupData.delete(t),this.lastSeen.delete(t),this.groupTTL.delete(t),"function"==typeof this.#w&&this.#w(t))}getActiveGroups(){return te(this.#h),Array.from(this.groupData.keys())}getAllUserMappings(){return te(this.#h),Object.fromEntries(this.userToGroup)}getInterval(){if(te(this.#h),"number"!=typeof this.#p||!Number.isFinite(this.#p))throw new Error("'interval' is not a valid finite number.");return this.#p}getMaxHits(){if(te(this.#h),"number"!=typeof this.#m||!Number.isFinite(this.#m))throw new Error("'maxHits' is not a valid finite number.");return this.#m}getTotalHits(e){te(this.#h);const t=this.groupData.get(e);return Array.isArray(t)?t.length:0}getLastHit(e){te(this.#h);const t=this.groupData.get(e);return t?.length?t[t.length-1]:null}getTimeSinceLastHit(e){te(this.#h);const t=this.getLastHit(e);return null!==t?Date.now()-t:null}_calculateAverageSpacing(e){if(!Array.isArray(e)||e.length<2)return null;let t=0;for(let r=1;r<e.length;r++)t+=e[r]-e[r-1];return t/(e.length-1)}getAverageHitSpacing(e){return te(this.#h),this._calculateAverageSpacing(this.groupData.get(e))}getMetrics(e){te(this.#h);const t=this.groupData.get(e);if(!Array.isArray(t)||0===t.length)return{totalHits:0,lastHit:null,timeSinceLastHit:null,averageHitSpacing:null};const r=t.length,i=t[r-1];return{totalHits:r,lastHit:i,timeSinceLastHit:Date.now()-i,averageHitSpacing:this._calculateAverageSpacing(t)}}destroy(){this.destroyed||(this.#c&&clearInterval(this.#c),this._cleanup(),this.groupData.clear(),this.lastSeen.clear(),this.userToGroup.clear(),this.groupTTL.clear(),this.groupFlags.clear(),this.#h=!0)}},ie=ee("TinyNotifyCenter");class ne{static getTemplate(){return'\n<div class="notify-overlay hidden">\n <div class="notify-center" id="notifCenter">\n <div class="header">\n <div>Notifications</div>\n <div class="options">\n <button class="clear-all" type="button">\n <svg\n xmlns="http://www.w3.org/2000/svg"\n viewBox="0 0 24 24"\n width="24"\n height="24"\n fill="currentColor"\n >\n <path\n d="M21.6 2.4a1 1 0 0 0-1.4 0L13 9.6l-1.3-1.3a1 1 0 0 0-1.4 0L3 15.6a1 1 0 0 0 0 1.4l4 4a1 1 0 0 0 1.4 0l7.3-7.3a1 1 0 0 0 0-1.4l-1.3-1.3 7.2-7.2a1 1 0 0 0 0-1.4zM6 17l3.5-3.5 1.5 1.5L7.5 18.5 6 17z"\n />\n </svg>\n </button>\n <button class="close">×</button>\n </div>\n </div>\n <div class="list"></div>\n </div>\n</div>\n\n<button class="notify-bell" aria-label="Open notifications">\n <svg\n xmlns="http://www.w3.org/2000/svg"\n width="20"\n height="20"\n fill="currentColor"\n viewBox="0 0 24 24"\n >\n <path\n d="M12 2C10.3 2 9 3.3 9 5v1.1C6.7 7.2 5 9.4 5 12v5l-1 1v1h16v-1l-1-1v-5c0-2.6-1.7-4.8-4-5.9V5c0-1.7-1.3-3-3-3zm0 20c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2z"\n />\n </svg>\n <span class="badge" id="notifBadge">0</span>\n</button>\n '}static insertTemplate(e="afterbegin"){document.body.insertAdjacentHTML(e,ne.getTemplate())}#h=!1;get destroyed(){return this.#h}#b;#v;#E;#T;#S;#x=0;#A=99;#C=300;#I=!1;#M=new WeakMap;#D(e){if(this.#M.delete(e),!(e instanceof HTMLElement))throw new Error("Invalid HTMLElement to clear.");e.classList.add("removing"),setTimeout(()=>{this.markAsRead(e),e.remove()},this.#C)}#k(e){this.#x=Math.max(0,e),this.#E.setAttribute("data-value",String(this.#x)),this.#E.textContent=this.#x>this.#A?`${this.#A}+`:String(this.#x)}constructor(e={}){const{center:t=document.getElementById("notifCenter"),badge:r=document.getElementById("notifBadge"),button:i=document.querySelector(".notify-bell"),overlay:n=document.querySelector(".notify-overlay")}=e;if(!(t instanceof HTMLElement))throw new Error(`NotificationCenter: "center" must be an HTMLElement. Got: ${t}`);if(!(n instanceof HTMLElement))throw new Error(`NotificationCenter: "overlay" must be an HTMLElement. Got: ${n}`);if(!(r instanceof HTMLElement))throw new Error(`NotificationCenter: "badge" must be an HTMLElement. Got: ${r}`);if(!(i instanceof HTMLElement))throw new Error(`NotificationCenter: "button" must be an HTMLElement. Got: ${i}`);const s=t?.querySelector(".clear-all"),o=t?.querySelector(".list")??null;if(!(o instanceof HTMLElement))throw new Error(`NotificationCenter: ".list" inside center must be an HTMLElement. Got: ${o}`);this.#b=t,this.#v=o,this.#E=r,this.#T=i,this.#S=n,this.#T.addEventListener("click",()=>this.toggle()),this.#b.querySelector(".close")?.addEventListener("click",()=>this.close()),s&&s.addEventListener("click",()=>this.clear()),this.#S.addEventListener("click",e=>{e.target===this.#S&&this.close()})}setMarkAllAsReadOnClose(e){if(ie(this.#h),"boolean"!=typeof e)throw new TypeError("Expected boolean for markAllAsReadOnClose, got "+typeof e);this.#I=e}setRemoveDelay(e){if(ie(this.#h),"number"!=typeof e)throw new Error('NotificationCenter: "ms" must be an number.');this.#C=e}getItemMode(e){ie(this.#h);const t=this.getItem(e);return t?this.#M.get(t):null}getItem(e){ie(this.#h);const t=this.#v.children.item(e);if(!(t instanceof HTMLElement))throw new Error(`NotificationCenter: "item" must be an HTMLElement. Got: ${t}`);return t}hasItem(e){return ie(this.#h),e>=0&&e<this.#v.children.length}markAsRead(e){ie(this.#h);const t=e instanceof HTMLElement?e:this.getItem(e);t.classList.contains("unread")&&(t.classList.remove("unread"),this.#k(this.#x-1))}add(e,t="text"){ie(this.#h);const r=document.createElement("div");r.className="item unread";let i=null,n=null,s=null,o=null;if("object"==typeof e&&null!==e?(i=e.title,n=e.message,s=e.avatar,o=e.onClick):n=e,s){const e=document.createElement("div");e.className="avatar",e.style.backgroundImage=`url("${s}")`,r.appendChild(e)}const a=document.createElement("div");if(a.className="content",i){const e=document.createElement("div");e.className="title",e.textContent=i,a.appendChild(e)}const l=document.createElement("div");l.className="message","html"===t?l.innerHTML=n:l.textContent=n,a.appendChild(l),"function"==typeof o&&(r.classList.add("clickable"),r.addEventListener("click",e=>{e.target instanceof HTMLElement&&!e.target.closest(".notify-close")&&o(e)}));const u=document.createElement("button");u.className="notify-close",u.setAttribute("type","button"),u.innerHTML="&times;",u.addEventListener("click",e=>{e.stopPropagation(),this.#D(r)}),r.append(a,u),this.#v.prepend(r),this.#M.set(r,t),this.#k(this.#x+1)}remove(e){ie(this.#h);const t=this.getItem(e);this.#D(t)}clear(){ie(this.#h);let e=!0;for(;e;){e=!1;const t=Array.from(this.#v.children);for(const r of t)r instanceof HTMLElement&&!r.classList.contains("removing")&&(this.#D(r),e=!0)}}open(){ie(this.#h),this.#S.classList.remove("hidden"),this.#b.classList.add("open")}close(){if(ie(this.#h),this.#S.classList.add("hidden"),this.#b.classList.remove("open"),this.#I){const e=this.#v.querySelectorAll(".item.unread");for(const t of e)t instanceof HTMLElement&&this.markAsRead(t)}}toggle(){ie(this.#h),this.#b.classList.contains("open")?this.close():this.open()}recount(){ie(this.#h);const e=this.#v.querySelectorAll(".item.unread").length;this.#k(e)}get count(){return this.#x}destroy(){this.#h||(this.#T?.removeEventListener("click",this.toggle),this.#b?.querySelector(".close")?.removeEventListener("click",this.close),this.#b?.querySelector(".clear-all")?.removeEventListener("click",this.clear),this.#S?.removeEventListener("click",this.close),this.clear(),this.#b?.remove(),this.#S?.remove(),this.#T?.remove(),this.#x=0,this.#M=new WeakMap,this.#h=!0)}}const se=ne,oe=ee("TinyToastNotify"),ae=class{#N;#L;#_;#j;#R;#P;#h=!1;get destroyed(){return this.#h}constructor(e="top",t="right",r=3e3,i=50,n=300,s=".notify-container"){this.#$(e),this.#O(t),this.#H(r,"baseDuration"),this.#H(i,"extraPerChar"),this.#H(n,"fadeOutDuration"),this.#N=e,this.#L=t,this.#_=r,this.#j=i,this.#R=n;const o=document.querySelector(`${s}.${e}.${t}`);o instanceof HTMLElement?this.#P=o:(this.#P=document.createElement("div"),this.#P.className=`notify-container ${e} ${t}`,document.body.appendChild(this.#P))}getContainer(){if(oe(this.#h),!(this.#P instanceof HTMLElement))throw new Error("Container is not a valid HTMLElement.");return this.#P}#$(e){if(!["top","bottom"].includes(e))throw new Error(`Invalid vertical direction "${e}". Expected "top" or "bottom".`)}#O(e){if(!["left","right","center"].includes(e))throw new Error(`Invalid horizontal position "${e}". Expected "left", "right" or "center".`)}#H(e,t){if("number"!=typeof e||e<0||!Number.isFinite(e))throw new Error(`Invalid value for "${t}": ${e}. Must be a non-negative finite number.`)}getY(){return oe(this.#h),this.#N}setY(e){oe(this.#h),this.#$(e);const t=this.getContainer();t.classList.remove(this.#N),t.classList.add(e),this.#N=e}getX(){return oe(this.#h),this.#L}setX(e){oe(this.#h),this.#O(e);const t=this.getContainer();t.classList.remove(this.#L),t.classList.add(e),this.#L=e}getBaseDuration(){return oe(this.#h),this.#_}setBaseDuration(e){oe(this.#h),this.#H(e,"baseDuration"),this.#_=e}getExtraPerChar(){return oe(this.#h),this.#j}setExtraPerChar(e){oe(this.#h),this.#H(e,"extraPerChar"),this.#j=e}getFadeOutDuration(){return oe(this.#h),this.#R}setFadeOutDuration(e){oe(this.#h),this.#H(e,"fadeOutDuration"),this.#R=e}show(e){oe(this.#h);let t="",r="",i=null,n=!1,s=null;const o=document.createElement("div");if(o.className="notify enter","string"==typeof e)t=e;else{if("object"!=typeof e||null===e||"string"!=typeof e.message)throw new Error("Invalid argument for show(): expected string or { message: string, title?: string, onClick?: function, html?: boolean, avatar?: string }");if(t=e.message,r="string"==typeof e.title?e.title:"",n=!0===e.html,s="string"==typeof e.avatar?e.avatar:null,void 0!==e.onClick){if("function"!=typeof e.onClick)throw new Error("onClick must be a function if defined");i=e.onClick,o.classList.add("clickable")}}const a=document.createElement("button");if(a.innerHTML="&times;",a.className="close",a.setAttribute("aria-label","Close"),a.addEventListener("mouseenter",()=>{a.style.color="var(--notify-close-color-hover)"}),a.addEventListener("mouseleave",()=>{a.style.color="var(--notify-close-color)"}),s){const e=document.createElement("img");e.src=s,e.alt="avatar",e.className="avatar",o.appendChild(e)}if(r){const e=document.createElement("strong");e.textContent=r,e.style.display="block",o.appendChild(e)}if(n){const e=document.createElement("div");e.innerHTML=t,o.appendChild(e)}else o.appendChild(document.createTextNode(t));o.appendChild(a),this.getContainer().appendChild(o);const l=this.#_+t.length*this.#j+this.#R;let u=!1;const h=()=>{u||(u=!0,o.classList.remove("enter","show"),o.classList.add("exit"),setTimeout(()=>o.remove(),this.#R))};"function"==typeof i&&o.addEventListener("click",e=>{e.target!==a&&i(e,h)}),a.addEventListener("click",e=>{e.stopPropagation(),h()}),setTimeout(()=>{o.classList.remove("enter"),o.classList.add("show")},1),setTimeout(()=>h(),l)}destroy(){this.#h||this.#P instanceof HTMLElement&&(this.#P.querySelectorAll(".notify").forEach(e=>e.remove()),this.#P.parentNode&&this.#P.parentNode.removeChild(this.#P),this.#P=null,this.#h=!0)}};function le(e,t){if(!(e instanceof Blob))return Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'));const r=["readAsArrayBuffer","readAsDataURL","readAsText","readAsBinaryString"];return"string"==typeof t&&r.includes(t)?new Promise((r,i)=>{const n=new FileReader;n.onload=()=>{try{r(n.result)}catch(e){i(e)}},n.onerror=()=>{i(n.error)},n[t](e)}):Promise.reject(new TypeError(`The "method" argument must be one of: ${r.join(", ")}.`))}function ue(e,t=!1){return e instanceof Blob?"string"!=typeof t&&"boolean"!=typeof t?Promise.reject(new TypeError("The isDataUrl parameter must be a boolean or a string.")):new Promise((r,i)=>{le(e,"readAsDataURL").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const i=e.match(/^data:(.+);base64,(.*)$/);if(!i||!i[2])throw new Error("Invalid data URL format or missing Base64 content.");const[,n,s]=i;if(!/^[\w/+]+=*$/.test(s))throw new Error("Base64 content is malformed.");if("boolean"==typeof t)return r(t?e:s);if(!/^[\w-]+\/[\w.+-]+$/.test(t))throw new Error(`Invalid MIME type string: ${t}`);return r(`data:${t};base64,${s}`)}).catch(i)}):Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'))}function he(e){return e instanceof Blob?new Promise((t,r)=>le(e,"readAsText").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const r=e.trim();if(0===r.length)throw new Error("File is empty or contains only whitespace.");const i=JSON.parse(r);if("object"!=typeof i||null===i)throw new Error("Parsed content is not a valid JSON object or array.");t(i)}).catch(r)):Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'))}function de(e,t,r=2){if("string"!=typeof e)throw new TypeError('The "filename" argument must be a string.');if("number"!=typeof r||!Number.isInteger(r)||r<0)throw new TypeError('The "spaces" argument must be a non-negative integer.');const i=JSON.stringify(t,null,r),n=new Blob([i],{type:"application/json"}),s=URL.createObjectURL(n),o=document.createElement("a");o.href=s,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(s)}function ce(e,t,r=e=>({headers:e.headers,status:e.status,statusText:e.statusText})){if(!(e instanceof Response))throw new TypeError('The "response" argument must be an instance of Response.');if("function"!=typeof t)throw new TypeError('The "onProgress" argument must be a function.');if(!e.body)return e;const i=e.headers.get("content-length"),n=i?parseInt(i,10):0;let s=0;const o=e.body.getReader(),a=new ReadableStream({async start(e){for(;;){const{done:r,value:i}=await o.read();if(r)break;s+=i.byteLength,t(s,n),e.enqueue(i)}e.close()}});return new Response(a,r(e))}async function me(e,t,r){return"string"!=typeof e?Promise.reject(new TypeError('The "url" argument must be a string.')):void 0!==t&&"object"!=typeof t?Promise.reject(new TypeError('The "options" argument must be an object.')):void 0!==r&&"function"!=typeof r?Promise.reject(new TypeError('The "onProgress" option must be a function.')):new Promise((i,n)=>{fetch(e,t??void 0).then(async e=>{const t=r?ce(e,r):e,n=t.headers.get("content-type")||"";if(!n.includes("application/json"))throw new Error(`Unexpected content-type: ${n}`);const s=await t.json();if(!Array.isArray(s)&&!g(s))throw new Error("Received invalid data instead of valid JSON.");return i(s)}).catch(n)})}async function pe(e,t,r,i){return"string"!=typeof e?Promise.reject(new TypeError('The "url" argument must be a string.')):void 0===t||Array.isArray(t)?void 0!==r&&"object"!=typeof r?Promise.reject(new TypeError('The "options" argument must be an object.')):void 0!==i&&"function"!=typeof i?Promise.reject(new TypeError('The "onProgress" option must be a function.')):new Promise((n,s)=>{fetch(e,r??void 0).then(async e=>{const r=i?ce(e,i):e,s=r.headers.get("content-type")||"";if(Array.isArray(t)&&t.length>0&&!t.some(e=>s.includes(e)))throw new Error(`Blocked MIME type: ${s}`);const o=await r.text();return n(o)}).catch(s)}):Promise.reject(new TypeError('The "allowedMimeTypes" argument must be an array of strings.'))}function fe(e={}){if(null===e||"object"!=typeof e)throw new TypeError('The "settings" argument must be an object.');const{element:t=document.body,hiddenClass:r="windowHidden",visibleClass:i="windowVisible",onVisible:n,onHidden:s}=e;if(!(t instanceof Element))throw new TypeError('"element" must be an instance of Element.');if("string"!=typeof r)throw new TypeError('"hiddenClass" must be a string.');if("string"!=typeof i)throw new TypeError('"visibleClass" must be a string.');if(void 0!==n&&"function"!=typeof n)throw new TypeError('"onVisible" must be a function if provided.');if(void 0!==s&&"function"!=typeof s)throw new TypeError('"onHidden" must be a function if provided.');let o="",a="";const l=()=>{t.classList.remove(r),t.classList.remove(i)};let u=null;const h=["visibilitychange","mozvisibilitychange","webkitvisibilitychange","msvisibilitychange"],d=["hidden","mozHidden","webkitHidden","msHidden"];for(let e=0;e<d.length;e++)if(d[e]in document){u=d[e];break}const c=function(e){l();const h=e?.type,d=u&&document[u];["focus","focusin","pageshow"].includes(h)?(t.classList.add(i),n?.({type:h,oldClass:a,oldType:o}),a=i):["blur","focusout","pagehide"].includes(h)||d?(t.classList.add(r),s?.({type:h,oldClass:a,oldType:o}),a=r):(t.classList.add(i),n?.({type:h,oldClass:a,oldType:o}),a=i),o=h};let m=()=>{};if(u){const e=h[d.indexOf(u)];document.addEventListener(e,c),window.addEventListener("focus",c),window.addEventListener("blur",c),m=()=>{document.removeEventListener(e,c),window.removeEventListener("focus",c),window.removeEventListener("blur",c),l()}}else"onfocusin"in document?(document.onfocusin=document.onfocusout=c,m=()=>{document.onfocusin=document.onfocusout=null,l()}):(window.onpageshow=window.onpagehide=window.onfocus=window.onblur=c,m=()=>{window.onpageshow=window.onpagehide=window.onfocus=window.onblur=null,l()});const p=new Event(u&&document[u]?"blur":"focus");return c(p),m}const ye=ee("TinyDragDropDetector"),ge=class{#F;#B;#z;#W;#V;#q;#K;#h=!1;get destroyed(){return this.#h}constructor(e,t){const{hoverClass:r="dnd-hover",onDrop:i,onEnter:n,onLeave:s}=t;if(!(e instanceof HTMLElement))throw new TypeError('The "target" option must be an instance of HTMLElement.');if("string"!=typeof r)throw new TypeError('The "hoverClass" option must be a string.');if("function"!=typeof i)throw new TypeError('The "onDrop" option must be a function.');if("function"!=typeof n)throw new TypeError('The "onEnter" option must be a function.');if("function"!=typeof s)throw new TypeError('The "onLeave" option must be a function.');this.#F=e,this.#B=r,this.#z=i||(()=>{}),this.#W=n,this.#V=s,this.#q=!1,this.#K=!1,this._handleDragEnter=this._handleDragEnter.bind(this),this._handleDragOver=this._handleDragOver.bind(this),this._handleDragLeave=this._handleDragLeave.bind(this),this._handleDrop=this._handleDrop.bind(this),this.#J()}getTarget(){return ye(this.#h),this.#F}getHoverClass(){return ye(this.#h),this.#B}isDragging(){return ye(this.#h),this.#q}bound(){return ye(this.#h),this.#K}#J(){if(this.#K)return;const e=this.getTarget();e.addEventListener("dragenter",this._handleDragEnter),e.addEventListener("dragover",this._handleDragOver),e.addEventListener("dragleave",this._handleDragLeave),e.addEventListener("drop",this._handleDrop),this.#K=!0}#U(){if(!this.#K)return;const e=this.getTarget();e.removeEventListener("dragenter",this._handleDragEnter),e.removeEventListener("dragover",this._handleDragOver),e.removeEventListener("dragleave",this._handleDragLeave),e.removeEventListener("drop",this._handleDrop),this.#K=!1}_handleDragEnter(e){if(e.preventDefault(),!this.#q){const t=this.getTarget();this.#q=!0,t.classList.add(this.#B),this.#W(e)}}_handleDragOver(e){e.preventDefault(),e.dataTransfer?e.dataTransfer.dropEffect="copy":console.warn("[TinyDragDropDetector] [handleDragOver] DragOver event missing dataTransfer.")}_handleDragLeave(e){e.preventDefault();const t=this.getTarget();null!==e.relatedTarget&&t.contains(e.relatedTarget)||(this.#q=!1,t.classList.remove(this.#B),this.#V(e))}_handleDrop(e){if(e.preventDefault(),!e.dataTransfer)return void console.warn("[TinyDragDropDetector] [handleDrop] DragOver event missing dataTransfer.");const t=this.getTarget();this.#q=!1,t.classList.remove(this.#B);const r=e.dataTransfer.files;r.length>0&&this.#z(r,e)}destroy(){this.#h||(this.#U(),this.getTarget().classList.remove(this.#B),this.#h=!0)}};var we=r(133),be=r(975);function ve(e){if(!(0,we.existsSync)(e))throw new Error(`File not found: ${e}`);const t=(0,we.readFileSync)(e,"utf-8");return JSON.parse(t)}function Ee(e,t,r=2){const i=JSON.stringify(t,null,r);(0,we.writeFileSync)(e,i,"utf-8")}function Te(e){(0,we.existsSync)(e)||(0,we.mkdirSync)(e,{recursive:!0})}function Se(e){if(!(0,we.existsSync)(e))return;const t=(0,we.readdirSync)(e);for(const r of t){const t=(0,be.join)(e,r);(0,we.lstatSync)(t).isDirectory()?(0,we.rmSync)(t,{recursive:!0,force:!0}):(0,we.unlinkSync)(t)}}function xe(e){return(0,we.existsSync)(e)&&(0,we.lstatSync)(e).isFile()}function Ae(e){return(0,we.existsSync)(e)&&(0,we.lstatSync)(e).isDirectory()}function Ce(e){return 0===(0,we.readdirSync)(e).length}function Ie(e,t,r){Te((0,be.dirname)(t)),(0,we.copyFileSync)(e,t,r)}function Me(e){return!!xe(e)&&((0,we.unlinkSync)(e),!0)}function De(e,t,r="utf-8"){Te((0,be.dirname)(e)),(0,we.writeFileSync)(e,t,r)}function ke(e,t=!1){const r={files:[],dirs:[]};if(!Ae(e))return r;const i=(0,we.readdirSync)(e);for(const n of i){const i=(0,be.join)(e,n);if((0,we.lstatSync)(i).isDirectory()){if(r.dirs.push(i),t){const e=ke(i,!0);r.files.push(...e.files),r.dirs.push(...e.dirs)}}else r.files.push(i)}return r}function Ne(e,t=!1){const r=[];if(!Ae(e))return r;const i=(0,we.readdirSync)(e);for(const n of i){const i=(0,be.join)(e,n);(0,we.lstatSync)(i).isDirectory()&&(r.push(i),t&&r.push(...Ne(i,!0)))}return r}function Le(e){return xe(e)?(0,we.statSync)(e).size:0}function _e(e){let t=0;const r=ke(e,!0).files;for(const e of r)t+=Le(e);return t}function je(e,t="bak"){xe(e)&&Ie(e,`${e}.${t}.${(new Date).toISOString().replace(/[:.]/g,"-")}`)}function Re(e,t="bak"){const r=(0,be.dirname)(e),i=(0,be.basename)(e),n=(0,we.readdirSync)(r).filter(e=>e.startsWith(`${i}.${t}.`)).sort().reverse();if(0===n.length)throw new Error(`No backups found for ${e}`);return(0,be.join)(r,n[0])}function Pe(e,t="bak"){Ie(Re(e,t),e)}function $e(e,t,r=[]){if("string"!=typeof e)throw new TypeError("dirPath must be a string");if("function"!=typeof t)throw new TypeError("renameFn must be a function");if(!Array.isArray(r))throw new TypeError("extensions must be an array of strings");if(!(0,we.existsSync)(e)||!(0,we.statSync)(e).isDirectory())throw new Error(`Directory not found or invalid: ${e}`);for(const e of r)if("string"!=typeof e||!e.startsWith("."))throw new TypeError(`Invalid extension: ${e}`);const i=ke(e).files;let n=0;for(const s of i){const i=(0,be.extname)(s);if(r.length&&!r.includes(i))continue;const o=(0,be.basename)(s),a=t(o,n++),l=(0,be.join)(e,a);o!==a&&(0,we.renameSync)(s,l)}}function Oe(e,t,r,i=[]){$e(e,e=>{const i=(0,be.extname)(e);return`${(0,be.basename)(e,i).replace(t,r)}${i}`},i)}function He(e,{prefix:t="",suffix:r=""},i=[]){$e(e,e=>{const i=(0,be.extname)(e),n=(0,be.basename)(e,i);return`${t}${n}${r}${i}`},i)}function Fe(e,t="lower",r=[],i=!1){if("string"!=typeof t||!["lower","upper","title"].includes(t))throw new Error(`Invalid mode "${t}". Must be 'lower', 'upper' or 'title'.`);$e(e,e=>{const r=e=>"lower"===t?e.toLowerCase():"upper"===t?e.toUpperCase():"title"===t?q(e):e,n=(0,be.extname)(e),s=i?r(n):n;return`${r((0,be.basename)(e,n))}${s}`},r)}function Be(e,t=3,r=[]){$e(e,e=>e.replace(/\d+/,e=>e.padStart(t,"0")),r)}var ze=r(370);async function We(e){if(!(0,we.existsSync)(e))return;const t=await(0,ze.readdir)(e),r={},i=[];for(const n of t){const t=(0,be.join)(e,n),s=(0,ze.lstat)(t);s.then(e=>(r[t]=e,e)),i.push(s)}await Promise.all(i);const n=[];for(const e in r)r[e].isDirectory()?n.push((0,ze.rm)(e,{recursive:!0,force:!0})):n.push((0,ze.unlink)(e));await Promise.all(n)}async function Ve(e){return 0===(await(0,ze.readdir)(e)).length}async function qe(e,t=!1){const r={files:[],dirs:[]};if(!Ae(e))return r;const i=await(0,ze.readdir)(e);for(const n of i){const i=(0,be.join)(e,n);if((await(0,ze.lstat)(i)).isDirectory()){if(r.dirs.push(i),t){const e=await qe(i,!0);r.files.push(...e.files),r.dirs.push(...e.dirs)}}else r.files.push(i)}return r}async function Ke(e,t=!1){const r=[];if(!Ae(e))return r;const i=await(0,ze.readdir)(e);for(const n of i){const i=(0,be.join)(e,n);(await(0,ze.lstat)(i)).isDirectory()&&(r.push(i),t&&r.push(...await Ke(i,!0)))}return r}async function Je(e){return xe(e)?(await(0,ze.stat)(e)).size:0}async function Ue(e){let t=0;const{files:r}=await qe(e,!0),i=[];for(const e of r){const r=Je(e);r.then(e=>(t+=e,e)),i.push(r)}return await Promise.all(i),t}const Ge=(e,t)=>e.bottom<t.top,Ye=(e,t)=>e.top>t.bottom,Xe=(e,t)=>e.right<t.left,Qe=(e,t)=>e.left>t.right,Ze=(e,t)=>e.bottom<=t.top,et=(e,t)=>e.top>=t.bottom,tt=(e,t)=>e.right<=t.left,rt=(e,t)=>e.left>=t.right,it=(e,t)=>!(Xe(e,t)||Qe(e,t)||Ge(e,t)||Ye(e,t)),nt=(e,t)=>!(tt(e,t)||rt(e,t)||Ze(e,t)||et(e,t)),st=(e,t)=>Xe(e,t)?"left":Qe(e,t)?"right":Ge(e,t)?"top":Ye(e,t)?"bottom":null,ot=(e,t)=>tt(e,t)?"left":rt(e,t)?"right":Ze(e,t)?"top":et(e,t)?"bottom":null,at=(e,t)=>({overlapLeft:t.right-e.left,overlapRight:e.right-t.left,overlapTop:t.bottom-e.top,overlapBottom:e.bottom-t.top}),lt=({overlapLeft:e=-1,overlapRight:t=-1,overlapTop:r=-1,overlapBottom:i=-1}={})=>({dirX:e<t?"right":"left",dirY:r<i?"bottom":"top"}),ut=e=>({x:e.left+e.width/2,y:e.top+e.height/2});function ht(e,t){const r=e.left+e.width/2,i=e.top+e.height/2;return{x:t.left+t.width/2-r,y:t.top+t.height/2-i}}function dt(e,t){if(!nt(e,t))return{inDir:null,dirX:null,dirY:null,depthX:0,depthY:0};const{overlapLeft:r,overlapRight:i,overlapTop:n,overlapBottom:s}=at(e,t),{dirX:o,dirY:a}=lt({overlapLeft:r,overlapRight:i,overlapTop:n,overlapBottom:s}),l=Math.min(r,i),u=Math.min(n,s);let h;return h=l<u?o:a,{inDir:h,dirX:o,dirY:a,depthX:l,depthY:u}}function ct(e,t){const r=nt(e,t),i={in:null,x:null,y:null},n={y:null,x:null},s={top:0,bottom:0,left:0,right:0},{overlapLeft:o,overlapRight:a,overlapTop:l,overlapBottom:u}=at(t,e);s.top=l,s.bottom=u,s.left=o,s.right=a;const h=Object.entries(s).filter(([,e])=>e>0).sort((e,t)=>e[1]-t[1]),{dirX:d,dirY:c}=lt({overlapLeft:a,overlapRight:o,overlapTop:u,overlapBottom:l});return i.y=c,i.x=d,s.bottom<0?n.y="bottom":s.top<0&&(n.y="top"),s.left<0?n.x="left":s.right<0&&(n.x="right"),i.in=r?s.top===s.bottom&&s.bottom===s.left&&s.left===s.right?"center":h.length?h[0][0]:"top":null,{dirs:i,depth:s,isNeg:n}}const mt=ee("TinyElementObserver"),pt=class{#h=!1;get destroyed(){return this.#h}#G;get el(){return mt(this.#h),this.#G}#Y={};get settings(){return mt(this.#h),this.#Y}set settings(e){if(mt(this.#h),"object"!=typeof e||null===e)throw new TypeError("settings must be a non-null object.");this.#Y=e}#X=null;get observer(){return mt(this.#h),this.#X}#Q=[];get detectors(){return mt(this.#h),this.#Q.map(e=>[e[0],e[1]])}set detectors(e){if(mt(this.#h),!Array.isArray(e))throw new TypeError("detectors must be an array.");const t=[];for(const[r,i]of e){if("string"!=typeof r)throw new TypeError("Detector name must be a string.");if("function"!=typeof i)throw new TypeError(`Detector handler for "${r}" must be a function.`);t.push([r,i])}this.#Q=t}get isActive(){return mt(this.#h),!!this.#X}get size(){return mt(this.#h),this.#Q.length}constructor(e,{initDetectors:t=[],initCfg:r={}}={}){this.#G=e,t.length&&(this.detectors=t),r&&(this.settings=r)}clear(){mt(this.#h),this.#Q=[]}start(){if(mt(this.#h),!this.#G)throw new Error("Cannot start observation: no target element has been set.");this.#X||(this.#X=new MutationObserver(e=>{e.forEach((e,t,r)=>this.#Q.forEach(i=>i[1](e,t,r)))}),this.#X.observe(this.#G,this.#Y))}stop(){mt(this.#h),this.#X&&(this.#X.disconnect(),this.#X=null)}add(e,t){mt(this.#h),this.#Z(e,t),this.#Q.push([e,t])}insertAtStart(e,t){mt(this.#h),this.#Z(e,t),this.#Q.unshift([e,t])}insertAt(e,t,r,i="after"){if(mt(this.#h),this.#Z(t,r),"number"!=typeof e||e<0||e>=this.#Q.length)throw new RangeError("Invalid index for insertDetectorAt.");const n="before"===i?e:e+1;this.#Q.splice(n,0,[t,r])}removeAt(e){if(mt(this.#h),"number"!=typeof e||e<0||e>=this.#Q.length)throw new RangeError("Invalid index for removeDetectorAt.");this.#Q.splice(e,1)}removeAround(e,t=0,r=0){if(mt(this.#h),"number"!=typeof e||e<0||e>=this.#Q.length)throw new RangeError("Invalid index for removeDetectorsAround.");const i=Math.max(0,e-t),n=t+1+r;this.#Q.splice(i,n)}isIndexUsed(e){return mt(this.#h),e>=0&&e<this.#Q.length}hasHandler(e){if(mt(this.#h),"function"!=typeof e)throw new TypeError("Handler must be a function.");return this.#Q.some(([t,r])=>r===e)}#Z(e,t){if("string"!=typeof e||!e.trim())throw new TypeError("Detector name must be a non-empty string.");if("function"!=typeof t)throw new TypeError(`Detector handler for "${e}" must be a function.`)}destroy(){this.#h||(this.stop(),this.clear(),this.#h=!0)}},{wE:ft,D6:yt,Kr:gt,iu:wt,cq:bt,lP:vt}=i,Et=new WeakMap,Tt=new WeakMap,St=new WeakMap,xt=new WeakMap,At={top:new WeakMap,bottom:new WeakMap,left:new WeakMap,right:new WeakMap};class Ct{static Utils={...n};static#ee=1;static get version(){return this.#ee}static#te=!1;static get elemDebug(){return Ct.#te}static set elemDebug(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value for elemDebug");Ct.#te=e}static _debugElemError(e,t){if(!Ct.#te)return;const r="[TinyHtml Debug] Element validation error";if(console.groupCollapsed(`${r}${t?" — details below":""}`),console.error(r),"undefined"!=typeof Error&&"function"==typeof Error.captureStackTrace){const e=new Error(r);Error.captureStackTrace(e,Ct._debugElemError),console.error(e.stack)}else console.trace(r);if(Array.isArray(e)){const t=e.map((e,t)=>({index:t,typeOf:null===e?"null":typeof e,constructor:e?.constructor?.name??(null===e?"null":"primitive"),summary:"undefined"!=typeof Element&&e instanceof Element?`${e.tagName?.toLowerCase?.()??"element"}#${e.id||""}.${String(e.className||"").trim().replace(/\s+/g,".")}`:e&&"object"==typeof e&&"nodeType"in e?`nodeType:${e.nodeType}`:"",value:e}));console.table(t)}else console.warn('[TinyHtml Debug] "elems" is not an array:',e);arguments.length>1&&(console.error("[TinyHtml Debug] Problematic element:",t),t&&"object"==typeof t&&console.dir(t)),console.groupEnd()}static parseStyle(e){const t={};return e.split(";").forEach(e=>{const[r,i]=e.split(":").map(e=>e&&e.trim());r&&i&&(t[r]=i)}),t}static#re="undefined"!=typeof window&&void 0!==window.document?new pt(window.document.documentElement,{initDetectors:[["tinyStyleEvent",e=>{if("attributes"!==e.type||"style"!==e.attributeName||!(e.target instanceof HTMLElement))return;const t=e.oldValue||"",r=e.target.getAttribute("style")||"",i=G(Ct.parseStyle(t),Ct.parseStyle(r));(Object.keys(i.added).length||Object.keys(i.removed).length||Object.keys(i.modified).length)&&e.target.dispatchEvent(new CustomEvent("tinyhtml.stylechanged",{detail:i}))}],["tinyClassEvent",e=>{if("attributes"!==e.type||"class"!==e.attributeName||!(e.target instanceof HTMLElement))return;const t=e.oldValue||"",r=e.target.className||"",i=l(t.split(/\s+/).filter(Boolean),r.split(/\s+/).filter(Boolean));(i.added.length||i.removed.length)&&e.target.dispatchEvent(new CustomEvent("tinyhtml.classchanged",{detail:i}))}]],initCfg:{attributeOldValue:!0,attributes:!0,subtree:!0,attributeFilter:["style","class"]}}):void 0;static get tinyObserver(){return Ct.#re}static async fetchHtmlFile(e,t={method:"GET"}){const r=await fetch(e,t),i=r.headers.get("Content-Type")||"";if(!r.ok)throw new Error(`Failed to fetch: ${r.status} ${r.statusText}`);if(!i.includes("text/html"))throw new Error(`Invalid content type: ${i} (expected text/html)`);const n=await r.text();return Ct.htmlToJson(n)}static async fetchHtmlNodes(e,t){const r=await Ct.fetchHtmlFile(e,t);return Ct.jsonToNodes(r)}static async fetchHtmlTinyElems(e,t){const r=await Ct.fetchHtmlNodes(e,t);return Ct.toTinyElm(r)}static templateToJson(e){return Ct.htmlToJson([...e.content.childNodes].map(e=>e instanceof Element?e.getHTML():e instanceof Text?e.textContent:"").join(""))}static templateToNodes(e){const t=[];return[...e.content.cloneNode(!0).childNodes].map(e=>{if(!(e instanceof Element||e instanceof Text||e instanceof Comment))throw new Error(`Expected only Element nodes in <template>, but found: ${e.constructor.name}`);e instanceof Comment||t.push(e)}),t}static templateToTinyElems(e){return Ct.toTinyElm(Ct.templateToNodes(e))}static htmlToJson(e){const t=document.createElement("div");t.innerHTML=e.trim();const r=[],i=e=>{if(e instanceof Comment)return null;if(e instanceof Text){const t=e.textContent?.trim();return t||null}if(!(e instanceof Element))return null;const t=e.tagName.toLowerCase(),r={};for(const t of e.attributes)r[Ct.getPropName(t.name)]=t.value;const n=Array.from(e.childNodes).map(i).filter(Boolean);return n.length>0?[t,r,...n]:[t,r]};for(const e of t.childNodes){const t=i(e);t&&r.push(t)}return t.innerHTML="",r}static jsonToNodes(e){const t=e=>{if("string"==typeof e)return document.createTextNode(e);if(!Array.isArray(e))return document.createTextNode("");const[r,i,...n]=e,s=document.createElement(r);for(const[e,t]of Object.entries(i))s.setAttribute(Ct.getAttrName(e),t);for(const e of n){const r=t(e);r instanceof Comment||s.appendChild(r)}return s};return e.map(t).filter(e=>!(e instanceof Comment))}static jsonToTinyElems(e){return Ct.toTinyElm(Ct.jsonToNodes(e))}static createFrom(e,t){if("string"!=typeof e)throw new TypeError('The "tagName" must be a string.');if(void 0!==t&&"object"!=typeof t)throw new TypeError('The "attrs" must be a object.');const r=Ct.createElement(e);if("object"==typeof t)for(const e in t)r.setAttr(e,t[e]);return r}static createElement(e,t){if("string"!=typeof e)throw new TypeError("[TinyHtml] createElement(): The tagName must be a string.");if(void 0!==t&&"object"!=typeof t)throw new TypeError("[TinyHtml] createElement(): The ops must be a object.");return new Ct(document.createElement(e,t))}static createTextNode(e){if("string"!=typeof e)throw new TypeError("[TinyHtml] createTextNode(): The value must be a string.");return new Ct(document.createTextNode(e))}static createElementFromHTML(e){const t=document.createElement("template");if(!(e=e.trim()).startsWith("<"))return Ct.createTextNode(e);if(t.innerHTML=e,!(t.content.firstChild instanceof Element))throw new Error("The HTML string must contain a valid HTML element.");return new Ct(t.content.firstChild)}static createFromHTML(e){const t=document.createElement("template");e=e.trim(),t.innerHTML=e;const r=Array.from(t.content.childNodes);if(!r.every(e=>e instanceof Element||e instanceof Text))throw new Error("The HTML string must contain a valid HTML element.");return new Ct(r)}static createFromHtml(e){return Ct.createFromHTML(e)}static query(e,t=document){const r=t.querySelector(e);return r?new Ct(r):null}querySelector(e){return Ct.query(e,Ct._preElem(this,"query"))}static queryAll(e,t=document){return new Ct(t.querySelectorAll(e))}querySelectorAll(e){return Ct.queryAll(e,Ct._preElem(this,"queryAll"))}static getById(e){const t=document.getElementById(e);return t?new Ct(t):null}static getByClassName(e,t=document){return new Ct(t.getElementsByClassName(e))}getElementsByClassName(e){return Ct.getByClassName(e,Ct._preElem(this,"getByClassName"))}static getByName(e){return new Ct(document.getElementsByName(e))}static getByTagNameNS(e,t="http://www.w3.org/1999/xhtml",r=document){return new Ct(r.getElementsByTagNameNS(t,e))}getElementsByTagNameNS(e,t="http://www.w3.org/1999/xhtml"){return Ct.getByTagNameNS(e,t,Ct._preElem(this,"getByTagNameNS"))}get elements(){return[...this.#G]}forEach(e){const t=this.elements.map((e,t)=>this.extract(t));for(const r in t)e(t[r],Number(r),t);return this}get(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");if(!this.#G[e])throw new Error(`No element found at index ${e}.`);return this.#G[e]}extract(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");if(!this.#G[e])throw new Error(`Cannot extract: no element exists at index ${e}.`);return new Ct(this.#G[e])}exists(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");return!!this.#G[e]}_getElement(e,t){if(!(this.#G[t]instanceof Element||this.#G[t]instanceof Window||this.#G[t]instanceof Document||this.#G[t]instanceof Text))throw Ct._debugElemError([...this.#G],this.#G[t]),new Error(`[TinyHtml] Invalid Element in ${e}().`);return this.#G[t]}_getElements(e){if(!this.#G.every(e=>e instanceof Element||e instanceof Window||e instanceof Document||e instanceof Text))throw Ct._debugElemError([...this.#G]),new Error(`[TinyHtml] Invalid Element in ${e}().`);return[...this.#G]}static _preElemsTemplate(e,t,r,i){const n=e=>{const n=[];return e.map(s=>(s instanceof Ct?s._getElements(t):[s]).map(s=>{let o=!1;for(const e of r)if(s instanceof e){o=!0;break}if(!o)throw Ct._debugElemError([...e],s),new Error(`[TinyHtml] Invalid element of the list "${i.join(",")}" in ${t}().`);return n.push(s),s})),n};return Array.isArray(e)?n(e):n([e])}_preElemsTemplate(e,t,r){return Ct._preElemsTemplate(this,e,t,r)}static _preElemTemplate(e,t,r,i,n=!1){const s=e=>{const s=e[0],o=s instanceof Ct?s._getElements(t):[s];if(o.length>1)throw Ct._debugElemError([...e]),new Error(`[TinyHtml] Invalid element amount in ${t}() (Received ${o.length}/1).`);let a=!1;for(const e of r)if(o[0]instanceof e){a=!0;break}if(!n||null!==o[0]&&void 0!==o[0]||(o[0]=null,a=!0),!a)throw Ct._debugElemError([...e],o[0]),new Error(`[TinyHtml] Invalid element of the list "${i.join(",")}" in ${t}().`);return o[0]};if(!Array.isArray(e))return s([e]);if(e.length>1)throw Ct._debugElemError([...e]),new Error(`[TinyHtml] Invalid element amount in ${t}() (Received ${e.length}/1).`);return s(e)}_preElemTemplate(e,t,r,i=!1){return Ct._preElemTemplate(this,e,t,r,i)}static _preElems(e,t){return Ct._preElemsTemplate(e,t,[Element],["Element"])}_preElems(e){return Ct._preElems(this,e)}static _preElem(e,t){return Ct._preElemTemplate(e,t,[Element],["Element"])}_preElem(e){return Ct._preElem(this,e)}static _preNodeElems(e,t){return Ct._preElemsTemplate(e,t,[Node],["Node"])}_preNodeElems(e){return Ct._preNodeElems(this,e)}static _preNodeElem(e,t){return Ct._preElemTemplate(e,t,[Node],["Node"])}_preNodeElem(e){return Ct._preNodeElem(this,e)}static _preNodeElemWithNull(e,t){return Ct._preElemTemplate(e,t,[Node],["Node"],!0)}_preNodeElemWithNull(e){return Ct._preNodeElemWithNull(this,e)}static _preHtmlElems(e,t){return Ct._preElemsTemplate(e,t,[HTMLElement],["HTMLElement"])}_preHtmlElems(e){return Ct._preHtmlElems(this,e)}static _preHtmlElem(e,t){return Ct._preElemTemplate(e,t,[HTMLElement],["HTMLElement"])}_preHtmlElem(e){return Ct._preHtmlElem(this,e)}static _preInputElems(e,t){return Ct._preElemsTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElems(e){return Ct._preInputElems(this,e)}static _preInputElem(e,t){return Ct._preElemTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElem(e){return Ct._preInputElem(this,e)}static _preEventTargetElems(e,t){return Ct._preElemsTemplate(e,t,[EventTarget],["EventTarget"])}_preEventTargetElems(e){return Ct._preEventTargetElems(this,e)}static _preEventTargetElem(e,t){return Ct._preElemTemplate(e,t,[EventTarget],["EventTarget"])}_preEventTargetElem(e){return Ct._preEventTargetElem(this,e)}static _preElemsAndWindow(e,t){return Ct._preElemsTemplate(e,t,[Element,Window],["Element","Window"])}_preElemsAndWindow(e){return Ct._preElemsAndWindow(this,e)}static _preElemAndWindow(e,t){return Ct._preElemTemplate(e,t,[Element,Window],["Element","Window"])}_preElemAndWindow(e){return Ct._preElemAndWindow(this,e)}static _preElemsAndWinAndDoc(e,t){return Ct._preElemsTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]).map(e=>e instanceof Document?e.documentElement:e)}_preElemsAndWinAndDoc(e){return Ct._preElemsAndWinAndDoc(this,e)}static _preElemAndWinAndDoc(e,t){const r=Ct._preElemTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]);return r instanceof Document?r.documentElement:r}_preElemAndWinAndDoc(e){return Ct._preElemAndWinAndDoc(this,e)}static _preElemsWithDoc(e,t){return Ct._preElemsTemplate(e,t,[Element,Document],["Element","Document"])}_preElemsWithDoc(e){return Ct._preElemsWithDoc(this,e)}static _preElemWithDoc(e,t){return Ct._preElemTemplate(e,t,[Element,Document],["Element","Document"])}_preElemWithDoc(e){return Ct._preElemWithDoc(this,e)}static toTinyElm(e){const t=e=>e.map(e=>e instanceof Ct?e:new Ct(e));return Array.isArray(e)?t(e):t([e])}static fromTinyElm(e){const t=e=>{const t=[];return e.map(e=>(e instanceof Ct?e._getElements("fromTinyElm"):[e]).map(e=>t.push(e))),t};return Array.isArray(e)?t(e):t([e])}static winnow(e,t,r,i=!1){if("boolean"!=typeof i)throw new TypeError('The "not" must be a boolean.');if("function"==typeof t)return Ct._preElems(e,r).filter((e,r)=>!!t.call(e,r,e)!==i);if(t instanceof Element)return Ct._preElems(e,r).filter(e=>e===t!==i);if(Array.isArray(t)||"string"!=typeof t&&null!=t.length)return Ct._preElems(e,r).filter(e=>t.includes(e)!==i);let n=t;return i&&(n=`:not(${n})`),Ct._preElems(e,r).filter(e=>1===e.nodeType&&e.matches(n))}static filter(e,t,r=!1){return r&&(t=`:not(${t})`),Ct._preElems(e,"filter").filter(e=>1===e.nodeType&&e.matches(t))}static filterOnly(e,t){return Ct.winnow(e,t,"filterOnly",!1)}static not(e,t){return Ct.winnow(e,t,"not",!0)}not(e){return Ct.not(this,e)}static find(e,t){const r=[];for(const i of Ct._preElems(e,"find"))r.push(...i.querySelectorAll(t));return[...new Set(r)]}find(e){return Ct.find(this,e)}static is(e,t){return Ct.winnow(e,t,"is",!1).length>0}is(e){return Ct.is(this,e)}static has(e,t){const r="string"==typeof t?[...document.querySelectorAll(t)]:Ct._preElems(t,"has");return Ct._preElems(e,"has").filter(e=>r.some(t=>e&&e.contains(t)))}has(e){return Ct.has(this,e)}static closest(e,t,r){const i=[];for(const n of Ct._preElems(e,"closest")){let e=n;for(;e&&e!==r;){if(1===e.nodeType&&("string"==typeof t?e.matches(t):e===t)){i.push(e);break}e=e.parentElement}}return[...new Set(i)]}closest(e,t){return Ct.closest(this,e,t)}static isSameDom(e,t){return Ct._preNodeElem(e,"isSameDom")===Ct._preNodeElem(t,"isSameDom")}isSameDom(e){return Ct.isSameDom(this,e)}#ie={};get _data(){return{...this.#ie}}set _data(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new Error("value must be a non-null object.");this.#ie=e}static _dataSelector={public:(e,t)=>{const r=Ct._preElem(t,e);let i=Tt.get(r);return i||(i={},Tt.set(r,i)),i},private:(e,t)=>{if(!(t instanceof Ct))throw new Error(`Element must be a TinyHtml instance to execute ${e}().`);return t.#ie}};static data(e,t,r=!1){const i=Ct._dataSelector[r?"private":"public"]("data",e);if(null==t)return{...i};if("string"!=typeof t)throw new TypeError("The key must be a string.");return i.hasOwnProperty(t)?i[t]:void 0}data(e,t){return Ct.data(this,e,t)}static setData(e,t,r,i=!1){const n=Ct._dataSelector[i?"private":"public"]("setData",e);if("string"!=typeof t)throw new TypeError("The key must be a string.");return void 0!==r?n[t]=r:Ct.removeData(e,t),e}setData(e,t,r=!1){return Ct.setData(this,e,t,r)}static hasData(e,t,r=!1){if("string"!=typeof t)throw new TypeError("The key must be a string.");const i=Ct._dataSelector[r?"private":"public"]("hasData",e);return Object.prototype.hasOwnProperty.call(i,t)}hasData(e,t=!1){return Ct.hasData(this,e,t)}static removeData(e,t,r=!1){if("string"!=typeof t)throw new TypeError("The key must be a string.");return delete Ct._dataSelector[r?"private":"public"]("removeData",e)[t]}removeData(e,t=!1){return Ct.removeData(this,e,t)}static _getSibling(e,t,r){let i=Ct._preNodeElemWithNull(e,r);for(;i&&(i=i[t])&&1!==i.nodeType;);return i instanceof Node?i:null}static _getSiblings(e,t){let r=e;const i=[];for(;r;r=r.nextSibling)1===r.nodeType&&r!==t&&i.push(r);return i}static domDir(e,t,r,i="domDir"){if("string"!=typeof t)throw new TypeError('The "direction" must be a string.');let n=Ct._preNodeElemWithNull(e,i);const s=[];for(;n&&(n=n[t]);)if(1===n.nodeType){if(r&&("string"==typeof r?n.matches(r):n===r))break;s.push(n)}return s}static parent(e){let t=Ct._preNodeElemWithNull(e,"parent");const r=t?t.parentNode:null;return r&&11!==r.nodeType?r:null}parent(){return Ct.parent(this)}static parents(e,t){return Ct.domDir(e,"parentNode",t,"parents")}parents(e){return Ct.parents(this,e)}static next(e){return Ct._getSibling(e,"nextSibling","next")}next(){return Ct.next(this)}static prev(e){return Ct._getSibling(e,"previousSibling","prev")}prev(){return Ct.prev(this)}static nextAll(e){return Ct.domDir(e,"nextSibling",void 0,"nextAll")}nextAll(){return Ct.nextAll(this)}static prevAll(e){return Ct.domDir(e,"previousSibling",void 0,"prevAll")}prevAll(){return Ct.prevAll(this)}static nextUntil(e,t){return Ct.domDir(e,"nextSibling",t,"nextUtil")}nextUntil(e){return Ct.nextUntil(this,e)}static prevUntil(e,t){return Ct.domDir(e,"previousSibling",t,"prevUtil")}prevUntil(e){return Ct.prevUntil(this,e)}static siblings(e){const t=Ct._preNodeElemWithNull(e,"siblings");return Ct._getSiblings(t&&t.parentNode?t.parentNode.firstChild:null,t)}siblings(){return Ct.siblings(this)}static children(e){const t=Ct._preNodeElemWithNull(e,"children");return Ct._getSiblings(t?t.firstChild:null)}children(){return Ct.children(this)}static contents(e){const t=Ct._preNodeElemWithNull(e,"contents");return t instanceof HTMLIFrameElement&&null!=t.contentDocument&&Object.getPrototypeOf(t.contentDocument)?[t.contentDocument]:t instanceof HTMLTemplateElement?Array.from((t.content||t).childNodes):t?Array.from(t.childNodes):[]}contents(){return Ct.contents(this)}static clone(e,t=!0){if("boolean"!=typeof t)throw new TypeError('The "deep" must be a boolean.');return Ct._preNodeElems(e,"clone").map(e=>e.cloneNode(t))}clone(e){return Ct.clone(this,e)[0]}static _appendChecker(e,...t){const r=[];for(const i of t)if(null!=i&&!1!==i)if("string"!=typeof i&&"number"!=typeof i)if(i instanceof Node||i instanceof Ct)r.push(...Ct._preNodeElems(i,e));else if(Array.isArray(i))r.push(...Ct._appendChecker(e,...i));else for(const t in i){const n=i[t];r.push(...Ct._appendChecker(e,n))}else r.push(i);return r}static append(e,...t){return Ct._preElem(e,"append").append(...Ct._appendChecker("append",...t)),e}append(...e){return Ct.append(this,...e)}static prepend(e,...t){return Ct._preElem(e,"prepend").prepend(...Ct._appendChecker("prepend",...t)),e}prepend(...e){return Ct.prepend(this,...e)}static before(e,...t){return Ct._preElem(e,"before").before(...Ct._appendChecker("before",...t)),e}before(...e){return Ct.before(this,...e)}static after(e,...t){return Ct._preElem(e,"after").after(...Ct._appendChecker("after",...t)),e}after(...e){return Ct.after(this,...e)}static replaceWith(e,...t){return Ct._preElem(e,"replaceWith").replaceWith(...Ct._appendChecker("replaceWith",...t)),e}replaceWith(...e){return Ct.replaceWith(this,...e)}static appendTo(e,t){const r=Ct._preNodeElems(e,"appendTo"),i=Ct._preNodeElems(t,"appendTo");return i.forEach((e,t)=>{r.forEach(r=>e.appendChild(t===i.length-1?r:r.cloneNode(!0)))}),e}appendTo(e){return Ct.appendTo(this,e)}static prependTo(e,t){const r=Ct._preElems(e,"prependTo"),i=Ct._preElems(t,"prependTo");return i.forEach((e,t)=>{r.slice().reverse().forEach(r=>e.prepend(t===i.length-1?r:r.cloneNode(!0)))}),e}prependTo(e){return Ct.prependTo(this,e)}static insertBefore(e,t,r=null){const i=Ct._preNodeElem(e,"insertBefore"),n=Ct._preNodeElem(t,"insertBefore"),s=Ct._preNodeElemWithNull(r,"insertBefore");if(!n.parentNode)throw new Error("The target element has no parent node to insert before.");return n.parentNode.insertBefore(i,s||n),e}insertBefore(e,t){return Ct.insertBefore(this,e,t)}static insertAfter(e,t,r=null){const i=Ct._preNodeElem(e,"insertAfter"),n=Ct._preNodeElem(t,"insertBefore"),s=Ct._preNodeElemWithNull(r,"insertBefore");if(!n.parentNode)throw new Error("The target element has no parent node to insert after.");return n.parentNode.insertBefore(i,s||n.nextSibling),e}insertAfter(e,t){return Ct.insertAfter(this,e,t)}static replaceAll(e,t){const r=Ct._preNodeElems(e,"replaceAll"),i=Ct._preNodeElems(t,"replaceAll");return i.forEach((e,t)=>{const n=e.parentNode;r.forEach(r=>{n&&n.replaceChild(t===i.length-1?r:r.cloneNode(!0),e)})}),e}replaceAll(e){return Ct.replaceAll(this,e)}#G;get size(){return this.#G.length}static _elCheck(e){for(const t of e)if(!(t instanceof Element||t instanceof Window||t instanceof Document||t instanceof Text))throw new Error("[TinyHtml] Invalid Target in constructor.")}add(e){return new Ct([...this.#G,...Ct._selector(e)])}static _selector(e){if(e instanceof Ct)throw new Error("[TinyHtml] You are trying to put a TinyHtml inside another TinyHtml in constructor.");const t=e=>Array.from(new Set(e)),r="string"!=typeof e?e:document.querySelectorAll(e);if(Array.isArray(r))return Ct._elCheck(r),t(r);if(r instanceof NodeList||r instanceof HTMLCollection){const e=[...r];return Ct._elCheck(e),t(e)}{const e=[r];return Ct._elCheck(e),t(e)}}constructor(e){this.#G=Ct._selector(e),this.#ne=Ct.#se}static isWindow(e){return null!=e&&e===e.window}static css(e){const t=Ct._preElem(e,"css");return window.getComputedStyle(t)}css(){return Ct.css(this)}static cssString(e,t){const r=Ct._preElem(e,"cssString");if("string"!=typeof t)throw new TypeError("The prop must be a string.");const i=window.getComputedStyle(r)[t];return"string"==typeof i?i:"number"==typeof i?i.toString():null}cssString(e){return Ct.cssString(this,e)}static cssList(e,t){const r=Ct._preElem(e,"cssList");if(!Array.isArray(t))throw new TypeError("The prop must be an array of strings.");const i=window.getComputedStyle(r),n={};for(const e of t)void 0!==e&&(n[e]=i.getPropertyValue(e));return n}cssList(e){return Ct.cssList(this,e)}static cssFloat(e,t){const r=Ct._preElem(e,"cssFloat");if("string"!=typeof t)throw new TypeError("The prop must be a string.");const i=window.getComputedStyle(r)[t];return parseFloat(i)||0}cssFloat(e){return Ct.cssFloat(this,e)}static cssFloats(e,t){const r=Ct._preElem(e,"cssFloats");if(!Array.isArray(t))throw new TypeError("The prop must be an array of strings.");const i=window.getComputedStyle(r),n={};for(const e of t)n[e]=parseFloat(i[e])||0;return n}cssFloats(e){return Ct.cssFloats(this,e)}static#oe={alignContent:"align-content",alignItems:"align-items",alignSelf:"align-self",animationDelay:"animation-delay",animationDirection:"animation-direction",animationDuration:"animation-duration",animationFillMode:"animation-fill-mode",animationIterationCount:"animation-iteration-count",animationName:"animation-name",animationPlayState:"animation-play-state",animationTimingFunction:"animation-timing-function",backfaceVisibility:"backface-visibility",backgroundAttachment:"background-attachment",backgroundBlendMode:"background-blend-mode",backgroundClip:"background-clip",backgroundColor:"background-color",backgroundImage:"background-image",backgroundOrigin:"background-origin",backgroundPosition:"background-position",backgroundRepeat:"background-repeat",backgroundSize:"background-size",borderBottom:"border-bottom",borderBottomColor:"border-bottom-color",borderBottomLeftRadius:"border-bottom-left-radius",borderBottomRightRadius:"border-bottom-right-radius",borderBottomStyle:"border-bottom-style",borderBottomWidth:"border-bottom-width",borderCollapse:"border-collapse",borderColor:"border-color",borderImage:"border-image",borderImageOutset:"border-image-outset",borderImageRepeat:"border-image-repeat",borderImageSlice:"border-image-slice",borderImageSource:"border-image-source",borderImageWidth:"border-image-width",borderLeft:"border-left",borderLeftColor:"border-left-color",borderLeftStyle:"border-left-style",borderLeftWidth:"border-left-width",borderRadius:"border-radius",borderRight:"border-right",borderRightColor:"border-right-color",borderRightStyle:"border-right-style",borderRightWidth:"border-right-width",borderSpacing:"border-spacing",borderStyle:"border-style",borderTop:"border-top",borderTopColor:"border-top-color",borderTopLeftRadius:"border-top-left-radius",borderTopRightRadius:"border-top-right-radius",borderTopStyle:"border-top-style",borderTopWidth:"border-top-width",borderWidth:"border-width",boxDecorationBreak:"box-decoration-break",boxShadow:"box-shadow",boxSizing:"box-sizing",breakAfter:"break-after",breakBefore:"break-before",breakInside:"break-inside",captionSide:"caption-side",caretColor:"caret-color",clipPath:"clip-path",columnCount:"column-count",columnFill:"column-fill",columnGap:"column-gap",columnRule:"column-rule",columnRuleColor:"column-rule-color",columnRuleStyle:"column-rule-style",columnRuleWidth:"column-rule-width",columnSpan:"column-span",columnWidth:"column-width",counterIncrement:"counter-increment",counterReset:"counter-reset",emptyCells:"empty-cells",flexBasis:"flex-basis",flexDirection:"flex-direction",flexFlow:"flex-flow",flexGrow:"flex-grow",flexShrink:"flex-shrink",flexWrap:"flex-wrap",fontFamily:"font-family",fontFeatureSettings:"font-feature-settings",fontKerning:"font-kerning",fontLanguageOverride:"font-language-override",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontSynthesis:"font-synthesis",fontVariant:"font-variant",fontVariantAlternates:"font-variant-alternates",fontVariantCaps:"font-variant-caps",fontVariantEastAsian:"font-variant-east-asian",fontVariantLigatures:"font-variant-ligatures",fontVariantNumeric:"font-variant-numeric",fontVariantPosition:"font-variant-position",fontWeight:"font-weight",gridArea:"grid-area",gridAutoColumns:"grid-auto-columns",gridAutoFlow:"grid-auto-flow",gridAutoRows:"grid-auto-rows",gridColumn:"grid-column",gridColumnEnd:"grid-column-end",gridColumnGap:"grid-column-gap",gridColumnStart:"grid-column-start",gridGap:"grid-gap",gridRow:"grid-row",gridRowEnd:"grid-row-end",gridRowGap:"grid-row-gap",gridRowStart:"grid-row-start",gridTemplate:"grid-template",gridTemplateAreas:"grid-template-areas",gridTemplateColumns:"grid-template-columns",gridTemplateRows:"grid-template-rows",imageRendering:"image-rendering",justifyContent:"justify-content",letterSpacing:"letter-spacing",lineBreak:"line-break",lineHeight:"line-height",listStyle:"list-style",listStyleImage:"list-style-image",listStylePosition:"list-style-position",listStyleType:"list-style-type",marginBottom:"margin-bottom",marginLeft:"margin-left",marginRight:"margin-right",marginTop:"margin-top",maskClip:"mask-clip",maskComposite:"mask-composite",maskImage:"mask-image",maskMode:"mask-mode",maskOrigin:"mask-origin",maskPosition:"mask-position",maskRepeat:"mask-repeat",maskSize:"mask-size",maskType:"mask-type",maxHeight:"max-height",maxWidth:"max-width",minHeight:"min-height",minWidth:"min-width",mixBlendMode:"mix-blend-mode",objectFit:"object-fit",objectPosition:"object-position",offsetAnchor:"offset-anchor",offsetDistance:"offset-distance",offsetPath:"offset-path",offsetRotate:"offset-rotate",outlineColor:"outline-color",outlineOffset:"outline-offset",outlineStyle:"outline-style",outlineWidth:"outline-width",overflowAnchor:"overflow-anchor",overflowWrap:"overflow-wrap",overflowX:"overflow-x",overflowY:"overflow-y",paddingBottom:"padding-bottom",paddingLeft:"padding-left",paddingRight:"padding-right",paddingTop:"padding-top",pageBreakAfter:"page-break-after",pageBreakBefore:"page-break-before",pageBreakInside:"page-break-inside",perspectiveOrigin:"perspective-origin",placeContent:"place-content",placeItems:"place-items",placeSelf:"place-self",pointerEvents:"pointer-events",rowGap:"row-gap",scrollBehavior:"scroll-behavior",scrollMargin:"scroll-margin",scrollMarginBlock:"scroll-margin-block",scrollMarginBlockEnd:"scroll-margin-block-end",scrollMarginBlockStart:"scroll-margin-block-start",scrollMarginBottom:"scroll-margin-bottom",scrollMarginInline:"scroll-margin-inline",scrollMarginInlineEnd:"scroll-margin-inline-end",scrollMarginInlineStart:"scroll-margin-inline-start",scrollMarginLeft:"scroll-margin-left",scrollMarginRight:"scroll-margin-right",scrollMarginTop:"scroll-margin-top",scrollPadding:"scroll-padding",scrollPaddingBlock:"scroll-padding-block",scrollPaddingBlockEnd:"scroll-padding-block-end",scrollPaddingBlockStart:"scroll-padding-block-start",scrollPaddingBottom:"scroll-padding-bottom",scrollPaddingInline:"scroll-padding-inline",scrollPaddingInlineEnd:"scroll-padding-inline-end",scrollPaddingInlineStart:"scroll-padding-inline-start",scrollPaddingLeft:"scroll-padding-left",scrollPaddingRight:"scroll-padding-right",scrollPaddingTop:"scroll-padding-top",scrollSnapAlign:"scroll-snap-align",scrollSnapStop:"scroll-snap-stop",scrollSnapType:"scroll-snap-type",shapeImageThreshold:"shape-image-threshold",shapeMargin:"shape-margin",shapeOutside:"shape-outside",tabSize:"tab-size",tableLayout:"table-layout",textAlign:"text-align",textAlignLast:"text-align-last",textCombineUpright:"text-combine-upright",textDecoration:"text-decoration",textDecorationColor:"text-decoration-color",textDecorationLine:"text-decoration-line",textDecorationStyle:"text-decoration-style",textIndent:"text-indent",textJustify:"text-justify",textOrientation:"text-orientation",textOverflow:"text-overflow",textShadow:"text-shadow",textTransform:"text-transform",transformBox:"transform-box",transformOrigin:"transform-origin",transformStyle:"transform-style",transitionDelay:"transition-delay",transitionDuration:"transition-duration",transitionProperty:"transition-property",transitionTimingFunction:"transition-timing-function",unicodeBidi:"unicode-bidi",userSelect:"user-select",verticalAlign:"vertical-align",whiteSpace:"white-space",willChange:"will-change",wordBreak:"word-break",wordSpacing:"word-spacing",wordWrap:"word-wrap",writingMode:"writing-mode",zIndex:"z-index",WebkitTransform:"-webkit-transform",WebkitTransition:"-webkit-transition",WebkitBoxShadow:"-webkit-box-shadow",MozBoxShadow:"-moz-box-shadow",MozTransform:"-moz-transform",MozTransition:"-moz-transition",msTransform:"-ms-transform",msTransition:"-ms-transition"};static cssPropAliases=new Proxy(Ct.#oe,{set:(e,t,r)=>(e[t]=r,Ct.cssPropRevAliases[r]=t,!0)});static cssPropRevAliases=Object.fromEntries(Object.entries(Ct.#oe).map(([e,t])=>[t,e]));static toStyleKc(e){return"string"==typeof Ct.cssPropAliases[e]?Ct.cssPropAliases[e]:e}static toStyleCc(e){return"string"==typeof Ct.cssPropRevAliases[e]?Ct.cssPropRevAliases[e]:e}static setStyle(e,t,r=null){return Ct._preHtmlElems(e,"setStyle").forEach(e=>{if("object"==typeof t)for(const[r,i]of Object.entries(t))e.style.setProperty(Ct.toStyleKc(r),"string"==typeof i?i:"number"==typeof i?`${i}px`:String(i));else e.style.setProperty(Ct.toStyleKc(t),r)}),e}setStyle(e,t){return Ct.setStyle(this,e,t)}static getStyle(e,t){return Ct._preHtmlElem(e,"getStyle").style.getPropertyValue(Ct.toStyleKc(t))}getStyle(e){return Ct.getStyle(this,e)}static style(e,{camelCase:t=!1,rawAttr:r=!1}={}){if("boolean"!=typeof t)throw new TypeError('"camelCase" must be a boolean. Received: '+typeof t);if("boolean"!=typeof r)throw new TypeError('"rawAttr" must be a boolean. Received: '+typeof r);const i=Ct._preHtmlElem(e,"style"),n={};if(r){const e=(i.getAttribute("style")||"").split(";");for(const r of e){const[e,i]=r.split(":");if(!e||!i)continue;const s=e.trim(),o=i.trim();n[t?Ct.toStyleCc(s):s]=o}}else{const e=i.style;for(let r=0;r<e.length;r++){const i=e[r],s=e.getPropertyValue(i);n[t?Ct.toStyleCc(i):i]=s}}return n}style(e){return Ct.style(this,e)}static removeStyle(e,t){return Ct._preHtmlElems(e,"removeStyle").forEach(e=>{if(Array.isArray(t))for(const r of t)e.style.removeProperty(Ct.toStyleKc(r));else e.style.removeProperty(Ct.toStyleKc(t))}),e}removeStyle(e){return Ct.removeStyle(this,e)}static toggleStyle(e,t,r,i){return Ct._preHtmlElems(e,"toggleStyle").forEach(e=>{const n=Ct.getStyle(e,t).trim()===Ct.toStyleKc(r)?i:r;Ct.setStyle(e,t,n)}),e}toggleStyle(e,t,r){return Ct.toggleStyle(this,e,t,r)}static clearStyle(e){return Ct._preElems(e,"clearStyle").forEach(e=>e.removeAttribute("style")),e}clearStyle(){return Ct.clearStyle(this)}static focus(e){return Ct._preHtmlElem(e,"focus").focus(),e}focus(){return Ct.focus(this)}static blur(e){return Ct._preHtmlElem(e,"blur").blur(),e}blur(){return Ct.blur(this)}static select(e){const t=Ct._preHtmlElem(e,"select");if(!(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement))throw new Error("Element must be an <input> or <textarea> to use select().");return t.select(),e}select(){return Ct.select(this)}static boolCheck(e){return void 0!==e&&("true"===e||"1"===e||!0===e||"on"===e||"number"==typeof e&&e>0)}static setWinScrollTop(e){if("number"!=typeof e)throw new TypeError("The value must be a number.");Ct.setScrollTop(window,e)}static setWinScrollLeft(e){if("number"!=typeof e)throw new TypeError("The value must be a number.");Ct.setScrollLeft(window,e)}static winScrollTop(){return window.scrollY||document.documentElement.scrollTop}static winScrollLeft(){return window.scrollX||document.documentElement.scrollLeft}static winInnerHeight(){return window.innerHeight||document.documentElement.clientHeight}static winInnerWidth(){return window.innerWidth||document.documentElement.clientWidth}static isPageTop(){return 0===window.scrollY}static isPageBottom(){return window.innerHeight+window.scrollY>=document.body.offsetHeight}static getDimension(e,t,r="content"){const i=Ct._preElemAndWinAndDoc(e,"getDimension");if("string"!=typeof t)throw new TypeError("The type must be a string.");if("string"!=typeof r)throw new TypeError("The extra must be a string.");const n="width"===t?"Width":"Height";if(Ct.isWindow(i))return"margin"===r?i["inner"+n]:i.document.documentElement["client"+n];const s=i;if(9===s.nodeType){const e=s.documentElement;return Math.max(s.body["scroll"+n],e["scroll"+n],s.body["offset"+n],e["offset"+n],e["client"+n])}let o=s.getBoundingClientRect()[t];function a(e){return"width"===t?Ct.cssFloat(s,e+"Left")+Ct.cssFloat(s,e+"Right"):Ct.cssFloat(s,e+"Top")+Ct.cssFloat(s,e+"Bottom")}switch(r){case"content":o-=a("padding"),o-=a("border");break;case"padding":o-=a("border");break;case"border":break;case"margin":o+=a("margin")}return o}getDimension(e,t){return Ct.getDimension(this,e,t)}static setHeight(e,t){const r=Ct._preHtmlElem(e,"setHeight");if("number"!=typeof t&&"string"!=typeof t)throw new TypeError("The value must be a string or number.");return r.style.height="number"==typeof t?`${t}px`:t,e}setHeight(e){return Ct.setHeight(this,e)}set height(e){Ct.setHeight(this,e)}static setWidth(e,t){const r=Ct._preHtmlElem(e,"setWidth");if("number"!=typeof t&&"string"!=typeof t)throw new TypeError("The value must be a string or number.");return r.style.width="number"==typeof t?`${t}px`:t,e}setWidth(e){return Ct.setWidth(this,e)}set width(e){Ct.setWidth(this,e)}static height(e){const t=Ct._preElemAndWinAndDoc(e,"height");return Ct.getDimension(t,"height","content")}get height(){return Ct.height(this)}static width(e){const t=Ct._preElemAndWinAndDoc(e,"width");return Ct.getDimension(t,"width","content")}get width(){return Ct.width(this)}static innerHeight(e){const t=Ct._preElemAndWinAndDoc(e,"innerHeight");return Ct.getDimension(t,"height","padding")}innerHeight(){return Ct.innerHeight(this)}static innerWidth(e){const t=Ct._preElemAndWinAndDoc(e,"innerWidth");return Ct.getDimension(t,"width","padding")}innerWidth(){return Ct.innerWidth(this)}static outerHeight(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=Ct._preElemAndWinAndDoc(e,"outerHeight");return Ct.getDimension(r,"height",t?"margin":"border")}outerHeight(e){return Ct.outerHeight(this,e)}static outerWidth(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=Ct._preElemAndWinAndDoc(e,"outerWidth");return Ct.getDimension(r,"width",t?"margin":"border")}outerWidth(e){return Ct.outerWidth(this,e)}#ne="";get mainDisplay(){return this.#ne}set mainDisplay(e){if("string"!=typeof e)throw new TypeError("mainDisplay must be a string.");this.#ne=e}static#se="block";static get defaultDisplay(){return Ct.#se}static set defaultDisplay(e){if("string"!=typeof e)throw new TypeError("defaultDisplay must be a string.");Ct.#se=e}static getAnimateData(e,t){let r=St.get(e);return r||(r={},St.set(e,r)),r[t]}static setAnimateData(e,t,r){if(!(e instanceof HTMLElement))throw new TypeError("setAnimateData: el must be an HTMLElement.");if("string"!=typeof t)throw new TypeError("setAnimateData: where must be a string.");if("string"!=typeof r&&"number"!=typeof r)throw new TypeError("setAnimateData: value must be a string or number.");let i=St.get(e);i||(i={},St.set(e,i)),i[t]=r}static#ae=!0;static get cancelOldStyleFx(){return Ct.#ae}static set cancelOldStyleFx(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value.");Ct.#ae=e}static#le={slow:{duration:600,easing:"ease"},fast:{duration:200,easing:"ease-out"},_default:{duration:400,easing:"linear"}};static get styleFxSpeeds(){const e={};for(const t in Ct.#le){const r=Ct.#le[t];e[t]="object"==typeof r?{...r}:r}return e}static set styleFxSpeeds(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleFxSpeeds must be an object.");for(const[t,r]of Object.entries(e))if("number"!=typeof r&&"object"!=typeof r)throw new TypeError(`styleFxSpeeds["${t}"] must be a number or KeyframeAnimationOptions.`);Ct.#le={};for(const[t,r]of Object.entries(e))Ct.setStyleFxSpeed(t,r)}static getStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=Ct.#le[e];return"object"==typeof t?{...t}:t}static setStyleFxSpeed(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("number"!=typeof t&&"object"!=typeof t)throw new TypeError("styleFxSpeed must be a number or KeyframeAnimationOptions");Ct.#le[e]="object"==typeof t?{...t}:t}static deleteStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete Ct.#le[e]}static hasStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(Ct.#le,e)}static#ue=["Top","Right","Bottom","Left"];static#he={slideDown:Ct.genStyleFx("show"),slideUp:Ct.genStyleFx("hide"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}};static get styleEffects(){return JSON.parse(JSON.stringify(Ct.#he))}static set styleEffects(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleEffects must be an object");for(const t in e)for(const[r,i]of Object.entries(e[t]))if(!("string"==typeof i||Array.isArray(i)&&i.every(e=>"string"==typeof e||"number"==typeof e)))throw new TypeError(`Invalid styleEffect["${r}"]`);Ct.#he={};for(const t in e)Ct.setStyleEffect(t,e[t])}static getStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=Ct.#he[e];return t?JSON.parse(JSON.stringify(t)):void 0}static setStyleEffect(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("styleEffect must be an object");const r={};for(const[e,i]of Object.entries(t))if("string"==typeof i)r[e]=i;else{if(!Array.isArray(i)||!i.every(e=>"string"==typeof e||"number"==typeof e))throw new TypeError(`Invalid styleEffect["${e}"]`);r[e]=[...i]}Ct.#he[e]=r}static deleteStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete Ct.#he[e]}static hasStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(Ct.#he,e)}static#de={slideDown:"slideUp",slideUp:"slideDown",fadeIn:"fadeOut",fadeOut:"fadeIn",fadeTo:"fadeIn"};static get styleEffectInverse(){return{...Ct.#de}}static set styleEffectInverse(e){if("object"!=typeof e||null===e)throw new TypeError("styleEffectInverse must be an object.");for(const[t,r]of Object.entries(e))if("string"!=typeof r)throw new TypeError(`styleEffectInverse["${t}"] must be a string.`);Ct.#de={};for(const[t,r]of Object.entries(e))Ct.setStyleEffectInverse(t,r)}static getStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Ct.#de[e]||null}static setStyleEffectInverse(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("string"!=typeof t)throw new TypeError(`styleEffectInverse["${e}"] must be a string.`);Ct.#de[e]=t}static deleteStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete Ct.#de[e]}static hasStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(Ct.#de,e)}static#ce={slideDown:e=>e.height[0]===e.height[1]&&(!e.width||e.width[0]===e.width[1]),slideUp:e=>e.height[0]===e.height[1]&&(!e.width||e.width[0]===e.width[1]),fadeIn:e=>Number(e.opacity[0])===Number(e.opacity[1]),fadeOut:e=>Number(e.opacity[0])===Number(e.opacity[1])};static get styleEffectsRd(){return{...Ct.#ce}}static set styleEffectsRd(e){if("object"!=typeof e||null===e)throw new TypeError("styleEffectsRd must be an object.");for(const[t,r]of Object.entries(e))if("function"!=typeof r)throw new TypeError(`styleEffectsRd["${t}"] must be a function.`);Ct.#ce={};for(const[t,r]of Object.entries(e))Ct.setStyleEffectRd(t,r)}static getStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Ct.#ce[e]||null}static setStyleEffectRd(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("function"!=typeof t)throw new TypeError(`styleEffectsRd["${e}"] must be a function.`);Ct.#ce[e]=t}static deleteStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete Ct.#ce[e]}static hasStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(Ct.#ce,e)}static#me={show:(e,t,r,i)=>{if("height"===r||"width"===r){const n=Ct.getAnimateData(e,`orig${r}`)||e.scrollHeight+"px";Ct.setAnimateData(e,`orig${r}`,n);const s=i[r];t[r]=[s,n]}else if(r.startsWith("margin")||r.startsWith("padding")){const n=Ct.getAnimateData(e,r)||i[r];Ct.setAnimateData(e,r,n),t[r]=["0px",n]}else if("opacity"===r){const e=i.opacity;t[r]=[e,1]}else{const n=Ct.getAnimateData(e,r)||i[r];Ct.setAnimateData(e,r,n),t[r]=[n,i[r]||1]}},hide:(e,t,r,i)=>{if("height"===r||"width"===r){const n=Ct.getAnimateData(e,`orig${r}`)||i[r];Ct.setAnimateData(e,`orig${r}`,n);const s=i[r];t[r]=[s,0]}else if(r.startsWith("margin")||r.startsWith("padding")){const n=Ct.getAnimateData(e,r)||i[r];Ct.setAnimateData(e,r,n),t[r]=[i[r],"0px"]}else if("opacity"===r){const e=i.opacity;t[r]=[e,0]}else{const n=Ct.getAnimateData(e,r)||i[r];Ct.setAnimateData(e,r,n),t[r]=[n,0]}}};static get styleEffectsProps(){return{...Ct.#me}}static set styleEffectsProps(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleEffectsProps must be an object");for(const[t,r]of Object.entries(e))if("function"!=typeof r)throw new TypeError(`styleEffectsProps["${t}"] must be a function`);Ct.#me={};for(const[t,r]of Object.entries(e))Ct.setStyleEffectProp(t,r)}static getStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Ct.#me[e]||null}static setStyleEffectProp(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("function"!=typeof t)throw new TypeError(`styleEffectsProps["${e}"] must be a function`);Ct.#me[e]=t}static deleteStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete Ct.#me[e]}static hasStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(Ct.#me,e)}static genStyleFx(e,t=!1){if("string"!=typeof e)throw new TypeError("genStyleFx: type must be a string.");if("boolean"!=typeof t)throw new TypeError("genStyleFx: includeWidth must be a boolean.");let r,i=0;const n={height:e},s=t?1:0;for(;i<4;i+=2-s)r=Ct.#ue[i],n["margin"+r]=e,n["padding"+r]=e;return t&&(n.opacity=e,n.width=e),n}static applyStyleFx(e,t,r,i){if("string"!=typeof t)throw new TypeError("applyStyleFx: id must be a string.");if("object"!=typeof r||null===r)throw new TypeError("applyStyleFx: props must be a non-null object.");if(void 0!==i&&"number"!=typeof i&&"string"!=typeof i&&("object"!=typeof i||null===i))throw new TypeError("applyStyleFx: ops must be a number, string, KeyframeAnimationOptions, or undefined.");const n=new Map;return Ct._preHtmlElems(e,"applyStyleFx").forEach(s=>{const o={};for(const[e,t]of Object.entries(r))if("string"==typeof t&&this.#me[t]){const r=getComputedStyle(s);this.#me[t](s,o,e,r)}else{if("object"!=typeof t)throw new TypeError(`applyStyleFx: invalid action for prop "${e}". Must be string or array.`);o[e]=t}if("function"==typeof Ct.#ce[t]&&Ct.#ce[t](o))return void n.set(s,null);const a=[],l=o[Object.keys(o)[0]].length;for(let e=0;e<l;e++){const t={};for(const r in o)t[r]=o[r][e];a.push(t)}n.set(s,Ct.animate(e,a,i,t)[0])}),n}applyStyleFx(e,t,r){return Ct.applyStyleFx(this,e,t,r)}static getCurrentAnimationId(e){if(!(e instanceof HTMLElement))throw new TypeError("Expected an HTMLElement.");return xt.get(e)?.id??void 0}static animate(e,t,r=Ct.#le._default,i=null,n=Ct.#ae){const s="string"==typeof r?Ct.#le[r]??void 0:"number"!=typeof r?{...r}:r;"object"==typeof s&&void 0===s.fill&&(s.fill="forwards");const o=[];return Ct._preHtmlElems(e,"animate").forEach(e=>{if(n){const t=xt.get(e);t&&t.animation.cancel()}const r=e.animate(t,s);o.push(r),xt.set(e,{animation:r,id:i??""}),r.addEventListener("finish",()=>{xt.get(e)?.animation===r&&xt.delete(e)})}),o}animate(e,t,r,i){return Ct.animate(this,e,t,r,i)}static stop(e){const t=[];return Ct._preHtmlElems(e,"stop").forEach(e=>{const r=xt.get(e);r?(r.animation.cancel(),xt.delete(e),t.push(!0)):t.push(!1)}),t}stop(){return Ct.stop(this)}static slideDown(e,t){return Ct.applyStyleFx(e,"slideDown",this.#he.slideDown,t??{duration:500,easing:"ease-out"})}slideDown(e){return Ct.slideDown(this,e)}static slideUp(e,t){return Ct.applyStyleFx(e,"slideUp",this.#he.slideUp,t??{duration:500,easing:"ease-out"})}slideUp(e){return Ct.slideUp(this,e)}static slideToggle(e,t){const r=Ct._preHtmlElem(e,"slideToggle"),i=getComputedStyle(r),n=Ct.getCurrentAnimationId(r),s="none"===i.display||0===r.offsetHeight;return("string"==typeof n?"slideUp"===n:s)?Ct.slideDown(e,t):Ct.slideUp(e,t)}slideToggle(e){return Ct.slideToggle(this,e)}static fadeIn(e,t){return Ct.applyStyleFx(e,"fadeIn",this.#he.fadeIn,t)}fadeIn(e){return Ct.fadeIn(this,e)}static fadeOut(e,t){return Ct.applyStyleFx(e,"fadeOut",this.#he.fadeOut,t)}fadeOut(e){return Ct.fadeOut(this,e)}static fadeToggle(e,t){const r=Ct._preHtmlElem(e,"fadeToggle"),i=getComputedStyle(r),n=Ct.getCurrentAnimationId(r),s="0"===i.opacity||null===r.offsetParent;return("string"==typeof n?"fadeOut"===n:s)?Ct.fadeIn(e,t):Ct.fadeOut(e,t)}fadeToggle(e){return Ct.fadeToggle(this,e)}static fadeTo(e,t,r,i=Ct.#se){if("number"!=typeof t||isNaN(t)||t<0||t>1)throw new TypeError("fadeTo: opacity must be a number between 0 and 1.");if(void 0!==r&&"number"!=typeof r&&"string"!=typeof r&&("object"!=typeof r||null===r))throw new TypeError("fadeTo: ops must be a number, string, KeyframeAnimationOptions, or undefined.");const n=new Map;return Ct._preHtmlElems(e,"fadeTo").forEach(s=>{const o=getComputedStyle(s);if(!(e instanceof Element&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length))){const e=Ct.getAnimateData(s,"origdisplay");s.style.display="string"==typeof e?e:i}const a=[o.opacity,t].map(e=>({opacity:e}));n.set(s,Ct.animate(s,a,r,"fadeTo")[0])}),n}fadeTo(e,t,r=this.#ne){return Ct.fadeTo(this,e,t,r)}static offset(e){const t=Ct._preElem(e,"offset").getBoundingClientRect(),r=window.scrollY||document.documentElement.scrollTop,i=window.scrollX||document.documentElement.scrollLeft;return{top:t.top+r,left:t.left+i}}offset(){return Ct.offset(this)}static position(e){const t=Ct._preHtmlElem(e,"position");let r,i,n={top:0,left:0};if("fixed"===window.getComputedStyle(t).position)i=t.getBoundingClientRect();else{i=Ct.offset(t),r=t.offsetParent||document.documentElement;const{position:e}=window.getComputedStyle(r);for(;r instanceof HTMLElement&&(r===document.body||r===document.documentElement)&&"static"===e;)r=r.parentNode;if(r instanceof HTMLElement&&r!==t&&1===r.nodeType){const{borderTopWidth:e,borderLeftWidth:t}=Ct.cssFloats(r,["borderTopWidth","borderLeftWidth"]);n=Ct.offset(r),n.top+=e,n.left+=t}}return{top:i.top-n.top-Ct.cssFloat(t,"marginTop"),left:i.left-n.left-Ct.cssFloat(t,"marginLeft")}}position(){return Ct.position(this)}static offsetParent(e){let t=Ct._preHtmlElem(e,"offsetParent").offsetParent;for(;t instanceof HTMLElement&&"static"===window.getComputedStyle(t).position;)t=t.offsetParent;return t instanceof HTMLElement?t:document.documentElement}offsetParent(){return Ct.offsetParent(this)}static scrollTop(e){const t=Ct._preElemAndWindow(e,"scrollTop");return Ct.isWindow(t)?t.pageYOffset:9===t.nodeType?t.defaultView.pageYOffset:t.scrollTop}scrollTop(){return Ct.scrollTop(this)}static scrollLeft(e){const t=Ct._preElemAndWindow(e,"scrollLeft");return Ct.isWindow(t)?t.pageXOffset:9===t.nodeType?t.defaultView.pageXOffset:t.scrollLeft}scrollLeft(){return Ct.scrollLeft(this)}static easings={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>e*(2-e),easeInOutQuad:e=>e<.5?2*e*e:(4-2*e)*e-1,easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1};static scrollToXY(e,{targetX:t,targetY:r,duration:i,easing:n,onAnimation:s}={}){if(void 0!==t&&"number"!=typeof t)throw new TypeError("`targetX` must be a number if provided.");if(void 0!==r&&"number"!=typeof r)throw new TypeError("`targetY` must be a number if provided.");if(void 0!==i&&"number"!=typeof i)throw new TypeError("`duration` must be a number if provided.");if(void 0!==n&&"string"!=typeof n)throw new TypeError("`easing` must be a string if provided.");if(void 0!==n&&"function"!=typeof Ct.easings[n])throw new TypeError(`Unknown easing function: "${n}".`);if(void 0!==s&&"function"!=typeof s)throw new TypeError("`onAnimation` must be a function if provided.");const o=(e,t,r,i)=>{if(e instanceof Window)window.scrollTo(t,r);else if(9===e.nodeType)e.defaultView.scrollTo(t,r);else{const i=e instanceof Window?window.scrollX:e.scrollLeft,n=e instanceof Window?window.scrollY:e.scrollTop;i!==t&&(e.scrollLeft=t),n!==r&&(e.scrollTop=r)}"function"==typeof s&&s({x:t,y:r,isComplete:i>=1,time:i})};return Ct._preElemsAndWindow(e,"scrollToXY").forEach(e=>{const s=e instanceof Window?window.scrollX:e.scrollLeft,a=e instanceof Window?window.scrollY:e.scrollTop,l=t??s,u=r??a,h=l-s,d=u-a,c="string"==typeof n&&Ct.easings[n]||null;if("number"!=typeof i||"function"!=typeof c)return o(e,l,u,1);const m=performance.now(),p=i??0;requestAnimationFrame(function t(r){if("function"!=typeof c)return;const i=Math.min(1,(r-m)/p),n=c(i);o(e,s+h*n,a+d*n,i),i<1&&requestAnimationFrame(t)})}),e}scrollToXY({targetX:e,targetY:t,duration:r,easing:i,onAnimation:n}={}){return Ct.scrollToXY(this,{targetX:e,targetY:t,duration:r,easing:i,onAnimation:n})}static setScrollTop(e,t){if("number"!=typeof t)throw new TypeError("ScrollTop value must be a number.");return Ct.scrollToXY(e,{targetY:t})}setScrollTop(e){return Ct.setScrollTop(this,e)}static setScrollLeft(e,t){if("number"!=typeof t)throw new TypeError("ScrollLeft value must be a number.");return Ct.scrollToXY(e,{targetX:t})}setScrollLeft(e){return Ct.setScrollLeft(this,e)}static borderWidth(e){const t=Ct._preElem(e,"borderWidth"),{borderLeftWidth:r,borderRightWidth:i,borderTopWidth:n,borderBottomWidth:s}=Ct.cssFloats(t,["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"]);return{x:r+i,y:n+s,left:r,right:i,top:n,bottom:s}}borderWidth(){return Ct.borderWidth(this)}static border(e){const t=Ct._preElem(e,"border"),{borderLeft:r,borderRight:i,borderTop:n,borderBottom:s}=Ct.cssFloats(t,["borderLeft","borderRight","borderTop","borderBottom"]);return{x:r+i,y:n+s,left:r,right:i,top:n,bottom:s}}border(){return Ct.border(this)}static margin(e){const t=Ct._preElem(e,"margin"),{marginLeft:r,marginRight:i,marginTop:n,marginBottom:s}=Ct.cssFloats(t,["marginLeft","marginRight","marginTop","marginBottom"]);return{x:r+i,y:n+s,left:r,right:i,top:n,bottom:s}}margin(){return Ct.margin(this)}static padding(e){const t=Ct._preElem(e,"padding"),{paddingLeft:r,paddingRight:i,paddingTop:n,paddingBottom:s}=Ct.cssFloats(t,["paddingLeft","paddingRight","paddingTop","paddingBottom"]);return{x:r+i,y:n+s,left:r,right:i,top:n,bottom:s}}padding(){return Ct.padding(this)}static#pe=!1;static get classCanWhitespace(){return this.#pe}static set classCanWhitespace(e){if("boolean"!=typeof e)throw new TypeError("classCanWhitespace must be a boolean");this.#pe=e}static addClass(e,...t){const r=[];for(const e of t)if(Ct.#pe){const t=e.split(" ");for(const e of t)r.push(e)}else r.push(e);return Ct._preElems(e,"addClass").forEach(e=>e.classList.add(...r)),e}addClass(...e){return Ct.addClass(this,...e)}static removeClass(e,...t){const r=[];for(const e of t)if(Ct.#pe){const t=e.split(" ");for(const e of t)r.push(e)}else r.push(e);return Ct._preElems(e,"removeClass").forEach(e=>e.classList.remove(...r)),e}removeClass(...e){return Ct.removeClass(this,...e)}static replaceClass(e,t,r){if("string"!=typeof t)throw new TypeError('The "token" parameter must be a string.');if("string"!=typeof r)throw new TypeError('The "newToken" parameter must be a string.');const i=[];return Ct._preElems(e,"replaceClass").forEach(e=>i.push(e.classList.replace(t,r))),i}replaceClass(e,t){return Ct.replaceClass(this,e,t)[0]}static classItem(e,t){const r=Ct._preElem(e,"classItem");if("number"!=typeof t)throw new TypeError('The "index" parameter must be a number.');return r.classList.item(t)}classItem(e){return Ct.classItem(this,e)}static toggleClass(e,t,r){if("string"!=typeof t)throw new TypeError('The "token" parameter must be a string.');if(void 0!==r&&"boolean"!=typeof r)throw new TypeError('The "force" parameter must be a boolean.');const i=[];return Ct._preElems(e,"toggleClass").forEach(e=>i.push(e.classList.toggle(t,r))),i}toggleClass(e,t){return Ct.toggleClass(this,e,t)[0]}static hasClass(e,t){const r=Ct._preElem(e,"hasClass");if("string"!=typeof t)throw new TypeError('The "token" parameter must be a string.');return r.classList.contains(t)}hasClass(e){return Ct.hasClass(this,e)}static classLength(e){return Ct._preElem(e,"classLength").classList.length}classLength(){return Ct.classLength(this)}static classList(e){return Ct._preElem(e,"classList").classList.values().toArray()}classList(){return Ct.classList(this)}static tagName(e){return Ct._preElem(e,"tagName").tagName}tagName(){return Ct.tagName(this)}static id(e){return Ct._preElem(e,"id").id}get id(){return Ct.id(this)}set id(e){Ct.setAttr(this,"id",e)}static toBigInt(e){const t=Ct._preElem(e,"toBigInt"),r=t.textContent?.trim();let i=null;try{i=BigInt(r??"")}catch{i=null}return i}toBigInt(){return Ct.toBigInt(this)}static setBigInt(e,t){if("bigint"!=typeof t)throw new Error("Value is not a valid BigInt.");const r=t.toString();return Ct._preElems(e,"setBigInt").forEach(e=>e.textContent=r),e}setBigInt(e){return Ct.setBigInt(this,e)}static toDate(e){const t=Ct._preElem(e,"toDate"),r=t.textContent?.trim();if(!r)return null;const i=new Date(r);return Number.isNaN(i.getTime())?null:i}toDate(){return Ct.toDate(this)}static setDate(e,t){if(!(t instanceof Date)||Number.isNaN(t.getTime()))throw new Error("Value is not a valid Date.");const r=t.toISOString();return Ct._preElems(e,"setDate").forEach(e=>e.textContent=r),e}setDate(e){return Ct.setDate(this,e)}static toJson(e){const t=Ct._preElem(e,"toJson"),r=t.textContent?.trim();if(!r)return null;try{return JSON.parse(r)}catch{return null}}toJson(){return Ct.toJson(this)}static setJson(e,t,r,i){const n=JSON.stringify(t,r,i);return Ct._preElems(e,"setJson").forEach(e=>e.textContent=n),e}setJson(e,t,r){return Ct.setJson(this,e,t,r)}static toNumber(e){const t=Ct._preElem(e,"toNumber");return"string"==typeof t.textContent?parseFloat(t.textContent.trim()):null}toNumber(){return Ct.toNumber(this)}static setNumber(e,t){if("number"!=typeof t)throw new Error("Value is not a valid number.");const r=t.toString();return Ct._preElems(e,"setNumber").forEach(e=>e.textContent=r),e}setNumber(e){return Ct.setNumber(this,e)}static toBoolean(e){const t=Ct._preElem(e,"toBoolean"),r=t.textContent?.trim();return null==r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}toBoolean(){return Ct.toBoolean(this)}static setBoolean(e,t){if("boolean"!=typeof t)throw new Error("Value is not a valid boolean.");const r=t.toString();return Ct._preElems(e,"setBoolean").forEach(e=>e.textContent=r),e}setBoolean(e){return Ct.setBoolean(this,e)}static toString(e){const t=Ct._preElem(e,"toString");return"string"==typeof t.textContent?t.textContent:null}toString(){return Ct.toString(this)}static setString(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return Ct._preElems(e,"setString").forEach(e=>e.textContent=t),e}setString(e){return Ct.setString(this,e)}static text(e){return Ct._preElem(e,"text").textContent}text(){return Ct.text(this)}static setText(e,t){const r=null!=t?String(t):"";return Ct._preElems(e,"setText").forEach(e=>e.textContent=r),e}setText(e){return Ct.setText(this,e)}static empty(e){return Ct._preElems(e,"empty").forEach(e=>e.textContent=""),e}empty(){return Ct.empty(this)}static html(e,t){return Ct._preElem(e,"html").getHTML(t)}html(e){return Ct.html(this,e)}static setHtml(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return Ct._preElems(e,"setHtml").forEach(e=>e.innerHTML=t),e}setHtml(e){return Ct.setHtml(this,e)}static _valHooks={option:{get:e=>{const t=e.getAttribute("value");return null!=t?t:e.textContent}},select:{get:e=>{const t=e.options,r=e.selectedIndex,i="select-one"===e.type,n=i?r+1:t.length,s=[];let o=r<0?n:i?r:0;for(;o<n;o++){const e=t[o],n=e.parentNode;if((e.selected||o===r)&&!e.disabled&&(!n||!n.disabled||"OPTGROUP"!==n.tagName)){const t=Ct._valHooks.option.get(e);if(i)return t;s.push(t)}}return s},set:(e,t)=>{const r=e.options,i=Array.isArray(t)?t.map(String):[String(t)];let n=!1;for(let e=0;e<r.length;e++){const t=r[e],s=Ct._valHooks.option.get(t);"string"==typeof s&&(t.selected=i.includes(s))&&(n=!0)}return n||(e.selectedIndex=-1),i}},radio:{get:e=>e.checked?"on":"off",set(e,t){if("boolean"==typeof t){const r=e.closest("label");return t&&r&&r.querySelectorAll('input[type="radio"]').forEach(t=>{t instanceof HTMLInputElement&&t!==e&&(t.checked=!1)}),e.checked=t,t}}},checkbox:{get:e=>e.checked?"on":"off",set(e,t){if("boolean"==typeof t)return e.checked=t,t}}};static setVal(e,t){return Ct._preInputElems(e,"setVal").forEach(e=>{if(1!==e.nodeType)return;let r="function"==typeof t?t(e,Ct.val(e)):t;null==r?r="":"number"==typeof r?r=String(r):Array.isArray(r)&&(r=((e,t)=>{const r=[];for(let i=0;i<e.length;i++)r.push(t(e[i]));return r})(r,e=>null==e?"":String(e)));const i=Ct._valHooks[e.type]||Ct._valHooks[e.nodeName.toLowerCase()];if(!i||"function"!=typeof i.set||void 0===i.set(e,r,"value")){if("string"!=typeof r&&"boolean"!=typeof r)throw new Error(`Invalid setValue "${typeof r}" value.`);"string"==typeof r&&(e.value=r)}}),e}setVal(e){return Ct.setVal(this,e)}static _valTypes={string:e=>e.value,date:e=>e.valueAsDate,number:e=>e.valueAsNumber};static _getValByType(e,t,r){if("string"!=typeof t)throw new TypeError('The "type" must be a string.');if("string"!=typeof r)throw new TypeError('The "where" must be a string.');if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error(`Provided element is not an HTMLInputElement in ${r}().`);if("function"!=typeof Ct._valTypes[t])throw new Error(`No handler found for type "${t}" in ${r}().`);return Ct._valTypes[t](e)}static _val(e,t,r){const i=Ct._preInputElem(e,t),n=Ct._valHooks[i.type]||Ct._valHooks[i.nodeName.toLowerCase()];if(n&&"function"==typeof n.get){const e=n.get(i,"value",r);if(void 0!==e)return"string"==typeof e?e.replace(/\r/g,""):e}return Ct._getValByType(i,r,t)}_val(e,t){return Ct._val(this,e,t)}static val(e){return Ct._val(e,"val","string")}val(){return Ct.val(this)}static valTxt(e){const t=Ct._val(e,"valTxt","string");if("string"!=typeof t&&null!==t)throw new Error("Value is not a valid string.");return null==t?"":"string"==typeof t?t.replace(/\r/g,""):t}valTxt(){return Ct.valTxt(this)}static _valArr(e,t,r){const i=Ct._val(e,t,r);if(!Array.isArray(i))throw new Error(`Value expected an array but got ${typeof i}.`);return i}_valArr(e,t){return Ct._valArr(this,e,t)}static valArr(e){return Ct._valArr(e,"valArr","string")}valArr(){return Ct.valArr(this)}static valNb(e){if(!(Ct._preInputElem(e,"valNb")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=Ct._val(e,"valNb","number");if(Number.isNaN(t))throw new Error("Value is not a valid number.");return t}valNb(){return Ct.valNb(this)}static valDate(e){if(!(Ct._preInputElem(e,"valDate")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=Ct._val(e,"valDate","date");if(!(t instanceof Date))throw new Error("Value is not a valid date.");return t}valDate(){return Ct.valDate(this)}static valBool(e){const t=Ct._preInputElem(e,"valBool");if(!(t instanceof HTMLInputElement))throw new Error("Element must be an input element.");return"on"===Ct.val(t)}valBool(){return Ct.valBool(this)}static listenForPaste(e,{onFilePaste:t,onTextPaste:r}={}){if(void 0!==t&&"function"!=typeof t)throw new TypeError("onFilePaste must be a function.");if(void 0!==r&&"function"!=typeof r)throw new TypeError("onTextPaste must be a function.");const i=e=>{if(!(e instanceof ClipboardEvent))return;const i=e.clipboardData?.items||[];for(const e of i)if("file"===e.kind){if("function"==typeof t){const r=e.getAsFile();r&&t(e,r)}}else"string"===e.kind&&"function"==typeof r&&e.getAsString(t=>r(e,t))};return Ct._preElemsWithDoc(e,"listenForPaste").forEach(e=>Ct.on(e,"paste",i)),i}listenForPaste({onFilePaste:e,onTextPaste:t}={}){return Ct.listenForPaste(this,{onFilePaste:e,onTextPaste:t})}static hasEventListener(e,t){const r=Ct._preEventTargetElem(e,"hasEventListener");if(!Et.has(r))return!1;const i=Et.get(r);return!!(i&&Array.isArray(i[t])&&i[t].length>0)}hasEventListener(e){return Ct.hasEventListener(this,e)}static hasExactEventListener(e,t,r){const i=Ct._preEventTargetElem(e,"hasExactEventListener");if("function"!=typeof r)throw new TypeError('The "handler" must be a function.');if(!Et.has(i))return!1;const n=Et.get(i);return!(!n||!Array.isArray(n[t]))&&n[t].some(e=>e.handler===r)}hasExactEventListener(e,t){return Ct.hasExactEventListener(this,e,t)}static hover(e,t,r,i){return Ct.on(e,"mouseenter",t,i),Ct.on(e,"mouseleave",r||t,i),e}hover(e,t,r){return Ct.hover(this,e,t,r)}static on(e,t,r,i){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const n of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof n)throw new TypeError("The event name must be a string.");Ct._preEventTargetElems(e,"on").forEach(e=>{e.addEventListener(n,r,i),Et.has(e)||Et.set(e,{});const t=Et.get(e);t&&(Array.isArray(t[n])||(t[n]=[]),t[n].push({handler:r,options:i}))})}return e}on(e,t,r){return Ct.on(this,e,t,r)}static once(e,t,r,i={}){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const n of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof n)throw new TypeError("The event name must be a string.");Ct._preEventTargetElems(e,"once").forEach(e=>{const t=i=>{Ct.off(e,n,t),"function"==typeof r&&r(i)};Ct.on(e,n,t,"boolean"==typeof i?i:{...i,once:!0})})}return e}once(e,t,r={}){return Ct.once(this,e,t,r)}static off(e,t,r,i){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const n of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof n)throw new TypeError("The event name must be a string.");Ct._preEventTargetElems(e,"off").forEach(e=>{e.removeEventListener(n,r,i);const t=Et.get(e);t&&t[n]&&(t[n]=t[n].filter(e=>e.handler!==r),0===t[n].length&&delete t[n])})}return e}off(e,t,r){return Ct.off(this,e,t,r)}static offAll(e,t){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const r of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof r)throw new TypeError("The event name must be a string.");Ct._preEventTargetElems(e,"offAll").forEach(e=>{const t=Et.get(e);if(t&&t[r]){for(const i of t[r])e.removeEventListener(r,i.handler,i.options);delete t[r]}})}return e}offAll(e){return Ct.offAll(this,e)}static offAllTypes(e,t=null){if(null!==t&&"function"!=typeof t)throw new TypeError('The "filterFn" must be a function.');return Ct._preEventTargetElems(e,"offAllTypes").forEach(e=>{const r=Et.get(e);if(r){for(const i in r)for(const n of r[i])("function"!=typeof t||t(n.handler,i))&&e.removeEventListener(i,n.handler,n.options);Et.delete(e)}}),e}offAllTypes(e=null){return Ct.offAllTypes(this,e)}static trigger(e,t,r={}){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const i of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof i)throw new TypeError("The event name must be a string.");Ct._preEventTargetElems(e,"trigger").forEach(e=>{const t=r instanceof Event||r instanceof CustomEvent?r:new CustomEvent(i,{bubbles:!0,cancelable:!0,detail:r});e.dispatchEvent(t)})}return e}trigger(e,t={}){return Ct.trigger(this,e,t)}static#fe={for:"htmlFor",class:"className"};static propFix=new Proxy(Ct.#fe,{set:(e,t,r)=>(e[t]=r,Ct.attrFix[r]=t,!0)});static attrFix=Object.fromEntries(Object.entries(Ct.#fe).map(([e,t])=>[t,e]));static getPropName(e){return"string"==typeof Ct.propFix[e]?Ct.propFix[e]:e}static getAttrName(e){return"string"==typeof Ct.attrFix[e]?Ct.attrFix[e]:e}static attrBigInt(e,t){const r=Ct._preElem(e,"attrBigInt").getAttribute(Ct.getAttrName(t));if(null==r)return null;try{return BigInt(r)}catch{return null}}attrBigInt(e){return Ct.attrBigInt(this,e)}static setAttrBigInt(e,t,r){if("bigint"!=typeof r)throw new Error("Value is not a valid BigInt.");return Ct.setAttr(e,t,r.toString())}setAttrBigInt(e,t){return Ct.setAttrBigInt(this,e,t)}static attrDate(e,t){const r=Ct._preElem(e,"attrDate").getAttribute(Ct.getAttrName(t));if(!r)return null;const i=new Date(r);return Number.isNaN(i.getTime())?null:i}attrDate(e){return Ct.attrDate(this,e)}static setAttrDate(e,t,r){if(!(r instanceof Date)||Number.isNaN(r.getTime()))throw new Error("Value is not a valid Date.");return Ct.setAttr(e,t,r.toISOString())}setAttrDate(e,t){return Ct.setAttrDate(this,e,t)}static attrJson(e,t){const r=Ct._preElem(e,"attrJson").getAttribute(Ct.getAttrName(t));if(!r)return null;try{return JSON.parse(r)}catch{return null}}attrJson(e){return Ct.attrJson(this,e)}static setAttrJson(e,t,r,i,n){const s=JSON.stringify(r,i,n);return Ct.setAttr(e,t,s)}setAttrJson(e,t,r,i){return Ct.setAttrJson(this,e,t,r,i)}static attrNumber(e,t){const r=Ct._preElem(e,"attrNumber").getAttribute(Ct.getAttrName(t));return null!=r?parseFloat(r):null}attrNumber(e){return Ct.attrNumber(this,e)}static setAttrNumber(e,t,r){if("number"!=typeof r)throw new Error("Value is not a valid number.");return Ct.setAttr(e,t,r.toString())}setAttrNumber(e,t){return Ct.setAttrNumber(this,e,t)}static attrBoolean(e,t){const r=Ct._preElem(e,"attrBoolean").getAttribute(Ct.getAttrName(t));return null===r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}attrBoolean(e){return Ct.attrBoolean(this,e)}static setAttrBoolean(e,t,r){if("boolean"!=typeof r)throw new Error("Value is not a valid boolean.");return Ct.setAttr(e,t,r.toString())}setAttrBoolean(e,t){return Ct.setAttrBoolean(this,e,t)}static attrString(e,t){const r=Ct._preElem(e,"attrString").getAttribute(Ct.getAttrName(t));return"string"==typeof r?r:null}attrString(e){return Ct.attrString(this,e)}static setAttrString(e,t,r){if("string"!=typeof r)throw new Error("Value is not a valid string.");return Ct.setAttr(e,t,r)}setAttrString(e,t){return Ct.setAttrString(this,e,t)}static attr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return Ct._preElem(e,"attr").getAttribute(Ct.getAttrName(t))}attr(e){return Ct.attr(this,e)}static setAttr(e,t,r=null){const i=Ct._preElems(e,"setAttr");if("object"==typeof t&&null!==t)return Object.entries(t).forEach(([e,t])=>i.forEach(r=>{null===t?r.removeAttribute(Ct.getAttrName(e)):r.setAttribute(Ct.getAttrName(e),String(t))})),e;if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return i.forEach(e=>{null===r?e.removeAttribute(Ct.getAttrName(t)):e.setAttribute(Ct.getAttrName(t),String(r))}),e}setAttr(e,t){return Ct.setAttr(this,e,t)}static removeAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return Ct._preElems(e,"removeAttr").forEach(e=>e.removeAttribute(Ct.getAttrName(t))),e}removeAttr(e){return Ct.removeAttr(this,e)}static hasAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return Ct._preElem(e,"hasAttr").hasAttribute(Ct.getAttrName(t))}hasAttr(e){return Ct.hasAttr(this,e)}static hasProp(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return!!Ct._preElem(e,"hasProp")[Ct.getPropName(t)]}hasProp(e){return Ct.hasProp(this,e)}static addProp(e,...t){return Ct._preElems(e,"addProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[Ct.getPropName(t)]=!0})}),e}addProp(...e){return Ct.addProp(this,...e)}static removeProp(e,...t){return Ct._preElems(e,"removeProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[Ct.getPropName(t)]=!1})}),e}removeProp(...e){return Ct.removeProp(this,...e)}static toggleProp(e,t,r){const i=Ct._preElems(e,"toggleProp");if(void 0!==r&&"boolean"!=typeof r)throw new TypeError('The "force" must be a boolean.');return(Array.isArray(t)?t:[t]).forEach(e=>{if("string"!=typeof e)throw new TypeError("Each property name must be a string.");i.forEach(t=>{(void 0===r?!t[Ct.getPropName(e)]:r)?Ct.addProp(t,e):Ct.removeProp(t,e)})}),e}toggleProp(e,t){return Ct.toggleProp(this,e,t)}static prop(e,t){if("string"!=typeof t)throw new TypeError('Invalid arguments passed to prop(). Expected string for "name".');return Ct._preElem(e,"prop")[t]}prop(e){return Ct.prop(this,e)}static setProp(e,t,r){if("string"!=typeof t||""===t.trim())throw new Error("Property name must be a non-empty string.");return Ct._preElems(e,"setProp").forEach(e=>{e[t]=r}),e}setProp(e,t){return Ct.setProp(this,e,t)}static remove(e){return Ct._preElems(e,"remove").forEach(e=>e.remove()),e}remove(){return Ct.remove(this)}static index(e,t=null){const r=Ct._preElem(e,"index");if(!r)return-1;if(!t)return Array.prototype.indexOf.call(r.parentNode?.children||[],r);if(t){const e="string"==typeof t?document.querySelectorAll(t):Ct._preElems(t,"index");return Array.prototype.indexOf.call(e,r)}return-1}index(e){return Ct.index(this,e)}static _getCustomRect(e,t){const r={height:0,width:0,x:0,y:0,bottom:0,left:0,right:0,top:0,toJSON:function(){throw new Error("Function not implemented.")}};for(const t in e)"number"==typeof e[t]&&(r[t]=e[t]);if("object"!=typeof t||null===t||Array.isArray(t))throw new Error("extraRect must be a non-null object.");const{height:i=0,width:n=0,top:s=0,bottom:o=0,left:a=0,right:l=0}=t;if("number"!=typeof i)throw new Error("extraRect.height must be a number.");if("number"!=typeof n)throw new Error("extraRect.width must be a number.");if("number"!=typeof s)throw new Error("extraRect.top must be a number.");if("number"!=typeof o)throw new Error("extraRect.bottom must be a number.");if("number"!=typeof a)throw new Error("extraRect.left must be a number.");if("number"!=typeof l)throw new Error("extraRect.right must be a number.");return r.height+=i,r.width+=n,r.top+=s,r.bottom+=o,r.left+=a,r.right+=l,r}static isCollWith(e,t,r={}){const i=Ct._getCustomRect(Ct._preElem(e,"isCollWith").getBoundingClientRect(),r),n=Ct._preElem(t,"isCollWith").getBoundingClientRect();return ft(i,n)}isCollWith(e,t){return Ct.isCollWith(this,e,t)}static isCollPerfWith(e,t,r={}){const i=Ct._getCustomRect(Ct._preElem(e,"isCollPerfWith").getBoundingClientRect(),r),n=Ct._preElem(t,"isCollPerfWith").getBoundingClientRect();return yt(i,n)}isCollPerfWith(e,t){return Ct.isCollPerfWith(this,e,t)}static _isCollWithLock(e,t,r,i,n){const s=At[n];if(e)return s.has(i)||s.set(i,!0),!0;if(s.has(i)){let e=!1;switch(n){case"top":e=gt(t,r);break;case"bottom":e=wt(t,r);break;case"left":e=bt(t,r);break;case"right":e=vt(t,r)}return e&&s.delete(i),s.has(i)}return!1}static isCollWithLock(e,t,r,i={}){const n=Ct._preElem(e,"isCollWithLock"),s=Ct._preElem(t,"isCollWithLock"),o=Ct._getCustomRect(n.getBoundingClientRect(),i),a=s.getBoundingClientRect(),l=ft(o,a);return Ct._isCollWithLock(l,o,a,n,r)}isCollWithLock(e,t,r){return Ct.isCollWithLock(this,e,t,r)}static isCollPerfWithLock(e,t,r,i={}){const n=Ct._preElem(e,"isCollPerfWithLock"),s=Ct._preElem(t,"isCollPerfWithLock"),o=Ct._getCustomRect(n.getBoundingClientRect(),i),a=s.getBoundingClientRect(),l=yt(o,a);return Ct._isCollWithLock(l,o,a,n,r)}isCollPerfWithLock(e,t,r){return Ct.isCollPerfWithLock(this,e,t,r)}static resetCollLock(e){const t=Ct._preElem(e,"resetCollLock");let r=!1;for(const e of["top","bottom","left","right"])At[e].has(t)&&(At[e].delete(t),r=!0);return r}resetCollLock(){return Ct.resetCollLock(this)}static resetCollLockDir(e,t){const r=Ct._preElem(e,"resetCollLockDir"),i=At[t];return!!i.has(r)&&(i.delete(r),!0)}resetCollLockDir(e){return Ct.resetCollLockDir(this,e)}static isInViewport(e){const t=Ct._preElem(e,"isInViewport");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=Ct.offset(t).top,i=r+Ct.outerHeight(t),n=Ct.scrollTop(window),s=n+Ct.height(window);return i>n&&r<s}isInViewport(){return Ct.isInViewport(this)}static isScrolledIntoView(e){const t=Ct._preElem(e,"isScrolledIntoView");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=Ct.scrollTop(window),i=r+Ct.height(window),n=Ct.offset(t).top;return n+Ct.height(t)<=i&&n>=r}isScrolledIntoView(){return Ct.isScrolledIntoView(this)}static isInContainer(e,t){const r=Ct._preElem(e,"isInContainer"),i=Ct._preElem(t,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const n=r.getBoundingClientRect(),s=i.getBoundingClientRect(),o=n.bottom>s.top&&n.top<s.bottom,a=n.right>s.left&&n.left<s.right;return o&&a}isInContainer(e){return Ct.isInContainer(this,e)}static isFullyInContainer(e,t){const r=Ct._preElem(e,"isScrolledIntoView"),i=Ct._preElem(t,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const n=r.getBoundingClientRect(),s=i.getBoundingClientRect();return n.top>=s.top&&n.bottom<=s.bottom&&n.left>=s.left&&n.right<=s.right}isFullyInContainer(e){return Ct.isFullyInContainer(this,e)}static hasScroll(e){const t=Ct._preElem(e,"hasScroll");return{v:t.scrollHeight>t.clientHeight,h:t.scrollWidth>t.clientWidth}}hasScroll(){return Ct.hasScroll(this)}}const It=Ct,Mt=ee("TinyDragger");class Dt{static Utils={...n,TinyHtml:It};#ye=!0;#h=!1;#ge=0;#we=0;#be=!0;#ve=!1;#Ee=!1;#Te=!1;#Se=!1;#xe=!1;#Ae=!1;#Ce=null;#Ie=[];#Me=null;#De={start:!1,end:!1,collide:!1,move:!1};#ke=null;#F;#Ne="drag-hidden";#Le="dragging";#_e="drag-active";#je="jail-drag-active";#Re="jail-drag-disabled";#Pe="dragging-collision";#$e=9999;constructor(e,t={}){if(!(e instanceof HTMLElement))throw new Error("TinyDragger requires a valid target HTMLElement to initialize.");if(this.#F=e,void 0!==t.jail&&!(t.jail instanceof HTMLElement))throw new Error('The "jail" option must be an HTMLElement if provided.');if(void 0!==t.defaultZIndex&&this.setDefaultZIndex(t.defaultZIndex),void 0!==t.vibration&&!1!==t.vibration&&!g(t.vibration))throw new Error('The "vibration" option must be an object or false.');const r=(e,t)=>{if(void 0!==e&&"boolean"!=typeof e)throw new Error(`The "${t}" option must be a boolean.`)},i=(e,t)=>{if(void 0!==e&&"string"!=typeof e)throw new Error(`The "${t}" option must be a string.`)};r(t.mirrorElem,"mirrorElem"),r(t.collisionByMouse,"collisionByMouse"),r(t.lockInsideJail,"lockInsideJail"),r(t.dropInJailOnly,"dropInJailOnly"),r(t.revertOnDrop,"revertOnDrop"),r(t.multiCollision,"multiCollision"),i(t.classDragging,"classDragging"),i(t.classBodyDragging,"classBodyDragging"),i(t.classJailDragging,"classJailDragging"),i(t.classJailDragDisabled,"classJailDragDisabled"),i(t.classDragCollision,"classDragCollision"),i(t.classHidden,"classHidden"),t.jail instanceof HTMLElement&&(this.#ke=t.jail),this.#De=Object.assign({start:!1,end:!1,collide:!1,move:!1},g(t.vibration)?t.vibration:{}),"string"==typeof t.classDragging&&(this.#Le=t.classDragging),"string"==typeof t.classBodyDragging&&(this.#_e=t.classBodyDragging),"string"==typeof t.classJailDragging&&(this.#je=t.classJailDragging),"string"==typeof t.classJailDragDisabled&&(this.#Re=t.classJailDragDisabled),"string"==typeof t.classHidden&&(this.#Ne=t.classHidden),"string"==typeof t.classDragCollision&&(this.#Pe=t.classDragCollision),"boolean"==typeof t.collisionByMouse&&(this.#xe=t.collisionByMouse),"boolean"==typeof t.mirrorElem&&(this.#be=t.mirrorElem),"boolean"==typeof t.revertOnDrop&&(this.#Te=t.revertOnDrop),"boolean"==typeof t.lockInsideJail&&(this.#Ee=t.lockInsideJail),"boolean"==typeof t.dropInJailOnly&&(this.#Ae=t.dropInJailOnly),"boolean"==typeof t.multiCollision&&(this.#ve=t.multiCollision),this._onMouseDown=this.#Oe.bind(this),this._onMouseMove=this.#He.bind(this),this._onMouseUp=this.#Fe.bind(this),this._onTouchStart=e=>this.#Oe(e.touches[0]),this._onTouchMove=e=>this.#He(e.touches[0]),this._onTouchEnd=e=>this.#Fe(e.changedTouches[0]),this.#F.addEventListener("mousedown",this._onMouseDown),this.#F.addEventListener("touchstart",this._onTouchStart,{passive:!1})}enable(){Mt(this.#h),this.#ke&&this.#ke.classList.add(this.#Re),this.#ye=!0}disable(){Mt(this.#h),this.#ke&&this.#ke.classList.remove(this.#Re),this.#ye=!1}addCollidable(e){if(Mt(this.#h),!(e instanceof HTMLElement))throw new Error("addCollidable expects an HTMLElement as argument.");this.#Ie.includes(e)||this.#Ie.push(e)}removeCollidable(e){if(Mt(this.#h),!(e instanceof HTMLElement))throw new Error("removeCollidable expects an HTMLElement as argument.");this.#Ie=this.#Ie.filter(t=>t!==e)}setVibrationPattern({startPattern:e=!1,endPattern:t=!1,collidePattern:r=!1,movePattern:i=!1}={}){Mt(this.#h);const n=e=>!1===e||Array.isArray(e)&&e.every(e=>"number"==typeof e);if(!n(e))throw new Error('Invalid "startPattern": must be false or an array of numbers.');if(!n(t))throw new Error('Invalid "endPattern": must be false or an array of numbers.');if(!n(r))throw new Error('Invalid "collidePattern": must be false or an array of numbers.');if(!n(i))throw new Error('Invalid "movePattern": must be false or an array of numbers.');this.#De={start:e,end:t,collide:r,move:i}}disableVibration(){Mt(this.#h),this.#De={start:!1,end:!1,collide:!1,move:!1}}getOffset(e){if(Mt(this.#h),!(e instanceof MouseEvent||e instanceof Touch)||"number"!=typeof e.clientX||"number"!=typeof e.clientY)throw new Error("getOffset expects an event with valid clientX and clientY coordinates.");const t=this.#F.getBoundingClientRect(),{left:r,top:i}=It.borderWidth(this.#F);return{x:e.clientX-t.left+r,y:e.clientY-t.top+i}}#Oe(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#h||!this.#ye||!this.#F.parentElement)return;if(this.#be){const e=this.#F.cloneNode(!0);if(!(e instanceof HTMLElement))throw new Error("[TinyDragger] INVALID DRAG ELEMENT!");this.#Me=e}else this.#Me=this.#F;this.#Se=!0;const t=this.#F.getBoundingClientRect();Object.assign(this.#Me.style,{position:"absolute",pointerEvents:"none",left:`${this.#F.offsetLeft}px`,top:`${this.#F.offsetTop}px`,width:`${t.width}px`,height:`${t.height}px`,zIndex:this.#$e}),this.#be&&(this.#F.classList.add(this.#Ne),this.#F.parentElement.appendChild(this.#Me));const{x:r,y:i}=this.getOffset(e);this.#we=r,this.#ge=i,this.#Me.classList.add(this.#Le),document.body.classList.add(this.#_e),this.#ke&&this.#ke.classList.add(this.#je),document.addEventListener("mousemove",this._onMouseMove),document.addEventListener("mouseup",this._onMouseUp),document.addEventListener("touchmove",this._onTouchMove,{passive:!1}),document.addEventListener("touchend",this._onTouchEnd),navigator.vibrate&&Array.isArray(this.#De.start)&&navigator.vibrate(this.#De.start),this.checkDragCollision(e),this.#Be("drag")}#ze=[];#We(e){e&&(e.classList.add(this.#Pe),this.#ze.push(e))}#Ve(){for(;this.#ze.length>0;){const e=this.#ze.shift();e&&e.classList.remove(this.#Pe)}this.#Ce&&this.#Ce.classList.remove(this.#Pe)}checkDragCollision(e){Mt(this.#h);const{collidedElements:t}=this.execCollision(e),r=t[0]||null;this.#Ce&&!t.includes(this.#Ce)&&this.#Ve(),t.forEach(e=>this.#We(e)),this.#Ie.forEach(e=>{t.includes(e)||e.classList.remove(this.#Pe)}),navigator.vibrate&&Array.isArray(this.#De.collide)&&t.length>0&&navigator.vibrate(this.#De.collide),this.#Ce=r}#He(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#h||!this.#Se||!this.#ye||!this.#Me)return;const t=(this.#Me.offsetParent||document.body).getBoundingClientRect();let r=e.clientX-t.left-this.#we,i=e.clientY-t.top-this.#ge;if(this.#Ee&&this.#ke){const e=this.#ke.getBoundingClientRect(),n=this.#Me.getBoundingClientRect(),s=e.left-t.left,o=e.top-t.top,{x:a,y:l}=It.borderWidth(this.#ke),u=s+e.width-n.width-l,h=o+e.height-n.height-a;r=Math.max(s,Math.min(r,u)),i=Math.max(o,Math.min(i,h))}this.#Me.style.position="absolute",this.#Me.style.left=`${r}px`,this.#Me.style.top=`${i}px`,navigator.vibrate&&Array.isArray(this.#De.move)&&navigator.vibrate(this.#De.move),this.checkDragCollision(e),this.#Be("dragging")}execCollision(e){if(Mt(this.#h),this.#h||!this.#Me)return{inJail:!1,collidedElements:[]};let t=[],r=!0;const i=this.#ke?.getBoundingClientRect();if(this.#xe){const n=e.clientX,s=e.clientY;this.#Ae&&this.#ke&&i&&(r=n>=i.left&&n<=i.right&&s>=i.top&&s<=i.bottom),t=r?this.#ve?this.getAllCollidedElements(n,s):[this.getCollidedElement(n,s)].filter(Boolean):[]}else{const e=this.#Me.getBoundingClientRect();this.#Ae&&this.#ke&&i&&(r=e.left>=i.left&&e.right<=i.right&&e.top>=i.top&&e.bottom<=i.bottom),t=r?this.#ve?this.getAllCollidedElementsByRect(e):[this.getCollidedElementByRect(e)].filter(Boolean):[]}return{inJail:r,collidedElements:t}}#Fe(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#h||!this.#Se)return;if(this.#Se=!1,!this.#Me)return;this.#F.classList.remove(this.#Le),document.body.classList.remove(this.#_e),this.#ke&&this.#ke.classList.remove(this.#je),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd);const{collidedElements:t}=this.execCollision(e);navigator.vibrate&&Array.isArray(this.#De.end)&&navigator.vibrate(this.#De.end);const r=this.#Me.style.left,i=this.#Me.style.top;this.#Me&&(this.#be?this.#Me.remove():Object.assign(this.#Me.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#Me=null),this.#Ce&&this.#Ve(),this.#Ce=null,this.#be&&this.#F.classList.remove(this.#Ne),this.#Te||(this.#F.style.left=r,this.#F.style.top=i);const n=new CustomEvent("drop",{detail:{targets:t,first:t[0]||null}});this.#F.dispatchEvent(n)}#qe(e,t){const r=e.getBoundingClientRect();return!(t.right<r.left||t.left>r.right||t.bottom<r.top||t.top>r.bottom)}getAllCollidedElementsByRect(e){if(Mt(this.#h),!(e instanceof DOMRect)||"number"!=typeof e.left||"number"!=typeof e.right||"number"!=typeof e.top||"number"!=typeof e.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#Ie.filter(t=>this.#qe(t,e))}getCollidedElementByRect(e){if(Mt(this.#h),!(e instanceof DOMRect)||"number"!=typeof e.left||"number"!=typeof e.right||"number"!=typeof e.top||"number"!=typeof e.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#Ie.find(t=>this.#qe(t,e))||null}#Ke(e,t,r){const i=e.getBoundingClientRect();return t>=i.left&&t<=i.right&&r>=i.top&&r<=i.bottom}getAllCollidedElements(e,t){if(Mt(this.#h),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Ie.filter(r=>this.#Ke(r,e,t))}getCollidedElement(e,t){if(Mt(this.#h),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Ie.find(r=>this.#Ke(r,e,t))||null}#Be(e){const t=new CustomEvent(e);this.#F.dispatchEvent(t)}getDragging(){return Mt(this.#h),this.#Se}getLockInsideJail(){return Mt(this.#h),this.#Ee}setLockInsideJail(e){if(Mt(this.#h),"boolean"!=typeof e)throw new Error("lockInsideJail must be a boolean.");this.#Ee=e}getRevertOnDrop(){return Mt(this.#h),this.#Te}setRevertOnDrop(e){if(Mt(this.#h),"boolean"!=typeof e)throw new Error("revertOnDrop must be a boolean.");this.#Te=e}getCollisionByMouse(){return Mt(this.#h),this.#xe}setCollisionByMouse(e){if(Mt(this.#h),"boolean"!=typeof e)throw new Error("collisionByMouse must be a boolean.");this.#xe=e}getDropInJailOnly(){return Mt(this.#h),this.#Ae}setDropInJailOnly(e){if(Mt(this.#h),"boolean"!=typeof e)throw new Error("dropInJailOnly must be a boolean.");this.#Ae=e}getDefaultZIndex(){return Mt(this.#h),this.#$e}setDefaultZIndex(e){if(Mt(this.#h),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("Z-index must be a finite number.");this.#$e=e}isMirrorEnabled(){return Mt(this.#h),this.#be}setMirrorEnabled(e){if(Mt(this.#h),"boolean"!=typeof e)throw new TypeError("Mirror setting must be a boolean.");this.#be=e}getTarget(){return Mt(this.#h),this.#F}getJail(){return Mt(this.#h),this.#ke}getDragProxy(){return Mt(this.#h),this.#Me}getLastCollision(){return Mt(this.#h),this.#Ce}getCollidables(){return Mt(this.#h),[...this.#Ie]}getDragHiddenClass(){return Mt(this.#h),this.#Ne}getClassDragging(){return Mt(this.#h),this.#Le}getClassBodyDragging(){return Mt(this.#h),this.#_e}getClassJailDragging(){return Mt(this.#h),this.#je}getClassJailDragDisabled(){return Mt(this.#h),this.#Re}getClassDragCollision(){return Mt(this.#h),this.#Pe}getVibrations(){return Mt(this.#h),{...this.#De}}getStartVibration(){return Mt(this.#h),this.#De.start}getEndVibration(){return Mt(this.#h),this.#De.end}getCollideVibration(){return Mt(this.#h),this.#De.collide}getMoveVibration(){return Mt(this.#h),this.#De.move}isEnabled(){return Mt(this.#h),this.#ye}destroy(){this.#h||(this.disable(),this.#F.removeEventListener("mousedown",this._onMouseDown),this.#F.removeEventListener("touchstart",this._onTouchStart),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd),this.#Ce&&this.#Ve(),this.#Me&&(this.#be?this.#Me.remove():Object.assign(this.#Me.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#Me=null),this.#Ie=[],this.#Se=!1,this.#Ce=null,this.#be&&this.#F.classList.remove(this.#Ne),this.#F.classList.remove(this.#Le),document.body.classList.remove(this.#_e),this.#ke&&this.#ke.classList.remove(this.#je,this.#Re),this.#h=!0)}}const kt=Dt,Nt=class{#Je=[];#Ue=!1;#Ge=!1;#Ye=[];#Xe(){this.#Ue&&Promise.all(this.#Ye).then(()=>{this.#Ge=!0,this.#Qe(!1)}).catch(e=>{console.error("[TinyDomReadyManager] Promise rejected:",e)})}#Qe(e){this.#Je.filter(t=>t.domOnly===e).sort((e,t)=>t.priority-e.priority).forEach(e=>this.#Ze(e)),this.#Je=this.#Je.filter(t=>!(t.once&&(!e||t.domOnly)))}#Ze(e){if("function"==typeof e.filter)try{if(!e.filter())return}catch(e){return void console.warn("[TinyDomReadyManager] Filter error:",e)}try{e.fn()}catch(e){console.error("[TinyDomReadyManager] Handler error:",e)}}_markDomReady(){this.#Ue=!0,this.#Qe(!0),this.#Xe()}init(){if(this.#Ue)throw new Error("[TinyDomReadyManager] init() has already been called.");"interactive"===document.readyState||"complete"===document.readyState?this._markDomReady():document.addEventListener("DOMContentLoaded",()=>this._markDomReady())}addPromise(e){if(!(e instanceof Promise))throw new TypeError("[TinyDomReadyManager] promise must be a valid Promise.");this.#Ge||(this.#Ye.push(e),this.#Ue&&this.#Xe())}onReady(e,{once:t=!0,priority:r=0,filter:i=null,domOnly:n=!1}={}){if("function"!=typeof e)throw new TypeError("[TinyDomReadyManager] fn must be a function.");const s={fn:e,once:t,priority:r,filter:i,domOnly:n};if(n&&this.#Ue)return this.#Ze(s),void(t||this.#Je.push(s));!n&&this.#Ge?this.#Ze(s):this.#Je.push(s)}isReady(){return this.#Ge}isDomReady(){return this.#Ue}},Lt=class{#et=!1;#tt=!1;#rt=null;#it=100;#nt=null;#st;constructor({audio:e=null,defaultIcon:t=null,bodyLimit:r=100,defaultOnClick:i=function(e){e.preventDefault(),window.focus&&window.focus(),this.close()}}={}){if(!(e instanceof HTMLAudioElement)&&"string"!=typeof e&&null!==e)throw new TypeError("audio must be an instance of HTMLAudioElement or null.");if(null!==t&&"string"!=typeof t)throw new TypeError("defaultIcon must be a string or null.");if(!Number.isFinite(r)||r<0)throw new TypeError("bodyLimit must be a non-negative number.");if("function"!=typeof i)throw new TypeError("defaultOnClick must be a function.");this.#rt="string"!=typeof e?e:new Audio(e),this.#nt=t,this.#it=r,this.#st=i}requestPerm(){const e=this;return new Promise((t,r)=>{e.isCompatible()?"default"===Notification.permission?Notification.requestPermission().then(r=>{this.#tt=!0,e.#et="granted"===r,t(e.#et)}).catch(r):(this.#tt=!0,e.#et="granted"===Notification.permission,t(e.#et)):(this.#tt=!0,e.#et=!1,t(!1))})}isCompatible(){return"Notification"in window}send(e,t={}){if(!this.#tt)throw new Error("You must call requestPerm() before sending a notification.");if("string"!=typeof e)throw new TypeError("title must be a string.");if("object"!=typeof t||null===t)throw new TypeError("config must be a non-null object.");if(!this.#et)return null;const{icon:r=this.#nt||void 0,vibrate:i=[200,100,200]}=t,n={...t};"string"==typeof r&&(n.icon=r),Array.isArray(i)&&(n.vibrate=i),"string"==typeof n.body&&(n.body=U(n.body,this.#it));const s=new Notification(e,n);return s.addEventListener("show",()=>{this.#rt instanceof HTMLAudioElement&&(this.#rt.currentTime=0,this.#rt.play().catch(e=>console.error(e)))}),"function"==typeof this.#st&&s.addEventListener("click",this.#st),s}wasPermissionRequested(){return this.#tt}isAllowed(){return this.#et}getAudio(){return this.#rt}setAudio(e){if(!(e instanceof HTMLAudioElement)&&"string"!=typeof e&&null!==e)throw new TypeError("sound must be an instance of HTMLAudioElement or null.");this.#rt="string"!=typeof e?e:new Audio(e)}getBodyLimit(){return this.#it}setBodyLimit(e){if(!Number.isFinite(e)||e<0)throw new TypeError("bodyLimit must be a non-negative number.");this.#it=e}getDefaultAvatar(){return this.#nt}setDefaultAvatar(e){if("string"!=typeof e&&null!==e)throw new TypeError("defaultIcon must be a string or null.");this.#nt=e}getDefaultOnClick(){return this.#st}setDefaultOnClick(e){if("function"!=typeof e)throw new TypeError("defaultOnClick must be a function.");this.#st=e}},_t=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');if("string"!=typeof e)throw new TypeError(`Expected "${t}" to be a string, but received ${typeof e}.`)},jt=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');if("function"!=typeof e)throw new TypeError(`Expected "${t}" to be a function, but received ${typeof e}.`)},Rt=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError(`Expected "${t}" to be a plain object, but received ${null===e?"null":Array.isArray(e)?"array":typeof e}.`)},Pt=(e,t=!1)=>!t&&void 0===e,$t=(e,t=!1)=>Pt(e,t)||"string"==typeof e||!t&&null===e,Ot=(e,t=!1)=>Pt(e,t)||"number"==typeof e||!t&&null===e,Ht=(e,t=!1)=>Pt(e,t)||"boolean"==typeof e||!t&&null===e,Ft=(e,t)=>!!Pt(e)||(jt(t,"valueValidator"),Array.isArray(e)&&e.every(t)),Bt=new Map;class zt extends Error{constructor(e,t,r){if(_t(e,"message"),_t(t,"url"),"string"!=typeof r)throw new TypeError(`Expected "stage" to be a string, but received ${typeof r}.`);super(e),this.name="MediaLoadingError",this.url=t,this.stage=r}}const Wt=async e=>{_t(e,"str");const t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-1",t);return Array.from(new Uint8Array(r)).map(e=>e.toString(16).padStart(2,"0")).join("").substring(0,8)},Vt=(e,t="image/jpeg")=>{if(!(e instanceof Uint8Array)&&"string"!=typeof e)throw new TypeError(`Expected "data" to be an instance of Uint8Array or a string, but received ${typeof e}.`);_t(t,"format");const r=e=>{const t=URL.createObjectURL(e),r=Bt.get(t);return Bt.set(t,"number"==typeof r?r+1:1),t};if(e instanceof Uint8Array)return r(new Blob([e],{type:t}));if("string"==typeof e&&e.startsWith("data:")){const i=e.split(",")[1],n=atob(i),s=new Uint8Array(n.length);for(let e=0;e<n.length;e++)s[e]=n.charCodeAt(e);return r(new Blob([s],{type:t}))}return"string"==typeof e?e:""},qt=async e=>{if(_t(e,"url"),!e.startsWith("blob:"))return e;try{const t=await fetch(e),r=await t.blob();return await new Promise((e,t)=>{const i=new FileReader;i.onloadend=()=>e(String(i.result)),i.onerror=t,i.readAsDataURL(r)})}catch(t){return console.warn(`[TinyAudioUtils] Failed to convert Blob URL to Base64 on export: ${e}`,t),e}},Kt=e=>{Rt(e,"content"),e&&Array.isArray(e.picture)&&e.picture.forEach(e=>{if("string"==typeof e.data&&e.data.startsWith("blob:")){const t=Bt.get(e.data)??0;t>1?Bt.set(e.data,t-1):Bt.delete(e.data),t<=1&&URL.revokeObjectURL(e.data)}})},Jt=(e,t=!1)=>{if(g(e)){if(4!==y(e)){if(t)return!1;throw new TypeError("Invalid fetch data: Object must be an MediaContentFetchData.")}Ut(e.common),Rt(e.native,"_fetchData.native"),Rt(e.format,"_fetchData.format"),Rt(e.quality,"_fetchData.quality");for(const r in e.native){const i=e.native[r];if(!Ft(i,e=>"string"==typeof e.id)){if(t)return!1;throw new TypeError(`Invalid native data: "${r}" must be an array of native fetch data.`)}}}return!0},Ut=e=>{if(Rt(e,"common"),Jt(e._fetchData),!$t(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!$t(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!$t(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a a string or null.');if(!$t(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(!Ht(e.compilation))throw new TypeError('Invalid metadata: "compilation" must be a boolean or null.');if(!Ht(e.podcast))throw new TypeError('Invalid metadata: "podcast" must be a boolean or null.');if(!Ht(e.gapless))throw new TypeError('Invalid metadata: "gapless" must be a boolean or null.');if(!Ht(e.showMovement))throw new TypeError('Invalid metadata: "showMovement" must be a boolean or null.');if(!Ot(e.averageLevel))throw new TypeError('Invalid metadata: "averageLevel" must be a number or null.');if(!Ot(e.peakLevel))throw new TypeError('Invalid metadata: "peakLevel" must be a number or null.');if(!Ot(e.hdVideo))throw new TypeError('Invalid metadata: "hdVideo" must be a number or null.');if(!Ot(e.stik))throw new TypeError('Invalid metadata: "stik" must be a number or null.');if(!Ot(e.playCounter))throw new TypeError('Invalid metadata: "playCounter" must be a number or null.');if(!Ot(e.tvSeason))throw new TypeError('Invalid metadata: "tvSeason" must be a number or null.');if(!Ot(e.tvEpisode))throw new TypeError('Invalid metadata: "tvEpisode" must be a number or null.');if(!Ot(e.year))throw new TypeError('Invalid metadata: "year" must be a number or null.');if(!Ot(e.bpm))throw new TypeError('Invalid metadata: "bpm" must be a number or null.');if(!Ot(e.originalyear))throw new TypeError('Invalid metadata: "originalyear" must be a number or null.');if(!Ot(e.movementTotal))throw new TypeError('Invalid metadata: "movementTotal" must be a number or null.');if(!$t(e.date))throw new TypeError('Invalid metadata: "date" must be a string or null.');if(!$t(e.originaldate))throw new TypeError('Invalid metadata: "originaldate" must be a string or null.');if(!$t(e.releasedate))throw new TypeError('Invalid metadata: "releasedate" must be a string or null.');if(!$t(e.albumsort))throw new TypeError('Invalid metadata: "albumsort" must be a string or null.');if(!$t(e.titlesort))throw new TypeError('Invalid metadata: "titlesort" must be a string or null.');if(!$t(e.work))throw new TypeError('Invalid metadata: "work" must be a string or null.');if(!$t(e.artistsort))throw new TypeError('Invalid metadata: "artistsort" must be a string or null.');if(!$t(e.albumartistsort))throw new TypeError('Invalid metadata: "albumartistsort" must be a string or null.');if(!$t(e.composersort))throw new TypeError('Invalid metadata: "composersort" must be a string or null.');if(!$t(e.grouping))throw new TypeError('Invalid metadata: "grouping" must be a string or null.');if(!$t(e.longDescription))throw new TypeError('Invalid metadata: "longDescription" must be a string or null.');if(!$t(e.totaltracks))throw new TypeError('Invalid metadata: "totaltracks" must be a string or null.');if(!$t(e.totaldiscs))throw new TypeError('Invalid metadata: "totaldiscs" must be a string or null.');if(!$t(e.mood))throw new TypeError('Invalid metadata: "mood" must be a string or null.');if(!$t(e.media))throw new TypeError('Invalid metadata: "media" must be a string or null.');if(!$t(e.tvShow))throw new TypeError('Invalid metadata: "tvShow" must be a string or null.');if(!$t(e.tvShowSort))throw new TypeError('Invalid metadata: "tvShowSort" must be a string or null.');if(!$t(e.tvEpisodeId))throw new TypeError('Invalid metadata: "tvEpisodeId" must be a string or null.');if(!$t(e.tvNetwork))throw new TypeError('Invalid metadata: "tvNetwork" must be a string or null.');if(!$t(e.podcasturl))throw new TypeError('Invalid metadata: "podcasturl" must be a string or null.');if(!$t(e.releasestatus))throw new TypeError('Invalid metadata: "releasestatus" must be a string or null.');if(!$t(e.releasecountry))throw new TypeError('Invalid metadata: "releasecountry" must be a string or null.');if(!$t(e.script))throw new TypeError('Invalid metadata: "script" must be a string or null.');if(!$t(e.language))throw new TypeError('Invalid metadata: "language" must be a string or null.');if(!$t(e.copyright))throw new TypeError('Invalid metadata: "copyright" must be a string or null.');if(!$t(e.license))throw new TypeError('Invalid metadata: "license" must be a string or null.');if(!$t(e.encodedby))throw new TypeError('Invalid metadata: "encodedby" must be a string or null.');if(!$t(e.encodersettings))throw new TypeError('Invalid metadata: "encodersettings" must be a string or null.');if(!$t(e.barcode))throw new TypeError('Invalid metadata: "barcode" must be a string or null.');if(!$t(e.asin))throw new TypeError('Invalid metadata: "asin" must be a string or null.');if(!$t(e.website))throw new TypeError('Invalid metadata: "website" must be a string or null.');if(!$t(e.originalalbum))throw new TypeError('Invalid metadata: "originalalbum" must be a string or null.');if(!$t(e.originalartist))throw new TypeError('Invalid metadata: "originalartist" must be a string or null.');if(!$t(e.key))throw new TypeError('Invalid metadata: "key" must be a string or null.');if(!$t(e.movement))throw new TypeError('Invalid metadata: "movement" must be a string or null.');if(!$t(e.podcastId))throw new TypeError('Invalid metadata: "podcastId" must be a string or null.');if(!Ft(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of strings.');if(!Ft(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of strings.');if(!Ft(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of strings.');if(!Ft(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of strings.');if(!Ft(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of strings.');if(!Ft(e.lyricist,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "lyricist" must be an array of strings.');if(!Ft(e.writer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "writer" must be an array of strings.');if(!Ft(e.conductor,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "conductor" must be an array of strings.');if(!Ft(e.remixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "remixer" must be an array of strings.');if(!Ft(e.arranger,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "arranger" must be an array of strings.');if(!Ft(e.engineer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "engineer" must be an array of strings.');if(!Ft(e.publisher,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "publisher" must be an array of strings.');if(!Ft(e.producer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "producer" must be an array of strings.');if(!Ft(e.djmixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "djmixer" must be an array of strings.');if(!Ft(e.mixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "mixer" must be an array of strings.');if(!Ft(e.technician,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "technician" must be an array of strings.');if(!Ft(e.subtitle,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "subtitle" must be an array of strings.');if(!Ft(e.description,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "description" must be an array of strings.');if(!Ft(e.discsubtitle,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "discsubtitle" must be an array of strings.');if(!Ft(e.releasetype,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "releasetype" must be an array of strings.');if(!Ft(e.isrc,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "isrc" must be an array of strings.');if(!Ft(e.performer_instrument,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "performer_instrument" must be an array of strings.');if(!Ft(e.notes,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "notes" must be an array of strings.');if(!Ft(e.category,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "category" must be an array of strings.');if(!Ft(e.keywords,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "keywords" must be an array of strings.');if(!Ft(e.catalognumber,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "catalognumber" must be an array of strings.');if(!Ft(e.picture,e=>e&&"object"==typeof e&&(void 0===e.description||"string"==typeof e.description)&&(void 0===e.name||"string"==typeof e.name)&&(void 0===e.type||"string"==typeof e.type)&&"string"==typeof e.format&&(e.data instanceof Uint8Array||"string"==typeof e.data)))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');if(!Ft(e.comment,e=>null!==e&&"object"==typeof e&&$t(e.descriptor)&&$t(e.language)&&$t(e.text)))throw new TypeError('Invalid metadata: "comment" must be an array of valid IComment objects.');if(!Ft(e.lyrics,e=>null!==e&&"object"==typeof e&&$t(e.text)&&$t(e.descriptor)&&$t(e.language)&&(!Array.isArray(e)||Ft(e.syncText,e=>null!==e&&"object"==typeof e&&$t(e.text)&&Ot(e.timestamp)))&&(e=>void 0===e||null!==e&&"object"==typeof e&&Ot(e.notSynchronized)&&Ot(e.mpegFrameNumber)&&Ot(e.milliseconds))(e.timeStampFormat)&&(e=>void 0===e||null!==e&&"object"==typeof e&&Ot(e.other)&&Ot(e.lyrics)&&Ot(e.text)&&Ot(e.movement_part)&&Ot(e.events)&&Ot(e.chord)&&Ot(e.trivia_pop))(e.contentType)))throw new TypeError('Invalid metadata: "lyrics" must be an array of valid ILyricsTag objects.');if(!Ft(e.rating,e=>null!==e&&"object"==typeof e&&$t(e.source)&&Ot(e.rating)))throw new TypeError('Invalid metadata: "rating" must be an array of valid IRating objects.');const t=(e,t)=>{if(!Pt(t)&&null!==t){if("object"!=typeof t)throw new TypeError(`Invalid metadata: "${e}" must be an object or null.`);if("number"!=typeof t.no&&null!==t.no)throw new TypeError(`Invalid metadata: "${e}.no" must be a number or null.`);if("number"!=typeof t.of&&null!==t.of)throw new TypeError(`Invalid metadata: "${e}.of" must be a number or null.`)}};t("disk",e.disk),t("track",e.track),t("movementIndex",e.movementIndex)},Gt=async(e,t,r=!0)=>{_t(e,"url"),jt(t,"parseFile");const i=await fetch(e);if(!i.ok)throw new Error(`Failed to fetch audio file: ${i.status} ${i.statusText}`);const n=await i.blob(),s=await t(n);if(!s||"object"!=typeof s.common)throw new TypeError('Invalid metadata: "common" property is missing.');void 0!==typeof s.common["performer:instrument"]&&(s.common.performer_instrument=s.common["performer:instrument"]),Jt(s);const o=s.common;Ut(o);const a=([e,t])=>Array.isArray(t)?t.length>0:g(t)?y(Object.fromEntries(Object.entries(t).filter(a)))>0:null!==t,l=o?.picture?.map(e=>({...e,data:r?Vt(e.data,e.format):e.data}))??[];s.common={...s.common,picture:l.map(e=>({...e,data:""}))},r&&Object.keys(s.native).forEach(e=>{s.native[e]=s.native[e].map(e=>{if(e.value&&"object"==typeof e.value&&e.value.data instanceof Uint8Array){const t=o?.picture?.findIndex(t=>t.data===e.value.data&&t.format===e.value.format&&t.description===e.value.description&&t.name===e.value.name)??-1;if(l[t])return{...e,value:{...e.value,data:""}}}return e})});const u=Object.fromEntries(Object.entries({title:o?.title??null,album:o?.album??null,albumartist:o?.albumartist??null,albumartists:o?.albumartists??[],genre:o?.genre??[],label:o?.label??[],composer:o?.composer??[],year:o?.year??null,artist:o?.artist??null,artists:o?.artists??[],disk:o?.disk?{no:o.disk.no,of:o.disk.of}:null,track:o?.track?{no:o.track.no,of:o.track.of}:null,movementIndex:o?.movementIndex?{no:o.movementIndex.no,of:o.movementIndex.of}:null,picture:l,date:o?.date??null,originaldate:o?.originaldate??null,originalyear:o?.originalyear??null,releasedate:o?.releasedate??null,comment:o?.comment??[],lyrics:o?.lyrics??[],albumsort:o?.albumsort??null,titlesort:o?.titlesort??null,work:o?.work??null,artistsort:o?.artistsort??null,albumartistsort:o?.albumartistsort??null,composersort:o?.composersort??null,lyricist:o?.lyricist??[],writer:o?.writer??[],conductor:o?.conductor??[],remixer:o?.remixer??[],arranger:o?.arranger??[],engineer:o?.engineer??[],publisher:o?.publisher??[],producer:o?.producer??[],djmixer:o?.djmixer??[],mixer:o?.mixer??[],technician:o?.technician??[],grouping:o?.grouping??null,subtitle:o?.subtitle??[],description:o?.description??[],longDescription:o?.longDescription??null,discsubtitle:o?.discsubtitle??[],totaltracks:o?.totaltracks??null,totaldiscs:o?.totaldiscs??null,movementTotal:o?.movementTotal??null,compilation:o?.compilation??null,rating:o?.rating??[],bpm:o?.bpm??null,mood:o?.mood??null,media:o?.media??null,catalognumber:o?.catalognumber??[],tvShow:o?.tvShow??null,tvShowSort:o?.tvShowSort??null,tvSeason:o?.tvSeason??null,tvEpisode:o?.tvEpisode??null,tvEpisodeId:o?.tvEpisodeId??null,tvNetwork:o?.tvNetwork??null,podcast:o?.podcast??null,podcasturl:o?.podcasturl??null,releasestatus:o?.releasestatus??null,releasetype:o?.releasetype??[],releasecountry:o?.releasecountry??null,script:o?.script??null,language:o?.language??null,copyright:o?.copyright??null,license:o?.license??null,encodedby:o?.encodedby??null,encodersettings:o?.encodersettings??null,gapless:o?.gapless??null,barcode:o?.barcode??null,isrc:o?.isrc??[],asin:o?.asin??null,website:o?.website??null,performer_instrument:o?.performer_instrument??[],averageLevel:o?.averageLevel??null,peakLevel:o?.peakLevel??null,notes:o?.notes??[],originalalbum:o?.originalalbum??null,originalartist:o?.originalartist??null,key:o?.key??null,category:o?.category??[],hdVideo:o?.hdVideo??null,keywords:o?.keywords??[],movement:o?.movement??null,podcastId:o?.podcastId??null,showMovement:o?.showMovement??null,stik:o?.stik??null,playCounter:o?.playCounter??null}).filter(a));return u._fetchData=s,u},Yt=async(e,t={},r={},i=e=>{if(!(e instanceof Blob))throw new TypeError('Expected "data" to be a Blob.');return new Promise((e,t)=>t(new TypeError("parseFile library not found.")))},n={},s=!0,o="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(Rt(t,"defaultMetadata"),Rt(r,"metadata"),jt(i,"parseFile"),Rt(n,"callbacks"),n.onProgress&&"function"!=typeof n.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(n.onError&&"function"!=typeof n.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof o&&"function"!=typeof o)throw new TypeError("unknownArtist must be a string or a function returning a string.");let a,l="";const u=(t,r)=>{if(_t(t,"stage"),void 0!==r&&!(r instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');n.onProgress&&n.onProgress({event:r,status:"loading",stage:t,url:l||(e instanceof HTMLMediaElement?e.src:"unknown")})},h=(t,r)=>{if(!(t instanceof Error))throw new TypeError('Expected "error" to be an Error.');_t(r,"stage"),n.onError&&n.onError({error:t instanceof Error?t:new Error(String(t)),url:l||(e instanceof HTMLMediaElement?e.src:"unknown"),stage:r})};try{u("INITIALIZING"),"string"==typeof e?(l=e,a=new Audio(l)):(a=e,l=a.src);try{await new Promise((e,t)=>{const r=e=>u("DOWNLOADING",e),i=()=>{s(),e(void 0)},n=e=>{s(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},s=()=>{a.removeEventListener("progress",r),a.removeEventListener("loadedmetadata",i),a.removeEventListener("error",n)};a.addEventListener("progress",r),a.addEventListener("loadedmetadata",i),a.addEventListener("error",n),a.readyState>=1&&(s(),e(void 0))}),u("METADATA_LOADED")}catch(e){throw new zt(e instanceof Error?e.message:"UNKNOWN ERROR",l,"METADATA")}const d={id:r.id||await Wt(l),duration:Math.floor(1e3*a.duration),url:l,weight:r.weight??1};let c={};u("EXTRACTING_ID3");try{c=await Gt(l,i,s)}catch(e){h(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${l}. Falling back to filename.`)}const m=e=>{_t(e,"url");try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},p=e=>{const t={...e};return g(t._fetchData)&&(g(c._fetchData)&&(t._fetchData={...c._fetchData}),g(e._fetchData)&&(void 0!==e._fetchData.common&&(t._fetchData.common=e._fetchData.common),void 0!==e._fetchData.native&&(t._fetchData.native=e._fetchData.native),void 0!==e._fetchData.format&&(t._fetchData.format=e._fetchData.format),void 0!==e._fetchData.quality&&(t._fetchData.quality=e._fetchData.quality))),t},f={...d,...p(t),...c,...p(r),title:c.title||r.title||m(l),artist:c.artist||r.artist||("string"==typeof o?o:String(o()))};return n.onProgress&&n.onProgress({status:"success",stage:"COMPLETE",url:l}),f}catch(e){if(e instanceof zt)throw e;const t=new zt(e instanceof Error?e.message:"UNKNOWN ERROR",l,"INITIALIZING");throw h(t,"INITIALIZING"),t}},Xt=ee("TinyAfterScrollWatcher"),Qt=class{#ot;get scrollTarget(){return Xt(this.#h),this.#ot}#at=null;#lt=[];get afterScrollQueueSize(){return Xt(this.#h),this.#lt.length}#ut=100;#ht=new Set;#dt=new Set;#h=!1;get destroyed(){return this.#h}constructor(e,t=100){if(!(e instanceof Element||e instanceof Window))throw new TypeError("scrollTarget must be an Element or the Window object.");this.#ot=e,this._checkTimer=this._checkTimer.bind(this),this.#ot.addEventListener("scroll",this._checkTimer),this.#ut=t}_checkTimer=()=>{this.#at&&clearTimeout(this.#at),this.#at=setTimeout(()=>{this.#at=null,this.#ct()},this.#ut)};get inactivityTime(){return Xt(this.#h),this.#ut}set inactivityTime(e){if(Xt(this.#h),"number"!=typeof e||e<=0||!Number.isFinite(e))throw new Error("inactivityTime must be a positive number in milliseconds.");this.#ut=e}#ct(){if(!this.#h){for(const e of this.#dt)"function"==typeof e&&e();for(;this.#lt.length;){const e=this.#lt.pop();"function"==typeof e&&e()}}}doAfterScroll(e){if(Xt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.lastScrollTime=Date.now(),this.#lt.push(e)}onStop(e){if(Xt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#dt.add(e)}offStop(e){if(Xt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#dt.delete(e)}onScroll(e){if(Xt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ot.addEventListener("scroll",e),this.#ht.add(e)}offScroll(e){if(Xt(this.#h),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ht.has(e)&&(this.#ot.removeEventListener("scroll",e),this.#ht.delete(e))}destroy(){if(!this.#h){this.#ot.removeEventListener("scroll",this._checkTimer);for(const e of this.#ht)this.#ot.removeEventListener("scroll",e);this.#ht.clear(),this.#dt.clear(),this.#h=!0}}},Zt=ee("UltraRandomMsgGen"),er=["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","sed","do","eiusmod","tempor","incididunt","ut","labore","et","dolore","magna","aliqua"],tr=["😂","🌈","🤖","💥","🐸","🍕","🦄","🧠","🧬","🚀","🫠","💫","🍩","👾","🎉","🥴","🐙","🧃","🪐","🎈","🧸","👻","🥳","🍭","💖","😺","🌮","🪅","🎮","🥓","🍮","🍬","🍓","🍒","🥝","🥑","🍄","🌊","☁️","🌟","🌙","🧚","🐾","🐥","🐼","🐨","🐳","✨","🧁","🌸","🍃","💎","🎐","🎀","🫧","☄️","🛸","🔮"],rr=["pudding","bean","snuggle","bloop","jelly","unicorn","floof","giggle","bubble","muffin","puff","pickle","goblin","waffle","sprinkle","cupcake","fizzle","marshmallow","duckling","sock","cloud","teacup","nugget","gnome","hug","moonbean","crayon","jiggle","glitter","carrot","goober"],ir=["wiggles","bounces","flies","splats","scoots","giggles","wigglesnacks","twirls","boops","pops","sings","hugs","floats","glows","flaps","mlems","dances","puddles","nomnoms","wigglejumps","sniffs","tumbles","slides","chirps","burps","sparkles","waddles","rambles","blinks","mews"],nr=["fluffy","silly","yummy","squishy","wobbly","magical","tiny","sleepy","wiggly","bubbly","glittery","fuzzy","jiggly","sparkly","giggly","crunchy","goofy","soft","mushy","sweet","loopy","floaty","bonkers","chewy","ticklish","dreamy","pastel","cozy","teensy","grumbly"],sr=["Boop!","Wiggle achieved.","Oops, {noun} everywhere!","Tiny {adj} {noun}, big {adj} {noun}.","Snuggle initiated with a {adj} {noun}.","{adj} vibes only, powered by {noun}.","No {noun}, no {noun}.","Bounce first, {verb} later.","Mlem. {verb}. {noun}.","{noun} go brrr and {verb}.","Why not? {noun} did. Then {noun} followed.","A {adj} {noun} just {verb} near the {adj} window.","That {adj} {noun} stole my {noun}!","Look, a {adj} {noun} trying to {verb} again!","Every {noun} deserves a {adj} nap.","The {adj} {noun} is my {adj} spirit animal.","Someone call the {noun}, it’s {verb}ing and {verb}ing again!","Don’t touch the {adj} {noun}. It {verb}s loudly.","{noun} forgot how {noun}s work and just {verb}ed.","There once was a {adj} {noun} who loved to {verb} with a {adj} {noun} all day.","Apparently, {noun}s are banned from {verb}ing and {verb}ing in the {noun} library.","That {adj} noise? Just a {noun} learning to {verb} on a {adj} {noun}.","I saw a {adj} {noun} {verb} so hard, it became a {adj} muffin.","The {adj} {noun} met a {adj} pickle and everything {verb}ed.","{noun}s are like {noun}: {adj}, unpredictable, and wiggly.","Don’t judge a {adj} {noun} by its ability to {verb}, or by its {adj} hat.","All I wanted was peace, but a {adj} {noun} with a {adj} {noun} had other plans.","One {adj} morning, a {adj} {noun} decided it was finally time to {verb}, but halfway through, it tripped on a {noun} and turned into a {adj} marshmallow.","I tried to be {adj} today, but then a {noun} {verb}ed across my {noun} and typed “asdfgh{noun}” repeatedly.","If you think you’ve seen everything, wait until a {adj} {noun} {verb}s on a {noun} wearing {adj} socks with tiny {noun}s.","No one ever believed the stories about the ancient {adj} {noun} who could {verb} with such {adj} grace that entire {noun}s turned pink out of embarrassment.","A curious {adj} {noun} wandered into a {noun} shop, not knowing that its destiny involved twelve {adj} {noun}s, one rubber {noun}, and a suspiciously quiet {adj} llama.","In a land where every {adj} {noun} was made of pudding and the sky was {adj} whipped cream, one brave {adj} {noun} set out to discover the legendary Spoon of {noun}s, facing obstacles like bouncing {noun}s, sassy {noun}s, and the Great Wobble of the {noun}.","Once upon a {adj} time, long before the {noun}s learned to {verb}, there existed a tiny {adj} {noun} who dreamed of swimming in a pool made entirely of {adj} glitter pudding while {verb}ing off-key lullabies to passing {noun}s with monocles.","The Council of {noun}s gathered in {adj} secret when the sacred {adj} {noun} started to {verb} uncontrollably, threatening the entire {adj} dessert-based civilization with spontaneous {noun} jiggles and uncontainable {noun} fits across the {noun}.","Hey... do you ever wonder if {noun}s dream of {noun}s?","Okay but hear me out: what if the {adj} {noun} could actually {verb} backwards?","Can we talk about the {noun} that just {verb}ed and vanished?","So I was talking to a {noun}, and it told me to stop being {adj}. Rude.","Not to alarm you, but there’s a {adj} {noun} behind you doing the {verb}.","Why does this {noun} keep staring at me like I owe it pudding?","Is this a safe space to admit I accidentally {verb}ed a {noun}?","I just walked into the room and someone shouted “{adj} {noun}!” — what did I miss?","Wait... we were supposed to bring a {noun}? No one told me!","Okay but what if the {adj} {noun} has feelings too?","Be honest, do I look like a {noun} that forgot how to {verb}?",'If I say "oops", do I still have to explain why the {noun} is glowing?',"I don’t know what’s going on but I brought snacks and a confused {noun}.","Do you think pudding knows it’s pudding? Just a thought.","Is this about the time I {verb}ed the {adj} {noun} by accident? Because I can explain.","Wait, are we talking about {noun}s or am I on the wrong chat again?",'What is this group even about? I just saw "pudding" and joined.',"Hi! I have no idea what’s happening but I’m here and I brought a {noun}.","I blinked and now there’s a {adj} {noun} in charge of everything.","Can someone please explain why the {noun} is floating and chanting?","Okay who gave the {noun} access to glitter and emotional support pickles?","I came for a calm discussion and now there’s a {adj} battle between {noun}s.","Not sure if I’m early, late, or inside a {noun} dream.","I was gone for 3 minutes and now someone’s riding a {noun} into the pudding realm.","This isn’t the pudding appreciation group, is it? ...oh no.","So... who summoned the {adj} {noun} this time? Be honest.","I came here for vibes and stayed for the {noun}s.","Does anyone else hear faint giggling or is that just the {adj} {noun} again?","I feel like I missed step one, two, and also three of this conversation.","All I asked was “what’s up?” and now I’m emotionally attached to a {noun}.",'Me: "I’ll be normal today." Also me: *{verb}s into a meeting riding a {adj} {noun}*','"It’s just pudding," they said. "It can’t hurt you," they said. They were wrong.',"I said one nice thing to a {noun} and now it follows me everywhere.","Can we take a moment to appreciate how the {adj} {noun} is just vibing?","Who put a tiny hat on the {noun}? Because that’s adorable.","My life has been different ever since the {noun} started {verb}ing.","Raise your hand if you’ve ever been personally attacked by a {adj} {noun}.",'"Don’t be weird," they said. So I became a {noun} instead.',"Do {noun}s have feelings? Asking for a {adj} friend.","I trusted the {noun} and all I got was a glitter-covered sock.","Plot twist: the {adj} {noun} was inside us all along.","In the glow of the {adj} moon, the {noun} began to {verb}.","A sprinkle of {adj} dust made the {noun} {verb} through the air.","The {noun} whispered a {adj} secret that made everyone {verb}.","Everything felt {adj} and {adj}, especially when the {noun} {verb}ed.","The {noun} is {verb}ing! The {noun} is {verb}ing! AAAAA!","Glitch in the {noun}: the {adj} {noun} just {verb}ed out of existence.","The {adj} {noun} {verb} and {verb} all over the {adj} {noun}!","Oops! {noun}s {verb}ed into the {adj} {noun} while {verb}ing crazily.","{adj}, {adj}, and more {adj} {noun}s just {verb}ed by!","Why does the {adj} {noun} keep {verb}ing and {verb}ing without stopping?","Look! A {adj} {noun}, a {adj} {noun}, and a {noun} all {verb}ing together!","Sometimes, the {noun} just {verb}s, then {verb}s again, and never stops being {adj}.","{noun}, {noun}, and {noun} — all {verb}ing and {verb}ing in a {adj} {noun}.","I saw a {adj} {noun} {verb}, then another {noun} {verb}ing with a {adj} {noun}.","The {noun} {verb}s {verb} while the {adj} {noun} {verb}s and the {noun} just {verb}s.","Can a {adj} {noun} {verb} {verb} without a {adj} {noun} watching?","Whoa! The {adj} {noun} just {verb}ed... and then {verb}ed again!","Hey... did you see that {adj} {noun} {verb} over there?","Umm, the {noun} is {verb}ing but also {verb}ing and {verb}ing!","Lol! {noun}s {verb} so {adj}ly, it’s impossible not to giggle.",'"Hey! What’s up?" asked the {adj} {noun}, who {verb}ed loudly.','"I’m just a {adj} {noun} trying to {verb}, you know?"','"Did you see the {adj} {noun} that just {verb}ed in the pudding?"','"No way! The {noun} {verb}s better than me!"','"Wait, the {adj} {noun} said it would {verb}, but it {verb}ed instead!"',"Once upon a {adj} {noun}, a group of {adj} {noun}s {verb}ed through the {adj} forest, singing {adj} songs and eating {noun}s made of pudding.","The legend tells of a {adj} {noun} who could {verb} faster than any {noun} ever seen, leaving trails of {adj} sparkles behind.","Every day, the {adj} {noun} would {verb} around the {adj} meadow, trying to convince the {noun}s to join the grand pudding party.","No one knows why the {adj} {noun} suddenly {verb}ed and then {verb}ed again, but everyone agrees it was the cutest thing they ever saw.","In the kingdom of {adj} {noun}s, only the bravest {noun} dared to {verb} the giant pudding monster, armed with nothing but {adj} smiles and jellybeans.","{adj} {noun} {verb} {verb} {verb} {noun} {verb} {adj} {noun} {verb} {noun}!","{noun} {noun} {verb} {adj} {noun} and then {verb} {verb} the {adj} {noun}.","{verb} the {adj} {noun}, then {verb} the {noun} while {verb}ing {adj}ly.","Can the {adj} {noun} {verb} and {verb} the {adj} {noun} at the same time?","{noun} {verb} {noun} {verb}, but the {adj} {noun} {verb}s better.","Boop! The {adj} {noun} just {verb}ed in the pudding.","Bloop bloop, the {noun} is {verb}ing all over again!","Mlem mlem, a {adj} {noun} {verb}s quietly in the corner.","Splat! {noun} {verb}ed right on the {adj} {noun}.","Yum! A {adj} {noun} just {verb}ed in my mouth.","Do {noun}s really {verb} when nobody’s watching?","Why does the {adj} {noun} always {verb} at midnight?","Can a {noun} be too {adj} to {verb} properly?","Is it normal for a {adj} {noun} to {verb} three times in a row?","Who taught the {noun} to {verb} like that?","Wait, did the {adj} {noun} just {verb} itself?","I can’t believe the {noun} {verb}ed into a {adj} {noun}!","Suddenly, a {adj} {noun} appeared and started to {verb} wildly.","That {noun} was {verb}ing so {adj}ly it broke the pudding meter.","Everyone’s talking about the {adj} {noun} that {verb}ed out of nowhere."];class or{static#mt=er;static#pt=tr;static#ft=rr;static#yt=ir;static#gt=nr;static#wt=sr;static#bt(e,t){if(!Array.isArray(e))throw new TypeError(`${t} must be an array of strings`);if(!e.every(e=>"string"==typeof e))throw new TypeError(`${t} must contain only strings`);if(0===e.length)throw new Error(`${t} cannot be empty`)}static get defaultWords(){return[...this.#mt]}static set defaultWords(e){this.#bt(e,"defaultWords"),this.#mt=[...e]}static get defaultEmojis(){return[...this.#pt]}static set defaultEmojis(e){this.#bt(e,"defaultEmojis"),this.#pt=[...e]}static get defaultNouns(){return[...this.#ft]}static set defaultNouns(e){this.#bt(e,"defaultNouns"),this.#ft=[...e]}static get defaultVerbs(){return[...this.#yt]}static set defaultVerbs(e){this.#bt(e,"defaultVerbs"),this.#yt=[...e]}static get defaultAdjectives(){return[...this.#gt]}static set defaultAdjectives(e){this.#bt(e,"defaultAdjectives"),this.#gt=[...e]}static get defaultTemplates(){return[...this.#wt]}static set defaultTemplates(e){this.#bt(e,"defaultTemplates"),this.#wt=[...e]}#h=!1;get destroyed(){return this.#h}#vt={minLength:10,maxLength:300,readable:!0,useEmojis:!0,includeNumbers:!0,includeSymbols:!0,allowWeirdSpacing:!1,emojiSet:[],wordSet:[],mode:"mixed",grammar:{templates:[],nouns:[],verbs:[],adjectives:[]},repeatWords:!0,emojiPlacement:"inline",line:{minLength:20,maxLength:120,emojiChance:.3}};get config(){return Zt(this.#h),structuredClone(this.#vt)}#Et="!@#$%^&*()-_=+[]{}|;:,.<>?/\\~".split("");get symbols(){return Zt(this.#h),structuredClone(this.#Et)}constructor(e={}){const{minLength:t,maxLength:r,readable:i,useEmojis:n,includeNumbers:s,includeSymbols:o,allowWeirdSpacing:a,emojiSet:l,wordSet:u,mode:h,grammar:d,repeatWords:c,emojiPlacement:m,paragraphs:p,line:f}=e;if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.minLength must be an integer >= 1");if(void 0!==r&&(!Number.isInteger(r)||r<1))throw new TypeError("config.maxLength must be an integer >= 1");if(void 0!==t&&void 0!==r&&t>r)throw new RangeError("config.minLength cannot be greater than config.maxLength");if(void 0!==i&&"boolean"!=typeof i)throw new TypeError("config.readable must be a boolean");if(void 0!==n&&"boolean"!=typeof n)throw new TypeError("config.useEmojis must be a boolean");if(void 0!==s&&"boolean"!=typeof s)throw new TypeError("config.includeNumbers must be a boolean");if(void 0!==o&&"boolean"!=typeof o)throw new TypeError("config.includeSymbols must be a boolean");if(void 0!==a&&"boolean"!=typeof a)throw new TypeError("config.allowWeirdSpacing must be a boolean");if(void 0!==l&&!Array.isArray(l))throw new TypeError("config.emojiSet must be an array of strings");if(void 0!==u&&!Array.isArray(u))throw new TypeError("config.wordSet must be an array of strings");if(void 0!==h&&!["mixed","readable","chaotic","natural"].includes(h))throw new RangeError('config.mode must be one of: "mixed", "readable", "chaotic", "natural');if(void 0!==d){if("object"!=typeof d||null===d)throw new TypeError("config.grammar must be an object");const{templates:e,nouns:t,verbs:r,adjectives:i}=d;if(void 0!==e&&!Array.isArray(e))throw new TypeError("config.grammar.templates must be an array of strings");if(void 0!==t&&!Array.isArray(t))throw new TypeError("config.grammar.nouns must be an array of strings");if(void 0!==r&&!Array.isArray(r))throw new TypeError("config.grammar.verbs must be an array of strings");if(void 0!==i&&!Array.isArray(i))throw new TypeError("config.grammar.adjectives must be an array of strings")}if(void 0!==c&&"boolean"!=typeof c)throw new TypeError("config.repeatWords must be a boolean");if(void 0!==m&&!["inline","end","none"].includes(m))throw new RangeError('config.emojiPlacement must be one of: "inline", "end", "none"');if(void 0!==p){if("object"!=typeof p)throw new TypeError("config.paragraphs must be an object or null");const{min:e,max:t}=p;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.paragraphs.min must be an integer >= 1");if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.paragraphs.max must be an integer >= 1");if(void 0!==e&&void 0!==t&&e>t)throw new RangeError("config.paragraphs.min cannot be greater than config.paragraphs.max")}if(void 0!==f){if("object"!=typeof f||null===f)throw new TypeError("config.line must be an object");const{minLength:e,maxLength:t,emojiChance:r}=f;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.line.minLength must be an integer >= 1");if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.line.maxLength must be an integer >= 1");if(void 0!==e&&void 0!==t&&e>t)throw new RangeError("config.line.minLength cannot be greater than config.line.maxLength");if(void 0!==r&&("number"!=typeof r||r<0||r>1))throw new RangeError("config.line.emojiChance must be a number between 0 and 1")}this.#vt.emojiSet=[...or.#pt],this.#vt.wordSet=[...or.#mt],this.#vt.grammar.templates=[...or.#wt],this.#vt.grammar.nouns=[...or.#ft],this.#vt.grammar.verbs=[...or.#yt],this.#vt.grammar.adjectives=[...or.#gt],Object.assign(this.#vt,e)}configure(e={}){return Zt(this.#h),Object.assign(this.#vt,e),this}setGrammarTemplates(...e){return Zt(this.#h),this.#vt.grammar.templates=e.flat(),this}addGrammarTemplates(...e){return Zt(this.#h),this.#vt.grammar.templates.push(...e.flat()),this}setGrammarNouns(...e){return Zt(this.#h),this.#vt.grammar.nouns=e.flat(),this}addGrammarNouns(...e){return Zt(this.#h),this.#vt.grammar.nouns.push(...e.flat()),this}setGrammarVerbs(...e){return Zt(this.#h),this.#vt.grammar.verbs=e.flat(),this}addGrammarVerbs(...e){return Zt(this.#h),this.#vt.grammar.verbs.push(...e.flat()),this}setGrammarAdjectives(...e){return Zt(this.#h),this.#vt.grammar.adjectives=e.flat(),this}addGrammarAdjectives(...e){return Zt(this.#h),this.#vt.grammar.adjectives.push(...e.flat()),this}removeGrammarTemplates(...e){Zt(this.#h);const t=new Set(e.flat());return this.#vt.grammar.templates=this.#vt.grammar.templates.filter(e=>!t.has(e)),this}removeGrammarNouns(...e){Zt(this.#h);const t=new Set(e.flat());return this.#vt.grammar.nouns=this.#vt.grammar.nouns.filter(e=>!t.has(e)),this}removeGrammarVerbs(...e){Zt(this.#h);const t=new Set(e.flat());return this.#vt.grammar.verbs=this.#vt.grammar.verbs.filter(e=>!t.has(e)),this}removeGrammarAdjectives(...e){Zt(this.#h);const t=new Set(e.flat());return this.#vt.grammar.adjectives=this.#vt.grammar.adjectives.filter(e=>!t.has(e)),this}setWords(...e){return Zt(this.#h),this.#vt.wordSet=e.flat(),this}addWords(...e){return Zt(this.#h),this.#vt.wordSet.push(...e.flat()),this}removeWords(...e){Zt(this.#h);const t=new Set(e.flat());return this.#vt.wordSet=this.#vt.wordSet.filter(e=>!t.has(e)),this}setEmojis(...e){return Zt(this.#h),this.#vt.emojiSet=e.flat(),this}addEmojis(...e){return Zt(this.#h),this.#vt.emojiSet.push(...e.flat()),this}removeEmojis(...e){Zt(this.#h);const t=new Set(e.flat());return this.#vt.emojiSet=this.#vt.emojiSet.filter(e=>!t.has(e)),this}_getRandomItem(e){return e[Math.floor(Math.random()*e.length)]}_generateChunk(){const{wordSet:e,emojiSet:t,includeNumbers:r,includeSymbols:i,useEmojis:n,readable:s,mode:o,emojiPlacement:a}=this.#vt;if("natural"===o)return this._generateNaturalSentence();const l=[];return(s||"readable"===o||"mixed"===o)&&l.push(this._getRandomItem(e)),"chaotic"!==o&&"mixed"!==o||l.push(Math.random().toString(36).slice(2)),r&&l.push(Math.floor(99999*Math.random()).toString()),i&&l.push(this._getRandomItem(this.#Et)),"inline"===a&&n&&t.length&&l.push(this._getRandomItem(t)),this._getRandomItem(l)}_generateNaturalSentence(){const{templates:e,nouns:t,verbs:r,adjectives:i}=this.#vt.grammar;return this._getRandomItem(e).replace(/{noun}/g,()=>this._getRandomItem(t)).replace(/{verb}/g,()=>this._getRandomItem(r)).replace(/{adj}/g,()=>this._getRandomItem(i))}_generateLine(e,t){const{allowWeirdSpacing:r,repeatWords:i,readable:n,emojiSet:s,useEmojis:o,emojiPlacement:a,line:l}=this.#vt,u=[];for(t??=new Set;u.join(" ").length<e;){let e=this._generateChunk();!i&&t.has(e)||(t.add(e),r&&(Math.random()<.1&&(e="\n"+e),Math.random()<.1&&(e=" "+e),Math.random()<.05&&(e=e.toUpperCase())),u.push(e))}let h=u.join(n?" ":"");return"end"===a&&o&&s.length&&Math.random()<(l?.emojiChance||0)&&(h+=" "+this._getRandomItem(s)),h}_generateParagraphLines(e){const{line:t}=this.#vt,r=[],i=new Set;let n=0;for(;n<e;){const s=Math.floor(Math.random()*(t.maxLength-t.minLength+1)+t.minLength),o=Math.min(s,e-n);r.push(this._generateLine(o,i)),n+=o}return r}generate(){Zt(this.#h);const{minLength:e,maxLength:t,paragraphs:r}=this.#vt,i=Math.floor(Math.random()*(t-e+1))+e;if(r&&"object"==typeof r){const e=Math.floor(Math.random()*(r.max-r.min+1))+r.min,t=Math.floor(i/e),n=[];for(let r=0;r<e;r++){const e=this._generateParagraphLines(t);n.push(e.join("\n"))}return n.join("\n\n")}return this._generateParagraphLines(i).join("\n")}destroy(){this.destroyed||(this.#Et=[],this.#vt.emojiSet=[],this.#vt.wordSet=[],this.#vt.grammar.templates=[],this.#vt.grammar.nouns=[],this.#vt.grammar.verbs=[],this.#vt.grammar.adjectives=[],this.#h=!0)}}const ar=or;var lr=r.cjs(function(e,t){var r,i="object"==typeof Reflect?Reflect:null,n=i&&"function"==typeof i.apply?i.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise(function(r,i){function n(r){e.removeListener(t,s),i(r)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",n),r([].slice.call(arguments))}y(e,t,s,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&y(e,"error",t,{once:!0})}(e,n)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var a=10;function l(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function h(e,t,r,i){var n,s,o,a;if(l(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),void 0===o)o=s[t]=r,++e._eventsCount;else if("function"==typeof o?o=s[t]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(n=u(e))>0&&o.length>n&&!o.warned){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=o.length,a=h,console&&console.warn&&console.warn(a)}return e}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function c(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=d.bind(i);return n.listener=r,i.wrapFn=n,n}function m(e,t,r){var i=e._events;if(void 0===i)return[];var n=i[t];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(n):f(n,n.length)}function p(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function f(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}function y(e,t,r,i){if("function"==typeof e.on)i.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function n(s){i.once&&e.removeEventListener(t,n),r(s)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,s=this._events;if(void 0!==s)i=i&&void 0===s.error;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var l=s[e];if(void 0===l)return!1;if("function"==typeof l)n(l,this,t);else{var u=l.length,h=f(l,u);for(r=0;r<u;++r)n(h[r],this,t)}return!0},o.prototype.addListener=function(e,t){return h(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return h(this,e,t,!0)},o.prototype.once=function(e,t){return l(t),this.on(e,c(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,c(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,i,n,s,o;if(l(t),void 0===(i=this._events))return this;if(void 0===(r=i[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(n=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,n=s;break}if(n<0)return this;0===n?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,n),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,o||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,i;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var n,s=Object.keys(r);for(i=0;i<s.length;++i)"removeListener"!==(n=s[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},o.prototype.listeners=function(e){return m(this,e,!0)},o.prototype.rawListeners=function(e){return m(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}});const ur=ee("TinySmartScroller");class hr extends lr.EventEmitter{static Utils={...n,TinyHtml:It};#Tt=new WeakMap;#St=new WeakMap;#xt=new WeakMap;#At=new WeakMap;#Ct=new WeakMap;#It=new WeakMap;#Mt=null;#Dt=null;#kt=new Set(["IMG","IFRAME","VIDEO"]);#Nt=null;#Lt=!1;#_t=!1;#jt=!1;#Rt=!1;#Pt=!1;#$t=!1;#Ot=!1;#Ht=!1;#Ft="";#Bt=!1;#h=!1;#zt=!1;#Wt=!1;#Vt=!1;#qt=!1;#Kt=0;#Jt=0;#Ut=0;#Gt=0;#Yt=0;#Xt;#Qt;#F;#Zt=new Set;constructor(e,{extraScrollBoundary:t=0,autoScrollBottom:r=!0,observeMutations:i=!0,preserveScrollOnLayoutShift:n=!0,debounceTime:s=100,querySelector:o=null,attributeFilter:a=["class","style","src","data-*","height","width"]}={}){if(super(),!(e instanceof Element||e===window))throw new TypeError("TinySmartScroller: 'target' must be a DOM Element or 'window', but got "+typeof e);if("number"!=typeof t||Number.isNaN(t))throw new TypeError(`TinySmartScroller: 'extraScrollBoundary' must be a valid number, received ${t}`);if("boolean"!=typeof r)throw new TypeError("TinySmartScroller: 'autoScrollBottom' must be a boolean, received "+typeof r);if("boolean"!=typeof i)throw new TypeError("TinySmartScroller: 'observeMutations' must be a boolean, received "+typeof i);if("boolean"!=typeof n)throw new TypeError("TinySmartScroller: 'preserveScrollOnLayoutShift' must be a boolean, received "+typeof n);if("number"!=typeof s||s<0||Number.isNaN(s))throw new TypeError(`TinySmartScroller: 'debounceTime' must be a non-negative number, received ${s}`);if(null!==o&&"string"!=typeof o)throw new TypeError("TinySmartScroller: 'querySelector' must be a string or null, received "+typeof o);if(!(null===a||Array.isArray(a)||a instanceof Set))throw new TypeError("TinySmartScroller: 'attributeFilter' must be an array, Set, or null. Got "+typeof a);let l;this.#F=e,this.#Qt=e instanceof Window?document.documentElement:e,this.#Bt=e instanceof Window,this.#Wt=r,this.#Vt=i,this.#qt=n,this.#Kt=s,this.#Yt=t,this.#Ft=o||"",this.#Xt=new Set(a||void 0),this.#Nt=()=>{this._scrollDataUpdater(),clearTimeout(l),l=setTimeout(()=>this._onScroll(),this.#Kt)},(this.#Bt?window:this.#Qt).addEventListener("scroll",this.#Nt,{passive:!0}),this.#Vt&&(this._observeMutations(),this._observeResizes(this.#Qt.children)),this._scrollDataUpdater()}getSimpleOnHeight(e=[]){if(ur(this.#h),!Array.isArray(e))throw new TypeError("getSimpleOnHeight(filter): filter must be an array of tag names");return(t,r,i)=>{if(e.length>0&&!e.includes(t.tagName)||i.now!==i.old)return;const n=r.old;return{height:r.now.height-n.height,width:0}}}addSimpleOnHeight(e){if(ur(this.#h),!Array.isArray(e))throw new TypeError("addSimpleOnHeight(filter): filter must be an array of tag names");const t=this.getSimpleOnHeight(e);return this.onSize(t),t}getLoadTags(){return ur(this.#h),Array.from(this.#kt)}addLoadTag(e){if(ur(this.#h),"string"!=typeof e)throw new TypeError("addLoadTag(tag): tag must be a string");this.#kt.add(e.toUpperCase())}removeLoadTag(e){if(ur(this.#h),"string"!=typeof e)throw new TypeError("removeLoadTag(tag): tag must be a string");this.#kt.delete(e.toUpperCase())}hasLoadTag(e){if(ur(this.#h),"string"!=typeof e)throw new TypeError("hasLoadTag(tag): tag must be a string");return this.#kt.has(e.toUpperCase())}resetLoadTags(e=!1){if(ur(this.#h),"boolean"!=typeof e)throw new TypeError("resetLoadTags(addDefault): addDefault must be a boolean");this.#kt.clear(),e&&(this.#kt.add("IMG"),this.#kt.add("IFRAME"),this.#kt.add("VIDEO"))}getAttributeFilters(){return ur(this.#h),Array.from(this.#Xt)}addAttributeFilter(e){if(ur(this.#h),"string"!=typeof e)throw new TypeError("addAttributeFilter(attr): attr must be a string");this.#Xt.add(e)}removeAttributeFilter(e){if(ur(this.#h),"string"!=typeof e)throw new TypeError("removeAttributeFilter(attr): attr must be a string");this.#Xt.delete(e)}hasAttributeFilter(e){if(ur(this.#h),"string"!=typeof e)throw new TypeError("hasAttributeFilter(attr): attr must be a string");return this.#Xt.has(e)}resetAttributeFilters(e=!1){if(ur(this.#h),"boolean"!=typeof e)throw new TypeError("resetAttributeFilters(addDefault): addDefault must be a boolean");this.#Xt.clear(),e&&["class","style","src","data-*","height","width"].forEach(e=>this.#Xt.add(e))}onSize(e){if(ur(this.#h),"function"!=typeof e)throw new TypeError("onSize(handler): handler must be a function");this.#Zt.add(e)}offSize(e){if(ur(this.#h),"function"!=typeof e)throw new TypeError("offSize(handler): handler must be a function");this.#Zt.delete(e)}_scrollDataUpdater(){const e=new Map;return this.#Qt.querySelectorAll(this.#Ft||"*").forEach(t=>{const r=this.#xt.get(t)??!1;this.#At.set(t,r);const i=It.isInContainer(this.#Qt,t);this.#xt.set(t,i),e.set(t,{oldIsVisible:r,isVisible:i})}),e}_onScroll(){if(this.#h)return;const e=this._scrollDataUpdater(),t=this.#Qt,r=t.scrollTop,i=t.scrollHeight,n=t.clientHeight,s={scrollTop:r,scrollHeight:i,clientHeight:n};let o=null,a=null;const l=0===r,u=r+n>=i-1,h=r<=0+this.#Yt,d=r+n>=i-1-this.#Yt;l&&u?o="all":l?o="top":u&&(o="bottom"),h&&d?a="all":h?a="top":d&&(a="bottom"),this.#_t=this.#$t??!1,this.#Lt=this.#Pt??!1,this.#jt=this.#Ot??!1,this.#Rt=this.#Ht??!1,this.#$t=l,this.#Pt=u,this.#Ot=h,this.#Ht=d,this.#zt=!(this.#Wt&&this.#Pt),this.#Gt=i-r-n,this.emit("onScrollBoundary",{status:o,...s,scrollCache:e}),this.emit("onExtraScrollBoundary",{status:a,...s,scrollCache:e}),this.#zt?this.emit("onScrollPause",{...s,scrollCache:e}):this.emit("onAutoScroll",{...s,scrollCache:e})}_fixScroll(e=[]){if(this.#h)return;if(!Array.isArray(e))throw new TypeError("_fixScroll: targets must be an array of Elements");const t=this.#Qt.scrollHeight,r=this.#Qt.scrollTop,i=this.#Qt.scrollHeight-this.#Qt.scrollTop-this.#Qt.clientHeight,n=this.#Qt.scrollHeight-t,s=()=>{const t={height:0,width:0};for(const r of e){const e=this.#Tt.get(r)||{height:0,width:0},i=this.#St.get(r)||{height:0,width:0};this.#Zt.forEach(n=>{const s=n(r,{old:e,now:i},{old:this.#Ut,now:this.#Jt});if(this.#xt.get(r)||this.#Ct.get(r)){if(void 0!==s&&"object"!=typeof s)throw new Error("_fixScroll: size filter must return an object or undefined");if(void 0===s)return;t.height=s.height,t.width=s.width}})}if("number"!=typeof t.height&&t.height<0)throw new Error("_fixScroll: invalid scrollSize.height value");if("number"!=typeof t.width&&t.width<0)throw new Error("_fixScroll: invalid scrollSize.width value");if(0!==t.height||0!==t.width)for(const t of e)this.#Ct.set(t,this.#xt.get(t)??!1),this.#It.set(t,this.#At.get(t)??!1);return t};if(this.#Ut>0&&It.hasScroll(this.#Qt).v&&this.#Wt&&this.#qt&&!this.#Pt&&!this.#$t){const e=s();this.#Qt.scrollTop=r+n+e.height,e.width>0&&(this.#Qt.scrollLeft=this.#Qt.scrollLeft+e.width)}else!this.#zt&&this.#Wt?(s(),this.scrollToBottom()):this.#Wt||this.#Pt||(s(),this.#Qt.scrollTop=this.#Qt.scrollHeight-this.#Qt.clientHeight-i)}_observeMutations(){this.#Dt=new MutationObserver(e=>{this.#h||(this._scrollDataUpdater(),this.#Ut=this.#Jt,this.#Jt=this.#Qt.childElementCount,e.forEach(e=>{e.addedNodes.forEach(e=>{if(e instanceof Element&&1===e.nodeType&&(this._observeResizes([e]),this._listenLoadEvents(e),this.#Ft)){const t=e.querySelectorAll(this.#Ft);this._observeResizes(t),this._listenLoadEvents(t)}})}),this._fixScroll())}),this.#Dt.observe(this.#Qt,{childList:!0,subtree:!0,attributes:!0,attributeFilter:this.#Xt.size>0?Array.from(this.#Xt):void 0})}_observeResizes(e){this.#Mt||(this.#Mt=new ResizeObserver(e=>{if(this.#h)return;this._scrollDataUpdater();const t=[];for(const r of e){const e=r.target,i=this.#St.get(e);i&&this.#Tt.set(e,i);const{width:n,height:s}=r.contentRect;this.#St.set(e,{width:n,height:s}),t.push(e)}this._fixScroll(t)})),Array.from(e).forEach(e=>{if(!this.#Mt)throw new Error("_observeResizes: ResizeObserver instance is not initialized");this.#Mt.observe(e)})}_listenLoadEvents(e){this.#h||(e instanceof NodeList?Array.from(e):[e]).forEach(e=>{this.#kt.has(e.tagName)&&(e.complete||e.addEventListener("load",()=>{this._scrollDataUpdater(),!this.#zt&&this.#Wt&&this.scrollToBottom()}))})}get target(){return this.#F}get targetElement(){return this.#Qt}getOldSize(e){return ur(this.#h),this.#Tt.get(e)??null}getNewSize(e){return ur(this.#h),this.#St.get(e)??null}wasVisible(e){return ur(this.#h),this.#At.get(e)??!1}isVisible(e){return ur(this.#h),this.#xt.get(e)??!1}wasTimedVisible(e){return ur(this.#h),this.#It.get(e)??!1}isTimedVisible(e){return ur(this.#h),this.#Ct.get(e)??!1}setExtraScrollBoundary(e){if(ur(this.#h),"number"!=typeof e||Number.isNaN(e))throw new TypeError("setExtraScrollBoundary(value): value must be a valid number");this.#Yt=e}getExtraScrollBoundary(){return ur(this.#h),this.#Yt}getLastKnownScrollBottomOffset(){return ur(this.#h),this.#Gt}scrollToBottom(){ur(this.#h),this.#Qt.scrollTop=this.#Qt.scrollHeight}scrollToTop(){ur(this.#h),this.#Qt.scrollTop=0}isAtCustomBottom(){return ur(this.#h),this.#Ht}isAtCustomTop(){return ur(this.#h),this.#Ot}isAtBottom(){return ur(this.#h),this.#Pt}isAtTop(){return ur(this.#h),this.#$t}isPastAtBottom(){return ur(this.#h),this.#Lt}isPastAtTop(){return ur(this.#h),this.#_t}isPastAtCustomTop(){return ur(this.#h),this.#jt}isPastAtCustomBottom(){return ur(this.#h),this.#Rt}isScrollPaused(){return ur(this.#h),this.#zt}isWindow(){return ur(this.#h),this.#Bt}isDestroyed(){return this.#h}getAutoScrollBottom(){return ur(this.#h),this.#Wt}getObserveMutations(){return ur(this.#h),this.#Vt}getPreserveScrollOnLayoutShift(){return ur(this.#h),this.#qt}getDebounceTime(){return ur(this.#h),this.#Kt}getElemAmount(){return ur(this.#h),this.#Jt}getPrevElemAmount(){return ur(this.#h),this.#Ut}getQuerySelector(){return ur(this.#h),this.#Ft}destroy(){if(this.#h)return;this.#Dt&&(this.#Dt.disconnect(),this.#Dt=null),this.#Mt&&(this.#Mt.disconnect(),this.#Mt=null);const e=this.#Bt?window:this.#Qt;this.#Nt&&e.removeEventListener("scroll",this.#Nt),this.#Tt=new WeakMap,this.#St=new WeakMap,this.#xt=new WeakMap,this.#At=new WeakMap,this.#Ct=new WeakMap,this.#It=new WeakMap,this.removeAllListeners(),this.#Zt.clear(),this.#kt.clear(),this.#h=!0}}const dr=hr,cr=class{#G;#er;#tr;constructor(e,{openTag:t="[",closeTag:r="]"}={}){if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new TypeError("Element must be an input or textarea.");if("string"!=typeof t)throw new TypeError("openTag must be a string.");if("string"!=typeof r)throw new TypeError("closeTag must be a string.");this.#G=e,this.#er=t,this.#tr=r}getOpenTag(){return this.#er}getCloseTag(){return this.#tr}setOpenTag(e){if("string"!=typeof e)throw new TypeError("Open tag must be a string.");this.#er=e}setCloseTag(e){if("string"!=typeof e)throw new TypeError("Close tag must be a string.");this.#tr=e}ensureFocus(){return document.activeElement!==this.#G&&this.#G.focus(),this}focus(){return this.#G.focus(),this}getSelectionRange(){return{start:this.#G.selectionStart??NaN,end:this.#G.selectionEnd??NaN}}setSelectionRange(e,t,r=!0){if("number"!=typeof e||"number"!=typeof t)throw new TypeError("start and end must be numbers.");if("boolean"!=typeof r)throw new TypeError("preserveScroll must be a boolean.");const i=this.#G.scrollTop,n=this.#G.scrollLeft;return this.#G.setSelectionRange(e,t),r&&(this.#G.scrollTop=i,this.#G.scrollLeft=n),this}getValue(){return this.#G.value}setValue(e){if("string"!=typeof e)throw new TypeError("Value must be a string.");return this.#G.value=e,this}getSelectedText(){const{start:e,end:t}=this.getSelectionRange();return this.#G.value.slice(e,t)}insertText(e,{newCursor:t="end",autoSpacing:r=!1,autoSpaceLeft:i=r,autoSpaceRight:n=r}={}){if("string"!=typeof e)throw new TypeError("Text must be a string.");if(!["start","end","preserve"].includes(t))throw new TypeError("newCursor must be one of 'start', 'end', or 'preserve'.");if("boolean"!=typeof r)throw new TypeError("autoSpacing must be a boolean.");if("boolean"!=typeof i)throw new TypeError("autoSpaceLeft must be a boolean.");if("boolean"!=typeof n)throw new TypeError("autoSpaceRight must be a boolean.");const{start:s,end:o}=this.getSelectionRange(),a=this.#G.value,l=a[s-1]||"",u=a[o]||"",h=`${i&&l&&!/\s/.test(l)?" ":""}${e}${n&&u&&!/\s/.test(u)?" ":""}`,d=a.slice(0,s)+h+a.slice(o);this.setValue(d);let c=s;return"end"===t?c=s+h.length:"preserve"===t&&(c=s),this.setSelectionRange(c,c),this}deleteSelection(){return this.insertText(""),this}transformSelection(e){if("function"!=typeof e)throw new TypeError("transformer must be a function.");const{start:t}=this.getSelectionRange(),r=e(this.getSelectedText());return this.insertText(r),this.setSelectionRange(t,t+r.length),this}surroundSelection(e,t){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("prefix and suffix must be strings.");const r=this.getSelectedText();return this.insertText(`${e}${r}${t}`),this}moveCaret(e){if("number"!=typeof e)throw new TypeError("offset must be a number.");const{start:t}=this.getSelectionRange(),r=Math.max(0,t+e);return this.setSelectionRange(r,r),this}selectAll(){return this.setSelectionRange(0,this.#G.value.length),this}expandSelection(e,t){if("number"!=typeof e||"number"!=typeof t)throw new TypeError("before and after must be numbers.");const{start:r,end:i}=this.getSelectionRange(),n=Math.max(0,r-e),s=Math.min(this.#G.value.length,i+t);return this.setSelectionRange(n,s),this}replaceAll(e,t){if(!(e instanceof RegExp))throw new TypeError("regex must be a RegExp.");if("function"!=typeof t)throw new TypeError("replacer must be a function.");const r=this.#G.value.replace(e,t);return this.setValue(r),this}replaceInSelection(e,t){if(!(e instanceof RegExp))throw new TypeError("regex must be a RegExp.");if("function"!=typeof t)throw new TypeError("replacer must be a function.");const{start:r,end:i}=this.getSelectionRange(),n=this.#G.value,s=n.slice(r,i).replace(e,t),o=n.slice(0,r)+s+n.slice(i);return this.setValue(o),this.setSelectionRange(r,r+s.length),this}toggleCode(e){if("string"!=typeof e)throw new TypeError("codeName must be a string.");const t=this.getSelectedText();if(t.startsWith(e)&&t.endsWith(e)){const r=t.slice(e.length,t.length-e.length);this.insertText(r)}else this.insertText(`${e}${t}${e}`);return this}_insertAttr(e){let t="";if(Array.isArray(e)){if(!e.every(e=>"string"==typeof e))throw new TypeError("All entries in attributes array must be strings.");t=e.map(e=>`${e}`).join(" ")}else{if("object"!=typeof e||null===e)throw new TypeError("attributes must be an object or an array of strings.");t=Object.entries(e).map(([e,t])=>{if("string"!=typeof t)throw new TypeError("All entries in attributes object must be strings.");return`${e}${t.length>0?`="${t}"`:""}`}).join(" ")}return t}wrapWithTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this._insertAttr(t),i=r?`${this.#er}${e} ${r}${this.#tr}`:`${this.#er}${e}${this.#tr}`,n=`${this.#er}/${e}${this.#tr}`;return this.surroundSelection(i,n),this}insertTag(e,t="",r={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");if("string"!=typeof t)throw new TypeError("content must be a string.");const i=this._insertAttr(r),n=i?`${this.#er}${e} ${i}${this.#tr}`:`${this.#er}${e}${this.#tr}`,s=`${this.#er}/${e}${this.#tr}`;return this.insertText(`${n}${t}${s}`),this}insertSelfClosingTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this._insertAttr(t),i=r?`${this.#er}${e} ${r}${this.#tr}`:`${this.#er}${e}${this.#tr}`;return this.insertText(i),this}toggleTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this.getSelectedText(),i=new RegExp(`^\\[${e}(\\s+[^\\]]*)?\\]`),n=new RegExp(`\\[/${e}\\]$`),s=i.test(r),o=n.test(r);if(s&&o){const e=r.replace(i,"").replace(n,"");this.insertText(e)}else{const i=this._insertAttr(t),n=i?`${this.#er}${e} ${i}${this.#tr}`:`${this.#er}${e}${this.#tr}`,s=`${this.#er}/${e}${this.#tr}`;this.insertText(`${n}${r}${s}`)}return this}},mr=class{#rr=!1;#ir=!1;#nr=null;#sr=null;constructor(){void 0!==navigator.clipboard&&null!==navigator.clipboard&&(this.#ir=!0,this.#nr=e=>navigator.clipboard.writeText(e),this.#sr=e=>navigator.clipboard.write([new ClipboardItem({[e.type]:e})])),this.#rr=void 0!==document.execCommand&&null!==document.execCommand}setCopyText(e){if("function"!=typeof e)throw new TypeError("setCopyText expected a function that returns Promise<void>.");this.#nr=e}setCopyBlob(e){if("function"!=typeof e)throw new TypeError("setCopyBlob expected a function that returns Promise<void>.");this.#sr=e}copyText(e){if("string"!=typeof e)throw new TypeError("copyText expected a string.");if(this.#nr)return this.#nr(e);if(this.#rr){const t=document.body,r=document.createElement("input");return r.style.position="fixed",r.style.opacity="0",r.value=e,t.append(r),r.select(),r.setSelectionRange(0,99999),document.execCommand("Copy"),r.remove(),new Promise(e=>e(void 0))}throw new Error("Clipboard API not found!")}copyBlob(e){if(!(e instanceof Blob))throw new TypeError("copyBlob expected a Blob instance.");return new Promise((t,r)=>{if(this.#sr)return this.#sr(e).then(t).catch(r);throw new Error("Clipboard API not found!")})}_handleBlob(e,t){return t.getType(e)}_handleText(e,t){return this._handleBlob(e,t).then(e=>e.text())}_readData(e=0,t=null,r=null,i=!1){return new Promise((n,s)=>{this._read(e).then(o=>{if(!o)return n(null);const a=[];let l=!0;const u=async(e,n)=>{if(l)if(null!==t&&"custom"!==t||"string"!=typeof r||!(!i&&e.startsWith(r)||i&&e===r))if(null!==t&&"text"!==t||"text/plain"!==e){if(null===t){l=!1;const t=await this._handleBlob(e,n);t&&a.push(t)}}else{l=!1;const t=await this._handleText(e,n);t&&a.push(t)}else{l=!1;const t=await this._handleBlob(e,n);t&&a.push(t)}},h=[],d=e=>{if(!(e instanceof ClipboardItem))throw new Error("Expected ClipboardItem when reading data.");for(const t in e.types)h.push(u(e.types[t],e))};if("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)&&e>-1)d(o),Promise.all(h).then(()=>{a[0]?n(a[0]):n(null)}).catch(s);else if(Array.isArray(o)){for(const e in o)d(o[e]);Promise.all(h).then(()=>n(a)).catch(s)}}).catch(s)})}async readText(e=0){const t=await this._readData(e,"text");if("string"!=typeof t)throw new Error("Failed to read text: expected string result.");return t}async readCustom(e=null,t=!1,r=0){const i=await this._readData(r,"custom",e,t);if(!(i instanceof Blob))throw new Error("Failed to read custom data: expected Blob.");return i}async readAllTexts(){const e=await this._readData(null,"text");if(!Array.isArray(e))throw new Error("Expected array of strings when reading all texts.");if(!e.every(e=>"string"==typeof e))throw new Error("Some values returned were not strings.");return e}async readAllCustom(e=null,t=!1){const r=await this._readData(null,"custom",e,t);if(!Array.isArray(r))throw new Error("Expected array of blobs when reading all custom items.");if(!r.every(e=>e instanceof Blob))throw new Error("Some values returned were not Blob instances.");return r}async readAllData(e=null,t=null){const r=await this._readData(null,e,t);if(!Array.isArray(r))throw new Error("Expected array result when reading all data.");return r}_read(e){return new Promise((t,r)=>{this.#ir||r(new Error("Clipboard API not found!")),navigator.clipboard.read().then(r=>{if("number"==typeof e){if(Number.isNaN(e)||!Number.isFinite(e)||e<0)throw new Error(`Invalid index value: ${e}`);r[e]?t(r[e]):t(null)}t(r)}).catch(r)})}async readIndex(e){const t=await this._read(e);if(null!==t&&!(t instanceof ClipboardItem))throw new Error(`Value at index ${e} is not a ClipboardItem.`);return t}async readAll(){const e=await this._read(null);if(!Array.isArray(e))throw new Error("Expected array result from clipboard read.");for(const t of e)if(!(t instanceof ClipboardItem))throw new Error("Invalid item type found in clipboard result.");return e}isExecCommandAvailable(){return this.#rr}isNavigatorClipboardAvailable(){return this.#ir}getCopyTextFunc(){return this.#nr}getCopyBlobFunc(){return this.#sr}};class pr{static _rca(e,t,r){let i=127,n=128;void 0===e&&(e=24),void 0===t&&(t="rgb"),!0===r&&(i=55,n=200);const s=2*Math.PI/e,o=[];for(let r=0;r<e;++r){const e=Math.sin(s*r+2)*i+n,a=Math.sin(s*r+0)*i+n,l=Math.sin(s*r+4)*i+n;switch(t){case"hex":o.push({hex:this.rgbToHex(Math.round(e),Math.round(a),Math.round(l))});break;case"rgb":o.push({r:e,g:a,b:l});break;case"hsl":const[t,r,i]=this.rgbaToHsl(Math.round(e),Math.round(a),Math.round(l));o.push({h:t,s:r,l:i})}}return o}static rcaRgb(e,t){return pr._rca(e,"rgb",t)}static rcaHsl(e,t){return pr._rca(e,"hsl",t)}static rcaHex(e,t){return pr._rca(e,"hex",t)}static randomColor(){return`#${Math.floor(16777216*Math.random()).toString(16).padStart(6,"0")}`}static parseInput(e,t){if("string"==typeof e){if((e=e.trim().toLowerCase()).startsWith("#"))return this.hexToRgba(e);if(e.startsWith("rgb"))return this.rgbStringToRgbaArray(e);if(e.startsWith("hsl"))return this.hslStringToRgbaArray(e)}if("number"==typeof e)return this.intToRgba(e);if(Array.isArray(e)&&(3===e.length||4===e.length)&&e.every(e=>"number"==typeof e)){if(t){const[t,r,i,n]=e;if(t<=360&&r<=100&&i<=100)return this.hslToRgba(t,r,i,n)}return[...e,1].slice(0,4)}throw new Error("Unsupported color format.")}static hslToInt(e,t,r){const[i,n,s]=pr.hslToRgba(e,t,r);return pr.rgbToInt(i,n,s)}static hslToHex(e,t,r){const[i,n,s]=pr.hslToRgba(e,t,r);return pr.rgbToHex(i,n,s)}static hslStringToRgbaArray(e){const t=e.match(/[\d.]+/g)?.map(Number);if(!t||t.length<3)return[0,0,0,1];const[r,i,n,s=1]=t;return this.hslToRgba(r,i,n,s)}static hslToRgba(e,t,r,i=1){r/=100;const n=t=>(t+e/30)%12,s=(t/=100)*Math.min(r,1-r),o=e=>r-s*Math.max(-1,Math.min(n(e)-3,Math.min(9-n(e),1)));return[Math.round(255*o(0)),Math.round(255*o(8)),Math.round(255*o(4)),i]}static hslToRgb(e,t,r,i=1){return pr.hslToRgba(e,t,r,i).slice(0,3)}static hexToInt(e){return parseInt(e.replace(/^#/,""),16)}static hexToHsl(e){const[t,r,i,n]=pr.hexToRgba(e);return pr.rgbaToHsl(t,r,i,n)}static hexToHsla(e){const[t,r,i,n]=pr.hexToRgba(e);return pr.rgbaToHsla(t,r,i,n)}static hexToRgba(e){3===(e=e.replace(/^#/,"")).length&&(e=e.split("").map(e=>e+e).join(""));const t=parseInt(e,16);return[t>>16&255,t>>8&255,255&t,1]}static hexToRgb(e){return this.hexToRgba(e).slice(0,3)}static rgbToHex(e,t,r){return"#"+[e,t,r].map(e=>e.toString(16).padStart(2,"0")).join("")}static rgbToInt(e,t,r){return e<<16|t<<8|r}static rgbaToHsla(e,t,r,i=1){e/=255,t/=255,r/=255;const n=Math.max(e,t,r),s=Math.min(e,t,r);let o=0,a=0,l=(n+s)/2;const u=n-s;if(0!==u){switch(a=u/(1-Math.abs(2*l-1)),n){case e:o=(t-r)/u+(t<r?6:0);break;case t:o=(r-e)/u+2;break;case r:o=(e-t)/u+4}o*=60}return[Math.round(o),Math.round(100*a),Math.round(100*l),i]}static rgbaToHsl(e,t,r,i){return this.rgbaToHsla(e,t,r,i).slice(0,3)}static rgbStringToRgbaArray(e){const t=e.match(/[\d.]+/g)?.map(Number);return t?[...t,1].slice(0,4):[]}static intToHsl(e){const[t,r,i,n]=pr.intToRgba(e);return pr.rgbaToHsl(t,r,i,n)}static intToHsla(e){const[t,r,i,n]=pr.intToRgba(e);return pr.rgbaToHsla(t,r,i,n)}static intToHex(e){return"#"+e.toString(16).padStart(6,"0")}static intToRgba(e){return[e>>16&255,e>>8&255,255&e,1]}#or="#000000";#ar=[0,0,0,0];#lr;constructor(e=null,t=!1){this.#lr=t,null!=e&&this.setColor(e)}setColor(e){this.#or=e;const t=this.#lr&&Array.isArray(e)&&e[0]<=360&&e[1]<=100&&e[2]<=100;this.#ar=pr.parseInput(e,t)}toHslaArray(){const[e,t,r,i]=this.#ar;return pr.rgbaToHsla(e,t,r,i)}toHslString(){const[e,t,r]=this.#ar,[i,n,s]=pr.rgbaToHsl(e,t,r);return`hsl(${i}, ${n}%, ${s}%)`}toHslaString(){const[e,t,r,i]=this.#ar,[n,s,o,a]=pr.rgbaToHsla(e,t,r,i);return`hsla(${n}, ${s}%, ${o}%, ${a??1})`}toRgbaArray(){return[...this.#ar]}toRgbString(){const[e,t,r]=this.#ar;return`rgb(${e}, ${t}, ${r})`}toRgbaString(){const[e,t,r,i]=this.#ar;return`rgba(${e}, ${t}, ${r}, ${i??1})`}toHex(){const[e,t,r]=this.#ar;return pr.rgbToHex(e,t,r)}toInt(){const[e,t,r]=this.#ar;return pr.rgbToInt(e,t,r)}getOriginal(){return this.#or}}const fr=pr,yr=(e,t=100)=>{if("function"!=typeof e)throw new TypeError("Expected 'getValue' to be a function.");if(!Number.isFinite(t)||t<=0)throw new TypeError("Expected 'checkInterval' to be a positive number.");return new Promise(r=>{const i=setInterval(()=>{e()&&(clearInterval(i),r())},t)})},gr=e=>{if("function"!=typeof e)throw new TypeError('The argument "baseFunction" must be a function.');let t=null;return{callback:async(...r)=>(null!==t||(t=(async()=>{try{const i=await e(...r);return t=null,i}catch(e){throw t=null,e}})()),t),getActivePromise:()=>t,resetActivePromise:()=>{t=null}}},wr=ee("TinyTimeout"),br=class{#ur=!1;#hr;#dr;#cr=null;#mr=new Map;constructor({cooldownWatcherTime:e=5e3,allowAutoConfigChange:t=!1}={}){if(!Number.isFinite(e)||e<=0)throw new TypeError("Expected 'cooldownWatcherTime' to be a positive number.");if("boolean"!=typeof t)throw new TypeError("Expected 'allowAutoConfigChange' to be a boolean.");this.#dr=e,this.#hr=t,this.setCooldownWatcherTime(e)}isDestroyed(){return this.#ur}getAllowAutoConfigChange(){return wr(this.#ur),this.#hr}getCooldownWatcherTime(){return wr(this.#ur),this.#dr}setAllowAutoConfigChange(e){if(wr(this.#ur),"boolean"!=typeof e)throw new TypeError("Expected 'value' to be a boolean.");this.#hr=e}setCooldownWatcherTime(e){if(wr(this.#ur),this.#ur)throw new Error("TinyTimeout has been destroyed.");if(!Number.isFinite(e)||e<=0)throw new TypeError("Expected 'value' to be a positive number.");this.#dr=e,this.#cr&&clearInterval(this.#cr),this.#cr=setInterval(()=>{this.#mr.forEach(e=>{e.now>0&&e.now--})},this.#dr)}set(e,t,r,i=null){if(wr(this.#ur),this.#ur)throw new Error("TinyTimeout has been destroyed.");if("string"!=typeof e||""===e.trim())throw new TypeError("Expected 'id' to be a non-empty string.");if("function"!=typeof t)throw new TypeError("Expected 'callback' to be a function.");if(!Number.isFinite(r)||r<0)throw new TypeError("Expected 'value' to be a non-negative number.");if(null!==i&&(!Number.isFinite(i)||i<0))throw new TypeError("Expected 'limit' to be null or a non-negative number.");let n=this.#mr.get(e);(!n||this.#hr&&r!==n.value)&&(n={value:r,now:0},this.#mr.set(e,n));const s=n.value*n.now;return n.now++,setTimeout(t,"number"==typeof i?Math.min(s,i):s)}static waitForTrue(e,t=100){return yr(e,t)}waitForTrue(e,t=100){if(wr(this.#ur),this.#ur)throw new Error("TinyTimeout has been destroyed.");if("function"!=typeof e)throw new TypeError("Expected 'getValue' to be a function.");if(null!==t&&(!Number.isFinite(t)||t<=0))throw new TypeError("Expected 'checkInterval' to be null or a positive number.");return yr(e,t??this.#dr)}destroy(){this.#ur||(this.#cr&&clearInterval(this.#cr),this.#cr=null,this.#mr.clear(),this.#ur=!0)}},vr=ee("TinyLocalStorage"),Er=new Map,Tr=new Map,Sr=new Set(["string","boolean","object","array",String,Boolean,Number,Object,Array,BigInt,Symbol]);class xr extends lr.EventEmitter{static hasJsonType(e){return Er.has(e)&&Tr.has(e)||Sr.has(e)}static registerJsonType(e,t,r,i=!1){if(Sr.has(e))throw new Error(`Cannot register type "${e}" because it is frozen.`);Er.set(e,t),Tr.set(e,r),i&&Sr.add(e)}static deleteJsonType(e){if(Sr.has(e))throw new Error(`Cannot remove type "${e}" because it is frozen.`);let t=!1;return Er.delete(e)&&(t=!0),Tr.delete(e)&&(t=!0),t}static encodeSpecialJson(e){if(void 0===e)return{__undefined__:!0};if(null===e)return{__null__:!0};for(const[t,r]of Er.entries())if("string"!=typeof t&&e instanceof t||typeof e===t)return r(e,xr.encodeSpecialJson);if(Array.isArray(e))return e.map(xr.encodeSpecialJson);if(g(e)){const t={};for(const r in e)t[r]=xr.encodeSpecialJson(e[r]);return t}return e}static decodeSpecialJson(e){const t=g(e);if(t){if(e.__undefined__)return;if(e.__null__)return null}if(Array.isArray(e))return e.map(xr.decodeSpecialJson);if(t){for(const[t,r]of Tr.entries())if(r.check&&r.check(e))return r.decode(e,xr.decodeSpecialJson);const t={};for(const r in e)t[r]=xr.decodeSpecialJson(e[r]);return t}return e}#h=!1;get destroyed(){return this.#h}#pr=window.localStorage;#fr=null;#ee=0;#yr=e=>this.emit("storage",e);constructor(e){if(super(),void 0!==e&&"string"!=typeof e)throw new TypeError("TinyLocalStorage: dbName must be a string if provided.");"string"==typeof e&&(this.#fr=`LSDB::${e}`),window.addEventListener("storage",this.#yr)}#gr(e){if("string"==typeof e&&e.startsWith("LSDB::"))throw new Error(`TinyLocalStorage: Key "${e}" may conflict with reserved dbKeys.`)}updateStorageVersion(e,t){if(vr(this.#h),"string"!=typeof this.#fr)throw new Error("TinyLocalStorage: Database key is not initialized. Set a valid dbName in the constructor.");if("number"!=typeof e||Number.isNaN(e)||e<1)throw new TypeError("TinyLocalStorage: version must be a positive number.");if("function"!=typeof t)throw new TypeError("TinyLocalStorage: onUpgrade must be a function.");const r=parseInt(localStorage.getItem(this.#fr),10)||0;if("number"!=typeof r||Number.isNaN(r)||r<0)throw new TypeError("TinyLocalStorage: saved version in localStorage is not a valid number.");if(e<r)throw new Error(`TinyLocalStorage: Cannot downgrade database version from ${r} to ${e}.`);e>r&&(t(r,e),localStorage.setItem(this.#fr,String(e)),this.#ee=e)}getDbKey(){return vr(this.#h),this.#fr}getVersion(){return vr(this.#h),this.#ee}setLocalStorage(e){if(vr(this.#h),!(e instanceof Storage))throw new TypeError("Argument must be a valid instance of Storage.");this.#pr=e}localStorageExists(){return vr(this.#h),this.#pr instanceof Storage}#wr(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return xr.encodeSpecialJson(t)}setJson(e,t){if(vr(this.#h),this.#gr(e),!(g(t)||Array.isArray(t)||t instanceof Map||t instanceof Set))throw new TypeError("The storage value is not a valid JSON-compatible structure.");const r=this.#wr(e,t);return this.emit("setJson",e,t),this.#pr.setItem(e,JSON.stringify(r))}#br(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const r=this.#pr.getItem(e),i={obj:()=>({}),array:()=>[],map:()=>new Map,set:()=>new Set},n="function"==typeof i[t]?i[t]():null;let s;try{s=JSON.parse(r)}catch{return n}return{decoded:xr.decodeSpecialJson(s),fallback:n}}getJson(e,t){vr(this.#h);const{decoded:r,fallback:i}=this.#br(e,t);return r instanceof Map||r instanceof Set||Array.isArray(r)||g(r)?r:i}setDate(e,t){if(vr(this.#h),this.#gr(e),!(t instanceof Date))throw new TypeError("Value must be a Date.");const r=this.#wr(e,t);return this.emit("setDate",e,t),this.#pr.setItem(e,JSON.stringify(r))}getDate(e){vr(this.#h);const t=this.#br(e).decoded;return t instanceof Date?t:null}setRegExp(e,t){if(vr(this.#h),this.#gr(e),!(t instanceof RegExp))throw new TypeError("Value must be a RegExp.");const r=this.#wr(e,t);return this.emit("setRegExp",e,t),this.#pr.setItem(e,JSON.stringify(r))}getRegExp(e){vr(this.#h);const t=this.#br(e).decoded;return t instanceof RegExp?t:null}setBigInt(e,t){if(vr(this.#h),this.#gr(e),"bigint"!=typeof t)throw new TypeError("Value must be a BigInt.");const r=this.#wr(e,t);return this.emit("setBigInt",e,t),this.#pr.setItem(e,JSON.stringify(r))}getBigInt(e){vr(this.#h);const t=this.#br(e).decoded;return"bigint"==typeof t?t:null}setSymbol(e,t){if(vr(this.#h),this.#gr(e),"symbol"!=typeof t)throw new TypeError("Value must be a Symbol.");const r=this.#wr(e,t);return this.emit("setSymbol",e,t),this.#pr.setItem(e,JSON.stringify(r))}getSymbol(e){vr(this.#h);const t=this.#br(e).decoded;return"symbol"==typeof t?t:null}getValue(e){return vr(this.#h),this.#br(e).decoded??null}setItem(e,t){if(vr(this.#h),this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("setItem",e,t),this.#pr.setItem(e,t)}getItem(e){if(vr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.#pr.getItem(e)}setString(e,t){if(vr(this.#h),this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("string"!=typeof t)throw new TypeError("Value must be a string.");return this.emit("setString",e,t),this.#pr.setItem(e,JSON.stringify({__string__:!0,value:t}))}getString(e){if(vr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#pr.getItem(e);try{if(t=JSON.parse(t),!g(t)||!t.__string__||"string"!=typeof t.value)return null;t=t.value}catch{t=null}return"string"==typeof t?t:null}setNumber(e,t){if(vr(this.#h),this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("number"!=typeof t)throw new TypeError("Value must be a number.");return this.emit("setNumber",e,t),this.#pr.setItem(e,String(t))}getNumber(e){if(vr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#pr.getItem(e);return"number"==typeof t||"string"==typeof t&&t.length>0&&(t=parseFloat(t),!Number.isNaN(t))?t:null}setBool(e,t){if(vr(this.#h),this.#gr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("boolean"!=typeof t)throw new TypeError("Value must be a boolean.");return this.emit("setBool",e,t),this.#pr.setItem(e,String(t))}getBool(e){if(vr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const t=this.#pr.getItem(e);if("boolean"==typeof t)return t;if("string"==typeof t){if("true"===t)return!0;if("false"===t)return!1}return null}removeItem(e){if(vr(this.#h),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("removeItem",e),this.#pr.removeItem(e)}clearLocalStorage(){return vr(this.#h),this.#pr.clear()}destroy(){this.#h||(window.removeEventListener("storage",this.#yr),this.removeAllListeners(),this.#h=!0)}}xr.registerJsonType(Map,(e,t)=>({__map__:!0,data:Array.from(e.entries()).map(([e,r])=>[e,t(r)])}),{check:e=>e.__map__,decode:(e,t)=>new Map(e.data.map(([e,r])=>[e,t(r)]))},!0),xr.registerJsonType(Set,(e,t)=>({__set__:!0,data:Array.from(e).map(t)}),{check:e=>e.__set__,decode:(e,t)=>new Set(e.data.map(t))},!0),xr.registerJsonType(Date,e=>({__date__:!0,value:e.toISOString()}),{check:e=>e.__date__,decode:e=>new Date(e.value)},!0),xr.registerJsonType(RegExp,e=>({__regexp__:!0,source:e.source,flags:e.flags}),{check:e=>e.__regexp__,decode:e=>new RegExp(e.source,e.flags)},!0),xr.registerJsonType("number",e=>({__number__:!0,value:e.toString()}),{check:e=>e.__number__,decode:e=>Number(e.value)},!0),xr.registerJsonType("bigint",e=>({__bigint__:!0,value:e.toString()}),{check:e=>e.__bigint__,decode:e=>BigInt(e.value)},!0),xr.registerJsonType("symbol",e=>({__symbol__:!0,key:Symbol.keyFor(e)??e.description??null}),{check:e=>e.__symbol__,decode:e=>{const t=e.key;return null!=t?Symbol.for(t):Symbol()}},!0);const Ar=xr,Cr=ee("TinyIframeEvents"),Ir=new WeakMap;class Mr extends lr.EventEmitter{#vr;get targetWindow(){return Cr(this.#ur),this.#vr}#Er;get targetIframeElement(){return Cr(this.#ur),this.#Er}#Tr;get targetOrigin(){return Cr(this.#ur),this.#Tr}#Sr;get selfType(){return Cr(this.#ur),this.#Sr}#ur=!1;#xr=!1;get ready(){return Cr(this.#ur),this.#xr}onReady(e){Cr(this.#ur),this.#xr?e():this.once(this.#Ar,e)}#Cr=null;#Ir=[];#Mr;#Dr;#Ar;#kr=null;constructor({targetIframe:e,targetOrigin:t=window.location.origin,secretEventName:r="__tinyIframeEvent__",handshakeEventName:i="__tinyIframeHandshake__",readyEventName:n="__tinyIframeReady__"}={}){if(super(),!(void 0===e||e instanceof HTMLIFrameElement&&e.contentWindow))throw new TypeError('[TinyIframeEvents] Invalid "targetIframe": expected HTMLIFrameElement, received '+typeof e);if("string"!=typeof t)throw new TypeError('[TinyIframeEvents] Invalid "targetOrigin": expected string, received '+typeof t);if(this.#Er=e,this.#vr=e?.contentWindow??window.parent,this.#Tr=t,this.#Sr=e?"parent":"iframe",this.#Mr=r,this.#Dr=i,this.#Ar=n,Ir.has(this.#vr))throw new Error("Duplicate window reference.");this._boundWindowMessage=this.#Nr.bind(this),this._boundPortMessage=this.#Lr.bind(this),this.#_r(),Ir.set(this.#vr,this)}get secretEventName(){return Cr(this.#ur),this.#Mr}set secretEventName(e){if(Cr(this.#ur),"string"!=typeof e)throw new TypeError("TinyIframeEvents: secretEventName must be a string.");this.#Mr=e}get handshakeEventName(){return Cr(this.#ur),this.#Dr}set handshakeEventName(e){if(Cr(this.#ur),"string"!=typeof e)throw new TypeError("TinyIframeEvents: handshakeEventName must be a string.");this.#Dr=e}get readyEventName(){return Cr(this.#ur),this.#Ar}set readyEventName(e){if(Cr(this.#ur),"string"!=typeof e)throw new TypeError("TinyIframeEvents: readyEventName must be a string.");this.#Ar=e}#_r(){"parent"===this.#Sr?(this.#kr=()=>{if(this.#ur)return;this.#Cr&&this.#Cr.close();const e=new MessageChannel;this.#Cr=e.port1,this.#Cr.onmessage=this._boundPortMessage,this.#xr=!1,this.#vr.postMessage({type:this.#Dr},this.#Tr,[e.port2])},this.#Er&&(this.#Er.addEventListener("load",this.#kr),this.#kr())):window.addEventListener("message",this._boundWindowMessage,!1)}#Nr(e){const t=e.data,r=e.ports;g(t)&&t.type===this.#Dr&&0!==r.length&&(this.#Cr=r[0],this.#Cr.onmessage=this._boundPortMessage,window.removeEventListener("message",this._boundWindowMessage),this.#Cr.postMessage({type:`${this.#Dr}_ACK`}),this.#jr())}#Lr(e){const t=e.data;if(g(t)&&t.type===`${this.#Dr}_ACK`)return void this.#jr();if(!g(t)||!t[this.#Mr])return;const r=t.eventName,i=t.payload,n=t.direction;"string"!=typeof r||"iframe"===this.#Sr&&"iframe"!==n||"parent"===this.#Sr&&"parent"!==n||this.emit(`win:${r}`,i,e)}#jr(){this.#xr||(this.#xr=!0,this.#Rr(),this.emit(this.#Ar))}#Rr(){for(;this.#Ir.length>0;){const e=this.#Ir.shift();e&&this.#Cr&&this.#Cr.postMessage(e)}}winEmit(e,t){if(Cr(this.#ur),"string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.#ur)throw new Error("Cannot emit: instance has been destroyed.");const r={[this.#Mr]:!0,eventName:e,payload:t,direction:"parent"===this.#Sr?"iframe":"parent"};this.#xr&&this.#Cr?this.#Cr.postMessage(r):this.#Ir.push(r)}isDestroyed(){return this.#ur}destroy(){this.#ur||(this.#xr=!1,window.removeEventListener("message",this._boundWindowMessage),this.#Er&&this.#kr&&this.#Er.removeEventListener("load",this.#kr),this.#Cr&&(this.#Cr.close(),this.#Cr=null),this.removeAllListeners(),this.#Ir=[],Ir.delete(this.#vr),this.#ur=!0)}}const Dr=Mr,kr=ee("TinyNewWinEvents"),Nr=new WeakMap;class Lr extends lr.EventEmitter{#Pr;#Tr;#Ir=[];#xr=!1;#$r=!1;#Or=null;#Ar="__TNE_READY__";#Hr="__TNE_ROUTE__";#h=!1;get destroyed(){return this.#h}get readyEventName(){return kr(this.#h),this.#Ar}set readyEventName(e){if(kr(this.#h),"string"!=typeof e)throw new TypeError("TinyNewWinEvents: readyEventName must be a string.");this.#Ar=e}get routeEventName(){return kr(this.#h),this.#Hr}set routeEventName(e){if(kr(this.#h),"string"!=typeof e)throw new TypeError("TinyNewWinEvents: routeEventName must be a string.");this.#Hr=e}constructor({targetOrigin:e,url:t,name:r,features:i}={}){if(super(),"string"==typeof r&&"_blank"===r)throw new Error('TinyNewWinEvents: The window name "_blank" is not supported. Please use a custom name to allow tracking.');if(void 0!==e&&"string"!=typeof e)throw new TypeError('TinyNewWinEvents: The "targetOrigin" option must be a string.');if(void 0!==t&&"string"!=typeof t)throw new TypeError('TinyNewWinEvents: The "url" option must be a string.');if(void 0!==i&&"string"!=typeof i)throw new TypeError('TinyNewWinEvents: The "features" option must be a string if provided.');if(void 0===t?this.#Pr=window.opener:(this.#Pr="string"==typeof t?window.open(t,r,i):t,this.#$r=!0),!this.#Pr||Nr.has(this.#Pr))throw new Error("Invalid or duplicate window reference.");this.#Tr=e??window.location.origin,this._handleMessage=this.#Fr.bind(this),window.addEventListener("message",this._handleMessage,!1),this.#$r||(this.#Br(this.#Ar,null),this.#zr())}getWin(){return kr(this.#h),this.#Pr}#Fr(e){if(!e.source||this.#Pr&&e.source!==this.#Pr)return;const{type:t,route:r,payload:i}=e.data||{};if(t===this.#Ar)return this.#xr=!0,this.#Rr(),this.#zr(),void(this.#$r&&this.#Br(this.#Ar,null));t===this.#Hr&&this.emit(`win:${r}`,i,e)}#Rr(){for(;this.#Ir.length;){const e=this.#Ir.shift();if(e){const{route:t,payload:r}=e;this.winEmit(t,r)}}}#Br(e,t,r=""){this.#Pr&&this.#Pr.closed||this.#Pr?.postMessage({type:e,route:r,payload:t},this.#Tr)}close(){if(kr(this.#h),!this.#$r)throw new Error("Only host can close the window.");this.#Pr&&!this.#Pr.closed&&this.#Pr.close()}winEmit(e,t){if(kr(this.#h),"string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.isDestroyed())throw new Error("Cannot emit: instance has been destroyed.");this.#xr?this.#Br(this.#Hr,t,e):this.#Ir.push({route:e,payload:t})}isConnected(){return kr(this.#h),!(!this.#xr||!this.#Pr||this.#Pr.closed)}#zr(){this.#Pr&&!this.#Or&&(this.#Or=setInterval(()=>{this.#Pr?.closed&&(this.emit("WINDOW_REF_CLOSED"),this.destroy())},500),Nr.set(this.#Pr,this.#Or))}onClose(e){kr(this.#h),this.on("WINDOW_REF_CLOSED",e)}offClose(e){kr(this.#h),this.off("WINDOW_REF_CLOSED",e)}isDestroyed(){return!this.#Pr}destroy(){this.#Pr&&(this.#Or&&(clearInterval(this.#Or),this.#Or=null,Nr.delete(this.#Pr)),window.removeEventListener("message",this._handleMessage),this.#Ir=[],this.#xr=!1,this.#Pr=null,this.removeAllListeners(),this.#h=!0)}}const _r=Lr,jr=class{#h=!1;get destroyed(){return this.#h}#Wr;#Vr;#qr;#Kr=0;#Jr=0;#Ur;#Gr=null;#Yr=null;get lineHeight(){return this.#Wr}get maxRows(){return this.#Vr-1}get extraHeight(){return this.#qr}get currentHeight(){return this.#Kr}get currentRows(){return this.#Jr}get textarea(){return this.#Ur}constructor(e,t={}){if(!(e instanceof HTMLTextAreaElement))throw new Error("TinyTextarea: Provided element is not a <textarea>.");if("object"!=typeof t||null===t)throw new TypeError("TinyTextarea: Options must be an object if provided.");if("maxRows"in t&&"number"!=typeof t.maxRows)throw new TypeError("TinyTextarea: `maxRows` must be a number.");if("extraHeight"in t&&"number"!=typeof t.extraHeight)throw new TypeError("TinyTextarea: `extraHeight` must be a number.");if("onResize"in t&&"function"!=typeof t.onResize)throw new TypeError("TinyTextarea: `onResize` must be a function.");if("onInput"in t&&"function"!=typeof t.onInput)throw new TypeError("TinyTextarea: `onInput` must be a function.");this.#Ur=e,this.#Vr=(t.maxRows??5)+1,this.#qr=t.extraHeight??0,this.#Gr=t.onResize??null,this.#Yr=t.onInput??null,this.#Wr=this.#Xr(),e.style.overflowY="hidden",e.style.resize="none",this._handleInput=()=>this.#Qr(),e.addEventListener("input",this._handleInput),this.#Qr()}#Qr(){this.#Ur.style.height="auto";const e=window.getComputedStyle(this.#Ur),t=parseFloat(e.paddingTop)||0,r=parseFloat(e.paddingBottom)||0,i=(this.#Ur.value.match(/\n/g)||[]).length,n=this.#Ur.scrollHeight,s=this.#Wr*this.#Vr,o=Math.ceil(Math.min(n,s)-t-r+this.#qr),a=this.#Vr-1,l=i<a?i+1:a;this.#Ur.style.height=`${o}px`,this.#Ur.style.overflowY=n>s?"auto":"hidden",this.#Kr=o;const u={breakLines:i,rows:l,height:o,scrollHeight:n,maxHeight:s,lineHeight:this.#Wr,maxRows:a};l!==this.#Jr&&(this.#Jr=l,"function"==typeof this.#Gr&&this.#Gr({...u})),"function"==typeof this.#Yr&&this.#Yr(u)}#Xr(){const e=window.getComputedStyle(this.#Ur),t=parseFloat(e.lineHeight);return Number.isNaN(t)?1.2*parseFloat(e.fontSize):t}getData(){return{rows:this.#Jr,height:this.#Kr}}refresh(){this.#Qr()}destroy(){this.destroyed||(this.#Ur.removeEventListener("input",this._handleInput),this.#h=!0)}},Rr=ee("TinyGamepad");class Pr{#ur=!1;#Zr=new Set;#ei=new Map;#ti=new Map;#ri=null;#ii=[];#ni={};#si=[];#oi=null;#ai=null;#li;#ui;#hi;#di;#ci;#mi;#pi;#fi;#yi=[];#gi=0;#wi=0;#bi=[];#vi=0;#Ei=null;#Ti=new Set;#Si=new Set;#xi=new Map;#Ai=new Map;#Ci=new Map;static#Ii={" ":"Space","\n":"Enter","\r":"Enter","\t":"Tab","-":"Minus",_:"Minus","=":"Equal","+":"Equal","[":"BracketLeft","{":"BracketLeft","]":"BracketRight","}":"BracketRight","\\":"Backslash","|":"Backslash",";":"Semicolon",":":"Semicolon","'":"Quote",'"':"Quote",",":"Comma","<":"Comma",".":"Period",">":"Period","/":"Slash","?":"Slash","`":"Backquote","~":"Backquote"};static addSpecialKey(e,t){if("string"!=typeof e)throw new TypeError("Invalid char type: expected string, got "+typeof e);if(1!==e.length)throw new Error(`Invalid char length: "${e}" (must be exactly one character)`);if("string"!=typeof t)throw new TypeError("Invalid code type: expected string, got "+typeof t);Pr.#Ii[e]=t}static removeSpecialKey(e){if("string"!=typeof e)throw new TypeError("Invalid char type: expected string, got "+typeof e);if(1!==e.length)throw new Error(`Invalid char length: "${e}" (must be exactly one character)`);delete Pr.#Ii[e]}static getSpecialKey(e){if("string"!=typeof e)throw new TypeError("Invalid char type: expected string, got "+typeof e);if(1!==e.length)throw new Error(`Invalid char length: "${e}" (must be exactly one character)`);return Pr.#Ii[e]}static getAllSpecialKeys(){return{...Pr.#Ii}}static stringToKeys(e){if("string"!=typeof e)throw new TypeError("Invalid text type: expected string, got "+typeof e);if(!e.length)throw new Error("Invalid text: cannot be empty");return Array.from(e).map(e=>{const t=e.toUpperCase();if(t>="A"&&t<="Z")return`Key${t}`;if(t>="0"&&t<="9")return`Digit${t}`;const r=Pr.#Ii[e];if(void 0!==r)return r;throw new Error(`Unsupported character: "${e}"`)})}constructor({expectedId:e=null,inputMode:t="both",ignoreIds:r=[],deadZone:i=.1,axisActiveSensitivity:n=.3,timeoutComboKeys:s=500,allowMouse:o=!1,elementBase:a=window}={}){if(null!==e&&"string"!=typeof e)throw new TypeError('"expectedId" must be a string or null, received: '+typeof e);if(!["keyboard-only","gamepad-only","both"].includes(t))throw new TypeError(`"inputMode" must be 'keyboard-only', 'gamepad-only', or 'both', received: ${t}`);if(!Array.isArray(r)||!r.every(e=>"string"==typeof e))throw new TypeError('"ignoreIds" must be an array of strings');if("number"!=typeof i||i<0||i>1)throw new RangeError(`"deadZone" must be a number between 0 and 1, received: ${i}`);if("number"!=typeof n||n<0||n>1)throw new RangeError(`"axisActiveSensitivity" must be a number between 0 and 1, received: ${n}`);if("number"!=typeof s||s<0)throw new RangeError(`"timeoutComboKeys" must be a positive number, received: ${s}`);if("boolean"!=typeof o)throw new TypeError('"allowMouse" must be a boolean, received: '+typeof o);if(!(a instanceof Window||a instanceof Element))throw new TypeError('"elementBase" must be a Window or Element instance');this.#di=e,this.#li=t,this.#ui=new Set(r),this.#hi=i,this.#ci=o,this.#mi=a,this.#pi=s,this.#fi=n,["gamepad-only","both"].includes(this.#li)&&this.#Mi(),["keyboard-only","both"].includes(this.#li)&&this.#Di()}#ki=e=>this.#Ni(e.gamepad);#Li=e=>this.#_i(e.gamepad);#Mi(){window.addEventListener("gamepadconnected",this.#ki),window.addEventListener("gamepaddisconnected",this.#Li)}#Ni(e){this.#ur||this.#ui.has(e.id)||this.#di&&e.id!==this.#di||this.#ri||(this.#ri=e,this.#di=e.id,this.#ji(),this.#Ri("connected",{id:e.id,gp:e,timestamp:e.timestamp}))}#_i(e){this.#ur||this.#ri&&e.id===this.#ri.id&&(this.#ri=null,this.#oi&&(cancelAnimationFrame(this.#oi),this.#oi=null),this.#Ri("disconnected",{id:e.id,gp:e,timestamp:e.timestamp}))}#ji(){const e=()=>{this.#ur||(this.#Pi(),this.#oi=requestAnimationFrame(e))};e()}#Pi(){if(this.#ur)return;const e=navigator.getGamepads(),t=Array.from(e).find(e=>e&&e.id===this.#di);t&&(this.#ri=t,t.buttons.forEach((e,r)=>{const i=`Button${r}`,n=this.#ii[r]?.pressed||!1;let s,o,a=!1;e.pressed&&!n?(o=1,s="down"):!e.pressed&&n?(o=0,s="up"):e.pressed&&n&&(o=1,s="hold"),e.pressed&&e.value>0&&e.value<1&&1!==e.value&&(o=e.value,a=!0),"number"==typeof o&&"string"==typeof s&&this.#$i({key:i,source:"gamepad-button",value:o,value2:NaN,type:s,gp:t,isPressure:a,pressed:e.pressed,prevPressed:n,timestamp:t.timestamp,id:t.id}),this.#ii[r]={pressed:e.pressed,value:"number"==typeof o?o:this.#ii[r]?.value,value2:NaN}}),t.axes.forEach((e,r)=>{Math.abs(e)<this.#hi&&(e=0);const i=`Axis${r}`;e!==(this.#si[r]??0)&&this.#$i({key:i,source:"gamepad-analog",value:e,value2:NaN,type:"change",timestamp:t.timestamp,id:t.id,gp:t}),this.#si[r]=e}))}#Oi=e=>{if(!this.#ur){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keydown listener.");this.#Zr.has(e.code)||(this.#Zr.add(e.code),this.#$i({event:e,key:e.code,source:"keyboard",value:1,value2:NaN,type:"down",pressed:!0,prevPressed:this.#ni[e.code]?.pressed??!1,id:"native_keyboard",timestamp:e.timeStamp}),this.#ni[e.code]={pressed:!0})}};#Hi=e=>{if(!this.#ur){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keyup listener.");this.#Zr.has(e.code)&&(this.#Zr.delete(e.code),this.#$i({event:e,key:e.code,source:"keyboard",value:0,value2:NaN,type:"up",pressed:!1,prevPressed:this.#ni[e.code]?.pressed??!1,id:"native_keyboard",timestamp:e.timeStamp}),this.#ni[e.code]={pressed:!1})}};#Fi=e=>{if(this.#ur)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mousedown listener.");const t=`Mouse${e.button}`;this.#Zr.add(t),this.#$i({event:e,key:t,source:"mouse",value:1,value2:NaN,type:"down",pressed:!0,prevPressed:this.#ni[t]?.pressed??!1,id:"native_mouse",timestamp:e.timeStamp}),this.#ni[t]={pressed:!0}};#Bi=e=>{if(this.#ur)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mouseup listener.");const t=`Mouse${e.button}`;this.#Zr.delete(t),this.#$i({event:e,key:t,source:"mouse",value:0,value2:NaN,type:"up",pressed:!1,prevPressed:this.#ni[t]?.pressed??!1,id:"native_mouse",timestamp:e.timeStamp}),this.#ni[t]={pressed:!1}};#zi=e=>{if(!this.#ur){if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mousemove listener.");if(0!==e.movementX||0!==e.movementY){const t="MouseMove",r=this.#ni[t]??{pressed:!1,value:0,value2:0};this.#$i({event:e,key:t,source:"mouse",value:e.movementX+(r.value??0),value2:e.movementY+(r.value??0),id:"native_mouse",type:"move",pressed:!0,prevPressed:null,timestamp:e.timeStamp}),this.#ni[t]={pressed:!1,value:e.movementX,value2:e.movementY}}}};#Di(){this.#mi.addEventListener("keydown",this.#Oi),this.#mi.addEventListener("keyup",this.#Hi),this.#ci&&(this.#mi.addEventListener("mousedown",this.#Fi),this.#mi.addEventListener("mouseup",this.#Bi),this.#mi.addEventListener("mousemove",this.#zi));const e=()=>{this.#ur||(this.#Zr.forEach(e=>{const t=e.startsWith("Mouse")?"mouse":"keyboard";this.#$i({key:e,source:t,id:`native_${t}`,value:1,value2:NaN,type:"hold",pressed:!0,prevPressed:this.#ni[e]?.pressed??!1,timestamp:NaN})}),this.#ai=requestAnimationFrame(e))};e()}#$i(e){if(this.#ur)return;const t=this.#ti.get("input-*")||[],{pressed:r,key:i}=e,n=i.startsWith("Axis"),s="boolean"==typeof r&&r||n&&(e.value>this.#fi||e.value<-Math.abs(this.#fi)),o=n?`${i}${e.value>0?"+":e.value<0?"-":""}`:i;let a=null;if("move"!==e.type&&"hold"!==e.type){if(s){if(!n&&!this.#Ti.has(i)||n&&!this.#Ti.has(i)&&!this.#Ti.has(`${i}+`)&&!this.#Ti.has(`${i}-`)){0===this.#vi&&(this.#vi=Date.now()),this.#Ti.add(o),a=!0,this.#bi.push(o),this.#yi.length<1&&(this.#Ei&&clearTimeout(this.#Ei),this.#Ei=setTimeout(()=>this.resetComboMapped(),this.#pi));const e=this.#ti.get("mapped-key-start")??[];for(const t of e)t({key:o,activeTime:this.#vi})}}else if(!n&&this.#Ti.has(i)||n&&(this.#Ti.has(i)||this.#Ti.has(`${i}+`)||this.#Ti.has(`${i}-`))){this.#Ti.delete(i),this.#Ti.delete(`${i}+`),this.#Ti.delete(`${i}-`),a=!1;const e=this.#ti.get("mapped-key-end")??[];for(const t of e)t({key:o,activeTime:this.#vi})}for(const{sequence:e,callback:t,triggered:r}of this.#Ai.values()){const i=this.#Ai.get(e.join("+"));if(!i)continue;const n=e.every((e,t)=>this.#bi[t]===e);n&&!r?(i.triggered=!0,t(this.#vi)):!n&&r&&(i.triggered=!1)}}for(const[r,l]of this.#ei.entries()){const u=e=>"string"==typeof l&&e===l||Array.isArray(l)&&l.findIndex((t,r)=>e===l[r])>-1,h=u(o),d=n&&u(`${i}+`),c=n&&u(`${i}-`);if(h||d||c){if(s&&h){if(a||!this.#Si.has(r)){0===this.#wi&&(this.#wi=Date.now()),this.#Si.add(r),0===this.#gi&&(this.#gi=Date.now()),this.#Ei&&clearTimeout(this.#Ei),this.#yi.push(r),this.#Ei=setTimeout(()=>this.resetComboMapped(),this.#pi);const e=this.#ti.get("mapped-input-start")??[];for(const t of e)t({logicalName:r,activeTime:this.#wi,comboTime:this.#gi})}}else if(!a||this.#Si.has(r)){this.#Si.delete(r),this.#Si.size<1&&(this.#wi=0);const e=this.#ti.get("mapped-input-end")??[];for(const t of e)t({logicalName:r,activeTime:this.#wi,comboTime:this.#gi})}for(const{sequence:e,callback:t,triggered:r}of this.#xi.values()){const i=this.#xi.get(e.join("+"));if(!i)continue;const n=Array.from(this.#Si),s=e.every((e,t)=>n[t]===e);s&&!r?(i.triggered=!0,t(this.#wi)):!s&&r&&(i.triggered=!1)}}const m=[];if(n&&0===e.value){const{value:t}=this.#Ci.get(`${i}-`)??{value:0,value2:NaN},{value:r}=this.#Ci.get(`${i}+`)??{value:0,value2:NaN};e.value!==t&&m.push(`${i}-`),e.value!==r&&m.push(`${i}+`)}else m.push(o);m.forEach(i=>{if(!("*"===l||l===i||Array.isArray(l)&&l.includes(i)))return;const n=this.#ti.get(`input-${e.type}-${r}`)||[],s=this.#ti.get(`input-${r}`)||[];if(s.length<1&&n.length<1&&t.length<1)return;const o={...e,key:i,logicalName:r};for(const e of t)e(o);for(const e of s)e(o);for(const e of n)e(o);this.#Ci.set(i,{value:e.value,value2:e.value2})})}}#Ri(e,t){const r=this.#ti.get(e)||[];for(const e of r)e(t)}#Wi(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const i=r.replace("{logicalName}",e);let n=this.#ti.get(i);Array.isArray(n)||(n=[],this.#ti.set(i,n)),n.push(t)}#Vi(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const i=n=>{this.#qi(e,i,r),t(n)};this.#Wi(e,i,r)}#Ki(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const i=r.replace("{logicalName}",e),n=this.#ti.get(i)??[];n.unshift(t),this.#ti.set(i,n)}#qi(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const i=r.replace("{logicalName}",e),n=this.#ti.get(i);Array.isArray(n)&&this.#ti.set(i,n.filter(e=>e!==t))}awaitInputMapping({timeout:e=1e4,eventName:t="MappingInput",canMove:r=!1}={}){return Rr(this.#ur),new Promise((i,n)=>{if("number"!=typeof e||Number.isNaN(e)||e<0)return n(new TypeError(`Invalid "timeout": expected a positive number, got ${e}`));if("string"!=typeof t||!t.trim())return n(new TypeError(`Invalid "eventName": expected a non-empty string, got ${t}`));if("boolean"!=typeof r)return n(new TypeError(`Invalid "canMove": expected a boolean, got ${r}`));const s={key:null,source:null},o=({key:e,type:n,source:l,gp:u,value:h})=>{(r||"move"!==n)&&(s.key=e,s.source=l,s.gp=u,clearTimeout(a),this.offInputStart(t,o),this.offInputChange(t,o),r&&this.offInputMove(t,o),i(s))},a=setTimeout(()=>i(s),e);this.mapInput(t,"*"),this.onInputStart(t,o),this.onInputChange(t,o),r&&this.onInputMove(t,o)})}mapInput(e,t){if(Rr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError(`Invalid "physicalInput": expected string or array of strings, got ${JSON.stringify(t)}`);this.#ei.set(e,t)}unmapInput(e){if(Rr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);this.#ei.delete(e)}hasMappedInput(e){if(Rr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);return this.#ei.has(e)}getMappedInput(e){if(Rr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);const t=this.#ei.get(e);if(!t)throw new Error(`No physical input mapped for logicalName: "${e}"`);return t}clearMapInputs(){Rr(this.#ur),this.#ei.clear()}registerInputSequence(e,t){if(Rr(this.#ur),!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);if("function"!=typeof t)throw new TypeError("'callback' must be a function, got: "+typeof t);if(0===e.length)throw new Error("'sequence' must contain at least one input name.");const r=e.join("+");this.#xi.set(r,{sequence:e,callback:t,triggered:!1})}unregisterInputSequence(e){if(Rr(this.#ur),!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");this.#xi.delete(t)}unregisterAllInputSequences(){Rr(this.#ur),this.#xi.clear()}hasInputSequence(e){if(Rr(this.#ur),!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");return this.#xi.has(t)}registerKeySequence(e,t){if(Rr(this.#ur),!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);if("function"!=typeof t)throw new TypeError("'callback' must be a function, got: "+typeof t);if(0===e.length)throw new Error("'sequence' must contain at least one input name.");const r=e.join("+");this.#Ai.set(r,{sequence:e,callback:t,triggered:!1})}unregisterKeySequence(e){if(Rr(this.#ur),!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");this.#Ai.delete(t)}unregisterAllKeySequences(){Rr(this.#ur),this.#Ai.clear()}hasKeySequence(e){if(Rr(this.#ur),!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");return this.#Ai.has(t)}renewComboMapped(){Rr(this.#ur),this.#Ei&&(clearTimeout(this.#Ei),this.#Ei=setTimeout(()=>this.resetComboMapped(),this.#pi))}resetComboMapped(){Rr(this.#ur),this.#Ei&&clearTimeout(this.#Ei),this.#bi=[],this.#Ei=null,this.#vi=0,this.#yi=[],this.#gi=0}onMappedKeyStart(e){return Rr(this.#ur),this.#Wi("",e,"mapped-key-start")}onceMappedKeyStart(e){return Rr(this.#ur),this.#Vi("",e,"mapped-key-start")}prependMappedKeyStart(e){return Rr(this.#ur),this.#Ki("",e,"mapped-key-start")}offMappedKeyStart(e){return Rr(this.#ur),this.#qi("",e,"mapped-key-start")}offAllMappedKeyStart(){Rr(this.#ur),this.#ti.delete("mapped-key-start")}onMappedKeyEnd(e){return Rr(this.#ur),this.#Wi("",e,"mapped-key-end")}onceMappedKeyEnd(e){return Rr(this.#ur),this.#Vi("",e,"mapped-key-end")}prependMappedKeyEnd(e){return Rr(this.#ur),this.#Ki("",e,"mapped-key-end")}offMappedKeyEnd(e){return Rr(this.#ur),this.#qi("",e,"mapped-key-end")}offAllMappedKeyEnd(){Rr(this.#ur),this.#ti.delete("mapped-key-end")}onMappedInputStart(e){return Rr(this.#ur),this.#Wi("",e,"mapped-input-start")}onceMappedInputStart(e){return Rr(this.#ur),this.#Vi("",e,"mapped-input-start")}prependMappedInputStart(e){return Rr(this.#ur),this.#Ki("",e,"mapped-input-start")}offMappedInputStart(e){return Rr(this.#ur),this.#qi("",e,"mapped-input-start")}offAllMappedInputStart(){Rr(this.#ur),this.#ti.delete("mapped-input-start")}onMappedInputEnd(e){return Rr(this.#ur),this.#Wi("",e,"mapped-input-end")}onceMappedInputEnd(e){return Rr(this.#ur),this.#Vi("",e,"mapped-input-end")}prependMappedInputEnd(e){return Rr(this.#ur),this.#Ki("",e,"mapped-input-end")}offMappedInputEnd(e){return Rr(this.#ur),this.#qi("",e,"mapped-input-end")}offAllMappedInputEnd(){Rr(this.#ur),this.#ti.delete("mapped-input-end")}onInput(e,t){return Rr(this.#ur),this.#Wi(e,t,"input-{logicalName}")}onceInput(e,t){return Rr(this.#ur),this.#Vi(e,t,"input-{logicalName}")}prependInput(e,t){return Rr(this.#ur),this.#Ki(e,t,"input-{logicalName}")}offInput(e,t){return Rr(this.#ur),this.#qi(e,t,"input-{logicalName}")}onInputStart(e,t){return Rr(this.#ur),this.#Wi(e,t,"input-down-{logicalName}")}onceInputStart(e,t){return Rr(this.#ur),this.#Vi(e,t,"input-down-{logicalName}")}prependInputStart(e,t){return Rr(this.#ur),this.#Ki(e,t,"input-down-{logicalName}")}offInputStart(e,t){return Rr(this.#ur),this.#qi(e,t,"input-down-{logicalName}")}onInputEnd(e,t){return Rr(this.#ur),this.#Wi(e,t,"input-up-{logicalName}")}onceInputEnd(e,t){return Rr(this.#ur),this.#Vi(e,t,"input-up-{logicalName}")}prependInputEnd(e,t){return Rr(this.#ur),this.#Ki(e,t,"input-up-{logicalName}")}offInputEnd(e,t){return Rr(this.#ur),this.#qi(e,t,"input-up-{logicalName}")}onInputHold(e,t){return Rr(this.#ur),this.#Wi(e,t,"input-hold-{logicalName}")}onceInputHold(e,t){return Rr(this.#ur),this.#Vi(e,t,"input-hold-{logicalName}")}prependInputHold(e,t){return Rr(this.#ur),this.#Ki(e,t,"input-hold-{logicalName}")}offInputHold(e,t){return Rr(this.#ur),this.#qi(e,t,"input-hold-{logicalName}")}onInputChange(e,t){return Rr(this.#ur),this.#Wi(e,t,"input-change-{logicalName}")}onceInputChange(e,t){return Rr(this.#ur),this.#Vi(e,t,"input-change-{logicalName}")}prependInputChange(e,t){return Rr(this.#ur),this.#Ki(e,t,"input-change-{logicalName}")}offInputChange(e,t){return Rr(this.#ur),this.#qi(e,t,"input-change-{logicalName}")}onInputMove(e,t){return Rr(this.#ur),this.#Wi(e,t,"input-move-{logicalName}")}onceInputMove(e,t){return Rr(this.#ur),this.#Vi(e,t,"input-move-{logicalName}")}prependInputMove(e,t){return Rr(this.#ur),this.#Ki(e,t,"input-move-{logicalName}")}offInputMove(e,t){return Rr(this.#ur),this.#qi(e,t,"input-move-{logicalName}")}getCalls(e,t="all"){if(Rr(this.#ur),"string"!=typeof e||""===e.trim())throw new TypeError(`"logicalName" must be a non-empty string, received ${e}`);const r=["all","start","end","hold","change","move"];if(!r.includes(t))throw new TypeError(`"type" must be one of ${r.join(", ")}, received ${t}`);const i=`${{all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t]}${e}`,n=this.#ti.get(i);return Array.isArray(n)?[...n]:[]}offAllInputs(e,t="all"){if(Rr(this.#ur),"string"!=typeof e||""===e.trim())throw new TypeError(`"logicalName" must be a non-empty string, received ${e}`);const r=["all","start","end","hold","change","move"];if(!r.includes(t))throw new TypeError(`"type" must be one of ${r.join(", ")}, received ${t}`);const i={all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t];i&&this.#ti.delete(`${i}${e}`)}getCallSize(e,t="all"){if(Rr(this.#ur),"string"!=typeof e||""===e.trim())throw new TypeError(`"logicalName" must be a non-empty string, received ${e}`);const r=["all","start","end","hold","change","move"];if(!r.includes(t))throw new TypeError(`"type" must be one of ${r.join(", ")}, received ${t}`);const i={all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t],n=this.#ti.get(`${i}${e}`);return Array.isArray(n)?n.length:0}#Ji={type:"dual-rumble",params:{startDelay:0,duration:200,weakMagnitude:.5,strongMagnitude:1}};get defaultHapticEffect(){return Rr(this.#ur),{type:this.#Ji.type,params:{...this.#Ji.params}}}setDefaultHapticEffect(e,t){if(Rr(this.#ur),"string"!=typeof e)throw new TypeError(`"type" must be a valid GamepadHapticEffectType string, received ${e}`);if("object"!=typeof t||null===t)throw new TypeError(`"params" must be a non-null object, received ${t}`);this.#Ji.type=e,this.#Ji.params=t}hasHapticEffect(){Rr(this.#ur);const e=this.#ri;return!!e&&e.vibrationActuator instanceof GamepadHapticActuator}vibrate(e,t){if(Rr(this.#ur),void 0!==e&&("object"!=typeof e||null===e))throw new TypeError(`"params" must be an object if provided, received ${e}`);if(void 0!==t&&"string"!=typeof t)throw new TypeError(`"type" must be a valid GamepadHapticEffectType string if provided, received ${t}`);const r=this.#ri;if(!r)return new Promise(e=>e("complete"));const i=r.vibrationActuator;return i instanceof GamepadHapticActuator?i.playEffect(t??this.#Ji.type,{...this.#Ji.params,...e}):new Promise(e=>e("complete"))}ignoreId(e){if(Rr(this.#ur),"string"!=typeof e||""===e.trim())throw new TypeError(`"id" must be a non-empty string, received ${e}`);this.#ui.add(e)}unignoreId(e){if(Rr(this.#ur),"string"!=typeof e||""===e.trim())throw new TypeError(`"id" must be a non-empty string, received ${e}`);this.#ui.delete(e)}onConnected(e){return Rr(this.#ur),this.#Wi("",e,"connected")}onceConnected(e){return Rr(this.#ur),this.#Vi("",e,"connected")}prependConnected(e){return Rr(this.#ur),this.#Ki("",e,"connected")}offConnected(e){return Rr(this.#ur),this.#qi("",e,"connected")}offAllConnected(){Rr(this.#ur),this.#ti.delete("connected")}onDisconnected(e){return Rr(this.#ur),this.#Wi("",e,"disconnected")}onceDisconnected(e){return Rr(this.#ur),this.#Vi("",e,"disconnected")}prependDisconnected(e){return Rr(this.#ur),this.#Ki("",e,"disconnected")}offDisconnected(e){return Rr(this.#ur),this.#qi("",e,"disconnected")}offAllDisconnected(){Rr(this.#ur),this.#ti.delete("disconnected")}hasGamepad(){return Rr(this.#ur),this.#ri instanceof Gamepad}getGamepad(){if(Rr(this.#ur),!this.#ri)throw new Error("No gamepad is currently connected.");return this.#ri}hasLastButtonState(e){return Rr(this.#ur),!!this.#ii[e]}getLastButtonState(e){if(Rr(this.#ur),!this.#ii[e])throw new Error(`No last button state found for index ${e}`);return{...this.#ii[e]}}exportConfig(){return Rr(this.#ur),{expectedId:this.#di,ignoreIds:Array.from(this.#ui),deadZone:this.#hi,timeoutComboKeys:this.#pi,axisActiveSensitivity:this.#fi,inputMap:Array.from(this.#ei.entries())}}importConfig(e){if(Rr(this.#ur),"string"!=typeof e&&("object"!=typeof e||null===e))throw new TypeError(`"json" must be a string or a non-null object, received: ${e}`);const t="string"==typeof e?JSON.parse(e):e;if(void 0!==t.expectedId&&"string"!=typeof t.expectedId&&null!==t.expectedId)throw new TypeError('"expectedId" must be a string or null if provided');if(void 0!==t.ignoreIds&&!Array.isArray(t.ignoreIds))throw new TypeError('"ignoreIds" must be an array if provided');if(void 0!==t.deadZone&&"number"!=typeof t.deadZone)throw new TypeError('"deadZone" must be a number if provided');if(void 0!==t.timeoutComboKeys&&"number"!=typeof t.timeoutComboKeys)throw new TypeError('"timeoutComboKeys" must be a number if provided');if(void 0!==t.axisActiveSensitivity&&"number"!=typeof t.axisActiveSensitivity)throw new TypeError('"axisActiveSensitivity" must be a number if provided');if(void 0!==t.inputMap&&!Array.isArray(t.inputMap))throw new TypeError('"inputMap" must be an array if provided');void 0!==t.expectedId&&(this.#di=t.expectedId),Array.isArray(t.ignoreIds)&&(this.#ui=new Set(t.ignoreIds)),"number"==typeof t.deadZone&&(this.#hi=t.deadZone),"number"==typeof t.timeoutComboKeys&&(this.#pi=t.timeoutComboKeys),"number"==typeof t.axisActiveSensitivity&&(this.#fi=t.axisActiveSensitivity),Array.isArray(t.inputMap)&&(this.#ei=new Map(t.inputMap))}get mappedKeyStartCalls(){Rr(this.#ur);const e=this.#ti.get("mapped-key-start");return Array.isArray(e)?[...e]:[]}get mappedKeyEndCalls(){Rr(this.#ur);const e=this.#ti.get("mapped-key-end");return Array.isArray(e)?[...e]:[]}get comboMappedKeys(){return Rr(this.#ur),[...this.#bi]}get comboMappedInputs(){return Rr(this.#ur),[...this.#yi]}get keySequenceSize(){return Rr(this.#ur),this.#Ai.size}get keySequences(){Rr(this.#ur);const e=[];for(const[,t]of this.#Ai.entries())e.push(t.callback);return e}get activeMappedKeys(){return Rr(this.#ur),[...this.#Ti]}get mappedInputStartCalls(){Rr(this.#ur);const e=this.#ti.get("mapped-input-start");return Array.isArray(e)?[...e]:[]}get mappedInputEndCalls(){Rr(this.#ur);const e=this.#ti.get("mapped-input-end");return Array.isArray(e)?[...e]:[]}get inputSequenceSize(){return Rr(this.#ur),this.#xi.size}get inputSequences(){Rr(this.#ur);const e=[];for(const[,t]of this.#xi.entries())e.push(t.callback);return e}get activeMappedInputs(){return Rr(this.#ur),[...this.#Si]}get mappedInputs(){Rr(this.#ur);const e={};for(const[t,r]of this.#ei.entries())e[t]=r;return e}get mappedInputSize(){return Rr(this.#ur),this.#ei.size}get connectedCalls(){Rr(this.#ur);const e=this.#ti.get("connected");return Array.isArray(e)?[...e]:[]}get disconnectedCalls(){Rr(this.#ur);const e=this.#ti.get("disconnected");return Array.isArray(e)?[...e]:[]}get ignoredDeviceIds(){return Rr(this.#ur),[...this.#ui]}get heldKeys(){return Rr(this.#ur),[...this.#Zr]}get eventsSize(){Rr(this.#ur);let e=0;return this.#ti.forEach(t=>{e+=t.length}),e}get callSize(){return Rr(this.#ur),this.#ti.size}get connectedCallSize(){Rr(this.#ur);const e=this.#ti.get("connected");return Array.isArray(e)?e.length:0}get disconnectedCallSize(){Rr(this.#ur);const e=this.#ti.get("disconnected");return Array.isArray(e)?e.length:0}get mappedKeyStartCallSize(){Rr(this.#ur);const e=this.#ti.get("mapped-key-start");return Array.isArray(e)?e.length:0}get mappedKeyEndCallSize(){Rr(this.#ur);const e=this.#ti.get("mapped-key-end");return Array.isArray(e)?e.length:0}get mappedInputStartCallSize(){Rr(this.#ur);const e=this.#ti.get("mapped-input-start");return Array.isArray(e)?e.length:0}get mappedInputEndCallSize(){Rr(this.#ur);const e=this.#ti.get("mapped-input-end");return Array.isArray(e)?e.length:0}get lastButtonStates(){Rr(this.#ur);const e=[];return this.#ii.forEach(t=>{e.push({...t})}),e}get lastAxes(){return Rr(this.#ur),[...this.#si]}get inputMode(){return Rr(this.#ur),this.#li}get elementBase(){return Rr(this.#ur),this.#mi}get timeComboInputs(){return Rr(this.#ur),this.#gi}get timeComboKeys(){return Rr(this.#ur),this.#vi}get timeMappedInputs(){return Rr(this.#ur),this.#wi}get timeoutComboKeys(){return Rr(this.#ur),this.#pi}set timeoutComboKeys(e){if(Rr(this.#ur),"number"!=typeof e||e<0||!Number.isFinite(e))throw new TypeError("Timeout combo keys must be a non-negative finite number.");this.#pi=e}get axisActiveSensitivity(){return Rr(this.#ur),this.#fi}set axisActiveSensitivity(e){if(Rr(this.#ur),"number"!=typeof e||e<0||e>1)throw new RangeError("Axis sensitivity must be a number between 0 and 1.");this.#fi=e}get deadZone(){return Rr(this.#ur),this.#hi}set deadZone(e){if(Rr(this.#ur),"number"!=typeof e||e<0||e>1)throw new RangeError("Dead zone must be a number between 0 and 1.");this.#hi=e}get expectedId(){return Rr(this.#ur),this.#di}set expectedId(e){if(Rr(this.#ur),"string"!=typeof e)throw new TypeError("Expected device id be a string.");this.#di=e}get isDestroyed(){return this.#ur}destroy(){this.#ur||(this.#oi&&cancelAnimationFrame(this.#oi),this.#ai&&cancelAnimationFrame(this.#ai),this.#oi=null,this.#ai=null,["keyboard-only","both"].includes(this.#li)&&(this.#mi.removeEventListener("keydown",this.#Oi),this.#mi.removeEventListener("keyup",this.#Hi),this.#ci&&(this.#mi.removeEventListener("mousedown",this.#Fi),this.#mi.removeEventListener("mouseup",this.#Bi),this.#mi.removeEventListener("mousemove",this.#zi))),["gamepad-only","both"].includes(this.#li)&&(window.removeEventListener("gamepadconnected",this.#ki),window.removeEventListener("gamepaddisconnected",this.#Li)),this.resetComboMapped(),this.#ei.clear(),this.#ti.clear(),this.#Zr.clear(),this.#Si.clear(),this.#Ti.clear(),this.#xi.clear(),this.#Ai.clear(),this.#ui.clear(),this.#Ci.clear(),this.#ii=[],this.#si=[],this.#ni={},this.#ri=null,this.#di=null,this.#ci=!1,this.#wi=0,this.#ur=!0)}}const $r=Pr,Or=ee("TinyDayNightCycle"),Hr=class{#Ui=!0;#Gi=86400;#Yi=3600;#Xi=60;#Qi=new Map;#Zi=[];#en;#tn;#rn={main:null};#in=0;#nn=0;#sn=0;#on="";#an=1;#ln=1;#un=1;#ur=!1;#hn=[31,31,31,31,31,31,31,31,31,31,31,31];#dn={default:{},day:{},night:{},hours:{},seasons:{}};#cn={min:60,max:180};#mn=0;get daySize(){return Or(this.#ur),this.#Gi}get autoSizeAdjuste(){return Or(this.#ur),this.#Ui}set autoSizeAdjuste(e){if(Or(this.#ur),"boolean"!=typeof e)throw new TypeError("autoSizeAdjuste must be a boolean.");this.#Ui=e}set daySize(e){if(Or(this.#ur),"number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("daySize must be a positive finite number.");const t=this.#Yi/this.#Gi,r=this.#Xi/this.#Gi;this.#Gi=e,this.#Ui&&(this.#Yi=e*t,this.#Xi=e*r)}get hourSize(){return Or(this.#ur),this.#Yi}set hourSize(e){if(Or(this.#ur),"number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("hourSize must be a positive finite number.");const t=this.#Gi/this.#Yi,r=this.#Xi/this.#Yi;this.#Yi=e,this.#Ui&&(this.#Gi=e*t,this.#Xi=e*r)}get minuteSize(){return Or(this.#ur),this.#Xi}set minuteSize(e){if(Or(this.#ur),"number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("minuteSize must be a positive finite number.");const t=this.#Yi/this.#Xi,r=this.#Gi/this.#Xi;this.#Xi=e,this.#Ui&&(this.#Yi=e*t,this.#Gi=e*r)}get isDestroyed(){return this.#ur}get currentSeconds(){return Or(this.#ur),this.#in}set currentSeconds(e){if(Or(this.#ur),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentSeconds must be a finite number, received "+typeof e);if(e<0||e>=this.#Gi)throw new RangeError(`currentSeconds must be between 0 and 86399, received ${e}`);this.#in=Math.floor(e),this.#nn=Math.floor(e/this.#Xi),this.#sn=Math.floor(e/this.#Yi)}get currentMinutes(){return Or(this.#ur),this.#nn}set currentMinutes(e){if(Or(this.#ur),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentMinutes must be a finite number, received "+typeof e);if(e<0||e>=1440)throw new RangeError(`currentMinutes must be between 0 and 1439, received ${e}`);this.#nn=Math.floor(e),this.#sn=Math.floor(e/this.#Xi),this.#in=Math.floor(e*this.#Xi)}get currentHours(){return Or(this.#ur),this.#sn}set currentHours(e){if(Or(this.#ur),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentHours must be a finite number, received "+typeof e);if(e<0||e>=24)throw new RangeError(`currentHours must be between 0 and less than 24, received ${e}`);this.#sn=Math.floor(e),this.#nn=Math.floor(e*this.#Xi),this.#in=Math.floor(e*this.#Yi)}get moons(){return Or(this.#ur),this.#Zi.map(e=>this.getMoon(e))}get seasons(){return Or(this.#ur),Array.from(this.#Qi.keys())}get dayStart(){return Or(this.#ur),this.#en}get nightStart(){return Or(this.#ur),this.#tn}get weather(){return Or(this.#ur),{...this.#rn}}get currentSeason(){return Or(this.#ur),this.#on}get currentDay(){return Or(this.#ur),this.#an}get currentMonth(){return Or(this.#ur),this.#ln}get currentYear(){return Or(this.#ur),this.#un}get monthDays(){return Or(this.#ur),[...this.#hn]}get weatherDuration(){return Or(this.#ur),{...this.#cn}}get weatherTimeLeft(){return Or(this.#ur),this.#mn}set dayStart(e){if(Or(this.#ur),"number"!=typeof e||e<1)throw new TypeError("dayStart must be a positive non-zero number, received "+typeof e);this.#en=e}set nightStart(e){if(Or(this.#ur),"number"!=typeof e||e<1)throw new TypeError("nightStart must be a positive non-zero number, received "+typeof e);this.#tn=e}set weather(e){if(Or(this.#ur),"object"!=typeof e||null===e||Array.isArray(e)||!Object.values(e).every(e=>"string"==typeof e))throw new TypeError("weather must be a object with strings, received "+typeof e);this.#rn=e}set currentSeason(e){if(Or(this.#ur),"string"!=typeof e||!this.#Qi.has(e))throw new TypeError(`currentSeason must be one of ${Array.from(this.#Qi).map(e=>e[0]).join(", ")}, received ${e}`);this.#on=e}set currentDay(e){if(Or(this.#ur),"number"!=typeof e||e<1||e>this.#hn[this.#ln-1])throw new TypeError("currentDay must be a valid day number, received "+typeof e);this.#an=e}set currentMonth(e){if(Or(this.#ur),"number"!=typeof e||"number"!=typeof this.#hn[e-1])throw new TypeError("currentMonth must be a valid month number, received "+typeof e);this.#ln=e}set currentYear(e){if(Or(this.#ur),"number"!=typeof e||e<1)throw new TypeError("currentYear must be a positive number non-zero, received "+typeof e);this.#un=e}set monthDays(e){if(Or(this.#ur),!Array.isArray(e))throw new TypeError("monthDays must be a array");if(!e.every(e=>"number"==typeof e))throw new TypeError("monthDays must have number values");this.#hn=[...e]}set weatherDuration(e){if(Or(this.#ur),"object"!=typeof e||null===e)throw new TypeError("weatherDuration must be a non-null object");if("number"!=typeof e.min||"number"!=typeof e.max)throw new TypeError("weatherDuration.min and weatherDuration.max must be numbers");this.#cn={...e}}set weatherTimeLeft(e){if(Or(this.#ur),"number"!=typeof e)throw new TypeError("weatherTimeLeft must be a number, received "+typeof e);this.#mn=e}get weatherConfig(){Or(this.#ur);const e={},t={};for(const t in this.#dn.hours)e[t]={...this.#dn.hours[t]};for(const e in this.#dn.seasons)t[e]={...this.#dn.seasons[e]};return{default:{...this.#dn.default},day:{...this.#dn.day},night:{...this.#dn.night},hours:e,seasons:t}}set weatherConfig(e){if(Or(this.#ur),"object"!=typeof e||null===e)throw new TypeError(`weatherConfig must be a non-null object, received ${e}`);const t=["default","day","night","hours","seasons"];for(const r of t)if(!(r in e))throw new TypeError(`weatherConfig is missing required property "${r}".`);const r={},i={},n=(e,t)=>{if("object"!=typeof e||null===e)throw new TypeError(`${t} must be an object, received ${e}`);for(const r in e){const i=typeof e[r];if("number"!==i&&"function"!==i)throw new TypeError(`${t}["${r}"] must be a number or function, received ${i}`)}};for(const t in e.hours)n(e.hours[t],`hours["${t}"]`),r[t]={...e.hours[t]};for(const t in e.seasons)n(e.seasons[t],`seasons["${t}"]`),i[t]={...e.seasons[t]};const s=(e,t)=>(n(e,t),{...e});this.#dn={default:s(e.default,"default"),day:s(e.day,"day"),night:s(e.night,"night"),hours:r,seasons:i}}constructor(e=6,t=18){this.#en=e,this.#tn=t}addSeason(e,t){if(Or(this.#ur),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);if(!Array.isArray(t)||!t.every(e=>"number"==typeof e))throw new TypeError("Season values must be an array of numbers");this.#Qi.set(e,t)}removeSeason(e){if(Or(this.#ur),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);this.#Qi.delete(e),this.#on===e&&(this.#on="")}hasSeason(e){if(Or(this.#ur),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);return this.#Qi.has(e)}getSeason(e){if(Or(this.#ur),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);const t=this.#Qi.get(e);if(!t)throw new Error(`Season "${e}" not found`);return[...t]}setTime({hour:e=0,minute:t=0,second:r=0}){Or(this.#ur),this.currentSeconds=(e*this.#Yi+t*this.#Xi+r)%this.#Gi}addTime({hours:e=0,minutes:t=0,seconds:r=0}){Or(this.#ur);let i=this.currentSeconds+e*this.#Yi+t*this.#Xi+r;for(;i>=this.#Gi;)i-=this.#Gi,this.nextDay();for(;i<0;)i+=this.#Gi,this.prevDay();this.currentSeconds=i,this.updateWeatherTimer((e*this.#Yi+t*this.#Xi+r)/this.#Xi)}getTime({withSeconds:e=!1,hourSize:t=this.#Yi,minuteSize:r=this.#Xi}={}){Or(this.#ur);const i=Math.floor(this.currentSeconds/t),n=Math.floor(this.currentSeconds%t/r),s=this.currentSeconds%r;return{hour:i,minute:n,second:s,formatted:`${i.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`+(e?`:${s.toString().padStart(2,"0")}`:"")}}isDay(){return Or(this.#ur),this.#en<this.#tn?this.#nn>=this.#en*this.#Xi&&this.#nn<this.#tn*this.#Xi:this.#nn>=this.#en*this.#Xi||this.#nn<this.#tn*this.#Xi}minutesUntilDay(){return this.timeUntil(this.#en,"minutes")}secondsUntilDay(){return this.timeUntil(this.#en,"seconds")}hoursUntilDay(){return this.timeUntil(this.#en,"hours")}minutesUntilNight(){return this.timeUntil(this.#tn,"minutes")}secondsUntilNight(){return this.timeUntil(this.#tn,"seconds")}hoursUntilNight(){return this.timeUntil(this.#tn,"hours")}timeUntil(e,t){Or(this.#ur);let r=e*this.#Yi-this.#in;switch(r<=0&&(r+=this.#Gi),t){case"minutes":return r/this.#Xi;case"hours":return r/this.#Yi;default:return r}}setTo(e){Or(this.#ur),"day"===e?this.setTime({hour:this.#en}):"night"===e&&this.setTime({hour:this.#tn})}nextDay(e=1){Or(this.#ur);for(let t=0;t<e;t++){this.#an++;const e=this.#hn[this.#ln-1];if(Number.isNaN(e)||!Number.isFinite(e))throw new Error("Invalid month day count: monthDays must be a finite number.");this.#an>e&&(this.#an=1,this.#ln++,this.#ln>this.#hn.length&&(this.#ln=1,this.#un++)),this.updateSeason(),this.advanceMoons(1)}}prevDay(e=1){Or(this.#ur);for(let t=0;t<e;t++)this.#an--,this.#an<1&&(this.#ln--,this.#ln<1&&(this.#ln=this.#hn.length,this.#un--),this.#an=this.#hn[this.#ln-1]||30),this.updateSeason(),this.rewindMoons(1)}updateSeason(){Or(this.#ur),this.#Qi.forEach((e,t)=>{e.includes(this.#ln)&&(this.#on=t)})}setWeatherConfig(e){Or(this.#ur),this.#dn={...this.#dn,...e}}setWeatherDuration(e,t){Or(this.#ur),this.#cn.min=e,this.#cn.max=t}updateWeatherTimer(e){Or(this.#ur),this.#mn-=e,this.#mn<=0&&this.chooseNewWeather()}forceWeather({where:e="main",type:t,duration:r=null}){Or(this.#ur);const i=this.#rn;i[e]=t,this.weather=i,this.#mn=r??this._randomInRange(this.#cn.min,this.#cn.max)}chooseNewWeather({customWeather:e,where:t="main"}={}){Or(this.#ur);let r={};const i=e=>{for(const[t,i]of Object.entries(e)){let e=i;"function"==typeof e&&(e=e({hour:Math.floor(this.#nn/this.#Xi),minute:this.#nn%this.#Xi,currentMinutes:this.#nn,isDay:this.isDay(),season:this.#on,weather:this.#rn})),"number"!=typeof e||Number.isNaN(e)||(r[t]=(r[t]||0)+e)}};i(this.#dn.default||{});for(const e in this.#dn.hours){const[t,r]=e.split("-").map(e=>{const[t,r]=e.split(":").map(Number);return t*this.#Xi+(r||0)}),n=this.#nn;(t<=r?n>=t&&n<=r:n>=t||n<=r)&&i(this.#dn.hours[e])}this.isDay()&&this.#dn.day?i(this.#dn.day):!this.isDay()&&this.#dn.night&&i(this.#dn.night),this.#dn.seasons?.[this.#on]&&i(this.#dn.seasons[this.#on]),e&&"object"==typeof e&&i(e);const n=Object.entries(r).filter(([,e])=>e>0);if(!n.length)return this.#rn[t]=null,null;const s=n.reduce((e,[,t])=>e+t,0);let o=Math.random()*s;for(const[e,r]of n){if(o<r)return this.#rn[t]=e,this.#mn=this._randomInRange(this.#cn.min,this.#cn.max),e;o-=r}return this.#rn[t]=null,null}_randomInRange(e,t){return Math.floor(Math.random()*(t-e+1))+e}addMoon(e,t,r,i=0){Or(this.#ur);const n=Math.max(1,t);return this.#Zi.push({name:e,cycleLength:n,currentPhase:(i%n+n)%n,phaseNames:r}),this.#Zi.length-1}removeMoon(e){Or(this.#ur),this.#Zi=this.#Zi.filter(t=>t.name!==e)}advanceMoons(e=1){for(const t in this.#Zi)this.advanceMoon(parseInt(t),e)}rewindMoons(e=1){for(const t in this.#Zi)this.rewindMoon(parseInt(t),e)}advanceMoon(e,t=1){Or(this.#ur);const r=this.#Zi[e];if(!r)throw new RangeError(`No moon found at index ${e}`);r.currentPhase=(r.currentPhase+t)%r.cycleLength}rewindMoon(e,t=1){Or(this.#ur);const r=this.#Zi[e];if(!r)throw new RangeError(`No moon found at index ${e}`);r.currentPhase=(r.currentPhase-t+r.cycleLength)%r.cycleLength}moonExists(e){return Or(this.#ur),!!this.#Zi[e]}getMoon(e){let t;if(Or(this.#ur),"number"==typeof e){if(t=this.#Zi[e],!t)throw new RangeError(`No moon found at index ${e}`)}else{if(!e||"object"!=typeof e||"string"!=typeof e.name||"number"!=typeof e.cycleLength||"number"!=typeof e.currentPhase)throw new TypeError("Invalid moon reference. Expected a number index or a MoonRaw object, received "+typeof e);t=e}return{name:t.name,phaseIndex:t.currentPhase,phaseName:t.phaseNames?t.phaseNames[t.currentPhase]??String(t.currentPhase):String(t.currentPhase),cycleLength:t.cycleLength}}destroy(){this.#ur||(this.#Qi.clear(),this.#Zi.length=0,this.#en=0,this.#tn=0,this.#in=0,this.#nn=0,this.#sn=0,this.#an=1,this.#ln=1,this.#un=1,this.#mn=0,this.#on="",this.#rn={main:null},this.#hn=[],this.#dn.default={},this.#dn.day={},this.#dn.night={},this.#dn.hours={},this.#dn.seasons={},this.#cn={min:0,max:0},this.#ur=!0)}},Fr=ee("TinyAdvancedRaffle");class Br extends lr.EventEmitter{#ur=!1;#pn;#fn;#yn=[];#gn=[];#wn=[];#bn=new Map;#vn=new Set;#En=new Map;#Tn;#Sn=new Map;#xn=new Map;get isDestroyed(){return this.#ur}get freq(){return Fr(this.#ur),Object.fromEntries(this.#xn)}get size(){return Fr(this.#ur),this.#Sn.size}get normalization(){return Fr(this.#ur),this.#pn}set normalization(e){if(Fr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("normalization must be a non-empty string (e.g., 'relative', 'softmax').");this.#pn=e}get seed(){return Fr(this.#ur),this.#fn}set seed(e){if(Fr(this.#ur),null!==e&&("number"!=typeof e||!Number.isFinite(e)))throw new TypeError("seed must be a finite number or null.");this.#fn=e,null!==e&&(this.#Tn=this._makeSeededRng(e))}get globalModifiers(){return Fr(this.#ur),[...this.#yn]}set globalModifiers(e){if(Fr(this.#ur),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("globalModifiers must be an array of functions (WeightsCallback).");this.#yn=e}get temporaryModifiers(){return Fr(this.#ur),[...this.#gn]}set temporaryModifiers(e){if(Fr(this.#ur),!Array.isArray(e)||!e.every(e=>e&&"function"==typeof e.fn&&Number.isInteger(e.uses)&&e.uses>0))throw new TypeError("temporaryModifiers must be an array of objects { fn: function, uses: positive integer }.");this.#gn=e}get conditionalRules(){return Fr(this.#ur),[...this.#wn]}set conditionalRules(e){if(Fr(this.#ur),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("conditionalRules must be an array of functions (WeightsCallback).");this.#wn=e}get pitySystems(){return Fr(this.#ur),Object.fromEntries(this.#bn)}set pitySystems(e){if(Fr(this.#ur),!(e instanceof Map&&[...e.values()].every(e=>e&&"number"==typeof e.threshold&&"number"==typeof e.increment&&"number"==typeof e.cap&&"number"==typeof e.counter&&"number"==typeof e.currentAdd)))throw new TypeError("pitySystems must be a Map<string, Pity> with all numeric fields.");this.#bn=e}get exclusions(){return Fr(this.#ur),Array.from(this.#vn)}set exclusions(e){if(Fr(this.#ur),!(e instanceof Set&&[...e].every(e=>"string"==typeof e)))throw new TypeError("exclusions must be a Set<string>.");this.#vn=e}get groups(){Fr(this.#ur);const e={};return this.#En.forEach((t,r)=>e[r]=Array.from(t)),e}set groups(e){if(Fr(this.#ur),!(e instanceof Map&&[...e.values()].every(e=>e instanceof Set&&[...e].every(e=>"string"==typeof e))))throw new TypeError("groups must be a Map<string, Set<string>>.");this.#En=e}get rng(){return Fr(this.#ur),this.#Tn}set rng(e){if(Fr(this.#ur),"function"!=typeof e||"number"!=typeof e())throw new TypeError("rng must be a function returning a number (RngGenerator).");this.#Tn=e}get items(){Fr(this.#ur);const e={};return this.#Sn.forEach((t,r)=>{e[r]={...t,groups:Array.from(t.groups)}}),e}set items(e){if(Fr(this.#ur),!(e instanceof Map&&[...e.values()].every(e=>e&&"string"==typeof e.id&&"string"==typeof e.label&&"number"==typeof e.baseWeight&&e.groups instanceof Set&&"boolean"==typeof e.locked&&"object"==typeof e.meta)))throw new TypeError("items must be a Map<string, ItemData> with valid item structures.");this.clearList(),this.#Sn=e}constructor(e={}){super();const{rng:t=null,seed:r=null,normalization:i="relative"}=e;this.#pn=i,this.#fn=r,"function"==typeof t?this.#Tn=t:null!==this.#fn?this.#Tn=this._makeSeededRng(this.#fn):this.#Tn=Math.random,this.#fn=r??null}hasItem(e){if(Fr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#Sn.has(e)}addItem(e,t={}){if(Fr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");if("object"!=typeof t||null===t)throw new TypeError("opts must be an object");let{weight:r=1,label:i=e,meta:n={},groups:s=[]}=t;if("number"!=typeof r||!Number.isFinite(r)||r<0)throw new TypeError("weight must be a non-negative number");if("string"!=typeof i)throw new TypeError("label must be a string");if("object"!=typeof n||null===n)throw new TypeError("meta must be an object");if(!(Array.isArray(s)||s instanceof Set))throw new TypeError("groups must be an array or a Set of strings");s=Array.isArray(s)?s:[...s];for(const e of s)if("string"!=typeof e)throw new TypeError("groups must contain only strings");const o={id:e,label:i,baseWeight:Math.max(0,Number(r)||0),meta:{...n},groups:new Set(s),locked:!1};this.#Sn.set(e,o);for(const t of s)this._ensureGroup(t).add(e);return this.emit("itemAdded",o),o}removeItem(e){if(Fr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");const t=this.#Sn.get(e);if(!t)return!1;for(const r of t.groups){const t=this.#En.get(r);t&&t.delete(e)}return this.#Sn.delete(e),this.emit("itemRemoved",e),this.resetFreq(e),this.resetPity(e),!0}setBaseWeight(e,t){if(Fr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");if("number"!=typeof t||!Number.isFinite(t)||t<0)throw new TypeError("weight must be a non-negative number");const r=this.#Sn.get(e);if(!r)throw new Error("Item not found");r.baseWeight=Math.max(0,Number(t)||0),this.emit("weightChanged",{id:e,weight:r.baseWeight})}getItem(e){if(Fr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");return this.#Sn.get(e)??null}listItems(){return Fr(this.#ur),Array.from(this.#Sn.values()).map(e=>({...e}))}clearList(){Fr(this.#ur),this.#Sn.clear(),this.clearFreqs(),this.clearPities()}hasGlobalModifier(e){if(Fr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");return this.#yn.includes(e)}addGlobalModifier(e){if(Fr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");this.#yn.push(e)}removeGlobalModifier(e){if(Fr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");this.#yn=this.#yn.filter(t=>t!==e)}hasTemporaryModifier(e){if(Fr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");return this.#gn.some(t=>t.fn===e)}addTemporaryModifier(e,t=1){if(Fr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");if("number"!=typeof t||Number.isNaN(t))throw new TypeError("uses must be a number");this.#gn.push({fn:e,uses:Math.max(1,Math.floor(t))})}removeTemporaryModifier(e){if(Fr(this.#ur),"function"!=typeof e)throw new TypeError("fn must be a function");const t=this.#gn.length;return this.#gn=this.#gn.filter(t=>t.fn!==e),this.#gn.length!==t}hasConditionalRule(e){if(Fr(this.#ur),"function"!=typeof e)throw new TypeError("ruleFn must be a function");return this.#wn.includes(e)}addConditionalRule(e){if(Fr(this.#ur),"function"!=typeof e)throw new TypeError("ruleFn must be a function");this.#wn.push(e)}removeConditionalRule(e){if(Fr(this.#ur),"function"!=typeof e)throw new TypeError("ruleFn must be a function");const t=this.#wn.length;return this.#wn=this.#wn.filter(t=>t!==e),this.#wn.length!==t}hasPity(e){if(Fr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#bn.has(e)}configurePity(e,t){if(Fr(this.#ur),!this.#Sn.has(e))throw new Error("Item not found");if("object"!=typeof t||null===t)throw new TypeError("cfg must be an object");const{threshold:r,increment:i,cap:n=1/0}=t;if("number"!=typeof r||r<=0)throw new TypeError("threshold must be a positive number");if("number"!=typeof i)throw new TypeError("increment must be a number");if("number"!=typeof n)throw new TypeError("cap must be a number");this.#bn.set(e,{threshold:Math.max(1,r),increment:Number(i)||0,cap:Number(n)||1/0,counter:0,currentAdd:0})}resetPity(e){if(Fr(this.#ur),"string"!=typeof e||!e.trim())throw new TypeError("itemId must be a non-empty string");const t=this.#bn.get(e);t&&(t.counter=0,t.currentAdd=0)}clearPities(){Fr(this.#ur),this.#bn.clear()}hasExclusion(e){if(Fr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#vn.has(e)}excludeItem(e){if(Fr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#vn.add(e)}includeItem(e){if(Fr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#vn.delete(e)}_ensureGroup(e){if(Fr(this.#ur),"string"!=typeof e)throw new TypeError("name must be a string");let t=this.#En.get(e);return t||(t=new Set,this.#En.set(e,t)),t}hasInGroup(e,t){if(Fr(this.#ur),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#En.get(t);return!!r&&r.has(e)}addToGroup(e,t){if(Fr(this.#ur),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#Sn.get(e);if(!r)throw new Error("Item missing");r.groups.add(t),this._ensureGroup(t).add(e)}removeFromGroup(e,t){if(Fr(this.#ur),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#En.get(t);r&&r.delete(e);const i=this.#Sn.get(e);i&&i.groups.delete(t)}clearFreqs(){Fr(this.#ur),this.#xn.clear()}resetFreq(e){if(Fr(this.#ur),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#xn.delete(e)}computeEffectiveWeights(e={}){if(Fr(this.#ur),"object"!=typeof e||null===e)throw new TypeError("computeEffectiveWeights: parameter 'context' must be a non-null object, got "+typeof e);if("previousDraws"in e&&!Array.isArray(e.previousDraws))throw new TypeError("computeEffectiveWeights: context.previousDraws must be an array if provided, got "+typeof e.previousDraws);if("metadata"in e&&void 0!==e.metadata&&("object"!=typeof e.metadata||null===e.metadata))throw new TypeError("computeEffectiveWeights: context.metadata must be a non-null object if provided, got "+typeof e.metadata);const t=new Map;for(const[e,r]of this.#Sn)t.set(e,r.baseWeight);for(const r of this.#yn){const i=r(t,e);if(i instanceof Map)for(const[e,r]of i)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#gn){const i=r.fn(t,e);if(i instanceof Map)for(const[e,r]of i)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#wn){const i=r(t,e);if(i instanceof Map)for(const[e,r]of i)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const[e,r]of this.#bn)if(t.has(e)&&r.counter>r.threshold){r.currentAdd=Math.min(r.cap,r.currentAdd+r.increment);const i=t.get(e);i&&t.set(e,i+r.currentAdd)}for(const e of this.#vn)t.delete(e);for(const[e,r]of Array.from(t.entries()))r>0||t.delete(e);return t}_weightsToDistribution(e){if(!(e instanceof Map))throw new TypeError("_weightsToDistribution: parameter 'weights' must be a Map, got "+typeof e);for(const[t,r]of e){if("string"!=typeof t)throw new TypeError("_weightsToDistribution: weights Map key must be string, got "+typeof t);if("number"!=typeof r||!Number.isFinite(r)||r<0)throw new TypeError(`_weightsToDistribution: weights Map value must be finite non-negative number, got ${r} for key ${t}`)}const t=Array.from(e.entries()).map(([e,t])=>({id:e,weight:t}));if(0===t.length)return[];if("softmax"===this.#pn){const e=Math.max(...t.map(e=>e.weight)),r=t.map(t=>Math.exp(t.weight-e)),i=r.reduce((e,t)=>e+t,0);let n=0;return t.map((e,t)=>{const s=r[t]/i;return n+=s,{id:e.id,weight:e.weight,p:s,cumulative:n}})}{const e=t.reduce((e,t)=>e+t.weight,0);let r=0;return t.map(t=>{const i=t.weight/e;return r+=i,{id:t.id,weight:t.weight,p:i,cumulative:r}})}}drawOne(e={}){if(Fr(this.#ur),"object"!=typeof e||null===e)throw new TypeError("drawOne: parameter 'opts' must be a non-null object, got "+typeof e);if("previousDraws"in e&&!Array.isArray(e.previousDraws))throw new TypeError("drawOne: opts.previousDraws must be an array if provided, got "+typeof e.previousDraws);if("metadata"in e&&void 0!==e.metadata&&("object"!=typeof e.metadata||null===e.metadata))throw new TypeError("drawOne: opts.metadata must be a non-null object if provided, got "+typeof e.metadata);const t={previousDraws:e.previousDraws??[],metadata:e.metadata??{},activeModifiers:[...this.#gn]},r=this.computeEffectiveWeights(t),i=this._weightsToDistribution(r);if(!i.length)return null;const n=this.#Tn(),s=i.find(e=>n<=e.cumulative)??i[i.length-1];for(const[e,t]of this.#bn)e===s.id?(t.counter=0,t.currentAdd=0):t.counter++;this._consumeTemporaryModifiers();const o=this.#Sn.get(s.id);if(!o)return null;const a={id:o.id,label:o.label,meta:{...o.meta},prob:s.p};return this.emit("draw",a),a&&this.#xn.set(a.id,(this.#xn.get(a.id)||0)+1),a}_consumeTemporaryModifiers(){for(let e=this.#gn.length-1;e>=0;--e){const t=this.#gn[e];t.uses-=1,t.uses<=0&&this.#gn.splice(e,1)}}drawMany(e=1,t={}){if(Fr(this.#ur),!Number.isInteger(e)||e<=0)throw new TypeError(`drawMany: parameter 'count' must be a positive integer, got ${e}`);if("object"!=typeof t||null===t)throw new TypeError("drawMany: parameter 'opts' must be a non-null object, got "+typeof t);if("withReplacement"in t&&"boolean"!=typeof t.withReplacement)throw new TypeError("drawMany: opts.withReplacement must be boolean if provided, got "+typeof t.withReplacement);if("ensureUnique"in t&&"boolean"!=typeof t.ensureUnique)throw new TypeError("drawMany: opts.ensureUnique must be boolean if provided, got "+typeof t.ensureUnique);if("metadata"in t&&void 0!==t.metadata&&("object"!=typeof t.metadata||null===t.metadata))throw new TypeError("drawMany: opts.metadata must be a non-null object if provided, got "+typeof t.metadata);if("previousDraws"in t&&!Array.isArray(t.previousDraws))throw new TypeError("drawMany: opts.previousDraws must be an array if provided, got "+typeof t.previousDraws);const r=t.withReplacement??!0,i=t.ensureUnique??!1,n=[],s=t.previousDraws??[];if(!r&&i){const r=new Set;for(let i=0;i<e;++i){const e=new Set(this.#vn);for(const e of r)this.#vn.add(e);const i=this.drawOne({previousDraws:s,metadata:t.metadata});if(this.#vn=e,!i)break;n.push(i),r.add(i.id),s.push(i)}return n}for(let i=0;i<e;++i){const e=this.drawOne({previousDraws:s,metadata:t.metadata});if(!e)break;n.push(e),s.push(e),r||this.excludeItem(e.id)}if(!r)for(const e of n)this.includeItem(e.id);return n}exportToJson(){return Fr(this.#ur),{items:Array.from(this.#Sn.values()).map(e=>({id:e.id,label:e.label,baseWeight:e.baseWeight,meta:e.meta,groups:Array.from(e.groups),locked:!1})),pity:Array.from(this.#bn.entries()),exclusions:Array.from(this.#vn),normalization:this.#pn,seed:this.#fn}}loadFromJson(e){if(Fr(this.#ur),"object"!=typeof e||null===e)throw new TypeError("data must be a non-null object");if(!Array.isArray(e.items)||!Array.isArray(e.pity)||!Array.isArray(e.exclusions))throw new TypeError("data must have items, pity, and exclusions arrays");if("string"!=typeof e.normalization)throw new TypeError("data.normalization must be a string");if(void 0!==e.seed&&null!==e.seed&&"number"!=typeof e.seed)throw new TypeError("data.seed must be a number, null, or undefined");this.clearList();for(const t of e.items){if("object"!=typeof t||null===t)throw new TypeError("Each item must be a non-null object");if("string"!=typeof t.id||!t.id.trim())throw new TypeError("Each item.id must be a non-empty string");if("string"!=typeof t.label)throw new TypeError(`Item with id "${t.id}" has invalid label; must be string`);if("number"!=typeof t.baseWeight||!Number.isFinite(t.baseWeight)||t.baseWeight<0)throw new TypeError(`Item with id "${t.id}" has invalid baseWeight; must be a finite non-negative number`);if(void 0!==t.groups&&!Array.isArray(t.groups))throw new TypeError(`Item with id "${t.id}" has invalid groups; must be an array of strings`);if(t.groups&&!t.groups.every(e=>"string"==typeof e))throw new TypeError(`Item with id "${t.id}" has groups containing non-string values`);if(void 0!==t.meta&&("object"!=typeof t.meta||null===t.meta))throw new TypeError(`Item with id "${t.id}" has invalid meta; must be an object`);this.#Sn.set(t.id,{id:t.id,label:t.label,baseWeight:t.baseWeight,meta:t.meta||{},groups:new Set(t.groups||[]),locked:!1});for(const e of t.groups||[])this._ensureGroup(e).add(t.id)}this.pitySystems=new Map(e.pity||[]),this.exclusions=new Set(e.exclusions||[]),this.normalization=e.normalization,void 0!==e.seed&&(this.seed=e.seed)}clone(){Fr(this.#ur);const e=new Br;return e.#pn=this.#pn,e.#fn=this.#fn,e.#yn=[...this.#yn],e.#gn=this.#gn.map(e=>({fn:e.fn,uses:e.uses})),e.#wn=[...this.#wn],e.#bn=new Map([...this.#bn.entries()].map(([e,t])=>[e,{...t}])),e.#vn=new Set(this.#vn),e.#En=new Map([...this.#En.entries()].map(([e,t])=>[e,new Set(t)])),e.#Tn=this.#Tn,e.#Sn=new Map([...this.#Sn.entries()].map(([e,t])=>[e,{...t,groups:new Set(t.groups),meta:{...t.meta}}])),e.#xn=new Map(this.#xn),e}_makeSeededRng(e){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("seed must be a finite number");let t=e>>>0;return function(){t+=1831565813;let e=Math.imul(t^t>>>15,1|t);return e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}destroy(){this.#ur||(this.#bn.clear(),this.#vn.clear(),this.#En.clear(),this.#Sn.clear(),this.#xn.clear(),this.#yn=[],this.#gn=[],this.#wn=[],this.#fn=null,this.#ur=!0)}}const zr=Br,Wr=class{#ie;get data(){return this.#ie}set data(e){if(!(Array.isArray(e)||e instanceof Set))throw new TypeError("Paginator expects an array or Set as data source.");this.#ie=e}get size(){return Array.isArray(this.#ie)?this.#ie.length:this.#ie.size}constructor(e){if(!(Array.isArray(e)||e instanceof Set))throw new TypeError("Paginator expects an array or Set as data source.");this.#ie=e}get({page:e,perPage:t,filter:r}){if(!Number.isInteger(e)||e<1)throw new RangeError("Page number must be a positive integer.");if(!Number.isInteger(t)||t<1)throw new RangeError("Items per page must be a positive integer.");const i=Array.isArray(this.#ie)?this.#ie:Array.from(this.#ie);let n=i;if(r)if("function"==typeof r)n=i.filter((e,t,i)=>r(e,t,i));else{if("object"!=typeof r)throw new TypeError("Filter must be an object or a function");n=i.filter(e=>Object.entries(r).every(([t,r])=>{const i=e[t];return r instanceof RegExp?r.test(i):i===r}))}else n=i;const s=n.length,o=Math.max(1,Math.ceil(s/t)),a=Math.min(e,o),l=(a-1)*t,u=l+t,h=a>1,d=a<o;return{items:n.slice(l,u),page:a,perPage:t,totalItems:s,totalPages:o,hasPrev:h,hasNext:d}}};class Vr{static#An=new Map;static get itemRegistry(){const e={},t=Object.fromEntries(Vr.#An);for(const r in t)e[r]={...t[r],metadata:{...t[r].metadata}};return e}static defineItem(e){if(!e||"object"!=typeof e)throw new TypeError("Config must be a valid object.");if(!e.id||"string"!=typeof e.id)throw new TypeError("Item must have a valid string 'id'.");if(void 0!==e.weight&&("number"!=typeof e.weight||e.weight<0))throw new TypeError(`weight must be a number >= 0. Received: ${e.weight}`);if(void 0!==e.maxStack&&(!Number.isInteger(e.maxStack)||e.maxStack<=0))throw new TypeError(`maxStack must be a positive integer. Received: ${e.maxStack}`);if(void 0!==e.metadata&&"object"!=typeof e.metadata)throw new TypeError("metadata must be an object.");if(void 0!==e.onUse&&null!==e.onUse&&"function"!=typeof e.onUse)throw new TypeError("onUse must be a function or null.");if(void 0!==e.type&&null!==e.type&&"string"!=typeof e.type)throw new TypeError("type must be a string or null.");Vr.#An.set(e.id,{id:e.id,weight:e.weight||0,maxStack:e.maxStack||1,metadata:e.metadata||{},type:e.type??null,onUse:"function"==typeof e.onUse?e.onUse:null})}static removeItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");return Vr.#An.delete(e)}static hasItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");return Vr.#An.has(e)}static getItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");const t=Vr.#An.get(e);if(!t)throw new Error(`Item '${e}' not defined in registry.`);return t}#Cn=new Map;#In={add:[],remove:[],use:[],set:[]};#Sn=[];#Mn;#Dn;#kn;#Nn;get maxStack(){return this.#Mn}set maxStack(e){if(!Number.isInteger(e)||Number.isFinite(e)&&e<=0)throw new TypeError(`maxStack must be a positive integer. Received: ${e}`);this.#Mn=e}get maxSize(){return this.#Dn}set maxSize(e){if(null!==e&&(!Number.isInteger(e)||e<=0))throw new TypeError(`maxSize must be null or a positive integer. Received: ${e}`);this.#Dn=e}get maxSlots(){return this.#kn}set maxSlots(e){if(null!==e&&(!Number.isInteger(e)||e<=0))throw new TypeError(`maxSlots must be null or a positive integer. Received: ${e}`);this.#kn=e}get maxWeight(){return this.#Nn}set maxWeight(e){if(null!==e&&("number"!=typeof e||e<=0))throw new TypeError(`maxWeight must be null or a positive number. Received: ${e}`);this.#Nn=e}get events(){return{add:[...this.#In.add],remove:[...this.#In.remove],use:[...this.#In.use],set:[...this.#In.set]}}get items(){return[...this.#Sn].map(e=>e?this.#Ln(e):null)}get specialSlots(){return new Map([...this.#Cn.entries()].map(([e,t])=>[e,{type:t.type,item:t.item?this.#Ln(t.item):null}]))}get size(){const e=this.getAllItems();let t=0;for(const r of e)t+=r.quantity;return t}get slotsSize(){return this.getAllItems().length}get weight(){return this.getAllItems().reduce((e,t)=>{const r=Vr.getItem(t.id);return e+(r?.weight||0)*t.quantity},0)}_cleanNulls(){let e=this.#Sn.length-1;for(;e>=0&&null===this.#Sn[e];)e--;this.#Sn=this.#Sn.slice(0,e+1)}constructor(e={}){if("object"!=typeof e||null===e)throw new TypeError("`options` must be an object.");if(void 0!==e.maxWeight&&null!==e.maxWeight&&"number"!=typeof e.maxWeight)throw new TypeError("`maxWeight` must be a number or null.");if(void 0!==e.maxSlots&&null!==e.maxSlots&&"number"!=typeof e.maxSlots)throw new TypeError("`maxSlots` must be a number or null.");if(void 0!==e.maxSize&&null!==e.maxSize&&"number"!=typeof e.maxSize)throw new TypeError("`maxSize` must be a number or null.");if(void 0!==e.maxStack&&"number"!=typeof e.maxStack)throw new TypeError("`maxStack` must be a number.");if(void 0!==e.specialSlots&&"object"!=typeof e.specialSlots)throw new TypeError("`specialSlots` must be an object if defined.");if(this.#Nn=e.maxWeight??null,this.#kn=e.maxSlots??null,this.#Dn=e.maxSize??null,this.#Mn=e.maxStack??1/0,e.specialSlots)for(const t in e.specialSlots){const r=e.specialSlots[t];if("object"!=typeof r||null===r)throw new TypeError("Each `specialSlot` entry must be an object.");if(void 0!==r.type&&null!==r.type&&"string"!=typeof r.type)throw new TypeError("`specialSlot.type` must be a string or null.");this.#Cn.set(t,{type:r.type??null,item:null})}}hasSpace({weight:e=0,sizeLength:t=0,slotsLength:r=0}={}){if("number"!=typeof e)throw new TypeError("`weight` must be a number.");if("number"!=typeof t)throw new TypeError("`sizeLength` must be a number.");if("number"!=typeof r)throw new TypeError("`slotsLength` must be a number.");return!(this.areFull(t)||this.areFullSlots(r)||this.isHeavy(e))}isHeavy(e=0){if("number"!=typeof e)throw new TypeError("`extraWeight` must be a number.");return null!==this.#Nn&&this.weight+e>this.#Nn}areFull(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Dn&&this.size+e>this.#Dn}isFull(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Dn&&this.size+e>=this.#Dn}areFullSlots(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#kn&&this.slotsSize+e>this.#kn}isFullSlots(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#kn&&this.slotsSize+e>=this.#kn}#_n(e,t){if("string"!=typeof e)throw new TypeError("`type` must be a string.");if("object"!=typeof t||null===t)throw new TypeError("`payload` must be an object.");if(this.#In[e])for(const r of this.#In[e])r(t)}off(e,t){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");if("function"!=typeof t)throw new TypeError("`callback` must be a function.");if(!this.#In[e])return;const r=this.#In[e],i=r.indexOf(t);-1!==i&&r.splice(i,1)}offAll(e){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");this.#In[e]&&(this.#In[e]=[])}cloneEventCallbacks(e){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");return this.#In[e]?[...this.#In[e]]:[]}onAddItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#In.add.push(e)}onSetItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#In.set.push(e)}onRemoveItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#In.remove.push(e)}onUseItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#In.use.push(e)}compactInventory(){this.#Sn=this.#Sn.filter((e,t)=>{const r=null!==e;return r||this.#_n("remove",{index:t,item:null,isCollection:!0,specialSlot:null,remove:()=>{}}),r})}addItem({itemId:e,quantity:t=1,metadata:r={},forceSpace:i=!1}){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");if("number"!=typeof t||!Number.isFinite(t)||t<=0)throw new TypeError("`quantity` must be a positive number.");if("object"!=typeof r||null===r)throw new TypeError("`metadata` must be an object.");if("boolean"!=typeof i)throw new TypeError("`forceSpace` must be a boolean.");const n=Vr.getItem(e);let s=t;const o=n.maxStack<=this.#Mn?n.maxStack:this.#Mn,a=[],l=(e,t)=>JSON.stringify(e)===JSON.stringify(t);let u=!0;for(;s>0&&u;){u=!1;for(const t in this.#Sn){const h=this.#Sn[t];if(h&&h.id===e&&h.quantity<o&&l(h.metadata,r)){const e=Math.min(o-h.quantity,s);if(!i&&!this.hasSpace({weight:n.weight*e,sizeLength:e}))continue;h.quantity+=e,s-=e,u=!0;const r=Number(t),l=a.findIndex(e=>e.index===r);if(l<0?a.push({index:r,quantity:e}):a[l].quantity+=e,this.#_n("add",{item:this.#Ln(h),index:r,isCollection:!0,specialSlot:null,remove:this.#jn({locationType:"normal",slotIndex:r,forceSpace:i,item:h})}),s<=0)break}}}if(s>0)for(const t in this.#Sn)if(null===this.#Sn[t]){const l=Math.min(o,s);if(!i&&!this.hasSpace({weight:n.weight*l,sizeLength:l}))continue;const u={id:e,quantity:l,metadata:r};this.#Sn[t]=u,s-=l;const h=Number(t),d=a.findIndex(e=>e.index===h);if(d<0?a.push({index:h,quantity:l}):a[d].quantity+=l,this.#_n("add",{item:this.#Ln(u),index:h,isCollection:!0,specialSlot:null,remove:this.#jn({locationType:"normal",slotIndex:h,forceSpace:i,item:u})}),s<=0)break}for(;s>0;){const t=Math.min(o,s);if(!i&&!this.hasSpace({weight:n.weight*t,sizeLength:t,slotsLength:1}))break;const l={id:e,quantity:t,metadata:r};this.#Sn.push(l);const u=this.#Sn.length-1,h=a.findIndex(e=>e.index===u);h<0?a.push({index:u,quantity:t}):a[h].quantity+=t,this.#_n("add",{item:this.#Ln(l),index:u,isCollection:!0,specialSlot:null,remove:this.#jn({locationType:"normal",slotIndex:u,forceSpace:i,item:l})}),s-=t}return{remaining:s,placesAdded:a}}getItemFrom(e){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if(e<0||e>=this.#Sn.length)throw new Error(`Slot index '${e}' out of bounds .`);return this.#Sn[e]?this.#Ln(this.#Sn[e]):null}setItem({slotIndex:e,item:t,forceSpace:r=!1}){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be a boolean.");const i=t&&"object"==typeof t&&"string"==typeof t.id&&"number"==typeof t.quantity&&!Number.isNaN(t.quantity)&&Number.isFinite(t.quantity)&&t.quantity>-1&&"object"==typeof t.metadata;if(null!==t&&!i)throw new Error("Invalid item type: must be null or a valid InventoryItem.");const n=t?Vr.#An.get(t.id):null;if(null!==t&&!n)throw new Error(`Item '${t?.id??"unknown"}' not defined in registry.`);if(n&&t){const e=n.maxStack<=this.#Mn?n.maxStack:this.#Mn;if(t.quantity>e)throw new Error(`Item '${t.id}' exceeds max stack size. Allowed: ${e}, got: ${t.quantity}.`)}if(null!==this.#kn&&(e<0||e>=this.#kn))throw new Error(`Slot index ${e} out of range.`);const s=this.#Sn[e]??null,o=s?Vr.#An.get(s.id)??null:null,a=(e,t)=>t?t.weight*(e?e.quantity:0):0,l=e=>e?e.quantity:0;if(!r&&!this.hasSpace({weight:a(t,n)-a(s,o),sizeLength:l(t)-l(s)}))throw new Error("Inventory is full or overweight.");for(;this.#Sn.length<=e;)this.#Sn.push(null);this.#Sn[e]=t,this._cleanNulls(),this.#_n("set",{index:e,isCollection:!0,item:t?this.#Ln(t):null,specialSlot:null,remove:t?this.#jn({locationType:"normal",slotIndex:e,forceSpace:r,item:t}):()=>{}})}deleteItem(e,t=!1){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if("boolean"!=typeof t)throw new TypeError("`forceSpace` must be a boolean.");this.setItem({slotIndex:e,item:null,forceSpace:t})}moveItem(e,t,r=!1){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`fromIndex` must be an integer.");if("number"!=typeof t||!Number.isInteger(t))throw new TypeError("`toIndex` must be an integer.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be a boolean.");const i=this.#Sn[e];if(!i)throw new Error(`No item found in slot ${e}.`);this.setItem({slotIndex:t,item:i,forceSpace:r}),this.setItem({slotIndex:e,item:null,forceSpace:r})}removeItem({itemId:e,metadata:t=null,quantity:r=1}){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");if(null!==t&&"object"!=typeof t)throw new TypeError("`metadata` must be an object or null.");if("number"!=typeof r||!Number.isFinite(r)||r<=0)throw new TypeError("`quantity` must be a positive number.");let i=r;const n=(e,t)=>JSON.stringify(e)===JSON.stringify(t);for(let r=0;r<this.#Sn.length;r++){const s=this.#Sn[r];if(s&&s.id===e&&(null===t||n(s.metadata,t))){const e=Math.min(s.quantity,i);s.quantity-=e,i-=e;const t=Number(r);if(s.quantity<=0&&(this.#Sn[r]=null),i<=0)return this._cleanNulls(),this.#_n("remove",{index:t,item:this.#Ln(s),isCollection:!0,specialSlot:null,remove:this.#jn({locationType:"normal",slotIndex:t,item:s})}),!0}}return this._cleanNulls(),this.#Cn.forEach((r,s)=>{if(i>0&&r.item&&r.item.id===e&&(null===t||n(r.item.metadata,t))){const e=Math.min(r.item.quantity,i);r.item.quantity-=e,r.item.quantity<0&&(r.item.quantity=0),i-=e,r.item.quantity<=0&&(r.item=null),this.#Cn.set(s,r),this.#_n("remove",{index:null,item:r.item?this.#Ln(r.item):null,isCollection:!1,specialSlot:s,remove:r.item?this.#jn({locationType:"special",specialSlot:s,item:r.item}):()=>{}})}}),i<=0}#jn({locationType:e,specialSlot:t,slotIndex:r,item:i,forceSpace:n=!1}){if("normal"!==e&&"special"!==e)throw new TypeError("`locationType` must be 'normal' or 'special'.");if("boolean"!=typeof n)throw new TypeError("`forceSpace` must be boolean.");if(!i||"object"!=typeof i)throw new TypeError("`item` must be an InventoryItem object.");if("special"===e&&t&&"string"!=typeof t)throw new TypeError("`specialSlot` must be a string when locationType is 'special'.");if("normal"===e&&"number"!=typeof r)throw new TypeError("`slotIndex` must be a number when locationType is 'normal'.");return(s=n)=>{if("special"===e&&t){const e=this.#Cn.get(t);if(!e?.item)throw new Error(`Special slot '${t}' is empty.`);e.item.quantity>1?(e.item.quantity-=1,this.#Cn.set(t,e)):this.setSpecialSlot({slotId:t,item:null,forceSpace:s})}else{if("number"!=typeof r)throw new Error("Invalid remove operation: no valid slotIndex or specialSlot provided.");i.quantity>1?this.setItem({slotIndex:r,item:{...i,quantity:i.quantity-1},forceSpace:s}):this.setItem({slotIndex:r,item:null,forceSpace:s})}}}useItem({slotIndex:e,specialSlot:t,forceSpace:r=!1},...i){if(void 0!==e&&("number"!=typeof e||!Number.isInteger(e)))throw new TypeError("`slotIndex` must be an integer if provided.");if(void 0!==t&&"string"!=typeof t)throw new TypeError("`specialSlot` must be a string if provided.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");let n=null,s="normal",o=null;if(t){if(!this.#Cn.has(t))throw new Error(`Special slot '${t}' not found.`);n=this.#Cn.get(t).item,s="special"}else o=this.#Sn,n=o[e??-1]??null,s="normal";if(!n)throw new Error("special"===s?`No item found in special slot '${t}'.`:`No item found in slot ${e} of inventory.`);const a=Vr.getItem(n.id);if(a.onUse){const l={inventory:this,item:this.#Ln(n),index:e??null,specialSlot:t??null,isCollection:!!o,itemDef:a,remove:this.#jn({locationType:s,specialSlot:t,slotIndex:e,forceSpace:r,item:n}),...i},u=a.onUse(l);return this.#_n("use",l),u}return null}hasSpecialSlot(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");return this.#Cn.has(e)}getSpecialItem(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(!this.#Cn.has(e))throw new Error(`Special slot '${e}' does not exist.`);const t=this.#Cn.get(e);return t?.item?this.#Ln(t.item):null}getSpecialSlotType(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(!this.#Cn.has(e))throw new Error(`Special slot '${e}' does not exist.`);const t=this.#Cn.get(e);return t?.type??null}setSpecialSlot({slotId:e,item:t,forceSpace:r=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");if(!this.#Cn.has(e))throw new Error(`Special slot '${e}' not found.`);const i=t&&"object"==typeof t&&"string"==typeof t.id&&"number"==typeof t.quantity&&!Number.isNaN(t.quantity)&&Number.isFinite(t.quantity)&&t.quantity>-1&&"object"==typeof t.metadata;if(null!==t&&!i)throw new Error("Invalid item type: must be null or a valid InventoryItem.");const n=t?Vr.#An.get(t.id):null;if(null!==t&&!n)throw new Error(`Item '${t?.id??"unknown"}' not defined in registry.`);const s=this.#Cn.get(e);if(!s)throw new Error(`Special slot ${e} out of range for slot '${e}'.`);const o=s.item?Vr.#An.get(s.item.id):null,a=(e,t)=>t?t.weight*(e?1:0):0,l=e=>e?1:0;if(!r&&!this.hasSpace({weight:a(t,n)-a(s.item,o),sizeLength:l(t)-l(s.item)}))throw new Error("Inventory is full or overweight.");s.item=t,this.#_n("set",{index:null,item:t?this.#Ln(t):null,isCollection:!1,specialSlot:e,remove:t?this.#jn({locationType:"special",specialSlot:e,forceSpace:r,item:t}):()=>{}})}deleteSpecialItem(e,t=!1){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if("boolean"!=typeof t)throw new TypeError("`forceSpace` must be boolean.");this.setSpecialSlot({slotId:e,item:null,forceSpace:t})}equipItem({slotId:e,slotIndex:t,quantity:r=1,forceSpace:i=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if("number"!=typeof t||!Number.isInteger(t))throw new TypeError("`slotIndex` must be an integer.");if("number"!=typeof r||!Number.isFinite(r)||r<=0)throw new TypeError("`quantity` must be a positive number.");if("boolean"!=typeof i)throw new TypeError("`forceSpace` must be boolean.");if(r<=0||!Number.isFinite(r))throw new Error(`Invalid quantity '${r}'.`);if(!this.#Cn.has(e))throw new Error(`Special slot '${e}' does not exist.`);const n=this.getItemFrom(t);if(!n)throw new Error(`No item found in inventory slot ${t}.`);if(n.quantity<r)throw new Error(`Not enough quantity of item '${n.id}' in inventory slot.`);const s=Vr.getItem(n.id),o=this.#Cn.get(e);if(!o)throw new Error(`Slot '${e}' not defined in registry.`);const a=o.type??null;if(null!==a&&s.type!==a)throw new Error(`Item '${n.id}' cannot be equipped in slot '${e}'.`);const l=Math.min(s.maxStack,this.#Mn);if(o.item&&o.item.id===n.id){const t=Math.max(0,l-o.item.quantity);if(t<=0)return r;const i=Math.min(r,t);return this.removeItem({itemId:n.id,quantity:i,metadata:null}),o.item.quantity+=i,this.#Cn.set(e,o),r-i}o.item&&this.unequipItem({slotId:e,forceSpace:i});const u=Math.min(r,l);return this.removeItem({itemId:n.id,quantity:u,metadata:null}),o.item={id:n.id,quantity:u,metadata:n.metadata},this.#Cn.set(e,o),r-u}unequipItem({slotId:e,quantity:t=null,forceSpace:r=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(null!==t&&("number"!=typeof t||!Number.isFinite(t)||t<=0))throw new TypeError("`quantity` must be a positive number or null.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");if(!this.#Cn.has(e))throw new Error(`Special slot '${e}' does not exist.`);const i=this.#Cn.get(e);if(!i)throw new Error(`Slot '${e}' not defined in registry.`);if(!i.item)return!1;const n=i.item,s=null===t?n.quantity:t;if(s<=0)throw new Error(`Invalid unequip quantity: ${s}`);if(s>n.quantity)throw new Error(`Not enough items in slot '${e}' to unequip.`);return this.addItem({itemId:n.id,quantity:s,metadata:n.metadata,forceSpace:r}),s===n.quantity?i.item=null:(n.quantity-=s,i.item=n),this.#Cn.set(e,i),!0}#Ln(e){if(!e||"object"!=typeof e)throw new TypeError("`item` must be an InventoryItem object.");if("string"!=typeof e.id)throw new TypeError("`item.id` must be a string.");if("number"!=typeof e.quantity||!Number.isFinite(e.quantity))throw new TypeError("`item.quantity` must be a finite number.");if(!e.metadata||"object"!=typeof e.metadata)throw new TypeError("`item.metadata` must be an object.");return{id:e.id,quantity:e.quantity,metadata:{...e.metadata}}}getItemList(){return[...this.#Sn].map((e,t)=>[e?this.#Ln(e):null,t]).filter(e=>null!==e[0])}getAllItems(){const e=[...this.#Sn].filter(e=>null!==e).map(this.#Ln);return this.#Cn.forEach(t=>{const r=t.item;r&&e.push(r)}),e}getItemsByMetadata(e){if("function"!=typeof e)throw new TypeError("`filterFn` must be a function.");return this.getAllItems().filter(t=>{const r=Vr.getItem(t.id);return e(r.metadata,t)})}findItem(e){if("function"!=typeof e)throw new TypeError("`predicate` must be a function.");return this.getAllItems().find(e)}findItems(e){if("function"!=typeof e)throw new TypeError("`predicate` must be a function.");return this.getAllItems().filter(e)}getItemCount(e){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");return this.getAllItems().filter(t=>t.id===e).reduce((e,t)=>e+t.quantity,0)}hasItem(e,t=1){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");if("number"!=typeof t||!Number.isFinite(t)||t<0)throw new TypeError("`quantity` must be a non-negative number.");return this.getItemCount(e)>=t}existsItemAt(e){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");return!!this.#Sn[e]}clear(){this.clearAllItems(),this.clearAllEvents()}clearAllEvents(){this.#In={add:[],remove:[],use:[],set:[]}}clearAllItems(){this.clearItems(),this.clearSpecialItems()}clearItems(){for(let e=this.#Sn.length-1;e>=0;e--)this.#Sn[e]&&this.deleteItem(e,!0)}clearSpecialItems(){for(const e of this.#Cn.keys()){const t=this.#Cn.get(e);t?.item&&this.deleteSpecialItem(e,!0)}}clone(){const e=this.toObject();return Vr.fromObject(e)}toObject(){const e={};for(const[t,r]of this.#Cn.entries())e[t]={type:r?.type??null,item:r?.item?this.#Ln(r.item):null};return{__schema:"TinyInventory",version:1,maxWeight:this.#Nn,maxSlots:this.#kn,maxSize:this.#Dn,maxStack:this.#Mn,items:this.#Sn.map(e=>e?this.#Ln(e):null),specialSlots:e}}toJSON(e=0){if("number"!=typeof e||!Number.isFinite(e)||e<0)throw new TypeError("`space` must be a non-negative number.");return JSON.stringify(this.toObject(),null,e)}static fromObject(e){if(!e||"object"!=typeof e)throw new TypeError("Invalid state: expected object.");if("TinyInventory"!==e.__schema||"number"!=typeof e.version)throw new TypeError("Invalid or missing schema header.");if(1!==e.version)throw new TypeError(`Unsupported TinyInventory state version: ${e.version}`);const t={};if(e.specialSlots&&"object"==typeof e.specialSlots)for(const r of Object.keys(e.specialSlots))t[r]={type:e.specialSlots[r]?.type??null};const r=new Vr({maxWeight:e.maxWeight??null,maxSlots:e.maxSlots??null,maxSize:e.maxSize??null,maxStack:e.maxStack??null,specialSlots:t});if(Array.isArray(e.items))for(const t in e.items){const i=e.items[t];if(null!==i){const e={id:String(i.id),quantity:Math.max(1,Number(i.quantity)||1),metadata:i.metadata&&"object"==typeof i.metadata?i.metadata:{}};r.setItem({slotIndex:Number(t),item:e,forceSpace:!0})}else r.setItem({slotIndex:Number(t),item:null,forceSpace:!0})}if(e.specialSlots&&"object"==typeof e.specialSlots)for(const[t,i]of Object.entries(e.specialSlots)){if(!r.hasSpecialSlot(t))continue;const e=i?.item;if(e&&e.id){const i={id:String(e.id),quantity:Math.max(1,Number(e.quantity)||1),metadata:e.metadata&&"object"==typeof e.metadata?e.metadata:{}};r.setSpecialSlot({slotId:t,item:i,forceSpace:!0})}}return r}static fromJSON(e){if("string"!=typeof e)throw new TypeError("`json` must be a string.");const t=JSON.parse(e);return Vr.fromObject(t)}}const qr=Vr,Kr=class{#Rn=null;#Pn=null;get sender(){return this.#Rn}get receiver(){return this.#Pn}set sender(e){if(!(e instanceof qr&&this.receiver instanceof qr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Rn=e}set receiver(e){if(!(this.sender instanceof qr&&e instanceof qr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Pn=e}constructor(e,t){if(e||t){if(!(e instanceof qr&&t instanceof qr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.connect(e,t)}}connect(e,t){if(!(e instanceof qr&&t instanceof qr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Rn=e,this.#Pn=t}disconnect(){this.#Rn=null,this.#Pn=null}invert(){const e=this.#Rn,t=this.#Pn;this.#Rn=t,this.#Pn=e}transferItem({slotIndex:e,specialSlot:t,quantity:r=1,receiverSlotIndex:i,forceSpace:n=!1,strict:s=!1}){if(!this.#Rn||!this.#Pn)throw new Error("Sender and receiver inventories must be connected.");let o;if(t){if(o=this.#Rn.getSpecialItem(t),!o)throw new Error(`No item found in sender special slot '${t}'.`)}else{if("number"!=typeof e)throw new Error("Must provide either slotIndex or specialSlot.");if(o=this.#Rn.getItemFrom(e),!o)throw new Error(`No item found in sender slot ${e}.`)}if(o.quantity<r)throw new Error(`Sender does not have enough quantity of '${o.id}' to transfer.`);const a={id:o.id,quantity:r,metadata:o.metadata};let l;if(s)if("number"==typeof i){const e=this.#Pn.existsItemAt(i)?this.#Pn.getItemFrom(i):null;if(e){if(e.id!==a.id)throw new Error(`Receiver slot ${i} contains a different item.`);const t=qr.getItem(e.id).maxStack-e.quantity;if(a.quantity>t)throw new Error(`Strict mode: not enough space in receiver slot ${i}.`)}}else if(this.#Pn.clone().addItem({itemId:a.id,quantity:a.quantity,metadata:a.metadata,forceSpace:n}).remaining>0)throw new Error("Strict mode: not enough space in receiver inventory.");if("number"==typeof i){const e=this.#Pn.existsItemAt(i)?this.#Pn.getItemFrom(i):null;let t=a.quantity;if(e){if(e.id!==a.id)throw new Error(`Receiver slot ${i} contains a different item.`);const r=qr.getItem(e.id).maxStack-e.quantity;t=Math.min(r,a.quantity),t>0&&this.#Pn.setItem({slotIndex:i,item:{...e,quantity:e.quantity+t},forceSpace:n})}else this.#Pn.setItem({slotIndex:i,item:a,forceSpace:n});l={remaining:a.quantity-t}}else l=this.#Pn.addItem({itemId:a.id,quantity:a.quantity,metadata:a.metadata,forceSpace:n});const u=a.quantity-l.remaining;if(u>0)if(t)this.#Rn.unequipItem({slotId:t,quantity:u,forceSpace:n});else if("number"==typeof e){const t=o.quantity-u;this.#Rn.setItem({slotIndex:e,item:t>0?{...o,quantity:t}:null,forceSpace:n})}return l}transferMultiple(e){return e.map(e=>this.transferItem(e))}},Jr=class{#$n;#vt={message:"We use cookies to improve your experience.",acceptText:"Accept All",rejectText:"Reject All",settingsText:"Manage Settings",categories:[],storageKey:"cookie-consent-preferences",onSave:e=>console.log("Preferences saved:",e),animationDuration:400,renderBar:null,renderModal:null};get preferences(){const e=localStorage.getItem(this.#vt.storageKey);return e?JSON.parse(e):{}}get config(){return{...this.#vt,categories:[...this.#vt.categories]}}set config(e){this.validateConfig(e),this.#vt=Object.assign(this.#vt,e)}constructor(e){if(!e||"object"!=typeof e)throw new TypeError("Config must be an object.");this.config=e;const t=this.loadPreferences();this.#$n=t??{},t||this.showConsentBar()}validateConfig(e){if(void 0!==e.message&&"string"!=typeof e.message)throw new TypeError("Config.message must be a string.");if(["acceptText","rejectText","settingsText","storageKey"].forEach(t=>{if(void 0!==e[t]&&"string"!=typeof e[t])throw new TypeError(`Config.${t} must be a string.`)}),void 0!==e.categories){if(!Array.isArray(e.categories))throw new TypeError("Config.categories must be an array of Category objects.");e.categories.forEach((e,t)=>this.validateCategory(e,t))}if(void 0!==e.onSave&&"function"!=typeof e.onSave)throw new TypeError("Config.onSave must be a function.");if(void 0!==e.animationDuration&&("number"!=typeof e.animationDuration||e.animationDuration<0))throw new TypeError("Config.animationDuration must be a positive number.");if(void 0!==e.renderBar&&null!==e.renderBar&&"function"!=typeof e.renderBar)throw new TypeError("Config.renderBar must be a function or null.");if(void 0!==e.renderModal&&null!==e.renderModal&&"function"!=typeof e.renderModal)throw new TypeError("Config.renderModal must be a function or null.")}validateCategory(e,t){if(!e||"object"!=typeof e)throw new TypeError(`Category at index ${t} must be an object.`);if("string"!=typeof e.label)throw new TypeError(`Category.label at index ${t} must be a string.`);if("boolean"!=typeof e.required)throw new TypeError(`Category.required at index ${t} must be a boolean.`);if("boolean"!=typeof e.default)throw new TypeError(`Category.default at index ${t} must be a boolean.`)}loadPreferences(){const e=localStorage.getItem(this.#vt.storageKey);return e?JSON.parse(e):null}removeWithAnimation(e){if(!(e instanceof HTMLElement))throw new TypeError("removeWithAnimation expects an HTMLElement.");e.classList.add("closing"),setTimeout(()=>e.remove(),this.#vt.animationDuration)}savePreferences(e){if(!e||"object"!=typeof e)throw new TypeError("Preferences must be an object.");localStorage.setItem(this.#vt.storageKey,JSON.stringify(e)),this.#vt.onSave(e)}showConsentBar(){const e=document.createElement("div");e.className="cookie-consent-bar",e.innerHTML=this.#vt.renderBar?this.#vt.renderBar(this.#vt):`\n <div><p>${this.#vt.message}</p></div>\n <div><button class="accept">${this.#vt.acceptText}</button></div>\n <div><button class="reject">${this.#vt.rejectText}</button></div>\n <div><button class="settings">${this.#vt.settingsText}</button></div>\n `,document.body.appendChild(e);const t=e.querySelector(".accept");t instanceof HTMLElement&&(t.onclick=()=>{const t={};this.#vt.categories.forEach(e=>t[e.label]=!0),this.savePreferences(t),this.removeWithAnimation(e)});const r=e.querySelector(".reject");r instanceof HTMLElement&&(r.onclick=()=>{const t={};this.#vt.categories.forEach(e=>t[e.label]=e.required),this.savePreferences(t),this.removeWithAnimation(e)});const i=e.querySelector(".settings");i instanceof HTMLElement&&(i.onclick=()=>this.showSettingsModal(e))}showSettingsModal(e){const t=document.createElement("div");t.className="cookie-consent-modal",t.innerHTML=this.#vt.renderModal?this.#vt.renderModal(this.#vt):`\n <div class="modal-content">\n <h2>Cookie Settings</h2>\n <form class="settings-form">\n ${this.#vt.categories.map(e=>`\n <label>\n <input type="checkbox" name="${e.label}" \n ${e.default?"checked":""} \n ${e.required?"disabled":""}>\n ${e.label}\n </label>\n `).join("")}\n </form>\n <button class="save">Save Preferences</button>\n </div>\n `,document.body.appendChild(t);const r=t.querySelector(".save");r instanceof HTMLElement&&(r.onclick=()=>{const r={};t.querySelectorAll("input[type=checkbox]").forEach(e=>{e instanceof HTMLInputElement&&(r[e.name]=e.checked)}),this.savePreferences(r),this.removeWithAnimation(t),e&&this.removeWithAnimation(e)})}isAllowed(e){if("string"!=typeof e)throw new TypeError("isAllowed expects a string as category.");return!!this.#$n&&!!this.#$n[e]}};var Ur=r(911),Gr=r(766);const Yr=ee("TinyI18"),Xr=class{static async mergeLocaleFiles({files:e,output:t,spaces:r=0}){if("number"!=typeof r||Number.isNaN(r)||r<0)throw new TypeError('mergeLocaleFiles: "spaces" must be a non-negative number');if(!Array.isArray(e)||0===e.length)throw new TypeError('mergeLocaleFiles: "files" must be a non-empty array of file paths');if("string"!=typeof t||!t)throw new TypeError('mergeLocaleFiles: "output" must be a non-empty string path');const i={};for(const t of e){if("string"!=typeof t||!t)throw new TypeError("mergeLocaleFiles: each file path must be a non-empty string");if(!(0,Gr.existsSync)(t))throw new Error(`mergeLocaleFiles: file "${t}" does not exist`);const e=await(0,Ur.readFile)(t,"utf-8");let r;try{r=JSON.parse(e)}catch(e){throw new Error(`mergeLocaleFiles: file "${t}" is not valid JSON`)}Object.assign(i,r)}await(0,Ur.writeFile)(t,JSON.stringify(i,null,r),"utf-8")}#h=!1;get destroyed(){return this.#h}#On;#Hn;#Fn=null;#Bn;#zn=null;#Wn=new Map;#Vn=new Map;#qn=new Map;#Kn=new Map;get currentLocale(){return Yr(this.#h),this.#Fn}get defaultLocale(){return Yr(this.#h),this.#Hn}get mode(){return Yr(this.#h),this.#On}get strict(){return Yr(this.#h),this.#Bn}get basePath(){return Yr(this.#h),this.#zn}get stats(){Yr(this.#h);const e=[];for(const t of this.#Wn.keys())e.push(this.getStatsForLocale(t));return e}get stringTables(){Yr(this.#h);const e={};for(const[t,r]of this.#Wn.entries())e[t]=this.#Jn(r);return e}get patternTables(){Yr(this.#h);const e={};for(const[t,r]of this.#Vn.entries())e[t]=r.map(e=>({$pattern:new RegExp(e.$pattern.source,e.$pattern.flags),value:this.#Jn(e.value),elseValue:this.#Jn(e.elseValue)}));return e}get helpers(){Yr(this.#h);const e={};for(const[t,r]of this.#qn.entries())e[t]=r;return e}get regexCache(){Yr(this.#h);const e={};for(const[t,r]of this.#Kn.entries())e[t]=new RegExp(r.source,r.flags);return e}#Jn(e){if(null==e||"string"==typeof e||"function"==typeof e||"number"==typeof e)return e;if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e))return e.map(e=>this.#Jn(e));if("object"==typeof e){const t={};for(const[r,i]of Object.entries(e))t[r]=this.#Jn(i);return t}return e}#Un(e){if(void 0!==e&&"string"!=typeof e)throw new TypeError('#resolveOrder: "forceLocale" must be a string if provided');const t=[];return e&&"string"==typeof e&&this.#Wn.has(e)?t.push(e):this.#Fn&&t.push(this.#Fn),t.push(this.#Hn),t}#Gn(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError('#resolveExact: "order" must be an array of strings');if("string"!=typeof t||!t)throw new TypeError('#resolveExact: "key" must be a non-empty string');for(const r of e){const e=this.#Wn.get(r);if(e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}}#Yn(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError('#resolveByPattern: "order" must be an array of strings');if("string"!=typeof t||!t)throw new TypeError('#resolveByPattern: "key" must be a non-empty string');for(const r of e){const e=this.#Vn.get(r)||[];for(const r of e)return r.$pattern.test(t)?r.value:r.elseValue??void 0}}#Xn(e,t){if(null==e){if(this.#Bn)throw new TypeError('#materialize: "value" cannot be null or undefined');return""}if("string"==typeof e)return this.#Qn(e,t);if("function"==typeof e)return e(t??{},this.#Zn());if(e&&"object"==typeof e&&"string"==typeof e.$fn){const r=this.#qn.get(e.$fn);if("function"!=typeof r){if(this.#Bn)throw new Error(`TinyI18: helper "${e.$fn}" is not registered`);return""}return r({...t??{},args:void 0!==e.args?e.args:void 0},this.#Zn())}if(this.#Bn)throw new Error("TinyI18: unsupported entry type");return""}#Qn(e,t){if("string"!=typeof e)throw new TypeError('#interpolate: "template" must be a string');if(void 0!==t&&(null===t||"object"!=typeof t))throw new TypeError('#interpolate: "params" must be an object if provided');return t&&"object"==typeof t?e.replace(/\{([a-zA-Z0-9_.$-]+)\}/g,(e,r)=>{const i=this.#es(t,r);return null==i?"":String(i)}):e}#es(e,t){if(!e||"object"!=typeof e)throw new TypeError('#dotGet: "obj" must be an object');if("string"!=typeof t||!t)throw new TypeError('#dotGet: "path" must be a non-empty string');const r=t.split(".");let i=e;for(const e of r){if(null==i)return;i=i[e]}return i}#Zn(){return{has:e=>this.#qn.has(e),call:(e,t,r)=>{const i=this.#qn.get(e);if("function"!=typeof i)throw new Error(`Helper "${e}" not found`);return i(t,r??{})}}}#ts(e,t){if("string"!=typeof e||!e)throw new TypeError('#ingestLocale: "locale" must be a non-empty string');if(!t||"object"!=typeof t)throw new TypeError('#ingestLocale: "raw" must be an object');if("string"!=typeof e||!e)throw new TypeError("#ingestLocale: invalid locale");if(!t||"object"!=typeof t)throw new TypeError('#ingestLocale: "raw" must be an object');const r={...this.#Wn.get(e)??{}},i=[...this.#Vn.get(e)??[]],n=(e,t)=>{if(null!=t)if("string"==typeof t||"function"==typeof t||t&&"object"==typeof t&&"string"==typeof t.$fn){if(!e)throw new TypeError("Leaf value requires a key path");r[e]=t}else if(t&&"object"==typeof t){if(t.$pattern instanceof RegExp&&Object.prototype.hasOwnProperty.call(t,"value"))return void i.push({$pattern:t.$pattern,value:t.value,elseValue:t.elseValue});for(const[r,i]of Object.entries(t))n(e?`${e}.${r}`:r,i)}};n("",t),this.#Wn.set(e,r),this.#Vn.set(e,i),this.#Wn.has(this.#Hn)||(this.#Wn.set(this.#Hn,{}),this.#Vn.set(this.#Hn,[]))}#rs(e){if("string"!=typeof e||!e)throw new TypeError('#unloadLocale: "locale" must be a non-empty string');e!==this.#Hn&&(this.#Wn.delete(e),this.#Vn.delete(e))}async#is(e){if("string"!=typeof e||!e)throw new TypeError('#loadLocaleFromFile: "locale" must be a non-empty string');if("string"!=typeof this.#zn||!this.#zn)throw new TypeError('#loadLocaleFromFile: "this.#basePath" must be a non-empty string');const t=(0,be.join)(this.#zn,`${e}.json`);let r;try{const e=await(0,Ur.readFile)(t,"utf8");r=JSON.parse(e)}catch(r){if(!(r instanceof Error))return;if(this.#Bn)throw new Error(`TinyI18: failed to load or parse ${t}: ${r.message}`);return this.#Wn.set(e,{}),void this.#Vn.set(e,[])}const i={...this.#Wn.get(e)??{}},n=[...this.#Vn.get(e)??[]],s=(e,t)=>{if(null!=t){if(t&&"object"==typeof t&&"string"==typeof t.$pattern&&Object.prototype.hasOwnProperty.call(t,"value")){const e=this.#ns(t.$pattern);return void n.push({$pattern:e,value:this.#ss(t.value),elseValue:this.#ss(t.elseValue)})}if("string"==typeof t||t&&"object"==typeof t&&"string"==typeof t.$fn){if(!e)throw new TypeError("Leaf value requires a key path");i[e]=this.#ss(t)}else if(t&&"object"==typeof t)for(const[r,i]of Object.entries(t))s(e?`${e}.${r}`:r,i)}};s("",r),this.#Wn.set(e,i),this.#Vn.set(e,n)}#ns(e){if("string"!=typeof e||!e)throw new TypeError('#safeRegExp: "src" must be a non-empty string');const t=this.#Kn.get(e);if(t)return t;try{const t=new RegExp(e);return this.#Kn.set(e,t),t}catch{if(this.#Bn)throw new Error(`TinyI18: invalid regex "${e}" in file`);return/^$/}}#ss(e){if("string"==typeof e)return e;if(e&&"object"==typeof e&&"string"==typeof e.$fn)return{$fn:String(e.$fn),args:e.args};if(this.#Bn)throw new Error("TinyI18: unsupported value in file JSON");return""}constructor(e){if(!e||"object"!=typeof e)throw new TypeError("TinyI18: options must be an object");const{mode:t,defaultLocale:r,basePath:i,localResources:n,strict:s=!0}=e;if("local"!==t&&"file"!==t)throw new TypeError('TinyI18: "mode" must be "local" or "file"');if("string"!=typeof r||!r)throw new TypeError('TinyI18: "defaultLocale" must be a non-empty string');if("boolean"!=typeof s)throw new TypeError('TinyI18: "strict" must be a boolean');if("file"===t){if("string"!=typeof i||!i)throw new TypeError('TinyI18: "basePath" is required in file mode');this.#zn=i}if(this.#On=t,this.#Hn=r,this.#Bn=s,"local"===t&&n&&"object"==typeof n)for(const[e,t]of Object.entries(n))this.#ts(e,t);this.#Wn.has(this.#Hn)||(this.#Wn.set(this.#Hn,{}),this.#Vn.set(this.#Hn,[]))}clearRegexCache(){Yr(this.#h),this.#Kn.clear()}registerHelper(e,t){if(Yr(this.#h),"string"!=typeof e||!e)throw new TypeError('registerHelper: "name" must be non-empty string');if("function"!=typeof t)throw new TypeError('registerHelper: "fn" must be a function');this.#qn.set(e,t)}unregisterHelper(e){if(Yr(this.#h),"string"!=typeof e||!e)throw new TypeError('unregisterHelper: "name" must be non-empty string');return this.#qn.delete(e)}loadLocaleLocal(e,t){if(Yr(this.#h),"local"!==this.#On)throw new TypeError('loadLocaleLocal is only available in "local" mode');this.#ts(e,t)}async setLocale(e){if(Yr(this.#h),null!==e&&("string"!=typeof e||!e))throw new TypeError('setLocale: "locale" must be string or null');const t=this.#Fn;null!==e&&("file"===this.#On?await this.#is(e):this.#Wn.has(e)||(this.#Wn.set(e,{}),this.#Vn.set(e,[]))),"file"===this.#On&&t&&t!==this.#Hn&&t!==e&&this.#rs(t),this.#Fn=e}t(e,t=void 0,r=void 0){return this.get(e,t,r)}get(e,t=void 0,r=void 0){if(Yr(this.#h),"string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:i}=r||{},n=this.#Un(i);let s=this.#Gn(n,e);if(void 0===s){if(this.#Bn)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return this.#Xn(s,t)}p(e,t){return this.resolveByPattern(e,t)}resolveByPattern(e,t){if(Yr(this.#h),"string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:r}=t||{},i=this.#Un(r);let n=this.#Yn(i,e);if(void 0===n){if(this.#Bn)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return n}resetToDefaultOnly(){if(Yr(this.#h),"file"===this.#On)for(const e of Array.from(this.#Wn.keys()))e!==this.#Hn&&this.#rs(e);this.#Fn=null}getStatsForLocale(e){if(Yr(this.#h),"string"!=typeof e||!e)throw new TypeError('getStatsForLocale: "locale" must be a non-empty string');if(!this.#Wn.has(e))throw new Error(`getStatsForLocale: locale "${e}" is not registered`);return{locale:e,strings:Object.keys(this.#Wn.get(e)??{}).length,patterns:this.#Vn.get(e)?.length??0,isDefault:e===this.#Hn,isCurrent:e===this.#Fn}}destroy(){this.#h||(this.#Wn.clear(),this.#Vn.clear(),this.#qn.clear(),this.#Kn.clear(),this.#Fn=null,this.#zn=null,this.#h=!0)}};class Qr{#os=new Map;#as;#ls;#us;get factors(){const e={};for(let[t,r]of this.#os.entries())e[t]={...r};return e}get currentPercent(){return this.#ls/this.#as*100}set maxValue(e){if("number"!=typeof e||Number.isNaN(e)||e<=0)throw new TypeError("maxValue must be a positive number.");this.#as=e,this.#ls=Math.min(this.#ls,e)}get maxValue(){return this.#as}get currentValue(){return this.#ls}set infiniteValue(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("infiniteValue must be a number.");this.#us=e,this.#ls=Math.max(0,e),this.#ls=Math.min(this.#ls,this.#as)}get infiniteValue(){return this.#us}constructor(e=100,t=1,r=1){if("number"!=typeof e||Number.isNaN(e)||e<=0)throw new TypeError("maxValue must be a positive number.");this.#as=e,this.setFactor("main",t,r),this.#ls=e,this.#us=e}getFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");const t=this.#os.get(e);if(!t)throw new Error(`Factor with key "${e}" not found.`);return{...t}}hasFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");return this.#os.has(e)}setFactor(e,t,r=1){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");if("number"!=typeof t||Number.isNaN(t))throw new TypeError("Amount must be a valid number.");if("number"!=typeof r||Number.isNaN(r))throw new TypeError("Multiplier must be a valid number.");this.#os.set(e,{amount:t,multiplier:r})}removeFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");return this.#os.delete(e)}#hs(e){const t=this.#us;return this.#us-=e,this.#ls=Math.max(0,this.#ls-e),{prevValue:t,removedTotal:e,removedPercent:e/this.#as*100,currentPercent:this.currentPercent,remainingValue:this.#ls,infiniteRemaining:this.#us}}tick(){let e=0;for(let[t,r]of this.#os.entries())e+=r.amount*r.multiplier;return this.#hs(e)}tickWithTempFactor(e){if("object"!=typeof e||null===e)throw new TypeError("You must provide a valid factor object.");if("number"!=typeof e.amount||Number.isNaN(e.amount))throw new TypeError('Temp factor "amount" must be a valid number.');if("multiplier"in e&&("number"!=typeof e.multiplier||Number.isNaN(e.multiplier)))throw new TypeError('Temp factor "multiplier" must be a valid number if provided.');let t=0;for(let[e,r]of this.#os.entries())t+=r.amount*r.multiplier;return e&&(t+=e.amount*(e.multiplier??1)),this.#hs(t)}tickSingleFactor(e){if("object"!=typeof e||null===e)throw new TypeError("You must provide a valid factor object.");if("number"!=typeof e.amount||Number.isNaN(e.amount))throw new TypeError('Temp factor "amount" must be a valid number.');if("multiplier"in e&&("number"!=typeof e.multiplier||Number.isNaN(e.multiplier)))throw new TypeError('Temp factor "multiplier" must be a valid number if provided.');if(!e)throw new Error("You must provide a factor to apply.");const t=e.amount*(e.multiplier??1);return this.#hs(t)}toJSON(){return{maxValue:this.#as,currentValue:this.#ls,infiniteValue:this.#us,factors:this.factors}}static fromJSON(e){const t=new Qr(e.maxValue,0,0);t.infiniteValue=e.infiniteValue,t.#os.clear();for(const[r,i]of Object.entries(e.factors))t.setFactor(r,i.amount,i.multiplier);return t}clone(){return Qr.fromJSON(this.toJSON())}clearFactors(){this.#os.clear()}}const Zr=Qr;class ei{static _safeEvaluate(e){if(!/^[\d+\-*/%.()\s^]+$/.test(e))throw new Error(`Invalid characters in expression: "${e}"`);const t=e.replace(/\^/g,"**");try{return Function(`"use strict"; return (${t})`)()}catch(t){if(!(t instanceof Error))throw new Error("Unknown Error");throw new Error(`Invalid expression "${e}": ${t.message}`)}}static replaceValues(e,t){let r=0;return e.replace(/(\d*)d(\d+)/g,(e,i)=>{const n=i?Number(i):1;let s=0;for(let e=0;e<n;e++){const e=t[r++];s+=void 0!==e?e:0}return String(s)})}static tokenizeValues(e,t){const r=ei.replaceValues(e,t),i=[],n=/\d+|[()+\-*/]/g;let s;for(;null!==(s=n.exec(r));)/^\d+$/.test(s[0])?i.push(Number(s[0])):i.push(s[0]);return{tokens:i,text:r}}static parseString(e){if("string"!=typeof e)throw new TypeError("Input must be a string.");const t=e.split(",").map(e=>e.trim()).filter(Boolean),r=[],i=[];if(t.forEach((e,t)=>{const n=/\b(?:(\d+)?d(\d+))\b/g;let s;const o=[],a=e.replace(/\(([^()]+?\|[^()]+?)\)/g,(e,t)=>{const r="string"==typeof t?t.split("|").map(e=>e.trim()).filter(Boolean):[];if(0===r.length)throw new Error(`Invalid random-choice group: "${e}"`);return r[Math.floor(Math.random()*r.length)]});for(;null!==(s=n.exec(a));){const e=parseInt(s[1]||"1",10),r=parseInt(s[2],10);if(isNaN(r))throw new Error(`Invalid dice sides in expression "${s[0]}" at position ${t+1}.`);o.push({count:e,sides:r})}if(0===o.length&&Number.isNaN(parseFloat(a)))throw new Error(`Invalid dice expression at position ${t+1}: "${e}"`);r.push(...o),i.push({index:t,original:e,expression:a})}),0===r.length)throw new Error("Invalid dice amount.");return{sides:r,modifiers:i}}static applyModifiers(e,t){if(!Array.isArray(e)||!e.every(e=>"number"==typeof e&&!Number.isNaN(e)||g(e)&&"number"==typeof e.value&&!Number.isNaN(e.value)&&"number"==typeof e.sides&&!Number.isNaN(e.sides)))throw new TypeError("Bases must be a valid numbers.");if(!Array.isArray(t))throw new TypeError("Modifiers must be an array of modifier objects.");let r=0;const i=[],n=[...e];for(const e in t){const s=t[e];if("string"!=typeof s.expression)throw new Error("Each modifier must include an expression string.");const o=s.original,a=s.expression,l=[],u=[],h=[],d=e=>e.match(/\(\s*[^()]+\|\s*[^()]+\s*\)|\b\d*d\d+\b|[-+]?\d+(?:\.\d+)?|[+\-*/%^()]/g)||[],c=d(a),m=d(o),p=[...c],f=[],y=a.replace(/\b\d*d\d+\b/g,e=>{const t=e.split("d"),r=()=>{for(const t in c)if(c[t]===e&&f.indexOf(t)<0){f.push(t),h.push(Number(t));break}},i=e=>{if(e.value>e.sides)throw new Error(`Invalid dice roll: value (${e.value}) must be between 1 and ${e.sides}.`)};if(0===t[0].trim().length){const t=n.shift(),s="number"==typeof t?t:g(t)?t.value:0;g(t)&&i(t),l.push([s]);for(const t in p)if(p[t]===e){p[t]=String(s),u.push(Number(t));break}return r(),s}const s=[],o=Number(t[0]),a=["("];let d="(";for(let e=0;e<o;e++){const t=n.shift(),r="number"==typeof t?t:g(t)?t.value:0;g(t)&&i(t),a.push(String(r));const l=e<o-1?" + ":")";a.push(l),d+=`${r}${l}`,s.push(r)}for(const t in p){const r=Number(t);if(p[r]===e){p.splice(r,1,...a);let e=1;for(let t=0;t<o;t++)u.push(r+t+e),e++;break}}return l.push(s),r(),d});let w;try{w=ei._safeEvaluate(y)}catch(e){if(!(e instanceof Error))throw new Error("Unknown Error");throw new Error(`Error evaluating expression "${y}" (from "${a}"): ${e.message}`)}i.push({rawTokensP:c,rawTokens:m,tokens:p,rawDiceTokenSlots:h,diceTokenSlots:u,dicesResult:l,total:w}),r+=w}return{final:r,steps:i}}static rollArrayIndex(e){const t=Array.isArray(e),r=e instanceof Set;if(!t&&!r)throw new TypeError("rollArrayIndex expects an array or Set.");return Math.floor(Math.random()*(t?e.length:e.size))}#as;#ds;get maxValue(){return this.#as}set maxValue(e){if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#as=e}get allowZero(){return this.#ds}set allowZero(e){if("boolean"!=typeof e)throw new TypeError("allowZero must be a boolean.");this.#ds=e}constructor({maxValue:e,allowZero:t=!0}){if("boolean"!=typeof t)throw new TypeError("allowZero must be an boolean.");if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#as=e,this.#ds=t}roll(){const e=this.#ds?0:1;return Math.floor(Math.random()*(this.#as-e+1))+e}}const ti=ei,ri=class{#S=null;get overlay(){return this.#S}#cs=null;get messageElement(){return this.#cs}#P;get container(){return this.#P}#ms={fadeIn:null,fadeOut:null,zIndex:9999};get options(){return{...this.#ms}}set options(e){if("object"!=typeof e||null===e)throw new TypeError("options must be an object");if(void 0!==e.fadeIn&&null!==e.fadeIn&&("number"!=typeof e.fadeIn||e.fadeIn<0))throw new TypeError("fadeIn must be a non-negative number or null");if(void 0!==e.fadeOut&&null!==e.fadeOut&&("number"!=typeof e.fadeOut||e.fadeOut<0))throw new TypeError("fadeOut must be a non-negative number or null");if(void 0!==e.zIndex&&("number"!=typeof e.zIndex||!Number.isInteger(e.zIndex)))throw new TypeError("zIndex must be an integer number");this.#ms={fadeIn:e.fadeIn??null,fadeOut:e.fadeOut??null,zIndex:e.zIndex??9999}}#ps="none";get status(){return this.#ps}#fs="";get defaultMessage(){return this.#fs}set defaultMessage(e){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("defaultMessage must be a string or an HTMLElement");this.#fs=e}#ys=null;get message(){return this.#ys}#gs=!1;get allowHtmlText(){return this.#gs}set allowHtmlText(e){if("boolean"!=typeof e)throw new TypeError("allowHtmlText must be a boolean");this.#gs=e}#ws=null;get fadeInTimeout(){return null!==this.#ws}#bs=null;get fadeOutTimeout(){return null!==this.#bs}get visible(){return!!this.#S}#vs=null;get onChange(){return this.#vs}set onChange(e){if(null!==e&&"function"!=typeof e)throw new TypeError("onChange must be a function or null");this.#vs=e}_emitChange(){"function"==typeof this.#vs&&this.#vs(this.#ps)}constructor(e=document.body){if(!(e instanceof HTMLElement))throw new TypeError("container must be an HTMLElement");this.#P=e}_updateMessage(e=this.#fs){if(!this.#cs)throw new Error("messageElement is not initialized");if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");if(this.#ys=e,"string"==typeof e)this.#gs?this.#cs.innerHTML=e:this.#cs.textContent=e;else{if(!this.#gs)throw new Error("HTMLElement messages require allowHtmlText = true");this.#cs.textContent="",this.#cs.appendChild(e)}}_removeOldClasses(){this.#S?.classList.remove("active"),this.#S?.classList.remove("fadeIn"),this.#S?.classList.remove("fadeOut")}start(e=this.#fs){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");if(!this.#S){this.#S=document.createElement("div"),this.#S.classList.add("loading-overlay"),this.#S.style.zIndex=String(this.#ms.zIndex);const t=document.createElement("div");t.classList.add("loading-container");const r=document.createElement("div");r.classList.add("loading-content");const i=document.createElement("div");i.classList.add("loading-spinner"),this.#cs=document.createElement("div"),this.#cs.classList.add("loading-message"),r.appendChild(i),r.appendChild(this.#cs),t.appendChild(r),this.#S.appendChild(t),this.#P.appendChild(this.#S),this._removeOldClasses(),this.#ps="fadeIn",this.#S.classList.add("fadeIn"),this._emitChange();const n=()=>{this._removeOldClasses(),this.#ws=null,this.#ps="active",this.#S?.classList.add("active"),this._emitChange()};return"number"==typeof this.#ms.fadeIn?(this.#ws&&clearTimeout(this.#ws),this.#ws=setTimeout(n,this.#ms.fadeIn)):n(),this._updateMessage(e),!0}return this.#cs&&this._updateMessage(e),!1}update(e=this.#fs){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");return!!this.#cs&&(this._updateMessage(e),!0)}stop(){if(this.#S){this._removeOldClasses(),this.#ps="fadeOut",this.#S.classList.add("fadeOut"),this._emitChange();const e=()=>{this._removeOldClasses(),this.#bs=null,this.#ps="none",this.#S?.remove(),this.#S=null,this.#cs=null,this.#ys=null,this._emitChange()};return"number"==typeof this.#ms.fadeOut?(this.#bs&&clearTimeout(this.#bs),this.#bs=setTimeout(e,this.#ms.fadeOut)):e(),!0}return!1}};class ii{static#Es=/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;static#Ts=/^#([A-Fa-f0-9]{8})$/;static#Ss="(0|1|0?\\.\\d+)";static#xs="(0|[1-9]\\d?|1\\d{2}|2[0-4]\\d|25[0-5])";static#As="(0|[1-9]\\d?|[1-2]\\d{2}|3[0-5]\\d|360)";static#Cs="(0|[1-9]?\\d|100)";static#Is=new RegExp(`^rgb\\(\\s*${ii.#xs}\\s*,\\s*${ii.#xs}\\s*,\\s*${ii.#xs}\\s*\\)$`);static#Ms=new RegExp(`^rgba\\(\\s*${ii.#xs}\\s*,\\s*${ii.#xs}\\s*,\\s*${ii.#xs}\\s*,\\s*${ii.#Ss}\\s*\\)$`);static#Ds=new RegExp(`^hsl\\(\\s*${ii.#As}\\s*,\\s*${ii.#Cs}%\\s*,\\s*${ii.#Cs}%\\s*\\)$`);static#ks=new RegExp(`^hsla\\(\\s*${ii.#As}\\s*,\\s*${ii.#Cs}%\\s*,\\s*${ii.#Cs}%\\s*,\\s*${ii.#Ss}\\s*\\)$`);static#Ns=new RegExp(`^hwb\\(\\s*${ii.#As}(deg|grad|rad|turn)?\\s*${ii.#Cs}%\\s*${ii.#Cs}%\\s*\\)$`);static#Ls="(-?\\d+)";static#_s=new RegExp(`^lab\\(\\s*${ii.#Cs}%?\\s*${ii.#Ls}%?\\s*${ii.#Ls}%?\\s*\\)$`);static#js=new RegExp(`^lch\\(\\s*${ii.#Cs}%?\\s*${ii.#Cs}%?\\s*${ii.#As}(deg|grad|rad|turn)?\\s*\\)$`);static#Rs=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);static#Ps=new Set(["transparent","currentColor"]);static getNames(){return Array.from(ii.#Rs)}static addName(e){const t=ii.#Rs.size;return ii.#Rs.add(e.toLowerCase()),ii.#Rs.size>t}static removeName(e){return ii.#Rs.delete(e.toLowerCase())}static hasName(e){return ii.#Rs.has(e.toLowerCase())}static getSpecialNames(){return Array.from(ii.#Ps)}static addSpecialName(e){const t=ii.#Ps.size;return ii.#Ps.add(e),ii.#Ps.size>t}static removeSpecialName(e){return ii.#Ps.delete(e)}static hasSpecialName(e){return ii.#Ps.has(e)}#$s;get code(){return this.#$s}#Os;get type(){return this.#Os}constructor(e){this.#$s=e,this.#Os=ii.isColor(this.#$s)}static isHex(e){if("string"!=typeof e)throw new TypeError("isHex: input must be a string.");return ii.#Es.test(e.trim())}isHex(){return ii.isHex(this.#$s)}static isHexa(e){if("string"!=typeof e)throw new TypeError("isHexa: input must be a string.");return ii.#Ts.test(e.trim())}isHexa(){return ii.isHexa(this.#$s)}static isRgb(e){if("string"!=typeof e)throw new TypeError("isRgb: input must be a string.");return ii.#Is.test(e.trim())}isRgb(){return ii.isRgb(this.#$s)}static isRgba(e){if("string"!=typeof e)throw new TypeError("isRgba: input must be a string.");return ii.#Ms.test(e.trim())}isRgba(){return ii.isRgba(this.#$s)}static isHsl(e){if("string"!=typeof e)throw new TypeError("isHsl: input must be a string.");return ii.#Ds.test(e.trim())}isHsl(){return ii.isHsl(this.#$s)}static isHsla(e){if("string"!=typeof e)throw new TypeError("isHsla: input must be a string.");return ii.#ks.test(e.trim())}isHsla(){return ii.isHsla(this.#$s)}static isHwb(e){if("string"!=typeof e)throw new TypeError("isHwb: input must be a string.");return ii.#Ns.test(e.trim())}isHwb(){return ii.isHwb(this.#$s)}static isLab(e){if("string"!=typeof e)throw new TypeError("isLab: input must be a string.");return ii.#_s.test(e.trim())}isLab(){return ii.isLab(this.#$s)}static isLch(e){if("string"!=typeof e)throw new TypeError("isLch: input must be a string.");return ii.#js.test(e.trim())}isLch(){return ii.isLch(this.#$s)}static isName(e){if("string"!=typeof e)throw new TypeError("isName: input must be a string.");return ii.#Rs.has(e.trim().toLowerCase())}isName(){return ii.isName(this.#$s)}static isSpecialName(e){if("string"!=typeof e)throw new TypeError("isSpecialName: input must be a string.");return ii.#Ps.has(e.trim())}isSpecialName(){return ii.isSpecialName(this.#$s)}static isColor(e){if("string"!=typeof e)throw new TypeError("isColor: input must be a string.");return ii.isHex(e)?"hex":ii.isHexa(e)?"hexa":ii.isRgb(e)?"rgb":ii.isRgba(e)?"rgba":ii.isHsl(e)?"hsl":ii.isHsla(e)?"hsla":ii.isHwb(e)?"hwb":ii.isLab(e)?"lab":ii.isLch(e)?"lch":ii.isName(e)?"name":ii.isSpecialName(e)?"specialName":null}parse(){switch(this.#Os){case"hex":return ii.parseHex(this.code);case"hexa":return ii.parseHexa(this.code);case"rgb":return ii.parseRgb(this.code);case"rgba":return ii.parseRgba(this.code);case"hsl":return ii.parseHsl(this.code);case"hsla":return ii.parseHsla(this.code);case"hwb":return ii.parseHwb(this.code);case"lab":return ii.parseLab(this.code);case"lch":return ii.parseLch(this.code);case"name":case"specialName":return this.#$s.trim().toLowerCase();default:return null}}static parseHex(e){if("string"!=typeof e)throw new TypeError("parseHex: input must be a string.");const t=new RegExp(ii.#Es,"gm").exec(e.trim());return t?t[1]:null}parseHex(){return ii.parseHex(this.#$s)}static parseHexa(e){if("string"!=typeof e)throw new TypeError("parseHexa: input must be a string.");const t=new RegExp(ii.#Ts,"gm").exec(e.trim());return t?t[1]:null}parseHexa(){return ii.parseHexa(this.#$s)}static parseRgb(e){if("string"!=typeof e)throw new TypeError("parseRgb: input must be a string.");const t=new RegExp(ii.#Is,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseRgb(){return ii.parseRgb(this.#$s)}static parseRgba(e){if("string"!=typeof e)throw new TypeError("parseRgba: input must be a string.");const t=new RegExp(ii.#Ms,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]:null}parseRgba(){return ii.parseRgba(this.#$s)}static parseHsl(e){if("string"!=typeof e)throw new TypeError("parseHsl: input must be a string.");const t=new RegExp(ii.#Ds,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseHsl(){return ii.parseHsl(this.#$s)}static parseHsla(e){if("string"!=typeof e)throw new TypeError("parseHsla: input must be a string.");const t=new RegExp(ii.#ks,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]:null}parseHsla(){return ii.parseHsla(this.#$s)}static parseHwb(e){if("string"!=typeof e)throw new TypeError("parseHwb: input must be a string.");const t=new RegExp(ii.#Ns,"gm").exec(e.trim());return t?[parseFloat(t[1]),t[2]??null,parseFloat(t[3]),parseFloat(t[4])]:null}parseHwb(){return ii.parseHwb(this.#$s)}static parseLab(e){if("string"!=typeof e)throw new TypeError("parseLab: input must be a string.");const t=new RegExp(ii.#_s,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseLab(){return ii.parseLab(this.#$s)}static parseLch(e){if("string"!=typeof e)throw new TypeError("parseLch: input must be a string.");const t=new RegExp(ii.#js,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),t[4]??null]:null}parseLch(){return ii.parseLch(this.#$s)}}const ni=ii,si=ee("TinyAnalogClock"),oi=class{#Hs;#Fs;#Bs;#vt;#oi=null;#h=!1;get destroyed(){return this.#h}_getDate(){const e=new Date,t=e.getSeconds(),r=e.getMinutes(),i=e.getHours();return{now:e,s:t,m:r,h:i}}constructor(e={}){this.#vt={bgColor:"#f0f0f0",borderColor:"#333",borderWidth:8,markColor:"#333",hourHandColor:"#000",minuteHandColor:"#444",secondHandColor:"#d81c1c",textColor:"#000",skinUrl:null,showNumbers:!0,showSeconds:!0,size:800,sizeAdjust:.04,padding:45,angleDistance:.95,pwH:.008,phH:.08,pwM:.005,phM:.03,...e},this.#Hs=document.createElement("div"),this.#Hs.className="analog-clock-container",this.#Hs.style.position="relative",this.#Hs.style.borderRadius="50%",this.#Hs.style.overflow="hidden",this.#Hs.style.boxSizing="border-box",this.#Bs=document.createElement("div"),this.#Bs.style.position="absolute",this.#Bs.style.inset="0",this.#Bs.style.backgroundSize="cover",this.#Bs.style.backgroundPosition="center",this.#Bs.style.zIndex="0",this.#Fs=document.createElement("div"),this.#Fs.style.position="absolute",this.#Fs.style.inset="0",this.#Fs.style.zIndex="1",this.#Fs.style.pointerEvents="none";const t=document.createElement("div");t.style.position="absolute",t.style.inset="0",t.style.zIndex="2",t.style.pointerEvents="none",t.innerHTML='\n <div class="hand hour-hand"></div>\n <div class="hand minute-hand"></div>\n <div class="hand second-hand"></div>\n <div class="center-pin"></div>\n ',this.#Hs.appendChild(this.#Bs),this.#Hs.appendChild(this.#Fs),this.#Hs.appendChild(t);const r=document.createElement("style");r.textContent="\n .analog-clock-container .hand {\n position: absolute;\n bottom: 50%;\n left: 50%;\n transform-origin: bottom center;\n border-radius: 4px;\n transform: translateX(-50%) rotate(0deg);\n z-index: 5;\n }\n .analog-clock-container .center-pin {\n position: absolute;\n top: 50%; left: 50%;\n width: 12px; height: 12px;\n background: #333;\n border-radius: 50%;\n transform: translate(-50%, -50%);\n z-index: 10;\n }\n .analog-clock-container .clock-mark {\n position: absolute;\n top: 50%; left: 50%;\n background: currentColor;\n transform-origin: center center;\n }\n .analog-clock-container .clock-number {\n position: absolute;\n top: 50%; left: 50%;\n transform: translate(-50%, -50%);\n font-family: sans-serif;\n font-weight: bold;\n text-align: center;\n line-height: 1;\n }\n ",this.#Hs.appendChild(r),this._applyConfig(),this._renderFace(),this._startTicker()}_applyConfig(){const e=this.#Hs.style,t=this.#vt;e.width=`${t.size}px`,e.height=`${t.size}px`,e.border=`${t.borderWidth}px solid ${t.borderColor}`,e.backgroundColor=t.bgColor,t.skinUrl?(this.#Bs.style.backgroundImage=`url(${t.skinUrl})`,this.#Bs.style.display="block"):this.#Bs.style.display="none";const r=e=>{const t=this.#Hs.querySelector(e);if(!(t instanceof HTMLDivElement))throw new Error(`TinyAnalogClock: Element ${e} not found.`);return t},i=r(".hour-hand");i.style.backgroundColor=t.hourHandColor,i.style.width=.025*t.size+"px",i.style.height=.25*t.size+"px",i.style.marginLeft=.025*t.size/-2+"px",i.style.bottom="50%",i.style.left="50%",i.style.transformOrigin="bottom center";const n=r(".minute-hand");n.style.backgroundColor=t.minuteHandColor,n.style.width=.015*t.size+"px",n.style.height=.35*t.size+"px",n.style.marginLeft=.015*t.size/-2+"px";const s=r(".second-hand");t.showSeconds?(s.style.display="block",s.style.backgroundColor=t.secondHandColor,s.style.width=.005*t.size+"px",s.style.height=.4*t.size+"px",s.style.marginLeft=.005*t.size/-2+"px"):s.style.display="none",r(".center-pin").style.background=t.borderColor}_renderFace(){this.#Fs.innerHTML="";const e=this.#vt.size/2-this.#vt.borderWidth;for(let t=0;t<60;t++){const r=t%5==0,i=document.createElement("div");i.className="clock-mark";const n=r?this.#vt.size*this.#vt.pwH:this.#vt.size*this.#vt.pwM,s=r?this.#vt.size*this.#vt.phH:this.#vt.size*this.#vt.phM,o=this.#vt.markColor;i.style.width=`${n}px`,i.style.height=`${s}px`,i.style.color=o;const a=e-this.#vt.padding-s/2;i.style.transform=`translate(-50%, -50%) rotate(${6*t}deg) translate(0, -${a}px)`,this.#Fs.appendChild(i)}if(this.#vt.showNumbers)for(let t=1;t<=12;t++){const r=30*t*(Math.PI/180),i=e*this.#vt.angleDistance,n=e+Math.sin(r)*i,s=e-Math.cos(r)*i,o=document.createElement("div");o.className="clock-number",o.innerText=t.toString(),o.style.left=`${n}px`,o.style.top=`${s}px`,o.style.color=this.#vt.textColor,o.style.fontSize=this.#vt.size*this.#vt.sizeAdjust+"px",this.#Fs.appendChild(o)}}_startTicker(){if(this.#oi)return;const e=()=>{const{s:t,m:r,h:i}=this._getDate(),n=6*t,s=6*r+.1*t,o=i%12*30+.5*r,a=e=>{const t=this.#Hs.querySelector(e);if(!(t instanceof HTMLDivElement))throw new Error(`${e} not found.`);return t};this.#Hs.querySelector(".second-hand")&&(a(".second-hand").style.transform=`rotate(${n}deg)`),a(".minute-hand").style.transform=`rotate(${s}deg)`,a(".hour-hand").style.transform=`rotate(${o}deg)`,this.#oi=requestAnimationFrame(e)};e()}get element(){return si(this.#h),this.#Hs}set size(e){if(si(this.#h),"number"!=typeof e||e<=0||isNaN(e))throw new Error(`TinyAnalogClock: 'size' must be a positive number. Received: ${e}`);this.#vt.size=e,this._applyConfig(),this._renderFace()}get size(){return si(this.#h),this.#vt.size}set skinUrl(e){if(si(this.#h),null!==e&&"string"!=typeof e)throw new Error("TinyAnalogClock: 'skin' must be a URL string or null. Received type: "+typeof e);this.#vt.skinUrl=e,this._applyConfig()}get skinUrl(){return si(this.#h),this.#vt.skinUrl}set borderColor(e){if(si(this.#h),"string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'borderColor' must be a non-empty string. Received: ${e}`);this.#vt.borderColor=e,this._applyConfig(),this._renderFace()}get borderColor(){return si(this.#h),this.#vt.borderColor}set markColor(e){if(si(this.#h),"string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'markColor' must be a non-empty string. Received: ${e}`);this.#vt.markColor=e,this._applyConfig(),this._renderFace()}get markColor(){return si(this.#h),this.#vt.markColor}set textColor(e){if(si(this.#h),"string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'textColor' must be a non-empty string. Received: ${e}`);this.#vt.textColor=e,this._applyConfig(),this._renderFace()}get textColor(){return si(this.#h),this.#vt.textColor}set showNumbers(e){if(si(this.#h),"boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showNumbers' must be a boolean. Received type: "+typeof e);this.#vt.showNumbers=e,this._renderFace()}get showNumbers(){return si(this.#h),this.#vt.showNumbers}set bgColor(e){if(si(this.#h),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'bgColor' must be a non-empty string.");this.#vt.bgColor=e,this._applyConfig()}get bgColor(){return si(this.#h),this.#vt.bgColor}set borderWidth(e){if(si(this.#h),"number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'borderWidth' must be a non-negative number.");this.#vt.borderWidth=e,this._applyConfig(),this._renderFace()}get borderWidth(){return si(this.#h),this.#vt.borderWidth}set hourHandColor(e){if(si(this.#h),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'hourHandColor' must be a non-empty string.");this.#vt.hourHandColor=e,this._applyConfig()}get hourHandColor(){return si(this.#h),this.#vt.hourHandColor}set minuteHandColor(e){if(si(this.#h),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'minuteHandColor' must be a non-empty string.");this.#vt.minuteHandColor=e,this._applyConfig()}get minuteHandColor(){return si(this.#h),this.#vt.minuteHandColor}set secondHandColor(e){if(si(this.#h),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'secondHandColor' must be a non-empty string.");this.#vt.secondHandColor=e,this._applyConfig()}get secondHandColor(){return si(this.#h),this.#vt.secondHandColor}set showSeconds(e){if(si(this.#h),"boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showSeconds' must be a boolean.");this.#vt.showSeconds=e,this._applyConfig()}get showSeconds(){return si(this.#h),this.#vt.showSeconds}set sizeAdjust(e){if(si(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'sizeAdjust' must be a positive number.");this.#vt.sizeAdjust=e,this._renderFace()}get sizeAdjust(){return si(this.#h),this.#vt.sizeAdjust}set padding(e){if(si(this.#h),"number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'padding' must be a non-negative number.");this.#vt.padding=e,this._renderFace()}get padding(){return si(this.#h),this.#vt.padding}set angleDistance(e){if(si(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'angleDistance' must be a positive number.");this.#vt.angleDistance=e,this._renderFace()}get angleDistance(){return si(this.#h),this.#vt.angleDistance}set pwH(e){if(si(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwH' must be a positive number.");this.#vt.pwH=e,this._renderFace()}get pwH(){return si(this.#h),this.#vt.pwH}set phH(e){if(si(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phH' must be a positive number.");this.#vt.phH=e,this._renderFace()}get phH(){return si(this.#h),this.#vt.phH}set pwM(e){if(si(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwM' must be a positive number.");this.#vt.pwM=e,this._renderFace()}get pwM(){return si(this.#h),this.#vt.pwM}set phM(e){if(si(this.#h),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phM' must be a positive number.");this.#vt.phM=e,this._renderFace()}get phM(){return si(this.#h),this.#vt.phM}destroy(){this.#h||(this.#oi&&(cancelAnimationFrame(this.#oi),this.#oi=null),this.#Hs.remove(),this.#h=!0)}},ai=ee("TinyTextDiffer"),li=class{#zs=[];#h=!1;get destroyed(){return this.#h}get history(){return ai(this.#h),[...this.#zs]}set history(e){if(ai(this.#h),!Array.isArray(e))throw new TypeError("History data must be provided as an array.");if(!e.every(e=>"string"==typeof e))throw new TypeError("All items in the history array must be strings.");this.#zs=[...e]}get size(){return ai(this.#h),this.#zs.length}constructor(e=[]){this.history=e}#Ws(e){if("number"!=typeof e)throw new TypeError("The provided index must be a valid number.")}#Vs(e){if("string"!=typeof e)throw new TypeError("The provided text must be a valid string.")}get(e){if(ai(this.#h),this.#Ws(e),void 0===this.#zs[e])throw new Error(`No text version found at index ${e}.`);return this.#zs[e]}has(e){return ai(this.#h),this.#Ws(e),void 0!==this.#zs[e]}add(e){ai(this.#h),this.#Vs(e),this.#zs.push(e)}remove(){return ai(this.#h),this.#zs.pop()}addAt(e,t){ai(this.#h),this.#Ws(e),this.#Vs(t),this.#zs.splice(e,0,t)}removeAt(e){ai(this.#h),this.#Ws(e);const t=this.#zs.length;return this.#zs.splice(e,1),t!==this.#zs.length}clear(){ai(this.#h),this.#zs=[]}compare(...e){ai(this.#h);const t=e.length;if(0===t||t%2!=0)throw new Error("The compare method requires an even number of indices to form comparison pairs.");const r=[];for(let i=0;i<t;i+=2){const n=i+1;if(n>t-1)continue;this.#Ws(e[i]),this.#Ws(e[n]);const s=this.#zs[e[i]],o=this.#zs[e[n]];r.push(this._computeDiff(s,o))}return r}_computeDiff(e,t){const r=e.length,i=t.length,n=Array(r+1).fill(null).map(()=>Array(i+1).fill(0));let s=1,o=1;for(s=1;s<=r;s++)for(o=1;o<=i;o++)e[s-1]===t[o-1]?n[s][o]=n[s-1][o-1]+1:n[s][o]=Math.max(n[s-1][o],n[s][o-1]);s=r,o=i;const a=[];for(;s>0||o>0;)s>0&&o>0&&e[s-1]===t[o-1]?(a.unshift({value:e[s-1],type:"normal"}),s--,o--):o>0&&(0===s||n[s][o-1]>=n[s-1][o])?(a.unshift({value:t[o-1],type:"added"}),o--):s>0&&(0===o||n[s][o-1]<n[s-1][o])&&(a.unshift({value:e[s-1],type:"deleted"}),s--);return a.reduce((e,t)=>{const r=e.length-1;return e.length>0&&e[r].type===t.type?e[r].value+=t.value:e.push(t),e},[])}destroy(){this.#h||(this.#zs=[],this.#h=!0)}};class ui{static generateHash(e){const t="object"==typeof e?JSON.stringify(e):String(e);let r=0;for(let e=0,i=t.length;e<i;e++)r=(r<<5)-r+t.charCodeAt(e),r|=0;return r.toString(36)}#qs=[];get oldArray(){return this.#qs}set oldArray(e){if(!Array.isArray(e))throw new TypeError("The provided oldArray must be a valid Array.");this.#qs=e}constructor(e){void 0!==e&&(this.oldArray=e)}_generateHash(e){return ui.generateHash(e)}compare(e){if(!Array.isArray(e))throw new TypeError("The provided newArray must be a valid Array.");const t={oldItemsMap:new Map,affectedItems:[]};for(const e of this.#qs){const r=this._generateHash(e);t.oldItemsMap.set(r,e)}for(const r of e){const e=this._generateHash(r);t.oldItemsMap.has(e)?t.oldItemsMap.delete(e):t.affectedItems.push({item:r,status:"added"})}for(const e of t.oldItemsMap.values())t.affectedItems.push({item:e,status:"deleted"});return t.affectedItems}}const hi=ui,di=e=>{if(!Array.isArray(e))throw new TypeError("Parameter 'sets' must be an array.");if(!e.every(e=>e instanceof fi))throw new TypeError("All elements in the array must be instances of FuzzySet.")},ci=(e,t,r=.5)=>{pi(e,"object","defuzzifyCentroid.fuzzyOutput");for(const t in e)pi(e[t],"number",`fuzzyOutput['${t}']`);di(t),pi(r,"number","defuzzifyCentroid.step");let i=0,n=0;for(let s=0;s<=100;s+=r){let r=0;t.forEach(t=>{const i=e[t.name]||0,n=Math.min(i,t.calculate(s));r=Math.max(r,n)}),i+=s*r,n+=r}return 0===n?0:i/n},mi=(e,t,r,i,n,s=!1)=>{if(s){if(e<=t||e>=n)return 0;if(e>=r&&e<=i)return 1}const o=t===r?1:(e-t)/(r-t),a=i===n?1:(n-e)/(n-i),l=Math.max(0,Math.min(o,1,a));return isNaN(l)?0:l},pi=(e,t,r)=>{if(typeof e!==t)throw new TypeError(`Parameter '${r}' must be a ${t}.`)};class fi{static trapezoid(e,t,r,i,n,s=!1){return mi(e,t,r,i,n,s)}#Ks="";#Js=0;#Us=0;#Gs=0;#Ys=0;#Xs=!1;get name(){return this.#Ks}set name(e){pi(e,"string","FuzzySet.name"),this.#Ks=e}get a(){return this.#Js}set a(e){pi(e,"number","FuzzySet.a"),this.#Js=e}get b(){return this.#Us}set b(e){pi(e,"number","FuzzySet.b"),this.#Us=e}get c(){return this.#Gs}set c(e){pi(e,"number","FuzzySet.c"),this.#Gs=e}get d(){return this.#Ys}set d(e){pi(e,"number","FuzzySet.d"),this.#Ys=e}get optimize(){return this.#Xs}set optimize(e){pi(e,"boolean","FuzzySet.optimize"),this.#Xs=e}constructor(e,t,r,i,n,s=!1){this.name=e,this.a=t,this.b=r,this.c=i,this.d=n,this.optimize=s}calculate(e){return pi(e,"number","calculate.x"),fi.trapezoid(e,this.#Js,this.#Us,this.#Gs,this.#Ys,this.#Xs)}}class yi{#Qs=new Map;addVariable(e,t){pi(e,"string","addVariable.name"),di(t),this.#Qs.set(e,t)}removeVariable(e){return pi(e,"string","removeVariable.name"),this.#Qs.delete(e)}getVariable(e){pi(e,"string","getVariable.name");const t=this.#Qs.get(e);if(!t)throw new Error(`Linguistic variable '${e}' not found in the inference system.`);return[...t]}hasVariable(e){return pi(e,"string","hasVariable.name"),this.#Qs.has(e)}fuzzify(e,t){pi(e,"string","fuzzify.varName"),pi(t,"number","fuzzify.value");const r=this.#Qs.get(e)||[],i={};return r.forEach(e=>{i[e.name]=e.calculate(t)}),i}}class gi{#Zs=new Set;get appliedPlugins(){if(this.#eo)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return[...this.#Zs]}#to=[];get appliedPluginClasses(){if(this.#eo)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return[...this.#to]}get size(){if(this.#eo)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return this.#to.length}#ro;get currentClass(){if(this.#eo)throw new Error("[TinyClassManager] Cannot get a consumed manager instance.");return this.#ro}#eo=!1;get used(){return this.#eo}constructor(e,t=[]){this.#ro=e,this.#to=[...t,e]}#io(e,t,r){if(this.#eo)throw new Error("[TinyClassManager] Cannot reuse a consumed manager instance.");if(this.#Zs.has(e))throw new Error(`[TinyClassManager] Plugin conflict: "${e}" is already installed.`);for(const r of t)if(!this.#Zs.has(r))throw new Error(`[TinyClassManager] Missing Dependency: "${e}" requires "${r}" to be installed first.`);const i=new gi(r,this.#to);return this.#Zs.forEach(e=>i.#Zs.add(e)),i.#Zs.add(e),this.#eo=!0,this.#Zs.clear(),this.#to=[],i}use(e){const t=e.dependencies||[],r=e.apply(this.#ro,this.appliedPluginClasses);return this.#io(e.name,t,r)}insert(e){const t=e(this.#ro,this.appliedPluginClasses),r=t._tinyDepName;if(!r)throw new Error("[TinyClassManager] Plugin class must define a static '_tinyDepName' property.");const i=t._tinyDeps??[];if(!Array.isArray(i)||!i.every(e=>"string"==typeof e))throw new Error("[TinyClassManager] Plugin class must define a static array of strings in '_tinyDepName' property.");return this.#io(r,i,t)}build(){if(this.#eo)throw new Error("[TinyClassManager] Cannot build from an already finalized manager.");return this.#eo=!0,this.#Zs.clear(),this.#to=[],this.#ro}}const wi=gi,bi=ee("TinyRadioFm");class vi extends lr.EventEmitter{static async parseContent(e,t,r,i,n,s=!0){return Yt(e,t,r,i,n,s,vi.#no)}static#no="Unknown Artist";static get unknownArtist(){return vi.#no}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must have an string or function.");vi.#no=e}#h=!1;get destroyed(){return this.#h}get size(){return bi(this.#h),this.#so.length+this.#oo.length}get musicSize(){return bi(this.#h),this.#so.length}get voiceSize(){return bi(this.#h),this.#oo.length}get customPosSize(){return bi(this.#h),this.#ao.length}get tasksSize(){return bi(this.#h),this.#lo.length}get cycleCacheSize(){return bi(this.#h),this.#uo.size}#so=[];get musicList(){return bi(this.#h),structuredClone(this.#so)}#oo=[];get voiceList(){return bi(this.#h),structuredClone(this.#oo)}#ao=[];get customPositions(){return bi(this.#h),structuredClone(this.#ao)}#lo=[];get scheduledTasks(){return bi(this.#h),structuredClone(this.#lo)}get allList(){return bi(this.#h),[...this.musicList,...this.voiceList]}#fn=0;get seed(){return bi(this.#h),this.#fn}set seed(e){if(bi(this.#h),"number"!=typeof e)throw new TypeError("Seed must be a number.");this.#fn=e,this.#uo.clear(),this.emit("seedChanged",{seed:e})}#ho=Date.now();get anchorDate(){return bi(this.#h),this.#ho}#uo=new Map;#vt={mode:"playlist",voiceMode:"playlist",silenceDuration:0,queryLimit:1e5,voiceAfterMusic:!0,voiceMin:0,voiceMax:1,musicMaxConsecutive:0,musicMinConsecutive:0,voiceMaxConsecutive:0,voiceMinConsecutive:0};get config(){return bi(this.#h),structuredClone(this.#vt)}set config(e){bi(this.#h),this.#do(e),this.#vt=structuredClone(e),this.#uo.clear(),this.emit("configChanged",{config:this.config})}#do(e){if("object"!=typeof e||null===e)throw new TypeError("Configuration must be a valid object.");const t=["playlist","random"];if(void 0!==e.mode&&!t.includes(e.mode))throw new TypeError(`Invalid mode: "${e.mode}". Must be one of: ${t.join(", ")}.`);if(void 0!==e.voiceMode&&!t.includes(e.voiceMode))throw new TypeError(`Invalid voiceMode: "${e.voiceMode}". Must be one of: ${t.join(", ")}.`);if(void 0!==e.silenceDuration&&("number"!=typeof e.silenceDuration||e.silenceDuration<0))throw new TypeError("silenceDuration must be a non-negative number.");if(void 0!==e.queryLimit&&("number"!=typeof e.queryLimit||e.queryLimit<=0))throw new TypeError("queryLimit must be a positive number.");if(void 0!==e.voiceAfterMusic&&"boolean"!=typeof e.voiceAfterMusic)throw new TypeError("voiceAfterMusic must be a boolean.");const r=(e,t)=>{if(void 0!==e&&("number"!=typeof e||e<0))throw new TypeError(`${t} must be a non-negative number.`)};r(e.voiceMin,"voiceMin"),r(e.voiceMax,"voiceMax"),r(e.musicMinConsecutive,"musicMinConsecutive"),r(e.musicMaxConsecutive,"musicMaxConsecutive"),r(e.voiceMinConsecutive,"voiceMinConsecutive"),r(e.voiceMaxConsecutive,"voiceMaxConsecutive");const i=e.voiceMin??this.#vt.voiceMin,n=e.voiceMax??this.#vt.voiceMax;if(n<i)throw new RangeError(`Logical error: voiceMax (${n}) cannot be less than voiceMin (${i}).`);const s=e.musicMinConsecutive??this.#vt.musicMinConsecutive,o=e.musicMaxConsecutive??this.#vt.musicMaxConsecutive;if(-1!==o&&s>o)throw new RangeError(`Logical error: musicMinConsecutive (${s}) cannot be greater than musicMaxConsecutive (${o}).`)}#co=!0;get optimizeMediaMemory(){return bi(this.#h),this.#co}set optimizeMediaMemory(e){if(bi(this.#h),"boolean"!=typeof e)throw new TypeError("optimizeMediaMemory must be a boolean.");this.#co=e}#mo=!0;get optimizePictureMemory(){return bi(this.#h),this.#mo}set optimizePictureMemory(e){if(bi(this.#h),"boolean"!=typeof e)throw new TypeError("optimizePictureMemory must be a boolean.");this.#mo=e}constructor(e=null,t=0){if(super(),null!==e&&"object"!=typeof e)throw new TypeError("initialData must be an object or null.");if("number"!=typeof t)throw new TypeError("seed must be a number.");this.#fn=t,e?this.#po(e):this.#ho=Date.now()}_ccBase64ToBlobUrl(e){this.#co&&"string"==typeof e.url&&e.url.startsWith("data:")&&(e.url=Vt(e.url)),e.picture&&Array.isArray(e.picture)&&(e.picture=e.picture.map(e=>{if(this.#mo){const t="string"==typeof e.data&&e.data.startsWith("data:"),r=e.data instanceof Uint8Array;if(t||r)return{...e,data:Vt(e.data,e.format)}}return e}))}async _rcblobUrlToBase64(e){this.#co&&"string"==typeof e.url&&e.url.startsWith("blob:")&&(e.url=await qt(e.url)),this.#mo&&e.picture&&Array.isArray(e.picture)&&(e.picture=await Promise.all(e.picture.map(async e=>"string"==typeof e.data&&e.data.startsWith("blob:")?{...e,data:await qt(e.data)}:e)))}add(e,t,r=!0){if(bi(this.#h),!["music","voice","custom"].includes(e))throw new TypeError('Type must be "music", "voice", or "custom".');if(!t||"string"!=typeof t.id||"number"!=typeof t.duration)throw new TypeError("Content must have a string ID and a valid numerical duration in milliseconds.");if("boolean"!=typeof r)throw new TypeError("smartQueue must be a boolean.");Ut(t);const i=structuredClone(t);this._ccBase64ToBlobUrl(i),"music"===e?(this.#so.push(i),this.#uo.clear()):"voice"===e?(this.#oo.push(i),this.#uo.clear()):"custom"===e&&this.#fo(i,r),this.#yo(Date.now()),this.emit("contentAdded",{type:e,data:structuredClone(i)})}scheduleTask(e,t,r,i,n=!0){if(bi(this.#h),"number"!=typeof e||isNaN(e))throw new TypeError("timestamp must be a valid number.");if(!["add","remove","move"].includes(t))throw new TypeError('action must be "add", "remove", or "move".');if(!["music","voice"].includes(r))throw new TypeError('type must be "music" or "voice".');if("boolean"!=typeof n)throw new TypeError("smartQueue must be a boolean.");if("add"===t){if("object"!=typeof i||null===i||"string"!=typeof i.id||"number"!=typeof i.duration)throw new TypeError('Payload for "add" must be a MediaContent object (id: string, duration: number).')}else if("remove"===t){if("string"!=typeof i)throw new TypeError('Payload for "remove" must be a string (the content ID).')}else if("move"===t&&("object"!=typeof i||null===i||"string"!=typeof i.id||"number"!=typeof i.newIndex))throw new TypeError('Payload for "move" must be a ScheduledMovePayload (id: string, newIndex: number).');let s=e;if(n){const t=this.#go(e,e);t&&(s=t.absoluteEnd)}g(i)&&"number"!=typeof i.newIndex&&Ut(i);const o={timestamp:s,action:t,type:r,payload:i};this.#lo.push(o),this.#yo(Date.now()),this.emit("taskScheduled",structuredClone(o))}remove(e){if(bi(this.#h),"string"!=typeof e)throw new TypeError("id must be a string.");this.#so.filter(t=>t.id===e).forEach(e=>Kt(e)),this.#oo.filter(t=>t.id===e).forEach(e=>Kt(e)),this.#ao.filter(t=>t.content?.id===e).forEach(e=>Kt(e.content));const t=t=>t.id!==e&&t.content?.id!==e;this.#so=this.#so.filter(t),this.#oo=this.#oo.filter(t),this.#ao=this.#ao.filter(t),this.#lo=this.#lo.filter(t=>"add"===t.action&&"object"==typeof t.payload&&null!==t.payload&&"id"in t.payload?t.payload.id!==e||(Kt(t.payload),!1):t.payload!==e),this.#uo.clear(),this.emit("contentRemoved",{id:e})}setConfig(e){bi(this.#h),this.#do(e);const t={...this.#vt,...e};this.#do(t),this.#vt=t,this.#uo.clear(),this.emit("configChanged",{config:this.config})}getCurrentEvent(){bi(this.#h);const e=Date.now();return this.#yo(e),this.#go(e,e)}queryTimeline(e,t=10){if(bi(this.#h),"number"!=typeof t||isNaN(t))throw new TypeError("Invalid query limit value. Ensure it is a number.");if(t>this.#vt.queryLimit||t<=0)throw new RangeError(`Invalid query limit. Ensure it is > 0 and <= ${this.#vt.queryLimit}.`);const r=new vi(JSON.parse(this._exportState())),i=[];let n=e;for(let s=0;s<t;s++){r.#yo(n);const t=r.#wo(n,e);if(!t)break;i.push(t),n=t.absoluteEnd}return r.destroy(!1),this.emit("timelineQueried",{targetDate:e,limit:t,resultCount:i.length}),i}searchCustomPositions(){return bi(this.#h),this.#yo(Date.now()),[...this.#ao]}async _processListForExport(e){return Promise.all(e.map(async e=>{Ut(e);const t=structuredClone(e);return await this._rcblobUrlToBase64(t),t}))}_exportState(){return JSON.stringify({music:this.#so,voice:this.#oo,custom:this.#ao,tasks:this.#lo,seed:this.#fn,anchorDate:this.#ho,config:this.#vt})}async exportState(){bi(this.#h);const e=await this._processListForExport(this.#so),t=await this._processListForExport(this.#oo),r=await Promise.all(this.#ao.map(async e=>{const t=await this._processListForExport([e.content]);return{...e,content:t[0]}})),i=await Promise.all(this.#lo.map(async e=>{if("add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload){const t=await this._processListForExport([e.payload]);return{...e,payload:t[0]}}return e}));return JSON.stringify({music:e,voice:t,custom:r,tasks:i,seed:this.#fn,anchorDate:this.#ho,config:this.#vt})}importState(e){let t;if(bi(this.#h),"string"==typeof e)try{t=JSON.parse(e)}catch{throw new TypeError("Provided string is not valid JSON.")}else{if("object"!=typeof e||null===e)throw new TypeError("Import data must be a valid JSON string or an object.");t=e}this.#po(t),this.emit("stateImported",{data:structuredClone(t)})}_prng(e){return function(){let t=e+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}#bo(e,t,r,i=0,n=0,s=null,o=0){if(0===e.length)return{items:[],lastId:s,consecutiveCount:o};if("random"!==r){const t=[...e],r=t[t.length-1];return{items:t,lastId:r.id,consecutiveCount:s===r.id?o+1:1}}const a=e.map(e=>({...e,weight:e.weight??1})),l=this._prng(t),u=[];let h=s,d=o;for(;a.length>0;){let e=null,t=-1;if(null!==h&&d<i&&(t=a.findIndex(e=>e.id===h),-1!==t?e=a[t]:u.length>0&&(e=u[u.length-1])),!e){let r=a;null!==h&&-1!==n&&d>=n&&(r=a.filter(e=>e.id!==h)),0===r.length&&(r=a);const i=r.reduce((e,t)=>e+t.weight,0);if(i<=0)e=r[0],t=a.findIndex(t=>t.id===e?.id);else{const n=l()*i;let s=0;for(let i=0;i<r.length;i++)if(s+=r[i].weight,n<=s){e=r[i],t=a.findIndex(t=>t.id===e?.id);break}}}e||(e=a[0],t=0),u.push(e),-1!==t&&a.splice(t,1),e.id===h?d++:(h=e.id,d=1)}return{items:u,lastId:h,consecutiveCount:d}}#vo(e){const t=this.#fn+e,r=this._prng(10*t);let i=null,n=0,s=null,o=0;if(e>0){const t=this.#uo.get(e-1);t&&(i=t.lastMusicId??null,n=t.musicConsecutiveCount??0,s=t.lastVoiceId??null,o=t.voiceConsecutiveCount??0)}const a=this.#bo(this.#so,t+1,this.#vt.mode,this.#vt.musicMinConsecutive,this.#vt.musicMaxConsecutive,i,n),l=a.items,u=this.#bo(this.#oo,t+2,this.#vt.voiceMode,this.#vt.voiceMinConsecutive,this.#vt.voiceMaxConsecutive,s,o),h=u.items,d=[];let c=0,m=0;for(let e=0;e<l.length;e++){const t=l[e];if(d.push({...t,cycleStart:c,cycleEnd:c+t.duration}),c+=t.duration+this.#vt.silenceDuration,this.#vt.voiceAfterMusic&&h.length>0){const e=this.#vt.voiceMax-this.#vt.voiceMin+1,t=Math.floor(r()*e)+this.#vt.voiceMin;for(let e=0;e<t;e++){const e=h[m%h.length];m++,d.push({...e,cycleStart:c,cycleEnd:c+e.duration}),c+=e.duration+this.#vt.silenceDuration}}}return{items:d,duration:c,lastMusicId:a.lastId,musicConsecutiveCount:a.consecutiveCount,lastVoiceId:u.lastId,voiceConsecutiveCount:u.consecutiveCount}}#Eo(e){if(0===this.#so.length)return null;let t=this.#ho,r=0;for(;;){if(r>this.#vt.queryLimit)throw new Error("Safety limit hit during cycle location.");let i=this.#uo.get(r);if(i||(i=this.#vo(r),this.#uo.set(r,i)),0===i.duration)return null;if(e>=t&&e<t+i.duration)return{block:i,startTimestamp:t,loopIndex:r};t+=i.duration,r++}}#wo(e,t){const r=this.#ao.filter(t=>t.intendedTimestamp+t.content.duration>e).sort((e,t)=>e.intendedTimestamp-t.intendedTimestamp)[0];let i=null;if(r){const e=Math.max(t,r.intendedTimestamp);i=this.#To(r.content,r.intendedTimestamp,e,!0)}const n=this.#So(e,t);return n||i?n?i?i.absoluteStart<=n.absoluteStart?i:(i.absoluteStart<n.absoluteEnd&&(n.absoluteEnd=i.absoluteStart,n.duration=n.absoluteEnd-n.absoluteStart,n.remainingTime=Math.max(0,n.absoluteEnd-t),n.progress=Math.min(1,n.elapsedTime/n.duration)),n):n:i:null}#So(e,t){let r=this.#Eo(e);if(!r)return null;const{block:i,startTimestamp:n}=r,s=e-n;let o,a=i.items.find(e=>e.cycleEnd>s);if(a)o=n+a.cycleStart;else{if(r=this.#Eo(n+i.duration),!r||0===r.block.items.length)return null;a=r.block.items[0],o=r.startTimestamp+a.cycleStart}const l=Math.max(t,o);return this.#To(a,o,l,!1)}#go(e,t){const r=this.#ao.find(t=>e>=t.intendedTimestamp&&e<t.intendedTimestamp+t.content.duration);if(r)return this.#To(r.content,r.intendedTimestamp,t,!0);const i=this.#Eo(e);if(!i)return null;const{block:n,startTimestamp:s}=i,o=e-s,a=n.items.find(e=>o>=e.cycleStart&&o<e.cycleEnd);return a?this.#To(a,s+a.cycleStart,t,!1):null}#To(e,t,r,i){const n=r-t;return{id:e.id,title:e.title,artist:e.artist,duration:e.duration,url:e.url,absoluteStart:t,absoluteEnd:t+e.duration,elapsedTime:n,remainingTime:e.duration-n,progress:Math.min(1,n/e.duration),isCustom:i}}#fo(e,t){let r=e.timestamp||Date.now();const i=e.duration;if(t){const e=this.#go(r,r);e&&(r=e.absoluteEnd)}const n=[...this.#ao].sort((e,t)=>e.intendedTimestamp-t.intendedTimestamp);let s=r;if(n.some(e=>r<e.intendedTimestamp+e.content.duration&&r+i>e.intendedTimestamp)){const e=[];let t=Date.now();for(const r of n)r.intendedTimestamp>t&&e.push({start:t,end:r.intendedTimestamp}),t=Math.max(t,r.intendedTimestamp+r.content.duration+this.#vt.silenceDuration);e.push({start:t,end:1/0});let o=1/0;for(const t of e)if(t.end-t.start>=i){let e=null;if(r>=t.start&&r+i<=t.end?e=r:r<t.start?e=t.start:r>t.end&&(e=t.end-i),null!==e){const t=Math.abs(r-e);t<o&&(o=t,s=e)}}}this.#ao.push({content:e,intendedTimestamp:s,originalTimestamp:e.timestamp||Date.now()})}#yo(e){const t=this.#lo.filter(t=>t.timestamp<=e);this.#lo=this.#lo.filter(t=>t.timestamp>e);const r=this.#ao.filter(t=>t.intendedTimestamp+t.content.duration<=e);this.#ao=this.#ao.filter(t=>t.intendedTimestamp+t.content.duration>e);let i=!1;r.forEach(e=>{Kt(e.content),this.#fn+=e.content.id.length,i=!0,this.emit("customPositionExpired",{contentId:e.content.id})}),t.length>0&&t.sort((e,t)=>e.timestamp-t.timestamp).forEach(e=>{const t="music"===e.type?this.#so:this.#oo;if("add"===e.action)t.push(e.payload);else if("remove"===e.action){const r=t.findIndex(t=>t.id===e.payload);if(-1!==r){const[e]=t.splice(r,1);Kt(e)}}else if("move"===e.action){const r=e.payload,i=t.findIndex(e=>e.id===r.id);if(-1!==i){const[e]=t.splice(i,1);t.splice(r.newIndex,0,e)}}this.#ho=e.timestamp,this.#fn+=1,i=!0,this.emit("taskExecuted",structuredClone(e))}),i&&this.#uo.clear()}#po(e){this.#so.forEach(e=>Kt(e)),this.#oo.forEach(e=>Kt(e)),this.#ao.forEach(e=>Kt(e.content)),this.#lo.forEach(e=>{"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload&&Kt(e.payload)});const t=e=>e.map(e=>{Ut(e);const t=structuredClone(e);return this._ccBase64ToBlobUrl(t),t});this.#so=t(e.music),this.#oo=t(e.voice),this.#fn=e.seed||0,this.#ho=e.anchorDate||Date.now(),this.#vt={...this.#vt,...e.config||{}},this.#ao=e.custom.map(e=>({...e,content:t([e.content])[0]})),this.#lo=e.tasks.map(e=>"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload?{...e,payload:t([e.payload])[0]}:e)}destroy(e=!0){this.#h||(e&&(this.#so.forEach(e=>Kt(e)),this.#oo.forEach(e=>Kt(e)),this.#ao.forEach(e=>Kt(e.content)),this.#lo.forEach(e=>{"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload&&Kt(e.payload)})),this.#so=[],this.#oo=[],this.#ao=[],this.#lo=[],this.#uo.clear(),this.emit("destroyed",{timestamp:Date.now()}),this.removeAllListeners(),this.#h=!0)}}const Ei=vi,Ti=["chrome","firefox","ie","edge","safari","opera","yandex","other"];function Si(){const e=navigator.userAgent;return-1!==e.indexOf("Chrome")?"chrome":-1!==e.indexOf("Firefox")?"firefox":-1!==e.indexOf("MSIE")?"ie":-1!==e.indexOf("Edge")?"edge":-1!==e.indexOf("Safari")?"safari":-1!==e.indexOf("Opera")?"opera":-1!==e.indexOf("YaBrowser")?"yandex":"other"}function xi(){const e=(Array.prototype.slice.call(window.getComputedStyle(document.documentElement,"")).join("").match(/-(moz|webkit|ms)-/)??["",""])[1];return"moz"===e?"gecko":"webkit"===e?"webkit":"ms"===e?"trident":"other"}function Ai(){const e=!!window.opr&&!!opr.addons||!!window.opera||navigator.userAgent.indexOf(" OPR/")>=0,t="undefined"!=typeof InstallTrigger,r=/constructor/i.test(window.HTMLElement)||"[object SafariRemoteNotification]"===(!window.safari||"undefined"!=typeof safari&&safari.pushNotification).toString(),i=!!document.documentMode,n=!i&&!!window.StyleMedia,s=!!window.chrome;return{isOpera:e,isFirefox:t,isSafari:r,isIE:i,isEdge:n,isChrome:s,isBlink:(s||e)&&!!window.CSS}}function Ci(e=[]){if(!Array.isArray(e))throw new TypeError('The "disable" argument must be an array.');for(const t of e)if(!Ti.includes(t))throw new TypeError(`Invalid browser name provided in disable array: ${t}`);const t={chrome:0,firefox:0,ie:0,edge:0,safari:0,opera:0,yandex:0,other:0};t[Si()]++;const r=xi();"gecko"===r?e.indexOf("firefox")<0&&t.firefox++:"webkit"===r?(e.indexOf("chrome")<0&&t.chrome++,e.indexOf("safari")<0&&t.safari++,e.indexOf("opera")<0&&t.opera++,e.indexOf("edge")<0&&t.edge++):"trident"===r?e.indexOf("ie")<0&&t.ie++:e.indexOf("other")<0&&t.other++;const i=Ai();return i.isOpera&&e.indexOf("opera")<0&&t.opera++,i.isFirefox&&e.indexOf("firefox")<0&&t.firefox++,i.isSafari&&e.indexOf("safari")<0&&t.safari++,i.isIE&&e.indexOf("ie")<0&&t.ie++,i.isEdge&&e.indexOf("edge")<0&&t.edge++,i.isChrome&&e.indexOf("chrome")<0&&t.chrome++,t}function Ii(e=[]){const t=Ci(e);return Object.keys(t).reduce((e,r)=>t[r]>t[e]?r:e)}class Mi extends lr.EventEmitter{#xo;#Ao;#Co;#Io;#Mo;#Do=new Map([["log",""],["info",""],["warn",""],["error",""],["debug",""],["reset",""],["black",""],["red",""],["green",""],["yellow",""],["blue",""],["magenta",""],["cyan",""],["white",""],["gray",""]]);#ko=new Map([["log","[_log_LOG_reset_]"],["info","[_info_INFO_reset_]"],["warn","[_warn_WARN_reset_]"],["error","[_error_ERROR_reset_]"],["debug","[_debug_DEBUG_reset_]"]]);constructor({logger:e,id:t,debugMode:r,canEmitLogs:i=!1,useLogColors:n=!1}){if(super(),!w(e))throw new TypeError("Logger must be an object that implements the Console interface.");if("string"!=typeof t)throw new TypeError("Logger instance id must be a string.");if("boolean"!=typeof r)throw new TypeError("debugMode must be a boolean.");if("boolean"!=typeof i)throw new TypeError("canEmitLogs must be a boolean.");if("boolean"!=typeof n)throw new TypeError("useLogColors must be a boolean.");this.#Ao=t,this.#xo=e,this.#Io=r,this.#Co=i,this.#Mo="firefox"!==Ii()&&n,this.log("info","Emit logs of debug mode set to: "+(this.#Io?"ON":"OFF")),this.log("info","Custom logger assigned.")}get logId(){return this.#Ao}get canEmitLogs(){return this.#Co}get useLogColors(){return this.#Mo}set useLogColors(e){if("boolean"!=typeof e)throw new TypeError("useLogColors must be a boolean.");this.#Mo=e,this.log("info","Log Colors usage mode set to: "+(this.#Mo?"ON":"OFF")),this.emit("setDebugMode",e)}get debugMode(){return this.#Io}set debugMode(e){if("boolean"!=typeof e)throw new TypeError("debugMode must be a boolean.");this.#Io=e,this.log("info","Debug mode set to: "+(this.#Io?"ON":"OFF")),this.emit("setDebugMode",e)}_addLogColor(e,t){this.#Do.set(e,t)}_removeLogColor(e){this.#Do.delete(e)}_addLogPrefix(e,t){this.#ko.set(e,t)}_removeLogPrefix(e){this.#ko.delete(e)}#No(e){if("string"!=typeof e)return e;let t=e;for(const[e,r]of this.#ko){const i=new RegExp(`\\:${e}\\:`,"g");t=t.replace(i,r)}for(const[e,r]of this.#Do){const i=new RegExp(`\\_${e}\\_`,"g");t=t.replace(i,this.#Mo?r:"")}return t}logClear(){if(this.#Io)return this.#Co&&this.emit("debug:clear"),this.#xo.clear?this.#xo.clear():console.clear()}logGroupEnd(){if(this.#Io)return this.#Co&&this.emit("debug:groupEnd"),this.#xo.groupEnd?this.#xo.groupEnd():console.groupEnd()}logLabel(e,t){if(!this.#Io)return;const r=["count","countReset","time","timeEnd","profile","profileEnd","timeStamp"];if(!r.includes(e))throw new TypeError(`Invalid logType. Expected one of: ${r.join(", ")}`);if(void 0!==t&&"string"!=typeof t)throw new TypeError("The label must be a string.");const i=this.#xo[e]?this.#xo[e]:console[e];if(!i)throw new TypeError(`The log type "${e}" is not supported by the provided logger or console.`);return this.#Co&&this.emit("debug:logLabel",e,t),i(t)}logTimeLabel(e,...t){if(this.#Io)return this.#Co&&this.emit("debug:timeLog",e,...t),this.#xo.timeLog?this.#xo.timeLog(e,...t):console.timeLog(e,...t)}logAssert(e,...t){if(this.#Io)return this.#Co&&this.emit("debug:assert",e,...t),this.#xo.assert?this.#xo.assert(e,...t):console.assert(e,...t)}logDir(e,t){if(this.#Io)return this.#Co&&this.emit("debug:dir",e,t),this.#xo.dir?this.#xo.dir(e,t):console.dir(e,t)}logTable(e,t){if(this.#Io){if(!(void 0===t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("Properties must be an array of strings.");return this.#Co&&this.emit("debug:table",e,t),this.#xo.table?this.#xo.table(e,t):console.table(e,t)}}log(e,t,...r){if(!this.#Io)return;const i=["log","info","warn","error","debug","dirxml","group","groupCollapsed","trace"];if(!i.includes(e))throw new TypeError(`Invalid logType. Expected one of: ${i.join(", ")}`);if("string"!=typeof t)throw new TypeError("The message must be a string.");let n=this.#Ao,s=t;n=this.#No(n),s=this.#No(s);const o=this.#xo[e]?this.#xo[e]:console[e];return o?(this.#Co&&this.emit("debug:log",n,s,...r),o(n,s,...r)):(this.#Co&&this.emit("debug:log",n,s,...r),console.log(n,s,...r))}}const Di=Mi,ki=ee("BaseMediaAdapter");class Ni extends lr.EventEmitter{constructor(){if(new.target===Ni)throw new Error("BaseMediaAdapter is an abstract class and cannot be instantiated directly.");super()}#h=!1;get destroyed(){return this.#h}static getThumbnailUrl(e){if("string"!=typeof e||""===e.trim())throw new TypeError('The "trackId" must be a non-empty string.');return""}static canHandle(e){throw new Error('Method "canHandle" must be implemented by the subclass.')}isReady(){throw ki(this.#h),new Error('Method "isReady" must be implemented by the subclass.')}isPaused(){throw ki(this.#h),new Error('Method "isPaused" must be implemented by the subclass.')}isEnded(){throw ki(this.#h),new Error('Method "isEnded" must be implemented by the subclass.')}async waitIsReady(){throw ki(this.#h),new Error('Method "waitIsReady" must be implemented by the subclass.')}canHandle(e){return ki(this.#h),Ni.canHandle(e)}async play(e){throw ki(this.#h),new Error('Method "play" must be implemented by the subclass.')}async pause(){throw ki(this.#h),new Error('Method "pause" must be implemented by the subclass.')}async stop(){throw ki(this.#h),new Error('Method "stop" must be implemented by the subclass.')}async seek(e){throw ki(this.#h),new Error('Method "seek" must be implemented by the subclass.')}isMuted(){throw ki(this.#h),new Error('Method "isMuted" must be implemented by the subclass.')}async mute(){throw ki(this.#h),new Error('Method "mute" must be implemented by the subclass.')}async unMute(){throw ki(this.#h),new Error('Method "unMute" must be implemented by the subclass.')}getCurrentTime(){throw ki(this.#h),new Error('Method "getCurrentTime" must be implemented by the subclass.')}getTotalDuration(){throw ki(this.#h),new Error('Method "getTotalDuration" must be implemented by the subclass.')}getRemainingTime(){throw ki(this.#h),new Error('Method "getRemainingTime" must be implemented by the subclass.')}getPlaybackPercentage(){throw ki(this.#h),new Error('Method "getPlaybackPercentage" must be implemented by the subclass.')}getTimeData(){throw ki(this.#h),new Error('Method "getTimeData" must be implemented by the subclass.')}setVolume(e){throw ki(this.#h),new Error('Method "setVolume" must be implemented by the subclass.')}getVolume(){throw ki(this.#h),new Error('Method "getVolume" must be implemented by the subclass.')}async getContentData(){throw ki(this.#h),new Error('Method "getContentData" must be implemented by the subclass.')}destroy(){this.#h||(this.removeAllListeners(),this.#h=!0,this.emit("destroyed"))}}const Li=ee("TinyMediaPlayer");class _i extends Di{static BaseMediaAdapter=Ni;static#no="Unknown Artist";static get unknownArtist(){return _i.#no}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must be a string or a function.");_i.#no=e}static async parseContent(e,t,r,i,n,s){return Yt(e,t,r,i,n,s,_i.#no)}#h=!1;get destroyed(){return this.#h}#Lo=new Set;#_o=new WeakMap;#jo=[];#Ro=-1;#Po="NONE";#$o=!1;#Oo=!1;#Ho=!1;#Fo=1;#Bo;#zo;#Wo;#Vo=!1;#qo;#Ko;#Jo=null;#Uo=null;#Go=300;get fadeVolumeSpeed(){return Li(this.#h),this.#Go}set fadeVolumeSpeed(e){if(Li(this.#h),"number"!=typeof e)throw new TypeError("fadeVolumeSpeed must be a number.");if(e<0)throw new RangeError("fadeVolumeSpeed cannot be negative.");this.#Go=e,this.emit("fadeVolumeSpeedChange",this.#Go)}#Yo=2e3;get prevClickTimeoutDuration(){return Li(this.#h),this.#Yo}set prevClickTimeoutDuration(e){if(Li(this.#h),"number"!=typeof e)throw new TypeError("prevClickTimeoutDuration must be a number.");if(e<0)throw new RangeError("prevClickTimeoutDuration cannot be negative.");this.#Yo=e,this.emit("prevClickTimeoutDurationChange",this.#Yo)}get repeatCurrentOnPrev(){return Li(this.#h),this.#Wo}set repeatCurrentOnPrev(e){if(Li(this.#h),"boolean"!=typeof e)throw new TypeError("repeatCurrentOnPrev must be a boolean.");this.#Wo=e,this.emit("repeatCurrentOnPrevChange",this.#Wo)}get smoothPlayPauseVolume(){return Li(this.#h),this.#qo}set smoothPlayPauseVolume(e){if(Li(this.#h),"boolean"!=typeof e)throw new TypeError("smoothPlayPauseVolume must be a boolean.");this.#qo=e,this.emit("smoothPlayPauseVolumeChange",this.#qo)}get smoothStopVolume(){return Li(this.#h),this.#Ko}set smoothStopVolume(e){if(Li(this.#h),"boolean"!=typeof e)throw new TypeError("smoothStopVolume must be a boolean.");this.#Ko=e,this.emit("smoothStopVolumeChange",this.#Ko)}constructor(e={}){if(!w(e))throw new TypeError("Options must be a non-null object.");if(super({id:"[_blue_TinyMediaPlayer_reset_] :debug:",logger:e.logger??console,debugMode:e.debugMode??!1,useLogColors:e.useLogColors??!1}),void 0!==e.persistVolume){if("boolean"!=typeof e.persistVolume)throw new TypeError("persistVolume must be a boolean.");this.#Bo=e.persistVolume}else this.#Bo=!1;if(void 0!==e.volumeStorageKey){if("string"!=typeof e.volumeStorageKey)throw new TypeError("volumeStorageKey must be a string.");this.#zo=e.volumeStorageKey}else this.#zo="tiny_media_player_volume";if(void 0!==e.repeatCurrentOnPrev){if("boolean"!=typeof e.repeatCurrentOnPrev)throw new TypeError("repeatCurrentOnPrev must be a boolean.");this.#Wo=e.repeatCurrentOnPrev}else this.#Wo=!1;if(void 0!==e.smoothPlayPauseVolume){if("boolean"!=typeof e.smoothPlayPauseVolume)throw new TypeError("smoothPlayPauseVolume must be a boolean.");this.#qo=e.smoothPlayPauseVolume}else this.#qo=!1;if(void 0!==e.smoothStopVolume){if("boolean"!=typeof e.smoothStopVolume)throw new TypeError("smoothStopVolume must be a boolean.");this.#Ko=e.smoothStopVolume}else this.#Ko=!1;this.#Bo&&this.#Xo(),this.log("info","Instance initialized.",{options:e})}#Xo(){try{if("undefined"!=typeof window&&window.localStorage){const e=window.localStorage.getItem(this.#zo);if(null!==e){const t=parseFloat(e);!isNaN(t)&&t>=0&&t<=1&&(this.#Fo=t,this.log("info",`Volume loaded from storage: ${this.#Fo}`))}}}catch(e){console.warn("[TinyMediaPlayer] Failed to read volume from localStorage.",e)}}#Qo(){try{this.#Bo&&"undefined"!=typeof window&&window.localStorage&&(window.localStorage.setItem(this.#zo,this.#Fo.toString()),this.log("info",`Volume saved to storage: ${this.#Fo}`))}catch(e){console.warn("[TinyMediaPlayer] Failed to save volume to localStorage.",e)}}_getWeightedRandomIndex(){if(0===this.#jo.length)return-1;if(1===this.#jo.length)return 0;let e=0;for(let t=0;t<this.#jo.length;t++){if(t===this.#Ro)continue;const r=this.#jo[t];e+="number"==typeof r.weight&&r.weight>0?r.weight:1}let t=Math.random()*e;for(let e=0;e<this.#jo.length;e++){if(e===this.#Ro)continue;const r=this.#jo[e],i="number"==typeof r.weight&&r.weight>0?r.weight:1;if(t<i)return e;t-=i}return this.#Ro===this.#jo.length-1?0:this.#jo.length-1}async#Zo(e){this.#Jo&&this.#Jo.abort(),this.#Jo=new AbortController;const{signal:t}=this.#Jo,r=this.#ea();if(!r)return;const i=r.getVolume(),n=performance.now(),s=this.#Go;return this.log("info",`Starting volume fade: ${i} -> ${e}`),new Promise(o=>{const a=l=>{if(t.aborted)return this.log("info","Volume fade aborted."),o();const u=l-n,h=Math.min(u/s,1),d=i+(e-i)*h,c=Math.max(0,Math.min(1,d));r.setVolume(c),h<1?requestAnimationFrame(a):(r.setVolume(e),this.log("info",`Volume fade completed: ${e}`),o())};requestAnimationFrame(a)})}get playlist(){return Li(this.#h),[...this.#jo]}set playlist(e){if(Li(this.#h),!Array.isArray(e))throw new TypeError("Playlist must be an array of MediaContent objects.");e.forEach(e=>Ut(e));const t=this.#Oo;let r=null;if(-1!==this.#Ro&&this.#jo.length>0)try{r=this.#ea()}catch(e){}this.#jo=e,this.log("info",`Playlist updated. New size: ${this.#jo.length}`),this.emit("playlistUpdate",this.playlist),0===this.#jo.length?this.#Ro=-1:(this.#Ro>=this.#jo.length||-1===this.#Ro)&&(this.#Ro=0),this.emit("trackChange",this.#Ro),t&&(async()=>{try{r&&await r.stop(),-1!==this.#Ro&&await this.play()}catch(e){this.log("error","Background transition error on playlist update:",e),console.warn("[TinyMediaPlayer] Background transition error on playlist update:",e)}})()}get currentIndex(){return Li(this.#h),this.#Ro}set currentIndex(e){if(Li(this.#h),"number"!=typeof e)throw new TypeError("Current index must be a number.");if(e<-1||e>=this.#jo.length&&this.#jo.length>0)throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);if(this.#Ro===e)return;this.log("info",`Index change requested: ${this.#Ro} -> ${e}`);const t=this.#Oo;let r=null;if(-1!==this.#Ro&&this.#jo.length>0)try{r=this.#ea()}catch(e){}this.#Ro=e,this.emit("trackChange",this.#Ro),t&&(async()=>{try{r&&await r.stop(),-1!==this.#Ro&&await this.play()}catch(e){this.log("error","Background transition error on index update:",e),console.warn("[TinyMediaPlayer] Background transition error on index update:",e)}})()}get loopMode(){return Li(this.#h),this.#Po}set loopMode(e){Li(this.#h);const t=["NONE","TRACK","PLAYLIST"];if(!t.includes(e))throw new TypeError(`Loop mode must be one of: ${t.join(", ")}.`);this.#Po=e,this.log("info",`Loop mode changed to: ${this.#Po}`),this.emit("loopModeChange",this.#Po)}get isRandom(){return Li(this.#h),this.#$o}set isRandom(e){if(Li(this.#h),"boolean"!=typeof e)throw new TypeError("Random mode state must be a boolean.");this.#$o=e,this.log("info",`Random mode: ${this.#$o}`),this.emit("randomModeChange",this.#$o)}get isPlaying(){return Li(this.#h),this.#Oo}get volume(){return Li(this.#h),this.#Fo}set volume(e){if(Li(this.#h),"number"!=typeof e)throw new TypeError("Volume must be a number.");if(e<0||e>1)throw new RangeError("Volume must be tightly constrained between 0.0 and 1.0.");if(this.#Jo&&this.#Jo.abort(),this.log("info",`Volume changed: ${this.#Fo} -> ${e}`),this.#Fo=e,this.#Qo(),this.emit("volumeChange",this.#Fo),-1!==this.#Ro&&this.#jo.length>0)try{const e=this.#ea();e&&e.setVolume(this.#Fo)}catch(e){}}get persistVolume(){return Li(this.#h),this.#Bo}set persistVolume(e){if(Li(this.#h),"boolean"!=typeof e)throw new TypeError("Persist volume parameter must be a boolean.");this.#Bo=e,this.log("info",`Persist volume: ${this.#Bo}`),e&&this.#Qo()}get volumeStorageKey(){return Li(this.#h),this.#zo}set volumeStorageKey(e){if(Li(this.#h),"string"!=typeof e)throw new TypeError("Volume storage key must be a string.");if(""===e.trim())throw new TypeError("Volume storage key cannot be an empty string.");const t=this.#zo;this.#zo=e;try{this.#Bo&&"undefined"!=typeof window&&window.localStorage&&(window.localStorage.removeItem(t),this.#Qo())}catch(e){console.warn("[TinyMediaPlayer] Failed to migrate volume storage key.",e)}}get isMuted(){return Li(this.#h),this.#Ho}async mute(){Li(this.#h);const e=this.#ea();e&&(await e.mute(),this.#Ho=!0,this.emit("muteChange",this.#Ho),this.log("info","Playback muted successfully."))}async unMute(){Li(this.#h);const e=this.#ea();e&&(await e.unMute(),this.#Ho=!1,this.emit("muteChange",this.#Ho),this.log("info","Playback unmuted successfully."))}get adapters(){return Array.from(this.#Lo)}get adaptersSize(){return this.#Lo.size}static#ta=["timeupdate","ended"];static get defaultAdapterEventNames(){return structuredClone(_i.#ta)}static set defaultAdapterEventNames(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError("TinyMediaPlayer.defaultAdapterEventNames must be an array of strings.");_i.#ta=[...e]}#ra=new Set(_i.defaultAdapterEventNames);#ia(e){const t=this.#_o.get(e);t&&(this.#ra.forEach(r=>{const i=t.get(r);i&&e.off(r,i)}),t.clear(),this.#_o.delete(e))}registerAdapter(e){if(Li(this.#h),!(e instanceof Ni))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");this.log("info","Registering new adapter:",e);const t=new Map;this.#_o.set(e,t),this.#ra.forEach(t=>{this.#na(e,t)}),this.#Lo.add(e)}removeAdapter(e){if(Li(this.#h),!(e instanceof Ni))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");return this.log("info","Removing adapter:",e),this.#ia(e),this.#Lo.delete(e)}destroyAdapter(e){if(Li(this.#h),!(e instanceof Ni))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");this.log("info","Destroying adapter:",e),this.#ia(e);const t=this.#Lo.delete(e);return t&&e.destroy(),t}hasAdapter(e){if(Li(this.#h),!(e instanceof Ni))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");return this.#Lo.has(e)}destroyAllAdapters(){Li(this.#h),this.log("info","Destroying all adapters."),this.#Lo.forEach(e=>{this.#ia(e),e.destroy()}),this.#Lo.clear()}clearAdapters(){Li(this.#h),this.log("info","Clearing all adapters."),this.#Lo.forEach(e=>this.#ia(e)),this.#Lo.clear()}getMediaAdapter(e){if(!w(e))throw new TypeError("Content must be a valid object.");for(const t of this.#Lo.values())if(t.canHandle(e))return t;return null}#ea(){if(-1===this.#Ro||0===this.#jo.length)return null;const e=this.#jo[this.#Ro],t=this.getMediaAdapter(e);if(t)return t;const r=`No compatible adapter found for content ID: ${e.id}.`;throw this.log("error",r),new Error(r)}addAdapterEvent(e){if(Li(this.#h),"string"!=typeof e)throw new TypeError("Event name must be a string.");this.#ra.has(e)||(this.log("info",`Adding adapter event listener: ${e}`),this.#ra.add(e),this.#Lo.forEach(t=>{this.#na(t,e)}))}removeAdapterEvent(e){if(Li(this.#h),"string"!=typeof e)throw new TypeError("Event name must be a string.");this.#ra.has(e)&&(this.log("info",`Removing adapter event listener: ${e}`),this.#ra.delete(e),this.#Lo.forEach(t=>{this.#sa(t,e)}))}resetAdapterEvents(){Li(this.#h);const e=_i.defaultAdapterEventNames,t=Array.from(this.#ra);for(const r of t)e.includes(r)||this.removeAdapterEvent(r);for(const t of e)this.#ra.has(t)||this.addAdapterEvent(t)}#na(e,t){const r=this.#_o.get(e);if(!r)return;const i=(...e)=>{this.#h||("timeupdate"!==t&&this.log("debug",`Adapter event triggered: ${t}`,...e),this.emit(t,...e))};e.on(t,i),r.set(t,i)}#sa(e,t){const r=this.#_o.get(e);if(!r)return;const i=r.get(t);i&&(e.off(t,i),r.delete(t))}addTrack(e){if(Li(this.#h),!w(e)||"string"!=typeof e.url)throw new TypeError("Track content must be a valid MediaContent object containing a URL.");const t={id:"",title:"",artist:"",url:"",duration:0,weight:1,...e};Ut(t);const r=this.#jo.push(t);return this.log("info",`Track added. New length: ${r}`,t),-1===this.#Ro&&(this.#Ro=0,this.emit("trackChange",this.#Ro)),this.emit("playlistUpdate",this.playlist),r}existsTrack(e){if(Li(this.#h),"number"!=typeof e)throw new TypeError("Index must be a number.");return e>=0&&e<this.#jo.length}getTrack(e){if(Li(this.#h),"number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);return this.#jo[e]}async removeTrack(e){if(Li(this.#h),"number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);this.log("info",`Removing track at index: ${e}`),e===this.#Ro?(await this.stop(),this.#jo.splice(e,1),0===this.#jo.length?this.#Ro=-1:this.#Ro>=this.#jo.length&&(this.#Ro=0),this.emit("trackChange",this.#Ro)):(this.#jo.splice(e,1),e<this.#Ro&&(this.#Ro-=1,this.emit("trackChange",this.#Ro))),this.emit("playlistUpdate",this.playlist)}searchTrack(e){if(Li(this.#h),"string"!=typeof e&&"function"!=typeof e)throw new TypeError("Search query must be a string or a boolean evaluation function.");this.log("info","Searching playlist...",{query:e});const t=[];for(let r=0;r<this.#jo.length;r++){const i=this.#jo[r];let n=!1;if("function"==typeof e)n=Boolean(e(i));else{const t=e.toLowerCase(),r=i.title&&i.title.toLowerCase().includes(t),s=i.artist&&i.artist.toLowerCase().includes(t),o=i.album&&i.album.toLowerCase().includes(t);n=Boolean(r||s||o)}n&&t.push({track:i,index:r})}return this.log("info",`Search completed. Found ${t.length} results.`),t}async clearPlaylist(){Li(this.#h),this.log("info","Clearing entire playlist."),await this.stop(),this.#jo=[],this.#Ro=-1,this.emit("playlistUpdate",this.playlist),this.emit("trackChange",this.#Ro)}async play(){Li(this.#h),this.log("info",`Attempting to play track at index: ${this.#Ro}`);const e=this.#ea();if(e){this.#qo?await this.#Zo(this.#Fo):e.setVolume(this.#Fo);try{await e.play(this.#jo[this.#Ro]),this.#Ho&&await e.mute(),this.#Oo=!0,this.log("info","Playback started successfully."),this.emit("play",this.#Ro)}catch(e){throw this.log("error","Failed to play track:",e),e}}else this.log("error","Failed to play track:",`Active adapter not found for track at index ${this.#Ro}.`)}async pause(){Li(this.#h),this.log("info","Attempting to pause playback.");const e=this.#ea();e&&(this.#qo&&await this.#Zo(0),await e.pause(),this.#Oo=!1,this.log("info","Playback paused."),this.emit("pause",this.#Ro))}async stop(){Li(this.#h),this.log("info","Attempting to stop playback.");const e=this.#ea();e&&(this.#Ko&&await this.#Zo(0),await e.stop(),this.#Oo=!1,this.log("info","Playback stopped."),this.emit("stop",this.#Ro))}async next(){if(Li(this.#h),0!==this.#jo.length){if(this.log("info","Next track requested."),await this.stop(),"TRACK"===this.#Po)return this.log("info","Loop mode: TRACK. Repeating current track."),void await this.play();if(this.#$o)this.#Ro=this._getWeightedRandomIndex(),this.log("info",`Random mode: Selected index ${this.#Ro}`);else{let e=this.#Ro+1;if(e>=this.#jo.length){if("PLAYLIST"!==this.#Po)return void this.log("info","End of playlist reached. Stopping.");e=0,this.log("info","Loop mode: PLAYLIST. Returning to start.")}this.#Ro=e}this.emit("trackChange",this.#Ro),await this.play()}}async prev(){if(Li(this.#h),0!==this.#jo.length){if(this.#Wo&&!this.#Vo)return this.log("info",'UX: Repeat current track on first "prev" click.'),this.#Vo=!0,this.#Uo&&clearTimeout(this.#Uo),this.#Uo=setTimeout(()=>{this.#Vo=!1,this.#Uo=null},2e3),await this.stop(),void await this.play();if(this.#Uo&&(clearTimeout(this.#Uo),this.#Uo=null),this.#Vo=!1,this.log("info","Previous track requested."),await this.stop(),this.#$o)this.#Ro=this._getWeightedRandomIndex(),this.log("info",`Random mode: Selected index ${this.#Ro}`);else{let e=this.#Ro-1;if(e<0){if("PLAYLIST"!==this.#Po)return void this.log("info","Start of playlist reached. Stopping.");e=this.#jo.length-1,this.log("info","Loop mode: PLAYLIST. Returning to end.")}this.#Ro=e}this.emit("trackChange",this.#Ro),await this.play()}}async skipTo(e){if(Li(this.#h),"number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);this.log("info",`Skipping to index: ${e}`),await this.stop(),this.#Ro=e,this.emit("trackChange",this.#Ro),await this.play()}async seek(e){if(Li(this.#h),"number"!=typeof e)throw new TypeError("Seek time must be a number in milliseconds.");if(e<0)throw new RangeError("Seek time cannot be negative.");this.log("info",`Seeking to: ${e}ms`);const t=this.#ea();t&&(await t.seek(e),this.emit("seek",e))}async step(e){if(Li(this.#h),"number"!=typeof e)throw new TypeError("Step amount must be a number in milliseconds.");this.log("info",`Stepping by: ${e}ms`);const t=this.#ea();if(!t)return;let r=t.getCurrentTime()+e;r<0&&(r=0),await this.seek(r)}getCurrentTime(){Li(this.#h);try{const e=this.#ea();return e?e.getCurrentTime():0}catch{return 0}}getTotalDuration(){Li(this.#h);try{const e=this.#ea();return e?e.getTotalDuration():0}catch{return 0}}getRemainingTime(){Li(this.#h);try{const e=this.#ea();return e?e.getRemainingTime():0}catch{return 0}}getPlaybackPercentage(){Li(this.#h);try{const e=this.#ea();return e?e.getPlaybackPercentage():0}catch{return 0}}get isPaused(){Li(this.#h);try{const e=this.#ea();return!!e&&e.isPaused()}catch{return!1}}get isEnded(){Li(this.#h);try{const e=this.#ea();return!e||e.isEnded()}catch{return!0}}async getContentData(){Li(this.#h);const e={id:"",createdAt:"",artistId:"",artistName:"",description:"",title:"",duration:0,avatar:"",url:""};try{const t=this.#ea();return t?t.getContentData():e}catch{return e}}async waitIsReady(){Li(this.#h);const e=this.#ea();if(e)return e.waitIsReady()}async destroy(){if(!this.#h){this.log("info","Destroying TinyMediaPlayer instance.");try{this.#Oo&&await this.stop()}catch(e){this.log("error","Non-fatal error during playback termination:",e),console.warn("[TinyMediaPlayer] Non-fatal error during playback termination:",e)}this.#Uo&&clearTimeout(this.#Uo),this.#jo=[],this.#Ro=-1,this.#Oo=!1,this.#Vo=!1,this.destroyAllAdapters(),this.removeAllListeners(),this.#ra.clear(),this.#h=!0,this.emit("destroyed")}}}const ji=_i}};const t={};function r(i){const n=t[i];if(void 0!==n)return n.exports;const s=t[i]={exports:{}};return e[i](s,s.exports,r),s.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var i=0;i<t.length;){var n=t[i++],s=t[i++];r.o(e,n)?0===s&&i++:0===s?Object.defineProperty(e,n,{enumerable:!0,value:t[i++]}):Object.defineProperty(e,n,{enumerable:!0,get:s})}else for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.cjs=e=>{const t={exports:{}};return e.call(t.exports,t,t.exports),t.exports};let i=r(256);window.TinyEssentials=i})();