UNPKG

react-h5-audio-player

Version:

A customizable React audio player. Written in TypeScript. Mobile compatible. Keyboard friendly

1 lines 43.4 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React")):"function"==typeof define&&define.amd?define("ReactH5AudioPlayer",["React"],t):"object"==typeof exports?exports.ReactH5AudioPlayer=t(require("React")):e.ReactH5AudioPlayer=t(e.React)}(self,(e=>(()=>{"use strict";var t={883:t=>{t.exports=e}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};o.r(r),o.d(r,{RHAP_UI:()=>Ke,default:()=>Xe});var i=o(883),s=o.n(i);const a=Object.freeze({left:0,top:0,width:16,height:16}),u=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),l=Object.freeze({...a,...u}),c=Object.freeze({...l,body:"",hidden:!1});function d(e,t){const n=function(e,t){const n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);const o=((e.rotate||0)+(t.rotate||0))%4;return o&&(n.rotate=o),n}(e,t);for(const o in c)o in u?o in e&&!(o in n)&&(n[o]=u[o]):o in t?n[o]=t[o]:o in e&&(n[o]=e[o]);return n}function h(e,t,n){const o=e.icons,r=e.aliases||Object.create(null);let i={};function s(e){i=d(o[e]||r[e],i)}return s(t),n.forEach(s),d(e,i)}function p(e,t){const n=[];if("object"!=typeof e||"object"!=typeof e.icons)return n;e.not_found instanceof Array&&e.not_found.forEach((e=>{t(e,null),n.push(e)}));const o=function(e){const t=e.icons,n=e.aliases||Object.create(null),o=Object.create(null);return Object.keys(t).concat(Object.keys(n)).forEach((function e(r){if(t[r])return o[r]=[];if(!(r in o)){o[r]=null;const t=n[r]&&n[r].parent,i=t&&e(t);i&&(o[r]=[t].concat(i))}return o[r]})),o}(e);for(const r in o){const i=o[r];i&&(t(r,h(e,r,i)),n.push(r))}return n}const f={provider:"",aliases:{},not_found:{},...a};function m(e,t){for(const n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function g(e){if("object"!=typeof e||null===e)return null;const t=e;if("string"!=typeof t.prefix||!e.icons||"object"!=typeof e.icons)return null;if(!m(e,f))return null;const n=t.icons;for(const e in n){const t=n[e];if(!e||"string"!=typeof t.body||!m(t,c))return null}const o=t.aliases||Object.create(null);for(const e in o){const t=o[e],r=t.parent;if(!e||"string"!=typeof r||!n[r]&&!o[r]||!m(t,c))return null}return t}const v=/^[a-z0-9]+(-[a-z0-9]+)*$/,E=function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const r=e.split(":");if("@"===e.slice(0,1)){if(r.length<2||r.length>3)return null;o=r.shift().slice(1)}if(r.length>3||!r.length)return null;if(r.length>1){const e=r.pop(),n=r.pop(),i={provider:r.length>0?r[0]:o,prefix:n,name:e};return t&&!y(i)?null:i}const i=r[0],s=i.split("-");if(s.length>1){const e={provider:o,prefix:s.shift(),name:s.join("-")};return t&&!y(e)?null:e}if(n&&""===o){const e={provider:o,prefix:"",name:i};return t&&!y(e,n)?null:e}return null},y=(e,t)=>!!e&&!(!(t&&""===e.prefix||e.prefix)||!e.name),w=Object.create(null);function b(e,t){const n=w[e]||(w[e]=Object.create(null));return n[t]||(n[t]=function(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}(e,t))}function T(e,t){return g(t)?p(t,((t,n)=>{n?e.icons[t]=n:e.missing.add(t)})):[]}let C=!1;function L(e){return"boolean"==typeof e&&(C=e),C}function A(e){const t="string"==typeof e?E(e,!0,C):e;if(t){const e=b(t.provider,t.prefix),n=t.name;return e.icons[n]||(e.missing.has(n)?null:void 0)}}const M=Object.freeze({width:null,height:null}),O=Object.freeze({...M,...u}),P=/(-?[0-9.]*[0-9]+[0-9.]*)/g,k=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function x(e,t,n){if(1===t)return e;if(n=n||100,"number"==typeof e)return Math.ceil(e*t*n)/n;if("string"!=typeof e)return e;const o=e.split(P);if(null===o||!o.length)return e;const r=[];let i=o.shift(),s=k.test(i);for(;;){if(s){const e=parseFloat(i);isNaN(e)?r.push(i):r.push(Math.ceil(e*t*n)/n)}else r.push(i);if(i=o.shift(),void 0===i)return r.join("");s=!s}}const S=/\sid="(\S+)"/g,_="IconifyId"+Date.now().toString(16)+(16777216*Math.random()|0).toString(16);let D=0;function N(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_;const n=[];let o;for(;o=S.exec(e);)n.push(o[1]);if(!n.length)return e;const r="suffix"+(16777216*Math.random()|Date.now()).toString(16);return n.forEach((n=>{const o="function"==typeof t?t(n):t+(D++).toString(),i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+i+')([")]|\\.[a-z])',"g"),"$1"+o+r+"$3")})),e=e.replace(new RegExp(r,"g"),"")}const R=Object.create(null);function V(e){return R[e]||R[""]}function U(e){let t;if("string"==typeof e.resources)t=[e.resources];else if(t=e.resources,!(t instanceof Array&&t.length))return null;return{resources:t,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:!0===e.random,index:e.index||0,dataAfterTimeout:!1!==e.dataAfterTimeout}}const I=Object.create(null),F=["https://api.simplesvg.com","https://api.unisvg.com"],j=[];for(;F.length>0;)1===F.length||Math.random()>.5?j.push(F.shift()):j.push(F.pop());function B(e,t){const n=U(t);return null!==n&&(I[e]=n,!0)}function W(e){return I[e]}I[""]=U({resources:["https://api.iconify.design"].concat(j)});let $=(()=>{let e;try{if(e=fetch,"function"==typeof e)return e}catch(e){}})();const z={prepare:(e,t,n)=>{const o=[],r=function(e,t){const n=W(e);if(!n)return 0;let o;if(n.maxURL){let e=0;n.resources.forEach((t=>{const n=t;e=Math.max(e,n.length)}));const r=t+".json?icons=";o=n.maxURL-e-n.path.length-r.length}else o=0;return o}(e,t),i="icons";let s={type:i,provider:e,prefix:t,icons:[]},a=0;return n.forEach(((n,u)=>{a+=n.length+1,a>=r&&u>0&&(o.push(s),s={type:i,provider:e,prefix:t,icons:[]},a=n.length),s.icons.push(n)})),o.push(s),o},send:(e,t,n)=>{if(!$)return void n("abort",424);let o=function(e){if("string"==typeof e){const t=W(e);if(t)return t.path}return"/"}(t.provider);switch(t.type){case"icons":{const e=t.prefix,n=t.icons.join(",");o+=e+".json?"+new URLSearchParams({icons:n}).toString();break}case"custom":{const e=t.uri;o+="/"===e.slice(0,1)?e.slice(1):e;break}default:return void n("abort",400)}let r=503;$(e+o).then((e=>{const t=e.status;if(200===t)return r=501,e.json();setTimeout((()=>{n(function(e){return 404===e}(t)?"abort":"next",t)}))})).then((e=>{"object"==typeof e&&null!==e?setTimeout((()=>{n("success",e)})):setTimeout((()=>{404===e?n("abort",e):n("next",r)}))})).catch((()=>{n("next",r)}))}};function J(e,t){e.forEach((e=>{const n=e.loaderCallbacks;n&&(e.loaderCallbacks=n.filter((e=>e.id!==t)))}))}let H=0;var G={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function q(e){const t={...G,...e};let n=[];function o(){n=n.filter((e=>"pending"===e().status))}return{query:function(e,r,i){const s=function(e,t,n,o){const r=e.resources.length,i=e.random?Math.floor(Math.random()*r):e.index;let s;if(e.random){let t=e.resources.slice(0);for(s=[];t.length>1;){const e=Math.floor(Math.random()*t.length);s.push(t[e]),t=t.slice(0,e).concat(t.slice(e+1))}s=s.concat(t)}else s=e.resources.slice(i).concat(e.resources.slice(0,i));const a=Date.now();let u,l="pending",c=0,d=null,h=[],p=[];function f(){d&&(clearTimeout(d),d=null)}function m(){"pending"===l&&(l="aborted"),f(),h.forEach((e=>{"pending"===e.status&&(e.status="aborted")})),h=[]}function g(e,t){t&&(p=[]),"function"==typeof e&&p.push(e)}function v(){l="failed",p.forEach((e=>{e(void 0,u)}))}function E(){h.forEach((e=>{"pending"===e.status&&(e.status="aborted")})),h=[]}return"function"==typeof o&&p.push(o),setTimeout((function o(){if("pending"!==l)return;f();const r=s.shift();if(void 0===r)return h.length?void(d=setTimeout((()=>{f(),"pending"===l&&(E(),v())}),e.timeout)):void v();const i={status:"pending",resource:r,callback:(t,n)=>{!function(t,n,r){const i="success"!==n;switch(h=h.filter((e=>e!==t)),l){case"pending":break;case"failed":if(i||!e.dataAfterTimeout)return;break;default:return}if("abort"===n)return u=r,void v();if(i)return u=r,void(h.length||(s.length?o():v()));if(f(),E(),!e.random){const n=e.resources.indexOf(t.resource);-1!==n&&n!==e.index&&(e.index=n)}l="completed",p.forEach((e=>{e(r)}))}(i,t,n)}};h.push(i),c++,d=setTimeout(o,e.rotate),n(r,t,i.callback)})),function(){return{startTime:a,payload:t,status:l,queriesSent:c,queriesPending:h.length,subscribe:g,abort:m}}}(t,e,r,((e,t)=>{o(),i&&i(e,t)}));return n.push(s),s},find:function(e){return n.find((t=>e(t)))||null},setIndex:e=>{t.index=e},getIndex:()=>t.index,cleanup:o}}function K(){}const Q=Object.create(null);const X="iconify2",Y="iconify",Z=Y+"-count",ee=Y+"-version",te=36e5;function ne(e,t){try{return e.getItem(t)}catch(e){}}function oe(e,t,n){try{return e.setItem(t,n),!0}catch(e){}}function re(e,t){try{e.removeItem(t)}catch(e){}}function ie(e,t){return oe(e,Z,t.toString())}function se(e){return parseInt(ne(e,Z))||0}const ae={local:!0,session:!0},ue={local:new Set,session:new Set};let le=!1,ce="undefined"==typeof window?{}:window;function de(e){const t=e+"Storage";try{if(ce&&ce[t]&&"number"==typeof ce[t].length)return ce[t]}catch(e){}ae[e]=!1}function he(e,t){const n=de(e);if(!n)return;const o=ne(n,ee);if(o!==X){if(o){const e=se(n);for(let t=0;t<e;t++)re(n,Y+t.toString())}return oe(n,ee,X),void ie(n,0)}const r=Math.floor(Date.now()/te)-168,i=e=>{const o=Y+e.toString(),i=ne(n,o);if("string"==typeof i){try{const n=JSON.parse(i);if("object"==typeof n&&"number"==typeof n.cached&&n.cached>r&&"string"==typeof n.provider&&"object"==typeof n.data&&"string"==typeof n.data.prefix&&t(n,e))return!0}catch(e){}re(n,o)}};let s=se(n);for(let t=s-1;t>=0;t--)i(t)||(t===s-1?(s--,ie(n,s)):ue[e].add(t))}function pe(){if(!le){le=!0;for(const e in ae)he(e,(e=>{const t=e.data,n=b(e.provider,t.prefix);if(!T(n,t).length)return!1;const o=t.lastModified||-1;return n.lastModifiedCached=n.lastModifiedCached?Math.min(n.lastModifiedCached,o):o,!0}))}}function fe(){}function me(e,t,n,o){function r(){const n=e.pendingIcons;t.forEach((t=>{n&&n.delete(t),e.icons[t]||e.missing.add(t)}))}if(n&&"object"==typeof n)try{if(!T(e,n).length)return void r();o&&function(e,t){function n(n){let o;if(!ae[n]||!(o=de(n)))return;const r=ue[n];let i;if(r.size)r.delete(i=Array.from(r).shift());else if(i=se(o),i>=50||!ie(o,i+1))return;const s={cached:Math.floor(Date.now()/te),provider:e.provider,data:t};return oe(o,Y+i.toString(),JSON.stringify(s))}le||pe(),t.lastModified&&!function(e,t){const n=e.lastModifiedCached;if(n&&n>=t)return n===t;if(e.lastModifiedCached=t,n)for(const n in ae)he(n,(n=>{const o=n.data;return n.provider!==e.provider||o.prefix!==e.prefix||o.lastModified===t}));return!0}(e,t.lastModified)||Object.keys(t.icons).length&&(t.not_found&&delete(t=Object.assign({},t)).not_found,n("local")||n("session"))}(e,n)}catch(e){console.error(e)}r(),function(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout((()=>{e.iconsLoaderFlag=!1,function(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout((()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1;const o=e.provider,r=e.prefix;t.forEach((t=>{const i=t.icons,s=i.pending.length;i.pending=i.pending.filter((t=>{if(t.prefix!==r)return!0;const s=t.name;if(e.icons[s])i.loaded.push({provider:o,prefix:r,name:s});else{if(!e.missing.has(s))return n=!0,!0;i.missing.push({provider:o,prefix:r,name:s})}return!1})),i.pending.length!==s&&(n||J([e],t.id),t.callback(i.loaded.slice(0),i.missing.slice(0),i.pending.slice(0),t.abort))}))})))}(e)})))}(e)}function ge(e,t){e instanceof Promise?e.then((e=>{t(e)})).catch((()=>{t(null)})):t(e)}function ve(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout((()=>{e.iconsQueueFlag=!1;const{provider:t,prefix:n}=e,o=e.iconsToLoad;if(delete e.iconsToLoad,!o||!o.length)return;const r=e.loadIcon;if(e.loadIcons&&(o.length>1||!r))return void ge(e.loadIcons(o,n,t),(t=>{me(e,o,t,!1)}));if(r)return void o.forEach((o=>{ge(r(o,n,t),(t=>{me(e,[o],t?{prefix:n,icons:{[o]:t}}:null,!1)}))}));const{valid:i,invalid:s}=function(e){const t=[],n=[];return e.forEach((e=>{(e.match(v)?t:n).push(e)})),{valid:t,invalid:n}}(o);if(s.length&&me(e,s,null,!1),!i.length)return;const a=n.match(v)?V(t):null;a?a.prepare(t,n,i).forEach((n=>{!function(e,t,n){let o,r;if("string"==typeof e){const t=V(e);if(!t)return n(void 0,424),K;r=t.send;const i=function(e){if(!Q[e]){const t=W(e);if(!t)return;const n={config:t,redundancy:q(t)};Q[e]=n}return Q[e]}(e);i&&(o=i.redundancy)}else{const t=U(e);if(t){o=q(t);const n=V(e.resources?e.resources[0]:"");n&&(r=n.send)}}o&&r?o.query(t,r,n)().abort:n(void 0,424)}(t,n,(t=>{me(e,n.icons,t,!0)}))})):me(e,i,null,!1)})))}const Ee=/[\s,]+/;function ye(e,t){t.split(Ee).forEach((t=>{switch(t.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0}}))}function we(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=e.replace(/^-?[0-9.]*/,"");function o(e){for(;e<0;)e+=4;return e%4}if(""===n){const t=parseInt(e);return isNaN(t)?0:o(t)}if(n!==e){let t=0;switch(n){case"%":t=25;break;case"deg":t=90}if(t){let r=parseFloat(e.slice(0,e.length-n.length));return isNaN(r)?0:(r/=t,r%1==0?o(r):0)}}return t}let be;function Te(e){return void 0===be&&function(){try{be=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch(e){be=null}}(),be?be.createHTML(e):e}const Ce={...O,inline:!1},Le={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},Ae={display:"inline-block"},Me={backgroundColor:"currentColor"},Oe={backgroundColor:"transparent"},Pe={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},ke={WebkitMask:Me,mask:Me,background:Oe};for(const e in ke){const t=ke[e];for(const n in Pe)t[e+n]=Pe[n]}const xe={...Ce,inline:!0};function Se(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}if(L(!0),_e=z,R[""]=_e,"undefined"!=typeof document&&"undefined"!=typeof window){pe();const e=window;if(void 0!==e.IconifyPreload){const t=e.IconifyPreload,n="Invalid IconifyPreload syntax.";"object"==typeof t&&null!==t&&(t instanceof Array?t:[t]).forEach((e=>{try{("object"!=typeof e||null===e||e instanceof Array||"object"!=typeof e.icons||"string"!=typeof e.prefix||!function(e,t){if("object"!=typeof e)return!1;if("string"!=typeof t&&(t=e.provider||""),C&&!t&&!e.prefix){let t=!1;return g(e)&&(e.prefix="",p(e,((e,n)=>{(function(e,t){const n=E(e,!0,C);if(!n)return!1;const o=b(n.provider,n.prefix);return t?function(e,t,n){try{if("string"==typeof n.body)return e.icons[t]={...n},!0}catch(e){}return!1}(o,n.name,t):(o.missing.add(n.name),!0)})(e,n)&&(t=!0)}))),t}const n=e.prefix;return!!y({provider:t,prefix:n,name:"a"})&&!!T(b(t,n),e)}(e))&&console.error(n)}catch(e){console.error(n)}}))}if(void 0!==e.IconifyProviders){const t=e.IconifyProviders;if("object"==typeof t&&null!==t)for(let e in t){const n="IconifyProviders["+e+"] is invalid.";try{const o=t[e];if("object"!=typeof o||!o||void 0===o.resources)continue;B(e,o)||console.error(n)}catch(e){console.error(n)}}}}var _e;function De(e){const[t,n]=(0,i.useState)(!!e.ssr),[o,r]=(0,i.useState)({}),[s,a]=(0,i.useState)(function(t){if(t){const t=e.icon;if("object"==typeof t)return{name:"",data:t};const n=A(t);if(n)return{name:t,data:n}}return{name:""}}(!!e.ssr));function u(){const e=o.callback;e&&(e(),r({}))}function c(e){if(JSON.stringify(s)!==JSON.stringify(e))return u(),a(e),!0}function d(){var t;const n=e.icon;if("object"==typeof n)return void c({name:"",data:n});const o=A(n);if(c({name:n,data:o}))if(void 0===o){const e=((e,t)=>{const n=function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const o=[];return e.forEach((e=>{const r="string"==typeof e?E(e,t,n):e;r&&o.push(r)})),o}(e,!0,L()),o=function(e){const t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort(((e,t)=>e.provider!==t.provider?e.provider.localeCompare(t.provider):e.prefix!==t.prefix?e.prefix.localeCompare(t.prefix):e.name.localeCompare(t.name)));let o={provider:"",prefix:"",name:""};return e.forEach((e=>{if(o.name===e.name&&o.prefix===e.prefix&&o.provider===e.provider)return;o=e;const r=e.provider,i=e.prefix,s=e.name,a=n[r]||(n[r]=Object.create(null)),u=a[i]||(a[i]=b(r,i));let l;l=s in u.icons?t.loaded:""===i||u.missing.has(s)?t.missing:t.pending;const c={provider:r,prefix:i,name:s};l.push(c)})),t}(n);if(!o.pending.length){let e=!0;return t&&setTimeout((()=>{e&&t(o.loaded,o.missing,o.pending,fe)})),()=>{e=!1}}const r=Object.create(null),i=[];let s,a;return o.pending.forEach((e=>{const{provider:t,prefix:n}=e;if(n===a&&t===s)return;s=t,a=n,i.push(b(t,n));const o=r[t]||(r[t]=Object.create(null));o[n]||(o[n]=[])})),o.pending.forEach((e=>{const{provider:t,prefix:n,name:o}=e,i=b(t,n),s=i.pendingIcons||(i.pendingIcons=new Set);s.has(o)||(s.add(o),r[t][n].push(o))})),i.forEach((e=>{const t=r[e.provider][e.prefix];t.length&&ve(e,t)})),t?function(e,t,n){const o=H++,r=J.bind(null,n,o);if(!t.pending.length)return r;const i={id:o,icons:t,callback:e,abort:r};return n.forEach((e=>{(e.loaderCallbacks||(e.loaderCallbacks=[])).push(i)})),r}(t,o,i):fe})([n],d);r({callback:e})}else o&&(null===(t=e.onLoad)||void 0===t||t.call(e,n))}(0,i.useEffect)((()=>(n(!0),u)),[]),(0,i.useEffect)((()=>{t&&d()}),[e.icon,t]);const{name:h,data:p}=s;return p?((e,t,n)=>{const o=t.inline?xe:Ce,r=function(e,t){const n={...e};for(const e in t){const o=t[e],r=typeof o;e in M?(null===o||o&&("string"===r||"number"===r))&&(n[e]=o):r===typeof n[e]&&(n[e]="rotate"===e?o%4:o)}return n}(o,t),s=t.mode||"svg",a={},u=t.style||{},c={..."svg"===s?Le:{}};if(n){const e=E(n,!1,!0);if(e){const t=["iconify"],n=["provider","prefix"];for(const o of n)e[o]&&t.push("iconify--"+e[o]);c.className=t.join(" ")}}for(let e in t){const n=t[e];if(void 0!==n)switch(e){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":break;case"_ref":c.ref=n;break;case"className":c[e]=(c[e]?c[e]+" ":"")+n;break;case"inline":case"hFlip":case"vFlip":r[e]=!0===n||"true"===n||1===n;break;case"flip":"string"==typeof n&&ye(r,n);break;case"color":a.color=n;break;case"rotate":"string"==typeof n?r[e]=we(n):"number"==typeof n&&(r[e]=n);break;case"ariaHidden":case"aria-hidden":!0!==n&&"true"!==n&&delete c["aria-hidden"];break;default:void 0===o[e]&&(c[e]=n)}}const d=function(e,t){const n={...l,...e},o={...O,...t},r={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,o].forEach((e=>{const t=[],n=e.hFlip,o=e.vFlip;let s,a=e.rotate;switch(n?o?a+=2:(t.push("translate("+(r.width+r.left).toString()+" "+(0-r.top).toString()+")"),t.push("scale(-1 1)"),r.top=r.left=0):o&&(t.push("translate("+(0-r.left).toString()+" "+(r.height+r.top).toString()+")"),t.push("scale(1 -1)"),r.top=r.left=0),a<0&&(a-=4*Math.floor(a/4)),a%=4,a){case 1:s=r.height/2+r.top,t.unshift("rotate(90 "+s.toString()+" "+s.toString()+")");break;case 2:t.unshift("rotate(180 "+(r.width/2+r.left).toString()+" "+(r.height/2+r.top).toString()+")");break;case 3:s=r.width/2+r.left,t.unshift("rotate(-90 "+s.toString()+" "+s.toString()+")")}a%2==1&&(r.left!==r.top&&(s=r.left,r.left=r.top,r.top=s),r.width!==r.height&&(s=r.width,r.width=r.height,r.height=s)),t.length&&(i=function(e,t){const n=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"defs",n="";const o=e.indexOf("<"+t);for(;o>=0;){const r=e.indexOf(">",o),i=e.indexOf("</"+t);if(-1===r||-1===i)break;const s=e.indexOf(">",i);if(-1===s)break;n+=e.slice(r+1,i).trim(),e=e.slice(0,o).trim()+e.slice(s+1)}return{defs:n,content:e}}(e);return o=n.defs,r=t+n.content+"</g>",o?"<defs>"+o+"</defs>"+r:r;var o,r}(i,'<g transform="'+t.join(" ")+'">'))}));const s=o.width,a=o.height,u=r.width,c=r.height;let d,h;null===s?(h=null===a?"1em":"auto"===a?c:a,d=x(h,u/c)):(d="auto"===s?u:s,h=null===a?x(d,c/u):"auto"===a?c:a);const p={},f=(e,t)=>{(e=>"unset"===e||"undefined"===e||"none"===e)(t)||(p[e]=t.toString())};f("width",d),f("height",h);const m=[r.left,r.top,u,c];return p.viewBox=m.join(" "),{attributes:p,viewBox:m,body:i}}(e,r),h=d.attributes;if(r.inline&&(a.verticalAlign="-0.125em"),"svg"===s){c.style={...a,...u},Object.assign(c,h);let e=0,n=t.id;return"string"==typeof n&&(n=n.replace(/-/g,"_")),c.dangerouslySetInnerHTML={__html:Te(N(d.body,n?()=>n+"ID"+e++:"iconifyReact"))},(0,i.createElement)("svg",c)}const{body:p,width:f,height:m}=e,g="mask"===s||"bg"!==s&&-1!==p.indexOf("currentColor"),v=function(e,t){let n=-1===e.indexOf("xlink:")?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const e in t)n+=" "+e+'="'+t[e]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+e+"</svg>"}(p,{...h,width:f+"",height:m+""});var y;return c.style={...a,"--svg":(y=v,'url("'+function(e){return"data:image/svg+xml,"+function(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}(e)}(y)+'")'),width:Se(h.width),height:Se(h.height),...Ae,...g?Me:Oe,...u},(0,i.createElement)("span",c)})({...l,...p},e,h):e.children?e.children:(0,i.createElement)("span",{})}const Ne=(0,i.forwardRef)(((e,t)=>De({...e,_ref:t})));function Re(){return Re=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},Re.apply(null,arguments)}(0,i.forwardRef)(((e,t)=>De({inline:!0,...e,_ref:t})));const Ve=e=>{switch(e){case"stacked":default:return"rhap_stacked";case"stacked-reverse":return"rhap_stacked-reverse";case"horizontal":return"rhap_horizontal";case"horizontal-reverse":return"rhap_horizontal-reverse"}},Ue=e=>e instanceof MouseEvent?e.clientX:e.touches[0].clientX,Ie=e=>e>9?e.toString():`0${e}`,Fe=(e,t,n)=>{if(!isFinite(e))return null;const o=Math.floor(e/60),r=Ie(o),i=Ie(Math.floor(e%60)),s=Ie(Math.floor(o%60)),a=`${r}:${i}`,u=`${Math.floor(o/60)}:${s}:${i}`;return"auto"===n?t>=3600?u:a:"mm:ss"===n?a:"hh:mm:ss"===n?u:void 0};function je(e,t){let n=!1;return o=>{n||(e(o),n=!0,setTimeout((()=>n=!1),t))}}class Be extends i.Component{timeOnMouseMove=0;hasAddedAudioEventListener=!1;state={isDraggingProgress:!1,currentTimePos:"0%",hasDownloadProgressAnimation:!1,downloadProgressArr:[],waitingForSeekCallback:!1};getDuration(){const{audio:e,srcDuration:t}=this.props;return void 0===t?e.duration:t}getCurrentProgress=e=>{const{audio:t,progressBar:n}=this.props;if(!(0===t.src.indexOf("blob:")||void 0!==this.props.srcDuration||t.src&&isFinite(t.currentTime)&&n.current))return{currentTime:0,currentTimePos:"0%"};const o=n.current.getBoundingClientRect(),r=o.width;let i=Ue(e)-o.left;return i<0?i=0:i>r&&(i=r),{currentTime:this.getDuration()*i/r,currentTimePos:`${(i/r*100).toFixed(2)}%`}};handleContextMenu=e=>{e.preventDefault()};handleMouseDownOrTouchStartProgressBar=e=>{e.stopPropagation();const{currentTime:t,currentTimePos:n}=this.getCurrentProgress(e.nativeEvent);isFinite(t)&&(this.timeOnMouseMove=t,this.setState({isDraggingProgress:!0,currentTimePos:n}),e.nativeEvent instanceof MouseEvent?(window.addEventListener("mousemove",this.handleWindowMouseOrTouchMove),window.addEventListener("mouseup",this.handleWindowMouseOrTouchUp)):(window.addEventListener("touchmove",this.handleWindowMouseOrTouchMove),window.addEventListener("touchend",this.handleWindowMouseOrTouchUp)))};handleWindowMouseOrTouchMove=e=>{e instanceof MouseEvent&&e.preventDefault(),e.stopPropagation();const t=window.getSelection();t&&"Range"===t.type&&t.empty();const{isDraggingProgress:n}=this.state;if(n){const{currentTime:t,currentTimePos:n}=this.getCurrentProgress(e);this.timeOnMouseMove=t,this.setState({currentTimePos:n})}};handleWindowMouseOrTouchUp=e=>{e.stopPropagation();const t=this.timeOnMouseMove,{audio:n,onChangeCurrentTimeError:o,onSeek:r}=this.props;if(r)this.setState({isDraggingProgress:!1,waitingForSeekCallback:!0},(()=>{r(n,t).then((()=>this.setState({waitingForSeekCallback:!1})),(e=>{throw new Error(e)}))}));else{const e={isDraggingProgress:!1};if(n.readyState===n.HAVE_NOTHING||n.readyState===n.HAVE_METADATA||!isFinite(t))try{n.load()}catch(t){return e.currentTimePos="0%",o&&o(t)}n.currentTime=t,this.setState(e)}e instanceof MouseEvent?(window.removeEventListener("mousemove",this.handleWindowMouseOrTouchMove),window.removeEventListener("mouseup",this.handleWindowMouseOrTouchUp)):(window.removeEventListener("touchmove",this.handleWindowMouseOrTouchMove),window.removeEventListener("touchend",this.handleWindowMouseOrTouchUp))};handleAudioTimeUpdate=(()=>je((e=>{const{isDraggingProgress:t}=this.state,n=e.target;if(t||!0===this.state.waitingForSeekCallback)return;const{currentTime:o}=n,r=this.getDuration();this.setState({currentTimePos:`${(o/r*100||0).toFixed(2)}%`})}),this.props.progressUpdateInterval))();handleAudioDownloadProgressUpdate=e=>{const t=e.target,n=this.getDuration(),o=[];for(let e=0;e<t.buffered.length;e++){const r=t.buffered.start(e),i=t.buffered.end(e);o.push({left:`${Math.round(100/n*r)||0}%`,width:`${Math.round(100/n*(i-r))||0}%`})}clearTimeout(this.downloadProgressAnimationTimer),this.setState({downloadProgressArr:o,hasDownloadProgressAnimation:!0}),this.downloadProgressAnimationTimer=setTimeout((()=>{this.setState({hasDownloadProgressAnimation:!1})}),200)};initialize(){const{audio:e}=this.props;e&&!this.hasAddedAudioEventListener&&(this.audio=e,this.hasAddedAudioEventListener=!0,e.addEventListener("timeupdate",this.handleAudioTimeUpdate),e.addEventListener("progress",this.handleAudioDownloadProgressUpdate))}componentDidMount(){this.initialize()}componentDidUpdate(){this.initialize()}componentWillUnmount(){this.audio&&this.hasAddedAudioEventListener&&(this.audio.removeEventListener("timeupdate",this.handleAudioTimeUpdate),this.audio.removeEventListener("progress",this.handleAudioDownloadProgressUpdate)),clearTimeout(this.downloadProgressAnimationTimer)}render(){const{showDownloadProgress:e,showFilledProgress:t,progressBar:n,i18nProgressBar:o}=this.props,{currentTimePos:r,downloadProgressArr:i,hasDownloadProgressAnimation:a}=this.state;return s().createElement("div",{className:"rhap_progress-container",ref:n,"aria-label":o,role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Number(r.split("%")[0]),tabIndex:0,onMouseDown:this.handleMouseDownOrTouchStartProgressBar,onTouchStart:this.handleMouseDownOrTouchStartProgressBar,onContextMenu:this.handleContextMenu},s().createElement("div",{className:"rhap_progress-bar "+(e?"rhap_progress-bar-show-download":"")},s().createElement("div",{className:"rhap_progress-indicator",style:{left:r}}),t&&s().createElement("div",{className:"rhap_progress-filled",style:{width:r}}),e&&i.map(((e,t)=>{let{left:n,width:o}=e;return s().createElement("div",{key:t,className:"rhap_download-progress",style:{left:n,width:o,transitionDuration:a?".2s":"0s"}})}))))}}const We=(0,i.forwardRef)(((e,t)=>s().createElement(Be,Re({},e,{progressBar:t}))));class $e extends i.PureComponent{hasAddedAudioEventListener=!1;constructor(e){super(e);const{audio:t,defaultCurrentTime:n,isLeftTime:o,timeFormat:r}=e;let i=n;t&&(i=Fe(o?t.duration-t.currentTime:t.currentTime,t.duration,r)),this.state={currentTime:i}}state={currentTime:this.props.defaultCurrentTime};handleAudioCurrentTimeChange=e=>{const t=e.target,{isLeftTime:n,timeFormat:o,defaultCurrentTime:r}=this.props;this.setState({currentTime:Fe(n?t.duration-t.currentTime:t.currentTime,t.duration,o)||r})};addAudioEventListeners=()=>{const{audio:e}=this.props;e&&!this.hasAddedAudioEventListener&&(this.audio=e,this.hasAddedAudioEventListener=!0,e.addEventListener("timeupdate",this.handleAudioCurrentTimeChange),e.addEventListener("loadedmetadata",this.handleAudioCurrentTimeChange))};componentDidMount(){this.addAudioEventListeners()}componentDidUpdate(){this.addAudioEventListeners()}componentWillUnmount(){this.audio&&this.hasAddedAudioEventListener&&(this.audio.removeEventListener("timeupdate",this.handleAudioCurrentTimeChange),this.audio.removeEventListener("loadedmetadata",this.handleAudioCurrentTimeChange))}render(){return this.state.currentTime}}const ze=$e;class Je extends i.PureComponent{hasAddedAudioEventListener=!1;constructor(e){super(e);const{audio:t,timeFormat:n,defaultDuration:o}=e;this.state={duration:t?Fe(t.duration,t.duration,n):o}}state=(()=>({duration:this.props.audio?Fe(this.props.audio.duration,this.props.audio.duration,this.props.timeFormat):this.props.defaultDuration}))();handleAudioDurationChange=e=>{const t=e.target,{timeFormat:n,defaultDuration:o}=this.props;this.setState({duration:Fe(t.duration,t.duration,n)||o})};addAudioEventListeners=()=>{const{audio:e}=this.props;e&&!this.hasAddedAudioEventListener&&(this.audio=e,this.hasAddedAudioEventListener=!0,e.addEventListener("durationchange",this.handleAudioDurationChange),e.addEventListener("abort",this.handleAudioDurationChange))};componentDidMount(){this.addAudioEventListeners()}componentDidUpdate(){this.addAudioEventListeners()}componentWillUnmount(){this.audio&&this.hasAddedAudioEventListener&&(this.audio.removeEventListener("durationchange",this.handleAudioDurationChange),this.audio.removeEventListener("abort",this.handleAudioDurationChange))}render(){return this.state.duration}}const He=Je;class Ge extends i.Component{hasAddedAudioEventListener=!1;volumeBar=(()=>(0,i.createRef)())();volumeAnimationTimer=0;lastVolume=this.props.volume;state=(()=>({currentVolumePos:`${(this.lastVolume/1*100||0).toFixed(2)}%`,hasVolumeAnimation:!1,isDraggingVolume:!1}))();getCurrentVolume=e=>{const{audio:t}=this.props;if(!this.volumeBar.current)return{currentVolume:t.volume,currentVolumePos:this.state.currentVolumePos};const n=this.volumeBar.current.getBoundingClientRect(),o=n.width,r=Ue(e)-n.left;let i,s;return r<0?(i=0,s="0%"):r>n.width?(i=1,s="100%"):(i=r/o,s=r/o*100+"%"),{currentVolume:i,currentVolumePos:s}};handleContextMenu=e=>{e.preventDefault()};handleClickVolumeButton=()=>{const{audio:e}=this.props;e.volume>0?(this.lastVolume=e.volume,e.volume=0):e.volume=this.lastVolume};handleVolumnControlMouseOrTouchDown=e=>{e.stopPropagation();const{audio:t}=this.props,{currentVolume:n,currentVolumePos:o}=this.getCurrentVolume(e.nativeEvent);t.volume=n,this.setState({isDraggingVolume:!0,currentVolumePos:o}),e.nativeEvent instanceof MouseEvent?(window.addEventListener("mousemove",this.handleWindowMouseOrTouchMove),window.addEventListener("mouseup",this.handleWindowMouseOrTouchUp)):(window.addEventListener("touchmove",this.handleWindowMouseOrTouchMove),window.addEventListener("touchend",this.handleWindowMouseOrTouchUp))};handleWindowMouseOrTouchMove=e=>{e instanceof MouseEvent&&e.preventDefault(),e.stopPropagation();const{audio:t}=this.props,n=window.getSelection();n&&"Range"===n.type&&n.empty();const{isDraggingVolume:o}=this.state;if(o){const{currentVolume:n,currentVolumePos:o}=this.getCurrentVolume(e);t.volume=n,this.setState({currentVolumePos:o})}};handleWindowMouseOrTouchUp=e=>{e.stopPropagation(),this.setState({isDraggingVolume:!1}),e instanceof MouseEvent?(window.removeEventListener("mousemove",this.handleWindowMouseOrTouchMove),window.removeEventListener("mouseup",this.handleWindowMouseOrTouchUp)):(window.removeEventListener("touchmove",this.handleWindowMouseOrTouchMove),window.removeEventListener("touchend",this.handleWindowMouseOrTouchUp))};handleAudioVolumeChange=e=>{const{isDraggingVolume:t}=this.state,{volume:n}=e.target;(this.lastVolume>0&&0===n||0===this.lastVolume&&n>0)&&this.props.onMuteChange(),this.lastVolume=n,t||(this.setState({hasVolumeAnimation:!0,currentVolumePos:`${(n/1*100||0).toFixed(2)}%`}),clearTimeout(this.volumeAnimationTimer),this.volumeAnimationTimer=setTimeout((()=>{this.setState({hasVolumeAnimation:!1})}),100))};componentDidUpdate(){const{audio:e}=this.props;e&&!this.hasAddedAudioEventListener&&(this.audio=e,this.hasAddedAudioEventListener=!0,e.addEventListener("volumechange",this.handleAudioVolumeChange))}componentWillUnmount(){this.audio&&this.hasAddedAudioEventListener&&this.audio.removeEventListener("volumechange",this.handleAudioVolumeChange),clearTimeout(this.volumeAnimationTimer)}render(){const{audio:e,showFilledVolume:t,i18nVolumeControl:n}=this.props,{currentVolumePos:o,hasVolumeAnimation:r}=this.state,{volume:i}=e||{};return s().createElement("div",{ref:this.volumeBar,onMouseDown:this.handleVolumnControlMouseOrTouchDown,onTouchStart:this.handleVolumnControlMouseOrTouchDown,onContextMenu:this.handleContextMenu,role:"progressbar","aria-label":n,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Number((100*i).toFixed(0)),tabIndex:0,className:"rhap_volume-bar-area"},s().createElement("div",{className:"rhap_volume-bar"},s().createElement("div",{className:"rhap_volume-indicator",style:{left:o,transitionDuration:r?".1s":"0s"}}),t&&s().createElement("div",{className:"rhap_volume-filled",style:{width:o}})))}}const qe=Ge;let Ke=function(e){return e.CURRENT_TIME="CURRENT_TIME",e.CURRENT_LEFT_TIME="CURRENT_LEFT_TIME",e.PROGRESS_BAR="PROGRESS_BAR",e.DURATION="DURATION",e.ADDITIONAL_CONTROLS="ADDITIONAL_CONTROLS",e.MAIN_CONTROLS="MAIN_CONTROLS",e.VOLUME_CONTROLS="VOLUME_CONTROLS",e.LOOP="LOOP",e.VOLUME="VOLUME",e}({});class Qe extends i.Component{static defaultI18nAriaLabels={player:"Audio player",progressControl:"Audio progress control",volumeControl:"Volume control",play:"Play",pause:"Pause",rewind:"Rewind",forward:"Forward",previous:"Previous",next:"Skip",loop:"Disable loop",loopOff:"Enable loop",volume:"Mute",volumeMute:"Unmute"};audio=(()=>(0,i.createRef)())();progressBar=(()=>(0,i.createRef)())();container=(()=>(0,i.createRef)())();lastVolume=(()=>this.props.volume??1)();togglePlay=e=>{e.stopPropagation();const t=this.audio.current;(t.paused||t.ended)&&t.src?this.playAudioPromise():t.paused||t.pause()};playAudioPromise=()=>{this.audio.current.error&&this.audio.current.load();const e=this.audio.current.play();e?e.then(null).catch((e=>{const{onPlayError:t}=this.props;t&&t(new Error(e))})):this.forceUpdate()};isPlaying=()=>{const e=this.audio.current;return!!e&&!e.paused&&!e.ended};handlePlay=e=>{this.forceUpdate(),this.props.onPlay&&this.props.onPlay(e)};handlePause=e=>{this.audio&&(this.forceUpdate(),this.props.onPause&&this.props.onPause(e))};handleEnded=e=>{this.audio&&(this.forceUpdate(),this.props.onEnded&&this.props.onEnded(e))};handleAbort=e=>{this.props.onAbort&&this.props.onAbort(e)};handleClickVolumeButton=()=>{const e=this.audio.current;e.volume>0?(this.lastVolume=e.volume,e.volume=0):e.volume=this.lastVolume};handleMuteChange=()=>{this.forceUpdate()};handleClickLoopButton=()=>{this.audio.current.loop=!this.audio.current.loop,this.forceUpdate()};handleClickRewind=()=>{const{progressJumpSteps:e,progressJumpStep:t}=this.props,n=e.backward||t;this.setJumpTime(-n)};handleClickForward=()=>{const{progressJumpSteps:e,progressJumpStep:t}=this.props,n=e.forward||t;this.setJumpTime(n)};setJumpTime=e=>{const t=this.audio.current,{duration:n,currentTime:o}=t;if(t.readyState===t.HAVE_NOTHING||t.readyState===t.HAVE_METADATA||!isFinite(n)||!isFinite(o))try{t.load()}catch(e){return this.props.onChangeCurrentTimeError&&this.props.onChangeCurrentTimeError(e)}let r=o+e/1e3;r<0?(t.currentTime=0,r=0):r>n?(t.currentTime=n,r=n):t.currentTime=r};setJumpVolume=e=>{let t=this.audio.current.volume+e;t<0?t=0:t>1&&(t=1),this.audio.current.volume=t};handleKeyDown=e=>{if(this.props.hasDefaultKeyBindings??1)switch(e.key){case" ":e.target!==this.container.current&&e.target!==this.progressBar.current||(e.preventDefault(),this.togglePlay(e));break;case"ArrowLeft":this.handleClickRewind();break;case"ArrowRight":this.handleClickForward();break;case"ArrowUp":e.preventDefault(),this.setJumpVolume(this.props.volumeJumpStep);break;case"ArrowDown":e.preventDefault(),this.setJumpVolume(-this.props.volumeJumpStep);break;case"l":this.handleClickLoopButton();break;case"m":this.handleClickVolumeButton()}};renderUIModules=e=>e.map(((e,t)=>this.renderUIModule(e,t)));renderUIModule=(e,t)=>{const{defaultCurrentTime:n="--:--",progressUpdateInterval:o=20,showDownloadProgress:r=!0,showFilledProgress:a=!0,showFilledVolume:u=!1,defaultDuration:l="--:--",customIcons:c={},showSkipControls:d=!1,onClickPrevious:h,onClickNext:p,onChangeCurrentTimeError:f,showJumpControls:m=!0,customAdditionalControls:g=[Ke.LOOP],customVolumeControls:v=[Ke.VOLUME],muted:E=!1,timeFormat:y="auto",volume:w=1,loop:b=!1,mse:T,i18nAriaLabels:C=Qe.defaultI18nAriaLabels}=this.props;switch(e){case Ke.CURRENT_TIME:return s().createElement("div",{key:t,id:"rhap_current-time",className:"rhap_time rhap_current-time"},s().createElement(ze,{audio:this.audio.current,isLeftTime:!1,defaultCurrentTime:n,timeFormat:y}));case Ke.CURRENT_LEFT_TIME:return s().createElement("div",{key:t,id:"rhap_current-left-time",className:"rhap_time rhap_current-left-time"},s().createElement(ze,{audio:this.audio.current,isLeftTime:!0,defaultCurrentTime:n,timeFormat:y}));case Ke.PROGRESS_BAR:return s().createElement(We,{key:t,ref:this.progressBar,audio:this.audio.current,progressUpdateInterval:o,showDownloadProgress:r,showFilledProgress:a,onSeek:T&&T.onSeek,onChangeCurrentTimeError:f,srcDuration:T&&T.srcDuration,i18nProgressBar:C.progressControl});case Ke.DURATION:return s().createElement("div",{key:t,className:"rhap_time rhap_total-time"},T&&T.srcDuration?Fe(T.srcDuration,T.srcDuration,this.props.timeFormat):s().createElement(He,{audio:this.audio.current,defaultDuration:l,timeFormat:y}));case Ke.ADDITIONAL_CONTROLS:return s().createElement("div",{key:t,className:"rhap_additional-controls"},this.renderUIModules(g));case Ke.MAIN_CONTROLS:{const e=this.isPlaying();let n;return n=e?c.pause?c.pause:s().createElement(Ne,{icon:"mdi:pause-circle"}):c.play?c.play:s().createElement(Ne,{icon:"mdi:play-circle"}),s().createElement("div",{key:t,className:"rhap_main-controls"},d&&s().createElement("button",{"aria-label":C.previous,className:"rhap_button-clear rhap_main-controls-button rhap_skip-button",type:"button",onClick:h},c.previous?c.previous:s().createElement(Ne,{icon:"mdi:skip-previous"})),m&&s().createElement("button",{"aria-label":C.rewind,className:"rhap_button-clear rhap_main-controls-button rhap_rewind-button",type:"button",onClick:this.handleClickRewind},c.rewind?c.rewind:s().createElement(Ne,{icon:"mdi:rewind"})),s().createElement("button",{"aria-label":e?C.pause:C.play,className:"rhap_button-clear rhap_main-controls-button rhap_play-pause-button",type:"button",onClick:this.togglePlay},n),m&&s().createElement("button",{"aria-label":C.forward,className:"rhap_button-clear rhap_main-controls-button rhap_forward-button",type:"button",onClick:this.handleClickForward},c.forward?c.forward:s().createElement(Ne,{icon:"mdi:fast-forward"})),d&&s().createElement("button",{"aria-label":C.next,className:"rhap_button-clear rhap_main-controls-button rhap_skip-button",type:"button",onClick:p},c.next?c.next:s().createElement(Ne,{icon:"mdi:skip-next"})))}case Ke.VOLUME_CONTROLS:return s().createElement("div",{key:t,className:"rhap_volume-controls"},this.renderUIModules(v));case Ke.LOOP:{const e=this.audio.current?this.audio.current.loop:b;let n;return n=e?c.loop?c.loop:s().createElement(Ne,{icon:"mdi:repeat"}):c.loopOff?c.loopOff:s().createElement(Ne,{icon:"mdi:repeat-off"}),s().createElement("button",{key:t,"aria-label":e?C.loop:C.loopOff,className:"rhap_button-clear rhap_repeat-button",type:"button",onClick:this.handleClickLoopButton},n)}case Ke.VOLUME:{const{volume:e=(E?0:w)}=this.audio.current||{};let n;return n=e?c.volume?c.volume:s().createElement(Ne,{icon:"mdi:volume-high"}):c.volume?c.volumeMute:s().createElement(Ne,{icon:"mdi:volume-mute"}),s().createElement("div",{key:t,className:"rhap_volume-container"},s().createElement("button",{"aria-label":e?C.volume:C.volumeMute,onClick:this.handleClickVolumeButton,type:"button",className:"rhap_button-clear rhap_volume-button"},n),s().createElement(qe,{audio:this.audio.current,volume:e,onMuteChange:this.handleMuteChange,showFilledVolume:u,i18nVolumeControl:C.volumeControl}))}default:return(0,i.isValidElement)(e)?e.key?e:(0,i.cloneElement)(e,{key:t}):null}};componentDidMount(){this.forceUpdate();const e=this.audio.current;this.props.muted?e.volume=0:e.volume=this.lastVolume,e.addEventListener("error",(e=>{const t=e.target;if(t.error&&t.currentTime===t.duration)return this.props.onEnded&&this.props.onEnded(e);this.props.onError&&this.props.onError(e)})),e.addEventListener("canplay",(e=>{this.props.onCanPlay&&this.props.onCanPlay(e)})),e.addEventListener("canplaythrough",(e=>{this.props.onCanPlayThrough&&this.props.onCanPlayThrough(e)})),e.addEventListener("play",this.handlePlay),e.addEventListener("abort",this.handleAbort),e.addEventListener("ended",this.handleEnded),e.addEventListener("playing",(e=>{this.props.onPlaying&&this.props.onPlaying(e)})),e.addEventListener("seeking",(e=>{this.props.onSeeking&&this.props.onSeeking(e)})),e.addEventListener("seeked",(e=>{this.props.onSeeked&&this.props.onSeeked(e)})),e.addEventListener("waiting",(e=>{this.props.onWaiting&&this.props.onWaiting(e)})),e.addEventListener("emptied",(e=>{this.props.onEmptied&&this.props.onEmptied(e)})),e.addEventListener("stalled",(e=>{this.props.onStalled&&this.props.onStalled(e)})),e.addEventListener("suspend",(e=>{this.props.onSuspend&&this.props.onSuspend(e)})),e.addEventListener("loadstart",(e=>{this.props.onLoadStart&&this.props.onLoadStart(e)})),e.addEventListener("loadedmetadata",(e=>{this.props.onLoadedMetaData&&this.props.onLoadedMetaData(e)})),e.addEventListener("loadeddata",(e=>{this.props.onLoadedData&&this.props.onLoadedData(e)})),e.addEventListener("pause",this.handlePause),e.addEventListener("timeupdate",je((e=>{this.props.onListen&&this.props.onListen(e)}),this.props.listenInterval)),e.addEventListener("volumechange",(e=>{this.props.onVolumeChange&&this.props.onVolumeChange(e)})),e.addEventListener("encrypted",(e=>{const{mse:t}=this.props;t&&t.onEcrypted&&t.onEcrypted(e)}))}componentDidUpdate(e){const{src:t,autoPlayAfterSrcChange:n}=this.props;e.src!==t&&(n?this.playAudioPromise():this.forceUpdate())}render(){const{className:e="",src:t,loop:n=!1,preload:o="auto",autoPlay:r=!1,crossOrigin:i,mediaGroup:a,header:u,footer:l,layout:c="stacked",customProgressBarSection:d=[Ke.CURRENT_TIME,Ke.PROGRESS_BAR,Ke.DURATION],customControlsSection:h=[Ke.ADDITIONAL_CONTROLS,Ke.MAIN_CONTROLS,Ke.VOLUME_CONTROLS],children:p,style:f,i18nAriaLabels:m=Qe.defaultI18nAriaLabels}=this.props,g=this.audio.current?this.audio.current.loop:n,v=g?"rhap_loop--on":"rhap_loop--off",E=this.isPlaying()?"rhap_play-status--playing":"rhap_play-status--paused";return s().createElement("div",{role:"group",tabIndex:0,"aria-label":m.player,className:`rhap_container ${v} ${E} ${e}`,onKeyDown:this.handleKeyDown,ref:this.container,style:f},s().createElement("audio",{src:t,controls:!1,loop:g,autoPlay:r,preload:o,crossOrigin:i,mediaGroup:a,ref:this.audio},p),u&&s().createElement("div",{className:"rhap_header"},u),s().createElement("div",{className:`rhap_main ${Ve(c)}`},s().createElement("div",{className:"rhap_progress-section"},this.renderUIModules(d)),s().createElement("div",{className:"rhap_controls-section"},this.renderUIModules(h))),l&&s().createElement("div",{className:"rhap_footer"},l))}}const Xe=Qe;return r})()));