-
Notifications
You must be signed in to change notification settings - Fork 1
/
cpu-audio.direct-download.js
16 lines (14 loc) · 47.6 KB
/
cpu-audio.direct-download.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
(()=>{"use strict";
/** @license
Cpu-Audio: an extension to the hash system to address timecode into audio/video elements and a player WebComponent
Version 7.1
Copyright (C) 2014-2022 Xavier "dascritch" Mouton-Dubosc & contributors.
License LGPL 3
- project mini-site https://dascritch.github.io/cpu-audio/
- project repository : https://github.com/dascritch/cpu-audio
- use case : http://cpu.pm
- blog post : https://dascritch.net/post/2018/11/06/Reconstruire-son-lecteur-audio-pour-le-web
**/
const t="CPU-AUDIO",e="CPU-CONTROLLER",n="audio[controls]",o=`${t} audio`;function a(t,e,n=document){Array.from(n.querySelectorAll(t)).forEach(e)}function i(n){if([t,e].includes(n.tagName))return n.CPU;let o=n.closest(t)??n.closest(e);return o?o.CPU:n.getRootNode().host.CPU}function r(t){const e=document.createElement("p");e.innerText=t;const{innerHTML:n}=e;return n}function s(t){const e=document.createElement("a");return e.href="string"!=typeof t?t:t.split("#")[0],e.href}const l={passive:!0},c={...l,once:!0};function d(t){s(window.location.href)===s(t.target.href)&&t.preventDefault()}const u=void 0!==window.customElements,p=!window.matchMedia("screen").matches,h=e=>window.console.warn(`${t}▷ `,e),m={fr:{loading:"Chargement en cours…",pause:"Pause",play:"Lecture",canonical:"Lien vers la fiche du sonore",moment:"Lien vers ce moment",untitled:"(sans titre)",cover:"pochette",more:"Actions",share:"Partager",twitter:"Partager sur Twitter",facebook:"Partager sur Facebook",e_mail:"Partager par e-mail",download:"Télécharger",back:"Annuler",chapters:"Chapitres",playlist:"Playlist",media_err_aborted:"Vous avez annulé la lecture.",media_err_network:"Une erreur réseau a causé l'interruption du téléchargement.",media_err_decode:"La lecture du sonore a été annulée suite à des problèmes de corruption ou de fonctionnalités non supportés par votre navigateur.",media_err_src_not_supported:"Le sonore n'a pu être chargé, soit à cause de sourcis sur le serveur, le réseau ou parce que le format n'est pas supporté.",media_err_unknow:"Erreur due à une raison inconnue."},en:{loading:"Loading…",pause:"Pause",play:"Play",canonical:"Link to the sound's page",moment:"Link to this time",untitled:"(untitled)",cover:"cover",more:"Actions",share:"Share",twitter:"Share on Twitter",facebook:"Share on Facebook",e_mail:"Share via e-mail",download:"Download",back:"Back",chapters:"Chapters",playlist:"Playlist",media_err_aborted:"You have aborted the play.",media_err_network:"A network error broke the download.",media_err_decode:"Play was canceled due to file corruption or a not supported function in your browser.",media_err_src_not_supported:"The media cannot be downloaded due to server problems, network problems or unsupported by your browser.",media_err_unknow:"Error of unknown cause."}};let g=function(){const t=document.querySelector("html").lang;if(t.length&&t.toLowerCase()in m)return t;const e=window.navigator.languages??[navigator.language||navigator.browserLanguage];for(const t of e)if(t.split){const[e]=t.split("-");if(e in m)return e}return"en"}();const f=m[g],v=f;const b=/^[\w-]+_«([\w-]+)(»_.*_«([\w-]+))?»$/,w=/^[\w-]+$/;function y(t){let e,n;return"string"==typeof t&&([,e,,n]=t?.match(b)||[]),{planeName:e??"",pointName:n??""}}function P(t,e,n){return`${n?"panel":"track"}_«${t}»_point_«${e}»`}const C={d:86400,h:3600,m:60,s:1},k=[1,60,3600,86400],_=/^\d+$/,x=/\D*/g,T=t=>{let e=0;return""!==t&&(e=_.test(t)?Number(t):t.includes(":")?A.colontimeInSeconds(t):A.subunittimeInSeconds(t)),e},E=t=>{if(t===1/0)return"?";let e="",n=!1;for(const o in C)if(C.hasOwnProperty(o)){let a=C[o];if(t>=a||n){n=!0;let i=Math.floor(t/a);e+=i+o,t-=i*a}}return""===e?"0s":e},L=t=>{if(t===1/0)return"?";let e="",n=!1;for(let o in C)if(C.hasOwnProperty(o)){let a=C[o];if(t>=a||n){n=!0;let o=Math.floor(t/a);e+=""===e?"":":",e+=(o<10&&""!==e?"0":"")+o,t-=o*a}}return 1===e.length?`0:0${e}`:2===e.length?`0:${e}`:""===e?"0:00":e},U=t=>`P${A.secondsInTime(t).toUpperCase()}`,A={timeInSeconds:T,subunittimeInSeconds:t=>{let e,n=0;for(let o in C)C.hasOwnProperty(o)&&t.includes(o)&&([e,t]=t.split(o),n+=Number(e.replace(x,""))*C[o]);return n},colontimeInSeconds:t=>{let e=0;const n=t.split(":");for(let t=0;t<n.length;t++)e+=Number(n[t])*k[n.length-1-t];return e},secondsInTime:E,secondsInColonTime:L,secondsInPaddledColonTime:t=>{if(t===1/0)return"?";let e=A.secondsInColonTime(t);return"00:00:00".substr(0,8-e.length)+e},durationIso:U},I=A;function $({target:t}){if(t.id||(t=t.closest("[id]")),!t)return;const{planeName:e,pointName:n}=y(t.id);i(t).highlightPoint(e,n)}function N({classList:t},e){e?t.remove("no"):t.add("no")}const S={i:"i",em:"i",b:"b",bold:"strong",u:"u",lang:"i"},M={i:"i",em:"i",b:"b",strong:"b",u:"u"};let D=S;const O=/<(\w+)(\.[^>]+)?( [^>]+)?>/gi,z=/<\/(\w+)( [^>]*)?>/gi,H=/\n/gi,q=/<br\s*[^>]*>/gi;function R(t){return!(t in D)}function j(t,e,n,o){if(R(e=e.toLowerCase()))return"";let a="";return"lang"==e&&(a=` lang="${o.trim()}"`),`<${D[e]}${a}>`}function B(t,e){return R(e=e.toLowerCase())?"":`</${D[e]}>`}const F=function(t,e=!0){if(D=e?S:M,t.split("<").length!==t.split(">").length)return r(t);const n=t.replace(O,j).replace(z,B);return e?n.replace(H,"<br/>"):n.replace(q,"\n")};function V(t){return null==t||t.duration===1/0||null!=t.dataset.streamed}function K(t){return t===1/0||null===t||isNaN(t)}function W(t){return 0===t||K(t)}function G({duration:t,dataset:e}){let n=null;const o=Number(t);if(W(o)){const t=Number(e.duration);W(t)||(n=t)}else n=o;return n}function X(t,e){if(K(e))return null;e=e<0?0:e;const n=G(t);return W(n)||(e=e<n?e:n),e}function J(t){if(!t)return null;let e=null;if(t.textTracks?.length>0)for(const n of t.textTracks)"chapters"!==n.kind.toLowerCase()||!n.cues||e&&n.language.toLowerCase()!==g||(e=n);return e}function Y(t,e,n){if(!t?.indexOf)return null;const o=t.indexOf(e);return-1===o?null:t[o+n]}let Q=null;function Z(t,e){const n=t.audiotag,o=t.planePoints("_chapters");if(!o)return;const{pointName:a}=y(Q);let i=Y(o,a,e),r=Object.values(o);e<0&&(r=r.reverse());const{currentTime:s}=n;if(!i)for(const t of r)!i&&(e<0&&t.end<=s||e>0&&t.start>=s)&&(i=t);i&&document.CPU.jumpIdAt(n.id,i.start)}function tt(t,e){const{classList:n}=document.body;n.remove(Q),Q=`cpu_playing_tag_«${e.id}»_cue_«${t.id}»`,n.add(Q)}const et="_chapters";async function nt(t){if(t.isController)return;const e=t.audiotag;let n=!1;const o={};if(e){const a=J(e);if(a?.cues.length>0){t.addPlane(et,{title:v.chapters,track:"chapters"});const i=()=>{ot(t)};a.removeEventListener("cuechange",i),a.addEventListener("cuechange",i,l);for(const n of a.cues)t.point(et,n.id)||(o[n.id]={start:X(e,Math.floor(n.startTime)),text:F(n.text),link:!0,end:X(e,Math.floor(n.endTime))});a.cues.length>0&&(n=!0),t.bulkPoints(et,o),ot(t,{target:{activeCues:a.cues}})}}const a=`cpu_tag_«${e.id}»_chaptered`,i=document.body.classList;n?i.add(a):(t.removePlane(et),i.remove(a))}function ot(t,e=null){const n=e?e.target.activeCues:J(t.audiotag)?.activeCues;let o;const a=t.audiotag.currentTime;if(n?.length>0)for(const t of n)t.startTime<=a&&a<t.endTime&&(o=t);o?.id!==t._activecue_id&&(t.removeHighlightsPoints(et,it),t._activecue_id=o?.id,o&&(tt(o,t.audiotag),t.emitEvent("chapterChanged",{cue:o}),t.highlightPoint(et,o.id,it)))}const at="with-preview",it="active-cue";const rt={drawPlane:function(t){this.planeTrack(t)?.remove(),this.planePanel(t)?.remove();const e=this.plane(t);if(!e)return;const{track:n,panel:o,title:a}=e,i=()=>this.removeHighlightsPoints(t,at,!0),s=t=>{t.addEventListener("mouseover",$,l),t.addEventListener("focusin",$,l),t.addEventListener("mouseleave",i,l),t.addEventListener("focusout",i,l)};if(!1!==n){const e=document.createElement("aside");e.id=`track_«${t}»`,!0!==n&&e.classList.add(n.split(" ")),this.shadowId("line").appendChild(e),s(e)}if(!1!==o){const e=document.createElement("details");e.open=!0,e.id=`panel_«${t}»`,!0!==o&&e.classList.add(o.split(" ")),e.classList.add("panel"),e.innerHTML=`<summary>${r(a)}</summary><nav><ul></ul></nav>`,this.container.appendChild(e),N(e.querySelector("summary"),a),s(e)}!this.isController&&this.mirroredInController()&&document.CPU.globalController.drawPlane(t)},drawPoint:function(t,e){const n=this.audiotag??document.CPU.globalController.audiotag,o=this.point(t,e),{start:a,link:i,text:r,image:s,end:l}=o;let c="#";!0===i&&(c=`#${n.id}&t=${a}`),"string"==typeof i&&(c=i);const d=this.planeTrack(t);let u;if(d){u=this.pointTrack(t,e),u||(u=document.createElement("a"),u.id=P(t,e,!1),u.tabIndex=-1,u.innerHTML='<img alt="" /><span></span>',d.appendChild(u)),u.href=c,u.title=function(t){const e=document.createElement("p");e.innerHTML=t;const{innerText:n}=e;return n}(r);const n=u.querySelector("img");N(n,s),n.src=s||"",u.querySelector("img").innerHTML=r,this.positionTimeElement(u,a,l)}const p=this.planeNav(t);let h;if(p){h=this.pointPanel(t,e),h||(h=document.createElement("li"),h.id=P(t,e,!0),h.innerHTML='<a href="#" class="cue"><strong></strong><time></time></a>',p.appendChild(h)),h.querySelector("a").href=c,h.querySelector("strong").innerHTML=r;const n=h.querySelector("time");n.dateTime=U(a),n.innerText=L(a)}this.emitEvent("drawPoint",{planeName:t,pointName:e,pointData:o,elementPointTrack:u,elementPointPanel:h}),!this.isController&&this.mirroredInController()&&document.CPU.globalController.drawPoint(t,e)},refreshPlane:function(t){this.planeSort(t);for(const e of this.planePointNames(t))this.drawPoint(t,e)},redrawAllPlanes:function(){a("aside, details.panel",(t=>t.remove()),this.container);for(const t of Object.keys({...this._planes,...this.audiotag._CPU_planes}))this.drawPlane(t),this.refreshPlane(t);ot(this)},removeHighlightsPoints:function(t,e="with-preview",n=!0){if(a(`#track_«${t}» .${e}, #panel_«${t}» .${e}`,(t=>t.classList.remove(e)),this.container),n&&this.mirroredInController()){const n=document.CPU.globalController;(this.isController?i(n.audiotag):n).removeHighlightsPoints(t,e,!1)}},highlightPoint:function(t,e,n="with-preview",o=!0){if(this.removeHighlightsPoints(t,n,o),this.plane(t)?.highlight&&(this.pointTrack(t,e)?.classList.add(n),this.pointPanel(t,e)?.classList.add(n),o&&this.mirroredInController())){const o=document.CPU.globalController;(this.isController?i(o.audiotag):o).highlightPoint(t,e,n,!1)}}},st=rt,lt="_playlist";function ct({id:t}){const e=document.CPU.playlists,n=document.CPU.currentPlaylistID();let o=!1;for(const a in e){const i=e[a].length,r=e[a].filter((e=>e!==t&&document.getElementById(e)));i!==r.length&&a===n&&(o=!0),document.CPU.playlists[a]=r,0===r.length&&delete document.CPU.playlists[a]}o&&ut()}function dt(){const t=document.CPU.globalController;if(!t)return;const e=t.current_playlist,n={};if(t.clearPlane(lt),0!==t.current_playlist.length){for(const t of e)n[t]={text:document.getElementById(t)?.dataset.title,link:`#${t}&t=0`};t.bulkPoints(lt,n),t.element.shadowRoot.querySelector("main").insertAdjacentElement("afterend",t.planePanel(lt))}else t.removePlane(lt)}function ut(t){const e=document.CPU.globalController;if(!e||!e.isController)return;const n=e.current_playlist;if(e.current_playlist=document.CPU.currentPlaylist(),e.plane(lt)||e.addPlane(lt,{title:v.playlist,track:!1,panel:"nocuetime",highlight:!0,_comp:!0}),n!==e.current_playlist&&dt(),e.highlightPoint(lt,e.audiotag.id,it),t){const{planeName:n,pointName:o}=y(t);e.focusPoint(n,o)}}let pt=!1,ht=0,mt=!1;function gt(t=null,e=null){if(!e){const{target:n}=t;e="AUDIO"==n.tagName?n:i(n).audiotag}e.pause(),document.CPU.currentAudiotagPlaying=null,window.localStorage.removeItem(e.currentSrc)}function ft(t=null,e=null){if(!t&&pt)return void h("play() prevented because already waiting for focus");var n;e=e??i(t.target).audiotag,pt=!1,((n=e.currentTime)<ht||!1!==mt&&n>mt)&&(ht=0,mt=!1);let o=e.play();o&&o.then((()=>{document.CPU.hadPlayed=!0})).catch((n=>{pt=!0;const o=()=>{!function(t,e){pt=!1,document.CPU.autoplay&&ft(t,e)}(t,e)};switch(n.name){case"NotAllowedError":if(h("Auto-play prevented : Browser requires a manual interaction first."),document.addEventListener("focus",o,c),document.addEventListener("click",o,c),null!=e._CPU_played){let t=i(e);t.glowBeforePlay=!0,t.setAct("glow")}break;case"NotSupportedError":n("The browser refuses the audio source, probably due to audio format.")}})),re(e)}function vt({target:t}){const{audiotag:e}=i(t);e.paused?ft(null,e):gt(null,e)}function bt(t){const{target:e,offsetX:n,at:o}=t,a=document.CPU,r=i(e),s=r.audiotag;if(o>=0)return void a.seekElementAt(s,o);const l=n/e.clientWidth,c=G(s);a.currentAudiotagPlaying&&!a.isAudiotagPlaying(s)&>(null,a.currentAudiotagPlaying),ft(t,s),W(c)?r.updateLoading(void 0,100):a.seekElementAt(s,l*c)}function wt(t){const{target:e,clientX:n,targetTouches:o}=t;if(!e)return;const a=i(e),r=a.audiotag,s=G(r);if(W(s))return void(V(r)||Lt(r,wt,t));const{x:l,width:c}=a.shadowId("time").getBoundingClientRect(),d=((n??o?.[0]?.clientX)-l)/c;a.showThrobberAt(X(r,d*s))}function yt(t,e=1){if(t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)return;const n=i(t.target),{audiotag:o}=n;function a(e){t.at=X(o,o.currentTime+e),n.showThrobberAt(t.at),bt(t),n.hideThrobberLater()}switch(t.keyCode){case 13:if("control"!==n.focused()?.id.toLowerCase())return;vt(t);break;case 27:Pt(t),gt(null,o);break;case 32:vt(t);break;case 35:document.CPU.seekElementAt(o,o.duration);break;case 36:Pt(t);break;case 37:a(-document.CPU.keymove*e);break;case 39:a(+document.CPU.keymove*e);break;case 38:n.prevFocus();break;case 40:n.nextFocus();break;default:return}t.preventDefault?.()}function Pt({target:t}){const e=i(t);document.CPU.seekElementAt(e.audiotag,0)}async function Ct(t,e=null){let n=!0;"string"!=typeof t&&(n="at_start"in t,t=location.hash.substr(1));let o=null,a="",i=!1;for(const e of t.split("&"))if(e.includes("=")){const[t,n]=e.split("=");switch(t.toLowerCase()){case"t":a=n||"0",i=!0;break;case"autoplay":i="1"===n;break;case"auto_play":i="true"===n.toLowerCase()}}else o=o??e;if(""===a||n&&!i)return void e?.();const[r,s]=a.split(",");let l=T(r),c=void 0!==s&&T(s);!1!==c&&(c=c>l&&c),function(t,e){ht=t,mt=e}(l,c),document.CPU.scrollTo&&(o?.length>0?document.querySelector(`#${o}`):document.CPU.currentAudiotagPlaying)?.closest("cpu-audio, cpu-controller").scrollIntoView(),await document.CPU.jumpIdAt(o??"",r,e),ut()}function kt(t,e){const{id:n}=t,o=t.dataset.playlist;if(!o)return;const a=document.CPU.playlists[o];if(!a)return void h(`Named playlist ${o} not created. WTF ?`);const i=a.indexOf(n);if(i<0)return void h(`Audiotag ${n} not in playlist ${o}. WTF ?`);const r=a[i+e];if(!r)return;const s=document.getElementById(r);s?(document.CPU.seekElementAt(s,0),ft(null,s)):h(`Audiotag #${r} doesn't exists. WTF ?`)}function _t({target:t}){!1!==mt&&t.currentTime>mt&>(void 0,t),function(t){i(t)?.update(),document.CPU.globalController?.update()}(t),t.paused||V(t)||window.localStorage.setItem(t.currentSrc,String(t.currentTime))}const xt={...{hashOrder:Ct},...{restart:Pt,reward:function(t){t.keyCode=37,yt(t)},foward:function(t){t.keyCode=39,yt(t)},fastreward:function(t){t.keyCode=37,yt(t,document.CPU.fastFactor)},fastfoward:function(t){t.keyCode=39,yt(t,document.CPU.fastFactor)}},...{throbble:bt,hover:wt,out:function({target:t}){i(t).hideThrobber()}},...{key:yt},...{update:_t},...{cuechange:tt,prevcue:function({target:t}){Z(i(t),-1)},nextcue:function({target:t}){Z(i(t),1)}},...{prevtrack:function({target:t},e=null){kt(e??i(t).audiotag,-1)},nexttrack:function({target:t},e=null){kt(e??i(t).audiotag,1)}},pause:gt,playOnce:function({target:t}){const e=document.CPU;e.lastUsed=t,e.playStopOthers&&e.currentAudiotagPlaying&&!e.isAudiotagPlaying(t)&>(void 0,e.currentAudiotagPlaying),e.currentAudiotagPlaying=t},play:ft,toggleplay:vt,_end:()=>mt};function Tt(t){let e=t.target;if(null!==document.CPU.currentAudiotagPlaying||V(e))return;let n=Number(window.localStorage.getItem(e.currentSrc));n>0&&!pt&&(document.CPU.seekElementAt(e,n),xt.play(null,e))}HTMLAudioElement.prototype._CPU_played=null,HTMLAudioElement.prototype._CPU_planes=null;let Et=0;function Lt(t,e=null,n=null){t&&(t.readyState>t.HAVE_NOTHING?e?.(n):(e&&t.addEventListener("loadedmetadata",(()=>e?.(n)),c),t.load()))}function Ut(t){t.addEventListener("loadedmetadata",Tt,c),t.addEventListener("play",xt.playOnce,l),t.addEventListener("ended",xt.nexttrack,l),t.addEventListener("ready",Tt,l),t.addEventListener("canplay",Tt,l);for(const e of["ready","load","loadeddata","canplay","abort","error","emptied","play","playing","pause","ended","durationchange","loadedmetadata","timeupdate","waiting"])t.addEventListener(e,xt.update,l);if(!u)for(const e of["pause","ended"])t.addEventListener(e,xt.pause,l);""===t.getAttribute("preload")&&Lt(t)}function At(t){null==t._CPU_played&&(t._CPU_played=!1,Ut(t),t.hidden=!0,t.removeAttribute("controls"),function(t){if("string"==typeof t.dataset.playlist){const e=t.dataset.playlist;e in document.CPU.playlists||(document.CPU.playlists[e]=[]),document.CPU.playlists[e].push(t.id),document.CPU.globalController&&e===document.CPU.currentPlaylistID()&&ut()}}(t))}let It=null;function $t({target:t}){It=setTimeout(Nt,document.CPU.alternateDelay,i(t))}function Nt(t){t.showHandheldNav(),It=null}function St(){clearTimeout(It),It=null}let Mt=null;const Dt=["fastreward","reward","foward","fastfoward"];function Ot(t){const e=t.target.id?t.target:t.target.closest("button");e.id&&Dt.includes(e.id)&&(xt[e.id](t),Mt&&window.clearTimeout(Mt),Mt=window.setTimeout(zt,document.CPU.repeatDelay,t),t.preventDefault())}function zt(t){xt[t.target.id](t),Mt=window.setTimeout(zt,document.CPU.repeatFactor,t),t.preventDefault?.()}function Ht(t){window.clearTimeout(Mt),Mt=null,t.preventDefault()}function qt(t){const{title:e,canonical:n}=i(t.target).audiotagDataset();navigator.share({title:e,text:e,url:n}),t.preventDefault()}const Rt=function(t){t.container.addEventListener("focus",(e=>{(t.shadowId("control")??t.shadowId("toggleplay"))?.focus(),e.preventDefault()}));const{classList:e}=t.container;t.shadowId("poster")?.addEventListener("load",(()=>{e.add("poster-loaded")}),l);const n={pause:xt.pause,play:xt.play,time:xt.throbble,actions:()=>t.showActions(),back:e=>{t.showMain(),e.preventDefault()},poster:()=>t.showMain(),restart:xt.restart,toggleplay:xt.toggleplay,prevcue:xt.prevcue,nextcue:xt.nextcue,prevtrack:xt.prevtrack,nexttrack:xt.nexttrack};for(const[e,o]of Object.entries(n)){const n=t.shadowId(e);n?.addEventListener("click",o,"A"===n.tagName?{}:l)}for(const e of Dt){const n=t.shadowId(e);n&&(n.addEventListener("pointerdown",Ot),n.addEventListener("pointerout",Ht),n.addEventListener("pointerup",Ht))}t.element.addEventListener("keydown",xt.key);const o=t.shadowId("time");o&&(o.addEventListener("pointerenter",xt.hover,l),o.addEventListener("pointermove",xt.hover,l),o.addEventListener("pointerout",xt.out,l),o.addEventListener("pointerdown",$t,l),o.addEventListener("pointerup",St,l)),navigator.share&&(e.add("hasnativeshare"),t.shadowId("nativeshare")?.addEventListener("click",qt,l));const a=t.shadowId("canonical");a&&a.addEventListener("click",d),t.audiotag&&(t.container.addEventListener("pointerenter",(()=>Lt(t.audiotag)),c),t.audiotag.addEventListener("durationchange",(()=>t.repositionTracks()),l),function(t){const e=()=>{nt(t)};e();const{audiotag:n}=t;n.addEventListener("loadedmetadata",e,c);const o=n.querySelector('track[kind="chapters"]');o&&!o._CPU_load_ev&&(o._CPU_load_ev=o.addEventListener("load",e,l))}(t),ut(),t.showMain(),t.updatePlayButton(),t.emitEvent("ready"),t.updateLinks())},jt=document.head,Bt={get title(){for(const t of['property="og:title"','name="twitter:title"']){const e=jt.querySelector(`meta[${t}]`);if(e)return e.content}const t=document.title;return""===t?null:t},get poster(){for(const t of['property="og:image"','name="twitter:image:src"']){const e=jt.querySelector(`meta[${t}]`);if(e)return e.content}return null},get canonical(){const t=jt.querySelector('link[rel="canonical"]');return t?t.href:location.href.split("#")[0]},get twitter(){const t=jt.querySelector('meta[name="twitter:creator"]');return t&&t.content.length>1?t.content:null},playlist:null,waveform:null,duration:null,download:null},Ft={attributesChanges:function(){let t=null;if(this.element.hasAttribute("mode")){t=this.element.getAttribute("mode");const[e,n]=t.split(",");n&&(t=this.audiotag.paused?e:n,this.mode_when_play=n)}this.setMode(t),this.element.hasAttribute("hide")&&this.setHide(this.element.getAttribute("hide").split(" "))},audiotagDataset:function(){return{...Bt,...this.audiotag.dataset}},mirroredInController:function(){const t=document.CPU.globalController;return t&&this.audiotag.isEqualNode(t.audiotag)},emitEvent:async function(t,e){this.element.dispatchEvent(new CustomEvent(`CPU_${t}`,{target:this.element,bubbles:!0,cancelable:!1,composed:!1,detail:e}))},shadowId:function(t){return this.shadow.getElementById(t)}},Vt=["poster","actions","timeline","chapters","panels","panels-title","panels-except-play"],Kt={setMode:function(t=null){if(t=t??"default",this.mode_was===t)return;const{classList:e}=this.container;e.remove(`mode-${this.mode_was}`),e.add(`mode-${t}`),this.mode_was=t},setAct:function(t){if(this.act_was===t)return;if(!document.CPU.hadPlayed&&"loading"===t){if(null!==this.act_was)return;t="glow"}const e=this.container.classList;e.remove("act-loading","act-buffer","act-pause","act-play","act-glow"),e.add(`act-${t}`),"play"===this.act_was&&"loading"===t&&e.add("act-buffer"),this.act_was=t},setHide:function(t){const e=this.container.classList;for(const t of Vt)e.remove(`hide-${t}`);for(let n of t)n=n.toLowerCase(),Vt.includes(n)&&e.add(`hide-${n}`)},completeTemplate:function(){const t=this.audiotagDataset();let{title:e,waveform:n}=t;const o=this.shadowId("canonical");if(o){o.href=t.canonical;let n=o.classList;e?n.remove("untitled"):(n.add("untitled"),e=v.untitled),o.innerText=e}this.element.title!==e&&(this.element.title=e);const a=this.shadowId("poster");a&&(a.src=t.poster||"");const i=this.shadowId("time");i&&(i.style.backgroundImage=n?`url(${n})`:""),this.showMain()},attachAudiotagToInterface:function(t){t&&(this.audiotag=t,function(t){t.id=t.id||`${document.CPU.IDPrefix}${Et++}`}(t),this.completeTemplate(),_t({target:t}))},injectCss:function(e,n){if(!e.match(w))return o=`injectCss invalid key "${e}"`,void window.console.error(`${t}▷ `,o);var o;this.removeCss(e);const a=document.createElement("style");a.id=`style_${e}`,a.innerHTML=n,this.container.appendChild(a)},removeCss:function(t){this.shadowId(`style_${t}`)?.remove()}},Wt=Kt,Gt="_borders",Xt={updatePlayButton:function(){const t=this.audiotag,e=t.getAttribute("preload"),n=this.shadowId("control"),o="aria-label";let a=!e||"none"!==e.toLowerCase();if(t.readyState<t.HAVE_CURRENT_DATA&&(a||t._CPU_played))return this.setAct("loading"),void n.setAttribute(o,v.loading);let i="pause",r="play";t.paused&&(i="play",r="pause",!t._CPU_played&&this.glowBeforePlay&&(r="glow")),this.setAct(r),n.setAttribute(o,v[i]);const s="last-used",l=this.container.classList;t.paused?this.audiotag.isEqualNode(document.CPU.lastUsed)||l.remove(s):(t._CPU_played=!0,l.add(s),this.mode_when_play&&(this.setMode(this.mode_when_play),this.mode_when_play=null))},updateLine:function(t,e=null){const n=this.shadowId("loadingline");if(!n)return;const{duration:o}=this.audiotag;e=e??(0===o?0:100*t/o),n.style.width=`${e}%`},updateTime:function(){const t=this.audiotag,e=V(t)?0:Math.floor(t.currentTime),n=t.dataset.canonical??"",o=n.indexOf("#"),a=this.shadowId("elapse");a&&(a.href=`${s(n)}#${o<0?t.id:n.substr(o+1)}&t=${e}`);this.shadowId("currenttime")&&(this.shadowId("currenttime").innerText=L(t.currentTime));const i=this.shadowId("totaltime");if(i){const e=G(t);i.innerText=W(e)?"":` / ${L(e)}`,N(i,e)}this.updateLine(t.currentTime)},updateTimeBorders:function(){const t=this.audiotag;if(document.CPU.isAudiotagGlobal(t)&&!1!==mt){if(this.plane(Gt)){const t=this.point(Gt,Gt);if(t&&t.start===ht&&t.end===mt)return}this.addPlane(Gt,{track:"borders",panel:!1,highlight:!1}),this.addPoint(Gt,Gt,{start:ht,link:!1,end:mt})}else this.removePlane(Gt)},updateLoading:function(t,e){this.updateLine(t,e),this.setAct("loading")},updateError:function(){const t=this.audiotag;if(!t)return!0;const e=t.error;if(e){let t;this.show("error");const n=MediaError;switch(e.code){case n.MEDIA_ERR_ABORTED:t=v.media_err_aborted;break;case n.MEDIA_ERR_NETWORK:t=v.media_err_network;break;case n.MEDIA_ERR_DECODE:t=v.media_err_decode;break;case n.MEDIA_ERR_SRC_NOT_SUPPORTED:t=v.media_err_src_not_supported;break;default:t=v.media_err_unknow}const o=this.shadowId("pageerror");return o&&(o.innerText=t),!0}return!1},updateLinks:function(){const t=this.audiotag,e=this.audiotagDataset(),n=s(e.canonical??""),o=0===t.currentTime?"":`&t=${Math.floor(t.currentTime)}`,a=n===s(window.location.href)?t.id:"",i=encodeURIComponent(`${n}#${a}${o}`),r="@"!==e.twitter?.[0]?"":`&via=${e.twitter.substring(1)}`,l=t.querySelector("source[data-downloadable]")?.src||e.download||t.currentSrc,c=e.title,d={twitter:`https://twitter.com/share?text=${c}&url=${i}${r}`,facebook:`https://www.facebook.com/sharer.php?t=${c}&u=${i}`,email:`mailto:?subject=${c}&body=${i}`,link:l};for(const t in d){const e=this.shadowId(t);e&&(e.href=d[t])}},update:function(){this.updateError()||(this.updatePlayButton(),this.updateTime(),this.updateTimeBorders())}},Jt=Xt,Yt={positionTimeElement:function(t,e=null,n=null){const{duration:o}=this.audiotag;if(W(o))return;const a=t=>null!=t&&!1!==t;a(e)&&(t.style.left=e/o*100+"%"),a(n)&&(t.style.right=100*(1-n/o)+"%")},showThrobberAt:async function(t){const e=this.audiotag;if(e.duration<1)return;isNaN(e.duration)&&!V(e)&&(e.setAttribute("preload","metadata"),Lt(e,wt,event));const n=this.shadowId("popup");this.positionTimeElement(n,t),n.style.opacity=1,n.innerHTML=L(t),n.dateTime=E(t).toUpperCase()},hideThrobber:function(){this.shadowId("popup").style.opacity=0},hideThrobberLater:function(){const t=this.shadowId("popup");t._hider&&window.clearTimeout(t._hider),t._hider=window.setTimeout((()=>{this.hideThrobber()}),1e3)}},Qt={show:function(t){const{classList:e}=this.container;e.remove("show-main","show-share","show-error","media-streamed"),V(this.audiotag)&&e.add("media-streamed"),e.add(`show-${t}`)},showActions:function(){this.show("share"),this.updateLinks()},showMain:function(){N(this.container,!0),this.show("main")},showHandheldNav:function(t){V(this.audiotag)||(this.container.classList.toggle("show-handheld-nav"),t?.preventDefault())}};function Zt({start:t,end:e}){return(null==t||t>=0)&&(null==e||e>=t)}const te={planeNames:function(){return Object.keys(this._planes).concat(Object.keys(this.audiotag?._CPU_planes??{}))},plane:function(t){return this._planes[t]??this.audiotag?._CPU_planes[t]},planeTrack:function(t){return this.shadowId(`track_«${t}»`)},planePanel:function(t){return this.shadowId(`panel_«${t}»`)},planeNav:function(t){return this.planePanel(t)?.querySelector("ul")},addPlane:function(t,e={}){if(!t.match(w)||this.plane(t))return!1;if((e={track:!0,panel:!0,title:"",highlight:!0,points:{},_comp:!1,...e})._comp)this._planes[t]=e;else{if(this.isController)return!1;this.audiotag._CPU_planes=this.audiotag._CPU_planes??{},this.audiotag._CPU_planes[t]=e}return this.drawPlane(t),!0},removePlane:function(t){return!(!t.match(w)||!this.plane(t)||this.isController&&!this._planes[t])&&(delete(this._planes[t]?this._planes:this.audiotag._CPU_planes)[t],this.planeTrack(t)?.remove(),this.planePanel(t)?.remove(),!this.isController&&this.mirroredInController()&&document.CPU.globalController.drawPlane(t),!0)},planePoints:function(t){return this.plane(t)?.points},point:function(t,e){return this.plane(t)?.points?.[e]},pointTrack:function(t,e){return this.shadowId(P(t,e,!1))},pointPanel:function(t,e){return this.shadowId(P(t,e,!0))},planeSort:function(t){const e=this.planePoints(t);if(!e)return;this.plane(t).points=Object.fromEntries(Object.entries(e).sort((([,t],[,e])=>t.start-e.start)));const n=Object.values(this.plane(t).points);this.plane(t)._st_max=n[n.length-1]?.start??0},planePointNames:function(t){return Object.keys(this.planePoints(t))},panelReorder:function(t){if(this.planeSort(t),!this.planePanel(t))return;let e,n;for(const o of this.planePointNames(t))n=this.pointPanel(t,o),e?.insertAdjacentElement("afterend",n),e=n},addPoint:function(t,e,n={}){const o=Number(n.start);return!(!e.match(w)||!this.plane(t)||this.point(t,e)||!Zt(n))&&(!(!this._planes[t]&&this.isController)&&(n.start=o,this.plane(t).points[e]=n,this.emitEvent("addPoint",{planeName:t,pointName:e,pointData:n}),this.plane(t)._st_max>o?this.panelReorder(t):(this.drawPoint(t,e),this.plane(t)._st_max=o),!0))},bulkPoints:function(t,e={}){if(!this.plane(t))return!1;if(!this._planes[t]&&this.isController)return!1;for(const[t,n]of Object.entries(e))if(!t.match(w)||!Zt(n))return!1;e={...this.plane(t).points,...e},this.plane(t).points=e,this.emitEvent("bulkPoints",{planeName:t,pointDataGroup:e});const n=this.planeNav(t);return n&&(n.innerHTML=""),this.refreshPlane(t),!0},editPoint:function(t,e,n){const o=this.plane(t);if(!o)return!1;const a=this.point(t,e);if(!a)return!1;let{start:i}=n;i=Number(i);const r=null!=i&&i!==a.start;if(!Zt(n={...a,...n}))return!1;o.points[e]=n,this.drawPoint(t,e),r&&this.panelReorder(t),this.emitEvent("editPoint",{planeName:t,pointName:e,pointData:n}),o._st_max<i&&(o._st_max=i)},removePoint:function(t,e){const n=this.plane(t);if(!n||!this.point(t,e))return!1;this.emitEvent("removePoint",{planeName:t,pointName:e}),this.pointTrack(t,e)?.remove(),this.pointPanel(t,e)?.remove();let o=0;for(const e of Object.values(this.planePoints(t))){const t=Number(e.start);o=o<t?t:o}return n._st_max=o,!this.isController&&this.mirroredInController()&&document.CPU.globalController.removePoint(t,e),n.points[e]&&delete n.points[e],!0},clearPlane:function(t){const e=this.plane(t);if(!e)return!1;for(const n of Object.keys(e.points))this.removePoint(t,n);const n=this.planeNav(t);return n&&(n.innerHTML=""),e._st_max=0,!0},repositionTracks:function(){if(!W(this.audiotag.duration))for(const t in this.audiotag._CPU_planes){if(this.plane(t).track)for(const e of this.planePointNames(t)){const{start:n,end:o}=this.point(t,e),a=this.pointTrack(t,e);a&&this.positionTimeElement(a,n,o)}}}};const ee=function(t,e){const n=t.planeNames();if(0==n.length)return;const o=e=>{const{track:n,panel:o,points:a}=t.plane(e);return(!1!==n||!1!==o)&&(t.planePanel(e)?.clientHeight>0||t.planeTrack(e)?.clientHeight>0)&&a&&Object.keys(a).length>0};let a,i,r,s=t.focused();if(s&&(s.id||(s=s.closest("[id]")),({planeName:a,pointName:i}=y(s.id))),""!=i&&(r=t.planePointNames(a),i=Y(r,i,e?1:-1)),!i){if(a=e?(t=>{for(let e=n.indexOf(t)+1;e<n.length;e++){const t=n[e];if(o(t))return t}})(a):(t=>{for(let e=n.indexOf(t)-1;e>=0;e--){const t=n[e];if(o(t))return t}})(a),!a)return;const r=t.planePointNames(a);i=r[e?0:r.length-1]}t.focusPoint(a,i)},ne={focusPoint:function(t,e){const n=this.pointPanel(t,e)?.querySelector("a")??this.pointTrack(t,e);return!!n&&(n.focus(),!0)},focused:function(){return this.shadow.querySelector(":focus")},focusedId:function(){const t=this.focused();if(!t)return;const e=""!=t.id?t.id:t.closest("[id]").id;return""==e?null:e},prevFocus:function(){ee(this,!1)},nextFocus:function(){ee(this,!0)}},oe=ne;const ae=function(t){const{audiotag:e,shadowRoot:n}=t,a={element:t,shadow:n,audiotag:e,mode_when_play:null,glowBeforePlay:!!t.hasAttribute("glow"),current_playlist:[],_activecue_id:null,mode_was:null,act_was:null,isController:!1,...Ft,...Wt,...Jt,...Yt,...Qt,...te,...st,...oe,translateVTT:F,planeAndPointNamesFromId:y};a.container=a.shadowId("interface"),t.CPU=a,e&&!e._CPU_planes&&(e._CPU_planes={}),a._planes={};const i=document.CPU.globalController;e&&i&&!i.audiotag&&re(e),e||(a.isController=!0,a.container.classList.add("controller"),document.CPU.globalController=a,a.audiotag=document.querySelector(o),Lt(a.audiotag)),Rt(a),a.attachAudiotagToInterface(a.audiotag),a.attributesChanges()},ie="audio";function re(t){const e=document.CPU.globalController;if(e&&!t.isEqualNode(e.audiotag)){const n=document.CPU.globalController.element.querySelector(ie);n&&(ct(n),n.remove());const o=e.focusedId();e.attachAudiotagToInterface(t),e.showMain(),e.redrawAllPlanes(),e.setMode(),ut(o)}}function se([{target:n}]){const o=i(n),a=o.element,r=a.querySelector(ie),s=document.CPU.globalController;if(!r&&a.tagName!==e)return l="<audio> element was removed.",window.console.info(`${t}▷ `,l),a.remove(),void(s&&dt());var l;a.copyAttributesToMediaDataset?.(),o.attributesChanges(),document.CPU.currentPlaylistID()===r?.dataset.playlist&&dt()}class le extends HTMLElement{constructor(){if(super(),this.CPU=null,this.observer=null,p)this.remove();else{if(this.tagName===t&&!this.querySelector(n))return h(`<${t}> tag without <audio controls>.\nRead the manual first: https://github.com/dascritch/cpu-audio/blob/master/INSTALL.md`),void this.remove();if(this.tagName===e&&document.CPU.globalController)return h(`<${e}> tag instancied twice`),void this.remove();this.shadow=this.attachShadow({mode:"open"}),this.shadow.innerHTML=`<style>:host{all:initial;display:block;contain:content}.act-buffer,.act-play{--cpu-background:var(--cpu-playing-background);--cpu-color:var(--cpu-playing-color)}.show-error{--cpu-background:var(--cpu-error-background);--cpu-color:var(--cpu-error-color)}#interface{--cpu-timeline-height:10px;background:var(--cpu-background);color:var(--cpu-color)}#interface.no{display:block;pointer-events:none}#interface.no main{visibility:hidden}#interface,*{font-family:var(--cpu-font-family);font-size:var(--cpu-font-size);font-weight:400;font-style:normal;line-height:var(--cpu-line-height);border:none;padding:0;margin:0;text-indent:0;list-style-type:none;-webkit-user-select:none;user-select:none;transition:color var(--cpu-color-transitions),background-color var(--cpu-background-transitions),opacity var(--cpu-background-transitions)}main{display:flex;overflow:hidden;height:var(--cpu-height);top:0;z-index:2}main,summary{position:sticky;background:var(--cpu-background)}a,button{color:currentColor;border:none;text-decoration:none;cursor:pointer;-webkit-touch-callout:none}button{background:0 0}svg{fill:currentColor;width:var(--cpu-height);height:var(--cpu-height)}em,i{font-style:italic}b,strong{font-weight:700}[src='']{visibility:hidden}#pageerror{padding:0 4px;align-self:center}.siders{flex:0 0 var(--cpu-height);width:var(--cpu-height);max-height:var(--cpu-height);height:100%;text-align:center;vertical-align:middle}.act-glow #play,.act-loading #loading,.act-pause #play,.act-play #pause{display:block}.act-glow #play{animation:glow 2s infinite}@keyframes glow{0%{opacity:.5}50%{opacity:1}100%{opacity:.5}}.show-main #pagemain,.show-share #pageshare{flex:1 1 100%;display:flex;align-items:center}.act-loading #loading circle{fill:#777;opacity:1;animation:pulse 2s infinite}#loading circle:nth-child(2){animation-delay:.5s}#loading circle:nth-child(3){animation-delay:1s}@keyframes pulse{50%{opacity:0}}#poster{max-width:var(--cpu-height);min-width:var(--cpu-height);max-height:var(--cpu-height);min-height:var(--cpu-height);object-fit:contain;opacity:0}.poster-loaded #poster{opacity:1}.siders svg{vertical-align:middle;max-width:100%;max-height:100%}#titleline{display:flex;align-items:center}#about,#title{flex:1 1 auto;position:relative}#title{overflow:hidden;text-overflow:'…'}#title a{display:block;max-height:calc(6px + calc(2 * var(--cpu-font-size)))}#canonical.untitled{font-style:italic}#elapse{flex:0 1 var(--cpu-elapse-width);text-align:right}.mode-compact #elapse{flex:0 0 calc(var(--cpu-elapse-width) + 32px);text-align:center}#time{background-color:#000;background-repeat:no-repeat;background-size:100% 100%;width:100%;height:var(--cpu-timeline-height);display:block;position:relative}#loadingline{background:currentColor;height:var(--cpu-timeline-height);display:block;position:absolute;left:0;pointer-events:none}#loadingline:after{content:'';position:absolute;right:0;width:0;height:var(--cpu-timeline-height);display:block;outline:var(--cpu-color) 4px solid;z-index:127;opacity:0}main:focus #loadingline:after,main:hover #loadingline:after{opacity:1}aside{position:absolute;width:100%}aside a{position:absolute;display:block}aside a span{display:none}aside.chapters{height:2px}aside.chapters a{background:var(--cpu-cue);height:2px;border:1px solid var(--cpu-background)}aside.chapters a.active-cue{background:var(--cpu-color)}aside.borders{pointer-events:none;height:var(--cpu-timeline-height);z-index:4;top:calc(var(--cpu-timeline-height) + 6px)}aside.borders a{height:var(--cpu-timeline-height);background:0 0}aside.borders a:after,aside.borders a:before{pointer-events:none;content:"";position:absolute;width:2px;height:var(--cpu-timeline-height);border:2px solid var(--cpu-timeline-limits)}aside.borders a:before{border-right-width:0;left:0}aside.borders a:after{border-left-width:0;left:100%}.act-loading #loadingline{background:repeating-linear-gradient(45deg,var(--cpu-color) 0,var(--cpu-background) 15px,var(--cpu-color) 30px);background-size:200% 200%;animation:loadingline 1s linear infinite}@keyframes loadingline{0%{background-position-y:var(--cpu-timeline-height)}}#handheld-nav{max-height:calc(6px + calc(2 * var(--cpu-font-size)));padding-bottom:8px}.show-handheld-nav #handheld-nav{display:flex}#handheld-nav *{flex:1 0 auto;height:calc(2 * var(--cpu-font-size))}.hide-actions #actions{visibility:hidden;pointer-events:none;min-width:var(--cpu-min-padding);max-width:var(--cpu-min-padding)}#pageshare{text-align:center}#pageshare a{display:flex;align-items:center;justify-content:center;height:var(--cpu-height)}#pageshare a,#pageshare div{flex:1 0;color:#fff;text-decoration:none;overflow:hidden;text-overflow:clip}#pageshare svg{vertical-align:middle;width:32px;height:32px}#twitter{background:#4db5f4}#facebook,#nativeshare{background:#5974cc}#email{background:#c00}#link{background:#77f}#popup{pointer-events:none;position:absolute;transform:translate(-25px,-19px);z-index:127;min-width:50px;font-size:11px;text-align:center;padding:2px;border-radius:4px;box-shadow:#000 2px 2px;background:var(--cpu-popup-background);color:var(--cpu-popup-color);opacity:0}#popup:before{pointer-events:none;content:"";position:absolute;z-index:127;left:20px;bottom:-8px;width:0;height:0;border-top:8px solid var(--cpu-popup-background);border-left:4px solid transparent;border-right:4px solid transparent}.panel{display:flex;list-style:none;flex-direction:column;padding:0 var(--cpu-min-padding);box-shadow:var(--cpu-inner-shadow)}summary{text-align:center;list-style-type:revert;top:var(--cpu-height);box-shadow:var(--cpu-inner-shadow);padding:4px}summary::marker{content:'⍓ '}[open]>summary::marker{content:'⍌ '}.cue{border-top:1px solid #000;display:flex;margin:0;padding:2px}.cue strong{flex:1 1;font-weight:400}.cue time{flex:0 0 var(--cpu-elapse-width) 0px;text-align:right}.nocuetime time{display:none}.cue time,aside a{font-size:var(--cpu-font-small-size)}.mode-compact{width:calc(var(--cpu-elapse-width) + var(--cpu-height) * 2 + 32px)}.mode-button{width:var(--cpu-height)}.mode-button #about,.mode-button #actions,.mode-button #poster,.mode-button .panel,.mode-button aside,.mode-compact #actions,.mode-compact #line,.mode-compact #title,.mode-compact .panel,.mode-compact aside{width:0;display:none}#control svg,#handheld-nav,#pageshare #nativeshare,.hasnativeshare #pageshare .nonativeshare,.hide-chapters .chapters,.hide-panels .panel,.hide-panels-except-play .panel,.hide-panels-title summary,.hide-poster #poster,.hide-timeline #line,.media-streamed #line,.media-streamed #link,.mode-hidden,.no,.show-error #pagemain,.show-error #pageshare,.show-error #poster,.show-error .panel,.show-handheld-nav #titleline,.show-main #pageerror,.show-main #pageshare,.show-share #pageerror,.show-share #pagemain{display:none}.hasnativeshare #pageshare #nativeshare{display:flex}.mode-compact.show-main #pagemain{flex:0 0 auto}#pageshare div:hover,.active-cue,.with-preview,a:focus,a:hover,button:focus,button:hover,summary:focus{background:var(--cpu-focus-background,var(--cpu-color))!important;color:var(--cpu-focus-color,var(--cpu-background))!important;outline:0}@media (max-width:640px){.nosmall{display:none!important}#elapse{max-height:16px}#interface{--cpu-timeline-height:8px}#handheld-nav{padding-bottom:4px}}@media (max-width:480px){.nosmaller{display:none!important}.mode-default #elapse{flex:0 1 var(--cpu-elapse-width)}.mode-default #pagemain{padding-bottom:16px}#titleline{height:32px}#line{position:absolute;left:calc(0px - var(--cpu-height));right:calc(0px - var(--cpu-height));height:16px;top:32px}aside a{pointer-events:none}aside.borders{top:-2px}aside.chapters{top:8px}#handheld-nav{padding-bottom:2px}.siders svg{height:calc(var(--cpu-height) - 16px)}}@media (max-width:320px){.mode-default #elapse,.nosmallest{display:none!important}}@media print{#interface{display:none}}@media (prefers-reduced-motion:reduce){*{animation:none!important}}</style><div id="interface"class="no"tabindex="-1"><main><img id="poster"class="nosmall"src=""alt=""loading="lazy"decoding="async"><section id="pageerror"role="alert"></section><section id="pagemain"><button type="button"id="control"tabindex="0"class="siders"><svg id="loading"viewBox="0 0 32 32"aria-hidden="true"><title>${f.loading}</title><circle cx="6"cy="22"r="4"/><circle cx="16"cy="22"r="4"/><circle cx="26"cy="22"r="4"/></svg> <svg id="pause"viewBox="0 0 32 32"aria-hidden="true"><title>${f.pause}</title><path d="M 6,6 12.667,6 12.667,26 6,26 z"/><path d="M 19.333,6 26,6 26,26 19.333,26 z"/></svg> <svg id="play"viewBox="0 0 32 32"aria-hidden="true"><title>${f.play}</title><path d="M 6,6 6,26 26,16 z"/></svg></button><div id="about"><div id="titleline"><strong id="title"><a href="#"id="canonical"aria-label="${f.canonical}"></a></strong> <a id="elapse"aria-label="${f.moment}"tabindex="-1"><span id="currenttime">…</span><span id="totaltime"class="nosmaller"></span></a></div><div id="handheld-nav"><button type="button"id="restart"><svg viewBox="0 0 24 16"aria-hidden="true"><polygon points="4,0 8,0 8,16 4,16"/><path d="M 16,0 8,8 16,16 z"/><path d="M 24,0 16,8 24,16 z"/></svg></button> <button type="button"id="fastreward"><svg viewBox="0 0 24 16"aria-hidden="true"><path d="M 8,0 0,8 8,16 z"/><path d="M 16,0 8,8 16,16 z"/><path d="M 24,0 16,8 24,16 z"/></svg></button> <button type="button"id="reward"class="nosmallest"><svg viewBox="0 0 24 16"aria-hidden="true"><path d="M 12,0 4,8 12,16 z"/><path d="M 20,0 12,8 20,16 z"/></svg></button> <button type="button"id="foward"><svg viewBox="0 0 24 16"aria-hidden="true"><path d="M 4,0 12,8 4,16 z"/><path d="M 12,0 20,8 12,16 z"/></svg></button> <button type="button"id="fastfoward"><svg viewBox="0 0 24 16"aria-hidden="true"><path d="M 0,0 8,8 0,16 z"/><path d="M 8,0 16,8 8,16 z"/><path d="M 16,0 24,8 16,16 z"/></svg></button></div><div id="line"><div id="time"><div id="loadingline"role="progressbar"aria-labelledby="popup"></div><time id="popup">--:--</time></div></div></div><a href="#"target="social"id="link"aria-label="${f.download}"title="${f.download}"download class="siders"><svg viewBox="0 0 32 32"aria-hidden="true"><path d="M 6,6 26,6 16,22 z"/><rect x="6"y="22"width="20"height="4"/></svg></a></section></main></div><style>/* Not the recommended way, but I didn't want to copy the whole scoped.css for invalidate only one^w a couple of rules */\n\t#link {\n\t\tbackground : none !important;\n\t}\n\t#link:hover, #link:focus {\n\t\tbackground: var(--cpu-focus-background, var(--cpu-color)) !important;\n\t}</style>`}}connectedCallback(){p||this.shadowRoot&&(new ae(this),this.observer=new MutationObserver(se),this.observer.observe(this,{childList:!0,attributes:!0}),this.CPU.attributesChanges())}disconnectedCallback(){this.observer&&(this.observer.disconnect(),this.CPU.emitEvent("removed"),this.tagName===e&&document.CPU.globalController&&(document.CPU.globalController=null))}}function ce([{target:t}]){const e=i(t);nt(e),e.completeTemplate();const n=document.CPU.globalController;e.audiotag.isEqualNode(n?.audiotag)&&(nt(n),n.completeTemplate())}class de extends le{constructor(){super(),this.audiotag=this.querySelector(n),this.audiotag?this.observer=null:this.remove()}copyAttributesToMediaDataset(){if(this.audiotag){for(const t in document.CPU.defaultDataset)if(this.hasAttribute(t)){const e=this.getAttribute(t);this.audiotag.dataset[t]="duration"!==t?e:T(e)}}else this.remove()}connectedCallback(){this.audiotag&&(this.copyAttributesToMediaDataset(),super.connectedCallback(),At(this.CPU.audiotag),this.observer=new MutationObserver(ce),this.observer.observe(this,{childList:!0,attributes:!0,subtree:!0}),document.CPU.currentPlaylistID()===this.audiotag.dataset.playlist&&dt())}disconnectedCallback(){const t=document.CPU.globalController,e=this.audiotag.dataset.playlist;this.audiotag&&t&&this.audiotag.isEqualNode(t.audiotag)?t.element.appendChild(this.audiotag):e&&ct(this.audiotag),super.disconnectedCallback()}}const ue="script[data-cpu-audio]";const pe=async function(t,e,n){function a({target:t}){const n=T(e);document.CPU.seekElementAt(t,n);const o={target:t};t.readyState>=t.HAVE_FUTURE_DATA?i(o):t.addEventListener("canplay",i,c),_t(o)}function i(t){ft(null,t.target),n?.()}const r=""!==t?document.getElementById(t):document.querySelector(o);if(null==(r?.currentTime??null))return void h(`Unknow audiotag #${t}`);const s={target:r};if(r.readyState<r.HAVE_CURRENT_DATA)return r.addEventListener("loadedmetadata",a,c),r.load(),void _t(s);a(s)},he=function(t,e){if(!K(e)&&!V(t)){if(e=X(t,e),t.fastSeek)t.fastSeek(e);else try{const n=()=>{t.currentTime=e};t.readyState>=t.HAVE_CURRENT_DATA?n():(t.load(),n(),t.currentTime<e&&t.addEventListener("loadedmetadata",n,{once:!0}))}catch(n){t.src=`${t.currentSrc.split("#")[0]}#t=${e}`}i(t)?.updateLoading?.(e)}},me={...{playStopOthers:!0,scrollTo:!1,autoplay:!1,IDPrefix:"CPU-Audio-tag-",globalCss:!0,advanceInPlaylist:!0,keymove:5,alternateDelay:1e3,fastFactor:4,repeatDelay:400,repeatFactor:100},...function(){const t=document.head.querySelector(ue);if(!t)return{};try{return JSON.parse(t.innerHTML)}catch{return h(`invalid ${ue} parameter tag`),{}}}(),defaultDataset:Bt,currentAudiotagPlaying:null,globalController:null,hadPlayed:!1,lastUsed:null,playlists:{},convert:I,trigger:xt,findCPU:i,adjacentKey:function(t,e,n){if(!t?.hasOwnProperty)return null;const o=Object.keys(t);return o[o.indexOf(e)+n]},isAudiotagPlaying:function(t){const e=document.CPU.currentAudiotagPlaying;return e&&t.isEqualNode(e)},isAudiotagGlobal:function(t){return this.globalController?t.isEqualNode(this.globalController.audiotag):this.isAudiotagPlaying(t)},jumpIdAt:pe,seekElementAt:he,currentPlaylist:function(){const t=this.globalController?.audiotag;if(!t)return[];for(const e of Object.values(this.playlists))if(e.includes(t.id))return e;return[]},currentPlaylistID:function(){const t=this.globalController?.audiotag;if(!t)return[];for(const e of Object.keys(this.playlists))if(this.playlists[e].includes(t.id))return e;return null}};async function ge(){let o;u?(o="with-webcomponents",me.globalCss&&function(){const t=document.createElement("style");t.innerHTML='audio[controls]{display:block;width:100%}:root{--cpu-height:64px;--cpu-font-family:Lato,"Open Sans","Segoe UI",Frutiger,"Frutiger Linotype","Dejavu Sans","Helvetica Neue",Arial,sans-serif;--cpu-font-size:15px;--cpu-font-small-size:calc(var(--cpu-font-size) * 0.8);--cpu-line-height:1.2;--cpu-background:#555;--cpu-color:#ddd;--cpu-playing-background:#444;--cpu-playing-color:#fff;--cpu-error-background:#a00;--cpu-error-color:#ff7;--cpu-popup-background:#aaa;--cpu-popup-color:#333;--cpu-cue:#000;--cpu-timeline-limits:#f00;--cpu-elapse-width:160px;--cpu-min-padding:16px;--cpu-inner-shadow:inset 0px 5px 10px -5px black;--cpu-color-transitions:0s;--cpu-background-transitions:0s}@media (max-width:640px){.interface,:root{--cpu-font-size:13px;--cpu-height:48px;--cpu-elapse-width:140px;--cpu-min-padding:4px}@media (max-width:480px){.interface,:root{--cpu-elapse-width:70px}}}',document.head.appendChild(t)}(),window.customElements.define(t.toLowerCase(),de),window.customElements.define(e.toLowerCase(),le)):(o="without-webcomponents",h("WebComponent may NOT behave correctly on this browser. Only timecode hash links are activated.\nSee https://github.com/dascritch/cpu-audio/ for details"),a(n,Ut)),document.body.classList.add(`cpu-audio-${o}`),window.addEventListener("hashchange",Ct,l),Ct({at_start:!0})}document.CPU||window.customElements.get(t.toLowerCase())?h("cpu-audio is called twice"):(HTMLDocument.prototype.CPU=me,document.addEventListener("DOMContentLoaded",ge,l),"loading"!==document.readyState&&ge())})();
//# sourceMappingURL=cpu-audio.direct-download.js.map
// Generated theme : direct-download