PageSourceSearch

https://ronig-protein-binding-search.hf.space/assets/StaticAudio-BQSU9k6M.js

js ronig-protein-binding-search.hf.space collected 2026-10-03 10:21:10 UTC 66,869 bytes, 104 lines download raw bytes

1import{I as jt}from"./Index-B0pzGNvZ.js";import{f as He,u as qt}from"./Blocks-CbMTi72h.js";import{B as Bt}from"./BlockLabel-BIX1_TXx.js";import{E as zt}from"./Empty-DxPQy4lp.js";import{S as It}from"./ShareButton-DY61e3s8.js";import{D as Ut}from"./Download-DVtk-Jv3.js";import{M as nt}from"./Music-CDm0RGMk.js";import{a as xt,P as Ft,T as Xt}from"./Trim-UKwaW4UI.js";import{U as Gt}from"./Undo-CpmTQw3B.js";import{r as ht}from"./file-url-MvGfSkSF.js";import{D as Zt}from"./DownloadLink-8VIFhju3.js";const{SvelteComponent:Yt,append:Jt,attr:F,detach:Kt,init:Qt,insert:ei,noop:Ue,safe_not_equal:ti,svg_element:ft}=window.__gradio__svelte__internal;function ii(s){let e,t;return{c(){e=ft("svg"),t=ft("path"),F(t,"stroke","currentColor"),F(t,"stroke-width","1.5"),F(t,"stroke-linecap","round"),F(t,"stroke-linejoin","round"),F(t,"d","M21.044 5.704a.6.6 0 0 1 .956.483v11.626a.6.6 0 0 1-.956.483l-7.889-5.813a.6.6 0 0 1 0-.966l7.89-5.813ZM10.044 5.704a.6.6 0 0 1 .956.483v11.626a.6.6 0 0 1-.956.483l-7.888-5.813a.6.6 0 0 1 0-.966l7.888-5.813Z"),F(e,"xmlns","http://www.w3.org/2000/svg"),F(e,"width","24px"),F(e,"height","24px"),F(e,"fill","currentColor"),F(e,"stroke-width","1.5"),F(e,"viewBox","0 0 24 24"),F(e,"color","currentColor")},m(i,n){ei(i,e,n),Jt(e,t)},p:Ue,i:Ue,o:Ue,d(i){i&&Kt(e)}}}class ni extends Yt{constructor(e){super(),Qt(this,e,null,ii,ti,{})}}const{SvelteComponent:si,append:ri,attr:X,detach:oi,init:li,insert:ai,noop:xe,safe_not_equal:ui,svg_element:mt}=window.__gradio__svelte__internal;function di(s){let e,t;return{c(){e=mt("svg"),t=mt("path"),X(t,"stroke","currentColor"),X(t,"
1stroke-width","1.5"),X(t,"stroke-linecap","round"),X(t,"stroke-linejoin","round"),X(t,"d","M2.956 5.704A.6.6 0 0 0 2 6.187v11.626a.6.6 0 0 0 .956.483l7.889-5.813a.6.6 0 0 0 0-.966l-7.89-5.813ZM13.956 5.704a.6.6 0 0 0-.956.483v11.626a.6.6 0 0 0 .956.483l7.889-5.813a.6.6 0 0 0 0-.966l-7.89-5.813Z"),X(e,"xmlns","http://www.w3.org/2000/svg"),X(e,"width","24px"),X(e,"height","24px"),X(e,"fill","currentColor"),X(e,"stroke-width","1.5"),X(e,"viewBox","0 0 24 24"),X(e,"color","currentColor")},m(i,n){ai(i,e,n),ri(e,t)},p:xe,i:xe,o:xe,d(i){i&&oi(e)}}}class ci extends si{constructor(e){super(),li(this,e,null,di,ui,{})}}const{SvelteComponent:hi,append:Ae,attr:q,detach:fi,init:mi,insert:_i,noop:Fe,safe_not_equal:pi,svg_element:We,text:gi}=window.__gradio__svelte__internal;function vi(s){let e,t,i,n,r;return{c(){e=We("svg"),t=We("title"),i=gi("Low volume"),n=We("path"),r=We("path"),q(n,"d","M19.5 7.5C19.5 7.5 21 9 21 11.5C21 14 19.5 15.5 19.5 15.5"),q(n,"stroke-width","1.5"),q(n,"stroke-linecap","round"),q(n,"stroke-linejoin","round"),q(r,"d","M2 13.8571V10.1429C2 9.03829 2.89543 8.14286 4 8.14286H6.9C7.09569 8.14286 7.28708 8.08544 7.45046 7.97772L13.4495 4.02228C14.1144 3.5839 15 4.06075 15 4.85714V19.1429C15 19.9392 14.1144 20.4161 13.4495 19.9777L7.45046 16.0223C7.28708 15.9146 7.09569 15.8571 6.9 15.8571H4C2.89543 15.8571 2 14.9617 2 13.8571Z"),q(r,"stroke-width","1.5"),q(e,"width","100%"),q(e,"height","100%"),q(e,"viewBox","0 0 24 24"),q(e,"stroke-width","1.5"),q(e,"fill","none"),q(e,"xmlns","http://www.w3.org/2000/svg"),q(e,"stroke","currentColor"),q(e,"color","currentColor")},m(o,u){_i(o,e,u),Ae(e,t),Ae(t,i),Ae(e,n),Ae(e,r)},p:Fe,i:Fe,o:Fe,d(o){o&&fi(e)}}}class bi extends hi{constructor(e){super(),mi(this,e,null,vi,pi,{})}}const{SvelteComponent:wi,append:$e,attr:A,detach:yi,init:ki,insert:Ci,noop:Xe,safe_not_equal:Ei,svg_element:Se,text:$i}=window.__gradio__svelte__internal;function Si(s){let e,t,i,n,r,o;return{c(){e=Se("svg"),t=Se("title"),i=$i("High volume"),n=Se("path"),r=Se("path"),o=Se("path"),A(n,"d","M1 13.8571V10.1429C1 9.03829 1.89543 8.14286 3 8.14286H5.9C6.09569 8.14286 6.28708 8.08544 6.45046 7.97772L12.4495 4.02228C13.1144 3.5839 14 4.06075 14 4.85714V19.1429C14 19.9392 13.1144 20.4161 12.4495 19.9777L6.45046 16.0223C6.28708 15.9146 6.09569 15.8571 5.9 15.8571H3C1.89543 15.8571 1 14.9617 1 13.8571Z"),A(n,"stroke-width","1.5"),A(r,"d","M17.5 7.5C17.5 7.5 19 9 19 11.5C19 14 17.5 15.5 17.5 15.5"),A(r,"stroke-width","1.5"),A(r,"stroke-linecap","round"),A(r,"stroke-linejoin","round"),A(o,"d","M20.5 4.5C20.5 4.5 23 7 23 11.5C23 16 20.5 18.5 20.5 18.5"),A(o,"stroke-width","1.5"),A(o,"stroke-linecap","round"),A(o,"stroke-linejoin","round"),A(e,"width","100%"),A(e,"height","100%"),A(e,"viewBox","0 0 24 24"),A(e,"stroke-width","1.5"),A(e,"fill","none"),A(e,"stroke","currentColor"),A(e,"xmlns","http://www.w3.org/2000/svg"),A(e,"color","currentColor")},m(u,a){Ci(u,e,a),$e(e,t),$e(t,i),$e(e,n),$e(e,r),$e(e,o)},p:Xe,i:Xe,o:Xe,d(u){u&&yi(e)}}}class Li extends wi{constructor(e){super(),ki(this,e,null,Si,Ei,{})}}const{SvelteComponent:Mi,append:te,attr:T,detach:Di,init:Ri,insert:Pi,noop:Ge,safe_not_equal:Ti,svg_element:ie,text:Ai}=window.__gradio__svelte__internal;function Wi(s){let e,t,i,n,r,o,u,a,d;return{c(){e=ie("svg"),t=ie("title"),i=Ai("Muted volume"),n=ie("g"),r=ie("path"),o=ie("path"),u=ie("defs"),a=ie("clipPath"),d=ie("rect"),T(r,"d","M18 14L20.0005 12M22 10L20.0005 12M20.0005 12L18 10M20.0005 12L22 14"),T(r,"stroke-width","1.5"),T(r,"stroke-linecap","round"),T(r,"stroke-linejoin","round"),T(o,"d","M2 13.8571V10.1429C2 9.03829 2.89543 8.14286 4 8.14286H6.9C7.09569 8.14286 7.28708 8.08544 7.45046 7.97772L13.4495 4.02228C14.1144 3.5839 15 4.06075 15 4.85714V19.1429C15 19.9392 14.1144 20.4161 13.4495 19.9777L7.45046 16.0223C7.28708 15.9146 7.09569 15.8571 6.9 15.8571H4C2.89543 15.8571 2 14.9617 2 13.8571Z"),T(o,"stroke-width","1.5"),T(n,"clip-path","url(#clip0_3173_16686)"),T(d,"width","24"),T(d,"height","24"),T(d,"fill","white"),T(a,"id","clip0_3173_16686"),T(e,"width","100%"),T(e,"height","100%"),T(e,"viewBox","0 0 24 24"),T(e,"stroke-width","1.5"),T(e,"fill","none"),T(e,"xmlns","http://www.w3.org/2000/svg"),T(e,"stroke","currentColor"),T(e,"color","currentColor")},m(l,c){Pi(l,e,c),te(e,t),te(t,i),te(e,n),te(n,r),te(n,o),te(e,u),te(u,a),te(a,d)},p:Ge,i:Ge,o:Ge,d(l){l&&Di(e)}}}class zi extends Mi{constructor(e){super(),Ri(this,e,null,Wi,Ti,{})}}var Oi=function(s,e,t,i){function n(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function u(l){try{d(i.next(l))}catch(c){o(c)}}function a(l){try{d(i.throw(l))}catch(c){o(c)}}function d(l){l.done?r(l.value):n(l.value).then(u,a)}d((i=i.apply(s,e||[])).next())})};function Hi(s,e){return Oi(this,void 0,void 0,function*(){const t=new AudioContext({sampleRate:e});return t.decodeAudioData(s).finally(()=>t.close())})}function Vi(s){const e=s[0];if(e.some(t=>t>1||t<-1)){const t=e.length;let i=0;for(let n=0;n<t;n++){const r=Math.abs(e[n]);r>i&&(i=r)}for(const n of s)for(let r=0;r<t;r++)n[r]/=i}return s}function Ni(s,e){return typeof s[0]=="number"&&(s=[s]),Vi(s),{duration:e,length:s[0].length,sampleRate:s[0].length/e,numberOfChannels:s.length,getChannelData:t=>s?.[t],copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}const Ze={decode:Hi,createBuffer:Ni};var _t=function(s,e,t,i){function n(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function u(l){try{d(i.next(l))}catch(c){o(c)}}function a(l){try{d(i.throw(l))}catch(c){o(c)}}function d(l){l.done?r(l.value):n(l.value).then(u,a)}d((i=i.apply(s,e||[])).next())})};function ji(s,e,t){var i,n;return _t(this,void 0,void 0,function*(){const r=yield fetch(s,t);{const o=(i=r.clone().body)===null||i===void 0?void 0:i.getReader(),u=Number((n=r.headers)===null||n===void 0?void 0:n.get("Content-Length"));let a=0;const d=(l,c)=>_t(this,void 0,void 0,function*(){if(l)return;a+=c?.length||0;const h=Math.round(a/u*100);return e(h),o?.read().then(({done:m,value:f})=>d(m,f))});o?.read().then(({done:l,value:c})=>d(l,c))}return r.blob()})}const qi={fetchBlob:ji};
vendor: 5,303 bytes, lines 1-17
1class je{constructor(){this.listeners={},this.on=this.addEventListener,this.un=this.removeEventListener}addEventListener(e,t,i){if(this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(t),i?.once){const n=()=>{this.removeEventListener(e,n),this.removeEventListener(e,t)};return this.addEventListener(e,n),n}return()=>this.removeEventListener(e,t)}removeEventListener(e,t){var i;(i=this.listeners[e])===null||i===void 0||i.delete(t)}once(e,t){return this.on(e,t,{once:!0})}unAll(){this.listeners={}}emit(e,...t){this.listeners[e]&&this.listeners[e].forEach(i=>i(...t))}}class Bi extends je{constructor(e){super(),this.isExternalMedia=!1,e.media?(this.media=e.media,this.isExternalMedia=!0):this.media=document.createElement("audio"),e.mediaControls&&(this.media.controls=!0),e.autoplay&&(this.media.autoplay=!0),e.playbackRate!=null&&this.onceMediaEvent("canplay",()=>{e.playbackRate!=null&&(this.media.playbackRate=e.playbackRate)})}onMediaEvent(e,t,i){return this.media.addEventListener(e,t,i),()=>this.media.removeEventListener(e,t)}onceMediaEvent(e,t){return this.onMediaEvent(e,t,{once:!0})}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){const e=this.getSrc();e.startsWith("blob:")&&URL.revokeObjectURL(e)}setSrc(e,t){if(this.getSrc()===e)return;this.revokeSrc();const n=t instanceof Blob?URL.createObjectURL(t):e;this.media.src=n,this.media.load()}destroy(){this.media.pause(),!this.isExternalMedia&&(this.media.remove(),this.revokeSrc(),this.media.src="",this.media.load())}setMediaElement(e){this.media=e}play(){return this.media.play()}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(e){this.media.currentTime=e}getDuration(){return this.media.duration}getCurrentTime(){return this.media.currentTime}getVolume(){return this.media.volume}setVolume(e){this.media.volume=e}getMuted(){return this.media.muted}setMuted(e){this.media.muted=e}getPlaybackRate(){return this.media.playbackRate}setPlaybackRate(e,t){t!=null&&(this.media.preservesPitch=t),this.media.playbackRate=e}getMediaElement(){return this.media}setSinkId(e){return this.media.setSinkId(e)}}function Ii(s,e,t,i,n=5){let r=()=>{};if(!s)return r;const o=u=>{if(u.button===2)return;u.preventDefault(),u.stopPropagation(),s.style.touchAction="none";let a=u.clientX,d=u.clientY,l=!1;const c=f=>{f.preventDefault(),f.stopPropagation();const g=f.clientX,p=f.clientY;if(l||Math.abs(g-a)>=n||Math.abs(p-d)>=n){const{left:C,top:k}=s.getBoundingClientRect();l||(l=!0,t?.(a-C,d-k)),e(g-a,p-d,g-C,p-k),a=g,d=p}},h=f=>{l&&(f.preventDefault(),f.stopPropagation())},m=()=>{s.style.touchAction="",l&&i?.(),r()};document.addEventListener("pointermove",c),document.addEventListener("pointerup",m),document.addEventListener("pointerleave",m),document.addEventListener("click",h,!0),r=()=>{document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",m),document.removeEventListener("pointerleave",m),setTimeout(()=>{document.removeEventListener("click",h,!0)},10)}};return s.addEventListener("pointerdown",o),()=>{r(),s.removeEventListener("pointerdown",o)}}class qe extends je{constructor(e,t){super(),this.timeouts=[],this.isScrolling=!1,this.audioData=null,this.resizeObserver=null,this.isDragging=!1,this.options=e;const i=this.parentFromOptionsContainer(e.container);this.parent=i;const[n,r]=this.initHtml();i.appendChild(n),this.container=n,this.scrollContainer=r.querySelector(".scroll"),this.wrapper=r.querySelector(".wrapper"),this.canvasWrapper=r.querySelector(".canvases"),this.progressWrapper=r.querySelector(".progress"),this.cursor=r.querySelector(".cursor"),t&&r.appendChild(t),this.initEvents()}parentFromOptionsContainer(e){let t;if(typeof e=="string"?t=document.querySelector(e):e instanceof HTMLElement&&(t=e),!t)throw new Error("Container not found");return t}initEvents(){const e=i=>{const n=this.wrapper.getBoundingClientRect(),r=i.clientX-n.left,o=i.clientX-n.left,u=r/n.width,a=o/n.height;return[u,a]};this.wrapper.addEventListener("click",i=>{const[n,r]=e(i);this.emit("click",n,r)}),this.wrapper.addEventListener("dblclick",i=>{const[n,r]=e(i);this.emit("dblclick",n,r)}),this.options.dragToSeek&&this.initDrag(),this.scrollContainer.addEventListener("scroll",()=>{const{scrollLeft:i,scrollWidth:n,clientWidth:r}=this.scrollContainer,o=i/n,u=(i+r)/n;this.emit("scroll",o,u)});const t=this.createDelay(100);this.resizeObserver=new ResizeObserver(()=>{t(()=>this.reRender())}),this.resizeObserver.observe(this.scrollContainer)}initDrag(){Ii(this.wrapper,(e,t,i)=>{this.emit("drag",Math.max(0,Math.min(1,i/this.wrapper.getBoundingClientRect().width)))},()=>this.isDragging=!0,()=>this.isDragging=!1)}getHeight(){return this.options.height==null?128:isNaN(Number(this.options.height))?this.options.height==="auto"&&this.parent.clientHeight||128:Number(this.options.height)}initHtml(){const e=document.createElement("div"),t=e.attachShadow({mode:"open"});return t.innerHTML=`
2      <style>
3        :host {
4          user-select: none;
5          min-width: 1px;
6        }
7        :host audio {
8          display: block;
9          width: 100%;
10        }
11        :host .scroll {
12          overflow-x: auto;
13          overflow-y: hidden;
14          width: 100%;
15          position: relative;
16        }
17        :host .noScrollbar {
18          scrollbar-color: transparent;
19          scrollbar-width: none;
20        }
21        :host .noScrollbar::-webkit-scrollbar {
22          display: none;
23          -webkit-appearance: none;
24        }
25        :host .wrapper {
26          position: relative;
27          overflow: visible;
28          z-index: 2;
29        }
30        :host .canvases {
31          min-height: ${this.getHeight()}px;
32        }
33        :host .canvases > div {
34          position: relative;
35        }
36        :host canvas {
37          display: block;
38          position: absolute;
39          top: 0;
40          image-rendering: pixelated;
41        }
42        :host .progress {
43          pointer-events: none;
44          position: absolute;
45          z-index: 2;
46          top: 0;
47          left: 0;
48          width: 0;
49          height: 100%;
50          overflow: hidden;
51        }
52        :host .progress > div {
53          position: relative;
54        }
55        :host .cursor {
56          pointer-events: none;
57          position: absolute;
58          z-index: 5;
59          top: 0;
60          left: 0;
61          height: 100%;
62          border-radius: 2px;
63        }
64      </style>
65
66      <div class="scroll" part="scroll">
67        <div class="wrapper" part="wrapper">
68          <div class="canvases"></div>
69          <div class="progress" part="progress"></div>
70          <div class="cursor" part="cursor"></div>
71        </div>
72      </div>
73    `,[e,t]}setOptions(e){if(this.options.container!==e.container){const t=this.parentFromOptionsContainer(e.container);t.appendChild(this.container),this.parent=t}e.dragToSeek&&!this.options.dragToSeek&&this.initDrag(),this.options=e,this.reRender()}getWrapper(){return this.wrapper}getScroll(){return this.scrollContainer.scrollLeft}destroy(){var e;this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect()}createDelay(e=10){const t={};return this.timeouts.push(t),i=>{t.timeout&&clearTimeout(t.timeout),t.timeout=setTimeout(i,e)}}convertColorValues(e){if(!Array.isArray(e))return e||"";if(e.length<2)return e[0]||"";const t=document.createElement("canvas"),n=t.getContext("2d").createLinearGradient(0,0,0,t.height),r=1/(e.length-1);return e.forEach((o,u)=>{const a=u*r;n.addColorStop(a,o)}),n}renderBarWaveform(e,t,i,n){const r=e[0],o=e[1]||e[0],u=r.length,{width:a,height:d}=i.canvas,l=d/2,c=window.devicePixelRatio||1,h=t.barWidth?t.barWidth*c:1,m=t.barGap?t.barGap*c:t.barWidth?h/2:0,f=t.barRadius||0,g=a/(h+m)/u,p=f&&"roundRect"in i?"roundRect":"rect";i.beginPath();let C=0,k=0,E=0;for(let _=0;_<=u;_++){const w=Math.round(_*g);if(w>C){const z=Math.round(k*l*n),x=Math.round(E*l*n),J=z+x||1;let I=l-z;t.barAlign==="top"?I=0:t.barAlign==="bottom"&&(I=d-J),i[p](C*(h+m),I,h,J,f),C=w,k=0,E=0}const $=Math.abs(r[_]||0),S=Math.abs(o[_]||0);$>k&&(k=$),S>E&&(E=S)}i.fill(),i.closePath()}renderLineWaveform(e,t,i,n){const r=o=>{const u=e[o]||e[0],a=u.length,{height:d}=i.canvas,l=d/2,c=i.canvas.width/a;i.moveTo(0,l);let h=0,m=0;for(let f=0;f<=a;f++){const g=Math.round(f*c);if(g>h){const C=Math.round(m*l*n)||1,k=l+C*(o===0?-1:1);i.lineTo(h,k),h=g,m=0}const p=Math.abs(u[f]||0);p>m&&(m=p)}i.lineTo(h,l)};i.beginPath(),r(0),r(1),i.fill(),i.closePath()}renderWaveform(e,t,i){if(i.fillStyle=this.convertColorValues(t.waveColor),t.renderFunction){t.renderFunction(e,i);return}let n=t.barHeight||1;if(t.normalize){const r=Array.from(e[0]).reduce((o,u)=>Math.max(o,Math.abs(u)),0);n=r?1/r:1}if(t.barWidth||t.barGap||t.barAlign){this.renderBarWaveform(e,t,i,n);return}this.renderLineWaveform(e,t,i,n)}renderSingleCanvas(e,t,i,n,r,o,u,a){const d=window.devicePixelRatio||1,l=document.createElement("canvas"),c=e[0].length;l.width=Math.round(i*(o-r)/c),l.height=n*d,l.style.width=`${Math.floor(l.width/d)}px`,l.style.height=`${n}px`,l.style.left=`${Math.floor(r*i/d/c)}px`,u.appendChild(l);const h=l.getContext("2d");if(this.renderWaveform(e.map(m=>m.slice(r,o)),t,h),l.width>0&&l.height>0){const m=l.cloneNode(),f=m.getContext("2d");f.drawImage(l,0,0),f.globalCompositeOperation="source-in",f.fillStyle=this.convertColorValues(t.progressColor),f.fillRect(0,0,l.width,l.height),a.appendChild(m)}}renderChannel(e,t,i){const n=document.createElement("div"),r=this.getHeight();n.style.height=`${r}px`,this.canvasWrapper.style.minHeight=`${r}px`,this.canvasWrapper.appendChild(n);const o=n.cloneNode();this.progressWrapper.appendChild(o);const{scrollLeft:u,scrollWidth:a,clientWidth:d}=this.scrollContainer,l=e[0].length,c=l/a;let h=Math.min(qe.MAX_CANVAS_WIDTH,d);if(t.barWidth||t.barGap){const w=t.barWidth||.5,$=t.barGap||w/2,S=w+$;h%S!==0&&(h=Math.floor(h/S)*S)}const m=Math.floor(Math.abs(u)*c),f=Math.floor(m+h*c),g=f-m,p=(w,$)=>{this.renderSingleCanvas(e,t,i,r,Math.max(0,w),Math.min($,l),n,o)},C=this.createDelay(),k=this.createDelay(),E=(w,$)=>{p(w,$),w>0&&C(()=>{E(w-g,$-g)})},_=(w,$)=>{p(w,$),$<l&&k(()=>{_(w+g,$+g)})};E(m,f),f<l&&_(f,f+g)}
vendor: 30,957 bytes, lines 73-103
73render(e){this.timeouts.forEach(u=>u.timeout&&clearTimeout(u.timeout)),this.timeouts=[],this.canvasWrapper.innerHTML="",this.progressWrapper.innerHTML="",this.wrapper.style.width="",this.options.width!=null&&(this.scrollContainer.style.width=typeof this.options.width=="number"?`${this.options.width}px`:this.options.width);const t=window.devicePixelRatio||1,i=this.scrollContainer.clientWidth,n=Math.ceil(e.duration*(this.options.minPxPerSec||0));this.isScrolling=n>i;const r=this.options.fillParent&&!this.isScrolling,o=(r?i:n)*t;if(this.wrapper.style.width=r?"100%":`${n}px`,this.scrollContainer.style.overflowX=this.isScrolling?"auto":"hidden",this.scrollContainer.classList.toggle("noScrollbar",!!this.options.hideScrollbar),this.cursor.style.backgroundColor=`${this.options.cursorColor||this.options.progressColor}`,this.cursor.style.width=`${this.options.cursorWidth}px`,this.options.splitChannels)for(let u=0;u<e.numberOfChannels;u++){const a=Object.assign(Object.assign({},this.options),this.options.splitChannels[u]);this.renderChannel([e.getChannelData(u)],a,o)}else{const u=[e.getChannelData(0)];e.numberOfChannels>1&&u.push(e.getChannelData(1)),this.renderChannel(u,this.options,o)}this.audioData=e,this.emit("render")}reRender(){if(!this.audioData)return;const e=this.progressWrapper.clientWidth;this.render(this.audioData);const t=this.progressWrapper.clientWidth;this.scrollContainer.scrollLeft+=t-e}zoom(e){this.options.minPxPerSec=e,this.reRender()}scrollIntoView(e,t=!1){const{clientWidth:i,scrollLeft:n,scrollWidth:r}=this.scrollContainer,o=r*e,u=i/2,a=t&&this.options.autoCenter&&!this.isDragging?u:i;if(o>n+a||o<n)if(this.options.autoCenter&&!this.isDragging){const d=u/20;o-(n+u)>=d&&o<n+i?this.scrollContainer.scrollLeft+=d:this.scrollContainer.scrollLeft=o-u}else this.isDragging?this.scrollContainer.scrollLeft=o<n?o-10:o-i+10:this.scrollContainer.scrollLeft=o;{const{scrollLeft:d}=this.scrollContainer,l=d/r,c=(d+i)/r;this.emit("scroll",l,c)}}renderProgress(e,t){if(isNaN(e))return;const i=e*100;this.canvasWrapper.style.clipPath=`polygon(${i}% 0, 100% 0, 100% 100%, ${i}% 100%)`,this.progressWrapper.style.width=`${i}%`,this.cursor.style.left=`${i}%`,this.cursor.style.marginLeft=Math.round(i)===100?`-${this.options.cursorWidth}px`:"",this.isScrolling&&this.options.autoScroll&&this.scrollIntoView(e,t)}}qe.MAX_CANVAS_WIDTH=4e3;class Ui extends je{constructor(){super(...arguments),this.unsubscribe=()=>{}}start(){this.unsubscribe=this.on("tick",()=>{requestAnimationFrame(()=>{this.emit("tick")})}),this.emit("tick")}stop(){this.unsubscribe()}destroy(){this.unsubscribe()}}var Ye=function(s,e,t,i){function n(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function u(l){try{d(i.next(l))}catch(c){o(c)}}function a(l){try{d(i.throw(l))}catch(c){o(c)}}function d(l){l.done?r(l.value):n(l.value).then(u,a)}d((i=i.apply(s,e||[])).next())})};class xi extends je{constructor(e=new AudioContext){super(),this.bufferNode=null,this.autoplay=!1,this.playStartTime=0,this.playedDuration=0,this._muted=!1,this.buffer=null,this.currentSrc="",this.paused=!0,this.crossOrigin=null,this.audioContext=e,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return Ye(this,void 0,void 0,function*(){})}get src(){return this.currentSrc}set src(e){this.currentSrc=e,fetch(e).then(t=>t.arrayBuffer()).then(t=>this.audioContext.decodeAudioData(t)).then(t=>{this.buffer=t,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play()})}_play(){var e;this.paused&&(this.paused=!1,(e=this.bufferNode)===null||e===void 0||e.disconnect(),this.bufferNode=this.audioContext.createBufferSource(),this.bufferNode.buffer=this.buffer,this.bufferNode.connect(this.gainNode),this.playedDuration>=this.duration&&(this.playedDuration=0),this.bufferNode.start(this.audioContext.currentTime,this.playedDuration),this.playStartTime=this.audioContext.currentTime,this.bufferNode.onended=()=>{this.currentTime>=this.duration&&(this.pause(),this.emit("ended"))})}_pause(){var e;this.paused||(this.paused=!0,(e=this.bufferNode)===null||e===void 0||e.stop(),this.playedDuration+=this.audioContext.currentTime-this.playStartTime)}play(){return Ye(this,void 0,void 0,function*(){this._play(),this.emit("play")})}pause(){this._pause(),this.emit("pause")}setSinkId(e){return Ye(this,void 0,void 0,function*(){return this.audioContext.setSinkId(e)})}get playbackRate(){var e,t;return(t=(e=this.bufferNode)===null||e===void 0?void 0:e.playbackRate.value)!==null&&t!==void 0?t:1}set playbackRate(e){this.bufferNode&&(this.bufferNode.playbackRate.value=e)}get currentTime(){return this.paused?this.playedDuration:this.playedDuration+this.audioContext.currentTime-this.playStartTime}set currentTime(e){this.emit("seeking"),this.paused?this.playedDuration=e:(this._pause(),this.playedDuration=e,this._play()),this.emit("timeupdate")}get duration(){var e;return((e=this.buffer)===null||e===void 0?void 0:e.duration)||0}get volume(){return this.gainNode.gain.value}set volume(e){this.gainNode.gain.value=e,this.emit("volumechange")}get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this._muted?this.gainNode.disconnect():this.gainNode.connect(this.audioContext.destination))}getGainNode(){return this.gainNode}}var ve=function(s,e,t,i){function n(r){return r instanceof t?r:new t(function(o){o(r)})}return new(t||(t=Promise))(function(r,o){function u(l){try{d(i.next(l))}catch(c){o(c)}}function a(l){try{d(i.throw(l))}catch(c){o(c)}}function d(l){l.done?r(l.value):n(l.value).then(u,a)}d((i=i.apply(s,e||[])).next())})};const Fi={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class st extends Bi{static create(e){return new st(e)}constructor(e){const t=e.media||(e.backend==="WebAudio"?new xi:void 0);super({media:t,mediaControls:e.mediaControls,autoplay:e.autoplay,playbackRate:e.audioRate}),this.plugins=[],this.decodedData=null,this.subscriptions=[],this.mediaSubscriptions=[],this.options=Object.assign({},Fi,e),this.timer=new Ui;const i=t?void 0:this.getMediaElement();this.renderer=new qe(this.options,i),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initPlugins();const n=this.options.url||this.getSrc();n?this.load(n,this.options.peaks,this.options.duration):this.options.peaks&&this.options.duration&&this.loadPredecoded()}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",()=>{const e=this.getCurrentTime();this.renderer.renderProgress(e/this.getDuration(),!0),this.emit("timeupdate",e),this.emit("audioprocess",e)}))}initPlayerEvents(){this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",()=>{const e=this.getCurrentTime();this.renderer.renderProgress(e/this.getDuration(),this.isPlaying()),this.emit("timeupdate",e)}),this.onMediaEvent("play",()=>{this.emit("play"),this.timer.start()}),this.onMediaEvent("pause",()=>{this.emit("pause"),this.timer.stop()}),this.onMediaEvent("emptied",()=>{this.timer.stop()}),this.onMediaEvent("ended",()=>{this.emit("finish")}),this.onMediaEvent("seeking",()=>{this.emit("seeking",this.getCurrentTime())}))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",(e,t)=>{this.options.interact&&(this.seekTo(e),this.emit("interaction",e*this.getDuration()),this.emit("click",e,t))}),this.renderer.on("dblclick",(e,t)=>{this.emit("dblclick",e,t)}),this.renderer.on("scroll",(e,t)=>{const i=this.getDuration();this.emit("scroll",e*i,t*i)}),this.renderer.on("render",()=>{this.emit("redraw")}));{let e;this.subscriptions.push(this.renderer.on("drag",t=>{this.options.interact&&(this.renderer.renderProgress(t),clearTimeout(e),e=setTimeout(()=>{this.seekTo(t)},this.isPlaying()?0:200),this.emit("interaction",t*this.getDuration()),this.emit("drag",t))}))}}initPlugins(){var e;!((e=this.options.plugins)===null||e===void 0)&&e.length&&this.options.plugins.forEach(t=>{this.registerPlugin(t)})}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach(e=>e()),this.mediaSubscriptions=[]}setOptions(e){this.options=Object.assign({},this.options,e),this.renderer.setOptions(this.options),e.audioRate&&this.setPlaybackRate(e.audioRate),e.mediaControls!=null&&(this.getMediaElement().controls=e.mediaControls)}registerPlugin(e){return e.init(this),this.plugins.push(e),this.subscriptions.push(e.once("destroy",()=>{this.plugins=this.plugins.filter(t=>t!==e)})),e}getWrapper(){return this.renderer.getWrapper()}getScroll(){return this.renderer.getScroll()}getActivePlugins(){return this.plugins}loadPredecoded(){return ve(this,void 0,void 0,function*(){this.options.peaks&&this.options.duration&&(this.decodedData=Ze.createBuffer(this.options.peaks,this.options.duration),yield Promise.resolve(),this.renderDecoded())})}renderDecoded(){return ve(this,void 0,void 0,function*(){this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData))})}loadAudio(e,t,i,n){return ve(this,void 0,void 0,function*(){if(this.emit("load",e),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,!t&&!i){const r=o=>this.emit("loading",o);t=yield qi.fetchBlob(e,r,this.options.fetchParams)}if(this.setSrc(e,t),n=(yield Promise.resolve(n||this.getDuration()))||(yield new Promise(r=>{this.onceMediaEvent("loadedmetadata",()=>r(this.getDuration()))}))||(yield Promise.resolve(0)),i)this.decodedData=Ze.createBuffer(i,n);else if(t){const r=yield t.arrayBuffer();this.decodedData=yield Ze.decode(r,this.options.sampleRate)}this.renderDecoded(),this.emit("ready",this.getDuration())})}load(e,t,i){return ve(this,void 0,void 0,function*(){yield this.loadAudio(e,void 0,t,i)})}loadBlob(e,t,i){return ve(this,void 0,void 0,function*(){yield this.loadAudio("blob",e,t,i)})}zoom(e){if(!this.decodedData)throw new Error("No audio loaded");this.renderer.zoom(e),this.emit("zoom",e)}getDecodedData(){return this.decodedData}exportPeaks({channels:e=2,maxLength:t=8e3,precision:i=1e4}={}){if(!this.decodedData)throw new Error("The audio has not been decoded yet");const n=Math.min(e,this.decodedData.numberOfChannels),r=[];for(let o=0;o<n;o++){const u=this.decodedData.getChannelData(o),a=[],d=Math.round(u.length/t);for(let l=0;l<t;l++){const c=u.slice(l*d,(l+1)*d),h=Math.max(...c);a.push(Math.round(h*i)/i)}r.push(a)}return r}getDuration(){let e=super.getDuration()||0;return(e===0||e===1/0)&&this.decodedData&&(e=this.decodedData.duration),e}toggleInteraction(e){this.options.interact=e}seekTo(e){const t=this.getDuration()*e;this.setTime(t)}playPause(){return ve(this,void 0,void 0,function*(){return this.isPlaying()?this.pause():this.play()})}stop(){this.pause(),this.setTime(0)}skip(e){this.setTime(this.getCurrentTime()+e)}empty(){this.load("",[[0]],.001)}setMediaElement(e){this.unsubscribePlayerEvents(),super.setMediaElement(e),this.initPlayerEvents()}destroy(){this.emit("destroy"),this.plugins.forEach(e=>e.destroy()),this.subscriptions.forEach(e=>e()),this.unsubscribePlayerEvents(),this.timer.destroy(),this.renderer.destroy(),super.destroy()}}function Xi(s){const e=s.numberOfChannels,t=s.length*e*2+44,i=new ArrayBuffer(t),n=new DataView(i);let r=0;const o=function(u,a,d){for(let l=0;l<d.length;l++)u.setUint8(a+l,d.charCodeAt(l))};o(n,r,"RIFF"),r+=4,n.setUint32(r,t-8,!0),r+=4,o(n,r,"WAVE"),r+=4,o(n,r,"fmt "),r+=4,n.setUint32(r,16,!0),r+=4,n.setUint16(r,1,!0),r+=2,n.setUint16(r,e,!0),r+=2,n.setUint32(r,s.sampleRate,!0),r+=4,n.setUint32(r,s.sampleRate*2*e,!0),r+=4,n.setUint16(r,e*2,!0),r+=2,n.setUint16(r,16,!0),r+=2,o(n,r,"data"),r+=4,n.setUint32(r,s.length*e*2,!0),r+=4;for(let u=0;u<s.length;u++)for(let a=0;a<e;a++){const d=Math.max(-1,Math.min(1,s.getChannelData(a)[u]));n.setInt16(r,d*32767,!0),r+=2}return new Uint8Array(i)}const Gi=async(s,e,t,i)=>{const n=new AudioContext({sampleRate:i||s.sampleRate}),r=s.numberOfChannels,o=i||s.sampleRate;let u=s.length,a=0;e&&t&&(a=Math.round(e*o),u=Math.round(t*o)-a);const d=n.createBuffer(r,u,o);for(let l=0;l<r;l++){const c=s.getChannelData(l),h=d.getChannelData(l);for(let m=0;m<u;m++)h[m]=c[a+m]}return Xi(d)},pt=(s,e)=>{s&&s.skip(e)},ye=(s,e)=>(e||(e=5),s/100*e||5);class Ot{constructor(){this.listeners={},this.on=this.addEventListener,this.un=this.removeEventListener}addEventListener(e,t,i){if(this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(t),i?.once){const n=()=>{this.removeEventListener(e,n),this.removeEventListener(e,t)};return this.addEventListener(e,n),n}return()=>this.removeEventListener(e,t)}removeEventListener(e,t){var i;(i=this.listeners[e])===null||i===void 0||i.delete(t)}once(e,t){return this.on(e,t,{once:!0})}unAll(){this.listeners={}}emit(e,...t){this.listeners[e]&&this.listeners[e].forEach(i=>i(...t))}}class Zi extends Ot{constructor(e){super(),this.subscriptions=[],this.options=e}onInit(){}init(e){this.wavesurfer=e,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(e=>e())}}function Oe(s,e,t,i,n=5){let r=()=>{};if(!s)return r;const o=u=>{if(u.button===2)return;u.preventDefault(),u.stopPropagation(),s.style.touchAction="none";let a=u.clientX,d=u.clientY,l=!1;const c=f=>{f.preventDefault(),f.stopPropagation();const g=f.clientX,p=f.clientY;if(l||Math.abs(g-a)>=n||Math.abs(p-d)>=n){const{left:C,top:k}=s.getBoundingClientRect();l||(l=!0,t?.(a-C,d-k)),e(g-a,p-d,g-C,p-k),a=g,d=p}},h=f=>{l&&(f.preventDefault(),f.stopPropagation())},m=()=>{s.style.touchAction="",l&&i?.(),r()};document.addEventListener("pointermove",c),document.addEventListener("pointerup",m),document.addEventListener("pointerleave",m),document.addEventListener("click",h,!0),r=()=>{document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",m),document.removeEventListener("pointerleave",m),setTimeout(()=>{document.removeEventListener("click",h,!0)},10)}};return s.addEventListener("pointerdown",o),()=>{r(),s.removeEventListener("pointerdown",o)}}class gt extends Ot{constructor(e,t,i=0){var n,r,o,u,a,d,l;super(),this.totalDuration=t,this.numberOfChannels=i,this.minLength=0,this.maxLength=1/0,this.id=e.id||`region-${Math.random().toString(32).slice(2)}`,this.start=this.clampPosition(e.start),this.end=this.clampPosition((n=e.end)!==null&&n!==void 0?n:e.start),this.drag=(r=e.drag)===null||r===void 0||r,this.resize=(o=e.resize)===null||o===void 0||o,this.color=(u=e.color)!==null&&u!==void 0?u:"rgba(0, 0, 0, 0.1)",this.minLength=(a=e.minLength)!==null&&a!==void 0?a:this.minLength,this.maxLength=(d=e.maxLength)!==null&&d!==void 0?d:this.maxLength,this.channelIdx=(l=e.channelIdx)!==null&&l!==void 0?l:-1,this.element=this.initElement(),this.setContent(e.content),this.setPart(),this.renderPosition(),this.initMouseEvents()}clampPosition(e){return Math.max(0,Math.min(this.totalDuration,e))}setPart(){const e=this.start===this.end;this.element.setAttribute("part",`${e?"marker":"region"} ${this.id}`)}addResizeHandles(e){const t=document.createElement("div");t.setAttribute("data-resize","left"),t.setAttribute("style",`
74        position: absolute;
75        z-index: 2;
76        width: 6px;
77        height: 100%;
78        top: 0;
79        left: 0;
80        border-left: 2px solid rgba(0, 0, 0, 0.5);
81        border-radius: 2px 0 0 2px;
82        cursor: ew-resize;
83        word-break: keep-all;
84      `),t.setAttribute("part","region-handle region-handle-left");const i=t.cloneNode();i.setAttribute("data-resize","right"),i.style.left="",i.style.right="0",i.style.borderRight=i.style.borderLeft,i.style.borderLeft="",i.style.borderRadius="0 2px 2px 0",i.setAttribute("part","region-handle region-handle-right"),e.appendChild(t),e.appendChild(i),Oe(t,n=>this.onResize(n,"start"),()=>null,()=>this.onEndResizing(),1),Oe(i,n=>this.onResize(n,"end"),()=>null,()=>this.onEndResizing(),1)}removeResizeHandles(e){const t=e.querySelector('[data-resize="left"]'),i=e.querySelector('[data-resize="right"]');t&&e.removeChild(t),i&&e.removeChild(i)}initElement(){const e=document.createElement("div"),t=this.start===this.end;let i=0,n=100;return this.channelIdx>=0&&this.channelIdx<this.numberOfChannels&&(n=100/this.numberOfChannels,i=n*this.channelIdx),e.setAttribute("style",`
85      position: absolute;
86      top: ${i}%;
87      height: ${n}%;
88      background-color: ${t?"none":this.color};
89      border-left: ${t?"2px solid "+this.color:"none"};
90      border-radius: 2px;
91      box-sizing: border-box;
92      transition: background-color 0.2s ease;
93      cursor: ${this.drag?"grab":"default"};
94      pointer-events: all;
95    `),!t&&this.resize&&this.addResizeHandles(e),e}renderPosition(){const e=this.start/this.totalDuration,t=(this.totalDuration-this.end)/this.totalDuration;this.element.style.left=100*e+"%",this.element.style.right=100*t+"%"}initMouseEvents(){const{element:e}=this;e&&(e.addEventListener("click",t=>this.emit("click",t)),e.addEventListener("mouseenter",t=>this.emit("over",t)),e.addEventListener("mouseleave",t=>this.emit("leave",t)),e.addEventListener("dblclick",t=>this.emit("dblclick",t)),Oe(e,t=>this.onMove(t),()=>this.onStartMoving(),()=>this.onEndMoving()))}onStartMoving(){this.drag&&(this.element.style.cursor="grabbing")}onEndMoving(){this.drag&&(this.element.style.cursor="grab",this.emit("update-end"))}_onUpdate(e,t){if(!this.element.parentElement)return;const i=e/this.element.parentElement.clientWidth*this.totalDuration,n=t&&t!=="start"?this.start:this.start+i,r=t&&t!=="end"?this.end:this.end+i,o=r-n;n>=0&&r<=this.totalDuration&&n<=r&&o>=this.minLength&&o<=this.maxLength&&(this.start=n,this.end=r,this.renderPosition(),this.emit("update"))}onMove(e){this.drag&&this._onUpdate(e)}onResize(e,t){this.resize&&this._onUpdate(e,t)}onEndResizing(){this.resize&&this.emit("update-end")}_setTotalDuration(e){this.totalDuration=e,this.renderPosition()}play(){this.emit("play")}setContent(e){var t;if((t=this.content)===null||t===void 0||t.remove(),e){if(typeof e=="string"){this.content=document.createElement("div");const i=this.start===this.end;this.content.style.padding=`0.2em ${i?.2:.4}em`,this.content.textContent=e}else this.content=e;this.content.setAttribute("part","region-content"),this.element.appendChild(this.content)}else this.content=void 0}setOptions(e){var t,i;if(e.color&&(this.color=e.color,this.element.style.backgroundColor=this.color),e.drag!==void 0&&(this.drag=e.drag,this.element.style.cursor=this.drag?"grab":"default"),e.start!==void 0||e.end!==void 0){const n=this.start===this.end;this.start=this.clampPosition((t=e.start)!==null&&t!==void 0?t:this.start),this.end=this.clampPosition((i=e.end)!==null&&i!==void 0?i:n?this.start:this.end),this.renderPosition(),this.setPart()}if(e.content&&this.setContent(e.content),e.id&&(this.id=e.id,this.setPart()),e.resize!==void 0&&e.resize!==this.resize){const n=this.start===this.end;this.resize=e.resize,this.resize&&!n?this.addResizeHandles(this.element):this.removeResizeHandles(this.element)}}remove(){this.emit("remove"),this.element.remove(),this.element=null}}class rt extends Zi{constructor(e){super(e),this.regions=[],this.regionsContainer=this.initRegionsContainer()}static create(e){return new rt(e)}onInit(){if(!this.wavesurfer)throw Error("WaveSurfer is not initialized");this.wavesurfer.getWrapper().appendChild(this.regionsContainer);let e=[];this.subscriptions.push(this.wavesurfer.on("timeupdate",t=>{const i=this.regions.filter(n=>n.start<=t&&n.end>=t);i.forEach(n=>{e.includes(n)||this.emit("region-in",n)}),e.forEach(n=>{i.includes(n)||this.emit("region-out",n)}),e=i}))}initRegionsContainer(){const e=document.createElement("div");return e.setAttribute("style",`
96      position: absolute;
97      top: 0;
98      left: 0;
99      width: 100%;
100      height: 100%;
101      z-index: 3;
102      pointer-events: none;
103    `),e}getRegions(){return this.regions}avoidOverlapping(e){if(!e.content)return;const t=e.content,i=t.getBoundingClientRect().left,n=e.element.scrollWidth,r=this.regions.filter(o=>{if(o===e||!o.content)return!1;const u=o.content.getBoundingClientRect().left,a=o.element.scrollWidth;return i<u+a&&u<i+n}).map(o=>{var u;return((u=o.content)===null||u===void 0?void 0:u.getBoundingClientRect().height)||0}).reduce((o,u)=>o+u,0);t.style.marginTop=`${r}px`}saveRegion(e){this.regionsContainer.appendChild(e.element),this.avoidOverlapping(e),this.regions.push(e);const t=[e.on("update-end",()=>{this.avoidOverlapping(e),this.emit("region-updated",e)}),e.on("play",()=>{var i,n;(i=this.wavesurfer)===null||i===void 0||i.play(),(n=this.wavesurfer)===null||n===void 0||n.setTime(e.start)}),e.on("click",i=>{this.emit("region-clicked",e,i)}),e.on("dblclick",i=>{this.emit("region-double-clicked",e,i)}),e.once("remove",()=>{t.forEach(i=>i()),this.regions=this.regions.filter(i=>i!==e)})];this.subscriptions.push(...t),this.emit("region-created",e)}addRegion(e){var t,i;if(!this.wavesurfer)throw Error("WaveSurfer is not initialized");const n=this.wavesurfer.getDuration(),r=(i=(t=this.wavesurfer)===null||t===void 0?void 0:t.getDecodedData())===null||i===void 0?void 0:i.numberOfChannels,o=new gt(e,n,r);return n?this.saveRegion(o):this.subscriptions.push(this.wavesurfer.once("ready",u=>{o._setTotalDuration(u),this.saveRegion(o)})),o}enableDragSelection(e){var t,i;const n=(i=(t=this.wavesurfer)===null||t===void 0?void 0:t.getWrapper())===null||i===void 0?void 0:i.querySelector("div");if(!n)return()=>{};let r=null,o=0;return Oe(n,(u,a,d)=>{r&&r._onUpdate(u,d>o?"end":"start")},u=>{var a,d;if(o=u,!this.wavesurfer)return;const l=this.wavesurfer.getDuration(),c=(d=(a=this.wavesurfer)===null||a===void 0?void 0:a.getDecodedData())===null||d===void 0?void 0:d.numberOfChannels,h=this.wavesurfer.getWrapper().clientWidth,m=u/h*l,f=(u+5)/h*l;r=new gt(Object.assign(Object.assign({},e),{start:m,end:f}),l,c),this.regionsContainer.appendChild(r.element)},()=>{r&&(this.saveRegion(r),r=null)})}clearRegions(){this.regions.forEach(e=>e.remove())}destroy(){this.clearRegions(),super.destroy()}}const{SvelteComponent:Yi,check_outros:Ji,create_component:ot,destroy_component:lt,detach:Ki,empty:Qi,flush:en,group_outros:tn,init:nn,insert:sn,mount_component:at,safe_not_equal:rn,transition_in:Re,transition_out:Pe}=window.__gradio__svelte__internal;function on(s){let e,t;return e=new Li({}),{c(){ot(e.$$.fragment)},m(i,n){at(e,i,n),t=!0},i(i){t||(Re(e.$$.fragment,i),t=!0)},o(i){Pe(e.$$.fragment,i),t=!1},d(i){lt(e,i)}}}function ln(s){let e,t;return e=new bi({}),{c(){ot(e.$$.fragment)},m(i,n){at(e,i,n),t=!0},i(i){t||(Re(e.$$.fragment,i),t=!0)},o(i){Pe(e.$$.fragment,i),t=!1},d(i){lt(e,i)}}}function an(s){let e,t;return e=new zi({}),{c(){ot(e.$$.fragment)},m(i,n){at(e,i,n),t=!0},i(i){t||(Re(e.$$.fragment,i),t=!0)},o(i){Pe(e.$$.fragment,i),t=!1},d(i){lt(e,i)}}}function un(s){let e,t,i,n;const r=[an,ln,on],o=[];function u(a,d){return a[0]==0?0:a[0]<.5?1:a[0]>=.5?2:-1}return~(e=u(s))&&(t=o[e]=r[e](s)),{c(){t&&t.c(),i=Qi()},m(a,d){~e&&o[e].m(a,d),sn(a,i,d),n=!0},p(a,[d]){let l=e;e=u(a),e!==l&&(t&&(tn(),Pe(o[l],1,1,()=>{o[l]=null}),Ji()),~e?(t=o[e],t||(t=o[e]=r[e](a),t.c()),Re(t,1),t.m(i.parentNode,i)):t=null)},i(a){n||(Re(t),n=!0)},o(a){Pe(t),n=!1},d(a){a&&Ki(i),~e&&o[e].d(a)}}}function dn(s,e,t){let{currentVolume:i}=e;return s.$$set=n=>{"currentVolume"in n&&t(0,i=n.currentVolume)},[i]}class cn extends Yi{constructor(e){super(),nn(this,e,dn,un,rn,{currentVolume:0})}get currentVolume(){return this.$$.ctx[0]}set currentVolume(e){this.$$set({currentVolume:e}),en()}}const{SvelteComponent:hn,attr:be,binding_callbacks:fn,detach:mn,element:_n,flush:Je,init:pn,insert:gn,listen:vt,noop:bt,run_all:vn,safe_not_equal:bn}=window.__gradio__svelte__internal,{onMount:wn}=window.__gradio__svelte__internal;function yn(s){let e,t,i;return{c(){e=_n("input"),be(e,"id","volume"),be(e,"class","volume-slider svelte-wuo8j5"),be(e,"type","range"),be(e,"min","0"),be(e,"max","1"),be(e,"step","0.01"),e.value=s[0]},m(n,r){gn(n,e,r),s[4](e),t||(i=[vt(e,"focusout",s[5]),vt(e,"input",s[6])],t=!0)},p(n,[r]){r&1&&(e.value=n[0])},i:bt,o:bt,d(n){n&&mn(e),s[4](null),t=!1,vn(i)}}}function kn(s,e,t){let{currentVolume:i=1}=e,{show_volume_slider:n=!1}=e,{waveform:r}=e,o;wn(()=>{u()});const u=()=>{let c=o;c&&(c.style.background=`linear-gradient(to right, var(--color-accent) ${i*100}%, var(--neutral-400) ${i*100}%)`)};function a(c){fn[c?"unshift":"push"](()=>{o=c,t(3,o)})}const d=()=>t(1,n=!1),l=c=>{c.target instanceof HTMLInputElement&&(t(0,i=parseFloat(c.target.value)),r.setVolume(i))};return s.$$set=c=>{"currentVolume"in c&&t(0,i=c.currentVolume),"show_volume_slider"in c&&t(1,n=c.show_volume_slider),"waveform"in c&&t(2,r=c.waveform)},s.$$.update=()=>{s.$$.dirty&1&&u()},[i,n,r,o,a,d,l]}class Cn extends hn{constructor(e){super(),pn(this,e,kn,yn,bn,{currentVolume:0,show_volume_slider:1,waveform:2})}get currentVolume(){return this.$$.ctx[0]}set currentVolume(e){this.$$set({currentVolume:e}),Je()}get show_volume_slider(){return this.$$.ctx[1]}set show_volume_slider(e){this.$$set({show_volume_slider:e}),Je()}get waveform(){return this.$$.ctx[2]}set waveform(e){this.$$set({waveform:e}),Je()}}const{SvelteComponent:En,add_flush_callback:wt,append:O,attr:M,bind:yt,binding_callbacks:kt,check_outros:Le,create_component:se,destroy_component:re,detach:oe,element:B,empty:$n,flush:N,group_outros:Me,init:Sn,insert:le,listen:ee,mount_component:ae,noop:De,run_all:Ht,safe_not_equal:Ln,set_data:Mn,set_style:Ct,space:ne,text:Et,toggle_class:$t,transition_in:R,transition_out:W}=window.__gradio__svelte__internal;function St(s){let e,t,i,n;function r(a){s[27](a)}function o(a){s[28](a)}let u={waveform:s[2]};return s[12]!==void 0&&(u.currentVolume=s[12]),s[1]!==void 0&&(u.show_volume_slider=s[1]),e=new Cn({props:u}),kt.push(()=>yt(e,"currentVolume",r)),kt.push(()=>yt(e,"show_volume_slider",o)),{c(){se(e.$$.fragment)},m(a,d){ae(e,a,d),n=!0},p(a,d){const l={};d[0]&4&&(l.waveform=a[2]),!t&&d[0]&4096&&(t=!0,l.currentVolume=a[12],wt(()=>t=!1)),!i&&d[0]&2&&(i=!0,l.show_volume_slider=a[1],wt(()=>i=!1)),e.$set(l)},i(a){n||(R(e.$$.fragment,a),n=!0)},o(a){W(e.$$.fragment,a),n=!1},d(a){re(e,a)}}}function Dn(s){let e,t;return e=new xt({}),{c(){se(e.$$.fragment)},m(i,n){ae(e,i,n),t=!0},i(i){t||(R(e.$$.fragment,i),t=!0)},o(i){W(e.$$.fragment,i),t=!1},d(i){re(e,i)}}}function Rn(s){let e,t;return e=new Ft({}),{c(){se(e.$$.fragment)},m(i,n){ae(e,i,n),t=!0},i(i){t||(R(e.$$.fragment,i),t=!0)},o(i){W(e.$$.fragment,i),t=!1},d(i){re(e,i)}}}function Lt(s){let e,t,i,n,r,o=s[6]&&s[0]===""&&Mt(s);const u=[Tn,Pn],a=[];function d(l,c){return l[0]===""?0:1}return t=d(s),i=a[t]=u[t](s),{c(){o&&o.c(),e=ne(),i.c(),n=$n()},m(l,c){o&&o.m(l,c),le(l,e,c),a[t].m(l,c),le(l,n,c),r=!0},p(l,c){l[6]&&l[0]===""?o?(o.p(l,c),c[0]&65&&R(o,1)):(o=Mt(l),o.c(),R(o,1),o.m(e.parentNode,e)):o&&(Me(),W(o,1,1,()=>{o=null}),Le());let h=t;t=d(l),t===h?a[t].p(l,c):(Me(),W(a[h],1,1,()=>{a[h]=null}),Le(),i=a[t],i?i.p(l,c):(i=a[t]=u[t](l),i.c()),R(i,1),i.m(n.parentNode,n))},i(l){r||(R(o),R(i),r=!0)},o(l){W(o),W(i),r=!1},d(l){l&&(oe(e),oe(n)),o&&o.d(l),a[t].d(l)}}}function Mt(s){let e,t,i,n,r;return t=new Gt({}),{c(){e=B("button"),se(t.$$.fragment),M(e,"class","action icon svelte-ije4bl"),M(e,"aria-label","Reset audio")},m(o,u){le(o,e,u),ae(t,e,null),i=!0,n||(r=ee(e,"click",s[33]),n=!0)},p:De,i(o){i||(R(t.$$.fragment,o),i=!0)},o(o){W(t.$$.fragment,o),i=!1},d(o){o&&oe(e),re(t),n=!1,r()}}}function Pn(s){let e,t,i,n,r;return{c(){e=B("button"),e.textContent="Trim",t=ne(),i=B("button"),i.textContent="Cancel",M(e,"class","text-button svelte-ije4bl"),M(i,"class","text-button svelte-ije4bl")},m(o,u){le(o,e,u),le(o,t,u),le(o,i,u),n||(r=[ee(e,"click",s[14]),ee(i,"click",s[16])],n=!0)},p:De,i:De,o:De,d(o){o&&(oe(e),oe(t),oe(i)),n=!1,Ht(r)}}}function Tn(s){let e,t,i,n,r;return t=new Xt({}),{c(){e=B("button"),se(t.$$.fragment),M(e,"class","action icon svelte-ije4bl"),M(e,"aria-label","Trim audio to selection")},m(o,u){le(o,e,u),ae(t,e,null),i=!0,n||(r=ee(e,"click",s[16]),n=!0)},p:De,i(o){i||(R(t.$$.fragment,o),i=!0)},o(o){W(t.$$.fragment,o),i=!1},d(o){o&&oe(e),re(t),n=!1,r()}}}function An(s){let e,t,i,n,r,o,u,a,d,l,c,h,m,f,g,p,C,k,E,_,w,$,S,z,x,J,I,H,de,ce;n=new cn({props:{currentVolume:s[12]}});let D=s[1]&&St(s);g=new ni({});const pe=[Rn,Dn],G=[];function v(y,P){return y[5]?0:1}E=v(s),_=G[E]=pe[E](s),z=new ci({});let L=s[10]&&s[7]&&Lt(s);return{c(){e=B("div"),t=B("div"),i=B("button"),se(n.$$.fragment),r=ne(),D&&D.c(),o=ne(),u=B("button"),a=B("span"),d=Et(s[11]),l=Et("x"),h=ne(),m=B("div"),f=B("button"),se(g.$$.fragment),C=ne(),k=B("button"),_.c(),$=ne(),S=B("button"),se(z.$$.fragment),J=ne(),I=B("div"),L&&L.c(),M(i,"class","action icon volume svelte-ije4bl"),M(i,"aria-label","Adjust volume"),Ct(i,"color",s[1]?"var(--color-accent)":"var(--neutral-400)"),M(u,"class","playback icon svelte-ije4bl"),M(u,"aria-label",c=`Adjust playback speed to ${s[13][(s[13].indexOf(s[11])+1)%s[13].length]}x`),$t(u,"hidden",s[1]),M(t,"class","control-wrapper svelte-ije4bl"),M(f,"class","rewind icon svelte-ije4bl"),M(f,"aria-label",p=`Skip backwards by ${ye(s[3],s[9].skip_length)} seconds`),M(k,"class","play-pause-button icon svelte-ije4bl"),M(k,"aria-label",w=s[5]?s[4]("audio.pause"):s[4]("audio.play")),M(S,"class","skip icon svelte-ije4bl"),M(S,"aria-label",x="Skip forward by "+ye(s[3],s[9].skip_length)+" seconds"),M(m,"class","play-pause-wrapper svelte-ije4bl"),M(I,"class","settings-wrapper svelte-ije4bl"),M(e,"class","controls svelte-ije4bl"),M(e,"data-testid","waveform-controls")},m(y,P){le(y,e,P),O(e,t),O(t,i),ae(n,i,null),O(t,r),D&&D.m(t,null),O(t,o),O(t,u),O(u,a),O(a,d),O(a,l),O(e,h),O(e,m),O(m,f),ae(g,f,null),O(m,C),O(m,k),G[E].m(k,null),O(m,$),O(m,S),ae(z,S,null),O(e,J),O(e,I),L&&L.m(I,null),H=!0,de||(ce=[ee(i,"click",s[26]),ee(u,"click",s[29]),ee(f,"click",s[30]),ee(k,"click",s[31]),ee(S,"click",s[32])],de=!0)},p(y,P){const Te={};P[0]&4096&&(Te.currentVolume=y[12]),n.$set(Te),P[0]&2&&Ct(i,"color",y[1]?"var(--color-accent)":"var(--neutral-400)"),y[1]?D?(D.p(y,P),P[0]&2&&R(D,1)):(D=St(y),D.c(),R(D,1),D.m(t,o)):D&&(Me(),W(D,1,1,()=>{D=null}),Le()),(!H||P[0]&2048)&&Mn(d,y[11]),(!H||P[0]&2048&&c!==(c=`Adjust playback speed to ${y[13][(y[13].indexOf(y[11])+1)%y[13].length]}x`))&&M(u,"aria-label",c),(!H||P[0]&2)&&$t(u,"hidden",y[1]),(!H||P[0]&520&&p!==(p=`Skip backwards by ${ye(y[3],y[9].skip_length)} seconds`))&&M(f,"aria-label",p);let b=E;E=v(y),E!==b&&(Me(),W(G[b],1,1,()=>{G[b]=null}),Le(),_=G[E],_||(_=G[E]=pe[E](y),_.c()),R(_,1),_.m(k,null)),(!H||P[0]&48&&w!==(w=y[5]?y[4]("audio.pause"):y[4]("audio.play")))&&M(k,"aria-label",w),(!H||P[0]&520&&x!==(x="Skip forward by "+ye(y[3],y[9].skip_length)+" seconds"))&&M(S,"aria-label",x),y[10]&&y[7]?L?(L.p(y,P),P[0]&1152&&R(L,1)):(L=Lt(y),L.c(),R(L,1),L.m(I,null)):L&&(Me(),W(L,1,1,()=>{L=null}),Le())},i(y){H||(R(n.$$.fragment,y),R(D),R(g.$$.fragment,y),R(_),R(z.$$.fragment,y),R(L),H=!0)},o(y){W(n.$$.fragment,y),W(D),W(g.$$.fragment,y),W(_),W(z.$$.fragment,y),W(L),H=!1},d(y){y&&oe(e),re(n),D&&D.d(),re(g),G[E].d(),re(z),L&&L.d(),de=!1,Ht(ce)}}}function Wn(s,e,t){let{waveform:i}=e,{audio_duration:n}=e,{i18n:r}=e,{playing:o}
103=e,{show_redo:u=!1}=e,{interactive:a=!1}=e,{handle_trim_audio:d}=e,{mode:l=""}=e,{container:c}=e,{handle_reset_value:h}=e,{waveform_options:m={}}=e,{trim_region_settings:f={}}=e,{show_volume_slider:g=!1}=e,{editable:p=!0}=e,{trimDuration:C=0}=e,k=[.5,1,1.5,2],E=k[1],_,w=null,$,S,z="",x=1;const J=()=>{t(22,w=_.addRegion({start:n/4,end:n/2,...f})),t(17,C=w.end-w.start)},I=()=>{if(i&&_&&w){const b=w.start,ge=w.end;d(b,ge),t(0,l=""),t(22,w=null)}},H=()=>{_?.getRegions().forEach(b=>{b.remove()}),_?.clearRegions()},de=()=>{H(),l==="edit"?t(0,l=""):(t(0,l="edit"),J())},ce=(b,ge)=>{let Ce,Ee;w&&(b==="left"?ge==="ArrowLeft"?(Ce=w.start-.05,Ee=w.end):(Ce=w.start+.05,Ee=w.end):ge==="ArrowLeft"?(Ce=w.start,Ee=w.end-.05):(Ce=w.start,Ee=w.end+.05),w.setOptions({start:Ce,end:Ee}),t(17,C=w.end-w.start))},D=()=>t(1,g=!g);function pe(b){x=b,t(12,x)}function G(b){g=b,t(1,g)}const v=()=>{t(11,E=k[(k.indexOf(E)+1)%k.length]),i.setPlaybackRate(E)},L=()=>i.skip(ye(n,m.skip_length)*-1),y=()=>i.playPause(),P=()=>i.skip(ye(n,m.skip_length)),Te=()=>{h(),H(),t(0,l="")};return s.$$set=b=>{"waveform"in b&&t(2,i=b.waveform),"audio_duration"in b&&t(3,n=b.audio_duration),"i18n"in b&&t(4,r=b.i18n),"playing"in b&&t(5,o=b.playing),"show_redo"in b&&t(6,u=b.show_redo),"interactive"in b&&t(7,a=b.interactive),"handle_trim_audio"in b&&t(18,d=b.handle_trim_audio),"mode"in b&&t(0,l=b.mode),"container"in b&&t(19,c=b.container),"handle_reset_value"in b&&t(8,h=b.handle_reset_value),"waveform_options"in b&&t(9,m=b.waveform_options),"trim_region_settings"in b&&t(20,f=b.trim_region_settings),"show_volume_slider"in b&&t(1,g=b.show_volume_slider),"editable"in b&&t(10,p=b.editable),"trimDuration"in b&&t(17,C=b.trimDuration)},s.$$.update=()=>{if(s.$$.dirty[0]&4&&t(21,_=i.registerPlugin(rt.create())),s.$$.dirty[0]&2097152&&_?.on("region-out",b=>{b.play()}),s.$$.dirty[0]&2097152&&_?.on("region-updated",b=>{t(17,C=b.end-b.start)}),s.$$.dirty[0]&2097152&&_?.on("region-clicked",(b,ge)=>{ge.stopPropagation(),t(22,w=b),b.play()}),s.$$.dirty[0]&31981568&&w){const b=c.children[0].shadowRoot;t(24,S=b.querySelector('[data-resize="right"]')),t(23,$=b.querySelector('[data-resize="left"]')),$&&S&&($.setAttribute("role","button"),S.setAttribute("role","button"),$?.setAttribute("aria-label","Drag to adjust start time"),S?.setAttribute("aria-label","Drag to adjust end time"),$?.setAttribute("tabindex","0"),S?.setAttribute("tabindex","0"),$.addEventListener("focus",()=>{_&&t(25,z="left")}),S.addEventListener("focus",()=>{_&&t(25,z="right")}))}s.$$.dirty[0]&35651584&&_&&window.addEventListener("keydown",b=>{b.key==="ArrowLeft"?ce(z,"ArrowLeft"):b.key==="ArrowRight"&&ce(z,"ArrowRight")})},[l,g,i,n,r,o,u,a,h,m,p,E,x,k,I,H,de,C,d,c,f,_,w,$,S,z,D,pe,G,v,L,y,P,Te]}class zn extends En{constructor(e){super(),Sn(this,e,Wn,An,Ln,{waveform:2,audio_duration:3,i18n:4,playing:5,show_redo:6,interactive:7,handle_trim_audio:18,mode:0,container:19,handle_reset_value:8,waveform_options:9,trim_region_settings:20,show_volume_slider:1,editable:10,trimDuration:17},null,[-1,-1])}get waveform(){return this.$$.ctx[2]}set waveform(e){this.$$set({waveform:e}),N()}get audio_duration(){return this.$$.ctx[3]}set audio_duration(e){this.$$set({audio_duration:e}),N()}get i18n(){return this.$$.ctx[4]}set i18n(e){this.$$set({i18n:e}),N()}get playing(){return this.$$.ctx[5]}set playing(e){this.$$set({playing:e}),N()}get show_redo(){return this.$$.ctx[6]}set show_redo(e){this.$$set({show_redo:e}),N()}get interactive(){return this.$$.ctx[7]}set interactive(e){this.$$set({interactive:e}),N()}get handle_trim_audio(){return this.$$.ctx[18]}set handle_trim_audio(e){this.$$set({handle_trim_audio:e}),N()}get mode(){return this.$$.ctx[0]}set mode(e){this.$$set({mode:e}),N()}get container(){return this.$$.ctx[19]}set container(e){this.$$set({container:e}),N()}get handle_reset_value(){return this.$$.ctx[8]}set handle_reset_value(e){this.$$set({handle_reset_value:e}),N()}get waveform_options(){return this.$$.ctx[9]}set waveform_options(e){this.$$set({waveform_options:e}),N()}get trim_region_settings(){return this.$$.ctx[20]}set trim_region_settings(e){this.$$set({trim_region_settings:e}),N()}get show_volume_slider(){return this.$$.ctx[1]}set show_volume_slider(e){this.$$set({show_volume_slider:e}),N()}get editable(){return this.$$.ctx[10]}set editable(e){this.$$set({editable:e}),N()}get trimDuration(){return this.$$.ctx[17]}set trimDuration(e){this.$$set({trimDuration:e}),N()}}const{SvelteComponent:On,add_flush_callback:Ke,append:Y,attr:V,bind:Qe,binding_callbacks:ke,bubble:Hn,check_outros:Vt,create_component:ut,destroy_component:dt,detach:Be,element:Q,empty:Vn,flush:Z,group_outros:Nt,init:Nn,insert:Ie,listen:jn,mount_component:ct,
103noop:Dt,safe_not_equal:qn,set_data:Bn,space:ze,src_url_equal:Rt,text:In,transition_in:ue,transition_out:he}=window.__gradio__svelte__internal,{onMount:Un}=window.__gradio__svelte__internal,{createEventDispatcher:xn}=window.__gradio__svelte__internal;function Fn(s){let e,t,i,n,r,o,u,a,d,l,c,h,m,f=s[0]==="edit"&&s[16]>0&&Pt(s),g=s[11]&&Tt(s);return{c(){e=Q("div"),t=Q("div"),i=Q("div"),n=ze(),r=Q("div"),o=Q("time"),o.textContent="0:00",u=ze(),a=Q("div"),f&&f.c(),d=ze(),l=Q("time"),l.textContent="0:00",c=ze(),g&&g.c(),V(i,"id","waveform"),V(i,"class","svelte-1ark3ru"),V(t,"class","waveform-container svelte-1ark3ru"),V(o,"id","time"),V(o,"class","svelte-1ark3ru"),V(l,"id","duration"),V(l,"class","svelte-1ark3ru"),V(r,"class","timestamps svelte-1ark3ru"),V(e,"class","component-wrapper svelte-1ark3ru"),V(e,"data-testid",h=s[2]?"waveform-"+s[2]:"unlabelled-audio")},m(p,C){Ie(p,e,C),Y(e,t),Y(t,i),s[22](i),Y(e,n),Y(e,r),Y(r,o),s[23](o),Y(r,u),Y(r,a),f&&f.m(a,null),Y(a,d),Y(a,l),s[24](l),Y(e,c),g&&g.m(e,null),m=!0},p(p,C){p[0]==="edit"&&p[16]>0?f?f.p(p,C):(f=Pt(p),f.c(),f.m(a,d)):f&&(f.d(1),f=null),p[11]?g?(g.p(p,C),C[0]&2048&&ue(g,1)):(g=Tt(p),g.c(),ue(g,1),g.m(e,null)):g&&(Nt(),he(g,1,1,()=>{g=null}),Vt()),(!m||C[0]&4&&h!==(h=p[2]?"waveform-"+p[2]:"unlabelled-audio"))&&V(e,"data-testid",h)},i(p){m||(ue(g),m=!0)},o(p){he(g),m=!1},d(p){p&&Be(e),s[22](null),s[23](null),f&&f.d(),s[24](null),g&&g.d()}}}function Xn(s){let e,t,i,n,r;return{c(){e=Q("audio"),V(e,"class","standard-player svelte-1ark3ru"),Rt(e.src,t=s[1].url)||V(e,"src",t),e.controls=!0,e.autoplay=i=s[7].autoplay},m(o,u){Ie(o,e,u),n||(r=jn(e,"load",s[21]),n=!0)},p(o,u){u[0]&2&&!Rt(e.src,t=o[1].url)&&V(e,"src",t),u[0]&128&&i!==(i=o[7].autoplay)&&(e.autoplay=i)},i:Dt,o:Dt,d(o){o&&Be(e),n=!1,r()}}}function Gn(s){let e,t;return e=new zt({props:{size:"small",$$slots:{default:[Zn]},$$scope:{ctx:s}}}),{c(){ut(e.$$.fragment)},m(i,n){ct(e,i,n),t=!0},p(i,n){const r={};n[1]&1&&(r.$$scope={dirty:n,ctx:i}),e.$set(r)},i(i){t||(ue(e.$$.fragment,i),t=!0)},o(i){he(e.$$.fragment,i),t=!1},d(i){dt(e,i)}}}function Pt(s){let e,t=He(s[16])+"",i;return{c(){e=Q("time"),i=In(t),V(e,"id","trim-duration"),V(e,"class","svelte-1ark3ru")},m(n,r){Ie(n,e,r),Y(e,i)},p(n,r){r[0]&65536&&t!==(t=He(n[16])+"")&&Bn(i,t)},d(n){n&&Be(e)}}}function Tt(s){let e,t,i,n,r;function o(l){s[25](l)}function u(l){s[26](l)}function a(l){s[27](l)}let d={container:s[10],waveform:s[11],playing:s[14],audio_duration:s[15],i18n:s[3],interactive:s[4],handle_trim_audio:s[18],show_redo:s[4],handle_reset_value:s[9],waveform_options:s[8],trim_region_settings:s[6],editable:s[5]};return s[0]!==void 0&&(d.mode=s[0]),s[16]!==void 0&&(d.trimDuration=s[16]),s[17]!==void 0&&(d.show_volume_slider=s[17]),e=new zn({props:d}),ke.push(()=>Qe(e,"mode",o)),ke.push(()=>Qe(e,"trimDuration",u)),ke.push(()=>Qe(e,"show_volume_slider",a)),{c(){ut(e.$$.fragment)},m(l,c){ct(e,l,c),r=!0},p(l,c){const h={};c[0]&1024&&(h.container=l[10]),c[0]&2048&&(h.waveform=l[11]),c[0]&16384&&(h.playing=l[14]),c[0]&32768&&(h.audio_duration=l[15]),c[0]&8&&(h.i18n=l[3]),c[0]&16&&(h.interactive=l[4]),c[0]&16&&(h.show_redo=l[4]),c[0]&512&&(h.handle_reset_value=l[9]),c[0]&256&&(h.waveform_options=l[8]),c[0]&64&&(h.trim_region_settings=l[6]),c[0]&32&&(h.editable=l[5]),!t&&c[0]&1&&(t=!0,h.mode=l[0],Ke(()=>t=!1)),!i&&c[0]&65536&&(i=!0,h.trimDuration=l[16],Ke(()=>i=!1)),!n&&c[0]&131072&&(n=!0,h.show_volume_slider=l[17],Ke(()=>n=!1)),e.$set(h)},i(l){r||(ue(e.$$.fragment,l),r=!0)},o(l){he(e.$$.fragment,l),r=!1},d(l){dt(e,l)}}}function Zn(s){let e,t;return e=new nt({}),{c(){ut(e.$$.fragment)},m(i,n){ct(e,i,n),t=!0},i(i){t||(ue(e.$$.fragment,i),t=!0)},o(i){he(e.$$.fragment,i),t=!1},d(i){dt(e,i)}}}function Yn(s){let e,t,i,n;const r=[Gn,Xn,Fn],o=[];function u(a,d){return a[1]===null?0:a[1].is_stream?1:2}return e=u(s),t=o[e]=r[e](s),{c(){t.c(),i=Vn()},m(a,d){o[e].m(a,d),Ie(a,i,d),n=!0},p(a,d){let l=e;e=u(a),e===l?o[e].p(a,d):(Nt(),he(o[l],1,1,()=>{o[l]=null}),Vt(),t=o[e],t?t.p(a,d):(t=o[e]=r[e](a),t.c()),ue(t,1),t.m(i.parentNode,i))},i(a){n||(ue(t),n=!0)},o(a){he(t),n=!1},d(a){a&&Be(i),o[e].d(a)}}}function Jn(s,e,t){let i,{value:n=null}=e,{label:r}=e,{i18n:o}=e,{dispatch_blob:u=()=>Promise.resolve()}=e,{interactive:a=!1}=e,{editable:d=!0}=e,{trim_region_settings:l={}}=e,{waveform_settings:c}=e,{waveform_options:h}=e,{mode:m=""}=e,{handle_reset_value:f=()=>{}}=e,g,p,C=!1,k,E,_,w=0,$=!1;const S=xn(),z=()=>{t(11,p=st.create({container:g,...c})),ht(n?.url).then(v=>{if(v&&p)return p.load(v)})},x=async(v,L)=>{t(0,m="");const y=p?.getDecodedData();y&&await Gi(y,v,L,c.sampleRate).then(async P=>{await u([P],"change"),p?.destroy(),t(10,g.innerHTML="",g)}),S("edit")};async function J(v){await ht(v).then(L=>{if(!(!L||n?.is_stream))return p?.load(L)})}Un(()=>{window.addEventListener("keydown",v=>{!p||$||(v.key==="ArrowRight"&&m!=="edit"?pt(p,.1):v.key==="ArrowLeft"&&m!=="edit"&&pt(p,-.1))})});function I(v){Hn.call(this,s,v)}function H(v){ke[v?"unshift":"push"](()=>{g=v,t(10,g),t(11,p)})}function de(v){ke[v?"unshift":"push"](()=>{k=v,t(12,k),t(11,p)})}function ce(v){ke[v?"unshift":"push"](()=>{E=v,t(13,E),t(11,p)})}function D(v){m=v,t(0,m)}function pe(v){w=v,t(16,w)}function G(v){$=v,t(17,$)}return s.$$set=v=>{"value"in v&&t(1,n=v.value),"label"in v&&t(2,r=v.label),"i18n"in v&&t(3,o=v.i18n),"dispatch_blob"in v&&t(19,u=v.dispatch_blob),"interactive"in v&&t(4,a=v.interactive),"editable"in v&&t(5,d=v.editable),"trim_region_settings"in v&&t(6,l=v.trim_region_settings),"waveform_settings"in v&&t(7,c=v.w
103aveform_settings),"waveform_options"in v&&t(8,h=v.waveform_options),"mode"in v&&t(0,m=v.mode),"handle_reset_value"in v&&t(9,f=v.handle_reset_value)},s.$$.update=()=>{s.$$.dirty[0]&2&&t(20,i=n?.url),s.$$.dirty[0]&3072&&g!==void 0&&(p!==void 0&&p.destroy(),t(10,g.innerHTML="",g),z(),t(14,C=!1)),s.$$.dirty[0]&10240&&p?.on("decode",v=>{t(15,_=v),E&&t(13,E.textContent=He(v),E)}),s.$$.dirty[0]&6144&&p?.on("timeupdate",v=>k&&t(12,k.textContent=He(v),k)),s.$$.dirty[0]&2176&&p?.on("ready",()=>{c.autoplay?p?.play():p?.stop()}),s.$$.dirty[0]&2048&&p?.on("finish",()=>{t(14,C=!1),S("stop")}),s.$$.dirty[0]&2048&&p?.on("pause",()=>{t(14,C=!1),S("pause")}),s.$$.dirty[0]&2048&&p?.on("play",()=>{t(14,C=!0),S("play")}),s.$$.dirty[0]&2048&&p?.on("load",()=>{S("load")}),s.$$.dirty[0]&1048576&&i&&J(i)},[m,n,r,o,a,d,l,c,h,f,g,p,k,E,C,_,w,$,x,u,i,I,H,de,ce,D,pe,G]}class Kn extends On{constructor(e){super(),Nn(this,e,Jn,Yn,qn,{value:1,label:2,i18n:3,dispatch_blob:19,interactive:4,editable:5,trim_region_settings:6,waveform_settings:7,waveform_options:8,mode:0,handle_reset_value:9},null,[-1,-1])}get value(){return this.$$.ctx[1]}set value(e){this.$$set({value:e}),Z()}get label(){return this.$$.ctx[2]}set label(e){this.$$set({label:e}),Z()}get i18n(){return this.$$.ctx[3]}set i18n(e){this.$$set({i18n:e}),Z()}get dispatch_blob(){return this.$$.ctx[19]}set dispatch_blob(e){this.$$set({dispatch_blob:e}),Z()}get interactive(){return this.$$.ctx[4]}set interactive(e){this.$$set({interactive:e}),Z()}get editable(){return this.$$.ctx[5]}set editable(e){this.$$set({editable:e}),Z()}get trim_region_settings(){return this.$$.ctx[6]}set trim_region_settings(e){this.$$set({trim_region_settings:e}),Z()}get waveform_settings(){return this.$$.ctx[7]}set waveform_settings(e){this.$$set({waveform_settings:e}),Z()}get waveform_options(){return this.$$.ctx[8]}set waveform_options(e){this.$$set({waveform_options:e}),Z()}get mode(){return this.$$.ctx[0]}set mode(e){this.$$set({mode:e}),Z()}get handle_reset_value(){return this.$$.ctx[9]}set handle_reset_value(e){this.$$set({handle_reset_value:e}),Z()}}const Qn=Kn,{SvelteComponent:es,append:ts,attr:is,bubble:we,check_outros:et,create_component:fe,destroy_component:me,detach:Ve,element:ns,empty:ss,flush:K,group_outros:tt,init:rs,insert:Ne,mount_component:_e,safe_not_equal:os,space:it,transition_in:j,transition_out:U}=window.__gradio__svelte__internal,{createEventDispatcher:ls}=window.__gradio__svelte__internal;function as(s){let e,t;return e=new zt({props:{size:"small",$$slots:{default:[ds]},$$scope:{ctx:s}}}),{c(){fe(e.$$.fragment)},m(i,n){_e(e,i,n),t=!0},p(i,n){const r={};n&131072&&(r.$$scope={dirty:n,ctx:i}),e.$set(r)},i(i){t||(j(e.$$.fragment,i),t=!0)},o(i){U(e.$$.fragment,i),t=!1},d(i){me(e,i)}}}function us(s){let e,t,i,n,r,o=s[3]&&At(s),u=s[4]&&Wt(s);return n=new Qn({props:{value:s[0],label:s[1],i18n:s[5],waveform_settings:s[6],waveform_options:s[7],editable:s[8]}}),n.$on("pause",s[12]),n.$on("play",s[13]),n.$on("stop",s[14]),n.$on("load",s[15]),{c(){e=ns("div"),o&&o.c(),t=it(),u&&u.c(),i=it(),fe(n.$$.fragment),is(e,"class","icon-buttons svelte-rvdo70")},m(a,d){Ne(a,e,d),o&&o.m(e,null),ts(e,t),u&&u.m(e,null),Ne(a,i,d),_e(n,a,d),r=!0},p(a,d){a[3]?o?(o.p(a,d),d&8&&j(o,1)):(o=At(a),o.c(),j(o,1),o.m(e,t)):o&&(tt(),U(o,1,1,()=>{o=null}),et()),a[4]?u?(u.p(a,d),d&16&&j(u,1)):(u=Wt(a),u.c(),j(u,1),u.m(e,null)):u&&(tt(),U(u,1,1,()=>{u=null}),et());const l={};d&1&&(l.value=a[0]),d&2&&(l.label=a[1]),d&32&&(l.i18n=a[5]),d&64&&(l.waveform_settings=a[6]),d&128&&(l.waveform_options=a[7]),d&256&&(l.editable=a[8]),n.$set(l)},i(a){r||(j(o),j(u),j(n.$$.fragment,a),r=!0)},o(a){U(o),U(u),U(n.$$.fragment,a),r=!1},d(a){a&&(Ve(e),Ve(i)),o&&o.d(),u&&u.d(),me(n,a)}}}function ds(s){let e,t;return e=new nt({}),{c(){fe(e.$$.fragment)},m(i,n){_e(e,i,n),t=!0},i(i){t||(j(e.$$.fragment,i),t=!0)},o(i){U(e.$$.fragment,i),t=!1},d(i){me(e,i)}}}function At(s){let e,t;return e=new Zt({props:{href:s[0].url,download:s[0].orig_name||s[0].path,$$slots:{default:[cs]},$$scope:{ctx:s}}}),{c(){fe(e.$$.fragment)},m(i,n){_e(e,i,n),t=!0},p(i,n){const r={};n&1&&(r.href=i[0].url),n&1&&(r.download=i[0].orig_name||i[0].path),n&131104&&(r.$$scope={dirty:n,ctx:i}),e.$set(r)},i(i){t||(j(e.$$.fragment,i),t=!0)},o(i){U(e.$$.fragment,i),t=!1},d(i){me(e,i)}}}function cs(s){let e,t;return e=new jt({props:{Icon:Ut,label:s[5]("common.download")}}),{c(){fe(e.$$.fragment)},m(i,n){_e(e,i,n),t=!0},p(i,n){const r={};n&32&&(r.label=i[5]("common.download")),e.$set(r)},i(i){t||(j(e.$$.fragment,i),t=!0)},o(i){U(e.$$.fragment,i),t=!1},d(i){me(e,i)}}}function Wt(s){let e,t;return e=new It({props:{i18n:s[5],formatter:s[9],value:s[0]}}),e.$on("error",s[10]),e.$on("share",s[11]),{c(){fe(e.$$.fragment)},m(i,n){_e(e,i,n),t=!0},p(i,n){const r={};n&32&&(r.i18n=i[5]),n&1&&(r.value=i[0]),e.$set(r)},i(i){t||(j(e.$$.fragment,i),t=!0)},o(i){U(e.$$.fragment,i),t=!1},d(i){me(e,i)}}}function hs(s){let e,t,i,n,r,o;e=new Bt({props:{show_label:s[2],Icon:nt,float:!1,label:s[1]||s[5]("audio.audio")}});const u=[us,as],a=[];function d(l,c){return l[0]!==null?0:1}return i=d(s),n=a[i]=u[i](s),{c(){fe(e.$$.fragment),t=it(),n.c(),r=ss()},m(l,c){_e(e,l,c),Ne(l,t,c),a[i].m(l,c),Ne(l,r,c),o=!0},p(l,[c]){const h={};c&4&&(h.show_label=l[2]),c&34&&(h.label=l[1]||l[5]("audio.audio")),e.$set(h);let m=i;i=d(l),i===m?a[i].p(l,c):(tt(),U(a[m],1,1,()=>{a[m]=null}),et(),n=a[i],n?n.p(l,c):(n=a[i]=u[i](l),n.c()),j(n,1),n.m(r.parentNode,r))},i(l){o||(j(e.$$.fragment,l),j(n),o=!0)},o(l){U(e.$$.fragment,l),U(n),o=!1},d(l){l&&(Ve(t),Ve(r)),me(e,l),a[i].d(l)}}}function fs(s,e,t){let{value:i=null}=e,{label:n}=e,{show_label:r=!0}=e,{show_download_button:o=!0}=e,{show_share_button:u=!1}=e,{i18n:a}=e,{waveform_settings:d}=e,{waveform_options:l}=e,{editable:c=!0}=e;const h=ls(),m=async _=>_?`<audio controls src="${await qt(_.url,"url")}"></audio>`:"";function f(_){we.call(this,s,_)}function g(_){we.call(this,s,_)}function p(_){we.call(this,s,_)}function C(_){we.call(this,s,_)}function k(_){we.call(this,s,_)}function E(_){we.call(this,s,_)}return s.$$set=_=>{"value"in _&&t(0,i=_.value),"label"in _&&t(1,n=_.label),"show_label"in _&&t(2,r=_.show_label),"show_download_button"in _&&t(3,o=_.show_download_button),"show_share_button"in _&&t(4,u=_.show_share_button),"i18n"in _&&t(5,a=_.i18n),"w
103aveform_settings"in _&&t(6,d=_.waveform_settings),"waveform_options"in _&&t(7,l=_.waveform_options),"editable"in _&&t(8,c=_.editable)},s.$$.update=()=>{s.$$.dirty&1&&i&&h("change",i)},[i,n,r,o,u,a,d,l,c,m,f,g,p,C,k,E]}class ms extends es{constructor(e){super(),rs(this,e,fs,hs,os,{value:0,label:1,show_label:2,show_download_button:3,show_share_button:4,i18n:5,waveform_settings:6,waveform_options:7,editable:8})}get value(){return this.$$.ctx[0]}set value(e){this.$$set({value:e}),K()}get label(){return this.$$.ctx[1]}set label(e){this.$$set({label:e}),K()}get show_label(){return this.$$.ctx[2]}set show_label(e){this.$$set({show_label:e}),K()}get show_download_button(){return this.$$.ctx[3]}set show_download_button(e){this.$$set({show_download_button:e}),K()}get show_share_button(){return this.$$.ctx[4]}set show_share_button(e){this.$$set({show_share_button:e}),K()}get i18n(){return this.$$.ctx[5]}set i18n(e){this.$$set({i18n:e}),K()}get waveform_settings(){return this.$$.ctx[6]}set waveform_settings(e){this.$$set({waveform_settings:e}),K()}get waveform_options(){return this.$$.ctx[7]}set waveform_options(e){this.$$set({waveform_options:e}),K()}get editable(){return this.$$.ctx[8]}set editable(e){this.$$set({editable:e}),K()}}const Ss=Object.freeze(Object.defineProperty({__proto__:null,default:ms},Symbol.toStringTag,{value:"Module"}));export{Qn as A,ms as S,zn as W,st as a,Ss as b,Gi as p,pt as s};
104//# sourceMappingURL=StaticAudio-BQSU9k6M.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.