react-h5-audio-player
Version:
A customizable React audio player. Written in TypeScript. Mobile compatible. Keyboard friendly
1 lines • 41.1 kB
JavaScript
!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:()=>_e,default:()=>Ne});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 m={provider:"",aliases:{},not_found:{},...a};function f(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(!f(e,m))return null;const n=t.icons;for(const e in n){const t=n[e];if(!e||"string"!=typeof t.body||!f(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]||!f(t,c))return null}return t}const v=/^[a-z0-9]+(-[a-z0-9]+)*$/,E=(e,t,n,o="")=>{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&&!b(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&&!b(e)?null:e}if(n&&""===o){const e={provider:o,prefix:"",name:i};return t&&!b(e,n)?null:e}return null},b=(e,t)=>!!e&&!(!(t&&""===e.prefix||e.prefix)||!e.name),w=Object.create(null);function y(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 L=!1;function C(e){return"boolean"==typeof e&&(L=e),L}function A(e){const t="string"==typeof e?E(e,!0,L):e;if(t){const e=y(t.provider,t.prefix),n=t.name;return e.icons[n]||(e.missing.has(n)?null:void 0)}}const O=Object.freeze({width:null,height:null}),M=Object.freeze({...O,...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,t=_){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 F=Object.create(null),I=["https://api.simplesvg.com","https://api.unisvg.com"],j=[];for(;I.length>0;)1===I.length||Math.random()>.5?j.push(I.shift()):j.push(I.pop());function B(e,t){const n=U(t);return null!==n&&(F[e]=n,!0)}function W(e){return F[e]}F[""]=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 m(){d&&(clearTimeout(d),d=null)}function f(){"pending"===l&&(l="aborted"),m(),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;m();const r=s.shift();if(void 0===r)return h.length?void(d=setTimeout(()=>{m(),"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(m(),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:f}}}(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);function X(){}function Y(e,t,n){function o(){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 o()}catch(e){console.error(e)}o(),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 Z(e,t){e instanceof Promise?e.then(e=>{t(e)}).catch(()=>{t(null)}):t(e)}function ee(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 Z(e.loadIcons(o,n,t),t=>{Y(e,o,t)});if(r)return void o.forEach(o=>{Z(r(o,n,t),t=>{Y(e,[o],t?{prefix:n,icons:{[o]:t}}:null)})});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&&Y(e,s,null),!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=>{Y(e,n.icons,t)})}):Y(e,i,null)}))}const te=/[\s,]+/;function ne(e,t){t.split(te).forEach(t=>{switch(t.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0}})}function oe(e,t=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 re;function ie(e){return void 0===re&&function(){try{re=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch(e){re=null}}(),re?re.createHTML(e):e}const se={...M,inline:!1},ae={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},ue={display:"inline-block"},le={backgroundColor:"currentColor"},ce={backgroundColor:"transparent"},de={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},he={WebkitMask:le,mask:le,background:ce};for(const e in he){const t=he[e];for(const n in de)t[e+n]=de[n]}const pe={...se,inline:!0};function me(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}if(C(!0),fe=z,R[""]=fe,"undefined"!=typeof document&&"undefined"!=typeof window){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||""),L&&!t&&!e.prefix){let t=!1;return g(e)&&(e.prefix="",p(e,(e,n)=>{(function(e,t){const n=E(e,!0,L);if(!n)return!1;const o=y(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!!b({prefix:n,name:"a"})&&!!T(y(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 fe;function ge(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,t=!0,n=!1){const o=[];return e.forEach(e=>{const r="string"==typeof e?E(e,t,n):e;r&&o.push(r)}),o}(e,!0,C()),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]=y(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,X)}),()=>{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(y(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=y(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&&ee(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):X})([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?pe:se,r=function(e,t){const n={...e};for(const e in t){const o=t[e],r=typeof o;e in O?(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?ae:{}};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&&ne(r,n);break;case"color":a.color=n;break;case"rotate":"string"==typeof n?r[e]=oe(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={...M,...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,t="defs"){let 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={},m=(e,t)=>{(e=>"unset"===e||"undefined"===e||"none"===e)(t)||(p[e]=t.toString())};m("width",d),m("height",h);const f=[r.left,r.top,u,c];return p.viewBox=f.join(" "),{attributes:p,viewBox:f,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:ie(N(d.body,n?()=>n+"ID"+e++:"iconifyReact"))},(0,i.createElement)("svg",c)}const{body:p,width:m,height:f}=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:m+"",height:f+""});var b;return c.style={...a,"--svg":(b=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)}(b)+'")'),width:me(h.width),height:me(h.height),...ue,...g?le:ce,...u},(0,i.createElement)("span",c)})({...l,...p},e,h):e.children?e.children:e.fallback?e.fallback:(0,i.createElement)("span",{})}const ve=(0,i.forwardRef)((e,t)=>ge({...e,_ref:t}));function Ee(){return Ee=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},Ee.apply(null,arguments)}(0,i.forwardRef)((e,t)=>ge({inline:!0,...e,_ref:t}));const be=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"}},we=e=>e instanceof MouseEvent?e.clientX:e.touches[0].clientX,ye=e=>e>9?e.toString():`0${e}`,Te=(e,t,n)=>{if(!isFinite(e))return null;const o=Math.floor(e/60),r=ye(o),i=ye(Math.floor(e%60)),s=ye(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 Le(e,t){let n=!1;return o=>{n||(e(o),n=!0,setTimeout(()=>n=!1,t))}}class Ce 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=we(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=>{const t=e instanceof Error?e.message:String(e);throw new Error(t)})});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=Le(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(({left:e,width:t},n)=>s().createElement("div",{key:n,className:"rhap_download-progress",style:{left:e,width:t,transitionDuration:a?".2s":"0s"}}))))}}const Ae=(0,i.forwardRef)((e,t)=>s().createElement(Ce,Ee({},e,{progressBar:t})));class Oe extends i.PureComponent{hasAddedAudioEventListener=!1;constructor(e){super(e);const{audio:t,defaultCurrentTime:n,isLeftTime:o,timeFormat:r}=e;let i=n;t&&(i=Te(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:Te(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 Me=Oe;class Pe extends i.PureComponent{hasAddedAudioEventListener=!1;constructor(e){super(e);const{audio:t,timeFormat:n,defaultDuration:o}=e;this.state={duration:t?Te(t.duration,t.duration,n):o}}state={duration:this.props.audio?Te(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:Te(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 ke=Pe;class xe 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=we(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 Se=xe;let _e=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 De 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"};static defaultProps={progressJumpSteps:{backward:5e3,forward:5e3},progressJumpStep:5e3,volumeJumpStep:.1};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,n=e instanceof Error?e.message:String(e);t&&t(new Error(n))}):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=>{const t=this.audio.current,n=Number(e),o=t?.volume;if(!t||!Number.isFinite(n)||!Number.isFinite(o))return;let r=o+n;r<0?r=0:r>1&&(r=1),t.volume=r};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:m,showJumpControls:f=!0,customAdditionalControls:g=[_e.LOOP],customVolumeControls:v=[_e.VOLUME],muted:E=!1,timeFormat:b="auto",volume:w=1,loop:y=!1,mse:T,i18nAriaLabels:L=De.defaultI18nAriaLabels}=this.props;switch(e){case _e.CURRENT_TIME:return s().createElement("div",{key:t,id:"rhap_current-time",className:"rhap_time rhap_current-time"},s().createElement(Me,{audio:this.audio.current,isLeftTime:!1,defaultCurrentTime:n,timeFormat:b}));case _e.CURRENT_LEFT_TIME:return s().createElement("div",{key:t,id:"rhap_current-left-time",className:"rhap_time rhap_current-left-time"},s().createElement(Me,{audio:this.audio.current,isLeftTime:!0,defaultCurrentTime:n,timeFormat:b}));case _e.PROGRESS_BAR:return s().createElement(Ae,{key:t,ref:this.progressBar,audio:this.audio.current,progressUpdateInterval:o,showDownloadProgress:r,showFilledProgress:a,onSeek:T&&T.onSeek,onChangeCurrentTimeError:m,srcDuration:T&&T.srcDuration,i18nProgressBar:L.progressControl});case _e.DURATION:return s().createElement("div",{key:t,className:"rhap_time rhap_total-time"},T&&T.srcDuration?Te(T.srcDuration,T.srcDuration,this.props.timeFormat):s().createElement(ke,{audio:this.audio.current,defaultDuration:l,timeFormat:b}));case _e.ADDITIONAL_CONTROLS:return s().createElement("div",{key:t,className:"rhap_additional-controls"},this.renderUIModules(g));case _e.MAIN_CONTROLS:{const e=this.isPlaying();let n;return n=e?c.pause?c.pause:s().createElement(ve,{icon:"mdi:pause-circle",ssr:!0}):c.play?c.play:s().createElement(ve,{icon:"mdi:play-circle",ssr:!0}),s().createElement("div",{key:t,className:"rhap_main-controls"},d&&s().createElement("button",{"aria-label":L.previous,className:"rhap_button-clear rhap_main-controls-button rhap_skip-button",type:"button",onClick:h},c.previous?c.previous:s().createElement(ve,{icon:"mdi:skip-previous",ssr:!0})),f&&s().createElement("button",{"aria-label":L.rewind,className:"rhap_button-clear rhap_main-controls-button rhap_rewind-button",type:"button",onClick:this.handleClickRewind},c.rewind?c.rewind:s().createElement(ve,{icon:"mdi:rewind",ssr:!0})),s().createElement("button",{"aria-label":e?L.pause:L.play,className:"rhap_button-clear rhap_main-controls-button rhap_play-pause-button",type:"button",onClick:this.togglePlay},n),f&&s().createElement("button",{"aria-label":L.forward,className:"rhap_button-clear rhap_main-controls-button rhap_forward-button",type:"button",onClick:this.handleClickForward},c.forward?c.forward:s().createElement(ve,{icon:"mdi:fast-forward",ssr:!0})),d&&s().createElement("button",{"aria-label":L.next,className:"rhap_button-clear rhap_main-controls-button rhap_skip-button",type:"button",onClick:p},c.next?c.next:s().createElement(ve,{icon:"mdi:skip-next",ssr:!0})))}case _e.VOLUME_CONTROLS:return s().createElement("div",{key:t,className:"rhap_volume-controls"},this.renderUIModules(v));case _e.LOOP:{const e=this.audio.current?this.audio.current.loop:y;let n;return n=e?c.loop?c.loop:s().createElement(ve,{icon:"mdi:repeat",ssr:!0}):c.loopOff?c.loopOff:s().createElement(ve,{icon:"mdi:repeat-off",ssr:!0}),s().createElement("button",{key:t,"aria-label":e?L.loop:L.loopOff,className:"rhap_button-clear rhap_repeat-button",type:"button",onClick:this.handleClickLoopButton},n)}case _e.VOLUME:{const{volume:e=(E?0:w)}=this.audio.current||{};let n;return n=e?c.volume?c.volume:s().createElement(ve,{icon:"mdi:volume-high",ssr:!0}):c.volume?c.volumeMute:s().createElement(ve,{icon:"mdi:volume-mute",ssr:!0}),s().createElement("div",{key:t,className:"rhap_volume-container"},s().createElement("button",{"aria-label":e?L.volume:L.volumeMute,onClick:this.handleClickVolumeButton,type:"button",className:"rhap_button-clear rhap_volume-button"},n),s().createElement(Se,{audio:this.audio.current,volume:e,onMuteChange:this.handleMuteChange,showFilledVolume:u,i18nVolumeControl:L.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",Le(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=[_e.CURRENT_TIME,_e.PROGRESS_BAR,_e.DURATION],customControlsSection:h=[_e.ADDITIONAL_CONTROLS,_e.MAIN_CONTROLS,_e.VOLUME_CONTROLS],children:p,style:m,i18nAriaLabels:f=De.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":f.player,className:`rhap_container ${v} ${E} ${e}`,onKeyDown:this.handleKeyDown,ref:this.container,style:m},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 ${be(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 Ne=De;return r})());