Skip to content

Instantly share code, notes, and snippets.

@kanjieater
Last active September 22, 2025 03:33
Show Gist options
  • Save kanjieater/da6708cb0e33aed4abc3038317092ab8 to your computer and use it in GitHub Desktop.
Save kanjieater/da6708cb0e33aed4abc3038317092ab8 to your computer and use it in GitHub Desktop.
ttu-whispersync
// ==UserScript==
// @name ttu-whispersync
// @namespace https://github.com/Renji-XD
// @version 1.0.12
// @description Listen to audiobooks with ttu ebook-reader
// @icon https://raw.githubusercontent.com/Renji-XD/ttu-whispersync/main/src/assets/icons/icon64.png
// @grant GM_getResourceURL
// @grant unsafeWindow
// @author Renji-xD
// @homepageURL https://github.com/Renji-XD/ttu-whispersync
// @resource mediaInfo https://cdn.jsdelivr.net/npm/[email protected]/dist/MediaInfoModule.wasm
// @resource ffmpeg-core.js https://cdn.jsdelivr.net/npm/@ffmpeg/[email protected]/dist/esm/ffmpeg-core.js
// @match https://reader.ttsu.app/*
// @match http://localhost:5173/*
// @run-at document-idle
// @noframes
// @updateURL https://github.com/Renji-XD/ttu-whispersync/releases/latest/download/ttu-whispersync.tm.user.js
// @downloadURL https://github.com/Renji-XD/ttu-whispersync/releases/latest/download/ttu-whispersync.tm.user.js
// @supportURL https://github.com/Renji-XD/ttu-whispersync/issues
// ==/UserScript==
var k7=Object.defineProperty;var A7=(Gn,wt,sn)=>wt in Gn?k7(Gn,wt,{enumerable:!0,configurable:!0,writable:!0,value:sn}):Gn[wt]=sn;var er=(Gn,wt,sn)=>(A7(Gn,typeof wt!="symbol"?wt+"":wt,sn),sn),d_=(Gn,wt,sn)=>{if(!wt.has(Gn))throw TypeError("Cannot "+sn)};var dn=(Gn,wt,sn)=>(d_(Gn,wt,"read from private field"),sn?sn.call(Gn):wt.get(Gn)),zs=(Gn,wt,sn)=>{if(wt.has(Gn))throw TypeError("Cannot add the same private member more than once");wt instanceof WeakSet?wt.add(Gn):wt.set(Gn,sn)},Gl=(Gn,wt,sn,Ca)=>(d_(Gn,wt,"write to private field"),Ca?Ca.call(Gn,sn):wt.set(Gn,sn),sn);(function(){"use strict";var wi,Ws,ks,Eo,So,Ic,si;var Gn=typeof document<"u"?document.currentScript:null;function wt(){}function sn(t,e){for(const n in e)t[n]=e[n];return t}function Ca(t){return t()}function nd(){return Object.create(null)}function vn(t){t.forEach(Ca)}function Ci(t){return typeof t=="function"}function Cn(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}let jl;function Co(t,e){return t===e?!0:(jl||(jl=document.createElement("a")),jl.href=e,t===jl.href)}function p_(t){return Object.keys(t).length===0}function ns(t,...e){if(t==null){for(const r of e)r(void 0);return wt}const n=t.subscribe(...e);return n.unsubscribe?()=>n.unsubscribe():n}function Ct(t){let e;return ns(t,n=>e=n)(),e}function ce(t,e,n){t.$$.on_destroy.push(ns(e,n))}function Mo(t,e,n,r){if(t){const i=rd(t,e,n,r);return t[0](i)}}function rd(t,e,n,r){return t[1]&&r?sn(n.ctx.slice(),t[1](r(e))):n.ctx}function Ro(t,e,n,r){if(t[2]&&r){const i=t[2](r(n));if(e.dirty===void 0)return i;if(typeof i=="object"){const s=[],o=Math.max(e.dirty.length,i.length);for(let a=0;a<o;a+=1)s[a]=e.dirty[a]|i[a];return s}return e.dirty|i}return e.dirty}function Lo(t,e,n,r,i,s){if(i){const o=rd(e,n,r,s);t.p(o,i)}}function Po(t){if(t.ctx.length>32){const e=[],n=t.ctx.length/32;for(let r=0;r<n;r++)e[r]=-1;return e}return-1}function fe(t,e,n){return t.set(n),e}function Ma(t){return t&&Ci(t.destroy)?t.destroy:wt}let id=typeof window<"u"?t=>requestAnimationFrame(t):wt;const $c=typeof window<"u"?window:typeof globalThis<"u"?globalThis:globalThis||void 0||self;function oe(t,e){t.appendChild(e)}function he(t,e,n){t.insertBefore(e,n||null)}function de(t){t.parentNode&&t.parentNode.removeChild(t)}function _e(t){return document.createElement(t)}function Xs(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function Nt(t){return document.createTextNode(t)}function me(){return Nt(" ")}function Fr(){return Nt("")}function Xe(t,e,n,r){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n,r)}function zl(t){return function(e){return e.preventDefault(),t.call(this,e)}}function Ra(t){return function(e){return e.stopPropagation(),t.call(this,e)}}function ie(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function Nc(t){return t===""?null:+t}function m_(t){return Array.from(t.childNodes)}function cn(t,e){e=""+e,t.data!==e&&(t.data=e)}function Mi(t,e){t.value=e??""}function Cr(t,e,n,r){n==null?t.style.removeProperty(e):t.style.setProperty(e,n,r?"important":"")}function Xl(t,e,n){for(let r=0;r<t.options.length;r+=1){const i=t.options[r];if(i.__value===e){i.selected=!0;return}}(!n||e!==void 0)&&(t.selectedIndex=-1)}function sd(t){const e=t.querySelector(":checked");return e&&e.__value}function pt(t,e,n){t.classList.toggle(e,!!n)}function __(t,e,{bubbles:n=!1,cancelable:r=!1}={}){return new CustomEvent(t,{detail:e,bubbles:n,cancelable:r})}class g_{constructor(e=!1){er(this,"is_svg",!1);er(this,"e");er(this,"n");er(this,"t");er(this,"a");this.is_svg=e,this.e=this.n=null}c(e){this.h(e)}m(e,n,r=null){this.e||(this.is_svg?this.e=Xs(n.nodeName):this.e=_e(n.nodeType===11?"TEMPLATE":n.nodeName),this.t=n.tagName!=="TEMPLATE"?n:n.content,this.c(e)),this.i(r)}h(e){this.e.innerHTML=e,this.n=Array.from(this.e.nodeName==="TEMPLATE"?this.e.content.childNodes:this.e.childNodes)}i(e){for(let n=0;n<this.n.length;n+=1)he(this.t,this.n[n],e)}p(e){this.d(),this.h(e),this.i(this.a)}d(){this.n.forEach(de)}}function od(t,e){return new t(e)}let La;function Pa(t){La=t}function Ia(){if(!La)throw new Error("Function called outside component initialization");return La}function Oa(t){Ia().$$.on_mount.push(t)}function Yl(t){Ia().$$.on_destroy.push(t)}function Ri(){const t=Ia();return(e,n,{cancelable:r=!1}={})=>{const i=t.$$.callbacks[e];if(i){const s=__(e,n,{cancelable:r});return i.slice().forEach(o=>{o.call(t,s)}),!s.defaultPrevented}return!0}}function b_(t,e){return Ia().$$.context.set(t,e),e}function Io(t){return Ia().$$.context.get(t)}function mn(t,e){const n=t.$$.callbacks[e.type];n&&n.slice().forEach(r=>r.call(this,e))}const Oo=[],Vt=[];let Bo=[];const Vc=[],ad=Promise.resolve();let Hc=!1;function ld(){Hc||(Hc=!0,ad.then(ud))}function Mr(){return ld(),ad}function Ms(t){Bo.push(t)}function Yn(t){Vc.push(t)}const xc=new Set;let Do=0;function ud(){if(Do!==0)return;const t=La;do{try{for(;Do<Oo.length;){const e=Oo[Do];Do++,Pa(e),w_(e.$$)}}catch(e){throw Oo.length=0,Do=0,e}for(Pa(null),Oo.length=0,Do=0;Vt.length;)Vt.pop()();for(let e=0;e<Bo.length;e+=1){const n=Bo[e];xc.has(n)||(xc.add(n),n())}Bo.length=0}while(Oo.length);for(;Vc.length;)Vc.pop()();Hc=!1,xc.clear(),Pa(t)}function w_(t){if(t.fragment!==null){t.update(),vn(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(Ms)}}function y_(t){const e=[],n=[];Bo.forEach(r=>t.indexOf(r)===-1?e.push(r):n.push(r)),n.forEach(r=>r()),Bo=e}const Kl=new Set;let Ys;function jt(){Ys={r:0,c:[],p:Ys}}function zt(){Ys.r||vn(Ys.c),Ys=Ys.p}function Z(t,e){t&&t.i&&(Kl.delete(t),t.i(e))}function ne(t,e,n,r){if(t&&t.o){if(Kl.has(t))return;Kl.add(t),Ys.c.push(()=>{Kl.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}else r&&r()}function Jr(t){return(t==null?void 0:t.length)!==void 0?t:Array.from(t)}function Ba(t,e){t.d(1),e.delete(t.key)}function cd(t,e){ne(t,1,1,()=>{e.delete(t.key)})}function Ks(t,e,n,r,i,s,o,a,l,c,u,f){let g=t.length,v=s.length,_=g;const b={};for(;_--;)b[t[_].key]=_;const y=[],p=new Map,m=new Map,w=[];for(_=v;_--;){const L=f(i,s,_),$=n(L);let P=o.get($);P?r&&w.push(()=>P.p(L,e)):(P=c($,L),P.c()),p.set($,y[_]=P),$ in b&&m.set($,Math.abs(_-b[$]))}const C=new Set,h=new Set;function A(L){Z(L,1),L.m(a,u),o.set(L.key,L),u=L.first,v--}for(;g&&v;){const L=y[v-1],$=t[g-1],P=L.key,I=$.key;L===$?(u=L.first,g--,v--):p.has(I)?!o.has(P)||C.has(P)?A(L):h.has(I)?g--:m.get(P)>m.get(I)?(h.add(P),A(L)):(C.add(I),g--):(l($,o),g--)}for(;g--;){const L=t[g];p.has(L.key)||l(L,o)}for(;v;)A(y[v-1]);return vn(w),y}function Kn(t,e){const n={},r={},i={$$scope:1};let s=t.length;for(;s--;){const o=t[s],a=e[s];if(a){for(const l in o)l in a||(r[l]=1);for(const l in a)i[l]||(n[l]=a[l],i[l]=1);t[s]=a}else for(const l in o)i[l]=1}for(const o in r)o in n||(n[o]=void 0);return n}function qn(t){return typeof t=="object"&&t!==null?t:{}}function Zn(t,e,n){const r=t.$$.props[e];r!==void 0&&(t.$$.bound[r]=n,n(t.$$.ctx[r]))}function ye(t){t&&t.c()}function be(t,e,n){const{fragment:r,after_update:i}=t.$$;r&&r.m(e,n),Ms(()=>{const s=t.$$.on_mount.map(Ca).filter(Ci);t.$$.on_destroy?t.$$.on_destroy.push(...s):vn(s),t.$$.on_mount=[]}),i.forEach(Ms)}function we(t,e){const n=t.$$;n.fragment!==null&&(y_(n.after_update),vn(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function v_(t,e){t.$$.dirty[0]===-1&&(Oo.push(t),ld(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function Bn(t,e,n,r,i,s,o=null,a=[-1]){const l=La;Pa(t);const c=t.$$={fragment:null,ctx:[],props:s,update:wt,not_equal:i,bound:nd(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(l?l.$$.context:[])),callbacks:nd(),dirty:a,skip_bound:!1,root:e.target||l.$$.root};o&&o(c.root);let u=!1;if(c.ctx=n?n(t,e.props||{},(f,g,...v)=>{const _=v.length?v[0]:g;return c.ctx&&i(c.ctx[f],c.ctx[f]=_)&&(!c.skip_bound&&c.bound[f]&&c.bound[f](_),u&&v_(t,f)),g}):[],c.update(),u=!0,vn(c.before_update),c.fragment=r?r(c.ctx):!1,e.target){if(e.hydrate){const f=m_(e.target);c.fragment&&c.fragment.l(f),f.forEach(de)}else c.fragment&&c.fragment.c();e.intro&&Z(t.$$.fragment),be(t,e.target,e.anchor),ud()}Pa(l)}class Dn{constructor(){er(this,"$$");er(this,"$$set")}$destroy(){we(this,1),this.$destroy=wt}$on(e,n){if(!Ci(n))return wt;const r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(n),()=>{const i=r.indexOf(n);i!==-1&&r.splice(i,1)}}$set(e){this.$$set&&!p_(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const E_="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(E_);function S_(t){let e,n,r,i,s,o;return{c(){e=Xs("svg"),n=Xs("path"),ie(n,"d",t[1]),ie(e,"tabindex","0"),ie(e,"role","button"),ie(e,"style",r="width: "+t[2]+"; height: "+t[3]+";"+t[4]),ie(e,"viewBox","0 0 24 24"),ie(e,"fill","currentColor"),ie(e,"class",i=`icon ${t[5]}`)},m(a,l){he(a,e,l),oe(e,n),t[8](e),s||(o=[Xe(e,"click",t[6]),Xe(e,"keyup",t[7])],s=!0)},p(a,[l]){l&2&&ie(n,"d",a[1]),l&28&&r!==(r="width: "+a[2]+"; height: "+a[3]+";"+a[4])&&ie(e,"style",r),l&32&&i!==(i=`icon ${a[5]}`)&&ie(e,"class",i)},i:wt,o:wt,d(a){a&&de(e),t[8](null),s=!1,vn(o)}}}function T_(t,e,n){let{path:r}=e,{width:i="1.4rem"}=e,{height:s="1.4rem"}=e,{element:o=void 0}=e,{iconStyles:a=""}=e,{class:l=""}=e;function c(g){mn.call(this,t,g)}function u(g){mn.call(this,t,g)}function f(g){Vt[g?"unshift":"push"](()=>{o=g,n(0,o)})}return t.$$set=g=>{"path"in g&&n(1,r=g.path),"width"in g&&n(2,i=g.width),"height"in g&&n(3,s=g.height),"element"in g&&n(0,o=g.element),"iconStyles"in g&&n(4,a=g.iconStyles),"class"in g&&n(5,l=g.class)},[o,r,i,s,a,l,c,u,f]}class kt extends Dn{constructor(e){super(),Bn(this,e,T_,S_,Cn,{path:1,width:2,height:3,element:0,iconStyles:4,class:5})}}var fd={},ql={};ql.byteLength=C_,ql.toByteArray=R_,ql.fromByteArray=I_;for(var Hi=[],yi=[],k_=typeof Uint8Array<"u"?Uint8Array:Array,Uc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Fo=0,A_=Uc.length;Fo<A_;++Fo)Hi[Fo]=Uc[Fo],yi[Uc.charCodeAt(Fo)]=Fo;yi[45]=62,yi[95]=63;function dd(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var r=n===e?0:4-n%4;return[n,r]}function C_(t){var e=dd(t),n=e[0],r=e[1];return(n+r)*3/4-r}function M_(t,e,n){return(e+n)*3/4-n}function R_(t){var e,n=dd(t),r=n[0],i=n[1],s=new k_(M_(t,r,i)),o=0,a=i>0?r-4:r,l;for(l=0;l<a;l+=4)e=yi[t.charCodeAt(l)]<<18|yi[t.charCodeAt(l+1)]<<12|yi[t.charCodeAt(l+2)]<<6|yi[t.charCodeAt(l+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=yi[t.charCodeAt(l)]<<2|yi[t.charCodeAt(l+1)]>>4,s[o++]=e&255),i===1&&(e=yi[t.charCodeAt(l)]<<10|yi[t.charCodeAt(l+1)]<<4|yi[t.charCodeAt(l+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function L_(t){return Hi[t>>18&63]+Hi[t>>12&63]+Hi[t>>6&63]+Hi[t&63]}function P_(t,e,n){for(var r,i=[],s=e;s<n;s+=3)r=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),i.push(L_(r));return i.join("")}function I_(t){for(var e,n=t.length,r=n%3,i=[],s=16383,o=0,a=n-r;o<a;o+=s)i.push(P_(t,o,o+s>a?a:o+s));return r===1?(e=t[n-1],i.push(Hi[e>>2]+Hi[e<<4&63]+"==")):r===2&&(e=(t[n-2]<<8)+t[n-1],i.push(Hi[e>>10]+Hi[e>>4&63]+Hi[e<<2&63]+"=")),i.join("")}var Wc={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Wc.read=function(t,e,n,r,i){var s,o,a=i*8-r-1,l=(1<<a)-1,c=l>>1,u=-7,f=n?i-1:0,g=n?-1:1,v=t[e+f];for(f+=g,s=v&(1<<-u)-1,v>>=-u,u+=a;u>0;s=s*256+t[e+f],f+=g,u-=8);for(o=s&(1<<-u)-1,s>>=-u,u+=r;u>0;o=o*256+t[e+f],f+=g,u-=8);if(s===0)s=1-c;else{if(s===l)return o?NaN:(v?-1:1)*(1/0);o=o+Math.pow(2,r),s=s-c}return(v?-1:1)*o*Math.pow(2,s-r)},Wc.write=function(t,e,n,r,i,s){var o,a,l,c=s*8-i-1,u=(1<<c)-1,f=u>>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,v=r?0:s-1,_=r?1:-1,b=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+f>=1?e+=g/l:e+=g*Math.pow(2,1-f),e*l>=2&&(o++,l/=2),o+f>=u?(a=0,o=u):o+f>=1?(a=(e*l-1)*Math.pow(2,i),o=o+f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[n+v]=a&255,v+=_,a/=256,i-=8);for(o=o<<i|a,c+=i;c>0;t[n+v]=o&255,v+=_,o/=256,c-=8);t[n+v-_]|=b*128};/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/(function(t){const e=ql,n=Wc,r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=u,t.SlowBuffer=h,t.INSPECT_MAX_BYTES=50;const i=2147483647;t.kMaxLength=i;const{Uint8Array:s,ArrayBuffer:o,SharedArrayBuffer:a}=globalThis;u.TYPED_ARRAY_SUPPORT=l(),!u.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function l(){try{const G=new s(1),T={foo:function(){return 42}};return Object.setPrototypeOf(T,s.prototype),Object.setPrototypeOf(G,T),G.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function c(G){if(G>i)throw new RangeError('The value "'+G+'" is invalid for option "size"');const T=new s(G);return Object.setPrototypeOf(T,u.prototype),T}function u(G,T,d){if(typeof G=="number"){if(typeof T=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return _(G)}return f(G,T,d)}u.poolSize=8192;function f(G,T,d){if(typeof G=="string")return b(G,T);if(o.isView(G))return p(G);if(G==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof G);if(Oe(G,o)||G&&Oe(G.buffer,o)||typeof a<"u"&&(Oe(G,a)||G&&Oe(G.buffer,a)))return m(G,T,d);if(typeof G=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const k=G.valueOf&&G.valueOf();if(k!=null&&k!==G)return u.from(k,T,d);const D=w(G);if(D)return D;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof G[Symbol.toPrimitive]=="function")return u.from(G[Symbol.toPrimitive]("string"),T,d);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof G)}u.from=function(G,T,d){return f(G,T,d)},Object.setPrototypeOf(u.prototype,s.prototype),Object.setPrototypeOf(u,s);function g(G){if(typeof G!="number")throw new TypeError('"size" argument must be of type number');if(G<0)throw new RangeError('The value "'+G+'" is invalid for option "size"')}function v(G,T,d){return g(G),G<=0?c(G):T!==void 0?typeof d=="string"?c(G).fill(T,d):c(G).fill(T):c(G)}u.alloc=function(G,T,d){return v(G,T,d)};function _(G){return g(G),c(G<0?0:C(G)|0)}u.allocUnsafe=function(G){return _(G)},u.allocUnsafeSlow=function(G){return _(G)};function b(G,T){if((typeof T!="string"||T==="")&&(T="utf8"),!u.isEncoding(T))throw new TypeError("Unknown encoding: "+T);const d=A(G,T)|0;let k=c(d);const D=k.write(G,T);return D!==d&&(k=k.slice(0,D)),k}function y(G){const T=G.length<0?0:C(G.length)|0,d=c(T);for(let k=0;k<T;k+=1)d[k]=G[k]&255;return d}function p(G){if(Oe(G,s)){const T=new s(G);return m(T.buffer,T.byteOffset,T.byteLength)}return y(G)}function m(G,T,d){if(T<0||G.byteLength<T)throw new RangeError('"offset" is outside of buffer bounds');if(G.byteLength<T+(d||0))throw new RangeError('"length" is outside of buffer bounds');let k;return T===void 0&&d===void 0?k=new s(G):d===void 0?k=new s(G,T):k=new s(G,T,d),Object.setPrototypeOf(k,u.prototype),k}function w(G){if(u.isBuffer(G)){const T=C(G.length)|0,d=c(T);return d.length===0||G.copy(d,0,0,T),d}if(G.length!==void 0)return typeof G.length!="number"||je(G.length)?c(0):y(G);if(G.type==="Buffer"&&Array.isArray(G.data))return y(G.data)}function C(G){if(G>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return G|0}function h(G){return+G!=G&&(G=0),u.alloc(+G)}u.isBuffer=function(T){return T!=null&&T._isBuffer===!0&&T!==u.prototype},u.compare=function(T,d){if(Oe(T,s)&&(T=u.from(T,T.offset,T.byteLength)),Oe(d,s)&&(d=u.from(d,d.offset,d.byteLength)),!u.isBuffer(T)||!u.isBuffer(d))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(T===d)return 0;let k=T.length,D=d.length;for(let U=0,te=Math.min(k,D);U<te;++U)if(T[U]!==d[U]){k=T[U],D=d[U];break}return k<D?-1:D<k?1:0},u.isEncoding=function(T){switch(String(T).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(T,d){if(!Array.isArray(T))throw new TypeError('"list" argument must be an Array of Buffers');if(T.length===0)return u.alloc(0);let k;if(d===void 0)for(d=0,k=0;k<T.length;++k)d+=T[k].length;const D=u.allocUnsafe(d);let U=0;for(k=0;k<T.length;++k){let te=T[k];if(Oe(te,s))U+te.length>D.length?(u.isBuffer(te)||(te=u.from(te)),te.copy(D,U)):s.prototype.set.call(D,te,U);else if(u.isBuffer(te))te.copy(D,U);else throw new TypeError('"list" argument must be an Array of Buffers');U+=te.length}return D};function A(G,T){if(u.isBuffer(G))return G.length;if(o.isView(G)||Oe(G,o))return G.byteLength;if(typeof G!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof G);const d=G.length,k=arguments.length>2&&arguments[2]===!0;if(!k&&d===0)return 0;let D=!1;for(;;)switch(T){case"ascii":case"latin1":case"binary":return d;case"utf8":case"utf-8":return H(G).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d*2;case"hex":return d>>>1;case"base64":return qe(G).length;default:if(D)return k?-1:H(G).length;T=(""+T).toLowerCase(),D=!0}}u.byteLength=A;function L(G,T,d){let k=!1;if((T===void 0||T<0)&&(T=0),T>this.length||((d===void 0||d>this.length)&&(d=this.length),d<=0)||(d>>>=0,T>>>=0,d<=T))return"";for(G||(G="utf8");;)switch(G){case"hex":return M(this,T,d);case"utf8":case"utf-8":return Y(this,T,d);case"ascii":return j(this,T,d);case"latin1":case"binary":return B(this,T,d);case"base64":return N(this,T,d);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,T,d);default:if(k)throw new TypeError("Unknown encoding: "+G);G=(G+"").toLowerCase(),k=!0}}u.prototype._isBuffer=!0;function $(G,T,d){const k=G[T];G[T]=G[d],G[d]=k}u.prototype.swap16=function(){const T=this.length;if(T%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let d=0;d<T;d+=2)$(this,d,d+1);return this},u.prototype.swap32=function(){const T=this.length;if(T%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let d=0;d<T;d+=4)$(this,d,d+3),$(this,d+1,d+2);return this},u.prototype.swap64=function(){const T=this.length;if(T%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let d=0;d<T;d+=8)$(this,d,d+7),$(this,d+1,d+6),$(this,d+2,d+5),$(this,d+3,d+4);return this},u.prototype.toString=function(){const T=this.length;return T===0?"":arguments.length===0?Y(this,0,T):L.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(T){if(!u.isBuffer(T))throw new TypeError("Argument must be a Buffer");return this===T?!0:u.compare(this,T)===0},u.prototype.inspect=function(){let T="";const d=t.INSPECT_MAX_BYTES;return T=this.toString("hex",0,d).replace(/(.{2})/g,"$1 ").trim(),this.length>d&&(T+=" ... "),"<Buffer "+T+">"},r&&(u.prototype[r]=u.prototype.inspect),u.prototype.compare=function(T,d,k,D,U){if(Oe(T,s)&&(T=u.from(T,T.offset,T.byteLength)),!u.isBuffer(T))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof T);if(d===void 0&&(d=0),k===void 0&&(k=T?T.length:0),D===void 0&&(D=0),U===void 0&&(U=this.length),d<0||k>T.length||D<0||U>this.length)throw new RangeError("out of range index");if(D>=U&&d>=k)return 0;if(D>=U)return-1;if(d>=k)return 1;if(d>>>=0,k>>>=0,D>>>=0,U>>>=0,this===T)return 0;let te=U-D,ee=k-d;const se=Math.min(te,ee),ge=this.slice(D,U),pe=T.slice(d,k);for(let Ae=0;Ae<se;++Ae)if(ge[Ae]!==pe[Ae]){te=ge[Ae],ee=pe[Ae];break}return te<ee?-1:ee<te?1:0};function P(G,T,d,k,D){if(G.length===0)return-1;if(typeof d=="string"?(k=d,d=0):d>2147483647?d=2147483647:d<-2147483648&&(d=-2147483648),d=+d,je(d)&&(d=D?0:G.length-1),d<0&&(d=G.length+d),d>=G.length){if(D)return-1;d=G.length-1}else if(d<0)if(D)d=0;else return-1;if(typeof T=="string"&&(T=u.from(T,k)),u.isBuffer(T))return T.length===0?-1:I(G,T,d,k,D);if(typeof T=="number")return T=T&255,typeof s.prototype.indexOf=="function"?D?s.prototype.indexOf.call(G,T,d):s.prototype.lastIndexOf.call(G,T,d):I(G,[T],d,k,D);throw new TypeError("val must be string, number or Buffer")}function I(G,T,d,k,D){let U=1,te=G.length,ee=T.length;if(k!==void 0&&(k=String(k).toLowerCase(),k==="ucs2"||k==="ucs-2"||k==="utf16le"||k==="utf-16le")){if(G.length<2||T.length<2)return-1;U=2,te/=2,ee/=2,d/=2}function se(pe,Ae){return U===1?pe[Ae]:pe.readUInt16BE(Ae*U)}let ge;if(D){let pe=-1;for(ge=d;ge<te;ge++)if(se(G,ge)===se(T,pe===-1?0:ge-pe)){if(pe===-1&&(pe=ge),ge-pe+1===ee)return pe*U}else pe!==-1&&(ge-=ge-pe),pe=-1}else for(d+ee>te&&(d=te-ee),ge=d;ge>=0;ge--){let pe=!0;for(let Ae=0;Ae<ee;Ae++)if(se(G,ge+Ae)!==se(T,Ae)){pe=!1;break}if(pe)return ge}return-1}u.prototype.includes=function(T,d,k){return this.indexOf(T,d,k)!==-1},u.prototype.indexOf=function(T,d,k){return P(this,T,d,k,!0)},u.prototype.lastIndexOf=function(T,d,k){return P(this,T,d,k,!1)};function x(G,T,d,k){d=Number(d)||0;const D=G.length-d;k?(k=Number(k),k>D&&(k=D)):k=D;const U=T.length;k>U/2&&(k=U/2);let te;for(te=0;te<k;++te){const ee=parseInt(T.substr(te*2,2),16);if(je(ee))return te;G[d+te]=ee}return te}function ae(G,T,d,k){return nt(H(T,G.length-d),G,d,k)}function V(G,T,d,k){return nt(Pe(T),G,d,k)}function E(G,T,d,k){return nt(qe(T),G,d,k)}function F(G,T,d,k){return nt(xe(T,G.length-d),G,d,k)}u.prototype.write=function(T,d,k,D){if(d===void 0)D="utf8",k=this.length,d=0;else if(k===void 0&&typeof d=="string")D=d,k=this.length,d=0;else if(isFinite(d))d=d>>>0,isFinite(k)?(k=k>>>0,D===void 0&&(D="utf8")):(D=k,k=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const U=this.length-d;if((k===void 0||k>U)&&(k=U),T.length>0&&(k<0||d<0)||d>this.length)throw new RangeError("Attempt to write outside buffer bounds");D||(D="utf8");let te=!1;for(;;)switch(D){case"hex":return x(this,T,d,k);case"utf8":case"utf-8":return ae(this,T,d,k);case"ascii":case"latin1":case"binary":return V(this,T,d,k);case"base64":return E(this,T,d,k);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return F(this,T,d,k);default:if(te)throw new TypeError("Unknown encoding: "+D);D=(""+D).toLowerCase(),te=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function N(G,T,d){return T===0&&d===G.length?e.fromByteArray(G):e.fromByteArray(G.slice(T,d))}function Y(G,T,d){d=Math.min(G.length,d);const k=[];let D=T;for(;D<d;){const U=G[D];let te=null,ee=U>239?4:U>223?3:U>191?2:1;if(D+ee<=d){let se,ge,pe,Ae;switch(ee){case 1:U<128&&(te=U);break;case 2:se=G[D+1],(se&192)===128&&(Ae=(U&31)<<6|se&63,Ae>127&&(te=Ae));break;case 3:se=G[D+1],ge=G[D+2],(se&192)===128&&(ge&192)===128&&(Ae=(U&15)<<12|(se&63)<<6|ge&63,Ae>2047&&(Ae<55296||Ae>57343)&&(te=Ae));break;case 4:se=G[D+1],ge=G[D+2],pe=G[D+3],(se&192)===128&&(ge&192)===128&&(pe&192)===128&&(Ae=(U&15)<<18|(se&63)<<12|(ge&63)<<6|pe&63,Ae>65535&&Ae<1114112&&(te=Ae))}}te===null?(te=65533,ee=1):te>65535&&(te-=65536,k.push(te>>>10&1023|55296),te=56320|te&1023),k.push(te),D+=ee}return J(k)}const K=4096;function J(G){const T=G.length;if(T<=K)return String.fromCharCode.apply(String,G);let d="",k=0;for(;k<T;)d+=String.fromCharCode.apply(String,G.slice(k,k+=K));return d}function j(G,T,d){let k="";d=Math.min(G.length,d);for(let D=T;D<d;++D)k+=String.fromCharCode(G[D]&127);return k}function B(G,T,d){let k="";d=Math.min(G.length,d);for(let D=T;D<d;++D)k+=String.fromCharCode(G[D]);return k}function M(G,T,d){const k=G.length;(!T||T<0)&&(T=0),(!d||d<0||d>k)&&(d=k);let D="";for(let U=T;U<d;++U)D+=et[G[U]];return D}function S(G,T,d){const k=G.slice(T,d);let D="";for(let U=0;U<k.length-1;U+=2)D+=String.fromCharCode(k[U]+k[U+1]*256);return D}u.prototype.slice=function(T,d){const k=this.length;T=~~T,d=d===void 0?k:~~d,T<0?(T+=k,T<0&&(T=0)):T>k&&(T=k),d<0?(d+=k,d<0&&(d=0)):d>k&&(d=k),d<T&&(d=T);const D=this.subarray(T,d);return Object.setPrototypeOf(D,u.prototype),D};function R(G,T,d){if(G%1!==0||G<0)throw new RangeError("offset is not uint");if(G+T>d)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(T,d,k){T=T>>>0,d=d>>>0,k||R(T,d,this.length);let D=this[T],U=1,te=0;for(;++te<d&&(U*=256);)D+=this[T+te]*U;return D},u.prototype.readUintBE=u.prototype.readUIntBE=function(T,d,k){T=T>>>0,d=d>>>0,k||R(T,d,this.length);let D=this[T+--d],U=1;for(;d>0&&(U*=256);)D+=this[T+--d]*U;return D},u.prototype.readUint8=u.prototype.readUInt8=function(T,d){return T=T>>>0,d||R(T,1,this.length),this[T]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(T,d){return T=T>>>0,d||R(T,2,this.length),this[T]|this[T+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(T,d){return T=T>>>0,d||R(T,2,this.length),this[T]<<8|this[T+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(T,d){return T=T>>>0,d||R(T,4,this.length),(this[T]|this[T+1]<<8|this[T+2]<<16)+this[T+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(T,d){return T=T>>>0,d||R(T,4,this.length),this[T]*16777216+(this[T+1]<<16|this[T+2]<<8|this[T+3])},u.prototype.readBigUInt64LE=rt(function(T){T=T>>>0,Le(T,"offset");const d=this[T],k=this[T+7];(d===void 0||k===void 0)&&Fe(T,this.length-8);const D=d+this[++T]*2**8+this[++T]*2**16+this[++T]*2**24,U=this[++T]+this[++T]*2**8+this[++T]*2**16+k*2**24;return BigInt(D)+(BigInt(U)<<BigInt(32))}),u.prototype.readBigUInt64BE=rt(function(T){T=T>>>0,Le(T,"offset");const d=this[T],k=this[T+7];(d===void 0||k===void 0)&&Fe(T,this.length-8);const D=d*2**24+this[++T]*2**16+this[++T]*2**8+this[++T],U=this[++T]*2**24+this[++T]*2**16+this[++T]*2**8+k;return(BigInt(D)<<BigInt(32))+BigInt(U)}),u.prototype.readIntLE=function(T,d,k){T=T>>>0,d=d>>>0,k||R(T,d,this.length);let D=this[T],U=1,te=0;for(;++te<d&&(U*=256);)D+=this[T+te]*U;return U*=128,D>=U&&(D-=Math.pow(2,8*d)),D},u.prototype.readIntBE=function(T,d,k){T=T>>>0,d=d>>>0,k||R(T,d,this.length);let D=d,U=1,te=this[T+--D];for(;D>0&&(U*=256);)te+=this[T+--D]*U;return U*=128,te>=U&&(te-=Math.pow(2,8*d)),te},u.prototype.readInt8=function(T,d){return T=T>>>0,d||R(T,1,this.length),this[T]&128?(255-this[T]+1)*-1:this[T]},u.prototype.readInt16LE=function(T,d){T=T>>>0,d||R(T,2,this.length);const k=this[T]|this[T+1]<<8;return k&32768?k|4294901760:k},u.prototype.readInt16BE=function(T,d){T=T>>>0,d||R(T,2,this.length);const k=this[T+1]|this[T]<<8;return k&32768?k|4294901760:k},u.prototype.readInt32LE=function(T,d){return T=T>>>0,d||R(T,4,this.length),this[T]|this[T+1]<<8|this[T+2]<<16|this[T+3]<<24},u.prototype.readInt32BE=function(T,d){return T=T>>>0,d||R(T,4,this.length),this[T]<<24|this[T+1]<<16|this[T+2]<<8|this[T+3]},u.prototype.readBigInt64LE=rt(function(T){T=T>>>0,Le(T,"offset");const d=this[T],k=this[T+7];(d===void 0||k===void 0)&&Fe(T,this.length-8);const D=this[T+4]+this[T+5]*2**8+this[T+6]*2**16+(k<<24);return(BigInt(D)<<BigInt(32))+BigInt(d+this[++T]*2**8+this[++T]*2**16+this[++T]*2**24)}),u.prototype.readBigInt64BE=rt(function(T){T=T>>>0,Le(T,"offset");const d=this[T],k=this[T+7];(d===void 0||k===void 0)&&Fe(T,this.length-8);const D=(d<<24)+this[++T]*2**16+this[++T]*2**8+this[++T];return(BigInt(D)<<BigInt(32))+BigInt(this[++T]*2**24+this[++T]*2**16+this[++T]*2**8+k)}),u.prototype.readFloatLE=function(T,d){return T=T>>>0,d||R(T,4,this.length),n.read(this,T,!0,23,4)},u.prototype.readFloatBE=function(T,d){return T=T>>>0,d||R(T,4,this.length),n.read(this,T,!1,23,4)},u.prototype.readDoubleLE=function(T,d){return T=T>>>0,d||R(T,8,this.length),n.read(this,T,!0,52,8)},u.prototype.readDoubleBE=function(T,d){return T=T>>>0,d||R(T,8,this.length),n.read(this,T,!1,52,8)};function X(G,T,d,k,D,U){if(!u.isBuffer(G))throw new TypeError('"buffer" argument must be a Buffer instance');if(T>D||T<U)throw new RangeError('"value" argument is out of bounds');if(d+k>G.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(T,d,k,D){if(T=+T,d=d>>>0,k=k>>>0,!D){const ee=Math.pow(2,8*k)-1;X(this,T,d,k,ee,0)}let U=1,te=0;for(this[d]=T&255;++te<k&&(U*=256);)this[d+te]=T/U&255;return d+k},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(T,d,k,D){if(T=+T,d=d>>>0,k=k>>>0,!D){const ee=Math.pow(2,8*k)-1;X(this,T,d,k,ee,0)}let U=k-1,te=1;for(this[d+U]=T&255;--U>=0&&(te*=256);)this[d+U]=T/te&255;return d+k},u.prototype.writeUint8=u.prototype.writeUInt8=function(T,d,k){return T=+T,d=d>>>0,k||X(this,T,d,1,255,0),this[d]=T&255,d+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(T,d,k){return T=+T,d=d>>>0,k||X(this,T,d,2,65535,0),this[d]=T&255,this[d+1]=T>>>8,d+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(T,d,k){return T=+T,d=d>>>0,k||X(this,T,d,2,65535,0),this[d]=T>>>8,this[d+1]=T&255,d+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(T,d,k){return T=+T,d=d>>>0,k||X(this,T,d,4,4294967295,0),this[d+3]=T>>>24,this[d+2]=T>>>16,this[d+1]=T>>>8,this[d]=T&255,d+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(T,d,k){return T=+T,d=d>>>0,k||X(this,T,d,4,4294967295,0),this[d]=T>>>24,this[d+1]=T>>>16,this[d+2]=T>>>8,this[d+3]=T&255,d+4};function re(G,T,d,k,D){Te(T,k,D,G,d,7);let U=Number(T&BigInt(4294967295));G[d++]=U,U=U>>8,G[d++]=U,U=U>>8,G[d++]=U,U=U>>8,G[d++]=U;let te=Number(T>>BigInt(32)&BigInt(4294967295));return G[d++]=te,te=te>>8,G[d++]=te,te=te>>8,G[d++]=te,te=te>>8,G[d++]=te,d}function W(G,T,d,k,D){Te(T,k,D,G,d,7);let U=Number(T&BigInt(4294967295));G[d+7]=U,U=U>>8,G[d+6]=U,U=U>>8,G[d+5]=U,U=U>>8,G[d+4]=U;let te=Number(T>>BigInt(32)&BigInt(4294967295));return G[d+3]=te,te=te>>8,G[d+2]=te,te=te>>8,G[d+1]=te,te=te>>8,G[d]=te,d+8}u.prototype.writeBigUInt64LE=rt(function(T,d=0){return re(this,T,d,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=rt(function(T,d=0){return W(this,T,d,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(T,d,k,D){if(T=+T,d=d>>>0,!D){const se=Math.pow(2,8*k-1);X(this,T,d,k,se-1,-se)}let U=0,te=1,ee=0;for(this[d]=T&255;++U<k&&(te*=256);)T<0&&ee===0&&this[d+U-1]!==0&&(ee=1),this[d+U]=(T/te>>0)-ee&255;return d+k},u.prototype.writeIntBE=function(T,d,k,D){if(T=+T,d=d>>>0,!D){const se=Math.pow(2,8*k-1);X(this,T,d,k,se-1,-se)}let U=k-1,te=1,ee=0;for(this[d+U]=T&255;--U>=0&&(te*=256);)T<0&&ee===0&&this[d+U+1]!==0&&(ee=1),this[d+U]=(T/te>>0)-ee&255;return d+k},u.prototype.writeInt8=function(T,d,k){return T=+T,d=d>>>0,k||X(this,T,d,1,127,-128),T<0&&(T=255+T+1),this[d]=T&255,d+1},u.prototype.writeInt16LE=function(T,d,k){return T=+T,d=d>>>0,k||X(this,T,d,2,32767,-32768),this[d]=T&255,this[d+1]=T>>>8,d+2},u.prototype.writeInt16BE=function(T,d,k){return T=+T,d=d>>>0,k||X(this,T,d,2,32767,-32768),this[d]=T>>>8,this[d+1]=T&255,d+2},u.prototype.writeInt32LE=function(T,d,k){return T=+T,d=d>>>0,k||X(this,T,d,4,2147483647,-2147483648),this[d]=T&255,this[d+1]=T>>>8,this[d+2]=T>>>16,this[d+3]=T>>>24,d+4},u.prototype.writeInt32BE=function(T,d,k){return T=+T,d=d>>>0,k||X(this,T,d,4,2147483647,-2147483648),T<0&&(T=4294967295+T+1),this[d]=T>>>24,this[d+1]=T>>>16,this[d+2]=T>>>8,this[d+3]=T&255,d+4},u.prototype.writeBigInt64LE=rt(function(T,d=0){return re(this,T,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=rt(function(T,d=0){return W(this,T,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function z(G,T,d,k,D,U){if(d+k>G.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("Index out of range")}function le(G,T,d,k,D){return T=+T,d=d>>>0,D||z(G,T,d,4),n.write(G,T,d,k,23,4),d+4}u.prototype.writeFloatLE=function(T,d,k){return le(this,T,d,!0,k)},u.prototype.writeFloatBE=function(T,d,k){return le(this,T,d,!1,k)};function Me(G,T,d,k,D){return T=+T,d=d>>>0,D||z(G,T,d,8),n.write(G,T,d,k,52,8),d+8}u.prototype.writeDoubleLE=function(T,d,k){return Me(this,T,d,!0,k)},u.prototype.writeDoubleBE=function(T,d,k){return Me(this,T,d,!1,k)},u.prototype.copy=function(T,d,k,D){if(!u.isBuffer(T))throw new TypeError("argument should be a Buffer");if(k||(k=0),!D&&D!==0&&(D=this.length),d>=T.length&&(d=T.length),d||(d=0),D>0&&D<k&&(D=k),D===k||T.length===0||this.length===0)return 0;if(d<0)throw new RangeError("targetStart out of bounds");if(k<0||k>=this.length)throw new RangeError("Index out of range");if(D<0)throw new RangeError("sourceEnd out of bounds");D>this.length&&(D=this.length),T.length-d<D-k&&(D=T.length-d+k);const U=D-k;return this===T&&typeof s.prototype.copyWithin=="function"?this.copyWithin(d,k,D):s.prototype.set.call(T,this.subarray(k,D),d),U},u.prototype.fill=function(T,d,k,D){if(typeof T=="string"){if(typeof d=="string"?(D=d,d=0,k=this.length):typeof k=="string"&&(D=k,k=this.length),D!==void 0&&typeof D!="string")throw new TypeError("encoding must be a string");if(typeof D=="string"&&!u.isEncoding(D))throw new TypeError("Unknown encoding: "+D);if(T.length===1){const te=T.charCodeAt(0);(D==="utf8"&&te<128||D==="latin1")&&(T=te)}}else typeof T=="number"?T=T&255:typeof T=="boolean"&&(T=Number(T));if(d<0||this.length<d||this.length<k)throw new RangeError("Out of range index");if(k<=d)return this;d=d>>>0,k=k===void 0?this.length:k>>>0,T||(T=0);let U;if(typeof T=="number")for(U=d;U<k;++U)this[U]=T;else{const te=u.isBuffer(T)?T:u.from(T,D),ee=te.length;if(ee===0)throw new TypeError('The value "'+T+'" is invalid for argument "value"');for(U=0;U<k-d;++U)this[U+d]=te[U%ee]}return this};const Ee={};function ve(G,T,d){Ee[G]=class extends d{constructor(){super(),Object.defineProperty(this,"message",{value:T.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${G}]`,this.stack,delete this.name}get code(){return G}set code(D){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:D,writable:!0})}toString(){return`${this.name} [${G}]: ${this.message}`}}}ve("ERR_BUFFER_OUT_OF_BOUNDS",function(G){return G?`${G} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ve("ERR_INVALID_ARG_TYPE",function(G,T){return`The "${G}" argument must be of type number. Received type ${typeof T}`},TypeError),ve("ERR_OUT_OF_RANGE",function(G,T,d){let k=`The value of "${G}" is out of range.`,D=d;return Number.isInteger(d)&&Math.abs(d)>2**32?D=ke(String(d)):typeof d=="bigint"&&(D=String(d),(d>BigInt(2)**BigInt(32)||d<-(BigInt(2)**BigInt(32)))&&(D=ke(D)),D+="n"),k+=` It must be ${T}. Received ${D}`,k},RangeError);function ke(G){let T="",d=G.length;const k=G[0]==="-"?1:0;for(;d>=k+4;d-=3)T=`_${G.slice(d-3,d)}${T}`;return`${G.slice(0,d)}${T}`}function Ne(G,T,d){Le(T,"offset"),(G[T]===void 0||G[T+d]===void 0)&&Fe(T,G.length-(d+1))}function Te(G,T,d,k,D,U){if(G>d||G<T){const te=typeof T=="bigint"?"n":"";let ee;throw U>3?T===0||T===BigInt(0)?ee=`>= 0${te} and < 2${te} ** ${(U+1)*8}${te}`:ee=`>= -(2${te} ** ${(U+1)*8-1}${te}) and < 2 ** ${(U+1)*8-1}${te}`:ee=`>= ${T}${te} and <= ${d}${te}`,new Ee.ERR_OUT_OF_RANGE("value",ee,G)}Ne(k,D,U)}function Le(G,T){if(typeof G!="number")throw new Ee.ERR_INVALID_ARG_TYPE(T,"number",G)}function Fe(G,T,d){throw Math.floor(G)!==G?(Le(G,d),new Ee.ERR_OUT_OF_RANGE(d||"offset","an integer",G)):T<0?new Ee.ERR_BUFFER_OUT_OF_BOUNDS:new Ee.ERR_OUT_OF_RANGE(d||"offset",`>= ${d?1:0} and <= ${T}`,G)}const Ze=/[^+/0-9A-Za-z-_]/g;function O(G){if(G=G.split("=")[0],G=G.trim().replace(Ze,""),G.length<2)return"";for(;G.length%4!==0;)G=G+"=";return G}function H(G,T){T=T||1/0;let d;const k=G.length;let D=null;const U=[];for(let te=0;te<k;++te){if(d=G.charCodeAt(te),d>55295&&d<57344){if(!D){if(d>56319){(T-=3)>-1&&U.push(239,191,189);continue}else if(te+1===k){(T-=3)>-1&&U.push(239,191,189);continue}D=d;continue}if(d<56320){(T-=3)>-1&&U.push(239,191,189),D=d;continue}d=(D-55296<<10|d-56320)+65536}else D&&(T-=3)>-1&&U.push(239,191,189);if(D=null,d<128){if((T-=1)<0)break;U.push(d)}else if(d<2048){if((T-=2)<0)break;U.push(d>>6|192,d&63|128)}else if(d<65536){if((T-=3)<0)break;U.push(d>>12|224,d>>6&63|128,d&63|128)}else if(d<1114112){if((T-=4)<0)break;U.push(d>>18|240,d>>12&63|128,d>>6&63|128,d&63|128)}else throw new Error("Invalid code point")}return U}function Pe(G){const T=[];for(let d=0;d<G.length;++d)T.push(G.charCodeAt(d)&255);return T}function xe(G,T){let d,k,D;const U=[];for(let te=0;te<G.length&&!((T-=2)<0);++te)d=G.charCodeAt(te),k=d>>8,D=d%256,U.push(D),U.push(k);return U}function qe(G){return e.toByteArray(O(G))}function nt(G,T,d,k){let D;for(D=0;D<k&&!(D+d>=T.length||D>=G.length);++D)T[D+d]=G[D];return D}function Oe(G,T){return G instanceof T||G!=null&&G.constructor!=null&&G.constructor.name!=null&&G.constructor.name===T.name}function je(G){return G!==G}const et=function(){const G="0123456789abcdef",T=new Array(256);for(let d=0;d<16;++d){const k=d*16;for(let D=0;D<16;++D)T[k+D]=G[d]+G[D]}return T}();function rt(G){return typeof BigInt>"u"?Je:G}function Je(){throw new Error("BigInt not supported")}})(fd);const Gc=fd.Buffer,hd=new Map([["Copy subtitle",!0],["Toggle playback",!0],["Restart playback",!0],["Toggle play and pause",!0],["Toggle playback loop",!0],["Toggle bookmark",!0],["Toggle menu bookmark filter",!1],["Toggle for merge",!0],["Toggle menu merge filter",!1],["Edit subtitle",!0],["Restore original text and time",!0],["Create new card",!0],["Update last created card",!0],["Open last exported card",!0]]),pd=new Map([["Restart playback",!0],["Toggle bookmark",!0],["Toggle menu bookmark filter",!1],["Restore original text and time",!0],["Toggle play and pause",!0],["Toggle for merge",!0],["Toggle menu merge filter",!1],["Create new card",!0],["Toggle playback loop",!0],["Edit subtitle",!0],["Update last created card",!0]]),jc=new Map([["Toggle playback",!0],["Rewind #2",!1],["Rewind",!1],["Fast-Forward",!1],["Fast-Forward #2",!1],["Go to previous subtitle",!1],["Go to next subtitle",!1],["Restart playback",!1],["Toggle play and pause",!1],["Toggle playback loop",!1],["Toggle bookmark",!1],["Toggle menu bookmark filter",!1],["Toggle for merge",!1],["Toggle menu merge filter",!1],["Edit subtitle",!1],["Restore original text and time",!1],["Copy subtitle",!1],["Create new card",!1],["Update last created card",!1],["Open last exported card",!1]]);var ci=(t=>(t.NONE="none",t.READER="Reader",t.SUBTITLES="Subtitles",t.PLAYER="Player",t.EXPORT="Export",t.ANKI="Anki",t.KEYBINDINGS="Keybindings",t.READER_ACTIONS="Reader actions",t.SUBTITLE_ACTIONS="Subtitle actions",t.FOOTER_ACTIONS="Footer actions",t))(ci||{}),Da=(t=>(t.CREATE="Create card",t.UPDATE="Update card",t))(Da||{}),Zl=(t=>(t.ALWAYS="Always",t.PAGE="Page",t))(Zl||{}),Jl=(t=>(t.AUTO="auto",t.INSTANT="instant",t.SMOOTH="smooth",t))(Jl||{}),tr=(t=>(t.DISABLED="Disabled",t.CLICK="On click",t.HOLD="On hold",t))(tr||{}),Ql=(t=>(t.DISABLED="Disabled",t.PAUSE="Pause on open",t))(Ql||{}),Tr=(t=>(t.HIDDEN="Hidden",t.ALWAYS="Always visible",t.HOVER="On hover",t.TOGGLE="Toggle on hold",t))(Tr||{}),fi=(t=>(t.DISABLED="Disabled",t.MODERATE="Moderate",t.STRICT="Strict",t))(fi||{}),kr=(t=>(t.RECORDER="Recorder",t.FFMPEG="FFMPEG",t))(kr||{}),Rs=(t=>(t.MP3="mp3",t.OGG="ogg",t.OPUS="opus",t))(Rs||{}),$o=(t=>(t.AUTO="auto",t.JPEG="jpeg",t.PNG="png",t.WEBP="webp",t))($o||{}),Ls=(t=>(t.BEFORE="Insert before",t.AFTER="Insert after",t.REPLACE="Replace",t))(Ls||{}),di=(t=>(t.DISABLED="Disabled",t.DECK="Deck",t.SUBDECK="Deck and children",t.COLLECTION="Collection",t))(di||{});function O_(){return{"ttu-whispersync-reader-line-highlight-color":"#fffa82","ttu-whispersync-reader-line-text-highlight-color":"#000000","ttu-whispersync-reader-enable-line-highlight":!0,"ttu-whispersync-reader-enable-line-text-highlight":!0,"ttu-whispersync-reader-enable-auto-reload":!0,"ttu-whispersync-reader-enable-filesystem-api":!0,"ttu-whispersync-reader-enable-auto-scroll":!0,"ttu-whispersync-reader-enable-tracker-auto-pause":!0,"ttu-whispersync-reader-prevent-action-on-selection":!0,"ttu-whispersync-reader-enable-menu-target":!0,"ttu-whispersync-reader-scroll-mode":"Always","ttu-whispersync-reader-scroll-behavior":"instant","ttu-whispersync-reader-click-action":"None","ttu-whispersync-reader-menu-open-mode":"On click","ttu-whispersync-reader-menu-pause-mode":"Pause on open","ttu-whispersync-reader-menu-open-time":500,"ttu-whispersync-subtitles-enable-persist":!1,"ttu-whispersync-subtitles-enable-auto-scroll":!0,"ttu-whispersync-subtitles-copy-font-family":!0,"ttu-whispersync-subtitles-copy-font-size":!1,"ttu-whispersync-subtitles-copy-line-height":!1,"ttu-whispersync-subtitles-prevent-action-on-selection":!0,"ttu-whispersync-subtitles-click-action":"Restart playback","ttu-whispersync-subtitles-actions-visibility":"On hover","ttu-whispersync-subtitles-actions-visibility-time":500,"ttu-whispersync-subtitles-global-start-padding":0,"ttu-whispersync-subtitles-global-end-padding":0,"ttu-whispersync-subtitles-font-family":"Noto Serif JP","ttu-whispersync-subtitles-font-size":20,"ttu-whispersync-subtitles-line-height":1.65,"ttu-whispersync-player-enable-cover":!0,"ttu-whispersync-player-enable-chapters":!0,"ttu-whispersync-player-enable-wake-lock":!1,"ttu-whispersync-player-enable-subtitle-copy":!1,"ttu-whispersync-player-enable-dictionary-detection":!1,"ttu-whispersync-player-auto-pause-mode":"Disabled","ttu-whispersync-player-rewind-time":5,"ttu-whispersync-player-alt-rewind-time":10,"ttu-whispersync-player-fast-forward-time":5,"ttu-whispersync-player-alt-fast-forward-time":10,"ttu-whispersync-player-playback-rate-decrease-time":.05,"ttu-whispersync-player-playback-rate-increase-time":.05,"ttu-whispersync-export-field-mode":"Insert after","ttu-whispersync-export-audio-processor":"Recorder","ttu-whispersync-export-audio-format":"mp3","ttu-whispersync-export-audio-bitrate":128,"ttu-whispersync-export-cover-format":"auto","ttu-whispersync-export-enable-merge-selection-auto-clear":!1,"ttu-whispersync-enable-ffmpeg-log":!1,"ttu-whispersync-anki-add-subtitle-tag":!1,"ttu-whispersync-anki-add-audio-tag":!1,"ttu-whispersync-anki-enable-open-in-browser":!1,"ttu-whispersync-anki-allow-empty-key-field":!1,"ttu-whispersync-anki-tag-list":"","ttu-whispersync-anki-duplicate-mode":"Disabled","ttu-whispersync-anki-url":"http://localhost:8765","ttu-whispersync-anki-key":"","ttu-whispersync-anki-deck":"","ttu-whispersync-anki-update-deck":"","ttu-whispersync-anki-model":"","ttu-whispersync-anki-update-model":"","ttu-whispersync-anki-sentence-field":"","ttu-whispersync-anki-update-sentence-field":"","ttu-whispersync-anki-sound-field":"","ttu-whispersync-anki-update-sound-field":"","ttu-whispersync-anki-cover-field":"","ttu-whispersync-anki-update-cover-field":"","ttu-whispersync-keybindings-enable-time-fallback":!1,"ttu-whispersync-action-list-of-reader":zc(hd),"ttu-whispersync-action-list-of-subtitles":zc(pd),"ttu-whispersync-action-list-of-footer":zc(jc),"ttu-whispersync-match-line-ignore-rp":!1,"ttu-whispersync-match-line-similarity-threshold":.9,"ttu-whispersync-match-line-max-attempts":50}}function eu(t){return B_[t]}const B_=O_();function zc(t){const e=[],n=[...t.entries()];for(let r=0,{length:i}=n;r<i;r+=1){const[s,o]=n[r];e.push({action:s,enabled:o})}return e}var Nn;(function(t){t.LOAD="LOAD",t.EXEC="EXEC",t.WRITE_FILE="WRITE_FILE",t.READ_FILE="READ_FILE",t.DELETE_FILE="DELETE_FILE",t.RENAME="RENAME",t.CREATE_DIR="CREATE_DIR",t.LIST_DIR="LIST_DIR",t.DELETE_DIR="DELETE_DIR",t.ERROR="ERROR",t.DOWNLOAD="DOWNLOAD",t.PROGRESS="PROGRESS",t.LOG="LOG",t.MOUNT="MOUNT",t.UNMOUNT="UNMOUNT"})(Nn||(Nn={}));const D_=(()=>{let t=0;return()=>t++})(),F_=new Error("ffmpeg is not loaded, call `await ffmpeg.load()` first"),$_=new Error("called FFmpeg.terminate()");class N_{constructor(){zs(this,wi,null);zs(this,Ws,{});zs(this,ks,{});zs(this,Eo,[]);zs(this,So,[]);er(this,"loaded",!1);zs(this,Ic,()=>{dn(this,wi)&&(dn(this,wi).onmessage=({data:{id:e,type:n,data:r}})=>{switch(n){case Nn.LOAD:this.loaded=!0,dn(this,Ws)[e](r);break;case Nn.MOUNT:case Nn.UNMOUNT:case Nn.EXEC:case Nn.WRITE_FILE:case Nn.READ_FILE:case Nn.DELETE_FILE:case Nn.RENAME:case Nn.CREATE_DIR:case Nn.LIST_DIR:case Nn.DELETE_DIR:dn(this,Ws)[e](r);break;case Nn.LOG:dn(this,Eo).forEach(i=>i(r));break;case Nn.PROGRESS:dn(this,So).forEach(i=>i(r));break;case Nn.ERROR:dn(this,ks)[e](r);break}delete dn(this,Ws)[e],delete dn(this,ks)[e]})});zs(this,si,({type:e,data:n},r=[],i)=>dn(this,wi)?new Promise((s,o)=>{const a=D_();dn(this,wi)&&dn(this,wi).postMessage({id:a,type:e,data:n},r),dn(this,Ws)[a]=s,dn(this,ks)[a]=o,i==null||i.addEventListener("abort",()=>{o(new DOMException(`Message # ${a} was aborted`,"AbortError"))},{once:!0})}):Promise.reject(F_));er(this,"load",({classWorkerURL:e,...n}={},{signal:r}={})=>(dn(this,wi)||(Gl(this,wi,e?new Worker(new URL(e,Gn&&Gn.src||new URL("ttu-whispersync.tm.user.js",document.baseURI).href),{type:"module"}):new Worker(new URL(""+new URL("worker-lPYB70QI.js",document.currentScript&&document.currentScript.src||document.baseURI).href,Gn&&Gn.src||new URL("ttu-whispersync.tm.user.js",document.baseURI).href),{type:"module"})),dn(this,Ic).call(this)),dn(this,si).call(this,{type:Nn.LOAD,data:n},void 0,r)));er(this,"exec",(e,n=-1,{signal:r}={})=>dn(this,si).call(this,{type:Nn.EXEC,data:{args:e,timeout:n}},void 0,r));er(this,"terminate",()=>{const e=Object.keys(dn(this,ks));for(const n of e)dn(this,ks)[n]($_),delete dn(this,ks)[n],delete dn(this,Ws)[n];dn(this,wi)&&(dn(this,wi).terminate(),Gl(this,wi,null),this.loaded=!1)});er(this,"writeFile",(e,n,{signal:r}={})=>{const i=[];return n instanceof Uint8Array&&i.push(n.buffer),dn(this,si).call(this,{type:Nn.WRITE_FILE,data:{path:e,data:n}},i,r)});er(this,"mount",(e,n,r)=>{const i=[];return dn(this,si).call(this,{type:Nn.MOUNT,data:{fsType:e,options:n,mountPoint:r}},i)});er(this,"unmount",e=>{const n=[];return dn(this,si).call(this,{type:Nn.UNMOUNT,data:{mountPoint:e}},n)});er(this,"readFile",(e,n="binary",{signal:r}={})=>dn(this,si).call(this,{type:Nn.READ_FILE,data:{path:e,encoding:n}},void 0,r));er(this,"deleteFile",(e,{signal:n}={})=>dn(this,si).call(this,{type:Nn.DELETE_FILE,data:{path:e}},void 0,n));er(this,"rename",(e,n,{signal:r}={})=>dn(this,si).call(this,{type:Nn.RENAME,data:{oldPath:e,newPath:n}},void 0,r));er(this,"createDir",(e,{signal:n}={})=>dn(this,si).call(this,{type:Nn.CREATE_DIR,data:{path:e}},void 0,n));er(this,"listDir",(e,{signal:n}={})=>dn(this,si).call(this,{type:Nn.LIST_DIR,data:{path:e}},void 0,n));er(this,"deleteDir",(e,{signal:n}={})=>dn(this,si).call(this,{type:Nn.DELETE_DIR,data:{path:e}},void 0,n))}on(e,n){e==="log"?dn(this,Eo).push(n):e==="progress"&&dn(this,So).push(n)}off(e,n){e==="log"?Gl(this,Eo,dn(this,Eo).filter(r=>r!==n)):e==="progress"&&Gl(this,So,dn(this,So).filter(r=>r!==n))}}wi=new WeakMap,Ws=new WeakMap,ks=new WeakMap,Eo=new WeakMap,So=new WeakMap,Ic=new WeakMap,si=new WeakMap;const No=[];function V_(t,e){return{subscribe:on(t,e).subscribe}}function on(t,e=wt){let n;const r=new Set;function i(a){if(Cn(t,a)&&(t=a,n)){const l=!No.length;for(const c of r)c[1](),No.push(c,t);if(l){for(let c=0;c<No.length;c+=2)No[c][0](No[c+1]);No.length=0}}}function s(a){i(a(t))}function o(a,l=wt){const c=[a,l];return r.add(c),r.size===1&&(n=e(i,s)||wt),a(t),()=>{r.delete(c),r.size===0&&n&&(n(),n=null)}}return{set:i,update:s,subscribe:o}}function H_(t,e,n){const r=!Array.isArray(t),i=r?[t]:t;if(!i.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");const s=e.length<2;return V_(n,(o,a)=>{let l=!1;const c=[];let u=0,f=wt;const g=()=>{if(u)return;f();const _=e(r?c[0]:c,o,a);s?o(_):f=Ci(_)?_:wt},v=i.map((_,b)=>ns(_,y=>{c[b]=y,u&=~(1<<b),l&&g()},()=>{u|=1<<b}));return l=!0,g(),function(){vn(v),f(),l=!1}})}var _n=(t=>(t.AUDIOBOOK="Audiobook",t.MATCH="Match",t.CHAPTERS="Chapters",t.SETTINGS="Settings",t))(_n||{});function x_(){const{subscribe:t,set:e,update:n}=on([]);return{subscribe:t,set:e,add:r=>{n(i=>(i.push(r),i))}}}function an(t,e=0){return{id:"-1",originalStartSeconds:t,startSeconds:t,startTime:"",originalEndSeconds:e,endSeconds:e,endTime:"",originalText:"",text:"",subIndex:-1}}function tu(t,e){return(n,r)=>{const i=r??eu(n),s=U_()(n,i,t),{subscribe:o,set:a}=on(s);function l(g){window.localStorage.setItem(n,e(g)),a(g)}function c(){let g=i;return o(_=>g=_)(),g}function u(){return n}function f(){return l(i),i}return{subscribe:o,set:l,get:c,key:u,reset:f}}}function U_(){return(t,e,n)=>{const r=window.localStorage.getItem(t);return r?n(r):e}}function $n(){return tu(t=>!!+t,t=>t?"1":"0")}function $r(){return tu(t=>+t,t=>`${t}`)}function W_(t){return tu(e=>JSON.parse(e||t),e=>JSON.stringify(e))}function Xc(){return W_("[]")}function G_(t,e){t(e)}function ur(t){return on(t,e=>G_(e,t))}function Pn(){return tu(t=>t,t=>t)}const Fa=on(!1),nu=on(!1),At=ur(!0),Mt=ur(""),Vo=x_(),En=ur(!1),Ho=on(),Li=ur({id:0,title:"",elementHtml:"",lastBookModified:0}),xo=ur({matchedBy:"",matchedOn:0}),Rr=ur({title:""}),rs=ur(),Lr=ur(new Map),$a=on(),qs=on(""),Na=on(""),Zs=on([]),Ps=on(!1),ru=on(!1),Va=on(!1),Ha=on(0),iu=ur(0),vi=ur(),xi=on(!1),xa=on(""),Ua=on(""),Wa=on(""),Ga=on(""),ja=on(""),Uo=on(""),Wo=on(""),Go=on(""),jo=on(""),zo=on(""),su=on(""),ou=on(""),au=on(""),lu=on(""),za=on(""),Xa=on(""),is=on(""),ss=on(""),os=on(""),Xo=on(""),md=Pn()("ttu-whispersync-menu-position","left"),uu=$n()("ttu-whispersync-hide-footer-actions",!1),Js=ur(_n.AUDIOBOOK),Yo=on(!1),cu=ur(new Set),Ko=on(!1),Ya=ur(new Set),as=ur({previous:"",current:"",useTimeFallback:!0}),Ka=ur(),Mn=ur(!0),Ui=ur(0),ls=ur(0),qa=ur(!1),qo=$r()("ttu-whispersync-player-playback-rate",1),fu=ur(),Za=ur(),_t={readerLineHighlightColor$:Pn()("ttu-whispersync-reader-line-highlight-color"),readerLineTextHighlightColor$:Pn()("ttu-whispersync-reader-line-text-highlight-color"),readerEnableLineHighlight$:$n()("ttu-whispersync-reader-enable-line-highlight"),readerEnableLineTextHighlight$:$n()("ttu-whispersync-reader-enable-line-text-highlight"),readerEnableAutoReload$:$n()("ttu-whispersync-reader-enable-auto-reload"),readerEnableFilesystemApi$:$n()("ttu-whispersync-reader-enable-filesystem-api"),readerEnableAutoScroll$:$n()("ttu-whispersync-reader-enable-auto-scroll"),readerEnableTrackerAutoPause$:$n()("ttu-whispersync-reader-enable-tracker-auto-pause"),readerPreventActionOnSelection$:$n()("ttu-whispersync-reader-prevent-action-on-selection"),readerEnableMenuTarget$:$n()("ttu-whispersync-reader-enable-menu-target"),readerScrollMode$:Pn()("ttu-whispersync-reader-scroll-mode"),readerScrollBehavior$:Pn()("ttu-whispersync-reader-scroll-behavior"),readerClickAction$:Pn()("ttu-whispersync-reader-click-action"),readerMenuOpenMode$:Pn()("ttu-whispersync-reader-menu-open-mode"),readerMenuPauseMode$:Pn()("ttu-whispersync-reader-menu-pause-mode"),readerMenuOpenTime$:$r()("ttu-whispersync-reader-menu-open-time"),readerTrackerPauseThreshold$:$r()("ttu-whispersync-reader-tracker-pause-threshold"),subtitlesEnablePersist$:$n()("ttu-whispersync-subtitles-enable-persist"),subtitlesEnableAutoScroll$:$n()("ttu-whispersync-subtitles-enable-auto-scroll"),subtitlesCopyFontFamily$:$n()("ttu-whispersync-subtitles-copy-font-family"),subtitlesCopyFontSize$:$n()("ttu-whispersync-subtitles-copy-font-size"),subtitlesCopyLineHeight$:$n()("ttu-whispersync-subtitles-copy-line-height"),subtitlePreventActionOnSelection$:$n()("ttu-whispersync-subtitles-prevent-action-on-selection"),subtitlesClickAction$:Pn()("ttu-whispersync-subtitles-click-action"),subtitlesActionsVisibility$:Pn()("ttu-whispersync-subtitles-actions-visibility"),subtitlesActionsVisibilityTime$:$r()("ttu-whispersync-subtitles-actions-visibility-time"),subtitlesGlobalStartPadding$:$r()("ttu-whispersync-subtitles-global-start-padding"),subtitlesGlobalEndPadding$:$r()("ttu-whispersync-subtitles-global-end-padding"),subtitlesFontFamily$:Pn()("ttu-whispersync-subtitles-font-family"),subtitlesFontSize$:$r()("ttu-whispersync-subtitles-font-size"),subtitlesLineHeight$:$r()("ttu-whispersync-subtitles-line-height"),playerEnableCover$:$n()("ttu-whispersync-player-enable-cover"),playerEnableChapters$:$n()("ttu-whispersync-player-enable-chapters"),playerEnableWakeLock$:$n()("ttu-whispersync-player-enable-wake-lock"),playerEnableSubtitleCopy$:$n()("ttu-whispersync-player-enable-subtitle-copy"),playerEnableDictionaryDetection$:$n()("ttu-whispersync-player-enable-dictionary-detection"),playerAutoPauseMode$:Pn()("ttu-whispersync-player-auto-pause-mode"),playerRewindTime$:$r()("ttu-whispersync-player-rewind-time"),playerAltRewindTime$:$r()("ttu-whispersync-player-alt-rewind-time"),playerFastForwardTime$:$r()("ttu-whispersync-player-fast-forward-time"),playerAltFastForwardTime$:$r()("ttu-whispersync-player-alt-fast-forward-time"),playerPlaybackRateDecreaseTime$:$r()("ttu-whispersync-player-playback-rate-decrease-time"),playerPlaybackRateIncreaseTime$:$r()("ttu-whispersync-player-playback-rate-increase-time"),exportFieldMode$:Pn()("ttu-whispersync-export-field-mode"),exportAudioProcessor$:Pn()("ttu-whispersync-export-audio-processor"),exportAudioFormat$:Pn()("ttu-whispersync-export-audio-format"),exportAudioBitrate$:$r()("ttu-whispersync-export-audio-bitrate"),exportCoverFormat$:Pn()("ttu-whispersync-export-cover-format"),exportEnableMergeSelectionAutoClear$:$n()("ttu-whispersync-export-enable-merge-selection-auto-clear"),enableFFMPEGLog$:$n()("ttu-whispersync-enable-ffmpeg-log"),ankiAddSubtitleTag$:$n()("ttu-whispersync-anki-add-subtitle-tag"),ankiAddAudioTag$:$n()("ttu-whispersync-anki-add-audio-tag"),ankiAllowEmptyKeyField$:$n()("ttu-whispersync-anki-allow-empty-key-field"),ankiTagList$:Pn()("ttu-whispersync-anki-tag-list"),ankiDuplicateMode$:Pn()("ttu-whispersync-anki-duplicate-mode"),ankiUrl$:Pn()("ttu-whispersync-anki-url"),ankiKey$:Pn()("ttu-whispersync-anki-key"),ankiDeck$:Pn()("ttu-whispersync-anki-deck"),ankiUpdateDeck$:Pn()("ttu-whispersync-anki-update-deck"),ankiModel$:Pn()("ttu-whispersync-anki-model"),ankiUpdateModel$:Pn()("ttu-whispersync-anki-update-model"),ankiSentenceField$:Pn()("ttu-whispersync-anki-sentence-field"),ankiUpdateSentenceField$:Pn()("ttu-whispersync-anki-update-sentence-field"),ankiSoundField$:Pn()("ttu-whispersync-anki-sound-field"),ankiUpdateSoundField$:Pn()("ttu-whispersync-anki-update-sound-field"),ankiCoverField$:Pn()("ttu-whispersync-anki-cover-field"),ankiUpdateCoverField$:Pn()("ttu-whispersync-anki-update-cover-field"),ankiEnableOpenInBrowser$:$n()("ttu-whispersync-anki-enable-open-in-browser"),actionListOfReader$:Xc()("ttu-whispersync-action-list-of-reader"),actionListOfSubtitles$:Xc()("ttu-whispersync-action-list-of-subtitles"),actionListOfFooter$:Xc()("ttu-whispersync-action-list-of-footer"),keybindingsEnableTimeFallback$:$n()("ttu-whispersync-keybindings-enable-time-fallback"),matchLineIgnoreRp$:$n()("ttu-whispersync-match-line-ignore-rp"),matchLineSimilarityThreshold$:$r()("ttu-whispersync-match-line-similarity-threshold"),matchLineMaxAttempts$:$r()("ttu-whispersync-match-line-max-attempts")};function _d(){return!!window.GM_info&&window.GM_info.scriptHandler==="Tampermonkey"}async function gd({currentTarget:t},e,n){const r=t.hasAttribute("min"),i=t.hasAttribute("max"),s=r?Number.parseFloat(t.min):0,o=i?Number.parseFloat(t.max):0;let a=Number.parseFloat(t.value);(Number.isNaN(a)||r&&a<s||i&&a>o)&&(a=e),await new Promise(l=>setTimeout(l)),n==null||n.set(a),await Mr(),t.value=`${a}`}async function j_({currentTarget:t},e,n){let r=t.value||"";r||(r=e),n==null||n.set(r),await Mr(),t.value=r}class bd extends Error{constructor(){super(...arguments);er(this,"name","AbortError")}}const Ja="ttu-whispersync-line-highlight-",du=new Set(["rp","rt"]);function hu(t,e){let{body:n}=t.parseFromString(e,"text/html");if(n.childNodes.length||({body:n}=t.parseFromString(e,"text/xml")),!n.childNodes.length)throw new Error("Failed to parse html");return n}function Yc(t,e){if(!t.contentWindow)throw new Error("Sandbox has no content window");const n=new MessageChannel;return n.port1.start(),new Promise((r,i)=>{n.port1.addEventListener("message",({data:s})=>{if(n.port1.close(),s.error)return i(new Error(s.error));r(s)},!1),t.contentWindow.postMessage(e,"*",[n.port2])})}function us(t){const e=Math.floor(t/3600),n=t-e*3600,r=Math.floor(n/60),i=n-r*60,s=Math.floor(i),o=Math.round((i-s)*1e3);return[e,r,s,o]}function Qr(t){const[e,n,r,i]=us(t);return`${`${e}`.padStart(2,"0")}:${`${n}`.padStart(2,"0")}:${`${r}`.padStart(2,"0")},${`${i}`.padStart(3,"0")}`}function pu(){return`span[class^='${Ja}']`}function Kc(t){var e;return((e=[...t.classList].find(n=>n.startsWith(Ja)))==null?void 0:e.replace(Ja,""))||"not existing"}function Qs(t){return`span.${Ja}${t}`}function z_(t){return`${Ja}${t}`}function X_(t,e){return gd(t,e,void 0)}function wd(t,e){return gd(t,eu(e.key()),e)}function Y_(t,e){return j_(t,eu(e.key()),e)}function Wi(t,e,n){return Math.min(e,Math.max(n,t))}function mu(t){if(t){if(typeof t.throwIfAborted=="function")t.throwIfAborted();else if(t.aborted)throw new bd("user aborted")}}function _u(t,e,n,r=!1){const i=t.createElement("a");i.href=URL.createObjectURL(e),r?i.target="_blank":(i.rel="noopener",i.download=n),setTimeout(()=>{URL.revokeObjectURL(i.href)},1e4),setTimeout(()=>{i.click()})}function eo(t){const[e,n,r]=us(t);return`${`${e}`.padStart(2,"0")}:${`${n}`.padStart(2,"0")}:${`${r}`.padStart(2,"0")}`}function Qa(t,e,n=!0){return!t||!e?0:n?Math.floor(t/e*100):Math.round((t/e*100+Number.EPSILON)*100)/100}function K_(t){const e=t.split(":"),n=Number.parseInt(e[0],10),r=Number.parseInt(e[1],10),i=Number.parseInt(e[2],10);return Math.floor(n*3600)+Math.floor(r*60)+i}function yd(t){return`${t.getFullYear()}-${`${t.getMonth()+1}`.padStart(2,"0")}-${`${t.getDate()}`.padStart(2,"0")}`}const qc="data:text/javascript;base64,KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IFI9Imh0dHBzOi8vdW5wa2cuY29tL0BmZm1wZWcvY29yZUAwLjEyLjYvZGlzdC91bWQvZmZtcGVnLWNvcmUuanMiO3ZhciBFOyhmdW5jdGlvbih0KXt0LkxPQUQ9IkxPQUQiLHQuRVhFQz0iRVhFQyIsdC5XUklURV9GSUxFPSJXUklURV9GSUxFIix0LlJFQURfRklMRT0iUkVBRF9GSUxFIix0LkRFTEVURV9GSUxFPSJERUxFVEVfRklMRSIsdC5SRU5BTUU9IlJFTkFNRSIsdC5DUkVBVEVfRElSPSJDUkVBVEVfRElSIix0LkxJU1RfRElSPSJMSVNUX0RJUiIsdC5ERUxFVEVfRElSPSJERUxFVEVfRElSIix0LkVSUk9SPSJFUlJPUiIsdC5ET1dOTE9BRD0iRE9XTkxPQUQiLHQuUFJPR1JFU1M9IlBST0dSRVNTIix0LkxPRz0iTE9HIix0Lk1PVU5UPSJNT1VOVCIsdC5VTk1PVU5UPSJVTk1PVU5UIn0pKEV8fChFPXt9KSk7Y29uc3QgYT1uZXcgRXJyb3IoInVua25vd24gbWVzc2FnZSB0eXBlIiksZj1uZXcgRXJyb3IoImZmbXBlZyBpcyBub3QgbG9hZGVkLCBjYWxsIGBhd2FpdCBmZm1wZWcubG9hZCgpYCBmaXJzdCIpLHU9bmV3IEVycm9yKCJmYWlsZWQgdG8gaW1wb3J0IGZmbXBlZy1jb3JlLmpzIik7bGV0IHI7Y29uc3QgTz1hc3luYyh7Y29yZVVSTDp0LHdhc21VUkw6bix3b3JrZXJVUkw6ZX0pPT57Y29uc3Qgbz0hcjt0cnl7dHx8KHQ9UiksaW1wb3J0U2NyaXB0cyh0KX1jYXRjaHtpZih0fHwodD1SLnJlcGxhY2UoIi91bWQvIiwiL2VzbS8iKSksc2VsZi5jcmVhdGVGRm1wZWdDb3JlPShhd2FpdCBpbXBvcnQodCkpLmRlZmF1bHQsIXNlbGYuY3JlYXRlRkZtcGVnQ29yZSl0aHJvdyB1fWNvbnN0IHM9dCxjPW58fHQucmVwbGFjZSgvLmpzJC9nLCIud2FzbSIpLGI9ZXx8dC5yZXBsYWNlKC8uanMkL2csIi53b3JrZXIuanMiKTtyZXR1cm4gcj1hd2FpdCBzZWxmLmNyZWF0ZUZGbXBlZ0NvcmUoe21haW5TY3JpcHRVcmxPckJsb2I6YCR7c30jJHtidG9hKEpTT04uc3RyaW5naWZ5KHt3YXNtVVJMOmMsd29ya2VyVVJMOmJ9KSl9YH0pLHIuc2V0TG9nZ2VyKGk9PnNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6RS5MT0csZGF0YTppfSkpLHIuc2V0UHJvZ3Jlc3MoaT0+c2VsZi5wb3N0TWVzc2FnZSh7dHlwZTpFLlBST0dSRVNTLGRhdGE6aX0pKSxvfSxsPSh7YXJnczp0LHRpbWVvdXQ6bj0tMX0pPT57ci5zZXRUaW1lb3V0KG4pLHIuZXhlYyguLi50KTtjb25zdCBlPXIucmV0O3JldHVybiByLnJlc2V0KCksZX0sbT0oe3BhdGg6dCxkYXRhOm59KT0+KHIuRlMud3JpdGVGaWxlKHQsbiksITApLEQ9KHtwYXRoOnQsZW5jb2Rpbmc6bn0pPT5yLkZTLnJlYWRGaWxlKHQse2VuY29kaW5nOm59KSxTPSh7cGF0aDp0fSk9PihyLkZTLnVubGluayh0KSwhMCksST0oe29sZFBhdGg6dCxuZXdQYXRoOm59KT0+KHIuRlMucmVuYW1lKHQsbiksITApLEw9KHtwYXRoOnR9KT0+KHIuRlMubWtkaXIodCksITApLE49KHtwYXRoOnR9KT0+e2NvbnN0IG49ci5GUy5yZWFkZGlyKHQpLGU9W107Zm9yKGNvbnN0IG8gb2Ygbil7Y29uc3Qgcz1yLkZTLnN0YXQoYCR7dH0vJHtvfWApLGM9ci5GUy5pc0RpcihzLm1vZGUpO2UucHVzaCh7bmFtZTpvLGlzRGlyOmN9KX1yZXR1cm4gZX0sQT0oe3BhdGg6dH0pPT4oci5GUy5ybWRpcih0KSwhMCksdz0oe2ZzVHlwZTp0LG9wdGlvbnM6bixtb3VudFBvaW50OmV9KT0+e2NvbnN0IG89dCxzPXIuRlMuZmlsZXN5c3RlbXNbb107cmV0dXJuIHM/KHIuRlMubW91bnQocyxuLGUpLCEwKTohMX0saz0oe21vdW50UG9pbnQ6dH0pPT4oci5GUy51bm1vdW50KHQpLCEwKTtzZWxmLm9ubWVzc2FnZT1hc3luYyh7ZGF0YTp7aWQ6dCx0eXBlOm4sZGF0YTplfX0pPT57Y29uc3Qgbz1bXTtsZXQgczt0cnl7aWYobiE9PUUuTE9BRCYmIXIpdGhyb3cgZjtzd2l0Y2gobil7Y2FzZSBFLkxPQUQ6cz1hd2FpdCBPKGUpO2JyZWFrO2Nhc2UgRS5FWEVDOnM9bChlKTticmVhaztjYXNlIEUuV1JJVEVfRklMRTpzPW0oZSk7YnJlYWs7Y2FzZSBFLlJFQURfRklMRTpzPUQoZSk7YnJlYWs7Y2FzZSBFLkRFTEVURV9GSUxFOnM9UyhlKTticmVhaztjYXNlIEUuUkVOQU1FOnM9SShlKTticmVhaztjYXNlIEUuQ1JFQVRFX0RJUjpzPUwoZSk7YnJlYWs7Y2FzZSBFLkxJU1RfRElSOnM9TihlKTticmVhaztjYXNlIEUuREVMRVRFX0RJUjpzPUEoZSk7YnJlYWs7Y2FzZSBFLk1PVU5UOnM9dyhlKTticmVhaztjYXNlIEUuVU5NT1VOVDpzPWsoZSk7YnJlYWs7ZGVmYXVsdDp0aHJvdyBhfX1jYXRjaChjKXtzZWxmLnBvc3RNZXNzYWdlKHtpZDp0LHR5cGU6RS5FUlJPUixkYXRhOmMudG9TdHJpbmcoKX0pO3JldHVybn1zIGluc3RhbmNlb2YgVWludDhBcnJheSYmby5wdXNoKHMuYnVmZmVyKSxzZWxmLnBvc3RNZXNzYWdlKHtpZDp0LHR5cGU6bixkYXRhOnN9LG8pfX0pKCk7Cg==",Pr=new N_,q_=!!window.chrome&&!!chrome.runtime&&chrome.runtime.id,Z_=!!window.GM_info&&window.GM_info.scriptHandler==="Tampermonkey",vd="ttu-whispersync-tampermonkey",Ed=new Map([["ogg","libvorbis"],["opus","opus"],["mp3","libmp3lame"]]),J_=/chapter.+start (\d+\.\d+), end/i,Q_=/title.+:(.+)/i,gu=new Map([["ffmpeg-core.wasm",{url:"https://cdn.jsdelivr.net/npm/@ffmpeg/[email protected]/dist/esm/ffmpeg-core.wasm",version:"0.12.6"}]]);let el={key:"",label:"",startSeconds:0,startText:""},bu=[],wu=!0;async function Zc(t,e,n){const r=Z_&&gu.has(t);let i;if(r)try{const s=await caches.open(vd),o=await s.keys(),a=[];for(const l of o)if(l.url===e){const c=await s.match(l.url);i=await(c==null?void 0:c.arrayBuffer())}else l.url.endsWith(t)&&a.push(l);await Promise.allSettled(a.map(l=>s.delete(l)))}catch({message:s}){throw new Error(`Failed to get cached data for ${t}: ${s}`)}if(i||(i=await fetch(e).then(async s=>{if(!s.ok)throw new Error(`Failed to download from ${e}`);if(r)try{await(await caches.open(vd)).add(e)}catch{}return s.arrayBuffer()})),!i)throw new Error(`Failed to get data for ${t}`);return URL.createObjectURL(new Blob([i],{type:n}))}function Jc(t,e="text/javascript"){if(t===qc)return Zc(t,qc,e);if(q_)return Zc(t,chrome.runtime.getURL(`src/assets/js/${t}`),e);if(!gu.has(t)||window.GM_info.scriptHandler==="Violentmonkey")return window.GM_getResourceURL(t);if(gu.has(t))return Zc(t,gu.get(t).url,e);throw new Error(`No data found for resource ${t}`)}function Sd(t){try{if(wu){const e=t.message.match(J_);if((e==null?void 0:e.length)===2){const n=Number.parseFloat(e[1]);el.startSeconds=n,wu=!1}}else if(!wu){const e=t.message.match(Q_);if((e==null?void 0:e.length)===2){const n=e[1].trim(),{startSeconds:r}=el;el={key:`${n}_${r}`,label:n,startSeconds:r,startText:eo(r)},bu.push(el),Qc()}}}catch{Qc()}}function Qc(t=!1){el={key:"",label:"",startSeconds:0,startText:""},wu=!0,t&&(bu=[])}function Td(t){console.log(t.type,t.message)}async function kd(){if(Pr.loaded)return;const t=[];try{const e=[],n=await Promise.allSettled([Jc("ffmpeg-core.js"),Jc("ffmpeg-core.wasm","application/wasm"),Jc(qc)]);for(let r=0,{length:i}=n;r<i;r+=1){const s=n[r];s.status==="rejected"?e.push(s.reason.message):t.push(s.value)}if(e.length)throw new Error(e.join("; "));await Pr.load({coreURL:t[0],wasmURL:t[1],classWorkerURL:t[2]})}catch(e){_t.exportAudioProcessor$.set(kr.RECORDER);let n="Unknown error";throw typeof e=="string"?n=e:e!=null&&e.message&&(n=e.message),new Error(`Error loading FFMPEG - ${n}`)}finally{for(let e=0,{length:n}=t;e<n;e+=1)URL.revokeObjectURL(t[e])}}async function Ad(t){if(Pr.loaded)try{if(await e1(!0),t){const e=t.name.split(".").pop(),n=await t.arrayBuffer();await Pr.writeFile(`audio_input.${e}`,new Uint8Array(n))}}catch({message:e}){throw new Error(`Failed to update files in FFMPEG - ${e}`)}}async function e1(t=!1){if(!Pr.loaded)return;const n=(await Pr.listDir("/")).filter(r=>!r.isDir&&(t&&r.name.startsWith("audio_input")||r.name.startsWith("audio_output")));return Promise.allSettled(n.map(r=>Pr.deleteFile(r.name)))}async function t1(t){if(Qc(!0),!Pr.loaded)return bu;try{const n=["-hide_banner","-y","-i",`audio_input.${t.name.split(".").pop()}`];Pr.on("log",Sd),await Pr.exec(n)}catch({message:e}){console.log(`Failed to get chapter data with ffmpeg: ${e}`)}return Pr.off("log",Sd),bu}async function Cd(t,e,n=!0,r=void 0,i="mp3",s=128,o=!1){const a=t.name.split(".").pop(),l=Ct(_t.enableFFMPEGLog$),c=e.length===1?`audio_output_0.${i}`:`audio_output.${i}`;let u="",f="",g=[],v;try{l&&Pr.on("log",Td);for(let b=0,{length:y}=e;b<y;b+=1){mu(r);const p=e[b],m=`audio_output_${b}.${i}`,w=["-hide_banner","-y","-ss",`${p.startSeconds}`,"-i",`audio_input.${a}`,"-t",`${p.endSeconds-p.startSeconds}`,...i===Rs.OPUS?["-strict","-2"]:[],"-vn","-acodec",Ed.get(i)||"libmp3lame",...o?["-b:a",`${s}k`]:[],"-write_xing","0",m];l&&console.log(w),g.push("-i",m),f+=`[${b}:a]`,await Pr.exec(w)}if(e.length>1){g.push("-filter_complex"),f=`${f}concat=n=${e.length}:v=0:a=1`;const b=["-hide_banner","-y",...g,f,...i===Rs.OPUS?["-strict","-2"]:[],"-vn","-acodec",Ed.get(i)||"libmp3lame",...o?["-b:a",`${s}k`]:[],"-write_xing","0",c];l&&console.log(b),await Pr.exec(b)}v=(await Pr.readFile(c)).buffer}catch(_){!(r&&r.aborted)&&_.name!=="AbortError"&&(u=typeof _=="string"?`Audio creation failed - ${_}`:`Audio creation failed${_.message?` - ${_.message}`:""}`)}if(n&&await e1(),l&&Pr.off("log",Td),u)throw new Error(u);return mu(r),v}function eg(){Pr.loaded&&Pr.terminate()}let n1=!1,tl="";async function Yr(t,e,n=!0){if(n&&await tg(t),(e==null?void 0:e.action)==="multi"&&tl)for(let r=0,{length:i}=e.params.actions;r<i;r+=1)e.params.actions[r].key=tl;return fetch(t,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify({...e,version:6,...tl?{key:tl}:{}})}).then(r=>{if(!r.ok)throw new Error(`Request failed with status ${r.status}`);return r.json()}).then(r=>{let i=new Set;if(r.error&&i.add(r.error),(e==null?void 0:e.action)==="multi"&&Array.isArray(r.result))for(let s=0,{length:o}=r.result;s<o;s+=1){const{error:a}=r.result[s];a&&i.add(a)}if(i.size)throw new Error([...i].join("; "));return r.result})}async function tg(t){if(n1)return;const e=await Yr(t,{action:"requestPermission"},!1).catch(n=>{if(n.message.includes("com.google.gson.stream.MalformedJsonException"))return Va.set(!0),{permission:"granted",requireApikey:!1,version:6};throw n});if(typeof e!="string"&&e.permission!=="granted")throw new Error("Anki permission not granted");return n1=!0,e}async function ng(t,e,n,r,i,s,o,a,l,c,u,f){if(!t||!e||!r||!s&&!a)return{isOutdatedVersion:!1,isAnkiConfigValid:!1,ankiFields:[]};let g=[],v=!1,_=!0;try{v=await Yr(t,{action:"apiReflect",params:{scopes:["actions"],actions:["updateNote"]}}).then(()=>!1).catch(()=>!0);const[b,y]=await Rd(t);b.find(p=>e===p)||(n.set(""),_=!1),y.find(p=>r===p)||(i.set(""),_=!1),_&&(g=await Ld(t,r),s&&!g.find(p=>p===s)&&(o.set(""),_=!1),a&&!g.find(p=>p===a)&&(l.set(""),_=!1),c&&!g.find(p=>p===c)&&(u.set(""),_=!1))}catch({message:b}){Pd(f),Mt.set(`Failed to verify Anki settings for card ${f?"update":"creation"}: ${b}`),_=!1,g=[]}return{isOutdatedVersion:v,isAnkiConfigValid:_,ankiFields:g}}async function rg(t,e,n){if(e)return;const r=await Yr(t,{action:"guiSelectedNotes"}).catch(()=>[]);return r.length&&n?await Yr(t,{action:"guiBrowse",params:{query:"nid:1"}}):r.length&&await Yr(t,{action:"guiSelectNote",params:{note:"1"}}),r[r.length-1]}async function Md(t,e){const n=t.encode(e),r=await window.crypto.subtle.digest("SHA-1",n);return Array.from(new Uint8Array(r)).map(s=>s.toString(16).padStart(2,"0")).join("").trim()}function ig(t){return new Promise((e,n)=>{var l,c;const r=document.createElement("canvas"),i=document.querySelector("#ttu-whispersync-cover");if(!i)return n(new Error("cover element not found"));r.width=i.naturalWidth,r.height=i.naturalHeight;const s=r.getContext("2d");if(!s)return n(new Error("canvas context undefined"));s.drawImage(i,0,0);const o=r.toDataURL(t),a=((c=(l=o.match(/data:image\/(?<ext>.+);/))==null?void 0:l.groups)==null?void 0:c.ext)||"jpeg";e([o.split(",")[1],a])})}function yu(t,e,n){let r="";return t===Ls.BEFORE?r=`${n}${n&&e?"<br/>":""}${e}`:t===Ls.AFTER?r=`${e}${n&&e?"<br/>":""}${n}`:r=n,r}async function sg(t,e,n){if(e)return n?Yr(t,{action:"guiBrowse",params:{query:`"note:${n}"`}}).catch(()=>{}):Yr(t,{action:"guiSelectNote",params:{note:e}}).catch(()=>{})}function og(t){tl=t}function Rd(t){return Yr(t,{action:"multi",params:{actions:[{action:"deckNames"},{action:"modelNames"}]}})}function Ld(t,e){return Yr(t,{action:"modelFieldNames",params:{modelName:e}})}function Pd(t){t?(_t.ankiUpdateDeck$.set(""),_t.ankiUpdateModel$.set(""),_t.ankiUpdateSentenceField$.set(""),_t.ankiUpdateSoundField$.set("")):(_t.ankiDeck$.set(""),_t.ankiModel$.set(""),_t.ankiSentenceField$.set(""),_t.ankiSoundField$.set(""),_t.ankiCoverField$.set("")),n1=!1}async function ag(t,e,n){var Me,Ee;const r=new AbortController,i=Ct(rs),s=Ct(_t.exportAudioProcessor$)===kr.FFMPEG;if(!i)return;s||Mn.set(!0),Mt.set(""),iu.set(0),vi.set(r);const o=Ct($a),a=Ct(qs),l=Ct(_t.exportAudioFormat$),c=Ct(_t.exportAudioBitrate$),u=Ct(_t.exportCoverFormat$),f=Ct(_t.exportFieldMode$),g=Ct(_t.ankiAddSubtitleTag$),v=Ct(_t.ankiAddAudioTag$),_=Ct(_t.ankiTagList$).trim(),b=_?_.split(",").map(ve=>ve.trim().replaceAll(" ","_").trim()):[],y=Ct(_t.ankiDuplicateMode$),p=e&&(!!Ct(_t.ankiUpdateSentenceField$)||!!Ct(_t.ankiUpdateSoundField$)),m=p?_t.ankiUpdateDeck$:_t.ankiDeck$,w=p?_t.ankiUpdateModel$:_t.ankiModel$,C=p?_t.ankiUpdateSentenceField$:_t.ankiSentenceField$,h=p?_t.ankiUpdateSoundField$:_t.ankiSoundField$,A=p?_t.ankiUpdateCoverField$:_t.ankiCoverField$,L=Ct(_t.ankiUrl$),$=Ct(m),P=Ct(w),I=Ct(C),x=Ct(h),ae=Ct(A),V=Ct(_t.ankiEnableOpenInBrowser$),{isOutdatedVersion:E,isAnkiConfigValid:F,ankiFields:N}=await ng(L,$,m,P,w,I,C,x,h,ae,A,e),Y=Ct(Va),K=y===di.DISABLED&&Ct(_t.ankiAllowEmptyKeyField$);let J;if(!F){const ve=Ct(Mt);return Mt.set(`${ve?`${ve}; `:""}${F?"":`Anki ${e?"update":"create"} settings are invalid`}`)}if(e)try{const ve=await Yr(L,{action:"findNotes",params:{query:`added:1 "deck:${$}" "note:${P}"`}}),ke=ve[ve.length-1];if(!ke)throw new Error("No card added today");if([J]=await Yr(L,{action:"notesInfo",params:{notes:[ke]}}),!J)throw new Error("Data for last added card not available")}catch({message:ve}){return Mt.set(`Failed to get card for update: ${ve}`)}const j=await rg(L,Y,E),B=i.name.split(/\.(?=[^\.]+$)/)[0],M=o?o.name.split(/\.(?=[^\.]+$)/)[0]:"";let S=0,R="",X="",re="",W="",z=0;try{const ve=new TextEncoder;R=await Md(ve,M),X=await Md(ve,`${M}_cover`)}catch{R=B}try{a&&ae&&(u===$o.AUTO?W=await fetch(a).then(ve=>{if(!ve.ok)throw new Error("Failed to fetch cover");return ve.blob()}).then(ve=>(re=ve.type.replace("image/","")||"jpeg",ve.arrayBuffer())).then(ve=>Gc.from(ve).toString("base64")):[W,re]=await ig(`image/${u}`))}catch({message:ve}){return Mt.set(`Failed to get cover: ${ve}`)}Ha.set(0);for(let ve=0,{length:ke}=t;ve<ke;ve+=1){mu(r.signal);const Ne=t[ve],Te=`${R}-${Ne[0].id}${Ne.length>1?`-${Ne[Ne.length-1].id}`:""}.${l}`,Le=Ne.map(xe=>xe.text.trim()).join("<br/>")||"",Fe=new Set(J?J.tags:[]),Ze={note:{fields:{},tags:[]}};let O="",H="",Pe;try{if(x&&o){if(s?Pe=await Cd(o,Ne,!1,r.signal,l,c,!0):Pe=await new Promise((je,et)=>fu.set({subtitles:Ne,action:Re.TOGGLE_PLAY_PAUSE,recorderSuccess:je,recorderFailure:et})),!Pe)throw new Error("No audio file returned");H=Gc.from(Pe).toString("base64")}g&&Fe.add(B.trim().replaceAll(" ","_").trim()),v&&M&&Fe.add(M.trim().replaceAll(" ","_").trim());const xe=[...new Set([...Fe,...b])],qe=y!==di.DISABLED?{allowDuplicate:!1,duplicateScope:y===di.DECK||y===di.SUBDECK?"deck":"collection",duplicateScopeOptions:{checkChildren:y===di.SUBDECK}}:{allowDuplicate:!0};qe.duplicateScopeOptions&&y===di.DECK&&(qe.duplicateScopeOptions.deckName=$),Ze.note=J?{...Ze.note,id:J.noteId,tags:xe}:{...Ze.note,deckName:$,modelName:P,options:qe,tags:xe};for(let je=0,{length:et}=N;je<et;je+=1){const rt=N[je],Je=rt===I&&Le,G=rt===x&&H,T=rt===ae&&W,d=J&&((Me=J.fields[rt])==null?void 0:Me.value)||"";if(Je||G||T){let k="";if(Je&&(k+=Le),T){const D=await Yr(L,{action:"storeMediaFile",params:{data:W,filename:`${X}.${re}`}});k=yu(Ls.AFTER,k,`<img src="${D}">`)}if(G){const D=await Yr(L,{action:"storeMediaFile",params:{data:H,filename:Te}});k=yu(Ls.AFTER,k,`[sound:${D}]`)}Ze.note.fields[rt]=yu(f,d,k)}else Ze.note.fields[rt]=d}const nt=!((Ee=Ze.note.fields[N[0]])!=null&&Ee.trim());if(nt&&K)Ze.note.fields[N[0]]=yu(f,"","&#8203;");else if(nt)throw new Error("cannot process note because it is empty");e?O=Y||E?"updateNoteFields":"updateNote":O="addNote";const Oe=await Yr(L,{action:O,params:Ze});if(!e&&!Oe)throw new Error("Got failure response");J?z=J.noteId:typeof Oe=="number"&&(z=Oe)}catch(xe){if(!r.signal.aborted&&xe.name!=="AbortError")console.log(`Failed to create card for subtitle(s) ${Ne.map(qe=>qe.id).join(", ")}: ${xe.message}`),S+=1;else break}iu.set(Math.min(100,Qa(ve+1,ke)))}const le=z&&!Y;await e1(),le&&Ha.set(z),le&&V?await Id(L,z):await sg(L,j,E?P:void 0),S?Mt.set(`${S} Export(s) failed`):n&&Ct(_t.exportEnableMergeSelectionAutoClear$)&&Ya.set(new Set)}function Id(t,e=0){return e||Ct(Ha)?Yr(t,{action:"guiBrowse",params:{query:`nid:${e||Ct(Ha)}`}}).catch(({message:r})=>console.log(`Failed to open Anki browser: ${r}`)):Promise.resolve([0])}const lg=t=>({}),Od=t=>({}),ug=t=>({}),Bd=t=>({}),cg=t=>({}),Dd=t=>({});function fg(t){let e,n,r,i,s,o,a;const l=t[1].header,c=Mo(l,t,t[0],Dd),u=t[1].content,f=Mo(u,t,t[0],Bd),g=t[1].footer,v=Mo(g,t,t[0],Od);return{c(){e=_e("section"),n=_e("h2"),c&&c.c(),r=me(),i=_e("div"),f&&f.c(),s=me(),o=_e("footer"),v&&v.c(),ie(n,"class","weight-medium mb-5 text-xl"),ie(i,"class","slot-content"),ie(o,"class","flex flex-wrap items-center justify-end pt-5"),ie(e,"class","mdc-elevation--z24 p-6 rounded")},m(_,b){he(_,e,b),oe(e,n),c&&c.m(n,null),oe(e,r),oe(e,i),f&&f.m(i,null),oe(e,s),oe(e,o),v&&v.m(o,null),a=!0},p(_,[b]){c&&c.p&&(!a||b&1)&&Lo(c,l,_,_[0],a?Ro(l,_[0],b,cg):Po(_[0]),Dd),f&&f.p&&(!a||b&1)&&Lo(f,u,_,_[0],a?Ro(u,_[0],b,ug):Po(_[0]),Bd),v&&v.p&&(!a||b&1)&&Lo(v,g,_,_[0],a?Ro(g,_[0],b,lg):Po(_[0]),Od)},i(_){a||(Z(c,_),Z(f,_),Z(v,_),a=!0)},o(_){ne(c,_),ne(f,_),ne(v,_),a=!1},d(_){_&&de(e),c&&c.d(_),f&&f.d(_),v&&v.d(_)}}}function dg(t,e,n){let{$$slots:r={},$$scope:i}=e;return t.$$set=s=>{"$$scope"in s&&n(0,i=s.$$scope)},[i,r]}class vu extends Dn{constructor(e){super(),Bn(this,e,dg,fg,Cn,{})}}var hg="M18,16V13H15V22H13V2H15V11H18V8L22,12L18,16M2,12L6,16V13H9V22H11V2H9V11H6V8L2,12Z",pg="M13 20.5C13 21.03 13.09 21.53 13.26 22H6C4.89 22 4 21.11 4 20V4C4 2.9 4.89 2 6 2H7V9L9.5 7.5L12 9V2H18C19.1 2 20 2.89 20 4V11H16.5V16.11C14.5 16.57 13 18.36 13 20.5M20 13H18.5V18.21C18.19 18.07 17.86 18 17.5 18C16.12 18 15 19.12 15 20.5S16.12 23 17.5 23 20 21.88 20 20.5V15H22V13H20Z",nl="M12 2C17.5 2 22 6.5 22 12S17.5 22 12 22 2 17.5 2 12 6.5 2 12 2M12 4C10.1 4 8.4 4.6 7.1 5.7L18.3 16.9C19.3 15.5 20 13.8 20 12C20 7.6 16.4 4 12 4M16.9 18.3L5.7 7.1C4.6 8.4 4 10.1 4 12C4 16.4 7.6 20 12 20C13.9 20 15.6 19.4 16.9 18.3Z",Fd="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z",mg="M0.41,13.41L6,19L7.41,17.58L1.83,12M22.24,5.58L11.66,16.17L7.5,12L6.07,13.41L11.66,19L23.66,7M18,7L16.59,5.58L10.24,11.93L11.66,13.34L18,7Z",$d="M21 13.1C20.9 13.1 20.7 13.2 20.6 13.3L19.6 14.3L21.7 16.4L22.7 15.4C22.9 15.2 22.9 14.8 22.7 14.6L21.4 13.3C21.3 13.2 21.2 13.1 21 13.1M19.1 14.9L13 20.9V23H15.1L21.2 16.9L19.1 14.9M11 21.9C5.9 21.4 2 17.1 2 12C2 6.5 6.5 2 12 2C17.3 2 21.6 6.1 22 11.3C21.7 11.2 21.4 11.1 21 11.1C20.2 11.1 19.6 11.5 19.2 11.9L16.5 14.6L12.5 12.2V7H11V13L15.4 15.7L11 20.1V21.9Z",Nd="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",Eu="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z",rl="M18,14H20V17H23V19H20V22H18V19H15V17H18V14M12,3C16.42,3 20,4.79 20,7C20,9.21 16.42,11 12,11C7.58,11 4,9.21 4,7C4,4.79 7.58,3 12,3M4,9C4,11.21 7.58,13 12,13C16.42,13 20,11.21 20,9V9L20,12.08L19,12C16.41,12 14.2,13.64 13.36,15.94L12,16C7.58,16 4,14.21 4,12V9M4,14C4,16.21 7.58,18 12,18H13C13,19.05 13.27,20.04 13.75,20.9L12,21C7.58,21 4,19.21 4,17V14Z",_g="M15.46,15.88L16.88,14.46L19,16.59L21.12,14.47L22.53,15.88L20.41,18L22.54,20.12L21.12,21.54L19,19.41L16.88,21.53L15.47,20.12L17.59,18L15.46,15.88M12,3C16.42,3 20,4.79 20,7C20,9.21 16.42,11 12,11C7.58,11 4,9.21 4,7C4,4.79 7.58,3 12,3M4,9C4,11.21 7.58,13 12,13C16.42,13 20,11.21 20,9V12.08L19,12C16.41,12 14.2,13.64 13.36,15.94L12,16C7.58,16 4,14.21 4,12V9M4,14C4,16.21 7.58,18 12,18H13C13,19.05 13.27,20.04 13.75,20.9L12,21C7.58,21 4,19.21 4,17V14Z",il="M19,12V13.5A4,4 0 0,1 23,17.5C23,18.32 22.75,19.08 22.33,19.71L21.24,18.62C21.41,18.28 21.5,17.9 21.5,17.5A2.5,2.5 0 0,0 19,15V16.5L16.75,14.25L19,12M19,23V21.5A4,4 0 0,1 15,17.5C15,16.68 15.25,15.92 15.67,15.29L16.76,16.38C16.59,16.72 16.5,17.1 16.5,17.5A2.5,2.5 0 0,0 19,20V18.5L21.25,20.75L19,23M12,3C16.42,3 20,4.79 20,7C20,9.21 16.42,11 12,11C7.58,11 4,9.21 4,7C4,4.79 7.58,3 12,3M4,9C4,11.21 7.58,13 12,13C13.11,13 14.17,12.89 15.14,12.68C14.19,13.54 13.5,14.67 13.18,15.96L12,16C7.58,16 4,14.21 4,12V9M20,9V11H19.5L18.9,11.03C19.6,10.43 20,9.74 20,9M4,14C4,16.21 7.58,18 12,18L13,17.97C13.09,19.03 13.42,20 13.95,20.88L12,21C7.58,21 4,19.21 4,17V14Z",gg="M12,14A2,2 0 0,1 14,16A2,2 0 0,1 12,18A2,2 0 0,1 10,16A2,2 0 0,1 12,14M23.46,8.86L21.87,15.75L15,14.16L18.8,11.78C17.39,9.5 14.87,8 12,8C8.05,8 4.77,10.86 4.12,14.63L2.15,14.28C2.96,9.58 7.06,6 12,6C15.58,6 18.73,7.89 20.5,10.72L23.46,8.86Z",bg="M15 13H16.5V15.82L18.94 17.23L18.19 18.53L15 16.69V13M23 16C23 19.87 19.87 23 16 23C14.09 23 12.36 22.24 11.1 21H8C6.9 21 6 20.1 6 19V7H18V9.29C20.89 10.15 23 12.83 23 16M16 11C13.24 11 11 13.24 11 16C11 18.76 13.24 21 16 21C18.76 21 21 18.76 21 16C21 13.24 18.76 11 16 11M19 4V6H5V4H8.5L9.5 3H14.5L15.5 4H19Z",wg="M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19M8,9H16V19H8V9M15.5,4L14.5,3H9.5L8.5,4H5V6H19V4H15.5Z",yg="M15,16H19V18H15V16M15,8H22V10H15V8M15,12H21V14H15V12M3,18A2,2 0 0,0 5,20H11A2,2 0 0,0 13,18V8H3V18M14,5H11L10,4H6L5,5H2V7H14V5Z",r1="M19,10H5V8H19V10M19,16H5V14H19V16Z",Vd="M2,5.27L3.28,4L20,20.72L18.73,22L15.65,18.92C14.5,19.3 13.28,19.5 12,19.5C7,19.5 2.73,16.39 1,12C1.69,10.24 2.79,8.69 4.19,7.46L2,5.27M12,9A3,3 0 0,1 15,12C15,12.35 14.94,12.69 14.83,13L11,9.17C11.31,9.06 11.65,9 12,9M12,4.5C17,4.5 21.27,7.61 23,12C22.18,14.08 20.79,15.88 19,17.19L17.58,15.76C18.94,14.82 20.06,13.54 20.82,12C19.17,8.64 15.76,6.5 12,6.5C10.91,6.5 9.84,6.68 8.84,7L7.3,5.47C8.74,4.85 10.33,4.5 12,4.5M3.18,12C4.83,15.36 8.24,17.5 12,17.5C12.69,17.5 13.37,17.43 14,17.29L11.72,15C10.29,14.85 9.15,13.71 9,12.28L5.6,8.87C4.61,9.72 3.78,10.78 3.18,12Z",Hd="M12,9A3,3 0 0,1 15,12A3,3 0 0,1 12,15A3,3 0 0,1 9,12A3,3 0 0,1 12,9M12,4.5C17,4.5 21.27,7.61 23,12C21.27,16.39 17,19.5 12,19.5C7,19.5 2.73,16.39 1,12C2.73,7.61 7,4.5 12,4.5M3.18,12C4.83,15.36 8.24,17.5 12,17.5C15.76,17.5 19.17,15.36 20.82,12C19.17,8.64 15.76,6.5 12,6.5C8.24,6.5 4.83,8.64 3.18,12Z",Su="M13.09 20C13.21 20.72 13.46 21.39 13.81 22H6C4.89 22 4 21.11 4 20V4C4 2.9 4.89 2 6 2H14L20 8V13.09C19.67 13.04 19.34 13 19 13C18.66 13 18.33 13.04 18 13.09V9H13V4H6V20H13.09M23 17L20 14.5V16H16V18H20V19.5L23 17M18 18.5L15 21L18 23.5V22H22V20H18V18.5Z",Tu="M13.81 22H6C4.89 22 4 21.11 4 20V4C4 2.9 4.89 2 6 2H14L20 8V13.09C19.67 13.04 19.34 13 19 13S18.33 13.04 18 13.09V9H13V4H6V20H13.09C13.21 20.72 13.46 21.39 13.81 22M23 18H20V15H18V18H15V20H18V23H20V20H23V18Z",vg="M14,12V19.88C14.04,20.18 13.94,20.5 13.71,20.71C13.32,21.1 12.69,21.1 12.3,20.71L10.29,18.7C10.06,18.47 9.96,18.16 10,17.87V12H9.97L4.21,4.62C3.87,4.19 3.95,3.56 4.38,3.22C4.57,3.08 4.78,3 5,3V3H19V3C19.22,3 19.43,3.08 19.62,3.22C20.05,3.56 20.13,4.19 19.79,4.62L14.03,12H14Z",Eg="M3.46 5C3.25 5 3.04 5.08 2.87 5.21C2.43 5.55 2.35 6.18 2.69 6.61L2.69 6.62L8 13.42V19.41L10.29 21.71C10.68 22.1 11.32 22.1 11.71 21.71C12.1 21.32 12.1 20.68 11.71 20.29L10 18.59V12.73L4.27 5.39C4.08 5.14 3.78 5 3.46 5M16 12V19.88C16.04 20.18 15.94 20.5 15.71 20.71C15.32 21.1 14.69 21.1 14.3 20.71L12.29 18.7C12.06 18.47 11.96 18.16 12 17.87V12H11.97L6.21 4.62C5.87 4.19 5.95 3.56 6.38 3.22C6.57 3.08 6.78 3 7 3H21C21.22 3 21.43 3.08 21.62 3.22C22.05 3.56 22.13 4.19 21.79 4.62L16.03 12H16Z",Sg="M3.47 5C3.25 5 3.04 5.08 2.87 5.21C2.43 5.55 2.35 6.18 2.69 6.61L2.69 6.62L7 12.14V18.05L10.64 21.71C11 22.1 11.66 22.1 12.05 21.71L12.05 21.71C12.44 21.32 12.44 20.69 12.06 20.3L9 17.22V11.45L4.27 5.39C4.08 5.14 3.78 5 3.47 5M21.62 3.22C21.43 3.08 21.22 3 21 3H7C6.78 3 6.57 3.08 6.38 3.22C5.95 3.56 5.87 4.19 6.21 4.62L11 10.75V15.87C10.96 16.16 11.06 16.47 11.29 16.7L15.3 20.71C15.69 21.1 16.32 21.1 16.71 20.71C16.94 20.5 17.04 20.18 17 19.88V10.75L21.79 4.62C22.13 4.19 22.05 3.56 21.62 3.22M15 10.05V17.58L13 15.58V10.06L9.04 5H18.96L15 10.05Z",Tg="M15,19.88C15.04,20.18 14.94,20.5 14.71,20.71C14.32,21.1 13.69,21.1 13.3,20.71L9.29,16.7C9.06,16.47 8.96,16.16 9,15.87V10.75L4.21,4.62C3.87,4.19 3.95,3.56 4.38,3.22C4.57,3.08 4.78,3 5,3V3H19V3C19.22,3 19.43,3.08 19.62,3.22C20.05,3.56 20.13,4.19 19.79,4.62L15,10.75V19.88M7.04,5L11,10.06V15.58L13,17.58V10.05L16.96,5H7.04Z",sl="M5,3A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5.5L18.5,3H17V9A1,1 0 0,1 16,10H8A1,1 0 0,1 7,9V3H5M12,4V9H15V4H12M7,12H17A1,1 0 0,1 18,13V19H6V13A1,1 0 0,1 7,12Z",to="M15.07,11.25L14.17,12.17C13.45,12.89 13,13.5 13,15H11V14.5C11,13.39 11.45,12.39 12.17,11.67L13.41,10.41C13.78,10.05 14,9.55 14,9C14,7.89 13.1,7 12,7A2,2 0 0,0 10,9H8A4,4 0 0,1 12,5A4,4 0 0,1 16,9C16,9.88 15.64,10.67 15.07,11.25M13,19H11V17H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,6.47 17.5,2 12,2Z",xd="M13,9H11V7H13M13,17H11V11H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z",kg="M19,13H5V11H19V13Z",ol="M12,10L8,14H11V20H13V14H16M19,4H5C3.89,4 3,4.9 3,6V18A2,2 0 0,0 5,20H9V18H5V8H19V18H15V20H19A2,2 0 0,0 21,18V6A2,2 0 0,0 19,4Z",Ud="M22,3H5A2,2 0 0,0 3,5V9H5V5H22V19H5V15H3V19A2,2 0 0,0 5,21H22A2,2 0 0,0 24,19V5A2,2 0 0,0 22,3M7,15V13H0V11H7V9L11,12L7,15M20,13H13V11H20V13M20,9H13V7H20V9M17,17H13V15H17V17Z",Wd="M2,3H19A2,2 0 0,1 21,5V9H19V5H2V19H19V15H21V19A2,2 0 0,1 19,21H2A2,2 0 0,1 0,19V5A2,2 0 0,1 2,3M17,15V13H24V11H17V9L13,12L17,15M4,13H11V11H4V13M4,9H11V7H4V9M4,17H8V15H4V17Z",al="M14,19H18V5H14M6,19H10V5H6V19Z",Gd="M13,16V8H15V16H13M9,16V8H11V16H9M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4Z",ku="M8,5.14V19.14L19,12.14L8,5.14Z",jd="M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M10,16.5L16,12L10,7.5V16.5Z",i1="M3,5V19L11,12M13,19H16V5H13M18,5V19H21V5",Ag="M15,6V8H3V6H15M15,10V12H3V10H15M3,16V14H11V16H3M17,6H22V8H19V17A3,3 0 0,1 16,20A3,3 0 0,1 13,17A3,3 0 0,1 16,14C16.35,14 16.69,14.07 17,14.18V6M16,16A1,1 0 0,0 15,17A1,1 0 0,0 16,18A1,1 0 0,0 17,17A1,1 0 0,0 16,16Z",zd="M3 10H14V12H3V10M3 6H14V8H3V6M3 14H10V16H3V14M16 13V21L22 17L16 13Z",Cg="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",s1="M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z",Xd="M17,17H7V14L3,18L7,22V19H19V13H17M7,7H17V10L21,6L17,2V5H5V11H7V7Z",Mg="M2,5.27L3.28,4L20,20.72L18.73,22L15.73,19H7V22L3,18L7,14V17H13.73L7,10.27V11H5V8.27L2,5.27M17,13H19V17.18L17,15.18V13M17,5V2L21,6L17,10V7H8.82L6.82,5H17Z",Yd="M6,5.75L10.25,10H7V16H13.5L15.5,18H7A2,2 0 0,1 5,16V10H1.75L6,5.75M18,18.25L13.75,14H17V8H10.5L8.5,6H17A2,2 0 0,1 19,8V14H22.25L18,18.25Z",Zo="M13,3A9,9 0 0,0 4,12H1L4.89,15.89L4.96,16.03L9,12H6A7,7 0 0,1 13,5A7,7 0 0,1 20,12A7,7 0 0,1 13,19C11.07,19 9.32,18.21 8.06,16.94L6.64,18.36C8.27,20 10.5,21 13,21A9,9 0 0,0 22,12A9,9 0 0,0 13,3Z",o1="M4,3H5V5H3V4A1,1 0 0,1 4,3M20,3A1,1 0 0,1 21,4V5H19V3H20M15,5V3H17V5H15M11,5V3H13V5H11M7,5V3H9V5H7M21,20A1,1 0 0,1 20,21H19V19H21V20M15,21V19H17V21H15M11,21V19H13V21H11M7,21V19H9V21H7M4,21A1,1 0 0,1 3,20V19H5V21H4M3,15H5V17H3V15M21,15V17H19V15H21M3,11H5V13H3V11M21,11V13H19V11H21M3,7H5V9H3V7M21,7V9H19V7H21Z",a1="M21 20C21 20.55 20.55 21 20 21H19V19H21V20M15 21V19H17V21H15M11 21V19H13V21H11M7 21V19H9V21H7M4 21C3.45 21 3 20.55 3 20V19H5V21H4M3 15H5V17H3V15M21 15V17H19V15H21M14.59 8L12 10.59L9.41 8L8 9.41L10.59 12L8 14.59L9.41 16L12 13.41L14.59 16L16 14.59L13.41 12L16 9.41L14.59 8M3 11H5V13H3V11M21 11V13H19V11H21M3 7H5V9H3V7M21 7V9H19V7H21M4 3H5V5H3V4C3 3.45 3.45 3 4 3M20 3C20.55 3 21 3.45 21 4V5H19V3H20M15 5V3H17V5H15M11 5V3H13V5H11M7 5V3H9V5H7Z",l1="M20,5V19L13,12M6,5V19H4V5M13,5V19L6,12",u1="M4,5V19L11,12M18,5V19H20V5M11,5V19L18,12",c1="M16,18H18V6H16M6,18L14.5,12L6,6V18Z",f1="M6,18V6H8V18H6M9.5,12L18,6V18L9.5,12Z",Rg="M12,16A3,3 0 0,1 9,13C9,11.88 9.61,10.9 10.5,10.39L20.21,4.77L14.68,14.35C14.18,15.33 13.17,16 12,16M12,3C13.81,3 15.5,3.5 16.97,4.32L14.87,5.53C14,5.19 13,5 12,5A8,8 0 0,0 4,13C4,15.21 4.89,17.21 6.34,18.65H6.35C6.74,19.04 6.74,19.67 6.35,20.06C5.96,20.45 5.32,20.45 4.93,20.07V20.07C3.12,18.26 2,15.76 2,13A10,10 0 0,1 12,3M22,13C22,15.76 20.88,18.26 19.07,20.07V20.07C18.68,20.45 18.05,20.45 17.66,20.06C17.27,19.67 17.27,19.04 17.66,18.65V18.65C19.11,17.2 20,15.21 20,13C20,12 19.81,11 19.46,10.1L20.67,8C21.5,9.5 22,11.18 22,13Z",d1="M12,17.27L18.18,21L16.54,13.97L22,9.24L14.81,8.62L12,2L9.19,8.62L2,9.24L7.45,13.97L5.82,21L12,17.27Z",h1="M12,15.39L8.24,17.66L9.23,13.38L5.91,10.5L10.29,10.13L12,6.09L13.71,10.13L18.09,10.5L14.77,13.38L15.76,17.66M22,9.24L14.81,8.63L12,2L9.19,8.63L2,9.24L7.45,13.97L5.82,21L12,17.27L18.18,21L16.54,13.97L22,9.24Z",Lg="M21,9L17,5V8H10V10H17V13M7,11L3,15L7,19V16H14V14H7V11Z",Kd="M11,2V4.07C7.38,4.53 4.53,7.38 4.07,11H2V13H4.07C4.53,16.62 7.38,19.47 11,19.93V22H13V19.93C16.62,19.47 19.47,16.62 19.93,13H22V11H19.93C19.47,7.38 16.62,4.53 13,4.07V2M11,6.08V8H13V6.09C15.5,6.5 17.5,8.5 17.92,11H16V13H17.91C17.5,15.5 15.5,17.5 13,17.92V16H11V17.91C8.5,17.5 6.5,15.5 6.08,13H8V11H6.09C6.5,8.5 8.5,6.5 11,6.08M12,11A1,1 0 0,0 11,12A1,1 0 0,0 12,13A1,1 0 0,0 13,12A1,1 0 0,0 12,11Z",Pg="M21,6V8H3V6H21M3,18H12V16H3V18M3,13H21V11H3V13Z",Ig="M14,17H7V15H14M17,13H7V11H17M17,9H7V7H17M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3Z",Jo="M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M9,8H11V17H9V8M13,8H15V17H13V8Z",qd="M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M7,6H17V19H7V6M9,8V17H11V8H9M13,8V17H15V8H13Z",Zd="M14,3.23V5.29C16.89,6.15 19,8.83 19,12C19,15.17 16.89,17.84 14,18.7V20.77C18,19.86 21,16.28 21,12C21,7.72 18,4.14 14,3.23M16.5,12C16.5,10.23 15.5,8.71 14,7.97V16C15.5,15.29 16.5,13.76 16.5,12M3,9V15H7L12,20V4L7,9H3Z",Jd="M12,4L9.91,6.09L12,8.18M4.27,3L3,4.27L7.73,9H3V15H7L12,20V13.27L16.25,17.53C15.58,18.04 14.83,18.46 14,18.7V20.77C15.38,20.45 16.63,19.82 17.68,18.96L19.73,21L21,19.73L12,10.73M19,12C19,12.94 18.8,13.82 18.46,14.64L19.97,16.15C20.62,14.91 21,13.5 21,12C21,7.72 18,4.14 14,3.23V5.29C16.89,6.15 19,8.83 19,12M16.5,12C16.5,10.23 15.5,8.71 14,7.97V10.18L16.45,12.63C16.5,12.43 16.5,12.21 16.5,12Z";/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function Ar(t,e,n,r){return new(n||(n=Promise))(function(i,s){function o(c){try{l(r.next(c))}catch(u){s(u)}}function a(c){try{l(r.throw(c))}catch(u){s(u)}}function l(c){var u;c.done?i(c.value):(u=c.value,u instanceof n?u:new n(function(f){f(u)})).then(o,a)}l((r=r.apply(t,e||[])).next())})}let ll=class{constructor(){this.listeners={}}on(e,n,r){if(this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(n),r==null?void 0:r.once){const i=()=>{this.un(e,i),this.un(e,n)};return this.on(e,i),i}return()=>this.un(e,n)}un(e,n){var r;(r=this.listeners[e])===null||r===void 0||r.delete(n)}once(e,n){return this.on(e,n,{once:!0})}unAll(){this.listeners={}}emit(e,...n){this.listeners[e]&&this.listeners[e].forEach(r=>r(...n))}};const Qd={decode:function(t,e){return Ar(this,void 0,void 0,function*(){const n=new AudioContext({sampleRate:e});return n.decodeAudioData(t).finally(()=>n.close())})},createBuffer:function(t,e){return typeof t[0]=="number"&&(t=[t]),function(n){const r=n[0];if(r.some(i=>i>1||i<-1)){const i=r.length;let s=0;for(let o=0;o<i;o++){const a=Math.abs(r[o]);a>s&&(s=a)}for(const o of n)for(let a=0;a<i;a++)o[a]/=s}}(t),{duration:e,length:t[0].length,sampleRate:t[0].length/e,numberOfChannels:t.length,getChannelData:n=>t==null?void 0:t[n],copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}};function e0(t,e){const n=e.xmlns?document.createElementNS(e.xmlns,t):document.createElement(t);for(const[r,i]of Object.entries(e))if(r==="children")for(const[s,o]of Object.entries(e))typeof o=="string"?n.appendChild(document.createTextNode(o)):n.appendChild(e0(s,o));else r==="style"?Object.assign(n.style,i):r==="textContent"?n.textContent=i:n.setAttribute(r,i.toString());return n}function t0(t,e,n){const r=e0(t,e||{});return n==null||n.appendChild(r),r}var Og=Object.freeze({__proto__:null,createElement:t0,default:t0});const Bg={fetchBlob:function(t,e,n){return Ar(this,void 0,void 0,function*(){const r=yield fetch(t,n);if(r.status>=400)throw new Error(`Failed to fetch ${t}: ${r.status} (${r.statusText})`);return function(i,s){Ar(this,void 0,void 0,function*(){if(!i.body||!i.headers)return;const o=i.body.getReader(),a=Number(i.headers.get("Content-Length"))||0;let l=0;const c=f=>Ar(this,void 0,void 0,function*(){l+=(f==null?void 0:f.length)||0;const g=Math.round(l/a*100);s(g)}),u=()=>Ar(this,void 0,void 0,function*(){let f;try{f=yield o.read()}catch{return}f.done||(c(f.value),yield u())});u()})}(r.clone(),e),r.blob()})}};class Dg extends ll{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.onMediaEvent("canplay",()=>{e.playbackRate!=null&&(this.media.playbackRate=e.playbackRate)},{once:!0})}onMediaEvent(e,n,r){return this.media.addEventListener(e,n,r),()=>this.media.removeEventListener(e,n,r)}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){const e=this.getSrc();e.startsWith("blob:")&&URL.revokeObjectURL(e)}canPlayType(e){return this.media.canPlayType(e)!==""}setSrc(e,n){if(this.getSrc()===e)return;this.revokeSrc();const r=n instanceof Blob&&this.canPlayType(n.type)?URL.createObjectURL(n):e;this.media.src=r}destroy(){this.media.pause(),this.isExternalMedia||(this.media.remove(),this.revokeSrc(),this.media.src="",this.media.load())}setMediaElement(e){this.media=e}play(){return Ar(this,void 0,void 0,function*(){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}isSeeking(){return this.media.seeking}setPlaybackRate(e,n){n!=null&&(this.media.preservesPitch=n),this.media.playbackRate=e}getMediaElement(){return this.media}setSinkId(e){return this.media.setSinkId(e)}}class Au extends ll{constructor(e,n){super(),this.timeouts=[],this.isScrollable=!1,this.audioData=null,this.resizeObserver=null,this.lastContainerWidth=0,this.isDragging=!1,this.options=e;const r=this.parentFromOptionsContainer(e.container);this.parent=r;const[i,s]=this.initHtml();r.appendChild(i),this.container=i,this.scrollContainer=s.querySelector(".scroll"),this.wrapper=s.querySelector(".wrapper"),this.canvasWrapper=s.querySelector(".canvases"),this.progressWrapper=s.querySelector(".progress"),this.cursor=s.querySelector(".cursor"),n&&s.appendChild(n),this.initEvents()}parentFromOptionsContainer(e){let n;if(typeof e=="string"?n=document.querySelector(e):e instanceof HTMLElement&&(n=e),!n)throw new Error("Container not found");return n}initEvents(){const e=r=>{const i=this.wrapper.getBoundingClientRect(),s=r.clientX-i.left,o=r.clientX-i.left;return[s/i.width,o/i.height]};this.wrapper.addEventListener("click",r=>{const[i,s]=e(r);this.emit("click",i,s)}),this.wrapper.addEventListener("dblclick",r=>{const[i,s]=e(r);this.emit("dblclick",i,s)}),this.options.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.scrollContainer.addEventListener("scroll",()=>{const{scrollLeft:r,scrollWidth:i,clientWidth:s}=this.scrollContainer,o=r/i,a=(r+s)/i;this.emit("scroll",o,a)});const n=this.createDelay(100);this.resizeObserver=new ResizeObserver(()=>{n().then(()=>this.onContainerResize()).catch(()=>{})}),this.resizeObserver.observe(this.scrollContainer)}onContainerResize(){const e=this.parent.clientWidth;e===this.lastContainerWidth&&this.options.height!=="auto"||(this.lastContainerWidth=e,this.reRender())}initDrag(){(function(e,n,r,i,s=3,o=0){if(!e)return()=>{};let a=()=>{};const l=c=>{if(c.button!==o)return;c.preventDefault(),c.stopPropagation();let u=c.clientX,f=c.clientY,g=!1;const v=m=>{m.preventDefault(),m.stopPropagation();const w=m.clientX,C=m.clientY,h=w-u,A=C-f;if(g||Math.abs(h)>s||Math.abs(A)>s){const L=e.getBoundingClientRect(),{left:$,top:P}=L;g||(r==null||r(u-$,f-P),g=!0),n(h,A,w-$,C-P),u=w,f=C}},_=m=>{if(g){const w=m.clientX,C=m.clientY,h=e.getBoundingClientRect(),{left:A,top:L}=h;i==null||i(w-A,C-L)}a()},b=m=>{m.relatedTarget&&m.relatedTarget!==document.documentElement||_(m)},y=m=>{g&&(m.stopPropagation(),m.preventDefault())},p=m=>{g&&m.preventDefault()};document.addEventListener("pointermove",v),document.addEventListener("pointerup",_),document.addEventListener("pointerout",b),document.addEventListener("pointercancel",b),document.addEventListener("touchmove",p,{passive:!1}),document.addEventListener("click",y,{capture:!0}),a=()=>{document.removeEventListener("pointermove",v),document.removeEventListener("pointerup",_),document.removeEventListener("pointerout",b),document.removeEventListener("pointercancel",b),document.removeEventListener("touchmove",p),setTimeout(()=>{document.removeEventListener("click",y,{capture:!0})},10)}};e.addEventListener("pointerdown",l)})(this.wrapper,(e,n,r)=>{this.emit("drag",Math.max(0,Math.min(1,r/this.wrapper.getBoundingClientRect().width)))},e=>{this.isDragging=!0,this.emit("dragstart",Math.max(0,Math.min(1,e/this.wrapper.getBoundingClientRect().width)))},e=>{this.isDragging=!1,this.emit("dragend",Math.max(0,Math.min(1,e/this.wrapper.getBoundingClientRect().width)))})}getHeight(e){return e==null?128:isNaN(Number(e))?e==="auto"&&this.parent.clientHeight||128:Number(e)}initHtml(){const e=document.createElement("div"),n=e.attachShadow({mode:"open"});return n.innerHTML=`
<style>
:host {
user-select: none;
min-width: 1px;
}
:host audio {
display: block;
width: 100%;
}
:host .scroll {
overflow-x: auto;
overflow-y: hidden;
width: 100%;
position: relative;
}
:host .noScrollbar {
scrollbar-color: transparent;
scrollbar-width: none;
}
:host .noScrollbar::-webkit-scrollbar {
display: none;
-webkit-appearance: none;
}
:host .wrapper {
position: relative;
overflow: visible;
z-index: 2;
}
:host .canvases {
min-height: ${this.getHeight(this.options.height)}px;
}
:host .canvases > div {
position: relative;
}
:host canvas {
display: block;
position: absolute;
top: 0;
image-rendering: pixelated;
}
:host .progress {
pointer-events: none;
position: absolute;
z-index: 2;
top: 0;
left: 0;
width: 0;
height: 100%;
overflow: hidden;
}
:host .progress > div {
position: relative;
}
:host .cursor {
pointer-events: none;
position: absolute;
z-index: 5;
top: 0;
left: 0;
height: 100%;
border-radius: 2px;
}
</style>
<div class="scroll" part="scroll">
<div class="wrapper" part="wrapper">
<div class="canvases"></div>
<div class="progress" part="progress"></div>
<div class="cursor" part="cursor"></div>
</div>
</div>
`,[e,n]}setOptions(e){if(this.options.container!==e.container){const n=this.parentFromOptionsContainer(e.container);n.appendChild(this.container),this.parent=n}e.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.options=e,this.reRender()}getWrapper(){return this.wrapper}getScroll(){return this.scrollContainer.scrollLeft}setScroll(e){this.scrollContainer.scrollLeft=e}setScrollPercentage(e){const{scrollWidth:n}=this.scrollContainer,r=n*e;this.setScroll(r)}destroy(){var e;this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect()}createDelay(e=10){let n,r;const i=()=>{n&&clearTimeout(n),r&&r()};return this.timeouts.push(i),()=>new Promise((s,o)=>{i(),r=o,n=setTimeout(()=>{n=void 0,r=void 0,s()},e)})}convertColorValues(e){if(!Array.isArray(e))return e||"";if(e.length<2)return e[0]||"";const n=document.createElement("canvas"),r=n.getContext("2d"),i=n.height*(window.devicePixelRatio||1),s=r.createLinearGradient(0,0,0,i),o=1/(e.length-1);return e.forEach((a,l)=>{const c=l*o;s.addColorStop(c,a)}),s}renderBarWaveform(e,n,r,i){const s=e[0],o=e[1]||e[0],a=s.length,{width:l,height:c}=r.canvas,u=c/2,f=window.devicePixelRatio||1,g=n.barWidth?n.barWidth*f:1,v=n.barGap?n.barGap*f:n.barWidth?g/2:0,_=n.barRadius||0,b=l/(g+v)/a,y=_&&"roundRect"in r?"roundRect":"rect";r.beginPath();let p=0,m=0,w=0;for(let C=0;C<=a;C++){const h=Math.round(C*b);if(h>p){const $=Math.round(m*u*i),P=$+Math.round(w*u*i)||1;let I=u-$;n.barAlign==="top"?I=0:n.barAlign==="bottom"&&(I=c-P),r[y](p*(g+v),I,g,P,_),p=h,m=0,w=0}const A=Math.abs(s[C]||0),L=Math.abs(o[C]||0);A>m&&(m=A),L>w&&(w=L)}r.fill(),r.closePath()}renderLineWaveform(e,n,r,i){const s=o=>{const a=e[o]||e[0],l=a.length,{height:c}=r.canvas,u=c/2,f=r.canvas.width/l;r.moveTo(0,u);let g=0,v=0;for(let _=0;_<=l;_++){const b=Math.round(_*f);if(b>g){const p=u+(Math.round(v*u*i)||1)*(o===0?-1:1);r.lineTo(g,p),g=b,v=0}const y=Math.abs(a[_]||0);y>v&&(v=y)}r.lineTo(g,u)};r.beginPath(),s(0),s(1),r.fill(),r.closePath()}renderWaveform(e,n,r){if(r.fillStyle=this.convertColorValues(n.waveColor),n.renderFunction)return void n.renderFunction(e,r);let i=n.barHeight||1;if(n.normalize){const s=Array.from(e[0]).reduce((o,a)=>Math.max(o,Math.abs(a)),0);i=s?1/s:1}n.barWidth||n.barGap||n.barAlign?this.renderBarWaveform(e,n,r,i):this.renderLineWaveform(e,n,r,i)}renderSingleCanvas(e,n,r,i,s,o,a,l){const c=window.devicePixelRatio||1,u=document.createElement("canvas"),f=e[0].length;u.width=Math.round(r*(o-s)/f),u.height=i*c,u.style.width=`${Math.floor(u.width/c)}px`,u.style.height=`${i}px`,u.style.left=`${Math.floor(s*r/c/f)}px`,a.appendChild(u);const g=u.getContext("2d");if(this.renderWaveform(e.map(v=>v.slice(s,o)),n,g),u.width>0&&u.height>0){const v=u.cloneNode(),_=v.getContext("2d");_.drawImage(u,0,0),_.globalCompositeOperation="source-in",_.fillStyle=this.convertColorValues(n.progressColor),_.fillRect(0,0,u.width,u.height),l.appendChild(v)}}renderChannel(e,n,r){return Ar(this,void 0,void 0,function*(){const i=document.createElement("div"),s=this.getHeight(n.height);i.style.height=`${s}px`,this.canvasWrapper.style.minHeight=`${s}px`,this.canvasWrapper.appendChild(i);const o=i.cloneNode();this.progressWrapper.appendChild(o);const a=e[0].length,l=(p,m)=>{this.renderSingleCanvas(e,n,r,s,Math.max(0,p),Math.min(m,a),i,o)};if(!this.isScrollable)return void l(0,a);const{scrollLeft:c,scrollWidth:u,clientWidth:f}=this.scrollContainer,g=a/u;let v=Math.min(Au.MAX_CANVAS_WIDTH,f);if(n.barWidth||n.barGap){const p=n.barWidth||.5,m=p+(n.barGap||p/2);v%m!=0&&(v=Math.floor(v/m)*m)}const _=Math.floor(Math.abs(c)*g),b=Math.floor(_+v*g),y=b-_;y<=0||(l(_,b),yield Promise.all([Ar(this,void 0,void 0,function*(){if(_===0)return;const p=this.createDelay();for(let m=_;m>=0;m-=y)yield p(),l(Math.max(0,m-y),m)}),Ar(this,void 0,void 0,function*(){if(b===a)return;const p=this.createDelay();for(let m=b;m<a;m+=y)yield p(),l(m,Math.min(a,m+y))})]))})}render(e){return Ar(this,void 0,void 0,function*(){this.timeouts.forEach(a=>a()),this.timeouts=[],this.canvasWrapper.innerHTML="",this.progressWrapper.innerHTML="",this.options.width!=null&&(this.scrollContainer.style.width=typeof this.options.width=="number"?`${this.options.width}px`:this.options.width);const n=window.devicePixelRatio||1,r=this.scrollContainer.clientWidth,i=Math.ceil(e.duration*(this.options.minPxPerSec||0));this.isScrollable=i>r;const s=this.options.fillParent&&!this.isScrollable,o=(s?r:i)*n;this.wrapper.style.width=s?"100%":`${i}px`,this.scrollContainer.style.overflowX=this.isScrollable?"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.audioData=e,this.emit("render");try{if(this.options.splitChannels)yield Promise.all(Array.from({length:e.numberOfChannels}).map((a,l)=>{var c;const u=Object.assign(Object.assign({},this.options),(c=this.options.splitChannels)===null||c===void 0?void 0:c[l]);return this.renderChannel([e.getChannelData(l)],u,o)}));else{const a=[e.getChannelData(0)];e.numberOfChannels>1&&a.push(e.getChannelData(1)),yield this.renderChannel(a,this.options,o)}}catch{return}this.emit("rendered")})}reRender(){if(!this.audioData)return;const{scrollWidth:e}=this.scrollContainer,{right:n}=this.progressWrapper.getBoundingClientRect();if(this.render(this.audioData),this.isScrollable&&e!==this.scrollContainer.scrollWidth){const{right:r}=this.progressWrapper.getBoundingClientRect();let i=r-n;i*=2,i=i<0?Math.floor(i):Math.ceil(i),i/=2,this.scrollContainer.scrollLeft+=i}}zoom(e){this.options.minPxPerSec=e,this.reRender()}scrollIntoView(e,n=!1){const{scrollLeft:r,scrollWidth:i,clientWidth:s}=this.scrollContainer,o=e*i,a=r,l=r+s,c=s/2;if(this.isDragging)o+30>l?this.scrollContainer.scrollLeft+=30:o-30<a&&(this.scrollContainer.scrollLeft-=30);else{(o<a||o>l)&&(this.scrollContainer.scrollLeft=o-(this.options.autoCenter?c:0));const u=o-r-c;n&&this.options.autoCenter&&u>0&&(this.scrollContainer.scrollLeft+=Math.min(u,10))}{const u=this.scrollContainer.scrollLeft,f=u/i,g=(u+s)/i;this.emit("scroll",f,g)}}renderProgress(e,n){if(isNaN(e))return;const r=100*e;this.canvasWrapper.style.clipPath=`polygon(${r}% 0, 100% 0, 100% 100%, ${r}% 100%)`,this.progressWrapper.style.width=`${r}%`,this.cursor.style.left=`${r}%`,this.cursor.style.transform=`translateX(-${Math.round(r)===100?this.options.cursorWidth:0}px)`,this.isScrollable&&this.options.autoScroll&&this.scrollIntoView(e,n)}exportImage(e,n,r){return Ar(this,void 0,void 0,function*(){const i=this.canvasWrapper.querySelectorAll("canvas");if(!i.length)throw new Error("No waveform data");if(r==="dataURL"){const s=Array.from(i).map(o=>o.toDataURL(e,n));return Promise.resolve(s)}return Promise.all(Array.from(i).map(s=>new Promise((o,a)=>{s.toBlob(l=>{l?o(l):a(new Error("Could not export image"))},e,n)})))})}}Au.MAX_CANVAS_WIDTH=4e3;class Fg extends ll{constructor(){super(...arguments),this.unsubscribe=()=>{}}start(){this.unsubscribe=this.on("tick",()=>{requestAnimationFrame(()=>{this.emit("tick")})}),this.emit("tick")}stop(){this.unsubscribe()}destroy(){this.unsubscribe()}}class n0 extends ll{constructor(e=new AudioContext){super(),this.bufferNode=null,this.playStartTime=0,this.playedDuration=0,this._muted=!1,this._playbackRate=1,this._duration=void 0,this.buffer=null,this.currentSrc="",this.paused=!0,this.crossOrigin=null,this.seeking=!1,this.autoplay=!1,this.addEventListener=this.on,this.removeEventListener=this.un,this.audioContext=e,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return Ar(this,void 0,void 0,function*(){})}get src(){return this.currentSrc}set src(e){if(this.currentSrc=e,this._duration=void 0,!e)return this.buffer=null,void this.emit("emptied");fetch(e).then(n=>{if(n.status>=400)throw new Error(`Failed to fetch ${e}: ${n.status} (${n.statusText})`);return n.arrayBuffer()}).then(n=>this.currentSrc!==e?null:this.audioContext.decodeAudioData(n)).then(n=>{this.currentSrc===e&&(this.buffer=n,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play())})}_play(){var e;if(!this.paused)return;this.paused=!1,(e=this.bufferNode)===null||e===void 0||e.disconnect(),this.bufferNode=this.audioContext.createBufferSource(),this.buffer&&(this.bufferNode.buffer=this.buffer),this.bufferNode.playbackRate.value=this._playbackRate,this.bufferNode.connect(this.gainNode);let n=this.playedDuration*this._playbackRate;n>=this.duration&&(n=0,this.playedDuration=0),this.bufferNode.start(this.audioContext.currentTime,n),this.playStartTime=this.audioContext.currentTime,this.bufferNode.onended=()=>{this.currentTime>=this.duration&&(this.pause(),this.emit("ended"))}}_pause(){var e;this.paused=!0,(e=this.bufferNode)===null||e===void 0||e.stop(),this.playedDuration+=this.audioContext.currentTime-this.playStartTime}play(){return Ar(this,void 0,void 0,function*(){this.paused&&(this._play(),this.emit("play"))})}pause(){this.paused||(this._pause(),this.emit("pause"))}stopAt(e){var n,r;const i=e-this.currentTime;(n=this.bufferNode)===null||n===void 0||n.stop(this.audioContext.currentTime+i),(r=this.bufferNode)===null||r===void 0||r.addEventListener("ended",()=>{this.bufferNode=null,this.pause()},{once:!0})}setSinkId(e){return Ar(this,void 0,void 0,function*(){return this.audioContext.setSinkId(e)})}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e,this.bufferNode&&(this.bufferNode.playbackRate.value=e)}get currentTime(){return(this.paused?this.playedDuration:this.playedDuration+(this.audioContext.currentTime-this.playStartTime))*this._playbackRate}set currentTime(e){const n=!this.paused;n&&this._pause(),this.playedDuration=e/this._playbackRate,n&&this._play(),this.emit("seeking"),this.emit("timeupdate")}get duration(){var e,n;return(e=this._duration)!==null&&e!==void 0?e:((n=this.buffer)===null||n===void 0?void 0:n.duration)||0}set duration(e){this._duration=e}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))}canPlayType(e){return/^(audio|video)\//.test(e)}getGainNode(){return this.gainNode}getChannelData(){const e=[];if(!this.buffer)return e;const n=this.buffer.numberOfChannels;for(let r=0;r<n;r++)e.push(this.buffer.getChannelData(r));return e}}const $g={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class ul extends Dg{static create(e){return new ul(e)}constructor(e){const n=e.media||(e.backend==="WebAudio"?new n0:void 0);super({media:n,mediaControls:e.mediaControls,autoplay:e.autoplay,playbackRate:e.audioRate}),this.plugins=[],this.decodedData=null,this.subscriptions=[],this.mediaSubscriptions=[],this.options=Object.assign({},$g,e),this.timer=new Fg;const r=n?void 0:this.getMediaElement();this.renderer=new Au(this.options,r),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initPlugins(),Promise.resolve().then(()=>{this.emit("init");const i=this.options.url||this.getSrc()||"";(i||this.options.peaks&&this.options.duration)&&this.load(i,this.options.peaks,this.options.duration).catch(()=>null)})}updateProgress(e=this.getCurrentTime()){return this.renderer.renderProgress(e/this.getDuration(),this.isPlaying()),e}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",()=>{if(!this.isSeeking()){const e=this.updateProgress();this.emit("timeupdate",e),this.emit("audioprocess",e)}}))}initPlayerEvents(){this.isPlaying()&&(this.emit("play"),this.timer.start()),this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",()=>{const e=this.updateProgress();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())}),this.onMediaEvent("error",e=>{this.emit("error",e.error)}))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",(e,n)=>{this.options.interact&&(this.seekTo(e),this.emit("interaction",e*this.getDuration()),this.emit("click",e,n))}),this.renderer.on("dblclick",(e,n)=>{this.emit("dblclick",e,n)}),this.renderer.on("scroll",(e,n)=>{const r=this.getDuration();this.emit("scroll",e*r,n*r)}),this.renderer.on("render",()=>{this.emit("redraw")}),this.renderer.on("rendered",()=>{this.emit("redrawcomplete")}),this.renderer.on("dragstart",e=>{this.emit("dragstart",e)}),this.renderer.on("dragend",e=>{this.emit("dragend",e)}));{let e;this.subscriptions.push(this.renderer.on("drag",n=>{if(!this.options.interact)return;let r;this.renderer.renderProgress(n),clearTimeout(e),this.isPlaying()?r=0:this.options.dragToSeek===!0?r=200:typeof this.options.dragToSeek=="object"&&this.options.dragToSeek!==void 0&&(r=this.options.dragToSeek.debounceTime),e=setTimeout(()=>{this.seekTo(n)},r),this.emit("interaction",n*this.getDuration()),this.emit("drag",n)}))}}initPlugins(){var e;!((e=this.options.plugins)===null||e===void 0)&&e.length&&this.options.plugins.forEach(n=>{this.registerPlugin(n)})}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(n=>n!==e)})),e}getWrapper(){return this.renderer.getWrapper()}getScroll(){return this.renderer.getScroll()}setScrollTime(e){const n=e/this.getDuration();this.renderer.setScrollPercentage(n)}getActivePlugins(){return this.plugins}loadAudio(e,n,r,i){return Ar(this,void 0,void 0,function*(){if(this.emit("load",e),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,!n&&!r){const o=a=>this.emit("loading",a);n=yield Bg.fetchBlob(e,o,this.options.fetchParams)}this.setSrc(e,n);const s=i||this.getDuration()||(yield new Promise(o=>{this.onMediaEvent("loadedmetadata",()=>o(this.getDuration()),{once:!0})}));if(!e&&!n){const o=this.getMediaElement();o instanceof n0&&(o.duration=s)}if(r)this.decodedData=Qd.createBuffer(r,s||0);else if(n){const o=yield n.arrayBuffer();this.decodedData=yield Qd.decode(o,this.options.sampleRate)}this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData)),this.emit("ready",this.getDuration())})}load(e,n,r){return Ar(this,void 0,void 0,function*(){try{return yield this.loadAudio(e,void 0,n,r)}catch(i){throw this.emit("error",i),i}})}loadBlob(e,n,r){return Ar(this,void 0,void 0,function*(){try{return yield this.loadAudio("blob",e,n,r)}catch(i){throw this.emit("error",i),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:n=8e3,precision:r=1e4}={}){if(!this.decodedData)throw new Error("The audio has not been decoded yet");const i=Math.min(e,this.decodedData.numberOfChannels),s=[];for(let o=0;o<i;o++){const a=this.decodedData.getChannelData(o),l=[],c=Math.round(a.length/n);for(let u=0;u<n;u++){const f=a.slice(u*c,(u+1)*c);let g=0;for(let v=0;v<f.length;v++){const _=f[v];Math.abs(_)>Math.abs(g)&&(g=_)}l.push(Math.round(g*r)/r)}s.push(l)}return s}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}setTime(e){super.setTime(e),this.updateProgress(e),this.emit("timeupdate",e)}seekTo(e){const n=this.getDuration()*e;this.setTime(n)}playPause(){return Ar(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()}exportImage(e="image/png",n=1,r="dataURL"){return Ar(this,void 0,void 0,function*(){return this.renderer.exportImage(e,n,r)})}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()}}ul.BasePlugin=class extends ll{constructor(t){super(),this.subscriptions=[],this.options=t}onInit(){}_init(t){this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t())}},ul.dom=Og;class r0{constructor(){this.listeners={}}on(e,n,r){if(this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(n),r==null?void 0:r.once){const i=()=>{this.un(e,i),this.un(e,n)};return this.on(e,i),i}return()=>this.un(e,n)}un(e,n){var r;(r=this.listeners[e])===null||r===void 0||r.delete(n)}once(e,n){return this.on(e,n,{once:!0})}unAll(){this.listeners={}}emit(e,...n){this.listeners[e]&&this.listeners[e].forEach(r=>r(...n))}}class Ng extends r0{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 Cu(t,e,n,r,i=3,s=0){if(!t)return()=>{};let o=()=>{};const a=l=>{if(l.button!==s)return;l.preventDefault(),l.stopPropagation();let c=l.clientX,u=l.clientY,f=!1;const g=p=>{p.preventDefault(),p.stopPropagation();const m=p.clientX,w=p.clientY,C=m-c,h=w-u;if(f||Math.abs(C)>i||Math.abs(h)>i){const A=t.getBoundingClientRect(),{left:L,top:$}=A;f||(n==null||n(c-L,u-$),f=!0),e(C,h,m-L,w-$),c=m,u=w}},v=p=>{if(f){const m=p.clientX,w=p.clientY,C=t.getBoundingClientRect(),{left:h,top:A}=C;r==null||r(m-h,w-A)}o()},_=p=>{p.relatedTarget&&p.relatedTarget!==document.documentElement||v(p)},b=p=>{f&&(p.stopPropagation(),p.preventDefault())},y=p=>{f&&p.preventDefault()};document.addEventListener("pointermove",g),document.addEventListener("pointerup",v),document.addEventListener("pointerout",_),document.addEventListener("pointercancel",_),document.addEventListener("touchmove",y,{passive:!1}),document.addEventListener("click",b,{capture:!0}),o=()=>{document.removeEventListener("pointermove",g),document.removeEventListener("pointerup",v),document.removeEventListener("pointerout",_),document.removeEventListener("pointercancel",_),document.removeEventListener("touchmove",y),setTimeout(()=>{document.removeEventListener("click",b,{capture:!0})},10)}};return t.addEventListener("pointerdown",a),()=>{o(),t.removeEventListener("pointerdown",a)}}function i0(t,e){const n=e.xmlns?document.createElementNS(e.xmlns,t):document.createElement(t);for(const[r,i]of Object.entries(e))if(r==="children")for(const[s,o]of Object.entries(e))typeof o=="string"?n.appendChild(document.createTextNode(o)):n.appendChild(i0(s,o));else r==="style"?Object.assign(n.style,i):r==="textContent"?n.textContent=i:n.setAttribute(r,i.toString());return n}function cl(t,e,n){const r=i0(t,e||{});return n==null||n.appendChild(r),r}class s0 extends r0{constructor(e,n,r=0){var i,s,o,a,l,c,u,f;super(),this.totalDuration=n,this.numberOfChannels=r,this.minLength=0,this.maxLength=1/0,this.contentEditable=!1,this.id=e.id||`region-${Math.random().toString(32).slice(2)}`,this.start=this.clampPosition(e.start),this.end=this.clampPosition((i=e.end)!==null&&i!==void 0?i:e.start),this.drag=(s=e.drag)===null||s===void 0||s,this.resize=(o=e.resize)===null||o===void 0||o,this.color=(a=e.color)!==null&&a!==void 0?a:"rgba(0, 0, 0, 0.1)",this.minLength=(l=e.minLength)!==null&&l!==void 0?l:this.minLength,this.maxLength=(c=e.maxLength)!==null&&c!==void 0?c:this.maxLength,this.channelIdx=(u=e.channelIdx)!==null&&u!==void 0?u:-1,this.contentEditable=(f=e.contentEditable)!==null&&f!==void 0?f:this.contentEditable,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 n={position:"absolute",zIndex:"2",width:"6px",height:"100%",top:"0",cursor:"ew-resize",wordBreak:"keep-all"},r=cl("div",{part:"region-handle region-handle-left",style:Object.assign(Object.assign({},n),{left:"0",borderLeft:"2px solid rgba(0, 0, 0, 0.5)",borderRadius:"2px 0 0 2px"})},e),i=cl("div",{part:"region-handle region-handle-right",style:Object.assign(Object.assign({},n),{right:"0",borderRight:"2px solid rgba(0, 0, 0, 0.5)",borderRadius:"0 2px 2px 0"})},e);Cu(r,s=>this.onResize(s,"start"),()=>null,()=>this.onEndResizing(),1),Cu(i,s=>this.onResize(s,"end"),()=>null,()=>this.onEndResizing(),1)}removeResizeHandles(e){const n=e.querySelector('[part*="region-handle-left"]'),r=e.querySelector('[part*="region-handle-right"]');n&&e.removeChild(n),r&&e.removeChild(r)}initElement(){const e=this.start===this.end;let n=0,r=100;this.channelIdx>=0&&this.channelIdx<this.numberOfChannels&&(r=100/this.numberOfChannels,n=r*this.channelIdx);const i=cl("div",{style:{position:"absolute",top:`${n}%`,height:`${r}%`,backgroundColor:e?"none":this.color,borderLeft:e?"2px solid "+this.color:"none",borderRadius:"2px",boxSizing:"border-box",transition:"background-color 0.2s ease",cursor:this.drag?"grab":"default",pointerEvents:"all"}});return!e&&this.resize&&this.addResizeHandles(i),i}renderPosition(){const e=this.start/this.totalDuration,n=(this.totalDuration-this.end)/this.totalDuration;this.element.style.left=100*e+"%",this.element.style.right=100*n+"%"}toggleCursor(e){var n;this.drag&&(!((n=this.element)===null||n===void 0)&&n.style)&&(this.element.style.cursor=e?"grabbing":"grab")}initMouseEvents(){const{element:e}=this;e&&(e.addEventListener("click",n=>this.emit("click",n)),e.addEventListener("mouseenter",n=>this.emit("over",n)),e.addEventListener("mouseleave",n=>this.emit("leave",n)),e.addEventListener("dblclick",n=>this.emit("dblclick",n)),e.addEventListener("pointerdown",()=>this.toggleCursor(!0)),e.addEventListener("pointerup",()=>this.toggleCursor(!1)),Cu(e,n=>this.onMove(n),()=>this.toggleCursor(!0),()=>{this.toggleCursor(!1),this.drag&&this.emit("update-end")}),this.contentEditable&&this.content&&(this.content.addEventListener("click",n=>this.onContentClick(n)),this.content.addEventListener("blur",()=>this.onContentBlur())))}_onUpdate(e,n){if(!this.element.parentElement)return;const{width:r}=this.element.parentElement.getBoundingClientRect(),i=e/r*this.totalDuration,s=n&&n!=="start"?this.start:this.start+i,o=n&&n!=="end"?this.end:this.end+i,a=o-s;s>=0&&o<=this.totalDuration&&s<=o&&a>=this.minLength&&a<=this.maxLength&&(this.start=s,this.end=o,this.renderPosition(),this.emit("update",n))}onMove(e){this.drag&&this._onUpdate(e)}onResize(e,n){this.resize&&this._onUpdate(e,n)}onEndResizing(){this.resize&&this.emit("update-end")}onContentClick(e){e.stopPropagation(),e.target.focus(),this.emit("click",e)}onContentBlur(){this.emit("update-end")}_setTotalDuration(e){this.totalDuration=e,this.renderPosition()}play(){this.emit("play")}setContent(e){var n;if((n=this.content)===null||n===void 0||n.remove(),e){if(typeof e=="string"){const r=this.start===this.end;this.content=cl("div",{style:{padding:`0.2em ${r?.2:.4}em`,display:"inline-block"},textContent:e})}else this.content=e;this.contentEditable&&(this.content.contentEditable="true"),this.content.setAttribute("part","region-content"),this.element.appendChild(this.content)}else this.content=void 0}setOptions(e){var n,r;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 i=this.start===this.end;this.start=this.clampPosition((n=e.start)!==null&&n!==void 0?n:this.start),this.end=this.clampPosition((r=e.end)!==null&&r!==void 0?r:i?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 i=this.start===this.end;this.resize=e.resize,this.resize&&!i?this.addResizeHandles(this.element):this.removeResizeHandles(this.element)}}remove(){this.emit("remove"),this.element.remove(),this.element=null}}class p1 extends Ng{constructor(e){super(e),this.regions=[],this.regionsContainer=this.initRegionsContainer()}static create(e){return new p1(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",n=>{const r=this.regions.filter(i=>i.start<=n&&(i.end===i.start?i.start+.05:i.end)>=n);r.forEach(i=>{e.includes(i)||this.emit("region-in",i)}),e.forEach(i=>{r.includes(i)||this.emit("region-out",i)}),e=r}))}initRegionsContainer(){return cl("div",{style:{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",zIndex:"3",pointerEvents:"none"}})}getRegions(){return this.regions}avoidOverlapping(e){if(!e.content)return;const n=e.content,r=n.getBoundingClientRect(),i=this.regions.map(s=>{if(s===e||!s.content)return 0;const o=s.content.getBoundingClientRect();return r.left<o.left+o.width&&o.left<r.left+r.width?o.height:0}).reduce((s,o)=>s+o,0);n.style.marginTop=`${i}px`}adjustScroll(e){var n,r;const i=(r=(n=this.wavesurfer)===null||n===void 0?void 0:n.getWrapper())===null||r===void 0?void 0:r.parentElement;if(!i)return;const{clientWidth:s,scrollWidth:o}=i;if(o<=s)return;const a=i.getBoundingClientRect(),l=e.element.getBoundingClientRect(),c=l.left-a.left,u=l.right-a.left;c<0?i.scrollLeft+=c:u>s&&(i.scrollLeft+=u-s)}saveRegion(e){this.regionsContainer.appendChild(e.element),this.avoidOverlapping(e),this.regions.push(e);const n=[e.on("update",r=>{r||this.adjustScroll(e)}),e.on("update-end",()=>{this.avoidOverlapping(e),this.emit("region-updated",e)}),e.on("play",()=>{var r,i;(r=this.wavesurfer)===null||r===void 0||r.play(),(i=this.wavesurfer)===null||i===void 0||i.setTime(e.start)}),e.on("click",r=>{this.emit("region-clicked",e,r)}),e.on("dblclick",r=>{this.emit("region-double-clicked",e,r)}),e.once("remove",()=>{n.forEach(r=>r()),this.regions=this.regions.filter(r=>r!==e),this.emit("region-removed",e)})];this.subscriptions.push(...n),this.emit("region-created",e)}addRegion(e){var n,r;if(!this.wavesurfer)throw Error("WaveSurfer is not initialized");const i=this.wavesurfer.getDuration(),s=(r=(n=this.wavesurfer)===null||n===void 0?void 0:n.getDecodedData())===null||r===void 0?void 0:r.numberOfChannels,o=new s0(e,i,s);return i?this.saveRegion(o):this.subscriptions.push(this.wavesurfer.once("ready",a=>{o._setTotalDuration(a),this.saveRegion(o)})),o}enableDragSelection(e,n=3){var r;const i=(r=this.wavesurfer)===null||r===void 0?void 0:r.getWrapper();if(!(i&&i instanceof HTMLElement))return()=>{};let s=null,o=0;return Cu(i,(a,l,c)=>{s&&s._onUpdate(a,c>o?"end":"start")},a=>{var l,c;if(o=a,!this.wavesurfer)return;const u=this.wavesurfer.getDuration(),f=(c=(l=this.wavesurfer)===null||l===void 0?void 0:l.getDecodedData())===null||c===void 0?void 0:c.numberOfChannels,{width:g}=this.wavesurfer.getWrapper().getBoundingClientRect(),v=a/g*u,_=(a+5)/g*u;s=new s0(Object.assign(Object.assign({},e),{start:v,end:_}),u,f),this.regionsContainer.appendChild(s.element)},()=>{s&&(this.saveRegion(s),s=null)},n)}clearRegions(){this.regions.forEach(e=>e.remove())}destroy(){this.clearRegions(),super.destroy(),this.regionsContainer.remove()}}function Vg(t){let e;return{c(){e=Nt("Edit Subtitle")},m(n,r){he(n,e,r)},d(n){n&&de(e)}}}function o0(t){let e,n;return e=new Sn({props:{ignoreSkipKeyListener:!0,buttonClasses:"match-btns m-l-s",path:nl,title:t[10],action:Re.CANCEL_EXPORT,subtitle:t[0]}}),e.$on("executed",t[29]),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},p(r,i){const s={};i[0]&1024&&(s.title=r[10]),i[0]&1&&(s.subtitle=r[0]),e.$set(s)},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function a0(t){let e,n,r,i,s;return n=new kt({props:{path:r1}}),{c(){e=_e("button"),ye(n.$$.fragment),ie(e,"title",Re.ALIGN_SUBTITLE),ie(e,"class","m-l-s")},m(o,a){he(o,e,a),be(n,e,null),r=!0,i||(s=Xe(e,"click",t[18]),i=!0)},p:wt,i(o){r||(Z(n.$$.fragment,o),r=!0)},o(o){ne(n.$$.fragment,o),r=!1},d(o){o&&de(e),we(n),i=!1,s()}}}function Hg(t){let e,n,r,i,s,o,a,l,c,u,f,g,v,_,b,y,p,m,w,C,h,A,L,$,P=t[0].text+"",I,x,ae,V,E,F,N;i=new kt({props:{path:al}}),c=new kt({props:{path:Xd}}),g=new kt({props:{path:Zo}}),_=new Sn({props:{ignoreSkipKeyListener:!0,buttonClasses:"m-l-s",path:rl,title:t[6],action:Re.EXPORT_NEW,subtitle:t[0],clickHandler:t[19]}}),_.$on("executed",t[20]),y=new Sn({props:{ignoreSkipKeyListener:!0,buttonClasses:"m-l-s",path:il,title:t[7],action:Re.EXPORT_UPDATE,subtitle:t[0],clickHandler:t[19]}}),y.$on("executed",t[20]),m=new Sn({props:{ignoreSkipKeyListener:!0,buttonClasses:"m-l-s",path:ol,title:t[8],action:Re.OPEN_LAST_EXPORTED_CARD,subtitle:t[0]}});let Y=t[9]&&o0(t),K=!t[13]&&t[11].matchedBy&&a0(t);return V=new Sn({props:{path:Eu,title:Re.COPY_SUBTITLE,action:Re.COPY_SUBTITLE,subtitle:t[0],ignoreSkipKeyListener:!0,buttonClasses:"match-btns m-l-s"}}),{c(){e=_e("div"),n=_e("div"),r=_e("button"),ye(i.$$.fragment),a=me(),l=_e("button"),ye(c.$$.fragment),u=me(),f=_e("button"),ye(g.$$.fragment),v=me(),ye(_.$$.fragment),b=me(),ye(y.$$.fragment),p=me(),ye(m.$$.fragment),w=me(),Y&&Y.c(),C=me(),h=_e("div"),A=me(),L=_e("div"),$=_e("div"),I=Nt(P),x=me(),K&&K.c(),ae=me(),ye(V.$$.fragment),ie(r,"title",s=t[4]?"Pause playback":"Already paused"),r.disabled=o=!t[4],ie(l,"title","Play active subtitle"),ie(l,"class","m-l-s"),ie(f,"title","Restore time"),ie(f,"class","m-l-s"),ie(h,"class","waveform w-full h-full"),ie(L,"class","flex items-center"),ie(e,"class","w-full p-x-xs"),ie(e,"slot","content")},m(J,j){he(J,e,j),oe(e,n),oe(n,r),be(i,r,null),oe(n,a),oe(n,l),be(c,l,null),oe(n,u),oe(n,f),be(g,f,null),oe(n,v),be(_,n,null),oe(n,b),be(y,n,null),oe(n,p),be(m,n,null),oe(n,w),Y&&Y.m(n,null),oe(e,C),oe(e,h),t[30](h),oe(e,A),oe(e,L),oe(L,$),oe($,I),oe(L,x),K&&K.m(L,null),oe(L,ae),be(V,L,null),E=!0,F||(N=[Xe(r,"click",t[16]),Xe(l,"click",t[17]),Xe(f,"click",t[28]),Xe(e,"touchstart",Ra(t[27]))],F=!0)},p(J,j){(!E||j[0]&16&&s!==(s=J[4]?"Pause playback":"Already paused"))&&ie(r,"title",s),(!E||j[0]&16&&o!==(o=!J[4]))&&(r.disabled=o);const B={};j[0]&64&&(B.title=J[6]),j[0]&1&&(B.subtitle=J[0]),_.$set(B);const M={};j[0]&128&&(M.title=J[7]),j[0]&1&&(M.subtitle=J[0]),y.$set(M);const S={};j[0]&256&&(S.title=J[8]),j[0]&1&&(S.subtitle=J[0]),m.$set(S),J[9]?Y?(Y.p(J,j),j[0]&512&&Z(Y,1)):(Y=o0(J),Y.c(),Z(Y,1),Y.m(n,null)):Y&&(jt(),ne(Y,1,1,()=>{Y=null}),zt()),(!E||j[0]&1)&&P!==(P=J[0].text+"")&&cn(I,P),!J[13]&&J[11].matchedBy?K?(K.p(J,j),j[0]&2048&&Z(K,1)):(K=a0(J),K.c(),Z(K,1),K.m(L,ae)):K&&(jt(),ne(K,1,1,()=>{K=null}),zt());const R={};j[0]&1&&(R.subtitle=J[0]),V.$set(R)},i(J){E||(Z(i.$$.fragment,J),Z(c.$$.fragment,J),Z(g.$$.fragment,J),Z(_.$$.fragment,J),Z(y.$$.fragment,J),Z(m.$$.fragment,J),Z(Y),Z(K),Z(V.$$.fragment,J),E=!0)},o(J){ne(i.$$.fragment,J),ne(c.$$.fragment,J),ne(g.$$.fragment,J),ne(_.$$.fragment,J),ne(y.$$.fragment,J),ne(m.$$.fragment,J),ne(Y),ne(K),ne(V.$$.fragment,J),E=!1},d(J){J&&de(e),we(i),we(c),we(g),we(_),we(y),we(m),Y&&Y.d(),t[30](null),K&&K.d(),we(V),F=!1,vn(N)}}}function xg(t){let e,n,r,i,s,o;return{c(){e=_e("div"),n=_e("button"),n.textContent="Cancel",r=me(),i=_e("button"),i.textContent="Save",ie(e,"class","flex grow justify-between p-x-xs"),ie(e,"slot","footer")},m(a,l){he(a,e,l),oe(e,n),oe(e,r),oe(e,i),s||(o=[Xe(n,"click",t[21]),Xe(i,"click",t[22])],s=!0)},p:wt,d(a){a&&de(e),s=!1,vn(o)}}}function Ug(t){let e,n,r,i,s,o;return e=new vu({props:{$$slots:{footer:[xg],content:[Hg],header:[Vg]},$$scope:{ctx:t}}}),{c(){ye(e.$$.fragment),n=me(),r=_e("div"),r.innerHTML='<span class="spinner"></span>',ie(r,"class","backdrop"),pt(r,"hidden",!t[2]&&!t[9])},m(a,l){be(e,a,l),he(a,n,l),he(a,r,l),i=!0,s||(o=Xe(window,"keydown",t[15]),s=!0)},p(a,l){const c={};l[0]&4091|l[1]&32768&&(c.$$scope={dirty:l,ctx:a}),e.$set(c),(!i||l[0]&516)&&pt(r,"hidden",!a[2]&&!a[9])},i(a){i||(Z(e.$$.fragment,a),i=!0)},o(a){ne(e.$$.fragment,a),i=!1},d(a){a&&(de(n),de(r)),we(e,a),s=!1,o()}}}function Wg(t,e,n){let r,i,s,o,a,l,c,u,f,g;ce(t,$a,ke=>n(36,r=ke)),ce(t,Va,ke=>n(38,s=ke)),ce(t,Lr,ke=>n(39,o=ke)),ce(t,is,ke=>n(6,a=ke)),ce(t,ss,ke=>n(7,l=ke)),ce(t,os,ke=>n(8,c=ke)),ce(t,vi,ke=>n(9,u=ke)),ce(t,Xo,ke=>n(10,f=ke)),ce(t,xo,ke=>n(11,g=ke));let{activeSubtitle:v}=e,{subtitleRegions:_}=e,{resolver:b}=e;const y=_[0].startSeconds,p=getComputedStyle(document.documentElement).getPropertyValue("--ttu-whispersync-color"),m=Ri(),w=JSON.parse(JSON.stringify(v)),C=v.text!==v.originalText,{ankiEnableOpenInBrowser$:h}=_t;ce(t,h,ke=>n(37,i=ke));let A,L,$,P=!0,I,x,ae=!1,V=!1,E=-1,F;Oa(X),Yl(()=>{F==null||F(),L==null||L.destroy(),URL.revokeObjectURL(I)});function N(ke){if(P||ke.repeat||!(ke.ctrlKey||ke.metaKey||ke.altKey))return;const Ne=(ke.code||ke.key||"").toLowerCase();let Te=Re.NONE,Le=!0;if(ke.altKey)switch(Ne){case"keyd":case"d":Te=Re.TOGGLE_PLAY_PAUSE;break;case"keye":case"e":Te=Re.EXPORT_UPDATE;break;case"keyz":case"z":Te=Re.COPY_SUBTITLE;break;case"keyj":case"j":Y();break;default:Le=!1;break}else switch(Ne){case"space":case" ":Y();break;case"keyd":case"d":Te=Re.TOGGLE_PLAY_PAUSE;break;case"keye":case"e":Te=Re.EXPORT_NEW;break;case"keyo":case"o":Te=Re.OPEN_LAST_EXPORTED_CARD;break;default:Le=!1;break}Le&&(ke.preventDefault(),ke.stopPropagation()),Te===Re.TOGGLE_PLAY_PAUSE?K():Fn(Te,v,{ignoreSkipKeyListener:!0})}function Y(){L.pause(),F==null||F(),E=-1}function K(){F==null||F(),E=x.end,F=L.on("timeupdate",J),L.setTime(x.start),L.play()}function J(ke){ke>E&&Y()}async function j(){n(2,P=!0),await Fn(Re.ALIGN_SUBTITLE,w,{persistAlignment:!1,ignoreSkipKeyListener:!0}),n(0,v.text=o.get(v.id).text,v),n(2,P=!1)}function B(){n(5,V=!1)}function M(){if(V||!s&&!i)return;const ke=x.start+y,Ne=x.end+y;return!C&&v.text!==v.originalText||ke!==w.startSeconds||Ne!==w.endSeconds?R():z({wasCanceled:!0})}function S(){if(!C&&v.text!==v.originalText)return z({wasCanceled:!1,subtitle:w});z({wasCanceled:!0})}function R(){W(),z({wasCanceled:!1,subtitle:v})}async function X(){try{if(!r)throw new Error("Audio file required");const ke=await Cd(r,[an(_[0].startSeconds,_[_.length-1].endSeconds)]);if(!ke)throw new Error("No audio file returned");I=URL.createObjectURL(new Blob([ke],{type:"audio/mpeg"})),L=ul.create({container:A,waveColor:p,url:I}),$=L.registerPlugin(p1.create()),L.once("decode",()=>{for(let Ne=0,{length:Te}=_;Ne<Te;Ne+=1){const Le=_[Ne];if(Le.subIndex===-1)continue;const Fe=v.id===Le.id,Ze=$.addRegion(re(Le,Fe));Fe?(Ze.element.part.add("active"),Ze.on("update",Y),Ze.on("update-end",W),n(3,x=Ze),W()):Ze.element.part.add("inactive")}}),L.on("interaction",Ne=>{F==null||F(),Ne>=x.start&&Ne<=x.end&&(E=x.end,F=L.on("timeupdate",J)),L.play()}),L.on("play",()=>n(4,ae=!0)),L.on("pause",()=>n(4,ae=!1)),L.once("ready",()=>{n(2,P=!1)})}catch({message:ke}){n(2,P=!1),z({wasCanceled:!1,error:`Failed to create waveform: ${ke}`})}}function re(ke,Ne=!0){return{start:ke.startSeconds-y,end:ke.endSeconds-y,color:p,drag:Ne,resize:Ne,id:ke.id}}function W(){const ke=x.start+y,Ne=x.end+y;n(0,v={...v,adjustedStartSeconds:ke,startSeconds:ke,startTime:Qr(ke),adjustedEndSeconds:Ne,endSeconds:Ne,endTime:Qr(Ne)})}function z(ke){b==null||b(ke),m("close")}function le(ke){mn.call(this,t,ke)}const Me=()=>{Y(),x.setOptions(re(w)),x.element.part.add("active"),W()},Ee=()=>n(5,V=!0);function ve(ke){Vt[ke?"unshift":"push"](()=>{A=ke,n(1,A)})}return t.$$set=ke=>{"activeSubtitle"in ke&&n(0,v=ke.activeSubtitle),"subtitleRegions"in ke&&n(25,_=ke.subtitleRegions),"resolver"in ke&&n(26,b=ke.resolver)},[v,A,P,x,ae,V,a,l,c,u,f,g,w,C,h,N,Y,K,j,B,M,S,R,re,W,_,b,le,Me,Ee,ve]}class Gg extends Dn{constructor(e){super(),Bn(this,e,Wg,Ug,Cn,{activeSubtitle:0,subtitleRegions:25,resolver:26},null,[-1,-1])}}function jg(t){let e,n,r,i;return{c(){e=_e("input"),ie(e,"type","number"),ie(e,"class","time-input"),ie(e,"min",t[1]),ie(e,"max",t[2]),ie(e,"step",t[3])},m(s,o){he(s,e,o),Mi(e,t[0]),r||(i=[Xe(e,"input",t[7]),Xe(e,"change",t[5]),Ma(n=Mu.call(null,e,{document,isSkipped:t[4]}))],r=!0)},p(s,[o]){o&2&&ie(e,"min",s[1]),o&4&&ie(e,"max",s[2]),o&8&&ie(e,"step",s[3]),o&1&&Nc(e.value)!==s[0]&&Mi(e,s[0]),n&&Ci(n.update)&&o&16&&n.update.call(null,{document,isSkipped:s[4]})},i:wt,o:wt,d(s){s&&de(e),r=!1,vn(i)}}}function zg(t,e,n){let r;ce(t,En,g=>n(4,r=g));let{value:i}=e,{defaultValue:s}=e,{min:o=0}=e,{max:a=59}=e,{step:l=1}=e;const c=Ri();async function u(g){await X_(g,s),c("changed")}function f(){i=Nc(this.value),n(0,i)}return t.$$set=g=>{"value"in g&&n(0,i=g.value),"defaultValue"in g&&n(6,s=g.defaultValue),"min"in g&&n(1,o=g.min),"max"in g&&n(2,a=g.max),"step"in g&&n(3,l=g.step)},[i,o,a,l,r,u,s,f]}class Pi extends Dn{constructor(e){super(),Bn(this,e,zg,jg,Cn,{value:0,defaultValue:6,min:1,max:2,step:3})}}function l0(t){let e,n,r=!1,i,s=!0,o,a;function l(){cancelAnimationFrame(i),e.paused||(i=id(l),r=!0),t[46].call(e)}return{c(){e=_e("audio"),e.controls=!0,ie(e,"class","hidden"),Co(e.src,n=t[10])||ie(e,"src",n),t[1]===void 0&&Ms(()=>t[45].call(e))},m(c,u){he(c,e,u),t[48](e),o||(a=[Xe(e,"durationchange",t[45]),Xe(e,"timeupdate",l),Xe(e,"play",t[47]),Xe(e,"pause",t[47]),Xe(e,"loadedmetadata",t[34]),Xe(e,"timeupdate",t[35])],o=!0)},p(c,u){u[0]&1024&&!Co(e.src,n=c[10])&&ie(e,"src",n),!r&&u[0]&8192&&!isNaN(c[13])&&(e.currentTime=c[13]),r=!1,u[0]&16384&&s!==(s=c[14])&&e[s?"pause":"play"]()},d(c){c&&de(e),t[48](null),o=!1,vn(a)}}}function Xg(t){let e;return{c(){e=Nt("Edit Subtitle")},m(n,r){he(n,e,r)},d(n){n&&de(e)}}}function u0(t){let e,n,r,i,s,o,a,l;return n=new kt({props:{path:t[14]?ku:al}}),s=new kt({props:{path:Xd}}),{c(){e=_e("button"),ye(n.$$.fragment),r=me(),i=_e("button"),ye(s.$$.fragment),ie(e,"title","Toggle playback"),ie(i,"title","Replay"),ie(i,"class","m-l-s")},m(c,u){he(c,e,u),be(n,e,null),he(c,r,u),he(c,i,u),be(s,i,null),o=!0,a||(l=[Xe(e,"click",t[49]),Xe(i,"click",t[36])],a=!0)},p(c,u){const f={};u[0]&16384&&(f.path=c[14]?ku:al),n.$set(f)},i(c){o||(Z(n.$$.fragment,c),Z(s.$$.fragment,c),o=!0)},o(c){ne(n.$$.fragment,c),ne(s.$$.fragment,c),o=!1},d(c){c&&(de(e),de(r),de(i)),we(n),we(s),a=!1,vn(l)}}}function c0(t){let e,n;return e=new Sn({props:{ignoreSkipKeyListener:!0,buttonClasses:"match-btns m-l-s",path:nl,title:t[21],action:Re.CANCEL_EXPORT,subtitle:t[0]}}),e.$on("executed",t[51]),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},p(r,i){const s={};i[0]&2097152&&(s.title=r[21]),i[0]&1&&(s.subtitle=r[0]),e.$set(s)},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function f0(t){let e,n,r,i,s;return n=new kt({props:{path:r1}}),{c(){e=_e("button"),ye(n.$$.fragment),ie(e,"title",Re.ALIGN_SUBTITLE),ie(e,"class","m-l-s")},m(o,a){he(o,e,a),be(n,e,null),r=!0,i||(s=Xe(e,"click",t[38]),i=!0)},p:wt,i(o){r||(Z(n.$$.fragment,o),r=!0)},o(o){ne(n.$$.fragment,o),r=!1},d(o){o&&de(e),we(n),i=!1,s()}}}function Yg(t){let e,n,r,i,s,o,a,l,c,u,f,g,v,_,b,y,p,m,w,C,h,A,L,$,P,I,x,ae,V,E,F,N,Y,K,J,j,B,M,S,R,X,re,W,z,le,Me,Ee,ve,ke,Ne,Te,Le,Fe,Ze,O,H,Pe,xe=t[0].text+"",qe,nt,Oe,je,et,rt,Je,G=t[10]&&u0(t);s=new kt({props:{path:Zo}}),a=new Sn({props:{ignoreSkipKeyListener:!0,buttonClasses:"m-l-s",path:rl,title:t[17],action:Re.EXPORT_NEW,subtitle:t[0],clickHandler:t[39]}}),a.$on("executed",t[40]),c=new Sn({props:{ignoreSkipKeyListener:!0,buttonClasses:"m-l-s",path:il,title:t[18],action:Re.EXPORT_UPDATE,subtitle:t[0],clickHandler:t[39]}}),c.$on("executed",t[40]),f=new Sn({props:{ignoreSkipKeyListener:!0,buttonClasses:"m-l-s",path:ol,title:t[19],action:Re.OPEN_LAST_EXPORTED_CARD,subtitle:t[0]}});let T=t[20]&&c0(t);function d($e){t[52]($e)}let k={defaultValue:t[24],max:t[16]};t[2]!==void 0&&(k.value=t[2]),p=new Pi({props:k}),Vt.push(()=>Zn(p,"value",d)),p.$on("changed",t[37]);function D($e){t[53]($e)}let U={defaultValue:t[25]};t[3]!==void 0&&(U.value=t[3]),A=new Pi({props:U}),Vt.push(()=>Zn(A,"value",D)),A.$on("changed",t[37]);function te($e){t[54]($e)}let ee={defaultValue:t[26]};t[4]!==void 0&&(ee.value=t[4]),x=new Pi({props:ee}),Vt.push(()=>Zn(x,"value",te)),x.$on("changed",t[37]);function se($e){t[55]($e)}let ge={defaultValue:t[27],max:999,step:100};t[5]!==void 0&&(ge.value=t[5]),N=new Pi({props:ge}),Vt.push(()=>Zn(N,"value",se)),N.$on("changed",t[37]);function pe($e){t[56]($e)}let Ae={defaultValue:t[28],max:t[16]};t[6]!==void 0&&(Ae.value=t[6]),M=new Pi({props:Ae}),Vt.push(()=>Zn(M,"value",pe)),M.$on("changed",t[37]);function Ce($e){t[57]($e)}let De={defaultValue:t[29]};t[7]!==void 0&&(De.value=t[7]),W=new Pi({props:De}),Vt.push(()=>Zn(W,"value",Ce)),W.$on("changed",t[37]);function tt($e){t[58]($e)}let mt={defaultValue:t[30]};t[8]!==void 0&&(mt.value=t[8]),ve=new Pi({props:mt}),Vt.push(()=>Zn(ve,"value",tt)),ve.$on("changed",t[37]);function We($e){t[59]($e)}let dt={defaultValue:t[31],max:999,step:100};t[9]!==void 0&&(dt.value=t[9]),Fe=new Pi({props:dt}),Vt.push(()=>Zn(Fe,"value",We)),Fe.$on("changed",t[37]);let Be=!t[32]&&t[22].matchedBy&&f0(t);return je=new Sn({props:{path:Eu,title:Re.COPY_SUBTITLE,action:Re.COPY_SUBTITLE,subtitle:t[0],ignoreSkipKeyListener:!0,buttonClasses:"match-btns m-l-s"}}),{c(){e=_e("div"),n=_e("div"),G&&G.c(),r=me(),i=_e("button"),ye(s.$$.fragment),o=me(),ye(a.$$.fragment),l=me(),ye(c.$$.fragment),u=me(),ye(f.$$.fragment),g=me(),T&&T.c(),v=me(),_=_e("div"),b=_e("div"),y=_e("div"),ye(p.$$.fragment),w=me(),C=_e("span"),C.textContent=":",h=me(),ye(A.$$.fragment),$=me(),P=_e("span"),P.textContent=":",I=me(),ye(x.$$.fragment),V=me(),E=_e("span"),E.textContent=",",F=me(),ye(N.$$.fragment),K=me(),J=_e("span"),J.textContent="-",j=me(),B=_e("div"),ye(M.$$.fragment),R=me(),X=_e("span"),X.textContent=":",re=me(),ye(W.$$.fragment),le=me(),Me=_e("span"),Me.textContent=":",Ee=me(),ye(ve.$$.fragment),Ne=me(),Te=_e("span"),Te.textContent=",",Le=me(),ye(Fe.$$.fragment),O=me(),H=_e("div"),Pe=_e("div"),qe=Nt(xe),nt=me(),Be&&Be.c(),Oe=me(),ye(je.$$.fragment),ie(i,"title","Restore time"),pt(i,"m-l-s",t[10]),ie(n,"class","m-b-s"),ie(y,"class","flex"),ie(J,"class","m-b"),ie(B,"class","flex"),ie(b,"class","flex items-center time-edit m-b-s"),ie(H,"class","flex items-center m-t-b"),ie(_,"class","flex flex-col"),ie(e,"slot","content")},m($e,ft){he($e,e,ft),oe(e,n),G&&G.m(n,null),oe(n,r),oe(n,i),be(s,i,null),oe(n,o),be(a,n,null),oe(n,l),be(c,n,null),oe(n,u),be(f,n,null),oe(n,g),T&&T.m(n,null),oe(e,v),oe(e,_),oe(_,b),oe(b,y),be(p,y,null),oe(y,w),oe(y,C),oe(y,h),be(A,y,null),oe(y,$),oe(y,P),oe(y,I),be(x,y,null),oe(y,V),oe(y,E),oe(y,F),be(N,y,null),oe(b,K),oe(b,J),oe(b,j),oe(b,B),be(M,B,null),oe(B,R),oe(B,X),oe(B,re),be(W,B,null),oe(B,le),oe(B,Me),oe(B,Ee),be(ve,B,null),oe(B,Ne),oe(B,Te),oe(B,Le),be(Fe,B,null),oe(_,O),oe(_,H),oe(H,Pe),oe(Pe,qe),oe(H,nt),Be&&Be.m(H,null),oe(H,Oe),be(je,H,null),et=!0,rt||(Je=Xe(i,"click",t[50]),rt=!0)},p($e,ft){$e[10]?G?(G.p($e,ft),ft[0]&1024&&Z(G,1)):(G=u0($e),G.c(),Z(G,1),G.m(n,r)):G&&(jt(),ne(G,1,1,()=>{G=null}),zt()),(!et||ft[0]&1024)&&pt(i,"m-l-s",$e[10]);const ze={};ft[0]&131072&&(ze.title=$e[17]),ft[0]&1&&(ze.subtitle=$e[0]),a.$set(ze);const at={};ft[0]&262144&&(at.title=$e[18]),ft[0]&1&&(at.subtitle=$e[0]),c.$set(at);const Qe={};ft[0]&524288&&(Qe.title=$e[19]),ft[0]&1&&(Qe.subtitle=$e[0]),f.$set(Qe),$e[20]?T?(T.p($e,ft),ft[0]&1048576&&Z(T,1)):(T=c0($e),T.c(),Z(T,1),T.m(n,null)):T&&(jt(),ne(T,1,1,()=>{T=null}),zt());const vt={};ft[0]&65536&&(vt.max=$e[16]),!m&&ft[0]&4&&(m=!0,vt.value=$e[2],Yn(()=>m=!1)),p.$set(vt);const Rt={};!L&&ft[0]&8&&(L=!0,Rt.value=$e[3],Yn(()=>L=!1)),A.$set(Rt);const lt={};!ae&&ft[0]&16&&(ae=!0,lt.value=$e[4],Yn(()=>ae=!1)),x.$set(lt);const St={};!Y&&ft[0]&32&&(Y=!0,St.value=$e[5],Yn(()=>Y=!1)),N.$set(St);const ht={};ft[0]&65536&&(ht.max=$e[16]),!S&&ft[0]&64&&(S=!0,ht.value=$e[6],Yn(()=>S=!1)),M.$set(ht);const xt={};!z&&ft[0]&128&&(z=!0,xt.value=$e[7],Yn(()=>z=!1)),W.$set(xt);const ln={};!ke&&ft[0]&256&&(ke=!0,ln.value=$e[8],Yn(()=>ke=!1)),ve.$set(ln);const qt={};!Ze&&ft[0]&512&&(Ze=!0,qt.value=$e[9],Yn(()=>Ze=!1)),Fe.$set(qt),(!et||ft[0]&1)&&xe!==(xe=$e[0].text+"")&&cn(qe,xe),!$e[32]&&$e[22].matchedBy?Be?(Be.p($e,ft),ft[0]&4194304&&Z(Be,1)):(Be=f0($e),Be.c(),Z(Be,1),Be.m(H,Oe)):Be&&(jt(),ne(Be,1,1,()=>{Be=null}),zt());const Dt={};ft[0]&1&&(Dt.subtitle=$e[0]),je.$set(Dt)},i($e){et||(Z(G),Z(s.$$.fragment,$e),Z(a.$$.fragment,$e),Z(c.$$.fragment,$e),Z(f.$$.fragment,$e),Z(T),Z(p.$$.fragment,$e),Z(A.$$.fragment,$e),Z(x.$$.fragment,$e),Z(N.$$.fragment,$e),Z(M.$$.fragment,$e),Z(W.$$.fragment,$e),Z(ve.$$.fragment,$e),Z(Fe.$$.fragment,$e),Z(Be),Z(je.$$.fragment,$e),et=!0)},o($e){ne(G),ne(s.$$.fragment,$e),ne(a.$$.fragment,$e),ne(c.$$.fragment,$e),ne(f.$$.fragment,$e),ne(T),ne(p.$$.fragment,$e),ne(A.$$.fragment,$e),ne(x.$$.fragment,$e),ne(N.$$.fragment,$e),ne(M.$$.fragment,$e),ne(W.$$.fragment,$e),ne(ve.$$.fragment,$e),ne(Fe.$$.fragment,$e),ne(Be),ne(je.$$.fragment,$e),et=!1},d($e){$e&&de(e),G&&G.d(),we(s),we(a),we(c),we(f),T&&T.d(),we(p),we(A),we(x),we(N),we(M),we(W),we(ve),we(Fe),Be&&Be.d(),we(je),rt=!1,Je()}}}function Kg(t){let e,n,r,i,s,o;return{c(){e=_e("div"),n=_e("button"),n.textContent="Cancel",r=me(),i=_e("button"),i.textContent="Save",ie(e,"class","flex grow justify-between"),ie(e,"slot","footer")},m(a,l){he(a,e,l),oe(e,n),oe(e,r),oe(e,i),s||(o=[Xe(n,"click",t[41]),Xe(i,"click",t[42])],s=!0)},p:wt,d(a){a&&de(e),s=!1,vn(o)}}}function qg(t){let e,n,r,i,s,o,a,l=t[10]&&l0(t);return n=new vu({props:{$$slots:{footer:[Kg],content:[Yg],header:[Xg]},$$scope:{ctx:t}}}),{c(){l&&l.c(),e=me(),ye(n.$$.fragment),r=me(),i=_e("div"),i.innerHTML='<span class="spinner"></span>',ie(i,"class","backdrop"),pt(i,"hidden",!t[12]&&!t[20])},m(c,u){l&&l.m(c,u),he(c,e,u),be(n,c,u),he(c,r,u),he(c,i,u),s=!0,o||(a=Xe(window,"keydown",t[33]),o=!0)},p(c,u){c[10]?l?l.p(c,u):(l=l0(c),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null);const f={};u[0]&8374269|u[2]&512&&(f.$$scope={dirty:u,ctx:c}),n.$set(f),(!s||u[0]&1052672)&&pt(i,"hidden",!c[12]&&!c[20])},i(c){s||(Z(n.$$.fragment,c),s=!0)},o(c){ne(n.$$.fragment,c),s=!1},d(c){c&&(de(e),de(r),de(i)),l&&l.d(c),we(n,c),o=!1,a()}}}function Zg(t,e,n){let r,i,s,o,a,l,c,u,f,g,v,_,b,y;ce(t,Va,se=>n(63,a=se)),ce(t,Lr,se=>n(64,l=se)),ce(t,Na,se=>n(10,c=se)),ce(t,xi,se=>n(65,u=se)),ce(t,is,se=>n(17,f=se)),ce(t,ss,se=>n(18,g=se)),ce(t,os,se=>n(19,v=se)),ce(t,vi,se=>n(20,_=se)),ce(t,Xo,se=>n(21,b=se)),ce(t,xo,se=>n(22,y=se));let{activeSubtitle:p}=e,{resolver:m}=e;const{isIOS:w}=Io("context"),{ankiEnableOpenInBrowser$:C}=_t;ce(t,C,se=>n(62,o=se));const[h,A,L,$]=us(p.startSeconds),[P,I,x,ae]=us(p.endSeconds),V=JSON.parse(JSON.stringify(p)),E=p.text!==p.originalText,F=Ri();let N,Y=!!c,K=p.startSeconds,J=0,j=!0,B=!1,[M,S,R,X]=[h,A,L,$],[re,W,z,le]=[P,I,x,ae];function Me(se){if(Y||u||se.repeat||!(se.ctrlKey||se.metaKey||se.altKey))return;const ge=(se.code||se.key||"").toLowerCase();let pe=Re.NONE,Ae=!0;if(se.altKey)switch(ge){case"keyd":case"d":pe=c?Re.TOGGLE_PLAY_PAUSE:Re.NONE;break;case"keye":case"e":H(),pe=Re.EXPORT_UPDATE;break;case"keyz":case"z":pe=Re.COPY_SUBTITLE;break;case"keyj":case"j":c&&n(14,j=!j);break;default:Ae=!1;break}else switch(ge){case"space":case" ":c&&n(14,j=!j);break;case"keyd":case"d":pe=c?Re.TOGGLE_PLAY_PAUSE:Re.NONE;break;case"keye":case"e":H(),pe=Re.EXPORT_NEW;break;case"keyo":case"o":pe=Re.OPEN_LAST_EXPORTED_CARD;break;default:Ae=!1;break}Ae&&(se.preventDefault(),se.stopPropagation()),pe===Re.TOGGLE_PLAY_PAUSE?ke():Fn(pe,p,{ignoreSkipKeyListener:!0})}async function Ee(){if(!w){n(11,N.currentTime=p.startSeconds,N),n(12,Y=!1);return}let se=0,ge;const pe=new Promise(Ce=>{ge=Ce,N.addEventListener("loadeddata",Ce,{once:!0,capture:!1})});await new Promise(Ce=>{const De=setInterval(async()=>{try{se+=1,N.play(),setTimeout(ge,1e4),await pe,N.pause(),clearInterval(De),Ce()}catch{}se>20&&(clearInterval(De),ge(void 0),Ce())},500)}),n(11,N.currentTime=p.startSeconds,N),await Mr(),n(12,Y=!1)}function ve(){K>i&&H()}function ke(){n(13,K=r),n(14,j=!1)}async function Ne(){n(14,j=!0),c&&r>J&&n(2,[M,S,R,X]=us(i),M,n(3,S),n(4,R),n(5,X)),c&&i>J&&n(6,[re,W,z,le]=us(J),re,n(7,W),n(8,z),n(9,le)),await Mr(),r>i&&(n(2,[M,S,R,X]=us(i),M,n(3,S),n(4,R),n(5,X)),n(6,[re,W,z,le]=us(r),re,n(7,W),n(8,z),n(9,le)),await Mr()),n(13,K=r),Pe()}async function Te(){n(12,Y=!0),await Fn(Re.ALIGN_SUBTITLE,V,{persistAlignment:!1,ignoreSkipKeyListener:!0}),n(0,p.text=l.get(p.id).text,p),n(12,Y=!1)}function Le(){H(),n(15,B=!1)}function Fe(){if(!(B||!a&&!o))return!E&&p.text!==p.originalText||r!==V.startSeconds||i!==V.endSeconds?O():xe({wasCanceled:!0})}function Ze(){if(!E&&p.text!==p.originalText)return xe({wasCanceled:!1,subtitle:V});xe({wasCanceled:!0})}async function O(){await Mr(),Pe(),xe({wasCanceled:!1,subtitle:p})}function H(){n(14,j=!0),n(13,K=r)}function Pe(){n(0,p={...p,adjustedStartSeconds:r,startSeconds:r,startTime:Qr(r),adjustedEndSeconds:i,endSeconds:i,endTime:Qr(i)})}function xe(se){m==null||m(se),F("close")}function qe(){J=this.duration,n(1,J)}function nt(){K=this.currentTime,n(13,K)}function Oe(){j=this.paused,n(14,j)}function je(se){Vt[se?"unshift":"push"](()=>{N=se,n(11,N)})}const et=()=>n(14,j=!j),rt=()=>{n(14,j=!0),n(2,[M,S,R,X]=[h,A,L,$],M,n(3,S),n(4,R),n(5,X)),n(6,[re,W,z,le]=[P,I,x,ae],re,n(7,W),n(8,z),n(9,le)),Mr().then(Pe)},Je=()=>n(15,B=!0);function G(se){M=se,n(2,M)}function T(se){S=se,n(3,S)}function d(se){R=se,n(4,R)}function k(se){X=se,n(5,X)}function D(se){re=se,n(6,re)}function U(se){W=se,n(7,W)}function te(se){z=se,n(8,z)}function ee(se){le=se,n(9,le)}return t.$$set=se=>{"activeSubtitle"in se&&n(0,p=se.activeSubtitle),"resolver"in se&&n(44,m=se.resolver)},t.$$.update=()=>{t.$$.dirty[0]&60&&(r=M*3600+S*60+R+X/1e3),t.$$.dirty[0]&960&&(i=re*3600+W*60+z+le/1e3),t.$$.dirty[0]&1026&&n(16,s=c?Math.floor(J/3600):999)},[p,J,M,S,R,X,re,W,z,le,c,N,Y,K,j,B,s,f,g,v,_,b,y,C,h,A,L,$,P,I,x,ae,E,Me,Ee,ve,ke,Ne,Te,Le,Fe,Ze,O,Pe,m,qe,nt,Oe,je,et,rt,Je,G,T,d,k,D,U,te,ee]}class Jg extends Dn{constructor(e){super(),Bn(this,e,Zg,qg,Cn,{activeSubtitle:0,resolver:44},null,[-1,-1,-1])}}function m1(t,e){t.dispatchEvent(new CustomEvent("ttu-action",{detail:{type:"skipKeyDownListener",params:{value:e}}})),En.set(e)}function d0(t,e){const n=Ct(t);n.has(e)?n.delete(e):n.add(e),t.set(n)}async function Qg(t){Mn.set(!0);const e=Ct(Ps)&&Ct(_t.exportAudioProcessor$)===kr.FFMPEG,n=e?Gg:Jg,r=Ct(Lr),i=[...r.values()],s={activeSubtitle:JSON.parse(JSON.stringify(t))};if(e){const a=i.slice(Math.max(0,t.subIndex-1),t.subIndex+2);if(t.subIndex===0){const l=Math.max(0,t.startSeconds-10);a.unshift(an(l))}else if(t.subIndex===r.size-1){const l=Wi(0,Ct(ls),t.endSeconds+10);a.push(an(l,l))}s.subtitleRegions=JSON.parse(JSON.stringify(a))}const o=await new Promise(a=>{Vo.add({component:n,props:{...s,resolver:a}})});if(o.error)return Mt.set(o.error);o.wasCanceled||!o.subtitle||(r.set(t.id,o.subtitle),Lr.set(r),Za.set({subtitles:[o.subtitle]}),Ct(_t.subtitlesEnablePersist$)&&(Mt.set(""),i[o.subtitle.subIndex]=o.subtitle,await Is({name:Ct(rs).name,subtitles:i}).catch(({message:a})=>Mt.set(a))))}async function eb(t,e){var n;try{Mt.set(""),await new Promise(o=>window.setTimeout(o,100));const r=hu(new DOMParser,Ct(Li).elementHtml),i=Ct(Lr);let s=!1;for(let o=0,{length:a}=t;o<a;o+=1){const l=i.get(t[o].id),c=r.querySelectorAll(Qs(l.id));let u="";for(let f=0,{length:g}=c;f<g;f+=1){const v=c[f],_=(((n=v.parentElement)==null?void 0:n.tagName)||"").toLowerCase();du.has(_)||(u+=v.innerText.trim())}u!==l.originalText&&(l.text=u,i.set(l.id,l),s=!0)}if(!s||(Lr.set(i),!e||!Ct(_t.subtitlesEnablePersist$)))return;Mt.set(""),await Is({name:Ct(rs).name,subtitles:[...i.values()]})}catch({message:r}){Mt.set(`Failed to align: ${r}`)}}async function tb(t){const e=[],n=Ct(Lr),r=Ct(ls),i=Ct(_t.subtitlesGlobalStartPadding$)/1e3,s=Ct(_t.subtitlesGlobalEndPadding$)/1e3;let o=!1;for(let a=0,{length:l}=t;a<l;a+=1){const c=t[a],u=Math.max(0,c.originalStartSeconds+i),f=r?Wi(0,r,c.originalEndSeconds+s):Math.max(0,c.originalEndSeconds+s),g=c.text!==c.originalText,v=Number.isFinite(c.adjustedStartSeconds)&&c.adjustedStartSeconds!==u||Number.isFinite(c.adjustedEndSeconds)&&c.adjustedEndSeconds!==f;if(delete c.adjustedStartSeconds,delete c.adjustedEndSeconds,g||v){const _={...c,startSeconds:u,startTime:Qr(u),endSeconds:f,endTime:Qr(f),text:c.originalText};n.set(c.id,_),o=!0,v&&e.push(_)}}o&&(Lr.set(n),Za.set({subtitles:e}),Ct(_t.subtitlesEnablePersist$)&&(Mt.set(""),await Is({name:Ct(rs).name,subtitles:[...n.values()]}).catch(({message:a})=>Mt.set(a))))}function nb(t,e){if(e)return JSON.parse(JSON.stringify([t]));const n=[];for(let r=0,{length:i}=t;r<i;r+=1)n.push([t[r]]);return JSON.parse(JSON.stringify(n))}var Re=(t=>(t.NONE="None",t.TOGGLE_PLAYBACK="Toggle playback",t.REWIND="Rewind",t.REWIND_ALT="Rewind #2",t.FAST_FORWARD="Fast-Forward",t.FAST_FORWARD_ALT="Fast-Forward #2",t.RESTART_PLAYBACK="Restart playback",t.TOGGLE_PLAY_PAUSE="Toggle play and pause",t.TOGGLE_PLAYBACK_LOOP="Toggle playback loop",t.TOGGLE_BOOKMARK="Toggle bookmark",t.TOGGLE_SHOW_BOOKMARKED="Toggle menu bookmark filter",t.TOGGLE_MERGE="Toggle for merge",t.TOGGLE_SHOW_FOR_MERGE="Toggle menu merge filter",t.ALIGN_SUBTITLE="Align with book text",t.EDIT_SUBTITLE="Edit subtitle",t.RESTORE_SUBTITLE="Restore original text and time",t.COPY_SUBTITLE="Copy subtitle",t.PREVIOUS_SUBTITLE="Go to previous subtitle",t.NEXT_SUBTITLE="Go to next subtitle",t.EXPORT_NEW="Create new card",t.EXPORT_UPDATE="Update last created card",t.OPEN_LAST_EXPORTED_CARD="Open last exported card",t.CANCEL_EXPORT="Cancel Export",t))(Re||{});function rb(t,e){const n=r=>{!r.defaultPrevented&&!t.contains(r.target)&&e(r)};return document.addEventListener("click",n,!0),{destroy(){document.removeEventListener("click",n,!0)}}}function Mu(t,{document:e,isSkipped:n}){const r=()=>m1(e,!0),i=()=>m1(e,!1);return n||(t.addEventListener("focus",r,!1),t.addEventListener("blur",i,!1)),{destroy(){t.removeEventListener("focus",r,!1),t.removeEventListener("blur",i,!1),n||m1(e,!1)}}}async function Fn(t,e,n={mergeSubtitles:!1,skipUpdates:!1,keepPauseState:!1,persistAlignment:!0,ignoreSkipKeyListener:!1}){if(t==="None"||!e||!n.ignoreSkipKeyListener&&Ct(En))return;const r=Array.isArray(e)?e:[e],i=Ct(vi),s=Ct(xi);if(r.length)if(!s&&t==="Toggle playback"){const o=Ct(Mn);Mn.set(!o)}else if(!s&&(t==="Restart playback"||t==="Toggle play and pause"||t==="Toggle playback loop"))fu.set({action:t,subtitles:r,skipUpdates:n.skipUpdates,keepPauseState:n.keepPauseState});else if(t==="Toggle bookmark")d0(cu,r[0].id);else if(t==="Toggle menu bookmark filter")Yo.set(!Ct(Yo));else if(t==="Toggle for merge")d0(Ya,r[0].id);else if(t==="Toggle menu merge filter")Ko.set(!Ct(Ko));else if(!i&&t==="Edit subtitle")await Qg(r[0]);else if(!i&&t==="Align with book text"&&Ct(xo).matchedBy)await eb(r,n.persistAlignment);else if(!i&&t==="Restore original text and time")await tb(r);else if(t==="Copy subtitle")await navigator.clipboard.writeText(r[0].text).catch(({message:o})=>console.log(`failed to copy subtitle: ${o}`));else if(!s&&(t==="Go to previous subtitle"||t==="Go to next subtitle")){const o=[...Ct(Lr).values()];let a;t==="Go to previous subtitle"?a=o[Math.max(r[0].subIndex-1,0)]:a=o[Math.min(r[0].subIndex+1,o.length-1)],fu.set({action:"Restart playback",subtitles:[a],skipUpdates:n.skipUpdates,keepPauseState:!0})}else!i&&(t==="Create new card"||t==="Update last created card")&&Ct(ru)?await ag(nb(r,n.mergeSubtitles),t==="Update last created card",n.mergeSubtitles||!1).finally(()=>{iu.set(0),vi.set(void 0)}):i?i&&!i.signal.aborted&&t==="Cancel Export"&&(i.abort("user aborted"),vi.set(i)):await Id(Ct(_t.ankiUrl$))}async function Is(t){const e=Ct(Rr);try{await Ct(Ho).put("subtitle",{subtitleData:t,title:e.title,lastSubtitleDataModified:Date.now()}),e.subtitleData=t,document.dispatchEvent(new CustomEvent("ttu-action",{detail:{type:"sync",syncType:"subtitle"}}))}catch({message:n}){throw new Error(`Failed to persist subtitles - ${n}`)}finally{Rr.set(e)}}function ib(t){let e,n,r,i,s,o;return n=new kt({props:{path:t[0],iconStyles:t[7]}}),{c(){e=_e("button"),ye(n.$$.fragment),ie(e,"title",t[1]),ie(e,"style",t[6]),ie(e,"class",t[5]),e.disabled=r=t[1]!==t[2]},m(a,l){he(a,e,l),be(n,e,null),i=!0,s||(o=Xe(e,"click",t[11]),s=!0)},p(a,[l]){const c={};l&1&&(c.path=a[0]),l&128&&(c.iconStyles=a[7]),n.$set(c),(!i||l&2)&&ie(e,"title",a[1]),(!i||l&64)&&ie(e,"style",a[6]),(!i||l&32)&&ie(e,"class",a[5]),(!i||l&6&&r!==(r=a[1]!==a[2]))&&(e.disabled=r)},i(a){i||(Z(n.$$.fragment,a),i=!0)},o(a){ne(n.$$.fragment,a),i=!1},d(a){a&&de(e),we(n),s=!1,o()}}}function sb(t,e,n){let{path:r}=e,{title:i}=e,{action:s}=e,{skipUpdates:o=!1}=e,{ignoreSkipKeyListener:a=!1}=e,{buttonClasses:l="m-y-xs"}=e,{buttonStyles:c=""}=e,{iconStyles:u=""}=e,{subtitle:f=void 0}=e,{clickHandler:g=void 0}=e;const v=Ri(),_=()=>{g==null||g(),Fn(s,f,{skipUpdates:o,ignoreSkipKeyListener:a,mergeSubtitles:!1,keepPauseState:!1,persistAlignment:!0}).finally(()=>v("executed",s))};return t.$$set=b=>{"path"in b&&n(0,r=b.path),"title"in b&&n(1,i=b.title),"action"in b&&n(2,s=b.action),"skipUpdates"in b&&n(3,o=b.skipUpdates),"ignoreSkipKeyListener"in b&&n(4,a=b.ignoreSkipKeyListener),"buttonClasses"in b&&n(5,l=b.buttonClasses),"buttonStyles"in b&&n(6,c=b.buttonStyles),"iconStyles"in b&&n(7,u=b.iconStyles),"subtitle"in b&&n(8,f=b.subtitle),"clickHandler"in b&&n(9,g=b.clickHandler)},[r,i,s,o,a,l,c,u,f,g,v,_]}class Sn extends Dn{constructor(e){super(),Bn(this,e,sb,ib,Cn,{path:0,title:1,action:2,skipUpdates:3,ignoreSkipKeyListener:4,buttonClasses:5,buttonStyles:6,iconStyles:7,subtitle:8,clickHandler:9})}}function h0(t,e,n){const r=t.slice();return r[65]=e[n],r}function p0(t){let e,n,r,i;const s=[kb,Tb,Sb,Eb,vb,yb,wb,bb,gb,_b,mb,pb,hb,db,fb,cb,ub,lb,ab,ob],o=[];function a(l,c){return l[65].action===Re.TOGGLE_PLAYBACK?0:l[65].action===Re.REWIND_ALT?1:l[65].action===Re.REWIND?2:l[65].action===Re.FAST_FORWARD?3:l[65].action===Re.FAST_FORWARD_ALT?4:l[65].action===Re.PREVIOUS_SUBTITLE?5:l[65].action===Re.NEXT_SUBTITLE?6:l[65].action===Re.RESTART_PLAYBACK?7:l[65].action===Re.TOGGLE_PLAY_PAUSE?8:l[65].action===Re.TOGGLE_PLAYBACK_LOOP?9:l[65].action===Re.TOGGLE_BOOKMARK?10:l[65].action===Re.TOGGLE_SHOW_BOOKMARKED?11:l[65].action===Re.TOGGLE_MERGE?12:l[65].action===Re.TOGGLE_SHOW_FOR_MERGE?13:l[65].action===Re.EDIT_SUBTITLE?14:l[65].action===Re.RESTORE_SUBTITLE?15:l[65].action===Re.COPY_SUBTITLE?16:l[65].action===Re.EXPORT_NEW?17:l[65].action===Re.EXPORT_UPDATE?18:l[65].action===Re.OPEN_LAST_EXPORTED_CARD?19:-1}return~(e=a(t))&&(n=o[e]=s[e](t)),{c(){n&&n.c(),r=Fr()},m(l,c){~e&&o[e].m(l,c),he(l,r,c),i=!0},p(l,c){let u=e;e=a(l),e===u?~e&&o[e].p(l,c):(n&&(jt(),ne(o[u],1,1,()=>{o[u]=null}),zt()),~e?(n=o[e],n?n.p(l,c):(n=o[e]=s[e](l),n.c()),Z(n,1),n.m(r.parentNode,r)):n=null)},i(l){i||(Z(n),i=!0)},o(l){ne(n),i=!1},d(l){l&&de(r),~e&&o[e].d(l)}}}function ob(t){let e,n;const r=[t[32](Re.OPEN_LAST_EXPORTED_CARD,t[28],ol,an(0))];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[60]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&268435456|o[1]&2?Kn(r,[qn(s[32](Re.OPEN_LAST_EXPORTED_CARD,s[28],ol,an(0)))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function ab(t){let e,n;const r=[t[32](Re.EXPORT_UPDATE,t[27],il,t[1])];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[59]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&134217730|o[1]&2?Kn(r,[qn(s[32](Re.EXPORT_UPDATE,s[27],il,s[1]))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function lb(t){let e,n;const r=[t[32](Re.EXPORT_NEW,t[26],rl,t[1])];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[58]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&67108866|o[1]&2?Kn(r,[qn(s[32](Re.EXPORT_NEW,s[26],rl,s[1]))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function ub(t){let e,n;const r=[t[32](Re.COPY_SUBTITLE,Re.COPY_SUBTITLE,Eu,t[1])];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[57]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&2|o[1]&2?Kn(r,[qn(s[32](Re.COPY_SUBTITLE,Re.COPY_SUBTITLE,Eu,s[1]))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function cb(t){let e,n;const r=[t[32](Re.RESTORE_SUBTITLE,t[8],Zo,t[1])];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[56]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&258|o[1]&2?Kn(r,[qn(s[32](Re.RESTORE_SUBTITLE,s[8],Zo,s[1]))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function fb(t){let e,n;const r=[t[32](Re.EDIT_SUBTITLE,t[25],$d,t[1])];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[55]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&33554434|o[1]&2?Kn(r,[qn(s[32](Re.EDIT_SUBTITLE,s[25],$d,s[1]))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function db(t){let e,n;const r=[t[32](Re.TOGGLE_SHOW_FOR_MERGE,t[24],t[4],an(0))];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[54]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&16777232|o[1]&2?Kn(r,[qn(s[32](Re.TOGGLE_SHOW_FOR_MERGE,s[24],s[4],an(0)))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function hb(t){let e,n;const r=[t[32](Re.TOGGLE_MERGE,t[23],t[5],t[1])];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[53]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&8388642|o[1]&2?Kn(r,[qn(s[32](Re.TOGGLE_MERGE,s[23],s[5],s[1]))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function pb(t){let e,n;const r=[t[32](Re.TOGGLE_SHOW_BOOKMARKED,t[22],t[6],an(0))];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[52]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&4194368|o[1]&2?Kn(r,[qn(s[32](Re.TOGGLE_SHOW_BOOKMARKED,s[22],s[6],an(0)))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function mb(t){let e,n;const r=[t[32](Re.TOGGLE_BOOKMARK,t[21],t[7],t[1])];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[51]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&2097282|o[1]&2?Kn(r,[qn(s[32](Re.TOGGLE_BOOKMARK,s[21],s[7],s[1]))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function _b(t){let e,n;const r=[{skipUpdates:t[2]},t[32](Re.TOGGLE_PLAYBACK_LOOP,t[20],s1,t[1])];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[50]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&1048582|o[1]&2?Kn(r,[o[0]&4&&{skipUpdates:s[2]},o[0]&1048578|o[1]&2&&qn(s[32](Re.TOGGLE_PLAYBACK_LOOP,s[20],s1,s[1]))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function gb(t){let e,n;const r=[{skipUpdates:t[2]},t[32](Re.TOGGLE_PLAY_PAUSE,t[19],i1,t[1])];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[49]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&524294|o[1]&2?Kn(r,[o[0]&4&&{skipUpdates:s[2]},o[0]&524290|o[1]&2&&qn(s[32](Re.TOGGLE_PLAY_PAUSE,s[19],i1,s[1]))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function bb(t){let e,n;const r=[{skipUpdates:t[2]},t[32](Re.RESTART_PLAYBACK,t[18],zd,t[1])];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[48]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&262150|o[1]&2?Kn(r,[o[0]&4&&{skipUpdates:s[2]},o[0]&262146|o[1]&2&&qn(s[32](Re.RESTART_PLAYBACK,s[18],zd,s[1]))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function wb(t){let e,n;const r=[t[32](Re.NEXT_SUBTITLE,t[17],Ud,t[1])];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[47]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&131074|o[1]&2?Kn(r,[qn(s[32](Re.NEXT_SUBTITLE,s[17],Ud,s[1]))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function yb(t){let e,n;const r=[t[32](Re.PREVIOUS_SUBTITLE,t[16],Wd,t[1])];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[46]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&65538|o[1]&2?Kn(r,[qn(s[32](Re.PREVIOUS_SUBTITLE,s[16],Wd,s[1]))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function vb(t){let e,n;const r=[t[32](Re.FAST_FORWARD_ALT,t[15],u1,an(0))];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[45]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&32768|o[1]&2?Kn(r,[qn(s[32](Re.FAST_FORWARD_ALT,s[15],u1,an(0)))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function Eb(t){let e,n;const r=[t[32](Re.FAST_FORWARD,t[14],c1,an(0))];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[44]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&16384|o[1]&2?Kn(r,[qn(s[32](Re.FAST_FORWARD,s[14],c1,an(0)))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function Sb(t){let e,n;const r=[t[32](Re.REWIND,t[13],f1,an(0))];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[43]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&8192|o[1]&2?Kn(r,[qn(s[32](Re.REWIND,s[13],f1,an(0)))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function Tb(t){let e,n;const r=[t[32](Re.REWIND_ALT,t[12],l1,an(0))];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[42]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&4096|o[1]&2?Kn(r,[qn(s[32](Re.REWIND_ALT,s[12],l1,an(0)))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function kb(t){let e,n;const r=[t[32](Re.TOGGLE_PLAYBACK,t[9],t[10]||t[11]?jd:Gd,an(0))];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[41]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&3584|o[1]&2?Kn(r,[qn(s[32](Re.TOGGLE_PLAYBACK,s[9],s[10]||s[11]?jd:Gd,an(0)))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function m0(t,e){let n,r,i,s=e[65].enabled&&p0(e);return{key:t,first:null,c(){n=Fr(),s&&s.c(),r=Fr(),this.first=n},m(o,a){he(o,n,a),s&&s.m(o,a),he(o,r,a),i=!0},p(o,a){e=o,e[65].enabled?s?(s.p(e,a),a[0]&1&&Z(s,1)):(s=p0(e),s.c(),Z(s,1),s.m(r.parentNode,r)):s&&(jt(),ne(s,1,1,()=>{s=null}),zt())},i(o){i||(Z(s),i=!0)},o(o){ne(s),i=!1},d(o){o&&(de(n),de(r)),s&&s.d(o)}}}function _0(t){let e,n;const r=[t[32](Re.CANCEL_EXPORT,t[29],nl,an(0))];let i={};for(let s=0;s<r.length;s+=1)i=sn(i,r[s]);return e=new Sn({props:i}),e.$on("executed",t[61]),{c(){ye(e.$$.fragment)},m(s,o){be(e,s,o),n=!0},p(s,o){const a=o[0]&536870912|o[1]&2?Kn(r,[qn(s[32](Re.CANCEL_EXPORT,s[29],nl,an(0)))]):{};e.$set(a)},i(s){n||(Z(e.$$.fragment,s),n=!0)},o(s){ne(e.$$.fragment,s),n=!1},d(s){we(e,s)}}}function Ab(t){let e=[],n=new Map,r,i,s,o=Jr(t[0]);const a=c=>c[65].action;for(let c=0;c<o.length;c+=1){let u=h0(t,o,c),f=a(u);n.set(f,e[c]=m0(f,u))}let l=t[3]&&_0(t);return{c(){for(let c=0;c<e.length;c+=1)e[c].c();r=me(),l&&l.c(),i=Fr()},m(c,u){for(let f=0;f<e.length;f+=1)e[f]&&e[f].m(c,u);he(c,r,u),l&&l.m(c,u),he(c,i,u),s=!0},p(c,u){u[0]&536870903|u[1]&2&&(o=Jr(c[0]),jt(),e=Ks(e,u,a,1,c,o,n,r.parentNode,cd,m0,r,h0),zt()),c[3]?l?(l.p(c,u),u[0]&8&&Z(l,1)):(l=_0(c),l.c(),Z(l,1),l.m(i.parentNode,i)):l&&(jt(),ne(l,1,1,()=>{l=null}),zt())},i(c){if(!s){for(let u=0;u<o.length;u+=1)Z(e[u]);Z(l),s=!0}},o(c){for(let u=0;u<e.length;u+=1)ne(e[u]);ne(l),s=!1},d(c){c&&(de(r),de(i));for(let u=0;u<e.length;u+=1)e[u].d(c);l&&l.d(c)}}}function Cb(t,e,n){let r,i,s,o,a,l,c,u,f,g,v,_,b,y,p,m,w,C,h,A,L,$,P,I,x,ae,V,E,F,N,Y,K,J,j,B;ce(t,ls,d=>n(62,l=d)),ce(t,Xa,d=>n(8,f=d)),ce(t,vi,d=>n(36,g=d)),ce(t,Ko,d=>n(37,v=d)),ce(t,Ya,d=>n(38,_=d)),ce(t,Yo,d=>n(39,b=d)),ce(t,cu,d=>n(40,y=d)),ce(t,xa,d=>n(9,p=d)),ce(t,xi,d=>n(10,m=d)),ce(t,Mn,d=>n(11,w=d)),ce(t,Wa,d=>n(12,C=d)),ce(t,Ua,d=>n(13,h=d)),ce(t,Ga,d=>n(14,A=d)),ce(t,ja,d=>n(15,L=d)),ce(t,Uo,d=>n(16,$=d)),ce(t,Wo,d=>n(17,P=d)),ce(t,Go,d=>n(18,I=d)),ce(t,jo,d=>n(19,x=d)),ce(t,zo,d=>n(20,ae=d)),ce(t,su,d=>n(21,V=d)),ce(t,ou,d=>n(22,E=d)),ce(t,au,d=>n(23,F=d)),ce(t,lu,d=>n(24,N=d)),ce(t,za,d=>n(25,Y=d)),ce(t,is,d=>n(26,K=d)),ce(t,ss,d=>n(27,J=d)),ce(t,os,d=>n(28,j=d)),ce(t,Xo,d=>n(29,B=d));let{listItems:M}=e,{subtitle:S}=e,{hideCancelAction:R=!1}=e,{skipUpdates:X=!1}=e,{isFooter:re=!1}=e,{buttonClasses:W=""}=e;const{subtitlesGlobalStartPadding$:z,subtitlesGlobalEndPadding$:le}=_t;ce(t,z,d=>n(64,u=d)),ce(t,le,d=>n(63,c=d));function Me(d,k,D,U){let te=U?"":"No matching subtitle";if(k===f&&U){const ge=u/1e3,pe=c/1e3,Ae=Math.max(0,U.originalStartSeconds+ge),Ce=l?Wi(0,l,U.originalEndSeconds+pe):Math.max(0,U.originalEndSeconds+pe);te=U.text!==U.originalText||Number.isFinite(U.adjustedStartSeconds)&&U.adjustedStartSeconds!==Ae||Number.isFinite(U.adjustedEndSeconds)&&U.adjustedEndSeconds!==Ce?k:"No data to restore"}const ee=d===k&&te||k,se=ee!==d;return{path:D,action:d,buttonClasses:W,title:ee,subtitle:U,buttonStyles:re?`margin-left: 0.5rem;${se?"opacity: 0.4;":""}`:"",iconStyles:re&&se?"cursor: not-allowed;":""}}function Ee(d){mn.call(this,t,d)}function ve(d){mn.call(this,t,d)}function ke(d){mn.call(this,t,d)}function Ne(d){mn.call(this,t,d)}function Te(d){mn.call(this,t,d)}function Le(d){mn.call(this,t,d)}function Fe(d){mn.call(this,t,d)}function Ze(d){mn.call(this,t,d)}function O(d){mn.call(this,t,d)}function H(d){mn.call(this,t,d)}function Pe(d){mn.call(this,t,d)}function xe(d){mn.call(this,t,d)}function qe(d){mn.call(this,t,d)}function nt(d){mn.call(this,t,d)}function Oe(d){mn.call(this,t,d)}function je(d){mn.call(this,t,d)}function et(d){mn.call(this,t,d)}function rt(d){mn.call(this,t,d)}function Je(d){mn.call(this,t,d)}function G(d){mn.call(this,t,d)}function T(d){mn.call(this,t,d)}return t.$$set=d=>{"listItems"in d&&n(0,M=d.listItems),"subtitle"in d&&n(1,S=d.subtitle),"hideCancelAction"in d&&n(33,R=d.hideCancelAction),"skipUpdates"in d&&n(2,X=d.skipUpdates),"isFooter"in d&&n(34,re=d.isFooter),"buttonClasses"in d&&n(35,W=d.buttonClasses)},t.$$.update=()=>{t.$$.dirty[0]&2|t.$$.dirty[1]&512&&n(7,r=S&&y.has(S.id)?d1:h1),t.$$.dirty[1]&256&&n(6,i=b?vg:Tg),t.$$.dirty[0]&2|t.$$.dirty[1]&128&&n(5,s=S&&_.has(S.id)?a1:o1),t.$$.dirty[1]&64&&n(4,o=v?Eg:Sg),t.$$.dirty[0]&1|t.$$.dirty[1]&36&&n(3,a=!R&&!!g&&!!M.find(({action:d})=>d===Re.EXPORT_NEW||d===Re.EXPORT_UPDATE))},[M,S,X,a,o,s,i,r,f,p,m,w,C,h,A,L,$,P,I,x,ae,V,E,F,N,Y,K,J,j,B,z,le,Me,R,re,W,g,v,_,b,y,Ee,ve,ke,Ne,Te,Le,Fe,Ze,O,H,Pe,xe,qe,nt,Oe,je,et,rt,Je,G,T]}class _1 extends Dn{constructor(e){super(),Bn(this,e,Cb,Ab,Cn,{listItems:0,subtitle:1,hideCancelAction:33,skipUpdates:2,isFooter:34,buttonClasses:35},null,[-1,-1,-1])}}function Mb(t){let e,n,r,i,s,o,a;return{c(){e=_e("button"),n=_e("div"),r=Nt(t[1]),i=me(),s=_e("input"),ie(n,"class","pointer-events-none whitespace-pre-wrap p-4"),ie(e,"class",t[7]),ie(e,"style",t[6]),ie(s,"class","hidden"),ie(s,"type","file"),s.multiple=t[2],ie(s,"accept",t[5])},m(l,c){he(l,e,c),oe(e,n),oe(n,r),he(l,i,c),he(l,s,c),t[28](s),o||(a=[Xe(e,"dragenter",t[26]),Xe(e,"dragleave",t[27]),Xe(e,"dragover",zl(t[25])),Xe(e,"drop",zl(t[10])),Xe(e,"click",t[8]),Xe(s,"change",t[9])],o=!0)},p(l,c){c[0]&2&&cn(r,l[1]),c[0]&128&&ie(e,"class",l[7]),c[0]&64&&ie(e,"style",l[6]),c[0]&4&&(s.multiple=l[2]),c[0]&32&&ie(s,"accept",l[5])},i:wt,o:wt,d(l){l&&(de(e),de(i),de(s)),t[28](null),o=!1,vn(a)}}}function g1(t,e){const n=t,r=e.split("/");return n.filePath=e,n.parentFolder=r.length>2?r[r.length-2]:"/",n}function Rb(t){return t.isFile}function Lb(t){return t.isDirectory}function Pb(t){return new Promise((e,n)=>{t.file(r=>e(r),n)})}function g0(t){return new Promise((e,n)=>{t.readEntries(e,n)})}function Ib(t,e,n){let r,i,s,o,a,{disabled:l=!1}=e,{width:c="100%"}=e,{height:u="120px"}=e,{classes:f=""}=e,{dragClasses:g=""}=e,{label:v="Drag-and-drop files / folders to this zone or click it to select them"}=e,{allowRootFiles:_=!1}=e,{multiple:b=!1}=e,{preferNativeFilesystem:y=!1}=e,{fileFormatsDescription:p="Allowed files"}=e,{filePickerId:m="Dropzone"}=e,{fileFormats:w=[]}=e,{oldHandles:C=[]}=e,{oldFiles:h=[]}=e,{accepts:A=""}=e,{types:L=""}=e;const $=Ri(),P="showOpenFilePicker"in window&&y;let I,x=!1;function ae(){if(!l){if(P)return $("start"),F();I.click()}}async function V({currentTarget:R}){var W;if(l||!((W=R.files)!=null&&W.length))return;const X=[...R.files],re={files:[],errors:[]};for(let z=0,{length:le}=X;z<le;z+=1){const Me=g1(X[z],"/"),Ee=`.${Me.name.split(".").pop()}`;try{(!s.size||s.has(Ee))&&(!a||a.test(Me.type))&&!h.find(ve=>ve===Me)&&re.files.push({file:Me,extension:Ee})}catch({message:ve}){re.errors.push(`Error on file ${Me.name} - ${ve}`)}}R.value="",J(re)}function E({dataTransfer:R}){if(n(3,x=!1),l||!R)return;const X=R.items,re=[];$("start");for(let W=0,{length:z}=X;W<z;W+=1){const le=X[W];if(le.kind==="file"){const Me=P?le.getAsFileSystemHandle():le.webkitGetAsEntry();Me&&re.push(Promise.resolve(Me))}}N(re)}async function F(){try{const R=[...s],re=await(_d()?unsafeWindow:window).showOpenFilePicker({multiple:b,id:m,excludeAcceptAllOption:!!s.size,...s.size?{types:[{description:p,accept:{"*/*":R}}]}:{}});N(re.map(W=>Promise.resolve(W)))}catch(R){R.name==="AbortError"?J():J({files:[],errors:[`Error selecting file(s) - ${R.message}`]})}}async function N(R){const X={files:[],errors:[]};for(let re=0,{length:W}=R;re<W;re+=1){try{const z=await R[re];if(z){const le=await Y(z);X.files.push(...le.files),X.errors.push(...le.errors)}}catch({message:z}){X.errors.push(`Error processing entry - ${z}`)}if(X.files.length&&!b)break}J(X)}async function Y(R,X="/"){const re={files:[],errors:[]};if(R instanceof FileSystemFileHandle){const W=`.${R.name.split(".").pop()}`;let z=!1;if(s.size&&!s.has(W))return re;for(let le=0,{length:Me}=C;le<Me&&!z;le+=1)z=await C[le].isSameEntry(R).catch(()=>!1);return z||await R.getFile().then(le=>{const Me=g1(le,X);(_||Me.filePath!=="/")&&(!a||a.test(Me.type))&&!h.find(Ee=>Ee===Me)&&re.files.push({file:Me,handle:R,extension:W})}).catch(({message:le})=>re.errors.push(`Error reading file ${R.name} - ${le}`)),re}else if(Rb(R)){const W=`.${R.name.split(".").pop()}`;return s.size&&!s.has(W)||await Pb(R).then(z=>{const le=g1(z,R.fullPath);(_||le.filePath!=="/")&&(!a||a.test(le.type))&&!h.find(Me=>Me===le)&&re.files.push({file:le,extension:W})}).catch(({message:z})=>re.errors.push(`Error reading file ${R.name} - ${z}`)),re}else if(R instanceof FileSystemDirectoryHandle){const W=R.entries();let z=await W.next().catch(({message:le})=>(re.errors.push(`Error reading directory ${R.name} - ${le}`),{done:!0,value:[]}));for(;!z.done;){const[le,Me]=z.value,Ee=await Y(Me,`${X}${X==="/"?"":"/"}${R.name}${Me.kind==="file"?`/${le}`:""}`);if(re.errors.push(...Ee.errors),!re.files.length||b){const ve=b?Ee.files.length:1;for(let ke=0;ke<ve;ke++)re.files.push(Ee.files[ke])}z=!re.files.length||b?await W.next().catch(({message:ve})=>(re.errors.push(`Error reading directory ${R.name} - ${ve}`),{done:!0,value:[]})):{done:!0,value:[]}}return re}else if(Lb(R))return K(R.createReader(),R.fullPath||R.name);return re}async function K(R,X){const re={files:[],errors:[]};let W=await g0(R).catch(({message:z})=>(re.errors.push(`Error reading directory ${X} - ${z}`),[]));for(;W.length;){for(let z=0,le=W.length;z<le;z+=1){const Me=W[z];try{const Ee=await Y(W[z],Me.fullPath);if(re.errors.push(...Ee.errors),!re.files.length||b){const ve=b?Ee.files.length:1;for(let ke=0;ke<ve;ke++)re.files.push(Ee.files[ke])}}catch({message:Ee}){re.errors.push(`Error reading file ${Me.name} - ${Ee}`)}if(re.files.length&&!b)break}W=!re.files.length||b?await g0(R).catch(({message:z})=>(re.errors.push(`Error reading directory ${X} - ${z}`),[])):[]}return re}function J(R={files:[],errors:[]}){R.files.length||R.errors.length?$("result",R):$("stop")}function j(R){mn.call(this,t,R)}const B=()=>{l||n(3,x=!0)},M=()=>{l||n(3,x=!1)};function S(R){Vt[R?"unshift":"push"](()=>{I=R,n(4,I)})}return t.$$set=R=>{"disabled"in R&&n(0,l=R.disabled),"width"in R&&n(11,c=R.width),"height"in R&&n(12,u=R.height),"classes"in R&&n(13,f=R.classes),"dragClasses"in R&&n(14,g=R.dragClasses),"label"in R&&n(1,v=R.label),"allowRootFiles"in R&&n(15,_=R.allowRootFiles),"multiple"in R&&n(2,b=R.multiple),"preferNativeFilesystem"in R&&n(16,y=R.preferNativeFilesystem),"fileFormatsDescription"in R&&n(17,p=R.fileFormatsDescription),"filePickerId"in R&&n(18,m=R.filePickerId),"fileFormats"in R&&n(19,w=R.fileFormats),"oldHandles"in R&&n(20,C=R.oldHandles),"oldFiles"in R&&n(21,h=R.oldFiles),"accepts"in R&&n(22,A=R.accepts),"types"in R&&n(23,L=R.types)},t.$$.update=()=>{t.$$.dirty[0]&24584&&n(7,r=`dropzone flex justify-center items-center relative ${f||""} ${x?g:""}`),t.$$.dirty[0]&6144&&n(6,i=`width: ${c}; height: ${u};`),t.$$.dirty[0]&524288&&n(24,s=w.length?new Set(w):new Set),t.$$.dirty[0]&20971520&&n(5,o=A||[...s].join(",")||"*"),t.$$.dirty[0]&8388608&&(a=L?new RegExp(L):void 0)},[l,v,b,x,I,o,i,r,ae,V,E,c,u,f,g,_,y,p,m,w,C,h,A,L,s,j,B,M,S]}class Ob extends Dn{constructor(e){super(),Bn(this,e,Ib,Mb,Cn,{disabled:0,width:11,height:12,classes:13,dragClasses:14,label:1,allowRootFiles:15,multiple:2,preferNativeFilesystem:16,fileFormatsDescription:17,filePickerId:18,fileFormats:19,oldHandles:20,oldFiles:21,accepts:22,types:23},null,[-1,-1])}}function Bb(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,s,o,a=[],l=!0,c=!1;try{if(s=(n=n.call(t)).next,e===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=s.call(n)).done)&&(a.push(r.value),a.length!==e);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return a}}function b0(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function hi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?b0(Object(n),!0).forEach(function(r){Ru(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):b0(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Db(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function w0(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,E0(r.key),r)}}function Fb(t,e,n){return e&&w0(t.prototype,e),n&&w0(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function Ru(t,e,n){return e=E0(e),e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $b(t,e){if(t==null)return{};var n={},r=Object.keys(t),i,s;for(s=0;s<r.length;s++)i=r[s],!(e.indexOf(i)>=0)&&(n[i]=t[i]);return n}function Nb(t,e){if(t==null)return{};var n=$b(t,e),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(i=0;i<s.length;i++)r=s[i],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}function Vb(t,e){return Hb(t)||Bb(t,e)||y0(t,e)||xb()}function Hb(t){if(Array.isArray(t))return t}function y0(t,e){if(t){if(typeof t=="string")return v0(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return v0(t,e)}}function v0(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function xb(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ub(t,e){var n=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=y0(t))||e&&t&&typeof t.length=="number"){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,o=!1,a;return{s:function(){n=n.call(t)},n:function(){var l=n.next();return s=l.done,l},e:function(l){o=!0,a=l},f:function(){try{!s&&n.return!=null&&n.return()}finally{if(o)throw a}}}}function Wb(t,e){if(typeof t!="object"||t===null)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function E0(t){var e=Wb(t,"string");return typeof e=="symbol"?e:String(e)}var Gb=["AudioCount","Audio_Channels_Total","BitDepth_Detected","BitDepth","BitDepth_Stored","Channels","Channels_Original","Chapters_Pos_Begin","Chapters_Pos_End","Comic_Position_Total","Count","DataSize","ElementCount","EPG_Positions_Begin","EPG_Positions_End","FirstPacketOrder","FooterSize","Format_Settings_GMC","Format_Settings_RefFrames","FrameCount","FrameRate_Den","FrameRate_Num","GeneralCount","HeaderSize","Height_CleanAperture","Height","Height_Offset","Height_Original","ImageCount","Matrix_Channels","MenuCount","OtherCount","Part_Position","Part_Position_Total","Played_Count","Reel_Position","Reel_Position_Total","Resolution","Sampled_Height","Sampled_Width","SamplingCount","Season_Position","Season_Position_Total","Source_FrameCount","Source_SamplingCount","Source_StreamSize_Encoded","Source_StreamSize","Status","Stored_Height","Stored_Width","StreamCount","StreamKindID","StreamKindPos","StreamOrder","StreamSize_Demuxed","StreamSize_Encoded","StreamSize","TextCount","Track_Position","Track_Position_Total","Video0_Delay","VideoCount","Width_CleanAperture","Width","Width_Offset","Width_Original"],jb=["BitRate_Encoded","BitRate_Maximum","BitRate_Minimum","BitRate","BitRate_Nominal","Bits-Pixel_Frame","BitsPixel_Frame","Compression_Ratio","Delay","Delay_Original","DisplayAspectRatio_CleanAperture","DisplayAspectRatio","DisplayAspectRatio_Original","Duration_End_Command","Duration_End","Duration_FirstFrame","Duration_LastFrame","Duration","Duration_Start2End","Duration_Start_Command","Duration_Start","Events_MinDuration","FrameRate_Maximum","FrameRate_Minimum","FrameRate","FrameRate_Nominal","FrameRate_Original_Den","FrameRate_Original","FrameRate_Original_Num","FrameRate_Real","Interleave_Duration","Interleave_Preload","Interleave_VideoFrames","OverallBitRate_Maximum","OverallBitRate_Minimum","OverallBitRate","OverallBitRate_Nominal","PixelAspectRatio_CleanAperture","PixelAspectRatio","PixelAspectRatio_Original","SamplesPerFrame","SamplingRate","Source_Duration_FirstFrame","Source_Duration_LastFrame","Source_Duration","TimeStamp_FirstFrame","Video_Delay"],b1={coverData:!1,chunkSize:256*1024,format:"object",full:!1},zb=function(){function t(e,n){Db(this,t),this.mediainfoModule=e,this.options=n,this.mediainfoModuleInstance=new e.MediaInfo(n.format==="object"?"JSON":n.format,n.coverData,n.full)}return Fb(t,[{key:"analyzeData",value:function(n,r,i){var s=this;if(i===void 0)return new Promise(function(c,u){var f=function(v,_){return _?u(_):c(v)};s.analyzeData(n,r,f)});var o=0,a=function(u){var f=function _(){var b=function(C){g(C)?_():v()},y;try{var p,m=Math.min((p=s.options.chunkSize)!==null&&p!==void 0?p:b1.chunkSize,u-o);y=r(m,o)}catch(w){if(w instanceof Error)return i("",w);if(typeof w=="string")return i("",new Error(w))}y instanceof Promise?y.then(b).catch(function(w){return i("",w)}):y!==void 0&&b(y)},g=function(b){if(b.length===0||s.openBufferContinue(b,b.length))return!1;var y=s.openBufferContinueGotoGet();return y===-1?o+=b.length:(o=y,s.openBufferInit(u,y)),!0},v=function(){s.openBufferFinalize();var b=s.inform();s.options.format==="object"?i(s.parseResultJson(b)):i(b)};s.openBufferInit(u,o),f()},l=n();l instanceof Promise?l.then(a).catch(function(c){return i(null,c)}):a(l)}},{key:"close",value:function(){var n;this.mediainfoModuleInstance&&this.mediainfoModuleInstance.close(),this.mediainfoModule&&typeof((n=this.mediainfoModule)===null||n===void 0?void 0:n.destroy)=="function"&&this.mediainfoModule.destroy(this.mediainfoModuleInstance)}},{key:"inform",value:function(){return this.mediainfoModuleInstance.inform()}},{key:"openBufferContinue",value:function(n,r){return!!(this.mediainfoModuleInstance.open_buffer_continue(n,r)&8)}},{key:"openBufferContinueGotoGet",value:function(){var n=-1,r=this.mediainfoModuleInstance.open_buffer_continue_goto_get_lower(),i=this.mediainfoModuleInstance.open_buffer_continue_goto_get_upper();return r==-1&&i==-1?n=-1:r<0?n=r+4294967296+i*4294967296:n=r+i*4294967296,n}},{key:"openBufferFinalize",value:function(){this.mediainfoModuleInstance.open_buffer_finalize()}},{key:"openBufferInit",value:function(n,r){this.mediainfoModuleInstance.open_buffer_init(n,r)}},{key:"parseResultJson",value:function(n){var r=Gb,i=jb,s=JSON.parse(n);if(s.media){var o=hi(hi({},s.media),{},{track:[]});if(s.media.track&&Array.isArray(s.media.track)){var a=Ub(s.media.track),l;try{for(a.s();!(l=a.n()).done;){for(var c=l.value,u={"@type":c["@type"]},f=0,g=Object.entries(c);f<g.length;f++){var v=Vb(g[f],2),_=v[0],b=v[1];_!=="@type"&&(typeof b=="string"&&r.includes(_)?u=hi(hi({},u),{},Ru({},_,parseInt(b,10))):typeof b=="string"&&i.includes(_)?u=hi(hi({},u),{},Ru({},_,parseFloat(b))):u=hi(hi({},u),{},Ru({},_,b)))}o.track.push(u)}}catch(y){a.e(y)}finally{a.f()}}return hi(hi({},s),{},{media:o})}return s}}]),t}(),Xb=(()=>{var t=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(e={}){var n=e,r,i;n.ready=new Promise((q,Q)=>{r=q,i=Q});var s=Object.assign({},n),o="./this.program",a=!0,l="";function c(q){return n.locateFile?n.locateFile(q,l):l+q}typeof document<"u"&&document.currentScript&&(l=document.currentScript.src),t&&(l=t),l.indexOf("blob:")!==0?l=l.substr(0,l.replace(/[?#].*/,"").lastIndexOf("/")+1):l="",n.print||console.log.bind(console);var u=n.printErr||console.error.bind(console);Object.assign(n,s),s=null,n.arguments&&n.arguments,n.thisProgram&&(o=n.thisProgram),n.quit&&n.quit;var f;n.wasmBinary&&(f=n.wasmBinary),n.noExitRuntime,typeof WebAssembly!="object"&&M("no native wasm support detected");var g,v,_=!1,b,y,p,m,w,C,h,A;function L(){var q=g.buffer;n.HEAP8=b=new Int8Array(q),n.HEAP16=p=new Int16Array(q),n.HEAP32=w=new Int32Array(q),n.HEAPU8=y=new Uint8Array(q),n.HEAPU16=m=new Uint16Array(q),n.HEAPU32=C=new Uint32Array(q),n.HEAPF32=h=new Float32Array(q),n.HEAPF64=A=new Float64Array(q)}var $,P=[],I=[],x=[];function ae(){if(n.preRun)for(typeof n.preRun=="function"&&(n.preRun=[n.preRun]);n.preRun.length;)F(n.preRun.shift());Ee(P)}function V(){Ee(I)}function E(){if(n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;)Y(n.postRun.shift());Ee(x)}function F(q){P.unshift(q)}function N(q){I.unshift(q)}function Y(q){x.unshift(q)}var K=0,J=null;function j(q){K++,n.monitorRunDependencies&&n.monitorRunDependencies(K)}function B(q){if(K--,n.monitorRunDependencies&&n.monitorRunDependencies(K),K==0&&J){var Q=J;J=null,Q()}}function M(q){n.onAbort&&n.onAbort(q),q="Aborted("+q+")",u(q),_=!0,q+=". Build with -sASSERTIONS for more info.";var Q=new WebAssembly.RuntimeError(q);throw i(Q),Q}var S="data:application/octet-stream;base64,";function R(q){return q.startsWith(S)}var X;X="MediaInfoModule.wasm",R(X)||(X=c(X));function re(q){if(q==X&&f)return new Uint8Array(f);throw"both async and sync fetching of the wasm failed"}function W(q){return!f&&a&&typeof fetch=="function"?fetch(q,{credentials:"same-origin"}).then(Q=>{if(!Q.ok)throw"failed to load wasm binary file at '"+q+"'";return Q.arrayBuffer()}).catch(()=>re(q)):Promise.resolve().then(()=>re(q))}function z(q,Q,ue){return W(q).then(Ie=>WebAssembly.instantiate(Ie,Q)).then(Ie=>Ie).then(ue,Ie=>{u("failed to asynchronously prepare wasm: "+Ie),M(Ie)})}function le(q,Q,ue,Ie){return!q&&typeof WebAssembly.instantiateStreaming=="function"&&!R(Q)&&typeof fetch=="function"?fetch(Q,{credentials:"same-origin"}).then(Ge=>{var it=WebAssembly.instantiateStreaming(Ge,ue);return it.then(Ie,function(st){return u("wasm streaming compile failed: "+st),u("falling back to ArrayBuffer instantiation"),z(Q,ue,Ie)})}):z(Q,ue,Ie)}function Me(){var q={a:T7};function Q(Ie,Ge){var it=Ie.exports;return v=it,g=v.u,L(),$=v.x,N(v.v),B(),it}j();function ue(Ie){Q(Ie.instance)}if(n.instantiateWasm)try{return n.instantiateWasm(q,Q)}catch(Ie){u("Module.instantiateWasm callback failed with error: "+Ie),i(Ie)}return le(f,X,q,ue).catch(i),{}}var Ee=q=>{for(;q.length>0;)q.shift()(n)};function ve(q,Q,ue,Ie,Ge){}function ke(q){switch(q){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${q}`)}}function Ne(){for(var q=new Array(256),Q=0;Q<256;++Q)q[Q]=String.fromCharCode(Q);Te=q}var Te=void 0;function Le(q){for(var Q="",ue=q;y[ue];)Q+=Te[y[ue++]];return Q}var Fe={},Ze={},O={},H=void 0;function Pe(q){throw new H(q)}var xe=void 0;function qe(q){throw new xe(q)}function nt(q,Q,ue){q.forEach(function(ot){O[ot]=Q});function Ie(ot){var Tt=ue(ot);Tt.length!==q.length&&qe("Mismatched type converter count");for(var bt=0;bt<q.length;++bt)je(q[bt],Tt[bt])}var Ge=new Array(Q.length),it=[],st=0;Q.forEach((ot,Tt)=>{Ze.hasOwnProperty(ot)?Ge[Tt]=Ze[ot]:(it.push(ot),Fe.hasOwnProperty(ot)||(Fe[ot]=[]),Fe[ot].push(()=>{Ge[Tt]=Ze[ot],++st,st===it.length&&Ie(Ge)}))}),it.length===0&&Ie(Ge)}function Oe(q,Q,ue={}){var Ie=Q.name;if(q||Pe(`type "${Ie}" must have a positive integer typeid pointer`),Ze.hasOwnProperty(q)){if(ue.ignoreDuplicateRegistrations)return;Pe(`Cannot register type '${Ie}' twice`)}if(Ze[q]=Q,delete O[q],Fe.hasOwnProperty(q)){var Ge=Fe[q];delete Fe[q],Ge.forEach(it=>it())}}function je(q,Q,ue={}){if(!("argPackAdvance"in Q))throw new TypeError("registerType registeredInstance requires argPackAdvance");return Oe(q,Q,ue)}function et(q,Q,ue,Ie,Ge){var it=ke(ue);Q=Le(Q),je(q,{name:Q,fromWireType:function(st){return!!st},toWireType:function(st,ot){return ot?Ie:Ge},argPackAdvance:8,readValueFromPointer:function(st){var ot;if(ue===1)ot=b;else if(ue===2)ot=p;else if(ue===4)ot=w;else throw new TypeError("Unknown boolean type size: "+Q);return this.fromWireType(ot[st>>it])},destructorFunction:null})}function rt(q){if(!(this instanceof Rt)||!(q instanceof Rt))return!1;for(var Q=this.$$.ptrType.registeredClass,ue=this.$$.ptr,Ie=q.$$.ptrType.registeredClass,Ge=q.$$.ptr;Q.baseClass;)ue=Q.upcast(ue),Q=Q.baseClass;for(;Ie.baseClass;)Ge=Ie.upcast(Ge),Ie=Ie.baseClass;return Q===Ie&&ue===Ge}function Je(q){return{count:q.count,deleteScheduled:q.deleteScheduled,preservePointerOnDelete:q.preservePointerOnDelete,ptr:q.ptr,ptrType:q.ptrType,smartPtr:q.smartPtr,smartPtrType:q.smartPtrType}}function G(q){function Q(ue){return ue.$$.ptrType.registeredClass.name}Pe(Q(q)+" instance already deleted")}var T=!1;function d(q){}function k(q){q.smartPtr?q.smartPtrType.rawDestructor(q.smartPtr):q.ptrType.registeredClass.rawDestructor(q.ptr)}function D(q){q.count.value-=1;var Q=q.count.value===0;Q&&k(q)}function U(q,Q,ue){if(Q===ue)return q;if(ue.baseClass===void 0)return null;var Ie=U(q,Q,ue.baseClass);return Ie===null?null:ue.downcast(Ie)}var te={};function ee(){return Object.keys(tt).length}function se(){var q=[];for(var Q in tt)tt.hasOwnProperty(Q)&&q.push(tt[Q]);return q}var ge=[];function pe(){for(;ge.length;){var q=ge.pop();q.$$.deleteScheduled=!1,q.delete()}}var Ae=void 0;function Ce(q){Ae=q,ge.length&&Ae&&Ae(pe)}function De(){n.getInheritedInstanceCount=ee,n.getLiveInheritedInstances=se,n.flushPendingDeletes=pe,n.setDelayFunction=Ce}var tt={};function mt(q,Q){for(Q===void 0&&Pe("ptr should not be undefined");q.baseClass;)Q=q.upcast(Q),q=q.baseClass;return Q}function We(q,Q){return Q=mt(q,Q),tt[Q]}function dt(q,Q){(!Q.ptrType||!Q.ptr)&&qe("makeClassHandle requires ptr and ptrType");var ue=!!Q.smartPtrType,Ie=!!Q.smartPtr;return ue!==Ie&&qe("Both smartPtrType and smartPtr must be specified"),Q.count={value:1},$e(Object.create(q,{$$:{value:Q}}))}function Be(q){var Q=this.getPointee(q);if(!Q)return this.destructor(q),null;var ue=We(this.registeredClass,Q);if(ue!==void 0){if(ue.$$.count.value===0)return ue.$$.ptr=Q,ue.$$.smartPtr=q,ue.clone();var Ie=ue.clone();return this.destructor(q),Ie}function Ge(){return this.isSmartPointer?dt(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:Q,smartPtrType:this,smartPtr:q}):dt(this.registeredClass.instancePrototype,{ptrType:this,ptr:q})}var it=this.registeredClass.getActualType(Q),st=te[it];if(!st)return Ge.call(this);var ot;this.isConst?ot=st.constPointerType:ot=st.pointerType;var Tt=U(Q,this.registeredClass,ot.registeredClass);return Tt===null?Ge.call(this):this.isSmartPointer?dt(ot.registeredClass.instancePrototype,{ptrType:ot,ptr:Tt,smartPtrType:this,smartPtr:q}):dt(ot.registeredClass.instancePrototype,{ptrType:ot,ptr:Tt})}var $e=function(q){return typeof FinalizationRegistry>"u"?($e=Q=>Q,q):(T=new FinalizationRegistry(Q=>{D(Q.$$)}),$e=Q=>{var ue=Q.$$,Ie=!!ue.smartPtr;if(Ie){var Ge={$$:ue};T.register(Q,Ge,Q)}return Q},d=Q=>T.unregister(Q),$e(q))};function ft(){if(this.$$.ptr||G(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var q=$e(Object.create(Object.getPrototypeOf(this),{$$:{value:Je(this.$$)}}));return q.$$.count.value+=1,q.$$.deleteScheduled=!1,q}function ze(){this.$$.ptr||G(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Pe("Object already scheduled for deletion"),d(this),D(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function at(){return!this.$$.ptr}function Qe(){return this.$$.ptr||G(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Pe("Object already scheduled for deletion"),ge.push(this),ge.length===1&&Ae&&Ae(pe),this.$$.deleteScheduled=!0,this}function vt(){Rt.prototype.isAliasOf=rt,Rt.prototype.clone=ft,Rt.prototype.delete=ze,Rt.prototype.isDeleted=at,Rt.prototype.deleteLater=Qe}function Rt(){}var lt=48,St=57;function ht(q){if(q===void 0)return"_unknown";q=q.replace(/[^a-zA-Z0-9_]/g,"$");var Q=q.charCodeAt(0);return Q>=lt&&Q<=St?`_${q}`:q}function xt(q,Q){return q=ht(q),{[q]:function(){return Q.apply(this,arguments)}}[q]}function ln(q,Q,ue){if(q[Q].overloadTable===void 0){var Ie=q[Q];q[Q]=function(){return q[Q].overloadTable.hasOwnProperty(arguments.length)||Pe(`Function '${ue}' called with an invalid number of arguments (${arguments.length}) - expects one of (${q[Q].overloadTable})!`),q[Q].overloadTable[arguments.length].apply(this,arguments)},q[Q].overloadTable=[],q[Q].overloadTable[Ie.argCount]=Ie}}function qt(q,Q,ue){n.hasOwnProperty(q)?((ue===void 0||n[q].overloadTable!==void 0&&n[q].overloadTable[ue]!==void 0)&&Pe(`Cannot register public name '${q}' twice`),ln(n,q,q),n.hasOwnProperty(ue)&&Pe(`Cannot register multiple overloads of a function with the same number of arguments (${ue})!`),n[q].overloadTable[ue]=Q):(n[q]=Q,ue!==void 0&&(n[q].numArguments=ue))}function Dt(q,Q,ue,Ie,Ge,it,st,ot){this.name=q,this.constructor=Q,this.instancePrototype=ue,this.rawDestructor=Ie,this.baseClass=Ge,this.getActualType=it,this.upcast=st,this.downcast=ot,this.pureVirtualFunctions=[]}function rn(q,Q,ue){for(;Q!==ue;)Q.upcast||Pe(`Expected null or instance of ${ue.name}, got an instance of ${Q.name}`),q=Q.upcast(q),Q=Q.baseClass;return q}function In(q,Q){if(Q===null)return this.isReference&&Pe(`null is not a valid ${this.name}`),0;Q.$$||Pe(`Cannot pass "${nn(Q)}" as a ${this.name}`),Q.$$.ptr||Pe(`Cannot pass deleted object as a pointer of type ${this.name}`);var ue=Q.$$.ptrType.registeredClass,Ie=rn(Q.$$.ptr,ue,this.registeredClass);return Ie}function Hn(q,Q){var ue;if(Q===null)return this.isReference&&Pe(`null is not a valid ${this.name}`),this.isSmartPointer?(ue=this.rawConstructor(),q!==null&&q.push(this.rawDestructor,ue),ue):0;Q.$$||Pe(`Cannot pass "${nn(Q)}" as a ${this.name}`),Q.$$.ptr||Pe(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&Q.$$.ptrType.isConst&&Pe(`Cannot convert argument of type ${Q.$$.smartPtrType?Q.$$.smartPtrType.name:Q.$$.ptrType.name} to parameter type ${this.name}`);var Ie=Q.$$.ptrType.registeredClass;if(ue=rn(Q.$$.ptr,Ie,this.registeredClass),this.isSmartPointer)switch(Q.$$.smartPtr===void 0&&Pe("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:Q.$$.smartPtrType===this?ue=Q.$$.smartPtr:Pe(`Cannot convert argument of type ${Q.$$.smartPtrType?Q.$$.smartPtrType.name:Q.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:ue=Q.$$.smartPtr;break;case 2:if(Q.$$.smartPtrType===this)ue=Q.$$.smartPtr;else{var Ge=Q.clone();ue=this.rawShare(ue,Et.toHandle(function(){Ge.delete()})),q!==null&&q.push(this.rawDestructor,ue)}break;default:Pe("Unsupporting sharing policy")}return ue}function xn(q,Q){if(Q===null)return this.isReference&&Pe(`null is not a valid ${this.name}`),0;Q.$$||Pe(`Cannot pass "${nn(Q)}" as a ${this.name}`),Q.$$.ptr||Pe(`Cannot pass deleted object as a pointer of type ${this.name}`),Q.$$.ptrType.isConst&&Pe(`Cannot convert argument of type ${Q.$$.ptrType.name} to parameter type ${this.name}`);var ue=Q.$$.ptrType.registeredClass,Ie=rn(Q.$$.ptr,ue,this.registeredClass);return Ie}function Xt(q){return this.fromWireType(w[q>>2])}function Ft(q){return this.rawGetPointee&&(q=this.rawGetPointee(q)),q}function Wt(q){this.rawDestructor&&this.rawDestructor(q)}function un(q){q!==null&&q.delete()}function Ye(){ut.prototype.getPointee=Ft,ut.prototype.destructor=Wt,ut.prototype.argPackAdvance=8,ut.prototype.readValueFromPointer=Xt,ut.prototype.deleteObject=un,ut.prototype.fromWireType=Be}function ut(q,Q,ue,Ie,Ge,it,st,ot,Tt,bt,Jt){this.name=q,this.registeredClass=Q,this.isReference=ue,this.isConst=Ie,this.isSmartPointer=Ge,this.pointeeType=it,this.sharingPolicy=st,this.rawGetPointee=ot,this.rawConstructor=Tt,this.rawShare=bt,this.rawDestructor=Jt,!Ge&&Q.baseClass===void 0?Ie?(this.toWireType=In,this.destructorFunction=null):(this.toWireType=xn,this.destructorFunction=null):this.toWireType=Hn}function yr(q,Q,ue){n.hasOwnProperty(q)||qe("Replacing nonexistant public symbol"),n[q].overloadTable!==void 0&&ue!==void 0?n[q].overloadTable[ue]=Q:(n[q]=Q,n[q].argCount=ue)}var Xn=(q,Q,ue)=>{var Ie=n["dynCall_"+q];return ue&&ue.length?Ie.apply(null,[Q].concat(ue)):Ie.call(null,Q)},Yt=q=>$.get(q),sr=(q,Q,ue)=>{if(q.includes("j"))return Xn(q,Q,ue);var Ie=Yt(Q).apply(null,ue);return Ie},Qn=(q,Q)=>{var ue=[];return function(){return ue.length=0,Object.assign(ue,arguments),sr(q,Q,ue)}};function Un(q,Q){q=Le(q);function ue(){return q.includes("j")?Qn(q,Q):Yt(Q)}var Ie=ue();return typeof Ie!="function"&&Pe(`unknown function pointer with signature ${q}: ${Q}`),Ie}function vr(q,Q){var ue=xt(Q,function(Ie){this.name=Q,this.message=Ie;var Ge=new Error(Ie).stack;Ge!==void 0&&(this.stack=this.toString()+`
`+Ge.replace(/^Error(:[^\n]*)?\n/,""))});return ue.prototype=Object.create(q.prototype),ue.prototype.constructor=ue,ue.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},ue}var dr=void 0;function hn(q){var Q=c_(q),ue=Le(Q);return Cs(Q),ue}function Gr(q,Q){var ue=[],Ie={};function Ge(it){if(!Ie[it]&&!Ze[it]){if(O[it]){O[it].forEach(Ge);return}ue.push(it),Ie[it]=!0}}throw Q.forEach(Ge),new dr(`${q}: `+ue.map(hn).join([", "]))}function pn(q,Q,ue,Ie,Ge,it,st,ot,Tt,bt,Jt,wn,en){Jt=Le(Jt),it=Un(Ge,it),ot&&(ot=Un(st,ot)),bt&&(bt=Un(Tt,bt)),en=Un(wn,en);var An=ht(Jt);qt(An,function(){Gr(`Cannot construct ${Jt} due to unbound types`,[Ie])}),nt([q,Q,ue],Ie?[Ie]:[],function(Sr){Sr=Sr[0];var Dr,Vr;Ie?(Dr=Sr.registeredClass,Vr=Dr.instancePrototype):Vr=Rt.prototype;var Ai=xt(An,function(){if(Object.getPrototypeOf(this)!==gt)throw new H("Use 'new' to construct "+Jt);if(Ot.constructor_body===void 0)throw new H(Jt+" has no accessible constructor");var Fc=Ot.constructor_body[arguments.length];if(Fc===void 0)throw new H(`Tried to invoke ctor of ${Jt} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(Ot.constructor_body).toString()}) parameters instead!`);return Fc.apply(this,arguments)}),gt=Object.create(Vr,{constructor:{value:Ai}});Ai.prototype=gt;var Ot=new Dt(Jt,Ai,gt,en,Dr,it,ot,bt);Ot.baseClass&&(Ot.baseClass.__derivedClasses===void 0&&(Ot.baseClass.__derivedClasses=[]),Ot.baseClass.__derivedClasses.push(Ot));var ui=new ut(Jt,Ot,!0,!1,!1),Hr=new ut(Jt+"*",Ot,!1,!1,!1),Ao=new ut(Jt+" const*",Ot,!1,!0,!1);return te[q]={pointerType:Hr,constPointerType:Ao},yr(An,Ai),[ui,Hr,Ao]})}function or(q,Q){for(var ue=[],Ie=0;Ie<q;Ie++)ue.push(C[Q+Ie*4>>2]);return ue}function Or(q){for(;q.length;){var Q=q.pop(),ue=q.pop();ue(Q)}}function oi(q,Q){if(!(q instanceof Function))throw new TypeError(`new_ called with constructor type ${typeof q} which is not a function`);var ue=xt(q.name||"unknownFunctionName",function(){});ue.prototype=q.prototype;var Ie=new ue,Ge=q.apply(Ie,Q);return Ge instanceof Object?Ge:Ie}function Wn(q,Q,ue,Ie,Ge,it){var st=Q.length;st<2&&Pe("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var ot=Q[1]!==null&&ue!==null,Tt=!1,bt=1;bt<Q.length;++bt)if(Q[bt]!==null&&Q[bt].destructorFunction===void 0){Tt=!0;break}for(var Jt=Q[0].name!=="void",wn="",en="",bt=0;bt<st-2;++bt)wn+=(bt!==0?", ":"")+"arg"+bt,en+=(bt!==0?", ":"")+"arg"+bt+"Wired";var An=`
return function ${ht(q)}(${wn}) {
if (arguments.length !== ${st-2}) {
throwBindingError('function ${q} called with ${arguments.length} arguments, expected ${st-2} args!');
}`;Tt&&(An+=`var destructors = [];
`);var Sr=Tt?"destructors":"null",Dr=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],Vr=[Pe,Ie,Ge,Or,Q[0],Q[1]];ot&&(An+="var thisWired = classParam.toWireType("+Sr+`, this);
`);for(var bt=0;bt<st-2;++bt)An+="var arg"+bt+"Wired = argType"+bt+".toWireType("+Sr+", arg"+bt+"); // "+Q[bt+2].name+`
`,Dr.push("argType"+bt),Vr.push(Q[bt+2]);if(ot&&(en="thisWired"+(en.length>0?", ":"")+en),An+=(Jt||it?"var rv = ":"")+"invoker(fn"+(en.length>0?", ":"")+en+`);
`,Tt)An+=`runDestructors(destructors);
`;else for(var bt=ot?1:2;bt<Q.length;++bt){var Ai=bt===1?"thisWired":"arg"+(bt-2)+"Wired";Q[bt].destructorFunction!==null&&(An+=Ai+"_dtor("+Ai+"); // "+Q[bt].name+`
`,Dr.push(Ai+"_dtor"),Vr.push(Q[bt].destructorFunction))}return Jt&&(An+=`var ret = retType.fromWireType(rv);
return ret;
`),An+=`}
`,Dr.push(An),oi(Function,Dr).apply(null,Vr)}function jr(q,Q,ue,Ie,Ge,it){var st=or(Q,ue);Ge=Un(Ie,Ge),nt([],[q],function(ot){ot=ot[0];var Tt=`constructor ${ot.name}`;if(ot.registeredClass.constructor_body===void 0&&(ot.registeredClass.constructor_body=[]),ot.registeredClass.constructor_body[Q-1]!==void 0)throw new H(`Cannot register multiple constructors with identical number of parameters (${Q-1}) for class '${ot.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return ot.registeredClass.constructor_body[Q-1]=()=>{Gr(`Cannot construct ${ot.name} due to unbound types`,st)},nt([],st,function(bt){return bt.splice(1,0,null),ot.registeredClass.constructor_body[Q-1]=Wn(Tt,bt,null,Ge,it),[]}),[]})}function Ve(q,Q,ue,Ie,Ge,it,st,ot,Tt){var bt=or(ue,Ie);Q=Le(Q),it=Un(Ge,it),nt([],[q],function(Jt){Jt=Jt[0];var wn=`${Jt.name}.${Q}`;Q.startsWith("@@")&&(Q=Symbol[Q.substring(2)]),ot&&Jt.registeredClass.pureVirtualFunctions.push(Q);function en(){Gr(`Cannot call ${wn} due to unbound types`,bt)}var An=Jt.registeredClass.instancePrototype,Sr=An[Q];return Sr===void 0||Sr.overloadTable===void 0&&Sr.className!==Jt.name&&Sr.argCount===ue-2?(en.argCount=ue-2,en.className=Jt.name,An[Q]=en):(ln(An,Q,wn),An[Q].overloadTable[ue-2]=en),nt([],bt,function(Dr){var Vr=Wn(wn,Dr,Jt,it,st,Tt);return An[Q].overloadTable===void 0?(Vr.argCount=ue-2,An[Q]=Vr):An[Q].overloadTable[ue-2]=Vr,[]}),[]})}function It(){Object.assign(Bt.prototype,{get(q){return this.allocated[q]},has(q){return this.allocated[q]!==void 0},allocate(q){var Q=this.freelist.pop()||this.allocated.length;return this.allocated[Q]=q,Q},free(q){this.allocated[q]=void 0,this.freelist.push(q)}})}function Bt(){this.allocated=[void 0],this.freelist=[]}var $t=new Bt;function tn(q){q>=$t.reserved&&--$t.get(q).refcount===0&&$t.free(q)}function Tn(){for(var q=0,Q=$t.reserved;Q<$t.allocated.length;++Q)$t.allocated[Q]!==void 0&&++q;return q}function He(){$t.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),$t.reserved=$t.allocated.length,n.count_emval_handles=Tn}var Et={toValue:q=>(q||Pe("Cannot use deleted val. handle = "+q),$t.get(q).value),toHandle:q=>{switch(q){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return $t.allocate({refcount:1,value:q})}}};function Gt(q,Q){Q=Le(Q),je(q,{name:Q,fromWireType:function(ue){var Ie=Et.toValue(ue);return tn(ue),Ie},toWireType:function(ue,Ie){return Et.toHandle(Ie)},argPackAdvance:8,readValueFromPointer:Xt,destructorFunction:null})}function nn(q){if(q===null)return"null";var Q=typeof q;return Q==="object"||Q==="array"||Q==="function"?q.toString():""+q}function hr(q,Q){switch(Q){case 2:return function(ue){return this.fromWireType(h[ue>>2])};case 3:return function(ue){return this.fromWireType(A[ue>>3])};default:throw new TypeError("Unknown float type: "+q)}}function Pt(q,Q,ue){var Ie=ke(ue);Q=Le(Q),je(q,{name:Q,fromWireType:function(Ge){return Ge},toWireType:function(Ge,it){return it},argPackAdvance:8,readValueFromPointer:hr(Q,Ie),destructorFunction:null})}function Zt(q,Q,ue){switch(Q){case 0:return ue?function(Ge){return b[Ge]}:function(Ge){return y[Ge]};case 1:return ue?function(Ge){return p[Ge>>1]}:function(Ge){return m[Ge>>1]};case 2:return ue?function(Ge){return w[Ge>>2]}:function(Ge){return C[Ge>>2]};default:throw new TypeError("Unknown integer type: "+q)}}function On(q,Q,ue,Ie,Ge){Q=Le(Q);var it=ke(ue),st=wn=>wn;if(Ie===0){var ot=32-8*ue;st=wn=>wn<<ot>>>ot}var Tt=Q.includes("unsigned"),bt=(wn,en)=>{},Jt;Tt?Jt=function(wn,en){return bt(en,this.name),en>>>0}:Jt=function(wn,en){return bt(en,this.name),en},je(q,{name:Q,fromWireType:st,toWireType:Jt,argPackAdvance:8,readValueFromPointer:Zt(Q,it,Ie!==0),destructorFunction:null})}function Br(q,Q,ue){var Ie=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Ge=Ie[Q];function it(st){st=st>>2;var ot=C,Tt=ot[st],bt=ot[st+1];return new Ge(ot.buffer,bt,Tt)}ue=Le(ue),je(q,{name:ue,fromWireType:it,argPackAdvance:8,readValueFromPointer:it},{ignoreDuplicateRegistrations:!0})}var zr=(q,Q,ue,Ie)=>{if(!(Ie>0))return 0;for(var Ge=ue,it=ue+Ie-1,st=0;st<q.length;++st){var ot=q.charCodeAt(st);if(ot>=55296&&ot<=57343){var Tt=q.charCodeAt(++st);ot=65536+((ot&1023)<<10)|Tt&1023}if(ot<=127){if(ue>=it)break;Q[ue++]=ot}else if(ot<=2047){if(ue+1>=it)break;Q[ue++]=192|ot>>6,Q[ue++]=128|ot&63}else if(ot<=65535){if(ue+2>=it)break;Q[ue++]=224|ot>>12,Q[ue++]=128|ot>>6&63,Q[ue++]=128|ot&63}else{if(ue+3>=it)break;Q[ue++]=240|ot>>18,Q[ue++]=128|ot>>12&63,Q[ue++]=128|ot>>6&63,Q[ue++]=128|ot&63}}return Q[ue]=0,ue-Ge},To=(q,Q,ue)=>zr(q,y,Q,ue),Gs=q=>{for(var Q=0,ue=0;ue<q.length;++ue){var Ie=q.charCodeAt(ue);Ie<=127?Q++:Ie<=2047?Q+=2:Ie>=55296&&Ie<=57343?(Q+=4,++ue):Q+=3}return Q},Sa=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Nl=(q,Q,ue)=>{for(var Ie=Q+ue,Ge=Q;q[Ge]&&!(Ge>=Ie);)++Ge;if(Ge-Q>16&&q.buffer&&Sa)return Sa.decode(q.subarray(Q,Ge));for(var it="";Q<Ge;){var st=q[Q++];if(!(st&128)){it+=String.fromCharCode(st);continue}var ot=q[Q++]&63;if((st&224)==192){it+=String.fromCharCode((st&31)<<6|ot);continue}var Tt=q[Q++]&63;if((st&240)==224?st=(st&15)<<12|ot<<6|Tt:st=(st&7)<<18|ot<<12|Tt<<6|q[Q++]&63,st<65536)it+=String.fromCharCode(st);else{var bt=st-65536;it+=String.fromCharCode(55296|bt>>10,56320|bt&1023)}}return it},ko=(q,Q)=>q?Nl(y,q,Q):"";function Vl(q,Q){Q=Le(Q);var ue=Q==="std::string";je(q,{name:Q,fromWireType:function(Ie){var Ge=C[Ie>>2],it=Ie+4,st;if(ue)for(var ot=it,Tt=0;Tt<=Ge;++Tt){var bt=it+Tt;if(Tt==Ge||y[bt]==0){var Jt=bt-ot,wn=ko(ot,Jt);st===void 0?st=wn:(st+="\0",st+=wn),ot=bt+1}}else{for(var en=new Array(Ge),Tt=0;Tt<Ge;++Tt)en[Tt]=String.fromCharCode(y[it+Tt]);st=en.join("")}return Cs(Ie),st},toWireType:function(Ie,Ge){Ge instanceof ArrayBuffer&&(Ge=new Uint8Array(Ge));var it,st=typeof Ge=="string";st||Ge instanceof Uint8Array||Ge instanceof Uint8ClampedArray||Ge instanceof Int8Array||Pe("Cannot pass non-string to std::string"),ue&&st?it=Gs(Ge):it=Ge.length;var ot=Bc(4+it+1),Tt=ot+4;if(C[ot>>2]=it,ue&&st)To(Ge,Tt,it+1);else if(st)for(var bt=0;bt<it;++bt){var Jt=Ge.charCodeAt(bt);Jt>255&&(Cs(Tt),Pe("String has UTF-16 code units that do not fit in 8 bits")),y[Tt+bt]=Jt}else for(var bt=0;bt<it;++bt)y[Tt+bt]=Ge[bt];return Ie!==null&&Ie.push(Cs,ot),ot},argPackAdvance:8,readValueFromPointer:Xt,destructorFunction:function(Ie){Cs(Ie)}})}var Ta=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,Hl=(q,Q)=>{for(var ue=q,Ie=ue>>1,Ge=Ie+Q/2;!(Ie>=Ge)&&m[Ie];)++Ie;if(ue=Ie<<1,ue-q>32&&Ta)return Ta.decode(y.subarray(q,ue));for(var it="",st=0;!(st>=Q/2);++st){var ot=p[q+st*2>>1];if(ot==0)break;it+=String.fromCharCode(ot)}return it},xl=(q,Q,ue)=>{if(ue===void 0&&(ue=2147483647),ue<2)return 0;ue-=2;for(var Ie=Q,Ge=ue<q.length*2?ue/2:q.length,it=0;it<Ge;++it){var st=q.charCodeAt(it);p[Q>>1]=st,Q+=2}return p[Q>>1]=0,Q-Ie},Ul=q=>q.length*2,Ue=(q,Q)=>{for(var ue=0,Ie="";!(ue>=Q/4);){var Ge=w[q+ue*4>>2];if(Ge==0)break;if(++ue,Ge>=65536){var it=Ge-65536;Ie+=String.fromCharCode(55296|it>>10,56320|it&1023)}else Ie+=String.fromCharCode(Ge)}return Ie},pr=(q,Q,ue)=>{if(ue===void 0&&(ue=2147483647),ue<4)return 0;for(var Ie=Q,Ge=Ie+ue-4,it=0;it<q.length;++it){var st=q.charCodeAt(it);if(st>=55296&&st<=57343){var ot=q.charCodeAt(++it);st=65536+((st&1023)<<10)|ot&1023}if(w[Q>>2]=st,Q+=4,Q+4>Ge)break}return w[Q>>2]=0,Q-Ie},ar=q=>{for(var Q=0,ue=0;ue<q.length;++ue){var Ie=q.charCodeAt(ue);Ie>=55296&&Ie<=57343&&++ue,Q+=4}return Q},ai=function(q,Q,ue){ue=Le(ue);var Ie,Ge,it,st,ot;Q===2?(Ie=Hl,Ge=xl,st=Ul,it=()=>m,ot=1):Q===4&&(Ie=Ue,Ge=pr,st=ar,it=()=>C,ot=2),je(q,{name:ue,fromWireType:function(Tt){for(var bt=C[Tt>>2],Jt=it(),wn,en=Tt+4,An=0;An<=bt;++An){var Sr=Tt+4+An*Q;if(An==bt||Jt[Sr>>ot]==0){var Dr=Sr-en,Vr=Ie(en,Dr);wn===void 0?wn=Vr:(wn+="\0",wn+=Vr),en=Sr+Q}}return Cs(Tt),wn},toWireType:function(Tt,bt){typeof bt!="string"&&Pe(`Cannot pass non-string to C++ string type ${ue}`);var Jt=st(bt),wn=Bc(4+Jt+Q);return C[wn>>2]=Jt>>ot,Ge(bt,wn+4,Jt+Q),Tt!==null&&Tt.push(Cs,wn),wn},argPackAdvance:8,readValueFromPointer:Xt,destructorFunction:function(Tt){Cs(Tt)}})};function mr(q,Q){Q=Le(Q),je(q,{isVoid:!0,name:Q,argPackAdvance:0,fromWireType:function(){},toWireType:function(ue,Ie){}})}function Xr(q,Q){return Q+2097152>>>0<4194305-!!q?(q>>>0)+Q*4294967296:NaN}function es(q,Q,ue){var Ie=Xr(q,Q),Ge=new Date(Ie*1e3);w[ue>>2]=Ge.getUTCSeconds(),w[ue+4>>2]=Ge.getUTCMinutes(),w[ue+8>>2]=Ge.getUTCHours(),w[ue+12>>2]=Ge.getUTCDate(),w[ue+16>>2]=Ge.getUTCMonth(),w[ue+20>>2]=Ge.getUTCFullYear()-1900,w[ue+24>>2]=Ge.getUTCDay();var it=Date.UTC(Ge.getUTCFullYear(),0,1,0,0,0,0),st=(Ge.getTime()-it)/(1e3*60*60*24)|0;w[ue+28>>2]=st}var ka=q=>{var Q=Gs(q)+1,ue=Bc(Q);return ue&&To(q,ue,Q),ue},Aa=(q,Q,ue)=>{var Ie=new Date().getFullYear(),Ge=new Date(Ie,0,1),it=new Date(Ie,6,1),st=Ge.getTimezoneOffset(),ot=it.getTimezoneOffset(),Tt=Math.max(st,ot);C[q>>2]=Tt*60,w[Q>>2]=+(st!=ot);function bt(Sr){var Dr=Sr.toTimeString().match(/\(([A-Za-z ]+)\)$/);return Dr?Dr[1]:"GMT"}var Jt=bt(Ge),wn=bt(it),en=ka(Jt),An=ka(wn);ot<st?(C[ue>>2]=en,C[ue+4>>2]=An):(C[ue>>2]=An,C[ue+4>>2]=en)},As=()=>{M("")};function Wl(){return Date.now()}var Se=()=>2147483648,Lt=q=>{var Q=g.buffer,ue=q-Q.byteLength+65535>>>16;try{return g.grow(ue),L(),1}catch{}},Ln=q=>{var Q=y.length;q>>>=0;var ue=Se();if(q>ue)return!1;for(var Ie=(Tt,bt)=>Tt+(bt-Tt%bt)%bt,Ge=1;Ge<=4;Ge*=2){var it=Q*(1+.2/Ge);it=Math.min(it,q+100663296);var st=Math.min(ue,Ie(Math.max(q,it),65536)),ot=Lt(st);if(ot)return!0}return!1},fn={},kn=()=>o||"./this.program",lr=()=>{if(!lr.strings){var q=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",Q={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:q,_:kn()};for(var ue in fn)fn[ue]===void 0?delete Q[ue]:Q[ue]=fn[ue];var Ie=[];for(var ue in Q)Ie.push(`${ue}=${Q[ue]}`);lr.strings=Ie}return lr.strings},li=(q,Q)=>{for(var ue=0;ue<q.length;++ue)b[Q++>>0]=q.charCodeAt(ue);b[Q>>0]=0},Er=(q,Q)=>{var ue=0;return lr().forEach(function(Ie,Ge){var it=Q+ue;C[q+Ge*4>>2]=it,li(Ie,it),ue+=Ie.length+1}),0},js=(q,Q)=>{var ue=lr();C[q>>2]=ue.length;var Ie=0;return ue.forEach(function(Ge){Ie+=Ge.length+1}),C[Q>>2]=Ie,0},ts=q=>q%4===0&&(q%100!==0||q%400===0),Oc=(q,Q)=>{for(var ue=0,Ie=0;Ie<=Q;ue+=q[Ie++]);return ue},l_=[31,29,31,30,31,30,31,31,30,31,30,31],u_=[31,28,31,30,31,30,31,31,30,31,30,31],w7=(q,Q)=>{for(var ue=new Date(q.getTime());Q>0;){var Ie=ts(ue.getFullYear()),Ge=ue.getMonth(),it=(Ie?l_:u_)[Ge];if(Q>it-ue.getDate())Q-=it-ue.getDate()+1,ue.setDate(1),Ge<11?ue.setMonth(Ge+1):(ue.setMonth(0),ue.setFullYear(ue.getFullYear()+1));else return ue.setDate(ue.getDate()+Q),ue}return ue};function y7(q,Q,ue){var Ie=ue>0?ue:Gs(q)+1,Ge=new Array(Ie),it=zr(q,Ge,0,Ge.length);return Q&&(Ge.length=it),Ge}var v7=(q,Q)=>{b.set(q,Q)},E7=(q,Q,ue,Ie)=>{var Ge=w[Ie+40>>2],it={tm_sec:w[Ie>>2],tm_min:w[Ie+4>>2],tm_hour:w[Ie+8>>2],tm_mday:w[Ie+12>>2],tm_mon:w[Ie+16>>2],tm_year:w[Ie+20>>2],tm_wday:w[Ie+24>>2],tm_yday:w[Ie+28>>2],tm_isdst:w[Ie+32>>2],tm_gmtoff:w[Ie+36>>2],tm_zone:Ge?ko(Ge):""},st=ko(ue),ot={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var Tt in ot)st=st.replace(new RegExp(Tt,"g"),ot[Tt]);var bt=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Jt=["January","February","March","April","May","June","July","August","September","October","November","December"];function wn(gt,Ot,ui){for(var Hr=typeof gt=="number"?gt.toString():gt||"";Hr.length<Ot;)Hr=ui[0]+Hr;return Hr}function en(gt,Ot){return wn(gt,Ot,"0")}function An(gt,Ot){function ui(Ao){return Ao<0?-1:Ao>0?1:0}var Hr;return(Hr=ui(gt.getFullYear()-Ot.getFullYear()))===0&&(Hr=ui(gt.getMonth()-Ot.getMonth()))===0&&(Hr=ui(gt.getDate()-Ot.getDate())),Hr}function Sr(gt){switch(gt.getDay()){case 0:return new Date(gt.getFullYear()-1,11,29);case 1:return gt;case 2:return new Date(gt.getFullYear(),0,3);case 3:return new Date(gt.getFullYear(),0,2);case 4:return new Date(gt.getFullYear(),0,1);case 5:return new Date(gt.getFullYear()-1,11,31);case 6:return new Date(gt.getFullYear()-1,11,30)}}function Dr(gt){var Ot=w7(new Date(gt.tm_year+1900,0,1),gt.tm_yday),ui=new Date(Ot.getFullYear(),0,4),Hr=new Date(Ot.getFullYear()+1,0,4),Ao=Sr(ui),Fc=Sr(Hr);return An(Ao,Ot)<=0?An(Fc,Ot)<=0?Ot.getFullYear()+1:Ot.getFullYear():Ot.getFullYear()-1}var Vr={"%a":gt=>bt[gt.tm_wday].substring(0,3),"%A":gt=>bt[gt.tm_wday],"%b":gt=>Jt[gt.tm_mon].substring(0,3),"%B":gt=>Jt[gt.tm_mon],"%C":gt=>{var Ot=gt.tm_year+1900;return en(Ot/100|0,2)},"%d":gt=>en(gt.tm_mday,2),"%e":gt=>wn(gt.tm_mday,2," "),"%g":gt=>Dr(gt).toString().substring(2),"%G":gt=>Dr(gt),"%H":gt=>en(gt.tm_hour,2),"%I":gt=>{var Ot=gt.tm_hour;return Ot==0?Ot=12:Ot>12&&(Ot-=12),en(Ot,2)},"%j":gt=>en(gt.tm_mday+Oc(ts(gt.tm_year+1900)?l_:u_,gt.tm_mon-1),3),"%m":gt=>en(gt.tm_mon+1,2),"%M":gt=>en(gt.tm_min,2),"%n":()=>`
`,"%p":gt=>gt.tm_hour>=0&&gt.tm_hour<12?"AM":"PM","%S":gt=>en(gt.tm_sec,2),"%t":()=>" ","%u":gt=>gt.tm_wday||7,"%U":gt=>{var Ot=gt.tm_yday+7-gt.tm_wday;return en(Math.floor(Ot/7),2)},"%V":gt=>{var Ot=Math.floor((gt.tm_yday+7-(gt.tm_wday+6)%7)/7);if((gt.tm_wday+371-gt.tm_yday-2)%7<=2&&Ot++,Ot){if(Ot==53){var Hr=(gt.tm_wday+371-gt.tm_yday)%7;Hr!=4&&(Hr!=3||!ts(gt.tm_year))&&(Ot=1)}}else{Ot=52;var ui=(gt.tm_wday+7-gt.tm_yday-1)%7;(ui==4||ui==5&&ts(gt.tm_year%400-1))&&Ot++}return en(Ot,2)},"%w":gt=>gt.tm_wday,"%W":gt=>{var Ot=gt.tm_yday+7-(gt.tm_wday+6)%7;return en(Math.floor(Ot/7),2)},"%y":gt=>(gt.tm_year+1900).toString().substring(2),"%Y":gt=>gt.tm_year+1900,"%z":gt=>{var Ot=gt.tm_gmtoff,ui=Ot>=0;return Ot=Math.abs(Ot)/60,Ot=Ot/60*100+Ot%60,(ui?"+":"-")+("0000"+Ot).slice(-4)},"%Z":gt=>gt.tm_zone,"%%":()=>"%"};st=st.replace(/%%/g,"\0\0");for(var Tt in Vr)st.includes(Tt)&&(st=st.replace(new RegExp(Tt,"g"),Vr[Tt](it)));st=st.replace(/\0\0/g,"%");var Ai=y7(st,!1);return Ai.length>Q?0:(v7(Ai,q),Ai.length-1)},S7=(q,Q,ue,Ie,Ge)=>E7(q,Q,ue,Ie);Ne(),H=n.BindingError=class extends Error{constructor(Q){super(Q),this.name="BindingError"}},xe=n.InternalError=class extends Error{constructor(Q){super(Q),this.name="InternalError"}},vt(),De(),Ye(),dr=n.UnboundTypeError=vr(Error,"UnboundTypeError"),It(),He();var T7={k:ve,h:et,t:pn,s:jr,d:Ve,r:Gt,g:Pt,c:On,b:Br,f:Vl,e:ai,i:mr,j:es,p:Aa,a:As,q:Wl,o:Ln,m:Er,n:js,l:S7};Me();var Bc=q=>(Bc=v.w)(q),Cs=q=>(Cs=v.y)(q),c_=q=>(c_=v.z)(q);n.__embind_initialize_bindings=()=>(n.__embind_initialize_bindings=v.A)(),n.dynCall_iiijj=(q,Q,ue,Ie,Ge,it,st)=>(n.dynCall_iiijj=v.B)(q,Q,ue,Ie,Ge,it,st),n.dynCall_viijii=(q,Q,ue,Ie,Ge,it,st)=>(n.dynCall_viijii=v.C)(q,Q,ue,Ie,Ge,it,st),n.dynCall_iiiiij=(q,Q,ue,Ie,Ge,it,st)=>(n.dynCall_iiiiij=v.D)(q,Q,ue,Ie,Ge,it,st),n.dynCall_iiiiijj=(q,Q,ue,Ie,Ge,it,st,ot,Tt)=>(n.dynCall_iiiiijj=v.E)(q,Q,ue,Ie,Ge,it,st,ot,Tt),n.dynCall_iiiiiijj=(q,Q,ue,Ie,Ge,it,st,ot,Tt,bt)=>(n.dynCall_iiiiiijj=v.F)(q,Q,ue,Ie,Ge,it,st,ot,Tt,bt);var Dc;J=function q(){Dc||f_(),Dc||(J=q)};function f_(){if(K>0||(ae(),K>0))return;function q(){Dc||(Dc=!0,n.calledRun=!0,!_&&(V(),r(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),E()))}n.setStatus?(n.setStatus("Running..."),setTimeout(function(){setTimeout(function(){n.setStatus("")},1),q()},1)):q()}if(n.preInit)for(typeof n.preInit=="function"&&(n.preInit=[n.preInit]);n.preInit.length>0;)n.preInit.pop()();return f_(),e.ready}})(),Yb=["locateFile"],S0=function(){};function Kb(t,e){try{var n=new URL(e);if(n.pathname==="/")return"".concat(e,"mediainfo.js/dist/").concat(t)}catch{}return"".concat(e,"../").concat(t)}function T0(){var t,e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0;if(n===void 0)return new Promise(function(l,c){return T0(e,l,c)});var i=hi(hi(hi({},b1),e),{},{format:(t=e.format)!==null&&t!==void 0?t:b1.format}),s=i.locateFile,o=Nb(i,Yb),a={print:S0,printErr:S0,locateFile:s||Kb,onAbort:function(c){r&&r(c)}};Xb(a).then(function(l){return n(new zb(l,o))}).catch(function(l){r&&r(l)})}const k0=new Map([["/9j/","image/jpg"],["iVBORw0KGgo","image/png"],["UklGR","image/webp"],["R0lGODdh","image/gif"],["R0lGODlh","image/gif"]]);let fl;function qb(t){if(!t)return;const n=[...k0.keys()].find(r=>t.startsWith(r))||"";return k0.get(n)}function w1(t,e,n){return new Promise((r,i)=>{if(fl&&!e)return r();T0({coverData:t,format:"object",locateFile:()=>n||window.GM_getResourceURL("mediaInfo")},s=>{if(fl)try{fl.close()}catch{}fl=s,r()},({message:s})=>i(new Error(`Failed to create MediaInfo instance - ${s}`)))})}async function Zb(t,e,n=""){return await w1(e,!1,n),new Promise((r,i)=>{const s=()=>t.size,o=(a,l)=>new Promise((c,u)=>{const f=new FileReader;f.addEventListener("loadend",g=>{if(g.target){if(g.target.error)return u(new Error(`Error reading file - ${g.target.error.message}`))}else return u(new Error("No FileReader data"));c(new Uint8Array(g.target.result))}),f.addEventListener("error",()=>{u(new Error("Error reading file"))}),f.readAsArrayBuffer(t.slice(l,l+a))});fl.analyzeData(s,o).then(a=>r(a)).catch(({message:a})=>i(new Error(`Failed to get audio metadata - ${a}`)))})}function Jb(t){if(!t)return"";const e=qb(t);return e?URL.createObjectURL(new Blob([Gc.from(t,"base64")],{type:e})):""}class Qb{constructor(){er(this,"seperator",",")}timestampToSeconds(e){const[n,r]=e.split(","),i=parseInt(r),[s,o,a]=n.split(":").map(c=>parseInt(c)),l=i*.001+a+60*o+3600*s;return Math.round(l*1e3)/1e3}correctFormat(e){let n=e.replace(".",",");var r=null,i=null,s=null,o=null,[a,l]=n.split(",");o=this.fixed_str_digit(3,l);var[c,u,f]=a.split(":");return r=this.fixed_str_digit(2,c,!1),i=this.fixed_str_digit(2,u,!1),s=this.fixed_str_digit(2,f,!1),`${r}:${i}:${s},${o}`}fixed_str_digit(e,n,r=!0){if(n.length==e)return n;if(n.length>e)return n.slice(0,e);if(n.length<e)return r?n.padEnd(e,"0"):n.padStart(e,"0")}tryComma(e){e=e.replace(/\r/g,"");var n=/(\d+)\n(\d{1,2}:\d{2}:\d{2},\d{1,3}) --> (\d{1,2}:\d{2}:\d{2},\d{1,3})/g;let r=e.split(n);return r.shift(),r}tryDot(e){e=e.replace(/\r/g,"");var n=/(\d+)\n(\d{1,2}:\d{2}:\d{2}\.\d{1,3}) --> (\d{1,2}:\d{2}:\d{2}\.\d{1,3})/g;let r=e.split(n);return r.shift(),this.seperator=".",r}fromSrt(e){var n=e,r=this.tryComma(n);r.length==0&&(r=this.tryDot(n));for(var i=[],s=0;s<r.length;s+=4){const a=this.correctFormat(r[s+1].trim()),l=this.correctFormat(r[s+2].trim());var o={id:r[s].trim(),startTime:a,startSeconds:this.timestampToSeconds(a),endTime:l,endSeconds:this.timestampToSeconds(l),text:r[s+3].trim()};i.push(o)}return i}toSrt(e){var n="";const r=`\r
`;for(var i=0;i<e.length;i++){var s=e[i];n+=s.id+r,n+=s.startTime+" --> "+s.endTime+r,n+=s.text.replace(`
`,r)+r+r}return n}}async function A0(t,e={mode:"read"}){if(await t.queryPermission(e)==="granted"||await t.requestPermission(e)==="granted")return!0;throw new Error("File access not granted")}function e3(t){return new Promise((e,n)=>{const r=new FileReader;r.addEventListener("loadend",i=>{if(i.target){if(i.target.error)return n(new Error(`Error reading file - ${i.target.error.message}`))}else return n(new Error("No FileReader data"));e(i.target.result)}),r.addEventListener("error",()=>{n(new Error("Error reading file"))}),r.readAsText(t)})}function t3(t,e){const n=e.createElement("audio"),r=e.createElement("track");return r.default=!0,n.append(r),new Promise((i,s)=>{r.addEventListener("load",()=>i([...n.textTracks[0].cues||[]])),r.addEventListener("error",()=>s(new Error("Failed to load vtt track"))),r.src=t})}async function C0(t,e={mode:"read"}){const n=[];for(let i=0,{length:s}=t;i<s;i+=1){const o=t[i];o&&n.push(A0(o,e))}if((await Promise.all(n)).some(i=>!i))throw new Error("File access not granted");return!0}async function Lu(t,e,n=!1){const r=new Map;let i="";try{Mn.set(!0);const s=Ct(_t.subtitlesGlobalStartPadding$)/1e3,o=Ct(_t.subtitlesGlobalEndPadding$)/1e3,a=Ct(ls);if(t.name.endsWith(".srt")||t.name.endsWith(".txt")){const l=new Qb,c=await e3(t),u=[...l.fromSrt(c)];for(let f=0,{length:g}=u;f<g;f+=1){const v=u[f],_=Math.max(0,v.startSeconds+s),b=a?Wi(0,a,v.endSeconds+o):Math.max(0,v.endSeconds+o),y=v.text.trim();r.set(v.id,{id:v.id,originalStartSeconds:v.startSeconds,startSeconds:_,startTime:Qr(_),originalEndSeconds:v.endSeconds,endSeconds:b,endTime:Qr(b),originalText:y,text:y,subIndex:f})}}else if(t.name.endsWith(".vtt")){i=URL.createObjectURL(t);const l=await t3(i,e);for(let c=0,{length:u}=l;c<u;c+=1){const f=l[c],g=`${c+1}`,v=Math.max(0,f.startTime+s),_=a?Wi(0,a,f.endTime+o):Math.max(0,f.endTime+o),b=f.text.trim();r.set(g,{id:g,originalStartSeconds:f.startTime,startSeconds:v,startTime:Qr(v),originalEndSeconds:f.endTime,endSeconds:_,endTime:Qr(_),originalText:b,text:b,subIndex:c})}}else throw new Error("File needs to be .srt,.txt or .vtt");return n&&cs(t,r),r}finally{URL.revokeObjectURL(i)}}function cs(t=void 0,e=new Map){cu.set(new Set),Ya.set(new Set),rs.set(t),Lr.set(e),Za.set({subtitles:[...e.values()],replaceTrack:!0})}async function Qo(t,e,n=!1,r=!1,i="",s=""){const o=Ct(_t.playerEnableCover$),a=Ct(_t.playerEnableChapters$),l=t.name.split(".").pop(),c=[];let u="",f=!1,g="",v=[],_;if(r||(Mn.set(!0),Ct(_t.exportAudioProcessor$)===kr.FFMPEG&&await kd().catch(({message:b})=>c.push(`FFMEPG failure: ${b}`))),o||a)try{if(_=await(e?Yc(e,{action:"getAudioMetadata",url:chrome.runtime.getURL("src/assets/js/MediaInfoModule_0.2.1.wasm"),file:t,enableCover:o}):Zb(t,o)),!(_!=null&&_.media))throw new Error("No media metadata found");const b=_.media.track.find(y=>y["@type"]==="General");if(!b)throw new Error("No general track found");if(f=l==="mp3"&&(b.OverallBitRate_Mode==="VBR"||b.OverallBitRate_Mode_String==="VBR"),a)for(let y=0,{length:p}=_.media.track;y<p;y+=1){const m=_.media.track[y],w=Object.keys(m.extra||{});if(!(m["@type"]!=="Menu"||!w.length||!w[0].match(/_(\d{2}_\d{2}_\d{2}_\d{3})/)))for(let C=0,{length:h}=w;C<h;C+=1){const A=w[C],L=A.split("_"),$=m.extra[A],P=Number.parseInt(L[1],10)*3600+Number.parseInt(L[2],10)*60+Number.parseInt(L[3],10)+Number.parseInt(L[4],10)/1e3;v.push({key:`${$}_${P}`,label:$,startSeconds:P,startText:eo(P)})}}o&&(u=Jb(b.Cover_Data))}catch({message:b}){c.push(`MediaInfo failure: ${b}`)}if(!r&&!f)try{g=URL.createObjectURL(t),n&&await Os(i,s,t,{coverUrl:u,chapters:v,audioSourceUrl:g})}catch({message:b}){URL.revokeObjectURL(u),URL.revokeObjectURL(g),c.push(b)}if(f&&c.push("MP3 files with variable bitrates are not supported"),c.length)throw new Error(c.join("; "));return{coverUrl:u,audioSourceUrl:g,chapters:v}}async function Os(t,e,n=void 0,r={coverUrl:"",chapters:[],audioSourceUrl:""}){await Ad(n);const i=await(n&&!r.chapters.length?t1(n):Promise.resolve(r.chapters));Ps.set(!1),$a.set(n),qs.set(r.coverUrl),Na.set(r.audioSourceUrl),Zs.set(i),n||as.set({previous:"",current:"",useTimeFallback:!1}),URL.revokeObjectURL(t),URL.revokeObjectURL(e)}async function M0(t,e,n,r){const i=_d()?unsafeWindow:t,[s]=await i.showOpenFilePicker({excludeAcceptAllOption:!0,id:"ttu-whispersync-file",types:[{description:e,accept:{"*/*":n}}]});if(!await A0(s))throw new Error("File access not granted");const a=await(r?r.isSameEntry(s):Promise.resolve(!1));let l;return a||(l=await s.getFile()),{handle:s,file:l}}function n3(t){let e;return{c(){e=Nt(t[0])},m(n,r){he(n,e,r)},p(n,r){r&1&&cn(e,n[0])},d(n){n&&de(e)}}}function R0(t){let e,n,r,i,s,o;return{c(){e=_e("div"),n=_e("label"),n.textContent="Enable filesystem api",r=me(),i=_e("input"),ie(n,"for","fs-state"),ie(i,"id","fs-state"),ie(i,"type","checkbox"),ie(e,"class","mt-4")},m(a,l){he(a,e,l),oe(e,n),oe(e,r),oe(e,i),i.checked=t[5],s||(o=Xe(i,"change",t[11]),s=!0)},p(a,l){l&32&&(i.checked=a[5])},d(a){a&&de(e),s=!1,o()}}}function r3(t){let e,n,r,i,s=t[4]&&R0(t);return{c(){e=_e("p"),n=Nt(t[1]),r=me(),s&&s.c(),i=Fr(),ie(e,"style",t[2])},m(o,a){he(o,e,a),oe(e,n),he(o,r,a),s&&s.m(o,a),he(o,i,a)},p(o,a){a&2&&cn(n,o[1]),a&4&&ie(e,"style",o[2]),o[4]?s?s.p(o,a):(s=R0(o),s.c(),s.m(i.parentNode,i)):s&&(s.d(1),s=null)},d(o){o&&(de(e),de(r),de(i)),s&&s.d(o)}}}function i3(t){let e,n,r,i,s,o;return{c(){e=_e("div"),n=_e("button"),n.textContent="Cancel",r=me(),i=_e("button"),i.textContent="Confirm",pt(n,"invisible",!t[3]),ie(e,"class","flex grow justify-between"),ie(e,"slot","footer")},m(a,l){he(a,e,l),oe(e,n),oe(e,r),oe(e,i),s||(o=[Xe(n,"click",t[9]),Xe(i,"click",t[10])],s=!0)},p(a,l){l&8&&pt(n,"invisible",!a[3])},d(a){a&&de(e),s=!1,vn(o)}}}function s3(t){let e,n;return e=new vu({props:{$$slots:{footer:[i3],content:[r3],header:[n3]},$$scope:{ctx:t}}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},p(r,[i]){const s={};i&8255&&(s.$$scope={dirty:i,ctx:r}),e.$set(s)},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function o3(t,e,n){let r,{dialogHeader:i}=e,{dialogMessage:s}=e,{contentStyles:o}=e,{showCancel:a=!0}=e,{isFileReopen:l=!1}=e,{resolver:c}=e;const{readerEnableFilesystemApi$:u}=_t;ce(t,u,y=>n(5,r=y));const f=Ri();function g(y=!1){c(y),f("close")}const v=()=>g(!0),_=()=>g();function b(){r=this.checked,u.set(r)}return t.$$set=y=>{"dialogHeader"in y&&n(0,i=y.dialogHeader),"dialogMessage"in y&&n(1,s=y.dialogMessage),"contentStyles"in y&&n(2,o=y.contentStyles),"showCancel"in y&&n(3,a=y.showCancel),"isFileReopen"in y&&n(4,l=y.isFileReopen),"resolver"in y&&n(8,c=y.resolver)},[i,s,o,a,l,r,u,g,c,v,_,b]}class L0 extends Dn{constructor(e){super(),Bn(this,e,o3,s3,Cn,{dialogHeader:0,dialogMessage:1,contentStyles:2,showCancel:3,isFileReopen:4,resolver:8})}}function a3(t){return new Int8Array(t)}function P0(t){return new Int16Array(t)}function I0(t){return new Int32Array(t)}function O0(t){return new Float32Array(t)}function l3(t){return new Float64Array(t)}function B0(t){if(t.length==1)return O0(t[0]);var e=t[0];t=t.slice(1);for(var n=[],r=0;r<e;r++)n.push(B0(t));return n}function D0(t){if(t.length==1)return I0(t[0]);var e=t[0];t=t.slice(1);for(var n=[],r=0;r<e;r++)n.push(D0(t));return n}function F0(t){if(t.length==1)return P0(t[0]);var e=t[0];t=t.slice(1);for(var n=[],r=0;r<e;r++)n.push(F0(t));return n}function $0(t){if(t.length==1)return new Array(t[0]);var e=t[0];t=t.slice(1);for(var n=[],r=0;r<e;r++)n.push($0(t));return n}var N0={};N0.fill=function(t,e,n,r){if(arguments.length==2)for(var i=0;i<t.length;i++)t[i]=arguments[1];else for(var i=e;i<n;i++)t[i]=r};var dl={};dl.arraycopy=function(t,e,n,r,i){for(var s=e+i;e<s;)n[r++]=t[e++]},dl.out={},dl.out.println=function(t){console.log(t)},dl.out.printf=function(){console.log.apply(console,arguments)};var Pu={};Pu.SQRT2=1.4142135623730951,Pu.FAST_LOG10=function(t){return Math.log10(t)},Pu.FAST_LOG10_X=function(t,e){return Math.log10(t)*e};function fs(t){this.ordinal=t}fs.short_block_allowed=new fs(0),fs.short_block_coupled=new fs(1),fs.short_block_dispensed=new fs(2),fs.short_block_forced=new fs(3);var V0={};V0.MAX_VALUE=34028235e31;function pi(t){this.ordinal=t}pi.vbr_off=new pi(0),pi.vbr_mt=new pi(1),pi.vbr_rh=new pi(2),pi.vbr_abr=new pi(3),pi.vbr_mtrh=new pi(4),pi.vbr_default=pi.vbr_mtrh;var u3=function(t){},jn={System:dl,VbrMode:pi,Float:V0,ShortBlock:fs,Util:Pu,Arrays:N0,new_array_n:$0,new_byte:a3,new_double:l3,new_float:O0,new_float_n:B0,new_int:I0,new_int_n:D0,new_short:P0,new_short_n:F0,assert:u3},y1,H0;function c3(){if(H0)return y1;H0=1;var t=jn,e=t.System,n=t.Util,r=t.Arrays,i=t.new_float,s=xr();function o(){var a=[-.1482523854003001,32.308141959636465,296.40344946382766,883.1344870032432,11113.947376231741,1057.2713659324597,305.7402417275812,30.825928907280012,3.8533188138216365,59.42900443849514,709.5899960123345,5281.91112291017,-5829.66483675846,-817.6293103748613,-76.91656988279972,-4.594269939176596,.9063471690191471,.1960342806591213,-.15466694054279598,34.324387823855965,301.8067566458425,817.599602898885,11573.795901679885,1181.2520595540152,321.59731579894424,31.232021761053772,3.7107095756221318,53.650946155329365,684.167428119626,5224.56624370173,-6366.391851890084,-908.9766368219582,-89.83068876699639,-5.411397422890401,.8206787908286602,.3901806440322567,-.16070888947830023,36.147034243915876,304.11815768187864,732.7429163887613,11989.60988270091,1300.012278487897,335.28490093152146,31.48816102859945,3.373875931311736,47.232241542899175,652.7371796173471,5132.414255594984,-6909.087078780055,-1001.9990371107289,-103.62185754286375,-6.104916304710272,.7416505462720353,.5805693545089249,-.16636367662261495,37.751650073343995,303.01103387567713,627.9747488785183,12358.763425278165,1412.2779918482834,346.7496836825721,31.598286663170416,3.1598635433980946,40.57878626349686,616.1671130880391,5007.833007176154,-7454.040671756168,-1095.7960341867115,-118.24411666465777,-6.818469345853504,.6681786379192989,.7653668647301797,-.1716176790982088,39.11551877123304,298.3413246578966,503.5259106886539,12679.589408408976,1516.5821921214542,355.9850766329023,31.395241710249053,2.9164211881972335,33.79716964664243,574.8943997801362,4853.234992253242,-7997.57021486075,-1189.7624067269965,-133.6444792601766,-7.7202770609839915,.5993769336819237,.9427934736519954,-.17645823955292173,40.21879108166477,289.9982036694474,359.3226160751053,12950.259102786438,1612.1013903507662,362.85067106591504,31.045922092242872,2.822222032597987,26.988862316190684,529.8996541764288,4671.371946949588,-8535.899136645805,-1282.5898586244496,-149.58553632943463,-8.643494270763135,.5345111359507916,1.111140466039205,-.36174739330527045,41.04429910497807,277.5463268268618,195.6386023135583,13169.43812144731,1697.6433561479398,367.40983966190305,30.557037410382826,2.531473372857427,20.070154905927314,481.50208566532336,4464.970341588308,-9065.36882077239,-1373.62841526722,-166.1660487028118,-9.58289321133207,.4729647758913199,1.268786568327291,-.36970682634889585,41.393213350082036,261.2935935556502,12.935476055240873,13336.131683328815,1772.508612059496,369.76534388639965,29.751323653701338,2.4023193045459172,13.304795348228817,430.5615775526625,4237.0568611071185,-9581.931701634761,-1461.6913552409758,-183.12733958476446,-10.718010163869403,.41421356237309503,1.414213562373095,-.37677560326535325,41.619486213528496,241.05423794991074,-187.94665032361226,13450.063605744153,1836.153896465782,369.4908799925761,29.001847876923147,2.0714759319987186,6.779591200894186,377.7767837205709,3990.386575512536,-10081.709459700915,-1545.947424837898,-200.3762958015653,-11.864482073055006,.3578057213145241,1.546020906725474,-.3829366947518991,41.1516456456653,216.47684307105183,-406.1569483347166,13511.136535077321,1887.8076599260432,367.3025214564151,28.136213436723654,1.913880671464418,.3829366947518991,323.85365704338597,3728.1472257487526,-10561.233882199509,-1625.2025997821418,-217.62525175416,-13.015432208941645,.3033466836073424,1.66293922460509,-.5822628872992417,40.35639251440489,188.20071124269245,-640.2706748618148,13519.21490106562,1927.6022433578062,362.8197642637487,26.968821921868447,1.7463817695935329,-5.62650678237171,269.3016715297017,3453.386536448852,-11016.145278780888,-1698.6569643425091,-234.7658734267683,-14.16351421663124,.2504869601913055,1.76384252869671,-.5887180101749253,39.23429103868072,155.76096234403798,-889.2492977967378,13475.470561874661,1955.0535223723712,356.4450994756727,25.894952980042156,1.5695032905781554,-11.181939564328772,214.80884394039484,3169.1640829158237,-11443.321309975563,-1765.1588461316153,-251.68908574481912,-15.49755935939164,.198912367379658,1.847759065022573,-.7912582233652842,37.39369355329111,119.699486012458,-1151.0956593239027,13380.446257078214,1970.3952110853447,348.01959814116185,24.731487364283044,1.3850130831637748,-16.421408865300393,161.05030052864092,2878.3322807850063,-11838.991423510031,-1823.985884688674,-268.2854986386903,-16.81724543849939,.1483359875383474,1.913880671464418,-.7960642926861912,35.2322109610459,80.01928065061526,-1424.0212633405113,13235.794061869668,1973.804052543835,337.9908651258184,23.289159354463873,1.3934255946442087,-21.099669467133474,108.48348407242611,2583.700758091299,-12199.726194855148,-1874.2780658979746,-284.2467154529415,-18.11369784385905,.09849140335716425,1.961570560806461,-.998795456205172,32.56307803611191,36.958364584370486,-1706.075448829146,13043.287458812016,1965.3831106103316,326.43182772364605,22.175018750622293,1.198638339011324,-25.371248002043963,57.53505923036915,2288.41886619975,-12522.674544337233,-1914.8400385312243,-299.26241273417224,-19.37805630698734,.04912684976946725,1.990369453344394,.035780907*n.SQRT2*.5/2384e-9,.017876148*n.SQRT2*.5/2384e-9,.003134727*n.SQRT2*.5/2384e-9,.002457142*n.SQRT2*.5/2384e-9,971317e-9*n.SQRT2*.5/2384e-9,218868e-9*n.SQRT2*.5/2384e-9,101566e-9*n.SQRT2*.5/2384e-9,13828e-9*n.SQRT2*.5/2384e-9,12804.797818791945,1945.5515939597317,313.4244966442953,20.801593959731544,1995.1556208053692,9.000838926174497,-29.20218120805369],l=12,c=36,u=[[2382191739347913e-28,6423305872147834e-28,9400849094049688e-28,1122435026096556e-27,1183840321267481e-27,1122435026096556e-27,940084909404969e-27,6423305872147839e-28,2382191739347918e-28,5456116108943412e-27,4878985199565852e-27,4240448995017367e-27,3559909094758252e-27,2858043359288075e-27,2156177623817898e-27,1475637723558783e-27,8371015190102974e-28,2599706096327376e-28,-5456116108943412e-27,-4878985199565852e-27,-4240448995017367e-27,-3559909094758252e-27,-2858043359288076e-27,-2156177623817898e-27,-1475637723558783e-27,-8371015190102975e-28,-2599706096327376e-28,-2382191739347923e-28,-6423305872147843e-28,-9400849094049696e-28,-1122435026096556e-27,-1183840321267481e-27,-1122435026096556e-27,-9400849094049694e-28,-642330587214784e-27,-2382191739347918e-28],[2382191739347913e-28,6423305872147834e-28,9400849094049688e-28,1122435026096556e-27,1183840321267481e-27,1122435026096556e-27,9400849094049688e-28,6423305872147841e-28,2382191739347918e-28,5456116108943413e-27,4878985199565852e-27,4240448995017367e-27,3559909094758253e-27,2858043359288075e-27,2156177623817898e-27,1475637723558782e-27,8371015190102975e-28,2599706096327376e-28,-5461314069809755e-27,-4921085770524055e-27,-4343405037091838e-27,-3732668368707687e-27,-3093523840190885e-27,-2430835727329465e-27,-1734679010007751e-27,-974825365660928e-27,-2797435120168326e-28,0,0,0,0,0,0,-2283748241799531e-28,-4037858874020686e-28,-2146547464825323e-28],[.1316524975873958,.414213562373095,.7673269879789602,1.091308501069271,1.303225372841206,1.56968557711749,1.920982126971166,2.414213562373094,3.171594802363212,4.510708503662055,7.595754112725146,22.90376554843115,.984807753012208,.6427876096865394,.3420201433256688,.9396926207859084,-.1736481776669303,-.7660444431189779,.8660254037844387,.5,-.5144957554275265,-.4717319685649723,-.3133774542039019,-.1819131996109812,-.09457419252642064,-.04096558288530405,-.01419856857247115,-.003699974673760037,.8574929257125442,.8817419973177052,.9496286491027329,.9833145924917901,.9955178160675857,.9991605581781475,.999899195244447,.9999931550702802],[0,0,0,0,0,0,2283748241799531e-28,4037858874020686e-28,2146547464825323e-28,5461314069809755e-27,4921085770524055e-27,4343405037091838e-27,3732668368707687e-27,3093523840190885e-27,2430835727329466e-27,1734679010007751e-27,974825365660928e-27,2797435120168326e-28,-5456116108943413e-27,-4878985199565852e-27,-4240448995017367e-27,-3559909094758253e-27,-2858043359288075e-27,-2156177623817898e-27,-1475637723558782e-27,-8371015190102975e-28,-2599706096327376e-28,-2382191739347913e-28,-6423305872147834e-28,-9400849094049688e-28,-1122435026096556e-27,-1183840321267481e-27,-1122435026096556e-27,-9400849094049688e-28,-6423305872147841e-28,-2382191739347918e-28]],f=u[s.SHORT_TYPE],g=u[s.SHORT_TYPE],v=u[s.SHORT_TYPE],_=u[s.SHORT_TYPE],b=[0,1,16,17,8,9,24,25,4,5,20,21,12,13,28,29,2,3,18,19,10,11,26,27,6,7,22,23,14,15,30,31];function y(w,C,h){for(var A=10,L=C+238-14-286,$=-15;$<0;$++){var P,I,x;P=a[A+-10],I=w[L+-224]*P,x=w[C+224]*P,P=a[A+-9],I+=w[L+-160]*P,x+=w[C+160]*P,P=a[A+-8],I+=w[L+-96]*P,x+=w[C+96]*P,P=a[A+-7],I+=w[L+-32]*P,x+=w[C+32]*P,P=a[A+-6],I+=w[L+32]*P,x+=w[C+-32]*P,P=a[A+-5],I+=w[L+96]*P,x+=w[C+-96]*P,P=a[A+-4],I+=w[L+160]*P,x+=w[C+-160]*P,P=a[A+-3],I+=w[L+224]*P,x+=w[C+-224]*P,P=a[A+-2],I+=w[C+-256]*P,x-=w[L+256]*P,P=a[A+-1],I+=w[C+-192]*P,x-=w[L+192]*P,P=a[A+0],I+=w[C+-128]*P,x-=w[L+128]*P,P=a[A+1],I+=w[C+-64]*P,x-=w[L+64]*P,P=a[A+2],I+=w[C+0]*P,x-=w[L+0]*P,P=a[A+3],I+=w[C+64]*P,x-=w[L+-64]*P,P=a[A+4],I+=w[C+128]*P,x-=w[L+-128]*P,P=a[A+5],I+=w[C+192]*P,x-=w[L+-192]*P,I*=a[A+6],P=x-I,h[30+$*2]=x+I,h[31+$*2]=a[A+7]*P,A+=18,C--,L++}{var I,x,ae,V;x=w[C+-16]*a[A+-10],I=w[C+-32]*a[A+-2],x+=(w[C+-48]-w[C+16])*a[A+-9],I+=w[C+-96]*a[A+-1],x+=(w[C+-80]+w[C+48])*a[A+-8],I+=w[C+-160]*a[A+0],x+=(w[C+-112]-w[C+80])*a[A+-7],I+=w[C+-224]*a[A+1],x+=(w[C+-144]+w[C+112])*a[A+-6],I-=w[C+32]*a[A+2],x+=(w[C+-176]-w[C+144])*a[A+-5],I-=w[C+96]*a[A+3],x+=(w[C+-208]+w[C+176])*a[A+-4],I-=w[C+160]*a[A+4],x+=(w[C+-240]-w[C+208])*a[A+-3],I-=w[C+224],ae=I-x,V=I+x,x=h[14],I=h[15]-x,h[31]=V+x,h[30]=ae+I,h[15]=ae-I,h[14]=V-x}{var E;E=h[28]-h[0],h[0]+=h[28],h[28]=E*a[A+-2*18+7],E=h[29]-h[1],h[1]+=h[29],h[29]=E*a[A+-2*18+7],E=h[26]-h[2],h[2]+=h[26],h[26]=E*a[A+-4*18+7],E=h[27]-h[3],h[3]+=h[27],h[27]=E*a[A+-4*18+7],E=h[24]-h[4],h[4]+=h[24],h[24]=E*a[A+-6*18+7],E=h[25]-h[5],h[5]+=h[25],h[25]=E*a[A+-6*18+7],E=h[22]-h[6],h[6]+=h[22],h[22]=E*n.SQRT2,E=h[23]-h[7],h[7]+=h[23],h[23]=E*n.SQRT2-h[7],h[7]-=h[6],h[22]-=h[7],h[23]-=h[22],E=h[6],h[6]=h[31]-E,h[31]=h[31]+E,E=h[7],h[7]=h[30]-E,h[30]=h[30]+E,E=h[22],h[22]=h[15]-E,h[15]=h[15]+E,E=h[23],h[23]=h[14]-E,h[14]=h[14]+E,E=h[20]-h[8],h[8]+=h[20],h[20]=E*a[A+-10*18+7],E=h[21]-h[9],h[9]+=h[21],h[21]=E*a[A+-10*18+7],E=h[18]-h[10],h[10]+=h[18],h[18]=E*a[A+-12*18+7],E=h[19]-h[11],h[11]+=h[19],h[19]=E*a[A+-12*18+7],E=h[16]-h[12],h[12]+=h[16],h[16]=E*a[A+-14*18+7],E=h[17]-h[13],h[13]+=h[17],h[17]=E*a[A+-14*18+7],E=-h[20]+h[24],h[20]+=h[24],h[24]=E*a[A+-12*18+7],E=-h[21]+h[25],h[21]+=h[25],h[25]=E*a[A+-12*18+7],E=h[4]-h[8],h[4]+=h[8],h[8]=E*a[A+-12*18+7],E=h[5]-h[9],h[5]+=h[9],h[9]=E*a[A+-12*18+7],E=h[0]-h[12],h[0]+=h[12],h[12]=E*a[A+-4*18+7],E=h[1]-h[13],h[1]+=h[13],h[13]=E*a[A+-4*18+7],E=h[16]-h[28],h[16]+=h[28],h[28]=E*a[A+-4*18+7],E=-h[17]+h[29],h[17]+=h[29],h[29]=E*a[A+-4*18+7],E=n.SQRT2*(h[2]-h[10]),h[2]+=h[10],h[10]=E,E=n.SQRT2*(h[3]-h[11]),h[3]+=h[11],h[11]=E,E=n.SQRT2*(-h[18]+h[26]),h[18]+=h[26],h[26]=E-h[18],E=n.SQRT2*(-h[19]+h[27]),h[19]+=h[27],h[27]=E-h[19],E=h[2],h[19]-=h[3],h[3]-=E,h[2]=h[31]-E,h[31]+=E,E=h[3],h[11]-=h[19],h[18]-=E,h[3]=h[30]-E,h[30]+=E,E=h[18],h[27]-=h[11],h[19]-=E,h[18]=h[15]-E,h[15]+=E,E=h[19],h[10]-=E,h[19]=h[14]-E,h[14]+=E,E=h[10],h[11]-=E,h[10]=h[23]-E,h[23]+=E,E=h[11],h[26]-=E,h[11]=h[22]-E,h[22]+=E,E=h[26],h[27]-=E,h[26]=h[7]-E,h[7]+=E,E=h[27],h[27]=h[6]-E,h[6]+=E,E=n.SQRT2*(h[0]-h[4]),h[0]+=h[4],h[4]=E,E=n.SQRT2*(h[1]-h[5]),h[1]+=h[5],h[5]=E,E=n.SQRT2*(h[16]-h[20]),h[16]+=h[20],h[20]=E,E=n.SQRT2*(h[17]-h[21]),h[17]+=h[21],h[21]=E,E=-n.SQRT2*(h[8]-h[12]),h[8]+=h[12],h[12]=E-h[8],E=-n.SQRT2*(h[9]-h[13]),h[9]+=h[13],h[13]=E-h[9],E=-n.SQRT2*(h[25]-h[29]),h[25]+=h[29],h[29]=E-h[25],E=-n.SQRT2*(h[24]+h[28]),h[24]-=h[28],h[28]=E-h[24],E=h[24]-h[16],h[24]=E,E=h[20]-E,h[20]=E,E=h[28]-E,h[28]=E,E=h[25]-h[17],h[25]=E,E=h[21]-E,h[21]=E,E=h[29]-E,h[29]=E,E=h[17]-h[1],h[17]=E,E=h[9]-E,h[9]=E,E=h[25]-E,h[25]=E,E=h[5]-E,h[5]=E,E=h[21]-E,h[21]=E,E=h[13]-E,h[13]=E,E=h[29]-E,h[29]=E,E=h[1]-h[0],h[1]=E,E=h[16]-E,h[16]=E,E=h[17]-E,h[17]=E,E=h[8]-E,h[8]=E,E=h[9]-E,h[9]=E,E=h[24]-E,h[24]=E,E=h[25]-E,h[25]=E,E=h[4]-E,h[4]=E,E=h[5]-E,h[5]=E,E=h[20]-E,h[20]=E,E=h[21]-E,h[21]=E,E=h[12]-E,h[12]=E,E=h[13]-E,h[13]=E,E=h[28]-E,h[28]=E,E=h[29]-E,h[29]=E,E=h[0],h[0]+=h[31],h[31]-=E,E=h[1],h[1]+=h[30],h[30]-=E,E=h[16],h[16]+=h[15],h[15]-=E,E=h[17],h[17]+=h[14],h[14]-=E,E=h[8],h[8]+=h[23],h[23]-=E,E=h[9],h[9]+=h[22],h[22]-=E,E=h[24],h[24]+=h[7],h[7]-=E,E=h[25],h[25]+=h[6],h[6]-=E,E=h[4],h[4]+=h[27],h[27]-=E,E=h[5],h[5]+=h[26],h[26]-=E,E=h[20],h[20]+=h[11],h[11]-=E,E=h[21],h[21]+=h[10],h[10]-=E,E=h[12],h[12]+=h[19],h[19]-=E,E=h[13],h[13]+=h[18],h[18]-=E,E=h[28],h[28]+=h[3],h[3]-=E,E=h[29],h[29]+=h[2],h[2]-=E}}function p(w,C){for(var h=0;h<3;h++){var A,L,$,P,I,x;P=w[C+2*3]*u[s.SHORT_TYPE][0]-w[C+5*3],A=w[C+0*3]*u[s.SHORT_TYPE][2]-w[C+3*3],L=P+A,$=P-A,P=w[C+5*3]*u[s.SHORT_TYPE][0]+w[C+2*3],A=w[C+3*3]*u[s.SHORT_TYPE][2]+w[C+0*3],I=P+A,x=-P+A,A=(w[C+1*3]*u[s.SHORT_TYPE][1]-w[C+4*3])*2069978111953089e-26,P=(w[C+4*3]*u[s.SHORT_TYPE][1]+w[C+1*3])*2069978111953089e-26,w[C+3*0]=L*190752519173728e-25+A,w[C+3*5]=-I*190752519173728e-25+P,$=$*.8660254037844387*1907525191737281e-26,I=I*.5*1907525191737281e-26+P,w[C+3*1]=$-I,w[C+3*2]=$+I,L=L*.5*1907525191737281e-26-A,x=x*.8660254037844387*1907525191737281e-26,w[C+3*3]=L+x,w[C+3*4]=L-x,C++}}function m(w,C,h){var A,L;{var $,P,I,x,ae,V,E,F;$=h[17]-h[9],I=h[15]-h[11],x=h[14]-h[12],ae=h[0]+h[8],V=h[1]+h[7],E=h[2]+h[6],F=h[3]+h[5],w[C+17]=ae+E-F-(V-h[4]),L=(ae+E-F)*g[19]+(V-h[4]),A=($-I-x)*g[18],w[C+5]=A+L,w[C+6]=A-L,P=(h[16]-h[10])*g[18],V=V*g[19]+h[4],A=$*g[12]+P+I*g[13]+x*g[14],L=-ae*g[16]+V-E*g[17]+F*g[15],w[C+1]=A+L,w[C+2]=A-L,A=$*g[13]-P-I*g[14]+x*g[12],L=-ae*g[17]+V-E*g[15]+F*g[16],w[C+9]=A+L,w[C+10]=A-L,A=$*g[14]-P+I*g[12]-x*g[13],L=ae*g[15]-V+E*g[16]-F*g[17],w[C+13]=A+L,w[C+14]=A-L}{var N,Y,K,J,j,B,M,S;N=h[8]-h[0],K=h[6]-h[2],J=h[5]-h[3],j=h[17]+h[9],B=h[16]+h[10],M=h[15]+h[11],S=h[14]+h[12],w[C+0]=j+M+S+(B+h[13]),A=(j+M+S)*g[19]-(B+h[13]),L=(N-K+J)*g[18],w[C+11]=A+L,w[C+12]=A-L,Y=(h[7]-h[1])*g[18],B=h[13]-B*g[19],A=j*g[15]-B+M*g[16]+S*g[17],L=N*g[14]+Y+K*g[12]+J*g[13],w[C+3]=A+L,w[C+4]=A-L,A=-j*g[17]+B-M*g[15]-S*g[16],L=N*g[13]+Y-K*g[14]-J*g[12],w[C+7]=A+L,w[C+8]=A-L,A=-j*g[16]+B-M*g[17]-S*g[15],L=N*g[12]-Y+K*g[13]-J*g[14],w[C+15]=A+L,w[C+16]=A-L}}this.mdct_sub48=function(w,C,h){for(var A=C,L=286,$=0;$<w.channels_out;$++){for(var P=0;P<w.mode_gr;P++){for(var I,x=w.l3_side.tt[P][$],ae=x.xr,V=0,E=w.sb_sample[$][1-P],F=0,N=0;N<18/2;N++)for(y(A,L,E[F]),y(A,L+32,E[F+1]),F+=2,L+=64,I=1;I<32;I+=2)E[F-1][I]*=-1;for(I=0;I<32;I++,V+=18){var Y=x.block_type,K=w.sb_sample[$][P],J=w.sb_sample[$][1-P];if(x.mixed_block_flag!=0&&I<2&&(Y=0),w.amp_filter[I]<1e-12)r.fill(ae,V+0,V+18,0);else{if(w.amp_filter[I]<1)for(var N=0;N<18;N++)J[N][b[I]]*=w.amp_filter[I];if(Y==s.SHORT_TYPE){for(var N=-l/4;N<0;N++){var j=u[s.SHORT_TYPE][N+3];ae[V+N*3+9]=K[9+N][b[I]]*j-K[8-N][b[I]],ae[V+N*3+18]=K[14-N][b[I]]*j+K[15+N][b[I]],ae[V+N*3+10]=K[15+N][b[I]]*j-K[14-N][b[I]],ae[V+N*3+19]=J[2-N][b[I]]*j+J[3+N][b[I]],ae[V+N*3+11]=J[3+N][b[I]]*j-J[2-N][b[I]],ae[V+N*3+20]=J[8-N][b[I]]*j+J[9+N][b[I]]}p(ae,V)}else{for(var B=i(18),N=-c/4;N<0;N++){var M,S;M=u[Y][N+27]*J[N+9][b[I]]+u[Y][N+36]*J[8-N][b[I]],S=u[Y][N+9]*K[N+9][b[I]]-u[Y][N+18]*K[8-N][b[I]],B[N+9]=M-S*f[3+N+9],B[N+18]=M*f[3+N+9]+S}m(ae,V,B)}}if(Y!=s.SHORT_TYPE&&I!=0)for(var N=7;N>=0;--N){var R,X;R=ae[V+N]*v[20+N]+ae[V+-1-N]*_[28+N],X=ae[V+N]*_[28+N]-ae[V+-1-N]*v[20+N],ae[V+-1-N]=R,ae[V+N]=X}}}if(A=h,L=286,w.mode_gr==1)for(var re=0;re<18;re++)e.arraycopy(w.sb_sample[$][1][re],0,w.sb_sample[$][0][re],0,32)}}}return y1=o,y1}var v1,x0;function U0(){if(x0)return v1;x0=1;var t=xr(),e=jn,n=e.System,r=e.new_float,i=e.new_float_n;function s(){this.l=r(t.SBMAX_l),this.s=i([t.SBMAX_s,3]);var o=this;this.assign=function(a){n.arraycopy(a.l,0,o.l,0,t.SBMAX_l);for(var l=0;l<t.SBMAX_s;l++)for(var c=0;c<3;c++)o.s[l][c]=a.s[l][c]}}return v1=s,v1}var E1,W0;function f3(){if(W0)return E1;W0=1;var t=U0();function e(){this.thm=new t,this.en=new t}return E1=e,E1}function Ii(t){var e=t;this.ordinal=function(){return e}}Ii.STEREO=new Ii(0),Ii.JOINT_STEREO=new Ii(1),Ii.DUAL_CHANNEL=new Ii(2),Ii.MONO=new Ii(3),Ii.NOT_SET=new Ii(4);var hl=Ii,S1,G0;function xr(){if(G0)return S1;G0=1;var t=jn,e=t.System,n=t.VbrMode,r=t.new_array_n,i=t.new_float,s=t.new_float_n,o=t.new_int,a=t.assert;l.ENCDELAY=576,l.POSTDELAY=1152,l.MDCTDELAY=48,l.FFTOFFSET=224+l.MDCTDELAY,l.DECDELAY=528,l.SBLIMIT=32,l.CBANDS=64,l.SBPSY_l=21,l.SBPSY_s=12,l.SBMAX_l=22,l.SBMAX_s=13,l.PSFB21=6,l.PSFB12=6,l.BLKSIZE=1024,l.HBLKSIZE=l.BLKSIZE/2+1,l.BLKSIZE_s=256,l.HBLKSIZE_s=l.BLKSIZE_s/2+1,l.NORM_TYPE=0,l.START_TYPE=1,l.SHORT_TYPE=2,l.STOP_TYPE=3,l.MPG_MD_LR_LR=0,l.MPG_MD_LR_I=1,l.MPG_MD_MS_LR=2,l.MPG_MD_MS_I=3,l.fircoef=[-.0207887*5,-.0378413*5,-.0432472*5,-.031183*5,779609e-23*5,.0467745*5,.10091*5,.151365*5,.187098*5];function l(){var c=c3(),u=f3(),f=hl,g=l.FFTOFFSET,v=l.MPG_MD_MS_LR,_=null;this.psy=null;var b=null,y=null,p=null;this.setModules=function(A,L,$,P){_=A,this.psy=L,b=L,y=P,p=$};var m=new c;function w(A){var L,$;if(A.ATH.useAdjust==0){A.ATH.adjust=1;return}if($=A.loudness_sq[0][0],L=A.loudness_sq[1][0],A.channels_out==2?($+=A.loudness_sq[0][1],L+=A.loudness_sq[1][1]):($+=$,L+=L),A.mode_gr==2&&($=Math.max($,L)),$*=.5,$*=A.ATH.aaSensitivityP,$>.03125)A.ATH.adjust>=1?A.ATH.adjust=1:A.ATH.adjust<A.ATH.adjustLimit&&(A.ATH.adjust=A.ATH.adjustLimit),A.ATH.adjustLimit=1;else{var P=31.98*$+625e-6;A.ATH.adjust>=P?(A.ATH.adjust*=P*.075+.925,A.ATH.adjust<P&&(A.ATH.adjust=P)):A.ATH.adjustLimit>=P?A.ATH.adjust=P:A.ATH.adjust<A.ATH.adjustLimit&&(A.ATH.adjust=A.ATH.adjustLimit),A.ATH.adjustLimit=P}}function C(A){var L,$;for(a(0<=A.bitrate_index&&A.bitrate_index<16),a(0<=A.mode_ext&&A.mode_ext<4),A.bitrate_stereoMode_Hist[A.bitrate_index][4]++,A.bitrate_stereoMode_Hist[15][4]++,A.channels_out==2&&(A.bitrate_stereoMode_Hist[A.bitrate_index][A.mode_ext]++,A.bitrate_stereoMode_Hist[15][A.mode_ext]++),L=0;L<A.mode_gr;++L)for($=0;$<A.channels_out;++$){var P=A.l3_side.tt[L][$].block_type|0;A.l3_side.tt[L][$].mixed_block_flag!=0&&(P=4),A.bitrate_blockType_Hist[A.bitrate_index][P]++,A.bitrate_blockType_Hist[A.bitrate_index][5]++,A.bitrate_blockType_Hist[15][P]++,A.bitrate_blockType_Hist[15][5]++}}function h(A,L){var $=A.internal_flags,P,I;if($.lame_encode_frame_init==0){var x,ae,V=i(2014),E=i(2014);for($.lame_encode_frame_init=1,x=0,ae=0;x<286+576*(1+$.mode_gr);++x)x<576*$.mode_gr?(V[x]=0,$.channels_out==2&&(E[x]=0)):(V[x]=L[0][ae],$.channels_out==2&&(E[x]=L[1][ae]),++ae);for(I=0;I<$.mode_gr;I++)for(P=0;P<$.channels_out;P++)$.l3_side.tt[I][P].block_type=l.SHORT_TYPE;m.mdct_sub48($,V,E),a(576>=l.FFTOFFSET),a($.mf_size>=l.BLKSIZE+A.framesize-l.FFTOFFSET),a($.mf_size>=512+A.framesize-32)}}this.lame_encode_mp3_frame=function(A,L,$,P,I,x){var ae,V=r([2,2]);V[0][0]=new u,V[0][1]=new u,V[1][0]=new u,V[1][1]=new u;var E=r([2,2]);E[0][0]=new u,E[0][1]=new u,E[1][0]=new u,E[1][1]=new u;var F,N=[null,null],Y=A.internal_flags,K=s([2,4]),J=[.5,.5],j=[[0,0],[0,0]],B=[[0,0],[0,0]],M,S,R;if(N[0]=L,N[1]=$,Y.lame_encode_frame_init==0&&h(A,N),Y.padding=0,(Y.slot_lag-=Y.frac_SpF)<0&&(Y.slot_lag+=A.out_samplerate,Y.padding=1),Y.psymodel!=0){var X,re=[null,null],W=0,z=o(2);for(R=0;R<Y.mode_gr;R++){for(S=0;S<Y.channels_out;S++)re[S]=N[S],W=576+R*576-l.FFTOFFSET;if(A.VBR==n.vbr_mtrh||A.VBR==n.vbr_mt?X=b.L3psycho_anal_vbr(A,re,W,R,V,E,j[R],B[R],K[R],z):X=b.L3psycho_anal_ns(A,re,W,R,V,E,j[R],B[R],K[R],z),X!=0)return-4;for(A.mode==f.JOINT_STEREO&&(J[R]=K[R][2]+K[R][3],J[R]>0&&(J[R]=K[R][3]/J[R])),S=0;S<Y.channels_out;S++){var le=Y.l3_side.tt[R][S];le.block_type=z[S],le.mixed_block_flag=0}}}else for(R=0;R<Y.mode_gr;R++)for(S=0;S<Y.channels_out;S++)Y.l3_side.tt[R][S].block_type=l.NORM_TYPE,Y.l3_side.tt[R][S].mixed_block_flag=0,B[R][S]=j[R][S]=700;if(w(Y),m.mdct_sub48(Y,N[0],N[1]),Y.mode_ext=l.MPG_MD_LR_LR,A.force_ms)Y.mode_ext=l.MPG_MD_MS_LR;else if(A.mode==f.JOINT_STEREO){var Me=0,Ee=0;for(R=0;R<Y.mode_gr;R++)for(S=0;S<Y.channels_out;S++)Me+=B[R][S],Ee+=j[R][S];if(Me<=1*Ee){var ve=Y.l3_side.tt[0],ke=Y.l3_side.tt[Y.mode_gr-1];ve[0].block_type==ve[1].block_type&&ke[0].block_type==ke[1].block_type&&(Y.mode_ext=l.MPG_MD_MS_LR)}}if(Y.mode_ext==v?(F=E,M=B):(F=V,M=j),A.analysis&&Y.pinfo!=null)for(R=0;R<Y.mode_gr;R++)for(S=0;S<Y.channels_out;S++)Y.pinfo.ms_ratio[R]=Y.ms_ratio[R],Y.pinfo.ms_ener_ratio[R]=J[R],Y.pinfo.blocktype[R][S]=Y.l3_side.tt[R][S].block_type,Y.pinfo.pe[R][S]=M[R][S],e.arraycopy(Y.l3_side.tt[R][S].xr,0,Y.pinfo.xr[R][S],0,576),Y.mode_ext==v&&(Y.pinfo.ers[R][S]=Y.pinfo.ers[R][S+2],e.arraycopy(Y.pinfo.energy[R][S+2],0,Y.pinfo.energy[R][S],0,Y.pinfo.energy[R][S].length));if(A.VBR==n.vbr_off||A.VBR==n.vbr_abr){var Ne,Te;for(Ne=0;Ne<18;Ne++)Y.nsPsy.pefirbuf[Ne]=Y.nsPsy.pefirbuf[Ne+1];for(Te=0,R=0;R<Y.mode_gr;R++)for(S=0;S<Y.channels_out;S++)Te+=M[R][S];for(Y.nsPsy.pefirbuf[18]=Te,Te=Y.nsPsy.pefirbuf[9],Ne=0;Ne<9;Ne++)Te+=(Y.nsPsy.pefirbuf[Ne]+Y.nsPsy.pefirbuf[18-Ne])*l.fircoef[Ne];for(Te=670*5*Y.mode_gr*Y.channels_out/Te,R=0;R<Y.mode_gr;R++)for(S=0;S<Y.channels_out;S++)M[R][S]*=Te}if(Y.iteration_loop.iteration_loop(A,M,J,F),_.format_bitstream(A),ae=_.copy_buffer(Y,P,I,x,1),A.bWriteVbrTag&&y.addVbrFrame(A),A.analysis&&Y.pinfo!=null){for(S=0;S<Y.channels_out;S++){var Le;for(Le=0;Le<g;Le++)Y.pinfo.pcmdata[S][Le]=Y.pinfo.pcmdata[S][Le+A.framesize];for(Le=g;Le<1600;Le++)Y.pinfo.pcmdata[S][Le]=N[S][Le-g]}p.set_frame_pinfo(A,F)}return C(Y),ae}}return S1=l,S1}var j0=jn,z0=j0.Util,X0=j0.new_float,cr=xr();function d3(){var t=X0(cr.BLKSIZE),e=X0(cr.BLKSIZE_s/2),n=[.9238795325112867,.3826834323650898,.9951847266721969,.0980171403295606,.9996988186962042,.02454122852291229,.9999811752826011,.006135884649154475];function r(s,o,a){var l=0,c,u,f;a<<=1;var g=o+a;c=4;do{var v,_,b,y,p,m,w;w=c>>1,y=c,p=c<<1,m=p+y,c=p<<1,u=o,f=u+w;do{var C,h,A,L;h=s[u+0]-s[u+y],C=s[u+0]+s[u+y],L=s[u+p]-s[u+m],A=s[u+p]+s[u+m],s[u+p]=C-A,s[u+0]=C+A,s[u+m]=h-L,s[u+y]=h+L,h=s[f+0]-s[f+y],C=s[f+0]+s[f+y],L=z0.SQRT2*s[f+m],A=z0.SQRT2*s[f+p],s[f+p]=C-A,s[f+0]=C+A,s[f+m]=h-L,s[f+y]=h+L,f+=c,u+=c}while(u<g);for(_=n[l+0],v=n[l+1],b=1;b<w;b++){var $,P;$=1-2*v*v,P=2*v*_,u=o+b,f=o+y-b;do{var I,x,ae,C,h,V,A,E,L,F;x=P*s[u+y]-$*s[f+y],I=$*s[u+y]+P*s[f+y],h=s[u+0]-I,C=s[u+0]+I,V=s[f+0]-x,ae=s[f+0]+x,x=P*s[u+m]-$*s[f+m],I=$*s[u+m]+P*s[f+m],L=s[u+p]-I,A=s[u+p]+I,F=s[f+p]-x,E=s[f+p]+x,x=v*A-_*F,I=_*A+v*F,s[u+p]=C-I,s[u+0]=C+I,s[f+m]=V-x,s[f+y]=V+x,x=_*E-v*L,I=v*E+_*L,s[f+p]=ae-I,s[f+0]=ae+I,s[u+m]=h-x,s[u+y]=h+x,f+=c,u+=c}while(u<g);$=_,_=$*n[l+0]-v*n[l+1],v=$*n[l+1]+v*n[l+0]}l+=2}while(c<a)}var i=[0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254];this.fft_short=function(s,o,a,l,c){for(var u=0;u<3;u++){var f=cr.BLKSIZE_s/2,g=65535&576/3*(u+1),v=cr.BLKSIZE_s/8-1;do{var _,b,y,p,m,w=i[v<<2]&255;_=e[w]*l[a][c+w+g],m=e[127-w]*l[a][c+w+g+128],b=_-m,_=_+m,y=e[w+64]*l[a][c+w+g+64],m=e[63-w]*l[a][c+w+g+192],p=y-m,y=y+m,f-=4,o[u][f+0]=_+y,o[u][f+2]=_-y,o[u][f+1]=b+p,o[u][f+3]=b-p,_=e[w+1]*l[a][c+w+g+1],m=e[126-w]*l[a][c+w+g+129],b=_-m,_=_+m,y=e[w+65]*l[a][c+w+g+65],m=e[62-w]*l[a][c+w+g+193],p=y-m,y=y+m,o[u][f+cr.BLKSIZE_s/2+0]=_+y,o[u][f+cr.BLKSIZE_s/2+2]=_-y,o[u][f+cr.BLKSIZE_s/2+1]=b+p,o[u][f+cr.BLKSIZE_s/2+3]=b-p}while(--v>=0);r(o[u],f,cr.BLKSIZE_s/2)}},this.fft_long=function(s,o,a,l,c){var u=cr.BLKSIZE/8-1,f=cr.BLKSIZE/2;do{var g,v,_,b,y,p=i[u]&255;g=t[p]*l[a][c+p],y=t[p+512]*l[a][c+p+512],v=g-y,g=g+y,_=t[p+256]*l[a][c+p+256],y=t[p+768]*l[a][c+p+768],b=_-y,_=_+y,f-=4,o[f+0]=g+_,o[f+2]=g-_,o[f+1]=v+b,o[f+3]=v-b,g=t[p+1]*l[a][c+p+1],y=t[p+513]*l[a][c+p+513],v=g-y,g=g+y,_=t[p+257]*l[a][c+p+257],y=t[p+769]*l[a][c+p+769],b=_-y,_=_+y,o[f+cr.BLKSIZE/2+0]=g+_,o[f+cr.BLKSIZE/2+2]=g-_,o[f+cr.BLKSIZE/2+1]=v+b,o[f+cr.BLKSIZE/2+3]=v-b}while(--u>=0);r(o,f,cr.BLKSIZE/2)},this.init_fft=function(s){for(var o=0;o<cr.BLKSIZE;o++)t[o]=.42-.5*Math.cos(2*Math.PI*(o+.5)/cr.BLKSIZE)+.08*Math.cos(4*Math.PI*(o+.5)/cr.BLKSIZE);for(var o=0;o<cr.BLKSIZE_s/2;o++)e[o]=.5*(1-Math.cos(2*Math.PI*(o+.5)/cr.BLKSIZE_s))}}var h3=d3,ds=jn,ea=ds.VbrMode,Y0=ds.Float,ta=ds.ShortBlock,ei=ds.Util,p3=ds.Arrays,_r=ds.new_float,Ei=ds.new_float_n,no=ds.new_int,Kt=ds.assert,m3=h3,Ke=xr();function _3(){var t=hl,e=new m3,n=2.302585092994046,r=2,i=16,s=2,o=16,a=.34,l=1/(14752*14752)/(Ke.BLKSIZE/2),c=.01,u=.8,f=.6,g=.3,v=3.5,_=21,b=.2302585093;function y(d,k){for(var D=0,U=0;U<Ke.BLKSIZE/2;++U)D+=d[U]*k.ATH.eql_w[U];return D*=l,D}function p(d,k,D,U,te,ee,se,ge,pe,Ae,Ce){var De=d.internal_flags;if(pe<2)e.fft_long(De,U[te],pe,Ae,Ce),e.fft_short(De,ee[se],pe,Ae,Ce);else if(pe==2){for(var tt=Ke.BLKSIZE-1;tt>=0;--tt){var mt=U[te+0][tt],We=U[te+1][tt];U[te+0][tt]=(mt+We)*ei.SQRT2*.5,U[te+1][tt]=(mt-We)*ei.SQRT2*.5}for(var dt=2;dt>=0;--dt)for(var tt=Ke.BLKSIZE_s-1;tt>=0;--tt){var mt=ee[se+0][dt][tt],We=ee[se+1][dt][tt];ee[se+0][dt][tt]=(mt+We)*ei.SQRT2*.5,ee[se+1][dt][tt]=(mt-We)*ei.SQRT2*.5}}k[0]=U[te+0][0],k[0]*=k[0];for(var tt=Ke.BLKSIZE/2-1;tt>=0;--tt){var Be=U[te+0][Ke.BLKSIZE/2-tt],$e=U[te+0][Ke.BLKSIZE/2+tt];k[Ke.BLKSIZE/2-tt]=(Be*Be+$e*$e)*.5}for(var dt=2;dt>=0;--dt){D[dt][0]=ee[se+0][dt][0],D[dt][0]*=D[dt][0];for(var tt=Ke.BLKSIZE_s/2-1;tt>=0;--tt){var Be=ee[se+0][dt][Ke.BLKSIZE_s/2-tt],$e=ee[se+0][dt][Ke.BLKSIZE_s/2+tt];D[dt][Ke.BLKSIZE_s/2-tt]=(Be*Be+$e*$e)*.5}}{for(var ft=0,tt=11;tt<Ke.HBLKSIZE;tt++)ft+=k[tt];De.tot_ener[pe]=ft}if(d.analysis){for(var tt=0;tt<Ke.HBLKSIZE;tt++)De.pinfo.energy[ge][pe][tt]=De.pinfo.energy_save[pe][tt],De.pinfo.energy_save[pe][tt]=k[tt];De.pinfo.pe[ge][pe]=De.pe[pe]}d.athaa_loudapprox==2&&pe<2&&(De.loudness_sq[ge][pe]=De.loudness_sq_save[pe],De.loudness_sq_save[pe]=y(k,De))}var m=8,w=23,C=15,h,A,L,$=[1,.79433,.63096,.63096,.63096,.63096,.63096,.25119,.11749];function P(){h=Math.pow(10,(m+1)/16),A=Math.pow(10,(w+1)/16),L=Math.pow(10,C/10)}var I=[3.3246*3.3246,3.23837*3.23837,3.15437*3.15437,3.00412*3.00412,2.86103*2.86103,2.65407*2.65407,2.46209*2.46209,2.284*2.284,2.11879*2.11879,1.96552*1.96552,1.82335*1.82335,1.69146*1.69146,1.56911*1.56911,1.46658*1.46658,1.37074*1.37074,1.31036*1.31036,1.25264*1.25264,1.20648*1.20648,1.16203*1.16203,1.12765*1.12765,1.09428*1.09428,1.0659*1.0659,1.03826*1.03826,1.01895*1.01895,1],x=[1.33352*1.33352,1.35879*1.35879,1.38454*1.38454,1.39497*1.39497,1.40548*1.40548,1.3537*1.3537,1.30382*1.30382,1.22321*1.22321,1.14758*1.14758,1],ae=[2.35364*2.35364,2.29259*2.29259,2.23313*2.23313,2.12675*2.12675,2.02545*2.02545,1.87894*1.87894,1.74303*1.74303,1.61695*1.61695,1.49999*1.49999,1.39148*1.39148,1.29083*1.29083,1.19746*1.19746,1.11084*1.11084,1.03826*1.03826];function V(d,k,D,U,te,ee){var se;if(k>d)if(k<d*A)se=k/d;else return d+k;else{if(d>=k*A)return d+k;se=d/k}if(d+=k,U+3<=6){if(se>=h)return d;var ge=0|ei.FAST_LOG10_X(se,16);return d*x[ge]}var ge=0|ei.FAST_LOG10_X(se,16);if(ee!=0?k=te.ATH.cb_s[D]*te.ATH.adjust:k=te.ATH.cb_l[D]*te.ATH.adjust,d<L*k){if(d>k){var pe,Ae;return pe=1,ge<=13&&(pe=ae[ge]),Ae=ei.FAST_LOG10_X(d/k,10/15),d*((I[ge]-pe)*Ae+pe)}return ge>13?d:d*ae[ge]}return d*I[ge]}var E=[1.33352*1.33352,1.35879*1.35879,1.38454*1.38454,1.39497*1.39497,1.40548*1.40548,1.3537*1.3537,1.30382*1.30382,1.22321*1.22321,1.14758*1.14758,1];function F(d,k,D){var U;if(d<0&&(d=0),k<0&&(k=0),d<=0)return k;if(k<=0)return d;if(k>d?U=k/d:U=d/k,-2<=D&&D<=2){if(U>=h)return d+k;var te=0|ei.FAST_LOG10_X(U,16);return(d+k)*E[te]}return U<A?d+k:(d<k&&(d=k),d)}function N(d,k){var D=d.internal_flags;if(D.channels_out>1){for(var U=0;U<Ke.SBMAX_l;U++){var te=D.thm[0].l[U],ee=D.thm[1].l[U];D.thm[0].l[U]+=ee*k,D.thm[1].l[U]+=te*k}for(var U=0;U<Ke.SBMAX_s;U++)for(var se=0;se<3;se++){var te=D.thm[0].s[U][se],ee=D.thm[1].s[U][se];D.thm[0].s[U][se]+=ee*k,D.thm[1].s[U][se]+=te*k}}}function Y(d){for(var k=0;k<Ke.SBMAX_l;k++)if(!(d.thm[0].l[k]>1.58*d.thm[1].l[k]||d.thm[1].l[k]>1.58*d.thm[0].l[k])){var D=d.mld_l[k]*d.en[3].l[k],U=Math.max(d.thm[2].l[k],Math.min(d.thm[3].l[k],D));D=d.mld_l[k]*d.en[2].l[k];var te=Math.max(d.thm[3].l[k],Math.min(d.thm[2].l[k],D));d.thm[2].l[k]=U,d.thm[3].l[k]=te}for(var k=0;k<Ke.SBMAX_s;k++)for(var ee=0;ee<3;ee++)if(!(d.thm[0].s[k][ee]>1.58*d.thm[1].s[k][ee]||d.thm[1].s[k][ee]>1.58*d.thm[0].s[k][ee])){var D=d.mld_s[k]*d.en[3].s[k][ee],U=Math.max(d.thm[2].s[k][ee],Math.min(d.thm[3].s[k][ee],D));D=d.mld_s[k]*d.en[2].s[k][ee];var te=Math.max(d.thm[3].s[k][ee],Math.min(d.thm[2].s[k][ee],D));d.thm[2].s[k][ee]=U,d.thm[3].s[k][ee]=te}}function K(d,k,D){var U=k,te=Math.pow(10,D);k*=2,U*=2;for(var ee=0;ee<Ke.SBMAX_l;ee++){var se,ge,pe,Ae;if(Ae=d.ATH.cb_l[d.bm_l[ee]]*te,se=Math.min(Math.max(d.thm[0].l[ee],Ae),Math.max(d.thm[1].l[ee],Ae)),ge=Math.max(d.thm[2].l[ee],Ae),pe=Math.max(d.thm[3].l[ee],Ae),se*k<ge+pe){var Ce=se*U/(ge+pe);ge*=Ce,pe*=Ce}d.thm[2].l[ee]=Math.min(ge,d.thm[2].l[ee]),d.thm[3].l[ee]=Math.min(pe,d.thm[3].l[ee])}te*=Ke.BLKSIZE_s/Ke.BLKSIZE;for(var ee=0;ee<Ke.SBMAX_s;ee++)for(var De=0;De<3;De++){var se,ge,pe,Ae;if(Ae=d.ATH.cb_s[d.bm_s[ee]]*te,se=Math.min(Math.max(d.thm[0].s[ee][De],Ae),Math.max(d.thm[1].s[ee][De],Ae)),ge=Math.max(d.thm[2].s[ee][De],Ae),pe=Math.max(d.thm[3].s[ee][De],Ae),se*k<ge+pe){var Ce=se*k/(ge+pe);ge*=Ce,pe*=Ce}d.thm[2].s[ee][De]=Math.min(d.thm[2].s[ee][De],ge),d.thm[3].s[ee][De]=Math.min(d.thm[3].s[ee][De],pe)}}function J(d,k,D,U,te){var ee,se,ge=0,pe=0;for(ee=se=0;ee<Ke.SBMAX_s;++se,++ee){for(var Ae=d.bo_s[ee],Ce=d.npart_s,De=Ae<Ce?Ae:Ce;se<De;)Kt(k[se]>=0),Kt(D[se]>=0),ge+=k[se],pe+=D[se],se++;if(d.en[U].s[ee][te]=ge,d.thm[U].s[ee][te]=pe,se>=Ce){++ee;break}Kt(k[se]>=0),Kt(D[se]>=0);{var tt=d.PSY.bo_s_weight[ee],mt=1-tt;ge=tt*k[se],pe=tt*D[se],d.en[U].s[ee][te]+=ge,d.thm[U].s[ee][te]+=pe,ge=mt*k[se],pe=mt*D[se]}}for(;ee<Ke.SBMAX_s;++ee)d.en[U].s[ee][te]=0,d.thm[U].s[ee][te]=0}function j(d,k,D,U){var te,ee,se=0,ge=0;for(te=ee=0;te<Ke.SBMAX_l;++ee,++te){for(var pe=d.bo_l[te],Ae=d.npart_l,Ce=pe<Ae?pe:Ae;ee<Ce;)Kt(k[ee]>=0),Kt(D[ee]>=0),se+=k[ee],ge+=D[ee],ee++;if(d.en[U].l[te]=se,d.thm[U].l[te]=ge,ee>=Ae){++te;break}Kt(k[ee]>=0),Kt(D[ee]>=0);{var De=d.PSY.bo_l_weight[te],tt=1-De;se=De*k[ee],ge=De*D[ee],d.en[U].l[te]+=se,d.thm[U].l[te]+=ge,se=tt*k[ee],ge=tt*D[ee]}}for(;te<Ke.SBMAX_l;++te)d.en[U].l[te]=0,d.thm[U].l[te]=0}function B(d,k,D,U,te,ee){var se=d.internal_flags,ge,pe;for(pe=ge=0;pe<se.npart_s;++pe){for(var Ae=0,Ce=se.numlines_s[pe],De=0;De<Ce;++De,++ge){var tt=k[ee][ge];Ae+=tt}D[pe]=Ae}for(Kt(pe==se.npart_s),ge=pe=0;pe<se.npart_s;pe++){var mt=se.s3ind_s[pe][0],We=se.s3_ss[ge++]*D[mt];for(++mt;mt<=se.s3ind_s[pe][1];)We+=se.s3_ss[ge]*D[mt],++ge,++mt;{var dt=s*se.nb_s1[te][pe];U[pe]=Math.min(We,dt)}if(se.blocktype_old[te&1]==Ke.SHORT_TYPE){var dt=o*se.nb_s2[te][pe],Be=U[pe];U[pe]=Math.min(dt,Be)}se.nb_s2[te][pe]=se.nb_s1[te][pe],se.nb_s1[te][pe]=We,Kt(U[pe]>=0)}for(;pe<=Ke.CBANDS;++pe)D[pe]=0,U[pe]=0}function M(d,k,D,U){var te=d.internal_flags;d.short_blocks==ta.short_block_coupled&&!(k[0]!=0&&k[1]!=0)&&(k[0]=k[1]=0);for(var ee=0;ee<te.channels_out;ee++)U[ee]=Ke.NORM_TYPE,d.short_blocks==ta.short_block_dispensed&&(k[ee]=1),d.short_blocks==ta.short_block_forced&&(k[ee]=0),k[ee]!=0?(Kt(te.blocktype_old[ee]!=Ke.START_TYPE),te.blocktype_old[ee]==Ke.SHORT_TYPE&&(U[ee]=Ke.STOP_TYPE)):(U[ee]=Ke.SHORT_TYPE,te.blocktype_old[ee]==Ke.NORM_TYPE&&(te.blocktype_old[ee]=Ke.START_TYPE),te.blocktype_old[ee]==Ke.STOP_TYPE&&(te.blocktype_old[ee]=Ke.SHORT_TYPE)),D[ee]=te.blocktype_old[ee],te.blocktype_old[ee]=U[ee]}function S(d,k,D){return D>=1?d:D<=0?k:k>0?Math.pow(d/k,D)*k:0}var R=[11.8,13.6,17.2,32,46.5,51.3,57.5,67.1,71.5,84.6,97.6,130];function X(d,k){for(var D=309.07,U=0;U<Ke.SBMAX_s-1;U++)for(var te=0;te<3;te++){var ee=d.thm.s[U][te];if(ee>0){var se=ee*k,ge=d.en.s[U][te];ge>se&&(ge>se*1e10?D+=R[U]*(10*n):D+=R[U]*ei.FAST_LOG10(ge/se))}}return D}var re=[6.8,5.8,5.8,6.4,6.5,9.9,12.1,14.4,15,18.9,21.6,26.9,34.2,40.2,46.8,56.5,60.7,73.9,85.7,93.4,126.1];function W(d,k){for(var D=281.0575,U=0;U<Ke.SBMAX_l-1;U++){var te=d.thm.l[U];if(te>0){var ee=te*k,se=d.en.l[U];se>ee&&(se>ee*1e10?D+=re[U]*(10*n):D+=re[U]*ei.FAST_LOG10(se/ee))}}return D}function z(d,k,D,U,te){var ee,se;for(ee=se=0;ee<d.npart_l;++ee){var ge=0,pe=0,Ae;for(Ae=0;Ae<d.numlines_l[ee];++Ae,++se){var Ce=k[se];ge+=Ce,pe<Ce&&(pe=Ce)}D[ee]=ge,U[ee]=pe,te[ee]=ge*d.rnumlines_l[ee],Kt(d.rnumlines_l[ee]>=0),Kt(D[ee]>=0),Kt(U[ee]>=0),Kt(te[ee]>=0)}}function le(d,k,D,U){var te=$.length-1,ee=0,se=D[ee]+D[ee+1];if(se>0){var ge=k[ee];ge<k[ee+1]&&(ge=k[ee+1]),Kt(d.numlines_l[ee]+d.numlines_l[ee+1]-1>0),se=20*(ge*2-se)/(se*(d.numlines_l[ee]+d.numlines_l[ee+1]-1));var pe=0|se;pe>te&&(pe=te),U[ee]=pe}else U[ee]=0;for(ee=1;ee<d.npart_l-1;ee++)if(se=D[ee-1]+D[ee]+D[ee+1],se>0){var ge=k[ee-1];ge<k[ee]&&(ge=k[ee]),ge<k[ee+1]&&(ge=k[ee+1]),Kt(d.numlines_l[ee-1]+d.numlines_l[ee]+d.numlines_l[ee+1]-1>0),se=20*(ge*3-se)/(se*(d.numlines_l[ee-1]+d.numlines_l[ee]+d.numlines_l[ee+1]-1));var pe=0|se;pe>te&&(pe=te),U[ee]=pe}else U[ee]=0;if(Kt(ee==d.npart_l-1),se=D[ee-1]+D[ee],se>0){var ge=k[ee-1];ge<k[ee]&&(ge=k[ee]),Kt(d.numlines_l[ee-1]+d.numlines_l[ee]-1>0),se=20*(ge*2-se)/(se*(d.numlines_l[ee-1]+d.numlines_l[ee]-1));var pe=0|se;pe>te&&(pe=te),U[ee]=pe}else U[ee]=0;Kt(ee==d.npart_l-1)}var Me=[-865163e-23*2,-.00851586*2,-674764e-23*2,.0209036*2,-336639e-22*2,-.0438162*2,-154175e-22*2,.0931738*2,-552212e-22*2,-.313819*2];this.L3psycho_anal_ns=function(d,k,D,U,te,ee,se,ge,pe,Ae){var Ce=d.internal_flags,De=Ei([2,Ke.BLKSIZE]),tt=Ei([2,3,Ke.BLKSIZE_s]),mt=_r(Ke.CBANDS+1),We=_r(Ke.CBANDS+1),dt=_r(Ke.CBANDS+2),Be=no(2),$e=no(2),ft,ze,at,Qe,vt,Rt,lt,St,ht=Ei([2,576]),xt,ln=no(Ke.CBANDS+2),qt=no(Ke.CBANDS+2);for(p3.fill(qt,0),ft=Ce.channels_out,d.mode==t.JOINT_STEREO&&(ft=4),d.VBR==ea.vbr_off?xt=Ce.ResvMax==0?0:Ce.ResvSize/Ce.ResvMax*.5:d.VBR==ea.vbr_rh||d.VBR==ea.vbr_mtrh||d.VBR==ea.vbr_mt?xt=.6:xt=1,ze=0;ze<Ce.channels_out;ze++){var Dt=k[ze],rn=D+576-350-_+192;for(Qe=0;Qe<576;Qe++){var In,Hn;for(In=Dt[rn+Qe+10],Hn=0,vt=0;vt<(_-1)/2-1;vt+=2)In+=Me[vt]*(Dt[rn+Qe+vt]+Dt[rn+Qe+_-vt]),Hn+=Me[vt+1]*(Dt[rn+Qe+vt+1]+Dt[rn+Qe+_-vt-1]);ht[ze][Qe]=In+Hn}te[U][ze].en.assign(Ce.en[ze]),te[U][ze].thm.assign(Ce.thm[ze]),ft>2&&(ee[U][ze].en.assign(Ce.en[ze+2]),ee[U][ze].thm.assign(Ce.thm[ze+2]))}for(ze=0;ze<ft;ze++){var xn,Xt,Ft=_r(12),Wt=[0,0,0,0],un=_r(12),Ye=1,ut,yr=_r(Ke.CBANDS),Xn=_r(Ke.CBANDS),Yt=[0,0,0,0],sr=_r(Ke.HBLKSIZE),Qn=Ei([3,Ke.HBLKSIZE_s]);for(Kt(Ce.npart_s<=Ke.CBANDS),Kt(Ce.npart_l<=Ke.CBANDS),Qe=0;Qe<3;Qe++)Ft[Qe]=Ce.nsPsy.last_en_subshort[ze][Qe+6],Kt(Ce.nsPsy.last_en_subshort[ze][Qe+4]>0),un[Qe]=Ft[Qe]/Ce.nsPsy.last_en_subshort[ze][Qe+4],Wt[0]+=Ft[Qe];if(ze==2)for(Qe=0;Qe<576;Qe++){var Un,vr;Un=ht[0][Qe],vr=ht[1][Qe],ht[0][Qe]=Un+vr,ht[1][Qe]=Un-vr}{var dr=ht[ze&1],hn=0;for(Qe=0;Qe<9;Qe++){for(var Gr=hn+64,pn=1;hn<Gr;hn++)pn<Math.abs(dr[hn])&&(pn=Math.abs(dr[hn]));Ce.nsPsy.last_en_subshort[ze][Qe]=Ft[Qe+3]=pn,Wt[1+Qe/3]+=pn,pn>Ft[Qe+3-2]?(Kt(Ft[Qe+3-2]>0),pn=pn/Ft[Qe+3-2]):Ft[Qe+3-2]>pn*10?pn=Ft[Qe+3-2]/(pn*10):pn=0,un[Qe+3]=pn}}if(d.analysis){var or=un[0];for(Qe=1;Qe<12;Qe++)or<un[Qe]&&(or=un[Qe]);Ce.pinfo.ers[U][ze]=Ce.pinfo.ers_save[ze],Ce.pinfo.ers_save[ze]=or}for(ut=ze==3?Ce.nsPsy.attackthre_s:Ce.nsPsy.attackthre,Qe=0;Qe<12;Qe++)Yt[Qe/3]==0&&un[Qe]>ut&&(Yt[Qe/3]=Qe%3+1);for(Qe=1;Qe<4;Qe++){var Or;Wt[Qe-1]>Wt[Qe]?(Kt(Wt[Qe]>0),Or=Wt[Qe-1]/Wt[Qe]):(Kt(Wt[Qe-1]>0),Or=Wt[Qe]/Wt[Qe-1]),Or<1.7&&(Yt[Qe]=0,Qe==1&&(Yt[0]=0))}for(Yt[0]!=0&&Ce.nsPsy.lastAttacks[ze]!=0&&(Yt[0]=0),(Ce.nsPsy.lastAttacks[ze]==3||Yt[0]+Yt[1]+Yt[2]+Yt[3]!=0)&&(Ye=0,Yt[1]!=0&&Yt[0]!=0&&(Yt[1]=0),Yt[2]!=0&&Yt[1]!=0&&(Yt[2]=0),Yt[3]!=0&&Yt[2]!=0&&(Yt[3]=0)),ze<2?$e[ze]=Ye:Ye==0&&($e[0]=$e[1]=0),pe[ze]=Ce.tot_ener[ze],Xt=tt,xn=De,p(d,sr,Qn,xn,ze&1,Xt,ze&1,U,ze,k,D),z(Ce,sr,mt,yr,Xn),le(Ce,yr,Xn,ln),St=0;St<3;St++){var oi,Wn;for(B(d,Qn,We,dt,ze,St),J(Ce,We,dt,ze,St),lt=0;lt<Ke.SBMAX_s;lt++){if(Wn=Ce.thm[ze].s[lt][St],Wn*=u,Yt[St]>=2||Yt[St+1]==1){var jr=St!=0?St-1:2,pn=S(Ce.thm[ze].s[lt][jr],Wn,f*xt);Wn=Math.min(Wn,pn)}if(Yt[St]==1){var jr=St!=0?St-1:2,pn=S(Ce.thm[ze].s[lt][jr],Wn,g*xt);Wn=Math.min(Wn,pn)}else if(St!=0&&Yt[St-1]==3||St==0&&Ce.nsPsy.lastAttacks[ze]==3){var jr=St!=2?St+1:0,pn=S(Ce.thm[ze].s[lt][jr],Wn,g*xt);Wn=Math.min(Wn,pn)}oi=Ft[St*3+3]+Ft[St*3+4]+Ft[St*3+5],Ft[St*3+5]*6<oi&&(Wn*=.5,Ft[St*3+4]*6<oi&&(Wn*=.5)),Ce.thm[ze].s[lt][St]=Wn}}for(Ce.nsPsy.lastAttacks[ze]=Yt[2],Rt=0,at=0;at<Ce.npart_l;at++){for(var Ve=Ce.s3ind[at][0],It=mt[Ve]*$[ln[Ve]],Bt=Ce.s3_ll[Rt++]*It;++Ve<=Ce.s3ind[at][1];)It=mt[Ve]*$[ln[Ve]],Bt=V(Bt,Ce.s3_ll[Rt++]*It,Ve,Ve-at,Ce,0);Bt*=.158489319246111,Ce.blocktype_old[ze&1]==Ke.SHORT_TYPE?dt[at]=Bt:dt[at]=S(Math.min(Bt,Math.min(r*Ce.nb_1[ze][at],i*Ce.nb_2[ze][at])),Bt,xt),Ce.nb_2[ze][at]=Ce.nb_1[ze][at],Ce.nb_1[ze][at]=Bt}for(;at<=Ke.CBANDS;++at)mt[at]=0,dt[at]=0;j(Ce,mt,dt,ze)}if((d.mode==t.STEREO||d.mode==t.JOINT_STEREO)&&d.interChRatio>0&&N(d,d.interChRatio),d.mode==t.JOINT_STEREO){var $t;Y(Ce),$t=d.msfix,Math.abs($t)>0&&K(Ce,$t,d.ATHlower*Ce.ATH.adjust)}for(M(d,$e,Ae,Be),ze=0;ze<ft;ze++){var tn,Tn=0,He,Et;ze>1?(tn=ge,Tn=-2,He=Ke.NORM_TYPE,(Ae[0]==Ke.SHORT_TYPE||Ae[1]==Ke.SHORT_TYPE)&&(He=Ke.SHORT_TYPE),Et=ee[U][ze-2]):(tn=se,Tn=0,He=Ae[ze],Et=te[U][ze]),He==Ke.SHORT_TYPE?tn[Tn+ze]=X(Et,Ce.masking_lower):tn[Tn+ze]=W(Et,Ce.masking_lower),d.analysis&&(Ce.pinfo.pe[U][ze]=tn[Tn+ze])}return 0};function Ee(d,k,D,U,te,ee,se,ge){var pe=d.internal_flags;if(U<2)e.fft_long(pe,se[ge],U,k,D);else if(U==2)for(var Ae=Ke.BLKSIZE-1;Ae>=0;--Ae){var Ce=se[ge+0][Ae],De=se[ge+1][Ae];se[ge+0][Ae]=(Ce+De)*ei.SQRT2*.5,se[ge+1][Ae]=(Ce-De)*ei.SQRT2*.5}ee[0]=se[ge+0][0],ee[0]*=ee[0];for(var Ae=Ke.BLKSIZE/2-1;Ae>=0;--Ae){var tt=se[ge+0][Ke.BLKSIZE/2-Ae],mt=se[ge+0][Ke.BLKSIZE/2+Ae];ee[Ke.BLKSIZE/2-Ae]=(tt*tt+mt*mt)*.5}{for(var We=0,Ae=11;Ae<Ke.HBLKSIZE;Ae++)We+=ee[Ae];pe.tot_ener[U]=We}if(d.analysis){for(var Ae=0;Ae<Ke.HBLKSIZE;Ae++)pe.pinfo.energy[te][U][Ae]=pe.pinfo.energy_save[U][Ae],pe.pinfo.energy_save[U][Ae]=ee[Ae];pe.pinfo.pe[te][U]=pe.pe[U]}}function ve(d,k,D,U,te,ee,se,ge){var pe=d.internal_flags;if(te==0&&U<2&&e.fft_short(pe,se[ge],U,k,D),U==2)for(var Ae=Ke.BLKSIZE_s-1;Ae>=0;--Ae){var Ce=se[ge+0][te][Ae],De=se[ge+1][te][Ae];se[ge+0][te][Ae]=(Ce+De)*ei.SQRT2*.5,se[ge+1][te][Ae]=(Ce-De)*ei.SQRT2*.5}ee[te][0]=se[ge+0][te][0],ee[te][0]*=ee[te][0];for(var Ae=Ke.BLKSIZE_s/2-1;Ae>=0;--Ae){var tt=se[ge+0][te][Ke.BLKSIZE_s/2-Ae],mt=se[ge+0][te][Ke.BLKSIZE_s/2+Ae];ee[te][Ke.BLKSIZE_s/2-Ae]=(tt*tt+mt*mt)*.5}}function ke(d,k,D,U){var te=d.internal_flags;d.athaa_loudapprox==2&&D<2&&(te.loudness_sq[k][D]=te.loudness_sq_save[D],te.loudness_sq_save[D]=y(U,te))}var Ne=[-865163e-23*2,-.00851586*2,-674764e-23*2,.0209036*2,-336639e-22*2,-.0438162*2,-154175e-22*2,.0931738*2,-552212e-22*2,-.313819*2];function Te(d,k,D,U,te,ee,se,ge,pe,Ae){for(var Ce=Ei([2,576]),De=d.internal_flags,tt=De.channels_out,mt=d.mode==t.JOINT_STEREO?4:tt,We=0;We<tt;We++){firbuf=k[We];for(var dt=D+576-350-_+192,Be=0;Be<576;Be++){var $e,ft;$e=firbuf[dt+Be+10],ft=0;for(var ze=0;ze<(_-1)/2-1;ze+=2)$e+=Ne[ze]*(firbuf[dt+Be+ze]+firbuf[dt+Be+_-ze]),ft+=Ne[ze+1]*(firbuf[dt+Be+ze+1]+firbuf[dt+Be+_-ze-1]);Ce[We][Be]=$e+ft}te[U][We].en.assign(De.en[We]),te[U][We].thm.assign(De.thm[We]),mt>2&&(ee[U][We].en.assign(De.en[We+2]),ee[U][We].thm.assign(De.thm[We+2]))}for(var We=0;We<mt;We++){var at=_r(12),Qe=_r(12),vt=[0,0,0,0],Rt=Ce[We&1],lt=0,St=We==3?De.nsPsy.attackthre_s:De.nsPsy.attackthre,ht=1;if(We==2)for(var Be=0,ze=576;ze>0;++Be,--ze){var xt=Ce[0][Be],ln=Ce[1][Be];Ce[0][Be]=xt+ln,Ce[1][Be]=xt-ln}for(var Be=0;Be<3;Be++)Qe[Be]=De.nsPsy.last_en_subshort[We][Be+6],Kt(De.nsPsy.last_en_subshort[We][Be+4]>0),at[Be]=Qe[Be]/De.nsPsy.last_en_subshort[We][Be+4],vt[0]+=Qe[Be];for(var Be=0;Be<9;Be++){for(var qt=lt+64,Dt=1;lt<qt;lt++)Dt<Math.abs(Rt[lt])&&(Dt=Math.abs(Rt[lt]));De.nsPsy.last_en_subshort[We][Be]=Qe[Be+3]=Dt,vt[1+Be/3]+=Dt,Dt>Qe[Be+3-2]?(Kt(Qe[Be+3-2]>0),Dt=Dt/Qe[Be+3-2]):Qe[Be+3-2]>Dt*10?Dt=Qe[Be+3-2]/(Dt*10):Dt=0,at[Be+3]=Dt}for(var Be=0;Be<3;++Be){var rn=Qe[Be*3+3]+Qe[Be*3+4]+Qe[Be*3+5],In=1;Qe[Be*3+5]*6<rn&&(In*=.5,Qe[Be*3+4]*6<rn&&(In*=.5)),ge[We][Be]=In}if(d.analysis){for(var Hn=at[0],Be=1;Be<12;Be++)Hn<at[Be]&&(Hn=at[Be]);De.pinfo.ers[U][We]=De.pinfo.ers_save[We],De.pinfo.ers_save[We]=Hn}for(var Be=0;Be<12;Be++)pe[We][Be/3]==0&&at[Be]>St&&(pe[We][Be/3]=Be%3+1);for(var Be=1;Be<4;Be++){var xn=vt[Be-1],Xt=vt[Be],Ft=Math.max(xn,Xt);Ft<4e4&&xn<1.7*Xt&&Xt<1.7*xn&&(Be==1&&pe[We][0]<=pe[We][Be]&&(pe[We][0]=0),pe[We][Be]=0)}pe[We][0]<=De.nsPsy.lastAttacks[We]&&(pe[We][0]=0),(De.nsPsy.lastAttacks[We]==3||pe[We][0]+pe[We][1]+pe[We][2]+pe[We][3]!=0)&&(ht=0,pe[We][1]!=0&&pe[We][0]!=0&&(pe[We][1]=0),pe[We][2]!=0&&pe[We][1]!=0&&(pe[We][2]=0),pe[We][3]!=0&&pe[We][2]!=0&&(pe[We][3]=0)),We<2?Ae[We]=ht:ht==0&&(Ae[0]=Ae[1]=0),se[We]=De.tot_ener[We]}}function Le(d,k,D){if(D==0)for(var U=0;U<d.npart_s;U++)d.nb_s2[k][U]=d.nb_s1[k][U],d.nb_s1[k][U]=0}function Fe(d,k){for(var D=0;D<d.npart_l;D++)d.nb_2[k][D]=d.nb_1[k][D],d.nb_1[k][D]=0}function Ze(d,k,D,U){var te=$.length-1,ee=0,se=D[ee]+D[ee+1];if(se>0){var ge=k[ee];ge<k[ee+1]&&(ge=k[ee+1]),Kt(d.numlines_s[ee]+d.numlines_s[ee+1]-1>0),se=20*(ge*2-se)/(se*(d.numlines_s[ee]+d.numlines_s[ee+1]-1));var pe=0|se;pe>te&&(pe=te),U[ee]=pe}else U[ee]=0;for(ee=1;ee<d.npart_s-1;ee++)if(se=D[ee-1]+D[ee]+D[ee+1],Kt(ee+1<d.npart_s),se>0){var ge=k[ee-1];ge<k[ee]&&(ge=k[ee]),ge<k[ee+1]&&(ge=k[ee+1]),Kt(d.numlines_s[ee-1]+d.numlines_s[ee]+d.numlines_s[ee+1]-1>0),se=20*(ge*3-se)/(se*(d.numlines_s[ee-1]+d.numlines_s[ee]+d.numlines_s[ee+1]-1));var pe=0|se;pe>te&&(pe=te),U[ee]=pe}else U[ee]=0;if(Kt(ee==d.npart_s-1),se=D[ee-1]+D[ee],se>0){var ge=k[ee-1];ge<k[ee]&&(ge=k[ee]),Kt(d.numlines_s[ee-1]+d.numlines_s[ee]-1>0),se=20*(ge*2-se)/(se*(d.numlines_s[ee-1]+d.numlines_s[ee]-1));var pe=0|se;pe>te&&(pe=te),U[ee]=pe}else U[ee]=0;Kt(ee==d.npart_s-1)}function O(d,k,D,U,te,ee){var se=d.internal_flags,ge=new float[Ke.CBANDS],pe=_r(Ke.CBANDS),Ae,Ce,De,tt=new int[Ke.CBANDS];for(De=Ce=0;De<se.npart_s;++De){var mt=0,We=0,dt=se.numlines_s[De];for(Ae=0;Ae<dt;++Ae,++Ce){var Be=k[ee][Ce];mt+=Be,We<Be&&(We=Be)}D[De]=mt,ge[De]=We,pe[De]=mt/dt,Kt(pe[De]>=0)}for(Kt(De==se.npart_s);De<Ke.CBANDS;++De)ge[De]=0,pe[De]=0;for(Ze(se,ge,pe,tt),Ce=De=0;De<se.npart_s;De++){var $e=se.s3ind_s[De][0],ft=se.s3ind_s[De][1],ze,at,Qe,vt,Rt;for(ze=tt[$e],at=1,vt=se.s3_ss[Ce]*D[$e]*$[tt[$e]],++Ce,++$e;$e<=ft;)ze+=tt[$e],at+=1,Qe=se.s3_ss[Ce]*D[$e]*$[tt[$e]],vt=F(vt,Qe,$e-De),++Ce,++$e;ze=(1+2*ze)/(2*at),Rt=$[ze]*.5,vt*=Rt,U[De]=vt,se.nb_s2[te][De]=se.nb_s1[te][De],se.nb_s1[te][De]=vt,Qe=ge[De],Qe*=se.minval_s[De],Qe*=Rt,U[De]>Qe&&(U[De]=Qe),se.masking_lower>1&&(U[De]*=se.masking_lower),U[De]>D[De]&&(U[De]=D[De]),se.masking_lower<1&&(U[De]*=se.masking_lower),Kt(U[De]>=0)}for(;De<Ke.CBANDS;++De)D[De]=0,U[De]=0}function H(d,k,D,U,te){var ee=_r(Ke.CBANDS),se=_r(Ke.CBANDS),ge=no(Ke.CBANDS+2),pe;z(d,k,D,ee,se),le(d,ee,se,ge);var Ae=0;for(pe=0;pe<d.npart_l;pe++){var Ce,De,tt,mt,We=d.s3ind[pe][0],dt=d.s3ind[pe][1],Be=0,$e=0;for(Be=ge[We],$e+=1,De=d.s3_ll[Ae]*D[We]*$[ge[We]],++Ae,++We;We<=dt;)Be+=ge[We],$e+=1,Ce=d.s3_ll[Ae]*D[We]*$[ge[We]],mt=F(De,Ce,We-pe),De=mt,++Ae,++We;if(Be=(1+2*Be)/(2*$e),tt=$[Be]*.5,De*=tt,d.blocktype_old[te&1]==Ke.SHORT_TYPE){var ft=r*d.nb_1[te][pe];ft>0?U[pe]=Math.min(De,ft):U[pe]=Math.min(De,D[pe]*g)}else{var ze=i*d.nb_2[te][pe],at=r*d.nb_1[te][pe],ft;ze<=0&&(ze=De),at<=0&&(at=De),d.blocktype_old[te&1]==Ke.NORM_TYPE?ft=Math.min(at,ze):ft=at,U[pe]=Math.min(De,ft)}d.nb_2[te][pe]=d.nb_1[te][pe],d.nb_1[te][pe]=De,Ce=ee[pe],Ce*=d.minval_l[pe],Ce*=tt,U[pe]>Ce&&(U[pe]=Ce),d.masking_lower>1&&(U[pe]*=d.masking_lower),U[pe]>D[pe]&&(U[pe]=D[pe]),d.masking_lower<1&&(U[pe]*=d.masking_lower),Kt(U[pe]>=0)}for(;pe<Ke.CBANDS;++pe)D[pe]=0,U[pe]=0}function Pe(d,k){var D=d.internal_flags;d.short_blocks==ta.short_block_coupled&&!(k[0]!=0&&k[1]!=0)&&(k[0]=k[1]=0);for(var U=0;U<D.channels_out;U++)d.short_blocks==ta.short_block_dispensed&&(k[U]=1),d.short_blocks==ta.short_block_forced&&(k[U]=0)}function xe(d,k,D){for(var U=d.internal_flags,te=0;te<U.channels_out;te++){var ee=Ke.NORM_TYPE;k[te]!=0?(Kt(U.blocktype_old[te]!=Ke.START_TYPE),U.blocktype_old[te]==Ke.SHORT_TYPE&&(ee=Ke.STOP_TYPE)):(ee=Ke.SHORT_TYPE,U.blocktype_old[te]==Ke.NORM_TYPE&&(U.blocktype_old[te]=Ke.START_TYPE),U.blocktype_old[te]==Ke.STOP_TYPE&&(U.blocktype_old[te]=Ke.SHORT_TYPE)),D[te]=U.blocktype_old[te],U.blocktype_old[te]=ee}}function qe(d,k,D,U,te,ee,se){for(var ge=ee*2,pe=ee>0?Math.pow(10,te):1,Ae,Ce,De=0;De<se;++De){var tt=d[2][De],mt=d[3][De],We=k[0][De],dt=k[1][De],Be=k[2][De],$e=k[3][De];if(We<=1.58*dt&&dt<=1.58*We){var ft=D[De]*mt,ze=D[De]*tt;Ce=Math.max(Be,Math.min($e,ft)),Ae=Math.max($e,Math.min(Be,ze))}else Ce=Be,Ae=$e;if(ee>0){var at,Qe,vt=U[De]*pe;if(at=Math.min(Math.max(We,vt),Math.max(dt,vt)),Be=Math.max(Ce,vt),$e=Math.max(Ae,vt),Qe=Be+$e,Qe>0&&at*ge<Qe){var Rt=at*ge/Qe;Be*=Rt,$e*=Rt}Ce=Math.min(Be,Ce),Ae=Math.min($e,Ae)}Ce>tt&&(Ce=tt),Ae>mt&&(Ae=mt),k[2][De]=Ce,k[3][De]=Ae}}this.L3psycho_anal_vbr=function(d,k,D,U,te,ee,se,ge,pe,Ae){var Ce=d.internal_flags,De,tt,mt=_r(Ke.HBLKSIZE),We=Ei([3,Ke.HBLKSIZE_s]),dt=Ei([2,Ke.BLKSIZE]),Be=Ei([2,3,Ke.BLKSIZE_s]),$e=Ei([4,Ke.CBANDS]),ft=Ei([4,Ke.CBANDS]),ze=Ei([4,3]),at=.6,Qe=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],vt=no(2),Rt=d.mode==t.JOINT_STEREO?4:Ce.channels_out;Te(d,k,D,U,te,ee,pe,ze,Qe,vt),Pe(d,vt);{for(var lt=0;lt<Rt;lt++){var St=lt&1;De=dt,Ee(d,k,D,lt,U,mt,De,St),ke(d,U,lt,mt),vt[St]!=0?H(Ce,mt,$e[lt],ft[lt],lt):Fe(Ce,lt)}vt[0]+vt[1]==2&&d.mode==t.JOINT_STEREO&&qe($e,ft,Ce.mld_cb_l,Ce.ATH.cb_l,d.ATHlower*Ce.ATH.adjust,d.msfix,Ce.npart_l);for(var lt=0;lt<Rt;lt++){var St=lt&1;vt[St]!=0&&j(Ce,$e[lt],ft[lt],lt)}}{for(var ht=0;ht<3;ht++){for(var lt=0;lt<Rt;++lt){var St=lt&1;vt[St]!=0?Le(Ce,lt,ht):(tt=Be,ve(d,k,D,lt,ht,We,tt,St),O(d,We,$e[lt],ft[lt],lt,ht))}vt[0]+vt[1]==0&&d.mode==t.JOINT_STEREO&&qe($e,ft,Ce.mld_cb_s,Ce.ATH.cb_s,d.ATHlower*Ce.ATH.adjust,d.msfix,Ce.npart_s);for(var lt=0;lt<Rt;++lt){var St=lt&1;vt[St]==0&&J(Ce,$e[lt],ft[lt],lt,ht)}}for(var lt=0;lt<Rt;lt++){var St=lt&1;if(vt[St]==0)for(var xt=0;xt<Ke.SBMAX_s;xt++){for(var ln=_r(3),ht=0;ht<3;ht++){var qt=Ce.thm[lt].s[xt][ht];if(qt*=u,Qe[lt][ht]>=2||Qe[lt][ht+1]==1){var Dt=ht!=0?ht-1:2,rn=S(Ce.thm[lt].s[xt][Dt],qt,f*at);qt=Math.min(qt,rn)}else if(Qe[lt][ht]==1){var Dt=ht!=0?ht-1:2,rn=S(Ce.thm[lt].s[xt][Dt],qt,g*at);qt=Math.min(qt,rn)}else if(ht!=0&&Qe[lt][ht-1]==3||ht==0&&Ce.nsPsy.lastAttacks[lt]==3){var Dt=ht!=2?ht+1:0,rn=S(Ce.thm[lt].s[xt][Dt],qt,g*at);qt=Math.min(qt,rn)}qt*=ze[lt][ht],ln[ht]=qt}for(var ht=0;ht<3;ht++)Ce.thm[lt].s[xt][ht]=ln[ht]}}}for(var lt=0;lt<Rt;lt++)Ce.nsPsy.lastAttacks[lt]=Qe[lt][2];xe(d,vt,Ae);for(var lt=0;lt<Rt;lt++){var In,Hn,xn,Xt;lt>1?(In=ge,Hn=-2,xn=Ke.NORM_TYPE,(Ae[0]==Ke.SHORT_TYPE||Ae[1]==Ke.SHORT_TYPE)&&(xn=Ke.SHORT_TYPE),Xt=ee[U][lt-2]):(In=se,Hn=0,xn=Ae[lt],Xt=te[U][lt]),xn==Ke.SHORT_TYPE?In[Hn+lt]=X(Xt,Ce.masking_lower):In[Hn+lt]=W(Xt,Ce.masking_lower),d.analysis&&(Ce.pinfo.pe[U][lt]=In[Hn+lt])}return 0};function nt(d,k){var D=d,U;return D>=0?U=-D*27:U=D*k,U<=-72?0:Math.exp(U*b)}function Oe(d){var k=0,D=0;{var U=0,te,ee;for(U=0;nt(U,d)>1e-20;U-=1);for(te=U,ee=0;Math.abs(ee-te)>1e-12;)U=(ee+te)/2,nt(U,d)>0?ee=U:te=U;k=te}{var U=0,te,ee;for(U=0;nt(U,d)>1e-20;U+=1);for(te=0,ee=U;Math.abs(ee-te)>1e-12;)U=(ee+te)/2,nt(U,d)>0?te=U:ee=U;D=ee}{var se=0,ge=1e3,pe;for(pe=0;pe<=ge;++pe){var U=k+pe*(D-k)/ge,Ae=nt(U,d);se+=Ae}{var Ce=(ge+1)/(se*(D-k));return Ce}}}function je(d){var k,D,U,te;return k=d,k>=0?k*=3:k*=1.5,k>=.5&&k<=2.5?(te=k-.5,D=8*(te*te-2*te)):D=0,k+=.474,U=15.811389+7.5*k-17.5*Math.sqrt(1+k*k),U<=-60?0:(k=Math.exp((D+U)*b),k/=.6609193,k)}function et(d){return d<0&&(d=0),d=d*.001,13*Math.atan(.76*d)+3.5*Math.atan(d*d/(7.5*7.5))}function rt(d,k,D,U,te,ee,se,ge,pe,Ae,Ce,De){var tt=_r(Ke.CBANDS+1),mt=ge/(De>15?2*576:2*192),We=no(Ke.HBLKSIZE),dt;ge/=pe;var Be=0,$e=0;for(dt=0;dt<Ke.CBANDS;dt++){var ft,ze;for(ft=et(ge*Be),tt[dt]=ge*Be,ze=Be;et(ge*ze)-ft<a&&ze<=pe/2;ze++);for(d[dt]=ze-Be,$e=dt+1;Be<ze;)Kt(Be<Ke.HBLKSIZE),We[Be++]=dt;if(Be>pe/2){Be=pe/2,++dt;break}}Kt(dt<Ke.CBANDS),tt[dt]=ge*Be;for(var at=0;at<De;at++){var Qe,vt,Rt,lt,St;Rt=Ae[at],lt=Ae[at+1],Qe=0|Math.floor(.5+Ce*(Rt-.5)),Qe<0&&(Qe=0),vt=0|Math.floor(.5+Ce*(lt-.5)),vt>pe/2&&(vt=pe/2),D[at]=(We[Qe]+We[vt])/2,k[at]=We[vt];var ht=mt*lt;se[at]=(ht-tt[k[at]])/(tt[k[at]+1]-tt[k[at]]),se[at]<0?se[at]=0:se[at]>1&&(se[at]=1),St=et(ge*Ae[at]*Ce),St=Math.min(St,15.5)/15.5,ee[at]=Math.pow(10,1.25*(1-Math.cos(Math.PI*St))-2.5)}Be=0;for(var xt=0;xt<$e;xt++){var ln=d[xt],ft,qt;ft=et(ge*Be),qt=et(ge*(Be+ln-1)),U[xt]=.5*(ft+qt),ft=et(ge*(Be-.5)),qt=et(ge*(Be+ln-.5)),te[xt]=qt-ft,Be+=ln}return $e}function Je(d,k,D,U,te,ee){var se=Ei([Ke.CBANDS,Ke.CBANDS]),ge,pe=0;if(ee)for(var Ae=0;Ae<k;Ae++)for(ge=0;ge<k;ge++){var Ce=je(D[Ae]-D[ge])*U[ge];se[Ae][ge]=Ce*te[Ae]}else for(ge=0;ge<k;ge++)for(var De=15+Math.min(21/D[ge],12),tt=Oe(De),Ae=0;Ae<k;Ae++){var Ce=tt*nt(D[Ae]-D[ge],De)*U[ge];se[Ae][ge]=Ce*te[Ae]}for(var Ae=0;Ae<k;Ae++){for(ge=0;ge<k&&!(se[Ae][ge]>0);ge++);for(d[Ae][0]=ge,ge=k-1;ge>0&&!(se[Ae][ge]>0);ge--);d[Ae][1]=ge,pe+=d[Ae][1]-d[Ae][0]+1}for(var mt=_r(pe),We=0,Ae=0;Ae<k;Ae++)for(ge=d[Ae][0];ge<=d[Ae][1];ge++)mt[We++]=se[Ae][ge];return mt}function G(d){var k=et(d);return k=Math.min(k,15.5)/15.5,Math.pow(10,1.25*(1-Math.cos(Math.PI*k))-2.5)}this.psymodel_init=function(d){var k=d.internal_flags,D,U=!0,te=13,ee=24,se=0,ge=0,pe=-8.25,Ae=-4.5,Ce=_r(Ke.CBANDS),De=_r(Ke.CBANDS),tt=_r(Ke.CBANDS),mt=d.out_samplerate;switch(d.experimentalZ){default:case 0:U=!0;break;case 1:U=!(d.VBR==ea.vbr_mtrh||d.VBR==ea.vbr_mt);break;case 2:U=!1;break;case 3:te=8,se=-1.75,ge=-.0125,pe=-8.25,Ae=-2.25;break}for(k.ms_ener_ratio_old=.25,k.blocktype_old[0]=k.blocktype_old[1]=Ke.NORM_TYPE,D=0;D<4;++D){for(var Be=0;Be<Ke.CBANDS;++Be)k.nb_1[D][Be]=1e20,k.nb_2[D][Be]=1e20,k.nb_s1[D][Be]=k.nb_s2[D][Be]=1;for(var We=0;We<Ke.SBMAX_l;We++)k.en[D].l[We]=1e20,k.thm[D].l[We]=1e20;for(var Be=0;Be<3;++Be){for(var We=0;We<Ke.SBMAX_s;We++)k.en[D].s[We][Be]=1e20,k.thm[D].s[We][Be]=1e20;k.nsPsy.lastAttacks[D]=0}for(var Be=0;Be<9;Be++)k.nsPsy.last_en_subshort[D][Be]=10}for(k.loudness_sq_save[0]=k.loudness_sq_save[1]=0,k.npart_l=rt(k.numlines_l,k.bo_l,k.bm_l,Ce,De,k.mld_l,k.PSY.bo_l_weight,mt,Ke.BLKSIZE,k.scalefac_band.l,Ke.BLKSIZE/(2*576),Ke.SBMAX_l),Kt(k.npart_l<Ke.CBANDS),D=0;D<k.npart_l;D++){var dt=se;Ce[D]>=te&&(dt=ge*(Ce[D]-te)/(ee-te)+se*(ee-Ce[D])/(ee-te)),tt[D]=Math.pow(10,dt/10),k.numlines_l[D]>0?k.rnumlines_l[D]=1/k.numlines_l[D]:k.rnumlines_l[D]=0}k.s3_ll=Je(k.s3ind,k.npart_l,Ce,De,tt,U);var Be=0;for(D=0;D<k.npart_l;D++){var $e;$e=Y0.MAX_VALUE;for(var ft=0;ft<k.numlines_l[D];ft++,Be++){var ze=mt*Be/(1e3*Ke.BLKSIZE),at;at=this.ATHformula(ze*1e3,d)-20,at=Math.pow(10,.1*at),at*=k.numlines_l[D],$e>at&&($e=at)}k.ATH.cb_l[D]=$e,$e=-20+Ce[D]*20/10,$e>6&&($e=100),$e<-15&&($e=-15),$e-=8,k.minval_l[D]=Math.pow(10,$e/10)*k.numlines_l[D]}for(k.npart_s=rt(k.numlines_s,k.bo_s,k.bm_s,Ce,De,k.mld_s,k.PSY.bo_s_weight,mt,Ke.BLKSIZE_s,k.scalefac_band.s,Ke.BLKSIZE_s/(2*192),Ke.SBMAX_s),Kt(k.npart_s<Ke.CBANDS),Be=0,D=0;D<k.npart_s;D++){var $e,dt=pe;Ce[D]>=te&&(dt=Ae*(Ce[D]-te)/(ee-te)+pe*(ee-Ce[D])/(ee-te)),tt[D]=Math.pow(10,dt/10),$e=Y0.MAX_VALUE;for(var ft=0;ft<k.numlines_s[D];ft++,Be++){var ze=mt*Be/(1e3*Ke.BLKSIZE_s),at;at=this.ATHformula(ze*1e3,d)-20,at=Math.pow(10,.1*at),at*=k.numlines_s[D],$e>at&&($e=at)}k.ATH.cb_s[D]=$e,$e=-7+Ce[D]*7/12,Ce[D]>12&&($e*=1+Math.log(1+$e)*3.1),Ce[D]<12&&($e*=1+Math.log(1-$e)*2.3),$e<-15&&($e=-15),$e-=8,k.minval_s[D]=Math.pow(10,$e/10)*k.numlines_s[D]}k.s3_ss=Je(k.s3ind_s,k.npart_s,Ce,De,tt,U),P(),e.init_fft(k),k.decay=Math.exp(-1*n/(c*mt/192));{var Qe;Qe=v,d.exp_nspsytune&2&&(Qe=1),Math.abs(d.msfix)>0&&(Qe=d.msfix),d.msfix=Qe;for(var vt=0;vt<k.npart_l;vt++)k.s3ind[vt][1]>k.npart_l-1&&(k.s3ind[vt][1]=k.npart_l-1)}var Rt=576*k.mode_gr/mt;if(k.ATH.decay=Math.pow(10,-12/10*Rt),k.ATH.adjust=.01,k.ATH.adjustLimit=1,Kt(k.bo_l[Ke.SBMAX_l-1]<=k.npart_l),Kt(k.bo_s[Ke.SBMAX_s-1]<=k.npart_s),d.ATHtype!=-1){var ze,lt=d.out_samplerate/Ke.BLKSIZE,St=0;for(ze=0,D=0;D<Ke.BLKSIZE/2;++D)ze+=lt,k.ATH.eql_w[D]=1/Math.pow(10,this.ATHformula(ze,d)/10),St+=k.ATH.eql_w[D];for(St=1/St,D=Ke.BLKSIZE/2;--D>=0;)k.ATH.eql_w[D]*=St}{for(var vt=Be=0;vt<k.npart_s;++vt)for(D=0;D<k.numlines_s[vt];++D)++Be;for(var vt=Be=0;vt<k.npart_l;++vt)for(D=0;D<k.numlines_l[vt];++D)++Be}for(Be=0,D=0;D<k.npart_l;D++){var ze=mt*(Be+k.numlines_l[D]/2)/(1*Ke.BLKSIZE);k.mld_cb_l[D]=G(ze),Be+=k.numlines_l[D]}for(;D<Ke.CBANDS;++D)k.mld_cb_l[D]=1;for(Be=0,D=0;D<k.npart_s;D++){var ze=mt*(Be+k.numlines_s[D]/2)/(1*Ke.BLKSIZE_s);k.mld_cb_s[D]=G(ze),Be+=k.numlines_s[D]}for(;D<Ke.CBANDS;++D)k.mld_cb_s[D]=1;return 0};function T(d,k){d<-.3&&(d=3410),d/=1e3,d=Math.max(.1,d);var D=3.64*Math.pow(d,-.8)-6.8*Math.exp(-.6*Math.pow(d-3.4,2))+6*Math.exp(-.15*Math.pow(d-8.7,2))+(.6+.04*k)*.001*Math.pow(d,4);return D}this.ATHformula=function(d,k){var D;switch(k.ATHtype){case 0:D=T(d,9);break;case 1:D=T(d,-1);break;case 2:D=T(d,0);break;case 3:D=T(d,1)+6;break;case 4:D=T(d,k.ATHcurve);break;default:D=T(d,0);break}return D}}var g3=_3,b3=hl;function w3(){this.class_id=0,this.num_samples=0,this.num_channels=0,this.in_samplerate=0,this.out_samplerate=0,this.scale=0,this.scale_left=0,this.scale_right=0,this.analysis=!1,this.bWriteVbrTag=!1,this.decode_only=!1,this.quality=0,this.mode=b3.STEREO,this.force_ms=!1,this.free_format=!1,this.findReplayGain=!1,this.decode_on_the_fly=!1,this.write_id3tag_automatic=!1,this.brate=0,this.compression_ratio=0,this.copyright=0,this.original=0,this.extension=0,this.emphasis=0,this.error_protection=0,this.strict_ISO=!1,this.disable_reservoir=!1,this.quant_comp=0,this.quant_comp_short=0,this.experimentalY=!1,this.experimentalZ=0,this.exp_nspsytune=0,this.preset=0,this.VBR=null,this.VBR_q_frac=0,this.VBR_q=0,this.VBR_mean_bitrate_kbps=0,this.VBR_min_bitrate_kbps=0,this.VBR_max_bitrate_kbps=0,this.VBR_hard_min=0,this.lowpassfreq=0,this.highpassfreq=0,this.lowpasswidth=0,this.highpasswidth=0,this.maskingadjust=0,this.maskingadjust_short=0,this.ATHonly=!1,this.ATHshort=!1,this.noATH=!1,this.ATHtype=0,this.ATHcurve=0,this.ATHlower=0,this.athaa_type=0,this.athaa_loudapprox=0,this.athaa_sensitivity=0,this.short_blocks=null,this.useTemporal=!1,this.interChRatio=0,this.msfix=0,this.tune=!1,this.tune_value_a=0,this.version=0,this.encoder_delay=0,this.encoder_padding=0,this.framesize=0,this.frameNum=0,this.lame_allocated_gfp=0,this.internal_flags=null}var y3=w3,v3=xr(),K0={};K0.SFBMAX=v3.SBMAX_s*3;var Iu=K0,q0=jn,E3=q0.new_float,ro=q0.new_int,T1=Iu;function S3(){this.xr=E3(576),this.l3_enc=ro(576),this.scalefac=ro(T1.SFBMAX),this.xrpow_max=0,this.part2_3_length=0,this.big_values=0,this.count1=0,this.global_gain=0,this.scalefac_compress=0,this.block_type=0,this.mixed_block_flag=0,this.table_select=ro(3),this.subblock_gain=ro(4),this.region0_count=0,this.region1_count=0,this.preflag=0,this.scalefac_scale=0,this.count1table_select=0,this.part2_length=0,this.sfb_lmax=0,this.sfb_smin=0,this.psy_lmax=0,this.sfbmax=0,this.psymax=0,this.sfbdivide=0,this.width=ro(T1.SFBMAX),this.window=ro(T1.SFBMAX),this.count1bits=0,this.sfb_partition_table=null,this.slen=ro(4),this.max_nonzero_coeff=0;var t=this;function e(r){return new Int32Array(r)}function n(r){return new Float32Array(r)}this.assign=function(r){t.xr=n(r.xr),t.l3_enc=e(r.l3_enc),t.scalefac=e(r.scalefac),t.xrpow_max=r.xrpow_max,t.part2_3_length=r.part2_3_length,t.big_values=r.big_values,t.count1=r.count1,t.global_gain=r.global_gain,t.scalefac_compress=r.scalefac_compress,t.block_type=r.block_type,t.mixed_block_flag=r.mixed_block_flag,t.table_select=e(r.table_select),t.subblock_gain=e(r.subblock_gain),t.region0_count=r.region0_count,t.region1_count=r.region1_count,t.preflag=r.preflag,t.scalefac_scale=r.scalefac_scale,t.count1table_select=r.count1table_select,t.part2_length=r.part2_length,t.sfb_lmax=r.sfb_lmax,t.sfb_smin=r.sfb_smin,t.psy_lmax=r.psy_lmax,t.sfbmax=r.sfbmax,t.psymax=r.psymax,t.sfbdivide=r.sfbdivide,t.width=e(r.width),t.window=e(r.window),t.count1bits=r.count1bits,t.sfb_partition_table=r.sfb_partition_table.slice(0),t.slen=e(r.slen),t.max_nonzero_coeff=r.max_nonzero_coeff}}var k1=S3,T3=jn,Z0=T3.new_int,k3=k1;function A3(){this.tt=[[null,null],[null,null]],this.main_data_begin=0,this.private_bits=0,this.resvDrain_pre=0,this.resvDrain_post=0,this.scfsi=[Z0(4),Z0(4)];for(var t=0;t<2;t++)for(var e=0;e<2;e++)this.tt[t][e]=new k3}var C3=A3,J0=jn,Ou=J0.System,Bu=J0.new_int,Du=xr();function M3(t,e,n,r){this.l=Bu(1+Du.SBMAX_l),this.s=Bu(1+Du.SBMAX_s),this.psfb21=Bu(1+Du.PSFB21),this.psfb12=Bu(1+Du.PSFB12);var i=this.l,s=this.s;arguments.length==4&&(this.arrL=arguments[0],this.arrS=arguments[1],this.arr21=arguments[2],this.arr12=arguments[3],Ou.arraycopy(this.arrL,0,i,0,Math.min(this.arrL.length,this.l.length)),Ou.arraycopy(this.arrS,0,s,0,Math.min(this.arrS.length,this.s.length)),Ou.arraycopy(this.arr21,0,this.psfb21,0,Math.min(this.arr21.length,this.psfb21.length)),Ou.arraycopy(this.arr12,0,this.psfb12,0,Math.min(this.arr12.length,this.psfb12.length)))}var Q0=M3,A1=jn,C1=A1.new_float,R3=A1.new_float_n,L3=A1.new_int,eh=xr();function P3(){this.last_en_subshort=R3([4,9]),this.lastAttacks=L3(4),this.pefirbuf=C1(19),this.longfact=C1(eh.SBMAX_l),this.shortfact=C1(eh.SBMAX_s),this.attackthre=0,this.attackthre_s=0}var I3=P3;function O3(){this.sum=0,this.seen=0,this.want=0,this.pos=0,this.size=0,this.bag=null,this.nVbrNumFrames=0,this.nBytesWritten=0,this.TotalFrameSize=0}var B3=O3,na=jn,D3=na.new_byte,F3=na.new_double,Si=na.new_float,io=na.new_float_n,Oi=na.new_int,Fu=na.new_int_n,$3=C3,N3=Q0,V3=I3,H3=B3,th=U0(),nr=xr(),x3=Iu;hs.MFSIZE=3*1152+nr.ENCDELAY-nr.MDCTDELAY,hs.MAX_HEADER_BUF=256,hs.MAX_BITS_PER_CHANNEL=4095,hs.MAX_BITS_PER_GRANULE=7680,hs.BPC=320;function hs(){var t=40;this.Class_ID=0,this.lame_encode_frame_init=0,this.iteration_init_init=0,this.fill_buffer_resample_init=0,this.mfbuf=io([2,hs.MFSIZE]),this.mode_gr=0,this.channels_in=0,this.channels_out=0,this.resample_ratio=0,this.mf_samples_to_encode=0,this.mf_size=0,this.VBR_min_bitrate=0,this.VBR_max_bitrate=0,this.bitrate_index=0,this.samplerate_index=0,this.mode_ext=0,this.lowpass1=0,this.lowpass2=0,this.highpass1=0,this.highpass2=0,this.noise_shaping=0,this.noise_shaping_amp=0,this.substep_shaping=0,this.psymodel=0,this.noise_shaping_stop=0,this.subblock_gain=0,this.use_best_huffman=0,this.full_outer_loop=0,this.l3_side=new $3,this.ms_ratio=Si(2),this.padding=0,this.frac_SpF=0,this.slot_lag=0,this.tag_spec=null,this.nMusicCRC=0,this.OldValue=Oi(2),this.CurrentStep=Oi(2),this.masking_lower=0,this.bv_scf=Oi(576),this.pseudohalf=Oi(x3.SFBMAX),this.sfb21_extra=!1,this.inbuf_old=new Array(2),this.blackfilt=new Array(2*hs.BPC+1),this.itime=F3(2),this.sideinfo_len=0,this.sb_sample=io([2,2,18,nr.SBLIMIT]),this.amp_filter=Si(32);function e(){this.write_timing=0,this.ptr=0,this.buf=D3(t)}this.header=new Array(hs.MAX_HEADER_BUF),this.h_ptr=0,this.w_ptr=0,this.ancillary_flag=0,this.ResvSize=0,this.ResvMax=0,this.scalefac_band=new N3,this.minval_l=Si(nr.CBANDS),this.minval_s=Si(nr.CBANDS),this.nb_1=io([4,nr.CBANDS]),this.nb_2=io([4,nr.CBANDS]),this.nb_s1=io([4,nr.CBANDS]),this.nb_s2=io([4,nr.CBANDS]),this.s3_ss=null,this.s3_ll=null,this.decay=0,this.thm=new Array(4),this.en=new Array(4),this.tot_ener=Si(4),this.loudness_sq=io([2,2]),this.loudness_sq_save=Si(2),this.mld_l=Si(nr.SBMAX_l),this.mld_s=Si(nr.SBMAX_s),this.bm_l=Oi(nr.SBMAX_l),this.bo_l=Oi(nr.SBMAX_l),this.bm_s=Oi(nr.SBMAX_s),this.bo_s=Oi(nr.SBMAX_s),this.npart_l=0,this.npart_s=0,this.s3ind=Fu([nr.CBANDS,2]),this.s3ind_s=Fu([nr.CBANDS,2]),this.numlines_s=Oi(nr.CBANDS),this.numlines_l=Oi(nr.CBANDS),this.rnumlines_l=Si(nr.CBANDS),this.mld_cb_l=Si(nr.CBANDS),this.mld_cb_s=Si(nr.CBANDS),this.numlines_s_num1=0,this.numlines_l_num1=0,this.pe=Si(4),this.ms_ratio_s_old=0,this.ms_ratio_l_old=0,this.ms_ener_ratio_old=0,this.blocktype_old=Oi(2),this.nsPsy=new V3,this.VBR_seek_table=new H3,this.ATH=null,this.PSY=null,this.nogap_total=0,this.nogap_current=0,this.decode_on_the_fly=!0,this.findReplayGain=!0,this.findPeakSample=!0,this.PeakSample=0,this.RadioGain=0,this.AudiophileGain=0,this.rgdata=null,this.noclipGainChange=0,this.noclipScale=0,this.bitrate_stereoMode_Hist=Fu([16,5]),this.bitrate_blockType_Hist=Fu([16,6]),this.pinfo=null,this.hip=null,this.in_buffer_nsamples=0,this.in_buffer_0=null,this.in_buffer_1=null,this.iteration_loop=null;for(var n=0;n<this.en.length;n++)this.en[n]=new th;for(var n=0;n<this.thm.length;n++)this.thm[n]=new th;for(var n=0;n<this.header.length;n++)this.header[n]=new e}var $u=hs,U3=jn,so=U3.new_float,oo=xr();function W3(){this.useAdjust=0,this.aaSensitivityP=0,this.adjust=0,this.adjustLimit=0,this.decay=0,this.floor=0,this.l=so(oo.SBMAX_l),this.s=so(oo.SBMAX_s),this.psfb21=so(oo.PSFB21),this.psfb12=so(oo.PSFB12),this.cb_l=so(oo.CBANDS),this.cb_s=so(oo.CBANDS),this.eql_w=so(oo.BLKSIZE/2)}var G3=W3,nh=jn,ti=nh.System,rh=nh.Arrays;rr.STEPS_per_dB=100,rr.MAX_dB=120,rr.GAIN_NOT_ENOUGH_SAMPLES=-24601,rr.GAIN_ANALYSIS_ERROR=0,rr.GAIN_ANALYSIS_OK=1,rr.INIT_GAIN_ANALYSIS_ERROR=0,rr.INIT_GAIN_ANALYSIS_OK=1,rr.YULE_ORDER=10,rr.MAX_ORDER=rr.YULE_ORDER,rr.MAX_SAMP_FREQ=48e3,rr.RMS_WINDOW_TIME_NUMERATOR=1,rr.RMS_WINDOW_TIME_DENOMINATOR=20,rr.MAX_SAMPLES_PER_WINDOW=rr.MAX_SAMP_FREQ*rr.RMS_WINDOW_TIME_NUMERATOR/rr.RMS_WINDOW_TIME_DENOMINATOR+1;function rr(){var t=64.82,e=.95,n=rr.RMS_WINDOW_TIME_NUMERATOR,r=rr.RMS_WINDOW_TIME_DENOMINATOR,i=[[.038575994352,-3.84664617118067,-.02160367184185,7.81501653005538,-.00123395316851,-11.34170355132042,-9291677959e-14,13.05504219327545,-.01655260341619,-12.28759895145294,.02161526843274,9.4829380631979,-.02074045215285,-5.87257861775999,.00594298065125,2.75465861874613,.00306428023191,-.86984376593551,.00012025322027,.13919314567432,.00288463683916],[.0541865640643,-3.47845948550071,-.02911007808948,6.36317777566148,-.00848709379851,-8.54751527471874,-.00851165645469,9.4769360780128,-.00834990904936,-8.81498681370155,.02245293253339,6.85401540936998,-.02596338512915,-4.39470996079559,.01624864962975,2.19611684890774,-.00240879051584,-.75104302451432,.00674613682247,.13149317958808,-.00187763777362],[.15457299681924,-2.37898834973084,-.09331049056315,2.84868151156327,-.06247880153653,-2.64577170229825,.02163541888798,2.23697657451713,-.05588393329856,-1.67148153367602,.04781476674921,1.00595954808547,.00222312597743,-.45953458054983,.03174092540049,.16378164858596,-.01390589421898,-.05032077717131,.00651420667831,.0234789740702,-.00881362733839],[.30296907319327,-1.61273165137247,-.22613988682123,1.0797749225997,-.08587323730772,-.2565625775407,.03282930172664,-.1627671912044,-.00915702933434,-.22638893773906,-.02364141202522,.39120800788284,-.00584456039913,-.22138138954925,.06276101321749,.04500235387352,-828086748e-14,.02005851806501,.00205861885564,.00302439095741,-.02950134983287],[.33642304856132,-1.49858979367799,-.2557224142557,.87350271418188,-.11828570177555,.12205022308084,.11921148675203,-.80774944671438,-.07834489609479,.47854794562326,-.0046997791438,-.12453458140019,-.0058950022444,-.04067510197014,.05724228140351,.08333755284107,.00832043980773,-.04237348025746,-.0163538138454,.02977207319925,-.0176017656815],[.4491525660845,-.62820619233671,-.14351757464547,.29661783706366,-.22784394429749,-.372563729424,-.01419140100551,.00213767857124,.04078262797139,-.42029820170918,-.12398163381748,.22199650564824,.04097565135648,.00613424350682,.10478503600251,.06747620744683,-.01863887810927,.05784820375801,-.03193428438915,.03222754072173,.00541907748707],[.56619470757641,-1.04800335126349,-.75464456939302,.29156311971249,.1624213774223,-.26806001042947,.16744243493672,.00819999645858,-.18901604199609,.45054734505008,.3093178284183,-.33032403314006,-.27562961986224,.0673936833311,.00647310677246,-.04784254229033,.08647503780351,.01639907836189,-.0378898455484,.01807364323573,-.00588215443421],[.58100494960553,-.51035327095184,-.53174909058578,-.31863563325245,-.14289799034253,-.20256413484477,.17520704835522,.1472815413433,.02377945217615,.38952639978999,.15558449135573,-.23313271880868,-.25344790059353,-.05246019024463,.01628462406333,-.02505961724053,.06920467763959,.02442357316099,-.03721611395801,.01818801111503,-.00749618797172],[.53648789255105,-.2504987195602,-.42163034350696,-.43193942311114,-.00275953611929,-.03424681017675,.04267842219415,-.04678328784242,-.10214864179676,.26408300200955,.14590772289388,.15113130533216,-.02459864859345,-.17556493366449,-.11202315195388,-.18823009262115,-.04060034127,.05477720428674,.0478866554818,.0470440968812,-.02217936801134]],s=[[.98621192462708,-1.97223372919527,-1.97242384925416,.97261396931306,.98621192462708],[.98500175787242,-1.96977855582618,-1.97000351574484,.9702284756635,.98500175787242],[.97938932735214,-1.95835380975398,-1.95877865470428,.95920349965459,.97938932735214],[.97531843204928,-1.95002759149878,-1.95063686409857,.95124613669835,.97531843204928],[.97316523498161,-1.94561023566527,-1.94633046996323,.94705070426118,.97316523498161],[.96454515552826,-1.92783286977036,-1.92909031105652,.93034775234268,.96454515552826],[.96009142950541,-1.91858953033784,-1.92018285901082,.92177618768381,.96009142950541],[.95856916599601,-1.9154210807478,-1.91713833199203,.91885558323625,.95856916599601],[.94597685600279,-1.88903307939452,-1.89195371200558,.89487434461664,.94597685600279]];function o(f,g,v,_,b,y){for(;b--!=0;)v[_]=1e-10+f[g+0]*y[0]-v[_-1]*y[1]+f[g-1]*y[2]-v[_-2]*y[3]+f[g-2]*y[4]-v[_-3]*y[5]+f[g-3]*y[6]-v[_-4]*y[7]+f[g-4]*y[8]-v[_-5]*y[9]+f[g-5]*y[10]-v[_-6]*y[11]+f[g-6]*y[12]-v[_-7]*y[13]+f[g-7]*y[14]-v[_-8]*y[15]+f[g-8]*y[16]-v[_-9]*y[17]+f[g-9]*y[18]-v[_-10]*y[19]+f[g-10]*y[20],++_,++g}function a(f,g,v,_,b,y){for(;b--!=0;)v[_]=f[g+0]*y[0]-v[_-1]*y[1]+f[g-1]*y[2]-v[_-2]*y[3]+f[g-2]*y[4],++_,++g}function l(f,g){for(var v=0;v<MAX_ORDER;v++)f.linprebuf[v]=f.lstepbuf[v]=f.loutbuf[v]=f.rinprebuf[v]=f.rstepbuf[v]=f.routbuf[v]=0;switch(0|g){case 48e3:f.reqindex=0;break;case 44100:f.reqindex=1;break;case 32e3:f.reqindex=2;break;case 24e3:f.reqindex=3;break;case 22050:f.reqindex=4;break;case 16e3:f.reqindex=5;break;case 12e3:f.reqindex=6;break;case 11025:f.reqindex=7;break;case 8e3:f.reqindex=8;break;default:return INIT_GAIN_ANALYSIS_ERROR}return f.sampleWindow=0|(g*n+r-1)/r,f.lsum=0,f.rsum=0,f.totsamp=0,rh.ill(f.A,0),INIT_GAIN_ANALYSIS_OK}this.InitGainAnalysis=function(f,g){return l(f,g)!=INIT_GAIN_ANALYSIS_OK?INIT_GAIN_ANALYSIS_ERROR:(f.linpre=MAX_ORDER,f.rinpre=MAX_ORDER,f.lstep=MAX_ORDER,f.rstep=MAX_ORDER,f.lout=MAX_ORDER,f.rout=MAX_ORDER,rh.fill(f.B,0),INIT_GAIN_ANALYSIS_OK)};function c(f){return f*f}this.AnalyzeSamples=function(f,g,v,_,b,y,p){var m,w,C,h,A,L,$;if(y==0)return GAIN_ANALYSIS_OK;switch($=0,A=y,p){case 1:_=g,b=v;break;case 2:break;default:return GAIN_ANALYSIS_ERROR}for(y<MAX_ORDER?(ti.arraycopy(g,v,f.linprebuf,MAX_ORDER,y),ti.arraycopy(_,b,f.rinprebuf,MAX_ORDER,y)):(ti.arraycopy(g,v,f.linprebuf,MAX_ORDER,MAX_ORDER),ti.arraycopy(_,b,f.rinprebuf,MAX_ORDER,MAX_ORDER));A>0;){L=A>f.sampleWindow-f.totsamp?f.sampleWindow-f.totsamp:A,$<MAX_ORDER?(m=f.linpre+$,w=f.linprebuf,C=f.rinpre+$,h=f.rinprebuf,L>MAX_ORDER-$&&(L=MAX_ORDER-$)):(m=v+$,w=g,C=b+$,h=_),o(w,m,f.lstepbuf,f.lstep+f.totsamp,L,i[f.reqindex]),o(h,C,f.rstepbuf,f.rstep+f.totsamp,L,i[f.reqindex]),a(f.lstepbuf,f.lstep+f.totsamp,f.loutbuf,f.lout+f.totsamp,L,s[f.reqindex]),a(f.rstepbuf,f.rstep+f.totsamp,f.routbuf,f.rout+f.totsamp,L,s[f.reqindex]),m=f.lout+f.totsamp,w=f.loutbuf,C=f.rout+f.totsamp,h=f.routbuf;for(var P=L%8;P--!=0;)f.lsum+=c(w[m++]),f.rsum+=c(h[C++]);for(P=L/8;P--!=0;)f.lsum+=c(w[m+0])+c(w[m+1])+c(w[m+2])+c(w[m+3])+c(w[m+4])+c(w[m+5])+c(w[m+6])+c(w[m+7]),m+=8,f.rsum+=c(h[C+0])+c(h[C+1])+c(h[C+2])+c(h[C+3])+c(h[C+4])+c(h[C+5])+c(h[C+6])+c(h[C+7]),C+=8;if(A-=L,$+=L,f.totsamp+=L,f.totsamp==f.sampleWindow){var I=rr.STEPS_per_dB*10*Math.log10((f.lsum+f.rsum)/f.totsamp*.5+1e-37),x=I<=0?0:0|I;x>=f.A.length&&(x=f.A.length-1),f.A[x]++,f.lsum=f.rsum=0,ti.arraycopy(f.loutbuf,f.totsamp,f.loutbuf,0,MAX_ORDER),ti.arraycopy(f.routbuf,f.totsamp,f.routbuf,0,MAX_ORDER),ti.arraycopy(f.lstepbuf,f.totsamp,f.lstepbuf,0,MAX_ORDER),ti.arraycopy(f.rstepbuf,f.totsamp,f.rstepbuf,0,MAX_ORDER),f.totsamp=0}if(f.totsamp>f.sampleWindow)return GAIN_ANALYSIS_ERROR}return y<MAX_ORDER?(ti.arraycopy(f.linprebuf,y,f.linprebuf,0,MAX_ORDER-y),ti.arraycopy(f.rinprebuf,y,f.rinprebuf,0,MAX_ORDER-y),ti.arraycopy(g,v,f.linprebuf,MAX_ORDER-y,y),ti.arraycopy(_,b,f.rinprebuf,MAX_ORDER-y,y)):(ti.arraycopy(g,v+y-MAX_ORDER,f.linprebuf,0,MAX_ORDER),ti.arraycopy(_,b+y-MAX_ORDER,f.rinprebuf,0,MAX_ORDER)),GAIN_ANALYSIS_OK};function u(f,g){var v,_=0;for(v=0;v<g;v++)_+=f[v];if(_==0)return GAIN_NOT_ENOUGH_SAMPLES;var b=0|Math.ceil(_*(1-e));for(v=g;v-- >0&&!((b-=f[v])<=0););return t-v/rr.STEPS_per_dB}this.GetTitleGain=function(f){for(var g=u(f.A,f.A.length),v=0;v<f.A.length;v++)f.B[v]+=f.A[v],f.A[v]=0;for(var v=0;v<MAX_ORDER;v++)f.linprebuf[v]=f.lstepbuf[v]=f.loutbuf[v]=f.rinprebuf[v]=f.rstepbuf[v]=f.routbuf[v]=0;return f.totsamp=0,f.lsum=f.rsum=0,g}}var ih=rr,sh=jn,ra=sh.new_float,oh=sh.new_int,ni=ih;function j3(){this.linprebuf=ra(ni.MAX_ORDER*2),this.linpre=0,this.lstepbuf=ra(ni.MAX_SAMPLES_PER_WINDOW+ni.MAX_ORDER),this.lstep=0,this.loutbuf=ra(ni.MAX_SAMPLES_PER_WINDOW+ni.MAX_ORDER),this.lout=0,this.rinprebuf=ra(ni.MAX_ORDER*2),this.rinpre=0,this.rstepbuf=ra(ni.MAX_SAMPLES_PER_WINDOW+ni.MAX_ORDER),this.rstep=0,this.routbuf=ra(ni.MAX_SAMPLES_PER_WINDOW+ni.MAX_ORDER),this.rout=0,this.sampleWindow=0,this.totsamp=0,this.lsum=0,this.rsum=0,this.freqindex=0,this.first=0,this.A=oh(0|ni.STEPS_per_dB*ni.MAX_dB),this.B=oh(0|ni.STEPS_per_dB*ni.MAX_dB)}var z3=j3;function X3(t){this.bits=t}var ah=X3,M1=jn,lh=M1.new_float,Y3=M1.new_int,uh=M1.assert,K3=ah,ch=xr(),q3=Iu,Z3=$u;function J3(t){var e=t;this.quantize=e,this.iteration_loop=function(n,r,i,s){var o=n.internal_flags,a=lh(q3.SFBMAX),l=lh(576),c=Y3(2),u=0,f,g=o.l3_side,v=new K3(u);this.quantize.rv.ResvFrameBegin(n,v),u=v.bits;for(var _=0;_<o.mode_gr;_++){f=this.quantize.qupvt.on_pe(n,r,c,u,_,_),o.mode_ext==ch.MPG_MD_MS_LR&&(this.quantize.ms_convert(o.l3_side,_),this.quantize.qupvt.reduce_side(c,i[_],u,f));for(var b=0;b<o.channels_out;b++){var y,p,m=g.tt[_][b];m.block_type!=ch.SHORT_TYPE?(y=0,p=o.PSY.mask_adjust-y):(y=0,p=o.PSY.mask_adjust_short-y),o.masking_lower=Math.pow(10,p*.1),this.quantize.init_outer_loop(o,m),this.quantize.init_xrpow(o,m,l)&&(this.quantize.qupvt.calc_xmin(n,s[_][b],m,a),this.quantize.outer_loop(n,m,a,l,b,c[b])),this.quantize.iteration_finish_one(o,_,b),uh(m.part2_3_length<=Z3.MAX_BITS_PER_CHANNEL),uh(m.part2_3_length<=c[b])}}this.quantize.rv.ResvFrameEnd(o,u)}}var Q3=J3;function gn(t,e,n,r){this.xlen=t,this.linmax=e,this.table=n,this.hlen=r}var ct={};ct.t1HB=[1,1,1,0],ct.t2HB=[1,2,1,3,1,1,3,2,0],ct.t3HB=[3,2,1,1,1,1,3,2,0],ct.t5HB=[1,2,6,5,3,1,4,4,7,5,7,1,6,1,1,0],ct.t6HB=[7,3,5,1,6,2,3,2,5,4,4,1,3,3,2,0],ct.t7HB=[1,2,10,19,16,10,3,3,7,10,5,3,11,4,13,17,8,4,12,11,18,15,11,2,7,6,9,14,3,1,6,4,5,3,2,0],ct.t8HB=[3,4,6,18,12,5,5,1,2,16,9,3,7,3,5,14,7,3,19,17,15,13,10,4,13,5,8,11,5,1,12,4,4,1,1,0],ct.t9HB=[7,5,9,14,15,7,6,4,5,5,6,7,7,6,8,8,8,5,15,6,9,10,5,1,11,7,9,6,4,1,14,4,6,2,6,0],ct.t10HB=[1,2,10,23,35,30,12,17,3,3,8,12,18,21,12,7,11,9,15,21,32,40,19,6,14,13,22,34,46,23,18,7,20,19,33,47,27,22,9,3,31,22,41,26,21,20,5,3,14,13,10,11,16,6,5,1,9,8,7,8,4,4,2,0],ct.t11HB=[3,4,10,24,34,33,21,15,5,3,4,10,32,17,11,10,11,7,13,18,30,31,20,5,25,11,19,59,27,18,12,5,35,33,31,58,30,16,7,5,28,26,32,19,17,15,8,14,14,12,9,13,14,9,4,1,11,4,6,6,6,3,2,0],ct.t12HB=[9,6,16,33,41,39,38,26,7,5,6,9,23,16,26,11,17,7,11,14,21,30,10,7,17,10,15,12,18,28,14,5,32,13,22,19,18,16,9,5,40,17,31,29,17,13,4,2,27,12,11,15,10,7,4,1,27,12,8,12,6,3,1,0],ct.t13HB=[1,5,14,21,34,51,46,71,42,52,68,52,67,44,43,19,3,4,12,19,31,26,44,33,31,24,32,24,31,35,22,14,15,13,23,36,59,49,77,65,29,40,30,40,27,33,42,16,22,20,37,61,56,79,73,64,43,76,56,37,26,31,25,14,35,16,60,57,97,75,114,91,54,73,55,41,48,53,23,24,58,27,50,96,76,70,93,84,77,58,79,29,74,49,41,17,47,45,78,74,115,94,90,79,69,83,71,50,59,38,36,15,72,34,56,95,92,85,91,90,86,73,77,65,51,44,43,42,43,20,30,44,55,78,72,87,78,61,46,54,37,30,20,16,53,25,41,37,44,59,54,81,66,76,57,54,37,18,39,11,35,33,31,57,42,82,72,80,47,58,55,21,22,26,38,22,53,25,23,38,70,60,51,36,55,26,34,23,27,14,9,7,34,32,28,39,49,75,30,52,48,40,52,28,18,17,9,5,45,21,34,64,56,50,49,45,31,19,12,15,10,7,6,3,48,23,20,39,36,35,53,21,16,23,13,10,6,1,4,2,16,15,17,27,25,20,29,11,17,12,16,8,1,1,0,1],ct.t15HB=[7,12,18,53,47,76,124,108,89,123,108,119,107,81,122,63,13,5,16,27,46,36,61,51,42,70,52,83,65,41,59,36,19,17,15,24,41,34,59,48,40,64,50,78,62,80,56,33,29,28,25,43,39,63,55,93,76,59,93,72,54,75,50,29,52,22,42,40,67,57,95,79,72,57,89,69,49,66,46,27,77,37,35,66,58,52,91,74,62,48,79,63,90,62,40,38,125,32,60,56,50,92,78,65,55,87,71,51,73,51,70,30,109,53,49,94,88,75,66,122,91,73,56,42,64,44,21,25,90,43,41,77,73,63,56,92,77,66,47,67,48,53,36,20,71,34,67,60,58,49,88,76,67,106,71,54,38,39,23,15,109,53,51,47,90,82,58,57,48,72,57,41,23,27,62,9,86,42,40,37,70,64,52,43,70,55,42,25,29,18,11,11,118,68,30,55,50,46,74,65,49,39,24,16,22,13,14,7,91,44,39,38,34,63,52,45,31,52,28,19,14,8,9,3,123,60,58,53,47,43,32,22,37,24,17,12,15,10,2,1,71,37,34,30,28,20,17,26,21,16,10,6,8,6,2,0],ct.t16HB=[1,5,14,44,74,63,110,93,172,149,138,242,225,195,376,17,3,4,12,20,35,62,53,47,83,75,68,119,201,107,207,9,15,13,23,38,67,58,103,90,161,72,127,117,110,209,206,16,45,21,39,69,64,114,99,87,158,140,252,212,199,387,365,26,75,36,68,65,115,101,179,164,155,264,246,226,395,382,362,9,66,30,59,56,102,185,173,265,142,253,232,400,388,378,445,16,111,54,52,100,184,178,160,133,257,244,228,217,385,366,715,10,98,48,91,88,165,157,148,261,248,407,397,372,380,889,884,8,85,84,81,159,156,143,260,249,427,401,392,383,727,713,708,7,154,76,73,141,131,256,245,426,406,394,384,735,359,710,352,11,139,129,67,125,247,233,229,219,393,743,737,720,885,882,439,4,243,120,118,115,227,223,396,746,742,736,721,712,706,223,436,6,202,224,222,218,216,389,386,381,364,888,443,707,440,437,1728,4,747,211,210,208,370,379,734,723,714,1735,883,877,876,3459,865,2,377,369,102,187,726,722,358,711,709,866,1734,871,3458,870,434,0,12,10,7,11,10,17,11,9,13,12,10,7,5,3,1,3],ct.t24HB=[15,13,46,80,146,262,248,434,426,669,653,649,621,517,1032,88,14,12,21,38,71,130,122,216,209,198,327,345,319,297,279,42,47,22,41,74,68,128,120,221,207,194,182,340,315,295,541,18,81,39,75,70,134,125,116,220,204,190,178,325,311,293,271,16,147,72,69,135,127,118,112,210,200,188,352,323,306,285,540,14,263,66,129,126,119,114,214,202,192,180,341,317,301,281,262,12,249,123,121,117,113,215,206,195,185,347,330,308,291,272,520,10,435,115,111,109,211,203,196,187,353,332,313,298,283,531,381,17,427,212,208,205,201,193,186,177,169,320,303,286,268,514,377,16,335,199,197,191,189,181,174,333,321,305,289,275,521,379,371,11,668,184,183,179,175,344,331,314,304,290,277,530,383,373,366,10,652,346,171,168,164,318,309,299,287,276,263,513,375,368,362,6,648,322,316,312,307,302,292,284,269,261,512,376,370,364,359,4,620,300,296,294,288,282,273,266,515,380,374,369,365,361,357,2,1033,280,278,274,267,264,259,382,378,372,367,363,360,358,356,0,43,20,19,17,15,13,11,9,7,6,4,7,5,3,1,3],ct.t32HB=[1,10,8,20,12,20,16,32,14,12,24,0,28,16,24,16],ct.t33HB=[15,28,26,48,22,40,36,64,14,24,20,32,12,16,8,0],ct.t1l=[1,4,3,5],ct.t2l=[1,4,7,4,5,7,6,7,8],ct.t3l=[2,3,7,4,4,7,6,7,8],ct.t5l=[1,4,7,8,4,5,8,9,7,8,9,10,8,8,9,10],ct.t6l=[3,4,6,8,4,4,6,7,5,6,7,8,7,7,8,9],ct.t7l=[1,4,7,9,9,10,4,6,8,9,9,10,7,7,9,10,10,11,8,9,10,11,11,11,8,9,10,11,11,12,9,10,11,12,12,12],ct.t8l=[2,4,7,9,9,10,4,4,6,10,10,10,7,6,8,10,10,11,9,10,10,11,11,12,9,9,10,11,12,12,10,10,11,11,13,13],ct.t9l=[3,4,6,7,9,10,4,5,6,7,8,10,5,6,7,8,9,10,7,7,8,9,9,10,8,8,9,9,10,11,9,9,10,10,11,11],ct.t10l=[1,4,7,9,10,10,10,11,4,6,8,9,10,11,10,10,7,8,9,10,11,12,11,11,8,9,10,11,12,12,11,12,9,10,11,12,12,12,12,12,10,11,12,12,13,13,12,13,9,10,11,12,12,12,13,13,10,10,11,12,12,13,13,13],ct.t11l=[2,4,6,8,9,10,9,10,4,5,6,8,10,10,9,10,6,7,8,9,10,11,10,10,8,8,9,11,10,12,10,11,9,10,10,11,11,12,11,12,9,10,11,12,12,13,12,13,9,9,9,10,11,12,12,12,9,9,10,11,12,12,12,12],ct.t12l=[4,4,6,8,9,10,10,10,4,5,6,7,9,9,10,10,6,6,7,8,9,10,9,10,7,7,8,8,9,10,10,10,8,8,9,9,10,10,10,11,9,9,10,10,10,11,10,11,9,9,9,10,10,11,11,12,10,10,10,11,11,11,11,12],ct.t13l=[1,5,7,8,9,10,10,11,10,11,12,12,13,13,14,14,4,6,8,9,10,10,11,11,11,11,12,12,13,14,14,14,7,8,9,10,11,11,12,12,11,12,12,13,13,14,15,15,8,9,10,11,11,12,12,12,12,13,13,13,13,14,15,15,9,9,11,11,12,12,13,13,12,13,13,14,14,15,15,16,10,10,11,12,12,12,13,13,13,13,14,13,15,15,16,16,10,11,12,12,13,13,13,13,13,14,14,14,15,15,16,16,11,11,12,13,13,13,14,14,14,14,15,15,15,16,18,18,10,10,11,12,12,13,13,14,14,14,14,15,15,16,17,17,11,11,12,12,13,13,13,15,14,15,15,16,16,16,18,17,11,12,12,13,13,14,14,15,14,15,16,15,16,17,18,19,12,12,12,13,14,14,14,14,15,15,15,16,17,17,17,18,12,13,13,14,14,15,14,15,16,16,17,17,17,18,18,18,13,13,14,15,15,15,16,16,16,16,16,17,18,17,18,18,14,14,14,15,15,15,17,16,16,19,17,17,17,19,18,18,13,14,15,16,16,16,17,16,17,17,18,18,21,20,21,18],ct.t15l=[3,5,6,8,8,9,10,10,10,11,11,12,12,12,13,14,5,5,7,8,9,9,10,10,10,11,11,12,12,12,13,13,6,7,7,8,9,9,10,10,10,11,11,12,12,13,13,13,7,8,8,9,9,10,10,11,11,11,12,12,12,13,13,13,8,8,9,9,10,10,11,11,11,11,12,12,12,13,13,13,9,9,9,10,10,10,11,11,11,11,12,12,13,13,13,14,10,9,10,10,10,11,11,11,11,12,12,12,13,13,14,14,10,10,10,11,11,11,11,12,12,12,12,12,13,13,13,14,10,10,10,11,11,11,11,12,12,12,12,13,13,14,14,14,10,10,11,11,11,11,12,12,12,13,13,13,13,14,14,14,11,11,11,11,12,12,12,12,12,13,13,13,13,14,15,14,11,11,11,11,12,12,12,12,13,13,13,13,14,14,14,15,12,12,11,12,12,12,13,13,13,13,13,13,14,14,15,15,12,12,12,12,12,13,13,13,13,14,14,14,14,14,15,15,13,13,13,13,13,13,13,13,14,14,14,14,15,15,14,15,13,13,13,13,13,13,13,14,14,14,14,14,15,15,15,15],ct.t16_5l=[1,5,7,9,10,10,11,11,12,12,12,13,13,13,14,11,4,6,8,9,10,11,11,11,12,12,12,13,14,13,14,11,7,8,9,10,11,11,12,12,13,12,13,13,13,14,14,12,9,9,10,11,11,12,12,12,13,13,14,14,14,15,15,13,10,10,11,11,12,12,13,13,13,14,14,14,15,15,15,12,10,10,11,11,12,13,13,14,13,14,14,15,15,15,16,13,11,11,11,12,13,13,13,13,14,14,14,14,15,15,16,13,11,11,12,12,13,13,13,14,14,15,15,15,15,17,17,13,11,12,12,13,13,13,14,14,15,15,15,15,16,16,16,13,12,12,12,13,13,14,14,15,15,15,15,16,15,16,15,14,12,13,12,13,14,14,14,14,15,16,16,16,17,17,16,13,13,13,13,13,14,14,15,16,16,16,16,16,16,15,16,14,13,14,14,14,14,15,15,15,15,17,16,16,16,16,18,14,15,14,14,14,15,15,16,16,16,18,17,17,17,19,17,14,14,15,13,14,16,16,15,16,16,17,18,17,19,17,16,14,11,11,11,12,12,13,13,13,14,14,14,14,14,14,14,12],ct.t16l=[1,5,7,9,10,10,11,11,12,12,12,13,13,13,14,10,4,6,8,9,10,11,11,11,12,12,12,13,14,13,14,10,7,8,9,10,11,11,12,12,13,12,13,13,13,14,14,11,9,9,10,11,11,12,12,12,13,13,14,14,14,15,15,12,10,10,11,11,12,12,13,13,13,14,14,14,15,15,15,11,10,10,11,11,12,13,13,14,13,14,14,15,15,15,16,12,11,11,11,12,13,13,13,13,14,14,14,14,15,15,16,12,11,11,12,12,13,13,13,14,14,15,15,15,15,17,17,12,11,12,12,13,13,13,14,14,15,15,15,15,16,16,16,12,12,12,12,13,13,14,14,15,15,15,15,16,15,16,15,13,12,13,12,13,14,14,14,14,15,16,16,16,17,17,16,12,13,13,13,13,14,14,15,16,16,16,16,16,16,15,16,13,13,14,14,14,14,15,15,15,15,17,16,16,16,16,18,13,15,14,14,14,15,15,16,16,16,18,17,17,17,19,17,13,14,15,13,14,16,16,15,16,16,17,18,17,19,17,16,13,10,10,10,11,11,12,12,12,13,13,13,13,13,13,13,10],ct.t24l=[4,5,7,8,9,10,10,11,11,12,12,12,12,12,13,10,5,6,7,8,9,10,10,11,11,11,12,12,12,12,12,10,7,7,8,9,9,10,10,11,11,11,11,12,12,12,13,9,8,8,9,9,10,10,10,11,11,11,11,12,12,12,12,9,9,9,9,10,10,10,10,11,11,11,12,12,12,12,13,9,10,9,10,10,10,10,11,11,11,11,12,12,12,12,12,9,10,10,10,10,10,11,11,11,11,12,12,12,12,12,13,9,11,10,10,10,11,11,11,11,12,12,12,12,12,13,13,10,11,11,11,11,11,11,11,11,11,12,12,12,12,13,13,10,11,11,11,11,11,11,11,12,12,12,12,12,13,13,13,10,12,11,11,11,11,12,12,12,12,12,12,13,13,13,13,10,12,12,11,11,11,12,12,12,12,12,12,13,13,13,13,10,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,10,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,10,13,12,12,12,12,12,12,13,13,13,13,13,13,13,13,10,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,6],ct.t32l=[1,5,5,7,5,8,7,9,5,7,7,9,7,9,9,10],ct.t33l=[4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8],ct.ht=[new gn(0,0,null,null),new gn(2,0,ct.t1HB,ct.t1l),new gn(3,0,ct.t2HB,ct.t2l),new gn(3,0,ct.t3HB,ct.t3l),new gn(0,0,null,null),new gn(4,0,ct.t5HB,ct.t5l),new gn(4,0,ct.t6HB,ct.t6l),new gn(6,0,ct.t7HB,ct.t7l),new gn(6,0,ct.t8HB,ct.t8l),new gn(6,0,ct.t9HB,ct.t9l),new gn(8,0,ct.t10HB,ct.t10l),new gn(8,0,ct.t11HB,ct.t11l),new gn(8,0,ct.t12HB,ct.t12l),new gn(16,0,ct.t13HB,ct.t13l),new gn(0,0,null,ct.t16_5l),new gn(16,0,ct.t15HB,ct.t15l),new gn(1,1,ct.t16HB,ct.t16l),new gn(2,3,ct.t16HB,ct.t16l),new gn(3,7,ct.t16HB,ct.t16l),new gn(4,15,ct.t16HB,ct.t16l),new gn(6,63,ct.t16HB,ct.t16l),new gn(8,255,ct.t16HB,ct.t16l),new gn(10,1023,ct.t16HB,ct.t16l),new gn(13,8191,ct.t16HB,ct.t16l),new gn(4,15,ct.t24HB,ct.t24l),new gn(5,31,ct.t24HB,ct.t24l),new gn(6,63,ct.t24HB,ct.t24l),new gn(7,127,ct.t24HB,ct.t24l),new gn(8,255,ct.t24HB,ct.t24l),new gn(9,511,ct.t24HB,ct.t24l),new gn(11,2047,ct.t24HB,ct.t24l),new gn(13,8191,ct.t24HB,ct.t24l),new gn(0,0,ct.t32HB,ct.t32l),new gn(0,0,ct.t33HB,ct.t33l)],ct.largetbl=[65540,327685,458759,589832,655369,655370,720906,720907,786443,786444,786444,851980,851980,851980,917517,655370,262149,393222,524295,589832,655369,720906,720906,720907,786443,786443,786444,851980,917516,851980,917516,655370,458759,524295,589832,655369,720905,720906,786442,786443,851979,786443,851979,851980,851980,917516,917517,720905,589832,589832,655369,720905,720906,786442,786442,786443,851979,851979,917515,917516,917516,983052,983052,786441,655369,655369,720905,720906,786442,786442,851978,851979,851979,917515,917516,917516,983052,983052,983053,720905,655370,655369,720906,720906,786442,851978,851979,917515,851979,917515,917516,983052,983052,983052,1048588,786441,720906,720906,720906,786442,851978,851979,851979,851979,917515,917516,917516,917516,983052,983052,1048589,786441,720907,720906,786442,786442,851979,851979,851979,917515,917516,983052,983052,983052,983052,1114125,1114125,786442,720907,786443,786443,851979,851979,851979,917515,917515,983051,983052,983052,983052,1048588,1048589,1048589,786442,786443,786443,786443,851979,851979,917515,917515,983052,983052,983052,983052,1048588,983053,1048589,983053,851978,786444,851979,786443,851979,917515,917516,917516,917516,983052,1048588,1048588,1048589,1114125,1114125,1048589,786442,851980,851980,851979,851979,917515,917516,983052,1048588,1048588,1048588,1048588,1048589,1048589,983053,1048589,851978,851980,917516,917516,917516,917516,983052,983052,983052,983052,1114124,1048589,1048589,1048589,1048589,1179661,851978,983052,917516,917516,917516,983052,983052,1048588,1048588,1048589,1179661,1114125,1114125,1114125,1245197,1114125,851978,917517,983052,851980,917516,1048588,1048588,983052,1048589,1048589,1114125,1179661,1114125,1245197,1114125,1048589,851978,655369,655369,655369,720905,720905,786441,786441,786441,851977,851977,851977,851978,851978,851978,851978,655366],ct.table23=[65538,262147,458759,262148,327684,458759,393222,458759,524296],ct.table56=[65539,262148,458758,524296,262148,327684,524294,589831,458757,524294,589831,655368,524295,524295,589832,655369],ct.bitrate_table=[[0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,-1],[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],[0,8,16,24,32,40,48,56,64,-1,-1,-1,-1,-1,-1,-1]],ct.samplerate_table=[[22050,24e3,16e3,-1],[44100,48e3,32e3,-1],[11025,12e3,8e3,-1]],ct.scfsi_band=[0,6,11,16,21];var R1=ct,L1,fh;function dh(){if(fh)return L1;fh=1;var t=Q0,e=jn,n=e.VbrMode,r=e.Float,i=e.Util,s=e.new_float,o=e.new_int,a=e.assert,l=xr(),c=ah,u=$u;f.Q_MAX=257,f.Q_MAX2=116,f.LARGE_BITS=1e5,f.IXMAX_VAL=8206;function f(){var g=O1(),v=null,_=null,b=null;this.setModules=function(F,N,Y){v=F,_=N,b=Y};function y(F){return a(0<=F+f.Q_MAX2&&F<f.Q_MAX),$[F+f.Q_MAX2]}this.IPOW20=function(F){return a(0<=F&&F<f.Q_MAX),P[F]};var p=2220446049250313e-31,m=f.IXMAX_VAL,w=m+2,C=f.Q_MAX,h=f.Q_MAX2;f.LARGE_BITS;var A=100;this.nr_of_sfb_block=[[[6,5,5,5],[9,9,9,9],[6,9,9,9]],[[6,5,7,3],[9,9,12,6],[6,9,12,6]],[[11,10,0,0],[18,18,0,0],[15,18,0,0]],[[7,7,7,0],[12,12,12,0],[6,15,12,0]],[[6,6,6,3],[12,9,9,6],[6,12,9,6]],[[8,8,5,0],[15,12,9,0],[6,18,9,0]]];var L=[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,2,0];this.pretab=L,this.sfBandIndex=[new t([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0,4,8,12,18,24,32,42,56,74,100,132,174,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,6,12,18,24,30,36,44,54,66,80,96,114,136,162,194,232,278,332,394,464,540,576],[0,4,8,12,18,26,36,48,62,80,104,136,180,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0,4,8,12,18,26,36,48,62,80,104,134,174,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,4,8,12,16,20,24,30,36,44,52,62,74,90,110,134,162,196,238,288,342,418,576],[0,4,8,12,16,22,30,40,52,66,84,106,136,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,4,8,12,16,20,24,30,36,42,50,60,72,88,106,128,156,190,230,276,330,384,576],[0,4,8,12,16,22,28,38,50,64,80,100,126,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,4,8,12,16,20,24,30,36,44,54,66,82,102,126,156,194,240,296,364,448,550,576],[0,4,8,12,16,22,30,42,58,78,104,138,180,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0/3,12/3,24/3,36/3,54/3,78/3,108/3,144/3,186/3,240/3,312/3,402/3,522/3,576/3],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0/3,12/3,24/3,36/3,54/3,78/3,108/3,144/3,186/3,240/3,312/3,402/3,522/3,576/3],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),new t([0,12,24,36,48,60,72,88,108,132,160,192,232,280,336,400,476,566,568,570,572,574,576],[0/3,24/3,48/3,72/3,108/3,156/3,216/3,288/3,372/3,480/3,486/3,492/3,498/3,576/3],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0])];var $=s(C+h+1),P=s(C),I=s(w),x=s(w);this.adj43=x;function ae(F,N){var Y=b.ATHformula(N,F);return Y-=A,Y=Math.pow(10,Y/10+F.ATHlower),Y}function V(F){for(var N=F.internal_flags.ATH.l,Y=F.internal_flags.ATH.psfb21,K=F.internal_flags.ATH.s,J=F.internal_flags.ATH.psfb12,j=F.internal_flags,B=F.out_samplerate,M=0;M<l.SBMAX_l;M++){var S=j.scalefac_band.l[M],R=j.scalefac_band.l[M+1];N[M]=r.MAX_VALUE;for(var X=S;X<R;X++){var re=X*B/1152,W=ae(F,re);N[M]=Math.min(N[M],W)}}for(var M=0;M<l.PSFB21;M++){var S=j.scalefac_band.psfb21[M],R=j.scalefac_band.psfb21[M+1];Y[M]=r.MAX_VALUE;for(var X=S;X<R;X++){var re=X*B/1152,W=ae(F,re);Y[M]=Math.min(Y[M],W)}}for(var M=0;M<l.SBMAX_s;M++){var S=j.scalefac_band.s[M],R=j.scalefac_band.s[M+1];K[M]=r.MAX_VALUE;for(var X=S;X<R;X++){var re=X*B/384,W=ae(F,re);K[M]=Math.min(K[M],W)}K[M]*=j.scalefac_band.s[M+1]-j.scalefac_band.s[M]}for(var M=0;M<l.PSFB12;M++){var S=j.scalefac_band.psfb12[M],R=j.scalefac_band.psfb12[M+1];J[M]=r.MAX_VALUE;for(var X=S;X<R;X++){var re=X*B/384,W=ae(F,re);J[M]=Math.min(J[M],W)}J[M]*=j.scalefac_band.s[13]-j.scalefac_band.s[12]}if(F.noATH){for(var M=0;M<l.SBMAX_l;M++)N[M]=1e-20;for(var M=0;M<l.PSFB21;M++)Y[M]=1e-20;for(var M=0;M<l.SBMAX_s;M++)K[M]=1e-20;for(var M=0;M<l.PSFB12;M++)J[M]=1e-20}j.ATH.floor=10*Math.log10(ae(F,-1))}this.iteration_init=function(F){var N=F.internal_flags,Y=N.l3_side,K;if(N.iteration_init_init==0){for(N.iteration_init_init=1,Y.main_data_begin=0,V(F),I[0]=0,K=1;K<w;K++)I[K]=Math.pow(K,4/3);for(K=0;K<w-1;K++)x[K]=K+1-Math.pow(.5*(I[K]+I[K+1]),.75);for(x[K]=.5,K=0;K<C;K++)P[K]=Math.pow(2,(K-210)*-.1875);for(K=0;K<=C+h;K++)$[K]=Math.pow(2,(K-210-h)*.25);v.huffman_init(N);{var J,j,B,M;for(K=F.exp_nspsytune>>2&63,K>=32&&(K-=64),J=Math.pow(10,K/4/10),K=F.exp_nspsytune>>8&63,K>=32&&(K-=64),j=Math.pow(10,K/4/10),K=F.exp_nspsytune>>14&63,K>=32&&(K-=64),B=Math.pow(10,K/4/10),K=F.exp_nspsytune>>20&63,K>=32&&(K-=64),M=B*Math.pow(10,K/4/10),K=0;K<l.SBMAX_l;K++){var S;K<=6?S=J:K<=13?S=j:K<=20?S=B:S=M,N.nsPsy.longfact[K]=S}for(K=0;K<l.SBMAX_s;K++){var S;K<=5?S=J:K<=10?S=j:K<=11?S=B:S=M,N.nsPsy.shortfact[K]=S}}}},this.on_pe=function(F,N,Y,K,J,j){var B=F.internal_flags,M=0,S,R=o(2),X,re=new c(M),W=_.ResvMaxBits(F,K,re,j);M=re.bits;var z=M+W;for(z>u.MAX_BITS_PER_GRANULE&&(z=u.MAX_BITS_PER_GRANULE),S=0,X=0;X<B.channels_out;++X)Y[X]=Math.min(u.MAX_BITS_PER_CHANNEL,M/B.channels_out),R[X]=0|Y[X]*N[J][X]/700-Y[X],R[X]>K*3/4&&(R[X]=K*3/4),R[X]<0&&(R[X]=0),R[X]+Y[X]>u.MAX_BITS_PER_CHANNEL&&(R[X]=Math.max(0,u.MAX_BITS_PER_CHANNEL-Y[X])),S+=R[X];if(S>W)for(X=0;X<B.channels_out;++X)R[X]=W*R[X]/S;for(X=0;X<B.channels_out;++X)Y[X]+=R[X],W-=R[X];for(S=0,X=0;X<B.channels_out;++X)S+=Y[X];if(S>u.MAX_BITS_PER_GRANULE){var le=0;for(X=0;X<B.channels_out;++X)Y[X]*=u.MAX_BITS_PER_GRANULE,Y[X]/=S,le+=Y[X]}return z},this.reduce_side=function(F,N,Y,K){a(F[0]+F[1]<=u.MAX_BITS_PER_GRANULE);var J=.33*(.5-N)/.5;J<0&&(J=0),J>.5&&(J=.5);var j=0|J*.5*(F[0]+F[1]);j>u.MAX_BITS_PER_CHANNEL-F[0]&&(j=u.MAX_BITS_PER_CHANNEL-F[0]),j<0&&(j=0),F[1]>=125&&(F[1]-j>125?(F[0]<Y&&(F[0]+=j),F[1]-=j):(F[0]+=F[1]-125,F[1]=125)),j=F[0]+F[1],j>K&&(F[0]=K*F[0]/j,F[1]=K*F[1]/j),a(F[0]<=u.MAX_BITS_PER_CHANNEL),a(F[1]<=u.MAX_BITS_PER_CHANNEL),a(F[0]+F[1]<=u.MAX_BITS_PER_GRANULE)},this.athAdjust=function(F,N,Y){var K=90.30873362,J=94.82444863,j=i.FAST_LOG10_X(N,10),B=F*F,M=0;return j-=Y,B>1e-20&&(M=1+i.FAST_LOG10_X(B,10/K)),M<0&&(M=0),j*=M,j+=Y+K-J,Math.pow(10,.1*j)},this.calc_xmin=function(F,N,Y,K){var J=0,j=F.internal_flags,B,M=0,S=0,R=j.ATH,X=Y.xr,re=F.VBR==n.vbr_mtrh?1:0,W=j.masking_lower;for((F.VBR==n.vbr_mtrh||F.VBR==n.vbr_mt)&&(W=1),B=0;B<Y.psy_lmax;B++){var z,le,Me,Ee,ve,ke;F.VBR==n.vbr_rh||F.VBR==n.vbr_mtrh?le=athAdjust(R.adjust,R.l[B],R.floor):le=R.adjust*R.l[B],ve=Y.width[B],Me=le/ve,Ee=p,ke=ve>>1,z=0;do{var Ne,Te;Ne=X[M]*X[M],z+=Ne,Ee+=Ne<Me?Ne:Me,M++,Te=X[M]*X[M],z+=Te,Ee+=Te<Me?Te:Me,M++}while(--ke>0);if(z>le&&S++,B==l.SBPSY_l){var Le=le*j.nsPsy.longfact[B];Ee<Le&&(Ee=Le)}if(re!=0&&(le=Ee),!F.ATHonly){var Fe=N.en.l[B];if(Fe>0){var Le;Le=z*N.thm.l[B]*W/Fe,re!=0&&(Le*=j.nsPsy.longfact[B]),le<Le&&(le=Le)}}re!=0?K[J++]=le:K[J++]=le*j.nsPsy.longfact[B]}var Ze=575;if(Y.block_type!=l.SHORT_TYPE)for(var O=576;O--!=0&&g.EQ(X[O],0);)Ze=O;Y.max_nonzero_coeff=Ze;for(var H=Y.sfb_smin;B<Y.psymax;H++,B+=3){var ve,Pe,xe;for(F.VBR==n.vbr_rh||F.VBR==n.vbr_mtrh?xe=athAdjust(R.adjust,R.s[H],R.floor):xe=R.adjust*R.s[H],ve=Y.width[B],Pe=0;Pe<3;Pe++){var z=0,le,Me,Ee,ke=ve>>1;Me=xe/ve,Ee=p;do{var Ne,Te;Ne=X[M]*X[M],z+=Ne,Ee+=Ne<Me?Ne:Me,M++,Te=X[M]*X[M],z+=Te,Ee+=Te<Me?Te:Me,M++}while(--ke>0);if(z>xe&&S++,H==l.SBPSY_s){var Le=xe*j.nsPsy.shortfact[H];Ee<Le&&(Ee=Le)}if(re!=0?le=Ee:le=xe,!F.ATHonly&&!F.ATHshort){var Fe=N.en.s[H][Pe];if(Fe>0){var Le;Le=z*N.thm.s[H][Pe]*W/Fe,re!=0&&(Le*=j.nsPsy.shortfact[H]),le<Le&&(le=Le)}}re!=0?K[J++]=le:K[J++]=le*j.nsPsy.shortfact[H]}F.useTemporal&&(K[J-3]>K[J-3+1]&&(K[J-3+1]+=(K[J-3]-K[J-3+1])*j.decay),K[J-3+1]>K[J-3+2]&&(K[J-3+2]+=(K[J-3+1]-K[J-3+2])*j.decay))}return S};function E(F){this.s=F}this.calc_noise_core=function(F,N,Y,K){var J=0,j=N.s,B=F.l3_enc;if(j>F.count1)for(;Y--!=0;){var M;M=F.xr[j],j++,J+=M*M,M=F.xr[j],j++,J+=M*M}else if(j>F.big_values){var S=s(2);for(S[0]=0,S[1]=K;Y--!=0;){var M;M=Math.abs(F.xr[j])-S[B[j]],j++,J+=M*M,M=Math.abs(F.xr[j])-S[B[j]],j++,J+=M*M}}else for(;Y--!=0;){var M;M=Math.abs(F.xr[j])-I[B[j]]*K,j++,J+=M*M,M=Math.abs(F.xr[j])-I[B[j]]*K,j++,J+=M*M}return N.s=j,J},this.calc_noise=function(F,N,Y,K,J){var j=0,B=0,M,S,R=0,X=0,re=0,W=-20,z=0,le=F.scalefac,Me=0;for(K.over_SSD=0,M=0;M<F.psymax;M++){var Ee=F.global_gain-(le[Me++]+(F.preflag!=0?L[M]:0)<<F.scalefac_scale+1)-F.subblock_gain[F.window[M]]*8,ve=0;if(J!=null&&J.step[M]==Ee)ve=J.noise[M],z+=F.width[M],Y[j++]=ve/N[B++],ve=J.noise_log[M];else{var ke=y(Ee);if(S=F.width[M]>>1,z+F.width[M]>F.max_nonzero_coeff){var Ne;Ne=F.max_nonzero_coeff-z+1,Ne>0?S=Ne>>1:S=0}var Te=new E(z);ve=this.calc_noise_core(F,Te,S,ke),z=Te.s,J!=null&&(J.step[M]=Ee,J.noise[M]=ve),ve=Y[j++]=ve/N[B++],ve=i.FAST_LOG10(Math.max(ve,1e-20)),J!=null&&(J.noise_log[M]=ve)}if(J!=null&&(J.global_gain=F.global_gain),re+=ve,ve>0){var Le;Le=Math.max(0|ve*10+.5,1),K.over_SSD+=Le*Le,R++,X+=ve}W=Math.max(W,ve)}return K.over_count=R,K.tot_noise=re,K.over_noise=X,K.max_noise=W,R},this.set_pinfo=function(F,N,Y,K,J){var j=F.internal_flags,B,M,S,R,X,re=N.scalefac_scale==0?.5:1,W=N.scalefac,z=s(L3Side.SFBMAX),le=s(L3Side.SFBMAX),Me=new CalcNoiseResult;calc_xmin(F,Y,N,z),calc_noise(N,z,le,Me,null);var Ee=0;for(M=N.sfb_lmax,N.block_type!=l.SHORT_TYPE&&N.mixed_block_flag==0&&(M=22),B=0;B<M;B++){var ve=j.scalefac_band.l[B],ke=j.scalefac_band.l[B+1],Ne=ke-ve;for(R=0;Ee<ke;Ee++)R+=N.xr[Ee]*N.xr[Ee];R/=Ne,X=1e15,j.pinfo.en[K][J][B]=X*R,j.pinfo.xfsf[K][J][B]=X*z[B]*le[B]/Ne,Y.en.l[B]>0&&!F.ATHonly?R=R/Y.en.l[B]:R=0,j.pinfo.thr[K][J][B]=X*Math.max(R*Y.thm.l[B],j.ATH.l[B]),j.pinfo.LAMEsfb[K][J][B]=0,N.preflag!=0&&B>=11&&(j.pinfo.LAMEsfb[K][J][B]=-re*L[B]),B<l.SBPSY_l&&(a(W[B]>=0),j.pinfo.LAMEsfb[K][J][B]-=re*W[B])}if(N.block_type==l.SHORT_TYPE)for(M=B,B=N.sfb_smin;B<l.SBMAX_s;B++)for(var ve=j.scalefac_band.s[B],ke=j.scalefac_band.s[B+1],Ne=ke-ve,Te=0;Te<3;Te++){for(R=0,S=ve;S<ke;S++)R+=N.xr[Ee]*N.xr[Ee],Ee++;R=Math.max(R/Ne,1e-20),X=1e15,j.pinfo.en_s[K][J][3*B+Te]=X*R,j.pinfo.xfsf_s[K][J][3*B+Te]=X*z[M]*le[M]/Ne,Y.en.s[B][Te]>0?R=R/Y.en.s[B][Te]:R=0,(F.ATHonly||F.ATHshort)&&(R=0),j.pinfo.thr_s[K][J][3*B+Te]=X*Math.max(R*Y.thm.s[B][Te],j.ATH.s[B]),j.pinfo.LAMEsfb_s[K][J][3*B+Te]=-2*N.subblock_gain[Te],B<l.SBPSY_s&&(j.pinfo.LAMEsfb_s[K][J][3*B+Te]-=re*W[M]),M++}j.pinfo.LAMEqss[K][J]=N.global_gain,j.pinfo.LAMEmainbits[K][J]=N.part2_3_length+N.part2_length,j.pinfo.LAMEsfbits[K][J]=N.part2_length,j.pinfo.over[K][J]=Me.over_count,j.pinfo.max_noise[K][J]=Me.max_noise*10,j.pinfo.over_noise[K][J]=Me.over_noise*10,j.pinfo.tot_noise[K][J]=Me.tot_noise*10,j.pinfo.over_SSD[K][J]=Me.over_SSD}}return L1=f,L1}var P1,hh;function ph(){if(hh)return P1;hh=1;var t=jn,e=t.System,n=t.Arrays,r=t.new_int,i=t.assert,s=xr(),o=R1,a=k1,l=dh();function c(){var u=null;this.qupvt=null,this.setModules=function(j){this.qupvt=j,u=j};function f(j){this.bits=0|j}var g=[[0,0],[0,0],[0,0],[0,0],[0,0],[0,1],[1,1],[1,1],[1,2],[2,2],[2,3],[2,3],[3,4],[3,4],[3,4],[4,5],[4,5],[4,6],[5,6],[5,6],[5,7],[6,7],[6,7]];function v(j,B,M,S,R,X){var re=.5946/B;for(j=j>>1;j--!=0;)R[X++]=re>M[S++]?0:1,R[X++]=re>M[S++]?0:1}function _(j,B,M,S,R,X){j=j>>1;var re=j%2;for(j=j>>1;j--!=0;){var W,z,le,Me,Ee,ve,ke,Ne;W=M[S++]*B,z=M[S++]*B,Ee=0|W,le=M[S++]*B,ve=0|z,Me=M[S++]*B,ke=0|le,W+=u.adj43[Ee],Ne=0|Me,z+=u.adj43[ve],R[X++]=0|W,le+=u.adj43[ke],R[X++]=0|z,Me+=u.adj43[Ne],R[X++]=0|le,R[X++]=0|Me}if(re!=0){var W,z,Ee,ve;W=M[S++]*B,z=M[S++]*B,Ee=0|W,ve=0|z,W+=u.adj43[Ee],z+=u.adj43[ve],R[X++]=0|W,R[X++]=0|z}}function b(j,B,M,S,R){var X,re,W=0,z,le=0,Me=0,Ee=0,ve=B,ke=0,Ne=ve,Te=0,Le=j,Fe=0;for(z=R!=null&&S.global_gain==R.global_gain,S.block_type==s.SHORT_TYPE?re=38:re=21,X=0;X<=re;X++){var Ze=-1;if((z||S.block_type==s.NORM_TYPE)&&(Ze=S.global_gain-(S.scalefac[X]+(S.preflag!=0?u.pretab[X]:0)<<S.scalefac_scale+1)-S.subblock_gain[S.window[X]]*8),i(S.width[X]>=0),z&&R.step[X]==Ze)le!=0&&(_(le,M,Le,Fe,Ne,Te),le=0),Me!=0&&(v(Me,M,Le,Fe,Ne,Te),Me=0);else{var O=S.width[X];if(W+S.width[X]>S.max_nonzero_coeff){var H;H=S.max_nonzero_coeff-W+1,n.fill(B,S.max_nonzero_coeff,576,0),O=H,O<0&&(O=0),X=re+1}if(le==0&&Me==0&&(Ne=ve,Te=ke,Le=j,Fe=Ee),R!=null&&R.sfb_count1>0&&X>=R.sfb_count1&&R.step[X]>0&&Ze>=R.step[X]?(le!=0&&(_(le,M,Le,Fe,Ne,Te),le=0,Ne=ve,Te=ke,Le=j,Fe=Ee),Me+=O):(Me!=0&&(v(Me,M,Le,Fe,Ne,Te),Me=0,Ne=ve,Te=ke,Le=j,Fe=Ee),le+=O),O<=0){Me!=0&&(v(Me,M,Le,Fe,Ne,Te),Me=0),le!=0&&(_(le,M,Le,Fe,Ne,Te),le=0);break}}X<=re&&(ke+=S.width[X],Ee+=S.width[X],W+=S.width[X])}le!=0&&(_(le,M,Le,Fe,Ne,Te),le=0),Me!=0&&(v(Me,M,Le,Fe,Ne,Te),Me=0)}function y(j,B,M){var S=0,R=0;do{var X=j[B++],re=j[B++];S<X&&(S=X),R<re&&(R=re)}while(B<M);return S<R&&(S=R),S}function p(j,B,M,S,R,X){var re=o.ht[S].xlen*65536+o.ht[R].xlen,W=0,z;do{var le=j[B++],Me=j[B++];le!=0&&(le>14&&(le=15,W+=re),le*=16),Me!=0&&(Me>14&&(Me=15,W+=re),le+=Me),W+=o.largetbl[le]}while(B<M);return z=W&65535,W>>=16,W>z&&(W=z,S=R),X.bits+=W,S}function m(j,B,M,S){var R=0,X=o.ht[1].hlen;do{var re=j[B+0]*2+j[B+1];B+=2,R+=X[re]}while(B<M);return S.bits+=R,1}function w(j,B,M,S,R){var X=0,re,W=o.ht[S].xlen,z;S==2?z=o.table23:z=o.table56;do{var le=j[B+0]*W+j[B+1];B+=2,X+=z[le]}while(B<M);return re=X&65535,X>>=16,X>re&&(X=re,S++),R.bits+=X,S}function C(j,B,M,S,R){var X=0,re=0,W=0,z=o.ht[S].xlen,le=o.ht[S].hlen,Me=o.ht[S+1].hlen,Ee=o.ht[S+2].hlen;do{var ve=j[B+0]*z+j[B+1];B+=2,X+=le[ve],re+=Me[ve],W+=Ee[ve]}while(B<M);var ke=S;return X>re&&(X=re,ke++),X>W&&(X=W,ke=S+2),R.bits+=X,ke}var h=[1,2,5,7,7,10,10,13,13,13,13,13,13,13,13];function A(j,B,M,S){var R=y(j,B,M);switch(R){case 0:return R;case 1:return m(j,B,M,S);case 2:case 3:return w(j,B,M,h[R-1],S);case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:return C(j,B,M,h[R-1],S);default:if(R>l.IXMAX_VAL)return S.bits=l.LARGE_BITS,-1;R-=15;var X;for(X=24;X<32&&!(o.ht[X].linmax>=R);X++);var re;for(re=X-8;re<24&&!(o.ht[re].linmax>=R);re++);return p(j,B,M,re,X,S)}}this.noquant_count_bits=function(j,B,M){var S=B.l3_enc,R=Math.min(576,B.max_nonzero_coeff+2>>1<<1);for(M!=null&&(M.sfb_count1=0);R>1&&!(S[R-1]|S[R-2]);R-=2);B.count1=R;for(var X=0,re=0;R>3;R-=4){var W;if(((S[R-1]|S[R-2]|S[R-3]|S[R-4])&2147483647)>1)break;W=((S[R-4]*2+S[R-3])*2+S[R-2])*2+S[R-1],X+=o.t32l[W],re+=o.t33l[W]}var z=X;if(B.count1table_select=0,X>re&&(z=re,B.count1table_select=1),B.count1bits=z,B.big_values=R,R==0)return z;if(B.block_type==s.SHORT_TYPE)X=3*j.scalefac_band.s[3],X>B.big_values&&(X=B.big_values),re=B.big_values;else if(B.block_type==s.NORM_TYPE){if(X=B.region0_count=j.bv_scf[R-2],re=B.region1_count=j.bv_scf[R-1],i(X+re+2<s.SBPSY_l),re=j.scalefac_band.l[X+re+2],X=j.scalefac_band.l[X+1],re<R){var le=new f(z);B.table_select[2]=A(S,re,R,le),z=le.bits}}else B.region0_count=7,B.region1_count=s.SBMAX_l-1-7-1,X=j.scalefac_band.l[8],re=R,X>re&&(X=re);if(X=Math.min(X,R),re=Math.min(re,R),0<X){var le=new f(z);B.table_select[0]=A(S,0,X,le),z=le.bits}if(X<re){var le=new f(z);B.table_select[1]=A(S,X,re,le),z=le.bits}if(j.use_best_huffman==2&&(B.part2_3_length=z,best_huffman_divide(j,B),z=B.part2_3_length),M!=null&&B.block_type==s.NORM_TYPE){for(var Me=0;j.scalefac_band.l[Me]<B.big_values;)Me++;M.sfb_count1=Me}return z},this.count_bits=function(j,B,M,S){var R=M.l3_enc,X=l.IXMAX_VAL/u.IPOW20(M.global_gain);if(M.xrpow_max>X)return l.LARGE_BITS;if(b(B,R,u.IPOW20(M.global_gain),M,S),j.substep_shaping&2)for(var re=0,W=M.global_gain+M.scalefac_scale,z=.634521682242439/u.IPOW20(W),le=0;le<M.sfbmax;le++){var Me=M.width[le];if(j.pseudohalf[le]==0)re+=Me;else{var Ee;for(Ee=re,re+=Me;Ee<re;++Ee)R[Ee]=B[Ee]>=z?R[Ee]:0}}return this.noquant_count_bits(j,M,S)};function L(j,B,M,S,R,X,re){for(var W=B.big_values,z=0;z<=22;z++)S[z]=l.LARGE_BITS;for(var z=0;z<16;z++){var le=j.scalefac_band.l[z+1];if(le>=W)break;var Me=0,Ee=new f(Me),ve=A(M,0,le,Ee);Me=Ee.bits;for(var ke=0;ke<8;ke++){var Ne=j.scalefac_band.l[z+ke+2];if(Ne>=W)break;var Te=Me;Ee=new f(Te);var Le=A(M,le,Ne,Ee);Te=Ee.bits,S[z+ke]>Te&&(S[z+ke]=Te,R[z+ke]=z,X[z+ke]=ve,re[z+ke]=Le)}}}function $(j,B,M,S,R,X,re,W){for(var z=B.big_values,le=2;le<s.SBMAX_l+1;le++){var Me=j.scalefac_band.l[le];if(Me>=z)break;var Ee=R[le-2]+B.count1bits;if(M.part2_3_length<=Ee)break;var ve=new f(Ee),ke=A(S,Me,z,ve);Ee=ve.bits,!(M.part2_3_length<=Ee)&&(M.assign(B),M.part2_3_length=Ee,M.region0_count=X[le-2],M.region1_count=le-2-X[le-2],M.table_select[0]=re[le-2],M.table_select[1]=W[le-2],M.table_select[2]=ke)}}this.best_huffman_divide=function(j,B){var M=new a,S=B.l3_enc,R=r(23),X=r(23),re=r(23),W=r(23);if(!(B.block_type==s.SHORT_TYPE&&j.mode_gr==1)){M.assign(B),B.block_type==s.NORM_TYPE&&(L(j,B,S,R,X,re,W),$(j,M,B,S,R,X,re,W));var z=M.big_values;if(!(z==0||(S[z-2]|S[z-1])>1)&&(z=B.count1+2,!(z>576))){M.assign(B),M.count1=z;for(var le=0,Me=0;z>M.big_values;z-=4){var Ee=((S[z-4]*2+S[z-3])*2+S[z-2])*2+S[z-1];le+=o.t32l[Ee],Me+=o.t33l[Ee]}if(M.big_values=z,M.count1table_select=0,le>Me&&(le=Me,M.count1table_select=1),M.count1bits=le,M.block_type==s.NORM_TYPE)$(j,M,B,S,R,X,re,W);else{if(M.part2_3_length=le,le=j.scalefac_band.l[8],le>z&&(le=z),le>0){var ve=new f(M.part2_3_length);M.table_select[0]=A(S,0,le,ve),M.part2_3_length=ve.bits}if(z>le){var ve=new f(M.part2_3_length);M.table_select[1]=A(S,le,z,ve),M.part2_3_length=ve.bits}B.part2_3_length>M.part2_3_length&&B.assign(M)}}}};var P=[1,1,1,1,8,2,2,2,4,4,4,8,8,8,16,16],I=[1,2,4,8,1,2,4,8,2,4,8,2,4,8,4,8],x=[0,0,0,0,3,1,1,1,2,2,2,3,3,3,4,4],ae=[0,1,2,3,0,1,2,3,1,2,3,1,2,3,2,3];c.slen1_tab=x,c.slen2_tab=ae;function V(j,B){for(var M,S=B.tt[1][j],R=B.tt[0][j],X=0;X<o.scfsi_band.length-1;X++){for(M=o.scfsi_band[X];M<o.scfsi_band[X+1]&&!(R.scalefac[M]!=S.scalefac[M]&&S.scalefac[M]>=0);M++);if(M==o.scfsi_band[X+1]){for(M=o.scfsi_band[X];M<o.scfsi_band[X+1];M++)S.scalefac[M]=-1;B.scfsi[j][X]=1}}var re=0,W=0;for(M=0;M<11;M++)S.scalefac[M]!=-1&&(W++,re<S.scalefac[M]&&(re=S.scalefac[M]));for(var z=0,le=0;M<s.SBPSY_l;M++)S.scalefac[M]!=-1&&(le++,z<S.scalefac[M]&&(z=S.scalefac[M]));for(var X=0;X<16;X++)if(re<P[X]&&z<I[X]){var Me=x[X]*W+ae[X]*le;S.part2_length>Me&&(S.part2_length=Me,S.scalefac_compress=X)}}this.best_scalefac_store=function(j,B,M,S){var R=S.tt[B][M],X,re,W,z,le=0;for(W=0,X=0;X<R.sfbmax;X++){var Me=R.width[X];for(W+=Me,z=-Me;z<0&&R.l3_enc[z+W]==0;z++);z==0&&(R.scalefac[X]=le=-2)}if(R.scalefac_scale==0&&R.preflag==0){var Ee=0;for(X=0;X<R.sfbmax;X++)R.scalefac[X]>0&&(Ee|=R.scalefac[X]);if(!(Ee&1)&&Ee!=0){for(X=0;X<R.sfbmax;X++)R.scalefac[X]>0&&(R.scalefac[X]>>=1);R.scalefac_scale=le=1}}if(R.preflag==0&&R.block_type!=s.SHORT_TYPE&&j.mode_gr==2){for(X=11;X<s.SBPSY_l&&!(R.scalefac[X]<u.pretab[X]&&R.scalefac[X]!=-2);X++);if(X==s.SBPSY_l){for(X=11;X<s.SBPSY_l;X++)R.scalefac[X]>0&&(R.scalefac[X]-=u.pretab[X]);R.preflag=le=1}}for(re=0;re<4;re++)S.scfsi[M][re]=0;for(j.mode_gr==2&&B==1&&S.tt[0][M].block_type!=s.SHORT_TYPE&&S.tt[1][M].block_type!=s.SHORT_TYPE&&(V(M,S),le=0),X=0;X<R.sfbmax;X++)R.scalefac[X]==-2&&(R.scalefac[X]=0);le!=0&&(j.mode_gr==2?this.scale_bitcount(R):this.scale_bitcount_lsf(j,R))};function E(j,B){for(var M=0;M<B;++M)if(j[M]<0)return!1;return!0}var F=[0,18,36,54,54,36,54,72,54,72,90,72,90,108,108,126],N=[0,18,36,54,51,35,53,71,52,70,88,69,87,105,104,122],Y=[0,10,20,30,33,21,31,41,32,42,52,43,53,63,64,74];this.scale_bitcount=function(j){var B,M,S=0,R=0,X,re=j.scalefac;if(i(E(re,j.sfbmax)),j.block_type==s.SHORT_TYPE)X=F,j.mixed_block_flag!=0&&(X=N);else if(X=Y,j.preflag==0){for(M=11;M<s.SBPSY_l&&!(re[M]<u.pretab[M]);M++);if(M==s.SBPSY_l)for(j.preflag=1,M=11;M<s.SBPSY_l;M++)re[M]-=u.pretab[M]}for(M=0;M<j.sfbdivide;M++)S<re[M]&&(S=re[M]);for(;M<j.sfbmax;M++)R<re[M]&&(R=re[M]);for(j.part2_length=l.LARGE_BITS,B=0;B<16;B++)S<P[B]&&R<I[B]&&j.part2_length>X[B]&&(j.part2_length=X[B],j.scalefac_compress=B);return j.part2_length==l.LARGE_BITS};var K=[[15,15,7,7],[15,15,7,0],[7,3,0,0],[15,31,31,0],[7,7,7,0],[3,3,0,0]];this.scale_bitcount_lsf=function(j,B){var M,S,R,X,re,W,z,le,Me=r(4),Ee=B.scalefac;for(B.preflag!=0?M=2:M=0,z=0;z<4;z++)Me[z]=0;if(B.block_type==s.SHORT_TYPE){S=1;var ve=u.nr_of_sfb_block[M][S];for(le=0,R=0;R<4;R++)for(X=ve[R]/3,z=0;z<X;z++,le++)for(re=0;re<3;re++)Ee[le*3+re]>Me[R]&&(Me[R]=Ee[le*3+re])}else{S=0;var ve=u.nr_of_sfb_block[M][S];for(le=0,R=0;R<4;R++)for(X=ve[R],z=0;z<X;z++,le++)Ee[le]>Me[R]&&(Me[R]=Ee[le])}for(W=!1,R=0;R<4;R++)Me[R]>K[M][R]&&(W=!0);if(!W){var ke,Ne,Te,Le;for(B.sfb_partition_table=u.nr_of_sfb_block[M][S],R=0;R<4;R++)B.slen[R]=J[Me[R]];switch(ke=B.slen[0],Ne=B.slen[1],Te=B.slen[2],Le=B.slen[3],M){case 0:B.scalefac_compress=(ke*5+Ne<<4)+(Te<<2)+Le;break;case 1:B.scalefac_compress=400+(ke*5+Ne<<2)+Te;break;case 2:B.scalefac_compress=500+ke*3+Ne;break;default:e.err.printf(`intensity stereo not implemented yet
`);break}}if(!W)for(i(B.sfb_partition_table!=null),B.part2_length=0,R=0;R<4;R++)B.part2_length+=B.slen[R]*B.sfb_partition_table[R];return W};var J=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];this.huffman_init=function(j){for(var B=2;B<=576;B+=2){for(var M=0,S;j.scalefac_band.l[++M]<B;);for(S=g[M][0];j.scalefac_band.l[S+1]>B;)S--;for(S<0&&(S=g[M][0]),j.bv_scf[B-2]=S,S=g[M][1];j.scalefac_band.l[S+j.bv_scf[B-2]+2]>B;)S--;S<0&&(S=g[M][1]),j.bv_scf[B-1]=S}}}return P1=c,P1}var I1,mh;function O1(){if(mh)return I1;mh=1;var t=jn,e=t.System,n=t.Arrays,r=t.new_byte,i=t.new_float_n,s=t.new_int,o=t.assert,a=ph(),l=R1,c=xr(),u=$u;f.EQ=function(g,v){return Math.abs(g)>Math.abs(v)?Math.abs(g-v)<=Math.abs(g)*1e-6:Math.abs(g-v)<=Math.abs(v)*1e-6},f.NEQ=function(g,v){return!f.EQ(g,v)};function f(){var g=D1(),v=this,_=32773,b=null,y=null,p=null,m=null;this.setModules=function(B,M,S,R){b=B,y=M,p=S,m=R};var w=null,C=0,h=0,A=0;this.getframebits=function(B){var M=B.internal_flags,S;M.bitrate_index!=0?S=l.bitrate_table[B.version][M.bitrate_index]:S=B.brate;var R=0|(B.version+1)*72e3*S/B.out_samplerate+M.padding;return 8*R};function L(B){e.arraycopy(B.header[B.w_ptr].buf,0,w,h,B.sideinfo_len),h+=B.sideinfo_len,C+=B.sideinfo_len*8,B.w_ptr=B.w_ptr+1&u.MAX_HEADER_BUF-1}function $(B,M,S){for(;S>0;){var R;A==0&&(A=8,h++,o(h<g.LAME_MAXMP3BUFFER),o(B.header[B.w_ptr].write_timing>=C),B.header[B.w_ptr].write_timing==C&&L(B),w[h]=0),R=Math.min(S,A),S-=R,A-=R,w[h]|=M>>S<<A,C+=R}}function P(B,M,S){for(;S>0;){var R;A==0&&(A=8,h++,o(h<g.LAME_MAXMP3BUFFER),w[h]=0),R=Math.min(S,A),S-=R,A-=R,w[h]|=M>>S<<A,C+=R}}function I(B,M){var S=B.internal_flags,R;if(M>=8&&($(S,76,8),M-=8),M>=8&&($(S,65,8),M-=8),M>=8&&($(S,77,8),M-=8),M>=8&&($(S,69,8),M-=8),M>=32){var X=p.getLameShortVersion();if(M>=32)for(R=0;R<X.length&&M>=8;++R)M-=8,$(S,X.charAt(R),8)}for(;M>=1;M-=1)$(S,S.ancillary_flag,1),S.ancillary_flag^=B.disable_reservoir?0:1}function x(B,M,S){for(var R=B.header[B.h_ptr].ptr;S>0;){var X=Math.min(S,8-(R&7));S-=X,B.header[B.h_ptr].buf[R>>3]|=M>>S<<8-(R&7)-X,R+=X}B.header[B.h_ptr].ptr=R}function ae(B,M){B<<=8;for(var S=0;S<8;S++)B<<=1,M<<=1,(M^B)&65536&&(M^=_);return M}this.CRC_writeheader=function(B,M){var S=65535;S=ae(M[2]&255,S),S=ae(M[3]&255,S);for(var R=6;R<B.sideinfo_len;R++)S=ae(M[R]&255,S);M[4]=byte(S>>8),M[5]=byte(S&255)};function V(B,M){var S=B.internal_flags,R,X,re;if(R=S.l3_side,S.header[S.h_ptr].ptr=0,n.fill(S.header[S.h_ptr].buf,0,S.sideinfo_len,0),B.out_samplerate<16e3?x(S,4094,12):x(S,4095,12),x(S,B.version,1),x(S,1,2),x(S,B.error_protection?0:1,1),x(S,S.bitrate_index,4),x(S,S.samplerate_index,2),x(S,S.padding,1),x(S,B.extension,1),x(S,B.mode.ordinal(),2),x(S,S.mode_ext,2),x(S,B.copyright,1),x(S,B.original,1),x(S,B.emphasis,2),B.error_protection&&x(S,0,16),B.version==1){for(o(R.main_data_begin>=0),x(S,R.main_data_begin,9),S.channels_out==2?x(S,R.private_bits,3):x(S,R.private_bits,5),re=0;re<S.channels_out;re++){var W;for(W=0;W<4;W++)x(S,R.scfsi[re][W],1)}for(X=0;X<2;X++)for(re=0;re<S.channels_out;re++){var z=R.tt[X][re];x(S,z.part2_3_length+z.part2_length,12),x(S,z.big_values/2,9),x(S,z.global_gain,8),x(S,z.scalefac_compress,4),z.block_type!=c.NORM_TYPE?(x(S,1,1),x(S,z.block_type,2),x(S,z.mixed_block_flag,1),z.table_select[0]==14&&(z.table_select[0]=16),x(S,z.table_select[0],5),z.table_select[1]==14&&(z.table_select[1]=16),x(S,z.table_select[1],5),x(S,z.subblock_gain[0],3),x(S,z.subblock_gain[1],3),x(S,z.subblock_gain[2],3)):(x(S,0,1),z.table_select[0]==14&&(z.table_select[0]=16),x(S,z.table_select[0],5),z.table_select[1]==14&&(z.table_select[1]=16),x(S,z.table_select[1],5),z.table_select[2]==14&&(z.table_select[2]=16),x(S,z.table_select[2],5),o(0<=z.region0_count&&z.region0_count<16),o(0<=z.region1_count&&z.region1_count<8),x(S,z.region0_count,4),x(S,z.region1_count,3)),x(S,z.preflag,1),x(S,z.scalefac_scale,1),x(S,z.count1table_select,1)}}else for(o(R.main_data_begin>=0),x(S,R.main_data_begin,8),x(S,R.private_bits,S.channels_out),X=0,re=0;re<S.channels_out;re++){var z=R.tt[X][re];x(S,z.part2_3_length+z.part2_length,12),x(S,z.big_values/2,9),x(S,z.global_gain,8),x(S,z.scalefac_compress,9),z.block_type!=c.NORM_TYPE?(x(S,1,1),x(S,z.block_type,2),x(S,z.mixed_block_flag,1),z.table_select[0]==14&&(z.table_select[0]=16),x(S,z.table_select[0],5),z.table_select[1]==14&&(z.table_select[1]=16),x(S,z.table_select[1],5),x(S,z.subblock_gain[0],3),x(S,z.subblock_gain[1],3),x(S,z.subblock_gain[2],3)):(x(S,0,1),z.table_select[0]==14&&(z.table_select[0]=16),x(S,z.table_select[0],5),z.table_select[1]==14&&(z.table_select[1]=16),x(S,z.table_select[1],5),z.table_select[2]==14&&(z.table_select[2]=16),x(S,z.table_select[2],5),o(0<=z.region0_count&&z.region0_count<16),o(0<=z.region1_count&&z.region1_count<8),x(S,z.region0_count,4),x(S,z.region1_count,3)),x(S,z.scalefac_scale,1),x(S,z.count1table_select,1)}B.error_protection&&CRC_writeheader(S,S.header[S.h_ptr].buf);{var le=S.h_ptr;o(S.header[le].ptr==S.sideinfo_len*8),S.h_ptr=le+1&u.MAX_HEADER_BUF-1,S.header[S.h_ptr].write_timing=S.header[le].write_timing+M,S.h_ptr==S.w_ptr&&e.err.println(`Error: MAX_HEADER_BUF too small in bitstream.c
`)}}function E(B,M){var S=l.ht[M.count1table_select+32],R,X=0,re=M.big_values,W=M.big_values;for(o(M.count1table_select<2),R=(M.count1-M.big_values)/4;R>0;--R){var z=0,le=0,Me;Me=M.l3_enc[re+0],Me!=0&&(le+=8,M.xr[W+0]<0&&z++),Me=M.l3_enc[re+1],Me!=0&&(le+=4,z*=2,M.xr[W+1]<0&&z++),Me=M.l3_enc[re+2],Me!=0&&(le+=2,z*=2,M.xr[W+2]<0&&z++),Me=M.l3_enc[re+3],Me!=0&&(le++,z*=2,M.xr[W+3]<0&&z++),re+=4,W+=4,$(B,z+S.table[le],S.hlen[le]),X+=S.hlen[le]}return X}function F(B,M,S,R,X){var re=l.ht[M],W=0;if(M==0)return W;for(var z=S;z<R;z+=2){var le=0,Me=0,Ee=re.xlen,ve=re.xlen,ke=0,Ne=X.l3_enc[z],Te=X.l3_enc[z+1];if(Ne!=0&&(X.xr[z]<0&&ke++,le--),M>15){if(Ne>14){var Le=Ne-15;o(Le<=re.linmax),ke|=Le<<1,Me=Ee,Ne=15}if(Te>14){var Fe=Te-15;o(Fe<=re.linmax),ke<<=Ee,ke|=Fe,Me+=Ee,Te=15}ve=16}Te!=0&&(ke<<=1,X.xr[z+1]<0&&ke++,le--),Ne=Ne*ve+Te,Me-=le,le+=re.hlen[Ne],$(B,re.table[Ne],le),$(B,ke,Me),W+=le+Me}return W}function N(B,M){var S=3*B.scalefac_band.s[3];S>M.big_values&&(S=M.big_values);var R=F(B,M.table_select[0],0,S,M);return R+=F(B,M.table_select[1],S,M.big_values,M),R}function Y(B,M){var S,R,X,re;S=M.big_values;var W=M.region0_count+1;return o(W<B.scalefac_band.l.length),X=B.scalefac_band.l[W],W+=M.region1_count+1,o(W<B.scalefac_band.l.length),re=B.scalefac_band.l[W],X>S&&(X=S),re>S&&(re=S),R=F(B,M.table_select[0],0,X,M),R+=F(B,M.table_select[1],X,re,M),R+=F(B,M.table_select[2],re,S,M),R}function K(B){var M,S,R,X,re=0,W=B.internal_flags,z=W.l3_side;if(B.version==1)for(M=0;M<2;M++)for(S=0;S<W.channels_out;S++){var le=z.tt[M][S],Me=a.slen1_tab[le.scalefac_compress],Ee=a.slen2_tab[le.scalefac_compress];for(X=0,R=0;R<le.sfbdivide;R++)le.scalefac[R]!=-1&&($(W,le.scalefac[R],Me),X+=Me);for(;R<le.sfbmax;R++)le.scalefac[R]!=-1&&($(W,le.scalefac[R],Ee),X+=Ee);o(X==le.part2_length),le.block_type==c.SHORT_TYPE?X+=N(W,le):X+=Y(W,le),X+=E(W,le),o(X==le.part2_3_length+le.part2_length),re+=X}else for(M=0,S=0;S<W.channels_out;S++){var le=z.tt[M][S],ve,ke,Ne=0;if(o(le.sfb_partition_table!=null),X=0,R=0,ke=0,le.block_type==c.SHORT_TYPE){for(;ke<4;ke++){var Te=le.sfb_partition_table[ke]/3,Le=le.slen[ke];for(ve=0;ve<Te;ve++,R++)$(W,Math.max(le.scalefac[R*3+0],0),Le),$(W,Math.max(le.scalefac[R*3+1],0),Le),$(W,Math.max(le.scalefac[R*3+2],0),Le),Ne+=3*Le}X+=N(W,le)}else{for(;ke<4;ke++){var Te=le.sfb_partition_table[ke],Le=le.slen[ke];for(ve=0;ve<Te;ve++,R++)$(W,Math.max(le.scalefac[R],0),Le),Ne+=Le}X+=Y(W,le)}X+=E(W,le),o(X==le.part2_3_length),o(Ne==le.part2_length),re+=Ne+X}return re}function J(){this.total=0}function j(B,M){var S=B.internal_flags,R,X,re,W,z;return z=S.w_ptr,W=S.h_ptr-1,W==-1&&(W=u.MAX_HEADER_BUF-1),R=S.header[W].write_timing-C,M.total=R,R>=0&&(X=1+W-z,W<z&&(X=1+W-z+u.MAX_HEADER_BUF),R-=X*8*S.sideinfo_len),re=v.getframebits(B),R+=re,M.total+=re,M.total%8!=0?M.total=1+M.total/8:M.total=M.total/8,M.total+=h+1,R<0&&e.err.println(`strange error flushing buffer ...
`),R}this.flush_bitstream=function(B){var M=B.internal_flags,S,R,X=M.h_ptr-1;if(X==-1&&(X=u.MAX_HEADER_BUF-1),S=M.l3_side,!((R=j(B,new J))<0)){if(I(B,R),o(M.header[X].write_timing+this.getframebits(B)==C),M.ResvSize=0,S.main_data_begin=0,M.findReplayGain){var re=b.GetTitleGain(M.rgdata);o(NEQ(re,GainAnalysis.GAIN_NOT_ENOUGH_SAMPLES)),M.RadioGain=Math.floor(re*10+.5)|0}M.findPeakSample&&(M.noclipGainChange=Math.ceil(Math.log10(M.PeakSample/32767)*20*10)|0,M.noclipGainChange>0&&(EQ(B.scale,1)||EQ(B.scale,0))?M.noclipScale=Math.floor(32767/M.PeakSample*100)/100:M.noclipScale=-1)}},this.add_dummy_byte=function(B,M,S){for(var R=B.internal_flags,X;S-- >0;)for(P(R,M,8),X=0;X<u.MAX_HEADER_BUF;++X)R.header[X].write_timing+=8},this.format_bitstream=function(B){var M=B.internal_flags,S;S=M.l3_side;var R=this.getframebits(B);I(B,S.resvDrain_pre),V(B,R);var X=8*M.sideinfo_len;if(X+=K(B),I(B,S.resvDrain_post),X+=S.resvDrain_post,S.main_data_begin+=(R-X)/8,j(B,new J)!=M.ResvSize&&e.err.println("Internal buffer inconsistency. flushbits <> ResvSize"),S.main_data_begin*8!=M.ResvSize&&(e.err.printf(`bit reservoir error:
l3_side.main_data_begin: %d
Resvoir size: %d
resv drain (post) %d
resv drain (pre) %d
header and sideinfo: %d
data bits: %d
total bits: %d (remainder: %d)
bitsperframe: %d
`,8*S.main_data_begin,M.ResvSize,S.resvDrain_post,S.resvDrain_pre,8*M.sideinfo_len,X-S.resvDrain_post-8*M.sideinfo_len,X,X%8,R),e.err.println("This is a fatal error. It has several possible causes:"),e.err.println("90%% LAME compiled with buggy version of gcc using advanced optimizations"),e.err.println(" 9%% Your system is overclocked"),e.err.println(" 1%% bug in LAME encoding library"),M.ResvSize=S.main_data_begin*8),C>1e9){var re;for(re=0;re<u.MAX_HEADER_BUF;++re)M.header[re].write_timing-=C;C=0}return 0},this.copy_buffer=function(B,M,S,R,X){var re=h+1;if(re<=0)return 0;if(R!=0&&re>R)return-1;if(e.arraycopy(w,0,M,S,re),h=-1,A=0,X!=0){var W=s(1);if(W[0]=B.nMusicCRC,m.updateMusicCRC(W,M,S,re),B.nMusicCRC=W[0],re>0&&(B.VBR_seek_table.nBytesWritten+=re),B.decode_on_the_fly){for(var z=i([2,1152]),le=re,Me=-1,Ee;Me!=0;)if(Me=y.hip_decode1_unclipped(B.hip,M,S,le,z[0],z[1]),le=0,Me==-1&&(Me=0),Me>0){if(B.findPeakSample){for(Ee=0;Ee<Me;Ee++)z[0][Ee]>B.PeakSample?B.PeakSample=z[0][Ee]:-z[0][Ee]>B.PeakSample&&(B.PeakSample=-z[0][Ee]);if(B.channels_out>1)for(Ee=0;Ee<Me;Ee++)z[1][Ee]>B.PeakSample?B.PeakSample=z[1][Ee]:-z[1][Ee]>B.PeakSample&&(B.PeakSample=-z[1][Ee])}if(B.findReplayGain&&b.AnalyzeSamples(B.rgdata,z[0],0,z[1],0,Me,B.channels_out)==GainAnalysis.GAIN_ANALYSIS_ERROR)return-6}}}return re},this.init_bit_stream_w=function(B){w=r(g.LAME_MAXMP3BUFFER),B.h_ptr=B.w_ptr=0,B.header[B.h_ptr].write_timing=0,h=-1,A=0,C=0}}return I1=f,I1}var B1,_h;function D1(){if(_h)return B1;_h=1;var t=jn,e=t.System,n=t.VbrMode,r=t.ShortBlock,i=t.new_float,s=t.new_int_n,o=t.new_short_n,a=t.assert,l=g3,c=y3,u=$u,f=G3,g=z3,v=Q3,_=O1(),b=R1,y=xr();function p(){var m=hl,w=this,C=128*1024;p.V9=410,p.V8=420,p.V7=430,p.V6=440,p.V5=450,p.V4=460,p.V3=470,p.V2=480,p.V1=490,p.V0=500,p.R3MIX=1e3,p.STANDARD=1001,p.EXTREME=1002,p.INSANE=1003,p.STANDARD_FAST=1004,p.EXTREME_FAST=1005,p.MEDIUM=1006,p.MEDIUM_FAST=1007;var h=16384+C;p.LAME_MAXMP3BUFFER=h;var A,L,$,P,I,x=new l,ae,V,E;this.enc=new y,this.setModules=function(O,H,Pe,xe,qe,nt,Oe,je,et){A=O,L=H,$=Pe,P=xe,I=qe,ae=nt,V=je,E=et,this.enc.setModules(L,x,P,ae)};function F(){this.mask_adjust=0,this.mask_adjust_short=0,this.bo_l_weight=i(y.SBMAX_l),this.bo_s_weight=i(y.SBMAX_s)}function N(){this.lowerlimit=0}function Y(O,H){this.lowpass=H}var K=4294479419;function J(O){var H;return O.class_id=K,H=O.internal_flags=new u,O.mode=m.NOT_SET,O.original=1,O.in_samplerate=44100,O.num_channels=2,O.num_samples=-1,O.bWriteVbrTag=!0,O.quality=-1,O.short_blocks=null,H.subblock_gain=-1,O.lowpassfreq=0,O.highpassfreq=0,O.lowpasswidth=-1,O.highpasswidth=-1,O.VBR=n.vbr_off,O.VBR_q=4,O.ATHcurve=-1,O.VBR_mean_bitrate_kbps=128,O.VBR_min_bitrate_kbps=0,O.VBR_max_bitrate_kbps=0,O.VBR_hard_min=0,H.VBR_min_bitrate=1,H.VBR_max_bitrate=13,O.quant_comp=-1,O.quant_comp_short=-1,O.msfix=-1,H.resample_ratio=1,H.OldValue[0]=180,H.OldValue[1]=180,H.CurrentStep[0]=4,H.CurrentStep[1]=4,H.masking_lower=1,H.nsPsy.attackthre=-1,H.nsPsy.attackthre_s=-1,O.scale=-1,O.athaa_type=-1,O.ATHtype=-1,O.athaa_loudapprox=-1,O.athaa_sensitivity=0,O.useTemporal=null,O.interChRatio=-1,H.mf_samples_to_encode=y.ENCDELAY+y.POSTDELAY,O.encoder_padding=0,H.mf_size=y.ENCDELAY-y.MDCTDELAY,O.findReplayGain=!1,O.decode_on_the_fly=!1,H.decode_on_the_fly=!1,H.findReplayGain=!1,H.findPeakSample=!1,H.RadioGain=0,H.AudiophileGain=0,H.noclipGainChange=0,H.noclipScale=-1,O.preset=0,O.write_id3tag_automatic=!0,0}this.lame_init=function(){var O=new c;return J(O),O.lame_allocated_gfp=1,O};function j(O){return O>1?0:O<=0?1:Math.cos(Math.PI/2*O)}this.nearestBitrateFullIndex=function(O){var H=[8,16,24,32,40,48,56,64,80,96,112,128,160,192,224,256,320],Pe=0,xe=0,qe=0,nt=0;nt=H[16],qe=16,xe=H[16],Pe=16;for(var Oe=0;Oe<16;Oe++)if(Math.max(O,H[Oe+1])!=O){nt=H[Oe+1],qe=Oe+1,xe=H[Oe],Pe=Oe;break}return nt-O>O-xe?Pe:qe};function B(O,H){var Pe=44100;return H>=48e3?Pe=48e3:H>=44100?Pe=44100:H>=32e3?Pe=32e3:H>=24e3?Pe=24e3:H>=22050?Pe=22050:H>=16e3?Pe=16e3:H>=12e3?Pe=12e3:H>=11025?Pe=11025:H>=8e3&&(Pe=8e3),O==-1?Pe:(O<=15960&&(Pe=44100),O<=15250&&(Pe=32e3),O<=11220&&(Pe=24e3),O<=9970&&(Pe=22050),O<=7230&&(Pe=16e3),O<=5420&&(Pe=12e3),O<=4510&&(Pe=11025),O<=3970&&(Pe=8e3),H<Pe?H>44100?48e3:H>32e3?44100:H>24e3?32e3:H>22050?24e3:H>16e3?22050:H>12e3?16e3:H>11025?12e3:H>8e3?11025:8e3:Pe)}function M(O,H){switch(O){case 44100:return H.version=1,0;case 48e3:return H.version=1,1;case 32e3:return H.version=1,2;case 22050:return H.version=0,0;case 24e3:return H.version=0,1;case 16e3:return H.version=0,2;case 11025:return H.version=0,0;case 12e3:return H.version=0,1;case 8e3:return H.version=0,2;default:return H.version=0,-1}}function S(O,H,Pe){Pe<16e3&&(H=2);for(var xe=b.bitrate_table[H][1],qe=2;qe<=14;qe++)b.bitrate_table[H][qe]>0&&Math.abs(b.bitrate_table[H][qe]-O)<Math.abs(xe-O)&&(xe=b.bitrate_table[H][qe]);return xe}function R(O,H,Pe){Pe<16e3&&(H=2);for(var xe=0;xe<=14;xe++)if(b.bitrate_table[H][xe]>0&&b.bitrate_table[H][xe]==O)return xe;return-1}function X(O,H){var Pe=[new Y(8,2e3),new Y(16,3700),new Y(24,3900),new Y(32,5500),new Y(40,7e3),new Y(48,7500),new Y(56,1e4),new Y(64,11e3),new Y(80,13500),new Y(96,15100),new Y(112,15600),new Y(128,17e3),new Y(160,17500),new Y(192,18600),new Y(224,19400),new Y(256,19700),new Y(320,20500)],xe=w.nearestBitrateFullIndex(H);O.lowerlimit=Pe[xe].lowpass}function re(O){var H=O.internal_flags,Pe=32,xe=-1;if(H.lowpass1>0){for(var qe=999,nt=0;nt<=31;nt++){var Oe=nt/31;Oe>=H.lowpass2&&(Pe=Math.min(Pe,nt)),H.lowpass1<Oe&&Oe<H.lowpass2&&(qe=Math.min(qe,nt))}qe==999?H.lowpass1=(Pe-.75)/31:H.lowpass1=(qe-.75)/31,H.lowpass2=Pe/31}if(H.highpass2>0&&H.highpass2<.9*(.75/31)&&(H.highpass1=0,H.highpass2=0,e.err.println(`Warning: highpass filter disabled. highpass frequency too small
`)),H.highpass2>0){for(var je=-1,nt=0;nt<=31;nt++){var Oe=nt/31;Oe<=H.highpass1&&(xe=Math.max(xe,nt)),H.highpass1<Oe&&Oe<H.highpass2&&(je=Math.max(je,nt))}H.highpass1=xe/31,je==-1?H.highpass2=(xe+.75)/31:H.highpass2=(je+.75)/31}for(var nt=0;nt<32;nt++){var et,rt,Oe=nt/31;H.highpass2>H.highpass1?et=j((H.highpass2-Oe)/(H.highpass2-H.highpass1+1e-20)):et=1,H.lowpass2>H.lowpass1?rt=j((Oe-H.lowpass1)/(H.lowpass2-H.lowpass1+1e-20)):rt=1,H.amp_filter[nt]=et*rt}}function W(O){var H=O.internal_flags;switch(O.quality){default:case 9:H.psymodel=0,H.noise_shaping=0,H.noise_shaping_amp=0,H.noise_shaping_stop=0,H.use_best_huffman=0,H.full_outer_loop=0;break;case 8:O.quality=7;case 7:H.psymodel=1,H.noise_shaping=0,H.noise_shaping_amp=0,H.noise_shaping_stop=0,H.use_best_huffman=0,H.full_outer_loop=0;break;case 6:H.psymodel=1,H.noise_shaping==0&&(H.noise_shaping=1),H.noise_shaping_amp=0,H.noise_shaping_stop=0,H.subblock_gain==-1&&(H.subblock_gain=1),H.use_best_huffman=0,H.full_outer_loop=0;break;case 5:H.psymodel=1,H.noise_shaping==0&&(H.noise_shaping=1),H.noise_shaping_amp=0,H.noise_shaping_stop=0,H.subblock_gain==-1&&(H.subblock_gain=1),H.use_best_huffman=0,H.full_outer_loop=0;break;case 4:H.psymodel=1,H.noise_shaping==0&&(H.noise_shaping=1),H.noise_shaping_amp=0,H.noise_shaping_stop=0,H.subblock_gain==-1&&(H.subblock_gain=1),H.use_best_huffman=1,H.full_outer_loop=0;break;case 3:H.psymodel=1,H.noise_shaping==0&&(H.noise_shaping=1),H.noise_shaping_amp=1,H.noise_shaping_stop=1,H.subblock_gain==-1&&(H.subblock_gain=1),H.use_best_huffman=1,H.full_outer_loop=0;break;case 2:H.psymodel=1,H.noise_shaping==0&&(H.noise_shaping=1),H.substep_shaping==0&&(H.substep_shaping=2),H.noise_shaping_amp=1,H.noise_shaping_stop=1,H.subblock_gain==-1&&(H.subblock_gain=1),H.use_best_huffman=1,H.full_outer_loop=0;break;case 1:H.psymodel=1,H.noise_shaping==0&&(H.noise_shaping=1),H.substep_shaping==0&&(H.substep_shaping=2),H.noise_shaping_amp=2,H.noise_shaping_stop=1,H.subblock_gain==-1&&(H.subblock_gain=1),H.use_best_huffman=1,H.full_outer_loop=0;break;case 0:H.psymodel=1,H.noise_shaping==0&&(H.noise_shaping=1),H.substep_shaping==0&&(H.substep_shaping=2),H.noise_shaping_amp=2,H.noise_shaping_stop=1,H.subblock_gain==-1&&(H.subblock_gain=1),H.use_best_huffman=1,H.full_outer_loop=0;break}}function z(O){var H=O.internal_flags;O.frameNum=0,O.write_id3tag_automatic&&V.id3tag_write_v2(O),H.bitrate_stereoMode_Hist=s([16,5]),H.bitrate_blockType_Hist=s([16,6]),H.PeakSample=0,O.bWriteVbrTag&&ae.InitVbrTag(O)}this.lame_init_params=function(O){var H=O.internal_flags;if(H.Class_ID=0,H.ATH==null&&(H.ATH=new f),H.PSY==null&&(H.PSY=new F),H.rgdata==null&&(H.rgdata=new g),H.channels_in=O.num_channels,H.channels_in==1&&(O.mode=m.MONO),H.channels_out=O.mode==m.MONO?1:2,H.mode_ext=y.MPG_MD_MS_LR,O.mode==m.MONO&&(O.force_ms=!1),O.VBR==n.vbr_off&&O.VBR_mean_bitrate_kbps!=128&&O.brate==0&&(O.brate=O.VBR_mean_bitrate_kbps),O.VBR==n.vbr_off||O.VBR==n.vbr_mtrh||O.VBR==n.vbr_mt||(O.free_format=!1),O.VBR==n.vbr_off&&O.brate==0&&_.EQ(O.compression_ratio,0)&&(O.compression_ratio=11.025),O.VBR==n.vbr_off&&O.compression_ratio>0&&(O.out_samplerate==0&&(O.out_samplerate=map2MP3Frequency(int(.97*O.in_samplerate))),O.brate=0|O.out_samplerate*16*H.channels_out/(1e3*O.compression_ratio),H.samplerate_index=M(O.out_samplerate,O),O.free_format||(O.brate=S(O.brate,O.version,O.out_samplerate))),O.out_samplerate!=0&&(O.out_samplerate<16e3?(O.VBR_mean_bitrate_kbps=Math.max(O.VBR_mean_bitrate_kbps,8),O.VBR_mean_bitrate_kbps=Math.min(O.VBR_mean_bitrate_kbps,64)):O.out_samplerate<32e3?(O.VBR_mean_bitrate_kbps=Math.max(O.VBR_mean_bitrate_kbps,8),O.VBR_mean_bitrate_kbps=Math.min(O.VBR_mean_bitrate_kbps,160)):(O.VBR_mean_bitrate_kbps=Math.max(O.VBR_mean_bitrate_kbps,32),O.VBR_mean_bitrate_kbps=Math.min(O.VBR_mean_bitrate_kbps,320))),O.lowpassfreq==0){var Pe=16e3;switch(O.VBR){case n.vbr_off:{var xe=new N;X(xe,O.brate),Pe=xe.lowerlimit;break}case n.vbr_abr:{var xe=new N;X(xe,O.VBR_mean_bitrate_kbps),Pe=xe.lowerlimit;break}case n.vbr_rh:{var qe=[19500,19e3,18600,18e3,17500,16e3,15600,14900,12500,1e4,3950];if(0<=O.VBR_q&&O.VBR_q<=9){var nt=qe[O.VBR_q],Oe=qe[O.VBR_q+1],je=O.VBR_q_frac;Pe=linear_int(nt,Oe,je)}else Pe=19500;break}default:{var qe=[19500,19e3,18500,18e3,17500,16500,15500,14500,12500,9500,3950];if(0<=O.VBR_q&&O.VBR_q<=9){var nt=qe[O.VBR_q],Oe=qe[O.VBR_q+1],je=O.VBR_q_frac;Pe=linear_int(nt,Oe,je)}else Pe=19500}}O.mode==m.MONO&&(O.VBR==n.vbr_off||O.VBR==n.vbr_abr)&&(Pe*=1.5),O.lowpassfreq=Pe|0}if(O.out_samplerate==0&&(2*O.lowpassfreq>O.in_samplerate&&(O.lowpassfreq=O.in_samplerate/2),O.out_samplerate=B(O.lowpassfreq|0,O.in_samplerate)),O.lowpassfreq=Math.min(20500,O.lowpassfreq),O.lowpassfreq=Math.min(O.out_samplerate/2,O.lowpassfreq),O.VBR==n.vbr_off&&(O.compression_ratio=O.out_samplerate*16*H.channels_out/(1e3*O.brate)),O.VBR==n.vbr_abr&&(O.compression_ratio=O.out_samplerate*16*H.channels_out/(1e3*O.VBR_mean_bitrate_kbps)),O.bWriteVbrTag||(O.findReplayGain=!1,O.decode_on_the_fly=!1,H.findPeakSample=!1),H.findReplayGain=O.findReplayGain,H.decode_on_the_fly=O.decode_on_the_fly,H.decode_on_the_fly&&(H.findPeakSample=!0),H.findReplayGain&&A.InitGainAnalysis(H.rgdata,O.out_samplerate)==GainAnalysis.INIT_GAIN_ANALYSIS_ERROR)return O.internal_flags=null,-6;switch(H.decode_on_the_fly&&!O.decode_only&&(H.hip!=null&&E.hip_decode_exit(H.hip),H.hip=E.hip_decode_init()),H.mode_gr=O.out_samplerate<=24e3?1:2,O.framesize=576*H.mode_gr,O.encoder_delay=y.ENCDELAY,H.resample_ratio=O.in_samplerate/O.out_samplerate,O.VBR){case n.vbr_mt:case n.vbr_rh:case n.vbr_mtrh:{var et=[5.7,6.5,7.3,8.2,10,11.9,13,14,15,16.5];O.compression_ratio=et[O.VBR_q]}break;case n.vbr_abr:O.compression_ratio=O.out_samplerate*16*H.channels_out/(1e3*O.VBR_mean_bitrate_kbps);break;default:O.compression_ratio=O.out_samplerate*16*H.channels_out/(1e3*O.brate);break}if(O.mode==m.NOT_SET&&(O.mode=m.JOINT_STEREO),O.highpassfreq>0?(H.highpass1=2*O.highpassfreq,O.highpasswidth>=0?H.highpass2=2*(O.highpassfreq+O.highpasswidth):H.highpass2=1*2*O.highpassfreq,H.highpass1/=O.out_samplerate,H.highpass2/=O.out_samplerate):(H.highpass1=0,H.highpass2=0),O.lowpassfreq>0?(H.lowpass2=2*O.lowpassfreq,O.lowpasswidth>=0?(H.lowpass1=2*(O.lowpassfreq-O.lowpasswidth),H.lowpass1<0&&(H.lowpass1=0)):H.lowpass1=1*2*O.lowpassfreq,H.lowpass1/=O.out_samplerate,H.lowpass2/=O.out_samplerate):(H.lowpass1=0,H.lowpass2=0),re(O),H.samplerate_index=M(O.out_samplerate,O),H.samplerate_index<0)return O.internal_flags=null,-1;if(O.VBR==n.vbr_off){if(O.free_format)H.bitrate_index=0;else if(O.brate=S(O.brate,O.version,O.out_samplerate),H.bitrate_index=R(O.brate,O.version,O.out_samplerate),H.bitrate_index<=0)return O.internal_flags=null,-1}else H.bitrate_index=1;O.analysis&&(O.bWriteVbrTag=!1),H.pinfo!=null&&(O.bWriteVbrTag=!1),L.init_bit_stream_w(H);for(var rt=H.samplerate_index+3*O.version+6*(O.out_samplerate<16e3?1:0),Je=0;Je<y.SBMAX_l+1;Je++)H.scalefac_band.l[Je]=P.sfBandIndex[rt].l[Je];for(var Je=0;Je<y.PSFB21+1;Je++){var G=(H.scalefac_band.l[22]-H.scalefac_band.l[21])/y.PSFB21,T=H.scalefac_band.l[21]+Je*G;H.scalefac_band.psfb21[Je]=T}H.scalefac_band.psfb21[y.PSFB21]=576;for(var Je=0;Je<y.SBMAX_s+1;Je++)H.scalefac_band.s[Je]=P.sfBandIndex[rt].s[Je];for(var Je=0;Je<y.PSFB12+1;Je++){var G=(H.scalefac_band.s[13]-H.scalefac_band.s[12])/y.PSFB12,T=H.scalefac_band.s[12]+Je*G;H.scalefac_band.psfb12[Je]=T}H.scalefac_band.psfb12[y.PSFB12]=192,O.version==1?H.sideinfo_len=H.channels_out==1?21:36:H.sideinfo_len=H.channels_out==1?13:21,O.error_protection&&(H.sideinfo_len+=2),z(O),H.Class_ID=K;{var d;for(d=0;d<19;d++)H.nsPsy.pefirbuf[d]=700*H.mode_gr*H.channels_out;O.ATHtype==-1&&(O.ATHtype=4)}switch(a(O.VBR_q<=9),a(O.VBR_q>=0),O.VBR){case n.vbr_mt:O.VBR=n.vbr_mtrh;case n.vbr_mtrh:{O.useTemporal==null&&(O.useTemporal=!1),$.apply_preset(O,500-O.VBR_q*10,0),O.quality<0&&(O.quality=LAME_DEFAULT_QUALITY),O.quality<5&&(O.quality=0),O.quality>5&&(O.quality=5),H.PSY.mask_adjust=O.maskingadjust,H.PSY.mask_adjust_short=O.maskingadjust_short,O.experimentalY?H.sfb21_extra=!1:H.sfb21_extra=O.out_samplerate>44e3,H.iteration_loop=new VBRNewIterationLoop(I);break}case n.vbr_rh:{$.apply_preset(O,500-O.VBR_q*10,0),H.PSY.mask_adjust=O.maskingadjust,H.PSY.mask_adjust_short=O.maskingadjust_short,O.experimentalY?H.sfb21_extra=!1:H.sfb21_extra=O.out_samplerate>44e3,O.quality>6&&(O.quality=6),O.quality<0&&(O.quality=LAME_DEFAULT_QUALITY),H.iteration_loop=new VBROldIterationLoop(I);break}default:{var k;H.sfb21_extra=!1,O.quality<0&&(O.quality=LAME_DEFAULT_QUALITY),k=O.VBR,k==n.vbr_off&&(O.VBR_mean_bitrate_kbps=O.brate),$.apply_preset(O,O.VBR_mean_bitrate_kbps,0),O.VBR=k,H.PSY.mask_adjust=O.maskingadjust,H.PSY.mask_adjust_short=O.maskingadjust_short,k==n.vbr_off?H.iteration_loop=new v(I):H.iteration_loop=new ABRIterationLoop(I);break}}if(a(O.scale>=0),O.VBR!=n.vbr_off){if(H.VBR_min_bitrate=1,H.VBR_max_bitrate=14,O.out_samplerate<16e3&&(H.VBR_max_bitrate=8),O.VBR_min_bitrate_kbps!=0&&(O.VBR_min_bitrate_kbps=S(O.VBR_min_bitrate_kbps,O.version,O.out_samplerate),H.VBR_min_bitrate=R(O.VBR_min_bitrate_kbps,O.version,O.out_samplerate),H.VBR_min_bitrate<0)||O.VBR_max_bitrate_kbps!=0&&(O.VBR_max_bitrate_kbps=S(O.VBR_max_bitrate_kbps,O.version,O.out_samplerate),H.VBR_max_bitrate=R(O.VBR_max_bitrate_kbps,O.version,O.out_samplerate),H.VBR_max_bitrate<0))return-1;O.VBR_min_bitrate_kbps=b.bitrate_table[O.version][H.VBR_min_bitrate],O.VBR_max_bitrate_kbps=b.bitrate_table[O.version][H.VBR_max_bitrate],O.VBR_mean_bitrate_kbps=Math.min(b.bitrate_table[O.version][H.VBR_max_bitrate],O.VBR_mean_bitrate_kbps),O.VBR_mean_bitrate_kbps=Math.max(b.bitrate_table[O.version][H.VBR_min_bitrate],O.VBR_mean_bitrate_kbps)}return O.tune&&(H.PSY.mask_adjust+=O.tune_value_a,H.PSY.mask_adjust_short+=O.tune_value_a),W(O),a(O.scale>=0),O.athaa_type<0?H.ATH.useAdjust=3:H.ATH.useAdjust=O.athaa_type,H.ATH.aaSensitivityP=Math.pow(10,O.athaa_sensitivity/-10),O.short_blocks==null&&(O.short_blocks=r.short_block_allowed),O.short_blocks==r.short_block_allowed&&(O.mode==m.JOINT_STEREO||O.mode==m.STEREO)&&(O.short_blocks=r.short_block_coupled),O.quant_comp<0&&(O.quant_comp=1),O.quant_comp_short<0&&(O.quant_comp_short=0),O.msfix<0&&(O.msfix=0),O.exp_nspsytune=O.exp_nspsytune|1,O.internal_flags.nsPsy.attackthre<0&&(O.internal_flags.nsPsy.attackthre=l.NSATTACKTHRE),O.internal_flags.nsPsy.attackthre_s<0&&(O.internal_flags.nsPsy.attackthre_s=l.NSATTACKTHRE_S),a(O.scale>=0),O.scale<0&&(O.scale=1),O.ATHtype<0&&(O.ATHtype=4),O.ATHcurve<0&&(O.ATHcurve=4),O.athaa_loudapprox<0&&(O.athaa_loudapprox=2),O.interChRatio<0&&(O.interChRatio=0),O.useTemporal==null&&(O.useTemporal=!0),H.slot_lag=H.frac_SpF=0,O.VBR==n.vbr_off&&(H.slot_lag=H.frac_SpF=(O.version+1)*72e3*O.brate%O.out_samplerate|0),P.iteration_init(O),x.psymodel_init(O),a(O.scale>=0),0};function le(O,H){(O.in_buffer_0==null||O.in_buffer_nsamples<H)&&(O.in_buffer_0=i(H),O.in_buffer_1=i(H),O.in_buffer_nsamples=H)}this.lame_encode_flush=function(O,H,Pe,xe){var qe=O.internal_flags,nt=o([2,1152]),Oe=0,je,et,rt,Je,G=qe.mf_samples_to_encode-y.POSTDELAY,T=Me(O);if(qe.mf_samples_to_encode<1)return 0;for(je=0,O.in_samplerate!=O.out_samplerate&&(G+=16*O.out_samplerate/O.in_samplerate),rt=O.framesize-G%O.framesize,rt<576&&(rt+=O.framesize),O.encoder_padding=rt,Je=(G+rt)/O.framesize;Je>0&&Oe>=0;){var d=T-qe.mf_size,k=O.frameNum;d*=O.in_samplerate,d/=O.out_samplerate,d>1152&&(d=1152),d<1&&(d=1),et=xe-je,xe==0&&(et=0),Oe=this.lame_encode_buffer(O,nt[0],nt[1],d,H,Pe,et),Pe+=Oe,je+=Oe,Je-=k!=O.frameNum?1:0}if(qe.mf_samples_to_encode=0,Oe<0||(et=xe-je,xe==0&&(et=0),L.flush_bitstream(O),Oe=L.copy_buffer(qe,H,Pe,et,1),Oe<0))return Oe;if(Pe+=Oe,je+=Oe,et=xe-je,xe==0&&(et=0),O.write_id3tag_automatic){if(V.id3tag_write_v1(O),Oe=L.copy_buffer(qe,H,Pe,et,0),Oe<0)return Oe;je+=Oe}return je},this.lame_encode_buffer=function(O,H,Pe,xe,qe,nt,Oe){var je=O.internal_flags,et=[null,null];if(je.Class_ID!=K)return-3;if(xe==0)return 0;le(je,xe),et[0]=je.in_buffer_0,et[1]=je.in_buffer_1;for(var rt=0;rt<xe;rt++)et[0][rt]=H[rt],je.channels_in>1&&(et[1][rt]=Pe[rt]);return Ee(O,et[0],et[1],xe,qe,nt,Oe)};function Me(O){var H=y.BLKSIZE+O.framesize-y.FFTOFFSET;return H=Math.max(H,512+O.framesize-32),H}function Ee(O,H,Pe,xe,qe,nt,Oe){var je=O.internal_flags,et=0,rt,Je,G,T,d,k=[null,null],D=[null,null];if(je.Class_ID!=K)return-3;if(xe==0)return 0;if(d=L.copy_buffer(je,qe,nt,Oe,0),d<0)return d;if(nt+=d,et+=d,D[0]=H,D[1]=Pe,_.NEQ(O.scale,0)&&_.NEQ(O.scale,1))for(Je=0;Je<xe;++Je)D[0][Je]*=O.scale,je.channels_out==2&&(D[1][Je]*=O.scale);if(_.NEQ(O.scale_left,0)&&_.NEQ(O.scale_left,1))for(Je=0;Je<xe;++Je)D[0][Je]*=O.scale_left;if(_.NEQ(O.scale_right,0)&&_.NEQ(O.scale_right,1))for(Je=0;Je<xe;++Je)D[1][Je]*=O.scale_right;if(O.num_channels==2&&je.channels_out==1)for(Je=0;Je<xe;++Je)D[0][Je]=.5*(D[0][Je]+D[1][Je]),D[1][Je]=0;T=Me(O),k[0]=je.mfbuf[0],k[1]=je.mfbuf[1];for(var U=0;xe>0;){var te=[null,null],ee=0,se=0;te[0]=D[0],te[1]=D[1];var ge=new ke;if(Ze(O,k,te,U,xe,ge),ee=ge.n_in,se=ge.n_out,je.findReplayGain&&!je.decode_on_the_fly&&A.AnalyzeSamples(je.rgdata,k[0],je.mf_size,k[1],je.mf_size,se,je.channels_out)==GainAnalysis.GAIN_ANALYSIS_ERROR)return-6;if(xe-=ee,U+=ee,je.channels_out==2,je.mf_size+=se,a(je.mf_size<=u.MFSIZE),je.mf_samples_to_encode<1&&(je.mf_samples_to_encode=y.ENCDELAY+y.POSTDELAY),je.mf_samples_to_encode+=se,je.mf_size>=T){var pe=Oe-et;if(Oe==0&&(pe=0),rt=ve(O,k[0],k[1],qe,nt,pe),rt<0)return rt;for(nt+=rt,et+=rt,je.mf_size-=O.framesize,je.mf_samples_to_encode-=O.framesize,G=0;G<je.channels_out;G++)for(Je=0;Je<je.mf_size;Je++)k[G][Je]=k[G][Je+O.framesize]}}return et}function ve(O,H,Pe,xe,qe,nt){var Oe=w.enc.lame_encode_mp3_frame(O,H,Pe,xe,qe,nt);return O.frameNum++,Oe}function ke(){this.n_in=0,this.n_out=0}function Ne(){this.num_used=0}function Te(O,H){return H!=0?Te(H,O%H):O}function Le(O,H,Pe){var xe=Math.PI*H;O/=Pe,O<0&&(O=0),O>1&&(O=1);var qe=O-.5,nt=.42-.5*Math.cos(2*O*Math.PI)+.08*Math.cos(4*O*Math.PI);return Math.abs(qe)<1e-9?xe/Math.PI:nt*Math.sin(Pe*xe*qe)/(Math.PI*Pe*qe)}function Fe(O,H,Pe,xe,qe,nt,Oe,je,et){var rt=O.internal_flags,Je,G=0,T,d=O.out_samplerate/Te(O.out_samplerate,O.in_samplerate);d>u.BPC&&(d=u.BPC);var k=Math.abs(rt.resample_ratio-Math.floor(.5+rt.resample_ratio))<1e-4?1:0,D=1/rt.resample_ratio;D>1&&(D=1);var U=31;U%2==0&&--U,U+=k;var te=U+1;if(rt.fill_buffer_resample_init==0){for(rt.inbuf_old[0]=i(te),rt.inbuf_old[1]=i(te),Je=0;Je<=2*d;++Je)rt.blackfilt[Je]=i(te);for(rt.itime[0]=0,rt.itime[1]=0,G=0;G<=2*d;G++){var ee=0,se=(G-d)/(2*d);for(Je=0;Je<=U;Je++)ee+=rt.blackfilt[G][Je]=Le(Je-se,D,U);for(Je=0;Je<=U;Je++)rt.blackfilt[G][Je]/=ee}rt.fill_buffer_resample_init=1}var ge=rt.inbuf_old[et];for(T=0;T<xe;T++){var pe,Ae;if(pe=T*rt.resample_ratio,G=0|Math.floor(pe-rt.itime[et]),U+G-U/2>=Oe)break;var se=pe-rt.itime[et]-(G+.5*(U%2));Ae=0|Math.floor(se*2*d+d+.5);var Ce=0;for(Je=0;Je<=U;++Je){var De=0|Je+G-U/2,tt;tt=De<0?ge[te+De]:qe[nt+De],Ce+=tt*rt.blackfilt[Ae][Je]}H[Pe+T]=Ce}if(je.num_used=Math.min(Oe,U+G-U/2),rt.itime[et]+=je.num_used-T*rt.resample_ratio,je.num_used>=te)for(Je=0;Je<te;Je++)ge[Je]=qe[nt+je.num_used+Je-te];else{var mt=te-je.num_used;for(Je=0;Je<mt;++Je)ge[Je]=ge[Je+je.num_used];for(G=0;Je<te;++Je,++G)ge[Je]=qe[nt+G];a(G==je.num_used)}return T}function Ze(O,H,Pe,xe,qe,nt){var Oe=O.internal_flags;if(Oe.resample_ratio<.9999||Oe.resample_ratio>1.0001)for(var je=0;je<Oe.channels_out;je++){var et=new Ne;nt.n_out=Fe(O,H[je],Oe.mf_size,O.framesize,Pe[je],xe,qe,et,je),nt.n_in=et.num_used}else{nt.n_out=Math.min(O.framesize,qe),nt.n_in=nt.n_out;for(var rt=0;rt<nt.n_out;++rt)H[0][Oe.mf_size+rt]=Pe[0][xe+rt],Oe.channels_out==2&&(H[1][Oe.mf_size+rt]=Pe[1][xe+rt])}}}return B1=p,B1}var e5=jn,Gi=e5.VbrMode;function t5(){var t=D1();function e(u,f,g,v,_,b,y,p,m,w,C,h,A,L,$){this.vbr_q=u,this.quant_comp=f,this.quant_comp_s=g,this.expY=v,this.st_lrm=_,this.st_s=b,this.masking_adj=y,this.masking_adj_short=p,this.ath_lower=m,this.ath_curve=w,this.ath_sensitivity=C,this.interch=h,this.safejoint=A,this.sfb21mod=L,this.msfix=$}function n(u,f,g,v,_,b,y,p,m,w,C,h,A,L){this.quant_comp=f,this.quant_comp_s=g,this.safejoint=v,this.nsmsfix=_,this.st_lrm=b,this.st_s=y,this.nsbass=p,this.scale=m,this.masking_adj=w,this.ath_lower=C,this.ath_curve=h,this.interch=A,this.sfscale=L}var r;this.setModules=function(u){r=u};var i=[new e(0,9,9,0,5.2,125,-4.2,-6.3,4.8,1,0,0,2,21,.97),new e(1,9,9,0,5.3,125,-3.6,-5.6,4.5,1.5,0,0,2,21,1.35),new e(2,9,9,0,5.6,125,-2.2,-3.5,2.8,2,0,0,2,21,1.49),new e(3,9,9,1,5.8,130,-1.8,-2.8,2.6,3,-4,0,2,20,1.64),new e(4,9,9,1,6,135,-.7,-1.1,1.1,3.5,-8,0,2,0,1.79),new e(5,9,9,1,6.4,140,.5,.4,-7.5,4,-12,2e-4,0,0,1.95),new e(6,9,9,1,6.6,145,.67,.65,-14.7,6.5,-19,4e-4,0,0,2.3),new e(7,9,9,1,6.6,145,.8,.75,-19.7,8,-22,6e-4,0,0,2.7),new e(8,9,9,1,6.6,145,1.2,1.15,-27.5,10,-23,7e-4,0,0,0),new e(9,9,9,1,6.6,145,1.6,1.6,-36,11,-25,8e-4,0,0,0),new e(10,9,9,1,6.6,145,2,2,-36,12,-25,8e-4,0,0,0)],s=[new e(0,9,9,0,4.2,25,-7,-4,7.5,1,0,0,2,26,.97),new e(1,9,9,0,4.2,25,-5.6,-3.6,4.5,1.5,0,0,2,21,1.35),new e(2,9,9,0,4.2,25,-4.4,-1.8,2,2,0,0,2,18,1.49),new e(3,9,9,1,4.2,25,-3.4,-1.25,1.1,3,-4,0,2,15,1.64),new e(4,9,9,1,4.2,25,-2.2,.1,0,3.5,-8,0,2,0,1.79),new e(5,9,9,1,4.2,25,-1,1.65,-7.7,4,-12,2e-4,0,0,1.95),new e(6,9,9,1,4.2,25,-0,2.47,-7.7,6.5,-19,4e-4,0,0,2),new e(7,9,9,1,4.2,25,.5,2,-14.5,8,-22,6e-4,0,0,2),new e(8,9,9,1,4.2,25,1,2.4,-22,10,-23,7e-4,0,0,2),new e(9,9,9,1,4.2,25,1.5,2.95,-30,11,-25,8e-4,0,0,2),new e(10,9,9,1,4.2,25,2,2.95,-36,12,-30,8e-4,0,0,2)];function o(u,f,g){var v=u.VBR==Gi.vbr_rh?i:s,_=u.VBR_q_frac,b=v[f],y=v[f+1],p=b;b.st_lrm=b.st_lrm+_*(y.st_lrm-b.st_lrm),b.st_s=b.st_s+_*(y.st_s-b.st_s),b.masking_adj=b.masking_adj+_*(y.masking_adj-b.masking_adj),b.masking_adj_short=b.masking_adj_short+_*(y.masking_adj_short-b.masking_adj_short),b.ath_lower=b.ath_lower+_*(y.ath_lower-b.ath_lower),b.ath_curve=b.ath_curve+_*(y.ath_curve-b.ath_curve),b.ath_sensitivity=b.ath_sensitivity+_*(y.ath_sensitivity-b.ath_sensitivity),b.interch=b.interch+_*(y.interch-b.interch),b.msfix=b.msfix+_*(y.msfix-b.msfix),c(u,p.vbr_q),g!=0?u.quant_comp=p.quant_comp:Math.abs(u.quant_comp- -1)>0||(u.quant_comp=p.quant_comp),g!=0?u.quant_comp_short=p.quant_comp_s:Math.abs(u.quant_comp_short- -1)>0||(u.quant_comp_short=p.quant_comp_s),p.expY!=0&&(u.experimentalY=p.expY!=0),g!=0?u.internal_flags.nsPsy.attackthre=p.st_lrm:Math.abs(u.internal_flags.nsPsy.attackthre- -1)>0||(u.internal_flags.nsPsy.attackthre=p.st_lrm),g!=0?u.internal_flags.nsPsy.attackthre_s=p.st_s:Math.abs(u.internal_flags.nsPsy.attackthre_s- -1)>0||(u.internal_flags.nsPsy.attackthre_s=p.st_s),g!=0?u.maskingadjust=p.masking_adj:Math.abs(u.maskingadjust-0)>0||(u.maskingadjust=p.masking_adj),g!=0?u.maskingadjust_short=p.masking_adj_short:Math.abs(u.maskingadjust_short-0)>0||(u.maskingadjust_short=p.masking_adj_short),g!=0?u.ATHlower=-p.ath_lower/10:Math.abs(-u.ATHlower*10-0)>0||(u.ATHlower=-p.ath_lower/10),g!=0?u.ATHcurve=p.ath_curve:Math.abs(u.ATHcurve- -1)>0||(u.ATHcurve=p.ath_curve),g!=0?u.athaa_sensitivity=p.ath_sensitivity:Math.abs(u.athaa_sensitivity- -1)>0||(u.athaa_sensitivity=p.ath_sensitivity),p.interch>0&&(g!=0?u.interChRatio=p.interch:Math.abs(u.interChRatio- -1)>0||(u.interChRatio=p.interch)),p.safejoint>0&&(u.exp_nspsytune=u.exp_nspsytune|p.safejoint),p.sfb21mod>0&&(u.exp_nspsytune=u.exp_nspsytune|p.sfb21mod<<20),g!=0?u.msfix=p.msfix:Math.abs(u.msfix- -1)>0||(u.msfix=p.msfix),g==0&&(u.VBR_q=f,u.VBR_q_frac=_)}var a=[new n(8,9,9,0,0,6.6,145,0,.95,0,-30,11,.0012,1),new n(16,9,9,0,0,6.6,145,0,.95,0,-25,11,.001,1),new n(24,9,9,0,0,6.6,145,0,.95,0,-20,11,.001,1),new n(32,9,9,0,0,6.6,145,0,.95,0,-15,11,.001,1),new n(40,9,9,0,0,6.6,145,0,.95,0,-10,11,9e-4,1),new n(48,9,9,0,0,6.6,145,0,.95,0,-10,11,9e-4,1),new n(56,9,9,0,0,6.6,145,0,.95,0,-6,11,8e-4,1),new n(64,9,9,0,0,6.6,145,0,.95,0,-2,11,8e-4,1),new n(80,9,9,0,0,6.6,145,0,.95,0,0,8,7e-4,1),new n(96,9,9,0,2.5,6.6,145,0,.95,0,1,5.5,6e-4,1),new n(112,9,9,0,2.25,6.6,145,0,.95,0,2,4.5,5e-4,1),new n(128,9,9,0,1.95,6.4,140,0,.95,0,3,4,2e-4,1),new n(160,9,9,1,1.79,6,135,0,.95,-2,5,3.5,0,1),new n(192,9,9,1,1.49,5.6,125,0,.97,-4,7,3,0,0),new n(224,9,9,1,1.25,5.2,125,0,.98,-6,9,2,0,0),new n(256,9,9,1,.97,5.2,125,0,1,-8,10,1,0,0),new n(320,9,9,1,.9,5.2,125,0,1,-10,12,0,0,0)];function l(u,f,g){var v=f,_=r.nearestBitrateFullIndex(f);if(u.VBR=Gi.vbr_abr,u.VBR_mean_bitrate_kbps=v,u.VBR_mean_bitrate_kbps=Math.min(u.VBR_mean_bitrate_kbps,320),u.VBR_mean_bitrate_kbps=Math.max(u.VBR_mean_bitrate_kbps,8),u.brate=u.VBR_mean_bitrate_kbps,u.VBR_mean_bitrate_kbps>320&&(u.disable_reservoir=!0),a[_].safejoint>0&&(u.exp_nspsytune=u.exp_nspsytune|2),a[_].sfscale>0&&(u.internal_flags.noise_shaping=2),Math.abs(a[_].nsbass)>0){var b=int(a[_].nsbass*4);b<0&&(b+=64),u.exp_nspsytune=u.exp_nspsytune|b<<2}return g!=0?u.quant_comp=a[_].quant_comp:Math.abs(u.quant_comp- -1)>0||(u.quant_comp=a[_].quant_comp),g!=0?u.quant_comp_short=a[_].quant_comp_s:Math.abs(u.quant_comp_short- -1)>0||(u.quant_comp_short=a[_].quant_comp_s),g!=0?u.msfix=a[_].nsmsfix:Math.abs(u.msfix- -1)>0||(u.msfix=a[_].nsmsfix),g!=0?u.internal_flags.nsPsy.attackthre=a[_].st_lrm:Math.abs(u.internal_flags.nsPsy.attackthre- -1)>0||(u.internal_flags.nsPsy.attackthre=a[_].st_lrm),g!=0?u.internal_flags.nsPsy.attackthre_s=a[_].st_s:Math.abs(u.internal_flags.nsPsy.attackthre_s- -1)>0||(u.internal_flags.nsPsy.attackthre_s=a[_].st_s),g!=0?u.scale=a[_].scale:Math.abs(u.scale- -1)>0||(u.scale=a[_].scale),g!=0?u.maskingadjust=a[_].masking_adj:Math.abs(u.maskingadjust-0)>0||(u.maskingadjust=a[_].masking_adj),a[_].masking_adj>0?g!=0?u.maskingadjust_short=a[_].masking_adj*.9:Math.abs(u.maskingadjust_short-0)>0||(u.maskingadjust_short=a[_].masking_adj*.9):g!=0?u.maskingadjust_short=a[_].masking_adj*1.1:Math.abs(u.maskingadjust_short-0)>0||(u.maskingadjust_short=a[_].masking_adj*1.1),g!=0?u.ATHlower=-a[_].ath_lower/10:Math.abs(-u.ATHlower*10-0)>0||(u.ATHlower=-a[_].ath_lower/10),g!=0?u.ATHcurve=a[_].ath_curve:Math.abs(u.ATHcurve- -1)>0||(u.ATHcurve=a[_].ath_curve),g!=0?u.interChRatio=a[_].interch:Math.abs(u.interChRatio- -1)>0||(u.interChRatio=a[_].interch),f}this.apply_preset=function(u,f,g){switch(f){case t.R3MIX:{f=t.V3,u.VBR=Gi.vbr_mtrh;break}case t.MEDIUM:{f=t.V4,u.VBR=Gi.vbr_rh;break}case t.MEDIUM_FAST:{f=t.V4,u.VBR=Gi.vbr_mtrh;break}case t.STANDARD:{f=t.V2,u.VBR=Gi.vbr_rh;break}case t.STANDARD_FAST:{f=t.V2,u.VBR=Gi.vbr_mtrh;break}case t.EXTREME:{f=t.V0,u.VBR=Gi.vbr_rh;break}case t.EXTREME_FAST:{f=t.V0,u.VBR=Gi.vbr_mtrh;break}case t.INSANE:return f=320,u.preset=f,l(u,f,g),u.VBR=Gi.vbr_off,f}switch(u.preset=f,f){case t.V9:return o(u,9,g),f;case t.V8:return o(u,8,g),f;case t.V7:return o(u,7,g),f;case t.V6:return o(u,6,g),f;case t.V5:return o(u,5,g),f;case t.V4:return o(u,4,g),f;case t.V3:return o(u,3,g),f;case t.V2:return o(u,2,g),f;case t.V1:return o(u,1,g),f;case t.V0:return o(u,0,g),f}return 8<=f&&f<=320?l(u,f,g):(u.preset=0,f)};function c(u,f){var g=0;return 0>f&&(g=-1,f=0),9<f&&(g=-1,f=9),u.VBR_q=f,u.VBR_q_frac=0,g}}var n5=t5;function r5(){this.setModules=function(t,e){}}var i5=r5;function s5(){this.over_noise=0,this.tot_noise=0,this.max_noise=0,this.over_count=0,this.over_SSD=0,this.bits=0}var o5=s5,gh=jn,bh=gh.new_float,a5=gh.new_int;function l5(){this.global_gain=0,this.sfb_count1=0,this.step=a5(39),this.noise=bh(39),this.noise_log=bh(39)}var u5=l5,ia=jn,Bs=ia.System,wh=ia.VbrMode,F1=ia.Util,sa=ia.Arrays,pl=ia.new_float,ml=ia.assert,c5=i5,$1=o5,f5=u5,bn=xr(),yh=k1,vh=Iu;function d5(){var t;this.rv=null;var e;this.qupvt=null;var n,r=new c5,i;this.setModules=function(p,m,w,C){t=p,e=m,this.rv=m,n=w,this.qupvt=w,i=C,r.setModules(n,i)},this.ms_convert=function(p,m){for(var w=0;w<576;++w){var C=p.tt[m][0].xr[w],h=p.tt[m][1].xr[w];p.tt[m][0].xr[w]=(C+h)*(F1.SQRT2*.5),p.tt[m][1].xr[w]=(C-h)*(F1.SQRT2*.5)}};function s(p,m,w,C){C=0;for(var h=0;h<=w;++h){var A=Math.abs(p.xr[h]);C+=A,m[h]=Math.sqrt(A*Math.sqrt(A)),m[h]>p.xrpow_max&&(p.xrpow_max=m[h])}return C}this.init_xrpow=function(p,m,w){var C=0,h=0|m.max_nonzero_coeff;if(m.xrpow_max=0,sa.fill(w,h,576,0),C=s(m,w,h,C),C>1e-20){var A=0;p.substep_shaping&2&&(A=1);for(var L=0;L<m.psymax;L++)p.pseudohalf[L]=A;return!0}return sa.fill(m.l3_enc,0,576,0),!1};function o(p,m){var w=p.ATH,C=m.xr;if(m.block_type!=bn.SHORT_TYPE)for(var h=!1,A=bn.PSFB21-1;A>=0&&!h;A--){var L=p.scalefac_band.psfb21[A],$=p.scalefac_band.psfb21[A+1],P=n.athAdjust(w.adjust,w.psfb21[A],w.floor);p.nsPsy.longfact[21]>1e-12&&(P*=p.nsPsy.longfact[21]);for(var I=$-1;I>=L;I--)if(Math.abs(C[I])<P)C[I]=0;else{h=!0;break}}else for(var x=0;x<3;x++)for(var h=!1,A=bn.PSFB12-1;A>=0&&!h;A--){var L=p.scalefac_band.s[12]*3+(p.scalefac_band.s[13]-p.scalefac_band.s[12])*x+(p.scalefac_band.psfb12[A]-p.scalefac_band.psfb12[0]),$=L+(p.scalefac_band.psfb12[A+1]-p.scalefac_band.psfb12[A]),ae=n.athAdjust(w.adjust,w.psfb12[A],w.floor);p.nsPsy.shortfact[12]>1e-12&&(ae*=p.nsPsy.shortfact[12]);for(var I=$-1;I>=L;I--)if(Math.abs(C[I])<ae)C[I]=0;else{h=!0;break}}}this.init_outer_loop=function(p,m){m.part2_3_length=0,m.big_values=0,m.count1=0,m.global_gain=210,m.scalefac_compress=0,m.table_select[0]=0,m.table_select[1]=0,m.table_select[2]=0,m.subblock_gain[0]=0,m.subblock_gain[1]=0,m.subblock_gain[2]=0,m.subblock_gain[3]=0,m.region0_count=0,m.region1_count=0,m.preflag=0,m.scalefac_scale=0,m.count1table_select=0,m.part2_length=0,m.sfb_lmax=bn.SBPSY_l,m.sfb_smin=bn.SBPSY_s,m.psy_lmax=p.sfb21_extra?bn.SBMAX_l:bn.SBPSY_l,m.psymax=m.psy_lmax,m.sfbmax=m.sfb_lmax,m.sfbdivide=11;for(var w=0;w<bn.SBMAX_l;w++)m.width[w]=p.scalefac_band.l[w+1]-p.scalefac_band.l[w],m.window[w]=3;if(m.block_type==bn.SHORT_TYPE){var C=pl(576);m.sfb_smin=0,m.sfb_lmax=0,m.mixed_block_flag!=0&&(m.sfb_smin=3,m.sfb_lmax=p.mode_gr*2+4),m.psymax=m.sfb_lmax+3*((p.sfb21_extra?bn.SBMAX_s:bn.SBPSY_s)-m.sfb_smin),m.sfbmax=m.sfb_lmax+3*(bn.SBPSY_s-m.sfb_smin),m.sfbdivide=m.sfbmax-18,m.psy_lmax=m.sfb_lmax;var h=p.scalefac_band.l[m.sfb_lmax];Bs.arraycopy(m.xr,0,C,0,576);for(var w=m.sfb_smin;w<bn.SBMAX_s;w++)for(var A=p.scalefac_band.s[w],L=p.scalefac_band.s[w+1],$=0;$<3;$++)for(var P=A;P<L;P++)m.xr[h++]=C[3*P+$];for(var I=m.sfb_lmax,w=m.sfb_smin;w<bn.SBMAX_s;w++)m.width[I]=m.width[I+1]=m.width[I+2]=p.scalefac_band.s[w+1]-p.scalefac_band.s[w],m.window[I]=0,m.window[I+1]=1,m.window[I+2]=2,I+=3}m.count1bits=0,m.sfb_partition_table=n.nr_of_sfb_block[0][0],m.slen[0]=0,m.slen[1]=0,m.slen[2]=0,m.slen[3]=0,m.max_nonzero_coeff=575,sa.fill(m.scalefac,0),o(p,m)};function a(p){this.ordinal=p}a.BINSEARCH_NONE=new a(0),a.BINSEARCH_UP=new a(1),a.BINSEARCH_DOWN=new a(2);function l(p,m,w,C,h){var A,L=p.CurrentStep[C],$=!1,P=p.OldValue[C],I=a.BINSEARCH_NONE;for(m.global_gain=P,w-=m.part2_length;;){var x;if(A=i.count_bits(p,h,m,null),L==1||A==w)break;A>w?(I==a.BINSEARCH_DOWN&&($=!0),$&&(L/=2),I=a.BINSEARCH_UP,x=L):(I==a.BINSEARCH_UP&&($=!0),$&&(L/=2),I=a.BINSEARCH_DOWN,x=-L),m.global_gain+=x,m.global_gain<0&&(m.global_gain=0,$=!0),m.global_gain>255&&(m.global_gain=255,$=!0)}for(ml(m.global_gain>=0),ml(m.global_gain<256);A>w&&m.global_gain<255;)m.global_gain++,A=i.count_bits(p,h,m,null);return p.CurrentStep[C]=P-m.global_gain>=4?4:2,p.OldValue[C]=m.global_gain,m.part2_3_length=A,A}this.trancate_smallspectrums=function(p,m,w,C){var h=pl(vh.SFBMAX);if(!(!(p.substep_shaping&4)&&m.block_type==bn.SHORT_TYPE||p.substep_shaping&128)){n.calc_noise(m,w,h,new $1,null);for(var L=0;L<576;L++){var A=0;m.l3_enc[L]!=0&&(A=Math.abs(m.xr[L])),C[L]=A}var L=0,$=8;m.block_type==bn.SHORT_TYPE&&($=6);do{var P,I,x,ae,V=m.width[$];if(L+=V,!(h[$]>=1)&&(sa.sort(C,L-V,V),!BitStream.EQ(C[L-1],0))){P=(1-h[$])*w[$],I=0,ae=0;do{var E;for(x=1;ae+x<V&&!BitStream.NEQ(C[ae+L-V],C[ae+L+x-V]);x++);if(E=C[ae+L-V]*C[ae+L-V]*x,P<E){ae!=0&&(I=C[ae+L-V-1]);break}P-=E,ae+=x}while(ae<V);if(!BitStream.EQ(I,0))do Math.abs(m.xr[L-V])<=I&&(m.l3_enc[L-V]=0);while(--V>0)}}while(++$<m.psymax);m.part2_3_length=i.noquant_count_bits(p,m,null)}};function c(p){for(var m=0;m<p.sfbmax;m++)if(p.scalefac[m]+p.subblock_gain[p.window[m]]==0)return!1;return!0}function u(p){return F1.FAST_LOG10(.368+.632*p*p*p)}function f(p,m){for(var w=1e-37,C=0;C<m.psymax;C++)w+=u(p[C]);return Math.max(1e-20,w)}function g(p,m,w,C,h){var A;switch(p){default:case 9:{m.over_count>0?(A=w.over_SSD<=m.over_SSD,w.over_SSD==m.over_SSD&&(A=w.bits<m.bits)):A=w.max_noise<0&&w.max_noise*10+w.bits<=m.max_noise*10+m.bits;break}case 0:A=w.over_count<m.over_count||w.over_count==m.over_count&&w.over_noise<m.over_noise||w.over_count==m.over_count&&BitStream.EQ(w.over_noise,m.over_noise)&&w.tot_noise<m.tot_noise;break;case 8:w.max_noise=f(h,C);case 1:A=w.max_noise<m.max_noise;break;case 2:A=w.tot_noise<m.tot_noise;break;case 3:A=w.tot_noise<m.tot_noise&&w.max_noise<m.max_noise;break;case 4:A=w.max_noise<=0&&m.max_noise>.2||w.max_noise<=0&&m.max_noise<0&&m.max_noise>w.max_noise-.2&&w.tot_noise<m.tot_noise||w.max_noise<=0&&m.max_noise>0&&m.max_noise>w.max_noise-.2&&w.tot_noise<m.tot_noise+m.over_noise||w.max_noise>0&&m.max_noise>-.05&&m.max_noise>w.max_noise-.1&&w.tot_noise+w.over_noise<m.tot_noise+m.over_noise||w.max_noise>0&&m.max_noise>-.1&&m.max_noise>w.max_noise-.15&&w.tot_noise+w.over_noise+w.over_noise<m.tot_noise+m.over_noise+m.over_noise;break;case 5:A=w.over_noise<m.over_noise||BitStream.EQ(w.over_noise,m.over_noise)&&w.tot_noise<m.tot_noise;break;case 6:A=w.over_noise<m.over_noise||BitStream.EQ(w.over_noise,m.over_noise)&&(w.max_noise<m.max_noise||BitStream.EQ(w.max_noise,m.max_noise)&&w.tot_noise<=m.tot_noise);break;case 7:A=w.over_count<m.over_count||w.over_noise<m.over_noise;break}return m.over_count==0&&(A=A&&w.bits<m.bits),A}function v(p,m,w,C,h){var A=p.internal_flags,L;m.scalefac_scale==0?L=1.2968395546510096:L=1.6817928305074292;for(var $=0,P=0;P<m.sfbmax;P++)$<w[P]&&($=w[P]);var I=A.noise_shaping_amp;switch(I==3&&(h?I=2:I=1),I){case 2:break;case 1:$>1?$=Math.pow($,.5):$*=.95;break;case 0:default:$>1?$=1:$*=.95;break}for(var x=0,P=0;P<m.sfbmax;P++){var ae=m.width[P],V;if(x+=ae,!(w[P]<$)){if(A.substep_shaping&2&&(A.pseudohalf[P]=A.pseudohalf[P]==0?1:0,A.pseudohalf[P]==0&&A.noise_shaping_amp==2))return;for(m.scalefac[P]++,V=-ae;V<0;V++)C[x+V]*=L,C[x+V]>m.xrpow_max&&(m.xrpow_max=C[x+V]);if(A.noise_shaping_amp==2)return}}}function _(p,m){for(var w=1.2968395546510096,C=0,h=0;h<p.sfbmax;h++){var A=p.width[h],L=p.scalefac[h];if(p.preflag!=0&&(L+=n.pretab[h]),C+=A,L&1){L++;for(var $=-A;$<0;$++)m[C+$]*=w,m[C+$]>p.xrpow_max&&(p.xrpow_max=m[C+$])}p.scalefac[h]=L>>1}p.preflag=0,p.scalefac_scale=1}function b(p,m,w){var C,h=m.scalefac;for(C=0;C<m.sfb_lmax;C++)if(h[C]>=16)return!0;for(var A=0;A<3;A++){var L=0,$=0;for(C=m.sfb_lmax+A;C<m.sfbdivide;C+=3)L<h[C]&&(L=h[C]);for(;C<m.sfbmax;C+=3)$<h[C]&&($=h[C]);if(!(L<16&&$<8)){if(m.subblock_gain[A]>=7)return!0;m.subblock_gain[A]++;var P=p.scalefac_band.l[m.sfb_lmax];for(C=m.sfb_lmax+A;C<m.sfbmax;C+=3){var I,x=m.width[C],ae=h[C];if(ae=ae-(4>>m.scalefac_scale),ae>=0){h[C]=ae,P+=x*3;continue}h[C]=0;{var V=210+(ae<<m.scalefac_scale+1);I=n.IPOW20(V)}P+=x*(A+1);for(var E=-x;E<0;E++)w[P+E]*=I,w[P+E]>m.xrpow_max&&(m.xrpow_max=w[P+E]);P+=x*(3-A-1)}{var I=n.IPOW20(202);P+=m.width[C]*(A+1);for(var E=-m.width[C];E<0;E++)w[P+E]*=I,w[P+E]>m.xrpow_max&&(m.xrpow_max=w[P+E])}}}return!1}function y(p,m,w,C,h){var A=p.internal_flags;v(p,m,w,C,h);var L=c(m);return L?!1:(A.mode_gr==2?L=i.scale_bitcount(m):L=i.scale_bitcount_lsf(A,m),L?(A.noise_shaping>1&&(sa.fill(A.pseudohalf,0),m.scalefac_scale==0?(_(m,C),L=!1):m.block_type==bn.SHORT_TYPE&&A.subblock_gain>0&&(L=b(A,m,C)||c(m))),L||(A.mode_gr==2?L=i.scale_bitcount(m):L=i.scale_bitcount_lsf(A,m)),!L):!0)}this.outer_loop=function(p,m,w,C,h,A){var L=p.internal_flags,$=new yh,P=pl(576),I=pl(vh.SFBMAX),x=new $1,ae,V=new f5,E=9999999,F=!1,N=!1,Y=0;if(l(L,m,A,h,C),L.noise_shaping==0)return 100;n.calc_noise(m,w,I,x,V),x.bits=m.part2_3_length,$.assign(m);var K=0;for(Bs.arraycopy(C,0,P,0,576);!F;){do{var J=new $1,j,B=255;if(L.substep_shaping&2?j=20:j=3,L.sfb21_extra&&(I[$.sfbmax]>1||$.block_type==bn.SHORT_TYPE&&(I[$.sfbmax+1]>1||I[$.sfbmax+2]>1))||!y(p,$,I,C,N))break;$.scalefac_scale!=0&&(B=254);var M=A-$.part2_length;if(M<=0)break;for(;($.part2_3_length=i.count_bits(L,C,$,V))>M&&$.global_gain<=B;)$.global_gain++;if($.global_gain>B)break;if(x.over_count==0){for(;($.part2_3_length=i.count_bits(L,C,$,V))>E&&$.global_gain<=B;)$.global_gain++;if($.global_gain>B)break}if(n.calc_noise($,w,I,J,V),J.bits=$.part2_3_length,m.block_type!=bn.SHORT_TYPE?ae=p.quant_comp:ae=p.quant_comp_short,ae=g(ae,x,J,$,I)?1:0,ae!=0)E=m.part2_3_length,x=J,m.assign($),K=0,Bs.arraycopy(C,0,P,0,576);else if(L.full_outer_loop==0&&(++K>j&&x.over_count==0||L.noise_shaping_amp==3&&N&&K>30||L.noise_shaping_amp==3&&N&&$.global_gain-Y>15))break}while($.global_gain+$.scalefac_scale<255);L.noise_shaping_amp==3?N?F=!0:($.assign(m),Bs.arraycopy(P,0,C,0,576),K=0,Y=$.global_gain,N=!0):F=!0}return ml(m.global_gain+m.scalefac_scale<=255),p.VBR==wh.vbr_rh||p.VBR==wh.vbr_mtrh?Bs.arraycopy(P,0,C,0,576):L.substep_shaping&1&&trancate_smallspectrums(L,m,w,C),x.over_count},this.iteration_finish_one=function(p,m,w){var C=p.l3_side,h=C.tt[m][w];i.best_scalefac_store(p,m,w,C),p.use_best_huffman==1&&i.best_huffman_divide(p,h),e.ResvAdjust(p,h)},this.VBR_encode_granule=function(p,m,w,C,h,A,L){var $=p.internal_flags,P=new yh,I=pl(576),x=L,ae=L+1,V=(L+A)/2,E,F,N=0,Y=$.sfb21_extra;ml(x<=LameInternalFlags.MAX_BITS_PER_CHANNEL),sa.fill(P.l3_enc,0);do V>x-42?$.sfb21_extra=!1:$.sfb21_extra=Y,F=outer_loop(p,m,w,C,h,V),F<=0?(N=1,ae=m.part2_3_length,P.assign(m),Bs.arraycopy(C,0,I,0,576),L=ae-32,E=L-A,V=(L+A)/2):(A=V+32,E=L-A,V=(L+A)/2,N!=0&&(N=2,m.assign(P),Bs.arraycopy(I,0,C,0,576)));while(E>12);$.sfb21_extra=Y,N==2&&Bs.arraycopy(P.l3_enc,0,m.l3_enc,0,576),ml(m.part2_3_length<=x)},this.get_framebits=function(p,m){var w=p.internal_flags;w.bitrate_index=w.VBR_min_bitrate;var C=t.getframebits(p);w.bitrate_index=1,C=t.getframebits(p);for(var h=1;h<=w.VBR_max_bitrate;h++){w.bitrate_index=h;var A=new MeanBits(C);m[h]=e.ResvFrameBegin(p,A),C=A.bits}},this.VBR_old_prepare=function(p,m,w,C,h,A,L,$,P){var I=p.internal_flags,x,ae=0,V=1,E=0;I.bitrate_index=I.VBR_max_bitrate;var F=e.ResvFrameBegin(p,new MeanBits(0))/I.mode_gr;get_framebits(p,A);for(var N=0;N<I.mode_gr;N++){var Y=n.on_pe(p,m,$[N],F,N,0);I.mode_ext==bn.MPG_MD_MS_LR&&(ms_convert(I.l3_side,N),n.reduce_side($[N],w[N],F,Y));for(var K=0;K<I.channels_out;++K){var J=I.l3_side.tt[N][K];J.block_type!=bn.SHORT_TYPE?(ae=1.28/(1+Math.exp(3.5-m[N][K]/300))-.05,x=I.PSY.mask_adjust-ae):(ae=2.56/(1+Math.exp(3.5-m[N][K]/300))-.14,x=I.PSY.mask_adjust_short-ae),I.masking_lower=Math.pow(10,x*.1),init_outer_loop(I,J),P[N][K]=n.calc_xmin(p,C[N][K],J,h[N][K]),P[N][K]!=0&&(V=0),L[N][K]=126,E+=$[N][K]}}for(var N=0;N<I.mode_gr;N++)for(var K=0;K<I.channels_out;K++)E>A[I.VBR_max_bitrate]&&($[N][K]*=A[I.VBR_max_bitrate],$[N][K]/=E),L[N][K]>$[N][K]&&(L[N][K]=$[N][K]);return V},this.bitpressure_strategy=function(p,m,w,C){for(var h=0;h<p.mode_gr;h++)for(var A=0;A<p.channels_out;A++){for(var L=p.l3_side.tt[h][A],$=m[h][A],P=0,I=0;I<L.psy_lmax;I++)$[P++]*=1+.029*I*I/bn.SBMAX_l/bn.SBMAX_l;if(L.block_type==bn.SHORT_TYPE)for(var I=L.sfb_smin;I<bn.SBMAX_s;I++)$[P++]*=1+.029*I*I/bn.SBMAX_s/bn.SBMAX_s,$[P++]*=1+.029*I*I/bn.SBMAX_s/bn.SBMAX_s,$[P++]*=1+.029*I*I/bn.SBMAX_s/bn.SBMAX_s;C[h][A]=0|Math.max(w[h][A],.9*C[h][A])}},this.VBR_new_prepare=function(p,m,w,C,h,A){var L=p.internal_flags,$=1,P=0,I=0,x;if(p.free_format){L.bitrate_index=0;var ae=new MeanBits(P);x=e.ResvFrameBegin(p,ae),P=ae.bits,h[0]=x}else{L.bitrate_index=L.VBR_max_bitrate;var ae=new MeanBits(P);e.ResvFrameBegin(p,ae),P=ae.bits,get_framebits(p,h),x=h[L.VBR_max_bitrate]}for(var V=0;V<L.mode_gr;V++){n.on_pe(p,m,A[V],P,V,0),L.mode_ext==bn.MPG_MD_MS_LR&&ms_convert(L.l3_side,V);for(var E=0;E<L.channels_out;++E){var F=L.l3_side.tt[V][E];L.masking_lower=Math.pow(10,L.PSY.mask_adjust*.1),init_outer_loop(L,F),n.calc_xmin(p,w[V][E],F,C[V][E])!=0&&($=0),I+=A[V][E]}}for(var V=0;V<L.mode_gr;V++)for(var E=0;E<L.channels_out;E++)I>x&&(A[V][E]*=x,A[V][E]/=I);return $},this.calc_target_bits=function(p,m,w,C,h,A){var L=p.internal_flags,$=L.l3_side,P,I,x,ae,V=0;L.bitrate_index=L.VBR_max_bitrate;var E=new MeanBits(V);for(A[0]=e.ResvFrameBegin(p,E),V=E.bits,L.bitrate_index=1,V=t.getframebits(p)-L.sideinfo_len*8,h[0]=V/(L.mode_gr*L.channels_out),V=p.VBR_mean_bitrate_kbps*p.framesize*1e3,L.substep_shaping&1&&(V*=1.09),V/=p.out_samplerate,V-=L.sideinfo_len*8,V/=L.mode_gr*L.channels_out,P=.93+.07*(11-p.compression_ratio)/(11-5.5),P<.9&&(P=.9),P>1&&(P=1),I=0;I<L.mode_gr;I++){var F=0;for(x=0;x<L.channels_out;x++){if(C[I][x]=int(P*V),m[I][x]>700){var N=int((m[I][x]-700)/1.4),Y=$.tt[I][x];C[I][x]=int(P*V),Y.block_type==bn.SHORT_TYPE&&N<V/2&&(N=V/2),N>V*3/2?N=V*3/2:N<0&&(N=0),C[I][x]+=N}C[I][x]>LameInternalFlags.MAX_BITS_PER_CHANNEL&&(C[I][x]=LameInternalFlags.MAX_BITS_PER_CHANNEL),F+=C[I][x]}if(F>LameInternalFlags.MAX_BITS_PER_GRANULE)for(x=0;x<L.channels_out;++x)C[I][x]*=LameInternalFlags.MAX_BITS_PER_GRANULE,C[I][x]/=F}if(L.mode_ext==bn.MPG_MD_MS_LR)for(I=0;I<L.mode_gr;I++)n.reduce_side(C[I],w[I],V*L.channels_out,LameInternalFlags.MAX_BITS_PER_GRANULE);for(ae=0,I=0;I<L.mode_gr;I++)for(x=0;x<L.channels_out;x++)C[I][x]>LameInternalFlags.MAX_BITS_PER_CHANNEL&&(C[I][x]=LameInternalFlags.MAX_BITS_PER_CHANNEL),ae+=C[I][x];if(ae>A[0])for(I=0;I<L.mode_gr;I++)for(x=0;x<L.channels_out;x++)C[I][x]*=A[0],C[I][x]/=ae}}var h5=d5,p5=jn,Eh=p5.assert;function m5(){var t;this.setModules=function(e){t=e},this.ResvFrameBegin=function(e,n){var r=e.internal_flags,i,s=r.l3_side,o=t.getframebits(e);n.bits=(o-r.sideinfo_len*8)/r.mode_gr;var a=8*256*r.mode_gr-8;e.brate>320?i=8*int(e.brate*1e3/(e.out_samplerate/1152)/8+.5):(i=8*1440,e.strict_ISO&&(i=8*int(32e4/(e.out_samplerate/1152)/8+.5))),r.ResvMax=i-o,r.ResvMax>a&&(r.ResvMax=a),(r.ResvMax<0||e.disable_reservoir)&&(r.ResvMax=0);var l=n.bits*r.mode_gr+Math.min(r.ResvSize,r.ResvMax);return l>i&&(l=i),Eh(r.ResvMax%8==0),Eh(r.ResvMax>=0),s.resvDrain_pre=0,r.pinfo!=null&&(r.pinfo.mean_bits=n.bits/2,r.pinfo.resvsize=r.ResvSize),l},this.ResvMaxBits=function(e,n,r,i){var s=e.internal_flags,o,a=s.ResvSize,l=s.ResvMax;i!=0&&(a+=n),s.substep_shaping&1&&(l*=.9),r.bits=n,a*10>l*9?(o=a-l*9/10,r.bits+=o,s.substep_shaping|=128):(o=0,s.substep_shaping&=127,!e.disable_reservoir&&!(s.substep_shaping&1)&&(r.bits-=.1*n));var c=a<s.ResvMax*6/10?a:s.ResvMax*6/10;return c-=o,c<0&&(c=0),c},this.ResvAdjust=function(e,n){e.ResvSize-=n.part2_3_length+n.part2_length},this.ResvFrameEnd=function(e,n){var r,i=e.l3_side;e.ResvSize+=n*e.mode_gr;var s=0;i.resvDrain_post=0,i.resvDrain_pre=0,(r=e.ResvSize%8)!=0&&(s+=r),r=e.ResvSize-s-e.ResvMax,r>0&&(s+=r);{var o=Math.min(i.main_data_begin*8,s)/8;i.resvDrain_pre+=8*o,s-=8*o,e.ResvSize-=8*o,i.main_data_begin-=o}i.resvDrain_post+=s,e.ResvSize-=s}}var _5=m5;function g5(){var t="http://www.mp3dev.org/",e=3,n=98,r=4,i=0,s=93;this.getLameVersion=function(){return e+"."+n+"."+r},this.getLameShortVersion=function(){return e+"."+n+"."+r},this.getLameVeryShortVersion=function(){return"LAME"+e+"."+n+"r"},this.getPsyVersion=function(){return i+"."+s},this.getLameUrl=function(){return t},this.getLameOsBitness=function(){return"32bits"}}var b5=g5,oa=jn,w5=oa.System,N1=oa.VbrMode,Sh=oa.ShortBlock,y5=oa.Arrays,Nu=oa.new_byte,v5=oa.assert;_l.NUMTOCENTRIES=100,_l.MAXFRAMESIZE=2880;function _l(){var t,e,n;this.setModules=function(V,E,F){t=V,e=E,n=F};var r=1,i=2,s=4,o=8,a=_l.NUMTOCENTRIES,l=_l.MAXFRAMESIZE,c=a+4+4+4+4+4,u=c+9+1+1+8+1+1+3+1+1+2+4+2+2,f=128,g=64,v=32,_=null,b="Xing",y="Info",p=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];function m(V,E){if(V.nVbrNumFrames++,V.sum+=E,V.seen++,!(V.seen<V.want)&&(V.pos<V.size&&(V.bag[V.pos]=V.sum,V.pos++,V.seen=0),V.pos==V.size)){for(var F=1;F<V.size;F+=2)V.bag[F/2]=V.bag[F];V.want*=2,V.pos/=2}}function w(V,E){if(!(V.pos<=0))for(var F=1;F<a;++F){var N=F/a,Y,K,J=0|Math.floor(N*V.pos);J>V.pos-1&&(J=V.pos-1),Y=V.bag[J],K=V.sum;var j=0|256*Y/K;j>255&&(j=255),E[F]=255&j}}this.addVbrFrame=function(V){var E=V.internal_flags,F=Tables.bitrate_table[V.version][E.bitrate_index];v5(E.VBR_seek_table.bag!=null),m(E.VBR_seek_table,F)};function C(V,E){var F=V[E+0]&255;return F<<=8,F|=V[E+1]&255,F<<=8,F|=V[E+2]&255,F<<=8,F|=V[E+3]&255,F}function h(V,E,F){V[E+0]=255&(F>>24&255),V[E+1]=255&(F>>16&255),V[E+2]=255&(F>>8&255),V[E+3]=255&(F&255)}function A(V,E,F){V[E+0]=255&(F>>8&255),V[E+1]=255&(F&255)}function L(V,E){return new String(V,E,b.length(),_).equals(b)||new String(V,E,y.length(),_).equals(y)}function $(V,E,F){return 255&(V<<E|F&~(-1<<E))}function P(V,E){var F=V.internal_flags;E[0]=$(E[0],8,255),E[1]=$(E[1],3,7),E[1]=$(E[1],1,V.out_samplerate<16e3?0:1),E[1]=$(E[1],1,V.version),E[1]=$(E[1],2,1),E[1]=$(E[1],1,V.error_protection?0:1),E[2]=$(E[2],4,F.bitrate_index),E[2]=$(E[2],2,F.samplerate_index),E[2]=$(E[2],1,0),E[2]=$(E[2],1,V.extension),E[3]=$(E[3],2,V.mode.ordinal()),E[3]=$(E[3],2,F.mode_ext),E[3]=$(E[3],1,V.copyright),E[3]=$(E[3],1,V.original),E[3]=$(E[3],2,V.emphasis),E[0]=255;var N=255&(E[1]&241),Y;V.version==1?Y=f:V.out_samplerate<16e3?Y=v:Y=g,V.VBR==N1.vbr_off&&(Y=V.brate);var K;V.free_format?K=0:K=255&16*t.BitrateIndex(Y,V.version,V.out_samplerate),V.version==1?(E[1]=255&(N|10),N=255&(E[2]&13),E[2]=255&(K|N)):(E[1]=255&(N|2),N=255&(E[2]&13),E[2]=255&(K|N))}this.getVbrTag=function(V){var E=new VBRTagData,F=0;E.flags=0;var N=V[F+1]>>3&1,Y=V[F+2]>>2&3,K=V[F+3]>>6&3,J=V[F+2]>>4&15;if(J=Tables.bitrate_table[N][J],V[F+1]>>4==14?E.samprate=Tables.samplerate_table[2][Y]:E.samprate=Tables.samplerate_table[N][Y],N!=0?K!=3?F+=36:F+=21:K!=3?F+=21:F+=13,!L(V,F))return null;F+=4,E.hId=N;var j=E.flags=C(V,F);if(F+=4,j&r&&(E.frames=C(V,F),F+=4),j&i&&(E.bytes=C(V,F),F+=4),j&s){if(E.toc!=null)for(var B=0;B<a;B++)E.toc[B]=V[F+B];F+=a}E.vbrScale=-1,j&o&&(E.vbrScale=C(V,F),F+=4),E.headersize=(N+1)*72e3*J/E.samprate,F+=21;var M=V[F+0]<<4;M+=V[F+1]>>4;var S=(V[F+1]&15)<<8;return S+=V[F+2]&255,(M<0||M>3e3)&&(M=-1),(S<0||S>3e3)&&(S=-1),E.encDelay=M,E.encPadding=S,E},this.InitVbrTag=function(V){var E=V.internal_flags,F;V.version==1?F=f:V.out_samplerate<16e3?F=v:F=g,V.VBR==N1.vbr_off&&(F=V.brate);var N=(V.version+1)*72e3*F/V.out_samplerate,Y=E.sideinfo_len+u;if(E.VBR_seek_table.TotalFrameSize=N,N<Y||N>l){V.bWriteVbrTag=!1;return}E.VBR_seek_table.nVbrNumFrames=0,E.VBR_seek_table.nBytesWritten=0,E.VBR_seek_table.sum=0,E.VBR_seek_table.seen=0,E.VBR_seek_table.want=1,E.VBR_seek_table.pos=0,E.VBR_seek_table.bag==null&&(E.VBR_seek_table.bag=new int[400],E.VBR_seek_table.size=400);var K=Nu(l);P(V,K);for(var J=E.VBR_seek_table.TotalFrameSize,j=0;j<J;++j)e.add_dummy_byte(V,K[j]&255,1)};function I(V,E){var F=E^V;return E=E>>8^p[F&255],E}this.updateMusicCRC=function(V,E,F,N){for(var Y=0;Y<N;++Y)V[0]=I(E[F+Y],V[0])};function x(V,E,F,N,Y){var K=V.internal_flags,J=0,j=V.encoder_delay,B=V.encoder_padding,M=100-10*V.VBR_q-V.quality,S=n.getLameVeryShortVersion(),R,X=0,re,W=[1,5,3,2,4,0,3],z=0|(V.lowpassfreq/100+.5>255?255:V.lowpassfreq/100+.5),le=0,Me=0,Ee=0,ve=V.internal_flags.noise_shaping,ke=0,Ne=0,Te=0,Le=0,Fe=0,Ze=(V.exp_nspsytune&1)!=0,O=(V.exp_nspsytune&2)!=0,H=!1,Pe=!1,xe=V.internal_flags.nogap_total,qe=V.internal_flags.nogap_current,nt=V.ATHtype,Oe=0,je;switch(V.VBR){case vbr_abr:je=V.VBR_mean_bitrate_kbps;break;case vbr_off:je=V.brate;break;default:je=V.VBR_min_bitrate_kbps}switch(V.VBR.ordinal()<W.length?R=W[V.VBR.ordinal()]:R=0,re=16*X+R,K.findReplayGain&&(K.RadioGain>510&&(K.RadioGain=510),K.RadioGain<-510&&(K.RadioGain=-510),Me=8192,Me|=3072,K.RadioGain>=0?Me|=K.RadioGain:(Me|=512,Me|=-K.RadioGain)),K.findPeakSample&&(le=Math.abs(0|K.PeakSample/32767*Math.pow(2,23)+.5)),xe!=-1&&(qe>0&&(Pe=!0),qe<xe-1&&(H=!0)),Oe=nt+((Ze?1:0)<<4)+((O?1:0)<<5)+((H?1:0)<<6)+((Pe?1:0)<<7),M<0&&(M=0),V.mode){case MONO:ke=0;break;case STEREO:ke=1;break;case DUAL_CHANNEL:ke=2;break;case JOINT_STEREO:V.force_ms?ke=4:ke=3;break;case NOT_SET:default:ke=7;break}V.in_samplerate<=32e3?Te=0:V.in_samplerate==48e3?Te=2:V.in_samplerate>48e3?Te=3:Te=1,(V.short_blocks==Sh.short_block_forced||V.short_blocks==Sh.short_block_dispensed||V.lowpassfreq==-1&&V.highpassfreq==-1||V.scale_left<V.scale_right||V.scale_left>V.scale_right||V.disable_reservoir&&V.brate<320||V.noATH||V.ATHonly||nt==0||V.in_samplerate<=32e3)&&(Ne=1),Le=ve+(ke<<2)+(Ne<<5)+(Te<<6),Fe=K.nMusicCRC,h(F,N+J,M),J+=4;for(var et=0;et<9;et++)F[N+J+et]=255&S.charAt(et);J+=9,F[N+J]=255&re,J++,F[N+J]=255&z,J++,h(F,N+J,le),J+=4,A(F,N+J,Me),J+=2,A(F,N+J,Ee),J+=2,F[N+J]=255&Oe,J++,je>=255?F[N+J]=255:F[N+J]=255&je,J++,F[N+J]=255&j>>4,F[N+J+1]=255&(j<<4)+(B>>8),F[N+J+2]=255&B,J+=3,F[N+J]=255&Le,J++,F[N+J++]=0,A(F,N+J,V.preset),J+=2,h(F,N+J,E),J+=4,A(F,N+J,Fe),J+=2;for(var rt=0;rt<J;rt++)Y=I(F[N+rt],Y);return A(F,N+J,Y),J+=2,J}function ae(V){V.seek(0);var E=Nu(10);V.readFully(E);var F;return new String(E,"ISO-8859-1").startsWith("ID3")?F=0:F=((E[6]&127)<<21|(E[7]&127)<<14|(E[8]&127)<<7|E[9]&127)+E.length,F}this.getLameTagFrame=function(V,E){var F=V.internal_flags;if(!V.bWriteVbrTag||F.Class_ID!=Lame.LAME_ID||F.VBR_seek_table.pos<=0)return 0;if(E.length<F.VBR_seek_table.TotalFrameSize)return F.VBR_seek_table.TotalFrameSize;y5.fill(E,0,F.VBR_seek_table.TotalFrameSize,0),P(V,E);var N=Nu(a);if(V.free_format)for(var Y=1;Y<a;++Y)N[Y]=255&255*Y/100;else w(F.VBR_seek_table,N);var K=F.sideinfo_len;V.error_protection&&(K-=2),V.VBR==N1.vbr_off?(E[K++]=255&y.charAt(0),E[K++]=255&y.charAt(1),E[K++]=255&y.charAt(2),E[K++]=255&y.charAt(3)):(E[K++]=255&b.charAt(0),E[K++]=255&b.charAt(1),E[K++]=255&b.charAt(2),E[K++]=255&b.charAt(3)),h(E,K,r+i+s+o),K+=4,h(E,K,F.VBR_seek_table.nVbrNumFrames),K+=4;var J=F.VBR_seek_table.nBytesWritten+F.VBR_seek_table.TotalFrameSize;h(E,K,0|J),K+=4,w5.arraycopy(N,0,E,K,N.length),K+=N.length,V.error_protection&&e.CRC_writeheader(F,E);for(var j=0,Y=0;Y<K;Y++)j=I(E[Y],j);return K+=x(V,J,E,K,j),F.VBR_seek_table.TotalFrameSize},this.putVbrTag=function(V,E){var F=V.internal_flags;if(F.VBR_seek_table.pos<=0||(E.seek(E.length()),E.length()==0))return-1;var N=ae(E);E.seek(N);var Y=Nu(l),K=getLameTagFrame(V,Y);return K>Y.length?-1:(K<1||E.write(Y,0,K),0)}}var E5=_l,Th=jn,kh=Th.new_byte,S5=Th.assert,T5=D1(),k5=n5,A5=ih,C5=dh(),M5=h5,R5=ph(),L5=_5,P5=hl,I5=O1();xr();var O5=b5,B5=E5;function D5(){this.setModules=function(t,e){}}function F5(){this.setModules=function(t,e,n){}}function $5(){}function N5(){this.setModules=function(t,e){}}function V5(t,e,n){arguments.length!=3&&(console.error("WARN: Mp3Encoder(channels, samplerate, kbps) not specified"),t=1,e=44100,n=128);var r=new T5,i=new D5,s=new A5,o=new I5,a=new k5,l=new C5,c=new M5,u=new B5,f=new O5,g=new N5,v=new L5,_=new R5,b=new F5,y=new $5;r.setModules(s,o,a,l,c,u,f,g,y),o.setModules(s,y,f,u),g.setModules(o,f),a.setModules(r),c.setModules(o,v,l,_),l.setModules(_,v,r.enc.psy),v.setModules(o),_.setModules(l),u.setModules(r,o,f),i.setModules(b,y),b.setModules(f,g,a);var p=r.lame_init();p.num_channels=t,p.in_samplerate=e,p.brate=n,p.mode=P5.STEREO,p.quality=3,p.bWriteVbrTag=!1,p.disable_reservoir=!0,p.write_id3tag_automatic=!1,r.lame_init_params(p);var m=1152,w=0|1.25*m+7200,C=kh(w);this.encodeBuffer=function(h,A){t==1&&(A=h),S5(h.length==A.length),h.length>m&&(m=h.length,w=0|1.25*m+7200,C=kh(w));var L=r.lame_encode_buffer(p,h,A,h.length,C,0,w);return new Int8Array(C.subarray(0,L))},this.flush=function(){var h=r.lame_encode_flush(p,C,0,w);return new Int8Array(C.subarray(0,h))}}function ji(){this.dataOffset=0,this.dataLen=0,this.channels=0,this.sampleRate=0}function Vu(t){return t.charCodeAt(0)<<24|t.charCodeAt(1)<<16|t.charCodeAt(2)<<8|t.charCodeAt(3)}ji.RIFF=Vu("RIFF"),ji.WAVE=Vu("WAVE"),ji.fmt_=Vu("fmt "),ji.data=Vu("data"),ji.readHeader=function(t){var e=new ji,n=t.getUint32(0,!1);if(ji.RIFF==n&&(t.getUint32(4,!0),ji.WAVE==t.getUint32(8,!1)&&ji.fmt_==t.getUint32(12,!1))){var r=t.getUint32(16,!0),i=20;switch(r){case 16:case 18:e.channels=t.getUint16(i+2,!0),e.sampleRate=t.getUint32(i+4,!0);break;default:throw"extended fmt chunk not implemented"}i+=r;for(var s=ji.data,o=0;s!=n&&(n=t.getUint32(i,!1),o=t.getUint32(i+4,!0),s!=n);)i+=o+8;return e.dataLen=o,e.dataOffset=i+8,e}};var H5=V5;const x5=t=>e=>{const n=t(e);return e.add(n),n},U5=t=>(e,n)=>(t.set(e,n),n),Ah=Number.MAX_SAFE_INTEGER===void 0?9007199254740991:Number.MAX_SAFE_INTEGER,Ch=536870912,Mh=Ch*2,W5=(t,e)=>n=>{const r=e.get(n);let i=r===void 0?n.size:r<Mh?r+1:0;if(!n.has(i))return t(n,i);if(n.size<Ch){for(;n.has(i);)i=Math.floor(Math.random()*Mh);return t(n,i)}if(n.size>Ah)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;n.has(i);)i=Math.floor(Math.random()*Ah);return t(n,i)},Rh=new WeakMap,G5=U5(Rh),V1=W5(G5,Rh),j5=x5(V1),z5=t=>typeof t.start=="function",Lh=new WeakMap,X5=t=>({...t,connect:({call:e})=>async()=>{const{port1:n,port2:r}=new MessageChannel,i=await e("connect",{port:n},[n]);return Lh.set(r,i),r},disconnect:({call:e})=>async n=>{const r=Lh.get(n);if(r===void 0)throw new Error("The given port is not connected.");await e("disconnect",{portId:r})},isSupported:({call:e})=>()=>e("isSupported")}),H1=new WeakMap,Y5=t=>{if(H1.has(t))return H1.get(t);const e=new Map;return H1.set(t,e),e},Ph=t=>{const e=X5(t);return n=>{const r=Y5(n);n.addEventListener("message",({data:a})=>{const{id:l}=a;if(l!==null&&r.has(l)){const{reject:c,resolve:u}=r.get(l);r.delete(l),a.error===void 0?u(a.result):c(new Error(a.error.message))}}),z5(n)&&n.start();const i=(a,l=null,c=[])=>new Promise((u,f)=>{const g=V1(r);r.set(g,{reject:f,resolve:u}),l===null?n.postMessage({id:g,method:a},c):n.postMessage({id:g,method:a,params:l},c)}),s=(a,l,c=[])=>{n.postMessage({id:null,method:a,params:l},c)};let o={};for(const[a,l]of Object.entries(e))o={...o,[a]:l({call:i,notify:s})};return{...o}}},Ih=new Set,K5=Ph({encode:({call:t})=>async(e,n)=>{const r=await t("encode",{encoderId:e,timeslice:n});return Ih.delete(e),r},instantiate:({call:t})=>async(e,n)=>{const r=j5(Ih),i=await t("instantiate",{encoderId:r,mimeType:e,sampleRate:n});return{encoderId:r,port:i}},register:({call:t})=>e=>t("register",{port:e},[e])}),q5=t=>{const e=new Worker(t);return K5(e)},Z5=`(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),c=void 0===a?r.size:a<s?a+1:0;if(!r.has(c))return e(r,c);if(r.size<o){for(;r.has(c);)c=Math.floor(Math.random()*s);return e(r,c)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(c);)c=Math.floor(Math.random()*n);return e(r,c)}},c=new WeakMap,i=r(c),l=a(i,c),u=t(l);e.addUniqueNumber=u,e.generateUniqueNumber=l}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,o=(e,t)=>Object.assign(new Error(e),{status:t}),s=t=>o('The handler of the method called "'.concat(t,'" returned an unexpected result.'),e),a=(t,r)=>async a=>{let{data:{id:c,method:i,params:l}}=a;const u=r[i];try{if(void 0===u)throw(e=>o('The requested method called "'.concat(e,'" is not supported.'),n))(i);const r=void 0===l?u():u(l);if(void 0===r)throw(t=>o('The handler of the method called "'.concat(t,'" returned no required result.'),e))(i);const a=r instanceof Promise?await r:r;if(null===c){if(void 0!==a.result)throw s(i)}else{if(void 0===a.result)throw s(i);const{result:e,transferables:r=[]}=a;t.postMessage({id:c,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:c})}};var c=r(455);const i=new Map,l=(e,r,n)=>({...r,connect:t=>{let{port:n}=t;n.start();const o=e(n,r),s=(0,c.generateUniqueNumber)(i);return i.set(s,(()=>{o(),n.close(),i.delete(s)})),{result:s}},disconnect:e=>{let{portId:r}=e;const n=i.get(r);if(void 0===n)throw(e=>o('The specified parameter called "portId" with the given value "'.concat(e,'" does not identify a port connected to this worker.'),t))(r);return n(),{result:null}},isSupported:async()=>{if(await new Promise((e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=t=>{let{data:r}=t;return e(null!==r)},n.postMessage(t,[t])}))){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),u=function(e,t){const r=l(u,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:()=>!0),n=a(e,r);return e.addEventListener("message",n),()=>e.removeEventListener("message",n)},d=e=>{e.onmessage=null,e.close()},h=new WeakMap,f=new WeakMap,p=(e=>{const t=(r=e,{...r,connect:e=>{let{call:t}=e;return async()=>{const{port1:e,port2:r}=new MessageChannel,n=await t("connect",{port:e},[e]);return h.set(r,n),r}},disconnect:e=>{let{call:t}=e;return async e=>{const r=h.get(e);if(void 0===r)throw new Error("The given port is not connected.");await t("disconnect",{portId:r})}},isSupported:e=>{let{call:t}=e;return()=>t("isSupported")}});var r;return e=>{const r=(e=>{if(f.has(e))return f.get(e);const t=new Map;return f.set(e,t),t})(e);e.addEventListener("message",(e=>{let{data:t}=e;const{id:n}=t;if(null!==n&&r.has(n)){const{reject:e,resolve:o}=r.get(n);r.delete(n),void 0===t.error?o(t.result):e(new Error(t.error.message))}})),(e=>"function"==typeof e.start)(e)&&e.start();const n=function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return new Promise(((s,a)=>{const i=(0,c.generateUniqueNumber)(r);r.set(i,{reject:a,resolve:s}),null===n?e.postMessage({id:i,method:t},o):e.postMessage({id:i,method:t,params:n},o)}))},o=function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];e.postMessage({id:null,method:t,params:r},n)};let s={};for(const[e,r]of Object.entries(t))s={...s,[e]:r({call:n,notify:o})};return{...s}}})({characterize:e=>{let{call:t}=e;return()=>t("characterize")},encode:e=>{let{call:t}=e;return(e,r)=>t("encode",{recordingId:e,timeslice:r})},record:e=>{let{call:t}=e;return async(e,r,n)=>{await t("record",{recordingId:e,sampleRate:r,typedArrays:n},n.map((e=>{let{buffer:t}=e;return t})))}}}),w=async(e,t)=>{const r=p(t),n=await r.characterize(),o=n.toString();if(e.has(o))throw new Error("There is already an encoder stored which handles exactly the same mime types.");return e.set(o,[n,r]),n},m=new Map,g=(e=>t=>{const r=e.get(t);if(void 0===r)throw new Error("There was no instance of an encoder stored with the given id.");return r})(m),v=((e,t)=>r=>{const n=t(r);return e.delete(r),n})(m,g),y=new Map,M=((e,t)=>r=>{const[n,o,s,a]=t(r);return s?new Promise((t=>{o.onmessage=s=>{let{data:c}=s;0===c.length?(e(o),t(n.encode(r,null))):n.record(r,a,c)}})):n.encode(r,null)})(d,v),E=(e=>t=>{for(const[r,n]of Array.from(e.values()))if(r.test(t))return n;throw new Error("There is no encoder registered which could handle the given mimeType.")})(y),b=((e,t,r)=>(n,o,s)=>{if(t.has(n))throw new Error('There is already an encoder registered with an id called "'.concat(n,'".'));const a=r(o),{port1:c,port2:i}=new MessageChannel,l=[a,c,!0,s];return t.set(n,l),c.onmessage=t=>{let{data:r}=t;0===r.length?(e(c),l[2]=!1):a.record(n,s,r.map((e=>"number"==typeof e?new Float32Array(e):e)))},i})(d,m,E),T=(e=>(t,r)=>{const[n]=e(t);return n.encode(t,r)})(g);u(self,{encode:async e=>{let{encoderId:t,timeslice:r}=e;const n=null===r?await M(t):await T(t,r);return{result:n,transferables:n}},instantiate:e=>{let{encoderId:t,mimeType:r,sampleRate:n}=e;const o=b(t,r,n);return{result:o,transferables:[o]}},register:async e=>{let{port:t}=e;return{result:await w(y,t)}}})})()})();`,J5=new Blob([Z5],{type:"application/javascript; charset=utf-8"}),Oh=URL.createObjectURL(J5),x1=q5(Oh),Hu=x1.encode,Bh=x1.instantiate,Q5=x1.register;URL.revokeObjectURL(Oh);const e4=t=>(e,n)=>{if(t===null)throw new Error("A native BlobEvent could not be created.");return new t(e,n)},t4=(t,e)=>(n,r,i)=>{const s=[];let o=r,a=0;for(;a<n.byteLength;)if(o===null){const l=e(n,a);if(l===null)break;const{length:c,type:u}=l;o=u,a+=c}else{const l=t(n,a,o,i);if(l===null)break;const{content:c,length:u}=l;o=null,a+=u,c!==null&&s.push(c)}return{contents:s,currentElementType:o,offset:a}},n4=(t,e)=>class{constructor(r=null){this._listeners=new WeakMap,this._nativeEventTarget=r===null?t():r}addEventListener(r,i,s){if(i!==null){let o=this._listeners.get(i);o===void 0&&(o=e(this,i),typeof i=="function"&&this._listeners.set(i,o)),this._nativeEventTarget.addEventListener(r,o,s)}}dispatchEvent(r){return this._nativeEventTarget.dispatchEvent(r)}removeEventListener(r,i,s){const o=i===null?void 0:this._listeners.get(i);this._nativeEventTarget.removeEventListener(r,o===void 0?null:o,s)}},r4=t=>()=>{if(t===null)throw new Error("A native EventTarget could not be created.");return t.document.createElement("p")},i4=(t="")=>{try{return new DOMException(t,"InvalidModificationError")}catch(e){return e.code=13,e.message=t,e.name="InvalidModificationError",e}},s4=()=>{try{return new DOMException("","InvalidStateError")}catch(t){return t.code=11,t.name="InvalidStateError",t}},o4=(t,e,n,r,i,s,o)=>class extends s{constructor(l,c={}){const{mimeType:u}=c;if(o!==null&&(u===void 0||o.isTypeSupported!==void 0&&o.isTypeSupported(u))){const f=t(o,l,c);super(f),this._internalMediaRecorder=f}else if(u!==void 0&&i.some(f=>f.test(u)))super(),o!==null&&o.isTypeSupported!==void 0&&o.isTypeSupported("audio/webm;codecs=pcm")?this._internalMediaRecorder=r(this,o,l,u):this._internalMediaRecorder=n(this,l,u);else throw o!==null&&t(o,l,c),e();this._ondataavailable=null,this._onerror=null,this._onpause=null,this._onresume=null,this._onstart=null,this._onstop=null}get mimeType(){return this._internalMediaRecorder.mimeType}get ondataavailable(){return this._ondataavailable===null?this._ondataavailable:this._ondataavailable[0]}set ondataavailable(l){if(this._ondataavailable!==null&&this.removeEventListener("dataavailable",this._ondataavailable[1]),typeof l=="function"){const c=l.bind(this);this.addEventListener("dataavailable",c),this._ondataavailable=[l,c]}else this._ondataavailable=null}get onerror(){return this._onerror===null?this._onerror:this._onerror[0]}set onerror(l){if(this._onerror!==null&&this.removeEventListener("error",this._onerror[1]),typeof l=="function"){const c=l.bind(this);this.addEventListener("error",c),this._onerror=[l,c]}else this._onerror=null}get onpause(){return this._onpause===null?this._onpause:this._onpause[0]}set onpause(l){if(this._onpause!==null&&this.removeEventListener("pause",this._onpause[1]),typeof l=="function"){const c=l.bind(this);this.addEventListener("pause",c),this._onpause=[l,c]}else this._onpause=null}get onresume(){return this._onresume===null?this._onresume:this._onresume[0]}set onresume(l){if(this._onresume!==null&&this.removeEventListener("resume",this._onresume[1]),typeof l=="function"){const c=l.bind(this);this.addEventListener("resume",c),this._onresume=[l,c]}else this._onresume=null}get onstart(){return this._onstart===null?this._onstart:this._onstart[0]}set onstart(l){if(this._onstart!==null&&this.removeEventListener("start",this._onstart[1]),typeof l=="function"){const c=l.bind(this);this.addEventListener("start",c),this._onstart=[l,c]}else this._onstart=null}get onstop(){return this._onstop===null?this._onstop:this._onstop[0]}set onstop(l){if(this._onstop!==null&&this.removeEventListener("stop",this._onstop[1]),typeof l=="function"){const c=l.bind(this);this.addEventListener("stop",c),this._onstop=[l,c]}else this._onstop=null}get state(){return this._internalMediaRecorder.state}pause(){return this._internalMediaRecorder.pause()}resume(){return this._internalMediaRecorder.resume()}start(l){return this._internalMediaRecorder.start(l)}stop(){return this._internalMediaRecorder.stop()}static isTypeSupported(l){return o!==null&&o.isTypeSupported!==void 0&&o.isTypeSupported(l)||i.some(c=>c.test(l))}},a4=t=>t!==null&&t.BlobEvent!==void 0?t.BlobEvent:null,l4=t=>t===null||t.MediaRecorder===void 0?null:t.MediaRecorder,u4=t=>(e,n,r)=>{const i=new Map,s=new WeakMap,o=new WeakMap,a=[],l=new e(n,r),c=new WeakMap;return l.addEventListener("stop",({isTrusted:u})=>{u&&setTimeout(()=>a.shift())}),l.addEventListener=(u=>(f,g,v)=>{let _=g;if(typeof g=="function")if(f==="dataavailable"){const b=[];_=y=>{const[[p,m]=[!1,!1]]=a;p&&!m?b.push(y):g.call(l,y)},i.set(g,b),s.set(g,_)}else f==="error"?(_=b=>{b instanceof ErrorEvent?g.call(l,b):g.call(l,new ErrorEvent("error",{error:b.error}))},o.set(g,_)):f==="stop"&&(_=b=>{for(const[y,p]of i.entries())if(p.length>0){const[m]=p;p.length>1&&Object.defineProperty(m,"data",{value:new Blob(p.map(({data:w})=>w),{type:m.data.type})}),p.length=0,y.call(l,m)}g.call(l,b)},c.set(g,_));return u.call(l,f,_,v)})(l.addEventListener),l.removeEventListener=(u=>(f,g,v)=>{let _=g;if(typeof g=="function"){if(f==="dataavailable"){i.delete(g);const b=s.get(g);b!==void 0&&(_=b)}else if(f==="error"){const b=o.get(g);b!==void 0&&(_=b)}else if(f==="stop"){const b=c.get(g);b!==void 0&&(_=b)}}return u.call(l,f,_,v)})(l.removeEventListener),l.start=(u=>f=>{if(r.mimeType!==void 0&&r.mimeType.startsWith("audio/")&&n.getVideoTracks().length>0)throw t();return l.state==="inactive"&&a.push([f!==void 0,!0]),f===void 0?u.call(l):u.call(l,f)})(l.start),l.stop=(u=>()=>{l.state!=="inactive"&&(a[0][1]=!1),u.call(l)})(l.stop),l},U1=()=>{try{return new DOMException("","NotSupportedError")}catch(t){return t.code=9,t.name="NotSupportedError",t}},c4=t=>(e,n,r,i=2)=>{const s=t(e,n);if(s===null)return s;const{length:o,value:a}=s;if(r==="master")return{content:null,length:o};if(n+o+a>e.byteLength)return null;if(r==="binary"){const l=(a/Float32Array.BYTES_PER_ELEMENT-1)/i,c=Array.from({length:i},()=>new Float32Array(l));for(let u=0;u<l;u+=1){const f=u*i+1;for(let g=0;g<i;g+=1)c[g][u]=e.getFloat32(n+o+(f+g)*Float32Array.BYTES_PER_ELEMENT,!0)}return{content:c,length:o+a}}return{content:null,length:o+a}},f4=t=>(e,n)=>{const r=t(e,n);if(r===null)return r;const{length:i,value:s}=r;return s===35?{length:i,type:"binary"}:s===46||s===97||s===88713574||s===106212971||s===139690087||s===172351395||s===256095861?{length:i,type:"master"}:{length:i,type:"unknown"}},d4=t=>(e,n)=>{const r=t(e,n);if(r===null)return r;const i=n+Math.floor((r-1)/8);if(i+r>e.byteLength)return null;let o=e.getUint8(i)&(1<<8-r%8)-1;for(let a=1;a<r;a+=1)o=(o<<8)+e.getUint8(i+a);return{length:r,value:o}},Dh=Symbol.observable||"@@observable";function h4(t){return Symbol.observable||(typeof t=="function"&&t.prototype&&t.prototype[Symbol.observable]?(t.prototype[Dh]=t.prototype[Symbol.observable],delete t.prototype[Symbol.observable]):(t[Dh]=t[Symbol.observable],delete t[Symbol.observable])),t}const xu=()=>{},Fh=t=>{throw t};function p4(t){return t?t.next&&t.error&&t.complete?t:{complete:(t.complete??xu).bind(t),error:(t.error??Fh).bind(t),next:(t.next??xu).bind(t)}:{complete:xu,error:Fh,next:xu}}const m4=t=>(e,n,r)=>t(i=>{const s=o=>i.next(o);return e.addEventListener(n,s,r),()=>e.removeEventListener(n,s,r)}),_4=((t,e)=>{const n=()=>{},r=i=>typeof i[0]=="function";return i=>{const s=(...o)=>{const a=i(r(o)?e({next:o[0]}):e(...o));return a!==void 0?a:n};return s[Symbol.observable]=()=>({subscribe:(...o)=>({unsubscribe:s(...o)})}),t(s)}})(h4,p4),$h=m4(_4),g4=(t,e,n)=>async r=>{const i=new t([n],{type:"application/javascript; charset=utf-8"}),s=e.createObjectURL(i);try{await r(s)}finally{e.revokeObjectURL(s)}},b4=t=>({data:e})=>{const{id:n}=e;if(n!==null){const r=t.get(n);if(r!==void 0){const{reject:i,resolve:s}=r;t.delete(n),e.error===void 0?s(e.result):i(new Error(e.error.message))}}},w4=t=>(e,n)=>(r,i=[])=>new Promise((s,o)=>{const a=t(e);e.set(a,{reject:o,resolve:s}),n.postMessage({id:a,...r},i)}),y4=(t,e,n,r)=>(i,s,o={})=>{const a=new i(s,"recorder-audio-worklet-processor",{...o,channelCountMode:"explicit",numberOfInputs:1,numberOfOutputs:0}),l=new Map,c=e(l,a.port),u=n(a.port,"message")(t(l));a.port.start();let f="inactive";return Object.defineProperties(a,{pause:{get(){return async()=>(r(["recording"],f),f="paused",c({method:"pause"}))}},port:{get(){throw new Error("The port of a RecorderAudioWorkletNode can't be accessed.")}},record:{get(){return async g=>(r(["inactive"],f),f="recording",c({method:"record",params:{encoderPort:g}},[g]))}},resume:{get(){return async()=>(r(["paused"],f),f="recording",c({method:"resume"}))}},stop:{get(){return async()=>{r(["paused","recording"],f),f="stopped";try{await c({method:"stop"})}finally{u()}}}}}),a},v4=(t,e)=>{if(!t.includes(e))throw new Error(`Expected the state to be ${t.map(n=>`"${n}"`).join(" or ")} but it was "${e}".`)},E4=g4(Blob,URL,'(()=>{"use strict";class e extends AudioWorkletProcessor{constructor(){super(),this._encoderPort=null,this._numberOfChannels=0,this._state="inactive",this.port.onmessage=e=>{let{data:t}=e;"pause"===t.method?"active"===this._state||"recording"===this._state?(this._state="paused",this._sendAcknowledgement(t.id)):this._sendUnexpectedStateError(t.id):"record"===t.method?"inactive"===this._state?(this._encoderPort=t.params.encoderPort,this._state="active",this._sendAcknowledgement(t.id)):this._sendUnexpectedStateError(t.id):"resume"===t.method?"paused"===this._state?(this._state="active",this._sendAcknowledgement(t.id)):this._sendUnexpectedStateError(t.id):"stop"===t.method?"active"!==this._state&&"paused"!==this._state&&"recording"!==this._state||null===this._encoderPort?this._sendUnexpectedStateError(t.id):(this._stop(this._encoderPort),this._sendAcknowledgement(t.id)):"number"==typeof t.id&&this.port.postMessage({error:{code:-32601,message:"The requested method is not supported."},id:t.id})}}process(e){let[t]=e;if("inactive"===this._state||"paused"===this._state)return!0;if("active"===this._state){if(void 0===t)throw new Error("No channelData was received for the first input.");if(0===t.length)return!0;this._state="recording"}if("recording"===this._state&&null!==this._encoderPort){if(void 0===t)throw new Error("No channelData was received for the first input.");return 0===t.length?this._encoderPort.postMessage(Array.from({length:this._numberOfChannels},(()=>128))):(this._encoderPort.postMessage(t,t.map((e=>{let{buffer:t}=e;return t}))),this._numberOfChannels=t.length),!0}return!1}_sendAcknowledgement(e){this.port.postMessage({id:e,result:null})}_sendUnexpectedStateError(e){this.port.postMessage({error:{code:-32603,message:"The internal state does not allow to process the given message."},id:e})}_stop(e){e.postMessage([]),e.close(),this._encoderPort=null,this._state="stopped"}}e.parameterDescriptors=[],registerProcessor("recorder-audio-worklet-processor",e)})();'),S4=y4(b4,w4(V1),$h,v4),Nh=(t,e,n)=>({endTime:e,insertTime:n,type:"exponentialRampToValue",value:t}),Vh=(t,e,n)=>({endTime:e,insertTime:n,type:"linearRampToValue",value:t}),W1=(t,e)=>({startTime:e,type:"setValue",value:t}),Hh=(t,e,n)=>({duration:n,startTime:e,type:"setValueCurve",values:t}),xh=(t,e,{startTime:n,target:r,timeConstant:i})=>r+(e-r)*Math.exp((n-t)/i),aa=t=>t.type==="exponentialRampToValue",Uu=t=>t.type==="linearRampToValue",Ds=t=>aa(t)||Uu(t),G1=t=>t.type==="setValue",ps=t=>t.type==="setValueCurve",Wu=(t,e,n,r)=>{const i=t[e];return i===void 0?r:Ds(i)||G1(i)?i.value:ps(i)?i.values[i.values.length-1]:xh(n,Wu(t,e-1,i.startTime,r),i)},Uh=(t,e,n,r,i)=>n===void 0?[r.insertTime,i]:Ds(n)?[n.endTime,n.value]:G1(n)?[n.startTime,n.value]:ps(n)?[n.startTime+n.duration,n.values[n.values.length-1]]:[n.startTime,Wu(t,e-1,n.startTime,i)],j1=t=>t.type==="cancelAndHold",z1=t=>t.type==="cancelScheduledValues",Fs=t=>j1(t)||z1(t)?t.cancelTime:aa(t)||Uu(t)?t.endTime:t.startTime,Wh=(t,e,n,{endTime:r,value:i})=>n===i?i:0<n&&0<i||n<0&&i<0?n*(i/n)**((t-e)/(r-e)):0,Gh=(t,e,n,{endTime:r,value:i})=>n+(t-e)/(r-e)*(i-n),T4=(t,e)=>{const n=Math.floor(e),r=Math.ceil(e);return n===r?t[n]:(1-(e-n))*t[n]+(1-(r-e))*t[r]},k4=(t,{duration:e,startTime:n,values:r})=>{const i=(t-n)/e*(r.length-1);return T4(r,i)},Gu=t=>t.type==="setTarget";class A4{constructor(e){this._automationEvents=[],this._currenTime=0,this._defaultValue=e}[Symbol.iterator](){return this._automationEvents[Symbol.iterator]()}add(e){const n=Fs(e);if(j1(e)||z1(e)){const r=this._automationEvents.findIndex(s=>z1(e)&&ps(s)?s.startTime+s.duration>=n:Fs(s)>=n),i=this._automationEvents[r];if(r!==-1&&(this._automationEvents=this._automationEvents.slice(0,r)),j1(e)){const s=this._automationEvents[this._automationEvents.length-1];if(i!==void 0&&Ds(i)){if(s!==void 0&&Gu(s))throw new Error("The internal list is malformed.");const o=s===void 0?i.insertTime:ps(s)?s.startTime+s.duration:Fs(s),a=s===void 0?this._defaultValue:ps(s)?s.values[s.values.length-1]:s.value,l=aa(i)?Wh(n,o,a,i):Gh(n,o,a,i),c=aa(i)?Nh(l,n,this._currenTime):Vh(l,n,this._currenTime);this._automationEvents.push(c)}if(s!==void 0&&Gu(s)&&this._automationEvents.push(W1(this.getValue(n),n)),s!==void 0&&ps(s)&&s.startTime+s.duration>n){const o=n-s.startTime,a=(s.values.length-1)/s.duration,l=Math.max(2,1+Math.ceil(o*a)),c=o/(l-1)*a,u=s.values.slice(0,l);if(c<1)for(let f=1;f<l;f+=1){const g=c*f%1;u[f]=s.values[f-1]*(1-g)+s.values[f]*g}this._automationEvents[this._automationEvents.length-1]=Hh(u,s.startTime,o)}}}else{const r=this._automationEvents.findIndex(o=>Fs(o)>n),i=r===-1?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[r-1];if(i!==void 0&&ps(i)&&Fs(i)+i.duration>n)return!1;const s=aa(e)?Nh(e.value,e.endTime,this._currenTime):Uu(e)?Vh(e.value,n,this._currenTime):e;if(r===-1)this._automationEvents.push(s);else{if(ps(e)&&n+e.duration>Fs(this._automationEvents[r]))return!1;this._automationEvents.splice(r,0,s)}}return!0}flush(e){const n=this._automationEvents.findIndex(r=>Fs(r)>e);if(n>1){const r=this._automationEvents.slice(n-1),i=r[0];Gu(i)&&r.unshift(W1(Wu(this._automationEvents,n-2,i.startTime,this._defaultValue),i.startTime)),this._automationEvents=r}}getValue(e){if(this._automationEvents.length===0)return this._defaultValue;const n=this._automationEvents.findIndex(o=>Fs(o)>e),r=this._automationEvents[n],i=(n===-1?this._automationEvents.length:n)-1,s=this._automationEvents[i];if(s!==void 0&&Gu(s)&&(r===void 0||!Ds(r)||r.insertTime>e))return xh(e,Wu(this._automationEvents,i-1,s.startTime,this._defaultValue),s);if(s!==void 0&&G1(s)&&(r===void 0||!Ds(r)))return s.value;if(s!==void 0&&ps(s)&&(r===void 0||!Ds(r)||s.startTime+s.duration>e))return e<s.startTime+s.duration?k4(e,s):s.values[s.values.length-1];if(s!==void 0&&Ds(s)&&(r===void 0||!Ds(r)))return s.value;if(r!==void 0&&aa(r)){const[o,a]=Uh(this._automationEvents,i,s,r,this._defaultValue);return Wh(e,o,a,r)}if(r!==void 0&&Uu(r)){const[o,a]=Uh(this._automationEvents,i,s,r,this._defaultValue);return Gh(e,o,a,r)}return this._defaultValue}}const C4=t=>({cancelTime:t,type:"cancelAndHold"}),M4=t=>({cancelTime:t,type:"cancelScheduledValues"}),R4=(t,e)=>({endTime:e,type:"exponentialRampToValue",value:t}),L4=(t,e)=>({endTime:e,type:"linearRampToValue",value:t}),P4=(t,e,n)=>({startTime:e,target:t,timeConstant:n,type:"setTarget"}),I4=()=>new DOMException("","AbortError"),O4=t=>(e,n,[r,i,s],o)=>{t(e[i],[n,r,s],a=>a[0]===n&&a[1]===r,o)},B4=t=>(e,n,r)=>{const i=[];for(let s=0;s<r.numberOfInputs;s+=1)i.push(new Set);t.set(e,{activeInputs:i,outputs:new Set,passiveInputs:new WeakMap,renderer:n})},D4=t=>(e,n)=>{t.set(e,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:n})},la=new WeakSet,jh=new WeakMap,zh=new WeakMap,Xh=new WeakMap,Yh=new WeakMap,Kh=new WeakMap,qh=new WeakMap,X1=new WeakMap,Y1=new WeakMap,K1=new WeakMap,Zh={construct(){return Zh}},F4=t=>{try{const e=new Proxy(t,Zh);new e}catch{return!1}return!0},Jh=/^import(?:(?:[\s]+[\w]+|(?:[\s]+[\w]+[\s]*,)?[\s]*\{[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?(?:[\s]*,[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?)*[\s]*}|(?:[\s]+[\w]+[\s]*,)?[\s]*\*[\s]+as[\s]+[\w]+)[\s]+from)?(?:[\s]*)("([^"\\]|\\.)+"|'([^'\\]|\\.)+')(?:[\s]*);?/,Qh=(t,e)=>{const n=[];let r=t.replace(/^[\s]+/,""),i=r.match(Jh);for(;i!==null;){const s=i[1].slice(1,-1),o=i[0].replace(/([\s]+)?;?$/,"").replace(s,new URL(s,e).toString());n.push(o),r=r.slice(i[0].length).replace(/^[\s]+/,""),i=r.match(Jh)}return[n.join(";"),r]},ep=t=>{if(t!==void 0&&!Array.isArray(t))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},tp=t=>{if(!F4(t))throw new TypeError("The given value for processorCtor should be a constructor.");if(t.prototype===null||typeof t.prototype!="object")throw new TypeError("The given value for processorCtor should have a prototype.")},$4=(t,e,n,r,i,s,o,a,l,c,u,f,g)=>{let v=0;return(_,b,y={credentials:"omit"})=>{const p=u.get(_);if(p!==void 0&&p.has(b))return Promise.resolve();const m=c.get(_);if(m!==void 0){const h=m.get(b);if(h!==void 0)return h}const w=s(_),C=w.audioWorklet===void 0?i(b).then(([h,A])=>{const[L,$]=Qh(h,A),P=`${L};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${$}
})})(window,'_AWGS')`;return n(P)}).then(()=>{const h=g._AWGS.pop();if(h===void 0)throw new SyntaxError;r(w.currentTime,w.sampleRate,()=>h(class{},void 0,(A,L)=>{if(A.trim()==="")throw e();const $=Y1.get(w);if($!==void 0){if($.has(A))throw e();tp(L),ep(L.parameterDescriptors),$.set(A,L)}else tp(L),ep(L.parameterDescriptors),Y1.set(w,new Map([[A,L]]))},w.sampleRate,void 0,void 0))}):Promise.all([i(b),Promise.resolve(t(f,f))]).then(([[h,A],L])=>{const $=v+1;v=$;const[P,I]=Qh(h,A),E=`${P};((AudioWorkletProcessor,registerProcessor)=>{${I}
})(${L?"AudioWorkletProcessor":"class extends AudioWorkletProcessor {__b=new WeakSet();constructor(){super();(p=>p.postMessage=(q=>(m,t)=>q.call(p,m,t?t.filter(u=>!this.__b.has(u)):t))(p.postMessage))(this.port)}}"},(n,p)=>registerProcessor(n,class extends p{${L?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${L?"":"i.forEach(this.__c);o.forEach(this.__c);this.__c(Object.values(p));"}return super.process(i.map(j=>j.some(k=>k.length===0)?[]:j),o,p)}}));registerProcessor('__sac${$}',class extends AudioWorkletProcessor{process(){return !1}})`,F=new Blob([E],{type:"application/javascript; charset=utf-8"}),N=URL.createObjectURL(F);return w.audioWorklet.addModule(N,y).then(()=>{if(a(w))return w;const Y=o(w);return Y.audioWorklet.addModule(N,y).then(()=>Y)}).then(Y=>{if(l===null)throw new SyntaxError;try{new l(Y,`__sac${$}`)}catch{throw new SyntaxError}}).finally(()=>URL.revokeObjectURL(N))});return m===void 0?c.set(_,new Map([[b,C]])):m.set(b,C),C.then(()=>{const h=u.get(_);h===void 0?u.set(_,new Set([b])):h.add(b)}).finally(()=>{const h=c.get(_);h!==void 0&&h.delete(b)}),C}},Bi=(t,e)=>{const n=t.get(e);if(n===void 0)throw new Error("A value with the given key could not be found.");return n},ju=(t,e)=>{const n=Array.from(t).filter(e);if(n.length>1)throw Error("More than one element was found.");if(n.length===0)throw Error("No element was found.");const[r]=n;return t.delete(r),r},np=(t,e,n,r)=>{const i=Bi(t,e),s=ju(i,o=>o[0]===n&&o[1]===r);return i.size===0&&t.delete(e),s},gl=t=>Bi(qh,t),zu=t=>{if(la.has(t))throw new Error("The AudioNode is already stored.");la.add(t),gl(t).forEach(e=>e(!0))},rp=t=>"port"in t,q1=t=>{if(!la.has(t))throw new Error("The AudioNode is not stored.");la.delete(t),gl(t).forEach(e=>e(!1))},Z1=(t,e)=>{!rp(t)&&e.every(n=>n.size===0)&&q1(t)},N4=(t,e,n,r,i,s,o,a,l,c,u,f,g)=>{const v=new WeakMap;return(_,b,y,p,m)=>{const{activeInputs:w,passiveInputs:C}=s(b),{outputs:h}=s(_),A=a(_),L=$=>{const P=l(b),I=l(_);if($){const x=np(C,_,y,p);t(w,_,x,!1),!m&&!f(_)&&n(I,P,y,p),g(b)&&zu(b)}else{const x=r(w,_,y,p);e(C,p,x,!1),!m&&!f(_)&&i(I,P,y,p);const ae=o(b);if(ae===0)u(b)&&Z1(b,w);else{const V=v.get(b);V!==void 0&&clearTimeout(V),v.set(b,setTimeout(()=>{u(b)&&Z1(b,w)},ae*1e3))}}};return c(h,[b,y,p],$=>$[0]===b&&$[1]===y&&$[2]===p,!0)?(A.add(L),u(_)?t(w,_,[y,p,L],!0):e(C,p,[_,y,L],!0),!0):!1}},V4=t=>(e,n,[r,i,s],o)=>{const a=e.get(r);a===void 0?e.set(r,new Set([[i,n,s]])):t(a,[i,n,s],l=>l[0]===i&&l[1]===n,o)},H4=t=>(e,n)=>{const r=t(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});n.connect(r).connect(e.destination);const i=()=>{n.removeEventListener("ended",i),n.disconnect(r),r.disconnect()};n.addEventListener("ended",i)},x4=t=>(e,n)=>{t(e).add(n)},ip=(t,e)=>t.context===e,sp=t=>{try{t.copyToChannel(new Float32Array(1),0,-1)}catch{return!1}return!0},ao=()=>new DOMException("","IndexSizeError"),U4=t=>{t.getChannelData=(e=>n=>{try{return e.call(t,n)}catch(r){throw r.code===12?ao():r}})(t.getChannelData)},W4={numberOfChannels:1},G4=(t,e,n,r,i,s,o,a)=>{let l=null;return class h_{constructor(u){if(i===null)throw new Error("Missing the native OfflineAudioContext constructor.");const{length:f,numberOfChannels:g,sampleRate:v}={...W4,...u};l===null&&(l=new i(1,1,44100));const _=r!==null&&e(s,s)?new r({length:f,numberOfChannels:g,sampleRate:v}):l.createBuffer(g,f,v);if(_.numberOfChannels===0)throw n();return typeof _.copyFromChannel!="function"?(o(_),U4(_)):e(sp,()=>sp(_))||a(_),t.add(_),_}static[Symbol.hasInstance](u){return u!==null&&typeof u=="object"&&Object.getPrototypeOf(u)===h_.prototype||t.has(u)}}},Xu=-34028234663852886e22,J1=-Xu,lo=t=>la.has(t),j4={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},z4=(t,e,n,r,i,s,o,a)=>class extends t{constructor(c,u){const f=s(c),g={...j4,...u},v=i(f,g),_=o(f),b=_?e():null;super(c,!1,v,b),this._audioBufferSourceNodeRenderer=b,this._isBufferNullified=!1,this._isBufferSet=g.buffer!==null,this._nativeAudioBufferSourceNode=v,this._onended=null,this._playbackRate=n(this,_,v.playbackRate,J1,Xu)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(c){if(this._nativeAudioBufferSourceNode.buffer=c,c!==null){if(this._isBufferSet)throw r();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(c){this._nativeAudioBufferSourceNode.loop=c}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(c){this._nativeAudioBufferSourceNode.loopEnd=c}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(c){this._nativeAudioBufferSourceNode.loopStart=c}get onended(){return this._onended}set onended(c){const u=typeof c=="function"?a(this,c):null;this._nativeAudioBufferSourceNode.onended=u;const f=this._nativeAudioBufferSourceNode.onended;this._onended=f!==null&&f===u?c:f}get playbackRate(){return this._playbackRate}start(c=0,u=0,f){if(this._nativeAudioBufferSourceNode.start(c,u,f),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.start=f===void 0?[c,u]:[c,u,f]),this.context.state!=="closed"){zu(this);const g=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",g),lo(this)&&q1(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",g)}}stop(c=0){this._nativeAudioBufferSourceNode.stop(c),this._audioBufferSourceNodeRenderer!==null&&(this._audioBufferSourceNodeRenderer.stop=c)}},X4=(t,e,n,r,i)=>()=>{const s=new WeakMap;let o=null,a=null;const l=async(c,u)=>{let f=n(c);const g=ip(f,u);if(!g){const v={buffer:f.buffer,channelCount:f.channelCount,channelCountMode:f.channelCountMode,channelInterpretation:f.channelInterpretation,loop:f.loop,loopEnd:f.loopEnd,loopStart:f.loopStart,playbackRate:f.playbackRate.value};f=e(u,v),o!==null&&f.start(...o),a!==null&&f.stop(a)}return s.set(u,f),g?await t(u,c.playbackRate,f.playbackRate):await r(u,c.playbackRate,f.playbackRate),await i(c,u,f),f};return{set start(c){o=c},set stop(c){a=c},render(c,u){const f=s.get(u);return f!==void 0?Promise.resolve(f):l(c,u)}}},Y4=t=>"playbackRate"in t,K4=t=>"frequency"in t&&"gain"in t,q4=t=>"offset"in t,Z4=t=>!("frequency"in t)&&"gain"in t,J4=t=>"detune"in t&&"frequency"in t,Q4=t=>"pan"in t,Kr=t=>Bi(jh,t),bl=t=>Bi(Xh,t),Q1=(t,e)=>{const{activeInputs:n}=Kr(t);n.forEach(i=>i.forEach(([s])=>{e.includes(t)||Q1(s,[...e,t])}));const r=Y4(t)?[t.playbackRate]:rp(t)?Array.from(t.parameters.values()):K4(t)?[t.Q,t.detune,t.frequency,t.gain]:q4(t)?[t.offset]:Z4(t)?[t.gain]:J4(t)?[t.detune,t.frequency]:Q4(t)?[t.pan]:[];for(const i of r){const s=bl(i);s!==void 0&&s.activeInputs.forEach(([o])=>Q1(o,e))}lo(t)&&q1(t)},ew=t=>{Q1(t.destination,[])},tw=t=>t===void 0||typeof t=="number"||typeof t=="string"&&(t==="balanced"||t==="interactive"||t==="playback"),nw=(t,e,n,r,i,s,o,a)=>class extends t{constructor(c,u){const f=s(c),g=o(f),v=i(f,u,g),_=g?e(a):null;super(c,!1,v,_),this._isNodeOfNativeOfflineAudioContext=g,this._nativeAudioDestinationNode=v}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(c){if(this._isNodeOfNativeOfflineAudioContext)throw r();if(c>this._nativeAudioDestinationNode.maxChannelCount)throw n();this._nativeAudioDestinationNode.channelCount=c}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(c){if(this._isNodeOfNativeOfflineAudioContext)throw r();this._nativeAudioDestinationNode.channelCountMode=c}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}},rw=t=>{const e=new WeakMap,n=async(r,i)=>{const s=i.destination;return e.set(i,s),await t(r,i,s),s};return{render(r,i){const s=e.get(i);return s!==void 0?Promise.resolve(s):n(r,i)}}},iw=(t,e,n,r,i,s,o,a)=>(l,c)=>{const u=c.listener,f=()=>{const h=new Float32Array(1),A=e(c,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),L=o(c);let $=!1,P=[0,0,-1,0,1,0],I=[0,0,0];const x=()=>{if($)return;$=!0;const F=r(c,256,9,0);F.onaudioprocess=({inputBuffer:N})=>{const Y=[s(N,h,0),s(N,h,1),s(N,h,2),s(N,h,3),s(N,h,4),s(N,h,5)];Y.some((J,j)=>J!==P[j])&&(u.setOrientation(...Y),P=Y);const K=[s(N,h,6),s(N,h,7),s(N,h,8)];K.some((J,j)=>J!==I[j])&&(u.setPosition(...K),I=K)},A.connect(F)},ae=F=>N=>{N!==P[F]&&(P[F]=N,u.setOrientation(...P))},V=F=>N=>{N!==I[F]&&(I[F]=N,u.setPosition(...I))},E=(F,N,Y)=>{const K=n(c,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:N});K.connect(A,0,F),K.start(),Object.defineProperty(K.offset,"defaultValue",{get(){return N}});const J=t({context:l},L,K.offset,J1,Xu);return a(J,"value",j=>()=>j.call(J),j=>B=>{try{j.call(J,B)}catch(M){if(M.code!==9)throw M}x(),L&&Y(B)}),J.cancelAndHoldAtTime=(j=>L?()=>{throw i()}:(...B)=>{const M=j.apply(J,B);return x(),M})(J.cancelAndHoldAtTime),J.cancelScheduledValues=(j=>L?()=>{throw i()}:(...B)=>{const M=j.apply(J,B);return x(),M})(J.cancelScheduledValues),J.exponentialRampToValueAtTime=(j=>L?()=>{throw i()}:(...B)=>{const M=j.apply(J,B);return x(),M})(J.exponentialRampToValueAtTime),J.linearRampToValueAtTime=(j=>L?()=>{throw i()}:(...B)=>{const M=j.apply(J,B);return x(),M})(J.linearRampToValueAtTime),J.setTargetAtTime=(j=>L?()=>{throw i()}:(...B)=>{const M=j.apply(J,B);return x(),M})(J.setTargetAtTime),J.setValueAtTime=(j=>L?()=>{throw i()}:(...B)=>{const M=j.apply(J,B);return x(),M})(J.setValueAtTime),J.setValueCurveAtTime=(j=>L?()=>{throw i()}:(...B)=>{const M=j.apply(J,B);return x(),M})(J.setValueCurveAtTime),J};return{forwardX:E(0,0,ae(0)),forwardY:E(1,0,ae(1)),forwardZ:E(2,-1,ae(2)),positionX:E(6,0,V(0)),positionY:E(7,0,V(1)),positionZ:E(8,0,V(2)),upX:E(3,0,ae(3)),upY:E(4,1,ae(4)),upZ:E(5,0,ae(5))}},{forwardX:g,forwardY:v,forwardZ:_,positionX:b,positionY:y,positionZ:p,upX:m,upY:w,upZ:C}=u.forwardX===void 0?f():u;return{get forwardX(){return g},get forwardY(){return v},get forwardZ(){return _},get positionX(){return b},get positionY(){return y},get positionZ(){return p},get upX(){return m},get upY(){return w},get upZ(){return C}}},Yu=t=>"context"in t,wl=t=>Yu(t[0]),uo=(t,e,n,r)=>{for(const i of t)if(n(i)){if(r)return!1;throw Error("The set contains at least one similar element.")}return t.add(e),!0},op=(t,e,[n,r],i)=>{uo(t,[e,n,r],s=>s[0]===e&&s[1]===n,i)},ap=(t,[e,n,r],i)=>{const s=t.get(e);s===void 0?t.set(e,new Set([[n,r]])):uo(s,[n,r],o=>o[0]===n,i)},lp=t=>"inputs"in t,ef=(t,e,n,r)=>{if(lp(e)){const i=e.inputs[r];return t.connect(i,n,0),[i,n,0]}return t.connect(e,n,r),[e,n,r]},up=(t,e,n)=>{for(const r of t)if(r[0]===e&&r[1]===n)return t.delete(r),r;return null},sw=(t,e,n)=>ju(t,r=>r[0]===e&&r[1]===n),cp=(t,e)=>{if(!gl(t).delete(e))throw new Error("Missing the expected event listener.")},fp=(t,e,n)=>{const r=Bi(t,e),i=ju(r,s=>s[0]===n);return r.size===0&&t.delete(e),i},tf=(t,e,n,r)=>{lp(e)?t.disconnect(e.inputs[r],n,0):t.disconnect(e,n,r)},Di=t=>Bi(zh,t),yl=t=>Bi(Yh,t),co=t=>X1.has(t),Ku=t=>!la.has(t),dp=(t,e)=>new Promise(n=>{if(e!==null)n(!0);else{const r=t.createScriptProcessor(256,1,1),i=t.createGain(),s=t.createBuffer(1,2,44100),o=s.getChannelData(0);o[0]=1,o[1]=1;const a=t.createBufferSource();a.buffer=s,a.loop=!0,a.connect(r).connect(t.destination),a.connect(i),a.disconnect(i),r.onaudioprocess=l=>{const c=l.inputBuffer.getChannelData(0);Array.prototype.some.call(c,u=>u===1)?n(!0):n(!1),a.stop(),r.onaudioprocess=null,a.disconnect(r),r.disconnect(t.destination)},a.start()}}),nf=(t,e)=>{const n=new Map;for(const r of t)for(const i of r){const s=n.get(i);n.set(i,s===void 0?1:s+1)}n.forEach((r,i)=>e(i,r))},qu=t=>"context"in t,ow=t=>{const e=new Map;t.connect=(n=>(r,i=0,s=0)=>{const o=qu(r)?n(r,i,s):n(r,i),a=e.get(r);return a===void 0?e.set(r,[{input:s,output:i}]):a.every(l=>l.input!==s||l.output!==i)&&a.push({input:s,output:i}),o})(t.connect.bind(t)),t.disconnect=(n=>(r,i,s)=>{if(n.apply(t),r===void 0)e.clear();else if(typeof r=="number")for(const[o,a]of e){const l=a.filter(c=>c.output!==r);l.length===0?e.delete(o):e.set(o,l)}else if(e.has(r))if(i===void 0)e.delete(r);else{const o=e.get(r);if(o!==void 0){const a=o.filter(l=>l.output!==i&&(l.input!==s||s===void 0));a.length===0?e.delete(r):e.set(r,a)}}for(const[o,a]of e)a.forEach(l=>{qu(o)?t.connect(o,l.output,l.input):t.connect(o,l.output)})})(t.disconnect)},aw=(t,e,n,r)=>{const{activeInputs:i,passiveInputs:s}=bl(e),{outputs:o}=Kr(t),a=gl(t),l=c=>{const u=Di(t),f=yl(e);if(c){const g=fp(s,t,n);op(i,t,g,!1),!r&&!co(t)&&u.connect(f,n)}else{const g=sw(i,t,n);ap(s,g,!1),!r&&!co(t)&&u.disconnect(f,n)}};return uo(o,[e,n],c=>c[0]===e&&c[1]===n,!0)?(a.add(l),lo(t)?op(i,t,[n,l],!0):ap(s,[t,n,l],!0),!0):!1},lw=(t,e,n,r)=>{const{activeInputs:i,passiveInputs:s}=Kr(e),o=up(i[r],t,n);return o===null?[np(s,t,n,r)[2],!1]:[o[2],!0]},uw=(t,e,n)=>{const{activeInputs:r,passiveInputs:i}=bl(e),s=up(r,t,n);return s===null?[fp(i,t,n)[1],!1]:[s[2],!0]},rf=(t,e,n,r,i)=>{const[s,o]=lw(t,n,r,i);if(s!==null&&(cp(t,s),o&&!e&&!co(t)&&tf(Di(t),Di(n),r,i)),lo(n)){const{activeInputs:a}=Kr(n);Z1(n,a)}},sf=(t,e,n,r)=>{const[i,s]=uw(t,n,r);i!==null&&(cp(t,i),s&&!e&&!co(t)&&Di(t).disconnect(yl(n),r))},cw=(t,e)=>{const n=Kr(t),r=[];for(const i of n.outputs)wl(i)?rf(t,e,...i):sf(t,e,...i),r.push(i[0]);return n.outputs.clear(),r},fw=(t,e,n)=>{const r=Kr(t),i=[];for(const s of r.outputs)s[1]===n&&(wl(s)?rf(t,e,...s):sf(t,e,...s),i.push(s[0]),r.outputs.delete(s));return i},dw=(t,e,n,r,i)=>{const s=Kr(t);return Array.from(s.outputs).filter(o=>o[0]===n&&(r===void 0||o[1]===r)&&(i===void 0||o[2]===i)).map(o=>(wl(o)?rf(t,e,...o):sf(t,e,...o),s.outputs.delete(o),o[0]))},hw=(t,e,n,r,i,s,o,a,l,c,u,f,g,v,_,b)=>class extends c{constructor(p,m,w,C){super(w),this._context=p,this._nativeAudioNode=w;const h=u(p);f(h)&&n(dp,()=>dp(h,b))!==!0&&ow(w),zh.set(this,w),qh.set(this,new Set),p.state!=="closed"&&m&&zu(this),t(this,C,w)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(p){this._nativeAudioNode.channelCount=p}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(p){this._nativeAudioNode.channelCountMode=p}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(p){this._nativeAudioNode.channelInterpretation=p}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(p,m=0,w=0){if(m<0||m>=this._nativeAudioNode.numberOfOutputs)throw i();const C=u(this._context),h=_(C);if(g(p)||v(p))throw s();if(Yu(p)){const $=Di(p);try{const I=ef(this._nativeAudioNode,$,m,w),x=Ku(this);(h||x)&&this._nativeAudioNode.disconnect(...I),this.context.state!=="closed"&&!x&&Ku(p)&&zu(p)}catch(I){throw I.code===12?s():I}if(e(this,p,m,w,h)){const I=l([this],p);nf(I,r(h))}return p}const A=yl(p);if(A.name==="playbackRate"&&A.maxValue===1024)throw o();try{this._nativeAudioNode.connect(A,m),(h||Ku(this))&&this._nativeAudioNode.disconnect(A,m)}catch($){throw $.code===12?s():$}if(aw(this,p,m,h)){const $=l([this],p);nf($,r(h))}}disconnect(p,m,w){let C;const h=u(this._context),A=_(h);if(p===void 0)C=cw(this,A);else if(typeof p=="number"){if(p<0||p>=this.numberOfOutputs)throw i();C=fw(this,A,p)}else{if(m!==void 0&&(m<0||m>=this.numberOfOutputs)||Yu(p)&&w!==void 0&&(w<0||w>=p.numberOfInputs))throw i();if(C=dw(this,A,p,m,w),C.length===0)throw s()}for(const L of C){const $=l([this],L);nf($,a)}}},pw=(t,e,n,r,i,s,o,a,l,c,u,f,g)=>(v,_,b,y=null,p=null)=>{const m=b.value,w=new A4(m),C=_?r(w):null,h={get defaultValue(){return m},get maxValue(){return y===null?b.maxValue:y},get minValue(){return p===null?b.minValue:p},get value(){return b.value},set value(A){b.value=A,h.setValueAtTime(A,v.context.currentTime)},cancelAndHoldAtTime(A){if(typeof b.cancelAndHoldAtTime=="function")C===null&&w.flush(v.context.currentTime),w.add(i(A)),b.cancelAndHoldAtTime(A);else{const L=Array.from(w).pop();C===null&&w.flush(v.context.currentTime),w.add(i(A));const $=Array.from(w).pop();b.cancelScheduledValues(A),L!==$&&$!==void 0&&($.type==="exponentialRampToValue"?b.exponentialRampToValueAtTime($.value,$.endTime):$.type==="linearRampToValue"?b.linearRampToValueAtTime($.value,$.endTime):$.type==="setValue"?b.setValueAtTime($.value,$.startTime):$.type==="setValueCurve"&&b.setValueCurveAtTime($.values,$.startTime,$.duration))}return h},cancelScheduledValues(A){return C===null&&w.flush(v.context.currentTime),w.add(s(A)),b.cancelScheduledValues(A),h},exponentialRampToValueAtTime(A,L){if(A===0)throw new RangeError;if(!Number.isFinite(L)||L<0)throw new RangeError;const $=v.context.currentTime;return C===null&&w.flush($),Array.from(w).length===0&&(w.add(c(m,$)),b.setValueAtTime(m,$)),w.add(o(A,L)),b.exponentialRampToValueAtTime(A,L),h},linearRampToValueAtTime(A,L){const $=v.context.currentTime;return C===null&&w.flush($),Array.from(w).length===0&&(w.add(c(m,$)),b.setValueAtTime(m,$)),w.add(a(A,L)),b.linearRampToValueAtTime(A,L),h},setTargetAtTime(A,L,$){return C===null&&w.flush(v.context.currentTime),w.add(l(A,L,$)),b.setTargetAtTime(A,L,$),h},setValueAtTime(A,L){return C===null&&w.flush(v.context.currentTime),w.add(c(A,L)),b.setValueAtTime(A,L),h},setValueCurveAtTime(A,L,$){const P=A instanceof Float32Array?A:new Float32Array(A);if(f!==null&&f.name==="webkitAudioContext"){const I=L+$,x=v.context.sampleRate,ae=Math.ceil(L*x),V=Math.floor(I*x),E=V-ae,F=new Float32Array(E);for(let Y=0;Y<E;Y+=1){const K=(P.length-1)/$*((ae+Y)/x-L),J=Math.floor(K),j=Math.ceil(K);F[Y]=J===j?P[J]:(1-(K-J))*P[J]+(1-(j-K))*P[j]}C===null&&w.flush(v.context.currentTime),w.add(u(F,L,$)),b.setValueCurveAtTime(F,L,$);const N=V/x;N<I&&g(h,F[F.length-1],N),g(h,P[P.length-1],I)}else C===null&&w.flush(v.context.currentTime),w.add(u(P,L,$)),b.setValueCurveAtTime(P,L,$);return h}};return n.set(h,b),e.set(h,v),t(h,C),h},mw=t=>({replay(e){for(const n of t)if(n.type==="exponentialRampToValue"){const{endTime:r,value:i}=n;e.exponentialRampToValueAtTime(i,r)}else if(n.type==="linearRampToValue"){const{endTime:r,value:i}=n;e.linearRampToValueAtTime(i,r)}else if(n.type==="setTarget"){const{startTime:r,target:i,timeConstant:s}=n;e.setTargetAtTime(i,r,s)}else if(n.type==="setValue"){const{startTime:r,value:i}=n;e.setValueAtTime(i,r)}else if(n.type==="setValueCurve"){const{duration:r,startTime:i,values:s}=n;e.setValueCurveAtTime(s,i,r)}else throw new Error("Can't apply an unknown automation.")}});class hp{constructor(e){this._map=new Map(e)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(e,n=null){return this._map.forEach((r,i)=>e.call(n,r,i,this))}get(e){return this._map.get(e)}has(e){return this._map.has(e)}keys(){return this._map.keys()}values(){return this._map.values()}}const _w={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}},gw=(t,e,n,r,i,s,o,a,l,c,u,f,g,v)=>class extends e{constructor(b,y,p){var m;const w=a(b),C=l(w),h=u({..._w,...p});g(h);const A=Y1.get(w),L=A==null?void 0:A.get(y),$=C||w.state!=="closed"?w:(m=o(w))!==null&&m!==void 0?m:w,P=i($,C?null:b.baseLatency,c,y,L,h),I=C?r(y,h,L):null;super(b,!0,P,I);const x=[];P.parameters.forEach((V,E)=>{const F=n(this,C,V);x.push([E,F])}),this._nativeAudioWorkletNode=P,this._onprocessorerror=null,this._parameters=new hp(x),C&&t(w,this);const{activeInputs:ae}=s(this);f(P,ae)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(b){const y=typeof b=="function"?v(this,b):null;this._nativeAudioWorkletNode.onprocessorerror=y;const p=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=p!==null&&p===y?b:p}get parameters(){return this._parameters===null?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}};function Zu(t,e,n,r,i){if(typeof t.copyFromChannel=="function")e[n].byteLength===0&&(e[n]=new Float32Array(128)),t.copyFromChannel(e[n],r,i);else{const s=t.getChannelData(r);if(e[n].byteLength===0)e[n]=s.slice(i,i+128);else{const o=new Float32Array(s.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);e[n].set(o)}}}const pp=(t,e,n,r,i)=>{typeof t.copyToChannel=="function"?e[n].byteLength!==0&&t.copyToChannel(e[n],r,i):e[n].byteLength!==0&&t.getChannelData(r).set(e[n],i)},Ju=(t,e)=>{const n=[];for(let r=0;r<t;r+=1){const i=[],s=typeof e=="number"?e:e[r];for(let o=0;o<s;o+=1)i.push(new Float32Array(128));n.push(i)}return n},bw=(t,e)=>{const n=Bi(K1,t),r=Di(e);return Bi(n,r)},ww=async(t,e,n,r,i,s,o)=>{const a=e===null?Math.ceil(t.context.length/128)*128:e.length,l=r.channelCount*r.numberOfInputs,c=i.reduce((y,p)=>y+p,0),u=c===0?null:n.createBuffer(c,a,n.sampleRate);if(s===void 0)throw new Error("Missing the processor constructor.");const f=Kr(t),g=await bw(n,t),v=Ju(r.numberOfInputs,r.channelCount),_=Ju(r.numberOfOutputs,i),b=Array.from(t.parameters.keys()).reduce((y,p)=>({...y,[p]:new Float32Array(128)}),{});for(let y=0;y<a;y+=128){if(r.numberOfInputs>0&&e!==null)for(let p=0;p<r.numberOfInputs;p+=1)for(let m=0;m<r.channelCount;m+=1)Zu(e,v[p],m,m,y);s.parameterDescriptors!==void 0&&e!==null&&s.parameterDescriptors.forEach(({name:p},m)=>{Zu(e,b,p,l+m,y)});for(let p=0;p<r.numberOfInputs;p+=1)for(let m=0;m<i[p];m+=1)_[p][m].byteLength===0&&(_[p][m]=new Float32Array(128));try{const p=v.map((w,C)=>f.activeInputs[C].size===0?[]:w),m=o(y/n.sampleRate,n.sampleRate,()=>g.process(p,_,b));if(u!==null)for(let w=0,C=0;w<r.numberOfOutputs;w+=1){for(let h=0;h<i[w];h+=1)pp(u,_[w],h,C+h,y);C+=i[w]}if(!m)break}catch(p){t.dispatchEvent(new ErrorEvent("processorerror",{colno:p.colno,filename:p.filename,lineno:p.lineno,message:p.message}));break}}return u},yw=(t,e,n,r,i,s,o,a,l,c,u,f,g,v,_,b)=>(y,p,m)=>{const w=new WeakMap;let C=null;const h=async(A,L)=>{let $=u(A),P=null;const I=ip($,L),x=Array.isArray(p.outputChannelCount)?p.outputChannelCount:Array.from(p.outputChannelCount);if(f===null){const ae=x.reduce((N,Y)=>N+Y,0),V=i(L,{channelCount:Math.max(1,ae),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,ae)}),E=[];for(let N=0;N<A.numberOfOutputs;N+=1)E.push(r(L,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:x[N]}));const F=o(L,{channelCount:p.channelCount,channelCountMode:p.channelCountMode,channelInterpretation:p.channelInterpretation,gain:1});F.connect=e.bind(null,E),F.disconnect=l.bind(null,E),P=[V,E,F]}else I||($=new f(L,y));if(w.set(L,P===null?$:P[2]),P!==null){if(C===null){if(m===void 0)throw new Error("Missing the processor constructor.");if(g===null)throw new Error("Missing the native OfflineAudioContext constructor.");const Y=A.channelCount*A.numberOfInputs,K=m.parameterDescriptors===void 0?0:m.parameterDescriptors.length,J=Y+K;C=ww(A,J===0?null:await(async()=>{const B=new g(J,Math.ceil(A.context.length/128)*128,L.sampleRate),M=[],S=[];for(let re=0;re<p.numberOfInputs;re+=1)M.push(o(B,{channelCount:p.channelCount,channelCountMode:p.channelCountMode,channelInterpretation:p.channelInterpretation,gain:1})),S.push(i(B,{channelCount:p.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:p.channelCount}));const R=await Promise.all(Array.from(A.parameters.values()).map(async re=>{const W=s(B,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:re.value});return await v(B,re,W.offset),W})),X=r(B,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,Y+K)});for(let re=0;re<p.numberOfInputs;re+=1){M[re].connect(S[re]);for(let W=0;W<p.channelCount;W+=1)S[re].connect(X,W,re*p.channelCount+W)}for(const[re,W]of R.entries())W.connect(X,0,Y+re),W.start(0);return X.connect(B.destination),await Promise.all(M.map(re=>_(A,B,re))),b(B)})(),L,p,x,m,c)}const ae=await C,V=n(L,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[E,F,N]=P;ae!==null&&(V.buffer=ae,V.start(0)),V.connect(E);for(let Y=0,K=0;Y<A.numberOfOutputs;Y+=1){const J=F[Y];for(let j=0;j<x[Y];j+=1)E.connect(J,K+j,j);K+=x[Y]}return N}if(I)for(const[ae,V]of A.parameters.entries())await t(L,V,$.parameters.get(ae));else for(const[ae,V]of A.parameters.entries())await v(L,V,$.parameters.get(ae));return await _(A,L,$),$};return{render(A,L){a(L,A);const $=w.get(L);return $!==void 0?Promise.resolve($):h(A,L)}}},vw=(t,e)=>(n,r)=>{const i=e.get(n);if(i!==void 0)return i;const s=t.get(n);if(s!==void 0)return s;try{const o=r();return o instanceof Promise?(t.set(n,o),o.catch(()=>!1).then(a=>(t.delete(n),e.set(n,a),a))):(e.set(n,o),o)}catch{return e.set(n,!1),!1}},Ew=t=>(e,n,r)=>t(n,e,r),Sw=t=>(e,n,r=0,i=0)=>{const s=e[r];if(s===void 0)throw t();return qu(n)?s.connect(n,0,i):s.connect(n,0)},Tw=t=>e=>(t[0]=e,t[0]),kw=(t,e,n,r,i,s,o,a)=>(l,c)=>{const u=e.get(l);if(u===void 0)throw new Error("Missing the expected cycle count.");const f=s(l.context),g=a(f);if(u===c){if(e.delete(l),!g&&o(l)){const v=r(l),{outputs:_}=n(l);for(const b of _)if(wl(b)){const y=r(b[0]);t(v,y,b[1],b[2])}else{const y=i(b[0]);v.connect(y,b[1])}}}else e.set(l,u-c)},Aw=t=>(e,n,r,i)=>t(e[i],s=>s[0]===n&&s[1]===r),Cw=t=>(e,n)=>{t(e).delete(n)},Mw=t=>"delayTime"in t,Rw=(t,e,n)=>function r(i,s){const o=Yu(s)?s:n(t,s);if(Mw(o))return[];if(i[0]===o)return[i];if(i.includes(o))return[];const{outputs:a}=e(o);return Array.from(a).map(l=>r([...i,o],l[0])).reduce((l,c)=>l.concat(c),[])},Qu=(t,e,n)=>{const r=e[n];if(r===void 0)throw t();return r},Lw=t=>(e,n=void 0,r=void 0,i=0)=>n===void 0?e.forEach(s=>s.disconnect()):typeof n=="number"?Qu(t,e,n).disconnect():qu(n)?r===void 0?e.forEach(s=>s.disconnect(n)):i===void 0?Qu(t,e,r).disconnect(n,0):Qu(t,e,r).disconnect(n,0,i):r===void 0?e.forEach(s=>s.disconnect(n)):Qu(t,e,r).disconnect(n,0),Pw=t=>e=>new Promise((n,r)=>{if(t===null){r(new SyntaxError);return}const i=t.document.head;if(i===null)r(new SyntaxError);else{const s=t.document.createElement("script"),o=new Blob([e],{type:"application/javascript"}),a=URL.createObjectURL(o),l=t.onerror,c=()=>{t.onerror=l,URL.revokeObjectURL(a)};t.onerror=(u,f,g,v,_)=>{if(f===a||f===t.location.href&&g===1&&v===1)return c(),r(_),!1;if(l!==null)return l(u,f,g,v,_)},s.onerror=()=>{c(),r(new SyntaxError)},s.onload=()=>{c(),n()},s.src=a,s.type="module",i.appendChild(s)}}),Iw=t=>class{constructor(n){this._nativeEventTarget=n,this._listeners=new WeakMap}addEventListener(n,r,i){if(r!==null){let s=this._listeners.get(r);s===void 0&&(s=t(this,r),typeof r=="function"&&this._listeners.set(r,s)),this._nativeEventTarget.addEventListener(n,s,i)}}dispatchEvent(n){return this._nativeEventTarget.dispatchEvent(n)}removeEventListener(n,r,i){const s=r===null?void 0:this._listeners.get(r);this._nativeEventTarget.removeEventListener(n,s===void 0?null:s,i)}},Ow=t=>(e,n,r)=>{Object.defineProperties(t,{currentFrame:{configurable:!0,get(){return Math.round(e*n)}},currentTime:{configurable:!0,get(){return e}}});try{return r()}finally{t!==null&&(delete t.currentFrame,delete t.currentTime)}},Bw=t=>async e=>{try{const n=await fetch(e);if(n.ok)return[await n.text(),n.url]}catch{}throw t()},Dw=(t,e)=>n=>e(t,n),Fw=t=>e=>{const n=t(e);if(n.renderer===null)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return n.renderer},$w=t=>e=>{var n;return(n=t.get(e))!==null&&n!==void 0?n:0},Nw=t=>e=>{const n=t(e);if(n.renderer===null)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return n.renderer},Vw=t=>e=>t.get(e),Fi=()=>new DOMException("","InvalidStateError"),Hw=t=>e=>{const n=t.get(e);if(n===void 0)throw Fi();return n},xw=(t,e)=>n=>{let r=t.get(n);if(r!==void 0)return r;if(e===null)throw new Error("Missing the native OfflineAudioContext constructor.");return r=new e(1,1,44100),t.set(n,r),r},Uw=t=>e=>{const n=t.get(e);if(n===void 0)throw new Error("The context has no set of AudioWorkletNodes.");return n},Ww=()=>new DOMException("","InvalidAccessError"),Gw=(t,e,n,r,i,s)=>o=>(a,l)=>{const c=t.get(a);if(c===void 0){if(!o&&s(a)){const u=r(a),{outputs:f}=n(a);for(const g of f)if(wl(g)){const v=r(g[0]);e(u,v,g[1],g[2])}else{const v=i(g[0]);u.disconnect(v,g[1])}}t.set(a,l)}else t.set(a,c+l)},jw=t=>e=>t!==null&&e instanceof t,zw=t=>e=>t!==null&&typeof t.AudioNode=="function"&&e instanceof t.AudioNode,Xw=t=>e=>t!==null&&typeof t.AudioParam=="function"&&e instanceof t.AudioParam,Yw=t=>e=>t!==null&&e instanceof t,Kw=t=>t!==null&&t.isSecureContext,qw=(t,e,n,r)=>class extends t{constructor(s,o){const a=n(s),l=e(a,o);if(r(a))throw new TypeError;super(s,!0,l,null),this._nativeMediaStreamAudioSourceNode=l}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}},Zw=(t,e,n,r,i)=>class extends r{constructor(o={}){if(i===null)throw new Error("Missing the native AudioContext constructor.");let a;try{a=new i(o)}catch(u){throw u.code===12&&u.message==="sampleRate is not in range"?e():u}if(a===null)throw n();if(!tw(o.latencyHint))throw new TypeError(`The provided value '${o.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(o.sampleRate!==void 0&&a.sampleRate!==o.sampleRate)throw e();super(a,2);const{latencyHint:l}=o,{sampleRate:c}=a;if(this._baseLatency=typeof a.baseLatency=="number"?a.baseLatency:l==="balanced"?512/c:l==="interactive"||l===void 0?256/c:l==="playback"?1024/c:Math.max(2,Math.min(128,Math.round(l*c/128)))*128/c,this._nativeAudioContext=a,i.name==="webkitAudioContext"?(this._nativeGainNode=a.createGain(),this._nativeOscillatorNode=a.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(a.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,a.state==="running"){this._state="suspended";const u=()=>{this._state==="suspended"&&(this._state=null),a.removeEventListener("statechange",u)};a.addEventListener("statechange",u)}}get baseLatency(){return this._baseLatency}get state(){return this._state!==null?this._state:this._nativeAudioContext.state}close(){return this.state==="closed"?this._nativeAudioContext.close().then(()=>{throw t()}):(this._state==="suspended"&&(this._state=null),this._nativeAudioContext.close().then(()=>{this._nativeGainNode!==null&&this._nativeOscillatorNode!==null&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),ew(this)}))}resume(){return this._state==="suspended"?new Promise((o,a)=>{const l=()=>{this._nativeAudioContext.removeEventListener("statechange",l),this._nativeAudioContext.state==="running"?o():this.resume().then(o,a)};this._nativeAudioContext.addEventListener("statechange",l)}):this._nativeAudioContext.resume().catch(o=>{throw o===void 0||o.code===15?t():o})}suspend(){return this._nativeAudioContext.suspend().catch(o=>{throw o===void 0?t():o})}},Jw=(t,e,n,r,i,s)=>class extends n{constructor(a,l){super(a),this._nativeContext=a,Kh.set(this,a),r(a)&&i.set(a,new Set),this._destination=new t(this,l),this._listener=e(this,a),this._onstatechange=null}get currentTime(){return this._nativeContext.currentTime}get destination(){return this._destination}get listener(){return this._listener}get onstatechange(){return this._onstatechange}set onstatechange(a){const l=typeof a=="function"?s(this,a):null;this._nativeContext.onstatechange=l;const c=this._nativeContext.onstatechange;this._onstatechange=c!==null&&c===l?a:c}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}},mp=t=>{const e=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{const n=t.decodeAudioData(e.buffer,()=>{});return n===void 0?!1:(n.catch(()=>{}),!0)}catch{}return!1},Qw=(t,e)=>(n,r,i)=>{const s=new Set;return n.connect=(o=>(a,l=0,c=0)=>{const u=s.size===0;if(e(a))return o.call(n,a,l,c),t(s,[a,l,c],f=>f[0]===a&&f[1]===l&&f[2]===c,!0),u&&r(),a;o.call(n,a,l),t(s,[a,l],f=>f[0]===a&&f[1]===l,!0),u&&r()})(n.connect),n.disconnect=(o=>(a,l,c)=>{const u=s.size>0;if(a===void 0)o.apply(n),s.clear();else if(typeof a=="number"){o.call(n,a);for(const g of s)g[1]===a&&s.delete(g)}else{e(a)?o.call(n,a,l,c):o.call(n,a,l);for(const g of s)g[0]===a&&(l===void 0||g[1]===l)&&(c===void 0||g[2]===c)&&s.delete(g)}const f=s.size===0;u&&f&&i()})(n.disconnect),n},fo=(t,e,n)=>{const r=e[n];r!==void 0&&r!==t[n]&&(t[n]=r)},vl=(t,e)=>{fo(t,e,"channelCount"),fo(t,e,"channelCountMode"),fo(t,e,"channelInterpretation")},e6=t=>t===null?null:t.hasOwnProperty("AudioBuffer")?t.AudioBuffer:null,of=(t,e,n)=>{const r=e[n];r!==void 0&&r!==t[n].value&&(t[n].value=r)},t6=t=>{t.start=(e=>{let n=!1;return(r=0,i=0,s)=>{if(n)throw Fi();e.call(t,r,i,s),n=!0}})(t.start)},_p=t=>{t.start=(e=>(n=0,r=0,i)=>{if(typeof i=="number"&&i<0||r<0||n<0)throw new RangeError("The parameters can't be negative.");e.call(t,n,r,i)})(t.start)},gp=t=>{t.stop=(e=>(n=0)=>{if(n<0)throw new RangeError("The parameter can't be negative.");e.call(t,n)})(t.stop)},n6=(t,e,n,r,i,s,o,a,l,c,u)=>(f,g)=>{const v=f.createBufferSource();return vl(v,g),of(v,g,"playbackRate"),fo(v,g,"buffer"),fo(v,g,"loop"),fo(v,g,"loopEnd"),fo(v,g,"loopStart"),e(n,()=>n(f))||t6(v),e(r,()=>r(f))||l(v),e(i,()=>i(f))||c(v,f),e(s,()=>s(f))||_p(v),e(o,()=>o(f))||u(v,f),e(a,()=>a(f))||gp(v),t(f,v),v},r6=t=>t===null?null:t.hasOwnProperty("AudioContext")?t.AudioContext:t.hasOwnProperty("webkitAudioContext")?t.webkitAudioContext:null,i6=(t,e)=>(n,r,i)=>{const s=n.destination;if(s.channelCount!==r)try{s.channelCount=r}catch{}i&&s.channelCountMode!=="explicit"&&(s.channelCountMode="explicit"),s.maxChannelCount===0&&Object.defineProperty(s,"maxChannelCount",{value:r});const o=t(n,{channelCount:r,channelCountMode:s.channelCountMode,channelInterpretation:s.channelInterpretation,gain:1});return e(o,"channelCount",a=>()=>a.call(o),a=>l=>{a.call(o,l);try{s.channelCount=l}catch(c){if(l>s.maxChannelCount)throw c}}),e(o,"channelCountMode",a=>()=>a.call(o),a=>l=>{a.call(o,l),s.channelCountMode=l}),e(o,"channelInterpretation",a=>()=>a.call(o),a=>l=>{a.call(o,l),s.channelInterpretation=l}),Object.defineProperty(o,"maxChannelCount",{get:()=>s.maxChannelCount}),o.connect(s),o},s6=t=>t===null?null:t.hasOwnProperty("AudioWorkletNode")?t.AudioWorkletNode:null,o6=t=>{const{port1:e}=new MessageChannel;try{e.postMessage(t)}finally{e.close()}},a6=(t,e,n,r,i)=>(s,o,a,l,c,u)=>{if(a!==null)try{const f=new a(s,l,u),g=new Map;let v=null;if(Object.defineProperties(f,{channelCount:{get:()=>u.channelCount,set:()=>{throw t()}},channelCountMode:{get:()=>"explicit",set:()=>{throw t()}},onprocessorerror:{get:()=>v,set:_=>{typeof v=="function"&&f.removeEventListener("processorerror",v),v=typeof _=="function"?_:null,typeof v=="function"&&f.addEventListener("processorerror",v)}}}),f.addEventListener=(_=>(...b)=>{if(b[0]==="processorerror"){const y=typeof b[1]=="function"?b[1]:typeof b[1]=="object"&&b[1]!==null&&typeof b[1].handleEvent=="function"?b[1].handleEvent:null;if(y!==null){const p=g.get(b[1]);p!==void 0?b[1]=p:(b[1]=m=>{m.type==="error"?(Object.defineProperties(m,{type:{value:"processorerror"}}),y(m)):y(new ErrorEvent(b[0],{...m}))},g.set(y,b[1]))}}return _.call(f,"error",b[1],b[2]),_.call(f,...b)})(f.addEventListener),f.removeEventListener=(_=>(...b)=>{if(b[0]==="processorerror"){const y=g.get(b[1]);y!==void 0&&(g.delete(b[1]),b[1]=y)}return _.call(f,"error",b[1],b[2]),_.call(f,b[0],b[1],b[2])})(f.removeEventListener),u.numberOfOutputs!==0){const _=n(s,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return f.connect(_).connect(s.destination),i(f,()=>_.disconnect(),()=>_.connect(s.destination))}return f}catch(f){throw f.code===11?r():f}if(c===void 0)throw r();return o6(u),e(s,o,c,u)},l6=(t,e)=>t===null?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(t*e))))),u6=t=>new Promise((e,n)=>{const{port1:r,port2:i}=new MessageChannel;r.onmessage=({data:s})=>{r.close(),i.close(),e(s)},r.onmessageerror=({data:s})=>{r.close(),i.close(),n(s)},i.postMessage(t)}),c6=async(t,e)=>{const n=await u6(e);return new t(n)},f6=(t,e,n,r)=>{let i=K1.get(t);i===void 0&&(i=new WeakMap,K1.set(t,i));const s=c6(n,r);return i.set(e,s),s},d6=(t,e,n,r,i,s,o,a,l,c,u,f,g)=>(v,_,b,y)=>{if(y.numberOfInputs===0&&y.numberOfOutputs===0)throw l();const p=Array.isArray(y.outputChannelCount)?y.outputChannelCount:Array.from(y.outputChannelCount);if(p.some(Te=>Te<1))throw l();if(p.length!==y.numberOfOutputs)throw e();if(y.channelCountMode!=="explicit")throw l();const m=y.channelCount*y.numberOfInputs,w=p.reduce((Te,Le)=>Te+Le,0),C=b.parameterDescriptors===void 0?0:b.parameterDescriptors.length;if(m+C>6||w>6)throw l();const h=new MessageChannel,A=[],L=[];for(let Te=0;Te<y.numberOfInputs;Te+=1)A.push(o(v,{channelCount:y.channelCount,channelCountMode:y.channelCountMode,channelInterpretation:y.channelInterpretation,gain:1})),L.push(i(v,{channelCount:y.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:y.channelCount}));const $=[];if(b.parameterDescriptors!==void 0)for(const{defaultValue:Te,maxValue:Le,minValue:Fe,name:Ze}of b.parameterDescriptors){const O=s(v,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:y.parameterData[Ze]!==void 0?y.parameterData[Ze]:Te===void 0?0:Te});Object.defineProperties(O.offset,{defaultValue:{get:()=>Te===void 0?0:Te},maxValue:{get:()=>Le===void 0?J1:Le},minValue:{get:()=>Fe===void 0?Xu:Fe}}),$.push(O)}const P=r(v,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,m+C)}),I=l6(_,v.sampleRate),x=a(v,I,m+C,Math.max(1,w)),ae=i(v,{channelCount:Math.max(1,w),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,w)}),V=[];for(let Te=0;Te<y.numberOfOutputs;Te+=1)V.push(r(v,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:p[Te]}));for(let Te=0;Te<y.numberOfInputs;Te+=1){A[Te].connect(L[Te]);for(let Le=0;Le<y.channelCount;Le+=1)L[Te].connect(P,Le,Te*y.channelCount+Le)}const E=new hp(b.parameterDescriptors===void 0?[]:b.parameterDescriptors.map(({name:Te},Le)=>{const Fe=$[Le];return Fe.connect(P,0,m+Le),Fe.start(0),[Te,Fe.offset]}));P.connect(x);let F=y.channelInterpretation,N=null;const Y=y.numberOfOutputs===0?[x]:V,K={get bufferSize(){return I},get channelCount(){return y.channelCount},set channelCount(Te){throw n()},get channelCountMode(){return y.channelCountMode},set channelCountMode(Te){throw n()},get channelInterpretation(){return F},set channelInterpretation(Te){for(const Le of A)Le.channelInterpretation=Te;F=Te},get context(){return x.context},get inputs(){return A},get numberOfInputs(){return y.numberOfInputs},get numberOfOutputs(){return y.numberOfOutputs},get onprocessorerror(){return N},set onprocessorerror(Te){typeof N=="function"&&K.removeEventListener("processorerror",N),N=typeof Te=="function"?Te:null,typeof N=="function"&&K.addEventListener("processorerror",N)},get parameters(){return E},get port(){return h.port2},addEventListener(...Te){return x.addEventListener(Te[0],Te[1],Te[2])},connect:t.bind(null,Y),disconnect:c.bind(null,Y),dispatchEvent(...Te){return x.dispatchEvent(Te[0])},removeEventListener(...Te){return x.removeEventListener(Te[0],Te[1],Te[2])}},J=new Map;h.port1.addEventListener=(Te=>(...Le)=>{if(Le[0]==="message"){const Fe=typeof Le[1]=="function"?Le[1]:typeof Le[1]=="object"&&Le[1]!==null&&typeof Le[1].handleEvent=="function"?Le[1].handleEvent:null;if(Fe!==null){const Ze=J.get(Le[1]);Ze!==void 0?Le[1]=Ze:(Le[1]=O=>{u(v.currentTime,v.sampleRate,()=>Fe(O))},J.set(Fe,Le[1]))}}return Te.call(h.port1,Le[0],Le[1],Le[2])})(h.port1.addEventListener),h.port1.removeEventListener=(Te=>(...Le)=>{if(Le[0]==="message"){const Fe=J.get(Le[1]);Fe!==void 0&&(J.delete(Le[1]),Le[1]=Fe)}return Te.call(h.port1,Le[0],Le[1],Le[2])})(h.port1.removeEventListener);let j=null;Object.defineProperty(h.port1,"onmessage",{get:()=>j,set:Te=>{typeof j=="function"&&h.port1.removeEventListener("message",j),j=typeof Te=="function"?Te:null,typeof j=="function"&&(h.port1.addEventListener("message",j),h.port1.start())}}),b.prototype.port=h.port1;let B=null;f6(v,K,b,y).then(Te=>B=Te);const S=Ju(y.numberOfInputs,y.channelCount),R=Ju(y.numberOfOutputs,p),X=b.parameterDescriptors===void 0?[]:b.parameterDescriptors.reduce((Te,{name:Le})=>({...Te,[Le]:new Float32Array(128)}),{});let re=!0;const W=()=>{y.numberOfOutputs>0&&x.disconnect(ae);for(let Te=0,Le=0;Te<y.numberOfOutputs;Te+=1){const Fe=V[Te];for(let Ze=0;Ze<p[Te];Ze+=1)ae.disconnect(Fe,Le+Ze,Ze);Le+=p[Te]}},z=new Map;x.onaudioprocess=({inputBuffer:Te,outputBuffer:Le})=>{if(B!==null){const Fe=f(K);for(let Ze=0;Ze<I;Ze+=128){for(let O=0;O<y.numberOfInputs;O+=1)for(let H=0;H<y.channelCount;H+=1)Zu(Te,S[O],H,H,Ze);b.parameterDescriptors!==void 0&&b.parameterDescriptors.forEach(({name:O},H)=>{Zu(Te,X,O,m+H,Ze)});for(let O=0;O<y.numberOfInputs;O+=1)for(let H=0;H<p[O];H+=1)R[O][H].byteLength===0&&(R[O][H]=new Float32Array(128));try{const O=S.map((Pe,xe)=>{if(Fe[xe].size>0)return z.set(xe,I/128),Pe;const nt=z.get(xe);return nt===void 0?[]:(Pe.every(Oe=>Oe.every(je=>je===0))&&(nt===1?z.delete(xe):z.set(xe,nt-1)),Pe)});re=u(v.currentTime+Ze/v.sampleRate,v.sampleRate,()=>B.process(O,R,X));for(let Pe=0,xe=0;Pe<y.numberOfOutputs;Pe+=1){for(let qe=0;qe<p[Pe];qe+=1)pp(Le,R[Pe],qe,xe+qe,Ze);xe+=p[Pe]}}catch(O){re=!1,K.dispatchEvent(new ErrorEvent("processorerror",{colno:O.colno,filename:O.filename,lineno:O.lineno,message:O.message}))}if(!re){for(let O=0;O<y.numberOfInputs;O+=1){A[O].disconnect(L[O]);for(let H=0;H<y.channelCount;H+=1)L[Ze].disconnect(P,H,O*y.channelCount+H)}if(b.parameterDescriptors!==void 0){const O=b.parameterDescriptors.length;for(let H=0;H<O;H+=1){const Pe=$[H];Pe.disconnect(P,0,m+H),Pe.stop()}}P.disconnect(x),x.onaudioprocess=null,le?W():ve();break}}}};let le=!1;const Me=o(v,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),Ee=()=>x.connect(Me).connect(v.destination),ve=()=>{x.disconnect(Me),Me.disconnect()},ke=()=>{if(re){ve(),y.numberOfOutputs>0&&x.connect(ae);for(let Te=0,Le=0;Te<y.numberOfOutputs;Te+=1){const Fe=V[Te];for(let Ze=0;Ze<p[Te];Ze+=1)ae.connect(Fe,Le+Ze,Ze);Le+=p[Te]}}le=!0},Ne=()=>{re&&(Ee(),W()),le=!1};return Ee(),g(K,ke,Ne)},h6=(t,e)=>(n,r)=>{const i=n.createChannelMerger(r.numberOfInputs);return t!==null&&t.name==="webkitAudioContext"&&e(n,i),vl(i,r),i},p6=t=>{const e=t.numberOfOutputs;Object.defineProperty(t,"channelCount",{get:()=>e,set:n=>{if(n!==e)throw Fi()}}),Object.defineProperty(t,"channelCountMode",{get:()=>"explicit",set:n=>{if(n!=="explicit")throw Fi()}}),Object.defineProperty(t,"channelInterpretation",{get:()=>"discrete",set:n=>{if(n!=="discrete")throw Fi()}})},bp=(t,e)=>{const n=t.createChannelSplitter(e.numberOfOutputs);return vl(n,e),p6(n),n},m6=(t,e,n,r,i)=>(s,o)=>{if(s.createConstantSource===void 0)return n(s,o);const a=s.createConstantSource();return vl(a,o),of(a,o,"offset"),e(r,()=>r(s))||_p(a),e(i,()=>i(s))||gp(a),t(s,a),a},wp=(t,e)=>(t.connect=e.connect.bind(e),t.disconnect=e.disconnect.bind(e),t),_6=(t,e,n,r)=>(i,{offset:s,...o})=>{const a=i.createBuffer(1,2,44100),l=e(i,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),c=n(i,{...o,gain:s}),u=a.getChannelData(0);u[0]=1,u[1]=1,l.buffer=a,l.loop=!0;const f={get bufferSize(){},get channelCount(){return c.channelCount},set channelCount(_){c.channelCount=_},get channelCountMode(){return c.channelCountMode},set channelCountMode(_){c.channelCountMode=_},get channelInterpretation(){return c.channelInterpretation},set channelInterpretation(_){c.channelInterpretation=_},get context(){return c.context},get inputs(){return[]},get numberOfInputs(){return l.numberOfInputs},get numberOfOutputs(){return c.numberOfOutputs},get offset(){return c.gain},get onended(){return l.onended},set onended(_){l.onended=_},addEventListener(..._){return l.addEventListener(_[0],_[1],_[2])},dispatchEvent(..._){return l.dispatchEvent(_[0])},removeEventListener(..._){return l.removeEventListener(_[0],_[1],_[2])},start(_=0){l.start.call(l,_)},stop(_=0){l.stop.call(l,_)}},g=()=>l.connect(c),v=()=>l.disconnect(c);return t(i,l),r(wp(f,c),g,v)},$s=(t,e)=>{const n=t.createGain();return vl(n,e),of(n,e,"gain"),n},g6=(t,{mediaStream:e})=>{const n=e.getAudioTracks();n.sort((s,o)=>s.id<o.id?-1:s.id>o.id?1:0);const r=n.slice(0,1),i=t.createMediaStreamSource(new MediaStream(r));return Object.defineProperty(i,"mediaStream",{value:e}),i},b6=t=>t===null?null:t.hasOwnProperty("OfflineAudioContext")?t.OfflineAudioContext:t.hasOwnProperty("webkitOfflineAudioContext")?t.webkitOfflineAudioContext:null,af=(t,e,n,r)=>t.createScriptProcessor(e,n,r),ho=()=>new DOMException("","NotSupportedError"),w6=(t,e)=>(n,r,i)=>(t(r).replay(i),e(r,n,i)),y6=(t,e,n)=>async(r,i,s)=>{const o=t(r);await Promise.all(o.activeInputs.map((a,l)=>Array.from(a).map(async([c,u])=>{const g=await e(c).render(c,i),v=r.context.destination;!n(c)&&(r!==v||!n(r))&&g.connect(s,u,l)})).reduce((a,l)=>[...a,...l],[]))},v6=(t,e,n)=>async(r,i,s)=>{const o=e(r);await Promise.all(Array.from(o.activeInputs).map(async([a,l])=>{const u=await t(a).render(a,i);n(a)||u.connect(s,l)}))},E6=(t,e,n,r)=>i=>t(mp,()=>mp(i))?Promise.resolve(t(r,r)).then(s=>{if(!s){const o=n(i,512,0,1);i.oncomplete=()=>{o.onaudioprocess=null,o.disconnect()},o.onaudioprocess=()=>i.currentTime,o.connect(i.destination)}return i.startRendering()}):new Promise(s=>{const o=e(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=a=>{o.disconnect(),s(a.renderedBuffer)},o.connect(i.destination),i.startRendering()}),S6=t=>(e,n)=>{t.set(e,n)},T6=t=>()=>{if(t===null)return!1;try{new t({length:1,sampleRate:44100})}catch{return!1}return!0},k6=(t,e)=>async()=>{if(t===null)return!0;if(e===null)return!1;const n=new Blob(['class A extends AudioWorkletProcessor{process(i){this.port.postMessage(i,[i[0][0].buffer])}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),r=new e(1,128,44100),i=URL.createObjectURL(n);let s=!1,o=!1;try{await r.audioWorklet.addModule(i);const a=new t(r,"a",{numberOfOutputs:0}),l=r.createOscillator();a.port.onmessage=()=>s=!0,a.onprocessorerror=()=>o=!0,l.connect(a),l.start(0),await r.startRendering(),await new Promise(c=>setTimeout(c))}catch{}finally{URL.revokeObjectURL(i)}return s&&!o},A6=(t,e)=>()=>{if(e===null)return Promise.resolve(!1);const n=new e(1,1,44100),r=t(n,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise(i=>{n.oncomplete=()=>{r.disconnect(),i(n.currentTime!==0)},n.startRendering()})},C6=()=>new DOMException("","UnknownError"),M6=()=>typeof window>"u"?null:window,R6=(t,e)=>n=>{n.copyFromChannel=(r,i,s=0)=>{const o=t(s),a=t(i);if(a>=n.numberOfChannels)throw e();const l=n.length,c=n.getChannelData(a),u=r.length;for(let f=o<0?-o:0;f+o<l&&f<u;f+=1)r[f]=c[f+o]},n.copyToChannel=(r,i,s=0)=>{const o=t(s),a=t(i);if(a>=n.numberOfChannels)throw e();const l=n.length,c=n.getChannelData(a),u=r.length;for(let f=o<0?-o:0;f+o<l&&f<u;f+=1)c[f+o]=r[f]}},L6=t=>e=>{e.copyFromChannel=(n=>(r,i,s=0)=>{const o=t(s),a=t(i);if(o<e.length)return n.call(e,r,a,o)})(e.copyFromChannel),e.copyToChannel=(n=>(r,i,s=0)=>{const o=t(s),a=t(i);if(o<e.length)return n.call(e,r,a,o)})(e.copyToChannel)},P6=t=>(e,n)=>{const r=n.createBuffer(1,1,44100);e.buffer===null&&(e.buffer=r),t(e,"buffer",i=>()=>{const s=i.call(e);return s===r?null:s},i=>s=>i.call(e,s===null?r:s))},I6=(t,e)=>(n,r)=>{r.channelCount=1,r.channelCountMode="explicit",Object.defineProperty(r,"channelCount",{get:()=>1,set:()=>{throw t()}}),Object.defineProperty(r,"channelCountMode",{get:()=>"explicit",set:()=>{throw t()}});const i=n.createBufferSource();e(r,()=>{const a=r.numberOfInputs;for(let l=0;l<a;l+=1)i.connect(r,0,l)},()=>i.disconnect(r))},O6=(t,e,n)=>t.copyFromChannel===void 0?t.getChannelData(n)[0]:(t.copyFromChannel(e,n),e[0]),lf=(t,e,n,r)=>{let i=t;for(;!i.hasOwnProperty(e);)i=Object.getPrototypeOf(i);const{get:s,set:o}=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(t,e,{get:n(s),set:r(o)})},B6=t=>({...t,outputChannelCount:t.outputChannelCount!==void 0?t.outputChannelCount:t.numberOfInputs===1&&t.numberOfOutputs===1?[t.channelCount]:Array.from({length:t.numberOfOutputs},()=>1)}),yp=(t,e,n)=>{try{t.setValueAtTime(e,n)}catch(r){if(r.code!==9)throw r;yp(t,e,n+1e-7)}},D6=t=>{const e=t.createBufferSource();e.start();try{e.start()}catch{return!0}return!1},F6=t=>{const e=t.createBufferSource(),n=t.createBuffer(1,1,44100);e.buffer=n;try{e.start(0,1)}catch{return!1}return!0},$6=t=>{const e=t.createBufferSource();e.start();try{e.stop()}catch{return!1}return!0},vp=t=>{const e=t.createOscillator();try{e.start(-1)}catch(n){return n instanceof RangeError}return!1},N6=t=>{const e=t.createBuffer(1,1,44100),n=t.createBufferSource();n.buffer=e,n.start(),n.stop();try{return n.stop(),!0}catch{return!1}},Ep=t=>{const e=t.createOscillator();try{e.stop(-1)}catch(n){return n instanceof RangeError}return!1},V6=t=>{const{port1:e,port2:n}=new MessageChannel;try{e.postMessage(t)}finally{e.close(),n.close()}},H6=t=>{t.start=(e=>(n=0,r=0,i)=>{const s=t.buffer,o=s===null?r:Math.min(s.duration,r);s!==null&&o>s.duration-.5/t.context.sampleRate?e.call(t,n,0,0):e.call(t,n,o,i)})(t.start)},x6=(t,e)=>{const n=e.createGain();t.connect(n);const r=(i=>()=>{i.call(t,n),t.removeEventListener("ended",r)})(t.disconnect);t.addEventListener("ended",r),wp(t,n),t.stop=(i=>{let s=!1;return(o=0)=>{if(s)try{i.call(t,o)}catch{n.gain.setValueAtTime(0,o)}else i.call(t,o),s=!0}})(t.stop)},ec=(t,e)=>n=>{const r={value:t};return Object.defineProperties(n,{currentTarget:r,target:r}),typeof e=="function"?e.call(t,n):e.handleEvent.call(t,n)},U6=O4(uo),W6=V4(uo),G6=Aw(ju),j6=$w(new WeakMap),ua=vw(new Map,new WeakMap),zi=M6(),Sp=Fw(Kr),uf=y6(Kr,Sp,co),po=Hw(Kh),ca=b6(zi),ms=Yw(ca),Tp=new WeakMap,kp=Iw(ec),tc=r6(zi),z6=jw(tc),Ap=zw(zi),X6=Xw(zi),El=s6(zi),nc=hw(B4(jh),N4(U6,W6,ef,G6,tf,Kr,j6,gl,Di,uo,lo,co,Ku),ua,Gw(X1,tf,Kr,Di,yl,lo),ao,Ww,ho,kw(ef,X1,Kr,Di,yl,po,lo,ms),Rw(Tp,Kr,Bi),kp,po,z6,Ap,X6,ms,El),Y6=new WeakSet,Cp=e6(zi),Mp=Tw(new Uint32Array(1)),K6=R6(Mp,ao),q6=L6(Mp),Z6=G4(Y6,ua,ho,Cp,ca,T6(Cp),K6,q6),cf=H4($s),Rp=v6(Sp,bl,co),Lp=Ew(Rp),rc=n6(cf,ua,D6,F6,$6,vp,N6,Ep,H6,P6(lf),x6),Pp=w6(Nw(bl),Rp),J6=X4(Lp,rc,Di,Pp,uf),ff=pw(D4(Xh),Tp,Yh,mw,C4,M4,R4,L4,P4,W1,Hh,tc,yp),Q6=z4(nc,J6,ff,Fi,rc,po,ms,ec),e8=nw(nc,rw,ao,Fi,i6($s,lf),po,ms,uf),ic=Qw(uo,Ap),t8=I6(Fi,ic),df=h6(tc,t8),n8=_6(cf,rc,$s,ic),hf=m6(cf,ua,n8,vp,Ep),r8=E6(ua,$s,af,A6($s,ca)),i8=iw(ff,df,hf,af,ho,O6,ms,lf),Ip=new WeakMap,s8=Jw(e8,i8,kp,ms,Ip,ec),Op=Kw(zi),pf=Ow(zi),Bp=new WeakMap,o8=xw(Bp,ca),Dp=Op?$4(ua,ho,Pw(zi),pf,Bw(I4),po,o8,ms,El,new WeakMap,new WeakMap,k6(El,ca),zi):void 0,a8=qw(nc,g6,po,ms),Fp=Uw(Ip),l8=x4(Fp),$p=Sw(ao),u8=Cw(Fp),Np=Lw(ao),Vp=new WeakMap,c8=Dw(Vp,Bi),f8=d6($p,ao,Fi,df,bp,hf,$s,af,ho,Np,pf,c8,ic),d8=a6(Fi,f8,$s,ho,ic),h8=yw(Lp,$p,rc,df,bp,hf,$s,u8,Np,pf,Di,El,ca,Pp,uf,r8),p8=Vw(Bp),m8=S6(Vp),Hp=Op?gw(l8,nc,ff,h8,d8,Kr,p8,po,ms,El,B6,m8,V6,ec):void 0,_8=Zw(Fi,ho,C6,s8,tc),xp="Missing AudioWorklet support. Maybe this is not running in a secure context.",g8=async(t,e,n,r,i)=>{const{encoderId:s,port:o}=await Bh(i,e.sampleRate);if(Hp===void 0)throw new Error(xp);const a=new Q6(e,{buffer:t}),l=new a8(e,{mediaStream:r}),c=S4(Hp,e,{channelCount:n});return{audioBufferSourceNode:a,encoderId:s,mediaStreamAudioSourceNode:l,port:o,recorderAudioWorkletNode:c}},b8=(t,e,n,r)=>(i,s,o)=>{var a;const l=(a=s.getAudioTracks()[0])===null||a===void 0?void 0:a.getSettings().sampleRate,c=new _8({latencyHint:"playback",sampleRate:l}),u=Math.max(1024,Math.ceil(c.baseLatency*c.sampleRate)),f=new Z6({length:u,sampleRate:c.sampleRate}),g=[],v=E4($=>{if(Dp===void 0)throw new Error(xp);return Dp(c,$)});let _=null,b=null,y=null,p=null,m=!0;const w=$=>{i.dispatchEvent(t("dataavailable",{data:new Blob($,{type:o})}))},C=async($,P)=>{const I=await Hu($,P);y===null?g.push(...I):(w(I),p=C($,P))},h=()=>(m=!0,c.resume()),A=()=>{y!==null&&(_!==null&&(s.removeEventListener("addtrack",_),s.removeEventListener("removetrack",_)),b!==null&&clearTimeout(b),y.then(async({encoderId:$,mediaStreamAudioSourceNode:P,recorderAudioWorkletNode:I})=>{p!==null&&(p.catch(()=>{}),p=null),await I.stop(),P.disconnect(I);const x=await Hu($,null);y===null&&await L(),w([...g,...x]),g.length=0,i.dispatchEvent(new Event("stop"))}),y=null)},L=()=>(m=!1,c.suspend());return L(),{get mimeType(){return o},get state(){return y===null?"inactive":m?"recording":"paused"},pause(){if(y===null)throw n();m&&(L(),i.dispatchEvent(new Event("pause")))},resume(){if(y===null)throw n();m||(h(),i.dispatchEvent(new Event("resume")))},start($){var P;if(y!==null)throw n();if(s.getVideoTracks().length>0)throw r();i.dispatchEvent(new Event("start"));const I=s.getAudioTracks(),x=I.length===0?2:(P=I[0].getSettings().channelCount)!==null&&P!==void 0?P:2;y=Promise.all([h(),v.then(()=>g8(f,c,x,s,o))]).then(async([,{audioBufferSourceNode:V,encoderId:E,mediaStreamAudioSourceNode:F,port:N,recorderAudioWorkletNode:Y}])=>(F.connect(Y),await new Promise(K=>{V.onended=K,V.connect(Y),V.start(c.currentTime+u/c.sampleRate)}),V.disconnect(Y),await Y.record(N),$!==void 0&&(p=C(E,$)),{encoderId:E,mediaStreamAudioSourceNode:F,recorderAudioWorkletNode:Y}));const ae=s.getTracks();_=()=>{A(),i.dispatchEvent(new ErrorEvent("error",{error:e()}))},s.addEventListener("addtrack",_),s.addEventListener("removetrack",_),b=setInterval(()=>{const V=s.getTracks();(V.length!==ae.length||V.some((E,F)=>E!==ae[F]))&&_!==null&&_()},1e3)},stop:A}};class mf{constructor(e,n=0,r){if(n<0||r!==void 0&&r<0)throw new RangeError;const i=e.reduce((u,f)=>u+f.byteLength,0);if(n>i||r!==void 0&&n+r>i)throw new RangeError;const s=[],o=r===void 0?i-n:r,a=[];let l=0,c=n;for(const u of e)if(a.length===0)if(u.byteLength>c){l=u.byteLength-c;const f=l>o?o:l;s.push(new DataView(u,c,f)),a.push(u)}else c-=u.byteLength;else if(l<o){l+=u.byteLength;const f=l>o?u.byteLength-l+o:u.byteLength;s.push(new DataView(u,0,f)),a.push(u)}this._buffers=a,this._byteLength=o,this._byteOffset=c,this._dataViews=s,this._internalBuffer=new DataView(new ArrayBuffer(8))}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get byteOffset(){return this._byteOffset}getFloat32(e,n){return this._internalBuffer.setUint8(0,this.getUint8(e+0)),this._internalBuffer.setUint8(1,this.getUint8(e+1)),this._internalBuffer.setUint8(2,this.getUint8(e+2)),this._internalBuffer.setUint8(3,this.getUint8(e+3)),this._internalBuffer.getFloat32(0,n)}getFloat64(e,n){return this._internalBuffer.setUint8(0,this.getUint8(e+0)),this._internalBuffer.setUint8(1,this.getUint8(e+1)),this._internalBuffer.setUint8(2,this.getUint8(e+2)),this._internalBuffer.setUint8(3,this.getUint8(e+3)),this._internalBuffer.setUint8(4,this.getUint8(e+4)),this._internalBuffer.setUint8(5,this.getUint8(e+5)),this._internalBuffer.setUint8(6,this.getUint8(e+6)),this._internalBuffer.setUint8(7,this.getUint8(e+7)),this._internalBuffer.getFloat64(0,n)}getInt16(e,n){return this._internalBuffer.setUint8(0,this.getUint8(e+0)),this._internalBuffer.setUint8(1,this.getUint8(e+1)),this._internalBuffer.getInt16(0,n)}getInt32(e,n){return this._internalBuffer.setUint8(0,this.getUint8(e+0)),this._internalBuffer.setUint8(1,this.getUint8(e+1)),this._internalBuffer.setUint8(2,this.getUint8(e+2)),this._internalBuffer.setUint8(3,this.getUint8(e+3)),this._internalBuffer.getInt32(0,n)}getInt8(e){const[n,r]=this._findDataViewWithOffset(e);return n.getInt8(e-r)}getUint16(e,n){return this._internalBuffer.setUint8(0,this.getUint8(e+0)),this._internalBuffer.setUint8(1,this.getUint8(e+1)),this._internalBuffer.getUint16(0,n)}getUint32(e,n){return this._internalBuffer.setUint8(0,this.getUint8(e+0)),this._internalBuffer.setUint8(1,this.getUint8(e+1)),this._internalBuffer.setUint8(2,this.getUint8(e+2)),this._internalBuffer.setUint8(3,this.getUint8(e+3)),this._internalBuffer.getUint32(0,n)}getUint8(e){const[n,r]=this._findDataViewWithOffset(e);return n.getUint8(e-r)}setFloat32(e,n,r){this._internalBuffer.setFloat32(0,n,r),this.setUint8(e,this._internalBuffer.getUint8(0)),this.setUint8(e+1,this._internalBuffer.getUint8(1)),this.setUint8(e+2,this._internalBuffer.getUint8(2)),this.setUint8(e+3,this._internalBuffer.getUint8(3))}setFloat64(e,n,r){this._internalBuffer.setFloat64(0,n,r),this.setUint8(e,this._internalBuffer.getUint8(0)),this.setUint8(e+1,this._internalBuffer.getUint8(1)),this.setUint8(e+2,this._internalBuffer.getUint8(2)),this.setUint8(e+3,this._internalBuffer.getUint8(3)),this.setUint8(e+4,this._internalBuffer.getUint8(4)),this.setUint8(e+5,this._internalBuffer.getUint8(5)),this.setUint8(e+6,this._internalBuffer.getUint8(6)),this.setUint8(e+7,this._internalBuffer.getUint8(7))}setInt16(e,n,r){this._internalBuffer.setInt16(0,n,r),this.setUint8(e,this._internalBuffer.getUint8(0)),this.setUint8(e+1,this._internalBuffer.getUint8(1))}setInt32(e,n,r){this._internalBuffer.setInt32(0,n,r),this.setUint8(e,this._internalBuffer.getUint8(0)),this.setUint8(e+1,this._internalBuffer.getUint8(1)),this.setUint8(e+2,this._internalBuffer.getUint8(2)),this.setUint8(e+3,this._internalBuffer.getUint8(3))}setInt8(e,n){const[r,i]=this._findDataViewWithOffset(e);r.setInt8(e-i,n)}setUint16(e,n,r){this._internalBuffer.setUint16(0,n,r),this.setUint8(e,this._internalBuffer.getUint8(0)),this.setUint8(e+1,this._internalBuffer.getUint8(1))}setUint32(e,n,r){this._internalBuffer.setUint32(0,n,r),this.setUint8(e,this._internalBuffer.getUint8(0)),this.setUint8(e+1,this._internalBuffer.getUint8(1)),this.setUint8(e+2,this._internalBuffer.getUint8(2)),this.setUint8(e+3,this._internalBuffer.getUint8(3))}setUint8(e,n){const[r,i]=this._findDataViewWithOffset(e);r.setUint8(e-i,n)}_findDataViewWithOffset(e){let n=0;for(const r of this._dataViews){const i=n+r.byteLength;if(e>=n&&e<i)return[r,n];n=i}throw new RangeError}}const w8=(t,e,n)=>(r,i,s,o)=>{const a=[],l=new i(s,{mimeType:"audio/webm;codecs=pcm"});let c=null,u=()=>{};const f=_=>{r.dispatchEvent(t("dataavailable",{data:new Blob(_,{type:o})}))},g=async(_,b)=>{const y=await Hu(_,b);l.state==="inactive"?a.push(...y):(f(y),c=g(_,b))},v=()=>{l.state!=="inactive"&&(c!==null&&(c.catch(()=>{}),c=null),u(),u=()=>{},l.stop())};return l.addEventListener("error",_=>{v(),r.dispatchEvent(new ErrorEvent("error",{error:_.error}))}),l.addEventListener("pause",()=>r.dispatchEvent(new Event("pause"))),l.addEventListener("resume",()=>r.dispatchEvent(new Event("resume"))),l.addEventListener("start",()=>r.dispatchEvent(new Event("start"))),{get mimeType(){return o},get state(){return l.state},pause(){return l.pause()},resume(){return l.resume()},start(_){const[b]=s.getAudioTracks();if(b!==void 0&&l.state==="inactive"){const{channelCount:y,sampleRate:p}=b.getSettings();if(y===void 0)throw new Error("The channelCount is not defined.");if(p===void 0)throw new Error("The sampleRate is not defined.");let m=!1,w=!1,C=0,h=Bh(o,p);u=()=>{w=!0};const A=$h(l,"dataavailable")(({data:L})=>{C+=1;const $=L.arrayBuffer();h=h.then(async({dataView:P=null,elementType:I=null,encoderId:x,port:ae})=>{const V=await $;C-=1;const E=P===null?new mf([V]):new mf([...P.buffers,V],P.byteOffset);if(!m&&l.state==="recording"&&!w){const J=n(E,0);if(J===null)return{dataView:E,elementType:I,encoderId:x,port:ae};const{value:j}=J;if(j!==172351395)return{dataView:P,elementType:I,encoderId:x,port:ae};m=!0}const{currentElementType:F,offset:N,contents:Y}=e(E,I,y),K=N<E.byteLength?new mf(E.buffers,E.byteOffset+N):null;return Y.forEach(J=>ae.postMessage(J,J.map(({buffer:j})=>j))),C===0&&(l.state==="inactive"||w)&&(Hu(x,null).then(J=>{f([...a,...J]),a.length=0,r.dispatchEvent(new Event("stop"))}),ae.postMessage([]),ae.close(),A()),{dataView:K,elementType:F,encoderId:x,port:ae}})});_!==void 0&&h.then(({encoderId:L})=>c=g(L,_))}l.start(100)},stop:v}},y8=()=>typeof window>"u"?null:window,Up=(t,e)=>{if(e>=t.byteLength)return null;const n=t.getUint8(e);if(n>127)return 1;if(n>63)return 2;if(n>31)return 3;if(n>15)return 4;if(n>7)return 5;if(n>3)return 6;if(n>1)return 7;if(n>0)return 8;const r=Up(t,e+1);return r===null?null:r+8},v8=(t,e)=>n=>{const r={value:t};return Object.defineProperties(n,{currentTarget:r,target:r}),typeof e=="function"?e.call(t,n):e.handleEvent.call(t,n)},Wp=[],_f=y8(),E8=a4(_f),Gp=e4(E8),S8=b8(Gp,i4,s4,U1),gf=d4(Up),T8=c4(gf),k8=f4(gf),A8=t4(T8,k8),C8=w8(Gp,A8,gf),M8=r4(_f),R8=l4(_f),L8=o4(u4(U1),U1,S8,C8,Wp,n4(M8,v8),R8),P8=async t=>{Wp.push(await Q5(t))},I8=Ph({characterize:({call:t})=>()=>t("characterize"),encode:({call:t})=>(e,n)=>t("encode",{recordingId:e,timeslice:n}),record:({call:t})=>async(e,n,r)=>{await t("record",{recordingId:e,sampleRate:n,typedArrays:r},r.map(({buffer:i})=>i))}}),O8=t=>{const e=new Worker(t);return I8(e)},B8=`(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,s=536870912,a=2*s,o=function(e,t){return function(r){var o=t.get(r),i=void 0===o?r.size:o<a?o+1:0;if(!r.has(i))return e(r,i);if(r.size<s){for(;r.has(i);)i=Math.floor(Math.random()*a);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,l=r(i),c=o(l,i),u=t(c);e.addUniqueNumber=u,e.generateUniqueNumber=c}(t)}},t={};function r(n){var s=t[n];if(void 0!==s)return s.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,s=(e,t)=>Object.assign(new Error(e),{status:t}),a=t=>s('The handler of the method called "'.concat(t,'" returned an unexpected result.'),e),o=(t,r)=>async o=>{let{data:{id:i,method:l,params:c}}=o;const u=r[l];try{if(void 0===u)throw(e=>s('The requested method called "'.concat(e,'" is not supported.'),n))(l);const r=void 0===c?u():u(c);if(void 0===r)throw(t=>s('The handler of the method called "'.concat(t,'" returned no required result.'),e))(l);const o=r instanceof Promise?await r:r;if(null===i){if(void 0!==o.result)throw a(l)}else{if(void 0===o.result)throw a(l);const{result:e,transferables:r=[]}=o;t.postMessage({id:i,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:i})}};var i=r(455);const l=new Map,c=(e,r,n)=>({...r,connect:t=>{let{port:n}=t;n.start();const s=e(n,r),a=(0,i.generateUniqueNumber)(l);return l.set(a,(()=>{s(),n.close(),l.delete(a)})),{result:a}},disconnect:e=>{let{portId:r}=e;const n=l.get(r);if(void 0===n)throw(e=>s('The specified parameter called "portId" with the given value "'.concat(e,'" does not identify a port connected to this worker.'),t))(r);return n(),{result:null}},isSupported:async()=>{if(await new Promise((e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=t=>{let{data:r}=t;return e(null!==r)},n.postMessage(t,[t])}))){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),u=function(e,t){const r=c(u,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:()=>!0),n=o(e,r);return e.addEventListener("message",n),()=>e.removeEventListener("message",n)},d=e=>e.reduce(((e,t)=>e+t.length),0),h=(e,t)=>{const r=[];let n=0;e:for(;n<t;){const t=e.length;for(let s=0;s<t;s+=1){const t=e[s];void 0===r[s]&&(r[s]=[]);const a=t.shift();if(void 0===a)break e;r[s].push(a),0===s&&(n+=a.length)}}if(n>t){const s=n-t;r.forEach(((t,r)=>{const n=t.pop(),a=n.length-s;t.push(n.subarray(0,a)),e[r].unshift(n.subarray(a))}))}return r},f=new Map,m=(e=>(t,r,n)=>{const s=e.get(t);if(void 0===s){const s={channelDataArrays:n.map((e=>[e])),isComplete:!0,sampleRate:r};return e.set(t,s),s}return s.channelDataArrays.forEach(((e,t)=>e.push(n[t]))),s})(f),p=((e,t)=>(r,n,s,a)=>{const o=s>>3,i="subsequent"===n?0:44,l=r.length,c=e(r[0]),u=new ArrayBuffer(c*l*o+i),d=new DataView(u);return"subsequent"!==n&&t(d,s,l,"complete"===n?c:Number.POSITIVE_INFINITY,a),r.forEach(((e,t)=>{let r=i+t*o;e.forEach((e=>{const t=e.length;for(let n=0;n<t;n+=1){const t=e[n];d.setInt16(r,t<0?32768*Math.max(-1,t):32767*Math.min(1,t),!0),r+=l*o}}))})),[u]})(d,((e,t,r,n,s)=>{const a=t>>3,o=Math.min(n*r*a,4294967251);e.setUint32(0,1380533830),e.setUint32(4,o+36,!0),e.setUint32(8,1463899717),e.setUint32(12,1718449184),e.setUint32(16,16,!0),e.setUint16(20,1,!0),e.setUint16(22,r,!0),e.setUint32(24,s,!0),e.setUint32(28,s*r*a,!0),e.setUint16(32,r*a,!0),e.setUint16(34,t,!0),e.setUint32(36,1684108385),e.setUint32(40,o,!0)})),v=new Map;u(self,{characterize:()=>({result:/^audio\\/wav$/}),encode:e=>{let{recordingId:t,timeslice:r}=e;const n=v.get(t);void 0!==n&&(v.delete(t),n.reject(new Error("Another request was made to initiate an encoding.")));const s=f.get(t);if(null!==r){if(void 0===s||d(s.channelDataArrays[0])*(1e3/s.sampleRate)<r)return new Promise(((e,n)=>{v.set(t,{reject:n,resolve:e,timeslice:r})}));const e=h(s.channelDataArrays,Math.ceil(r*(s.sampleRate/1e3))),n=p(e,s.isComplete?"initial":"subsequent",16,s.sampleRate);return s.isComplete=!1,{result:n,transferables:n}}if(void 0!==s){const e=p(s.channelDataArrays,s.isComplete?"complete":"subsequent",16,s.sampleRate);return f.delete(t),{result:e,transferables:e}}return{result:[],transferables:[]}},record:e=>{let{recordingId:t,sampleRate:r,typedArrays:n}=e;const s=m(t,r,n),a=v.get(t);if(void 0!==a&&d(s.channelDataArrays[0])*(1e3/r)>=a.timeslice){const e=h(s.channelDataArrays,Math.ceil(a.timeslice*(r/1e3))),n=p(e,s.isComplete?"initial":"subsequent",16,r);s.isComplete=!1,v.delete(t),a.resolve({result:n,transferables:n})}return{result:null}}})})()})();`,D8=new Blob([B8],{type:"application/javascript; charset=utf-8"}),jp=URL.createObjectURL(D8),F8=O8(jp).connect;URL.revokeObjectURL(jp);const zp=new WeakMap;let Xp=!1,_s,sc=[];function Yp(t){const e=t<0?t*32768:t*32767;return Math.max(-32768,Math.min(32768,e))}async function $8(t){if(!t)throw new Error("Audio element not defined");if(!Xp){try{await P8(await F8())}catch({message:n}){throw new Error(`Failed to register recorder - ${n}`)}Xp=!0}let e=zp.get(t);if(!e){const n=new AudioContext,r=n.createMediaElementSource(t);r.connect(n.destination);const i=n.createMediaStreamDestination();r.connect(i),e=i.stream,zp.set(t,e)}_s=new L8(e,{mimeType:"audio/wav"}),_s.addEventListener("dataavailable",n=>{sc.push(n.data)}),_s.start()}function Kp(t,e=!1){return new Promise((n,r)=>{if(!_s)return n(void 0);_s.addEventListener("stop",async()=>{if(!_s||e||!sc.length)return n(void 0);try{const i=[],o=_s.mimeType,a=new AudioContext,c=await new Blob(sc,{type:o}).arrayBuffer(),u=await a.decodeAudioData(c),f=u.getChannelData(0),g=u.getChannelData(1),v=new Int16Array(f.length),_=new Int16Array(g.length),b=new H5(u.numberOfChannels,u.sampleRate,t);for(let p=0,{length:m}=v;p<m;p+=1)v[p]=Yp(f[p]),_[p]=Yp(g[p]);for(let p=0,{length:m}=v;p<m;p+=1152){const w=v.subarray(p,p+1152),C=_.subarray(p,p+1152),h=b.encodeBuffer(w,C);h.length&&i.push(h)}const y=b.flush();if(y.length&&i.push(y),i.length){const p=await new Blob(i,{type:"audio/mpeg"}).arrayBuffer();n(p)}else n(void 0)}catch({message:i}){r(new Error(`Failed to stop recorder - ${i}`))}}),_s.stop()}).finally(()=>{_s=void 0,sc=[]})}const mo=Math.min,Xi=Math.max,oc=Math.round,ac=Math.floor,Ns=t=>({x:t,y:t}),N8={left:"right",right:"left",bottom:"top",top:"bottom"},V8={start:"end",end:"start"};function qp(t,e,n){return Xi(t,mo(e,n))}function Sl(t,e){return typeof t=="function"?t(e):t}function gs(t){return t.split("-")[0]}function lc(t){return t.split("-")[1]}function Zp(t){return t==="x"?"y":"x"}function Jp(t){return t==="y"?"height":"width"}function Tl(t){return["top","bottom"].includes(gs(t))?"y":"x"}function Qp(t){return Zp(Tl(t))}function H8(t,e,n){n===void 0&&(n=!1);const r=lc(t),i=Qp(t),s=Jp(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=uc(o)),[o,uc(o)]}function x8(t){const e=uc(t);return[bf(t),e,bf(e)]}function bf(t){return t.replace(/start|end/g,e=>V8[e])}function U8(t,e,n){const r=["left","right"],i=["right","left"],s=["top","bottom"],o=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:r:e?r:i;case"left":case"right":return e?s:o;default:return[]}}function W8(t,e,n,r){const i=lc(t);let s=U8(gs(t),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map(bf)))),s}function uc(t){return t.replace(/left|right|bottom|top/g,e=>N8[e])}function G8(t){return{top:0,right:0,bottom:0,left:0,...t}}function em(t){return typeof t!="number"?G8(t):{top:t,right:t,bottom:t,left:t}}function fa(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}function tm(t,e,n){let{reference:r,floating:i}=t;const s=Tl(e),o=Qp(e),a=Jp(o),l=gs(e),c=s==="y",u=r.x+r.width/2-i.width/2,f=r.y+r.height/2-i.height/2,g=r[a]/2-i[a]/2;let v;switch(l){case"top":v={x:u,y:r.y-i.height};break;case"bottom":v={x:u,y:r.y+r.height};break;case"right":v={x:r.x+r.width,y:f};break;case"left":v={x:r.x-i.width,y:f};break;default:v={x:r.x,y:r.y}}switch(lc(e)){case"start":v[o]-=g*(n&&c?-1:1);break;case"end":v[o]+=g*(n&&c?-1:1);break}return v}const j8=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=s.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:i}),{x:u,y:f}=tm(c,r,l),g=r,v={},_=0;for(let b=0;b<a.length;b++){const{name:y,fn:p}=a[b],{x:m,y:w,data:C,reset:h}=await p({x:u,y:f,initialPlacement:r,placement:g,strategy:i,middlewareData:v,rects:c,platform:o,elements:{reference:t,floating:e}});u=m??u,f=w??f,v={...v,[y]:{...v[y],...C}},h&&_<=50&&(_++,typeof h=="object"&&(h.placement&&(g=h.placement),h.rects&&(c=h.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:i}):h.rects),{x:u,y:f}=tm(c,g,l)),b=-1)}return{x:u,y:f,placement:g,strategy:i,middlewareData:v}};async function nm(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:o,elements:a,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:g=!1,padding:v=0}=Sl(e,t),_=em(v),y=a[g?f==="floating"?"reference":"floating":f],p=fa(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),m=f==="floating"?{...o.floating,x:r,y:i}:o.reference,w=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),C=await(s.isElement==null?void 0:s.isElement(w))?await(s.getScale==null?void 0:s.getScale(w))||{x:1,y:1}:{x:1,y:1},h=fa(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:m,offsetParent:w,strategy:l}):m);return{top:(p.top-h.top+_.top)/C.y,bottom:(h.bottom-p.bottom+_.bottom)/C.y,left:(p.left-h.left+_.left)/C.x,right:(h.right-p.right+_.right)/C.x}}const z8=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:g,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:_="none",flipAlignment:b=!0,...y}=Sl(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const p=gs(i),m=gs(a)===a,w=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=g||(m||!b?[uc(a)]:x8(a));!g&&_!=="none"&&C.push(...W8(a,b,_,w));const h=[a,...C],A=await nm(e,y),L=[];let $=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&L.push(A[p]),f){const ae=H8(i,o,w);L.push(A[ae[0]],A[ae[1]])}if($=[...$,{placement:i,overflows:L}],!L.every(ae=>ae<=0)){var P,I;const ae=(((P=s.flip)==null?void 0:P.index)||0)+1,V=h[ae];if(V)return{data:{index:ae,overflows:$},reset:{placement:V}};let E=(I=$.filter(F=>F.overflows[0]<=0).sort((F,N)=>F.overflows[1]-N.overflows[1])[0])==null?void 0:I.placement;if(!E)switch(v){case"bestFit":{var x;const F=(x=$.map(N=>[N.placement,N.overflows.filter(Y=>Y>0).reduce((Y,K)=>Y+K,0)]).sort((N,Y)=>N[1]-Y[1])[0])==null?void 0:x[0];F&&(E=F);break}case"initialPlacement":E=a;break}if(i!==E)return{reset:{placement:E}}}return{}}}};function rm(t){const e=mo(...t.map(s=>s.left)),n=mo(...t.map(s=>s.top)),r=Xi(...t.map(s=>s.right)),i=Xi(...t.map(s=>s.bottom));return{x:e,y:n,width:r-e,height:i-n}}function X8(t){const e=t.slice().sort((i,s)=>i.y-s.y),n=[];let r=null;for(let i=0;i<e.length;i++){const s=e[i];!r||s.y-r.y>r.height/2?n.push([s]):n[n.length-1].push(s),r=s}return n.map(i=>fa(rm(i)))}const Y8=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:r,rects:i,platform:s,strategy:o}=e,{padding:a=2,x:l,y:c}=Sl(t,e),u=Array.from(await(s.getClientRects==null?void 0:s.getClientRects(r.reference))||[]),f=X8(u),g=fa(rm(u)),v=em(a);function _(){if(f.length===2&&f[0].left>f[1].right&&l!=null&&c!=null)return f.find(y=>l>y.left-v.left&&l<y.right+v.right&&c>y.top-v.top&&c<y.bottom+v.bottom)||g;if(f.length>=2){if(Tl(n)==="y"){const I=f[0],x=f[f.length-1],ae=gs(n)==="top",V=I.top,E=x.bottom,F=ae?I.left:x.left,N=ae?I.right:x.right,Y=N-F,K=E-V;return{top:V,bottom:E,left:F,right:N,width:Y,height:K,x:F,y:V}}const y=gs(n)==="left",p=Xi(...f.map(I=>I.right)),m=mo(...f.map(I=>I.left)),w=f.filter(I=>y?I.left===m:I.right===p),C=w[0].top,h=w[w.length-1].bottom,A=m,L=p,$=L-A,P=h-C;return{top:C,bottom:h,left:A,right:L,width:$,height:P,x:A,y:C}}return g}const b=await s.getElementRects({reference:{getBoundingClientRect:_},floating:r.floating,strategy:o});return i.reference.x!==b.reference.x||i.reference.y!==b.reference.y||i.reference.width!==b.reference.width||i.reference.height!==b.reference.height?{reset:{rects:b}}:{}}}};async function K8(t,e){const{placement:n,platform:r,elements:i}=t,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=gs(n),a=lc(n),l=Tl(n)==="y",c=["left","top"].includes(o)?-1:1,u=s&&l?-1:1,f=Sl(e,t);let{mainAxis:g,crossAxis:v,alignmentAxis:_}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...f};return a&&typeof _=="number"&&(v=a==="end"?_*-1:_),l?{x:v*u,y:g*c}:{x:g*c,y:v*u}}const im=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:s,placement:o,middlewareData:a}=e,l=await K8(e,t);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:o}}}}},q8=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i}=e,{mainAxis:s=!0,crossAxis:o=!1,limiter:a={fn:y=>{let{x:p,y:m}=y;return{x:p,y:m}}},...l}=Sl(t,e),c={x:n,y:r},u=await nm(e,l),f=Tl(gs(i)),g=Zp(f);let v=c[g],_=c[f];if(s){const y=g==="y"?"top":"left",p=g==="y"?"bottom":"right",m=v+u[y],w=v-u[p];v=qp(m,v,w)}if(o){const y=f==="y"?"top":"left",p=f==="y"?"bottom":"right",m=_+u[y],w=_-u[p];_=qp(m,_,w)}const b=a.fn({...e,[g]:v,[f]:_});return{...b,data:{x:b.x-n,y:b.y-r}}}}};function Vs(t){return sm(t)?(t.nodeName||"").toLowerCase():"#document"}function mi(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function bs(t){var e;return(e=(sm(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function sm(t){return t instanceof Node||t instanceof mi(t).Node}function ws(t){return t instanceof Element||t instanceof mi(t).Element}function Yi(t){return t instanceof HTMLElement||t instanceof mi(t).HTMLElement}function om(t){return typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof mi(t).ShadowRoot}function kl(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=Ti(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!["inline","contents"].includes(i)}function Z8(t){return["table","td","th"].includes(Vs(t))}function wf(t){const e=yf(),n=Ti(t);return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function J8(t){let e=da(t);for(;Yi(e)&&!cc(e);){if(wf(e))return e;e=da(e)}return null}function yf(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function cc(t){return["html","body","#document"].includes(Vs(t))}function Ti(t){return mi(t).getComputedStyle(t)}function fc(t){return ws(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function da(t){if(Vs(t)==="html")return t;const e=t.assignedSlot||t.parentNode||om(t)&&t.host||bs(t);return om(e)?e.host:e}function am(t){const e=da(t);return cc(e)?t.ownerDocument?t.ownerDocument.body:t.body:Yi(e)&&kl(e)?e:am(e)}function Al(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=am(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),o=mi(i);return s?e.concat(o,o.visualViewport||[],kl(i)?i:[],o.frameElement&&n?Al(o.frameElement):[]):e.concat(i,Al(i,[],n))}function lm(t){const e=Ti(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=Yi(t),s=i?t.offsetWidth:n,o=i?t.offsetHeight:r,a=oc(n)!==s||oc(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function vf(t){return ws(t)?t:t.contextElement}function ha(t){const e=vf(t);if(!Yi(e))return Ns(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=lm(e);let o=(s?oc(n.width):n.width)/r,a=(s?oc(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const Q8=Ns(0);function um(t){const e=mi(t);return!yf()||!e.visualViewport?Q8:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function ey(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==mi(t)?!1:e}function _o(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=vf(t);let o=Ns(1);e&&(r?ws(r)&&(o=ha(r)):o=ha(t));const a=ey(s,n,r)?um(s):Ns(0);let l=(i.left+a.x)/o.x,c=(i.top+a.y)/o.y,u=i.width/o.x,f=i.height/o.y;if(s){const g=mi(s),v=r&&ws(r)?mi(r):r;let _=g,b=_.frameElement;for(;b&&r&&v!==_;){const y=ha(b),p=b.getBoundingClientRect(),m=Ti(b),w=p.left+(b.clientLeft+parseFloat(m.paddingLeft))*y.x,C=p.top+(b.clientTop+parseFloat(m.paddingTop))*y.y;l*=y.x,c*=y.y,u*=y.x,f*=y.y,l+=w,c+=C,_=mi(b),b=_.frameElement}}return fa({width:u,height:f,x:l,y:c})}const ty=[":popover-open",":modal"];function cm(t){return ty.some(e=>{try{return t.matches(e)}catch{return!1}})}function ny(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",o=bs(r),a=e?cm(e.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Ns(1);const u=Ns(0),f=Yi(r);if((f||!f&&!s)&&((Vs(r)!=="body"||kl(o))&&(l=fc(r)),Yi(r))){const g=_o(r);c=ha(r),u.x=g.x+r.clientLeft,u.y=g.y+r.clientTop}return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x,y:n.y*c.y-l.scrollTop*c.y+u.y}}function ry(t){return Array.from(t.getClientRects())}function fm(t){return _o(bs(t)).left+fc(t).scrollLeft}function iy(t){const e=bs(t),n=fc(t),r=t.ownerDocument.body,i=Xi(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=Xi(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+fm(t);const a=-n.scrollTop;return Ti(r).direction==="rtl"&&(o+=Xi(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}function sy(t,e){const n=mi(t),r=bs(t),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;const c=yf();(!c||c&&e==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}return{width:s,height:o,x:a,y:l}}function oy(t,e){const n=_o(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=Yi(t)?ha(t):Ns(1),o=t.clientWidth*s.x,a=t.clientHeight*s.y,l=i*s.x,c=r*s.y;return{width:o,height:a,x:l,y:c}}function dm(t,e,n){let r;if(e==="viewport")r=sy(t,n);else if(e==="document")r=iy(bs(t));else if(ws(e))r=oy(e,n);else{const i=um(t);r={...e,x:e.x-i.x,y:e.y-i.y}}return fa(r)}function hm(t,e){const n=da(t);return n===e||!ws(n)||cc(n)?!1:Ti(n).position==="fixed"||hm(n,e)}function ay(t,e){const n=e.get(t);if(n)return n;let r=Al(t,[],!1).filter(a=>ws(a)&&Vs(a)!=="body"),i=null;const s=Ti(t).position==="fixed";let o=s?da(t):t;for(;ws(o)&&!cc(o);){const a=Ti(o),l=wf(o);!l&&a.position==="fixed"&&(i=null),(s?!l&&!i:!l&&a.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||kl(o)&&!l&&hm(t,o))?r=r.filter(u=>u!==o):i=a,o=da(o)}return e.set(t,r),r}function ly(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const o=[...n==="clippingAncestors"?ay(e,this._c):[].concat(n),r],a=o[0],l=o.reduce((c,u)=>{const f=dm(e,u,i);return c.top=Xi(f.top,c.top),c.right=mo(f.right,c.right),c.bottom=mo(f.bottom,c.bottom),c.left=Xi(f.left,c.left),c},dm(e,a,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function uy(t){const{width:e,height:n}=lm(t);return{width:e,height:n}}function cy(t,e,n){const r=Yi(e),i=bs(e),s=n==="fixed",o=_o(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const l=Ns(0);if(r||!r&&!s)if((Vs(e)!=="body"||kl(i))&&(a=fc(e)),r){const f=_o(e,!0,s,e);l.x=f.x+e.clientLeft,l.y=f.y+e.clientTop}else i&&(l.x=fm(i));const c=o.left+a.scrollLeft-l.x,u=o.top+a.scrollTop-l.y;return{x:c,y:u,width:o.width,height:o.height}}function pm(t,e){return!Yi(t)||Ti(t).position==="fixed"?null:e?e(t):t.offsetParent}function mm(t,e){const n=mi(t);if(!Yi(t)||cm(t))return n;let r=pm(t,e);for(;r&&Z8(r)&&Ti(r).position==="static";)r=pm(r,e);return r&&(Vs(r)==="html"||Vs(r)==="body"&&Ti(r).position==="static"&&!wf(r))?n:r||J8(t)||n}const fy=async function(t){const e=this.getOffsetParent||mm,n=this.getDimensions;return{reference:cy(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,...await n(t.floating)}}};function dy(t){return Ti(t).direction==="rtl"}const hy={convertOffsetParentRelativeRectToViewportRelativeRect:ny,getDocumentElement:bs,getClippingRect:ly,getOffsetParent:mm,getElementRects:fy,getClientRects:ry,getDimensions:uy,getScale:ha,isElement:ws,isRTL:dy};function py(t,e){let n=null,r;const i=bs(t);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const{left:c,top:u,width:f,height:g}=t.getBoundingClientRect();if(a||e(),!f||!g)return;const v=ac(u),_=ac(i.clientWidth-(c+f)),b=ac(i.clientHeight-(u+g)),y=ac(c),m={rootMargin:-v+"px "+-_+"px "+-b+"px "+-y+"px",threshold:Xi(0,mo(1,l))||1};let w=!0;function C(h){const A=h[0].intersectionRatio;if(A!==l){if(!w)return o();A?o(!1,A):r=setTimeout(()=>{o(!1,1e-7)},100)}w=!1}try{n=new IntersectionObserver(C,{...m,root:i.ownerDocument})}catch{n=new IntersectionObserver(C,m)}n.observe(t)}return o(!0),s}function _m(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=vf(t),u=i||s?[...c?Al(c):[],...Al(e)]:[];u.forEach(p=>{i&&p.addEventListener("scroll",n,{passive:!0}),s&&p.addEventListener("resize",n)});const f=c&&a?py(c,n):null;let g=-1,v=null;o&&(v=new ResizeObserver(p=>{let[m]=p;m&&m.target===c&&v&&(v.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var w;(w=v)==null||w.observe(e)})),n()}),c&&!l&&v.observe(c),v.observe(e));let _,b=l?_o(t):null;l&&y();function y(){const p=_o(t);b&&(p.x!==b.x||p.y!==b.y||p.width!==b.width||p.height!==b.height)&&n(),b=p,_=requestAnimationFrame(y)}return n(),()=>{var p;u.forEach(m=>{i&&m.removeEventListener("scroll",n),s&&m.removeEventListener("resize",n)}),f==null||f(),(p=v)==null||p.disconnect(),v=null,l&&cancelAnimationFrame(_)}}const my=q8,gm=z8,_y=Y8,bm=(t,e,n)=>{const r=new Map,i={platform:hy,...n},s={...i.platform,_c:r};return j8(t,e,{...i,platform:s})},gy=t=>({}),wm=t=>({});function ym(t){let e,n,r,i,s;const o=t[8].default,a=Mo(o,t,t[7],null);return{c(){e=_e("div"),a&&a.c(),ie(e,"class","ttu-whispersync-container popover")},m(l,c){he(l,e,c),a&&a.m(e,null),t[10](e),r=!0,i||(s=Ma(n=rb.call(null,e,t[11])),i=!0)},p(l,c){a&&a.p&&(!r||c&128)&&Lo(a,o,l,l[7],r?Ro(o,l[7],c,null):Po(l[7]),null),n&&Ci(n.update)&&c&2&&n.update.call(null,l[11])},i(l){r||(Z(a,l),r=!0)},o(l){ne(a,l),r=!1},d(l){l&&de(e),a&&a.d(l),t[10](null),i=!1,s()}}}function by(t){let e,n,r,i,s,o;const a=t[8].icon,l=Mo(a,t,t[7],wm);let c=t[3]&&ym(t);return{c(){e=_e("div"),n=_e("button"),l&&l.c(),r=me(),c&&c.c(),ie(e,"class","flex")},m(u,f){he(u,e,f),oe(e,n),l&&l.m(n,null),t[9](n),oe(e,r),c&&c.m(e,null),i=!0,s||(o=Xe(n,"click",t[4]),s=!0)},p(u,[f]){l&&l.p&&(!i||f&128)&&Lo(l,a,u,u[7],i?Ro(a,u[7],f,gy):Po(u[7]),wm),u[3]?c?(c.p(u,f),f&8&&Z(c,1)):(c=ym(u),c.c(),Z(c,1),c.m(e,null)):c&&(jt(),ne(c,1,1,()=>{c=null}),zt())},i(u){i||(Z(l,u),Z(c),i=!0)},o(u){ne(l,u),ne(c),i=!1},d(u){u&&de(e),l&&l.d(u),t[9](null),c&&c.d(),s=!1,o()}}}function wy(t,e,n){let{$$slots:r={},$$scope:i}=e,{placement:s="left"}=e,{fallbackPlacements:o=["right","top","left"]}=e;function a(){f==null||f(),n(3,u=!1)}let l,c,u=!1,f;async function g(){if(u)return a();n(3,u=!0),await Mr(),f=_m(l,c,v)}function v(){bm(l,c,{placement:s,middleware:[im(5),gm({fallbackPlacements:o}),my()]}).then(({x:p,y:m})=>{n(2,c.style.left=`${p}px`,c),n(2,c.style.top=`${m}px`,c)}).catch(()=>{})}function _(p){Vt[p?"unshift":"push"](()=>{l=p,n(1,l)})}function b(p){Vt[p?"unshift":"push"](()=>{c=p,n(2,c)})}const y=({target:p})=>{p instanceof Element&&p!==l&&!l.contains(p)&&a()};return t.$$set=p=>{"placement"in p&&n(5,s=p.placement),"fallbackPlacements"in p&&n(6,o=p.fallbackPlacements),"$$scope"in p&&n(7,i=p.$$scope)},[a,l,c,u,g,s,o,i,r,_,b,y]}class _i extends Dn{constructor(e){super(),Bn(this,e,wy,by,Cn,{placement:5,fallbackPlacements:6,hide:0})}get hide(){return this.$$.ctx[0]}}function yy(t){let e,n;return{c(){e=_e("div"),n=_e("div"),ie(n,"class","opacity-70"),pt(n,"rounded-full",t[2]),Cr(n,"width",`${Math.min(100,t[0])}%`),Cr(n,"height",`${t[1]}rem`),ie(e,"class","w-full bg-inverted"),pt(e,"rounded-full",t[2]),pt(e,"m-t-s",t[3]),Cr(e,"height",`${t[1]}rem`)},m(r,i){he(r,e,i),oe(e,n)},p(r,[i]){i&4&&pt(n,"rounded-full",r[2]),i&1&&Cr(n,"width",`${Math.min(100,r[0])}%`),i&2&&Cr(n,"height",`${r[1]}rem`),i&4&&pt(e,"rounded-full",r[2]),i&8&&pt(e,"m-t-s",r[3]),i&2&&Cr(e,"height",`${r[1]}rem`)},i:wt,o:wt,d(r){r&&de(e)}}}function vy(t,e,n){let{currentProgress:r}=e,{height:i=.625}=e,{rounded:s=!1}=e,{margin:o=!1}=e;return t.$$set=a=>{"currentProgress"in a&&n(0,r=a.currentProgress),"height"in a&&n(1,i=a.height),"rounded"in a&&n(2,s=a.rounded),"margin"in a&&n(3,o=a.margin)},[r,i,s,o]}class Ef extends Dn{constructor(e){super(),Bn(this,e,vy,yy,Cn,{currentProgress:0,height:1,rounded:2,margin:3})}}const{document:vm,window:Sf}=$c;function Em(t){let e,n,r=!1,i,s=!0,o,a;function l(){cancelAnimationFrame(i),e.paused||(i=id(l),r=!0),t[64].call(e)}return{c(){e=_e("audio"),e.controls=!0,ie(e,"class","hidden"),Co(e.src,n=t[24])||ie(e,"src",n),t[4]===void 0&&Ms(()=>t[65].call(e))},m(c,u){he(c,e,u),e.muted=t[20],isNaN(t[18])||(e.playbackRate=t[18]),t[69](e),o||(a=[Xe(e,"timeupdate",l),Xe(e,"durationchange",t[65]),Xe(e,"volumechange",t[66]),Xe(e,"play",t[67]),Xe(e,"pause",t[67]),Xe(e,"ratechange",t[68]),Xe(e,"loadstart",t[62]),Xe(e,"loadedmetadata",t[46]),Xe(e,"timeupdate",t[47]),Xe(e,"pause",t[47]),Xe(e,"playing",t[51]),Xe(e,"error",t[63])],o=!0)},p(c,u){u[0]&16777216&&!Co(e.src,n=c[24])&&ie(e,"src",n),!r&&u[0]&8&&!isNaN(c[3])&&(e.currentTime=c[3]),r=!1,u[0]&1048576&&(e.muted=c[20]),u[0]&524288&&s!==(s=c[19])&&e[s?"pause":"play"](),u[0]&262144&&!isNaN(c[18])&&(e.playbackRate=c[18])},d(c){c&&de(e),t[69](null),o=!1,vn(a)}}}function Ey(t){let e,n,r,i,s,o,a,l,c,u,f,g,v,_,b;return o=new kt({props:{path:kg}}),g=new kt({props:{path:Cg}}),{c(){e=_e("div"),n=_e("input"),r=me(),i=_e("div"),s=_e("button"),ye(o.$$.fragment),a=me(),l=_e("span"),c=Nt(t[12]),u=me(),f=_e("button"),ye(g.$$.fragment),ie(n,"type","range"),ie(n,"min","0.1"),ie(n,"max","2"),ie(n,"step","0.05"),n.disabled=t[2],s.disabled=t[2],ie(l,"class","m-x-s"),f.disabled=t[2],ie(i,"class","playback-display flex m-t-s"),ie(e,"class","playback-rates")},m(y,p){he(y,e,p),oe(e,n),Mi(n,t[12]),oe(e,r),oe(e,i),oe(i,s),be(o,s,null),oe(i,a),oe(i,l),oe(l,c),oe(i,u),oe(i,f),be(g,f,null),v=!0,_||(b=[Xe(n,"change",t[77]),Xe(n,"input",t[77]),Xe(n,"change",t[50]),Xe(s,"click",t[78]),Xe(f,"click",t[79])],_=!0)},p(y,p){(!v||p[0]&4)&&(n.disabled=y[2]),p[0]&4096&&Mi(n,y[12]),(!v||p[0]&4)&&(s.disabled=y[2]),(!v||p[0]&4096)&&cn(c,y[12]),(!v||p[0]&4)&&(f.disabled=y[2])},i(y){v||(Z(o.$$.fragment,y),Z(g.$$.fragment,y),v=!0)},o(y){ne(o.$$.fragment,y),ne(g.$$.fragment,y),v=!1},d(y){y&&de(e),we(o),we(g),_=!1,vn(b)}}}function Sy(t){let e,n,r,i;return r=new kt({props:{path:Rg}}),{c(){e=_e("div"),n=_e("button"),ye(r.$$.fragment),ie(n,"title","Change playback speed"),n.disabled=t[2],ie(e,"class","flex m-x-xs"),ie(e,"slot","icon")},m(s,o){he(s,e,o),oe(e,n),be(r,n,null),i=!0},p(s,o){(!i||o[0]&4)&&(n.disabled=s[2])},i(s){i||(Z(r.$$.fragment,s),i=!0)},o(s){ne(r.$$.fragment,s),i=!1},d(s){s&&de(e),we(r)}}}function Ty(t){let e=t[24],n,r,i,s,o,a,l,c,u,f,g,v,_,b,y,p,m,w,C,h,A,L,$,P,I,x,ae,V,E,F,N,Y,K=Em(t);Ms(t[70]),o=new kt({props:{path:t[2]||t[19]?ku:al}}),c=new kt({props:{path:l1}}),g=new kt({props:{path:f1}}),b=new Ef({props:{currentProgress:Math.min(100,t[13]),height:1.5}}),A=new kt({props:{path:c1}}),P=new kt({props:{path:u1}}),ae=new kt({props:{path:t[2]||!t[20]?Zd:Jd}});let J={placement:"top",fallbackPlacements:["top-start","left-start"],$$slots:{icon:[Sy],default:[Ey]},$$scope:{ctx:t}};return E=new _i({props:J}),t[80](E),{c(){K.c(),n=me(),r=me(),i=_e("div"),s=_e("button"),ye(o.$$.fragment),a=me(),l=_e("button"),ye(c.$$.fragment),u=me(),f=_e("button"),ye(g.$$.fragment),v=me(),_=_e("button"),ye(b.$$.fragment),y=me(),p=_e("span"),m=Nt(t[10]),C=me(),h=_e("button"),ye(A.$$.fragment),L=me(),$=_e("button"),ye(P.$$.fragment),I=me(),x=_e("button"),ye(ae.$$.fragment),V=me(),ye(E.$$.fragment),ie(s,"title","Toggle playback"),ie(s,"class","m-x-xs"),s.disabled=t[2],ie(l,"class","m-x-xs"),ie(l,"title",t[16]),l.disabled=t[2],ie(f,"class","m-x-xs"),ie(f,"title",t[17]),f.disabled=t[2],ie(p,"class","w-full absolute left-0 player-progress-tooltip"),ie(_,"class","w-full relative player-progress-tooltip-button m-x-xs"),_.disabled=t[2],ie(_,"title",w=t[2]?"Recording in progress":null),pt(_,"recording",t[2]),ie(h,"class","m-x-xs"),ie(h,"title",t[15]),h.disabled=t[2],ie($,"class","m-x-xs"),ie($,"title",t[14]),$.disabled=t[2],ie(x,"title","Toggle mute"),ie(x,"class","m-x-xs"),x.disabled=t[2],ie(i,"class","flex items-center w-full m-t-b"),pt(i,"invisible",!t[21])},m(j,B){K.m(j,B),he(j,n,B),he(j,r,B),he(j,i,B),oe(i,s),be(o,s,null),oe(i,a),oe(i,l),be(c,l,null),oe(i,u),oe(i,f),be(g,f,null),oe(i,v),oe(i,_),be(b,_,null),oe(_,y),oe(_,p),oe(p,m),oe(i,C),oe(i,h),be(A,h,null),oe(i,L),oe(i,$),be(P,$,null),oe(i,I),oe(i,x),be(ae,x,null),oe(i,V),be(E,i,null),F=!0,N||(Y=[Xe(Sf,"blur",t[43]),Xe(Sf,"focus",t[44]),Xe(Sf,"keydown",t[45]),Xe(vm,"visibilitychange",t[70]),Xe(s,"click",t[71]),Xe(l,"click",t[72]),Xe(f,"click",t[73]),Xe(_,"pointerenter",t[48]),Xe(_,"pointermove",t[48]),Xe(_,"pointerout",t[48]),Xe(_,"click",t[49]),Xe(h,"click",t[74]),Xe($,"click",t[75]),Xe(x,"click",t[76])],N=!0)},p(j,B){B[0]&16777216&&Cn(e,e=j[24])?(K.d(1),K=Em(j),K.c(),K.m(n.parentNode,n)):K.p(j,B);const M={};B[0]&524292&&(M.path=j[2]||j[19]?ku:al),o.$set(M),(!F||B[0]&4)&&(s.disabled=j[2]),(!F||B[0]&65536)&&ie(l,"title",j[16]),(!F||B[0]&4)&&(l.disabled=j[2]),(!F||B[0]&131072)&&ie(f,"title",j[17]),(!F||B[0]&4)&&(f.disabled=j[2]);const S={};B[0]&8192&&(S.currentProgress=Math.min(100,j[13])),b.$set(S),(!F||B[0]&1024)&&cn(m,j[10]),(!F||B[0]&4)&&(_.disabled=j[2]),(!F||B[0]&4&&w!==(w=j[2]?"Recording in progress":null))&&ie(_,"title",w),(!F||B[0]&4)&&pt(_,"recording",j[2]),(!F||B[0]&32768)&&ie(h,"title",j[15]),(!F||B[0]&4)&&(h.disabled=j[2]),(!F||B[0]&16384)&&ie($,"title",j[14]),(!F||B[0]&4)&&($.disabled=j[2]);const R={};B[0]&1048580&&(R.path=j[2]||!j[20]?Zd:Jd),ae.$set(R),(!F||B[0]&4)&&(x.disabled=j[2]);const X={};B[0]&12587012|B[4]&16&&(X.$$scope={dirty:B,ctx:j}),E.$set(X),(!F||B[0]&2097152)&&pt(i,"invisible",!j[21])},i(j){F||(Z(o.$$.fragment,j),Z(c.$$.fragment,j),Z(g.$$.fragment,j),Z(b.$$.fragment,j),Z(A.$$.fragment,j),Z(P.$$.fragment,j),Z(ae.$$.fragment,j),Z(E.$$.fragment,j),F=!0)},o(j){ne(o.$$.fragment,j),ne(c.$$.fragment,j),ne(g.$$.fragment,j),ne(b.$$.fragment,j),ne(A.$$.fragment,j),ne(P.$$.fragment,j),ne(ae.$$.fragment,j),ne(E.$$.fragment,j),F=!1},d(j){j&&(de(n),de(r),de(i)),K.d(j),we(o),we(c),we(g),we(b),we(A),we(P),we(ae),t[80](null),we(E),N=!1,vn(Y)}}}function ky(t,e,n){let r,i,s,o,a,l,c,u,f,g,v,_,b,y,p,m,w,C,h,A,L,$,P,I,x,ae,V,E,F,N,Y,K,J,j,B,M,S,R,X,re,W,z;ce(t,qo,He=>n(18,l=He)),ce(t,Mn,He=>n(19,c=He)),ce(t,xi,He=>n(2,u=He)),ce(t,as,He=>n(92,f=He)),ce(t,Lr,He=>n(93,g=He)),ce(t,Ui,He=>n(3,v=He)),ce(t,qa,He=>n(20,m=He)),ce(t,Ps,He=>n(21,C=He)),ce(t,ls,He=>n(4,$=He)),ce(t,Rr,He=>n(99,P=He)),ce(t,Mt,He=>n(100,I=He)),ce(t,Ho,He=>n(101,x=He)),ce(t,At,He=>n(102,ae=He)),ce(t,vi,He=>n(104,E=He)),ce(t,Ka,He=>n(106,M=He)),ce(t,En,He=>n(109,X=He)),ce(t,Za,He=>n(60,re=He)),ce(t,fu,He=>n(61,W=He)),ce(t,Na,He=>n(24,z=He));let{imageLoaded:le}=e;async function Me(){if(u||!p)return;let He=g.get(f.current||f.previous);He||(He=[...g.values()].findLast(Gt=>v>=Gt.startSeconds)),He&&(w&&T&&document.dispatchEvent(new CustomEvent("ttu-action",{detail:{type:"pauseTracker",scrollMode:y,scrollBehavior:b,selector:Qs(He.id)}})),await new Promise(Et=>setTimeout(Et)),document.dispatchEvent(new CustomEvent("ttu-action",{detail:{type:"cue",scrollMode:y,scrollBehavior:b,selector:Qs(He.id)}})))}const Ee=Ri(),{readerEnableAutoScroll$:ve,readerEnableTrackerAutoPause$:ke,readerScrollMode$:Ne,readerScrollBehavior$:Te,readerEnableMenuTarget$:Le,readerMenuOpenMode$:Fe,playerEnableDictionaryDetection$:Ze,playerEnableWakeLock$:O,playerEnableSubtitleCopy$:H,playerAutoPauseMode$:Pe,playerRewindTime$:xe,playerAltRewindTime$:qe,playerFastForwardTime$:nt,playerAltFastForwardTime$:Oe,playerPlaybackRateDecreaseTime$:je,playerPlaybackRateIncreaseTime$:et,exportAudioBitrate$:rt,keybindingsEnableTimeFallback$:Je}=_t;ce(t,ve,He=>n(97,p=He)),ce(t,ke,He=>n(98,w=He)),ce(t,Ne,He=>n(96,y=He)),ce(t,Te,He=>n(95,b=He)),ce(t,Le,He=>n(108,R=He)),ce(t,Fe,He=>n(107,S=He)),ce(t,Ze,He=>n(57,h=He)),ce(t,O,He=>n(59,L=He)),ce(t,H,He=>n(94,_=He)),ce(t,Pe,He=>n(58,A=He)),ce(t,xe,He=>n(8,K=He)),ce(t,qe,He=>n(7,Y=He)),ce(t,nt,He=>n(6,N=He)),ce(t,Oe,He=>n(5,F=He)),ce(t,je,He=>n(22,J=He)),ce(t,et,He=>n(23,j=He)),ce(t,rt,He=>n(103,V=He)),ce(t,Je,He=>n(105,B=He));const{isIOS:G}=Io("context"),T=!!+`${window.localStorage.getItem("statisticsEnabled")||"0"}`,d=new MutationObserver(un),k=new MutationObserver(Ye);let D,U,te,ee,se,ge,pe="",Ae=[],Ce=[],De=!1,tt=!1,mt=-1,We=-1,dt=-1,Be=!1,$e,ft=l,ze,at;Oa(()=>{document.addEventListener("ttsu:section.change",Wt,!1),n(56,te=document.getElementById("jpdb-popup"))}),Yl(()=>{document.removeEventListener("ttsu:section.change",Wt,!1),d.disconnect(),k.disconnect(),Xn()});async function Qe(){c||u||A!==fi.STRICT||h&&ut()||(fe(Mn,c=!0,c),n(11,De=!0))}function vt(){!c||!De||A!==fi.STRICT||!h&&ut()||(fe(Mn,c=!1,c),n(11,De=!1))}function Rt(He){if(X||He.repeat||!(He.ctrlKey||He.metaKey||He.altKey)||!C||u)return;const Et=(He.code||He.key||"").toLowerCase(),Gt=R&&S!==tr.DISABLED?M:void 0;let nn=Re.NONE,hr=!0,Pt=!1,Zt=Gt||g.get(f.current||f.previous),On;if(!Zt&&B&&(On=[...g.values()],Zt=On.findLast(Br=>v>=Br.startSeconds)),He.altKey)switch(Et){case"keyd":case"d":nn=Zt?Re.TOGGLE_PLAY_PAUSE:Re.NONE;break;case"keyq":case"q":nn=Re.NEXT_SUBTITLE;break;case"keyk":case"k":Yt(j);break;case"keyj":case"j":fe(Mn,c=!c,c);break;default:hr=!1;break}else switch(Et){case"space":case" ":fe(Mn,c=!c,c);break;case"keyd":case"d":nn=Zt?Re.RESTART_PLAYBACK:Re.NONE;break;case"keyl":case"l":nn=Zt?Re.TOGGLE_PLAYBACK_LOOP:Re.NONE;break;case"keyq":case"q":nn=Re.PREVIOUS_SUBTITLE;break;case"keyk":case"k":Yt(-J);break;case"arrowleft":Zt=an(Math.max(0,v-K)),nn=Re.RESTART_PLAYBACK,Pt=!0;break;case"arrowdown":Zt=an(Math.max(0,v-Y)),nn=Re.RESTART_PLAYBACK,Pt=!0;break;case"arrowright":Zt=an(Math.min($,v+N)),nn=Re.RESTART_PLAYBACK,Pt=!0;break;case"arrowup":Zt=an(Math.min($,v+F)),nn=Re.RESTART_PLAYBACK,Pt=!0;break;default:hr=!1;break}hr&&(He.preventDefault(),He.stopPropagation()),Fn(nn,Zt,{keepPauseState:Pt})}async function lt(){if(!G)return n(0,D.currentTime=v,D),Ee("loaded");let He=0,Et;const Gt=v,nn=new Promise(Pt=>{Et=Pt,D.addEventListener("loadeddata",Pt,{once:!0,capture:!1})});await new Promise(Pt=>Vo.add({component:L0,props:{dialogHeader:"Audio",dialogMessage:"Start audio session",showCancel:!1,resolver:Pt}})),await new Promise(Pt=>{const Zt=setInterval(async()=>{try{He+=1,D.play(),setTimeout(Et,1e4),await nn,D.pause(),clearInterval(Zt),Pt()}catch{}He>20&&(clearInterval(Zt),Et(void 0),Pt())},500)}),qt(Gt),await Mr(),Ee("loaded")}async function St(){if(E!=null&&E.signal.aborted)return await Kp(V,!0).catch(()=>{}),at==null||at(new bd("user aborted")),Ae=[],Ce=[],mt=-1,tt=!1,fe(Mn,c=!0,c),Dt();if(mt>-1&&v>Ce[mt]){const Et=mt===Ce.length-1,Gt=tt&&Et,nn=Gt||!Et,hr=mt;if(mt=-1,nn)return mt=Gt?0:hr+1,qt(Ae[mt]);if(Ae=[],Ce=[],tt=!1,fe(Mn,c=!0,c),ze){const Pt=await Kp(V).catch(Zt=>{at==null||at(Zt),Dt()});ze(Pt)}return Dt()}let He=C;if(C||(fe(Ps,C=!0,C),g.size&&xn({subtitles:[...g.values()],replaceTrack:!0}),await Promise.all([Mr(),le()]),fe(At,ae=!1,ae)),!(We>-1||!He)){fe(Mt,I="",I);try{const Et=v;await x.put("audioBook",{playbackPosition:Et,title:P.title,lastAudioBookModified:Date.now()}),fe(Rr,P.playbackPosition=Et,P),document.dispatchEvent(new CustomEvent("ttu-action",{detail:{type:"sync",syncType:"audioBook"}}))}catch({message:Et}){fe(Mt,I=`Failed to update current time: ${Et}`,I)}Rr.set(P)}}function ht(He){n(10,pe=eo(rn(He)))}async function xt(){await Mr(),Fn(Re.RESTART_PLAYBACK,an(K_(pe)),{keepPauseState:!0})}function ln({currentTarget:He}){const Et=Number.parseFloat(He.value);fe(qo,l=Et,l),se.hide()}function qt(He){fe(Ui,v=He,v),D&&n(0,D.currentTime=He,D)}function Dt(){ze=void 0,at=void 0,We>-1&&(Be=!0,qt(We)),dt>-1&&fe(qo,l=dt,l),$e!==void 0&&fe(qa,m=$e,m),We=-1,dt=-1,$e=void 0}function rn(He){const Et=He.currentTarget.getBoundingClientRect();return Wi(0,$,Math.ceil((He.clientX-Et.left)/Et.width*$+Number.EPSILON))}function In(He){He==="visible"&&L&&setTimeout(yr,500),!(A!==fi.MODERATE||u)&&(He==="hidden"&&!c&&(!h||!ut())?(fe(Mn,c=!0,c),n(11,De=!0)):c&&De&&He==="visible"&&(h||!ut())&&(fe(Mn,c=!1,c),n(11,De=!1)))}async function Hn(He){if(!C||!He.subtitles.length)return;await Mr();const{action:Et,subtitles:Gt,skipUpdates:nn,keepPauseState:hr}=He,{startSeconds:Pt}=Gt[0],Zt=Et!==Re.RESTART_PLAYBACK;if({recorderSuccess:ze,recorderFailure:at}=He,nn||ze?(We=We>-1?We:v,dt=dt>-1?dt:l,$e=$e!==void 0?$e:m):(We=-1,dt=-1,$e=void 0,Be=!1),!nn&&!u&&p&&w&&T){const On=[...g.values()].findLast(Br=>Pt>=Br.startSeconds);On&&On.id!==f.current&&document.dispatchEvent(new CustomEvent("ttu-action",{detail:{type:"pauseTracker",scrollMode:y,scrollBehavior:b,selector:Qs(On.id)}}))}if(Ae=Zt?Gt.map(On=>On.startSeconds):[],Ce=Zt?Gt.map(On=>On.endSeconds):[],mt=Zt?0:-1,tt=Zt?Et===Re.TOGGLE_PLAYBACK_LOOP:!1,qt(Pt),ze&&at)return $8(D).then(()=>{fe(qo,l=1,l),fe(qa,m=!1,m),fe(Mn,c=!1,c)}).catch(On=>{at==null||at(On),Dt()});hr||fe(Mn,c=!1,c)}function xn(He){var hr;const{subtitles:Et}=He,Gt=[...D.textTracks],nn=Gt.findLast(Pt=>Pt.mode!=="disabled");if(He.replaceTrack)for(let Pt=0,{length:Zt}=Gt;Pt<Zt;Pt+=1)Gt[Pt].mode="disabled";if(!Et.length)return Wt();if(He.replaceTrack){const Pt=D.addTextTrack("captions","Captions","jp");for(let Zt=0,{length:On}=Et;Zt<On;Zt+=1)Pt.addCue(Xt(Et[Zt]));Pt.mode="hidden";return}if(nn){for(let Pt=0,{length:Zt}=Et;Pt<Zt;Pt+=1){const On=Et[Pt],Br=(hr=nn.cues)==null?void 0:hr.getCueById(On.id);Br&&(Br.removeEventListener("enter",Ft,!1),Br.removeEventListener("exit",Wt,!1),nn.removeCue(Br)),nn.addCue(Xt(On))}nn.mode="hidden"}}function Xt(He){const Et=new VTTCue(He.startSeconds,He.endSeconds,"");return Et.id=He.id,Et.addEventListener("enter",Ft,!1),Et.addEventListener("exit",Wt,!1),Et}function Ft(He){var Gt;const{id:Et}=He.target;Wt(Et),We===-1&&p&&!Be&&document.dispatchEvent(new CustomEvent("ttu-action",{detail:{type:"cue",scrollMode:y,scrollBehavior:b,selector:Qs(Et)}})),Be&&(Be=!1),_&&navigator.clipboard.writeText(((Gt=g.get(Et))==null?void 0:Gt.text)||"").catch(({message:nn})=>console.log(`failed to copy subtitle: ${nn}`))}async function Wt(He){var hr;if(We>-1)return;const Et=[...D.textTracks].findLast(Pt=>Pt.mode!=="disabled");let Gt=[...(Et==null?void 0:Et.activeCues)||[]].map(Pt=>Pt.id);if(Et&&!Gt.length&&typeof He=="string"&&G){const Pt=((hr=[...g.values()].findLast(Zt=>v>=Zt.startSeconds))==null?void 0:hr.id)||"";Pt&&Gt.push(Pt)}if(c&&Gt.length>1){const Pt=g.get(Gt[Gt.length-2]),Zt=g.get(Gt[Gt.length-1]);(Pt.startSeconds>=Zt.startSeconds&&Pt.startSeconds<=Zt.endSeconds||Zt.startSeconds>=Pt.startSeconds&&Zt.startSeconds<=Pt.endSeconds)&&(Gt=[Zt.id])}const nn=document.querySelectorAll(`${pu()}.active${Gt.length?`,${Gt.map(Pt=>Qs(Pt)).join(",")}`:""}`);for(let Pt=0,{length:Zt}=nn;Pt<Zt;Pt+=1){const On=nn[Pt],Br=Kc(On);Br!=="not existing"&&Gt.find(zr=>zr===Br)?On.classList.add("active"):On.classList.remove("active")}Gt.length?fe(as,f={previous:f.current,current:Gt[Gt.length-1],useTimeFallback:!1},f):fe(as,f={previous:f.current,current:"",useTimeFallback:!0},f)}function un(){n(55,U=document.querySelector(".yomichan-popup,.yomichan-float,.yomitan-popup,.yomitan-float")),U&&d.disconnect()}function Ye(){if(!te&&!U||u)return;const He=ut();He&&!c?(fe(Mn,c=!0,c),n(11,De=!0)):!He&&c&&De&&(fe(Mn,c=!1,c),n(11,De=!1))}function ut(){return U&&U.style.visibility!=="hidden"||te&&te.style.opacity!=="0"}async function yr(){ee&&!ee.released||(ee=await navigator.wakeLock.request().catch(()=>{}),ee&&ee.addEventListener("release",Xn,!1))}async function Xn(){ee&&!ee.released&&await ee.release().catch(()=>{}),ee=void 0}function Yt(He){fe(qo,l=Wi(.1,2,Math.round((l+He)*100+Number.EPSILON)/100),l),n(12,ft=l)}function sr(He){mn.call(this,t,He)}function Qn(He){mn.call(this,t,He)}function Un(){v=this.currentTime,Ui.set(v)}function vr(){$=this.duration,ls.set($)}function dr(){m=this.muted,qa.set(m)}function hn(){c=this.paused,Mn.set(c)}function Gr(){l=this.playbackRate,qo.set(l)}function pn(He){Vt[He?"unshift":"push"](()=>{D=He,n(0,D)})}function or(){n(1,ge=vm.visibilityState)}const Or=()=>{fe(Mn,c=!c,c),n(11,De=!1)},oi=()=>Fn(Re.RESTART_PLAYBACK,an(Math.max(0,v-Y)),{keepPauseState:!0}),Wn=()=>Fn(Re.RESTART_PLAYBACK,an(Math.max(0,v-K)),{keepPauseState:!0}),jr=()=>Fn(Re.RESTART_PLAYBACK,an(Math.min($,v+N)),{keepPauseState:!0}),Ve=()=>Fn(Re.RESTART_PLAYBACK,an(Math.min($,v+F)),{keepPauseState:!0}),It=()=>fe(qa,m=!m,m);function Bt(){ft=Nc(this.value),n(12,ft)}const $t=()=>Yt(-J),tn=()=>Yt(j);function Tn(He){Vt[He?"unshift":"push"](()=>{se=He,n(9,se)})}return t.$$set=He=>{"imageLoaded"in He&&n(53,le=He.imageLoaded)},t.$$.update=()=>{t.$$.dirty[0]&260&&n(17,r=u?"Recording in progress":`Rewind ${K} seconds`),t.$$.dirty[0]&132&&n(16,i=u?"Recording in progress":`Rewind ${Y} seconds`),t.$$.dirty[0]&68&&n(15,s=u?"Recording in progress":`Fast-Forward ${N} seconds`),t.$$.dirty[0]&36&&n(14,o=u?"Recording in progress":`Fast-Forward ${F} seconds`),t.$$.dirty[0]&24&&n(13,a=Math.min(100,Qa(v,$))),t.$$.dirty[0]&2&&In(ge),t.$$.dirty[1]&1073741824&&Hn(W),t.$$.dirty[0]&1|t.$$.dirty[1]&536870912&&D&&re&&xn(re),t.$$.dirty[1]&150994944&&(A!==fi.DISABLED&&!U?(n(55,U=document.querySelector(".yomichan-popup,.yomichan-float,.yomitan-popup,.yomitan-float")),U||d.observe(document.body,{childList:!0,subtree:!1})):d.disconnect()),t.$$.dirty[1]&251658240&&(A!==fi.DISABLED&&!h?(U&&k.observe(U,{attributes:!0}),te&&k.observe(te,{attributes:!0})):k.disconnect()),t.$$.dirty[1]&268435456&&(L?yr():Xn())},[D,ge,u,v,$,F,N,Y,K,se,pe,De,ft,a,o,s,i,r,l,c,m,C,J,j,z,ve,ke,Ne,Te,Le,Fe,Ze,O,H,Pe,xe,qe,nt,Oe,je,et,rt,Je,Qe,vt,Rt,lt,St,ht,xt,ln,yr,Yt,le,Me,U,te,h,A,L,re,W,sr,Qn,Un,vr,dr,hn,Gr,pn,or,Or,oi,Wn,jr,Ve,It,Bt,$t,tn,Tn]}class Ay extends Dn{constructor(e){super(),Bn(this,e,ky,Ty,Cn,{imageLoaded:53,onScrollToSubtitle:54},null,[-1,-1,-1,-1,-1])}get onScrollToSubtitle(){return this.$$.ctx[54]}}function Cy(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Sm={exports:{}},fr=Sm.exports={},Ki,qi;function Tf(){throw new Error("setTimeout has not been defined")}function kf(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?Ki=setTimeout:Ki=Tf}catch{Ki=Tf}try{typeof clearTimeout=="function"?qi=clearTimeout:qi=kf}catch{qi=kf}})();function Tm(t){if(Ki===setTimeout)return setTimeout(t,0);if((Ki===Tf||!Ki)&&setTimeout)return Ki=setTimeout,setTimeout(t,0);try{return Ki(t,0)}catch{try{return Ki.call(null,t,0)}catch{return Ki.call(this,t,0)}}}function My(t){if(qi===clearTimeout)return clearTimeout(t);if((qi===kf||!qi)&&clearTimeout)return qi=clearTimeout,clearTimeout(t);try{return qi(t)}catch{try{return qi.call(null,t)}catch{return qi.call(this,t)}}}var ys=[],pa=!1,go,dc=-1;function Ry(){!pa||!go||(pa=!1,go.length?ys=go.concat(ys):dc=-1,ys.length&&km())}function km(){if(!pa){var t=Tm(Ry);pa=!0;for(var e=ys.length;e;){for(go=ys,ys=[];++dc<e;)go&&go[dc].run();dc=-1,e=ys.length}go=null,pa=!1,My(t)}}fr.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];ys.push(new Am(t,e)),ys.length===1&&!pa&&Tm(km)};function Am(t,e){this.fun=t,this.array=e}Am.prototype.run=function(){this.fun.apply(null,this.array)},fr.title="browser",fr.browser=!0,fr.env={},fr.argv=[],fr.version="",fr.versions={};function vs(){}fr.on=vs,fr.addListener=vs,fr.once=vs,fr.off=vs,fr.removeListener=vs,fr.removeAllListeners=vs,fr.emit=vs,fr.prependListener=vs,fr.prependOnceListener=vs,fr.listeners=function(t){return[]},fr.binding=function(t){throw new Error("process.binding is not supported")},fr.cwd=function(){return"/"},fr.chdir=function(t){throw new Error("process.chdir is not supported")},fr.umask=function(){return 0};var Ly=Sm.exports;const ma=Cy(Ly);function _a(t,e,n){let r=n.initialDeps??[],i;return()=>{var s,o,a,l;let c;n.key&&((s=n.debug)!=null&&s.call(n))&&(c=Date.now());const u=t();if(!(u.length!==r.length||u.some((v,_)=>r[_]!==v)))return i;r=u;let g;if(n.key&&((o=n.debug)!=null&&o.call(n))&&(g=Date.now()),i=e(...u),n.key&&((a=n.debug)!=null&&a.call(n))){const v=Math.round((Date.now()-c)*100)/100,_=Math.round((Date.now()-g)*100)/100,b=_/16,y=(p,m)=>{for(p=String(p);p.length<m;)p=" "+p;return p};console.info(`%c⏱ ${y(_,5)} /${y(v,5)} ms`,`
font-size: .6rem;
font-weight: bold;
color: hsl(${Math.max(0,Math.min(120-120*b,120))}deg 100% 31%);`,n==null?void 0:n.key)}return(l=n==null?void 0:n.onChange)==null||l.call(n,i),i}}function Af(t,e){if(t===void 0)throw new Error(`Unexpected undefined${e?`: ${e}`:""}`);return t}const Py=(t,e)=>Math.abs(t-e)<1,Iy=t=>t,Oy=t=>{const e=Math.max(t.startIndex-t.overscan,0),n=Math.min(t.endIndex+t.overscan,t.count-1),r=[];for(let i=e;i<=n;i++)r.push(i);return r},By=(t,e)=>{const n=t.scrollElement;if(!n)return;const r=s=>{const{width:o,height:a}=s;e({width:Math.round(o),height:Math.round(a)})};if(r(n.getBoundingClientRect()),typeof ResizeObserver>"u")return()=>{};const i=new ResizeObserver(s=>{const o=s[0];if(o!=null&&o.borderBoxSize){const a=o.borderBoxSize[0];if(a){r({width:a.inlineSize,height:a.blockSize});return}}r(n.getBoundingClientRect())});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},Dy=(t,e)=>{const n=t.scrollElement;if(!n)return;const r=()=>{e(n[t.options.horizontal?"scrollLeft":"scrollTop"])};return r(),n.addEventListener("scroll",r,{passive:!0}),()=>{n.removeEventListener("scroll",r)}},Fy=(t,e,n)=>{if(e!=null&&e.borderBoxSize){const r=e.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return Math.round(t.getBoundingClientRect()[n.options.horizontal?"width":"height"])},$y=(t,{adjustments:e=0,behavior:n},r)=>{var i,s;const o=t+e;(s=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||s.call(i,{[r.options.horizontal?"left":"top"]:o,behavior:n})};class Ny{constructor(e){this.unsubs=[],this.scrollElement=null,this.isScrolling=!1,this.isScrollingTimeoutId=null,this.scrollToIndexTimeoutId=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollDirection=null,this.scrollAdjustments=0,this.measureElementCache=new Map,this.observer=(()=>{let n=null;const r=()=>n||(typeof ResizeObserver<"u"?n=new ResizeObserver(i=>{i.forEach(s=>{this._measureElement(s.target,s)})}):null);return{disconnect:()=>{var i;return(i=r())==null?void 0:i.disconnect()},observe:i=>{var s;return(s=r())==null?void 0:s.observe(i,{box:"border-box"})},unobserve:i=>{var s;return(s=r())==null?void 0:s.unobserve(i)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,i])=>{typeof i>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Iy,rangeExtractor:Oy,onChange:()=>{},measureElement:Fy,initialRect:{width:0,height:0},scrollMargin:0,scrollingDelay:150,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,...n}},this.notify=n=>{var r,i;(i=(r=this.options).onChange)==null||i.call(r,this,n)},this.maybeNotify=_a(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:ma.env.NODE_ENV!=="production"&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.scrollElement=null},this._didMount=()=>(this.measureElementCache.forEach(this.observer.observe),()=>{this.observer.disconnect(),this.cleanup()}),this._willUpdate=()=>{const n=this.options.getScrollElement();this.scrollElement!==n&&(this.cleanup(),this.scrollElement=n,this._scrollToOffset(this.scrollOffset,{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,r=>{this.scrollRect=r,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,r=>{this.scrollAdjustments=0,this.scrollOffset!==r&&(this.isScrollingTimeoutId!==null&&(clearTimeout(this.isScrollingTimeoutId),this.isScrollingTimeoutId=null),this.isScrolling=!0,this.scrollDirection=this.scrollOffset<r?"forward":"backward",this.scrollOffset=r,this.maybeNotify(),this.isScrollingTimeoutId=setTimeout(()=>{this.isScrollingTimeoutId=null,this.isScrolling=!1,this.scrollDirection=null,this.maybeNotify()},this.options.scrollingDelay))})))},this.getSize=()=>this.scrollRect[this.options.horizontal?"width":"height"],this.memoOptions=_a(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey],(n,r,i,s)=>(this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:i,getItemKey:s}),{key:!1}),this.getFurthestMeasurement=(n,r)=>{const i=new Map,s=new Map;for(let o=r-1;o>=0;o--){const a=n[o];if(i.has(a.lane))continue;const l=s.get(a.lane);if(l==null||a.end>l.end?s.set(a.lane,a):a.end<l.end&&i.set(a.lane,!0),i.size===this.options.lanes)break}return s.size===this.options.lanes?Array.from(s.values()).sort((o,a)=>o.end===a.end?o.index-a.index:o.end-a.end)[0]:void 0},this.getMeasurements=_a(()=>[this.memoOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:i,getItemKey:s},o)=>{const a=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const l=this.measurementsCache.slice(0,a);for(let c=a;c<n;c++){const u=s(c),f=this.options.lanes===1?l[c-1]:this.getFurthestMeasurement(l,c),g=f?f.end:r+i,v=o.get(u),_=typeof v=="number"?v:this.options.estimateSize(c),b=g+_,y=f?f.lane:c%this.options.lanes;l[c]={index:c,start:g,size:_,end:b,key:u,lane:y}}return this.measurementsCache=l,l},{key:ma.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=_a(()=>[this.getMeasurements(),this.getSize(),this.scrollOffset],(n,r,i)=>this.range=n.length>0&&r>0?Vy({measurements:n,outerSize:r,scrollOffset:i}):null,{key:ma.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getIndexes=_a(()=>[this.options.rangeExtractor,this.calculateRange(),this.options.overscan,this.options.count],(n,r,i,s)=>r===null?[]:n({...r,overscan:i,count:s}),{key:ma.env.NODE_ENV!=="production"&&"getIndexes",debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,i=n.getAttribute(r);return i?parseInt(i,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(n,r)=>{const i=this.measurementsCache[this.indexFromElement(n)];if(!i||!n.isConnected){this.measureElementCache.forEach((a,l)=>{a===n&&(this.observer.unobserve(n),this.measureElementCache.delete(l))});return}const s=this.measureElementCache.get(i.key);s!==n&&(s&&this.observer.unobserve(s),this.observer.observe(n),this.measureElementCache.set(i.key,n));const o=this.options.measureElement(n,r,this);this.resizeItem(i,o)},this.resizeItem=(n,r)=>{const i=this.itemSizeCache.get(n.key)??n.size,s=r-i;s!==0&&(n.start<this.scrollOffset+this.scrollAdjustments&&(ma.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",s),this._scrollToOffset(this.scrollOffset,{adjustments:this.scrollAdjustments+=s,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,r)),this.notify(!1))},this.measureElement=n=>{n&&this._measureElement(n,void 0)},this.getVirtualItems=_a(()=>[this.getIndexes(),this.getMeasurements()],(n,r)=>{const i=[];for(let s=0,o=n.length;s<o;s++){const a=n[s],l=r[a];i.push(l)}return i},{key:ma.env.NODE_ENV!=="production"&&"getIndexes",debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();return Af(r[Cm(0,r.length-1,i=>Af(r[i]).start,n)])},this.getOffsetForAlignment=(n,r)=>{const i=this.getSize();r==="auto"&&(n<=this.scrollOffset?r="start":n>=this.scrollOffset+i?r="end":r="start"),r==="start"?n=n:r==="end"?n=n-i:r==="center"&&(n=n-i/2);const s=this.options.horizontal?"scrollWidth":"scrollHeight",a=(this.scrollElement?"document"in this.scrollElement?this.scrollElement.document.documentElement[s]:this.scrollElement[s]:0)-this.getSize();return Math.max(Math.min(a,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=Af(this.getMeasurements()[n]);if(r==="auto")if(i.end>=this.scrollOffset+this.getSize()-this.options.scrollPaddingEnd)r="end";else if(i.start<=this.scrollOffset+this.options.scrollPaddingStart)r="start";else return[this.scrollOffset,r];const s=r==="end"?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(s,r),r]},this.isDynamicMode=()=>this.measureElementCache.size>0,this.cancelScrollToIndex=()=>{this.scrollToIndexTimeoutId!==null&&(clearTimeout(this.scrollToIndexTimeoutId),this.scrollToIndexTimeoutId=null)},this.scrollToOffset=(n,{align:r="start",behavior:i}={})=>{this.cancelScrollToIndex(),i==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(n,r),{adjustments:void 0,behavior:i})},this.scrollToIndex=(n,{align:r="auto",behavior:i}={})=>{n=Math.max(0,Math.min(n,this.options.count-1)),this.cancelScrollToIndex(),i==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");const[s,o]=this.getOffsetForIndex(n,r);this._scrollToOffset(s,{adjustments:void 0,behavior:i}),i!=="smooth"&&this.isDynamicMode()&&(this.scrollToIndexTimeoutId=setTimeout(()=>{if(this.scrollToIndexTimeoutId=null,this.measureElementCache.has(this.options.getItemKey(n))){const[l]=this.getOffsetForIndex(n,o);Py(l,this.scrollOffset)||this.scrollToIndex(n,{align:o,behavior:i})}else this.scrollToIndex(n,{align:o,behavior:i})}))},this.scrollBy=(n,{behavior:r}={})=>{this.cancelScrollToIndex(),r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.scrollOffset+n,{adjustments:void 0,behavior:r})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let i;return r.length===0?i=this.options.paddingStart:i=this.options.lanes===1?((n=r[r.length-1])==null?void 0:n.end)??0:Math.max(...r.slice(-this.options.lanes).map(s=>s.end)),i-this.options.scrollMargin+this.options.paddingEnd},this._scrollToOffset=(n,{adjustments:r,behavior:i})=>{this.options.scrollToFn(n,{behavior:i,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(e),this.scrollRect=this.options.initialRect,this.scrollOffset=this.options.initialOffset,this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(n=>{this.itemSizeCache.set(n.key,n.size)}),this.maybeNotify()}}const Cm=(t,e,n,r)=>{for(;t<=e;){const i=(t+e)/2|0,s=n(i);if(s<r)t=i+1;else if(s>r)e=i-1;else return i}return t>0?t-1:0};function Vy({measurements:t,outerSize:e,scrollOffset:n}){const r=t.length-1,s=Cm(0,r,a=>t[a].start,n);let o=s;for(;o<r&&t[o].end<n+e;)o++;return{startIndex:s,endIndex:o}}function Hy(t){const e=new Ny(t),n=e.setOptions;let r;const i=s=>{const o={...e.options,...s,onChange:s.onChange};n({...o,onChange:(a,l)=>{var c;r.set(a),(c=o.onChange)==null||c.call(o,a,l)}}),e._willUpdate()};return r=on(e,()=>(i(t),e._didMount())),H_(r,s=>Object.assign(s,{setOptions:i}))}function xy(t){return Hy({observeElementRect:By,observeElementOffset:Dy,scrollToFn:$y,...t})}function Mm(t,e,n){const r=t.slice();return r[56]=e[n],r[57]=e,r[58]=n,r}function Rm(t){let e,n,r=[],i=new Map,s,o,a=Jr(t[9]);const l=c=>c[56].key;for(let c=0;c<a.length;c+=1){let u=Mm(t,a,c),f=l(u);i.set(f,r[c]=Lm(f,u))}return{c(){var c;e=_e("div"),n=_e("div");for(let u=0;u<r.length;u+=1)r[u].c();ie(n,"class","absolute top-0 left-0 w-full"),ie(n,"style",s=`transform: translateY(${((c=t[9][0])==null?void 0:c.start)||0}px); font-family: "${t[25]}", "Lora", "Noto Serif JP", serif; font-size: ${t[26]}px; line-height: ${t[27]};`),ie(e,"class","relative w-full"),Cr(e,"height",`${t[5].getTotalSize()}px`)},m(c,u){he(c,e,u),oe(e,n);for(let f=0;f<r.length;f+=1)r[f]&&r[f].m(n,null);o=!0},p(c,u){var f;u[0]&805314123&&(a=Jr(c[9]),jt(),r=Ks(r,u,l,1,c,a,i,n,cd,Lm,null,Mm),zt()),(!o||u[0]&512&&s!==(s=`transform: translateY(${((f=c[9][0])==null?void 0:f.start)||0}px); font-family: "${c[25]}", "Lora", "Noto Serif JP", serif; font-size: ${c[26]}px; line-height: ${c[27]};`))&&ie(n,"style",s),u[0]&32&&Cr(e,"height",`${c[5].getTotalSize()}px`)},i(c){if(!o){for(let u=0;u<a.length;u+=1)Z(r[u]);o=!0}},o(c){for(let u=0;u<r.length;u+=1)ne(r[u]);o=!1},d(c){c&&de(e);for(let u=0;u<r.length;u+=1)r[u].d()}}}function Lm(t,e){let n,r,i=e[0][e[56].index].text+"",s,o,a,l,c,u,f,g,v=e[58],_,b,y;u=new _1({props:{hideCancelAction:!0,listItems:e[12],subtitle:e[0][e[56].index],skipUpdates:e[1]}});const p=()=>e[33](n,v),m=()=>e[33](null,v);return{key:t,first:null,c(){n=_e("div"),r=_e("div"),s=Nt(i),a=me(),l=_e("div"),c=_e("div"),ye(u.$$.fragment),f=me(),ie(r,"tabindex","0"),ie(r,"role","button"),ie(r,"class","flex-1 p-b"),ie(r,"title",o=e[11]?"Recording in progress":null),pt(r,"cursor-not-allowed",e[11]),ie(c,"class","grid"),ie(l,"class","flex invisible m-x-xs m-y-b sub-action"),pt(l,"show",e[10]===Tr.ALWAYS),pt(l,"hidden",e[10]===Tr.HIDDEN),ie(n,"class","flex items-center sub"),ie(n,"data-index",g=e[56].index),pt(n,"active",e[6].current===e[56].key),pt(n,"on-hover",e[10]===Tr.HOVER),this.first=n},m(w,C){he(w,n,C),oe(n,r),oe(r,s),oe(n,a),oe(n,l),oe(l,c),be(u,c,null),oe(n,f),p(),_=!0,b||(y=[Xe(r,"click",e[28]),Xe(r,"pointerdown",e[29]),Xe(r,"keyup",Wy)],b=!0)},p(w,C){e=w,(!_||C[0]&513)&&i!==(i=e[0][e[56].index].text+"")&&cn(s,i),(!_||C[0]&2048&&o!==(o=e[11]?"Recording in progress":null))&&ie(r,"title",o),(!_||C[0]&2048)&&pt(r,"cursor-not-allowed",e[11]);const h={};C[0]&4096&&(h.listItems=e[12]),C[0]&513&&(h.subtitle=e[0][e[56].index]),C[0]&2&&(h.skipUpdates=e[1]),u.$set(h),(!_||C[0]&1024)&&pt(l,"show",e[10]===Tr.ALWAYS),(!_||C[0]&1024)&&pt(l,"hidden",e[10]===Tr.HIDDEN),(!_||C[0]&512&&g!==(g=e[56].index))&&ie(n,"data-index",g),v!==e[58]&&(m(),v=e[58],p()),(!_||C[0]&576)&&pt(n,"active",e[6].current===e[56].key),(!_||C[0]&1024)&&pt(n,"on-hover",e[10]===Tr.HOVER)},i(w){_||(Z(u.$$.fragment,w),_=!0)},o(w){ne(u.$$.fragment,w),_=!1},d(w){w&&de(n),we(u),m(),b=!1,vn(y)}}}function Uy(t){let e,n,r,i,s=t[8]>0&&t[2]&&Rm(t);return{c(){e=_e("div"),s&&s.c(),ie(e,"class","ttu-whispersync-container subtitle-container h-full w-full"),Cr(e,"height",t[8]?`${t[8]}px`:null)},m(o,a){he(o,e,a),s&&s.m(e,null),t[34](e),n=!0,r||(i=[Xe(e,"pointerdown",t[35]),Xe(e,"pointerup",t[36])],r=!0)},p(o,a){o[8]>0&&o[2]?s?(s.p(o,a),a[0]&260&&Z(s,1)):(s=Rm(o),s.c(),Z(s,1),s.m(e,null)):s&&(jt(),ne(s,1,1,()=>{s=null}),zt()),a[0]&256&&Cr(e,"height",o[8]?`${o[8]}px`:null)},i(o){n||(Z(s),n=!0)},o(o){ne(s),n=!1},d(o){o&&de(e),s&&s.d(),t[34](null),r=!1,vn(i)}}}const Wy=()=>{};function Gy(t,e,n){let r,i,s=wt,o=()=>(s(),s=ns(z,Oe=>n(5,i=Oe)),z),a,l,c,u,f,g,v,_,b,y,p,m,w,C,h,A,L,$;ce(t,Fa,Oe=>n(41,u=Oe)),ce(t,as,Oe=>n(6,g=Oe)),ce(t,Mt,Oe=>n(32,v=Oe)),ce(t,Lr,Oe=>n(48,C=Oe)),ce(t,Ui,Oe=>n(49,h=Oe)),ce(t,xi,Oe=>n(11,L=Oe)),t.$$.on_destroy.push(()=>s());let{subtitles:P}=e,{skipUpdates:I=!1}=e;async function x(...Oe){le&&(n(8,ke=0),await Mr(),z||o(n(2,z=xy({count:P.length,overscan:10,estimateSize:()=>150,getScrollElement:()=>le,getItemKey:je=>P[je].id}))),i.measure(),n(8,ke=Math.floor(le.getBoundingClientRect().height)),await Mr(),ae())}async function ae(Oe=!1){if(L||!i||!P.length||!Oe&&(!A||!g.previous&&!g.current&&!g.useTimeFallback))return;const{previous:je,current:et,useTimeFallback:rt}=g,Je=h;let G=-1;if(et&&C.has(et)?G=P.findIndex(T=>T.id===et):je&&C.has(je)&&(G=P.findIndex(T=>T.id===je)),G===-1&&(Oe||rt)&&(G=Je?P.findLastIndex(T=>Je>=T.startSeconds):0),G!==-1){for(;!i.itemSizeCache.has(P[G].id);)H(),i.scrollToIndex(G,{align:"auto"}),await new Promise(T=>setTimeout(T));H(),i.scrollToIndex(G,{align:"auto"})}}const{subtitlesEnableAutoScroll$:V,subtitlePreventActionOnSelection$:E,subtitlesCopyFontFamily$:F,subtitlesCopyFontSize$:N,subtitlesCopyLineHeight$:Y,subtitlesFontFamily$:K,subtitlesFontSize$:J,subtitlesLineHeight$:j,subtitlesClickAction$:B,subtitlesActionsVisibility$:M,subtitlesActionsVisibilityTime$:S,actionListOfSubtitles$:R}=_t;ce(t,V,Oe=>n(50,A=Oe)),ce(t,E,Oe=>n(38,a=Oe)),ce(t,F,Oe=>n(47,w=Oe)),ce(t,N,Oe=>n(45,p=Oe)),ce(t,Y,Oe=>n(43,b=Oe)),ce(t,K,Oe=>n(46,m=Oe)),ce(t,J,Oe=>n(44,y=Oe)),ce(t,j,Oe=>n(42,_=Oe)),ce(t,B,Oe=>n(39,l=Oe)),ce(t,M,Oe=>n(10,f=Oe)),ce(t,S,Oe=>n(40,c=Oe)),ce(t,R,Oe=>n(12,$=Oe));const X=w?window.localStorage.getItem("fontFamilyGroupOne")||"Noto Serif JP":m,re=p?Number.parseInt(window.localStorage.getItem("fontSize")||"16",10):y,W=b?Number.parseFloat(window.localStorage.getItem("lineHeight")||"1.65"):_;let z,le,Me=[],Ee,ve=!1,ke=0;Oa(x);function Ne(Oe){Oe.button!==0||l===Re.NONE||f===Tr.TOGGLE||Fe()||(Ze(),Fn(l,P[Number.parseInt(Oe.currentTarget.parentElement.dataset.index,10)]))}function Te(Oe){var et;if(Oe.button!==0||f!==Tr.TOGGLE)return;a&&u&&((et=window.getSelection())==null||et.removeAllRanges(),document.body.style.userSelect="none");const{currentTarget:je}=Oe;je.addEventListener("pointerup",Le,!1),Ee=window.setTimeout(()=>{var rt;Ze(je),Fe()||(rt=je.nextElementSibling)==null||rt.classList.toggle("show")},c)}function Le(){Ze(this),!Fe()&&Fn(l,P[Number.parseInt(this.parentElement.dataset.index,10)])}function Fe(){var je;return a?!!((je=window.getSelection())==null?void 0:je.toString().trim()):!1}function Ze(Oe){clearTimeout(Ee),Oe==null||Oe.removeEventListener("pointerup",Le,!1),document.body.style.userSelect="auto"}async function O(){i&&(i.setOptions({count:P.length}),i.scrollToOffset(0),n(9,r=i.getVirtualItems()),i.measure(),ae())}function H(){for(let Oe=0,{length:je}=Me;Oe<je;Oe+=1)i.measureElement(Me[Oe])}function Pe(Oe,je){Vt[Oe?"unshift":"push"](()=>{Me[je]=Oe,n(3,Me)})}function xe(Oe){Vt[Oe?"unshift":"push"](()=>{le=Oe,n(7,le)})}const qe=()=>n(4,ve=!0),nt=()=>n(4,ve=!1);return t.$$set=Oe=>{"subtitles"in Oe&&n(0,P=Oe.subtitles),"skipUpdates"in Oe&&n(1,I=Oe.skipUpdates)},t.$$.update=()=>{t.$$.dirty[0]&36&&n(9,r=z?i.getVirtualItems():[]),t.$$.dirty[1]&2&&x(v),t.$$.dirty[0]&1&&P&&O(),t.$$.dirty[0]&64&&g&&ae(),t.$$.dirty[0]&24&&Me.length&&!ve&&H()},[P,I,z,Me,ve,i,g,le,ke,r,f,L,$,V,E,F,N,Y,K,J,j,B,M,S,R,X,re,W,Ne,Te,x,ae,v,Pe,xe,qe,nt]}class jy extends Dn{constructor(e){super(),Bn(this,e,Gy,Uy,Cn,{subtitles:0,skipUpdates:1,onResetList:30,scrollToSubtitle:31},null,[-1,-1])}get onResetList(){return this.$$.ctx[30]}get scrollToSubtitle(){return this.$$.ctx[31]}}function zy(t){let e,n,r,i,s,o,a;return{c(){e=_e("div"),n=Xs("svg"),r=Xs("g"),i=Xs("g"),s=Xs("path"),ie(s,"d","M448 80c8.8 0 16 7.2 16 16V415.8l-5-6.5-136-176c-4.5-5.9-11.6-9.3-19-9.3s-14.4 3.4-19 9.3L202 340.7l-30.5-42.7C167 291.7 159.8 288 152 288s-15 3.7-19.5 10.1l-80 112L48 416.3l0-.3V96c0-8.8 7.2-16 16-16H448zM64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64zm80 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"),ie(s,"fill","currentColor"),ie(s,"transform","translate(-256 -256)"),ie(i,"transform","translate(0,0) scale(1,1)"),ie(r,"transform","translate(256 256)"),ie(r,"transform-origin","128 0"),ie(n,"width","100%"),ie(n,"height","100%"),ie(n,"viewBox","0 0 512 512"),ie(n,"aria-hidden","true"),ie(n,"role","img"),ie(n,"xmlns","http://www.w3.org/2000/svg"),ie(e,"class","cover")},m(l,c){he(l,e,c),oe(e,n),oe(n,r),oe(r,i),oe(i,s),o||(a=Xe(n,"load",function(){Ci(t[42])&&t[42].apply(this,arguments)}),o=!0)},p(l,c){t=l},d(l){l&&de(e),o=!1,a()}}}function Xy(t){let e,n,r,i;return{c(){e=_e("img"),ie(e,"id","ttu-whispersync-cover"),ie(e,"class","cover"),Co(e.src,n=t[51])||ie(e,"src",n),ie(e,"alt","cover")},m(s,o){he(s,e,o),r||(i=Xe(e,"load",function(){Ci(t[42])&&t[42].apply(this,arguments)}),r=!0)},p(s,o){t=s,o[1]&1048576&&!Co(e.src,n=t[51])&&ie(e,"src",n)},d(s){s&&de(e),r=!1,i()}}}function Pm(t){let e,n,r,i,s,o,a;return n=new kt({props:{path:qd}}),{c(){e=_e("button"),ye(n.$$.fragment),ie(e,"class","m-l-s"),ie(e,"title",r=t[12]?"Export in progress":"Drop subtitle file"),e.disabled=i=!!t[12]},m(l,c){he(l,e,c),be(n,e,null),s=!0,o||(a=Xe(e,"click",t[86]),o=!0)},p(l,c){(!s||c[0]&4096&&r!==(r=l[12]?"Export in progress":"Drop subtitle file"))&&ie(e,"title",r),(!s||c[0]&4096&&i!==(i=!!l[12]))&&(e.disabled=i)},i(l){s||(Z(n.$$.fragment,l),s=!0)},o(l){ne(n.$$.fragment,l),s=!1},d(l){l&&de(e),we(n),o=!1,a()}}}function Im(t){let e,n,r,i,s,o,a;return n=new kt({props:{path:_g}}),{c(){e=_e("button"),ye(n.$$.fragment),ie(e,"class","m-l-s"),ie(e,"title",r=t[12]?"Export in progress":"Drop persisted subtitles"),e.disabled=i=!!t[12]},m(l,c){he(l,e,c),be(n,e,null),s=!0,o||(a=Xe(e,"click",t[71]),o=!0)},p(l,c){(!s||c[0]&4096&&r!==(r=l[12]?"Export in progress":"Drop persisted subtitles"))&&ie(e,"title",r),(!s||c[0]&4096&&i!==(i=!!l[12]))&&(e.disabled=i)},i(l){s||(Z(n.$$.fragment,l),s=!0)},o(l){ne(n.$$.fragment,l),s=!1},d(l){l&&de(e),we(n),o=!1,a()}}}function Yy(t){var y,p;let e,n=(((y=t[11])==null?void 0:y.name)||"None selected")+"",r,i,s,o,a,l,c,u,f,g,v;o=new kt({props:{path:t[11]?Su:Tu}});let _=(t[7].lastSubtitle||((p=t[17])==null?void 0:p.value)||t[24])&&Pm(t),b=t[7].subtitleData&&t[7].subtitleData.subtitles.length&&Im(t);return{c(){e=_e("div"),r=Nt(n),i=me(),s=_e("button"),ye(o.$$.fragment),l=me(),_&&_.c(),c=me(),b&&b.c(),u=Fr(),ie(s,"title",t[26]),s.disabled=a=!!t[12]},m(m,w){he(m,e,w),oe(e,r),he(m,i,w),he(m,s,w),be(o,s,null),he(m,l,w),_&&_.m(m,w),he(m,c,w),b&&b.m(m,w),he(m,u,w),f=!0,g||(v=Xe(s,"click",t[67]),g=!0)},p(m,w){var h,A;(!f||w[0]&2048)&&n!==(n=(((h=m[11])==null?void 0:h.name)||"None selected")+"")&&cn(r,n);const C={};w[0]&2048&&(C.path=m[11]?Su:Tu),o.$set(C),(!f||w[0]&67108864)&&ie(s,"title",m[26]),(!f||w[0]&4096&&a!==(a=!!m[12]))&&(s.disabled=a),m[7].lastSubtitle||(A=m[17])!=null&&A.value||m[24]?_?(_.p(m,w),w[0]&16908416&&Z(_,1)):(_=Pm(m),_.c(),Z(_,1),_.m(c.parentNode,c)):_&&(jt(),ne(_,1,1,()=>{_=null}),zt()),m[7].subtitleData&&m[7].subtitleData.subtitles.length?b?(b.p(m,w),w[0]&128&&Z(b,1)):(b=Im(m),b.c(),Z(b,1),b.m(u.parentNode,u)):b&&(jt(),ne(b,1,1,()=>{b=null}),zt())},i(m){f||(Z(o.$$.fragment,m),Z(_),Z(b),f=!0)},o(m){ne(o.$$.fragment,m),ne(_),ne(b),f=!1},d(m){m&&(de(e),de(i),de(s),de(l),de(c),de(u)),we(o),_&&_.d(m),b&&b.d(m),g=!1,v()}}}function Ky(t){let e,n,r;return n=new kt({props:{path:Pg}}),{c(){e=_e("div"),ye(n.$$.fragment),ie(e,"slot","icon"),ie(e,"title","Show subtitle file")},m(i,s){he(i,e,s),be(n,e,null),r=!0},p:wt,i(i){r||(Z(n.$$.fragment,i),r=!0)},o(i){ne(n.$$.fragment,i),r=!1},d(i){i&&de(e),we(n)}}}function qy(t){let e;return{c(){e=_e("div"),e.textContent="Book not matched yet"},m(n,r){he(n,e,r)},p:wt,d(n){n&&de(e)}}}function Zy(t){let e,n,r,i=t[14].matchedBy+"",s,o,a,l=t[14].matchedOn&&Om(t);return{c(){e=_e("div"),e.textContent="Matched by",n=me(),r=_e("div"),s=Nt(i),o=me(),l&&l.c(),a=Fr()},m(c,u){he(c,e,u),he(c,n,u),he(c,r,u),oe(r,s),he(c,o,u),l&&l.m(c,u),he(c,a,u)},p(c,u){u[0]&16384&&i!==(i=c[14].matchedBy+"")&&cn(s,i),c[14].matchedOn?l?l.p(c,u):(l=Om(c),l.c(),l.m(a.parentNode,a)):l&&(l.d(1),l=null)},d(c){c&&(de(e),de(n),de(r),de(o),de(a)),l&&l.d(c)}}}function Om(t){let e,n,r=yd(new Date(t[14].matchedOn))+"",i;return{c(){e=_e("div"),n=Nt("On: "),i=Nt(r),ie(e,"class","m-t-xs")},m(s,o){he(s,e,o),oe(e,n),oe(e,i)},p(s,o){o[0]&16384&&r!==(r=yd(new Date(s[14].matchedOn))+"")&&cn(i,r)},d(s){s&&de(e)}}}function Jy(t){let e;function n(s,o){return s[14].matchedBy?Zy:qy}let r=n(t),i=r(t);return{c(){i.c(),e=Fr()},m(s,o){i.m(s,o),he(s,e,o)},p(s,o){r===(r=n(s))&&i?i.p(s,o):(i.d(1),i=r(s),i&&(i.c(),i.m(e.parentNode,e)))},d(s){s&&de(e),i.d(s)}}}function Qy(t){let e,n,r;return n=new kt({props:{path:xd}}),{c(){e=_e("div"),ye(n.$$.fragment),ie(e,"slot","icon"),ie(e,"title","Show matched subtitle file")},m(i,s){he(i,e,s),be(n,e,null),r=!0},p:wt,i(i){r||(Z(n.$$.fragment,i),r=!0)},o(i){ne(n.$$.fragment,i),r=!1},d(i){i&&de(e),we(n)}}}function Bm(t){let e,n,r,i,s,o,a;return n=new kt({props:{path:qd}}),{c(){e=_e("button"),ye(n.$$.fragment),ie(e,"class","m-l-s"),ie(e,"title",r=t[12]?"Export in progress":"Drop audio file"),e.disabled=i=!!t[12]},m(l,c){he(l,e,c),be(n,e,null),s=!0,o||(a=Xe(e,"click",t[88]),o=!0)},p(l,c){(!s||c[0]&4096&&r!==(r=l[12]?"Export in progress":"Drop audio file"))&&ie(e,"title",r),(!s||c[0]&4096&&i!==(i=!!l[12]))&&(e.disabled=i)},i(l){s||(Z(n.$$.fragment,l),s=!0)},o(l){ne(n.$$.fragment,l),s=!1},d(l){l&&de(e),we(n),o=!1,a()}}}function ev(t){var _,b;let e,n=(((_=t[15])==null?void 0:_.name)||"None selected")+"",r,i,s,o,a,l,c,u,f,g;o=new kt({props:{path:t[15]?Su:Tu}});let v=(t[7].lastAudio||((b=t[18])==null?void 0:b.value)||t[25])&&Bm(t);return{c(){e=_e("div"),r=Nt(n),i=me(),s=_e("button"),ye(o.$$.fragment),l=me(),v&&v.c(),c=Fr(),ie(s,"title",t[28]),s.disabled=a=!!t[12]},m(y,p){he(y,e,p),oe(e,r),he(y,i,p),he(y,s,p),be(o,s,null),he(y,l,p),v&&v.m(y,p),he(y,c,p),u=!0,f||(g=Xe(s,"click",t[68]),f=!0)},p(y,p){var w,C;(!u||p[0]&32768)&&n!==(n=(((w=y[15])==null?void 0:w.name)||"None selected")+"")&&cn(r,n);const m={};p[0]&32768&&(m.path=y[15]?Su:Tu),o.$set(m),(!u||p[0]&268435456)&&ie(s,"title",y[28]),(!u||p[0]&4096&&a!==(a=!!y[12]))&&(s.disabled=a),y[7].lastAudio||(C=y[18])!=null&&C.value||y[25]?v?(v.p(y,p),p[0]&33816704&&Z(v,1)):(v=Bm(y),v.c(),Z(v,1),v.m(c.parentNode,c)):v&&(jt(),ne(v,1,1,()=>{v=null}),zt())},i(y){u||(Z(o.$$.fragment,y),Z(v),u=!0)},o(y){ne(o.$$.fragment,y),ne(v),u=!1},d(y){y&&(de(e),de(i),de(s),de(l),de(c)),we(o),v&&v.d(y),f=!1,g()}}}function tv(t){let e,n,r;return n=new kt({props:{path:pg}}),{c(){e=_e("div"),ye(n.$$.fragment),ie(e,"slot","icon"),ie(e,"title","Show audio file")},m(i,s){he(i,e,s),be(n,e,null),r=!0},p:wt,i(i){r||(Z(n.$$.fragment,i),r=!0)},o(i){ne(n.$$.fragment,i),r=!1},d(i){i&&de(e),we(n)}}}function Dm(t){let e,n,r,i,s,o,a,l,c;return o=new kt({props:{path:Fd}}),{c(){e=_e("span"),e.textContent="Id:",n=me(),r=_e("input"),i=me(),s=_e("button"),ye(o.$$.fragment),ie(e,"class","flex items-center m-r-s"),ie(r,"class","m-b-s"),Cr(r,"width","70px"),Cr(r,"height","35px"),ie(s,"title","Jump to time"),ie(s,"class","m-x-s"),s.disabled=t[13]},m(u,f){he(u,e,f),he(u,n,f),he(u,r,f),Mi(r,t[41]),he(u,i,f),he(u,s,f),be(o,s,null),a=!0,l||(c=[Xe(r,"input",t[103]),Xe(s,"click",t[76])],l=!0)},p(u,f){f[1]&1024&&r.value!==u[41]&&Mi(r,u[41]),(!a||f[0]&8192)&&(s.disabled=u[13])},i(u){a||(Z(o.$$.fragment,u),a=!0)},o(u){ne(o.$$.fragment,u),a=!1},d(u){u&&(de(e),de(n),de(r),de(i),de(s)),we(o),l=!1,vn(c)}}}function nv(t){let e,n,r,i,s,o,a,l,c,u,f,g,v,_,b,y,p,m,w,C,h,A,L;function $(F){t[100](F)}let P={defaultValue:0,max:t[44]};t[38]!==void 0&&(P.value=t[38]),s=new Pi({props:P}),Vt.push(()=>Zn(s,"value",$));function I(F){t[101](F)}let x={defaultValue:0};t[39]!==void 0&&(x.value=t[39]),u=new Pi({props:x}),Vt.push(()=>Zn(u,"value",I));function ae(F){t[102](F)}let V={defaultValue:0};t[40]!==void 0&&(V.value=t[40]),b=new Pi({props:V}),Vt.push(()=>Zn(b,"value",ae)),w=new kt({props:{path:Fd}});let E=t[6].size&&Dm(t);return{c(){e=_e("div"),n=_e("span"),n.textContent="Time:",r=me(),i=_e("div"),ye(s.$$.fragment),a=me(),l=_e("span"),l.textContent=":",c=me(),ye(u.$$.fragment),g=me(),v=_e("span"),v.textContent=":",_=me(),ye(b.$$.fragment),p=me(),m=_e("button"),ye(w.$$.fragment),C=me(),E&&E.c(),ie(n,"class","flex items-center m-r-s"),ie(i,"class","flex items-center"),ie(m,"title","Jump to time"),ie(m,"class","m-x-s"),m.disabled=t[13],ie(e,"class","pos-nav")},m(F,N){he(F,e,N),oe(e,n),oe(e,r),oe(e,i),be(s,i,null),oe(i,a),oe(i,l),oe(i,c),be(u,i,null),oe(i,g),oe(i,v),oe(i,_),be(b,i,null),oe(e,p),oe(e,m),be(w,m,null),oe(e,C),E&&E.m(e,null),h=!0,A||(L=Xe(m,"click",t[75]),A=!0)},p(F,N){const Y={};N[1]&8192&&(Y.max=F[44]),!o&&N[1]&128&&(o=!0,Y.value=F[38],Yn(()=>o=!1)),s.$set(Y);const K={};!f&&N[1]&256&&(f=!0,K.value=F[39],Yn(()=>f=!1)),u.$set(K);const J={};!y&&N[1]&512&&(y=!0,J.value=F[40],Yn(()=>y=!1)),b.$set(J),(!h||N[0]&8192)&&(m.disabled=F[13]),F[6].size?E?(E.p(F,N),N[0]&64&&Z(E,1)):(E=Dm(F),E.c(),Z(E,1),E.m(e,null)):E&&(jt(),ne(E,1,1,()=>{E=null}),zt())},i(F){h||(Z(s.$$.fragment,F),Z(u.$$.fragment,F),Z(b.$$.fragment,F),Z(w.$$.fragment,F),Z(E),h=!0)},o(F){ne(s.$$.fragment,F),ne(u.$$.fragment,F),ne(b.$$.fragment,F),ne(w.$$.fragment,F),ne(E),h=!1},d(F){F&&de(e),we(s),we(u),we(b),we(w),E&&E.d(),A=!1,L()}}}function rv(t){let e,n,r=eo(t[46])+"",i,s,o=eo(t[8])+"",a,l,c,u;return{c(){e=_e("div"),n=_e("button"),i=Nt(r),s=Nt(" / "),a=Nt(o),ie(n,"title",l=t[13]?"Recording in progress":"Change playback position"),n.disabled=t[13],ie(e,"slot","icon")},m(f,g){he(f,e,g),oe(e,n),oe(n,i),oe(n,s),oe(n,a),c||(u=Xe(n,"click",t[99]),c=!0)},p(f,g){g[1]&32768&&r!==(r=eo(f[46])+"")&&cn(i,r),g[0]&256&&o!==(o=eo(f[8])+"")&&cn(a,o),g[0]&8192&&l!==(l=f[13]?"Recording in progress":"Change playback position")&&ie(n,"title",l),g[0]&8192&&(n.disabled=f[13])},d(f){f&&de(e),c=!1,u()}}}function Fm(t){let e,n,r,i;return n=new kt({props:{path:gg}}),n.$on("click",t[105]),{c(){e=_e("button"),ye(n.$$.fragment),ie(e,"class","m-l-s"),ie(e,"title",r=t[13]?"Recording in progress":"Scroll to current playback position"),e.disabled=t[13]},m(s,o){he(s,e,o),be(n,e,null),i=!0},p(s,o){(!i||o[0]&8192&&r!==(r=s[13]?"Recording in progress":"Scroll to current playback position"))&&ie(e,"title",r),(!i||o[0]&8192)&&(e.disabled=s[13])},i(s){i||(Z(n.$$.fragment,s),i=!0)},o(s){ne(n.$$.fragment,s),i=!1},d(s){s&&de(e),we(n)}}}function $m(t){let e,n;return e=new Ob({props:{multiple:!0,allowRootFiles:!0,preferNativeFilesystem:!0,height:"100%",dragClasses:"on-drag",filePickerId:"ttu-whispersync-file",label:t[55]?"Click this zone / above icons to select subtitle/audio files":"Click this zone / above icons or drag-and-drop to select subtitle/audio files",disabled:!!t[12],fileFormats:[...t[61],...t[62]],oldHandles:[...t[7].lastSubtitle?[]:[],...t[7].lastAudio?[]:[]],oldFiles:[...t[11]?[]:[],...t[15]?[]:[]]}}),e.$on("start",t[63]),e.$on("stop",t[106]),e.$on("result",t[64]),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},p(r,i){const s={};i[1]&16777216&&(s.label=r[55]?"Click this zone / above icons to select subtitle/audio files":"Click this zone / above icons or drag-and-drop to select subtitle/audio files"),i[0]&4096&&(s.disabled=!!r[12]),i[0]&128&&(s.oldHandles=[...r[7].lastSubtitle?[]:[],...r[7].lastAudio?[]:[]]),i[0]&34816&&(s.oldFiles=[...r[11]?[]:[],...r[15]?[]:[]]),e.$set(s)},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function Nm(t){let e,n,r,i,s,o,a,l,c,u,f;n=new Ef({props:{currentProgress:t[57],rounded:!0,margin:!0}}),s=new kt({props:{path:nl}});let g={skipUpdates:t[5]||t[4],subtitles:t[1]};return l=new jy({props:g}),t[108](l),{c(){var v;e=_e("div"),ye(n.$$.fragment),r=me(),i=_e("button"),ye(s.$$.fragment),a=me(),ye(l.$$.fragment),ie(i,"class","m-l-s"),ie(i,"title","Cancel export"),i.disabled=o=(v=t[12])==null?void 0:v.signal.aborted,ie(e,"class","flex match-btns m-b-s"),pt(e,"invisible",!t[12])},m(v,_){he(v,e,_),be(n,e,null),oe(e,r),oe(e,i),be(s,i,null),he(v,a,_),be(l,v,_),c=!0,u||(f=Xe(i,"click",t[107]),u=!0)},p(v,_){var p;const b={};_[1]&67108864&&(b.currentProgress=v[57]),n.$set(b),(!c||_[0]&4096&&o!==(o=(p=v[12])==null?void 0:p.signal.aborted))&&(i.disabled=o),(!c||_[0]&4096)&&pt(e,"invisible",!v[12]);const y={};_[0]&48&&(y.skipUpdates=v[5]||v[4]),_[0]&2&&(y.subtitles=v[1]),l.$set(y)},i(v){c||(Z(n.$$.fragment,v),Z(s.$$.fragment,v),Z(l.$$.fragment,v),c=!0)},o(v){ne(n.$$.fragment,v),ne(s.$$.fragment,v),ne(l.$$.fragment,v),c=!1},d(v){v&&(de(e),de(a)),we(n),we(s),t[108](null),we(l,v),u=!1,f()}}}function Vm(t){let e,n,r={imageLoaded:t[42]};return e=new Ay({props:r}),t[109](e),e.$on("loadstart",t[78]),e.$on("loaded",t[110]),e.$on("error",t[111]),{c(){ye(e.$$.fragment)},m(i,s){be(e,i,s),n=!0},p(i,s){const o={};s[1]&2048&&(o.imageLoaded=i[42]),e.$set(o)},i(i){n||(Z(e.$$.fragment,i),n=!0)},o(i){ne(e.$$.fragment,i),n=!1},d(i){t[109](null),we(e,i)}}}function iv(t){let e,n,r,i,s,o,a,l,c,u,f,g,v,_,b,y,p,m,w,C,h,A,L,$,P,I,x,ae,V,E,F,N,Y,K,J,j,B,M,S,R,X,re,W,z,le,Me,Ee,ve,ke,Ne,Te,Le,Fe,Ze,O,H,Pe,xe,qe,nt,Oe,je,et,rt,Je,G,T,d,k,D,U,te,ee,se,ge,pe,Ae,Ce,De,tt,mt,We,dt,Be,$e,ft,ze,at,Qe,vt,Rt,lt,St,ht,xt,ln;function qt(Ye,ut){return Ye[51]?Xy:zy}let Dt=qt(t),rn=Dt(t);l=new kt({props:{path:Ig}}),f=new kt({props:{path:sl}});let In={placement:"bottom",$$slots:{icon:[Ky],default:[Yy]},$$scope:{ctx:t}};b=new _i({props:In}),t[87](b),p=new _i({props:{placement:"bottom",$$slots:{icon:[Qy],default:[Jy]},$$scope:{ctx:t}}}),C=new kt({props:{path:yg}});let Hn={placement:"bottom",$$slots:{icon:[tv],default:[ev]},$$scope:{ctx:t}};L=new _i({props:Hn}),t[89](L),I=new kt({props:{path:Jo}}),N=new kt({props:{path:bg}}),j=new kt({props:{path:r1}}),R=new kt({props:{path:Zo}}),z=new kt({props:{path:t[5]?d1:h1}}),ve=new kt({props:{path:t[4]?a1:o1}}),Le=new kt({props:{path:i1}}),H=new kt({props:{path:s1}}),Oe=new kt({props:{path:t[16]?Hd:Vd}}),rt=new kt({props:{path:rl}}),d=new kt({props:{path:il}}),U=new Sn({props:{title:t[54],action:Re.OPEN_LAST_EXPORTED_CARD,subtitle:an(0),path:ol,buttonClasses:""}}),se=new kt({props:{path:sl}}),Ae=new kt({props:{path:sl}}),tt=new kt({props:{path:sl}});let xn={placement:"bottom",$$slots:{icon:[rv],default:[nv]},$$scope:{ctx:t}};dt=new _i({props:xn}),t[104](dt);let Xt=t[6].size&&Fm(t),Ft=!t[6].size&&$m(t),Wt=t[0]&&t[56]===_n.AUDIOBOOK&&t[6].size&&Nm(t),un=t[10]&&Vm(t);return{c(){e=_e("div"),n=_e("button"),rn.c(),i=me(),s=_e("div"),o=_e("div"),a=_e("button"),ye(l.$$.fragment),c=me(),u=_e("button"),ye(f.$$.fragment),_=me(),ye(b.$$.fragment),y=me(),ye(p.$$.fragment),m=me(),w=_e("button"),ye(C.$$.fragment),A=me(),ye(L.$$.fragment),$=me(),P=_e("button"),ye(I.$$.fragment),V=me(),E=_e("div"),F=_e("button"),ye(N.$$.fragment),K=me(),J=_e("button"),ye(j.$$.fragment),M=me(),S=_e("button"),ye(R.$$.fragment),re=me(),W=_e("button"),ye(z.$$.fragment),Me=me(),Ee=_e("button"),ye(ve.$$.fragment),Ne=me(),Te=_e("button"),ye(Le.$$.fragment),Ze=me(),O=_e("button"),ye(H.$$.fragment),xe=me(),qe=_e("div"),nt=_e("button"),ye(Oe.$$.fragment),je=me(),et=_e("button"),ye(rt.$$.fragment),G=me(),T=_e("button"),ye(d.$$.fragment),D=me(),ye(U.$$.fragment),te=me(),ee=_e("button"),ye(se.$$.fragment),ge=me(),pe=_e("button"),ye(Ae.$$.fragment),Ce=me(),De=_e("button"),ye(tt.$$.fragment),mt=me(),We=_e("div"),ye(dt.$$.fragment),Be=me(),Xt&&Xt.c(),$e=me(),ft=_e("div"),ze=_e("div"),Ft&&Ft.c(),at=me(),Wt&&Wt.c(),Qe=me(),un&&un.c(),vt=me(),Rt=_e("input"),lt=me(),St=_e("input"),ie(n,"title",t[28]),n.disabled=r=!!t[12],ie(a,"title","Export book to text file"),ie(u,"title",g=t[6].size?"Save subtitles to file":"Subtitle file required"),u.disabled=v=!t[6].size,ie(w,"title",t[27]),w.disabled=h=!!t[12]||!t[9].htmlBackup,ie(P,"title",x=t[12]?"Export in progress":"Reset all & reload page"),P.disabled=ae=!!t[12],ie(o,"class","flex justify-between w-full header-icons"),ie(F,"title",t[29]),F.disabled=Y=t[29]!=="Reset playback position",ie(J,"title",t[30]),J.disabled=B=t[13]||!t[2]||!t[14].matchedBy,ie(S,"title",t[31]),S.disabled=X=t[13]||!t[2],ie(W,"title",t[53]),W.disabled=le=!t[6].size,ie(Ee,"title",t[52]),Ee.disabled=ke=!t[6].size,ie(Te,"title",t[32]),Te.disabled=Fe=!t[45]||!t[5]&&!t[4],ie(O,"title",t[33]),O.disabled=Pe=!t[45]||!t[5]&&!t[4],ie(E,"class","flex justify-between w-full m-t-s header-icons"),ie(nt,"title",t[43]),ie(et,"title",t[34]),et.disabled=Je=!t[36],ie(T,"title",t[35]),T.disabled=k=!t[37],ie(ee,"class","invisible"),ie(pe,"class","invisible"),ie(De,"class","invisible"),ie(qe,"class","flex justify-between w-full m-t-s header-icons"),ie(We,"class","flex flex-1"),Cr(We,"align-items","flex-end"),pt(We,"hidden",!t[3]&&!t[6].size),ie(s,"class","flex flex-1 flex-col"),ie(e,"class","flex m-y-s"),ie(ze,"class","flex flex-col flex-1"),ie(ft,"class","flex flex-col flex-1"),ie(Rt,"type","file"),ie(Rt,"class","hidden"),ie(Rt,"accept",`application/x-subrip,text/vtt,text/plain,${t[61].join(",")}`),ie(St,"type","file"),ie(St,"class","hidden"),ie(St,"accept",`audio/mp4,audio/mpeg,${t[62].join(",")}`)},m(Ye,ut){he(Ye,e,ut),oe(e,n),rn.m(n,null),oe(e,i),oe(e,s),oe(s,o),oe(o,a),be(l,a,null),oe(o,c),oe(o,u),be(f,u,null),oe(o,_),be(b,o,null),oe(o,y),be(p,o,null),oe(o,m),oe(o,w),be(C,w,null),oe(o,A),be(L,o,null),oe(o,$),oe(o,P),be(I,P,null),oe(s,V),oe(s,E),oe(E,F),be(N,F,null),oe(E,K),oe(E,J),be(j,J,null),oe(E,M),oe(E,S),be(R,S,null),oe(E,re),oe(E,W),be(z,W,null),oe(E,Me),oe(E,Ee),be(ve,Ee,null),oe(E,Ne),oe(E,Te),be(Le,Te,null),oe(E,Ze),oe(E,O),be(H,O,null),oe(s,xe),oe(s,qe),oe(qe,nt),be(Oe,nt,null),oe(qe,je),oe(qe,et),be(rt,et,null),oe(qe,G),oe(qe,T),be(d,T,null),oe(qe,D),be(U,qe,null),oe(qe,te),oe(qe,ee),be(se,ee,null),oe(qe,ge),oe(qe,pe),be(Ae,pe,null),oe(qe,Ce),oe(qe,De),be(tt,De,null),oe(s,mt),oe(s,We),be(dt,We,null),oe(We,Be),Xt&&Xt.m(We,null),he(Ye,$e,ut),he(Ye,ft,ut),oe(ft,ze),Ft&&Ft.m(ze,null),oe(ze,at),Wt&&Wt.m(ze,null),oe(ft,Qe),un&&un.m(ft,null),he(Ye,vt,ut),he(Ye,Rt,ut),t[112](Rt),he(Ye,lt,ut),he(Ye,St,ut),t[113](St),ht=!0,xt||(ln=[Xe(n,"click",t[68]),Xe(a,"click",t[65]),Xe(u,"click",t[66]),Xe(w,"click",t[72]),Xe(P,"click",t[74]),Xe(F,"click",t[73]),Xe(J,"click",t[90]),Xe(S,"click",t[91]),Xe(W,"click",t[92]),Xe(Ee,"click",t[93]),Xe(Te,"click",t[94]),Xe(O,"click",t[95]),Xe(nt,"click",t[96]),Xe(et,"click",t[97]),Xe(T,"click",t[98]),Xe(Rt,"change",t[69]),Xe(St,"change",t[69])],xt=!0)},p(Ye,ut){Dt===(Dt=qt(Ye))&&rn?rn.p(Ye,ut):(rn.d(1),rn=Dt(Ye),rn&&(rn.c(),rn.m(n,null))),(!ht||ut[0]&268435456)&&ie(n,"title",Ye[28]),(!ht||ut[0]&4096&&r!==(r=!!Ye[12]))&&(n.disabled=r),(!ht||ut[0]&64&&g!==(g=Ye[6].size?"Save subtitles to file":"Subtitle file required"))&&ie(u,"title",g),(!ht||ut[0]&64&&v!==(v=!Ye[6].size))&&(u.disabled=v);const yr={};ut[0]&84023424|ut[3]&536870912&&(yr.$$scope={dirty:ut,ctx:Ye}),b.$set(yr);const Xn={};ut[0]&16384|ut[3]&536870912&&(Xn.$$scope={dirty:ut,ctx:Ye}),p.$set(Xn),(!ht||ut[0]&134217728)&&ie(w,"title",Ye[27]),(!ht||ut[0]&4608&&h!==(h=!!Ye[12]||!Ye[9].htmlBackup))&&(w.disabled=h);const Yt={};ut[0]&302289024|ut[3]&536870912&&(Yt.$$scope={dirty:ut,ctx:Ye}),L.$set(Yt),(!ht||ut[0]&4096&&x!==(x=Ye[12]?"Export in progress":"Reset all & reload page"))&&ie(P,"title",x),(!ht||ut[0]&4096&&ae!==(ae=!!Ye[12]))&&(P.disabled=ae),(!ht||ut[0]&536870912)&&ie(F,"title",Ye[29]),(!ht||ut[0]&536870912&&Y!==(Y=Ye[29]!=="Reset playback position"))&&(F.disabled=Y),(!ht||ut[0]&1073741824)&&ie(J,"title",Ye[30]),(!ht||ut[0]&24580&&B!==(B=Ye[13]||!Ye[2]||!Ye[14].matchedBy))&&(J.disabled=B),(!ht||ut[1]&1)&&ie(S,"title",Ye[31]),(!ht||ut[0]&8196&&X!==(X=Ye[13]||!Ye[2]))&&(S.disabled=X);const sr={};ut[0]&32&&(sr.path=Ye[5]?d1:h1),z.$set(sr),(!ht||ut[1]&4194304)&&ie(W,"title",Ye[53]),(!ht||ut[0]&64&&le!==(le=!Ye[6].size))&&(W.disabled=le);const Qn={};ut[0]&16&&(Qn.path=Ye[4]?a1:o1),ve.$set(Qn),(!ht||ut[1]&2097152)&&ie(Ee,"title",Ye[52]),(!ht||ut[0]&64&&ke!==(ke=!Ye[6].size))&&(Ee.disabled=ke),(!ht||ut[1]&2)&&ie(Te,"title",Ye[32]),(!ht||ut[0]&48|ut[1]&16384&&Fe!==(Fe=!Ye[45]||!Ye[5]&&!Ye[4]))&&(Te.disabled=Fe),(!ht||ut[1]&4)&&ie(O,"title",Ye[33]),(!ht||ut[0]&48|ut[1]&16384&&Pe!==(Pe=!Ye[45]||!Ye[5]&&!Ye[4]))&&(O.disabled=Pe);const Un={};ut[0]&65536&&(Un.path=Ye[16]?Hd:Vd),Oe.$set(Un),(!ht||ut[1]&4096)&&ie(nt,"title",Ye[43]),(!ht||ut[1]&8)&&ie(et,"title",Ye[34]),(!ht||ut[1]&32&&Je!==(Je=!Ye[36]))&&(et.disabled=Je),(!ht||ut[1]&16)&&ie(T,"title",Ye[35]),(!ht||ut[1]&64&&k!==(k=!Ye[37]))&&(T.disabled=k);const vr={};ut[1]&8388608&&(vr.title=Ye[54]),U.$set(vr);const dr={};ut[0]&8512|ut[1]&567168|ut[3]&536870912&&(dr.$$scope={dirty:ut,ctx:Ye}),dt.$set(dr),Ye[6].size?Xt?(Xt.p(Ye,ut),ut[0]&64&&Z(Xt,1)):(Xt=Fm(Ye),Xt.c(),Z(Xt,1),Xt.m(We,null)):Xt&&(jt(),ne(Xt,1,1,()=>{Xt=null}),zt()),(!ht||ut[0]&72)&&pt(We,"hidden",!Ye[3]&&!Ye[6].size),Ye[6].size?Ft&&(jt(),ne(Ft,1,1,()=>{Ft=null}),zt()):Ft?(Ft.p(Ye,ut),ut[0]&64&&Z(Ft,1)):(Ft=$m(Ye),Ft.c(),Z(Ft,1),Ft.m(ze,at)),Ye[0]&&Ye[56]===_n.AUDIOBOOK&&Ye[6].size?Wt?(Wt.p(Ye,ut),ut[0]&65|ut[1]&33554432&&Z(Wt,1)):(Wt=Nm(Ye),Wt.c(),Z(Wt,1),Wt.m(ze,null)):Wt&&(jt(),ne(Wt,1,1,()=>{Wt=null}),zt()),Ye[10]?un?(un.p(Ye,ut),ut[0]&1024&&Z(un,1)):(un=Vm(Ye),un.c(),Z(un,1),un.m(ft,null)):un&&(jt(),ne(un,1,1,()=>{un=null}),zt())},i(Ye){ht||(Z(l.$$.fragment,Ye),Z(f.$$.fragment,Ye),Z(b.$$.fragment,Ye),Z(p.$$.fragment,Ye),Z(C.$$.fragment,Ye),Z(L.$$.fragment,Ye),Z(I.$$.fragment,Ye),Z(N.$$.fragment,Ye),Z(j.$$.fragment,Ye),Z(R.$$.fragment,Ye),Z(z.$$.fragment,Ye),Z(ve.$$.fragment,Ye),Z(Le.$$.fragment,Ye),Z(H.$$.fragment,Ye),Z(Oe.$$.fragment,Ye),Z(rt.$$.fragment,Ye),Z(d.$$.fragment,Ye),Z(U.$$.fragment,Ye),Z(se.$$.fragment,Ye),Z(Ae.$$.fragment,Ye),Z(tt.$$.fragment,Ye),Z(dt.$$.fragment,Ye),Z(Xt),Z(Ft),Z(Wt),Z(un),ht=!0)},o(Ye){ne(l.$$.fragment,Ye),ne(f.$$.fragment,Ye),ne(b.$$.fragment,Ye),ne(p.$$.fragment,Ye),ne(C.$$.fragment,Ye),ne(L.$$.fragment,Ye),ne(I.$$.fragment,Ye),ne(N.$$.fragment,Ye),ne(j.$$.fragment,Ye),ne(R.$$.fragment,Ye),ne(z.$$.fragment,Ye),ne(ve.$$.fragment,Ye),ne(Le.$$.fragment,Ye),ne(H.$$.fragment,Ye),ne(Oe.$$.fragment,Ye),ne(rt.$$.fragment,Ye),ne(d.$$.fragment,Ye),ne(U.$$.fragment,Ye),ne(se.$$.fragment,Ye),ne(Ae.$$.fragment,Ye),ne(tt.$$.fragment,Ye),ne(dt.$$.fragment,Ye),ne(Xt),ne(Ft),ne(Wt),ne(un),ht=!1},d(Ye){Ye&&(de(e),de($e),de(ft),de(vt),de(Rt),de(lt),de(St)),rn.d(),we(l),we(f),t[87](null),we(b),we(p),we(C),t[89](null),we(L),we(I),we(N),we(j),we(R),we(z),we(ve),we(Le),we(H),we(Oe),we(rt),we(d),we(U),we(se),we(Ae),we(tt),t[104](null),we(dt),Xt&&Xt.d(),Ft&&Ft.d(),Wt&&Wt.d(),un&&un.d(),t[112](null),t[113](null),xt=!1,vn(ln)}}}function sv(t,e,n){let r,i,s,o,a,l,c,u,f,g,v,_,b,y,p,m,w,C,h,A,L,$,P,I,x,ae,V,E,F,N,Y,K,J,j,B,M,S,R,X;ce(t,Ui,Ve=>n(46,a=Ve)),ce(t,Ps,Ve=>n(3,l=Ve)),ce(t,Ya,Ve=>n(81,c=Ve)),ce(t,Ko,Ve=>n(4,u=Ve)),ce(t,cu,Ve=>n(82,f=Ve)),ce(t,Yo,Ve=>n(5,g=Ve)),ce(t,Lr,Ve=>n(6,v=Ve)),ce(t,Rr,Ve=>n(7,_=Ve)),ce(t,Ho,Ve=>n(114,b=Ve)),ce(t,ls,Ve=>n(8,y=Ve)),ce(t,En,Ve=>n(47,p=Ve)),ce(t,At,Ve=>n(48,m=Ve)),ce(t,Li,Ve=>n(9,w=Ve)),ce(t,Mt,Ve=>n(49,C=Ve)),ce(t,Mn,Ve=>n(115,h=Ve)),ce(t,as,Ve=>n(50,A=Ve)),ce(t,Na,Ve=>n(10,L=Ve)),ce(t,qs,Ve=>n(51,$=Ve)),ce(t,nu,Ve=>n(116,P=Ve)),ce(t,rs,Ve=>n(11,x=Ve)),ce(t,vi,Ve=>n(12,E=Ve)),ce(t,ru,Ve=>n(85,F=Ve)),ce(t,xi,Ve=>n(13,N=Ve)),ce(t,lu,Ve=>n(52,Y=Ve)),ce(t,ou,Ve=>n(53,K=Ve)),ce(t,xo,Ve=>n(14,J=Ve)),ce(t,$a,Ve=>n(15,j=Ve)),ce(t,uu,Ve=>n(16,B=Ve)),ce(t,os,Ve=>n(54,M=Ve)),ce(t,Fa,Ve=>n(55,S=Ve)),ce(t,Js,Ve=>n(56,R=Ve)),ce(t,iu,Ve=>n(57,X=Ve));let{showMenu:re}=e;function W(){Pe==null||Pe.onResetList()}function z(){xe==null||xe.onScrollToSubtitle()}const{subtitlesEnablePersist$:le,ankiSentenceField$:Me,ankiSoundField$:Ee}=_t;ce(t,le,Ve=>n(117,I=Ve)),ce(t,Me,Ve=>n(83,ae=Ve)),ce(t,Ee,Ve=>n(84,V=Ve));const{sandboxElement:ve,isIOS:ke}=Io("context"),Ne=[".srt",".vtt",".txt"],Te=[".m4a",".m4b",".mp3"];let Le,Fe,Ze,O,H,Pe,xe,qe=!1,nt=!1,Oe="",je="",et="",rt="",Je="",G="",T="",d="",k="",D="",U=!1,te=!1,ee=0,se=0,ge=0,pe="",Ae,Ce=[];function De(){fe(Mn,h=!0,h),fe(At,m=!0,m),fe(En,p=!0,p),fe(Mt,C="",C),Ze.hide(),O.hide()}async function tt({detail:{files:Ve,errors:It}}){const Bt=[],$t=[];let tn,Tn;De();for(let Et=0,{length:Gt}=Ve;Et<Gt;Et+=1){const nn=Ve[Et];nn.extension===".srt"||nn.extension===".vtt"||nn.extension===".txt"?Bt.push(nn):$t.push(nn)}let He=Bt.length>1||$t.length>1;Bt.length>1&&It.push("Only 1 subtitle file is allowed"),$t.length>1&&It.push("Only 1 audio file is allowed");try{if(He||!Bt.length&&!$t.length)throw new Error("Stop process");if([tn]=Bt,[Tn]=$t,!await C0([tn==null?void 0:tn.handle,Tn==null?void 0:Tn.handle]).catch(({message:Gt})=>(It.push(`Access check failed: ${Gt}`),!1)))throw new Error("Stop process")}catch{fe(Mt,C=It.join("; "),C),fe(At,m=!1,m),fe(En,p=!1,p);return}if(tn){try{const Et=await Lu(tn.file,document);tn.handle&&await St(tn.handle,"lastSubtitle"),I&&await Is({name:tn.file.name,subtitles:[...Et.values()]}).catch(({message:Gt})=>It.push(Gt)),cs(tn.file,Et),n(24,qe=!0)}catch({message:Et}){It.push(`Failed to process subtitle: ${Et}`)}Tn||fe(At,m=!1,m)}if(Tn)try{const Et=await Qo(Tn.file,ve);Tn.handle&&await St(Tn.handle,"lastAudio"),await Os($,L,Tn.file,Et),n(25,nt=!0)}catch({message:Et}){It.push(`Failed to process audio: ${Et}`),fe(At,m=!1,m)}fe(Mt,C=It.join("; "),C),fe(En,p=!1,p)}async function mt(){fe(At,m=!0,m),fe(Mt,C="",C);try{await new Promise($t=>setTimeout($t,100));const Ve=hu(new DOMParser,w.htmlBackup||w.elementHtml);let It="";const Bt=document.createTreeWalker(Ve,NodeFilter.SHOW_TEXT,{acceptNode($t){var He;const tn=(((He=$t.parentElement)==null?void 0:He.tagName)||"").toLowerCase(),Tn=($t.textContent||"").replace(/\s/g,"").trim();return!du.has(tn)&&Tn&&(It+=`${$t.textContent}
`),NodeFilter.FILTER_ACCEPT}});for(;Bt.nextNode(););It&&_u(document,new Blob([It],{type:"text/plain;charset=utf-8"}),`${w.title}.txt`,ke)}catch({message:Ve}){fe(Mt,C=`Failed to export text: ${Ve}`,C)}fe(At,m=!1,m)}async function We(){fe(At,m=!0,m),await new Promise(Bt=>setTimeout(Bt,100));const Ve=[...v.values()];let It="";for(let Bt=0,{length:$t}=Ve;Bt<$t;Bt+=1){const tn=Ve[Bt];It+=`${tn.id}
${tn.startTime} --> ${tn.endTime}
${tn.text}
`}It&&_u(document,new Blob([It],{type:`${ke?"text/plain":"application/x-subrip"};charset=utf-8`}),`${x.name.split(/\.(?=[^\.]+$)/)[0]}.srt`,ke),fe(At,m=!1,m)}async function dt(){if(Ze.hide(),P){fe(En,p=!0,p),fe(At,m=!0,m),fe(Mt,C="",C);try{const{handle:Ve,file:It}=await M0(window,"Subtitle",Ne,_.lastSubtitle);if(It){const Bt=await Lu(It,document);await St(Ve,"lastSubtitle"),I&&await Is({name:Ve.name,subtitles:[...Bt.values()]}),cs(It,Bt),n(24,qe=!1)}}catch(Ve){Ve.name!=="AbortError"&&fe(Mt,C=`Failed to process subtitle: ${Ve.message}`,C)}fe(At,m=!1,m),fe(En,p=!1,p)}else Le.click()}async function Be(){if(O.hide(),P){fe(En,p=!0,p),fe(At,m=!0,m),fe(Mt,C="",C);try{const{handle:Ve,file:It}=await M0(window,"Audio",Te,_.lastAudio);if(It){const Bt=await Qo(It,ve);await St(Ve,"lastAudio"),await Os($,L,It,Bt),n(25,nt=!1)}else fe(At,m=!1,m)}catch(Ve){Ve.name!=="AbortError"&&fe(Mt,C=`Failed to process audio: ${Ve.message}`,C),fe(At,m=!1,m)}fe(En,p=!1,p)}else Fe.click()}async function $e(Ve){const It=Ve.target,Bt=It.accept.includes(".srt"),[$t]=It.files||[];if($t){fe(En,p=!0,p),fe(At,m=!0,m),fe(Mt,C="",C);try{if(Bt){const tn=await Lu($t,document,!0);I&&await Is({name:$t.name,subtitles:[...tn.values()]}),fe(At,m=!1,m),n(24,qe=!1)}else await Qo($t,ve,!0,!1,$,L),n(25,nt=!1)}catch({message:tn}){fe(Mt,C=`Failed to process ${Bt?"subtitle":"audio"}: ${tn}`,C),fe(At,m=!1,m)}fe(En,p=!1,p)}}async function ft(Ve){if(Ve==="lastSubtitle"?Ze.hide():O.hide(),fe(En,p=!0,p),fe(At,m=!0,m),fe(Mt,C="",C),fe(Mn,h=!0,h),P)try{Ve==="lastSubtitle"?(await b.delete("handle",[_.title,"subtitle"]),(!_.subtitleData||!_.subtitleData.subtitles.length)&&cs(),n(24,qe=!1)):Ve==="lastAudio"&&(await b.delete("handle",[_.title,"audioBook"]),await Os($,L),n(25,nt=!1)),delete _[Ve]}catch({message:It}){fe(Mt,C=`Failed to drop file: ${It}`,C)}else Ve==="lastSubtitle"?((!_.subtitleData||!_.subtitleData.subtitles.length)&&cs(),n(17,Le.value="",Le),n(24,qe=!1)):Ve==="lastAudio"&&(await Os($,L),n(18,Fe.value="",Fe),n(25,nt=!1));fe(At,m=!1,m),fe(En,p=!1,p),Rr.set(_)}async function ze(){Ze.hide(),fe(At,m=!0,m),fe(En,p=!0,p),fe(Mt,C="",C);try{const Ve={name:_.subtitleData.name,subtitles:[]};await b.put("subtitle",{subtitleData:Ve,title:_.title,lastSubtitleDataModified:Date.now()}),!_.lastSubtitle&&!Le.value&&!qe&&(fe(Mn,h=!0,h),cs()),fe(Rr,_.subtitleData=Ve,_),document.dispatchEvent(new CustomEvent("ttu-action",{detail:{type:"sync",syncType:"subtitle"}}))}catch({message:Ve}){fe(Mt,C=`Failed to drop persisted subtitles: ${Ve}`,C)}fe(At,m=!1,m),fe(En,p=!1,p),Rr.set(_)}async function at(){fe(En,p=!0,p),fe(At,m=!0,m),fe(Mn,h=!0,h);const{elementHtml:Ve,htmlBackup:It,lastBookModified:Bt}=w;try{fe(Li,w.elementHtml=It,w),fe(Li,w.lastBookModified=Date.now(),w),delete w.htmlBackup,await b.put("data",w),window.location.reload()}catch({message:$t}){fe(Mt,C=`Failed to reset book: ${$t}`,C),fe(Li,w={...w,elementHtml:Ve,htmlBackup:It,lastBookModified:Bt},w)}fe(At,m=!1,m),fe(En,p=!1,p)}async function Qe(){fe(En,p=!0,p),fe(At,m=!0,m),fe(Mn,h=!0,h);try{await b.put("audioBook",{title:_.title,playbackPosition:0,lastAudioBookModified:Date.now()}),fe(Ui,a=0,a),fe(Rr,_.playbackPosition=0,_),fe(as,A={previous:"",current:"",useTimeFallback:!0},A)}catch({message:Ve}){fe(Mt,C=`Failed to reset playback position: ${Ve}`,C)}fe(At,m=!1,m),fe(En,p=!1,p),Rr.set(_)}async function vt(){fe(En,p=!0,p),fe(At,m=!0,m),fe(Mn,h=!0,h);const Ve=b.transaction(["data","audioBook","subtitle","handle"],"readwrite"),{elementHtml:It,htmlBackup:Bt,lastBookModified:$t}=w,tn=Date.now(),Tn=_.subtitleData,He=_.playbackPosition;try{if(Bt&&(fe(Li,w.elementHtml=Bt,w),fe(Li,w.lastBookModified=tn,w),delete w.htmlBackup,await Ve.objectStore("data").put(w)),Tn){const Et={name:Tn.name,subtitles:[]};await Ve.objectStore("subtitle").put({subtitleData:Et,title:w.title,lastSubtitleDataModified:tn}),fe(Rr,_.subtitleData=Et,_)}await Ve.objectStore("audioBook").put({title:w.title,playbackPosition:0,lastAudioBookModified:tn}),await Ve.objectStore("handle").delete(IDBKeyRange.bound([w.title],[w.title,[]])),await Ve.done,fe(Rr,_.playbackPosition=0,_),window.location.reload()}catch({message:Et}){try{Ve.abort(),await Ve.done}catch{}fe(Mt,C=`Failed to reset Data: ${Et}`,C),fe(Li,w={...w,elementHtml:It,htmlBackup:Bt,lastBookModified:$t},w),fe(Rr,_={..._,playbackPosition:He,subtitleData:Tn},_)}fe(At,m=!1,m),fe(En,p=!1,p)}async function Rt(){H.hide();const Ve=(ee||0)*3600+(se||0)*60+(ge||0);await Fn(Re.RESTART_PLAYBACK,an(l?Wi(0,y,Ve):Math.max(0,Ve)),{keepPauseState:!0}),ln(Ve)}async function lt(){H.hide();const Ve=v.get(pe);Ve&&(await Fn(Re.RESTART_PLAYBACK,an(Ve.startSeconds),{keepPauseState:!0}),ln(Ve.startSeconds))}async function St(Ve,It){try{await b.put("handle",{handle:Ve,title:_.title,lastHandleModified:Date.now(),dataType:It==="lastSubtitle"?"subtitle":"audioBook"}),fe(Rr,_[It]=Ve,_)}catch({message:Bt}){throw new Error(`Failed to update extension data - ${Bt}`)}finally{Rr.set(_)}}async function ht(...Ve){n(1,Ce=[...v.values()].filter(It=>(!g||f.has(It.id))&&(!u||c.has(It.id)))),await Mr(),n(2,r=Ce.length>0)}function xt(...Ve){fe(Ps,l=!1,l),new Promise(Bt=>n(42,Ae=Bt));const It=document.querySelectorAll(`${pu()}.active`);for(let Bt=0,{length:$t}=It;Bt<$t;Bt+=1)It[Bt].classList.remove("active")}function ln(Ve){l||(fe(Ui,a=Ve,a),Pe==null||Pe.scrollToSubtitle(!0))}const qt=()=>ft("lastSubtitle");function Dt(Ve){Vt[Ve?"unshift":"push"](()=>{Ze=Ve,n(19,Ze)})}const rn=()=>ft("lastAudio");function In(Ve){Vt[Ve?"unshift":"push"](()=>{O=Ve,n(20,O)})}const Hn=async()=>{fe(At,m=!0,m),await Fn(Re.ALIGN_SUBTITLE,Ce),fe(At,m=!1,m)},xn=async()=>{fe(At,m=!0,m),await Fn(Re.RESTORE_SUBTITLE,Ce),fe(At,m=!1,m)},Xt=()=>fe(Yo,g=!g,g),Ft=()=>fe(Ko,u=!u,u),Wt=()=>Fn(Re.TOGGLE_PLAY_PAUSE,Ce,{skipUpdates:!0}),un=()=>Fn(Re.TOGGLE_PLAYBACK_LOOP,Ce,{skipUpdates:!0}),Ye=()=>fe(uu,B=!B,B),ut=()=>Fn(Re.EXPORT_NEW,Ce,{mergeSubtitles:u}).finally(()=>{u&&ht(v,g,u)}),yr=()=>Fn(Re.EXPORT_UPDATE,Ce,{mergeSubtitles:!0}).finally(()=>{u&&ht(v,g,u)}),Xn=()=>{n(38,[ee,se,ge]=us(a),ee,n(39,se),n(40,ge)),n(41,pe=A.current||A.previous)};function Yt(Ve){ee=Ve,n(38,ee)}function sr(Ve){se=Ve,n(39,se)}function Qn(Ve){ge=Ve,n(40,ge)}function Un(){pe=this.value,n(41,pe)}function vr(Ve){Vt[Ve?"unshift":"push"](()=>{H=Ve,n(21,H)})}const dr=()=>Pe==null?void 0:Pe.scrollToSubtitle(!0),hn=()=>{fe(At,m=!1,m),fe(En,p=!1,p)},Gr=()=>Fn(Re.CANCEL_EXPORT,Ce);function pn(Ve){Vt[Ve?"unshift":"push"](()=>{Pe=Ve,n(22,Pe)})}function or(Ve){Vt[Ve?"unshift":"push"](()=>{xe=Ve,n(23,xe)})}const Or=()=>Pe==null?void 0:Pe.onResetList(),oi=()=>{Os($,$).finally(()=>{fe(Mt,C="Unable to play audio - try a different codec/format",C),fe(At,m=!1,m)})};function Wn(Ve){Vt[Ve?"unshift":"push"](()=>{Le=Ve,n(17,Le)})}function jr(Ve){Vt[Ve?"unshift":"push"](()=>{Fe=Ve,n(18,Fe)})}return t.$$set=Ve=>{"showMenu"in Ve&&n(0,re=Ve.showMenu)},t.$$.update=()=>{t.$$.dirty[0]&2048&&x&&(fe(Yo,g=!1,g),fe(Ko,u=!1,u)),t.$$.dirty[0]&112&&ht(v,g,u),t.$$.dirty[0]&2&&n(2,r=Ce.length>0),t.$$.dirty[0]&8204&&n(45,i=l&&r&&!N),t.$$.dirty[0]&256&&n(44,s=y?Math.floor(y/3600):999),t.$$.dirty[0]&65536&&n(43,o=B?"Show footer actions":"Hide footer actions"),t.$$.dirty[0]&39424&&(E?(n(26,Oe="Export in progress"),n(27,je="Export in progress"),n(28,et="Export in progress")):(n(26,Oe=`${x?"Change":"Set"} subtitle file`),n(27,je=w.htmlBackup?"Reset book & reload page":"No data to reset"),n(28,et=`${j?"Change":"Set"} audio file`))),t.$$.dirty[0]&4224&&(!Number.isFinite(_.playbackPosition)||_.playbackPosition===0?n(29,rt="No data to reset"):E?n(29,rt="Export in progress"):n(29,rt="Reset playback position")),t.$$.dirty[0]&24692&&(v.size?N?n(30,Je="Recording in progress"):r?J.matchedBy?n(30,Je=`Align${g||u?" selected":" all"} subtitles with book text`):n(30,Je="Matched book required"):n(30,Je="No subtitle matches current filter"):n(30,Je="Subtitle file required")),t.$$.dirty[0]&8308&&(v.size?N?n(31,G="Recording in progress"):r?n(31,G=`Restore original time and text for${g||u?" selected":" all"} subtitles`):n(31,G="No subtitle matches current filter"):n(31,G="Subtitle file required")),t.$$.dirty[0]&64&&(v.size?(fe(ou,K=Re.TOGGLE_SHOW_BOOKMARKED,K),fe(lu,Y=Re.TOGGLE_SHOW_FOR_MERGE,Y)):(fe(ou,K="Subtitle file required",K),fe(lu,Y="Subtitle file required",Y))),t.$$.dirty[0]&8316&&(v.size?l?N?(n(32,T="Recording in progress"),n(33,d="Recording in progress")):r?!g&&!u?(n(32,T="Bookmark or merge filter required"),n(33,d="Bookmark or merge filter required")):(n(32,T="Toggle play and pause for selected subtitles"),n(33,d="Toggle playback loop for selected subtitles")):(n(32,T="No subtitle matches current filter"),n(33,d="No subtitle matches current filter")):(n(32,T="Audio file required"),n(33,d="Audio file required")):(n(32,T="Subtitle file required"),n(33,d="Subtitle file required"))),t.$$.dirty[0]&4220|t.$$.dirty[2]&14680064&&(F?E?(n(34,k="Export in progress"),n(35,D="Export in progress"),n(36,U=!1),n(37,te=!1)):v.size?V&&!l&&!ae?(n(34,k="Audio file required"),n(35,D="Audio file required"),n(36,U=!1),n(37,te=!1)):r?(u?(n(34,k="Merge selected subtitles and create new Card for selected subtitles"),n(36,U=!0)):g?(n(34,k="Create new cards for selected subtitles"),n(36,U=!0)):(n(34,k="Bookmark or merge filter required"),n(36,U=!1)),u?(n(35,D="Merge selected subtitles and update last card"),n(37,te=!0)):(n(35,D="Merge filter required"),n(37,te=!1))):(n(34,k="No subtitle matches current filter"),n(35,D="No subtitle matches current filter"),n(36,U=!1),n(37,te=!1)):(n(34,k="Subtitle file required"),n(35,D="Subtitle file required"),n(36,U=!1),n(37,te=!1)):(n(34,k="Anki configuration required"),n(35,D="Anki configuration required"),n(36,U=!1),n(37,te=!1))),t.$$.dirty[0]&32|t.$$.dirty[2]&1048576&&g&&ht(f),t.$$.dirty[0]&16|t.$$.dirty[2]&524288&&u&&ht(c),t.$$.dirty[0]&1024&&(L||xt())},[re,Ce,r,l,u,g,v,_,y,w,L,x,E,N,J,j,B,Le,Fe,Ze,O,H,Pe,xe,qe,nt,Oe,je,et,rt,Je,G,T,d,k,D,U,te,ee,se,ge,pe,Ae,o,s,i,a,p,m,C,A,$,Y,K,M,S,R,X,le,Me,Ee,Ne,Te,De,tt,mt,We,dt,Be,$e,ft,ze,at,Qe,vt,Rt,lt,ht,xt,W,z,c,f,ae,V,F,qt,Dt,rn,In,Hn,xn,Xt,Ft,Wt,un,Ye,ut,yr,Xn,Yt,sr,Qn,Un,vr,dr,hn,Gr,pn,or,Or,oi,Wn,jr]}class ov extends Dn{constructor(e){super(),Bn(this,e,sv,iv,Cn,{showMenu:0,resetSubtitleContainerHeight:79,scrollToSubtitle:80},null,[-1,-1,-1,-1])}get resetSubtitleContainerHeight(){return this.$$.ctx[79]}get scrollToSubtitle(){return this.$$.ctx[80]}}function Hm(t,e,n){const r=t.slice();return r[12]=e[n],r[13]=e,r[14]=n,r}function xm(t,e){let n,r,i=e[12].label+"",s,o,a,l=e[12].startText+"",c,u,f,g=e[14],v,_;const b=()=>e[8](n,g),y=()=>e[8](null,g);function p(){return e[9](e[12])}return{key:t,first:null,c(){n=_e("button"),r=_e("div"),s=Nt(i),o=me(),a=_e("div"),c=Nt(l),u=me(),ie(a,"class","audio-time"),ie(n,"class","m-y-xs p-b"),n.disabled=e[4],ie(n,"title",f=e[4]?"Recording in progress":"Play from chapter"),pt(n,"inactive-chapter",e[2]>e[14]),pt(n,"recording",e[4]),this.first=n},m(m,w){he(m,n,w),oe(n,r),oe(r,s),oe(n,o),oe(n,a),oe(a,c),oe(n,u),b(),v||(_=Xe(n,"click",p),v=!0)},p(m,w){e=m,w&8&&i!==(i=e[12].label+"")&&cn(s,i),w&8&&l!==(l=e[12].startText+"")&&cn(c,l),w&16&&(n.disabled=e[4]),w&16&&f!==(f=e[4]?"Recording in progress":"Play from chapter")&&ie(n,"title",f),g!==e[14]&&(y(),g=e[14],b()),w&12&&pt(n,"inactive-chapter",e[2]>e[14]),w&16&&pt(n,"recording",e[4])},d(m){m&&de(n),y(),v=!1,_()}}}function av(t){let e,n=[],r=new Map,i=Jr(t[3]);const s=o=>o[12].key;for(let o=0;o<i.length;o+=1){let a=Hm(t,i,o),l=s(a);r.set(l,n[o]=xm(l,a))}return{c(){e=_e("div");for(let o=0;o<n.length;o+=1)n[o].c();ie(e,"class","flex flex-col")},m(o,a){he(o,e,a);for(let l=0;l<n.length;l+=1)n[l]&&n[l].m(e,null);t[10](e)},p(o,[a]){a&62&&(i=Jr(o[3]),n=Ks(n,a,s,1,o,i,r,e,Ba,xm,null,Hm))},i:wt,o:wt,d(o){o&&de(e);for(let a=0;a<n.length;a+=1)n[a].d();t[10](null)}}}function lv(t,e,n){let r,i,s,o,a;ce(t,Ui,b=>n(11,r=b)),ce(t,Zs,b=>n(3,i=b)),ce(t,as,b=>n(6,s=b)),ce(t,Js,b=>n(7,o=b)),ce(t,xi,b=>n(4,a=b));let l,c=[],u=-1;function f(){n(2,u=i.findLastIndex(b=>r>=b.startSeconds)),!(u===-1||!c[u])&&(c[u].scrollIntoViewIfNeeded?c[u].scrollIntoViewIfNeeded():c[u].scrollIntoView())}function g(b,y){Vt[b?"unshift":"push"](()=>{c[y]=b,n(1,c)})}const v=b=>{Fn(Re.RESTART_PLAYBACK,an(b.startSeconds),{keepPauseState:!0}).then(Mr).then(f)};function _(b){Vt[b?"unshift":"push"](()=>{l=b,n(0,l)})}return t.$$.update=()=>{t.$$.dirty&192&&o===_n.CHAPTERS&&s&&f()},[l,c,u,i,a,f,s,o,g,v,_]}class uv extends Dn{constructor(e){super(),Bn(this,e,lv,av,Cn,{})}}function Um(t){let e,n,r,i,s,o,a,l,c;const u=[fv,cv],f=[];function g(v,_){return typeof v[0].component=="string"?0:1}return s=g(t),o=f[s]=u[s](t),{c(){e=_e("div"),n=_e("div"),r=me(),i=_e("div"),o.c(),ie(n,"tabindex","0"),ie(n,"role","button"),ie(n,"class","absolute inset-0 tap-highlight-transparent bg-black/[.32]"),ie(i,"class","ttu-whispersync-container dialog-container relative top-1/2 left-1/2 inline-block -translate-x-1/2 -translate-y-1/2"),ie(e,"class","ttu-whispersync-dialog writing-horizontal-tb fixed inset-0 w-full h-full"),Cr(e,"z-index",t[1])},m(v,_){he(v,e,_),oe(e,n),oe(e,r),oe(e,i),f[s].m(i,null),a=!0,l||(c=Xe(e,"wheel",Ra(t[4]),{passive:!0}),l=!0)},p(v,_){let b=s;s=g(v),s===b?f[s].p(v,_):(jt(),ne(f[b],1,1,()=>{f[b]=null}),zt(),o=f[s],o?o.p(v,_):(o=f[s]=u[s](v),o.c()),Z(o,1),o.m(i,null)),_&2&&Cr(e,"z-index",v[1])},i(v){a||(Z(o),a=!0)},o(v){ne(o),a=!1},d(v){v&&de(e),f[s].d(),l=!1,c()}}}function cv(t){let e,n,r;const i=[t[0].props];var s=t[0].component;function o(a,l){let c={};if(l!==void 0&&l&1)c=Kn(i,[qn(a[0].props)]);else for(let u=0;u<i.length;u+=1)c=sn(c,i[u]);return{props:c}}return s&&(e=od(s,o(t)),e.$on("close",t[2])),{c(){e&&ye(e.$$.fragment),n=Fr()},m(a,l){e&&be(e,a,l),he(a,n,l),r=!0},p(a,l){if(l&1&&s!==(s=a[0].component)){if(e){jt();const c=e;ne(c.$$.fragment,1,0,()=>{we(c,1)}),zt()}s?(e=od(s,o(a,l)),e.$on("close",a[2]),ye(e.$$.fragment),Z(e.$$.fragment,1),be(e,n.parentNode,n)):e=null}else if(s){const c=l&1?Kn(i,[qn(a[0].props)]):{};e.$set(c)}},i(a){r||(e&&Z(e.$$.fragment,a),r=!0)},o(a){e&&ne(e.$$.fragment,a),r=!1},d(a){a&&de(n),e&&we(e,a)}}}function fv(t){let e,n=t[0].component+"",r;return{c(){e=new g_(!1),r=Fr(),e.a=r},m(i,s){e.m(n,i,s),he(i,r,s)},p(i,s){s&1&&n!==(n=i[0].component+"")&&e.p(n)},i:wt,o:wt,d(i){i&&(de(r),e.d())}}}function dv(t){let e,n,r=t[0]&&Um(t);return{c(){r&&r.c(),e=Fr()},m(i,s){r&&r.m(i,s),he(i,e,s),n=!0},p(i,[s]){i[0]?r?(r.p(i,s),s&1&&Z(r,1)):(r=Um(i),r.c(),Z(r,1),r.m(e.parentNode,e)):r&&(jt(),ne(r,1,1,()=>{r=null}),zt())},i(i){n||(Z(r),n=!0)},o(i){ne(r),n=!1},d(i){i&&de(e),r&&r.d(i)}}}function hv(t,e,n){let r,i;ce(t,En,u=>n(5,r=u)),ce(t,Vo,u=>n(3,i=u));let s,o="";function a(){fe(Vo,i=i.slice(0,-1),i),l()}function l(){var f;const u=i.length-1;n(0,s=i[u]),n(1,o=((f=i[u])==null?void 0:f.zIndex)||""),fe(En,r=!!s,r)}function c(u){mn.call(this,t,u)}return t.$$.update=()=>{t.$$.dirty&9&&i.length&&!s&&l()},[s,o,a,i,c]}class pv extends Dn{constructor(e){super(),Bn(this,e,hv,dv,Cn,{})}}const Cf=(t,e)=>e.some(n=>t instanceof n);let Wm,Gm;function mv(){return Wm||(Wm=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function _v(){return Gm||(Gm=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Mf=new WeakMap,Rf=new WeakMap,hc=new WeakMap;function gv(t){const e=new Promise((n,r)=>{const i=()=>{t.removeEventListener("success",s),t.removeEventListener("error",o)},s=()=>{n(bo(t.result)),i()},o=()=>{r(t.error),i()};t.addEventListener("success",s),t.addEventListener("error",o)});return hc.set(e,t),e}function bv(t){if(Mf.has(t))return;const e=new Promise((n,r)=>{const i=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",o),t.removeEventListener("abort",o)},s=()=>{n(),i()},o=()=>{r(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",s),t.addEventListener("error",o),t.addEventListener("abort",o)});Mf.set(t,e)}let Lf={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return Mf.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return bo(t[e])},set(t,e,n){return t[e]=n,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function jm(t){Lf=t(Lf)}function wv(t){return _v().includes(t)?function(...e){return t.apply(Pf(this),e),bo(this.request)}:function(...e){return bo(t.apply(Pf(this),e))}}function yv(t){return typeof t=="function"?wv(t):(t instanceof IDBTransaction&&bv(t),Cf(t,mv())?new Proxy(t,Lf):t)}function bo(t){if(t instanceof IDBRequest)return gv(t);if(Rf.has(t))return Rf.get(t);const e=yv(t);return e!==t&&(Rf.set(t,e),hc.set(e,t)),e}const Pf=t=>hc.get(t);function vv(t,e,{blocked:n,upgrade:r,blocking:i,terminated:s}={}){const o=indexedDB.open(t,e),a=bo(o);return r&&o.addEventListener("upgradeneeded",l=>{r(bo(o.result),l.oldVersion,l.newVersion,bo(o.transaction),l)}),n&&o.addEventListener("blocked",l=>n(l.oldVersion,l.newVersion,l)),a.then(l=>{s&&l.addEventListener("close",()=>s()),i&&l.addEventListener("versionchange",c=>i(c.oldVersion,c.newVersion,c))}).catch(()=>{}),a}const Ev=["get","getKey","getAll","getAllKeys","count"],Sv=["put","add","delete","clear"],If=new Map;function zm(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(If.get(e))return If.get(e);const n=e.replace(/FromIndex$/,""),r=e!==n,i=Sv.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||Ev.includes(n)))return;const s=async function(o,...a){const l=this.transaction(o,i?"readwrite":"readonly");let c=l.store;return r&&(c=c.index(a.shift())),(await Promise.all([c[n](...a),i&&l.done]))[0]};return If.set(e,s),s}jm(t=>({...t,get:(e,n,r)=>zm(e,n)||t.get(e,n,r),has:(e,n)=>!!zm(e,n)||t.has(e,n)}));const Tv=["continue","continuePrimaryKey","advance"],Xm={},Of=new WeakMap,Ym=new WeakMap,kv={get(t,e){if(!Tv.includes(e))return t[e];let n=Xm[e];return n||(n=Xm[e]=function(...r){Of.set(this,Ym.get(this)[e](...r))}),n}};async function*Av(...t){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...t)),!e)return;e=e;const n=new Proxy(e,kv);for(Ym.set(n,e),hc.set(n,Pf(e));e;)yield n,e=await(Of.get(n)||e.continue()),Of.delete(n)}function Km(t,e){return e===Symbol.asyncIterator&&Cf(t,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&Cf(t,[IDBIndex,IDBObjectStore])}jm(t=>({...t,get(e,n,r){return Km(e,n)?Av:t.get(e,n,r)},has(e,n){return Km(e,n)||t.has(e,n)}}));async function Cv(t){try{const e=await vv("books",t);if(!e)throw new Error("failed to open db");Ho.set(e)}catch({message:e}){throw new Error(`Error accessing books db - ${e}`)}}function qm(t,e,n){const r=t.slice();return r[3]=e[n],r}function Mv(t){let e;return{c(){e=Nt("Differences")},m(n,r){he(n,e,r)},d(n){n&&de(e)}}}function Zm(t,e){let n,r=e[3].id+"",i,s,o,a=e[3].original+"",l,c,u,f=e[3].adjusted+"",g;return{key:t,first:null,c(){n=_e("div"),i=Nt(r),s=me(),o=_e("div"),l=Nt(a),c=me(),u=_e("div"),g=Nt(f),this.first=n},m(v,_){he(v,n,_),oe(n,i),he(v,s,_),he(v,o,_),oe(o,l),he(v,c,_),he(v,u,_),oe(u,g)},p(v,_){e=v,_&1&&r!==(r=e[3].id+"")&&cn(i,r),_&1&&a!==(a=e[3].original+"")&&cn(l,a),_&1&&f!==(f=e[3].adjusted+"")&&cn(g,f)},d(v){v&&(de(n),de(s),de(o),de(c),de(u))}}}function Rv(t){let e,n,r,i,s,o,a,l,c=[],u=new Map,f=Jr(t[0]);const g=v=>v[3].id;for(let v=0;v<f.length;v+=1){let _=qm(t,f,v),b=g(_);u.set(b,c[v]=Zm(b,_))}return{c(){e=_e("div"),n=_e("div"),r=_e("div"),r.textContent="Id",i=me(),s=_e("div"),s.textContent="Original",o=me(),a=_e("div"),a.textContent="Adjusted",l=me();for(let v=0;v<c.length;v+=1)c[v].c();ie(n,"class","diff-grid"),ie(e,"class","overflow-auto p-s")},m(v,_){he(v,e,_),oe(e,n),oe(n,r),oe(n,i),oe(n,s),oe(n,o),oe(n,a),oe(n,l);for(let b=0;b<c.length;b+=1)c[b]&&c[b].m(n,null)},p(v,_){_&1&&(f=Jr(v[0]),c=Ks(c,_,g,1,v,f,u,n,Ba,Zm,null,qm))},d(v){v&&de(e);for(let _=0;_<c.length;_+=1)c[_].d()}}}function Lv(t){let e,n,r,i;return{c(){e=_e("div"),n=_e("button"),n.textContent="Close",ie(e,"slot","footer")},m(s,o){he(s,e,o),oe(e,n),r||(i=Xe(n,"click",t[2]),r=!0)},p:wt,d(s){s&&de(e),r=!1,i()}}}function Pv(t){let e,n;return e=new vu({props:{$$slots:{footer:[Lv],content:[Rv],header:[Mv]},$$scope:{ctx:t}}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},p(r,[i]){const s={};i&65&&(s.$$scope={dirty:i,ctx:r}),e.$set(s)},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function Iv(t,e,n){let{subtitleDiffDetails:r}=e;const i=Ri(),s=()=>i("close");return t.$$set=o=>{"subtitleDiffDetails"in o&&n(0,r=o.subtitleDiffDetails)},[r,i,s]}class Ov extends Dn{constructor(e){super(),Bn(this,e,Iv,Pv,Cn,{subtitleDiffDetails:0})}}function Bv(t){let e,n;return{c(){e=_e("div"),n=Nt(t[2])},m(r,i){he(r,e,i),oe(e,n)},p(r,i){i&4&&cn(n,r[2])},d(r){r&&de(e)}}}function Dv(t){let e,n,r;return n=new kt({props:{path:to}}),{c(){e=_e("div"),ye(n.$$.fragment),ie(e,"slot","icon")},m(i,s){he(i,e,s),be(n,e,null),r=!0},p:wt,i(i){r||(Z(n.$$.fragment,i),r=!0)},o(i){ne(n.$$.fragment,i),r=!1},d(i){i&&de(e),we(n)}}}function Fv(t){let e,n,r,i,s,o,a,l,c;return o=new _i({props:{$$slots:{icon:[Dv],default:[Bv]},$$scope:{ctx:t}}}),{c(){e=_e("label"),n=Nt(t[1]),r=me(),i=_e("input"),s=me(),ye(o.$$.fragment),ie(e,"for",t[4]),ie(i,"type","checkbox"),ie(i,"id",t[4])},m(u,f){he(u,e,f),oe(e,n),he(u,r,f),he(u,i,f),i.checked=t[3],he(u,s,f),be(o,u,f),a=!0,l||(c=[Xe(i,"change",t[6]),Xe(i,"change",t[5])],l=!0)},p(u,[f]){(!a||f&2)&&cn(n,u[1]),f&8&&(i.checked=u[3]);const g={};f&132&&(g.$$scope={dirty:f,ctx:u}),o.$set(g)},i(u){a||(Z(o.$$.fragment,u),a=!0)},o(u){ne(o.$$.fragment,u),a=!1},d(u){u&&(de(e),de(r),de(i),de(s)),we(o,u),l=!1,vn(c)}}}function $v(t,e,n){let r,i=wt,s=()=>(i(),i=ns(o,g=>n(3,r=g)),o);t.$$.on_destroy.push(()=>i());let{targetStore$:o}=e;s();let{label:a}=e,{helpText:l}=e;const c=o.key();function u(g){mn.call(this,t,g)}function f(){r=this.checked,o.set(r)}return t.$$set=g=>{"targetStore$"in g&&s(n(0,o=g.targetStore$)),"label"in g&&n(1,a=g.label),"helpText"in g&&n(2,l=g.helpText)},[o,a,l,r,c,u,f]}class Vn extends Dn{constructor(e){super(),Bn(this,e,$v,Fv,Cn,{targetStore$:0,label:1,helpText:2})}}function Nv(t){let e,n;return{c(){e=_e("div"),n=Nt(t[2])},m(r,i){he(r,e,i),oe(e,n)},p(r,i){i&4&&cn(n,r[2])},d(r){r&&de(e)}}}function Vv(t){let e,n,r;return n=new kt({props:{path:to}}),{c(){e=_e("div"),ye(n.$$.fragment),ie(e,"slot","icon")},m(i,s){he(i,e,s),be(n,e,null),r=!0},p:wt,i(i){r||(Z(n.$$.fragment,i),r=!0)},o(i){ne(n.$$.fragment,i),r=!1},d(i){i&&de(e),we(n)}}}function Hv(t){let e,n,r,i,s,o,a,l,c,u;return a=new _i({props:{$$slots:{icon:[Vv],default:[Nv]},$$scope:{ctx:t}}}),{c(){e=_e("label"),n=Nt(t[1]),r=me(),i=_e("input"),o=me(),ye(a.$$.fragment),ie(e,"for",t[10]),ie(i,"type","number"),i.value=t[8],ie(i,"id",t[10]),i.disabled=t[3],ie(i,"min",t[4]),ie(i,"max",t[5]),ie(i,"step",t[6])},m(f,g){he(f,e,g),oe(e,n),he(f,r,g),he(f,i,g),he(f,o,g),be(a,f,g),l=!0,c||(u=[Xe(i,"change",t[11]),Xe(i,"blur",t[12]),Ma(s=Mu.call(null,i,{document,isSkipped:t[9]}))],c=!0)},p(f,[g]){(!l||g&2)&&cn(n,f[1]),(!l||g&256&&i.value!==f[8])&&(i.value=f[8]),(!l||g&8)&&(i.disabled=f[3]),(!l||g&16)&&ie(i,"min",f[4]),(!l||g&32)&&ie(i,"max",f[5]),(!l||g&64)&&ie(i,"step",f[6]),s&&Ci(s.update)&&g&512&&s.update.call(null,{document,isSkipped:f[9]});const v={};g&8196&&(v.$$scope={dirty:g,ctx:f}),a.$set(v)},i(f){l||(Z(a.$$.fragment,f),l=!0)},o(f){ne(a.$$.fragment,f),l=!1},d(f){f&&(de(e),de(r),de(i),de(o)),we(a,f),c=!1,vn(u)}}}function xv(t,e,n){let r,i=wt,s=()=>(i(),i=ns(a,m=>n(8,r=m)),a),o;ce(t,En,m=>n(9,o=m)),t.$$.on_destroy.push(()=>i());let{targetStore$:a}=e;s();let{label:l}=e,{helpText:c}=e,{disabled:u=void 0}=e,{min:f=void 0}=e,{max:g=void 0}=e,{step:v=100}=e,{blurHandler:_=void 0}=e;const b=a.key(),y=m=>{_||wd(m,a)},p=m=>{_&&_(m,a)};return t.$$set=m=>{"targetStore$"in m&&s(n(0,a=m.targetStore$)),"label"in m&&n(1,l=m.label),"helpText"in m&&n(2,c=m.helpText),"disabled"in m&&n(3,u=m.disabled),"min"in m&&n(4,f=m.min),"max"in m&&n(5,g=m.max),"step"in m&&n(6,v=m.step),"blurHandler"in m&&n(7,_=m.blurHandler)},[a,l,c,u,f,g,v,_,r,o,b,y,p]}class qr extends Dn{constructor(e){super(),Bn(this,e,xv,Hv,Cn,{targetStore$:0,label:1,helpText:2,disabled:3,min:4,max:5,step:6,blurHandler:7})}}function Jm(t){let e,n,r;return n=new kt({props:{path:sl}}),n.$on("click",t[16]),{c(){e=_e("button"),ye(n.$$.fragment),ie(e,"title","Download unmatched subtitle list")},m(i,s){he(i,e,s),be(n,e,null),r=!0},p:wt,i(i){r||(Z(n.$$.fragment,i),r=!0)},o(i){ne(n.$$.fragment,i),r=!1},d(i){i&&de(e),we(n)}}}function Uv(t){let e;return{c(){e=_e("div"),e.textContent="Indicates # of lines which passed the similiarity check but are not equal to the book text"},m(n,r){he(n,e,r)},p:wt,d(n){n&&de(e)}}}function Wv(t){let e,n,r;return n=new kt({props:{path:to}}),{c(){e=_e("div"),ye(n.$$.fragment),ie(e,"slot","icon")},m(i,s){he(i,e,s),be(n,e,null),r=!0},p:wt,i(i){r||(Z(n.$$.fragment,i),r=!0)},o(i){ne(n.$$.fragment,i),r=!1},d(i){i&&de(e),we(n)}}}function Qm(t){let e,n,r,i,s,o,a;return{c(){e=_e("button"),e.textContent="Show Diff",n=me(),r=_e("div"),i=me(),s=_e("div")},m(l,c){he(l,e,c),he(l,n,c),he(l,r,c),he(l,i,c),he(l,s,c),o||(a=Xe(e,"click",t[26]),o=!0)},p:wt,d(l){l&&(de(e),de(n),de(r),de(i),de(s)),o=!1,a()}}}function e2(t){let e,n,r,i,s;return{c(){e=_e("button"),n=Nt("Cancel"),ie(e,"class","btn m-r-s"),e.disabled=r=t[1].aborted},m(o,a){he(o,e,a),oe(e,n),i||(s=Xe(e,"click",t[18]),i=!0)},p(o,a){a[0]&2&&r!==(r=o[1].aborted)&&(e.disabled=r)},d(o){o&&de(e),i=!1,s()}}}function t2(t){let e,n,r,i,s,o;return{c(){e=_e("button"),n=Nt("Save & reload page"),ie(e,"class","btn m-r-s"),e.disabled=r=!!t[10],ie(e,"title",i=t[10]?"Export in progress":null)},m(a,l){he(a,e,l),oe(e,n),s||(o=Xe(e,"click",t[20]),s=!0)},p(a,l){l[0]&1024&&r!==(r=!!a[10])&&(e.disabled=r),l[0]&1024&&i!==(i=a[10]?"Export in progress":null)&&ie(e,"title",i)},d(a){a&&de(e),s=!1,o()}}}function n2(t){let e,n,r;return{c(){e=_e("button"),e.textContent="Download",ie(e,"class","btn m-r-s")},m(i,s){he(i,e,s),n||(r=Xe(e,"click",t[19]),n=!0)},p:wt,d(i){i&&de(e),n=!1,r()}}}function Gv(t){let e;return{c(){e=_e("div"),e.textContent=`By matching the subtitles to the book you can enable extra functionality like the reader menu, auto scroll
etc.`},m(n,r){he(n,e,r)},p:wt,d(n){n&&de(e)}}}function jv(t){let e,n,r;return n=new kt({props:{path:xd}}),{c(){e=_e("div"),ye(n.$$.fragment),ie(e,"slot","icon")},m(i,s){he(i,e,s),be(n,e,null),r=!0},p:wt,i(i){r||(Z(n.$$.fragment,i),r=!0)},o(i){ne(n.$$.fragment,i),r=!1},d(i){i&&de(e),we(n)}}}function zv(t){let e,n,r,i,s,o=t[9].size+"",a,l,c,u,f,g,v,_,b,y,p,m,w,C,h,A,L,$,P,I,x,ae,V,E,F,N,Y,K,J,j,B,M,S,R,X,re,W,z,le,Me,Ee;u=new kt({props:{path:t[8]?Jo:Kd}}),u.$on("click",t[25]);let ve=!t[3]&&t[7].length&&Jm(t);P=new _i({props:{$$slots:{icon:[Wv],default:[Uv]},$$scope:{ctx:t}}});let ke=!t[3]&&t[6].length&&Qm(t);ae=new Vn({props:{label:"Ignore rp elements",helpText:"If enabled the content of rp elements will be ignored for the similiarity check",targetStore$:t[11]}}),E=new qr({props:{label:"Line similiarity %",helpText:"Determines the % threshold for which a book text line is considered a match (1 being identical)",min:.1,max:1,step:.1,targetStore$:t[12]}}),N=new qr({props:{label:"Line match attempts",helpText:"Determines how many book text lines are tested before skipping the current subtitle line as unmatched",min:1,step:1,targetStore$:t[13]}});let Ne=t[3]&&e2(t),Te=t[0]&&!t[3]&&t2(t),Le=!t[3]&&t[6].length&&n2(t);return re=new _i({props:{placement:"top",$$slots:{icon:[jv],default:[Gv]},$$scope:{ctx:t}}}),z=new Ef({props:{currentProgress:t[2],rounded:!0,margin:!0}}),{c(){e=_e("div"),n=_e("div"),r=_e("div"),r.textContent="Lines to match",i=me(),s=_e("div"),a=Nt(o),l=me(),c=_e("button"),ye(u.$$.fragment),g=me(),v=_e("div"),v.textContent="Line match rate",_=me(),b=_e("div"),y=Nt(t[4]),p=me(),m=_e("div"),ve&&ve.c(),w=me(),C=_e("div"),C.textContent="Book diff rate",h=me(),A=_e("div"),L=Nt(t[5]),$=me(),ye(P.$$.fragment),I=me(),ke&&ke.c(),x=me(),ye(ae.$$.fragment),V=me(),ye(E.$$.fragment),F=me(),ye(N.$$.fragment),Y=me(),K=_e("div"),Ne&&Ne.c(),J=me(),Te&&Te.c(),j=me(),Le&&Le.c(),B=me(),M=_e("button"),S=Nt("Parse"),X=me(),ye(re.$$.fragment),W=me(),ye(z.$$.fragment),ie(c,"title",f=t[8]?"Delete start hint element":"Select start hint element"),ie(n,"class","settings-grid"),ie(e,"class","flex-1"),ie(M,"class","btn m-r-s"),M.disabled=R=t[3]>0,ie(K,"class","flex justify-end match-btns")},m(Fe,Ze){he(Fe,e,Ze),oe(e,n),oe(n,r),oe(n,i),oe(n,s),oe(s,a),oe(n,l),oe(n,c),be(u,c,null),oe(n,g),oe(n,v),oe(n,_),oe(n,b),oe(b,y),oe(n,p),oe(n,m),ve&&ve.m(m,null),oe(n,w),oe(n,C),oe(n,h),oe(n,A),oe(A,L),oe(n,$),be(P,n,null),oe(n,I),ke&&ke.m(n,null),oe(n,x),be(ae,n,null),oe(n,V),be(E,n,null),oe(n,F),be(N,n,null),he(Fe,Y,Ze),he(Fe,K,Ze),Ne&&Ne.m(K,null),oe(K,J),Te&&Te.m(K,null),oe(K,j),Le&&Le.m(K,null),oe(K,B),oe(K,M),oe(M,S),oe(K,X),be(re,K,null),he(Fe,W,Ze),be(z,Fe,Ze),le=!0,Me||(Ee=Xe(M,"click",t[17]),Me=!0)},p(Fe,Ze){(!le||Ze[0]&512)&&o!==(o=Fe[9].size+"")&&cn(a,o);const O={};Ze[0]&256&&(O.path=Fe[8]?Jo:Kd),u.$set(O),(!le||Ze[0]&256&&f!==(f=Fe[8]?"Delete start hint element":"Select start hint element"))&&ie(c,"title",f),(!le||Ze[0]&16)&&cn(y,Fe[4]),!Fe[3]&&Fe[7].length?ve?(ve.p(Fe,Ze),Ze[0]&136&&Z(ve,1)):(ve=Jm(Fe),ve.c(),Z(ve,1),ve.m(m,null)):ve&&(jt(),ne(ve,1,1,()=>{ve=null}),zt()),(!le||Ze[0]&32)&&cn(L,Fe[5]);const H={};Ze[1]&8192&&(H.$$scope={dirty:Ze,ctx:Fe}),P.$set(H),!Fe[3]&&Fe[6].length?ke?ke.p(Fe,Ze):(ke=Qm(Fe),ke.c(),ke.m(n,x)):ke&&(ke.d(1),ke=null),Fe[3]?Ne?Ne.p(Fe,Ze):(Ne=e2(Fe),Ne.c(),Ne.m(K,J)):Ne&&(Ne.d(1),Ne=null),Fe[0]&&!Fe[3]?Te?Te.p(Fe,Ze):(Te=t2(Fe),Te.c(),Te.m(K,j)):Te&&(Te.d(1),Te=null),!Fe[3]&&Fe[6].length?Le?Le.p(Fe,Ze):(Le=n2(Fe),Le.c(),Le.m(K,B)):Le&&(Le.d(1),Le=null),(!le||Ze[0]&8&&R!==(R=Fe[3]>0))&&(M.disabled=R);const Pe={};Ze[1]&8192&&(Pe.$$scope={dirty:Ze,ctx:Fe}),re.$set(Pe);const xe={};Ze[0]&4&&(xe.currentProgress=Fe[2]),z.$set(xe)},i(Fe){le||(Z(u.$$.fragment,Fe),Z(ve),Z(P.$$.fragment,Fe),Z(ae.$$.fragment,Fe),Z(E.$$.fragment,Fe),Z(N.$$.fragment,Fe),Z(re.$$.fragment,Fe),Z(z.$$.fragment,Fe),le=!0)},o(Fe){ne(u.$$.fragment,Fe),ne(ve),ne(P.$$.fragment,Fe),ne(ae.$$.fragment,Fe),ne(E.$$.fragment,Fe),ne(N.$$.fragment,Fe),ne(re.$$.fragment,Fe),ne(z.$$.fragment,Fe),le=!1},d(Fe){Fe&&(de(e),de(Y),de(K),de(W)),we(u),ve&&ve.d(),we(P),ke&&ke.d(),we(ae),we(E),we(N),Ne&&Ne.d(),Te&&Te.d(),Le&&Le.d(),we(re),we(z,Fe),Me=!1,Ee()}}}const Xv=/[\p{punct}\s]/u;function r2(t){if(t===null)return;if(t.nodeType===Node.TEXT_NODE&&$i(t.textContent))return t;let e;for(let n=0,{length:r}=t.childNodes;n<r;n+=1){const i=t.childNodes[n];if(i.nodeType===Node.TEXT_NODE&&$i(t.textContent)?e=i:e=r2(i),e)break}return e}function Bf(t){return t.parentElement.closest('div[id^="ttu-"]')}function Df(t,e){const n=t[e].text,r=[...n].length;return{currentSubtitle:n,currentSubtitleLength:r}}function i2(t){return[...$i(t)].length}function $i(t,e=!1){const n=(t||"").replace(/\s/g,"").trim();return e?n.toLowerCase():n}function s2(t,e){const n=[...t];if(n.length===e)return t;let r="",i=0;for(let s=0,{length:o}=n;s<o;s+=1){let a=n[s];r+=a;const l=a.trim();if(l&&!Xv.test(l)&&(i+=1),i===e)break}return r}function Ff(t,e){const n=$i(t,!0),r=$i(e,!0),i=[...n].length,s=[...r].length,o=i<5?1:2;if(n===r)return 1;if(i<o||s<o)return 0;const a=new Map;for(let c=0;c<i-(o-1);c+=1){const u=[...n].slice(c,c+o).join("");a.set(u,a.has(u)?a.get(u)+1:1)}let l=0;for(let c=0;c<s-(o-1);c++){const u=[...r].slice(c,c+o).join(""),f=a.has(u)?a.get(u):0;f>0&&(a.set(u,f-1),l+=1)}return l*2/(i+s-(o-1)*2)}function o2(t,e,n,r){throw console.log(t,e,n,r),new Error(t)}function Yv(t,e,n){let r,i,s,o,a,l,c,u,f,g,v,_,b;ce(t,At,Ee=>n(31,a=Ee)),ce(t,Mt,Ee=>n(32,l=Ee)),ce(t,Ho,Ee=>n(33,c=Ee)),ce(t,Li,Ee=>n(34,u=Ee)),ce(t,rs,Ee=>n(35,f=Ee)),ce(t,Lr,Ee=>n(9,v=Ee)),ce(t,vi,Ee=>n(10,b=Ee));const y=new Set(["rt"]),{isIOS:p}=Io("context"),{matchLineIgnoreRp$:m,matchLineSimilarityThreshold$:w,matchLineMaxAttempts$:C}=_t;ce(t,m,Ee=>n(24,_=Ee)),ce(t,w,Ee=>n(30,o=Ee)),ce(t,C,Ee=>n(36,g=Ee));const h=Ri();let A,L=new AbortController,$=L.signal,P=0,I=0,x="n/a",ae="n/a",V=[],E=[],F=[],N,Y;async function K(){document.addEventListener("click",j,{once:!0,capture:!1}),h("selectHint")}function J(){n(21,N=void 0),n(22,Y=void 0)}function j({x:Ee,y:ve}){const ke=r2(document.elementFromPoint(Ee,ve));if(ke){const Ne=Bf(ke);Ne!=null&&Ne.id&&(n(21,N=ke.textContent),n(22,Y=Ne.id),ke.parentElement.style.visibility="hidden",setTimeout(()=>ke.parentElement.style.visibility="",500))}h("hintSelected")}function B(){fe(At,a=!0,a);let Ee="";for(let ve=0,{length:ke}=F;ve<ke;ve+=1){const Ne=F[ve];Ee+=`${Ne.id}
${Ne.text}
`}_u(document,new Blob([Ee],{type:"text/plain;charset=utf-8"}),`${f.name.split(/\.(?=[^\.]+$)/)[0]}_unmatched.txt`,p),fe(At,a=!1,a)}async function M(){fe(At,a=!0,a),fe(Mt,l="",l),n(4,x="n/a"),n(5,ae="n/a"),V=[],n(6,E=[]),n(7,F=[]),n(3,I=v.size);try{const Ee=[],ve=[...v.values()],ke=Math.min(ve.length,g),Ne=new Map,Te=new Map,Le=[...du].join(",");let Fe=[],Ze="",O="",H=0,Pe=!r,{currentSubtitle:xe,currentSubtitleLength:qe}=Df(ve,H);n(0,A=hu(new DOMParser,u.elementHtml));const nt=document.createTreeWalker(A,NodeFilter.SHOW_TEXT,{acceptNode(D){var U;if(r&&!Pe&&(Pe=N===D.textContent&&((U=Bf(D))==null?void 0:U.id)===Y,Pe&&(D.parentElement.dataset.ttuWhispersyncStartNode="")),Pe){const te=$i(D.textContent);re(Ne,D,te),te&&Ee.push(D)}return NodeFilter.FILTER_ACCEPT}});for(;nt.nextNode(););let Oe=0,je=1,et=0,rt=0,Je=Ee.length;for(;et<Je&&H<ve.length;){mu($);const D=Qa(H+1,I);let U=Ee[et],te=U.parentElement;if(D!==P&&(n(2,P=D),await new Promise(se=>setTimeout(se))),te.closest(s)||(Ze+=U.textContent),i2(Ze)>=qe){const se=s2(Ze,qe),ge=[...se].length;let pe=0,Ae=ge,Ce=Ff(se,xe);Fe.push(U);const De=W(xe,qe,se,ge,pe,Ce,Fe,Ee,et),tt=De.bestLineSimiliarityValue>=o;for(tt&&({bestLineSimiliarityStartIndex:pe,bestLineSimiliarityEndIndex:Ae,currentNodes:Fe,currentTextNodeIndex:et}=De),U=Ee[et],te=U.parentElement,et+=1;te.closest(s)&&et<Je;)U=Ee[et],te=U.parentElement,te.closest(s)&&Fe.push(U),et+=1;if(et-=1,tt){let mt=Ae-pe,We=0,dt=!1;if(pe!==0){const Be=Fe[0],$e=Be.textContent||"",ft=document.createTextNode([...$e].slice(0,pe).join("")),ze=document.createTextNode([...$e].slice(pe).join(""));Be.parentElement.replaceChild(ft,Be),ft.after(ze),Fe[0]=ze}for(let Be=0,{length:$e}=Fe;Be<$e;Be+=1){const ft=Fe[Be],ze=ft.parentElement,at=ft.textContent||"",Qe=[...at].length,vt=!!ze.closest(s),Rt=document.createElement("span"),lt=vt?[...at].slice(0).join(""):[...at].slice(0,mt).join(""),St=document.createTextNode(lt),ht=[...lt].length,xt=Qe-ht;if(mt){const ln=ve[H];Rt.classList.add(z_(ln.id)),Rt.appendChild(St),ze.replaceChild(Rt,ft),ze.closest(Le)||(O+=lt)}if(We+=vt?0:ht,mt=Ae-pe-We,!mt&&xt){const ln=[];Be+=ht?0:1;let qt=ht;for(;Be<$e;){const Dt=Fe[Be],rn=Dt.textContent||"",In=document.createTextNode([...rn].slice(qt).join(""));if(!rn)throw new Error("charactersToProcess without remaining text found");Dt.parentElement||(Rt.after(In),ln.push(In)),Be+=1,qt=0}ln.length&&Ee.splice(et,ln.length,...ln),dt=!0}}z(ve[H],O),Ze="",O="",dt||(et+=1),rt=et,H+=1,Oe+=1,je=1,H<ve.length&&({currentSubtitle:xe,currentSubtitleLength:qe}=Df(ve,H))}else{et=rt+je,je+=1,Ze="",O="";const mt=et>Ee.length,We=je>ke;(We||mt)&&(console.log(We?`Max match attempts for ${xe} (${ve[H].id}) reached - reset`:`End of Text before max attempt for ${xe} (${ve[H].id}) reached - reset`),F.push(ve[H]),z(ve[H],O),je=1,H+=1,H<ve.length?(et=rt,{currentSubtitle:xe,currentSubtitleLength:qe}=Df(ve,H)):et=Je)}Fe=[]}else Fe.push(U),et+=1;Je=Ee.length}Pe=!r;const G=document.createTreeWalker(A,NodeFilter.SHOW_TEXT,{acceptNode(D){var U;return r&&!Pe&&(Pe=!!((U=D.parentElement)!=null&&U.closest("*[data-ttu-whispersync-start-node]"))),Pe&&re(Te,D,$i(D.textContent)),NodeFilter.FILTER_ACCEPT}});for(;G.nextNode(););const T=[...Ne.entries()],d=[...Te.entries()];for(let D=0,{length:U}=T;D<U;D+=1){const[te,ee]=T[D],[se,ge]=d[D]||[],pe=Bf(te);te!==se&&o2(`element mismatch on index ${D}`,te,se,pe);const Ae=[...ee],Ce=[...ge];for(let De=0,{length:tt}=Ae;De<tt;De+=1){const mt=Ae[De],We=Ce[De];mt!==We&&o2(`mismatch on index ${D}, position ${De}: ${[...ee].slice(Math.max(0,De-10),Math.min(Ae.length,De+10)).join("")} | vs | ${[...ge].slice(Math.max(0,De-10),Math.min(Ce.length,De+10)).join("")}`,te,se,pe)}}const k=ve[ve.length-1];Ze&&(F.push(k),console.log(`End of Text before max attempt for ${k.text} (${k.id}) reached - reset`)),V.length&&V[V.length-1].id!==k.id&&z(k,O),n(4,x=`${Oe} / ${ve.length} (${Qa(Oe,ve.length,!1)}%)`),n(5,ae=`${E.length} / ${Oe} (${Qa(E.length,Oe,!1)}%)`),A.firstElementChild instanceof HTMLElement&&(n(0,A.firstElementChild.dataset.ttuWhispersyncMatchedBy=f.name,A),n(0,A.firstElementChild.dataset.ttuWhispersyncMatchedOn=`${Date.now()}`,A),n(0,A.firstElementChild.dataset.ttuWhispersyncMatchedSource="default",A))}catch(Ee){n(4,x="n/a"),n(5,ae="n/a"),n(0,A=void 0),V=[],n(6,E=[]),n(7,F=[]),!L.signal.aborted&&Ee.name!=="AbortError"&&fe(Mt,l=`Failed to match: ${Ee.message}`,l)}n(2,P=0),n(3,I=0),L=new AbortController,n(1,$=L.signal),fe(At,a=!1,a)}function S(){$.aborted||L.abort("user aborted")}function R(){fe(At,a=!0,a);let Ee="";for(let ve=0,{length:ke}=V;ve<ke;ve+=1){const Ne=V[ve];Ee+=`${Ne.id}
${Ne.startTime} --> ${Ne.endTime}
${Ne.text}
`}_u(document,new Blob([Ee],{type:`${p?"text/plain":"application/x-subrip"};charset=utf-8`}),`${f.name.split(/\.(?=[^\.]+$)/)[0]}_adjusted.srt`,p),fe(At,a=!1,a)}async function X(){fe(At,a=!0,a);try{const Ee={...u,htmlBackup:u.elementHtml,elementHtml:A.innerHTML,lastBookModified:Date.now()};await c.put("data",Ee),window.location.reload()}catch({message:Ee}){fe(Mt,l=`Failed to save data: ${Ee}`,l),fe(At,a=!1,a)}}function re(Ee,ve,ke){const Ne=ve.parentElement instanceof HTMLSpanElement&&Kc(ve.parentElement)!=="not existing"?ve.parentElement.parentElement:ve.parentElement;Ee.set(Ne,`${Ee.get(Ne)||""}${ke}`)}function W(Ee,ve,ke,Ne,Te,Le,Fe,Ze,O){let H=Te,Pe=Ne,xe=Le;if(xe!==1){for(let G=Pe;G>Te;G-=1)if($i(Ee)===$i([...ke].slice(Te,G).join(""))){H=Te,Pe=G,xe=1;break}}if(xe!==1)for(let G=Te;G<Pe;G+=1){const T=Ff(Ee,[...ke].slice(G,Pe).join(""));T>xe&&(H=G,Pe=Ne,xe=T)}if(Te===H||xe===1||xe<o){if(xe!==1){xe=-1;for(let D=Pe;D>Te;D-=1){const U=Ff(Ee,[...ke].slice(Te,D).join(""));U>xe&&(H=Te,Pe=D,xe=U)}}if(xe<o||xe===1)return{bestLineSimiliarityStartIndex:H,bestLineSimiliarityEndIndex:Pe,bestLineSimiliarityValue:xe,currentNodes:Fe,currentTextNodeIndex:O};const G=[],T=Fe.length,d=Pe-H;let k=0;for(;k<d&&Fe.length;){const D=Fe.shift(),U=D.parentElement;k+=U.closest(s)?0:[...D.textContent||""].length,G.push(D)}return{bestLineSimiliarityStartIndex:H,bestLineSimiliarityEndIndex:Pe,bestLineSimiliarityValue:xe,currentNodes:G,currentTextNodeIndex:O-(T-G.length)}}let qe=0,nt=0,Oe=H;for(let G=0,{length:T}=Fe;G<T;G+=1){let d=Fe[G],D=d.parentElement.closest(s)?0:[...d.textContent||""].length;const U=Oe-D;if(nt+=D,Oe=U<0?Oe:U,nt>=H){qe=G+(nt===H?1:0);break}}const je=[];let et="",rt=0,Je=O-(Fe.length-(qe+1));for(;rt<=ve&&Je<Ze.length;){const G=Ze[Je];G.parentElement.closest(s)||(et+=G.textContent),je.push(G),Je+=1,rt=i2(et)}return Je=Je-1,et=s2(et,ve),W(Ee,ve,et,[...et].length,Oe,xe,je,Ze,Je)}function z(Ee,ve){const ke=$i(Ee.text,!0),Ne=$i(ve,!0);V.push({...Ee}),ve&&ke!==Ne&&(V[V.length-1].text=ve,E.push({id:Ee.id,original:Ee.text,adjusted:ve}))}const le=()=>r?J():K(),Me=()=>Vo.add({component:Ov,props:{subtitleDiffDetails:E}});return t.$$.update=()=>{t.$$.dirty[0]&6291456&&n(8,r=N!==void 0&&Y!==void 0),t.$$.dirty[0]&16777216&&n(23,i=_?du:y),t.$$.dirty[0]&8388608&&(s=[...i].join(","))},[A,$,P,I,x,ae,E,F,r,v,b,m,w,C,K,J,B,M,S,R,X,N,Y,i,_,le,Me]}class Kv extends Dn{constructor(e){super(),Bn(this,e,Yv,zv,Cn,{},null,[-1,-1])}}function qv(t){let e,n,r,i,s,o,a,l;return r=new kt({props:{path:Nd}}),s=new _1({props:{subtitle:t[1],buttonClasses:t[4]?"p-y-xs":"p-x-xs",listItems:t[3]}}),s.$on("executed",t[11]),{c(){e=_e("div"),n=_e("button"),ye(r.$$.fragment),i=me(),ye(s.$$.fragment),ie(n,"title","Close menu"),pt(n,"p-y-xs",t[4]),pt(n,"p-x-xs",!t[4]),ie(e,"class","ttu-whispersync-container popover reader-menu"),pt(e,"flex-col",t[4]),pt(e,"hidden",!t[0])},m(c,u){he(c,e,u),oe(e,n),be(r,n,null),oe(e,i),be(s,e,null),t[12](e),o=!0,a||(l=Xe(n,"click",t[6]),a=!0)},p(c,[u]){const f={};u&2&&(f.subtitle=c[1]),u&8&&(f.listItems=c[3]),s.$set(f),(!o||u&1)&&pt(e,"hidden",!c[0])},i(c){o||(Z(r.$$.fragment,c),Z(s.$$.fragment,c),o=!0)},o(c){ne(r.$$.fragment,c),ne(s.$$.fragment,c),o=!1},d(c){c&&de(e),we(r),we(s),t[12](null),a=!1,l()}}}function Zv(t,e,n){let r,i,s,o;ce(t,xi,I=>n(8,r=I)),ce(t,Ps,I=>n(9,i=I)),ce(t,Lr,I=>n(10,s=I));let{range:a}=e,{subtitle:l}=e;function c(I){return!I||!m?!1:m.contains(I)}const{bookContentElement:u,isVertical:f,isPaginated:g}=Io("context"),{actionListOfReader$:v}=_t;ce(t,v,I=>n(3,o=I));const _=f?"left-start":"top-start",b=f?["right-start","left-end","right-end"]:["bottom-start","top-end","bottom-end"],y=Ri();let p,m,w;Yl(()=>p==null?void 0:p());function C(){y("close")}async function h(I){p==null||p(),I&&(await Mr(),p=_m(I,m,A))}function A(){a&&bm({getBoundingClientRect:()=>a.getBoundingClientRect(),getClientRects:()=>{if(!g)return a.getClientRects();const I=L(),x=[...a.getClientRects()],ae=x.filter(E=>E.bottom>I.top&&E.right>I.left&&E.top<I.bottom&&E.left<I.right),V=(ae.length?ae:x).filter(E=>{var N;return!((N=document.elementFromPoint(E.x,E.y))==null?void 0:N.closest("rt"))});return V.length?V:x}},m,{placement:_,middleware:[im(5),_y(),gm({fallbackPlacements:b})]}).then(({x:I,y:x})=>{n(2,m.style.left=`${I}px`,m),n(2,m.style.top=`${x}px`,m)}).catch(()=>{})}function L(){w||(w=window.getComputedStyle(u));const I=u.getBoundingClientRect(),x=f?I.top:I.top+Number.parseFloat(w.paddingTop.replace("px","")),ae=f?I.right-Number.parseFloat(w.paddingRight.replace("px","")):I.right,V=f?I.bottom:I.bottom-Number.parseFloat(w.paddingBottom.replace("px","")),E=f?I.left+Number.parseFloat(w.paddingLeft.replace("px","")):I.left;return{top:x,right:ae,left:E,bottom:V}}const $=({detail:I})=>{I===Re.COPY_SUBTITLE&&C()};function P(I){Vt[I?"unshift":"push"](()=>{m=I,n(2,m)})}return t.$$set=I=>{"range"in I&&n(0,a=I.range),"subtitle"in I&&n(1,l=I.subtitle)},t.$$.update=()=>{t.$$.dirty&1794&&(l||s.size),t.$$.dirty&1&&h(a)},[a,l,m,o,f,v,C,c,r,i,s,$,P]}class Jv extends Dn{constructor(e){super(),Bn(this,e,Zv,qv,Cn,{range:0,subtitle:1,isInReaderMenu:7})}get isInReaderMenu(){return this.$$.ctx[7]}}function Qv(t){let e,n,r,i,s,o,a,l,c,u,f,g,v,_;return f=new kt({props:{path:Yd}}),{c(){e=_e("label"),n=Nt(t[1]),r=me(),i=_e("div"),s=_e("input"),a=me(),l=_e("input"),c=me(),u=_e("button"),ye(f.$$.fragment),ie(e,"for",t[4]),ie(s,"type","text"),Cr(s,"max-width","50%"),s.value=t[2],ie(l,"class","flex-1 m-l-s"),ie(l,"type","color"),ie(l,"id",t[4]),ie(i,"class","flex items-center"),ie(u,"title","Reset Color")},m(b,y){he(b,e,y),oe(e,n),he(b,r,y),he(b,i,y),oe(i,s),oe(i,a),oe(i,l),Mi(l,t[2]),he(b,c,y),he(b,u,y),be(f,u,null),g=!0,v||(_=[Xe(s,"blur",t[6]),Ma(o=Mu.call(null,s,{document,isSkipped:t[3]})),Xe(l,"input",t[8]),Xe(l,"change",t[7]),Xe(u,"click",t[9])],v=!0)},p(b,[y]){(!g||y&2)&&cn(n,b[1]),(!g||y&4&&s.value!==b[2])&&(s.value=b[2]),o&&Ci(o.update)&&y&8&&o.update.call(null,{document,isSkipped:b[3]}),y&4&&Mi(l,b[2])},i(b){g||(Z(f.$$.fragment,b),g=!0)},o(b){ne(f.$$.fragment,b),g=!1},d(b){b&&(de(e),de(r),de(i),de(c),de(u)),we(f),v=!1,vn(_)}}}function e9(t,e,n){let r,i=wt,s=()=>(i(),i=ns(a,b=>n(2,r=b)),a),o;ce(t,En,b=>n(3,o=b)),t.$$.on_destroy.push(()=>i());let{targetStore$:a}=e;s();let{label:l}=e;const c=a.key(),u=Ri();function f({currentTarget:b}){b.value.match(/^#[0-9A-F]{6}$/i)?(fe(a,r=b.value,r),u("change")):b.value=r}function g(b){mn.call(this,t,b)}function v(){r=this.value,a.set(r)}const _=()=>{a.set(eu(c)),u("reset")};return t.$$set=b=>{"targetStore$"in b&&s(n(0,a=b.targetStore$)),"label"in b&&n(1,l=b.label)},[a,l,r,o,c,u,f,g,v,_]}class a2 extends Dn{constructor(e){super(),Bn(this,e,e9,Qv,Cn,{targetStore$:0,label:1})}}function t9(t){let e,n,r,i,s,o=t[2]?" for active subtitle":"",a,l,c;return{c(){e=_e("div"),n=Nt(t[0]),r=me(),i=_e("div"),s=Nt(t[1]),a=Nt(o),l=me(),c=_e("div")},m(u,f){he(u,e,f),oe(e,n),he(u,r,f),he(u,i,f),oe(i,s),oe(i,a),he(u,l,f),he(u,c,f)},p(u,[f]){f&1&&cn(n,u[0]),f&2&&cn(s,u[1]),f&4&&o!==(o=u[2]?" for active subtitle":"")&&cn(a,o)},i:wt,o:wt,d(u){u&&(de(e),de(r),de(i),de(l),de(c))}}}function n9(t,e,n){let{key:r}=e,{description:i}=e,{extendDescription:s=!0}=e;return t.$$set=o=>{"key"in o&&n(0,r=o.key),"description"in o&&n(1,i=o.description),"extendDescription"in o&&n(2,s=o.extendDescription)},[r,i,s]}class gr extends Dn{constructor(e){super(),Bn(this,e,n9,t9,Cn,{key:0,description:1,extendDescription:2})}}function r9(t){let e,n,r,i,s,o,a,l;const c=t[5].default,u=Mo(c,t,t[4],null);return{c(){e=_e("details"),n=_e("summary"),r=Nt(t[0]),i=me(),s=_e("div"),u&&u.c(),ie(s,"class","settings-grid"),e.open=t[1]},m(f,g){he(f,e,g),oe(e,n),oe(n,r),oe(e,i),oe(e,s),u&&u.m(s,null),o=!0,a||(l=Xe(n,"click",Ra(zl(t[2]))),a=!0)},p(f,[g]){(!o||g&1)&&cn(r,f[0]),u&&u.p&&(!o||g&16)&&Lo(u,c,f,f[4],o?Ro(c,f[4],g,null):Po(f[4]),null),(!o||g&2)&&(e.open=f[1])},i(f){o||(Z(u,f),o=!0)},o(f){ne(u,f),o=!1},d(f){f&&de(e),u&&u.d(f),a=!1,l()}}}function i9(t,e,n){let r,{$$slots:i={},$$scope:s}=e,{openSettingsMenu:o}=e,{settingsMenu:a}=e;function l(){n(3,o=r?ci.NONE:a)}return t.$$set=c=>{"openSettingsMenu"in c&&n(3,o=c.openSettingsMenu),"settingsMenu"in c&&n(0,a=c.settingsMenu),"$$scope"in c&&n(4,s=c.$$scope)},t.$$.update=()=>{t.$$.dirty&9&&n(1,r=o===a)},[a,r,l,o,s,i]}class Es extends Dn{constructor(e){super(),Bn(this,e,i9,r9,Cn,{openSettingsMenu:3,settingsMenu:0})}}function l2(t,e,n){const r=t.slice();return r[12]=e[n],r}function u2(t,e){let n,r=e[12]+"",i,s,o;return{key:t,first:null,c(){n=_e("option"),i=Nt(r),s=me(),n.__value=o=e[12],Mi(n,n.__value),this.first=n},m(a,l){he(a,n,l),oe(n,i),oe(n,s)},p(a,l){e=a,l&2&&r!==(r=e[12]+"")&&cn(i,r),l&2&&o!==(o=e[12])&&(n.__value=o,Mi(n,n.__value))},d(a){a&&de(n)}}}function s9(t){let e;return{c(){e=_e("div")},m(n,r){he(n,e,r)},p:wt,i:wt,o:wt,d(n){n&&de(e)}}}function o9(t){let e,n,r;return n=new kt({props:{path:t[4]}}),n.$on("click",t[11]),{c(){e=_e("button"),ye(n.$$.fragment),ie(e,"title",t[5])},m(i,s){he(i,e,s),be(n,e,null),r=!0},p(i,s){const o={};s&16&&(o.path=i[4]),n.$set(o),(!r||s&32)&&ie(e,"title",i[5])},i(i){r||(Z(n.$$.fragment,i),r=!0)},o(i){ne(n.$$.fragment,i),r=!1},d(i){i&&de(e),we(n)}}}function a9(t){let e,n;return e=new _i({props:{$$slots:{icon:[u9],default:[l9]},$$scope:{ctx:t}}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},p(r,i){const s={};i&32776&&(s.$$scope={dirty:i,ctx:r}),e.$set(s)},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function l9(t){let e,n;return{c(){e=_e("div"),n=Nt(t[3])},m(r,i){he(r,e,i),oe(e,n)},p(r,i){i&8&&cn(n,r[3])},d(r){r&&de(e)}}}function u9(t){let e,n,r;return n=new kt({props:{path:to}}),{c(){e=_e("div"),ye(n.$$.fragment),ie(e,"slot","icon")},m(i,s){he(i,e,s),be(n,e,null),r=!0},p:wt,i(i){r||(Z(n.$$.fragment,i),r=!0)},o(i){ne(n.$$.fragment,i),r=!1},d(i){i&&de(e),we(n)}}}function c9(t){let e,n,r,i,s=[],o=new Map,a,l,c,u,f,g,v,_,b=Jr(t[1]);const y=C=>C[12];for(let C=0;C<b.length;C+=1){let h=l2(t,b,C),A=y(h);o.set(A,s[C]=u2(A,h))}const p=[a9,o9,s9],m=[];function w(C,h){return C[3]?0:C[4]?1:2}return c=w(t),u=m[c]=p[c](t),{c(){e=_e("label"),n=Nt(t[2]),r=me(),i=_e("select");for(let C=0;C<s.length;C+=1)s[C].c();l=me(),u.c(),f=Fr(),ie(e,"for",t[8]),i.disabled=a=!t[1].length||t[6],ie(i,"id",t[8]),t[7]===void 0&&Ms(()=>t[10].call(i))},m(C,h){he(C,e,h),oe(e,n),he(C,r,h),he(C,i,h);for(let A=0;A<s.length;A+=1)s[A]&&s[A].m(i,null);Xl(i,t[7],!0),he(C,l,h),m[c].m(C,h),he(C,f,h),g=!0,v||(_=[Xe(i,"change",t[10]),Xe(i,"change",t[9])],v=!0)},p(C,[h]){(!g||h&4)&&cn(n,C[2]),h&2&&(b=Jr(C[1]),s=Ks(s,h,y,1,C,b,o,i,Ba,u2,null,l2)),(!g||h&66&&a!==(a=!C[1].length||C[6]))&&(i.disabled=a),h&130&&Xl(i,C[7]);let A=c;c=w(C),c===A?m[c].p(C,h):(jt(),ne(m[A],1,1,()=>{m[A]=null}),zt(),u=m[c],u?u.p(C,h):(u=m[c]=p[c](C),u.c()),Z(u,1),u.m(f.parentNode,f))},i(C){g||(Z(u),g=!0)},o(C){ne(u),g=!1},d(C){C&&(de(e),de(r),de(i),de(l),de(f));for(let h=0;h<s.length;h+=1)s[h].d();m[c].d(C),v=!1,vn(_)}}}function f9(t,e,n){let r,i=wt,s=()=>(i(),i=ns(o,p=>n(7,r=p)),o);t.$$.on_destroy.push(()=>i());let{targetStore$:o}=e;s();let{options:a}=e,{label:l}=e,{helpText:c=""}=e,{buttonIcon:u=""}=e,{buttonTitle:f=""}=e,{disabled:g=!1}=e;const v=o.key();function _(p){mn.call(this,t,p)}function b(){r=sd(this),o.set(r),n(1,a)}function y(p){mn.call(this,t,p)}return t.$$set=p=>{"targetStore$"in p&&s(n(0,o=p.targetStore$)),"options"in p&&n(1,a=p.options),"label"in p&&n(2,l=p.label),"helpText"in p&&n(3,c=p.helpText),"buttonIcon"in p&&n(4,u=p.buttonIcon),"buttonTitle"in p&&n(5,f=p.buttonTitle),"disabled"in p&&n(6,g=p.disabled)},[o,a,l,c,u,f,g,r,v,_,b,y]}class Ir extends Dn{constructor(e){super(),Bn(this,e,f9,c9,Cn,{targetStore$:0,options:1,label:2,helpText:3,buttonIcon:4,buttonTitle:5,disabled:6})}}function d9(t){let e;return{c(){e=_e("div")},m(n,r){he(n,e,r)},p:wt,i:wt,o:wt,d(n){n&&de(e)}}}function h9(t){let e,n,r;return n=new kt({props:{path:t[3]}}),n.$on("click",t[10]),{c(){e=_e("button"),ye(n.$$.fragment),ie(e,"title",t[4])},m(i,s){he(i,e,s),be(n,e,null),r=!0},p(i,s){const o={};s&8&&(o.path=i[3]),n.$set(o),(!r||s&16)&&ie(e,"title",i[4])},i(i){r||(Z(n.$$.fragment,i),r=!0)},o(i){ne(n.$$.fragment,i),r=!1},d(i){i&&de(e),we(n)}}}function p9(t){let e,n;return e=new _i({props:{$$slots:{icon:[_9],default:[m9]},$$scope:{ctx:t}}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},p(r,i){const s={};i&2052&&(s.$$scope={dirty:i,ctx:r}),e.$set(s)},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function m9(t){let e,n;return{c(){e=_e("div"),n=Nt(t[2])},m(r,i){he(r,e,i),oe(e,n)},p(r,i){i&4&&cn(n,r[2])},d(r){r&&de(e)}}}function _9(t){let e,n,r;return n=new kt({props:{path:to}}),{c(){e=_e("div"),ye(n.$$.fragment),ie(e,"slot","icon")},m(i,s){he(i,e,s),be(n,e,null),r=!0},p:wt,i(i){r||(Z(n.$$.fragment,i),r=!0)},o(i){ne(n.$$.fragment,i),r=!1},d(i){i&&de(e),we(n)}}}function g9(t){let e,n,r,i,s,o,a,l,c,u,f,g;const v=[p9,h9,d9],_=[];function b(y,p){return y[2]?0:y[3]?1:2}return a=b(t),l=_[a]=v[a](t),{c(){e=_e("label"),n=Nt(t[1]),r=me(),i=_e("input"),o=me(),l.c(),c=Fr(),ie(e,"for",t[7]),i.value=t[5],ie(i,"id",t[7])},m(y,p){he(y,e,p),oe(e,n),he(y,r,p),he(y,i,p),he(y,o,p),_[a].m(y,p),he(y,c,p),u=!0,f||(g=[Xe(i,"blur",t[8]),Xe(i,"change",t[9]),Ma(s=Mu.call(null,i,{document,isSkipped:t[6]}))],f=!0)},p(y,[p]){(!u||p&2)&&cn(n,y[1]),(!u||p&32&&i.value!==y[5])&&(i.value=y[5]),s&&Ci(s.update)&&p&64&&s.update.call(null,{document,isSkipped:y[6]});let m=a;a=b(y),a===m?_[a].p(y,p):(jt(),ne(_[m],1,1,()=>{_[m]=null}),zt(),l=_[a],l?l.p(y,p):(l=_[a]=v[a](y),l.c()),Z(l,1),l.m(c.parentNode,c))},i(y){u||(Z(l),u=!0)},o(y){ne(l),u=!1},d(y){y&&(de(e),de(r),de(i),de(o),de(c)),_[a].d(y),f=!1,vn(g)}}}function b9(t,e,n){let r,i=wt,s=()=>(i(),i=ns(a,y=>n(5,r=y)),a),o;ce(t,En,y=>n(6,o=y)),t.$$.on_destroy.push(()=>i());let{targetStore$:a}=e;s();let{label:l}=e,{helpText:c=""}=e,{buttonIcon:u=""}=e,{buttonTitle:f=""}=e;const g=a.key();function v(y){mn.call(this,t,y)}const _=y=>Y_(y,a);function b(y){mn.call(this,t,y)}return t.$$set=y=>{"targetStore$"in y&&s(n(0,a=y.targetStore$)),"label"in y&&n(1,l=y.label),"helpText"in y&&n(2,c=y.helpText),"buttonIcon"in y&&n(3,u=y.buttonIcon),"buttonTitle"in y&&n(4,f=y.buttonTitle)},[a,l,c,u,f,r,o,g,v,_,b]}class pc extends Dn{constructor(e){super(),Bn(this,e,b9,g9,Cn,{targetStore$:0,label:1,helpText:2,buttonIcon:3,buttonTitle:4})}}/**!
* Sortable 1.15.2
* @author RubaXa <[email protected]>
* @author owenm <[email protected]>
* @license MIT
*/function c2(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Zi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?c2(Object(n),!0).forEach(function(r){w9(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):c2(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function mc(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?mc=function(e){return typeof e}:mc=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},mc(t)}function w9(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ji(){return Ji=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Ji.apply(this,arguments)}function y9(t,e){if(t==null)return{};var n={},r=Object.keys(t),i,s;for(s=0;s<r.length;s++)i=r[s],!(e.indexOf(i)>=0)&&(n[i]=t[i]);return n}function v9(t,e){if(t==null)return{};var n=y9(t,e),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(i=0;i<s.length;i++)r=s[i],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}var E9="1.15.2";function Ss(t){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(t)}var Ts=Ss(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Cl=Ss(/Edge/i),f2=Ss(/firefox/i),Ml=Ss(/safari/i)&&!Ss(/chrome/i)&&!Ss(/android/i),d2=Ss(/iP(ad|od|hone)/i),h2=Ss(/chrome/i)&&Ss(/android/i),p2={capture:!1,passive:!1};function Rn(t,e,n){t.addEventListener(e,n,!Ts&&p2)}function yn(t,e,n){t.removeEventListener(e,n,!Ts&&p2)}function _c(t,e){if(e){if(e[0]===">"&&(e=e.substring(1)),t)try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch{return!1}return!1}}function S9(t){return t.host&&t!==document&&t.host.nodeType?t.host:t.parentNode}function Ni(t,e,n,r){if(t){n=n||document;do{if(e!=null&&(e[0]===">"?t.parentNode===n&&_c(t,e):_c(t,e))||r&&t===n)return t;if(t===n)break}while(t=S9(t))}return null}var m2=/\s+/g;function Ur(t,e,n){if(t&&e)if(t.classList)t.classList[n?"add":"remove"](e);else{var r=(" "+t.className+" ").replace(m2," ").replace(" "+e+" "," ");t.className=(r+(n?" "+e:"")).replace(m2," ")}}function Ut(t,e,n){var r=t&&t.style;if(r){if(n===void 0)return document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(n=t.currentStyle),e===void 0?n:n[e];!(e in r)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),r[e]=n+(typeof n=="string"?"":"px")}}function ga(t,e){var n="";if(typeof t=="string")n=t;else do{var r=Ut(t,"transform");r&&r!=="none"&&(n=r+" "+n)}while(!e&&(t=t.parentNode));var i=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return i&&new i(n)}function _2(t,e,n){if(t){var r=t.getElementsByTagName(e),i=0,s=r.length;if(n)for(;i<s;i++)n(r[i],i);return r}return[]}function Qi(){var t=document.scrollingElement;return t||document.documentElement}function br(t,e,n,r,i){if(!(!t.getBoundingClientRect&&t!==window)){var s,o,a,l,c,u,f;if(t!==window&&t.parentNode&&t!==Qi()?(s=t.getBoundingClientRect(),o=s.top,a=s.left,l=s.bottom,c=s.right,u=s.height,f=s.width):(o=0,a=0,l=window.innerHeight,c=window.innerWidth,u=window.innerHeight,f=window.innerWidth),(e||n)&&t!==window&&(i=i||t.parentNode,!Ts))do if(i&&i.getBoundingClientRect&&(Ut(i,"transform")!=="none"||n&&Ut(i,"position")!=="static")){var g=i.getBoundingClientRect();o-=g.top+parseInt(Ut(i,"border-top-width")),a-=g.left+parseInt(Ut(i,"border-left-width")),l=o+s.height,c=a+s.width;break}while(i=i.parentNode);if(r&&t!==window){var v=ga(i||t),_=v&&v.a,b=v&&v.d;v&&(o/=b,a/=_,f/=_,u/=b,l=o+u,c=a+f)}return{top:o,left:a,bottom:l,right:c,width:f,height:u}}}function g2(t,e,n){for(var r=Hs(t,!0),i=br(t)[e];r;){var s=br(r)[n],o=void 0;if(n==="top"||n==="left"?o=i>=s:o=i<=s,!o)return r;if(r===Qi())break;r=Hs(r,!1)}return!1}function ba(t,e,n,r){for(var i=0,s=0,o=t.children;s<o.length;){if(o[s].style.display!=="none"&&o[s]!==Ht.ghost&&(r||o[s]!==Ht.dragged)&&Ni(o[s],n.draggable,t,!1)){if(i===e)return o[s];i++}s++}return null}function $f(t,e){for(var n=t.lastElementChild;n&&(n===Ht.ghost||Ut(n,"display")==="none"||e&&!_c(n,e));)n=n.previousElementSibling;return n||null}function ri(t,e){var n=0;if(!t||!t.parentNode)return-1;for(;t=t.previousElementSibling;)t.nodeName.toUpperCase()!=="TEMPLATE"&&t!==Ht.clone&&(!e||_c(t,e))&&n++;return n}function b2(t){var e=0,n=0,r=Qi();if(t)do{var i=ga(t),s=i.a,o=i.d;e+=t.scrollLeft*s,n+=t.scrollTop*o}while(t!==r&&(t=t.parentNode));return[e,n]}function T9(t,e){for(var n in t)if(t.hasOwnProperty(n)){for(var r in e)if(e.hasOwnProperty(r)&&e[r]===t[n][r])return Number(n)}return-1}function Hs(t,e){if(!t||!t.getBoundingClientRect)return Qi();var n=t,r=!1;do if(n.clientWidth<n.scrollWidth||n.clientHeight<n.scrollHeight){var i=Ut(n);if(n.clientWidth<n.scrollWidth&&(i.overflowX=="auto"||i.overflowX=="scroll")||n.clientHeight<n.scrollHeight&&(i.overflowY=="auto"||i.overflowY=="scroll")){if(!n.getBoundingClientRect||n===document.body)return Qi();if(r||e)return n;r=!0}}while(n=n.parentNode);return Qi()}function k9(t,e){if(t&&e)for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function Nf(t,e){return Math.round(t.top)===Math.round(e.top)&&Math.round(t.left)===Math.round(e.left)&&Math.round(t.height)===Math.round(e.height)&&Math.round(t.width)===Math.round(e.width)}var Rl;function w2(t,e){return function(){if(!Rl){var n=arguments,r=this;n.length===1?t.call(r,n[0]):t.apply(r,n),Rl=setTimeout(function(){Rl=void 0},e)}}}function A9(){clearTimeout(Rl),Rl=void 0}function y2(t,e,n){t.scrollLeft+=e,t.scrollTop+=n}function v2(t){var e=window.Polymer,n=window.jQuery||window.Zepto;return e&&e.dom?e.dom(t).cloneNode(!0):n?n(t).clone(!0)[0]:t.cloneNode(!0)}function E2(t,e,n){var r={};return Array.from(t.children).forEach(function(i){var s,o,a,l;if(!(!Ni(i,e.draggable,t,!1)||i.animated||i===n)){var c=br(i);r.left=Math.min((s=r.left)!==null&&s!==void 0?s:1/0,c.left),r.top=Math.min((o=r.top)!==null&&o!==void 0?o:1/0,c.top),r.right=Math.max((a=r.right)!==null&&a!==void 0?a:-1/0,c.right),r.bottom=Math.max((l=r.bottom)!==null&&l!==void 0?l:-1/0,c.bottom)}}),r.width=r.right-r.left,r.height=r.bottom-r.top,r.x=r.left,r.y=r.top,r}var gi="Sortable"+new Date().getTime();function C9(){var t=[],e;return{captureAnimationState:function(){if(t=[],!!this.options.animation){var r=[].slice.call(this.el.children);r.forEach(function(i){if(!(Ut(i,"display")==="none"||i===Ht.ghost)){t.push({target:i,rect:br(i)});var s=Zi({},t[t.length-1].rect);if(i.thisAnimationDuration){var o=ga(i,!0);o&&(s.top-=o.f,s.left-=o.e)}i.fromRect=s}})}},addAnimationState:function(r){t.push(r)},removeAnimationState:function(r){t.splice(T9(t,{target:r}),1)},animateAll:function(r){var i=this;if(!this.options.animation){clearTimeout(e),typeof r=="function"&&r();return}var s=!1,o=0;t.forEach(function(a){var l=0,c=a.target,u=c.fromRect,f=br(c),g=c.prevFromRect,v=c.prevToRect,_=a.rect,b=ga(c,!0);b&&(f.top-=b.f,f.left-=b.e),c.toRect=f,c.thisAnimationDuration&&Nf(g,f)&&!Nf(u,f)&&(_.top-f.top)/(_.left-f.left)===(u.top-f.top)/(u.left-f.left)&&(l=R9(_,g,v,i.options)),Nf(f,u)||(c.prevFromRect=u,c.prevToRect=f,l||(l=i.options.animation),i.animate(c,_,f,l)),l&&(s=!0,o=Math.max(o,l),clearTimeout(c.animationResetTimer),c.animationResetTimer=setTimeout(function(){c.animationTime=0,c.prevFromRect=null,c.fromRect=null,c.prevToRect=null,c.thisAnimationDuration=null},l),c.thisAnimationDuration=l)}),clearTimeout(e),s?e=setTimeout(function(){typeof r=="function"&&r()},o):typeof r=="function"&&r(),t=[]},animate:function(r,i,s,o){if(o){Ut(r,"transition",""),Ut(r,"transform","");var a=ga(this.el),l=a&&a.a,c=a&&a.d,u=(i.left-s.left)/(l||1),f=(i.top-s.top)/(c||1);r.animatingX=!!u,r.animatingY=!!f,Ut(r,"transform","translate3d("+u+"px,"+f+"px,0)"),this.forRepaintDummy=M9(r),Ut(r,"transition","transform "+o+"ms"+(this.options.easing?" "+this.options.easing:"")),Ut(r,"transform","translate3d(0,0,0)"),typeof r.animated=="number"&&clearTimeout(r.animated),r.animated=setTimeout(function(){Ut(r,"transition",""),Ut(r,"transform",""),r.animated=!1,r.animatingX=!1,r.animatingY=!1},o)}}}}function M9(t){return t.offsetWidth}function R9(t,e,n,r){return Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))/Math.sqrt(Math.pow(e.top-n.top,2)+Math.pow(e.left-n.left,2))*r.animation}var wa=[],Vf={initializeByDefault:!0},Ll={mount:function(e){for(var n in Vf)Vf.hasOwnProperty(n)&&!(n in e)&&(e[n]=Vf[n]);wa.forEach(function(r){if(r.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),wa.push(e)},pluginEvent:function(e,n,r){var i=this;this.eventCanceled=!1,r.cancel=function(){i.eventCanceled=!0};var s=e+"Global";wa.forEach(function(o){n[o.pluginName]&&(n[o.pluginName][s]&&n[o.pluginName][s](Zi({sortable:n},r)),n.options[o.pluginName]&&n[o.pluginName][e]&&n[o.pluginName][e](Zi({sortable:n},r)))})},initializePlugins:function(e,n,r,i){wa.forEach(function(a){var l=a.pluginName;if(!(!e.options[l]&&!a.initializeByDefault)){var c=new a(e,n,e.options);c.sortable=e,c.options=e.options,e[l]=c,Ji(r,c.defaults)}});for(var s in e.options)if(e.options.hasOwnProperty(s)){var o=this.modifyOption(e,s,e.options[s]);typeof o<"u"&&(e.options[s]=o)}},getEventProperties:function(e,n){var r={};return wa.forEach(function(i){typeof i.eventProperties=="function"&&Ji(r,i.eventProperties.call(n[i.pluginName],e))}),r},modifyOption:function(e,n,r){var i;return wa.forEach(function(s){e[s.pluginName]&&s.optionListeners&&typeof s.optionListeners[n]=="function"&&(i=s.optionListeners[n].call(e[s.pluginName],r))}),i}};function L9(t){var e=t.sortable,n=t.rootEl,r=t.name,i=t.targetEl,s=t.cloneEl,o=t.toEl,a=t.fromEl,l=t.oldIndex,c=t.newIndex,u=t.oldDraggableIndex,f=t.newDraggableIndex,g=t.originalEvent,v=t.putSortable,_=t.extraEventProperties;if(e=e||n&&n[gi],!!e){var b,y=e.options,p="on"+r.charAt(0).toUpperCase()+r.substr(1);window.CustomEvent&&!Ts&&!Cl?b=new CustomEvent(r,{bubbles:!0,cancelable:!0}):(b=document.createEvent("Event"),b.initEvent(r,!0,!0)),b.to=o||n,b.from=a||n,b.item=i||n,b.clone=s,b.oldIndex=l,b.newIndex=c,b.oldDraggableIndex=u,b.newDraggableIndex=f,b.originalEvent=g,b.pullMode=v?v.lastPutMode:void 0;var m=Zi(Zi({},_),Ll.getEventProperties(r,e));for(var w in m)b[w]=m[w];n&&n.dispatchEvent(b),y[p]&&y[p].call(e,b)}}var P9=["evt"],ii=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=r.evt,s=v9(r,P9);Ll.pluginEvent.bind(Ht)(e,n,Zi({dragEl:yt,parentEl:ir,ghostEl:Qt,rootEl:zn,nextEl:wo,lastDownEl:gc,cloneEl:Jn,cloneHidden:xs,dragStarted:Il,putSortable:Nr,activeSortable:Ht.active,originalEvent:i,oldIndex:ya,oldDraggableIndex:Pl,newIndex:bi,newDraggableIndex:Us,hideGhostForTarget:R2,unhideGhostForTarget:L2,cloneNowHidden:function(){xs=!0},cloneNowShown:function(){xs=!1},dispatchSortableEvent:function(a){Zr({sortable:n,name:a,originalEvent:i})}},s))};function Zr(t){L9(Zi({putSortable:Nr,cloneEl:Jn,targetEl:yt,rootEl:zn,oldIndex:ya,oldDraggableIndex:Pl,newIndex:bi,newDraggableIndex:Us},t))}var yt,ir,Qt,zn,wo,gc,Jn,xs,ya,bi,Pl,Us,bc,Nr,va=!1,wc=!1,yc=[],yo,Vi,Hf,xf,S2,T2,Il,Ea,Ol,Bl=!1,vc=!1,Ec,Wr,Uf=[],Wf=!1,Sc=[],Tc=typeof document<"u",kc=d2,k2=Cl||Ts?"cssFloat":"float",I9=Tc&&!h2&&!d2&&"draggable"in document.createElement("div"),A2=function(){if(Tc){if(Ts)return!1;var t=document.createElement("x");return t.style.cssText="pointer-events:auto",t.style.pointerEvents==="auto"}}(),C2=function(e,n){var r=Ut(e),i=parseInt(r.width)-parseInt(r.paddingLeft)-parseInt(r.paddingRight)-parseInt(r.borderLeftWidth)-parseInt(r.borderRightWidth),s=ba(e,0,n),o=ba(e,1,n),a=s&&Ut(s),l=o&&Ut(o),c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+br(s).width,u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+br(o).width;if(r.display==="flex")return r.flexDirection==="column"||r.flexDirection==="column-reverse"?"vertical":"horizontal";if(r.display==="grid")return r.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(s&&a.float&&a.float!=="none"){var f=a.float==="left"?"left":"right";return o&&(l.clear==="both"||l.clear===f)?"vertical":"horizontal"}return s&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||c>=i&&r[k2]==="none"||o&&r[k2]==="none"&&c+u>i)?"vertical":"horizontal"},O9=function(e,n,r){var i=r?e.left:e.top,s=r?e.right:e.bottom,o=r?e.width:e.height,a=r?n.left:n.top,l=r?n.right:n.bottom,c=r?n.width:n.height;return i===a||s===l||i+o/2===a+c/2},B9=function(e,n){var r;return yc.some(function(i){var s=i[gi].options.emptyInsertThreshold;if(!(!s||$f(i))){var o=br(i),a=e>=o.left-s&&e<=o.right+s,l=n>=o.top-s&&n<=o.bottom+s;if(a&&l)return r=i}}),r},M2=function(e){function n(s,o){return function(a,l,c,u){var f=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(s==null&&(o||f))return!0;if(s==null||s===!1)return!1;if(o&&s==="clone")return s;if(typeof s=="function")return n(s(a,l,c,u),o)(a,l,c,u);var g=(o?a:l).options.group.name;return s===!0||typeof s=="string"&&s===g||s.join&&s.indexOf(g)>-1}}var r={},i=e.group;(!i||mc(i)!="object")&&(i={name:i}),r.name=i.name,r.checkPull=n(i.pull,!0),r.checkPut=n(i.put),r.revertClone=i.revertClone,e.group=r},R2=function(){!A2&&Qt&&Ut(Qt,"display","none")},L2=function(){!A2&&Qt&&Ut(Qt,"display","")};Tc&&!h2&&document.addEventListener("click",function(t){if(wc)return t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.stopImmediatePropagation&&t.stopImmediatePropagation(),wc=!1,!1},!0);var vo=function(e){if(yt){e=e.touches?e.touches[0]:e;var n=B9(e.clientX,e.clientY);if(n){var r={};for(var i in e)e.hasOwnProperty(i)&&(r[i]=e[i]);r.target=r.rootEl=n,r.preventDefault=void 0,r.stopPropagation=void 0,n[gi]._onDragOver(r)}}},D9=function(e){yt&&yt.parentNode[gi]._isOutsideThisEl(e.target)};function Ht(t,e){if(!(t&&t.nodeType&&t.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(t));this.el=t,this.options=e=Ji({},e),t[gi]=this;var n={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(t.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return C2(t,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(o,a){o.setData("Text",a.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:Ht.supportPointer!==!1&&"PointerEvent"in window&&!Ml,emptyInsertThreshold:5};Ll.initializePlugins(this,t,n);for(var r in n)!(r in e)&&(e[r]=n[r]);M2(e);for(var i in this)i.charAt(0)==="_"&&typeof this[i]=="function"&&(this[i]=this[i].bind(this));this.nativeDraggable=e.forceFallback?!1:I9,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?Rn(t,"pointerdown",this._onTapStart):(Rn(t,"mousedown",this._onTapStart),Rn(t,"touchstart",this._onTapStart)),this.nativeDraggable&&(Rn(t,"dragover",this),Rn(t,"dragenter",this)),yc.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),Ji(this,C9())}Ht.prototype={constructor:Ht,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(Ea=null)},_getDirection:function(e,n){return typeof this.options.direction=="function"?this.options.direction.call(this,e,n,yt):this.options.direction},_onTapStart:function(e){if(e.cancelable){var n=this,r=this.el,i=this.options,s=i.preventOnFilter,o=e.type,a=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,l=(a||e).target,c=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,u=i.filter;if(W9(r),!yt&&!(/mousedown|pointerdown/.test(o)&&e.button!==0||i.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&Ml&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=Ni(l,i.draggable,r,!1),!(l&&l.animated)&&gc!==l)){if(ya=ri(l),Pl=ri(l,i.draggable),typeof u=="function"){if(u.call(this,e,l,this)){Zr({sortable:n,rootEl:c,name:"filter",targetEl:l,toEl:r,fromEl:r}),ii("filter",n,{evt:e}),s&&e.cancelable&&e.preventDefault();return}}else if(u&&(u=u.split(",").some(function(f){if(f=Ni(c,f.trim(),r,!1),f)return Zr({sortable:n,rootEl:f,name:"filter",targetEl:l,fromEl:r,toEl:r}),ii("filter",n,{evt:e}),!0}),u)){s&&e.cancelable&&e.preventDefault();return}i.handle&&!Ni(c,i.handle,r,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(e,n,r){var i=this,s=i.el,o=i.options,a=s.ownerDocument,l;if(r&&!yt&&r.parentNode===s){var c=br(r);if(zn=s,yt=r,ir=yt.parentNode,wo=yt.nextSibling,gc=r,bc=o.group,Ht.dragged=yt,yo={target:yt,clientX:(n||e).clientX,clientY:(n||e).clientY},S2=yo.clientX-c.left,T2=yo.clientY-c.top,this._lastX=(n||e).clientX,this._lastY=(n||e).clientY,yt.style["will-change"]="all",l=function(){if(ii("delayEnded",i,{evt:e}),Ht.eventCanceled){i._onDrop();return}i._disableDelayedDragEvents(),!f2&&i.nativeDraggable&&(yt.draggable=!0),i._triggerDragStart(e,n),Zr({sortable:i,name:"choose",originalEvent:e}),Ur(yt,o.chosenClass,!0)},o.ignore.split(",").forEach(function(u){_2(yt,u.trim(),Gf)}),Rn(a,"dragover",vo),Rn(a,"mousemove",vo),Rn(a,"touchmove",vo),Rn(a,"mouseup",i._onDrop),Rn(a,"touchend",i._onDrop),Rn(a,"touchcancel",i._onDrop),f2&&this.nativeDraggable&&(this.options.touchStartThreshold=4,yt.draggable=!0),ii("delayStart",this,{evt:e}),o.delay&&(!o.delayOnTouchOnly||n)&&(!this.nativeDraggable||!(Cl||Ts))){if(Ht.eventCanceled){this._onDrop();return}Rn(a,"mouseup",i._disableDelayedDrag),Rn(a,"touchend",i._disableDelayedDrag),Rn(a,"touchcancel",i._disableDelayedDrag),Rn(a,"mousemove",i._delayedDragTouchMoveHandler),Rn(a,"touchmove",i._delayedDragTouchMoveHandler),o.supportPointer&&Rn(a,"pointermove",i._delayedDragTouchMoveHandler),i._dragStartTimer=setTimeout(l,o.delay)}else l()}},_delayedDragTouchMoveHandler:function(e){var n=e.touches?e.touches[0]:e;Math.max(Math.abs(n.clientX-this._lastX),Math.abs(n.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){yt&&Gf(yt),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;yn(e,"mouseup",this._disableDelayedDrag),yn(e,"touchend",this._disableDelayedDrag),yn(e,"touchcancel",this._disableDelayedDrag),yn(e,"mousemove",this._delayedDragTouchMoveHandler),yn(e,"touchmove",this._delayedDragTouchMoveHandler),yn(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,n){n=n||e.pointerType=="touch"&&e,!this.nativeDraggable||n?this.options.supportPointer?Rn(document,"pointermove",this._onTouchMove):n?Rn(document,"touchmove",this._onTouchMove):Rn(document,"mousemove",this._onTouchMove):(Rn(yt,"dragend",this),Rn(zn,"dragstart",this._onDragStart));try{document.selection?Cc(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,n){if(va=!1,zn&&yt){ii("dragStarted",this,{evt:n}),this.nativeDraggable&&Rn(document,"dragover",D9);var r=this.options;!e&&Ur(yt,r.dragClass,!1),Ur(yt,r.ghostClass,!0),Ht.active=this,e&&this._appendGhost(),Zr({sortable:this,name:"start",originalEvent:n})}else this._nulling()},_emulateDragOver:function(){if(Vi){this._lastX=Vi.clientX,this._lastY=Vi.clientY,R2();for(var e=document.elementFromPoint(Vi.clientX,Vi.clientY),n=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(Vi.clientX,Vi.clientY),e!==n);)n=e;if(yt.parentNode[gi]._isOutsideThisEl(e),n)do{if(n[gi]){var r=void 0;if(r=n[gi]._onDragOver({clientX:Vi.clientX,clientY:Vi.clientY,target:e,rootEl:n}),r&&!this.options.dragoverBubble)break}e=n}while(n=n.parentNode);L2()}},_onTouchMove:function(e){if(yo){var n=this.options,r=n.fallbackTolerance,i=n.fallbackOffset,s=e.touches?e.touches[0]:e,o=Qt&&ga(Qt,!0),a=Qt&&o&&o.a,l=Qt&&o&&o.d,c=kc&&Wr&&b2(Wr),u=(s.clientX-yo.clientX+i.x)/(a||1)+(c?c[0]-Uf[0]:0)/(a||1),f=(s.clientY-yo.clientY+i.y)/(l||1)+(c?c[1]-Uf[1]:0)/(l||1);if(!Ht.active&&!va){if(r&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))<r)return;this._onDragStart(e,!0)}if(Qt){o?(o.e+=u-(Hf||0),o.f+=f-(xf||0)):o={a:1,b:0,c:0,d:1,e:u,f};var g="matrix(".concat(o.a,",").concat(o.b,",").concat(o.c,",").concat(o.d,",").concat(o.e,",").concat(o.f,")");Ut(Qt,"webkitTransform",g),Ut(Qt,"mozTransform",g),Ut(Qt,"msTransform",g),Ut(Qt,"transform",g),Hf=u,xf=f,Vi=s}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!Qt){var e=this.options.fallbackOnBody?document.body:zn,n=br(yt,!0,kc,!0,e),r=this.options;if(kc){for(Wr=e;Ut(Wr,"position")==="static"&&Ut(Wr,"transform")==="none"&&Wr!==document;)Wr=Wr.parentNode;Wr!==document.body&&Wr!==document.documentElement?(Wr===document&&(Wr=Qi()),n.top+=Wr.scrollTop,n.left+=Wr.scrollLeft):Wr=Qi(),Uf=b2(Wr)}Qt=yt.cloneNode(!0),Ur(Qt,r.ghostClass,!1),Ur(Qt,r.fallbackClass,!0),Ur(Qt,r.dragClass,!0),Ut(Qt,"transition",""),Ut(Qt,"transform",""),Ut(Qt,"box-sizing","border-box"),Ut(Qt,"margin",0),Ut(Qt,"top",n.top),Ut(Qt,"left",n.left),Ut(Qt,"width",n.width),Ut(Qt,"height",n.height),Ut(Qt,"opacity","0.8"),Ut(Qt,"position",kc?"absolute":"fixed"),Ut(Qt,"zIndex","100000"),Ut(Qt,"pointerEvents","none"),Ht.ghost=Qt,e.appendChild(Qt),Ut(Qt,"transform-origin",S2/parseInt(Qt.style.width)*100+"% "+T2/parseInt(Qt.style.height)*100+"%")}},_onDragStart:function(e,n){var r=this,i=e.dataTransfer,s=r.options;if(ii("dragStart",this,{evt:e}),Ht.eventCanceled){this._onDrop();return}ii("setupClone",this),Ht.eventCanceled||(Jn=v2(yt),Jn.removeAttribute("id"),Jn.draggable=!1,Jn.style["will-change"]="",this._hideClone(),Ur(Jn,this.options.chosenClass,!1),Ht.clone=Jn),r.cloneId=Cc(function(){ii("clone",r),!Ht.eventCanceled&&(r.options.removeCloneOnHide||zn.insertBefore(Jn,yt),r._hideClone(),Zr({sortable:r,name:"clone"}))}),!n&&Ur(yt,s.dragClass,!0),n?(wc=!0,r._loopId=setInterval(r._emulateDragOver,50)):(yn(document,"mouseup",r._onDrop),yn(document,"touchend",r._onDrop),yn(document,"touchcancel",r._onDrop),i&&(i.effectAllowed="move",s.setData&&s.setData.call(r,i,yt)),Rn(document,"drop",r),Ut(yt,"transform","translateZ(0)")),va=!0,r._dragStartId=Cc(r._dragStarted.bind(r,n,e)),Rn(document,"selectstart",r),Il=!0,Ml&&Ut(document.body,"user-select","none")},_onDragOver:function(e){var n=this.el,r=e.target,i,s,o,a=this.options,l=a.group,c=Ht.active,u=bc===l,f=a.sort,g=Nr||c,v,_=this,b=!1;if(Wf)return;function y(K,J){ii(K,_,Zi({evt:e,isOwner:u,axis:v?"vertical":"horizontal",revert:o,dragRect:i,targetRect:s,canSort:f,fromSortable:g,target:r,completed:m,onMove:function(B,M){return Ac(zn,n,yt,i,B,br(B),e,M)},changed:w},J))}function p(){y("dragOverAnimationCapture"),_.captureAnimationState(),_!==g&&g.captureAnimationState()}function m(K){return y("dragOverCompleted",{insertion:K}),K&&(u?c._hideClone():c._showClone(_),_!==g&&(Ur(yt,Nr?Nr.options.ghostClass:c.options.ghostClass,!1),Ur(yt,a.ghostClass,!0)),Nr!==_&&_!==Ht.active?Nr=_:_===Ht.active&&Nr&&(Nr=null),g===_&&(_._ignoreWhileAnimating=r),_.animateAll(function(){y("dragOverAnimationComplete"),_._ignoreWhileAnimating=null}),_!==g&&(g.animateAll(),g._ignoreWhileAnimating=null)),(r===yt&&!yt.animated||r===n&&!r.animated)&&(Ea=null),!a.dragoverBubble&&!e.rootEl&&r!==document&&(yt.parentNode[gi]._isOutsideThisEl(e.target),!K&&vo(e)),!a.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),b=!0}function w(){bi=ri(yt),Us=ri(yt,a.draggable),Zr({sortable:_,name:"change",toEl:n,newIndex:bi,newDraggableIndex:Us,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),r=Ni(r,a.draggable,n,!0),y("dragOver"),Ht.eventCanceled)return b;if(yt.contains(e.target)||r.animated&&r.animatingX&&r.animatingY||_._ignoreWhileAnimating===r)return m(!1);if(wc=!1,c&&!a.disabled&&(u?f||(o=ir!==zn):Nr===this||(this.lastPutMode=bc.checkPull(this,c,yt,e))&&l.checkPut(this,c,yt,e))){if(v=this._getDirection(e,r)==="vertical",i=br(yt),y("dragOverValid"),Ht.eventCanceled)return b;if(o)return ir=zn,p(),this._hideClone(),y("revert"),Ht.eventCanceled||(wo?zn.insertBefore(yt,wo):zn.appendChild(yt)),m(!0);var C=$f(n,a.draggable);if(!C||V9(e,v,this)&&!C.animated){if(C===yt)return m(!1);if(C&&n===e.target&&(r=C),r&&(s=br(r)),Ac(zn,n,yt,i,r,s,e,!!r)!==!1)return p(),C&&C.nextSibling?n.insertBefore(yt,C.nextSibling):n.appendChild(yt),ir=n,w(),m(!0)}else if(C&&N9(e,v,this)){var h=ba(n,0,a,!0);if(h===yt)return m(!1);if(r=h,s=br(r),Ac(zn,n,yt,i,r,s,e,!1)!==!1)return p(),n.insertBefore(yt,h),ir=n,w(),m(!0)}else if(r.parentNode===n){s=br(r);var A=0,L,$=yt.parentNode!==n,P=!O9(yt.animated&&yt.toRect||i,r.animated&&r.toRect||s,v),I=v?"top":"left",x=g2(r,"top","top")||g2(yt,"top","top"),ae=x?x.scrollTop:void 0;Ea!==r&&(L=s[I],Bl=!1,vc=!P&&a.invertSwap||$),A=H9(e,r,s,v,P?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,vc,Ea===r);var V;if(A!==0){var E=ri(yt);do E-=A,V=ir.children[E];while(V&&(Ut(V,"display")==="none"||V===Qt))}if(A===0||V===r)return m(!1);Ea=r,Ol=A;var F=r.nextElementSibling,N=!1;N=A===1;var Y=Ac(zn,n,yt,i,r,s,e,N);if(Y!==!1)return(Y===1||Y===-1)&&(N=Y===1),Wf=!0,setTimeout($9,30),p(),N&&!F?n.appendChild(yt):r.parentNode.insertBefore(yt,N?F:r),x&&y2(x,0,ae-x.scrollTop),ir=yt.parentNode,L!==void 0&&!vc&&(Ec=Math.abs(L-br(r)[I])),w(),m(!0)}if(n.contains(yt))return m(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){yn(document,"mousemove",this._onTouchMove),yn(document,"touchmove",this._onTouchMove),yn(document,"pointermove",this._onTouchMove),yn(document,"dragover",vo),yn(document,"mousemove",vo),yn(document,"touchmove",vo)},_offUpEvents:function(){var e=this.el.ownerDocument;yn(e,"mouseup",this._onDrop),yn(e,"touchend",this._onDrop),yn(e,"pointerup",this._onDrop),yn(e,"touchcancel",this._onDrop),yn(document,"selectstart",this)},_onDrop:function(e){var n=this.el,r=this.options;if(bi=ri(yt),Us=ri(yt,r.draggable),ii("drop",this,{evt:e}),ir=yt&&yt.parentNode,bi=ri(yt),Us=ri(yt,r.draggable),Ht.eventCanceled){this._nulling();return}va=!1,vc=!1,Bl=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),jf(this.cloneId),jf(this._dragStartId),this.nativeDraggable&&(yn(document,"drop",this),yn(n,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Ml&&Ut(document.body,"user-select",""),Ut(yt,"transform",""),e&&(Il&&(e.cancelable&&e.preventDefault(),!r.dropBubble&&e.stopPropagation()),Qt&&Qt.parentNode&&Qt.parentNode.removeChild(Qt),(zn===ir||Nr&&Nr.lastPutMode!=="clone")&&Jn&&Jn.parentNode&&Jn.parentNode.removeChild(Jn),yt&&(this.nativeDraggable&&yn(yt,"dragend",this),Gf(yt),yt.style["will-change"]="",Il&&!va&&Ur(yt,Nr?Nr.options.ghostClass:this.options.ghostClass,!1),Ur(yt,this.options.chosenClass,!1),Zr({sortable:this,name:"unchoose",toEl:ir,newIndex:null,newDraggableIndex:null,originalEvent:e}),zn!==ir?(bi>=0&&(Zr({rootEl:ir,name:"add",toEl:ir,fromEl:zn,originalEvent:e}),Zr({sortable:this,name:"remove",toEl:ir,originalEvent:e}),Zr({rootEl:ir,name:"sort",toEl:ir,fromEl:zn,originalEvent:e}),Zr({sortable:this,name:"sort",toEl:ir,originalEvent:e})),Nr&&Nr.save()):bi!==ya&&bi>=0&&(Zr({sortable:this,name:"update",toEl:ir,originalEvent:e}),Zr({sortable:this,name:"sort",toEl:ir,originalEvent:e})),Ht.active&&((bi==null||bi===-1)&&(bi=ya,Us=Pl),Zr({sortable:this,name:"end",toEl:ir,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){ii("nulling",this),zn=yt=ir=Qt=wo=Jn=gc=xs=yo=Vi=Il=bi=Us=ya=Pl=Ea=Ol=Nr=bc=Ht.dragged=Ht.ghost=Ht.clone=Ht.active=null,Sc.forEach(function(e){e.checked=!0}),Sc.length=Hf=xf=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":yt&&(this._onDragOver(e),F9(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],n,r=this.el.children,i=0,s=r.length,o=this.options;i<s;i++)n=r[i],Ni(n,o.draggable,this.el,!1)&&e.push(n.getAttribute(o.dataIdAttr)||U9(n));return e},sort:function(e,n){var r={},i=this.el;this.toArray().forEach(function(s,o){var a=i.children[o];Ni(a,this.options.draggable,i,!1)&&(r[s]=a)},this),n&&this.captureAnimationState(),e.forEach(function(s){r[s]&&(i.removeChild(r[s]),i.appendChild(r[s]))}),n&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,n){return Ni(e,n||this.options.draggable,this.el,!1)},option:function(e,n){var r=this.options;if(n===void 0)return r[e];var i=Ll.modifyOption(this,e,n);typeof i<"u"?r[e]=i:r[e]=n,e==="group"&&M2(r)},destroy:function(){ii("destroy",this);var e=this.el;e[gi]=null,yn(e,"mousedown",this._onTapStart),yn(e,"touchstart",this._onTapStart),yn(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(yn(e,"dragover",this),yn(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(n){n.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),yc.splice(yc.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!xs){if(ii("hideClone",this),Ht.eventCanceled)return;Ut(Jn,"display","none"),this.options.removeCloneOnHide&&Jn.parentNode&&Jn.parentNode.removeChild(Jn),xs=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(xs){if(ii("showClone",this),Ht.eventCanceled)return;yt.parentNode==zn&&!this.options.group.revertClone?zn.insertBefore(Jn,yt):wo?zn.insertBefore(Jn,wo):zn.appendChild(Jn),this.options.group.revertClone&&this.animate(yt,Jn),Ut(Jn,"display",""),xs=!1}}};function F9(t){t.dataTransfer&&(t.dataTransfer.dropEffect="move"),t.cancelable&&t.preventDefault()}function Ac(t,e,n,r,i,s,o,a){var l,c=t[gi],u=c.options.onMove,f;return window.CustomEvent&&!Ts&&!Cl?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=e,l.from=t,l.dragged=n,l.draggedRect=r,l.related=i||e,l.relatedRect=s||br(e),l.willInsertAfter=a,l.originalEvent=o,t.dispatchEvent(l),u&&(f=u.call(c,l,o)),f}function Gf(t){t.draggable=!1}function $9(){Wf=!1}function N9(t,e,n){var r=br(ba(n.el,0,n.options,!0)),i=E2(n.el,n.options,Qt),s=10;return e?t.clientX<i.left-s||t.clientY<r.top&&t.clientX<r.right:t.clientY<i.top-s||t.clientY<r.bottom&&t.clientX<r.left}function V9(t,e,n){var r=br($f(n.el,n.options.draggable)),i=E2(n.el,n.options,Qt),s=10;return e?t.clientX>i.right+s||t.clientY>r.bottom&&t.clientX>r.left:t.clientY>i.bottom+s||t.clientX>r.right&&t.clientY>r.top}function H9(t,e,n,r,i,s,o,a){var l=r?t.clientY:t.clientX,c=r?n.height:n.width,u=r?n.top:n.left,f=r?n.bottom:n.right,g=!1;if(!o){if(a&&Ec<c*i){if(!Bl&&(Ol===1?l>u+c*s/2:l<f-c*s/2)&&(Bl=!0),Bl)g=!0;else if(Ol===1?l<u+Ec:l>f-Ec)return-Ol}else if(l>u+c*(1-i)/2&&l<f-c*(1-i)/2)return x9(e)}return g=g||o,g&&(l<u+c*s/2||l>f-c*s/2)?l>u+c/2?1:-1:0}function x9(t){return ri(yt)<ri(t)?1:-1}function U9(t){for(var e=t.tagName+t.className+t.src+t.href+t.textContent,n=e.length,r=0;n--;)r+=e.charCodeAt(n);return r.toString(36)}function W9(t){Sc.length=0;for(var e=t.getElementsByTagName("input"),n=e.length;n--;){var r=e[n];r.checked&&Sc.push(r)}}function Cc(t){return setTimeout(t,0)}function jf(t){return clearTimeout(t)}Tc&&Rn(document,"touchmove",function(t){(Ht.active||va)&&t.cancelable&&t.preventDefault()}),Ht.utils={on:Rn,off:yn,css:Ut,find:_2,is:function(e,n){return!!Ni(e,n,e,!1)},extend:k9,throttle:w2,closest:Ni,toggleClass:Ur,clone:v2,index:ri,nextTick:Cc,cancelNextTick:jf,detectDirection:C2,getChild:ba},Ht.get=function(t){return t[gi]},Ht.mount=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];e[0].constructor===Array&&(e=e[0]),e.forEach(function(r){if(!r.prototype||!r.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(r));r.utils&&(Ht.utils=Zi(Zi({},Ht.utils),r.utils)),Ll.mount(r)})},Ht.create=function(t,e){return new Ht(t,e)},Ht.version=E9;var wr=[],Dl,zf,Xf=!1,Yf,Kf,Mc,Fl;function G9(){function t(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var e in this)e.charAt(0)==="_"&&typeof this[e]=="function"&&(this[e]=this[e].bind(this))}return t.prototype={dragStarted:function(n){var r=n.originalEvent;this.sortable.nativeDraggable?Rn(document,"dragover",this._handleAutoScroll):this.options.supportPointer?Rn(document,"pointermove",this._handleFallbackAutoScroll):r.touches?Rn(document,"touchmove",this._handleFallbackAutoScroll):Rn(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(n){var r=n.originalEvent;!this.options.dragOverBubble&&!r.rootEl&&this._handleAutoScroll(r)},drop:function(){this.sortable.nativeDraggable?yn(document,"dragover",this._handleAutoScroll):(yn(document,"pointermove",this._handleFallbackAutoScroll),yn(document,"touchmove",this._handleFallbackAutoScroll),yn(document,"mousemove",this._handleFallbackAutoScroll)),P2(),Rc(),A9()},nulling:function(){Mc=zf=Dl=Xf=Fl=Yf=Kf=null,wr.length=0},_handleFallbackAutoScroll:function(n){this._handleAutoScroll(n,!0)},_handleAutoScroll:function(n,r){var i=this,s=(n.touches?n.touches[0]:n).clientX,o=(n.touches?n.touches[0]:n).clientY,a=document.elementFromPoint(s,o);if(Mc=n,r||this.options.forceAutoScrollFallback||Cl||Ts||Ml){qf(n,this.options,a,r);var l=Hs(a,!0);Xf&&(!Fl||s!==Yf||o!==Kf)&&(Fl&&P2(),Fl=setInterval(function(){var c=Hs(document.elementFromPoint(s,o),!0);c!==l&&(l=c,Rc()),qf(n,i.options,c,r)},10),Yf=s,Kf=o)}else{if(!this.options.bubbleScroll||Hs(a,!0)===Qi()){Rc();return}qf(n,this.options,Hs(a,!1),!1)}}},Ji(t,{pluginName:"scroll",initializeByDefault:!0})}function Rc(){wr.forEach(function(t){clearInterval(t.pid)}),wr=[]}function P2(){clearInterval(Fl)}var qf=w2(function(t,e,n,r){if(e.scroll){var i=(t.touches?t.touches[0]:t).clientX,s=(t.touches?t.touches[0]:t).clientY,o=e.scrollSensitivity,a=e.scrollSpeed,l=Qi(),c=!1,u;zf!==n&&(zf=n,Rc(),Dl=e.scroll,u=e.scrollFn,Dl===!0&&(Dl=Hs(n,!0)));var f=0,g=Dl;do{var v=g,_=br(v),b=_.top,y=_.bottom,p=_.left,m=_.right,w=_.width,C=_.height,h=void 0,A=void 0,L=v.scrollWidth,$=v.scrollHeight,P=Ut(v),I=v.scrollLeft,x=v.scrollTop;v===l?(h=w<L&&(P.overflowX==="auto"||P.overflowX==="scroll"||P.overflowX==="visible"),A=C<$&&(P.overflowY==="auto"||P.overflowY==="scroll"||P.overflowY==="visible")):(h=w<L&&(P.overflowX==="auto"||P.overflowX==="scroll"),A=C<$&&(P.overflowY==="auto"||P.overflowY==="scroll"));var ae=h&&(Math.abs(m-i)<=o&&I+w<L)-(Math.abs(p-i)<=o&&!!I),V=A&&(Math.abs(y-s)<=o&&x+C<$)-(Math.abs(b-s)<=o&&!!x);if(!wr[f])for(var E=0;E<=f;E++)wr[E]||(wr[E]={});(wr[f].vx!=ae||wr[f].vy!=V||wr[f].el!==v)&&(wr[f].el=v,wr[f].vx=ae,wr[f].vy=V,clearInterval(wr[f].pid),(ae!=0||V!=0)&&(c=!0,wr[f].pid=setInterval((function(){r&&this.layer===0&&Ht.active._onTouchMove(Mc);var F=wr[this.layer].vy?wr[this.layer].vy*a:0,N=wr[this.layer].vx?wr[this.layer].vx*a:0;typeof u=="function"&&u.call(Ht.dragged.parentNode[gi],N,F,t,Mc,wr[this.layer].el)!=="continue"||y2(wr[this.layer].el,N,F)}).bind({layer:f}),24))),f++}while(e.bubbleScroll&&g!==l&&(g=Hs(g,!1)));Xf=c}},30),I2=function(e){var n=e.originalEvent,r=e.putSortable,i=e.dragEl,s=e.activeSortable,o=e.dispatchSortableEvent,a=e.hideGhostForTarget,l=e.unhideGhostForTarget;if(n){var c=r||s;a();var u=n.changedTouches&&n.changedTouches.length?n.changedTouches[0]:n,f=document.elementFromPoint(u.clientX,u.clientY);l(),c&&!c.el.contains(f)&&(o("spill"),this.onSpill({dragEl:i,putSortable:r}))}};function Zf(){}Zf.prototype={startIndex:null,dragStart:function(e){var n=e.oldDraggableIndex;this.startIndex=n},onSpill:function(e){var n=e.dragEl,r=e.putSortable;this.sortable.captureAnimationState(),r&&r.captureAnimationState();var i=ba(this.sortable.el,this.startIndex,this.options);i?this.sortable.el.insertBefore(n,i):this.sortable.el.appendChild(n),this.sortable.animateAll(),r&&r.animateAll()},drop:I2},Ji(Zf,{pluginName:"revertOnSpill"});function Jf(){}Jf.prototype={onSpill:function(e){var n=e.dragEl,r=e.putSortable,i=r||this.sortable;i.captureAnimationState(),n.parentNode&&n.parentNode.removeChild(n),i.animateAll()},drop:I2},Ji(Jf,{pluginName:"removeOnSpill"});var ki;function j9(){function t(){this.defaults={swapClass:"sortable-swap-highlight"}}return t.prototype={dragStart:function(n){var r=n.dragEl;ki=r},dragOverValid:function(n){var r=n.completed,i=n.target,s=n.onMove,o=n.activeSortable,a=n.changed,l=n.cancel;if(o.options.swap){var c=this.sortable.el,u=this.options;if(i&&i!==c){var f=ki;s(i)!==!1?(Ur(i,u.swapClass,!0),ki=i):ki=null,f&&f!==ki&&Ur(f,u.swapClass,!1)}a(),r(!0),l()}},drop:function(n){var r=n.activeSortable,i=n.putSortable,s=n.dragEl,o=i||this.sortable,a=this.options;ki&&Ur(ki,a.swapClass,!1),ki&&(a.swap||i&&i.options.swap)&&s!==ki&&(o.captureAnimationState(),o!==r&&r.captureAnimationState(),z9(s,ki),o.animateAll(),o!==r&&r.animateAll())},nulling:function(){ki=null}},Ji(t,{pluginName:"swap",eventProperties:function(){return{swapItem:ki}}})}function z9(t,e){var n=t.parentNode,r=e.parentNode,i,s;!n||!r||n.isEqualNode(e)||r.isEqualNode(t)||(i=ri(t),s=ri(e),n.isEqualNode(r)&&i<s&&s++,n.insertBefore(e,n.children[i]),r.insertBefore(t,r.children[s]))}Ht.mount(new G9),Ht.mount(Jf,Zf);function O2(t,e,n){const r=t.slice();return r[13]=e[n],r[14]=e,r[15]=n,r}function B2(t,e){let n,r=e[13].action+"",i,s,o,a,l,c,u,f;function g(){e[9].call(a,e[14],e[15])}return{key:t,first:null,c(){n=_e("div"),i=Nt(r),s=me(),o=_e("div"),a=_e("input"),l=me(),ie(a,"type","checkbox"),ie(o,"class","disable-sort"),ie(n,"class","sortable-list-item"),ie(n,"data-id",c=e[13].action),this.first=n},m(v,_){he(v,n,_),oe(n,i),oe(n,s),oe(n,o),oe(o,a),a.checked=e[13].enabled,oe(n,l),u||(f=[Xe(a,"change",g),Xe(a,"change",e[4])],u=!0)},p(v,_){e=v,_&2&&r!==(r=e[13].action+"")&&cn(i,r),_&2&&(a.checked=e[13].enabled),_&2&&c!==(c=e[13].action)&&ie(n,"data-id",c)},d(v){v&&de(n),u=!1,vn(f)}}}function X9(t){let e,n,r,i,s,o,a,l,c,u,f,g=[],v=new Map,_,b,y;r=new kt({props:{path:mg}}),o=new kt({props:{path:wg}}),o.$on("click",t[8]),c=new kt({props:{path:Zo}}),c.$on("click",t[3]);let p=Jr(t[1]);const m=w=>w[13].action;for(let w=0;w<p.length;w+=1){let C=O2(t,p,w),h=m(C);v.set(h,g[w]=B2(h,C))}return{c(){e=_e("div"),n=_e("button"),ye(r.$$.fragment),i=me(),s=_e("button"),ye(o.$$.fragment),a=me(),l=_e("button"),ye(c.$$.fragment),u=me(),f=_e("div");for(let w=0;w<g.length;w+=1)g[w].c();ie(n,"title","Select all"),ie(n,"class","m-r-s"),ie(s,"title","Remove all"),ie(s,"class","m-r-s"),ie(l,"title","Restore defaults"),ie(e,"class","sortable-list-icons"),ie(f,"class","sortable-list-container")},m(w,C){he(w,e,C),oe(e,n),be(r,n,null),oe(e,i),oe(e,s),be(o,s,null),oe(e,a),oe(e,l),be(c,l,null),he(w,u,C),he(w,f,C);for(let h=0;h<g.length;h+=1)g[h]&&g[h].m(f,null);t[10](f),_=!0,b||(y=Xe(n,"click",t[7]),b=!0)},p(w,[C]){C&18&&(p=Jr(w[1]),g=Ks(g,C,m,1,w,p,v,f,Ba,B2,null,O2))},i(w){_||(Z(r.$$.fragment,w),Z(o.$$.fragment,w),Z(c.$$.fragment,w),_=!0)},o(w){ne(r.$$.fragment,w),ne(o.$$.fragment,w),ne(c.$$.fragment,w),_=!1},d(w){w&&(de(e),de(u),de(f)),we(r),we(o),we(c);for(let C=0;C<g.length;C+=1)g[C].d();t[10](null),b=!1,y()}}}function Y9(t,e,n){let{actionList:r}=e,{defaultActions:i}=e,s,o,a=[];Oa(()=>{const y=[...i.entries()],p=new Set,m=[];for(let w=0,{length:C}=r;w<C;w+=1){const{action:h,enabled:A}=r[w];i.has(h)&&(m.push({action:h,enabled:A}),p.add(h))}for(let w=0,{length:C}=y;w<C;w+=1){const[h,A]=y[w];p.has(h)||(m.push({action:h,enabled:A}),p.add(h))}n(1,a=m);try{Ht.mount(new j9)}catch{}return o=Ht.create(s,{swap:!0,swapClass:"swap",animation:150,filter:".disable-sort",store:{get:()=>[...p],set:u}}),()=>{o.destroy()}});function l(y){const p=f();n(1,a=p.map(m=>({action:m.action,enabled:y}))),n(5,r=a)}function c(){const y=[],p=[...i.entries()];for(let m=0,{length:w}=p;m<w;m+=1){const[C,h]=p[m];y.push({action:C,enabled:h})}n(1,a=y),n(5,r=y),o.sort([...i.keys()],!1)}function u(){n(5,r=f())}function f(){const y=o.toArray();return a.slice().sort((p,m)=>y.indexOf(p.action)-y.indexOf(m.action))}const g=()=>l(!0),v=()=>l(!1);function _(y,p){y[p].enabled=this.checked,n(1,a)}function b(y){Vt[y?"unshift":"push"](()=>{s=y,n(0,s)})}return t.$$set=y=>{"actionList"in y&&n(5,r=y.actionList),"defaultActions"in y&&n(6,i=y.defaultActions)},[s,a,l,c,u,r,i,g,v,_,b]}class Qf extends Dn{constructor(e){super(),Bn(this,e,Y9,X9,Cn,{actionList:5,defaultActions:6})}}const{Map:K9}=$c;function D2(t,e,n){const r=t.slice();return r[148]=e[n],r}function F2(t){let e,n;return e=new Vn({props:{label:"Enable auto reload",helpText:"If enabled the reader will attempt to reload last used files from filesystem automatically without the need for opening the side menu",targetStore$:_t.readerEnableAutoReload$}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function q9(t){let e,n;return e=new Vn({props:{label:"Enable filesystem api",helpText:"If enabled the reader will use the filsystem api for storing and reading files",targetStore$:_t.readerEnableFilesystemApi$}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function $2(t){let e,n;return e=new Vn({props:{label:"Enable tracker pause",helpText:"If enabled user triggered changes to the playback position (e. g. click action, player controls etc.) will auto pause and unpause the reading tracker",targetStore$:_t.readerEnableTrackerAutoPause$}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function N2(t){let e,n;return e=new Vn({props:{label:"Prevent action on selection",helpText:"If enabled click/hold will not execute any action / open the reader menu in case any text is selected",targetStore$:_t.readerPreventActionOnSelection$}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function V2(t){let e,n;return e=new Vn({props:{label:"Enable menu target",helpText:"If enabled keybindings will prioritize the active menu subtitle over the current played one",targetStore$:_t.readerEnableMenuTarget$}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function H2(t){let e,n,r,i;return e=new Ir({props:{label:"Continuous scroll",helpText:t[11],targetStore$:t[57],options:t[43]}}),r=new Ir({props:{label:"Scroll behavior",helpText:"Determines the used scroll animation",targetStore$:_t.readerScrollBehavior$,options:t[44]}}),{c(){ye(e.$$.fragment),n=me(),ye(r.$$.fragment)},m(s,o){be(e,s,o),he(s,n,o),be(r,s,o),i=!0},p(s,o){const a={};o[0]&2048&&(a.helpText=s[11]),e.$set(a)},i(s){i||(Z(e.$$.fragment,s),Z(r.$$.fragment,s),i=!0)},o(s){ne(e.$$.fragment,s),ne(r.$$.fragment,s),i=!1},d(s){s&&de(n),we(e,s),we(r,s)}}}function x2(t){let e,n;return e=new Ir({props:{label:"Click Action",helpText:"Determines the action executed when clicking on book text - requires matched book/line and subtitle/audio file",targetStore$:_t.readerClickAction$,options:t[42]}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},p:wt,i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function U2(t){let e,n;return e=new Ir({props:{label:"Menu pause",helpText:"Determines if playback is automatilcally paused when opening the reader menu or not",targetStore$:_t.readerMenuPauseMode$,options:t[46]}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},p:wt,i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function W2(t){let e,n;return e=new qr({props:{label:"Menu open time",helpText:"# of ms to hold down on book text to open the reader menu - requires matched book/line. If released earlier the configured click action is executed instead",targetStore$:_t.readerMenuOpenTime$,min:100}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function Z9(t){let e,n,r,i,s,o,a,l,c,u,f,g,v,_,b,y,p,m,w,C,h,A;e=new a2({props:{label:"Line highlight",targetStore$:t[52]}}),e.$on("change",t[97]),e.$on("reset",t[97]),r=new a2({props:{label:"Line text color",targetStore$:t[53]}}),r.$on("change",t[97]),r.$on("reset",t[97]),s=new Vn({props:{label:"Enable line highlight",helpText:"If enabled active subtitles will be highlighted in the reader - requires matched book/line and subtitle/audio file",targetStore$:t[54]}}),a=new Vn({props:{label:"Enable line text highlight",helpText:"If enabled text of active subtitles will be highlighted in the reader - requires matched book/line and subtitle/audio file",targetStore$:t[55]}});let L=t[12]&&F2(),$=t[41]&&q9();f=new Vn({props:{label:"Enable auto scroll",helpText:"If enabled the reader will automatically scroll to active subtitles - requires matched book/line and subtitle/audio file",targetStore$:t[56]}});let P=t[13]&&$2(),I=(t[14]!==Re.NONE||t[15]!==tr.DISABLED)&&N2(),x=t[15]!==tr.DISABLED&&V2(),ae=t[13]&&H2(t),V=t[15]!==tr.CLICK&&x2(t);m=new Ir({props:{label:"Menu mode",helpText:"Determines the action for opening the reader menu - requires matched book/line",targetStore$:t[59],options:t[45]}});let E=t[15]!==tr.DISABLED&&U2(t),F=t[15]===tr.HOLD&&W2();return{c(){ye(e.$$.fragment),n=me(),ye(r.$$.fragment),i=me(),ye(s.$$.fragment),o=me(),ye(a.$$.fragment),l=me(),L&&L.c(),c=me(),$&&$.c(),u=me(),ye(f.$$.fragment),g=me(),P&&P.c(),v=me(),I&&I.c(),_=me(),x&&x.c(),b=me(),ae&&ae.c(),y=me(),V&&V.c(),p=me(),ye(m.$$.fragment),w=me(),E&&E.c(),C=me(),F&&F.c(),h=Fr()},m(N,Y){be(e,N,Y),he(N,n,Y),be(r,N,Y),he(N,i,Y),be(s,N,Y),he(N,o,Y),be(a,N,Y),he(N,l,Y),L&&L.m(N,Y),he(N,c,Y),$&&$.m(N,Y),he(N,u,Y),be(f,N,Y),he(N,g,Y),P&&P.m(N,Y),he(N,v,Y),I&&I.m(N,Y),he(N,_,Y),x&&x.m(N,Y),he(N,b,Y),ae&&ae.m(N,Y),he(N,y,Y),V&&V.m(N,Y),he(N,p,Y),be(m,N,Y),he(N,w,Y),E&&E.m(N,Y),he(N,C,Y),F&&F.m(N,Y),he(N,h,Y),A=!0},p(N,Y){N[12]?L?Y[0]&4096&&Z(L,1):(L=F2(),L.c(),Z(L,1),L.m(c.parentNode,c)):L&&(jt(),ne(L,1,1,()=>{L=null}),zt()),N[13]?P?Y[0]&8192&&Z(P,1):(P=$2(),P.c(),Z(P,1),P.m(v.parentNode,v)):P&&(jt(),ne(P,1,1,()=>{P=null}),zt()),N[14]!==Re.NONE||N[15]!==tr.DISABLED?I?Y[0]&49152&&Z(I,1):(I=N2(),I.c(),Z(I,1),I.m(_.parentNode,_)):I&&(jt(),ne(I,1,1,()=>{I=null}),zt()),N[15]!==tr.DISABLED?x?Y[0]&32768&&Z(x,1):(x=V2(),x.c(),Z(x,1),x.m(b.parentNode,b)):x&&(jt(),ne(x,1,1,()=>{x=null}),zt()),N[13]?ae?(ae.p(N,Y),Y[0]&8192&&Z(ae,1)):(ae=H2(N),ae.c(),Z(ae,1),ae.m(y.parentNode,y)):ae&&(jt(),ne(ae,1,1,()=>{ae=null}),zt()),N[15]!==tr.CLICK?V?(V.p(N,Y),Y[0]&32768&&Z(V,1)):(V=x2(N),V.c(),Z(V,1),V.m(p.parentNode,p)):V&&(jt(),ne(V,1,1,()=>{V=null}),zt()),N[15]!==tr.DISABLED?E?(E.p(N,Y),Y[0]&32768&&Z(E,1)):(E=U2(N),E.c(),Z(E,1),E.m(C.parentNode,C)):E&&(jt(),ne(E,1,1,()=>{E=null}),zt()),N[15]===tr.HOLD?F?Y[0]&32768&&Z(F,1):(F=W2(),F.c(),Z(F,1),F.m(h.parentNode,h)):F&&(jt(),ne(F,1,1,()=>{F=null}),zt())},i(N){A||(Z(e.$$.fragment,N),Z(r.$$.fragment,N),Z(s.$$.fragment,N),Z(a.$$.fragment,N),Z(L),Z($),Z(f.$$.fragment,N),Z(P),Z(I),Z(x),Z(ae),Z(V),Z(m.$$.fragment,N),Z(E),Z(F),A=!0)},o(N){ne(e.$$.fragment,N),ne(r.$$.fragment,N),ne(s.$$.fragment,N),ne(a.$$.fragment,N),ne(L),ne($),ne(f.$$.fragment,N),ne(P),ne(I),ne(x),ne(ae),ne(V),ne(m.$$.fragment,N),ne(E),ne(F),A=!1},d(N){N&&(de(n),de(i),de(o),de(l),de(c),de(u),de(g),de(v),de(_),de(b),de(y),de(p),de(w),de(C),de(h)),we(e,N),we(r,N),we(s,N),we(a,N),L&&L.d(N),$&&$.d(N),we(f,N),P&&P.d(N),I&&I.d(N),x&&x.d(N),ae&&ae.d(N),V&&V.d(N),we(m,N),E&&E.d(N),F&&F.d(N)}}}function G2(t){let e,n;return e=new Vn({props:{label:"Prevent action on selection",helpText:"If enabled click/hold will not execute any action / open the subtitle action list in case any text is selected",targetStore$:_t.subtitlePreventActionOnSelection$}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function j2(t){let e,n;return e=new qr({props:{label:"Visibility toggle time",helpText:"# of ms to hold down to toggle the action list. If released earlier the configured click action is executed instead",targetStore$:_t.subtitlesActionsVisibilityTime$,min:100}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function z2(t){let e,n;return e=new pc({props:{label:"Font",helpText:"Font name to use for the subtitle list - needs to be installed on the device or via reader",targetStore$:_t.subtitlesFontFamily$}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function X2(t){let e,n;return e=new qr({props:{label:"Font size",helpText:"Font size to use for the subtitle list",targetStore$:_t.subtitlesFontSize$,min:1,step:1}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function Y2(t){let e,n;return e=new qr({props:{label:"Line height",helpText:"Line height to use for the subtitle list",targetStore$:_t.subtitlesLineHeight$,min:1,step:.05}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function J9(t){let e,n,r,i,s,o,a,l,c,u,f,g,v,_,b,y,p,m,w,C,h,A,L,$;e=new Vn({props:{label:"Persist subtitles",helpText:"If enabled loading subtitles or changes to them will be stored locally in your browser and can be used as data fallback/source. May takes more storage quota and increased update times",targetStore$:t[60]}}),e.$on("change",t[98]),r=new Vn({props:{label:"Enable auto scroll",helpText:"If enabled the subtitle list will automatically scroll to active subtitles",targetStore$:_t.subtitlesEnableAutoScroll$}}),s=new Vn({props:{label:"Copy font",helpText:"If enabled the configured font of the reader is used for the subtitle list",targetStore$:t[61]}}),a=new Vn({props:{label:"Copy font size",helpText:"If enabled the configured font size of the reader is used for the subtitle list",targetStore$:t[62]}}),c=new Vn({props:{label:"Copy line height",helpText:"If enabled the configured line height of the reader is used for the subtitle list",targetStore$:t[63]}});let P=(t[16]!==Re.NONE||t[17]===Tr.TOGGLE)&&G2();g=new Ir({props:{label:"Click Action",helpText:"Determines the action executed when clicking on a subtitle",targetStore$:t[64],options:t[42]}}),_=new Ir({props:{label:"Actions visibility",helpText:"Determines the conditions for showing actions in the subtitle list",targetStore$:t[65],options:t[47]}});let I=t[17]===Tr.TOGGLE&&j2();p=new qr({props:{label:"Global start padding",helpText:"# of ms by which all subtitle start times are shifted",disabled:!!t[18],targetStore$:t[66],blurHandler:t[99]}}),w=new qr({props:{label:"Global end padding",helpText:"# of ms by which all subtitle end times are shifted",disabled:!!t[18],targetStore$:t[67],blurHandler:t[99]}});let x=!t[19]&&z2(),ae=!t[20]&&X2(),V=!t[21]&&Y2();return{c(){ye(e.$$.fragment),n=me(),ye(r.$$.fragment),i=me(),ye(s.$$.fragment),o=me(),ye(a.$$.fragment),l=me(),ye(c.$$.fragment),u=me(),P&&P.c(),f=me(),ye(g.$$.fragment),v=me(),ye(_.$$.fragment),b=me(),I&&I.c(),y=me(),ye(p.$$.fragment),m=me(),ye(w.$$.fragment),C=me(),x&&x.c(),h=me(),ae&&ae.c(),A=me(),V&&V.c(),L=Fr()},m(E,F){be(e,E,F),he(E,n,F),be(r,E,F),he(E,i,F),be(s,E,F),he(E,o,F),be(a,E,F),he(E,l,F),be(c,E,F),he(E,u,F),P&&P.m(E,F),he(E,f,F),be(g,E,F),he(E,v,F),be(_,E,F),he(E,b,F),I&&I.m(E,F),he(E,y,F),be(p,E,F),he(E,m,F),be(w,E,F),he(E,C,F),x&&x.m(E,F),he(E,h,F),ae&&ae.m(E,F),he(E,A,F),V&&V.m(E,F),he(E,L,F),$=!0},p(E,F){E[16]!==Re.NONE||E[17]===Tr.TOGGLE?P?F[0]&196608&&Z(P,1):(P=G2(),P.c(),Z(P,1),P.m(f.parentNode,f)):P&&(jt(),ne(P,1,1,()=>{P=null}),zt()),E[17]===Tr.TOGGLE?I?F[0]&131072&&Z(I,1):(I=j2(),I.c(),Z(I,1),I.m(y.parentNode,y)):I&&(jt(),ne(I,1,1,()=>{I=null}),zt());const N={};F[0]&262144&&(N.disabled=!!E[18]),p.$set(N);const Y={};F[0]&262144&&(Y.disabled=!!E[18]),w.$set(Y),E[19]?x&&(jt(),ne(x,1,1,()=>{x=null}),zt()):x?F[0]&524288&&Z(x,1):(x=z2(),x.c(),Z(x,1),x.m(h.parentNode,h)),E[20]?ae&&(jt(),ne(ae,1,1,()=>{ae=null}),zt()):ae?F[0]&1048576&&Z(ae,1):(ae=X2(),ae.c(),Z(ae,1),ae.m(A.parentNode,A)),E[21]?V&&(jt(),ne(V,1,1,()=>{V=null}),zt()):V?F[0]&2097152&&Z(V,1):(V=Y2(),V.c(),Z(V,1),V.m(L.parentNode,L))},i(E){$||(Z(e.$$.fragment,E),Z(r.$$.fragment,E),Z(s.$$.fragment,E),Z(a.$$.fragment,E),Z(c.$$.fragment,E),Z(P),Z(g.$$.fragment,E),Z(_.$$.fragment,E),Z(I),Z(p.$$.fragment,E),Z(w.$$.fragment,E),Z(x),Z(ae),Z(V),$=!0)},o(E){ne(e.$$.fragment,E),ne(r.$$.fragment,E),ne(s.$$.fragment,E),ne(a.$$.fragment,E),ne(c.$$.fragment,E),ne(P),ne(g.$$.fragment,E),ne(_.$$.fragment,E),ne(I),ne(p.$$.fragment,E),ne(w.$$.fragment,E),ne(x),ne(ae),ne(V),$=!1},d(E){E&&(de(n),de(i),de(o),de(l),de(u),de(f),de(v),de(b),de(y),de(m),de(C),de(h),de(A),de(L)),we(e,E),we(r,E),we(s,E),we(a,E),we(c,E),P&&P.d(E),we(g,E),we(_,E),I&&I.d(E),we(p,E),we(w,E),x&&x.d(E),ae&&ae.d(E),V&&V.d(E)}}}function K2(t){let e,n;return e=new Vn({props:{label:"Dictionary detection",helpText:"If enabled auto pause is skipped if open yomitan/jpdb-browser-reader popup was detected, disable to auto pause on open popup - yomitan requires disabled 'Secure Container' settings. Mobile / Touchscreen devices may require an explicit tap into the dictionary popup in order to trigger the pause.",targetStore$:_t.playerEnableDictionaryDetection$}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function Q9(t){let e,n;return e=new Vn({props:{label:"Enable WakeLock",helpText:"If enabled the sites attempts to request a WakeLock during audio play that prevents device screens from dimming or locking",targetStore$:_t.playerEnableWakeLock$}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function e7(t){let e,n,r,i,s,o,a,l,c,u,f,g,v,_,b,y,p,m,w,C,h,A,L=t[3]!==fi.DISABLED&&K2();n=new Vn({props:{label:"Enable cover",helpText:"If enabled the audio file is searched through for a cover with a cost of slightly longer loading time",targetStore$:t[68]}}),n.$on("change",t[100]),i=new Vn({props:{label:"Enable chapters",helpText:"If enabled the audio file is searched through for chapter metadata with a cost of slightly longer loading time",targetStore$:t[69]}}),i.$on("change",t[101]);let $=t[40]&&Q9();return a=new Vn({props:{label:"Enable subtitle copy",helpText:"If enabled an active subtitle will automatically be copied to the clipboard (chromium only;site needs to stay in focus)",targetStore$:_t.playerEnableSubtitleCopy$}}),c=new Ir({props:{label:"Auto pause",helpText:t[4],targetStore$:t[70],options:t[48]}}),f=new qr({props:{label:"Rewind",helpText:"# of seconds used for the regular rewind action",targetStore$:_t.playerRewindTime$,min:1,step:1}}),v=new qr({props:{label:"Rewind #2",helpText:"# of seconds used for the alternative rewind action",targetStore$:_t.playerAltRewindTime$,min:1,step:1}}),b=new qr({props:{label:"Fast-Forward",helpText:"# of seconds used for the regular fast-forward action",targetStore$:_t.playerFastForwardTime$,min:1,step:1}}),p=new qr({props:{label:"Fast-Forward #2",helpText:"# of seconds used for the alternative fast-forward action",targetStore$:_t.playerAltFastForwardTime$,min:1,step:1}}),w=new qr({props:{label:"Playback decrease time",helpText:"# of seconds used for the playback rate decrease action",targetStore$:_t.playerPlaybackRateDecreaseTime$,min:.05,max:1,step:.05}}),h=new qr({props:{label:"Playback increase time",helpText:"# of seconds used for the playback rate increase action",targetStore$:_t.playerPlaybackRateIncreaseTime$,min:.05,max:1,step:.05}}),{c(){L&&L.c(),e=me(),ye(n.$$.fragment),r=me(),ye(i.$$.fragment),s=me(),$&&$.c(),o=me(),ye(a.$$.fragment),l=me(),ye(c.$$.fragment),u=me(),ye(f.$$.fragment),g=me(),ye(v.$$.fragment),_=me(),ye(b.$$.fragment),y=me(),ye(p.$$.fragment),m=me(),ye(w.$$.fragment),C=me(),ye(h.$$.fragment)},m(P,I){L&&L.m(P,I),he(P,e,I),be(n,P,I),he(P,r,I),be(i,P,I),he(P,s,I),$&&$.m(P,I),he(P,o,I),be(a,P,I),he(P,l,I),be(c,P,I),he(P,u,I),be(f,P,I),he(P,g,I),be(v,P,I),he(P,_,I),be(b,P,I),he(P,y,I),be(p,P,I),he(P,m,I),be(w,P,I),he(P,C,I),be(h,P,I),A=!0},p(P,I){P[3]!==fi.DISABLED?L?I[0]&8&&Z(L,1):(L=K2(),L.c(),Z(L,1),L.m(e.parentNode,e)):L&&(jt(),ne(L,1,1,()=>{L=null}),zt());const x={};I[0]&16&&(x.helpText=P[4]),c.$set(x)},i(P){A||(Z(L),Z(n.$$.fragment,P),Z(i.$$.fragment,P),Z($),Z(a.$$.fragment,P),Z(c.$$.fragment,P),Z(f.$$.fragment,P),Z(v.$$.fragment,P),Z(b.$$.fragment,P),Z(p.$$.fragment,P),Z(w.$$.fragment,P),Z(h.$$.fragment,P),A=!0)},o(P){ne(L),ne(n.$$.fragment,P),ne(i.$$.fragment,P),ne($),ne(a.$$.fragment,P),ne(c.$$.fragment,P),ne(f.$$.fragment,P),ne(v.$$.fragment,P),ne(b.$$.fragment,P),ne(p.$$.fragment,P),ne(w.$$.fragment,P),ne(h.$$.fragment,P),A=!1},d(P){P&&(de(e),de(r),de(s),de(o),de(l),de(u),de(g),de(_),de(y),de(m),de(C)),L&&L.d(P),we(n,P),we(i,P),$&&$.d(P),we(a,P),we(c,P),we(f,P),we(v,P),we(b,P),we(p,P),we(w,P),we(h,P)}}}function q2(t){let e,n;return e=new Vn({props:{label:"Enable FFMPEG log",helpText:"If enabled ffmpeg logs will be printed out on console during export",targetStore$:_t.enableFFMPEGLog$}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function t7(t){let e,n,r,i,s,o,a,l,c,u,f,g,v,_;e=new Ir({props:{label:"Field mode",helpText:"Determines if the card data will be added before/after any current field value or if it will replace it",targetStore$:_t.exportFieldMode$,options:t[49]}}),r=new Ir({props:{label:"Audio processor",helpText:t[10],disabled:!!t[18],targetStore$:t[76],options:t[50]}}),r.$on("change",t[102]),s=new Ir({props:{label:"Audio Format",helpText:"Audio format used for exported audio",targetStore$:t[77],options:t[9]}}),a=new qr({props:{label:"Bitrate",helpText:"Approximate Kbps bitrate target used for exported audio",disabled:!!t[18],targetStore$:_t.exportAudioBitrate$,min:64,step:10}}),c=new Ir({props:{label:"Image Format",helpText:"Image format used for exported cover (.png fallback)",targetStore$:t[78],options:t[96]}}),f=new Vn({props:{label:"Enable merge selection auto clear after export",helpText:"If enabled the current selection of subtitles for a merge will be automatically cleared after a successfull merge export or update",targetStore$:t[75]}});let b=t[2]===kr.FFMPEG&&q2();return{c(){ye(e.$$.fragment),n=me(),ye(r.$$.fragment),i=me(),ye(s.$$.fragment),o=me(),ye(a.$$.fragment),l=me(),ye(c.$$.fragment),u=me(),ye(f.$$.fragment),g=me(),b&&b.c(),v=Fr()},m(y,p){be(e,y,p),he(y,n,p),be(r,y,p),he(y,i,p),be(s,y,p),he(y,o,p),be(a,y,p),he(y,l,p),be(c,y,p),he(y,u,p),be(f,y,p),he(y,g,p),b&&b.m(y,p),he(y,v,p),_=!0},p(y,p){const m={};p[0]&1024&&(m.helpText=y[10]),p[0]&262144&&(m.disabled=!!y[18]),r.$set(m);const w={};p[0]&512&&(w.options=y[9]),s.$set(w);const C={};p[0]&262144&&(C.disabled=!!y[18]),a.$set(C),y[2]===kr.FFMPEG?b?p[0]&4&&Z(b,1):(b=q2(),b.c(),Z(b,1),b.m(v.parentNode,v)):b&&(jt(),ne(b,1,1,()=>{b=null}),zt())},i(y){_||(Z(e.$$.fragment,y),Z(r.$$.fragment,y),Z(s.$$.fragment,y),Z(a.$$.fragment,y),Z(c.$$.fragment,y),Z(f.$$.fragment,y),Z(b),_=!0)},o(y){ne(e.$$.fragment,y),ne(r.$$.fragment,y),ne(s.$$.fragment,y),ne(a.$$.fragment,y),ne(c.$$.fragment,y),ne(f.$$.fragment,y),ne(b),_=!1},d(y){y&&(de(n),de(i),de(o),de(l),de(u),de(g),de(v)),we(e,y),we(r,y),we(s,y),we(a,y),we(c,y),we(f,y),b&&b.d(y)}}}function Z2(t){let e,n;return e=new Vn({props:{label:"Allow empty key field",helpText:"If enabled the export will set an empty key field to a zero-width character in order to avoid export errors",targetStore$:_t.ankiAllowEmptyKeyField$}}),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function J2(t,e){let n,r=e[148]+"",i,s;return{key:t,first:null,c(){n=_e("option"),i=Nt(r),s=me(),n.__value=e[148],Mi(n,n.__value),this.first=n},m(o,a){he(o,n,a),oe(n,i),oe(n,s)},p(o,a){e=o},d(o){o&&de(n)}}}function n7(t){let e;return{c(){e=_e("div"),e.textContent=`Anki export settings for the respective operation. Leaving sentence and sound field empty for 'Update
card' will automatically use all values from 'Create card' as fallback`},m(n,r){he(n,e,r)},p:wt,d(n){n&&de(e)}}}function r7(t){let e,n,r;return n=new kt({props:{path:to}}),{c(){e=_e("div"),ye(n.$$.fragment),ie(e,"slot","icon")},m(i,s){he(i,e,s),be(n,e,null),r=!0},p:wt,i(i){r||(Z(n.$$.fragment,i),r=!0)},o(i){ne(n.$$.fragment,i),r=!1},d(i){i&&de(e),we(n)}}}function i7(t){let e,n,r,i,s,o,a,l,c,u,f,g,v,_,b,y,p,m,w=[],C=new K9,h,A,L,$,P,I,x,ae,V,E,F,N,Y,K,J;e=new Vn({props:{label:"Add subtitle tag",helpText:"If enabled the name of the current loaded subtitle file will be added to the card tag list",targetStore$:_t.ankiAddSubtitleTag$}}),r=new Vn({props:{label:"Add audio tag",helpText:"If enabled the name of the current loaded audio file will be added to the card tag list",targetStore$:_t.ankiAddAudioTag$}}),s=new Vn({props:{label:"Open in browser",helpText:"If enabled an exported card will automatically open/show in the anki gui browser",targetStore$:_t.ankiEnableOpenInBrowser$}});let j=t[22]===di.DISABLED&&Z2();l=new pc({props:{label:"Card tags",helpText:"Comma separated list of tags added to the card tag list. Tags in card updates are supported on desktop only",targetStore$:_t.ankiTagList$}}),u=new Ir({props:{label:"Check duplicates",helpText:"Sets the respective options for Anki-Connect - works only on desktop and for creating new cards",targetStore$:t[79],options:t[51]}}),g=new pc({props:{label:"Anki url",buttonTitle:"Reload Anki data",targetStore$:t[80],buttonIcon:Yd}}),g.$on("click",t[112]),_=new pc({props:{helpText:"Anki API key",label:"Anki key",targetStore$:t[81]}}),_.$on("blur",t[113]);let B=Jr(t[95]);const M=S=>S[148];for(let S=0;S<B.length;S+=1){let R=D2(t,B,S),X=M(R);C.set(X,w[S]=J2(X,R))}return A=new _i({props:{$$slots:{icon:[r7],default:[n7]},$$scope:{ctx:t}}}),$=new Ir({props:{label:"Anki deck",helpText:"Target anki deck for exporting",targetStore$:t[8]?t[82]:t[83],options:t[5]}}),I=new Ir({props:{label:"Anki model",helpText:"Target anki model for exporting",targetStore$:t[8]?t[84]:t[85],options:t[6]}}),I.$on("change",t[116]),ae=new Ir({props:{label:"Sentence field",buttonTitle:"Clear field",targetStore$:t[8]?t[86]:t[87],buttonIcon:Jo,options:t[7]}}),ae.$on("click",t[117]),E=new Ir({props:{label:"Sound field",buttonTitle:"Clear field",targetStore$:t[8]?t[88]:t[89],buttonIcon:Jo,options:t[7]}}),E.$on("click",t[118]),N=new Ir({props:{label:"Cover field",buttonTitle:"Clear field",targetStore$:t[8]?t[90]:t[91],buttonIcon:Jo,options:t[7]}}),N.$on("click",t[119]),{c(){ye(e.$$.fragment),n=me(),ye(r.$$.fragment),i=me(),ye(s.$$.fragment),o=me(),j&&j.c(),a=me(),ye(l.$$.fragment),c=me(),ye(u.$$.fragment),f=me(),ye(g.$$.fragment),v=me(),ye(_.$$.fragment),b=me(),y=_e("label"),y.textContent="Anki settings",p=me(),m=_e("select");for(let S=0;S<w.length;S+=1)w[S].c();h=me(),ye(A.$$.fragment),L=me(),ye($.$$.fragment),P=me(),ye(I.$$.fragment),x=me(),ye(ae.$$.fragment),V=me(),ye(E.$$.fragment),F=me(),ye(N.$$.fragment),ie(y,"for","anki-settings-mode"),ie(m,"id","anki-settings-mode"),t[0]===void 0&&Ms(()=>t[114].call(m))},m(S,R){be(e,S,R),he(S,n,R),be(r,S,R),he(S,i,R),be(s,S,R),he(S,o,R),j&&j.m(S,R),he(S,a,R),be(l,S,R),he(S,c,R),be(u,S,R),he(S,f,R),be(g,S,R),he(S,v,R),be(_,S,R),he(S,b,R),he(S,y,R),he(S,p,R),he(S,m,R);for(let X=0;X<w.length;X+=1)w[X]&&w[X].m(m,null);Xl(m,t[0],!0),he(S,h,R),be(A,S,R),he(S,L,R),be($,S,R),he(S,P,R),be(I,S,R),he(S,x,R),be(ae,S,R),he(S,V,R),be(E,S,R),he(S,F,R),be(N,S,R),Y=!0,K||(J=[Xe(m,"change",t[114]),Xe(m,"change",t[115])],K=!0)},p(S,R){S[22]===di.DISABLED?j?R[0]&4194304&&Z(j,1):(j=Z2(),j.c(),Z(j,1),j.m(a.parentNode,a)):j&&(jt(),ne(j,1,1,()=>{j=null}),zt()),R[3]&4&&(B=Jr(S[95]),w=Ks(w,R,M,1,S,B,C,m,Ba,J2,null,D2)),R[0]&1|R[3]&4&&Xl(m,S[0]);const X={};R[4]&134217728&&(X.$$scope={dirty:R,ctx:S}),A.$set(X);const re={};R[0]&256&&(re.targetStore$=S[8]?S[82]:S[83]),R[0]&32&&(re.options=S[5]),$.$set(re);const W={};R[0]&256&&(W.targetStore$=S[8]?S[84]:S[85]),R[0]&64&&(W.options=S[6]),I.$set(W);const z={};R[0]&256&&(z.targetStore$=S[8]?S[86]:S[87]),R[0]&128&&(z.options=S[7]),ae.$set(z);const le={};R[0]&256&&(le.targetStore$=S[8]?S[88]:S[89]),R[0]&128&&(le.options=S[7]),E.$set(le);const Me={};R[0]&256&&(Me.targetStore$=S[8]?S[90]:S[91]),R[0]&128&&(Me.options=S[7]),N.$set(Me)},i(S){Y||(Z(e.$$.fragment,S),Z(r.$$.fragment,S),Z(s.$$.fragment,S),Z(j),Z(l.$$.fragment,S),Z(u.$$.fragment,S),Z(g.$$.fragment,S),Z(_.$$.fragment,S),Z(A.$$.fragment,S),Z($.$$.fragment,S),Z(I.$$.fragment,S),Z(ae.$$.fragment,S),Z(E.$$.fragment,S),Z(N.$$.fragment,S),Y=!0)},o(S){ne(e.$$.fragment,S),ne(r.$$.fragment,S),ne(s.$$.fragment,S),ne(j),ne(l.$$.fragment,S),ne(u.$$.fragment,S),ne(g.$$.fragment,S),ne(_.$$.fragment,S),ne(A.$$.fragment,S),ne($.$$.fragment,S),ne(I.$$.fragment,S),ne(ae.$$.fragment,S),ne(E.$$.fragment,S),ne(N.$$.fragment,S),Y=!1},d(S){S&&(de(n),de(i),de(o),de(a),de(c),de(f),de(v),de(b),de(y),de(p),de(m),de(h),de(L),de(P),de(x),de(V),de(F)),we(e,S),we(r,S),we(s,S),j&&j.d(S),we(l,S),we(u,S),we(g,S),we(_,S);for(let R=0;R<w.length;R+=1)w[R].d();we(A,S),we($,S),we(I,S),we(ae,S),we(E,S),we(N,S),K=!1,vn(J)}}}function Q2(t){let e,n,r;function i(o){t[122](o)}let s={settingsMenu:ci.READER_ACTIONS,$$slots:{default:[s7]},$$scope:{ctx:t}};return t[1]!==void 0&&(s.openSettingsMenu=t[1]),e=new Es({props:s}),Vt.push(()=>Zn(e,"openSettingsMenu",i)),{c(){ye(e.$$.fragment)},m(o,a){be(e,o,a),r=!0},p(o,a){const l={};a[1]&2|a[4]&134217728&&(l.$$scope={dirty:a,ctx:o}),!n&&a[0]&2&&(n=!0,l.openSettingsMenu=o[1],Yn(()=>n=!1)),e.$set(l)},i(o){r||(Z(e.$$.fragment,o),r=!0)},o(o){ne(e.$$.fragment,o),r=!1},d(o){we(e,o)}}}function s7(t){let e,n,r;function i(o){t[121](o)}let s={defaultActions:hd};return t[32]!==void 0&&(s.actionList=t[32]),e=new Qf({props:s}),Vt.push(()=>Zn(e,"actionList",i)),{c(){ye(e.$$.fragment)},m(o,a){be(e,o,a),r=!0},p(o,a){const l={};!n&&a[1]&2&&(n=!0,l.actionList=o[32],Yn(()=>n=!1)),e.$set(l)},i(o){r||(Z(e.$$.fragment,o),r=!0)},o(o){ne(e.$$.fragment,o),r=!1},d(o){we(e,o)}}}function e_(t){let e,n,r;function i(o){t[124](o)}let s={settingsMenu:ci.SUBTITLE_ACTIONS,$$slots:{default:[o7]},$$scope:{ctx:t}};return t[1]!==void 0&&(s.openSettingsMenu=t[1]),e=new Es({props:s}),Vt.push(()=>Zn(e,"openSettingsMenu",i)),{c(){ye(e.$$.fragment)},m(o,a){be(e,o,a),r=!0},p(o,a){const l={};a[1]&4|a[4]&134217728&&(l.$$scope={dirty:a,ctx:o}),!n&&a[0]&2&&(n=!0,l.openSettingsMenu=o[1],Yn(()=>n=!1)),e.$set(l)},i(o){r||(Z(e.$$.fragment,o),r=!0)},o(o){ne(e.$$.fragment,o),r=!1},d(o){we(e,o)}}}function o7(t){let e,n,r;function i(o){t[123](o)}let s={defaultActions:pd};return t[33]!==void 0&&(s.actionList=t[33]),e=new Qf({props:s}),Vt.push(()=>Zn(e,"actionList",i)),{c(){ye(e.$$.fragment)},m(o,a){be(e,o,a),r=!0},p(o,a){const l={};!n&&a[1]&4&&(n=!0,l.actionList=o[33],Yn(()=>n=!1)),e.$set(l)},i(o){r||(Z(e.$$.fragment,o),r=!0)},o(o){ne(e.$$.fragment,o),r=!1},d(o){we(e,o)}}}function a7(t){let e,n,r;function i(o){t[125](o)}let s={defaultActions:jc};return t[34]!==void 0&&(s.actionList=t[34]),e=new Qf({props:s}),Vt.push(()=>Zn(e,"actionList",i)),{c(){ye(e.$$.fragment)},m(o,a){be(e,o,a),r=!0},p(o,a){const l={};!n&&a[1]&8&&(n=!0,l.actionList=o[34],Yn(()=>n=!1)),e.$set(l)},i(o){r||(Z(e.$$.fragment,o),r=!0)},o(o){ne(e.$$.fragment,o),r=!1},d(o){we(e,o)}}}function t_(t){let e,n,r;function i(o){t[127](o)}let s={settingsMenu:ci.KEYBINDINGS,$$slots:{default:[l7]},$$scope:{ctx:t}};return t[1]!==void 0&&(s.openSettingsMenu=t[1]),e=new Es({props:s}),Vt.push(()=>Zn(e,"openSettingsMenu",i)),{c(){ye(e.$$.fragment)},m(o,a){be(e,o,a),r=!0},p(o,a){const l={};a[1]&480|a[4]&134217728&&(l.$$scope={dirty:a,ctx:o}),!n&&a[0]&2&&(n=!0,l.openSettingsMenu=o[1],Yn(()=>n=!1)),e.$set(l)},i(o){r||(Z(e.$$.fragment,o),r=!0)},o(o){ne(e.$$.fragment,o),r=!1},d(o){we(e,o)}}}function l7(t){let e,n,r,i,s,o,a,l,c,u,f,g,v,_,b,y,p,m,w,C,h,A,L,$,P,I,x,ae,V,E,F,N,Y,K,J,j,B,M,S,R,X,re;return e=new Vn({props:{label:"Enable time fallback",helpText:"If enabled and no subtitle is currently active the current time is used as fallback to search for the closest subtitle",targetStore$:_t.keybindingsEnableTimeFallback$}}),r=new gr({props:{key:"Cmd + Space",description:Re.TOGGLE_PLAYBACK,extendDescription:!1}}),s=new gr({props:{key:"Alt + j",description:Re.TOGGLE_PLAYBACK,extendDescription:!1}}),a=new gr({props:{key:"Cmd + d",description:Re.RESTART_PLAYBACK}}),c=new gr({props:{key:"Alt + d",description:Re.TOGGLE_PLAY_PAUSE}}),f=new gr({props:{key:"Cmd + l",description:Re.TOGGLE_PLAYBACK_LOOP}}),v=new gr({props:{key:"Cmd + b",description:Re.TOGGLE_BOOKMARK}}),b=new gr({props:{key:"Cmd + m",description:Re.TOGGLE_MERGE}}),p=new gr({props:{key:"Cmd + e",description:Re.EXPORT_NEW}}),w=new gr({props:{key:"Alt + e",description:Re.EXPORT_UPDATE}}),h=new gr({props:{key:"Alt + g",description:Re.EDIT_SUBTITLE,extendDescription:!1}}),L=new gr({props:{key:"Alt + z",description:Re.COPY_SUBTITLE,extendDescription:!1}}),P=new gr({props:{key:"Cmd + q",description:Re.PREVIOUS_SUBTITLE,extendDescription:!1}}),x=new gr({props:{key:"Alt + q",description:Re.NEXT_SUBTITLE,extendDescription:!1}}),V=new gr({props:{key:"Cmd + k",description:"Decrease playbackrate",extendDescription:!1}}),F=new gr({props:{key:"Alt + k",description:"Increase playbackrate",extendDescription:!1}}),Y=new gr({props:{key:"Cmd + Arrow Left",description:`Rewind ${t[36]} seconds`,extendDescription:!1}}),J=new gr({props:{key:"Cmd + Arrow Down",description:`Rewind ${t[37]} seconds`,extendDescription:!1}}),B=new gr({props:{key:"Cmd + Arrow Right",description:`Fast-Forward ${t[38]} seconds`,extendDescription:!1}}),S=new gr({props:{key:"Cmd + Arrow Up",description:`Fast-Forward ${t[39]} seconds`,extendDescription:!1}}),X=new gr({props:{key:"Alt + h",description:"Toggle visibility of footer actions",extendDescription:!1}}),{c(){ye(e.$$.fragment),n=me(),ye(r.$$.fragment),i=me(),ye(s.$$.fragment),o=me(),ye(a.$$.fragment),l=me(),ye(c.$$.fragment),u=me(),ye(f.$$.fragment),g=me(),ye(v.$$.fragment),_=me(),ye(b.$$.fragment),y=me(),ye(p.$$.fragment),m=me(),ye(w.$$.fragment),C=me(),ye(h.$$.fragment),A=me(),ye(L.$$.fragment),$=me(),ye(P.$$.fragment),I=me(),ye(x.$$.fragment),ae=me(),ye(V.$$.fragment),E=me(),ye(F.$$.fragment),N=me(),ye(Y.$$.fragment),K=me(),ye(J.$$.fragment),j=me(),ye(B.$$.fragment),M=me(),ye(S.$$.fragment),R=me(),ye(X.$$.fragment)},m(W,z){be(e,W,z),he(W,n,z),be(r,W,z),he(W,i,z),be(s,W,z),he(W,o,z),be(a,W,z),he(W,l,z),be(c,W,z),he(W,u,z),be(f,W,z),he(W,g,z),be(v,W,z),he(W,_,z),be(b,W,z),he(W,y,z),be(p,W,z),he(W,m,z),be(w,W,z),he(W,C,z),be(h,W,z),he(W,A,z),be(L,W,z),he(W,$,z),be(P,W,z),he(W,I,z),be(x,W,z),he(W,ae,z),be(V,W,z),he(W,E,z),be(F,W,z),he(W,N,z),be(Y,W,z),he(W,K,z),be(J,W,z),he(W,j,z),be(B,W,z),he(W,M,z),be(S,W,z),he(W,R,z),be(X,W,z),re=!0},p(W,z){const le={};z[1]&32&&(le.description=`Rewind ${W[36]} seconds`),Y.$set(le);const Me={};z[1]&64&&(Me.description=`Rewind ${W[37]} seconds`),J.$set(Me);const Ee={};z[1]&128&&(Ee.description=`Fast-Forward ${W[38]} seconds`),B.$set(Ee);const ve={};z[1]&256&&(ve.description=`Fast-Forward ${W[39]} seconds`),S.$set(ve)},i(W){re||(Z(e.$$.fragment,W),Z(r.$$.fragment,W),Z(s.$$.fragment,W),Z(a.$$.fragment,W),Z(c.$$.fragment,W),Z(f.$$.fragment,W),Z(v.$$.fragment,W),Z(b.$$.fragment,W),Z(p.$$.fragment,W),Z(w.$$.fragment,W),Z(h.$$.fragment,W),Z(L.$$.fragment,W),Z(P.$$.fragment,W),Z(x.$$.fragment,W),Z(V.$$.fragment,W),Z(F.$$.fragment,W),Z(Y.$$.fragment,W),Z(J.$$.fragment,W),Z(B.$$.fragment,W),Z(S.$$.fragment,W),Z(X.$$.fragment,W),re=!0)},o(W){ne(e.$$.fragment,W),ne(r.$$.fragment,W),ne(s.$$.fragment,W),ne(a.$$.fragment,W),ne(c.$$.fragment,W),ne(f.$$.fragment,W),ne(v.$$.fragment,W),ne(b.$$.fragment,W),ne(p.$$.fragment,W),ne(w.$$.fragment,W),ne(h.$$.fragment,W),ne(L.$$.fragment,W),ne(P.$$.fragment,W),ne(x.$$.fragment,W),ne(V.$$.fragment,W),ne(F.$$.fragment,W),ne(Y.$$.fragment,W),ne(J.$$.fragment,W),ne(B.$$.fragment,W),ne(S.$$.fragment,W),ne(X.$$.fragment,W),re=!1},d(W){W&&(de(n),de(i),de(o),de(l),de(u),de(g),de(_),de(y),de(m),de(C),de(A),de($),de(I),de(ae),de(E),de(N),de(K),de(j),de(M),de(R)),we(e,W),we(r,W),we(s,W),we(a,W),we(c,W),we(f,W),we(v,W),we(b,W),we(p,W),we(w,W),we(h,W),we(L,W),we(P,W),we(x,W),we(V,W),we(F,W),we(Y,W),we(J,W),we(B,W),we(S,W),we(X,W)}}}function u7(t){let e,n,r,i,s,o,a,l,c,u,f,g,v,_,b,y,p,m,w,C,h,A;function L(M){t[108](M)}let $={settingsMenu:ci.READER,$$slots:{default:[Z9]},$$scope:{ctx:t}};t[1]!==void 0&&($.openSettingsMenu=t[1]),n=new Es({props:$}),Vt.push(()=>Zn(n,"openSettingsMenu",L));function P(M){t[109](M)}let I={settingsMenu:ci.SUBTITLES,$$slots:{default:[J9]},$$scope:{ctx:t}};t[1]!==void 0&&(I.openSettingsMenu=t[1]),s=new Es({props:I}),Vt.push(()=>Zn(s,"openSettingsMenu",P));function x(M){t[110](M)}let ae={settingsMenu:ci.PLAYER,$$slots:{default:[e7]},$$scope:{ctx:t}};t[1]!==void 0&&(ae.openSettingsMenu=t[1]),l=new Es({props:ae}),Vt.push(()=>Zn(l,"openSettingsMenu",x));function V(M){t[111](M)}let E={settingsMenu:ci.EXPORT,$$slots:{default:[t7]},$$scope:{ctx:t}};t[1]!==void 0&&(E.openSettingsMenu=t[1]),f=new Es({props:E}),Vt.push(()=>Zn(f,"openSettingsMenu",V));function F(M){t[120](M)}let N={settingsMenu:ci.ANKI,$$slots:{default:[i7]},$$scope:{ctx:t}};t[1]!==void 0&&(N.openSettingsMenu=t[1]),_=new Es({props:N}),Vt.push(()=>Zn(_,"openSettingsMenu",F));let Y=t[15]!==tr.DISABLED&&Q2(t),K=t[17]!==Tr.HIDDEN&&e_(t);function J(M){t[126](M)}let j={settingsMenu:ci.FOOTER_ACTIONS,$$slots:{default:[a7]},$$scope:{ctx:t}};t[1]!==void 0&&(j.openSettingsMenu=t[1]),w=new Es({props:j}),Vt.push(()=>Zn(w,"openSettingsMenu",J));let B=!t[35]&&t_(t);return{c(){e=_e("div"),ye(n.$$.fragment),i=me(),ye(s.$$.fragment),a=me(),ye(l.$$.fragment),u=me(),ye(f.$$.fragment),v=me(),ye(_.$$.fragment),y=me(),Y&&Y.c(),p=me(),K&&K.c(),m=me(),ye(w.$$.fragment),h=me(),B&&B.c()},m(M,S){he(M,e,S),be(n,e,null),oe(e,i),be(s,e,null),oe(e,a),be(l,e,null),oe(e,u),be(f,e,null),oe(e,v),be(_,e,null),oe(e,y),Y&&Y.m(e,null),oe(e,p),K&&K.m(e,null),oe(e,m),be(w,e,null),oe(e,h),B&&B.m(e,null),A=!0},p(M,S){const R={};S[0]&63488|S[4]&134217728&&(R.$$scope={dirty:S,ctx:M}),!r&&S[0]&2&&(r=!0,R.openSettingsMenu=M[1],Yn(()=>r=!1)),n.$set(R);const X={};S[0]&4128768|S[4]&134217728&&(X.$$scope={dirty:S,ctx:M}),!o&&S[0]&2&&(o=!0,X.openSettingsMenu=M[1],Yn(()=>o=!1)),s.$set(X);const re={};S[0]&24|S[4]&134217728&&(re.$$scope={dirty:S,ctx:M}),!c&&S[0]&2&&(c=!0,re.openSettingsMenu=M[1],Yn(()=>c=!1)),l.$set(re);const W={};S[0]&263684|S[4]&134217728&&(W.$$scope={dirty:S,ctx:M}),!g&&S[0]&2&&(g=!0,W.openSettingsMenu=M[1],Yn(()=>g=!1)),f.$set(W);const z={};S[0]&2143289825|S[1]&1|S[4]&134217728&&(z.$$scope={dirty:S,ctx:M}),!b&&S[0]&2&&(b=!0,z.openSettingsMenu=M[1],Yn(()=>b=!1)),_.$set(z),M[15]!==tr.DISABLED?Y?(Y.p(M,S),S[0]&32768&&Z(Y,1)):(Y=Q2(M),Y.c(),Z(Y,1),Y.m(e,p)):Y&&(jt(),ne(Y,1,1,()=>{Y=null}),zt()),M[17]!==Tr.HIDDEN?K?(K.p(M,S),S[0]&131072&&Z(K,1)):(K=e_(M),K.c(),Z(K,1),K.m(e,m)):K&&(jt(),ne(K,1,1,()=>{K=null}),zt());const le={};S[1]&8|S[4]&134217728&&(le.$$scope={dirty:S,ctx:M}),!C&&S[0]&2&&(C=!0,le.openSettingsMenu=M[1],Yn(()=>C=!1)),w.$set(le),M[35]?B&&(jt(),ne(B,1,1,()=>{B=null}),zt()):B?(B.p(M,S),S[1]&16&&Z(B,1)):(B=t_(M),B.c(),Z(B,1),B.m(e,null))},i(M){A||(Z(n.$$.fragment,M),Z(s.$$.fragment,M),Z(l.$$.fragment,M),Z(f.$$.fragment,M),Z(_.$$.fragment,M),Z(Y),Z(K),Z(w.$$.fragment,M),Z(B),A=!0)},o(M){ne(n.$$.fragment,M),ne(s.$$.fragment,M),ne(l.$$.fragment,M),ne(f.$$.fragment,M),ne(_.$$.fragment,M),ne(Y),ne(K),ne(w.$$.fragment,M),ne(B),A=!1},d(M){M&&de(e),we(n),we(s),we(l),we(f),we(_),Y&&Y.d(),K&&K.d(),we(w),B&&B.d()}}}function c7(t,e,n){let r,i,s,o,a,l,c,u,f,g,v,_,b,y,p,m,w,C,h,A,L,$,P,I,x,ae,V,E,F,N,Y,K,J,j,B,M,S,R,X,re,W,z,le,Me,Ee,ve,ke,Ne,Te,Le,Fe,Ze,O,H;ce(t,At,Ue=>n(128,a=Ue)),ce(t,Mt,Ue=>n(129,l=Ue)),ce(t,$a,Ue=>n(131,f=Ue)),ce(t,Zs,Ue=>n(132,g=Ue)),ce(t,qs,Ue=>n(135,b=Ue)),ce(t,rs,Ue=>n(136,y=Ue)),ce(t,Lr,Ue=>n(138,m=Ue)),ce(t,ls,Ue=>n(139,w=Ue)),ce(t,nu,Ue=>n(12,V=Ue)),ce(t,vi,Ue=>n(18,J=Ue)),ce(t,Fa,Ue=>n(35,Le=Ue));const Pe="wakeLock"in navigator,{supportsFileSystem:xe,sandboxElement:qe}=Io("context"),nt=[Re.NONE,Re.RESTART_PLAYBACK,Re.TOGGLE_PLAY_PAUSE,Re.TOGGLE_PLAYBACK_LOOP,Re.TOGGLE_BOOKMARK,Re.TOGGLE_MERGE,Re.EDIT_SUBTITLE,Re.RESTORE_SUBTITLE,Re.COPY_SUBTITLE,Re.EXPORT_NEW,Re.EXPORT_UPDATE],Oe=[Zl.ALWAYS,Zl.PAGE],je=[Jl.AUTO,Jl.INSTANT,Jl.SMOOTH],et=[tr.DISABLED,tr.CLICK,tr.HOLD],rt=[Ql.DISABLED,Ql.PAUSE],Je=[Tr.HIDDEN,Tr.ALWAYS,Tr.HOVER,Tr.TOGGLE],G=[fi.DISABLED,fi.MODERATE,fi.STRICT],T=[Ls.BEFORE,Ls.AFTER,Ls.REPLACE],d=[kr.RECORDER,kr.FFMPEG],k=[di.DISABLED,di.DECK,di.SUBDECK,di.COLLECTION],{readerLineHighlightColor$:D,readerLineTextHighlightColor$:U,readerEnableLineHighlight$:te,readerEnableLineTextHighlight$:ee,readerEnableAutoScroll$:se,readerScrollMode$:ge,readerClickAction$:pe,readerMenuOpenMode$:Ae,subtitlesEnablePersist$:Ce,subtitlesCopyFontFamily$:De,subtitlesCopyFontSize$:tt,subtitlesCopyLineHeight$:mt,subtitlesClickAction$:We,subtitlesActionsVisibility$:dt,subtitlesGlobalStartPadding$:Be,subtitlesGlobalEndPadding$:$e,playerEnableCover$:ft,playerEnableChapters$:ze,playerAutoPauseMode$:at,playerRewindTime$:Qe,playerAltRewindTime$:vt,playerFastForwardTime$:Rt,playerAltFastForwardTime$:lt,exportEnableMergeSelectionAutoClear$:St,exportAudioProcessor$:ht,exportAudioFormat$:xt,exportCoverFormat$:ln,ankiDuplicateMode$:qt,ankiUrl$:Dt,ankiKey$:rn,ankiDeck$:In,ankiUpdateDeck$:Hn,ankiModel$:xn,ankiUpdateModel$:Xt,ankiSentenceField$:Ft,ankiUpdateSentenceField$:Wt,ankiSoundField$:un,ankiUpdateSoundField$:Ye,ankiCoverField$:ut,ankiUpdateCoverField$:yr,actionListOfReader$:Xn,actionListOfSubtitles$:Yt,actionListOfFooter$:sr}=_t;ce(t,D,Ue=>n(142,A=Ue)),ce(t,U,Ue=>n(143,L=Ue)),ce(t,te,Ue=>n(106,P=Ue)),ce(t,ee,Ue=>n(105,$=Ue)),ce(t,se,Ue=>n(13,E=Ue)),ce(t,ge,Ue=>n(107,ae=Ue)),ce(t,pe,Ue=>n(14,F=Ue)),ce(t,Ae,Ue=>n(15,N=Ue)),ce(t,Ce,Ue=>n(137,p=Ue)),ce(t,De,Ue=>n(19,j=Ue)),ce(t,tt,Ue=>n(20,B=Ue)),ce(t,mt,Ue=>n(21,M=Ue)),ce(t,We,Ue=>n(16,Y=Ue)),ce(t,dt,Ue=>n(17,K=Ue)),ce(t,Be,Ue=>n(141,h=Ue)),ce(t,$e,Ue=>n(140,C=Ue)),ce(t,ft,Ue=>n(134,_=Ue)),ce(t,ze,Ue=>n(133,v=Ue)),ce(t,at,Ue=>n(3,x=Ue)),ce(t,Qe,Ue=>n(36,Fe=Ue)),ce(t,vt,Ue=>n(37,Ze=Ue)),ce(t,Rt,Ue=>n(38,O=Ue)),ce(t,lt,Ue=>n(39,H=Ue)),ce(t,ht,Ue=>n(2,u=Ue)),ce(t,xt,Ue=>n(144,I=Ue)),ce(t,qt,Ue=>n(22,S=Ue)),ce(t,Dt,Ue=>n(130,c=Ue)),ce(t,rn,Ue=>n(23,R=Ue)),ce(t,xn,Ue=>n(24,X=Ue)),ce(t,Xt,Ue=>n(25,re=Ue)),ce(t,Ft,Ue=>n(26,W=Ue)),ce(t,Wt,Ue=>n(27,z=Ue)),ce(t,un,Ue=>n(28,le=Ue)),ce(t,Ye,Ue=>n(29,Me=Ue)),ce(t,ut,Ue=>n(30,Ee=Ue)),ce(t,yr,Ue=>n(31,ve=Ue)),ce(t,Xn,Ue=>n(32,ke=Ue)),ce(t,Yt,Ue=>n(33,Ne=Ue)),ce(t,sr,Ue=>n(34,Te=Ue));const Qn=new Map,Un=[Da.CREATE,Da.UPDATE],vr=[$o.AUTO,$o.JPEG,$o.PNG,$o.WEBP];let dr=Da.CREATE,hn=ci.NONE,Gr="",pn=[],or=[],Or=[];async function oi(...Ue){await Mr();const pr="ttu-whispersync-color-styles",ar=[];P&&$?ar.push("span[class^='ttu-whispersync-line-highlight-'].active,","span[class^='ttu-whispersync-line-highlight-'].menu-open ",`{color: ${L};background-color: ${A};}`):P?ar.push("span[class^='ttu-whispersync-line-highlight-'].active,","span[class^='ttu-whispersync-line-highlight-'].menu-open ",`{background-color: ${A};}`):$?ar.push("span[class^='ttu-whispersync-line-highlight-'].active,","span[class^='ttu-whispersync-line-highlight-'].menu-open ",`{color: ${L};}`):ar.push("span[class^='ttu-whispersync-line-highlight-'].menu-open ",`{color: ${L};background-color: ${A};}`);const ai=document.createTextNode(ar.join(""));let mr=document.getElementById(pr);if(mr)return mr.replaceChild(ai,mr.firstChild);mr=document.createElement("style"),mr.id=pr,mr.appendChild(ai),document.head.append(mr)}async function Wn(){!p||!y||(fe(At,a=!0,a),fe(Mt,l="",l),await Is({name:y.name,subtitles:[...m.values()]}).catch(({message:Ue})=>fe(Mt,l=Ue,l)),fe(At,a=!1,a))}async function jr(Ue,pr){fe(At,a=!0,a);const ar=h,ai=C;if(await wd(Ue,pr),!m.size||ar===h&&ai===C){fe(At,a=!1,a);return}const mr=[],Xr=new Map,es=[...m.entries()],ka=h/1e3,Aa=C/1e3;for(let As=0,{length:Wl}=es;As<Wl;As+=1){const[Se,Lt]=es[As],Ln=Lt.adjustedStartSeconds??Math.max(0,Lt.originalStartSeconds+ka),fn=Lt.adjustedEndSeconds??(w?Wi(0,w,Lt.originalEndSeconds+Aa):Math.max(0,Lt.originalEndSeconds+Aa)),kn={...Lt,startSeconds:Ln,startTime:Qr(Ln),endSeconds:fn,endTime:Qr(fn)};mr.push(kn),Xr.set(Se,kn)}fe(Lr,m=Xr,m),Za.set({subtitles:mr,replaceTrack:!0}),p&&(fe(Mt,l="",l),await Is({name:y.name,subtitles:mr}).catch(({message:As})=>fe(Mt,l=As,l))),fe(At,a=!1,a)}async function Ve(){fe(At,a=!0,a),fe(Mt,l="",l);try{await(qe?Yc(qe,{action:"setMediaInfoInstance",enableCover:_,url:chrome.runtime.getURL("src/assets/js/MediaInfoModule_0.2.1.wasm")}):w1(_,!0,""))}catch({message:Ue}){fe(Mt,l=`MediaInfo failure: ${Ue}`,l),fe(At,a=!1,a);return}if(_&&f)try{const{coverUrl:Ue}=await Qo(f,qe,!1,!0);URL.revokeObjectURL(b),fe(qs,b=Ue,b)}catch({message:Ue}){fe(Mt,l=`Failed to set cover: ${Ue}`,l)}else _||(URL.revokeObjectURL(b),fe(qs,b="",b));fe(At,a=!1,a)}async function It(){fe(At,a=!0,a),fe(Mt,l="",l);try{await(qe?Yc(qe,{action:"setMediaInfoInstance",enableCover:_,url:chrome.runtime.getURL("src/assets/js/MediaInfoModule_0.2.1.wasm")}):w1(_,!0,""))}catch({message:Ue}){fe(Mt,l=`MediaInfo failure: ${Ue}`,l),fe(At,a=!1,a);return}if(v&&f)try{let{chapters:Ue}=await Qo(f,qe,!1,!0);!Ue.length&&u===kr.FFMPEG&&(Ue=await t1(f)),fe(Zs,g=Ue,g)}catch({message:Ue}){fe(Mt,l=`Failed to set chapters: ${Ue}`,l)}else v||fe(Zs,g=[],g);fe(At,a=!1,a)}async function Bt({currentTarget:Ue}){if(!(Ue instanceof HTMLSelectElement))return;fe(At,a=!0,a),fe(Mt,l="",l);let pr=kr.RECORDER;if(u===kr.FFMPEG)try{await kd(),await Ad(f),pr=kr.FFMPEG}catch({message:ar}){fe(Mt,l=`Update to FFMPEG failed: ${ar}`,l)}if(pr===kr.FFMPEG&&!g.length&&v&&f&&fe(Zs,g=await t1(f),g),pr===kr.RECORDER)try{eg()}catch{}Ue.value=pr,fe(ht,u=pr,u),fe(At,a=!1,a)}async function $t(Ue=!1,pr=!1){if(!(!Ue&&!pr&&pn.length&&or.length)){fe(At,a=!0,a),fe(Mt,l="",l);try{(Ue||!pn.length||!or.length)&&n(5,[pn,or]=await Rd(c),pn,n(6,or)),Ue&&Qn.clear();let ar=o?In:Hn,ai=o?xn:Xt,mr=Ct(ar),Xr=Ct(ai);mr&&!pn.find(es=>es===mr)&&ar.set(""),Xr&&!or.find(es=>es===Xr)&&(ai.set(""),Xr=""),Xr&&await tn(Xr)}catch({message:ar}){fe(Mt,l=`Failed to get Anki data: ${ar}`,l),Tn()}fe(At,a=!1,a)}}async function tn(Ue){fe(At,a=!0,a),fe(Mt,l="",l);try{n(7,Or=await(Qn.has(Ue)?Promise.resolve(Qn.get(Ue)):Ld(c,Ue))),Qn.set(Ue,Or);let pr=o?Ft:Wt,ar=o?un:Ye,ai=Ct(pr),mr=Ct(ar);ai&&!Or.find(Xr=>Xr===ai)&&pr.set(""),mr&&!Or.find(Xr=>Xr===mr)&&ar.set("")}catch({message:pr}){fe(Mt,l=`Failed to get Anki data: ${pr}`,l),Tn()}fe(At,a=!1,a)}function Tn(){Pd(!o),Qn.clear(),n(5,pn=[]),n(6,or=[]),n(7,Or=[])}function He(Ue){hn=Ue,n(1,hn)}function Et(Ue){hn=Ue,n(1,hn)}function Gt(Ue){hn=Ue,n(1,hn)}function nn(Ue){hn=Ue,n(1,hn)}const hr=()=>$t(!0),Pt=()=>{og(R)};function Zt(){dr=sd(this),n(0,dr),n(95,Un)}const On=()=>$t(!1,!0),Br=()=>tn(o?X:re),zr=()=>{o?fe(Ft,W="",W):fe(Wt,z="",z)},To=()=>{o?fe(un,le="",le):fe(Ye,Me="",Me)},Gs=()=>{o?fe(ut,Ee="",Ee):fe(yr,ve="",ve)};function Sa(Ue){hn=Ue,n(1,hn)}function Nl(Ue){ke=Ue,Xn.set(ke)}function ko(Ue){hn=Ue,n(1,hn)}function Vl(Ue){Ne=Ue,Yt.set(Ne)}function Ta(Ue){hn=Ue,n(1,hn)}function Hl(Ue){Te=Ue,sr.set(Te)}function xl(Ue){hn=Ue,n(1,hn)}function Ul(Ue){hn=Ue,n(1,hn)}return t.$$.update=()=>{t.$$.dirty[3]&16384&&n(11,r=ae===Zl.ALWAYS?"The reader scrolls on every subtitle change":"The reader will only scroll if the subtitle is not fully visibile on the page"),t.$$.dirty[0]&4&&n(10,i=u===kr.RECORDER?"Use realtime audio recording - requires to block certain actions during export":"Use background transcoding (file limit ~1.8 GB) - has certain performance requirements and may crash the site but is non blocking. Reload the page/use recorder in case of issues"),t.$$.dirty[0]&4&&n(9,s=u===kr.FFMPEG?[Rs.MP3,Rs.OGG,Rs.OPUS]:[Rs.MP3]),t.$$.dirty[0]&1&&n(8,o=dr===Da.CREATE),t.$$.dirty[0]&8&&(x===fi.DISABLED?n(4,Gr="Player does not auto pause"):n(4,Gr=x===fi.MODERATE?"Player will auto pause when the browser tab loses focus":"Player will auto pause on any kind of site focus loss (e. g. different window etc.)")),t.$$.dirty[0]&4&&u===kr.RECORDER&&fe(xt,I=Rs.MP3,I),t.$$.dirty[0]&2&&hn===ci.ANKI&&$t(),t.$$.dirty[3]&12288&&oi(P,$)},[dr,hn,u,x,Gr,pn,or,Or,o,s,i,r,V,E,F,N,Y,K,J,j,B,M,S,R,X,re,W,z,le,Me,Ee,ve,ke,Ne,Te,Le,Fe,Ze,O,H,Pe,xe,nt,Oe,je,et,rt,Je,G,T,d,k,D,U,te,ee,se,ge,pe,Ae,Ce,De,tt,mt,We,dt,Be,$e,ft,ze,at,Qe,vt,Rt,lt,St,ht,xt,ln,qt,Dt,rn,In,Hn,xn,Xt,Ft,Wt,un,Ye,ut,yr,Xn,Yt,sr,Un,vr,oi,Wn,jr,Ve,It,Bt,$t,tn,$,P,ae,He,Et,Gt,nn,hr,Pt,Zt,On,Br,zr,To,Gs,Sa,Nl,ko,Vl,Ta,Hl,xl,Ul]}class f7 extends Dn{constructor(e){super(),Bn(this,e,c7,u7,Cn,{},null,[-1,-1,-1,-1,-1])}}const{window:n_}=$c;function r_(t){let e,n;return e=new _1({props:{isFooter:!0,buttonClasses:"h-full hover:opacity-70",listItems:t[6],hideCancelAction:!t[2],subtitle:t[14]||t[4].get(t[21].current||t[21].previous)}}),e.$on("executed",t[80]),{c(){ye(e.$$.fragment)},m(r,i){be(e,r,i),n=!0},p(r,i){const s={};i[0]&64&&(s.listItems=r[6]),i[0]&4&&(s.hideCancelAction=!r[2]),i[0]&2113552&&(s.subtitle=r[14]||r[4].get(r[21].current||r[21].previous)),e.$set(s)},i(r){n||(Z(e.$$.fragment,r),n=!0)},o(r){ne(e.$$.fragment,r),n=!1},d(r){we(e,r)}}}function d7(t){let e;return{c(){e=_e("ol"),e.innerHTML=`<li>Install Anki and configure deck and note type</li> <li>Install AnkiConnect and configure deck and note type</li> <li>Add https://reader.ttsu.app to the webCorsOriginList of AnkiConnect</li> <li>Load subtitle/audio files</li> <li>Switch to &quot;Match&quot; Tab, match the subtitle against your book and click on &quot;Save &amp; reload
page&quot; to enable full functionality like reader highlighting, reader menu, autoscroll etc.
after the page was reloaded</li> <li>Configure your experience to your preferences by going to the settings tab</li> <li>Read <a href="https://github.com/Renji-XD/ttu-whispersync" target="_blank">FAQ &amp; more</a> for
further Information</li>`,ie(e,"class","getting-started")},m(n,r){he(n,e,r)},p:wt,d(n){n&&de(e)}}}function h7(t){let e,n,r;return n=new kt({props:{path:to}}),{c(){e=_e("div"),ye(n.$$.fragment),ie(e,"slot","icon")},m(i,s){he(i,e,s),be(n,e,null),r=!0},p:wt,i(i){r||(Z(n.$$.fragment,i),r=!0)},o(i){ne(n.$$.fragment,i),r=!1},d(i){i&&de(e),we(n)}}}function i_(t){let e,n,r,i,s,o,a,l,c,u,f,g,v,_,b,y,p,m,w,C,h,A=t[4].size&&!t[5].matchedBy&&s_(t),L=t[27].length&&o_(t),$={showMenu:t[11]};return c=new ov({props:$}),t[91](c),g=new Kv({}),g.$on("selectHint",t[92]),g.$on("hintSelected",t[93]),b=new uv({}),m=new f7({}),{c(){e=_e("div"),n=_e("button"),n.textContent=`${_n.AUDIOBOOK}`,r=me(),A&&A.c(),i=me(),L&&L.c(),s=me(),o=_e("button"),o.textContent=`${_n.SETTINGS}`,a=me(),l=_e("div"),ye(c.$$.fragment),u=me(),f=_e("div"),ye(g.$$.fragment),v=me(),_=_e("div"),ye(b.$$.fragment),y=me(),p=_e("div"),ye(m.$$.fragment),ie(n,"title","Switch to Audiobook tab"),pt(n,"tab-active",t[26]===_n.AUDIOBOOK),ie(o,"title","Switch to Settings tab"),pt(o,"tab-active",t[26]===_n.SETTINGS),ie(e,"class","flex justify-between w-full tabs m-b-s"),ie(l,"class","flex-col flex-1 m-b-s"),pt(l,"hidden",t[26]!==_n.AUDIOBOOK),pt(l,"flex",t[26]===_n.AUDIOBOOK),ie(f,"class","flex flex-col flex-1"),pt(f,"hidden",t[26]!==_n.MATCH),ie(_,"class","overflow-auto"),pt(_,"hidden",t[26]!==_n.CHAPTERS),ie(p,"class","overflow-auto"),pt(p,"hidden",t[26]!==_n.SETTINGS)},m(P,I){he(P,e,I),oe(e,n),oe(e,r),A&&A.m(e,null),oe(e,i),L&&L.m(e,null),oe(e,s),oe(e,o),he(P,a,I),he(P,l,I),be(c,l,null),he(P,u,I),he(P,f,I),be(g,f,null),he(P,v,I),he(P,_,I),be(b,_,null),he(P,y,I),he(P,p,I),be(m,p,null),w=!0,C||(h=[Xe(n,"click",t[87]),Xe(o,"click",t[90])],C=!0)},p(P,I){(!w||I[0]&67108864)&&pt(n,"tab-active",P[26]===_n.AUDIOBOOK),P[4].size&&!P[5].matchedBy?A?A.p(P,I):(A=s_(P),A.c(),A.m(e,i)):A&&(A.d(1),A=null),P[27].length?L?L.p(P,I):(L=o_(P),L.c(),L.m(e,s)):L&&(L.d(1),L=null),(!w||I[0]&67108864)&&pt(o,"tab-active",P[26]===_n.SETTINGS);const x={};I[0]&2048&&(x.showMenu=P[11]),c.$set(x),(!w||I[0]&67108864)&&pt(l,"hidden",P[26]!==_n.AUDIOBOOK),(!w||I[0]&67108864)&&pt(l,"flex",P[26]===_n.AUDIOBOOK),(!w||I[0]&67108864)&&pt(f,"hidden",P[26]!==_n.MATCH),(!w||I[0]&67108864)&&pt(_,"hidden",P[26]!==_n.CHAPTERS),(!w||I[0]&67108864)&&pt(p,"hidden",P[26]!==_n.SETTINGS)},i(P){w||(Z(c.$$.fragment,P),Z(g.$$.fragment,P),Z(b.$$.fragment,P),Z(m.$$.fragment,P),w=!0)},o(P){ne(c.$$.fragment,P),ne(g.$$.fragment,P),ne(b.$$.fragment,P),ne(m.$$.fragment,P),w=!1},d(P){P&&(de(e),de(a),de(l),de(u),de(f),de(v),de(_),de(y),de(p)),A&&A.d(),L&&L.d(),t[91](null),we(c),we(g),we(b),we(m),C=!1,vn(h)}}}function s_(t){let e,n,r;return{c(){e=_e("button"),e.textContent=`${_n.MATCH}`,ie(e,"title","Switch to Match tab"),pt(e,"tab-active",t[26]===_n.MATCH)},m(i,s){he(i,e,s),n||(r=Xe(e,"click",t[88]),n=!0)},p(i,s){s[0]&67108864&&pt(e,"tab-active",i[26]===_n.MATCH)},d(i){i&&de(e),n=!1,r()}}}function o_(t){let e,n,r;return{c(){e=_e("button"),e.textContent=`${_n.CHAPTERS}`,ie(e,"title","Switch to Chapters tab"),pt(e,"tab-active",t[26]===_n.CHAPTERS)},m(i,s){he(i,e,s),n||(r=Xe(e,"click",t[89]),n=!0)},p(i,s){s[0]&67108864&&pt(e,"tab-active",i[26]===_n.CHAPTERS)},d(i){i&&de(e),n=!1,r()}}}function p7(t){var X,re;let e,n,r,i,s,o,a,l,c,u,f,g=(t[1]||t[16])+"",v,_,b,y,p,m,w,C,h,A,L,$,P,I,x,ae,V,E,F,N,Y,K,J,j,B;n=new kt({props:{path:Ag}});let M=t[3]&&r_(t);s=new pv({});let S={range:t[0],subtitle:t[14]};a=new Jv({props:S}),t[81](a),a.$on("close",t[82]),p=new kt({props:{path:Nd}}),C=new _i({props:{$$slots:{icon:[h7],default:[d7]},$$scope:{ctx:t}}}),L=new kt({props:{path:Lg}}),x=new kt({props:{path:Mg}}),E=new kt({props:{path:hg}});let R=!t[1]&&((X=t[20])==null?void 0:X.elementHtml)&&((re=t[17])==null?void 0:re.title)&&i_(t);return{c(){e=_e("button"),ye(n.$$.fragment),r=me(),M&&M.c(),i=me(),ye(s.$$.fragment),o=me(),ye(a.$$.fragment),l=me(),c=_e("div"),u=_e("div"),f=_e("button"),v=Nt(g),_=me(),b=_e("div"),y=_e("button"),ye(p.$$.fragment),m=me(),w=_e("div"),ye(C.$$.fragment),h=me(),A=_e("button"),ye(L.$$.fragment),P=me(),I=_e("button"),ye(x.$$.fragment),ae=me(),V=_e("button"),ye(E.$$.fragment),F=me(),N=_e("div"),R&&R.c(),Y=me(),K=_e("div"),K.innerHTML='<span class="spinner"></span>',ie(e,"class","h-full hover:opacity-70"),pt(e,"text-red-500",t[1]||t[16]),pt(e,"animate-pulse",t[1]||t[16]),ie(y,"title","Close menu"),pt(y,"m-l-b",t[13]),pt(y,"m-r-b",!t[13]),ie(w,"title","Getting started"),pt(w,"m-l-b",t[13]),pt(w,"m-r-b",!t[13]),ie(A,"title",$=`Switch menu position to ${t[13]?"right":"left"}`),ie(A,"class","side-menu-only"),pt(A,"m-l-s",t[13]),pt(A,"m-r-s",!t[13]),ie(I,"title","Reset menu width"),ie(I,"class","side-menu-only"),pt(I,"m-l-s",t[13]),pt(I,"m-r-s",!t[13]),ie(V,"title","Resize menu width"),ie(V,"class","resize-cursor side-menu-only"),pt(V,"m-l-s",t[13]),pt(V,"m-r-s",!t[13]),ie(b,"class","flex right-menu"),pt(b,"left-menu",t[13]),ie(u,"class","flex justify-between right-menu p-4 break-all"),pt(u,"left-menu",t[13]),ie(N,"class","flex flex-col flex-1 p-x-b p-y-s"),pt(N,"overflow-auto",t[26]===_n.SETTINGS||t[26]===_n.CHAPTERS),ie(K,"class","backdrop"),pt(K,"hidden",!t[15]),ie(c,"class","ttu-whispersync-container side-menu flex-col justify-between fixed top-0 left-0 h-full writing-horizontal-tb z-[60]"),pt(c,"left-0",t[13]),pt(c,"right-0",!t[13]),pt(c,"hidden",!t[11]),pt(c,"flex",t[11]),Cr(c,"width",t[12]||null)},m(W,z){he(W,e,z),be(n,e,null),he(W,r,z),M&&M.m(W,z),he(W,i,z),be(s,W,z),he(W,o,z),be(a,W,z),he(W,l,z),he(W,c,z),oe(c,u),oe(u,f),oe(f,v),oe(u,_),oe(u,b),oe(b,y),be(p,y,null),oe(b,m),oe(b,w),be(C,w,null),oe(b,h),oe(b,A),be(L,A,null),oe(b,P),oe(b,I),be(x,I,null),oe(b,ae),oe(b,V),be(E,V,null),oe(c,F),oe(c,N),R&&R.m(N,null),oe(c,Y),oe(c,K),t[94](c),J=!0,j||(B=[Xe(n_,"resize",t[51]),Xe(n_,"keydown",t[50]),Xe(e,"click",Ra(t[79])),Xe(f,"click",t[83]),Xe(y,"click",t[84]),Xe(A,"click",t[85]),Xe(I,"click",t[86]),Xe(V,"pointerdown",zl(t[52])),Xe(c,"wheel",Ra(t[78]),{passive:!0})],j=!0)},p(W,z){var Ee,ve;(!J||z[0]&65538)&&pt(e,"text-red-500",W[1]||W[16]),(!J||z[0]&65538)&&pt(e,"animate-pulse",W[1]||W[16]),W[3]?M?(M.p(W,z),z[0]&8&&Z(M,1)):(M=r_(W),M.c(),Z(M,1),M.m(i.parentNode,i)):M&&(jt(),ne(M,1,1,()=>{M=null}),zt());const le={};z[0]&1&&(le.range=W[0]),z[0]&16384&&(le.subtitle=W[14]),a.$set(le),(!J||z[0]&65538)&&g!==(g=(W[1]||W[16])+"")&&cn(v,g),(!J||z[0]&8192)&&pt(y,"m-l-b",W[13]),(!J||z[0]&8192)&&pt(y,"m-r-b",!W[13]);const Me={};z[5]&16&&(Me.$$scope={dirty:z,ctx:W}),C.$set(Me),(!J||z[0]&8192)&&pt(w,"m-l-b",W[13]),(!J||z[0]&8192)&&pt(w,"m-r-b",!W[13]),(!J||z[0]&8192&&$!==($=`Switch menu position to ${W[13]?"right":"left"}`))&&ie(A,"title",$),(!J||z[0]&8192)&&pt(A,"m-l-s",W[13]),(!J||z[0]&8192)&&pt(A,"m-r-s",!W[13]),(!J||z[0]&8192)&&pt(I,"m-l-s",W[13]),(!J||z[0]&8192)&&pt(I,"m-r-s",!W[13]),(!J||z[0]&8192)&&pt(V,"m-l-s",W[13]),(!J||z[0]&8192)&&pt(V,"m-r-s",!W[13]),(!J||z[0]&8192)&&pt(b,"left-menu",W[13]),(!J||z[0]&8192)&&pt(u,"left-menu",W[13]),!W[1]&&((Ee=W[20])!=null&&Ee.elementHtml)&&((ve=W[17])!=null&&ve.title)?R?(R.p(W,z),z[0]&1179650&&Z(R,1)):(R=i_(W),R.c(),Z(R,1),R.m(N,null)):R&&(jt(),ne(R,1,1,()=>{R=null}),zt()),(!J||z[0]&67108864)&&pt(N,"overflow-auto",W[26]===_n.SETTINGS||W[26]===_n.CHAPTERS),(!J||z[0]&32768)&&pt(K,"hidden",!W[15]),(!J||z[0]&8192)&&pt(c,"left-0",W[13]),(!J||z[0]&8192)&&pt(c,"right-0",!W[13]),(!J||z[0]&2048)&&pt(c,"hidden",!W[11]),(!J||z[0]&2048)&&pt(c,"flex",W[11]),z[0]&4096&&Cr(c,"width",W[12]||null)},i(W){J||(Z(n.$$.fragment,W),Z(M),Z(s.$$.fragment,W),Z(a.$$.fragment,W),Z(p.$$.fragment,W),Z(C.$$.fragment,W),Z(L.$$.fragment,W),Z(x.$$.fragment,W),Z(E.$$.fragment,W),Z(R),J=!0)},o(W){ne(n.$$.fragment,W),ne(M),ne(s.$$.fragment,W),ne(a.$$.fragment,W),ne(p.$$.fragment,W),ne(C.$$.fragment,W),ne(L.$$.fragment,W),ne(x.$$.fragment,W),ne(E.$$.fragment,W),ne(R),J=!1},d(W){W&&(de(e),de(r),de(i),de(o),de(l),de(c)),we(n),M&&M.d(W),we(s,W),t[81](null),we(a,W),we(p),we(C),we(L),we(x),we(E),R&&R.d(),t[94](null),j=!1,vn(B)}}}const Lc="ttu-whispersync-side-menu-width";function m7(t,e,n){let r,i,s,o,a,l,c,u,f,g,v,_,b,y,p,m,w,C,h,A,L,$,P,I,x,ae,V,E,F,N,Y,K,J,j,B,M,S,R,X,re,W,z,le,Me,Ee,ve,ke,Ne,Te,Le,Fe,Ze,O,H,Pe,xe,qe,nt,Oe,je,et,rt,Je,G,T,d,k,D,U,te,ee,se;ce(t,Ka,Se=>n(14,a=Se)),ce(t,Lr,Se=>n(4,f=Se)),ce(t,Fa,Se=>n(104,v=Se)),ce(t,At,Se=>n(15,_=Se)),ce(t,Mt,Se=>n(16,b=Se)),ce(t,Rr,Se=>n(17,y=Se)),ce(t,ls,Se=>n(18,p=Se)),ce(t,rs,Se=>n(62,C=Se)),ce(t,Na,Se=>n(107,h=Se)),ce(t,qs,Se=>n(108,A=Se)),ce(t,nu,Se=>n(109,L=Se)),ce(t,En,Se=>n(111,P=Se)),ce(t,Ui,Se=>n(19,I=Se)),ce(t,Li,Se=>n(20,x=Se)),ce(t,xo,Se=>n(5,ae=Se)),ce(t,Ho,Se=>n(112,V=Se)),ce(t,uu,Se=>n(63,E=Se)),ce(t,as,Se=>n(21,N=Se)),ce(t,vi,Se=>n(64,K=Se)),ce(t,Mn,Se=>n(115,J=Se)),ce(t,xi,Se=>n(65,j=Se)),ce(t,os,Se=>n(116,M=Se)),ce(t,Ha,Se=>n(67,S=Se)),ce(t,Va,Se=>n(68,R=Se)),ce(t,Xo,Se=>n(117,X=Se)),ce(t,ss,Se=>n(118,re=Se)),ce(t,is,Se=>n(119,W=Se)),ce(t,Ps,Se=>n(70,le=Se)),ce(t,ru,Se=>n(72,Ee=Se)),ce(t,au,Se=>n(120,ve=Se)),ce(t,su,Se=>n(121,ke=Se)),ce(t,Xa,Se=>n(122,Ne=Se)),ce(t,za,Se=>n(123,Te=Se)),ce(t,zo,Se=>n(124,Le=Se)),ce(t,jo,Se=>n(125,Fe=Se)),ce(t,Go,Se=>n(126,Ze=Se)),ce(t,Wo,Se=>n(127,O=Se)),ce(t,Uo,Se=>n(128,H=Se)),ce(t,ja,Se=>n(129,Pe=Se)),ce(t,Ga,Se=>n(130,xe=Se)),ce(t,Wa,Se=>n(131,qe=Se)),ce(t,Ua,Se=>n(132,nt=Se)),ce(t,xa,Se=>n(133,Oe=Se)),ce(t,md,Se=>n(7,T=Se)),ce(t,Js,Se=>n(26,ee=Se)),ce(t,Zs,Se=>n(27,se=Se));let{componentContainerElement:ge}=e,{bookContentElement:pe}=e,{sandboxElement:Ae}=e,{currentBookId:Ce}=e;const De="showOpenFilePicker"in window,tt=(window.localStorage.getItem("writingMode")||"vertical-rl")==="vertical-rl",mt=(window.localStorage.getItem("viewMode")||"paginated")==="paginated",We=`-${window.localStorage.getItem("firstDimensionMargin")||0}px`,dt=mt?void 0:new IntersectionObserver(Sa,{rootMargin:tt?`0px ${We} 0px ${We}`:`${We} 0px ${We} 0px`}),Be=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="iPad"||navigator.platform==="iPhone"||navigator.platform==="iPod",{readerEnableAutoReload$:$e,readerEnableFilesystemApi$:ft,readerPreventActionOnSelection$:ze,readerEnableMenuTarget$:at,readerClickAction$:Qe,readerMenuOpenMode$:vt,readerMenuPauseMode$:Rt,readerMenuOpenTime$:lt,subtitlesGlobalStartPadding$:St,subtitlesGlobalEndPadding$:ht,playerAltRewindTime$:xt,playerRewindTime$:ln,playerFastForwardTime$:qt,playerAltFastForwardTime$:Dt,ankiUrl$:rn,ankiDeck$:In,ankiModel$:Hn,ankiSoundField$:xn,ankiSentenceField$:Xt,exportAudioProcessor$:Ft,actionListOfFooter$:Wt,keybindingsEnableTimeFallback$:un}=_t;ce(t,$e,Se=>n(110,$=Se)),ce(t,ft,Se=>n(77,d=Se)),ce(t,ze,Se=>n(102,u=Se)),ce(t,at,Se=>n(114,Y=Se)),ce(t,Qe,Se=>n(60,l=Se)),ce(t,vt,Se=>n(61,c=Se)),ce(t,Rt,Se=>n(66,B=Se)),ce(t,lt,Se=>n(103,g=Se)),ce(t,St,Se=>n(106,w=Se)),ce(t,ht,Se=>n(105,m=Se)),ce(t,xt,Se=>n(22,k=Se)),ce(t,ln,Se=>n(23,D=Se)),ce(t,qt,Se=>n(24,U=Se)),ce(t,Dt,Se=>n(25,te=Se)),ce(t,rn,Se=>n(76,G=Se)),ce(t,In,Se=>n(75,Je=Se)),ce(t,Hn,Se=>n(74,rt=Se)),ce(t,xn,Se=>n(71,Me=Se)),ce(t,Xt,Se=>n(69,z=Se)),ce(t,Ft,Se=>n(73,et=Se)),ce(t,Wt,Se=>n(6,je=Se)),ce(t,un,Se=>n(113,F=Se));let Ye,ut,yr,Xn,Yt,sr,Qn=!1,Un="",vr=window.matchMedia("(min-width: 1000px)").matches&&window.localStorage.getItem(Lc)||"",dr=0,hn=0,Gr=0,pn=0,or;fe(Fa,v=navigator.maxTouchPoints>0,v),b_("context",{bookContentElement:pe,sandboxElement:Ae,isVertical:tt,isPaginated:mt,supportsFileSystem:De,isIOS:Be}),Oa(It),Yl(()=>{Zt(),document.removeEventListener("ttsu:skipKeyListener",Bt,!1),document.removeEventListener("ttsu:page.change",$t,!1),dt==null||dt.disconnect(),K&&K.abort("user aborted"),Os(A,h)});function Or(Se){var lr;if(P||Se.repeat||!(Se.ctrlKey||Se.metaKey||Se.altKey))return;const Lt=Se.code||((lr=Se.key)==null?void 0:lr.toLowerCase()),Ln=Y&&c!==tr.DISABLED?a:void 0;let fn,kn=Ln||f.get(N.current||N.previous);if(!kn&&F&&(kn=[...f.values()].findLast(Er=>I>=Er.startSeconds)),Se.altKey)switch(Lt){case"KeyE":case"e":fn=Re.EXPORT_UPDATE;break;case"KeyG":case"g":fn=Re.EDIT_SUBTITLE;break;case"KeyZ":case"z":fn=Re.COPY_SUBTITLE;break;case"KeyH":case"h":fn=Re.NONE,fe(uu,E=!E,E);break;default:fn=Re.NONE;break}else switch(Lt){case"KeyB":case"b":fn=Re.TOGGLE_BOOKMARK;break;case"KeyM":case"m":fn=Re.TOGGLE_MERGE;break;case"KeyE":case"e":fn=Re.EXPORT_NEW;break;case"KeyO":case"o":kn=an(0),fn=Re.OPEN_LAST_EXPORTED_CARD;break;default:fn=Re.NONE;break}fn!==Re.NONE&&(Se.preventDefault(),Se.stopPropagation(),Fn(fn,kn))}function oi(){window.clearTimeout(or),or=window.setTimeout(()=>{or=void 0,n(12,vr=window.matchMedia("(min-width: 1000px)").matches&&window.localStorage.getItem(Lc)||""),ut==null||ut.resetSubtitleContainerHeight(),ut==null||ut.scrollToSubtitle()},1e3)}function Wn(Se){dr=Ye.getBoundingClientRect().width,hn=Se.pageX,window.addEventListener("pointermove",jr,!1),window.addEventListener("pointerup",Ve,!1)}function jr(Se){n(12,vr=r?`${dr+(Se.pageX-hn)}px`:`${dr-(Se.pageX-hn)}px`)}function Ve(){window.removeEventListener("pointermove",jr,!1),window.removeEventListener("pointerup",Ve,!1),window.localStorage.setItem(Lc,vr),ut==null||ut.resetSubtitleContainerHeight()}async function It(){let Se;document.addEventListener("ttsu:skipKeyListener",Bt,!1),fe(At,_=!0,_);try{if(!V){const Er=await new Promise((js,ts)=>{document.addEventListener("ttsu:db.version",({detail:Oc})=>{if(Oc>5)return js(Oc);ts(new Error("Invalid ttu version"))},{once:!0,capture:!1}),document.dispatchEvent(new CustomEvent("ttu-action",{detail:{type:"dbVersion"}})),setTimeout(()=>ts(new Error("Invalid ttu version")),5e3)});await Cv(Er)}await new Promise(Er=>{document.addEventListener("ttsu:synced",Er,{once:!0,capture:!1}),document.dispatchEvent(new CustomEvent("ttu-action",{detail:{type:"waitForSync"}}))});const Lt=await V.get("data",Ce);if(!Lt||!Lt.title||!Lt.elementHtml&&!Lt.storageSource)throw new Error(`required data for id ${Ce} not found`);if(!Lt.elementHtml&&Lt.storageSource)throw new Error("books from external storage sources are currently not supported");Se=hu(new DOMParser,Lt.elementHtml);const Ln=Se.firstElementChild,[fn,kn,lr,li]=await Promise.all([V.get("audioBook",Lt.title),V.get("subtitle",Lt.title),...L?[V.get("handle",[Lt.title,"audioBook"]),V.get("handle",[Lt.title,"subtitle"])]:[]]);Ln instanceof HTMLElement&&fe(xo,ae={matchedBy:Ln.dataset.ttuWhispersyncMatchedBy||"",matchedOn:Number.parseInt(Ln.dataset.ttuWhispersyncMatchedOn||"0",10)},ae),fe(Li,x=Lt,x),fe(Rr,y={title:Lt.title,lastAudio:(lr==null?void 0:lr.handle)instanceof FileSystemFileHandle?lr.handle:void 0,lastSubtitle:(li==null?void 0:li.handle)instanceof FileSystemFileHandle?li.handle:void 0,playbackPosition:(fn==null?void 0:fn.playbackPosition)||0,subtitleData:kn==null?void 0:kn.subtitleData},y),fe(Ui,I=(fn==null?void 0:fn.playbackPosition)||0,I)}catch({message:Lt}){n(1,Un=`Initialization failed: ${Lt}`)}if(Un){fe(At,_=!1,_);return}mt&&document.addEventListener("ttsu:page.change",$t,!1),await tn()}function Bt({detail:Se}){fe(En,P=Se,P)}function $t(){zr()}async function tn(Se=!1){Se&&fe(At,_=!0,_),($||Se)&&await Tn(),await He(!h||Se)}async function Tn(Se=!0){const Lt=!C&&y.lastSubtitle?y.lastSubtitle:void 0,Ln=!h&&y.lastAudio?y.lastAudio:void 0;if(!L||!Lt&&!Ln)return;try{await C0([Lt,Ln])}catch({message:kn}){if(!kn.includes("activation is required"))fe(Mt,b=`Failed to reload file(s): ${kn}`,b);else{if(Se)return!await new Promise(li=>Vo.add({component:L0,props:{dialogHeader:"Reopen files",dialogMessage:"Click confirm to reopen files",isFileReopen:De,resolver:li}}))&&L?Tn(!1):void 0;fe(Mt,b=`Failed to acccess files: ${kn}`,b)}}if(b)return;const fn=[];if(Lt)try{const kn=await Lt.getFile();await Lu(kn,document,!0)}catch({message:kn}){fn.push(`Failed to load subtitle file: ${kn}`),cs()}if(Ln)try{const kn=await Ln.getFile();await Qo(kn,Ae,!0)}catch({message:kn}){fn.push(`Failed to load audio file: ${kn}`),await Os(A,h)}fn.length&&fe(Mt,b=fn.join("; "),b)}async function He(Se=!1){if(b||C||!y.subtitleData||!y.subtitleData.subtitles.length){Se&&fe(At,_=!1,_);return}try{const Lt=new Map,Ln=w/1e3,fn=m/1e3;for(let lr=0,{length:li}=y.subtitleData.subtitles;lr<li;lr+=1){const Er=y.subtitleData.subtitles[lr],js=Math.max(0,Er.adjustedStartSeconds??Er.originalStartSeconds+Ln),ts=p?Wi(0,p,Er.adjustedEndSeconds??Er.originalEndSeconds+fn):Math.max(0,Er.adjustedEndSeconds??Er.originalEndSeconds+fn);Lt.set(Er.id,{...Er,startSeconds:js,startTime:Qr(js),endSeconds:ts,endTime:Qr(ts)})}const kn=new Blob([""],{type:"application/x-subrip;charset=utf-8"});cs(new File([kn],y.subtitleData.name,{type:kn.type}),Lt)}catch({message:Lt}){fe(Mt,b=`Failed to load persisted subtitle: ${Lt}`,b),cs()}Se&&fe(At,_=!1,_)}function Et(Se,Lt,Ln){Zt(),zr(),Se===tr.CLICK||Se===tr.DISABLED&&Lt!==Re.NONE?pe.addEventListener("click",Gt,!1):Se===tr.HOLD&&pe.addEventListener("pointerdown",nn,!1)}function Gt(Se){Se.button!==0||!Br(Se)||Gs()}function nn(Se){var Lt;Se.button!==0||!Br(Se)||(mt||(Gr=tt?Se.pageX:Se.pageY,pn=0,window.addEventListener("pointermove",hr,!1)),u&&v&&((Lt=window.getSelection())==null||Lt.removeAllRanges(),document.body.style.userSelect="none"),pe.addEventListener("pointerup",Pt,!1),yr=window.setTimeout(Gs,g))}function hr(Se){const Lt=tt?Se.pageX:Se.pageY;pn=Math.abs(Lt-Gr)}function Pt(){var Se;On()||((!u||!((Se=window.getSelection())!=null&&Se.toString().trim()))&&(To(),Fn(l,a)),zr())}function Zt(){On(),pe.removeEventListener("click",Gt,!1),pe.removeEventListener("pointerdown",nn,!1)}function On(){return clearTimeout(yr),window.removeEventListener("pointermove",hr,!1),pe.removeEventListener("pointerup",Pt,!1),document.body.style.userSelect="auto",!mt&&pn>10}function Br(Se){const Lt=document.elementFromPoint(Se.x,Se.y),Ln=Lt==null?void 0:Lt.closest(pu());return Ln instanceof HTMLSpanElement?Xn=Ln:sr!=null&&sr.isInReaderMenu(Lt)||zr(),Xn}function zr(Se=!0){const Lt=pe.querySelectorAll(`${pu()}.menu-open`);for(let Ln=0,{length:fn}=Lt;Ln<fn;Ln+=1)Lt[Ln].classList.remove("menu-open");dt==null||dt.disconnect(),Se&&(Xn=void 0,n(0,Yt=void 0),fe(Ka,a=void 0,a))}function To(){if(!Xn)return["",""];const Se=Kc(Xn),Lt=a==null?void 0:a.id;return fe(Ka,a=f.get(Se),a),[Lt,Se]}function Gs(){var li;if(On())return;if(!Xn||u&&((li=window.getSelection())!=null&&li.toString().trim()))return zr();if(c===tr.DISABLED&&l!==Re.NONE)return Pt();const[Se,Lt]=To();if(Se===Lt)return;const Ln=[...pe.querySelectorAll(Qs(Lt))],fn=Ln[0],kn=Ln[Ln.length-1],lr=document.createRange();lr.setStart(fn,0),lr.setEnd(kn,kn.childNodes.length),zr(!1);for(let Er=0,{length:js}=Ln;Er<js;Er+=1)Ln[Er].classList.add("menu-open");n(0,Yt=lr),dt==null||dt.observe(kn)}function Sa(Se){Se.every(Lt=>!Lt.isIntersecting)&&zr()}function Nl(Se){a&&fe(Ka,a=Se.get(a.id),a)}function ko(Se){mn.call(this,t,Se)}const Vl=()=>{n(11,Qn=!0),!Un&&!_&&tn(!0)},Ta=({detail:Se})=>{Se===Re.REWIND_ALT?Fn(Re.RESTART_PLAYBACK,an(Math.max(0,I-k)),{keepPauseState:!0}):Se===Re.REWIND?Fn(Re.RESTART_PLAYBACK,an(Math.max(0,I-D)),{keepPauseState:!0}):Se===Re.FAST_FORWARD?Fn(Re.RESTART_PLAYBACK,an(Math.min(p,I+U)),{keepPauseState:!0}):Se===Re.FAST_FORWARD_ALT&&Fn(Re.RESTART_PLAYBACK,an(Math.min(p,I+te)),{keepPauseState:!0})};function Hl(Se){Vt[Se?"unshift":"push"](()=>{sr=Se,n(10,sr)})}const xl=()=>zr(),Ul=()=>fe(Mt,b="",b),Ue=()=>n(11,Qn=!1),pr=()=>fe(md,T=r?"right":"left",T),ar=()=>{n(12,vr=`${36*parseFloat(window.getComputedStyle(document.documentElement).fontSize)}px`),window.localStorage.removeItem(Lc),ut==null||ut.resetSubtitleContainerHeight()},ai=()=>fe(Js,ee=_n.AUDIOBOOK,ee),mr=()=>fe(Js,ee=_n.MATCH,ee),Xr=()=>fe(Js,ee=_n.CHAPTERS,ee),es=()=>fe(Js,ee=_n.SETTINGS,ee);function ka(Se){Vt[Se?"unshift":"push"](()=>{ut=Se,n(9,ut)})}const Aa=()=>n(11,Qn=!1),As=()=>n(11,Qn=!0);function Wl(Se){Vt[Se?"unshift":"push"](()=>{Ye=Se,n(8,Ye)})}return t.$$set=Se=>{"componentContainerElement"in Se&&n(55,ge=Se.componentContainerElement),"bookContentElement"in Se&&n(56,pe=Se.bookContentElement),"sandboxElement"in Se&&n(57,Ae=Se.sandboxElement),"currentBookId"in Se&&n(58,Ce=Se.currentBookId)},t.$$.update=()=>{t.$$.dirty[2]&32768&&fe(nu,L=De&&d,L),t.$$.dirty[0]&128&&n(13,r=T==="left"),t.$$.dirty[2]&29568&&fe(ru,Ee=!!G&&!!Je&&!!rt&&!!(Me&&le||z),Ee),t.$$.dirty[2]&2052&&fe(xi,j=et===kr.RECORDER&&!!K,j),t.$$.dirty[0]&64&&n(59,i=je.filter(Se=>Se.enabled)),t.$$.dirty[1]&268435456|t.$$.dirty[2]&4&&n(2,s=!!K&&!!i.find(({action:Se})=>Se===Re.EXPORT_NEW||Se===Re.EXPORT_UPDATE)),t.$$.dirty[1]&268435456|t.$$.dirty[2]&2&&n(3,o=i.length&&!E),t.$$.dirty[0]&12|t.$$.dirty[1]&268435456&&n(55,ge.style.width=o?`${1.9+1.9*i.length+(s?1.9:0)}rem`:"1.9rem",ge),t.$$.dirty[2]&264&&(le?j?(fe(xa,Oe="Recording in progress",Oe),fe(Ua,nt="Recording in progress",nt),fe(Wa,qe="Recording in progress",qe),fe(Ga,xe="Recording in progress",xe),fe(ja,Pe="Recording in progress",Pe)):(fe(xa,Oe=Re.TOGGLE_PLAYBACK,Oe),fe(Ua,nt=Re.REWIND,nt),fe(Wa,qe=Re.REWIND_ALT,qe),fe(Ga,xe=Re.FAST_FORWARD,xe),fe(ja,Pe=Re.FAST_FORWARD_ALT,Pe)):(fe(xa,Oe="Audio file required",Oe),fe(Ua,nt="Audio file required",nt),fe(Wa,qe="Audio file required",qe),fe(Ga,xe="Audio file required",xe),fe(ja,Pe="Audio file required",Pe))),t.$$.dirty[0]&16|t.$$.dirty[2]&264&&(f.size?le?j?(fe(Uo,H="Recording in progress",H),fe(Wo,O="Recording in progress",O),fe(Go,Ze="Recording in progress",Ze),fe(jo,Fe="Recording in progress",Fe),fe(zo,Le="Recording in progress",Le)):(fe(Uo,H=Re.PREVIOUS_SUBTITLE,H),fe(Wo,O=Re.NEXT_SUBTITLE,O),fe(Go,Ze=Re.RESTART_PLAYBACK,Ze),fe(jo,Fe=Re.TOGGLE_PLAY_PAUSE,Fe),fe(zo,Le=Re.TOGGLE_PLAYBACK_LOOP,Le)):(fe(Uo,H="Audio file required",H),fe(Wo,O="Audio file required",O),fe(Go,Ze="Audio file required",Ze),fe(jo,Fe="Audio file required",Fe),fe(zo,Le="Audio file required",Le)):(fe(Uo,H="Subtitle file required",H),fe(Wo,O="Subtitle file required",O),fe(Go,Ze="Subtitle file required",Ze),fe(jo,Fe="Subtitle file required",Fe),fe(zo,Le="Subtitle file required",Le))),t.$$.dirty[0]&16|t.$$.dirty[2]&4&&(f.size?K?(fe(za,Te="Export in progress",Te),fe(Xa,Ne="Export in progress",Ne)):(fe(za,Te=Re.EDIT_SUBTITLE,Te),fe(Xa,Ne=Re.RESTORE_SUBTITLE,Ne)):(fe(za,Te="Subtitle file required",Te),fe(Xa,Ne="Subtitle file required",Ne))),t.$$.dirty[0]&16&&(f.size?(fe(su,ke=Re.TOGGLE_BOOKMARK,ke),fe(au,ve=Re.TOGGLE_MERGE,ve)):(fe(su,ke="Subtitle file required",ke),fe(au,ve="Subtitle file required",ve))),t.$$.dirty[0]&16|t.$$.dirty[2]&1924&&(Ee?f.size?Me&&!le&&!z?(fe(is,W="Audio file required",W),fe(ss,re="Audio file required",re)):K?(fe(is,W="Export in progress",W),fe(ss,re="Export in progress",re),fe(Xo,X=Re.CANCEL_EXPORT,X)):(fe(is,W=Re.EXPORT_NEW,W),fe(ss,re=Re.EXPORT_UPDATE,re),fe(Xo,X="Export not started",X)):(fe(is,W="Subtitle file required",W),fe(ss,re="Subtitle file required",re)):(fe(is,W="Anki configuration required",W),fe(ss,re="Anki configuration required",re))),t.$$.dirty[2]&100&&(R?fe(os,M="Device not supported",M):K?fe(os,M="Export in progress",M):S?fe(os,M=Re.OPEN_LAST_EXPORTED_CARD,M):fe(os,M="No card exported",M)),t.$$.dirty[0]&34|t.$$.dirty[1]&1610612736|t.$$.dirty[2]&1&&!Un&&ae.matchedBy&&Et(c,l),t.$$.dirty[0]&1|t.$$.dirty[2]&24&&Yt&&B===Ql.PAUSE&&!j&&fe(Mn,J=!0,J),t.$$.dirty[0]&16&&Nl(f)},[Yt,Un,s,o,f,ae,je,T,Ye,ut,sr,Qn,vr,r,a,_,b,y,p,I,x,N,k,D,U,te,ee,se,$e,ft,ze,at,Qe,vt,Rt,lt,St,ht,xt,ln,qt,Dt,rn,In,Hn,xn,Xt,Ft,Wt,un,Or,oi,Wn,tn,zr,ge,pe,Ae,Ce,i,l,c,C,E,K,j,B,S,R,z,le,Me,Ee,et,rt,Je,G,d,ko,Vl,Ta,Hl,xl,Ul,Ue,pr,ar,ai,mr,Xr,es,ka,Aa,As,Wl]}class _7 extends Dn{constructor(e){super(),Bn(this,e,m7,p7,Cn,{componentContainerElement:55,bookContentElement:56,sandboxElement:57,currentBookId:58},null,[-1,-1,-1,-1,-1,-1])}}const g7=".ttu-whispersync-container,.ttu-whispersync-container input:not([type=checkbox]),.ttu-whispersync-container select,.ttu-whispersync-container .player-progress-tooltip{background-color:var(--ttu-whispersync-background-color);color:var(--ttu-whispersync-color)}.ttu-whispersync-container .tabs button:not(.tab-active),.ttu-whispersync-container button:disabled,.ttu-whispersync-container .btn:not(:disabled):hover,.ttu-whispersync-container button.inactive-chapter{opacity:.5}.ttu-whispersync-container button:not(:disabled):hover,.ttu-whispersync-container .dropzone:hover{opacity:.7}.ttu-whispersync-container button{text-align:left}.ttu-whispersync-container button:disabled,.ttu-whispersync-container select:disabled,.ttu-whispersync-container button:disabled [role=button]{cursor:not-allowed}.ttu-whispersync-container .m-b{margin:1rem}.ttu-whispersync-container .m-y-xs{margin-top:.25rem;margin-bottom:.25rem}.ttu-whispersync-container .m-y-s{margin-top:.5rem;margin-bottom:.5rem}.ttu-whispersync-container .m-y-b{margin-top:1rem;margin-bottom:1rem}.ttu-whispersync-container .m-x-xs{margin-left:.25rem;margin-right:.25rem}.ttu-whispersync-container .m-x-s{margin-left:.5rem;margin-right:.5rem}.ttu-whispersync-container .m-t-xs{margin-top:.25rem}.ttu-whispersync-container .m-t-s{margin-top:.5rem}.ttu-whispersync-container .m-t-b{margin-top:1rem}.ttu-whispersync-container .m-r-s{margin-right:.5rem}.ttu-whispersync-container .m-r-b{margin-right:.75rem}.ttu-whispersync-container .m-b-s{margin-bottom:.5rem}.ttu-whispersync-container .m-l-s{margin-left:.5rem}.ttu-whispersync-container .m-l-b{margin-left:.75rem}.ttu-whispersync-container .p-s{padding:.5rem}.ttu-whispersync-container .p-b{padding:1rem}.ttu-whispersync-container .p-y-s{padding-top:.5rem;padding-bottom:.5rem}.ttu-whispersync-container .p-y-xs{padding-top:.25rem;padding-bottom:.25rem}.ttu-whispersync-container .p-x-xs{padding-left:.25rem;padding-right:.25rem}.ttu-whispersync-container .p-x-b{padding-right:1rem;padding-left:1rem}.ttu-whispersync-container .backdrop{flex-direction:column;position:absolute;width:100%;height:100%;top:0;left:0;z-index:100;background-color:#00000052;justify-content:center;align-items:center}.ttu-whispersync-container .backdrop:not(.hidden){display:flex}.ttu-whispersync-container .backdrop .spinner{width:48px;height:48px;border:5px solid;border-radius:50%;border-bottom-color:var(--ttu-whispersync-background-color);display:inline-block;box-sizing:border-box;animation:ttu-whispersync-spinner-rotation 1s linear infinite}.ttu-whispersync-dialog{z-index:70}.ttu-whispersync-container .slot-content{max-height:70vh;overflow:auto}.ttu-whispersync-container.popover{position:absolute;width:max-content;max-width:100%;top:0;left:0;padding:.25rem;margin:.25rem;border:1px solid;border-radius:4px;word-break:break-word;z-index:50;background-color:var(--ttu-whispersync-background-color);color:var(--ttu-whispersync-color)}.ttu-whispersync-container .getting-started{list-style:decimal;padding-left:1.5rem;max-width:75vw}.ttu-whispersync-container .getting-started a{opacity:.5}.ttu-whispersync-container .waveform{width:100;margin:1.5rem 0rem}.ttu-whispersync-container .waveform ::part(region){opacity:.1}.ttu-whispersync-container .waveform ::part(region active){opacity:.5;z-index:10}.ttu-whispersync-container .time-edit span:not(.m-b){margin:.5rem}.ttu-whispersync-container .time-edit>div{flex-direction:column;align-items:center}.ttu-whispersync-container .time-input{width:70px;height:35px;text-align:center}.ttu-whispersync-container .side-menu-only{display:none}.ttu-whispersync-container.side-menu{cursor:initial;width:100vw;border:1px solid}.ttu-whispersync-container div.right-menu{flex-direction:row-reverse}.ttu-whispersync-container div.left-menu{flex-direction:row}.ttu-whispersync-container .resize-cursor,.ttu-whispersync-container .resize-cursor [role=button]{cursor:w-resize}.ttu-whispersync-container.subtitle-container{overflow-y:auto}.ttu-whispersync-container .sub-action.show,.ttu-whispersync-container .sub.on-hover:hover .sub-action{visibility:visible}.ttu-whispersync-container .sub-action .grid,.ttu-whispersync-container .sub.on-hover:hover .sub-action .grid{grid-template-columns:repeat(3,1fr);grid-auto-flow:row;row-gap:.25rem}.ttu-whispersync-container .audio-time{font-size:smaller;font-style:italic}.ttu-whispersync-container .bg-inverted{background-color:var(--ttu-whispersync-color)}.ttu-whispersync-container .bg-inverted>div{background-color:var(--ttu-whispersync-background-color)}.ttu-whispersync-container .color-inverted,.ttu-whispersync-container .color-inverted-hover:hover{background-color:var(--ttu-whispersync-color);color:var(--ttu-whispersync-background-color)}.ttu-whispersync-container .dropzone{border:1px solid transparent}.ttu-whispersync-container .dropzone.on-drag{border-color:var(--ttu-whispersync-color)}.ttu-whispersync-container .tabs button:not(.tab-active):not(:disabled):hover,.ttu-whispersync-container button:not(.recording).inactive-chapter:hover{opacity:1}.ttu-whispersync-container .header-icons{align-items:flex-start;flex-wrap:wrap}.ttu-whispersync-container .cover{width:110px;height:110px;align-self:center;margin-right:1rem}.ttu-whispersync-container .match-btns{z-index:200;position:relative}.ttu-whispersync-container .diff-grid{display:grid;grid-template-columns:auto auto auto;grid-column-gap:2rem;grid-row-gap:.5rem}.ttu-whispersync-container .btn{padding:.4rem;border-radius:5px;border:1px solid}.ttu-whispersync-container .sub{cursor:pointer;border-left:1px solid transparent}.ttu-whispersync-container .sub.active{border-color:var(--ttu-whispersync-color)}.ttu-whispersync-container .player-progress-tooltip{display:none;position:absolute;top:-2rem;border:1px solid}.ttu-whispersync-container .player-progress-tooltip-button:not(.recording){opacity:1!important}.ttu-whispersync-container .playback-rates{display:flex;flex-direction:column;width:6rem;align-items:center}.ttu-whispersync-container .playback-rates input{writing-mode:vertical-lr;direction:rtl;-webkit-appearance:slider-vertical;-moz-appearance:slider-vertical;appearance:slider-vertical}.ttu-whispersync-container .playback-display{width:100%;justify-content:space-between;align-items:end}.ttu-whispersync-container details{margin-bottom:1rem}.ttu-whispersync-container summary{cursor:pointer}.ttu-whispersync-container .settings-grid{display:grid;grid-template-columns:1fr 200px .2fr;gap:.75rem;align-items:center;margin-right:.5rem}.ttu-whispersync-container .pos-nav{display:grid;grid-template-columns:auto auto auto;row-gap:1rem}.ttu-whispersync-container .truncate{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ttu-whispersync-container.reader-menu.flex-col:not(.hidden){display:flex}.ttu-whispersync-container.reader-menu:not(.hidden,.flex-col){display:grid;grid-template-columns:repeat(8,.75fr);row-gap:.25rem}.ttu-whispersync-container .sortable-list-container,.ttu-whispersync-container .sortable-list-icons{grid-column:1/4;width:90%}.ttu-whispersync-container .sortable-list-icons{display:flex;justify-content:end}.ttu-whispersync-container .sortable-list-item{border:1px solid var(--ttu-whispersync-color);margin:.25rem 0;padding:.5rem;cursor:grab;display:flex;align-items:center;justify-content:space-between}.ttu-whispersync-container .sortable-list-item.swap{opacity:.2}@keyframes ttu-whispersync-spinner-rotation{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@media screen and (min-width: 550px){.ttu-whispersync-container.reader-menu:not(.hidden){display:flex}}@media screen and (min-width: 1000px){.ttu-whispersync-container .diff-grid{max-width:70vw}.ttu-whispersync-container .time-edit>div{flex-direction:row}.ttu-whispersync-container .side-menu-only{display:block}.ttu-whispersync-container.side-menu{width:36rem;min-width:425px;max-width:40vw}.ttu-whispersync-container .header-icon{display:block}.ttu-whispersync-container .cover{width:160px;height:160px}.ttu-whispersync-container .waveform{width:70vw}.ttu-whispersync-container .player-progress-tooltip-button:not(.recording):hover .player-progress-tooltip{display:block;text-align:center}}";let ed=!1,td=0,Pc,$l;async function a_(){var n;if($l)return;$l=window.setTimeout(()=>$l=void 0,1e3);const t=new URL(window.location.href),e=t.href.startsWith("https://reader.ttsu.app/b")||t.href.startsWith("http://localhost:5173/b")?t.searchParams.has("id"):!1;if(e&&!ed){ed=!0;let r=document.querySelector(".book-content");await new Promise(y=>{if(r)return y();const p=setInterval(()=>{r=document.querySelector(".book-content"),r&&(clearInterval(p),y())},500)});const i=document.querySelector(".z-10.flex.h-8.w-full");if(!r||!i||!i.firstElementChild)return;const s=window.localStorage.getItem("ttu-whispersync-reader-footer-actions");if(s){const y=JSON.parse(s),p=[];for(let m=0,{length:w}=y;m<w;m+=1){const C=y[m];jc.has(C)&&p.push({action:C,enabled:!0})}window.localStorage.setItem("ttu-whispersync-action-list-of-footer",JSON.stringify(p)),window.localStorage.removeItem("ttu-whispersync-reader-footer-actions")}td=Number.parseInt(t.searchParams.get("id")||"0",10);const o=document.querySelector(":root"),a=document.createElement("div"),l="ttu-whispersync-styles",c="ttu-whispersync-sandbox",[u,f,g]=(((n=r.style.color.match(/rgb[a]{0,1}\((.+)\)/))==null?void 0:n[1])||"0,0,0,1").split(",").map(y=>parseFloat(y.trim()));let v=document.getElementById(c),_=document.getElementById(l),b="";_||(_=document.createElement("style"),_.id=l,_.innerText=g7,document.head.appendChild(_)),!v&&window.chrome&&chrome.runtime&&chrome.runtime.id&&(v=document.createElement("iframe"),v.id=c,v.style.display="none",v.src=chrome.runtime.getURL("src/sandbox/sandbox.html"),await new Promise(y=>{v.addEventListener("load",y,!1),document.body.appendChild(v)})),a.classList.add("flex","h-full","items-center","justify-center","text-sm","sm:text-lg"),a.addEventListener("click",b7,!1),i.classList.remove("justify-between"),i.firstElementChild.insertAdjacentElement("beforebegin",a),await new Promise(y=>{const p=setInterval(()=>{b=document.body.style.backgroundColor,b&&(clearInterval(p),y())},500)}),o.style.setProperty("--ttu-whispersync-background-color",b),o.style.setProperty("--ttu-whispersync-color",`rgb(${u},${f},${g})`),Pc=new _7({target:a,props:{componentContainerElement:a,bookContentElement:r,sandboxElement:v,currentBookId:td}})}else e||(Pc==null||Pc.$destroy(),clearTimeout($l),td=0,ed=!1,$l=void 0)}function b7(t){t.stopPropagation()}new MutationObserver(a_).observe(document.body,{attributes:!0}),a_()})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment