@scorelabs/viewer 1.0.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.
Files changed (83) hide show
  1. package/README.md +5 -0
  2. package/dist/android-chrome-192x192.png +0 -0
  3. package/dist/android-chrome-512x512.png +0 -0
  4. package/dist/apple-touch-icon.png +0 -0
  5. package/dist/audio/AudioPlayer.d.ts +54 -0
  6. package/dist/favicon-16x16.png +0 -0
  7. package/dist/favicon-32x32.png +0 -0
  8. package/dist/favicon-96x96.png +0 -0
  9. package/dist/favicon.ico +0 -0
  10. package/dist/favicon.svg +1 -0
  11. package/dist/importers/MusicXMLParser.d.ts +51 -0
  12. package/dist/importers/index.d.ts +6 -0
  13. package/dist/index.d.ts +2 -0
  14. package/dist/layouts/LayoutConfig.d.ts +62 -0
  15. package/dist/layouts/LayoutUtils.d.ts +10 -0
  16. package/dist/layouts/MeasureLayout.d.ts +20 -0
  17. package/dist/layouts/NoteLayout.d.ts +21 -0
  18. package/dist/layouts/ScoreLayout.d.ts +28 -0
  19. package/dist/layouts/StaffLayout.d.ts +26 -0
  20. package/dist/layouts/StaffSystemLayout.d.ts +18 -0
  21. package/dist/layouts/index.d.ts +6 -0
  22. package/dist/models/Instrument.d.ts +26 -0
  23. package/dist/models/Measure.d.ts +80 -0
  24. package/dist/models/Note.d.ts +122 -0
  25. package/dist/models/Part.d.ts +60 -0
  26. package/dist/models/Pitch.d.ts +45 -0
  27. package/dist/models/Score.d.ts +120 -0
  28. package/dist/models/Staff.d.ts +57 -0
  29. package/dist/models/__tests__/Note.test.d.ts +1 -0
  30. package/dist/models/__tests__/Pitch.test.d.ts +1 -0
  31. package/dist/models/index.d.ts +7 -0
  32. package/dist/models/types.d.ts +163 -0
  33. package/dist/new_score.json +112 -0
  34. package/dist/rendering/NoteRenderer.d.ts +52 -0
  35. package/dist/rendering/ScoreRenderer.d.ts +35 -0
  36. package/dist/rendering/StaffRenderer.d.ts +67 -0
  37. package/dist/rendering/glyphs/AccidentalGlyphs.d.ts +5 -0
  38. package/dist/rendering/glyphs/ClefGlyphs.d.ts +19 -0
  39. package/dist/rendering/glyphs/DecorationGlyphs.d.ts +11 -0
  40. package/dist/rendering/glyphs/NoteGlyphs.d.ts +19 -0
  41. package/dist/rendering/glyphs/RestGlyphs.d.ts +11 -0
  42. package/dist/rendering/glyphs/SignatureGlyphs.d.ts +11 -0
  43. package/dist/rendering/glyphs/index.d.ts +6 -0
  44. package/dist/rendering/index.d.ts +4 -0
  45. package/dist/satb.xml +4 -0
  46. package/dist/score-viewer.js +13234 -0
  47. package/dist/score-viewer.umd.cjs +145 -0
  48. package/dist/scores/canon_pachelbel.xml +4 -0
  49. package/dist/scores/el_cant_dels_ocells.xml +112 -0
  50. package/dist/scores/el_noi_de_la_mare.xml +102 -0
  51. package/dist/scores/els_segadors.xml +110 -0
  52. package/dist/scores/imported/forest.xml +161 -0
  53. package/dist/showcase.json +292 -0
  54. package/dist/site.webmanifest +21 -0
  55. package/dist/src/App.d.ts +1 -0
  56. package/dist/src/components/AboutDialog.d.ts +6 -0
  57. package/dist/src/components/ChordDialog.d.ts +8 -0
  58. package/dist/src/components/ClefDialog.d.ts +9 -0
  59. package/dist/src/components/FloatingToolbar.d.ts +26 -0
  60. package/dist/src/components/InstrumentsDialog.d.ts +22 -0
  61. package/dist/src/components/KeySignatureDialog.d.ts +9 -0
  62. package/dist/src/components/Logo.d.ts +6 -0
  63. package/dist/src/components/MenuBar.d.ts +20 -0
  64. package/dist/src/components/NoteInputToolbar.d.ts +101 -0
  65. package/dist/src/components/PageSetupDialog.d.ts +9 -0
  66. package/dist/src/components/ScoreCanvas.d.ts +49 -0
  67. package/dist/src/components/ScoreInfoDialog.d.ts +19 -0
  68. package/dist/src/components/ScoreLayoutDialog.d.ts +9 -0
  69. package/dist/src/components/TempoDialog.d.ts +11 -0
  70. package/dist/src/components/TextDialog.d.ts +10 -0
  71. package/dist/src/components/TimeSignatureDialog.d.ts +9 -0
  72. package/dist/src/components/TransposeDialog.d.ts +9 -0
  73. package/dist/src/components/VirtualKeyboard.d.ts +10 -0
  74. package/dist/src/exporters/MusicXMLExporter.d.ts +10 -0
  75. package/dist/src/hooks/useHistory.d.ts +14 -0
  76. package/dist/src/index.d.ts +24 -0
  77. package/dist/src/main.d.ts +1 -0
  78. package/dist/src/services/HarmonyService.d.ts +10 -0
  79. package/dist/src/services/VocalSynthesisService.d.ts +13 -0
  80. package/dist/src/utils/pdfToPng.d.ts +5 -0
  81. package/dist/web-app-manifest-192x192.png +0 -0
  82. package/dist/web-app-manifest-512x512.png +0 -0
  83. package/package.json +63 -0
@@ -0,0 +1,145 @@
1
+ (function(vt,K){typeof exports=="object"&&typeof module<"u"?K(exports,require("react"),require("@mui/material"),require("@mui/icons-material"),require("@emotion/styled"),require("@emotion/react"),require("@magenta/music"),require("tone")):typeof define=="function"&&define.amd?define(["exports","react","@mui/material","@mui/icons-material","@emotion/styled","@emotion/react","@magenta/music","tone"],K):(vt=typeof globalThis<"u"?globalThis:vt||self,K(vt.ScoreViewer={},vt.React,vt.MaterialUI,vt.MaterialUIIcons,vt.emotionStyled,vt.emotionReact,vt.magenta,vt.Tone))})(this,function(vt,K,u,te,Or,$c,Nr,Rr){"use strict";var Nc=Object.defineProperty;var Rc=(vt,K,u)=>K in vt?Nc(vt,K,{enumerable:!0,configurable:!0,writable:!0,value:u}):vt[K]=u;var qt=(vt,K,u)=>Rc(vt,typeof K!="symbol"?K+"":K,u);function Ci(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const Ee=Ci(K),cn=Ci(Nr),Bt=Ci(Rr);function $r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ii={exports:{}},xs={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var hn;function Lr(){if(hn)return xs;hn=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function s(i,n,r){var a=null;if(r!==void 0&&(a=""+r),n.key!==void 0&&(a=""+n.key),"key"in n){r={};for(var l in n)l!=="key"&&(r[l]=n[l])}else r=n;return n=r.ref,{$$typeof:t,type:i,key:a,ref:n!==void 0?n:null,props:r}}return xs.Fragment=e,xs.jsx=s,xs.jsxs=s,xs}var ys={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var un;function Wr(){return un||(un=1,process.env.NODE_ENV!=="production"&&function(){function t(x){if(x==null)return null;if(typeof x=="function")return x.$$typeof===st?null:x.displayName||x.name||null;if(typeof x=="string")return x;switch(x){case k:return"Fragment";case Y:return"Profiler";case E:return"StrictMode";case q:return"Suspense";case it:return"SuspenseList";case dt:return"Activity"}if(typeof x=="object")switch(typeof x.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),x.$$typeof){case m:return"Portal";case O:return x.displayName||"Context";case R:return(x._context.displayName||"Context")+".Consumer";case M:var W=x.render;return x=x.displayName,x||(x=W.displayName||W.name||"",x=x!==""?"ForwardRef("+x+")":"ForwardRef"),x;case ot:return W=x.displayName||null,W!==null?W:t(x.type)||"Memo";case U:W=x._payload,x=x._init;try{return t(x(W))}catch{}}return null}function e(x){return""+x}function s(x){try{e(x);var W=!1}catch{W=!0}if(W){W=console;var z=W.error,Z=typeof Symbol=="function"&&Symbol.toStringTag&&x[Symbol.toStringTag]||x.constructor.name||"Object";return z.call(W,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",Z),e(x)}}function i(x){if(x===k)return"<>";if(typeof x=="object"&&x!==null&&x.$$typeof===U)return"<...>";try{var W=t(x);return W?"<"+W+">":"<...>"}catch{return"<...>"}}function n(){var x=g.A;return x===null?null:x.getOwner()}function r(){return Error("react-stack-top-frame")}function a(x){if(L.call(x,"key")){var W=Object.getOwnPropertyDescriptor(x,"key").get;if(W&&W.isReactWarning)return!1}return x.key!==void 0}function l(x,W){function z(){ct||(ct=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",W))}z.isReactWarning=!0,Object.defineProperty(x,"key",{get:z,configurable:!0})}function c(){var x=t(this.type);return bt[x]||(bt[x]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),x=this.props.ref,x!==void 0?x:null}function h(x,W,z,Z,yt,G){var lt=z.ref;return x={$$typeof:I,type:x,key:W,props:z,_owner:Z},(lt!==void 0?lt:null)!==null?Object.defineProperty(x,"ref",{enumerable:!1,get:c}):Object.defineProperty(x,"ref",{enumerable:!1,value:null}),x._store={},Object.defineProperty(x._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(x,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(x,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:yt}),Object.defineProperty(x,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:G}),Object.freeze&&(Object.freeze(x.props),Object.freeze(x)),x}function d(x,W,z,Z,yt,G){var lt=W.children;if(lt!==void 0)if(Z)if($(lt)){for(Z=0;Z<lt.length;Z++)p(lt[Z]);Object.freeze&&Object.freeze(lt)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else p(lt);if(L.call(W,"key")){lt=t(x);var xt=Object.keys(W).filter(function(pt){return pt!=="key"});Z=0<xt.length?"{key: someKey, "+xt.join(": ..., ")+": ...}":"{key: someKey}",_[lt+Z]||(xt=0<xt.length?"{"+xt.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
+ let props = %s;
19
+ <%s {...props} />
20
+ React keys must be passed directly to JSX without using spread:
21
+ let props = %s;
22
+ <%s key={someKey} {...props} />`,Z,lt,xt,lt),_[lt+Z]=!0)}if(lt=null,z!==void 0&&(s(z),lt=""+z),a(W)&&(s(W.key),lt=""+W.key),"key"in W){z={};for(var Ct in W)Ct!=="key"&&(z[Ct]=W[Ct])}else z=W;return lt&&l(z,typeof x=="function"?x.displayName||x.name||"Unknown":x),h(x,lt,z,n(),yt,G)}function p(x){y(x)?x._store&&(x._store.validated=1):typeof x=="object"&&x!==null&&x.$$typeof===U&&(x._payload.status==="fulfilled"?y(x._payload.value)&&x._payload.value._store&&(x._payload.value._store.validated=1):x._store&&(x._store.validated=1))}function y(x){return typeof x=="object"&&x!==null&&x.$$typeof===I}var S=K,I=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),Y=Symbol.for("react.profiler"),R=Symbol.for("react.consumer"),O=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),q=Symbol.for("react.suspense"),it=Symbol.for("react.suspense_list"),ot=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),dt=Symbol.for("react.activity"),st=Symbol.for("react.client.reference"),g=S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=Object.prototype.hasOwnProperty,$=Array.isArray,Q=console.createTask?console.createTask:function(){return null};S={react_stack_bottom_frame:function(x){return x()}};var ct,bt={},ht=S.react_stack_bottom_frame.bind(S,r)(),It=Q(i(r)),_={};ys.Fragment=k,ys.jsx=function(x,W,z){var Z=1e4>g.recentlyCreatedOwnerStacks++;return d(x,W,z,!1,Z?Error("react-stack-top-frame"):ht,Z?Q(i(x)):It)},ys.jsxs=function(x,W,z){var Z=1e4>g.recentlyCreatedOwnerStacks++;return d(x,W,z,!0,Z?Error("react-stack-top-frame"):ht,Z?Q(i(x)):It)}}()),ys}process.env.NODE_ENV==="production"?Ii.exports=Lr():Ii.exports=Wr();var o=Ii.exports,We=(t=>(t.Up="up",t.Down="down",t))(We||{}),ft=(t=>(t.Treble="treble",t.Bass="bass",t.Alto="alto",t.Tenor="tenor",t.Percussion="percussion",t.Tab="tab",t))(ft||{}),P=(t=>(t.Whole="whole",t.Half="half",t.Quarter="quarter",t.Eighth="eighth",t.Sixteenth="sixteenth",t.ThirtySecond="thirty-second",t.SixtyFourth="sixty-fourth",t.OneHundredTwentyEighth="one-hundred-twenty-eighth",t.TwoHundredFiftySixth="two-hundred-fifty-sixth",t))(P||{}),At=(t=>(t.Sharp="sharp",t.Flat="flat",t.Natural="natural",t.DoubleSharp="double-sharp",t.DoubleFlat="double-flat",t))(At||{}),xe=(t=>(t.Staccato="staccato",t.Accent="accent",t.Tenuto="tenuto",t.Marcato="marcato",t.Fermata="fermata",t.Staccatissimo="staccatissimo",t))(xe||{}),Ue=(t=>(t.DownBow="down-bow",t.UpBow="up-bow",t))(Ue||{}),se=(t=>(t.Normal="normal",t.Cross="cross",t.Diamond="diamond",t.Slash="slash",t.Triangle="triangle",t.Square="square",t))(se||{}),fn=(t=>(t.PPP="ppp",t.PP="pp",t.P="p",t.MP="mp",t.MF="mf",t.F="f",t.FF="ff",t.FFF="fff",t))(fn||{}),Xe=(t=>(t.Crescendo="crescendo",t.Decrescendo="decrescendo",t))(Xe||{}),ki=(t=>(t.Wavy="wavy",t.Straight="straight",t))(ki||{}),_e=(t=>(t.Normal="normal",t.Up="up",t.Down="down",t))(_e||{}),Fe=(t=>(t.OttavaAlta="8va",t.OttavaBassa="8vb",t.QuindicesimaAlta="15ma",t.QuindicesimaBassa="15mb",t))(Fe||{}),Be=(t=>(t.Trill="trill",t.Mordent="mordent",t.InvertedMordent="inverted-mordent",t.Turn="turn",t.InvertedTurn="inverted-turn",t))(Be||{});const Je={whole:4,half:2,quarter:1,eighth:.5,sixteenth:.25,"thirty-second":.125,"sixty-fourth":.0625,"one-hundred-twenty-eighth":.03125,"two-hundred-fifty-sixth":.015625};function Ze(t){const e=[];let s=t;const i=[{val:4,dur:"whole",dot:!1},{val:3,dur:"half",dot:!0},{val:2,dur:"half",dot:!1},{val:1.5,dur:"quarter",dot:!0},{val:1,dur:"quarter",dot:!1},{val:.75,dur:"eighth",dot:!0},{val:.5,dur:"eighth",dot:!1},{val:.375,dur:"sixteenth",dot:!0},{val:.25,dur:"sixteenth",dot:!1}];for(;s>.1;){const n=i.find(r=>r.val<=s+.001);if(n)e.push({duration:n.dur,isDotted:n.dot,val:n.val}),s-=n.val;else break}return e}class le{constructor(e,s,i,n){qt(this,"step");qt(this,"alter");qt(this,"octave");if(this.midiNumber=e,s!==void 0&&i!==void 0&&n!==void 0)this.step=s,this.alter=i,this.octave=n;else{this.octave=Math.floor(e/12)-1;const r=[0,0,1,1,2,3,3,4,4,5,5,6];this.step=r[e%12];const a=[0,2,4,5,7,9,11];this.alter=e%12-a[this.step]}}getNoteName(){return["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"][this.midiNumber%12]}getOctave(){return this.octave}getStaffPosition(e){const i={[ft.Treble]:34,[ft.Bass]:22,[ft.Alto]:28,[ft.Tenor]:26,[ft.Percussion]:28,[ft.Tab]:28}[e];return this.getAbsoluteDiatonicStep()-i}getAbsoluteDiatonicStep(){return this.octave*7+this.step}getDiatonicStep(){return this.step}transposeDiatonic(e){const s=this.octave*7+this.step+e,i=Math.floor(s/7),n=(s%7+7)%7,r=[0,2,4,5,7,9,11],a=(i+1)*12+r[n];return new le(a,n,0,i)}withEnharmonicNext(){const e=[0,2,4,5,7,9,11],s=[];for(let a=this.octave-1;a<=this.octave+1;a++)for(let l=0;l<7;l++){const c=(a+1)*12+e[l],h=this.midiNumber-c;Math.abs(h)<=2&&s.push({step:l,alter:h,octave:a})}s.sort((a,l)=>a.octave*7+a.step-(l.octave*7+l.step));const n=(s.findIndex(a=>a.step===this.step&&a.alter===this.alter&&a.octave===this.octave)+1)%s.length,r=s[n];return new le(this.midiNumber,r.step,r.alter,r.octave)}static fromNoteName(e,s){const i={C:0,D:1,E:2,F:3,G:4,A:5,B:6},n=e[0].toUpperCase(),r=i[n]??0;let a=0;e.includes("#")&&(a=e.split("#").length-1),e.includes("b")&&(a=-(e.split("b").length-1)),e.includes("x")&&(a=(e.split("x").length-1)*2);const l=[0,2,4,5,7,9,11],c=(s+1)*12+l[r]+a;return new le(c,r,a,s)}static fromStaffPosition(e,s){const n={[ft.Treble]:34,[ft.Bass]:22,[ft.Alto]:28,[ft.Tenor]:26,[ft.Percussion]:28,[ft.Tab]:28}[e]+s,r=Math.floor(n/7),a=(n%7+7)%7,l=[0,2,4,5,7,9,11],c=(r+1)*12+l[a];return new le(c,a,0,r)}}class wt{constructor(e,s,i=!1,n=!1,r,a,l,c,h,d,p,y,S=!1,I,m,k,E,Y,R,O,M,q,it,ot,U,dt,st,g,L){this.duration=e,this.pitch=s,this.isRest=i,this.isDotted=n,this.accidental=r,this.beamGroup=a,this.articulation=l,this.dynamic=c,this.tie=h,this.slur=d,this.tuplet=p,this.hairpin=y,this.isGrace=S,this.lyric=I,this.chord=m,this.glissando=k,this.arpeggio=E,this.ottava=Y,this.pedal=R,this.ornament=O,this.fret=M,this.string=q,this.fretboardDiagram=it,this.lyrics=ot,this.staffText=U,this.color=dt,this.notehead=st,this.bowing=g,this.fingering=L}getDurationValue(){if(this.isGrace)return 0;const e=Je[this.duration];let s=this.isDotted?e*1.5:e;return this.tuplet&&(s=s*(this.tuplet.normal/this.tuplet.actual)),s}isBeamable(){return!this.isRest&&(this.duration===P.Eighth||this.duration===P.Sixteenth||this.duration===P.ThirtySecond||this.duration===P.SixtyFourth||this.duration===P.OneHundredTwentyEighth||this.duration===P.TwoHundredFiftySixth)}withGrace(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,e,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withChord(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,e,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}static fromJSON(e){const s=e.pitch?new le(e.pitch.midiNumber,e.pitch.step,e.pitch.alter,e.pitch.octave):void 0;return new wt(e.duration,s,e.isRest??!1,e.isDotted??!1,e.accidental,e.beamGroup,e.articulation,e.dynamic,e.tie,e.slur,e.tuplet,e.hairpin,e.isGrace??!1,e.lyric,e.chord,e.glissando,e.arpeggio,e.ottava,e.pedal,e.ornament,e.fret,e.string,e.fretboardDiagram,e.lyrics,e.staffText,e.color,e.notehead,e.bowing,e.fingering)}transpose(e){if(this.isRest||!this.pitch)return this;const s=new le(this.pitch.midiNumber+e),i=s.midiNumber%12,r=[1,3,6,8,10].includes(i)?At.Sharp:void 0;return new wt(this.duration,s,this.isRest,this.isDotted,r,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}transposeOctave(e){if(!this.pitch||this.isRest)return this;const s=new le(this.pitch.midiNumber+e*12,this.pitch.step,this.pitch.alter,this.pitch.octave+e);return this.withPitch(s)}transposeDiatonic(e){if(this.isRest||!this.pitch)return this;const s=this.pitch.transposeDiatonic(e);return this.withPitch(s).withAccidental(void 0)}toggleEnharmonic(){if(!this.pitch||this.isRest)return this;const e=this.pitch.withEnharmonicNext();let s;return e.alter===1?s=At.Sharp:e.alter===-1?s=At.Flat:e.alter===2?s=At.DoubleSharp:e.alter===-2?s=At.DoubleFlat:e.alter===0&&(s=void 0),this.withPitch(e).withAccidental(s)}withPitch(e){return new wt(this.duration,e,!1,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withArticulation(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,e,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withDynamic(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,e,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withTie(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,e,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withSlur(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,e,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withTuplet(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,e,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withLyric(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,e,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withLyrics(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,e,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withHairpin(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,e,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withAccidental(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,e,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withDuration(e,s=!1){return new wt(e,this.pitch,this.isRest,s,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withRest(e){return new wt(this.duration,this.pitch,e,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withFretboardDiagram(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,e,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withBeamGroup(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,e,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}toJSON(){return{duration:this.duration,pitch:this.isRest?void 0:this.pitch?{midiNumber:this.pitch.midiNumber,step:this.pitch.step,alter:this.pitch.alter,octave:this.pitch.octave}:void 0,isRest:this.isRest||void 0,isDotted:this.isDotted||void 0,accidental:this.accidental,beamGroup:this.beamGroup,articulation:this.articulation,dynamic:this.dynamic,tie:this.tie,slur:this.slur,tuplet:this.tuplet,hairpin:this.hairpin,isGrace:this.isGrace||void 0,lyric:this.lyric,chord:this.chord,glissando:this.glissando,arpeggio:this.arpeggio,ottava:this.ottava,pedal:this.pedal,ornament:this.ornament,fret:this.fret,string:this.string,fretboardDiagram:this.fretboardDiagram,lyrics:this.lyrics,staffText:this.staffText,color:this.color,notehead:this.notehead,bowing:this.bowing,fingering:this.fingering}}withGlissando(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,e,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withArpeggio(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,e,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withOttava(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,e,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withPedal(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,e,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withOrnament(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,e,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withTab(e,s){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,e,s,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,this.fingering)}withStaffText(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,e,this.color,this.notehead,this.bowing,this.fingering)}withColor(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,e,this.notehead,this.bowing,this.fingering)}withNotehead(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,e,this.bowing,this.fingering)}withBowing(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,e,this.fingering)}withFingering(e){return new wt(this.duration,this.pitch,this.isRest,this.isDotted,this.accidental,this.beamGroup,this.articulation,this.dynamic,this.tie,this.slur,this.tuplet,this.hairpin,this.isGrace,this.lyric,this.chord,this.glissando,this.arpeggio,this.ottava,this.pedal,this.ornament,this.fret,this.string,this.fretboardDiagram,this.lyrics,this.staffText,this.color,this.notehead,this.bowing,e)}}class _t{constructor(e,s,i,n=!1,r=!1,a=[],l,c=!1,h,d,p,y){this.voices=e,this.timeSignature=s,this.keySignature=i,this.systemBreak=n,this.pageBreak=r,this.repeats=a,this.volta=l,this.isPickup=c,this.clef=h,this.tempo=d,this.rehearsalMark=p,this.systemText=y}get notes(){return this.voices[0]||[]}changeNoteDuration(e,s,i=!1,n=0){const r=this.voices[n];if(!r||e<0||e>=r.length)return this;const a=r[e],l=a.getDurationValue(),c=Je[s],h=i?c*1.5:c;if(Math.abs(h-l)<.001)return this;const d=[...r];if(h<l){const y=l-h;d[e]=a.withDuration(s,i);const S=Ze(y).map(I=>new wt(I.duration,void 0,!0,I.isDotted));d.splice(e+1,0,...S)}else{const y=h-l;let S=0;for(let E=e+1;E<d.length;E++)S+=d[E].getDurationValue();if(S<y-.001)return this;d[e]=a.withDuration(s,i);let I=0,m=0;const k=[];for(let E=e+1;E<r.length;E++){const Y=r[E],R=Y.getDurationValue();if(I+R<=y+.001){if(I+=R,m++,I>=y-.001)break}else{const O=I+R-y;k.push(...Ze(O).map(M=>Y.isRest?new wt(M.duration,void 0,!0,M.isDotted):Y.withDuration(M.duration,M.isDotted))),m++;break}}d.splice(e+1,m,...k)}const p=[...this.voices];return p[n]=d,new _t(p,this.timeSignature,this.keySignature,this.systemBreak,this.pageBreak,this.repeats,this.volta,this.isPickup,this.clef,this.tempo)}getTotalDuration(e=0){const s=this.voices[e];return s?s.reduce((i,n)=>i+n.getDurationValue(),0):0}static fromJSON(e){let s;return e.voices?s=e.voices.map(i=>i.map(n=>wt.fromJSON(n))):e.notes?s=[e.notes.map(i=>wt.fromJSON(i))]:s=[[]],new _t(s,e.timeSignature,e.keySignature,e.systemBreak??!1,e.pageBreak??!1,e.repeats||(e.repeat?[e.repeat]:[]),e.volta,e.isPickup??!1,e.clef,e.tempo)}transpose(e){return new _t(this.voices.map(s=>s.map(i=>i.transpose(e))),this.timeSignature,this.keySignature,this.systemBreak,this.pageBreak,this.repeats,this.volta,this.isPickup,this.clef,this.tempo)}replaceNote(e,s,i=0){if(i<0||i>=this.voices.length)return this;const n=this.voices[i];if(e<0||e>=n.length)return this;const r=[...this.voices],a=[...n];return a[e]=s,r[i]=a,new _t(r,this.timeSignature,this.keySignature,this.systemBreak,this.pageBreak,this.repeats,this.volta,this.isPickup,this.clef,this.tempo)}deleteNote(e,s=0){if(s<0||s>=this.voices.length)return this;const i=this.voices[s];if(e<0||e>=i.length)return this;const n=[...this.voices],r=[...i];return r.splice(e,1),n[s]=r,new _t(n,this.timeSignature,this.keySignature,this.systemBreak,this.pageBreak,this.repeats,this.volta,this.isPickup,this.clef,this.tempo)}autoBeam(e){let s=4/e.beatType;e.beatType===8&&e.beats%3===0&&(s=1.5);const i=this.voices.map(n=>{let r=0,a=-1,l=-1;const c=[];for(const d of n){const p=d.getDurationValue(),y=Math.floor(r/s+.001);let S;if(d.isBeamable()){const I=r+p;Math.floor(I/s-.001)!==y?a=-1:(y===l&&a!==-1||(a=Math.floor(Math.random()*1e6)+1),S=a)}else a=-1;c.push(d.withBeamGroup(S)),l=y,r+=p}const h=new Map;for(const d of c)d.beamGroup!==void 0&&h.set(d.beamGroup,(h.get(d.beamGroup)||0)+1);return c.map(d=>d.beamGroup!==void 0&&(h.get(d.beamGroup)||0)<2?d.withBeamGroup(void 0):d)});return new _t(i,this.timeSignature,this.keySignature,this.systemBreak,this.pageBreak,this.repeats,this.volta,this.isPickup,this.clef,this.tempo,this.rehearsalMark,this.systemText)}withTimeSignature(e){return new _t(this.voices,e,this.keySignature,this.systemBreak,this.pageBreak,this.repeats,this.volta,this.isPickup,this.clef,this.tempo,this.rehearsalMark,this.systemText)}withKeySignature(e){return new _t(this.voices,this.timeSignature,e,this.systemBreak,this.pageBreak,this.repeats,this.volta,this.isPickup,this.clef,this.tempo,this.rehearsalMark,this.systemText)}withClef(e){return new _t(this.voices,this.timeSignature,this.keySignature,this.systemBreak,this.pageBreak,this.repeats,this.volta,this.isPickup,e,this.tempo,this.rehearsalMark,this.systemText)}withTempo(e){return new _t(this.voices,this.timeSignature,this.keySignature,this.systemBreak,this.pageBreak,this.repeats,this.volta,this.isPickup,this.clef,e,this.rehearsalMark,this.systemText)}withSystemBreak(e){return new _t(this.voices,this.timeSignature,this.keySignature,e,this.pageBreak,this.repeats,this.volta,this.isPickup,this.clef,this.tempo,this.rehearsalMark,this.systemText)}withPageBreak(e){return new _t(this.voices,this.timeSignature,this.keySignature,this.systemBreak,e,this.repeats,this.volta,this.isPickup,this.clef,this.tempo,this.rehearsalMark,this.systemText)}withVoices(e){return new _t(e,this.timeSignature,this.keySignature,this.systemBreak,this.pageBreak,this.repeats,this.volta,this.isPickup,this.clef,this.tempo,this.rehearsalMark,this.systemText)}withRepeat(e){if(!e)return this.withRepeats([]);const s=this.repeats.find(n=>n.type===e.type);let i;return s?i=this.repeats.filter(n=>n.type!==e.type):i=[...this.repeats,e],this.withRepeats(i)}withRepeats(e){return new _t(this.voices,this.timeSignature,this.keySignature,this.systemBreak,this.pageBreak,e,this.volta,this.isPickup,this.clef,this.tempo,this.rehearsalMark,this.systemText)}withVolta(e){return new _t(this.voices,this.timeSignature,this.keySignature,this.systemBreak,this.pageBreak,this.repeats,e,this.isPickup,this.clef,this.tempo,this.rehearsalMark,this.systemText)}withPickup(e){return new _t(this.voices,this.timeSignature,this.keySignature,this.systemBreak,this.pageBreak,this.repeats,this.volta,e,this.clef,this.tempo,this.rehearsalMark,this.systemText)}withRehearsalMark(e){return new _t(this.voices,this.timeSignature,this.keySignature,this.systemBreak,this.pageBreak,this.repeats,this.volta,this.isPickup,this.clef,this.tempo,e,this.systemText)}withSystemText(e){return new _t(this.voices,this.timeSignature,this.keySignature,this.systemBreak,this.pageBreak,this.repeats,this.volta,this.isPickup,this.clef,this.tempo,this.rehearsalMark,e)}fillVoiceWithRests(e,s){const i=[...this.voices];for(;i.length<=e;)i.push([]);const n=i[e],r=n.reduce((a,l)=>a+l.getDurationValue(),0);if(r<s-.001){const a=s-r,l=Ze(a).map(c=>new wt(c.duration,void 0,!0,c.isDotted));i[e]=[...n,...l]}return new _t(i,this.timeSignature,this.keySignature,this.systemBreak,this.pageBreak,this.repeats,this.volta,this.isPickup,this.clef,this.tempo,this.rehearsalMark,this.systemText)}toJSON(){return{voices:this.voices.map(e=>e.map(s=>s.toJSON())),timeSignature:this.timeSignature,keySignature:this.keySignature,systemBreak:this.systemBreak||void 0,pageBreak:this.pageBreak||void 0,repeats:this.repeats,volta:this.volta,isPickup:this.isPickup||void 0,clef:this.clef,tempo:this.tempo,rehearsalMark:this.rehearsalMark,systemText:this.systemText}}}function _r(t,e,s,i,n,r=5,a=0,l=0){let c=0;n===ft.Tab&&t.string!==void 0?c=r-1-2*(t.string-1):t.pitch&&!t.isRest&&(c=t.pitch.getStaffPosition(n));const h=s-c*i/2,d=t.isGrace?i*.7:i,p=c>=0?We.Down:We.Up;let y=t.isGrace?d*2.5:d*3.5;t.duration===P.ThirtySecond&&(y+=d*.5),t.duration===P.SixtyFourth&&(y+=d*1.5),t.duration===P.OneHundredTwentyEighth&&(y+=d*2.5),t.duration===P.TwoHundredFiftySixth&&(y+=d*3.5);const S=h,I=p===We.Up?h-y:h+y;return{note:t,x:e,y:h,staffPosition:c,stemDirection:p,stemStartY:S,stemEndY:I,clef:n,voiceIndex:a,noteIndex:l}}function Fr(t,e,s,i,n,r,a,l,c=5){const{staffLineSpacing:h}=l,p=t.voices.some(it=>it.some(ot=>ot.beamGroup!==void 0))?t:t.autoBeam(a),y=t.clef||r,S=[],I=h*1.66,m=i-I*2;let k=0;if(t.clef&&(k+=l.midMeasureClefWidth),t.keySignature){const it=Math.abs(t.keySignature.fifths);k+=it*l.keySignatureStepWidth+l.keySignatureRightPadding}t.timeSignature&&(k+=l.timeSignatureWidth);const E=s+I+k,Y=m-k,R=new Set;t.voices.forEach(it=>{let ot=0;it.forEach(U=>{R.add(ot),ot+=U.getDurationValue()}),R.add(ot)});const O=Array.from(R).sort((it,ot)=>it-ot),M=new Map,q=O.length-1;if(q<=0)M.set(0,E);else{const it=h*1.25,ot=O[q]-O[0];let U=(Y-q*it)/ot,dt=it;U<0&&(U=0,dt=Y/q);let st=E;for(let g=0;g<O.length;g++)if(M.set(O[g],st),g<q){const L=O[g+1]-O[g];st+=dt+U*L}}return t.voices.forEach((it,ot)=>{const U=[];let dt=0;for(let st=0;st<it.length;st++){const g=it[st],L=g.getDurationValue();let $=M.get(dt)??E;g.accidental!==void 0&&($+=h*.5);const Q=_r(g,$,n,h,y,c,ot,st);t.voices.filter(bt=>bt.some(ht=>!ht.isRest)).length>1&&(Q.stemDirection=ot===0?We.Up:We.Down),U.push(Q),dt+=L}for(let st=U.length-2;st>=0;st--){const g=U[st],L=U[st+1];if(g.note.isGrace){let $=h*1.5;if(L.note.accidental){const Q=L.note.isGrace?h*.7:h;$+=Q*1.5}g.x=L.x-$}}S.push(U)}),{measure:p,x:s,width:i,voiceLayouts:S,noteLayouts:S.flat(),measureNumber:e,signatureWidth:k}}function qr(t,e,s,i,n,r,a,l,c,h,d,p=1,y=0,S=0,I){const{staffLineSpacing:m}=d,k=m*(t.lineCount-1),E=[],Y=t.measures.slice(a,a+l),R=I&&I.length>=Y.length?I:Array(Y.length).fill(r/l);let O=h,M=p,q=i;for(let it=0;it<Y.length;it++){const ot=Y[it];ot.timeSignature&&(O=ot.timeSignature);const U=R[it],dt=Fr(ot,M,q,U,n,t.clef,O,d,t.lineCount);ot.isPickup||M++,E.push(dt),q+=U}return{staff:t,x:i,y:n,width:r,height:k,clef:t.clef,measureLayouts:E,partIndex:e,staffIndex:s,keySignature:c,timeSignature:h,maxClefWidth:y,maxKeySignatureWidth:S}}function zr(t,e){const s=e.staffLineSpacing;return t===ft.Treble?25*(s*5.5/41.64*.6*e.trebleClefScale):t===ft.Bass?28*(s*3.5/30*e.bassClefScale):t===ft.Alto||t===ft.Tenor?s*2.5:s*2}function Gr(t,e){return t===0?0:(Math.abs(t)-1)*e.staffLineSpacing*.9+e.staffLineSpacing*.8}function dn(t,e,s,i,n,r,a,l,c,h=1){const{staffLineSpacing:d,staffMargin:p,clefWidth:y}=c,S=[],I=i-y,m=t.getAllStaves(),k=U=>{const dt=U.lineCount;let st=dt-1,g=-(dt-1);const L=Math.min(r,U.measures.length-n);for(let $=0;$<L;$++){const Q=U.measures[n+$];for(const ct of Q.voices)for(const bt of ct){if(bt.isRest||!bt.pitch)continue;const ht=bt.pitch.getStaffPosition(U.clef);st=Math.max(st,ht),g=Math.min(g,ht),st=Math.max(st,ht+7),g=Math.min(g,ht-7)}}return{headroom:st*d/2,legroom:-g*d/2}};let E=s;const Y=m.map(U=>({...U,extents:k(U.staff)}));let R=0,O=0;for(const{staff:U}of Y){const dt=zr(U.clef,c);dt>R&&(R=dt);const st=Gr(a.fifths,c);st>O&&(O=st)}const M=[],q=Math.min(r,t.getMeasureCount()-n);for(let U=0;U<q;U++){const dt=n+U;let st=0;for(const{staff:g}of m){const L=g.measures[dt];if(L){let Q=Math.max(...L.voices.map(ct=>ct.length),0)*c.minNoteSpacing+c.staffLineSpacing*3.33;L.clef&&(Q+=c.midMeasureClefWidth),L.keySignature&&(Q+=Math.abs(L.keySignature.fifths)*c.keySignatureStepWidth),L.timeSignature&&(Q+=c.timeSignatureWidth),Q>st&&(st=Q)}}M.push(Math.max(st,c.staffLineSpacing*5))}const it=M.reduce((U,dt)=>U+dt,0),ot=it>0?M.map(U=>U/it*I):Array(q).fill(I/Math.max(1,q));for(let U=0;U<Y.length;U++){const{partIndex:dt,staffIndex:st,staff:g,extents:L}=Y[U];let $;$=E+L.headroom;const Q=qr(g,dt,st,e+y,$,I,n,r,a,l,c,h,R,O,ot);S.push(Q),E=$+L.legroom+p}return{y:s,height:E-s-p,staffLayouts:S,measureStartIndex:n,measuresInSystem:q}}const vs={canvasWidth:1200,marginTop:3.3,marginLeft:3.3,marginRight:3.3,marginBottom:3.3,titleHeight:5,staffLineSpacing:12,staffMargin:2.5,systemMargin:5,measuresPerLine:4,clefWidth:9,trebleClefYOffset:1,bassClefYOffset:1.2,noteDotDistance:1.2,titleSubtitleSpacing:1,subtitleScoreSpacing:3.3,minNoteSpacing:3.3,firstSystemIndentation:2.5,musicFont:"Standard",showMeasureNumbers:!0,measureNumberMode:"system",measureNumberInterval:5,showPartNames:!0,groupMultiMeasureRests:!0,titleStyle:{fontFamily:"Georgia, serif",fontSize:24,fontWeight:"bold",fontStyle:"normal"},subtitleStyle:{fontFamily:"Georgia, serif",fontSize:18,fontWeight:"normal",fontStyle:"normal"},composerStyle:{fontFamily:"Georgia, serif",fontSize:16,fontWeight:"normal",fontStyle:"italic"},pageWidth:1200,pageHeight:1600,tempoStyle:{fontFamily:"serif",fontSize:16,fontWeight:"bold",fontStyle:"normal"},clefKeySignatureSpacing:1.25,noteNameMode:"none",bassClefScale:.8,trebleClefScale:1,clefLeftPadding:1.25,midMeasureClefWidth:3,keySignatureStepWidth:.9,keySignatureRightPadding:1.66,timeSignatureWidth:3.3};function pn(t){const e=t.staffLineSpacing;return{...t,marginTop:t.marginTop*e,marginLeft:t.marginLeft*e,marginRight:t.marginRight*e,marginBottom:t.marginBottom*e,titleHeight:t.titleHeight*e,staffMargin:t.staffMargin*e,systemMargin:t.systemMargin*e,clefWidth:t.clefWidth*e,titleSubtitleSpacing:t.titleSubtitleSpacing*e,subtitleScoreSpacing:t.subtitleScoreSpacing*e,minNoteSpacing:t.minNoteSpacing*e,firstSystemIndentation:t.firstSystemIndentation*e,clefKeySignatureSpacing:t.clefKeySignatureSpacing*e,clefLeftPadding:t.clefLeftPadding*e,midMeasureClefWidth:t.midMeasureClefWidth*e,keySignatureStepWidth:t.keySignatureStepWidth*e,keySignatureRightPadding:t.keySignatureRightPadding*e,timeSignatureWidth:t.timeSignatureWidth*e,titleStyle:{...t.titleStyle,fontSize:t.titleStyle.fontSize/12*e},subtitleStyle:{...t.subtitleStyle,fontSize:t.subtitleStyle.fontSize/12*e},composerStyle:{...t.composerStyle,fontSize:t.composerStyle.fontSize/12*e},tempoStyle:{...t.tempoStyle,fontSize:t.tempoStyle.fontSize/12*e}}}function gn(t,e=vs,s){const i=pn(e),n=[],r=i.pageWidth-i.marginLeft-i.marginRight,a=t.getAllStaves().filter(q=>s?s.includes(q.partIndex):!0),l=t.getMeasureCount();let c=0,h=1;const d=i.pageHeight-i.marginBottom,p=i.titleStyle.fontSize,y=i.subtitleStyle.fontSize,S=i.marginTop+p,I=S+y+i.titleSubtitleSpacing,m=S,k=S+p;let E=[],Y=I+i.subtitleScoreSpacing,R=!0,O=t.keySignature,M=t.timeSignature;for(;c<l;){const q=c===0;let it=i.firstSystemIndentation;if(i.showPartNames&&q){let ht=0;const It=9,_=20;for(const{partIndex:W}of a){const z=t.parts[W];if(z&&z.name){const Z=z.name.length;Z>ht&&(ht=Z)}}const x=ht*It+_;x>it&&(it=x)}const ot=q?it:0,U=i.marginLeft+ot,dt=r-ot,st=dt-i.clefWidth;let g=0,L=0;for(let ht=0;ht<i.measuresPerLine;ht++){const It=c+ht;if(It>=l)break;const _=a.some(z=>{var Z;return(Z=z.staff.measures[It])==null?void 0:Z.systemBreak}),x=a.some(z=>{var Z;return(Z=z.staff.measures[It])==null?void 0:Z.pageBreak});let W=0;for(const{staff:z}of a){const Z=z.measures[It];if(Z){let G=Math.max(...Z.voices.map(lt=>lt.length),0)*i.minNoteSpacing+i.staffLineSpacing*3.33;Z.clef&&(G+=i.midMeasureClefWidth*i.staffLineSpacing),Z.keySignature&&(G+=Math.abs(Z.keySignature.fifths)*i.keySignatureStepWidth*i.staffLineSpacing),Z.timeSignature&&(G+=i.timeSignatureWidth*i.staffLineSpacing),G>W&&(W=G)}}if(L+W<=st){if(g=ht+1,L+=W,_||x)break}else{g===0&&(g=1,L=W);break}}g===0&&c<l&&(g=1);const $=dn(t,U,Y,dt,c,g,O,M,i,h),Q=Y+$.height+i.marginBottom,ct=c+g-1,bt=a.some(ht=>{var It;return(It=ht.staff.measures[ct])==null?void 0:It.pageBreak});if((Q>i.pageHeight||bt)&&E.length>0){n.push({width:i.pageWidth,height:i.pageHeight,systemLayouts:E,titleY:R?S:void 0,subtitleY:R?I:void 0,composerY:R?m:void 0,lyricistY:R?k:void 0,copyrightY:d}),E=[],Y=i.marginTop,R=!1;const ht=dn(t,U,Y,dt,c,g,O,M,i,h);E.push(ht),Y+=ht.height+i.systemMargin}else E.push($),Y+=$.height+i.systemMargin;for(let ht=0;ht<g;ht++){const It=c+ht;for(const{staff:_}of a){const x=_.measures[It];x&&(x.keySignature&&(O=x.keySignature),x.timeSignature&&(M=x.timeSignature))}}for(let ht=0;ht<g;ht++){const It=c+ht;a.some(x=>{var W;return(W=x.staff.measures[It])==null?void 0:W.isPickup})||h++}c+=g}return E.length>0&&n.push({width:i.pageWidth,height:i.pageHeight,systemLayouts:E,titleY:R?S:void 0,subtitleY:R?I:void 0,composerY:R?m:void 0,lyricistY:R?k:void 0,copyrightY:d}),{pages:n,totalWidth:i.pageWidth,totalHeight:n.length*i.pageHeight}}function mn(t,e,s,i,n=-1,r=1){t.save(),t.fillStyle="#000";const a=i*5.5/41.64*.6*r,l=e-.58*i,c=s+i*n;t.translate(l,c),t.scale(a,a),t.beginPath(),t.moveTo(16.8,-41.3),t.quadraticCurveTo(17.85,-39.35,18.65,-36.5),t.quadraticCurveTo(19.45,-33.75,19.55,-31.35),t.quadraticCurveTo(19.3,-22.85,12.95,-16.4),t.lineTo(14.25,-9.7),t.lineTo(15.8,-9.85),t.quadraticCurveTo(19.7,-9.75,22.1,-6.9),t.quadraticCurveTo(24.45,-4.05,24.5,-.1),t.quadraticCurveTo(24.45,3.15,22.7,5.45),t.quadraticCurveTo(20.95,7.8,18.05,9.2),t.lineTo(19.7,17.3),t.lineTo(19.8,19.15),t.quadraticCurveTo(19.6,25.45,12.95,26.35),t.quadraticCurveTo(10.35,26.6,8.1,25.05),t.quadraticCurveTo(5.85,23.5,5.45,20.8),t.quadraticCurveTo(5.35,18.9,6.35,17.4),t.quadraticCurveTo(7.4,15.95,9.2,15.65),t.quadraticCurveTo(10.8,15.5,12,16.65),t.quadraticCurveTo(13.2,17.75,13.3,19.45),t.quadraticCurveTo(13.25,21.75,11.75,22.6),t.quadraticCurveTo(10.25,23.5,9.2,23.25),t.quadraticCurveTo(9.4,24.25,10.65,24.7),t.lineTo(12.85,25),t.quadraticCurveTo(18.35,24.15,18.45,19.05),t.quadraticCurveTo(18.5,17.7,18.15,16.15),t.lineTo(16.75,9.75),t.lineTo(13.15,10.3),t.quadraticCurveTo(7.85,10.15,4.2,6.4),t.quadraticCurveTo(.55,2.65,0,-3.15),t.quadraticCurveTo(-.2,-8.95,3.25,-13.5),t.quadraticCurveTo(6.7,-18,10.6,-21.7),t.quadraticCurveTo(9.45,-26.05,9.4,-30.55),t.quadraticCurveTo(9.4,-33.6,10.75,-37.6),t.quadraticCurveTo(12.1,-41.65,14.9,-43),t.quadraticCurveTo(15.75,-43.2,16.8,-41.3),t.moveTo(15.65,-37.1),t.quadraticCurveTo(13.2,-36.35,12.15,-33.25),t.quadraticCurveTo(11.1,-30.2,11.05,-27.75),t.quadraticCurveTo(11.1,-25.2,11.75,-22.8),t.quadraticCurveTo(14.2,-24.85,16.05,-27.95),t.quadraticCurveTo(17.85,-31.1,17.8,-34.55),t.quadraticCurveTo(17.8,-35.55,17.25,-36.3),t.quadraticCurveTo(16.7,-37.05,15.65,-37.1),t.moveTo(11.05,-2.85),t.quadraticCurveTo(9.85,-1.35,9.85,.55),t.quadraticCurveTo(10.1,3.7,12.95,4.9),t.lineTo(13.25,5.3),t.lineTo(12.7,5.7),t.quadraticCurveTo(10.4,4.85,8.95,2.9),t.quadraticCurveTo(7.5,.9,7.5,-1.65),t.quadraticCurveTo(7.6,-4.2,9.2,-6.35),t.quadraticCurveTo(10.8,-8.45,13.1,-9.35),t.lineTo(11.9,-15.4),t.quadraticCurveTo(8.55,-12.6,5.85,-9.05),t.quadraticCurveTo(3.15,-5.55,2.95,-.95),t.quadraticCurveTo(3.1,3.8,6.25,6.4),t.quadraticCurveTo(9.45,9.05,13.95,8.9),t.lineTo(16.55,8.4),t.lineTo(13.95,-4.9),t.quadraticCurveTo(12.2,-4.35,11.05,-2.85),t.moveTo(15.15,-5.05),t.lineTo(17.8,8),t.quadraticCurveTo(21.7,5.85,21.75,1.3),t.quadraticCurveTo(21.5,-1.55,19.7,-3.25),t.quadraticCurveTo(17.9,-5,15.15,-5.05),t.fill("evenodd"),t.restore()}function xn(t,e,s,i,n=1,r=1){t.save(),t.fillStyle="#000";const a=i*3.5/30*r,l=s-i*n;t.translate(e,l),t.scale(a,a),t.beginPath(),t.moveTo(6.8,-8.15),t.lineTo(4.75,-7),t.quadraticCurveTo(4,-6.2,3.55,-5.2),t.quadraticCurveTo(3.1,-4.2,4.5,-3.9),t.lineTo(6.1,-4.25),t.quadraticCurveTo(7.75,-4.35,8.8,-3.4),t.quadraticCurveTo(9.9,-2.4,9.95,-1),t.quadraticCurveTo(9.9,.4,8.85,1.5),t.quadraticCurveTo(7.8,2.6,5.9,2.65),t.quadraticCurveTo(3.9,2.65,2.5,1.45),t.quadraticCurveTo(1.15,.3,1.05,-1.55),t.quadraticCurveTo(1,-3.6,2.15,-5.45),t.quadraticCurveTo(3.3,-7.25,5.25,-8.35),t.quadraticCurveTo(6.35,-9,8,-9.5),t.lineTo(10.9,-10),t.quadraticCurveTo(14.7,-10.25,18.25,-7.5),t.quadraticCurveTo(20.05,-6.05,20.85,-4.5),t.quadraticCurveTo(21.6,-2.95,21.85,-.5),t.quadraticCurveTo(22.1,3.2,19.8,7.2),t.quadraticCurveTo(17.55,11.15,14.5,13.65),t.lineTo(7.85,18.05),t.lineTo(.25,22),t.lineTo(0,21.15),t.lineTo(7.85,15.65),t.quadraticCurveTo(11.1,13.05,13.65,8.75),t.quadraticCurveTo(14.8,6.75,15.5,4.25),t.quadraticCurveTo(16.25,1.8,16.25,-.35),t.quadraticCurveTo(16.4,-3.55,15.3,-5.75),t.quadraticCurveTo(14.55,-7.15,13.1,-8),t.quadraticCurveTo(11.55,-8.9,9.55,-8.75),t.lineTo(6.8,-8.15),t.moveTo(25.65,-6.85),t.quadraticCurveTo(27.7,-6.6,27.8,-4.7),t.quadraticCurveTo(27.7,-2.75,25.65,-2.5),t.quadraticCurveTo(23.5,-2.75,23.45,-4.7),t.quadraticCurveTo(23.5,-6.6,25.65,-6.85),t.moveTo(27.8,4.05),t.quadraticCurveTo(27.7,6,25.65,6.25),t.quadraticCurveTo(23.5,6,23.45,4.05),t.quadraticCurveTo(23.5,2.15,25.65,1.9),t.quadraticCurveTo(27.7,2.15,27.8,4.05),t.fill("evenodd"),t.restore()}function Fs(t,e,s,i,n){t.save(),t.fillStyle="#000";const r=i,a=r/10,l=s-n*r/2;t.translate(e,l),t.scale(a,a);const c=new Path2D("M18.25,-20Q22.2,-19.95 24.6,-17.4Q26.9,-14.8 26.95,-10.5Q26.9,-7.05 24.95,-4.65Q23,-2.25 19.55,-1.9Q17.7,-1.7 15.35,-2.65L13.5,0.3L15.35,3.25Q17.7,2.3 19.55,2.5Q23,2.9 24.95,5.25Q26.9,7.65 27,11.1Q26.9,15.4 24.6,17.95Q22.2,20.55 18.25,20.6Q15.8,20.65 13.45,19.5Q11.1,18.45 10.95,15.7Q10.95,14.5 11.7,13.6Q12.45,12.75 13.6,12.7Q16.1,12.8 16.35,15.2Q16.25,16.5 15.5,17.1Q14.8,17.7 14.7,18.2Q14.75,18.9 15.6,19.15L17.05,19.4Q20.2,19.2 21,16.7Q21.85,14.2 21.65,11.6Q21.8,9.3 21.2,6.65Q20.65,4.05 17.7,4.05Q15.7,4.35 14.65,6.05Q13.65,7.8 13.45,9.7L13.35,9.7Q13,7.65 11.95,4.95Q10.8,2.25 8.6,0.65L8.6,20.6L7.05,20.6L7.05,-20L8.6,-20L8.6,-0.05Q10.8,-1.6 11.9,-4.35Q13,-7.1 13.35,-9.05L13.45,-9.05Q13.65,-7.2 14.65,-5.45Q15.7,-3.75 17.7,-3.45Q20.7,-3.45 21.25,-6.2Q21.8,-8.9 21.65,-11.25Q21.85,-14.05 21,-16.2Q20.2,-18.4 17.05,-18.75L15.6,-18.6Q14.75,-18.35 14.7,-17.6Q14.8,-17.15 15.5,-16.55Q16.25,-15.95 16.35,-14.65Q16.1,-12.25 13.6,-12.2Q11.15,-12.5 10.95,-15.15Q11.1,-17.9 13.45,-19Q15.85,-20.05 18.25,-20M4.7,-20L4.7,20.6L0,20.6L0,-20L4.7,-20");t.fill(c),t.restore()}function yn(t,e,s,i){t.save(),t.fillStyle="#000";const n=i;t.fillRect(e+.41*n,s-n,n*.4,n*2),t.fillRect(e+.41*n+n*.7,s-n,n*.4,n*2),t.restore()}function vn(t,e,s,i,n,r="#000",a=se.Normal){t.save(),t.fillStyle=r,t.strokeStyle=r;const l=n/10.4;t.translate(e,s),t.scale(l,l),t.translate(-6.5,0);const c=i===P.Whole||i===P.Half;switch(t.beginPath(),a){case se.Cross:t.lineWidth=.16*n/l,t.moveTo(3.5,-3.5),t.lineTo(9.5,3.5),t.moveTo(3.5,3.5),t.lineTo(9.5,-3.5),t.stroke();break;case se.Diamond:t.moveTo(6.5,-4.8),t.lineTo(11,0),t.lineTo(6.5,4.8),t.lineTo(2,0),t.closePath(),c?(t.lineWidth=.12*n/l,t.stroke()):t.fill();break;case se.Triangle:t.moveTo(6.5,-4.5),t.lineTo(10.5,4),t.lineTo(2.5,4),t.closePath(),c?(t.lineWidth=.12*n/l,t.stroke()):t.fill();break;case se.Slash:t.moveTo(2.5,5),t.lineTo(9.5,-5),t.lineTo(11.5,-5),t.lineTo(4.5,5),t.closePath(),t.fill();break;case se.Square:t.rect(3,-3.5,7,7),c?(t.lineWidth=.12*n/l,t.stroke()):t.fill();break;case se.Normal:default:t.moveTo(13,-1.55),t.quadraticCurveTo(12.8,1.2,10.15,3.15),t.quadraticCurveTo(7.4,5.1,4.4,5.2),t.quadraticCurveTo(2.5,5.15,1.3,4.2),t.quadraticCurveTo(.05,3.15,0,1.45),t.quadraticCurveTo(.2,-1.15,2.85,-3.1),t.quadraticCurveTo(5.45,-5.1,8.25,-5.2),t.quadraticCurveTo(10.45,-5.25,11.65,-4.3),t.quadraticCurveTo(12.95,-3.45,13,-1.55),c?(t.lineWidth=.12*n/l,t.stroke()):t.fill();break}t.restore()}function Yr(t,e,s,i,n,r,a="#000"){if(n===P.Whole||n===P.Half||n===P.Quarter)return;t.save(),t.fillStyle=a;const l=r,c=r/10;let h=1;n===P.Sixteenth&&(h=2),n===P.ThirtySecond&&(h=3),n===P.SixtyFourth&&(h=4),n===P.OneHundredTwentyEighth&&(h=5),n===P.TwoHundredFiftySixth&&(h=6);for(let d=0;d<h;d++){const p=d*l*.7;t.save(),t.translate(e,s+p),i==="up"?t.scale(c,c):t.scale(c,-c),t.beginPath(),t.moveTo(9.65,19.45),t.quadraticCurveTo(9.6,22.6,8.45,25.45),t.lineTo(6.2,30),t.lineTo(5.6,30),t.lineTo(7.35,25.85),t.quadraticCurveTo(8.3,23.35,8.3,20.5),t.quadraticCurveTo(8.15,17.1,6.05,14.4),t.quadraticCurveTo(4.9,12.9,3.2,11.9),t.quadraticCurveTo(1.5,10.9,-.2,10.7),t.lineTo(-.2,11.5),t.lineTo(-1.25,11.5),t.lineTo(-1.25,0),t.lineTo(-.2,0),t.lineTo(.35,3.3),t.quadraticCurveTo(.7,5.15,2.2,7.05),t.lineTo(6.8,12.25),t.quadraticCurveTo(9.45,15.45,9.65,19.45),t.fill(),t.restore()}t.restore()}function Vr(t,e,s,i,n=.8,r="#000"){t.save(),t.fillStyle=r,t.beginPath(),t.arc(e+i*n,s,i*.15,0,Math.PI*2),t.fill(),t.restore()}function Hr(t,e,s,i,n,r="#000"){t.save(),t.strokeStyle=r,t.lineWidth=1.5;const a=n/2;if(t.translate(e,s),t.beginPath(),i===Ue.DownBow){const l=a*1.5,c=a*.8;t.moveTo(-l/2,c),t.lineTo(-l/2,0),t.lineTo(l/2,0),t.lineTo(l/2,c),t.stroke()}else if(i===Ue.UpBow){const l=a*1.5,c=a*1.2;t.moveTo(-l/2,-c/2),t.lineTo(0,c/2),t.lineTo(l/2,-c/2),t.stroke()}t.restore()}function Kr(t,e,s,i,n,r="#000"){t.save(),t.fillStyle=r,t.strokeStyle=r,t.lineWidth=n*.16;const a=n;switch(i){case P.Whole:t.fillRect(e-a*.6,s-a,a*1.2,a*.5);break;case P.Half:t.fillRect(e-a*.6,s-a*.5,a*1.2,a*.5);break;case P.Quarter:{t.save(),t.translate(e,s);const l=a/10;t.scale(l,l),t.translate(-5,0),t.beginPath(),t.moveTo(10.4,-7.2),t.quadraticCurveTo(6.65,-3.15,6.3,.2),t.quadraticCurveTo(6.35,2.3,7.6,4.2),t.lineTo(10.2,7.65),t.lineTo(9.6,8.45),t.quadraticCurveTo(8.15,7.65,6.8,7.55),t.quadraticCurveTo(5.5,7.5,4.65,8.75),t.quadraticCurveTo(3.6,10.6,4.4,12.2),t.quadraticCurveTo(5.15,13.8,6.1,14.55),t.lineTo(5.55,15.35),t.lineTo(1.95,12.2),t.quadraticCurveTo(.25,10.45,0,8.1),t.quadraticCurveTo(.35,4.7,3.85,4.65),t.quadraticCurveTo(5.2,4.65,6.95,5.6),t.lineTo(6.95,5.5),t.lineTo(.65,-2.7),t.quadraticCurveTo(2.4,-4.2,3.6,-6.25),t.quadraticCurveTo(4.8,-8.3,4.6,-10.65),t.quadraticCurveTo(4,-13.05,2.25,-15),t.lineTo(3.95,-15),t.lineTo(10.4,-7.2),t.fill(),t.restore();break}case P.Eighth:{t.save(),t.translate(e,s);const l=a/10;t.scale(l,l),t.translate(-5,0),t.beginPath(),t.moveTo(5.35,-6.25),t.lineTo(5.25,-5.8),t.quadraticCurveTo(5.55,-5.15,6.25,-5.5),t.quadraticCurveTo(8.65,-6.6,9.75,-8.9),t.lineTo(10.4,-8.9),t.lineTo(5.65,8.5),t.lineTo(4.25,8.5),t.lineTo(8.1,-5.15),t.quadraticCurveTo(6.05,-3.85,3.75,-3.65),t.quadraticCurveTo(2.25,-3.7,1.15,-4.6),t.quadraticCurveTo(.1,-5.5,0,-6.95),t.quadraticCurveTo(.05,-9.35,2.45,-9.95),t.quadraticCurveTo(3.7,-10.15,4.6,-9.35),t.quadraticCurveTo(5.5,-8.55,5.55,-7.25),t.lineTo(5.35,-6.25),t.fill(),t.restore();break}case P.Sixteenth:{t.save(),t.translate(e,s);const l=a/10;t.scale(l,l),t.translate(-6,0),t.beginPath(),t.moveTo(3.85,-4.55),t.quadraticCurveTo(2.75,-5.45,2.7,-6.9),t.quadraticCurveTo(2.7,-9.3,5.15,-9.95),t.quadraticCurveTo(6.35,-10.15,7.25,-9.3),t.quadraticCurveTo(8.15,-8.5,8.2,-7.2),t.lineTo(8,-6.15),t.lineTo(7.9,-5.7),t.quadraticCurveTo(8.2,-5.1,8.9,-5.45),t.quadraticCurveTo(11.25,-6.5,12.55,-8.85),t.lineTo(13.3,-8.85),t.lineTo(5.7,18.4),t.lineTo(4.3,18.4),t.lineTo(8.1,4.75),t.quadraticCurveTo(6.1,6.05,3.8,6.25),t.quadraticCurveTo(2.3,6.2,1.2,5.3),t.quadraticCurveTo(.1,4.4,0,2.95),t.quadraticCurveTo(.15,.15,2.95,-.15),t.quadraticCurveTo(4.2,-.1,4.9,.8),t.quadraticCurveTo(5.65,1.7,5.6,2.9),t.lineTo(5.3,4.25),t.quadraticCurveTo(5.45,4.55,5.8,4.5),t.quadraticCurveTo(6.5,4.5,7.35,3.85),t.lineTo(8.65,2.8),t.lineTo(10.75,-5.1),t.quadraticCurveTo(8.7,-3.8,6.4,-3.6),t.quadraticCurveTo(5,-3.65,3.85,-4.55),t.fill(),t.restore();break}case P.ThirtySecond:case P.SixtyFourth:case P.OneHundredTwentyEighth:case P.TwoHundredFiftySixth:{t.save(),t.translate(e,s);const l=a/10;t.scale(l,l);let c=-7;i===P.SixtyFourth&&(c=-8),i===P.OneHundredTwentyEighth&&(c=-9),i===P.TwoHundredFiftySixth&&(c=-10),t.translate(c,0);let h=3;i===P.SixtyFourth&&(h=4),i===P.OneHundredTwentyEighth&&(h=5),i===P.TwoHundredFiftySixth&&(h=6),t.beginPath();const d=-16.2-(h-3)*8;t.moveTo(4.35,18.5),t.lineTo(5.75,18.5),t.lineTo(5.75+h*1.5,d);for(let p=0;p<h;p++){const S=-16.2+p*8;t.moveTo(10.9,S),t.lineTo(10.75,S+.45),t.quadraticCurveTo(11.05,S+1.1,11.75,S+.75),t.quadraticCurveTo(14.1,S-.35,15.4,S-2.65),t.lineTo(16.1,S-2.65),t.lineTo(8.15,S+21.05)}t.fill(),t.restore();break}}t.restore()}function bn(t,e,s,i,n,r="#000"){t.save(),t.fillStyle=r,t.strokeStyle=r,t.lineWidth=1.5;const a=n;switch(i){case At.Sharp:{t.save(),t.translate(e,s);const l=a/10;t.scale(l,l),t.translate(-4.5,0),t.beginPath(),t.moveTo(3.2,-14.05),t.lineTo(3.2,-6.55),t.lineTo(5.85,-7.25),t.lineTo(5.85,-15),t.lineTo(7.1,-15),t.lineTo(7.1,-7.5),t.lineTo(9,-8),t.lineTo(9,-3.95),t.lineTo(7.1,-3.5),t.lineTo(7.1,2.25),t.lineTo(9,1.75),t.lineTo(9,5.9),t.lineTo(7.1,6.4),t.lineTo(7.1,13.8),t.lineTo(5.85,13.8),t.lineTo(5.85,6.7),t.lineTo(3.2,7.35),t.lineTo(3.2,15.1),t.lineTo(1.95,15.1),t.lineTo(1.95,7.65),t.lineTo(0,8.1),t.lineTo(0,4),t.lineTo(1.95,3.5),t.lineTo(1.95,-2.2),t.lineTo(0,-1.7),t.lineTo(0,-5.75),t.lineTo(1.95,-6.25),t.lineTo(1.95,-14.05),t.lineTo(3.2,-14.05),t.moveTo(3.2,-2.5),t.lineTo(3.2,3.2),t.lineTo(5.85,2.5),t.lineTo(5.85,-3.2),t.lineTo(3.2,-2.5),t.fill("evenodd"),t.restore();break}case At.Flat:{t.save(),t.translate(e,s);const l=a/10;t.scale(l,l),t.translate(-4,0),t.beginPath(),t.moveTo(1.2,-4.35),t.quadraticCurveTo(2.75,-5.7,4.75,-5.85),t.quadraticCurveTo(6,-5.85,6.95,-4.85),t.quadraticCurveTo(7.9,-3.9,7.9,-2.5),t.quadraticCurveTo(7.75,-.7,6.5,.65),t.lineTo(3.9,3),t.lineTo(0,6.8),t.lineTo(0,-20),t.lineTo(1.2,-20),t.lineTo(1.2,-4.35),t.moveTo(3.4,-4.3),t.quadraticCurveTo(2.65,-4.35,1.95,-3.7),t.quadraticCurveTo(1.25,-3,1.2,-2.55),t.lineTo(1.2,4.2),t.lineTo(3.55,1.25),t.quadraticCurveTo(4.85,-.45,4.95,-2.15),t.quadraticCurveTo(4.8,-4.05,3.4,-4.3),t.fill("evenodd"),t.restore();break}case At.Natural:{t.save(),t.translate(e,s);const l=a/10;t.scale(l,l),t.translate(-3.5,0),t.beginPath(),t.moveTo(7,-7.4),t.lineTo(7,13.9),t.lineTo(5.75,13.9),t.lineTo(5.75,5.65),t.lineTo(0,7.1),t.lineTo(0,-14.2),t.lineTo(1.25,-14.2),t.lineTo(1.25,-5.95),t.lineTo(7,-7.4),t.moveTo(1.25,-2.1),t.lineTo(1.25,3),t.lineTo(5.75,1.8),t.lineTo(5.75,-3.25),t.lineTo(1.25,-2.1),t.fill("evenodd"),t.restore();break}case At.DoubleSharp:{t.save(),t.translate(e,s);const l=a/10;t.scale(l,l),t.translate(-5.35,0),t.beginPath(),t.moveTo(3.9,-2.6),t.quadraticCurveTo(3.9,-2.3,4.25,-1.7),t.quadraticCurveTo(4.55,-1.15,5.35,-1.1),t.quadraticCurveTo(6.7,-1.35,6.8,-2.65),t.lineTo(7.1,-5),t.lineTo(10.7,-5),t.lineTo(10.7,-1.55),t.lineTo(8.4,-1.1),t.quadraticCurveTo(7.2,-.95,7,.35),t.quadraticCurveTo(7.2,1.7,8.5,1.75),t.lineTo(10.7,2.1),t.lineTo(10.7,5.6),t.lineTo(7.1,5.6),t.lineTo(6.8,3.1),t.quadraticCurveTo(6.6,1.8,5.35,1.7),t.quadraticCurveTo(4.6,1.8,4.3,2.3),t.lineTo(3.95,3.15),t.lineTo(3.5,5.6),t.lineTo(0,5.6),t.lineTo(0,2.1),t.lineTo(2.25,1.65),t.quadraticCurveTo(3.6,1.5,3.7,.2),t.quadraticCurveTo(3.65,-.55,3.1,-.9),t.lineTo(2.25,-1.25),t.lineTo(0,-1.55),t.lineTo(0,-5),t.lineTo(3.5,-5),t.lineTo(3.9,-2.6),t.fill(),t.restore();break}case At.DoubleFlat:{t.save(),t.translate(e,s);const l=a/12;t.scale(l,l),t.translate(-4,0),t.beginPath(),t.moveTo(7.95,-20),t.lineTo(7.95,-4.3),t.quadraticCurveTo(9.5,-5.65,11.5,-5.8),t.quadraticCurveTo(12.75,-5.8,13.7,-4.8),t.quadraticCurveTo(14.65,-3.85,14.7,-2.45),t.quadraticCurveTo(14.55,-.65,13.3,.7),t.quadraticCurveTo(12.05,2.05,10.7,3.05),t.quadraticCurveTo(8.55,4.85,6.7,6.8),t.lineTo(6.7,.4),t.lineTo(3.95,3.05),t.lineTo(0,6.8),t.lineTo(0,-20),t.lineTo(1.25,-20),t.lineTo(1.25,-4.3),t.quadraticCurveTo(2.75,-5.65,4.75,-5.8),t.quadraticCurveTo(5.85,-5.8,6.7,-5),t.lineTo(6.7,-20),t.lineTo(7.95,-20),t.moveTo(3.4,-4.25),t.quadraticCurveTo(2.7,-4.3,2,-3.65),t.quadraticCurveTo(1.3,-2.95,1.25,-2.5),t.lineTo(1.25,4.2),t.lineTo(3.6,1.3),t.quadraticCurveTo(4.85,-.4,4.95,-2.1),t.quadraticCurveTo(4.8,-4,3.4,-4.25),t.moveTo(7.95,-2.5),t.lineTo(7.95,4.2),t.lineTo(10.35,1.3),t.quadraticCurveTo(11.6,-.4,11.7,-2.1),t.quadraticCurveTo(11.6,-4,10.15,-4.25),t.quadraticCurveTo(9.45,-4.3,8.75,-3.65),t.lineTo(7.95,-2.5),t.fill("evenodd"),t.restore();break}}t.restore()}function Tn(t,e,s,i,n,r,a="Standard"){t.save(),t.fillStyle="#000";const l=a==="Jazz"?'"Patrick Hand", cursive':"serif";t.font=`bold ${r*2.5}px ${l}`,t.textAlign="center",t.textBaseline="middle",t.fillText(String(i),e,s-r),t.fillText(String(n),e,s+r),t.restore()}function ji(t,e,s,i,n,r){if(i===0)return;const a=i>0,l=Math.abs(i),c=a?At.Sharp:At.Flat,h=n===ft.Treble?[4,1,5,2,-1,3,0]:[2,-1,3,0,-3,1,-2],d=n===ft.Treble?[0,3,-1,2,-2,1,-3]:[-2,1,-3,0,-4,-1,-5],p=a?h:d;for(let y=0;y<l&&y<7;y++){const S=e+y*r*.9,I=s-p[y]*r*.5;bn(t,S,I,c,r)}}function Qr(t,e,s,i,n,r="#000",a="Standard"){t.save(),t.fillStyle=r;const l=a==="Jazz"?'"Patrick Hand", cursive':'"Times New Roman", Times, serif',c=a==="Jazz"?"normal":"italic bold";t.font=`${c} ${n*2.2}px ${l}`,t.textAlign="center",t.textBaseline="middle",t.fillText(i,e,s),t.restore()}function bs(t,e,s,i,n,r,a,l=.8,c="#000"){t.save(),t.strokeStyle=c,t.lineWidth=a*.12,t.beginPath(),t.moveTo(e,s);const h=i-e,d=a*l,p=r==="up"?-1:1,y=e+h/3,S=i-h/3,I=s+d*p,m=n+d*p;t.bezierCurveTo(y,I,S,m,i,n),t.stroke(),t.restore()}class Ur{constructor(e,s,i,n=-1,r=1,a="Standard",l={fontFamily:"serif",fontSize:16,fontWeight:"bold",fontStyle:"normal"},c=40,h=1,d=1,p=10){this.ctx=e,this.staffLineSpacing=s,this.clefWidth=i,this.trebleClefYOffset=n,this.bassClefYOffset=r,this.musicFont=a,this.tempoStyle=l,this.clefKeySignatureSpacing=c,this.bassClefScale=h,this.trebleClefScale=d,this.clefLeftPadding=p}drawStaffLines(e){const{x:s,y:i,width:n}=e,r=this.staffLineSpacing;this.ctx.save(),this.ctx.strokeStyle="#000",this.ctx.lineWidth=r*.08;const a=s-this.clefWidth,l=e.staff.lineCount,c=(l-1)/2;for(let h=0;h<l;h++){const d=i+(h-c)*r;this.ctx.beginPath(),this.ctx.moveTo(a,d),this.ctx.lineTo(s+n,d),this.ctx.stroke()}this.ctx.restore()}drawClef(e){const s=e.y,n=e.x-this.clefWidth+this.clefLeftPadding;switch(e.clef){case ft.Treble:mn(this.ctx,n,s,this.staffLineSpacing,this.trebleClefYOffset,this.trebleClefScale);break;case ft.Bass:xn(this.ctx,n,s,this.staffLineSpacing,this.bassClefYOffset,this.bassClefScale);break;case ft.Alto:Fs(this.ctx,n,s,this.staffLineSpacing,0);break;case ft.Tenor:Fs(this.ctx,n,s,this.staffLineSpacing,2);break;case ft.Percussion:yn(this.ctx,n,s,this.staffLineSpacing);break;case ft.Tab:this.drawTabClef(n,s,e.staff.lineCount);break}}drawTabClef(e,s,i){const n=this.staffLineSpacing,r=(i-1)/2;this.ctx.save(),this.ctx.font=`bold ${n*1.5}px sans-serif`,this.ctx.textAlign="center",this.ctx.textBaseline="middle";const a=s-r*n,c=s+r*n-a;this.ctx.fillText("T",e+10,a+c*.2),this.ctx.fillText("A",e+10,a+c*.5),this.ctx.fillText("B",e+10,a+c*.8),this.ctx.restore()}drawTimeSignature(e,s,i){const n=e.y,a=e.x-this.clefWidth+this.clefLeftPadding,l=e.maxClefWidth||this.getClefWidth(e.clef),c=i?e.maxKeySignatureWidth||this.getKeySignatureWidth(i.fifths):0,h=c>0?this.clefKeySignatureSpacing:0,p=a+l+h+c+1.25*this.staffLineSpacing;Tn(this.ctx,p,n,s.beats,s.beatType,this.staffLineSpacing,this.musicFont)}drawKeySignature(e,s){const i=e.y,r=e.x-this.clefWidth+this.clefLeftPadding,a=e.maxClefWidth||this.getClefWidth(e.clef),l=r+a+this.clefKeySignatureSpacing;return ji(this.ctx,l,i,s.fifths,e.clef,this.staffLineSpacing),this.getKeySignatureWidth(s.fifths)}getClefWidth(e){const s=this.staffLineSpacing;return e===ft.Treble?25*(s*5.5/41.64*.6*this.trebleClefScale):e===ft.Bass?28*(s*3.5/30*this.bassClefScale):e===ft.Alto||e===ft.Tenor?s*2.5:s*2}getKeySignatureWidth(e){return e===0?0:(Math.abs(e)-1)*this.staffLineSpacing*.9+this.staffLineSpacing*.8}drawKeySignatureAt(e,s,i,n){ji(this.ctx,e,s,i,n,this.staffLineSpacing)}drawTimeSignatureAt(e,s,i,n){Tn(this.ctx,e,s,i,n,this.staffLineSpacing,this.musicFont)}drawSystemBarlines(e,s){if(e.length===0)return;const i=e[0],n=e[e.length-1],r=i.y-this.staffLineSpacing*2,a=n.y+this.staffLineSpacing*2;this.ctx.save(),this.ctx.strokeStyle="#000",this.ctx.lineWidth=this.staffLineSpacing*.08;const l=i.measureLayouts[0];l&&l.measure.repeats.some(h=>h.type==="start")&&this.drawRepeatBarline(e,"start",i.x);for(let h=0;h<i.measureLayouts.length;h++){const d=i.measureLayouts[h],p=d.x+d.width,y=i.measureLayouts[h+1],S=d.measure.repeats.some(m=>m.type==="end"),I=y&&y.measure.repeats.some(m=>m.type==="start");if(S&&I)this.drawRepeatBarline(e,"end",p),this.drawRepeatBarline(e,"start",p);else if(S)this.drawRepeatBarline(e,"end",p);else if(I)this.drawRepeatBarline(e,"start",p);else if(s!==void 0&&d.measureNumber===s){const m=this.staffLineSpacing;this.ctx.beginPath(),this.ctx.lineWidth=m*.08,this.ctx.moveTo(p-m*.4,r),this.ctx.lineTo(p-m*.4,a),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.lineWidth=m*.4,this.ctx.moveTo(p,r),this.ctx.lineTo(p,a),this.ctx.stroke()}else this.ctx.beginPath(),this.ctx.moveTo(p,r),this.ctx.lineTo(p,a),this.ctx.stroke();d.measure.volta&&this.drawVolta(e[0],d)}this.ctx.restore()}drawRepeatBarline(e,s,i){const n=e[0],r=e[e.length-1],a=n.y-this.staffLineSpacing*2,l=r.y+this.staffLineSpacing*2,c=this.staffLineSpacing;if(this.ctx.save(),this.ctx.strokeStyle="#000",this.ctx.fillStyle="#000",s==="start"){this.ctx.lineWidth=c*.33,this.ctx.beginPath(),this.ctx.moveTo(i,a),this.ctx.lineTo(i,l),this.ctx.stroke(),this.ctx.lineWidth=c*.08,this.ctx.beginPath(),this.ctx.moveTo(i+.5*c,a),this.ctx.lineTo(i+.5*c,l),this.ctx.stroke();for(const h of e)this.ctx.beginPath(),this.ctx.arc(i+1*c,h.y-c*.5,c*.15,0,Math.PI*2),this.ctx.arc(i+1*c,h.y+c*.5,c*.15,0,Math.PI*2),this.ctx.fill()}else{for(const h of e)this.ctx.beginPath(),this.ctx.arc(i-1*c,h.y-c*.5,c*.15,0,Math.PI*2),this.ctx.arc(i-1*c,h.y+c*.5,c*.15,0,Math.PI*2),this.ctx.fill();this.ctx.lineWidth=c*.08,this.ctx.beginPath(),this.ctx.moveTo(i-.5*c,a),this.ctx.lineTo(i-.5*c,l),this.ctx.stroke(),this.ctx.lineWidth=c*.33,this.ctx.beginPath(),this.ctx.moveTo(i,a),this.ctx.lineTo(i,l),this.ctx.stroke()}this.ctx.restore()}drawVolta(e,s){const{x:i,width:n}=s,r=e.y-this.staffLineSpacing*4,a=this.staffLineSpacing,l=s.measure.volta;this.ctx.save(),this.ctx.strokeStyle="#000",this.ctx.fillStyle="#000",this.ctx.lineWidth=1,this.ctx.font=`bold ${a*.9}px ${this.musicFont==="Jazz"?'"Patrick Hand", cursive':"serif"}`,l.type==="start"?(this.ctx.beginPath(),this.ctx.moveTo(i,r+a*.8),this.ctx.lineTo(i,r),this.ctx.lineTo(i+n,r),this.ctx.stroke(),this.ctx.fillText(l.number.toString()+".",i+5,r+a*.8)):(this.ctx.beginPath(),this.ctx.moveTo(i,r),this.ctx.lineTo(i+n,r),this.ctx.lineTo(i+n,r+a*.8),this.ctx.stroke()),this.ctx.restore()}drawLedgerLines(e,s,i){if(Math.abs(s)<5)return;const n=this.staffLineSpacing,r=n*1.6;if(this.ctx.save(),this.ctx.strokeStyle="#000",this.ctx.lineWidth=n*.08,s>=5)for(let a=6;a<=s+.1;a+=2){const l=i-a*n/2;this.ctx.beginPath(),this.ctx.moveTo(e-r/2,l),this.ctx.lineTo(e+r/2,l),this.ctx.stroke()}else if(s<=-5)for(let a=-6;a>=s-.1;a-=2){const l=i-a*n/2;this.ctx.beginPath(),this.ctx.moveTo(e-r/2,l),this.ctx.lineTo(e+r/2,l),this.ctx.stroke()}this.ctx.restore()}drawTempoMarking(e,s,i,n=!1,r){const a=e.y,l=r!==void 0?r:e.x-this.clefWidth+10,c=a-this.staffLineSpacing*5;this.ctx.save(),this.ctx.fillStyle="#000",this.ctx.textAlign="left",this.ctx.textBaseline="middle";const d=this.musicFont==="Jazz"?'"Patrick Hand", cursive':this.tempoStyle.fontFamily,p=this.tempoStyle.fontSize;this.ctx.font=`${this.tempoStyle.fontWeight} ${this.tempoStyle.fontStyle} ${p}px ${d}`,vn(this.ctx,l+this.staffLineSpacing,c,i,this.staffLineSpacing),n&&(this.ctx.beginPath(),this.ctx.arc(l+this.staffLineSpacing*2.2,c,this.staffLineSpacing*.2,0,Math.PI*2),this.ctx.fill());const y=this.staffLineSpacing*3.5;this.ctx.beginPath(),this.ctx.moveTo(l+this.staffLineSpacing+this.staffLineSpacing*.6,c),this.ctx.lineTo(l+this.staffLineSpacing+this.staffLineSpacing*.6,c-y),this.ctx.lineWidth=1.5,this.ctx.stroke();const S=l+this.staffLineSpacing*(n?4.5:3.5);this.ctx.fillText(`= ${s}`,S,c),this.ctx.restore()}}class Xr{constructor(e,s,i=.8,n="none",r="Standard"){this.ctx=e,this.staffLineSpacing=s,this.noteDotDistance=i,this.noteNameMode=n,this.musicFont=r}drawNote(e,s=!1){const{note:i,x:n,y:r,staffPosition:a,stemDirection:l,stemEndY:c}=e,h=i.isGrace?this.staffLineSpacing*.7:this.staffLineSpacing,d=this.staffLineSpacing,p=i.color||"#000";if(i.isRest){Kr(this.ctx,n,r,i.duration,h,p);return}if(i.accidental&&bn(this.ctx,n-h*1.2,r,i.accidental,h,p),e.clef===ft.Tab&&i.fret!==void 0?this.drawFretNumber(n,r,i.fret,h,p):vn(this.ctx,n,r,i.duration,h,p,i.notehead),i.isDotted&&Vr(this.ctx,n,r,h,this.noteDotDistance,p),i.duration!==P.Whole&&!s&&(this.drawStem(n,r,c,l,i.isGrace,p),i.beamGroup===void 0&&i.isBeamable()&&Yr(this.ctx,n+(l==="up"?h*.5:-h*.5),c,l,i.duration,h,p),i.isGrace&&i.duration===P.Eighth&&this.drawGraceSlash(n,c,l,p)),i.articulation&&this.drawArticulation(n,r,i.articulation,l,h,p),i.dynamic){const k=r+a*d/2+d*4.5;Qr(this.ctx,n,k,i.dynamic,d,p)}const y=r+a*d/2;i.lyrics&&i.lyrics.length>0?i.lyrics.forEach((m,k)=>{m&&this.drawLyric(n,y,m,k)}):i.lyric&&this.drawLyric(n,y,i.lyric,0),i.staffText&&this.drawStaffText(n,y,i.staffText);const S=r+a*d/2;let I=4.5;if(i.fretboardDiagram&&(this.drawFretboardDiagram(n,S,i.fretboardDiagram),I+=5),i.chord&&this.drawChordSymbol(n,S,i.chord,I),this.noteNameMode!=="none"&&this.drawNoteName(e),i.arpeggio&&this.drawArpeggio(n,r,4,i.arpeggio,p),i.ornament&&this.drawOrnament(n,r,i.ornament,d,p),i.bowing){const k=r-a*d/2-d*2.5;Hr(this.ctx,n,k,i.bowing,d,p)}if(i.fingering!==void 0){const k=r-a*d/2-d*3.5;this.drawFingering(n,k,i.fingering,d,p)}}drawFingering(e,s,i,n,r){this.ctx.save(),this.ctx.fillStyle=r,this.ctx.font=`bold ${n*.9}px sans-serif`,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(i.toString(),e,s),this.ctx.restore()}drawFretNumber(e,s,i,n,r="#000"){this.ctx.save();const a=n*1.2;this.ctx.font=`bold ${a}px sans-serif`;const l=i.toString(),c=this.ctx.measureText(l),h=n*.16;this.ctx.fillStyle="#fff",this.ctx.fillRect(e-c.width/2-h,s-a/2-h,c.width+h*2,a+h*2),this.ctx.fillStyle=r,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(l,e,s),this.ctx.restore()}drawLyric(e,s,i,n=0){const r=this.staffLineSpacing;this.ctx.save(),this.ctx.fillStyle="#000";const a=this.musicFont==="Jazz"?'"Patrick Hand", cursive':"serif";this.ctx.font=`bold ${r*1.05}px ${a}`,this.ctx.textAlign="center",this.ctx.textBaseline="top";const l=n*r*1.5;this.ctx.fillText(i,e,s+r*8+l),this.ctx.restore()}drawChordSymbol(e,s,i,n=4.5){const r=this.staffLineSpacing;this.ctx.save(),this.ctx.fillStyle="#000";const a=this.musicFont==="Jazz"?'"Patrick Hand", cursive':"serif";this.ctx.font=`bold ${r*1.2}px ${a}`,this.ctx.textAlign="center",this.ctx.textBaseline="bottom",this.ctx.fillText(i,e,s-r*n),this.ctx.restore()}drawFretboardDiagram(e,s,i){const n=this.staffLineSpacing;this.ctx.save(),this.ctx.strokeStyle="#000",this.ctx.fillStyle="#000",this.ctx.lineWidth=1;const r=i.strings||6,a=i.frets||5,l=n*.6,c=n*.8,h=(r-1)*l,d=a*c,p=s-n*5,y=p-d,S=e-h/2;for(let m=0;m<r;m++)this.ctx.beginPath(),this.ctx.moveTo(S+m*l,y),this.ctx.lineTo(S+m*l,p),this.ctx.stroke();for(let m=0;m<=a;m++){this.ctx.beginPath(),m===0&&(i.startingFret===void 0||i.startingFret===1)?this.ctx.lineWidth=n*.25:this.ctx.lineWidth=n*.08;const k=y+m*c;this.ctx.moveTo(S,k),this.ctx.lineTo(S+h,k),this.ctx.stroke()}i.startingFret&&i.startingFret>1&&(this.ctx.font=`${n*.8}px sans-serif`,this.ctx.textAlign="right",this.ctx.textBaseline="top",this.ctx.fillText(`${i.startingFret}fr`,S-n*.33,y));const I=l*.35;i.dots.forEach(m=>{const k=S+(r-m.string)*l,E=y+(m.fret-.5)*c;this.ctx.beginPath(),this.ctx.arc(k,E,I,0,Math.PI*2),this.ctx.fill(),m.label&&(this.ctx.save(),this.ctx.fillStyle="#fff",this.ctx.font=`${n*.66}px sans-serif`,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(m.label,k,E),this.ctx.restore())}),i.openStrings&&i.openStrings.forEach(m=>{const k=S+(r-m)*l,E=y-I*2;this.ctx.beginPath(),this.ctx.arc(k,E,I*.8,0,Math.PI*2),this.ctx.stroke()}),i.mutedStrings&&i.mutedStrings.forEach(m=>{const k=S+(r-m)*l,E=y-I*2;this.ctx.beginPath(),this.ctx.moveTo(k-n*.25,E-n*.25),this.ctx.lineTo(k+n*.25,E+n*.25),this.ctx.moveTo(k+n*.25,E-n*.25),this.ctx.lineTo(k-n*.25,E+n*.25),this.ctx.stroke()}),i.barres&&i.barres.forEach(m=>{const k=S+(r-m.startString)*l,E=S+(r-m.endString)*l,Y=Math.min(k,E),R=Math.max(k,E),O=y+(m.fret-.5)*c;this.ctx.lineWidth=I*1.5,this.ctx.lineCap="round",this.ctx.beginPath(),this.ctx.moveTo(Y,O),this.ctx.lineTo(R,O),this.ctx.stroke(),this.ctx.lineCap="butt"}),this.ctx.restore()}drawNoteName(e){const{note:s,x:i,y:n,staffPosition:r}=e;if(!s.pitch)return;const a=this.staffLineSpacing,l=this.musicFont==="Jazz"?'"Patrick Hand", cursive':"sans-serif";this.ctx.save(),this.ctx.fillStyle="#666",this.ctx.font=`bold ${a*.8}px ${l}`,this.ctx.textAlign="center",this.ctx.textBaseline="bottom";const h=n+r*a/2-a*3.5;let d="";const p=s.pitch.getNoteName().charAt(0);this.noteNameMode==="alphabetical"?d=p:this.noteNameMode==="solfege"&&(d={C:"Do",D:"Re",E:"Mi",F:"Fa",G:"Sol",A:"La",B:"Si"}[p]||p),this.ctx.fillText(d,i,h),this.ctx.restore()}drawStem(e,s,i,n,r=!1,a="#000"){const l=r?this.staffLineSpacing*.7:this.staffLineSpacing,c=e+(n==="up"?l*.5:-l*.5),h=l*.5,d=n==="up"?s-h:s+h;this.ctx.save(),this.ctx.strokeStyle=a,this.ctx.lineWidth=r?1:1.5,this.ctx.beginPath(),this.ctx.moveTo(c,d),this.ctx.lineTo(c,i),this.ctx.stroke(),this.ctx.restore()}drawStaffText(e,s,i){const n=this.staffLineSpacing;this.ctx.save();const a=this.musicFont==="Jazz"?'"Patrick Hand", cursive':"serif",l=n*1.1;this.ctx.font=`italic ${l}px ${a}`,this.ctx.fillStyle="#000",this.ctx.textAlign="left",this.ctx.textBaseline="bottom",this.ctx.fillText(i,e,s-n*5),this.ctx.restore()}drawGraceSlash(e,s,i,n="#000"){const r=this.staffLineSpacing*.7,a=e+(i==="up"?r*.5:-r*.5);this.ctx.save(),this.ctx.strokeStyle=n,this.ctx.lineWidth=1,this.ctx.beginPath(),i==="up"?(this.ctx.moveTo(a-r*.8,s+r*.4),this.ctx.lineTo(a+r*.8,s-r*.4)):(this.ctx.moveTo(a-r*.8,s-r*.4),this.ctx.lineTo(a+r*.8,s+r*.4)),this.ctx.stroke(),this.ctx.restore()}drawBeamGroup(e){if(e.length<2)return;const s=this.staffLineSpacing,n=e.reduce((S,I)=>S+I.staffPosition,0)/e.length>=0?"down":"up";let r;n==="up"?r=Math.min(...e.map(S=>S.stemEndY)):r=Math.max(...e.map(S=>S.stemEndY));const a=s*.5,l=s*.3,c=e[0],h=e[e.length-1],d=n==="up"?s*.5:-s*.5,p=c.note.color||"#000";this.ctx.save(),this.ctx.fillStyle=p,this.ctx.beginPath(),this.ctx.moveTo(c.x+d,r),this.ctx.lineTo(h.x+d,r),this.ctx.lineTo(h.x+d,r+(n==="up"?a:-a)),this.ctx.lineTo(c.x+d,r+(n==="up"?a:-a)),this.ctx.closePath(),this.ctx.fill(),[P.Sixteenth,P.ThirtySecond,P.SixtyFourth,P.OneHundredTwentyEighth,P.TwoHundredFiftySixth].forEach((S,I)=>{const m=e.filter(k=>{const E=Je[k.note.duration],Y=Je[S];return E<=Y});if(m.length>0){const k=m[0],E=m[m.length-1],Y=n==="up"?r+(I+1)*(a+l):r-(I+1)*(a+l);this.ctx.beginPath(),this.ctx.moveTo(k.x+d,Y),this.ctx.lineTo(E.x+d,Y),this.ctx.lineTo(E.x+d,Y+(n==="up"?a:-a)),this.ctx.lineTo(k.x+d,Y+(n==="up"?a:-a)),this.ctx.closePath(),this.ctx.fill()}}),this.ctx.lineWidth=1.5;for(const S of e){const I=S.note.isGrace?s*.7:s,m=I*.5,k=n==="up"?S.y-m:S.y+m,E=S.note.color||"#000";this.ctx.strokeStyle=E,this.ctx.beginPath(),this.ctx.moveTo(S.x+(n==="up"?I*.5:-I*.5),k),this.ctx.lineTo(S.x+(n==="up"?I*.5:-I*.5),r),this.ctx.stroke(),S.stemEndY=r,this.drawNote(S,!0)}this.ctx.restore()}drawMeasureNotes(e){const{noteLayouts:s}=e,i=new Map,n=[];for(const r of s)r.note.beamGroup!==void 0?(i.has(r.note.beamGroup)||i.set(r.note.beamGroup,[]),i.get(r.note.beamGroup).push(r)):n.push(r);for(const r of i.values())this.drawBeamGroup(r);for(const r of n)this.drawNote(r)}drawStaffConnections(e){var n,r,a;const i=[...e.measureLayouts.flatMap(l=>l.noteLayouts)].sort((l,c)=>l.x-c.x);for(let l=0;l<i.length;l++){const c=i[l];if(c.note.tie){const h=i.slice(l+1).find(y=>!y.note.isRest&&y.note.pitch&&c.note.pitch&&y.note.pitch.midiNumber===c.note.pitch.midiNumber),d=c.stemDirection==="up"?"down":"up",p=c.x+this.staffLineSpacing*.5;if(h){const y=h.x-this.staffLineSpacing*.5;bs(this.ctx,p,c.y,y,h.y,d,this.staffLineSpacing,.5,c.note.color||"#000")}else{const y=e.x+e.width;bs(this.ctx,p,c.y,y,c.y,d,this.staffLineSpacing,.3,c.note.color||"#000")}}if(((n=c.note.slur)==null?void 0:n.placement)==="start"){const h=i.findIndex((y,S)=>{var I;return S>l&&((I=y.note.slur)==null?void 0:I.placement)==="stop"}),d=this.staffLineSpacing*.6,p=c.stemDirection==="up"?c.y+d:c.y-d;if(h!==-1){const y=i[h];let m=i.slice(l,h+1).every(E=>E.stemDirection==="up")?"down":"up";(r=c.note.slur)!=null&&r.direction&&(m=c.note.slur.direction);const k=y.stemDirection==="up"?y.y+d:y.y-d;bs(this.ctx,c.x,p,y.x,k,m,this.staffLineSpacing,.7,c.note.color||"#000")}else{const y=e.x+e.width;bs(this.ctx,c.x,p,y,p,"up",this.staffLineSpacing,.4,c.note.color||"#000")}}else if(((a=c.note.slur)==null?void 0:a.placement)==="stop"&&i.findIndex((d,p)=>{var y;return p<l&&((y=d.note.slur)==null?void 0:y.placement)==="start"})===-1){const d=this.staffLineSpacing*.6,p=e.x-1.66*this.staffLineSpacing,y=c.stemDirection==="up"?c.y+d:c.y-d;bs(this.ctx,p,y,c.x,y,"up",this.staffLineSpacing,.4,c.note.color||"#000")}if(c.note.tuplet&&c.note.tuplet.type==="start"){const h=i.findIndex((d,p)=>p>l&&d.note.tuplet&&d.note.tuplet.type==="stop");if(h!==-1){const d=i.slice(l,h+1);this.drawTupletGroup(d)}}if(c.note.hairpin&&c.note.hairpin.placement==="start"){const h=i.findIndex((p,y)=>y>l&&p.note.hairpin&&p.note.hairpin.placement==="stop"&&p.note.hairpin.type===c.note.hairpin.type),d=c.y+this.staffLineSpacing*6;if(h!==-1){const p=i[h];this.drawHairpin(c.x,p.x,d,c.note.hairpin.type,c.note.color||"#000")}else{const p=e.x+e.width;this.drawHairpin(c.x,p,d,c.note.hairpin.type,c.note.color||"#000")}}else if(c.note.hairpin&&c.note.hairpin.placement==="stop"&&i.findIndex((d,p)=>p<l&&d.note.hairpin&&d.note.hairpin.placement==="start"&&d.note.hairpin.type===c.note.hairpin.type)===-1){const d=e.x-20,p=c.y+this.staffLineSpacing*6;this.drawHairpin(d,c.x,p,c.note.hairpin.type,c.note.color||"#000")}if(c.note.glissando&&c.note.glissando.placement==="start"){const h=i.findIndex((d,p)=>p>l&&d.note.glissando&&d.note.glissando.placement==="stop");if(h!==-1){const d=i[h];this.drawGlissLine(c.x,c.y,d.x,d.y,c.note.glissando.type,c.note.color||"#000")}else{const d=e.x+e.width;this.drawGlissLine(c.x,c.y,d,c.y,c.note.glissando.type,c.note.color||"#000")}}else if(c.note.glissando&&c.note.glissando.placement==="stop"&&i.findIndex((d,p)=>p<l&&d.note.glissando&&d.note.glissando.placement==="start")===-1){const d=e.x;this.drawGlissLine(d,c.y,c.x,c.y,c.note.glissando.type,c.note.color||"#000")}if(c.note.ottava&&c.note.ottava.placement==="start"){const h=i.findIndex((p,y)=>y>l&&p.note.ottava&&p.note.ottava.placement==="stop"),d=c.note.ottava.type===Fe.OttavaAlta||c.note.ottava.type===Fe.QuindicesimaAlta?e.y-this.staffLineSpacing*6:e.y+this.staffLineSpacing*9;if(h!==-1){const p=i[h];this.drawOttavaLine(c.x,p.x,d,c.note.ottava.type,c.note.color||"#000")}else{const p=e.x+e.width;this.drawOttavaLine(c.x,p,d,c.note.ottava.type,c.note.color||"#000")}}else if(c.note.ottava&&c.note.ottava.placement==="stop"&&i.findIndex((d,p)=>p<l&&d.note.ottava&&d.note.ottava.placement==="start")===-1){const d=c.note.ottava.type===Fe.OttavaAlta||c.note.ottava.type===Fe.QuindicesimaAlta?e.y-this.staffLineSpacing*6:e.y+this.staffLineSpacing*9,p=e.x;this.drawOttavaLine(p,c.x,d,c.note.ottava.type,c.note.color||"#000")}if(c.note.pedal&&c.note.pedal.placement==="start"){const h=i.findIndex((p,y)=>y>l&&p.note.pedal&&p.note.pedal.placement==="stop"),d=e.y+this.staffLineSpacing*12;if(h!==-1){const p=i[h];this.drawPedalLine(c.x,p.x,d,c.note.color||"#000")}else{const p=e.x+e.width;this.drawPedalLine(c.x,p,d,c.note.color||"#000")}}else if(c.note.pedal&&c.note.pedal.placement==="stop"&&i.findIndex((d,p)=>p<l&&d.note.pedal&&d.note.pedal.placement==="start")===-1){const d=e.y+this.staffLineSpacing*12,p=e.x;this.drawPedalLine(p,c.x,d,c.note.color||"#000")}}}drawHairpin(e,s,i,n,r="#000"){const a=this.staffLineSpacing*1.2;this.ctx.save(),this.ctx.strokeStyle=r,this.ctx.lineWidth=1.2,this.ctx.beginPath(),n==="crescendo"?(this.ctx.moveTo(s,i-a/2),this.ctx.lineTo(e,i),this.ctx.lineTo(s,i+a/2)):(this.ctx.moveTo(e,i-a/2),this.ctx.lineTo(s,i),this.ctx.lineTo(e,i+a/2)),this.ctx.stroke(),this.ctx.restore()}drawTupletGroup(e){var y;const s=e[0],i=e[e.length-1],n=this.staffLineSpacing,r=((y=s.note.tuplet)==null?void 0:y.actual)||3,a=s.note.color||"#000",c=e.every(S=>S.stemDirection==="up")?"up":"down",h=c==="up"?Math.min(...e.map(S=>S.stemEndY))-n*1:Math.max(...e.map(S=>S.stemEndY))+n*1;this.ctx.save(),this.ctx.strokeStyle=a,this.ctx.lineWidth=1,this.ctx.beginPath(),this.ctx.moveTo(s.x,h+(c==="up"?n*.5:-n*.5)),this.ctx.lineTo(s.x,h),this.ctx.lineTo(i.x,h),this.ctx.lineTo(i.x,h+(c==="up"?n*.5:-n*.5)),this.ctx.stroke(),this.ctx.fillStyle="#000";const d=this.musicFont==="Jazz"?'"Patrick Hand", cursive':"serif";this.ctx.font=`italic bold ${n*1.2}px ${d}`,this.ctx.textAlign="center",this.ctx.textBaseline="middle";const p=(s.x+i.x)/2;this.ctx.fillStyle="#fff",this.ctx.fillRect(p-n*.8,h-n*.8,n*1.6,n*1.6),this.ctx.fillStyle="#000",this.ctx.fillText(r.toString(),p,h),this.ctx.restore()}drawArticulation(e,s,i,n,r,a="#000"){const l=n==="up"?s+r*1.5:s-r*1.5;switch(this.ctx.save(),this.ctx.fillStyle=a,this.ctx.strokeStyle=a,this.ctx.lineWidth=1.2,i){case xe.Staccato:this.ctx.beginPath(),this.ctx.arc(e,l,r*.15,0,Math.PI*2),this.ctx.fill();break;case xe.Accent:this.ctx.beginPath(),this.ctx.moveTo(e-r*.4,l),this.ctx.lineTo(e,l+(n==="up"?r*.3:-r*.3)),this.ctx.lineTo(e+r*.4,l),this.ctx.stroke();break;case xe.Tenuto:this.ctx.beginPath(),this.ctx.moveTo(e-r*.4,l),this.ctx.lineTo(e+r*.4,l),this.ctx.lineWidth=1.5,this.ctx.stroke();break;case xe.Fermata:{const c=n==="up"?s+r*2:s-r*2,h=n==="down";this.ctx.beginPath(),h?this.ctx.arc(e,c+r*.3,r*.6,Math.PI,0,!1):this.ctx.arc(e,c-r*.3,r*.6,0,Math.PI,!1),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.arc(e,c,r*.1,0,Math.PI*2),this.ctx.fill();break}}this.ctx.restore()}drawGlissLine(e,s,i,n,r,a="#000"){if(this.ctx.save(),this.ctx.strokeStyle=a,this.ctx.lineWidth=1.2,r==="straight")this.ctx.beginPath(),this.ctx.moveTo(e+10,s),this.ctx.lineTo(i-10,n),this.ctx.stroke();else{const l=i-10-(e+10),c=n-s,h=Math.floor(l/5);this.ctx.beginPath(),this.ctx.moveTo(e+10,s);for(let d=0;d<=h;d++){const p=e+10+l*d/h,y=s+c*d/h+(d%2===0?3:-3);this.ctx.lineTo(p,y)}this.ctx.stroke()}this.ctx.restore()}drawArpeggio(e,s,i,n,r="#000"){this.ctx.save(),this.ctx.strokeStyle=r,this.ctx.lineWidth=1.2;const a=e-this.staffLineSpacing*1.2,l=this.staffLineSpacing,c=i*l,h=s-c/2,d=Math.floor(c/4);this.ctx.beginPath(),this.ctx.moveTo(a,h);for(let p=0;p<=d;p++){const y=h+c*p/d,S=a+(p%2===0?2:-2);this.ctx.lineTo(S,y)}if(this.ctx.stroke(),n===_e.Up||n===_e.Down){this.ctx.beginPath();const p=n===_e.Up?h:h+c,y=n===_e.Up?-4:4;this.ctx.moveTo(a-3,p+y),this.ctx.lineTo(a,p),this.ctx.lineTo(a+3,p+y),this.ctx.stroke()}this.ctx.restore()}drawOttavaLine(e,s,i,n,r="#000"){this.ctx.save(),this.ctx.fillStyle=r,this.ctx.strokeStyle=r,this.ctx.lineWidth=1;const a=this.musicFont==="Jazz"?'"Patrick Hand", cursive':"serif";this.ctx.font=`italic bold ${this.staffLineSpacing*1.5}px ${a}`,this.ctx.textBaseline="middle",this.ctx.fillText(n,e,i);const l=this.ctx.measureText(n).width;this.ctx.beginPath(),this.ctx.setLineDash([5,5]),this.ctx.moveTo(e+l+5,i),this.ctx.lineTo(s,i),this.ctx.lineTo(s,i+(n.includes("va")||n.includes("ma")?10:-10)),this.ctx.stroke(),this.ctx.restore()}drawPedalLine(e,s,i,n="#000"){this.ctx.save(),this.ctx.fillStyle=n,this.ctx.strokeStyle=n,this.ctx.lineWidth=1.2;const r=this.musicFont==="Jazz"?'"Patrick Hand", cursive':"serif";this.ctx.font=`italic bold ${this.staffLineSpacing*2}px ${r}`,this.ctx.textBaseline="middle",this.ctx.fillText("Ped.",e,i);const a=this.ctx.measureText("Ped.").width;this.ctx.beginPath(),this.ctx.moveTo(e+a+5,i+5),this.ctx.lineTo(s,i+5),this.ctx.lineTo(s,i-5),this.ctx.stroke(),this.ctx.restore()}drawOrnament(e,s,i,n,r="#000"){this.ctx.save(),this.ctx.strokeStyle=r,this.ctx.fillStyle=r,this.ctx.lineWidth=1.2;const a=s-n*2.5;switch(i){case Be.Trill:{this.ctx.font=`italic bold ${n*1.5}px serif`,this.ctx.fillText("tr",e-n*.5,a);break}case Be.Mordent:{this.ctx.beginPath(),this.ctx.moveTo(e-n*.5,a),this.ctx.lineTo(e-n*.2,a-3),this.ctx.lineTo(e,a),this.ctx.lineTo(e+n*.2,a-3),this.ctx.lineTo(e+n*.5,a),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.moveTo(e,a-5),this.ctx.lineTo(e,a+5),this.ctx.stroke();break}case Be.Turn:{this.ctx.beginPath(),this.ctx.arc(e-n*.3,a,n*.3,Math.PI,0,!1),this.ctx.arc(e+n*.3,a,n*.3,0,Math.PI,!1),this.ctx.stroke();break}}this.ctx.restore()}}class Sn{constructor(e,s={}){qt(this,"staffRenderer");qt(this,"noteRenderer");qt(this,"config");this.ctx=e,this.config=pn({...vs,...s}),this.staffRenderer=new Ur(e,this.config.staffLineSpacing,this.config.clefWidth,this.config.trebleClefYOffset,this.config.bassClefYOffset,this.config.musicFont,this.config.tempoStyle,this.config.clefKeySignatureSpacing,this.config.bassClefScale,this.config.trebleClefScale,this.config.clefLeftPadding),this.noteRenderer=new Xr(this.ctx,this.config.staffLineSpacing,this.config.noteDotDistance,this.config.noteNameMode,this.config.musicFont)}render(e,s,i=0){const n=s.pages[i];if(!n)return;this.ctx.fillStyle="#fff",this.ctx.fillRect(0,0,n.width,n.height),n.titleY!==void 0&&this.drawTitle(e,n);const r=i===0;n.systemLayouts.forEach((a,l)=>{const c=r&&l===0;this.staffRenderer.drawSystemBarlines(a.staffLayouts,e.getMeasureCount());for(const h of a.staffLayouts)this.staffRenderer.drawStaffLines(h),this.staffRenderer.drawClef(h),this.staffRenderer.drawKeySignature(h,h.keySignature),this.staffRenderer.drawTimeSignature(h,h.timeSignature,h.keySignature),c&&a.staffLayouts.indexOf(h)===0&&this.staffRenderer.drawTempoMarking(h,e.bpm,e.tempoDuration,e.tempoIsDotted||!1),this.renderStaffNotes(h,a.staffLayouts.indexOf(h)===0),this.noteRenderer.drawStaffConnections(h);a.staffLayouts.length>1&&this.drawSystemBrace(a.staffLayouts),this.config.showMeasureNumbers&&a.staffLayouts.length>0&&this.renderMeasureNumbers(a.staffLayouts[0]),this.config.showPartNames&&this.drawPartNames(e,a,c)})}drawPartNames(e,s,i){this.ctx.save();const r=this.config.musicFont==="Jazz"?'"Patrick Hand", cursive':"Georgia, serif";this.ctx.font=`italic 14px ${r}`,this.ctx.fillStyle="#000",this.ctx.textAlign="right",this.ctx.textBaseline="middle";let a=0;const l=this.config.staffLineSpacing,c=s.staffLayouts[0].x-this.config.clefWidth-1.66*l;for(const h of e.parts){const d=h.staves.length,p=s.staffLayouts.slice(a,a+d);if(p.length>0){const y=p[0],S=p[p.length-1],I=(y.y+S.y)/2,m=i?h.name:h.abbreviation||h.name.substring(0,3);this.ctx.fillText(m,c,I)}a+=d}this.ctx.restore()}renderMeasureNumbers(e){this.ctx.save(),this.ctx.fillStyle="#666";const i=this.config.musicFont==="Jazz"?'"Patrick Hand", cursive':"sans-serif";this.ctx.font=`italic 12px ${i}`,this.ctx.textAlign="center",this.ctx.textBaseline="bottom";const n=this.config.staffLineSpacing,r=e.y-4.5*n;for(let a=0;a<e.measureLayouts.length;a++){const l=e.measureLayouts[a],c=l.measureNumber;let h=!1;this.config.measureNumberMode==="system"?a===0&&c!==1&&(h=!0):this.config.measureNumberMode==="interval"?c!==1&&c%(this.config.measureNumberInterval||5)===0&&(h=!0):this.config.measureNumberMode==="measure"&&c!==1&&(h=!0),h&&this.ctx.fillText(c.toString(),l.x-.16*n,r)}this.ctx.restore()}drawTitle(e,s){if(s.titleY===void 0||s.composerY===void 0)return;this.ctx.save(),this.ctx.fillStyle="#000";const i=this.config.titleStyle,n=this.config.musicFont==="Jazz"?'"Patrick Hand", cursive':i.fontFamily;if(this.ctx.font=`${i.fontWeight} ${i.fontStyle} ${i.fontSize}px ${n}`,this.ctx.textAlign="center",this.ctx.fillText(e.title,s.width/2,s.titleY),s.subtitleY!==void 0&&e.subtitle){const c=this.config.subtitleStyle,h=this.config.musicFont==="Jazz"?'"Patrick Hand", cursive':c.fontFamily;this.ctx.font=`${c.fontWeight} ${c.fontStyle} ${c.fontSize}px ${h}`,this.ctx.textAlign="center",this.ctx.fillText(e.subtitle,s.width/2,s.subtitleY)}const r=this.config.composerStyle,a=this.config.musicFont==="Jazz"?'"Patrick Hand", cursive':r.fontFamily;this.ctx.font=`${r.fontWeight} ${r.fontStyle} ${r.fontSize}px ${a}`,this.ctx.textAlign="right";const l=s.width-this.config.marginRight;this.ctx.fillText(e.composer,l,s.composerY),s.lyricistY!==void 0&&e.lyricist&&(this.ctx.textAlign="left",this.ctx.fillText(e.lyricist,this.config.marginLeft,s.lyricistY)),s.copyrightY!==void 0&&e.copyright&&(this.ctx.textAlign="center",this.ctx.font=`italic 12px ${this.config.titleStyle.fontFamily}`,this.ctx.fillText(e.copyright,s.width/2,s.copyrightY)),this.ctx.restore()}renderStaffNotes(e,s){const i=e.y,n=e.clef;for(const r of e.measureLayouts){if(s&&r.measure.tempo&&this.staffRenderer.drawTempoMarking(e,r.measure.tempo.bpm,r.measure.tempo.duration,r.measure.tempo.isDotted,r.x),s&&r.measure.systemText&&this.drawSystemText(r.x,e.y,r.measure.systemText),s&&r.measure.rehearsalMark&&this.drawRehearsalMark(r.x,e.y,r.measure.rehearsalMark),r.measure.keySignature&&this.staffRenderer.drawKeySignatureAt(r.x+10,i,r.measure.keySignature.fifths,n),r.measure.timeSignature){const a=r.measure.keySignature?r.signatureWidth||40:10;this.staffRenderer.drawTimeSignatureAt(r.x+a,i,r.measure.timeSignature.beats,r.measure.timeSignature.beatType)}for(const a of r.noteLayouts)!a.note.isRest&&Math.abs(a.staffPosition)>2&&this.staffRenderer.drawLedgerLines(a.x,a.staffPosition,i);this.noteRenderer.drawMeasureNotes(r)}}drawSystemBrace(e){if(e.length<2)return;const s=e[0],i=e[e.length-1],n=s.y-this.config.staffLineSpacing*2,r=i.y+this.config.staffLineSpacing*2,a=this.config.staffLineSpacing,c=s.x-this.config.clefWidth-.41*a;this.ctx.save(),this.ctx.strokeStyle="#000",this.ctx.lineWidth=1.5,this.ctx.beginPath(),this.ctx.moveTo(c+5,n),this.ctx.lineTo(c,n),this.ctx.lineTo(c,r),this.ctx.lineTo(c+5,r),this.ctx.stroke(),this.ctx.restore()}drawSystemText(e,s,i){const n=this.config.staffLineSpacing;this.ctx.save();const a=this.config.musicFont==="Jazz"?'"Patrick Hand", cursive':"serif",l=n*1.3;this.ctx.font=`bold ${l}px ${a}`,this.ctx.fillStyle="#000",this.ctx.textAlign="left",this.ctx.textBaseline="bottom",this.ctx.fillText(i,e,s-n*6),this.ctx.restore()}drawRehearsalMark(e,s,i){const n=this.config.staffLineSpacing;this.ctx.save();const a=this.config.musicFont==="Jazz"?'"Patrick Hand", cursive':"serif",l=n*1.5;this.ctx.font=`bold ${l}px ${a}`;const h=this.ctx.measureText(i).width,d=l,p=n*.4,y=Math.max(h+p*2,n*2),S=d+p,I=e,m=s-n*6;this.ctx.strokeStyle="#000",this.ctx.lineWidth=1.5,this.ctx.strokeRect(I,m,y,S),this.ctx.fillStyle="#000",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(i,I+y/2,m+S/2+1),this.ctx.restore()}}const wn=t=>t,Jr=(()=>{let t=wn;return{configure(e){t=e},generate(e){return t(e)},reset(){t=wn}}})();function De(t,...e){const s=new URL(`https://mui.com/production-error/?code=${t}`);return e.forEach(i=>s.searchParams.append("args[]",i)),`Minified MUI error #${t}; visit ${s} for the full message.`}function qe(t){if(typeof t!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":De(7));return t.charAt(0).toUpperCase()+t.slice(1)}var Ei={exports:{}},qs={exports:{}},Dt={};/** @license React v16.13.1
23
+ * react-is.production.min.js
24
+ *
25
+ * Copyright (c) Facebook, Inc. and its affiliates.
26
+ *
27
+ * This source code is licensed under the MIT license found in the
28
+ * LICENSE file in the root directory of this source tree.
29
+ */var Cn;function Zr(){if(Cn)return Dt;Cn=1;var t=typeof Symbol=="function"&&Symbol.for,e=t?Symbol.for("react.element"):60103,s=t?Symbol.for("react.portal"):60106,i=t?Symbol.for("react.fragment"):60107,n=t?Symbol.for("react.strict_mode"):60108,r=t?Symbol.for("react.profiler"):60114,a=t?Symbol.for("react.provider"):60109,l=t?Symbol.for("react.context"):60110,c=t?Symbol.for("react.async_mode"):60111,h=t?Symbol.for("react.concurrent_mode"):60111,d=t?Symbol.for("react.forward_ref"):60112,p=t?Symbol.for("react.suspense"):60113,y=t?Symbol.for("react.suspense_list"):60120,S=t?Symbol.for("react.memo"):60115,I=t?Symbol.for("react.lazy"):60116,m=t?Symbol.for("react.block"):60121,k=t?Symbol.for("react.fundamental"):60117,E=t?Symbol.for("react.responder"):60118,Y=t?Symbol.for("react.scope"):60119;function R(M){if(typeof M=="object"&&M!==null){var q=M.$$typeof;switch(q){case e:switch(M=M.type,M){case c:case h:case i:case r:case n:case p:return M;default:switch(M=M&&M.$$typeof,M){case l:case d:case I:case S:case a:return M;default:return q}}case s:return q}}}function O(M){return R(M)===h}return Dt.AsyncMode=c,Dt.ConcurrentMode=h,Dt.ContextConsumer=l,Dt.ContextProvider=a,Dt.Element=e,Dt.ForwardRef=d,Dt.Fragment=i,Dt.Lazy=I,Dt.Memo=S,Dt.Portal=s,Dt.Profiler=r,Dt.StrictMode=n,Dt.Suspense=p,Dt.isAsyncMode=function(M){return O(M)||R(M)===c},Dt.isConcurrentMode=O,Dt.isContextConsumer=function(M){return R(M)===l},Dt.isContextProvider=function(M){return R(M)===a},Dt.isElement=function(M){return typeof M=="object"&&M!==null&&M.$$typeof===e},Dt.isForwardRef=function(M){return R(M)===d},Dt.isFragment=function(M){return R(M)===i},Dt.isLazy=function(M){return R(M)===I},Dt.isMemo=function(M){return R(M)===S},Dt.isPortal=function(M){return R(M)===s},Dt.isProfiler=function(M){return R(M)===r},Dt.isStrictMode=function(M){return R(M)===n},Dt.isSuspense=function(M){return R(M)===p},Dt.isValidElementType=function(M){return typeof M=="string"||typeof M=="function"||M===i||M===h||M===r||M===n||M===p||M===y||typeof M=="object"&&M!==null&&(M.$$typeof===I||M.$$typeof===S||M.$$typeof===a||M.$$typeof===l||M.$$typeof===d||M.$$typeof===k||M.$$typeof===E||M.$$typeof===Y||M.$$typeof===m)},Dt.typeOf=R,Dt}var Pt={};/** @license React v16.13.1
30
+ * react-is.development.js
31
+ *
32
+ * Copyright (c) Facebook, Inc. and its affiliates.
33
+ *
34
+ * This source code is licensed under the MIT license found in the
35
+ * LICENSE file in the root directory of this source tree.
36
+ */var In;function to(){return In||(In=1,process.env.NODE_ENV!=="production"&&function(){var t=typeof Symbol=="function"&&Symbol.for,e=t?Symbol.for("react.element"):60103,s=t?Symbol.for("react.portal"):60106,i=t?Symbol.for("react.fragment"):60107,n=t?Symbol.for("react.strict_mode"):60108,r=t?Symbol.for("react.profiler"):60114,a=t?Symbol.for("react.provider"):60109,l=t?Symbol.for("react.context"):60110,c=t?Symbol.for("react.async_mode"):60111,h=t?Symbol.for("react.concurrent_mode"):60111,d=t?Symbol.for("react.forward_ref"):60112,p=t?Symbol.for("react.suspense"):60113,y=t?Symbol.for("react.suspense_list"):60120,S=t?Symbol.for("react.memo"):60115,I=t?Symbol.for("react.lazy"):60116,m=t?Symbol.for("react.block"):60121,k=t?Symbol.for("react.fundamental"):60117,E=t?Symbol.for("react.responder"):60118,Y=t?Symbol.for("react.scope"):60119;function R(H){return typeof H=="string"||typeof H=="function"||H===i||H===h||H===r||H===n||H===p||H===y||typeof H=="object"&&H!==null&&(H.$$typeof===I||H.$$typeof===S||H.$$typeof===a||H.$$typeof===l||H.$$typeof===d||H.$$typeof===k||H.$$typeof===E||H.$$typeof===Y||H.$$typeof===m)}function O(H){if(typeof H=="object"&&H!==null){var Ut=H.$$typeof;switch(Ut){case e:var Ne=H.type;switch(Ne){case c:case h:case i:case r:case n:case p:return Ne;default:var Re=Ne&&Ne.$$typeof;switch(Re){case l:case d:case I:case S:case a:return Re;default:return Ut}}case s:return Ut}}}var M=c,q=h,it=l,ot=a,U=e,dt=d,st=i,g=I,L=S,$=s,Q=r,ct=n,bt=p,ht=!1;function It(H){return ht||(ht=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),_(H)||O(H)===c}function _(H){return O(H)===h}function x(H){return O(H)===l}function W(H){return O(H)===a}function z(H){return typeof H=="object"&&H!==null&&H.$$typeof===e}function Z(H){return O(H)===d}function yt(H){return O(H)===i}function G(H){return O(H)===I}function lt(H){return O(H)===S}function xt(H){return O(H)===s}function Ct(H){return O(H)===r}function pt(H){return O(H)===n}function Wt(H){return O(H)===p}Pt.AsyncMode=M,Pt.ConcurrentMode=q,Pt.ContextConsumer=it,Pt.ContextProvider=ot,Pt.Element=U,Pt.ForwardRef=dt,Pt.Fragment=st,Pt.Lazy=g,Pt.Memo=L,Pt.Portal=$,Pt.Profiler=Q,Pt.StrictMode=ct,Pt.Suspense=bt,Pt.isAsyncMode=It,Pt.isConcurrentMode=_,Pt.isContextConsumer=x,Pt.isContextProvider=W,Pt.isElement=z,Pt.isForwardRef=Z,Pt.isFragment=yt,Pt.isLazy=G,Pt.isMemo=lt,Pt.isPortal=xt,Pt.isProfiler=Ct,Pt.isStrictMode=pt,Pt.isSuspense=Wt,Pt.isValidElementType=R,Pt.typeOf=O}()),Pt}var kn;function jn(){return kn||(kn=1,process.env.NODE_ENV==="production"?qs.exports=Zr():qs.exports=to()),qs.exports}/*
37
+ object-assign
38
+ (c) Sindre Sorhus
39
+ @license MIT
40
+ */var Bi,En;function eo(){if(En)return Bi;En=1;var t=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;function i(r){if(r==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(r)}function n(){try{if(!Object.assign)return!1;var r=new String("abc");if(r[5]="de",Object.getOwnPropertyNames(r)[0]==="5")return!1;for(var a={},l=0;l<10;l++)a["_"+String.fromCharCode(l)]=l;var c=Object.getOwnPropertyNames(a).map(function(d){return a[d]});if(c.join("")!=="0123456789")return!1;var h={};return"abcdefghijklmnopqrst".split("").forEach(function(d){h[d]=d}),Object.keys(Object.assign({},h)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Bi=n()?Object.assign:function(r,a){for(var l,c=i(r),h,d=1;d<arguments.length;d++){l=Object(arguments[d]);for(var p in l)e.call(l,p)&&(c[p]=l[p]);if(t){h=t(l);for(var y=0;y<h.length;y++)s.call(l,h[y])&&(c[h[y]]=l[h[y]])}}return c},Bi}var Di,Bn;function Pi(){if(Bn)return Di;Bn=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Di=t,Di}var Mi,Dn;function Pn(){return Dn||(Dn=1,Mi=Function.call.bind(Object.prototype.hasOwnProperty)),Mi}var Ai,Mn;function so(){if(Mn)return Ai;Mn=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var e=Pi(),s={},i=Pn();t=function(r){var a="Warning: "+r;typeof console<"u"&&console.error(a);try{throw new Error(a)}catch{}}}function n(r,a,l,c,h){if(process.env.NODE_ENV!=="production"){for(var d in r)if(i(r,d)){var p;try{if(typeof r[d]!="function"){var y=Error((c||"React class")+": "+l+" type `"+d+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof r[d]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw y.name="Invariant Violation",y}p=r[d](a,d,c,l,null,e)}catch(I){p=I}if(p&&!(p instanceof Error)&&t((c||"React class")+": type specification of "+l+" `"+d+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof p+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),p instanceof Error&&!(p.message in s)){s[p.message]=!0;var S=h?h():"";t("Failed "+l+" type: "+p.message+(S??""))}}}}return n.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(s={})},Ai=n,Ai}var Oi,An;function io(){if(An)return Oi;An=1;var t=jn(),e=eo(),s=Pi(),i=Pn(),n=so(),r=function(){};process.env.NODE_ENV!=="production"&&(r=function(l){var c="Warning: "+l;typeof console<"u"&&console.error(c);try{throw new Error(c)}catch{}});function a(){return null}return Oi=function(l,c){var h=typeof Symbol=="function"&&Symbol.iterator,d="@@iterator";function p(_){var x=_&&(h&&_[h]||_[d]);if(typeof x=="function")return x}var y="<<anonymous>>",S={array:E("array"),bigint:E("bigint"),bool:E("boolean"),func:E("function"),number:E("number"),object:E("object"),string:E("string"),symbol:E("symbol"),any:Y(),arrayOf:R,element:O(),elementType:M(),instanceOf:q,node:dt(),objectOf:ot,oneOf:it,oneOfType:U,shape:g,exact:L};function I(_,x){return _===x?_!==0||1/_===1/x:_!==_&&x!==x}function m(_,x){this.message=_,this.data=x&&typeof x=="object"?x:{},this.stack=""}m.prototype=Error.prototype;function k(_){if(process.env.NODE_ENV!=="production")var x={},W=0;function z(yt,G,lt,xt,Ct,pt,Wt){if(xt=xt||y,pt=pt||lt,Wt!==s){if(c){var H=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw H.name="Invariant Violation",H}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var Ut=xt+":"+lt;!x[Ut]&&W<3&&(r("You are manually calling a React.PropTypes validation function for the `"+pt+"` prop on `"+xt+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),x[Ut]=!0,W++)}}return G[lt]==null?yt?G[lt]===null?new m("The "+Ct+" `"+pt+"` is marked as required "+("in `"+xt+"`, but its value is `null`.")):new m("The "+Ct+" `"+pt+"` is marked as required in "+("`"+xt+"`, but its value is `undefined`.")):null:_(G,lt,xt,Ct,pt)}var Z=z.bind(null,!1);return Z.isRequired=z.bind(null,!0),Z}function E(_){function x(W,z,Z,yt,G,lt){var xt=W[z],Ct=ct(xt);if(Ct!==_){var pt=bt(xt);return new m("Invalid "+yt+" `"+G+"` of type "+("`"+pt+"` supplied to `"+Z+"`, expected ")+("`"+_+"`."),{expectedType:_})}return null}return k(x)}function Y(){return k(a)}function R(_){function x(W,z,Z,yt,G){if(typeof _!="function")return new m("Property `"+G+"` of component `"+Z+"` has invalid PropType notation inside arrayOf.");var lt=W[z];if(!Array.isArray(lt)){var xt=ct(lt);return new m("Invalid "+yt+" `"+G+"` of type "+("`"+xt+"` supplied to `"+Z+"`, expected an array."))}for(var Ct=0;Ct<lt.length;Ct++){var pt=_(lt,Ct,Z,yt,G+"["+Ct+"]",s);if(pt instanceof Error)return pt}return null}return k(x)}function O(){function _(x,W,z,Z,yt){var G=x[W];if(!l(G)){var lt=ct(G);return new m("Invalid "+Z+" `"+yt+"` of type "+("`"+lt+"` supplied to `"+z+"`, expected a single ReactElement."))}return null}return k(_)}function M(){function _(x,W,z,Z,yt){var G=x[W];if(!t.isValidElementType(G)){var lt=ct(G);return new m("Invalid "+Z+" `"+yt+"` of type "+("`"+lt+"` supplied to `"+z+"`, expected a single ReactElement type."))}return null}return k(_)}function q(_){function x(W,z,Z,yt,G){if(!(W[z]instanceof _)){var lt=_.name||y,xt=It(W[z]);return new m("Invalid "+yt+" `"+G+"` of type "+("`"+xt+"` supplied to `"+Z+"`, expected ")+("instance of `"+lt+"`."))}return null}return k(x)}function it(_){if(!Array.isArray(_))return process.env.NODE_ENV!=="production"&&(arguments.length>1?r("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):r("Invalid argument supplied to oneOf, expected an array.")),a;function x(W,z,Z,yt,G){for(var lt=W[z],xt=0;xt<_.length;xt++)if(I(lt,_[xt]))return null;var Ct=JSON.stringify(_,function(Wt,H){var Ut=bt(H);return Ut==="symbol"?String(H):H});return new m("Invalid "+yt+" `"+G+"` of value `"+String(lt)+"` "+("supplied to `"+Z+"`, expected one of "+Ct+"."))}return k(x)}function ot(_){function x(W,z,Z,yt,G){if(typeof _!="function")return new m("Property `"+G+"` of component `"+Z+"` has invalid PropType notation inside objectOf.");var lt=W[z],xt=ct(lt);if(xt!=="object")return new m("Invalid "+yt+" `"+G+"` of type "+("`"+xt+"` supplied to `"+Z+"`, expected an object."));for(var Ct in lt)if(i(lt,Ct)){var pt=_(lt,Ct,Z,yt,G+"."+Ct,s);if(pt instanceof Error)return pt}return null}return k(x)}function U(_){if(!Array.isArray(_))return process.env.NODE_ENV!=="production"&&r("Invalid argument supplied to oneOfType, expected an instance of array."),a;for(var x=0;x<_.length;x++){var W=_[x];if(typeof W!="function")return r("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+ht(W)+" at index "+x+"."),a}function z(Z,yt,G,lt,xt){for(var Ct=[],pt=0;pt<_.length;pt++){var Wt=_[pt],H=Wt(Z,yt,G,lt,xt,s);if(H==null)return null;H.data&&i(H.data,"expectedType")&&Ct.push(H.data.expectedType)}var Ut=Ct.length>0?", expected one of type ["+Ct.join(", ")+"]":"";return new m("Invalid "+lt+" `"+xt+"` supplied to "+("`"+G+"`"+Ut+"."))}return k(z)}function dt(){function _(x,W,z,Z,yt){return $(x[W])?null:new m("Invalid "+Z+" `"+yt+"` supplied to "+("`"+z+"`, expected a ReactNode."))}return k(_)}function st(_,x,W,z,Z){return new m((_||"React class")+": "+x+" type `"+W+"."+z+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+Z+"`.")}function g(_){function x(W,z,Z,yt,G){var lt=W[z],xt=ct(lt);if(xt!=="object")return new m("Invalid "+yt+" `"+G+"` of type `"+xt+"` "+("supplied to `"+Z+"`, expected `object`."));for(var Ct in _){var pt=_[Ct];if(typeof pt!="function")return st(Z,yt,G,Ct,bt(pt));var Wt=pt(lt,Ct,Z,yt,G+"."+Ct,s);if(Wt)return Wt}return null}return k(x)}function L(_){function x(W,z,Z,yt,G){var lt=W[z],xt=ct(lt);if(xt!=="object")return new m("Invalid "+yt+" `"+G+"` of type `"+xt+"` "+("supplied to `"+Z+"`, expected `object`."));var Ct=e({},W[z],_);for(var pt in Ct){var Wt=_[pt];if(i(_,pt)&&typeof Wt!="function")return st(Z,yt,G,pt,bt(Wt));if(!Wt)return new m("Invalid "+yt+" `"+G+"` key `"+pt+"` supplied to `"+Z+"`.\nBad object: "+JSON.stringify(W[z],null," ")+`
41
+ Valid keys: `+JSON.stringify(Object.keys(_),null," "));var H=Wt(lt,pt,Z,yt,G+"."+pt,s);if(H)return H}return null}return k(x)}function $(_){switch(typeof _){case"number":case"string":case"undefined":return!0;case"boolean":return!_;case"object":if(Array.isArray(_))return _.every($);if(_===null||l(_))return!0;var x=p(_);if(x){var W=x.call(_),z;if(x!==_.entries){for(;!(z=W.next()).done;)if(!$(z.value))return!1}else for(;!(z=W.next()).done;){var Z=z.value;if(Z&&!$(Z[1]))return!1}}else return!1;return!0;default:return!1}}function Q(_,x){return _==="symbol"?!0:x?x["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&x instanceof Symbol:!1}function ct(_){var x=typeof _;return Array.isArray(_)?"array":_ instanceof RegExp?"object":Q(x,_)?"symbol":x}function bt(_){if(typeof _>"u"||_===null)return""+_;var x=ct(_);if(x==="object"){if(_ instanceof Date)return"date";if(_ instanceof RegExp)return"regexp"}return x}function ht(_){var x=bt(_);switch(x){case"array":case"object":return"an "+x;case"boolean":case"date":case"regexp":return"a "+x;default:return x}}function It(_){return!_.constructor||!_.constructor.name?y:_.constructor.name}return S.checkPropTypes=n,S.resetWarningCache=n.resetWarningCache,S.PropTypes=S,S},Oi}var Ni,On;function no(){if(On)return Ni;On=1;var t=Pi();function e(){}function s(){}return s.resetWarningCache=e,Ni=function(){function i(a,l,c,h,d,p){if(p!==t){var y=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw y.name="Invariant Violation",y}}i.isRequired=i;function n(){return i}var r={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:n,element:i,elementType:i,instanceOf:n,node:i,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:s,resetWarningCache:e};return r.PropTypes=r,r},Ni}if(process.env.NODE_ENV!=="production"){var ro=jn(),oo=!0;Ei.exports=io()(ro.isElement,oo)}else Ei.exports=no()();var ao=Ei.exports;const jt=$r(ao);function Nn(t){var e,s,i="";if(typeof t=="string"||typeof t=="number")i+=t;else if(typeof t=="object")if(Array.isArray(t)){var n=t.length;for(e=0;e<n;e++)t[e]&&(s=Nn(t[e]))&&(i&&(i+=" "),i+=s)}else for(s in t)t[s]&&(i&&(i+=" "),i+=s);return i}function Rn(){for(var t,e,s=0,i="",n=arguments.length;s<n;s++)(t=arguments[s])&&(e=Nn(t))&&(i&&(i+=" "),i+=e);return i}function lo(t,e,s=void 0){const i={};for(const n in t){const r=t[n];let a="",l=!0;for(let c=0;c<r.length;c+=1){const h=r[c];h&&(a+=(l===!0?"":" ")+e(h),l=!1,s&&s[h]&&(a+=" "+s[h]))}i[n]=a}return i}var Ri={exports:{}},$t={};/**
42
+ * @license React
43
+ * react-is.production.js
44
+ *
45
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
46
+ *
47
+ * This source code is licensed under the MIT license found in the
48
+ * LICENSE file in the root directory of this source tree.
49
+ */var $n;function co(){if($n)return $t;$n=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),n=Symbol.for("react.profiler"),r=Symbol.for("react.consumer"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),y=Symbol.for("react.view_transition"),S=Symbol.for("react.client.reference");function I(m){if(typeof m=="object"&&m!==null){var k=m.$$typeof;switch(k){case t:switch(m=m.type,m){case s:case n:case i:case c:case h:case y:return m;default:switch(m=m&&m.$$typeof,m){case a:case l:case p:case d:return m;case r:return m;default:return k}}case e:return k}}}return $t.ContextConsumer=r,$t.ContextProvider=a,$t.Element=t,$t.ForwardRef=l,$t.Fragment=s,$t.Lazy=p,$t.Memo=d,$t.Portal=e,$t.Profiler=n,$t.StrictMode=i,$t.Suspense=c,$t.SuspenseList=h,$t.isContextConsumer=function(m){return I(m)===r},$t.isContextProvider=function(m){return I(m)===a},$t.isElement=function(m){return typeof m=="object"&&m!==null&&m.$$typeof===t},$t.isForwardRef=function(m){return I(m)===l},$t.isFragment=function(m){return I(m)===s},$t.isLazy=function(m){return I(m)===p},$t.isMemo=function(m){return I(m)===d},$t.isPortal=function(m){return I(m)===e},$t.isProfiler=function(m){return I(m)===n},$t.isStrictMode=function(m){return I(m)===i},$t.isSuspense=function(m){return I(m)===c},$t.isSuspenseList=function(m){return I(m)===h},$t.isValidElementType=function(m){return typeof m=="string"||typeof m=="function"||m===s||m===n||m===i||m===c||m===h||typeof m=="object"&&m!==null&&(m.$$typeof===p||m.$$typeof===d||m.$$typeof===a||m.$$typeof===r||m.$$typeof===l||m.$$typeof===S||m.getModuleId!==void 0)},$t.typeOf=I,$t}var Lt={};/**
50
+ * @license React
51
+ * react-is.development.js
52
+ *
53
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
54
+ *
55
+ * This source code is licensed under the MIT license found in the
56
+ * LICENSE file in the root directory of this source tree.
57
+ */var Ln;function ho(){return Ln||(Ln=1,process.env.NODE_ENV!=="production"&&function(){function t(m){if(typeof m=="object"&&m!==null){var k=m.$$typeof;switch(k){case e:switch(m=m.type,m){case i:case r:case n:case h:case d:case S:return m;default:switch(m=m&&m.$$typeof,m){case l:case c:case y:case p:return m;case a:return m;default:return k}}case s:return k}}}var e=Symbol.for("react.transitional.element"),s=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),S=Symbol.for("react.view_transition"),I=Symbol.for("react.client.reference");Lt.ContextConsumer=a,Lt.ContextProvider=l,Lt.Element=e,Lt.ForwardRef=c,Lt.Fragment=i,Lt.Lazy=y,Lt.Memo=p,Lt.Portal=s,Lt.Profiler=r,Lt.StrictMode=n,Lt.Suspense=h,Lt.SuspenseList=d,Lt.isContextConsumer=function(m){return t(m)===a},Lt.isContextProvider=function(m){return t(m)===l},Lt.isElement=function(m){return typeof m=="object"&&m!==null&&m.$$typeof===e},Lt.isForwardRef=function(m){return t(m)===c},Lt.isFragment=function(m){return t(m)===i},Lt.isLazy=function(m){return t(m)===y},Lt.isMemo=function(m){return t(m)===p},Lt.isPortal=function(m){return t(m)===s},Lt.isProfiler=function(m){return t(m)===r},Lt.isStrictMode=function(m){return t(m)===n},Lt.isSuspense=function(m){return t(m)===h},Lt.isSuspenseList=function(m){return t(m)===d},Lt.isValidElementType=function(m){return typeof m=="string"||typeof m=="function"||m===i||m===r||m===n||m===h||m===d||typeof m=="object"&&m!==null&&(m.$$typeof===y||m.$$typeof===p||m.$$typeof===l||m.$$typeof===a||m.$$typeof===c||m.$$typeof===I||m.getModuleId!==void 0)},Lt.typeOf=t}()),Lt}process.env.NODE_ENV==="production"?Ri.exports=co():Ri.exports=ho();var zs=Ri.exports;function we(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function Wn(t){if(Ee.isValidElement(t)||zs.isValidElementType(t)||!we(t))return t;const e={};return Object.keys(t).forEach(s=>{e[s]=Wn(t[s])}),e}function de(t,e,s={clone:!0}){const i=s.clone?{...t}:t;return we(t)&&we(e)&&Object.keys(e).forEach(n=>{Ee.isValidElement(e[n])||zs.isValidElementType(e[n])?i[n]=e[n]:we(e[n])&&Object.prototype.hasOwnProperty.call(t,n)&&we(t[n])?i[n]=de(t[n],e[n],s):s.clone?i[n]=we(e[n])?Wn(e[n]):e[n]:i[n]=e[n]}),i}function Ts(t,e){return e?de(t,e,{clone:!1}):t}const Pe=process.env.NODE_ENV!=="production"?jt.oneOfType([jt.number,jt.string,jt.object,jt.array]):{};function _n(t,e){if(!t.containerQueries)return e;const s=Object.keys(e).filter(i=>i.startsWith("@container")).sort((i,n)=>{var a,l;const r=/min-width:\s*([0-9.]+)/;return+(((a=i.match(r))==null?void 0:a[1])||0)-+(((l=n.match(r))==null?void 0:l[1])||0)});return s.length?s.reduce((i,n)=>{const r=e[n];return delete i[n],i[n]=r,i},{...e}):e}function uo(t,e){return e==="@"||e.startsWith("@")&&(t.some(s=>e.startsWith(`@${s}`))||!!e.match(/^@\d/))}function fo(t,e){const s=e.match(/^@([^/]+)?\/?(.+)?$/);if(!s){if(process.env.NODE_ENV!=="production")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The provided shorthand ${`(${e})`} is invalid. The format should be \`@<breakpoint | number>\` or \`@<breakpoint | number>/<container>\`.
58
+ For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`:De(18,`(${e})`));return null}const[,i,n]=s,r=Number.isNaN(+i)?i||0:+i;return t.containerQueries(n).up(r)}function po(t){const e=(r,a)=>r.replace("@media",a?`@container ${a}`:"@container");function s(r,a){r.up=(...l)=>e(t.breakpoints.up(...l),a),r.down=(...l)=>e(t.breakpoints.down(...l),a),r.between=(...l)=>e(t.breakpoints.between(...l),a),r.only=(...l)=>e(t.breakpoints.only(...l),a),r.not=(...l)=>{const c=e(t.breakpoints.not(...l),a);return c.includes("not all and")?c.replace("not all and ","").replace("min-width:","width<").replace("max-width:","width>").replace("and","or"):c}}const i={},n=r=>(s(i,r),i);return s(n),{...t,containerQueries:n}}const Gs={xs:0,sm:600,md:900,lg:1200,xl:1536},Fn={keys:["xs","sm","md","lg","xl"],up:t=>`@media (min-width:${Gs[t]}px)`},go={containerQueries:t=>({up:e=>{let s=typeof e=="number"?e:Gs[e]||e;return typeof s=="number"&&(s=`${s}px`),t?`@container ${t} (min-width:${s})`:`@container (min-width:${s})`}})};function Ce(t,e,s){const i=t.theme||{};if(Array.isArray(e)){const r=i.breakpoints||Fn;return e.reduce((a,l,c)=>(a[r.up(r.keys[c])]=s(e[c]),a),{})}if(typeof e=="object"){const r=i.breakpoints||Fn;return Object.keys(e).reduce((a,l)=>{if(uo(r.keys,l)){const c=fo(i.containerQueries?i:go,l);c&&(a[c]=s(e[l],l))}else if(Object.keys(r.values||Gs).includes(l)){const c=r.up(l);a[c]=s(e[l],l)}else{const c=l;a[c]=e[c]}return a},{})}return s(e)}function mo(t={}){var s;return((s=t.keys)==null?void 0:s.reduce((i,n)=>{const r=t.up(n);return i[r]={},i},{}))||{}}function qn(t,e){return t.reduce((s,i)=>{const n=s[i];return(!n||Object.keys(n).length===0)&&delete s[i],s},e)}function Ys(t,e,s=!0){if(!e||typeof e!="string")return null;if(t&&t.vars&&s){const i=`vars.${e}`.split(".").reduce((n,r)=>n&&n[r]?n[r]:null,t);if(i!=null)return i}return e.split(".").reduce((i,n)=>i&&i[n]!=null?i[n]:null,t)}function Vs(t,e,s,i=s){let n;return typeof t=="function"?n=t(s):Array.isArray(t)?n=t[s]||i:n=Ys(t,s)||i,e&&(n=e(n,i,t)),n}function Yt(t){const{prop:e,cssProperty:s=t.prop,themeKey:i,transform:n}=t,r=a=>{if(a[e]==null)return null;const l=a[e],c=a.theme,h=Ys(c,i)||{};return Ce(a,l,p=>{let y=Vs(h,n,p);return p===y&&typeof p=="string"&&(y=Vs(h,n,`${e}${p==="default"?"":qe(p)}`,p)),s===!1?y:{[s]:y}})};return r.propTypes=process.env.NODE_ENV!=="production"?{[e]:Pe}:{},r.filterProps=[e],r}function xo(t){const e={};return s=>(e[s]===void 0&&(e[s]=t(s)),e[s])}const yo={m:"margin",p:"padding"},vo={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},zn={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},bo=xo(t=>{if(t.length>2)if(zn[t])t=zn[t];else return[t];const[e,s]=t.split(""),i=yo[e],n=vo[s]||"";return Array.isArray(n)?n.map(r=>i+r):[i+n]}),Hs=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],Ks=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],To=[...Hs,...Ks];function Ss(t,e,s,i){const n=Ys(t,e,!0)??s;return typeof n=="number"||typeof n=="string"?r=>typeof r=="string"?r:(process.env.NODE_ENV!=="production"&&typeof r!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${r}.`),typeof n=="string"?n.startsWith("var(")&&r===0?0:n.startsWith("var(")&&r===1?n:`calc(${r} * ${n})`:n*r):Array.isArray(n)?r=>{if(typeof r=="string")return r;const a=Math.abs(r);process.env.NODE_ENV!=="production"&&(Number.isInteger(a)?a>n.length-1&&console.error([`MUI: The value provided (${a}) overflows.`,`The supported values are: ${JSON.stringify(n)}.`,`${a} > ${n.length-1}, you need to add the missing values.`].join(`
59
+ `)):console.error([`MUI: The \`theme.${e}\` array type cannot be combined with non integer values.You should either use an integer value that can be used as index, or define the \`theme.${e}\` as a number.`].join(`
60
+ `)));const l=n[a];return r>=0?l:typeof l=="number"?-l:typeof l=="string"&&l.startsWith("var(")?`calc(-1 * ${l})`:`-${l}`}:typeof n=="function"?n:(process.env.NODE_ENV!=="production"&&console.error([`MUI: The \`theme.${e}\` value (${n}) is invalid.`,"It should be a number, an array or a function."].join(`
61
+ `)),()=>{})}function $i(t){return Ss(t,"spacing",8,"spacing")}function ws(t,e){return typeof e=="string"||e==null?e:t(e)}function So(t,e){return s=>t.reduce((i,n)=>(i[n]=ws(e,s),i),{})}function wo(t,e,s,i){if(!e.includes(s))return null;const n=bo(s),r=So(n,i),a=t[s];return Ce(t,a,r)}function Gn(t,e){const s=$i(t.theme);return Object.keys(t).map(i=>wo(t,e,i,s)).reduce(Ts,{})}function zt(t){return Gn(t,Hs)}zt.propTypes=process.env.NODE_ENV!=="production"?Hs.reduce((t,e)=>(t[e]=Pe,t),{}):{},zt.filterProps=Hs;function Gt(t){return Gn(t,Ks)}Gt.propTypes=process.env.NODE_ENV!=="production"?Ks.reduce((t,e)=>(t[e]=Pe,t),{}):{},Gt.filterProps=Ks,process.env.NODE_ENV!=="production"&&To.reduce((t,e)=>(t[e]=Pe,t),{});function Qs(...t){const e=t.reduce((i,n)=>(n.filterProps.forEach(r=>{i[r]=n}),i),{}),s=i=>Object.keys(i).reduce((n,r)=>e[r]?Ts(n,e[r](i)):n,{});return s.propTypes=process.env.NODE_ENV!=="production"?t.reduce((i,n)=>Object.assign(i,n.propTypes),{}):{},s.filterProps=t.reduce((i,n)=>i.concat(n.filterProps),[]),s}function ye(t){return typeof t!="number"?t:`${t}px solid`}function ve(t,e){return Yt({prop:t,themeKey:"borders",transform:e})}const Co=ve("border",ye),Io=ve("borderTop",ye),ko=ve("borderRight",ye),jo=ve("borderBottom",ye),Eo=ve("borderLeft",ye),Bo=ve("borderColor"),Do=ve("borderTopColor"),Po=ve("borderRightColor"),Mo=ve("borderBottomColor"),Ao=ve("borderLeftColor"),Oo=ve("outline",ye),No=ve("outlineColor"),Us=t=>{if(t.borderRadius!==void 0&&t.borderRadius!==null){const e=Ss(t.theme,"shape.borderRadius",4,"borderRadius"),s=i=>({borderRadius:ws(e,i)});return Ce(t,t.borderRadius,s)}return null};Us.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:Pe}:{},Us.filterProps=["borderRadius"],Qs(Co,Io,ko,jo,Eo,Bo,Do,Po,Mo,Ao,Us,Oo,No);const Xs=t=>{if(t.gap!==void 0&&t.gap!==null){const e=Ss(t.theme,"spacing",8,"gap"),s=i=>({gap:ws(e,i)});return Ce(t,t.gap,s)}return null};Xs.propTypes=process.env.NODE_ENV!=="production"?{gap:Pe}:{},Xs.filterProps=["gap"];const Js=t=>{if(t.columnGap!==void 0&&t.columnGap!==null){const e=Ss(t.theme,"spacing",8,"columnGap"),s=i=>({columnGap:ws(e,i)});return Ce(t,t.columnGap,s)}return null};Js.propTypes=process.env.NODE_ENV!=="production"?{columnGap:Pe}:{},Js.filterProps=["columnGap"];const Zs=t=>{if(t.rowGap!==void 0&&t.rowGap!==null){const e=Ss(t.theme,"spacing",8,"rowGap"),s=i=>({rowGap:ws(e,i)});return Ce(t,t.rowGap,s)}return null};Zs.propTypes=process.env.NODE_ENV!=="production"?{rowGap:Pe}:{},Zs.filterProps=["rowGap"];const Ro=Yt({prop:"gridColumn"}),$o=Yt({prop:"gridRow"}),Lo=Yt({prop:"gridAutoFlow"}),Wo=Yt({prop:"gridAutoColumns"}),_o=Yt({prop:"gridAutoRows"}),Fo=Yt({prop:"gridTemplateColumns"}),qo=Yt({prop:"gridTemplateRows"}),zo=Yt({prop:"gridTemplateAreas"}),Go=Yt({prop:"gridArea"});Qs(Xs,Js,Zs,Ro,$o,Lo,Wo,_o,Fo,qo,zo,Go);function ts(t,e){return e==="grey"?e:t}const Yo=Yt({prop:"color",themeKey:"palette",transform:ts}),Vo=Yt({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:ts}),Ho=Yt({prop:"backgroundColor",themeKey:"palette",transform:ts});Qs(Yo,Vo,Ho);function pe(t){return t<=1&&t!==0?`${t*100}%`:t}const Ko=Yt({prop:"width",transform:pe}),Li=t=>{if(t.maxWidth!==void 0&&t.maxWidth!==null){const e=s=>{var n,r,a,l,c;const i=((a=(r=(n=t.theme)==null?void 0:n.breakpoints)==null?void 0:r.values)==null?void 0:a[s])||Gs[s];return i?((c=(l=t.theme)==null?void 0:l.breakpoints)==null?void 0:c.unit)!=="px"?{maxWidth:`${i}${t.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:pe(s)}};return Ce(t,t.maxWidth,e)}return null};Li.filterProps=["maxWidth"];const Qo=Yt({prop:"minWidth",transform:pe}),Uo=Yt({prop:"height",transform:pe}),Xo=Yt({prop:"maxHeight",transform:pe}),Jo=Yt({prop:"minHeight",transform:pe});Yt({prop:"size",cssProperty:"width",transform:pe}),Yt({prop:"size",cssProperty:"height",transform:pe});const Zo=Yt({prop:"boxSizing"});Qs(Ko,Li,Qo,Uo,Xo,Jo,Zo);const ti={border:{themeKey:"borders",transform:ye},borderTop:{themeKey:"borders",transform:ye},borderRight:{themeKey:"borders",transform:ye},borderBottom:{themeKey:"borders",transform:ye},borderLeft:{themeKey:"borders",transform:ye},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:ye},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:Us},color:{themeKey:"palette",transform:ts},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:ts},backgroundColor:{themeKey:"palette",transform:ts},p:{style:Gt},pt:{style:Gt},pr:{style:Gt},pb:{style:Gt},pl:{style:Gt},px:{style:Gt},py:{style:Gt},padding:{style:Gt},paddingTop:{style:Gt},paddingRight:{style:Gt},paddingBottom:{style:Gt},paddingLeft:{style:Gt},paddingX:{style:Gt},paddingY:{style:Gt},paddingInline:{style:Gt},paddingInlineStart:{style:Gt},paddingInlineEnd:{style:Gt},paddingBlock:{style:Gt},paddingBlockStart:{style:Gt},paddingBlockEnd:{style:Gt},m:{style:zt},mt:{style:zt},mr:{style:zt},mb:{style:zt},ml:{style:zt},mx:{style:zt},my:{style:zt},margin:{style:zt},marginTop:{style:zt},marginRight:{style:zt},marginBottom:{style:zt},marginLeft:{style:zt},marginX:{style:zt},marginY:{style:zt},marginInline:{style:zt},marginInlineStart:{style:zt},marginInlineEnd:{style:zt},marginBlock:{style:zt},marginBlockStart:{style:zt},marginBlockEnd:{style:zt},displayPrint:{cssProperty:!1,transform:t=>({"@media print":{display:t}})},display:{},overflow:{},textOverflow:{},visibility:{},whiteSpace:{},flexBasis:{},flexDirection:{},flexWrap:{},justifyContent:{},alignItems:{},alignContent:{},order:{},flex:{},flexGrow:{},flexShrink:{},alignSelf:{},justifyItems:{},justifySelf:{},gap:{style:Xs},rowGap:{style:Zs},columnGap:{style:Js},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:pe},maxWidth:{style:Li},minWidth:{transform:pe},height:{transform:pe},maxHeight:{transform:pe},minHeight:{transform:pe},boxSizing:{},font:{themeKey:"font"},fontFamily:{themeKey:"typography"},fontSize:{themeKey:"typography"},fontStyle:{themeKey:"typography"},fontWeight:{themeKey:"typography"},letterSpacing:{},textTransform:{},lineHeight:{},textAlign:{},typography:{cssProperty:!1,themeKey:"typography"}};function ta(...t){const e=t.reduce((i,n)=>i.concat(Object.keys(n)),[]),s=new Set(e);return t.every(i=>s.size===Object.keys(i).length)}function ea(t,e){return typeof t=="function"?t(e):t}function sa(){function t(s,i,n,r){const a={[s]:i,theme:n},l=r[s];if(!l)return{[s]:i};const{cssProperty:c=s,themeKey:h,transform:d,style:p}=l;if(i==null)return null;if(h==="typography"&&i==="inherit")return{[s]:i};const y=Ys(n,h)||{};return p?p(a):Ce(a,i,I=>{let m=Vs(y,d,I);return I===m&&typeof I=="string"&&(m=Vs(y,d,`${s}${I==="default"?"":qe(I)}`,I)),c===!1?m:{[c]:m}})}function e(s){const{sx:i,theme:n={},nested:r}=s||{};if(!i)return null;const a=n.unstable_sxConfig??ti;function l(c){let h=c;if(typeof c=="function")h=c(n);else if(typeof c!="object")return c;if(!h)return null;const d=mo(n.breakpoints),p=Object.keys(d);let y=d;return Object.keys(h).forEach(S=>{const I=ea(h[S],n);if(I!=null)if(typeof I=="object")if(a[S])y=Ts(y,t(S,I,n,a));else{const m=Ce({theme:n},I,k=>({[S]:k}));ta(m,I)?y[S]=e({sx:I,theme:n,nested:!0}):y=Ts(y,m)}else y=Ts(y,t(S,I,n,a))}),!r&&n.modularCssLayers?{"@layer sx":_n(n,qn(p,y))}:_n(n,qn(p,y))}return Array.isArray(i)?i.map(l):l(i)}return e}const es=sa();es.filterProps=["sx"];function ia(t){for(var e=0,s,i=0,n=t.length;n>=4;++i,n-=4)s=t.charCodeAt(i)&255|(t.charCodeAt(++i)&255)<<8|(t.charCodeAt(++i)&255)<<16|(t.charCodeAt(++i)&255)<<24,s=(s&65535)*1540483477+((s>>>16)*59797<<16),s^=s>>>24,e=(s&65535)*1540483477+((s>>>16)*59797<<16)^(e&65535)*1540483477+((e>>>16)*59797<<16);switch(n){case 3:e^=(t.charCodeAt(i+2)&255)<<16;case 2:e^=(t.charCodeAt(i+1)&255)<<8;case 1:e^=t.charCodeAt(i)&255,e=(e&65535)*1540483477+((e>>>16)*59797<<16)}return e^=e>>>13,e=(e&65535)*1540483477+((e>>>16)*59797<<16),((e^e>>>15)>>>0).toString(36)}var na={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};function ra(t){var e=Object.create(null);return function(s){return e[s]===void 0&&(e[s]=t(s)),e[s]}}var oa=/[A-Z]|^ms/g,aa=/_EMO_([^_]+?)_([^]*?)_EMO_/g,Yn=function(e){return e.charCodeAt(1)===45},Vn=function(e){return e!=null&&typeof e!="boolean"},Wi=ra(function(t){return Yn(t)?t:t.replace(oa,"-$&").toLowerCase()}),Hn=function(e,s){switch(e){case"animation":case"animationName":if(typeof s=="string")return s.replace(aa,function(i,n,r){return Me={name:n,styles:r,next:Me},n})}return na[e]!==1&&!Yn(e)&&typeof s=="number"&&s!==0?s+"px":s};function ei(t,e,s){if(s==null)return"";var i=s;if(i.__emotion_styles!==void 0)return i;switch(typeof s){case"boolean":return"";case"object":{var n=s;if(n.anim===1)return Me={name:n.name,styles:n.styles,next:Me},n.name;var r=s;if(r.styles!==void 0){var a=r.next;if(a!==void 0)for(;a!==void 0;)Me={name:a.name,styles:a.styles,next:Me},a=a.next;var l=r.styles+";";return l}return la(t,e,s)}}var c=s;return c}function la(t,e,s){var i="";if(Array.isArray(s))for(var n=0;n<s.length;n++)i+=ei(t,e,s[n])+";";else for(var r in s){var a=s[r];if(typeof a!="object"){var l=a;Vn(l)&&(i+=Wi(r)+":"+Hn(r,l)+";")}else if(Array.isArray(a)&&typeof a[0]=="string"&&e==null)for(var c=0;c<a.length;c++)Vn(a[c])&&(i+=Wi(r)+":"+Hn(r,a[c])+";");else{var h=ei(t,e,a);switch(r){case"animation":case"animationName":{i+=Wi(r)+":"+h+";";break}default:i+=r+"{"+h+"}"}}}return i}var Kn=/label:\s*([^\s;{]+)\s*(;|$)/g,Me;function ca(t,e,s){if(t.length===1&&typeof t[0]=="object"&&t[0]!==null&&t[0].styles!==void 0)return t[0];var i=!0,n="";Me=void 0;var r=t[0];if(r==null||r.raw===void 0)i=!1,n+=ei(s,e,r);else{var a=r;n+=a[0]}for(var l=1;l<t.length;l++)if(n+=ei(s,e,t[l]),i){var c=r;n+=c[l]}Kn.lastIndex=0;for(var h="",d;(d=Kn.exec(n))!==null;)h+="-"+d[1];var p=ia(n)+h;return{name:p,styles:n,next:Me}}/**
62
+ * @mui/styled-engine v7.3.7
63
+ *
64
+ * @license MIT
65
+ * This source code is licensed under the MIT license found in the
66
+ * LICENSE file in the root directory of this source tree.
67
+ */function ha(t,e){const s=Or(t,e);return process.env.NODE_ENV!=="production"?(...i)=>{const n=typeof t=="string"?`"${t}"`:"component";return i.length===0?console.error([`MUI: Seems like you called \`styled(${n})()\` without a \`style\` argument.`,'You must provide a `styles` argument: `styled("div")(styleYouForgotToPass)`.'].join(`
68
+ `)):i.some(r=>r===void 0)&&console.error(`MUI: the styled(${n})(...args) API requires all its args to be defined.`),s(...i)}:s}function ua(t,e){Array.isArray(t.__emotion_styles)&&(t.__emotion_styles=e(t.__emotion_styles))}const Qn=[];function ze(t){return Qn[0]=t,ca(Qn)}const fa=t=>{const e=Object.keys(t).map(s=>({key:s,val:t[s]}))||[];return e.sort((s,i)=>s.val-i.val),e.reduce((s,i)=>({...s,[i.key]:i.val}),{})};function da(t){const{values:e={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:s="px",step:i=5,...n}=t,r=fa(e),a=Object.keys(r);function l(y){return`@media (min-width:${typeof e[y]=="number"?e[y]:y}${s})`}function c(y){return`@media (max-width:${(typeof e[y]=="number"?e[y]:y)-i/100}${s})`}function h(y,S){const I=a.indexOf(S);return`@media (min-width:${typeof e[y]=="number"?e[y]:y}${s}) and (max-width:${(I!==-1&&typeof e[a[I]]=="number"?e[a[I]]:S)-i/100}${s})`}function d(y){return a.indexOf(y)+1<a.length?h(y,a[a.indexOf(y)+1]):l(y)}function p(y){const S=a.indexOf(y);return S===0?l(a[1]):S===a.length-1?c(a[S]):h(y,a[a.indexOf(y)+1]).replace("@media","@media not all and")}return{keys:a,values:r,up:l,down:c,between:h,only:d,not:p,unit:s,...n}}const pa={borderRadius:4};function Un(t=8,e=$i({spacing:t})){if(t.mui)return t;const s=(...i)=>(process.env.NODE_ENV!=="production"&&(i.length<=4||console.error(`MUI: Too many arguments provided, expected between 0 and 4, got ${i.length}`)),(i.length===0?[1]:i).map(r=>{const a=e(r);return typeof a=="number"?`${a}px`:a}).join(" "));return s.mui=!0,s}function ga(t,e){var i;const s=this;if(s.vars){if(!((i=s.colorSchemes)!=null&&i[t])||typeof s.getColorSchemeSelector!="function")return{};let n=s.getColorSchemeSelector(t);return n==="&"?e:((n.includes("data-")||n.includes("."))&&(n=`*:where(${n.replace(/\s*&$/,"")}) &`),{[n]:e})}return s.palette.mode===t?e:{}}function Xn(t={},...e){const{breakpoints:s={},palette:i={},spacing:n,shape:r={},...a}=t,l=da(s),c=Un(n);let h=de({breakpoints:l,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:c,shape:{...pa,...r}},a);return h=po(h),h.applyStyles=ga,h=e.reduce((d,p)=>de(d,p),h),h.unstable_sxConfig={...ti,...a==null?void 0:a.unstable_sxConfig},h.unstable_sx=function(p){return es({sx:p,theme:this})},h}const ma={active:"active",checked:"checked",completed:"completed",disabled:"disabled",error:"error",expanded:"expanded",focused:"focused",focusVisible:"focusVisible",open:"open",readOnly:"readOnly",required:"required",selected:"selected"};function _i(t,e,s="Mui"){const i=ma[e];return i?`${s}-${i}`:`${Jr.generate(t)}-${e}`}function xa(t,e,s="Mui"){const i={};return e.forEach(n=>{i[n]=_i(t,n,s)}),i}function Jn(t,e=""){return t.displayName||t.name||e}function Zn(t,e,s){const i=Jn(e);return t.displayName||(i!==""?`${s}(${i})`:s)}function ya(t){if(t!=null){if(typeof t=="string")return t;if(typeof t=="function")return Jn(t,"Component");if(typeof t=="object")switch(t.$$typeof){case zs.ForwardRef:return Zn(t,t.render,"ForwardRef");case zs.Memo:return Zn(t,t.type,"memo");default:return}}}function tr(t){const{variants:e,...s}=t,i={variants:e,style:ze(s),isProcessed:!0};return i.style===s||e&&e.forEach(n=>{typeof n.style!="function"&&(n.style=ze(n.style))}),i}const va=Xn();function Fi(t){return t!=="ownerState"&&t!=="theme"&&t!=="sx"&&t!=="as"}function Ge(t,e){return e&&t&&typeof t=="object"&&t.styles&&!t.styles.startsWith("@layer")&&(t.styles=`@layer ${e}{${String(t.styles)}}`),t}function ba(t){return t?(e,s)=>s[t]:null}function Ta(t,e,s){t.theme=Ia(t.theme)?s:t.theme[e]||t.theme}function si(t,e,s){const i=typeof e=="function"?e(t):e;if(Array.isArray(i))return i.flatMap(n=>si(t,n,s));if(Array.isArray(i==null?void 0:i.variants)){let n;if(i.isProcessed)n=s?Ge(i.style,s):i.style;else{const{variants:r,...a}=i;n=s?Ge(ze(a),s):a}return er(t,i.variants,[n],s)}return i!=null&&i.isProcessed?s?Ge(ze(i.style),s):i.style:s?Ge(ze(i),s):i}function er(t,e,s=[],i=void 0){var r;let n;t:for(let a=0;a<e.length;a+=1){const l=e[a];if(typeof l.props=="function"){if(n??(n={...t,...t.ownerState,ownerState:t.ownerState}),!l.props(n))continue}else for(const c in l.props)if(t[c]!==l.props[c]&&((r=t.ownerState)==null?void 0:r[c])!==l.props[c])continue t;typeof l.style=="function"?(n??(n={...t,...t.ownerState,ownerState:t.ownerState}),s.push(i?Ge(ze(l.style(n)),i):l.style(n))):s.push(i?Ge(ze(l.style),i):l.style)}return s}function Sa(t={}){const{themeId:e,defaultTheme:s=va,rootShouldForwardProp:i=Fi,slotShouldForwardProp:n=Fi}=t;function r(l){Ta(l,e,s)}return(l,c={})=>{ua(l,q=>q.filter(it=>it!==es));const{name:h,slot:d,skipVariantsResolver:p,skipSx:y,overridesResolver:S=ba(sr(d)),...I}=c,m=h&&h.startsWith("Mui")||d?"components":"custom",k=p!==void 0?p:d&&d!=="Root"&&d!=="root"||!1,E=y||!1;let Y=Fi;d==="Root"||d==="root"?Y=i:d?Y=n:ka(l)&&(Y=void 0);const R=ha(l,{shouldForwardProp:Y,label:Ca(h,d),...I}),O=q=>{if(q.__emotion_real===q)return q;if(typeof q=="function")return function(ot){return si(ot,q,ot.theme.modularCssLayers?m:void 0)};if(we(q)){const it=tr(q);return function(U){return it.variants?si(U,it,U.theme.modularCssLayers?m:void 0):U.theme.modularCssLayers?Ge(it.style,m):it.style}}return q},M=(...q)=>{const it=[],ot=q.map(O),U=[];if(it.push(r),h&&S&&U.push(function(L){var bt,ht;const Q=(ht=(bt=L.theme.components)==null?void 0:bt[h])==null?void 0:ht.styleOverrides;if(!Q)return null;const ct={};for(const It in Q)ct[It]=si(L,Q[It],L.theme.modularCssLayers?"theme":void 0);return S(L,ct)}),h&&!k&&U.push(function(L){var ct,bt;const $=L.theme,Q=(bt=(ct=$==null?void 0:$.components)==null?void 0:ct[h])==null?void 0:bt.variants;return Q?er(L,Q,[],L.theme.modularCssLayers?"theme":void 0):null}),E||U.push(es),Array.isArray(ot[0])){const g=ot.shift(),L=new Array(it.length).fill(""),$=new Array(U.length).fill("");let Q;Q=[...L,...g,...$],Q.raw=[...L,...g.raw,...$],it.unshift(Q)}const dt=[...it,...ot,...U],st=R(...dt);return l.muiName&&(st.muiName=l.muiName),process.env.NODE_ENV!=="production"&&(st.displayName=wa(h,d,l)),st};return R.withConfig&&(M.withConfig=R.withConfig),M}}function wa(t,e,s){return t?`${t}${qe(e||"")}`:`Styled(${ya(s)})`}function Ca(t,e){let s;return process.env.NODE_ENV!=="production"&&t&&(s=`${t}-${sr(e||"Root")}`),s}function Ia(t){for(const e in t)return!1;return!0}function ka(t){return typeof t=="string"&&t.charCodeAt(0)>96}function sr(t){return t&&t.charAt(0).toLowerCase()+t.slice(1)}function qi(t,e,s=!1){const i={...e};for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const r=n;if(r==="components"||r==="slots")i[r]={...t[r],...i[r]};else if(r==="componentsProps"||r==="slotProps"){const a=t[r],l=e[r];if(!l)i[r]=a||{};else if(!a)i[r]=l;else{i[r]={...l};for(const c in a)if(Object.prototype.hasOwnProperty.call(a,c)){const h=c;i[r][h]=qi(a[h],l[h],s)}}}else r==="className"&&s&&e.className?i.className=Rn(t==null?void 0:t.className,e==null?void 0:e.className):r==="style"&&s&&e.style?i.style={...t==null?void 0:t.style,...e==null?void 0:e.style}:i[r]===void 0&&(i[r]=t[r])}return i}function ja(t,e=Number.MIN_SAFE_INTEGER,s=Number.MAX_SAFE_INTEGER){return Math.max(e,Math.min(t,s))}function zi(t,e=0,s=1){return process.env.NODE_ENV!=="production"&&(t<e||t>s)&&console.error(`MUI: The value provided ${t} is out of range [${e}, ${s}].`),ja(t,e,s)}function Ea(t){t=t.slice(1);const e=new RegExp(`.{1,${t.length>=6?2:1}}`,"g");let s=t.match(e);return s&&s[0].length===1&&(s=s.map(i=>i+i)),process.env.NODE_ENV!=="production"&&t.length!==t.trim().length&&console.error(`MUI: The color: "${t}" is invalid. Make sure the color input doesn't contain leading/trailing space.`),s?`rgb${s.length===4?"a":""}(${s.map((i,n)=>n<3?parseInt(i,16):Math.round(parseInt(i,16)/255*1e3)/1e3).join(", ")})`:""}function Ae(t){if(t.type)return t;if(t.charAt(0)==="#")return Ae(Ea(t));const e=t.indexOf("("),s=t.substring(0,e);if(!["rgb","rgba","hsl","hsla","color"].includes(s))throw new Error(process.env.NODE_ENV!=="production"?`MUI: Unsupported \`${t}\` color.
69
+ The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`:De(9,t));let i=t.substring(e+1,t.length-1),n;if(s==="color"){if(i=i.split(" "),n=i.shift(),i.length===4&&i[3].charAt(0)==="/"&&(i[3]=i[3].slice(1)),!["srgb","display-p3","a98-rgb","prophoto-rgb","rec-2020"].includes(n))throw new Error(process.env.NODE_ENV!=="production"?`MUI: unsupported \`${n}\` color space.
70
+ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:De(10,n))}else i=i.split(",");return i=i.map(r=>parseFloat(r)),{type:s,values:i,colorSpace:n}}const Ba=t=>{const e=Ae(t);return e.values.slice(0,3).map((s,i)=>e.type.includes("hsl")&&i!==0?`${s}%`:s).join(" ")},Cs=(t,e)=>{try{return Ba(t)}catch{return e&&process.env.NODE_ENV!=="production"&&console.warn(e),t}};function ii(t){const{type:e,colorSpace:s}=t;let{values:i}=t;return e.includes("rgb")?i=i.map((n,r)=>r<3?parseInt(n,10):n):e.includes("hsl")&&(i[1]=`${i[1]}%`,i[2]=`${i[2]}%`),e.includes("color")?i=`${s} ${i.join(" ")}`:i=`${i.join(", ")}`,`${e}(${i})`}function ir(t){t=Ae(t);const{values:e}=t,s=e[0],i=e[1]/100,n=e[2]/100,r=i*Math.min(n,1-n),a=(h,d=(h+s/30)%12)=>n-r*Math.max(Math.min(d-3,9-d,1),-1);let l="rgb";const c=[Math.round(a(0)*255),Math.round(a(8)*255),Math.round(a(4)*255)];return t.type==="hsla"&&(l+="a",c.push(e[3])),ii({type:l,values:c})}function Gi(t){t=Ae(t);let e=t.type==="hsl"||t.type==="hsla"?Ae(ir(t)).values:t.values;return e=e.map(s=>(t.type!=="color"&&(s/=255),s<=.03928?s/12.92:((s+.055)/1.055)**2.4)),Number((.2126*e[0]+.7152*e[1]+.0722*e[2]).toFixed(3))}function nr(t,e){const s=Gi(t),i=Gi(e);return(Math.max(s,i)+.05)/(Math.min(s,i)+.05)}function rr(t,e){return t=Ae(t),e=zi(e),(t.type==="rgb"||t.type==="hsl")&&(t.type+="a"),t.type==="color"?t.values[3]=`/${e}`:t.values[3]=e,ii(t)}function Ye(t,e,s){try{return rr(t,e)}catch{return s&&process.env.NODE_ENV!=="production"&&console.warn(s),t}}function ni(t,e){if(t=Ae(t),e=zi(e),t.type.includes("hsl"))t.values[2]*=1-e;else if(t.type.includes("rgb")||t.type.includes("color"))for(let s=0;s<3;s+=1)t.values[s]*=1-e;return ii(t)}function Ot(t,e,s){try{return ni(t,e)}catch{return s&&process.env.NODE_ENV!=="production"&&console.warn(s),t}}function ri(t,e){if(t=Ae(t),e=zi(e),t.type.includes("hsl"))t.values[2]+=(100-t.values[2])*e;else if(t.type.includes("rgb"))for(let s=0;s<3;s+=1)t.values[s]+=(255-t.values[s])*e;else if(t.type.includes("color"))for(let s=0;s<3;s+=1)t.values[s]+=(1-t.values[s])*e;return ii(t)}function Nt(t,e,s){try{return ri(t,e)}catch{return s&&process.env.NODE_ENV!=="production"&&console.warn(s),t}}function Da(t,e=.15){return Gi(t)>.5?ni(t,e):ri(t,e)}function oi(t,e,s){try{return Da(t,e)}catch{return t}}const Pa=Ee.createContext(void 0);process.env.NODE_ENV!=="production"&&(jt.node,jt.object);function Ma(t){const{theme:e,name:s,props:i}=t;if(!e||!e.components||!e.components[s])return i;const n=e.components[s];return n.defaultProps?qi(n.defaultProps,i,e.components.mergeClassNameAndStyle):!n.styleOverrides&&!n.variants?qi(n,i,e.components.mergeClassNameAndStyle):i}function Aa({props:t,name:e}){const s=Ee.useContext(Pa);return Ma({props:t,name:e,theme:{components:s}})}const or={theme:void 0};function Oa(t){let e,s;return function(n){let r=e;return(r===void 0||n.theme!==s)&&(or.theme=n.theme,r=tr(t(or)),e=r,s=n.theme),r}}function Na(t=""){function e(...i){if(!i.length)return"";const n=i[0];return typeof n=="string"&&!n.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))|^(-?(\d*\.)?\d+)$|(\d+ \d+ \d+)/)?`, var(--${t?`${t}-`:""}${n}${e(...i.slice(1))})`:`, ${n}`}return(i,...n)=>`var(--${t?`${t}-`:""}${i}${e(...n)})`}const ar=(t,e,s,i=[])=>{let n=t;e.forEach((r,a)=>{a===e.length-1?Array.isArray(n)?n[Number(r)]=s:n&&typeof n=="object"&&(n[r]=s):n&&typeof n=="object"&&(n[r]||(n[r]=i.includes(r)?[]:{}),n=n[r])})},Ra=(t,e,s)=>{function i(n,r=[],a=[]){Object.entries(n).forEach(([l,c])=>{(!s||s&&!s([...r,l]))&&c!=null&&(typeof c=="object"&&Object.keys(c).length>0?i(c,[...r,l],Array.isArray(c)?[...a,l]:a):e([...r,l],c,a))})}i(t)},$a=(t,e)=>typeof e=="number"?["lineHeight","fontWeight","opacity","zIndex"].some(i=>t.includes(i))||t[t.length-1].toLowerCase().includes("opacity")?e:`${e}px`:e;function Yi(t,e){const{prefix:s,shouldSkipGeneratingVar:i}=e||{},n={},r={},a={};return Ra(t,(l,c,h)=>{if((typeof c=="string"||typeof c=="number")&&(!i||!i(l,c))){const d=`--${s?`${s}-`:""}${l.join("-")}`,p=$a(l,c);Object.assign(n,{[d]:p}),ar(r,l,`var(${d})`,h),ar(a,l,`var(${d}, ${p})`,h)}},l=>l[0]==="vars"),{css:n,vars:r,varsWithDefaults:a}}function La(t,e={}){const{getSelector:s=E,disableCssColorScheme:i,colorSchemeSelector:n,enableContrastVars:r}=e,{colorSchemes:a={},components:l,defaultColorScheme:c="light",...h}=t,{vars:d,css:p,varsWithDefaults:y}=Yi(h,e);let S=y;const I={},{[c]:m,...k}=a;if(Object.entries(k||{}).forEach(([O,M])=>{const{vars:q,css:it,varsWithDefaults:ot}=Yi(M,e);S=de(S,ot),I[O]={css:it,vars:q}}),m){const{css:O,vars:M,varsWithDefaults:q}=Yi(m,e);S=de(S,q),I[c]={css:O,vars:M}}function E(O,M){var it,ot;let q=n;if(n==="class"&&(q=".%s"),n==="data"&&(q="[data-%s]"),n!=null&&n.startsWith("data-")&&!n.includes("%s")&&(q=`[${n}="%s"]`),O){if(q==="media")return t.defaultColorScheme===O?":root":{[`@media (prefers-color-scheme: ${((ot=(it=a[O])==null?void 0:it.palette)==null?void 0:ot.mode)||O})`]:{":root":M}};if(q)return t.defaultColorScheme===O?`:root, ${q.replace("%s",String(O))}`:q.replace("%s",String(O))}return":root"}return{vars:S,generateThemeVars:()=>{let O={...d};return Object.entries(I).forEach(([,{vars:M}])=>{O=de(O,M)}),O},generateStyleSheets:()=>{var U,dt;const O=[],M=t.defaultColorScheme||"light";function q(st,g){Object.keys(g).length&&O.push(typeof st=="string"?{[st]:{...g}}:st)}q(s(void 0,{...p}),p);const{[M]:it,...ot}=I;if(it){const{css:st}=it,g=(dt=(U=a[M])==null?void 0:U.palette)==null?void 0:dt.mode,L=!i&&g?{colorScheme:g,...st}:{...st};q(s(M,{...L}),L)}return Object.entries(ot).forEach(([st,{css:g}])=>{var Q,ct;const L=(ct=(Q=a[st])==null?void 0:Q.palette)==null?void 0:ct.mode,$=!i&&L?{colorScheme:L,...g}:{...g};q(s(st,{...$}),$)}),r&&O.push({":root":{"--__l-threshold":"0.7","--__l":"clamp(0, (l / var(--__l-threshold) - 1) * -infinity, 1)","--__a":"clamp(0.87, (l / var(--__l-threshold) - 1) * -infinity, 1)"}}),O}}}function Wa(t){return function(s){return t==="media"?(process.env.NODE_ENV!=="production"&&s!=="light"&&s!=="dark"&&console.error(`MUI: @media (prefers-color-scheme) supports only 'light' or 'dark', but receive '${s}'.`),`@media (prefers-color-scheme: ${s})`):t?t.startsWith("data-")&&!t.includes("%s")?`[${t}="${s}"] &`:t==="class"?`.${s} &`:t==="data"?`[data-${s}] &`:`${t.replace("%s",s)} &`:"&"}}const Is={black:"#000",white:"#fff"},_a={50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#f5f5f5",A200:"#eeeeee",A400:"#bdbdbd",A700:"#616161"},ss={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},is={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},ks={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},ns={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},rs={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},os={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function lr(){return{text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.38)"},divider:"rgba(0, 0, 0, 0.12)",background:{paper:Is.white,default:Is.white},action:{active:"rgba(0, 0, 0, 0.54)",hover:"rgba(0, 0, 0, 0.04)",hoverOpacity:.04,selected:"rgba(0, 0, 0, 0.08)",selectedOpacity:.08,disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(0, 0, 0, 0.12)",disabledOpacity:.38,focus:"rgba(0, 0, 0, 0.12)",focusOpacity:.12,activatedOpacity:.12}}}const cr=lr();function hr(){return{text:{primary:Is.white,secondary:"rgba(255, 255, 255, 0.7)",disabled:"rgba(255, 255, 255, 0.5)",icon:"rgba(255, 255, 255, 0.5)"},divider:"rgba(255, 255, 255, 0.12)",background:{paper:"#121212",default:"#121212"},action:{active:Is.white,hover:"rgba(255, 255, 255, 0.08)",hoverOpacity:.08,selected:"rgba(255, 255, 255, 0.16)",selectedOpacity:.16,disabled:"rgba(255, 255, 255, 0.3)",disabledBackground:"rgba(255, 255, 255, 0.12)",disabledOpacity:.38,focus:"rgba(255, 255, 255, 0.12)",focusOpacity:.12,activatedOpacity:.24}}}const Vi=hr();function ur(t,e,s,i){const n=i.light||i,r=i.dark||i*1.5;t[e]||(t.hasOwnProperty(s)?t[e]=t[s]:e==="light"?t.light=ri(t.main,n):e==="dark"&&(t.dark=ni(t.main,r)))}function fr(t,e,s,i,n){const r=n.light||n,a=n.dark||n*1.5;e[s]||(e.hasOwnProperty(i)?e[s]=e[i]:s==="light"?e.light=`color-mix(in ${t}, ${e.main}, #fff ${(r*100).toFixed(0)}%)`:s==="dark"&&(e.dark=`color-mix(in ${t}, ${e.main}, #000 ${(a*100).toFixed(0)}%)`))}function Fa(t="light"){return t==="dark"?{main:ns[200],light:ns[50],dark:ns[400]}:{main:ns[700],light:ns[400],dark:ns[800]}}function qa(t="light"){return t==="dark"?{main:ss[200],light:ss[50],dark:ss[400]}:{main:ss[500],light:ss[300],dark:ss[700]}}function za(t="light"){return t==="dark"?{main:is[500],light:is[300],dark:is[700]}:{main:is[700],light:is[400],dark:is[800]}}function Ga(t="light"){return t==="dark"?{main:rs[400],light:rs[300],dark:rs[700]}:{main:rs[700],light:rs[500],dark:rs[900]}}function Ya(t="light"){return t==="dark"?{main:os[400],light:os[300],dark:os[700]}:{main:os[800],light:os[500],dark:os[900]}}function Va(t="light"){return t==="dark"?{main:ks[400],light:ks[300],dark:ks[700]}:{main:"#ed6c02",light:ks[500],dark:ks[900]}}function Ha(t){return`oklch(from ${t} var(--__l) 0 h / var(--__a))`}function Hi(t){const{mode:e="light",contrastThreshold:s=3,tonalOffset:i=.2,colorSpace:n,...r}=t,a=t.primary||Fa(e),l=t.secondary||qa(e),c=t.error||za(e),h=t.info||Ga(e),d=t.success||Ya(e),p=t.warning||Va(e);function y(k){if(n)return Ha(k);const E=nr(k,Vi.text.primary)>=s?Vi.text.primary:cr.text.primary;if(process.env.NODE_ENV!=="production"){const Y=nr(k,E);Y<3&&console.error([`MUI: The contrast ratio of ${Y}:1 for ${E} on ${k}`,"falls below the WCAG recommended absolute minimum contrast ratio of 3:1.","https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast"].join(`
71
+ `))}return E}const S=({color:k,name:E,mainShade:Y=500,lightShade:R=300,darkShade:O=700})=>{if(k={...k},!k.main&&k[Y]&&(k.main=k[Y]),!k.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${E?` (${E})`:""} provided to augmentColor(color) is invalid.
72
+ The color object needs to have a \`main\` property or a \`${Y}\` property.`:De(11,E?` (${E})`:"",Y));if(typeof k.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${E?` (${E})`:""} provided to augmentColor(color) is invalid.
73
+ \`color.main\` should be a string, but \`${JSON.stringify(k.main)}\` was provided instead.
74
+
75
+ Did you intend to use one of the following approaches?
76
+
77
+ import { green } from "@mui/material/colors";
78
+
79
+ const theme1 = createTheme({ palette: {
80
+ primary: green,
81
+ } });
82
+
83
+ const theme2 = createTheme({ palette: {
84
+ primary: { main: green[500] },
85
+ } });`:De(12,E?` (${E})`:"",JSON.stringify(k.main)));return n?(fr(n,k,"light",R,i),fr(n,k,"dark",O,i)):(ur(k,"light",R,i),ur(k,"dark",O,i)),k.contrastText||(k.contrastText=y(k.main)),k};let I;return e==="light"?I=lr():e==="dark"&&(I=hr()),process.env.NODE_ENV!=="production"&&(I||console.error(`MUI: The palette mode \`${e}\` is not supported.`)),de({common:{...Is},mode:e,primary:S({color:a,name:"primary"}),secondary:S({color:l,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:S({color:c,name:"error"}),warning:S({color:p,name:"warning"}),info:S({color:h,name:"info"}),success:S({color:d,name:"success"}),grey:_a,contrastThreshold:s,getContrastText:y,augmentColor:S,tonalOffset:i,...I},r)}function Ka(t){const e={};return Object.entries(t).forEach(i=>{const[n,r]=i;typeof r=="object"&&(e[n]=`${r.fontStyle?`${r.fontStyle} `:""}${r.fontVariant?`${r.fontVariant} `:""}${r.fontWeight?`${r.fontWeight} `:""}${r.fontStretch?`${r.fontStretch} `:""}${r.fontSize||""}${r.lineHeight?`/${r.lineHeight} `:""}${r.fontFamily||""}`)}),e}function Qa(t,e){return{toolbar:{minHeight:56,[t.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[t.up("sm")]:{minHeight:64}},...e}}function Ua(t){return Math.round(t*1e5)/1e5}const dr={textTransform:"uppercase"},pr='"Roboto", "Helvetica", "Arial", sans-serif';function Xa(t,e){const{fontFamily:s=pr,fontSize:i=14,fontWeightLight:n=300,fontWeightRegular:r=400,fontWeightMedium:a=500,fontWeightBold:l=700,htmlFontSize:c=16,allVariants:h,pxToRem:d,...p}=typeof e=="function"?e(t):e;process.env.NODE_ENV!=="production"&&(typeof i!="number"&&console.error("MUI: `fontSize` is required to be a number."),typeof c!="number"&&console.error("MUI: `htmlFontSize` is required to be a number."));const y=i/14,S=d||(k=>`${k/c*y}rem`),I=(k,E,Y,R,O)=>({fontFamily:s,fontWeight:k,fontSize:S(E),lineHeight:Y,...s===pr?{letterSpacing:`${Ua(R/E)}em`}:{},...O,...h}),m={h1:I(n,96,1.167,-1.5),h2:I(n,60,1.2,-.5),h3:I(r,48,1.167,0),h4:I(r,34,1.235,.25),h5:I(r,24,1.334,0),h6:I(a,20,1.6,.15),subtitle1:I(r,16,1.75,.15),subtitle2:I(a,14,1.57,.1),body1:I(r,16,1.5,.15),body2:I(r,14,1.43,.15),button:I(a,14,1.75,.4,dr),caption:I(r,12,1.66,.4),overline:I(r,12,2.66,1,dr),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return de({htmlFontSize:c,pxToRem:S,fontFamily:s,fontSize:i,fontWeightLight:n,fontWeightRegular:r,fontWeightMedium:a,fontWeightBold:l,...m},p,{clone:!1})}const Ja=.2,Za=.14,tl=.12;function Ft(...t){return[`${t[0]}px ${t[1]}px ${t[2]}px ${t[3]}px rgba(0,0,0,${Ja})`,`${t[4]}px ${t[5]}px ${t[6]}px ${t[7]}px rgba(0,0,0,${Za})`,`${t[8]}px ${t[9]}px ${t[10]}px ${t[11]}px rgba(0,0,0,${tl})`].join(",")}const el=["none",Ft(0,2,1,-1,0,1,1,0,0,1,3,0),Ft(0,3,1,-2,0,2,2,0,0,1,5,0),Ft(0,3,3,-2,0,3,4,0,0,1,8,0),Ft(0,2,4,-1,0,4,5,0,0,1,10,0),Ft(0,3,5,-1,0,5,8,0,0,1,14,0),Ft(0,3,5,-1,0,6,10,0,0,1,18,0),Ft(0,4,5,-2,0,7,10,1,0,2,16,1),Ft(0,5,5,-3,0,8,10,1,0,3,14,2),Ft(0,5,6,-3,0,9,12,1,0,3,16,2),Ft(0,6,6,-3,0,10,14,1,0,4,18,3),Ft(0,6,7,-4,0,11,15,1,0,4,20,3),Ft(0,7,8,-4,0,12,17,2,0,5,22,4),Ft(0,7,8,-4,0,13,19,2,0,5,24,4),Ft(0,7,9,-4,0,14,21,2,0,5,26,4),Ft(0,8,9,-5,0,15,22,2,0,6,28,5),Ft(0,8,10,-5,0,16,24,2,0,6,30,5),Ft(0,8,11,-5,0,17,26,2,0,6,32,5),Ft(0,9,11,-5,0,18,28,2,0,7,34,6),Ft(0,9,12,-6,0,19,29,2,0,7,36,6),Ft(0,10,13,-6,0,20,31,3,0,8,38,7),Ft(0,10,13,-6,0,21,33,3,0,8,40,7),Ft(0,10,14,-6,0,22,35,3,0,8,42,7),Ft(0,11,14,-7,0,23,36,3,0,9,44,8),Ft(0,11,15,-7,0,24,38,3,0,9,46,8)],sl={easeInOut:"cubic-bezier(0.4, 0, 0.2, 1)",easeOut:"cubic-bezier(0.0, 0, 0.2, 1)",easeIn:"cubic-bezier(0.4, 0, 1, 1)",sharp:"cubic-bezier(0.4, 0, 0.6, 1)"},il={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function gr(t){return`${Math.round(t)}ms`}function nl(t){if(!t)return 0;const e=t/36;return Math.min(Math.round((4+15*e**.25+e/5)*10),3e3)}function rl(t){const e={...sl,...t.easing},s={...il,...t.duration};return{getAutoHeightDuration:nl,create:(n=["all"],r={})=>{const{duration:a=s.standard,easing:l=e.easeInOut,delay:c=0,...h}=r;if(process.env.NODE_ENV!=="production"){const d=y=>typeof y=="string",p=y=>!Number.isNaN(parseFloat(y));!d(n)&&!Array.isArray(n)&&console.error('MUI: Argument "props" must be a string or Array.'),!p(a)&&!d(a)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${a}.`),d(l)||console.error('MUI: Argument "easing" must be a string.'),!p(c)&&!d(c)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof r!="object"&&console.error(["MUI: Secong argument of transition.create must be an object.","Arguments should be either `create('prop1', options)` or `create(['prop1', 'prop2'], options)`"].join(`
86
+ `)),Object.keys(h).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(h).join(",")}].`)}return(Array.isArray(n)?n:[n]).map(d=>`${d} ${typeof a=="string"?a:gr(a)} ${l} ${typeof c=="string"?c:gr(c)}`).join(",")},...t,easing:e,duration:s}}const ol={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function al(t){return we(t)||typeof t>"u"||typeof t=="string"||typeof t=="boolean"||typeof t=="number"||Array.isArray(t)}function mr(t={}){const e={...t};function s(i){const n=Object.entries(i);for(let r=0;r<n.length;r++){const[a,l]=n[r];!al(l)||a.startsWith("unstable_")?delete i[a]:we(l)&&(i[a]={...l},s(i[a]))}}return s(e),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
87
+
88
+ const theme = ${JSON.stringify(e,null,2)};
89
+
90
+ theme.breakpoints = createBreakpoints(theme.breakpoints || {});
91
+ theme.transitions = createTransitions(theme.transitions || {});
92
+
93
+ export default theme;`}function xr(t){return typeof t=="number"?`${(t*100).toFixed(0)}%`:`calc((${t}) * 100%)`}const ll=t=>{if(!Number.isNaN(+t))return+t;const e=t.match(/\d*\.?\d+/g);if(!e)return 0;let s=0;for(let i=0;i<e.length;i+=1)s+=+e[i];return s};function cl(t){Object.assign(t,{alpha(e,s){const i=this||t;return i.colorSpace?`oklch(from ${e} l c h / ${typeof s=="string"?`calc(${s})`:s})`:i.vars?`rgba(${e.replace(/var\(--([^,\s)]+)(?:,[^)]+)?\)+/g,"var(--$1Channel)")} / ${typeof s=="string"?`calc(${s})`:s})`:rr(e,ll(s))},lighten(e,s){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${e}, #fff ${xr(s)})`:ri(e,s)},darken(e,s){const i=this||t;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${e}, #000 ${xr(s)})`:ni(e,s)}})}function Ki(t={},...e){const{breakpoints:s,mixins:i={},spacing:n,palette:r={},transitions:a={},typography:l={},shape:c,colorSpace:h,...d}=t;if(t.vars&&t.generateThemeVars===void 0)throw new Error(process.env.NODE_ENV!=="production"?"MUI: `vars` is a private field used for CSS variables support.\nPlease use another name or follow the [docs](https://mui.com/material-ui/customization/css-theme-variables/usage/) to enable the feature.":De(20));const p=Hi({...r,colorSpace:h}),y=Xn(t);let S=de(y,{mixins:Qa(y.breakpoints,i),palette:p,shadows:el.slice(),typography:Xa(p,l),transitions:rl(a),zIndex:{...ol}});if(S=de(S,d),S=e.reduce((I,m)=>de(I,m),S),process.env.NODE_ENV!=="production"){const I=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],m=(k,E)=>{let Y;for(Y in k){const R=k[Y];if(I.includes(Y)&&Object.keys(R).length>0){if(process.env.NODE_ENV!=="production"){const O=_i("",Y);console.error([`MUI: The \`${E}\` component increases the CSS specificity of the \`${Y}\` internal state.`,"You can not override it like this: ",JSON.stringify(k,null,2),"",`Instead, you need to use the '&.${O}' syntax:`,JSON.stringify({root:{[`&.${O}`]:R}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
94
+ `))}k[Y]={}}}};Object.keys(S.components).forEach(k=>{const E=S.components[k].styleOverrides;E&&k.startsWith("Mui")&&m(E,k)})}return S.unstable_sxConfig={...ti,...d==null?void 0:d.unstable_sxConfig},S.unstable_sx=function(m){return es({sx:m,theme:this})},S.toRuntimeSource=mr,cl(S),S}function hl(t){let e;return t<1?e=5.11916*t**2:e=4.5*Math.log(t+1)+2,Math.round(e*10)/1e3}const ul=[...Array(25)].map((t,e)=>{if(e===0)return"none";const s=hl(e);return`linear-gradient(rgba(255 255 255 / ${s}), rgba(255 255 255 / ${s}))`});function yr(t){return{inputPlaceholder:t==="dark"?.5:.42,inputUnderline:t==="dark"?.7:.42,switchTrackDisabled:t==="dark"?.2:.12,switchTrack:t==="dark"?.3:.38}}function vr(t){return t==="dark"?ul:[]}function fl(t){const{palette:e={mode:"light"},opacity:s,overlays:i,colorSpace:n,...r}=t,a=Hi({...e,colorSpace:n});return{palette:a,opacity:{...yr(a.mode),...s},overlays:i||vr(a.mode),...r}}function dl(t){var e;return!!t[0].match(/(cssVarPrefix|colorSchemeSelector|modularCssLayers|rootSelector|typography|mixins|breakpoints|direction|transitions)/)||!!t[0].match(/sxConfig$/)||t[0]==="palette"&&!!((e=t[1])!=null&&e.match(/(mode|contrastThreshold|tonalOffset)/))}const pl=t=>[...[...Array(25)].map((e,s)=>`--${t?`${t}-`:""}overlays-${s}`),`--${t?`${t}-`:""}palette-AppBar-darkBg`,`--${t?`${t}-`:""}palette-AppBar-darkColor`],gl=t=>(e,s)=>{const i=t.rootSelector||":root",n=t.colorSchemeSelector;let r=n;if(n==="class"&&(r=".%s"),n==="data"&&(r="[data-%s]"),n!=null&&n.startsWith("data-")&&!n.includes("%s")&&(r=`[${n}="%s"]`),t.defaultColorScheme===e){if(e==="dark"){const a={};return pl(t.cssVarPrefix).forEach(l=>{a[l]=s[l],delete s[l]}),r==="media"?{[i]:s,"@media (prefers-color-scheme: dark)":{[i]:a}}:r?{[r.replace("%s",e)]:a,[`${i}, ${r.replace("%s",e)}`]:s}:{[i]:{...s,...a}}}if(r&&r!=="media")return`${i}, ${r.replace("%s",String(e))}`}else if(e){if(r==="media")return{[`@media (prefers-color-scheme: ${String(e)})`]:{[i]:s}};if(r)return r.replace("%s",String(e))}return i};function ml(t,e){e.forEach(s=>{t[s]||(t[s]={})})}function A(t,e,s){!t[e]&&s&&(t[e]=s)}function js(t){return typeof t!="string"||!t.startsWith("hsl")?t:ir(t)}function Ie(t,e){`${e}Channel`in t||(t[`${e}Channel`]=Cs(js(t[e]),`MUI: Can't create \`palette.${e}Channel\` because \`palette.${e}\` is not one of these formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().
95
+ To suppress this warning, you need to explicitly provide the \`palette.${e}Channel\` as a string (in rgb format, for example "12 12 12") or undefined if you want to remove the channel token.`))}function xl(t){return typeof t=="number"?`${t}px`:typeof t=="string"||typeof t=="function"||Array.isArray(t)?t:"8px"}const Te=t=>{try{return t()}catch{}},yl=(t="mui")=>Na(t);function Qi(t,e,s,i,n){if(!s)return;s=s===!0?{}:s;const r=n==="dark"?"dark":"light";if(!i){e[n]=fl({...s,palette:{mode:r,...s==null?void 0:s.palette},colorSpace:t});return}const{palette:a,...l}=Ki({...i,palette:{mode:r,...s==null?void 0:s.palette},colorSpace:t});return e[n]={...s,palette:a,opacity:{...yr(r),...s==null?void 0:s.opacity},overlays:(s==null?void 0:s.overlays)||vr(r)},l}function vl(t={},...e){const{colorSchemes:s={light:!0},defaultColorScheme:i,disableCssColorScheme:n=!1,cssVarPrefix:r="mui",nativeColor:a=!1,shouldSkipGeneratingVar:l=dl,colorSchemeSelector:c=s.light&&s.dark?"media":void 0,rootSelector:h=":root",...d}=t,p=Object.keys(s)[0],y=i||(s.light&&p!=="light"?"light":p),S=yl(r),{[y]:I,light:m,dark:k,...E}=s,Y={...E};let R=I;if((y==="dark"&&!("dark"in s)||y==="light"&&!("light"in s))&&(R=!0),!R)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${y}\` option is either missing or invalid.`:De(21,y));let O;a&&(O="oklch");const M=Qi(O,Y,R,d,y);m&&!Y.light&&Qi(O,Y,m,void 0,"light"),k&&!Y.dark&&Qi(O,Y,k,void 0,"dark");let q={defaultColorScheme:y,...M,cssVarPrefix:r,colorSchemeSelector:c,rootSelector:h,getCssVar:S,colorSchemes:Y,font:{...Ka(M.typography),...M.font},spacing:xl(d.spacing)};Object.keys(q.colorSchemes).forEach(st=>{const g=q.colorSchemes[st].palette,L=Q=>{const ct=Q.split("-"),bt=ct[1],ht=ct[2];return S(Q,g[bt][ht])};g.mode==="light"&&(A(g.common,"background","#fff"),A(g.common,"onBackground","#000")),g.mode==="dark"&&(A(g.common,"background","#000"),A(g.common,"onBackground","#fff"));function $(Q,ct,bt){if(O){let ht;return Q===Ye&&(ht=`transparent ${((1-bt)*100).toFixed(0)}%`),Q===Ot&&(ht=`#000 ${(bt*100).toFixed(0)}%`),Q===Nt&&(ht=`#fff ${(bt*100).toFixed(0)}%`),`color-mix(in ${O}, ${ct}, ${ht})`}return Q(ct,bt)}if(ml(g,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),g.mode==="light"){A(g.Alert,"errorColor",$(Ot,g.error.light,.6)),A(g.Alert,"infoColor",$(Ot,g.info.light,.6)),A(g.Alert,"successColor",$(Ot,g.success.light,.6)),A(g.Alert,"warningColor",$(Ot,g.warning.light,.6)),A(g.Alert,"errorFilledBg",L("palette-error-main")),A(g.Alert,"infoFilledBg",L("palette-info-main")),A(g.Alert,"successFilledBg",L("palette-success-main")),A(g.Alert,"warningFilledBg",L("palette-warning-main")),A(g.Alert,"errorFilledColor",Te(()=>g.getContrastText(g.error.main))),A(g.Alert,"infoFilledColor",Te(()=>g.getContrastText(g.info.main))),A(g.Alert,"successFilledColor",Te(()=>g.getContrastText(g.success.main))),A(g.Alert,"warningFilledColor",Te(()=>g.getContrastText(g.warning.main))),A(g.Alert,"errorStandardBg",$(Nt,g.error.light,.9)),A(g.Alert,"infoStandardBg",$(Nt,g.info.light,.9)),A(g.Alert,"successStandardBg",$(Nt,g.success.light,.9)),A(g.Alert,"warningStandardBg",$(Nt,g.warning.light,.9)),A(g.Alert,"errorIconColor",L("palette-error-main")),A(g.Alert,"infoIconColor",L("palette-info-main")),A(g.Alert,"successIconColor",L("palette-success-main")),A(g.Alert,"warningIconColor",L("palette-warning-main")),A(g.AppBar,"defaultBg",L("palette-grey-100")),A(g.Avatar,"defaultBg",L("palette-grey-400")),A(g.Button,"inheritContainedBg",L("palette-grey-300")),A(g.Button,"inheritContainedHoverBg",L("palette-grey-A100")),A(g.Chip,"defaultBorder",L("palette-grey-400")),A(g.Chip,"defaultAvatarColor",L("palette-grey-700")),A(g.Chip,"defaultIconColor",L("palette-grey-700")),A(g.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),A(g.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),A(g.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),A(g.LinearProgress,"primaryBg",$(Nt,g.primary.main,.62)),A(g.LinearProgress,"secondaryBg",$(Nt,g.secondary.main,.62)),A(g.LinearProgress,"errorBg",$(Nt,g.error.main,.62)),A(g.LinearProgress,"infoBg",$(Nt,g.info.main,.62)),A(g.LinearProgress,"successBg",$(Nt,g.success.main,.62)),A(g.LinearProgress,"warningBg",$(Nt,g.warning.main,.62)),A(g.Skeleton,"bg",O?$(Ye,g.text.primary,.11):`rgba(${L("palette-text-primaryChannel")} / 0.11)`),A(g.Slider,"primaryTrack",$(Nt,g.primary.main,.62)),A(g.Slider,"secondaryTrack",$(Nt,g.secondary.main,.62)),A(g.Slider,"errorTrack",$(Nt,g.error.main,.62)),A(g.Slider,"infoTrack",$(Nt,g.info.main,.62)),A(g.Slider,"successTrack",$(Nt,g.success.main,.62)),A(g.Slider,"warningTrack",$(Nt,g.warning.main,.62));const Q=O?$(Ot,g.background.default,.6825):oi(g.background.default,.8);A(g.SnackbarContent,"bg",Q),A(g.SnackbarContent,"color",Te(()=>O?Vi.text.primary:g.getContrastText(Q))),A(g.SpeedDialAction,"fabHoverBg",oi(g.background.paper,.15)),A(g.StepConnector,"border",L("palette-grey-400")),A(g.StepContent,"border",L("palette-grey-400")),A(g.Switch,"defaultColor",L("palette-common-white")),A(g.Switch,"defaultDisabledColor",L("palette-grey-100")),A(g.Switch,"primaryDisabledColor",$(Nt,g.primary.main,.62)),A(g.Switch,"secondaryDisabledColor",$(Nt,g.secondary.main,.62)),A(g.Switch,"errorDisabledColor",$(Nt,g.error.main,.62)),A(g.Switch,"infoDisabledColor",$(Nt,g.info.main,.62)),A(g.Switch,"successDisabledColor",$(Nt,g.success.main,.62)),A(g.Switch,"warningDisabledColor",$(Nt,g.warning.main,.62)),A(g.TableCell,"border",$(Nt,$(Ye,g.divider,1),.88)),A(g.Tooltip,"bg",$(Ye,g.grey[700],.92))}if(g.mode==="dark"){A(g.Alert,"errorColor",$(Nt,g.error.light,.6)),A(g.Alert,"infoColor",$(Nt,g.info.light,.6)),A(g.Alert,"successColor",$(Nt,g.success.light,.6)),A(g.Alert,"warningColor",$(Nt,g.warning.light,.6)),A(g.Alert,"errorFilledBg",L("palette-error-dark")),A(g.Alert,"infoFilledBg",L("palette-info-dark")),A(g.Alert,"successFilledBg",L("palette-success-dark")),A(g.Alert,"warningFilledBg",L("palette-warning-dark")),A(g.Alert,"errorFilledColor",Te(()=>g.getContrastText(g.error.dark))),A(g.Alert,"infoFilledColor",Te(()=>g.getContrastText(g.info.dark))),A(g.Alert,"successFilledColor",Te(()=>g.getContrastText(g.success.dark))),A(g.Alert,"warningFilledColor",Te(()=>g.getContrastText(g.warning.dark))),A(g.Alert,"errorStandardBg",$(Ot,g.error.light,.9)),A(g.Alert,"infoStandardBg",$(Ot,g.info.light,.9)),A(g.Alert,"successStandardBg",$(Ot,g.success.light,.9)),A(g.Alert,"warningStandardBg",$(Ot,g.warning.light,.9)),A(g.Alert,"errorIconColor",L("palette-error-main")),A(g.Alert,"infoIconColor",L("palette-info-main")),A(g.Alert,"successIconColor",L("palette-success-main")),A(g.Alert,"warningIconColor",L("palette-warning-main")),A(g.AppBar,"defaultBg",L("palette-grey-900")),A(g.AppBar,"darkBg",L("palette-background-paper")),A(g.AppBar,"darkColor",L("palette-text-primary")),A(g.Avatar,"defaultBg",L("palette-grey-600")),A(g.Button,"inheritContainedBg",L("palette-grey-800")),A(g.Button,"inheritContainedHoverBg",L("palette-grey-700")),A(g.Chip,"defaultBorder",L("palette-grey-700")),A(g.Chip,"defaultAvatarColor",L("palette-grey-300")),A(g.Chip,"defaultIconColor",L("palette-grey-300")),A(g.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),A(g.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),A(g.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),A(g.LinearProgress,"primaryBg",$(Ot,g.primary.main,.5)),A(g.LinearProgress,"secondaryBg",$(Ot,g.secondary.main,.5)),A(g.LinearProgress,"errorBg",$(Ot,g.error.main,.5)),A(g.LinearProgress,"infoBg",$(Ot,g.info.main,.5)),A(g.LinearProgress,"successBg",$(Ot,g.success.main,.5)),A(g.LinearProgress,"warningBg",$(Ot,g.warning.main,.5)),A(g.Skeleton,"bg",O?$(Ye,g.text.primary,.13):`rgba(${L("palette-text-primaryChannel")} / 0.13)`),A(g.Slider,"primaryTrack",$(Ot,g.primary.main,.5)),A(g.Slider,"secondaryTrack",$(Ot,g.secondary.main,.5)),A(g.Slider,"errorTrack",$(Ot,g.error.main,.5)),A(g.Slider,"infoTrack",$(Ot,g.info.main,.5)),A(g.Slider,"successTrack",$(Ot,g.success.main,.5)),A(g.Slider,"warningTrack",$(Ot,g.warning.main,.5));const Q=O?$(Nt,g.background.default,.985):oi(g.background.default,.98);A(g.SnackbarContent,"bg",Q),A(g.SnackbarContent,"color",Te(()=>O?cr.text.primary:g.getContrastText(Q))),A(g.SpeedDialAction,"fabHoverBg",oi(g.background.paper,.15)),A(g.StepConnector,"border",L("palette-grey-600")),A(g.StepContent,"border",L("palette-grey-600")),A(g.Switch,"defaultColor",L("palette-grey-300")),A(g.Switch,"defaultDisabledColor",L("palette-grey-600")),A(g.Switch,"primaryDisabledColor",$(Ot,g.primary.main,.55)),A(g.Switch,"secondaryDisabledColor",$(Ot,g.secondary.main,.55)),A(g.Switch,"errorDisabledColor",$(Ot,g.error.main,.55)),A(g.Switch,"infoDisabledColor",$(Ot,g.info.main,.55)),A(g.Switch,"successDisabledColor",$(Ot,g.success.main,.55)),A(g.Switch,"warningDisabledColor",$(Ot,g.warning.main,.55)),A(g.TableCell,"border",$(Ot,$(Ye,g.divider,1),.68)),A(g.Tooltip,"bg",$(Ye,g.grey[700],.92))}Ie(g.background,"default"),Ie(g.background,"paper"),Ie(g.common,"background"),Ie(g.common,"onBackground"),Ie(g,"divider"),Object.keys(g).forEach(Q=>{const ct=g[Q];Q!=="tonalOffset"&&ct&&typeof ct=="object"&&(ct.main&&A(g[Q],"mainChannel",Cs(js(ct.main))),ct.light&&A(g[Q],"lightChannel",Cs(js(ct.light))),ct.dark&&A(g[Q],"darkChannel",Cs(js(ct.dark))),ct.contrastText&&A(g[Q],"contrastTextChannel",Cs(js(ct.contrastText))),Q==="text"&&(Ie(g[Q],"primary"),Ie(g[Q],"secondary")),Q==="action"&&(ct.active&&Ie(g[Q],"active"),ct.selected&&Ie(g[Q],"selected")))})}),q=e.reduce((st,g)=>de(st,g),q);const it={prefix:r,disableCssColorScheme:n,shouldSkipGeneratingVar:l,getSelector:gl(q),enableContrastVars:a},{vars:ot,generateThemeVars:U,generateStyleSheets:dt}=La(q,it);return q.vars=ot,Object.entries(q.colorSchemes[q.defaultColorScheme]).forEach(([st,g])=>{q[st]=g}),q.generateThemeVars=U,q.generateStyleSheets=dt,q.generateSpacing=function(){return Un(d.spacing,$i(this))},q.getColorSchemeSelector=Wa(c),q.spacing=q.generateSpacing(),q.shouldSkipGeneratingVar=l,q.unstable_sxConfig={...ti,...d==null?void 0:d.unstable_sxConfig},q.unstable_sx=function(g){return es({sx:g,theme:this})},q.toRuntimeSource=mr,q}function br(t,e,s){t.colorSchemes&&s&&(t.colorSchemes[e]={...s!==!0&&s,palette:Hi({...s===!0?{}:s.palette,mode:e})})}function bl(t={},...e){const{palette:s,cssVariables:i=!1,colorSchemes:n=s?void 0:{light:!0},defaultColorScheme:r=s==null?void 0:s.mode,...a}=t,l=r||"light",c=n==null?void 0:n[l],h={...n,...s?{[l]:{...typeof c!="boolean"&&c,palette:s}}:void 0};if(i===!1){if(!("colorSchemes"in t))return Ki(t,...e);let d=s;"palette"in t||h[l]&&(h[l]!==!0?d=h[l].palette:l==="dark"&&(d={mode:"dark"}));const p=Ki({...t,palette:d},...e);return p.defaultColorScheme=l,p.colorSchemes=h,p.palette.mode==="light"&&(p.colorSchemes.light={...h.light!==!0&&h.light,palette:p.palette},br(p,"dark",h.dark)),p.palette.mode==="dark"&&(p.colorSchemes.dark={...h.dark!==!0&&h.dark,palette:p.palette},br(p,"light",h.light)),p}return!s&&!("light"in h)&&l==="light"&&(h.light=!0),vl({...a,colorSchemes:h,defaultColorScheme:l,...typeof i!="boolean"&&i},...e)}const Tl=bl(),Sl="$$material";function wl(t){return t!=="ownerState"&&t!=="theme"&&t!=="sx"&&t!=="as"}const Cl=Sa({themeId:Sl,defaultTheme:Tl,rootShouldForwardProp:t=>wl(t)&&t!=="classes"}),Il=Oa;process.env.NODE_ENV!=="production"&&(jt.node,jt.object.isRequired);function kl(t){return Aa(t)}function jl(t){return _i("MuiSvgIcon",t)}xa("MuiSvgIcon",["root","colorPrimary","colorSecondary","colorAction","colorError","colorDisabled","fontSizeInherit","fontSizeSmall","fontSizeMedium","fontSizeLarge"]);const El=t=>{const{color:e,fontSize:s,classes:i}=t,n={root:["root",e!=="inherit"&&`color${qe(e)}`,`fontSize${qe(s)}`]};return lo(n,jl,i)},Bl=Cl("svg",{name:"MuiSvgIcon",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:s}=t;return[e.root,s.color!=="inherit"&&e[`color${qe(s.color)}`],e[`fontSize${qe(s.fontSize)}`]]}})(Il(({theme:t})=>{var e,s,i,n,r,a,l,c,h,d,p,y,S,I;return{userSelect:"none",width:"1em",height:"1em",display:"inline-block",flexShrink:0,transition:(n=(e=t.transitions)==null?void 0:e.create)==null?void 0:n.call(e,"fill",{duration:(i=(s=(t.vars??t).transitions)==null?void 0:s.duration)==null?void 0:i.shorter}),variants:[{props:m=>!m.hasSvgAsChild,style:{fill:"currentColor"}},{props:{fontSize:"inherit"},style:{fontSize:"inherit"}},{props:{fontSize:"small"},style:{fontSize:((a=(r=t.typography)==null?void 0:r.pxToRem)==null?void 0:a.call(r,20))||"1.25rem"}},{props:{fontSize:"medium"},style:{fontSize:((c=(l=t.typography)==null?void 0:l.pxToRem)==null?void 0:c.call(l,24))||"1.5rem"}},{props:{fontSize:"large"},style:{fontSize:((d=(h=t.typography)==null?void 0:h.pxToRem)==null?void 0:d.call(h,35))||"2.1875rem"}},...Object.entries((t.vars??t).palette).filter(([,m])=>m&&m.main).map(([m])=>{var k,E;return{props:{color:m},style:{color:(E=(k=(t.vars??t).palette)==null?void 0:k[m])==null?void 0:E.main}}}),{props:{color:"action"},style:{color:(y=(p=(t.vars??t).palette)==null?void 0:p.action)==null?void 0:y.active}},{props:{color:"disabled"},style:{color:(I=(S=(t.vars??t).palette)==null?void 0:S.action)==null?void 0:I.disabled}},{props:{color:"inherit"},style:{color:void 0}}]}})),ai=Ee.forwardRef(function(e,s){const i=kl({props:e,name:"MuiSvgIcon"}),{children:n,className:r,color:a="inherit",component:l="svg",fontSize:c="medium",htmlColor:h,inheritViewBox:d=!1,titleAccess:p,viewBox:y="0 0 24 24",...S}=i,I=Ee.isValidElement(n)&&n.type==="svg",m={...i,color:a,component:l,fontSize:c,instanceFontSize:e.fontSize,inheritViewBox:d,viewBox:y,hasSvgAsChild:I},k={};d||(k.viewBox=y);const E=El(m);return o.jsxs(Bl,{as:l,className:Rn(E.root,r),focusable:"false",color:h,"aria-hidden":p?void 0:!0,role:p?"img":void 0,ref:s,...k,...S,...I&&n.props,ownerState:m,children:[I?n.props.children:n,p?o.jsx("title",{children:p}):null]})});process.env.NODE_ENV!=="production"&&(ai.propTypes={children:jt.node,classes:jt.object,className:jt.string,color:jt.oneOfType([jt.oneOf(["inherit","action","disabled","primary","secondary","error","info","success","warning"]),jt.string]),component:jt.elementType,fontSize:jt.oneOfType([jt.oneOf(["inherit","large","medium","small"]),jt.string]),htmlColor:jt.string,inheritViewBox:jt.bool,shapeRendering:jt.string,sx:jt.oneOfType([jt.arrayOf(jt.oneOfType([jt.func,jt.object,jt.bool])),jt.func,jt.object]),titleAccess:jt.string,viewBox:jt.string}),ai.muiName="SvgIcon";function Dl(t,e){function s(i,n){return o.jsx(ai,{"data-testid":process.env.NODE_ENV!=="production"?`${e}Icon`:void 0,ref:n,...i,children:t})}return process.env.NODE_ENV!=="production"&&(s.displayName=`${e}Icon`),s.muiName=ai.muiName,Ee.memo(Ee.forwardRef(s))}const li=Dl(o.jsx("path",{d:"m19 9 1.25-2.75L23 5l-2.75-1.25L19 1l-1.25 2.75L15 5l2.75 1.25zm-7.5.5L9 4 6.5 9.5 1 12l5.5 2.5L9 20l2.5-5.5L17 12zM19 15l-1.25 2.75L15 19l2.75 1.25L19 23l1.25-2.75L23 19l-2.75-1.25z"}),"AutoAwesome"),Pl=()=>o.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M12 2v20"}),o.jsx("path",{d:"M5 22h14"}),o.jsx("path",{d:"m16 7-4 10"}),o.jsx("path",{d:"m9 12 3-8"})]}),Ml=t=>o.jsx(u.SvgIcon,{...t,viewBox:"0 0 24 24",children:o.jsx("path",{fill:"currentColor",d:"M4 11h3l9-2.5V15.5L7 13H4v-2m12-2.5c2.5-1 5-3 6-5v11c-1-2-3.5-4-6-5v-1M9 11V6h1v5m2 0V6h1v5m2 0V6h1v5"})}),Al=t=>o.jsxs(u.SvgIcon,{...t,viewBox:"0 0 24 24",children:[o.jsx("path",{fill:"currentColor",d:"M6 18.57V6.43L18 12.5m-12-8.5v16.36L18 12L6 4.07Z",opacity:".3"}),o.jsx("path",{fill:"currentColor",d:"M6 18.57V6.43L18 12.5L6 18.57Zm0-14.5L18 12L6 19.93V4.07Z"})]}),Ol=()=>o.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:o.jsx("ellipse",{cx:"12",cy:"12",rx:"6",ry:"4",strokeWidth:"1.5"})}),Nl=()=>o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:[o.jsx("ellipse",{cx:"8",cy:"16",rx:"5",ry:"3.5",strokeWidth:"1.5"}),o.jsx("line",{x1:"13",y1:"16",x2:"13",y2:"4",strokeWidth:"1.5"})]}),Rl=()=>o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor",children:[o.jsx("ellipse",{cx:"8",cy:"16",rx:"5",ry:"3.5"}),o.jsx("line",{x1:"13",y1:"16",x2:"13",y2:"4",stroke:"currentColor",strokeWidth:"1.5"})]}),$l=()=>o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor",children:[o.jsx("ellipse",{cx:"8",cy:"16",rx:"5",ry:"3.5"}),o.jsx("line",{x1:"13",y1:"16",x2:"13",y2:"4",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("line",{x1:"13",y1:"4",x2:"17",y2:"6",stroke:"currentColor",strokeWidth:"1.8"})]}),Ll=()=>o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor",children:[o.jsx("ellipse",{cx:"8",cy:"16",rx:"5",ry:"3.5"}),o.jsx("line",{x1:"13",y1:"16",x2:"13",y2:"4",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("line",{x1:"13",y1:"4",x2:"17",y2:"6",stroke:"currentColor",strokeWidth:"1.8"}),o.jsx("line",{x1:"13",y1:"6",x2:"17",y2:"8",stroke:"currentColor",strokeWidth:"1.8"})]}),Wl=()=>o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor",children:[o.jsx("ellipse",{cx:"8",cy:"16",rx:"5",ry:"3.5"}),o.jsx("line",{x1:"13",y1:"16",x2:"13",y2:"4",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("line",{x1:"13",y1:"4",x2:"17",y2:"6",stroke:"currentColor",strokeWidth:"1.8"}),o.jsx("line",{x1:"13",y1:"6",x2:"17",y2:"8",stroke:"currentColor",strokeWidth:"1.8"}),o.jsx("line",{x1:"13",y1:"8",x2:"17",y2:"10",stroke:"currentColor",strokeWidth:"1.8"})]}),_l=()=>o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor",children:[o.jsx("ellipse",{cx:"8",cy:"16",rx:"5",ry:"3.5"}),o.jsx("line",{x1:"13",y1:"16",x2:"13",y2:"4",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("line",{x1:"13",y1:"4",x2:"17",y2:"6",stroke:"currentColor",strokeWidth:"1.8"}),o.jsx("line",{x1:"13",y1:"6",x2:"17",y2:"8",stroke:"currentColor",strokeWidth:"1.8"}),o.jsx("line",{x1:"13",y1:"8",x2:"17",y2:"10",stroke:"currentColor",strokeWidth:"1.8"}),o.jsx("line",{x1:"13",y1:"10",x2:"17",y2:"12",stroke:"currentColor",strokeWidth:"1.8"})]}),Fl=()=>o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor",children:[o.jsx("ellipse",{cx:"8",cy:"16",rx:"5",ry:"3.5"}),o.jsx("line",{x1:"13",y1:"16",x2:"13",y2:"4",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("line",{x1:"13",y1:"4",x2:"17",y2:"6",stroke:"currentColor",strokeWidth:"1.8"}),o.jsx("line",{x1:"13",y1:"6",x2:"17",y2:"8",stroke:"currentColor",strokeWidth:"1.8"}),o.jsx("line",{x1:"13",y1:"8",x2:"17",y2:"10",stroke:"currentColor",strokeWidth:"1.8"}),o.jsx("line",{x1:"13",y1:"10",x2:"17",y2:"12",stroke:"currentColor",strokeWidth:"1.8"}),o.jsx("line",{x1:"13",y1:"12",x2:"17",y2:"14",stroke:"currentColor",strokeWidth:"1.8"})]}),ql=()=>o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor",children:[o.jsx("ellipse",{cx:"8",cy:"16",rx:"5",ry:"3.5"}),o.jsx("line",{x1:"13",y1:"16",x2:"13",y2:"4",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("line",{x1:"13",y1:"4",x2:"17",y2:"6",stroke:"currentColor",strokeWidth:"1.8"}),o.jsx("line",{x1:"13",y1:"6",x2:"17",y2:"8",stroke:"currentColor",strokeWidth:"1.8"}),o.jsx("line",{x1:"13",y1:"8",x2:"17",y2:"10",stroke:"currentColor",strokeWidth:"1.8"}),o.jsx("line",{x1:"13",y1:"10",x2:"17",y2:"12",stroke:"currentColor",strokeWidth:"1.8"}),o.jsx("line",{x1:"13",y1:"12",x2:"17",y2:"14",stroke:"currentColor",strokeWidth:"1.8"}),o.jsx("line",{x1:"13",y1:"14",x2:"17",y2:"16",stroke:"currentColor",strokeWidth:"1.8"})]}),zl=()=>o.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M10 8 L14 8 L12 12 L16 12 L14 16 L10 16 L12 12 L8 12 Z"})}),Gl=()=>o.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:"M5 14 L9 9 L13 14 L17 9 L21 14"})}),Yl=()=>o.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:"M5 15 C5 10 9 8 12 12 C 15 16 19 14 19 9"})}),ci=({children:t})=>o.jsx(u.Badge,{overlap:"rectangular",anchorOrigin:{vertical:"bottom",horizontal:"right"},sx:{"& .MuiBadge-badge":{bottom:2,right:2,padding:0}},badgeContent:o.jsx(u.Box,{sx:{bgcolor:"#f59e0b",borderRadius:"50%",width:12,height:12,display:"flex",alignItems:"center",justifyContent:"center",border:"1.5px solid #fff",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"},children:o.jsx(te.Star,{sx:{fontSize:7,color:"#fff"}})}),children:t}),Tt={px:1.2,py:0,height:"40px",minWidth:"40px",border:"1px solid",borderColor:"divider","&.Mui-selected":{bgcolor:"#64748b",color:"#ffffff","&:hover":{bgcolor:"#475569"}}};function Vl({selectedDuration:t,onDurationChange:e,isRestMode:s,onRestModeChange:i,selectedAccidental:n,onAccidentalChange:r,selectedArticulation:a,onArticulationChange:l,selectedDynamic:c,onDynamicChange:h,isTied:d,onTieChange:p,isSlurred:y,onSlurChange:S,isDotted:I,onDottedChange:m,selectedOrnament:k,onOrnamentChange:E,selectedHairpin:Y,onHairpinChange:R,selectedGlissando:O,onGlissandoChange:M,selectedArpeggio:q,onArpeggioChange:it,selectedOttava:ot,onOttavaChange:U,selectedPedal:dt,onPedalChange:st,isPickup:g=!1,onPickupChange:L,selectedFret:$=0,onFretChange:Q,selectedString:ct=1,onStringChange:bt,activeVoice:ht=0,onVoiceChange:It,isGrace:_=!1,onGraceChange:x,onAddKeySignature:W,onAddTimeSignature:z,onAddClef:Z,onAddTempo:yt,onAddVolta:G,onAddChordSymbol:lt,isSystemBreak:xt=!1,onSystemBreakChange:Ct,isPageBreak:pt=!1,onPageBreakChange:Wt,onAddRehearsalMark:H,onAddSystemText:Ut,onAddStaffText:Ne,onAddMeasureBefore:Re,onAddMeasureAfter:Xi,onRemoveMeasure:Bs,onAddRepeat:$e,onTupletChange:ls,onToggleEnharmonic:Ds,onBeamingChange:Se,selectedColor:hi="#000000",onColorChange:Ps,selectedNotehead:Ji=se.Normal,onNoteheadChange:Ms,selectedBowing:Zi,onBowingChange:cs,selectedFingering:tn,onFingeringChange:Ht,onApplyInfill:He,onPageSetup:ke,onScoreLayout:As,onLoadSATBTemplate:ui,onDownloadMusicXML:Os,onDownloadPDF:Xt,onSave:Ke,canSave:ue,onScoreInfo:hs,onPlay:us,onStop:fs,isPlaying:be,isMetronome:ds,onToggleMetronome:Ns,isSwing:ps,onToggleSwing:fi,showKeyboard:di,onToggleKeyboard:en,onTranspose:pi,onInstruments:Mt,onOpenFile:Rt,onImportPDF:Rs,isEditMode:ge,sx:kt,userTier:Kt="free",aiSuggestionAvailable:gi=!1,onGenerateVocalGuide:$s,onUpgrade:mi}){const[ne,xi]=K.useState("note"),[yi,gs]=K.useState(!1),je=Kt==="premium",ms=et=>{je?et():mi?mi():gs(!0)},vi=K.useRef(null),bi=K.useRef(null),sn=(et,mt)=>{xi(mt)};K.useEffect(()=>{!ge&&["note","articulations","measure","tab","text","style","magic"].includes(ne)&&xi("score")},[ge,ne]);const nn=[{value:P.Whole,icon:o.jsx(Ol,{}),shortcut:"1"},{value:P.Half,icon:o.jsx(Nl,{}),shortcut:"2"},{value:P.Quarter,icon:o.jsx(Rl,{}),shortcut:"3"},{value:P.Eighth,icon:o.jsx($l,{}),shortcut:"4"},{value:P.Sixteenth,icon:o.jsx(Ll,{}),shortcut:"5"},{value:P.ThirtySecond,icon:o.jsx(Wl,{}),shortcut:"6"},{value:P.SixtyFourth,icon:o.jsx(_l,{}),shortcut:"7"},{value:P.OneHundredTwentyEighth,icon:o.jsx(Fl,{}),shortcut:"8"},{value:P.TwoHundredFiftySixth,icon:o.jsx(ql,{}),shortcut:"9"}],rn=["ppp","pp","p","mp","mf","f","ff","fff"],on=["#000000","#ef4444","#f97316","#eab308","#22c55e","#33a854","#8b5cf6","#ec4899"];return o.jsxs(u.Paper,{elevation:0,sx:{pt:2.5,pb:1.5,pl:4,pr:1.5,display:"flex",gap:2,bgcolor:"transparent",width:"100%",borderRadius:0,border:"none",...kt},children:[o.jsx(u.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:1.5,px:1.5},children:o.jsxs(u.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[o.jsx(u.Tooltip,{title:be?"Stop (Space)":"Play (Space)",children:o.jsx(u.IconButton,{size:"small",color:be?"warning":"primary",onClick:be?fs:us,sx:{width:42,height:42,bgcolor:be?"warning.light":"primary.light",color:be?"warning.contrastText":"primary.contrastText","&:hover":{bgcolor:be?"warning.main":"primary.main"}},children:be?o.jsx(te.Stop,{}):o.jsx(te.PlayArrow,{})})}),ge&&Ke&&o.jsx(u.Tooltip,{title:ue?"Save to Cloud":"No changes to save",children:o.jsx(u.IconButton,{size:"small",onClick:Ke,disabled:!ue,sx:{bgcolor:ue?"success.light":"transparent",color:ue?"success.contrastText":"text.disabled","&:hover":{bgcolor:ue?"success.main":"transparent"},width:40,height:40},children:o.jsx(te.CloudUpload,{sx:{fontSize:28}})})})]})}),o.jsxs(u.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minWidth:0},children:[o.jsx(u.Box,{sx:{mb:1},children:o.jsxs(u.Tabs,{value:ne,onChange:sn,variant:"scrollable",scrollButtons:"auto",sx:{minHeight:"unset","& .MuiTab-root":{minHeight:"unset",py:.5,px:1.5,fontSize:"0.65rem",fontWeight:800,letterSpacing:"0.05em",transition:"all 0.2s","&:hover":{color:"primary.main",bgcolor:"rgba(59, 130, 246, 0.04)"}}},children:[ge&&o.jsx(u.Tab,{label:"NOTE",value:"note"}),ge&&o.jsx(u.Tab,{label:"ANNOTATE",value:"articulations"}),ge&&o.jsx(u.Tab,{label:"MEASURE",value:"measure"}),ge&&o.jsx(u.Tab,{label:"TAB",value:"tab"}),o.jsx(u.Tab,{label:"SCORE",value:"score"}),o.jsx(u.Tab,{label:"PLAY",value:"play"}),ge&&o.jsx(u.Tab,{label:"TEXT",value:"text"}),ge&&o.jsx(u.Tab,{label:"STYLE",value:"style"}),ge&&o.jsx(u.Tab,{label:o.jsxs(u.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["MAGIC",gi&&ne!=="magic"&&o.jsx(u.Box,{sx:{width:8,height:8,bgcolor:"#8b5cf6",borderRadius:"50%",display:"inline-block",animation:"aiPulse 1.5s infinite ease-in-out",boxShadow:"0 0 10px rgba(139, 92, 246, 0.6)","@keyframes aiPulse":{"0%":{transform:"scale(0.8)",opacity:.6},"50%":{transform:"scale(1.2)",opacity:1,boxShadow:"0 0 15px rgba(139, 92, 246, 1)"},"100%":{transform:"scale(0.8)",opacity:.6}}}})]}),value:"magic"}),o.jsx(u.Tab,{label:"EXPORT",value:"export"})]})}),o.jsxs(u.Box,{sx:{display:"flex",alignItems:"center",height:"64px",overflowX:"auto",pb:.5},children:[ne==="score"&&o.jsxs(u.Box,{sx:{display:"flex",gap:2,alignItems:"center"},children:[o.jsxs(u.Box,{sx:{display:"flex",alignItems:"center"},children:[o.jsx("input",{type:"file",ref:vi,style:{display:"none"},accept:".xml,.musicxml,.json",onChange:et=>{var Jt;const mt=(Jt=et.target.files)==null?void 0:Jt[0];mt&&(Rt==null||Rt(mt)),et.target.value=""}}),o.jsx("input",{type:"file",ref:bi,style:{display:"none"},accept:"application/pdf",onChange:et=>{var Jt;const mt=(Jt=et.target.files)==null?void 0:Jt[0];mt&&(Rs==null||Rs(mt)),et.target.value=""}}),o.jsxs(u.Box,{sx:{display:"flex",gap:1},children:[o.jsx(u.Tooltip,{title:"Open MusicXML or JSON file",children:o.jsx(u.Button,{variant:"outlined",size:"small",onClick:()=>{var et;return(et=vi.current)==null?void 0:et.click()},startIcon:o.jsx(te.FolderOpen,{}),sx:{fontWeight:700,textTransform:"none",height:"40px",color:"text.primary",borderColor:"rgba(0,0,0,0.23)"},children:"Open File"})}),o.jsx(u.Tooltip,{title:"Import Score from PDF (AI)",children:o.jsx(u.Button,{variant:"outlined",size:"small",onClick:()=>ms(()=>{var et;return(et=bi.current)==null?void 0:et.click()}),startIcon:je?o.jsx(li,{sx:{color:"#33a854"}}):o.jsx(ci,{children:o.jsx(li,{sx:{opacity:.6}})}),sx:{fontWeight:800,textTransform:"none",height:"40px",color:"text.primary",borderColor:"rgba(0,0,0,0.23)"},children:"Import PDF"})})]})]}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsxs(u.Box,{sx:{display:"flex",gap:1},children:[o.jsx(u.Tooltip,{title:"Transpose the whole score",children:o.jsx(u.Button,{variant:"outlined",size:"small",onClick:pi,startIcon:o.jsx(te.MusicNote,{}),sx:{fontWeight:700,textTransform:"none",height:"40px",color:"text.primary",borderColor:"rgba(0,0,0,0.23)"},children:"Transpose"})}),o.jsx(u.Tooltip,{title:"Add, remove or edit instruments",children:o.jsx(u.Button,{variant:"outlined",size:"small",onClick:Mt,startIcon:o.jsx(Ml,{}),sx:{fontWeight:700,textTransform:"none",height:"40px",color:"text.primary",borderColor:"rgba(0,0,0,0.23)"},children:"Manage Instruments"})})]})}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsxs(u.Box,{sx:{display:"flex",gap:1},children:[o.jsx(u.Tooltip,{title:"Configure page size and margins",children:o.jsx(u.Button,{variant:"outlined",size:"small",onClick:ke,startIcon:o.jsx(te.Pageview,{}),sx:{fontWeight:700,textTransform:"none",height:"40px",color:"text.primary",borderColor:"rgba(0,0,0,0.23)"},children:"Page Setup"})}),o.jsx(u.Tooltip,{title:"Adjust staff spacing and styles",children:o.jsx(u.Button,{variant:"outlined",size:"small",onClick:As,startIcon:o.jsx(te.Settings,{}),sx:{fontWeight:700,textTransform:"none",height:"40px",color:"text.primary",borderColor:"rgba(0,0,0,0.23)"},children:"Score Layout"})})]})}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsx(u.Box,{sx:{display:"flex",gap:1},children:o.jsx(u.Tooltip,{title:"Edit Score Data (Title, Composer, etc.)",children:o.jsx(u.Button,{variant:"outlined",size:"small",onClick:hs,startIcon:o.jsx(te.Info,{}),sx:{fontWeight:700,textTransform:"none",height:"40px",color:"text.primary",borderColor:"rgba(0,0,0,0.23)"},children:"Score Data"})})})})]}),ne==="tab"&&ge&&o.jsx(u.Box,{sx:{display:"flex",gap:2,alignItems:"center"},children:o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsxs(u.Box,{sx:{display:"flex",gap:1,alignItems:"center"},children:[o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsx(u.Tooltip,{title:"Select String (1-6)",children:o.jsx(u.ToggleButtonGroup,{value:ct,exclusive:!0,onChange:(et,mt)=>mt!==null&&(bt==null?void 0:bt(mt)),size:"small",children:[1,2,3,4,5,6].map(et=>o.jsx(u.ToggleButton,{value:et,sx:{...Tt,px:.8,py:.2,minWidth:26},children:et},et))})})}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsx(u.Tooltip,{title:"Fret Number",children:o.jsx("input",{type:"number",value:$,onChange:et=>Q==null?void 0:Q(parseInt(et.target.value)||0),style:{width:"40px",height:"40px",borderRadius:"4px",border:"1px solid #ced4da",textAlign:"center",fontSize:"0.8rem",fontWeight:600}})})})]})})}),ne==="note"&&o.jsxs(u.Box,{sx:{display:"flex",gap:2,alignItems:"center"},children:[o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsx(u.Stack,{direction:"row",spacing:.5,alignItems:"center",children:o.jsx(u.ToggleButtonGroup,{value:t,exclusive:!0,onChange:(et,mt)=>mt&&e(mt),size:"small",sx:{gap:.5},children:nn.map(({value:et,icon:mt,shortcut:Jt})=>o.jsx(u.ToggleButton,{value:et,sx:Tt,children:o.jsx(u.Tooltip,{title:`${et.charAt(0).toUpperCase()+et.slice(1)} (${Jt})`,children:o.jsx(u.Box,{children:mt})})},et))})})}),o.jsxs(u.Box,{sx:{display:"flex",gap:.5,alignSelf:"flex-end",mb:.5},children:[o.jsx(u.ToggleButton,{value:"dotted",selected:I,onChange:()=>m(!I),size:"small",sx:Tt,children:o.jsx(u.Tooltip,{title:"Dotted (.)",children:o.jsx(u.Box,{sx:{fontSize:"1.2rem",fontWeight:800},children:"·"})})}),o.jsx(u.ToggleButton,{value:"grace",selected:_,onChange:()=>x&&x(!_),size:"small",sx:Tt,children:o.jsx(u.Tooltip,{title:"Grace Note (G)",children:o.jsx(u.Box,{sx:{fontSize:"0.9rem",fontWeight:700,fontStyle:"italic"},children:"g"})})}),o.jsx(u.ToggleButton,{value:"triplet",onClick:()=>ls&&ls(3,2),size:"small",sx:Tt,children:o.jsx(u.Tooltip,{title:"Triplet (3)",children:o.jsx(u.Box,{sx:{fontSize:"0.9rem",fontWeight:800},children:"3"})})})]}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsx(u.ToggleButton,{value:"rest",selected:s,onChange:()=>i(!s),size:"small",sx:{...Tt,px:2},children:o.jsx(u.Tooltip,{title:"Rest (0)",children:o.jsxs(u.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[o.jsx(zl,{}),o.jsx(u.Typography,{variant:"caption",fontWeight:600,children:"REST"})]})})})}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsx(u.ToggleButtonGroup,{value:ht,exclusive:!0,onChange:(et,mt)=>mt!==null&&(It==null?void 0:It(mt)),size:"small",sx:{gap:.5},children:[{id:0,color:"#33a854",label:"1"},{id:1,color:"#47C76B",label:"2"},{id:2,color:"#f59e0b",label:"3"},{id:3,color:"#8b5cf6",label:"4"}].map(et=>o.jsx(u.ToggleButton,{value:et.id,sx:{...Tt,px:0,fontWeight:700,minWidth:"32px"},children:o.jsx(u.Tooltip,{title:`Voice ${et.label}`,children:o.jsx(u.Box,{children:et.label})})},et.id))})}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsxs(u.Box,{sx:{display:"flex",alignItems:"center"},children:[o.jsx(u.ToggleButtonGroup,{value:n,exclusive:!0,onChange:(et,mt)=>r(mt),size:"small",sx:{gap:.5},children:[{val:At.DoubleSharp,sym:"𝄪"},{val:At.Sharp,sym:"♯"},{val:At.Natural,sym:"♮"},{val:At.Flat,sym:"♭"},{val:At.DoubleFlat,sym:"𝄫"}].map(({val:et,sym:mt})=>o.jsx(u.ToggleButton,{value:et,sx:{...Tt,fontWeight:700,fontSize:"1.2rem"},children:o.jsx(u.Tooltip,{title:et.replace("-"," "),children:o.jsx("span",{children:mt})})},et))}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),o.jsx(u.Tooltip,{title:"Toggle Enharmonic (J)",children:o.jsx(u.ToggleButton,{size:"small",value:"enharmonic",onClick:()=>Ds==null?void 0:Ds(),sx:Tt,children:o.jsxs(u.Box,{sx:{display:"flex",alignItems:"baseline",fontSize:"0.9rem"},children:["♯",o.jsx(u.Typography,{variant:"caption",sx:{mx:.2},children:"/"}),"♭"]})})}),o.jsx(u.ToggleButton,{value:"beamJoin",onClick:()=>Se==null?void 0:Se("join"),size:"small",sx:Tt,children:o.jsx(u.Tooltip,{title:"Join Beam",children:o.jsx(u.Box,{sx:{fontSize:"0.7rem",fontWeight:800},children:"JOIN"})})}),o.jsx(u.ToggleButton,{value:"beamBreak",onClick:()=>Se==null?void 0:Se("break"),size:"small",sx:Tt,children:o.jsx(u.Tooltip,{title:"Break Beam",children:o.jsx(u.Box,{sx:{fontSize:"0.7rem",fontWeight:800},children:"BREAK"})})})]})]}),ne==="articulations"&&o.jsxs(u.Box,{sx:{display:"flex",gap:2,alignItems:"center"},children:[o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsx(u.ToggleButtonGroup,{value:a,exclusive:!0,onChange:(et,mt)=>l(mt),size:"small",sx:{gap:.5},children:[{val:xe.Staccato,sym:"·",title:"Staccato"},{val:xe.Staccatissimo,sym:"▼",title:"Staccatissimo"},{val:xe.Accent,sym:">",title:"Accent"},{val:xe.Tenuto,sym:"-",title:"Tenuto"},{val:xe.Marcato,sym:"^",title:"Marcato"},{val:xe.Fermata,sym:"𝄐",title:"Fermata"}].map(({val:et,sym:mt,title:Jt})=>o.jsx(u.ToggleButton,{value:et,sx:{...Tt,fontSize:"1.2rem"},children:o.jsx(u.Tooltip,{title:Jt,children:o.jsx(u.Box,{children:mt})})},et))})}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsx(u.ToggleButtonGroup,{value:c,exclusive:!0,onChange:(et,mt)=>h(mt),size:"small",sx:{gap:.5},children:rn.map(et=>o.jsx(u.ToggleButton,{value:et,sx:{...Tt,px:.8,fontFamily:'"Times New Roman", serif',fontStyle:"italic",fontWeight:"bold",fontSize:"1.1rem"},children:o.jsx(u.Tooltip,{title:et.toUpperCase(),children:o.jsx(u.Box,{children:et})})},et))})}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsxs(u.ToggleButtonGroup,{size:"small",sx:{gap:.5},children:[o.jsx(u.ToggleButton,{value:"tie",selected:d,onChange:()=>p(!d),sx:Tt,children:o.jsx(u.Tooltip,{title:"Tie",children:o.jsx(u.Box,{sx:{fontSize:"1.2rem",lineHeight:1},children:"⁀"})})}),o.jsx(u.ToggleButton,{value:"slur",selected:y,onChange:()=>S(!y),sx:Tt,children:o.jsx(u.Tooltip,{title:"Slur",children:o.jsx(u.Box,{sx:{fontSize:"1.2rem",lineHeight:1},children:"◡"})})})]})}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsx(u.ToggleButtonGroup,{value:k,exclusive:!0,onChange:(et,mt)=>E(mt),size:"small",sx:{gap:.5},children:[{val:Be.Trill,icon:o.jsx(u.Box,{sx:{fontSize:"1.2rem",fontFamily:"serif"},children:"tr"}),title:"Trill"},{val:Be.Mordent,icon:o.jsx(Gl,{}),title:"Mordent"},{val:Be.Turn,icon:o.jsx(Yl,{}),title:"Turn"}].map(({val:et,icon:mt,title:Jt})=>o.jsx(u.ToggleButton,{value:et,sx:{...Tt,fontSize:"1.2rem"},children:o.jsx(u.Tooltip,{title:Jt,children:mt})},et))})}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsxs(u.Box,{sx:{display:"flex",alignItems:"center"},children:[o.jsxs(u.ToggleButtonGroup,{value:Zi,exclusive:!0,onChange:(et,mt)=>cs==null?void 0:cs(mt),size:"small",sx:{gap:.5},children:[o.jsx(u.ToggleButton,{value:Ue.DownBow,sx:Tt,children:o.jsx(u.Tooltip,{title:"Down Bow",children:o.jsx(u.Box,{sx:{fontWeight:"bold"},children:"⊓"})})}),o.jsx(u.ToggleButton,{value:Ue.UpBow,sx:Tt,children:o.jsx(u.Tooltip,{title:"Up Bow",children:o.jsx(u.Box,{sx:{fontWeight:"bold"},children:"V"})})})]}),o.jsx(u.ToggleButtonGroup,{value:tn,exclusive:!0,onChange:(et,mt)=>Ht==null?void 0:Ht(mt?parseInt(mt):null),size:"small",sx:{gap:.5},children:[1,2,3,4,5].map(et=>o.jsx(u.ToggleButton,{value:et,sx:{...Tt,px:1,minWidth:"30px"},children:o.jsx(u.Tooltip,{title:`Finger ${et}`,children:o.jsx(u.Box,{children:et})})},et))})]}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsx(u.ToggleButtonGroup,{value:Y,exclusive:!0,onChange:(et,mt)=>R(mt),size:"small",sx:{gap:.5},children:[{val:Xe.Crescendo,sym:"<",title:"Crescendo"},{val:Xe.Decrescendo,sym:">",title:"Decrescendo"}].map(({val:et,sym:mt,title:Jt})=>o.jsx(u.ToggleButton,{value:et,sx:{...Tt,fontSize:"1.1rem"},children:o.jsx(u.Tooltip,{title:Jt,children:o.jsx(u.Box,{children:mt})})},et))})}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsx(u.ToggleButtonGroup,{value:Y,exclusive:!0,onChange:(et,mt)=>R(mt),size:"small",sx:{gap:.5},children:[{val:Xe.Crescendo,sym:"<",title:"Crescendo"},{val:Xe.Decrescendo,sym:">",title:"Decrescendo"}].map(({val:et,sym:mt,title:Jt})=>o.jsx(u.ToggleButton,{value:et,sx:{...Tt,fontSize:"1.1rem"},children:o.jsx(u.Tooltip,{title:Jt,children:o.jsx(u.Box,{children:mt})})},et))})}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsxs(u.ToggleButtonGroup,{size:"small",sx:{gap:.5},children:[o.jsx(u.ToggleButton,{value:"glissando",selected:O!==null,onChange:()=>M(O?null:ki.Wavy),sx:Tt,children:o.jsx(u.Tooltip,{title:"Glissando",children:o.jsx(u.Box,{sx:{fontSize:"1.1rem"},children:"╲"})})}),o.jsx(u.ToggleButton,{value:"arpeggio",selected:q!==null,onChange:()=>it(q?null:_e.Normal),sx:Tt,children:o.jsx(u.Tooltip,{title:"Arpeggio",children:o.jsx(u.Box,{sx:{fontSize:"1.1rem"},children:"⌇"})})}),o.jsx(u.ToggleButton,{value:"ottava",selected:ot!==null,onChange:()=>U(ot?null:Fe.OttavaAlta),sx:Tt,children:o.jsx(u.Tooltip,{title:"Ottava (8va)",children:o.jsx(u.Box,{sx:{fontSize:"0.9rem",fontWeight:700},children:"8va"})})}),o.jsx(u.ToggleButton,{value:"pedal",selected:dt!==null,onChange:()=>st(dt?null:"sustain"),sx:Tt,children:o.jsx(u.Tooltip,{title:"Pedal",children:o.jsx(u.Box,{sx:{fontSize:"0.9rem",fontWeight:700},children:"Ped."})})})]})})]}),ne==="measure"&&o.jsxs(u.Box,{sx:{display:"flex",gap:2,alignItems:"center"},children:[o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsxs(u.Box,{sx:{display:"flex",gap:.5},children:[o.jsx(u.ToggleButton,{value:"clef",onClick:Z,sx:Tt,children:o.jsx(u.Tooltip,{title:"Change Clef",children:o.jsx(u.Box,{sx:{fontSize:"1rem",fontWeight:700},children:"𝄞"})})}),o.jsx(u.ToggleButton,{value:"keySig",onClick:W,sx:Tt,children:o.jsx(u.Tooltip,{title:"Change Key Signature",children:o.jsx(u.Box,{sx:{fontSize:"0.7rem",fontWeight:700},children:"# b"})})}),o.jsx(u.ToggleButton,{value:"timeSig",onClick:z,sx:Tt,children:o.jsx(u.Tooltip,{title:"Change Time Signature",children:o.jsx(u.Box,{sx:{fontSize:"0.7rem",fontWeight:700},children:"4/4"})})}),o.jsx(u.ToggleButton,{value:"tempo",onClick:yt,sx:Tt,children:o.jsx(u.Tooltip,{title:"Add Tempo Marking",children:o.jsx(u.Box,{sx:{fontSize:"0.7rem",fontWeight:700},children:"♩="})})})]})}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsxs(u.Box,{sx:{display:"flex",gap:.5},children:[o.jsx(u.Button,{variant:"outlined",size:"small",onClick:Re,sx:{minWidth:40,px:1,height:"40px",fontSize:"0.7rem",fontWeight:700},children:"+ BEF"}),o.jsx(u.Button,{variant:"outlined",size:"small",onClick:Xi,sx:{minWidth:40,px:1,height:"40px",fontSize:"0.7rem",fontWeight:700},children:"+ AFT"}),o.jsx(u.Button,{variant:"outlined",size:"small",onClick:Bs,sx:{minWidth:40,px:1,height:"40px",fontSize:"0.7rem",fontWeight:700,color:"text.primary",borderColor:"rgba(0,0,0,0.23)"},children:"DEL"})]})}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsxs(u.Box,{sx:{display:"flex",gap:.5},children:[o.jsx(u.ToggleButton,{value:"systemBreak",selected:xt,onChange:()=>Ct==null?void 0:Ct(!xt),sx:Tt,children:o.jsx(u.Tooltip,{title:"System Break",children:o.jsx(u.Box,{sx:{fontSize:"0.8rem",fontWeight:700},children:"SYS"})})}),o.jsx(u.ToggleButton,{value:"pageBreak",selected:pt,onChange:()=>Wt==null?void 0:Wt(!pt),sx:Tt,children:o.jsx(u.Tooltip,{title:"Page Break",children:o.jsx(u.Box,{sx:{fontSize:"0.8rem",fontWeight:700},children:"PAGE"})})})]})}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsx(u.ToggleButton,{value:"isPickup",selected:g,onChange:()=>L==null?void 0:L(!g),sx:Tt,children:o.jsx(u.Tooltip,{title:"Toggle Pickup Measure",children:o.jsx(u.Box,{sx:{fontSize:"0.8rem",fontWeight:700},children:"PICKUP"})})})}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsxs(u.ToggleButtonGroup,{size:"small",sx:{gap:.5},children:[o.jsx(u.ToggleButton,{value:"volta1",onClick:()=>G==null?void 0:G(1),sx:Tt,children:o.jsx(u.Tooltip,{title:"Volta 1",children:o.jsx(u.Box,{sx:{fontSize:"0.8rem",fontWeight:700},children:"1."})})}),o.jsx(u.ToggleButton,{value:"volta2",onClick:()=>G==null?void 0:G(2),sx:Tt,children:o.jsx(u.Tooltip,{title:"Volta 2",children:o.jsx(u.Box,{sx:{fontSize:"0.8rem",fontWeight:700},children:"2."})})}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),o.jsx(u.ToggleButton,{value:"repeatStart",onClick:()=>$e==null?void 0:$e("start"),sx:Tt,children:o.jsx(u.Tooltip,{title:"Start Repeat (||:)",children:o.jsx(u.Box,{sx:{fontSize:"0.8rem",fontWeight:700},children:"||:"})})}),o.jsx(u.ToggleButton,{value:"repeatEnd",onClick:()=>$e==null?void 0:$e("end"),sx:Tt,children:o.jsx(u.Tooltip,{title:"End Repeat (:||)",children:o.jsx(u.Box,{sx:{fontSize:"0.8rem",fontWeight:700},children:":||"})})})]})})]}),ne==="play"&&o.jsxs(u.Box,{sx:{display:"flex",gap:2,alignItems:"center"},children:[o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsxs(u.Box,{sx:{display:"flex",gap:1},children:[o.jsx(u.Tooltip,{title:ds?"Disable Metronome":"Enable Metronome",children:o.jsx(u.ToggleButton,{value:"metronome",selected:ds,onChange:Ns,sx:Tt,children:o.jsx(Pl,{})})}),o.jsx(u.Tooltip,{title:ps?"Disable Swing":"Enable Swing",children:o.jsx(u.ToggleButton,{value:"swing",selected:ps,onChange:fi,sx:Tt,children:o.jsx(Al,{})})}),o.jsx(u.Tooltip,{title:di?"Hide Keyboard":"Show Keyboard",children:o.jsx(u.ToggleButton,{value:"keyboard",selected:di,onChange:en,sx:Tt,children:o.jsx(te.Piano,{})})})]})}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsx(u.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:o.jsx(u.Tooltip,{title:"Generate Vocal Guide (Based on Lyrics)",children:o.jsx(u.Button,{variant:"outlined",size:"small",onClick:()=>ms(()=>$s==null?void 0:$s()),startIcon:je?o.jsx(te.RecordVoiceOver,{}):o.jsx(ci,{children:o.jsx(te.RecordVoiceOver,{sx:{opacity:.6}})}),sx:{fontWeight:800,textTransform:"none",borderRadius:2,height:"40px",color:"text.primary",borderColor:"rgba(0,0,0,0.23)"},children:"Vocal Guide"})})})]}),ne==="text"&&o.jsxs(u.Box,{sx:{display:"flex",gap:2,alignItems:"center"},children:[o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsxs(u.ToggleButtonGroup,{size:"small",sx:{gap:.5},children:[o.jsx(u.ToggleButton,{value:"lyrics",selected:!1,onChange:()=>window.dispatchEvent(new KeyboardEvent("keydown",{key:"l",code:"KeyL",bubbles:!0})),sx:Tt,children:o.jsx(u.Tooltip,{title:"Lyrics (L)",children:o.jsx(u.Box,{sx:{fontSize:"0.8rem",fontWeight:700},children:"LYRICS"})})}),o.jsx(u.ToggleButton,{value:"chord",selected:!1,onClick:lt,sx:Tt,children:o.jsx(u.Tooltip,{title:"Chord Symbol",children:o.jsx(u.Box,{sx:{fontSize:"0.8rem",fontWeight:700},children:"CHORD"})})}),o.jsx(u.ToggleButton,{value:"systemText",onClick:Ut,sx:Tt,children:o.jsx(u.Tooltip,{title:"System Text",children:o.jsx(u.Box,{sx:{fontSize:"0.7rem",fontWeight:700},children:"SYSTEM"})})}),o.jsx(u.ToggleButton,{value:"staffText",onClick:Ne,sx:Tt,children:o.jsx(u.Tooltip,{title:"Staff Text",children:o.jsx(u.Box,{sx:{fontSize:"0.7rem",fontWeight:700},children:"STAFF"})})})]})}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsx(u.ToggleButton,{value:"rehearsal",onClick:H,sx:Tt,children:o.jsx(u.Tooltip,{title:"Rehearsal Mark",children:o.jsx(u.Box,{sx:{fontSize:"0.8rem",fontWeight:700,border:"1px solid currentColor",px:.5},children:"A"})})})})]}),ne==="style"&&o.jsxs(u.Box,{sx:{display:"flex",gap:2,alignItems:"center"},children:[o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsx(u.ToggleButtonGroup,{value:hi,exclusive:!0,onChange:(et,mt)=>mt&&(Ps==null?void 0:Ps(mt)),size:"small",sx:{gap:.5},children:on.map(et=>o.jsx(u.ToggleButton,{value:et,sx:{...Tt,minWidth:"32px",width:"32px",height:"32px",bgcolor:et,border:hi===et?"2px solid #000":"1px solid rgba(0,0,0,0.1)","&:hover":{bgcolor:et,opacity:.8},"&.Mui-selected":{bgcolor:et,border:"2px solid #000","&:hover":{bgcolor:et}}}},et))})}),o.jsx(u.Divider,{orientation:"vertical",flexItem:!0,sx:{my:.5}}),o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsx(u.ToggleButtonGroup,{value:Ji,exclusive:!0,onChange:(et,mt)=>mt&&(Ms==null?void 0:Ms(mt)),size:"small",sx:{gap:.5},children:[{val:se.Normal,label:"●",title:"Normal"},{val:se.Cross,label:"X",title:"Cross (Percussion)"},{val:se.Diamond,label:"◇",title:"Diamond (Harmonic)"},{val:se.Triangle,label:"△",title:"Triangle"},{val:se.Slash,label:"/",title:"Slash (Rhythmic)"}].map(({val:et,label:mt,title:Jt})=>o.jsx(u.ToggleButton,{value:et,sx:{...Tt,fontSize:"1.2rem",fontWeight:900},children:o.jsx(u.Tooltip,{title:Jt,children:o.jsx(u.Box,{children:mt})})},et))})})]}),ne==="magic"&&o.jsx(u.Box,{sx:{display:"flex",gap:2,alignItems:"center"},children:o.jsx(u.Box,{sx:{display:"flex",alignItems:"center"},children:o.jsxs(u.Stack,{direction:"row",spacing:1.5,children:[o.jsx(u.Tooltip,{title:"Automatically generate harmonies for your melody",children:o.jsx(u.Button,{variant:"contained",onClick:He,startIcon:o.jsx(li,{}),sx:{bgcolor:"rgba(0,0,0,0.06)",color:"text.primary",fontWeight:700,position:"relative",height:"40px","&:hover":{bgcolor:"rgba(0,0,0,0.1)"},...gi&&{animation:"aiGlow 3s infinite ease-in-out",background:"linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%)",border:"none","@keyframes aiGlow":{"0%":{boxShadow:"0 0 8px rgba(148, 163, 184, 0.4)",transform:"scale(1)"},"50%":{boxShadow:"0 0 25px rgba(148, 163, 184, 0.8), 0 0 40px rgba(203, 213, 225, 0.5)",transform:"scale(1.03)"},"100%":{boxShadow:"0 0 8px rgba(148, 163, 184, 0.4)",transform:"scale(1)"}}}},children:"Harmonize Selection"})}),o.jsx(u.Tooltip,{title:"Load a professional Soprano, Alto, Tenor, Bass church chorale template",children:o.jsx(u.Button,{variant:"outlined",onClick:ui,startIcon:o.jsx(li,{}),sx:{fontWeight:700,textTransform:"none",height:"40px"},children:"Load SATB Template"})})]})})}),ne==="export"&&o.jsx(u.Box,{sx:{display:"flex",gap:2,alignItems:"center"},children:o.jsxs(u.Box,{sx:{display:"flex",gap:1},children:[o.jsx(u.Tooltip,{title:je?"":"Premium Feature",children:o.jsx(u.Button,{variant:"contained",size:"small",onClick:()=>ms(()=>Os==null?void 0:Os()),startIcon:je?o.jsx(te.Code,{}):o.jsx(ci,{children:o.jsx(te.Code,{sx:{opacity:.6}})}),sx:{borderRadius:2,fontWeight:700,textTransform:"none",height:"40px",bgcolor:"rgba(0,0,0,0.06)",color:"text.primary","&:hover":{bgcolor:"rgba(0,0,0,0.1)"}},children:"Download MusicXML"})}),o.jsx(u.Tooltip,{title:je?"":"Premium Feature",children:o.jsx(u.Button,{variant:"outlined",onClick:()=>ms(()=>Xt==null?void 0:Xt()),startIcon:je?o.jsx(te.PictureAsPdf,{}):o.jsx(ci,{children:o.jsx(te.PictureAsPdf,{sx:{opacity:.6}})}),sx:{borderRadius:2,fontWeight:700,textTransform:"none",height:"40px",color:"text.primary",borderColor:"rgba(0,0,0,0.12)","&:hover":{bgcolor:"rgba(0,0,0,0.04)",borderColor:"rgba(0,0,0,0.2)"}},children:"Download PDF"})})]})})]}),o.jsx(u.Dialog,{open:yi,onClose:()=>gs(!1),PaperProps:{sx:{borderRadius:"24px",p:2,maxWidth:"400px"}},children:o.jsxs(u.Box,{sx:{p:2,textAlign:"center"},children:[o.jsx(u.Box,{sx:{width:64,height:64,borderRadius:"20px",bgcolor:"rgba(0,0,0,0.03)",display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto",mb:3},children:o.jsx(te.Star,{sx:{fontSize:40,color:"rgba(0,0,0,0.2)"}})}),o.jsx(u.Typography,{variant:"h5",sx:{fontWeight:800,mb:1},children:"Unlock Premium"}),o.jsx(u.Typography,{variant:"body1",sx:{color:"text.secondary",mb:4},children:"Exporting to MusicXML and PDF are premium features. Upgrade your plan to unlock professional tools."}),o.jsx(u.Button,{fullWidth:!0,variant:"contained",size:"large",onClick:()=>{window.open("http://localhost:5173/pricing","_blank"),gs(!1)},sx:{borderRadius:"16px",py:2,fontWeight:800,fontSize:"1.1rem",background:"linear-gradient(135deg, #33a854 0%, #1e7e34 100%)",boxShadow:"0 10px 25px rgba(30, 126, 52, 0.2)",textTransform:"none",mb:2},children:"Upgrade to Premium"}),o.jsx(u.Button,{fullWidth:!0,variant:"text",onClick:()=>gs(!1),sx:{fontWeight:600,color:"text.secondary"},children:"Maybe Later"})]})})]})]})}const Tr=()=>o.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:o.jsx("ellipse",{cx:"12",cy:"12",rx:"6",ry:"4",strokeWidth:"1.5"})}),Sr=()=>o.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",children:[o.jsx("ellipse",{cx:"8",cy:"16",rx:"5",ry:"3.5",strokeWidth:"1.5"}),o.jsx("line",{x1:"13",y1:"16",x2:"13",y2:"4",strokeWidth:"1.5"})]}),wr=()=>o.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:[o.jsx("ellipse",{cx:"8",cy:"16",rx:"5",ry:"3.5"}),o.jsx("line",{x1:"13",y1:"16",x2:"13",y2:"4",stroke:"currentColor",strokeWidth:"1.5"})]}),Cr=()=>o.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:[o.jsx("ellipse",{cx:"8",cy:"16",rx:"5",ry:"3.5"}),o.jsx("line",{x1:"13",y1:"16",x2:"13",y2:"4",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("line",{x1:"13",y1:"4",x2:"17",y2:"6",stroke:"currentColor",strokeWidth:"1.8"})]}),Ir=()=>o.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:[o.jsx("ellipse",{cx:"8",cy:"16",rx:"5",ry:"3.5"}),o.jsx("line",{x1:"13",y1:"16",x2:"13",y2:"4",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("line",{x1:"13",y1:"4",x2:"17",y2:"6",stroke:"currentColor",strokeWidth:"1.8"}),o.jsx("line",{x1:"13",y1:"6",x2:"17",y2:"8",stroke:"currentColor",strokeWidth:"1.8"})]});function Hl({open:t,onClose:e,onSave:s,currentBpm:i,currentDuration:n,currentIsDotted:r}){const[a,l]=K.useState(i),[c,h]=K.useState(n),[d,p]=K.useState(r);K.useEffect(()=>{t&&(l(i),h(n),p(r))},[t,i,n,r]);const y=()=>{s(a,c,d),e()};return o.jsxs(u.Dialog,{open:t,onClose:e,maxWidth:"xs",fullWidth:!0,children:[o.jsx(u.DialogTitle,{sx:{fontWeight:700},children:"Tempo"}),o.jsx(u.DialogContent,{children:o.jsxs(u.Stack,{spacing:3,sx:{mt:1},children:[o.jsxs(u.Box,{sx:{display:"flex",gap:2,alignItems:"center"},children:[o.jsxs(u.FormControl,{fullWidth:!0,children:[o.jsx(u.InputLabel,{children:"Beat Note"}),o.jsxs(u.Select,{value:c,label:"Beat Note",onChange:S=>h(S.target.value),renderValue:S=>o.jsxs(u.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[S===P.Whole&&o.jsx(Tr,{}),S===P.Half&&o.jsx(Sr,{}),S===P.Quarter&&o.jsx(wr,{}),S===P.Eighth&&o.jsx(Cr,{}),S===P.Sixteenth&&o.jsx(Ir,{})]}),children:[o.jsx(u.MenuItem,{value:P.Whole,children:o.jsxs(u.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[o.jsx(Tr,{})," ",o.jsx("span",{children:"Whole"})]})}),o.jsx(u.MenuItem,{value:P.Half,children:o.jsxs(u.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[o.jsx(Sr,{})," ",o.jsx("span",{children:"Half"})]})}),o.jsx(u.MenuItem,{value:P.Quarter,children:o.jsxs(u.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[o.jsx(wr,{})," ",o.jsx("span",{children:"Quarter"})]})}),o.jsx(u.MenuItem,{value:P.Eighth,children:o.jsxs(u.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[o.jsx(Cr,{})," ",o.jsx("span",{children:"Eighth"})]})}),o.jsx(u.MenuItem,{value:P.Sixteenth,children:o.jsxs(u.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[o.jsx(Ir,{})," ",o.jsx("span",{children:"Sixteenth"})]})})]})]}),o.jsx(u.FormControlLabel,{control:o.jsx(u.Checkbox,{checked:d,onChange:S=>p(S.target.checked)}),label:"Dotted"})]}),o.jsxs(u.Box,{sx:{px:1},children:[o.jsxs(u.Typography,{variant:"body2",gutterBottom:!0,sx:{display:"flex",justifyContent:"space-between"},children:["Tempo (BPM) ",o.jsx("span",{children:a})]}),o.jsx(u.Slider,{value:a,onChange:(S,I)=>l(I),min:20,max:300,step:1,valueLabelDisplay:"auto",marks:[{value:60,label:"60"},{value:120,label:"120"},{value:180,label:"180"},{value:240,label:"240"}]})]})]})}),o.jsxs(u.DialogActions,{children:[o.jsx(u.Button,{onClick:e,children:"Cancel"}),o.jsx(u.Button,{onClick:y,variant:"contained",sx:{borderRadius:2},children:"Save"})]})]})}function Kl({fifths:t,isSelected:e,onClick:s,label:i}){const n=K.useRef(null);return K.useEffect(()=>{const r=n.current;if(!r)return;const a=r.getContext("2d");if(!a)return;const l=r.width,c=r.height,h=8,d=c/2;a.clearRect(0,0,l,c),a.strokeStyle="#e2e8f0",a.lineWidth=1;for(let p=-2;p<=2;p++){const y=d+p*h;a.beginPath(),a.moveTo(10,y),a.lineTo(l-10,y),a.stroke()}ji(a,15,d,t,ft.Treble,h)},[t]),o.jsxs(u.Paper,{elevation:0,onClick:s,sx:{p:1.5,cursor:"pointer",border:"2px solid",borderColor:e?"primary.main":"divider",backgroundColor:e?"primary.50":"background.paper","&:hover":{borderColor:e?"primary.main":"primary.light",backgroundColor:e?"primary.50":"rgba(0,0,0,0.02)"},textAlign:"center",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",display:"flex",flexDirection:"column",alignItems:"center",gap:1,borderRadius:2},children:[o.jsx("canvas",{ref:n,width:80,height:50,style:{filter:e?"none":"grayscale(0.5) opacity(0.8)",transition:"filter 0.2s"}}),o.jsx(u.Typography,{variant:"caption",sx:{fontWeight:e?700:500,color:e?"primary.main":"text.secondary",fontSize:"0.7rem"},children:i})]})}function Ql({open:t,onClose:e,onSave:s,currentKeySignature:i}){const[n,r]=K.useState(0);K.useEffect(()=>{t&&r((i==null?void 0:i.fifths)||0)},[t,i]);const a=()=>{s({fifths:n}),e()},l=[{fifths:0,label:"C Major"},{fifths:1,label:"G Major (1#)"},{fifths:2,label:"D Major (2#)"},{fifths:3,label:"A Major (3#)"},{fifths:4,label:"E Major (4#)"},{fifths:5,label:"B Major (5#)"},{fifths:6,label:"F# Major (6#)"},{fifths:7,label:"C# Major (7#)"},{fifths:-1,label:"F Major (1b)"},{fifths:-2,label:"Bb Major (2b)"},{fifths:-3,label:"Eb Major (3b)"},{fifths:-4,label:"Ab Major (4b)"},{fifths:-5,label:"Db Major (5b)"},{fifths:-6,label:"Gb Major (6b)"},{fifths:-7,label:"Cb Major (7b)"}].sort((c,h)=>c.fifths-h.fifths);return o.jsxs(u.Dialog,{open:t,onClose:e,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:3,p:1}},children:[o.jsx(u.DialogTitle,{sx:{fontWeight:700},children:"Key Signature"}),o.jsx(u.DialogContent,{children:o.jsxs(u.Box,{sx:{mt:1},children:[o.jsx(u.Grid,{container:!0,spacing:1.5,children:l.map(c=>o.jsx(u.Grid,{size:{xs:4,sm:3},children:o.jsx(Kl,{fifths:c.fifths,label:c.label,isSelected:n===c.fifths,onClick:()=>r(c.fifths)})},c.fifths))}),o.jsx(u.Typography,{variant:"body2",color:"text.secondary",sx:{mt:3,textAlign:"center"},children:"Changing the key signature will affect all subsequent measures."})]})}),o.jsxs(u.DialogActions,{sx:{p:2,pt:0},children:[o.jsx(u.Button,{onClick:e,color:"inherit",children:"Cancel"}),o.jsx(u.Button,{onClick:a,variant:"contained",sx:{borderRadius:2,px:4},children:"Apply Key"})]})]})}function Ul({open:t,onClose:e,onSave:s,currentTimeSignature:i}){const[n,r]=K.useState(4),[a,l]=K.useState(4);K.useEffect(()=>{t&&(r((i==null?void 0:i.beats)||4),l((i==null?void 0:i.beatType)||4))},[t,i]);const c=()=>{s({beats:n,beatType:a}),e()};return o.jsxs(u.Dialog,{open:t,onClose:e,maxWidth:"xs",fullWidth:!0,children:[o.jsx(u.DialogTitle,{children:"Time Signature"}),o.jsx(u.DialogContent,{children:o.jsxs(u.Box,{sx:{mt:2},children:[o.jsxs(u.Box,{sx:{px:1,mb:3},children:[o.jsxs(u.Typography,{variant:"body2",gutterBottom:!0,sx:{display:"flex",justifyContent:"space-between",fontWeight:600},children:["Beats (Top) ",o.jsx("span",{children:n})]}),o.jsx(u.Slider,{value:n,onChange:(h,d)=>r(d),min:1,max:32,step:1,valueLabelDisplay:"auto",marks:[{value:1,label:"1"},{value:4,label:"4"},{value:8,label:"8"},{value:16,label:"16"},{value:32,label:"32"}]})]}),o.jsxs(u.Box,{sx:{display:"flex",gap:2,alignItems:"center"},children:[o.jsx(u.Typography,{variant:"h6",sx:{color:"text.secondary",fontWeight:300},children:"/"}),o.jsxs(u.FormControl,{fullWidth:!0,children:[o.jsx(u.InputLabel,{children:"Beat Type (Bottom)"}),o.jsxs(u.Select,{value:a,label:"Beat Type (Bottom)",onChange:h=>l(Number(h.target.value)),children:[o.jsx(u.MenuItem,{value:1,children:"1 (Whole)"}),o.jsx(u.MenuItem,{value:2,children:"2 (Half)"}),o.jsx(u.MenuItem,{value:4,children:"4 (Quarter)"}),o.jsx(u.MenuItem,{value:8,children:"8 (Eighth)"}),o.jsx(u.MenuItem,{value:16,children:"16 (Sixteenth)"}),o.jsx(u.MenuItem,{value:32,children:"32 (Thirty-second)"})]})]})]}),o.jsx(u.Typography,{variant:"body2",color:"text.secondary",sx:{mt:2},children:"This will change the time signature for the selected measure onwards."})]})}),o.jsxs(u.DialogActions,{children:[o.jsx(u.Button,{onClick:e,children:"Cancel"}),o.jsx(u.Button,{onClick:c,variant:"contained",children:"Save"})]})]})}function Xl({open:t,onClose:e,onSave:s,currentClef:i}){const[n,r]=K.useState(ft.Treble);K.useEffect(()=>{t&&r(i||ft.Treble)},[t,i]);const a=()=>{s(n),e()},l=[{value:ft.Treble,label:"Treble"},{value:ft.Bass,label:"Bass"},{value:ft.Alto,label:"Alto"},{value:ft.Tenor,label:"Tenor"},{value:ft.Percussion,label:"Percussion"},{value:ft.Tab,label:"Tab"}];return o.jsxs(u.Dialog,{open:t,onClose:e,maxWidth:"xs",fullWidth:!0,children:[o.jsx(u.DialogTitle,{sx:{fontWeight:700},children:"Select Clef"}),o.jsx(u.DialogContent,{children:o.jsxs(u.Box,{sx:{mt:2},children:[o.jsx(u.Grid,{container:!0,spacing:2,children:l.map(c=>o.jsx(u.Grid,{size:{xs:4},children:o.jsxs(u.Paper,{elevation:n===c.value?4:1,onClick:()=>r(c.value),sx:{p:1,display:"flex",flexDirection:"column",alignItems:"center",cursor:"pointer",border:"2px solid",borderColor:n===c.value?"primary.main":"transparent",transition:"all 0.2s","&:hover":{bgcolor:"rgba(0,0,0,0.02)"}},children:[o.jsx(Jl,{type:c.value}),o.jsx(u.Typography,{variant:"caption",sx:{fontWeight:"bold",mt:.5},children:c.label})]})},c.value))}),o.jsx(u.Typography,{variant:"body2",color:"text.secondary",sx:{mt:2,textAlign:"center"},children:"This change will apply to the current staff."})]})}),o.jsxs(u.DialogActions,{children:[o.jsx(u.Button,{onClick:e,children:"Cancel"}),o.jsx(u.Button,{onClick:a,variant:"contained",sx:{borderRadius:2},children:"Save"})]})]})}function Jl({type:t}){const e=K.useRef(null);return K.useEffect(()=>{const s=e.current;if(!s)return;const i=s.getContext("2d");if(!i)return;const n=s.width,r=s.height;i.clearRect(0,0,n,r);const a=8,l=r/2;i.strokeStyle="#ddd",i.lineWidth=1;for(let c=-2;c<=2;c++)i.beginPath(),i.moveTo(5,l+c*a),i.lineTo(n-5,l+c*a),i.stroke();i.fillStyle="#000",i.strokeStyle="#000",t===ft.Treble?mn(i,n/2,l+a*2,a):t===ft.Bass?xn(i,n/2,l,a):t===ft.Alto?Fs(i,n/2-10,l,a,0):t===ft.Tenor?Fs(i,n/2-10,l,a,2):t===ft.Percussion?yn(i,n/2-10,l,a):t===ft.Tab&&(i.font="bold 16px sans-serif",i.textAlign="center",i.textBaseline="middle",i.fillText("TAB",n/2,l))},[t]),o.jsx("canvas",{ref:e,width:70,height:60,style:{width:70,height:60}})}const Zl=({open:t,onClose:e,title:s,subtitle:i,composer:n,lyricist:r,copyright:a,onSave:l})=>{const[c,h]=K.useState(s),[d,p]=K.useState(i),[y,S]=K.useState(n),[I,m]=K.useState(r),[k,E]=K.useState(a),Y=()=>{l({title:c,subtitle:d,composer:y,lyricist:I,copyright:k}),e()};return o.jsxs(u.Dialog,{open:t,onClose:e,fullWidth:!0,maxWidth:"sm",children:[o.jsx(u.DialogTitle,{children:"Edit Score Info"}),o.jsx(u.DialogContent,{dividers:!0,children:o.jsxs(u.Stack,{spacing:3,sx:{mt:1},children:[o.jsx(u.TextField,{fullWidth:!0,label:"Title",value:c,onChange:R=>h(R.target.value),variant:"outlined"}),o.jsx(u.TextField,{fullWidth:!0,label:"Subtitle",value:d,onChange:R=>p(R.target.value),variant:"outlined"}),o.jsx(u.TextField,{fullWidth:!0,label:"Composer",value:y,onChange:R=>S(R.target.value),variant:"outlined"}),o.jsx(u.TextField,{fullWidth:!0,label:"Lyricist",value:I,onChange:R=>m(R.target.value),variant:"outlined"}),o.jsx(u.TextField,{fullWidth:!0,label:"Copyright",value:k,onChange:R=>E(R.target.value),variant:"outlined",multiline:!0,rows:2})]})}),o.jsxs(u.DialogActions,{sx:{p:2},children:[o.jsx(u.Button,{onClick:e,color:"inherit",children:"Cancel"}),o.jsx(u.Button,{onClick:Y,variant:"contained",color:"primary",children:"Save Changes"})]})]})};function tc({activeNotes:t=[],playedNotes:e=[],onNoteClick:s,minMidi:i=21,maxMidi:n=108}){const r=K.useMemo(()=>{const l=[];for(let c=i;c<=n;c++){const h=Math.floor(c/12)-1,d=c%12,p=[1,3,6,8,10].includes(d);l.push({midi:c,octave:h,noteInOctave:d,isBlack:p})}return l},[i,n]),a=r.filter(l=>!l.isBlack);return o.jsx(u.Paper,{elevation:4,sx:{width:"100%",height:120,display:"flex",position:"relative",bgcolor:"#000",borderTop:"1px solid",borderColor:"divider",overflowX:"auto",userSelect:"none"},children:o.jsxs(u.Box,{sx:{display:"flex",position:"relative",minWidth:"100%",px:2},children:[a.map(l=>{const c=t.includes(l.midi),h=e.includes(l.midi);return o.jsx(u.Box,{onClick:()=>s==null?void 0:s(l.midi),sx:{width:40,height:110,bgcolor:h?"primary.light":c?"warning.light":"#fff",border:"1px solid #ccc",borderBottomLeftRadius:4,borderBottomRightRadius:4,flexShrink:0,cursor:"pointer",transition:"background-color 0.1s","&:hover":{bgcolor:h?"primary.main":c?"warning.main":"#f0f0f0"},display:"flex",alignItems:"flex-end",justifyContent:"center",pb:1},children:l.noteInOctave===0&&o.jsxs(u.Typography,{variant:"caption",sx:{color:"#888",fontWeight:"bold",pointerEvents:"none"},children:["C",l.octave]})},l.midi)}),r.map((l,c)=>{if(!l.isBlack)return null;const d=r.slice(0,c).filter(S=>!S.isBlack).length*40-12+16,p=t.includes(l.midi),y=e.includes(l.midi);return o.jsx(u.Box,{onClick:S=>{S.stopPropagation(),s==null||s(l.midi)},sx:{position:"absolute",left:d,top:0,width:24,height:70,bgcolor:y?"primary.main":p?"warning.main":"#333",borderBottomLeftRadius:3,borderBottomRightRadius:3,zIndex:2,cursor:"pointer",transition:"background-color 0.1s","&:hover":{bgcolor:y?"primary.dark":p?"warning.dark":"#000"}}},l.midi)})]})})}function ec({open:t,onClose:e,onSave:s,title:i,label:n,defaultValue:r=""}){const[a,l]=K.useState(r);K.useEffect(()=>{t&&l(r)},[t,r]);const c=()=>{s(a),e()};return o.jsxs(u.Dialog,{open:t,onClose:e,maxWidth:"xs",fullWidth:!0,children:[o.jsx(u.DialogTitle,{sx:{fontWeight:700},children:i}),o.jsx(u.DialogContent,{children:o.jsx(u.TextField,{autoFocus:!0,margin:"dense",label:n,fullWidth:!0,variant:"outlined",value:a,onChange:h=>l(h.target.value),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),c())}})}),o.jsxs(u.DialogActions,{children:[o.jsx(u.Button,{onClick:e,children:"Cancel"}),o.jsx(u.Button,{onClick:c,variant:"contained",sx:{borderRadius:2},children:"Save"})]})]})}function sc({open:t,onClose:e,onSave:s,currentChord:i}){const[n,r]=K.useState("");K.useEffect(()=>{t&&r(i||"")},[t,i]);const a=()=>{s(n),e()},l=["C","G","D","A","E","B","F","Bb","Eb","Ab","Db","Gb"],c=["maj","m","7","maj7","m7","dim","aug","sus4","7sus4"],h=d=>{r(p=>p+d)};return o.jsxs(u.Dialog,{open:t,onClose:e,maxWidth:"xs",fullWidth:!0,children:[o.jsx(u.DialogTitle,{sx:{fontWeight:700},children:"Chord Symbol"}),o.jsx(u.DialogContent,{children:o.jsxs(u.Box,{sx:{mt:2,display:"flex",flexDirection:"column",gap:3},children:[o.jsx(u.TextField,{autoFocus:!0,fullWidth:!0,label:"Chord",value:n,onChange:d=>r(d.target.value),placeholder:"e.g. Cmaj7",variant:"outlined",onKeyDown:d=>{d.key==="Enter"&&a()}}),o.jsxs(u.Box,{children:[o.jsx(u.Typography,{variant:"caption",sx:{fontWeight:"bold",color:"text.secondary",mb:1,display:"block"},children:"ROOTS"}),o.jsx(u.Grid,{container:!0,spacing:1,children:l.map(d=>o.jsx(u.Grid,{size:{xs:2},children:o.jsx(u.Button,{size:"small",variant:"outlined",fullWidth:!0,onClick:()=>r(d),sx:{minWidth:0,px:0},children:d})},d))})]}),o.jsxs(u.Box,{children:[o.jsx(u.Typography,{variant:"caption",sx:{fontWeight:"bold",color:"text.secondary",mb:1,display:"block"},children:"QUALITIES / EXTENSIONS"}),o.jsx(u.Grid,{container:!0,spacing:1,children:c.map(d=>o.jsx(u.Grid,{size:{xs:4},children:o.jsx(u.Button,{size:"small",variant:"outlined",fullWidth:!0,onClick:()=>h(d),sx:{textTransform:"none"},children:d})},d))})]})]})}),o.jsxs(u.DialogActions,{children:[o.jsx(u.Button,{onClick:e,children:"Cancel"}),o.jsx(u.Button,{onClick:()=>s(""),color:"error",children:"Clear"}),o.jsx(u.Button,{onClick:a,variant:"contained",sx:{borderRadius:2},children:"Save"})]})]})}const ic="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='1024'%20height='1024'%20viewBox='0%200%201024%201024'%3e%3cg%3e%3cpath%20d='M%20725.00%20816.60%20C718.73,818.42%20711.42,818.49%20515.50,818.60%20C403.85,818.66%20311.15,818.52%20309.50,818.29%20C278.23,813.91%20249.37,790.44%20237.18,759.50%20C227.43,734.75%20227.40,706.05%20237.10,680.90%20C240.77,671.39%20245.52,663.36%20277.57,612.50%20C281.04,607.00%20285.85,599.35%20288.26,595.50%20C290.67,591.65%20296.04,583.10%20300.19,576.50%20C304.34,569.90%20310.53,560.00%20313.95,554.50%20C327.24,533.08%20333.35,523.30%20336.46,518.50%20C343.24,507.99%20347.01,502.07%20355.21,489.00%20C359.88,481.58%20369.68,466.05%20377.00,454.50%20C384.32,442.95%20392.07,430.58%20394.23,427.00%20C396.38,423.42%20399.88,417.80%20401.99,414.50%20C410.58,401.10%20417.85,388.17%20419.99,382.50%20C424.64,370.14%20425.00,365.42%20424.98,316.50%20C424.96,274.11%20424.81,270.18%20423.13,266.48%20C421.36,262.58%20420.30,261.42%20411.28,253.52%20C402.16,245.53%20399.12,230.62%20404.45,220.09%20C407.42,214.24%20414.92,207.39%20419.88,206.02%20C422.19,205.38%20456.31,205.02%20514.00,205.03%20C520.35,205.03%20526.27,205.03%20531.80,205.03%20C599.75,205.02%20608.19,205.01%20613.09,209.17%20C614.19,210.10%20615.11,211.24%20616.47,212.63%20C622.07,218.32%20624.33,224.09%20624.28,232.55%20C624.22,242.15%20621.26,247.84%20612.11,255.97%20C607.98,259.64%20604.20,264.06%20602.82,266.83%20L%20600.50%20271.50%20L%20600.50%20317.50%20C600.50,362.47%20600.55,363.69%20602.81,372.00%20C604.09,376.67%20606.33,383.20%20607.80,386.50%20C610.03,391.52%20620.21,408.71%20629.41,423.00%20C630.66,424.92%20635.19,432.12%20639.49,439.00%20C643.79,445.88%20649.87,455.55%20653.00,460.50%20C656.14,465.45%20662.21,475.12%20666.51,482.00%20C688.88,517.83%20711.85,554.46%20716.67,562.00%20C719.66,566.67%20726.19,577.03%20731.18,585.00%20C736.17,592.97%20746.16,608.86%20753.37,620.30%20C782.49,666.45%20785.34,671.37%20789.73,682.99%20C798.39,705.93%20798.26,736.34%20789.42,758.69%20C777.89,787.82%20755.87,807.62%20725.00,816.60%20ZM%20315.50%20784.36%20C316.60,784.59%20406.60,784.72%20515.50,784.64%20L%20713.50%20784.50%20L%20720.00%20782.17%20C737.10,776.03%20748.09,766.49%20755.95,751.00%20C760.59,741.84%20763.00,731.66%20762.99,721.30%20C762.98,703.96%20759.24,693.35%20745.62,672.00%20C740.53,664.03%20731.67,649.98%20725.93,640.79%20C720.19,631.59%20713.25,620.53%20710.50,616.21%20C707.75,611.89%20701.03,601.19%20695.56,592.43%20C690.09,583.67%20682.63,571.78%20678.97,566.00%20C675.31,560.22%20670.41,552.35%20668.08,548.50%20C665.75,544.65%20661.10,537.22%20657.76,532.00%20C654.41,526.78%20648.44,517.33%20644.50,511.00%20C630.33,488.29%20623.48,477.40%20619.52,471.29%20C617.31,467.87%20613.92,462.51%20612.00,459.37%20C605.57,448.90%20592.21,427.59%20586.70,419.00%20C575.97,402.29%20570.96,389.72%20568.48,373.25%20C566.71,361.51%20566.36,274.71%20568.03,264.00%20C569.20,256.52%20572.03,249.29%20576.09,243.38%20C577.65,241.11%20578.64,238.97%20578.29,238.63%20C577.18,237.51%20448.00,237.90%20448.00,239.02%20C448.00,239.57%20449.57,242.40%20451.49,245.29%20C453.65,248.54%20455.77,253.68%20457.06,258.77%20C459.07,266.71%20459.13,268.85%20458.70,319.25%20C458.41,354.43%20457.87,373.30%20457.07,377.00%20C453.24,394.65%20449.81,402.35%20436.20,423.94%20C427.60,437.59%20425.80,440.46%20414.11,459.23%20C410.59,464.88%20405.19,473.43%20402.11,478.24%20C399.02,483.05%20395.34,488.90%20393.92,491.24%20C392.50,493.58%20385.94,504.05%20379.34,514.50%20C360.88,543.74%20355.05,553.03%20348.00,564.42%20C344.42,570.20%20333.89,586.98%20324.60,601.71%20C315.30,616.45%20306.08,631.12%20304.10,634.33%20C302.12,637.53%20298.53,643.16%20296.13,646.83%20C293.72,650.50%20289.04,658.00%20285.72,663.50%20C282.40,669.00%20277.76,676.43%20275.41,680.01%20C266.54,693.52%20263.60,703.71%20263.59,721.00%20C263.58,731.44%20263.97,734.65%20265.91,740.50%20C269.66,751.74%20273.99,758.99%20281.50,766.56%20C290.68,775.81%20301.20,781.32%20315.50,784.36%20ZM%20716.00%20757.89%20L%20710.50%20760.50%20L%20515.50%20760.65%20C408.25,760.73%20318.63,760.42%20316.34,759.97%20C306.35,757.97%20295.75,749.20%20291.37,739.30%20C288.28,732.31%20286.92,721.10%20288.07,711.97%20C289.00,704.57%20293.25,694.96%20300.00,685.00%20C302.05,681.97%20306.73,674.55%20310.40,668.50%20C314.06,662.45%20319.41,653.78%20322.28,649.22%20C325.15,644.67%20333.22,631.85%20340.20,620.72%20C347.19,609.60%20361.69,586.55%20372.41,569.50%20C383.14,552.45%20393.82,535.24%20396.14,531.25%20L%20400.36%20524.00%20L%20512.00%20524.00%20L%20512.00%20465.45%20C512.00,402.79%20512.01,402.67%20516.94,400.03%20C519.42,398.70%20525.58,398.70%20528.06,400.03%20C529.12,400.60%20532.07,405.35%20534.62,410.59%20C538.99,419.56%20549.30,433.82%20553.76,437.04%20C559.62,441.27%20579.30,458.55%20584.62,464.14%20C593.88,473.85%20601.31,486.75%20605.58,500.50%20C608.29,509.27%20608.30,534.99%20605.58,543.50%20C602.30,553.80%20597.58,561.89%20592.04,566.71%20C587.84,570.38%20587.44,569.72%20588.13,560.25%20C589.86,536.57%20583.34,518.85%20567.53,504.29%20C557.19,494.76%20541.59,487.13%20532.25,487.02%20L%20530.00%20487.00%20L%20530.00%20546.00%20C530.00,578.45%20529.81,605.00%20529.57,605.00%20C529.33,605.00%20525.17,603.02%20520.32,600.61%20C509.13,595.04%20502.97,593.59%20490.50,593.58%20C472.08,593.57%20453.56,600.10%20438.82,611.81%20C421.77,625.36%20413.00,641.81%20413.00,660.24%20C413.00,676.45%20420.13,688.90%20435.00,698.68%20C449.32,708.09%20468.08,710.52%20487.51,705.47%20C505.54,700.79%20519.70,692.49%20531.89,679.46%20C538.70,672.18%20542.77,664.91%20545.90,654.46%20C547.89,647.78%20547.99,645.01%20548.24,586.00%20L%20548.50%20524.50%20L%20555.99%20524.20%20C566.97,523.76%20567.39,523.98%20571.46,532.26%20C576.56,542.62%20578.23,551.81%20577.83,567.35%20L%20577.50%20580.20%20L%20581.82%20579.72%20C587.86,579.04%20597.93,573.66%20604.78,567.46%20C609.23,563.43%20611.47,560.32%20614.37,554.15%20C617.86,546.71%20620.88,534.62%20620.97,527.72%20C621.01,523.75%20623.79,523.01%20626.41,526.27%20C627.56,527.70%20631.88,534.33%20636.00,540.99%20C640.12,547.66%20646.42,557.74%20650.00,563.40%20C653.58,569.06%20657.62,575.55%20659.00,577.83%20C660.38,580.10%20666.10,589.28%20671.71,598.23%20C677.33,607.18%20682.77,615.85%20683.79,617.50%20C689.45,626.58%20696.87,638.29%20700.58,644.00%20C717.31,669.73%20734.15,698.01%20736.28,703.92%20C738.83,711.01%20739.63,723.18%20738.00,730.15%20C735.12,742.54%20727.14,752.60%20716.00,757.89%20Z'%20fill='rgb(125,189,66)'/%3e%3c/g%3e%3c/svg%3e";function nc({size:t=40,sx:e,...s}){return o.jsx(u.Box,{sx:{width:t,height:t,borderRadius:"12px",background:"#ffffff",border:"1px solid #ebf5ed",display:"flex",alignItems:"center",justifyContent:"center",p:0,...e},...s,children:o.jsx(u.Box,{component:"img",src:ic,sx:{width:"100%",height:"100%",objectFit:"contain"},alt:"ScoreLabs Logo"})})}class Ve{static async play(e,s,i){this.isSpeaking&&this.stop();const n=s.length>0?s[0].partIndex:0,r=e.parts[n];if(!r)return;this.isSpeaking=!0;const l=6e4/(e.bpm||120),c=s.length>0?s[0].measureIndex:0;console.log(`VocalGuide: Starting for part ${n} at measure ${c}`);for(let h=c;h<r.staves[0].measures.length&&this.isSpeaking;h++){const p=r.staves[0].measures[h].voices[0]||[];for(const y of p){if(!this.isSpeaking)break;const I=y.getDurationValue()*l,m=y.lyric||y.lyrics&&y.lyrics[0];if(m&&!y.isRest){const k=new SpeechSynthesisUtterance(m);if(y.pitch){const E=y.pitch.midiNumber,Y=Math.max(.1,Math.min(2,(E-50)/20+.5));k.pitch=Y}k.rate=1.2,k.volume=1,this.currentUtterances.add(k),k.onend=()=>this.currentUtterances.delete(k),this.synthesis.speak(k)}await new Promise(k=>setTimeout(k,I))}}this.isSpeaking=!1,i&&i()}static stop(){this.isSpeaking=!1,this.synthesis.cancel(),this.currentUtterances.clear()}}qt(Ve,"synthesis",window.speechSynthesis),qt(Ve,"isSpeaking",!1),qt(Ve,"currentUtterances",new Set);function rc({score:t,zoomLevel:e,onZoomIn:s,onZoomOut:i,onResetZoom:n,onOpenFile:r,onImportPDF:a,onTranspose:l,onInstruments:c,onUpdateScore:h,onPlay:d,onStop:p,onPageSetup:y,onScoreLayout:S,onLoadSATBTemplate:I,audioPlayer:m,isPlaying:k,layoutConfig:E=vs,visiblePartIndices:Y,isMetronome:R,onToggleMetronome:O,onDownloadMusicXML:M,onDownloadPDF:q,initialEditMode:it=!1,onSave:ot,canSave:U,onUpdateTitle:dt,onUpdateComposer:st,userTier:g="free",isLoading:L=!1,onUpgrade:$,onInfill:Q,brandingLabel:ct="Powered by ScoreLabs",brandingLink:bt="https://scorelabs.io"}){var Mr;const ht=K.useRef(null),[It,_]=K.useState({open:!1,title:"",label:"",onSave:()=>{}}),[x,W]=K.useState([]),[z]=K.useState(it),[Z,yt]=K.useState(!1),[G,lt]=K.useState(0),[xt,Ct]=K.useState(null),[pt,Wt]=K.useState(null),[H,Ut]=K.useState(null),[Ne,Re]=K.useState(!1),[Xi,Bs]=K.useState(!1),[$e,ls]=K.useState(!1),[Ds,Se]=K.useState(!1),hi=K.useMemo(()=>{var v,f;if(x.length>0){const T=x[0],D=(f=(v=t.parts[T.partIndex])==null?void 0:v.staves[T.staffIndex])==null?void 0:f.measures[T.measureIndex];if(D)return D.keySignature||t.keySignature}return t.keySignature},[t,x]),Ps=K.useMemo(()=>{var v,f;if(x.length>0){const T=x[0],D=(f=(v=t.parts[T.partIndex])==null?void 0:v.staves[T.staffIndex])==null?void 0:f.measures[T.measureIndex];if(D)return D.timeSignature||t.timeSignature}return t.timeSignature},[t,x]),Ji=K.useMemo(()=>{var v;if(x.length>0){const f=x[0],T=(v=t.parts[f.partIndex])==null?void 0:v.staves[f.staffIndex];if(T){const D=T.measures[f.measureIndex];return(D==null?void 0:D.clef)||T.clef}}return ft.Treble},[t,x]),Ms=K.useMemo(()=>{var v,f;if(x.length>0){const T=x[0],D=(f=(v=t.parts[T.partIndex])==null?void 0:v.staves[T.staffIndex])==null?void 0:f.measures[T.measureIndex];if(D)return D.systemBreak}return!1},[t,x]),Zi=K.useMemo(()=>{var v,f;if(x.length>0){const T=x[0],D=(f=(v=t.parts[T.partIndex])==null?void 0:v.staves[T.staffIndex])==null?void 0:f.measures[T.measureIndex];if(D)return D.pageBreak}return!1},[t,x]),[cs,tn]=K.useState(null),[Ht,He]=K.useState(null),[ke,As]=K.useState(null),[ui,Os]=K.useState(null),[Xt,Ke]=K.useState(null),[ue,hs]=K.useState(null),[us,fs]=K.useState(!1),[be,ds]=K.useState(null),[Ns,ps]=K.useState(""),[fi,di]=K.useState(0),[en,pi]=K.useState(!1),[Mt,Rt]=K.useState({duration:"quarter",isRest:!1,accidental:"natural",articulation:null,ornament:null,dynamic:null,tie:!1,isSlurred:!1,isDotted:!1,hairpin:null,glissando:null,arpeggio:null,ottava:null,pedal:null,isPickup:!1,fret:0,string:1,isGrace:!1,color:void 0,notehead:se.Normal,bowing:null,fingering:null}),Rs=v=>{Rt(f=>({...f,fret:v})),x.length>0&&Kt(f=>f.fret!==void 0?f.withTab(v,f.string??1):f)},ge=v=>{Rt(f=>({...f,string:v})),x.length>0&&Kt(f=>f.string!==void 0?f.withTab(f.fret??0,v):f)};K.useEffect(()=>{var v,f,T;if(x.length>0){const D=x[x.length-1],j=t.parts[D.partIndex],w=D.voiceIndex||0,b=(T=(f=(v=j==null?void 0:j.staves[D.staffIndex])==null?void 0:v.measures[D.measureIndex])==null?void 0:f.voices[w])==null?void 0:T[D.noteIndex];b&&Rt(C=>{var B,N,F,V;return{...C,duration:b.duration,isRest:b.isRest,accidental:b.accidental||null,isDotted:b.isDotted,articulation:b.articulation||null,ornament:b.ornament||null,dynamic:b.dynamic||null,tie:b.tie||!1,slur:!!b.slur,hairpin:((B=b.hairpin)==null?void 0:B.type)||null,glissando:((N=b.glissando)==null?void 0:N.type)||null,arpeggio:b.arpeggio||null,ottava:((F=b.ottava)==null?void 0:F.type)||null,pedal:((V=b.pedal)==null?void 0:V.type)||null,fret:b.fret??0,string:b.string??1,color:b.color,notehead:b.notehead??se.Normal,bowing:b.bowing||null,fingering:b.fingering||null}})}},[x,t]);const kt=(v,f=!1)=>{if(x.length===0||!h)return;let T=x;if(f){const w=new Set;T=x.filter(b=>{const C=`${b.partIndex} -${b.staffIndex} -${b.measureIndex} `;return w.has(C)?!1:(w.add(C),!0)})}const D=[...T].sort((w,b)=>w.partIndex!==b.partIndex?b.partIndex-w.partIndex:w.staffIndex!==b.staffIndex?b.staffIndex-w.staffIndex:w.measureIndex!==b.measureIndex?b.measureIndex-w.measureIndex:b.noteIndex-w.noteIndex);let j=t;for(const w of D)j=v(j,w);h(j)},Kt=v=>{kt((f,T)=>{const D=f.parts[T.partIndex];if(!D)return f;const j=D.staves[T.staffIndex];if(!j)return f;const w=j.measures[T.measureIndex];if(!w)return f;const b=T.voiceIndex||0,C=w.voices[b];if(!C)return f;const B=C[T.noteIndex];if(!B)return f;const N=v(B);return f.replaceNote(T.partIndex,T.staffIndex,T.measureIndex,T.noteIndex,N,b)})},gi=v=>{Rt(f=>({...f,accidental:v})),x.length>0&&Kt(f=>f.withAccidental(v||void 0))},$s=v=>{Rt(f=>({...f,articulation:v})),x.length>0&&Kt(f=>f.withArticulation(v||void 0))},mi=v=>{Rt(f=>({...f,dynamic:v})),x.length>0&&Kt(f=>f.withDynamic(v||void 0))},ne=v=>{Rt(f=>({...f,tie:v})),x.length>0&&Kt(f=>f.withTie(v||void 0))},xi=v=>{Rt(f=>({...f,slur:v})),x.length>0&&Kt(f=>f.withSlur(v?{placement:"start"}:void 0))},yi=v=>{Rt(f=>({...f,isDotted:v})),x.length>0&&kt((f,T)=>{const D=f.parts[T.partIndex];if(!D)return f;const j=D.staves[T.staffIndex];if(!j)return f;const w=j.measures[T.measureIndex];if(!w)return f;const b=T.voiceIndex||0,C=w.voices[b];if(!C)return f;const B=C[T.noteIndex];return B?f.changeNoteDuration(T.partIndex,T.staffIndex,T.measureIndex,T.noteIndex,B.duration,v,b):f})},gs=v=>{Rt(f=>({...f,ornament:v})),x.length>0&&Kt(f=>f.withOrnament(v||void 0))},je=v=>{if(Rt(w=>({...w,hairpin:v})),!h||x.length===0)return;const f=[...x].sort((w,b)=>w.partIndex!==b.partIndex?w.partIndex-b.partIndex:w.staffIndex!==b.staffIndex?w.staffIndex-b.staffIndex:w.measureIndex!==b.measureIndex?w.measureIndex-b.measureIndex:w.noteIndex-b.noteIndex);let T=t;const D=f[0],j=f[f.length-1];if(v)if(f.length===1){T=Vt(T,D,b=>b.withHairpin({type:v,placement:"start"}));const w=oc(T,D);w&&(T=Vt(T,w,b=>b.withHairpin({type:v,placement:"stop"})))}else{T=Vt(T,D,w=>w.withHairpin({type:v,placement:"start"})),T=Vt(T,j,w=>w.withHairpin({type:v,placement:"stop"}));for(let w=1;w<f.length-1;w++)T=Vt(T,f[w],b=>b.withHairpin(void 0))}else for(const w of f)T=Vt(T,w,b=>b.withHairpin(void 0));h(T)},ms=v=>{Rt(f=>({...f,glissando:v})),x.length>0&&Kt(f=>f.withGlissando(v?{type:v,placement:"start"}:void 0))},vi=v=>{Rt(f=>({...f,arpeggio:v})),x.length>0&&Kt(f=>f.withArpeggio(v||void 0))},bi=v=>{Rt(f=>({...f,ottava:v})),x.length>0&&Kt(f=>f.withOttava(v?{type:v,placement:"start"}:void 0))},sn=v=>{Rt(f=>({...f,pedal:v})),x.length>0&&Kt(f=>f.withPedal(v?{type:v,placement:"start"}:void 0))},nn=v=>{Rt(f=>({...f,color:v})),x.length>0&&Kt(f=>f.withColor(v))},rn=v=>{Rt(f=>({...f,notehead:v})),x.length>0&&Kt(f=>f.withNotehead(v))},on=v=>{Rt(f=>({...f,bowing:v})),x.length>0&&Kt(f=>f.withBowing(v||void 0))},et=v=>{Rt(f=>({...f,fingering:v})),x.length>0&&Kt(f=>f.withFingering(v||void 0))},mt=async()=>{if(!(x.length===0||!h||!Q)){pi(!0);try{const v=await Q(t,x);h(v)}catch(v){console.error("AI Infill failed:",v)}finally{pi(!1)}}},[Jt,Ti]=K.useState(!1),mc=async()=>{if(Jt){Ve.stop(),Ti(!1);return}Ti(!0),await Ve.play(t,x,()=>{Ti(!1)})},xc=v=>{if(di(v),v>0&&x.length>0&&h){const f=x[0],T=t.parts[f.partIndex],D=T.staves.map(j=>{let w=!1;for(const b of j.measures)if(!b.voices[v]||b.voices[v].length===0){w=!0;break}if(w){const b=j.measures.map(C=>{const N=(C.voices[0]||[]).reduce((F,V)=>F+V.getDurationValue(),0);return C.fillVoiceWithRests(v,N)});return j.withMeasures(b)}return j});if(D.some((j,w)=>j!==T.staves[w])){const j=T.withStaves(D),w=t.replacePart(f.partIndex,j);h(w)}}},gt=K.useMemo(()=>gn(t,{...vs,...E,staffLineSpacing:E.staffLineSpacing*e},Y),[t,e,E,Y]),yc=K.useMemo(()=>{const v=new Map;return gt&&gt.pages.forEach((f,T)=>{f.systemLayouts.forEach(D=>{D.staffLayouts.forEach(j=>{j.measureLayouts.forEach(w=>{v.set(w.measureNumber-1,T)})})})}),v},[gt]);K.useEffect(()=>{G>=gt.pages.length&&lt(Math.max(0,gt.pages.length-1))},[gt,G]);const vc=(v,f)=>{if(G>=gt.pages.length)return null;const T=15*e,D=gt.pages[G];for(const j of D.systemLayouts)if(!(f<j.y-T||f>j.y+j.height+T))for(const w of j.staffLayouts)for(let b=0;b<w.measureLayouts.length;b++){const C=w.measureLayouts[b];if(!(v<C.x-T||v>C.x+C.width+T))for(let B=0;B<C.noteLayouts.length;B++){const N=C.noteLayouts[B],F=N.x-v,V=N.y-f;if(F*F+V*V<T*T)return{partIndex:w.partIndex,staffIndex:w.staffIndex,measureIndex:w.measureLayouts[b].measureNumber-1,noteIndex:N.noteIndex,voiceIndex:N.voiceIndex}}}return null},Ls=K.useCallback((v,f,T)=>{if(G>=gt.pages.length)return null;const D=gt.pages[G];let j=null,w=1/0;for(const b of D.systemLayouts){const C=b.staffLayouts.find(B=>B.partIndex===T.partIndex&&B.staffIndex===T.staffIndex);if(C){const N=E.staffLineSpacing*e*10;f>=b.y-N&&f<=b.y+b.height+N&&C.measureLayouts.forEach(F=>{F.noteLayouts.forEach(V=>{const X=Math.abs(V.x-v);X<w&&(w=X,j={partIndex:C.partIndex,staffIndex:C.staffIndex,measureIndex:F.measureNumber-1,noteIndex:V.noteIndex,voiceIndex:V.voiceIndex})})})}}return j},[G,gt,E.staffLineSpacing,e]),bc=v=>{if(G>=gt.pages.length)return[];const f=gt.pages[G],T=[],D=v.x,j=v.y,w=v.w,b=v.h;for(const C of f.systemLayouts)if(!(j>C.y+C.height||j+b<C.y))for(const B of C.staffLayouts)for(let N=0;N<B.measureLayouts.length;N++){const F=B.measureLayouts[N];if(!(D>F.x+F.width||D+w<F.x))for(let V=0;V<F.noteLayouts.length;V++){const X=F.noteLayouts[V];X.x>=D&&X.x<=D+w&&X.y>=j&&X.y<=j+b&&T.push({partIndex:B.partIndex,staffIndex:B.staffIndex,measureIndex:B.measureLayouts[N].measureNumber-1,noteIndex:X.noteIndex,voiceIndex:X.voiceIndex})}}return T};K.useEffect(()=>{const v=ht.current;if(!v)return;const f=v.getContext("2d");if(!f)return;G<gt.pages.length?(v.width=gt.pages[G].width,v.height=gt.pages[G].height):(v.width=100,v.height=100);const T=new Sn(f,{staffLineSpacing:E.staffLineSpacing*e,marginLeft:E.marginLeft*e,marginRight:E.marginRight*e,marginTop:E.marginTop*e,trebleClefYOffset:E.trebleClefYOffset,bassClefYOffset:E.bassClefYOffset,noteDotDistance:E.noteDotDistance,titleSubtitleSpacing:E.titleSubtitleSpacing*e,subtitleScoreSpacing:E.subtitleScoreSpacing*e,musicFont:E.musicFont,showMeasureNumbers:E.showMeasureNumbers,measureNumberMode:E.measureNumberMode,measureNumberInterval:E.measureNumberInterval,showPartNames:E.showPartNames,groupMultiMeasureRests:E.groupMultiMeasureRests,titleStyle:E.titleStyle,composerStyle:E.composerStyle});if(G<gt.pages.length){if(f.save(),T.render(t,gt,G),x.length>0){const D=gt.pages[G];for(const j of D.systemLayouts)for(const w of j.staffLayouts)for(const b of w.measureLayouts)b.noteLayouts.forEach((C,B)=>{if(x.some(F=>F.partIndex===w.partIndex&&F.staffIndex===w.staffIndex&&F.measureIndex===b.measureNumber-1&&F.noteIndex===B)){f.strokeStyle="#f97316",f.lineWidth=2;const F=20*e;f.strokeRect(C.x-F/2,C.y-F/2,F,F)}})}f.restore()}},[gt,x,t,e,E,G]);const kr=K.useRef(null),Tc=K.useRef(xt);K.useEffect(()=>{Tc.current=xt},[xt]),K.useEffect(()=>{const v=kr.current;if(!v||!gt)return;const f=v.getContext("2d");if(!f)return;G<gt.pages.length?(v.width=gt.pages[G].width,v.height=gt.pages[G].height):(v.width=100,v.height=100);let T;const D=()=>{if(!m||!gt||G>=gt.pages.length)return[];const b=m.getMeasureTimings();if(b.length===0)return[];const C=[],B=gt.pages[G],N=new Map;B.systemLayouts.forEach(F=>{F.staffLayouts.forEach((V,X)=>{X===0&&V.measureLayouts.forEach(J=>{N.set(J.measureNumber-1,{x:J.x,width:J.width,top:F.y,bottom:F.y+F.height})})})});for(const F of b){const V=N.get(F.measureIndex);V&&(C.push({time:F.startTime,x:V.x,top:V.top,bottom:V.bottom}),C.push({time:F.startTime+F.duration,x:V.x+V.width,top:V.top,bottom:V.bottom}))}return C};let j=[];const w=()=>{if(f.clearRect(0,0,v.width,v.height),k&&m&&(j.length===0&&(j=D()||[]),j.length>0)){const B=m.getCurrentTime(),F=m.getMeasureTimings().find(tt=>B>=tt.startTime&&B<tt.startTime+tt.duration);if(F){const tt=yc.get(F.measureIndex);if(tt!==void 0&&tt!==G){lt(tt);return}}let V=0,X=!1,J=0,at=0;const nt=j;if(B<nt[0].time)V=nt[0].x,J=nt[0].top,at=nt[0].bottom,X=!0;else if(B>=nt[nt.length-1].time)V=nt[nt.length-1].x,J=nt[nt.length-1].top,at=nt[nt.length-1].bottom,X=!0;else for(let tt=0;tt<nt.length-1;tt++){const rt=nt[tt],ut=nt[tt+1];if(B>=rt.time&&B<ut.time){if(rt.top!==ut.top)V=rt.x,J=rt.top,at=rt.bottom;else{const St=(B-rt.time)/(ut.time-rt.time);V=rt.x+(ut.x-rt.x)*St,J=rt.top,at=rt.bottom}X=!0;break}}X&&(f.beginPath(),f.moveTo(V,J),f.lineTo(V,at),f.strokeStyle="#33a854",f.lineWidth=2,f.stroke())}const b=Ht||cs;if(b&&gt){const B=gt.pages[G],N=[b.start,b.end],F=!!Ht,V=F?"#ea580c":"#9333ea",X=F?"rgba(234, 88, 12, 0.2)":"rgba(147, 51, 234, 0.2)";f.strokeStyle=V,f.lineWidth=2,f.fillStyle=X;const J=[];if(N.forEach(at=>{const nt=B.systemLayouts.find(tt=>tt.staffLayouts.some(rt=>rt.partIndex===at.partIndex&&rt.staffIndex===at.staffIndex));if(nt){const tt=nt.staffLayouts.find(rt=>rt.partIndex===at.partIndex&&rt.staffIndex===at.staffIndex);if(tt){const rt=tt.measureLayouts.find(ut=>ut.measureNumber-1===at.measureIndex);if(rt){const ut=rt.noteLayouts[at.noteIndex];if(ut){const St=24*e;f.strokeRect(ut.x-St/2,ut.y-St/2,St,St),f.fillRect(ut.x-St/2,ut.y-St/2,St,St),J.push({x:ut.x,y:ut.y})}}}}}),F&&J.length===2){const at=10*e,nt=E.staffLineSpacing*e,tt=J[0].y+nt*6;f.fillStyle="#fff",f.strokeStyle="#000",f.lineWidth=1;const rt=J[0].x,ut=J[1].x;if(ke&&H&&(f.beginPath(),ke==="start"?(f.moveTo(H.x,tt),f.lineTo(ut,tt)):(f.moveTo(rt,tt),f.lineTo(H.x,tt)),f.strokeStyle="#ea580c",f.setLineDash([5,5]),f.stroke(),f.setLineDash([]),Ht)){const St=Ls(H.x,H.y,Ht.start);if(St){const Zt=St,re=B.systemLayouts.find(Et=>Et.staffLayouts.some(me=>me.partIndex===Zt.partIndex&&me.staffIndex===Zt.staffIndex)),ie=re==null?void 0:re.staffLayouts.find(Et=>Et.partIndex===Zt.partIndex&&Et.staffIndex===Zt.staffIndex),fe=ie==null?void 0:ie.measureLayouts.find(Et=>Et.measureNumber-1===Zt.measureIndex),oe=fe==null?void 0:fe.noteLayouts[Zt.noteIndex];if(oe){const Et=24*e;f.restore(),f.save(),f.strokeStyle="#ea580c",f.lineWidth=2,f.setLineDash([]),f.strokeRect(oe.x-Et/2,oe.y-Et/2,Et,Et),f.strokeStyle="#000",f.lineWidth=1}}}[rt,ut].forEach(St=>{f.fillRect(St-at/2,tt-at/2,at,at),f.strokeRect(St-at/2,tt-at/2,at,at)})}}const C=Xt||ui;if(C&&gt){const B=gt.pages[G],N=[C.start,C.end],F=!!Xt,V=F?"#ea580c":"#33a854",X=F?"rgba(234, 88, 12, 0.2)":"rgba(51, 168, 84, 0.2)";f.strokeStyle=V,f.lineWidth=2,f.fillStyle=X;const J=[];if(N.forEach(at=>{const nt=B.systemLayouts.find(tt=>tt.staffLayouts.some(rt=>rt.partIndex===at.partIndex&&rt.staffIndex===at.staffIndex));if(nt){const tt=nt.staffLayouts.find(rt=>rt.partIndex===at.partIndex&&rt.staffIndex===at.staffIndex);if(tt){const rt=tt.measureLayouts.find(ut=>ut.measureNumber-1===at.measureIndex);if(rt){const ut=rt.noteLayouts[at.noteIndex];if(ut){const St=24*e;f.strokeRect(ut.x-St/2,ut.y-St/2,St,St),f.fillRect(ut.x-St/2,ut.y-St/2,St,St),J.push({x:ut.x,y:ut.y})}}}}}),F&&J.length===2){const at=10*e,nt=E.staffLineSpacing*e,tt=J[0].y+nt*3;f.fillStyle="#fff",f.strokeStyle="#000",f.lineWidth=1;const rt=J[0].x,ut=J[1].x;if(ue&&H&&(f.beginPath(),ue==="start"?(f.moveTo(H.x,tt),f.lineTo(ut,tt)):(f.moveTo(rt,tt),f.lineTo(H.x,tt)),f.strokeStyle="#ea580c",f.setLineDash([5,5]),f.stroke(),f.setLineDash([]),Xt)){const St=Ls(H.x,H.y,Xt.start);if(St){const Zt=St,re=B.systemLayouts.find(Et=>Et.staffLayouts.some(me=>me.partIndex===Zt.partIndex&&me.staffIndex===Zt.staffIndex)),ie=re==null?void 0:re.staffLayouts.find(Et=>Et.partIndex===Zt.partIndex&&Et.staffIndex===Zt.staffIndex),fe=ie==null?void 0:ie.measureLayouts.find(Et=>Et.measureNumber-1===Zt.measureIndex),oe=fe==null?void 0:fe.noteLayouts[Zt.noteIndex];if(oe){const Et=24*e;f.restore(),f.save(),f.strokeStyle="#ea580c",f.lineWidth=2,f.setLineDash([]),f.strokeRect(oe.x-Et/2,oe.y-Et/2,Et,Et),f.strokeStyle="#000",f.lineWidth=1}}}[rt,ut].forEach(St=>{f.fillRect(St-at/2,tt-at/2,at,at),f.strokeRect(St-at/2,tt-at/2,at,at)})}}if(!k&&xt&&!z&&!pt){const{x:B,y:N}=xt,F=24*e,V=B+5*e,X=N+5*e;f.beginPath(),f.arc(V+F/2,X+F/2,F/2,0,Math.PI*2),f.fillStyle="rgba(51, 168, 84, 0.9)",f.fill(),f.beginPath();const J=V+F*.35,at=X+F*.3;f.moveTo(J,at),f.lineTo(J+F*.4,at+F*.2),f.lineTo(J,at+F*.4),f.closePath(),f.fillStyle="white",f.fill()}if(pt&&H&&!ke&&!ue){const B=H.x-pt.x,N=H.y-pt.y;if(Math.sqrt(B*B+N*N)>5){const F=Math.min(pt.x,H.x),V=Math.min(pt.y,H.y),X=Math.abs(H.x-pt.x),J=Math.abs(H.y-pt.y);f.fillStyle="rgba(51, 168, 84, 0.2)",f.fillRect(F,V,X,J),f.strokeStyle="#33a854",f.lineWidth=1,f.strokeRect(F,V,X,J)}}T=requestAnimationFrame(w)};return w(),()=>cancelAnimationFrame(T)},[k,gt,m,t,xt,cs,Ht,ke,z,e,G,pt,H,ue,Ls,ui,E,Xt]);const Sc=v=>{const f=ht.current;if(!f)return;const T=f.getBoundingClientRect(),D=f.width/T.width,j=f.height/T.height,w=(v.clientX-T.left)*D,b=(v.clientY-T.top)*j;if(Ht&&gt){const C=gt.pages[G],B=E.staffLineSpacing*e,N=[Ht.start,Ht.end],F=[];if(N.forEach(V=>{const X=C.systemLayouts.find(tt=>tt.staffLayouts.some(rt=>rt.partIndex===V.partIndex&&rt.staffIndex===V.staffIndex)),J=X==null?void 0:X.staffLayouts.find(tt=>tt.partIndex===V.partIndex&&tt.staffIndex===V.staffIndex),at=J==null?void 0:J.measureLayouts.find(tt=>tt.measureNumber-1===V.measureIndex),nt=at==null?void 0:at.noteLayouts[V.noteIndex];nt&&F.push({x:nt.x,y:nt.y})}),F.length===2){const V=F[0].y+B*6,J=10*e;if(Math.abs(w-F[0].x)<J&&Math.abs(b-V)<J){As("start"),Wt({x:w,y:b}),Ut({x:w,y:b});return}if(Math.abs(w-F[1].x)<J&&Math.abs(b-V)<J){As("end"),Wt({x:w,y:b}),Ut({x:w,y:b});return}}}if(Xt&&gt){const C=gt.pages[G],B=E.staffLineSpacing*e,N=[Xt.start,Xt.end],F=[];if(N.forEach(V=>{const X=C.systemLayouts.find(tt=>tt.staffLayouts.some(rt=>rt.partIndex===V.partIndex&&rt.staffIndex===V.staffIndex)),J=X==null?void 0:X.staffLayouts.find(tt=>tt.partIndex===V.partIndex&&tt.staffIndex===V.staffIndex),at=J==null?void 0:J.measureLayouts.find(tt=>tt.measureNumber-1===V.measureIndex),nt=at==null?void 0:at.noteLayouts[V.noteIndex];nt&&F.push({x:nt.x,y:nt.y})}),F.length===2){const V=F[0].y+B*3,J=10*e;if(Math.abs(w-F[0].x)<J&&Math.abs(b-V)<J){hs("start"),Wt({x:w,y:b}),Ut({x:w,y:b});return}if(Math.abs(w-F[1].x)<J&&Math.abs(b-V)<J){hs("end"),Wt({x:w,y:b}),Ut({x:w,y:b});return}}}Wt({x:w,y:b})},wc=v=>{const f=ht.current;if(!f||k)return;const T=f.getBoundingClientRect(),D=f.width/T.width,j=f.height/T.height,w=(v.clientX-T.left)*D,b=(v.clientY-T.top)*j;if(pt){const C=w-pt.x,B=b-pt.y;(H||Math.sqrt(C*C+B*B)>2)&&Ut({x:w,y:b})}else if(!k){let C=null;if(G<gt.pages.length){const F=gt.pages[G];for(const V of F.systemLayouts){if(b>=V.y&&b<=V.y+V.height)for(const X of V.staffLayouts){for(const J of X.measureLayouts)if(w>=J.x&&w<=J.x+J.width){C={index:J.measureNumber-1,x:J.x,y:V.y,height:V.height};break}if(C)break}if(C)break}}Ct(C);const B=Er(w,b);tn(B||null);const N=jr(w,b);Os(N)}},jr=(v,f)=>{if(G>=gt.pages.length)return null;const T=gt.pages[G],D=E.staffLineSpacing*e;for(const j of T.systemLayouts)if(!(f<j.y-D*5||f>j.y+j.height+D*5))for(const w of j.staffLayouts){const b=[];w.measureLayouts.forEach(C=>{C.noteLayouts.forEach((B,N)=>{B.note.slur&&b.push({placement:B.note.slur.placement,x:B.x,y:B.y,selection:{partIndex:w.partIndex,staffIndex:w.staffIndex,measureIndex:C.measureNumber-1,noteIndex:N}})})});for(let C=0;C<b.length;C++){const B=b[C];if(B.placement==="start"){const N=b.slice(C+1).find(F=>F.placement==="stop");if(N){const F=D*2;if(v>=B.x&&v<=N.x&&Math.abs(f-B.y)<F)return{start:B.selection,end:N.selection}}}}}return null},Er=(v,f)=>{if(G>=gt.pages.length)return null;const T=gt.pages[G],D=E.staffLineSpacing*e;for(const j of T.systemLayouts)if(!(f<j.y||f>j.y+j.height+D*8))for(const w of j.staffLayouts){const b=[];w.measureLayouts.forEach(C=>{C.noteLayouts.forEach((B,N)=>{B.note.hairpin&&b.push({type:B.note.hairpin.type,placement:B.note.hairpin.placement,x:B.x,y:B.y,selection:{partIndex:w.partIndex,staffIndex:w.staffIndex,measureIndex:C.measureNumber-1,noteIndex:N}})})});for(let C=0;C<b.length;C++){const B=b[C];if(B.placement==="start"){const N=b.slice(C+1).find(F=>F.placement==="stop"&&F.type===B.type);if(N){const F=B.y+D*6,V=D*2;if(v>=B.x&&v<=N.x&&f>=F-V/2&&f<=F+V/2)return{start:B.selection,end:N.selection,type:B.type}}}}}return null},Cc=(v,f)=>{if(G>=gt.pages.length)return null;const T=gt.pages[G],D=E.staffLineSpacing*e;for(const j of T.systemLayouts)if(f>=j.y&&f<=j.y+j.height+D*8){for(const w of j.staffLayouts)if(f>=w.y-D*8&&f<=w.y+D*12){for(const b of w.measureLayouts)if(v>=b.x&&v<=b.x+b.width){const C=w.y-f,B=Math.round(C/(D/2)),N=le.fromStaffPosition(w.clef,B);return{partIndex:w.partIndex,staffIndex:w.staffIndex,measureIndex:b.measureNumber-1,pitch:N}}}}return null},Ic=v=>{var V;const f=ht.current;if(!f)return;const T=()=>{As(null),hs(null),Wt(null),Ut(null)};if(ke&&Ht&&H){const X=Ls(H.x,H.y,Ht.start);if(X&&h){let J=t;J=Vt(J,Ht.start,tt=>tt.withHairpin(void 0)),J=Vt(J,Ht.end,tt=>tt.withHairpin(void 0));const at=ke==="start"?X:Ht.start,nt=ke==="end"?X:Ht.end;J=Vt(J,at,tt=>tt.withHairpin({type:Ht.type,placement:"start"})),J=Vt(J,nt,tt=>tt.withHairpin({type:Ht.type,placement:"stop"})),h(J),He({start:at,end:nt,type:Ht.type})}T();return}if(ue&&Xt&&H){if(ue==="body"&&pt){const X=H.y-pt.y;if(Math.abs(X)>20){const J=X<0?"up":"down";if(h){const at=Vt(t,Xt.start,nt=>nt.withSlur({...nt.slur,placement:"start",direction:J}));h(at)}}}else{const X=Ls(H.x,H.y,Xt.start);if(X&&h){let J=t;J=Vt(J,Xt.start,ut=>ut.withSlur(void 0)),J=Vt(J,Xt.end,ut=>ut.withSlur(void 0));const at=ue==="start"?X:Xt.start,nt=ue==="end"?X:Xt.end,tt=ee(t,Xt.start),rt=(V=tt==null?void 0:tt.slur)==null?void 0:V.direction;J=Vt(J,at,ut=>ut.withSlur({placement:"start",direction:rt})),J=Vt(J,nt,ut=>ut.withSlur({placement:"stop"})),h(J),Ke({start:at,end:nt})}}T();return}if(!pt)return;const D=f.getBoundingClientRect(),j=f.width/D.width,w=f.height/D.height,b=(v.clientX-D.left)*j,C=(v.clientY-D.top)*w,B=b-pt.x,N=C-pt.y;if(Math.sqrt(B*B+N*N)<5){if(z&&G===0&&gt.pages.length>0){const nt=gt.pages[0],tt=(E.marginRight||40)*e;if(nt.titleY!==void 0){const rt=nt.titleY*e,ut=nt.width*e/2;if(Math.abs(C-rt)<30*e&&Math.abs(b-ut)<200*e){yt(!0),T();return}}if(nt.subtitleY!==void 0){const rt=nt.subtitleY*e,ut=nt.width*e/2;if(Math.abs(C-rt)<20*e&&Math.abs(b-ut)<150*e){yt(!0),T();return}}if(nt.composerY!==void 0){const rt=nt.composerY*e,ut=nt.width*e-tt;if(Math.abs(C-rt)<20*e&&b>ut-150*e&&b<ut+20*e){yt(!0),T();return}}}if(z&&G===0&&gt.pages.length>0){const nt=gt.pages[0];if(nt.systemLayouts.length>0){const tt=nt.systemLayouts[0];if(tt.staffLayouts.length>0){const rt=tt.staffLayouts[0],ut=E.staffLineSpacing*e,St=E.clefWidth*e,re=rt.x-St+10,ie=rt.y-ut*5;if(b>=re-10&&b<=re+ut*10&&C>=ie-ut&&C<=ie+ut*2){Re(!0),T();return}}}}if(xt&&!k&&!z){const nt=24*e,tt=xt.x+5*e,rt=xt.y+5*e;if(b>=tt&&b<=tt+nt&&C>=rt&&C<=rt+nt){d&&d(xt.index),T();return}}const X=vc(b,C),J=Er(b,C),at=jr(b,C);if(J){He(J),W([]),T();return}else X?He(null):at||He(null);if(at?(Ke(at),W([]),He(null),hs("body")):Ke(null),at||(v.shiftKey?X&&W(nt=>{const tt=nt.findIndex(rt=>rt.partIndex===X.partIndex&&rt.staffIndex===X.staffIndex&&rt.measureIndex===X.measureIndex&&rt.noteIndex===X.noteIndex&&rt.voiceIndex===X.voiceIndex);return tt>=0?nt.filter((rt,ut)=>ut!==tt):[...nt,X]}):W(X?[X]:[])),X&&m){const rt=t.parts[X.partIndex].staves[X.staffIndex].measures[X.measureIndex],ut=X.voiceIndex||0,St=rt.voices[ut];if(St&&X.noteIndex<St.length){const Zt=St[X.noteIndex];!Zt.isRest&&Zt.pitch&&m.playPitch(Zt.pitch)}}if(!X&&!J&&!at&&z&&h){const nt=Cc(b,C);if(nt){const{partIndex:tt,staffIndex:rt,measureIndex:ut,pitch:St}=nt,ie=t.parts[tt].staves[rt].measures[ut];if(x.length===0){const Et=[];if(ie.voices.forEach((me,Qe)=>{me.forEach((Le,ae)=>{Et.push({partIndex:tt,staffIndex:rt,measureIndex:ut,noteIndex:ae,voiceIndex:Qe})})}),Et.length>0){W(Et),T();return}}else if(!v.shiftKey){W([]),T();return}const fe=fi;let oe=t;if(!ie.voices[fe]||ie.voices[fe].length===0){const Et=[...ie.voices];for(let Le=0;Le<=fe;Le++)Et[Le]||(Et[Le]=[new wt(P.Whole,void 0,!0)]);const me=new _t(Et,ie.timeSignature,ie.keySignature);oe=oe.replaceMeasure(tt,rt,ut,me);const Qe=new wt(Mt.duration||P.Quarter,St,!1).withColor(Mt.color);oe=oe.replaceNote(tt,rt,ut,0,Qe,fe),h(oe)}else{const me=gt.pages[G].systemLayouts.find(ae=>ae.staffLayouts.some(Ws=>Ws.partIndex===tt&&Ws.staffIndex===rt)),Qe=me==null?void 0:me.staffLayouts.find(ae=>ae.partIndex===tt&&ae.staffIndex===rt),Le=Qe==null?void 0:Qe.measureLayouts.find(ae=>ae.measureNumber-1===ut);if(Le){const ae=[];let Ws=0;if(Le.noteLayouts.forEach(_s=>{(_s.voiceIndex||0)===fe&&(ae.push({x:_s.x,index:Ws}),Ws++)}),ae.length>0){let _s=ae[0],ln=Math.abs(ae[0].x-b);for(let wi=1;wi<ae.length;wi++){const Ar=Math.abs(ae[wi].x-b);Ar<ln&&(ln=Ar,_s=ae[wi])}const Oc=new wt(Mt.duration||P.Quarter,St,!1).withColor(Mt.color);oe=oe.replaceNote(tt,rt,ut,_s.index,Oc,fe),h(oe)}}}}}}else{const X=Math.min(pt.x,b),J=Math.min(pt.y,C),at=Math.abs(b-pt.x),nt=Math.abs(C-pt.y),tt=bc({x:X,y:J,w:at,h:nt});tt.length>0?v.shiftKey?W(rt=>{const ut=[...rt];return tt.forEach(St=>{ut.some(re=>re.partIndex===St.partIndex&&re.staffIndex===St.staffIndex&&re.measureIndex===St.measureIndex&&re.noteIndex===St.noteIndex)||ut.push(St)}),ut}):W(tt):v.shiftKey||W([])}T()},[Br,kc]=K.useState(!1),[an,jc]=K.useState(!1),[Ec,Dr]=K.useState([]),[Bc,Pr]=K.useState(!1);K.useEffect(()=>{kc(!!k)},[k]),K.useEffect(()=>{if(!Br||!m){Dr([]);return}let v;const f=()=>{const T=m.getCurrentTime(),D=m.getTrackedNotes(),j=[];D.forEach(w=>{const b=m.getNoteStartTimes().get(w.note)??0,C=b+w.durationMs/1e3;T>=b&&T<C&&w.note.pitch&&j.push(w.note.pitch.midiNumber)}),Dr(j),v=requestAnimationFrame(f)};return v=requestAnimationFrame(f),()=>{cancelAnimationFrame(v)}},[Br,m]);const Si=K.useRef([]),Dc=v=>{if(x.length>0){const f=v.split(`
96
+ `);f.length>1?Kt(T=>T.withLyrics(f)):Kt(T=>T.withLyric(v).withLyrics([]))}};K.useEffect(()=>{var D;if(!us){ds(null);return}if(x.length!==1||!gt){ds(null),x.length===0&&fs(!1);return}const v=x[0],T=gt.pages[G].systemLayouts.find(j=>j.staffLayouts.some(w=>w.partIndex===v.partIndex&&w.staffIndex===v.staffIndex));if(T){const j=T.staffLayouts.find(w=>w.partIndex===v.partIndex&&w.staffIndex===v.staffIndex);if(j){const w=j.measureLayouts.find(b=>b.measureNumber-1===v.measureIndex);if(w){const b=w.noteLayouts[v.noteIndex];if(b){const C=E.staffLineSpacing*e,B=j.y+C*8;ds({x:b.x,y:B});const F=t.parts[v.partIndex].staves[v.staffIndex].measures[v.measureIndex],V=v.voiceIndex||0,X=(D=F.voices[V])==null?void 0:D[v.noteIndex];X&&(X.lyrics&&X.lyrics.length>0?ps(X.lyrics.join(`
97
+ `)):ps(X.lyric||""))}}}}},[us,x,gt,G,t,E,e]),K.useEffect(()=>{if(!h)return;const v=f=>{var D;if(f.target instanceof HTMLInputElement||f.target instanceof HTMLTextAreaElement)return;const T=f.metaKey||f.ctrlKey;if(T&&f.key==="k")f.preventDefault(),Bs(!0);else if(T&&f.key==="m")f.preventDefault(),ls(!0);else if(T&&f.key==="l")f.preventDefault(),Se(!0);else if(T&&f.key==="o")f.preventDefault(),(D=document.querySelector('input[type="file"]'))==null||D.click();else if(T&&f.key==="t")f.preventDefault(),l();else if(T&&f.key==="p")f.preventDefault(),q==null||q();else if(T&&(f.key==="="||f.key==="+"))f.preventDefault(),s();else if(T&&f.key==="-")f.preventDefault(),i();else if(T&&f.key==="0")f.preventDefault(),n();else if(T&&f.key==="c"){if(x.length===0)return;f.preventDefault();const j=[...x].sort((b,C)=>b.partIndex!==C.partIndex?b.partIndex-C.partIndex:b.staffIndex!==C.staffIndex?b.staffIndex-C.staffIndex:b.measureIndex!==C.measureIndex?b.measureIndex-C.measureIndex:b.noteIndex-C.noteIndex),w=[];for(const b of j){const C=ee(t,b);C&&w.push(C)}Si.current=w,console.log("Copied notes:",w.length)}else if(T&&f.key==="x"){if(!z||x.length===0)return;f.preventDefault();const j=[...x].sort((b,C)=>b.partIndex!==C.partIndex?b.partIndex-C.partIndex:b.staffIndex!==C.staffIndex?b.staffIndex-C.staffIndex:b.measureIndex!==C.measureIndex?b.measureIndex-C.measureIndex:b.noteIndex-C.noteIndex),w=[];for(const b of j){const C=ee(t,b);C&&w.push(C)}Si.current=w,kt((b,C)=>b.deleteNote(C.partIndex,C.staffIndex,C.measureIndex,C.noteIndex,C.voiceIndex||0)),W([])}else if(T&&f.key==="v"){if(!z||Si.current.length===0)return;f.preventDefault();let j=x[0];if(!j)return;j=[...x].sort((B,N)=>B.partIndex!==N.partIndex?B.partIndex-N.partIndex:B.staffIndex!==N.staffIndex?B.staffIndex-N.staffIndex:B.measureIndex!==N.measureIndex?B.measureIndex-N.measureIndex:B.noteIndex-N.noteIndex)[0];const b=Si.current,C=t.pasteNotes(j.partIndex,j.staffIndex,j.measureIndex,j.noteIndex,b);h(C)}else if(f.key==="Delete"){if(!z)return;kt((j,w)=>j.deleteNote(w.partIndex,w.staffIndex,w.measureIndex,w.noteIndex,w.voiceIndex||0)),W([])}else if(f.key==="Backspace"){if(!z)return;kt((j,w)=>Vt(j,w,b=>b.withRest(!0)))}else if(z&&/^[1-9]$/.test(f.key)){f.preventDefault();const w={1:P.Whole,2:P.Half,3:P.Quarter,4:P.Eighth,5:P.Sixteenth,6:P.ThirtySecond,7:P.SixtyFourth,8:P.OneHundredTwentyEighth,9:P.TwoHundredFiftySixth}[f.key];Rt(b=>({...b,duration:w})),x.length>0&&kt((b,C)=>{if(!b.parts[C.partIndex])return b;const N=ee(b,C);return N?b.changeNoteDuration(C.partIndex,C.staffIndex,C.measureIndex,C.noteIndex,w,N.isDotted,C.voiceIndex||0):b})}else if(z&&f.key==="0"){f.preventDefault();const j=!Mt.isRest;Rt(w=>({...w,isRest:j})),x.length>0&&kt((w,b)=>{if(!w.parts[b.partIndex])return w;const B=ee(w,b);if(!B)return w;const N=B.withRest(j);return w.replaceNote(b.partIndex,b.staffIndex,b.measureIndex,b.noteIndex,N,b.voiceIndex||0)})}else if(z&&f.key===".")f.preventDefault(),yi(!Mt.isDotted);else if(z&&f.key==="j")f.preventDefault(),x.length>0&&kt((j,w)=>Vt(j,w,b=>b.toggleEnharmonic()));else if(f.key==="ArrowUp"){if(!z)return;f.preventDefault();const j=f.shiftKey,w=f.ctrlKey||f.metaKey;if(kt((b,C)=>{var V;const B=ee(b,C);if(!B)return b;const N=(V=b.parts[C.partIndex])==null?void 0:V.staves[C.staffIndex];if(!N)return b;if(N.clef===ft.Tab){const X=w?12:1,J=B.fret??0,at=Math.max(0,J+X);return b.replaceNote(C.partIndex,C.staffIndex,C.measureIndex,C.noteIndex,B.withTab(at,B.string??1),C.voiceIndex||0)}let F;return w?F=B.transposeOctave(1):j?F=B.transpose(1):F=B.transposeDiatonic(1),b.replaceNote(C.partIndex,C.staffIndex,C.measureIndex,C.noteIndex,F,C.voiceIndex||0)}),m&&x.length>0){const b=x[x.length-1],C=ee(t,b);if(C!=null&&C.pitch){let B;w?B=C.transposeOctave(1).pitch:j?B=C.transpose(1).pitch:B=C.transposeDiatonic(1).pitch,B&&m.playPitch(B)}}}else if(f.key==="ArrowDown"){if(!z)return;f.preventDefault();const j=f.shiftKey,w=f.ctrlKey||f.metaKey;if(kt((b,C)=>{var V;const B=ee(b,C);if(!B)return b;const N=(V=b.parts[C.partIndex])==null?void 0:V.staves[C.staffIndex];if(!N)return b;if(N.clef===ft.Tab){const X=w?12:1,J=B.fret??0,at=Math.max(0,J-X);return b.replaceNote(C.partIndex,C.staffIndex,C.measureIndex,C.noteIndex,B.withTab(at,B.string??1),C.voiceIndex||0)}let F;return w?F=B.transposeOctave(-1):j?F=B.transpose(-1):F=B.transposeDiatonic(-1),b.replaceNote(C.partIndex,C.staffIndex,C.measureIndex,C.noteIndex,F,C.voiceIndex||0)}),m&&x.length>0){const b=x[x.length-1],C=ee(t,b);if(C!=null&&C.pitch){let B;w?B=C.transposeOctave(-1).pitch:j?B=C.transpose(-1).pitch:B=C.transposeDiatonic(-1).pitch,B&&m.playPitch(B)}}}else if(f.key==="ArrowRight"){if(!z||x.length!==1)return;f.preventDefault();const j=x[0],b=t.parts[j.partIndex].staves[j.staffIndex],C=b.measures[j.measureIndex],B=j.voiceIndex||0,N=C.voices[B]||[];j.noteIndex<N.length-1?W([{...j,noteIndex:j.noteIndex+1}]):j.measureIndex<b.measures.length-1&&W([{...j,measureIndex:j.measureIndex+1,noteIndex:0}])}else if(f.key==="ArrowLeft"){if(!z||x.length!==1)return;f.preventDefault();const j=x[0];if(j.noteIndex>0)W([{...j,noteIndex:j.noteIndex-1}]);else if(j.measureIndex>0){const w=t.parts[j.partIndex].staves[j.staffIndex].measures[j.measureIndex-1],b=j.voiceIndex||0,C=w.voices[b]||[];W([{...j,measureIndex:j.measureIndex-1,noteIndex:Math.max(0,C.length-1)}])}}else if(/^[a-gA-G]$/.test(f.key)){if(!z)return;f.preventDefault();const j=f.key.toUpperCase();if(kt((w,b)=>{const C=ee(w,b);if(!C)return w;const B=b.voiceIndex||0,N=!C.isRest&&C.pitch?C.pitch.getOctave():4,F=le.fromNoteName(j,N);m==null||m.playPitch(F,500);const V=C.withPitch(F);return w.replaceNote(b.partIndex,b.staffIndex,b.measureIndex,b.noteIndex,V,B)}),x.length===1){const w=x[0],b=t.parts[w.partIndex];if(b){const C=b.staves[w.staffIndex];if(C){const B=C.measures[w.measureIndex];if(B){const N=w.voiceIndex||0,F=B.voices[N]||[];w.noteIndex<F.length-1?W([{...w,noteIndex:w.noteIndex+1}]):w.measureIndex<C.measures.length-1&&W([{...w,measureIndex:w.measureIndex+1,noteIndex:0}])}}}}}else if(f.key==="+"||f.key==="="||f.key==="]"){if(!z)return;f.preventDefault(),kt((j,w)=>{const b=ee(j,w);if(!b)return j;const C=w.voiceIndex||0,B=[P.TwoHundredFiftySixth,P.OneHundredTwentyEighth,P.SixtyFourth,P.ThirtySecond,P.Sixteenth,P.Eighth,P.Quarter,P.Half,P.Whole],N=B.indexOf(b.duration);return N<B.length-1?j.changeNoteDuration(w.partIndex,w.staffIndex,w.measureIndex,w.noteIndex,B[N+1],b.isDotted,C):j})}else if(f.key==="-"||f.key==="["){if(!z)return;f.preventDefault(),kt((j,w)=>{const b=ee(j,w);if(!b)return j;const C=w.voiceIndex||0,B=[P.TwoHundredFiftySixth,P.OneHundredTwentyEighth,P.SixtyFourth,P.ThirtySecond,P.Sixteenth,P.Eighth,P.Quarter,P.Half,P.Whole],N=B.indexOf(b.duration);return N>0?j.changeNoteDuration(w.partIndex,w.staffIndex,w.measureIndex,w.noteIndex,B[N-1],b.isDotted,C):j})}else if(f.shiftKey&&f.code==="Digit3"){if(!z||x.length===0)return;f.preventDefault();const j=[...x].sort((B,N)=>B.partIndex!==N.partIndex?B.partIndex-N.partIndex:B.staffIndex!==N.staffIndex?B.staffIndex-N.staffIndex:B.measureIndex!==N.measureIndex?B.measureIndex-N.measureIndex:B.noteIndex-N.noteIndex),w=j[0],b=ee(t,w),C=!!(b!=null&&b.tuplet);kt((B,N)=>{const F=j.findIndex(nt=>nt.partIndex===N.partIndex&&nt.staffIndex===N.staffIndex&&nt.measureIndex===N.measureIndex&&nt.noteIndex===N.noteIndex&&nt.voiceIndex===N.voiceIndex);let V="middle";F===0&&(V="start"),F===j.length-1&&(V="stop"),j.length===1&&(V="start");const X=ee(B,N);if(!X)return B;const J=N.voiceIndex||0,at=C?X.withTuplet(void 0):X.withTuplet({actual:3,normal:2,type:V});return B.replaceNote(N.partIndex,N.staffIndex,N.measureIndex,N.noteIndex,at,J)})}else f.key==="l"&&x.length===1&&!us?(f.preventDefault(),fs(!0)):f.key===" "&&(f.preventDefault(),k?p==null||p():d==null||d())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[x,t,h,z,k,d,p,m]);const Pc=v=>{const f=new le(v);m==null||m.playPitch(f),z&&x.length>0&&kt((T,D)=>{const j=ee(T,D);if(!j)return T;const w=T.getKeySignatureAt(D.measureIndex);let b;f.alter===1?b=At.Sharp:f.alter===-1?b=At.Flat:f.alter===2?b=At.DoubleSharp:f.alter===-2&&(b=At.DoubleFlat);const C=f.step,B=w.fifths;let N=0;B>0?[3,0,4,1,5,2,6].slice(0,B).includes(C)&&(N=1):B<0&&[6,2,5,1,4,0,3].slice(0,-B).includes(C)&&(N=-1),f.alter===N?b=void 0:f.alter===0&&N!==0&&(b=At.Natural);const F=D.voiceIndex||0,V=j.isRest?new wt(j.duration,f,!1,j.isDotted,b):j.withPitch(f).withAccidental(b);return T.replaceNote(D.partIndex,D.staffIndex,D.measureIndex,D.noteIndex,V,F)})},Mc=K.useMemo(()=>{const v=[];return x.forEach(f=>{const T=ee(t,f);T&&!T.isRest&&T.pitch&&v.push(T.pitch.midiNumber)}),v},[x,t]),Ac=()=>{jc(v=>!v)};return o.jsxs(u.Box,{sx:{flex:1,display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",bgcolor:"background.default"},children:[o.jsx(u.Box,{sx:{width:"100%",position:"sticky",top:0,zIndex:1100,bgcolor:"background.paper",display:"flex",flexDirection:"column",alignItems:"stretch",boxShadow:"0 10px 15px -3px rgb(0 0 0 / 0.07), 0 4px 6px -4px rgb(0 0 0 / 0.05)"},children:o.jsx(u.Box,{sx:{width:"100%",display:"flex",flexDirection:"column",alignItems:"stretch"},children:o.jsx(Vl,{selectedDuration:Mt.duration,onDurationChange:v=>{Rt(f=>({...f,duration:v})),x.length>0&&h&&kt((f,T)=>f.changeNoteDuration(T.partIndex,T.staffIndex,T.measureIndex,T.noteIndex,v,!1))},isRestMode:Mt.isRest,onRestModeChange:v=>{Rt(f=>({...f,isRest:v})),x.length>0&&h&&kt((f,T)=>Vt(f,T,D=>D.withRest(v)))},selectedAccidental:Mt.accidental,onAccidentalChange:gi,selectedArticulation:Mt.articulation,onArticulationChange:$s,selectedDynamic:Mt.dynamic,onDynamicChange:mi,isTied:Mt.tie,onTieChange:ne,isSlurred:Mt.isSlurred,onSlurChange:xi,isDotted:Mt.isDotted,onDottedChange:yi,selectedOrnament:Mt.ornament,onOrnamentChange:gs,selectedHairpin:Mt.hairpin,onHairpinChange:je,selectedGlissando:Mt.glissando,onGlissandoChange:ms,selectedArpeggio:Mt.arpeggio,onArpeggioChange:vi,selectedOttava:Mt.ottava,onOttavaChange:bi,selectedPedal:Mt.pedal,onPedalChange:sn,isGrace:Mt.isGrace,onGraceChange:v=>{Rt(f=>({...f,isGrace:v})),x.length>0&&kt((f,T)=>Vt(f,T,D=>D.withGrace(v)))},onPageSetup:y,onScoreLayout:S,onLoadSATBTemplate:I,onDownloadMusicXML:M,onDownloadPDF:q,onSave:ot,canSave:U,onScoreInfo:()=>yt(!0),userTier:g,onUpgrade:$,onToggleEnharmonic:()=>{x.length>0&&h&&kt((v,f)=>Vt(v,f,T=>T.toggleEnharmonic()))},onAddKeySignature:()=>{Bs(!0)},onAddTimeSignature:()=>{ls(!0)},onAddClef:()=>{Se(!0)},onAddTempo:()=>{Re(!0)},onAddVolta:v=>{x.length>0&&h&&kt((f,T)=>{var b;const D=f.parts[T.partIndex].staves[T.staffIndex].measures[T.measureIndex],j=((b=D.volta)==null?void 0:b.number)===v?void 0:{number:v,type:"start"},w=D.withVolta(j);return f.replaceMeasure(T.partIndex,T.staffIndex,T.measureIndex,w)},!0)},onAddRepeat:v=>{x.length>0&&h&&kt((f,T)=>{const j=f.parts[T.partIndex].staves[T.staffIndex].measures[T.measureIndex].withRepeat({type:v});return f.replaceMeasure(T.partIndex,T.staffIndex,T.measureIndex,j)},!0)},onTupletChange:(v,f)=>{if(x.length>0&&h){const T=[...x].sort((j,w)=>j.partIndex!==w.partIndex?j.partIndex-w.partIndex:j.staffIndex!==w.staffIndex?j.staffIndex-w.staffIndex:j.measureIndex-w.measureIndex||j.noteIndex-w.noteIndex),D=x.some(j=>{const w=ee(t,j);return(w==null?void 0:w.tuplet)!==void 0});kt((j,w)=>{const b=T.findIndex(V=>V.partIndex===w.partIndex&&V.staffIndex===w.staffIndex&&V.measureIndex===w.measureIndex&&V.noteIndex===w.noteIndex&&V.voiceIndex===w.voiceIndex);let C="middle";b===0&&(C="start"),b===T.length-1&&(C="stop"),T.length===1&&(C="start");const B=ee(j,w);if(!B)return j;const N=w.voiceIndex||0,F=D?B.withTuplet(void 0):B.withTuplet({actual:v,normal:f,type:C});return j.replaceNote(w.partIndex,w.staffIndex,w.measureIndex,w.noteIndex,F,N)},!0)}},onBeamingChange:v=>{if(x.length>0&&h){const f=v==="join"?Math.floor(Math.random()*1e6):void 0;kt((T,D)=>{const j=ee(T,D);if(!j)return T;const w=D.voiceIndex||0;return j.isBeamable()||v==="break"?T.replaceNote(D.partIndex,D.staffIndex,D.measureIndex,D.noteIndex,j.withBeamGroup(f),w):T},!0)}},onAddChordSymbol:()=>{x.length>0&&Pr(!0)},onAddMeasureBefore:()=>{if(x.length===0||!h)return;const v=x[0],D=t.parts[v.partIndex].staves[v.staffIndex].measures[v.measureIndex],j=new _t([[new wt(P.Whole,void 0,!0)]],D.timeSignature,D.keySignature);h(t.addMeasure(v.measureIndex,j))},onAddMeasureAfter:()=>{if(x.length===0||!h)return;const v=x[0],D=t.parts[v.partIndex].staves[v.staffIndex].measures[v.measureIndex],j=new _t([[new wt(P.Whole,void 0,!0)]],D.timeSignature,D.keySignature);h(t.addMeasure(v.measureIndex+1,j))},onRemoveMeasure:()=>{if(x.length===0||!h)return;const v=x[0];h(t.deleteMeasure(v.measureIndex)),W([])},isPickup:Mt.isPickup,onPickupChange:v=>{Rt(f=>({...f,isPickup:v})),x.length>0&&kt((f,T)=>{const D=f.parts[T.partIndex].staves[T.staffIndex].measures[T.measureIndex];return f.replaceMeasure(T.partIndex,T.staffIndex,T.measureIndex,D.withPickup(v))},!0)},isSystemBreak:Ms,onSystemBreakChange:v=>{x.length>0&&kt((f,T)=>{const D=f.parts[T.partIndex].staves[T.staffIndex].measures[T.measureIndex];return f.replaceMeasure(T.partIndex,T.staffIndex,T.measureIndex,D.withSystemBreak(v))},!0)},isPageBreak:Zi,onPageBreakChange:v=>{x.length>0&&kt((f,T)=>{const D=f.parts[T.partIndex].staves[T.staffIndex].measures[T.measureIndex];return f.replaceMeasure(T.partIndex,T.staffIndex,T.measureIndex,D.withPageBreak(v))},!0)},selectedFret:Mt.fret,onFretChange:Rs,selectedString:Mt.string,onStringChange:ge,activeVoice:fi,onVoiceChange:xc,onApplyInfill:mt,aiSuggestionAvailable:!!Q&&x.length>0,selectedColor:Mt.color,onColorChange:nn,selectedNotehead:Mt.notehead,onNoteheadChange:rn,selectedBowing:Mt.bowing,onBowingChange:on,selectedFingering:Mt.fingering,onFingeringChange:et,onAddRehearsalMark:()=>{x.length>0&&h&&kt((v,f)=>{const D=v.parts[f.partIndex].staves[f.staffIndex].measures[f.measureIndex].withRehearsalMark("A");return v.replaceMeasure(f.partIndex,f.staffIndex,f.measureIndex,D)},!0)},onAddSystemText:()=>{x.length>0&&h&&_({open:!0,title:"Add System Text",label:"Text",onSave:v=>{kt((f,T)=>{const j=f.parts[T.partIndex].staves[T.staffIndex].measures[T.measureIndex].withSystemText(v);return f.replaceMeasure(T.partIndex,T.staffIndex,T.measureIndex,j)},!0),_(f=>({...f,open:!1}))}})},onAddStaffText:()=>{x.length>0&&h&&_({open:!0,title:"Add Staff Text",label:"Text",onSave:v=>{v&&Kt(f=>f.withStaffText(v)),_(f=>({...f,open:!1}))}})},onPlay:d,onStop:()=>{p==null||p(),Ve.stop(),Ti(!1)},isPlaying:k||Jt,isMetronome:R,onToggleMetronome:O,isSwing:t.swing,onToggleSwing:()=>h==null?void 0:h(t.withSwing(!t.swing)),showKeyboard:an,onToggleKeyboard:Ac,onTranspose:l,onInstruments:c,onResetZoom:n,onOpenFile:r,onImportPDF:a,isEditMode:z,onGenerateVocalGuide:mc})})}),o.jsxs(u.Box,{sx:{flex:1,overflow:"auto",display:"flex",flexDirection:"column",alignItems:"center",pb:an?"140px":0,position:"relative"},children:[o.jsxs(u.Paper,{elevation:0,sx:{my:4,p:6,borderRadius:4,maxWidth:"96%",width:"fit-content",border:"2px solid",borderColor:z?"primary.main":"divider",boxShadow:z?"0 0 20px rgba(37, 99, 235, 0.1), 0 4px 6px -1px rgb(0 0 0 / 0.1)":"0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",position:"relative",transition:"all 0.2s ease-in-out"},children:[o.jsxs(u.Box,{component:"a",href:bt,target:"_blank",rel:"noopener noreferrer",sx:{position:"absolute",top:10,right:20,display:"flex",alignItems:"center",gap:.5,textDecoration:"none",color:"text.secondary",cursor:"pointer",opacity:.6,zIndex:10,transition:"all 0.2s ease","&:hover":{opacity:1,color:"primary.main"}},children:[o.jsx(nc,{sx:{fontSize:16}}),o.jsx(u.Typography,{variant:"caption",sx:{fontWeight:600,fontSize:"0.65rem"},children:ct})]}),o.jsxs("div",{style:{position:"relative"},children:[o.jsx("canvas",{ref:ht,onMouseDown:Sc,onMouseMove:wc,onMouseUp:Ic,onMouseLeave:()=>{Ct(null),Wt(null),Ut(null)},style:{display:"block",borderRadius:8,cursor:"pointer"}}),o.jsx("canvas",{ref:kr,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}})]}),us&&be&&o.jsx("textarea",{autoFocus:!0,value:Ns,onChange:v=>{ps(v.target.value),Dc(v.target.value)},onKeyDown:v=>{var f,T;if(v.stopPropagation(),v.key==="Escape")v.preventDefault(),fs(!1),(f=ht.current)==null||f.focus();else if(v.key==="Enter"&&v.shiftKey||v.key==="Tab"||v.key===" "){v.preventDefault();const D=x[0],w=t.parts[D.partIndex].staves[D.staffIndex],b=w.measures[D.measureIndex];D.noteIndex<b.notes.length-1?W([{...D,noteIndex:D.noteIndex+1}]):D.measureIndex<w.measures.length-1?W([{...D,measureIndex:D.measureIndex+1,noteIndex:0}]):(fs(!1),(T=ht.current)==null||T.focus())}},style:{position:"absolute",top:be.y,left:be.x,transform:"translate(-50%, 0)",width:`${Math.max(60,Ns.split(`
98
+ `).reduce((v,f)=>Math.max(v,f.length),0)*(E.staffLineSpacing*e*.6)+20)}px`,height:`${(Ns.split(`
99
+ `).length*1.5+1)*E.staffLineSpacing*e}px`,fontSize:`${E.staffLineSpacing*e*1.05}px`,fontFamily:E.musicFont==="Jazz"?'"Patrick Hand", cursive':"serif",fontWeight:"bold",textAlign:"center",background:"rgba(255, 255, 255, 0.9)",border:"1px solid #33a854",borderRadius:"4px",outline:"none",resize:"none",overflow:"hidden",zIndex:1e3}})]}),gt.pages.length>1&&o.jsx(u.Box,{sx:{mb:4,mt:2,display:"flex",justifyContent:"center",width:"100%"},children:o.jsxs(u.Paper,{elevation:0,sx:{p:1,px:2,borderRadius:"12px",border:"1px solid",borderColor:"divider",bgcolor:"rgba(255,255,255,0.8)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",gap:2},children:[o.jsxs(u.Typography,{variant:"caption",sx:{fontWeight:700,color:"text.secondary",ml:1,mr:2},children:["PAGE ",G+1," OF ",gt.pages.length]}),o.jsx(u.IconButton,{size:"small",onClick:()=>lt(v=>Math.max(0,v-1)),disabled:G===0,sx:{bgcolor:"rgba(0,0,0,0.03)"},children:o.jsx(te.NavigateBefore,{fontSize:"small"})}),o.jsx(u.IconButton,{size:"small",onClick:()=>lt(v=>Math.min(gt.pages.length-1,v+1)),disabled:G>=gt.pages.length-1,sx:{bgcolor:"rgba(0,0,0,0.03)"},children:o.jsx(te.NavigateNext,{fontSize:"small"})})]})}),Z&&o.jsx(Zl,{open:Z,onClose:()=>yt(!1),title:t.title,subtitle:t.subtitle,composer:t.composer,lyricist:t.lyricist,copyright:t.copyright,onSave:({title:v,subtitle:f,composer:T,lyricist:D,copyright:j})=>{const w=t.withTitle(v).withSubtitle(f).withComposer(T).withLyricist(D).withCopyright(j);h==null||h(w),dt&&v!==t.title&&dt(v),st&&T!==t.composer&&st(T),yt(!1)}}),o.jsx(Hl,{open:Ne,onClose:()=>Re(!1),currentBpm:t.bpm,currentDuration:t.tempoDuration||P.Quarter,currentIsDotted:t.tempoIsDotted||!1,onSave:(v,f,T)=>{h&&(x.length>0?kt((D,j)=>{const b=D.parts[j.partIndex].staves[j.staffIndex].measures[j.measureIndex].withTempo({bpm:v,duration:f,isDotted:T});return D.replaceMeasure(j.partIndex,j.staffIndex,j.measureIndex,b)},!0):h(t.withTempo(v,f,T)))}}),o.jsx(Ql,{open:Xi,onClose:()=>Bs(!1),currentKeySignature:hi,onSave:v=>{x.length>0&&h&&kt((f,T)=>{const j=f.parts[T.partIndex].staves[T.staffIndex].measures[T.measureIndex].withKeySignature(v);return f.replaceMeasure(T.partIndex,T.staffIndex,T.measureIndex,j)},!0)}}),o.jsx(Ul,{open:$e,onClose:()=>ls(!1),currentTimeSignature:Ps,onSave:v=>{x.length>0&&h&&kt((f,T)=>{const j=f.parts[T.partIndex].staves[T.staffIndex].measures[T.measureIndex].withTimeSignature(v);return f.replaceMeasure(T.partIndex,T.staffIndex,T.measureIndex,j)},!0)}}),o.jsx(Xl,{open:Ds,onClose:()=>Se(!1),currentClef:Ji,onSave:v=>{x.length>0&&h&&kt((f,T)=>{const j=f.parts[T.partIndex].staves[T.staffIndex].measures[T.measureIndex].withClef(v);return f.replaceMeasure(T.partIndex,T.staffIndex,T.measureIndex,j)},!0)}})]}),an&&o.jsx(u.Box,{sx:{position:"fixed",bottom:0,left:0,right:0,borderTop:"1px solid",borderColor:"divider",bgcolor:"background.paper",boxShadow:"0 -4px 20px rgba(0,0,0,0.15)",zIndex:2e3},children:o.jsx(tc,{activeNotes:Mc,playedNotes:Ec,onNoteClick:Pc})}),o.jsx(sc,{open:Bc,onClose:()=>Pr(!1),currentChord:x.length>0?(Mr=ac(t,x[0]))==null?void 0:Mr.chord:void 0,onSave:v=>{x.length>0&&kt((f,T)=>Vt(f,T,D=>D.withChord(v)))}}),o.jsx(ec,{open:It.open,onClose:()=>_(v=>({...v,open:!1})),onSave:It.onSave,title:It.title,label:It.label,defaultValue:It.defaultValue}),o.jsxs(u.Backdrop,{sx:{color:"primary.main",zIndex:3e3,flexDirection:"column",gap:2,backgroundColor:"rgba(255, 255, 255, 0.8)",backdropFilter:"blur(4px)"},open:en,children:[o.jsx(u.CircularProgress,{color:"inherit",size:60,thickness:4}),o.jsx(u.Typography,{variant:"h6",sx:{color:"primary.dark",fontWeight:800},children:"AI Harmonization in progress..."}),o.jsx(u.Typography,{variant:"body2",sx:{color:"text.secondary",fontWeight:500},children:"Our creative partner is generating your perfect harmony."})]}),o.jsxs(u.Backdrop,{sx:{color:"primary.main",zIndex:4e3,flexDirection:"column",gap:2,backgroundColor:"rgba(255, 255, 255, 0.95)",backdropFilter:"blur(8px)"},open:L,children:[o.jsx(u.CircularProgress,{color:"inherit",size:60,thickness:4}),o.jsx(u.Typography,{variant:"h5",sx:{color:"primary.dark",fontWeight:800},children:"Loading Score"}),o.jsx(u.Typography,{variant:"body1",sx:{color:"text.secondary",fontWeight:500},children:"Please wait while we prepare your music..."})]})]})}function ee(t,e){const s=t.parts[e.partIndex];if(!s)return null;const i=s.staves[e.staffIndex];if(!i)return null;const n=i.measures[e.measureIndex];if(!n)return null;const r=e.voiceIndex||0,a=n.voices[r];return a&&a[e.noteIndex]||null}function Vt(t,e,s){const i=t.parts[e.partIndex];if(!i)return t;const n=i.staves[e.staffIndex];if(!n)return t;const r=n.measures[e.measureIndex];if(!r)return t;const a=e.voiceIndex||0,l=r.voices[a];if(!l)return t;const c=l[e.noteIndex];return c?t.replaceNote(e.partIndex,e.staffIndex,e.measureIndex,e.noteIndex,s(c),a):t}function oc(t,e){const s=t.parts[e.partIndex];if(!s)return null;const i=s.staves[e.staffIndex];if(!i)return null;const n=i.measures[e.measureIndex];if(n&&e.noteIndex<n.notes.length-1)return{...e,noteIndex:e.noteIndex+1};for(let r=e.measureIndex+1;r<i.measures.length;r++)if(i.measures[r].notes.length>0)return{partIndex:e.partIndex,staffIndex:e.staffIndex,measureIndex:r,noteIndex:0};return null}function ac(t,e){const s=t.parts[e.partIndex];if(!s)return null;const i=s.staves[e.staffIndex];if(!i)return null;const n=i.measures[e.measureIndex];if(!n)return null;const r=n.voices[e.voiceIndex||0];return r&&r[e.noteIndex]||null}class ce{constructor(e,s,i=5,n){this.clef=e,this.measures=s,this.lineCount=i,this.tuning=n}getMeasureCount(){return this.measures.length}static fromJSON(e){var n;const s=e.measures.map(r=>_t.fromJSON(r)),i=(n=e.tuning)==null?void 0:n.map(r=>new le(r.midiNumber));return new ce(e.clef,s,e.lineCount??5,i)}transpose(e){var s;return new ce(this.clef,this.measures.map(i=>i.transpose(e)),this.lineCount,(s=this.tuning)==null?void 0:s.map(i=>new le(i.midiNumber+e)))}replaceNote(e,s,i,n=0){if(e<0||e>=this.measures.length)return this;const r=[...this.measures];return r[e]=r[e].replaceNote(s,i,n),new ce(this.clef,r,this.lineCount,this.tuning)}replaceMeasure(e,s){if(e<0||e>=this.measures.length)return this;const i=[...this.measures];return i[e]=s,new ce(this.clef,i,this.lineCount,this.tuning)}deleteNote(e,s,i=0){if(e<0||e>=this.measures.length)return this;const n=[...this.measures];return n[e]=n[e].deleteNote(s,i),new ce(this.clef,n,this.lineCount,this.tuning)}changeNoteDuration(e,s,i,n=!1,r=0){if(e<0||e>=this.measures.length)return this;const a=[...this.measures];return a[e]=a[e].changeNoteDuration(s,i,n,r),new ce(this.clef,a,this.lineCount,this.tuning)}toJSON(){var e;return{clef:this.clef,measures:this.measures.map(s=>s.toJSON()),lineCount:this.lineCount,tuning:(e=this.tuning)==null?void 0:e.map(s=>({midiNumber:s.midiNumber}))}}withClef(e){return new ce(e,this.measures,this.lineCount,this.tuning)}withLineCount(e){return new ce(this.clef,this.measures,e,this.tuning)}withTuning(e){return new ce(this.clef,this.measures,this.lineCount,e)}withMeasures(e){return new ce(this.clef,e,this.lineCount,this.tuning)}addMeasure(e,s){const i=[...this.measures],n=Math.min(Math.max(0,e),i.length);return i.splice(n,0,s),new ce(this.clef,i,this.lineCount,this.tuning)}deleteMeasure(e){if(e<0||e>=this.measures.length)return this;const s=[...this.measures];return s.splice(e,1),new ce(this.clef,s,this.lineCount,this.tuning)}}const as={piano:{name:"Acoustic Grand Piano",midiProgram:0,type:"keyboard"},violin:{name:"Violin",midiProgram:40,type:"string"},cello:{name:"Cello",midiProgram:42,type:"string"},guitar:{name:"Acoustic Guitar (nylon)",midiProgram:24,type:"string"},"electric-guitar":{name:"Electric Guitar (clean)",midiProgram:27,type:"string"},bass:{name:"Acoustic Bass",midiProgram:32,type:"string"},flute:{name:"Flute",midiProgram:73,type:"woodwind"},trumpet:{name:"Trumpet",midiProgram:56,type:"brass"},drums:{name:"Drum Kit",midiProgram:118,type:"percussion"}};function lc(t){return Object.values(as).find(s=>s.midiProgram===t)||as.piano}class he{constructor(e,s,i=e.substring(0,Math.min(e.length,3))+".",n=as.piano){this.name=e,this.staves=s,this.abbreviation=i,this.instrument=n}isMultiStaff(){return this.staves.length>1}getMeasureCount(){var e;return((e=this.staves[0])==null?void 0:e.getMeasureCount())??0}static fromJSON(e){const s=e.staves.map(n=>ce.fromJSON(n)),i=e.instrument||as.piano;return new he(e.name,s,e.abbreviation,i)}transpose(e){return new he(this.name,this.staves.map(s=>s.transpose(e)),this.abbreviation,this.instrument)}replaceNote(e,s,i,n,r=0){if(e<0||e>=this.staves.length)return this;const a=[...this.staves];return a[e]=a[e].replaceNote(s,i,n,r),new he(this.name,a,this.abbreviation,this.instrument)}replaceMeasure(e,s,i){if(e<0||e>=this.staves.length)return this;const n=[...this.staves];return n[e]=n[e].replaceMeasure(s,i),new he(this.name,n,this.abbreviation,this.instrument)}deleteNote(e,s,i,n=0){if(e<0||e>=this.staves.length)return this;const r=[...this.staves];return r[e]=r[e].deleteNote(s,i,n),new he(this.name,r,this.abbreviation,this.instrument)}changeNoteDuration(e,s,i,n,r=!1,a=0){if(e<0||e>=this.staves.length)return this;const l=[...this.staves];return l[e]=l[e].changeNoteDuration(s,i,n,r,a),new he(this.name,l,this.abbreviation,this.instrument)}toJSON(){return{name:this.name,staves:this.staves.map(e=>e.toJSON()),abbreviation:this.abbreviation,instrument:this.instrument}}withInstrument(e){return new he(this.name,this.staves,this.abbreviation,e)}replaceStaff(e,s){if(e<0||e>=this.staves.length)return this;const i=[...this.staves];return i[e]=s,new he(this.name,i,this.abbreviation,this.instrument)}withStaves(e){return new he(this.name,e,this.abbreviation,this.instrument)}addMeasure(e,s){return new he(this.name,this.staves.map(i=>i.addMeasure(e,s)),this.abbreviation,this.instrument)}deleteMeasure(e){return new he(this.name,this.staves.map(s=>s.deleteMeasure(e)),this.abbreviation,this.instrument)}}class Qt{constructor(e,s,i,n,r,a=120,l=P.Quarter,c=!1,h="",d="",p=!1,y=""){this.title=e,this.composer=s,this.timeSignature=i,this.keySignature=n,this.parts=r,this.bpm=a,this.tempoDuration=l,this.tempoIsDotted=c,this.copyright=h,this.lyricist=d,this.swing=p,this.subtitle=y}withTitle(e){return new Qt(e,this.composer,this.timeSignature,this.keySignature,this.parts,this.bpm,this.tempoDuration,this.tempoIsDotted,this.copyright,this.lyricist,this.swing,this.subtitle)}withComposer(e){return new Qt(this.title,e,this.timeSignature,this.keySignature,this.parts,this.bpm,this.tempoDuration,this.tempoIsDotted,this.copyright,this.lyricist,this.swing,this.subtitle)}withSubtitle(e){return new Qt(this.title,this.composer,this.timeSignature,this.keySignature,this.parts,this.bpm,this.tempoDuration,this.tempoIsDotted,this.copyright,this.lyricist,this.swing,e)}getMeasureCount(){var e;return((e=this.parts[0])==null?void 0:e.getMeasureCount())??0}getTimeSignatureAt(e){let s=this.timeSignature;const i=this.parts[0];if(i&&i.staves[0]){const n=i.staves[0].measures;for(let r=0;r<=e&&r<n.length;r++)n[r].timeSignature&&(s=n[r].timeSignature)}return s}getKeySignatureAt(e){let s=this.keySignature;const i=this.parts[0];if(i&&i.staves[0]){const n=i.staves[0].measures;for(let r=0;r<=e&&r<n.length;r++)n[r].keySignature&&(s=n[r].keySignature)}return s}getAllStaves(){const e=[];return this.parts.forEach((s,i)=>{s.staves.forEach((n,r)=>{e.push({partIndex:i,staffIndex:r,staff:n})})}),e}static empty(){return new Qt("","",{beats:4,beatType:4},{fifths:0},[])}static fromJSON(e){const s=e.parts.map(i=>he.fromJSON(i));return new Qt(e.title,e.composer,e.timeSignature,e.keySignature,s,e.bpm??120,e.tempoDuration??P.Quarter,e.tempoIsDotted??!1,e.copyright??"",e.lyricist??"",e.swing??!1,e.subtitle??"")}static fromMusicXML(e){const{MusicXMLParser:s}=require("../importers/MusicXMLParser"),n=new s().parse(e);return Qt.fromJSON(n)}transpose(e){const s={0:0,1:7,2:2,3:-3,4:4,5:-1,6:6,7:1,8:-4,9:3,10:-2,11:5},i=(e%12+12)%12,n=s[i];let r=this.keySignature.fifths+n;for(;r>7;)r-=12;for(;r<-7;)r+=12;const a={fifths:r};return new Qt(this.title,this.composer,this.timeSignature,a,this.parts.map(l=>l.transpose(e)),this.bpm,this.tempoDuration,this.tempoIsDotted,this.copyright,this.lyricist,this.swing,this.subtitle)}replaceNote(e,s,i,n,r,a=0){if(e<0||e>=this.parts.length)return this;const c=this.parts[e].staves[s].measures[i].replaceNote(n,r,a);return this.replaceMeasure(e,s,i,c,!0)}replaceMeasure(e,s,i,n,r=!0){if(e<0||e>=this.parts.length)return this;let a=n;if(r){const c=this.getTimeSignatureAt(i);a=n.autoBeam(c)}const l=[...this.parts];return l[e]=l[e].replaceMeasure(s,i,a),new Qt(this.title,this.composer,this.timeSignature,this.keySignature,l,this.bpm,this.tempoDuration,this.tempoIsDotted,this.copyright,this.lyricist,this.swing,this.subtitle)}deleteNote(e,s,i,n,r=0){if(e<0||e>=this.parts.length)return this;const l=this.parts[e].staves[s].measures[i].deleteNote(n,r);return this.replaceMeasure(e,s,i,l,!0)}changeNoteDuration(e,s,i,n,r,a=!1,l=0){if(e<0||e>=this.parts.length)return this;const h=this.parts[e].staves[s].measures[i].changeNoteDuration(n,r,a,l);return this.replaceMeasure(e,s,i,h,!0)}pasteNotes(e,s,i,n,r){if(e<0||e>=this.parts.length)return this;let a=this,l=i,c=n;const h=[...r];for(;h.length>0;){const d=h.shift(),p=a.parts[e];if(!p)break;const y=p.staves[s];if(!y||l>=y.measures.length)break;const S=y.measures[l];if(c>=S.notes.length){l++,c=0,h.unshift(d);continue}let I=0;for(let k=c;k<S.notes.length;k++)I+=S.notes[k].getDurationValue();const m=d.getDurationValue();if(m<=I+.001)a=a.changeNoteDuration(e,s,l,c,d.duration,d.isDotted),a=a.replaceNote(e,s,l,c,d),c++;else{const k=Ze(I);if(k.length===0){l++,c=0,h.unshift(d);continue}const E=k[0],Y=d.withDuration(E.duration,E.isDotted).withTie(!0);a=a.changeNoteDuration(e,s,l,c,E.duration,E.isDotted),a=a.replaceNote(e,s,l,c,Y);const R=m-E.val,O=Ze(R),M=O.map((q,it)=>{const U=it===O.length-1?d.tie:!0;return d.withDuration(q.duration,q.isDotted).withTie(U)});h.unshift(...M),c++}}return a}withTempo(e,s,i){return new Qt(this.title,this.composer,this.timeSignature,this.keySignature,this.parts,e,s,i,this.copyright,this.lyricist,this.swing,this.subtitle)}withSwing(e){return new Qt(this.title,this.composer,this.timeSignature,this.keySignature,this.parts,this.bpm,this.tempoDuration,this.tempoIsDotted,this.copyright,this.lyricist,e,this.subtitle)}withLyricist(e){return new Qt(this.title,this.composer,this.timeSignature,this.keySignature,this.parts,this.bpm,this.tempoDuration,this.tempoIsDotted,this.copyright,e,this.swing,this.subtitle)}withCopyright(e){return new Qt(this.title,this.composer,this.timeSignature,this.keySignature,this.parts,this.bpm,this.tempoDuration,this.tempoIsDotted,e,this.lyricist,this.swing,this.subtitle)}toJSON(){return{title:this.title,composer:this.composer,timeSignature:this.timeSignature,keySignature:this.keySignature,parts:this.parts.map(e=>e.toJSON()),bpm:this.bpm,tempoDuration:this.tempoDuration,tempoIsDotted:this.tempoIsDotted,copyright:this.copyright,lyricist:this.lyricist,swing:this.swing,subtitle:this.subtitle}}replacePart(e,s){if(e<0||e>=this.parts.length)return this;const i=[...this.parts];return i[e]=s,new Qt(this.title,this.composer,this.timeSignature,this.keySignature,i,this.bpm,this.tempoDuration,this.tempoIsDotted,this.copyright,this.lyricist,this.swing,this.subtitle)}addPart(e){return new Qt(this.title,this.composer,this.timeSignature,this.keySignature,[...this.parts,e],this.bpm,this.tempoDuration,this.tempoIsDotted,this.copyright,this.lyricist,this.swing,this.subtitle)}removePart(e){if(e<0||e>=this.parts.length)return this;const s=this.parts.filter((i,n)=>n!==e);return new Qt(this.title,this.composer,this.timeSignature,this.keySignature,s,this.bpm,this.tempoDuration,this.tempoIsDotted,this.copyright,this.lyricist,this.swing,this.subtitle)}replaceStaff(e,s,i){if(e<0||e>=this.parts.length)return this;const n=[...this.parts];return n[e]=n[e].replaceStaff(s,i),new Qt(this.title,this.composer,this.timeSignature,this.keySignature,n,this.bpm,this.tempoDuration,this.tempoIsDotted,this.copyright,this.lyricist,this.swing,this.subtitle)}addMeasure(e,s){return new Qt(this.title,this.composer,this.timeSignature,this.keySignature,this.parts.map(i=>i.addMeasure(e,s)),this.bpm,this.tempoDuration,this.tempoIsDotted,this.copyright,this.lyricist,this.swing,this.subtitle)}deleteMeasure(e){return new Qt(this.title,this.composer,this.timeSignature,this.keySignature,this.parts.map(s=>s.deleteMeasure(e)),this.bpm,this.tempoDuration,this.tempoIsDotted,this.copyright,this.lyricist,this.swing,this.subtitle)}getPlaybackSequence(){var a,l;const e=((l=(a=this.parts[0])==null?void 0:a.staves[0])==null?void 0:l.measures)||[],s=[];let i=0,n=0;const r=new Map;for(;i<e.length;){const c=e[i];c.repeats.some(p=>p.type==="start")&&(n=i);const h=c.repeats.find(p=>p.type==="end");let d=1;if(h)d=(r.get(i)||0)+1;else{let p=-1;for(let y=i;y<e.length;y++)if(e[y].repeats.some(S=>S.type==="end")){p=y;break}p!==-1&&(d=(r.get(p)||0)+1)}if(c.volta&&c.volta.number!==d){i++;continue}if(s.push(i),h){const p=h.times||2,y=r.get(i)||0;if(y+1<p){r.set(i,y+1),i=n;continue}else r.set(i,0)}i++}return s}}function cc(t,e,s=0){const n={C:0,D:2,E:4,F:5,G:7,A:9,B:11}[t.toUpperCase()]??0;return(e+1)*12+n+s}function hc(t){return{whole:P.Whole,half:P.Half,quarter:P.Quarter,eighth:P.Eighth,"16th":P.Sixteenth}[t]??P.Quarter}function uc(t){switch(t.toUpperCase()){case"G":return ft.Treble;case"F":return ft.Bass;default:return ft.Treble}}function fc(t){if(t===1)return At.Sharp;if(t===-1)return At.Flat}function Oe(t,e){const s=t.querySelector(e);return(s==null?void 0:s.textContent)??null}function Es(t,e){const s=Oe(t,e);return s!==null?parseFloat(s):null}class dc{constructor(){qt(this,"currentKeyFifths",0);qt(this,"currentBeats",4);qt(this,"currentBeatType",4)}parse(e){const i=new DOMParser().parseFromString(e,"application/xml"),n=i.querySelector("parsererror");if(n)throw new Error(`XML parsing error: ${n.textContent}`);const r=i.documentElement;if(r.tagName!=="score-partwise")throw new Error(`Unsupported MusicXML format: ${r.tagName}. Only score-partwise is supported.`);const a=this.parseTitle(i),l=this.parseComposer(i),c=this.parsePartList(i),h=this.parseParts(i,c),d={title:a,composer:l,timeSignature:{beats:this.currentBeats,beatType:this.currentBeatType},keySignature:{fifths:this.currentKeyFifths},parts:h};return this.postProcess(d)}parseTitle(e){let s=Oe(e.documentElement,"work-title");return s||(s=Oe(e.documentElement,"movement-title")),s??"Untitled"}parseComposer(e){const s=e.querySelectorAll("identification creator");for(const n of s)if(n.getAttribute("type")==="composer")return n.textContent??"Unknown";const i=e.querySelector("identification creator");return(i==null?void 0:i.textContent)??"Unknown"}parsePartList(e){const s=new Map,i=e.querySelectorAll("part-list score-part");for(const n of i){const r=n.getAttribute("id"),a=Oe(n,"part-name");r&&s.set(r,a??"Part")}return s}parseParts(e,s){const i=[],n=e.querySelectorAll("part");for(const r of n){const a=r.getAttribute("id"),l=s.get(a??"")??"Part",c=this.parsePart(r);i.push({name:l,staves:c})}return i}parsePart(e){const s=e.querySelectorAll("measure");let i=1;const n=e.querySelector("measure");if(n){const l=n.querySelector("attributes staves");l&&(i=parseInt(l.textContent||"1"))}const r=Array.from({length:i},()=>({clef:ft.Treble,measures:[]})),a=Array(i).fill(ft.Treble);for(const l of s){const c=l.querySelector("attributes");if(c){const p=Es(c,"key fifths");p!==null&&(this.currentKeyFifths=p);const y=Es(c,"time beats"),S=Es(c,"time beat-type");y!==null&&(this.currentBeats=y),S!==null&&(this.currentBeatType=S),c.querySelectorAll("clef").forEach(m=>{const k=parseInt(m.getAttribute("number")||"1"),E=Oe(m,"sign");E&&k<=i&&(a[k-1]=uc(E))})}const h=Array.from({length:i},()=>[]),d=l.querySelectorAll("note");for(const p of d){if(p.querySelector("chord"))continue;const y=parseInt(Oe(p,"staff")||"1"),S=Math.min(Math.max(y-1,0),i-1),I=this.parseNote(p);I&&h[S].push(I)}for(let p=0;p<i;p++)r[p].measures.push({notes:h[p]}),r[p].clef=a[p]}return r}parseNote(e){const s=e.querySelector("rest")!==null,i=Oe(e,"type"),n=i?hc(i):P.Quarter,r=e.querySelector("dot")!==null;if(s)return{duration:n,isRest:!0,isDotted:r};const a=e.querySelector("pitch");if(!a)return null;const l=Oe(a,"step")||"C",c=Es(a,"octave")??4,h=Es(a,"alter")??0,d=cc(l,c,h),p=fc(h);return{duration:n,pitch:{midiNumber:d,step:this.stepToNumber(l),alter:h,octave:c},isDotted:r,accidental:p}}stepToNumber(e){return{C:0,D:1,E:2,F:3,G:4,A:5,B:6}[e.toUpperCase()]??0}postProcess(e){return this.cleanAccidentals(e),this.applyBeaming(e),e}cleanAccidentals(e){var l;const s=((l=e.keySignature)==null?void 0:l.fifths)??0,i=["F","C","G","D","A","E","B"],n=["B","E","A","D","G","C","F"],r=()=>{const c={C:0,D:0,E:0,F:0,G:0,A:0,B:0};if(s>0)for(let h=0;h<Math.min(s,7);h++)c[i[h]]=1;else if(s<0)for(let h=0;h<Math.min(Math.abs(s),7);h++)c[n[h]]=-1;return c},a=["C","D","E","F","G","A","B"];e.parts.forEach(c=>{c.staves.forEach(h=>{h.measures.forEach(d=>{const p=r();(d.notes||[]).forEach(S=>{if(S.isRest||!S.pitch||S.pitch.step===void 0)return;const I=a[S.pitch.step],m=S.pitch.alter??0;S.accidental?p[I]===m?delete S.accidental:p[I]=m:p[I]!==m&&(m===0?S.accidental=At.Natural:m===1?S.accidental=At.Sharp:m===-1&&(S.accidental=At.Flat),p[I]=m)})})})})}applyBeaming(e){const s={whole:4,half:2,quarter:1,eighth:.5,sixteenth:.25,"thirty-second":.125,"sixty-fourth":.0625};e.parts.forEach(i=>{i.staves.forEach(n=>{n.measures.forEach(r=>{let a=0,l=1;const c=r.notes||[];for(let h=0;h<c.length;h++){const d=c[h];let p=s[d.duration]||1;if(d.isDotted&&(p*=1.5),!d.isRest&&p<1){const y=Math.floor(a+.001)+1,S=[d];let I=p,m=h+1;for(;m<c.length;){const k=c[m];let E=s[k.duration]||1;if(k.isDotted&&(E*=1.5),!k.isRest&&E<1&&a+I+E<=y)S.push(k),I+=E,m++;else break}if(S.length>1){S.forEach(k=>k.beamGroup=l),l++,h=m-1,a+=I;continue}}a+=p}})})})}}class pc{static export(e){let s=`<?xml version="1.0" encoding="UTF-8"?>
100
+ `;return s+=`<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 4.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
101
+ `,s+=`<score-partwise version="4.0">
102
+ `,s+=` <work>
103
+ <work-title>${e.title||"Untitled"}</work-title>
104
+ </work>
105
+ `,e.composer&&(s+=` <identification>
106
+ <creator type="composer">${e.composer}</creator>
107
+ </identification>
108
+ `),s+=` <part-list>
109
+ `,e.parts.forEach((i,n)=>{s+=` <score-part id="P${n+1}">
110
+ `,s+=` <part-name>${i.name}</part-name>
111
+ `,s+=` </score-part>
112
+ `}),s+=` </part-list>
113
+ `,e.parts.forEach((i,n)=>{s+=` <part id="P${n+1}">
114
+ `,i.staves[0].measures.forEach((l,c)=>{if(s+=` <measure number="${c+1}">
115
+ `,c===0){s+=` <attributes>
116
+ `,s+=` <divisions>256</divisions>
117
+ `;const h=l.timeSignature||e.timeSignature;s+=` <time>
118
+ `,s+=` <beats>${h.beats}</beats>
119
+ `,s+=` <beat-type>${h.beatType}</beat-type>
120
+ `,s+=` </time>
121
+ `;const d=l.keySignature||e.keySignature;s+=` <key>
122
+ `,s+=` <fifths>${d.fifths}</fifths>
123
+ `,s+=` </key>
124
+ `,s+=` <staves>${i.staves.length}</staves>
125
+ `,i.staves.forEach((p,y)=>{s+=` <clef number="${y+1}">
126
+ `;const S=p.clef===ft.Bass?"F":p.clef===ft.Alto?"C":p.clef===ft.Tab?"TAB":"G",I=p.clef===ft.Bass?4:p.clef===ft.Alto?"3":"2";s+=` <sign>${S}</sign>
127
+ `,s+=` <line>${I}</line>
128
+ `,s+=` </clef>
129
+ `}),s+=` </attributes>
130
+ `}i.staves.forEach((h,d)=>{h.measures[c].voices.forEach((y,S)=>{y.forEach(I=>{s+=this.noteToXML(I,d+1,S+1)})})}),s+=` </measure>
131
+ `}),s+=` </part>
132
+ `}),s+="</score-partwise>",s}static noteToXML(e,s,i){let n=` <note>
133
+ `;e.isRest?n+=` <rest/>
134
+ `:e.pitch&&(n+=` <pitch>
135
+ `,n+=` <step>${e.pitch.step}</step>
136
+ `,e.pitch.alter!==0&&(n+=` <alter>${e.pitch.alter}</alter>
137
+ `),n+=` <octave>${e.pitch.octave}</octave>
138
+ `,n+=` </pitch>
139
+ `);const r=this.getDurationDivisions(e.duration,e.isDotted);return n+=` <duration>${r}</duration>
140
+ `,n+=` <voice>${i}</voice>
141
+ `,n+=` <type>${this.getXMLNoteType(e.duration)}</type>
142
+ `,e.isDotted&&(n+=` <dot/>
143
+ `),n+=` <staff>${s}</staff>
144
+ `,n+=` </note>
145
+ `,n}static getDurationDivisions(e,s){let n=0;switch(e){case P.Whole:n=256*4;break;case P.Half:n=256*2;break;case P.Quarter:n=256;break;case P.Eighth:n=256/2;break;case P.Sixteenth:n=256/4;break;case P.ThirtySecond:n=256/8;break;case P.SixtyFourth:n=256/16;break;case P.OneHundredTwentyEighth:n=256/32;break;case P.TwoHundredFiftySixth:n=256/64;break}return s?n*1.5:n}static getXMLNoteType(e){switch(e){case P.Whole:return"whole";case P.Half:return"half";case P.Quarter:return"quarter";case P.Eighth:return"eighth";case P.Sixteenth:return"16th";case P.ThirtySecond:return"32nd";case P.SixtyFourth:return"64th";case P.OneHundredTwentyEighth:return"128th";case P.TwoHundredFiftySixth:return"256th";default:return"quarter"}}}class Ui{static async init(){this.model||(this.model=new cn.Coconet(this.MODEL_URL),await this.model.initialize(),console.log("Magenta Coconet initialized"))}static async infill(e,s,i){var p,y,S,I,m,k,E,Y;if(await this.init(),e.parts.length<4)return console.warn("Infill requires at least 4 parts (SATB)"),e;const n=cn.sequences.createQuantizedNoteSequence(4),r=4;n.quantizationInfo={stepsPerQuarter:r};let a=0;for(let R=0;R<=i;R++){const O=e.parts[0].staves[0].measures[R],M=((p=O.timeSignature)==null?void 0:p.beats)||4,q=((y=O.timeSignature)==null?void 0:y.beatType)||4;a+=M*(4/q)*r}n.totalQuantizedSteps=a;let l=0;for(let R=0;R<=i;R++){const O=e.parts[0].staves[0].measures[R],M=((S=O.timeSignature)==null?void 0:S.beats)||4,q=((I=O.timeSignature)==null?void 0:I.beatType)||4,it=M*(4/q)*r;for(let ot=0;ot<4;ot++){const U=e.parts[ot].staves[0].measures[R];let dt=0;U.notes.forEach(st=>{const g=st.getDurationValue(),L=Math.round(g*r);!st.isRest&&st.pitch&&n.notes.push({pitch:st.pitch.midiNumber,instrument:ot,program:0,quantizedStartStep:l+dt,quantizedEndStep:l+dt+L}),dt+=L})}l+=it}let c=0;for(let R=0;R<s;R++){const O=e.parts[0].staves[0].measures[R],M=((m=O.timeSignature)==null?void 0:m.beats)||4,q=((k=O.timeSignature)==null?void 0:k.beatType)||4;c+=M*(4/q)*r}n.notes=n.notes.filter(R=>R.instrument===0||R.quantizedStartStep<c);const h=await this.model.infill(n);let d=e;l=0;for(let R=0;R<=i;R++){const O=e.parts[0].staves[0].measures[R],M=((E=O.timeSignature)==null?void 0:E.beats)||4,q=((Y=O.timeSignature)==null?void 0:Y.beatType)||4,it=M*(4/q)*r;if(R>=s)for(let ot=1;ot<4;ot++){const U=[],st=(h.notes||[]).filter(Q=>Q.instrument===ot&&Q.quantizedStartStep>=l&&Q.quantizedStartStep<l+it).sort((Q,ct)=>(Q.quantizedStartStep||0)-(ct.quantizedStartStep||0));let g=l;for(const Q of st){if(Q.quantizedStartStep>g){const bt=Q.quantizedStartStep-g;for(let ht=0;ht<bt;ht++)U.push(new wt(P.Sixteenth,void 0,!0))}const ct=Q.quantizedEndStep-Q.quantizedStartStep;for(let bt=0;bt<ct;bt++){const ht=new le(Q.pitch),It=new wt(P.Sixteenth,ht);U.push(It)}g=Q.quantizedEndStep}if(g<l+it){const Q=l+it-g;for(let ct=0;ct<Q;ct++)U.push(new wt(P.Sixteenth,void 0,!0))}const $=d.parts[ot].staves[0].measures[R].withVoices([U]);d=d.replaceMeasure(ot,0,R,$,!0)}l+=it}return d}}qt(Ui,"model",null),qt(Ui,"MODEL_URL","https://storage.googleapis.com/magentadata/js/checkpoints/coconet/bach");class gc{constructor(){qt(this,"partChannels",new Map);qt(this,"partSynths",new Map);qt(this,"partSettings",new Map);qt(this,"partInstruments",new Map);qt(this,"measureTimings",[]);qt(this,"flattenedNotes",[]);qt(this,"noteStartTimes",new Map);qt(this,"isPlaying",!1);qt(this,"totalDuration",0)}async init(){Bt.context.state!=="running"&&(await Bt.start(),console.log("AudioPlayer: Tone.js initialized"))}resumeSync(){Bt.context.state==="suspended"&&Bt.context.resume()}getInstrumentSynth(e){const s=e.name.toLowerCase();let i;return s.includes("guitar")?i=new Bt.PolySynth(Bt.Synth,{oscillator:{type:"triangle"},envelope:{attack:.005,decay:.3,sustain:.1,release:1}}):s.includes("violin")||s.includes("cello")||s.includes("strings")?i=new Bt.PolySynth(Bt.FMSynth,{harmonicity:3.01,modulationIndex:14,oscillator:{type:"triangle"},envelope:{attack:.2,decay:.3,sustain:.9,release:1.2},modulation:{type:"square"},modulationEnvelope:{attack:.2,decay:.01,sustain:1,release:.5}}):s.includes("flute")?i=new Bt.PolySynth(Bt.Synth,{oscillator:{type:"sine"},envelope:{attack:.1,decay:.1,sustain:.9,release:1}}):s.includes("trumpet")||e.type==="brass"?i=new Bt.PolySynth(Bt.Synth,{oscillator:{type:"sawtooth"},envelope:{attack:.05,decay:.1,sustain:.7,release:.5}}):e.type==="percussion"?i=new Bt.PolySynth(Bt.Synth,{oscillator:{type:"square"},envelope:{attack:.001,decay:.1,sustain:0,release:.1}}):i=new Bt.PolySynth(Bt.Synth,{oscillator:{type:"triangle"},envelope:{attack:.005,decay:.1,sustain:.3,release:1}}),i}setupPart(e,s){var a,l;this.partSynths.has(e)&&((a=this.partSynths.get(e))==null||a.dispose()),this.partChannels.has(e)&&((l=this.partChannels.get(e))==null||l.dispose());const i=new Bt.Channel({volume:0,pan:0}).toDestination(),n=this.partSettings.get(e)||{volume:100,muted:!1};this.updateChannelVolume(i,n);const r=this.getInstrumentSynth(s);r.connect(i),this.partChannels.set(e,i),this.partSynths.set(e,r),this.partInstruments.set(e,s)}updateChannelVolume(e,s){s.muted?e.mute=!0:(e.mute=!1,s.volume<=0?e.volume.value=-1/0:e.volume.value=20*Math.log10(s.volume/100))}async play(e,s=0,i=!1){var m;await this.init(),this.stop(!1),Bt.Transport.stop(),Bt.Transport.cancel(),this.isPlaying=!0,this.flattenedNotes=[],this.noteStartTimes.clear(),this.measureTimings=[],e.parts.forEach((k,E)=>{this.setupPart(E,k.instrument||as.piano)});let n=null;i&&(n=new Bt.MembraneSynth({pitchDecay:.008,octaves:2,envelope:{attack:6e-4,decay:.2,sustain:0}}).toDestination());const r=(m=e.parts[0])==null?void 0:m.staves[0];if(!r)return 0;let a=0,l=0;const c=(k,E,Y)=>{const R=6e4/k;let O=Je[E]||1;return Y&&(O*=1.5),R/O};let h=0,d=e.bpm||120,p=e.tempoDuration||P.Quarter,y=e.tempoIsDotted||!1;const S=e.getPlaybackSequence();let I=0;for(const k of S){if(k===s)break;const E=r.measures[k];E.tempo&&(d=E.tempo.bpm,p=E.tempo.duration,y=E.tempo.isDotted);const Y=c(d,p,y),R=e.getTimeSignatureAt(k),O=R.beats*(4/R.beatType);I+=O*Y/1e3}return l=I,h=0,d=e.bpm||120,p=e.tempoDuration||P.Quarter,y=e.tempoIsDotted||!1,S.forEach(k=>{const E=r.measures[k];E.tempo&&(d=E.tempo.bpm,p=E.tempo.duration,y=E.tempo.isDotted);const Y=c(d,p,y),R=e.getTimeSignatureAt(k),O=R.beats,M=R.beatType,q=O*(4/M),it=q*Y/1e3,ot=h-l;if(ot>=-.001&&this.measureTimings.push({measureIndex:k,startTime:Math.max(0,ot),duration:it}),i&&ot>=-.001&&n){const dt=4/M;for(let st=0;st<O;st++){const L=h+st*dt*Y/1e3-l;if(L>=0){const $=st===0?"C2":"G1";Bt.Transport.schedule(Q=>{n==null||n.triggerAttackRelease($,"32n",Q)},L)}}}let U=0;E.notes.forEach((dt,st)=>{const g=dt.getDurationValue(),L=g*Y,$=h+U*Y/1e3;this.flattenedNotes.push({note:dt,durationMs:L,partIndex:0,staffIndex:0,measureIndex:k,noteIndex:st}),this.noteStartTimes.set(dt,$),U+=g}),h+=q*Y/1e3,a=h}),e.parts.forEach((k,E)=>{const Y=this.partSynths.get(E);Y&&k.staves.forEach(R=>{let O=0,M=e.bpm||120,q=e.tempoDuration||P.Quarter,it=e.tempoIsDotted||!1;S.forEach(ot=>{const U=R.measures[ot];if(!U)return;U.tempo&&(M=U.tempo.bpm,q=U.tempo.duration,it=U.tempo.isDotted);const dt=c(M,q,it),st=e.getTimeSignatureAt(ot),g=st.beats,L=st.beatType,$=g*(4/L);U.voices.forEach(Q=>{let ct=0;Q.forEach(bt=>{const ht=bt.getDurationValue();let It=ct,_=ct+ht;if(e.swing){const Z=yt=>{const G=yt%1,lt=Math.floor(yt);return G<.5?lt+G/.5*.66:lt+.66+(G-.5)/.5*.34};It=Z(ct),_=Z(ct+ht)}const x=O+It*dt/1e3,W=(_-It)*dt,z=x-l;if(z>=0&&!bt.isRest&&bt.pitch){const Z=440*Math.pow(2,(bt.pitch.midiNumber-69)/12);Bt.Transport.schedule(yt=>{Y.triggerAttackRelease(Z,W/1e3,yt)},z)}ct+=ht})}),O+=$*dt/1e3})})}),Bt.Transport.start(),this.totalDuration=Math.max(0,a-l),Bt.Transport.schedule(()=>{this.stop(!0)},this.totalDuration+.5),console.log(`AudioPlayer: Started Tone.js Transport. Duration: ${this.totalDuration}`),this.totalDuration}stop(e=!0){this.isPlaying=!1,Bt.Transport.stop(),Bt.Transport.cancel(),this.partSynths.forEach(s=>{s instanceof Bt.PolySynth&&s.releaseAll()})}getCurrentTime(){return this.isPlaying?Bt.Transport.seconds:0}getNoteStartTimes(){return this.noteStartTimes}getTrackedNotes(){return this.flattenedNotes}getMeasureTimings(){return this.measureTimings}getTotalDuration(){return this.totalDuration}setPartVolume(e,s){const i=this.partSettings.get(e)||{volume:100,muted:!1};i.volume=s,this.partSettings.set(e,i);const n=this.partChannels.get(e);n&&this.updateChannelVolume(n,i)}setPartMuted(e,s){const i=this.partSettings.get(e)||{volume:100,muted:!1};i.muted=s,this.partSettings.set(e,i);const n=this.partChannels.get(e);n&&this.updateChannelVolume(n,i)}getPartSettings(){return this.partSettings}async playPitch(e,s=400){Bt.context.state!=="running"&&await Bt.start();const i=new Bt.Synth().toDestination(),n=440*Math.pow(2,(e.midiNumber-69)/12);i.triggerAttackRelease(n,s/1e3),setTimeout(()=>i.dispose(),s+1e3)}}vt.Accidental=At,vt.Arpeggio=_e,vt.Articulation=xe,vt.AudioPlayer=gc,vt.Bowing=Ue,vt.Clef=ft,vt.DEFAULT_LAYOUT_CONFIG=vs,vt.DURATION_VALUES=Je,vt.Duration=P,vt.Dynamic=fn,vt.GlissandoType=ki,vt.HairpinType=Xe,vt.HarmonyService=Ui,vt.Measure=_t,vt.MusicXMLExporter=pc,vt.MusicXMLParser=dc,vt.Note=wt,vt.NoteheadShape=se,vt.Ornament=Be,vt.OttavaType=Fe,vt.PRESET_INSTRUMENTS=as,vt.Part=he,vt.Pitch=le,vt.Score=Qt,vt.ScoreCanvas=rc,vt.ScoreRenderer=Sn,vt.Staff=ce,vt.StemDirection=We,vt.VocalSynthesisService=Ve,vt.calculateScoreLayout=gn,vt.decomposeDuration=Ze,vt.getInstrumentByProgram=lc,Object.defineProperty(vt,Symbol.toStringTag,{value:"Module"})});