tiny-essentials 1.28.14 → 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.
- package/changelog/1/28/14.md +3 -3
- package/changelog/1/28/15.md +11 -0
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyMediaPlayer.min.js +1 -1
- package/dist/v1/TinyRadioFm.min.js +1 -1
- package/dist/v1/basics/mediaContent.cjs +208 -212
- package/dist/v1/basics/mediaContent.d.mts +22 -14
- package/dist/v1/basics/mediaContent.mjs +190 -191
- package/package.json +1 -1
package/changelog/1/28/14.md
CHANGED
|
@@ -6,9 +6,9 @@ We have released a significant update to `mediaContent.mjs`, focusing on memory
|
|
|
6
6
|
We have introduced a new property within the `MediaContentMetadata` structure to provide more transparency.
|
|
7
7
|
|
|
8
8
|
* **`valFetchMediaContent` Function:** The new function added.
|
|
9
|
-
* **`
|
|
10
|
-
* **⚠️ Developer Responsibility:** Please note that `
|
|
11
|
-
* **⚙️ Customization:** If you want `
|
|
9
|
+
* **`_fetchData` Property:** This new property provides direct access to the **original, raw value** retrieved by `parseFile`.
|
|
10
|
+
* **⚠️ Developer Responsibility:** Please note that `_fetchData` is **pure and unvalidated**. Because it bypasses our standard validation pipeline, it is the developer's responsibility to implement custom validation logic if these native values are used.
|
|
11
|
+
* **⚙️ Customization:** If you want `_fetchData` to return `null`, you can achieve this via `parseMediaMetadata` by passing `null` to the `metadata` argument (manual metadata overrides automatic extraction). 🔄
|
|
12
12
|
|
|
13
13
|
### ⚡ Performance & Memory Optimizations
|
|
14
14
|
We have refined the internal data structure of `MediaContent` to ensure higher efficiency. 🚀
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
## 🚀 Update: `mediaContent` Enhancements
|
|
2
|
+
|
|
3
|
+
### ✨ Features
|
|
4
|
+
- **`ILyricsTag`**: Added `descriptor` and `language` properties to provide more detailed metadata.
|
|
5
|
+
|
|
6
|
+
### 🛠️ Improvements
|
|
7
|
+
- **`mediaContent` Validation**: Upgraded validators for the following types to support partial validation, increasing flexibility in data processing:
|
|
8
|
+
- `ILyricsText`
|
|
9
|
+
- `TimestampFormat`
|
|
10
|
+
- `LyricsContentType`
|
|
11
|
+
- `ILyricsTag`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";const e={d:(t,r)=>{if(Array.isArray(r))for(var n=0;n<r.length;){var o=r[n++],a=r[n++];e.o(t,o)?0===a&&n++:0===a?Object.defineProperty(t,o,{enumerable:!0,value:r[n++]}):Object.defineProperty(t,o,{enumerable:!0,get:a})}else for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}};let t={};function r(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 n(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 n=0;n<e.length;n++){if("number"!=typeof t[n]||Number.isNaN(t[n]))throw new TypeError(`Element at counts[${n}] must be a valid number.`);for(let o=0;o<t[n];o++)r.push(e[n])}return r}function o(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 a(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 i(){const e=new Intl.DateTimeFormat(void 0,{hour:"numeric"}).resolvedOptions().hourCycle;return e?.startsWith("h12")?12:24}function s(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 n=["asMilliseconds","asSeconds","asMinutes","asHours","asDays"];if(!n.includes(t))throw new RangeError(`The 'durationType' must be one of: ${n.join(", ")}.`);if(null!==r&&!(r instanceof Date))throw new TypeError("The 'now' argument must be an instance of Date or null.");const o=r instanceof Date?r:new Date,a=e.getTime()-o.getTime();switch(t){case"asMilliseconds":return a;case"asSeconds":default:return a/1e3;case"asMinutes":return a/6e4;case"asHours":return a/36e5;case"asDays":return a/864e5}}function l(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 n=["seconds","minutes","hours","days","months","years"];if(!n.includes(t))throw new RangeError(`The 'level' must be one of: ${n.join(", ")}.`);if("string"!=typeof r)throw new TypeError("The 'format' argument must be a string.");e=Math.max(0,Math.floor(e));const o=n.indexOf(t),a=o>=5,i=o>=4,s=o>=3,l=o>=2,u=o>=1,m=o>=0,c={years:a?0:NaN,months:i?0:NaN,days:s?0:NaN,hours:l?0:NaN,minutes:u?0:NaN,seconds:m?0:NaN,total:NaN};let f=e;if(a||i||s){const e=new Date(1980,0,1),t=new Date(e.getTime()+1e3*f),r=new Date(e);if(a)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),c.years++;if(i)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),c.months++;if(s)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),c.days++;f=Math.floor((t.getTime()-r.getTime())/1e3)}l&&(c.hours=Math.floor(f/3600),f%=3600),u&&(c.minutes=Math.floor(f/60),f%=60),m&&(c.seconds=f),c.total=+e.toFixed(2).replace(/\.00$/,"");const d=e=>{const t="string"==typeof e?parseInt(e):e;return Number.isNaN(t)?"NaN":String(t).padStart(2,"0")},p=[l?d(c.hours):null,u?d(c.minutes):null,m?d(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,d(c.hours)).replace(/\{minutes\}/g,d(c.minutes)).replace(/\{seconds\}/g,d(c.seconds)).replace(/\{time\}/g,p).replace(/\{total\}/g,String(c.total)).trim()}function u(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'seconds' argument must be a valid number.");return l(e,"hours","{hours}:{minutes}:{seconds}")}function m(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'seconds' argument must be a valid number.");return l(e,"days","{days}d {hours}:{minutes}:{seconds}")}function c(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 n=r.indexOf(t),o=n>=6,a=n>=5,i=n>=4,s=n>=3,l=n>=2,u=n>=1,m=n>=0,c={years:o?0:NaN,months:a?0:NaN,days:i?0:NaN,hours:s?0:NaN,minutes:l?0:NaN,seconds:u?0:NaN,milliseconds:m?0:NaN,total:NaN};let f=e;if(o||a||i){const e=new Date(1980,0,1),t=new Date(e.getTime()+f),r=new Date(e);if(o)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),c.years++;if(a)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),c.months++;if(i)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),c.days++;f=t.getTime()-r.getTime()}return s&&(c.hours=Math.floor(f/36e5),f%=36e5),l&&(c.minutes=Math.floor(f/6e4),f%=6e4),u&&(c.seconds=Math.floor(f/1e3),f%=1e3),m&&(c.milliseconds=f),c.total=+e,c}function f(e){if(!Array.isArray(e)&&!d(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 d(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}function p(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function y(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,n)=>{const o=new FileReader;o.onload=()=>{try{r(o.result)}catch(e){n(e)}},o.onerror=()=>{n(o.error)},o[t](e)}):Promise.reject(new TypeError(`The "method" argument must be one of: ${r.join(", ")}.`))}function w(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,n)=>{y(e,"readAsDataURL").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const n=e.match(/^data:(.+);base64,(.*)$/);if(!n||!n[2])throw new Error("Invalid data URL format or missing Base64 content.");const[,o,a]=n;if(!/^[\w/+]+=*$/.test(a))throw new Error("Base64 content is malformed.");if("boolean"==typeof t)return r(t?e:a);if(!/^[\w-]+\/[\w.+-]+$/.test(t))throw new Error(`Invalid MIME type string: ${t}`);return r(`data:${t};base64,${a}`)}).catch(n)}):Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'))}function g(e){return e instanceof Blob?new Promise((t,r)=>y(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 n=JSON.parse(r);if("object"!=typeof n||null===n)throw new Error("Parsed content is not a valid JSON object or array.");t(n)}).catch(r)):Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'))}function b(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 n=JSON.stringify(t,null,r),o=new Blob([n],{type:"application/json"}),a=URL.createObjectURL(o),i=document.createElement("a");i.href=a,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(a)}function h(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 n=e.headers.get("content-length"),o=n?parseInt(n,10):0;let a=0;const i=e.body.getReader(),s=new ReadableStream({async start(e){for(;;){const{done:r,value:n}=await i.read();if(r)break;a+=n.byteLength,t(a,o),e.enqueue(n)}e.close()}});return new Response(s,r(e))}async function E(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((n,o)=>{fetch(e,t??void 0).then(async e=>{const t=r?h(e,r):e,o=t.headers.get("content-type")||"";if(!o.includes("application/json"))throw new Error(`Unexpected content-type: ${o}`);const a=await t.json();if(!Array.isArray(a)&&!d(a))throw new Error("Received invalid data instead of valid JSON.");return n(a)}).catch(o)})}async function v(e,t,r,n){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!==n&&"function"!=typeof n?Promise.reject(new TypeError('The "onProgress" option must be a function.')):new Promise((o,a)=>{fetch(e,r??void 0).then(async e=>{const r=n?h(e,n):e,a=r.headers.get("content-type")||"";if(Array.isArray(t)&&t.length>0&&!t.some(e=>a.includes(e)))throw new Error(`Blocked MIME type: ${a}`);const i=await r.text();return o(i)}).catch(a)}):Promise.reject(new TypeError('The "allowedMimeTypes" argument must be an array of strings.'))}function T(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:n="windowVisible",onVisible:o,onHidden:a}=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 n)throw new TypeError('"visibleClass" must be a string.');if(void 0!==o&&"function"!=typeof o)throw new TypeError('"onVisible" must be a function if provided.');if(void 0!==a&&"function"!=typeof a)throw new TypeError('"onHidden" must be a function if provided.');let i="",s="";const l=()=>{t.classList.remove(r),t.classList.remove(n)};let u=null;const m=["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 f=function(e){l();const m=e?.type,c=u&&document[u];["focus","focusin","pageshow"].includes(m)?(t.classList.add(n),o?.({type:m,oldClass:s,oldType:i}),s=n):["blur","focusout","pagehide"].includes(m)||c?(t.classList.add(r),a?.({type:m,oldClass:s,oldType:i}),s=r):(t.classList.add(n),o?.({type:m,oldClass:s,oldType:i}),s=n),i=m};let d=()=>{};if(u){const e=m[c.indexOf(u)];document.addEventListener(e,f),window.addEventListener("focus",f),window.addEventListener("blur",f),d=()=>{document.removeEventListener(e,f),window.removeEventListener("focus",f),window.removeEventListener("blur",f),l()}}else"onfocusin"in document?(document.onfocusin=document.onfocusout=f,d=()=>{document.onfocusin=document.onfocusout=null,l()}):(window.onpageshow=window.onpagehide=window.onfocus=window.onblur=f,d=()=>{window.onpageshow=window.onpagehide=window.onfocus=window.onblur=null,l()});const p=new Event(u&&document[u]?"blur":"focus");return f(p),d}e.r(t),e.d(t,{addAiMarkerShortcut:()=>G,areElsCollBottom:()=>te,areElsCollLeft:()=>re,areElsCollPerfBottom:()=>ae,areElsCollPerfLeft:()=>ie,areElsCollPerfRight:()=>se,areElsCollPerfTop:()=>oe,areElsCollRight:()=>ne,areElsCollTop:()=>ee,areElsColliding:()=>le,areElsPerfColliding:()=>ue,arraySortPositions:()=>a,asyncReplace:()=>J,breakdownDuration:()=>c,browserIs:()=>Ue,calculateMarketcap:()=>V,cloneObjTypeOrder:()=>k,compareMarketcap:()=>z,countObj:()=>f,createSingletonTask:()=>Ce,diffArrayList:()=>o,diffObjList:()=>Z,diffStrings:()=>Q,documentIsFullScreen:()=>S,exitFullScreen:()=>C,extendObjType:()=>N,extractMediaId3Tags:()=>Oe,fetchJson:()=>E,fetchText:()=>v,formatBytes:()=>H,formatCustomTimer:()=>l,formatDayTimer:()=>m,formatTimer:()=>u,genFibonacciSeq:()=>q,getAge:()=>Y,getBrowserCssPrefix:()=>Be,getBrowserPings:()=>_e,getDuckTyping:()=>$e,getElsCollDetails:()=>ge,getElsCollDirDepth:()=>we,getElsCollOverlap:()=>fe,getElsCollOverlapPos:()=>de,getElsColliding:()=>me,getElsPerfColliding:()=>ce,getElsRelativeCenterOffset:()=>ye,getPercentage:()=>U,getRectCenter:()=>pe,getSimplePerc:()=>_,getTimeDuration:()=>s,getUserTimeFormat:()=>i,installWindowHiddenScript:()=>T,isBrowserAgent:()=>Re,isFullScreenMode:()=>F,isJsonObject:()=>d,isObjType:()=>D,isScreenFilled:()=>O,isValidObj:()=>p,multiplyArrayBlocks:()=>n,objType:()=>M,objTypeName:()=>j,offFullScreenChange:()=>B,onFullScreenChange:()=>R,parseMediaMetadata:()=>Fe,readBase64Blob:()=>w,readFileBlob:()=>y,readJsonBlob:()=>g,reorderObjTypeOrder:()=>A,requestFullScreen:()=>L,ruleOfThree:()=>$,safeTextTrim:()=>K,saveJsonFile:()=>b,shuffleArray:()=>r,toTitleCase:()=>W,toTitleCaseLowerFirst:()=>X,valFetchMediaContent:()=>Me,valMediaContentMetadata:()=>Se,waitForTrue:()=>Le});const I="undefined"!=typeof window&&void 0!==window.document,x={items:{},order:[]};function N(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=[],n=Array.isArray(e)?e:Object.entries(e);for(const e of n){if(!Array.isArray(e)||e.length<2)throw new TypeError("Each item in 'newItems' array must be a [key, function] pair.");const[n,o]=e;if("string"!=typeof n)throw new TypeError("Validator key must be a string.");if("function"!=typeof o)throw new TypeError(`Validator for key '${n}' must be a function.`);if(!x.items.hasOwnProperty(n)){x.items[n]=o;let e="number"==typeof t?t:-1;if(-1===e){const t=x.order.indexOf("object");e=t>-1?t:x.order.length}e=Math.min(Math.max(0,e),x.order.length),x.order.splice(e,0,n),r.push(n)}}return r}function A(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=[...x.order];return!!e.every(e=>t.includes(e))&&(x.order=e.slice(),!0)}function k(){return[...x.order]}const j=e=>{if(null===e)return"null";for(const t of x.order)if("function"!=typeof x.items[t]||x.items[t](e))return t;return"unknown"};function D(e,t){if("string"!=typeof t)throw new TypeError("Argument 'type' must be a string.");return j(e)===t.toLowerCase()}function M(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=j(e);return"string"==typeof t?r===t.toLowerCase():r}N([["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)]]),I&&N([["file",e=>"undefined"!=typeof File&&e instanceof File]]),N([["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]]),I&&N([["htmlelement",e=>"undefined"!=typeof HTMLElement&&e instanceof HTMLElement]]),N([["object",e=>d(e)]]);const S=()=>!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitIsFullScreen||document.mozFullScreen),O=()=>window.innerHeight===screen.height&&window.innerWidth===screen.width,F=()=>S()||O(),L=e=>new Promise(async(t,r)=>{const n=document.documentElement;try{n.requestFullscreen?await n.requestFullscreen(e):n.mozRequestFullScreen?n.mozRequestFullScreen(e):n.webkitRequestFullScreen?n.webkitRequestFullScreen(e):n.msRequestFullscreen&&n.msRequestFullscreen(e),t()}catch(e){r(e)}}),C=()=>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)}}),P=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],R=(e,t)=>{P.forEach(r=>{document.addEventListener(r,e,t)})},B=(e,t)=>{P.forEach(r=>{document.removeEventListener(r,e,t)})};function $(e,t,r,n=!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 n)throw new TypeError("inverse must be a boolean.");return n?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 U(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 Y(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 n=t instanceof Date?t:new Date;let o=n.getFullYear()-r.getFullYear();const a=n.getMonth(),i=r.getMonth(),s=n.getDate(),l=r.getDate();return(a<i||a===i&&s<l)&&o--,Math.abs(o)}function H(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 n=["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(!n.includes(r))throw new RangeError(`maxUnit must be one of: ${n.join(", ")}`)}const o=r&&n.includes(r)?n.indexOf(r):n.length-1,a=Math.min(Math.floor(Math.log(e)/Math.log(1024)),o);let i=e/Math.pow(1024,a);if(null!==t){const e=t<0?0:t;i=parseFloat(i.toFixed(e))}return{unit:n[a],value:i}}function q({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 n=[...e.slice(0,2)];for(let e=2;e<t;e++){const t=r(n[e-2],n[e-1],e);n.push(t)}return n}function V(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 z(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 n=V(e,t),o="number"==typeof r?r/t:NaN;return{originalPrice:n,newPrice:o,priceChangePercent:"number"==typeof r?(o-n)/n*100:NaN}}async function J(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 n=[];e.replace(t,(e,...t)=>(n.push(r(e,...t)),e));const o=await Promise.all(n);return e.replace(t,()=>o.shift())}function W(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 X(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 G({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 K(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 n=e.trim();if(n.length>t){const e=n.lastIndexOf(" ",t);return e>0&&e>=t*r?`${n.substring(0,e).trim()}...`:`${n.substring(0,t).trim()}...`}return n}function Z(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 n in e)n in t?e[n]!==t[n]&&(r.modified[n]={old:e[n],new:t[n]}):r.removed[n]=e[n];for(const n in t)n in e||(r.added[n]=t[n]);return r}const Q=Z,ee=(e,t)=>e.bottom<t.top,te=(e,t)=>e.top>t.bottom,re=(e,t)=>e.right<t.left,ne=(e,t)=>e.left>t.right,oe=(e,t)=>e.bottom<=t.top,ae=(e,t)=>e.top>=t.bottom,ie=(e,t)=>e.right<=t.left,se=(e,t)=>e.left>=t.right,le=(e,t)=>!(re(e,t)||ne(e,t)||ee(e,t)||te(e,t)),ue=(e,t)=>!(ie(e,t)||se(e,t)||oe(e,t)||ae(e,t)),me=(e,t)=>re(e,t)?"left":ne(e,t)?"right":ee(e,t)?"top":te(e,t)?"bottom":null,ce=(e,t)=>ie(e,t)?"left":se(e,t)?"right":oe(e,t)?"top":ae(e,t)?"bottom":null,fe=(e,t)=>({overlapLeft:t.right-e.left,overlapRight:e.right-t.left,overlapTop:t.bottom-e.top,overlapBottom:e.bottom-t.top}),de=({overlapLeft:e=-1,overlapRight:t=-1,overlapTop:r=-1,overlapBottom:n=-1}={})=>({dirX:e<t?"right":"left",dirY:r<n?"bottom":"top"}),pe=e=>({x:e.left+e.width/2,y:e.top+e.height/2});function ye(e,t){const r=e.left+e.width/2,n=e.top+e.height/2;return{x:t.left+t.width/2-r,y:t.top+t.height/2-n}}function we(e,t){if(!ue(e,t))return{inDir:null,dirX:null,dirY:null,depthX:0,depthY:0};const{overlapLeft:r,overlapRight:n,overlapTop:o,overlapBottom:a}=fe(e,t),{dirX:i,dirY:s}=de({overlapLeft:r,overlapRight:n,overlapTop:o,overlapBottom:a}),l=Math.min(r,n),u=Math.min(o,a);let m;return m=l<u?i:s,{inDir:m,dirX:i,dirY:s,depthX:l,depthY:u}}function ge(e,t){const r=ue(e,t),n={in:null,x:null,y:null},o={y:null,x:null},a={top:0,bottom:0,left:0,right:0},{overlapLeft:i,overlapRight:s,overlapTop:l,overlapBottom:u}=fe(t,e);a.top=l,a.bottom=u,a.left=i,a.right=s;const m=Object.entries(a).filter(([,e])=>e>0).sort((e,t)=>e[1]-t[1]),{dirX:c,dirY:f}=de({overlapLeft:s,overlapRight:i,overlapTop:u,overlapBottom:l});return n.y=f,n.x=c,a.bottom<0?o.y="bottom":a.top<0&&(o.y="top"),a.left<0?o.x="left":a.right<0&&(o.x="right"),n.in=r?a.top===a.bottom&&a.bottom===a.left&&a.left===a.right?"center":m.length?m[0][0]:"top":null,{dirs:n,depth:a,isNeg:o}}const be=(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}.`)},he=(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}.`)},Ee=(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}.`)},ve=(e,t=!1)=>!t&&void 0===e,Te=(e,t=!1)=>ve(e,t)||"string"==typeof e||!t&&null===e,Ie=(e,t=!1)=>ve(e,t)||"number"==typeof e||!t&&null===e,xe=(e,t=!1)=>ve(e,t)||"boolean"==typeof e||!t&&null===e,Ne=(e,t)=>!!ve(e)||(he(t,"valueValidator"),Array.isArray(e)&&e.every(t)),Ae=new Map;class ke extends Error{constructor(e,t,r){if(be(e,"message"),be(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 je=async e=>{be(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)},De=(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}.`);be(t,"format");const r=e=>{const t=URL.createObjectURL(e),r=Ae.get(t);return Ae.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 n=e.split(",")[1],o=atob(n),a=new Uint8Array(o.length);for(let e=0;e<o.length;e++)a[e]=o.charCodeAt(e);return r(new Blob([a],{type:t}))}return"string"==typeof e?e:""},Me=(e,t=!1)=>{if(d(e)){if(4!==f(e)){if(t)return!1;throw new TypeError("Invalid fetch data: Object must be an MediaContentFetchData.")}Se(e.common),Ee(e.native,"_fetchData.native"),Ee(e.format,"_fetchData.format"),Ee(e.quality,"_fetchData.quality");for(const r in e.native){const n=e.native[r];if(!Ne(n,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},Se=e=>{if(Ee(e,"common"),Me(e._fetchData),!Te(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!Te(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!Te(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a a string or null.');if(!Te(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(!xe(e.compilation))throw new TypeError('Invalid metadata: "compilation" must be a boolean or null.');if(!xe(e.podcast))throw new TypeError('Invalid metadata: "podcast" must be a boolean or null.');if(!xe(e.gapless))throw new TypeError('Invalid metadata: "gapless" must be a boolean or null.');if(!xe(e.showMovement))throw new TypeError('Invalid metadata: "showMovement" must be a boolean or null.');if(!Ie(e.averageLevel))throw new TypeError('Invalid metadata: "averageLevel" must be a number or null.');if(!Ie(e.peakLevel))throw new TypeError('Invalid metadata: "peakLevel" must be a number or null.');if(!Ie(e.hdVideo))throw new TypeError('Invalid metadata: "hdVideo" must be a number or null.');if(!Ie(e.stik))throw new TypeError('Invalid metadata: "stik" must be a number or null.');if(!Ie(e.playCounter))throw new TypeError('Invalid metadata: "playCounter" must be a number or null.');if(!Ie(e.tvSeason))throw new TypeError('Invalid metadata: "tvSeason" must be a number or null.');if(!Ie(e.tvEpisode))throw new TypeError('Invalid metadata: "tvEpisode" must be a number or null.');if(!Ie(e.year))throw new TypeError('Invalid metadata: "year" must be a number or null.');if(!Ie(e.bpm))throw new TypeError('Invalid metadata: "bpm" must be a number or null.');if(!Ie(e.originalyear))throw new TypeError('Invalid metadata: "originalyear" must be a number or null.');if(!Ie(e.movementTotal))throw new TypeError('Invalid metadata: "movementTotal" must be a number or null.');if(!Te(e.date))throw new TypeError('Invalid metadata: "date" must be a string or null.');if(!Te(e.originaldate))throw new TypeError('Invalid metadata: "originaldate" must be a string or null.');if(!Te(e.releasedate))throw new TypeError('Invalid metadata: "releasedate" must be a string or null.');if(!Te(e.albumsort))throw new TypeError('Invalid metadata: "albumsort" must be a string or null.');if(!Te(e.titlesort))throw new TypeError('Invalid metadata: "titlesort" must be a string or null.');if(!Te(e.work))throw new TypeError('Invalid metadata: "work" must be a string or null.');if(!Te(e.artistsort))throw new TypeError('Invalid metadata: "artistsort" must be a string or null.');if(!Te(e.albumartistsort))throw new TypeError('Invalid metadata: "albumartistsort" must be a string or null.');if(!Te(e.composersort))throw new TypeError('Invalid metadata: "composersort" must be a string or null.');if(!Te(e.grouping))throw new TypeError('Invalid metadata: "grouping" must be a string or null.');if(!Te(e.longDescription))throw new TypeError('Invalid metadata: "longDescription" must be a string or null.');if(!Te(e.totaltracks))throw new TypeError('Invalid metadata: "totaltracks" must be a string or null.');if(!Te(e.totaldiscs))throw new TypeError('Invalid metadata: "totaldiscs" must be a string or null.');if(!Te(e.mood))throw new TypeError('Invalid metadata: "mood" must be a string or null.');if(!Te(e.media))throw new TypeError('Invalid metadata: "media" must be a string or null.');if(!Te(e.tvShow))throw new TypeError('Invalid metadata: "tvShow" must be a string or null.');if(!Te(e.tvShowSort))throw new TypeError('Invalid metadata: "tvShowSort" must be a string or null.');if(!Te(e.tvEpisodeId))throw new TypeError('Invalid metadata: "tvEpisodeId" must be a string or null.');if(!Te(e.tvNetwork))throw new TypeError('Invalid metadata: "tvNetwork" must be a string or null.');if(!Te(e.podcasturl))throw new TypeError('Invalid metadata: "podcasturl" must be a string or null.');if(!Te(e.releasestatus))throw new TypeError('Invalid metadata: "releasestatus" must be a string or null.');if(!Te(e.releasecountry))throw new TypeError('Invalid metadata: "releasecountry" must be a string or null.');if(!Te(e.script))throw new TypeError('Invalid metadata: "script" must be a string or null.');if(!Te(e.language))throw new TypeError('Invalid metadata: "language" must be a string or null.');if(!Te(e.copyright))throw new TypeError('Invalid metadata: "copyright" must be a string or null.');if(!Te(e.license))throw new TypeError('Invalid metadata: "license" must be a string or null.');if(!Te(e.encodedby))throw new TypeError('Invalid metadata: "encodedby" must be a string or null.');if(!Te(e.encodersettings))throw new TypeError('Invalid metadata: "encodersettings" must be a string or null.');if(!Te(e.barcode))throw new TypeError('Invalid metadata: "barcode" must be a string or null.');if(!Te(e.asin))throw new TypeError('Invalid metadata: "asin" must be a string or null.');if(!Te(e.website))throw new TypeError('Invalid metadata: "website" must be a string or null.');if(!Te(e.originalalbum))throw new TypeError('Invalid metadata: "originalalbum" must be a string or null.');if(!Te(e.originalartist))throw new TypeError('Invalid metadata: "originalartist" must be a string or null.');if(!Te(e.key))throw new TypeError('Invalid metadata: "key" must be a string or null.');if(!Te(e.movement))throw new TypeError('Invalid metadata: "movement" must be a string or null.');if(!Te(e.podcastId))throw new TypeError('Invalid metadata: "podcastId" must be a string or null.');if(!Ne(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of strings.');if(!Ne(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of strings.');if(!Ne(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of strings.');if(!Ne(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of strings.');if(!Ne(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of strings.');if(!Ne(e.lyricist,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "lyricist" must be an array of strings.');if(!Ne(e.writer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "writer" must be an array of strings.');if(!Ne(e.conductor,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "conductor" must be an array of strings.');if(!Ne(e.remixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "remixer" must be an array of strings.');if(!Ne(e.arranger,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "arranger" must be an array of strings.');if(!Ne(e.engineer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "engineer" must be an array of strings.');if(!Ne(e.publisher,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "publisher" must be an array of strings.');if(!Ne(e.producer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "producer" must be an array of strings.');if(!Ne(e.djmixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "djmixer" must be an array of strings.');if(!Ne(e.mixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "mixer" must be an array of strings.');if(!Ne(e.technician,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "technician" must be an array of strings.');if(!Ne(e.subtitle,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "subtitle" must be an array of strings.');if(!Ne(e.description,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "description" must be an array of strings.');if(!Ne(e.discsubtitle,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "discsubtitle" must be an array of strings.');if(!Ne(e.releasetype,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "releasetype" must be an array of strings.');if(!Ne(e.isrc,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "isrc" must be an array of strings.');if(!Ne(e.performer_instrument,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "performer_instrument" must be an array of strings.');if(!Ne(e.notes,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "notes" must be an array of strings.');if(!Ne(e.category,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "category" must be an array of strings.');if(!Ne(e.keywords,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "keywords" must be an array of strings.');if(!Ne(e.catalognumber,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "catalognumber" must be an array of strings.');if(!Ne(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(!Ne(e.comment,e=>null!==e&&"object"==typeof e&&Te(e.descriptor)&&Te(e.language)&&Te(e.text)))throw new TypeError('Invalid metadata: "comment" must be an array of valid IComment objects.');if(!Ne(e.lyrics,e=>null!==e&&"object"==typeof e&&Te(e.text)&&Ne(e.syncText,e=>null!==e&&"object"==typeof e&&Te(e.text,!0)&&Ie(e.timestamp))&&(e=>null!==e&&"object"==typeof e&&Ie(e.notSynchronized,!0)&&Ie(e.mpegFrameNumber,!0)&&Ie(e.milliseconds,!0))(e.timeStampFormat)&&(e=>null!==e&&"object"==typeof e&&Ie(e.other,!0)&&Ie(e.lyrics,!0)&&Ie(e.text,!0)&&Ie(e.movement_part,!0)&&Ie(e.events,!0)&&Ie(e.chord,!0)&&Ie(e.trivia_pop,!0))(e.contentType)))throw new TypeError('Invalid metadata: "lyrics" must be an array of valid ILyricsTag objects.');if(!Ne(e.rating,e=>null!==e&&"object"==typeof e&&Te(e.source)&&Ie(e.rating)))throw new TypeError('Invalid metadata: "rating" must be an array of valid IRating objects.');const t=(e,t)=>{if(!ve(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)},Oe=async(e,t,r=!0)=>{be(e,"url"),he(t,"parseFile");try{const n=await fetch(e);if(!n.ok)throw new Error(`Failed to fetch audio file: ${n.status} ${n.statusText}`);const o=await n.blob(),a=await t(o);if(!a||"object"!=typeof a.common)throw new TypeError('Invalid metadata: "common" property is missing.');void 0!==typeof a.common["performer:instrument"]&&(a.common.performer_instrument=a.common["performer:instrument"]),Me(a);const i=a.common;Se(i);const s=([e,t])=>Array.isArray(t)?t.length>0:d(t)?f(Object.fromEntries(Object.entries(t).filter(s)))>0:null!==t,l=i?.picture?.map(e=>({...e,data:r?De(e.data,e.format):e.data}))??[];a.common={...a.common,picture:l.map(e=>({...e,data:""}))},r&&Object.keys(a.native).forEach(e=>{a.native[e]=a.native[e].map(e=>{if(e.value&&"object"==typeof e.value&&e.value.data instanceof Uint8Array){const t=i?.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:i?.title??null,album:i?.album??null,albumartist:i?.albumartist??null,albumartists:i?.albumartists??[],genre:i?.genre??[],label:i?.label??[],composer:i?.composer??[],year:i?.year??null,artist:i?.artist??null,artists:i?.artists??[],disk:i?.disk?{no:i.disk.no,of:i.disk.of}:null,track:i?.track?{no:i.track.no,of:i.track.of}:null,movementIndex:i?.movementIndex?{no:i.movementIndex.no,of:i.movementIndex.of}:null,picture:l,date:i?.date??null,originaldate:i?.originaldate??null,originalyear:i?.originalyear??null,releasedate:i?.releasedate??null,comment:i?.comment??[],lyrics:i?.lyrics??[],albumsort:i?.albumsort??null,titlesort:i?.titlesort??null,work:i?.work??null,artistsort:i?.artistsort??null,albumartistsort:i?.albumartistsort??null,composersort:i?.composersort??null,lyricist:i?.lyricist??[],writer:i?.writer??[],conductor:i?.conductor??[],remixer:i?.remixer??[],arranger:i?.arranger??[],engineer:i?.engineer??[],publisher:i?.publisher??[],producer:i?.producer??[],djmixer:i?.djmixer??[],mixer:i?.mixer??[],technician:i?.technician??[],grouping:i?.grouping??null,subtitle:i?.subtitle??[],description:i?.description??[],longDescription:i?.longDescription??null,discsubtitle:i?.discsubtitle??[],totaltracks:i?.totaltracks??null,totaldiscs:i?.totaldiscs??null,movementTotal:i?.movementTotal??null,compilation:i?.compilation??null,rating:i?.rating??[],bpm:i?.bpm??null,mood:i?.mood??null,media:i?.media??null,catalognumber:i?.catalognumber??[],tvShow:i?.tvShow??null,tvShowSort:i?.tvShowSort??null,tvSeason:i?.tvSeason??null,tvEpisode:i?.tvEpisode??null,tvEpisodeId:i?.tvEpisodeId??null,tvNetwork:i?.tvNetwork??null,podcast:i?.podcast??null,podcasturl:i?.podcasturl??null,releasestatus:i?.releasestatus??null,releasetype:i?.releasetype??[],releasecountry:i?.releasecountry??null,script:i?.script??null,language:i?.language??null,copyright:i?.copyright??null,license:i?.license??null,encodedby:i?.encodedby??null,encodersettings:i?.encodersettings??null,gapless:i?.gapless??null,barcode:i?.barcode??null,isrc:i?.isrc??[],asin:i?.asin??null,website:i?.website??null,performer_instrument:i?.performer_instrument??[],averageLevel:i?.averageLevel??null,peakLevel:i?.peakLevel??null,notes:i?.notes??[],originalalbum:i?.originalalbum??null,originalartist:i?.originalartist??null,key:i?.key??null,category:i?.category??[],hdVideo:i?.hdVideo??null,keywords:i?.keywords??[],movement:i?.movement??null,podcastId:i?.podcastId??null,showMovement:i?.showMovement??null,stik:i?.stik??null,playCounter:i?.playCounter??null}).filter(s));return u._fetchData=a,u}catch(e){throw e}},Fe=async(e,t={},r={},n=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.")))},o={},a=!0,i="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(Ee(t,"defaultMetadata"),Ee(r,"metadata"),he(n,"parseFile"),Ee(o,"callbacks"),o.onProgress&&"function"!=typeof o.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(o.onError&&"function"!=typeof o.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof i&&"function"!=typeof i)throw new TypeError("unknownArtist must be a string or a function returning a string.");let s,l="";const u=(t,r)=>{if(be(t,"stage"),void 0!==r&&!(r instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');o.onProgress&&o.onProgress({event:r,status:"loading",stage:t,url:l||(e instanceof HTMLMediaElement?e.src:"unknown")})},m=(t,r)=>{if(!(t instanceof Error))throw new TypeError('Expected "error" to be an Error.');be(r,"stage"),o.onError&&o.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,s=new Audio(l)):(s=e,l=s.src);try{await new Promise((e,t)=>{const r=e=>u("DOWNLOADING",e),n=()=>{a(),e(void 0)},o=e=>{a(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},a=()=>{s.removeEventListener("progress",r),s.removeEventListener("loadedmetadata",n),s.removeEventListener("error",o)};s.addEventListener("progress",r),s.addEventListener("loadedmetadata",n),s.addEventListener("error",o),s.readyState>=1&&(a(),e(void 0))}),u("METADATA_LOADED")}catch(e){throw new ke(e instanceof Error?e.message:"UNKNOWN ERROR",l,"METADATA")}const c={id:r.id||await je(l),duration:Math.floor(1e3*s.duration),url:l,weight:r.weight??1};let f={};u("EXTRACTING_ID3");try{f=await Oe(l,n,a)}catch(e){m(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${l}. Falling back to filename.`)}const p=e=>{be(e,"url");try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},y=e=>{const t={...e};return d(t._fetchData)&&(d(f._fetchData)&&(t._fetchData={...f._fetchData}),d(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},w={...c,...y(t),...f,...y(r),title:f.title||r.title||p(l),artist:f.artist||r.artist||("string"==typeof i?i:String(i()))};return o.onProgress&&o.onProgress({status:"success",stage:"COMPLETE",url:l}),w}catch(e){if(e instanceof ke)throw e;const t=new ke(e instanceof Error?e.message:"UNKNOWN ERROR",l,"INITIALIZING");throw m(t,"INITIALIZING"),t}},Le=(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 n=setInterval(()=>{e()&&(clearInterval(n),r())},t)})},Ce=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 n=await e(...r);return t=null,n}catch(e){throw t=null,e}})()),t),getActivePromise:()=>t,resetActivePromise:()=>{t=null}}},Pe=["chrome","firefox","ie","edge","safari","opera","yandex","other"];function Re(){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 Be(){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 $e(){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(),n=!!document.documentMode,o=!n&&!!window.StyleMedia,a=!!window.chrome;return{isOpera:e,isFirefox:t,isSafari:r,isIE:n,isEdge:o,isChrome:a,isBlink:(a||e)&&!!window.CSS}}function _e(e=[]){if(!Array.isArray(e))throw new TypeError('The "disable" argument must be an array.');for(const t of e)if(!Pe.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[Re()]++;const r=Be();"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 n=$e();return n.isOpera&&e.indexOf("opera")<0&&t.opera++,n.isFirefox&&e.indexOf("firefox")<0&&t.firefox++,n.isSafari&&e.indexOf("safari")<0&&t.safari++,n.isIE&&e.indexOf("ie")<0&&t.ie++,n.isEdge&&e.indexOf("edge")<0&&t.edge++,n.isChrome&&e.indexOf("chrome")<0&&t.chrome++,t}function Ue(e=[]){const t=_e(e);return Object.keys(t).reduce((e,r)=>t[r]>t[e]?r:e)}window.TinyBasicsEs=t})();
|
|
1
|
+
(()=>{"use strict";const e={d:(t,r)=>{if(Array.isArray(r))for(var n=0;n<r.length;){var o=r[n++],a=r[n++];e.o(t,o)?0===a&&n++:0===a?Object.defineProperty(t,o,{enumerable:!0,value:r[n++]}):Object.defineProperty(t,o,{enumerable:!0,get:a})}else for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}};let t={};function r(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 n(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 n=0;n<e.length;n++){if("number"!=typeof t[n]||Number.isNaN(t[n]))throw new TypeError(`Element at counts[${n}] must be a valid number.`);for(let o=0;o<t[n];o++)r.push(e[n])}return r}function o(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 a(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 i(){const e=new Intl.DateTimeFormat(void 0,{hour:"numeric"}).resolvedOptions().hourCycle;return e?.startsWith("h12")?12:24}function s(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 n=["asMilliseconds","asSeconds","asMinutes","asHours","asDays"];if(!n.includes(t))throw new RangeError(`The 'durationType' must be one of: ${n.join(", ")}.`);if(null!==r&&!(r instanceof Date))throw new TypeError("The 'now' argument must be an instance of Date or null.");const o=r instanceof Date?r:new Date,a=e.getTime()-o.getTime();switch(t){case"asMilliseconds":return a;case"asSeconds":default:return a/1e3;case"asMinutes":return a/6e4;case"asHours":return a/36e5;case"asDays":return a/864e5}}function l(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 n=["seconds","minutes","hours","days","months","years"];if(!n.includes(t))throw new RangeError(`The 'level' must be one of: ${n.join(", ")}.`);if("string"!=typeof r)throw new TypeError("The 'format' argument must be a string.");e=Math.max(0,Math.floor(e));const o=n.indexOf(t),a=o>=5,i=o>=4,s=o>=3,l=o>=2,u=o>=1,m=o>=0,f={years:a?0:NaN,months:i?0:NaN,days:s?0:NaN,hours:l?0:NaN,minutes:u?0:NaN,seconds:m?0:NaN,total:NaN};let c=e;if(a||i||s){const e=new Date(1980,0,1),t=new Date(e.getTime()+1e3*c),r=new Date(e);if(a)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),f.years++;if(i)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),f.months++;if(s)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),f.days++;c=Math.floor((t.getTime()-r.getTime())/1e3)}l&&(f.hours=Math.floor(c/3600),c%=3600),u&&(f.minutes=Math.floor(c/60),c%=60),m&&(f.seconds=c),f.total=+e.toFixed(2).replace(/\.00$/,"");const d=e=>{const t="string"==typeof e?parseInt(e):e;return Number.isNaN(t)?"NaN":String(t).padStart(2,"0")},p=[l?d(f.hours):null,u?d(f.minutes):null,m?d(f.seconds):null].filter(e=>null!==e).join(":");return r.replace(/\{years\}/g,String(f.years)).replace(/\{months\}/g,String(f.months)).replace(/\{days\}/g,String(f.days)).replace(/\{hours\}/g,d(f.hours)).replace(/\{minutes\}/g,d(f.minutes)).replace(/\{seconds\}/g,d(f.seconds)).replace(/\{time\}/g,p).replace(/\{total\}/g,String(f.total)).trim()}function u(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'seconds' argument must be a valid number.");return l(e,"hours","{hours}:{minutes}:{seconds}")}function m(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'seconds' argument must be a valid number.");return l(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 n=r.indexOf(t),o=n>=6,a=n>=5,i=n>=4,s=n>=3,l=n>=2,u=n>=1,m=n>=0,f={years:o?0:NaN,months:a?0:NaN,days:i?0:NaN,hours:s?0:NaN,minutes:l?0:NaN,seconds:u?0:NaN,milliseconds:m?0:NaN,total:NaN};let c=e;if(o||a||i){const e=new Date(1980,0,1),t=new Date(e.getTime()+c),r=new Date(e);if(o)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),f.years++;if(a)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),f.months++;if(i)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),f.days++;c=t.getTime()-r.getTime()}return s&&(f.hours=Math.floor(c/36e5),c%=36e5),l&&(f.minutes=Math.floor(c/6e4),c%=6e4),u&&(f.seconds=Math.floor(c/1e3),c%=1e3),m&&(f.milliseconds=c),f.total=+e,f}function c(e){if(!Array.isArray(e)&&!d(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 d(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}function p(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function y(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,n)=>{const o=new FileReader;o.onload=()=>{try{r(o.result)}catch(e){n(e)}},o.onerror=()=>{n(o.error)},o[t](e)}):Promise.reject(new TypeError(`The "method" argument must be one of: ${r.join(", ")}.`))}function w(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,n)=>{y(e,"readAsDataURL").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const n=e.match(/^data:(.+);base64,(.*)$/);if(!n||!n[2])throw new Error("Invalid data URL format or missing Base64 content.");const[,o,a]=n;if(!/^[\w/+]+=*$/.test(a))throw new Error("Base64 content is malformed.");if("boolean"==typeof t)return r(t?e:a);if(!/^[\w-]+\/[\w.+-]+$/.test(t))throw new Error(`Invalid MIME type string: ${t}`);return r(`data:${t};base64,${a}`)}).catch(n)}):Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'))}function g(e){return e instanceof Blob?new Promise((t,r)=>y(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 n=JSON.parse(r);if("object"!=typeof n||null===n)throw new Error("Parsed content is not a valid JSON object or array.");t(n)}).catch(r)):Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'))}function b(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 n=JSON.stringify(t,null,r),o=new Blob([n],{type:"application/json"}),a=URL.createObjectURL(o),i=document.createElement("a");i.href=a,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(a)}function h(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 n=e.headers.get("content-length"),o=n?parseInt(n,10):0;let a=0;const i=e.body.getReader(),s=new ReadableStream({async start(e){for(;;){const{done:r,value:n}=await i.read();if(r)break;a+=n.byteLength,t(a,o),e.enqueue(n)}e.close()}});return new Response(s,r(e))}async function E(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((n,o)=>{fetch(e,t??void 0).then(async e=>{const t=r?h(e,r):e,o=t.headers.get("content-type")||"";if(!o.includes("application/json"))throw new Error(`Unexpected content-type: ${o}`);const a=await t.json();if(!Array.isArray(a)&&!d(a))throw new Error("Received invalid data instead of valid JSON.");return n(a)}).catch(o)})}async function v(e,t,r,n){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!==n&&"function"!=typeof n?Promise.reject(new TypeError('The "onProgress" option must be a function.')):new Promise((o,a)=>{fetch(e,r??void 0).then(async e=>{const r=n?h(e,n):e,a=r.headers.get("content-type")||"";if(Array.isArray(t)&&t.length>0&&!t.some(e=>a.includes(e)))throw new Error(`Blocked MIME type: ${a}`);const i=await r.text();return o(i)}).catch(a)}):Promise.reject(new TypeError('The "allowedMimeTypes" argument must be an array of strings.'))}function T(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:n="windowVisible",onVisible:o,onHidden:a}=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 n)throw new TypeError('"visibleClass" must be a string.');if(void 0!==o&&"function"!=typeof o)throw new TypeError('"onVisible" must be a function if provided.');if(void 0!==a&&"function"!=typeof a)throw new TypeError('"onHidden" must be a function if provided.');let i="",s="";const l=()=>{t.classList.remove(r),t.classList.remove(n)};let u=null;const m=["visibilitychange","mozvisibilitychange","webkitvisibilitychange","msvisibilitychange"],f=["hidden","mozHidden","webkitHidden","msHidden"];for(let e=0;e<f.length;e++)if(f[e]in document){u=f[e];break}const c=function(e){l();const m=e?.type,f=u&&document[u];["focus","focusin","pageshow"].includes(m)?(t.classList.add(n),o?.({type:m,oldClass:s,oldType:i}),s=n):["blur","focusout","pagehide"].includes(m)||f?(t.classList.add(r),a?.({type:m,oldClass:s,oldType:i}),s=r):(t.classList.add(n),o?.({type:m,oldClass:s,oldType:i}),s=n),i=m};let d=()=>{};if(u){const e=m[f.indexOf(u)];document.addEventListener(e,c),window.addEventListener("focus",c),window.addEventListener("blur",c),d=()=>{document.removeEventListener(e,c),window.removeEventListener("focus",c),window.removeEventListener("blur",c),l()}}else"onfocusin"in document?(document.onfocusin=document.onfocusout=c,d=()=>{document.onfocusin=document.onfocusout=null,l()}):(window.onpageshow=window.onpagehide=window.onfocus=window.onblur=c,d=()=>{window.onpageshow=window.onpagehide=window.onfocus=window.onblur=null,l()});const p=new Event(u&&document[u]?"blur":"focus");return c(p),d}e.r(t),e.d(t,{addAiMarkerShortcut:()=>G,areElsCollBottom:()=>te,areElsCollLeft:()=>re,areElsCollPerfBottom:()=>ae,areElsCollPerfLeft:()=>ie,areElsCollPerfRight:()=>se,areElsCollPerfTop:()=>oe,areElsCollRight:()=>ne,areElsCollTop:()=>ee,areElsColliding:()=>le,areElsPerfColliding:()=>ue,arraySortPositions:()=>a,asyncReplace:()=>J,breakdownDuration:()=>f,browserIs:()=>Ue,calculateMarketcap:()=>V,cloneObjTypeOrder:()=>k,compareMarketcap:()=>z,countObj:()=>c,createSingletonTask:()=>Ce,diffArrayList:()=>o,diffObjList:()=>Z,diffStrings:()=>Q,documentIsFullScreen:()=>S,exitFullScreen:()=>C,extendObjType:()=>N,extractMediaId3Tags:()=>Oe,fetchJson:()=>E,fetchText:()=>v,formatBytes:()=>H,formatCustomTimer:()=>l,formatDayTimer:()=>m,formatTimer:()=>u,genFibonacciSeq:()=>q,getAge:()=>Y,getBrowserCssPrefix:()=>Be,getBrowserPings:()=>_e,getDuckTyping:()=>$e,getElsCollDetails:()=>ge,getElsCollDirDepth:()=>we,getElsCollOverlap:()=>ce,getElsCollOverlapPos:()=>de,getElsColliding:()=>me,getElsPerfColliding:()=>fe,getElsRelativeCenterOffset:()=>ye,getPercentage:()=>U,getRectCenter:()=>pe,getSimplePerc:()=>_,getTimeDuration:()=>s,getUserTimeFormat:()=>i,installWindowHiddenScript:()=>T,isBrowserAgent:()=>Re,isFullScreenMode:()=>F,isJsonObject:()=>d,isObjType:()=>D,isScreenFilled:()=>O,isValidObj:()=>p,multiplyArrayBlocks:()=>n,objType:()=>M,objTypeName:()=>j,offFullScreenChange:()=>B,onFullScreenChange:()=>R,parseMediaMetadata:()=>Fe,readBase64Blob:()=>w,readFileBlob:()=>y,readJsonBlob:()=>g,reorderObjTypeOrder:()=>A,requestFullScreen:()=>L,ruleOfThree:()=>$,safeTextTrim:()=>K,saveJsonFile:()=>b,shuffleArray:()=>r,toTitleCase:()=>W,toTitleCaseLowerFirst:()=>X,valFetchMediaContent:()=>Me,valMediaContentMetadata:()=>Se,waitForTrue:()=>Le});const I="undefined"!=typeof window&&void 0!==window.document,x={items:{},order:[]};function N(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=[],n=Array.isArray(e)?e:Object.entries(e);for(const e of n){if(!Array.isArray(e)||e.length<2)throw new TypeError("Each item in 'newItems' array must be a [key, function] pair.");const[n,o]=e;if("string"!=typeof n)throw new TypeError("Validator key must be a string.");if("function"!=typeof o)throw new TypeError(`Validator for key '${n}' must be a function.`);if(!x.items.hasOwnProperty(n)){x.items[n]=o;let e="number"==typeof t?t:-1;if(-1===e){const t=x.order.indexOf("object");e=t>-1?t:x.order.length}e=Math.min(Math.max(0,e),x.order.length),x.order.splice(e,0,n),r.push(n)}}return r}function A(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=[...x.order];return!!e.every(e=>t.includes(e))&&(x.order=e.slice(),!0)}function k(){return[...x.order]}const j=e=>{if(null===e)return"null";for(const t of x.order)if("function"!=typeof x.items[t]||x.items[t](e))return t;return"unknown"};function D(e,t){if("string"!=typeof t)throw new TypeError("Argument 'type' must be a string.");return j(e)===t.toLowerCase()}function M(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=j(e);return"string"==typeof t?r===t.toLowerCase():r}N([["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)]]),I&&N([["file",e=>"undefined"!=typeof File&&e instanceof File]]),N([["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]]),I&&N([["htmlelement",e=>"undefined"!=typeof HTMLElement&&e instanceof HTMLElement]]),N([["object",e=>d(e)]]);const S=()=>!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitIsFullScreen||document.mozFullScreen),O=()=>window.innerHeight===screen.height&&window.innerWidth===screen.width,F=()=>S()||O(),L=e=>new Promise(async(t,r)=>{const n=document.documentElement;try{n.requestFullscreen?await n.requestFullscreen(e):n.mozRequestFullScreen?n.mozRequestFullScreen(e):n.webkitRequestFullScreen?n.webkitRequestFullScreen(e):n.msRequestFullscreen&&n.msRequestFullscreen(e),t()}catch(e){r(e)}}),C=()=>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)}}),P=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],R=(e,t)=>{P.forEach(r=>{document.addEventListener(r,e,t)})},B=(e,t)=>{P.forEach(r=>{document.removeEventListener(r,e,t)})};function $(e,t,r,n=!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 n)throw new TypeError("inverse must be a boolean.");return n?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 U(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 Y(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 n=t instanceof Date?t:new Date;let o=n.getFullYear()-r.getFullYear();const a=n.getMonth(),i=r.getMonth(),s=n.getDate(),l=r.getDate();return(a<i||a===i&&s<l)&&o--,Math.abs(o)}function H(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 n=["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(!n.includes(r))throw new RangeError(`maxUnit must be one of: ${n.join(", ")}`)}const o=r&&n.includes(r)?n.indexOf(r):n.length-1,a=Math.min(Math.floor(Math.log(e)/Math.log(1024)),o);let i=e/Math.pow(1024,a);if(null!==t){const e=t<0?0:t;i=parseFloat(i.toFixed(e))}return{unit:n[a],value:i}}function q({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 n=[...e.slice(0,2)];for(let e=2;e<t;e++){const t=r(n[e-2],n[e-1],e);n.push(t)}return n}function V(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 z(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 n=V(e,t),o="number"==typeof r?r/t:NaN;return{originalPrice:n,newPrice:o,priceChangePercent:"number"==typeof r?(o-n)/n*100:NaN}}async function J(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 n=[];e.replace(t,(e,...t)=>(n.push(r(e,...t)),e));const o=await Promise.all(n);return e.replace(t,()=>o.shift())}function W(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 X(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 G({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 K(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 n=e.trim();if(n.length>t){const e=n.lastIndexOf(" ",t);return e>0&&e>=t*r?`${n.substring(0,e).trim()}...`:`${n.substring(0,t).trim()}...`}return n}function Z(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 n in e)n in t?e[n]!==t[n]&&(r.modified[n]={old:e[n],new:t[n]}):r.removed[n]=e[n];for(const n in t)n in e||(r.added[n]=t[n]);return r}const Q=Z,ee=(e,t)=>e.bottom<t.top,te=(e,t)=>e.top>t.bottom,re=(e,t)=>e.right<t.left,ne=(e,t)=>e.left>t.right,oe=(e,t)=>e.bottom<=t.top,ae=(e,t)=>e.top>=t.bottom,ie=(e,t)=>e.right<=t.left,se=(e,t)=>e.left>=t.right,le=(e,t)=>!(re(e,t)||ne(e,t)||ee(e,t)||te(e,t)),ue=(e,t)=>!(ie(e,t)||se(e,t)||oe(e,t)||ae(e,t)),me=(e,t)=>re(e,t)?"left":ne(e,t)?"right":ee(e,t)?"top":te(e,t)?"bottom":null,fe=(e,t)=>ie(e,t)?"left":se(e,t)?"right":oe(e,t)?"top":ae(e,t)?"bottom":null,ce=(e,t)=>({overlapLeft:t.right-e.left,overlapRight:e.right-t.left,overlapTop:t.bottom-e.top,overlapBottom:e.bottom-t.top}),de=({overlapLeft:e=-1,overlapRight:t=-1,overlapTop:r=-1,overlapBottom:n=-1}={})=>({dirX:e<t?"right":"left",dirY:r<n?"bottom":"top"}),pe=e=>({x:e.left+e.width/2,y:e.top+e.height/2});function ye(e,t){const r=e.left+e.width/2,n=e.top+e.height/2;return{x:t.left+t.width/2-r,y:t.top+t.height/2-n}}function we(e,t){if(!ue(e,t))return{inDir:null,dirX:null,dirY:null,depthX:0,depthY:0};const{overlapLeft:r,overlapRight:n,overlapTop:o,overlapBottom:a}=ce(e,t),{dirX:i,dirY:s}=de({overlapLeft:r,overlapRight:n,overlapTop:o,overlapBottom:a}),l=Math.min(r,n),u=Math.min(o,a);let m;return m=l<u?i:s,{inDir:m,dirX:i,dirY:s,depthX:l,depthY:u}}function ge(e,t){const r=ue(e,t),n={in:null,x:null,y:null},o={y:null,x:null},a={top:0,bottom:0,left:0,right:0},{overlapLeft:i,overlapRight:s,overlapTop:l,overlapBottom:u}=ce(t,e);a.top=l,a.bottom=u,a.left=i,a.right=s;const m=Object.entries(a).filter(([,e])=>e>0).sort((e,t)=>e[1]-t[1]),{dirX:f,dirY:c}=de({overlapLeft:s,overlapRight:i,overlapTop:u,overlapBottom:l});return n.y=c,n.x=f,a.bottom<0?o.y="bottom":a.top<0&&(o.y="top"),a.left<0?o.x="left":a.right<0&&(o.x="right"),n.in=r?a.top===a.bottom&&a.bottom===a.left&&a.left===a.right?"center":m.length?m[0][0]:"top":null,{dirs:n,depth:a,isNeg:o}}const be=(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}.`)},he=(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}.`)},Ee=(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}.`)},ve=(e,t=!1)=>!t&&void 0===e,Te=(e,t=!1)=>ve(e,t)||"string"==typeof e||!t&&null===e,Ie=(e,t=!1)=>ve(e,t)||"number"==typeof e||!t&&null===e,xe=(e,t=!1)=>ve(e,t)||"boolean"==typeof e||!t&&null===e,Ne=(e,t)=>!!ve(e)||(he(t,"valueValidator"),Array.isArray(e)&&e.every(t)),Ae=new Map;class ke extends Error{constructor(e,t,r){if(be(e,"message"),be(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 je=async e=>{be(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)},De=(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}.`);be(t,"format");const r=e=>{const t=URL.createObjectURL(e),r=Ae.get(t);return Ae.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 n=e.split(",")[1],o=atob(n),a=new Uint8Array(o.length);for(let e=0;e<o.length;e++)a[e]=o.charCodeAt(e);return r(new Blob([a],{type:t}))}return"string"==typeof e?e:""},Me=(e,t=!1)=>{if(d(e)){if(4!==c(e)){if(t)return!1;throw new TypeError("Invalid fetch data: Object must be an MediaContentFetchData.")}Se(e.common),Ee(e.native,"_fetchData.native"),Ee(e.format,"_fetchData.format"),Ee(e.quality,"_fetchData.quality");for(const r in e.native){const n=e.native[r];if(!Ne(n,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},Se=e=>{if(Ee(e,"common"),Me(e._fetchData),!Te(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!Te(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!Te(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a a string or null.');if(!Te(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(!xe(e.compilation))throw new TypeError('Invalid metadata: "compilation" must be a boolean or null.');if(!xe(e.podcast))throw new TypeError('Invalid metadata: "podcast" must be a boolean or null.');if(!xe(e.gapless))throw new TypeError('Invalid metadata: "gapless" must be a boolean or null.');if(!xe(e.showMovement))throw new TypeError('Invalid metadata: "showMovement" must be a boolean or null.');if(!Ie(e.averageLevel))throw new TypeError('Invalid metadata: "averageLevel" must be a number or null.');if(!Ie(e.peakLevel))throw new TypeError('Invalid metadata: "peakLevel" must be a number or null.');if(!Ie(e.hdVideo))throw new TypeError('Invalid metadata: "hdVideo" must be a number or null.');if(!Ie(e.stik))throw new TypeError('Invalid metadata: "stik" must be a number or null.');if(!Ie(e.playCounter))throw new TypeError('Invalid metadata: "playCounter" must be a number or null.');if(!Ie(e.tvSeason))throw new TypeError('Invalid metadata: "tvSeason" must be a number or null.');if(!Ie(e.tvEpisode))throw new TypeError('Invalid metadata: "tvEpisode" must be a number or null.');if(!Ie(e.year))throw new TypeError('Invalid metadata: "year" must be a number or null.');if(!Ie(e.bpm))throw new TypeError('Invalid metadata: "bpm" must be a number or null.');if(!Ie(e.originalyear))throw new TypeError('Invalid metadata: "originalyear" must be a number or null.');if(!Ie(e.movementTotal))throw new TypeError('Invalid metadata: "movementTotal" must be a number or null.');if(!Te(e.date))throw new TypeError('Invalid metadata: "date" must be a string or null.');if(!Te(e.originaldate))throw new TypeError('Invalid metadata: "originaldate" must be a string or null.');if(!Te(e.releasedate))throw new TypeError('Invalid metadata: "releasedate" must be a string or null.');if(!Te(e.albumsort))throw new TypeError('Invalid metadata: "albumsort" must be a string or null.');if(!Te(e.titlesort))throw new TypeError('Invalid metadata: "titlesort" must be a string or null.');if(!Te(e.work))throw new TypeError('Invalid metadata: "work" must be a string or null.');if(!Te(e.artistsort))throw new TypeError('Invalid metadata: "artistsort" must be a string or null.');if(!Te(e.albumartistsort))throw new TypeError('Invalid metadata: "albumartistsort" must be a string or null.');if(!Te(e.composersort))throw new TypeError('Invalid metadata: "composersort" must be a string or null.');if(!Te(e.grouping))throw new TypeError('Invalid metadata: "grouping" must be a string or null.');if(!Te(e.longDescription))throw new TypeError('Invalid metadata: "longDescription" must be a string or null.');if(!Te(e.totaltracks))throw new TypeError('Invalid metadata: "totaltracks" must be a string or null.');if(!Te(e.totaldiscs))throw new TypeError('Invalid metadata: "totaldiscs" must be a string or null.');if(!Te(e.mood))throw new TypeError('Invalid metadata: "mood" must be a string or null.');if(!Te(e.media))throw new TypeError('Invalid metadata: "media" must be a string or null.');if(!Te(e.tvShow))throw new TypeError('Invalid metadata: "tvShow" must be a string or null.');if(!Te(e.tvShowSort))throw new TypeError('Invalid metadata: "tvShowSort" must be a string or null.');if(!Te(e.tvEpisodeId))throw new TypeError('Invalid metadata: "tvEpisodeId" must be a string or null.');if(!Te(e.tvNetwork))throw new TypeError('Invalid metadata: "tvNetwork" must be a string or null.');if(!Te(e.podcasturl))throw new TypeError('Invalid metadata: "podcasturl" must be a string or null.');if(!Te(e.releasestatus))throw new TypeError('Invalid metadata: "releasestatus" must be a string or null.');if(!Te(e.releasecountry))throw new TypeError('Invalid metadata: "releasecountry" must be a string or null.');if(!Te(e.script))throw new TypeError('Invalid metadata: "script" must be a string or null.');if(!Te(e.language))throw new TypeError('Invalid metadata: "language" must be a string or null.');if(!Te(e.copyright))throw new TypeError('Invalid metadata: "copyright" must be a string or null.');if(!Te(e.license))throw new TypeError('Invalid metadata: "license" must be a string or null.');if(!Te(e.encodedby))throw new TypeError('Invalid metadata: "encodedby" must be a string or null.');if(!Te(e.encodersettings))throw new TypeError('Invalid metadata: "encodersettings" must be a string or null.');if(!Te(e.barcode))throw new TypeError('Invalid metadata: "barcode" must be a string or null.');if(!Te(e.asin))throw new TypeError('Invalid metadata: "asin" must be a string or null.');if(!Te(e.website))throw new TypeError('Invalid metadata: "website" must be a string or null.');if(!Te(e.originalalbum))throw new TypeError('Invalid metadata: "originalalbum" must be a string or null.');if(!Te(e.originalartist))throw new TypeError('Invalid metadata: "originalartist" must be a string or null.');if(!Te(e.key))throw new TypeError('Invalid metadata: "key" must be a string or null.');if(!Te(e.movement))throw new TypeError('Invalid metadata: "movement" must be a string or null.');if(!Te(e.podcastId))throw new TypeError('Invalid metadata: "podcastId" must be a string or null.');if(!Ne(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of strings.');if(!Ne(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of strings.');if(!Ne(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of strings.');if(!Ne(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of strings.');if(!Ne(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of strings.');if(!Ne(e.lyricist,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "lyricist" must be an array of strings.');if(!Ne(e.writer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "writer" must be an array of strings.');if(!Ne(e.conductor,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "conductor" must be an array of strings.');if(!Ne(e.remixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "remixer" must be an array of strings.');if(!Ne(e.arranger,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "arranger" must be an array of strings.');if(!Ne(e.engineer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "engineer" must be an array of strings.');if(!Ne(e.publisher,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "publisher" must be an array of strings.');if(!Ne(e.producer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "producer" must be an array of strings.');if(!Ne(e.djmixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "djmixer" must be an array of strings.');if(!Ne(e.mixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "mixer" must be an array of strings.');if(!Ne(e.technician,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "technician" must be an array of strings.');if(!Ne(e.subtitle,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "subtitle" must be an array of strings.');if(!Ne(e.description,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "description" must be an array of strings.');if(!Ne(e.discsubtitle,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "discsubtitle" must be an array of strings.');if(!Ne(e.releasetype,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "releasetype" must be an array of strings.');if(!Ne(e.isrc,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "isrc" must be an array of strings.');if(!Ne(e.performer_instrument,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "performer_instrument" must be an array of strings.');if(!Ne(e.notes,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "notes" must be an array of strings.');if(!Ne(e.category,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "category" must be an array of strings.');if(!Ne(e.keywords,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "keywords" must be an array of strings.');if(!Ne(e.catalognumber,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "catalognumber" must be an array of strings.');if(!Ne(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(!Ne(e.comment,e=>null!==e&&"object"==typeof e&&Te(e.descriptor)&&Te(e.language)&&Te(e.text)))throw new TypeError('Invalid metadata: "comment" must be an array of valid IComment objects.');if(!Ne(e.lyrics,e=>null!==e&&"object"==typeof e&&Te(e.text)&&Te(e.descriptor)&&Te(e.language)&&(!Array.isArray(e)||Ne(e.syncText,e=>null!==e&&"object"==typeof e&&Te(e.text)&&Ie(e.timestamp)))&&(e=>void 0===e||null!==e&&"object"==typeof e&&Ie(e.notSynchronized)&&Ie(e.mpegFrameNumber)&&Ie(e.milliseconds))(e.timeStampFormat)&&(e=>void 0===e||null!==e&&"object"==typeof e&&Ie(e.other)&&Ie(e.lyrics)&&Ie(e.text)&&Ie(e.movement_part)&&Ie(e.events)&&Ie(e.chord)&&Ie(e.trivia_pop))(e.contentType)))throw new TypeError('Invalid metadata: "lyrics" must be an array of valid ILyricsTag objects.');if(!Ne(e.rating,e=>null!==e&&"object"==typeof e&&Te(e.source)&&Ie(e.rating)))throw new TypeError('Invalid metadata: "rating" must be an array of valid IRating objects.');const t=(e,t)=>{if(!ve(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)},Oe=async(e,t,r=!0)=>{be(e,"url"),he(t,"parseFile");const n=await fetch(e);if(!n.ok)throw new Error(`Failed to fetch audio file: ${n.status} ${n.statusText}`);const o=await n.blob(),a=await t(o);if(!a||"object"!=typeof a.common)throw new TypeError('Invalid metadata: "common" property is missing.');void 0!==typeof a.common["performer:instrument"]&&(a.common.performer_instrument=a.common["performer:instrument"]),Me(a);const i=a.common;Se(i);const s=([e,t])=>Array.isArray(t)?t.length>0:d(t)?c(Object.fromEntries(Object.entries(t).filter(s)))>0:null!==t,l=i?.picture?.map(e=>({...e,data:r?De(e.data,e.format):e.data}))??[];a.common={...a.common,picture:l.map(e=>({...e,data:""}))},r&&Object.keys(a.native).forEach(e=>{a.native[e]=a.native[e].map(e=>{if(e.value&&"object"==typeof e.value&&e.value.data instanceof Uint8Array){const t=i?.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:i?.title??null,album:i?.album??null,albumartist:i?.albumartist??null,albumartists:i?.albumartists??[],genre:i?.genre??[],label:i?.label??[],composer:i?.composer??[],year:i?.year??null,artist:i?.artist??null,artists:i?.artists??[],disk:i?.disk?{no:i.disk.no,of:i.disk.of}:null,track:i?.track?{no:i.track.no,of:i.track.of}:null,movementIndex:i?.movementIndex?{no:i.movementIndex.no,of:i.movementIndex.of}:null,picture:l,date:i?.date??null,originaldate:i?.originaldate??null,originalyear:i?.originalyear??null,releasedate:i?.releasedate??null,comment:i?.comment??[],lyrics:i?.lyrics??[],albumsort:i?.albumsort??null,titlesort:i?.titlesort??null,work:i?.work??null,artistsort:i?.artistsort??null,albumartistsort:i?.albumartistsort??null,composersort:i?.composersort??null,lyricist:i?.lyricist??[],writer:i?.writer??[],conductor:i?.conductor??[],remixer:i?.remixer??[],arranger:i?.arranger??[],engineer:i?.engineer??[],publisher:i?.publisher??[],producer:i?.producer??[],djmixer:i?.djmixer??[],mixer:i?.mixer??[],technician:i?.technician??[],grouping:i?.grouping??null,subtitle:i?.subtitle??[],description:i?.description??[],longDescription:i?.longDescription??null,discsubtitle:i?.discsubtitle??[],totaltracks:i?.totaltracks??null,totaldiscs:i?.totaldiscs??null,movementTotal:i?.movementTotal??null,compilation:i?.compilation??null,rating:i?.rating??[],bpm:i?.bpm??null,mood:i?.mood??null,media:i?.media??null,catalognumber:i?.catalognumber??[],tvShow:i?.tvShow??null,tvShowSort:i?.tvShowSort??null,tvSeason:i?.tvSeason??null,tvEpisode:i?.tvEpisode??null,tvEpisodeId:i?.tvEpisodeId??null,tvNetwork:i?.tvNetwork??null,podcast:i?.podcast??null,podcasturl:i?.podcasturl??null,releasestatus:i?.releasestatus??null,releasetype:i?.releasetype??[],releasecountry:i?.releasecountry??null,script:i?.script??null,language:i?.language??null,copyright:i?.copyright??null,license:i?.license??null,encodedby:i?.encodedby??null,encodersettings:i?.encodersettings??null,gapless:i?.gapless??null,barcode:i?.barcode??null,isrc:i?.isrc??[],asin:i?.asin??null,website:i?.website??null,performer_instrument:i?.performer_instrument??[],averageLevel:i?.averageLevel??null,peakLevel:i?.peakLevel??null,notes:i?.notes??[],originalalbum:i?.originalalbum??null,originalartist:i?.originalartist??null,key:i?.key??null,category:i?.category??[],hdVideo:i?.hdVideo??null,keywords:i?.keywords??[],movement:i?.movement??null,podcastId:i?.podcastId??null,showMovement:i?.showMovement??null,stik:i?.stik??null,playCounter:i?.playCounter??null}).filter(s));return u._fetchData=a,u},Fe=async(e,t={},r={},n=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.")))},o={},a=!0,i="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(Ee(t,"defaultMetadata"),Ee(r,"metadata"),he(n,"parseFile"),Ee(o,"callbacks"),o.onProgress&&"function"!=typeof o.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(o.onError&&"function"!=typeof o.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof i&&"function"!=typeof i)throw new TypeError("unknownArtist must be a string or a function returning a string.");let s,l="";const u=(t,r)=>{if(be(t,"stage"),void 0!==r&&!(r instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');o.onProgress&&o.onProgress({event:r,status:"loading",stage:t,url:l||(e instanceof HTMLMediaElement?e.src:"unknown")})},m=(t,r)=>{if(!(t instanceof Error))throw new TypeError('Expected "error" to be an Error.');be(r,"stage"),o.onError&&o.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,s=new Audio(l)):(s=e,l=s.src);try{await new Promise((e,t)=>{const r=e=>u("DOWNLOADING",e),n=()=>{a(),e(void 0)},o=e=>{a(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},a=()=>{s.removeEventListener("progress",r),s.removeEventListener("loadedmetadata",n),s.removeEventListener("error",o)};s.addEventListener("progress",r),s.addEventListener("loadedmetadata",n),s.addEventListener("error",o),s.readyState>=1&&(a(),e(void 0))}),u("METADATA_LOADED")}catch(e){throw new ke(e instanceof Error?e.message:"UNKNOWN ERROR",l,"METADATA")}const f={id:r.id||await je(l),duration:Math.floor(1e3*s.duration),url:l,weight:r.weight??1};let c={};u("EXTRACTING_ID3");try{c=await Oe(l,n,a)}catch(e){m(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${l}. Falling back to filename.`)}const p=e=>{be(e,"url");try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},y=e=>{const t={...e};return d(t._fetchData)&&(d(c._fetchData)&&(t._fetchData={...c._fetchData}),d(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},w={...f,...y(t),...c,...y(r),title:c.title||r.title||p(l),artist:c.artist||r.artist||("string"==typeof i?i:String(i()))};return o.onProgress&&o.onProgress({status:"success",stage:"COMPLETE",url:l}),w}catch(e){if(e instanceof ke)throw e;const t=new ke(e instanceof Error?e.message:"UNKNOWN ERROR",l,"INITIALIZING");throw m(t,"INITIALIZING"),t}},Le=(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 n=setInterval(()=>{e()&&(clearInterval(n),r())},t)})},Ce=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 n=await e(...r);return t=null,n}catch(e){throw t=null,e}})()),t),getActivePromise:()=>t,resetActivePromise:()=>{t=null}}},Pe=["chrome","firefox","ie","edge","safari","opera","yandex","other"];function Re(){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 Be(){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 $e(){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(),n=!!document.documentMode,o=!n&&!!window.StyleMedia,a=!!window.chrome;return{isOpera:e,isFirefox:t,isSafari:r,isIE:n,isEdge:o,isChrome:a,isBlink:(a||e)&&!!window.CSS}}function _e(e=[]){if(!Array.isArray(e))throw new TypeError('The "disable" argument must be an array.');for(const t of e)if(!Pe.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[Re()]++;const r=Be();"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 n=$e();return n.isOpera&&e.indexOf("opera")<0&&t.opera++,n.isFirefox&&e.indexOf("firefox")<0&&t.firefox++,n.isSafari&&e.indexOf("safari")<0&&t.safari++,n.isIE&&e.indexOf("ie")<0&&t.ie++,n.isEdge&&e.indexOf("edge")<0&&t.edge++,n.isChrome&&e.indexOf("chrome")<0&&t.chrome++,t}function Ue(e=[]){const t=_e(e);return Object.keys(t).reduce((e,r)=>t[r]>t[e]?r:e)}window.TinyBasicsEs=t})();
|