@pepperhorn/chordl-react 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/chordl.cjs CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("react/jsx-runtime"),ft=require("react"),pe=23,Mr=25.3,Pr=65,Er=120,re=3,Cr=13,ii=14.3,oi=40,ai=80,jn=1,oe="#fafafa",ae="#222222",li="#333333",Ke=1,ci={C:14.33,D:18.67,F:13.25,G:16.25,A:19.75},hi={C:15.76,D:20.54,F:14.58,G:17.88,A:21.73},ui=new Set(["C","D","F","G","A"]),gt=["C","D","E","F","G","A","B"],Oo={C:"C#",D:"D#",F:"F#",G:"G#",A:"A#"};function ln(t="C",n=8,e="compact"){const s=e==="exact",r=s?Er:Pr,i=s?ai:oi,a=s?Mr:pe,o=s?ii:Cr,l=s?hi:ci,d=[],m=gt.indexOf(t);let f=.5,p=0;for(let h=0;h<n;h++){const b=(m+h)%7,g=gt[b];if(h>0&&g==="C"&&p++,d.push({note:g,octave:p,isBlack:!1,x:f,y:0,width:a,height:r}),ui.has(g)){const v=l[g];d.push({note:Oo[g],octave:p,isBlack:!0,x:f+v,y:0,width:o,height:i})}f+=a}return d}function Nr(t,n="compact"){const e=n==="exact",s=e?Er:Pr;return{width:t*(e?Mr:pe)+1,height:s+2}}const Ce={Db:"C#",Eb:"D#",Gb:"F#",Ab:"G#",Bb:"A#"},di={"C#":"Db","D#":"Eb","F#":"Gb","G#":"Ab","A#":"Bb"},Bo=new Set(["F","Bb","Eb","Ab","Db","Gb","Cb"]);function Gn(t){return Ce[t]??t}function zo(t,n){return Bo.has(n)?di[t]??t:Ce[t]??t}function jo(t,n,e=!1){return e?di[t]??t:zo(t,n)}const mr={C:0,"C#":1,Db:1,D:2,"D#":3,Eb:3,E:4,Fb:4,"E#":5,F:5,"F#":6,Gb:6,G:7,"G#":8,Ab:8,A:9,"A#":10,Bb:10,B:11,Cb:11,"B#":0};function St(t){return Gn(t)}function Do(t){const n=t.indexOf(":");if(n!==-1){const e=St(t.slice(0,n)),s=parseInt(t.slice(n+1),10);return{note:e,octave:s}}return{note:St(t),octave:null}}function Ir(t,n,e){const r=[...n.map(Do)];return t.map(i=>{const a=St(i.note),o=r.findIndex(d=>!(d.note!==a||d.octave!==null&&d.octave!==i.octave)),l=o!==-1;return l&&r.splice(o,1),e?i.isBlack?e.blackKey(a,l):e.whiteKey(a,l):l?i.isBlack?"#5a8ab5":"#a0c6e8":i.isBlack?ae:oe})}const Ne=19,Ut=5,Fo=new Set(["C#","D#","F#","G#","A#"]);function pr(t){return Gn(t)}function Ur(t){return Fo.has(pr(t))}function qe(t,n){const e=mr[pr(t)],s=mr[pr(n)];return e==null||s==null?0:((s-e)%12+12)%12}function gr(t){let n=0;for(let e=1;e<t.length;e++)n+=qe(t[e-1],t[e]);return n}function fi(t){return t.length<=Ut&&gr(t)<=Ne}function Lo(t){if(t.length>Ut)return!1;if(t.length<=1)return!0;const n=[...t].sort((e,s)=>e-s);return n[n.length-1]-n[0]<=Ne}const $o={2:[[1,5],[1,3],[2,5]],3:[[1,3,5],[1,2,5],[1,2,4],[1,3,4],[2,3,5],[1,2,3]],4:[[1,2,3,5],[1,2,4,5],[1,2,3,4],[1,3,4,5],[2,3,4,5]],5:[[1,2,3,4,5]]};function Ho(t,n){let e=0;for(let r=0;r<t.length;r++)n[r]===1&&Ur(t[r])&&r!==0&&(e+=10),n[r]===5&&Ur(t[r])&&(e+=2);for(let r=0;r<t.length-1;r++){const i=qe(t[r],t[r+1]),a=Math.abs(n[r+1]-n[r]);i>=5&&a<=1&&(e+=5),i<=1&&a>=3&&(e+=3)}n[0]!==1&&(e+=1);const s=n[n.length-1];return s!==5&&s!==4&&(e+=1),e}function Xt(t,n){const e=t.length;if(e===0)return[];if(e===1)return[3];const s=$o[e];if(!s)return Array(e).fill(3);let r=s[0],i=1/0;for(const a of s){const o=Ho(t,a);o<i&&(i=o,r=a)}return n==="lh"?r.map(a=>6-a):r}function An(t,n,e){const s=t.length;if(s===0)return{fingering:[],hands:[]};if(n&&n.length===s)return Go(t,n);if(e&&e.length===s)return Uo(t,e);if(fi(t))return{fingering:Xt(t,"rh"),hands:Array(s).fill("rh")};const r=Ko(t);return Wo(t,r)}function Uo(t,n){const e=t.length,s=Array.from({length:e},(h,b)=>b).sort((h,b)=>n[h]-n[b]),r=s.map(h=>t[h]),i=s.map(h=>n[h]);if(Lo(i)){const h=Xt(r,"rh"),b=new Array(e),g=new Array(e);return s.forEach((v,y)=>{b[v]=h[y],g[v]="rh"}),{fingering:b,hands:g}}const a=Vo(r,i),o=r.slice(0,a),l=r.slice(a),d=Xt(o,"lh"),m=Xt(l,"rh"),f=new Array(e),p=new Array(e);return s.forEach((h,b)=>{b<a?(f[h]=d[b],p[h]="lh"):(f[h]=m[b-a],p[h]="rh")}),{fingering:f,hands:p}}function Wo(t,n){const e=t.slice(0,n),s=t.slice(n),r=Xt(e,"lh"),i=Xt(s,"rh");return{fingering:[...r,...i],hands:[...Array(e.length).fill("lh"),...Array(s.length).fill("rh")]}}function Go(t,n){const e=[],s=[];for(let m=0;m<t.length;m++)n[m]==="LH"?e.push(m):s.push(m);const r=e.map(m=>t[m]),i=s.map(m=>t[m]),a=Xt(r,"lh"),o=Xt(i,"rh"),l=new Array(t.length),d=new Array(t.length);return e.forEach((m,f)=>{l[m]=a[f],d[m]="lh"}),s.forEach((m,f)=>{l[m]=o[f],d[m]="rh"}),{fingering:l,hands:d}}function Wr(t){let n=0;for(let e=1;e<t.length;e++)n=Math.max(n,t[e]-t[e-1]);return n}function Vo(t,n){const e=t.length;let s=Math.min(2,e-1),r=1/0;for(let i=1;i<e;i++){const a=n.slice(0,i),o=n.slice(i);if(i>Ut||e-i>Ut)continue;const l=a[a.length-1]-a[0],d=o[o.length-1]-o[0];if(l>Ne||d>Ne)continue;let m=0;const f=i,p=e-i,h=Wr(a),b=Wr(o),g=Math.max(h,b);m+=g*5;const v=f/Ut,y=p/Ut,_=Math.abs(v-y);m+=_*8,(f===Ut||p===Ut)&&(m+=4);const k=n[i]-n[i-1];m-=k*3,f>=1&&f<=3&&(m-=4),p>=3&&p<=4&&(m-=2),m<r&&(r=m,s=i)}return s}function Ko(t){const n=t.length;let e=Math.min(2,n-1),s=1/0;for(let r=1;r<n;r++){const i=t.slice(0,r),a=t.slice(r);if(r>Ut||n-r>Ut||gr(i)>Ne||gr(a)>Ne)continue;let o=0,l=0;for(let f=1;f<r;f++)l=Math.max(l,qe(t[f-1],t[f]));let d=0;for(let f=r+1;f<n;f++)d=Math.max(d,qe(t[f-1],t[f]));o+=Math.max(l,d)*5;const m=qe(t[r-1],t[r]);o-=m*3,r>=1&&r<=3&&(o-=4),n-r>=3&&n-r<=4&&(o-=2),o+=Math.abs(r-(n-r)),o<s&&(s=o,e=r)}return e}function cn(t,n="rh"){const e=t.length;return e===0?[]:e===1?[3]:fi(t)?Xt(t,n):An(t).fingering}const qo={C:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},G:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},D:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},A:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},E:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},B:{rh:[1,2,3,1,2,3,4,5],lh:[4,3,2,1,4,3,2,1]},F:{rh:[1,2,3,4,1,2,3,4],lh:[5,4,3,2,1,3,2,1]},Bb:{rh:[2,1,2,3,1,2,3,4],lh:[3,2,1,4,3,2,1,3]},Eb:{rh:[2,1,2,3,4,1,2,3],lh:[3,2,1,4,3,2,1,3]},Ab:{rh:[2,3,1,2,3,1,2,3],lh:[3,2,1,4,3,2,1,3]},Db:{rh:[2,3,1,2,3,4,1,2],lh:[3,2,1,4,3,2,1,3]},Gb:{rh:[2,3,4,1,2,3,1,2],lh:[4,3,2,1,3,2,1,4]},"F#":{rh:[2,3,4,1,2,3,1,2],lh:[4,3,2,1,3,2,1,4]},"C#":{rh:[2,3,1,2,3,4,1,2],lh:[3,2,1,4,3,2,1,3]}},Gr={A:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},E:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},B:{rh:[1,2,3,1,2,3,4,5],lh:[4,3,2,1,4,3,2,1]},D:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},G:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},C:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},F:{rh:[1,2,3,4,1,2,3,4],lh:[5,4,3,2,1,3,2,1]},"F#":{rh:[2,3,1,2,3,1,2,3],lh:[4,3,2,1,3,2,1,4]},"C#":{rh:[2,3,1,2,3,1,2,3],lh:[3,2,1,4,3,2,1,3]},"G#":{rh:[2,3,1,2,3,1,2,3],lh:[3,2,1,4,3,2,1,3]},Bb:{rh:[2,1,2,3,1,2,3,4],lh:[2,1,3,2,1,4,3,2]},Eb:{rh:[2,1,2,3,4,1,2,3],lh:[2,1,4,3,2,1,3,2]},Ab:{rh:[2,3,1,2,3,1,2,3],lh:[3,2,1,4,3,2,1,3]}},Vr={Db:"C#",Eb:"D#",Gb:"F#",Ab:"G#",Bb:"A#"};function Yo(t,n,e="rh",s=1){const r=n.toLowerCase().replace(/\s+/g," ").trim();let i;if(r==="major"||r==="ionian")i=qo;else if(r==="minor"||r==="natural minor"||r==="harmonic minor"||r==="minor harmonic"||r==="melodic minor"||r==="minor melodic"||r==="aeolian")i=Gr;else if(r==="dorian"||r==="mixolydian"||r==="phrygian"||r==="lydian"||r==="locrian")i=Gr;else return[];let a=i[t];if(!a){const d=Vr[t];d&&(a=i[d])}if(!a){for(const[d,m]of Object.entries(Vr))if(m===t){a=i[d];break}}if(!a)return[];const o=e==="rh"?a.rh:a.lh;if(s<=1)return o;const l=[];for(let d=0;d<s;d++)d<s-1?l.push(...o.slice(0,7)):l.push(...o);return l}const Wt=8,mi=4,pi=120,se=75,br=6.75,gi=14,Zo=br*2,Xo=10,Kr=7,Qo=1,Jo=20,Mn=22,ta=10,qr=.8,bn=8;function ea(t){return t.map(n=>{const[e,s]=n.split(":");return{pitchClass:Tr(e),octave:parseInt(s,10)}})}const bi={C:0,D:1,E:2,F:3,G:4,A:5,B:6},na=30,ra=18;function Tr(t){return Gn(t)}function Rr(t){return t.replace("#","").replace("b","")}function nr(t,n){const e=Rr(t),r={C:0,D:2,E:4,F:5,G:7,A:9,B:11}[e]??0,i=t.includes("#")?1:t.includes("b")?-1:0;return(n+1)*12+r+i}function sa(t,n){const e=Rr(t);return n*7+(bi[e]??0)}function yr(t,n,e){return n-(t-e)*mi}function ia(t,n,e){const s=n+8,r=[];if(t<n)for(let i=n-2;i>=t;i-=2)r.push(yr(i,e,n));else if(t>s)for(let i=s+2;i<=t;i+=2)r.push(yr(i,e,n));return r}function Yr(t,n){const e=[];let s=n,r=-1;for(const i of t){const a=Tr(i),o=Rr(a),l=bi[o]??0;r>=0&&l<=r&&s++,r=l,e.push({pitchClass:a,octave:s})}return e}function oa(t){const n=[...t].sort((s,r)=>s.diatonicPos-r.diatonicPos),e=new Set;for(let s=1;s<n.length;s++)n[s].diatonicPos-n[s-1].diatonicPos===1&&(e.has(n[s-1])||(e.add(n[s]),n[s].noteX=se+Zo))}function aa(t){const n=t.filter(r=>r.accidental!==null).sort((r,i)=>r.y-i.y);if(n.length===0)return;const e=[],s=Wt*2.5;for(const r of n){let o=t.some(l=>l.noteX>se&&Math.abs(l.y-r.y)<Wt*2)?1:0;for(;e.some(d=>d.col===o&&Math.abs(d.y-r.y)<s);)o++;e.push({col:o,y:r.y}),r.accidentalX=se-gi-o*Xo}}function yi(t,n={}){const{lhNotes:e,rhOctave:s=4,lhOctave:r=3,octaveQualifiedNotes:i}=n;let a,o;if(i)a=ea(i),o=e??[];else{const P=e?t.filter(L=>!e.includes(L)):t;o=e??[];const j=Yr(P,s);a=[...Yr(o,r),...j]}const l=e&&e.length>0,d=57,m=a.filter(P=>nr(P.pitchClass,P.octave)>d).length,f=a.filter(P=>nr(P.pitchClass,P.octave)<=d).length;let p;l?p="grand":m>0&&f>0?p=m>=f?"treble":"bass":m>0?p="treble":p="bass";const h=Mn+Wt*4,b=p==="grand"?h+Jo:p==="bass"?Mn:-1,g=b>=0?b+Wt*4:-1,v=p!=="bass"?Mn:-1,y=b,_=a.map(P=>{const j=nr(P.pitchClass,P.octave),C=e?o.some(W=>Tr(W)===P.pitchClass):j<60;let L,V,A;C&&p!=="treble"?(L="bass",V=g,A=ra):(L="treble",V=h,A=na);const N=sa(P.pitchClass,P.octave),u=yr(N,V,A),z=ia(N,A,V),Q=P.pitchClass.includes("#")?"sharp":P.pitchClass.includes("b")?"flat":null;return{pitchClass:P.pitchClass,octave:P.octave,staff:L,y:u,noteX:se,accidental:Q,accidentalX:se-gi,ledgerLines:z,diatonicPos:N}});oa(_),aa(_);const k=p==="bass"||p==="grand"?g:h,M=Math.max(k,..._.map(P=>P.y)),w=Math.max(k,..._.flatMap(P=>P.ledgerLines)),T=Math.max(M,w)+ta+mi;return{notes:_,staffMode:p,totalHeight:T,totalWidth:pi,trebleTopY:v,bassTopY:y}}const zt={gClef:"",fClef:"",noteheadWhole:"",accidentalSharp:"",accidentalFlat:"",accidentalNatural:""};function vi(t){return n=>{const e=n/2,s=n/4;return`M ${t} 0 C ${t-4} ${s} 0 ${e-4} 0 ${e} C 0 ${e+4} ${t-4} ${e+s} ${t} ${n}`}}const _i={name:"Bravura",fontFamily:"Bravura, serif",glyphs:{trebleClef:zt.gClef,bassClef:zt.fClef,sharp:zt.accidentalSharp,flat:zt.accidentalFlat,natural:zt.accidentalNatural,wholeNote:zt.noteheadWhole},brace:vi(6)},la={name:"Petaluma",fontFamily:"Petaluma, serif",glyphs:{trebleClef:zt.gClef,bassClef:zt.fClef,sharp:zt.accidentalSharp,flat:zt.accidentalFlat,natural:zt.accidentalNatural,wholeNote:zt.noteheadWhole},brace:vi(6)};let wi=_i;function xi(){return wi}function ca(t){wi=t}const ha=/\b(show\s+me|draw|display|render|please|a|an|the|with|that|this|me|of)\b/gi,Zr=/\b(compact|exact|full)\b/i,Xr=/\bfull\s+(?:layout|height|size|keys?)\b/i,Qr=/\b(?:size|keys?)\s+([\d.]+)\s*%?\b/i,Jr=/\b(?:size|keys?)\s+(sm|base|lg|xl|2xl)\b/i,ua={sm:.5,base:.7,lg:.85,xl:1,"2xl":1.2},da={first:1,second:2,third:3,fourth:4,root:0},ts=/(?:(?:with\s+|show\s+)?all|every)\s+inversions?/i,es=/(\d+)(?:st|nd|rd|th)\s+inversion/i,ns=/(first|second|third|fourth)\s+inversion/i,rs=/root\s+position/i,ss=/spanning\s+([A-Ga-g][#b]?)\s+to\s+([A-Ga-g][#b]?)/i,is=/start(?:s|ing)?\s+(?:on|from|at|around)\s+(?:the\s+)?([A-Ga-g][#b]?)/i,os=/start(?:s|ing)?\s+(?:on|from|at|around)\s+(?:the\s+)?(\d+)(?:st|nd|rd|th)/i,as=/(?:with\s+)?(?:the\s+)?(\d+)(?:st|nd|rd|th)\s+(?:in\s+)?(?:the\s+)?(?:bottom|bass|lowest)/i,ls=/(?:with\s+)?([A-Ga-g][#b]?)\s+(?:in\s+)?(?:the\s+)?(?:bottom|bass|lowest)/i,cs=/\bover\s+([A-Ga-g][#b]?)(?:\s|$)/i,hs=/(?:(?:in\s+)?(?:the\s+)?style\s+of\s+|like\s+|a\s+la\s+)([\w\s]+?)(?:\s*$|\s*,|\s+(?:starting|spanning|with|compact|exact))/i,us=/\b(bebop|basie|nestico|ellington|modal|comping|rootless|quartal|block\s*chords?|locked\s*hands|drop\s*2\s*\+?\s*4|drop\s*2|upper\s*structure|shell|stride|spread|4[- ]?note\s*closed)\b/i,ds=/(?:with\s+)?(\d+)\s+(?:notes?|keys?)\s+(?:on\s+)?(?:either|each|both)\s+side/i,fs=/(?:with\s+)?(?:the\s+)?chord\s+(?:(?:(down|up|lower|higher)\s+)?(?:(\d+)\s+)?(?:an?\s+)?octaves?(?:\s+(down|up|lower|higher))?)/i,ms=/(?:with\s+)?(?:the\s+)?bass(?:\s+note)?\s+(?:(?:(down|up|lower|higher)\s+)?(?:(\d+)\s+)?(?:an?\s+)?octaves?(?:\s+(down|up|lower|higher))?)/i,ps=/(?:(?:with\s+)?(?:show\s+)?(?:(base|lg|xl|2xl)\s+)?note\s*names?(?:\s+(?:in\s+)?(base|lg|xl|2xl))?|name\s+the\s+notes(?:\s+(?:in\s+)?(base|lg|xl|2xl))?)/i,fa=/(?:(?:with\s+)?(?:show\s+)?midi\s+(?:(base|lg|xl|2xl)\s+)?(?:note\s*)?names?(?:\s+(?:in\s+)?(base|lg|xl|2xl))?)/i,gs=/(?:with\s+)?finger(?:ing|s)?\s+([\dxX\-](?:[,\s\-]*[\dxX\-])+)(?!\s*xl)(?:\s+(?:in\s+)?(base|lg|xl|2xl))?/i,ma=new Set(["0","1","2","3","4","5","-","x"]),bs=/(?:with\s+)?(?:custom\s+)?finger(?:ing|s)?\s+(?:(?:in\s+)?(base|lg|xl|2xl)\s+)?[""]([^""]+)[""](?:\s+(?:in\s+)?(base|lg|xl|2xl))?/i,ys=/(?:with\s+)?(?:show\s+)?finger(?:ings?|s)?(?:\s+(?:in\s+)?(base|lg|xl|2xl)|\s+(base|lg|xl|2xl))?(?!\s+\d)(?:\s|$)/i,pa=new Set(["base","lg","xl","2xl"]);function Ot(t){if(!t)return;const n=t.toLowerCase();return pa.has(n)?n:void 0}const ga=["dorian","mixolydian","phrygian","lydian","locrian","harmonic\\s+minor","minor\\s+harmonic","melodic\\s+minor","minor\\s+melodic","natural\\s+minor","major\\s+pentatonic","minor\\s+pentatonic","pentatonic","blues","whole\\s+tone","bebop","diminished"],vs=new RegExp(`([A-Ga-g][#b]?)\\s+(${ga.join("|")})(?:\\s+scale)?`,"i"),_s=/([A-Ga-g][#b]?)\s+(major|minor)\s+scale/i,ws=/\b(ascending|descending)\b/i,xs=/\b(?:in\s+)?(\d+)\s+octaves?\b/i,ba=/\bwith\s+(?:note\s+names?\s+and\s+)?degrees?(?:\s+(?:in\s+)?(base|lg|xl|2xl))?\b/i,ya=/\bwith\s+degrees?(?:\s+(?:in\s+)?(base|lg|xl|2xl))?\b/i,Ss=/\bwith\s+note\s+names?\s+and\s+degrees?(?:\s+(?:in\s+)?(base|lg|xl|2xl))?\b/i,ks=/\b(?:with\s+)?(?:a\s+)?(?:show\s+)?heading\b/i,As=/\b(?:(?:with\s+)?(?:the\s+)?)?(?:(boomwhacker|boomwhackers|crf|rainbow)\s*(?:theme|colors?|colours?)?)\b/i,va={boomwhacker:"boomwhacker",boomwhackers:"boomwhacker",crf:"crf",rainbow:"crf"},_a={major:"",minor:"m",diminished:"dim",augmented:"aug",dominant:"dom",suspended:"sus",triad:"",seventh:"7",ninth:"9",eleventh:"11",thirteenth:"13"},wa=/([A-Ga-g][#b]?)\s*(maj|min|m|aug|dim|sus|add|dom|M|°|ø|[0-9#b/]+)*/i;function ee(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Vn(t){const n={chordName:""},e=t.match(Xr),s=t.match(Zr);if(e)n.format="exact";else if(s){const $=s[1].toLowerCase();n.format=$==="full"?"exact":$}const r=t.match(Jr),i=t.match(Qr);if(r)n.scale=ua[r[1].toLowerCase()];else if(i){const $=parseFloat(i[1]);n.scale=$>10?$/100:$}const a=t.match(ts),o=t.match(es),l=t.match(ns),d=t.match(rs);a?n.allInversions=!0:o?n.inversion=parseInt(o[1],10):l?n.inversion=da[l[1].toLowerCase()]:d&&(n.inversion=0);const m=t.match(ss);m&&(n.spanFrom=ee(m[1]),n.spanTo=ee(m[2]));const f=t.match(ds);f&&(n.padding=parseInt(f[1],10));const p=t.match(fs);if(p){const $=(p[1]||p[3]||"").toLowerCase(),X=p[2]?parseInt(p[2],10):1,B=$==="down"||$==="lower";n.chordOctaveShift=B?-X:X}const h=t.match(ms);if(h){const $=(h[1]||h[3]||"").toLowerCase(),X=h[2]?parseInt(h[2],10):1,B=$==="down"||$==="lower";n.bassOctaveShift=B?-X:X}const b=t.match(fa);if(b&&(n.showNoteNames=!0,n.noteNameMode="midi",n.noteNameSize=Ot(b[1])??Ot(b[2])),!b){const $=t.match(ps);$&&(n.showNoteNames=!0,n.noteNameSize=Ot($[1])??Ot($[2])??Ot($[3]))}!n.showNoteNames&&/\bmidi\b/i.test(t)&&(n.showNoteNames=!0,n.noteNameMode="midi");const g=t.match(bs);if(g&&(n.customFingering=g[2].split(/[,\-\s]+/).filter(Boolean),n.fingeringSize=Ot(g[1])??Ot(g[3])),!n.customFingering){const $=t.match(ys);if($&&(n.autoFingering=!0,n.fingeringSize=Ot($[1])??Ot($[2])),!n.autoFingering){const X=t.match(gs);if(X){const B=[];for(const R of X[1].split(/[\s,]+/))R==="-"||R==="x"||R==="X"?B.push(R):R.includes("-")?B.push(...R.split("-").filter(J=>J.length>0)):B.push(R);n.fingering=B.map(R=>{const J=R.toLowerCase();if(!ma.has(J))return"?";const tt=parseInt(J,10);return isNaN(tt)?J:tt}),n.fingeringSize=Ot(X[2])}}}const v=t.match(as),y=t.match(ls),_=t.match(cs);v?n.bassDegree=parseInt(v[1],10):y?n.bassNote=ee(y[1]):_&&(n.bassNote=ee(_[1]));const k=t.match(hs),M=t.match(us);k?n.styleHint=k[1].trim():M&&(n.styleHint=M[1].trim()),ks.test(t)&&(n.showHeading=!0);const w=t.match(As);w&&(n.colorTheme=va[w[1].toLowerCase()]??w[1].toLowerCase());const T=t.match(Ss),P=t.match(ya);if(T){n.showNoteNames=!0,n.noteNameMode="pitch-class+degree";const $=Ot(T[1]);$&&(n.noteNameSize=$)}else if(P){n.showNoteNames=!0,n.noteNameMode="degree";const $=Ot(P[1]);$&&(n.noteNameSize=$)}const j=t.match(ws);j&&(n.scaleDirection=j[1].toLowerCase());const C=t.match(xs),L=C?parseInt(C[1],10):void 0,V=t.match(vs),A=t.match(_s),N=V||A;if(N){const $=ee(N[1]),X=N[2].toLowerCase().replace(/\s+/g," ").trim();n.isScale=!0,n.scaleName=`${$} ${X}`,n.scaleOctaves=L??1}else L&&(n.chordOctaves=L);const u=t.match(os),z=t.match(is);u?n.startingDegree=parseInt(u[1],10):z&&(n.startingNote=ee(z[1]));let Q=t.replace(Xr,"").replace(Zr,"").replace(Jr,"").replace(Qr,"").replace(ts,"").replace(es,"").replace(ns,"").replace(rs,"").replace(ss,"").replace(ds,"").replace(fs,"").replace(ms,"").replace(ps,"").replace(bs,"").replace(gs,"").replace(ys,"").replace(hs,"").replace(us,"").replace(as,"").replace(ls,"").replace(cs,"").replace(os,"").replace(is,"").replace(Ss,"").replace(ba,"").replace(ws,"").replace(xs,"").replace(vs,"").replace(_s,"").replace(/\bscale\b/gi,"").replace(ks,"").replace(As,"").replace(/\btheme\b/gi,"").replace(/\bcolou?rs?\b/gi,"").replace(/\bcustom\b/gi,"").replace(/\band\b/gi,"").replace(ha,"").replace(/,/g,"").replace(/\blayout\b/gi,"").replace(/\bfull\b/gi,"").replace(/\bheight\b/gi,"").replace(/\bsize\b/gi,"").replace(/\bkeys?\b/gi,"").replace(/\bin\b/gi,"").replace(/\s+/g," ").trim();Q=Q.replace(/\bsharp\b/gi,"#").replace(/\bflat\b/gi,"b"),Q=Q.replace(/([A-Ga-g])\s+([#b])/g,"$1$2"),Q=Q.replace(/\s+/g," ").trim();const W=/([A-Ga-g][#b]?)\s+((?:major|minor|diminished|augmented|dominant|suspended)\s*(?:triad|seventh|ninth|eleventh|thirteenth)?)/i,st=Q.match(W);if(st){const $=ee(st[1]),X=st[2].toLowerCase().trim().split(/\s+/);let B="";for(const R of X)B+=_a[R]??"";n.chordName=$+B}else{const $=Q.match(wa);if($){const X=ee($[1]),R=$[0].slice($[1].length);n.chordName=X+R.trim()}}return n}const ge=3,xa=!1,Ms="[#b]?(?:iv|vi{1,2}|i{1,3}|IV|VI{1,2}|I{1,3}|V)(?:[°ø]?\\d*(?:maj|m)?[0-9#b]*)(?![a-z])",Si=new RegExp(`(?:^|\\s)(${Ms}(?:[\\s\\-–—→>]+${Ms})+)`,"i"),Sa=/(\d+)\s*(?:examples?|variations?|versions?|ways?|options?)/i,ka=/(?:(?:in\s+)?(?:the\s+)?style\s+of\s+|like\s+|a\s+la\s+)([\w\s]+?)(?:\s*$|\s*,|\s+(?:in\s|examples?|variations?))/i,Aa=/\b(bebop|basie|nestico|ellington|modal|comping|rootless|quartal|block\s*chords?|locked\s*hands|drop\s*2\s*\+?\s*4|drop\s*2|upper\s*structure|shell|stride|spread|4[- ]?note\s*closed|bill\s*evans|mccoy\s*tyner|herbie\s*hancock|bud\s*powell|monk)\b/i,ki=[{pattern:/\bjazz\s*blues\b/i,id:"jazz blues"},{pattern:/\bblues\b/i,id:"blues"},{pattern:/\brhythm\s*changes?\b/i,id:"rhythm changes"},{pattern:/\bturnaround\b/i,id:"I-vi-ii-V"},{pattern:/\bmodal\s*vamp\b/i,id:"modal vamp"},{pattern:/\bbackdoor\b/i,id:"backdoor"},{pattern:/\btritone\s*sub(?:stitution)?\b/i,id:"tritone sub"},{pattern:/\bminor\s*(?:ii[\s\-–—]*v[\s\-–—]*i|2[\s\-–—]*5[\s\-–—]*1)\b/i,id:"minor ii-V-i"}];function Ma(t){for(const{pattern:n}of ki)if(n.test(t))return!0;return!!(Si.test(t)||/\bprogression\b/i.test(t))}function Pa(t){let n=ge;const e=t.match(Sa);e&&(n=Math.min(parseInt(e[1],10),ge));let s;const r=t.match(ka),i=t.match(Aa);r?s=r[1].trim():i&&(s=i[1].trim());let a;const o=t.match(/\b(compact|exact)\b/i);o&&(a=o[1].toLowerCase());let l="C";const d=t.match(/\bin\s+(?:the\s+)?(?:key\s+(?:of\s+)?)?([A-Ga-g][#b]?)(?:\s|$)/i);d&&(l=d[1].charAt(0).toUpperCase()+d[1].slice(1));let m="";for(const{pattern:f,id:p}of ki)if(f.test(t)){m=p;break}if(!m){const f=t.match(Si);f&&(m=f[1].trim())}return m||(m="ii-V-I"),{progression:m,key:l,numExamples:n,styleHint:s,format:a}}function Ai(t){return t!==null&&typeof t=="object"&&"name"in t&&typeof t.name=="string"}function Mi(t){return t!==null&&typeof t=="object"&&"step"in t&&typeof t.step=="number"&&"alt"in t&&typeof t.alt=="number"&&!isNaN(t.step)&&!isNaN(t.alt)}var Pi=[0,2,4,-1,1,3,5],Ei=Pi.map(t=>Math.floor(t*7/12));function Ci(t){const{step:n,alt:e,oct:s,dir:r=1}=t,i=Pi[n]+7*e;if(s===void 0)return[r*i];const a=s-Ei[n]-4*e;return[r*i,r*a]}var Ea=[3,0,4,1,5,2,6];function Ni(t){const[n,e,s]=t,r=Ea[Ca(n)],i=Math.floor((n+1)/7);if(e===void 0)return{step:r,alt:i,dir:s};const a=e+4*i+Ei[r];return{step:r,alt:i,oct:a,dir:s}}function Ca(t){const n=(t+1)%7;return n<0?7+n:n}var Ps=(t,n)=>Array(Math.abs(n)+1).join(t),vr=Object.freeze({empty:!0,name:"",num:NaN,q:"",type:"",step:NaN,alt:NaN,dir:NaN,simple:NaN,semitones:NaN,chroma:NaN,coord:[],oct:NaN}),Na="([-+]?\\d+)(d{1,4}|m|M|P|A{1,4})",Ia="(AA|A|P|M|m|d|dd)([-+]?\\d+)",Ta=new RegExp("^"+Na+"|"+Ia+"$");function Ra(t){const n=Ta.exec(`${t}`);return n===null?["",""]:n[1]?[n[1],n[2]]:[n[4],n[3]]}var Es={};function be(t){return typeof t=="string"?Es[t]||(Es[t]=Oa(t)):Mi(t)?be(za(t)):Ai(t)?be(t.name):vr}var Cs=[0,2,4,5,7,9,11],Ii="PMMPPMM";function Oa(t){const n=Ra(t);if(n[0]==="")return vr;const e=+n[0],s=n[1],r=(Math.abs(e)-1)%7,i=Ii[r];if(i==="M"&&s==="P")return vr;const a=i==="M"?"majorable":"perfectable",o=""+e+s,l=e<0?-1:1,d=e===8||e===-8?e:l*(r+1),m=Ba(a,s),f=Math.floor((Math.abs(e)-1)/7),p=l*(Cs[r]+m+12*f),h=(l*(Cs[r]+m)%12+12)%12,b=Ci({step:r,alt:m,oct:f,dir:l});return{empty:!1,name:o,num:e,q:s,step:r,alt:m,dir:l,type:a,simple:d,semitones:p,chroma:h,coord:b,oct:f}}function Ti(t,n){const[e,s=0]=t,r=e*7+s*12<0,i=n||r?[-e,-s,-1]:[e,s,1];return be(Ni(i))}function Ba(t,n){return n==="M"&&t==="majorable"||n==="P"&&t==="perfectable"?0:n==="m"&&t==="majorable"?-1:/^A+$/.test(n)?n.length:/^d+$/.test(n)?-1*(t==="perfectable"?n.length:n.length+1):0}function za(t){const{step:n,alt:e,oct:s=0,dir:r}=t;if(!r)return"";const i=n+1+7*s,a=i===0?n+1:i,o=r<0?"-":"",l=Ii[n]==="M"?"majorable":"perfectable";return o+a+ja(l,e)}function ja(t,n){return n===0?t==="majorable"?"M":"P":n===-1&&t==="majorable"?"m":n>0?Ps("A",n):Ps("d",t==="perfectable"?n:n+1)}var Ns=(t,n)=>Array(Math.abs(n)+1).join(t),Ri=Object.freeze({empty:!0,name:"",letter:"",acc:"",pc:"",step:NaN,alt:NaN,chroma:NaN,height:NaN,coord:[],midi:null,freq:null}),Is=new Map,Da=t=>"CDEFGAB".charAt(t),Fa=t=>t<0?Ns("b",-t):Ns("#",t),La=t=>t[0]==="b"?-t.length:t.length;function It(t){const n=JSON.stringify(t),e=Is.get(n);if(e)return e;const s=typeof t=="string"?Wa(t):Mi(t)?It(Ga(t)):Ai(t)?It(t.name):Ri;return Is.set(n,s),s}var $a=/^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)$/;function Or(t){const n=$a.exec(t);return n?[n[1].toUpperCase(),n[2].replace(/x/g,"##"),n[3],n[4]]:["","","",""]}function Ha(t){return It(Ni(t))}var Ua=(t,n)=>(t%n+n)%n,rr=[0,2,4,5,7,9,11];function Wa(t){const n=Or(t);if(n[0]===""||n[3]!=="")return Ri;const e=n[0],s=n[1],r=n[2],i=(e.charCodeAt(0)+3)%7,a=La(s),o=r.length?+r:void 0,l=Ci({step:i,alt:a,oct:o}),d=e+s+r,m=e+s,f=(rr[i]+a+120)%12,p=o===void 0?Ua(rr[i]+a,12)-1188:rr[i]+a+12*(o+1),h=p>=0&&p<=127?p:null,b=o===void 0?null:Math.pow(2,(p-69)/12)*440;return{empty:!1,acc:s,alt:a,chroma:f,coord:l,freq:b,height:p,letter:e,midi:h,name:d,oct:o,pc:m,step:i}}function Ga(t){const{step:n,alt:e,oct:s}=t,r=Da(n);if(!r)return"";const i=r+Fa(e);return s||s===0?i+s:i}function Kn(t,n){const e=It(t),s=Array.isArray(n)?n:be(n).coord;if(e.empty||!s||s.length<2)return"";const r=e.coord,i=r.length===1?[r[0]+s[0]]:[r[0]+s[0],r[1]+s[1]];return Ha(i).name}function Ts(t,n){const e=It(t),s=It(n);if(e.empty||s.empty)return"";const r=e.coord,i=s.coord,a=i[0]-r[0],o=r.length===2&&i.length===2?i[1]-r[1]:-Math.floor(a*7/12),l=s.height===e.height&&s.midi!==null&&e.oct===s.oct&&e.step>s.step;return Ti([a,o],l).name}function Oi(t,n){const e=n.length,s=(t%e+e)%e;return n.slice(s,e).concat(n.slice(0,s))}var ye={empty:!0,name:"",setNum:0,chroma:"000000000000",normalized:"000000000000",intervals:[]},Bi=t=>Number(t).toString(2).padStart(12,"0"),Rs=t=>parseInt(t,2),Va=/^[01]{12}$/;function zi(t){return Va.test(t)}var Ka=t=>typeof t=="number"&&t>=0&&t<=4095,qa=t=>t&&zi(t.chroma),Os={[ye.chroma]:ye};function ji(t){const n=zi(t)?t:Ka(t)?Bi(t):Array.isArray(t)?Ja(t):qa(t)?t.chroma:ye.chroma;return Os[n]=Os[n]||Qa(n)}var Ya=["1P","2m","2M","3m","3M","4P","5d","5P","6m","6M","7m","7M"];function Za(t){const n=[];for(let e=0;e<12;e++)t.charAt(e)==="1"&&n.push(Ya[e]);return n}function Xa(t){const n=t.split("");return n.map((e,s)=>Oi(s,n).join(""))}function Qa(t){const n=Rs(t),e=Xa(t).map(Rs).filter(i=>i>=2048).sort()[0],s=Bi(e),r=Za(t);return{empty:!1,name:"",setNum:n,chroma:t,normalized:s,intervals:r}}function Ja(t){if(t.length===0)return ye.chroma;let n;const e=[0,0,0,0,0,0,0,0,0,0,0,0];for(let s=0;s<t.length;s++)n=It(t[s]),n.empty&&(n=be(t[s])),n.empty||(e[n.chroma]=1);return e.join("")}var tl=[["1P 3M 5P","major","M ^ maj"],["1P 3M 5P 7M","major seventh","maj7 Δ ma7 M7 Maj7 ^7"],["1P 3M 5P 7M 9M","major ninth","maj9 Δ9 ^9"],["1P 3M 5P 7M 9M 13M","major thirteenth","maj13 Maj13 ^13"],["1P 3M 5P 6M","sixth","6 add6 add13 M6"],["1P 3M 5P 6M 9M","sixth added ninth","6add9 6/9 69 M69"],["1P 3M 6m 7M","major seventh flat sixth","M7b6 ^7b6"],["1P 3M 5P 7M 11A","major seventh sharp eleventh","maj#4 Δ#4 Δ#11 M7#11 ^7#11 maj7#11"],["1P 3m 5P","minor","m min -"],["1P 3m 5P 7m","minor seventh","m7 min7 mi7 -7"],["1P 3m 5P 7M","minor/major seventh","m/ma7 m/maj7 mM7 mMaj7 m/M7 -Δ7 mΔ -^7 -maj7"],["1P 3m 5P 6M","minor sixth","m6 -6"],["1P 3m 5P 7m 9M","minor ninth","m9 -9"],["1P 3m 5P 7M 9M","minor/major ninth","mM9 mMaj9 -^9"],["1P 3m 5P 7m 9M 11P","minor eleventh","m11 -11"],["1P 3m 5P 7m 9M 13M","minor thirteenth","m13 -13"],["1P 3m 5d","diminished","dim ° o"],["1P 3m 5d 7d","diminished seventh","dim7 °7 o7"],["1P 3m 5d 7m","half-diminished","m7b5 ø -7b5 h7 h"],["1P 3M 5P 7m","dominant seventh","7 dom"],["1P 3M 5P 7m 9M","dominant ninth","9"],["1P 3M 5P 7m 9M 13M","dominant thirteenth","13"],["1P 3M 5P 7m 11A","lydian dominant seventh","7#11 7#4"],["1P 3M 5P 7m 9m","dominant flat ninth","7b9"],["1P 3M 5P 7m 9A","dominant sharp ninth","7#9"],["1P 3M 7m 9m","altered","alt7"],["1P 4P 5P","suspended fourth","sus4 sus"],["1P 2M 5P","suspended second","sus2"],["1P 4P 5P 7m","suspended fourth seventh","7sus4 7sus"],["1P 5P 7m 9M 11P","eleventh","11"],["1P 4P 5P 7m 9m","suspended fourth flat ninth","b9sus phryg 7b9sus 7b9sus4"],["1P 5P","fifth","5"],["1P 3M 5A","augmented","aug + +5 ^#5"],["1P 3m 5A","minor augmented","m#5 -#5 m+"],["1P 3M 5A 7M","augmented seventh","maj7#5 maj7+5 +maj7 ^7#5"],["1P 3M 5P 7M 9M 11A","major sharp eleventh (lydian)","maj9#11 Δ9#11 ^9#11"],["1P 2M 4P 5P","","sus24 sus4add9"],["1P 3M 5A 7M 9M","","maj9#5 Maj9#5"],["1P 3M 5A 7m","","7#5 +7 7+ 7aug aug7"],["1P 3M 5A 7m 9A","","7#5#9 7#9#5 7alt"],["1P 3M 5A 7m 9M","","9#5 9+"],["1P 3M 5A 7m 9M 11A","","9#5#11"],["1P 3M 5A 7m 9m","","7#5b9 7b9#5"],["1P 3M 5A 7m 9m 11A","","7#5b9#11"],["1P 3M 5A 9A","","+add#9"],["1P 3M 5A 9M","","M#5add9 +add9"],["1P 3M 5P 6M 11A","","M6#11 M6b5 6#11 6b5"],["1P 3M 5P 6M 7M 9M","","M7add13"],["1P 3M 5P 6M 9M 11A","","69#11"],["1P 3m 5P 6M 9M","","m69 -69"],["1P 3M 5P 6m 7m","","7b6"],["1P 3M 5P 7M 9A 11A","","maj7#9#11"],["1P 3M 5P 7M 9M 11A 13M","","M13#11 maj13#11 M13+4 M13#4"],["1P 3M 5P 7M 9m","","M7b9"],["1P 3M 5P 7m 11A 13m","","7#11b13 7b5b13"],["1P 3M 5P 7m 13M","","7add6 67 7add13"],["1P 3M 5P 7m 9A 11A","","7#9#11 7b5#9 7#9b5"],["1P 3M 5P 7m 9A 11A 13M","","13#9#11"],["1P 3M 5P 7m 9A 11A 13m","","7#9#11b13"],["1P 3M 5P 7m 9A 13M","","13#9"],["1P 3M 5P 7m 9A 13m","","7#9b13"],["1P 3M 5P 7m 9M 11A","","9#11 9+4 9#4"],["1P 3M 5P 7m 9M 11A 13M","","13#11 13+4 13#4"],["1P 3M 5P 7m 9M 11A 13m","","9#11b13 9b5b13"],["1P 3M 5P 7m 9m 11A","","7b9#11 7b5b9 7b9b5"],["1P 3M 5P 7m 9m 11A 13M","","13b9#11"],["1P 3M 5P 7m 9m 11A 13m","","7b9b13#11 7b9#11b13 7b5b9b13"],["1P 3M 5P 7m 9m 13M","","13b9"],["1P 3M 5P 7m 9m 13m","","7b9b13"],["1P 3M 5P 7m 9m 9A","","7b9#9"],["1P 3M 5P 9M","","Madd9 2 add9 add2"],["1P 3M 5P 9m","","Maddb9"],["1P 3M 5d","","Mb5"],["1P 3M 5d 6M 7m 9M","","13b5"],["1P 3M 5d 7M","","M7b5"],["1P 3M 5d 7M 9M","","M9b5"],["1P 3M 5d 7m","","7b5"],["1P 3M 5d 7m 9M","","9b5"],["1P 3M 7m","","7no5"],["1P 3M 7m 13m","","7b13"],["1P 3M 7m 9M","","9no5"],["1P 3M 7m 9M 13M","","13no5"],["1P 3M 7m 9M 13m","","9b13"],["1P 3m 4P 5P","","madd4"],["1P 3m 5P 6m 7M","","mMaj7b6"],["1P 3m 5P 6m 7M 9M","","mMaj9b6"],["1P 3m 5P 7m 11P","","m7add11 m7add4"],["1P 3m 5P 9M","","madd9"],["1P 3m 5d 6M 7M","","o7M7"],["1P 3m 5d 7M","","oM7"],["1P 3m 6m 7M","","mb6M7"],["1P 3m 6m 7m","","m7#5"],["1P 3m 6m 7m 9M","","m9#5"],["1P 3m 5A 7m 9M 11P","","m11A"],["1P 3m 6m 9m","","mb6b9"],["1P 2M 3m 5d 7m","","m9b5"],["1P 4P 5A 7M","","M7#5sus4"],["1P 4P 5A 7M 9M","","M9#5sus4"],["1P 4P 5A 7m","","7#5sus4"],["1P 4P 5P 7M","","M7sus4"],["1P 4P 5P 7M 9M","","M9sus4"],["1P 4P 5P 7m 9M","","9sus4 9sus"],["1P 4P 5P 7m 9M 13M","","13sus4 13sus"],["1P 4P 5P 7m 9m 13m","","7sus4b9b13 7b9b13sus4"],["1P 4P 7m 10m","","4 quartal"],["1P 5P 7m 9m 11P","","11b9"]],el=tl,nl={...ye,name:"",quality:"Unknown",intervals:[],aliases:[]},Di=[],Ye={};function rl(t){return Ye[t]||nl}function sl(t,n,e){const s=ol(t),r={...ji(t),name:e||"",quality:s,intervals:t,aliases:n};Di.push(r),r.name&&(Ye[r.name]=r),Ye[r.setNum]=r,Ye[r.chroma]=r,r.aliases.forEach(i=>il(r,i))}function il(t,n){Ye[n]=t}function ol(t){const n=e=>t.indexOf(e)!==-1;return n("5A")?"Augmented":n("3M")?"Major":n("5d")?"Diminished":n("3m")?"Minor":"Unknown"}el.forEach(([t,n,e])=>sl(t.split(" "),e.split(" "),n));Di.sort((t,n)=>t.setNum-n.setNum);var al=ll((t,n)=>[t[0]-n[0],t[1]-n[1]]);function ll(t){return(n,e)=>{const s=be(n).coord,r=be(e).coord;if(s&&r){const i=t(s,r);return Ti(i).name}}}var cl=[["1P 2M 3M 5P 6M","major pentatonic","pentatonic"],["1P 2M 3M 4P 5P 6M 7M","major","ionian"],["1P 2M 3m 4P 5P 6m 7m","minor","aeolian"],["1P 2M 3m 3M 5P 6M","major blues"],["1P 3m 4P 5d 5P 7m","minor blues","blues"],["1P 2M 3m 4P 5P 6M 7M","melodic minor"],["1P 2M 3m 4P 5P 6m 7M","harmonic minor"],["1P 2M 3M 4P 5P 6M 7m 7M","bebop"],["1P 2M 3m 4P 5d 6m 6M 7M","diminished","whole-half diminished"],["1P 2M 3m 4P 5P 6M 7m","dorian"],["1P 2M 3M 4A 5P 6M 7M","lydian"],["1P 2M 3M 4P 5P 6M 7m","mixolydian","dominant"],["1P 2m 3m 4P 5P 6m 7m","phrygian"],["1P 2m 3m 4P 5d 6m 7m","locrian"],["1P 3M 4P 5P 7M","ionian pentatonic"],["1P 3M 4P 5P 7m","mixolydian pentatonic","indian"],["1P 2M 4P 5P 6M","ritusen"],["1P 2M 4P 5P 7m","egyptian"],["1P 3M 4P 5d 7m","neapolitan major pentatonic"],["1P 3m 4P 5P 6m","vietnamese 1"],["1P 2m 3m 5P 6m","pelog"],["1P 2m 4P 5P 6m","kumoijoshi"],["1P 2M 3m 5P 6m","hirajoshi"],["1P 2m 4P 5d 7m","iwato"],["1P 2m 4P 5P 7m","in-sen"],["1P 3M 4A 5P 7M","lydian pentatonic","chinese"],["1P 3m 4P 6m 7m","malkos raga"],["1P 3m 4P 5d 7m","locrian pentatonic","minor seven flat five pentatonic"],["1P 3m 4P 5P 7m","minor pentatonic","vietnamese 2"],["1P 3m 4P 5P 6M","minor six pentatonic"],["1P 2M 3m 5P 6M","flat three pentatonic","kumoi"],["1P 2M 3M 5P 6m","flat six pentatonic"],["1P 2m 3M 5P 6M","scriabin"],["1P 3M 5d 6m 7m","whole tone pentatonic"],["1P 3M 4A 5A 7M","lydian #5p pentatonic"],["1P 3M 4A 5P 7m","lydian dominant pentatonic"],["1P 3m 4P 5P 7M","minor #7m pentatonic"],["1P 3m 4d 5d 7m","super locrian pentatonic"],["1P 2M 3m 4P 5P 7M","minor hexatonic"],["1P 2A 3M 5P 5A 7M","augmented"],["1P 2M 4P 5P 6M 7m","piongio"],["1P 2m 3M 4A 6M 7m","prometheus neapolitan"],["1P 2M 3M 4A 6M 7m","prometheus"],["1P 2m 3M 5d 6m 7m","mystery #1"],["1P 2m 3M 4P 5A 6M","six tone symmetric"],["1P 2M 3M 4A 5A 6A","whole tone","messiaen's mode #1"],["1P 2m 4P 4A 5P 7M","messiaen's mode #5"],["1P 2M 3M 4P 5d 6m 7m","locrian major","arabian"],["1P 2m 3M 4A 5P 6m 7M","double harmonic lydian"],["1P 2m 2A 3M 4A 6m 7m","altered","super locrian","diminished whole tone","pomeroy"],["1P 2M 3m 4P 5d 6m 7m","locrian #2","half-diminished","aeolian b5"],["1P 2M 3M 4P 5P 6m 7m","mixolydian b6","melodic minor fifth mode","hindu"],["1P 2M 3M 4A 5P 6M 7m","lydian dominant","lydian b7","overtone"],["1P 2M 3M 4A 5A 6M 7M","lydian augmented"],["1P 2m 3m 4P 5P 6M 7m","dorian b2","phrygian #6","melodic minor second mode"],["1P 2m 3m 4d 5d 6m 7d","ultralocrian","superlocrian bb7","superlocrian diminished"],["1P 2m 3m 4P 5d 6M 7m","locrian 6","locrian natural 6","locrian sharp 6"],["1P 2A 3M 4P 5P 5A 7M","augmented heptatonic"],["1P 2M 3m 4A 5P 6M 7m","dorian #4","ukrainian dorian","romanian minor","altered dorian"],["1P 2M 3m 4A 5P 6M 7M","lydian diminished"],["1P 2M 3M 4A 5A 7m 7M","leading whole tone"],["1P 2M 3M 4A 5P 6m 7m","lydian minor"],["1P 2m 3M 4P 5P 6m 7m","phrygian dominant","spanish","phrygian major"],["1P 2m 3m 4P 5P 6m 7M","balinese"],["1P 2m 3m 4P 5P 6M 7M","neapolitan major"],["1P 2M 3M 4P 5P 6m 7M","harmonic major"],["1P 2m 3M 4P 5P 6m 7M","double harmonic major","gypsy"],["1P 2M 3m 4A 5P 6m 7M","hungarian minor"],["1P 2A 3M 4A 5P 6M 7m","hungarian major"],["1P 2m 3M 4P 5d 6M 7m","oriental"],["1P 2m 3m 3M 4A 5P 7m","flamenco"],["1P 2m 3m 4A 5P 6m 7M","todi raga"],["1P 2m 3M 4P 5d 6m 7M","persian"],["1P 2m 3M 5d 6m 7m 7M","enigmatic"],["1P 2M 3M 4P 5A 6M 7M","major augmented","major #5","ionian augmented","ionian #5"],["1P 2A 3M 4A 5P 6M 7M","lydian #9"],["1P 2m 2M 4P 4A 5P 6m 7M","messiaen's mode #4"],["1P 2m 3M 4P 4A 5P 6m 7M","purvi raga"],["1P 2m 3m 3M 4P 5P 6m 7m","spanish heptatonic"],["1P 2M 3m 3M 4P 5P 6M 7m","bebop minor"],["1P 2M 3M 4P 5P 5A 6M 7M","bebop major"],["1P 2m 3m 4P 5d 5P 6m 7m","bebop locrian"],["1P 2M 3m 4P 5P 6m 7m 7M","minor bebop"],["1P 2M 3M 4P 5d 5P 6M 7M","ichikosucho"],["1P 2M 3m 4P 5P 6m 6M 7M","minor six diminished"],["1P 2m 3m 3M 4A 5P 6M 7m","half-whole diminished","dominant diminished","messiaen's mode #2"],["1P 3m 3M 4P 5P 6M 7m 7M","kafi raga"],["1P 2M 3M 4P 4A 5A 6A 7M","messiaen's mode #6"],["1P 2M 3m 3M 4P 5d 5P 6M 7m","composite blues"],["1P 2M 3m 3M 4A 5P 6m 7m 7M","messiaen's mode #3"],["1P 2m 2M 3m 4P 4A 5P 6m 6M 7M","messiaen's mode #7"],["1P 2m 2M 3m 3M 4P 5d 5P 6m 6M 7m 7M","chromatic"]],hl=cl,ul={...ye,intervals:[],aliases:[]},Ze={};function Fi(t){return Ze[t]||ul}function dl(t,n,e=[]){const s={...ji(t),name:n,intervals:t,aliases:e};return Ze[s.name]=s,Ze[s.setNum]=s,Ze[s.chroma]=s,s.aliases.forEach(r=>fl(s,r)),s}function fl(t,n){Ze[n]=t}hl.forEach(([t,n,...e])=>dl(t.split(" "),n,e));var Li={empty:!0,name:"",symbol:"",root:"",bass:"",rootDegree:0,type:"",tonic:null,setNum:NaN,quality:"Unknown",chroma:"",normalized:"",aliases:[],notes:[],intervals:[]};function ml(t){const[n,e,s,r]=Or(t);return n===""?sr("",t):n==="A"&&r==="ug"?sr("","aug"):sr(n+e,s+r)}function sr(t,n){const e=n.split("/");if(e.length===1)return[t,e[0],""];const[s,r,i,a]=Or(e[1]);return s!==""&&i===""&&a===""?[t,e[0],s+r]:[t,n,""]}function Ie(t){if(Array.isArray(t))return ir(t[1]||"",t[0],t[2]);if(t==="")return Li;{const[n,e,s]=ml(t),r=ir(e,n,s);return r.empty?ir(t):r}}function ir(t,n,e){const s=rl(t),r=It(n||""),i=It(e||"");if(s.empty||n&&r.empty||e&&i.empty)return Li;const a=Ts(r.pc,i.pc),o=s.intervals.indexOf(a),l=o>=0,d=l?i:It(""),m=o===-1?NaN:o+1,f=i.pc&&i.pc!==r.pc,p=Array.from(s.intervals);if(l)for(let v=1;v<m;v++){const y=p[0][0],_=p[0][1],k=parseInt(y,10)+7;p.push(`${k}${_}`),p.shift()}else if(f){const v=al(Ts(r.pc,i.pc),"8P");v&&p.unshift(v)}const h=r.empty?[]:p.map(v=>Kn(r.pc,v));t=s.aliases.indexOf(t)!==-1?t:s.aliases[0];const b=`${r.empty?"":r.pc}${t}${l&&m>1?"/"+d.pc:f?"/"+i.pc:""}`,g=`${n?r.pc+" ":""}${s.name}${l&&m>1?" over "+d.pc:f?" over "+i.pc:""}`;return{...s,name:g,symbol:b,tonic:r.pc,type:s.name,root:d.pc,bass:f?i.pc:"",intervals:p,rootDegree:m,notes:h}}var pl=[[.125,"dl",["large","duplex longa","maxima","octuple","octuple whole"]],[.25,"l",["long","longa"]],[.5,"d",["double whole","double","breve"]],[1,"w",["whole","semibreve"]],[2,"h",["half","minim"]],[4,"q",["quarter","crotchet"]],[8,"e",["eighth","quaver"]],[16,"s",["sixteenth","semiquaver"]],[32,"t",["thirty-second","demisemiquaver"]],[64,"sf",["sixty-fourth","hemidemisemiquaver"]],[128,"h",["hundred twenty-eighth"]],[256,"th",["two hundred fifty-sixth"]]],gl=pl;gl.forEach(([t,n,e])=>void 0);var bl="C C# D D# E F F# G G# A A# B".split(" "),yl="C Db D Eb E F Gb G Ab A Bb B".split(" ");function Br(t,n={}){if(isNaN(t)||t===-1/0||t===1/0)return"";t=Math.round(t);const s=(n.sharps===!0?bl:yl)[t%12];if(n.pitchClass)return s;const r=Math.floor(t/12)-1;return s+r}var Te=It,Ft=t=>Te(t).pc,or=t=>Te(t).oct,vt=t=>Te(t).midi;function Qt(t){return Br(t)}var Ht=Kn,vl=t=>{const n=Te(t);return n.empty?"":Br(n.midi||n.chroma,{sharps:n.alt>0,pitchClass:n.midi===null})};function _l(t,n){const e=Te(t);if(e.empty)return"";const s=Te(n||Br(e.midi||e.chroma,{sharps:e.alt<0,pitchClass:!0}));if(s.empty||s.chroma!==e.chroma)return"";if(e.oct===void 0)return s.pc;const r=e.chroma-e.alt,i=s.chroma-s.alt,a=r>11||i<0?-1:r<0||i>11?1:0,o=e.oct+a;return s.pc+o}var zr=[[0,2773,0,"ionian","","Maj7","major"],[1,2902,2,"dorian","m","m7"],[2,3418,4,"phrygian","m","m7"],[3,2741,-1,"lydian","","Maj7"],[4,2774,1,"mixolydian","","7"],[5,2906,3,"aeolian","m","m7","minor"],[6,3434,5,"locrian","dim","m7b5"]],Bs={...ye,name:"",alt:0,modeNum:NaN,triad:"",seventh:"",aliases:[]},wl=zr.map(xl),_r={};wl.forEach(t=>{_r[t.name]=t,t.aliases.forEach(n=>{_r[n]=t})});function $i(t){return typeof t=="string"?_r[t.toLowerCase()]||Bs:t&&t.name?$i(t.name):Bs}function xl(t){const[n,e,s,r,i,a,o]=t,l=o?[o]:[],d=Number(e).toString(2);return{empty:!1,intervals:Fi(r).intervals,modeNum:n,chroma:d,normalized:d,name:r,setNum:e,alt:s,triad:i,seventh:a,aliases:l}}function Hi(t){return(n,e)=>{const s=$i(n);if(s.empty)return[];const r=Oi(s.modeNum,t),i=s.intervals.map(a=>Kn(e,a));return r.map((a,o)=>i[o]+a)}}Hi(zr.map(t=>t[4]));Hi(zr.map(t=>t[5]));var Sl={empty:!0,name:"",type:"",tonic:null,setNum:NaN,chroma:"",normalized:"",aliases:[],notes:[],intervals:[]};function kl(t){if(typeof t!="string")return["",""];const n=t.indexOf(" "),e=It(t.substring(0,n));if(e.empty){const r=It(t);return r.empty?["",t.toLowerCase()]:[r.name,""]}const s=t.substring(e.name.length+1).toLowerCase();return[e.name,s.length?s:""]}function Al(t){const n=Array.isArray(t)?t:kl(t),e=It(n[0]).name,s=Fi(n[1]);if(s.empty)return Sl;const r=s.name,i=e?s.intervals.map(o=>Kn(e,o)):[],a=e?e+" "+r:r;return{...s,name:a,type:r,tonic:e,notes:i}}function Dt(t){return vl(t)||t}const Ml=/([#b](?:5|9|11|13)|add(?:9|11|13|b9|#9|b13|#11))$/,Pl={"#5":"5A",b5:"5d","#9":"2A",b9:"2m","#11":"4A",b11:"4d","#13":"6A",b13:"6m",add9:"2M",add11:"4P",add13:"6M",addb9:"2m","add#9":"2A","add#11":"4A",addb13:"6m"};function El(t){const n=t.match(/^([A-G][#b]?)/);if(!n)return null;const e=n[1];let s=t.slice(e.length);const r=[];let i=0;for(;s&&i<5;){const a=s.match(Ml);if(!a)break;const o=a[1],l=Pl[o];if(!l)break;r.unshift(l),s=s.slice(0,-o.length),i++;const d=Ie(e+s);if(!d.empty){let m=d.notes.map(Dt);for(const f of r){const p=Ht(e,f);if(p){const h=Dt(p);m.includes(h)||m.push(h)}}return{notes:m,root:Dt(e),type:d.type+" (extended)"}}}return null}function Cl(t){const n=t.match(/^([A-G][#b]?)/i);if(!n)return t;const e=n[1];let s=t.slice(e.length);return s=s.replace(/^maug$/i,"m#5"),s=s.replace(/mmaj/i,"mMaj"),e+s}function Nl(t){const n=t.match(/^([A-G][#b]?)/i);if(!n)return null;const e=n[1],s=t.slice(e.length);return/^7omit3$/i.test(s)?{notes:[e,Ht(e,"5P"),Ht(e,"7m")].map(Dt),root:Dt(e),type:"7omit3"}:/^m7sus4?$/i.test(s)?{notes:[e,Ht(e,"3m"),Ht(e,"4P"),Ht(e,"7m")].map(Dt),root:Dt(e),type:"m7sus4"}:/^m6\/9$/i.test(s)?{notes:[e,Ht(e,"3m"),Ht(e,"5P"),Ht(e,"6M"),Ht(e,"2M")].map(Dt),root:Dt(e),type:"m6/9"}:null}function mn(t,n){t=Cl(t);const e=Ie(t);let s,r,i,a;const o=Nl(t);if(o)s=o.notes,r=o.root,i=o.type;else if(!e.empty)s=e.notes.map(Dt),r=Dt(e.tonic??s[0]),i=e.type,a=e.intervals;else{const l=El(t);if(!l)throw new Error(`Unknown chord: "${t}"`);s=l.notes,r=l.root,i=l.type}if(n&&n>0){const l=n%s.length;s=[...s.slice(l),...s.slice(0,l)]}return{notes:s,root:r,type:i,intervals:a}}const Il=new Set(["C","D","F","G","A"]);function ke(t){return Il.has(gt[(t%7+7)%7])}function Oe(t){return Gn(t).replace("#","")}function Tl(t,n){const e=gt.indexOf(t);let s=gt.indexOf(n);return s<e&&(s+=7),s-e}function zs(t,n){const e=(t%7+7)%7,s=(n%7+7)%7;return e===1&&(t-=1),e===4&&(t-=1),e===5&&(t-=2),s===1&&(n+=1),s===4&&(n+=2),s===5&&(n+=1),{startIdx:t,endIdx:n}}function qn(t,n={}){const{padding:e=1,startingNote:s,spanFrom:r,spanTo:i}=n;if(s){const M=Oe(s);let w=gt.indexOf(M)-e,T=!1;ke(w)&&(w-=1,T=!0);const P=gt[(w%7+7)%7];if(t.length>0){const j=t.map(Oe),C=gt.indexOf(M),L=[];for(const R of j){let J=gt.indexOf(R);if(L.length===0)for(;J<C;)J+=7;else{const tt=L[L.length-1];for(;J<=tt;)J+=7}L.push(J)}let A=Math.max(...L)+e,N=!1;ke(A)&&(A+=1,N=!0);const u=zs(w,A);w=u.startIdx,A=u.endIdx;const z=gt[(w%7+7)%7];let Q=A-w+1;const W=gt.indexOf(M),st=gt.indexOf(z),$=((W-st)%7+7)%7,X=$===0&&e>0?7:$;let B=0;for(let R=1;R<=X;R++)gt[(st+R)%7]==="C"&&B++;return{startFrom:z,size:Math.max(Q,t.length+2),chordOctave:B,clipLeft:T,clipRight:N}}return{startFrom:P,size:8,chordOctave:0,clipLeft:T}}if(r&&i){const M=Oe(r),w=Oe(i),T=Tl(M,w);return{startFrom:M,size:T===0?8:T+1,chordOctave:0}}if(t.length===0)return{startFrom:"C",size:8,chordOctave:0};const a=t.map(Oe),o=[];for(const M of a){let w=gt.indexOf(M);if(o.length>0){const T=o[o.length-1];for(;w<=T;)w+=7}o.push(w)}const l=o[0],d=o[o.length-1];let m=l-e,f=d+e,p=!1,h=!1;ke(m)&&(m-=1,p=!0),ke(f)&&(f+=1,h=!0);const b=zs(m,f);m=b.startIdx,f=b.endIdx;const g=gt[(m%7+7)%7],v=f-m+1,y=l-m,_=gt.indexOf(g);let k=0;for(let M=1;M<=y;M++){const w=(_+M)%7;gt[w]==="C"&&k++}return{startFrom:g,size:Math.max(v,t.length+2),chordOctave:k,clipLeft:p,clipRight:h}}const Rl={i:0,ii:2,iii:4,iv:5,v:7,vi:9,vii:11};function Ol(t){const n=/^([#b]?)(iv|vi{1,2}|i{1,3}|v)(.*)/i,e=t.match(n);if(!e)return null;const s=e[1],r=e[2],i=e[3],a=r.toLowerCase(),o=Rl[a];if(o===void 0)return null;let l=o;s==="b"&&(l-=1),s==="#"&&(l+=1),l=(l%12+12)%12;const d=r===r.toLowerCase();let m="";if(i){let f=i.replace(/^°7/,"dim7").replace(/^°/,"dim").replace(/^ø7?/,"m7b5").replace(/^Δ7?/,"maj7");d&&!f.startsWith("m")&&!f.startsWith("dim")&&!f.startsWith("M")?m="m"+f:m=f}else m=d?"m":"";return{semitones:l,quality:m,hasFlat:s==="b"}}function Ui(t,n){const e=vt(`${n}4`);if(e==null)throw new Error(`Invalid key: ${n}`);return t.map(s=>{const r=Ol(s);if(!r)throw new Error(`Can't parse roman numeral: "${s}"`);const i=e+r.semitones,a=Ft(Qt(i)),o=jo(a,n,r.hasFlat),l=o+r.quality;return{root:o,symbol:l,degree:r.semitones}})}function Wi(t){return t.split(/[\s\-–—→>]+/).map(n=>n.trim()).filter(n=>n.length>0)}const Pn=[{id:"ii-V-I",name:"ii-V-I",numerals:["ii7","V7","Imaj7"],description:"The most common jazz cadence"},{id:"minor-ii-V-i",name:"Minor ii-V-i",numerals:["iiø7","V7","i7"],description:"Minor key ii-V-i cadence"},{id:"I-vi-ii-V",name:"I-vi-ii-V",numerals:["Imaj7","vi7","ii7","V7"],description:"Classic turnaround (rhythm changes A section)"},{id:"iii-vi-ii-V",name:"iii-vi-ii-V",numerals:["iii7","vi7","ii7","V7"],description:"Extended turnaround from the iii chord"},{id:"blues",name:"12-Bar Blues",numerals:["I7","IV7","I7","I7","IV7","IV7","I7","I7","V7","IV7","I7","V7"],description:"Standard 12-bar blues progression"},{id:"jazz-blues",name:"Jazz Blues",numerals:["I7","IV7","I7","vi7","ii7","V7","I7","vi7","ii7","V7","I7","ii7","V7"],description:"Jazz blues with ii-V turnarounds"},{id:"rhythm-changes",name:"Rhythm Changes (A)",numerals:["Imaj7","vi7","ii7","V7","iii7","vi7","ii7","V7"],description:"A section of rhythm changes (I Got Rhythm)"},{id:"modal-vamp",name:"Modal Vamp",numerals:["i7","bVII7"],description:"Two-chord modal vamp (So What / Impressions style)"},{id:"backdoor-ii-V",name:"Backdoor ii-V",numerals:["iv7","bVII7","Imaj7"],description:"Backdoor resolution via bVII to I"},{id:"tritone-sub",name:"Tritone Sub ii-V-I",numerals:["ii7","bII7","Imaj7"],description:"ii-V-I with tritone substitution on the V"}],Bl={blues:"blues",jazzblues:"jazz-blues",rhythmchanges:"rhythm-changes",rhythmchange:"rhythm-changes",turnaround:"I-vi-ii-V",modalvamp:"modal-vamp",backdoor:"backdoor-ii-V",tritonesub:"tritone-sub",tritonesubstitution:"tritone-sub",minoriivi:"minor-ii-V-i","minorii-v-i":"minor-ii-V-i"};function Gi(t){const n=t.toLowerCase().replace(/[\s\-–—]+/g,""),e=Pn.find(r=>r.id.replace(/-/g,"").toLowerCase()===n);if(e)return e;const s=Bl[n];return s?Pn.find(r=>r.id===s):Pn.find(r=>{const i=r.name.toLowerCase().replace(/[\s\-–—]+/g,"");return i.includes(n)||n.includes(i)})}const zl=[{id:"shell-maj7-r7",name:"Shell Maj7 (Root + 7)",quality:"maj7",intervals:[0,11],tags:{era:"Bebop",style:"Shell",artist:"Bud Powell",source:"Shell Voicings"},range:{min:36,max:60}},{id:"shell-maj7-r3",name:"Shell Maj7 (Root + 3)",quality:"maj7",intervals:[0,4],tags:{era:"Bebop",style:"Shell",artist:"Bud Powell",source:"Shell Voicings"},range:{min:36,max:60}},{id:"shell-maj7-tenth",name:"Shell Maj7 (Tenth)",quality:"maj7",intervals:[0,16],tags:{era:"Bebop",style:"Shell",artist:"Bud Powell",source:"Shell Voicings"},range:{min:36,max:55}},{id:"shell-min7-r7",name:"Shell m7 (Root + b7)",quality:"min7",intervals:[0,10],tags:{era:"Bebop",style:"Shell",artist:"Bud Powell",source:"Shell Voicings"},range:{min:36,max:60}},{id:"shell-min7-r3",name:"Shell m7 (Root + b3)",quality:"min7",intervals:[0,3],tags:{era:"Bebop",style:"Shell",artist:"Bud Powell",source:"Shell Voicings"},range:{min:36,max:60}},{id:"shell-min7-tenth",name:"Shell m7 (Tenth)",quality:"min7",intervals:[0,15],tags:{era:"Bebop",style:"Shell",artist:"Bud Powell",source:"Shell Voicings"},range:{min:36,max:55}},{id:"shell-dom7-r7",name:"Shell Dom7 (Root + b7)",quality:"dom7",intervals:[0,10],tags:{era:"Bebop",style:"Shell",artist:"Bud Powell",source:"Shell Voicings"},range:{min:36,max:60}},{id:"shell-dom7-r3",name:"Shell Dom7 (Root + 3)",quality:"dom7",intervals:[0,4],tags:{era:"Bebop",style:"Shell",artist:"Bud Powell",source:"Shell Voicings"},range:{min:36,max:60}},{id:"shell-dom7-tenth",name:"Shell Dom7 (Tenth)",quality:"dom7",intervals:[0,16],tags:{era:"Bebop",style:"Shell",artist:"Bud Powell",source:"Shell Voicings"},range:{min:36,max:55}}],jl=[{id:"rootless-maj7-a",name:"Rootless Maj7 Type A (3-5-7-9)",quality:"maj7",intervals:[4,7,11,14],tags:{era:"Post-Bop",style:"Rootless Type A",artist:"Bill Evans",source:"Rootless Voicings"},range:{min:50,max:67}},{id:"rootless-maj7-b",name:"Rootless Maj7 Type B (7-9-3-5)",quality:"maj7",intervals:[11,14,16,19],tags:{era:"Post-Bop",style:"Rootless Type B",artist:"Bill Evans",source:"Rootless Voicings"},range:{min:50,max:67}},{id:"rootless-min7-a",name:"Rootless m7 Type A (b3-5-b7-9)",quality:"min7",intervals:[3,7,10,14],tags:{era:"Post-Bop",style:"Rootless Type A",artist:"Bill Evans",source:"Rootless Voicings"},range:{min:50,max:67}},{id:"rootless-min7-b",name:"Rootless m7 Type B (b7-9-b3-5)",quality:"min7",intervals:[10,14,15,19],tags:{era:"Post-Bop",style:"Rootless Type B",artist:"Bill Evans",source:"Rootless Voicings"},range:{min:50,max:67}},{id:"rootless-dom7-a",name:"Rootless Dom7 Type A (3-13-b7-9)",quality:"dom7",intervals:[4,9,10,14],tags:{era:"Post-Bop",style:"Rootless Type A",artist:"Bill Evans",source:"Rootless Voicings"},range:{min:50,max:67}},{id:"rootless-dom7-b",name:"Rootless Dom7 Type B (b7-9-3-13)",quality:"dom7",intervals:[10,14,16,21],tags:{era:"Post-Bop",style:"Rootless Type B",artist:"Bill Evans",source:"Rootless Voicings"},range:{min:50,max:67}},{id:"rootless-alt-a",name:"Rootless Alt Type A (3-b7-#9-b13)",quality:"alt",intervals:[4,10,15,20],tags:{era:"Post-Bop",style:"Rootless Type A",artist:"Bill Evans",source:"Altered Voicings"},range:{min:50,max:67}},{id:"rootless-alt-b",name:"Rootless Alt Type B (b7-#9-3-b13)",quality:"alt",intervals:[10,15,16,20],tags:{era:"Post-Bop",style:"Rootless Type B",artist:"Bill Evans",source:"Altered Voicings"},range:{min:50,max:67}},{id:"rootless-m7b5-a",name:"Rootless m7b5 Type A (b3-b5-b7-9)",quality:"m7b5",intervals:[3,6,10,14],tags:{era:"Post-Bop",style:"Rootless Type A",artist:"Bill Evans",source:"Rootless Voicings"},range:{min:50,max:67}},{id:"rootless-m7b5-b",name:"Rootless m7b5 Type B (b7-9-b3-b5)",quality:"m7b5",intervals:[10,14,15,18],tags:{era:"Post-Bop",style:"Rootless Type B",artist:"Bill Evans",source:"Rootless Voicings"},range:{min:50,max:67}}],Dl=[{id:"quartal-3note",name:"Quartal Stack (3 notes)",quality:"sus4",intervals:[0,5,10],tags:{era:"Modal",style:"Quartal",artist:"McCoy Tyner",source:"Quartal Voicings"},range:{min:48,max:72}},{id:"quartal-4note",name:"Quartal Stack (4 notes)",quality:"min7",intervals:[0,5,10,15],tags:{era:"Modal",style:"Quartal",artist:"McCoy Tyner",source:"Quartal Voicings"},range:{min:48,max:72}},{id:"modal-so-what",name:"So What Chord (3 P4ths + M3)",quality:"min7",intervals:[0,5,10,15,19],tags:{era:"Modal",style:"Quartal",artist:"McCoy Tyner",source:"Quartal Voicings"},range:{min:48,max:72}},{id:"phrygian-stack",name:"Phrygian Stack (5 notes)",quality:"sus4",intervals:[0,5,10,15,20],tags:{era:"Modal",style:"Quartal",artist:"Kenny Barron",source:"Quartal Voicings"},range:{min:48,max:72}}],Fl=[{id:"us-II",name:"Upper Structure II (Lydian Dominant)",quality:"dom7",intervals:[4,10,14,18,21],hands:["LH","LH","RH","RH","RH"],tags:{era:"Modern",style:"Upper Structure",artist:"Herbie Hancock",source:"Upper Structures"},range:{min:48,max:72}},{id:"us-bVI",name:"Upper Structure bVI (Altered)",quality:"alt",intervals:[4,10,20,24,27],hands:["LH","LH","RH","RH","RH"],tags:{era:"Modern",style:"Upper Structure",artist:"Herbie Hancock",source:"Upper Structures"},range:{min:48,max:72}},{id:"us-bV",name:"Upper Structure bV (Altered #2)",quality:"alt",intervals:[4,10,18,22,25],hands:["LH","LH","RH","RH","RH"],tags:{era:"Modern",style:"Upper Structure",artist:"Herbie Hancock",source:"Upper Structures"},range:{min:48,max:72}},{id:"us-VI",name:"Upper Structure VI (Diminished Sound)",quality:"dom7",intervals:[4,10,21,25,28],hands:["LH","LH","RH","RH","RH"],tags:{era:"Modern",style:"Upper Structure",artist:"Herbie Hancock",source:"Upper Structures"},range:{min:48,max:72}}],Ll=[{id:"drop2-maj6",name:"Drop 2 Maj6 (5th in bass)",quality:"maj6",intervals:[-5,0,4,9],tags:{era:"Hard Bop",style:"Drop 2",artist:"Barry Harris",source:"Drop 2 Voicings"},range:{min:48,max:72}},{id:"drop2-maj6-inv2",name:"Drop 2 Maj6 (6th in bass)",quality:"maj6",intervals:[-3,4,7,12],tags:{era:"Hard Bop",style:"Drop 2",artist:"Barry Harris",source:"Drop 2 Voicings"},range:{min:48,max:72}},{id:"drop2-min7",name:"Drop 2 m7 (5th in bass)",quality:"min7",intervals:[-5,0,3,10],tags:{era:"Hard Bop",style:"Drop 2",artist:"Bill Evans",source:"Drop 2 Voicings"},range:{min:48,max:72}},{id:"drop2-dom7",name:"Drop 2 Dom7 (5th in bass)",quality:"dom7",intervals:[-5,0,4,10],tags:{era:"Hard Bop",style:"Drop 2",source:"Drop 2 Voicings"},range:{min:48,max:72}},{id:"drop2-m7b5",name:"Drop 2 m7b5 (b5 in bass)",quality:"m7b5",intervals:[-6,0,3,10],tags:{era:"Hard Bop",style:"Drop 2",source:"Drop 2 Voicings"},range:{min:48,max:72}}],$l=[{id:"drop24-maj7",name:"Drop 2+4 Maj7",quality:"maj7",intervals:[-8,-1,4,7],tags:{era:"Hard Bop",style:"Drop 2+4",source:"Drop 2+4 Voicings"},range:{min:48,max:72}},{id:"drop24-min7",name:"Drop 2+4 m7",quality:"min7",intervals:[-9,-2,3,7],tags:{era:"Hard Bop",style:"Drop 2+4",source:"Drop 2+4 Voicings"},range:{min:48,max:72}},{id:"drop24-dom7",name:"Drop 2+4 Dom7",quality:"dom7",intervals:[-8,-2,4,7],tags:{era:"Hard Bop",style:"Drop 2+4",source:"Drop 2+4 Voicings"},range:{min:48,max:72}},{id:"drop24-m7b5",name:"Drop 2+4 m7b5",quality:"m7b5",intervals:[-8,-2,3,6],tags:{era:"Hard Bop",style:"Drop 2+4",source:"Drop 2+4 Voicings"},range:{min:48,max:72}}],Hl=[{id:"spread-maj7",name:"Spread Maj7 (3+7 low, 9+5 high)",quality:"maj7",intervals:[0,4,11,14,19],tags:{era:"Modern",style:"Spread",source:"Big Band Arranging"},range:{min:36,max:72}},{id:"spread-min7",name:"Spread m7 (3+7 low, 9+5 high)",quality:"min7",intervals:[0,3,10,14,19],tags:{era:"Modern",style:"Spread",source:"Big Band Arranging"},range:{min:36,max:72}},{id:"spread-dom7",name:"Spread Dom7 (3+7 low, 9+13 high)",quality:"dom7",intervals:[0,4,10,14,21],tags:{era:"Modern",style:"Spread",source:"Big Band Arranging"},range:{min:36,max:72}},{id:"spread-dom7-sharp11",name:"Spread Dom7#11 (3+7 low, #11+9 high)",quality:"dom7",intervals:[0,4,10,14,18],tags:{era:"Modern",style:"Spread",source:"Big Band Arranging"},range:{min:36,max:72}},{id:"spread-m7b5",name:"Spread m7b5 (3+7 low, 9+b5 high)",quality:"m7b5",intervals:[0,3,10,13,18],tags:{era:"Modern",style:"Spread",source:"Big Band Arranging"},range:{min:36,max:72}}],Ul=[{id:"4close-maj7",name:"4-Note Closed Maj7 (1-3-7-9)",quality:"maj7",intervals:[0,4,11,14],tags:{era:"Modern",style:"4-Note Closed",artist:"Sammy Nestico",source:"Big Band Arranging"},range:{min:48,max:72}},{id:"4close-min7",name:"4-Note Closed m7 (1-3-7-9)",quality:"min7",intervals:[0,3,10,14],tags:{era:"Modern",style:"4-Note Closed",artist:"Sammy Nestico",source:"Big Band Arranging"},range:{min:48,max:72}},{id:"4close-dom7",name:"4-Note Closed Dom7 (3-13-7-9)",quality:"dom7",intervals:[4,9,10,14],tags:{era:"Modern",style:"4-Note Closed",artist:"Sammy Nestico",source:"Big Band Arranging"},range:{min:48,max:72}},{id:"4close-dom13",name:"4-Note Closed Dom13 (3-13-9-7)",quality:"dom7",intervals:[4,10,14,21],tags:{era:"Modern",style:"4-Note Closed",artist:"Sammy Nestico",source:"Big Band Arranging"},range:{min:55,max:72}},{id:"4close-m7b5",name:"4-Note Closed m7b5 (1-b3-b5-9)",quality:"m7b5",intervals:[0,3,6,14],tags:{era:"Modern",style:"4-Note Closed",artist:"Sammy Nestico",source:"Big Band Arranging"},range:{min:48,max:72}}],Yn=[...zl,...jl,...Dl,...Fl,...Ll,...$l,...Hl,...Ul],Vi={Db:"C#",Eb:"D#",Gb:"F#",Ab:"G#",Bb:"A#"},Wl={"C#":"Db","D#":"Eb","F#":"Gb","G#":"Ab","A#":"Bb"},Gl=new Set(["F","Bb","Eb","Ab","Db","Gb","Cb"]);function wr(t){return Vi[t]??t}function Vl(t,n){return Gl.has(n)?Wl[t]??t:Vi[t]??t}const Kl={"bud powell":{style:"Shell"},"thelonious monk":{style:"Shell"},bebop:{style:"Shell"},"count basie":{style:"Shell"},basie:{style:"Shell"},"bill evans":{style:"Rootless Type A"},"wynton kelly":{style:"Rootless Type A"},comping:{style:"Rootless Type A"},rootless:{style:"Rootless Type A"},"mccoy tyner":{style:"Quartal"},modal:{style:"Quartal"},"so what":{style:"Quartal"},"herbie hancock":{style:"Upper Structure"},"upper structure":{style:"Upper Structure"},altered:{style:"Upper Structure"},"duke ellington":{style:"Drop 2"},ellington:{style:"Drop 2"},"george shearing":{style:"Drop 2"},"barry harris":{style:"Drop 2"},block:{style:"Drop 2"},"drop 2+4":{style:"Drop 2+4"},"drop 2 and 4":{style:"Drop 2+4"},"drop 2":{style:"Drop 2"},"locked hands":{style:"Drop 2"},spread:{style:"Spread"},"sax section":{style:"Spread"},"sammy nestico":{style:"4-Note Closed"},nestico:{style:"4-Note Closed"},"4-note closed":{style:"4-Note Closed"},"four note closed":{style:"4-Note Closed"},"trumpet section":{style:"4-Note Closed"}};function Zn(t,n){const e=t.toLowerCase();if(e.includes("alt"))return"alt";if(e.includes("dim7")||e.includes("diminished seventh"))return"dim7";if(e.includes("m7b5")||e.includes("half"))return"m7b5";if(e.includes("sus"))return"sus4";if(e.includes("min")||e.includes("minor"))return e==="minor"||e==="minor triad"?void 0:e.includes("6/9")||e.includes("6add9")?"m6/9":e.includes("6")?"min6":"min7";if(e.includes("maj")||e.includes("major"))return e==="major"||e==="major triad"?void 0:"maj7";if(e.includes("dom")||e.includes("7")||e.includes("9")||e.includes("13"))return"dom7";if(e.includes("6/9"))return"6/9";if(e.includes("6"))return"maj6"}function jr(t){const n=t.toLowerCase().trim();for(const[e,s]of Object.entries(Kl))if(n.includes(e))return s.style}function ie(t){return Yn.filter(n=>{if(t.quality&&n.quality!==t.quality||t.era&&n.tags.era!==t.era||t.style&&n.tags.style!==t.style)return!1;if(t.artist){const e=t.artist.toLowerCase();if(n.tags.artist&&!n.tags.artist.toLowerCase().includes(e)||!n.tags.artist)return!1}return!0})}function Dr(t,n,e=3){const s=vt(`${t}${e}`);return s==null?[]:n.intervals.map((r,i)=>{var f;const a=s+r,o=Qt(a),l=Ft(o),d=Vl(l,t),m=((f=n.hands)==null?void 0:f[i])??"LH";return{note:o,midi:a,pitchClass:d,hand:m}})}function ql(t,n,e=3){return Dr(t,n,e).map(s=>s.note)}function Re(t,n,e=3){return Dr(t,n,e).map(s=>s.pitchClass)}function Yl(t,n){return Yn.filter(e=>e.quality===t&&e.id!==n)}function Xn(t,n){const e=n?jr(n):void 0;if(e){const r=ie({quality:t,style:e});if(r.length>0)return r[0];if(e==="Rootless Type A"){const i=ie({quality:t,style:"Rootless Type B"});if(i.length>0)return i[0]}}const s=ie({quality:t});if(s.length>0)return s[0];n&&console.warn(`No voicing found for quality "${t}" with style hint "${n}"`)}const js={SWEET_LOW:50,SWEET_HIGH:62};function Ki(t,n){const e=ie({quality:n,style:"Rootless Type A"}),s=ie({quality:n,style:"Rootless Type B"});if(e.length===0&&s.length===0)return;if(e.length===0)return s[0];if(s.length===0)return e[0];const r=Math.min(...e[0].intervals),i=t+r;return i<js.SWEET_LOW?s[0]:(i>js.SWEET_HIGH,e[0])}function Zl(t,n,e=3,s){if(s){const a=ie({quality:n,style:s});if(a.length>0)return a[0]}const r=vt(`${t}${e}`);if(r!=null)return Ki(r,n)}function Xl(t,n){const e=vt(t);if(e==null)throw new Error(`Invalid melody note: ${t}`);const s=Ie(n);if(!s.notes.length)throw new Error(`Unknown chord symbol: ${n}`);const r=s.notes.map(p=>vt(`${p}4`)%12);if(r.length<4)throw new Error(`${n} has only ${r.length} notes — locked hands requires a 7th chord or richer`);const i=e%12;if(!r.includes(i))throw new Error(`Melody note ${t} (pc=${i}) is not a chord tone of ${n} (pcs=${r.join(",")})`);const a=[e],o=new Set([i]);let l=e-1;for(;a.length<4;){const p=(l%12+12)%12;if(r.includes(p)&&!o.has(p)&&(a.push(l),o.add(p)),l--,e-l>24)throw new Error(`Could not find enough chord tones below ${t} for ${n}`)}const d=e-12;a.sort((p,h)=>p-h);const m=[d,...a];return m.sort((p,h)=>p-h),m.map((p,h)=>{const b=Qt(p),g=Ft(b),v=h===0?"LH":"RH";return{note:b,midi:p,pitchClass:wr(g),hand:v}})}function Xe(t,n){const e=Qt(t),s=Ft(e);return{note:e,midi:t,pitchClass:s,hand:n}}function Ql(t,n){const e=Ie(`${t}${n}`);if(!e||e.empty){const r={dom7:"7",maj:"M",min:"m",maj7:"maj7",min7:"m7",dim:"dim",aug:"aug"}[n];if(r){const i=Ie(`${t}${r}`);if(i&&!i.empty)return i.notes}return[t]}return e.notes}function Qe(t,n){const e=vt(`${t}${n}`);if(e==null)throw new Error(`Cannot resolve MIDI for ${t}${n}`);return e}function Jl(t){const n=Ie(`${t}7`);if(!n||n.empty||n.notes.length<4){const e=vt(`${t}4`);if(e==null)throw new Error(`Invalid root note: ${t}`);return[Ft(Qt(e+4)),Ft(Qt(e+10))]}return[n.notes[1],n.notes[3]]}function tc(t,n){const e=[];if(n.quality==="dom7"||n.quality==="7"){const r=Jl(n.root);for(const i of r){const a=Qe(i,3);e.push(Xe(a,"LH"))}}else{const r=Qe(n.root,3);e.push(Xe(r,"LH"))}const s=Ql(t.root,t.quality);for(const r of s){const i=Qe(r,4);e.push(Xe(i,"RH"))}return e.sort((r,i)=>r.midi-i.midi),e}function ec(t,n){const e=[],s=Qe(n,3);e.push(Xe(s,"LH"));const r=_l(n),i=t.filter(o=>o!==n&&o!==r),a=i.length>0?i:t;for(const o of a){const l=Qe(o,4);e.push(Xe(l,"RH"))}return e.sort((o,l)=>o.midi-l.midi),e}function nc(t,n){return t.length===0?!1:wr(t[0])===wr(n)}function rc(t,n,e,s=3,r){const i=new Set((r==null?void 0:r.excludeIds)??[]),a=[],o=new Set,l=p=>p.join(","),d=p=>{const h=l(p.notes);return o.has(h)||i.has(p.id)?!1:(o.add(h),a.push(p),!0)};let m;if(r!=null&&r.styleHint&&n&&(m=Xn(n,r.styleHint)),m){const p=Re(t,m);d({id:m.id,label:m.tags.style,notes:p,handHints:m.hands,source:"library"})}else{const p=[...e],h=nc(p,t),b=h?"Root position":`From ${p[0]}`;d({id:h?"root-position":"default",label:b,notes:p,source:"inversion"})}if(n){const p=new Map;for(const h of Yn)h.quality===n&&(i.has(h.id)||m&&h.id===m.id||p.has(h.tags.style)||p.set(h.tags.style,h));for(const[h,b]of p){const g=Re(t,b);d({id:b.id,label:h,notes:g,handHints:b.hands,source:"library"})}}const f=["1st inv","2nd inv","3rd inv","4th inv","5th inv"];for(let p=1;p<e.length&&p<=5;p++){const h=[...e.slice(p),...e.slice(0,p)];d({id:`inv-${p}`,label:f[p-1]??`${p}th inv`,notes:h,source:"inversion"})}if(e.length>=3){const p=[e[0],...e.slice(2),e[1]];d({id:"algo-open",label:"Open voicing",notes:p,source:"algorithmic"});const h=[...e],b=h.splice(-2,1)[0];h.unshift(b),d({id:"algo-drop2",label:"Drop 2",notes:h,source:"algorithmic"})}if(e.length>=4){const p=[e[0],e[1],e[e.length-1]];d({id:"algo-simplified",label:"Simplified",notes:p,source:"algorithmic"})}return a.slice(0,s)}const qi=["Rootless Type A","Drop 2","Shell","Quartal","Spread","4-Note Closed","Rootless Type B","Upper Structure","Drop 2+4"];function sc(t){const n=jr(t);if(!n)return qi.slice(0,ge);const e=[n];return n==="Rootless Type A"?e.push("Rootless Type B","Shell"):n==="Rootless Type B"?e.push("Rootless Type A","Shell"):n==="Shell"?e.push("Rootless Type A","Drop 2"):n==="Drop 2"?e.push("Drop 2+4","Shell"):n==="Drop 2+4"?e.push("Drop 2","Spread"):n==="Quartal"?e.push("Upper Structure","Rootless Type A"):n==="Upper Structure"?e.push("Quartal","Spread"):n==="Spread"?e.push("Drop 2","4-Note Closed"):n==="4-Note Closed"&&e.push("Spread","Drop 2"),e.slice(0,ge)}function ic(t,n){const e=mn(t),s=Zn(e.type,e.notes);let r=e.notes,i;if(s&&n){const a=ie({quality:s,style:n});if(a.length>0){const o=Re(e.root,a[0]);o.length>0&&(r=o,i=n)}}if(!i&&s){const a=Xn(s);if(a){const o=Re(e.root,a);o.length>0&&(r=o,i=a.tags.style)}}return{symbol:t,root:e.root,notes:r,voicingStyle:i}}function oc(t){const n=Math.min(t.numExamples??ge,ge),e=Gi(t.progression);let s,r;e?(s=e.numerals,r=e.name):(s=Wi(t.progression),r=s.join("-"));const i=Ui(s,t.key),a=t.styleHint?sc(t.styleHint):qi.slice(0,n),o=[];for(let l=0;l<n;l++){const d=a[l%a.length],m=i.map(f=>ic(f.symbol,d));o.push({label:`Example ${l+1} — ${d}`,chords:m})}return{progressionName:r,key:t.key,examples:o}}function yn(t){if(t<128)return[t];const n=[];for(n.unshift(t&127),t>>=7;t>0;)n.unshift(t&127|128),t>>=7;return n}function _e(t){return[t>>8&255,t&255]}function vn(t){return[t>>24&255,t>>16&255,t>>8&255,t&255]}function ar(t,n=4){return/[0-9]$/.test(t)?vt(t):vt(`${t}${n}`)}function lr(t,n,e,s,r,i,a,o){const l=[],d=144|n,m=128|n;if(i){const{microsecondsPerBeat:h}=i;l.push(0,255,81,3,h>>16&255,h>>8&255,h&255)}const f=Array.from(r,h=>h.charCodeAt(0)&127);if(l.push(0,255,3,...yn(f.length),...f),a&&o)for(let h=0;h<t.length;h++){const b=h===0?0:o;l.push(...yn(b),d,t[h],e)}else for(let h=0;h<t.length;h++)l.push(...yn(0),d,t[h],e);const p=a&&o?(t.length-1)*o:0;for(let h=0;h<t.length;h++){const b=h===0?s+p:0;l.push(...yn(b),m,t[h],0)}return l.push(0,255,47,0),l}function Qn(t){const{notes:n,lhNotes:e,octave:s=4,lhOctave:r,durationTicks:i=960,velocity:a=90,tempo:o=120,arpeggiated:l=!1,arpDelayTicks:d=120}=t,m=480,f=Math.round(6e7/o);if(e&&e.length>0){const y=r??3,_=s,k=new Set(e),M=n.filter(N=>!k.has(N)),w=e.map(N=>ar(N,y)).filter(N=>N!=null),T=M.map(N=>ar(N,_)).filter(N=>N!=null);if(w.length===0&&T.length===0)return new Uint8Array(0);const P=[];w.length>0&&P.push(lr(w,0,a,i,"L.H.",{microsecondsPerBeat:f},l,d)),T.length>0&&P.push(lr(T,1,a,i,"R.H.",P.length===0?{microsecondsPerBeat:f}:void 0,l,d));const j=[77,84,104,100,...vn(6),..._e(1),..._e(P.length),..._e(m)];let C=j.length;const L=[];for(const N of P){const u=[77,84,114,107,...vn(N.length),...N];L.push(u),C+=u.length}const V=new Uint8Array(C);let A=0;V.set(j,A),A+=j.length;for(const N of L)V.set(N,A),A+=N.length;return V}const p=n.map(y=>ar(y,s)).filter(y=>y!=null);if(p.length===0)return new Uint8Array(0);const h=lr(p,0,a,i,"Chord",{microsecondsPerBeat:f},l,d),b=[77,84,104,100,...vn(6),..._e(0),..._e(1),..._e(m)],g=[77,84,114,107,...vn(h.length)],v=new Uint8Array(b.length+g.length+h.length);return v.set(b,0),v.set(g,b.length),v.set(h,b.length+g.length),v}function Yi(t,n,e=4,s,r){const i=Qn({notes:t,octave:e,lhNotes:s,lhOctave:r});if(i.length===0)return;const a=new Blob([i.buffer],{type:"audio/midi"}),o=URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=`${n.replace(/[^a-zA-Z0-9\-_ ]/g,"_").slice(0,100)}.mid`,l.click(),URL.revokeObjectURL(o)}const Zi="1.1.0";function Xi(t,n){if(!n.enabled||!n.endpoint)return;const e={logSchema:Zi,...t,versions:n.versions??{},timestamp:new Date().toISOString()};try{fetch(n.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{})}catch{}}function ac(t){const n=t.match(/^(\d+)(.*)/);return n?{degree:parseInt(n[1],10),quality:n[2]}:{degree:0,quality:""}}const lc=["","I","II","III","IV","V","VI","VII"],cc={9:"IX",10:"X",11:"XI",12:"XII",13:"XIII"};function hc(t){const n=t>7?t-7:t;return n===1||n===4||n===5?"P":"M"}function uc(t){const{degree:n,quality:e}=ac(t);if(n===0)return"?";const s=n<=7?lc[n]??String(n):cc[n]??String(n),r=hc(n);return e===r?s:e==="m"||e==="d"?`b${s}`:e==="A"?`#${s}`:e==="dd"?`bb${s}`:s}function Ds(t){return t.map(uc)}const dc={"natural minor":"minor","minor harmonic":"harmonic minor","minor melodic":"melodic minor","major pentatonic":"major pentatonic","minor pentatonic":"minor pentatonic","whole tone":"whole tone",bebop:"bebop major"};function fc(t,n,e,s=1){let r=n;n==="melodic minor"&&e==="descending"&&(r="minor");const i=dc[r]??r,a=Al(`${t} ${i}`);if(a.empty)throw new Error(`Unknown scale: "${t} ${n}"`);const o=a.notes,l=a.intervals,d=[];for(let m=0;m<s;m++)d.push(...o);return d.push(o[0]),{notes:d,root:t,type:n,intervals:l}}const Fs={C:"#e81c1c","C#":"#d44a1a",D:"#f09819","D#":"#c8b816",E:"#f5e616",F:"#59b816","F#":"#16a085",G:"#16a3b8","G#":"#1670b8",A:"#5b16b8","A#":"#8b16b8",B:"#b816a0"},mc={name:"boomwhacker",whiteKey:(t,n)=>n?Fs[t]??oe:oe,blackKey:(t,n)=>n?Fs[t]??ae:ae},Ls={C:{hex:"#f86e6e",cmyk:[0,56,56,3]},"C#":{hex:"#f58841",cmyk:[0,44,73,4]},D:{hex:"#ffbc57",cmyk:[0,26,66,0]},"D#":{hex:"#b8a334",cmyk:[0,11,72,28]},E:{hex:"#fff56d",cmyk:[0,4,57,0]},F:{hex:"#b3f888",cmyk:[28,0,45,3]},"F#":{hex:"#93d154",cmyk:[30,0,60,18]},G:{hex:"#6bc6a0",cmyk:[46,0,19,22]},"G#":{hex:"#7ee8df",cmyk:[46,0,4,9]},A:{hex:"#88a7f8",cmyk:[45,33,0,3]},"A#":{hex:"#cc97e8",cmyk:[12,35,0,9]},B:{hex:"#e277b1",cmyk:[0,47,22,11]}},pc={name:"crf",whiteKey:(t,n)=>{var e;return n?((e=Ls[t])==null?void 0:e.hex)??oe:oe},blackKey:(t,n)=>{var e;return n?((e=Ls[t])==null?void 0:e.hex)??ae:ae}},gc="#a0c6e8",bc="#5a8ab5";function xr(t){const n=t??gc,e=t??bc;return{name:"simple",whiteKey:(s,r)=>r?n:oe,blackKey:(s,r)=>r?e:ae}}const Qi={boomwhacker:mc,crf:pc,simple:xr()};function yc(t){return Qi[t]}function Ji(t,n){if(!(!t&&!n))return!t&&n?xr(n):typeof t=="string"?t==="simple"&&n?xr(n):Qi[t]:t}function vc(t,n,e,s){const r=[],i=[];for(let a=0;a<t.length;a++){const o=t[a],l=n[a],d=o.isBlack?jn:re,m=`<rect x="${o.x}" y="${o.y}" width="${o.width}" height="${o.height}" rx="${d}" ry="${d}" fill="${l}" stroke="${li}" stroke-width="${Ke}"/>`;o.isBlack?i.push(m):r.push(m)}return[`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${s}" viewBox="0 0 ${e} ${s}">`,...r,...i,"</svg>"].join(`
2
- `)}function _c(t){const n=performance.now(),e=s=>({success:!1,chordName:"",root:"",notes:[],keyboard:{startFrom:"C",size:8,highlightKeys:[]},telemetry:{parser:"chord",resolver:{root:"",type:"",pitchClasses:[]},durationMs:performance.now()-n},errorMessage:s});try{const{input:s,format:r,logConfig:i}=t;if(!s||!s.trim())return e("No chord input provided");const a=Vn(s);if(!a.chordName)return e("Could not extract a chord name from the input");const o=mn(a.chordName,a.inversion),l=o.notes,d=l.map(St),m=a.format??"compact",f=qn(d,{padding:a.padding,startingNote:a.startingNote,spanFrom:a.spanFrom,spanTo:a.spanTo}),p=ln(f.startFrom,f.size,m),h=4,b=[],g=[],v=28;let y=-1,_=h+f.chordOctave;const k=[];for(let T=0;T<l.length;T++){const P=l[T],j=d[T],C=mr[P];C!==void 0&&(y!==-1&&C<=y&&_++,y=C,k.push({pc:P,kpc:j,semitone:C,octave:_}))}if(k.length>1){const T=k[0].semitone+k[0].octave*12;for(let P=1;P<k.length;P++)k[P].semitone+k[P].octave*12-T>v&&k[P].octave>k[0].octave&&k[P].octave--}for(const T of k){g.push(`${T.pc}${T.octave}`);const P=T.octave-h;b.push(`${T.kpc}:${P}`)}const M=Ir(p,b),w={success:!0,chordName:a.chordName,root:o.root,notes:g,inversion:a.inversion,keyboard:{startFrom:f.startFrom,size:f.size,highlightKeys:b},telemetry:{parser:"chord",resolver:{root:o.root,type:o.type,pitchClasses:l},durationMs:performance.now()-n}};if(r==="svg"){const T=Nr(f.size,m);w.svg=vc(p,M,T.width,T.height)}if(r==="midi"&&(w.midi=Qn({notes:l})),i){const T={input:s,pipeline:{parser:"chord",parsed:{chordName:a.chordName,inversion:a.inversion,allInversions:a.allInversions,startingNote:a.startingNote,startingDegree:a.startingDegree,bassNote:a.bassNote,bassDegree:a.bassDegree,spanFrom:a.spanFrom,spanTo:a.spanTo,padding:a.padding,chordOctaveShift:a.chordOctaveShift,bassOctaveShift:a.bassOctaveShift,styleHint:a.styleHint,format:a.format,showNoteNames:a.showNoteNames,fingering:a.fingering,autoFingering:a.autoFingering},resolver:{method:"tonal",type:o.type,root:o.root,pitchClasses:l},voicing:{attempted:!1,found:!1},layout:{startFrom:f.startFrom,size:f.size,chordOctave:f.chordOctave},output:{notes:g,highlightKeys:b,format:r}},success:!0,durationMs:performance.now()-n};Xi(T,i)}return w}catch(s){const r=s instanceof Error?s.message:String(s);return e(r)}}const to={display:"keyboard",format:"compact",theme:"simple",highlightColor:"#a0c6e8",padding:1,scale:.5,glyphs:"bravura",showNoteNames:!1,noteNameSize:"base",noteNameMode:"pitch-class",showFingering:!1,fingeringSize:"base"};function eo(t,n,e){return{...to,...t?cr(t):{},...n?cr(n):{},...e?cr(e):{}}}function cr(t){const n={...t};for(const e of Object.keys(n))n[e]===void 0&&delete n[e];return n}function no(t,n,e,s){const r=n+1;return e<=1?String(r):`${s??String.fromCharCode(65+t)}${r}`}const Dn="1.0";function ro(t){if(!t||typeof t!="string")throw new Error("Missing or invalid schema version");const[n]=t.split("."),[e]=Dn.split(".");if(n!==e)throw new Error(`Incompatible schema version "${t}" (current: "${Dn}"). Major version mismatch — this sheet was created with a newer or older format.`)}const Je="bcs1.";async function wc(t,n){const e=JSON.stringify({...t,v:t.v??Dn}),s=new TextEncoder().encode(e);if(!(n!=null&&n.skipCompression)&&typeof CompressionStream<"u")try{const r=await kc(s);return Je+$s(r)}catch{}return Je+$s(s)}async function xc(t,n){if(!t.startsWith(Je))throw new Error(`Invalid token: must start with "${Je}"`);const e=t.slice(Je.length),s=Sc(e);let r;if(typeof DecompressionStream<"u")try{const a=await Ac(s);r=new TextDecoder().decode(a)}catch{r=new TextDecoder().decode(s)}else r=new TextDecoder().decode(s);let i;try{i=JSON.parse(r)}catch{throw new Error("Invalid token: could not parse payload as JSON")}return ro(i.v),i}function $s(t){let n="";for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Sc(t){const n=t.replace(/-/g,"+").replace(/_/g,"/"),e=atob(n),s=new Uint8Array(e.length);for(let r=0;r<e.length;r++)s[r]=e.charCodeAt(r);return s}async function kc(t){const n=new CompressionStream("deflate"),e=n.writable.getWriter();e.write(t),e.close();const s=n.readable.getReader(),r=[];for(;;){const{done:i,value:a}=await s.read();if(i)break;r.push(a)}return so(r)}async function Ac(t){const n=new DecompressionStream("deflate"),e=n.writable.getWriter(),s=e.write(t).then(()=>e.close()).catch(()=>{}),r=n.readable.getReader(),i=[];try{for(;;){const{done:a,value:o}=await r.read();if(a)break;i.push(o)}}catch(a){throw await s,a}return await s,so(i)}function so(t){const n=t.reduce((r,i)=>r+i.length,0),e=new Uint8Array(n);let s=0;for(const r of t)e.set(r,s),s+=r.length;return e}const io=!1,oo=120;function ao(t=oo){return 6e4/(t*4)}const lo={text:"#1a1a1a",textMuted:"#555",textSubtle:"#777",border:"#ccc",btnBg:"#e8e8e8",btnBgActive:"#333",btnText:"#333",btnTextActive:"#fff",inputBg:"#fff",inputText:"#333",iconFill:"#fff",playbackBg:"rgba(100, 100, 115, 0.6)",playbackActive:"rgba(74, 144, 217, 0.85)",playbackTrayBg:"rgba(200, 210, 225, 0.5)",playbackTrayBorder:"rgba(255, 255, 255, 0.7)",playbackBtnBorder:"rgba(255, 255, 255, 0.45)",bracketColor:"#888",whiteFill:"#fafafa",blackFill:"#222222",keyStroke:"#333333"},co={text:"#eee",textMuted:"#aaa",textSubtle:"#888",border:"#555",btnBg:"rgba(255, 255, 255, 0.08)",btnBgActive:"rgba(57, 51, 51, 0.89)",btnText:"#aab2c0",btnTextActive:"#eef0f4",inputBg:"#1e1e2e",inputText:"#eee",iconFill:"#fff",playbackBg:"rgba(70, 70, 90, 0.7)",playbackActive:"rgba(74, 144, 217, 0.85)",playbackTrayBg:"rgba(50, 55, 75, 0.65)",playbackTrayBorder:"rgba(255, 255, 255, 0.18)",playbackBtnBorder:"rgba(255, 255, 255, 0.12)",bracketColor:"#999",whiteFill:"#fafafa",blackFill:"#222222",keyStroke:"#333333"},Fn="light";function Fr(t){return t==="dark"?co:lo}let hr=null,Be=null,ze=null;function Lr(){return hr||(hr=new AudioContext),hr}async function ho(){if(Be)return Be;if(ze)return await ze,Be;const{Soundfont:t}=await Promise.resolve().then(()=>Mh),n=Lr(),e=new t(n,{instrument:"acoustic_grand_piano"});ze=e.load.then(()=>{});try{await ze,Be=e}catch{throw ze=null,new Error("Failed to load piano soundfont")}return Be}const Mc={C:0,"C#":1,Db:1,D:2,"D#":3,Eb:3,E:4,Fb:4,"E#":5,F:5,"F#":6,Gb:6,G:7,"G#":8,Ab:8,A:9,"A#":10,Bb:10,B:11,Cb:11,"B#":0};function Pe(t,n=4){let e=n,s=-1;return t.map(r=>{if(/[0-9]$/.test(r))return r;const i=Mc[r];return i==null?`${r}${e}`:(s>=0&&i<=s&&e++,s=i,`${r}${e}`)})}async function uo(t,n=4,e=1.5){const s=await ho(),r=Lr();r.state==="suspended"&&await r.resume();const i=Pe(t,n),a=r.currentTime;for(const o of i)s.start({note:o,time:a,duration:e})}async function fo(t,n=4,e=100,s=1.5){const r=await ho(),i=Lr();i.state==="suspended"&&await i.resume();const a=Pe(t,n),o=i.currentTime;for(let l=0;l<a.length;l++)r.start({note:a[l],time:o+l*e/1e3,duration:s})}const _n="http://www.w3.org/2000/svg";function mo(t){return t.replace(/[^a-zA-Z0-9\-_ ]/g,"_").slice(0,100)}function Pc(t,n){const e=t.getAttribute("data-annotations");if(!e)return;t.removeAttribute("data-annotations");let s;try{s=JSON.parse(e)}catch{return}const{items:r,fontSize:i,fingerFontSize:a,hasStagger:o,staggerHeight:l,textColor:d,mutedColor:m,keyboardHeight:f,controlsHeight:p}=s;if(!r||r.length===0)return;const h=i+3,b=o?l:0,v=r.some(P=>P.degree)?i*.85+3:0,_=r.some(P=>P.finger)?a+3:0,k=b+h+v+_+4,M=s.heading?i*1.4+4:0,w=n.height+k+M;if(t.setAttribute("viewBox",`${n.x} ${n.y-M} ${n.width} ${w}`),s.heading){const P=document.createElementNS(_n,"text");P.setAttribute("x",String(n.x+n.width/2)),P.setAttribute("y",String(n.y-4)),P.setAttribute("text-anchor","middle"),P.setAttribute("font-size",String(i*1.2)),P.setAttribute("font-weight","600"),P.setAttribute("fill",d),P.setAttribute("font-family","system-ui, sans-serif"),P.textContent=s.heading,t.appendChild(P)}const T=n.y+n.height+2;for(const P of r){const j=P.x;let C=T;if(P.note){const L=o&&!P.isAccidental?b:0,V=document.createElementNS(_n,"text");V.setAttribute("x",String(j)),V.setAttribute("y",String(C+i+L)),V.setAttribute("text-anchor","middle"),V.setAttribute("font-size",String(i)),V.setAttribute("font-weight","600"),V.setAttribute("fill",d),V.setAttribute("font-family","system-ui, sans-serif"),V.textContent=P.note,t.appendChild(V)}if(P.degree){const L=i*.85,V=document.createElementNS(_n,"text");V.setAttribute("x",String(j)),V.setAttribute("y",String(C+b+h+L)),V.setAttribute("text-anchor","middle"),V.setAttribute("font-size",String(L)),V.setAttribute("font-weight","500"),V.setAttribute("fill",m),V.setAttribute("font-family","system-ui, sans-serif"),V.textContent=P.degree,t.appendChild(V)}if(P.finger){const L=document.createElementNS(_n,"text");L.setAttribute("x",String(j)),L.setAttribute("y",String(C+b+h+v+a)),L.setAttribute("text-anchor","middle"),L.setAttribute("font-size",String(a)),L.setAttribute("font-weight","500"),L.setAttribute("fill",m),L.setAttribute("font-family","system-ui, sans-serif"),L.textContent=P.finger,t.appendChild(L)}}}function Jn(t){const n=t.cloneNode(!0),e=n.querySelector("[data-controls]");let s=0;e&&(s=30,e.remove());const r=t.viewBox.baseVal;n.setAttribute("viewBox",`${r.x} ${s} ${r.width} ${r.height-s}`);const i={x:r.x,y:s,width:r.width,height:r.height-s};return Pc(n,i),{clone:n,offsetY:s}}function po(t,n){const{clone:e}=Jn(t),s=new XMLSerializer().serializeToString(e),r=new Blob([s],{type:"image/svg+xml;charset=utf-8"}),i=URL.createObjectURL(r),a=document.createElement("a");a.href=i,a.download=`${mo(n)}.svg`,a.click(),setTimeout(()=>URL.revokeObjectURL(i),1e3)}function go(t,n,e=2){const{clone:s}=Jn(t),r=s.viewBox.baseVal,i=r.width,a=r.height;s.setAttribute("width",String(i)),s.setAttribute("height",String(a));const o=new XMLSerializer().serializeToString(s),l=new Blob([o],{type:"image/svg+xml;charset=utf-8"}),d=URL.createObjectURL(l),m=new Image;m.onload=()=>{const f=document.createElement("canvas");f.width=i*e,f.height=a*e;const p=f.getContext("2d");if(!p){URL.revokeObjectURL(d),console.error("PNG export: could not get canvas 2d context");return}p.scale(e,e),p.drawImage(m,0,0,i,a),URL.revokeObjectURL(d),f.toBlob(h=>{if(!h){console.error("PNG export: canvas.toBlob returned null");return}const b=URL.createObjectURL(h),g=document.createElement("a");g.href=b,g.download=`${mo(n)}.png`,g.click(),setTimeout(()=>URL.revokeObjectURL(b),1e3)},"image/png")},m.onerror=()=>{URL.revokeObjectURL(d),console.error("PNG export: failed to load SVG as image")},m.src=d}const Ec=["C","C#/Db","D","D#/Eb","E","F","F#/Gb","G","G#/Ab","A","Bb","B"];function Hs(t){return t%12}function Cc(t){return Math.floor(t/12)-1}function Nc(t){return Ec[t%12]}function Ic(t,n){const e=t.map(o=>vt(o)).filter(o=>o!=null);if(e.length===0)return"";const s=Ft(n||t[0]),r=Math.min(...e.map(Hs)),i=e.map((o,l)=>({name:Nc(o),col:1,row:Hs(o),octave:Cc(o),isRoot:Ft(t[l])===s,sustainCells:0})),a={_type:"play-grid-clip",label:`${i.length} notes (${i.map(o=>o.name.split("/")[0]).join(", ")})`,timestamp:Date.now(),data:{notes:i,lines:[],originCol:1,originRow:r}};return JSON.stringify(a)}async function Tc(t,n){const e=Ic(t,n);if(!e)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}const bo=ft.createContext({mode:Fn,tokens:Fr(Fn)}),Bt=bo.Provider;function pn(){return ft.useContext(bo)}function gn(t){const n=t??Fn;return{mode:n,tokens:Fr(n)}}const Us=16,_t=22,je=4,wn=10;function yo({notes:t,lhNotes:n,rhOctave:e,lhOctave:s,chordName:r,x:i,y:a}){const{tokens:o}=pn(),[l,d]=ft.useState(null),m=(n==null?void 0:n.length)??0,f=s??2,p=e??3,h=t.map(u=>u.replace(/:.*$/,"")),b=(()=>{if(m>0){const u=h.slice(0,m),z=h.slice(m);return[...Pe(u,f),...Pe(z,p)]}return Pe(h,p)})(),g=ft.useCallback(async()=>{if(!l){d("block");try{await uo(b),setTimeout(()=>d(null),1500)}catch{d(null)}}},[b,l]),v=ft.useCallback(async()=>{if(!l){d("arp");try{await fo(b,4,ao()),setTimeout(()=>d(null),1500)}catch{d(null)}}},[b,l]),y=ft.useCallback(()=>{Yi(t,r,p,n,f)},[t,r,p,n,f]),_=ft.useCallback(u=>u.currentTarget.closest("svg"),[]),k=ft.useCallback(u=>{const z=_(u);z&&po(z,r)},[r,_]),M=ft.useCallback(u=>{const z=_(u);z&&go(z,r)},[r,_]),[w,T]=ft.useState(!1),P=ft.useCallback(async()=>{const u=h[0];await Tc(b,u)&&(T(!0),setTimeout(()=>T(!1),1500))},[b,h]),j={cursor:"pointer",opacity:l?.5:1},C=2*_t+je,L=(u,z,Q,W,st,$,X=!1)=>I.jsxs("g",{transform:`translate(${u}, ${a})`,onClick:Q,style:st,role:"button","aria-label":W,children:[I.jsx("rect",{width:_t,height:_t,rx:5,fill:z,stroke:o.playbackBtnBorder,strokeWidth:.5}),I.jsx("rect",{width:_t,height:_t,rx:5,fill:`url(#${X?N:A})`}),I.jsx("line",{x1:6,y1:1.5,x2:_t-6,y2:1.5,stroke:"rgba(255,255,255,0.18)",strokeWidth:.5,strokeLinecap:"round"}),$]}),V=`translate(${(_t-Us)/2}, ${(_t-Us)/2})`,A=`btn-glass-${i}-${a}`,N=`btn-glass-active-${i}-${a}`;return I.jsxs("g",{className:"bc-playback-controls",children:[I.jsxs("defs",{children:[I.jsxs("linearGradient",{id:A,x1:"0",y1:"0",x2:"0",y2:"1",children:[I.jsx("stop",{offset:"0%",stopColor:"rgba(255,255,255,0.12)"}),I.jsx("stop",{offset:"50%",stopColor:"rgba(255,255,255,0.02)"}),I.jsx("stop",{offset:"100%",stopColor:"rgba(0,0,0,0.06)"})]}),I.jsxs("linearGradient",{id:N,x1:"0",y1:"0",x2:"0",y2:"1",children:[I.jsx("stop",{offset:"0%",stopColor:"rgba(255,255,255,0.15)"}),I.jsx("stop",{offset:"50%",stopColor:"rgba(255,255,255,0.03)"}),I.jsx("stop",{offset:"100%",stopColor:"rgba(0,0,0,0.08)"})]})]}),L(i,l==="block"?o.playbackActive:o.playbackBg,g,"Play block chord",j,I.jsxs("g",{transform:V,children:[I.jsx("polygon",{points:"2,5 5,5 9,2 9,14 5,11 2,11",fill:o.iconFill}),I.jsx("path",{d:"M11,5.5 C12.5,6.5 12.5,9.5 11,10.5",stroke:o.iconFill,strokeWidth:"1.5",fill:"none",strokeLinecap:"round"}),I.jsx("path",{d:"M12.5,3.5 C15,5.5 15,10.5 12.5,12.5",stroke:o.iconFill,strokeWidth:"1.2",fill:"none",strokeLinecap:"round"})]}),l==="block"),L(i+_t+je,l==="arp"?o.playbackActive:o.playbackBg,v,"Play arpeggiated",j,I.jsxs("g",{transform:V,children:[I.jsx("path",{d:"M8,14 C6,11 10,9 8,7 C6,5 10,3 8,1",stroke:o.iconFill,strokeWidth:"1.8",fill:"none",strokeLinecap:"round"}),I.jsx("polygon",{points:"5,3 8,0 11,3",fill:o.iconFill})]}),l==="arp"),L(i+C+wn,o.playbackBg,y,"Download MIDI file",{cursor:"pointer"},I.jsx("text",{x:_t/2,y:_t/2+3,textAnchor:"middle",fontSize:6,fontWeight:"bold",fill:o.iconFill,fontFamily:"system-ui, sans-serif",children:"MIDI"})),L(i+C+wn+_t+je,o.playbackBg,k,"Download SVG",{cursor:"pointer"},I.jsx("text",{x:_t/2,y:_t/2+3,textAnchor:"middle",fontSize:7,fontWeight:"bold",fill:o.iconFill,fontFamily:"system-ui, sans-serif",children:"SVG"})),L(i+C+wn+2*(_t+je),o.playbackBg,M,"Download PNG",{cursor:"pointer"},I.jsx("text",{x:_t/2,y:_t/2+3,textAnchor:"middle",fontSize:7,fontWeight:"bold",fill:o.iconFill,fontFamily:"system-ui, sans-serif",children:"PNG"})),L(i+C+wn+3*(_t+je),w?o.playbackActive:o.playbackBg,P,"Copy chord for dottl.app",{cursor:"pointer"},w?I.jsx("text",{x:_t/2,y:_t/2+3,textAnchor:"middle",fontSize:6,fontWeight:"bold",fill:o.iconFill,fontFamily:"system-ui, sans-serif",children:"OK!"}):I.jsxs("g",{transform:`translate(${_t/2-6}, ${_t/2-6.5})`,children:[I.jsx("path",{d:"M2,1 L2,12 L6.5,12 C10,12 12,9.5 12,6.5 C12,3.5 10,1 6.5,1 Z M4,3 L6,3 C8.5,3 10,4.5 10,6.5 C10,8.5 8.5,10 6,10 L4,10 Z",fill:o.iconFill}),I.jsx("circle",{cx:"6",cy:"5",r:"0.9",fill:"#22c55e"}),I.jsx("circle",{cx:"8",cy:"5",r:"0.9",fill:"#3b82f6"}),I.jsx("circle",{cx:"6",cy:"7",r:"0.9",fill:"#f59e0b"}),I.jsx("circle",{cx:"8",cy:"7",r:"0.9",fill:"#a855f7"}),I.jsx("circle",{cx:"6",cy:"9",r:"0.9",fill:"#ef4444"}),I.jsx("circle",{cx:"8",cy:"9",r:"0.9",fill:"#06b6d4"})]}))]})}function Rc(t,n,e,s){if(n.keyIndices.length===0)return null;const r=n.keyIndices.map(f=>t[f]).filter(Boolean);if(r.length===0)return null;const i=r.reduce((f,p)=>f.x<p.x?f:p),a=r.reduce((f,p)=>f.x+f.width>p.x+p.width?f:p),o=i.x+(i.isBlack?0:2),l=a.x+a.width-(a.isBlack?0:2),d=(o+l)/2,m=4;return I.jsxs("g",{children:[I.jsx("line",{x1:o,y1:e,x2:l,y2:e,stroke:s,strokeWidth:1.5}),I.jsx("line",{x1:o,y1:e-m,x2:o,y2:e,stroke:s,strokeWidth:1.5}),I.jsx("line",{x1:l,y1:e-m,x2:l,y2:e,stroke:s,strokeWidth:1.5}),I.jsx("text",{x:d,y:e+11,textAnchor:"middle",fontSize:10,fontWeight:500,fill:s,fontFamily:"system-ui, sans-serif",children:n.label})]},n.label)}const Oc={base:1,lg:1.25,xl:1.5,"2xl":1.875};function Ws(t="base"){return Math.min(pe*.48,11)*Oc[t]}function Bc(t,n,e,s="pitch-class",r=4){const i=[],a=n.map((o,l)=>{const d=o.indexOf(":");return{note:St(d!==-1?o.slice(0,d):o),idx:l,matched:!1}});for(const o of t){const l=St(o.note),d=a.findIndex(m=>{if(m.matched||m.note!==l)return!1;const f=n[m.idx];return!(f.includes(":")&&parseInt(f.split(":")[1],10)!==o.octave)});if(d!==-1){a[d].matched=!0;let m=(e==null?void 0:e[a[d].idx])??a[d].note;s==="midi"&&(m=`${m}${r+o.octave}`),i.push({x:o.x,width:o.isBlack?Cr:pe,note:m,index:a[d].idx})}}return i}function me({format:t="compact",size:n=8,startFrom:e="C",highlightKeys:s=[],allNotes:r,lhNotes:i,rhOctave:a,lhOctave:o,theme:l,highlightColor:d,showPlayback:m=!0,chordLabel:f,showHeading:p,handBrackets:h,scale:b=.5,showNoteNames:g,displayNoteNames:v,noteNameSize:y="base",noteNameMode:_="pitch-class",midiBaseOctave:k=4,fingering:M,fingeringSize:w="base",degreeLabels:T,clipLeft:P=!1,clipRight:j=!1,uiTheme:C,className:L,style:V}){const A=pn(),N=C?gn(C):A,u=N.tokens,z=ln(e,n,t),Q=Ji(l,d),st=Ir(z,s,Q).map((ot,mt)=>ot===oe?u.whiteFill:ot===ae&&z[mt].isBlack?u.blackFill:ot),$=u.keyStroke,{width:X,height:B}=Nr(n,t),R=pe/2,J=P?R:0,tt=n*pe,pt=(j?tt-R:X)-J,wt=m&&s.length>0,ht=h&&h.length>0,ut=wt?30:0,yt=ht?24:0,Z=g??io,et=_==="degree",it=_==="pitch-class+degree",c=Z&&s.length>0&&!et,F=Z&&s.length>0&&(et||it)&&T&&T.length>0,D=M&&M.length>0,S=c||D||F,x=B+ut+yt,E=ut,H=z.map((ot,mt)=>({key:ot,fill:st[mt],index:mt})).filter(({key:ot})=>!ot.isBlack),G=z.map((ot,mt)=>({key:ot,fill:st[mt],index:mt})).filter(({key:ot})=>ot.isBlack),O=J+pt-172,nt=I.jsxs("svg",{viewBox:`${J} 0 ${pt} ${x}`,xmlns:"http://www.w3.org/2000/svg",className:`bc-keyboard ${L??""}`.trim(),style:{width:"100%",display:"block",...V},role:"img","aria-label":"Piano keyboard",children:[wt&&I.jsx("g",{"data-controls":"",children:I.jsx(yo,{notes:r??s,lhNotes:i,rhOctave:a,lhOctave:o,chordName:f??s.join("-"),x:O,y:4})}),(P||j)&&H.length>0&&I.jsx("defs",{children:I.jsx("clipPath",{id:`kb-clip-${J}-${E}`,children:I.jsx("rect",{x:J,y:0,width:pt,height:H[0].key.height,rx:re,ry:re})})}),I.jsxs("g",{transform:`translate(0, ${E})`,children:[I.jsxs("g",{clipPath:(P||j)&&H.length>0?`url(#kb-clip-${J}-${E})`:void 0,children:[H.map(({key:ot,fill:mt,index:kt})=>I.jsx("rect",{x:ot.x,y:ot.y,width:ot.width,height:ot.height,rx:re,ry:re,fill:mt,stroke:$,strokeWidth:Ke},`white-${kt}`)),G.map(({key:ot,fill:mt,index:kt})=>I.jsx("rect",{x:ot.x,y:ot.y,width:ot.width,height:ot.height,rx:jn,ry:jn,fill:mt,stroke:$,strokeWidth:Ke},`black-${kt}`))]}),(P||j)&&H.length>0&&I.jsx("rect",{x:J,y:0,width:pt,height:H[0].key.height,rx:re,ry:re,fill:"none",stroke:$,strokeWidth:Ke})]}),ht&&I.jsx("g",{transform:`translate(0, ${E+B+6})`,children:h.map(ot=>Rc(z,ot,0,u.bracketColor))})]}),K=S?Bc(z,s,et?T:v,et?"pitch-class":_,k):[],rt=Ws(y),dt=Ws(w),ct=ot=>/[#b]/.test(ot.slice(1)),xt=K.some(ot=>ct(ot.note)),Ct=xt?rt*1.3:0,At=S&&K.length>0?JSON.stringify({heading:p?f:void 0,items:K.map(ot=>({x:ot.x+ot.width/2,note:c||et&&F?ot.note:void 0,degree:it&&F?T==null?void 0:T[ot.index]:void 0,finger:D?(()=>{const mt=M==null?void 0:M[ot.index];if(mt!=null)return typeof mt=="number"&&(mt<0||mt>5)?"?":String(mt)})():void 0,isAccidental:ct(ot.note)})),fontSize:rt,fingerFontSize:dt,hasStagger:xt,staggerHeight:Ct,textColor:u.text,mutedColor:u.textMuted,keyboardHeight:x-ut,controlsHeight:ut}):void 0,Rt=ot=>{if(!ot)return;const mt=ot.querySelector("svg.bc-keyboard");mt&&(At?mt.setAttribute("data-annotations",At):mt.removeAttribute("data-annotations"))},bt=I.jsxs("div",{className:"bc-keyboard-container",ref:Rt,style:{width:"100%",maxWidth:pt*b*2},children:[p&&f&&I.jsx("div",{className:"bc-keyboard-heading",style:{textAlign:"center",fontSize:14,fontWeight:600,color:u.text,fontFamily:"system-ui, sans-serif",marginBottom:4},children:f}),nt,S&&K.length>0&&I.jsx("div",{className:"bc-annotations",style:{position:"relative",width:"100%",marginTop:2,minHeight:Ct+rt*1.3+(D?dt*1.3:0)},children:K.map((ot,mt)=>{const kt=(ot.x+ot.width/2-J)/pt*100,Lt=c||et&&F,ce=it&&F,Vt=D,Jt=T==null?void 0:T[ot.index],Nt=M==null?void 0:M[ot.index],Et=Nt==null?null:typeof Nt=="number"&&(Nt<0||Nt>5)?"?":Nt,Mt=xt&&!ct(ot.note)?Ct:0;return I.jsxs("div",{className:"bc-annotation-cell",style:{position:"absolute",left:`${kt}%`,transform:"translateX(-50%)",top:Mt,display:"flex",flexDirection:"column",alignItems:"center",gap:0,whiteSpace:"nowrap",lineHeight:1.2},children:[Lt&&I.jsx("span",{className:"bc-note-name",style:{fontSize:rt,fontWeight:600,color:u.text,fontFamily:"system-ui, sans-serif"},children:ot.note}),ce&&Jt&&I.jsx("span",{className:"bc-degree-label",style:{fontSize:rt*.85,fontWeight:500,color:u.textMuted,fontFamily:"system-ui, sans-serif"},children:Jt}),Vt&&Et!=null&&I.jsx("span",{className:"bc-fingering",style:{fontSize:dt,fontWeight:500,color:u.textMuted,fontFamily:"system-ui, sans-serif"},children:Et})]},`ann-${mt}`)})})]});return C?I.jsx(Bt,{value:N,children:bt}):bt}function Ln({notes:t,lhNotes:n,rhOctave:e,lhOctave:s,octaveQualifiedNotes:r,chordLabel:i,scale:a=.5,showPlayback:o=!0,glyphs:l,className:d,style:m}){const{tokens:f}=pn(),p=l??xi(),b=yi(t,{lhNotes:n,rhOctave:e,lhOctave:s,octaveQualifiedNotes:r}),g=o&&t.length>0,v=g?30:0,y=b.totalHeight+v,_=b.totalWidth,k=f.text??"#333",M=f.text??"#333";function w(A){const N=[];for(let u=0;u<5;u++){const z=A+u*Wt;N.push(I.jsx("line",{className:"bc-staff__line",x1:bn+2,y1:z,x2:pi-4,y2:z,stroke:k,strokeWidth:qr},`line-${A}-${u}`))}return N}const T=Wt*4;function P(A,N){const u=bn+4,z=A==="treble"?N+Wt*3:N+Wt,Q=A==="treble"?p.glyphs.trebleClef:p.glyphs.bassClef;return I.jsx("text",{className:`bc-staff__clef--${A}`,x:u,y:z,fontFamily:p.fontFamily,fontSize:T,fill:k,children:Q})}function j(A,N,u){const z=A==="sharp"?p.glyphs.sharp:p.glyphs.flat;return I.jsx("text",{className:"bc-staff__accidental",x:N,y:u,fontFamily:p.fontFamily,fontSize:T,fill:M,textAnchor:"middle",children:z})}const C=_-170,L=4,V=v;return I.jsxs("svg",{viewBox:`0 0 ${_} ${y}`,xmlns:"http://www.w3.org/2000/svg",className:`bc-staff ${d??""}`.trim(),style:{width:"100%",maxWidth:_*a*2,...m},role:"img","aria-label":i?`Staff notation: ${i}`:"Staff notation",children:[g&&I.jsx("g",{"data-controls":"",children:I.jsx(yo,{notes:t,lhNotes:n,rhOctave:e,lhOctave:s,chordName:i??t.join("-"),x:C,y:L})}),I.jsxs("g",{transform:`translate(0, ${V})`,children:[i&&I.jsx("text",{className:"bc-staff__label",x:se,y:Mn-13,textAnchor:"middle",fontSize:13,fontWeight:600,fill:M,fontFamily:"system-ui, sans-serif",children:i}),I.jsxs("g",{className:"bc-staff__system",children:[b.staffMode==="grand"&&b.trebleTopY>=0&&I.jsx("path",{className:"bc-staff__brace",d:p.brace(b.bassTopY+Wt*4-b.trebleTopY),transform:`translate(0, ${b.trebleTopY})`,fill:"none",stroke:k,strokeWidth:2}),b.staffMode==="grand"&&I.jsx("line",{className:"bc-staff__barline",x1:bn+2,y1:b.trebleTopY,x2:bn+2,y2:b.bassTopY+Wt*4,stroke:k,strokeWidth:qr}),b.trebleTopY>=0&&I.jsxs("g",{className:"bc-staff__treble",children:[w(b.trebleTopY),P("treble",b.trebleTopY)]}),b.bassTopY>=0&&I.jsxs("g",{className:"bc-staff__bass",children:[w(b.bassTopY),P("bass",b.bassTopY)]}),I.jsx("g",{className:"bc-staff__notes",children:b.notes.map((A,N)=>{const u=Math.min(A.noteX,se)-br-Kr,z=Math.max(A.noteX,se)+br+Kr;return I.jsxs("g",{className:"bc-staff__note",children:[A.ledgerLines.map((Q,W)=>I.jsx("line",{className:"bc-staff__ledger",x1:u,y1:Q,x2:z,y2:Q,stroke:k,strokeWidth:Qo},`ledger-${W}`)),A.accidental&&j(A.accidental,A.accidentalX,A.y),I.jsx("text",{className:"bc-staff__notehead",x:A.noteX,y:A.y,fontFamily:p.fontFamily,fontSize:T,fill:M,textAnchor:"middle",children:p.glyphs.wholeNote})]},N)})})]})]})]})}function zc(t){return t<=1?1:t<=2||t<=3?2:4}function tr({chords:t,label:n,format:e,theme:s,highlightColor:r,showPlayback:i=!0,scale:a,display:o="keyboard",showNoteNames:l,noteNameMode:d,noteNameSize:m,showFingering:f,fingeringSize:p,onVariation:h,renderVariationExtras:b}){const{tokens:g}=pn(),v=t.map(k=>qn(k.notes,{padding:1})),y=Math.max(...v.map(k=>k.size),8),_=zc(t.length);return I.jsxs("div",{className:"bc-chord-group",style:{marginBottom:16,width:"100%"},children:[n&&I.jsx("div",{className:"bc-chord-group__label",style:{fontWeight:600,marginBottom:8,fontSize:14},children:n}),I.jsx("div",{className:"bc-chord-group__grid",style:{display:"flex",flexWrap:"wrap",gap:12,alignItems:"flex-start",width:"100%"},children:t.map((k,M)=>{let w=k.notes;if(v[M].chordOctave>0){let T=v[M].chordOctave;const P=St(k.notes[0]);let C=gt.indexOf(P.replace("#",""));w=k.notes.map((L,V)=>{const A=St(L),N=A.replace("#",""),u=gt.indexOf(N);return V>0&&u<=C&&T++,C=u,`${A}:${T}`})}return I.jsxs(jc,{chord:k,index:M,perRow:_,onVariation:h,renderVariationExtras:b,children:[I.jsx("div",{className:"bc-chord-group__symbol",style:{fontSize:12,fontWeight:500,marginBottom:4},children:k.symbol}),o==="staff"?I.jsx(Ln,{notes:k.notes,chordLabel:k.symbol,showPlayback:i,scale:a}):o==="both"?I.jsxs("div",{className:"bc-display-both",style:{display:"flex",gap:8,alignItems:"flex-start"},children:[I.jsx(Ln,{notes:k.notes,chordLabel:k.symbol,showPlayback:!1,scale:a}),I.jsx(me,{format:e,size:y,startFrom:v[M].startFrom,highlightKeys:w,theme:s,highlightColor:r,showPlayback:i,chordLabel:k.symbol,scale:a,showNoteNames:l,noteNameMode:d,noteNameSize:m,displayNoteNames:k.notes,fingering:f?cn(k.notes):void 0,fingeringSize:p})]}):I.jsx(me,{format:e,size:y,startFrom:v[M].startFrom,highlightKeys:w,theme:s,highlightColor:r,showPlayback:i,chordLabel:k.symbol,scale:a,showNoteNames:l,noteNameMode:d,noteNameSize:m,displayNoteNames:k.notes,fingering:f?cn(k.notes):void 0,fingeringSize:p}),k.voicingStyle&&I.jsx("div",{className:"bc-chord-group__voicing-style",style:{fontSize:10,color:g.textSubtle,marginTop:2},children:k.voicingStyle})]},M)})})]})}function jc({chord:t,index:n,perRow:e,onVariation:s,renderVariationExtras:r,children:i}){const a=ft.useRef(null),o=ft.useRef(""),l=()=>{var d,m;return{chordSymbol:t.symbol,chordIndex:n,voicingId:"default",notes:t.notes,svgString:((m=(d=a.current)==null?void 0:d.querySelector("svg"))==null?void 0:m.outerHTML)??""}};return ft.useEffect(()=>{if(!s)return;const d=l(),m=`${d.chordSymbol}|${d.voicingId}|${d.chordIndex}|${d.notes.join(",")}|${d.svgString.length}`;m!==o.current&&(o.current=m,s(d))}),I.jsxs("div",{ref:a,className:"bc-chord-group__item",style:{textAlign:"center",flex:`0 1 calc(${100/e}% - ${(e-1)*12/e}px)`,minWidth:0},children:[i,r==null?void 0:r(l())]})}function vo(t){const n=(t%12+12)%12;return n===0?1:n<=2?2:n<=4?3:n===5?4:n<=7?5:n<=9?6:7}const Sr={1:"root",2:"2nd",3:"3rd",4:"4th",5:"5th",6:"6th",7:"7th",9:"9th",11:"11th",13:"13th"};function Gs(t,n,e){const s=vt(`${t}4`);if(s==null)return;const r=n>7?n-7:n;for(const i of e){const a=vt(`${i}4`);if(a==null)continue;const o=((a-s)%12+12)%12;if(vo(o)===r)return i}}function ur(t,n){const e=vt(`${t}4`);if(e==null)return n.join(", ");const s=[];for(const r of n){const i=vt(`${r}4`);if(i==null)continue;const a=((i-e)%12+12)%12,o=vo(a),l=Sr[o]??`${o}th`;s.push(`${l} (${r})`)}return s.join(", ")}function Dc(t){return"chord"in t}function $n(t){if(!Dc(t))return I.jsx(me,{...t});const{chord:n,format:e,theme:s,highlightColor:r,padding:i,scale:a,display:o="keyboard",uiTheme:l,showPlayback:d=!0,className:m,style:f}=t,{onVariation:p,renderVariationExtras:h,voicingId:b="default",chordIndex:g=0}=t,v=gn(l),y=ft.useRef(null),_=ft.useRef("");let k=[];const M=()=>{var Z,et;return{chordSymbol:typeof n=="string"?n:String(n),chordIndex:g,voicingId:b,notes:k,svgString:((et=(Z=y.current)==null?void 0:Z.querySelector("svg"))==null?void 0:et.outerHTML)??""}};ft.useEffect(()=>{if(!p)return;const Z=M(),et=`${Z.chordSymbol}|${Z.voicingId}|${Z.chordIndex}|${Z.notes.join(",")}|${Z.svgString.length}`;et!==_.current&&(_.current=et,p(Z))});const w=Vn(n),T=w.colorTheme??s,P=w.scale??a;if(w.isScale&&w.scaleName){const[Z,...et]=w.scaleName.split(" "),it=et.join(" "),c=fc(Z,it,w.scaleDirection,w.scaleOctaves),F=c.notes.map(St),D=w.padding??i??1,S=w.format??e,E=(vt(`${F[0]}3`)??48)>=57?3:4;let H=E,G=-1;const O=F.map(Et=>{const Mt=vt(`${Et}${H}`);if(Mt==null)return 60;if(G>=0&&Mt<=G){H++;const ve=vt(`${Et}${H}`)??Mt+12;return G=ve,ve}return G=Mt,Mt}),q=O[0],nt=O[O.length-1],K=D*2,rt=Qt(q-K),dt=Qt(nt+K),ct=Ft(rt).replace(/[#b]/,""),xt=Ft(dt).replace(/[#b]/,""),Ct=or(rt)??E,At=or(dt)??E+1,Rt=gt.indexOf(ct),bt=gt.indexOf(xt),mt=(At-Ct)*7+(bt-Rt)+1,kt=Math.max(mt,8),Lt=O.map((Et,Mt)=>{const Pt=(or(Qt(Et))??E)-Ct;return`${F[Mt]}:${Pt}`}),ce=Ct,Vt=Ds(c.intervals),Jt=c.notes.map((Et,Mt)=>Vt[Mt%Vt.length]),Nt=w.autoFingering?Yo(Z,it,"rh",w.scaleOctaves??1):void 0;return k=F,I.jsxs(I.Fragment,{children:[I.jsx("div",{ref:y,className:"bc-pianochord-root",children:I.jsx(Bt,{value:v,children:I.jsx(me,{format:S,size:kt,startFrom:ct,highlightKeys:Lt,displayNoteNames:c.notes,theme:T,highlightColor:r,chordLabel:w.scaleName,showHeading:w.showHeading,scale:P,showNoteNames:w.showNoteNames,noteNameSize:w.noteNameSize,noteNameMode:w.noteNameMode,midiBaseOctave:ce,degreeLabels:Jt,fingering:Nt&&Nt.length>0?Nt:void 0,fingeringSize:w.fingeringSize,showPlayback:d,className:m,style:f})})}),h==null?void 0:h(M())]})}if(!w.chordName)throw new Error(`Couldn't find a chord name in "${n}"`);const j=mn(w.chordName,w.inversion);if(w.allInversions){const Z=j.notes.length,et=["Root position","1st inversion","2nd inversion","3rd inversion","4th inversion"],it=[];for(let F=0;F<Z;F++){const D=[...j.notes.slice(F),...j.notes.slice(0,F)];it.push({symbol:et[F]??`${F}th inversion`,root:j.root,notes:D})}const c=w.format??e;return k=j.notes,I.jsxs(I.Fragment,{children:[I.jsx("div",{ref:y,className:"bc-pianochord-root",children:I.jsx(Bt,{value:v,children:I.jsx(tr,{chords:it,label:w.chordName,format:c,theme:T,highlightColor:r,showPlayback:d,scale:P})})}),h==null?void 0:h(M())]})}let{notes:C}=j,L;if(w.styleHint){const Z=Zn(j.type,j.notes);if(Z){const et=Xn(Z,w.styleHint);if(et){const it=Re(j.root,et);it.length>0&&(C=it,L=et.hands)}}}let V;if(w.bassDegree!=null){const Z=ur(j.root,C),et=Gs(j.root,w.bassDegree,C);if(!et){const it=Sr[w.bassDegree]??`${w.bassDegree}th`;throw new Error(`${w.chordName} doesn't have a ${it} — try: ${Z}`)}V=et}else w.bassNote&&(V=Ce[w.bassNote]??w.bassNote);let A=w.startingNote;if(!A&&w.startingDegree!=null){const Z=ur(j.root,C);if(A=Gs(j.root,w.startingDegree,C),!A){const et=Sr[w.startingDegree]??`${w.startingDegree}th`;throw new Error(`${w.chordName} doesn't have a ${et} — try: ${Z}`)}}if(A){const Z=Ce[A]??A,et=C.indexOf(Z);if(et<0){const it=ur(j.root,C);throw new Error(`${A} isn't in ${w.chordName} — the notes are: ${it}`)}et>0&&(C=[...C.slice(et),...C.slice(0,et)])}if(w.chordOctaves&&w.chordOctaves>1){const Z=[...C],et=[];for(let it=0;it<w.chordOctaves;it++)et.push(...Z);et.push(Z[0]),C=et}const N=(()=>{if(w.noteNameMode!=="degree"&&w.noteNameMode!=="pitch-class+degree")return;const Z=j.intervals;if(!Z||Z.length===0)return;const et=Ds(Z);return C.map((it,c)=>et[c%et.length])})(),u=w.padding??i??1,z=w.format??e,Q=(Z,et)=>{const it=et!=null&&et.bassNote?[et.bassNote,...Z]:Z,c=3+(w.bassOctaveShift??0),F=4+(w.chordOctaveShift??0);return I.jsx(Ln,{notes:it,lhNotes:et!=null&&et.bassNote?[et.bassNote]:void 0,rhOctave:F,lhOctave:c,octaveQualifiedNotes:et==null?void 0:et.octaveQualifiedNotes,chordLabel:w.chordName,scale:P,showPlayback:d,className:m,style:f})},W=28,st=(Z,et)=>{let it=et;const c=St(Z[0]);let D=gt.indexOf(c.replace("#",""));const S=Z.map((E,H)=>{const G=St(E),O=G.replace("#",""),q=gt.indexOf(O);return H>0&&q<=D&&it++,D=q,{norm:G,octave:it}}),x=vt(`${S[0].norm}${S[0].octave}`);if(x!=null)for(let E=1;E<S.length;E++){const H=vt(`${S[E].norm}${S[E].octave}`);H!=null&&H-x>W&&S[E].octave>S[0].octave&&S[E].octave--}return S.map(E=>`${E.norm}:${E.octave}`)};if(V){const Z=St(V),et=Z.replace("#",""),it=gt.indexOf(et),c=1+(w.chordOctaveShift??0)-(w.bassOctaveShift??0),F=Math.max(c,0)*7,D=C.map(Pt=>{const Kt=St(Pt).replace("#","");let qt=gt.indexOf(Kt)-it;return qt<=0&&(qt+=7),qt+F}),S=Math.max(...D);let x=((it-u)%7+7)%7,E=!1;ke(x)&&(x=((x-1)%7+7)%7,E=!0);const H=gt[x],G=((it-x)%7+7)%7;let O=Math.max(G+S+u+1,10),q=!1;const nt=x+O-1;ke(nt)&&(O+=1,q=!0);const K=ln(H,O,z),rt=K.findIndex(Pt=>St(Pt.note)===Z),dt=rt>=0?K[rt].octave:0,ct=dt+Math.max(c,0),xt=[`${Z}:${dt}`],Ct=C.map(Pt=>{const $t=St(Pt),Kt=$t.replace("#",""),er=gt.indexOf(Kt)>it?ct:ct+1;return`${$t}:${er}`}),At=[...xt,...Ct],Rt=3+(w.bassOctaveShift??0),bt=Rt+Math.max(c,0),ot=[`${Z}:${Rt}`,...C.map(Pt=>{const $t=St(Pt),Kt=$t.replace("#",""),er=gt.indexOf(Kt)>it?bt:bt+1;return`${$t}:${er}`})],mt=[],kt=[],Lt=At.map((Pt,$t)=>{const[Kt,te]=Pt.split(":");return{note:Kt,octave:parseInt(te,10),isLH:$t<xt.length,matched:!1}});for(let Pt=0;Pt<K.length;Pt++){const $t=St(K[Pt].note),Kt=K[Pt].octave,te=Lt.findIndex(qt=>!qt.matched&&qt.note===$t&&qt.octave===Kt);te!==-1&&(Lt[te].matched=!0,(Lt[te].isLH?mt:kt).push(Pt))}const ce=[{label:"L.H.",keyIndices:mt},{label:"R.H.",keyIndices:kt}],Vt=2+(w.bassOctaveShift??0),Jt=3+(w.chordOctaveShift??0),Nt=cn([V],"lh"),Et=An(C,L),Mt=w.customFingering??w.fingering??(w.autoFingering?[...Nt,...Et.fingering]:void 0),ve=I.jsx(me,{format:z,size:O,startFrom:H,highlightKeys:At,displayNoteNames:[V,...C],clipLeft:E,clipRight:q,allNotes:[V,...C],lhNotes:[V],lhOctave:Vt,rhOctave:Jt,theme:T,highlightColor:r,chordLabel:w.chordName,showHeading:w.showHeading,handBrackets:ce,scale:P,showNoteNames:w.showNoteNames,noteNameSize:w.noteNameSize,noteNameMode:w.noteNameMode,midiBaseOctave:Vt+1,fingering:Mt,fingeringSize:w.fingeringSize,showPlayback:d,className:m,style:f});return k=[V,...C],o==="staff"?I.jsxs(I.Fragment,{children:[I.jsx("div",{ref:y,className:"bc-pianochord-root",children:I.jsx(Bt,{value:v,children:Q(C,{bassNote:V,octaveQualifiedNotes:ot})})}),h==null?void 0:h(M())]}):o==="both"?I.jsxs(I.Fragment,{children:[I.jsx("div",{ref:y,className:"bc-pianochord-root",children:I.jsx(Bt,{value:v,children:I.jsxs("div",{className:"bc-display-both bc-display-both--stacked",style:{display:"flex",flexDirection:"column",gap:8,alignItems:"center"},children:[ve,Q(C,{bassNote:V,octaveQualifiedNotes:ot})]})})}),h==null?void 0:h(M())]}):I.jsxs(I.Fragment,{children:[I.jsx("div",{ref:y,className:"bc-pianochord-root",children:I.jsx(Bt,{value:v,children:ve})}),h==null?void 0:h(M())]})}const $=C.map(St),X=qn($,{padding:u,startingNote:A,spanFrom:w.spanFrom,spanTo:w.spanTo}),B=w.chordOctaveShift??0,R=B>0?X.size+B*7:X.size;let J=$;{const Z=$.map(it=>gt.indexOf(it.replace("#","")));if(X.chordOctave>0||B!==0||Z.some((it,c)=>c>0&&it<=Z[c-1])){let it=Math.max(X.chordOctave+B,0),c=Z[0];const F=$.map((S,x)=>{const E=Z[x];return x>0&&E<=c&&it++,c=E,{note:S,octave:it}}),D=vt(`${F[0].note}${F[0].octave+4}`);if(D!=null)for(let S=1;S<F.length;S++){const x=vt(`${F[S].note}${F[S].octave+4}`);x!=null&&x-D>W&&F[S].octave>F[0].octave&&F[S].octave--}J=F.map(S=>`${S.note}:${S.octave}`)}}const tt=J.map(Z=>{if(Z.includes(":")){const[et,it]=Z.split(":");return vt(`${et}${parseInt(it,10)+4}`)??60}return vt(`${Z}4`)??60});let Y;if(V){const Z=cn([V],"lh"),et=An(C,L);Y={fingering:[...Z,...et.fingering],hands:["lh",...et.hands]}}else Y=An(C,L,tt);const pt=w.customFingering??w.fingering??(w.autoFingering?Y.fingering:void 0),wt=!V&&Y.hands.some(Z=>Z==="lh");let ht;if(wt){const Z=ln(X.startFrom,R,z),et=[],it=[],c=new Set;for(let F=0;F<$.length;F++){const D=Y.hands[F],S=J[F],x=S.includes(":");for(let E=0;E<Z.length;E++){if(c.has(E))continue;const H=St(Z[E].note);if(x){const[G,O]=S.split(":");if(H===G&&Z[E].octave===parseInt(O,10)){c.add(E),(D==="lh"?et:it).push(E);break}}else if(H===S){c.add(E),(D==="lh"?et:it).push(E);break}}}et.length>0&&it.length>0&&(ht=[{label:"L.H.",keyIndices:et},{label:"R.H.",keyIndices:it}])}const ut=I.jsx(me,{format:z,size:R,startFrom:X.startFrom,highlightKeys:J,displayNoteNames:C,clipLeft:X.clipLeft,clipRight:X.clipRight,rhOctave:B!==0?4+B:void 0,theme:T,highlightColor:r,chordLabel:w.chordName,showHeading:w.showHeading,handBrackets:ht,scale:P,showNoteNames:w.showNoteNames,noteNameSize:w.noteNameSize,noteNameMode:w.noteNameMode,midiBaseOctave:4,fingering:pt,fingeringSize:w.fingeringSize,degreeLabels:N,showPlayback:d,className:m,style:f}),yt=st(C,4+B);return k=C,o==="staff"?I.jsxs(I.Fragment,{children:[I.jsx("div",{ref:y,className:"bc-pianochord-root",children:I.jsx(Bt,{value:v,children:Q(C,{octaveQualifiedNotes:yt})})}),h==null?void 0:h(M())]}):o==="both"?I.jsxs(I.Fragment,{children:[I.jsx("div",{ref:y,className:"bc-pianochord-root",children:I.jsx(Bt,{value:v,children:I.jsxs("div",{className:"bc-display-both",style:{display:"flex",gap:16,alignItems:"flex-start"},children:[Q(C,{octaveQualifiedNotes:yt}),ut]})})}),h==null?void 0:h(M())]}):I.jsxs(I.Fragment,{children:[I.jsx("div",{ref:y,className:"bc-pianochord-root",children:I.jsx(Bt,{value:v,children:ut})}),h==null?void 0:h(M())]})}var xn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Fc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Sn(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var dr={exports:{}};/*!
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("react/jsx-runtime"),ft=require("react"),pe=23,Mr=25.3,Pr=65,Cr=120,re=3,Er=13,oi=14.3,ai=40,li=80,zn=1,oe="#fafafa",ae="#222222",ci="#333333",Ye=1,hi={C:14.33,D:18.67,F:13.25,G:16.25,A:19.75},ui={C:15.76,D:20.54,F:14.58,G:17.88,A:21.73},di=new Set(["C","D","F","G","A"]),gt=["C","D","E","F","G","A","B"],Bo={C:"C#",D:"D#",F:"F#",G:"G#",A:"A#"};function ln(t="C",n=8,e="compact"){const s=e==="exact",r=s?Cr:Pr,i=s?li:ai,a=s?Mr:pe,o=s?oi:Er,l=s?ui:hi,d=[],m=gt.indexOf(t);let f=.5,p=0;for(let h=0;h<n;h++){const b=(m+h)%7,g=gt[b];if(h>0&&g==="C"&&p++,d.push({note:g,octave:p,isBlack:!1,x:f,y:0,width:a,height:r}),di.has(g)){const v=l[g];d.push({note:Bo[g],octave:p,isBlack:!0,x:f+v,y:0,width:o,height:i})}f+=a}return d}function Ir(t,n="compact"){const e=n==="exact",s=e?Cr:Pr;return{width:t*(e?Mr:pe)+1,height:s+2}}const Ee={Db:"C#",Eb:"D#",Gb:"F#",Ab:"G#",Bb:"A#"},fi={"C#":"Db","D#":"Eb","F#":"Gb","G#":"Ab","A#":"Bb"},jo=new Set(["F","Bb","Eb","Ab","Db","Gb","Cb"]);function $n(t){return Ee[t]??t}function zo(t,n){return jo.has(n)?fi[t]??t:Ee[t]??t}function Fo(t,n,e=!1){return e?fi[t]??t:zo(t,n)}const mr={C:0,"C#":1,Db:1,D:2,"D#":3,Eb:3,E:4,Fb:4,"E#":5,F:5,"F#":6,Gb:6,G:7,"G#":8,Ab:8,A:9,"A#":10,Bb:10,B:11,Cb:11,"B#":0};function At(t){return $n(t)}function Do(t){const n=t.indexOf(":");if(n!==-1){const e=At(t.slice(0,n)),s=parseInt(t.slice(n+1),10);return{note:e,octave:s}}return{note:At(t),octave:null}}function Nr(t,n,e){const r=[...n.map(Do)];return t.map(i=>{const a=At(i.note),o=r.findIndex(d=>!(d.note!==a||d.octave!==null&&d.octave!==i.octave)),l=o!==-1;return l&&r.splice(o,1),e?i.isBlack?e.blackKey(a,l):e.whiteKey(a,l):l?i.isBlack?"#5a8ab5":"#a0c6e8":i.isBlack?ae:oe})}const Ie=19,Wt=5,Lo=new Set(["C#","D#","F#","G#","A#"]);function pr(t){return $n(t)}function Wr(t){return Lo.has(pr(t))}function Ke(t,n){const e=mr[pr(t)],s=mr[pr(n)];return e==null||s==null?0:((s-e)%12+12)%12}function gr(t){let n=0;for(let e=1;e<t.length;e++)n+=Ke(t[e-1],t[e]);return n}function mi(t){return t.length<=Wt&&gr(t)<=Ie}function Ho(t){if(t.length>Wt)return!1;if(t.length<=1)return!0;const n=[...t].sort((e,s)=>e-s);return n[n.length-1]-n[0]<=Ie}const Uo={2:[[1,5],[1,3],[2,5]],3:[[1,3,5],[1,2,5],[1,2,4],[1,3,4],[2,3,5],[1,2,3]],4:[[1,2,3,5],[1,2,4,5],[1,2,3,4],[1,3,4,5],[2,3,4,5]],5:[[1,2,3,4,5]]};function Wo(t,n){let e=0;for(let r=0;r<t.length;r++)n[r]===1&&Wr(t[r])&&r!==0&&(e+=10),n[r]===5&&Wr(t[r])&&(e+=2);for(let r=0;r<t.length-1;r++){const i=Ke(t[r],t[r+1]),a=Math.abs(n[r+1]-n[r]);i>=5&&a<=1&&(e+=5),i<=1&&a>=3&&(e+=3)}n[0]!==1&&(e+=1);const s=n[n.length-1];return s!==5&&s!==4&&(e+=1),e}function Qt(t,n){const e=t.length;if(e===0)return[];if(e===1)return[3];const s=Uo[e];if(!s)return Array(e).fill(3);let r=s[0],i=1/0;for(const a of s){const o=Wo(t,a);o<i&&(i=o,r=a)}return n==="lh"?r.map(a=>6-a):r}function kn(t,n,e){const s=t.length;if(s===0)return{fingering:[],hands:[]};if(n&&n.length===s)return Vo(t,n);if(e&&e.length===s)return Go(t,e);if(mi(t))return{fingering:Qt(t,"rh"),hands:Array(s).fill("rh")};const r=Ko(t);return $o(t,r)}function Go(t,n){const e=t.length,s=Array.from({length:e},(h,b)=>b).sort((h,b)=>n[h]-n[b]),r=s.map(h=>t[h]),i=s.map(h=>n[h]);if(Ho(i)){const h=Qt(r,"rh"),b=new Array(e),g=new Array(e);return s.forEach((v,y)=>{b[v]=h[y],g[v]="rh"}),{fingering:b,hands:g}}const a=Yo(r,i),o=r.slice(0,a),l=r.slice(a),d=Qt(o,"lh"),m=Qt(l,"rh"),f=new Array(e),p=new Array(e);return s.forEach((h,b)=>{b<a?(f[h]=d[b],p[h]="lh"):(f[h]=m[b-a],p[h]="rh")}),{fingering:f,hands:p}}function $o(t,n){const e=t.slice(0,n),s=t.slice(n),r=Qt(e,"lh"),i=Qt(s,"rh");return{fingering:[...r,...i],hands:[...Array(e.length).fill("lh"),...Array(s.length).fill("rh")]}}function Vo(t,n){const e=[],s=[];for(let m=0;m<t.length;m++)n[m]==="LH"?e.push(m):s.push(m);const r=e.map(m=>t[m]),i=s.map(m=>t[m]),a=Qt(r,"lh"),o=Qt(i,"rh"),l=new Array(t.length),d=new Array(t.length);return e.forEach((m,f)=>{l[m]=a[f],d[m]="lh"}),s.forEach((m,f)=>{l[m]=o[f],d[m]="rh"}),{fingering:l,hands:d}}function Gr(t){let n=0;for(let e=1;e<t.length;e++)n=Math.max(n,t[e]-t[e-1]);return n}function Yo(t,n){const e=t.length;let s=Math.min(2,e-1),r=1/0;for(let i=1;i<e;i++){const a=n.slice(0,i),o=n.slice(i);if(i>Wt||e-i>Wt)continue;const l=a[a.length-1]-a[0],d=o[o.length-1]-o[0];if(l>Ie||d>Ie)continue;let m=0;const f=i,p=e-i,h=Gr(a),b=Gr(o),g=Math.max(h,b);m+=g*5;const v=f/Wt,y=p/Wt,_=Math.abs(v-y);m+=_*8,(f===Wt||p===Wt)&&(m+=4);const S=n[i]-n[i-1];m-=S*3,f>=1&&f<=3&&(m-=4),p>=3&&p<=4&&(m-=2),m<r&&(r=m,s=i)}return s}function Ko(t){const n=t.length;let e=Math.min(2,n-1),s=1/0;for(let r=1;r<n;r++){const i=t.slice(0,r),a=t.slice(r);if(r>Wt||n-r>Wt||gr(i)>Ie||gr(a)>Ie)continue;let o=0,l=0;for(let f=1;f<r;f++)l=Math.max(l,Ke(t[f-1],t[f]));let d=0;for(let f=r+1;f<n;f++)d=Math.max(d,Ke(t[f-1],t[f]));o+=Math.max(l,d)*5;const m=Ke(t[r-1],t[r]);o-=m*3,r>=1&&r<=3&&(o-=4),n-r>=3&&n-r<=4&&(o-=2),o+=Math.abs(r-(n-r)),o<s&&(s=o,e=r)}return e}function cn(t,n="rh"){const e=t.length;return e===0?[]:e===1?[3]:mi(t)?Qt(t,n):kn(t).fingering}const Zo={C:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},G:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},D:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},A:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},E:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},B:{rh:[1,2,3,1,2,3,4,5],lh:[4,3,2,1,4,3,2,1]},F:{rh:[1,2,3,4,1,2,3,4],lh:[5,4,3,2,1,3,2,1]},Bb:{rh:[2,1,2,3,1,2,3,4],lh:[3,2,1,4,3,2,1,3]},Eb:{rh:[2,1,2,3,4,1,2,3],lh:[3,2,1,4,3,2,1,3]},Ab:{rh:[2,3,1,2,3,1,2,3],lh:[3,2,1,4,3,2,1,3]},Db:{rh:[2,3,1,2,3,4,1,2],lh:[3,2,1,4,3,2,1,3]},Gb:{rh:[2,3,4,1,2,3,1,2],lh:[4,3,2,1,3,2,1,4]},"F#":{rh:[2,3,4,1,2,3,1,2],lh:[4,3,2,1,3,2,1,4]},"C#":{rh:[2,3,1,2,3,4,1,2],lh:[3,2,1,4,3,2,1,3]}},$r={A:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},E:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},B:{rh:[1,2,3,1,2,3,4,5],lh:[4,3,2,1,4,3,2,1]},D:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},G:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},C:{rh:[1,2,3,1,2,3,4,5],lh:[5,4,3,2,1,3,2,1]},F:{rh:[1,2,3,4,1,2,3,4],lh:[5,4,3,2,1,3,2,1]},"F#":{rh:[2,3,1,2,3,1,2,3],lh:[4,3,2,1,3,2,1,4]},"C#":{rh:[2,3,1,2,3,1,2,3],lh:[3,2,1,4,3,2,1,3]},"G#":{rh:[2,3,1,2,3,1,2,3],lh:[3,2,1,4,3,2,1,3]},Bb:{rh:[2,1,2,3,1,2,3,4],lh:[2,1,3,2,1,4,3,2]},Eb:{rh:[2,1,2,3,4,1,2,3],lh:[2,1,4,3,2,1,3,2]},Ab:{rh:[2,3,1,2,3,1,2,3],lh:[3,2,1,4,3,2,1,3]}},Vr={Db:"C#",Eb:"D#",Gb:"F#",Ab:"G#",Bb:"A#"};function qo(t,n,e="rh",s=1){const r=n.toLowerCase().replace(/\s+/g," ").trim();let i;if(r==="major"||r==="ionian")i=Zo;else if(r==="minor"||r==="natural minor"||r==="harmonic minor"||r==="minor harmonic"||r==="melodic minor"||r==="minor melodic"||r==="aeolian")i=$r;else if(r==="dorian"||r==="mixolydian"||r==="phrygian"||r==="lydian"||r==="locrian")i=$r;else return[];let a=i[t];if(!a){const d=Vr[t];d&&(a=i[d])}if(!a){for(const[d,m]of Object.entries(Vr))if(m===t){a=i[d];break}}if(!a)return[];const o=e==="rh"?a.rh:a.lh;if(s<=1)return o;const l=[];for(let d=0;d<s;d++)d<s-1?l.push(...o.slice(0,7)):l.push(...o);return l}const Gt=8,pi=4,gi=120,se=75,br=6.75,bi=14,Qo=br*2,Xo=10,Yr=7,Jo=1,ta=20,Mn=22,ea=10,Kr=.8,bn=8;function na(t){return t.map(n=>{const[e,s]=n.split(":");return{pitchClass:Tr(e),octave:parseInt(s,10)}})}const yi={C:0,D:1,E:2,F:3,G:4,A:5,B:6},ra=30,sa=18;function Tr(t){return $n(t)}function Rr(t){return t.replace("#","").replace("b","")}function nr(t,n){const e=Rr(t),r={C:0,D:2,E:4,F:5,G:7,A:9,B:11}[e]??0,i=t.includes("#")?1:t.includes("b")?-1:0;return(n+1)*12+r+i}function ia(t,n){const e=Rr(t);return n*7+(yi[e]??0)}function yr(t,n,e){return n-(t-e)*pi}function oa(t,n,e){const s=n+8,r=[];if(t<n)for(let i=n-2;i>=t;i-=2)r.push(yr(i,e,n));else if(t>s)for(let i=s+2;i<=t;i+=2)r.push(yr(i,e,n));return r}function Zr(t,n){const e=[];let s=n,r=-1;for(const i of t){const a=Tr(i),o=Rr(a),l=yi[o]??0;r>=0&&l<=r&&s++,r=l,e.push({pitchClass:a,octave:s})}return e}function aa(t){const n=[...t].sort((s,r)=>s.diatonicPos-r.diatonicPos),e=new Set;for(let s=1;s<n.length;s++)n[s].diatonicPos-n[s-1].diatonicPos===1&&(e.has(n[s-1])||(e.add(n[s]),n[s].noteX=se+Qo))}function la(t){const n=t.filter(r=>r.accidental!==null).sort((r,i)=>r.y-i.y);if(n.length===0)return;const e=[],s=Gt*2.5;for(const r of n){let o=t.some(l=>l.noteX>se&&Math.abs(l.y-r.y)<Gt*2)?1:0;for(;e.some(d=>d.col===o&&Math.abs(d.y-r.y)<s);)o++;e.push({col:o,y:r.y}),r.accidentalX=se-bi-o*Xo}}function vi(t,n={}){const{lhNotes:e,rhOctave:s=4,lhOctave:r=3,octaveQualifiedNotes:i}=n;let a,o;if(i)a=na(i),o=e??[];else{const P=e?t.filter(L=>!e.includes(L)):t;o=e??[];const z=Zr(P,s);a=[...Zr(o,r),...z]}const l=e&&e.length>0,d=57,m=a.filter(P=>nr(P.pitchClass,P.octave)>d).length,f=a.filter(P=>nr(P.pitchClass,P.octave)<=d).length;let p;l?p="grand":m>0&&f>0?p=m>=f?"treble":"bass":m>0?p="treble":p="bass";const h=Mn+Gt*4,b=p==="grand"?h+ta:p==="bass"?Mn:-1,g=b>=0?b+Gt*4:-1,v=p!=="bass"?Mn:-1,y=b,_=a.map(P=>{const z=nr(P.pitchClass,P.octave),E=e?o.some(G=>Tr(G)===P.pitchClass):z<60;let L,V,k;E&&p!=="treble"?(L="bass",V=g,k=sa):(L="treble",V=h,k=ra);const I=ia(P.pitchClass,P.octave),u=yr(I,V,k),j=oa(I,k,V),X=P.pitchClass.includes("#")?"sharp":P.pitchClass.includes("b")?"flat":null;return{pitchClass:P.pitchClass,octave:P.octave,staff:L,y:u,noteX:se,accidental:X,accidentalX:se-bi,ledgerLines:j,diatonicPos:I}});aa(_),la(_);const S=p==="bass"||p==="grand"?g:h,M=Math.max(S,..._.map(P=>P.y)),w=Math.max(S,..._.flatMap(P=>P.ledgerLines)),T=Math.max(M,w)+ea+pi;return{notes:_,staffMode:p,totalHeight:T,totalWidth:gi,trebleTopY:v,bassTopY:y}}const jt={gClef:"",fClef:"",noteheadWhole:"",accidentalSharp:"",accidentalFlat:"",accidentalNatural:""};function _i(t){return n=>{const e=n/2,s=n/4;return`M ${t} 0 C ${t-4} ${s} 0 ${e-4} 0 ${e} C 0 ${e+4} ${t-4} ${e+s} ${t} ${n}`}}const wi={name:"Bravura",fontFamily:"PHBravura, Bravura, serif",glyphs:{trebleClef:jt.gClef,bassClef:jt.fClef,sharp:jt.accidentalSharp,flat:jt.accidentalFlat,natural:jt.accidentalNatural,wholeNote:jt.noteheadWhole},brace:_i(6)},ca={name:"Petaluma",fontFamily:"PHPetaluma, Petaluma, serif",glyphs:{trebleClef:jt.gClef,bassClef:jt.fClef,sharp:jt.accidentalSharp,flat:jt.accidentalFlat,natural:jt.accidentalNatural,wholeNote:jt.noteheadWhole},brace:_i(6)};let xi=wi;function Ai(){return xi}function ha(t){xi=t}const ua=/\b(show\s+me|draw|display|render|please|a|an|the|with|that|this|me|of)\b/gi,qr=/\b(compact|exact|full)\b/i,Qr=/\bfull\s+(?:layout|height|size|keys?)\b/i,Xr=/\b(?:size|keys?)\s+([\d.]+)\s*%?\b/i,Jr=/\b(?:size|keys?)\s+(sm|base|lg|xl|2xl)\b/i,da={sm:.5,base:.7,lg:.85,xl:1,"2xl":1.2},fa={first:1,second:2,third:3,fourth:4,root:0},ts=/(?:(?:with\s+|show\s+)?all|every)\s+inversions?/i,es=/(\d+)(?:st|nd|rd|th)\s+inversion/i,ns=/(first|second|third|fourth)\s+inversion/i,rs=/root\s+position/i,ss=/spanning\s+([A-Ga-g][#b]?)\s+to\s+([A-Ga-g][#b]?)/i,is=/start(?:s|ing)?\s+(?:on|from|at|around)\s+(?:the\s+)?([A-Ga-g][#b]?)/i,os=/start(?:s|ing)?\s+(?:on|from|at|around)\s+(?:the\s+)?(\d+)(?:st|nd|rd|th)/i,as=/(?:with\s+)?(?:the\s+)?(\d+)(?:st|nd|rd|th)\s+(?:in\s+)?(?:the\s+)?(?:bottom|bass|lowest)/i,ls=/(?:with\s+)?([A-Ga-g][#b]?)\s+(?:in\s+)?(?:the\s+)?(?:bottom|bass|lowest)/i,cs=/\bover\s+([A-Ga-g][#b]?)(?:\s|$)/i,hs=/(?:(?:in\s+)?(?:the\s+)?style\s+of\s+|like\s+|a\s+la\s+)([\w\s]+?)(?:\s*$|\s*,|\s+(?:starting|spanning|with|compact|exact))/i,us=/\b(bebop|basie|nestico|ellington|modal|comping|rootless|quartal|block\s*chords?|locked\s*hands|drop\s*2\s*\+?\s*4|drop\s*2|upper\s*structure|shell|stride|spread|4[- ]?note\s*closed)\b/i,ds=/(?:with\s+)?(\d+)\s+(?:notes?|keys?)\s+(?:on\s+)?(?:either|each|both)\s+side/i,fs=/(?:with\s+)?(?:the\s+)?chord\s+(?:(?:(down|up|lower|higher)\s+)?(?:(\d+)\s+)?(?:an?\s+)?octaves?(?:\s+(down|up|lower|higher))?)/i,ms=/(?:with\s+)?(?:the\s+)?bass(?:\s+note)?\s+(?:(?:(down|up|lower|higher)\s+)?(?:(\d+)\s+)?(?:an?\s+)?octaves?(?:\s+(down|up|lower|higher))?)/i,ps=/(?:(?:with\s+)?(?:show\s+)?(?:(base|lg|xl|2xl)\s+)?note\s*names?(?:\s+(?:in\s+)?(base|lg|xl|2xl))?|name\s+the\s+notes(?:\s+(?:in\s+)?(base|lg|xl|2xl))?)/i,ma=/(?:(?:with\s+)?(?:show\s+)?midi\s+(?:(base|lg|xl|2xl)\s+)?(?:note\s*)?names?(?:\s+(?:in\s+)?(base|lg|xl|2xl))?)/i,gs=/(?:with\s+)?finger(?:ing|s)?\s+([\dxX\-](?:[,\s\-]*[\dxX\-])+)(?!\s*xl)(?:\s+(?:in\s+)?(base|lg|xl|2xl))?/i,pa=new Set(["0","1","2","3","4","5","-","x"]),bs=/(?:with\s+)?(?:custom\s+)?finger(?:ing|s)?\s+(?:(?:in\s+)?(base|lg|xl|2xl)\s+)?[""]([^""]+)[""](?:\s+(?:in\s+)?(base|lg|xl|2xl))?/i,ys=/(?:with\s+)?(?:show\s+)?finger(?:ings?|s)?(?:\s+(?:in\s+)?(base|lg|xl|2xl)|\s+(base|lg|xl|2xl))?(?!\s+\d)(?:\s|$)/i,ga=new Set(["base","lg","xl","2xl"]);function Ot(t){if(!t)return;const n=t.toLowerCase();return ga.has(n)?n:void 0}const ba=["dorian","mixolydian","phrygian","lydian","locrian","harmonic\\s+minor","minor\\s+harmonic","melodic\\s+minor","minor\\s+melodic","natural\\s+minor","major\\s+pentatonic","minor\\s+pentatonic","pentatonic","blues","whole\\s+tone","bebop","diminished"],vs=new RegExp(`([A-Ga-g][#b]?)\\s+(${ba.join("|")})(?:\\s+scale)?`,"i"),_s=/([A-Ga-g][#b]?)\s+(major|minor)\s+scale/i,ws=/\b(ascending|descending)\b/i,xs=/\b(?:in\s+)?(\d+)\s+octaves?\b/i,ya=/\bwith\s+(?:note\s+names?\s+and\s+)?degrees?(?:\s+(?:in\s+)?(base|lg|xl|2xl))?\b/i,va=/\bwith\s+degrees?(?:\s+(?:in\s+)?(base|lg|xl|2xl))?\b/i,As=/\bwith\s+note\s+names?\s+and\s+degrees?(?:\s+(?:in\s+)?(base|lg|xl|2xl))?\b/i,Ss=/\b(?:with\s+)?(?:a\s+)?(?:show\s+)?heading\b/i,ks=/\b(?:(?:with\s+)?(?:the\s+)?)?(?:(boomwhacker|boomwhackers|crf|rainbow)\s*(?:theme|colors?|colours?)?)\b/i,_a={boomwhacker:"boomwhacker",boomwhackers:"boomwhacker",crf:"crf",rainbow:"crf"},wa={major:"",minor:"m",diminished:"dim",augmented:"aug",dominant:"dom",suspended:"sus",triad:"",seventh:"7",ninth:"9",eleventh:"11",thirteenth:"13"},xa=/([A-Ga-g][#b]?)\s*(maj|min|m|aug|dim|sus|add|dom|M|°|ø|[0-9#b/]+)*/i;function ee(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Vn(t){const n={chordName:""},e=t.match(Qr),s=t.match(qr);if(e)n.format="exact";else if(s){const H=s[1].toLowerCase();n.format=H==="full"?"exact":H}const r=t.match(Jr),i=t.match(Xr);if(r)n.scale=da[r[1].toLowerCase()];else if(i){const H=parseFloat(i[1]);n.scale=H>10?H/100:H}const a=t.match(ts),o=t.match(es),l=t.match(ns),d=t.match(rs);a?n.allInversions=!0:o?n.inversion=parseInt(o[1],10):l?n.inversion=fa[l[1].toLowerCase()]:d&&(n.inversion=0);const m=t.match(ss);m&&(n.spanFrom=ee(m[1]),n.spanTo=ee(m[2]));const f=t.match(ds);f&&(n.padding=parseInt(f[1],10));const p=t.match(fs);if(p){const H=(p[1]||p[3]||"").toLowerCase(),Q=p[2]?parseInt(p[2],10):1,B=H==="down"||H==="lower";n.chordOctaveShift=B?-Q:Q}const h=t.match(ms);if(h){const H=(h[1]||h[3]||"").toLowerCase(),Q=h[2]?parseInt(h[2],10):1,B=H==="down"||H==="lower";n.bassOctaveShift=B?-Q:Q}const b=t.match(ma);if(b&&(n.showNoteNames=!0,n.noteNameMode="midi",n.noteNameSize=Ot(b[1])??Ot(b[2])),!b){const H=t.match(ps);H&&(n.showNoteNames=!0,n.noteNameSize=Ot(H[1])??Ot(H[2])??Ot(H[3]))}!n.showNoteNames&&/\bmidi\b/i.test(t)&&(n.showNoteNames=!0,n.noteNameMode="midi");const g=t.match(bs);if(g&&(n.customFingering=g[2].split(/[,\-\s]+/).filter(Boolean),n.fingeringSize=Ot(g[1])??Ot(g[3])),!n.customFingering){const H=t.match(ys);if(H&&(n.autoFingering=!0,n.fingeringSize=Ot(H[1])??Ot(H[2])),!n.autoFingering){const Q=t.match(gs);if(Q){const B=[];for(const R of Q[1].split(/[\s,]+/))R==="-"||R==="x"||R==="X"?B.push(R):R.includes("-")?B.push(...R.split("-").filter(J=>J.length>0)):B.push(R);n.fingering=B.map(R=>{const J=R.toLowerCase();if(!pa.has(J))return"?";const tt=parseInt(J,10);return isNaN(tt)?J:tt}),n.fingeringSize=Ot(Q[2])}}}const v=t.match(as),y=t.match(ls),_=t.match(cs);v?n.bassDegree=parseInt(v[1],10):y?n.bassNote=ee(y[1]):_&&(n.bassNote=ee(_[1]));const S=t.match(hs),M=t.match(us);S?n.styleHint=S[1].trim():M&&(n.styleHint=M[1].trim()),Ss.test(t)&&(n.showHeading=!0);const w=t.match(ks);w&&(n.colorTheme=_a[w[1].toLowerCase()]??w[1].toLowerCase());const T=t.match(As),P=t.match(va);if(T){n.showNoteNames=!0,n.noteNameMode="pitch-class+degree";const H=Ot(T[1]);H&&(n.noteNameSize=H)}else if(P){n.showNoteNames=!0,n.noteNameMode="degree";const H=Ot(P[1]);H&&(n.noteNameSize=H)}const z=t.match(ws);z&&(n.scaleDirection=z[1].toLowerCase());const E=t.match(xs),L=E?parseInt(E[1],10):void 0,V=t.match(vs),k=t.match(_s),I=V||k;if(I){const H=ee(I[1]),Q=I[2].toLowerCase().replace(/\s+/g," ").trim();n.isScale=!0,n.scaleName=`${H} ${Q}`,n.scaleOctaves=L??1}else L&&(n.chordOctaves=L);const u=t.match(os),j=t.match(is);u?n.startingDegree=parseInt(u[1],10):j&&(n.startingNote=ee(j[1]));let X=t.replace(Qr,"").replace(qr,"").replace(Jr,"").replace(Xr,"").replace(ts,"").replace(es,"").replace(ns,"").replace(rs,"").replace(ss,"").replace(ds,"").replace(fs,"").replace(ms,"").replace(ps,"").replace(bs,"").replace(gs,"").replace(ys,"").replace(hs,"").replace(us,"").replace(as,"").replace(ls,"").replace(cs,"").replace(os,"").replace(is,"").replace(As,"").replace(ya,"").replace(ws,"").replace(xs,"").replace(vs,"").replace(_s,"").replace(/\bscale\b/gi,"").replace(Ss,"").replace(ks,"").replace(/\btheme\b/gi,"").replace(/\bcolou?rs?\b/gi,"").replace(/\bcustom\b/gi,"").replace(/\band\b/gi,"").replace(ua,"").replace(/,/g,"").replace(/\blayout\b/gi,"").replace(/\bfull\b/gi,"").replace(/\bheight\b/gi,"").replace(/\bsize\b/gi,"").replace(/\bkeys?\b/gi,"").replace(/\bin\b/gi,"").replace(/\s+/g," ").trim();X=X.replace(/\bsharp\b/gi,"#").replace(/\bflat\b/gi,"b"),X=X.replace(/([A-Ga-g])\s+([#b])/g,"$1$2"),X=X.replace(/\s+/g," ").trim();const G=/([A-Ga-g][#b]?)\s+((?:major|minor|diminished|augmented|dominant|suspended)\s*(?:triad|seventh|ninth|eleventh|thirteenth)?)/i,st=X.match(G);if(st){const H=ee(st[1]),Q=st[2].toLowerCase().trim().split(/\s+/);let B="";for(const R of Q)B+=wa[R]??"";n.chordName=H+B}else{const H=X.match(xa);if(H){const Q=ee(H[1]),R=H[0].slice(H[1].length);n.chordName=Q+R.trim()}}return n}const ge=3,Aa=!1,Ms="[#b]?(?:iv|vi{1,2}|i{1,3}|IV|VI{1,2}|I{1,3}|V)(?:[°ø]?\\d*(?:maj|m)?[0-9#b]*)(?![a-z])",Si=new RegExp(`(?:^|\\s)(${Ms}(?:[\\s\\-–—→>]+${Ms})+)`,"i"),Sa=/(\d+)\s*(?:examples?|variations?|versions?|ways?|options?)/i,ka=/(?:(?:in\s+)?(?:the\s+)?style\s+of\s+|like\s+|a\s+la\s+)([\w\s]+?)(?:\s*$|\s*,|\s+(?:in\s|examples?|variations?))/i,Ma=/\b(bebop|basie|nestico|ellington|modal|comping|rootless|quartal|block\s*chords?|locked\s*hands|drop\s*2\s*\+?\s*4|drop\s*2|upper\s*structure|shell|stride|spread|4[- ]?note\s*closed|bill\s*evans|mccoy\s*tyner|herbie\s*hancock|bud\s*powell|monk)\b/i,ki=[{pattern:/\bjazz\s*blues\b/i,id:"jazz blues"},{pattern:/\bblues\b/i,id:"blues"},{pattern:/\brhythm\s*changes?\b/i,id:"rhythm changes"},{pattern:/\bturnaround\b/i,id:"I-vi-ii-V"},{pattern:/\bmodal\s*vamp\b/i,id:"modal vamp"},{pattern:/\bbackdoor\b/i,id:"backdoor"},{pattern:/\btritone\s*sub(?:stitution)?\b/i,id:"tritone sub"},{pattern:/\bminor\s*(?:ii[\s\-–—]*v[\s\-–—]*i|2[\s\-–—]*5[\s\-–—]*1)\b/i,id:"minor ii-V-i"}];function Pa(t){for(const{pattern:n}of ki)if(n.test(t))return!0;return!!(Si.test(t)||/\bprogression\b/i.test(t))}function Ca(t){let n=ge;const e=t.match(Sa);e&&(n=Math.min(parseInt(e[1],10),ge));let s;const r=t.match(ka),i=t.match(Ma);r?s=r[1].trim():i&&(s=i[1].trim());let a;const o=t.match(/\b(compact|exact)\b/i);o&&(a=o[1].toLowerCase());let l="C";const d=t.match(/\bin\s+(?:the\s+)?(?:key\s+(?:of\s+)?)?([A-Ga-g][#b]?)(?:\s|$)/i);d&&(l=d[1].charAt(0).toUpperCase()+d[1].slice(1));let m="";for(const{pattern:f,id:p}of ki)if(f.test(t)){m=p;break}if(!m){const f=t.match(Si);f&&(m=f[1].trim())}return m||(m="ii-V-I"),{progression:m,key:l,numExamples:n,styleHint:s,format:a}}function Mi(t){return t!==null&&typeof t=="object"&&"name"in t&&typeof t.name=="string"}function Pi(t){return t!==null&&typeof t=="object"&&"step"in t&&typeof t.step=="number"&&"alt"in t&&typeof t.alt=="number"&&!isNaN(t.step)&&!isNaN(t.alt)}var Ci=[0,2,4,-1,1,3,5],Ei=Ci.map(t=>Math.floor(t*7/12));function Ii(t){const{step:n,alt:e,oct:s,dir:r=1}=t,i=Ci[n]+7*e;if(s===void 0)return[r*i];const a=s-Ei[n]-4*e;return[r*i,r*a]}var Ea=[3,0,4,1,5,2,6];function Ni(t){const[n,e,s]=t,r=Ea[Ia(n)],i=Math.floor((n+1)/7);if(e===void 0)return{step:r,alt:i,dir:s};const a=e+4*i+Ei[r];return{step:r,alt:i,oct:a,dir:s}}function Ia(t){const n=(t+1)%7;return n<0?7+n:n}var Ps=(t,n)=>Array(Math.abs(n)+1).join(t),vr=Object.freeze({empty:!0,name:"",num:NaN,q:"",type:"",step:NaN,alt:NaN,dir:NaN,simple:NaN,semitones:NaN,chroma:NaN,coord:[],oct:NaN}),Na="([-+]?\\d+)(d{1,4}|m|M|P|A{1,4})",Ta="(AA|A|P|M|m|d|dd)([-+]?\\d+)",Ra=new RegExp("^"+Na+"|"+Ta+"$");function Oa(t){const n=Ra.exec(`${t}`);return n===null?["",""]:n[1]?[n[1],n[2]]:[n[4],n[3]]}var Cs={};function be(t){return typeof t=="string"?Cs[t]||(Cs[t]=Ba(t)):Pi(t)?be(za(t)):Mi(t)?be(t.name):vr}var Es=[0,2,4,5,7,9,11],Ti="PMMPPMM";function Ba(t){const n=Oa(t);if(n[0]==="")return vr;const e=+n[0],s=n[1],r=(Math.abs(e)-1)%7,i=Ti[r];if(i==="M"&&s==="P")return vr;const a=i==="M"?"majorable":"perfectable",o=""+e+s,l=e<0?-1:1,d=e===8||e===-8?e:l*(r+1),m=ja(a,s),f=Math.floor((Math.abs(e)-1)/7),p=l*(Es[r]+m+12*f),h=(l*(Es[r]+m)%12+12)%12,b=Ii({step:r,alt:m,oct:f,dir:l});return{empty:!1,name:o,num:e,q:s,step:r,alt:m,dir:l,type:a,simple:d,semitones:p,chroma:h,coord:b,oct:f}}function Ri(t,n){const[e,s=0]=t,r=e*7+s*12<0,i=n||r?[-e,-s,-1]:[e,s,1];return be(Ni(i))}function ja(t,n){return n==="M"&&t==="majorable"||n==="P"&&t==="perfectable"?0:n==="m"&&t==="majorable"?-1:/^A+$/.test(n)?n.length:/^d+$/.test(n)?-1*(t==="perfectable"?n.length:n.length+1):0}function za(t){const{step:n,alt:e,oct:s=0,dir:r}=t;if(!r)return"";const i=n+1+7*s,a=i===0?n+1:i,o=r<0?"-":"",l=Ti[n]==="M"?"majorable":"perfectable";return o+a+Fa(l,e)}function Fa(t,n){return n===0?t==="majorable"?"M":"P":n===-1&&t==="majorable"?"m":n>0?Ps("A",n):Ps("d",t==="perfectable"?n:n+1)}var Is=(t,n)=>Array(Math.abs(n)+1).join(t),Oi=Object.freeze({empty:!0,name:"",letter:"",acc:"",pc:"",step:NaN,alt:NaN,chroma:NaN,height:NaN,coord:[],midi:null,freq:null}),Ns=new Map,Da=t=>"CDEFGAB".charAt(t),La=t=>t<0?Is("b",-t):Is("#",t),Ha=t=>t[0]==="b"?-t.length:t.length;function Nt(t){const n=JSON.stringify(t),e=Ns.get(n);if(e)return e;const s=typeof t=="string"?$a(t):Pi(t)?Nt(Va(t)):Mi(t)?Nt(t.name):Oi;return Ns.set(n,s),s}var Ua=/^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)$/;function Or(t){const n=Ua.exec(t);return n?[n[1].toUpperCase(),n[2].replace(/x/g,"##"),n[3],n[4]]:["","","",""]}function Wa(t){return Nt(Ni(t))}var Ga=(t,n)=>(t%n+n)%n,rr=[0,2,4,5,7,9,11];function $a(t){const n=Or(t);if(n[0]===""||n[3]!=="")return Oi;const e=n[0],s=n[1],r=n[2],i=(e.charCodeAt(0)+3)%7,a=Ha(s),o=r.length?+r:void 0,l=Ii({step:i,alt:a,oct:o}),d=e+s+r,m=e+s,f=(rr[i]+a+120)%12,p=o===void 0?Ga(rr[i]+a,12)-1188:rr[i]+a+12*(o+1),h=p>=0&&p<=127?p:null,b=o===void 0?null:Math.pow(2,(p-69)/12)*440;return{empty:!1,acc:s,alt:a,chroma:f,coord:l,freq:b,height:p,letter:e,midi:h,name:d,oct:o,pc:m,step:i}}function Va(t){const{step:n,alt:e,oct:s}=t,r=Da(n);if(!r)return"";const i=r+La(e);return s||s===0?i+s:i}function Yn(t,n){const e=Nt(t),s=Array.isArray(n)?n:be(n).coord;if(e.empty||!s||s.length<2)return"";const r=e.coord,i=r.length===1?[r[0]+s[0]]:[r[0]+s[0],r[1]+s[1]];return Wa(i).name}function Ts(t,n){const e=Nt(t),s=Nt(n);if(e.empty||s.empty)return"";const r=e.coord,i=s.coord,a=i[0]-r[0],o=r.length===2&&i.length===2?i[1]-r[1]:-Math.floor(a*7/12),l=s.height===e.height&&s.midi!==null&&e.oct===s.oct&&e.step>s.step;return Ri([a,o],l).name}function Bi(t,n){const e=n.length,s=(t%e+e)%e;return n.slice(s,e).concat(n.slice(0,s))}var ye={empty:!0,name:"",setNum:0,chroma:"000000000000",normalized:"000000000000",intervals:[]},ji=t=>Number(t).toString(2).padStart(12,"0"),Rs=t=>parseInt(t,2),Ya=/^[01]{12}$/;function zi(t){return Ya.test(t)}var Ka=t=>typeof t=="number"&&t>=0&&t<=4095,Za=t=>t&&zi(t.chroma),Os={[ye.chroma]:ye};function Fi(t){const n=zi(t)?t:Ka(t)?ji(t):Array.isArray(t)?tl(t):Za(t)?t.chroma:ye.chroma;return Os[n]=Os[n]||Ja(n)}var qa=["1P","2m","2M","3m","3M","4P","5d","5P","6m","6M","7m","7M"];function Qa(t){const n=[];for(let e=0;e<12;e++)t.charAt(e)==="1"&&n.push(qa[e]);return n}function Xa(t){const n=t.split("");return n.map((e,s)=>Bi(s,n).join(""))}function Ja(t){const n=Rs(t),e=Xa(t).map(Rs).filter(i=>i>=2048).sort()[0],s=ji(e),r=Qa(t);return{empty:!1,name:"",setNum:n,chroma:t,normalized:s,intervals:r}}function tl(t){if(t.length===0)return ye.chroma;let n;const e=[0,0,0,0,0,0,0,0,0,0,0,0];for(let s=0;s<t.length;s++)n=Nt(t[s]),n.empty&&(n=be(t[s])),n.empty||(e[n.chroma]=1);return e.join("")}var el=[["1P 3M 5P","major","M ^ maj"],["1P 3M 5P 7M","major seventh","maj7 Δ ma7 M7 Maj7 ^7"],["1P 3M 5P 7M 9M","major ninth","maj9 Δ9 ^9"],["1P 3M 5P 7M 9M 13M","major thirteenth","maj13 Maj13 ^13"],["1P 3M 5P 6M","sixth","6 add6 add13 M6"],["1P 3M 5P 6M 9M","sixth added ninth","6add9 6/9 69 M69"],["1P 3M 6m 7M","major seventh flat sixth","M7b6 ^7b6"],["1P 3M 5P 7M 11A","major seventh sharp eleventh","maj#4 Δ#4 Δ#11 M7#11 ^7#11 maj7#11"],["1P 3m 5P","minor","m min -"],["1P 3m 5P 7m","minor seventh","m7 min7 mi7 -7"],["1P 3m 5P 7M","minor/major seventh","m/ma7 m/maj7 mM7 mMaj7 m/M7 -Δ7 mΔ -^7 -maj7"],["1P 3m 5P 6M","minor sixth","m6 -6"],["1P 3m 5P 7m 9M","minor ninth","m9 -9"],["1P 3m 5P 7M 9M","minor/major ninth","mM9 mMaj9 -^9"],["1P 3m 5P 7m 9M 11P","minor eleventh","m11 -11"],["1P 3m 5P 7m 9M 13M","minor thirteenth","m13 -13"],["1P 3m 5d","diminished","dim ° o"],["1P 3m 5d 7d","diminished seventh","dim7 °7 o7"],["1P 3m 5d 7m","half-diminished","m7b5 ø -7b5 h7 h"],["1P 3M 5P 7m","dominant seventh","7 dom"],["1P 3M 5P 7m 9M","dominant ninth","9"],["1P 3M 5P 7m 9M 13M","dominant thirteenth","13"],["1P 3M 5P 7m 11A","lydian dominant seventh","7#11 7#4"],["1P 3M 5P 7m 9m","dominant flat ninth","7b9"],["1P 3M 5P 7m 9A","dominant sharp ninth","7#9"],["1P 3M 7m 9m","altered","alt7"],["1P 4P 5P","suspended fourth","sus4 sus"],["1P 2M 5P","suspended second","sus2"],["1P 4P 5P 7m","suspended fourth seventh","7sus4 7sus"],["1P 5P 7m 9M 11P","eleventh","11"],["1P 4P 5P 7m 9m","suspended fourth flat ninth","b9sus phryg 7b9sus 7b9sus4"],["1P 5P","fifth","5"],["1P 3M 5A","augmented","aug + +5 ^#5"],["1P 3m 5A","minor augmented","m#5 -#5 m+"],["1P 3M 5A 7M","augmented seventh","maj7#5 maj7+5 +maj7 ^7#5"],["1P 3M 5P 7M 9M 11A","major sharp eleventh (lydian)","maj9#11 Δ9#11 ^9#11"],["1P 2M 4P 5P","","sus24 sus4add9"],["1P 3M 5A 7M 9M","","maj9#5 Maj9#5"],["1P 3M 5A 7m","","7#5 +7 7+ 7aug aug7"],["1P 3M 5A 7m 9A","","7#5#9 7#9#5 7alt"],["1P 3M 5A 7m 9M","","9#5 9+"],["1P 3M 5A 7m 9M 11A","","9#5#11"],["1P 3M 5A 7m 9m","","7#5b9 7b9#5"],["1P 3M 5A 7m 9m 11A","","7#5b9#11"],["1P 3M 5A 9A","","+add#9"],["1P 3M 5A 9M","","M#5add9 +add9"],["1P 3M 5P 6M 11A","","M6#11 M6b5 6#11 6b5"],["1P 3M 5P 6M 7M 9M","","M7add13"],["1P 3M 5P 6M 9M 11A","","69#11"],["1P 3m 5P 6M 9M","","m69 -69"],["1P 3M 5P 6m 7m","","7b6"],["1P 3M 5P 7M 9A 11A","","maj7#9#11"],["1P 3M 5P 7M 9M 11A 13M","","M13#11 maj13#11 M13+4 M13#4"],["1P 3M 5P 7M 9m","","M7b9"],["1P 3M 5P 7m 11A 13m","","7#11b13 7b5b13"],["1P 3M 5P 7m 13M","","7add6 67 7add13"],["1P 3M 5P 7m 9A 11A","","7#9#11 7b5#9 7#9b5"],["1P 3M 5P 7m 9A 11A 13M","","13#9#11"],["1P 3M 5P 7m 9A 11A 13m","","7#9#11b13"],["1P 3M 5P 7m 9A 13M","","13#9"],["1P 3M 5P 7m 9A 13m","","7#9b13"],["1P 3M 5P 7m 9M 11A","","9#11 9+4 9#4"],["1P 3M 5P 7m 9M 11A 13M","","13#11 13+4 13#4"],["1P 3M 5P 7m 9M 11A 13m","","9#11b13 9b5b13"],["1P 3M 5P 7m 9m 11A","","7b9#11 7b5b9 7b9b5"],["1P 3M 5P 7m 9m 11A 13M","","13b9#11"],["1P 3M 5P 7m 9m 11A 13m","","7b9b13#11 7b9#11b13 7b5b9b13"],["1P 3M 5P 7m 9m 13M","","13b9"],["1P 3M 5P 7m 9m 13m","","7b9b13"],["1P 3M 5P 7m 9m 9A","","7b9#9"],["1P 3M 5P 9M","","Madd9 2 add9 add2"],["1P 3M 5P 9m","","Maddb9"],["1P 3M 5d","","Mb5"],["1P 3M 5d 6M 7m 9M","","13b5"],["1P 3M 5d 7M","","M7b5"],["1P 3M 5d 7M 9M","","M9b5"],["1P 3M 5d 7m","","7b5"],["1P 3M 5d 7m 9M","","9b5"],["1P 3M 7m","","7no5"],["1P 3M 7m 13m","","7b13"],["1P 3M 7m 9M","","9no5"],["1P 3M 7m 9M 13M","","13no5"],["1P 3M 7m 9M 13m","","9b13"],["1P 3m 4P 5P","","madd4"],["1P 3m 5P 6m 7M","","mMaj7b6"],["1P 3m 5P 6m 7M 9M","","mMaj9b6"],["1P 3m 5P 7m 11P","","m7add11 m7add4"],["1P 3m 5P 9M","","madd9"],["1P 3m 5d 6M 7M","","o7M7"],["1P 3m 5d 7M","","oM7"],["1P 3m 6m 7M","","mb6M7"],["1P 3m 6m 7m","","m7#5"],["1P 3m 6m 7m 9M","","m9#5"],["1P 3m 5A 7m 9M 11P","","m11A"],["1P 3m 6m 9m","","mb6b9"],["1P 2M 3m 5d 7m","","m9b5"],["1P 4P 5A 7M","","M7#5sus4"],["1P 4P 5A 7M 9M","","M9#5sus4"],["1P 4P 5A 7m","","7#5sus4"],["1P 4P 5P 7M","","M7sus4"],["1P 4P 5P 7M 9M","","M9sus4"],["1P 4P 5P 7m 9M","","9sus4 9sus"],["1P 4P 5P 7m 9M 13M","","13sus4 13sus"],["1P 4P 5P 7m 9m 13m","","7sus4b9b13 7b9b13sus4"],["1P 4P 7m 10m","","4 quartal"],["1P 5P 7m 9m 11P","","11b9"]],nl=el,rl={...ye,name:"",quality:"Unknown",intervals:[],aliases:[]},Di=[],Ze={};function sl(t){return Ze[t]||rl}function il(t,n,e){const s=al(t),r={...Fi(t),name:e||"",quality:s,intervals:t,aliases:n};Di.push(r),r.name&&(Ze[r.name]=r),Ze[r.setNum]=r,Ze[r.chroma]=r,r.aliases.forEach(i=>ol(r,i))}function ol(t,n){Ze[n]=t}function al(t){const n=e=>t.indexOf(e)!==-1;return n("5A")?"Augmented":n("3M")?"Major":n("5d")?"Diminished":n("3m")?"Minor":"Unknown"}nl.forEach(([t,n,e])=>il(t.split(" "),e.split(" "),n));Di.sort((t,n)=>t.setNum-n.setNum);var ll=cl((t,n)=>[t[0]-n[0],t[1]-n[1]]);function cl(t){return(n,e)=>{const s=be(n).coord,r=be(e).coord;if(s&&r){const i=t(s,r);return Ri(i).name}}}var hl=[["1P 2M 3M 5P 6M","major pentatonic","pentatonic"],["1P 2M 3M 4P 5P 6M 7M","major","ionian"],["1P 2M 3m 4P 5P 6m 7m","minor","aeolian"],["1P 2M 3m 3M 5P 6M","major blues"],["1P 3m 4P 5d 5P 7m","minor blues","blues"],["1P 2M 3m 4P 5P 6M 7M","melodic minor"],["1P 2M 3m 4P 5P 6m 7M","harmonic minor"],["1P 2M 3M 4P 5P 6M 7m 7M","bebop"],["1P 2M 3m 4P 5d 6m 6M 7M","diminished","whole-half diminished"],["1P 2M 3m 4P 5P 6M 7m","dorian"],["1P 2M 3M 4A 5P 6M 7M","lydian"],["1P 2M 3M 4P 5P 6M 7m","mixolydian","dominant"],["1P 2m 3m 4P 5P 6m 7m","phrygian"],["1P 2m 3m 4P 5d 6m 7m","locrian"],["1P 3M 4P 5P 7M","ionian pentatonic"],["1P 3M 4P 5P 7m","mixolydian pentatonic","indian"],["1P 2M 4P 5P 6M","ritusen"],["1P 2M 4P 5P 7m","egyptian"],["1P 3M 4P 5d 7m","neapolitan major pentatonic"],["1P 3m 4P 5P 6m","vietnamese 1"],["1P 2m 3m 5P 6m","pelog"],["1P 2m 4P 5P 6m","kumoijoshi"],["1P 2M 3m 5P 6m","hirajoshi"],["1P 2m 4P 5d 7m","iwato"],["1P 2m 4P 5P 7m","in-sen"],["1P 3M 4A 5P 7M","lydian pentatonic","chinese"],["1P 3m 4P 6m 7m","malkos raga"],["1P 3m 4P 5d 7m","locrian pentatonic","minor seven flat five pentatonic"],["1P 3m 4P 5P 7m","minor pentatonic","vietnamese 2"],["1P 3m 4P 5P 6M","minor six pentatonic"],["1P 2M 3m 5P 6M","flat three pentatonic","kumoi"],["1P 2M 3M 5P 6m","flat six pentatonic"],["1P 2m 3M 5P 6M","scriabin"],["1P 3M 5d 6m 7m","whole tone pentatonic"],["1P 3M 4A 5A 7M","lydian #5p pentatonic"],["1P 3M 4A 5P 7m","lydian dominant pentatonic"],["1P 3m 4P 5P 7M","minor #7m pentatonic"],["1P 3m 4d 5d 7m","super locrian pentatonic"],["1P 2M 3m 4P 5P 7M","minor hexatonic"],["1P 2A 3M 5P 5A 7M","augmented"],["1P 2M 4P 5P 6M 7m","piongio"],["1P 2m 3M 4A 6M 7m","prometheus neapolitan"],["1P 2M 3M 4A 6M 7m","prometheus"],["1P 2m 3M 5d 6m 7m","mystery #1"],["1P 2m 3M 4P 5A 6M","six tone symmetric"],["1P 2M 3M 4A 5A 6A","whole tone","messiaen's mode #1"],["1P 2m 4P 4A 5P 7M","messiaen's mode #5"],["1P 2M 3M 4P 5d 6m 7m","locrian major","arabian"],["1P 2m 3M 4A 5P 6m 7M","double harmonic lydian"],["1P 2m 2A 3M 4A 6m 7m","altered","super locrian","diminished whole tone","pomeroy"],["1P 2M 3m 4P 5d 6m 7m","locrian #2","half-diminished","aeolian b5"],["1P 2M 3M 4P 5P 6m 7m","mixolydian b6","melodic minor fifth mode","hindu"],["1P 2M 3M 4A 5P 6M 7m","lydian dominant","lydian b7","overtone"],["1P 2M 3M 4A 5A 6M 7M","lydian augmented"],["1P 2m 3m 4P 5P 6M 7m","dorian b2","phrygian #6","melodic minor second mode"],["1P 2m 3m 4d 5d 6m 7d","ultralocrian","superlocrian bb7","superlocrian diminished"],["1P 2m 3m 4P 5d 6M 7m","locrian 6","locrian natural 6","locrian sharp 6"],["1P 2A 3M 4P 5P 5A 7M","augmented heptatonic"],["1P 2M 3m 4A 5P 6M 7m","dorian #4","ukrainian dorian","romanian minor","altered dorian"],["1P 2M 3m 4A 5P 6M 7M","lydian diminished"],["1P 2M 3M 4A 5A 7m 7M","leading whole tone"],["1P 2M 3M 4A 5P 6m 7m","lydian minor"],["1P 2m 3M 4P 5P 6m 7m","phrygian dominant","spanish","phrygian major"],["1P 2m 3m 4P 5P 6m 7M","balinese"],["1P 2m 3m 4P 5P 6M 7M","neapolitan major"],["1P 2M 3M 4P 5P 6m 7M","harmonic major"],["1P 2m 3M 4P 5P 6m 7M","double harmonic major","gypsy"],["1P 2M 3m 4A 5P 6m 7M","hungarian minor"],["1P 2A 3M 4A 5P 6M 7m","hungarian major"],["1P 2m 3M 4P 5d 6M 7m","oriental"],["1P 2m 3m 3M 4A 5P 7m","flamenco"],["1P 2m 3m 4A 5P 6m 7M","todi raga"],["1P 2m 3M 4P 5d 6m 7M","persian"],["1P 2m 3M 5d 6m 7m 7M","enigmatic"],["1P 2M 3M 4P 5A 6M 7M","major augmented","major #5","ionian augmented","ionian #5"],["1P 2A 3M 4A 5P 6M 7M","lydian #9"],["1P 2m 2M 4P 4A 5P 6m 7M","messiaen's mode #4"],["1P 2m 3M 4P 4A 5P 6m 7M","purvi raga"],["1P 2m 3m 3M 4P 5P 6m 7m","spanish heptatonic"],["1P 2M 3m 3M 4P 5P 6M 7m","bebop minor"],["1P 2M 3M 4P 5P 5A 6M 7M","bebop major"],["1P 2m 3m 4P 5d 5P 6m 7m","bebop locrian"],["1P 2M 3m 4P 5P 6m 7m 7M","minor bebop"],["1P 2M 3M 4P 5d 5P 6M 7M","ichikosucho"],["1P 2M 3m 4P 5P 6m 6M 7M","minor six diminished"],["1P 2m 3m 3M 4A 5P 6M 7m","half-whole diminished","dominant diminished","messiaen's mode #2"],["1P 3m 3M 4P 5P 6M 7m 7M","kafi raga"],["1P 2M 3M 4P 4A 5A 6A 7M","messiaen's mode #6"],["1P 2M 3m 3M 4P 5d 5P 6M 7m","composite blues"],["1P 2M 3m 3M 4A 5P 6m 7m 7M","messiaen's mode #3"],["1P 2m 2M 3m 4P 4A 5P 6m 6M 7M","messiaen's mode #7"],["1P 2m 2M 3m 3M 4P 5d 5P 6m 6M 7m 7M","chromatic"]],ul=hl,dl={...ye,intervals:[],aliases:[]},qe={};function Li(t){return qe[t]||dl}function fl(t,n,e=[]){const s={...Fi(t),name:n,intervals:t,aliases:e};return qe[s.name]=s,qe[s.setNum]=s,qe[s.chroma]=s,s.aliases.forEach(r=>ml(s,r)),s}function ml(t,n){qe[n]=t}ul.forEach(([t,n,...e])=>fl(t.split(" "),n,e));var Hi={empty:!0,name:"",symbol:"",root:"",bass:"",rootDegree:0,type:"",tonic:null,setNum:NaN,quality:"Unknown",chroma:"",normalized:"",aliases:[],notes:[],intervals:[]};function pl(t){const[n,e,s,r]=Or(t);return n===""?sr("",t):n==="A"&&r==="ug"?sr("","aug"):sr(n+e,s+r)}function sr(t,n){const e=n.split("/");if(e.length===1)return[t,e[0],""];const[s,r,i,a]=Or(e[1]);return s!==""&&i===""&&a===""?[t,e[0],s+r]:[t,n,""]}function Ne(t){if(Array.isArray(t))return ir(t[1]||"",t[0],t[2]);if(t==="")return Hi;{const[n,e,s]=pl(t),r=ir(e,n,s);return r.empty?ir(t):r}}function ir(t,n,e){const s=sl(t),r=Nt(n||""),i=Nt(e||"");if(s.empty||n&&r.empty||e&&i.empty)return Hi;const a=Ts(r.pc,i.pc),o=s.intervals.indexOf(a),l=o>=0,d=l?i:Nt(""),m=o===-1?NaN:o+1,f=i.pc&&i.pc!==r.pc,p=Array.from(s.intervals);if(l)for(let v=1;v<m;v++){const y=p[0][0],_=p[0][1],S=parseInt(y,10)+7;p.push(`${S}${_}`),p.shift()}else if(f){const v=ll(Ts(r.pc,i.pc),"8P");v&&p.unshift(v)}const h=r.empty?[]:p.map(v=>Yn(r.pc,v));t=s.aliases.indexOf(t)!==-1?t:s.aliases[0];const b=`${r.empty?"":r.pc}${t}${l&&m>1?"/"+d.pc:f?"/"+i.pc:""}`,g=`${n?r.pc+" ":""}${s.name}${l&&m>1?" over "+d.pc:f?" over "+i.pc:""}`;return{...s,name:g,symbol:b,tonic:r.pc,type:s.name,root:d.pc,bass:f?i.pc:"",intervals:p,rootDegree:m,notes:h}}var gl=[[.125,"dl",["large","duplex longa","maxima","octuple","octuple whole"]],[.25,"l",["long","longa"]],[.5,"d",["double whole","double","breve"]],[1,"w",["whole","semibreve"]],[2,"h",["half","minim"]],[4,"q",["quarter","crotchet"]],[8,"e",["eighth","quaver"]],[16,"s",["sixteenth","semiquaver"]],[32,"t",["thirty-second","demisemiquaver"]],[64,"sf",["sixty-fourth","hemidemisemiquaver"]],[128,"h",["hundred twenty-eighth"]],[256,"th",["two hundred fifty-sixth"]]],bl=gl;bl.forEach(([t,n,e])=>void 0);var yl="C C# D D# E F F# G G# A A# B".split(" "),vl="C Db D Eb E F Gb G Ab A Bb B".split(" ");function Br(t,n={}){if(isNaN(t)||t===-1/0||t===1/0)return"";t=Math.round(t);const s=(n.sharps===!0?yl:vl)[t%12];if(n.pitchClass)return s;const r=Math.floor(t/12)-1;return s+r}var Te=Nt,Dt=t=>Te(t).pc,or=t=>Te(t).oct,vt=t=>Te(t).midi;function Xt(t){return Br(t)}var Ut=Yn,_l=t=>{const n=Te(t);return n.empty?"":Br(n.midi||n.chroma,{sharps:n.alt>0,pitchClass:n.midi===null})};function wl(t,n){const e=Te(t);if(e.empty)return"";const s=Te(n||Br(e.midi||e.chroma,{sharps:e.alt<0,pitchClass:!0}));if(s.empty||s.chroma!==e.chroma)return"";if(e.oct===void 0)return s.pc;const r=e.chroma-e.alt,i=s.chroma-s.alt,a=r>11||i<0?-1:r<0||i>11?1:0,o=e.oct+a;return s.pc+o}var jr=[[0,2773,0,"ionian","","Maj7","major"],[1,2902,2,"dorian","m","m7"],[2,3418,4,"phrygian","m","m7"],[3,2741,-1,"lydian","","Maj7"],[4,2774,1,"mixolydian","","7"],[5,2906,3,"aeolian","m","m7","minor"],[6,3434,5,"locrian","dim","m7b5"]],Bs={...ye,name:"",alt:0,modeNum:NaN,triad:"",seventh:"",aliases:[]},xl=jr.map(Al),_r={};xl.forEach(t=>{_r[t.name]=t,t.aliases.forEach(n=>{_r[n]=t})});function Ui(t){return typeof t=="string"?_r[t.toLowerCase()]||Bs:t&&t.name?Ui(t.name):Bs}function Al(t){const[n,e,s,r,i,a,o]=t,l=o?[o]:[],d=Number(e).toString(2);return{empty:!1,intervals:Li(r).intervals,modeNum:n,chroma:d,normalized:d,name:r,setNum:e,alt:s,triad:i,seventh:a,aliases:l}}function Wi(t){return(n,e)=>{const s=Ui(n);if(s.empty)return[];const r=Bi(s.modeNum,t),i=s.intervals.map(a=>Yn(e,a));return r.map((a,o)=>i[o]+a)}}Wi(jr.map(t=>t[4]));Wi(jr.map(t=>t[5]));var Sl={empty:!0,name:"",type:"",tonic:null,setNum:NaN,chroma:"",normalized:"",aliases:[],notes:[],intervals:[]};function kl(t){if(typeof t!="string")return["",""];const n=t.indexOf(" "),e=Nt(t.substring(0,n));if(e.empty){const r=Nt(t);return r.empty?["",t.toLowerCase()]:[r.name,""]}const s=t.substring(e.name.length+1).toLowerCase();return[e.name,s.length?s:""]}function Ml(t){const n=Array.isArray(t)?t:kl(t),e=Nt(n[0]).name,s=Li(n[1]);if(s.empty)return Sl;const r=s.name,i=e?s.intervals.map(o=>Yn(e,o)):[],a=e?e+" "+r:r;return{...s,name:a,type:r,tonic:e,notes:i}}function Ft(t){return _l(t)||t}const Pl=/([#b](?:5|9|11|13)|add(?:9|11|13|b9|#9|b13|#11))$/,Cl={"#5":"5A",b5:"5d","#9":"2A",b9:"2m","#11":"4A",b11:"4d","#13":"6A",b13:"6m",add9:"2M",add11:"4P",add13:"6M",addb9:"2m","add#9":"2A","add#11":"4A",addb13:"6m"};function El(t){const n=t.match(/^([A-G][#b]?)/);if(!n)return null;const e=n[1];let s=t.slice(e.length);const r=[];let i=0;for(;s&&i<5;){const a=s.match(Pl);if(!a)break;const o=a[1],l=Cl[o];if(!l)break;r.unshift(l),s=s.slice(0,-o.length),i++;const d=Ne(e+s);if(!d.empty){let m=d.notes.map(Ft);for(const f of r){const p=Ut(e,f);if(p){const h=Ft(p);m.includes(h)||m.push(h)}}return{notes:m,root:Ft(e),type:d.type+" (extended)"}}}return null}function Il(t){const n=t.match(/^([A-G][#b]?)/i);if(!n)return t;const e=n[1];let s=t.slice(e.length);return s=s.replace(/^maug$/i,"m#5"),s=s.replace(/mmaj/i,"mMaj"),e+s}function Nl(t){const n=t.match(/^([A-G][#b]?)/i);if(!n)return null;const e=n[1],s=t.slice(e.length);return/^7omit3$/i.test(s)?{notes:[e,Ut(e,"5P"),Ut(e,"7m")].map(Ft),root:Ft(e),type:"7omit3"}:/^m7sus4?$/i.test(s)?{notes:[e,Ut(e,"3m"),Ut(e,"4P"),Ut(e,"7m")].map(Ft),root:Ft(e),type:"m7sus4"}:/^m6\/9$/i.test(s)?{notes:[e,Ut(e,"3m"),Ut(e,"5P"),Ut(e,"6M"),Ut(e,"2M")].map(Ft),root:Ft(e),type:"m6/9"}:null}function mn(t,n){t=Il(t);const e=Ne(t);let s,r,i,a;const o=Nl(t);if(o)s=o.notes,r=o.root,i=o.type;else if(!e.empty)s=e.notes.map(Ft),r=Ft(e.tonic??s[0]),i=e.type,a=e.intervals;else{const l=El(t);if(!l)throw new Error(`Unknown chord: "${t}"`);s=l.notes,r=l.root,i=l.type}if(n&&n>0){const l=n%s.length;s=[...s.slice(l),...s.slice(0,l)]}return{notes:s,root:r,type:i,intervals:a}}const Tl=new Set(["C","D","F","G","A"]);function Se(t){return Tl.has(gt[(t%7+7)%7])}function Oe(t){return $n(t).replace("#","")}function Rl(t,n){const e=gt.indexOf(t);let s=gt.indexOf(n);return s<e&&(s+=7),s-e}function js(t,n){const e=(t%7+7)%7,s=(n%7+7)%7;return e===1&&(t-=1),e===4&&(t-=1),e===5&&(t-=2),s===1&&(n+=1),s===4&&(n+=2),s===5&&(n+=1),{startIdx:t,endIdx:n}}function Kn(t,n={}){const{padding:e=1,startingNote:s,spanFrom:r,spanTo:i}=n;if(s){const M=Oe(s);let w=gt.indexOf(M)-e,T=!1;Se(w)&&(w-=1,T=!0);const P=gt[(w%7+7)%7];if(t.length>0){const z=t.map(Oe),E=gt.indexOf(M),L=[];for(const R of z){let J=gt.indexOf(R);if(L.length===0)for(;J<E;)J+=7;else{const tt=L[L.length-1];for(;J<=tt;)J+=7}L.push(J)}let k=Math.max(...L)+e,I=!1;Se(k)&&(k+=1,I=!0);const u=js(w,k);w=u.startIdx,k=u.endIdx;const j=gt[(w%7+7)%7];let X=k-w+1;const G=gt.indexOf(M),st=gt.indexOf(j),H=((G-st)%7+7)%7,Q=H===0&&e>0?7:H;let B=0;for(let R=1;R<=Q;R++)gt[(st+R)%7]==="C"&&B++;return{startFrom:j,size:Math.max(X,t.length+2),chordOctave:B,clipLeft:T,clipRight:I}}return{startFrom:P,size:8,chordOctave:0,clipLeft:T}}if(r&&i){const M=Oe(r),w=Oe(i),T=Rl(M,w);return{startFrom:M,size:T===0?8:T+1,chordOctave:0}}if(t.length===0)return{startFrom:"C",size:8,chordOctave:0};const a=t.map(Oe),o=[];for(const M of a){let w=gt.indexOf(M);if(o.length>0){const T=o[o.length-1];for(;w<=T;)w+=7}o.push(w)}const l=o[0],d=o[o.length-1];let m=l-e,f=d+e,p=!1,h=!1;Se(m)&&(m-=1,p=!0),Se(f)&&(f+=1,h=!0);const b=js(m,f);m=b.startIdx,f=b.endIdx;const g=gt[(m%7+7)%7],v=f-m+1,y=l-m,_=gt.indexOf(g);let S=0;for(let M=1;M<=y;M++){const w=(_+M)%7;gt[w]==="C"&&S++}return{startFrom:g,size:Math.max(v,t.length+2),chordOctave:S,clipLeft:p,clipRight:h}}const Ol={i:0,ii:2,iii:4,iv:5,v:7,vi:9,vii:11};function Bl(t){const n=/^([#b]?)(iv|vi{1,2}|i{1,3}|v)(.*)/i,e=t.match(n);if(!e)return null;const s=e[1],r=e[2],i=e[3],a=r.toLowerCase(),o=Ol[a];if(o===void 0)return null;let l=o;s==="b"&&(l-=1),s==="#"&&(l+=1),l=(l%12+12)%12;const d=r===r.toLowerCase();let m="";if(i){let f=i.replace(/^°7/,"dim7").replace(/^°/,"dim").replace(/^ø7?/,"m7b5").replace(/^Δ7?/,"maj7");d&&!f.startsWith("m")&&!f.startsWith("dim")&&!f.startsWith("M")?m="m"+f:m=f}else m=d?"m":"";return{semitones:l,quality:m,hasFlat:s==="b"}}function Gi(t,n){const e=vt(`${n}4`);if(e==null)throw new Error(`Invalid key: ${n}`);return t.map(s=>{const r=Bl(s);if(!r)throw new Error(`Can't parse roman numeral: "${s}"`);const i=e+r.semitones,a=Dt(Xt(i)),o=Fo(a,n,r.hasFlat),l=o+r.quality;return{root:o,symbol:l,degree:r.semitones}})}function $i(t){return t.split(/[\s\-–—→>]+/).map(n=>n.trim()).filter(n=>n.length>0)}const Pn=[{id:"ii-V-I",name:"ii-V-I",numerals:["ii7","V7","Imaj7"],description:"The most common jazz cadence"},{id:"minor-ii-V-i",name:"Minor ii-V-i",numerals:["iiø7","V7","i7"],description:"Minor key ii-V-i cadence"},{id:"I-vi-ii-V",name:"I-vi-ii-V",numerals:["Imaj7","vi7","ii7","V7"],description:"Classic turnaround (rhythm changes A section)"},{id:"iii-vi-ii-V",name:"iii-vi-ii-V",numerals:["iii7","vi7","ii7","V7"],description:"Extended turnaround from the iii chord"},{id:"blues",name:"12-Bar Blues",numerals:["I7","IV7","I7","I7","IV7","IV7","I7","I7","V7","IV7","I7","V7"],description:"Standard 12-bar blues progression"},{id:"jazz-blues",name:"Jazz Blues",numerals:["I7","IV7","I7","vi7","ii7","V7","I7","vi7","ii7","V7","I7","ii7","V7"],description:"Jazz blues with ii-V turnarounds"},{id:"rhythm-changes",name:"Rhythm Changes (A)",numerals:["Imaj7","vi7","ii7","V7","iii7","vi7","ii7","V7"],description:"A section of rhythm changes (I Got Rhythm)"},{id:"modal-vamp",name:"Modal Vamp",numerals:["i7","bVII7"],description:"Two-chord modal vamp (So What / Impressions style)"},{id:"backdoor-ii-V",name:"Backdoor ii-V",numerals:["iv7","bVII7","Imaj7"],description:"Backdoor resolution via bVII to I"},{id:"tritone-sub",name:"Tritone Sub ii-V-I",numerals:["ii7","bII7","Imaj7"],description:"ii-V-I with tritone substitution on the V"}],jl={blues:"blues",jazzblues:"jazz-blues",rhythmchanges:"rhythm-changes",rhythmchange:"rhythm-changes",turnaround:"I-vi-ii-V",modalvamp:"modal-vamp",backdoor:"backdoor-ii-V",tritonesub:"tritone-sub",tritonesubstitution:"tritone-sub",minoriivi:"minor-ii-V-i","minorii-v-i":"minor-ii-V-i"};function Vi(t){const n=t.toLowerCase().replace(/[\s\-–—]+/g,""),e=Pn.find(r=>r.id.replace(/-/g,"").toLowerCase()===n);if(e)return e;const s=jl[n];return s?Pn.find(r=>r.id===s):Pn.find(r=>{const i=r.name.toLowerCase().replace(/[\s\-–—]+/g,"");return i.includes(n)||n.includes(i)})}const zl=[{id:"shell-maj7-r7",name:"Shell Maj7 (Root + 7)",quality:"maj7",intervals:[0,11],tags:{era:"Bebop",style:"Shell",artist:"Bud Powell",source:"Shell Voicings"},range:{min:36,max:60}},{id:"shell-maj7-r3",name:"Shell Maj7 (Root + 3)",quality:"maj7",intervals:[0,4],tags:{era:"Bebop",style:"Shell",artist:"Bud Powell",source:"Shell Voicings"},range:{min:36,max:60}},{id:"shell-maj7-tenth",name:"Shell Maj7 (Tenth)",quality:"maj7",intervals:[0,16],tags:{era:"Bebop",style:"Shell",artist:"Bud Powell",source:"Shell Voicings"},range:{min:36,max:55}},{id:"shell-min7-r7",name:"Shell m7 (Root + b7)",quality:"min7",intervals:[0,10],tags:{era:"Bebop",style:"Shell",artist:"Bud Powell",source:"Shell Voicings"},range:{min:36,max:60}},{id:"shell-min7-r3",name:"Shell m7 (Root + b3)",quality:"min7",intervals:[0,3],tags:{era:"Bebop",style:"Shell",artist:"Bud Powell",source:"Shell Voicings"},range:{min:36,max:60}},{id:"shell-min7-tenth",name:"Shell m7 (Tenth)",quality:"min7",intervals:[0,15],tags:{era:"Bebop",style:"Shell",artist:"Bud Powell",source:"Shell Voicings"},range:{min:36,max:55}},{id:"shell-dom7-r7",name:"Shell Dom7 (Root + b7)",quality:"dom7",intervals:[0,10],tags:{era:"Bebop",style:"Shell",artist:"Bud Powell",source:"Shell Voicings"},range:{min:36,max:60}},{id:"shell-dom7-r3",name:"Shell Dom7 (Root + 3)",quality:"dom7",intervals:[0,4],tags:{era:"Bebop",style:"Shell",artist:"Bud Powell",source:"Shell Voicings"},range:{min:36,max:60}},{id:"shell-dom7-tenth",name:"Shell Dom7 (Tenth)",quality:"dom7",intervals:[0,16],tags:{era:"Bebop",style:"Shell",artist:"Bud Powell",source:"Shell Voicings"},range:{min:36,max:55}}],Fl=[{id:"rootless-maj7-a",name:"Rootless Maj7 Type A (3-5-7-9)",quality:"maj7",intervals:[4,7,11,14],tags:{era:"Post-Bop",style:"Rootless Type A",artist:"Bill Evans",source:"Rootless Voicings"},range:{min:50,max:67}},{id:"rootless-maj7-b",name:"Rootless Maj7 Type B (7-9-3-5)",quality:"maj7",intervals:[11,14,16,19],tags:{era:"Post-Bop",style:"Rootless Type B",artist:"Bill Evans",source:"Rootless Voicings"},range:{min:50,max:67}},{id:"rootless-min7-a",name:"Rootless m7 Type A (b3-5-b7-9)",quality:"min7",intervals:[3,7,10,14],tags:{era:"Post-Bop",style:"Rootless Type A",artist:"Bill Evans",source:"Rootless Voicings"},range:{min:50,max:67}},{id:"rootless-min7-b",name:"Rootless m7 Type B (b7-9-b3-5)",quality:"min7",intervals:[10,14,15,19],tags:{era:"Post-Bop",style:"Rootless Type B",artist:"Bill Evans",source:"Rootless Voicings"},range:{min:50,max:67}},{id:"rootless-dom7-a",name:"Rootless Dom7 Type A (3-13-b7-9)",quality:"dom7",intervals:[4,9,10,14],tags:{era:"Post-Bop",style:"Rootless Type A",artist:"Bill Evans",source:"Rootless Voicings"},range:{min:50,max:67}},{id:"rootless-dom7-b",name:"Rootless Dom7 Type B (b7-9-3-13)",quality:"dom7",intervals:[10,14,16,21],tags:{era:"Post-Bop",style:"Rootless Type B",artist:"Bill Evans",source:"Rootless Voicings"},range:{min:50,max:67}},{id:"rootless-alt-a",name:"Rootless Alt Type A (3-b7-#9-b13)",quality:"alt",intervals:[4,10,15,20],tags:{era:"Post-Bop",style:"Rootless Type A",artist:"Bill Evans",source:"Altered Voicings"},range:{min:50,max:67}},{id:"rootless-alt-b",name:"Rootless Alt Type B (b7-#9-3-b13)",quality:"alt",intervals:[10,15,16,20],tags:{era:"Post-Bop",style:"Rootless Type B",artist:"Bill Evans",source:"Altered Voicings"},range:{min:50,max:67}},{id:"rootless-m7b5-a",name:"Rootless m7b5 Type A (b3-b5-b7-9)",quality:"m7b5",intervals:[3,6,10,14],tags:{era:"Post-Bop",style:"Rootless Type A",artist:"Bill Evans",source:"Rootless Voicings"},range:{min:50,max:67}},{id:"rootless-m7b5-b",name:"Rootless m7b5 Type B (b7-9-b3-b5)",quality:"m7b5",intervals:[10,14,15,18],tags:{era:"Post-Bop",style:"Rootless Type B",artist:"Bill Evans",source:"Rootless Voicings"},range:{min:50,max:67}}],Dl=[{id:"quartal-3note",name:"Quartal Stack (3 notes)",quality:"sus4",intervals:[0,5,10],tags:{era:"Modal",style:"Quartal",artist:"McCoy Tyner",source:"Quartal Voicings"},range:{min:48,max:72}},{id:"quartal-4note",name:"Quartal Stack (4 notes)",quality:"min7",intervals:[0,5,10,15],tags:{era:"Modal",style:"Quartal",artist:"McCoy Tyner",source:"Quartal Voicings"},range:{min:48,max:72}},{id:"modal-so-what",name:"So What Chord (3 P4ths + M3)",quality:"min7",intervals:[0,5,10,15,19],tags:{era:"Modal",style:"Quartal",artist:"McCoy Tyner",source:"Quartal Voicings"},range:{min:48,max:72}},{id:"phrygian-stack",name:"Phrygian Stack (5 notes)",quality:"sus4",intervals:[0,5,10,15,20],tags:{era:"Modal",style:"Quartal",artist:"Kenny Barron",source:"Quartal Voicings"},range:{min:48,max:72}}],Ll=[{id:"us-II",name:"Upper Structure II (Lydian Dominant)",quality:"dom7",intervals:[4,10,14,18,21],hands:["LH","LH","RH","RH","RH"],tags:{era:"Modern",style:"Upper Structure",artist:"Herbie Hancock",source:"Upper Structures"},range:{min:48,max:72}},{id:"us-bVI",name:"Upper Structure bVI (Altered)",quality:"alt",intervals:[4,10,20,24,27],hands:["LH","LH","RH","RH","RH"],tags:{era:"Modern",style:"Upper Structure",artist:"Herbie Hancock",source:"Upper Structures"},range:{min:48,max:72}},{id:"us-bV",name:"Upper Structure bV (Altered #2)",quality:"alt",intervals:[4,10,18,22,25],hands:["LH","LH","RH","RH","RH"],tags:{era:"Modern",style:"Upper Structure",artist:"Herbie Hancock",source:"Upper Structures"},range:{min:48,max:72}},{id:"us-VI",name:"Upper Structure VI (Diminished Sound)",quality:"dom7",intervals:[4,10,21,25,28],hands:["LH","LH","RH","RH","RH"],tags:{era:"Modern",style:"Upper Structure",artist:"Herbie Hancock",source:"Upper Structures"},range:{min:48,max:72}}],Hl=[{id:"drop2-maj6",name:"Drop 2 Maj6 (5th in bass)",quality:"maj6",intervals:[-5,0,4,9],tags:{era:"Hard Bop",style:"Drop 2",artist:"Barry Harris",source:"Drop 2 Voicings"},range:{min:48,max:72}},{id:"drop2-maj6-inv2",name:"Drop 2 Maj6 (6th in bass)",quality:"maj6",intervals:[-3,4,7,12],tags:{era:"Hard Bop",style:"Drop 2",artist:"Barry Harris",source:"Drop 2 Voicings"},range:{min:48,max:72}},{id:"drop2-min7",name:"Drop 2 m7 (5th in bass)",quality:"min7",intervals:[-5,0,3,10],tags:{era:"Hard Bop",style:"Drop 2",artist:"Bill Evans",source:"Drop 2 Voicings"},range:{min:48,max:72}},{id:"drop2-dom7",name:"Drop 2 Dom7 (5th in bass)",quality:"dom7",intervals:[-5,0,4,10],tags:{era:"Hard Bop",style:"Drop 2",source:"Drop 2 Voicings"},range:{min:48,max:72}},{id:"drop2-m7b5",name:"Drop 2 m7b5 (b5 in bass)",quality:"m7b5",intervals:[-6,0,3,10],tags:{era:"Hard Bop",style:"Drop 2",source:"Drop 2 Voicings"},range:{min:48,max:72}}],Ul=[{id:"drop24-maj7",name:"Drop 2+4 Maj7",quality:"maj7",intervals:[-8,-1,4,7],tags:{era:"Hard Bop",style:"Drop 2+4",source:"Drop 2+4 Voicings"},range:{min:48,max:72}},{id:"drop24-min7",name:"Drop 2+4 m7",quality:"min7",intervals:[-9,-2,3,7],tags:{era:"Hard Bop",style:"Drop 2+4",source:"Drop 2+4 Voicings"},range:{min:48,max:72}},{id:"drop24-dom7",name:"Drop 2+4 Dom7",quality:"dom7",intervals:[-8,-2,4,7],tags:{era:"Hard Bop",style:"Drop 2+4",source:"Drop 2+4 Voicings"},range:{min:48,max:72}},{id:"drop24-m7b5",name:"Drop 2+4 m7b5",quality:"m7b5",intervals:[-8,-2,3,6],tags:{era:"Hard Bop",style:"Drop 2+4",source:"Drop 2+4 Voicings"},range:{min:48,max:72}}],Wl=[{id:"spread-maj7",name:"Spread Maj7 (3+7 low, 9+5 high)",quality:"maj7",intervals:[0,4,11,14,19],tags:{era:"Modern",style:"Spread",source:"Big Band Arranging"},range:{min:36,max:72}},{id:"spread-min7",name:"Spread m7 (3+7 low, 9+5 high)",quality:"min7",intervals:[0,3,10,14,19],tags:{era:"Modern",style:"Spread",source:"Big Band Arranging"},range:{min:36,max:72}},{id:"spread-dom7",name:"Spread Dom7 (3+7 low, 9+13 high)",quality:"dom7",intervals:[0,4,10,14,21],tags:{era:"Modern",style:"Spread",source:"Big Band Arranging"},range:{min:36,max:72}},{id:"spread-dom7-sharp11",name:"Spread Dom7#11 (3+7 low, #11+9 high)",quality:"dom7",intervals:[0,4,10,14,18],tags:{era:"Modern",style:"Spread",source:"Big Band Arranging"},range:{min:36,max:72}},{id:"spread-m7b5",name:"Spread m7b5 (3+7 low, 9+b5 high)",quality:"m7b5",intervals:[0,3,10,13,18],tags:{era:"Modern",style:"Spread",source:"Big Band Arranging"},range:{min:36,max:72}}],Gl=[{id:"4close-maj7",name:"4-Note Closed Maj7 (1-3-7-9)",quality:"maj7",intervals:[0,4,11,14],tags:{era:"Modern",style:"4-Note Closed",artist:"Sammy Nestico",source:"Big Band Arranging"},range:{min:48,max:72}},{id:"4close-min7",name:"4-Note Closed m7 (1-3-7-9)",quality:"min7",intervals:[0,3,10,14],tags:{era:"Modern",style:"4-Note Closed",artist:"Sammy Nestico",source:"Big Band Arranging"},range:{min:48,max:72}},{id:"4close-dom7",name:"4-Note Closed Dom7 (3-13-7-9)",quality:"dom7",intervals:[4,9,10,14],tags:{era:"Modern",style:"4-Note Closed",artist:"Sammy Nestico",source:"Big Band Arranging"},range:{min:48,max:72}},{id:"4close-dom13",name:"4-Note Closed Dom13 (3-13-9-7)",quality:"dom7",intervals:[4,10,14,21],tags:{era:"Modern",style:"4-Note Closed",artist:"Sammy Nestico",source:"Big Band Arranging"},range:{min:55,max:72}},{id:"4close-m7b5",name:"4-Note Closed m7b5 (1-b3-b5-9)",quality:"m7b5",intervals:[0,3,6,14],tags:{era:"Modern",style:"4-Note Closed",artist:"Sammy Nestico",source:"Big Band Arranging"},range:{min:48,max:72}}],Zn=[...zl,...Fl,...Dl,...Ll,...Hl,...Ul,...Wl,...Gl],Yi={Db:"C#",Eb:"D#",Gb:"F#",Ab:"G#",Bb:"A#"},$l={"C#":"Db","D#":"Eb","F#":"Gb","G#":"Ab","A#":"Bb"},Vl=new Set(["F","Bb","Eb","Ab","Db","Gb","Cb"]);function wr(t){return Yi[t]??t}function Yl(t,n){return Vl.has(n)?$l[t]??t:Yi[t]??t}const Kl={"bud powell":{style:"Shell"},"thelonious monk":{style:"Shell"},bebop:{style:"Shell"},"count basie":{style:"Shell"},basie:{style:"Shell"},"bill evans":{style:"Rootless Type A"},"wynton kelly":{style:"Rootless Type A"},comping:{style:"Rootless Type A"},rootless:{style:"Rootless Type A"},"mccoy tyner":{style:"Quartal"},modal:{style:"Quartal"},"so what":{style:"Quartal"},"herbie hancock":{style:"Upper Structure"},"upper structure":{style:"Upper Structure"},altered:{style:"Upper Structure"},"duke ellington":{style:"Drop 2"},ellington:{style:"Drop 2"},"george shearing":{style:"Drop 2"},"barry harris":{style:"Drop 2"},block:{style:"Drop 2"},"drop 2+4":{style:"Drop 2+4"},"drop 2 and 4":{style:"Drop 2+4"},"drop 2":{style:"Drop 2"},"locked hands":{style:"Drop 2"},spread:{style:"Spread"},"sax section":{style:"Spread"},"sammy nestico":{style:"4-Note Closed"},nestico:{style:"4-Note Closed"},"4-note closed":{style:"4-Note Closed"},"four note closed":{style:"4-Note Closed"},"trumpet section":{style:"4-Note Closed"}};function qn(t,n){const e=t.toLowerCase();if(e.includes("alt"))return"alt";if(e.includes("dim7")||e.includes("diminished seventh"))return"dim7";if(e.includes("m7b5")||e.includes("half"))return"m7b5";if(e.includes("sus"))return"sus4";if(e.includes("min")||e.includes("minor"))return e==="minor"||e==="minor triad"?void 0:e.includes("6/9")||e.includes("6add9")?"m6/9":e.includes("6")?"min6":"min7";if(e.includes("maj")||e.includes("major"))return e==="major"||e==="major triad"?void 0:"maj7";if(e.includes("dom")||e.includes("7")||e.includes("9")||e.includes("13"))return"dom7";if(e.includes("6/9"))return"6/9";if(e.includes("6"))return"maj6"}function zr(t){const n=t.toLowerCase().trim();for(const[e,s]of Object.entries(Kl))if(n.includes(e))return s.style}function ie(t){return Zn.filter(n=>{if(t.quality&&n.quality!==t.quality||t.era&&n.tags.era!==t.era||t.style&&n.tags.style!==t.style)return!1;if(t.artist){const e=t.artist.toLowerCase();if(n.tags.artist&&!n.tags.artist.toLowerCase().includes(e)||!n.tags.artist)return!1}return!0})}function Fr(t,n,e=3){const s=vt(`${t}${e}`);return s==null?[]:n.intervals.map((r,i)=>{var f;const a=s+r,o=Xt(a),l=Dt(o),d=Yl(l,t),m=((f=n.hands)==null?void 0:f[i])??"LH";return{note:o,midi:a,pitchClass:d,hand:m}})}function Zl(t,n,e=3){return Fr(t,n,e).map(s=>s.note)}function Re(t,n,e=3){return Fr(t,n,e).map(s=>s.pitchClass)}function ql(t,n){return Zn.filter(e=>e.quality===t&&e.id!==n)}function Qn(t,n){const e=n?zr(n):void 0;if(e){const r=ie({quality:t,style:e});if(r.length>0)return r[0];if(e==="Rootless Type A"){const i=ie({quality:t,style:"Rootless Type B"});if(i.length>0)return i[0]}}const s=ie({quality:t});if(s.length>0)return s[0];n&&console.warn(`No voicing found for quality "${t}" with style hint "${n}"`)}const zs={SWEET_LOW:50,SWEET_HIGH:62};function Ki(t,n){const e=ie({quality:n,style:"Rootless Type A"}),s=ie({quality:n,style:"Rootless Type B"});if(e.length===0&&s.length===0)return;if(e.length===0)return s[0];if(s.length===0)return e[0];const r=Math.min(...e[0].intervals),i=t+r;return i<zs.SWEET_LOW?s[0]:(i>zs.SWEET_HIGH,e[0])}function Ql(t,n,e=3,s){if(s){const a=ie({quality:n,style:s});if(a.length>0)return a[0]}const r=vt(`${t}${e}`);if(r!=null)return Ki(r,n)}function Xl(t,n){const e=vt(t);if(e==null)throw new Error(`Invalid melody note: ${t}`);const s=Ne(n);if(!s.notes.length)throw new Error(`Unknown chord symbol: ${n}`);const r=s.notes.map(p=>vt(`${p}4`)%12);if(r.length<4)throw new Error(`${n} has only ${r.length} notes — locked hands requires a 7th chord or richer`);const i=e%12;if(!r.includes(i))throw new Error(`Melody note ${t} (pc=${i}) is not a chord tone of ${n} (pcs=${r.join(",")})`);const a=[e],o=new Set([i]);let l=e-1;for(;a.length<4;){const p=(l%12+12)%12;if(r.includes(p)&&!o.has(p)&&(a.push(l),o.add(p)),l--,e-l>24)throw new Error(`Could not find enough chord tones below ${t} for ${n}`)}const d=e-12;a.sort((p,h)=>p-h);const m=[d,...a];return m.sort((p,h)=>p-h),m.map((p,h)=>{const b=Xt(p),g=Dt(b),v=h===0?"LH":"RH";return{note:b,midi:p,pitchClass:wr(g),hand:v}})}function Qe(t,n){const e=Xt(t),s=Dt(e);return{note:e,midi:t,pitchClass:s,hand:n}}function Jl(t,n){const e=Ne(`${t}${n}`);if(!e||e.empty){const r={dom7:"7",maj:"M",min:"m",maj7:"maj7",min7:"m7",dim:"dim",aug:"aug"}[n];if(r){const i=Ne(`${t}${r}`);if(i&&!i.empty)return i.notes}return[t]}return e.notes}function Xe(t,n){const e=vt(`${t}${n}`);if(e==null)throw new Error(`Cannot resolve MIDI for ${t}${n}`);return e}function tc(t){const n=Ne(`${t}7`);if(!n||n.empty||n.notes.length<4){const e=vt(`${t}4`);if(e==null)throw new Error(`Invalid root note: ${t}`);return[Dt(Xt(e+4)),Dt(Xt(e+10))]}return[n.notes[1],n.notes[3]]}function ec(t,n){const e=[];if(n.quality==="dom7"||n.quality==="7"){const r=tc(n.root);for(const i of r){const a=Xe(i,3);e.push(Qe(a,"LH"))}}else{const r=Xe(n.root,3);e.push(Qe(r,"LH"))}const s=Jl(t.root,t.quality);for(const r of s){const i=Xe(r,4);e.push(Qe(i,"RH"))}return e.sort((r,i)=>r.midi-i.midi),e}function nc(t,n){const e=[],s=Xe(n,3);e.push(Qe(s,"LH"));const r=wl(n),i=t.filter(o=>o!==n&&o!==r),a=i.length>0?i:t;for(const o of a){const l=Xe(o,4);e.push(Qe(l,"RH"))}return e.sort((o,l)=>o.midi-l.midi),e}function rc(t,n){return t.length===0?!1:wr(t[0])===wr(n)}function sc(t,n,e,s=3,r){const i=new Set((r==null?void 0:r.excludeIds)??[]),a=[],o=new Set,l=p=>p.join(","),d=p=>{const h=l(p.notes);return o.has(h)||i.has(p.id)?!1:(o.add(h),a.push(p),!0)};let m;if(r!=null&&r.styleHint&&n&&(m=Qn(n,r.styleHint)),m){const p=Re(t,m);d({id:m.id,label:m.tags.style,notes:p,handHints:m.hands,source:"library"})}else{const p=[...e],h=rc(p,t),b=h?"Root position":`From ${p[0]}`;d({id:h?"root-position":"default",label:b,notes:p,source:"inversion"})}if(n){const p=new Map;for(const h of Zn)h.quality===n&&(i.has(h.id)||m&&h.id===m.id||p.has(h.tags.style)||p.set(h.tags.style,h));for(const[h,b]of p){const g=Re(t,b);d({id:b.id,label:h,notes:g,handHints:b.hands,source:"library"})}}const f=["1st inv","2nd inv","3rd inv","4th inv","5th inv"];for(let p=1;p<e.length&&p<=5;p++){const h=[...e.slice(p),...e.slice(0,p)];d({id:`inv-${p}`,label:f[p-1]??`${p}th inv`,notes:h,source:"inversion"})}if(e.length>=3){const p=[e[0],...e.slice(2),e[1]];d({id:"algo-open",label:"Open voicing",notes:p,source:"algorithmic"});const h=[...e],b=h.splice(-2,1)[0];h.unshift(b),d({id:"algo-drop2",label:"Drop 2",notes:h,source:"algorithmic"})}if(e.length>=4){const p=[e[0],e[1],e[e.length-1]];d({id:"algo-simplified",label:"Simplified",notes:p,source:"algorithmic"})}return a.slice(0,s)}const Zi=["Rootless Type A","Drop 2","Shell","Quartal","Spread","4-Note Closed","Rootless Type B","Upper Structure","Drop 2+4"];function ic(t){const n=zr(t);if(!n)return Zi.slice(0,ge);const e=[n];return n==="Rootless Type A"?e.push("Rootless Type B","Shell"):n==="Rootless Type B"?e.push("Rootless Type A","Shell"):n==="Shell"?e.push("Rootless Type A","Drop 2"):n==="Drop 2"?e.push("Drop 2+4","Shell"):n==="Drop 2+4"?e.push("Drop 2","Spread"):n==="Quartal"?e.push("Upper Structure","Rootless Type A"):n==="Upper Structure"?e.push("Quartal","Spread"):n==="Spread"?e.push("Drop 2","4-Note Closed"):n==="4-Note Closed"&&e.push("Spread","Drop 2"),e.slice(0,ge)}function oc(t,n){const e=mn(t),s=qn(e.type,e.notes);let r=e.notes,i;if(s&&n){const a=ie({quality:s,style:n});if(a.length>0){const o=Re(e.root,a[0]);o.length>0&&(r=o,i=n)}}if(!i&&s){const a=Qn(s);if(a){const o=Re(e.root,a);o.length>0&&(r=o,i=a.tags.style)}}return{symbol:t,root:e.root,notes:r,voicingStyle:i}}function ac(t){const n=Math.min(t.numExamples??ge,ge),e=Vi(t.progression);let s,r;e?(s=e.numerals,r=e.name):(s=$i(t.progression),r=s.join("-"));const i=Gi(s,t.key),a=t.styleHint?ic(t.styleHint):Zi.slice(0,n),o=[];for(let l=0;l<n;l++){const d=a[l%a.length],m=i.map(f=>oc(f.symbol,d));o.push({label:`Example ${l+1} — ${d}`,chords:m})}return{progressionName:r,key:t.key,examples:o}}function yn(t){if(t<128)return[t];const n=[];for(n.unshift(t&127),t>>=7;t>0;)n.unshift(t&127|128),t>>=7;return n}function _e(t){return[t>>8&255,t&255]}function vn(t){return[t>>24&255,t>>16&255,t>>8&255,t&255]}function ar(t,n=4){return/[0-9]$/.test(t)?vt(t):vt(`${t}${n}`)}function lr(t,n,e,s,r,i,a,o){const l=[],d=144|n,m=128|n;if(i){const{microsecondsPerBeat:h}=i;l.push(0,255,81,3,h>>16&255,h>>8&255,h&255)}const f=Array.from(r,h=>h.charCodeAt(0)&127);if(l.push(0,255,3,...yn(f.length),...f),a&&o)for(let h=0;h<t.length;h++){const b=h===0?0:o;l.push(...yn(b),d,t[h],e)}else for(let h=0;h<t.length;h++)l.push(...yn(0),d,t[h],e);const p=a&&o?(t.length-1)*o:0;for(let h=0;h<t.length;h++){const b=h===0?s+p:0;l.push(...yn(b),m,t[h],0)}return l.push(0,255,47,0),l}function Xn(t){const{notes:n,lhNotes:e,octave:s=4,lhOctave:r,durationTicks:i=960,velocity:a=90,tempo:o=120,arpeggiated:l=!1,arpDelayTicks:d=120}=t,m=480,f=Math.round(6e7/o);if(e&&e.length>0){const y=r??3,_=s,S=new Set(e),M=n.filter(I=>!S.has(I)),w=e.map(I=>ar(I,y)).filter(I=>I!=null),T=M.map(I=>ar(I,_)).filter(I=>I!=null);if(w.length===0&&T.length===0)return new Uint8Array(0);const P=[];w.length>0&&P.push(lr(w,0,a,i,"L.H.",{microsecondsPerBeat:f},l,d)),T.length>0&&P.push(lr(T,1,a,i,"R.H.",P.length===0?{microsecondsPerBeat:f}:void 0,l,d));const z=[77,84,104,100,...vn(6),..._e(1),..._e(P.length),..._e(m)];let E=z.length;const L=[];for(const I of P){const u=[77,84,114,107,...vn(I.length),...I];L.push(u),E+=u.length}const V=new Uint8Array(E);let k=0;V.set(z,k),k+=z.length;for(const I of L)V.set(I,k),k+=I.length;return V}const p=n.map(y=>ar(y,s)).filter(y=>y!=null);if(p.length===0)return new Uint8Array(0);const h=lr(p,0,a,i,"Chord",{microsecondsPerBeat:f},l,d),b=[77,84,104,100,...vn(6),..._e(0),..._e(1),..._e(m)],g=[77,84,114,107,...vn(h.length)],v=new Uint8Array(b.length+g.length+h.length);return v.set(b,0),v.set(g,b.length),v.set(h,b.length+g.length),v}function qi(t,n,e=4,s,r){const i=Xn({notes:t,octave:e,lhNotes:s,lhOctave:r});if(i.length===0)return;const a=new Blob([i.buffer],{type:"audio/midi"}),o=URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=`${n.replace(/[^a-zA-Z0-9\-_ ]/g,"_").slice(0,100)}.mid`,l.click(),URL.revokeObjectURL(o)}const Qi="1.1.0";function Xi(t,n){if(!n.enabled||!n.endpoint)return;const e={logSchema:Qi,...t,versions:n.versions??{},timestamp:new Date().toISOString()};try{fetch(n.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{})}catch{}}function lc(t){const n=t.match(/^(\d+)(.*)/);return n?{degree:parseInt(n[1],10),quality:n[2]}:{degree:0,quality:""}}const cc=["","I","II","III","IV","V","VI","VII"],hc={9:"IX",10:"X",11:"XI",12:"XII",13:"XIII"};function uc(t){const n=t>7?t-7:t;return n===1||n===4||n===5?"P":"M"}function dc(t){const{degree:n,quality:e}=lc(t);if(n===0)return"?";const s=n<=7?cc[n]??String(n):hc[n]??String(n),r=uc(n);return e===r?s:e==="m"||e==="d"?`b${s}`:e==="A"?`#${s}`:e==="dd"?`bb${s}`:s}function Fs(t){return t.map(dc)}const fc={"natural minor":"minor","minor harmonic":"harmonic minor","minor melodic":"melodic minor","major pentatonic":"major pentatonic","minor pentatonic":"minor pentatonic","whole tone":"whole tone",bebop:"bebop major"};function mc(t,n,e,s=1){let r=n;n==="melodic minor"&&e==="descending"&&(r="minor");const i=fc[r]??r,a=Ml(`${t} ${i}`);if(a.empty)throw new Error(`Unknown scale: "${t} ${n}"`);const o=a.notes,l=a.intervals,d=[];for(let m=0;m<s;m++)d.push(...o);return d.push(o[0]),{notes:d,root:t,type:n,intervals:l}}const Ds={C:"#e81c1c","C#":"#d44a1a",D:"#f09819","D#":"#c8b816",E:"#f5e616",F:"#59b816","F#":"#16a085",G:"#16a3b8","G#":"#1670b8",A:"#5b16b8","A#":"#8b16b8",B:"#b816a0"},pc={name:"boomwhacker",whiteKey:(t,n)=>n?Ds[t]??oe:oe,blackKey:(t,n)=>n?Ds[t]??ae:ae},Ls={C:{hex:"#f86e6e",cmyk:[0,56,56,3]},"C#":{hex:"#f58841",cmyk:[0,44,73,4]},D:{hex:"#ffbc57",cmyk:[0,26,66,0]},"D#":{hex:"#b8a334",cmyk:[0,11,72,28]},E:{hex:"#fff56d",cmyk:[0,4,57,0]},F:{hex:"#b3f888",cmyk:[28,0,45,3]},"F#":{hex:"#93d154",cmyk:[30,0,60,18]},G:{hex:"#6bc6a0",cmyk:[46,0,19,22]},"G#":{hex:"#7ee8df",cmyk:[46,0,4,9]},A:{hex:"#88a7f8",cmyk:[45,33,0,3]},"A#":{hex:"#cc97e8",cmyk:[12,35,0,9]},B:{hex:"#e277b1",cmyk:[0,47,22,11]}},gc={name:"crf",whiteKey:(t,n)=>{var e;return n?((e=Ls[t])==null?void 0:e.hex)??oe:oe},blackKey:(t,n)=>{var e;return n?((e=Ls[t])==null?void 0:e.hex)??ae:ae}},bc="#a0c6e8",yc="#5a8ab5";function xr(t){const n=t??bc,e=t??yc;return{name:"simple",whiteKey:(s,r)=>r?n:oe,blackKey:(s,r)=>r?e:ae}}const Ji={boomwhacker:pc,crf:gc,simple:xr()};function vc(t){return Ji[t]}function to(t,n){if(!(!t&&!n))return!t&&n?xr(n):typeof t=="string"?t==="simple"&&n?xr(n):Ji[t]:t}function _c(t,n,e,s){const r=[],i=[];for(let a=0;a<t.length;a++){const o=t[a],l=n[a],d=o.isBlack?zn:re,m=`<rect x="${o.x}" y="${o.y}" width="${o.width}" height="${o.height}" rx="${d}" ry="${d}" fill="${l}" stroke="${ci}" stroke-width="${Ye}"/>`;o.isBlack?i.push(m):r.push(m)}return[`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${s}" viewBox="0 0 ${e} ${s}">`,...r,...i,"</svg>"].join(`
2
+ `)}function wc(t){const n=performance.now(),e=s=>({success:!1,chordName:"",root:"",notes:[],keyboard:{startFrom:"C",size:8,highlightKeys:[]},telemetry:{parser:"chord",resolver:{root:"",type:"",pitchClasses:[]},durationMs:performance.now()-n},errorMessage:s});try{const{input:s,format:r,logConfig:i}=t;if(!s||!s.trim())return e("No chord input provided");const a=Vn(s);if(!a.chordName)return e("Could not extract a chord name from the input");const o=mn(a.chordName,a.inversion),l=o.notes,d=l.map(At),m=a.format??"compact",f=Kn(d,{padding:a.padding,startingNote:a.startingNote,spanFrom:a.spanFrom,spanTo:a.spanTo}),p=ln(f.startFrom,f.size,m),h=4,b=[],g=[],v=28;let y=-1,_=h+f.chordOctave;const S=[];for(let T=0;T<l.length;T++){const P=l[T],z=d[T],E=mr[P];E!==void 0&&(y!==-1&&E<=y&&_++,y=E,S.push({pc:P,kpc:z,semitone:E,octave:_}))}if(S.length>1){const T=S[0].semitone+S[0].octave*12;for(let P=1;P<S.length;P++)S[P].semitone+S[P].octave*12-T>v&&S[P].octave>S[0].octave&&S[P].octave--}for(const T of S){g.push(`${T.pc}${T.octave}`);const P=T.octave-h;b.push(`${T.kpc}:${P}`)}const M=Nr(p,b),w={success:!0,chordName:a.chordName,root:o.root,notes:g,inversion:a.inversion,keyboard:{startFrom:f.startFrom,size:f.size,highlightKeys:b},telemetry:{parser:"chord",resolver:{root:o.root,type:o.type,pitchClasses:l},durationMs:performance.now()-n}};if(r==="svg"){const T=Ir(f.size,m);w.svg=_c(p,M,T.width,T.height)}if(r==="midi"&&(w.midi=Xn({notes:l})),i){const T={input:s,pipeline:{parser:"chord",parsed:{chordName:a.chordName,inversion:a.inversion,allInversions:a.allInversions,startingNote:a.startingNote,startingDegree:a.startingDegree,bassNote:a.bassNote,bassDegree:a.bassDegree,spanFrom:a.spanFrom,spanTo:a.spanTo,padding:a.padding,chordOctaveShift:a.chordOctaveShift,bassOctaveShift:a.bassOctaveShift,styleHint:a.styleHint,format:a.format,showNoteNames:a.showNoteNames,fingering:a.fingering,autoFingering:a.autoFingering},resolver:{method:"tonal",type:o.type,root:o.root,pitchClasses:l},voicing:{attempted:!1,found:!1},layout:{startFrom:f.startFrom,size:f.size,chordOctave:f.chordOctave},output:{notes:g,highlightKeys:b,format:r}},success:!0,durationMs:performance.now()-n};Xi(T,i)}return w}catch(s){const r=s instanceof Error?s.message:String(s);return e(r)}}const eo={display:"keyboard",format:"compact",theme:"simple",highlightColor:"#a0c6e8",padding:1,scale:.5,glyphs:"bravura",showNoteNames:!1,noteNameSize:"base",noteNameMode:"pitch-class",showFingering:!1,fingeringSize:"base"};function no(t,n,e){return{...eo,...t?cr(t):{},...n?cr(n):{},...e?cr(e):{}}}function cr(t){const n={...t};for(const e of Object.keys(n))n[e]===void 0&&delete n[e];return n}function ro(t,n,e,s){const r=n+1;return e<=1?String(r):`${s??String.fromCharCode(65+t)}${r}`}const Fn="1.0";function so(t){if(!t||typeof t!="string")throw new Error("Missing or invalid schema version");const[n]=t.split("."),[e]=Fn.split(".");if(n!==e)throw new Error(`Incompatible schema version "${t}" (current: "${Fn}"). Major version mismatch — this sheet was created with a newer or older format.`)}const Je="bcs1.";async function xc(t,n){const e=JSON.stringify({...t,v:t.v??Fn}),s=new TextEncoder().encode(e);if(!(n!=null&&n.skipCompression)&&typeof CompressionStream<"u")try{const r=await kc(s);return Je+Hs(r)}catch{}return Je+Hs(s)}async function Ac(t,n){if(!t.startsWith(Je))throw new Error(`Invalid token: must start with "${Je}"`);const e=t.slice(Je.length),s=Sc(e);let r;if(typeof DecompressionStream<"u")try{const a=await Mc(s);r=new TextDecoder().decode(a)}catch{r=new TextDecoder().decode(s)}else r=new TextDecoder().decode(s);let i;try{i=JSON.parse(r)}catch{throw new Error("Invalid token: could not parse payload as JSON")}return so(i.v),i}function Hs(t){let n="";for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Sc(t){const n=t.replace(/-/g,"+").replace(/_/g,"/"),e=atob(n),s=new Uint8Array(e.length);for(let r=0;r<e.length;r++)s[r]=e.charCodeAt(r);return s}async function kc(t){const n=new CompressionStream("deflate"),e=n.writable.getWriter();e.write(t),e.close();const s=n.readable.getReader(),r=[];for(;;){const{done:i,value:a}=await s.read();if(i)break;r.push(a)}return io(r)}async function Mc(t){const n=new DecompressionStream("deflate"),e=n.writable.getWriter(),s=e.write(t).then(()=>e.close()).catch(()=>{}),r=n.readable.getReader(),i=[];try{for(;;){const{done:a,value:o}=await r.read();if(a)break;i.push(o)}}catch(a){throw await s,a}return await s,io(i)}function io(t){const n=t.reduce((r,i)=>r+i.length,0),e=new Uint8Array(n);let s=0;for(const r of t)e.set(r,s),s+=r.length;return e}const oo=!1,ao=120;function lo(t=ao){return 6e4/(t*4)}const co={text:"#1a1a1a",textMuted:"#555",textSubtle:"#777",border:"#ccc",btnBg:"#e8e8e8",btnBgActive:"#333",btnText:"#333",btnTextActive:"#fff",inputBg:"#fff",inputText:"#333",iconFill:"#fff",playbackBg:"rgba(100, 100, 115, 0.6)",playbackActive:"rgba(74, 144, 217, 0.85)",playbackTrayBg:"rgba(200, 210, 225, 0.5)",playbackTrayBorder:"rgba(255, 255, 255, 0.7)",playbackBtnBorder:"rgba(255, 255, 255, 0.45)",bracketColor:"#888",whiteFill:"#fafafa",blackFill:"#222222",keyStroke:"#333333"},ho={text:"#eee",textMuted:"#aaa",textSubtle:"#888",border:"#555",btnBg:"rgba(255, 255, 255, 0.08)",btnBgActive:"rgba(57, 51, 51, 0.89)",btnText:"#aab2c0",btnTextActive:"#eef0f4",inputBg:"#1e1e2e",inputText:"#eee",iconFill:"#fff",playbackBg:"rgba(70, 70, 90, 0.7)",playbackActive:"rgba(74, 144, 217, 0.85)",playbackTrayBg:"rgba(50, 55, 75, 0.65)",playbackTrayBorder:"rgba(255, 255, 255, 0.18)",playbackBtnBorder:"rgba(255, 255, 255, 0.12)",bracketColor:"#999",whiteFill:"#fafafa",blackFill:"#222222",keyStroke:"#333333"},Dn="light";function Dr(t){return t==="dark"?ho:co}let hr=null,Be=null,je=null;function Lr(){return hr||(hr=new AudioContext),hr}async function uo(){if(Be)return Be;if(je)return await je,Be;const{Soundfont:t}=await Promise.resolve().then(()=>Ih),n=Lr(),e=new t(n,{instrument:"acoustic_grand_piano"});je=e.load.then(()=>{});try{await je,Be=e}catch{throw je=null,new Error("Failed to load piano soundfont")}return Be}const Pc={C:0,"C#":1,Db:1,D:2,"D#":3,Eb:3,E:4,Fb:4,"E#":5,F:5,"F#":6,Gb:6,G:7,"G#":8,Ab:8,A:9,"A#":10,Bb:10,B:11,Cb:11,"B#":0};function Pe(t,n=4){let e=n,s=-1;return t.map(r=>{if(/[0-9]$/.test(r))return r;const i=Pc[r];return i==null?`${r}${e}`:(s>=0&&i<=s&&e++,s=i,`${r}${e}`)})}async function fo(t,n=4,e=1.5){const s=await uo(),r=Lr();r.state==="suspended"&&await r.resume();const i=Pe(t,n),a=r.currentTime;for(const o of i)s.start({note:o,time:a,duration:e})}async function mo(t,n=4,e=100,s=1.5){const r=await uo(),i=Lr();i.state==="suspended"&&await i.resume();const a=Pe(t,n),o=i.currentTime;for(let l=0;l<a.length;l++)r.start({note:a[l],time:o+l*e/1e3,duration:s})}const _n="http://www.w3.org/2000/svg";function po(t){return t.replace(/[^a-zA-Z0-9\-_ ]/g,"_").slice(0,100)}function Cc(t,n){const e=t.getAttribute("data-annotations");if(!e)return;t.removeAttribute("data-annotations");let s;try{s=JSON.parse(e)}catch{return}const{items:r,fontSize:i,fingerFontSize:a,hasStagger:o,staggerHeight:l,textColor:d,mutedColor:m,keyboardHeight:f,controlsHeight:p}=s;if(!r||r.length===0)return;const h=i+3,b=o?l:0,v=r.some(P=>P.degree)?i*.85+3:0,_=r.some(P=>P.finger)?a+3:0,S=b+h+v+_+4,M=s.heading?i*1.4+4:0,w=n.height+S+M;if(t.setAttribute("viewBox",`${n.x} ${n.y-M} ${n.width} ${w}`),s.heading){const P=document.createElementNS(_n,"text");P.setAttribute("x",String(n.x+n.width/2)),P.setAttribute("y",String(n.y-4)),P.setAttribute("text-anchor","middle"),P.setAttribute("font-size",String(i*1.2)),P.setAttribute("font-weight","600"),P.setAttribute("fill",d),P.setAttribute("font-family","system-ui, sans-serif"),P.textContent=s.heading,t.appendChild(P)}const T=n.y+n.height+2;for(const P of r){const z=P.x;let E=T;if(P.note){const L=o&&!P.isAccidental?b:0,V=document.createElementNS(_n,"text");V.setAttribute("x",String(z)),V.setAttribute("y",String(E+i+L)),V.setAttribute("text-anchor","middle"),V.setAttribute("font-size",String(i)),V.setAttribute("font-weight","600"),V.setAttribute("fill",d),V.setAttribute("font-family","system-ui, sans-serif"),V.textContent=P.note,t.appendChild(V)}if(P.degree){const L=i*.85,V=document.createElementNS(_n,"text");V.setAttribute("x",String(z)),V.setAttribute("y",String(E+b+h+L)),V.setAttribute("text-anchor","middle"),V.setAttribute("font-size",String(L)),V.setAttribute("font-weight","500"),V.setAttribute("fill",m),V.setAttribute("font-family","system-ui, sans-serif"),V.textContent=P.degree,t.appendChild(V)}if(P.finger){const L=document.createElementNS(_n,"text");L.setAttribute("x",String(z)),L.setAttribute("y",String(E+b+h+v+a)),L.setAttribute("text-anchor","middle"),L.setAttribute("font-size",String(a)),L.setAttribute("font-weight","500"),L.setAttribute("fill",m),L.setAttribute("font-family","system-ui, sans-serif"),L.textContent=P.finger,t.appendChild(L)}}}function Jn(t){const n=t.cloneNode(!0),e=n.querySelector("[data-controls]");let s=0;e&&(s=30,e.remove());const r=t.viewBox.baseVal;n.setAttribute("viewBox",`${r.x} ${s} ${r.width} ${r.height-s}`);const i={x:r.x,y:s,width:r.width,height:r.height-s};return Cc(n,i),{clone:n,offsetY:s}}function go(t,n){const{clone:e}=Jn(t),s=new XMLSerializer().serializeToString(e),r=new Blob([s],{type:"image/svg+xml;charset=utf-8"}),i=URL.createObjectURL(r),a=document.createElement("a");a.href=i,a.download=`${po(n)}.svg`,a.click(),setTimeout(()=>URL.revokeObjectURL(i),1e3)}function bo(t,n,e=2){const{clone:s}=Jn(t),r=s.viewBox.baseVal,i=r.width,a=r.height;s.setAttribute("width",String(i)),s.setAttribute("height",String(a));const o=new XMLSerializer().serializeToString(s),l=new Blob([o],{type:"image/svg+xml;charset=utf-8"}),d=URL.createObjectURL(l),m=new Image;m.onload=()=>{const f=document.createElement("canvas");f.width=i*e,f.height=a*e;const p=f.getContext("2d");if(!p){URL.revokeObjectURL(d),console.error("PNG export: could not get canvas 2d context");return}p.scale(e,e),p.drawImage(m,0,0,i,a),URL.revokeObjectURL(d),f.toBlob(h=>{if(!h){console.error("PNG export: canvas.toBlob returned null");return}const b=URL.createObjectURL(h),g=document.createElement("a");g.href=b,g.download=`${po(n)}.png`,g.click(),setTimeout(()=>URL.revokeObjectURL(b),1e3)},"image/png")},m.onerror=()=>{URL.revokeObjectURL(d),console.error("PNG export: failed to load SVG as image")},m.src=d}const Ec=["C","C#/Db","D","D#/Eb","E","F","F#/Gb","G","G#/Ab","A","Bb","B"];function Us(t){return t%12}function Ic(t){return Math.floor(t/12)-1}function Nc(t){return Ec[t%12]}function Tc(t,n){const e=t.map(o=>vt(o)).filter(o=>o!=null);if(e.length===0)return"";const s=Dt(n||t[0]),r=Math.min(...e.map(Us)),i=e.map((o,l)=>({name:Nc(o),col:1,row:Us(o),octave:Ic(o),isRoot:Dt(t[l])===s,sustainCells:0})),a={_type:"play-grid-clip",label:`${i.length} notes (${i.map(o=>o.name.split("/")[0]).join(", ")})`,timestamp:Date.now(),data:{notes:i,lines:[],originCol:1,originRow:r}};return JSON.stringify(a)}async function Rc(t,n){const e=Tc(t,n);if(!e)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}const yo=ft.createContext({mode:Dn,tokens:Dr(Dn)}),Bt=yo.Provider;function pn(){return ft.useContext(yo)}function gn(t){const n=t??Dn;return{mode:n,tokens:Dr(n)}}const Ws=16,_t=22,ze=4,wn=10;function vo({notes:t,lhNotes:n,rhOctave:e,lhOctave:s,chordName:r,x:i,y:a}){const{tokens:o}=pn(),[l,d]=ft.useState(null),m=(n==null?void 0:n.length)??0,f=s??2,p=e??3,h=t.map(u=>u.replace(/:.*$/,"")),b=(()=>{if(m>0){const u=h.slice(0,m),j=h.slice(m);return[...Pe(u,f),...Pe(j,p)]}return Pe(h,p)})(),g=ft.useCallback(async()=>{if(!l){d("block");try{await fo(b),setTimeout(()=>d(null),1500)}catch{d(null)}}},[b,l]),v=ft.useCallback(async()=>{if(!l){d("arp");try{await mo(b,4,lo()),setTimeout(()=>d(null),1500)}catch{d(null)}}},[b,l]),y=ft.useCallback(()=>{qi(t,r,p,n,f)},[t,r,p,n,f]),_=ft.useCallback(u=>u.currentTarget.closest("svg"),[]),S=ft.useCallback(u=>{const j=_(u);j&&go(j,r)},[r,_]),M=ft.useCallback(u=>{const j=_(u);j&&bo(j,r)},[r,_]),[w,T]=ft.useState(!1),P=ft.useCallback(async()=>{const u=h[0];await Rc(b,u)&&(T(!0),setTimeout(()=>T(!1),1500))},[b,h]),z={cursor:"pointer",opacity:l?.5:1},E=2*_t+ze,L=(u,j,X,G,st,H,Q=!1)=>N.jsxs("g",{transform:`translate(${u}, ${a})`,onClick:X,style:st,role:"button","aria-label":G,children:[N.jsx("rect",{width:_t,height:_t,rx:5,fill:j,stroke:o.playbackBtnBorder,strokeWidth:.5}),N.jsx("rect",{width:_t,height:_t,rx:5,fill:`url(#${Q?I:k})`}),N.jsx("line",{x1:6,y1:1.5,x2:_t-6,y2:1.5,stroke:"rgba(255,255,255,0.18)",strokeWidth:.5,strokeLinecap:"round"}),H]}),V=`translate(${(_t-Ws)/2}, ${(_t-Ws)/2})`,k=`btn-glass-${i}-${a}`,I=`btn-glass-active-${i}-${a}`;return N.jsxs("g",{className:"bc-playback-controls",children:[N.jsxs("defs",{children:[N.jsxs("linearGradient",{id:k,x1:"0",y1:"0",x2:"0",y2:"1",children:[N.jsx("stop",{offset:"0%",stopColor:"rgba(255,255,255,0.12)"}),N.jsx("stop",{offset:"50%",stopColor:"rgba(255,255,255,0.02)"}),N.jsx("stop",{offset:"100%",stopColor:"rgba(0,0,0,0.06)"})]}),N.jsxs("linearGradient",{id:I,x1:"0",y1:"0",x2:"0",y2:"1",children:[N.jsx("stop",{offset:"0%",stopColor:"rgba(255,255,255,0.15)"}),N.jsx("stop",{offset:"50%",stopColor:"rgba(255,255,255,0.03)"}),N.jsx("stop",{offset:"100%",stopColor:"rgba(0,0,0,0.08)"})]})]}),L(i,l==="block"?o.playbackActive:o.playbackBg,g,"Play block chord",z,N.jsxs("g",{transform:V,children:[N.jsx("polygon",{points:"2,5 5,5 9,2 9,14 5,11 2,11",fill:o.iconFill}),N.jsx("path",{d:"M11,5.5 C12.5,6.5 12.5,9.5 11,10.5",stroke:o.iconFill,strokeWidth:"1.5",fill:"none",strokeLinecap:"round"}),N.jsx("path",{d:"M12.5,3.5 C15,5.5 15,10.5 12.5,12.5",stroke:o.iconFill,strokeWidth:"1.2",fill:"none",strokeLinecap:"round"})]}),l==="block"),L(i+_t+ze,l==="arp"?o.playbackActive:o.playbackBg,v,"Play arpeggiated",z,N.jsxs("g",{transform:V,children:[N.jsx("path",{d:"M8,14 C6,11 10,9 8,7 C6,5 10,3 8,1",stroke:o.iconFill,strokeWidth:"1.8",fill:"none",strokeLinecap:"round"}),N.jsx("polygon",{points:"5,3 8,0 11,3",fill:o.iconFill})]}),l==="arp"),L(i+E+wn,o.playbackBg,y,"Download MIDI file",{cursor:"pointer"},N.jsx("text",{x:_t/2,y:_t/2+3,textAnchor:"middle",fontSize:6,fontWeight:"bold",fill:o.iconFill,fontFamily:"system-ui, sans-serif",children:"MIDI"})),L(i+E+wn+_t+ze,o.playbackBg,S,"Download SVG",{cursor:"pointer"},N.jsx("text",{x:_t/2,y:_t/2+3,textAnchor:"middle",fontSize:7,fontWeight:"bold",fill:o.iconFill,fontFamily:"system-ui, sans-serif",children:"SVG"})),L(i+E+wn+2*(_t+ze),o.playbackBg,M,"Download PNG",{cursor:"pointer"},N.jsx("text",{x:_t/2,y:_t/2+3,textAnchor:"middle",fontSize:7,fontWeight:"bold",fill:o.iconFill,fontFamily:"system-ui, sans-serif",children:"PNG"})),L(i+E+wn+3*(_t+ze),w?o.playbackActive:o.playbackBg,P,"Copy chord for dottl.app",{cursor:"pointer"},w?N.jsx("text",{x:_t/2,y:_t/2+3,textAnchor:"middle",fontSize:6,fontWeight:"bold",fill:o.iconFill,fontFamily:"system-ui, sans-serif",children:"OK!"}):N.jsxs("g",{transform:`translate(${_t/2-6}, ${_t/2-6.5})`,children:[N.jsx("path",{d:"M2,1 L2,12 L6.5,12 C10,12 12,9.5 12,6.5 C12,3.5 10,1 6.5,1 Z M4,3 L6,3 C8.5,3 10,4.5 10,6.5 C10,8.5 8.5,10 6,10 L4,10 Z",fill:o.iconFill}),N.jsx("circle",{cx:"6",cy:"5",r:"0.9",fill:"#22c55e"}),N.jsx("circle",{cx:"8",cy:"5",r:"0.9",fill:"#3b82f6"}),N.jsx("circle",{cx:"6",cy:"7",r:"0.9",fill:"#f59e0b"}),N.jsx("circle",{cx:"8",cy:"7",r:"0.9",fill:"#a855f7"}),N.jsx("circle",{cx:"6",cy:"9",r:"0.9",fill:"#ef4444"}),N.jsx("circle",{cx:"8",cy:"9",r:"0.9",fill:"#06b6d4"})]}))]})}function Oc(t,n,e,s){if(n.keyIndices.length===0)return null;const r=n.keyIndices.map(f=>t[f]).filter(Boolean);if(r.length===0)return null;const i=r.reduce((f,p)=>f.x<p.x?f:p),a=r.reduce((f,p)=>f.x+f.width>p.x+p.width?f:p),o=i.x+(i.isBlack?0:2),l=a.x+a.width-(a.isBlack?0:2),d=(o+l)/2,m=4;return N.jsxs("g",{children:[N.jsx("line",{x1:o,y1:e,x2:l,y2:e,stroke:s,strokeWidth:1.5}),N.jsx("line",{x1:o,y1:e-m,x2:o,y2:e,stroke:s,strokeWidth:1.5}),N.jsx("line",{x1:l,y1:e-m,x2:l,y2:e,stroke:s,strokeWidth:1.5}),N.jsx("text",{x:d,y:e+11,textAnchor:"middle",fontSize:10,fontWeight:500,fill:s,fontFamily:"system-ui, sans-serif",children:n.label})]},n.label)}const Bc={base:1,lg:1.25,xl:1.5,"2xl":1.875};function Gs(t="base"){return Math.min(pe*.48,11)*Bc[t]}function jc(t,n,e,s="pitch-class",r=4){const i=[],a=n.map((o,l)=>{const d=o.indexOf(":");return{note:At(d!==-1?o.slice(0,d):o),idx:l,matched:!1}});for(const o of t){const l=At(o.note),d=a.findIndex(m=>{if(m.matched||m.note!==l)return!1;const f=n[m.idx];return!(f.includes(":")&&parseInt(f.split(":")[1],10)!==o.octave)});if(d!==-1){a[d].matched=!0;let m=(e==null?void 0:e[a[d].idx])??a[d].note;s==="midi"&&(m=`${m}${r+o.octave}`),i.push({x:o.x,width:o.isBlack?Er:pe,note:m,index:a[d].idx})}}return i}function me({format:t="compact",size:n=8,startFrom:e="C",highlightKeys:s=[],allNotes:r,lhNotes:i,rhOctave:a,lhOctave:o,theme:l,highlightColor:d,showPlayback:m=!0,chordLabel:f,showHeading:p,handBrackets:h,scale:b=.5,showNoteNames:g,displayNoteNames:v,noteNameSize:y="base",noteNameMode:_="pitch-class",midiBaseOctave:S=4,fingering:M,fingeringSize:w="base",degreeLabels:T,clipLeft:P=!1,clipRight:z=!1,uiTheme:E,className:L,style:V}){const k=pn(),I=E?gn(E):k,u=I.tokens,j=ln(e,n,t),X=to(l,d),st=Nr(j,s,X).map((ot,mt)=>ot===oe?u.whiteFill:ot===ae&&j[mt].isBlack?u.blackFill:ot),H=u.keyStroke,{width:Q,height:B}=Ir(n,t),R=pe/2,J=P?R:0,tt=n*pe,pt=(z?tt-R:Q)-J,wt=m&&s.length>0,ht=h&&h.length>0,ut=wt?30:0,yt=ht?24:0,q=g??oo,et=_==="degree",it=_==="pitch-class+degree",c=q&&s.length>0&&!et,D=q&&s.length>0&&(et||it)&&T&&T.length>0,F=M&&M.length>0,A=c||F||D,x=B+ut+yt,C=ut,U=j.map((ot,mt)=>({key:ot,fill:st[mt],index:mt})).filter(({key:ot})=>!ot.isBlack),$=j.map((ot,mt)=>({key:ot,fill:st[mt],index:mt})).filter(({key:ot})=>ot.isBlack),O=J+pt-172,nt=N.jsxs("svg",{viewBox:`${J} 0 ${pt} ${x}`,xmlns:"http://www.w3.org/2000/svg",className:`bc-keyboard ${L??""}`.trim(),style:{width:"100%",display:"block",...V},role:"img","aria-label":"Piano keyboard",children:[wt&&N.jsx("g",{"data-controls":"",children:N.jsx(vo,{notes:r??s,lhNotes:i,rhOctave:a,lhOctave:o,chordName:f??s.join("-"),x:O,y:4})}),(P||z)&&U.length>0&&N.jsx("defs",{children:N.jsx("clipPath",{id:`kb-clip-${J}-${C}`,children:N.jsx("rect",{x:J,y:0,width:pt,height:U[0].key.height,rx:re,ry:re})})}),N.jsxs("g",{transform:`translate(0, ${C})`,children:[N.jsxs("g",{clipPath:(P||z)&&U.length>0?`url(#kb-clip-${J}-${C})`:void 0,children:[U.map(({key:ot,fill:mt,index:St})=>N.jsx("rect",{x:ot.x,y:ot.y,width:ot.width,height:ot.height,rx:re,ry:re,fill:mt,stroke:H,strokeWidth:Ye},`white-${St}`)),$.map(({key:ot,fill:mt,index:St})=>N.jsx("rect",{x:ot.x,y:ot.y,width:ot.width,height:ot.height,rx:zn,ry:zn,fill:mt,stroke:H,strokeWidth:Ye},`black-${St}`))]}),(P||z)&&U.length>0&&N.jsx("rect",{x:J,y:0,width:pt,height:U[0].key.height,rx:re,ry:re,fill:"none",stroke:H,strokeWidth:Ye})]}),ht&&N.jsx("g",{transform:`translate(0, ${C+B+6})`,children:h.map(ot=>Oc(j,ot,0,u.bracketColor))})]}),Y=A?jc(j,s,et?T:v,et?"pitch-class":_,S):[],rt=Gs(y),dt=Gs(w),ct=ot=>/[#b]/.test(ot.slice(1)),xt=Y.some(ot=>ct(ot.note)),Et=xt?rt*1.3:0,kt=A&&Y.length>0?JSON.stringify({heading:p?f:void 0,items:Y.map(ot=>({x:ot.x+ot.width/2,note:c||et&&D?ot.note:void 0,degree:it&&D?T==null?void 0:T[ot.index]:void 0,finger:F?(()=>{const mt=M==null?void 0:M[ot.index];if(mt!=null)return typeof mt=="number"&&(mt<0||mt>5)?"?":String(mt)})():void 0,isAccidental:ct(ot.note)})),fontSize:rt,fingerFontSize:dt,hasStagger:xt,staggerHeight:Et,textColor:u.text,mutedColor:u.textMuted,keyboardHeight:x-ut,controlsHeight:ut}):void 0,Rt=ot=>{if(!ot)return;const mt=ot.querySelector("svg.bc-keyboard");mt&&(kt?mt.setAttribute("data-annotations",kt):mt.removeAttribute("data-annotations"))},bt=N.jsxs("div",{className:"bc-keyboard-container",ref:Rt,style:{width:"100%",maxWidth:pt*b*2},children:[p&&f&&N.jsx("div",{className:"bc-keyboard-heading",style:{textAlign:"center",fontSize:14,fontWeight:600,color:u.text,fontFamily:"system-ui, sans-serif",marginBottom:4},children:f}),nt,A&&Y.length>0&&N.jsx("div",{className:"bc-annotations",style:{position:"relative",width:"100%",marginTop:2,minHeight:Et+rt*1.3+(F?dt*1.3:0)},children:Y.map((ot,mt)=>{const St=(ot.x+ot.width/2-J)/pt*100,Lt=c||et&&D,ce=it&&D,Vt=F,Jt=T==null?void 0:T[ot.index],It=M==null?void 0:M[ot.index],Ct=It==null?null:typeof It=="number"&&(It<0||It>5)?"?":It,Mt=xt&&!ct(ot.note)?Et:0;return N.jsxs("div",{className:"bc-annotation-cell",style:{position:"absolute",left:`${St}%`,transform:"translateX(-50%)",top:Mt,display:"flex",flexDirection:"column",alignItems:"center",gap:0,whiteSpace:"nowrap",lineHeight:1.2},children:[Lt&&N.jsx("span",{className:"bc-note-name",style:{fontSize:rt,fontWeight:600,color:u.text,fontFamily:"system-ui, sans-serif"},children:ot.note}),ce&&Jt&&N.jsx("span",{className:"bc-degree-label",style:{fontSize:rt*.85,fontWeight:500,color:u.textMuted,fontFamily:"system-ui, sans-serif"},children:Jt}),Vt&&Ct!=null&&N.jsx("span",{className:"bc-fingering",style:{fontSize:dt,fontWeight:500,color:u.textMuted,fontFamily:"system-ui, sans-serif"},children:Ct})]},`ann-${mt}`)})})]});return E?N.jsx(Bt,{value:I,children:bt}):bt}const zc="d09GMgABAAAAAA30AAoAAAAALWQAAA2rAAFkWgAAAAAAAAAAAAAAAAAAAAAAAAAABmAATAqPaIwIATYCJAMcCxAABCAFxloHIBvDKjOjwsYBQCFviKjcZCKqNq3iv0jgzbCuHG0G7jgEcpAOwSlKQKcZC7qsQ4jQd/W/Bz9G4rk+PJ75/k9+mrNzVHpiDuC2Tu5uUgeKDYDJtSEhc18D1TxxlLbVrb4aprpjax71xXxmwggh73+basctl9Pv2MraJ2zkmBcMZiXpUYgPqNGqJHB9PPZqTW2AbIQKj4+QcZHyfv95A1i6lDAs+68KKCSwq6yrAyBVIcsSyLkqWSHrZF3912XvY6fiUQAKADAsOu+uj7JXRxa3RiO+6c3j8ZaGk07TCQuAYTwwCkW/PHQzolghMOvUNlFof3/tUkIROeQQCSIS8uMc4MlOMhEMoKNpNYC81eJIY8hY1gWZY9uygvIspDwsftxMdfdnAjQkunGAAACxIncACQIACoADYA0OBIA1eMQAMIQICvqw+GGzh4sfN9PrgR2d5ivcNrktdGvq2iCI7SrgaqYAzAC6FeDMAAAAH2U40LFET9YzFwditI3dscfCP8ywOqcTEj452G7XRY3V6MQ2nt8vBq5iMgqtfL/fL8A/jPOCzqmMaoSG+z0e9/0sj6DO5YVKxYflcn9brcLC1QrvCCFqZEboHZsN+f9C2Q4bkrhUMid1/ElvaUVLRISQQYxm2eXy+6vVTozK0DiPI6imypfLnlapDGjlsCqMCuVQo3Y6ZLOYTI5jrL5Q7WYzLFerQ+eJ6Jd/Q622Gzgo881ymUK2EjpWI22xID/8A5+ytEKD7kTwHpBjafvAZgglaUHnbNGIZn6kKbI6NhX8Xq+BPpth8lhE5v3+80l5Id1td7nA4BOBTfksb10tA3W/8caFSiUnjYanlst95IeCODE5lQhxDmA3gH9uEFqqPXur2TxnCuAXK78hiCh6rEnsZIs1hbQMeEBTY8jArBmrDEhmU3S7Z3LFp1HHAVzEg1xrcQID0TEkCKazE1thoTDwAJ5Owdkki+tUIsIBSh1HM5wQUzLAPF6MqBwsevICoZxC2CcbRtJU2JKvEP37QWfwihn3nC9SS3VpXkRjdWPSoBgbvdv0Xg8WhoR87GRTZlOGoqD4vCI7nhuurarW1mj5aSNqmtc028FbWpg/7iJJ4pSePXmuXWEh1cbEGLLmDfywqAzDgHFjL0obN4ZZdxvaiWtI81F8WV/jMXN0dh4WU/Jdz55FOZolZySnd6aSrBinL3TgeJGWRqZFKk/S3cMMPFV29rS7n+KX+rHDyiBPyyOKXVkLpCDt3dvwki5NBcHDgzFFLvmXEEQN56+7u1kKV4X727lbLNp06aHZUJKfnJdM2joZOsRnHgwrCmwpSaoaV3tLS931OXOJYjZk6NKhkiTiDxvEJ2QkZiI/6dXrQx/PTk1xeo+P9eQlBoZeXiKmT8unhcQrwzOjJ85phmqGbNA0V6sF5uGpEocerJoxYdxefIQhOQXZBYNJrxLt+/cqVR7Rrqrw2z4bYR/90bjRrwUGD+a4r186kV7gvthEfvqUgzaJI1u31ip+/mb2iyYN76LRihvHj/v2iJ1hbxwIo1XpPDU3R727FJQasmY3NVw5Uzb5+jSfVt6CJ4Qi1cuLmdDOtJOLWJ4mGg2fbuJJ/9DftR7VnJm5ZCyKtHOTJlLx4EnW9lOXWJfyKhtrHmO3EgIi/fqtYeYSt4KpPZgJkz0ZZ2BgTgjBsddvtGK4IkxjnjKs8lCz77yFO5c+ih6TA9/eS9EJrYPP7i1m4RKHt91TI7xYFm9hwRFCQaYMSWFpstCHybIgyjIbrLLzbTEt2ueKxsZH6MVkhUErjTCK8kktHTKFpKpdAPlyXRuaQYiMFJqL3rCjZMoU6BrItCMlwpvvi6GX91TYGEMv77CTBOYa70jWH5KUeOnxgo+PUrpkCuH1kmaxCLVBIyHWvzRgZufRYyQmuRPOxMTSnvFCYp++KSws3NLKzMzGJiwhtgAAEACkRW3J45d3mpglfBM57iWAuzFjcwHcedX92P/7zxgDM9VCABwoAIAA/1XMaKeO7V/7Pn6YaxB/gC4A6Fr9H7Jcr8djYCXwi7qool+jQkYFygGoBQfCGwAeOmDHR2DqodNT83gfh1wPeTiv6WNw9HiOAvh8/8ilsXsnhjHAfzg7OTslUAUUukU3wAY7waBGPmojzSDQw4Nq1/B9DMHeHR/vxrGPPIH9SMsh9v9BYCeyI5TY0OIs4XvCyugAGVMIHxeOzZNjH48OQOE7Cm8rV2t9n90xh8HpbSQFR+3pspPuBCBIQsTQJink1qIH/sgUR0/wKc56YWJ6ejQLg7zeyUVJyD8qLOTQFp8ad9gKEyfqa5n0Bh7h80xI1kp8TmSCaVTEC4U7+CR/z52w6D8LEOmR+Siilc1X6eP+vNo4/OALPFuaefKspskSmlhFGwqHY+OOVwIbY+sm5vZz8FtPrm0eTOFZ0mizSGmUW8PRfjCeOwSZ0WyNZA/fXRx+QPy7YDCVC6Gm+Ci8gfdZdjHqOsSPmuOYrVJQALLYSgYQAs6kff6YerQ/t878QR48QVlM1gqkYLB4DFwobs5m7IeCI5s7GGfIrkhwbn4qhR4mYV0c3xWFTgvLM86bYdJAmqk4QwTYOt6QccQGLKeMaX4FCDD2ESCNJs3ENcX2Uw8uGv3a7GY/KZyAUThbRkM6/NDZtDng5hcbYUpCbxYPvJFMm+R9qOYjwY0QP2oaE4nWjakT51mZN2/qhTEzas4860Q7hcHI2SUfseQEhIbTiLu+j3fQHo7eyCRN+3FXsC45Jp/Km2hPhG/PpZmo61rO6gExL+Ie/TaROb9DRmprJUkuwPH2TN3FVCKk5sdKNFg4TcQtvurGI6yOyKss3N3uKlc6xls9YXrOxzYuddq0VheZ0fQxmJZBa44vcUDSLAS5k9U4jXIWTjjc2FvMjzLuEZoKi7+T+JUJaBlUnwsbFpvRslFMawB9Z4hHe86SUTLAmyaE1wyfgMqUJIPko7sr0E8GydFc3QcmxqNbukqyWag9r9t3PUDUsPSRhvfiJESkVz3WSNcL6NYcLad4NzTZa2sjjfyQ7/4HfcZQXFmOu6uT9DqD8mWF/C66XHzcPMgNs3lpMzmOIqkgMcdlAyNWxWtW4Mybg6OeXHeDgRqb9c5b8bSu2ccpvB7rx7u4L/LYnBtzhwaU3wG7wMa6W0uI2DwAHekwUtOiydrvrDG45K1WEng1IaTZbZv6a39sKxyprjMDxBnLymREHsFJ4Vpk/s1VtW1oCNOYQyMdaxe8yx5zYjnhnQjMfjqVdznYFoVEbCKCc/bRcJnC4MFki3fYKMskbIgH6Ts85h2gX5yFSzrM0V+P6Pmo1+xl8MOgyyyhJeFFrGsNHTKpyxQW715wXvMdQZtIMihqThZo3Xhn3mzVQSd0Iy1j8PMnLTdJVdVChq8zgpNtcV3kJzo2CO9wXGUNWuifEZCG2yBtGziMQ3BvQMJ73Po104Y6ZpdjbjG4beapxwZUtN1X90TYWq8Qk42v1oj333e/80TQXPeXffqNkx4pdwpH85ZjUnBpG41J6Gdrg/GNAQMEczn7u9B4q5Y/yVDEtH02g97ukkZi8iVUreFqmo9K/rDZV5PHdJryGkKVZa1YNAgHx9TPy0dq/1BemnMErCwe/+Al4xByZGSTyzmJceF8FmtnZq1cvV3EjmxNjuhseRPbPM7GVzP2NqKXIWUDUlDzQwctWgG+jP9Cwwujq2cddvP1bjen8TyWBeu1JCHLFT8msZ+R4mnFUdUISuECvxigo6PJHyZDG0SZtwf3YrQ2fQGX4VuojdK2Ri/Rr30e37FrWExYuQk63XnPzMzLkt9QkzebW3W5YhgjHKApG0BwZkXjsEY1tQZZfKNkOAtyS7olG/teWyMt1xUIMQFGunPSmxZZM7uweVsk11RMyOiMZjxkFUGg3jPot/xxuqt6ZEMzp8NLXQM3TdWwtRVj7cHhXs6KuNhA0M7oxnBQpspPYzbuiHCZdWGztoprJm1b5EWC9ylHW9ELxl8htUv/jSHmlQ5ooiujzSxu+rTpKoUbiNXMkIXnTK+x11QaFNGqH49AViHKIwoMxrSqDQjyye02m3cViRzUYxQbdFu2Yf9rtl/tC83577Usqg9c1sGNuzVN4mvKh+jVYjbiV8Sq7LDVxlNt0JXtayx57uawgj25TKNkYwXor6/p38iuVOuwWjxH5Sfc/nXYlvlTEtMYPkbVkH+Mnj8vc2HtjaAJ5TJSuPAbHE7xxh9ZeiyQ6YuS00UxQCiB69u/24kO4x6s5CY+ufYAC9Uhy//OB59U4w51rj2KNk90iWd0+uV6ZBEtElGY6AjgJGWwWh1dBJCHcF42vL28Cs2927yiMIqRPTPSr0pDTjHMD7yxNTlvf49dzq6ta6KnehynXpvyWATawyMhqdxrnFAqHxGdwcCF9KTvFYVraQoCVRgHv/s0VugX1AFFf5ckIz4xhCeQOY6gYX5n9UhJOjEpCNSBoGcSIXJiabGlS7mUiuC+l5frtbBF3PxPKcm4rYCLfdGMmeiYFZsGmIhPpK3ox7TMjsJpZU5GKK/1d9Vs/HnuTlM4jrPIAnFSzviVvPlIN9VEMeV4JeWZPoebcoKCBBjzsYupUkxVys3i247+Y+NaicNfoHe7v93/vfPbs/tqUz/cy6T7/1955H6VXu9Olfv99wAA0G87e/PV/iF03hE=",Fc="d09GMgABAAAAAA/MAAoAAAAAL5wAAA+AAAEQowAAAAAAAAAAAAAAAAAAAAAAAAAABmAATAqTWI46ATYCJAMcCxAABCAFxyQHIBs/LDPSDdKKF1E1CkVUbaLBf5FgTBn6BTaMZm1JUuWmL/fi4ymiuDnEoYiISNO15/NwdiSSq14tDh+ORq/6b+595/YxEs/lof5ob3c7r/HmCwUepyWURYGHEFh+kzVUZ26OjA+wdlpnWwc6goXw6qs/4Vn/JjPhtA7YZGsu3O6BuS+J+6rfDtj+Y5h5onRfq1vvM7ajJOJsy1hyQmamjY115dLNyrT8MUNNp08cPFK53e3/v1c1Y+kHy1iYiAXx/Zs56GbMTWMDxmh1jAXYUkF6alYgDNZ/2/v/00PVNwj51ZcYh7M4st8+ewVWViZ+cn6zJ0fR6szcuaVp6JZuHBKJ9FiQqimEZLdSR2s6Vii6g8TJvc7fRJ/m/d5apYQg8pCHiEiQ0BsP0Il2dAKwBkli1gD2nx/FUVM7oOujsXDiYfHqy2D6g5uPHP7iHx30IurLgYBYo7eBLQiJwganwAaXHcjIQMqf/4H74O9H7v//gY3x4zfcYfcCd0OnDRBN9fn4DAtQnUDdAEAH0FUS3XRGropr2amtLMVzZ/TV1FuCMYjWqT0KQxGgAaRNNKjMdZYOnVbDXreiIaDZM69DIgWTZTIKpSKAoiWYGl/dxJbkSJKpUrMBt5eX9IdWoQOs0DwEKxRlbnxuuq/cZ9N13ytk6guUTHtmvDNOETXcgUBBs212ma53pQuYIA2AwA0ZtKoh0YCAUmt/GGB8k9dUjz5NReYOyFMRwNGk8ujU4pSTceapQMbT5blyH8AECsBQGEUsQdVAAzGKqLSrSwoUZWh8boHyKpdlO1RQLNNY6i3RIjMYilLvqF6KDCMSmpxNmUF0NNWKwivMi8ADAZI6C30WfObfle+y6QBrdI9wxXaKlMlbLASIRdflaBRRGS/MV/odqIQBRpNlel4mPzdYE9Ax1Y4stU2dySqUzHhG+cyyTu0HqGqwTImEpeaadLSGrFBoeGep12W6BgGTzoJVpC3bkb1qO8HG2qByjc3KHSbjBYbB0IMft5pQFAFsR3QDSR7Ld+Xnm2vPtNOQpSJNe2SUUABFxTYQw1SuldHoYiVgpVupyCLwWUfH0w0IlmbbTZ5UhQ2GQaFhLMvdiMhgep52uVlGX2A44vTNIGpVQjFgMtERQpqGkn7rQK04ymNtKWx0GxG4DRaYbTpdgVc5C24CWAZWKAC1FMGFaQAfFbomzOuMyLNMpoU7mlJwm244/RC52pSRQUMrQFqPY1lmFzYohXQBNJACvabb7RrNBYjGwiqtEkg8yqePL4wmzcggTgdscl7xrESD6YFpWOSDG3OcD0zE03afwrY/pjaLyQE3BfAGBdE2zYLP0NecwxAYhJcNds65ddQZdb7LQgDVqUZC9JofurwHYeYm7K2laB9HYby8AkIbJ80cvW+Of6wlHRpoShKtX3//7LmsVz83k2wAIR5zs7B6dd3qumGf9Lw7sevP+BRqto080MWoCh4r42kuzMTe2xzNcmLsTlQhceWNf9+53dFqX33t+b/ddkfYqrmMstGNwM2F93n6lHL6B27KN2rzGGFmkdfiRafEOA5RCEq2UjPf/19HHXGWHvX777e0fiecdOmB6adH0VYhQRB0ks/HHtaTW3bapkFzbQZ9+P+ns7bdNBYxnJi8/iburLP6uThJLFUfisejkdTG81aDpMLbe7vfsDnxC/qGAIn4sCTR0s5rrXX7gJOTYcjWyN5WhLCA/v7kg/olQcTJtN8pr/JYH9tJSMSNBNa/d3woDw/v+7LOMgNn98PX8rxoVXTSMOqRyz/H2kristdfPFfEr66Lyt33FAxJyn9RBuQxch7hZtno+svO/wKtvONHfn7DM+5Lx49HUkopF9FyWm/n+5+/yvP356HcrlcXhh4ejWzcIV+mpU2CIg//MTPNPorHr653u1RHN1ppIXLQw+ZWF5fuwyYmm+QzXQn2triNnbtznWXE3703/+6Fg9ejhcbfMle75QB//0LGsY/+wNmYex7RT1xJTV1jDVHo86/q+WnpAe7+iVqSqTjhTzFz7eogecidSruc1umgW3NXkgRFsd1KeUFyUtvDNojIl4+AqFjEDU+xqrIByg+Zo1xEIW7ZCli1bdcLE3RjizxrHoYlsewNNV79cC4meEu5KBchmc7TT3HQ0Ga+aS6LCSY4jrHO8zrehCMJxSuImHIIc3w2b5gfaTi1Z03TLIVCoaBx+uYK0fASDk9OTw4vyU7FDCe8t+47i1x+eXR6fcssWbFodEYT+ANusPjkPhJg2Wn7tOdXMIPl18/fn0JInb+SYQuCKAoCL7A8RyrOHVUvrBhnSTIen28IYiAQYxA6u3TuXowAz3NipyMwmMEeTsVjjESp5NbP2qf10Gta2pVyUOC5XC6ZIgyDPW/L3TbfLRP2IttjLkIQ9oNW4iXLlEqLdcrUlNb6Z9m0Fuw7zfZfJt2EcBp50em0TyABPP+YCHxuy31+2v3wGKpeBz6luI8DotZiMOZI4QiWm/WJKYCQRDR2cJ7Ojb/PhjkIIBYX34+49tr1w+O/CpjzMwCv3n6tOZ6f9S3+b/DHicJrPgLmFAYgwBnvGnyjBP/dNuJUJu/bwV0MHdQAgrjAnAcgr4Et/v9X0DssDa+5LEVzibW8gjr8ELQr0IhEQC9ljFA7SYZl2wUywmuPyVibtM+sHMXt+lg2KUinp8A/TK1Y+s7LDHBPIZI4qOiAS6hBLPAAeb2EBaxDkADHIucE+KKnVLZj0aLRrF4gNagFyayx6l8ZYET9PXAHCVgHFn8VHGGJAlesCIF3biBlBVVkvbNgRrKKHpF8872F2eZHVqHRRR4WEA8lUjNfJQ2LCwi8iCTvP3UBXMs5VYXjC6Jk+KQXQViXZQtYwLBdH6zotyViVBycN0dyWn6RYd0XwZb7BxYJ33UCnCkt57Lr1vZ9agds6sXCK0imbMwoywLe1usXXTtyMd//XgUdzrZw78ahq3vXrjyUU/veL3fv8FXAfN/Ic0Pi9cgpaiA0ZeH/umTT6K9LfHcO7bq058JhmM3TucOuE6KMcI6GcgZffHz4FSRgo9iSuZCoBkj6MPdL0ARp00D7RUMgSxY1pEgeXIUImgStOIfPuYX7/VnBfkKeEgZmqbIskdVi9Zy8UN69XVGrnQSd17E8C83IIpLjmXtz0qnIvPwzI4dNQl5pSJyDwkIeuNBCGtohzog98RGvKqdangGGUWaPkHubbmONrCn3Rka9Y8dN+nMEShjSzDOzSvE3peNcBORffQg1aYpTQOyhUDdZnOgWJNCdET6rDsqEi3VxxEWJ+KH2C6y51cmbDxfEqXQ0SDMQkq1Osp9+HsCHU8BToh4zC1WapwlGXAaSWWr5GA3KEJ69YCeUmQR9QVjQq8CH4y5DPxWU5BZLDmQMiO5UzdUAE+fGRS1YrLwG5AlZdu0Qq2HyaUunT5e1qxTkk8IYruN5jEyfN8z1ZSae7KPpJXRQCAPIWLqJFM7aRQ6rSMMdCU6pjQKpAx/Y0Fh+qegEFegl1E+Gj8umtO4U23WAucHMwyBtNSpE+JhjuDKvItU1CQpZwntO+WeGItrrO4HKePfAoSOnrnB64PXC/bIzyY6ldzzYyoMRoD4tcJFsWmTKPU/rHJ+HNrueYMHKz/KF+MofQZTXViHPeJafUyhZV1bgVZuL5+NZcbjRl2dV4aFMLYiSXHcwgHXcxhKc3Lk62ZX7fiBSrbRvRJav6y6BAqzbjYZ8zjsjAUdy3B9Y0PWU0Uu21d5GYoTuYdjBB6HaLpxY/MyDjpfFbKeC9xND2D11uQDHn8dWjmLbmRDtFOvKhWSejZR0QKYA3Fe5PvRQ1UFCJ231C0yjydyZFk4BuW6ofeLN0bEwZGN08Xr24cBRw0YE1RZT6JR1FQ4EBPwJz2UE8MuAlOkpznCYu/zYKw67STGc0zrLaEp4FQtbXYvM8Trr9j0TT4wjQ89kUKgWnTLSIbvn7pxMUQf2IC+n8Mu+Q3cunbp3vxgK+JQSOzt1sDCKDz17SMTj2GYdW+igM1DCOzJ924AQiFQ+BxnibfMrc3Qho82huBDdMftQRAeq+u6nJ0bae68QFJ2v14kvn9rf80bQXS8PjfpzqzRU3yrcTExHVWBvawYltdPm4IQjYoaBYi5iJzZsLOZvXUEU1PF0pnS6VI0o+yJd77iqCekUELp9t3pcaaiwXara15q7BvDMM7WJ+YaavmrvzDsgdnaPv/CecY05CrLZRVIiMEhotXkWywn2+0W0ZO9ygEfP27LP22l7O0NzA3wdU3QgqR7nPfRweTV//m/a8VLPOKn5dn7Y3M6pv4h1gQVbs1Ama79kuqFRJOqro6tir9Ir+9URiZ5mOVwIRgBDd8TNGMxtv4OLCVd6Td7e6UUNm8PEmbFjoWJVMvR06yte4cTs+AFVzA736nrLcEp2GE/lCBppLGk7vFNtuwix+ppskAaVPd2rDY1vrJPWG4tJoQIa7TmnuxZlO+ewe3soD2JQQOmZhIAoaxqDftOA45Lj6bYeho4T9drjUfOYfqmC3lYNjkcHN3O+iqs7CBhq3hk+jHiZP42FlSPwitXEzfuqDaBqx0IvE71veygv6cXynjE11v9RF/ROC3TZvfFGGQ99OS5LBXcQ+0mRx+eZzmCz6XQowHU/38BsQ1CwMCAa2y3bhFTzcbs5fFuRzQFFhHFAeeQ+7F/N/df4TvO83yprDrnDrvvoTt67JgzoUxDh1vJ1czixYNUtttt5uh26c/8aax63c7aFvZ9KIS0zY/CfVfhfyV61liSWJWS+2PxvByWjsKAxHAMCyI4xCB+X+1xS9JIuVQzUeGENCOf2YEKTTKJwKy3yXTFBMgbM8i934uM2aWaKx85WCRDdh7niL33mlBzwQ6dQb8JRKweg85kpNbQgQsuajU0I7CznuBLHBoEpmHShPHGay+TfXCpYHEcMmrmVWTCWyEHcEXv4plxK68FXzKo4oaLchJ3T2SKTMfWHiZClCrftDGJFC9MJx3zICwBaDmsqBRJdHILjTNVp3BD3QPiXSVDCC2J4h1kYxJb0ovOc0s5zLwpQMknmIgkZmlpKHBXMqYwJ0FwfOmkPuQcgpyydgv/deK74QZdtmfE8mI14AW/hL5mWR+W1ci8Diw7gnKPDZfKe5gWZ06BhgVJB2dM4acFP+TDmArDmPAFgfKgoIAmElpMbhisFldUelj/d+q+N1djY/RX6z/rU1dIxMjTnJZZy89n2+QkQa+4Htfi6d/Ou3PwdeX9LV8fUXPbJycbw/Vsbf5vUS0MD/AOHpkaaAPAf1/Pd3b/cvvYLAAAA";let $s=!1;function Dc(){if($s||typeof document>"u")return;$s=!0;const t=document.createElement("style");t.setAttribute("data-pepperhorn-staff-fonts",""),t.textContent="@font-face{font-family:'PHBravura';font-display:block;src:url(data:font/woff2;base64,"+zc+") format('woff2');}@font-face{font-family:'PHPetaluma';font-display:block;src:url(data:font/woff2;base64,"+Fc+") format('woff2');}",document.head.appendChild(t)}Dc();function Ln({notes:t,lhNotes:n,rhOctave:e,lhOctave:s,octaveQualifiedNotes:r,chordLabel:i,scale:a=.5,showPlayback:o=!0,glyphs:l,className:d,style:m}){const{tokens:f}=pn(),p=l??Ai(),b=vi(t,{lhNotes:n,rhOctave:e,lhOctave:s,octaveQualifiedNotes:r}),g=o&&t.length>0,v=g?30:0,y=b.totalHeight+v,_=b.totalWidth,S=f.text??"#333",M=f.text??"#333";function w(k){const I=[];for(let u=0;u<5;u++){const j=k+u*Gt;I.push(N.jsx("line",{className:"bc-staff__line",x1:bn+2,y1:j,x2:gi-4,y2:j,stroke:S,strokeWidth:Kr},`line-${k}-${u}`))}return I}const T=Gt*4;function P(k,I){const u=bn+4,j=k==="treble"?I+Gt*3:I+Gt,X=k==="treble"?p.glyphs.trebleClef:p.glyphs.bassClef;return N.jsx("text",{className:`bc-staff__clef--${k}`,x:u,y:j,fontFamily:p.fontFamily,fontSize:T,fill:S,children:X})}function z(k,I,u){const j=k==="sharp"?p.glyphs.sharp:p.glyphs.flat;return N.jsx("text",{className:"bc-staff__accidental",x:I,y:u,fontFamily:p.fontFamily,fontSize:T,fill:M,textAnchor:"middle",children:j})}const E=_-170,L=4,V=v;return N.jsxs("svg",{viewBox:`0 0 ${_} ${y}`,xmlns:"http://www.w3.org/2000/svg",className:`bc-staff ${d??""}`.trim(),style:{width:"100%",maxWidth:_*a*2,...m},role:"img","aria-label":i?`Staff notation: ${i}`:"Staff notation",children:[g&&N.jsx("g",{"data-controls":"",children:N.jsx(vo,{notes:t,lhNotes:n,rhOctave:e,lhOctave:s,chordName:i??t.join("-"),x:E,y:L})}),N.jsxs("g",{transform:`translate(0, ${V})`,children:[i&&N.jsx("text",{className:"bc-staff__label",x:se,y:Mn-13,textAnchor:"middle",fontSize:13,fontWeight:600,fill:M,fontFamily:"system-ui, sans-serif",children:i}),N.jsxs("g",{className:"bc-staff__system",children:[b.staffMode==="grand"&&b.trebleTopY>=0&&N.jsx("path",{className:"bc-staff__brace",d:p.brace(b.bassTopY+Gt*4-b.trebleTopY),transform:`translate(0, ${b.trebleTopY})`,fill:"none",stroke:S,strokeWidth:2}),b.staffMode==="grand"&&N.jsx("line",{className:"bc-staff__barline",x1:bn+2,y1:b.trebleTopY,x2:bn+2,y2:b.bassTopY+Gt*4,stroke:S,strokeWidth:Kr}),b.trebleTopY>=0&&N.jsxs("g",{className:"bc-staff__treble",children:[w(b.trebleTopY),P("treble",b.trebleTopY)]}),b.bassTopY>=0&&N.jsxs("g",{className:"bc-staff__bass",children:[w(b.bassTopY),P("bass",b.bassTopY)]}),N.jsx("g",{className:"bc-staff__notes",children:b.notes.map((k,I)=>{const u=Math.min(k.noteX,se)-br-Yr,j=Math.max(k.noteX,se)+br+Yr;return N.jsxs("g",{className:"bc-staff__note",children:[k.ledgerLines.map((X,G)=>N.jsx("line",{className:"bc-staff__ledger",x1:u,y1:X,x2:j,y2:X,stroke:S,strokeWidth:Jo},`ledger-${G}`)),k.accidental&&z(k.accidental,k.accidentalX,k.y),N.jsx("text",{className:"bc-staff__notehead",x:k.noteX,y:k.y,fontFamily:p.fontFamily,fontSize:T,fill:M,textAnchor:"middle",children:p.glyphs.wholeNote})]},I)})})]})]})]})}function Lc(t){return t<=1?1:t<=2||t<=3?2:4}function tr({chords:t,label:n,format:e,theme:s,highlightColor:r,showPlayback:i=!0,scale:a,display:o="keyboard",showNoteNames:l,noteNameMode:d,noteNameSize:m,showFingering:f,fingeringSize:p,onVariation:h,renderVariationExtras:b}){const{tokens:g}=pn(),v=t.map(S=>Kn(S.notes,{padding:1})),y=Math.max(...v.map(S=>S.size),8),_=Lc(t.length);return N.jsxs("div",{className:"bc-chord-group",style:{marginBottom:16,width:"100%"},children:[n&&N.jsx("div",{className:"bc-chord-group__label",style:{fontWeight:600,marginBottom:8,fontSize:14},children:n}),N.jsx("div",{className:"bc-chord-group__grid",style:{display:"flex",flexWrap:"wrap",gap:12,alignItems:"flex-start",width:"100%"},children:t.map((S,M)=>{let w=S.notes;if(v[M].chordOctave>0){let T=v[M].chordOctave;const P=At(S.notes[0]);let E=gt.indexOf(P.replace("#",""));w=S.notes.map((L,V)=>{const k=At(L),I=k.replace("#",""),u=gt.indexOf(I);return V>0&&u<=E&&T++,E=u,`${k}:${T}`})}return N.jsxs(Hc,{chord:S,index:M,perRow:_,onVariation:h,renderVariationExtras:b,children:[N.jsx("div",{className:"bc-chord-group__symbol",style:{fontSize:12,fontWeight:500,marginBottom:4},children:S.symbol}),o==="staff"?N.jsx(Ln,{notes:S.notes,chordLabel:S.symbol,showPlayback:i,scale:a}):o==="both"?N.jsxs("div",{className:"bc-display-both",style:{display:"flex",gap:8,alignItems:"flex-start"},children:[N.jsx(Ln,{notes:S.notes,chordLabel:S.symbol,showPlayback:!1,scale:a}),N.jsx(me,{format:e,size:y,startFrom:v[M].startFrom,highlightKeys:w,theme:s,highlightColor:r,showPlayback:i,chordLabel:S.symbol,scale:a,showNoteNames:l,noteNameMode:d,noteNameSize:m,displayNoteNames:S.notes,fingering:f?cn(S.notes):void 0,fingeringSize:p})]}):N.jsx(me,{format:e,size:y,startFrom:v[M].startFrom,highlightKeys:w,theme:s,highlightColor:r,showPlayback:i,chordLabel:S.symbol,scale:a,showNoteNames:l,noteNameMode:d,noteNameSize:m,displayNoteNames:S.notes,fingering:f?cn(S.notes):void 0,fingeringSize:p}),S.voicingStyle&&N.jsx("div",{className:"bc-chord-group__voicing-style",style:{fontSize:10,color:g.textSubtle,marginTop:2},children:S.voicingStyle})]},M)})})]})}function Hc({chord:t,index:n,perRow:e,onVariation:s,renderVariationExtras:r,children:i}){const a=ft.useRef(null),o=ft.useRef(""),l=()=>{var d,m;return{chordSymbol:t.symbol,chordIndex:n,voicingId:"default",notes:t.notes,svgString:((m=(d=a.current)==null?void 0:d.querySelector("svg"))==null?void 0:m.outerHTML)??""}};return ft.useEffect(()=>{if(!s)return;const d=l(),m=`${d.chordSymbol}|${d.voicingId}|${d.chordIndex}|${d.notes.join(",")}|${d.svgString.length}`;m!==o.current&&(o.current=m,s(d))}),N.jsxs("div",{ref:a,className:"bc-chord-group__item",style:{textAlign:"center",flex:`0 1 calc(${100/e}% - ${(e-1)*12/e}px)`,minWidth:0},children:[i,r==null?void 0:r(l())]})}function _o(t){const n=(t%12+12)%12;return n===0?1:n<=2?2:n<=4?3:n===5?4:n<=7?5:n<=9?6:7}const Ar={1:"root",2:"2nd",3:"3rd",4:"4th",5:"5th",6:"6th",7:"7th",9:"9th",11:"11th",13:"13th"};function Vs(t,n,e){const s=vt(`${t}4`);if(s==null)return;const r=n>7?n-7:n;for(const i of e){const a=vt(`${i}4`);if(a==null)continue;const o=((a-s)%12+12)%12;if(_o(o)===r)return i}}function ur(t,n){const e=vt(`${t}4`);if(e==null)return n.join(", ");const s=[];for(const r of n){const i=vt(`${r}4`);if(i==null)continue;const a=((i-e)%12+12)%12,o=_o(a),l=Ar[o]??`${o}th`;s.push(`${l} (${r})`)}return s.join(", ")}function Uc(t){return"chord"in t}function Hn(t){if(!Uc(t))return N.jsx(me,{...t});const{chord:n,format:e,theme:s,highlightColor:r,padding:i,scale:a,display:o="keyboard",uiTheme:l,showPlayback:d=!0,className:m,style:f}=t,{onVariation:p,renderVariationExtras:h,voicingId:b="default",chordIndex:g=0}=t,v=gn(l),y=ft.useRef(null),_=ft.useRef("");let S=[];const M=()=>{var q,et;return{chordSymbol:typeof n=="string"?n:String(n),chordIndex:g,voicingId:b,notes:S,svgString:((et=(q=y.current)==null?void 0:q.querySelector("svg"))==null?void 0:et.outerHTML)??""}};ft.useEffect(()=>{if(!p)return;const q=M(),et=`${q.chordSymbol}|${q.voicingId}|${q.chordIndex}|${q.notes.join(",")}|${q.svgString.length}`;et!==_.current&&(_.current=et,p(q))});const w=Vn(n),T=w.colorTheme??s,P=w.scale??a;if(w.isScale&&w.scaleName){const[q,...et]=w.scaleName.split(" "),it=et.join(" "),c=mc(q,it,w.scaleDirection,w.scaleOctaves),D=c.notes.map(At),F=w.padding??i??1,A=w.format??e,C=(vt(`${D[0]}3`)??48)>=57?3:4;let U=C,$=-1;const O=D.map(Ct=>{const Mt=vt(`${Ct}${U}`);if(Mt==null)return 60;if($>=0&&Mt<=$){U++;const ve=vt(`${Ct}${U}`)??Mt+12;return $=ve,ve}return $=Mt,Mt}),K=O[0],nt=O[O.length-1],Y=F*2,rt=Xt(K-Y),dt=Xt(nt+Y),ct=Dt(rt).replace(/[#b]/,""),xt=Dt(dt).replace(/[#b]/,""),Et=or(rt)??C,kt=or(dt)??C+1,Rt=gt.indexOf(ct),bt=gt.indexOf(xt),mt=(kt-Et)*7+(bt-Rt)+1,St=Math.max(mt,8),Lt=O.map((Ct,Mt)=>{const Pt=(or(Xt(Ct))??C)-Et;return`${D[Mt]}:${Pt}`}),ce=Et,Vt=Fs(c.intervals),Jt=c.notes.map((Ct,Mt)=>Vt[Mt%Vt.length]),It=w.autoFingering?qo(q,it,"rh",w.scaleOctaves??1):void 0;return S=D,N.jsxs(N.Fragment,{children:[N.jsx("div",{ref:y,className:"bc-pianochord-root",children:N.jsx(Bt,{value:v,children:N.jsx(me,{format:A,size:St,startFrom:ct,highlightKeys:Lt,displayNoteNames:c.notes,theme:T,highlightColor:r,chordLabel:w.scaleName,showHeading:w.showHeading,scale:P,showNoteNames:w.showNoteNames,noteNameSize:w.noteNameSize,noteNameMode:w.noteNameMode,midiBaseOctave:ce,degreeLabels:Jt,fingering:It&&It.length>0?It:void 0,fingeringSize:w.fingeringSize,showPlayback:d,className:m,style:f})})}),h==null?void 0:h(M())]})}if(!w.chordName)throw new Error(`Couldn't find a chord name in "${n}"`);const z=mn(w.chordName,w.inversion);if(w.allInversions){const q=z.notes.length,et=["Root position","1st inversion","2nd inversion","3rd inversion","4th inversion"],it=[];for(let D=0;D<q;D++){const F=[...z.notes.slice(D),...z.notes.slice(0,D)];it.push({symbol:et[D]??`${D}th inversion`,root:z.root,notes:F})}const c=w.format??e;return S=z.notes,N.jsxs(N.Fragment,{children:[N.jsx("div",{ref:y,className:"bc-pianochord-root",children:N.jsx(Bt,{value:v,children:N.jsx(tr,{chords:it,label:w.chordName,format:c,theme:T,highlightColor:r,showPlayback:d,scale:P})})}),h==null?void 0:h(M())]})}let{notes:E}=z,L;if(w.styleHint){const q=qn(z.type,z.notes);if(q){const et=Qn(q,w.styleHint);if(et){const it=Re(z.root,et);it.length>0&&(E=it,L=et.hands)}}}let V;if(w.bassDegree!=null){const q=ur(z.root,E),et=Vs(z.root,w.bassDegree,E);if(!et){const it=Ar[w.bassDegree]??`${w.bassDegree}th`;throw new Error(`${w.chordName} doesn't have a ${it} — try: ${q}`)}V=et}else w.bassNote&&(V=Ee[w.bassNote]??w.bassNote);let k=w.startingNote;if(!k&&w.startingDegree!=null){const q=ur(z.root,E);if(k=Vs(z.root,w.startingDegree,E),!k){const et=Ar[w.startingDegree]??`${w.startingDegree}th`;throw new Error(`${w.chordName} doesn't have a ${et} — try: ${q}`)}}if(k){const q=Ee[k]??k,et=E.indexOf(q);if(et<0){const it=ur(z.root,E);throw new Error(`${k} isn't in ${w.chordName} — the notes are: ${it}`)}et>0&&(E=[...E.slice(et),...E.slice(0,et)])}if(w.chordOctaves&&w.chordOctaves>1){const q=[...E],et=[];for(let it=0;it<w.chordOctaves;it++)et.push(...q);et.push(q[0]),E=et}const I=(()=>{if(w.noteNameMode!=="degree"&&w.noteNameMode!=="pitch-class+degree")return;const q=z.intervals;if(!q||q.length===0)return;const et=Fs(q);return E.map((it,c)=>et[c%et.length])})(),u=w.padding??i??1,j=w.format??e,X=(q,et)=>{const it=et!=null&&et.bassNote?[et.bassNote,...q]:q,c=3+(w.bassOctaveShift??0),D=4+(w.chordOctaveShift??0);return N.jsx(Ln,{notes:it,lhNotes:et!=null&&et.bassNote?[et.bassNote]:void 0,rhOctave:D,lhOctave:c,octaveQualifiedNotes:et==null?void 0:et.octaveQualifiedNotes,chordLabel:w.chordName,scale:P,showPlayback:d,className:m,style:f})},G=28,st=(q,et)=>{let it=et;const c=At(q[0]);let F=gt.indexOf(c.replace("#",""));const A=q.map((C,U)=>{const $=At(C),O=$.replace("#",""),K=gt.indexOf(O);return U>0&&K<=F&&it++,F=K,{norm:$,octave:it}}),x=vt(`${A[0].norm}${A[0].octave}`);if(x!=null)for(let C=1;C<A.length;C++){const U=vt(`${A[C].norm}${A[C].octave}`);U!=null&&U-x>G&&A[C].octave>A[0].octave&&A[C].octave--}return A.map(C=>`${C.norm}:${C.octave}`)};if(V){const q=At(V),et=q.replace("#",""),it=gt.indexOf(et),c=1+(w.chordOctaveShift??0)-(w.bassOctaveShift??0),D=Math.max(c,0)*7,F=E.map(Pt=>{const Yt=At(Pt).replace("#","");let Kt=gt.indexOf(Yt)-it;return Kt<=0&&(Kt+=7),Kt+D}),A=Math.max(...F);let x=((it-u)%7+7)%7,C=!1;Se(x)&&(x=((x-1)%7+7)%7,C=!0);const U=gt[x],$=((it-x)%7+7)%7;let O=Math.max($+A+u+1,10),K=!1;const nt=x+O-1;Se(nt)&&(O+=1,K=!0);const Y=ln(U,O,j),rt=Y.findIndex(Pt=>At(Pt.note)===q),dt=rt>=0?Y[rt].octave:0,ct=dt+Math.max(c,0),xt=[`${q}:${dt}`],Et=E.map(Pt=>{const Ht=At(Pt),Yt=Ht.replace("#",""),er=gt.indexOf(Yt)>it?ct:ct+1;return`${Ht}:${er}`}),kt=[...xt,...Et],Rt=3+(w.bassOctaveShift??0),bt=Rt+Math.max(c,0),ot=[`${q}:${Rt}`,...E.map(Pt=>{const Ht=At(Pt),Yt=Ht.replace("#",""),er=gt.indexOf(Yt)>it?bt:bt+1;return`${Ht}:${er}`})],mt=[],St=[],Lt=kt.map((Pt,Ht)=>{const[Yt,te]=Pt.split(":");return{note:Yt,octave:parseInt(te,10),isLH:Ht<xt.length,matched:!1}});for(let Pt=0;Pt<Y.length;Pt++){const Ht=At(Y[Pt].note),Yt=Y[Pt].octave,te=Lt.findIndex(Kt=>!Kt.matched&&Kt.note===Ht&&Kt.octave===Yt);te!==-1&&(Lt[te].matched=!0,(Lt[te].isLH?mt:St).push(Pt))}const ce=[{label:"L.H.",keyIndices:mt},{label:"R.H.",keyIndices:St}],Vt=2+(w.bassOctaveShift??0),Jt=3+(w.chordOctaveShift??0),It=cn([V],"lh"),Ct=kn(E,L),Mt=w.customFingering??w.fingering??(w.autoFingering?[...It,...Ct.fingering]:void 0),ve=N.jsx(me,{format:j,size:O,startFrom:U,highlightKeys:kt,displayNoteNames:[V,...E],clipLeft:C,clipRight:K,allNotes:[V,...E],lhNotes:[V],lhOctave:Vt,rhOctave:Jt,theme:T,highlightColor:r,chordLabel:w.chordName,showHeading:w.showHeading,handBrackets:ce,scale:P,showNoteNames:w.showNoteNames,noteNameSize:w.noteNameSize,noteNameMode:w.noteNameMode,midiBaseOctave:Vt+1,fingering:Mt,fingeringSize:w.fingeringSize,showPlayback:d,className:m,style:f});return S=[V,...E],o==="staff"?N.jsxs(N.Fragment,{children:[N.jsx("div",{ref:y,className:"bc-pianochord-root",children:N.jsx(Bt,{value:v,children:X(E,{bassNote:V,octaveQualifiedNotes:ot})})}),h==null?void 0:h(M())]}):o==="both"?N.jsxs(N.Fragment,{children:[N.jsx("div",{ref:y,className:"bc-pianochord-root",children:N.jsx(Bt,{value:v,children:N.jsxs("div",{className:"bc-display-both bc-display-both--stacked",style:{display:"flex",flexDirection:"column",gap:8,alignItems:"center"},children:[ve,X(E,{bassNote:V,octaveQualifiedNotes:ot})]})})}),h==null?void 0:h(M())]}):N.jsxs(N.Fragment,{children:[N.jsx("div",{ref:y,className:"bc-pianochord-root",children:N.jsx(Bt,{value:v,children:ve})}),h==null?void 0:h(M())]})}const H=E.map(At),Q=Kn(H,{padding:u,startingNote:k,spanFrom:w.spanFrom,spanTo:w.spanTo}),B=w.chordOctaveShift??0,R=B>0?Q.size+B*7:Q.size;let J=H;{const q=H.map(it=>gt.indexOf(it.replace("#","")));if(Q.chordOctave>0||B!==0||q.some((it,c)=>c>0&&it<=q[c-1])){let it=Math.max(Q.chordOctave+B,0),c=q[0];const D=H.map((A,x)=>{const C=q[x];return x>0&&C<=c&&it++,c=C,{note:A,octave:it}}),F=vt(`${D[0].note}${D[0].octave+4}`);if(F!=null)for(let A=1;A<D.length;A++){const x=vt(`${D[A].note}${D[A].octave+4}`);x!=null&&x-F>G&&D[A].octave>D[0].octave&&D[A].octave--}J=D.map(A=>`${A.note}:${A.octave}`)}}const tt=J.map(q=>{if(q.includes(":")){const[et,it]=q.split(":");return vt(`${et}${parseInt(it,10)+4}`)??60}return vt(`${q}4`)??60});let Z;if(V){const q=cn([V],"lh"),et=kn(E,L);Z={fingering:[...q,...et.fingering],hands:["lh",...et.hands]}}else Z=kn(E,L,tt);const pt=w.customFingering??w.fingering??(w.autoFingering?Z.fingering:void 0),wt=!V&&Z.hands.some(q=>q==="lh");let ht;if(wt){const q=ln(Q.startFrom,R,j),et=[],it=[],c=new Set;for(let D=0;D<H.length;D++){const F=Z.hands[D],A=J[D],x=A.includes(":");for(let C=0;C<q.length;C++){if(c.has(C))continue;const U=At(q[C].note);if(x){const[$,O]=A.split(":");if(U===$&&q[C].octave===parseInt(O,10)){c.add(C),(F==="lh"?et:it).push(C);break}}else if(U===A){c.add(C),(F==="lh"?et:it).push(C);break}}}et.length>0&&it.length>0&&(ht=[{label:"L.H.",keyIndices:et},{label:"R.H.",keyIndices:it}])}const ut=N.jsx(me,{format:j,size:R,startFrom:Q.startFrom,highlightKeys:J,displayNoteNames:E,clipLeft:Q.clipLeft,clipRight:Q.clipRight,rhOctave:B!==0?4+B:void 0,theme:T,highlightColor:r,chordLabel:w.chordName,showHeading:w.showHeading,handBrackets:ht,scale:P,showNoteNames:w.showNoteNames,noteNameSize:w.noteNameSize,noteNameMode:w.noteNameMode,midiBaseOctave:4,fingering:pt,fingeringSize:w.fingeringSize,degreeLabels:I,showPlayback:d,className:m,style:f}),yt=st(E,4+B);return S=E,o==="staff"?N.jsxs(N.Fragment,{children:[N.jsx("div",{ref:y,className:"bc-pianochord-root",children:N.jsx(Bt,{value:v,children:X(E,{octaveQualifiedNotes:yt})})}),h==null?void 0:h(M())]}):o==="both"?N.jsxs(N.Fragment,{children:[N.jsx("div",{ref:y,className:"bc-pianochord-root",children:N.jsx(Bt,{value:v,children:N.jsxs("div",{className:"bc-display-both",style:{display:"flex",gap:16,alignItems:"flex-start"},children:[X(E,{octaveQualifiedNotes:yt}),ut]})})}),h==null?void 0:h(M())]}):N.jsxs(N.Fragment,{children:[N.jsx("div",{ref:y,className:"bc-pianochord-root",children:N.jsx(Bt,{value:v,children:ut})}),h==null?void 0:h(M())]})}var xn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Wc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function An(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var dr={exports:{}};/*!
3
3
 
4
4
  JSZip v3.10.1 - A JavaScript class for generating and reading zip files
5
5
  <http://stuartk.com/jszip>
@@ -9,5 +9,5 @@ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/js
9
9
 
10
10
  JSZip uses the library pako released under the MIT license :
11
11
  https://github.com/nodeca/pako/blob/main/LICENSE
12
- */var Vs;function Lc(){return Vs||(Vs=1,(function(t,n){(function(e){t.exports=e()})(function(){return(function e(s,r,i){function a(d,m){if(!r[d]){if(!s[d]){var f=typeof Sn=="function"&&Sn;if(!m&&f)return f(d,!0);if(o)return o(d,!0);var p=new Error("Cannot find module '"+d+"'");throw p.code="MODULE_NOT_FOUND",p}var h=r[d]={exports:{}};s[d][0].call(h.exports,function(b){var g=s[d][1][b];return a(g||b)},h,h.exports,e,s,r,i)}return r[d].exports}for(var o=typeof Sn=="function"&&Sn,l=0;l<i.length;l++)a(i[l]);return a})({1:[function(e,s,r){var i=e("./utils"),a=e("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(l){for(var d,m,f,p,h,b,g,v=[],y=0,_=l.length,k=_,M=i.getTypeOf(l)!=="string";y<l.length;)k=_-y,f=M?(d=l[y++],m=y<_?l[y++]:0,y<_?l[y++]:0):(d=l.charCodeAt(y++),m=y<_?l.charCodeAt(y++):0,y<_?l.charCodeAt(y++):0),p=d>>2,h=(3&d)<<4|m>>4,b=1<k?(15&m)<<2|f>>6:64,g=2<k?63&f:64,v.push(o.charAt(p)+o.charAt(h)+o.charAt(b)+o.charAt(g));return v.join("")},r.decode=function(l){var d,m,f,p,h,b,g=0,v=0,y="data:";if(l.substr(0,y.length)===y)throw new Error("Invalid base64 input, it looks like a data url.");var _,k=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===o.charAt(64)&&k--,l.charAt(l.length-2)===o.charAt(64)&&k--,k%1!=0)throw new Error("Invalid base64 input, bad content length.");for(_=a.uint8array?new Uint8Array(0|k):new Array(0|k);g<l.length;)d=o.indexOf(l.charAt(g++))<<2|(p=o.indexOf(l.charAt(g++)))>>4,m=(15&p)<<4|(h=o.indexOf(l.charAt(g++)))>>2,f=(3&h)<<6|(b=o.indexOf(l.charAt(g++))),_[v++]=d,h!==64&&(_[v++]=m),b!==64&&(_[v++]=f);return _}},{"./support":30,"./utils":32}],2:[function(e,s,r){var i=e("./external"),a=e("./stream/DataWorker"),o=e("./stream/Crc32Probe"),l=e("./stream/DataLengthProbe");function d(m,f,p,h,b){this.compressedSize=m,this.uncompressedSize=f,this.crc32=p,this.compression=h,this.compressedContent=b}d.prototype={getContentWorker:function(){var m=new a(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),f=this;return m.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),m},getCompressedWorker:function(){return new a(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},d.createWorkerFrom=function(m,f,p){return m.pipe(new o).pipe(new l("uncompressedSize")).pipe(f.compressWorker(p)).pipe(new l("compressedSize")).withStreamInfo("compression",f)},s.exports=d},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,s,r){var i=e("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},r.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,s,r){var i=e("./utils"),a=(function(){for(var o,l=[],d=0;d<256;d++){o=d;for(var m=0;m<8;m++)o=1&o?3988292384^o>>>1:o>>>1;l[d]=o}return l})();s.exports=function(o,l){return o!==void 0&&o.length?i.getTypeOf(o)!=="string"?(function(d,m,f,p){var h=a,b=p+f;d^=-1;for(var g=p;g<b;g++)d=d>>>8^h[255&(d^m[g])];return-1^d})(0|l,o,o.length,0):(function(d,m,f,p){var h=a,b=p+f;d^=-1;for(var g=p;g<b;g++)d=d>>>8^h[255&(d^m.charCodeAt(g))];return-1^d})(0|l,o,o.length,0):0}},{"./utils":32}],5:[function(e,s,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(e,s,r){var i=null;i=typeof Promise<"u"?Promise:e("lie"),s.exports={Promise:i}},{lie:37}],7:[function(e,s,r){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=e("pako"),o=e("./utils"),l=e("./stream/GenericWorker"),d=i?"uint8array":"array";function m(f,p){l.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=p,this.meta={}}r.magic="\b\0",o.inherits(m,l),m.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(d,f.data),!1)},m.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},m.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},m.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(p){f.push({data:p,meta:f.meta})}},r.compressWorker=function(f){return new m("Deflate",f)},r.uncompressWorker=function(){return new m("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,s,r){function i(h,b){var g,v="";for(g=0;g<b;g++)v+=String.fromCharCode(255&h),h>>>=8;return v}function a(h,b,g,v,y,_){var k,M,w=h.file,T=h.compression,P=_!==d.utf8encode,j=o.transformTo("string",_(w.name)),C=o.transformTo("string",d.utf8encode(w.name)),L=w.comment,V=o.transformTo("string",_(L)),A=o.transformTo("string",d.utf8encode(L)),N=C.length!==w.name.length,u=A.length!==L.length,z="",Q="",W="",st=w.dir,$=w.date,X={crc32:0,compressedSize:0,uncompressedSize:0};b&&!g||(X.crc32=h.crc32,X.compressedSize=h.compressedSize,X.uncompressedSize=h.uncompressedSize);var B=0;b&&(B|=8),P||!N&&!u||(B|=2048);var R=0,J=0;st&&(R|=16),y==="UNIX"?(J=798,R|=(function(Y,pt){var wt=Y;return Y||(wt=pt?16893:33204),(65535&wt)<<16})(w.unixPermissions,st)):(J=20,R|=(function(Y){return 63&(Y||0)})(w.dosPermissions)),k=$.getUTCHours(),k<<=6,k|=$.getUTCMinutes(),k<<=5,k|=$.getUTCSeconds()/2,M=$.getUTCFullYear()-1980,M<<=4,M|=$.getUTCMonth()+1,M<<=5,M|=$.getUTCDate(),N&&(Q=i(1,1)+i(m(j),4)+C,z+="up"+i(Q.length,2)+Q),u&&(W=i(1,1)+i(m(V),4)+A,z+="uc"+i(W.length,2)+W);var tt="";return tt+=`
13
- \0`,tt+=i(B,2),tt+=T.magic,tt+=i(k,2),tt+=i(M,2),tt+=i(X.crc32,4),tt+=i(X.compressedSize,4),tt+=i(X.uncompressedSize,4),tt+=i(j.length,2),tt+=i(z.length,2),{fileRecord:f.LOCAL_FILE_HEADER+tt+j+z,dirRecord:f.CENTRAL_FILE_HEADER+i(J,2)+tt+i(V.length,2)+"\0\0\0\0"+i(R,4)+i(v,4)+j+z+V}}var o=e("../utils"),l=e("../stream/GenericWorker"),d=e("../utf8"),m=e("../crc32"),f=e("../signature");function p(h,b,g,v){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=g,this.encodeFileName=v,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(p,l),p.prototype.push=function(h){var b=h.meta.percent||0,g=this.entriesCount,v=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,l.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:g?(b+100*(g-v-1))/g:100}}))},p.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var b=this.streamFiles&&!h.file.dir;if(b){var g=a(h,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:g.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(h){this.accumulate=!1;var b=this.streamFiles&&!h.file.dir,g=a(h,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(g.dirRecord),b)this.push({data:(function(v){return f.DATA_DESCRIPTOR+i(v.crc32,4)+i(v.compressedSize,4)+i(v.uncompressedSize,4)})(h),meta:{percent:100}});else for(this.push({data:g.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var h=this.bytesWritten,b=0;b<this.dirRecords.length;b++)this.push({data:this.dirRecords[b],meta:{percent:100}});var g=this.bytesWritten-h,v=(function(y,_,k,M,w){var T=o.transformTo("string",w(M));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(y,2)+i(y,2)+i(_,4)+i(k,4)+i(T.length,2)+T})(this.dirRecords.length,g,h,this.zipComment,this.encodeFileName);this.push({data:v,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(h){this._sources.push(h);var b=this;return h.on("data",function(g){b.processChunk(g)}),h.on("end",function(){b.closedSource(b.previous.streamInfo),b._sources.length?b.prepareNextSource():b.end()}),h.on("error",function(g){b.error(g)}),this},p.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},p.prototype.error=function(h){var b=this._sources;if(!l.prototype.error.call(this,h))return!1;for(var g=0;g<b.length;g++)try{b[g].error(h)}catch{}return!0},p.prototype.lock=function(){l.prototype.lock.call(this);for(var h=this._sources,b=0;b<h.length;b++)h[b].lock()},s.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,s,r){var i=e("../compressions"),a=e("./ZipFileWorker");r.generateWorker=function(o,l,d){var m=new a(l.streamFiles,d,l.platform,l.encodeFileName),f=0;try{o.forEach(function(p,h){f++;var b=(function(_,k){var M=_||k,w=i[M];if(!w)throw new Error(M+" is not a valid compression method !");return w})(h.options.compression,l.compression),g=h.options.compressionOptions||l.compressionOptions||{},v=h.dir,y=h.date;h._compressWorker(b,g).withStreamInfo("file",{name:p,dir:v,date:y,comment:h.comment||"",unixPermissions:h.unixPermissions,dosPermissions:h.dosPermissions}).pipe(m)}),m.entriesCount=f}catch(p){m.error(p)}return m}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,s,r){function i(){if(!(this instanceof i))return new i;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new i;for(var o in this)typeof this[o]!="function"&&(a[o]=this[o]);return a}}(i.prototype=e("./object")).loadAsync=e("./load"),i.support=e("./support"),i.defaults=e("./defaults"),i.version="3.10.1",i.loadAsync=function(a,o){return new i().loadAsync(a,o)},i.external=e("./external"),s.exports=i},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,s,r){var i=e("./utils"),a=e("./external"),o=e("./utf8"),l=e("./zipEntries"),d=e("./stream/Crc32Probe"),m=e("./nodejsUtils");function f(p){return new a.Promise(function(h,b){var g=p.decompressed.getContentWorker().pipe(new d);g.on("error",function(v){b(v)}).on("end",function(){g.streamInfo.crc32!==p.decompressed.crc32?b(new Error("Corrupted zip : CRC32 mismatch")):h()}).resume()})}s.exports=function(p,h){var b=this;return h=i.extend(h||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),m.isNode&&m.isStream(p)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):i.prepareContent("the loaded zip file",p,!0,h.optimizedBinaryString,h.base64).then(function(g){var v=new l(h);return v.load(g),v}).then(function(g){var v=[a.Promise.resolve(g)],y=g.files;if(h.checkCRC32)for(var _=0;_<y.length;_++)v.push(f(y[_]));return a.Promise.all(v)}).then(function(g){for(var v=g.shift(),y=v.files,_=0;_<y.length;_++){var k=y[_],M=k.fileNameStr,w=i.resolve(k.fileNameStr);b.file(w,k.decompressed,{binary:!0,optimizedBinaryString:!0,date:k.date,dir:k.dir,comment:k.fileCommentStr.length?k.fileCommentStr:null,unixPermissions:k.unixPermissions,dosPermissions:k.dosPermissions,createFolders:h.createFolders}),k.dir||(b.file(w).unsafeOriginalName=M)}return v.zipComment.length&&(b.comment=v.zipComment),b})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,s,r){var i=e("../utils"),a=e("../stream/GenericWorker");function o(l,d){a.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(d)}i.inherits(o,a),o.prototype._bindStream=function(l){var d=this;(this._stream=l).pause(),l.on("data",function(m){d.push({data:m,meta:{percent:0}})}).on("error",function(m){d.isPaused?this.generatedError=m:d.error(m)}).on("end",function(){d.isPaused?d._upstreamEnded=!0:d.end()})},o.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},s.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,s,r){var i=e("readable-stream").Readable;function a(o,l,d){i.call(this,l),this._helper=o;var m=this;o.on("data",function(f,p){m.push(f)||m._helper.pause(),d&&d(p)}).on("error",function(f){m.emit("error",f)}).on("end",function(){m.push(null)})}e("../utils").inherits(a,i),a.prototype._read=function(){this._helper.resume()},s.exports=a},{"../utils":32,"readable-stream":16}],14:[function(e,s,r){s.exports={isNode:typeof Buffer<"u",newBufferFrom:function(i,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(i,a);if(typeof i=="number")throw new Error('The "data" argument must not be a number');return new Buffer(i,a)},allocBuffer:function(i){if(Buffer.alloc)return Buffer.alloc(i);var a=new Buffer(i);return a.fill(0),a},isBuffer:function(i){return Buffer.isBuffer(i)},isStream:function(i){return i&&typeof i.on=="function"&&typeof i.pause=="function"&&typeof i.resume=="function"}}},{}],15:[function(e,s,r){function i(w,T,P){var j,C=o.getTypeOf(T),L=o.extend(P||{},m);L.date=L.date||new Date,L.compression!==null&&(L.compression=L.compression.toUpperCase()),typeof L.unixPermissions=="string"&&(L.unixPermissions=parseInt(L.unixPermissions,8)),L.unixPermissions&&16384&L.unixPermissions&&(L.dir=!0),L.dosPermissions&&16&L.dosPermissions&&(L.dir=!0),L.dir&&(w=y(w)),L.createFolders&&(j=v(w))&&_.call(this,j,!0);var V=C==="string"&&L.binary===!1&&L.base64===!1;P&&P.binary!==void 0||(L.binary=!V),(T instanceof f&&T.uncompressedSize===0||L.dir||!T||T.length===0)&&(L.base64=!1,L.binary=!0,T="",L.compression="STORE",C="string");var A=null;A=T instanceof f||T instanceof l?T:b.isNode&&b.isStream(T)?new g(w,T):o.prepareContent(w,T,L.binary,L.optimizedBinaryString,L.base64);var N=new p(w,A,L);this.files[w]=N}var a=e("./utf8"),o=e("./utils"),l=e("./stream/GenericWorker"),d=e("./stream/StreamHelper"),m=e("./defaults"),f=e("./compressedObject"),p=e("./zipObject"),h=e("./generate"),b=e("./nodejsUtils"),g=e("./nodejs/NodejsStreamInputAdapter"),v=function(w){w.slice(-1)==="/"&&(w=w.substring(0,w.length-1));var T=w.lastIndexOf("/");return 0<T?w.substring(0,T):""},y=function(w){return w.slice(-1)!=="/"&&(w+="/"),w},_=function(w,T){return T=T!==void 0?T:m.createFolders,w=y(w),this.files[w]||i.call(this,w,null,{dir:!0,createFolders:T}),this.files[w]};function k(w){return Object.prototype.toString.call(w)==="[object RegExp]"}var M={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(w){var T,P,j;for(T in this.files)j=this.files[T],(P=T.slice(this.root.length,T.length))&&T.slice(0,this.root.length)===this.root&&w(P,j)},filter:function(w){var T=[];return this.forEach(function(P,j){w(P,j)&&T.push(j)}),T},file:function(w,T,P){if(arguments.length!==1)return w=this.root+w,i.call(this,w,T,P),this;if(k(w)){var j=w;return this.filter(function(L,V){return!V.dir&&j.test(L)})}var C=this.files[this.root+w];return C&&!C.dir?C:null},folder:function(w){if(!w)return this;if(k(w))return this.filter(function(C,L){return L.dir&&w.test(C)});var T=this.root+w,P=_.call(this,T),j=this.clone();return j.root=P.name,j},remove:function(w){w=this.root+w;var T=this.files[w];if(T||(w.slice(-1)!=="/"&&(w+="/"),T=this.files[w]),T&&!T.dir)delete this.files[w];else for(var P=this.filter(function(C,L){return L.name.slice(0,w.length)===w}),j=0;j<P.length;j++)delete this.files[P[j].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(w){var T,P={};try{if((P=o.extend(w||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=P.type.toLowerCase(),P.compression=P.compression.toUpperCase(),P.type==="binarystring"&&(P.type="string"),!P.type)throw new Error("No output type specified.");o.checkSupport(P.type),P.platform!=="darwin"&&P.platform!=="freebsd"&&P.platform!=="linux"&&P.platform!=="sunos"||(P.platform="UNIX"),P.platform==="win32"&&(P.platform="DOS");var j=P.comment||this.comment||"";T=h.generateWorker(this,P,j)}catch(C){(T=new l("error")).error(C)}return new d(T,P.type||"string",P.mimeType)},generateAsync:function(w,T){return this.generateInternalStream(w).accumulate(T)},generateNodeStream:function(w,T){return(w=w||{}).type||(w.type="nodebuffer"),this.generateInternalStream(w).toNodejsStream(T)}};s.exports=M},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(e,s,r){s.exports=e("stream")},{stream:void 0}],17:[function(e,s,r){var i=e("./DataReader");function a(o){i.call(this,o);for(var l=0;l<this.data.length;l++)o[l]=255&o[l]}e("../utils").inherits(a,i),a.prototype.byteAt=function(o){return this.data[this.zero+o]},a.prototype.lastIndexOfSignature=function(o){for(var l=o.charCodeAt(0),d=o.charCodeAt(1),m=o.charCodeAt(2),f=o.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===l&&this.data[p+1]===d&&this.data[p+2]===m&&this.data[p+3]===f)return p-this.zero;return-1},a.prototype.readAndCheckSignature=function(o){var l=o.charCodeAt(0),d=o.charCodeAt(1),m=o.charCodeAt(2),f=o.charCodeAt(3),p=this.readData(4);return l===p[0]&&d===p[1]&&m===p[2]&&f===p[3]},a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},s.exports=a},{"../utils":32,"./DataReader":18}],18:[function(e,s,r){var i=e("../utils");function a(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var l,d=0;for(this.checkOffset(o),l=this.index+o-1;l>=this.index;l--)d=(d<<8)+this.byteAt(l);return this.index+=o,d},readString:function(o){return i.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},s.exports=a},{"../utils":32}],19:[function(e,s,r){var i=e("./Uint8ArrayReader");function a(o){i.call(this,o)}e("../utils").inherits(a,i),a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},s.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,s,r){var i=e("./DataReader");function a(o){i.call(this,o)}e("../utils").inherits(a,i),a.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},a.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},a.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},s.exports=a},{"../utils":32,"./DataReader":18}],21:[function(e,s,r){var i=e("./ArrayReader");function a(o){i.call(this,o)}e("../utils").inherits(a,i),a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},s.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(e,s,r){var i=e("../utils"),a=e("../support"),o=e("./ArrayReader"),l=e("./StringReader"),d=e("./NodeBufferReader"),m=e("./Uint8ArrayReader");s.exports=function(f){var p=i.getTypeOf(f);return i.checkSupport(p),p!=="string"||a.uint8array?p==="nodebuffer"?new d(f):a.uint8array?new m(i.transformTo("uint8array",f)):new o(i.transformTo("array",f)):new l(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,s,r){r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(e,s,r){var i=e("./GenericWorker"),a=e("../utils");function o(l){i.call(this,"ConvertWorker to "+l),this.destType=l}a.inherits(o,i),o.prototype.processChunk=function(l){this.push({data:a.transformTo(this.destType,l.data),meta:l.meta})},s.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(e,s,r){var i=e("./GenericWorker"),a=e("../crc32");function o(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(o,i),o.prototype.processChunk=function(l){this.streamInfo.crc32=a(l.data,this.streamInfo.crc32||0),this.push(l)},s.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,s,r){var i=e("../utils"),a=e("./GenericWorker");function o(l){a.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}i.inherits(o,a),o.prototype.processChunk=function(l){if(l){var d=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=d+l.data.length}a.prototype.processChunk.call(this,l)},s.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(e,s,r){var i=e("../utils"),a=e("./GenericWorker");function o(l){a.call(this,"DataWorker");var d=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(m){d.dataIsReady=!0,d.data=m,d.max=m&&m.length||0,d.type=i.getTypeOf(m),d.isPaused||d._tickAndRepeat()},function(m){d.error(m)})}i.inherits(o,a),o.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,d=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,d);break;case"uint8array":l=this.data.subarray(this.index,d);break;case"array":case"nodebuffer":l=this.data.slice(this.index,d)}return this.index=d,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},s.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(e,s,r){function i(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,o){return this._listeners[a].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,o){if(this._listeners[a])for(var l=0;l<this._listeners[a].length;l++)this._listeners[a][l].call(this,o)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var o=this;return a.on("data",function(l){o.processChunk(l)}),a.on("end",function(){o.end()}),a.on("error",function(l){o.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,o){return this.extraStreamInfo[a]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},s.exports=i},{}],29:[function(e,s,r){var i=e("../utils"),a=e("./ConvertWorker"),o=e("./GenericWorker"),l=e("../base64"),d=e("../support"),m=e("../external"),f=null;if(d.nodestream)try{f=e("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(b,g){return new m.Promise(function(v,y){var _=[],k=b._internalType,M=b._outputType,w=b._mimeType;b.on("data",function(T,P){_.push(T),g&&g(P)}).on("error",function(T){_=[],y(T)}).on("end",function(){try{var T=(function(P,j,C){switch(P){case"blob":return i.newBlob(i.transformTo("arraybuffer",j),C);case"base64":return l.encode(j);default:return i.transformTo(P,j)}})(M,(function(P,j){var C,L=0,V=null,A=0;for(C=0;C<j.length;C++)A+=j[C].length;switch(P){case"string":return j.join("");case"array":return Array.prototype.concat.apply([],j);case"uint8array":for(V=new Uint8Array(A),C=0;C<j.length;C++)V.set(j[C],L),L+=j[C].length;return V;case"nodebuffer":return Buffer.concat(j);default:throw new Error("concat : unsupported type '"+P+"'")}})(k,_),w);v(T)}catch(P){y(P)}_=[]}).resume()})}function h(b,g,v){var y=g;switch(g){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=g,this._mimeType=v,i.checkSupport(y),this._worker=b.pipe(new a(y)),b.lock()}catch(_){this._worker=new o("error"),this._worker.error(_)}}h.prototype={accumulate:function(b){return p(this,b)},on:function(b,g){var v=this;return b==="data"?this._worker.on(b,function(y){g.call(v,y.data,y.meta)}):this._worker.on(b,function(){i.delay(g,arguments,v)}),this},resume:function(){return i.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(b){if(i.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},b)}},s.exports=h},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,s,r){if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",r.nodebuffer=typeof Buffer<"u",r.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")r.blob=!1;else{var i=new ArrayBuffer(0);try{r.blob=new Blob([i],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(i),r.blob=a.getBlob("application/zip").size===0}catch{r.blob=!1}}}try{r.nodestream=!!e("readable-stream").Readable}catch{r.nodestream=!1}},{"readable-stream":16}],31:[function(e,s,r){for(var i=e("./utils"),a=e("./support"),o=e("./nodejsUtils"),l=e("./stream/GenericWorker"),d=new Array(256),m=0;m<256;m++)d[m]=252<=m?6:248<=m?5:240<=m?4:224<=m?3:192<=m?2:1;d[254]=d[254]=1;function f(){l.call(this,"utf-8 decode"),this.leftOver=null}function p(){l.call(this,"utf-8 encode")}r.utf8encode=function(h){return a.nodebuffer?o.newBufferFrom(h,"utf-8"):(function(b){var g,v,y,_,k,M=b.length,w=0;for(_=0;_<M;_++)(64512&(v=b.charCodeAt(_)))==55296&&_+1<M&&(64512&(y=b.charCodeAt(_+1)))==56320&&(v=65536+(v-55296<<10)+(y-56320),_++),w+=v<128?1:v<2048?2:v<65536?3:4;for(g=a.uint8array?new Uint8Array(w):new Array(w),_=k=0;k<w;_++)(64512&(v=b.charCodeAt(_)))==55296&&_+1<M&&(64512&(y=b.charCodeAt(_+1)))==56320&&(v=65536+(v-55296<<10)+(y-56320),_++),v<128?g[k++]=v:(v<2048?g[k++]=192|v>>>6:(v<65536?g[k++]=224|v>>>12:(g[k++]=240|v>>>18,g[k++]=128|v>>>12&63),g[k++]=128|v>>>6&63),g[k++]=128|63&v);return g})(h)},r.utf8decode=function(h){return a.nodebuffer?i.transformTo("nodebuffer",h).toString("utf-8"):(function(b){var g,v,y,_,k=b.length,M=new Array(2*k);for(g=v=0;g<k;)if((y=b[g++])<128)M[v++]=y;else if(4<(_=d[y]))M[v++]=65533,g+=_-1;else{for(y&=_===2?31:_===3?15:7;1<_&&g<k;)y=y<<6|63&b[g++],_--;1<_?M[v++]=65533:y<65536?M[v++]=y:(y-=65536,M[v++]=55296|y>>10&1023,M[v++]=56320|1023&y)}return M.length!==v&&(M.subarray?M=M.subarray(0,v):M.length=v),i.applyFromCharCode(M)})(h=i.transformTo(a.uint8array?"uint8array":"array",h))},i.inherits(f,l),f.prototype.processChunk=function(h){var b=i.transformTo(a.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var g=b;(b=new Uint8Array(g.length+this.leftOver.length)).set(this.leftOver,0),b.set(g,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var v=(function(_,k){var M;for((k=k||_.length)>_.length&&(k=_.length),M=k-1;0<=M&&(192&_[M])==128;)M--;return M<0||M===0?k:M+d[_[M]]>k?M:k})(b),y=b;v!==b.length&&(a.uint8array?(y=b.subarray(0,v),this.leftOver=b.subarray(v,b.length)):(y=b.slice(0,v),this.leftOver=b.slice(v,b.length))),this.push({data:r.utf8decode(y),meta:h.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=f,i.inherits(p,l),p.prototype.processChunk=function(h){this.push({data:r.utf8encode(h.data),meta:h.meta})},r.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,s,r){var i=e("./support"),a=e("./base64"),o=e("./nodejsUtils"),l=e("./external");function d(g){return g}function m(g,v){for(var y=0;y<g.length;++y)v[y]=255&g.charCodeAt(y);return v}e("setimmediate"),r.newBlob=function(g,v){r.checkSupport("blob");try{return new Blob([g],{type:v})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(g),y.getBlob(v)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(g,v,y){var _=[],k=0,M=g.length;if(M<=y)return String.fromCharCode.apply(null,g);for(;k<M;)v==="array"||v==="nodebuffer"?_.push(String.fromCharCode.apply(null,g.slice(k,Math.min(k+y,M)))):_.push(String.fromCharCode.apply(null,g.subarray(k,Math.min(k+y,M)))),k+=y;return _.join("")},stringifyByChar:function(g){for(var v="",y=0;y<g.length;y++)v+=String.fromCharCode(g[y]);return v},applyCanBeUsed:{uint8array:(function(){try{return i.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return i.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}})()}};function p(g){var v=65536,y=r.getTypeOf(g),_=!0;if(y==="uint8array"?_=f.applyCanBeUsed.uint8array:y==="nodebuffer"&&(_=f.applyCanBeUsed.nodebuffer),_)for(;1<v;)try{return f.stringifyByChunk(g,y,v)}catch{v=Math.floor(v/2)}return f.stringifyByChar(g)}function h(g,v){for(var y=0;y<g.length;y++)v[y]=g[y];return v}r.applyFromCharCode=p;var b={};b.string={string:d,array:function(g){return m(g,new Array(g.length))},arraybuffer:function(g){return b.string.uint8array(g).buffer},uint8array:function(g){return m(g,new Uint8Array(g.length))},nodebuffer:function(g){return m(g,o.allocBuffer(g.length))}},b.array={string:p,array:d,arraybuffer:function(g){return new Uint8Array(g).buffer},uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return o.newBufferFrom(g)}},b.arraybuffer={string:function(g){return p(new Uint8Array(g))},array:function(g){return h(new Uint8Array(g),new Array(g.byteLength))},arraybuffer:d,uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return o.newBufferFrom(new Uint8Array(g))}},b.uint8array={string:p,array:function(g){return h(g,new Array(g.length))},arraybuffer:function(g){return g.buffer},uint8array:d,nodebuffer:function(g){return o.newBufferFrom(g)}},b.nodebuffer={string:p,array:function(g){return h(g,new Array(g.length))},arraybuffer:function(g){return b.nodebuffer.uint8array(g).buffer},uint8array:function(g){return h(g,new Uint8Array(g.length))},nodebuffer:d},r.transformTo=function(g,v){if(v=v||"",!g)return v;r.checkSupport(g);var y=r.getTypeOf(v);return b[y][g](v)},r.resolve=function(g){for(var v=g.split("/"),y=[],_=0;_<v.length;_++){var k=v[_];k==="."||k===""&&_!==0&&_!==v.length-1||(k===".."?y.pop():y.push(k))}return y.join("/")},r.getTypeOf=function(g){return typeof g=="string"?"string":Object.prototype.toString.call(g)==="[object Array]"?"array":i.nodebuffer&&o.isBuffer(g)?"nodebuffer":i.uint8array&&g instanceof Uint8Array?"uint8array":i.arraybuffer&&g instanceof ArrayBuffer?"arraybuffer":void 0},r.checkSupport=function(g){if(!i[g.toLowerCase()])throw new Error(g+" is not supported by this platform")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(g){var v,y,_="";for(y=0;y<(g||"").length;y++)_+="\\x"+((v=g.charCodeAt(y))<16?"0":"")+v.toString(16).toUpperCase();return _},r.delay=function(g,v,y){setImmediate(function(){g.apply(y||null,v||[])})},r.inherits=function(g,v){function y(){}y.prototype=v.prototype,g.prototype=new y},r.extend=function(){var g,v,y={};for(g=0;g<arguments.length;g++)for(v in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],v)&&y[v]===void 0&&(y[v]=arguments[g][v]);return y},r.prepareContent=function(g,v,y,_,k){return l.Promise.resolve(v).then(function(M){return i.blob&&(M instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(M))!==-1)&&typeof FileReader<"u"?new l.Promise(function(w,T){var P=new FileReader;P.onload=function(j){w(j.target.result)},P.onerror=function(j){T(j.target.error)},P.readAsArrayBuffer(M)}):M}).then(function(M){var w=r.getTypeOf(M);return w?(w==="arraybuffer"?M=r.transformTo("uint8array",M):w==="string"&&(k?M=a.decode(M):y&&_!==!0&&(M=(function(T){return m(T,i.uint8array?new Uint8Array(T.length):new Array(T.length))})(M))),M):l.Promise.reject(new Error("Can't read the data of '"+g+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,s,r){var i=e("./reader/readerFor"),a=e("./utils"),o=e("./signature"),l=e("./zipEntry"),d=e("./support");function m(f){this.files=[],this.loadOptions=f}m.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(p)+", expected "+a.pretty(f)+")")}},isSignature:function(f,p){var h=this.reader.index;this.reader.setIndex(f);var b=this.reader.readString(4)===p;return this.reader.setIndex(h),b},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),p=d.uint8array?"uint8array":"array",h=a.transformTo(p,f);this.zipComment=this.loadOptions.decodeFileName(h)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,p,h,b=this.zip64EndOfCentralSize-44;0<b;)f=this.reader.readInt(2),p=this.reader.readInt(4),h=this.reader.readData(p),this.zip64ExtensibleData[f]={id:f,length:p,value:h}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,p;for(f=0;f<this.files.length;f++)p=this.files[f],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(f=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var p=f;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var h=this.centralDirOffset+this.centralDirSize;this.zip64&&(h+=20,h+=12+this.zip64EndOfCentralSize);var b=p-h;if(0<b)this.isSignature(p,o.CENTRAL_FILE_HEADER)||(this.reader.zero=b);else if(b<0)throw new Error("Corrupted zip: missing "+Math.abs(b)+" bytes.")},prepareReader:function(f){this.reader=i(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},s.exports=m},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,s,r){var i=e("./reader/readerFor"),a=e("./utils"),o=e("./compressedObject"),l=e("./crc32"),d=e("./utf8"),m=e("./compressions"),f=e("./support");function p(h,b){this.options=h,this.loadOptions=b}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(h){var b,g;if(h.skip(22),this.fileNameLength=h.readInt(2),g=h.readInt(2),this.fileName=h.readData(this.fileNameLength),h.skip(g),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((b=(function(v){for(var y in m)if(Object.prototype.hasOwnProperty.call(m,y)&&m[y].magic===v)return m[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,b,h.readData(this.compressedSize))},readCentralPart:function(h){this.versionMadeBy=h.readInt(2),h.skip(2),this.bitFlag=h.readInt(2),this.compressionMethod=h.readString(2),this.date=h.readDate(),this.crc32=h.readInt(4),this.compressedSize=h.readInt(4),this.uncompressedSize=h.readInt(4);var b=h.readInt(2);if(this.extraFieldsLength=h.readInt(2),this.fileCommentLength=h.readInt(2),this.diskNumberStart=h.readInt(2),this.internalFileAttributes=h.readInt(2),this.externalFileAttributes=h.readInt(4),this.localHeaderOffset=h.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");h.skip(b),this.readExtraFields(h),this.parseZIP64ExtraField(h),this.fileComment=h.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var h=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=i(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var b,g,v,y=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4<y;)b=h.readInt(2),g=h.readInt(2),v=h.readData(g),this.extraFields[b]={id:b,length:g,value:v};h.setIndex(y)},handleUTF8:function(){var h=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=d.utf8decode(this.fileName),this.fileCommentStr=d.utf8decode(this.fileComment);else{var b=this.findExtraFieldUnicodePath();if(b!==null)this.fileNameStr=b;else{var g=a.transformTo(h,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var v=this.findExtraFieldUnicodeComment();if(v!==null)this.fileCommentStr=v;else{var y=a.transformTo(h,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var h=this.extraFields[28789];if(h){var b=i(h.value);return b.readInt(1)!==1||l(this.fileName)!==b.readInt(4)?null:d.utf8decode(b.readData(h.length-5))}return null},findExtraFieldUnicodeComment:function(){var h=this.extraFields[25461];if(h){var b=i(h.value);return b.readInt(1)!==1||l(this.fileComment)!==b.readInt(4)?null:d.utf8decode(b.readData(h.length-5))}return null}},s.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,s,r){function i(b,g,v){this.name=b,this.dir=v.dir,this.date=v.date,this.comment=v.comment,this.unixPermissions=v.unixPermissions,this.dosPermissions=v.dosPermissions,this._data=g,this._dataBinary=v.binary,this.options={compression:v.compression,compressionOptions:v.compressionOptions}}var a=e("./stream/StreamHelper"),o=e("./stream/DataWorker"),l=e("./utf8"),d=e("./compressedObject"),m=e("./stream/GenericWorker");i.prototype={internalStream:function(b){var g=null,v="string";try{if(!b)throw new Error("No output type specified.");var y=(v=b.toLowerCase())==="string"||v==="text";v!=="binarystring"&&v!=="text"||(v="string"),g=this._decompressWorker();var _=!this._dataBinary;_&&!y&&(g=g.pipe(new l.Utf8EncodeWorker)),!_&&y&&(g=g.pipe(new l.Utf8DecodeWorker))}catch(k){(g=new m("error")).error(k)}return new a(g,v,"")},async:function(b,g){return this.internalStream(b).accumulate(g)},nodeStream:function(b,g){return this.internalStream(b||"nodebuffer").toNodejsStream(g)},_compressWorker:function(b,g){if(this._data instanceof d&&this._data.compression.magic===b.magic)return this._data.getCompressedWorker();var v=this._decompressWorker();return this._dataBinary||(v=v.pipe(new l.Utf8EncodeWorker)),d.createWorkerFrom(v,b,g)},_decompressWorker:function(){return this._data instanceof d?this._data.getContentWorker():this._data instanceof m?this._data:new o(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<f.length;h++)i.prototype[f[h]]=p;s.exports=i},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,s,r){(function(i){var a,o,l=i.MutationObserver||i.WebKitMutationObserver;if(l){var d=0,m=new l(b),f=i.document.createTextNode("");m.observe(f,{characterData:!0}),a=function(){f.data=d=++d%2}}else if(i.setImmediate||i.MessageChannel===void 0)a="document"in i&&"onreadystatechange"in i.document.createElement("script")?function(){var g=i.document.createElement("script");g.onreadystatechange=function(){b(),g.onreadystatechange=null,g.parentNode.removeChild(g),g=null},i.document.documentElement.appendChild(g)}:function(){setTimeout(b,0)};else{var p=new i.MessageChannel;p.port1.onmessage=b,a=function(){p.port2.postMessage(0)}}var h=[];function b(){var g,v;o=!0;for(var y=h.length;y;){for(v=h,h=[],g=-1;++g<y;)v[g]();y=h.length}o=!1}s.exports=function(g){h.push(g)!==1||o||a()}}).call(this,typeof xn<"u"?xn:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(e,s,r){var i=e("immediate");function a(){}var o={},l=["REJECTED"],d=["FULFILLED"],m=["PENDING"];function f(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=m,this.queue=[],this.outcome=void 0,y!==a&&g(this,y)}function p(y,_,k){this.promise=y,typeof _=="function"&&(this.onFulfilled=_,this.callFulfilled=this.otherCallFulfilled),typeof k=="function"&&(this.onRejected=k,this.callRejected=this.otherCallRejected)}function h(y,_,k){i(function(){var M;try{M=_(k)}catch(w){return o.reject(y,w)}M===y?o.reject(y,new TypeError("Cannot resolve promise with itself")):o.resolve(y,M)})}function b(y){var _=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof _=="function")return function(){_.apply(y,arguments)}}function g(y,_){var k=!1;function M(P){k||(k=!0,o.reject(y,P))}function w(P){k||(k=!0,o.resolve(y,P))}var T=v(function(){_(w,M)});T.status==="error"&&M(T.value)}function v(y,_){var k={};try{k.value=y(_),k.status="success"}catch(M){k.status="error",k.value=M}return k}(s.exports=f).prototype.finally=function(y){if(typeof y!="function")return this;var _=this.constructor;return this.then(function(k){return _.resolve(y()).then(function(){return k})},function(k){return _.resolve(y()).then(function(){throw k})})},f.prototype.catch=function(y){return this.then(null,y)},f.prototype.then=function(y,_){if(typeof y!="function"&&this.state===d||typeof _!="function"&&this.state===l)return this;var k=new this.constructor(a);return this.state!==m?h(k,this.state===d?y:_,this.outcome):this.queue.push(new p(k,y,_)),k},p.prototype.callFulfilled=function(y){o.resolve(this.promise,y)},p.prototype.otherCallFulfilled=function(y){h(this.promise,this.onFulfilled,y)},p.prototype.callRejected=function(y){o.reject(this.promise,y)},p.prototype.otherCallRejected=function(y){h(this.promise,this.onRejected,y)},o.resolve=function(y,_){var k=v(b,_);if(k.status==="error")return o.reject(y,k.value);var M=k.value;if(M)g(y,M);else{y.state=d,y.outcome=_;for(var w=-1,T=y.queue.length;++w<T;)y.queue[w].callFulfilled(_)}return y},o.reject=function(y,_){y.state=l,y.outcome=_;for(var k=-1,M=y.queue.length;++k<M;)y.queue[k].callRejected(_);return y},f.resolve=function(y){return y instanceof this?y:o.resolve(new this(a),y)},f.reject=function(y){var _=new this(a);return o.reject(_,y)},f.all=function(y){var _=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var k=y.length,M=!1;if(!k)return this.resolve([]);for(var w=new Array(k),T=0,P=-1,j=new this(a);++P<k;)C(y[P],P);return j;function C(L,V){_.resolve(L).then(function(A){w[V]=A,++T!==k||M||(M=!0,o.resolve(j,w))},function(A){M||(M=!0,o.reject(j,A))})}},f.race=function(y){var _=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var k=y.length,M=!1;if(!k)return this.resolve([]);for(var w=-1,T=new this(a);++w<k;)P=y[w],_.resolve(P).then(function(j){M||(M=!0,o.resolve(T,j))},function(j){M||(M=!0,o.reject(T,j))});var P;return T}},{immediate:36}],38:[function(e,s,r){var i={};(0,e("./lib/utils/common").assign)(i,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),s.exports=i},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,s,r){var i=e("./zlib/deflate"),a=e("./utils/common"),o=e("./utils/strings"),l=e("./zlib/messages"),d=e("./zlib/zstream"),m=Object.prototype.toString,f=0,p=-1,h=0,b=8;function g(y){if(!(this instanceof g))return new g(y);this.options=a.assign({level:p,method:b,chunkSize:16384,windowBits:15,memLevel:8,strategy:h,to:""},y||{});var _=this.options;_.raw&&0<_.windowBits?_.windowBits=-_.windowBits:_.gzip&&0<_.windowBits&&_.windowBits<16&&(_.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var k=i.deflateInit2(this.strm,_.level,_.method,_.windowBits,_.memLevel,_.strategy);if(k!==f)throw new Error(l[k]);if(_.header&&i.deflateSetHeader(this.strm,_.header),_.dictionary){var M;if(M=typeof _.dictionary=="string"?o.string2buf(_.dictionary):m.call(_.dictionary)==="[object ArrayBuffer]"?new Uint8Array(_.dictionary):_.dictionary,(k=i.deflateSetDictionary(this.strm,M))!==f)throw new Error(l[k]);this._dict_set=!0}}function v(y,_){var k=new g(_);if(k.push(y,!0),k.err)throw k.msg||l[k.err];return k.result}g.prototype.push=function(y,_){var k,M,w=this.strm,T=this.options.chunkSize;if(this.ended)return!1;M=_===~~_?_:_===!0?4:0,typeof y=="string"?w.input=o.string2buf(y):m.call(y)==="[object ArrayBuffer]"?w.input=new Uint8Array(y):w.input=y,w.next_in=0,w.avail_in=w.input.length;do{if(w.avail_out===0&&(w.output=new a.Buf8(T),w.next_out=0,w.avail_out=T),(k=i.deflate(w,M))!==1&&k!==f)return this.onEnd(k),!(this.ended=!0);w.avail_out!==0&&(w.avail_in!==0||M!==4&&M!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(a.shrinkBuf(w.output,w.next_out))):this.onData(a.shrinkBuf(w.output,w.next_out)))}while((0<w.avail_in||w.avail_out===0)&&k!==1);return M===4?(k=i.deflateEnd(this.strm),this.onEnd(k),this.ended=!0,k===f):M!==2||(this.onEnd(f),!(w.avail_out=0))},g.prototype.onData=function(y){this.chunks.push(y)},g.prototype.onEnd=function(y){y===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},r.Deflate=g,r.deflate=v,r.deflateRaw=function(y,_){return(_=_||{}).raw=!0,v(y,_)},r.gzip=function(y,_){return(_=_||{}).gzip=!0,v(y,_)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,s,r){var i=e("./zlib/inflate"),a=e("./utils/common"),o=e("./utils/strings"),l=e("./zlib/constants"),d=e("./zlib/messages"),m=e("./zlib/zstream"),f=e("./zlib/gzheader"),p=Object.prototype.toString;function h(g){if(!(this instanceof h))return new h(g);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},g||{});var v=this.options;v.raw&&0<=v.windowBits&&v.windowBits<16&&(v.windowBits=-v.windowBits,v.windowBits===0&&(v.windowBits=-15)),!(0<=v.windowBits&&v.windowBits<16)||g&&g.windowBits||(v.windowBits+=32),15<v.windowBits&&v.windowBits<48&&(15&v.windowBits)==0&&(v.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new m,this.strm.avail_out=0;var y=i.inflateInit2(this.strm,v.windowBits);if(y!==l.Z_OK)throw new Error(d[y]);this.header=new f,i.inflateGetHeader(this.strm,this.header)}function b(g,v){var y=new h(v);if(y.push(g,!0),y.err)throw y.msg||d[y.err];return y.result}h.prototype.push=function(g,v){var y,_,k,M,w,T,P=this.strm,j=this.options.chunkSize,C=this.options.dictionary,L=!1;if(this.ended)return!1;_=v===~~v?v:v===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof g=="string"?P.input=o.binstring2buf(g):p.call(g)==="[object ArrayBuffer]"?P.input=new Uint8Array(g):P.input=g,P.next_in=0,P.avail_in=P.input.length;do{if(P.avail_out===0&&(P.output=new a.Buf8(j),P.next_out=0,P.avail_out=j),(y=i.inflate(P,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&C&&(T=typeof C=="string"?o.string2buf(C):p.call(C)==="[object ArrayBuffer]"?new Uint8Array(C):C,y=i.inflateSetDictionary(this.strm,T)),y===l.Z_BUF_ERROR&&L===!0&&(y=l.Z_OK,L=!1),y!==l.Z_STREAM_END&&y!==l.Z_OK)return this.onEnd(y),!(this.ended=!0);P.next_out&&(P.avail_out!==0&&y!==l.Z_STREAM_END&&(P.avail_in!==0||_!==l.Z_FINISH&&_!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(k=o.utf8border(P.output,P.next_out),M=P.next_out-k,w=o.buf2string(P.output,k),P.next_out=M,P.avail_out=j-M,M&&a.arraySet(P.output,P.output,k,M,0),this.onData(w)):this.onData(a.shrinkBuf(P.output,P.next_out)))),P.avail_in===0&&P.avail_out===0&&(L=!0)}while((0<P.avail_in||P.avail_out===0)&&y!==l.Z_STREAM_END);return y===l.Z_STREAM_END&&(_=l.Z_FINISH),_===l.Z_FINISH?(y=i.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===l.Z_OK):_!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(P.avail_out=0))},h.prototype.onData=function(g){this.chunks.push(g)},h.prototype.onEnd=function(g){g===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},r.Inflate=h,r.inflate=b,r.inflateRaw=function(g,v){return(v=v||{}).raw=!0,b(g,v)},r.ungzip=b},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,s,r){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";r.assign=function(l){for(var d=Array.prototype.slice.call(arguments,1);d.length;){var m=d.shift();if(m){if(typeof m!="object")throw new TypeError(m+"must be non-object");for(var f in m)m.hasOwnProperty(f)&&(l[f]=m[f])}}return l},r.shrinkBuf=function(l,d){return l.length===d?l:l.subarray?l.subarray(0,d):(l.length=d,l)};var a={arraySet:function(l,d,m,f,p){if(d.subarray&&l.subarray)l.set(d.subarray(m,m+f),p);else for(var h=0;h<f;h++)l[p+h]=d[m+h]},flattenChunks:function(l){var d,m,f,p,h,b;for(d=f=0,m=l.length;d<m;d++)f+=l[d].length;for(b=new Uint8Array(f),d=p=0,m=l.length;d<m;d++)h=l[d],b.set(h,p),p+=h.length;return b}},o={arraySet:function(l,d,m,f,p){for(var h=0;h<f;h++)l[p+h]=d[m+h]},flattenChunks:function(l){return[].concat.apply([],l)}};r.setTyped=function(l){l?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,a)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,o))},r.setTyped(i)},{}],42:[function(e,s,r){var i=e("./common"),a=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var l=new i.Buf8(256),d=0;d<256;d++)l[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;function m(f,p){if(p<65537&&(f.subarray&&o||!f.subarray&&a))return String.fromCharCode.apply(null,i.shrinkBuf(f,p));for(var h="",b=0;b<p;b++)h+=String.fromCharCode(f[b]);return h}l[254]=l[254]=1,r.string2buf=function(f){var p,h,b,g,v,y=f.length,_=0;for(g=0;g<y;g++)(64512&(h=f.charCodeAt(g)))==55296&&g+1<y&&(64512&(b=f.charCodeAt(g+1)))==56320&&(h=65536+(h-55296<<10)+(b-56320),g++),_+=h<128?1:h<2048?2:h<65536?3:4;for(p=new i.Buf8(_),g=v=0;v<_;g++)(64512&(h=f.charCodeAt(g)))==55296&&g+1<y&&(64512&(b=f.charCodeAt(g+1)))==56320&&(h=65536+(h-55296<<10)+(b-56320),g++),h<128?p[v++]=h:(h<2048?p[v++]=192|h>>>6:(h<65536?p[v++]=224|h>>>12:(p[v++]=240|h>>>18,p[v++]=128|h>>>12&63),p[v++]=128|h>>>6&63),p[v++]=128|63&h);return p},r.buf2binstring=function(f){return m(f,f.length)},r.binstring2buf=function(f){for(var p=new i.Buf8(f.length),h=0,b=p.length;h<b;h++)p[h]=f.charCodeAt(h);return p},r.buf2string=function(f,p){var h,b,g,v,y=p||f.length,_=new Array(2*y);for(h=b=0;h<y;)if((g=f[h++])<128)_[b++]=g;else if(4<(v=l[g]))_[b++]=65533,h+=v-1;else{for(g&=v===2?31:v===3?15:7;1<v&&h<y;)g=g<<6|63&f[h++],v--;1<v?_[b++]=65533:g<65536?_[b++]=g:(g-=65536,_[b++]=55296|g>>10&1023,_[b++]=56320|1023&g)}return m(_,b)},r.utf8border=function(f,p){var h;for((p=p||f.length)>f.length&&(p=f.length),h=p-1;0<=h&&(192&f[h])==128;)h--;return h<0||h===0?p:h+l[f[h]]>p?h:p}},{"./common":41}],43:[function(e,s,r){s.exports=function(i,a,o,l){for(var d=65535&i|0,m=i>>>16&65535|0,f=0;o!==0;){for(o-=f=2e3<o?2e3:o;m=m+(d=d+a[l++]|0)|0,--f;);d%=65521,m%=65521}return d|m<<16|0}},{}],44:[function(e,s,r){s.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(e,s,r){var i=(function(){for(var a,o=[],l=0;l<256;l++){a=l;for(var d=0;d<8;d++)a=1&a?3988292384^a>>>1:a>>>1;o[l]=a}return o})();s.exports=function(a,o,l,d){var m=i,f=d+l;a^=-1;for(var p=d;p<f;p++)a=a>>>8^m[255&(a^o[p])];return-1^a}},{}],46:[function(e,s,r){var i,a=e("../utils/common"),o=e("./trees"),l=e("./adler32"),d=e("./crc32"),m=e("./messages"),f=0,p=4,h=0,b=-2,g=-1,v=4,y=2,_=8,k=9,M=286,w=30,T=19,P=2*M+1,j=15,C=3,L=258,V=L+C+1,A=42,N=113,u=1,z=2,Q=3,W=4;function st(c,F){return c.msg=m[F],F}function $(c){return(c<<1)-(4<c?9:0)}function X(c){for(var F=c.length;0<=--F;)c[F]=0}function B(c){var F=c.state,D=F.pending;D>c.avail_out&&(D=c.avail_out),D!==0&&(a.arraySet(c.output,F.pending_buf,F.pending_out,D,c.next_out),c.next_out+=D,F.pending_out+=D,c.total_out+=D,c.avail_out-=D,F.pending-=D,F.pending===0&&(F.pending_out=0))}function R(c,F){o._tr_flush_block(c,0<=c.block_start?c.block_start:-1,c.strstart-c.block_start,F),c.block_start=c.strstart,B(c.strm)}function J(c,F){c.pending_buf[c.pending++]=F}function tt(c,F){c.pending_buf[c.pending++]=F>>>8&255,c.pending_buf[c.pending++]=255&F}function Y(c,F){var D,S,x=c.max_chain_length,E=c.strstart,H=c.prev_length,G=c.nice_match,O=c.strstart>c.w_size-V?c.strstart-(c.w_size-V):0,q=c.window,nt=c.w_mask,K=c.prev,rt=c.strstart+L,dt=q[E+H-1],ct=q[E+H];c.prev_length>=c.good_match&&(x>>=2),G>c.lookahead&&(G=c.lookahead);do if(q[(D=F)+H]===ct&&q[D+H-1]===dt&&q[D]===q[E]&&q[++D]===q[E+1]){E+=2,D++;do;while(q[++E]===q[++D]&&q[++E]===q[++D]&&q[++E]===q[++D]&&q[++E]===q[++D]&&q[++E]===q[++D]&&q[++E]===q[++D]&&q[++E]===q[++D]&&q[++E]===q[++D]&&E<rt);if(S=L-(rt-E),E=rt-L,H<S){if(c.match_start=F,G<=(H=S))break;dt=q[E+H-1],ct=q[E+H]}}while((F=K[F&nt])>O&&--x!=0);return H<=c.lookahead?H:c.lookahead}function pt(c){var F,D,S,x,E,H,G,O,q,nt,K=c.w_size;do{if(x=c.window_size-c.lookahead-c.strstart,c.strstart>=K+(K-V)){for(a.arraySet(c.window,c.window,K,K,0),c.match_start-=K,c.strstart-=K,c.block_start-=K,F=D=c.hash_size;S=c.head[--F],c.head[F]=K<=S?S-K:0,--D;);for(F=D=K;S=c.prev[--F],c.prev[F]=K<=S?S-K:0,--D;);x+=K}if(c.strm.avail_in===0)break;if(H=c.strm,G=c.window,O=c.strstart+c.lookahead,q=x,nt=void 0,nt=H.avail_in,q<nt&&(nt=q),D=nt===0?0:(H.avail_in-=nt,a.arraySet(G,H.input,H.next_in,nt,O),H.state.wrap===1?H.adler=l(H.adler,G,nt,O):H.state.wrap===2&&(H.adler=d(H.adler,G,nt,O)),H.next_in+=nt,H.total_in+=nt,nt),c.lookahead+=D,c.lookahead+c.insert>=C)for(E=c.strstart-c.insert,c.ins_h=c.window[E],c.ins_h=(c.ins_h<<c.hash_shift^c.window[E+1])&c.hash_mask;c.insert&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[E+C-1])&c.hash_mask,c.prev[E&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=E,E++,c.insert--,!(c.lookahead+c.insert<C)););}while(c.lookahead<V&&c.strm.avail_in!==0)}function wt(c,F){for(var D,S;;){if(c.lookahead<V){if(pt(c),c.lookahead<V&&F===f)return u;if(c.lookahead===0)break}if(D=0,c.lookahead>=C&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+C-1])&c.hash_mask,D=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart),D!==0&&c.strstart-D<=c.w_size-V&&(c.match_length=Y(c,D)),c.match_length>=C)if(S=o._tr_tally(c,c.strstart-c.match_start,c.match_length-C),c.lookahead-=c.match_length,c.match_length<=c.max_lazy_match&&c.lookahead>=C){for(c.match_length--;c.strstart++,c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+C-1])&c.hash_mask,D=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart,--c.match_length!=0;);c.strstart++}else c.strstart+=c.match_length,c.match_length=0,c.ins_h=c.window[c.strstart],c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+1])&c.hash_mask;else S=o._tr_tally(c,0,c.window[c.strstart]),c.lookahead--,c.strstart++;if(S&&(R(c,!1),c.strm.avail_out===0))return u}return c.insert=c.strstart<C-1?c.strstart:C-1,F===p?(R(c,!0),c.strm.avail_out===0?Q:W):c.last_lit&&(R(c,!1),c.strm.avail_out===0)?u:z}function ht(c,F){for(var D,S,x;;){if(c.lookahead<V){if(pt(c),c.lookahead<V&&F===f)return u;if(c.lookahead===0)break}if(D=0,c.lookahead>=C&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+C-1])&c.hash_mask,D=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart),c.prev_length=c.match_length,c.prev_match=c.match_start,c.match_length=C-1,D!==0&&c.prev_length<c.max_lazy_match&&c.strstart-D<=c.w_size-V&&(c.match_length=Y(c,D),c.match_length<=5&&(c.strategy===1||c.match_length===C&&4096<c.strstart-c.match_start)&&(c.match_length=C-1)),c.prev_length>=C&&c.match_length<=c.prev_length){for(x=c.strstart+c.lookahead-C,S=o._tr_tally(c,c.strstart-1-c.prev_match,c.prev_length-C),c.lookahead-=c.prev_length-1,c.prev_length-=2;++c.strstart<=x&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+C-1])&c.hash_mask,D=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart),--c.prev_length!=0;);if(c.match_available=0,c.match_length=C-1,c.strstart++,S&&(R(c,!1),c.strm.avail_out===0))return u}else if(c.match_available){if((S=o._tr_tally(c,0,c.window[c.strstart-1]))&&R(c,!1),c.strstart++,c.lookahead--,c.strm.avail_out===0)return u}else c.match_available=1,c.strstart++,c.lookahead--}return c.match_available&&(S=o._tr_tally(c,0,c.window[c.strstart-1]),c.match_available=0),c.insert=c.strstart<C-1?c.strstart:C-1,F===p?(R(c,!0),c.strm.avail_out===0?Q:W):c.last_lit&&(R(c,!1),c.strm.avail_out===0)?u:z}function ut(c,F,D,S,x){this.good_length=c,this.max_lazy=F,this.nice_length=D,this.max_chain=S,this.func=x}function yt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=_,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*P),this.dyn_dtree=new a.Buf16(2*(2*w+1)),this.bl_tree=new a.Buf16(2*(2*T+1)),X(this.dyn_ltree),X(this.dyn_dtree),X(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(j+1),this.heap=new a.Buf16(2*M+1),X(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*M+1),X(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Z(c){var F;return c&&c.state?(c.total_in=c.total_out=0,c.data_type=y,(F=c.state).pending=0,F.pending_out=0,F.wrap<0&&(F.wrap=-F.wrap),F.status=F.wrap?A:N,c.adler=F.wrap===2?0:1,F.last_flush=f,o._tr_init(F),h):st(c,b)}function et(c){var F=Z(c);return F===h&&(function(D){D.window_size=2*D.w_size,X(D.head),D.max_lazy_match=i[D.level].max_lazy,D.good_match=i[D.level].good_length,D.nice_match=i[D.level].nice_length,D.max_chain_length=i[D.level].max_chain,D.strstart=0,D.block_start=0,D.lookahead=0,D.insert=0,D.match_length=D.prev_length=C-1,D.match_available=0,D.ins_h=0})(c.state),F}function it(c,F,D,S,x,E){if(!c)return b;var H=1;if(F===g&&(F=6),S<0?(H=0,S=-S):15<S&&(H=2,S-=16),x<1||k<x||D!==_||S<8||15<S||F<0||9<F||E<0||v<E)return st(c,b);S===8&&(S=9);var G=new yt;return(c.state=G).strm=c,G.wrap=H,G.gzhead=null,G.w_bits=S,G.w_size=1<<G.w_bits,G.w_mask=G.w_size-1,G.hash_bits=x+7,G.hash_size=1<<G.hash_bits,G.hash_mask=G.hash_size-1,G.hash_shift=~~((G.hash_bits+C-1)/C),G.window=new a.Buf8(2*G.w_size),G.head=new a.Buf16(G.hash_size),G.prev=new a.Buf16(G.w_size),G.lit_bufsize=1<<x+6,G.pending_buf_size=4*G.lit_bufsize,G.pending_buf=new a.Buf8(G.pending_buf_size),G.d_buf=1*G.lit_bufsize,G.l_buf=3*G.lit_bufsize,G.level=F,G.strategy=E,G.method=D,et(c)}i=[new ut(0,0,0,0,function(c,F){var D=65535;for(D>c.pending_buf_size-5&&(D=c.pending_buf_size-5);;){if(c.lookahead<=1){if(pt(c),c.lookahead===0&&F===f)return u;if(c.lookahead===0)break}c.strstart+=c.lookahead,c.lookahead=0;var S=c.block_start+D;if((c.strstart===0||c.strstart>=S)&&(c.lookahead=c.strstart-S,c.strstart=S,R(c,!1),c.strm.avail_out===0)||c.strstart-c.block_start>=c.w_size-V&&(R(c,!1),c.strm.avail_out===0))return u}return c.insert=0,F===p?(R(c,!0),c.strm.avail_out===0?Q:W):(c.strstart>c.block_start&&(R(c,!1),c.strm.avail_out),u)}),new ut(4,4,8,4,wt),new ut(4,5,16,8,wt),new ut(4,6,32,32,wt),new ut(4,4,16,16,ht),new ut(8,16,32,32,ht),new ut(8,16,128,128,ht),new ut(8,32,128,256,ht),new ut(32,128,258,1024,ht),new ut(32,258,258,4096,ht)],r.deflateInit=function(c,F){return it(c,F,_,15,8,0)},r.deflateInit2=it,r.deflateReset=et,r.deflateResetKeep=Z,r.deflateSetHeader=function(c,F){return c&&c.state?c.state.wrap!==2?b:(c.state.gzhead=F,h):b},r.deflate=function(c,F){var D,S,x,E;if(!c||!c.state||5<F||F<0)return c?st(c,b):b;if(S=c.state,!c.output||!c.input&&c.avail_in!==0||S.status===666&&F!==p)return st(c,c.avail_out===0?-5:b);if(S.strm=c,D=S.last_flush,S.last_flush=F,S.status===A)if(S.wrap===2)c.adler=0,J(S,31),J(S,139),J(S,8),S.gzhead?(J(S,(S.gzhead.text?1:0)+(S.gzhead.hcrc?2:0)+(S.gzhead.extra?4:0)+(S.gzhead.name?8:0)+(S.gzhead.comment?16:0)),J(S,255&S.gzhead.time),J(S,S.gzhead.time>>8&255),J(S,S.gzhead.time>>16&255),J(S,S.gzhead.time>>24&255),J(S,S.level===9?2:2<=S.strategy||S.level<2?4:0),J(S,255&S.gzhead.os),S.gzhead.extra&&S.gzhead.extra.length&&(J(S,255&S.gzhead.extra.length),J(S,S.gzhead.extra.length>>8&255)),S.gzhead.hcrc&&(c.adler=d(c.adler,S.pending_buf,S.pending,0)),S.gzindex=0,S.status=69):(J(S,0),J(S,0),J(S,0),J(S,0),J(S,0),J(S,S.level===9?2:2<=S.strategy||S.level<2?4:0),J(S,3),S.status=N);else{var H=_+(S.w_bits-8<<4)<<8;H|=(2<=S.strategy||S.level<2?0:S.level<6?1:S.level===6?2:3)<<6,S.strstart!==0&&(H|=32),H+=31-H%31,S.status=N,tt(S,H),S.strstart!==0&&(tt(S,c.adler>>>16),tt(S,65535&c.adler)),c.adler=1}if(S.status===69)if(S.gzhead.extra){for(x=S.pending;S.gzindex<(65535&S.gzhead.extra.length)&&(S.pending!==S.pending_buf_size||(S.gzhead.hcrc&&S.pending>x&&(c.adler=d(c.adler,S.pending_buf,S.pending-x,x)),B(c),x=S.pending,S.pending!==S.pending_buf_size));)J(S,255&S.gzhead.extra[S.gzindex]),S.gzindex++;S.gzhead.hcrc&&S.pending>x&&(c.adler=d(c.adler,S.pending_buf,S.pending-x,x)),S.gzindex===S.gzhead.extra.length&&(S.gzindex=0,S.status=73)}else S.status=73;if(S.status===73)if(S.gzhead.name){x=S.pending;do{if(S.pending===S.pending_buf_size&&(S.gzhead.hcrc&&S.pending>x&&(c.adler=d(c.adler,S.pending_buf,S.pending-x,x)),B(c),x=S.pending,S.pending===S.pending_buf_size)){E=1;break}E=S.gzindex<S.gzhead.name.length?255&S.gzhead.name.charCodeAt(S.gzindex++):0,J(S,E)}while(E!==0);S.gzhead.hcrc&&S.pending>x&&(c.adler=d(c.adler,S.pending_buf,S.pending-x,x)),E===0&&(S.gzindex=0,S.status=91)}else S.status=91;if(S.status===91)if(S.gzhead.comment){x=S.pending;do{if(S.pending===S.pending_buf_size&&(S.gzhead.hcrc&&S.pending>x&&(c.adler=d(c.adler,S.pending_buf,S.pending-x,x)),B(c),x=S.pending,S.pending===S.pending_buf_size)){E=1;break}E=S.gzindex<S.gzhead.comment.length?255&S.gzhead.comment.charCodeAt(S.gzindex++):0,J(S,E)}while(E!==0);S.gzhead.hcrc&&S.pending>x&&(c.adler=d(c.adler,S.pending_buf,S.pending-x,x)),E===0&&(S.status=103)}else S.status=103;if(S.status===103&&(S.gzhead.hcrc?(S.pending+2>S.pending_buf_size&&B(c),S.pending+2<=S.pending_buf_size&&(J(S,255&c.adler),J(S,c.adler>>8&255),c.adler=0,S.status=N)):S.status=N),S.pending!==0){if(B(c),c.avail_out===0)return S.last_flush=-1,h}else if(c.avail_in===0&&$(F)<=$(D)&&F!==p)return st(c,-5);if(S.status===666&&c.avail_in!==0)return st(c,-5);if(c.avail_in!==0||S.lookahead!==0||F!==f&&S.status!==666){var G=S.strategy===2?(function(O,q){for(var nt;;){if(O.lookahead===0&&(pt(O),O.lookahead===0)){if(q===f)return u;break}if(O.match_length=0,nt=o._tr_tally(O,0,O.window[O.strstart]),O.lookahead--,O.strstart++,nt&&(R(O,!1),O.strm.avail_out===0))return u}return O.insert=0,q===p?(R(O,!0),O.strm.avail_out===0?Q:W):O.last_lit&&(R(O,!1),O.strm.avail_out===0)?u:z})(S,F):S.strategy===3?(function(O,q){for(var nt,K,rt,dt,ct=O.window;;){if(O.lookahead<=L){if(pt(O),O.lookahead<=L&&q===f)return u;if(O.lookahead===0)break}if(O.match_length=0,O.lookahead>=C&&0<O.strstart&&(K=ct[rt=O.strstart-1])===ct[++rt]&&K===ct[++rt]&&K===ct[++rt]){dt=O.strstart+L;do;while(K===ct[++rt]&&K===ct[++rt]&&K===ct[++rt]&&K===ct[++rt]&&K===ct[++rt]&&K===ct[++rt]&&K===ct[++rt]&&K===ct[++rt]&&rt<dt);O.match_length=L-(dt-rt),O.match_length>O.lookahead&&(O.match_length=O.lookahead)}if(O.match_length>=C?(nt=o._tr_tally(O,1,O.match_length-C),O.lookahead-=O.match_length,O.strstart+=O.match_length,O.match_length=0):(nt=o._tr_tally(O,0,O.window[O.strstart]),O.lookahead--,O.strstart++),nt&&(R(O,!1),O.strm.avail_out===0))return u}return O.insert=0,q===p?(R(O,!0),O.strm.avail_out===0?Q:W):O.last_lit&&(R(O,!1),O.strm.avail_out===0)?u:z})(S,F):i[S.level].func(S,F);if(G!==Q&&G!==W||(S.status=666),G===u||G===Q)return c.avail_out===0&&(S.last_flush=-1),h;if(G===z&&(F===1?o._tr_align(S):F!==5&&(o._tr_stored_block(S,0,0,!1),F===3&&(X(S.head),S.lookahead===0&&(S.strstart=0,S.block_start=0,S.insert=0))),B(c),c.avail_out===0))return S.last_flush=-1,h}return F!==p?h:S.wrap<=0?1:(S.wrap===2?(J(S,255&c.adler),J(S,c.adler>>8&255),J(S,c.adler>>16&255),J(S,c.adler>>24&255),J(S,255&c.total_in),J(S,c.total_in>>8&255),J(S,c.total_in>>16&255),J(S,c.total_in>>24&255)):(tt(S,c.adler>>>16),tt(S,65535&c.adler)),B(c),0<S.wrap&&(S.wrap=-S.wrap),S.pending!==0?h:1)},r.deflateEnd=function(c){var F;return c&&c.state?(F=c.state.status)!==A&&F!==69&&F!==73&&F!==91&&F!==103&&F!==N&&F!==666?st(c,b):(c.state=null,F===N?st(c,-3):h):b},r.deflateSetDictionary=function(c,F){var D,S,x,E,H,G,O,q,nt=F.length;if(!c||!c.state||(E=(D=c.state).wrap)===2||E===1&&D.status!==A||D.lookahead)return b;for(E===1&&(c.adler=l(c.adler,F,nt,0)),D.wrap=0,nt>=D.w_size&&(E===0&&(X(D.head),D.strstart=0,D.block_start=0,D.insert=0),q=new a.Buf8(D.w_size),a.arraySet(q,F,nt-D.w_size,D.w_size,0),F=q,nt=D.w_size),H=c.avail_in,G=c.next_in,O=c.input,c.avail_in=nt,c.next_in=0,c.input=F,pt(D);D.lookahead>=C;){for(S=D.strstart,x=D.lookahead-(C-1);D.ins_h=(D.ins_h<<D.hash_shift^D.window[S+C-1])&D.hash_mask,D.prev[S&D.w_mask]=D.head[D.ins_h],D.head[D.ins_h]=S,S++,--x;);D.strstart=S,D.lookahead=C-1,pt(D)}return D.strstart+=D.lookahead,D.block_start=D.strstart,D.insert=D.lookahead,D.lookahead=0,D.match_length=D.prev_length=C-1,D.match_available=0,c.next_in=G,c.input=O,c.avail_in=H,D.wrap=E,h},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,s,r){s.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(e,s,r){s.exports=function(i,a){var o,l,d,m,f,p,h,b,g,v,y,_,k,M,w,T,P,j,C,L,V,A,N,u,z;o=i.state,l=i.next_in,u=i.input,d=l+(i.avail_in-5),m=i.next_out,z=i.output,f=m-(a-i.avail_out),p=m+(i.avail_out-257),h=o.dmax,b=o.wsize,g=o.whave,v=o.wnext,y=o.window,_=o.hold,k=o.bits,M=o.lencode,w=o.distcode,T=(1<<o.lenbits)-1,P=(1<<o.distbits)-1;t:do{k<15&&(_+=u[l++]<<k,k+=8,_+=u[l++]<<k,k+=8),j=M[_&T];e:for(;;){if(_>>>=C=j>>>24,k-=C,(C=j>>>16&255)===0)z[m++]=65535&j;else{if(!(16&C)){if((64&C)==0){j=M[(65535&j)+(_&(1<<C)-1)];continue e}if(32&C){o.mode=12;break t}i.msg="invalid literal/length code",o.mode=30;break t}L=65535&j,(C&=15)&&(k<C&&(_+=u[l++]<<k,k+=8),L+=_&(1<<C)-1,_>>>=C,k-=C),k<15&&(_+=u[l++]<<k,k+=8,_+=u[l++]<<k,k+=8),j=w[_&P];n:for(;;){if(_>>>=C=j>>>24,k-=C,!(16&(C=j>>>16&255))){if((64&C)==0){j=w[(65535&j)+(_&(1<<C)-1)];continue n}i.msg="invalid distance code",o.mode=30;break t}if(V=65535&j,k<(C&=15)&&(_+=u[l++]<<k,(k+=8)<C&&(_+=u[l++]<<k,k+=8)),h<(V+=_&(1<<C)-1)){i.msg="invalid distance too far back",o.mode=30;break t}if(_>>>=C,k-=C,(C=m-f)<V){if(g<(C=V-C)&&o.sane){i.msg="invalid distance too far back",o.mode=30;break t}if(N=y,(A=0)===v){if(A+=b-C,C<L){for(L-=C;z[m++]=y[A++],--C;);A=m-V,N=z}}else if(v<C){if(A+=b+v-C,(C-=v)<L){for(L-=C;z[m++]=y[A++],--C;);if(A=0,v<L){for(L-=C=v;z[m++]=y[A++],--C;);A=m-V,N=z}}}else if(A+=v-C,C<L){for(L-=C;z[m++]=y[A++],--C;);A=m-V,N=z}for(;2<L;)z[m++]=N[A++],z[m++]=N[A++],z[m++]=N[A++],L-=3;L&&(z[m++]=N[A++],1<L&&(z[m++]=N[A++]))}else{for(A=m-V;z[m++]=z[A++],z[m++]=z[A++],z[m++]=z[A++],2<(L-=3););L&&(z[m++]=z[A++],1<L&&(z[m++]=z[A++]))}break}}break}}while(l<d&&m<p);l-=L=k>>3,_&=(1<<(k-=L<<3))-1,i.next_in=l,i.next_out=m,i.avail_in=l<d?d-l+5:5-(l-d),i.avail_out=m<p?p-m+257:257-(m-p),o.hold=_,o.bits=k}},{}],49:[function(e,s,r){var i=e("../utils/common"),a=e("./adler32"),o=e("./crc32"),l=e("./inffast"),d=e("./inftrees"),m=1,f=2,p=0,h=-2,b=1,g=852,v=592;function y(A){return(A>>>24&255)+(A>>>8&65280)+((65280&A)<<8)+((255&A)<<24)}function _(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function k(A){var N;return A&&A.state?(N=A.state,A.total_in=A.total_out=N.total=0,A.msg="",N.wrap&&(A.adler=1&N.wrap),N.mode=b,N.last=0,N.havedict=0,N.dmax=32768,N.head=null,N.hold=0,N.bits=0,N.lencode=N.lendyn=new i.Buf32(g),N.distcode=N.distdyn=new i.Buf32(v),N.sane=1,N.back=-1,p):h}function M(A){var N;return A&&A.state?((N=A.state).wsize=0,N.whave=0,N.wnext=0,k(A)):h}function w(A,N){var u,z;return A&&A.state?(z=A.state,N<0?(u=0,N=-N):(u=1+(N>>4),N<48&&(N&=15)),N&&(N<8||15<N)?h:(z.window!==null&&z.wbits!==N&&(z.window=null),z.wrap=u,z.wbits=N,M(A))):h}function T(A,N){var u,z;return A?(z=new _,(A.state=z).window=null,(u=w(A,N))!==p&&(A.state=null),u):h}var P,j,C=!0;function L(A){if(C){var N;for(P=new i.Buf32(512),j=new i.Buf32(32),N=0;N<144;)A.lens[N++]=8;for(;N<256;)A.lens[N++]=9;for(;N<280;)A.lens[N++]=7;for(;N<288;)A.lens[N++]=8;for(d(m,A.lens,0,288,P,0,A.work,{bits:9}),N=0;N<32;)A.lens[N++]=5;d(f,A.lens,0,32,j,0,A.work,{bits:5}),C=!1}A.lencode=P,A.lenbits=9,A.distcode=j,A.distbits=5}function V(A,N,u,z){var Q,W=A.state;return W.window===null&&(W.wsize=1<<W.wbits,W.wnext=0,W.whave=0,W.window=new i.Buf8(W.wsize)),z>=W.wsize?(i.arraySet(W.window,N,u-W.wsize,W.wsize,0),W.wnext=0,W.whave=W.wsize):(z<(Q=W.wsize-W.wnext)&&(Q=z),i.arraySet(W.window,N,u-z,Q,W.wnext),(z-=Q)?(i.arraySet(W.window,N,u-z,z,0),W.wnext=z,W.whave=W.wsize):(W.wnext+=Q,W.wnext===W.wsize&&(W.wnext=0),W.whave<W.wsize&&(W.whave+=Q))),0}r.inflateReset=M,r.inflateReset2=w,r.inflateResetKeep=k,r.inflateInit=function(A){return T(A,15)},r.inflateInit2=T,r.inflate=function(A,N){var u,z,Q,W,st,$,X,B,R,J,tt,Y,pt,wt,ht,ut,yt,Z,et,it,c,F,D,S,x=0,E=new i.Buf8(4),H=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!A||!A.state||!A.output||!A.input&&A.avail_in!==0)return h;(u=A.state).mode===12&&(u.mode=13),st=A.next_out,Q=A.output,X=A.avail_out,W=A.next_in,z=A.input,$=A.avail_in,B=u.hold,R=u.bits,J=$,tt=X,F=p;t:for(;;)switch(u.mode){case b:if(u.wrap===0){u.mode=13;break}for(;R<16;){if($===0)break t;$--,B+=z[W++]<<R,R+=8}if(2&u.wrap&&B===35615){E[u.check=0]=255&B,E[1]=B>>>8&255,u.check=o(u.check,E,2,0),R=B=0,u.mode=2;break}if(u.flags=0,u.head&&(u.head.done=!1),!(1&u.wrap)||(((255&B)<<8)+(B>>8))%31){A.msg="incorrect header check",u.mode=30;break}if((15&B)!=8){A.msg="unknown compression method",u.mode=30;break}if(R-=4,c=8+(15&(B>>>=4)),u.wbits===0)u.wbits=c;else if(c>u.wbits){A.msg="invalid window size",u.mode=30;break}u.dmax=1<<c,A.adler=u.check=1,u.mode=512&B?10:12,R=B=0;break;case 2:for(;R<16;){if($===0)break t;$--,B+=z[W++]<<R,R+=8}if(u.flags=B,(255&u.flags)!=8){A.msg="unknown compression method",u.mode=30;break}if(57344&u.flags){A.msg="unknown header flags set",u.mode=30;break}u.head&&(u.head.text=B>>8&1),512&u.flags&&(E[0]=255&B,E[1]=B>>>8&255,u.check=o(u.check,E,2,0)),R=B=0,u.mode=3;case 3:for(;R<32;){if($===0)break t;$--,B+=z[W++]<<R,R+=8}u.head&&(u.head.time=B),512&u.flags&&(E[0]=255&B,E[1]=B>>>8&255,E[2]=B>>>16&255,E[3]=B>>>24&255,u.check=o(u.check,E,4,0)),R=B=0,u.mode=4;case 4:for(;R<16;){if($===0)break t;$--,B+=z[W++]<<R,R+=8}u.head&&(u.head.xflags=255&B,u.head.os=B>>8),512&u.flags&&(E[0]=255&B,E[1]=B>>>8&255,u.check=o(u.check,E,2,0)),R=B=0,u.mode=5;case 5:if(1024&u.flags){for(;R<16;){if($===0)break t;$--,B+=z[W++]<<R,R+=8}u.length=B,u.head&&(u.head.extra_len=B),512&u.flags&&(E[0]=255&B,E[1]=B>>>8&255,u.check=o(u.check,E,2,0)),R=B=0}else u.head&&(u.head.extra=null);u.mode=6;case 6:if(1024&u.flags&&($<(Y=u.length)&&(Y=$),Y&&(u.head&&(c=u.head.extra_len-u.length,u.head.extra||(u.head.extra=new Array(u.head.extra_len)),i.arraySet(u.head.extra,z,W,Y,c)),512&u.flags&&(u.check=o(u.check,z,Y,W)),$-=Y,W+=Y,u.length-=Y),u.length))break t;u.length=0,u.mode=7;case 7:if(2048&u.flags){if($===0)break t;for(Y=0;c=z[W+Y++],u.head&&c&&u.length<65536&&(u.head.name+=String.fromCharCode(c)),c&&Y<$;);if(512&u.flags&&(u.check=o(u.check,z,Y,W)),$-=Y,W+=Y,c)break t}else u.head&&(u.head.name=null);u.length=0,u.mode=8;case 8:if(4096&u.flags){if($===0)break t;for(Y=0;c=z[W+Y++],u.head&&c&&u.length<65536&&(u.head.comment+=String.fromCharCode(c)),c&&Y<$;);if(512&u.flags&&(u.check=o(u.check,z,Y,W)),$-=Y,W+=Y,c)break t}else u.head&&(u.head.comment=null);u.mode=9;case 9:if(512&u.flags){for(;R<16;){if($===0)break t;$--,B+=z[W++]<<R,R+=8}if(B!==(65535&u.check)){A.msg="header crc mismatch",u.mode=30;break}R=B=0}u.head&&(u.head.hcrc=u.flags>>9&1,u.head.done=!0),A.adler=u.check=0,u.mode=12;break;case 10:for(;R<32;){if($===0)break t;$--,B+=z[W++]<<R,R+=8}A.adler=u.check=y(B),R=B=0,u.mode=11;case 11:if(u.havedict===0)return A.next_out=st,A.avail_out=X,A.next_in=W,A.avail_in=$,u.hold=B,u.bits=R,2;A.adler=u.check=1,u.mode=12;case 12:if(N===5||N===6)break t;case 13:if(u.last){B>>>=7&R,R-=7&R,u.mode=27;break}for(;R<3;){if($===0)break t;$--,B+=z[W++]<<R,R+=8}switch(u.last=1&B,R-=1,3&(B>>>=1)){case 0:u.mode=14;break;case 1:if(L(u),u.mode=20,N!==6)break;B>>>=2,R-=2;break t;case 2:u.mode=17;break;case 3:A.msg="invalid block type",u.mode=30}B>>>=2,R-=2;break;case 14:for(B>>>=7&R,R-=7&R;R<32;){if($===0)break t;$--,B+=z[W++]<<R,R+=8}if((65535&B)!=(B>>>16^65535)){A.msg="invalid stored block lengths",u.mode=30;break}if(u.length=65535&B,R=B=0,u.mode=15,N===6)break t;case 15:u.mode=16;case 16:if(Y=u.length){if($<Y&&(Y=$),X<Y&&(Y=X),Y===0)break t;i.arraySet(Q,z,W,Y,st),$-=Y,W+=Y,X-=Y,st+=Y,u.length-=Y;break}u.mode=12;break;case 17:for(;R<14;){if($===0)break t;$--,B+=z[W++]<<R,R+=8}if(u.nlen=257+(31&B),B>>>=5,R-=5,u.ndist=1+(31&B),B>>>=5,R-=5,u.ncode=4+(15&B),B>>>=4,R-=4,286<u.nlen||30<u.ndist){A.msg="too many length or distance symbols",u.mode=30;break}u.have=0,u.mode=18;case 18:for(;u.have<u.ncode;){for(;R<3;){if($===0)break t;$--,B+=z[W++]<<R,R+=8}u.lens[H[u.have++]]=7&B,B>>>=3,R-=3}for(;u.have<19;)u.lens[H[u.have++]]=0;if(u.lencode=u.lendyn,u.lenbits=7,D={bits:u.lenbits},F=d(0,u.lens,0,19,u.lencode,0,u.work,D),u.lenbits=D.bits,F){A.msg="invalid code lengths set",u.mode=30;break}u.have=0,u.mode=19;case 19:for(;u.have<u.nlen+u.ndist;){for(;ut=(x=u.lencode[B&(1<<u.lenbits)-1])>>>16&255,yt=65535&x,!((ht=x>>>24)<=R);){if($===0)break t;$--,B+=z[W++]<<R,R+=8}if(yt<16)B>>>=ht,R-=ht,u.lens[u.have++]=yt;else{if(yt===16){for(S=ht+2;R<S;){if($===0)break t;$--,B+=z[W++]<<R,R+=8}if(B>>>=ht,R-=ht,u.have===0){A.msg="invalid bit length repeat",u.mode=30;break}c=u.lens[u.have-1],Y=3+(3&B),B>>>=2,R-=2}else if(yt===17){for(S=ht+3;R<S;){if($===0)break t;$--,B+=z[W++]<<R,R+=8}R-=ht,c=0,Y=3+(7&(B>>>=ht)),B>>>=3,R-=3}else{for(S=ht+7;R<S;){if($===0)break t;$--,B+=z[W++]<<R,R+=8}R-=ht,c=0,Y=11+(127&(B>>>=ht)),B>>>=7,R-=7}if(u.have+Y>u.nlen+u.ndist){A.msg="invalid bit length repeat",u.mode=30;break}for(;Y--;)u.lens[u.have++]=c}}if(u.mode===30)break;if(u.lens[256]===0){A.msg="invalid code -- missing end-of-block",u.mode=30;break}if(u.lenbits=9,D={bits:u.lenbits},F=d(m,u.lens,0,u.nlen,u.lencode,0,u.work,D),u.lenbits=D.bits,F){A.msg="invalid literal/lengths set",u.mode=30;break}if(u.distbits=6,u.distcode=u.distdyn,D={bits:u.distbits},F=d(f,u.lens,u.nlen,u.ndist,u.distcode,0,u.work,D),u.distbits=D.bits,F){A.msg="invalid distances set",u.mode=30;break}if(u.mode=20,N===6)break t;case 20:u.mode=21;case 21:if(6<=$&&258<=X){A.next_out=st,A.avail_out=X,A.next_in=W,A.avail_in=$,u.hold=B,u.bits=R,l(A,tt),st=A.next_out,Q=A.output,X=A.avail_out,W=A.next_in,z=A.input,$=A.avail_in,B=u.hold,R=u.bits,u.mode===12&&(u.back=-1);break}for(u.back=0;ut=(x=u.lencode[B&(1<<u.lenbits)-1])>>>16&255,yt=65535&x,!((ht=x>>>24)<=R);){if($===0)break t;$--,B+=z[W++]<<R,R+=8}if(ut&&(240&ut)==0){for(Z=ht,et=ut,it=yt;ut=(x=u.lencode[it+((B&(1<<Z+et)-1)>>Z)])>>>16&255,yt=65535&x,!(Z+(ht=x>>>24)<=R);){if($===0)break t;$--,B+=z[W++]<<R,R+=8}B>>>=Z,R-=Z,u.back+=Z}if(B>>>=ht,R-=ht,u.back+=ht,u.length=yt,ut===0){u.mode=26;break}if(32&ut){u.back=-1,u.mode=12;break}if(64&ut){A.msg="invalid literal/length code",u.mode=30;break}u.extra=15&ut,u.mode=22;case 22:if(u.extra){for(S=u.extra;R<S;){if($===0)break t;$--,B+=z[W++]<<R,R+=8}u.length+=B&(1<<u.extra)-1,B>>>=u.extra,R-=u.extra,u.back+=u.extra}u.was=u.length,u.mode=23;case 23:for(;ut=(x=u.distcode[B&(1<<u.distbits)-1])>>>16&255,yt=65535&x,!((ht=x>>>24)<=R);){if($===0)break t;$--,B+=z[W++]<<R,R+=8}if((240&ut)==0){for(Z=ht,et=ut,it=yt;ut=(x=u.distcode[it+((B&(1<<Z+et)-1)>>Z)])>>>16&255,yt=65535&x,!(Z+(ht=x>>>24)<=R);){if($===0)break t;$--,B+=z[W++]<<R,R+=8}B>>>=Z,R-=Z,u.back+=Z}if(B>>>=ht,R-=ht,u.back+=ht,64&ut){A.msg="invalid distance code",u.mode=30;break}u.offset=yt,u.extra=15&ut,u.mode=24;case 24:if(u.extra){for(S=u.extra;R<S;){if($===0)break t;$--,B+=z[W++]<<R,R+=8}u.offset+=B&(1<<u.extra)-1,B>>>=u.extra,R-=u.extra,u.back+=u.extra}if(u.offset>u.dmax){A.msg="invalid distance too far back",u.mode=30;break}u.mode=25;case 25:if(X===0)break t;if(Y=tt-X,u.offset>Y){if((Y=u.offset-Y)>u.whave&&u.sane){A.msg="invalid distance too far back",u.mode=30;break}pt=Y>u.wnext?(Y-=u.wnext,u.wsize-Y):u.wnext-Y,Y>u.length&&(Y=u.length),wt=u.window}else wt=Q,pt=st-u.offset,Y=u.length;for(X<Y&&(Y=X),X-=Y,u.length-=Y;Q[st++]=wt[pt++],--Y;);u.length===0&&(u.mode=21);break;case 26:if(X===0)break t;Q[st++]=u.length,X--,u.mode=21;break;case 27:if(u.wrap){for(;R<32;){if($===0)break t;$--,B|=z[W++]<<R,R+=8}if(tt-=X,A.total_out+=tt,u.total+=tt,tt&&(A.adler=u.check=u.flags?o(u.check,Q,tt,st-tt):a(u.check,Q,tt,st-tt)),tt=X,(u.flags?B:y(B))!==u.check){A.msg="incorrect data check",u.mode=30;break}R=B=0}u.mode=28;case 28:if(u.wrap&&u.flags){for(;R<32;){if($===0)break t;$--,B+=z[W++]<<R,R+=8}if(B!==(4294967295&u.total)){A.msg="incorrect length check",u.mode=30;break}R=B=0}u.mode=29;case 29:F=1;break t;case 30:F=-3;break t;case 31:return-4;case 32:default:return h}return A.next_out=st,A.avail_out=X,A.next_in=W,A.avail_in=$,u.hold=B,u.bits=R,(u.wsize||tt!==A.avail_out&&u.mode<30&&(u.mode<27||N!==4))&&V(A,A.output,A.next_out,tt-A.avail_out)?(u.mode=31,-4):(J-=A.avail_in,tt-=A.avail_out,A.total_in+=J,A.total_out+=tt,u.total+=tt,u.wrap&&tt&&(A.adler=u.check=u.flags?o(u.check,Q,tt,A.next_out-tt):a(u.check,Q,tt,A.next_out-tt)),A.data_type=u.bits+(u.last?64:0)+(u.mode===12?128:0)+(u.mode===20||u.mode===15?256:0),(J==0&&tt===0||N===4)&&F===p&&(F=-5),F)},r.inflateEnd=function(A){if(!A||!A.state)return h;var N=A.state;return N.window&&(N.window=null),A.state=null,p},r.inflateGetHeader=function(A,N){var u;return A&&A.state?(2&(u=A.state).wrap)==0?h:((u.head=N).done=!1,p):h},r.inflateSetDictionary=function(A,N){var u,z=N.length;return A&&A.state?(u=A.state).wrap!==0&&u.mode!==11?h:u.mode===11&&a(1,N,z,0)!==u.check?-3:V(A,N,z,z)?(u.mode=31,-4):(u.havedict=1,p):h},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,s,r){var i=e("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],d=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];s.exports=function(m,f,p,h,b,g,v,y){var _,k,M,w,T,P,j,C,L,V=y.bits,A=0,N=0,u=0,z=0,Q=0,W=0,st=0,$=0,X=0,B=0,R=null,J=0,tt=new i.Buf16(16),Y=new i.Buf16(16),pt=null,wt=0;for(A=0;A<=15;A++)tt[A]=0;for(N=0;N<h;N++)tt[f[p+N]]++;for(Q=V,z=15;1<=z&&tt[z]===0;z--);if(z<Q&&(Q=z),z===0)return b[g++]=20971520,b[g++]=20971520,y.bits=1,0;for(u=1;u<z&&tt[u]===0;u++);for(Q<u&&(Q=u),A=$=1;A<=15;A++)if($<<=1,($-=tt[A])<0)return-1;if(0<$&&(m===0||z!==1))return-1;for(Y[1]=0,A=1;A<15;A++)Y[A+1]=Y[A]+tt[A];for(N=0;N<h;N++)f[p+N]!==0&&(v[Y[f[p+N]]++]=N);if(P=m===0?(R=pt=v,19):m===1?(R=a,J-=257,pt=o,wt-=257,256):(R=l,pt=d,-1),A=u,T=g,st=N=B=0,M=-1,w=(X=1<<(W=Q))-1,m===1&&852<X||m===2&&592<X)return 1;for(;;){for(j=A-st,L=v[N]<P?(C=0,v[N]):v[N]>P?(C=pt[wt+v[N]],R[J+v[N]]):(C=96,0),_=1<<A-st,u=k=1<<W;b[T+(B>>st)+(k-=_)]=j<<24|C<<16|L|0,k!==0;);for(_=1<<A-1;B&_;)_>>=1;if(_!==0?(B&=_-1,B+=_):B=0,N++,--tt[A]==0){if(A===z)break;A=f[p+v[N]]}if(Q<A&&(B&w)!==M){for(st===0&&(st=Q),T+=u,$=1<<(W=A-st);W+st<z&&!(($-=tt[W+st])<=0);)W++,$<<=1;if(X+=1<<W,m===1&&852<X||m===2&&592<X)return 1;b[M=B&w]=Q<<24|W<<16|T-g|0}}return B!==0&&(b[T+B]=A-st<<24|64<<16|0),y.bits=Q,0}},{"../utils/common":41}],51:[function(e,s,r){s.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(e,s,r){var i=e("../utils/common"),a=0,o=1;function l(x){for(var E=x.length;0<=--E;)x[E]=0}var d=0,m=29,f=256,p=f+1+m,h=30,b=19,g=2*p+1,v=15,y=16,_=7,k=256,M=16,w=17,T=18,P=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],j=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],C=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],L=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],V=new Array(2*(p+2));l(V);var A=new Array(2*h);l(A);var N=new Array(512);l(N);var u=new Array(256);l(u);var z=new Array(m);l(z);var Q,W,st,$=new Array(h);function X(x,E,H,G,O){this.static_tree=x,this.extra_bits=E,this.extra_base=H,this.elems=G,this.max_length=O,this.has_stree=x&&x.length}function B(x,E){this.dyn_tree=x,this.max_code=0,this.stat_desc=E}function R(x){return x<256?N[x]:N[256+(x>>>7)]}function J(x,E){x.pending_buf[x.pending++]=255&E,x.pending_buf[x.pending++]=E>>>8&255}function tt(x,E,H){x.bi_valid>y-H?(x.bi_buf|=E<<x.bi_valid&65535,J(x,x.bi_buf),x.bi_buf=E>>y-x.bi_valid,x.bi_valid+=H-y):(x.bi_buf|=E<<x.bi_valid&65535,x.bi_valid+=H)}function Y(x,E,H){tt(x,H[2*E],H[2*E+1])}function pt(x,E){for(var H=0;H|=1&x,x>>>=1,H<<=1,0<--E;);return H>>>1}function wt(x,E,H){var G,O,q=new Array(v+1),nt=0;for(G=1;G<=v;G++)q[G]=nt=nt+H[G-1]<<1;for(O=0;O<=E;O++){var K=x[2*O+1];K!==0&&(x[2*O]=pt(q[K]++,K))}}function ht(x){var E;for(E=0;E<p;E++)x.dyn_ltree[2*E]=0;for(E=0;E<h;E++)x.dyn_dtree[2*E]=0;for(E=0;E<b;E++)x.bl_tree[2*E]=0;x.dyn_ltree[2*k]=1,x.opt_len=x.static_len=0,x.last_lit=x.matches=0}function ut(x){8<x.bi_valid?J(x,x.bi_buf):0<x.bi_valid&&(x.pending_buf[x.pending++]=x.bi_buf),x.bi_buf=0,x.bi_valid=0}function yt(x,E,H,G){var O=2*E,q=2*H;return x[O]<x[q]||x[O]===x[q]&&G[E]<=G[H]}function Z(x,E,H){for(var G=x.heap[H],O=H<<1;O<=x.heap_len&&(O<x.heap_len&&yt(E,x.heap[O+1],x.heap[O],x.depth)&&O++,!yt(E,G,x.heap[O],x.depth));)x.heap[H]=x.heap[O],H=O,O<<=1;x.heap[H]=G}function et(x,E,H){var G,O,q,nt,K=0;if(x.last_lit!==0)for(;G=x.pending_buf[x.d_buf+2*K]<<8|x.pending_buf[x.d_buf+2*K+1],O=x.pending_buf[x.l_buf+K],K++,G===0?Y(x,O,E):(Y(x,(q=u[O])+f+1,E),(nt=P[q])!==0&&tt(x,O-=z[q],nt),Y(x,q=R(--G),H),(nt=j[q])!==0&&tt(x,G-=$[q],nt)),K<x.last_lit;);Y(x,k,E)}function it(x,E){var H,G,O,q=E.dyn_tree,nt=E.stat_desc.static_tree,K=E.stat_desc.has_stree,rt=E.stat_desc.elems,dt=-1;for(x.heap_len=0,x.heap_max=g,H=0;H<rt;H++)q[2*H]!==0?(x.heap[++x.heap_len]=dt=H,x.depth[H]=0):q[2*H+1]=0;for(;x.heap_len<2;)q[2*(O=x.heap[++x.heap_len]=dt<2?++dt:0)]=1,x.depth[O]=0,x.opt_len--,K&&(x.static_len-=nt[2*O+1]);for(E.max_code=dt,H=x.heap_len>>1;1<=H;H--)Z(x,q,H);for(O=rt;H=x.heap[1],x.heap[1]=x.heap[x.heap_len--],Z(x,q,1),G=x.heap[1],x.heap[--x.heap_max]=H,x.heap[--x.heap_max]=G,q[2*O]=q[2*H]+q[2*G],x.depth[O]=(x.depth[H]>=x.depth[G]?x.depth[H]:x.depth[G])+1,q[2*H+1]=q[2*G+1]=O,x.heap[1]=O++,Z(x,q,1),2<=x.heap_len;);x.heap[--x.heap_max]=x.heap[1],(function(ct,xt){var Ct,At,Rt,bt,ot,mt,kt=xt.dyn_tree,Lt=xt.max_code,ce=xt.stat_desc.static_tree,Vt=xt.stat_desc.has_stree,Jt=xt.stat_desc.extra_bits,Nt=xt.stat_desc.extra_base,Et=xt.stat_desc.max_length,Mt=0;for(bt=0;bt<=v;bt++)ct.bl_count[bt]=0;for(kt[2*ct.heap[ct.heap_max]+1]=0,Ct=ct.heap_max+1;Ct<g;Ct++)Et<(bt=kt[2*kt[2*(At=ct.heap[Ct])+1]+1]+1)&&(bt=Et,Mt++),kt[2*At+1]=bt,Lt<At||(ct.bl_count[bt]++,ot=0,Nt<=At&&(ot=Jt[At-Nt]),mt=kt[2*At],ct.opt_len+=mt*(bt+ot),Vt&&(ct.static_len+=mt*(ce[2*At+1]+ot)));if(Mt!==0){do{for(bt=Et-1;ct.bl_count[bt]===0;)bt--;ct.bl_count[bt]--,ct.bl_count[bt+1]+=2,ct.bl_count[Et]--,Mt-=2}while(0<Mt);for(bt=Et;bt!==0;bt--)for(At=ct.bl_count[bt];At!==0;)Lt<(Rt=ct.heap[--Ct])||(kt[2*Rt+1]!==bt&&(ct.opt_len+=(bt-kt[2*Rt+1])*kt[2*Rt],kt[2*Rt+1]=bt),At--)}})(x,E),wt(q,dt,x.bl_count)}function c(x,E,H){var G,O,q=-1,nt=E[1],K=0,rt=7,dt=4;for(nt===0&&(rt=138,dt=3),E[2*(H+1)+1]=65535,G=0;G<=H;G++)O=nt,nt=E[2*(G+1)+1],++K<rt&&O===nt||(K<dt?x.bl_tree[2*O]+=K:O!==0?(O!==q&&x.bl_tree[2*O]++,x.bl_tree[2*M]++):K<=10?x.bl_tree[2*w]++:x.bl_tree[2*T]++,q=O,dt=(K=0)===nt?(rt=138,3):O===nt?(rt=6,3):(rt=7,4))}function F(x,E,H){var G,O,q=-1,nt=E[1],K=0,rt=7,dt=4;for(nt===0&&(rt=138,dt=3),G=0;G<=H;G++)if(O=nt,nt=E[2*(G+1)+1],!(++K<rt&&O===nt)){if(K<dt)for(;Y(x,O,x.bl_tree),--K!=0;);else O!==0?(O!==q&&(Y(x,O,x.bl_tree),K--),Y(x,M,x.bl_tree),tt(x,K-3,2)):K<=10?(Y(x,w,x.bl_tree),tt(x,K-3,3)):(Y(x,T,x.bl_tree),tt(x,K-11,7));q=O,dt=(K=0)===nt?(rt=138,3):O===nt?(rt=6,3):(rt=7,4)}}l($);var D=!1;function S(x,E,H,G){tt(x,(d<<1)+(G?1:0),3),(function(O,q,nt,K){ut(O),J(O,nt),J(O,~nt),i.arraySet(O.pending_buf,O.window,q,nt,O.pending),O.pending+=nt})(x,E,H)}r._tr_init=function(x){D||((function(){var E,H,G,O,q,nt=new Array(v+1);for(O=G=0;O<m-1;O++)for(z[O]=G,E=0;E<1<<P[O];E++)u[G++]=O;for(u[G-1]=O,O=q=0;O<16;O++)for($[O]=q,E=0;E<1<<j[O];E++)N[q++]=O;for(q>>=7;O<h;O++)for($[O]=q<<7,E=0;E<1<<j[O]-7;E++)N[256+q++]=O;for(H=0;H<=v;H++)nt[H]=0;for(E=0;E<=143;)V[2*E+1]=8,E++,nt[8]++;for(;E<=255;)V[2*E+1]=9,E++,nt[9]++;for(;E<=279;)V[2*E+1]=7,E++,nt[7]++;for(;E<=287;)V[2*E+1]=8,E++,nt[8]++;for(wt(V,p+1,nt),E=0;E<h;E++)A[2*E+1]=5,A[2*E]=pt(E,5);Q=new X(V,P,f+1,p,v),W=new X(A,j,0,h,v),st=new X(new Array(0),C,0,b,_)})(),D=!0),x.l_desc=new B(x.dyn_ltree,Q),x.d_desc=new B(x.dyn_dtree,W),x.bl_desc=new B(x.bl_tree,st),x.bi_buf=0,x.bi_valid=0,ht(x)},r._tr_stored_block=S,r._tr_flush_block=function(x,E,H,G){var O,q,nt=0;0<x.level?(x.strm.data_type===2&&(x.strm.data_type=(function(K){var rt,dt=4093624447;for(rt=0;rt<=31;rt++,dt>>>=1)if(1&dt&&K.dyn_ltree[2*rt]!==0)return a;if(K.dyn_ltree[18]!==0||K.dyn_ltree[20]!==0||K.dyn_ltree[26]!==0)return o;for(rt=32;rt<f;rt++)if(K.dyn_ltree[2*rt]!==0)return o;return a})(x)),it(x,x.l_desc),it(x,x.d_desc),nt=(function(K){var rt;for(c(K,K.dyn_ltree,K.l_desc.max_code),c(K,K.dyn_dtree,K.d_desc.max_code),it(K,K.bl_desc),rt=b-1;3<=rt&&K.bl_tree[2*L[rt]+1]===0;rt--);return K.opt_len+=3*(rt+1)+5+5+4,rt})(x),O=x.opt_len+3+7>>>3,(q=x.static_len+3+7>>>3)<=O&&(O=q)):O=q=H+5,H+4<=O&&E!==-1?S(x,E,H,G):x.strategy===4||q===O?(tt(x,2+(G?1:0),3),et(x,V,A)):(tt(x,4+(G?1:0),3),(function(K,rt,dt,ct){var xt;for(tt(K,rt-257,5),tt(K,dt-1,5),tt(K,ct-4,4),xt=0;xt<ct;xt++)tt(K,K.bl_tree[2*L[xt]+1],3);F(K,K.dyn_ltree,rt-1),F(K,K.dyn_dtree,dt-1)})(x,x.l_desc.max_code+1,x.d_desc.max_code+1,nt+1),et(x,x.dyn_ltree,x.dyn_dtree)),ht(x),G&&ut(x)},r._tr_tally=function(x,E,H){return x.pending_buf[x.d_buf+2*x.last_lit]=E>>>8&255,x.pending_buf[x.d_buf+2*x.last_lit+1]=255&E,x.pending_buf[x.l_buf+x.last_lit]=255&H,x.last_lit++,E===0?x.dyn_ltree[2*H]++:(x.matches++,E--,x.dyn_ltree[2*(u[H]+f+1)]++,x.dyn_dtree[2*R(E)]++),x.last_lit===x.lit_bufsize-1},r._tr_align=function(x){tt(x,2,3),Y(x,k,V),(function(E){E.bi_valid===16?(J(E,E.bi_buf),E.bi_buf=0,E.bi_valid=0):8<=E.bi_valid&&(E.pending_buf[E.pending++]=255&E.bi_buf,E.bi_buf>>=8,E.bi_valid-=8)})(x)}},{"../utils/common":41}],53:[function(e,s,r){s.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,s,r){(function(i){(function(a,o){if(!a.setImmediate){var l,d,m,f,p=1,h={},b=!1,g=a.document,v=Object.getPrototypeOf&&Object.getPrototypeOf(a);v=v&&v.setTimeout?v:a,l={}.toString.call(a.process)==="[object process]"?function(M){process.nextTick(function(){_(M)})}:(function(){if(a.postMessage&&!a.importScripts){var M=!0,w=a.onmessage;return a.onmessage=function(){M=!1},a.postMessage("","*"),a.onmessage=w,M}})()?(f="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",k,!1):a.attachEvent("onmessage",k),function(M){a.postMessage(f+M,"*")}):a.MessageChannel?((m=new MessageChannel).port1.onmessage=function(M){_(M.data)},function(M){m.port2.postMessage(M)}):g&&"onreadystatechange"in g.createElement("script")?(d=g.documentElement,function(M){var w=g.createElement("script");w.onreadystatechange=function(){_(M),w.onreadystatechange=null,d.removeChild(w),w=null},d.appendChild(w)}):function(M){setTimeout(_,0,M)},v.setImmediate=function(M){typeof M!="function"&&(M=new Function(""+M));for(var w=new Array(arguments.length-1),T=0;T<w.length;T++)w[T]=arguments[T+1];var P={callback:M,args:w};return h[p]=P,l(p),p++},v.clearImmediate=y}function y(M){delete h[M]}function _(M){if(b)setTimeout(_,0,M);else{var w=h[M];if(w){b=!0;try{(function(T){var P=T.callback,j=T.args;switch(j.length){case 0:P();break;case 1:P(j[0]);break;case 2:P(j[0],j[1]);break;case 3:P(j[0],j[1],j[2]);break;default:P.apply(o,j)}})(w)}finally{y(M),b=!1}}}}function k(M){M.source===a&&typeof M.data=="string"&&M.data.indexOf(f)===0&&_(+M.data.slice(f.length))}})(typeof self>"u"?i===void 0?this:i:self)}).call(this,typeof xn<"u"?xn:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(dr)),dr.exports}var $c=Lc();const _o=Fc($c);var Hc=Object.defineProperty,Uc=Object.defineProperties,Wc=Object.getOwnPropertyDescriptors,Ks=Object.getOwnPropertySymbols,Gc=Object.prototype.hasOwnProperty,Vc=Object.prototype.propertyIsEnumerable,wo=t=>{throw TypeError(t)},qs=(t,n,e)=>n in t?Hc(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,De=(t,n)=>{for(var e in n||(n={}))Gc.call(n,e)&&qs(t,e,n[e]);if(Ks)for(var e of Ks(n))Vc.call(n,e)&&qs(t,e,n[e]);return t},Kc=(t,n)=>Uc(t,Wc(n)),$r=(t,n,e)=>n.has(t)||wo("Cannot "+e),U=(t,n,e)=>($r(t,n,"read from private field"),e?e.call(t):n.get(t)),lt=(t,n,e)=>n.has(t)?wo("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(t):n.set(t,e),at=(t,n,e,s)=>($r(t,n,"write to private field"),n.set(t,e),e),Hn=(t,n,e)=>($r(t,n,"access private method"),e),le=(t,n,e)=>new Promise((s,r)=>{var i=l=>{try{o(e.next(l))}catch(d){r(d)}},a=l=>{try{o(e.throw(l))}catch(d){r(d)}},o=l=>l.done?s(l.value):Promise.resolve(l.value).then(i,a);o((e=e.apply(t,n)).next())}),Hr={fetch(t){return fetch(t)}};function fr(t){const n=t.filter(e=>!!e);return n.reduce((e,s)=>{const r="output"in e?e.output:e,i="input"in s?s.input:s;return r.connect(i),s}),()=>{n.reduce((e,s)=>{const r="output"in e?e.output:e,i="input"in s?s.input:s;return r.disconnect(i),s})}}function qc(t){let n=t;const e=new Set;function s(a){return e.add(a),a(n),()=>{e.delete(a)}}function r(a){n=a,e.forEach(o=>o(n))}function i(){return n}return{subscribe:s,set:r,get:i}}function xo(t){return t*t/16129}function Yc(t){return Math.pow(10,t/20)}var he,ne,we,xe,En,ue,de,Zc=class{constructor(t,n){this.context=t,lt(this,he),lt(this,ne),lt(this,we),lt(this,xe),lt(this,En),lt(this,ue),lt(this,de,!1);var e,s,r;at(this,ue,{destination:(e=n==null?void 0:n.destination)!=null?e:t.destination,volume:(s=n==null?void 0:n.volume)!=null?s:100,volumeToGain:(r=n==null?void 0:n.volumeToGain)!=null?r:xo}),this.input=t.createGain(),at(this,he,t.createGain()),at(this,xe,fr([this.input,U(this,he),U(this,ue).destination]));const i=qc(U(this,ue).volume);this.setVolume=i.set,at(this,En,i.subscribe(a=>{U(this,he).gain.value=U(this,ue).volumeToGain(a)}))}addInsert(t){var n;if(U(this,de))throw Error("Can't add insert to disconnected channel");(n=U(this,we))!=null||at(this,we,[]),U(this,we).push(t),U(this,xe).call(this),at(this,xe,fr([this.input,...U(this,we),U(this,he),U(this,ue).destination]))}addEffect(t,n,e){var s;if(U(this,de))throw Error("Can't add effect to disconnected channel");const r=this.context.createGain();r.gain.value=e;const i="input"in n?n.input:n,a=fr([U(this,he),r,i]);(s=U(this,ne))!=null||at(this,ne,[]),U(this,ne).push({name:t,mix:r,disconnect:a})}sendEffect(t,n){var e;if(U(this,de))throw Error("Can't send effect to disconnected channel");const s=(e=U(this,ne))==null?void 0:e.find(r=>r.name===t);s?s.mix.gain.value=n:console.warn("Send bus not found: "+t)}disconnect(){var t;U(this,de)||(at(this,de,!0),U(this,xe).call(this),U(this,En).call(this),(t=U(this,ne))==null||t.forEach(n=>n.disconnect()),at(this,ne,void 0))}};he=new WeakMap;ne=new WeakMap;we=new WeakMap;xe=new WeakMap;En=new WeakMap;ue=new WeakMap;de=new WeakMap;function Xc(t){const e=/^([a-gA-G]?)(#{1,}|b{1,}|)(-?\d+)$/.exec(t);if(!e)return;const s=e[1].toUpperCase();if(!s)return;const r=e[2],i=r[0]==="b"?-r.length:r.length,a=e[3]?+e[3]:4,o=(s.charCodeAt(0)+3)%7;return[0,2,4,5,7,9,11][o]+i+12*(a+1)}function hn(t){return t===void 0?void 0:typeof t=="number"?t:Xc(t)}var So={volume:0,tune:0,detune:0,ampRelease:.3,ampAttack:0,lpfCutoffHz:2e4,offset:0,loop:!1,loopStart:0,loopEnd:0},Qc=Object.keys(So);function Ys(t){const n={};for(const e of Qc){const s=t[e];s!==void 0&&(n[e]=s)}return n}function Jc(t,n,e,s,r,i){var a,o,l,d,m;const f=De(De(De(De({},So),t),Ys(n)),Ys(e)),p=(o=(a=e.pitch)!=null?a:e.key)!=null?o:s;let b=(s-p+f.tune)*100+f.detune;return(i==null?void 0:i.detune)!==void 0&&(b+=i.detune),{detune:b,velocity:r,volume:f.volume,ampRelease:(l=i==null?void 0:i.ampRelease)!=null?l:f.ampRelease,ampAttack:f.ampAttack,lpfCutoffHz:(d=i==null?void 0:i.lpfCutoffHz)!=null?d:f.lpfCutoffHz,offset:f.offset,loop:(m=i==null?void 0:i.loop)!=null?m:f.loop,loopStart:f.loopStart,loopEnd:f.loopEnd,ampVelCurve:e.ampVelCurve,loopAuto:e.loopAuto}}function th(t){var n,e,s,r,i;let a,o,l;return t.key!==void 0?(a=o=t.key,l=t.key):t.keyRange?([a,o]=t.keyRange,l=t.pitch):(a=0,o=127,l=t.pitch),{keyLow:a,keyHigh:o,pitch:l,velLow:(e=(n=t.velRange)==null?void 0:n[0])!=null?e:0,velHigh:(r=(s=t.velRange)==null?void 0:s[1])!=null?r:127,ccRange:t.ccRange,seqPosition:(i=t.seqPosition)!=null?i:1,group:t.group,offBy:t.offBy,sample:t.sample,ref:t}}function eh(t){var n,e,s,r,i,a,o,l;return{keyLow:(e=(n=t.keyRange)==null?void 0:n[0])!=null?e:0,keyHigh:(r=(s=t.keyRange)==null?void 0:s[1])!=null?r:127,velLow:(a=(i=t.velRange)==null?void 0:i[0])!=null?a:0,velHigh:(l=(o=t.velRange)==null?void 0:o[1])!=null?l:127,ccRange:t.ccRange,seqLength:t.seqLength,group:t.group,offBy:t.offBy,regions:t.regions.map(th),ref:t}}function Zs(t,n){var e;if(!n)return!0;for(const[s,[r,i]]of Object.entries(n)){const a=parseInt(s,10),o=(e=t.get(a))!=null?e:0;if(o<r||o>i)return!1}return!0}var Fe,Le,Xs=class{constructor(t){lt(this,Fe),lt(this,Le),at(this,Fe,t.groups.map(eh)),at(this,Le,new Map)}match(t,n,e){var s,r,i,a;const o=[];for(let l=0;l<U(this,Fe).length;l++){const d=U(this,Fe)[l];if(t<d.keyLow||t>d.keyHigh||n<d.velLow||n>d.velHigh||!Zs(e,d.ccRange))continue;const m=(s=U(this,Le).get(l))!=null?s:0;for(const f of d.regions)if(!(t<f.keyLow||t>f.keyHigh)&&!(n<f.velLow||n>f.velHigh)&&Zs(e,f.ccRange)){if(d.seqLength!==void 0){const p=f.seqPosition-1;if(m%d.seqLength!==p)continue}o.push({sample:f.sample,pitch:(r=f.pitch)!=null?r:t,group:(i=f.group)!=null?i:d.group,offBy:(a=f.offBy)!=null?a:d.offBy,groupRef:d.ref,regionRef:f.ref})}d.seqLength!==void 0&&U(this,Le).set(l,m+1)}return o}};Fe=new WeakMap;Le=new WeakMap;function nh(t,n,e){return le(this,null,function*(){n=n.replace(/#/g,"%23").replace(/ /g,"%20").replace(/([^:]\/)\/+/g,"$1");const s=yield e.fetch(n);if(s.status!==200){console.warn("Error loading buffer. Invalid status: ",s.status,n);return}try{const r=yield s.arrayBuffer();return yield t.decodeAudioData(r)}catch(r){console.warn("Error loading buffer",r,n)}})}function rh(){if(typeof navigator>"u")return!1;const t=navigator.userAgent;return t.includes("Safari")&&!t.includes("Chrome")&&!t.includes("Chromium")}function ko(t){if(typeof document>"u")return null;const n=rh(),e=document.createElement("audio");for(let s=0;s<t.length;s++){const r=t[s];if(n&&r==="ogg")continue;const i=e.canPlayType(`audio/${r}`);if(i==="probably"||i==="maybe")return r;if(r==="m4a"){const a=e.canPlayType("audio/aac");if(a==="probably"||a==="maybe")return r}}return null}var Cn,Nn,In,sh=class{constructor(t,n){lt(this,Cn),lt(this,Nn),lt(this,In,new Map);var e;at(this,Cn,t),at(this,Nn,(e=n==null?void 0:n.storage)!=null?e:Hr)}load(t,n){return le(this,null,function*(){var e,s;const r=typeof n=="object"?n.buffers:void 0,i=typeof n=="function"?n:n==null?void 0:n.onProgress,a=(s=(e=ko(t.samples.formats))!=null?e:t.samples.formats[0])!=null?s:"ogg",o=t.samples.baseUrl.replace(/\/$/,""),l=ih(t),d=l.length;let m=0;const f=new Map;return yield Promise.all(l.map(p=>le(this,null,function*(){var h,b;const g=r==null?void 0:r.get(p);if(g){f.set(p,g),m++,i==null||i(m,d);return}const v=(b=(h=t.samples.map)==null?void 0:h[p])!=null?b:p,y=`${o}/${v}.${a}`;let _=U(this,In).get(y);if(!_){const k=yield nh(U(this,Cn),y,U(this,Nn));k&&(_=k,U(this,In).set(y,_))}_&&f.set(p,_),m++,i==null||i(m,d)}))),f})}};Cn=new WeakMap;Nn=new WeakMap;In=new WeakMap;function ih(t){const n=new Set;for(const e of t.groups)for(const s of e.regions)n.add(s.sample);return[...n]}var Tt,oh=class{constructor(t){this.compare=t,lt(this,Tt,[])}push(t){const n=U(this,Tt).length;let e=0,s=n-1,r=n;for(;e<=s;){const i=Math.floor((e+s)/2);this.compare(t,U(this,Tt)[i])<0?(r=i,s=i-1):e=i+1}U(this,Tt).splice(r,0,t)}pop(){return U(this,Tt).shift()}peek(){return U(this,Tt)[0]}removeAll(t){const n=U(this,Tt).length;return at(this,Tt,U(this,Tt).filter(e=>!t(e))),U(this,Tt).length!==n}clear(){at(this,Tt,[])}size(){return U(this,Tt).length}};Tt=new WeakMap;var ah=200,lh=50,tn,en,Un,Gt,Zt,kr,Ao,ch=class{constructor(t,n){lt(this,kr),lt(this,tn),lt(this,en),lt(this,Un),lt(this,Gt),lt(this,Zt);var e,s;at(this,tn,t),at(this,en,((e=n==null?void 0:n.lookaheadMs)!=null?e:ah)/1e3),at(this,Un,(s=n==null?void 0:n.intervalMs)!=null?s:lh),at(this,Gt,new oh((r,i)=>r.time-i.time))}schedule(t,n){var e;const s=U(this,tn).currentTime,r=(e=hh(t))!=null?e:s;if(r<=s+U(this,en))return n(t),uh;const i={time:r,event:t,callback:n};return U(this,Gt).push(i),Hn(this,kr,Ao).call(this),()=>{U(this,Gt).removeAll(a=>a===i)}}stop(){U(this,Gt).clear(),U(this,Zt)!==void 0&&(clearInterval(U(this,Zt)),at(this,Zt,void 0))}};tn=new WeakMap;en=new WeakMap;Un=new WeakMap;Gt=new WeakMap;Zt=new WeakMap;kr=new WeakSet;Ao=function(){U(this,Zt)===void 0&&at(this,Zt,setInterval(()=>{const t=U(this,tn).currentTime+U(this,en);for(;U(this,Gt).size()>0&&U(this,Gt).peek().time<=t;){const n=U(this,Gt).pop();n.callback(n.event)}U(this,Gt).size()===0&&(clearInterval(U(this,Zt)),at(this,Zt,void 0))},U(this,Un)))};function hh(t){return typeof t=="object"?t.time:void 0}var uh=()=>{},Tn,$e,Se,Rn,On,fe,He,dh=class{constructor(t,n,e,s,r,i,a){lt(this,Tn),lt(this,$e),lt(this,Se),lt(this,Rn),lt(this,On),lt(this,fe,"playing"),lt(this,He,[]),at(this,Tn,t),this.stopId=r,this.group=i,at(this,On,e.ampRelease);const o=t.createBufferSource();o.buffer=n;const l=e.detune;o.detune?o.detune.value=l:o.playbackRate.value=Math.pow(2,l/1200),e.loopAuto?(o.loop=!0,o.loopStart=n.duration*e.loopAuto.startRatio,o.loopEnd=n.duration*e.loopAuto.endRatio):e.loop&&(o.loop=!0,o.loopStart=e.loopStart,o.loopEnd=e.loopEnd||n.duration);let d;e.lpfCutoffHz<2e4&&(d=t.createBiquadFilter(),d.type="lowpass",d.frequency.value=e.lpfCutoffHz);const m=t.createGain();m.gain.value=xo(e.velocity)*Yc(e.volume);const f=t.createGain();f.gain.value=1,d?(o.connect(d),d.connect(m)):o.connect(m),m.connect(f),f.connect(s);const p=a??t.currentTime;at(this,Rn,p);const h=e.offset>0?e.offset/n.sampleRate:0;o.start(p,h),at(this,$e,o),at(this,Se,f),o.onended=()=>{at(this,fe,"stopped"),f.disconnect(),m.disconnect(),d==null||d.disconnect(),o.disconnect();for(const b of U(this,He))b();at(this,He,[])}}stop(t){if(U(this,fe)!=="playing")return;at(this,fe,"stopping");const n=t??U(this,Tn).currentTime;if(n<=U(this,Rn))U(this,$e).stop(n);else{const e=n+U(this,On);U(this,Se).gain.cancelScheduledValues(n),U(this,Se).gain.setValueAtTime(1,n),U(this,Se).gain.linearRampToValueAtTime(0,e),U(this,$e).stop(e)}}onEnded(t){U(this,fe)==="stopped"?t():U(this,He).push(t)}get isActive(){return U(this,fe)!=="stopped"}};Tn=new WeakMap;$e=new WeakMap;Se=new WeakMap;Rn=new WeakMap;On=new WeakMap;fe=new WeakMap;He=new WeakMap;var Ae,nn,rn,Ar,Mo,fh=class{constructor(){lt(this,Ar),lt(this,Ae,new Set),lt(this,nn,new Map),lt(this,rn,new Map)}add(t){U(this,Ae).add(t),Qs(U(this,nn),t.stopId).add(t),t.group!==void 0&&Qs(U(this,rn),t.group).add(t),t.onEnded(()=>Hn(this,Ar,Mo).call(this,t))}stopAll(t){for(const n of[...U(this,Ae)])n.stop(t)}stopById(t,n){const e=U(this,nn).get(t);if(e)for(const s of[...e])s.stop(n)}stopGroup(t,n){const e=U(this,rn).get(t);if(e)for(const s of[...e])s.stop(n)}get activeCount(){return U(this,Ae).size}};Ae=new WeakMap;nn=new WeakMap;rn=new WeakMap;Ar=new WeakSet;Mo=function(t){var n,e;U(this,Ae).delete(t),(n=U(this,nn).get(t.stopId))==null||n.delete(t),t.group!==void 0&&((e=U(this,rn).get(t.group))==null||e.delete(t))};function Qs(t,n){let e=t.get(n);return e||(e=new Set,t.set(n,e)),e}function Js(t,n){return t&&n?e=>{t(e),n(e)}:t??n}var mh={samples:{baseUrl:"",formats:[]},groups:[]};function ti(t){return typeof t=="object"&&t!==null&&"groups"in t&&Array.isArray(t.groups)}var Ue,sn,on,un,Ee,an,jt,We,Me,Ge,Ve,dn,fn,Wn,Bn,Po,Eo,ph=class{constructor(t,n,e){lt(this,Bn),lt(this,Ue,{loaded:0,total:0}),lt(this,sn,new Map),lt(this,on),lt(this,un),lt(this,Ee),lt(this,an),lt(this,jt),lt(this,We),lt(this,Me),lt(this,Ge),lt(this,Ve),lt(this,dn),lt(this,fn),lt(this,Wn,new Map);var s,r,i;const a=ti(n)?n:void 0,o=ti(n)?e:n;this.context=t,at(this,on,a==null?void 0:a.defaults),at(this,un,(s=o==null?void 0:o.velocity)!=null?s:100),at(this,Ve,o==null?void 0:o.onLoadProgress),at(this,dn,o==null?void 0:o.onStart),at(this,fn,o==null?void 0:o.onEnded),a!=null&&a.aliases&&at(this,Ee,new Map(Object.entries(a.aliases))),at(this,Me,new Zc(t,{destination:o==null?void 0:o.destination,volume:o==null?void 0:o.volume,volumeToGain:o==null?void 0:o.volumeToGain})),at(this,We,(r=o==null?void 0:o.scheduler)!=null?r:new ch(t)),at(this,an,new Xs(a??mh)),at(this,jt,new fh),at(this,Ge,(i=o==null?void 0:o.loader)!=null?i:new sh(t,{storage:o==null?void 0:o.storage})),a?this.load=U(this,Ge).load(a,(l,d)=>{var m;at(this,Ue,{loaded:l,total:d}),(m=U(this,Ve))==null||m.call(this,{loaded:l,total:d})}).then(l=>(at(this,sn,l),this)):this.load=Promise.resolve(this)}loadInstrument(t,n){return at(this,on,t.defaults),at(this,Ee,t.aliases?new Map(Object.entries(t.aliases)):void 0),at(this,an,new Xs(t)),U(this,Ge).load(t,{buffers:n,onProgress:(e,s)=>{var r;at(this,Ue,{loaded:e,total:s}),(r=U(this,Ve))==null||r.call(this,{loaded:e,total:s})}}).then(e=>{at(this,sn,e)})}get loadProgress(){return U(this,Ue)}get output(){return U(this,Me)}setCC(t,n){U(this,Wn).set(t,n)}start(t){const n=Hn(this,Bn,Eo).call(this,t),e=U(this,We).schedule(n,s=>Hn(this,Bn,Po).call(this,s));return s=>{e(),U(this,jt).stopById(n.stopId,s)}}stop(t){t===void 0?U(this,jt).stopAll():typeof t=="string"||typeof t=="number"?U(this,jt).stopById(t):t.stopId!==void 0?U(this,jt).stopById(t.stopId,t.time):U(this,jt).stopAll(t.time)}disconnect(){U(this,jt).stopAll(),U(this,Me).disconnect(),U(this,We).stop()}};Ue=new WeakMap;sn=new WeakMap;on=new WeakMap;un=new WeakMap;Ee=new WeakMap;an=new WeakMap;jt=new WeakMap;We=new WeakMap;Me=new WeakMap;Ge=new WeakMap;Ve=new WeakMap;dn=new WeakMap;fn=new WeakMap;Wn=new WeakMap;Bn=new WeakSet;Po=function(t){const{midi:n,velocity:e,time:s,stopId:r,duration:i,detune:a,lpfCutoffHz:o,loop:l,ampRelease:d,onStart:m,onEnded:f}=t,p=U(this,an).match(n,e,U(this,Wn));for(const b of p)b.offBy!==void 0&&U(this,jt).stopGroup(b.offBy,s);let h=!1;for(const b of p){const g=U(this,sn).get(b.sample);if(!g)continue;const v=Jc(U(this,on),b.groupRef,b.regionRef,n,e,{detune:a,lpfCutoffHz:o,loop:l,ampRelease:d}),y=new dh(this.context,g,v,U(this,Me).input,r,b.group,s);if(U(this,jt).add(y),h||(m==null||m(t),h=!0),f&&y.onEnded(()=>f(t)),i!=null){const k=(s??this.context.currentTime)+i,M=Math.max(0,(k-this.context.currentTime)*1e3);setTimeout(()=>y.stop(k),M)}}};Eo=function(t){var n,e,s,r,i,a,o,l;if(typeof t=="string"||typeof t=="number"){const m=(s=(e=hn(t))!=null?e:(n=U(this,Ee))==null?void 0:n.get(String(t)))!=null?s:0;return{note:t,midi:m,velocity:U(this,un),stopId:t,onStart:U(this,dn),onEnded:U(this,fn)}}const d=(a=(i=hn(t.note))!=null?i:(r=U(this,Ee))==null?void 0:r.get(String(t.note)))!=null?a:0;return Kc(De({},t),{midi:d,velocity:(o=t.velocity)!=null?o:U(this,un),stopId:(l=t.stopId)!=null?l:t.note,onStart:Js(U(this,dn),t.onStart),onEnded:Js(U(this,fn),t.onEnded)})};function Co(t){if(t.length===0)return[];const n=[...t].sort(([e],[s])=>e-s);return n.map(([e,s],r)=>{const i=r===0?0:Math.floor((n[r-1][0]+e)/2)+1,a=r===n.length-1?127:Math.floor((e+n[r+1][0])/2);return{keyRange:[i,a],pitch:e,sample:s}})}function gh(t,n){var e;const s=(e=ko(["ogg","mp3"]))!=null?e:"mp3";return console.debug(`Soundfont: using ${s} format for ${t}`),`https://gleitz.github.io/midi-js-soundfonts/${n}/${t}-${s}.js`}var bh=["MusyngKite","FluidR3_GM"],ei=bh[0];function yh(t,n){if(!t.startsWith("http"))return`https://goldst.dev/midi-js-soundfonts/${n}/${t}-loop.json`}function vh(t,n=44100){return le(this,null,function*(){if(t)try{const e=yield fetch(t);if(e.status!==200)return;const s=yield e.json(),r={};return Object.keys(s).forEach(i=>{const a=hn(i);if(a){const o=s[i];r[a]=[o[0]/n,o[1]/n]}}),r}catch{return}})}var Yt,zn,No=class{constructor(t,n){this.context=t,lt(this,Yt),lt(this,zn,!1),this.config=xh(n);const e={destination:n.destination,volume:n.volume,velocity:n.velocity,storage:this.config.storage,onLoadProgress:n.onLoadProgress};at(this,Yt,new ph(t,e));const s=t.createGain();s.gain.value=this.config.extraGain,U(this,Yt).output.addInsert(s),this.load=_h(t,this.config).then(({buffers:r,noteNames:i,loopData:a})=>(at(this,zn,!!a),U(this,Yt).loadInstrument(Io(i,a),r))).then(()=>this)}get hasLoops(){return U(this,zn)}get output(){return U(this,Yt).output}loaded(){return le(this,null,function*(){return console.warn("deprecated: use load instead"),this.load})}disconnect(){return U(this,Yt).disconnect()}start(t){return U(this,Yt).start(typeof t=="object"?t:{note:t})}stop(t){return U(this,Yt).stop(t===void 0?void 0:t)}};Yt=new WeakMap;zn=new WeakMap;function _h(t,n){return le(this,null,function*(){const[{buffers:e,noteNames:s},r]=yield Promise.all([wh(t,n),vh(n.loopDataUrl)]);return{buffers:e,noteNames:s,loopData:r}})}function wh(t,n){return le(this,null,function*(){const e=yield(yield n.storage.fetch(n.instrumentUrl)).text(),s=Sh(e),r=Object.keys(s),i=new Map;return yield Promise.all(r.map(a=>le(this,null,function*(){if(hn(a))try{const l=Ah(kh(s[a])),d=yield t.decodeAudioData(l);i.set(a,d)}catch(l){console.warn(`Soundfont: failed to decode note ${a}`,l instanceof Error?l.message:l)}}))),{buffers:i,noteNames:[...i.keys()]}})}function Io(t,n){const e=[];for(const i of t){const a=hn(i);a!==void 0&&e.push([a,i])}const r=Co(e).map(({keyRange:i,pitch:a,sample:o})=>{const l={sample:o,keyRange:i,pitch:a};if(n){const d=n[a];d&&(l.loop=!0,l.loopStart=d[0],l.loopEnd=d[1])}return l});return{samples:{baseUrl:"",formats:["ogg"]},groups:[{regions:r}]}}function xh(t){var n,e,s,r,i;if(!t.instrument&&!t.instrumentUrl)throw Error("Soundfont: instrument or instrumentUrl is required");const a={kit:(n=t.kit)!=null?n:ei,instrument:t.instrument,storage:(e=t.storage)!=null?e:Hr,extraGain:(s=t.extraGain)!=null?s:5,loadLoopData:(r=t.loadLoopData)!=null?r:!1,loopDataUrl:t.loopDataUrl,instrumentUrl:(i=t.instrumentUrl)!=null?i:""};if(a.instrument&&a.instrument.startsWith("http")&&(console.warn("Use 'instrumentUrl' instead of 'instrument' to load from a URL"),a.instrumentUrl=a.instrument,a.instrument=void 0),a.instrumentUrl)(a.kit!==ei||a.instrument)&&console.warn("Soundfont: 'kit' and 'instrument' config parameters are ignored because 'instrumentUrl' is explicitly set.");else if(a.instrument)a.instrumentUrl=gh(a.instrument,a.kit);else throw Error("Soundfont: 'instrument' or 'instrumentUrl' configuration parameter is required");return a.loadLoopData&&a.instrument&&!a.loopDataUrl&&(a.loopDataUrl=yh(a.instrument,a.kit)),a}function Sh(t){const n=t.indexOf("MIDI.Soundfont.");if(n<0)throw Error("Invalid MIDI.js Soundfont format");const e=t.indexOf("=",n)+2,s=t.lastIndexOf(",");return JSON.parse(t.slice(e,s)+"}")}function kh(t){return t.slice(t.indexOf(",")+1)}function Ah(t){const n=window.atob(t),e=n.length,s=new Uint8Array(e);for(let r=0;r<e;r++)s[r]=n.charCodeAt(r);return s.buffer}const Mh=Object.freeze(Object.defineProperty({__proto__:null,HttpStorage:Hr,Soundfont:No,soundfontToSmplrJson:Io,spreadKeyRanges:Co},Symbol.toStringTag,{value:"Module"})),ni=44100;async function Ph(t,n,e=4,s=2.5,r=120){const i=Pe(t,e),a=n==="arpeggio"?s+i.length*r/1e3:s,o=new OfflineAudioContext(2,Math.ceil(ni*a),ni),l=new No(o,{instrument:"acoustic_grand_piano"});await l.load;for(let d=0;d<i.length;d++){const m=n==="arpeggio"?d*r/1e3:0;l.start({note:i[d],time:m,duration:s})}return o.startRendering()}function Eh(t){const n=t.numberOfChannels,e=t.sampleRate,s=16,r=s/8,i=t.length,a=i*n*r,o=44+a,l=new ArrayBuffer(o),d=new DataView(l);kn(d,0,"RIFF"),d.setUint32(4,o-8,!0),kn(d,8,"WAVE"),kn(d,12,"fmt "),d.setUint32(16,16,!0),d.setUint16(20,1,!0),d.setUint16(22,n,!0),d.setUint32(24,e,!0),d.setUint32(28,e*n*r,!0),d.setUint16(32,n*r,!0),d.setUint16(34,s,!0),kn(d,36,"data"),d.setUint32(40,a,!0);const m=Array.from({length:n},(p,h)=>t.getChannelData(h));let f=44;for(let p=0;p<i;p++)for(let h=0;h<n;h++){const b=Math.max(-1,Math.min(1,m[h][p]));d.setInt16(f,b<0?b*32768:b*32767,!0),f+=2}return new Uint8Array(l)}function kn(t,n,e){for(let s=0;s<e.length;s++)t.setUint8(n+s,e.charCodeAt(s))}async function ri(t,n,e){const s=await Ph(t,n,e);return Eh(s)}function To(t){return t.replace(/[^a-zA-Z0-9\-_ ]/g,"_").slice(0,80)}function Ch(t){const{clone:n}=Jn(t),e=new XMLSerializer().serializeToString(n);return new TextEncoder().encode(e)}function Nh(t,n=2){return new Promise((e,s)=>{const{clone:r}=Jn(t),i=r.viewBox.baseVal,a=i.width,o=i.height;r.setAttribute("width",String(a)),r.setAttribute("height",String(o));const l=new XMLSerializer().serializeToString(r),d=new Blob([l],{type:"image/svg+xml;charset=utf-8"}),m=URL.createObjectURL(d),f=new Image;f.onload=()=>{const p=document.createElement("canvas");p.width=a*n,p.height=o*n;const h=p.getContext("2d");if(!h){URL.revokeObjectURL(m),s(new Error("No canvas context"));return}h.scale(n,n),h.drawImage(f,0,0,a,o),URL.revokeObjectURL(m),p.toBlob(b=>{if(!b){s(new Error("toBlob failed"));return}b.arrayBuffer().then(g=>e(new Uint8Array(g)))},"image/png")},f.onerror=()=>{URL.revokeObjectURL(m),s(new Error("SVG load failed"))},f.src=m})}async function Ro(t,n,e){const s=To(e);if(n.svgElement){t.file(`${s}.svg`,Ch(n.svgElement));try{const i=await Nh(n.svgElement);t.file(`${s}.png`,i)}catch{}}const r=Qn({notes:n.notes});t.file(`${s}.mid`,r);try{const i=await ri(n.notes,"block");t.file(`${s}_chord.wav`,i)}catch{}try{const i=await ri(n.notes,"arpeggio");t.file(`${s}_arpeggio.wav`,i)}catch{}}async function Ih(t,n){const e=new _o;return await Ro(e,n,t),e.generateAsync({type:"blob"})}async function Th(t,n){const e=new _o;for(let s=0;s<n.length;s++){const i=`${String.fromCharCode(65+s)}_${To(n[s].label)}`,a=e.folder(i);await Ro(a,n[s],t)}return e.generateAsync({type:"blob"})}function si(t,n){const e=URL.createObjectURL(t),s=document.createElement("a");s.href=e,s.download=n,s.click(),setTimeout(()=>URL.revokeObjectURL(e),1e3)}const Rh="ABCDEFGHIJKLMNOPQRSTUVWXYZ";function Oh({chord:t,format:n,theme:e,highlightColor:s,scale:r,display:i,uiTheme:a,onExportStatus:o,onVariation:l,renderVariationExtras:d,chordIndex:m}){var A;const[f,p]=ft.useState(0),[h,b]=ft.useState(3),[g,v]=ft.useState(!1),y=ft.useRef(null),_=ft.useMemo(()=>{try{const N=Vn(t);if(N.isScale||!N.chordName)return null;const u=mn(N.chordName,N.inversion);let z=u.notes;if(N.startingNote){const W=Ce[N.startingNote]??N.startingNote,st=z.indexOf(W);st>0&&(z=[...z.slice(st),...z.slice(0,st)])}const Q=Zn(u.type,z);return{parsed:N,root:u.root,quality:Q,notes:z,type:u.type,styleHint:N.styleHint}}catch{return null}},[t]),k=ft.useMemo(()=>_?rc(_.root,_.quality,_.notes,h,{styleHint:_.styleHint}):[],[_,h]),M=_?`${_.root}:${_.notes.join(",")}`:t,[w,T]=ft.useState(M);if(M!==w&&(T(M),p(0),b(3)),!_||k.length<=1)return I.jsx($n,{chord:t,format:n,theme:e,highlightColor:s,scale:r,display:i,uiTheme:a,onVariation:l,renderVariationExtras:d,voicingId:"default",chordIndex:m??0});const P=k[Math.min(f,k.length-1)],j=ft.useMemo(()=>{if(!_)return"";const N=[],u=_.parsed;return u.showNoteNames&&(u.noteNameMode==="midi"?N.push("midi note names"):N.push("note names"),u.noteNameSize&&u.noteNameSize!=="base"&&N.push(`in ${u.noteNameSize}`)),u.customFingering?N.push(`custom fingering "${u.customFingering.join(",")}"`):u.autoFingering?N.push("with fingering"):u.fingering&&N.push(`fingering ${u.fingering.join("-")}`),u.fingeringSize&&u.fingeringSize!=="base"&&N.push(`fingering in ${u.fingeringSize}`),u.colorTheme&&N.push(u.colorTheme),u.scale!=null&&N.push(`size ${Math.round(u.scale*100)}`),u.showHeading&&N.push("heading"),N.length>0?" "+N.join(" "):""},[_]);let C=t;if(f>0){const N=_.parsed.chordName??t;P.source==="inversion"?C=`${N} starting on ${P.notes[0]}${j}`:P.source==="library"?C=`${N} ${P.label} style${j}`:C=`${N}${j}`}const L=ft.useCallback(()=>{var N;return((N=y.current)==null?void 0:N.querySelector("svg"))??null},[]),V=ft.useCallback(async N=>{v(!1),o==null||o("preparing");try{const u=(_==null?void 0:_.parsed.chordName)??"chord";if(N==="this"){const z=L(),Q={label:P.label,notes:P.notes,svgElement:z},W=await Ih(u,Q);si(W,`${u.replace(/[^a-zA-Z0-9]/g,"_")}.zip`)}else{const z=k.map((W,st)=>({label:W.label,notes:W.notes,svgElement:st===f?L():null})),Q=await Th(u,z);si(Q,`${u.replace(/[^a-zA-Z0-9]/g,"_")}_all.zip`)}}catch(u){console.error("ZIP export failed:",u)}finally{o==null||o("idle")}},[_,P,f,k,L,o]);return I.jsxs("div",{className:"voicing-variant-toggle",style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"0.75rem"},children:[I.jsx("div",{className:"voicing-output-wrapper",ref:y,style:{width:"100%",overflowX:"auto",display:"flex",justifyContent:"center"},children:I.jsx($n,{chord:C,format:n,theme:e,highlightColor:s,scale:r,display:i,uiTheme:a,onVariation:l,renderVariationExtras:d,voicingId:((A=k[f])==null?void 0:A.label)??"default",chordIndex:m??0})}),I.jsxs("div",{className:"variant-toggle-row",style:{display:"flex",alignItems:"flex-start",gap:6,justifyContent:"center"},children:[k.map((N,u)=>I.jsxs("button",{className:"variant-pill","data-active":u===f,onClick:()=>p(u),style:{display:"flex",flexDirection:"column",alignItems:"center",gap:3,padding:"12px 22px 10px",border:u===f?"1px solid transparent":"1px solid var(--btn-border)",borderRadius:10,background:u===f?"var(--pill-active-bg)":"var(--pill-bg)",color:u===f?"var(--pill-active-text)":"var(--text-muted)",boxShadow:u===f?"0 1px 6px var(--pill-active-shadow)":"none",cursor:"pointer",fontFamily:"inherit",fontSize:"1.2rem",fontWeight:u===f?600:500,transition:"all 0.2s ease",minWidth:64},children:[I.jsx("span",{children:Rh[u]}),I.jsx("span",{className:"variant-pill-label",style:{fontSize:"0.78rem",fontWeight:400,color:"var(--text-dim)",whiteSpace:"nowrap",maxWidth:80,overflow:"hidden",textOverflow:"ellipsis"},children:N.label})]},N.id)),k.length>=h&&I.jsx("button",{className:"variant-pill-add",onClick:()=>b(N=>N+3),style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px 16px",border:"1px dashed var(--btn-border)",borderRadius:10,background:"transparent",color:"var(--text-muted)",cursor:"pointer",fontFamily:"inherit",fontSize:"1.2rem",fontWeight:400,transition:"all 0.2s ease",minWidth:52,height:52},title:"Generate more voicing options",children:"+"}),I.jsxs("div",{className:"zip-export-container",style:{position:"relative"},children:[I.jsxs("button",{className:"variant-pill-zip",onClick:()=>v(N=>!N),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,padding:"12px 16px",border:"1px solid var(--btn-border)",borderRadius:10,background:"var(--pill-bg)",color:"var(--text-muted)",cursor:"pointer",fontFamily:"inherit",fontSize:"0.78rem",fontWeight:500,transition:"all 0.2s ease",height:52,whiteSpace:"nowrap"},title:"Download .zip package",children:[I.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:I.jsx("path",{d:"M3.5 0A1.5 1.5 0 002 1.5v13A1.5 1.5 0 003.5 16h9a1.5 1.5 0 001.5-1.5V4.707A1.5 1.5 0 0013.56 3.65L10.354.44A1.5 1.5 0 009.293 0H3.5zM7 3v1h2V3H7zm0 2v1h2V5H7zm0 2v1h2V7H7zm0 2h2v2H7V9z"})}),".zip"]}),g&&I.jsxs("div",{className:"zip-menu",style:{position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",marginTop:6,display:"flex",gap:4,padding:4,background:"var(--pill-active-bg)",border:"1px solid var(--btn-border)",borderRadius:10,boxShadow:"0 4px 16px var(--glass-shadow)",zIndex:10},children:[I.jsx("button",{className:"zip-menu-btn",onClick:()=>V("this"),style:{padding:"8px 16px",border:"none",borderRadius:8,background:"transparent",color:"var(--text)",cursor:"pointer",fontFamily:"inherit",fontSize:"0.8rem",fontWeight:500,whiteSpace:"nowrap",transition:"background 0.15s ease"},children:"This"}),I.jsx("button",{className:"zip-menu-btn",onClick:()=>V("all"),style:{padding:"8px 16px",border:"none",borderRadius:8,background:"transparent",color:"var(--text)",cursor:"pointer",fontFamily:"inherit",fontSize:"0.8rem",fontWeight:500,whiteSpace:"nowrap",transition:"background 0.15s ease"},children:"All"})]})]})]})]})}const Bh=[{label:"50%",value:.5},{label:"60%",value:.6},{label:"70%",value:.7},{label:"80%",value:.8},{label:"90%",value:.9},{label:"100%",value:1}];function zh({result:t,format:n,theme:e,highlightColor:s,showPlayback:r=!0,defaultGroupMode:i="by-progression",uiTheme:a,onVariation:o,renderVariationExtras:l}){const d=gn(a),m=d.tokens,[f,p]=ft.useState(i),[h,b]=ft.useState("compact"),[g,v]=ft.useState("keyboard"),[y,_]=ft.useState(.5),[k,M]=ft.useState("off"),[w,T]=ft.useState(!1),P={display:"inline-flex",background:m.btnBg,borderRadius:10,padding:3,gap:2},j=C=>({fontFamily:"inherit",fontSize:"0.8rem",fontWeight:C?600:500,padding:"6px 14px",border:"none",borderRadius:8,background:C?m.btnBgActive:"transparent",color:C?m.btnTextActive:m.btnText,cursor:"pointer",transition:"all 0.2s ease",whiteSpace:"nowrap",letterSpacing:"0.01em",boxShadow:C?"0 1px 4px rgba(0,0,0,0.15)":"none"});return I.jsx(Bt,{value:d,children:I.jsxs("div",{className:"bc-progression","data-bc-theme":d.mode,style:{width:"100%",maxWidth:"100vw",color:m.text},children:[I.jsxs("div",{className:"bc-progression__controls",style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,marginBottom:16},children:[I.jsxs("span",{className:"bc-progression__title",style:{fontWeight:700,fontSize:16},children:[t.progressionName," in ",t.key]}),I.jsxs("div",{className:"bc-progression__controls-row",style:{display:"flex",gap:"0.75rem",alignItems:"center",flexWrap:"wrap",justifyContent:"center"},children:[I.jsxs("div",{className:"bc-progression__group-toggle",style:P,children:[I.jsx("button",{className:"bc-progression__btn",style:j(f==="by-progression"),onClick:()=>p("by-progression"),children:"By Progression"}),I.jsx("button",{className:"bc-progression__btn",style:j(f==="by-chord"),onClick:()=>p("by-chord"),children:"By Chord"})]}),I.jsxs("div",{className:"bc-progression__format-toggle",style:P,children:[I.jsx("button",{className:"bc-progression__btn",style:j(h==="compact"),onClick:()=>b("compact"),children:"Compact"}),I.jsx("button",{className:"bc-progression__btn",style:j(h==="exact"),onClick:()=>b("exact"),children:"Full"})]}),I.jsx("div",{className:"bc-progression__display-toggle",style:P,children:["keyboard","staff","both"].map(C=>I.jsx("button",{className:"bc-progression__btn",style:j(g===C),onClick:()=>v(C),children:C==="keyboard"?"Keyboard":C==="staff"?"Staff":"Both"},C))}),I.jsx("div",{className:"bc-progression__scale-toggle",style:P,children:Bh.map(C=>I.jsx("button",{className:"bc-progression__btn",style:j(y===C.value),onClick:()=>_(C.value),children:C.label},C.value))}),I.jsxs("div",{className:"bc-progression__names-toggle",style:P,children:[I.jsx("button",{className:"bc-progression__btn",style:j(k==="off"),onClick:()=>M("off"),children:"Names Off"}),I.jsx("button",{className:"bc-progression__btn",style:j(k==="notes"),onClick:()=>M("notes"),children:"Notes"}),I.jsx("button",{className:"bc-progression__btn",style:j(k==="midi"),onClick:()=>M("midi"),children:"MIDI"})]}),I.jsxs("div",{className:"bc-progression__fingering-toggle",style:P,children:[I.jsx("button",{className:"bc-progression__btn",style:j(!w),onClick:()=>T(!1),children:"No Fingering"}),I.jsx("button",{className:"bc-progression__btn",style:j(w),onClick:()=>T(!0),children:"Fingering"})]})]})]}),f==="by-progression"?t.examples.map((C,L)=>I.jsx(tr,{chords:C.chords,label:C.label,format:n??h,theme:e,highlightColor:s,showPlayback:r,scale:y,display:g,showNoteNames:k!=="off",noteNameMode:k==="midi"?"midi":"pitch-class",showFingering:w,onVariation:o,renderVariationExtras:l},L)):jh(t,n??h,e,s,r,y,g,k,w,o,l)]})})}function jh(t,n,e,s,r,i,a,o,l,d,m){if(t.examples.length===0)return null;const f=t.examples[0].chords.length,p=[];for(let h=0;h<f;h++){const b=t.examples[0].chords[h].symbol,g=t.examples.map(v=>({chord:v.chords[h],style:v.label}));p.push({symbol:b,chords:g})}return p.map((h,b)=>I.jsx(tr,{chords:h.chords.map(g=>g.chord),label:`${h.symbol} — ${h.chords.length} voicings`,format:n,theme:e,highlightColor:s,showPlayback:r,scale:i,display:a,showNoteNames:o!=="off",noteNameMode:o==="midi"?"midi":"pitch-class",showFingering:l,onVariation:d,renderVariationExtras:m},b))}function Dh(t){return t<=1?1:t<=2||t<=3?2:4}class Fh extends ft.Component{constructor(){super(...arguments),this.state={error:null}}static getDerivedStateFromError(n){return{error:n.message}}render(){return this.state.error?I.jsxs("div",{className:"bc-chord-sheet__chord-error",style:{padding:"8px 12px",fontSize:"0.75rem",color:"#c0392b",textAlign:"center"},children:[this.props.chordRef,": ",this.state.error]}):this.props.children}}function Lh({data:t,printMode:n,uiTheme:e,className:s,style:r,onVariation:i,renderVariationExtras:a}){const o=t.sections.length,l=I.jsxs("div",{className:`bc-chord-sheet${s?` ${s}`:""}`,style:r,children:[t.heading&&I.jsx("h2",{className:"bc-chord-sheet__heading",style:{margin:"0 0 4px",fontSize:"1.3rem",fontWeight:600},children:t.heading}),t.subheading&&I.jsx("p",{className:"bc-chord-sheet__subheading",style:{margin:"0 0 16px",fontSize:"0.85rem",opacity:.7},children:t.subheading}),t.sections.map((m,f)=>I.jsx($h,{section:m,sectionIndex:f,sectionCount:o,sheetDefaults:t.defaults,printMode:n,uiTheme:e,onVariation:i,renderVariationExtras:a},m.id??f))]});if(!e)return l;const d=gn(e);return I.jsx(Bt,{value:d,children:l})}function $h({section:t,sectionIndex:n,sectionCount:e,sheetDefaults:s,printMode:r,uiTheme:i,onVariation:a,renderVariationExtras:o}){const l=Dh(t.chords.length);return I.jsxs("section",{className:"bc-chord-sheet__section",style:{marginBottom:24},children:[t.heading&&I.jsx("h3",{className:"bc-chord-sheet__section-heading",style:{margin:"0 0 2px",fontSize:"1rem",fontWeight:600},children:t.heading}),t.subheading&&I.jsx("p",{className:"bc-chord-sheet__section-subheading",style:{margin:"0 0 8px",fontSize:"0.8rem",opacity:.65},children:t.subheading}),t.textAbove&&I.jsx("div",{className:"bc-chord-sheet__text--above",style:{marginBottom:8,fontSize:"0.85rem",whiteSpace:"pre-wrap"},children:t.textAbove}),I.jsx("div",{className:"bc-chord-sheet__grid",style:{display:"flex",flexWrap:"wrap",gap:12,alignItems:"flex-start"},children:t.chords.map((d,m)=>{const f=no(n,m,e,t.id),p=eo(s,t.defaults,d);return I.jsxs("div",{className:"bc-chord-sheet__chord",style:{textAlign:"center",flex:`0 1 calc(${100/l}% - ${(l-1)*12/l}px)`,minWidth:0},children:[!r&&I.jsx("span",{className:"bc-chord-sheet__chord-ref",style:{display:"inline-block",fontSize:"0.65rem",fontWeight:500,opacity:.45,marginBottom:2},children:f}),d.chordHeading&&I.jsx("div",{className:"bc-chord-sheet__chord-heading",style:{fontSize:"0.85rem",fontWeight:600,marginBottom:2},children:d.chordHeading}),I.jsx(Fh,{chordRef:f,children:I.jsx(Hh,{chord:d,resolved:p,uiTheme:i,chordIndex:m,onVariation:a,renderVariationExtras:o})}),d.annotationText&&I.jsx("div",{className:"bc-chord-sheet__annotation",style:{fontSize:"0.75rem",opacity:.6,marginTop:2,whiteSpace:"pre-wrap"},children:d.annotationText})]},m)})}),t.textBelow&&I.jsx("div",{className:"bc-chord-sheet__text--below",style:{marginTop:8,fontSize:"0.85rem",whiteSpace:"pre-wrap"},children:t.textBelow})]})}function Hh({chord:t,resolved:n,uiTheme:e,chordIndex:s,onVariation:r,renderVariationExtras:i}){return I.jsx($n,{chord:t.chord,format:n.format,theme:n.theme,highlightColor:n.highlightColor,padding:n.padding,scale:n.scale,display:n.display,uiTheme:e,onVariation:r,renderVariationExtras:i,chordIndex:s,voicingId:"default"})}exports.ARPEGGIO_BPM=oo;exports.BLACK_KEY_HEIGHT_COMPACT=oi;exports.BLACK_KEY_HEIGHT_EXACT=ai;exports.BLACK_KEY_OFFSETS=ci;exports.BLACK_KEY_OFFSETS_EXACT=hi;exports.BLACK_KEY_RY=jn;exports.BLACK_KEY_WIDTH=Cr;exports.BLACK_KEY_WIDTH_EXACT=ii;exports.BRAVURA_GLYPHS=_i;exports.CHORD_SHEET_SCHEMA_VERSION=Dn;exports.ChordGroup=tr;exports.ChordSheet=Lh;exports.DARK_THEME=co;exports.DEFAULT_BLACK_FILL=ae;exports.DEFAULT_STROKE=li;exports.DEFAULT_STROKE_WIDTH=Ke;exports.DEFAULT_UI_THEME=Fn;exports.DEFAULT_WHITE_FILL=oe;exports.ENABLE_CHORD_LOGGING=xa;exports.FLAT_TO_SHARP=Ce;exports.FORM_TEMPLATES=Pn;exports.LIGHT_THEME=lo;exports.LOG_SCHEMA_VERSION=Zi;exports.MAX_EXAMPLES=ge;exports.PETALUMA_GLYPHS=la;exports.PianoChord=$n;exports.PianoKeyboard=me;exports.ProgressionView=zh;exports.SHOW_NOTE_NAMES=io;exports.SYSTEM_DEFAULTS=to;exports.StaffNotation=Ln;exports.UIThemeProvider=Bt;exports.VOICING_LIBRARY=Yn;exports.VoicingVariantToggle=Oh;exports.WHITE_KEY_HEIGHT_COMPACT=Pr;exports.WHITE_KEY_HEIGHT_EXACT=Er;exports.WHITE_KEY_RY=re;exports.WHITE_KEY_WIDTH=pe;exports.WHITE_KEY_WIDTH_EXACT=Mr;exports.WHITE_NOTES_WITH_SHARPS=ui;exports.WHITE_NOTE_ORDER=gt;exports.arpeggioDelayMs=ao;exports.autoFingering=cn;exports.autoSelectVoicing=Zl;exports.calculateLayout=qn;exports.chordRef=no;exports.computeKeyboard=ln;exports.computeStaffLayout=yi;exports.computeSvgDimensions=Nr;exports.decodeChordSheet=xc;exports.downloadMidi=Yi;exports.downloadPng=go;exports.downloadSvg=po;exports.encodeChordSheet=wc;exports.findTemplate=Gi;exports.findVoicing=Xn;exports.generateLockedHands=Xl;exports.generateMidiFile=Qn;exports.getAlternativeVoicings=Yl;exports.getDefaultGlyphs=xi;exports.getTheme=yc;exports.getUIThemeTokens=Fr;exports.inferStyle=jr;exports.isProgressionRequest=Ma;exports.logChordRequest=Xi;exports.mapHighlights=Ir;exports.mapToVoicingQuality=Zn;exports.normalizeNote=St;exports.parseChordDescription=Vn;exports.parseProgressionRequest=Pa;exports.playArpeggiated=fo;exports.playBlock=uo;exports.processChordRequest=_c;exports.queryVoicings=ie;exports.realizeVoicing=ql;exports.realizeVoicingFull=Dr;exports.resolveChord=mn;exports.resolveDefaults=eo;exports.resolveProgression=Ui;exports.resolveProgressionRequest=oc;exports.resolveTheme=Ji;exports.resolveUITheme=gn;exports.selectByRange=Ki;exports.setDefaultGlyphs=ca;exports.solvePolychord=tc;exports.solveSlashChord=ec;exports.tokenizeProgression=Wi;exports.useUITheme=pn;exports.validateVersion=ro;exports.voicingPitchClasses=Re;
12
+ */var Ys;function Gc(){return Ys||(Ys=1,(function(t,n){(function(e){t.exports=e()})(function(){return(function e(s,r,i){function a(d,m){if(!r[d]){if(!s[d]){var f=typeof An=="function"&&An;if(!m&&f)return f(d,!0);if(o)return o(d,!0);var p=new Error("Cannot find module '"+d+"'");throw p.code="MODULE_NOT_FOUND",p}var h=r[d]={exports:{}};s[d][0].call(h.exports,function(b){var g=s[d][1][b];return a(g||b)},h,h.exports,e,s,r,i)}return r[d].exports}for(var o=typeof An=="function"&&An,l=0;l<i.length;l++)a(i[l]);return a})({1:[function(e,s,r){var i=e("./utils"),a=e("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(l){for(var d,m,f,p,h,b,g,v=[],y=0,_=l.length,S=_,M=i.getTypeOf(l)!=="string";y<l.length;)S=_-y,f=M?(d=l[y++],m=y<_?l[y++]:0,y<_?l[y++]:0):(d=l.charCodeAt(y++),m=y<_?l.charCodeAt(y++):0,y<_?l.charCodeAt(y++):0),p=d>>2,h=(3&d)<<4|m>>4,b=1<S?(15&m)<<2|f>>6:64,g=2<S?63&f:64,v.push(o.charAt(p)+o.charAt(h)+o.charAt(b)+o.charAt(g));return v.join("")},r.decode=function(l){var d,m,f,p,h,b,g=0,v=0,y="data:";if(l.substr(0,y.length)===y)throw new Error("Invalid base64 input, it looks like a data url.");var _,S=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===o.charAt(64)&&S--,l.charAt(l.length-2)===o.charAt(64)&&S--,S%1!=0)throw new Error("Invalid base64 input, bad content length.");for(_=a.uint8array?new Uint8Array(0|S):new Array(0|S);g<l.length;)d=o.indexOf(l.charAt(g++))<<2|(p=o.indexOf(l.charAt(g++)))>>4,m=(15&p)<<4|(h=o.indexOf(l.charAt(g++)))>>2,f=(3&h)<<6|(b=o.indexOf(l.charAt(g++))),_[v++]=d,h!==64&&(_[v++]=m),b!==64&&(_[v++]=f);return _}},{"./support":30,"./utils":32}],2:[function(e,s,r){var i=e("./external"),a=e("./stream/DataWorker"),o=e("./stream/Crc32Probe"),l=e("./stream/DataLengthProbe");function d(m,f,p,h,b){this.compressedSize=m,this.uncompressedSize=f,this.crc32=p,this.compression=h,this.compressedContent=b}d.prototype={getContentWorker:function(){var m=new a(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),f=this;return m.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),m},getCompressedWorker:function(){return new a(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},d.createWorkerFrom=function(m,f,p){return m.pipe(new o).pipe(new l("uncompressedSize")).pipe(f.compressWorker(p)).pipe(new l("compressedSize")).withStreamInfo("compression",f)},s.exports=d},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,s,r){var i=e("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},r.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,s,r){var i=e("./utils"),a=(function(){for(var o,l=[],d=0;d<256;d++){o=d;for(var m=0;m<8;m++)o=1&o?3988292384^o>>>1:o>>>1;l[d]=o}return l})();s.exports=function(o,l){return o!==void 0&&o.length?i.getTypeOf(o)!=="string"?(function(d,m,f,p){var h=a,b=p+f;d^=-1;for(var g=p;g<b;g++)d=d>>>8^h[255&(d^m[g])];return-1^d})(0|l,o,o.length,0):(function(d,m,f,p){var h=a,b=p+f;d^=-1;for(var g=p;g<b;g++)d=d>>>8^h[255&(d^m.charCodeAt(g))];return-1^d})(0|l,o,o.length,0):0}},{"./utils":32}],5:[function(e,s,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(e,s,r){var i=null;i=typeof Promise<"u"?Promise:e("lie"),s.exports={Promise:i}},{lie:37}],7:[function(e,s,r){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=e("pako"),o=e("./utils"),l=e("./stream/GenericWorker"),d=i?"uint8array":"array";function m(f,p){l.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=p,this.meta={}}r.magic="\b\0",o.inherits(m,l),m.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(d,f.data),!1)},m.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},m.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},m.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(p){f.push({data:p,meta:f.meta})}},r.compressWorker=function(f){return new m("Deflate",f)},r.uncompressWorker=function(){return new m("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,s,r){function i(h,b){var g,v="";for(g=0;g<b;g++)v+=String.fromCharCode(255&h),h>>>=8;return v}function a(h,b,g,v,y,_){var S,M,w=h.file,T=h.compression,P=_!==d.utf8encode,z=o.transformTo("string",_(w.name)),E=o.transformTo("string",d.utf8encode(w.name)),L=w.comment,V=o.transformTo("string",_(L)),k=o.transformTo("string",d.utf8encode(L)),I=E.length!==w.name.length,u=k.length!==L.length,j="",X="",G="",st=w.dir,H=w.date,Q={crc32:0,compressedSize:0,uncompressedSize:0};b&&!g||(Q.crc32=h.crc32,Q.compressedSize=h.compressedSize,Q.uncompressedSize=h.uncompressedSize);var B=0;b&&(B|=8),P||!I&&!u||(B|=2048);var R=0,J=0;st&&(R|=16),y==="UNIX"?(J=798,R|=(function(Z,pt){var wt=Z;return Z||(wt=pt?16893:33204),(65535&wt)<<16})(w.unixPermissions,st)):(J=20,R|=(function(Z){return 63&(Z||0)})(w.dosPermissions)),S=H.getUTCHours(),S<<=6,S|=H.getUTCMinutes(),S<<=5,S|=H.getUTCSeconds()/2,M=H.getUTCFullYear()-1980,M<<=4,M|=H.getUTCMonth()+1,M<<=5,M|=H.getUTCDate(),I&&(X=i(1,1)+i(m(z),4)+E,j+="up"+i(X.length,2)+X),u&&(G=i(1,1)+i(m(V),4)+k,j+="uc"+i(G.length,2)+G);var tt="";return tt+=`
13
+ \0`,tt+=i(B,2),tt+=T.magic,tt+=i(S,2),tt+=i(M,2),tt+=i(Q.crc32,4),tt+=i(Q.compressedSize,4),tt+=i(Q.uncompressedSize,4),tt+=i(z.length,2),tt+=i(j.length,2),{fileRecord:f.LOCAL_FILE_HEADER+tt+z+j,dirRecord:f.CENTRAL_FILE_HEADER+i(J,2)+tt+i(V.length,2)+"\0\0\0\0"+i(R,4)+i(v,4)+z+j+V}}var o=e("../utils"),l=e("../stream/GenericWorker"),d=e("../utf8"),m=e("../crc32"),f=e("../signature");function p(h,b,g,v){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=g,this.encodeFileName=v,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(p,l),p.prototype.push=function(h){var b=h.meta.percent||0,g=this.entriesCount,v=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,l.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:g?(b+100*(g-v-1))/g:100}}))},p.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var b=this.streamFiles&&!h.file.dir;if(b){var g=a(h,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:g.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(h){this.accumulate=!1;var b=this.streamFiles&&!h.file.dir,g=a(h,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(g.dirRecord),b)this.push({data:(function(v){return f.DATA_DESCRIPTOR+i(v.crc32,4)+i(v.compressedSize,4)+i(v.uncompressedSize,4)})(h),meta:{percent:100}});else for(this.push({data:g.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var h=this.bytesWritten,b=0;b<this.dirRecords.length;b++)this.push({data:this.dirRecords[b],meta:{percent:100}});var g=this.bytesWritten-h,v=(function(y,_,S,M,w){var T=o.transformTo("string",w(M));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(y,2)+i(y,2)+i(_,4)+i(S,4)+i(T.length,2)+T})(this.dirRecords.length,g,h,this.zipComment,this.encodeFileName);this.push({data:v,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(h){this._sources.push(h);var b=this;return h.on("data",function(g){b.processChunk(g)}),h.on("end",function(){b.closedSource(b.previous.streamInfo),b._sources.length?b.prepareNextSource():b.end()}),h.on("error",function(g){b.error(g)}),this},p.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},p.prototype.error=function(h){var b=this._sources;if(!l.prototype.error.call(this,h))return!1;for(var g=0;g<b.length;g++)try{b[g].error(h)}catch{}return!0},p.prototype.lock=function(){l.prototype.lock.call(this);for(var h=this._sources,b=0;b<h.length;b++)h[b].lock()},s.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,s,r){var i=e("../compressions"),a=e("./ZipFileWorker");r.generateWorker=function(o,l,d){var m=new a(l.streamFiles,d,l.platform,l.encodeFileName),f=0;try{o.forEach(function(p,h){f++;var b=(function(_,S){var M=_||S,w=i[M];if(!w)throw new Error(M+" is not a valid compression method !");return w})(h.options.compression,l.compression),g=h.options.compressionOptions||l.compressionOptions||{},v=h.dir,y=h.date;h._compressWorker(b,g).withStreamInfo("file",{name:p,dir:v,date:y,comment:h.comment||"",unixPermissions:h.unixPermissions,dosPermissions:h.dosPermissions}).pipe(m)}),m.entriesCount=f}catch(p){m.error(p)}return m}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,s,r){function i(){if(!(this instanceof i))return new i;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new i;for(var o in this)typeof this[o]!="function"&&(a[o]=this[o]);return a}}(i.prototype=e("./object")).loadAsync=e("./load"),i.support=e("./support"),i.defaults=e("./defaults"),i.version="3.10.1",i.loadAsync=function(a,o){return new i().loadAsync(a,o)},i.external=e("./external"),s.exports=i},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,s,r){var i=e("./utils"),a=e("./external"),o=e("./utf8"),l=e("./zipEntries"),d=e("./stream/Crc32Probe"),m=e("./nodejsUtils");function f(p){return new a.Promise(function(h,b){var g=p.decompressed.getContentWorker().pipe(new d);g.on("error",function(v){b(v)}).on("end",function(){g.streamInfo.crc32!==p.decompressed.crc32?b(new Error("Corrupted zip : CRC32 mismatch")):h()}).resume()})}s.exports=function(p,h){var b=this;return h=i.extend(h||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),m.isNode&&m.isStream(p)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):i.prepareContent("the loaded zip file",p,!0,h.optimizedBinaryString,h.base64).then(function(g){var v=new l(h);return v.load(g),v}).then(function(g){var v=[a.Promise.resolve(g)],y=g.files;if(h.checkCRC32)for(var _=0;_<y.length;_++)v.push(f(y[_]));return a.Promise.all(v)}).then(function(g){for(var v=g.shift(),y=v.files,_=0;_<y.length;_++){var S=y[_],M=S.fileNameStr,w=i.resolve(S.fileNameStr);b.file(w,S.decompressed,{binary:!0,optimizedBinaryString:!0,date:S.date,dir:S.dir,comment:S.fileCommentStr.length?S.fileCommentStr:null,unixPermissions:S.unixPermissions,dosPermissions:S.dosPermissions,createFolders:h.createFolders}),S.dir||(b.file(w).unsafeOriginalName=M)}return v.zipComment.length&&(b.comment=v.zipComment),b})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,s,r){var i=e("../utils"),a=e("../stream/GenericWorker");function o(l,d){a.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(d)}i.inherits(o,a),o.prototype._bindStream=function(l){var d=this;(this._stream=l).pause(),l.on("data",function(m){d.push({data:m,meta:{percent:0}})}).on("error",function(m){d.isPaused?this.generatedError=m:d.error(m)}).on("end",function(){d.isPaused?d._upstreamEnded=!0:d.end()})},o.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},s.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,s,r){var i=e("readable-stream").Readable;function a(o,l,d){i.call(this,l),this._helper=o;var m=this;o.on("data",function(f,p){m.push(f)||m._helper.pause(),d&&d(p)}).on("error",function(f){m.emit("error",f)}).on("end",function(){m.push(null)})}e("../utils").inherits(a,i),a.prototype._read=function(){this._helper.resume()},s.exports=a},{"../utils":32,"readable-stream":16}],14:[function(e,s,r){s.exports={isNode:typeof Buffer<"u",newBufferFrom:function(i,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(i,a);if(typeof i=="number")throw new Error('The "data" argument must not be a number');return new Buffer(i,a)},allocBuffer:function(i){if(Buffer.alloc)return Buffer.alloc(i);var a=new Buffer(i);return a.fill(0),a},isBuffer:function(i){return Buffer.isBuffer(i)},isStream:function(i){return i&&typeof i.on=="function"&&typeof i.pause=="function"&&typeof i.resume=="function"}}},{}],15:[function(e,s,r){function i(w,T,P){var z,E=o.getTypeOf(T),L=o.extend(P||{},m);L.date=L.date||new Date,L.compression!==null&&(L.compression=L.compression.toUpperCase()),typeof L.unixPermissions=="string"&&(L.unixPermissions=parseInt(L.unixPermissions,8)),L.unixPermissions&&16384&L.unixPermissions&&(L.dir=!0),L.dosPermissions&&16&L.dosPermissions&&(L.dir=!0),L.dir&&(w=y(w)),L.createFolders&&(z=v(w))&&_.call(this,z,!0);var V=E==="string"&&L.binary===!1&&L.base64===!1;P&&P.binary!==void 0||(L.binary=!V),(T instanceof f&&T.uncompressedSize===0||L.dir||!T||T.length===0)&&(L.base64=!1,L.binary=!0,T="",L.compression="STORE",E="string");var k=null;k=T instanceof f||T instanceof l?T:b.isNode&&b.isStream(T)?new g(w,T):o.prepareContent(w,T,L.binary,L.optimizedBinaryString,L.base64);var I=new p(w,k,L);this.files[w]=I}var a=e("./utf8"),o=e("./utils"),l=e("./stream/GenericWorker"),d=e("./stream/StreamHelper"),m=e("./defaults"),f=e("./compressedObject"),p=e("./zipObject"),h=e("./generate"),b=e("./nodejsUtils"),g=e("./nodejs/NodejsStreamInputAdapter"),v=function(w){w.slice(-1)==="/"&&(w=w.substring(0,w.length-1));var T=w.lastIndexOf("/");return 0<T?w.substring(0,T):""},y=function(w){return w.slice(-1)!=="/"&&(w+="/"),w},_=function(w,T){return T=T!==void 0?T:m.createFolders,w=y(w),this.files[w]||i.call(this,w,null,{dir:!0,createFolders:T}),this.files[w]};function S(w){return Object.prototype.toString.call(w)==="[object RegExp]"}var M={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(w){var T,P,z;for(T in this.files)z=this.files[T],(P=T.slice(this.root.length,T.length))&&T.slice(0,this.root.length)===this.root&&w(P,z)},filter:function(w){var T=[];return this.forEach(function(P,z){w(P,z)&&T.push(z)}),T},file:function(w,T,P){if(arguments.length!==1)return w=this.root+w,i.call(this,w,T,P),this;if(S(w)){var z=w;return this.filter(function(L,V){return!V.dir&&z.test(L)})}var E=this.files[this.root+w];return E&&!E.dir?E:null},folder:function(w){if(!w)return this;if(S(w))return this.filter(function(E,L){return L.dir&&w.test(E)});var T=this.root+w,P=_.call(this,T),z=this.clone();return z.root=P.name,z},remove:function(w){w=this.root+w;var T=this.files[w];if(T||(w.slice(-1)!=="/"&&(w+="/"),T=this.files[w]),T&&!T.dir)delete this.files[w];else for(var P=this.filter(function(E,L){return L.name.slice(0,w.length)===w}),z=0;z<P.length;z++)delete this.files[P[z].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(w){var T,P={};try{if((P=o.extend(w||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=P.type.toLowerCase(),P.compression=P.compression.toUpperCase(),P.type==="binarystring"&&(P.type="string"),!P.type)throw new Error("No output type specified.");o.checkSupport(P.type),P.platform!=="darwin"&&P.platform!=="freebsd"&&P.platform!=="linux"&&P.platform!=="sunos"||(P.platform="UNIX"),P.platform==="win32"&&(P.platform="DOS");var z=P.comment||this.comment||"";T=h.generateWorker(this,P,z)}catch(E){(T=new l("error")).error(E)}return new d(T,P.type||"string",P.mimeType)},generateAsync:function(w,T){return this.generateInternalStream(w).accumulate(T)},generateNodeStream:function(w,T){return(w=w||{}).type||(w.type="nodebuffer"),this.generateInternalStream(w).toNodejsStream(T)}};s.exports=M},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(e,s,r){s.exports=e("stream")},{stream:void 0}],17:[function(e,s,r){var i=e("./DataReader");function a(o){i.call(this,o);for(var l=0;l<this.data.length;l++)o[l]=255&o[l]}e("../utils").inherits(a,i),a.prototype.byteAt=function(o){return this.data[this.zero+o]},a.prototype.lastIndexOfSignature=function(o){for(var l=o.charCodeAt(0),d=o.charCodeAt(1),m=o.charCodeAt(2),f=o.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===l&&this.data[p+1]===d&&this.data[p+2]===m&&this.data[p+3]===f)return p-this.zero;return-1},a.prototype.readAndCheckSignature=function(o){var l=o.charCodeAt(0),d=o.charCodeAt(1),m=o.charCodeAt(2),f=o.charCodeAt(3),p=this.readData(4);return l===p[0]&&d===p[1]&&m===p[2]&&f===p[3]},a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},s.exports=a},{"../utils":32,"./DataReader":18}],18:[function(e,s,r){var i=e("../utils");function a(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var l,d=0;for(this.checkOffset(o),l=this.index+o-1;l>=this.index;l--)d=(d<<8)+this.byteAt(l);return this.index+=o,d},readString:function(o){return i.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},s.exports=a},{"../utils":32}],19:[function(e,s,r){var i=e("./Uint8ArrayReader");function a(o){i.call(this,o)}e("../utils").inherits(a,i),a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},s.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,s,r){var i=e("./DataReader");function a(o){i.call(this,o)}e("../utils").inherits(a,i),a.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},a.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},a.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},s.exports=a},{"../utils":32,"./DataReader":18}],21:[function(e,s,r){var i=e("./ArrayReader");function a(o){i.call(this,o)}e("../utils").inherits(a,i),a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},s.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(e,s,r){var i=e("../utils"),a=e("../support"),o=e("./ArrayReader"),l=e("./StringReader"),d=e("./NodeBufferReader"),m=e("./Uint8ArrayReader");s.exports=function(f){var p=i.getTypeOf(f);return i.checkSupport(p),p!=="string"||a.uint8array?p==="nodebuffer"?new d(f):a.uint8array?new m(i.transformTo("uint8array",f)):new o(i.transformTo("array",f)):new l(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,s,r){r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(e,s,r){var i=e("./GenericWorker"),a=e("../utils");function o(l){i.call(this,"ConvertWorker to "+l),this.destType=l}a.inherits(o,i),o.prototype.processChunk=function(l){this.push({data:a.transformTo(this.destType,l.data),meta:l.meta})},s.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(e,s,r){var i=e("./GenericWorker"),a=e("../crc32");function o(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(o,i),o.prototype.processChunk=function(l){this.streamInfo.crc32=a(l.data,this.streamInfo.crc32||0),this.push(l)},s.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,s,r){var i=e("../utils"),a=e("./GenericWorker");function o(l){a.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}i.inherits(o,a),o.prototype.processChunk=function(l){if(l){var d=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=d+l.data.length}a.prototype.processChunk.call(this,l)},s.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(e,s,r){var i=e("../utils"),a=e("./GenericWorker");function o(l){a.call(this,"DataWorker");var d=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(m){d.dataIsReady=!0,d.data=m,d.max=m&&m.length||0,d.type=i.getTypeOf(m),d.isPaused||d._tickAndRepeat()},function(m){d.error(m)})}i.inherits(o,a),o.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,d=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,d);break;case"uint8array":l=this.data.subarray(this.index,d);break;case"array":case"nodebuffer":l=this.data.slice(this.index,d)}return this.index=d,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},s.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(e,s,r){function i(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,o){return this._listeners[a].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,o){if(this._listeners[a])for(var l=0;l<this._listeners[a].length;l++)this._listeners[a][l].call(this,o)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var o=this;return a.on("data",function(l){o.processChunk(l)}),a.on("end",function(){o.end()}),a.on("error",function(l){o.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,o){return this.extraStreamInfo[a]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},s.exports=i},{}],29:[function(e,s,r){var i=e("../utils"),a=e("./ConvertWorker"),o=e("./GenericWorker"),l=e("../base64"),d=e("../support"),m=e("../external"),f=null;if(d.nodestream)try{f=e("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(b,g){return new m.Promise(function(v,y){var _=[],S=b._internalType,M=b._outputType,w=b._mimeType;b.on("data",function(T,P){_.push(T),g&&g(P)}).on("error",function(T){_=[],y(T)}).on("end",function(){try{var T=(function(P,z,E){switch(P){case"blob":return i.newBlob(i.transformTo("arraybuffer",z),E);case"base64":return l.encode(z);default:return i.transformTo(P,z)}})(M,(function(P,z){var E,L=0,V=null,k=0;for(E=0;E<z.length;E++)k+=z[E].length;switch(P){case"string":return z.join("");case"array":return Array.prototype.concat.apply([],z);case"uint8array":for(V=new Uint8Array(k),E=0;E<z.length;E++)V.set(z[E],L),L+=z[E].length;return V;case"nodebuffer":return Buffer.concat(z);default:throw new Error("concat : unsupported type '"+P+"'")}})(S,_),w);v(T)}catch(P){y(P)}_=[]}).resume()})}function h(b,g,v){var y=g;switch(g){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=g,this._mimeType=v,i.checkSupport(y),this._worker=b.pipe(new a(y)),b.lock()}catch(_){this._worker=new o("error"),this._worker.error(_)}}h.prototype={accumulate:function(b){return p(this,b)},on:function(b,g){var v=this;return b==="data"?this._worker.on(b,function(y){g.call(v,y.data,y.meta)}):this._worker.on(b,function(){i.delay(g,arguments,v)}),this},resume:function(){return i.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(b){if(i.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},b)}},s.exports=h},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,s,r){if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",r.nodebuffer=typeof Buffer<"u",r.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")r.blob=!1;else{var i=new ArrayBuffer(0);try{r.blob=new Blob([i],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(i),r.blob=a.getBlob("application/zip").size===0}catch{r.blob=!1}}}try{r.nodestream=!!e("readable-stream").Readable}catch{r.nodestream=!1}},{"readable-stream":16}],31:[function(e,s,r){for(var i=e("./utils"),a=e("./support"),o=e("./nodejsUtils"),l=e("./stream/GenericWorker"),d=new Array(256),m=0;m<256;m++)d[m]=252<=m?6:248<=m?5:240<=m?4:224<=m?3:192<=m?2:1;d[254]=d[254]=1;function f(){l.call(this,"utf-8 decode"),this.leftOver=null}function p(){l.call(this,"utf-8 encode")}r.utf8encode=function(h){return a.nodebuffer?o.newBufferFrom(h,"utf-8"):(function(b){var g,v,y,_,S,M=b.length,w=0;for(_=0;_<M;_++)(64512&(v=b.charCodeAt(_)))==55296&&_+1<M&&(64512&(y=b.charCodeAt(_+1)))==56320&&(v=65536+(v-55296<<10)+(y-56320),_++),w+=v<128?1:v<2048?2:v<65536?3:4;for(g=a.uint8array?new Uint8Array(w):new Array(w),_=S=0;S<w;_++)(64512&(v=b.charCodeAt(_)))==55296&&_+1<M&&(64512&(y=b.charCodeAt(_+1)))==56320&&(v=65536+(v-55296<<10)+(y-56320),_++),v<128?g[S++]=v:(v<2048?g[S++]=192|v>>>6:(v<65536?g[S++]=224|v>>>12:(g[S++]=240|v>>>18,g[S++]=128|v>>>12&63),g[S++]=128|v>>>6&63),g[S++]=128|63&v);return g})(h)},r.utf8decode=function(h){return a.nodebuffer?i.transformTo("nodebuffer",h).toString("utf-8"):(function(b){var g,v,y,_,S=b.length,M=new Array(2*S);for(g=v=0;g<S;)if((y=b[g++])<128)M[v++]=y;else if(4<(_=d[y]))M[v++]=65533,g+=_-1;else{for(y&=_===2?31:_===3?15:7;1<_&&g<S;)y=y<<6|63&b[g++],_--;1<_?M[v++]=65533:y<65536?M[v++]=y:(y-=65536,M[v++]=55296|y>>10&1023,M[v++]=56320|1023&y)}return M.length!==v&&(M.subarray?M=M.subarray(0,v):M.length=v),i.applyFromCharCode(M)})(h=i.transformTo(a.uint8array?"uint8array":"array",h))},i.inherits(f,l),f.prototype.processChunk=function(h){var b=i.transformTo(a.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var g=b;(b=new Uint8Array(g.length+this.leftOver.length)).set(this.leftOver,0),b.set(g,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var v=(function(_,S){var M;for((S=S||_.length)>_.length&&(S=_.length),M=S-1;0<=M&&(192&_[M])==128;)M--;return M<0||M===0?S:M+d[_[M]]>S?M:S})(b),y=b;v!==b.length&&(a.uint8array?(y=b.subarray(0,v),this.leftOver=b.subarray(v,b.length)):(y=b.slice(0,v),this.leftOver=b.slice(v,b.length))),this.push({data:r.utf8decode(y),meta:h.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=f,i.inherits(p,l),p.prototype.processChunk=function(h){this.push({data:r.utf8encode(h.data),meta:h.meta})},r.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,s,r){var i=e("./support"),a=e("./base64"),o=e("./nodejsUtils"),l=e("./external");function d(g){return g}function m(g,v){for(var y=0;y<g.length;++y)v[y]=255&g.charCodeAt(y);return v}e("setimmediate"),r.newBlob=function(g,v){r.checkSupport("blob");try{return new Blob([g],{type:v})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(g),y.getBlob(v)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(g,v,y){var _=[],S=0,M=g.length;if(M<=y)return String.fromCharCode.apply(null,g);for(;S<M;)v==="array"||v==="nodebuffer"?_.push(String.fromCharCode.apply(null,g.slice(S,Math.min(S+y,M)))):_.push(String.fromCharCode.apply(null,g.subarray(S,Math.min(S+y,M)))),S+=y;return _.join("")},stringifyByChar:function(g){for(var v="",y=0;y<g.length;y++)v+=String.fromCharCode(g[y]);return v},applyCanBeUsed:{uint8array:(function(){try{return i.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return i.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}})()}};function p(g){var v=65536,y=r.getTypeOf(g),_=!0;if(y==="uint8array"?_=f.applyCanBeUsed.uint8array:y==="nodebuffer"&&(_=f.applyCanBeUsed.nodebuffer),_)for(;1<v;)try{return f.stringifyByChunk(g,y,v)}catch{v=Math.floor(v/2)}return f.stringifyByChar(g)}function h(g,v){for(var y=0;y<g.length;y++)v[y]=g[y];return v}r.applyFromCharCode=p;var b={};b.string={string:d,array:function(g){return m(g,new Array(g.length))},arraybuffer:function(g){return b.string.uint8array(g).buffer},uint8array:function(g){return m(g,new Uint8Array(g.length))},nodebuffer:function(g){return m(g,o.allocBuffer(g.length))}},b.array={string:p,array:d,arraybuffer:function(g){return new Uint8Array(g).buffer},uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return o.newBufferFrom(g)}},b.arraybuffer={string:function(g){return p(new Uint8Array(g))},array:function(g){return h(new Uint8Array(g),new Array(g.byteLength))},arraybuffer:d,uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return o.newBufferFrom(new Uint8Array(g))}},b.uint8array={string:p,array:function(g){return h(g,new Array(g.length))},arraybuffer:function(g){return g.buffer},uint8array:d,nodebuffer:function(g){return o.newBufferFrom(g)}},b.nodebuffer={string:p,array:function(g){return h(g,new Array(g.length))},arraybuffer:function(g){return b.nodebuffer.uint8array(g).buffer},uint8array:function(g){return h(g,new Uint8Array(g.length))},nodebuffer:d},r.transformTo=function(g,v){if(v=v||"",!g)return v;r.checkSupport(g);var y=r.getTypeOf(v);return b[y][g](v)},r.resolve=function(g){for(var v=g.split("/"),y=[],_=0;_<v.length;_++){var S=v[_];S==="."||S===""&&_!==0&&_!==v.length-1||(S===".."?y.pop():y.push(S))}return y.join("/")},r.getTypeOf=function(g){return typeof g=="string"?"string":Object.prototype.toString.call(g)==="[object Array]"?"array":i.nodebuffer&&o.isBuffer(g)?"nodebuffer":i.uint8array&&g instanceof Uint8Array?"uint8array":i.arraybuffer&&g instanceof ArrayBuffer?"arraybuffer":void 0},r.checkSupport=function(g){if(!i[g.toLowerCase()])throw new Error(g+" is not supported by this platform")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(g){var v,y,_="";for(y=0;y<(g||"").length;y++)_+="\\x"+((v=g.charCodeAt(y))<16?"0":"")+v.toString(16).toUpperCase();return _},r.delay=function(g,v,y){setImmediate(function(){g.apply(y||null,v||[])})},r.inherits=function(g,v){function y(){}y.prototype=v.prototype,g.prototype=new y},r.extend=function(){var g,v,y={};for(g=0;g<arguments.length;g++)for(v in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],v)&&y[v]===void 0&&(y[v]=arguments[g][v]);return y},r.prepareContent=function(g,v,y,_,S){return l.Promise.resolve(v).then(function(M){return i.blob&&(M instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(M))!==-1)&&typeof FileReader<"u"?new l.Promise(function(w,T){var P=new FileReader;P.onload=function(z){w(z.target.result)},P.onerror=function(z){T(z.target.error)},P.readAsArrayBuffer(M)}):M}).then(function(M){var w=r.getTypeOf(M);return w?(w==="arraybuffer"?M=r.transformTo("uint8array",M):w==="string"&&(S?M=a.decode(M):y&&_!==!0&&(M=(function(T){return m(T,i.uint8array?new Uint8Array(T.length):new Array(T.length))})(M))),M):l.Promise.reject(new Error("Can't read the data of '"+g+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,s,r){var i=e("./reader/readerFor"),a=e("./utils"),o=e("./signature"),l=e("./zipEntry"),d=e("./support");function m(f){this.files=[],this.loadOptions=f}m.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(p)+", expected "+a.pretty(f)+")")}},isSignature:function(f,p){var h=this.reader.index;this.reader.setIndex(f);var b=this.reader.readString(4)===p;return this.reader.setIndex(h),b},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),p=d.uint8array?"uint8array":"array",h=a.transformTo(p,f);this.zipComment=this.loadOptions.decodeFileName(h)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,p,h,b=this.zip64EndOfCentralSize-44;0<b;)f=this.reader.readInt(2),p=this.reader.readInt(4),h=this.reader.readData(p),this.zip64ExtensibleData[f]={id:f,length:p,value:h}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,p;for(f=0;f<this.files.length;f++)p=this.files[f],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(f=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var p=f;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var h=this.centralDirOffset+this.centralDirSize;this.zip64&&(h+=20,h+=12+this.zip64EndOfCentralSize);var b=p-h;if(0<b)this.isSignature(p,o.CENTRAL_FILE_HEADER)||(this.reader.zero=b);else if(b<0)throw new Error("Corrupted zip: missing "+Math.abs(b)+" bytes.")},prepareReader:function(f){this.reader=i(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},s.exports=m},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,s,r){var i=e("./reader/readerFor"),a=e("./utils"),o=e("./compressedObject"),l=e("./crc32"),d=e("./utf8"),m=e("./compressions"),f=e("./support");function p(h,b){this.options=h,this.loadOptions=b}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(h){var b,g;if(h.skip(22),this.fileNameLength=h.readInt(2),g=h.readInt(2),this.fileName=h.readData(this.fileNameLength),h.skip(g),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((b=(function(v){for(var y in m)if(Object.prototype.hasOwnProperty.call(m,y)&&m[y].magic===v)return m[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,b,h.readData(this.compressedSize))},readCentralPart:function(h){this.versionMadeBy=h.readInt(2),h.skip(2),this.bitFlag=h.readInt(2),this.compressionMethod=h.readString(2),this.date=h.readDate(),this.crc32=h.readInt(4),this.compressedSize=h.readInt(4),this.uncompressedSize=h.readInt(4);var b=h.readInt(2);if(this.extraFieldsLength=h.readInt(2),this.fileCommentLength=h.readInt(2),this.diskNumberStart=h.readInt(2),this.internalFileAttributes=h.readInt(2),this.externalFileAttributes=h.readInt(4),this.localHeaderOffset=h.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");h.skip(b),this.readExtraFields(h),this.parseZIP64ExtraField(h),this.fileComment=h.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var h=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=i(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var b,g,v,y=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4<y;)b=h.readInt(2),g=h.readInt(2),v=h.readData(g),this.extraFields[b]={id:b,length:g,value:v};h.setIndex(y)},handleUTF8:function(){var h=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=d.utf8decode(this.fileName),this.fileCommentStr=d.utf8decode(this.fileComment);else{var b=this.findExtraFieldUnicodePath();if(b!==null)this.fileNameStr=b;else{var g=a.transformTo(h,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var v=this.findExtraFieldUnicodeComment();if(v!==null)this.fileCommentStr=v;else{var y=a.transformTo(h,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var h=this.extraFields[28789];if(h){var b=i(h.value);return b.readInt(1)!==1||l(this.fileName)!==b.readInt(4)?null:d.utf8decode(b.readData(h.length-5))}return null},findExtraFieldUnicodeComment:function(){var h=this.extraFields[25461];if(h){var b=i(h.value);return b.readInt(1)!==1||l(this.fileComment)!==b.readInt(4)?null:d.utf8decode(b.readData(h.length-5))}return null}},s.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,s,r){function i(b,g,v){this.name=b,this.dir=v.dir,this.date=v.date,this.comment=v.comment,this.unixPermissions=v.unixPermissions,this.dosPermissions=v.dosPermissions,this._data=g,this._dataBinary=v.binary,this.options={compression:v.compression,compressionOptions:v.compressionOptions}}var a=e("./stream/StreamHelper"),o=e("./stream/DataWorker"),l=e("./utf8"),d=e("./compressedObject"),m=e("./stream/GenericWorker");i.prototype={internalStream:function(b){var g=null,v="string";try{if(!b)throw new Error("No output type specified.");var y=(v=b.toLowerCase())==="string"||v==="text";v!=="binarystring"&&v!=="text"||(v="string"),g=this._decompressWorker();var _=!this._dataBinary;_&&!y&&(g=g.pipe(new l.Utf8EncodeWorker)),!_&&y&&(g=g.pipe(new l.Utf8DecodeWorker))}catch(S){(g=new m("error")).error(S)}return new a(g,v,"")},async:function(b,g){return this.internalStream(b).accumulate(g)},nodeStream:function(b,g){return this.internalStream(b||"nodebuffer").toNodejsStream(g)},_compressWorker:function(b,g){if(this._data instanceof d&&this._data.compression.magic===b.magic)return this._data.getCompressedWorker();var v=this._decompressWorker();return this._dataBinary||(v=v.pipe(new l.Utf8EncodeWorker)),d.createWorkerFrom(v,b,g)},_decompressWorker:function(){return this._data instanceof d?this._data.getContentWorker():this._data instanceof m?this._data:new o(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<f.length;h++)i.prototype[f[h]]=p;s.exports=i},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,s,r){(function(i){var a,o,l=i.MutationObserver||i.WebKitMutationObserver;if(l){var d=0,m=new l(b),f=i.document.createTextNode("");m.observe(f,{characterData:!0}),a=function(){f.data=d=++d%2}}else if(i.setImmediate||i.MessageChannel===void 0)a="document"in i&&"onreadystatechange"in i.document.createElement("script")?function(){var g=i.document.createElement("script");g.onreadystatechange=function(){b(),g.onreadystatechange=null,g.parentNode.removeChild(g),g=null},i.document.documentElement.appendChild(g)}:function(){setTimeout(b,0)};else{var p=new i.MessageChannel;p.port1.onmessage=b,a=function(){p.port2.postMessage(0)}}var h=[];function b(){var g,v;o=!0;for(var y=h.length;y;){for(v=h,h=[],g=-1;++g<y;)v[g]();y=h.length}o=!1}s.exports=function(g){h.push(g)!==1||o||a()}}).call(this,typeof xn<"u"?xn:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(e,s,r){var i=e("immediate");function a(){}var o={},l=["REJECTED"],d=["FULFILLED"],m=["PENDING"];function f(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=m,this.queue=[],this.outcome=void 0,y!==a&&g(this,y)}function p(y,_,S){this.promise=y,typeof _=="function"&&(this.onFulfilled=_,this.callFulfilled=this.otherCallFulfilled),typeof S=="function"&&(this.onRejected=S,this.callRejected=this.otherCallRejected)}function h(y,_,S){i(function(){var M;try{M=_(S)}catch(w){return o.reject(y,w)}M===y?o.reject(y,new TypeError("Cannot resolve promise with itself")):o.resolve(y,M)})}function b(y){var _=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof _=="function")return function(){_.apply(y,arguments)}}function g(y,_){var S=!1;function M(P){S||(S=!0,o.reject(y,P))}function w(P){S||(S=!0,o.resolve(y,P))}var T=v(function(){_(w,M)});T.status==="error"&&M(T.value)}function v(y,_){var S={};try{S.value=y(_),S.status="success"}catch(M){S.status="error",S.value=M}return S}(s.exports=f).prototype.finally=function(y){if(typeof y!="function")return this;var _=this.constructor;return this.then(function(S){return _.resolve(y()).then(function(){return S})},function(S){return _.resolve(y()).then(function(){throw S})})},f.prototype.catch=function(y){return this.then(null,y)},f.prototype.then=function(y,_){if(typeof y!="function"&&this.state===d||typeof _!="function"&&this.state===l)return this;var S=new this.constructor(a);return this.state!==m?h(S,this.state===d?y:_,this.outcome):this.queue.push(new p(S,y,_)),S},p.prototype.callFulfilled=function(y){o.resolve(this.promise,y)},p.prototype.otherCallFulfilled=function(y){h(this.promise,this.onFulfilled,y)},p.prototype.callRejected=function(y){o.reject(this.promise,y)},p.prototype.otherCallRejected=function(y){h(this.promise,this.onRejected,y)},o.resolve=function(y,_){var S=v(b,_);if(S.status==="error")return o.reject(y,S.value);var M=S.value;if(M)g(y,M);else{y.state=d,y.outcome=_;for(var w=-1,T=y.queue.length;++w<T;)y.queue[w].callFulfilled(_)}return y},o.reject=function(y,_){y.state=l,y.outcome=_;for(var S=-1,M=y.queue.length;++S<M;)y.queue[S].callRejected(_);return y},f.resolve=function(y){return y instanceof this?y:o.resolve(new this(a),y)},f.reject=function(y){var _=new this(a);return o.reject(_,y)},f.all=function(y){var _=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=y.length,M=!1;if(!S)return this.resolve([]);for(var w=new Array(S),T=0,P=-1,z=new this(a);++P<S;)E(y[P],P);return z;function E(L,V){_.resolve(L).then(function(k){w[V]=k,++T!==S||M||(M=!0,o.resolve(z,w))},function(k){M||(M=!0,o.reject(z,k))})}},f.race=function(y){var _=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var S=y.length,M=!1;if(!S)return this.resolve([]);for(var w=-1,T=new this(a);++w<S;)P=y[w],_.resolve(P).then(function(z){M||(M=!0,o.resolve(T,z))},function(z){M||(M=!0,o.reject(T,z))});var P;return T}},{immediate:36}],38:[function(e,s,r){var i={};(0,e("./lib/utils/common").assign)(i,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),s.exports=i},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,s,r){var i=e("./zlib/deflate"),a=e("./utils/common"),o=e("./utils/strings"),l=e("./zlib/messages"),d=e("./zlib/zstream"),m=Object.prototype.toString,f=0,p=-1,h=0,b=8;function g(y){if(!(this instanceof g))return new g(y);this.options=a.assign({level:p,method:b,chunkSize:16384,windowBits:15,memLevel:8,strategy:h,to:""},y||{});var _=this.options;_.raw&&0<_.windowBits?_.windowBits=-_.windowBits:_.gzip&&0<_.windowBits&&_.windowBits<16&&(_.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var S=i.deflateInit2(this.strm,_.level,_.method,_.windowBits,_.memLevel,_.strategy);if(S!==f)throw new Error(l[S]);if(_.header&&i.deflateSetHeader(this.strm,_.header),_.dictionary){var M;if(M=typeof _.dictionary=="string"?o.string2buf(_.dictionary):m.call(_.dictionary)==="[object ArrayBuffer]"?new Uint8Array(_.dictionary):_.dictionary,(S=i.deflateSetDictionary(this.strm,M))!==f)throw new Error(l[S]);this._dict_set=!0}}function v(y,_){var S=new g(_);if(S.push(y,!0),S.err)throw S.msg||l[S.err];return S.result}g.prototype.push=function(y,_){var S,M,w=this.strm,T=this.options.chunkSize;if(this.ended)return!1;M=_===~~_?_:_===!0?4:0,typeof y=="string"?w.input=o.string2buf(y):m.call(y)==="[object ArrayBuffer]"?w.input=new Uint8Array(y):w.input=y,w.next_in=0,w.avail_in=w.input.length;do{if(w.avail_out===0&&(w.output=new a.Buf8(T),w.next_out=0,w.avail_out=T),(S=i.deflate(w,M))!==1&&S!==f)return this.onEnd(S),!(this.ended=!0);w.avail_out!==0&&(w.avail_in!==0||M!==4&&M!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(a.shrinkBuf(w.output,w.next_out))):this.onData(a.shrinkBuf(w.output,w.next_out)))}while((0<w.avail_in||w.avail_out===0)&&S!==1);return M===4?(S=i.deflateEnd(this.strm),this.onEnd(S),this.ended=!0,S===f):M!==2||(this.onEnd(f),!(w.avail_out=0))},g.prototype.onData=function(y){this.chunks.push(y)},g.prototype.onEnd=function(y){y===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},r.Deflate=g,r.deflate=v,r.deflateRaw=function(y,_){return(_=_||{}).raw=!0,v(y,_)},r.gzip=function(y,_){return(_=_||{}).gzip=!0,v(y,_)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,s,r){var i=e("./zlib/inflate"),a=e("./utils/common"),o=e("./utils/strings"),l=e("./zlib/constants"),d=e("./zlib/messages"),m=e("./zlib/zstream"),f=e("./zlib/gzheader"),p=Object.prototype.toString;function h(g){if(!(this instanceof h))return new h(g);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},g||{});var v=this.options;v.raw&&0<=v.windowBits&&v.windowBits<16&&(v.windowBits=-v.windowBits,v.windowBits===0&&(v.windowBits=-15)),!(0<=v.windowBits&&v.windowBits<16)||g&&g.windowBits||(v.windowBits+=32),15<v.windowBits&&v.windowBits<48&&(15&v.windowBits)==0&&(v.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new m,this.strm.avail_out=0;var y=i.inflateInit2(this.strm,v.windowBits);if(y!==l.Z_OK)throw new Error(d[y]);this.header=new f,i.inflateGetHeader(this.strm,this.header)}function b(g,v){var y=new h(v);if(y.push(g,!0),y.err)throw y.msg||d[y.err];return y.result}h.prototype.push=function(g,v){var y,_,S,M,w,T,P=this.strm,z=this.options.chunkSize,E=this.options.dictionary,L=!1;if(this.ended)return!1;_=v===~~v?v:v===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof g=="string"?P.input=o.binstring2buf(g):p.call(g)==="[object ArrayBuffer]"?P.input=new Uint8Array(g):P.input=g,P.next_in=0,P.avail_in=P.input.length;do{if(P.avail_out===0&&(P.output=new a.Buf8(z),P.next_out=0,P.avail_out=z),(y=i.inflate(P,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&E&&(T=typeof E=="string"?o.string2buf(E):p.call(E)==="[object ArrayBuffer]"?new Uint8Array(E):E,y=i.inflateSetDictionary(this.strm,T)),y===l.Z_BUF_ERROR&&L===!0&&(y=l.Z_OK,L=!1),y!==l.Z_STREAM_END&&y!==l.Z_OK)return this.onEnd(y),!(this.ended=!0);P.next_out&&(P.avail_out!==0&&y!==l.Z_STREAM_END&&(P.avail_in!==0||_!==l.Z_FINISH&&_!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(S=o.utf8border(P.output,P.next_out),M=P.next_out-S,w=o.buf2string(P.output,S),P.next_out=M,P.avail_out=z-M,M&&a.arraySet(P.output,P.output,S,M,0),this.onData(w)):this.onData(a.shrinkBuf(P.output,P.next_out)))),P.avail_in===0&&P.avail_out===0&&(L=!0)}while((0<P.avail_in||P.avail_out===0)&&y!==l.Z_STREAM_END);return y===l.Z_STREAM_END&&(_=l.Z_FINISH),_===l.Z_FINISH?(y=i.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===l.Z_OK):_!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(P.avail_out=0))},h.prototype.onData=function(g){this.chunks.push(g)},h.prototype.onEnd=function(g){g===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},r.Inflate=h,r.inflate=b,r.inflateRaw=function(g,v){return(v=v||{}).raw=!0,b(g,v)},r.ungzip=b},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,s,r){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";r.assign=function(l){for(var d=Array.prototype.slice.call(arguments,1);d.length;){var m=d.shift();if(m){if(typeof m!="object")throw new TypeError(m+"must be non-object");for(var f in m)m.hasOwnProperty(f)&&(l[f]=m[f])}}return l},r.shrinkBuf=function(l,d){return l.length===d?l:l.subarray?l.subarray(0,d):(l.length=d,l)};var a={arraySet:function(l,d,m,f,p){if(d.subarray&&l.subarray)l.set(d.subarray(m,m+f),p);else for(var h=0;h<f;h++)l[p+h]=d[m+h]},flattenChunks:function(l){var d,m,f,p,h,b;for(d=f=0,m=l.length;d<m;d++)f+=l[d].length;for(b=new Uint8Array(f),d=p=0,m=l.length;d<m;d++)h=l[d],b.set(h,p),p+=h.length;return b}},o={arraySet:function(l,d,m,f,p){for(var h=0;h<f;h++)l[p+h]=d[m+h]},flattenChunks:function(l){return[].concat.apply([],l)}};r.setTyped=function(l){l?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,a)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,o))},r.setTyped(i)},{}],42:[function(e,s,r){var i=e("./common"),a=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var l=new i.Buf8(256),d=0;d<256;d++)l[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;function m(f,p){if(p<65537&&(f.subarray&&o||!f.subarray&&a))return String.fromCharCode.apply(null,i.shrinkBuf(f,p));for(var h="",b=0;b<p;b++)h+=String.fromCharCode(f[b]);return h}l[254]=l[254]=1,r.string2buf=function(f){var p,h,b,g,v,y=f.length,_=0;for(g=0;g<y;g++)(64512&(h=f.charCodeAt(g)))==55296&&g+1<y&&(64512&(b=f.charCodeAt(g+1)))==56320&&(h=65536+(h-55296<<10)+(b-56320),g++),_+=h<128?1:h<2048?2:h<65536?3:4;for(p=new i.Buf8(_),g=v=0;v<_;g++)(64512&(h=f.charCodeAt(g)))==55296&&g+1<y&&(64512&(b=f.charCodeAt(g+1)))==56320&&(h=65536+(h-55296<<10)+(b-56320),g++),h<128?p[v++]=h:(h<2048?p[v++]=192|h>>>6:(h<65536?p[v++]=224|h>>>12:(p[v++]=240|h>>>18,p[v++]=128|h>>>12&63),p[v++]=128|h>>>6&63),p[v++]=128|63&h);return p},r.buf2binstring=function(f){return m(f,f.length)},r.binstring2buf=function(f){for(var p=new i.Buf8(f.length),h=0,b=p.length;h<b;h++)p[h]=f.charCodeAt(h);return p},r.buf2string=function(f,p){var h,b,g,v,y=p||f.length,_=new Array(2*y);for(h=b=0;h<y;)if((g=f[h++])<128)_[b++]=g;else if(4<(v=l[g]))_[b++]=65533,h+=v-1;else{for(g&=v===2?31:v===3?15:7;1<v&&h<y;)g=g<<6|63&f[h++],v--;1<v?_[b++]=65533:g<65536?_[b++]=g:(g-=65536,_[b++]=55296|g>>10&1023,_[b++]=56320|1023&g)}return m(_,b)},r.utf8border=function(f,p){var h;for((p=p||f.length)>f.length&&(p=f.length),h=p-1;0<=h&&(192&f[h])==128;)h--;return h<0||h===0?p:h+l[f[h]]>p?h:p}},{"./common":41}],43:[function(e,s,r){s.exports=function(i,a,o,l){for(var d=65535&i|0,m=i>>>16&65535|0,f=0;o!==0;){for(o-=f=2e3<o?2e3:o;m=m+(d=d+a[l++]|0)|0,--f;);d%=65521,m%=65521}return d|m<<16|0}},{}],44:[function(e,s,r){s.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(e,s,r){var i=(function(){for(var a,o=[],l=0;l<256;l++){a=l;for(var d=0;d<8;d++)a=1&a?3988292384^a>>>1:a>>>1;o[l]=a}return o})();s.exports=function(a,o,l,d){var m=i,f=d+l;a^=-1;for(var p=d;p<f;p++)a=a>>>8^m[255&(a^o[p])];return-1^a}},{}],46:[function(e,s,r){var i,a=e("../utils/common"),o=e("./trees"),l=e("./adler32"),d=e("./crc32"),m=e("./messages"),f=0,p=4,h=0,b=-2,g=-1,v=4,y=2,_=8,S=9,M=286,w=30,T=19,P=2*M+1,z=15,E=3,L=258,V=L+E+1,k=42,I=113,u=1,j=2,X=3,G=4;function st(c,D){return c.msg=m[D],D}function H(c){return(c<<1)-(4<c?9:0)}function Q(c){for(var D=c.length;0<=--D;)c[D]=0}function B(c){var D=c.state,F=D.pending;F>c.avail_out&&(F=c.avail_out),F!==0&&(a.arraySet(c.output,D.pending_buf,D.pending_out,F,c.next_out),c.next_out+=F,D.pending_out+=F,c.total_out+=F,c.avail_out-=F,D.pending-=F,D.pending===0&&(D.pending_out=0))}function R(c,D){o._tr_flush_block(c,0<=c.block_start?c.block_start:-1,c.strstart-c.block_start,D),c.block_start=c.strstart,B(c.strm)}function J(c,D){c.pending_buf[c.pending++]=D}function tt(c,D){c.pending_buf[c.pending++]=D>>>8&255,c.pending_buf[c.pending++]=255&D}function Z(c,D){var F,A,x=c.max_chain_length,C=c.strstart,U=c.prev_length,$=c.nice_match,O=c.strstart>c.w_size-V?c.strstart-(c.w_size-V):0,K=c.window,nt=c.w_mask,Y=c.prev,rt=c.strstart+L,dt=K[C+U-1],ct=K[C+U];c.prev_length>=c.good_match&&(x>>=2),$>c.lookahead&&($=c.lookahead);do if(K[(F=D)+U]===ct&&K[F+U-1]===dt&&K[F]===K[C]&&K[++F]===K[C+1]){C+=2,F++;do;while(K[++C]===K[++F]&&K[++C]===K[++F]&&K[++C]===K[++F]&&K[++C]===K[++F]&&K[++C]===K[++F]&&K[++C]===K[++F]&&K[++C]===K[++F]&&K[++C]===K[++F]&&C<rt);if(A=L-(rt-C),C=rt-L,U<A){if(c.match_start=D,$<=(U=A))break;dt=K[C+U-1],ct=K[C+U]}}while((D=Y[D&nt])>O&&--x!=0);return U<=c.lookahead?U:c.lookahead}function pt(c){var D,F,A,x,C,U,$,O,K,nt,Y=c.w_size;do{if(x=c.window_size-c.lookahead-c.strstart,c.strstart>=Y+(Y-V)){for(a.arraySet(c.window,c.window,Y,Y,0),c.match_start-=Y,c.strstart-=Y,c.block_start-=Y,D=F=c.hash_size;A=c.head[--D],c.head[D]=Y<=A?A-Y:0,--F;);for(D=F=Y;A=c.prev[--D],c.prev[D]=Y<=A?A-Y:0,--F;);x+=Y}if(c.strm.avail_in===0)break;if(U=c.strm,$=c.window,O=c.strstart+c.lookahead,K=x,nt=void 0,nt=U.avail_in,K<nt&&(nt=K),F=nt===0?0:(U.avail_in-=nt,a.arraySet($,U.input,U.next_in,nt,O),U.state.wrap===1?U.adler=l(U.adler,$,nt,O):U.state.wrap===2&&(U.adler=d(U.adler,$,nt,O)),U.next_in+=nt,U.total_in+=nt,nt),c.lookahead+=F,c.lookahead+c.insert>=E)for(C=c.strstart-c.insert,c.ins_h=c.window[C],c.ins_h=(c.ins_h<<c.hash_shift^c.window[C+1])&c.hash_mask;c.insert&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[C+E-1])&c.hash_mask,c.prev[C&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=C,C++,c.insert--,!(c.lookahead+c.insert<E)););}while(c.lookahead<V&&c.strm.avail_in!==0)}function wt(c,D){for(var F,A;;){if(c.lookahead<V){if(pt(c),c.lookahead<V&&D===f)return u;if(c.lookahead===0)break}if(F=0,c.lookahead>=E&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+E-1])&c.hash_mask,F=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart),F!==0&&c.strstart-F<=c.w_size-V&&(c.match_length=Z(c,F)),c.match_length>=E)if(A=o._tr_tally(c,c.strstart-c.match_start,c.match_length-E),c.lookahead-=c.match_length,c.match_length<=c.max_lazy_match&&c.lookahead>=E){for(c.match_length--;c.strstart++,c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+E-1])&c.hash_mask,F=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart,--c.match_length!=0;);c.strstart++}else c.strstart+=c.match_length,c.match_length=0,c.ins_h=c.window[c.strstart],c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+1])&c.hash_mask;else A=o._tr_tally(c,0,c.window[c.strstart]),c.lookahead--,c.strstart++;if(A&&(R(c,!1),c.strm.avail_out===0))return u}return c.insert=c.strstart<E-1?c.strstart:E-1,D===p?(R(c,!0),c.strm.avail_out===0?X:G):c.last_lit&&(R(c,!1),c.strm.avail_out===0)?u:j}function ht(c,D){for(var F,A,x;;){if(c.lookahead<V){if(pt(c),c.lookahead<V&&D===f)return u;if(c.lookahead===0)break}if(F=0,c.lookahead>=E&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+E-1])&c.hash_mask,F=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart),c.prev_length=c.match_length,c.prev_match=c.match_start,c.match_length=E-1,F!==0&&c.prev_length<c.max_lazy_match&&c.strstart-F<=c.w_size-V&&(c.match_length=Z(c,F),c.match_length<=5&&(c.strategy===1||c.match_length===E&&4096<c.strstart-c.match_start)&&(c.match_length=E-1)),c.prev_length>=E&&c.match_length<=c.prev_length){for(x=c.strstart+c.lookahead-E,A=o._tr_tally(c,c.strstart-1-c.prev_match,c.prev_length-E),c.lookahead-=c.prev_length-1,c.prev_length-=2;++c.strstart<=x&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+E-1])&c.hash_mask,F=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart),--c.prev_length!=0;);if(c.match_available=0,c.match_length=E-1,c.strstart++,A&&(R(c,!1),c.strm.avail_out===0))return u}else if(c.match_available){if((A=o._tr_tally(c,0,c.window[c.strstart-1]))&&R(c,!1),c.strstart++,c.lookahead--,c.strm.avail_out===0)return u}else c.match_available=1,c.strstart++,c.lookahead--}return c.match_available&&(A=o._tr_tally(c,0,c.window[c.strstart-1]),c.match_available=0),c.insert=c.strstart<E-1?c.strstart:E-1,D===p?(R(c,!0),c.strm.avail_out===0?X:G):c.last_lit&&(R(c,!1),c.strm.avail_out===0)?u:j}function ut(c,D,F,A,x){this.good_length=c,this.max_lazy=D,this.nice_length=F,this.max_chain=A,this.func=x}function yt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=_,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*P),this.dyn_dtree=new a.Buf16(2*(2*w+1)),this.bl_tree=new a.Buf16(2*(2*T+1)),Q(this.dyn_ltree),Q(this.dyn_dtree),Q(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(z+1),this.heap=new a.Buf16(2*M+1),Q(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*M+1),Q(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function q(c){var D;return c&&c.state?(c.total_in=c.total_out=0,c.data_type=y,(D=c.state).pending=0,D.pending_out=0,D.wrap<0&&(D.wrap=-D.wrap),D.status=D.wrap?k:I,c.adler=D.wrap===2?0:1,D.last_flush=f,o._tr_init(D),h):st(c,b)}function et(c){var D=q(c);return D===h&&(function(F){F.window_size=2*F.w_size,Q(F.head),F.max_lazy_match=i[F.level].max_lazy,F.good_match=i[F.level].good_length,F.nice_match=i[F.level].nice_length,F.max_chain_length=i[F.level].max_chain,F.strstart=0,F.block_start=0,F.lookahead=0,F.insert=0,F.match_length=F.prev_length=E-1,F.match_available=0,F.ins_h=0})(c.state),D}function it(c,D,F,A,x,C){if(!c)return b;var U=1;if(D===g&&(D=6),A<0?(U=0,A=-A):15<A&&(U=2,A-=16),x<1||S<x||F!==_||A<8||15<A||D<0||9<D||C<0||v<C)return st(c,b);A===8&&(A=9);var $=new yt;return(c.state=$).strm=c,$.wrap=U,$.gzhead=null,$.w_bits=A,$.w_size=1<<$.w_bits,$.w_mask=$.w_size-1,$.hash_bits=x+7,$.hash_size=1<<$.hash_bits,$.hash_mask=$.hash_size-1,$.hash_shift=~~(($.hash_bits+E-1)/E),$.window=new a.Buf8(2*$.w_size),$.head=new a.Buf16($.hash_size),$.prev=new a.Buf16($.w_size),$.lit_bufsize=1<<x+6,$.pending_buf_size=4*$.lit_bufsize,$.pending_buf=new a.Buf8($.pending_buf_size),$.d_buf=1*$.lit_bufsize,$.l_buf=3*$.lit_bufsize,$.level=D,$.strategy=C,$.method=F,et(c)}i=[new ut(0,0,0,0,function(c,D){var F=65535;for(F>c.pending_buf_size-5&&(F=c.pending_buf_size-5);;){if(c.lookahead<=1){if(pt(c),c.lookahead===0&&D===f)return u;if(c.lookahead===0)break}c.strstart+=c.lookahead,c.lookahead=0;var A=c.block_start+F;if((c.strstart===0||c.strstart>=A)&&(c.lookahead=c.strstart-A,c.strstart=A,R(c,!1),c.strm.avail_out===0)||c.strstart-c.block_start>=c.w_size-V&&(R(c,!1),c.strm.avail_out===0))return u}return c.insert=0,D===p?(R(c,!0),c.strm.avail_out===0?X:G):(c.strstart>c.block_start&&(R(c,!1),c.strm.avail_out),u)}),new ut(4,4,8,4,wt),new ut(4,5,16,8,wt),new ut(4,6,32,32,wt),new ut(4,4,16,16,ht),new ut(8,16,32,32,ht),new ut(8,16,128,128,ht),new ut(8,32,128,256,ht),new ut(32,128,258,1024,ht),new ut(32,258,258,4096,ht)],r.deflateInit=function(c,D){return it(c,D,_,15,8,0)},r.deflateInit2=it,r.deflateReset=et,r.deflateResetKeep=q,r.deflateSetHeader=function(c,D){return c&&c.state?c.state.wrap!==2?b:(c.state.gzhead=D,h):b},r.deflate=function(c,D){var F,A,x,C;if(!c||!c.state||5<D||D<0)return c?st(c,b):b;if(A=c.state,!c.output||!c.input&&c.avail_in!==0||A.status===666&&D!==p)return st(c,c.avail_out===0?-5:b);if(A.strm=c,F=A.last_flush,A.last_flush=D,A.status===k)if(A.wrap===2)c.adler=0,J(A,31),J(A,139),J(A,8),A.gzhead?(J(A,(A.gzhead.text?1:0)+(A.gzhead.hcrc?2:0)+(A.gzhead.extra?4:0)+(A.gzhead.name?8:0)+(A.gzhead.comment?16:0)),J(A,255&A.gzhead.time),J(A,A.gzhead.time>>8&255),J(A,A.gzhead.time>>16&255),J(A,A.gzhead.time>>24&255),J(A,A.level===9?2:2<=A.strategy||A.level<2?4:0),J(A,255&A.gzhead.os),A.gzhead.extra&&A.gzhead.extra.length&&(J(A,255&A.gzhead.extra.length),J(A,A.gzhead.extra.length>>8&255)),A.gzhead.hcrc&&(c.adler=d(c.adler,A.pending_buf,A.pending,0)),A.gzindex=0,A.status=69):(J(A,0),J(A,0),J(A,0),J(A,0),J(A,0),J(A,A.level===9?2:2<=A.strategy||A.level<2?4:0),J(A,3),A.status=I);else{var U=_+(A.w_bits-8<<4)<<8;U|=(2<=A.strategy||A.level<2?0:A.level<6?1:A.level===6?2:3)<<6,A.strstart!==0&&(U|=32),U+=31-U%31,A.status=I,tt(A,U),A.strstart!==0&&(tt(A,c.adler>>>16),tt(A,65535&c.adler)),c.adler=1}if(A.status===69)if(A.gzhead.extra){for(x=A.pending;A.gzindex<(65535&A.gzhead.extra.length)&&(A.pending!==A.pending_buf_size||(A.gzhead.hcrc&&A.pending>x&&(c.adler=d(c.adler,A.pending_buf,A.pending-x,x)),B(c),x=A.pending,A.pending!==A.pending_buf_size));)J(A,255&A.gzhead.extra[A.gzindex]),A.gzindex++;A.gzhead.hcrc&&A.pending>x&&(c.adler=d(c.adler,A.pending_buf,A.pending-x,x)),A.gzindex===A.gzhead.extra.length&&(A.gzindex=0,A.status=73)}else A.status=73;if(A.status===73)if(A.gzhead.name){x=A.pending;do{if(A.pending===A.pending_buf_size&&(A.gzhead.hcrc&&A.pending>x&&(c.adler=d(c.adler,A.pending_buf,A.pending-x,x)),B(c),x=A.pending,A.pending===A.pending_buf_size)){C=1;break}C=A.gzindex<A.gzhead.name.length?255&A.gzhead.name.charCodeAt(A.gzindex++):0,J(A,C)}while(C!==0);A.gzhead.hcrc&&A.pending>x&&(c.adler=d(c.adler,A.pending_buf,A.pending-x,x)),C===0&&(A.gzindex=0,A.status=91)}else A.status=91;if(A.status===91)if(A.gzhead.comment){x=A.pending;do{if(A.pending===A.pending_buf_size&&(A.gzhead.hcrc&&A.pending>x&&(c.adler=d(c.adler,A.pending_buf,A.pending-x,x)),B(c),x=A.pending,A.pending===A.pending_buf_size)){C=1;break}C=A.gzindex<A.gzhead.comment.length?255&A.gzhead.comment.charCodeAt(A.gzindex++):0,J(A,C)}while(C!==0);A.gzhead.hcrc&&A.pending>x&&(c.adler=d(c.adler,A.pending_buf,A.pending-x,x)),C===0&&(A.status=103)}else A.status=103;if(A.status===103&&(A.gzhead.hcrc?(A.pending+2>A.pending_buf_size&&B(c),A.pending+2<=A.pending_buf_size&&(J(A,255&c.adler),J(A,c.adler>>8&255),c.adler=0,A.status=I)):A.status=I),A.pending!==0){if(B(c),c.avail_out===0)return A.last_flush=-1,h}else if(c.avail_in===0&&H(D)<=H(F)&&D!==p)return st(c,-5);if(A.status===666&&c.avail_in!==0)return st(c,-5);if(c.avail_in!==0||A.lookahead!==0||D!==f&&A.status!==666){var $=A.strategy===2?(function(O,K){for(var nt;;){if(O.lookahead===0&&(pt(O),O.lookahead===0)){if(K===f)return u;break}if(O.match_length=0,nt=o._tr_tally(O,0,O.window[O.strstart]),O.lookahead--,O.strstart++,nt&&(R(O,!1),O.strm.avail_out===0))return u}return O.insert=0,K===p?(R(O,!0),O.strm.avail_out===0?X:G):O.last_lit&&(R(O,!1),O.strm.avail_out===0)?u:j})(A,D):A.strategy===3?(function(O,K){for(var nt,Y,rt,dt,ct=O.window;;){if(O.lookahead<=L){if(pt(O),O.lookahead<=L&&K===f)return u;if(O.lookahead===0)break}if(O.match_length=0,O.lookahead>=E&&0<O.strstart&&(Y=ct[rt=O.strstart-1])===ct[++rt]&&Y===ct[++rt]&&Y===ct[++rt]){dt=O.strstart+L;do;while(Y===ct[++rt]&&Y===ct[++rt]&&Y===ct[++rt]&&Y===ct[++rt]&&Y===ct[++rt]&&Y===ct[++rt]&&Y===ct[++rt]&&Y===ct[++rt]&&rt<dt);O.match_length=L-(dt-rt),O.match_length>O.lookahead&&(O.match_length=O.lookahead)}if(O.match_length>=E?(nt=o._tr_tally(O,1,O.match_length-E),O.lookahead-=O.match_length,O.strstart+=O.match_length,O.match_length=0):(nt=o._tr_tally(O,0,O.window[O.strstart]),O.lookahead--,O.strstart++),nt&&(R(O,!1),O.strm.avail_out===0))return u}return O.insert=0,K===p?(R(O,!0),O.strm.avail_out===0?X:G):O.last_lit&&(R(O,!1),O.strm.avail_out===0)?u:j})(A,D):i[A.level].func(A,D);if($!==X&&$!==G||(A.status=666),$===u||$===X)return c.avail_out===0&&(A.last_flush=-1),h;if($===j&&(D===1?o._tr_align(A):D!==5&&(o._tr_stored_block(A,0,0,!1),D===3&&(Q(A.head),A.lookahead===0&&(A.strstart=0,A.block_start=0,A.insert=0))),B(c),c.avail_out===0))return A.last_flush=-1,h}return D!==p?h:A.wrap<=0?1:(A.wrap===2?(J(A,255&c.adler),J(A,c.adler>>8&255),J(A,c.adler>>16&255),J(A,c.adler>>24&255),J(A,255&c.total_in),J(A,c.total_in>>8&255),J(A,c.total_in>>16&255),J(A,c.total_in>>24&255)):(tt(A,c.adler>>>16),tt(A,65535&c.adler)),B(c),0<A.wrap&&(A.wrap=-A.wrap),A.pending!==0?h:1)},r.deflateEnd=function(c){var D;return c&&c.state?(D=c.state.status)!==k&&D!==69&&D!==73&&D!==91&&D!==103&&D!==I&&D!==666?st(c,b):(c.state=null,D===I?st(c,-3):h):b},r.deflateSetDictionary=function(c,D){var F,A,x,C,U,$,O,K,nt=D.length;if(!c||!c.state||(C=(F=c.state).wrap)===2||C===1&&F.status!==k||F.lookahead)return b;for(C===1&&(c.adler=l(c.adler,D,nt,0)),F.wrap=0,nt>=F.w_size&&(C===0&&(Q(F.head),F.strstart=0,F.block_start=0,F.insert=0),K=new a.Buf8(F.w_size),a.arraySet(K,D,nt-F.w_size,F.w_size,0),D=K,nt=F.w_size),U=c.avail_in,$=c.next_in,O=c.input,c.avail_in=nt,c.next_in=0,c.input=D,pt(F);F.lookahead>=E;){for(A=F.strstart,x=F.lookahead-(E-1);F.ins_h=(F.ins_h<<F.hash_shift^F.window[A+E-1])&F.hash_mask,F.prev[A&F.w_mask]=F.head[F.ins_h],F.head[F.ins_h]=A,A++,--x;);F.strstart=A,F.lookahead=E-1,pt(F)}return F.strstart+=F.lookahead,F.block_start=F.strstart,F.insert=F.lookahead,F.lookahead=0,F.match_length=F.prev_length=E-1,F.match_available=0,c.next_in=$,c.input=O,c.avail_in=U,F.wrap=C,h},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,s,r){s.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(e,s,r){s.exports=function(i,a){var o,l,d,m,f,p,h,b,g,v,y,_,S,M,w,T,P,z,E,L,V,k,I,u,j;o=i.state,l=i.next_in,u=i.input,d=l+(i.avail_in-5),m=i.next_out,j=i.output,f=m-(a-i.avail_out),p=m+(i.avail_out-257),h=o.dmax,b=o.wsize,g=o.whave,v=o.wnext,y=o.window,_=o.hold,S=o.bits,M=o.lencode,w=o.distcode,T=(1<<o.lenbits)-1,P=(1<<o.distbits)-1;t:do{S<15&&(_+=u[l++]<<S,S+=8,_+=u[l++]<<S,S+=8),z=M[_&T];e:for(;;){if(_>>>=E=z>>>24,S-=E,(E=z>>>16&255)===0)j[m++]=65535&z;else{if(!(16&E)){if((64&E)==0){z=M[(65535&z)+(_&(1<<E)-1)];continue e}if(32&E){o.mode=12;break t}i.msg="invalid literal/length code",o.mode=30;break t}L=65535&z,(E&=15)&&(S<E&&(_+=u[l++]<<S,S+=8),L+=_&(1<<E)-1,_>>>=E,S-=E),S<15&&(_+=u[l++]<<S,S+=8,_+=u[l++]<<S,S+=8),z=w[_&P];n:for(;;){if(_>>>=E=z>>>24,S-=E,!(16&(E=z>>>16&255))){if((64&E)==0){z=w[(65535&z)+(_&(1<<E)-1)];continue n}i.msg="invalid distance code",o.mode=30;break t}if(V=65535&z,S<(E&=15)&&(_+=u[l++]<<S,(S+=8)<E&&(_+=u[l++]<<S,S+=8)),h<(V+=_&(1<<E)-1)){i.msg="invalid distance too far back",o.mode=30;break t}if(_>>>=E,S-=E,(E=m-f)<V){if(g<(E=V-E)&&o.sane){i.msg="invalid distance too far back",o.mode=30;break t}if(I=y,(k=0)===v){if(k+=b-E,E<L){for(L-=E;j[m++]=y[k++],--E;);k=m-V,I=j}}else if(v<E){if(k+=b+v-E,(E-=v)<L){for(L-=E;j[m++]=y[k++],--E;);if(k=0,v<L){for(L-=E=v;j[m++]=y[k++],--E;);k=m-V,I=j}}}else if(k+=v-E,E<L){for(L-=E;j[m++]=y[k++],--E;);k=m-V,I=j}for(;2<L;)j[m++]=I[k++],j[m++]=I[k++],j[m++]=I[k++],L-=3;L&&(j[m++]=I[k++],1<L&&(j[m++]=I[k++]))}else{for(k=m-V;j[m++]=j[k++],j[m++]=j[k++],j[m++]=j[k++],2<(L-=3););L&&(j[m++]=j[k++],1<L&&(j[m++]=j[k++]))}break}}break}}while(l<d&&m<p);l-=L=S>>3,_&=(1<<(S-=L<<3))-1,i.next_in=l,i.next_out=m,i.avail_in=l<d?d-l+5:5-(l-d),i.avail_out=m<p?p-m+257:257-(m-p),o.hold=_,o.bits=S}},{}],49:[function(e,s,r){var i=e("../utils/common"),a=e("./adler32"),o=e("./crc32"),l=e("./inffast"),d=e("./inftrees"),m=1,f=2,p=0,h=-2,b=1,g=852,v=592;function y(k){return(k>>>24&255)+(k>>>8&65280)+((65280&k)<<8)+((255&k)<<24)}function _(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function S(k){var I;return k&&k.state?(I=k.state,k.total_in=k.total_out=I.total=0,k.msg="",I.wrap&&(k.adler=1&I.wrap),I.mode=b,I.last=0,I.havedict=0,I.dmax=32768,I.head=null,I.hold=0,I.bits=0,I.lencode=I.lendyn=new i.Buf32(g),I.distcode=I.distdyn=new i.Buf32(v),I.sane=1,I.back=-1,p):h}function M(k){var I;return k&&k.state?((I=k.state).wsize=0,I.whave=0,I.wnext=0,S(k)):h}function w(k,I){var u,j;return k&&k.state?(j=k.state,I<0?(u=0,I=-I):(u=1+(I>>4),I<48&&(I&=15)),I&&(I<8||15<I)?h:(j.window!==null&&j.wbits!==I&&(j.window=null),j.wrap=u,j.wbits=I,M(k))):h}function T(k,I){var u,j;return k?(j=new _,(k.state=j).window=null,(u=w(k,I))!==p&&(k.state=null),u):h}var P,z,E=!0;function L(k){if(E){var I;for(P=new i.Buf32(512),z=new i.Buf32(32),I=0;I<144;)k.lens[I++]=8;for(;I<256;)k.lens[I++]=9;for(;I<280;)k.lens[I++]=7;for(;I<288;)k.lens[I++]=8;for(d(m,k.lens,0,288,P,0,k.work,{bits:9}),I=0;I<32;)k.lens[I++]=5;d(f,k.lens,0,32,z,0,k.work,{bits:5}),E=!1}k.lencode=P,k.lenbits=9,k.distcode=z,k.distbits=5}function V(k,I,u,j){var X,G=k.state;return G.window===null&&(G.wsize=1<<G.wbits,G.wnext=0,G.whave=0,G.window=new i.Buf8(G.wsize)),j>=G.wsize?(i.arraySet(G.window,I,u-G.wsize,G.wsize,0),G.wnext=0,G.whave=G.wsize):(j<(X=G.wsize-G.wnext)&&(X=j),i.arraySet(G.window,I,u-j,X,G.wnext),(j-=X)?(i.arraySet(G.window,I,u-j,j,0),G.wnext=j,G.whave=G.wsize):(G.wnext+=X,G.wnext===G.wsize&&(G.wnext=0),G.whave<G.wsize&&(G.whave+=X))),0}r.inflateReset=M,r.inflateReset2=w,r.inflateResetKeep=S,r.inflateInit=function(k){return T(k,15)},r.inflateInit2=T,r.inflate=function(k,I){var u,j,X,G,st,H,Q,B,R,J,tt,Z,pt,wt,ht,ut,yt,q,et,it,c,D,F,A,x=0,C=new i.Buf8(4),U=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!k||!k.state||!k.output||!k.input&&k.avail_in!==0)return h;(u=k.state).mode===12&&(u.mode=13),st=k.next_out,X=k.output,Q=k.avail_out,G=k.next_in,j=k.input,H=k.avail_in,B=u.hold,R=u.bits,J=H,tt=Q,D=p;t:for(;;)switch(u.mode){case b:if(u.wrap===0){u.mode=13;break}for(;R<16;){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}if(2&u.wrap&&B===35615){C[u.check=0]=255&B,C[1]=B>>>8&255,u.check=o(u.check,C,2,0),R=B=0,u.mode=2;break}if(u.flags=0,u.head&&(u.head.done=!1),!(1&u.wrap)||(((255&B)<<8)+(B>>8))%31){k.msg="incorrect header check",u.mode=30;break}if((15&B)!=8){k.msg="unknown compression method",u.mode=30;break}if(R-=4,c=8+(15&(B>>>=4)),u.wbits===0)u.wbits=c;else if(c>u.wbits){k.msg="invalid window size",u.mode=30;break}u.dmax=1<<c,k.adler=u.check=1,u.mode=512&B?10:12,R=B=0;break;case 2:for(;R<16;){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}if(u.flags=B,(255&u.flags)!=8){k.msg="unknown compression method",u.mode=30;break}if(57344&u.flags){k.msg="unknown header flags set",u.mode=30;break}u.head&&(u.head.text=B>>8&1),512&u.flags&&(C[0]=255&B,C[1]=B>>>8&255,u.check=o(u.check,C,2,0)),R=B=0,u.mode=3;case 3:for(;R<32;){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}u.head&&(u.head.time=B),512&u.flags&&(C[0]=255&B,C[1]=B>>>8&255,C[2]=B>>>16&255,C[3]=B>>>24&255,u.check=o(u.check,C,4,0)),R=B=0,u.mode=4;case 4:for(;R<16;){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}u.head&&(u.head.xflags=255&B,u.head.os=B>>8),512&u.flags&&(C[0]=255&B,C[1]=B>>>8&255,u.check=o(u.check,C,2,0)),R=B=0,u.mode=5;case 5:if(1024&u.flags){for(;R<16;){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}u.length=B,u.head&&(u.head.extra_len=B),512&u.flags&&(C[0]=255&B,C[1]=B>>>8&255,u.check=o(u.check,C,2,0)),R=B=0}else u.head&&(u.head.extra=null);u.mode=6;case 6:if(1024&u.flags&&(H<(Z=u.length)&&(Z=H),Z&&(u.head&&(c=u.head.extra_len-u.length,u.head.extra||(u.head.extra=new Array(u.head.extra_len)),i.arraySet(u.head.extra,j,G,Z,c)),512&u.flags&&(u.check=o(u.check,j,Z,G)),H-=Z,G+=Z,u.length-=Z),u.length))break t;u.length=0,u.mode=7;case 7:if(2048&u.flags){if(H===0)break t;for(Z=0;c=j[G+Z++],u.head&&c&&u.length<65536&&(u.head.name+=String.fromCharCode(c)),c&&Z<H;);if(512&u.flags&&(u.check=o(u.check,j,Z,G)),H-=Z,G+=Z,c)break t}else u.head&&(u.head.name=null);u.length=0,u.mode=8;case 8:if(4096&u.flags){if(H===0)break t;for(Z=0;c=j[G+Z++],u.head&&c&&u.length<65536&&(u.head.comment+=String.fromCharCode(c)),c&&Z<H;);if(512&u.flags&&(u.check=o(u.check,j,Z,G)),H-=Z,G+=Z,c)break t}else u.head&&(u.head.comment=null);u.mode=9;case 9:if(512&u.flags){for(;R<16;){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}if(B!==(65535&u.check)){k.msg="header crc mismatch",u.mode=30;break}R=B=0}u.head&&(u.head.hcrc=u.flags>>9&1,u.head.done=!0),k.adler=u.check=0,u.mode=12;break;case 10:for(;R<32;){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}k.adler=u.check=y(B),R=B=0,u.mode=11;case 11:if(u.havedict===0)return k.next_out=st,k.avail_out=Q,k.next_in=G,k.avail_in=H,u.hold=B,u.bits=R,2;k.adler=u.check=1,u.mode=12;case 12:if(I===5||I===6)break t;case 13:if(u.last){B>>>=7&R,R-=7&R,u.mode=27;break}for(;R<3;){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}switch(u.last=1&B,R-=1,3&(B>>>=1)){case 0:u.mode=14;break;case 1:if(L(u),u.mode=20,I!==6)break;B>>>=2,R-=2;break t;case 2:u.mode=17;break;case 3:k.msg="invalid block type",u.mode=30}B>>>=2,R-=2;break;case 14:for(B>>>=7&R,R-=7&R;R<32;){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}if((65535&B)!=(B>>>16^65535)){k.msg="invalid stored block lengths",u.mode=30;break}if(u.length=65535&B,R=B=0,u.mode=15,I===6)break t;case 15:u.mode=16;case 16:if(Z=u.length){if(H<Z&&(Z=H),Q<Z&&(Z=Q),Z===0)break t;i.arraySet(X,j,G,Z,st),H-=Z,G+=Z,Q-=Z,st+=Z,u.length-=Z;break}u.mode=12;break;case 17:for(;R<14;){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}if(u.nlen=257+(31&B),B>>>=5,R-=5,u.ndist=1+(31&B),B>>>=5,R-=5,u.ncode=4+(15&B),B>>>=4,R-=4,286<u.nlen||30<u.ndist){k.msg="too many length or distance symbols",u.mode=30;break}u.have=0,u.mode=18;case 18:for(;u.have<u.ncode;){for(;R<3;){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}u.lens[U[u.have++]]=7&B,B>>>=3,R-=3}for(;u.have<19;)u.lens[U[u.have++]]=0;if(u.lencode=u.lendyn,u.lenbits=7,F={bits:u.lenbits},D=d(0,u.lens,0,19,u.lencode,0,u.work,F),u.lenbits=F.bits,D){k.msg="invalid code lengths set",u.mode=30;break}u.have=0,u.mode=19;case 19:for(;u.have<u.nlen+u.ndist;){for(;ut=(x=u.lencode[B&(1<<u.lenbits)-1])>>>16&255,yt=65535&x,!((ht=x>>>24)<=R);){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}if(yt<16)B>>>=ht,R-=ht,u.lens[u.have++]=yt;else{if(yt===16){for(A=ht+2;R<A;){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}if(B>>>=ht,R-=ht,u.have===0){k.msg="invalid bit length repeat",u.mode=30;break}c=u.lens[u.have-1],Z=3+(3&B),B>>>=2,R-=2}else if(yt===17){for(A=ht+3;R<A;){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}R-=ht,c=0,Z=3+(7&(B>>>=ht)),B>>>=3,R-=3}else{for(A=ht+7;R<A;){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}R-=ht,c=0,Z=11+(127&(B>>>=ht)),B>>>=7,R-=7}if(u.have+Z>u.nlen+u.ndist){k.msg="invalid bit length repeat",u.mode=30;break}for(;Z--;)u.lens[u.have++]=c}}if(u.mode===30)break;if(u.lens[256]===0){k.msg="invalid code -- missing end-of-block",u.mode=30;break}if(u.lenbits=9,F={bits:u.lenbits},D=d(m,u.lens,0,u.nlen,u.lencode,0,u.work,F),u.lenbits=F.bits,D){k.msg="invalid literal/lengths set",u.mode=30;break}if(u.distbits=6,u.distcode=u.distdyn,F={bits:u.distbits},D=d(f,u.lens,u.nlen,u.ndist,u.distcode,0,u.work,F),u.distbits=F.bits,D){k.msg="invalid distances set",u.mode=30;break}if(u.mode=20,I===6)break t;case 20:u.mode=21;case 21:if(6<=H&&258<=Q){k.next_out=st,k.avail_out=Q,k.next_in=G,k.avail_in=H,u.hold=B,u.bits=R,l(k,tt),st=k.next_out,X=k.output,Q=k.avail_out,G=k.next_in,j=k.input,H=k.avail_in,B=u.hold,R=u.bits,u.mode===12&&(u.back=-1);break}for(u.back=0;ut=(x=u.lencode[B&(1<<u.lenbits)-1])>>>16&255,yt=65535&x,!((ht=x>>>24)<=R);){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}if(ut&&(240&ut)==0){for(q=ht,et=ut,it=yt;ut=(x=u.lencode[it+((B&(1<<q+et)-1)>>q)])>>>16&255,yt=65535&x,!(q+(ht=x>>>24)<=R);){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}B>>>=q,R-=q,u.back+=q}if(B>>>=ht,R-=ht,u.back+=ht,u.length=yt,ut===0){u.mode=26;break}if(32&ut){u.back=-1,u.mode=12;break}if(64&ut){k.msg="invalid literal/length code",u.mode=30;break}u.extra=15&ut,u.mode=22;case 22:if(u.extra){for(A=u.extra;R<A;){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}u.length+=B&(1<<u.extra)-1,B>>>=u.extra,R-=u.extra,u.back+=u.extra}u.was=u.length,u.mode=23;case 23:for(;ut=(x=u.distcode[B&(1<<u.distbits)-1])>>>16&255,yt=65535&x,!((ht=x>>>24)<=R);){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}if((240&ut)==0){for(q=ht,et=ut,it=yt;ut=(x=u.distcode[it+((B&(1<<q+et)-1)>>q)])>>>16&255,yt=65535&x,!(q+(ht=x>>>24)<=R);){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}B>>>=q,R-=q,u.back+=q}if(B>>>=ht,R-=ht,u.back+=ht,64&ut){k.msg="invalid distance code",u.mode=30;break}u.offset=yt,u.extra=15&ut,u.mode=24;case 24:if(u.extra){for(A=u.extra;R<A;){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}u.offset+=B&(1<<u.extra)-1,B>>>=u.extra,R-=u.extra,u.back+=u.extra}if(u.offset>u.dmax){k.msg="invalid distance too far back",u.mode=30;break}u.mode=25;case 25:if(Q===0)break t;if(Z=tt-Q,u.offset>Z){if((Z=u.offset-Z)>u.whave&&u.sane){k.msg="invalid distance too far back",u.mode=30;break}pt=Z>u.wnext?(Z-=u.wnext,u.wsize-Z):u.wnext-Z,Z>u.length&&(Z=u.length),wt=u.window}else wt=X,pt=st-u.offset,Z=u.length;for(Q<Z&&(Z=Q),Q-=Z,u.length-=Z;X[st++]=wt[pt++],--Z;);u.length===0&&(u.mode=21);break;case 26:if(Q===0)break t;X[st++]=u.length,Q--,u.mode=21;break;case 27:if(u.wrap){for(;R<32;){if(H===0)break t;H--,B|=j[G++]<<R,R+=8}if(tt-=Q,k.total_out+=tt,u.total+=tt,tt&&(k.adler=u.check=u.flags?o(u.check,X,tt,st-tt):a(u.check,X,tt,st-tt)),tt=Q,(u.flags?B:y(B))!==u.check){k.msg="incorrect data check",u.mode=30;break}R=B=0}u.mode=28;case 28:if(u.wrap&&u.flags){for(;R<32;){if(H===0)break t;H--,B+=j[G++]<<R,R+=8}if(B!==(4294967295&u.total)){k.msg="incorrect length check",u.mode=30;break}R=B=0}u.mode=29;case 29:D=1;break t;case 30:D=-3;break t;case 31:return-4;case 32:default:return h}return k.next_out=st,k.avail_out=Q,k.next_in=G,k.avail_in=H,u.hold=B,u.bits=R,(u.wsize||tt!==k.avail_out&&u.mode<30&&(u.mode<27||I!==4))&&V(k,k.output,k.next_out,tt-k.avail_out)?(u.mode=31,-4):(J-=k.avail_in,tt-=k.avail_out,k.total_in+=J,k.total_out+=tt,u.total+=tt,u.wrap&&tt&&(k.adler=u.check=u.flags?o(u.check,X,tt,k.next_out-tt):a(u.check,X,tt,k.next_out-tt)),k.data_type=u.bits+(u.last?64:0)+(u.mode===12?128:0)+(u.mode===20||u.mode===15?256:0),(J==0&&tt===0||I===4)&&D===p&&(D=-5),D)},r.inflateEnd=function(k){if(!k||!k.state)return h;var I=k.state;return I.window&&(I.window=null),k.state=null,p},r.inflateGetHeader=function(k,I){var u;return k&&k.state?(2&(u=k.state).wrap)==0?h:((u.head=I).done=!1,p):h},r.inflateSetDictionary=function(k,I){var u,j=I.length;return k&&k.state?(u=k.state).wrap!==0&&u.mode!==11?h:u.mode===11&&a(1,I,j,0)!==u.check?-3:V(k,I,j,j)?(u.mode=31,-4):(u.havedict=1,p):h},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,s,r){var i=e("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],d=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];s.exports=function(m,f,p,h,b,g,v,y){var _,S,M,w,T,P,z,E,L,V=y.bits,k=0,I=0,u=0,j=0,X=0,G=0,st=0,H=0,Q=0,B=0,R=null,J=0,tt=new i.Buf16(16),Z=new i.Buf16(16),pt=null,wt=0;for(k=0;k<=15;k++)tt[k]=0;for(I=0;I<h;I++)tt[f[p+I]]++;for(X=V,j=15;1<=j&&tt[j]===0;j--);if(j<X&&(X=j),j===0)return b[g++]=20971520,b[g++]=20971520,y.bits=1,0;for(u=1;u<j&&tt[u]===0;u++);for(X<u&&(X=u),k=H=1;k<=15;k++)if(H<<=1,(H-=tt[k])<0)return-1;if(0<H&&(m===0||j!==1))return-1;for(Z[1]=0,k=1;k<15;k++)Z[k+1]=Z[k]+tt[k];for(I=0;I<h;I++)f[p+I]!==0&&(v[Z[f[p+I]]++]=I);if(P=m===0?(R=pt=v,19):m===1?(R=a,J-=257,pt=o,wt-=257,256):(R=l,pt=d,-1),k=u,T=g,st=I=B=0,M=-1,w=(Q=1<<(G=X))-1,m===1&&852<Q||m===2&&592<Q)return 1;for(;;){for(z=k-st,L=v[I]<P?(E=0,v[I]):v[I]>P?(E=pt[wt+v[I]],R[J+v[I]]):(E=96,0),_=1<<k-st,u=S=1<<G;b[T+(B>>st)+(S-=_)]=z<<24|E<<16|L|0,S!==0;);for(_=1<<k-1;B&_;)_>>=1;if(_!==0?(B&=_-1,B+=_):B=0,I++,--tt[k]==0){if(k===j)break;k=f[p+v[I]]}if(X<k&&(B&w)!==M){for(st===0&&(st=X),T+=u,H=1<<(G=k-st);G+st<j&&!((H-=tt[G+st])<=0);)G++,H<<=1;if(Q+=1<<G,m===1&&852<Q||m===2&&592<Q)return 1;b[M=B&w]=X<<24|G<<16|T-g|0}}return B!==0&&(b[T+B]=k-st<<24|64<<16|0),y.bits=X,0}},{"../utils/common":41}],51:[function(e,s,r){s.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(e,s,r){var i=e("../utils/common"),a=0,o=1;function l(x){for(var C=x.length;0<=--C;)x[C]=0}var d=0,m=29,f=256,p=f+1+m,h=30,b=19,g=2*p+1,v=15,y=16,_=7,S=256,M=16,w=17,T=18,P=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],z=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],E=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],L=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],V=new Array(2*(p+2));l(V);var k=new Array(2*h);l(k);var I=new Array(512);l(I);var u=new Array(256);l(u);var j=new Array(m);l(j);var X,G,st,H=new Array(h);function Q(x,C,U,$,O){this.static_tree=x,this.extra_bits=C,this.extra_base=U,this.elems=$,this.max_length=O,this.has_stree=x&&x.length}function B(x,C){this.dyn_tree=x,this.max_code=0,this.stat_desc=C}function R(x){return x<256?I[x]:I[256+(x>>>7)]}function J(x,C){x.pending_buf[x.pending++]=255&C,x.pending_buf[x.pending++]=C>>>8&255}function tt(x,C,U){x.bi_valid>y-U?(x.bi_buf|=C<<x.bi_valid&65535,J(x,x.bi_buf),x.bi_buf=C>>y-x.bi_valid,x.bi_valid+=U-y):(x.bi_buf|=C<<x.bi_valid&65535,x.bi_valid+=U)}function Z(x,C,U){tt(x,U[2*C],U[2*C+1])}function pt(x,C){for(var U=0;U|=1&x,x>>>=1,U<<=1,0<--C;);return U>>>1}function wt(x,C,U){var $,O,K=new Array(v+1),nt=0;for($=1;$<=v;$++)K[$]=nt=nt+U[$-1]<<1;for(O=0;O<=C;O++){var Y=x[2*O+1];Y!==0&&(x[2*O]=pt(K[Y]++,Y))}}function ht(x){var C;for(C=0;C<p;C++)x.dyn_ltree[2*C]=0;for(C=0;C<h;C++)x.dyn_dtree[2*C]=0;for(C=0;C<b;C++)x.bl_tree[2*C]=0;x.dyn_ltree[2*S]=1,x.opt_len=x.static_len=0,x.last_lit=x.matches=0}function ut(x){8<x.bi_valid?J(x,x.bi_buf):0<x.bi_valid&&(x.pending_buf[x.pending++]=x.bi_buf),x.bi_buf=0,x.bi_valid=0}function yt(x,C,U,$){var O=2*C,K=2*U;return x[O]<x[K]||x[O]===x[K]&&$[C]<=$[U]}function q(x,C,U){for(var $=x.heap[U],O=U<<1;O<=x.heap_len&&(O<x.heap_len&&yt(C,x.heap[O+1],x.heap[O],x.depth)&&O++,!yt(C,$,x.heap[O],x.depth));)x.heap[U]=x.heap[O],U=O,O<<=1;x.heap[U]=$}function et(x,C,U){var $,O,K,nt,Y=0;if(x.last_lit!==0)for(;$=x.pending_buf[x.d_buf+2*Y]<<8|x.pending_buf[x.d_buf+2*Y+1],O=x.pending_buf[x.l_buf+Y],Y++,$===0?Z(x,O,C):(Z(x,(K=u[O])+f+1,C),(nt=P[K])!==0&&tt(x,O-=j[K],nt),Z(x,K=R(--$),U),(nt=z[K])!==0&&tt(x,$-=H[K],nt)),Y<x.last_lit;);Z(x,S,C)}function it(x,C){var U,$,O,K=C.dyn_tree,nt=C.stat_desc.static_tree,Y=C.stat_desc.has_stree,rt=C.stat_desc.elems,dt=-1;for(x.heap_len=0,x.heap_max=g,U=0;U<rt;U++)K[2*U]!==0?(x.heap[++x.heap_len]=dt=U,x.depth[U]=0):K[2*U+1]=0;for(;x.heap_len<2;)K[2*(O=x.heap[++x.heap_len]=dt<2?++dt:0)]=1,x.depth[O]=0,x.opt_len--,Y&&(x.static_len-=nt[2*O+1]);for(C.max_code=dt,U=x.heap_len>>1;1<=U;U--)q(x,K,U);for(O=rt;U=x.heap[1],x.heap[1]=x.heap[x.heap_len--],q(x,K,1),$=x.heap[1],x.heap[--x.heap_max]=U,x.heap[--x.heap_max]=$,K[2*O]=K[2*U]+K[2*$],x.depth[O]=(x.depth[U]>=x.depth[$]?x.depth[U]:x.depth[$])+1,K[2*U+1]=K[2*$+1]=O,x.heap[1]=O++,q(x,K,1),2<=x.heap_len;);x.heap[--x.heap_max]=x.heap[1],(function(ct,xt){var Et,kt,Rt,bt,ot,mt,St=xt.dyn_tree,Lt=xt.max_code,ce=xt.stat_desc.static_tree,Vt=xt.stat_desc.has_stree,Jt=xt.stat_desc.extra_bits,It=xt.stat_desc.extra_base,Ct=xt.stat_desc.max_length,Mt=0;for(bt=0;bt<=v;bt++)ct.bl_count[bt]=0;for(St[2*ct.heap[ct.heap_max]+1]=0,Et=ct.heap_max+1;Et<g;Et++)Ct<(bt=St[2*St[2*(kt=ct.heap[Et])+1]+1]+1)&&(bt=Ct,Mt++),St[2*kt+1]=bt,Lt<kt||(ct.bl_count[bt]++,ot=0,It<=kt&&(ot=Jt[kt-It]),mt=St[2*kt],ct.opt_len+=mt*(bt+ot),Vt&&(ct.static_len+=mt*(ce[2*kt+1]+ot)));if(Mt!==0){do{for(bt=Ct-1;ct.bl_count[bt]===0;)bt--;ct.bl_count[bt]--,ct.bl_count[bt+1]+=2,ct.bl_count[Ct]--,Mt-=2}while(0<Mt);for(bt=Ct;bt!==0;bt--)for(kt=ct.bl_count[bt];kt!==0;)Lt<(Rt=ct.heap[--Et])||(St[2*Rt+1]!==bt&&(ct.opt_len+=(bt-St[2*Rt+1])*St[2*Rt],St[2*Rt+1]=bt),kt--)}})(x,C),wt(K,dt,x.bl_count)}function c(x,C,U){var $,O,K=-1,nt=C[1],Y=0,rt=7,dt=4;for(nt===0&&(rt=138,dt=3),C[2*(U+1)+1]=65535,$=0;$<=U;$++)O=nt,nt=C[2*($+1)+1],++Y<rt&&O===nt||(Y<dt?x.bl_tree[2*O]+=Y:O!==0?(O!==K&&x.bl_tree[2*O]++,x.bl_tree[2*M]++):Y<=10?x.bl_tree[2*w]++:x.bl_tree[2*T]++,K=O,dt=(Y=0)===nt?(rt=138,3):O===nt?(rt=6,3):(rt=7,4))}function D(x,C,U){var $,O,K=-1,nt=C[1],Y=0,rt=7,dt=4;for(nt===0&&(rt=138,dt=3),$=0;$<=U;$++)if(O=nt,nt=C[2*($+1)+1],!(++Y<rt&&O===nt)){if(Y<dt)for(;Z(x,O,x.bl_tree),--Y!=0;);else O!==0?(O!==K&&(Z(x,O,x.bl_tree),Y--),Z(x,M,x.bl_tree),tt(x,Y-3,2)):Y<=10?(Z(x,w,x.bl_tree),tt(x,Y-3,3)):(Z(x,T,x.bl_tree),tt(x,Y-11,7));K=O,dt=(Y=0)===nt?(rt=138,3):O===nt?(rt=6,3):(rt=7,4)}}l(H);var F=!1;function A(x,C,U,$){tt(x,(d<<1)+($?1:0),3),(function(O,K,nt,Y){ut(O),J(O,nt),J(O,~nt),i.arraySet(O.pending_buf,O.window,K,nt,O.pending),O.pending+=nt})(x,C,U)}r._tr_init=function(x){F||((function(){var C,U,$,O,K,nt=new Array(v+1);for(O=$=0;O<m-1;O++)for(j[O]=$,C=0;C<1<<P[O];C++)u[$++]=O;for(u[$-1]=O,O=K=0;O<16;O++)for(H[O]=K,C=0;C<1<<z[O];C++)I[K++]=O;for(K>>=7;O<h;O++)for(H[O]=K<<7,C=0;C<1<<z[O]-7;C++)I[256+K++]=O;for(U=0;U<=v;U++)nt[U]=0;for(C=0;C<=143;)V[2*C+1]=8,C++,nt[8]++;for(;C<=255;)V[2*C+1]=9,C++,nt[9]++;for(;C<=279;)V[2*C+1]=7,C++,nt[7]++;for(;C<=287;)V[2*C+1]=8,C++,nt[8]++;for(wt(V,p+1,nt),C=0;C<h;C++)k[2*C+1]=5,k[2*C]=pt(C,5);X=new Q(V,P,f+1,p,v),G=new Q(k,z,0,h,v),st=new Q(new Array(0),E,0,b,_)})(),F=!0),x.l_desc=new B(x.dyn_ltree,X),x.d_desc=new B(x.dyn_dtree,G),x.bl_desc=new B(x.bl_tree,st),x.bi_buf=0,x.bi_valid=0,ht(x)},r._tr_stored_block=A,r._tr_flush_block=function(x,C,U,$){var O,K,nt=0;0<x.level?(x.strm.data_type===2&&(x.strm.data_type=(function(Y){var rt,dt=4093624447;for(rt=0;rt<=31;rt++,dt>>>=1)if(1&dt&&Y.dyn_ltree[2*rt]!==0)return a;if(Y.dyn_ltree[18]!==0||Y.dyn_ltree[20]!==0||Y.dyn_ltree[26]!==0)return o;for(rt=32;rt<f;rt++)if(Y.dyn_ltree[2*rt]!==0)return o;return a})(x)),it(x,x.l_desc),it(x,x.d_desc),nt=(function(Y){var rt;for(c(Y,Y.dyn_ltree,Y.l_desc.max_code),c(Y,Y.dyn_dtree,Y.d_desc.max_code),it(Y,Y.bl_desc),rt=b-1;3<=rt&&Y.bl_tree[2*L[rt]+1]===0;rt--);return Y.opt_len+=3*(rt+1)+5+5+4,rt})(x),O=x.opt_len+3+7>>>3,(K=x.static_len+3+7>>>3)<=O&&(O=K)):O=K=U+5,U+4<=O&&C!==-1?A(x,C,U,$):x.strategy===4||K===O?(tt(x,2+($?1:0),3),et(x,V,k)):(tt(x,4+($?1:0),3),(function(Y,rt,dt,ct){var xt;for(tt(Y,rt-257,5),tt(Y,dt-1,5),tt(Y,ct-4,4),xt=0;xt<ct;xt++)tt(Y,Y.bl_tree[2*L[xt]+1],3);D(Y,Y.dyn_ltree,rt-1),D(Y,Y.dyn_dtree,dt-1)})(x,x.l_desc.max_code+1,x.d_desc.max_code+1,nt+1),et(x,x.dyn_ltree,x.dyn_dtree)),ht(x),$&&ut(x)},r._tr_tally=function(x,C,U){return x.pending_buf[x.d_buf+2*x.last_lit]=C>>>8&255,x.pending_buf[x.d_buf+2*x.last_lit+1]=255&C,x.pending_buf[x.l_buf+x.last_lit]=255&U,x.last_lit++,C===0?x.dyn_ltree[2*U]++:(x.matches++,C--,x.dyn_ltree[2*(u[U]+f+1)]++,x.dyn_dtree[2*R(C)]++),x.last_lit===x.lit_bufsize-1},r._tr_align=function(x){tt(x,2,3),Z(x,S,V),(function(C){C.bi_valid===16?(J(C,C.bi_buf),C.bi_buf=0,C.bi_valid=0):8<=C.bi_valid&&(C.pending_buf[C.pending++]=255&C.bi_buf,C.bi_buf>>=8,C.bi_valid-=8)})(x)}},{"../utils/common":41}],53:[function(e,s,r){s.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,s,r){(function(i){(function(a,o){if(!a.setImmediate){var l,d,m,f,p=1,h={},b=!1,g=a.document,v=Object.getPrototypeOf&&Object.getPrototypeOf(a);v=v&&v.setTimeout?v:a,l={}.toString.call(a.process)==="[object process]"?function(M){process.nextTick(function(){_(M)})}:(function(){if(a.postMessage&&!a.importScripts){var M=!0,w=a.onmessage;return a.onmessage=function(){M=!1},a.postMessage("","*"),a.onmessage=w,M}})()?(f="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",S,!1):a.attachEvent("onmessage",S),function(M){a.postMessage(f+M,"*")}):a.MessageChannel?((m=new MessageChannel).port1.onmessage=function(M){_(M.data)},function(M){m.port2.postMessage(M)}):g&&"onreadystatechange"in g.createElement("script")?(d=g.documentElement,function(M){var w=g.createElement("script");w.onreadystatechange=function(){_(M),w.onreadystatechange=null,d.removeChild(w),w=null},d.appendChild(w)}):function(M){setTimeout(_,0,M)},v.setImmediate=function(M){typeof M!="function"&&(M=new Function(""+M));for(var w=new Array(arguments.length-1),T=0;T<w.length;T++)w[T]=arguments[T+1];var P={callback:M,args:w};return h[p]=P,l(p),p++},v.clearImmediate=y}function y(M){delete h[M]}function _(M){if(b)setTimeout(_,0,M);else{var w=h[M];if(w){b=!0;try{(function(T){var P=T.callback,z=T.args;switch(z.length){case 0:P();break;case 1:P(z[0]);break;case 2:P(z[0],z[1]);break;case 3:P(z[0],z[1],z[2]);break;default:P.apply(o,z)}})(w)}finally{y(M),b=!1}}}}function S(M){M.source===a&&typeof M.data=="string"&&M.data.indexOf(f)===0&&_(+M.data.slice(f.length))}})(typeof self>"u"?i===void 0?this:i:self)}).call(this,typeof xn<"u"?xn:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(dr)),dr.exports}var $c=Gc();const wo=Wc($c);var Vc=Object.defineProperty,Yc=Object.defineProperties,Kc=Object.getOwnPropertyDescriptors,Ks=Object.getOwnPropertySymbols,Zc=Object.prototype.hasOwnProperty,qc=Object.prototype.propertyIsEnumerable,xo=t=>{throw TypeError(t)},Zs=(t,n,e)=>n in t?Vc(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,Fe=(t,n)=>{for(var e in n||(n={}))Zc.call(n,e)&&Zs(t,e,n[e]);if(Ks)for(var e of Ks(n))qc.call(n,e)&&Zs(t,e,n[e]);return t},Qc=(t,n)=>Yc(t,Kc(n)),Hr=(t,n,e)=>n.has(t)||xo("Cannot "+e),W=(t,n,e)=>(Hr(t,n,"read from private field"),e?e.call(t):n.get(t)),lt=(t,n,e)=>n.has(t)?xo("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(t):n.set(t,e),at=(t,n,e,s)=>(Hr(t,n,"write to private field"),n.set(t,e),e),Un=(t,n,e)=>(Hr(t,n,"access private method"),e),le=(t,n,e)=>new Promise((s,r)=>{var i=l=>{try{o(e.next(l))}catch(d){r(d)}},a=l=>{try{o(e.throw(l))}catch(d){r(d)}},o=l=>l.done?s(l.value):Promise.resolve(l.value).then(i,a);o((e=e.apply(t,n)).next())}),Ur={fetch(t){return fetch(t)}};function fr(t){const n=t.filter(e=>!!e);return n.reduce((e,s)=>{const r="output"in e?e.output:e,i="input"in s?s.input:s;return r.connect(i),s}),()=>{n.reduce((e,s)=>{const r="output"in e?e.output:e,i="input"in s?s.input:s;return r.disconnect(i),s})}}function Xc(t){let n=t;const e=new Set;function s(a){return e.add(a),a(n),()=>{e.delete(a)}}function r(a){n=a,e.forEach(o=>o(n))}function i(){return n}return{subscribe:s,set:r,get:i}}function Ao(t){return t*t/16129}function Jc(t){return Math.pow(10,t/20)}var he,ne,we,xe,Cn,ue,de,th=class{constructor(t,n){this.context=t,lt(this,he),lt(this,ne),lt(this,we),lt(this,xe),lt(this,Cn),lt(this,ue),lt(this,de,!1);var e,s,r;at(this,ue,{destination:(e=n==null?void 0:n.destination)!=null?e:t.destination,volume:(s=n==null?void 0:n.volume)!=null?s:100,volumeToGain:(r=n==null?void 0:n.volumeToGain)!=null?r:Ao}),this.input=t.createGain(),at(this,he,t.createGain()),at(this,xe,fr([this.input,W(this,he),W(this,ue).destination]));const i=Xc(W(this,ue).volume);this.setVolume=i.set,at(this,Cn,i.subscribe(a=>{W(this,he).gain.value=W(this,ue).volumeToGain(a)}))}addInsert(t){var n;if(W(this,de))throw Error("Can't add insert to disconnected channel");(n=W(this,we))!=null||at(this,we,[]),W(this,we).push(t),W(this,xe).call(this),at(this,xe,fr([this.input,...W(this,we),W(this,he),W(this,ue).destination]))}addEffect(t,n,e){var s;if(W(this,de))throw Error("Can't add effect to disconnected channel");const r=this.context.createGain();r.gain.value=e;const i="input"in n?n.input:n,a=fr([W(this,he),r,i]);(s=W(this,ne))!=null||at(this,ne,[]),W(this,ne).push({name:t,mix:r,disconnect:a})}sendEffect(t,n){var e;if(W(this,de))throw Error("Can't send effect to disconnected channel");const s=(e=W(this,ne))==null?void 0:e.find(r=>r.name===t);s?s.mix.gain.value=n:console.warn("Send bus not found: "+t)}disconnect(){var t;W(this,de)||(at(this,de,!0),W(this,xe).call(this),W(this,Cn).call(this),(t=W(this,ne))==null||t.forEach(n=>n.disconnect()),at(this,ne,void 0))}};he=new WeakMap;ne=new WeakMap;we=new WeakMap;xe=new WeakMap;Cn=new WeakMap;ue=new WeakMap;de=new WeakMap;function eh(t){const e=/^([a-gA-G]?)(#{1,}|b{1,}|)(-?\d+)$/.exec(t);if(!e)return;const s=e[1].toUpperCase();if(!s)return;const r=e[2],i=r[0]==="b"?-r.length:r.length,a=e[3]?+e[3]:4,o=(s.charCodeAt(0)+3)%7;return[0,2,4,5,7,9,11][o]+i+12*(a+1)}function hn(t){return t===void 0?void 0:typeof t=="number"?t:eh(t)}var So={volume:0,tune:0,detune:0,ampRelease:.3,ampAttack:0,lpfCutoffHz:2e4,offset:0,loop:!1,loopStart:0,loopEnd:0},nh=Object.keys(So);function qs(t){const n={};for(const e of nh){const s=t[e];s!==void 0&&(n[e]=s)}return n}function rh(t,n,e,s,r,i){var a,o,l,d,m;const f=Fe(Fe(Fe(Fe({},So),t),qs(n)),qs(e)),p=(o=(a=e.pitch)!=null?a:e.key)!=null?o:s;let b=(s-p+f.tune)*100+f.detune;return(i==null?void 0:i.detune)!==void 0&&(b+=i.detune),{detune:b,velocity:r,volume:f.volume,ampRelease:(l=i==null?void 0:i.ampRelease)!=null?l:f.ampRelease,ampAttack:f.ampAttack,lpfCutoffHz:(d=i==null?void 0:i.lpfCutoffHz)!=null?d:f.lpfCutoffHz,offset:f.offset,loop:(m=i==null?void 0:i.loop)!=null?m:f.loop,loopStart:f.loopStart,loopEnd:f.loopEnd,ampVelCurve:e.ampVelCurve,loopAuto:e.loopAuto}}function sh(t){var n,e,s,r,i;let a,o,l;return t.key!==void 0?(a=o=t.key,l=t.key):t.keyRange?([a,o]=t.keyRange,l=t.pitch):(a=0,o=127,l=t.pitch),{keyLow:a,keyHigh:o,pitch:l,velLow:(e=(n=t.velRange)==null?void 0:n[0])!=null?e:0,velHigh:(r=(s=t.velRange)==null?void 0:s[1])!=null?r:127,ccRange:t.ccRange,seqPosition:(i=t.seqPosition)!=null?i:1,group:t.group,offBy:t.offBy,sample:t.sample,ref:t}}function ih(t){var n,e,s,r,i,a,o,l;return{keyLow:(e=(n=t.keyRange)==null?void 0:n[0])!=null?e:0,keyHigh:(r=(s=t.keyRange)==null?void 0:s[1])!=null?r:127,velLow:(a=(i=t.velRange)==null?void 0:i[0])!=null?a:0,velHigh:(l=(o=t.velRange)==null?void 0:o[1])!=null?l:127,ccRange:t.ccRange,seqLength:t.seqLength,group:t.group,offBy:t.offBy,regions:t.regions.map(sh),ref:t}}function Qs(t,n){var e;if(!n)return!0;for(const[s,[r,i]]of Object.entries(n)){const a=parseInt(s,10),o=(e=t.get(a))!=null?e:0;if(o<r||o>i)return!1}return!0}var De,Le,Xs=class{constructor(t){lt(this,De),lt(this,Le),at(this,De,t.groups.map(ih)),at(this,Le,new Map)}match(t,n,e){var s,r,i,a;const o=[];for(let l=0;l<W(this,De).length;l++){const d=W(this,De)[l];if(t<d.keyLow||t>d.keyHigh||n<d.velLow||n>d.velHigh||!Qs(e,d.ccRange))continue;const m=(s=W(this,Le).get(l))!=null?s:0;for(const f of d.regions)if(!(t<f.keyLow||t>f.keyHigh)&&!(n<f.velLow||n>f.velHigh)&&Qs(e,f.ccRange)){if(d.seqLength!==void 0){const p=f.seqPosition-1;if(m%d.seqLength!==p)continue}o.push({sample:f.sample,pitch:(r=f.pitch)!=null?r:t,group:(i=f.group)!=null?i:d.group,offBy:(a=f.offBy)!=null?a:d.offBy,groupRef:d.ref,regionRef:f.ref})}d.seqLength!==void 0&&W(this,Le).set(l,m+1)}return o}};De=new WeakMap;Le=new WeakMap;function oh(t,n,e){return le(this,null,function*(){n=n.replace(/#/g,"%23").replace(/ /g,"%20").replace(/([^:]\/)\/+/g,"$1");const s=yield e.fetch(n);if(s.status!==200){console.warn("Error loading buffer. Invalid status: ",s.status,n);return}try{const r=yield s.arrayBuffer();return yield t.decodeAudioData(r)}catch(r){console.warn("Error loading buffer",r,n)}})}function ah(){if(typeof navigator>"u")return!1;const t=navigator.userAgent;return t.includes("Safari")&&!t.includes("Chrome")&&!t.includes("Chromium")}function ko(t){if(typeof document>"u")return null;const n=ah(),e=document.createElement("audio");for(let s=0;s<t.length;s++){const r=t[s];if(n&&r==="ogg")continue;const i=e.canPlayType(`audio/${r}`);if(i==="probably"||i==="maybe")return r;if(r==="m4a"){const a=e.canPlayType("audio/aac");if(a==="probably"||a==="maybe")return r}}return null}var En,In,Nn,lh=class{constructor(t,n){lt(this,En),lt(this,In),lt(this,Nn,new Map);var e;at(this,En,t),at(this,In,(e=n==null?void 0:n.storage)!=null?e:Ur)}load(t,n){return le(this,null,function*(){var e,s;const r=typeof n=="object"?n.buffers:void 0,i=typeof n=="function"?n:n==null?void 0:n.onProgress,a=(s=(e=ko(t.samples.formats))!=null?e:t.samples.formats[0])!=null?s:"ogg",o=t.samples.baseUrl.replace(/\/$/,""),l=ch(t),d=l.length;let m=0;const f=new Map;return yield Promise.all(l.map(p=>le(this,null,function*(){var h,b;const g=r==null?void 0:r.get(p);if(g){f.set(p,g),m++,i==null||i(m,d);return}const v=(b=(h=t.samples.map)==null?void 0:h[p])!=null?b:p,y=`${o}/${v}.${a}`;let _=W(this,Nn).get(y);if(!_){const S=yield oh(W(this,En),y,W(this,In));S&&(_=S,W(this,Nn).set(y,_))}_&&f.set(p,_),m++,i==null||i(m,d)}))),f})}};En=new WeakMap;In=new WeakMap;Nn=new WeakMap;function ch(t){const n=new Set;for(const e of t.groups)for(const s of e.regions)n.add(s.sample);return[...n]}var Tt,hh=class{constructor(t){this.compare=t,lt(this,Tt,[])}push(t){const n=W(this,Tt).length;let e=0,s=n-1,r=n;for(;e<=s;){const i=Math.floor((e+s)/2);this.compare(t,W(this,Tt)[i])<0?(r=i,s=i-1):e=i+1}W(this,Tt).splice(r,0,t)}pop(){return W(this,Tt).shift()}peek(){return W(this,Tt)[0]}removeAll(t){const n=W(this,Tt).length;return at(this,Tt,W(this,Tt).filter(e=>!t(e))),W(this,Tt).length!==n}clear(){at(this,Tt,[])}size(){return W(this,Tt).length}};Tt=new WeakMap;var uh=200,dh=50,tn,en,Wn,$t,qt,Sr,Mo,fh=class{constructor(t,n){lt(this,Sr),lt(this,tn),lt(this,en),lt(this,Wn),lt(this,$t),lt(this,qt);var e,s;at(this,tn,t),at(this,en,((e=n==null?void 0:n.lookaheadMs)!=null?e:uh)/1e3),at(this,Wn,(s=n==null?void 0:n.intervalMs)!=null?s:dh),at(this,$t,new hh((r,i)=>r.time-i.time))}schedule(t,n){var e;const s=W(this,tn).currentTime,r=(e=mh(t))!=null?e:s;if(r<=s+W(this,en))return n(t),ph;const i={time:r,event:t,callback:n};return W(this,$t).push(i),Un(this,Sr,Mo).call(this),()=>{W(this,$t).removeAll(a=>a===i)}}stop(){W(this,$t).clear(),W(this,qt)!==void 0&&(clearInterval(W(this,qt)),at(this,qt,void 0))}};tn=new WeakMap;en=new WeakMap;Wn=new WeakMap;$t=new WeakMap;qt=new WeakMap;Sr=new WeakSet;Mo=function(){W(this,qt)===void 0&&at(this,qt,setInterval(()=>{const t=W(this,tn).currentTime+W(this,en);for(;W(this,$t).size()>0&&W(this,$t).peek().time<=t;){const n=W(this,$t).pop();n.callback(n.event)}W(this,$t).size()===0&&(clearInterval(W(this,qt)),at(this,qt,void 0))},W(this,Wn)))};function mh(t){return typeof t=="object"?t.time:void 0}var ph=()=>{},Tn,He,Ae,Rn,On,fe,Ue,gh=class{constructor(t,n,e,s,r,i,a){lt(this,Tn),lt(this,He),lt(this,Ae),lt(this,Rn),lt(this,On),lt(this,fe,"playing"),lt(this,Ue,[]),at(this,Tn,t),this.stopId=r,this.group=i,at(this,On,e.ampRelease);const o=t.createBufferSource();o.buffer=n;const l=e.detune;o.detune?o.detune.value=l:o.playbackRate.value=Math.pow(2,l/1200),e.loopAuto?(o.loop=!0,o.loopStart=n.duration*e.loopAuto.startRatio,o.loopEnd=n.duration*e.loopAuto.endRatio):e.loop&&(o.loop=!0,o.loopStart=e.loopStart,o.loopEnd=e.loopEnd||n.duration);let d;e.lpfCutoffHz<2e4&&(d=t.createBiquadFilter(),d.type="lowpass",d.frequency.value=e.lpfCutoffHz);const m=t.createGain();m.gain.value=Ao(e.velocity)*Jc(e.volume);const f=t.createGain();f.gain.value=1,d?(o.connect(d),d.connect(m)):o.connect(m),m.connect(f),f.connect(s);const p=a??t.currentTime;at(this,Rn,p);const h=e.offset>0?e.offset/n.sampleRate:0;o.start(p,h),at(this,He,o),at(this,Ae,f),o.onended=()=>{at(this,fe,"stopped"),f.disconnect(),m.disconnect(),d==null||d.disconnect(),o.disconnect();for(const b of W(this,Ue))b();at(this,Ue,[])}}stop(t){if(W(this,fe)!=="playing")return;at(this,fe,"stopping");const n=t??W(this,Tn).currentTime;if(n<=W(this,Rn))W(this,He).stop(n);else{const e=n+W(this,On);W(this,Ae).gain.cancelScheduledValues(n),W(this,Ae).gain.setValueAtTime(1,n),W(this,Ae).gain.linearRampToValueAtTime(0,e),W(this,He).stop(e)}}onEnded(t){W(this,fe)==="stopped"?t():W(this,Ue).push(t)}get isActive(){return W(this,fe)!=="stopped"}};Tn=new WeakMap;He=new WeakMap;Ae=new WeakMap;Rn=new WeakMap;On=new WeakMap;fe=new WeakMap;Ue=new WeakMap;var ke,nn,rn,kr,Po,bh=class{constructor(){lt(this,kr),lt(this,ke,new Set),lt(this,nn,new Map),lt(this,rn,new Map)}add(t){W(this,ke).add(t),Js(W(this,nn),t.stopId).add(t),t.group!==void 0&&Js(W(this,rn),t.group).add(t),t.onEnded(()=>Un(this,kr,Po).call(this,t))}stopAll(t){for(const n of[...W(this,ke)])n.stop(t)}stopById(t,n){const e=W(this,nn).get(t);if(e)for(const s of[...e])s.stop(n)}stopGroup(t,n){const e=W(this,rn).get(t);if(e)for(const s of[...e])s.stop(n)}get activeCount(){return W(this,ke).size}};ke=new WeakMap;nn=new WeakMap;rn=new WeakMap;kr=new WeakSet;Po=function(t){var n,e;W(this,ke).delete(t),(n=W(this,nn).get(t.stopId))==null||n.delete(t),t.group!==void 0&&((e=W(this,rn).get(t.group))==null||e.delete(t))};function Js(t,n){let e=t.get(n);return e||(e=new Set,t.set(n,e)),e}function ti(t,n){return t&&n?e=>{t(e),n(e)}:t??n}var yh={samples:{baseUrl:"",formats:[]},groups:[]};function ei(t){return typeof t=="object"&&t!==null&&"groups"in t&&Array.isArray(t.groups)}var We,sn,on,un,Ce,an,zt,Ge,Me,$e,Ve,dn,fn,Gn,Bn,Co,Eo,vh=class{constructor(t,n,e){lt(this,Bn),lt(this,We,{loaded:0,total:0}),lt(this,sn,new Map),lt(this,on),lt(this,un),lt(this,Ce),lt(this,an),lt(this,zt),lt(this,Ge),lt(this,Me),lt(this,$e),lt(this,Ve),lt(this,dn),lt(this,fn),lt(this,Gn,new Map);var s,r,i;const a=ei(n)?n:void 0,o=ei(n)?e:n;this.context=t,at(this,on,a==null?void 0:a.defaults),at(this,un,(s=o==null?void 0:o.velocity)!=null?s:100),at(this,Ve,o==null?void 0:o.onLoadProgress),at(this,dn,o==null?void 0:o.onStart),at(this,fn,o==null?void 0:o.onEnded),a!=null&&a.aliases&&at(this,Ce,new Map(Object.entries(a.aliases))),at(this,Me,new th(t,{destination:o==null?void 0:o.destination,volume:o==null?void 0:o.volume,volumeToGain:o==null?void 0:o.volumeToGain})),at(this,Ge,(r=o==null?void 0:o.scheduler)!=null?r:new fh(t)),at(this,an,new Xs(a??yh)),at(this,zt,new bh),at(this,$e,(i=o==null?void 0:o.loader)!=null?i:new lh(t,{storage:o==null?void 0:o.storage})),a?this.load=W(this,$e).load(a,(l,d)=>{var m;at(this,We,{loaded:l,total:d}),(m=W(this,Ve))==null||m.call(this,{loaded:l,total:d})}).then(l=>(at(this,sn,l),this)):this.load=Promise.resolve(this)}loadInstrument(t,n){return at(this,on,t.defaults),at(this,Ce,t.aliases?new Map(Object.entries(t.aliases)):void 0),at(this,an,new Xs(t)),W(this,$e).load(t,{buffers:n,onProgress:(e,s)=>{var r;at(this,We,{loaded:e,total:s}),(r=W(this,Ve))==null||r.call(this,{loaded:e,total:s})}}).then(e=>{at(this,sn,e)})}get loadProgress(){return W(this,We)}get output(){return W(this,Me)}setCC(t,n){W(this,Gn).set(t,n)}start(t){const n=Un(this,Bn,Eo).call(this,t),e=W(this,Ge).schedule(n,s=>Un(this,Bn,Co).call(this,s));return s=>{e(),W(this,zt).stopById(n.stopId,s)}}stop(t){t===void 0?W(this,zt).stopAll():typeof t=="string"||typeof t=="number"?W(this,zt).stopById(t):t.stopId!==void 0?W(this,zt).stopById(t.stopId,t.time):W(this,zt).stopAll(t.time)}disconnect(){W(this,zt).stopAll(),W(this,Me).disconnect(),W(this,Ge).stop()}};We=new WeakMap;sn=new WeakMap;on=new WeakMap;un=new WeakMap;Ce=new WeakMap;an=new WeakMap;zt=new WeakMap;Ge=new WeakMap;Me=new WeakMap;$e=new WeakMap;Ve=new WeakMap;dn=new WeakMap;fn=new WeakMap;Gn=new WeakMap;Bn=new WeakSet;Co=function(t){const{midi:n,velocity:e,time:s,stopId:r,duration:i,detune:a,lpfCutoffHz:o,loop:l,ampRelease:d,onStart:m,onEnded:f}=t,p=W(this,an).match(n,e,W(this,Gn));for(const b of p)b.offBy!==void 0&&W(this,zt).stopGroup(b.offBy,s);let h=!1;for(const b of p){const g=W(this,sn).get(b.sample);if(!g)continue;const v=rh(W(this,on),b.groupRef,b.regionRef,n,e,{detune:a,lpfCutoffHz:o,loop:l,ampRelease:d}),y=new gh(this.context,g,v,W(this,Me).input,r,b.group,s);if(W(this,zt).add(y),h||(m==null||m(t),h=!0),f&&y.onEnded(()=>f(t)),i!=null){const S=(s??this.context.currentTime)+i,M=Math.max(0,(S-this.context.currentTime)*1e3);setTimeout(()=>y.stop(S),M)}}};Eo=function(t){var n,e,s,r,i,a,o,l;if(typeof t=="string"||typeof t=="number"){const m=(s=(e=hn(t))!=null?e:(n=W(this,Ce))==null?void 0:n.get(String(t)))!=null?s:0;return{note:t,midi:m,velocity:W(this,un),stopId:t,onStart:W(this,dn),onEnded:W(this,fn)}}const d=(a=(i=hn(t.note))!=null?i:(r=W(this,Ce))==null?void 0:r.get(String(t.note)))!=null?a:0;return Qc(Fe({},t),{midi:d,velocity:(o=t.velocity)!=null?o:W(this,un),stopId:(l=t.stopId)!=null?l:t.note,onStart:ti(W(this,dn),t.onStart),onEnded:ti(W(this,fn),t.onEnded)})};function Io(t){if(t.length===0)return[];const n=[...t].sort(([e],[s])=>e-s);return n.map(([e,s],r)=>{const i=r===0?0:Math.floor((n[r-1][0]+e)/2)+1,a=r===n.length-1?127:Math.floor((e+n[r+1][0])/2);return{keyRange:[i,a],pitch:e,sample:s}})}function _h(t,n){var e;const s=(e=ko(["ogg","mp3"]))!=null?e:"mp3";return console.debug(`Soundfont: using ${s} format for ${t}`),`https://gleitz.github.io/midi-js-soundfonts/${n}/${t}-${s}.js`}var wh=["MusyngKite","FluidR3_GM"],ni=wh[0];function xh(t,n){if(!t.startsWith("http"))return`https://goldst.dev/midi-js-soundfonts/${n}/${t}-loop.json`}function Ah(t,n=44100){return le(this,null,function*(){if(t)try{const e=yield fetch(t);if(e.status!==200)return;const s=yield e.json(),r={};return Object.keys(s).forEach(i=>{const a=hn(i);if(a){const o=s[i];r[a]=[o[0]/n,o[1]/n]}}),r}catch{return}})}var Zt,jn,No=class{constructor(t,n){this.context=t,lt(this,Zt),lt(this,jn,!1),this.config=Mh(n);const e={destination:n.destination,volume:n.volume,velocity:n.velocity,storage:this.config.storage,onLoadProgress:n.onLoadProgress};at(this,Zt,new vh(t,e));const s=t.createGain();s.gain.value=this.config.extraGain,W(this,Zt).output.addInsert(s),this.load=Sh(t,this.config).then(({buffers:r,noteNames:i,loopData:a})=>(at(this,jn,!!a),W(this,Zt).loadInstrument(To(i,a),r))).then(()=>this)}get hasLoops(){return W(this,jn)}get output(){return W(this,Zt).output}loaded(){return le(this,null,function*(){return console.warn("deprecated: use load instead"),this.load})}disconnect(){return W(this,Zt).disconnect()}start(t){return W(this,Zt).start(typeof t=="object"?t:{note:t})}stop(t){return W(this,Zt).stop(t===void 0?void 0:t)}};Zt=new WeakMap;jn=new WeakMap;function Sh(t,n){return le(this,null,function*(){const[{buffers:e,noteNames:s},r]=yield Promise.all([kh(t,n),Ah(n.loopDataUrl)]);return{buffers:e,noteNames:s,loopData:r}})}function kh(t,n){return le(this,null,function*(){const e=yield(yield n.storage.fetch(n.instrumentUrl)).text(),s=Ph(e),r=Object.keys(s),i=new Map;return yield Promise.all(r.map(a=>le(this,null,function*(){if(hn(a))try{const l=Eh(Ch(s[a])),d=yield t.decodeAudioData(l);i.set(a,d)}catch(l){console.warn(`Soundfont: failed to decode note ${a}`,l instanceof Error?l.message:l)}}))),{buffers:i,noteNames:[...i.keys()]}})}function To(t,n){const e=[];for(const i of t){const a=hn(i);a!==void 0&&e.push([a,i])}const r=Io(e).map(({keyRange:i,pitch:a,sample:o})=>{const l={sample:o,keyRange:i,pitch:a};if(n){const d=n[a];d&&(l.loop=!0,l.loopStart=d[0],l.loopEnd=d[1])}return l});return{samples:{baseUrl:"",formats:["ogg"]},groups:[{regions:r}]}}function Mh(t){var n,e,s,r,i;if(!t.instrument&&!t.instrumentUrl)throw Error("Soundfont: instrument or instrumentUrl is required");const a={kit:(n=t.kit)!=null?n:ni,instrument:t.instrument,storage:(e=t.storage)!=null?e:Ur,extraGain:(s=t.extraGain)!=null?s:5,loadLoopData:(r=t.loadLoopData)!=null?r:!1,loopDataUrl:t.loopDataUrl,instrumentUrl:(i=t.instrumentUrl)!=null?i:""};if(a.instrument&&a.instrument.startsWith("http")&&(console.warn("Use 'instrumentUrl' instead of 'instrument' to load from a URL"),a.instrumentUrl=a.instrument,a.instrument=void 0),a.instrumentUrl)(a.kit!==ni||a.instrument)&&console.warn("Soundfont: 'kit' and 'instrument' config parameters are ignored because 'instrumentUrl' is explicitly set.");else if(a.instrument)a.instrumentUrl=_h(a.instrument,a.kit);else throw Error("Soundfont: 'instrument' or 'instrumentUrl' configuration parameter is required");return a.loadLoopData&&a.instrument&&!a.loopDataUrl&&(a.loopDataUrl=xh(a.instrument,a.kit)),a}function Ph(t){const n=t.indexOf("MIDI.Soundfont.");if(n<0)throw Error("Invalid MIDI.js Soundfont format");const e=t.indexOf("=",n)+2,s=t.lastIndexOf(",");return JSON.parse(t.slice(e,s)+"}")}function Ch(t){return t.slice(t.indexOf(",")+1)}function Eh(t){const n=window.atob(t),e=n.length,s=new Uint8Array(e);for(let r=0;r<e;r++)s[r]=n.charCodeAt(r);return s.buffer}const Ih=Object.freeze(Object.defineProperty({__proto__:null,HttpStorage:Ur,Soundfont:No,soundfontToSmplrJson:To,spreadKeyRanges:Io},Symbol.toStringTag,{value:"Module"})),ri=44100;async function Nh(t,n,e=4,s=2.5,r=120){const i=Pe(t,e),a=n==="arpeggio"?s+i.length*r/1e3:s,o=new OfflineAudioContext(2,Math.ceil(ri*a),ri),l=new No(o,{instrument:"acoustic_grand_piano"});await l.load;for(let d=0;d<i.length;d++){const m=n==="arpeggio"?d*r/1e3:0;l.start({note:i[d],time:m,duration:s})}return o.startRendering()}function Th(t){const n=t.numberOfChannels,e=t.sampleRate,s=16,r=s/8,i=t.length,a=i*n*r,o=44+a,l=new ArrayBuffer(o),d=new DataView(l);Sn(d,0,"RIFF"),d.setUint32(4,o-8,!0),Sn(d,8,"WAVE"),Sn(d,12,"fmt "),d.setUint32(16,16,!0),d.setUint16(20,1,!0),d.setUint16(22,n,!0),d.setUint32(24,e,!0),d.setUint32(28,e*n*r,!0),d.setUint16(32,n*r,!0),d.setUint16(34,s,!0),Sn(d,36,"data"),d.setUint32(40,a,!0);const m=Array.from({length:n},(p,h)=>t.getChannelData(h));let f=44;for(let p=0;p<i;p++)for(let h=0;h<n;h++){const b=Math.max(-1,Math.min(1,m[h][p]));d.setInt16(f,b<0?b*32768:b*32767,!0),f+=2}return new Uint8Array(l)}function Sn(t,n,e){for(let s=0;s<e.length;s++)t.setUint8(n+s,e.charCodeAt(s))}async function si(t,n,e){const s=await Nh(t,n,e);return Th(s)}function Ro(t){return t.replace(/[^a-zA-Z0-9\-_ ]/g,"_").slice(0,80)}function Rh(t){const{clone:n}=Jn(t),e=new XMLSerializer().serializeToString(n);return new TextEncoder().encode(e)}function Oh(t,n=2){return new Promise((e,s)=>{const{clone:r}=Jn(t),i=r.viewBox.baseVal,a=i.width,o=i.height;r.setAttribute("width",String(a)),r.setAttribute("height",String(o));const l=new XMLSerializer().serializeToString(r),d=new Blob([l],{type:"image/svg+xml;charset=utf-8"}),m=URL.createObjectURL(d),f=new Image;f.onload=()=>{const p=document.createElement("canvas");p.width=a*n,p.height=o*n;const h=p.getContext("2d");if(!h){URL.revokeObjectURL(m),s(new Error("No canvas context"));return}h.scale(n,n),h.drawImage(f,0,0,a,o),URL.revokeObjectURL(m),p.toBlob(b=>{if(!b){s(new Error("toBlob failed"));return}b.arrayBuffer().then(g=>e(new Uint8Array(g)))},"image/png")},f.onerror=()=>{URL.revokeObjectURL(m),s(new Error("SVG load failed"))},f.src=m})}async function Oo(t,n,e){const s=Ro(e);if(n.svgElement){t.file(`${s}.svg`,Rh(n.svgElement));try{const i=await Oh(n.svgElement);t.file(`${s}.png`,i)}catch{}}const r=Xn({notes:n.notes});t.file(`${s}.mid`,r);try{const i=await si(n.notes,"block");t.file(`${s}_chord.wav`,i)}catch{}try{const i=await si(n.notes,"arpeggio");t.file(`${s}_arpeggio.wav`,i)}catch{}}async function Bh(t,n){const e=new wo;return await Oo(e,n,t),e.generateAsync({type:"blob"})}async function jh(t,n){const e=new wo;for(let s=0;s<n.length;s++){const i=`${String.fromCharCode(65+s)}_${Ro(n[s].label)}`,a=e.folder(i);await Oo(a,n[s],t)}return e.generateAsync({type:"blob"})}function ii(t,n){const e=URL.createObjectURL(t),s=document.createElement("a");s.href=e,s.download=n,s.click(),setTimeout(()=>URL.revokeObjectURL(e),1e3)}const zh="ABCDEFGHIJKLMNOPQRSTUVWXYZ";function Fh({chord:t,format:n,theme:e,highlightColor:s,scale:r,display:i,uiTheme:a,onExportStatus:o,onVariation:l,renderVariationExtras:d,chordIndex:m}){var k;const[f,p]=ft.useState(0),[h,b]=ft.useState(3),[g,v]=ft.useState(!1),y=ft.useRef(null),_=ft.useMemo(()=>{try{const I=Vn(t);if(I.isScale||!I.chordName)return null;const u=mn(I.chordName,I.inversion);let j=u.notes;if(I.startingNote){const G=Ee[I.startingNote]??I.startingNote,st=j.indexOf(G);st>0&&(j=[...j.slice(st),...j.slice(0,st)])}const X=qn(u.type,j);return{parsed:I,root:u.root,quality:X,notes:j,type:u.type,styleHint:I.styleHint}}catch{return null}},[t]),S=ft.useMemo(()=>_?sc(_.root,_.quality,_.notes,h,{styleHint:_.styleHint}):[],[_,h]),M=_?`${_.root}:${_.notes.join(",")}`:t,[w,T]=ft.useState(M);if(M!==w&&(T(M),p(0),b(3)),!_||S.length<=1)return N.jsx(Hn,{chord:t,format:n,theme:e,highlightColor:s,scale:r,display:i,uiTheme:a,onVariation:l,renderVariationExtras:d,voicingId:"default",chordIndex:m??0});const P=S[Math.min(f,S.length-1)],z=ft.useMemo(()=>{if(!_)return"";const I=[],u=_.parsed;return u.showNoteNames&&(u.noteNameMode==="midi"?I.push("midi note names"):I.push("note names"),u.noteNameSize&&u.noteNameSize!=="base"&&I.push(`in ${u.noteNameSize}`)),u.customFingering?I.push(`custom fingering "${u.customFingering.join(",")}"`):u.autoFingering?I.push("with fingering"):u.fingering&&I.push(`fingering ${u.fingering.join("-")}`),u.fingeringSize&&u.fingeringSize!=="base"&&I.push(`fingering in ${u.fingeringSize}`),u.colorTheme&&I.push(u.colorTheme),u.scale!=null&&I.push(`size ${Math.round(u.scale*100)}`),u.showHeading&&I.push("heading"),I.length>0?" "+I.join(" "):""},[_]);let E=t;if(f>0){const I=_.parsed.chordName??t;P.source==="inversion"?E=`${I} starting on ${P.notes[0]}${z}`:P.source==="library"?E=`${I} ${P.label} style${z}`:E=`${I}${z}`}const L=ft.useCallback(()=>{var I;return((I=y.current)==null?void 0:I.querySelector("svg"))??null},[]),V=ft.useCallback(async I=>{v(!1),o==null||o("preparing");try{const u=(_==null?void 0:_.parsed.chordName)??"chord";if(I==="this"){const j=L(),X={label:P.label,notes:P.notes,svgElement:j},G=await Bh(u,X);ii(G,`${u.replace(/[^a-zA-Z0-9]/g,"_")}.zip`)}else{const j=S.map((G,st)=>({label:G.label,notes:G.notes,svgElement:st===f?L():null})),X=await jh(u,j);ii(X,`${u.replace(/[^a-zA-Z0-9]/g,"_")}_all.zip`)}}catch(u){console.error("ZIP export failed:",u)}finally{o==null||o("idle")}},[_,P,f,S,L,o]);return N.jsxs("div",{className:"voicing-variant-toggle",style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"0.75rem"},children:[N.jsx("div",{className:"voicing-output-wrapper",ref:y,style:{width:"100%",overflowX:"auto",display:"flex",justifyContent:"center"},children:N.jsx(Hn,{chord:E,format:n,theme:e,highlightColor:s,scale:r,display:i,uiTheme:a,onVariation:l,renderVariationExtras:d,voicingId:((k=S[f])==null?void 0:k.label)??"default",chordIndex:m??0})}),N.jsxs("div",{className:"variant-toggle-row",style:{display:"flex",alignItems:"flex-start",gap:6,justifyContent:"center"},children:[S.map((I,u)=>N.jsxs("button",{className:"variant-pill","data-active":u===f,onClick:()=>p(u),style:{display:"flex",flexDirection:"column",alignItems:"center",gap:3,padding:"12px 22px 10px",border:u===f?"1px solid transparent":"1px solid var(--btn-border)",borderRadius:10,background:u===f?"var(--pill-active-bg)":"var(--pill-bg)",color:u===f?"var(--pill-active-text)":"var(--text-muted)",boxShadow:u===f?"0 1px 6px var(--pill-active-shadow)":"none",cursor:"pointer",fontFamily:"inherit",fontSize:"1.2rem",fontWeight:u===f?600:500,transition:"all 0.2s ease",minWidth:64},children:[N.jsx("span",{children:zh[u]}),N.jsx("span",{className:"variant-pill-label",style:{fontSize:"0.78rem",fontWeight:400,color:"var(--text-dim)",whiteSpace:"nowrap",maxWidth:80,overflow:"hidden",textOverflow:"ellipsis"},children:I.label})]},I.id)),S.length>=h&&N.jsx("button",{className:"variant-pill-add",onClick:()=>b(I=>I+3),style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px 16px",border:"1px dashed var(--btn-border)",borderRadius:10,background:"transparent",color:"var(--text-muted)",cursor:"pointer",fontFamily:"inherit",fontSize:"1.2rem",fontWeight:400,transition:"all 0.2s ease",minWidth:52,height:52},title:"Generate more voicing options",children:"+"}),N.jsxs("div",{className:"zip-export-container",style:{position:"relative"},children:[N.jsxs("button",{className:"variant-pill-zip",onClick:()=>v(I=>!I),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,padding:"12px 16px",border:"1px solid var(--btn-border)",borderRadius:10,background:"var(--pill-bg)",color:"var(--text-muted)",cursor:"pointer",fontFamily:"inherit",fontSize:"0.78rem",fontWeight:500,transition:"all 0.2s ease",height:52,whiteSpace:"nowrap"},title:"Download .zip package",children:[N.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:N.jsx("path",{d:"M3.5 0A1.5 1.5 0 002 1.5v13A1.5 1.5 0 003.5 16h9a1.5 1.5 0 001.5-1.5V4.707A1.5 1.5 0 0013.56 3.65L10.354.44A1.5 1.5 0 009.293 0H3.5zM7 3v1h2V3H7zm0 2v1h2V5H7zm0 2v1h2V7H7zm0 2h2v2H7V9z"})}),".zip"]}),g&&N.jsxs("div",{className:"zip-menu",style:{position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",marginTop:6,display:"flex",gap:4,padding:4,background:"var(--pill-active-bg)",border:"1px solid var(--btn-border)",borderRadius:10,boxShadow:"0 4px 16px var(--glass-shadow)",zIndex:10},children:[N.jsx("button",{className:"zip-menu-btn",onClick:()=>V("this"),style:{padding:"8px 16px",border:"none",borderRadius:8,background:"transparent",color:"var(--text)",cursor:"pointer",fontFamily:"inherit",fontSize:"0.8rem",fontWeight:500,whiteSpace:"nowrap",transition:"background 0.15s ease"},children:"This"}),N.jsx("button",{className:"zip-menu-btn",onClick:()=>V("all"),style:{padding:"8px 16px",border:"none",borderRadius:8,background:"transparent",color:"var(--text)",cursor:"pointer",fontFamily:"inherit",fontSize:"0.8rem",fontWeight:500,whiteSpace:"nowrap",transition:"background 0.15s ease"},children:"All"})]})]})]})]})}const Dh=[{label:"50%",value:.5},{label:"60%",value:.6},{label:"70%",value:.7},{label:"80%",value:.8},{label:"90%",value:.9},{label:"100%",value:1}];function Lh({result:t,format:n,theme:e,highlightColor:s,showPlayback:r=!0,defaultGroupMode:i="by-progression",uiTheme:a,onVariation:o,renderVariationExtras:l}){const d=gn(a),m=d.tokens,[f,p]=ft.useState(i),[h,b]=ft.useState("compact"),[g,v]=ft.useState("keyboard"),[y,_]=ft.useState(.5),[S,M]=ft.useState("off"),[w,T]=ft.useState(!1),P={display:"inline-flex",background:m.btnBg,borderRadius:10,padding:3,gap:2},z=E=>({fontFamily:"inherit",fontSize:"0.8rem",fontWeight:E?600:500,padding:"6px 14px",border:"none",borderRadius:8,background:E?m.btnBgActive:"transparent",color:E?m.btnTextActive:m.btnText,cursor:"pointer",transition:"all 0.2s ease",whiteSpace:"nowrap",letterSpacing:"0.01em",boxShadow:E?"0 1px 4px rgba(0,0,0,0.15)":"none"});return N.jsx(Bt,{value:d,children:N.jsxs("div",{className:"bc-progression","data-bc-theme":d.mode,style:{width:"100%",maxWidth:"100vw",color:m.text},children:[N.jsxs("div",{className:"bc-progression__controls",style:{display:"flex",flexDirection:"column",alignItems:"center",gap:8,marginBottom:16},children:[N.jsxs("span",{className:"bc-progression__title",style:{fontWeight:700,fontSize:16},children:[t.progressionName," in ",t.key]}),N.jsxs("div",{className:"bc-progression__controls-row",style:{display:"flex",gap:"0.75rem",alignItems:"center",flexWrap:"wrap",justifyContent:"center"},children:[N.jsxs("div",{className:"bc-progression__group-toggle",style:P,children:[N.jsx("button",{className:"bc-progression__btn",style:z(f==="by-progression"),onClick:()=>p("by-progression"),children:"By Progression"}),N.jsx("button",{className:"bc-progression__btn",style:z(f==="by-chord"),onClick:()=>p("by-chord"),children:"By Chord"})]}),N.jsxs("div",{className:"bc-progression__format-toggle",style:P,children:[N.jsx("button",{className:"bc-progression__btn",style:z(h==="compact"),onClick:()=>b("compact"),children:"Compact"}),N.jsx("button",{className:"bc-progression__btn",style:z(h==="exact"),onClick:()=>b("exact"),children:"Full"})]}),N.jsx("div",{className:"bc-progression__display-toggle",style:P,children:["keyboard","staff","both"].map(E=>N.jsx("button",{className:"bc-progression__btn",style:z(g===E),onClick:()=>v(E),children:E==="keyboard"?"Keyboard":E==="staff"?"Staff":"Both"},E))}),N.jsx("div",{className:"bc-progression__scale-toggle",style:P,children:Dh.map(E=>N.jsx("button",{className:"bc-progression__btn",style:z(y===E.value),onClick:()=>_(E.value),children:E.label},E.value))}),N.jsxs("div",{className:"bc-progression__names-toggle",style:P,children:[N.jsx("button",{className:"bc-progression__btn",style:z(S==="off"),onClick:()=>M("off"),children:"Names Off"}),N.jsx("button",{className:"bc-progression__btn",style:z(S==="notes"),onClick:()=>M("notes"),children:"Notes"}),N.jsx("button",{className:"bc-progression__btn",style:z(S==="midi"),onClick:()=>M("midi"),children:"MIDI"})]}),N.jsxs("div",{className:"bc-progression__fingering-toggle",style:P,children:[N.jsx("button",{className:"bc-progression__btn",style:z(!w),onClick:()=>T(!1),children:"No Fingering"}),N.jsx("button",{className:"bc-progression__btn",style:z(w),onClick:()=>T(!0),children:"Fingering"})]})]})]}),f==="by-progression"?t.examples.map((E,L)=>N.jsx(tr,{chords:E.chords,label:E.label,format:n??h,theme:e,highlightColor:s,showPlayback:r,scale:y,display:g,showNoteNames:S!=="off",noteNameMode:S==="midi"?"midi":"pitch-class",showFingering:w,onVariation:o,renderVariationExtras:l},L)):Hh(t,n??h,e,s,r,y,g,S,w,o,l)]})})}function Hh(t,n,e,s,r,i,a,o,l,d,m){if(t.examples.length===0)return null;const f=t.examples[0].chords.length,p=[];for(let h=0;h<f;h++){const b=t.examples[0].chords[h].symbol,g=t.examples.map(v=>({chord:v.chords[h],style:v.label}));p.push({symbol:b,chords:g})}return p.map((h,b)=>N.jsx(tr,{chords:h.chords.map(g=>g.chord),label:`${h.symbol} — ${h.chords.length} voicings`,format:n,theme:e,highlightColor:s,showPlayback:r,scale:i,display:a,showNoteNames:o!=="off",noteNameMode:o==="midi"?"midi":"pitch-class",showFingering:l,onVariation:d,renderVariationExtras:m},b))}function Uh(t){return t<=1?1:t<=2||t<=3?2:4}class Wh extends ft.Component{constructor(){super(...arguments),this.state={error:null}}static getDerivedStateFromError(n){return{error:n.message}}render(){return this.state.error?N.jsxs("div",{className:"bc-chord-sheet__chord-error",style:{padding:"8px 12px",fontSize:"0.75rem",color:"#c0392b",textAlign:"center"},children:[this.props.chordRef,": ",this.state.error]}):this.props.children}}function Gh({data:t,printMode:n,uiTheme:e,className:s,style:r,onVariation:i,renderVariationExtras:a}){const o=t.sections.length,l=N.jsxs("div",{className:`bc-chord-sheet${s?` ${s}`:""}`,style:r,children:[t.heading&&N.jsx("h2",{className:"bc-chord-sheet__heading",style:{margin:"0 0 4px",fontSize:"1.3rem",fontWeight:600},children:t.heading}),t.subheading&&N.jsx("p",{className:"bc-chord-sheet__subheading",style:{margin:"0 0 16px",fontSize:"0.85rem",opacity:.7},children:t.subheading}),t.sections.map((m,f)=>N.jsx($h,{section:m,sectionIndex:f,sectionCount:o,sheetDefaults:t.defaults,printMode:n,uiTheme:e,onVariation:i,renderVariationExtras:a},m.id??f))]});if(!e)return l;const d=gn(e);return N.jsx(Bt,{value:d,children:l})}function $h({section:t,sectionIndex:n,sectionCount:e,sheetDefaults:s,printMode:r,uiTheme:i,onVariation:a,renderVariationExtras:o}){const l=Uh(t.chords.length);return N.jsxs("section",{className:"bc-chord-sheet__section",style:{marginBottom:24},children:[t.heading&&N.jsx("h3",{className:"bc-chord-sheet__section-heading",style:{margin:"0 0 2px",fontSize:"1rem",fontWeight:600},children:t.heading}),t.subheading&&N.jsx("p",{className:"bc-chord-sheet__section-subheading",style:{margin:"0 0 8px",fontSize:"0.8rem",opacity:.65},children:t.subheading}),t.textAbove&&N.jsx("div",{className:"bc-chord-sheet__text--above",style:{marginBottom:8,fontSize:"0.85rem",whiteSpace:"pre-wrap"},children:t.textAbove}),N.jsx("div",{className:"bc-chord-sheet__grid",style:{display:"flex",flexWrap:"wrap",gap:12,alignItems:"flex-start"},children:t.chords.map((d,m)=>{const f=ro(n,m,e,t.id),p=no(s,t.defaults,d);return N.jsxs("div",{className:"bc-chord-sheet__chord",style:{textAlign:"center",flex:`0 1 calc(${100/l}% - ${(l-1)*12/l}px)`,minWidth:0},children:[!r&&N.jsx("span",{className:"bc-chord-sheet__chord-ref",style:{display:"inline-block",fontSize:"0.65rem",fontWeight:500,opacity:.45,marginBottom:2},children:f}),d.chordHeading&&N.jsx("div",{className:"bc-chord-sheet__chord-heading",style:{fontSize:"0.85rem",fontWeight:600,marginBottom:2},children:d.chordHeading}),N.jsx(Wh,{chordRef:f,children:N.jsx(Vh,{chord:d,resolved:p,uiTheme:i,chordIndex:m,onVariation:a,renderVariationExtras:o})}),d.annotationText&&N.jsx("div",{className:"bc-chord-sheet__annotation",style:{fontSize:"0.75rem",opacity:.6,marginTop:2,whiteSpace:"pre-wrap"},children:d.annotationText})]},m)})}),t.textBelow&&N.jsx("div",{className:"bc-chord-sheet__text--below",style:{marginTop:8,fontSize:"0.85rem",whiteSpace:"pre-wrap"},children:t.textBelow})]})}function Vh({chord:t,resolved:n,uiTheme:e,chordIndex:s,onVariation:r,renderVariationExtras:i}){return N.jsx(Hn,{chord:t.chord,format:n.format,theme:n.theme,highlightColor:n.highlightColor,padding:n.padding,scale:n.scale,display:n.display,uiTheme:e,onVariation:r,renderVariationExtras:i,chordIndex:s,voicingId:"default"})}exports.ARPEGGIO_BPM=ao;exports.BLACK_KEY_HEIGHT_COMPACT=ai;exports.BLACK_KEY_HEIGHT_EXACT=li;exports.BLACK_KEY_OFFSETS=hi;exports.BLACK_KEY_OFFSETS_EXACT=ui;exports.BLACK_KEY_RY=zn;exports.BLACK_KEY_WIDTH=Er;exports.BLACK_KEY_WIDTH_EXACT=oi;exports.BRAVURA_GLYPHS=wi;exports.CHORD_SHEET_SCHEMA_VERSION=Fn;exports.ChordGroup=tr;exports.ChordSheet=Gh;exports.DARK_THEME=ho;exports.DEFAULT_BLACK_FILL=ae;exports.DEFAULT_STROKE=ci;exports.DEFAULT_STROKE_WIDTH=Ye;exports.DEFAULT_UI_THEME=Dn;exports.DEFAULT_WHITE_FILL=oe;exports.ENABLE_CHORD_LOGGING=Aa;exports.FLAT_TO_SHARP=Ee;exports.FORM_TEMPLATES=Pn;exports.LIGHT_THEME=co;exports.LOG_SCHEMA_VERSION=Qi;exports.MAX_EXAMPLES=ge;exports.PETALUMA_GLYPHS=ca;exports.PianoChord=Hn;exports.PianoKeyboard=me;exports.ProgressionView=Lh;exports.SHOW_NOTE_NAMES=oo;exports.SYSTEM_DEFAULTS=eo;exports.StaffNotation=Ln;exports.UIThemeProvider=Bt;exports.VOICING_LIBRARY=Zn;exports.VoicingVariantToggle=Fh;exports.WHITE_KEY_HEIGHT_COMPACT=Pr;exports.WHITE_KEY_HEIGHT_EXACT=Cr;exports.WHITE_KEY_RY=re;exports.WHITE_KEY_WIDTH=pe;exports.WHITE_KEY_WIDTH_EXACT=Mr;exports.WHITE_NOTES_WITH_SHARPS=di;exports.WHITE_NOTE_ORDER=gt;exports.arpeggioDelayMs=lo;exports.autoFingering=cn;exports.autoSelectVoicing=Ql;exports.calculateLayout=Kn;exports.chordRef=ro;exports.computeKeyboard=ln;exports.computeStaffLayout=vi;exports.computeSvgDimensions=Ir;exports.decodeChordSheet=Ac;exports.downloadMidi=qi;exports.downloadPng=bo;exports.downloadSvg=go;exports.encodeChordSheet=xc;exports.findTemplate=Vi;exports.findVoicing=Qn;exports.generateLockedHands=Xl;exports.generateMidiFile=Xn;exports.getAlternativeVoicings=ql;exports.getDefaultGlyphs=Ai;exports.getTheme=vc;exports.getUIThemeTokens=Dr;exports.inferStyle=zr;exports.isProgressionRequest=Pa;exports.logChordRequest=Xi;exports.mapHighlights=Nr;exports.mapToVoicingQuality=qn;exports.normalizeNote=At;exports.parseChordDescription=Vn;exports.parseProgressionRequest=Ca;exports.playArpeggiated=mo;exports.playBlock=fo;exports.processChordRequest=wc;exports.queryVoicings=ie;exports.realizeVoicing=Zl;exports.realizeVoicingFull=Fr;exports.resolveChord=mn;exports.resolveDefaults=no;exports.resolveProgression=Gi;exports.resolveProgressionRequest=ac;exports.resolveTheme=to;exports.resolveUITheme=gn;exports.selectByRange=Ki;exports.setDefaultGlyphs=ha;exports.solvePolychord=ec;exports.solveSlashChord=nc;exports.tokenizeProgression=$i;exports.useUITheme=pn;exports.validateVersion=so;exports.voicingPitchClasses=Re;