tiny-essentials 1.28.5 → 1.28.6

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.
Files changed (35) hide show
  1. package/README.md +18 -1
  2. package/changelog/1/28/6.md +11 -0
  3. package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
  4. package/dist/v1/TinyEssentials.min.js +1 -1
  5. package/dist/v1/TinyIframeEvents.min.js +1 -1
  6. package/dist/v1/TinyLocalStorage.min.js +1 -1
  7. package/dist/v1/TinyMediaPlayer.min.js +1 -1
  8. package/dist/v1/TinyNewWinEvents.min.js +1 -1
  9. package/dist/v1/TinyRadioFm.min.js +1 -1
  10. package/dist/v1/TinySmartScroller.min.js +1 -1
  11. package/dist/v1/TinyUploadClicker.min.js +1 -1
  12. package/dist/v1/css/TinyLoadingScreen.min.css +1 -1
  13. package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.cjs +53 -3
  14. package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.d.mts +25 -0
  15. package/dist/v1/libs/TinyMediaPlayer/HtmlAudio.mjs +49 -3
  16. package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.cjs +53 -3
  17. package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.d.mts +25 -0
  18. package/dist/v1/libs/TinyMediaPlayer/HtmlVideo.mjs +49 -3
  19. package/dist/v1/libs/TinyMediaPlayer/SoundCloud.cjs +792 -0
  20. package/dist/v1/libs/TinyMediaPlayer/SoundCloud.d.mts +300 -0
  21. package/dist/v1/libs/TinyMediaPlayer/SoundCloud.mjs +697 -0
  22. package/dist/v1/libs/TinyMediaPlayer/Youtube.cjs +124 -12
  23. package/dist/v1/libs/TinyMediaPlayer/Youtube.d.mts +96 -0
  24. package/dist/v1/libs/TinyMediaPlayer/Youtube.mjs +107 -10
  25. package/dist/v1/libs/TinyMediaPlayer/docs/SoundCloudWidget.cjs +381 -0
  26. package/dist/v1/libs/TinyMediaPlayer/docs/SoundCloudWidget.d.mts +704 -0
  27. package/dist/v1/libs/TinyMediaPlayer/docs/SoundCloudWidget.mjs +343 -0
  28. package/dist/v1/libs/TinyMediaPlayer/index.cjs +52 -1
  29. package/dist/v1/libs/TinyMediaPlayer/index.d.mts +60 -0
  30. package/dist/v1/libs/TinyMediaPlayer/index.mjs +47 -1
  31. package/dist/v1/libs/TinyMediaPlayer.cjs +38 -0
  32. package/dist/v1/libs/TinyMediaPlayer.d.mts +13 -0
  33. package/dist/v1/libs/TinyMediaPlayer.mjs +38 -0
  34. package/docs/v1/libs/TinyMediaPlayer.md +31 -9
  35. package/package.json +51 -10
@@ -1 +1 @@
1
- (()=>{"use strict";var e={7(e){var t,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,e.exports.once=function(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,s),r(n)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}c(e,t,s,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&c(e,"error",t,{once:!0})}(e,i)})},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function h(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function d(e,t,n,r){var i,s,o,d;if(a(n),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),o=s[t]),void 0===o)o=s[t]=n,++e._eventsCount;else if("function"==typeof o?o=s[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),(i=h(e))>0&&o.length>i&&!o.warned){o.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=e,f.type=t,f.count=o.length,d=f,console&&console.warn&&console.warn(d)}return e}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}function p(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):y(i,i.length)}function v(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function y(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function c(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function i(s){r.once&&e.removeEventListener(t,i),n(s)})}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=e}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return h(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i="error"===e,s=this._events;if(void 0!==s)i=i&&void 0===s.error;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var h=s[e];if(void 0===h)return!1;if("function"==typeof h)r(h,this,t);else{var d=h.length,f=y(h,d);for(n=0;n<d;++n)r(f[n],this,t)}return!0},s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)},s.prototype.once=function(e,t){return a(t),this.on(e,u(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,u(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,s,o;if(a(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){o=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,s=Object.keys(n);for(r=0;r<s.length;++r)"removeListener"!==(i=s[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},s.prototype.listeners=function(e){return p(this,e,!0)},s.prototype.rawListeners=function(e){return p(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):v.call(e,t)},s.prototype.listenerCount=v,s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}}};const t={};function n(r){const i=t[r];if(void 0!==i)return i.exports;const s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.d=(e,t)=>{if(Array.isArray(t))for(var r=0;r<t.length;){var i=t[r++],s=t[r++];n.o(e,i)?0===s&&r++:0===s?Object.defineProperty(e,i,{enumerable:!0,value:t[r++]}):Object.defineProperty(e,i,{enumerable:!0,get:s})}else for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let r={};n.d(r,{TinyIframeEvents:()=>d});var i=n(7);function s(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}const o=e=>{if(e)throw new Error("This TinyIframeEvents instance has been destroyed and can no longer be used.")};const a=new WeakMap;class h extends i.EventEmitter{#e;get targetWindow(){return o(this.#t),this.#e}#n;get targetIframeElement(){return o(this.#t),this.#n}#r;get targetOrigin(){return o(this.#t),this.#r}#i;get selfType(){return o(this.#t),this.#i}#t=!1;#s=!1;get ready(){return o(this.#t),this.#s}onReady(e){o(this.#t),this.#s?e():this.once(this.#o,e)}#a=null;#h=[];#d;#f;#o;#u=null;constructor({targetIframe:e,targetOrigin:t=window.location.origin,secretEventName:n="__tinyIframeEvent__",handshakeEventName:r="__tinyIframeHandshake__",readyEventName:i="__tinyIframeReady__"}={}){if(super(),!(void 0===e||e instanceof HTMLIFrameElement&&e.contentWindow))throw new TypeError('[TinyIframeEvents] Invalid "targetIframe": expected HTMLIFrameElement, received '+typeof e);if("string"!=typeof t)throw new TypeError('[TinyIframeEvents] Invalid "targetOrigin": expected string, received '+typeof t);if(this.#n=e,this.#e=e?.contentWindow??window.parent,this.#r=t,this.#i=e?"parent":"iframe",this.#d=n,this.#f=r,this.#o=i,a.has(this.#e))throw new Error("Duplicate window reference.");this._boundWindowMessage=this.#p.bind(this),this._boundPortMessage=this.#v.bind(this),this.#y(),a.set(this.#e,this)}get secretEventName(){return o(this.#t),this.#d}set secretEventName(e){if(o(this.#t),"string"!=typeof e)throw new TypeError("TinyIframeEvents: secretEventName must be a string.");this.#d=e}get handshakeEventName(){return o(this.#t),this.#f}set handshakeEventName(e){if(o(this.#t),"string"!=typeof e)throw new TypeError("TinyIframeEvents: handshakeEventName must be a string.");this.#f=e}get readyEventName(){return o(this.#t),this.#o}set readyEventName(e){if(o(this.#t),"string"!=typeof e)throw new TypeError("TinyIframeEvents: readyEventName must be a string.");this.#o=e}#y(){"parent"===this.#i?(this.#u=()=>{if(this.#t)return;this.#a&&this.#a.close();const e=new MessageChannel;this.#a=e.port1,this.#a.onmessage=this._boundPortMessage,this.#s=!1,this.#e.postMessage({type:this.#f},this.#r,[e.port2])},this.#n&&(this.#n.addEventListener("load",this.#u),this.#u())):window.addEventListener("message",this._boundWindowMessage,!1)}#p(e){const t=e.data,n=e.ports;s(t)&&t.type===this.#f&&0!==n.length&&(this.#a=n[0],this.#a.onmessage=this._boundPortMessage,window.removeEventListener("message",this._boundWindowMessage),this.#a.postMessage({type:`${this.#f}_ACK`}),this.#c())}#v(e){const t=e.data;if(s(t)&&t.type===`${this.#f}_ACK`)return void this.#c();if(!s(t)||!t[this.#d])return;const n=t.eventName,r=t.payload,i=t.direction;"string"!=typeof n||"iframe"===this.#i&&"iframe"!==i||"parent"===this.#i&&"parent"!==i||this.emit(`win:${n}`,r,e)}#c(){this.#s||(this.#s=!0,this.#l(),this.emit(this.#o))}#l(){for(;this.#h.length>0;){const e=this.#h.shift();e&&this.#a&&this.#a.postMessage(e)}}winEmit(e,t){if(o(this.#t),"string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.#t)throw new Error("Cannot emit: instance has been destroyed.");const n={[this.#d]:!0,eventName:e,payload:t,direction:"parent"===this.#i?"iframe":"parent"};this.#s&&this.#a?this.#a.postMessage(n):this.#h.push(n)}isDestroyed(){return this.#t}destroy(){this.#t||(this.#s=!1,window.removeEventListener("message",this._boundWindowMessage),this.#n&&this.#u&&this.#n.removeEventListener("load",this.#u),this.#a&&(this.#a.close(),this.#a=null),this.removeAllListeners(),this.#h=[],a.delete(this.#e),this.#t=!0)}}const d=h;window.TinyIframeEvents=r.TinyIframeEvents})();
1
+ (()=>{"use strict";var e={323(e,t,n){n.d(t,{TinyIframeEvents:()=>h});var r=n.cjs(function(e,t){var n,r="object"==typeof Reflect?Reflect:null,i=r&&"function"==typeof r.apply?r.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};n=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,s),r(n)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}l(e,t,s,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&l(e,"error",t,{once:!0})}(e,i)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var a=10;function h(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function d(e,t,n,r){var i,s,o,a;if(h(n),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),o=s[t]),void 0===o)o=s[t]=n,++e._eventsCount;else if("function"==typeof o?o=s[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),(i=u(e))>0&&o.length>i&&!o.warned){o.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=e,d.type=t,d.count=o.length,a=d,console&&console.warn&&console.warn(a)}return e}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}function v(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):y(i,i.length)}function c(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function y(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function l(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function i(s){r.once&&e.removeEventListener(t,i),n(s)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,s=this._events;if(void 0!==s)r=r&&void 0===s.error;else if(!r)return!1;if(r){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var h=s[e];if(void 0===h)return!1;if("function"==typeof h)i(h,this,t);else{var u=h.length,d=y(h,u);for(n=0;n<u;++n)i(d[n],this,t)}return!0},o.prototype.addListener=function(e,t){return d(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return d(this,e,t,!0)},o.prototype.once=function(e,t){return h(t),this.on(e,p(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return h(t),this.prependListener(e,p(this,e,t)),this},o.prototype.removeListener=function(e,t){var n,r,i,s,o;if(h(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){o=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,o||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,s=Object.keys(n);for(r=0;r<s.length;++r)"removeListener"!==(i=s[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},o.prototype.listeners=function(e){return v(this,e,!0)},o.prototype.rawListeners=function(e){return v(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):c.call(e,t)},o.prototype.listenerCount=c,o.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}});function i(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}const s=e=>{if(e)throw new Error("This TinyIframeEvents instance has been destroyed and can no longer be used.")};const o=new WeakMap;class a extends r.EventEmitter{#e;get targetWindow(){return s(this.#t),this.#e}#n;get targetIframeElement(){return s(this.#t),this.#n}#r;get targetOrigin(){return s(this.#t),this.#r}#i;get selfType(){return s(this.#t),this.#i}#t=!1;#s=!1;get ready(){return s(this.#t),this.#s}onReady(e){s(this.#t),this.#s?e():this.once(this.#o,e)}#a=null;#h=[];#u;#d;#o;#f=null;constructor({targetIframe:e,targetOrigin:t=window.location.origin,secretEventName:n="__tinyIframeEvent__",handshakeEventName:r="__tinyIframeHandshake__",readyEventName:i="__tinyIframeReady__"}={}){if(super(),!(void 0===e||e instanceof HTMLIFrameElement&&e.contentWindow))throw new TypeError('[TinyIframeEvents] Invalid "targetIframe": expected HTMLIFrameElement, received '+typeof e);if("string"!=typeof t)throw new TypeError('[TinyIframeEvents] Invalid "targetOrigin": expected string, received '+typeof t);if(this.#n=e,this.#e=e?.contentWindow??window.parent,this.#r=t,this.#i=e?"parent":"iframe",this.#u=n,this.#d=r,this.#o=i,o.has(this.#e))throw new Error("Duplicate window reference.");this._boundWindowMessage=this.#p.bind(this),this._boundPortMessage=this.#v.bind(this),this.#c(),o.set(this.#e,this)}get secretEventName(){return s(this.#t),this.#u}set secretEventName(e){if(s(this.#t),"string"!=typeof e)throw new TypeError("TinyIframeEvents: secretEventName must be a string.");this.#u=e}get handshakeEventName(){return s(this.#t),this.#d}set handshakeEventName(e){if(s(this.#t),"string"!=typeof e)throw new TypeError("TinyIframeEvents: handshakeEventName must be a string.");this.#d=e}get readyEventName(){return s(this.#t),this.#o}set readyEventName(e){if(s(this.#t),"string"!=typeof e)throw new TypeError("TinyIframeEvents: readyEventName must be a string.");this.#o=e}#c(){"parent"===this.#i?(this.#f=()=>{if(this.#t)return;this.#a&&this.#a.close();const e=new MessageChannel;this.#a=e.port1,this.#a.onmessage=this._boundPortMessage,this.#s=!1,this.#e.postMessage({type:this.#d},this.#r,[e.port2])},this.#n&&(this.#n.addEventListener("load",this.#f),this.#f())):window.addEventListener("message",this._boundWindowMessage,!1)}#p(e){const t=e.data,n=e.ports;i(t)&&t.type===this.#d&&0!==n.length&&(this.#a=n[0],this.#a.onmessage=this._boundPortMessage,window.removeEventListener("message",this._boundWindowMessage),this.#a.postMessage({type:`${this.#d}_ACK`}),this.#y())}#v(e){const t=e.data;if(i(t)&&t.type===`${this.#d}_ACK`)return void this.#y();if(!i(t)||!t[this.#u])return;const n=t.eventName,r=t.payload,s=t.direction;"string"!=typeof n||"iframe"===this.#i&&"iframe"!==s||"parent"===this.#i&&"parent"!==s||this.emit(`win:${n}`,r,e)}#y(){this.#s||(this.#s=!0,this.#l(),this.emit(this.#o))}#l(){for(;this.#h.length>0;){const e=this.#h.shift();e&&this.#a&&this.#a.postMessage(e)}}winEmit(e,t){if(s(this.#t),"string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.#t)throw new Error("Cannot emit: instance has been destroyed.");const n={[this.#u]:!0,eventName:e,payload:t,direction:"parent"===this.#i?"iframe":"parent"};this.#s&&this.#a?this.#a.postMessage(n):this.#h.push(n)}isDestroyed(){return this.#t}destroy(){this.#t||(this.#s=!1,window.removeEventListener("message",this._boundWindowMessage),this.#n&&this.#f&&this.#n.removeEventListener("load",this.#f),this.#a&&(this.#a.close(),this.#a=null),this.removeAllListeners(),this.#h=[],o.delete(this.#e),this.#t=!0)}}const h=a}};const t={};function n(r){const i=t[r];if(void 0!==i)return i.exports;const s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.d=(e,t)=>{if(Array.isArray(t))for(var r=0;r<t.length;){var i=t[r++],s=t[r++];n.o(e,i)?0===s&&r++:0===s?Object.defineProperty(e,i,{enumerable:!0,value:t[r++]}):Object.defineProperty(e,i,{enumerable:!0,get:s})}else for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.cjs=e=>{const t={exports:{}};return e.call(t.exports,t,t.exports),t.exports};let r=n(323);window.TinyIframeEvents=r.TinyIframeEvents})();
@@ -1 +1 @@
1
- (()=>{"use strict";var e={7(e){var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,e.exports.once=function(e,t){return new Promise(function(r,n){function o(r){e.removeListener(t,s),n(r)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",o),r([].slice.call(arguments))}p(e,t,s,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&p(e,"error",t,{once:!0})}(e,o)})},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var i=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function c(e,t,r,n){var o,s,i,c;if(a(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),i=s[t]),void 0===i)i=s[t]=r,++e._eventsCount;else if("function"==typeof i?i=s[t]=n?[r,i]:[i,r]:n?i.unshift(r):i.push(r),(o=l(e))>0&&i.length>o&&!i.warned){i.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=i.length,c=u,console&&console.warn&&console.warn(c)}return e}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function y(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=u.bind(n);return o.listener=r,n.wrapFn=o,o}function f(e,t,r){var n=e._events;if(void 0===n)return[];var o=n[t];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(o):d(o,o.length)}function h(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function d(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function p(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function o(s){n.once&&e.removeEventListener(t,o),r(s)})}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return i},set:function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");i=e}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return l(this)},s.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var o="error"===e,s=this._events;if(void 0!==s)o=o&&void 0===s.error;else if(!o)return!1;if(o){var i;if(t.length>0&&(i=t[0]),i instanceof Error)throw i;var a=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw a.context=i,a}var l=s[e];if(void 0===l)return!1;if("function"==typeof l)n(l,this,t);else{var c=l.length,u=d(l,c);for(r=0;r<c;++r)n(u[r],this,t)}return!0},s.prototype.addListener=function(e,t){return c(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return c(this,e,t,!0)},s.prototype.once=function(e,t){return a(t),this.on(e,y(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,y(this,e,t)),this},s.prototype.removeListener=function(e,t){var r,n,o,s,i;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){i=r[s].listener,o=s;break}if(o<0)return this;0===o?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,o),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,i||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var o,s=Object.keys(r);for(n=0;n<s.length;++n)"removeListener"!==(o=s[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return f(this,e,!0)},s.prototype.rawListeners=function(e){return f(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h,s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}}};const t={};function r(n){const o=t[n];if(void 0!==o)return o.exports;const s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var n=0;n<t.length;){var o=t[n++],s=t[n++];r.o(e,o)?0===s&&n++:0===s?Object.defineProperty(e,o,{enumerable:!0,value:t[n++]}):Object.defineProperty(e,o,{enumerable:!0,get:s})}else for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let n={};r.d(n,{TinyLocalStorage:()=>y});var o=r(7);function s(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}const i=e=>{if(e)throw new Error("This TinyLocalStorage instance has been destroyed and can no longer be used.")};const a=new Map,l=new Map,c=new Set(["string","boolean","object","array",String,Boolean,Number,Object,Array,BigInt,Symbol]);class u extends o.EventEmitter{static hasJsonType(e){return a.has(e)&&l.has(e)||c.has(e)}static registerJsonType(e,t,r,n=!1){if(c.has(e))throw new Error(`Cannot register type "${e}" because it is frozen.`);a.set(e,t),l.set(e,r),n&&c.add(e)}static deleteJsonType(e){if(c.has(e))throw new Error(`Cannot remove type "${e}" because it is frozen.`);let t=!1;return a.delete(e)&&(t=!0),l.delete(e)&&(t=!0),t}static encodeSpecialJson(e){if(void 0===e)return{__undefined__:!0};if(null===e)return{__null__:!0};for(const[t,r]of a.entries())if("string"!=typeof t&&e instanceof t||typeof e===t)return r(e,u.encodeSpecialJson);if(Array.isArray(e))return e.map(u.encodeSpecialJson);if(s(e)){const t={};for(const r in e)t[r]=u.encodeSpecialJson(e[r]);return t}return e}static decodeSpecialJson(e){const t=s(e);if(t){if(e.__undefined__)return;if(e.__null__)return null}if(Array.isArray(e))return e.map(u.decodeSpecialJson);if(t){for(const[t,r]of l.entries())if(r.check&&r.check(e))return r.decode(e,u.decodeSpecialJson);const t={};for(const r in e)t[r]=u.decodeSpecialJson(e[r]);return t}return e}#e=!1;get destroyed(){return this.#e}#t=window.localStorage;#r=null;#n=0;#o=e=>this.emit("storage",e);constructor(e){if(super(),void 0!==e&&"string"!=typeof e)throw new TypeError("TinyLocalStorage: dbName must be a string if provided.");"string"==typeof e&&(this.#r=`LSDB::${e}`),window.addEventListener("storage",this.#o)}#s(e){if("string"==typeof e&&e.startsWith("LSDB::"))throw new Error(`TinyLocalStorage: Key "${e}" may conflict with reserved dbKeys.`)}updateStorageVersion(e,t){if(i(this.#e),"string"!=typeof this.#r)throw new Error("TinyLocalStorage: Database key is not initialized. Set a valid dbName in the constructor.");if("number"!=typeof e||Number.isNaN(e)||e<1)throw new TypeError("TinyLocalStorage: version must be a positive number.");if("function"!=typeof t)throw new TypeError("TinyLocalStorage: onUpgrade must be a function.");const r=parseInt(localStorage.getItem(this.#r),10)||0;if("number"!=typeof r||Number.isNaN(r)||r<0)throw new TypeError("TinyLocalStorage: saved version in localStorage is not a valid number.");if(e<r)throw new Error(`TinyLocalStorage: Cannot downgrade database version from ${r} to ${e}.`);e>r&&(t(r,e),localStorage.setItem(this.#r,String(e)),this.#n=e)}getDbKey(){return i(this.#e),this.#r}getVersion(){return i(this.#e),this.#n}setLocalStorage(e){if(i(this.#e),!(e instanceof Storage))throw new TypeError("Argument must be a valid instance of Storage.");this.#t=e}localStorageExists(){return i(this.#e),this.#t instanceof Storage}#i(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return u.encodeSpecialJson(t)}setJson(e,t){if(i(this.#e),this.#s(e),!(s(t)||Array.isArray(t)||t instanceof Map||t instanceof Set))throw new TypeError("The storage value is not a valid JSON-compatible structure.");const r=this.#i(e,t);return this.emit("setJson",e,t),this.#t.setItem(e,JSON.stringify(r))}#a(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const r=this.#t.getItem(e),n={obj:()=>({}),array:()=>[],map:()=>new Map,set:()=>new Set},o="function"==typeof n[t]?n[t]():null;let s;try{s=JSON.parse(r)}catch{return o}return{decoded:u.decodeSpecialJson(s),fallback:o}}getJson(e,t){i(this.#e);const{decoded:r,fallback:n}=this.#a(e,t);return r instanceof Map||r instanceof Set||Array.isArray(r)||s(r)?r:n}setDate(e,t){if(i(this.#e),this.#s(e),!(t instanceof Date))throw new TypeError("Value must be a Date.");const r=this.#i(e,t);return this.emit("setDate",e,t),this.#t.setItem(e,JSON.stringify(r))}getDate(e){i(this.#e);const t=this.#a(e).decoded;return t instanceof Date?t:null}setRegExp(e,t){if(i(this.#e),this.#s(e),!(t instanceof RegExp))throw new TypeError("Value must be a RegExp.");const r=this.#i(e,t);return this.emit("setRegExp",e,t),this.#t.setItem(e,JSON.stringify(r))}getRegExp(e){i(this.#e);const t=this.#a(e).decoded;return t instanceof RegExp?t:null}setBigInt(e,t){if(i(this.#e),this.#s(e),"bigint"!=typeof t)throw new TypeError("Value must be a BigInt.");const r=this.#i(e,t);return this.emit("setBigInt",e,t),this.#t.setItem(e,JSON.stringify(r))}getBigInt(e){i(this.#e);const t=this.#a(e).decoded;return"bigint"==typeof t?t:null}setSymbol(e,t){if(i(this.#e),this.#s(e),"symbol"!=typeof t)throw new TypeError("Value must be a Symbol.");const r=this.#i(e,t);return this.emit("setSymbol",e,t),this.#t.setItem(e,JSON.stringify(r))}getSymbol(e){i(this.#e);const t=this.#a(e).decoded;return"symbol"==typeof t?t:null}getValue(e){return i(this.#e),this.#a(e).decoded??null}setItem(e,t){if(i(this.#e),this.#s(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("setItem",e,t),this.#t.setItem(e,t)}getItem(e){if(i(this.#e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.#t.getItem(e)}setString(e,t){if(i(this.#e),this.#s(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("string"!=typeof t)throw new TypeError("Value must be a string.");return this.emit("setString",e,t),this.#t.setItem(e,JSON.stringify({__string__:!0,value:t}))}getString(e){if(i(this.#e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#t.getItem(e);try{if(t=JSON.parse(t),!s(t)||!t.__string__||"string"!=typeof t.value)return null;t=t.value}catch{t=null}return"string"==typeof t?t:null}setNumber(e,t){if(i(this.#e),this.#s(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("number"!=typeof t)throw new TypeError("Value must be a number.");return this.emit("setNumber",e,t),this.#t.setItem(e,String(t))}getNumber(e){if(i(this.#e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#t.getItem(e);return"number"==typeof t||"string"==typeof t&&t.length>0&&(t=parseFloat(t),!Number.isNaN(t))?t:null}setBool(e,t){if(i(this.#e),this.#s(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("boolean"!=typeof t)throw new TypeError("Value must be a boolean.");return this.emit("setBool",e,t),this.#t.setItem(e,String(t))}getBool(e){if(i(this.#e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const t=this.#t.getItem(e);if("boolean"==typeof t)return t;if("string"==typeof t){if("true"===t)return!0;if("false"===t)return!1}return null}removeItem(e){if(i(this.#e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("removeItem",e),this.#t.removeItem(e)}clearLocalStorage(){return i(this.#e),this.#t.clear()}destroy(){this.#e||(window.removeEventListener("storage",this.#o),this.removeAllListeners(),this.#e=!0)}}u.registerJsonType(Map,(e,t)=>({__map__:!0,data:Array.from(e.entries()).map(([e,r])=>[e,t(r)])}),{check:e=>e.__map__,decode:(e,t)=>new Map(e.data.map(([e,r])=>[e,t(r)]))},!0),u.registerJsonType(Set,(e,t)=>({__set__:!0,data:Array.from(e).map(t)}),{check:e=>e.__set__,decode:(e,t)=>new Set(e.data.map(t))},!0),u.registerJsonType(Date,e=>({__date__:!0,value:e.toISOString()}),{check:e=>e.__date__,decode:e=>new Date(e.value)},!0),u.registerJsonType(RegExp,e=>({__regexp__:!0,source:e.source,flags:e.flags}),{check:e=>e.__regexp__,decode:e=>new RegExp(e.source,e.flags)},!0),u.registerJsonType("number",e=>({__number__:!0,value:e.toString()}),{check:e=>e.__number__,decode:e=>Number(e.value)},!0),u.registerJsonType("bigint",e=>({__bigint__:!0,value:e.toString()}),{check:e=>e.__bigint__,decode:e=>BigInt(e.value)},!0),u.registerJsonType("symbol",e=>({__symbol__:!0,key:Symbol.keyFor(e)??e.description??null}),{check:e=>e.__symbol__,decode:e=>{const t=e.key;return null!=t?Symbol.for(t):Symbol()}},!0);const y=u;window.TinyLocalStorage=n.TinyLocalStorage})();
1
+ (()=>{"use strict";var e={683(e,t,r){r.d(t,{TinyLocalStorage:()=>u});var n=r.cjs(function(e,t){var r,n="object"==typeof Reflect?Reflect:null,o=n&&"function"==typeof n.apply?n.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};r=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}e.exports=i,e.exports.once=function(e,t){return new Promise(function(r,n){function o(r){e.removeListener(t,s),n(r)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",o),r([].slice.call(arguments))}g(e,t,s,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&g(e,"error",t,{once:!0})}(e,o)})},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var a=10;function l(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function u(e,t,r,n){var o,s,i,a;if(l(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),i=s[t]),void 0===i)i=s[t]=r,++e._eventsCount;else if("function"==typeof i?i=s[t]=n?[r,i]:[i,r]:n?i.unshift(r):i.push(r),(o=c(e))>0&&i.length>o&&!i.warned){i.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=i.length,a=u,console&&console.warn&&console.warn(a)}return e}function y(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function f(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=y.bind(n);return o.listener=r,n.wrapFn=o,o}function h(e,t,r){var n=e._events;if(void 0===n)return[];var o=n[t];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(o):d(o,o.length)}function p(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function d(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function g(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function o(s){n.once&&e.removeEventListener(t,o),r(s)})}}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),i.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},i.prototype.getMaxListeners=function(){return c(this)},i.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,s=this._events;if(void 0!==s)n=n&&void 0===s.error;else if(!n)return!1;if(n){var i;if(t.length>0&&(i=t[0]),i instanceof Error)throw i;var a=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw a.context=i,a}var l=s[e];if(void 0===l)return!1;if("function"==typeof l)o(l,this,t);else{var c=l.length,u=d(l,c);for(r=0;r<c;++r)o(u[r],this,t)}return!0},i.prototype.addListener=function(e,t){return u(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return u(this,e,t,!0)},i.prototype.once=function(e,t){return l(t),this.on(e,f(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,f(this,e,t)),this},i.prototype.removeListener=function(e,t){var r,n,o,s,i;if(l(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){i=r[s].listener,o=s;break}if(o<0)return this;0===o?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,o),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,i||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var o,s=Object.keys(r);for(n=0;n<s.length;++n)"removeListener"!==(o=s[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},i.prototype.listeners=function(e){return h(this,e,!0)},i.prototype.rawListeners=function(e){return h(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},i.prototype.listenerCount=p,i.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}});function o(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}const s=e=>{if(e)throw new Error("This TinyLocalStorage instance has been destroyed and can no longer be used.")};const i=new Map,a=new Map,l=new Set(["string","boolean","object","array",String,Boolean,Number,Object,Array,BigInt,Symbol]);class c extends n.EventEmitter{static hasJsonType(e){return i.has(e)&&a.has(e)||l.has(e)}static registerJsonType(e,t,r,n=!1){if(l.has(e))throw new Error(`Cannot register type "${e}" because it is frozen.`);i.set(e,t),a.set(e,r),n&&l.add(e)}static deleteJsonType(e){if(l.has(e))throw new Error(`Cannot remove type "${e}" because it is frozen.`);let t=!1;return i.delete(e)&&(t=!0),a.delete(e)&&(t=!0),t}static encodeSpecialJson(e){if(void 0===e)return{__undefined__:!0};if(null===e)return{__null__:!0};for(const[t,r]of i.entries())if("string"!=typeof t&&e instanceof t||typeof e===t)return r(e,c.encodeSpecialJson);if(Array.isArray(e))return e.map(c.encodeSpecialJson);if(o(e)){const t={};for(const r in e)t[r]=c.encodeSpecialJson(e[r]);return t}return e}static decodeSpecialJson(e){const t=o(e);if(t){if(e.__undefined__)return;if(e.__null__)return null}if(Array.isArray(e))return e.map(c.decodeSpecialJson);if(t){for(const[t,r]of a.entries())if(r.check&&r.check(e))return r.decode(e,c.decodeSpecialJson);const t={};for(const r in e)t[r]=c.decodeSpecialJson(e[r]);return t}return e}#e=!1;get destroyed(){return this.#e}#t=window.localStorage;#r=null;#n=0;#o=e=>this.emit("storage",e);constructor(e){if(super(),void 0!==e&&"string"!=typeof e)throw new TypeError("TinyLocalStorage: dbName must be a string if provided.");"string"==typeof e&&(this.#r=`LSDB::${e}`),window.addEventListener("storage",this.#o)}#s(e){if("string"==typeof e&&e.startsWith("LSDB::"))throw new Error(`TinyLocalStorage: Key "${e}" may conflict with reserved dbKeys.`)}updateStorageVersion(e,t){if(s(this.#e),"string"!=typeof this.#r)throw new Error("TinyLocalStorage: Database key is not initialized. Set a valid dbName in the constructor.");if("number"!=typeof e||Number.isNaN(e)||e<1)throw new TypeError("TinyLocalStorage: version must be a positive number.");if("function"!=typeof t)throw new TypeError("TinyLocalStorage: onUpgrade must be a function.");const r=parseInt(localStorage.getItem(this.#r),10)||0;if("number"!=typeof r||Number.isNaN(r)||r<0)throw new TypeError("TinyLocalStorage: saved version in localStorage is not a valid number.");if(e<r)throw new Error(`TinyLocalStorage: Cannot downgrade database version from ${r} to ${e}.`);e>r&&(t(r,e),localStorage.setItem(this.#r,String(e)),this.#n=e)}getDbKey(){return s(this.#e),this.#r}getVersion(){return s(this.#e),this.#n}setLocalStorage(e){if(s(this.#e),!(e instanceof Storage))throw new TypeError("Argument must be a valid instance of Storage.");this.#t=e}localStorageExists(){return s(this.#e),this.#t instanceof Storage}#i(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return c.encodeSpecialJson(t)}setJson(e,t){if(s(this.#e),this.#s(e),!(o(t)||Array.isArray(t)||t instanceof Map||t instanceof Set))throw new TypeError("The storage value is not a valid JSON-compatible structure.");const r=this.#i(e,t);return this.emit("setJson",e,t),this.#t.setItem(e,JSON.stringify(r))}#a(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const r=this.#t.getItem(e),n={obj:()=>({}),array:()=>[],map:()=>new Map,set:()=>new Set},o="function"==typeof n[t]?n[t]():null;let s;try{s=JSON.parse(r)}catch{return o}return{decoded:c.decodeSpecialJson(s),fallback:o}}getJson(e,t){s(this.#e);const{decoded:r,fallback:n}=this.#a(e,t);return r instanceof Map||r instanceof Set||Array.isArray(r)||o(r)?r:n}setDate(e,t){if(s(this.#e),this.#s(e),!(t instanceof Date))throw new TypeError("Value must be a Date.");const r=this.#i(e,t);return this.emit("setDate",e,t),this.#t.setItem(e,JSON.stringify(r))}getDate(e){s(this.#e);const t=this.#a(e).decoded;return t instanceof Date?t:null}setRegExp(e,t){if(s(this.#e),this.#s(e),!(t instanceof RegExp))throw new TypeError("Value must be a RegExp.");const r=this.#i(e,t);return this.emit("setRegExp",e,t),this.#t.setItem(e,JSON.stringify(r))}getRegExp(e){s(this.#e);const t=this.#a(e).decoded;return t instanceof RegExp?t:null}setBigInt(e,t){if(s(this.#e),this.#s(e),"bigint"!=typeof t)throw new TypeError("Value must be a BigInt.");const r=this.#i(e,t);return this.emit("setBigInt",e,t),this.#t.setItem(e,JSON.stringify(r))}getBigInt(e){s(this.#e);const t=this.#a(e).decoded;return"bigint"==typeof t?t:null}setSymbol(e,t){if(s(this.#e),this.#s(e),"symbol"!=typeof t)throw new TypeError("Value must be a Symbol.");const r=this.#i(e,t);return this.emit("setSymbol",e,t),this.#t.setItem(e,JSON.stringify(r))}getSymbol(e){s(this.#e);const t=this.#a(e).decoded;return"symbol"==typeof t?t:null}getValue(e){return s(this.#e),this.#a(e).decoded??null}setItem(e,t){if(s(this.#e),this.#s(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("setItem",e,t),this.#t.setItem(e,t)}getItem(e){if(s(this.#e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.#t.getItem(e)}setString(e,t){if(s(this.#e),this.#s(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("string"!=typeof t)throw new TypeError("Value must be a string.");return this.emit("setString",e,t),this.#t.setItem(e,JSON.stringify({__string__:!0,value:t}))}getString(e){if(s(this.#e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#t.getItem(e);try{if(t=JSON.parse(t),!o(t)||!t.__string__||"string"!=typeof t.value)return null;t=t.value}catch{t=null}return"string"==typeof t?t:null}setNumber(e,t){if(s(this.#e),this.#s(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("number"!=typeof t)throw new TypeError("Value must be a number.");return this.emit("setNumber",e,t),this.#t.setItem(e,String(t))}getNumber(e){if(s(this.#e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#t.getItem(e);return"number"==typeof t||"string"==typeof t&&t.length>0&&(t=parseFloat(t),!Number.isNaN(t))?t:null}setBool(e,t){if(s(this.#e),this.#s(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("boolean"!=typeof t)throw new TypeError("Value must be a boolean.");return this.emit("setBool",e,t),this.#t.setItem(e,String(t))}getBool(e){if(s(this.#e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const t=this.#t.getItem(e);if("boolean"==typeof t)return t;if("string"==typeof t){if("true"===t)return!0;if("false"===t)return!1}return null}removeItem(e){if(s(this.#e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("removeItem",e),this.#t.removeItem(e)}clearLocalStorage(){return s(this.#e),this.#t.clear()}destroy(){this.#e||(window.removeEventListener("storage",this.#o),this.removeAllListeners(),this.#e=!0)}}c.registerJsonType(Map,(e,t)=>({__map__:!0,data:Array.from(e.entries()).map(([e,r])=>[e,t(r)])}),{check:e=>e.__map__,decode:(e,t)=>new Map(e.data.map(([e,r])=>[e,t(r)]))},!0),c.registerJsonType(Set,(e,t)=>({__set__:!0,data:Array.from(e).map(t)}),{check:e=>e.__set__,decode:(e,t)=>new Set(e.data.map(t))},!0),c.registerJsonType(Date,e=>({__date__:!0,value:e.toISOString()}),{check:e=>e.__date__,decode:e=>new Date(e.value)},!0),c.registerJsonType(RegExp,e=>({__regexp__:!0,source:e.source,flags:e.flags}),{check:e=>e.__regexp__,decode:e=>new RegExp(e.source,e.flags)},!0),c.registerJsonType("number",e=>({__number__:!0,value:e.toString()}),{check:e=>e.__number__,decode:e=>Number(e.value)},!0),c.registerJsonType("bigint",e=>({__bigint__:!0,value:e.toString()}),{check:e=>e.__bigint__,decode:e=>BigInt(e.value)},!0),c.registerJsonType("symbol",e=>({__symbol__:!0,key:Symbol.keyFor(e)??e.description??null}),{check:e=>e.__symbol__,decode:e=>{const t=e.key;return null!=t?Symbol.for(t):Symbol()}},!0);const u=c}};const t={};function r(n){const o=t[n];if(void 0!==o)return o.exports;const s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var n=0;n<t.length;){var o=t[n++],s=t[n++];r.o(e,o)?0===s&&n++:0===s?Object.defineProperty(e,o,{enumerable:!0,value:t[n++]}):Object.defineProperty(e,o,{enumerable:!0,get:s})}else for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.cjs=e=>{const t={exports:{}};return e.call(t.exports,t,t.exports),t.exports};let n=r(683);window.TinyLocalStorage=n.TinyLocalStorage})();
@@ -1 +1 @@
1
- (()=>{"use strict";var e={7(e){var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,e.exports.once=function(e,t){return new Promise(function(r,n){function o(r){e.removeListener(t,s),n(r)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",o),r([].slice.call(arguments))}y(e,t,s,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&y(e,"error",t,{once:!0})}(e,o)})},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var i=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function u(e,t,r,n){var o,s,i,u;if(a(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),i=s[t]),void 0===i)i=s[t]=r,++e._eventsCount;else if("function"==typeof i?i=s[t]=n?[r,i]:[i,r]:n?i.unshift(r):i.push(r),(o=l(e))>0&&i.length>o&&!i.warned){i.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=e,d.type=t,d.count=i.length,u=d,console&&console.warn&&console.warn(u)}return e}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=d.bind(n);return o.listener=r,n.wrapFn=o,o}function p(e,t,r){var n=e._events;if(void 0===n)return[];var o=n[t];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(o):m(o,o.length)}function c(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function m(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function y(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function o(s){n.once&&e.removeEventListener(t,o),r(s)})}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return i},set:function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");i=e}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return l(this)},s.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var o="error"===e,s=this._events;if(void 0!==s)o=o&&void 0===s.error;else if(!o)return!1;if(o){var i;if(t.length>0&&(i=t[0]),i instanceof Error)throw i;var a=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw a.context=i,a}var l=s[e];if(void 0===l)return!1;if("function"==typeof l)n(l,this,t);else{var u=l.length,d=m(l,u);for(r=0;r<u;++r)n(d[r],this,t)}return!0},s.prototype.addListener=function(e,t){return u(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return u(this,e,t,!0)},s.prototype.once=function(e,t){return a(t),this.on(e,h(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,h(this,e,t)),this},s.prototype.removeListener=function(e,t){var r,n,o,s,i;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){i=r[s].listener,o=s;break}if(o<0)return this;0===o?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,o),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,i||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var o,s=Object.keys(r);for(n=0;n<s.length;++n)"removeListener"!==(o=s[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return p(this,e,!0)},s.prototype.rawListeners=function(e){return p(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):c.call(e,t)},s.prototype.listenerCount=c,s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}}};const t={};function r(n){const o=t[n];if(void 0!==o)return o.exports;const s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var n=0;n<t.length;){var o=t[n++],s=t[n++];r.o(e,o)?0===s&&n++:0===s?Object.defineProperty(e,o,{enumerable:!0,value:t[n++]}):Object.defineProperty(e,o,{enumerable:!0,get:s})}else for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let n={};r.d(n,{TinyMediaPlayer:()=>b});var o=r(7);const s=(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}.`)},i=(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}.`)},a=(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}.`)},l=new Map;class u extends Error{constructor(e,t,r){if(s(e,"message"),s(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 d=async e=>{s(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)},h=(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}.`);s(t,"format");const r=e=>{const t=URL.createObjectURL(e),r=l.get(t);return l.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),s=new Uint8Array(o.length);for(let e=0;e<o.length;e++)s[e]=o.charCodeAt(e);return r(new Blob([s],{type:t}))}return"string"==typeof e?e:""},p=(e,t)=>{if(a(e,"common"),"boolean"!=typeof t)throw new TypeError('Expected "isPartial" to be a boolean.');const r=e=>t&&void 0===e,n=e=>r(e)||"string"==typeof e||null===e,o=(e,t)=>(i(t,"valueValidator"),!!r(e)||!(!Array.isArray(e)||!e.every(t)));if(!n(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!n(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!n(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!n(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(l=e.year,!r(l)&&"number"!=typeof l&&null!==l)throw new TypeError('Invalid metadata: "year" must be a number or null.');var l;if(!o(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!o(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!o(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!o(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!o(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!o(e.picture,e=>e&&"object"==typeof e&&(void 0===e.description||"string"==typeof e.description)&&(void 0===e.name||"string"==typeof e.name)&&(void 0===e.type||"string"==typeof e.type)&&"string"==typeof e.format&&(e.data instanceof Uint8Array||"string"==typeof e.data)))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');const u=(e,t)=>{if(s(e,"name"),!r(t)){if(null==t)throw new TypeError(`Invalid metadata: "${e}" is required.`);if("object"!=typeof t)throw new TypeError(`Invalid metadata: "${e}" must be an object or null.`);if("number"!=typeof t.no&&null!==t.no)throw new TypeError(`Invalid metadata: "${e}.no" must be a number or null.`);if("number"!=typeof t.of&&null!==t.of)throw new TypeError(`Invalid metadata: "${e}.of" must be a number or null.`)}};u("disk",e.disk),u("track",e.track)},c=e=>(a(e,"common"),p(e,!1)),m=e=>t=>{if(t)throw new Error(`This ${e} instance has been destroyed and can no longer be used.`)},y=m("BaseMediaAdapter");class f extends o.EventEmitter{constructor(){if(new.target===f)throw new Error("BaseMediaAdapter is an abstract class and cannot be instantiated directly.");super()}#e=!1;get destroyed(){return this.#e}canHandle(e){throw y(this.#e),new Error('Method "canHandle" must be implemented by the subclass.')}async play(e){throw y(this.#e),new Error('Method "play" must be implemented by the subclass.')}async pause(){throw y(this.#e),new Error('Method "pause" must be implemented by the subclass.')}async stop(){throw y(this.#e),new Error('Method "stop" must be implemented by the subclass.')}async seek(e){throw y(this.#e),new Error('Method "seek" must be implemented by the subclass.')}getCurrentTime(){throw y(this.#e),new Error('Method "getCurrentTime" must be implemented by the subclass.')}getTotalDuration(){throw y(this.#e),new Error('Method "getTotalDuration" must be implemented by the subclass.')}getRemainingTime(){throw y(this.#e),new Error('Method "getRemainingTime" must be implemented by the subclass.')}getPlaybackPercentage(){throw y(this.#e),new Error('Method "getPlaybackPercentage" must be implemented by the subclass.')}getTimeData(){throw y(this.#e),new Error('Method "getTimeData" must be implemented by the subclass.')}setVolume(e){throw y(this.#e),new Error('Method "setVolume" must be implemented by the subclass.')}getVolume(){throw y(this.#e),new Error('Method "getVolume" must be implemented by the subclass.')}destroy(){this.#e||(this.removeAllListeners(),this.#e=!0,this.emit("destroyed"))}}function g(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}const w=m("TinyMediaPlayer");class v extends o.EventEmitter{static BaseMediaAdapter=f;static#t="Unknown Artist";static get unknownArtist(){return v.#t}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must be a string or a function.");v.#t=e}static async parseContent(e,t,r,n,o){return(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={},l="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(a(t,"defaultMetadata"),a(r,"metadata"),i(n,"parseFile"),a(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 l&&"function"!=typeof l)throw new TypeError("unknownArtist must be a string or a function returning a string.");let c,m="";const y=(t,r)=>{if(s(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:m||(e instanceof HTMLMediaElement?e.src:"unknown")})},f=(t,r)=>{if(!(t instanceof Error))throw new TypeError('Expected "error" to be an Error.');s(r,"stage"),o.onError&&o.onError({error:t,url:m||(e instanceof HTMLMediaElement?e.src:"unknown"),stage:r})};try{y("INITIALIZING"),"string"==typeof e?(m=e,c=new Audio(m)):(c=e,m=c.src);try{await new Promise((e,t)=>{const r=e=>y("DOWNLOADING",e),n=()=>{s(),e(void 0)},o=e=>{s(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},s=()=>{c.removeEventListener("progress",r),c.removeEventListener("loadedmetadata",n),c.removeEventListener("error",o)};c.addEventListener("progress",r),c.addEventListener("loadedmetadata",n),c.addEventListener("error",o),c.readyState>=1&&(s(),e(void 0))}),y("METADATA_LOADED")}catch(e){throw new u(e instanceof Error?e.message:"UNKNOWN ERROR",m,"METADATA")}const g={id:r.id||await d(m),duration:Math.floor(1e3*c.duration),url:m,weight:r.weight??1};let w={};y("EXTRACTING_ID3");try{w=await(async(e,t)=>{s(e,"url"),i(t,"parseFile");try{const r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch audio file: ${r.status} ${r.statusText}`);const n=await r.blob(),o=await t(n);if(!o||"object"!=typeof o.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const s=o.common;return(e=>{a(e,"common"),p(e,!0)})(s),{title:s?.title??null,album:s?.album??null,albumartist:s?.albumartist??null,albumartists:s?.albumartists??[],genre:s?.genre??[],label:s?.label??[],composer:s?.composer??[],year:s?.year??null,artist:s?.artist??null,artists:s?.artists??[],disk:s?.disk?{no:s.disk.no,of:s.disk.of}:{no:null,of:null},track:s?.track?{no:s.track.no,of:s.track.of}:{no:null,of:null},picture:s?.picture?.map(e=>({...e,data:h(e.data,e.format)}))??[]}}catch(e){throw e}})(m,n)}catch(e){f(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${m}. Falling back to filename.`)}const v=e=>{s(e,"url");try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},b={...g,...t,...w,...r,title:w.title||r.title||v(m),artist:w.artist||r.artist||("string"==typeof l?l:String(l()))};return o.onProgress&&o.onProgress({status:"success",stage:"COMPLETE",url:m}),b}catch(e){if(e instanceof u)throw e;{const t=new u(e instanceof Error?e.message:"UNKNOWN ERROR",m,"INITIALIZING");throw f(t,"INITIALIZING"),t}}})(e,t,r,n,o,v.#t)}#e=!1;get destroyed(){return this.#e}#r=new Set;#n=new WeakMap;#o=[];#s=-1;#i="NONE";#a=!1;#l=!1;#u=1;#d;#h;#p;#c=!1;#m;#y;#f=null;#g=null;#w=300;get fadeVolumeSpeed(){return w(this.#e),this.#w}set fadeVolumeSpeed(e){if(w(this.#e),"number"!=typeof e)throw new TypeError("fadeVolumeSpeed must be a number.");if(e<0)throw new RangeError("fadeVolumeSpeed cannot be negative.");this.#w=e,this.emit("fadeVolumeSpeedChange",this.#w)}#v=2e3;get prevClickTimeoutDuration(){return w(this.#e),this.#v}set prevClickTimeoutDuration(e){if(w(this.#e),"number"!=typeof e)throw new TypeError("prevClickTimeoutDuration must be a number.");if(e<0)throw new RangeError("prevClickTimeoutDuration cannot be negative.");this.#v=e,this.emit("prevClickTimeoutDurationChange",this.#v)}get repeatCurrentOnPrev(){return w(this.#e),this.#p}set repeatCurrentOnPrev(e){if(w(this.#e),"boolean"!=typeof e)throw new TypeError("repeatCurrentOnPrev must be a boolean.");this.#p=e,this.emit("repeatCurrentOnPrevChange",this.#p)}get smoothPlayPauseVolume(){return w(this.#e),this.#m}set smoothPlayPauseVolume(e){if(w(this.#e),"boolean"!=typeof e)throw new TypeError("smoothPlayPauseVolume must be a boolean.");this.#m=e,this.emit("smoothPlayPauseVolumeChange",this.#m)}get smoothStopVolume(){return w(this.#e),this.#y}set smoothStopVolume(e){if(w(this.#e),"boolean"!=typeof e)throw new TypeError("smoothStopVolume must be a boolean.");this.#y=e,this.emit("smoothStopVolumeChange",this.#y)}constructor(e={}){if(super(),!g(e))throw new TypeError("Options must be a non-null object.");if(void 0!==e.persistVolume){if("boolean"!=typeof e.persistVolume)throw new TypeError("persistVolume must be a boolean.");this.#d=e.persistVolume}else this.#d=!1;if(void 0!==e.volumeStorageKey){if("string"!=typeof e.volumeStorageKey)throw new TypeError("volumeStorageKey must be a string.");this.#h=e.volumeStorageKey}else this.#h="tiny_media_player_volume";if(void 0!==e.repeatCurrentOnPrev){if("boolean"!=typeof e.repeatCurrentOnPrev)throw new TypeError("repeatCurrentOnPrev must be a boolean.");this.#p=e.repeatCurrentOnPrev}else this.#p=!1;if(void 0!==e.smoothPlayPauseVolume){if("boolean"!=typeof e.smoothPlayPauseVolume)throw new TypeError("smoothPlayPauseVolume must be a boolean.");this.#m=e.smoothPlayPauseVolume}else this.#m=!1;if(void 0!==e.smoothStopVolume){if("boolean"!=typeof e.smoothStopVolume)throw new TypeError("smoothStopVolume must be a boolean.");this.#y=e.smoothStopVolume}else this.#y=!1;this.#d&&this.#b()}#b(){try{if("undefined"!=typeof window&&window.localStorage){const e=window.localStorage.getItem(this.#h);if(null!==e){const t=parseFloat(e);!isNaN(t)&&t>=0&&t<=1&&(this.#u=t)}}}catch(e){console.warn("[TinyMediaPlayer] Failed to read volume from localStorage.",e)}}#E(){try{this.#d&&"undefined"!=typeof window&&window.localStorage&&window.localStorage.setItem(this.#h,this.#u.toString())}catch(e){console.warn("[TinyMediaPlayer] Failed to save volume to localStorage.",e)}}_getWeightedRandomIndex(){if(0===this.#o.length)return-1;if(1===this.#o.length)return 0;let e=0;for(let t=0;t<this.#o.length;t++){if(t===this.#s)continue;const r=this.#o[t];e+="number"==typeof r.weight&&r.weight>0?r.weight:1}let t=Math.random()*e;for(let e=0;e<this.#o.length;e++){if(e===this.#s)continue;const r=this.#o[e],n="number"==typeof r.weight&&r.weight>0?r.weight:1;if(t<n)return e;t-=n}return this.#s===this.#o.length-1?0:this.#o.length-1}async#T(e){this.#f&&this.#f.abort(),this.#f=new AbortController;const{signal:t}=this.#f,r=this.#A();if(!r)return;const n=r.getVolume(),o=performance.now(),s=this.#w;return new Promise(i=>{const a=l=>{if(t.aborted)return i();const u=l-o,d=Math.min(u/s,1),h=n+(e-n)*d,p=Math.max(0,Math.min(1,h));r.setVolume(p),d<1?requestAnimationFrame(a):(r.setVolume(e),i())};requestAnimationFrame(a)})}get playlist(){return w(this.#e),[...this.#o]}set playlist(e){if(w(this.#e),!Array.isArray(e))throw new TypeError("Playlist must be an array of MediaContent objects.");e.forEach(e=>c(e));const t=this.#l;let r=null;if(-1!==this.#s&&this.#o.length>0)try{r=this.#A()}catch(e){}this.#o=e,this.emit("playlistUpdate",this.playlist),0===this.#o.length?this.#s=-1:(this.#s>=this.#o.length||-1===this.#s)&&(this.#s=0),this.emit("trackChange",this.#s),t&&(async()=>{try{r&&await r.stop(),-1!==this.#s&&await this.play()}catch(e){console.warn("[TinyMediaPlayer] Background transition error on playlist update:",e)}})()}get currentIndex(){return w(this.#e),this.#s}set currentIndex(e){if(w(this.#e),"number"!=typeof e)throw new TypeError("Current index must be a number.");if(e<-1||e>=this.#o.length&&this.#o.length>0)throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);if(this.#s===e)return;const t=this.#l;let r=null;if(-1!==this.#s&&this.#o.length>0)try{r=this.#A()}catch(e){}this.#s=e,this.emit("trackChange",this.#s),t&&(async()=>{try{r&&await r.stop(),-1!==this.#s&&await this.play()}catch(e){console.warn("[TinyMediaPlayer] Background transition error on index update:",e)}})()}get loopMode(){return w(this.#e),this.#i}set loopMode(e){w(this.#e);const t=["NONE","TRACK","PLAYLIST"];if(!t.includes(e))throw new TypeError(`Loop mode must be one of: ${t.join(", ")}.`);this.#i=e,this.emit("loopModeChange",this.#i)}get isRandom(){return w(this.#e),this.#a}set isRandom(e){if(w(this.#e),"boolean"!=typeof e)throw new TypeError("Random mode state must be a boolean.");this.#a=e,this.emit("randomModeChange",this.#a)}get isPlaying(){return w(this.#e),this.#l}get volume(){return w(this.#e),this.#u}set volume(e){if(w(this.#e),"number"!=typeof e)throw new TypeError("Volume must be a number.");if(e<0||e>1)throw new RangeError("Volume must be tightly constrained between 0.0 and 1.0.");if(this.#f&&this.#f.abort(),this.#u=e,this.#E(),this.emit("volumeChange",this.#u),-1!==this.#s&&this.#o.length>0)try{const e=this.#A();e&&e.setVolume(this.#u)}catch(e){}}get persistVolume(){return w(this.#e),this.#d}set persistVolume(e){if(w(this.#e),"boolean"!=typeof e)throw new TypeError("Persist volume parameter must be a boolean.");this.#d=e,e&&this.#E()}get volumeStorageKey(){return w(this.#e),this.#h}set volumeStorageKey(e){if(w(this.#e),"string"!=typeof e)throw new TypeError("Volume storage key must be a string.");if(""===e.trim())throw new TypeError("Volume storage key cannot be an empty string.");const t=this.#h;this.#h=e;try{this.#d&&"undefined"!=typeof window&&window.localStorage&&(window.localStorage.removeItem(t),this.#E())}catch(e){console.warn("[TinyMediaPlayer] Failed to migrate volume storage key.",e)}}get adapters(){return Array.from(this.#r)}get adaptersSize(){return this.#r.size}static#P=["timeupdate","ended"];static get defaultAdapterEventNames(){return structuredClone(v.#P)}static set defaultAdapterEventNames(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError("TinyMediaPlayer.defaultAdapterEventNames must be an array of strings.");v.#P=[...e]}#x=new Set(v.defaultAdapterEventNames);#I(e){const t=this.#n.get(e);t&&(this.#x.forEach(r=>{const n=t.get(r);n&&e.off(r,n)}),t.clear(),this.#n.delete(e))}registerAdapter(e){if(w(this.#e),!(e instanceof f))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");const t=new Map;this.#n.set(e,t),this.#x.forEach(t=>{this.#k(e,t)}),this.#r.add(e)}removeAdapter(e){if(w(this.#e),!(e instanceof f))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");return this.#I(e),this.#r.delete(e)}destroyAdapter(e){if(w(this.#e),!(e instanceof f))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");this.#I(e);const t=this.#r.delete(e);return t&&e.destroy(),t}hasAdapter(e){if(w(this.#e),!(e instanceof f))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");return this.#r.has(e)}destroyAllAdapters(){w(this.#e),this.#r.forEach(e=>{this.#I(e),e.destroy()}),this.#r.clear()}clearAdapters(){w(this.#e),this.#r.forEach(e=>this.#I(e)),this.#r.clear()}getMediaAdapter(e){if(!g(e))throw new TypeError("Content must be a valid object.");for(const t of this.#r.values())if(t.canHandle(e))return t;return null}#A(){if(-1===this.#s||0===this.#o.length)return null;const e=this.#o[this.#s],t=this.getMediaAdapter(e);if(t)return t;throw new Error(`No compatible adapter found for content ID: ${e.id}.`)}addAdapterEvent(e){if(w(this.#e),"string"!=typeof e)throw new TypeError("Event name must be a string.");this.#x.has(e)||(this.#x.add(e),this.#r.forEach(t=>{this.#k(t,e)}))}removeAdapterEvent(e){if(w(this.#e),"string"!=typeof e)throw new TypeError("Event name must be a string.");this.#x.has(e)&&(this.#x.delete(e),this.#r.forEach(t=>{this.#C(t,e)}))}resetAdapterEvents(){w(this.#e);const e=v.defaultAdapterEventNames,t=Array.from(this.#x);for(const r of t)e.includes(r)||this.removeAdapterEvent(r);for(const t of e)this.#x.has(t)||this.addAdapterEvent(t)}#k(e,t){const r=this.#n.get(e);if(!r)return;const n=(...e)=>{this.#e||this.emit(t,...e)};e.on(t,n),r.set(t,n)}#C(e,t){const r=this.#n.get(e);if(!r)return;const n=r.get(t);n&&(e.off(t,n),r.delete(t))}addTrack(e){if(w(this.#e),!g(e)||"string"!=typeof e.url)throw new TypeError("Track content must be a valid MediaContent object containing a URL.");const t={id:"",title:"",artist:"",url:"",duration:0,weight:1,title:null,album:null,albumartist:null,albumartists:[],genre:[],label:[],composer:[],year:null,artist:null,artists:[],disk:{no:null,of:null},track:{no:null,of:null},picture:[],...e};c(t);const r=this.#o.push(t);return-1===this.#s&&(this.#s=0,this.emit("trackChange",this.#s)),this.emit("playlistUpdate",this.playlist),r}existsTrack(e){if(w(this.#e),"number"!=typeof e)throw new TypeError("Index must be a number.");return e>=0&&e<this.#o.length}getTrack(e){if(w(this.#e),"number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);return this.#o[e]}async removeTrack(e){if(w(this.#e),"number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);e===this.#s?(await this.stop(),this.#o.splice(e,1),0===this.#o.length?this.#s=-1:this.#s>=this.#o.length&&(this.#s=0),this.emit("trackChange",this.#s)):(this.#o.splice(e,1),e<this.#s&&(this.#s-=1,this.emit("trackChange",this.#s))),this.emit("playlistUpdate",this.playlist)}searchTrack(e){if(w(this.#e),"string"!=typeof e&&"function"!=typeof e)throw new TypeError("Search query must be a string or a boolean evaluation function.");const t=[];for(let r=0;r<this.#o.length;r++){const n=this.#o[r];let o=!1;if("function"==typeof e)o=Boolean(e(n));else{const t=e.toLowerCase(),r=n.title&&n.title.toLowerCase().includes(t),s=n.artist&&n.artist.toLowerCase().includes(t),i=n.album&&n.album.toLowerCase().includes(t);o=Boolean(r||s||i)}o&&t.push({track:n,index:r})}return t}async clearPlaylist(){w(this.#e),await this.stop(),this.#o=[],this.#s=-1,this.emit("playlistUpdate",this.playlist),this.emit("trackChange",this.#s)}async play(){w(this.#e);const e=this.#A();e&&(this.#m?await this.#T(this.#u):e.setVolume(this.#u),await e.play(this.#o[this.#s]),this.#l=!0,this.emit("play",this.#s))}async pause(){w(this.#e);const e=this.#A();e&&(this.#m&&await this.#T(0),await e.pause(),this.#l=!1,this.emit("pause",this.#s))}async stop(){w(this.#e);const e=this.#A();e&&(this.#y&&await this.#T(0),await e.stop(),this.#l=!1,this.emit("stop",this.#s))}async next(){if(w(this.#e),0!==this.#o.length)if(await this.stop(),"TRACK"!==this.#i){if(this.#a)this.#s=this._getWeightedRandomIndex();else{let e=this.#s+1;if(e>=this.#o.length){if("PLAYLIST"!==this.#i)return;e=0}this.#s=e}this.emit("trackChange",this.#s),await this.play()}else await this.play()}async prev(){if(w(this.#e),0!==this.#o.length){if(this.#p&&!this.#c)return this.#c=!0,this.#g&&clearTimeout(this.#g),this.#g=setTimeout(()=>{this.#c=!1,this.#g=null},2e3),await this.stop(),void await this.play();if(this.#g&&(clearTimeout(this.#g),this.#g=null),this.#c=!1,await this.stop(),this.#a)this.#s=this._getWeightedRandomIndex();else{let e=this.#s-1;if(e<0){if("PLAYLIST"!==this.#i)return;e=this.#o.length-1}this.#s=e}this.emit("trackChange",this.#s),await this.play()}}async seek(e){if(w(this.#e),"number"!=typeof e)throw new TypeError("Seek time must be a number in milliseconds.");if(e<0)throw new RangeError("Seek time cannot be negative.");const t=this.#A();t&&(await t.seek(e),this.emit("seek",e))}async step(e){if(w(this.#e),"number"!=typeof e)throw new TypeError("Step amount must be a number in milliseconds.");const t=this.#A();if(!t)return;let r=t.getCurrentTime()+e;r<0&&(r=0),await this.seek(r)}getCurrentTime(){w(this.#e);try{const e=this.#A();return e?e.getCurrentTime():0}catch{return 0}}getTotalDuration(){w(this.#e);try{const e=this.#A();return e?e.getTotalDuration():0}catch{return 0}}getRemainingTime(){w(this.#e);try{const e=this.#A();return e?e.getRemainingTime():0}catch{return 0}}getPlaybackPercentage(){w(this.#e);try{const e=this.#A();return e?e.getPlaybackPercentage():0}catch{return 0}}async destroy(){if(!this.#e){try{this.#l&&await this.stop()}catch(e){console.warn("[TinyMediaPlayer] Non-fatal error during playback termination:",e)}this.#g&&clearTimeout(this.#g),this.#o=[],this.#s=-1,this.#l=!1,this.#c=!1,this.destroyAllAdapters(),this.removeAllListeners(),this.#x.clear(),this.#e=!0,this.emit("destroyed")}}}const b=v;window.TinyMediaPlayer=n.TinyMediaPlayer})();
1
+ (()=>{"use strict";var e={843(e,t,r){r.d(t,{TinyMediaPlayer:()=>v});var n=r.cjs(function(e,t){var r,n="object"==typeof Reflect?Reflect:null,o=n&&"function"==typeof n.apply?n.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};r=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}e.exports=i,e.exports.once=function(e,t){return new Promise(function(r,n){function o(r){e.removeListener(t,s),n(r)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",o),r([].slice.call(arguments))}f(e,t,s,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&f(e,"error",t,{once:!0})}(e,o)})},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var a=10;function l(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function d(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function u(e,t,r,n){var o,s,i,a;if(l(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),i=s[t]),void 0===i)i=s[t]=r,++e._eventsCount;else if("function"==typeof i?i=s[t]=n?[r,i]:[i,r]:n?i.unshift(r):i.push(r),(o=d(e))>0&&i.length>o&&!i.warned){i.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=i.length,a=u,console&&console.warn&&console.warn(a)}return e}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=h.bind(n);return o.listener=r,n.wrapFn=o,o}function c(e,t,r){var n=e._events;if(void 0===n)return[];var o=n[t];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(o):y(o,o.length)}function m(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function y(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function f(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function o(s){n.once&&e.removeEventListener(t,o),r(s)})}}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),i.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},i.prototype.getMaxListeners=function(){return d(this)},i.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,s=this._events;if(void 0!==s)n=n&&void 0===s.error;else if(!n)return!1;if(n){var i;if(t.length>0&&(i=t[0]),i instanceof Error)throw i;var a=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw a.context=i,a}var l=s[e];if(void 0===l)return!1;if("function"==typeof l)o(l,this,t);else{var d=l.length,u=y(l,d);for(r=0;r<d;++r)o(u[r],this,t)}return!0},i.prototype.addListener=function(e,t){return u(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return u(this,e,t,!0)},i.prototype.once=function(e,t){return l(t),this.on(e,p(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,p(this,e,t)),this},i.prototype.removeListener=function(e,t){var r,n,o,s,i;if(l(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){i=r[s].listener,o=s;break}if(o<0)return this;0===o?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,o),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,i||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var o,s=Object.keys(r);for(n=0;n<s.length;++n)"removeListener"!==(o=s[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},i.prototype.listeners=function(e){return c(this,e,!0)},i.prototype.rawListeners=function(e){return c(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},i.prototype.listenerCount=m,i.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}});const o=(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}.`)},s=(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}.`)},i=(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}.`)},a=new Map;class l extends Error{constructor(e,t,r){if(o(e,"message"),o(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 d=async e=>{o(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)},u=(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}.`);o(t,"format");const r=e=>{const t=URL.createObjectURL(e),r=a.get(t);return a.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),s=new Uint8Array(o.length);for(let e=0;e<o.length;e++)s[e]=o.charCodeAt(e);return r(new Blob([s],{type:t}))}return"string"==typeof e?e:""},h=(e,t)=>{if(i(e,"common"),"boolean"!=typeof t)throw new TypeError('Expected "isPartial" to be a boolean.');const r=e=>t&&void 0===e,n=e=>r(e)||"string"==typeof e||null===e,a=(e,t)=>(s(t,"valueValidator"),!!r(e)||!(!Array.isArray(e)||!e.every(t)));if(!n(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!n(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!n(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!n(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(l=e.year,!r(l)&&"number"!=typeof l&&null!==l)throw new TypeError('Invalid metadata: "year" must be a number or null.');var l;if(!a(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!a(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!a(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!a(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!a(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!a(e.picture,e=>e&&"object"==typeof e&&(void 0===e.description||"string"==typeof e.description)&&(void 0===e.name||"string"==typeof e.name)&&(void 0===e.type||"string"==typeof e.type)&&"string"==typeof e.format&&(e.data instanceof Uint8Array||"string"==typeof e.data)))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');const d=(e,t)=>{if(o(e,"name"),!r(t)){if(null==t)throw new TypeError(`Invalid metadata: "${e}" is required.`);if("object"!=typeof t)throw new TypeError(`Invalid metadata: "${e}" must be an object or null.`);if("number"!=typeof t.no&&null!==t.no)throw new TypeError(`Invalid metadata: "${e}.no" must be a number or null.`);if("number"!=typeof t.of&&null!==t.of)throw new TypeError(`Invalid metadata: "${e}.of" must be a number or null.`)}};d("disk",e.disk),d("track",e.track)},p=e=>(i(e,"common"),h(e,!1)),c=e=>t=>{if(t)throw new Error(`This ${e} instance has been destroyed and can no longer be used.`)},m=c("BaseMediaAdapter");class y extends n.EventEmitter{constructor(){if(new.target===y)throw new Error("BaseMediaAdapter is an abstract class and cannot be instantiated directly.");super()}#e=!1;get destroyed(){return this.#e}static canHandle(e){throw new Error('Method "canHandle" must be implemented by the subclass.')}isReady(){throw m(this.#e),new Error('Method "isReady" must be implemented by the subclass.')}async waitIsReady(){throw m(this.#e),new Error('Method "waitIsReady" must be implemented by the subclass.')}canHandle(e){return m(this.#e),y.canHandle(e)}async play(e){throw m(this.#e),new Error('Method "play" must be implemented by the subclass.')}async pause(){throw m(this.#e),new Error('Method "pause" must be implemented by the subclass.')}async stop(){throw m(this.#e),new Error('Method "stop" must be implemented by the subclass.')}async seek(e){throw m(this.#e),new Error('Method "seek" must be implemented by the subclass.')}getCurrentTime(){throw m(this.#e),new Error('Method "getCurrentTime" must be implemented by the subclass.')}getTotalDuration(){throw m(this.#e),new Error('Method "getTotalDuration" must be implemented by the subclass.')}getRemainingTime(){throw m(this.#e),new Error('Method "getRemainingTime" must be implemented by the subclass.')}getPlaybackPercentage(){throw m(this.#e),new Error('Method "getPlaybackPercentage" must be implemented by the subclass.')}getTimeData(){throw m(this.#e),new Error('Method "getTimeData" must be implemented by the subclass.')}setVolume(e){throw m(this.#e),new Error('Method "setVolume" must be implemented by the subclass.')}getVolume(){throw m(this.#e),new Error('Method "getVolume" must be implemented by the subclass.')}async getContentData(){throw m(this.#e),new Error('Method "getContentData" must be implemented by the subclass.')}destroy(){this.#e||(this.removeAllListeners(),this.#e=!0,this.emit("destroyed"))}}function f(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}const w=c("TinyMediaPlayer");class g extends n.EventEmitter{static BaseMediaAdapter=y;static#t="Unknown Artist";static get unknownArtist(){return g.#t}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must be a string or a function.");g.#t=e}static async parseContent(e,t,r,n,a){return(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.")))},a={},p="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(i(t,"defaultMetadata"),i(r,"metadata"),s(n,"parseFile"),i(a,"callbacks"),a.onProgress&&"function"!=typeof a.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(a.onError&&"function"!=typeof a.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof p&&"function"!=typeof p)throw new TypeError("unknownArtist must be a string or a function returning a string.");let c,m="";const y=(t,r)=>{if(o(t,"stage"),void 0!==r&&!(r instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');a.onProgress&&a.onProgress({event:r,status:"loading",stage:t,url:m||(e instanceof HTMLMediaElement?e.src:"unknown")})},f=(t,r)=>{if(!(t instanceof Error))throw new TypeError('Expected "error" to be an Error.');o(r,"stage"),a.onError&&a.onError({error:t,url:m||(e instanceof HTMLMediaElement?e.src:"unknown"),stage:r})};try{y("INITIALIZING"),"string"==typeof e?(m=e,c=new Audio(m)):(c=e,m=c.src);try{await new Promise((e,t)=>{const r=e=>y("DOWNLOADING",e),n=()=>{s(),e(void 0)},o=e=>{s(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},s=()=>{c.removeEventListener("progress",r),c.removeEventListener("loadedmetadata",n),c.removeEventListener("error",o)};c.addEventListener("progress",r),c.addEventListener("loadedmetadata",n),c.addEventListener("error",o),c.readyState>=1&&(s(),e(void 0))}),y("METADATA_LOADED")}catch(e){throw new l(e instanceof Error?e.message:"UNKNOWN ERROR",m,"METADATA")}const w={id:r.id||await d(m),duration:Math.floor(1e3*c.duration),url:m,weight:r.weight??1};let g={};y("EXTRACTING_ID3");try{g=await(async(e,t)=>{o(e,"url"),s(t,"parseFile");try{const r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch audio file: ${r.status} ${r.statusText}`);const n=await r.blob(),o=await t(n);if(!o||"object"!=typeof o.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const s=o.common;return(e=>{i(e,"common"),h(e,!0)})(s),{title:s?.title??null,album:s?.album??null,albumartist:s?.albumartist??null,albumartists:s?.albumartists??[],genre:s?.genre??[],label:s?.label??[],composer:s?.composer??[],year:s?.year??null,artist:s?.artist??null,artists:s?.artists??[],disk:s?.disk?{no:s.disk.no,of:s.disk.of}:{no:null,of:null},track:s?.track?{no:s.track.no,of:s.track.of}:{no:null,of:null},picture:s?.picture?.map(e=>({...e,data:u(e.data,e.format)}))??[]}}catch(e){throw e}})(m,n)}catch(e){f(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${m}. Falling back to filename.`)}const v=e=>{o(e,"url");try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},b={...w,...t,...g,...r,title:g.title||r.title||v(m),artist:g.artist||r.artist||("string"==typeof p?p:String(p()))};return a.onProgress&&a.onProgress({status:"success",stage:"COMPLETE",url:m}),b}catch(e){if(e instanceof l)throw e;{const t=new l(e instanceof Error?e.message:"UNKNOWN ERROR",m,"INITIALIZING");throw f(t,"INITIALIZING"),t}}})(e,t,r,n,a,g.#t)}#e=!1;get destroyed(){return this.#e}#r=new Set;#n=new WeakMap;#o=[];#s=-1;#i="NONE";#a=!1;#l=!1;#d=1;#u;#h;#p;#c=!1;#m;#y;#f=null;#w=null;#g=300;get fadeVolumeSpeed(){return w(this.#e),this.#g}set fadeVolumeSpeed(e){if(w(this.#e),"number"!=typeof e)throw new TypeError("fadeVolumeSpeed must be a number.");if(e<0)throw new RangeError("fadeVolumeSpeed cannot be negative.");this.#g=e,this.emit("fadeVolumeSpeedChange",this.#g)}#v=2e3;get prevClickTimeoutDuration(){return w(this.#e),this.#v}set prevClickTimeoutDuration(e){if(w(this.#e),"number"!=typeof e)throw new TypeError("prevClickTimeoutDuration must be a number.");if(e<0)throw new RangeError("prevClickTimeoutDuration cannot be negative.");this.#v=e,this.emit("prevClickTimeoutDurationChange",this.#v)}get repeatCurrentOnPrev(){return w(this.#e),this.#p}set repeatCurrentOnPrev(e){if(w(this.#e),"boolean"!=typeof e)throw new TypeError("repeatCurrentOnPrev must be a boolean.");this.#p=e,this.emit("repeatCurrentOnPrevChange",this.#p)}get smoothPlayPauseVolume(){return w(this.#e),this.#m}set smoothPlayPauseVolume(e){if(w(this.#e),"boolean"!=typeof e)throw new TypeError("smoothPlayPauseVolume must be a boolean.");this.#m=e,this.emit("smoothPlayPauseVolumeChange",this.#m)}get smoothStopVolume(){return w(this.#e),this.#y}set smoothStopVolume(e){if(w(this.#e),"boolean"!=typeof e)throw new TypeError("smoothStopVolume must be a boolean.");this.#y=e,this.emit("smoothStopVolumeChange",this.#y)}constructor(e={}){if(super(),!f(e))throw new TypeError("Options must be a non-null object.");if(void 0!==e.persistVolume){if("boolean"!=typeof e.persistVolume)throw new TypeError("persistVolume must be a boolean.");this.#u=e.persistVolume}else this.#u=!1;if(void 0!==e.volumeStorageKey){if("string"!=typeof e.volumeStorageKey)throw new TypeError("volumeStorageKey must be a string.");this.#h=e.volumeStorageKey}else this.#h="tiny_media_player_volume";if(void 0!==e.repeatCurrentOnPrev){if("boolean"!=typeof e.repeatCurrentOnPrev)throw new TypeError("repeatCurrentOnPrev must be a boolean.");this.#p=e.repeatCurrentOnPrev}else this.#p=!1;if(void 0!==e.smoothPlayPauseVolume){if("boolean"!=typeof e.smoothPlayPauseVolume)throw new TypeError("smoothPlayPauseVolume must be a boolean.");this.#m=e.smoothPlayPauseVolume}else this.#m=!1;if(void 0!==e.smoothStopVolume){if("boolean"!=typeof e.smoothStopVolume)throw new TypeError("smoothStopVolume must be a boolean.");this.#y=e.smoothStopVolume}else this.#y=!1;this.#u&&this.#b()}#b(){try{if("undefined"!=typeof window&&window.localStorage){const e=window.localStorage.getItem(this.#h);if(null!==e){const t=parseFloat(e);!isNaN(t)&&t>=0&&t<=1&&(this.#d=t)}}}catch(e){console.warn("[TinyMediaPlayer] Failed to read volume from localStorage.",e)}}#E(){try{this.#u&&"undefined"!=typeof window&&window.localStorage&&window.localStorage.setItem(this.#h,this.#d.toString())}catch(e){console.warn("[TinyMediaPlayer] Failed to save volume to localStorage.",e)}}_getWeightedRandomIndex(){if(0===this.#o.length)return-1;if(1===this.#o.length)return 0;let e=0;for(let t=0;t<this.#o.length;t++){if(t===this.#s)continue;const r=this.#o[t];e+="number"==typeof r.weight&&r.weight>0?r.weight:1}let t=Math.random()*e;for(let e=0;e<this.#o.length;e++){if(e===this.#s)continue;const r=this.#o[e],n="number"==typeof r.weight&&r.weight>0?r.weight:1;if(t<n)return e;t-=n}return this.#s===this.#o.length-1?0:this.#o.length-1}async#T(e){this.#f&&this.#f.abort(),this.#f=new AbortController;const{signal:t}=this.#f,r=this.#A();if(!r)return;const n=r.getVolume(),o=performance.now(),s=this.#g;return new Promise(i=>{const a=l=>{if(t.aborted)return i();const d=l-o,u=Math.min(d/s,1),h=n+(e-n)*u,p=Math.max(0,Math.min(1,h));r.setVolume(p),u<1?requestAnimationFrame(a):(r.setVolume(e),i())};requestAnimationFrame(a)})}get playlist(){return w(this.#e),[...this.#o]}set playlist(e){if(w(this.#e),!Array.isArray(e))throw new TypeError("Playlist must be an array of MediaContent objects.");e.forEach(e=>p(e));const t=this.#l;let r=null;if(-1!==this.#s&&this.#o.length>0)try{r=this.#A()}catch(e){}this.#o=e,this.emit("playlistUpdate",this.playlist),0===this.#o.length?this.#s=-1:(this.#s>=this.#o.length||-1===this.#s)&&(this.#s=0),this.emit("trackChange",this.#s),t&&(async()=>{try{r&&await r.stop(),-1!==this.#s&&await this.play()}catch(e){console.warn("[TinyMediaPlayer] Background transition error on playlist update:",e)}})()}get currentIndex(){return w(this.#e),this.#s}set currentIndex(e){if(w(this.#e),"number"!=typeof e)throw new TypeError("Current index must be a number.");if(e<-1||e>=this.#o.length&&this.#o.length>0)throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);if(this.#s===e)return;const t=this.#l;let r=null;if(-1!==this.#s&&this.#o.length>0)try{r=this.#A()}catch(e){}this.#s=e,this.emit("trackChange",this.#s),t&&(async()=>{try{r&&await r.stop(),-1!==this.#s&&await this.play()}catch(e){console.warn("[TinyMediaPlayer] Background transition error on index update:",e)}})()}get loopMode(){return w(this.#e),this.#i}set loopMode(e){w(this.#e);const t=["NONE","TRACK","PLAYLIST"];if(!t.includes(e))throw new TypeError(`Loop mode must be one of: ${t.join(", ")}.`);this.#i=e,this.emit("loopModeChange",this.#i)}get isRandom(){return w(this.#e),this.#a}set isRandom(e){if(w(this.#e),"boolean"!=typeof e)throw new TypeError("Random mode state must be a boolean.");this.#a=e,this.emit("randomModeChange",this.#a)}get isPlaying(){return w(this.#e),this.#l}get volume(){return w(this.#e),this.#d}set volume(e){if(w(this.#e),"number"!=typeof e)throw new TypeError("Volume must be a number.");if(e<0||e>1)throw new RangeError("Volume must be tightly constrained between 0.0 and 1.0.");if(this.#f&&this.#f.abort(),this.#d=e,this.#E(),this.emit("volumeChange",this.#d),-1!==this.#s&&this.#o.length>0)try{const e=this.#A();e&&e.setVolume(this.#d)}catch(e){}}get persistVolume(){return w(this.#e),this.#u}set persistVolume(e){if(w(this.#e),"boolean"!=typeof e)throw new TypeError("Persist volume parameter must be a boolean.");this.#u=e,e&&this.#E()}get volumeStorageKey(){return w(this.#e),this.#h}set volumeStorageKey(e){if(w(this.#e),"string"!=typeof e)throw new TypeError("Volume storage key must be a string.");if(""===e.trim())throw new TypeError("Volume storage key cannot be an empty string.");const t=this.#h;this.#h=e;try{this.#u&&"undefined"!=typeof window&&window.localStorage&&(window.localStorage.removeItem(t),this.#E())}catch(e){console.warn("[TinyMediaPlayer] Failed to migrate volume storage key.",e)}}get adapters(){return Array.from(this.#r)}get adaptersSize(){return this.#r.size}static#x=["timeupdate","ended"];static get defaultAdapterEventNames(){return structuredClone(g.#x)}static set defaultAdapterEventNames(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError("TinyMediaPlayer.defaultAdapterEventNames must be an array of strings.");g.#x=[...e]}#I=new Set(g.defaultAdapterEventNames);#P(e){const t=this.#n.get(e);t&&(this.#I.forEach(r=>{const n=t.get(r);n&&e.off(r,n)}),t.clear(),this.#n.delete(e))}registerAdapter(e){if(w(this.#e),!(e instanceof y))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");const t=new Map;this.#n.set(e,t),this.#I.forEach(t=>{this.#C(e,t)}),this.#r.add(e)}removeAdapter(e){if(w(this.#e),!(e instanceof y))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");return this.#P(e),this.#r.delete(e)}destroyAdapter(e){if(w(this.#e),!(e instanceof y))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");this.#P(e);const t=this.#r.delete(e);return t&&e.destroy(),t}hasAdapter(e){if(w(this.#e),!(e instanceof y))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");return this.#r.has(e)}destroyAllAdapters(){w(this.#e),this.#r.forEach(e=>{this.#P(e),e.destroy()}),this.#r.clear()}clearAdapters(){w(this.#e),this.#r.forEach(e=>this.#P(e)),this.#r.clear()}getMediaAdapter(e){if(!f(e))throw new TypeError("Content must be a valid object.");for(const t of this.#r.values())if(t.canHandle(e))return t;return null}#A(){if(-1===this.#s||0===this.#o.length)return null;const e=this.#o[this.#s],t=this.getMediaAdapter(e);if(t)return t;throw new Error(`No compatible adapter found for content ID: ${e.id}.`)}addAdapterEvent(e){if(w(this.#e),"string"!=typeof e)throw new TypeError("Event name must be a string.");this.#I.has(e)||(this.#I.add(e),this.#r.forEach(t=>{this.#C(t,e)}))}removeAdapterEvent(e){if(w(this.#e),"string"!=typeof e)throw new TypeError("Event name must be a string.");this.#I.has(e)&&(this.#I.delete(e),this.#r.forEach(t=>{this.#k(t,e)}))}resetAdapterEvents(){w(this.#e);const e=g.defaultAdapterEventNames,t=Array.from(this.#I);for(const r of t)e.includes(r)||this.removeAdapterEvent(r);for(const t of e)this.#I.has(t)||this.addAdapterEvent(t)}#C(e,t){const r=this.#n.get(e);if(!r)return;const n=(...e)=>{this.#e||this.emit(t,...e)};e.on(t,n),r.set(t,n)}#k(e,t){const r=this.#n.get(e);if(!r)return;const n=r.get(t);n&&(e.off(t,n),r.delete(t))}addTrack(e){if(w(this.#e),!f(e)||"string"!=typeof e.url)throw new TypeError("Track content must be a valid MediaContent object containing a URL.");const t={id:"",title:"",artist:"",url:"",duration:0,weight:1,title:null,album:null,albumartist:null,albumartists:[],genre:[],label:[],composer:[],year:null,artist:null,artists:[],disk:{no:null,of:null},track:{no:null,of:null},picture:[],...e};p(t);const r=this.#o.push(t);return-1===this.#s&&(this.#s=0,this.emit("trackChange",this.#s)),this.emit("playlistUpdate",this.playlist),r}existsTrack(e){if(w(this.#e),"number"!=typeof e)throw new TypeError("Index must be a number.");return e>=0&&e<this.#o.length}getTrack(e){if(w(this.#e),"number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);return this.#o[e]}async removeTrack(e){if(w(this.#e),"number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);e===this.#s?(await this.stop(),this.#o.splice(e,1),0===this.#o.length?this.#s=-1:this.#s>=this.#o.length&&(this.#s=0),this.emit("trackChange",this.#s)):(this.#o.splice(e,1),e<this.#s&&(this.#s-=1,this.emit("trackChange",this.#s))),this.emit("playlistUpdate",this.playlist)}searchTrack(e){if(w(this.#e),"string"!=typeof e&&"function"!=typeof e)throw new TypeError("Search query must be a string or a boolean evaluation function.");const t=[];for(let r=0;r<this.#o.length;r++){const n=this.#o[r];let o=!1;if("function"==typeof e)o=Boolean(e(n));else{const t=e.toLowerCase(),r=n.title&&n.title.toLowerCase().includes(t),s=n.artist&&n.artist.toLowerCase().includes(t),i=n.album&&n.album.toLowerCase().includes(t);o=Boolean(r||s||i)}o&&t.push({track:n,index:r})}return t}async clearPlaylist(){w(this.#e),await this.stop(),this.#o=[],this.#s=-1,this.emit("playlistUpdate",this.playlist),this.emit("trackChange",this.#s)}async play(){w(this.#e);const e=this.#A();e&&(this.#m?await this.#T(this.#d):e.setVolume(this.#d),await e.play(this.#o[this.#s]),this.#l=!0,this.emit("play",this.#s))}async pause(){w(this.#e);const e=this.#A();e&&(this.#m&&await this.#T(0),await e.pause(),this.#l=!1,this.emit("pause",this.#s))}async stop(){w(this.#e);const e=this.#A();e&&(this.#y&&await this.#T(0),await e.stop(),this.#l=!1,this.emit("stop",this.#s))}async next(){if(w(this.#e),0!==this.#o.length)if(await this.stop(),"TRACK"!==this.#i){if(this.#a)this.#s=this._getWeightedRandomIndex();else{let e=this.#s+1;if(e>=this.#o.length){if("PLAYLIST"!==this.#i)return;e=0}this.#s=e}this.emit("trackChange",this.#s),await this.play()}else await this.play()}async prev(){if(w(this.#e),0!==this.#o.length){if(this.#p&&!this.#c)return this.#c=!0,this.#w&&clearTimeout(this.#w),this.#w=setTimeout(()=>{this.#c=!1,this.#w=null},2e3),await this.stop(),void await this.play();if(this.#w&&(clearTimeout(this.#w),this.#w=null),this.#c=!1,await this.stop(),this.#a)this.#s=this._getWeightedRandomIndex();else{let e=this.#s-1;if(e<0){if("PLAYLIST"!==this.#i)return;e=this.#o.length-1}this.#s=e}this.emit("trackChange",this.#s),await this.play()}}async seek(e){if(w(this.#e),"number"!=typeof e)throw new TypeError("Seek time must be a number in milliseconds.");if(e<0)throw new RangeError("Seek time cannot be negative.");const t=this.#A();t&&(await t.seek(e),this.emit("seek",e))}async step(e){if(w(this.#e),"number"!=typeof e)throw new TypeError("Step amount must be a number in milliseconds.");const t=this.#A();if(!t)return;let r=t.getCurrentTime()+e;r<0&&(r=0),await this.seek(r)}getCurrentTime(){w(this.#e);try{const e=this.#A();return e?e.getCurrentTime():0}catch{return 0}}getTotalDuration(){w(this.#e);try{const e=this.#A();return e?e.getTotalDuration():0}catch{return 0}}getRemainingTime(){w(this.#e);try{const e=this.#A();return e?e.getRemainingTime():0}catch{return 0}}getPlaybackPercentage(){w(this.#e);try{const e=this.#A();return e?e.getPlaybackPercentage():0}catch{return 0}}async getContentData(){w(this.#e);const e={id:"",createdAt:"",artistId:"",artistName:"",description:"",title:"",duration:0,avatar:"",url:""};try{const t=this.#A();return t?t.getContentData():e}catch{return e}}async waitIsReady(){w(this.#e);const e=this.#A();if(e)return e.waitIsReady()}async destroy(){if(!this.#e){try{this.#l&&await this.stop()}catch(e){console.warn("[TinyMediaPlayer] Non-fatal error during playback termination:",e)}this.#w&&clearTimeout(this.#w),this.#o=[],this.#s=-1,this.#l=!1,this.#c=!1,this.destroyAllAdapters(),this.removeAllListeners(),this.#I.clear(),this.#e=!0,this.emit("destroyed")}}}const v=g}};const t={};function r(n){const o=t[n];if(void 0!==o)return o.exports;const s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var n=0;n<t.length;){var o=t[n++],s=t[n++];r.o(e,o)?0===s&&n++:0===s?Object.defineProperty(e,o,{enumerable:!0,value:t[n++]}):Object.defineProperty(e,o,{enumerable:!0,get:s})}else for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.cjs=e=>{const t={exports:{}};return e.call(t.exports,t,t.exports),t.exports};let n=r(843);window.TinyMediaPlayer=n.TinyMediaPlayer})();
@@ -1 +1 @@
1
- (()=>{"use strict";var e={7(e){var t,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,o),r(n)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}c(e,t,o,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&c(e,"error",t,{once:!0})}(e,i)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function h(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,n,r){var i,o,s,u;if(a(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]),void 0===s)s=o[t]=n,++e._eventsCount;else if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),(i=h(e))>0&&s.length>i&&!s.warned){s.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=e,f.type=t,f.count=s.length,u=f,console&&console.warn&&console.warn(u)}return e}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}function l(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):p(i,i.length)}function v(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function p(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function c(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function i(o){r.once&&e.removeEventListener(t,i),n(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return h(this)},o.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var h=o[e];if(void 0===h)return!1;if("function"==typeof h)r(h,this,t);else{var u=h.length,f=p(h,u);for(n=0;n<u;++n)r(f[n],this,t)}return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,d(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,d(this,e,t)),this},o.prototype.removeListener=function(e,t){var n,r,i,o,s;if(a(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){s=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},o.prototype.listeners=function(e){return l(this,e,!0)},o.prototype.rawListeners=function(e){return l(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):v.call(e,t)},o.prototype.listenerCount=v,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}}};const t={};function n(r){const i=t[r];if(void 0!==i)return i.exports;const o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.d=(e,t)=>{if(Array.isArray(t))for(var r=0;r<t.length;){var i=t[r++],o=t[r++];n.o(e,i)?0===o&&r++:0===o?Object.defineProperty(e,i,{enumerable:!0,value:t[r++]}):Object.defineProperty(e,i,{enumerable:!0,get:o})}else for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let r={};n.d(r,{TinyNewWinEvents:()=>h});var i=n(7);const o=e=>{if(e)throw new Error("This TinyNewWinEvents instance has been destroyed and can no longer be used.")};const s=new WeakMap;class a extends i.EventEmitter{#e;#t;#n=[];#r=!1;#i=!1;#o=null;#s="__TNE_READY__";#a="__TNE_ROUTE__";#h=!1;get destroyed(){return this.#h}get readyEventName(){return o(this.#h),this.#s}set readyEventName(e){if(o(this.#h),"string"!=typeof e)throw new TypeError("TinyNewWinEvents: readyEventName must be a string.");this.#s=e}get routeEventName(){return o(this.#h),this.#a}set routeEventName(e){if(o(this.#h),"string"!=typeof e)throw new TypeError("TinyNewWinEvents: routeEventName must be a string.");this.#a=e}constructor({targetOrigin:e,url:t,name:n,features:r}={}){if(super(),"string"==typeof n&&"_blank"===n)throw new Error('TinyNewWinEvents: The window name "_blank" is not supported. Please use a custom name to allow tracking.');if(void 0!==e&&"string"!=typeof e)throw new TypeError('TinyNewWinEvents: The "targetOrigin" option must be a string.');if(void 0!==t&&"string"!=typeof t)throw new TypeError('TinyNewWinEvents: The "url" option must be a string.');if(void 0!==r&&"string"!=typeof r)throw new TypeError('TinyNewWinEvents: The "features" option must be a string if provided.');if(void 0===t?this.#e=window.opener:(this.#e="string"==typeof t?window.open(t,n,r):t,this.#i=!0),!this.#e||s.has(this.#e))throw new Error("Invalid or duplicate window reference.");this.#t=e??window.location.origin,this._handleMessage=this.#u.bind(this),window.addEventListener("message",this._handleMessage,!1),this.#i||(this.#f(this.#s,null),this.#d())}getWin(){return o(this.#h),this.#e}#u(e){if(!e.source||this.#e&&e.source!==this.#e)return;const{type:t,route:n,payload:r}=e.data||{};if(t===this.#s)return this.#r=!0,this.#l(),this.#d(),void(this.#i&&this.#f(this.#s,null));t===this.#a&&this.emit(`win:${n}`,r,e)}#l(){for(;this.#n.length;){const e=this.#n.shift();if(e){const{route:t,payload:n}=e;this.winEmit(t,n)}}}#f(e,t,n=""){this.#e&&this.#e.closed||this.#e?.postMessage({type:e,route:n,payload:t},this.#t)}close(){if(o(this.#h),!this.#i)throw new Error("Only host can close the window.");this.#e&&!this.#e.closed&&this.#e.close()}winEmit(e,t){if(o(this.#h),"string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.isDestroyed())throw new Error("Cannot emit: instance has been destroyed.");this.#r?this.#f(this.#a,t,e):this.#n.push({route:e,payload:t})}isConnected(){return o(this.#h),!(!this.#r||!this.#e||this.#e.closed)}#d(){this.#e&&!this.#o&&(this.#o=setInterval(()=>{this.#e?.closed&&(this.emit("WINDOW_REF_CLOSED"),this.destroy())},500),s.set(this.#e,this.#o))}onClose(e){o(this.#h),this.on("WINDOW_REF_CLOSED",e)}offClose(e){o(this.#h),this.off("WINDOW_REF_CLOSED",e)}isDestroyed(){return!this.#e}destroy(){this.#e&&(this.#o&&(clearInterval(this.#o),this.#o=null,s.delete(this.#e)),window.removeEventListener("message",this._handleMessage),this.#n=[],this.#r=!1,this.#e=null,this.removeAllListeners(),this.#h=!0)}}const h=a;window.TinyNewWinEvents=r.TinyNewWinEvents})();
1
+ (()=>{"use strict";var e={700(e,t,n){n.d(t,{TinyNewWinEvents:()=>a});var r=n.cjs(function(e,t){var n,r="object"==typeof Reflect?Reflect:null,i=r&&"function"==typeof r.apply?r.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};n=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,s),r(n)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}y(e,t,s,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&y(e,"error",t,{once:!0})}(e,i)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var a=10;function h(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function f(e,t,n,r){var i,s,o,a;if(h(n),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),o=s[t]),void 0===o)o=s[t]=n,++e._eventsCount;else if("function"==typeof o?o=s[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),(i=u(e))>0&&o.length>i&&!o.warned){o.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=e,f.type=t,f.count=o.length,a=f,console&&console.warn&&console.warn(a)}return e}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=d.bind(r);return i.listener=n,r.wrapFn=i,i}function p(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):c(i,i.length)}function v(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function c(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function y(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function i(s){r.once&&e.removeEventListener(t,i),n(s)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,s=this._events;if(void 0!==s)r=r&&void 0===s.error;else if(!r)return!1;if(r){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var h=s[e];if(void 0===h)return!1;if("function"==typeof h)i(h,this,t);else{var u=h.length,f=c(h,u);for(n=0;n<u;++n)i(f[n],this,t)}return!0},o.prototype.addListener=function(e,t){return f(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return f(this,e,t,!0)},o.prototype.once=function(e,t){return h(t),this.on(e,l(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return h(t),this.prependListener(e,l(this,e,t)),this},o.prototype.removeListener=function(e,t){var n,r,i,s,o;if(h(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){o=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,o||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,s=Object.keys(n);for(r=0;r<s.length;++r)"removeListener"!==(i=s[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},o.prototype.listeners=function(e){return p(this,e,!0)},o.prototype.rawListeners=function(e){return p(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):v.call(e,t)},o.prototype.listenerCount=v,o.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}});const i=e=>{if(e)throw new Error("This TinyNewWinEvents instance has been destroyed and can no longer be used.")};const s=new WeakMap;class o extends r.EventEmitter{#e;#t;#n=[];#r=!1;#i=!1;#s=null;#o="__TNE_READY__";#a="__TNE_ROUTE__";#h=!1;get destroyed(){return this.#h}get readyEventName(){return i(this.#h),this.#o}set readyEventName(e){if(i(this.#h),"string"!=typeof e)throw new TypeError("TinyNewWinEvents: readyEventName must be a string.");this.#o=e}get routeEventName(){return i(this.#h),this.#a}set routeEventName(e){if(i(this.#h),"string"!=typeof e)throw new TypeError("TinyNewWinEvents: routeEventName must be a string.");this.#a=e}constructor({targetOrigin:e,url:t,name:n,features:r}={}){if(super(),"string"==typeof n&&"_blank"===n)throw new Error('TinyNewWinEvents: The window name "_blank" is not supported. Please use a custom name to allow tracking.');if(void 0!==e&&"string"!=typeof e)throw new TypeError('TinyNewWinEvents: The "targetOrigin" option must be a string.');if(void 0!==t&&"string"!=typeof t)throw new TypeError('TinyNewWinEvents: The "url" option must be a string.');if(void 0!==r&&"string"!=typeof r)throw new TypeError('TinyNewWinEvents: The "features" option must be a string if provided.');if(void 0===t?this.#e=window.opener:(this.#e="string"==typeof t?window.open(t,n,r):t,this.#i=!0),!this.#e||s.has(this.#e))throw new Error("Invalid or duplicate window reference.");this.#t=e??window.location.origin,this._handleMessage=this.#u.bind(this),window.addEventListener("message",this._handleMessage,!1),this.#i||(this.#f(this.#o,null),this.#d())}getWin(){return i(this.#h),this.#e}#u(e){if(!e.source||this.#e&&e.source!==this.#e)return;const{type:t,route:n,payload:r}=e.data||{};if(t===this.#o)return this.#r=!0,this.#l(),this.#d(),void(this.#i&&this.#f(this.#o,null));t===this.#a&&this.emit(`win:${n}`,r,e)}#l(){for(;this.#n.length;){const e=this.#n.shift();if(e){const{route:t,payload:n}=e;this.winEmit(t,n)}}}#f(e,t,n=""){this.#e&&this.#e.closed||this.#e?.postMessage({type:e,route:n,payload:t},this.#t)}close(){if(i(this.#h),!this.#i)throw new Error("Only host can close the window.");this.#e&&!this.#e.closed&&this.#e.close()}winEmit(e,t){if(i(this.#h),"string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.isDestroyed())throw new Error("Cannot emit: instance has been destroyed.");this.#r?this.#f(this.#a,t,e):this.#n.push({route:e,payload:t})}isConnected(){return i(this.#h),!(!this.#r||!this.#e||this.#e.closed)}#d(){this.#e&&!this.#s&&(this.#s=setInterval(()=>{this.#e?.closed&&(this.emit("WINDOW_REF_CLOSED"),this.destroy())},500),s.set(this.#e,this.#s))}onClose(e){i(this.#h),this.on("WINDOW_REF_CLOSED",e)}offClose(e){i(this.#h),this.off("WINDOW_REF_CLOSED",e)}isDestroyed(){return!this.#e}destroy(){this.#e&&(this.#s&&(clearInterval(this.#s),this.#s=null,s.delete(this.#e)),window.removeEventListener("message",this._handleMessage),this.#n=[],this.#r=!1,this.#e=null,this.removeAllListeners(),this.#h=!0)}}const a=o}};const t={};function n(r){const i=t[r];if(void 0!==i)return i.exports;const s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.d=(e,t)=>{if(Array.isArray(t))for(var r=0;r<t.length;){var i=t[r++],s=t[r++];n.o(e,i)?0===s&&r++:0===s?Object.defineProperty(e,i,{enumerable:!0,value:t[r++]}):Object.defineProperty(e,i,{enumerable:!0,get:s})}else for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.cjs=e=>{const t={exports:{}};return e.call(t.exports,t,t.exports),t.exports};let r=n(700);window.TinyNewWinEvents=r.TinyNewWinEvents})();
@@ -1 +1 @@
1
- (()=>{"use strict";var t={7(t){var e,i="object"==typeof Reflect?Reflect:null,r=i&&"function"==typeof i.apply?i.apply:function(t,e,i){return Function.prototype.apply.call(t,e,i)};e=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var n=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise(function(i,r){function n(i){t.removeListener(e,o),r(i)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",n),i([].slice.call(arguments))}p(t,e,o,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&p(t,"error",e,{once:!0})}(t,n)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function c(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function u(t,e,i,r){var n,o,s,u;if(a(i),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,i.listener?i.listener:i),o=t._events),s=o[e]),void 0===s)s=o[e]=i,++t._eventsCount;else if("function"==typeof s?s=o[e]=r?[i,s]:[s,i]:r?s.unshift(i):s.push(i),(n=c(t))>0&&s.length>n&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,u=l,console&&console.warn&&console.warn(u)}return t}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},n=l.bind(r);return n.listener=i,r.wrapFn=n,n}function h(t,e,i){var r=t._events;if(void 0===r)return[];var n=r[e];return void 0===n?[]:"function"==typeof n?i?[n.listener||n]:[n]:i?function(t){for(var e=new Array(t.length),i=0;i<e.length;++i)e[i]=t[i].listener||t[i];return e}(n):m(n,n.length)}function f(t){var e=this._events;if(void 0!==e){var i=e[t];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function m(t,e){for(var i=new Array(e),r=0;r<e;++r)i[r]=t[r];return i}function p(t,e,i,r){if("function"==typeof t.on)r.once?t.once(e,i):t.on(e,i);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,function n(o){r.once&&t.removeEventListener(e,n),i(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(t){if("number"!=typeof t||t<0||n(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");s=t}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||n(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(t){for(var e=[],i=1;i<arguments.length;i++)e.push(arguments[i]);var n="error"===t,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)r(c,this,e);else{var u=c.length,l=m(c,u);for(i=0;i<u;++i)r(l[i],this,e)}return!0},o.prototype.addListener=function(t,e){return u(this,t,e,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(t,e){return u(this,t,e,!0)},o.prototype.once=function(t,e){return a(e),this.on(t,d(this,t,e)),this},o.prototype.prependOnceListener=function(t,e){return a(e),this.prependListener(t,d(this,t,e)),this},o.prototype.removeListener=function(t,e){var i,r,n,o,s;if(a(e),void 0===(r=this._events))return this;if(void 0===(i=r[t]))return this;if(i===e||i.listener===e)0===--this._eventsCount?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,i.listener||e));else if("function"!=typeof i){for(n=-1,o=i.length-1;o>=0;o--)if(i[o]===e||i[o].listener===e){s=i[o].listener,n=o;break}if(n<0)return this;0===n?i.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(i,n),1===i.length&&(r[t]=i[0]),void 0!==r.removeListener&&this.emit("removeListener",t,s||e)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(t){var e,i,r;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[t]&&(0===--this._eventsCount?this._events=Object.create(null):delete i[t]),this;if(0===arguments.length){var n,o=Object.keys(i);for(r=0;r<o.length;++r)"removeListener"!==(n=o[r])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=i[t]))this.removeListener(t,e);else if(void 0!==e)for(r=e.length-1;r>=0;r--)this.removeListener(t,e[r]);return this},o.prototype.listeners=function(t){return h(this,t,!0)},o.prototype.rawListeners=function(t){return h(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},o.prototype.listenerCount=f,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}}};const e={};function i(r){const n=e[r];if(void 0!==n)return n.exports;const o=e[r]={exports:{}};return t[r](o,o.exports,i),o.exports}i.d=(t,e)=>{if(Array.isArray(e))for(var r=0;r<e.length;){var n=e[r++],o=e[r++];i.o(t,n)?0===o&&r++:0===o?Object.defineProperty(t,n,{enumerable:!0,value:e[r++]}):Object.defineProperty(t,n,{enumerable:!0,get:o})}else for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let r={};i.d(r,{TinyRadioFm:()=>v});var n=i(7);const o=(t,e)=>{if("string"!=typeof e)throw new TypeError('Expected "name" to be a string.');if("string"!=typeof t)throw new TypeError(`Expected "${e}" to be a string, but received ${typeof t}.`)},s=(t,e)=>{if("string"!=typeof e)throw new TypeError('Expected "name" to be a string.');if("function"!=typeof t)throw new TypeError(`Expected "${e}" to be a function, but received ${typeof t}.`)},a=(t,e)=>{if("string"!=typeof e)throw new TypeError('Expected "name" to be a string.');if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError(`Expected "${e}" to be a plain object, but received ${null===t?"null":Array.isArray(t)?"array":typeof t}.`)},c=new Map;class u extends Error{constructor(t,e,i){if(o(t,"message"),o(e,"url"),"string"!=typeof i)throw new TypeError(`Expected "stage" to be a string, but received ${typeof i}.`);super(t),this.name="MediaLoadingError",this.url=e,this.stage=i}}const l=async t=>{o(t,"str");const e=(new TextEncoder).encode(t),i=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(i)).map(t=>t.toString(16).padStart(2,"0")).join("").substring(0,8)},d=(t,e="image/jpeg")=>{if(!(t instanceof Uint8Array)&&"string"!=typeof t)throw new TypeError(`Expected "data" to be an instance of Uint8Array or a string, but received ${typeof t}.`);o(e,"format");const i=t=>{const e=URL.createObjectURL(t),i=c.get(e);return c.set(e,"number"==typeof i?i+1:1),e};if(t instanceof Uint8Array)return i(new Blob([t],{type:e}));if("string"==typeof t&&t.startsWith("data:")){const r=t.split(",")[1],n=atob(r),o=new Uint8Array(n.length);for(let t=0;t<n.length;t++)o[t]=n.charCodeAt(t);return i(new Blob([o],{type:e}))}return"string"==typeof t?t:""},h=async t=>{if(o(t,"url"),!t.startsWith("blob:"))return t;try{const e=await fetch(t),i=await e.blob();return await new Promise((t,e)=>{const r=new FileReader;r.onloadend=()=>t(String(r.result)),r.onerror=e,r.readAsDataURL(i)})}catch(e){return console.warn(`[TinyAudioUtils] Failed to convert Blob URL to Base64 on export: ${t}`,e),t}},f=t=>{a(t,"content"),t&&Array.isArray(t.picture)&&t.picture.forEach(t=>{if("string"==typeof t.data&&t.data.startsWith("blob:")){const e=c.get(t.data)??0;e>1?c.set(t.data,e-1):c.delete(t.data),e<=1&&URL.revokeObjectURL(t.data)}})},m=async(t,e)=>{o(t,"url"),s(e,"parseFile");try{const i=await fetch(t);if(!i.ok)throw new Error(`Failed to fetch audio file: ${i.status} ${i.statusText}`);const r=await i.blob(),n=await e(r);if(!n||"object"!=typeof n.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const c=n.common;return(t=>{a(t,"common"),((t,e)=>{if(a(t,"common"),"boolean"!=typeof e)throw new TypeError('Expected "isPartial" to be a boolean.');const i=t=>e&&void 0===t,r=t=>i(t)||"string"==typeof t||null===t,n=(t,e)=>(s(e,"valueValidator"),!!i(t)||!(!Array.isArray(t)||!t.every(e)));if(!r(t.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!r(t.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!r(t.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!r(t.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(c=t.year,!i(c)&&"number"!=typeof c&&null!==c)throw new TypeError('Invalid metadata: "year" must be a number or null.');var c;if(!n(t.albumartists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!n(t.genre,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!n(t.label,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!n(t.composer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!n(t.artists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!n(t.picture,t=>t&&"object"==typeof t&&(void 0===t.description||"string"==typeof t.description)&&(void 0===t.name||"string"==typeof t.name)&&(void 0===t.type||"string"==typeof t.type)&&"string"==typeof t.format&&(t.data instanceof Uint8Array||"string"==typeof t.data)))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');const u=(t,e)=>{if(o(t,"name"),!i(e)){if(null==e)throw new TypeError(`Invalid metadata: "${t}" is required.`);if("object"!=typeof e)throw new TypeError(`Invalid metadata: "${t}" must be an object or null.`);if("number"!=typeof e.no&&null!==e.no)throw new TypeError(`Invalid metadata: "${t}.no" must be a number or null.`);if("number"!=typeof e.of&&null!==e.of)throw new TypeError(`Invalid metadata: "${t}.of" must be a number or null.`)}};u("disk",t.disk),u("track",t.track)})(t,!0)})(c),{title:c?.title??null,album:c?.album??null,albumartist:c?.albumartist??null,albumartists:c?.albumartists??[],genre:c?.genre??[],label:c?.label??[],composer:c?.composer??[],year:c?.year??null,artist:c?.artist??null,artists:c?.artists??[],disk:c?.disk?{no:c.disk.no,of:c.disk.of}:{no:null,of:null},track:c?.track?{no:c.track.no,of:c.track.of}:{no:null,of:null},picture:c?.picture?.map(t=>({...t,data:d(t.data,t.format)}))??[]}}catch(t){throw t}},p=t=>{if(t)throw new Error("This TinyRadioFm instance has been destroyed and can no longer be used.")};class y extends n.EventEmitter{static async parseContent(t,e,i,r,n){return(async(t,e={},i={},r=t=>{if(!(t instanceof Blob))throw new TypeError('Expected "data" to be a Blob.');return new Promise((t,e)=>e(new TypeError("parseFile library not found.")))},n={},c="null")=>{if("string"!=typeof t&&!(t instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(a(e,"defaultMetadata"),a(i,"metadata"),s(r,"parseFile"),a(n,"callbacks"),n.onProgress&&"function"!=typeof n.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(n.onError&&"function"!=typeof n.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof c&&"function"!=typeof c)throw new TypeError("unknownArtist must be a string or a function returning a string.");let d,h="";const f=(e,i)=>{if(o(e,"stage"),void 0!==i&&!(i instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');n.onProgress&&n.onProgress({event:i,status:"loading",stage:e,url:h||(t instanceof HTMLMediaElement?t.src:"unknown")})},p=(e,i)=>{if(!(e instanceof Error))throw new TypeError('Expected "error" to be an Error.');o(i,"stage"),n.onError&&n.onError({error:e,url:h||(t instanceof HTMLMediaElement?t.src:"unknown"),stage:i})};try{f("INITIALIZING"),"string"==typeof t?(h=t,d=new Audio(h)):(d=t,h=d.src);try{await new Promise((t,e)=>{const i=t=>f("DOWNLOADING",t),r=()=>{o(),t(void 0)},n=t=>{o(),e(new Error(`HTMLMediaElement failed to load: ${t.message||"Unknown error"}`))},o=()=>{d.removeEventListener("progress",i),d.removeEventListener("loadedmetadata",r),d.removeEventListener("error",n)};d.addEventListener("progress",i),d.addEventListener("loadedmetadata",r),d.addEventListener("error",n),d.readyState>=1&&(o(),t(void 0))}),f("METADATA_LOADED")}catch(t){throw new u(t instanceof Error?t.message:"UNKNOWN ERROR",h,"METADATA")}const s={id:i.id||await l(h),duration:Math.floor(1e3*d.duration),url:h,weight:i.weight??1};let a={};f("EXTRACTING_ID3");try{a=await m(h,r)}catch(t){p(t instanceof Error?t:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${h}. Falling back to filename.`)}const y=t=>{o(t,"url");try{return(t.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},v={...s,...e,...a,...i,title:a.title||i.title||y(h),artist:a.artist||i.artist||("string"==typeof c?c:String(c()))};return n.onProgress&&n.onProgress({status:"success",stage:"COMPLETE",url:h}),v}catch(t){if(t instanceof u)throw t;{const e=new u(t instanceof Error?t.message:"UNKNOWN ERROR",h,"INITIALIZING");throw p(e,"INITIALIZING"),e}}})(t,e,i,r,n,y.#t)}static#t="Unknown Artist";static get unknownArtist(){return y.#t}static set unknownArtist(t){if("string"!=typeof t&&"function"!=typeof t)throw new TypeError("unknownArtist must have an string or function.");y.#t=t}#e=!1;get destroyed(){return this.#e}get size(){return p(this.#e),this.#i.length+this.#r.length}get musicSize(){return p(this.#e),this.#i.length}get voiceSize(){return p(this.#e),this.#r.length}get customPosSize(){return p(this.#e),this.#n.length}get tasksSize(){return p(this.#e),this.#o.length}get cycleCacheSize(){return p(this.#e),this.#s.size}#i=[];get musicList(){return p(this.#e),structuredClone(this.#i)}#r=[];get voiceList(){return p(this.#e),structuredClone(this.#r)}#n=[];get customPositions(){return p(this.#e),structuredClone(this.#n)}#o=[];get scheduledTasks(){return p(this.#e),structuredClone(this.#o)}get allList(){return p(this.#e),[...this.musicList,...this.voiceList]}#a=0;get seed(){return p(this.#e),this.#a}set seed(t){if(p(this.#e),"number"!=typeof t)throw new TypeError("Seed must be a number.");this.#a=t,this.#s.clear(),this.emit("seedChanged",{seed:t})}#c=Date.now();get anchorDate(){return p(this.#e),this.#c}#s=new Map;#u={mode:"playlist",voiceMode:"playlist",silenceDuration:0,queryLimit:1e5,voiceAfterMusic:!0,voiceMin:0,voiceMax:1,musicMaxConsecutive:0,voiceMaxConsecutive:0};get config(){return p(this.#e),structuredClone(this.#u)}set config(t){p(this.#e),this.#l(t),this.#u=structuredClone(t),this.#s.clear(),this.emit("configChanged",{config:this.config})}#l(t){if("object"!=typeof t||null===t)throw new TypeError("Configuration must be a valid object.");const e=["playlist","random"];if(void 0!==t.mode&&!e.includes(t.mode))throw new TypeError(`Invalid mode: "${t.mode}". Must be one of: ${e.join(", ")}.`);if(void 0!==t.voiceMode&&!e.includes(t.voiceMode))throw new TypeError(`Invalid voiceMode: "${t.voiceMode}". Must be one of: ${e.join(", ")}.`);if(void 0!==t.silenceDuration&&("number"!=typeof t.silenceDuration||t.silenceDuration<0))throw new TypeError("silenceDuration must be a non-negative number.");if(void 0!==t.queryLimit&&("number"!=typeof t.queryLimit||t.queryLimit<=0))throw new TypeError("queryLimit must be a positive number.");if(void 0!==t.voiceAfterMusic&&"boolean"!=typeof t.voiceAfterMusic)throw new TypeError("voiceAfterMusic must be a boolean.");if(void 0!==t.voiceMin&&("number"!=typeof t.voiceMin||t.voiceMin<0))throw new TypeError("voiceMin must be a non-negative number.");if(void 0!==t.voiceMax&&("number"!=typeof t.voiceMax||t.voiceMax<0))throw new TypeError("voiceMax must be a non-negative number.");if(void 0!==t.musicMaxConsecutive&&("number"!=typeof t.musicMaxConsecutive||t.musicMaxConsecutive<-1))throw new TypeError("musicMaxConsecutive must be a number >= -1.");if(void 0!==t.voiceMaxConsecutive&&("number"!=typeof t.voiceMaxConsecutive||t.voiceMaxConsecutive<-1))throw new TypeError("voiceMaxConsecutive must be a number >= -1.");const i=t.voiceMin??this.#u.voiceMin,r=t.voiceMax??this.#u.voiceMax;if(r<i)throw new RangeError(`Logical error: voiceMax (${r}) cannot be less than voiceMin (${i}).`)}constructor(t=null,e=0){if(super(),null!==t&&"object"!=typeof t)throw new TypeError("initialData must be an object or null.");if("number"!=typeof e)throw new TypeError("seed must be a number.");this.#a=e,t?this.#d(t):this.#c=Date.now()}add(t,e,i=!0){if(p(this.#e),!["music","voice","custom"].includes(t))throw new TypeError('Type must be "music", "voice", or "custom".');if(!e||"string"!=typeof e.id||"number"!=typeof e.duration)throw new TypeError("Content must have a string ID and a valid numerical duration in milliseconds.");if("boolean"!=typeof i)throw new TypeError("smartQueue must be a boolean.");"music"===t?(this.#i.push(e),this.#s.clear()):"voice"===t?(this.#r.push(e),this.#s.clear()):"custom"===t&&this.#h(e,i),this.#f(Date.now()),this.emit("contentAdded",{type:t,data:structuredClone(e)})}scheduleTask(t,e,i,r,n=!0){if(p(this.#e),"number"!=typeof t||isNaN(t))throw new TypeError("timestamp must be a valid number.");if(!["add","remove","move"].includes(e))throw new TypeError('action must be "add", "remove", or "move".');if(!["music","voice"].includes(i))throw new TypeError('type must be "music" or "voice".');if("boolean"!=typeof n)throw new TypeError("smartQueue must be a boolean.");if("add"===e){if("object"!=typeof r||null===r||"string"!=typeof r.id||"number"!=typeof r.duration)throw new TypeError('Payload for "add" must be a MediaContent object (id: string, duration: number).')}else if("remove"===e){if("string"!=typeof r)throw new TypeError('Payload for "remove" must be a string (the content ID).')}else if("move"===e&&("object"!=typeof r||null===r||"string"!=typeof r.id||"number"!=typeof r.newIndex))throw new TypeError('Payload for "move" must be a ScheduledMovePayload (id: string, newIndex: number).');let o=t;if(n){const e=this.#m(t,t);e&&(o=e.absoluteEnd)}const s={timestamp:o,action:e,type:i,payload:r};this.#o.push(s),this.#f(Date.now()),this.emit("taskScheduled",structuredClone(s))}remove(t){if(p(this.#e),"string"!=typeof t)throw new TypeError("id must be a string.");this.#i.filter(e=>e.id===t).forEach(t=>f(t)),this.#r.filter(e=>e.id===t).forEach(t=>f(t)),this.#n.filter(e=>e.content?.id===t).forEach(t=>f(t.content));const e=e=>e.id!==t&&e.content?.id!==t;this.#i=this.#i.filter(e),this.#r=this.#r.filter(e),this.#n=this.#n.filter(e),this.#o=this.#o.filter(e=>"add"===e.action&&"object"==typeof e.payload&&null!==e.payload&&"id"in e.payload?e.payload.id!==t||(f(e.payload),!1):e.payload!==t),this.#s.clear(),this.emit("contentRemoved",{id:t})}setConfig(t){p(this.#e),this.#l(t);const e={...this.#u,...t};this.#l(e),this.#u=e,this.#s.clear(),this.emit("configChanged",{config:this.config})}getCurrentEvent(){p(this.#e);const t=Date.now();return this.#f(t),this.#m(t,t)}queryTimeline(t,e=10){if(p(this.#e),"number"!=typeof e||isNaN(e))throw new TypeError("Invalid query limit value. Ensure it is a number.");if(e>this.#u.queryLimit||e<=0)throw new RangeError(`Invalid query limit. Ensure it is > 0 and <= ${this.#u.queryLimit}.`);const i=new y(JSON.parse(this._exportState())),r=[];let n=t;for(let o=0;o<e;o++){i.#f(n);const e=i.#p(n,t);if(!e)break;r.push(e),n=e.absoluteEnd}return i.destroy(!1),this.emit("timelineQueried",{targetDate:t,limit:e,resultCount:r.length}),r}searchCustomPositions(){return p(this.#e),this.#f(Date.now()),[...this.#n]}async _processListForExport(t){return Promise.all(t.map(async t=>{const e=structuredClone(t);return e.picture&&Array.isArray(e.picture)&&(e.picture=await Promise.all(e.picture.map(async t=>"string"==typeof t.data&&t.data.startsWith("blob:")?{...t,data:await h(t.data)}:t))),e}))}_exportState(){return JSON.stringify({music:this.#i,voice:this.#r,custom:this.#n,tasks:this.#o,seed:this.#a,anchorDate:this.#c,config:this.#u})}async exportState(){p(this.#e);const t=await this._processListForExport(this.#i),e=await this._processListForExport(this.#r),i=await Promise.all(this.#n.map(async t=>{const e=await this._processListForExport([t.content]);return{...t,content:e[0]}})),r=await Promise.all(this.#o.map(async t=>{if("add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload){const e=await this._processListForExport([t.payload]);return{...t,payload:e[0]}}return t}));return JSON.stringify({music:t,voice:e,custom:i,tasks:r,seed:this.#a,anchorDate:this.#c,config:this.#u})}importState(t){let e;if(p(this.#e),"string"==typeof t)try{e=JSON.parse(t)}catch{throw new TypeError("Provided string is not valid JSON.")}else{if("object"!=typeof t||null===t)throw new TypeError("Import data must be a valid JSON string or an object.");e=t}this.#d(e),this.emit("stateImported",{data:structuredClone(e)})}_prng(t){return function(){let e=t+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}#y(t,e,i,r=0){if(0===t.length)return[];if("random"!==i)return[...t];const n=t.map(t=>({...t,weight:t.weight??1})),o=this._prng(e),s=[];let a=null,c=0;for(;n.length>0;){let t=n;-1!==r&&null!==a&&c>r&&(t=n.filter(t=>t.id!==a),0===t.length&&(t=n));const e=t.reduce((t,e)=>t+e.weight,0);if(e<=0){s.push(...t);break}const i=o()*e;let u=0,l=null,d=-1;for(let e=0;e<t.length;e++)if(u+=t[e].weight,i<=u){l=t[e],d=n.findIndex(t=>l&&t.id===l.id);break}l&&-1!==d||(l=t[0],d=n.findIndex(t=>l&&t.id===l.id)),s.push(l),n.splice(d,1),l.id===a?c++:(a=l.id,c=1)}return s}#v(t){const e=this.#a+t,i=this._prng(10*e),r=this.#y(this.#i,e+1,this.#u.mode,this.#u.musicMaxConsecutive),n=this.#y(this.#r,e+2,this.#u.voiceMode,this.#u.voiceMaxConsecutive),o=[];let s=0,a=0;for(let t=0;t<r.length;t++){const e=r[t];if(o.push({...e,cycleStart:s,cycleEnd:s+e.duration}),s+=e.duration+this.#u.silenceDuration,this.#u.voiceAfterMusic&&n.length>0){const t=this.#u.voiceMax-this.#u.voiceMin+1,e=Math.floor(i()*t)+this.#u.voiceMin;for(let t=0;t<e;t++){const t=n[a%n.length];a++,o.push({...t,cycleStart:s,cycleEnd:s+t.duration}),s+=t.duration+this.#u.silenceDuration}}}return{items:o,duration:s}}#g(t){if(0===this.#i.length)return null;let e=this.#c,i=0;for(;;){if(i>this.#u.queryLimit)throw new Error("Safety limit hit during cycle location.");let r=this.#s.get(i);if(r||(r=this.#v(i),this.#s.set(i,r)),0===r.duration)return null;if(t>=e&&t<e+r.duration)return{block:r,startTimestamp:e,loopIndex:i};e+=r.duration,i++}}#p(t,e){const i=this.#n.filter(e=>e.intendedTimestamp+e.content.duration>t).sort((t,e)=>t.intendedTimestamp-e.intendedTimestamp)[0];let r=null;if(i){const t=Math.max(e,i.intendedTimestamp);r=this.#w(i.content,i.intendedTimestamp,t,!0)}const n=this.#b(t,e);return n||r?n?r?r.absoluteStart<=n.absoluteStart?r:(r.absoluteStart<n.absoluteEnd&&(n.absoluteEnd=r.absoluteStart,n.duration=n.absoluteEnd-n.absoluteStart,n.remainingTime=Math.max(0,n.absoluteEnd-e),n.progress=Math.min(1,n.elapsedTime/n.duration)),n):n:r:null}#b(t,e){let i=this.#g(t);if(!i)return null;const{block:r,startTimestamp:n}=i,o=t-n;let s,a=r.items.find(t=>t.cycleEnd>o);if(a)s=n+a.cycleStart;else{if(i=this.#g(n+r.duration),!i||0===i.block.items.length)return null;a=i.block.items[0],s=i.startTimestamp+a.cycleStart}const c=Math.max(e,s);return this.#w(a,s,c,!1)}#m(t,e){const i=this.#n.find(e=>t>=e.intendedTimestamp&&t<e.intendedTimestamp+e.content.duration);if(i)return this.#w(i.content,i.intendedTimestamp,e,!0);const r=this.#g(t);if(!r)return null;const{block:n,startTimestamp:o}=r,s=t-o,a=n.items.find(t=>s>=t.cycleStart&&s<t.cycleEnd);return a?this.#w(a,o+a.cycleStart,e,!1):null}#w(t,e,i,r){const n=i-e;return{id:t.id,title:t.title,artist:t.artist,duration:t.duration,url:t.url,absoluteStart:e,absoluteEnd:e+t.duration,elapsedTime:n,remainingTime:t.duration-n,progress:Math.min(1,n/t.duration),isCustom:r}}#h(t,e){let i=t.timestamp||Date.now();const r=t.duration;if(e){const t=this.#m(i,i);t&&(i=t.absoluteEnd)}const n=[...this.#n].sort((t,e)=>t.intendedTimestamp-e.intendedTimestamp);let o=i;if(n.some(t=>i<t.intendedTimestamp+t.content.duration&&i+r>t.intendedTimestamp)){const t=[];let e=Date.now();for(const i of n)i.intendedTimestamp>e&&t.push({start:e,end:i.intendedTimestamp}),e=Math.max(e,i.intendedTimestamp+i.content.duration+this.#u.silenceDuration);t.push({start:e,end:1/0});let s=1/0;for(const e of t)if(e.end-e.start>=r){let t=null;if(i>=e.start&&i+r<=e.end?t=i:i<e.start?t=e.start:i>e.end&&(t=e.end-r),null!==t){const e=Math.abs(i-t);e<s&&(s=e,o=t)}}}this.#n.push({content:t,intendedTimestamp:o,originalTimestamp:t.timestamp||Date.now()})}#f(t){const e=this.#o.filter(e=>e.timestamp<=t);this.#o=this.#o.filter(e=>e.timestamp>t);const i=this.#n.filter(e=>e.intendedTimestamp+e.content.duration<=t);this.#n=this.#n.filter(e=>e.intendedTimestamp+e.content.duration>t);let r=!1;i.forEach(t=>{f(t.content),this.#a+=t.content.id.length,r=!0,this.emit("customPositionExpired",{contentId:t.content.id})}),e.length>0&&e.sort((t,e)=>t.timestamp-e.timestamp).forEach(t=>{const e="music"===t.type?this.#i:this.#r;if("add"===t.action)e.push(t.payload);else if("remove"===t.action){const i=t.payload,r=e.findIndex(t=>t.id===i);if(-1!==r){const[t]=e.splice(r,1);f(t)}}else if("move"===t.action){const i=t.payload,r=e.findIndex(t=>t.id===i.id);if(-1!==r){const[t]=e.splice(r,1);e.splice(i.newIndex,0,t)}}this.#c=t.timestamp,this.#a+=1,r=!0,this.emit("taskExecuted",structuredClone(t))}),r&&this.#s.clear()}#d(t){this.#i.forEach(t=>f(t)),this.#r.forEach(t=>f(t)),this.#n.forEach(t=>f(t.content)),this.#o.forEach(t=>{"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload&&f(t.payload)});const e=t=>t.map(t=>{const e={...t};return e.picture&&Array.isArray(e.picture)&&(e.picture=e.picture.map(t=>{const e="string"==typeof t.data&&t.data.startsWith("data:"),i=t.data instanceof Uint8Array;return e||i?{...t,data:d(t.data,t.format)}:t})),e});this.#i=e(t.music),this.#r=e(t.voice),this.#a=t.seed||0,this.#c=t.anchorDate||Date.now(),this.#u={...this.#u,...t.config||{}},this.#n=t.custom.map(t=>({...t,content:e([t.content])[0]})),this.#o=t.tasks.map(t=>"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload?{...t,payload:e([t.payload])[0]}:t)}destroy(t=!0){this.#e||(t&&(this.#i.forEach(t=>f(t)),this.#r.forEach(t=>f(t)),this.#n.forEach(t=>f(t.content)),this.#o.forEach(t=>{"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload&&f(t.payload)})),this.#i=[],this.#r=[],this.#n=[],this.#o=[],this.#s.clear(),this.emit("destroyed",{timestamp:Date.now()}),this.removeAllListeners(),this.#e=!0)}}const v=y;window.TinyRadioFm=r.TinyRadioFm})();
1
+ (()=>{"use strict";var t={669(t,e,i){i.d(e,{TinyRadioFm:()=>y});var r=i.cjs(function(t,e){var i,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(t,e,i){return Function.prototype.apply.call(t,e,i)};i=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var o=Number.isNaN||function(t){return t!=t};function s(){s.init.call(this)}t.exports=s,t.exports.once=function(t,e){return new Promise(function(i,r){function n(i){t.removeListener(e,o),r(i)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",n),i([].slice.call(arguments))}y(t,e,o,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&y(t,"error",e,{once:!0})}(t,n)})},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var a=10;function c(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function u(t){return void 0===t._maxListeners?s.defaultMaxListeners:t._maxListeners}function l(t,e,i,r){var n,o,s,a;if(c(i),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,i.listener?i.listener:i),o=t._events),s=o[e]),void 0===s)s=o[e]=i,++t._eventsCount;else if("function"==typeof s?s=o[e]=r?[i,s]:[s,i]:r?s.unshift(i):s.push(i),(n=u(t))>0&&s.length>n&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,a=l,console&&console.warn&&console.warn(a)}return t}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(t,e,i){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},n=d.bind(r);return n.listener=i,r.wrapFn=n,n}function f(t,e,i){var r=t._events;if(void 0===r)return[];var n=r[e];return void 0===n?[]:"function"==typeof n?i?[n.listener||n]:[n]:i?function(t){for(var e=new Array(t.length),i=0;i<e.length;++i)e[i]=t[i].listener||t[i];return e}(n):p(n,n.length)}function m(t){var e=this._events;if(void 0!==e){var i=e[t];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function p(t,e){for(var i=new Array(e),r=0;r<e;++r)i[r]=t[r];return i}function y(t,e,i,r){if("function"==typeof t.on)r.once?t.once(e,i):t.on(e,i);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,function n(o){r.once&&t.removeEventListener(e,n),i(o)})}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(t){if("number"!=typeof t||t<0||o(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");a=t}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||o(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(t){for(var e=[],i=1;i<arguments.length;i++)e.push(arguments[i]);var r="error"===t,o=this._events;if(void 0!==o)r=r&&void 0===o.error;else if(!r)return!1;if(r){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)n(c,this,e);else{var u=c.length,l=p(c,u);for(i=0;i<u;++i)n(l[i],this,e)}return!0},s.prototype.addListener=function(t,e){return l(this,t,e,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(t,e){return l(this,t,e,!0)},s.prototype.once=function(t,e){return c(e),this.on(t,h(this,t,e)),this},s.prototype.prependOnceListener=function(t,e){return c(e),this.prependListener(t,h(this,t,e)),this},s.prototype.removeListener=function(t,e){var i,r,n,o,s;if(c(e),void 0===(r=this._events))return this;if(void 0===(i=r[t]))return this;if(i===e||i.listener===e)0===--this._eventsCount?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,i.listener||e));else if("function"!=typeof i){for(n=-1,o=i.length-1;o>=0;o--)if(i[o]===e||i[o].listener===e){s=i[o].listener,n=o;break}if(n<0)return this;0===n?i.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(i,n),1===i.length&&(r[t]=i[0]),void 0!==r.removeListener&&this.emit("removeListener",t,s||e)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(t){var e,i,r;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[t]&&(0===--this._eventsCount?this._events=Object.create(null):delete i[t]),this;if(0===arguments.length){var n,o=Object.keys(i);for(r=0;r<o.length;++r)"removeListener"!==(n=o[r])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=i[t]))this.removeListener(t,e);else if(void 0!==e)for(r=e.length-1;r>=0;r--)this.removeListener(t,e[r]);return this},s.prototype.listeners=function(t){return f(this,t,!0)},s.prototype.rawListeners=function(t){return f(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):m.call(t,e)},s.prototype.listenerCount=m,s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]}});const n=(t,e)=>{if("string"!=typeof e)throw new TypeError('Expected "name" to be a string.');if("string"!=typeof t)throw new TypeError(`Expected "${e}" to be a string, but received ${typeof t}.`)},o=(t,e)=>{if("string"!=typeof e)throw new TypeError('Expected "name" to be a string.');if("function"!=typeof t)throw new TypeError(`Expected "${e}" to be a function, but received ${typeof t}.`)},s=(t,e)=>{if("string"!=typeof e)throw new TypeError('Expected "name" to be a string.');if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError(`Expected "${e}" to be a plain object, but received ${null===t?"null":Array.isArray(t)?"array":typeof t}.`)},a=new Map;class c extends Error{constructor(t,e,i){if(n(t,"message"),n(e,"url"),"string"!=typeof i)throw new TypeError(`Expected "stage" to be a string, but received ${typeof i}.`);super(t),this.name="MediaLoadingError",this.url=e,this.stage=i}}const u=async t=>{n(t,"str");const e=(new TextEncoder).encode(t),i=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(i)).map(t=>t.toString(16).padStart(2,"0")).join("").substring(0,8)},l=(t,e="image/jpeg")=>{if(!(t instanceof Uint8Array)&&"string"!=typeof t)throw new TypeError(`Expected "data" to be an instance of Uint8Array or a string, but received ${typeof t}.`);n(e,"format");const i=t=>{const e=URL.createObjectURL(t),i=a.get(e);return a.set(e,"number"==typeof i?i+1:1),e};if(t instanceof Uint8Array)return i(new Blob([t],{type:e}));if("string"==typeof t&&t.startsWith("data:")){const r=t.split(",")[1],n=atob(r),o=new Uint8Array(n.length);for(let t=0;t<n.length;t++)o[t]=n.charCodeAt(t);return i(new Blob([o],{type:e}))}return"string"==typeof t?t:""},d=async t=>{if(n(t,"url"),!t.startsWith("blob:"))return t;try{const e=await fetch(t),i=await e.blob();return await new Promise((t,e)=>{const r=new FileReader;r.onloadend=()=>t(String(r.result)),r.onerror=e,r.readAsDataURL(i)})}catch(e){return console.warn(`[TinyAudioUtils] Failed to convert Blob URL to Base64 on export: ${t}`,e),t}},h=t=>{s(t,"content"),t&&Array.isArray(t.picture)&&t.picture.forEach(t=>{if("string"==typeof t.data&&t.data.startsWith("blob:")){const e=a.get(t.data)??0;e>1?a.set(t.data,e-1):a.delete(t.data),e<=1&&URL.revokeObjectURL(t.data)}})},f=async(t,e)=>{n(t,"url"),o(e,"parseFile");try{const i=await fetch(t);if(!i.ok)throw new Error(`Failed to fetch audio file: ${i.status} ${i.statusText}`);const r=await i.blob(),a=await e(r);if(!a||"object"!=typeof a.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const c=a.common;return(t=>{s(t,"common"),((t,e)=>{if(s(t,"common"),"boolean"!=typeof e)throw new TypeError('Expected "isPartial" to be a boolean.');const i=t=>e&&void 0===t,r=t=>i(t)||"string"==typeof t||null===t,a=(t,e)=>(o(e,"valueValidator"),!!i(t)||!(!Array.isArray(t)||!t.every(e)));if(!r(t.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!r(t.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!r(t.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!r(t.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(c=t.year,!i(c)&&"number"!=typeof c&&null!==c)throw new TypeError('Invalid metadata: "year" must be a number or null.');var c;if(!a(t.albumartists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!a(t.genre,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!a(t.label,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!a(t.composer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!a(t.artists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!a(t.picture,t=>t&&"object"==typeof t&&(void 0===t.description||"string"==typeof t.description)&&(void 0===t.name||"string"==typeof t.name)&&(void 0===t.type||"string"==typeof t.type)&&"string"==typeof t.format&&(t.data instanceof Uint8Array||"string"==typeof t.data)))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');const u=(t,e)=>{if(n(t,"name"),!i(e)){if(null==e)throw new TypeError(`Invalid metadata: "${t}" is required.`);if("object"!=typeof e)throw new TypeError(`Invalid metadata: "${t}" must be an object or null.`);if("number"!=typeof e.no&&null!==e.no)throw new TypeError(`Invalid metadata: "${t}.no" must be a number or null.`);if("number"!=typeof e.of&&null!==e.of)throw new TypeError(`Invalid metadata: "${t}.of" must be a number or null.`)}};u("disk",t.disk),u("track",t.track)})(t,!0)})(c),{title:c?.title??null,album:c?.album??null,albumartist:c?.albumartist??null,albumartists:c?.albumartists??[],genre:c?.genre??[],label:c?.label??[],composer:c?.composer??[],year:c?.year??null,artist:c?.artist??null,artists:c?.artists??[],disk:c?.disk?{no:c.disk.no,of:c.disk.of}:{no:null,of:null},track:c?.track?{no:c.track.no,of:c.track.of}:{no:null,of:null},picture:c?.picture?.map(t=>({...t,data:l(t.data,t.format)}))??[]}}catch(t){throw t}},m=t=>{if(t)throw new Error("This TinyRadioFm instance has been destroyed and can no longer be used.")};class p extends r.EventEmitter{static async parseContent(t,e,i,r,a){return(async(t,e={},i={},r=t=>{if(!(t instanceof Blob))throw new TypeError('Expected "data" to be a Blob.');return new Promise((t,e)=>e(new TypeError("parseFile library not found.")))},a={},l="null")=>{if("string"!=typeof t&&!(t instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(s(e,"defaultMetadata"),s(i,"metadata"),o(r,"parseFile"),s(a,"callbacks"),a.onProgress&&"function"!=typeof a.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(a.onError&&"function"!=typeof a.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof l&&"function"!=typeof l)throw new TypeError("unknownArtist must be a string or a function returning a string.");let d,h="";const m=(e,i)=>{if(n(e,"stage"),void 0!==i&&!(i instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');a.onProgress&&a.onProgress({event:i,status:"loading",stage:e,url:h||(t instanceof HTMLMediaElement?t.src:"unknown")})},p=(e,i)=>{if(!(e instanceof Error))throw new TypeError('Expected "error" to be an Error.');n(i,"stage"),a.onError&&a.onError({error:e,url:h||(t instanceof HTMLMediaElement?t.src:"unknown"),stage:i})};try{m("INITIALIZING"),"string"==typeof t?(h=t,d=new Audio(h)):(d=t,h=d.src);try{await new Promise((t,e)=>{const i=t=>m("DOWNLOADING",t),r=()=>{o(),t(void 0)},n=t=>{o(),e(new Error(`HTMLMediaElement failed to load: ${t.message||"Unknown error"}`))},o=()=>{d.removeEventListener("progress",i),d.removeEventListener("loadedmetadata",r),d.removeEventListener("error",n)};d.addEventListener("progress",i),d.addEventListener("loadedmetadata",r),d.addEventListener("error",n),d.readyState>=1&&(o(),t(void 0))}),m("METADATA_LOADED")}catch(t){throw new c(t instanceof Error?t.message:"UNKNOWN ERROR",h,"METADATA")}const o={id:i.id||await u(h),duration:Math.floor(1e3*d.duration),url:h,weight:i.weight??1};let s={};m("EXTRACTING_ID3");try{s=await f(h,r)}catch(t){p(t instanceof Error?t:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${h}. Falling back to filename.`)}const y=t=>{n(t,"url");try{return(t.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},v={...o,...e,...s,...i,title:s.title||i.title||y(h),artist:s.artist||i.artist||("string"==typeof l?l:String(l()))};return a.onProgress&&a.onProgress({status:"success",stage:"COMPLETE",url:h}),v}catch(t){if(t instanceof c)throw t;{const e=new c(t instanceof Error?t.message:"UNKNOWN ERROR",h,"INITIALIZING");throw p(e,"INITIALIZING"),e}}})(t,e,i,r,a,p.#t)}static#t="Unknown Artist";static get unknownArtist(){return p.#t}static set unknownArtist(t){if("string"!=typeof t&&"function"!=typeof t)throw new TypeError("unknownArtist must have an string or function.");p.#t=t}#e=!1;get destroyed(){return this.#e}get size(){return m(this.#e),this.#i.length+this.#r.length}get musicSize(){return m(this.#e),this.#i.length}get voiceSize(){return m(this.#e),this.#r.length}get customPosSize(){return m(this.#e),this.#n.length}get tasksSize(){return m(this.#e),this.#o.length}get cycleCacheSize(){return m(this.#e),this.#s.size}#i=[];get musicList(){return m(this.#e),structuredClone(this.#i)}#r=[];get voiceList(){return m(this.#e),structuredClone(this.#r)}#n=[];get customPositions(){return m(this.#e),structuredClone(this.#n)}#o=[];get scheduledTasks(){return m(this.#e),structuredClone(this.#o)}get allList(){return m(this.#e),[...this.musicList,...this.voiceList]}#a=0;get seed(){return m(this.#e),this.#a}set seed(t){if(m(this.#e),"number"!=typeof t)throw new TypeError("Seed must be a number.");this.#a=t,this.#s.clear(),this.emit("seedChanged",{seed:t})}#c=Date.now();get anchorDate(){return m(this.#e),this.#c}#s=new Map;#u={mode:"playlist",voiceMode:"playlist",silenceDuration:0,queryLimit:1e5,voiceAfterMusic:!0,voiceMin:0,voiceMax:1,musicMaxConsecutive:0,voiceMaxConsecutive:0};get config(){return m(this.#e),structuredClone(this.#u)}set config(t){m(this.#e),this.#l(t),this.#u=structuredClone(t),this.#s.clear(),this.emit("configChanged",{config:this.config})}#l(t){if("object"!=typeof t||null===t)throw new TypeError("Configuration must be a valid object.");const e=["playlist","random"];if(void 0!==t.mode&&!e.includes(t.mode))throw new TypeError(`Invalid mode: "${t.mode}". Must be one of: ${e.join(", ")}.`);if(void 0!==t.voiceMode&&!e.includes(t.voiceMode))throw new TypeError(`Invalid voiceMode: "${t.voiceMode}". Must be one of: ${e.join(", ")}.`);if(void 0!==t.silenceDuration&&("number"!=typeof t.silenceDuration||t.silenceDuration<0))throw new TypeError("silenceDuration must be a non-negative number.");if(void 0!==t.queryLimit&&("number"!=typeof t.queryLimit||t.queryLimit<=0))throw new TypeError("queryLimit must be a positive number.");if(void 0!==t.voiceAfterMusic&&"boolean"!=typeof t.voiceAfterMusic)throw new TypeError("voiceAfterMusic must be a boolean.");if(void 0!==t.voiceMin&&("number"!=typeof t.voiceMin||t.voiceMin<0))throw new TypeError("voiceMin must be a non-negative number.");if(void 0!==t.voiceMax&&("number"!=typeof t.voiceMax||t.voiceMax<0))throw new TypeError("voiceMax must be a non-negative number.");if(void 0!==t.musicMaxConsecutive&&("number"!=typeof t.musicMaxConsecutive||t.musicMaxConsecutive<-1))throw new TypeError("musicMaxConsecutive must be a number >= -1.");if(void 0!==t.voiceMaxConsecutive&&("number"!=typeof t.voiceMaxConsecutive||t.voiceMaxConsecutive<-1))throw new TypeError("voiceMaxConsecutive must be a number >= -1.");const i=t.voiceMin??this.#u.voiceMin,r=t.voiceMax??this.#u.voiceMax;if(r<i)throw new RangeError(`Logical error: voiceMax (${r}) cannot be less than voiceMin (${i}).`)}constructor(t=null,e=0){if(super(),null!==t&&"object"!=typeof t)throw new TypeError("initialData must be an object or null.");if("number"!=typeof e)throw new TypeError("seed must be a number.");this.#a=e,t?this.#d(t):this.#c=Date.now()}add(t,e,i=!0){if(m(this.#e),!["music","voice","custom"].includes(t))throw new TypeError('Type must be "music", "voice", or "custom".');if(!e||"string"!=typeof e.id||"number"!=typeof e.duration)throw new TypeError("Content must have a string ID and a valid numerical duration in milliseconds.");if("boolean"!=typeof i)throw new TypeError("smartQueue must be a boolean.");"music"===t?(this.#i.push(e),this.#s.clear()):"voice"===t?(this.#r.push(e),this.#s.clear()):"custom"===t&&this.#h(e,i),this.#f(Date.now()),this.emit("contentAdded",{type:t,data:structuredClone(e)})}scheduleTask(t,e,i,r,n=!0){if(m(this.#e),"number"!=typeof t||isNaN(t))throw new TypeError("timestamp must be a valid number.");if(!["add","remove","move"].includes(e))throw new TypeError('action must be "add", "remove", or "move".');if(!["music","voice"].includes(i))throw new TypeError('type must be "music" or "voice".');if("boolean"!=typeof n)throw new TypeError("smartQueue must be a boolean.");if("add"===e){if("object"!=typeof r||null===r||"string"!=typeof r.id||"number"!=typeof r.duration)throw new TypeError('Payload for "add" must be a MediaContent object (id: string, duration: number).')}else if("remove"===e){if("string"!=typeof r)throw new TypeError('Payload for "remove" must be a string (the content ID).')}else if("move"===e&&("object"!=typeof r||null===r||"string"!=typeof r.id||"number"!=typeof r.newIndex))throw new TypeError('Payload for "move" must be a ScheduledMovePayload (id: string, newIndex: number).');let o=t;if(n){const e=this.#m(t,t);e&&(o=e.absoluteEnd)}const s={timestamp:o,action:e,type:i,payload:r};this.#o.push(s),this.#f(Date.now()),this.emit("taskScheduled",structuredClone(s))}remove(t){if(m(this.#e),"string"!=typeof t)throw new TypeError("id must be a string.");this.#i.filter(e=>e.id===t).forEach(t=>h(t)),this.#r.filter(e=>e.id===t).forEach(t=>h(t)),this.#n.filter(e=>e.content?.id===t).forEach(t=>h(t.content));const e=e=>e.id!==t&&e.content?.id!==t;this.#i=this.#i.filter(e),this.#r=this.#r.filter(e),this.#n=this.#n.filter(e),this.#o=this.#o.filter(e=>"add"===e.action&&"object"==typeof e.payload&&null!==e.payload&&"id"in e.payload?e.payload.id!==t||(h(e.payload),!1):e.payload!==t),this.#s.clear(),this.emit("contentRemoved",{id:t})}setConfig(t){m(this.#e),this.#l(t);const e={...this.#u,...t};this.#l(e),this.#u=e,this.#s.clear(),this.emit("configChanged",{config:this.config})}getCurrentEvent(){m(this.#e);const t=Date.now();return this.#f(t),this.#m(t,t)}queryTimeline(t,e=10){if(m(this.#e),"number"!=typeof e||isNaN(e))throw new TypeError("Invalid query limit value. Ensure it is a number.");if(e>this.#u.queryLimit||e<=0)throw new RangeError(`Invalid query limit. Ensure it is > 0 and <= ${this.#u.queryLimit}.`);const i=new p(JSON.parse(this._exportState())),r=[];let n=t;for(let o=0;o<e;o++){i.#f(n);const e=i.#p(n,t);if(!e)break;r.push(e),n=e.absoluteEnd}return i.destroy(!1),this.emit("timelineQueried",{targetDate:t,limit:e,resultCount:r.length}),r}searchCustomPositions(){return m(this.#e),this.#f(Date.now()),[...this.#n]}async _processListForExport(t){return Promise.all(t.map(async t=>{const e=structuredClone(t);return e.picture&&Array.isArray(e.picture)&&(e.picture=await Promise.all(e.picture.map(async t=>"string"==typeof t.data&&t.data.startsWith("blob:")?{...t,data:await d(t.data)}:t))),e}))}_exportState(){return JSON.stringify({music:this.#i,voice:this.#r,custom:this.#n,tasks:this.#o,seed:this.#a,anchorDate:this.#c,config:this.#u})}async exportState(){m(this.#e);const t=await this._processListForExport(this.#i),e=await this._processListForExport(this.#r),i=await Promise.all(this.#n.map(async t=>{const e=await this._processListForExport([t.content]);return{...t,content:e[0]}})),r=await Promise.all(this.#o.map(async t=>{if("add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload){const e=await this._processListForExport([t.payload]);return{...t,payload:e[0]}}return t}));return JSON.stringify({music:t,voice:e,custom:i,tasks:r,seed:this.#a,anchorDate:this.#c,config:this.#u})}importState(t){let e;if(m(this.#e),"string"==typeof t)try{e=JSON.parse(t)}catch{throw new TypeError("Provided string is not valid JSON.")}else{if("object"!=typeof t||null===t)throw new TypeError("Import data must be a valid JSON string or an object.");e=t}this.#d(e),this.emit("stateImported",{data:structuredClone(e)})}_prng(t){return function(){let e=t+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}#y(t,e,i,r=0){if(0===t.length)return[];if("random"!==i)return[...t];const n=t.map(t=>({...t,weight:t.weight??1})),o=this._prng(e),s=[];let a=null,c=0;for(;n.length>0;){let t=n;-1!==r&&null!==a&&c>r&&(t=n.filter(t=>t.id!==a),0===t.length&&(t=n));const e=t.reduce((t,e)=>t+e.weight,0);if(e<=0){s.push(...t);break}const i=o()*e;let u=0,l=null,d=-1;for(let e=0;e<t.length;e++)if(u+=t[e].weight,i<=u){l=t[e],d=n.findIndex(t=>l&&t.id===l.id);break}l&&-1!==d||(l=t[0],d=n.findIndex(t=>l&&t.id===l.id)),s.push(l),n.splice(d,1),l.id===a?c++:(a=l.id,c=1)}return s}#v(t){const e=this.#a+t,i=this._prng(10*e),r=this.#y(this.#i,e+1,this.#u.mode,this.#u.musicMaxConsecutive),n=this.#y(this.#r,e+2,this.#u.voiceMode,this.#u.voiceMaxConsecutive),o=[];let s=0,a=0;for(let t=0;t<r.length;t++){const e=r[t];if(o.push({...e,cycleStart:s,cycleEnd:s+e.duration}),s+=e.duration+this.#u.silenceDuration,this.#u.voiceAfterMusic&&n.length>0){const t=this.#u.voiceMax-this.#u.voiceMin+1,e=Math.floor(i()*t)+this.#u.voiceMin;for(let t=0;t<e;t++){const t=n[a%n.length];a++,o.push({...t,cycleStart:s,cycleEnd:s+t.duration}),s+=t.duration+this.#u.silenceDuration}}}return{items:o,duration:s}}#g(t){if(0===this.#i.length)return null;let e=this.#c,i=0;for(;;){if(i>this.#u.queryLimit)throw new Error("Safety limit hit during cycle location.");let r=this.#s.get(i);if(r||(r=this.#v(i),this.#s.set(i,r)),0===r.duration)return null;if(t>=e&&t<e+r.duration)return{block:r,startTimestamp:e,loopIndex:i};e+=r.duration,i++}}#p(t,e){const i=this.#n.filter(e=>e.intendedTimestamp+e.content.duration>t).sort((t,e)=>t.intendedTimestamp-e.intendedTimestamp)[0];let r=null;if(i){const t=Math.max(e,i.intendedTimestamp);r=this.#w(i.content,i.intendedTimestamp,t,!0)}const n=this.#b(t,e);return n||r?n?r?r.absoluteStart<=n.absoluteStart?r:(r.absoluteStart<n.absoluteEnd&&(n.absoluteEnd=r.absoluteStart,n.duration=n.absoluteEnd-n.absoluteStart,n.remainingTime=Math.max(0,n.absoluteEnd-e),n.progress=Math.min(1,n.elapsedTime/n.duration)),n):n:r:null}#b(t,e){let i=this.#g(t);if(!i)return null;const{block:r,startTimestamp:n}=i,o=t-n;let s,a=r.items.find(t=>t.cycleEnd>o);if(a)s=n+a.cycleStart;else{if(i=this.#g(n+r.duration),!i||0===i.block.items.length)return null;a=i.block.items[0],s=i.startTimestamp+a.cycleStart}const c=Math.max(e,s);return this.#w(a,s,c,!1)}#m(t,e){const i=this.#n.find(e=>t>=e.intendedTimestamp&&t<e.intendedTimestamp+e.content.duration);if(i)return this.#w(i.content,i.intendedTimestamp,e,!0);const r=this.#g(t);if(!r)return null;const{block:n,startTimestamp:o}=r,s=t-o,a=n.items.find(t=>s>=t.cycleStart&&s<t.cycleEnd);return a?this.#w(a,o+a.cycleStart,e,!1):null}#w(t,e,i,r){const n=i-e;return{id:t.id,title:t.title,artist:t.artist,duration:t.duration,url:t.url,absoluteStart:e,absoluteEnd:e+t.duration,elapsedTime:n,remainingTime:t.duration-n,progress:Math.min(1,n/t.duration),isCustom:r}}#h(t,e){let i=t.timestamp||Date.now();const r=t.duration;if(e){const t=this.#m(i,i);t&&(i=t.absoluteEnd)}const n=[...this.#n].sort((t,e)=>t.intendedTimestamp-e.intendedTimestamp);let o=i;if(n.some(t=>i<t.intendedTimestamp+t.content.duration&&i+r>t.intendedTimestamp)){const t=[];let e=Date.now();for(const i of n)i.intendedTimestamp>e&&t.push({start:e,end:i.intendedTimestamp}),e=Math.max(e,i.intendedTimestamp+i.content.duration+this.#u.silenceDuration);t.push({start:e,end:1/0});let s=1/0;for(const e of t)if(e.end-e.start>=r){let t=null;if(i>=e.start&&i+r<=e.end?t=i:i<e.start?t=e.start:i>e.end&&(t=e.end-r),null!==t){const e=Math.abs(i-t);e<s&&(s=e,o=t)}}}this.#n.push({content:t,intendedTimestamp:o,originalTimestamp:t.timestamp||Date.now()})}#f(t){const e=this.#o.filter(e=>e.timestamp<=t);this.#o=this.#o.filter(e=>e.timestamp>t);const i=this.#n.filter(e=>e.intendedTimestamp+e.content.duration<=t);this.#n=this.#n.filter(e=>e.intendedTimestamp+e.content.duration>t);let r=!1;i.forEach(t=>{h(t.content),this.#a+=t.content.id.length,r=!0,this.emit("customPositionExpired",{contentId:t.content.id})}),e.length>0&&e.sort((t,e)=>t.timestamp-e.timestamp).forEach(t=>{const e="music"===t.type?this.#i:this.#r;if("add"===t.action)e.push(t.payload);else if("remove"===t.action){const i=t.payload,r=e.findIndex(t=>t.id===i);if(-1!==r){const[t]=e.splice(r,1);h(t)}}else if("move"===t.action){const i=t.payload,r=e.findIndex(t=>t.id===i.id);if(-1!==r){const[t]=e.splice(r,1);e.splice(i.newIndex,0,t)}}this.#c=t.timestamp,this.#a+=1,r=!0,this.emit("taskExecuted",structuredClone(t))}),r&&this.#s.clear()}#d(t){this.#i.forEach(t=>h(t)),this.#r.forEach(t=>h(t)),this.#n.forEach(t=>h(t.content)),this.#o.forEach(t=>{"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload&&h(t.payload)});const e=t=>t.map(t=>{const e={...t};return e.picture&&Array.isArray(e.picture)&&(e.picture=e.picture.map(t=>{const e="string"==typeof t.data&&t.data.startsWith("data:"),i=t.data instanceof Uint8Array;return e||i?{...t,data:l(t.data,t.format)}:t})),e});this.#i=e(t.music),this.#r=e(t.voice),this.#a=t.seed||0,this.#c=t.anchorDate||Date.now(),this.#u={...this.#u,...t.config||{}},this.#n=t.custom.map(t=>({...t,content:e([t.content])[0]})),this.#o=t.tasks.map(t=>"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload?{...t,payload:e([t.payload])[0]}:t)}destroy(t=!0){this.#e||(t&&(this.#i.forEach(t=>h(t)),this.#r.forEach(t=>h(t)),this.#n.forEach(t=>h(t.content)),this.#o.forEach(t=>{"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload&&h(t.payload)})),this.#i=[],this.#r=[],this.#n=[],this.#o=[],this.#s.clear(),this.emit("destroyed",{timestamp:Date.now()}),this.removeAllListeners(),this.#e=!0)}}const y=p}};const e={};function i(r){const n=e[r];if(void 0!==n)return n.exports;const o=e[r]={exports:{}};return t[r](o,o.exports,i),o.exports}i.d=(t,e)=>{if(Array.isArray(e))for(var r=0;r<e.length;){var n=e[r++],o=e[r++];i.o(t,n)?0===o&&r++:0===o?Object.defineProperty(t,n,{enumerable:!0,value:e[r++]}):Object.defineProperty(t,n,{enumerable:!0,get:o})}else for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.cjs=t=>{const e={exports:{}};return t.call(e.exports,e,e.exports),e.exports};let r=i(669);window.TinyRadioFm=r.TinyRadioFm})();