jpfun 0.2.0 → 0.4.0

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 (167) hide show
  1. package/README.md +141 -11
  2. package/dist/converter/midi/convert.d.ts +50 -0
  3. package/dist/converter/midi/convert.js +700 -0
  4. package/dist/converter/midi/index.d.ts +5 -0
  5. package/dist/converter/midi/index.js +11 -0
  6. package/dist/converter/midi/json.d.ts +38 -0
  7. package/dist/converter/midi/json.js +1 -0
  8. package/dist/converter/midi/triplet.d.ts +30 -0
  9. package/dist/converter/midi/triplet.js +75 -0
  10. package/dist/converter/musicxml/dom.d.ts +25 -0
  11. package/dist/converter/musicxml/dom.js +65 -0
  12. package/dist/converter/musicxml/features.d.ts +51 -0
  13. package/dist/converter/musicxml/features.js +232 -0
  14. package/dist/converter/musicxml/index.d.ts +9 -0
  15. package/dist/converter/musicxml/index.js +1140 -0
  16. package/dist/converter/musicxml/model.d.ts +123 -0
  17. package/dist/converter/musicxml/model.js +1 -0
  18. package/dist/converter/source.d.ts +22 -0
  19. package/dist/converter/source.js +51 -0
  20. package/dist/core.d.ts +22 -0
  21. package/dist/core.js +22 -0
  22. package/dist/diagnostic.js +5 -2
  23. package/dist/fraction.d.ts +24 -0
  24. package/dist/fraction.js +132 -0
  25. package/dist/functions/ASTtypes.d.ts +51 -31
  26. package/dist/functions/ASTtypes.js +59 -38
  27. package/dist/functions/adjust/index.d.ts +2 -0
  28. package/dist/functions/adjust/index.js +193 -0
  29. package/dist/functions/arpeggio/index.d.ts +2 -0
  30. package/dist/functions/arpeggio/index.js +180 -0
  31. package/dist/functions/arpeggio/shape.d.ts +7 -0
  32. package/dist/functions/arpeggio/shape.js +122 -0
  33. package/dist/functions/bar/index.d.ts +8 -0
  34. package/dist/functions/bar/index.js +62 -25
  35. package/dist/functions/beam/auto.d.ts +1 -1
  36. package/dist/functions/beam/auto.js +33 -16
  37. package/dist/functions/beam/index.js +10 -6
  38. package/dist/functions/beam/layout.d.ts +4 -3
  39. package/dist/functions/beam/layout.js +43 -65
  40. package/dist/functions/box/index.js +37 -36
  41. package/dist/functions/br/index.js +10 -8
  42. package/dist/functions/dash/index.js +40 -7
  43. package/dist/functions/default.js +19 -8
  44. package/dist/functions/div/index.d.ts +16 -0
  45. package/dist/functions/div/index.js +45 -17
  46. package/dist/functions/dot/index.js +23 -25
  47. package/dist/functions/dyn/index.d.ts +2 -0
  48. package/dist/functions/dyn/index.js +242 -0
  49. package/dist/functions/grace/index.d.ts +8 -11
  50. package/dist/functions/grace/index.js +84 -79
  51. package/dist/functions/head/index.d.ts +2 -0
  52. package/dist/functions/head/index.js +496 -0
  53. package/dist/functions/key/index.js +98 -3
  54. package/dist/functions/meter/index.d.ts +2 -0
  55. package/dist/functions/meter/index.js +155 -0
  56. package/dist/functions/note/accidentals.d.ts +24 -3
  57. package/dist/functions/note/accidentals.js +31 -1
  58. package/dist/functions/note/index.js +106 -79
  59. package/dist/functions/note/noteNameFSM.js +52 -63
  60. package/dist/functions/page/index.d.ts +11 -2
  61. package/dist/functions/page/index.js +65 -4
  62. package/dist/functions/program/index.d.ts +2 -0
  63. package/dist/functions/program/index.js +30 -0
  64. package/dist/functions/set/index.js +43 -32
  65. package/dist/functions/stack/index.js +26 -22
  66. package/dist/functions/symbol/index.d.ts +31 -0
  67. package/dist/functions/symbol/index.js +139 -0
  68. package/dist/functions/symbol/ornament.d.ts +15 -0
  69. package/dist/functions/symbol/ornament.js +73 -0
  70. package/dist/functions/symbol/shape.d.ts +24 -0
  71. package/dist/functions/symbol/shape.js +52 -0
  72. package/dist/functions/symbol/symbols/accent.d.ts +2 -0
  73. package/dist/functions/symbol/symbols/accent.js +24 -0
  74. package/dist/functions/symbol/symbols/dc.d.ts +4 -0
  75. package/dist/functions/symbol/symbols/dc.js +82 -0
  76. package/dist/functions/symbol/symbols/ds.d.ts +2 -0
  77. package/dist/functions/symbol/symbols/ds.js +93 -0
  78. package/dist/functions/symbol/symbols/dynamics.d.ts +3 -0
  79. package/dist/functions/symbol/symbols/dynamics.js +168 -0
  80. package/dist/functions/symbol/symbols/fermata.d.ts +2 -0
  81. package/dist/functions/symbol/symbols/fermata.js +24 -0
  82. package/dist/functions/symbol/symbols/fine.d.ts +2 -0
  83. package/dist/functions/symbol/symbols/fine.js +12 -0
  84. package/dist/functions/symbol/symbols/mordent.d.ts +2 -0
  85. package/dist/functions/symbol/symbols/mordent.js +56 -0
  86. package/dist/functions/symbol/symbols/prall.d.ts +2 -0
  87. package/dist/functions/symbol/symbols/prall.js +42 -0
  88. package/dist/functions/symbol/symbols/segno.d.ts +4 -0
  89. package/dist/functions/symbol/symbols/segno.js +82 -0
  90. package/dist/functions/symbol/symbols/tr.d.ts +2 -0
  91. package/dist/functions/symbol/symbols/tr.js +71 -0
  92. package/dist/functions/tempo/glyph.d.ts +12 -0
  93. package/dist/functions/tempo/glyph.js +30 -0
  94. package/dist/functions/tempo/index.js +57 -4
  95. package/dist/functions/temporal.d.ts +138 -0
  96. package/dist/functions/temporal.js +101 -0
  97. package/dist/functions/text/index.js +86 -27
  98. package/dist/functions/tie/index.js +136 -152
  99. package/dist/functions/tuplet/index.d.ts +2 -0
  100. package/dist/functions/tuplet/index.js +218 -0
  101. package/dist/functions/up/index.d.ts +1 -0
  102. package/dist/functions/up/index.js +258 -182
  103. package/dist/functions/voice/index.js +203 -109
  104. package/dist/functions/volta/index.d.ts +2 -0
  105. package/dist/functions/volta/index.js +230 -0
  106. package/dist/iife/core.d.ts +1 -0
  107. package/dist/iife/core.js +3 -0
  108. package/dist/iife/from-midi.d.ts +1 -0
  109. package/dist/iife/from-midi.js +15 -0
  110. package/dist/iife/from-musicxml.d.ts +1 -0
  111. package/dist/iife/from-musicxml.js +3 -0
  112. package/dist/iife/full.d.ts +1 -0
  113. package/dist/iife/full.js +3 -0
  114. package/dist/index.d.ts +3 -17
  115. package/dist/index.js +3 -17
  116. package/dist/jpfun.core.min.js +153 -0
  117. package/dist/jpfun.from-midi.min.js +9 -0
  118. package/dist/jpfun.from-musicxml.min.js +12 -0
  119. package/dist/jpfun.min.js +166 -0
  120. package/dist/layout/default.js +2 -3
  121. package/dist/layout/engine.d.ts +6 -12
  122. package/dist/layout/engine.js +115 -64
  123. package/dist/layout/model.d.ts +12 -5
  124. package/dist/layout/model.js +31 -18
  125. package/dist/layout/page.js +5 -4
  126. package/dist/layout/path.d.ts +19 -0
  127. package/dist/layout/path.js +101 -0
  128. package/dist/layout/types.d.ts +71 -20
  129. package/dist/layout/types.js +3 -1
  130. package/dist/lowering/loweringContext.d.ts +20 -20
  131. package/dist/lowering/loweringContext.js +153 -101
  132. package/dist/lowering/track.d.ts +5 -9
  133. package/dist/lowering/track.js +7 -2
  134. package/dist/lowering/types.d.ts +26 -112
  135. package/dist/lowering/types.js +1 -92
  136. package/dist/parser/parse-utils/call-utils.d.ts +0 -2
  137. package/dist/parser/parse-utils/call-utils.js +0 -6
  138. package/dist/parser/parse-utils/note-utils.d.ts +8 -0
  139. package/dist/parser/parse-utils/note-utils.js +35 -13
  140. package/dist/parser/parse-utils/string-utils.d.ts +10 -0
  141. package/dist/parser/parse-utils/string-utils.js +24 -0
  142. package/dist/parser/parserContext.d.ts +11 -9
  143. package/dist/parser/parserContext.js +65 -55
  144. package/dist/parser/preprocess.js +17 -11
  145. package/dist/pipeline.d.ts +6 -5
  146. package/dist/pipeline.js +4 -5
  147. package/dist/playback/compile.d.ts +18 -0
  148. package/dist/playback/compile.js +414 -0
  149. package/dist/playback/event.d.ts +105 -0
  150. package/dist/playback/event.js +105 -0
  151. package/dist/playback/time.d.ts +14 -0
  152. package/dist/playback/time.js +81 -0
  153. package/dist/playback/types.d.ts +129 -0
  154. package/dist/playback/types.js +3 -0
  155. package/dist/render/canvas.d.ts +4 -4
  156. package/dist/render/canvas.js +20 -5
  157. package/dist/render/index.d.ts +1 -0
  158. package/dist/render/index.js +1 -0
  159. package/dist/render/paint.d.ts +8 -0
  160. package/dist/render/paint.js +101 -0
  161. package/dist/render/svg.d.ts +3 -3
  162. package/dist/render/svg.js +10 -8
  163. package/dist/render/text.d.ts +22 -0
  164. package/dist/render/text.js +42 -0
  165. package/dist/render/types.d.ts +1 -1
  166. package/grammar.md +132 -13
  167. package/package.json +19 -6
@@ -0,0 +1,153 @@
1
+ /*! jpfun | Apache-2.0 | github.com/madderscientist/jpFun */
2
+ "use strict";(()=>{var Ws=Object.defineProperty;var Gs=(r,t)=>{for(var e in t)Ws(r,e,{get:t[e],enumerable:!0})};var to={};Gs(to,{ANCHOR_KEY:()=>G,ASTBraceNode:()=>z,ASTFunctionNode:()=>T,ASTLabelNode:()=>Q,ASTNodeBase:()=>Y,ASTTextNode:()=>H,CanvasPainter:()=>_e,CanvasTextMeasurer:()=>Je,DEFAULT_BPM:()=>it,DEFAULT_FONT_SIZE:()=>Go,DEFAULT_KEY:()=>J,DEFAULT_OCTAVE:()=>vi,DEFAULT_PAGE_CONFIG:()=>Z,DEFAULT_PROGRAM:()=>Zt,DEFAULT_TEXT_FONT:()=>Et,DEFAULT_TONALITY:()=>It,DEFAULT_VELOCITY:()=>bt,DefaultTextMeasurer:()=>se,Diagnostic:()=>E,ErrorDiagnostic:()=>C,Fraction:()=>M,JIANPU_NUMBER_FONT:()=>tn,LoweringContext:()=>Yt,PageLayoutError:()=>Ct,ParserContext:()=>j,RecordingPainter:()=>Jn,SvgPainter:()=>Ee,TemporalNodeBase:()=>P,Track:()=>Vt,WarningDiagnostic:()=>k,analyzeScoreSyntax:()=>yr,canvasFont:()=>ie,compilePlayback:()=>Cr,compileScore:()=>dr,completeSpringConfig:()=>qt,createLayoutPrepareContext:()=>Gn,defaultFunctions:()=>Se,defaultTextMeasurer:()=>en,functionAddonKey:()=>at,isLayoutAttachment:()=>lt,isPlaybackRelation:()=>Zn,isVisualTemporalNode:()=>D,layoutDocument:()=>De,layoutElement:()=>Qt,layoutHorizontal:()=>Ie,layoutHorizontalRegion:()=>wt,layoutPageBounds:()=>yt,normalizePageConfig:()=>Ot,paginateLayoutLines:()=>Oe,paintLayout:()=>Qn,performanceTimeToScoreTime:()=>$s,performanceTimeToSeconds:()=>Le,prepareLayoutHost:()=>et,preprocessSource:()=>Ae,primaryName:()=>Rt,renderLayoutPagesToCanvas:()=>Er,renderLayoutPagesToSvg:()=>Lr,resolveArgType:()=>gt,scoreTimeToPerformanceTime:()=>Bs,scoreTimeToSeconds:()=>br,secondsToPerformanceTime:()=>Fs,secondsToScoreTime:()=>gr,skipSpaces:()=>ot,skipSpacesBack:()=>Bt,unionLayoutBoxes:()=>Dt});var E=class r{code;message;span;constructor(t,e,n){this.code=t,this.message=e,this.span=n}toLineCol(t){let e=r.offsetToLineCol(this.span.start,t),n=r.offsetToLineCol(this.span.end,t);return{startLine:e.line,startColumn:e.column,endLine:n.line,endColumn:n.column}}static offsetToLineCol(t,e){let n=e.length;if(n===0)return{line:1,column:Math.max(0,t)+1};let o=t;o<0&&(o=0);let s=0,i=n-1;for(;s<=i;){let l=s+i>>1;e[l]<=o?s=l+1:i=l-1}let c=Math.max(0,i),a=e[c]??0;return{line:c+1,column:o-a+1}}static error;static warning},C=class extends E{},k=class extends E{};E.error={Bug:(r,t)=>new C("E_BUG",`\u89E3\u6790\u5668\u9519\u8BEF: ${r}\uFF0C\u8BF7\u8054\u7CFB\u5F00\u53D1\u8005\u4FEE\u590D\u8FD9\u4E2A\u95EE\u9898`,t),MissingArg:(r,t,e)=>{let n=typeof t=="number"?`[${t}]`:`"${t}"`;return new C("E_MISSING_REQUIRED_ARG",`\u51FD\u6570@${r} \u7F3A\u5C11\u5FC5\u9700\u7684\u53C2\u6570 ${n}`,e)},InvalidArgType:(r,t,e,n,o)=>{let s=typeof t=="number"?`[${t}]`:`"${t}"`;return new C("E_WRONG_ARG_TYPE",`\u51FD\u6570 @${r} \u7684\u53C2\u6570 ${s} \u7C7B\u578B\u9519\u8BEF: \u5F97\u5230\u4E86 ${n}\uFF0C\u4F46\u671F\u671B ${e}`,o)},PosAfterNamedArg:(r,t)=>new C("E_POSARG_AFTER_KWARG",`\u51FD\u6570 @${r} \u7684\u4F4D\u7F6E\u53C2\u6570\u51FA\u73B0\u5728\u547D\u540D\u53C2\u6570\u4E4B\u540E\uFF0C\u8FD9\u662F\u4E0D\u5141\u8BB8\u7684`,t),EmptyContent:(r,t,e)=>{let n=typeof t=="number"?`[${t}]`:`"${t}"`;return new C("E_EMPTY_CONTENT",`\u51FD\u6570 @${r} \u7684\u53C2\u6570 ${n} \u5185\u5BB9\u4E3A\u7A7A(\u6216\u65E0\u53EF\u7528\u5185\u5BB9)\uFF1B\u8BF7\u63D0\u4F9B\u6709\u6548\u5185\u5BB9`,e)},UnterminatedCall:(r,t)=>new C("E_UNTERMINATED_CALL",`\u51FD\u6570\u8C03\u7528\u672A\u95ED\u5408: @${r}(...)`,t),UnterminatedString:r=>new C("E_UNTERMINATED_String","\u5F15\u53F7\u672A\u95ED\u5408",r),UnknownFunction:(r,t)=>new C("E_UNKNOWN_FUNCTION",`\u672A\u77E5\u51FD\u6570: @${r}\uFF0C\u8BF7\u68C0\u67E5\u62FC\u5199`,t),UnknownLabel:(r,t)=>new C("E_UNKNOWN_LABEL",`\u672A\u77E5\u6807\u7B7E: "${r}"`,t),InvalidTonality:(r,t)=>new C("E_INVALID_TONALITY",`\u65E0\u6548\u7684\u8C03\u6027: "${r}"\uFF0C\u8BF7\u63D0\u4F9B\u6709\u6548\u7684\u8C03\u6027\u540D\u79F0\uFF0C\u5FC5\u987B [\u4E00\u4E2A\u5927\u5199\u5B57\u6BCD][\u53D8\u97F3\u8BB0\u53F7#bn\u53EA\u80FD\u4E00\u4E2A][\u7EDD\u5BF9\u516B\u5EA6\u6570\u5B57]\uFF0C\u540E\u4E8C\u8005\u53EF\u9009`,t),BreakInsideEvent:r=>new C("E_BREAK_INSIDE_EVENT","\u6362\u884C\u5207\u65AD\u4E86\u4E00\u4E2A\u4ECD\u5728\u6301\u7EED\u7684\u4E8B\u4EF6\uFF1B\u8BF7\u628A\u957F\u97F3\u5199\u6210\u591A\u4E2A\u4E8B\u4EF6\uFF0C\u6216\u8C03\u6574 @br \u7684\u4F4D\u7F6E",r),InvalidPageConfig:(r,t)=>new C("E_INVALID_PAGE_CONFIG",r,t),PageOverflow:(r,t,e)=>new C("E_PAGE_OVERFLOW",`\u8C31\u9762\u884C\u9700\u8981 ${r}px \u9AD8\u5EA6\uFF0C\u4F46\u9875\u9762\u5185\u5BB9\u533A\u53EA\u6709 ${t}px`,e)};E.warning={UnknownFunction:(r,t)=>new k("W_UNKNOWN_FUNCTION",`\u672A\u77E5\u51FD\u6570: @${r}\uFF0C\u5C06\u88AB\u5F53\u4F5C\u666E\u901A\u6587\u672C\u5904\u7406`,t),UnknownNamedArg:(r,t,e)=>new k("W_UNKNOWN_NAMED_ARG",`\u51FD\u6570 @${r} \u6536\u5230\u672A\u77E5\u7684\u547D\u540D\u53C2\u6570 "${t}"`,e),TooManyPosArgs:(r,t,e,n)=>new k("W_TOO_MANY_POS_ARGS",`\u51FD\u6570 @${r} \u63A5\u6536\u4E86\u8FC7\u591A\u7684\u4F4D\u7F6E\u53C2\u6570\uFF0C\u671F\u671B ${t} \u4E2A\u4F46\u5F97\u5230\u4E86 ${e} \u4E2A`,n),InvalidNumber:(r,t)=>new k("W_INVALID_NUMBER",`\u65E0\u6548\u7684\u6570\u5B57: "${r}"\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidBoolean:(r,t)=>new k("W_INVALID_BOOL",`\u65E0\u6548\u7684\u5E03\u5C14\u503C: "${r}": \u5E94\u4E3A 'true' \u6216 'false'\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidLength:(r,t)=>new k("W_INVALID_LENGTH",`\u65E0\u6548\u7684\u957F\u5EA6\u503C: "${r}"\uFF1B\u8BF7\u63D0\u4F9B\u6709\u6548\u7684\u957F\u5EA6\u503C\uFF0C\u4F8B\u5982 "10px" \u6216 "2em"\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidLengthUnit:(r,t)=>new k("W_INVALID_LENGTH_UNIT",`\u65E0\u6548\u7684\u957F\u5EA6\u5355\u4F4D: "${r}"\uFF1B\u4EC5\u652F\u6301 "px" \u548C "em"\uFF1B\u8BF7\u68C0\u67E5\u51FD\u6570\u53C2\u6570\u6216\u53D8\u91CF\u5B9A\u4E49\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidContent:r=>new k("W_INVALID_CONTENT","\u5185\u5BB9\u89E3\u6790\u5931\u8D25\uFF0C\u9519\u8BEF\u539F\u56E0\u89C1\u4E0A\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u4F46\u5F80\u5F80\u4E0D\u5B58\u5728\uFF0C\u6781\u6709\u53EF\u80FD\u5BFC\u81F4\u9519\u8BEF)",r),EmptyContent:(r,t,e)=>new k("W_EMPTY_CONTENT",`\u51FD\u6570 @${r} \u7684\u53C2\u6570 "${t}" \u5185\u5BB9\u4E3A\u7A7A(\u6216\u65E0\u53EF\u7528\u5185\u5BB9)`,e),UnmatchedBrace:r=>new k("W_UNMATCHED_BRACE","\u672A\u5339\u914D\u7684\u5927\u62EC\u53F7: \u7F3A\u5C11\u53F3\u5927\u62EC\u53F7'}'\uFF1B\u5C06\u5C1D\u8BD5\u81EA\u52A8\u4FEE\u590D",r),LabelWithoutTarget:(r,t)=>new k("W_LABEL_WITHOUT_TARGET",`\u6807\u7B7E "${r}" \u6CA1\u6709\u53EF\u7ED1\u5B9A\u7684\u76EE\u6807\uFF1B\u6807\u7B7E\u5C06\u88AB\u5FFD\u7565`,t),TargetAlreadyLabeled:(r,t,e)=>new k("W_TARGET_ALREADY_LABELED",`\u76EE\u6807\u5DF2\u6807\u6CE8\u4E3A "${t}"\uFF0C"${r}" \u5C06\u88AB\u5FFD\u7565`,e),UnresolvedEndpoint:(r,t)=>new k("W_UNRESOLVED_ENDPOINT",`@${r} \u6709\u7AEF\u70B9\u627E\u4E0D\u5230\u5BF9\u5E94\u7684\u8C31\u9762\u5BF9\u8C61\uFF1B\u8BE5\u5173\u7CFB\u5C06\u88AB\u5FFD\u7565`,t),ZeroTimeTrack:(r,t)=>new k("W_ZERO_TIME_TRACK",`\u7B2C${t}\u4E2A\u5B50\u8F68\u9053\u7684\u65F6\u957F\u4E3A0`,r)};function at(r){return`@${r}`}var Y=class{sourceSpan;parent;get children(){return null}constructor(t,e=null){this.sourceSpan=t,this.parent=e}loweringEnter(t,e){return[]}timeFlowModel(t){return null}loweringExit(t,e,n){return[]}toString(t){return t.slice(this.sourceSpan.start,this.sourceSpan.end)}},H=class extends Y{},Q=class extends Y{label;target;constructor(t,e,n,o=null){super(t,o),this.label=e,this.target=n}toString(t){return`@${this.label} `}},z=class r extends Y{content;get children(){return this.content}constructor(t,e,n=null){super(t,n),this.content=e,this.content.forEach(o=>o.parent=this)}innerSpan(){return r.getContentSpan(this.content)}static getContentSpan(t){if(Array.isArray(t)){if(t.length===0)return{start:0,end:0};let e=r.getContentSpan(t[0]),n=r.getContentSpan(t[t.length-1]);return{start:e.start,end:n.end}}else return{start:t.sourceSpan.start,end:t.sourceSpan.end}}timeFlowModel(){return{children:this.content,mode:"sequence"}}toString(t){return`{${this.content.map(e=>e.toString(t)).join("")}}`}};function gt(r,t,e){return t?r.args.find(n=>n.name?.toLowerCase()===t)?.type:r.args[e]?.type??(r.allowExtraArgs?r.extraArgType:void 0)}function Rt(r){return Array.isArray(r.name)?r.name[0]:r.name}var T=class r extends Y{label;static def;get def(){return this.constructor.def}get callName(){return this.def?Rt(this.def):""}static deSugarAtom=()=>null;get deSugarAtom(){return this.constructor.deSugarAtom}static deSugarRelation=()=>null;get deSugarRelation(){return this.constructor.deSugarRelation}getArgValue(t,e){let n=this.def;if(!n)return[];let o=n.args,s=Rt(n);return o.map((i,c)=>{let a=i.name?i.name.toLowerCase():null,l=(a?t.get(a):null)??t.get(c)??(a?e.variables[`${s}.${a}`.toLowerCase()]:null)??i.default;if(l===null)throw E.error.MissingArg(s,i.name||c,this.sourceSpan);return l})}toString(t){let e=this.callName;return e?`@${e} `:super.toString(t)}static loweringAugment;static loweringFinalize;static layoutDecorationHandler;static findLabelable(t){let e=t;if(e.labelable)return e.labelable();for(let n of t.children??[]){let o=r.findLabelable(n);if(o)return o}return null}static findLastFuncContentNode(t,e){for(;e>=0;e--){let n=t[e];if(n instanceof H)return null;if(n instanceof r||n instanceof z)return n}return null}};function Vs(r,t){for(;t!==0;){let e=r%t;r=t,t=e}return r}var M=class r{_numerator=0;_denominator=1;constructor(t=0,e=1){this.set(t,e)}get numerator(){return this._numerator}get denominator(){return this._denominator}set(t,e=1){if(e===0)throw new RangeError("Denominator must not be zero");e<0&&(t=-t,e=-e);let n=Vs(Math.abs(t),e);return this._numerator=t/n,this._denominator=e/n,this}copyFrom(t){return this._numerator=t._numerator,this._denominator=t._denominator,this}clone(){return new r(this._numerator,this._denominator)}add(t,e=1){let n;return typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),this.set(this._numerator*e+n*this._denominator,this._denominator*e)}sub(t,e=1){let n;return typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),this.set(this._numerator*e-n*this._denominator,this._denominator*e)}mul(t,e=1){let n;return typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),this.set(this._numerator*n,this._denominator*e)}div(t,e=1){let n;if(typeof t=="number"?n=t:(n=t._numerator,e=t._denominator),n===0)throw new RangeError("Cannot divide by zero");return this.set(this._numerator*e,this._denominator*n)}divPow2(t=1){if(this._numerator===0)return this;for(;t>0&&this._numerator%2===0;)this._numerator/=2,t--;return this._denominator*=2**t,this}compare(t,e=1){let n;typeof t=="number"?n=t:(n=t._numerator,e=t._denominator);let o=this._numerator*e-n*this._denominator;return o<0?-1:o>0?1:0}equals(t,e=1){return t instanceof r?this._numerator===t._numerator&&this._denominator===t._denominator:this._numerator*e===t*this._denominator}isZero(){return this._numerator===0}toNumber(){return this._numerator/this._denominator}toString(){return this._denominator===1?String(this._numerator):`${this._numerator}/${this._denominator}`}};var it=120,bt=80,It="C4",Zt=0,G=-1/0,J=1/0,P=class{t=new M;T=new M;track;ast;order;addon;mergeKey;foldedInto;breakBefore=0;layoutLine=0;box;springConfig;ports;decorations;initLayoutBox(){return this.box={x:0,y:0,w:0,h:0,anchor:0,visualAxis:0}}playbackState;prepareLayout(t){}paint(t){}};function D(r){return r.box!==void 0}function lt(r){return typeof r.createGeometry=="function"}var Ne=class extends T{static def={name:["adjust","adj"],description:"\u5FAE\u8C03\u76EE\u6807\u7684\u4F4D\u7F6E\u4E0E\u5360\u4F4D",example:`@adjust(content, dx=0px, dy=0px, dw=0px, dh=0px)
3
+ dw/dh \u5728\u6392\u7248\u524D\u589E\u51CF\u5360\u4F4D\uFF0C\u6700\u7EC8\u5C3A\u5BF8\u4E0D\u5C0F\u4E8E 0\uFF1Bdw \u6309\u539F\u5DE6\u53F3\u5360\u4F4D\u6BD4\u4F8B\u5206\u914D\uFF0Cdh \u8C03\u6574\u4E0B\u65B9\uFF1B
4
+ dx/dy \u5728\u6392\u7248\u5B8C\u6210\u540E\u5E73\u79FB\u76EE\u6807\uFF0C\u90BB\u5C45\u4E0D\u4F1A\u8BA9\u5F00\uFF0C\u56E0\u6B64\u53EF\u4EE5\u6545\u610F\u91CD\u53E0\u3002
5
+ \u62EC\u4F4F\u7684\u82E5\u662F\u5173\u7CFB\u5BF9\u8C61\uFF08\u8FDE\u97F3\u7EBF\u7B49\uFF09\u4E14\u5176\u4E2D\u6CA1\u6709\u5BF9\u8C61\uFF0C\u5E73\u79FB\u7684\u5C31\u662F\u8FD9\u6761\u5173\u7CFB\u5BF9\u8C61`,allowExtraArgs:!1,args:[{type:"content",default:null},{name:"dx",type:"length",default:{value:0,unit:"px"}},{name:"dy",type:"length",default:{value:0,unit:"px"}},{name:"dw",type:"length",default:{value:0,unit:"px"}},{name:"dh",type:"length",default:{value:0,unit:"px"}}]};target;dx;dy;dw;dh;get children(){return[this.target]}timeFlowModel(){return{children:[this.target],mode:"sequence"}}loweringEnter(t){let e={temporal:0,attachment:0},n={targets:e,onTemporal:o=>{D(o)&&(e.temporal++,Ys(o,this))},onAttachment:o=>{lt(o)&&(e.attachment++,Ks(o,e,this.dx,this.dy))}};return t.beginLoweringGroup(this,n),[]}loweringExit(t){let e=t.endLoweringGroup(this);return e.targets.temporal===0&&e.targets.attachment===0&&t.diagnostics.push(new k("W_ADJUST_NO_TARGET","@adjust \u6CA1\u6709\u627E\u5230\u53EF\u8C03\u6574\u7684\u5BF9\u8C61",this.sourceSpan)),[]}constructor(t,e,n,o=null){super(t,o);let[s,i,c,a,l]=this.getArgValue(e,n);s.parent=this,this.target=s,this.dx=n.length2px(i),this.dy=n.length2px(c),this.dw=n.length2px(a),this.dh=n.length2px(l)}},oo=Ne;function Ys(r,t){let{dx:e,dy:n,dw:o,dh:s}=t;if(e===0&&n===0&&o===0&&s===0)return;let i,c,a=r.finalizeLayout,l=r.onPlaced;r.finalizeLayout=h=>{a?.call(r,h);let p=Math.max(0,r.box.w+o);r.box.anchor=r.box.w>0?r.box.anchor*p/r.box.w:0,r.box.w=p,r.box.h=Math.max(0,r.box.h+s)},r.onPlaced=()=>{r.box.x!==i&&(r.box.x+=e),r.box.y!==c&&(r.box.y+=n),l?.call(r),i=r.box.x,c=r.box.y}}function Ks(r,t,e,n){if(e===0&&n===0)return;let o=r.createGeometry;r.createGeometry=s=>{let i=o.call(r,s);if(t.temporal>0)return i;let c=a=>a.line===void 0?{x:a.x+e,y:a.y+n,w:a.w,h:a.h}:{x:a.x+e,y:a.y+n,w:a.w,h:a.h,line:a.line,track:a.track};return{regions:i.regions.map(c),occupancy:i.occupancy?.map(c),paint(a){i.paint(new Me(a,e,n))}}}}var Me=class{target;dx;dy;constructor(t,e,n){this.target=t,this.dx=e,this.dy=n}drawText(t,e,n,o){this.target.drawText(t,e+this.dx,n+this.dy,o)}drawLine(t,e,n,o,s){this.target.drawLine(t+this.dx,e+this.dy,n+this.dx,o+this.dy,s)}drawRect(t,e,n,o,s){this.target.drawRect(t+this.dx,e+this.dy,n,o,s)}drawCircle(t,e,n,o){this.target.drawCircle(t+this.dx,e+this.dy,n,o)}drawPath(t,e,n){if(n){let o={...n,x:n.x+this.dx,y:n.y+this.dy};this.target.drawPath(t,e,o);return}this.target.drawPath(t.map(o=>this.translateCommand(o)),e)}translateCommand(t){switch(t.op){case"Z":return t;case"Q":return{op:"Q",cx:t.cx+this.dx,cy:t.cy+this.dy,x:t.x+this.dx,y:t.y+this.dy};case"C":return{op:"C",cx1:t.cx1+this.dx,cy1:t.cy1+this.dy,cx2:t.cx2+this.dx,cy2:t.cy2+this.dy,x:t.x+this.dx,y:t.y+this.dy};default:return{op:t.op,x:t.x+this.dx,y:t.y+this.dy}}}};var jt=1,Us=6,Xs=16,Re=32,so=1e-6,Zs=.01;function qt(r,t=jt){let e=r.alpha_L??r.alpha_R??Us;r.alpha_L??=e,r.alpha_R??=e;let n=r.mu_L??r.mu_R??Xs;r.mu_L??=n,r.mu_R??=n,r.beta_L??=t/Math.max(r.alpha_L,so),r.beta_R??=t/Math.max(r.alpha_R,so)}function Qt(r,t,e,n=jt){qt(r,n);let o=Math.pow(Math.max(e.T.toNumber(),Zs),.5);return{config:r,box:t,time:e,duration_L:o,duration_R:o,WL:t.anchor,WR:t.w-t.anchor,margin_L:o*r.alpha_L,margin_R:o*r.alpha_R}}function js(r,t=jt){let e=new Map,n=0;for(let s of r)for(let i of s)e.has(i.time.track)||e.set(i.time.track,n++);let o=[];for(let s of r){if(s.length===0)continue;let i=Array(s.length);o.push(i);let c=0,a=0,l=n;for(let p of s){p.WL>c&&(c=p.WL),p.WR>a&&(a=p.WR);let f=e.get(p.time.track);if(i[f]){let d=i[f];p.time.T.compare(d.time.T)>0?(i[f]=p,i[l++]=d):i[l++]=p}else i[f]=p}let h=s[0].time.t;for(let p of e){let f=p[1];if(!i[f]){let d=Qt({anchor:0,alpha_L:c,alpha_R:a},{x:0,w:0,anchor:0},{t:h,T:new M(1),track:p[0]},t);d.fake=!0,i[f]=d}}}return{mat:o,rows:n}}function qs(r,t,e,n){let o=n-e-r.WR-t.WL,s=r.margin_R+t.margin_L;if(o>=s)return{force:0,stiffness:0};let i=r.config.beta_R/r.duration_R,c=t.config.beta_L/t.duration_L,a=i*c/(i+c),l,h;if(o<0){let p=r.config.mu_R*t.config.mu_L/(r.config.mu_R+t.config.mu_L);l=a*s-p*o,h=p}else{let p=s-o;l=a*p,h=a}return{force:l,stiffness:h}}function Qs(r,t,e=Re){let n=t-r.WL,o=r.margin_L;if(n>=o)return{force:0,stiffness:0};let s=r.config.beta_L/r.duration_L;if(n>=0)return{force:s*(o-n),stiffness:s};let i=r.config.mu_L*e;return{force:r.config.alpha_L*r.config.beta_L-i*n,stiffness:i}}function Js(r,t,e,n=Re){let o=e-(t+r.WR),s=r.margin_R;if(o>=s)return{force:0,stiffness:0};let i=r.config.beta_R/r.duration_R;if(o>=0)return{force:i*(s-o),stiffness:i};let c=r.config.mu_R*n;return{force:r.config.alpha_R*r.config.beta_R-c*o,stiffness:c}}function ti(r){return{damping:r.damping??.6,maxIter:r.maxIter??100,eps:r.eps??.01,crossPunish:r.crossPunish??Re,globalC:r.globalC??jt}}function ei(r,t,e,n,o){let{damping:s,maxIter:i,eps:c,crossPunish:a}=o,l=r.length,h=new Float64Array(t);for(let S=0;S<l;S++){let _=0,L=r[S];for(let A=0;A<t;A++){let N=h[A]+L[A].WL+L[A].margin_L;N>_&&(_=N)}for(let A=0;A<t;A++)h[A]=_+L[A].WR+L[A].margin_R;e[S]=_}let p=h.reduce((S,_)=>Math.max(S,_),0);if(p<=n)return!0;p=n/p;for(let S=0;S<l;S++)e[S]*=p;let f=new Float64Array(l),d=new Float32Array(t*(l+1));function x(S){f.fill(0);for(let _=0;_<t;_++){let L=_*(l+1),A=r[0][_],N=Qs(A,S[0],a);f[0]+=N.force,d[L]=N.stiffness;for(let W=1;W<l;W++){let U=r[W-1][_],B=r[W][_],K=qs(U,B,S[W-1],S[W]);f[W-1]-=K.force,f[W]+=K.force,d[L+W]=K.stiffness}let I=r[l-1][_],$=Js(I,S[l-1],n,a);f[l-1]-=$.force,d[L+l]=$.stiffness}return f}let g=new Float64Array(l);function y(S){g.fill(0);for(let L=0,A=0;L<t;L++,A+=l+1){g[0]+=d[A]*S[0];for(let N=1;N<l;N++){let I=d[A+N]*(S[N]-S[N-1]);g[N-1]-=I,g[N]+=I}g[l-1]+=d[A+l]*S[l-1]}let _=1e-4;for(let L=0;L<S.length;L++)g[L]+=_*S[L];return g}function u(S,_){let L=0;for(let A=0;A<S.length;A++)L+=S[A]*_[A];return L}let m=new Float64Array(l),b=new Float64Array(l),w=new Float64Array(l);function R(S,_=8){m.fill(0),b.set(S),w.set(b);let L=u(b,b);if(L<1e-12)return m;for(let A=0;A<_;A++){let N=y(w),I=u(w,N);if(Math.abs(I)<1e-12)break;let $=L/I;for(let B=0;B<l;B++)m[B]+=$*w[B],b[B]-=$*N[B];let W=u(b,b);if(Math.sqrt(W)<1e-6)break;let U=W/L;for(let B=0;B<l;B++)w[B]=b[B]+U*w[B];L=W}return m}let v=0,O=0;for(;v<i;v++){let S=x(e);O=0;for(let L=0;L<S.length;L++){let A=Math.abs(S[L]);A>O&&(O=A)}if(O<c)break;let _=R(S);for(let L=0;L<l;L++)e[L]+=s*_[L]}return!1}function wt(r,t,e,n,o,s,i){if(e.length!==r.length||n.length!==Math.max(0,e.length-1))throw new Error("Horizontal region state does not match its columns");if(e.length===0||t===0)return;let c=n.some(d=>d!==0),a,l,h=r,p=e;if(c){a=new Uint32Array(e.length),l=new Float64Array(e.length),h=[];for(let d=0;d<e.length;){let x=d;for(;x<n.length&&n[x];)x++;let g=h.length;for(let y=d;y<=x;y++)a[y]=g,l[y]=e[y]-e[d];if(d===x)h.push(r[d]);else{let y=e[x]-e[d];h.push(Array.from({length:t},(u,m)=>{let b=r[d][m],w=r[x][m];return{config:{alpha_L:b.config.alpha_L,alpha_R:w.config.alpha_R,mu_L:b.config.mu_L,mu_R:w.config.mu_R,beta_L:b.config.beta_L,beta_R:w.config.beta_R},box:b.box,time:b.time,duration_L:b.duration_L,duration_R:w.duration_R,WL:b.WL,WR:y+w.WR,margin_L:b.margin_L,margin_R:w.margin_R,fake:b.fake&&w.fake}}))}d=x+1}p=new Float64Array(h.length)}let f=ei(h,t,p,o,s);if(n.fill(1),i!==void 0){let d=0,x=0;for(let y=0;y<t;y++)d=Math.max(d,h[0][y].WL),x=Math.max(x,h[h.length-1][y].WR);let g=p[p.length-1]+x-p[0]+d;if(!f||g>=o*i){let y=d-p[0],u=o-g;for(let m=0;m<p.length;m++)p[m]+=y+(p.length>1?u*m/(p.length-1):0)}}if(c)for(let d=0;d<e.length;d++)e[d]=p[a[d]]+l[d]}function Ie(r,t,e={},n=[],o){let s=ti(e),{mat:i,rows:c}=js(r,s.globalC),a=new Float64Array(i.length),l=new Uint8Array(Math.max(0,i.length-1)),h=n.length>1?[...n].sort((p,f)=>p.end-p.start-(f.end-f.start)):n;for(let{start:p,end:f,hook:d}of h){if(p<0||f<p||f>=i.length)throw new Error("Horizontal layout registration references invalid columns");d({columns:i,rows:c,start:p,end:f,X:a,fixed:l,options:s})}wt(i,c,a,l,t,s,o);for(let p=0;p<i.length;p++)for(let f of i[p])f.box.x=a[p]-f.box.anchor;return i}var Ct=class extends Error{line;requiredHeight;availableHeight;constructor(t,e,n){super(`Page cannot fit layout line ${t}: requires ${e}px, available ${n}px`),this.name="PageLayoutError",this.line=t,this.requiredHeight=e,this.availableHeight=n}},Z={width:794,height:1/0,marginTop:45,marginBottom:48,marginLeft:40,marginRight:40,lineGap:22};function Ot(r={}){let t=r.height??Z.height,e={width:r.width??Z.width,height:t<=0?1/0:t,marginTop:Math.max(0,r.marginTop??Z.marginTop),marginBottom:Math.max(0,r.marginBottom??Z.marginBottom),marginLeft:Math.max(0,r.marginLeft??Z.marginLeft),marginRight:Math.max(0,r.marginRight??Z.marginRight),lineGap:Math.max(0,r.lineGap??Z.lineGap)};if(!Number.isFinite(e.width)||e.width<=0)throw new Error(`Page width must be a positive finite number, got ${e.width}`);if(e.height!==1/0&&(!Number.isFinite(e.height)||e.height<=0))throw new Error(`Page height must be positive or Infinity, got ${e.height}`);if([e.marginTop,e.marginBottom,e.marginLeft,e.marginRight,e.lineGap].some(i=>!Number.isFinite(i)||i<0))throw new Error("Page margins and line gap must be finite non-negative numbers");let o=e.width-e.marginLeft-e.marginRight;if(o<=0)throw new Error(`Page horizontal margins leave no content width: ${o}px`);let s=e.height-e.marginTop-e.marginBottom;if(Number.isFinite(e.height)&&s<=0)throw new Error(`Page vertical margins leave no content height: ${s}px`);return e}function Oe(r,t){let e=t.height-t.marginTop-t.marginBottom,n=[],o=new Array(r.length).fill(0),s=0,i=0,c=0,a=0,l=(h,p)=>{let f=h-i,d=p?Math.max(0,e-a-t.lineGap*(f-1)):0,x=t.lineGap+d/f,g=s+t.marginTop;for(let u=i;u<h;u++)o[u]=g,g+=r[u]+(u+1<h?x:0);let y=Number.isFinite(t.height)?t.height:g-s+t.marginBottom;n.push({bounds:{x:0,y:s,w:t.width,h:y},lineStart:i,lineEnd:h}),s+=y,i=h,c=0,a=0};for(let h=0;h<r.length;h++){let p=r[h];if(Number.isFinite(t.height)&&p>e+1e-6)throw new Ct(h,p,e);Number.isFinite(t.height)&&h>i&&c+t.lineGap+p>e+1e-6&&l(h,!0),c+=(h>i?t.lineGap:0)+p,a+=p}return r.length>i&&l(r.length,!1),{pages:n,lineTops:o}}function Dt(r,t){let e=1/0,n=1/0,o=-1/0,s=-1/0;for(let i of t)e=Math.min(e,i.x),n=Math.min(n,i.y),o=Math.max(o,i.x+i.w),s=Math.max(s,i.y+i.h);return Number.isFinite(e)?(r.x=e,r.y=n,r.w=o-e,r.h=s-n,!0):(r.x=r.y=r.w=r.h=0,!1)}function et(r,t){r.springConfig??={},r.decorations=[],r.ports={},r.box.x=r.box.y=0,r.prepareLayout(t);for(let[e,n]of Object.entries(r.addon??{})){let o=t.decorationHandlers.get(e);if(!o)continue;let s=o(r,n,t);s&&r.decorations.push(s)}ni(r),r.finalizeLayout?.(t)}function De(r,t,e={}){let n=r.attachments.filter(lt),o=Ot(r.page),s=o.width-o.marginLeft-o.marginRight,i=o.marginLeft,c=oi(r),a=[];for(let m of c)for(let b of m.columns)for(let w of b)a.push(w),et(w,t);let l=si(c,e.globalC);for(let m of a)m.prepareHorizontal?.(l[m.layoutLine]);for(let m of n)m.prepareHorizontal?.(l,t);for(let m=0;m<c.length;m++){let b=c[m],w=b.columns.map(R=>R.map(v=>Qt(v.springConfig,v.box,v,e.globalC)));Ie(w,s,e,b.horizontalLayoutHooks,.5);for(let R of b.columns)for(let v of R)v.box.x+=i}for(let m of a){let b=c[m.layoutLine],w=-m.box.visualAxis;te(b.hostExtents,m.track,w,w+m.box.h)}let h=ii(c.length,a,e.rowGap),p=()=>{let m=[],b=c.map((S,_)=>{let L=ri(S,r.rootTrack,h[_]);return m.push(L.height),L.axes}),w,R;try{({pages:w,lineTops:R}=Oe(m,o))}catch(S){if(!(S instanceof Ct))throw S;let _=c[S.line],L=1/0,A=-1/0;for(let N of _?.columns??[])for(let I of N)L=Math.min(L,I.ast.sourceSpan.start),A=Math.max(A,I.ast.sourceSpan.end);throw Number.isFinite(L)?E.error.PageOverflow(S.requiredHeight,S.availableHeight,{start:L,end:A}):S}let v=(S,_)=>(R[S]??0)+(b[S]?.get(_)??0);for(let S of a)S.box.y=v(S.layoutLine,S.track)-S.box.visualAxis,S.onPlaced?.();let O={...t,width:s,originX:i,pages:w.map(S=>S.bounds),lines:l,getVisualAxis:v,getHostExtent:(S,_)=>c[S]?.hostExtents.get(_)};return{pages:w,attachmentContext:O}},f=p(),d=io(n,f.attachmentContext,c);d.needsRelayout&&(f=p(),d=io(n,f.attachmentContext,c));let x=f.pages,g=n.map((m,b)=>{let{geometry:w,box:R}=d.items[b];return{box:R,regions:w.regions,layer:m.layer,sourceSpan:m.sourceSpan,paint(v){w.paint(v)}}}),y={x:0,y:0,w:0,h:0};function*u(){for(let m of x)yield m.bounds;for(let m of a)yield m.box;for(let m of g)yield m.box}return Dt(y,u()),{diagnostics:r.diagnostics,objects:a,attachments:g,bounds:y,lineCount:c.length,pages:x}}function ni(r){let t=r.decorations.map(n=>n.below).filter(n=>n!==void 0).sort((n,o)=>n.order-o.order);if(t.length===0)return;let e=r.box.h;for(let n of t)e+=n.gap??0,n.place?.(e),e+=Math.max(0,n.height??0);r.box.h=e}function oi(r){let t=()=>({columns:[],horizontalLayoutHooks:[],hostExtents:new Map,attachmentExtents:new Map,attachmentRanges:[]}),e=[],n=t();for(let o of r.columns){let s=[];for(;e.length<o[0].layoutLine;)e.push(n),n=t();for(let i of o)D(i)&&s.push(i);s.length&&n.columns.push(s)}return(n.columns.length>0||e.length===0)&&e.push(n),e}function Jt(r,t,e){r.top=Math.min(r.top,t),r.bottom=Math.max(r.bottom,e)}function te(r,t,e,n){let o=r.get(t);o?Jt(o,e,n):r.set(t,{top:e,bottom:n})}function si(r,t){return r.map((e,n)=>{let o=new Map,s=new Map;for(let i=0;i<e.columns.length;i++)for(let c of e.columns[i]){o.set(c,i),qt(c.springConfig,t);let a=s.get(c.track);a?a.push(c):s.set(c.track,[c])}return{index:n,columns:e.columns,trackRuns:s,columnOf:i=>o.get(i)??-1,registerHorizontalLayoutHook(i,c,a){let l=o.get(i),h=o.get(c);l===void 0||h===void 0||e.horizontalLayoutHooks.push({start:Math.min(l,h),end:Math.max(l,h),hook:a})}}})}function ii(r,t,e){if(e!==void 0)return new Array(r).fill(e);let n=new Array(r).fill(0),o=0;for(let s of t){let i=s.ast.size*.75;i>n[s.layoutLine]&&(n[s.layoutLine]=i),i>o&&(o=i)}for(let s=0;s<r;s++)n[s]||=o;return n}function io(r,t,e){let n=new Map,o=!1;for(let c of e)c.attachmentRanges.length=0;let s={...t,getAttachmentBox(c){let a=n.get(c);if(!a)throw new Error("Layout attachment dependency has not been measured");return a.box},getRangeExtents(c,a){let l=e[c],h=new Map;if(!l)return h;let p=a===void 0;if(a&&a[0]>a[1])return h;let f=p?0:Math.max(0,a[0]),d=p?l.columns.length-1:Math.min(a[1],l.columns.length-1);if(!p&&f>d)return h;let x=p?t.originX:1/0,g=p?t.originX+t.width:-1/0;for(let y=f;y<=d;y++)for(let u of l.columns[y]){p||(u.box.x<x&&(x=u.box.x),u.box.x+u.box.w>g&&(g=u.box.x+u.box.w));let m=u.box.y-t.getVisualAxis(c,u.track),b=m+u.box.h;te(h,u.track,m,b)}for(let y of l.attachmentRanges)y.right<=x||y.left>=g||te(h,y.track,y.top,y.bottom);return h}};return{items:r.map(c=>{let a=c.createGeometry(s),l={x:0,y:0,w:0,h:0};Dt(l,a.regions);let h={geometry:a,box:l};n.set(c,h);for(let p of a.occupancy??a.regions){if(p.line===void 0)continue;let f=e[p.line],d=p.y-t.getVisualAxis(p.line,p.track),x=d+p.h,g=f.hostExtents.get(p.track),y=f.attachmentExtents.get(p.track);(d<Math.min(g?.top??1/0,y?.top??1/0)||x>Math.max(g?.bottom??-1/0,y?.bottom??-1/0))&&(o=!0),te(f.attachmentExtents,p.track,d,x),f.attachmentRanges.push({track:p.track,left:p.x,right:p.x+p.w,top:d,bottom:x})}return h}),needsRelayout:o}}function ri(r,t,e){let n=new Map,o=a=>{let l=r.hostExtents.get(a),h=r.attachmentExtents.get(a),p=l?{top:l.top,bottom:l.bottom}:null;h&&(p?Jt(p,h.top,h.bottom):p={top:h.top,bottom:h.bottom});let f=[];for(let x of a.groups){let g=x.members.map(o);if(g.every(m=>m===null))continue;let y=x.measure(g,e),u=null;for(let m of y){if(!m)continue;let b=m.offset+m.extent.top,w=m.offset+m.extent.bottom;u?Jt(u,b,w):u={top:b,bottom:w}}u&&f.push({group:x,placements:y,extent:u})}let d=(x,g)=>{p??={top:0,bottom:0};for(let y=0;y<x.group.members.length;y++){let u=x.placements[y];u&&n.set(x.group.members[y],g+u.offset)}Jt(p,g+x.extent.top,g+x.extent.bottom)};for(let x of f)x.group.place||d(x,0);for(let x of f){let g=x.group.place;if(!g)continue;d(x,g(p??{top:0,bottom:0},x.extent,e))}return p},s=o(t),i=new Map;if(!s)return{axes:i,height:0};let c=(a,l)=>{i.set(a,l);for(let h of a.groups)for(let p of h.members){let f=n.get(p);f!==void 0&&c(p,l+f)}};return c(t,-s.top),{axes:i,height:s.bottom-s.top}}var ee=class{min=1/0;max=-1/0;add(t){t<this.min&&(this.min=t),t>this.max&&(this.max=t)}};function Pe(r,t,e,n,o,s){if(!(r>0&&r<1))return;let i=1-r;s.add(i*i*i*t+3*i*i*r*e+3*i*r*r*n+r*r*r*o)}function ro(r,t,e,n,o){o.add(r),o.add(n);let s=-r+3*t-3*e+n,i=2*(r-2*t+e),c=t-r;if(Math.abs(s)<1e-12){Math.abs(i)>1e-12&&Pe(-c/i,r,t,e,n,o);return}let a=i*i-4*s*c;if(a<0)return;let l=Math.sqrt(a);Pe((-i+l)/(2*s),r,t,e,n,o),Pe((-i-l)/(2*s),r,t,e,n,o)}function co(r,t,e,n){n.add(r),n.add(e);let o=r-2*t+e;if(Math.abs(o)<1e-12)return;let s=(r-t)/o;if(!(s>0&&s<1))return;let i=1-s;n.add(i*i*r+2*i*s*t+s*s*e)}function St(r){let t=new ee,e=new ee,n=0,o=0,s=0,i=0;for(let c of r){if(c.op==="Z"){n=s,o=i;continue}c.op==="C"?(ro(n,c.cx1,c.cx2,c.x,t),ro(o,c.cy1,c.cy2,c.y,e)):c.op==="Q"?(co(n,c.cx,c.x,t),co(o,c.cy,c.y,e)):(t.add(c.x),e.add(c.y),c.op==="M"&&(s=c.x,i=c.y)),n=c.x,o=c.y}return Number.isFinite(t.min)?{x:t.min,y:e.min,w:t.max-t.min,h:e.max-e.min}:{x:0,y:0,w:0,h:0}}var ci=54.2813,ao=87.37505,ne=72.8125,ho=93.6719,ai=-27.4688,po=-7.9375,li=po+ho,hi=[{op:"M",x:28.1406,y:86.06255},{op:"C",cx1:28.1406,cy1:86.06255,cx2:30.4531,cy2:84.07815,x:32.7656,y:81.42185},{op:"C",cx1:33.7656,cy1:80.43755,cx2:34.0938,cy2:79.10935,x:34.0938,y:78.10935},{op:"C",cx1:34.0938,cy1:77.12505,cx2:33.7656,cy2:76.45315,x:33.0938,y:75.79685},{op:"L",x:29.4531,y:72.15625},{op:"C",cx1:28.7969,cy1:71.50005,cx2:28.4688,cy2:70.82815,x:28.4688,y:70.17185},{op:"C",cx1:28.4688,cy1:68.84375,cx2:29.4531,cy2:68.18755,x:29.4531,y:68.18755},{op:"C",cx1:29.4531,cy1:68.18755,cx2:47.6563,cy2:47.00005,x:50.6406,y:43.68755},{op:"C",cx1:53.2969,cy1:40.04685,cx2:54.2813,cy2:36.40625,x:54.2813,y:33.09375},{op:"C",cx1:54.2813,cy1:26.14065,cx2:50.3125,cy2:19.85935,x:47.3281,y:17.21875},{op:"L",x:31.4375,y:1.32812},{op:"C",cx1:30.4531,cy1:.32812,cx2:29.7969,cy2:0,x:28.7969,y:0},{op:"C",cx1:27.1406,cy1:0,cx2:25.8125,cy2:1.32812,x:25.8125,y:1.32812},{op:"C",cx1:25.8125,cy1:1.32812,cx2:23.5,cy2:3.3125,x:21.1875,y:5.95312},{op:"C",cx1:20.1875,cy1:6.95313,cx2:19.8594,cy2:7.9375,x:19.8594,y:8.9375},{op:"C",cx1:19.8594,cy1:9.92188,cx2:20.1875,cy2:10.59375,x:20.8594,y:11.25},{op:"L",x:24.5,y:14.89063},{op:"C",cx1:25.1563,cy1:15.5625,cx2:25.4844,cy2:16.21875,x:25.4844,y:16.875},{op:"C",cx1:25.4844,cy1:18.20315,cx2:24.5,cy2:19.20315,x:24.5,y:19.20315},{op:"C",cx1:24.5,cy1:19.20315,cx2:6.625,cy2:40.37505,x:3.64063,y:43.68755},{op:"C",cx1:1,cy1:47.32815,cx2:0,cy2:50.96875,x:0,y:54.28125},{op:"C",cx1:0,cy1:61.23435,cx2:3.96875,cy2:67.51565,x:6.95313,y:70.17185},{op:"L",x:22.8438,y:86.06255},{op:"C",cx1:23.8281,cy1:87.04685,cx2:24.8281,cy2:87.37505,x:25.4844,y:87.37505},{op:"C",cx1:27.1406,cy1:87.37505,cx2:28.1406,cy2:86.06255,x:28.1406,y:86.06255}],pi=[{op:"M",x:111.8751,y:21.5156},{op:"C",cx1:112.5313,cy1:20.1875,cx2:113.5313,cy2:18.2031,x:113.5313,y:16.875},{op:"C",cx1:113.5313,cy1:12.23438,cx2:109.8907,cy2:8.9375,x:105.2501,y:8.9375},{op:"C",cx1:103.9219,cy1:8.9375,cx2:101.6094,cy2:9.26563,x:100.2813,y:10.25},{op:"L",x:72.1563,y:31.7656},{op:"L",x:72.1563,y:28.4531},{op:"C",cx1:72.1563,cy1:16.54688,cx2:66.8594,cy2:8.26563,x:58.2501,y:.98437},{op:"C",cx1:57.2657,cy1:.32812,cx2:55.9376,cy2:0,x:55.2657,y:0},{op:"C",cx1:53.6251,cy1:0,cx2:52.9532,cy2:.98437,x:52.9532,y:.98437},{op:"C",cx1:51.6251,cy1:2.3125,cx2:49.3126,cy2:4.29687,x:48.3282,y:5.625},{op:"C",cx1:47.3282,cy1:6.9375,cx2:47.0001,cy2:7.9375,x:47.0001,y:8.9375},{op:"C",cx1:47.0001,cy1:9.92188,cx2:47.3282,cy2:10.57813,x:47.6563,y:11.25},{op:"C",cx1:49.9688,cy1:13.5625,cx2:50.9688,cy2:16.21875,x:50.9688,y:18.8594},{op:"C",cx1:50.9688,cy1:24.8125,cx2:46.3282,cy2:30.1094,x:41.0469,y:30.1094},{op:"C",cx1:39.3907,cy1:30.1094,cx2:37.7344,cy2:29.4531,x:36.4063,y:28.4531},{op:"L",x:12.9063,y:10.57813},{op:"C",cx1:11.5782,cy1:9.59375,cx2:9.5938,cy2:8.9375,x:7.9375,y:8.9375},{op:"C",cx1:3.6407,cy1:8.9375,cx2:0,cy2:12.57813,x:0,y:16.875},{op:"C",cx1:0,cy1:18.2031,cx2:.6563,cy2:20.1875,x:1.3125,y:21.5156},{op:"L",x:49.9688,y:90.3594},{op:"C",cx1:51.2969,cy1:92.3438,cx2:54.2813,cy2:93.6719,x:56.5938,y:93.6719},{op:"C",cx1:58.9063,cy1:93.6719,cx2:61.8907,cy2:92.3438,x:63.2188,y:90.3594},{op:"L",x:111.8751,y:21.5156}];function lo(r,t,e,n,o,s,i,c){let a=h=>o+(c?e-h:h)*i,l=h=>s+(c?n-h:h)*i;for(let h of t)h.op==="Z"?r.push(h):h.op==="C"?r.push({op:"C",cx1:a(h.cx1),cy1:l(h.cy1),cx2:a(h.cx2),cy2:l(h.cy2),x:a(h.x),y:l(h.y)}):h.op==="Q"?r.push({op:"Q",cx:a(h.cx),cy:l(h.cy),x:a(h.x),y:l(h.y)}):r.push({op:h.op,x:a(h.x),y:l(h.y)})}function fo(r,t,e){let n=e==="up"||e==="down",o=Math.max(1,Math.round(r/(t*.3))),s=n?Math.max(0,o-1):o,i=n?li+ne*s:ao+ne*(s-1),c=r/i,a=[];for(let p=0;p<s;p++)lo(a,hi,ci,ao,0,p*ne*c,c,e==="");n&&lo(a,pi,113.5313,ho,ai*c,(s*ne+po)*c,c,!1);let l=St(a);return e!=="up"?{commands:a,bounds:l}:{commands:a.map(p=>p.op==="Z"?p:p.op==="C"?{op:"C",cx1:l.x+l.w-(p.cx1-l.x),cy1:r-p.cy1,cx2:l.x+l.w-(p.cx2-l.x),cy2:r-p.cy2,x:l.x+l.w-(p.x-l.x),y:r-p.y}:p.op==="Q"?{op:"Q",cx:l.x+l.w-(p.cx-l.x),cy:r-p.cy,x:l.x+l.w-(p.x-l.x),y:r-p.y}:{op:p.op,x:l.x+l.w-(p.x-l.x),y:r-p.y}),bounds:{x:l.x,y:r-l.y-l.h,w:l.w,h:l.h}}}function fi(r){let t=r,e=r.ast;return(e.callName==="up"||e.callName==="down")&&Array.isArray(t.members)&&Array.isArray(e.contents)?t:null}var Fe=class extends T{static def={name:["arp","arpeggio"],description:"\u7436\u97F3",example:`@arp({1 ^ 3 ^ 5}) \u9ED8\u8BA4\u4ECE\u4F4E\u5230\u9AD8\uFF0C\u65E0\u7BAD\u5934
6
+ @arp({1 ^ 3 ^ 5}, direction=up) \u4ECE\u4F4E\u5230\u9AD8\uFF0C\u9876\u7AEF\u5E26\u7BAD\u5934
7
+ @arp({1 ^ 3 ^ 5}, direction=down) \u4ECE\u9AD8\u5230\u4F4E\uFF0C\u5E95\u7AEF\u5E26\u7BAD\u5934`,allowExtraArgs:!1,args:[{name:"content",type:"content",default:null},{name:"direction",type:"string",default:""}]};content;direction;size;get children(){return[this.content]}constructor(t,e,n,o=null){super(t,o);let[s,i]=this.getArgValue(e,n),c="";i!==""&&i!=="up"&&i!=="down"?n.diagnostics.push(new k("W_ARPEGGIO_INVALID_DIRECTION","@arp \u7684 direction \u53EA\u80FD\u662F up \u6216 down\uFF0C\u5DF2\u56DE\u9000\u5230\u65E0\u7BAD\u5934\u4E0A\u884C\u7436\u97F3",t)):c=i,this.content=s,this.direction=c,this.size=n.variables.fontsize,s.parent=this}loweringEnter(t,e){let n=null;t.isolateFromLoweringGroups(()=>{let s=t.trackedEvents(this.content,new M,e).flat();if(s.length!==1||!s[0].box)throw new C("E_ARPEGGIO_INVALID_CONTENT","@arp \u7684\u5185\u5BB9\u5FC5\u987B\u6070\u597D\u4EA7\u751F\u4E00\u4E2A\u540C\u8F68\u548C\u5F26",this.content.sourceSpan);n=s[0]});let o=fi(n);if(!o||o.members.length<2||o.members.some(s=>s.track!==e))throw new C("E_ARPEGGIO_INVALID_CONTENT","@arp \u53EA\u63A5\u53D7\u81F3\u5C11\u5305\u542B\u4E24\u4E2A\u6210\u5458\u7684\u540C\u8F68 @up/@down \u6298\u53E0\u4F53",this.content.sourceSpan);return[new $e(this,o)]}toString(t){let e=this.direction?`, direction=${this.direction}`:"";return`@arp(${this.content.toString(t)}${e})`}},uo=Fe,$e=class extends P{host;playbackMembers;hostX=0;markX=0;markCommands=[];constructor(t,e){super(),this.ast=t,this.host=e;let n=e.ast.contents.length,o=[...e.members.slice(n).reverse(),e.members[0],...e.members.slice(1,n)];this.playbackMembers=t.direction==="down"?o.reverse():o,this.T.copyFrom(e.T),this.mergeKey=e.mergeKey,this.initLayoutBox(),e.addon&&(this.addon={...e.addon}),e.addon=void 0,e.foldedInto=this}onTimeState(t){this.host.t.copyFrom(this.t),this.host.T.copyFrom(this.T),this.host.track=this.track,this.host.layoutLine=this.layoutLine,this.host.onTimeState?.(t)}prepareLayout(t){this.addon&&(this.host.addon=this.addon,this.addon=void 0),et(this.host,t);let e=this.ast.size,n=e*.16,{commands:o,bounds:s}=fo(this.host.box.h,e,this.ast.direction);this.markCommands=o,this.markX=-s.x,this.hostX=s.w+n,this.box.w=this.hostX+this.host.box.w,this.box.h=this.host.box.h,this.box.anchor=this.hostX+this.host.box.anchor,this.box.visualAxis=this.host.box.visualAxis;for(let i in this.host.ports){let c=this.host.ports[i];this.ports[i]={x:this.hostX+c.x,y:c.y}}}onPlaced(){this.host.box.x=this.box.x+this.hostX,this.host.box.y=this.box.y,this.host.onPlaced?.()}emitPlayback(t){t.play(this.host);let e=t.end.clone().sub(t.start),n=new M(1,8),o=e.clone().div(2).div(this.playbackMembers.length-1);n.compare(o)>0&&n.copyFrom(o);let s=new Map(this.playbackMembers.map((c,a)=>[c,a])),i=this;t.defer(c=>{let a;for(let l=c.events.length-1;l>=0;l--){let h=c.events[l];if(h.origins.some(p=>p.node===i)){a=h.origins[0];break}}if(a)for(let l of c.events){if(l.kind!=="note-on"&&l.kind!=="note-off"||l.origins[0]!==a)continue;let h=l.origins.find(f=>s.has(f.node))?.node,p=h?s.get(h):void 0;p&&(l.at.add(n.clone().mul(p)),l.kind==="note-off"&&l.at.compare(t.end)>0&&l.at.copyFrom(t.end))}})}paint(t){let e=this.box.x,n=this.box.y;t.drawPath(this.markCommands,{fill:"#000"},{x:e+this.markX,y:n,scaleX:1,scaleY:1}),this.host.paint(t);for(let o of this.host.decorations)o.paint(t)}};var Be=class extends T{static def={name:["bar","|"],description:"\u5C0F\u8282\u7EBF",example:`@bar(type, lengthEM) \u521B\u5EFA\u4E00\u4E2A\u5C0F\u8282\u7EBF
8
+ \u8BED\u6CD5\u7CD6:
9
+ - type0: '|' \u666E\u901A\u5C0F\u8282\u7EBF
10
+ - type1: '||' \u7EC8\u6B62\u5C0F\u8282\u7EBF \u5DE6\u7EC6\u53F3\u7C97
11
+ - type2: '|:' \u91CD\u590D\u5C0F\u8282\u7EBF \u5DE6\u7C97\u53F3\u7EC6
12
+ - type3: ':|'
13
+ - type4: ':|:' \u5DE6\u53F3\u53CD\u590D
14
+ `,allowExtraArgs:!1,args:[{name:"type",type:"number",default:0},{name:"length",type:"length",default:{value:1.25,unit:"em"}}]};static deSugarAtom(t,e,n){let o=e,s=0,i=t.slice(o,o+2);if(i==="||")s=1,o+=2;else if(i==="|:")s=2,o+=2;else if(i===":|")t[o+2]===":"?(s=4,o+=3):(s=3,o+=2);else if(t[o]==="|")s=0,o+=1;else return null;let c=new Map;return c.set("type",s),{next:o,node:{kind:"call",typed:!0,name:"bar",args:c,span:{start:e,end:o},syntaxKind:"atom"}}}type;size;constructor(t,e,n,o=null){super(t,o);let[s,i]=this.getArgValue(e,n);this.type=s,this.size=n.length2px(i)}loweringEnter(){return[this.type>=2?new He(this):new oe(this)]}toString(){return`@bar(${this.type}, ${this.size}px)`}},xo=Be,oe=class extends P{lines=[];repeatDots=[];constructor(t){super(),this.ast=t,this.mergeKey=G,this.initLayoutBox(),this.springConfig={alpha_L:128,alpha_R:128}}prepareHorizontal(t){let e=this;for(;e.foldedInto;)e=e.foldedInto;if(!D(e))return;let n=t.trackRuns.get(e.track),o=n?.indexOf(e)??-1;!n||o<0||t.registerHorizontalLayoutHook(e,e,({columns:s,start:i})=>{let c=s[i].find(f=>f.time===e);if(!c)return;let a=f=>{let d=t.columnOf(f);return d<0?void 0:s[d].find(x=>x.time===f)},l=o>0?a(n[o-1]):void 0;l&&(l.config.mu_R*=4,c.config.mu_L*=4);let h=n[o+1],p=h?a(h):void 0;p&&h.mergeKey!==G&&(c.config.mu_R*=4,p.config.mu_L*=4)})}prepareLayout(){let{type:t,size:e}=this.ast;this.lines.length=0;let n=[],o=e,s=Math.max(1,e*.065),i=s*2.6,c=s*1.8,a=s*.8,l=c+a,h=t===3||t===4,p=t===2||t===4,f=h?a*2+l:0;if(t===1||t===3||t===4?(this.lines.push({x:f,w:s}),f+=s+c,this.lines.push({x:f,w:i}),f+=i):t===2?(this.lines.push({x:f,w:i}),f+=i+c,this.lines.push({x:f,w:s}),f+=s):(this.lines.push({x:f,w:s}),f+=s),h){let x=a;n.push({x,y:o*.38}),n.push({x,y:o*.62})}if(p){let x=f+l;n.push({x,y:o*.38}),n.push({x,y:o*.62}),f=x+a}this.box.w=f,this.box.h=o;let d=t>=2?this.lines[0]:void 0;this.box.anchor=d?d.x+d.w/2:f/2,this.box.visualAxis=o/2;for(let x of this.lines)x.x-=this.box.anchor;this.repeatDots=n.map(x=>({x:x.x-this.box.anchor,y:x.y,r:a}))}paint(t){for(let e of this.lines)t.drawRect(this.box.x+this.box.anchor+e.x,this.box.y,e.w,this.box.h,{fill:"#000"});for(let e of this.repeatDots)t.drawCircle(this.box.x+this.box.anchor+e.x,this.box.y+e.y,e.r,{fill:"#000"})}},ze="repeat.start";function mo(r,t){return r.visits(r.seek(ze,t+1,-1)??0)}var He=class extends oe{playbackMarks(){return this.ast.type===3?[]:[ze]}playbackFlow(t){if(this.ast.type===2)return;let e=t(this);if(e!==void 0)return{range:[e,e],run:n=>n.visits(e)>1?void 0:{kind:"jump",column:n.seek(ze,e,-1)??0}}}};var yo="div",ht=at(yo);function nt(r,t){return`div.${r}.${t}`}function go(r,t){let e=r.ports[nt(t,"left")];e&&(e.claimed=!0)}function Ge(r){return Math.max(1,r*.055)}function*bo(r){for(let t=0;;t++){let e=!1,n=-1;for(let o=0;o<=r.length;o++){let s=r[o]?.ports,i=s?.[nt(t,"left")],c=s?.[nt(t,"right")];if((i||c)&&(e=!0),i&&c){n<0&&(n=o);continue}n>=0&&o-n>=2&&(yield{level:t,from:n,to:o-1}),n=-1}if(!e)return}}var We=class r extends T{static def={name:[yo,"/"],description:"\u51CF\u65F6\u7EBF",example:`@div(C1, 2): C1\u4E0B\u65B9\u521B\u5EFA2\u6839\u51CF\u65F6\u7EBF
15
+ @/({C1 C2 @dash()}, 3): C1\u3001C2\u548C\u589E\u65F6\u7EBF\u4E0B\u65B9\u521B\u5EFA3\u6839\u51CF\u65F6\u7EBF\u5E76\u8FDE\u63A5
16
+ \u8BED\u6CD5\u7CD6\uFF1A\u5728\u97F3\u7B26\u540E\u52A0\u659C\u6760'/'\uFF0C\u53EF\u4EE5\u591A\u4E2A
17
+ @div(C1, 2) === C1//
18
+ @div(C1 C2/ @dash(), 2) === {C1 C2/ @dash()}//
19
+ \u8BBE\u7F6E\u547D\u540D\u53C2\u6570\u524D\u7F00: div
20
+ `,allowExtraArgs:!1,args:[{type:"content",default:null},{name:"n",type:"number",default:1},{name:"autobeam",type:"boolean",default:!0}]};static deSugarAtom(t,e,n){let o=0,s=e;for(;s<n&&t[s]==="/";)o++,s++;return o===0?null:{next:s,node:{kind:"sugar",data:{class:r,n:o},span:{start:e,end:s}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==r)return null;let s=T.findLastFuncContentNode(t.nodes,t.nodes.length-1);if(!s)return n;if(s instanceof r)return s.n+=o.data.n,n;let i=new Map;i.set(0,s),i.set("n",o.data.n);let c=s.sourceSpan,a=new r({start:Math.min(c.start,o.span.start),end:Math.max(c.end,o.span.end)},i,t,null);return t.nodes.pop(),t.pushNode(a),n}static layoutDecorationHandler=(t,e)=>{let n=Math.max(0,Math.floor(Number(e)||0));if(n===0)return null;let o=t.ast.size*.14,s=Ge(t.ast.size),i=(n-1)*o+s,c=0,a=0,l=0;return{below:{order:0,gap:-t.ast.size*.08,height:i,place(h){c=t.ports["body.left"]?.x??0,a=t.ports["body.right"]?.x??t.box.w,l=h+s/2;for(let p=0;p<n;p++){let f=l+p*o;t.ports[nt(p,"left")]={x:c,y:f},t.ports[nt(p,"right")]={x:a,y:f}}}},paint(h){for(let p=0;p<n;p++){if(t.ports[nt(p,"left")].claimed)continue;let d=t.box.y+l+p*o;h.drawLine(t.box.x+c,d,t.box.x+a,d,{stroke:"#000",strokeWidth:s})}}}};loweringEnter(t){let e=this.n;return t.beginLoweringGroup(this,{onTemporal(n){if(e===0)return;let o=n.addon??={};o[ht]=(Number(o[ht])||0)+e,n.T.divPow2(e)}}),[]}loweringExit(t){return t.endLoweringGroup(this),[]}content;n;autoBeamEnabled;get children(){return[this.content]}timeFlowModel(){return{children:[this.content],mode:"sequence"}}constructor(t,e,n,o=null){super(t,o),[this.content,this.n,this.autoBeamEnabled]=this.getArgValue(e,n),this.content.parent=this;let s=Math.max(0,Math.trunc(this.n));s!==this.n&&(n.diagnostics.push(new k("W_DIV_INVALID_N",`@div \u7684\u6570\u91CF\u53C2\u6570 n \u5FC5\u987B\u4E3A\u975E\u8D1F\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A ${s}`,this.sourceSpan)),this.n=s)}toString(t){return`@div(${this.content.toString(t)}, ${this.n})`}},At=We;function Lt(r,t,e){return new Pt(r,t,e)}function wo(r){let t=new Map;for(let n of r.columns)for(let o of n){if(!D(o))continue;let s=t.get(o.layoutLine);s||(s=new Map,t.set(o.layoutLine,s));let i=s.get(o.track);i?i.push(o):s.set(o.track,[o])}let e=new Map;for(let[n,o]of t)for(let[s,i]of o)for(let c=0;c<i.length;c++)e.set(i[c],{line:n,track:s,index:c});for(let n of r.attachments)if(!(!(n instanceof Pt)||!n.explicit))for(let o=1;o<n.endPoints.length;o++){let s=n.endPoints[o-1],i=n.endPoints[o];if(!D(s)||!D(i))continue;let c=e.get(s),a=e.get(i);if(!(s!==i&&c!==void 0&&a!==void 0&&c.line===a.line&&c.track===a.track&&a.index===c.index+1))throw new C("E_NON_ADJACENT_BEAM","@beam \u7684\u7AEF\u70B9\u5FC5\u987B\u6309\u65F6\u95F4\u987A\u5E8F\u8FDE\u63A5\u540C\u4E00\u8F68\u9053\u3001\u540C\u4E00\u8C31\u9762\u884C\u4E2D\u7684\u76F8\u90BB\u53EF\u89C1\u5143\u7D20",n.sourceSpan)}}function Co(r){let t=new Set;for(let e of r)if(!(!(e instanceof Pt)||!e.explicit))for(let n of e.endPoints)t.add(n);return t}var Pt=class{layer="foreground";endPoints;explicit;sourceSpan;fontSize;strokeWidth;constructor(t,e,n){this.endPoints=t,this.explicit=e,this.sourceSpan=n,this.fontSize=t.reduce((o,s)=>D(s)?Math.max(o,s.ast.size):o,0),this.strokeWidth=Ge(this.fontSize)}prepareHorizontal(t){let e=new Set(this.endPoints);for(let n of t)for(let o of n.trackRuns.values())for(let s=1;s<o.length;s++){let i=o[s-1],c=o[s];!e.has(i)||!e.has(c)||(i.springConfig.alpha_R=i.springConfig.alpha_R*.8,c.springConfig.alpha_L=c.springConfig.alpha_L*.8)}}createGeometry(t){let e=this.collectLines(t),n=this.strokeWidth;return{regions:e.map(s=>({x:Math.min(s.start.x,s.end.x),y:s.start.y-n/2,w:Math.abs(s.end.x-s.start.x),h:n,line:s.line,track:s.track})),paint(s){for(let i of e)s.drawLine(i.start.x,i.start.y,i.end.x,i.end.y,{stroke:"#000",strokeWidth:n})}}}absolutePort(t,e){let n=t.ports[e];return{x:t.box.x+n.x,y:t.box.y+n.y}}collectLines(t){let e=[],n=this.endPoints.filter(D);if(n.length<2)return e;for(let{level:o,from:s,to:i}of bo(n)){let c=[];for(let a=s;a<=i;a++){let l=n[a];c.push({left:this.absolutePort(l,nt(o,"left")),right:this.absolutePort(l,nt(o,"right")),line:l.layoutLine,track:l.track,node:l})}this.addSystemLines(c,t,o,e)}if(e.length===0&&this.explicit){let o=this.fontSize*.12,s=n.map(i=>{let c={x:i.box.x+i.box.anchor,y:i.box.y+i.box.h+o};return{left:c,right:c,line:i.layoutLine,track:i.track,node:i}});this.addSystemLines(s,t,null,e)}return e}addSystemLines(t,e,n,o){let s=Math.min(...t.map(h=>h.line)),i=Math.max(...t.map(h=>h.line)),c=t[0].track,a=e.getVisualAxis(t[0].line,c),l=t[0].left.y-a;for(let h=s;h<=i;h++){let p=t.filter(u=>u.line===h).sort((u,m)=>u.left.x-m.left.x);if(p.length===0){let m=e.getVisualAxis(h,c)+l;o.push({start:{x:e.originX,y:m},end:{x:e.originX+e.width,y:m},line:h,track:c});continue}let f=p[0],d=p[p.length-1],x=f.left.y,g={x:f.left.x,y:x},y={x:d.right.x,y:x};if(h>s&&(g.x=e.originX),h<i&&(y.x=e.originX+e.width),!(g.x===y.x&&s===i)){if(n!==null)for(let u of p)go(u.node,n);o.push({start:g,end:y,line:h,track:f.track})}}}};function So(r){let t=[],e=Math.max(0,Math.floor(Number(r.addon?.[ht])||0)),n=i=>{t.push(i),e-=Math.max(0,i.n)},o=r.ast.parent;for(;o&&e>0;)o instanceof At&&n(o),o=o.parent;let s=i=>{for(let c of i.children??[]){if(e<=0)return;c instanceof At&&n(c),s(c)}};return s(r.ast),t}function ui(r){let t=new Map,e=new Map;for(let n of r.columns)for(let o of n){if(!D(o))continue;let s=So(o);if(s.length===0)continue;let i=[];for(let c of s){let a=t.get(c);a||(a={owner:c,nodes:[]},t.set(c,a)),a.nodes.push(o),i.push(a)}e.set(o,i)}return{scopes:[...t.values()],nodeScopes:e}}function xi(r){let t=new Set(r.map(e=>e.owner));return r.filter(e=>{let n=e.owner.parent;for(;n;){if(n instanceof At&&t.has(n))return!1;n=n.parent}return!0})}function mi(r){let t=1/0,e=-1/0;for(let n of r){t=Math.min(t,n.ast.sourceSpan.start),e=Math.max(e,n.ast.sourceSpan.end);for(let o of So(n))t=Math.min(t,o.sourceSpan.start),e=Math.max(e,o.sourceSpan.end)}return{start:t,end:e}}function Ao(r){return Lt(r,!1,mi(r))}function di(r,t){let e=[];for(let n of xi(r)){let o=new Map;for(let s of n.nodes){let i=o.get(s.track);i?i.push(s):o.set(s.track,[s])}for(let s of o.values()){let i=[],c=()=>{i.length>=2&&e.push(Ao(i)),i=[]};for(let a of s){if(t.has(a)){c();continue}i.push(a)}c()}}return e}function yi(r){return Math.floor(r.numerator/r.denominator)}function gi(r,t,e){let n=[],o=new Map,s=new Map,i=new M,c=new M;for(let h of r.columns)for(let p of h){let f=s.get(p.layoutLine);(f===void 0||p.t.compare(f)<0)&&s.set(p.layoutLine,p.t)}let a=h=>{let p=o.get(h);p&&(o.delete(h),p.nodes.length>=2&&n.push(Ao(p.nodes)))},l=()=>{for(let h of[...o.keys()])a(h)};for(let h of r.columns){let p=h.find(f=>f.mergeKey===G);p&&(l(),i.copyFrom(p.t));for(let f of h){if(f.mergeKey===G)continue;let d=D(f)?t.get(f):void 0,x=d?.every(v=>v.nodes.length===1)??!1,g=d?.every(v=>v.owner.autoBeamEnabled)??!1;if(!(D(f)&&x&&g&&f.T.compare(1)<0&&!e.has(f))){(D(f)||!f.T.isZero())&&a(f.track);continue}let u=s.get(f.layoutLine)??f.t,m=i.compare(u)>=0?i:u,b=yi(c.copyFrom(f.t).sub(m)),w=o.get(f.track);if(!w){o.set(f.track,{nodes:[f],line:f.layoutLine,beat:b,endTime:f.t.clone().add(f.T)});continue}let R=f.t.equals(w.endTime);if(f.layoutLine!==w.line||b!==w.beat||!R){a(f.track),o.set(f.track,{nodes:[f],line:f.layoutLine,beat:b,endTime:f.t.clone().add(f.T)});continue}w.nodes.push(f),w.endTime.copyFrom(f.t).add(f.T)}}return l(),n}function Lo(r){let{scopes:t,nodeScopes:e}=ui(r),n=Co(r.attachments);return[...di(t,n),...gi(r,e,n)]}var Ve=class extends T{static loweringAugment=Lo;static loweringFinalize=wo;static def={name:["beam"],description:"\u51CF\u65F6\u7EBF\u8FDE\u63A5",example:"@beam(label1, label2, ...): \u5C06\u591A\u4E2A\u5DF2\u6807\u8BB0\u97F3\u7B26\u6309\u987A\u5E8F\u8FDE\u63A5\u4E3A\u51CF\u65F6\u7EBF\u7EC4",allowExtraArgs:!0,extraArgType:"label",args:[]};endPoints=[];constructor(t,e,n,o=null){super(t,o);for(let[,i]of e){let c=i instanceof T?i:n.parseArgWithType(i.valueSpan,"label",t.start);c instanceof T&&this.endPoints.push(c)}let s=n.labelableNodes.length-1;for(;this.endPoints.length<2&&s>=0;){let i=n.labelableNodes[s--];!i||this.endPoints.includes(i)||this.endPoints.unshift(i)}if(this.endPoints.length<2)throw new C("E_NOT_ENOUGH_ARGS","@beam \u81F3\u5C11\u9700\u8981\u4E24\u4E2A\u7AEF\u70B9",t)}loweringEnter(t){let e=[];for(let n of this.endPoints){let o=t.getTemporalNodes(n).at(-1);for(;o?.foldedInto;)o=o.foldedInto;o&&e.push(o)}return e.length<2?(t.diagnostics.push(E.warning.UnresolvedEndpoint("beam",this.sourceSpan)),[]):(t.addAttachment(Lt(e,!0,this.sourceSpan)),[])}},To=Ve;var Ye=class extends T{static def={name:["box"],description:"\u7ED9\u76EE\u6807\u7ED3\u6784\u6216\u5BF9\u8C61\u52A0\u5916\u6846",example:"@box(content, padding=0.2em, stroke=0.08em, width=-1px)",allowExtraArgs:!1,args:[{type:"content",default:null},{name:"padding",type:"length",default:{value:0,unit:"em"}},{name:"stroke",type:"length",default:{value:1,unit:"px"}},{name:"width",type:"length",default:{value:-1,unit:"px"}}]};target;padding;stroke;width;get children(){return[this.target]}timeFlowModel(){return{children:[this.target],mode:"sequence"}}loweringEnter(t){let e=[],n=[];return t.beginLoweringGroup(this,{attachment:new Ke(e,n,this),onTemporal(o){D(o)&&e.push(o)},onAttachment(o){lt(o)&&n.push(o)}}),[]}loweringExit(t){return t.endLoweringGroup(this),[]}constructor(t,e,n,o=null){super(t,o);let[s,i,c,a]=this.getArgValue(e,n);s.parent=this,this.target=s,this.padding=Math.max(0,n.length2px(i)),this.stroke=Math.max(0,n.length2px(c)),this.width=n.length2px(a)}},Eo=Ye,Ke=class{layer="background";temporalMembers;childAttachments;owner;fixedStart=null;wallOffset=0;get sourceSpan(){return this.owner.sourceSpan}constructor(t,e,n){this.temporalMembers=t,this.childAttachments=e,this.owner=n}prepareHorizontal(t){let e=this.temporalMembers[0]?.layoutLine;if(e===void 0)return;if(this.temporalMembers.some(h=>h.layoutLine!==e))throw new C("E_BOX_CROSS_LINE","@box \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8D8A\u8C31\u9762\u884C",this.owner.sourceSpan);if(this.owner.width<=0)return;let n=t[e];if(!n)return;let o=null,s=null,i=1/0,c=-1/0,a=0,l=0;for(let h of this.temporalMembers){let p=n.columnOf(h);if(p<0)continue;let f=h.box.anchor,d=h.box.w-f;p<i?(i=p,o=h,a=f):p===i&&(a=Math.max(a,f)),p>c?(c=p,s=h,l=d):p===c&&(l=Math.max(l,d))}if(!(!o||!s)){if(this.owner.width<a+l-1e-6)throw new C("E_BOX_WIDTH_TOO_SMALL","@box \u7684\u5BBD\u5EA6\u5C0F\u4E8E\u9996\u672B\u5143\u7D20\u7684\u56FA\u6709\u5BBD\u5EA6",this.owner.sourceSpan);n.registerHorizontalLayoutHook(o,s,({columns:h,rows:p,start:f,end:d,X:x,fixed:g,options:y})=>{if(g[f-1]||g[d])throw new C("E_BOX_CONSTRAINT_CROSSING","\u5B9A\u5BBD @box \u53EF\u4EE5\u5D4C\u5957\uFF0C\u4F46\u4E0D\u80FD\u90E8\u5206\u4EA4\u53C9",this.owner.sourceSpan);let u=x.subarray(f,d+1);wt(h.slice(f,d+1),p,u,g.subarray(f,d),this.owner.width,y,0);let m=u[u.length-1]-u[0]+a+l;if(Math.abs(m-this.owner.width)>1e-6)throw new C("E_BOX_CONSTRAINT_CONFLICT","\u591A\u4E2A @box \u4E3A\u76F8\u540C\u5185\u5BB9\u6307\u5B9A\u4E86\u4E0D\u540C\u5BBD\u5EA6",this.owner.sourceSpan);this.fixedStart=o,this.wallOffset=-u[0]})}}createGeometry(t){let{padding:e,stroke:n}=this.owner,o={x:0,y:0,w:0,h:0},s=[...this.temporalMembers.map(l=>l.box),...this.childAttachments.map(l=>t.getAttachmentBox(l))];if(!Dt(o,s.filter(l=>l.w>0||l.h>0)))return{regions:[],paint(){}};let i=e+n/2,a={x:(this.fixedStart?this.fixedStart.box.x+this.fixedStart.box.anchor+this.wallOffset:o.x)-i,y:o.y-i,w:(this.fixedStart?this.owner.width:o.w)+i*2,h:o.h+i*2};return{regions:[a],paint(l){let h=n/2;l.drawRect(a.x+h,a.y+h,Math.max(0,a.w-n),Math.max(0,a.h-n),{stroke:"#000",strokeWidth:n})}}}};var Ue=class extends T{static def={name:["dash","-"],description:"\u589E\u65F6\u7EBF",example:`@dash() \u521B\u5EFA\u4E00\u6839\u589E\u65F6\u7EBF
21
+ \u8BED\u6CD5\u7CD6: \u4E00\u4E2A '-' \u4EE3\u8868\u4E00\u4E2A @dash()
22
+ `,allowExtraArgs:!1,args:[]};static deSugarAtom(t,e,n){if(t[e]!=="-")return null;let o={kind:"call",typed:!0,name:"-",args:new Map,span:{start:e,end:e+1},syntaxKind:"atom"};return{next:e+1,node:o}}size;constructor(t,e,n,o=null){super(t,o),this.size=n.variables.fontsize}loweringEnter(){return[new Xe(this)]}toString(){return"-"}},_o=Ue,Xe=class extends P{lineWidth=0;lineY=0;constructor(t){super(),this.ast=t,this.T.set(1),this.mergeKey=J,this.initLayoutBox()}onTimeState(t){this.playbackState={bpm:t.bpm}}prepareLayout(){let t=this.ast.size;this.lineWidth=t*.42,this.box.w=this.lineWidth,this.box.h=t,this.box.anchor=this.lineWidth/2,this.lineY=t*.5,this.box.visualAxis=this.lineY}emitPlayback(t){let e=t.start.clone(),n=t.end.clone(),o=t.track,s=this.ast.sourceSpan;t.defer(i=>{let c;for(let a=i.events.length-1;a>=0;a--){let l=i.events[a];if(!(l.kind!=="note-off"||l.origins.at(-1).node.track!==o)){if(c===void 0){if(!l.at.equals(e))continue;c=l.origins[0]}else if(l.origins[0]!==c)break;l.at.equals(e)&&l.at.copyFrom(n)}}c===void 0&&i.diagnostics.push(new k("W_PLAYBACK_SUSTAIN_WITHOUT_TARGET","\u589E\u65F6\u7EBF\u524D\u6CA1\u6709\u53EF\u5EF6\u7EED\u7684\u53D1\u58F0\u97F3\u7B26",s))})}paint(t){t.drawLine(this.box.x,this.box.y+this.lineY,this.box.x+this.lineWidth,this.box.y+this.lineY,{stroke:"#000",strokeWidth:Math.max(1,this.ast.size*.1)})}};var No="dot",vo=at(No);function ko(r){let t=2**r;return[2*t-1,t]}var Ze=class r extends T{static def={name:[No,"."],description:"\u9644\u70B9",example:`@dot(C1, 2): C1\u53F3\u4FA7\u521B\u5EFA2\u4E2A\u70B9 \u4EC5\u63A5\u6536\u4E00\u4E2A\u53EF\u63A5\u6536\u5143\u7D20
23
+ \u8BED\u6CD5\u7CD6\uFF1A\u5728\u76EE\u6807\u540E\u52A0'.'\uFF0C\u53EF\u4EE5\u591A\u4E2A
24
+ @dot(C1, 2) === C1..
25
+ {1^2}. === {1.^2}
26
+ @dot(C1 C2/ @dash(), 2) \u62A5\u9519 \u56E0\u4E3A\u70B9\u53EA\u80FD\u63A5\u6536\u4E00\u4E2A\u53EF\u89C1\u65F6\u95F4\u5143\u7D20
27
+ `,allowExtraArgs:!1,args:[{type:"content",default:null},{name:"n",type:"number",default:1}]};static deSugarAtom(t,e,n){let o=0,s=e;for(;s<n&&t[s]===".";)o++,s++;return o===0?null:{next:s,node:{kind:"sugar",data:{class:r,n:o},span:{start:e,end:s}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==r)return null;let s=T.findLastFuncContentNode(t.nodes,t.nodes.length-1);if(!s)return n;if(s instanceof r)return s.n+=o.data.n,n;let i=new Map;i.set(0,s),i.set("n",o.data.n);let c=s.sourceSpan,a=new r({start:Math.min(c.start,o.span.start),end:Math.max(c.end,o.span.end)},i,t,null);return t.nodes.pop(),t.pushNode(a),n}static layoutDecorationHandler=(t,e)=>{let n=Math.max(0,Math.floor(Number(e)||0));if(n===0)return null;let o=t.ast.size*.075,s=t.ast.size*.12,i=t.ports.dot??{x:t.box.w,y:t.box.visualAxis},c=i.x+s+o,a=o*2+s,l=c+(n-1)*a+o;return t.box.w=Math.max(t.box.w,l),{paint(h){let p=t.box.y+i.y;for(let f=0;f<n;f++)h.drawCircle(t.box.x+c+f*a,p,o,{fill:"#000"})}}};loweringEnter(t){let e=this.n,n={temporalCount:0,onTemporal(o){if(n.temporalCount++,e===0)return;let s=o.addon??={},i=Number(s[vo])||0,c=i+e,[a,l]=ko(c),[h,p]=ko(i);o.T.mul(a*p,l*h),s[vo]=c}};return t.beginLoweringGroup(this,n),[]}loweringExit(t){let e=t.endLoweringGroup(this);if(e.temporalCount!==1)throw new C("E_DOT_INVALID_CONTENT",`\u51FD\u6570 @dot \u53EA\u80FD\u63A5\u6536 1\u4E2A\u5143\u7D20\uFF0C\u4F46\u627E\u5230\u4E86 ${e.temporalCount} \u4E2A`,this.sourceSpan);return[]}timeFlowModel(){return{children:[this.content],mode:"sequence"}}content;n;get children(){return[this.content]}constructor(t,e,n,o=null){super(t,o),[this.content,this.n]=this.getArgValue(e,n),this.content.parent=this;let s=Math.max(0,Math.trunc(this.n));s!==this.n&&(n.diagnostics.push(new k("W_DOT_INVALID_N",`@dot \u7684\u6570\u91CF\u53C2\u6570 n \u5FC5\u987B\u4E3A\u975E\u8D1F\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A ${s}`,this.sourceSpan)),this.n=s)}toString(t){return`@dot(${this.content.toString(t)}, ${this.n})`}},Mo=Ze;var je=class extends T{static def={name:["dyn"],description:"\u6E10\u5F3A\u6E10\u5F31",example:`@dyn(from, to, dv) \u5728\u4E24\u4E2A\u6807\u7B7E\u4E4B\u95F4\u7EBF\u6027\u6539\u53D8\u529B\u5EA6
28
+ from\u3001to \u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68\u4E14\u65F6\u95F4\u4E0D\u540C
29
+ dv \u4E3A\u6B63\u65F6\u6E10\u5F3A\uFF0C\u4E3A\u8D1F\u65F6\u6E10\u5F31\uFF1B\u53D8\u5316\u91CF\u53E0\u52A0\u5728\u6BCF\u4E2A\u97F3\u7B26\u539F\u6709\u529B\u5EA6\u4E0A
30
+
31
+ 1 ^ $p 2@a 3 4@b
32
+ @dyn(a, b, 24)`,allowExtraArgs:!1,args:[{name:"from",type:"label",default:null},{name:"to",type:"label",default:null},{name:"dv",type:"number",default:null}]};static loweringFinalize=t=>{let e=t.attachments.filter(o=>o instanceof Ft);if(e.length===0)return;let n=[];for(let o of t.astToTemporal.values())for(let s of o){let i=s.playbackState?.velocity;if(i===void 0)continue;let c=s;for(;c.foldedInto;)c=c.foldedInto;n.push({node:s,host:c,velocity:i,increment:0})}n.sort((o,s)=>o.host.t.compare(s.host.t)||o.node.order-s.node.order);for(let o of e){let s=o.end.playbackState?.velocity??n.find(a=>a.host===o.toHost)?.velocity;if(s===void 0)throw new Error("@dyn end endpoint has no velocity-bearing member");let i=n.find(a=>a.host.track===o.track&&a.host.t.compare(o.toHost.t)>0&&a.velocity!==s)?.host.t,c=o.toHost.t.clone().sub(o.fromHost.t);for(let a of n){if(a.host.track!==o.track||a.host.t.compare(o.fromHost.t)<0||i&&a.host.t.compare(i)>=0)continue;let h=a.host.t.compare(o.toHost.t)>=0?1:a.host.t.clone().sub(o.fromHost.t).div(c).toNumber();a.increment+=o.dv*h}}for(let o of n){if(o.increment===0)continue;let s=Math.max(1,Math.min(127,o.velocity+o.increment));o.node.playbackState={...o.node.playbackState,velocity:s}}};from;to;dv;size;loweringEnter(t){let e=t.getTemporalNodes(this.from).at(0),n=t.getTemporalNodes(this.to).at(-1);if(!e||!n)return t.diagnostics.push(E.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];let o=e,s=n;for(;o.foldedInto;)o=o.foldedInto;for(;s.foldedInto;)s=s.foldedInto;if(!D(o)||!D(s))return t.diagnostics.push(E.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];if(o.track!==s.track)throw new C("E_DYN_CROSS_TRACK","@dyn \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68",this.sourceSpan);if(o.t.equals(s.t))throw new C("E_DYN_ZERO_SPAN","@dyn \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u4E0D\u540C\u65F6\u95F4",this.sourceSpan);return o.t.compare(s.t)<0?t.addAttachment(new Ft(this,n,o,s)):t.addAttachment(new Ft(this,e,s,o)),[]}constructor(t,e,n,o=null){super(t,o);let[s,i,c]=this.getArgValue(e,n),a=c;if(!Number.isFinite(a)||a===0)throw new C("E_DYN_INVALID_DELTA","@dyn \u7684 dv \u5FC5\u987B\u662F\u975E\u96F6\u6709\u9650\u6570",t);a=Math.max(-127,Math.min(127,a)),a!==c&&n.diagnostics.push(new k("W_DYN_DELTA_CLAMPED",`@dyn \u7684 dv \u5FC5\u987B\u5728 -127 \u5230 127 \u4E4B\u95F4\uFF0C\u5DF2\u88AB\u9650\u5236\u4E3A ${a}`,t)),this.from=s,this.to=i,this.dv=a,this.size=n.variables.fontsize}toString(t){let e=n=>n.label??n.toString(t);return`@dyn(${e(this.from)}, ${e(this.to)}, ${this.dv})`}},Ro=je,Ft=class{ast;end;fromHost;toHost;layer="foreground";constructor(t,e,n,o){this.ast=t,this.end=e,this.fromHost=n,this.toHost=o}get sourceSpan(){return this.ast.sourceSpan}get dv(){return this.ast.dv}get track(){return this.fromHost.track}createGeometry(t){let e=x=>{let g=t.lines[x.layoutLine];return{line:x.layoutLine,view:g,column:g?.columnOf(x)??-1}},n=e(this.fromHost),o=e(this.toHost);if(!n.view||!o.view||n.column<0||o.column<0)return{regions:[],paint(){}};let s=[],i=this.ast.size;for(let x=n.line;x<=o.line;x++){let g=t.lines[x],y=x===n.line?n.column:0,u=x===o.line?o.column:g.columns.length-1,m=-1,b=-1;for(let w=y;w<=u;w++)for(let R of g.columns[w])R.track===this.track&&(m=m<0?w:m,b=w,i=Math.max(i,R.ast.size));m<0||s.push({line:x,startX:x===n.line?this.fromHost.box.x:this.lineEntryX(t,x),endX:x===o.line?this.toHost.box.x+this.toHost.box.w:this.lineRightX(t,x),columns:[m,b]})}for(let x of s)x.line>n.line&&(x.startX-=i/4);let c=Math.max(.75,i*.035),a=s.filter(x=>x.startX!==x.endX),l=a.reduce((x,g)=>x+Math.abs(g.endX-g.startX),0);if(l===0)return{regions:[],paint(){}};let h=i*.4,p=c/2,f=0,d=a.map(x=>{let g=Math.abs(x.endX-x.startX),y=f/l,u=(f+g)/l;f+=g;let m=t.getRangeExtents(x.line,x.columns).get(this.track),b=t.getVisualAxis(x.line,this.track),w=m?b+m.top:b;return{line:x.line,startX:x.startX,endX:x.endX,lineY:w-i*.62,startOpen:h*(this.dv>0?y:1-y),endOpen:h*(this.dv>0?u:1-u)}});return{regions:d.map(x=>({x:Math.min(x.startX,x.endX)-p,y:x.lineY-Math.max(x.startOpen,x.endOpen)/2-p,w:Math.abs(x.endX-x.startX)+c,h:Math.max(x.startOpen,x.endOpen)+c,line:x.line,track:this.track})),paint(x){let g={stroke:"#000",strokeWidth:c};for(let y of d)x.drawLine(y.startX,y.lineY-y.startOpen/2,y.endX,y.lineY-y.endOpen/2,g),x.drawLine(y.startX,y.lineY+y.startOpen/2,y.endX,y.lineY+y.endOpen/2,g)}}}lineEntryX(t,e){return t.lines[e].trackRuns.get(this.track)?.find(o=>!o.T.isZero())?.box.x??t.originX}lineRightX(t,e){let n=t.lines[e].trackRuns;if(n.size===0)return t.originX+t.width;let o=t.originX;for(let s of n.values())for(let i of s)o=Math.max(o,i.box.x+i.box.w);return o}};var Tt=.7,Io="shoulder";function Do(r,t){let e=r;typeof e.size=="number"&&(e.size*=t);for(let n of r.children??[])Do(n,t)}var qe=class r extends T{static def={name:["grace"],description:"\u501A\u97F3",example:`\u524D\u501A\u97F3: @grace(\u5BBF\u4E3B, \u501A\u97F3, side=pre) \u540E\u501A\u97F3: @grace(\u5BBF\u4E3B, \u501A\u97F3, side=post)
33
+ \u8BED\u6CD5\u7CD6\uFF1A'>' \u4E0E '<'\uFF0C\u7BAD\u5934\u6C38\u8FDC\u6307\u5411\u5BBF\u4E3B
34
+ 2>1 \u524D\u501A\u97F3\uFF1A2 \u662F 1 \u7684\u501A\u97F3\uFF0C\u753B\u5728 1 \u7684\u5DE6\u4E0A\u89D2
35
+ 1<2 \u540E\u501A\u97F3\uFF1A2 \u662F 1 \u7684\u501A\u97F3\uFF0C\u753B\u5728 1 \u7684\u53F3\u4E0A\u89D2
36
+ {3 2}>1 \u591A\u4E2A\u501A\u97F3\u7528\u5927\u62EC\u53F7\u62EC\u8D77\u6765
37
+ 1>2>3 \u5141\u8BB8\u5D4C\u5957\uFF1A1 \u662F 2 \u7684\u501A\u97F3\uFF0C2 \u662F 3 \u7684\u501A\u97F3
38
+ \u501A\u97F3\u9ED8\u8BA4\u5C31\u662F\u516B\u5206\u97F3\u7B26\uFF08\u81EA\u5E26\u4E00\u6761\u51CF\u65F6\u7EBF\uFF09\uFF0C\u518D\u5199 '/' \u53D8\u6210\u5341\u516D\u5206\u97F3\u7B26`,allowExtraArgs:!0,args:[{name:"host",type:"content",default:null},{name:"grace",type:"content",default:null},{name:"side",type:"string",default:"pre"}]};labelable(){return T.findLabelable(this.host)}static deSugarAtom(t,e,n){let o=t[e];switch(o){case">":o="pre";break;case"<":o="post";break;default:return null}return{next:e+1,node:{kind:"sugar",data:{class:r,side:o},span:{start:e,end:e+1}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.kind!=="sugar"||o.data?.class!==r)return null;let s=o.data.side,i=t.nodes.length-1;for(;i>=0&&t.nodes[i]instanceof H;)i--;if(i<0)throw new C("E_GRACE_NO_TARGET","@grace\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u76EE\u6807",o.span);let c=t.nodes[i],a=i;if(c instanceof Q){let h=c.target;for(;h&&!t.nodes.includes(h);)h=h.parent;for(let p=i-1;p>=0;p--)if(t.nodes[p]===h){c=new z({start:h.sourceSpan.start,end:c.sourceSpan.end},t.nodes.slice(p,i+1),null),a=p;break}}let l=t.nodes;t.nodes=[],t.makeNodes(e,n);for(let h=0;h<t.nodes.length;h++){let p=t.nodes[h];if(p instanceof H)continue;let f=s==="pre"?r.attachPre(c,p,o.span,t):r.create(t,o.span,"post",c,p);for(l.length=a,l.push(f);++h<t.nodes.length;)l.push(t.nodes[h]);return t.nodes=l,e.length}throw new C("E_GRACE_NO_TARGET","@grace\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u76EE\u6807",o.span)}host;grace;side="pre";size;static attachPre(t,e,n,o){if(e instanceof r&&e.side==="pre"){let s=e,i=1;for(;s.grace instanceof r&&s.grace.side==="pre";)s=s.grace,i++;let c=new Map;c.set(0,s.grace),c.set(1,t);let a=Tt**i,l=new r(n,c,o,null,Tt*a);return l.size*=a,s.setGrace(l,1),e}return r.create(o,n,"pre",e,t)}static create(t,e,n,o,s){let i=new Map;return i.set(0,o),i.set(1,s),i.set("side",n),new r(e,i,t)}get children(){let t=[];return this.host&&t.push(this.host),this.grace&&t.push(this.grace),t}constructor(t,e,n,o=null,s=Tt){if(super(t,o),this.size=n.variables.fontsize,[this.host,this.grace,this.side]=this.getArgValue(e,n),this.side!=="pre"&&this.side!=="post")throw new C("E_GRACE_INVALID_SIDE","@grace \u7684 side \u53C2\u6570\u5FC5\u987B\u662F 'pre' \u6216 'post'",t);this.adopt(this.host),this.setGrace(this.grace,s)}setGrace(t,e=Tt){Do(t,e),this.grace=t,this.adopt(t)}adopt(t){t.parent=this,this.sourceSpan.start=Math.min(this.sourceSpan.start,t.sourceSpan.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,t.sourceSpan.end)}loweringEnter(t,e){if(!this.host||!this.grace)throw new C("E_GRACE_MISSING_ARGS","@grace \u9700\u8981\u540C\u65F6\u7ED9\u51FA\u5BBF\u4E3B\u548C\u501A\u97F3",this.sourceSpan);let n=[],o=null;t.isolateFromLoweringGroups(()=>{let i=this.side==="pre"?[this.grace,this.host]:[this.host,this.grace];for(let c of i){let a=t.trackedEvents(c,new M,e).flat(),l=a.filter(D);if(a.some(h=>h.track!==e))throw new C("E_GRACE_PARALLEL_CONTENT","@grace \u7684\u5185\u5BB9\u4E0D\u80FD\u5305\u542B\u591A\u58F0\u90E8\u7ED3\u6784\uFF08& / @voices\uFF09\uFF1B\u8981\u5728\u501A\u97F3\u91CC\u53E0\u97F3\u8BF7\u7528 ^",c.sourceSpan);if(c===this.host){if(l.length!==1||l.length!==a.length)throw new C("E_GRACE_INVALID_HOST","@grace \u7684\u5BBF\u4E3B\u5FC5\u987B\u6070\u597D\u4EA7\u751F\u4E00\u4E2A\u53EF\u89C1 Temporal",c.sourceSpan);o=l[0]}else{if(l.length===0||l.length!==a.length)throw new C("E_GRACE_INVALID_CONTENT","@grace \u7684\u501A\u97F3\u5FC5\u987B\u53EA\u4EA7\u751F\u53EF\u89C1 Temporal\uFF0C\u4E14\u81F3\u5C11\u4E00\u4E2A",c.sourceSpan);n=l}}});let s=new Qe(this,o,n,this.side);for(let i of s.graceRuns)i.length<2||t.addAttachment(Lt([...i],!1,this.grace.sourceSpan));return[s]}toString(t){let e=this.host?.toString(t)??"",n=this.grace?.toString(t)??"";return`@grace(${e}, ${n}, side=${this.side})`}},Po=qe,bi=[{op:"M",x:0,y:0},{op:"C",cx1:-.01,cy1:.26,cx2:.14,cy2:.42,x:.29,y:.36}],wi=.07,Ci=.18,Oo=new M(3,4),Qe=class extends P{host;graces;graceRuns;side;hostOffset={x:0,y:0};graceOffsets=[];hookOrigin=null;constructor(t,e,n,o){super(),this.ast=t,this.host=e,this.graces=n,this.side=o,this.T.copyFrom(e.T),this.mergeKey=e.mergeKey,this.initLayoutBox(),e.addon&&(this.addon={...e.addon}),e.addon=void 0,e.foldedInto=this;let s=[],i=[];for(let c of n){if(c.foldedInto=this,c.T.isZero()){i.length>0&&s.push(i),i=[];continue}i.push(c);let a=c.addon={...c.addon};a[ht]=(Number(a[ht])||0)+1,c.T.divPow2()}i.length>0&&s.push(i),this.graceRuns=s}onTimeState(t){this.host.T.copyFrom(this.T);let e=this.side==="pre"?[...this.graces,this.host]:[this.host,...this.graces];for(let n of e)n.t.copyFrom(this.t),n.track=this.track,n.layoutLine=this.layoutLine,n.onTimeState?.(t)}emitPlayback(t){let e=new M;for(let l of this.graces)e.add(l.T);let n=e.compare(Oo)>0?Oo:e,o=t.end.clone().sub(t.start),s=o.clone().mul(n),i=o.sub(s),c=t.start.clone(),a=l=>{for(let h of this.graces){if(h.T.isZero()||e.isZero()){t.play(h,l,new M);continue}let p=s.clone().mul(h.T).div(e);t.play(h,l,p),l.add(p)}};if(this.side==="pre"){let l=c.clone();a(l),t.play(this.host,l,i)}else t.play(this.host,c,i),a(c.clone().add(i))}prepareLayout(t){this.addon&&(this.host.addon=this.addon,this.addon=void 0);for(let g of this.graces)et(g,t);et(this.host,t);let n=this.ast.size*Tt,o=n*.16,s=n*.2,i=n*Ci,c=0,a=0,l=0;for(let g of this.graces)a=Math.max(a,g.box.visualAxis);this.graceOffsets=this.graces.map(g=>{let y=c;c+=g.box.w+o;let u=a-g.box.visualAxis;return l=Math.max(l,u+g.box.h),{x:y,y:u}}),this.graces.length>0&&(c-=o);let p=(this.host.ports[Io]?.y??0)-i-l,f=Math.max(0,-p),d=this.side==="pre"?0:this.host.box.w+s;this.hostOffset={x:this.side==="pre"?c+s:0,y:f};for(let g of this.graceOffsets)g.x+=d,g.y+=p+f;this.box.w=this.host.box.w+s+c,this.box.h=f+this.host.box.h,this.box.anchor=this.hostOffset.x+this.host.box.anchor,this.box.visualAxis=f+this.host.box.visualAxis;for(let g in this.host.ports){let y=this.host.ports[g];this.ports[g]={x:this.hostOffset.x+y.x,y:this.hostOffset.y+y.y}}this.ports[Io]??={x:this.box.anchor,y:this.hostOffset.y};let x=this.side==="pre"?this.graceRuns.at(-1)?.at(-1):this.graceRuns[0]?.[0];this.hookOrigin=x?{x:this.graceOffsets[this.graces.indexOf(x)].x+x.box.anchor,y:p+f+l}:null}onPlaced(){this.host.box.x=this.box.x+this.hostOffset.x,this.host.box.y=this.box.y+this.hostOffset.y,this.host.onPlaced?.(),this.graces.forEach((t,e)=>{t.box.x=this.box.x+this.graceOffsets[e].x,t.box.y=this.box.y+this.graceOffsets[e].y,t.onPlaced?.()})}paint(t){for(let s of[this.host,...this.graces]){s.paint(t);for(let i of s.decorations)i.paint(t)}if(!this.hookOrigin)return;let e=this.ast.size*Tt,n=this.hookOrigin,o=this.side==="pre"?1:-1;t.drawPath(bi,{stroke:"#000",strokeWidth:Math.max(.8,e*wi)},{x:this.box.x+n.x,y:this.box.y+n.y,scaleX:e*o,scaleY:e})}};var Et="sans-serif",tn="'Cascadia Mono', Consolas, 'Liberation Mono', 'Noto Sans Mono', monospace";function ie(r){return`${r.fontWeight??"normal"} ${r.fontSize}px ${r.fontFamily??Et}`}var se=class{measureText(t,e){let n=e.fontSize,o=e.fontFamily?.toLowerCase().includes("mono")??!1,s=0;for(let i of t)s+=i.charCodeAt(0)>127?1:o?.62:.58;return{w:Math.max(s*n,n*.25),h:n,baseline:n*.8}}},en=new se,Je=class{context;widths=new Map;constructor(t){this.context=t}clearCache(){this.widths.clear()}measureText(t,e){let n=ie(e),o=`${n}\0${t}`,s=this.widths.get(o);return s===void 0&&(this.context.font=n,s=this.context.measureText(t).width,this.widths.set(o,s)),{w:Math.max(s,e.fontSize*.25),h:e.fontSize,baseline:e.fontSize*.8}}};var Si=/[A-Za-z0-9_./-]/;function $o(r,t,e){let n=t+1;for(;n<e&&Si.test(r[n]);)n++;let o=r.slice(t+1,n);if(!o||n>=e||r[n]!=="(")return null;let s=n,i=1,c=0,a=null,l=!1,h=[],p=s+1,f=(x,g,y=!1)=>{let u=$t(r,p,x);if(!y&&u.start>=u.end)return;let m=Ai(r,u.start,u.end),b=m>u.start?$t(r,u.start,m):void 0,w=m>u.start?$t(r,m+1,u.end):u;h.push({span:u,valueSpan:w,nameSpan:b,equalsSpan:m>u.start?{start:m,end:m+1}:void 0,commaSpan:g===void 0?void 0:{start:g,end:g+1}})},d=(x,g)=>({name:o,span:{start:t,end:x},nameSpan:{start:t,end:s},openParenSpan:{start:s,end:s+1},closeParenSpan:g,args:h});for(n++;n<e;n++){let x=r[n];if(a){l?l=!1:x==="\\"?l=!0:x===a&&(a=null);continue}if(x==='"'){a=x;continue}if(x==="{")c++;else if(x==="}")c=Math.max(0,c-1);else if(x==="("&&c===0)i++;else if(x===")"&&c===0){if(--i)continue;return f(n),d(n+1,{start:n,end:n+1})}else x===","&&i===1&&c===0&&(f(n,n,!0),p=n+1)}return f(e),d(e)}var Fo=/\s/;function $t(r,t,e){let n=t,o=e;for(;n<o&&Fo.test(r[n]);)n+=1;for(;o>n&&Fo.test(r[o-1]);)o-=1;return{start:n,end:o}}function Ai(r,t=0,e=r.length){let n=0,o=0,s=null,i=!1;for(let c=t;c<e;c++){let a=r[c];if(s){i?i=!1:a==="\\"?i=!0:a===s&&(s=null);continue}if(a==='"')s=a;else if(a==="("&&o===0)n++;else if(a===")"&&o===0)n=Math.max(0,n-1);else if(a==="{")o++;else if(a==="}")o=Math.max(0,o-1);else if(a==="="&&n===0&&o===0)return c}return-1}function Bo(r,t,e){let n=1,o=null,s=!1;for(let i=t;i<e;i++){let c=r[i];if(o){s?s=!1:c==="\\"?s=!0:c===o&&(o=null);continue}if(c==='"')o=c;else if(c==="(")n++;else if(c===")"&&--n===0)return i}return-1}function _t(r,t,e){for(let n=t+1;n<e;n++)if(r[n]==="\\")n++;else if(r[n]==='"')return n;return-1}function pt(r){return r.length<2||!r.startsWith('"')||!r.endsWith('"')?r:r.slice(1,-1).replace(/\\(.)/gs,"$1")}function tt(r){return`"${r.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function zo(r,t,e){let n=1,o=null,s=!1;for(let i=t+1;i<e;i++){let c=r[i];if(o){s?s=!1:c==="\\"?s=!0:c===o&&(o=null);continue}if(c==='"')o=c;else if(c==="{")n++;else if(c==="}"&&(n--,n===0))return i}return-1}var Li=/\s|\(|\)|\{|\}|,/;function Ho(r,t,e){let n=t+1;for(;n<e&&!Li.test(r[n]);)n++;return n<=t+1?null:{label:r.slice(t+1,n),next:n}}var Ti=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]+)?$/i,Ei=["em","px"];function nn(r){let t=r.match(Ti);if(!t)return E.warning.InvalidLength(r,{start:0,end:r.length});let e=parseFloat(t[1]);if(t[2]){let n=t[2].toLowerCase();return Ei.includes(n)?{value:e,unit:n}:E.warning.InvalidLengthUnit(n,{start:t[1].length,end:r.length})}else return{value:e,unit:"px"}}var Wo=/^(true|false)$/;function _i(r,t){if(r)return r==="content"?void 0:r;if(Wo.test(t))return"boolean";if(t.startsWith('"'))return"string";if(!isNaN(Number(t)))return"number";if(!(nn(t)instanceof E))return"length"}var Go=22,vi=4,j=class r{static systemVariables={fontsize:{type:"length",default:Go},font:{type:"string",default:Et},numberfont:{type:"string",default:tn},strict:{type:"boolean",default:!1}};scopeDepth;source;syntax;diagnostics;variables;documentDeclarations;functions;deSugarAtomFns;deSugarRelationFns;labelableNodes;nodes;constructor(t){t instanceof r?(this.scopeDepth=t.scopeDepth+1,this.documentDeclarations=t.documentDeclarations,this.source=t.source,this.diagnostics=t.diagnostics,this.syntax=t.syntax,this.variables={...t.variables},this.functions=t.functions,this.deSugarAtomFns=t.deSugarAtomFns,this.deSugarRelationFns=t.deSugarRelationFns,this.labelableNodes=t.labelableNodes,this.nodes=[]):(this.scopeDepth=0,this.documentDeclarations={},this.source=t.source,this.diagnostics=t.diagnostics??[],this.syntax={tokens:(t.commentSpans??[]).map(e=>({kind:"comment",span:e})),calls:[]},this.variables=Object.fromEntries(Object.entries(r.systemVariables).map(([e,n])=>[e,n.default])),Object.assign(this.variables,t.variables),this.functions=t.functions??new Map,this.labelableNodes=t.labelableNodes??[],this.nodes=t.toConsume??[],t.functions?[this.deSugarAtomFns,this.deSugarRelationFns]=r.getDeSugarFns(this.functions.values()):(this.deSugarAtomFns=[],this.deSugarRelationFns=[]))}static getDeSugarFns(t){let e=new Set(t),n=[],o=[];for(let s of e){let i=s.deSugarAtom;i&&i!==T.deSugarAtom&&n.push(i);let c=s.deSugarRelation;c&&c!==T.deSugarRelation&&o.push(c)}return[n,o]}pushNode(t){this.nodes.push(t);let e=t.labelable?.();e!==void 0&&this.labelableNodes.push(e)}setVariable(t,e){Object.hasOwn(r.systemVariables,t)&&(t==="fontsize"&&e&&(e=this.length2px(e)),(e===void 0||e===""||e===0)&&(e=r.systemVariables[t].default)),this.variables[t]=e}registerFunctions(t){let e=this.functions;for(let n of t){let o=n.def;if(!o)continue;let s=Array.isArray(o.name)?o.name:[o.name];for(let i of s){if(e.has(i.toLowerCase()))throw new Error(`Duplicate function name detected: ${i}`);e.set(i.toLowerCase(),n)}}[this.deSugarAtomFns,this.deSugarRelationFns]=r.getDeSugarFns(this.functions.values())}parse(t=0,e=this.source.length){return this.makeNodes(this.parseGrammar(t,e)),this.nodes}parseSyntax(t=0,e=this.source.length){if(this.parseGrammar(t,e,!0),this.scopeDepth===0){let n=(o,s)=>o.span.start-s.span.start||o.span.end-s.span.end;this.syntax.tokens.sort(n),this.syntax.calls.sort(n)}return this.syntax}addSyntax(t,e){e&&e.start<e.end&&this.syntax.tokens.push({kind:t,span:e})}recordSyntax(t){if(t.kind==="brace"){this.addSyntax("punctuation",{start:t.span.start,end:t.span.start+1});let c=Math.min(this.source.length,t.span.end-1);this.source[c]==="}"&&this.addSyntax("punctuation",{start:c,end:c+1}),new r(this).parseSyntax(t.span.start+1,c);return}if(t.kind==="label"){this.addSyntax("label",t.span);return}if(t.kind==="sugar"||t.typed){this.addSyntax(t.syntaxKind??"operator",t.span);return}let{kind:e,typed:n,syntaxKind:o,...s}=t;this.syntax.calls.push(s),this.addSyntax("function",s.nameSpan),this.addSyntax("punctuation",s.openParenSpan),this.addSyntax("punctuation",s.closeParenSpan);let i=this.functions.get(s.name.toLowerCase())?.def;for(let c=0;c<s.args.length;c++){let a=s.args[c];this.addSyntax("property",a.nameSpan),this.addSyntax("punctuation",a.equalsSpan),this.addSyntax("punctuation",a.commaSpan);let l=a.nameSpan?this.source.slice(a.nameSpan.start,a.nameSpan.end).toLowerCase():void 0,h=i&&gt(i,l,c);if(h==="content")new r(this).parseSyntax(a.valueSpan.start,a.valueSpan.end);else{let p=this.source.slice(a.valueSpan.start,a.valueSpan.end),f=_i(h,p);f&&this.addSyntax(f,a.valueSpan)}}}makeNodes(t,e=0,n=t.length){t:for(;e<n;e++){let o=t[e];if(typeof o=="number"){let s=this.nodes.at(-1);s instanceof H&&s.sourceSpan.end===o?s.sourceSpan.end=o+1:this.nodes.push(new H({start:o,end:o+1},null));continue}switch(o.kind){case"call":this.pushNode(this.parseCallNode(o));break;case"brace":let s=new r(this);this.nodes.push(new z(o.span,s.parse(o.span.start+1,o.span.end-1),null));break;case"label":let i=this.labelableNodes.at(-1);i?i.label!==void 0?this.diagnostics.push(E.warning.TargetAlreadyLabeled(o.label,i.label,o.span)):(i.label=o.label,this.nodes.push(new Q(o.span,o.label,i))):this.diagnostics.push(E.warning.LabelWithoutTarget(o.label,o.span));break;case"sugar":for(let a of this.deSugarRelationFns){let l=a(this,t,e);if(l!==null){e=l-1;continue t}}let c=this.nodes.at(-1);c instanceof H&&c.sourceSpan.end===o.span.start?c.sourceSpan.end=o.span.end:this.nodes.push(new H(o.span,null));break}}return e}parseGrammar(t,e,n=!1){let o=[],s=i=>{o.push(i),n&&this.recordSyntax(i)};t:for(;(t=ot(this.source,t,e))<e;){let i=this.source[t];if(i==="@"){let c=$o(this.source,t,e);if(c){s(Object.assign(c,{kind:"call",typed:!1}));let l=!1;for(let h of c.args){let p=h.nameSpan!==void 0;if(p&&!l)l=!0;else if(!p&&l){let f=E.error.PosAfterNamedArg(c.name,h.span);if(!n)throw f;this.diagnostics.push(f)}}if(!c.closeParenSpan){let h=E.error.UnterminatedCall(c.name,c.span);if(!n)throw h;this.diagnostics.push(h)}t=c.span.end;continue}let a=Ho(this.source,t,e);if(a){s({kind:"label",span:{start:t,end:a.next},label:a.label}),t=a.next;continue}}if(i==="{"){let c=zo(this.source,t,e);(c<0||c>=e||c<=t)&&(this.diagnostics.push(E.warning.UnmatchedBrace({start:t,end:e})),c=e),s({kind:"brace",span:{start:t,end:c+1}}),t=c+1;continue}for(let c of this.deSugarAtomFns)try{let a=c(this.source,t,e,this.scopeDepth);if(a){s(a.node),t=a.next;continue t}}catch(a){throw a instanceof E?this.diagnostics.push(a):this.diagnostics.push(E.error.Bug(a.toString(),{start:t,end:e})),a}o.push(t++)}return o}parseCallNode(t){let e=this.functions.get(t.name.toLowerCase()),n=e?.def;if(!e||!n){if(this.variables.strict)throw E.error.UnknownFunction(t.name,t.span);return this.diagnostics.push(E.warning.UnknownFunction(t.name,t.span)),new T(t.span,null)}let o=n.args;if(!t.typed){let s=new Map;for(let i=0;i<t.args.length;i++){let c=t.args[i],a=c.nameSpan?this.source.slice(c.nameSpan.start,c.nameSpan.end).toLowerCase():void 0,l=gt(n,a,i),h=a??i;if(l===void 0){n.allowExtraArgs?s.set(h,c):this.diagnostics.push(E.warning.TooManyPosArgs(t.name,o.length,i+1,c.valueSpan));continue}let p=this.parseArgWithType(c.valueSpan,l,t.span.start);p!==null&&s.set(h,p)}return new e(t.span,s,this,null)}return new e(t.span,t.args,this,null)}parseArgWithType(t,e,n){let o=$t(this.source,t.start,t.end),s=o.start,i=o.end;if(s>=i)return null;let c=e==="content"?"":this.source.slice(s,i);switch(e){case"number":let a=Number(c);return isNaN(a)?(this.diagnostics.push(E.warning.InvalidNumber(c,o)),null):a;case"boolean":let l=c;return Wo.test(l)?l==="true":(this.diagnostics.push(E.warning.InvalidBoolean(c,o)),null);case"content":{let f=this.labelableNodes,d=f.length,x=f.at(-1),g=x?.label,y=x&&Object.hasOwn(x,"label");try{let m=new r(this).parse(s,i);return m.length===1?m[0]:new z(o,m,null)}catch(u){if(f.length=d,x&&(y?x.label=g:delete x.label),this.variables.strict||!(u instanceof E))throw u;return this.diagnostics.push(u,E.warning.InvalidContent(o)),null}}case"label":n??=t.start;for(let f=this.labelableNodes.length-1;f>=0;f--){let d=this.labelableNodes[f];if(d&&!(d.sourceSpan.start>=n)&&d.label==c)return d}throw E.error.UnknownLabel(c,o);case"length":let h=nn(c);return h instanceof E?(h.span.start+=s,h.span.end+=s,this.diagnostics.push(h),null):h;default:return pt(c)}return null}length2px(t){return t.unit==="em"?t.value*this.variables.fontsize:t.value}};function ot(r,t,e){for(;t<e&&Vo(r[t]);)t++;return t}function Bt(r,t,e=0){for(;t>=e&&Vo(r[t]);)t--;return t}function Vo(r){switch(r){case" ":case" ":case"\v":case"\f":case"\xA0":case"\uFEFF":case"\u3000":return!0;default:return!1}}var ki=/^[A-GXZ]/,re=/^[0-9]/,ce=/^[#bn]+/,Yo=/^[+-]?\d+/,Ko=/^[,']+/;function zt(r,t=0,e=r.length){if(e-t===0)return new C("E_WRONG_NOTE_NAME",'\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u4E0D\u80FD\u4E3A\u7A7A',{start:t,end:e});let n=0,o=null,s=null,i=null,c=!1,a;for(let l=t;l<e;l++){let h=r[l];switch(n){case 0:if(ki.test(h))o=h,c=!0,n=1;else if(re.test(h))o=h,c=!1,n=3;else{let f=r.slice(l,e).match(ce);if(f)s=f[0],l+=s.length-1,c=!1,n=2;else return new C("E_WRONG_NOTE_NAME",`\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u9996\u5B57\u7B26 "${h}" \u4E0D\u5408\u6CD5\uFF0C\u671F\u671B A-G (a-g)\u30010-9\u3001X \u6216 Z \u5F00\u5934\uFF0C\u6216\u5728\u5F00\u5934\u76F4\u63A5\u4F7F\u7528\u5347\u964D\u53F7(#/b/n)`,{start:l,end:l+1})}break;case 1:let p=r.slice(l,e);if(a=p.match(Yo),a){i=parseInt(a[0],10),l+=a[0].length-1,n=4;break}if(a=p.match(ce),a){s=a[0],l+=s.length-1,n=5;break}return{name:o,next:l,acc:null,octave:null,absOctave:c};case 2:if(re.test(h)){o=h,n=6;break}else return new C("E_WRONG_NOTE_NAME",`\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u5728\u5347\u964D\u53F7\u5F00\u5934\u65F6\uFF0C\u5E94\u8BE5\u63A5\u6570\u5B57\u97F3\u540D\uFF0C\u4F46\u53D1\u73B0\u5B57\u7B26 "${h}"`,{start:l,end:l+1});case 3:if(a=r.slice(l,e).match(Ko),a){let f=a[0];return i=Uo(f),{name:o,next:l+f.length,acc:s,octave:i,absOctave:c}}if(a=r.slice(l,e).match(ce),a&&!re.test(r[l+a[0].length]??"")){let f=a[0];s=f,l+=f.length-1,n=6;break}return{name:o,next:l,acc:s,octave:i,absOctave:c};case 4:if(a=r.slice(l,e).match(ce),a&&!re.test(r[l+a[0].length]??"")){let f=a[0];return s=f,{name:o,next:l+f.length,acc:s,octave:i,absOctave:c}}return{name:o,next:l,acc:null,octave:i,absOctave:c};case 5:return a=r.slice(l,e).match(Yo),a?(i=parseInt(a[0],10),{name:o,next:l+a[0].length,acc:s,octave:i,absOctave:c}):{name:o,next:l,acc:s,octave:null,absOctave:c};case 6:if(a=r.slice(l,e).match(Ko),a){let f=a[0];return i=Uo(f),{name:o,next:l+f.length,acc:s,octave:i,absOctave:c}}return{name:o,next:l,acc:s,octave:i,absOctave:c};default:return E.error.Bug("\u97F3\u7B26\u540D\u79F0\u89E3\u6790\u72B6\u6001\u673A\u8FDB\u5165\u4E86\u672A\u5B9A\u4E49\u7684\u72B6\u6001",{start:l,end:e})}}return o===null?new C("E_WRONG_NOTE_NAME",'\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u5728\u5347\u964D\u53F7\u5F00\u5934\u65F6\uFF0C\u5E94\u8BE5\u63A5\u6570\u5B57\u97F3\u540D\uFF0C\u4F46\u8F93\u5165\u5DF2\u7ED3\u675F',{start:t,end:e}):{name:o,next:e,acc:s,octave:i,absOctave:c}}function Uo(r){let t=0;for(let e=0;e<r.length;e++)r[e]===","?t--:r[e]==="'"&&t++;return t}var vt={C:0,"C#":1,Db:1,D:2,"D#":3,Eb:3,E:4,F:5,"F#":6,Gb:6,G:7,"G#":8,Ab:8,A:9,"A#":10,Bb:10,B:11,1:0,2:2,3:4,4:5,5:7,6:9,7:11},ae=["C","D","E","F","G","A","B"],on=[0,2,4,5,7,9,11];function Ht(r,t){let e=r[0],n="",o=1;o<r.length&&(r[o]==="#"||r[o]==="b"||r[o]==="n")&&(n=r[o],o++);let s=vt[e+n];if(s===void 0)throw E.error.InvalidTonality(r,{start:0,end:o});if(o<r.length&&(t=parseInt(r.slice(o),10),isNaN(t)))throw E.error.InvalidTonality(r,{start:o,end:r.length});return(t+1)*12+s}function rn(r,t=!0,e=0){for(let n of r)n==="#"?e++:n==="b"?e--:n==="n"&&!t&&(e=0);return e}function cn(r,t,e,n){let o=vt[r];if(o===void 0)return null;let s=rn(t);return r>="1"&&r<="7"?Ht(n,4)+o+s+e*12:(e+1)*12+o+s}function Xo(r,t,e,n){let o,s;if(r>="1"&&r<="7")o=Number(r)-1,s=e;else{let a=an(r,t,e,n);if(!a)return;o=Number(a.renderName)-1,s=a.renderOctave}let i=Ht(n,4),c=s*7+o;return a=>{let l=c+a,h=Math.floor(l/7);return i+on[(l%7+7)%7]+h*12}}function sn(r){return(r%12+12)%12}function Ni(r){let t=sn(r);return t>6?t-12:t}function Mi(r){return r===0?"":r>0?"#".repeat(r):"b".repeat(-r)}function an(r,t,e,n){let o=ae.indexOf(n[0]),s=ae.indexOf(r),i=cn(r,t,e,n);if(o<0||s<0||i===null)return null;let c=Ht(n,4),a=(s-o+ae.length)%ae.length,l=sn(c+on[a]),h=Ni(sn(i)-l),p=(i-c-on[a]-h)/12;return{renderName:String(a+1),renderAcc:Mi(h),renderOctave:p}}var Ri={"#":{w:.46,h:.78,baseline:.63,commands:[{op:"M",x:.34,y:.05},{op:"L",x:.27,y:.95},{op:"M",x:.72,y:.05},{op:"L",x:.65,y:.95},{op:"M",x:.08,y:.38},{op:"L",x:.9,y:.28},{op:"M",x:.05,y:.72},{op:"L",x:.87,y:.62}]},b:{w:.38,h:.82,baseline:.67,commands:[{op:"M",x:.3,y:.04},{op:"L",x:.3,y:.94},{op:"M",x:.3,y:.5},{op:"Q",cx:.92,cy:.36,x:.76,y:.68},{op:"Q",cx:.63,cy:.87,x:.3,y:.86}]},n:{w:.42,h:.82,baseline:.67,commands:[{op:"M",x:.28,y:.05},{op:"L",x:.28,y:.82},{op:"L",x:.72,y:.68},{op:"L",x:.72,y:.95},{op:"M",x:.72,y:.95},{op:"L",x:.72,y:.18},{op:"L",x:.28,y:.32}]}};function Ii(r,t){let e=Ri[r];if(!e)return null;let n=t*.72;return{w:e.w*n,h:e.h*n,baseline:e.baseline*n,strokeWidth:t*.06,commands:e.commands}}function le(r,t,e,n,o){let s=[],i=t*.42,c=e,a=0;for(let l of r){let h=Ii(l,t);if(!h)continue;let p=n-h.baseline-i;s.push({shape:h,x:c,y:p}),p<a&&(a=p),c+=h.w+o}return{placed:s,right:c,top:a}}function he(r,{shape:t,x:e,y:n},o,s){r.drawPath(t.commands,{stroke:s,strokeWidth:t.strokeWidth},{x:o.x+e,y:o.y+n,scaleX:t.w,scaleY:t.h})}function Oi(r){try{return Ht(r,4),r}catch{}let t=zt(r.replace(/^[a-g]/,c=>c.toUpperCase()));if(t instanceof E)return null;let e=vt[t.name];if(e===void 0)return null;let n=rn(t.acc??"",!1),s=((t.absOctave?t.octave??4:4+(t.octave??0))+1)*12+e+n,i=Object.keys(vt).filter(c=>vt[c]===(s%12+12)%12&&/^[A-G]/.test(c));return(n<0?i.at(-1):i[0])+(Math.floor(s/12)-1)}var hn=class extends T{static def={name:["key","1"],description:"\u8BBE\u7F6E\u65F6\u95F4\u7EBF\u4E0A\u7684 1= \u8C03\u6027\u57FA\u51C6",example:`@1(C4) \u6216 @key(F#3)
39
+ \u5B83\u4E0D\u4F1A\u4FEE\u6539 parser \u7684\u5C40\u90E8\u53D8\u91CF\uFF0C\u800C\u662F\u5728\u65F6\u95F4\u56FA\u5316\u9636\u6BB5\u5F71\u54CD\u5176\u540E\u7684\u6570\u5B57\u97F3\u540D\u89E3\u91CA
40
+ \u753B\u51FA\u6765\u7684\u8BB0\u53F7\u53EA\u542B\u97F3\u540D\u548C\u5347\u964D\u53F7\uFF0C\u4E0D\u542B\u516B\u5EA6\uFF1B\u901A\u5E38\u53E0\u5728\u97F3\u7B26\u4E0A\u65B9\u4E66\u5199\uFF1A1 ^ @1(F#)`,allowExtraArgs:!1,args:[{name:"tonality",type:"string",default:null},{name:"size",type:"length",default:{value:1,unit:"em"}}]};tonality;size;font;displayName;displayAcc;constructor(t,e,n,o=null){super(t,o);let[s,i]=this.getArgValue(e,n);this.font=n.variables.numberfont,this.tonality=s,this.size=n.length2px(i);let c=Oi(s);if(c!==s){if(n.variables.strict)throw new C("E_KEY_TONALITY",`@key \u65E0\u6CD5\u89E3\u6790\u8C03\u6027 "${s}"`,t);this.tonality=c??It,n.diagnostics.push(new k("W_KEY_TONALITY",`@key \u7684\u8C03\u6027 "${s}" \u4E0D\u662F\u89C4\u8303\u5199\u6CD5\uFF0C\u5DF2\u81EA\u52A8\u5207\u6362\u5230 ${this.tonality}`,t))}this.displayName=this.tonality[0],this.displayAcc=this.tonality[1]==="#"||this.tonality[1]==="b"?this.tonality[1]:""}loweringEnter(){return[new pn(this)]}toString(){return`@1(${this.tonality})`}},pe=hn,ln="1=",pn=class extends P{accidentals=[];nameX=0;textBaselineY=0;style;constructor(t){super(),this.ast=t,this.style={fontSize:t.size,fontFamily:t.font,fill:"#000"},this.initLayoutBox()}onTimeState(t){t.keySignature=this.ast.tonality}prepareLayout(t){let e=this.ast.size,n=this.style,o=t.textMeasurer.measureText(ln,n),s=t.textMeasurer.measureText(this.ast.displayName,n),i=e*.02,{placed:c,right:a,top:l}=le(this.ast.displayAcc,e,o.w,o.baseline,i);this.accidentals=c;let h=-l;for(let p of c)p.y+=h;this.nameX=a,this.textBaselineY=h+o.baseline,this.box.w=a+s.w,this.box.h=h+Math.max(o.h,s.h),this.box.anchor=t.textMeasurer.measureText(ln[0],n).w/2,this.box.visualAxis=this.box.h/2}paint(t){let e=this.style;t.drawText(ln,this.box.x,this.box.y+this.textBaselineY,e);for(let n of this.accidentals)he(t,n,this.box,"#000");t.drawText(this.ast.displayName,this.box.x+this.nameX,this.box.y+this.textBaselineY,e)}};var fn=class extends T{static def={name:["meter"],description:"\u8BBE\u7F6E\u62CD\u53F7",example:"@meter(6, 8) \u8BBE\u7F6E 6/8 \u62CD\u53F7",allowExtraArgs:!1,args:[{name:"num",type:"number",default:null},{name:"den",type:"number",default:null},{name:"size",type:"length",default:{value:.7,unit:"em"}}]};numerator;denominator;measureDuration;size;strict;font;constructor(t,e,n,o=null){super(t,o);let[s,i,c]=this.getArgValue(e,n);if(this.font=n.variables.numberfont,!Number.isSafeInteger(s)||!Number.isSafeInteger(s*4)||s<=0||!Number.isSafeInteger(i)||i<=0){let a="@meter \u7684\u5206\u5B50\u548C\u5206\u6BCD\u5FC5\u987B\u662F\u6B63\u6574\u6570";if(n.variables.strict)throw new C("E_METER_INVALID",a,t);n.diagnostics.push(new k("W_METER_INVALID",`${a}\uFF0C\u5DF2\u56DE\u843D\u4E3A 4/4`,t)),s=i=4}this.numerator=s,this.denominator=i,this.measureDuration=new M(s*4,i),this.size=n.length2px(c),this.strict=n.variables.strict}loweringEnter(){return[new fe(this)]}static loweringFinalize=t=>{let e=new M,n=new M,o=null,s=!1,i=0,c=(a,l)=>{if(!(!o||a.equals(e))){if(n.copyFrom(a).sub(e),!n.equals(o.measureDuration)&&(s||n.compare(o.measureDuration)>0)){let h=`\u5C0F\u8282\u65F6\u957F\u4E3A ${n} QN\uFF0C\u4E0D\u6EE1\u8DB3 ${o.numerator}/${o.denominator} \u62CD\u53F7`,p={start:i,end:l};if(o.strict)throw new C("E_METER_MISMATCH",h,p);t.diagnostics.push(new k("W_METER_MISMATCH",h,p))}e.copyFrom(a)}};for(let a of t.columns){let l=a[0].t,h=a.find(f=>f instanceof fe);h&&(c(l,h.ast.sourceSpan.start),o=h.ast,e.copyFrom(l),i=h.ast.sourceSpan.end);let p=a.find(f=>f.mergeKey===G);p&&(c(l,p.ast.sourceSpan.end),i=p.ast.sourceSpan.end,s=!0)}if(o){let a=t.columns.at(-1)?.at(-1)?.ast.sourceSpan??o.sourceSpan;c(t.duration,a.end)}};toString(){return`@meter(${this.numerator}, ${this.denominator})`}},ue=fn,fe=class extends P{style;numeratorBaseline=0;denominatorBaseline=0;lineY=0;lineHeight=0;constructor(t){super(),this.ast=t,this.style={fontSize:t.size,fontFamily:t.font,textAlign:"center",fill:"#000"},this.initLayoutBox()}emitPlayback(t){t.emit({kind:"time-signature",at:t.start,numerator:this.ast.numerator,denominator:this.ast.denominator})}prepareLayout(t){let e=t.textMeasurer.measureText(String(this.ast.numerator),this.style),n=t.textMeasurer.measureText(String(this.ast.denominator),this.style),o=this.ast.size*.08,s=this.ast.size*.08;this.lineHeight=Math.max(1,this.ast.size*.06),this.numeratorBaseline=e.baseline,this.lineY=e.h+o,this.denominatorBaseline=this.lineY+this.lineHeight+o+n.baseline,this.box.w=Math.max(e.w,n.w)+s*2,this.box.h=this.lineY+this.lineHeight+o+n.h,this.box.anchor=this.box.w/2,this.box.visualAxis=this.lineY+this.lineHeight/2}paint(t){let e=this.box.x+this.box.anchor;t.drawText(String(this.ast.numerator),e,this.box.y+this.numeratorBaseline,this.style),t.drawRect(this.box.x,this.box.y+this.lineY,this.box.w,this.lineHeight,{fill:"#000"}),t.drawText(String(this.ast.denominator),e,this.box.y+this.denominatorBaseline,this.style)}};var Di=[{op:"M",x:3.864,y:8.5},{op:"Q",cx:3.864,cy:9.228,x:3.5,y:9.76},{op:"Q",cx:3.136,cy:10.292,x:2.555,y:10.586},{op:"Q",cx:1.974,cy:10.88,x:1.302,y:10.88},{op:"Q",cx:.826,cy:10.88,x:.413,y:10.621},{op:"Q",cx:0,cy:10.362,x:0,y:9.844},{op:"Q",cx:0,cy:9.34,x:.364,y:8.899},{op:"Q",cx:.728,cy:8.458,x:1.288,y:8.185},{op:"Q",cx:1.848,cy:7.912,x:2.422,y:7.912},{op:"Q",cx:2.968,cy:7.912,x:3.304,y:8.094},{op:"L",x:3.304,y:0},{op:"L",x:3.864,y:0},{op:"Z"}];function Zo(r){let t=r/11;return{w:3.864*t,h:10.88*t,stemCenterX:(3.304+3.864)/2*t,commands:Di,scale:t}}var un=class extends T{static def={name:["tempo"],description:"\u8BBE\u7F6E\u65F6\u95F4\u7EBF\u4E0A\u7684\u901F\u5EA6",example:"@tempo(96) \u5C06\u5176\u540E\u7684\u65F6\u95F4\u72B6\u6001\u901F\u5EA6\u8BBE\u7F6E\u4E3A 96 BPM",allowExtraArgs:!1,args:[{name:"bpm",type:"number",default:null},{name:"size",type:"length",default:{value:1,unit:"em"}}]};bpm;size;font;constructor(t,e,n,o=null){super(t,o);let[s,i]=this.getArgValue(e,n);this.bpm=s,this.size=n.length2px(i),this.font=n.variables.font}loweringEnter(){return[new xn(this)]}toString(){return`@tempo(${this.bpm}, size=${this.size}px)`}},xe=un,xn=class extends P{glyph;text;style;glyphY=0;textX=0;textBaselineY=0;constructor(t){super(),this.ast=t,this.glyph=Zo(t.size),this.text=`= ${t.bpm}`,this.style={fontSize:t.size,fontFamily:t.font,fill:"#000"},Number.isFinite(t.bpm)&&t.bpm>0&&(this.playbackState={bpm:t.bpm}),this.initLayoutBox()}onTimeState(t){let e=this.playbackState?.bpm;e!==void 0&&(t.bpm=e)}prepareLayout(t){let e=this.glyph,n=t.textMeasurer.measureText(this.text,this.style),o=Math.max(0,e.h-n.baseline);this.textX=e.w+this.ast.size*.26,this.textBaselineY=o+n.baseline,this.glyphY=this.textBaselineY-e.h,this.box.w=this.textX+n.w,this.box.h=o+n.h,this.box.anchor=e.stemCenterX,this.box.visualAxis=o+n.h/2}paint(t){t.drawPath(this.glyph.commands,{fill:"#000"},{x:this.box.x,y:this.box.y+this.glyphY,scaleX:this.glyph.scale,scaleY:this.glyph.scale}),t.drawText(this.text,this.box.x+this.textX,this.box.y+this.textBaselineY,this.style)}};var mn=class extends T{static def={name:["text"],description:"\u6587\u672C\u6807\u8BB0\u3002\u62EC\u53F7\u5185\u53EF\u76F4\u63A5\u6362\u884C\uFF0C\u652F\u6301 left\u3001center\u3001right \u5BF9\u9F50",example:`@text(\u8FDB\u5165\u4E3B\u9898)
41
+ \u8BED\u6CD5\u7CD6\uFF1A\u76F4\u63A5\u5199\u53CC\u5F15\u53F7\u5B57\u7B26\u4E32\uFF0C\u5982 "\u8FDB\u5165\u4E3B\u9898"\uFF1B\u53EF\u8DE8\u884C\uFF0C\u5F15\u53F7\u672A\u914D\u5BF9\u5219\u4E0D\u751F\u6548`,allowExtraArgs:!1,args:[{type:"string",default:null},{name:"size",type:"length",default:{value:.8,unit:"em"}},{name:"lineheight",type:"number",default:1.25},{name:"align",type:"string",default:"left"},{name:"font",type:"string",default:""}]};static deSugarAtom(t,e,n){if(t[e]!=='"')return null;let o=_t(t,e,n);if(o<0)return null;let s={kind:"call",typed:!0,name:"text",args:new Map([[0,pt(t.slice(e,o+1))]]),span:{start:e,end:o+1},syntaxKind:"string"};return{next:o+1,node:s}}lines;size;lineAdvance;align;font;constructor(t,e,n,o=null){super(t,o);let[s,i,c,a,l]=this.getArgValue(e,n);if(this.font=l||n.variables.font,a!=="left"&&a!=="center"&&a!=="right")throw new C("E_TEXT_INVALID_ALIGN","@text \u7684 align \u53C2\u6570\u5FC5\u987B\u662F 'left'\u3001'center' \u6216 'right'",t);this.lines=s.split(/\r?\n/),this.size=n.length2px(i),this.lineAdvance=c*this.size,this.align=a}loweringEnter(){return[new dn(this)]}toString(){let t=this.size===0?1.25:this.lineAdvance/this.size;return`@text(${tt(this.lines.join(`
42
+ `))}, size=${this.size}px, lineheight=${t}, align=${this.align}, font=${tt(this.font)})`}},me=mn,dn=class extends P{style;textBaselineY=0;constructor(t){super(),this.ast=t,this.mergeKey=J,this.style={fontSize:t.size,fontFamily:t.font,fill:"#000",textAlign:t.align},this.initLayoutBox()}prepareLayout(t){let{lines:e,align:n,lineAdvance:o}=this.ast,s=a=>t.textMeasurer.measureText(a,this.style),i=s(e[0]),c=i.w;for(let a=1;a<e.length;a++)c=Math.max(c,s(e[a]).w);if(this.box.w=c,this.box.h=(e.length-1)*o+i.h,this.box.visualAxis=this.box.h/2,this.textBaselineY=i.baseline,n==="center")this.box.anchor=c/2;else if(n==="right"){let a=[...e[0]].at(-1);this.box.anchor=c-(a?s(a).w/2:0)}else{let a=[...e[0]][0];this.box.anchor=a?s(a).w/2:0}}paint(t){let{lines:e,align:n,lineAdvance:o}=this.ast,s=this.box.x+(n==="center"?this.box.w/2:n==="right"?this.box.w:0),i=this.box.y+this.textBaselineY;for(let c of e)t.drawText(c,s,i,this.style),i+=o}};var jo={title:"center",subtitle:"center",author:"right",signature:"left",tempo:"left",left:"left",center:"center",right:"right"},Pi={title:[2,"center"],subtitle:[.85,"center"],author:[.8,"right"]},Fi=.25,qo=5,Qo=1e4;function de(r,t){return t.length===1&&t[0]instanceof z?t[0]:new z(r,t)}function Jo(r,t,e=r.length){for(;t<e&&r[t]!=="\r"&&r[t]!==`
43
+ `;)t++;return t}function $i({columns:r,rows:t,start:e,end:n,X:o,fixed:s,options:i},c){wt(r.slice(e,n+1),t,o.subarray(e,n+1),s.subarray(e,n),1/0,i);let a=1/0,l=-1/0;for(let h=e+1;h<n;h++)for(let p=0;p<t;p++)a=Math.min(a,o[h]-r[h][p].WL),l=Math.max(l,o[h]+r[h][p].WR);c&&a<=l?(o[e]=a,o[n]=l):o[n]=o[e]}function ts(r,t,e){let n=[],o,s;for(let i of r){if(!i){n.push(null);continue}let c=s===void 0?0:s+t-i.top;n.push({offset:c,extent:i}),o??=c+i.top,s=c+i.bottom}return e?.(o===void 0||s===void 0?null:{top:o,bottom:s}),n}var ye=class extends P{members=[];slots=[];titleBottom=0;leftExtent=null;rightExtent=null;constructor(t){super(),this.ast=t,this.initLayoutBox()}prepareLayout(){this.box.w=this.box.h=this.box.anchor=this.box.visualAxis=0}prepareHorizontal(t){this.slots.length>0&&this.prepareHead(t)}onPlaced(){this.slots.length>0&&this.alignHead()}createTracks(t){let{name:e,owner:n}=t;return{laneKey:`head/rows/${n.sourceSpan.start}/${e}`,hostIndex:null,measure:o=>{if(e==="center"){let s=ts(o,n.gap),i=s.find(c=>c!==null);return this.titleBottom=i?i.offset+i.extent.bottom:0,s}return ts(o,n.gap,s=>{e==="left"?this.leftExtent=s:this.rightExtent=s})},place:e==="center"?void 0:()=>{let o=e==="left"?this.leftExtent:this.rightExtent;if(!o)return this.titleBottom;let s=this.leftExtent?this.leftExtent.bottom-this.leftExtent.top:0,i=this.rightExtent?this.rightExtent.bottom-this.rightExtent.top:0;return this.titleBottom+Math.max(s,i)-o.bottom}}}prepareHead(t){if(this.members.some(s=>D(s)&&s.layoutLine!==t.index))throw new C("E_HEAD_INTERNAL_BREAK","@head \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8C31\u9762\u884C",this.ast.owner.sourceSpan);let[e,n,o]=this.slots;e.start.springConfig.alpha_L=0,o.end.springConfig.alpha_R=0,this.stretch(n.start,"L"),this.stretch(n.end,"R");for(let s of this.slots)t.registerHorizontalLayoutHook(s.start,s.end,i=>$i(i,s===n))}alignHead(){let t=new Map;for(let o of this.members){if(!D(o))continue;let s=this.sideCellOf(o.ast);if(!s)continue;let i=t.get(s);i?i.push(o):t.set(s,[o])}let[e,,n]=this.slots;this.packRows(e.ast,e.start.box.x,"left",t),this.packRows(n.ast,n.end.box.x,"right",t)}stretch(t,e){let n=e==="L"?"alpha_L":"alpha_R",o=e==="L"?"beta_L":"beta_R";t.springConfig[n]=t.springConfig[n]*Qo,t.springConfig[o]=t.springConfig[o]*3/Qo}packRows(t,e,n,o){let s=this.ast.owner.size*Fi,i=n==="left",c=i?1:-1;for(let a of t.rows){let l=a instanceof z?a.content:[a],h=e;for(let p=i?0:l.length-1;p>=0&&p<l.length;p+=c){let f=o.get(l[p]);if(!f)continue;let d=1/0,x=-1/0;for(let y of f)d=Math.min(d,y.box.x),x=Math.max(x,y.box.x+y.box.w);let g=h-(i?d:x);for(let y of f)y.box.x+=g;for(let y of f)y.onPlaced?.();h+=c*(x-d+s)}}}sideCellOf(t){let e=t;for(;e.parent;){let n=e.parent,o=n instanceof ft?n:n instanceof z&&n.parent instanceof ft?n.parent:null;if(o?.owner===this.ast.owner)return o.name==="center"?null:e;e=n}return null}},ft=class extends Y{owner;name;rows;constructor(t,e,n,o){super(t,e),this.owner=e,this.name=n,this.rows=o;for(let s of this.rows)s.parent=this}get size(){return this.owner.size}get children(){return this.rows}timeFlowModel(t){if(this.rows.length===0)return null;let e=t.getTemporalNodes(this.owner.slots[0])[0];return{mode:"parallel",children:this.rows,tracks:e.createTracks(this)}}loweringEnter(){return[new ye(this)]}loweringExit(){return[new ye(this)]}addRow(t){t.parent=this,this.rows.push(t)}},yn=class r extends T{static def={name:["head"],description:"\u63D0\u4F9B\u5DE6\u3001\u4E2D\u3001\u53F3\u4E09\u5757\u5E03\u5C40\uFF0C\u5E38\u7528\u4E8E\u66F2\u8C31\u5934\u90E8\u4FE1\u606F\u5C55\u793A\uFF1B\u4E5F\u53EF\u7528\u8FDE\u7EED\u7684 H.*: \u884C\u58F0\u660E\u6784\u9020",example:`@head(left={{@key(C) @meter(4,4)}}, center={@text(\u6807\u9898)}, right={@text(\u4F5C\u8005)})
44
+ \u8BED\u6CD5\u7CD6\uFF1A\u76F8\u90BB\u7684 H.*: \u58F0\u660E\u5408\u5E76\u4E3A\u4E00\u4E2A head\uFF0C\u6BCF\u6761\u58F0\u660E\u751F\u6210\u5BF9\u5E94\u69FD\u7684\u4E00\u884C\uFF1B\u7A7A\u884C\u6216\u666E\u901A\u5185\u5BB9\u7ED3\u675F\u7EC4\u5408
45
+ H.title: \u6807\u9898 center \u69FD\uFF0C\u9884\u8BBE\u5927\u5B57\u53F7\u5C45\u4E2D Text
46
+ H.subtitle: \u526F\u6807\u9898 center \u69FD\uFF0C\u9884\u8BBE\u5C0F\u5B57\u53F7\u5C45\u4E2D Text
47
+ H.author: \u4F5C\u8005 right \u69FD\uFF0C\u9884\u8BBE\u5C0F\u5B57\u53F7\u53F3\u5BF9\u9F50 Text
48
+ H.signature: 1=C 4/4 left \u69FD\uFF0C\u540C\u4E00\u884C\u751F\u6210 Key \u548C Meter
49
+ H.tempo: 94 left \u69FD\uFF0C\u751F\u6210 Tempo
50
+ H.left: / H.center: / H.right: \u63A5\u53D7\u5BF9\u5E94\u69FD\u7684\u4EFB\u610F\u96F6\u65F6\u957F DSL \u5185\u5BB9
51
+ \u4EE5 @ \u6216 { \u5F00\u5934\u65F6\u6309 DSL \u89E3\u6790\uFF0C\u5426\u5219\u6309\u8BE5\u5B57\u6BB5\u7684\u88F8\u6587\u672C\u89C4\u5219\u751F\u6210 Text`,allowExtraArgs:!1,args:[{name:"left",type:"content",default:""},{name:"center",type:"content",default:""},{name:"right",type:"content",default:""},{name:"gap",type:"length",default:{value:qo,unit:"px"}}]};slots;size;gap;createdBySugar=!1;get children(){return this.slots}timeFlowModel(){return{mode:"sequence",children:this.slots}}static deSugarAtom(t,e,n){if(t[e]!=="H"||t[e+1]!==".")return null;let o=e+2;for(;o<n&&t[o]>="a"&&t[o]<="z";)o++;let s=t.slice(e+2,o);if(!Object.hasOwn(jo,s)||t[o]!==":")return null;o++;let i=Jo(t,o,n),c=ot(t,o,i);return{next:t[c]==="@"||t[c]==="{"?o:i,node:{kind:"sugar",data:{class:r,field:s},span:{start:e,end:o}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==r)return null;let s=o.data.field,i=n;for(;i<e.length;i++){let u=e[i];if(typeof u=="number"&&(t.source[u]==="\r"||t.source[u]===`
52
+ `)||typeof u!="number"&&u.kind==="sugar"&&u.data?.class===r)break}let c=e[i],a;if(typeof c=="number")a=c;else if(c)a=c.span.start;else if(i>n){let u=e[i-1];a=typeof u=="number"?u+1:u.span.end}else a=Jo(t.source,o.span.end);let l=ot(t.source,o.span.end,a),h=Bt(t.source,a-1,l),p={start:l,end:Math.max(l,h+1)};if(p.start>=p.end)throw new C("E_HEAD_EMPTY_DECLARATION",`H.${s}: \u540E\u5FC5\u987B\u6709\u5185\u5BB9`,o.span);let f=t.source.slice(p.start,p.end).trim(),d;if(f.startsWith("@")||f.startsWith("{")){let u=new j(t);u.makeNodes(e.slice(n,i)),d=u.nodes}let x=t.nodes.at(-1),g=x instanceof r&&x.createdBySugar?x:new r(o.span,new Map,t,null);if(g.createdBySugar=!0,g.addSugarRow(jo[s],r.parseSugarRow(t,s,p,f,d)),g.sourceSpan.end=p.end,g!==x&&t.pushNode(g),typeof c!="number")return i;let y=i+1;if(t.source[c]==="\r"){let u=e[y];typeof u=="number"&&t.source[u]===`
53
+ `&&y++}return y}static parseSugarRow(t,e,n,o,s){if(s!==void 0)return de(n,s);if(e==="signature"){let a=/^(1\s*=\s*(\S+))\s+((\d+)\s*\/\s*(\d+))$/.exec(o);if(!a)throw new C("E_HEAD_INVALID_SIGNATURE","H.signature \u7684\u683C\u5F0F\u5E94\u4E3A 1=C 4/4",n);let l={start:n.start,end:n.start+a[1].length},h={start:n.end-a[3].length,end:n.end};return de(n,[new pe(l,new Map([["tonality",a[2]]]),t,null),new ue(h,new Map([["num",Number(a[4])],["den",Number(a[5])]]),t,null)])}if(e==="tempo"){let a=Number(o);if(!Number.isFinite(a)||a<=0)throw new C("E_HEAD_INVALID_TEMPO","H.tempo \u540E\u5FC5\u987B\u662F\u6B63\u6570",n);return de(n,[new xe(n,new Map([["bpm",a]]),t,null)])}let i=new Map([[0,o]]),c=Pi[e];return c&&(i.set("size",{value:c[0],unit:"em"}),i.set("align",c[1])),de(n,[new me(n,i,t,null)])}constructor(t,e,n,o=null){super(t,o),this.size=n.variables.fontsize,this.gap=n.length2px(this.getArgValue(e,n)[3]);let s=(i,c)=>{let a=e.get(i)??e.get(c);return a instanceof Y?a instanceof z?a.content:[a]:[]};this.slots=[new ft(t,this,"left",s("left",0)),new ft(t,this,"center",s("center",1)),new ft(t,this,"right",s("right",2))]}loweringEnter(t){let e={members:[],onTemporal(n){this.members.push(n)}};return t.beginLoweringGroup(this,e),[]}loweringExit(t){let{members:e}=t.endLoweringGroup(this),n=t.getTemporalNodes(this.slots[0])[0];n.members=e,n.slots=this.slots.map(o=>{let[s,i]=t.getTemporalNodes(o);return{ast:o,start:s,end:i}});for(let o of e){if(!o.T.isZero())throw new C("E_HEAD_NONZERO_DURATION","@head \u7684\u5185\u5BB9\u5FC5\u987B\u5168\u90E8\u4E3A\u96F6\u65F6\u957F",o.ast.sourceSpan);if(o.breakBefore>0)throw new C("E_HEAD_INTERNAL_BREAK","@head \u7684\u5185\u90E8\u4E0D\u80FD\u4F7F\u7528 @br\uFF1B\u7B2C\u4E00\u5C42\u5185\u5BB9\u5DF2\u7ECF\u8868\u793A\u89C6\u89C9\u884C",o.ast.sourceSpan)}return[]}addSugarRow(t,e){this.slots.find(n=>n.name===t).addRow(e)}toString(t){let e=this.slots.filter(n=>n.rows.length>0).map(n=>{let o=n.rows.map(s=>` ${s.toString(t).replaceAll(`
54
+ `,`
55
+ `)}`).join(`
56
+ `);return` ${n.name}={
57
+ ${o}
58
+ }`});return this.gap!==qo&&e.push(` gap=${this.gap}px`),`@head(
59
+ ${e.join(`,
60
+ `)}
61
+ )`}},es=yn;var gn=class extends T{static def={name:["br"],description:"\u6362\u884C",example:`@br(offset=1): \u5728\u540E\u7EED\u4E8B\u4EF6\u524D\u504F\u79FB\u6307\u5B9A\u884C\u6570
62
+ @br() === @br(1)
63
+ @br(2): \u7A7A\u51FA\u4E00\u884C\u540E\u7EE7\u7EED
64
+ \u8BED\u6CD5\u7CD6: [\u4EC5\u9650\u9876\u5C42]\u81F3\u5C11\u8FDE\u7EED\u4E24\u4E2A\u6362\u884C
65
+ `,allowExtraArgs:!1,args:[{name:"offset",type:"number",default:1}]};static deSugarAtom(t,e,n,o){if(o>0||t[e]!==`
66
+ `||t[Bt(t,e-1)]!==`
67
+ `)return null;let s=e+1,i=s;for(;(i=ot(t,i,n))<n&&t[i]===`
68
+ `;)s=++i;return{next:s,node:{kind:"call",typed:!0,name:"br",args:new Map,span:{start:e,end:s}}}}offset;loweringEnter(){let t=new P;return t.ast=this,t.mergeKey=-1,t.breakBefore=this.offset,[t]}static loweringFinalize=t=>{let e=new M,n=new M,o=null;for(let s of t.columns){if(o&&e.compare(s[0].t)>0&&s.some(i=>i.breakBefore>0))throw E.error.BreakInsideEvent(o.ast.sourceSpan);for(let i of s)i.T.isZero()||(n.copyFrom(i.t).add(i.T),(!o||n.compare(e)>0)&&(e.copyFrom(n),o=i))}};constructor(t,e,n,o=null){super(t,o);let[s]=this.getArgValue(e,n);this.offset=Number.isFinite(s)?Math.max(1,Math.floor(s)):1,this.offset!==s&&n.diagnostics.push(new k("W_BR_OFFSET",`@br \u7684 offset \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A ${this.offset}`,this.sourceSpan))}toString(){return`@br(${this.offset})`}},ns=gn;var bn="note.jeOctaveOffset",wn=class extends T{static def={name:["note","n"],description:"\u521B\u5EFA\u97F3\u7B26",example:`@note(name, acc, octave, color)
69
+ \u53C2\u6570\u8BF4\u660E:
70
+ - name: [\u5FC5\u586B]\u97F3\u7B26\u540D\uFF0C\u53EF\u4EE5\u662F\u5927\u5199\u5B57\u6BCD\u6216\u8005\u6570\u5B57\uFF0C\u4E0D\u5141\u8BB8\u5C0F\u5199\u5B57\u6BCD\uFF08\u4F1A\u548C\u964D\u53F7\u51B2\u7A81\uFF09\u3002\u6B64\u53C2\u6570\u5199\u6CD5\u6709\u8BED\u6CD5\u7CD6\uFF0C\u89C1\u4E0B\u3002
71
+ \u5176\u4E2D 0 \u6216 Z \u662F\u4F11\u6B62\u7B26\uFF0C8 \u662F\u9690\u5F62\u5360\u4F4D\uFF0C9 \u6216 X \u662F\u53EA\u6253\u62CD\u4E0D\u53D1\u97F3\u7684\u8282\u62CD\u8BB0\u53F7\uFF08\u663E\u793A\u4E3A X\uFF09\uFF0C\u8FD9\u4E09\u8005\u90FD\u4E0D\u663E\u793A\u5347\u964D\u53F7\u548C\u516B\u5EA6\u70B9\u3002
72
+ - acc: [\u53EF\u9009]\u7684\u989D\u5916\u5347\u964D\u53F7\u5B57\u7B26\u4E32\uFF0C\u4F8B\u5982 "##" \u8868\u793A\u518D\u5347\u4E24\u4E2A\u534A\u97F3\uFF0C"b" \u8868\u793A\u518D\u964D\u4E00\u4E2A\u534A\u97F3\u3002
73
+ - octave: [\u53EF\u9009]\u516B\u5EA6\uFF0C\u7C7B\u578B\u4E3A\u6570\u5B57\u3002\u5982\u679C name \u662F\u5B57\u6BCD\uFF0C\u5219\u6B64\u9879\u4EE3\u8868\u7EDD\u5BF9\u516B\u5EA6\uFF1B\u5982\u679C\u662F\u6570\u5B57\uFF0C\u5219\u6B64\u9879\u4EE3\u8868\u76F8\u5BF9\u516B\u5EA6\u3002
74
+
75
+ \u8BED\u6CD5\u7CD6\uFF1A\u6570\u5B57\u97F3\u540D\u5199\u4F5C [\u5347\u964D\u53F7][\u97F3\u540D][\u76F8\u5BF9\u516B\u5EA6]\uFF1B\u5B57\u6BCD\u97F3\u540D\u5199\u4F5C [\u97F3\u540D][\u5347\u964D\u53F7][\u7EDD\u5BF9\u516B\u5EA6]
76
+ \u4F8B\uFF1AA#3 === @note(A#3) === @note(A, #, 3)
77
+ \u4E5F\u652F\u6301 A##bn99 \u7684\u5199\u6CD5\u3002\u53EF\u4EE5\u8BBE\u7F6E note.octave \u6539\u53D8\u9ED8\u8BA4\u7684\u7EDD\u5BF9\u516B\u5EA6
78
+
79
+ \u517C\u5BB9\u65E0\u6B67\u4E49\u7684\u540E\u7F6E\u5347\u964D\u53F7\uFF1AA3# \u7B49\u4EF7\u4E8E A#3\uFF0C6#,, \u7B49\u4EF7\u4E8E #6,,
80
+ \u5982\u679C\u6574\u6BB5\u5347\u964D\u53F7\u540E\u7D27\u8DDF\u6570\u5B57\uFF0C\u5219\u5347\u964D\u53F7\u5C5E\u4E8E\u4E0B\u4E00\u4E2A\u97F3\u7B26\uFF1A6#3 \u89E3\u6790\u4E3A 6 \u548C #3
81
+
82
+ \u652F\u6301 \u6570\u5B57\u97F3\u540D, \u6B64\u65F6 octave \u4E3A\u76F8\u5BF9\u516B\u5EA6
83
+ \u652F\u6301\u4F7F\u7528\u6570\u5B57\u97F3\u540D\u65F6\u4F7F\u7528\u76F8\u5BF9\u516B\u5EA6\uFF0C\u5982 "1,," \u4EE3\u8868\u5728\u5F53\u524D\u57FA\u51C6\u97F3\uFF08\u7531\u4E0A\u4E0B\u6587\u5C5E\u6027"1=?"\u51B3\u5B9A\uFF09\u7684\u57FA\u7840\u4E0A\u964D\u4F4E\u4E24\u500D\u516B\u5EA6\uFF0C"1'" \u4EE3\u8868\u5728\u5F53\u524D\u57FA\u51C6\u97F3\u7684\u57FA\u7840\u4E0A\u63D0\u9AD8\u4E00\u4E2A\u516B\u5EA6
84
+ \u4F8B\uFF1A#1' === @note("#1'") === @note(1, #, 1)
85
+ `,allowExtraArgs:!1,args:[{name:"name",type:"string",default:null},{name:"acc",type:"string",default:""},{name:"octave",type:"number",default:4},{name:"color",type:"string",default:"#000"}]};static deSugarAtom(t,e,n){let o=0;switch(t[e]){case"(":case"]":o=-1;break;case"[":case")":o=1;break}if(o)return{next:e+1,node:{kind:"sugar",data:{jeOffset:o},span:{start:e,end:e+1},syntaxKind:"punctuation"}};let s=zt(t,e,n);if(s instanceof E)return null;let i=new Map;i.set("name",s.name),s.octave!==null&&i.set("octave",s.octave),s.acc&&i.set("acc",s.acc);let c={kind:"call",typed:!0,name:"note",args:i,span:{start:e,end:s.next},syntaxKind:"atom"};return{next:s.next,node:c}}static deSugarRelation(t,e,n){let o=e[n],s=o.data?.jeOffset;return typeof s!="number"?null:(t.variables[bn]=(t.variables[bn]??0)+s,t.nodes.push(new H(o.span)),n+1)}labelable(){return this}loweringEnter(){return[new Cn(this)]}name;octave;acc;color;size;font;jeOctaveOffset;constructor(t,e,n,o=null){super(t,o),[this.name,this.acc,this.octave,this.color]=this.getArgValue(e,n),this.font=n.variables.numberfont,this.size=n.variables.fontsize;let s=zt(this.name);if(s instanceof E)throw s.span=t,s;if(s.next!==this.name.length)throw new C("E_WRONG_NOTE_NAME",`\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u65E0\u6CD5\u89E3\u6790\u5C3E\u90E8 "${this.name.slice(s.next)}"`,t);this.name=s.name==="X"?"9":s.name==="Z"?"0":s.name;let i=e.get("octave")??e.get(2);if(i!==void 0){if(s.octave!==null&&s.octave!=i)throw new C("E_NOTE_OCTAVE_CONFLICT",`\u51FD\u6570 @note \u7684\u53C2\u6570 "octave" \u4E0E\u97F3\u7B26\u540D\u79F0\u4E2D\u7684\u516B\u5EA6\u4FE1\u606F\u51B2\u7A81: ${i} != ${s.octave}`,t)}else s.octave!==null?this.octave=s.octave:s.absOctave||(this.octave=0);this.jeOctaveOffset=n.variables[bn]??0,s.acc!==null&&(this.acc=s.acc+this.acc)}toString(){return`@n(${this.name}, ${this.acc}, ${this.octave}, ${this.color})`}},os=wn,Bi={8:"",9:"X"},Cn=class extends P{resolvedMidi=null;transposeDiatonic;name;acc;octave;accidentals=[];numberStyle;upperOctaveDotY=[];lowerOctaveDotY=[];octaveDotRadius=0;numberY=0;constructor(t){super(),this.ast=t,this.T.set(1),this.mergeKey=J,this.name=t.name,this.acc=t.acc,this.octave=t.octave+t.jeOctaveOffset,this.numberStyle={fontSize:t.size,fontFamily:t.font,fontWeight:400,textAlign:"center",fill:t.color},this.initLayoutBox()}prepareLayout(t){this.upperOctaveDotY.length=0,this.lowerOctaveDotY.length=0;let{size:e,color:n}=this.ast,o=t.textMeasurer.measureText("0",this.numberStyle),s=Math.abs(this.octave);this.octaveDotRadius=e*.065;let i=e*.08,c=this.octaveDotRadius*2+i,a=s===0?0:s*this.octaveDotRadius*2+(s-1)*i+i,l=this.octave>0?a:0;this.numberY=l+o.baseline;let h=e*.01,{placed:p,right:f}=le(this.acc,e,0,this.numberY,h);if(this.accidentals=p,this.box.w=f+o.w,this.box.h=l+o.h,this.box.anchor=f+o.w/2,this.box.visualAxis=l+o.h/2,this.ports["body.left"]={x:this.box.anchor-o.w/2,y:this.box.visualAxis},this.ports["body.right"]={x:this.box.anchor+o.w/2,y:this.box.visualAxis},this.ports.dot={x:this.box.w,y:l+o.h*.64},this.octave>0){for(let g=0;g<s;g++)this.upperOctaveDotY.push(l-i-this.octaveDotRadius-g*c);return}if(this.octave>=0)return;let d=s*this.octaveDotRadius*2+(s-1)*i,x={below:{order:100,gap:i,height:d,place:g=>{for(let y=0;y<s;y++)this.lowerOctaveDotY.push(g+this.octaveDotRadius+y*c)}},paint:g=>{for(let y of this.lowerOctaveDotY)g.drawCircle(this.box.x+this.box.anchor,this.box.y+y,this.octaveDotRadius,{fill:n})}};this.decorations.push(x)}finalizeLayout(){this.ports.lyric={x:this.box.anchor,y:this.box.h}}paint(t){let e=this.ast.color;for(let o of this.accidentals)he(t,o,this.box,e);let n=Bi[this.name]??this.name;n&&t.drawText(n,this.box.x+this.box.anchor,this.box.y+this.numberY,this.numberStyle);for(let o of this.upperOctaveDotY)t.drawCircle(this.box.x+this.box.anchor,this.box.y+o,this.octaveDotRadius,{fill:e})}onTimeState(t){let e=t.keySignature;if(this.playbackState={bpm:t.bpm,velocity:t.velocity,program:t.program},this.resolvedMidi=cn(this.name,this.acc,this.octave,e),this.transposeDiatonic=Xo(this.name,this.acc,this.octave,e),this.name>="0"&&this.name<="9")(this.name==="0"||this.name>="8")&&(this.octave=0,this.acc="");else{let n=an(this.name,this.acc,this.octave,e);n&&(this.name=n.renderName,this.acc=n.renderAcc,this.octave=n.renderOctave)}}emitPlayback(t){let e=this.ast.name==="9",n=e?37:this.resolvedMidi;if(n===null||t.end.compare(t.start)<=0)return;let o=t.nextNoteId();t.emit({kind:"note-on",at:t.start,noteId:o,midi:n,velocity:this.playbackState?.velocity??bt,...e?{percussion:!0}:{transpose:this.transposeDiatonic}}),t.emit({kind:"note-off",at:t.end,noteId:o})}};var ge=class r extends T{contents=[];belows=[];size;get side(){return this.constructor.side}get children(){return this.belows.length?[...this.contents,...this.belows]:this.contents}constructor(t,e,n,o=null){super(t,o),this.size=n.variables.fontsize;for(let[,s]of e){if(s instanceof Y){this.addContent(s,this.side,n);continue}let i=n.parseArgWithType(s.valueSpan,"content",t.start);i!==null&&this.addContent(i,this.side,n)}}labelable(){return this.children.some(T.findLabelable)?this:null}addContent(t,e,n){return this.contents.length===0&&(e="above"),t instanceof r?this.flatten(t,e,n):((e==="above"?this.contents:this.belows).push(t),t.parent=this,this.growSpan(t.sourceSpan),this)}growSpan(t){this.sourceSpan.start=Math.min(this.sourceSpan.start,t.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,t.end)}loweringEnter(t,e){let n=[];return t.isolateFromLoweringGroups(()=>{for(let o of this.children){let[s,...i]=t.trackedEvents(o,new M,e).flat();if(!s||i.length>0||!D(s))throw new C("E_UP_INVALID_CHILD","@up \u7684\u6BCF\u4E2A\u53C2\u6570\u5FC5\u987B\u6070\u597D\u4EA7\u751F\u4E00\u4E2A\u53EF\u89C1 Temporal\uFF0C\u4E14\u4E0D\u80FD\u5305\u542B\u591A\u58F0\u90E8\u7ED3\u6784",o.sourceSpan);n.push(s)}}),[new Ln(this,n)]}toString(t){let e=this.contents.map(o=>o.toString(t));return this.belows.length===0?`@up(${e.join(", ")})`:`@down(${[e.length>1?`@up(${e.join(", ")})`:e[0],...this.belows.map(o=>o.toString(t))].join(", ")})`}flatten(t,e,n){let o=t.sourceSpan.start<this.sourceSpan.start?t:this,s=o===t?this:t,[i,...c]=s.contents,a=i?[i]:[],l=[...o.contents,...e==="above"?a:[],...c],h=[...o.belows,...e==="below"?a:[],...s.belows];this.contents=l,this.belows=h;for(let f of this.children)f.parent=this;this.growSpan(t.sourceSpan),t.contents=[],t.belows=[];let p=n.labelableNodes.indexOf(t);return p>=0&&n.labelableNodes.splice(p,1),this}static desugar(t,e,n){let o=e[n++];if(!(o.kind==="sugar"&&o.data===this))return null;let s=this.side==="above"?"@up":"@down",i=t.nodes.length-1;for(;i>=0&&t.nodes[i]instanceof H;)i--;if(i<0)throw new C("E_FOLD_NO_TARGET",`${s}\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807`,o.span);let c=t.nodes[i],a=i;if(c instanceof Q){let p=c,f=p.target;for(;f&&!t.nodes.includes(f);)f=f.parent;for(let d=i-1;d>=0;d--)if(t.nodes[d]===f){c=new z({start:f.sourceSpan.start,end:p.sourceSpan.end},t.nodes.slice(d,i+1),null),a=d;break}}let l=c instanceof r?c:new this(o.span,new Map,t).addContent(c,"above",t),h=t.nodes;t.nodes=[],t.makeNodes(e,n);for(let p=0;p<t.nodes.length;p++){let f=t.nodes[p];if(f instanceof H)continue;let d=f instanceof r?f.flatten(l,this.side,t):l.addContent(f,this.side,t);for(h.length=a,h.push(d);++p<t.nodes.length;)h.push(t.nodes[p]);return t.nodes=h,t.labelableNodes.push(d.labelable()),e.length}throw new C("E_FOLD_NO_TARGET",`${s}\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807`,o.span)}},Sn=class r extends ge{static side="above";static def={name:["up"],description:"\u628A\u540C\u4E00\u65F6\u95F4\u4F4D\u7F6E\u7684\u53EF\u89C1\u5BF9\u8C61\u5411\u4E0A\u5806\u53E0",example:`@up(content1, content2, ...)
86
+ \u8BED\u6CD5\u7CD6: ^
87
+ {content1} ^ {content2} ^ ...
88
+ \u7B2C\u4E00\u4E2A\u53C2\u6570\u662F\u5BBF\u4E3B\uFF0C\u5176\u4F59\u4F9D\u6B21\u53E0\u5728\u5B83\u7684\u4E0A\u65B9\uFF0C\u5E38\u7528\u4E8E\u548C\u5F26\u3001\u53D8\u901F\u8BB0\u53F7\u3001\u97F3\u7B26\u6CE8\u91CA\u3002
89
+ \u5168\u4F53\u6210\u5458\u6298\u53E0\u6210\u4E00\u4E2A\u4E8B\u4EF6\u3001\u5171\u4EAB\u5BBF\u4E3B\u7684\u65F6\u503C\uFF1B\u9700\u8981\u5404\u81EA\u72EC\u7ACB\u65F6\u503C\u7684\u5E76\u884C\u5206\u652F\u8BF7\u7528 & / @stack\u3002
90
+ `,allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,n){if(t[e]!=="^")return null;let o={kind:"sugar",data:r,span:{start:e,end:e+1}};return{next:e+1,node:o}}static deSugarRelation(t,e,n){return r.desugar(t,e,n)}},An=class r extends ge{static side="below";static def={name:["down"],description:"\u628A\u540C\u4E00\u65F6\u95F4\u4F4D\u7F6E\u7684\u53EF\u89C1\u5BF9\u8C61\u5411\u4E0B\u5806\u53E0",example:`@down(content1, content2, ...)
91
+ \u8BED\u6CD5\u7CD6: _
92
+ {content1} _ {content2} _ ...
93
+ \u7B2C\u4E00\u4E2A\u53C2\u6570\u662F\u5BBF\u4E3B\uFF0C\u5176\u4F59\u4F9D\u6B21\u53E0\u5728\u5B83\u7684\u4E0B\u65B9\uFF0C\u5E38\u7528\u4E8E\u529B\u5EA6\u8BB0\u53F7\u7B49\u5199\u5728\u97F3\u7B26\u4E0B\u9762\u7684\u6807\u8BB0\u3002
94
+ \u4E0E ^ \u6DF7\u5199\u65F6\u5168\u90E8\u7ED1\u5230\u540C\u4E00\u4E2A\u5BBF\u4E3B\uFF1A1^2_3 \u8868\u793A 2 \u5728\u4E0A\u30013 \u5728\u4E0B\u3002
95
+ `,allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,n){if(t[e]!=="_")return null;let o={kind:"sugar",data:r,span:{start:e,end:e+1}};return{next:e+1,node:o}}static deSugarRelation(t,e,n){return r.desugar(t,e,n)}},ss=Sn,is=An,Ln=class extends P{members;aboveCount;verticalOffsets=[];constructor(t,e){super(),this.ast=t,this.members=e,this.aboveCount=t.contents.length;let n=e.find(s=>!s.T.isZero());n&&this.T.copyFrom(n.T),this.mergeKey=J,this.initLayoutBox();let o=e[0]?.addon;o&&(this.addon={...o});for(let s of e)s.mergeKey===G&&(this.mergeKey=G),s.addon=void 0,s.foldedInto=this}onTimeState(t){for(let e=this.members.length-1;e>=0;e--){let n=this.members[e];n.T.isZero()||n.T.copyFrom(this.T),n.t.copyFrom(this.t),n.track=this.track,n.layoutLine=this.layoutLine,n.onTimeState?.(t)}}emitPlayback(t){for(let e=this.members.length-1;e>=0;e--)t.play(this.members[e])}prepareHorizontal(t){this.members[0]?.prepareHorizontal?.(t)}prepareLayout(t){this.addon&&this.members[0]&&(this.members[0].addon=this.addon,this.addon=void 0);for(let h of this.members)et(h,t);let e=this.members[0];if(!e){this.box.w=this.box.h=0,this.box.anchor=this.box.visualAxis=0;return}this.springConfig={...e.springConfig,...this.springConfig};let n=e.box.anchor,o=this.ast.size*.12;this.verticalOffsets.length=this.members.length,this.verticalOffsets.fill(0);let s=0;for(let h=1;h<this.aboveCount;h++)s-=o+this.members[h].box.h,this.verticalOffsets[h]=s;let i=e.box.h;for(let h=this.aboveCount;h<this.members.length;h++)i+=o,this.verticalOffsets[h]=i,i+=this.members[h].box.h;for(let h=0;h<this.verticalOffsets.length;h++)this.verticalOffsets[h]-=s;this.box.w=e.box.w,this.box.h=i-s,this.box.anchor=n,this.box.visualAxis=e.box.visualAxis-s;let c=this.verticalOffsets[0];for(let h in e.ports){let p=e.ports[h];this.ports[h]={x:p.x,y:c+p.y}}this.ports["body.left"]??={x:0,y:this.box.visualAxis},this.ports["body.right"]??={x:e.box.w,y:this.box.visualAxis};let a=this.aboveCount-1,l=this.verticalOffsets[a];this.ports["tie.top"]={x:n,y:l+(this.members[a].ports["tie.top"]?.y??0)}}onPlaced(){for(let t=0;t<this.members.length;t++){let e=this.members[t];e.box.x=this.box.x+this.box.anchor-e.box.anchor,e.box.y=this.box.y+this.verticalOffsets[t],e.onPlaced?.()}}paint(t){for(let e of this.members){e.paint(t);for(let n of e.decorations)n.paint(t)}}};var kt=r=>({value:r,unit:"px"}),Tn=16,zi={fontSize:Tn,textAlign:"center",fill:"#606060"};function Hi(r,t,e){let n=r.lastIndexOf("1"),o=r.indexOf("1")!==n;return r.replace(/1/g,(s,i)=>String(o&&i===n?e:t))}var En=class{sourceSpan;pattern;marginBottom;style;layer="foreground";constructor(t,e,n,o){this.sourceSpan=t,this.pattern=e,this.marginBottom=n,this.style=o}createGeometry(t){let e=this.style,n=t.pages.map((o,s)=>{let i=Hi(this.pattern,s+1,t.pages.length),{w:c,h:a,baseline:l}=t.textMeasurer.measureText(i,e),h=o.y+o.h-this.marginBottom/2;return{text:i,x:o.x+o.w/2,y:h-a/2+l,w:c,h:a,baseline:l}});return{regions:n.map(({x:o,y:s,w:i,h:c,baseline:a})=>({x:o-i/2,y:s-a,w:i,h:c})),paint(o){for(let s of n)o.drawText(s.text,s.x,s.y,e)}}}},_n=class extends T{static def={name:["page"],description:"\u8BBE\u7F6E\u6587\u6863\u9875\u9762\u5C3A\u5BF8\u3001\u8FB9\u8DDD\u3001\u6700\u5C0F\u8C31\u9762\u884C\u95F4\u8DDD\u548C\u9875\u7801",example:'@page(width=794px, height=1123px, top=48px, bottom=48px, left=40px, right=40px, gap=1em, numbering="1/1")',allowExtraArgs:!1,args:[{name:"width",type:"length",default:kt(Z.width)},{name:"height",type:"length",default:kt(0)},{name:"top",type:"length",default:kt(Z.marginTop)},{name:"bottom",type:"length",default:kt(Z.marginBottom)},{name:"left",type:"length",default:kt(Z.marginLeft)},{name:"right",type:"length",default:kt(Z.marginRight)},{name:"gap",type:"length",default:{value:1,unit:"em"}},{name:"numbering",type:"string",default:""},{name:"font",type:"string",default:""}]};config;numbering="";font;constructor(t,e,n,o=null){if(super(t,o),this.font=n.variables.font,n.scopeDepth!==0){n.diagnostics.push(new k("W_PAGE_NOT_TOP_LEVEL","@page \u53EA\u80FD\u5728\u6587\u6863\u9876\u5C42\u58F0\u660E\uFF1B\u5F53\u524D\u58F0\u660E\u5DF2\u5FFD\u7565",t)),this.config=null;return}if(n.documentDeclarations.page){n.diagnostics.push(new k("W_DUPLICATE_PAGE","\u6587\u6863\u53EA\u80FD\u58F0\u660E\u4E00\u4E2A @page\uFF1B\u540E\u7EED\u58F0\u660E\u5DF2\u5FFD\u7565",t)),this.config=null;return}n.documentDeclarations.page=!0;let s=this.getArgValue(e,n);this.font=s.pop()||n.variables.font;let i=s.pop(),[c,a,l,h,p,f,d]=s.map(x=>n.length2px(x));if(!Number.isFinite(c)||c<=0)throw E.error.InvalidPageConfig("@page \u7684 width \u5FC5\u987B\u662F\u6B63\u6709\u9650\u957F\u5EA6",t);if(!Number.isFinite(a)||a<0)throw E.error.InvalidPageConfig("@page \u7684 height \u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u957F\u5EA6\uFF1B0 \u8868\u793A\u4E0D\u5206\u9875",t);if([l,h,p,f,d].some(x=>!Number.isFinite(x)||x<0))throw E.error.InvalidPageConfig("@page \u7684\u8FB9\u8DDD\u548C gap \u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u957F\u5EA6",t);if(p+f>=c)throw E.error.InvalidPageConfig("@page \u7684\u5DE6\u53F3\u8FB9\u8DDD\u6CA1\u6709\u7559\u4E0B\u53EF\u7528\u5185\u5BB9\u5BBD\u5EA6",t);if(a>0&&l+h>=a)throw E.error.InvalidPageConfig("@page \u7684\u4E0A\u4E0B\u8FB9\u8DDD\u6CA1\u6709\u7559\u4E0B\u53EF\u7528\u5185\u5BB9\u9AD8\u5EA6",t);if(i&&h<Tn)throw E.error.InvalidPageConfig(`@page \u7684 bottom \u81F3\u5C11\u9700\u8981 ${Tn}px \u624D\u80FD\u653E\u4E0B\u9875\u7801`,t);this.config=Ot({width:c,height:a,marginTop:l,marginBottom:h,marginLeft:p,marginRight:f,lineGap:d}),this.numbering=i}loweringEnter(t){return!t||!this.config?[]:(t.setPageConfig(this.config),this.numbering&&t.addAttachment(new En(this.sourceSpan,this.numbering,this.config.marginBottom,{...zi,fontFamily:this.font})),[])}toString(){if(!this.config)return"@page()";let{width:t,height:e,marginTop:n,marginBottom:o,marginLeft:s,marginRight:i,lineGap:c}=this.config;return`@page(width=${t}px, height=${Number.isFinite(e)?e:0}px, top=${n}px, bottom=${o}px, left=${s}px, right=${i}px, gap=${c}px, numbering=${tt(this.numbering)}, font=${tt(this.font)})`}},rs=_n;var vn=class extends T{static def={name:["program","instrument"],description:"\u8BBE\u7F6E\u5F53\u524D\u97F3\u8F68\u7684 MIDI \u97F3\u8272",example:"@program(40) \u5C06\u540E\u7EED\u97F3\u7B26\u5207\u6362\u5230 MIDI program 40",allowExtraArgs:!1,args:[{name:"program",type:"number",default:null}]};program;constructor(t,e,n,o=null){super(t,o);let[s]=this.getArgValue(e,n);if(!Number.isSafeInteger(s)||s<0||s>127)throw new C("E_PROGRAM_INVALID","@program \u5FC5\u987B\u662F 0..127 \u7684\u6574\u6570",t);this.program=s}loweringEnter(){let t=new P;return t.ast=this,t.playbackState={program:this.program},t.onTimeState=e=>{e.program=this.program},[t]}toString(){return`@program(${this.program})`}},cs=vn;var as=.4,Wi=(r,t,e)=>r.top-e*as-t.bottom,Gi=(r,t)=>{let e=t*as,n=[],o=0;for(let s of r){if(!s){n.push(null);continue}let i=o-s.bottom;n.push({offset:i,extent:s}),o=i+s.top-e}return n},Vi={laneKey:"stack",measure:Gi,place:Wi},kn=class r extends T{static def={name:["stack"],description:"\u4E34\u65F6\u591A\u58F0\u90E8",example:`@stack(content1, content2, ...)
96
+ \u8BED\u6CD5\u7CD6: &
97
+ {content1} & {content2} & ...
98
+ \u8868\u793Acontent1\u548Ccontent2\u5728\u65F6\u95F4\u4E0A\u5B8C\u5168\u91CD\u53E0\uFF0C\u901A\u5E38\u7528\u4E8E\u548C\u58F0\u7B49\u9700\u8981\u5BF9\u9F50\u7684\u573A\u666F\u3002\u53EF\u4EE5\u6709\u4EFB\u610F\u591A\u4E2A\u53C2\u6570\uFF0C\u81F3\u5C11\u9700\u8981\u4E24\u4E2A\u53C2\u6570\u3002
99
+ `,allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,n){if(t[e]==="&"){let o={kind:"sugar",data:r,span:{start:e,end:e+1}};return{next:e+1,node:o}}return null}static deSugarRelation(t,e,n){let o=e[n++];if(!(o.kind==="sugar"&&o.data===r))return null;let s=t.nodes.length-1;for(;s>=0&&t.nodes[s]instanceof H;s--);let i=s>=0?t.nodes[s]:null;if(i===null)throw new C("E_STACK_NO_TARGET","@stack\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807",o.span);let c=s;if(i instanceof Q){let h=i,p=h.target;for(;p&&!t.nodes.includes(p);)p=p.parent;for(let f=s-1;f>=0;f--)if(t.nodes[f]===p){i=new z({start:p.sourceSpan.start,end:h.sourceSpan.end},t.nodes.slice(f,s+1),null),c=f;break}}let a=i instanceof r?i:new r(o.span,new Map,t).addContent(i),l=t.nodes;t.nodes=[],t.makeNodes(e,n);for(let h=0;h<t.nodes.length;h++){let p=t.nodes[h];if(!(p instanceof H)){for(a.addContent(p),l.length=c,l.push(a);++h<t.nodes.length;)l.push(t.nodes[h]);return t.nodes=l,e.length}}throw new C("E_STACK_NO_TARGET","@stack\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807",o.span)}contents=[];get children(){return this.contents}timeFlowModel(){return{children:this.contents,mode:"parallel",tracks:Vi}}constructor(t,e,n,o=null){super(t,o);for(let[,s]of e){if(s instanceof Y){this.addContent(s);continue}let i=n.parseArgWithType(s.valueSpan,"content",t.start);i!==null&&this.addContent(i)}}addContent(t){if(t instanceof r)return this.combine(t);this.contents.push(t),t.parent=this;let e=t.sourceSpan;return this.sourceSpan.start=Math.min(this.sourceSpan.start,e.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,e.end),this}toString(t){return`@stack(
100
+ ${this.contents.map(n=>n.toString(t)).join(`,
101
+ `).split(`
102
+ `).join(`
103
+ `)}
104
+ )`}combine(t){this.sourceSpan.start=Math.min(this.sourceSpan.start,t.sourceSpan.start),this.sourceSpan.end=Math.max(this.sourceSpan.end,t.sourceSpan.end);for(let e of t.contents)e.parent=this;return this.contents.push(...t.contents),t.contents.length=0,this}},ls=kn;function hs(r){let t=1/0,e=1/0,n=-1/0,o=-1/0,s=(i,c,a,l)=>{t=Math.min(t,i),e=Math.min(e,c),n=Math.max(n,i+a),o=Math.max(o,c+l)};for(let i of r){let c=i.dx??0;if(i.circle){let{cx:a,cy:l,r:h}=i.circle;s(a+c-h,l-h,2*h,2*h)}if(i.path?.length){let a=St(i.path);s(a.x+c,a.y,a.w,a.h)}}return Number.isFinite(t)?{x:t,y:e,w:Math.max(1e-9,n-t),h:Math.max(1e-9,o-e)}:{x:0,y:0,w:1e-9,h:1e-9}}function ps(r,t,e,n,o){let s=n.x-e.x*o,i=n.y-e.y*o;for(let c of t){let a=c.style,l=a.strokeWidth===void 0?a:{...a,strokeWidth:a.strokeWidth*o},h=s+(c.dx??0)*o;c.path&&r.drawPath(c.path,l,{x:h,y:i,scaleX:o,scaleY:o}),c.circle&&r.drawCircle(h+c.circle.cx*o,i+c.circle.cy*o,c.circle.r*o,l)}}var fs={name:"accent",description:"\u91CD\u97F3",weight:.5,shapes:[{path:[{op:"M",x:.21413,y:.4818},{op:"L",x:8.21413,y:3.72071},{op:"L",x:.29494,y:6.92724}],style:{stroke:"#000",strokeWidth:1}}],emitPlayback:r=>r.affectFollowing((t,e)=>{for(let n of e)n.kind==="note-on"&&(n.velocity=Math.min(127,n.velocity+20))})};var Wt="repeat.jump",us={name:"dc",description:"\u4ECE\u5934\u53CD\u590D\uFF1A\u8DF3\u56DE\u66F2\u9996\u518D\u6F14\u4E00\u904D",weight:.9,shapes:[{path:[{op:"M",x:1.06974,y:7.0752},{op:"L",x:2.69184,y:1.21499},{op:"C",cx1:2.69184,cy1:1.1221,cx2:2.73825,cy2:.93022,x:2.73825,y:.86039},{op:"C",cx1:2.73825,cy1:.48248,cx2:2.4825,cy2:.33152,x:1.7614,y:.23838},{op:"L",x:1.7614,y:.04641},{op:"L",x:4.88344,y:.04641},{op:"C",cx1:7.64477,cy1:.04641,cx2:9.02278,cy2:1.18018,x:9.02278,y:3.45323},{op:"C",cx1:9.02278,cy1:4.47649,cx2:8.74941,cy2:5.36592,x:8.20888,y:6.11596},{op:"C",cx1:7.6681,cy1:6.86578,cx2:6.95303,cy2:7.4297,x:6.05765,y:7.81334},{op:"C",cx1:5.16823,cy1:8.19125,cx2:4.22074,cy2:8.38316,x:3.21493,y:8.38316},{op:"L",x:0,y:8.38316},{op:"L",x:0,y:8.19119},{op:"C",cx1:.64542,cy1:8.19126,cx2:.91275,cy2:7.81343,x:1.06974,y:7.07521},{op:"L",x:1.06974,y:7.0752},{op:"Z"},{op:"M",x:4.09864,y:.66867},{op:"L",x:2.2848,y:7.35998},{op:"C",cx1:2.2848,cy1:7.42409,cx2:2.26718,cy2:7.48786,x:2.23815,y:7.55197},{op:"C",cx1:2.29051,cy1:7.84841,cx2:2.58133,cy2:7.99961,x:3.12179,y:7.99961},{op:"C",cx1:3.97639,cy1:7.99961,cx2:4.74389,cy2:7.79034,x:5.42397,y:7.37165},{op:"C",cx1:6.10429,cy1:6.94733,cx2:6.62746,cy2:6.37751,x:7.00538,y:5.65666},{op:"C",cx1:7.3833,cy1:4.92994,cx2:7.5752,cy2:4.1334,x:7.5752,y:3.26134},{op:"C",cx1:7.5752,cy1:1.372,cx2:6.69156,cy2:.43029,x:4.92984,y:.43029},{op:"C",cx1:4.53471,cy1:.43029,cx2:4.25555,cy2:.51151,x:4.09864,y:.66869},{op:"L",x:4.09864,y:.66867},{op:"Z"},{op:"M",x:18.35961,y:.04641},{op:"L",x:17.90593,y:2.62204},{op:"L",x:17.66755,y:2.62204},{op:"C",cx1:17.563,cy1:1.19183,cx2:16.91187,cy2:.47678,x:15.71418,y:.47678},{op:"C",cx1:14.96437,cy1:.47678,cx2:14.29564,cy2:.73848,x:13.70274,y:1.26165},{op:"C",cx1:13.11556,cy1:1.77911,cx2:12.65617,cy2:2.43578,x:12.33664,y:3.22668},{op:"C",cx1:12.01679,cy1:4.01155,cx2:11.85988,cy2:4.77302,x:11.85988,y:5.49984},{op:"C",cx1:11.85988,cy1:6.26131,cx2:12.03424,cy2:6.90076,x:12.37734,y:7.41814},{op:"C",cx1:12.72598,cy1:7.9356,cx2:13.24931,cy2:8.19126,x:13.95279,y:8.19126},{op:"C",cx1:15.08622,cy1:8.19126,cx2:16.11543,cy2:7.68548,x:17.02818,y:6.66825},{op:"L",x:17.21412,y:6.86023},{op:"C",cx1:16.26663,cy1:8.16232,cx2:15.08051,cy2:8.81352,x:13.66775,y:8.81352},{op:"C",cx1:13.034,cy1:8.81352,cx2:12.47014,cy2:8.65637,x:11.97608,y:8.34254},{op:"C",cx1:11.48195,cy1:8.02864,cx2:11.10411,cy2:7.60432,x:10.83074,y:7.06925},{op:"C",cx1:10.56333,cy1:6.53442,cx2:10.42974,cy2:5.94748,x:10.42974,y:5.31357},{op:"C",cx1:10.42974,cy1:4.43581,cx2:10.67383,cy2:3.58692,x:11.15655,y:2.7616},{op:"C",cx1:11.63894,cy1:1.93602,cx2:12.28427,cy2:1.26738,x:13.09223,y:.76158},{op:"C",cx1:13.90042,cy1:.25578,cx2:14.74336,cy2:3e-5,x:15.62137,y:3e-5},{op:"C",cx1:15.88283,cy1:3e-5,cx2:16.12121,cy2:.0174,x:16.33651,y:.0581},{op:"C",cx1:16.55157,cy1:.09886,cx2:16.79557,cy2:.15122,x:17.05729,y:.21501},{op:"C",cx1:17.31875,cy1:.2791,cx2:17.51072,cy2:.31979,x:17.62123,y:.33717},{op:"C",cx1:17.85961,cy1:.2557,cx2:18.03389,cy2:.15694,x:18.14432,y:.04643},{op:"L",x:18.35962,y:.04643},{op:"L",x:18.35961,y:.04644},{op:"Z"},{op:"M",x:8.19134,y:7.69151},{op:"C",cx1:8.19134,cy1:7.5169,cx2:8.25544,cy2:7.36596,x:8.38894,y:7.2322},{op:"C",cx1:8.52277,cy1:7.09838,cx2:8.69134,cy2:7.0288,x:8.88332,y:7.0288},{op:"C",cx1:9.0519,cy1:7.0288,cx2:9.19722,cy2:7.09838,x:9.3251,y:7.2322},{op:"C",cx1:9.45893,cy1:7.36603,cx2:9.5227,cy2:7.52294,x:9.5227,y:7.69151},{op:"C",cx1:9.5227,cy1:8.0925,cx2:9.23221,cy2:8.38324,x:8.88332,y:8.38324},{op:"C",cx1:8.48803,cy1:8.38324,cx2:8.19134,cy2:8.10416,x:8.19134,y:7.69151},{op:"Z"},{op:"M",x:18.00469,y:7.79028},{op:"C",cx1:18.00469,cy1:7.40068,cx2:18.27814,cy2:7.12162,x:18.64432,y:7.12162},{op:"C",cx1:19.03969,cy1:7.12162,cx2:19.31298,cy2:7.39507,x:19.31298,y:7.79028},{op:"C",cx1:19.31298,cy1:8.15653,cx2:19.0339,cy2:8.42965,x:18.64432,y:8.42965},{op:"C",cx1:18.28972,cy1:8.42965,cx2:18.00469,cy2:8.14486,x:18.00469,y:7.79028},{op:"Z"}],style:{fill:"#000"}}],playbackMarks:()=>[Wt],onVisit:(r,t)=>r.visits(t)>1?void 0:{kind:"jump",column:0}};var Nn="repeat.segno",xs={name:"segno",description:"\u53CD\u590D\u8BB0\u53F7\uFF1AD.S. \u7684\u56DE\u8DF3\u76EE\u6807",weight:1.15,playbackMarks:()=>[Nn],shapes:[{path:[{op:"M",x:3.75502,y:7.52938},{op:"C",cx1:1.3411,cy1:6.32492,cx2:.10249,cy2:4.89115,x:.03897,y:3.23307},{op:"C",cx1:.06833,cy1:2.69176,cx2:.20975,cy2:2.17002,x:.45843,y:1.67267},{op:"C",cx1:.71191,cy1:1.1751,cx2:1.05826,cy2:.77042,x:1.49231,y:.46321},{op:"C",cx1:1.93115,cy1:.156,cx2:2.41873,cy2:0,x:2.95524,y:0},{op:"C",cx1:3.6136,cy1:0,cx2:4.17428,cy2:.17538,x:4.64747,y:.52174},{op:"C",cx1:5.12047,cy1:.8679,cx2:5.35457,cy2:1.36047,x:5.35457,y:1.99925},{op:"C",cx1:5.33499,cy1:2.26751,cx2:5.21315,cy2:2.49182,x:4.98384,y:2.66739},{op:"C",cx1:4.75473,cy1:2.83817,cx2:4.50106,cy2:2.93565,x:4.21343,y:2.95502},{op:"C",cx1:3.67691,cy1:2.90629,cx2:3.35013,cy2:2.68696,x:3.23807,y:2.29686},{op:"L",x:3.06249,y:1.73119},{op:"C",cx1:2.93086,cy1:1.31652,cx2:2.71134,cy2:1.0191,x:2.29687,y:1.0191},{op:"C",cx1:1.99446,cy1:1.0191,cx2:1.74578,cy2:1.16551,x:1.55561,y:1.46293},{op:"C",cx1:1.36544,cy1:1.76035,cx2:1.26798,cy2:2.06276,x:1.25819,y:2.37476},{op:"C",cx1:1.28735,cy1:2.79902,cx2:1.42398,cy2:3.17954,x:1.66287,y:3.50612},{op:"C",cx1:1.90677,cy1:3.8329,cx2:2.20418,cy2:4.11094,x:2.56012,y:4.34984},{op:"C",cx1:2.91627,cy1:4.58394,cx2:3.31116,cy2:4.79846,x:3.73542,y:4.99841},{op:"C",cx1:4.15967,cy1:5.19835,cx2:4.57914,cy2:5.38851,x:4.99361,y:5.57387},{op:"L",x:8.62659,y:.12183},{op:"L",x:9.70919,y:.12183},{op:"L",x:5.85194,y:5.97376},{op:"C",cx1:6.5005,cy1:6.29076,cx2:7.09535,cy2:6.65649,x:7.62705,y:7.06117},{op:"C",cx1:8.15855,cy1:7.47085,cx2:8.60221,cy2:7.95363,x:8.95835,y:8.50473},{op:"C",cx1:9.3143,cy1:9.05562,cx2:9.48985,cy2:9.65546,x:9.48985,y:10.30403},{op:"C",cx1:9.48985,cy1:10.86491,cx2:9.35822,cy2:11.39164,x:9.08996,y:11.88421},{op:"C",cx1:8.82652,cy1:12.37658,cx2:8.44618,cy2:12.77167,x:7.9488,y:13.0643},{op:"C",cx1:7.45147,cy1:13.35691,cx2:6.871,cy2:13.50314,x:6.21285,y:13.50314},{op:"C",cx1:5.62259,cy1:13.44461,cx2:5.1448,cy2:13.23009,x:4.78386,y:12.85457},{op:"C",cx1:4.42791,cy1:12.47906,cx2:4.23776,cy2:12.06938,x:4.21338,y:11.62572},{op:"C",cx1:4.23275,cy1:11.35746,cx2:4.33043,cy2:11.12338,x:4.5108,y:10.92821},{op:"C",cx1:4.69118,cy1:10.73326,cx2:4.94485,cy2:10.626,x:5.27163,y:10.60644},{op:"C",cx1:5.63239,cy1:10.60644,cx2:5.88605,cy2:10.68931,x:6.03726,y:10.85033},{op:"C",cx1:6.18828,cy1:11.01611,cx2:6.31031,cy2:11.26001,x:6.3932,y:11.58656},{op:"C",cx1:6.48092,cy1:11.91335,cx2:6.56377,cy2:12.14745,x:6.64186,y:12.2791},{op:"C",cx1:6.72476,cy1:12.41573,cx2:6.88578,cy2:12.48404,x:7.12944,y:12.48404},{op:"C",cx1:7.50019,cy1:12.48404,cx2:7.78783,cy2:12.35718,x:7.99756,y:12.10353},{op:"C",cx1:8.20729,cy1:11.85485,cx2:8.30974,cy2:11.52805,x:8.30974,y:11.12338},{op:"C",cx1:8.30974,cy1:10.57728,cx2:8.11459,cy2:10.11887,x:7.72451,y:9.74812},{op:"C",cx1:7.33918,cy1:9.38239,cx2:6.75395,cy2:9.00689,x:5.97375,y:8.62657},{op:"C",cx1:5.19353,cy1:8.25105,cx2:4.73513,cy2:8.01693,x:4.59371,y:7.92926},{op:"L",x:1.05823,y:13.42024},{op:"L",x:0,y:13.42024},{op:"L",x:3.755,y:7.52937},{op:"L",x:3.75502,y:7.52938},{op:"Z"},{op:"M",x:.07812,y:8.54848},{op:"C",cx1:.07812,cy1:8.20711,cx2:.18039,cy2:7.95364,x:.38033,y:7.78285},{op:"C",cx1:.58028,cy1:7.61227,cx2:.81937,cy2:7.5294,x:1.09721,y:7.5294},{op:"C",cx1:1.36068,cy1:7.55377,cx2:1.58499,cy2:7.65124,x:1.76535,y:7.822},{op:"C",cx1:1.94572,cy1:7.99259,cx2:2.03841,cy2:8.25105,x:2.03841,y:8.58763},{op:"C",cx1:2.03841,cy1:8.79736,cx2:1.93594,cy2:8.99731,x:1.736,y:9.19226},{op:"C",cx1:1.53606,cy1:9.39222,cx2:1.32153,cy2:9.48971,x:1.09721,y:9.48971},{op:"C",cx1:.81936,cy1:9.48971,cx2:.57548,cy2:9.41181,x:.37553,y:9.25081},{op:"C",cx1:.17558,cy1:9.08978,cx2:.07811,cy2:8.85588,x:.07811,y:8.54849},{op:"L",x:.07812,y:8.54848},{op:"Z"},{op:"M",x:8.3098,y:5.11547},{op:"C",cx1:8.3098,cy1:4.7789,cx2:8.4023,cy2:4.51564,x:8.58285,y:4.33027},{op:"C",cx1:8.76803,cy1:4.14508,cx2:9.00212,cy2:4.05242,x:9.28995,y:4.05242},{op:"C",cx1:9.57758,cy1:4.05242,cx2:9.82145,cy2:4.14011,x:10.01644,y:4.31568},{op:"C",cx1:10.21158,cy1:4.48627,cx2:10.30902,cy2:4.73994,x:10.30902,y:5.07152},{op:"C",cx1:10.30902,cy1:5.30083,cx2:10.20677,cy2:5.51036,x:10.00184,y:5.69572},{op:"C",cx1:9.7971,cy1:5.88108,cx2:9.57279,cy2:5.97376,x:9.32892,y:5.97376},{op:"C",cx1:9.07043,cy1:5.97376,cx2:8.83156,cy2:5.88587,x:8.62182,y:5.71529},{op:"C",cx1:8.41209,cy1:5.53971,cx2:8.3098,cy2:5.33977,x:8.3098,y:5.11546},{op:"L",x:8.3098,y:5.11547},{op:"Z"}],style:{fill:"#000"}}]};var ms={name:"ds",description:"\u4ECE\u8BB0\u53F7\u5904\u53CD\u590D\uFF1A\u8DF3\u56DE\u6700\u8FD1\u7684 $segno",weight:.9,shapes:[{path:[{op:"M",x:3.30971,y:8.58253},{op:"L",x:0,y:8.58253},{op:"L",x:0,y:8.38492},{op:"C",cx1:.66434,cy1:8.38492,cx2:.93964,cy2:7.9959,x:1.10119,y:7.23595},{op:"L",x:2.77112,y:1.20293},{op:"C",cx1:2.77112,cy1:1.10732,cx2:2.81892,cy2:.90973,x:2.81892,y:.83791},{op:"C",cx1:2.81892,cy1:.44886,cx2:2.55564,cy2:.29345,x:1.81333,y:.19758},{op:"L",x:1.81333,y:0},{op:"L",x:5.02743,y:0},{op:"C",cx1:7.87013,cy1:0,cx2:9.28879,cy2:1.16713,x:9.28879,y:3.50729},{op:"C",cx1:9.28879,cy1:4.56066,cx2:9.00736,cy2:5.47632,x:8.45088,y:6.24853},{op:"C",cx1:7.89416,cy1:7.02049,cx2:7.15799,cy2:7.60099,x:6.23624,y:7.9959},{op:"C",cx1:5.32063,cy1:8.38492,cx2:4.34519,cy2:8.58253,x:3.3097,y:8.58253},{op:"L",x:3.30971,y:8.58253},{op:"Z"},{op:"M",x:4.21944,y:.64057},{op:"L",x:2.35218,y:7.52917},{op:"C",cx1:2.35218,cy1:7.59509,cx2:2.33403,cy2:7.66079,x:2.30413,y:7.72673},{op:"C",cx1:2.35806,cy1:8.03196,cx2:2.65738,cy2:8.18763,x:3.21387,y:8.18763},{op:"C",cx1:4.71023,cy1:8.18763,cx2:5.84745,cy2:7.75053,x:6.6253,y:6.88271},{op:"C",cx1:7.40952,cy1:6.00899,cx2:7.79857,cy2:4.81807,x:7.79857,y:3.30973},{op:"C",cx1:7.79857,cy1:1.36475,cx2:6.88883,cy2:.39519,x:5.07525,y:.39519},{op:"C",cx1:4.66831,cy1:.39517,cx2:4.38101,cy2:.47876,x:4.21945,y:.64056},{op:"L",x:4.21944,y:.64056},{op:"Z"},{op:"M",x:17.3325,y:1e-5},{op:"L",x:16.81794,y:2.54976},{op:"L",x:16.57254,y:2.54976},{op:"C",cx1:16.57254,cy1:1.14312,cx2:16.03984,cy2:.44299,x:14.98033,y:.44299},{op:"C",cx1:14.57337,cy1:.44299,cx2:14.24416,cy2:.56262,x:13.98698,y:.80212},{op:"C",cx1:13.72958,cy1:1.04139,cx2:13.60383,cy2:1.35272,x:13.60383,y:1.74176},{op:"C",cx1:13.60383,cy1:2.10677,cx2:13.70556,cy2:2.424,x:13.91516,y:2.70518},{op:"C",cx1:14.12452,cy1:2.98048,cx2:14.45375,cy2:3.34575,x:14.91464,y:3.7946},{op:"C",cx1:15.37551,cy1:4.24346,cx2:15.72261,cy2:4.65626,x:15.9619,y:5.03332},{op:"C",cx1:16.20729,cy1:5.40444,cx2:16.32715,cy2:5.83541,x:16.32715,y:6.32621},{op:"C",cx1:16.35708,cy1:7.82844,cx2:15.01635,cy2:8.89386,x:13.70558,y:8.87572},{op:"C",cx1:13.47219,cy1:8.87572,cx2:13.12508,cy2:8.79188,x:12.65219,y:8.63033},{op:"C",cx1:12.17955,cy1:8.46874,cx2:11.86231,cy2:8.38489,x:11.69463,y:8.38489},{op:"C",cx1:11.45538,cy1:8.38489,cx2:11.25778,cy2:8.60652,x:11.20385,y:8.82787},{op:"L",x:10.95848,y:8.82787},{op:"L",x:11.40145,y:6.00895},{op:"L",x:11.69464,y:6.00895},{op:"C",cx1:11.69464,cy1:6.12272,cx2:11.67678,cy2:6.24847,x:11.64684,y:6.374},{op:"C",cx1:11.67065,cy1:6.93075,cx2:11.85619,cy2:7.40948,x:12.20332,y:7.82232},{op:"C",cx1:12.55657,cy1:8.22948,cx2:13.00544,cy2:8.43297,x:13.55603,y:8.43297},{op:"C",cx1:14.02891,cy1:8.43297,cx2:14.42384,cy2:8.26529,x:14.74108,y:7.92405},{op:"C",cx1:15.06418,cy1:7.58305,cx2:15.22573,cy2:7.18198,x:15.22573,y:6.72112},{op:"C",cx1:15.22573,cy1:6.34406,cx2:15.11223,cy2:6.00313,x:14.89062,y:5.69764},{op:"C",cx1:14.66925,cy1:5.39246,cx2:14.32802,cy2:5.00951,x:13.85538,y:4.54279},{op:"C",cx1:13.38247,cy1:4.07579,cx2:13.03535,cy2:3.67473,x:12.80197,y:3.33374},{op:"C",cx1:12.56858,cy1:2.99248,cx2:12.45484,cy2:2.59756,x:12.45484,y:2.16072},{op:"C",cx1:12.45484,cy1:1.53216,cx2:12.67621,cy2:1.01761,x:13.12509,y:.61042},{op:"C",cx1:13.57395,cy1:.20348,cx2:14.11864,cy2:2e-5,x:14.75896,y:2e-5},{op:"C",cx1:15.18993,cy1:2e-5,cx2:15.55495,cy2:.05983,x:15.86016,y:.17358},{op:"C",cx1:16.16536,cy1:.28733,cx2:16.38697,cy2:.34714,x:16.52452,y:.34714},{op:"C",cx1:16.6922,cy1:.34714,cx2:16.86576,cy2:.23339,x:17.03932,y:2e-5},{op:"L",x:17.33249,y:2e-5},{op:"L",x:17.3325,y:1e-5},{op:"Z"},{op:"M",x:8.43275,y:7.87042},{op:"C",cx1:8.43275,cy1:7.69072,cx2:8.4987,cy2:7.5353,x:8.63622,y:7.3975},{op:"C",cx1:8.774,cy1:7.25976,cx2:8.94755,cy2:7.18816,x:9.14514,y:7.18816},{op:"C",cx1:9.3187,cy1:7.18816,cx2:9.46824,cy2:7.25975,x:9.59988,y:7.3975},{op:"C",cx1:9.73766,cy1:7.53529,cx2:9.80338,cy2:7.69685,x:9.80338,y:7.87042},{op:"C",cx1:9.80338,cy1:8.28325,cx2:9.5043,cy2:8.58254,x:9.14514,y:8.58254},{op:"C",cx1:8.7382,cy1:8.58254,cx2:8.43275,cy2:8.29521,x:8.43275,y:7.87042},{op:"Z"},{op:"M",x:16.88952,y:7.9721},{op:"C",cx1:16.88952,cy1:7.57106,cx2:17.21875,cy2:7.28373,x:17.62569,y:7.28373},{op:"C",cx1:18.00297,cy1:7.28373,cx2:18.29003,cy2:7.56516,x:18.29003,y:7.9721},{op:"C",cx1:18.29003,cy1:8.34914,cx2:17.99096,cy2:8.63036,x:17.62569,y:8.63036},{op:"C",cx1:17.42219,cy1:8.63036,cx2:17.24863,cy2:8.56461,x:17.105,y:8.43887},{op:"C",cx1:16.96135,cy1:8.31309,cx2:16.88952,cy2:8.1577,x:16.88952,y:7.9721},{op:"Z"}],style:{fill:"#000"}}],playbackMarks:()=>[Wt],onVisit:(r,t)=>r.visits(t)>1?void 0:{kind:"jump",column:r.seek(Nn,t,-1)??0}};var Yi={m:[{op:"M",x:1.13,y:10.3672},{op:"L",x:2.9911,y:5.3125},{op:"C",cx1:3.0585,cy1:5.0607,cx2:3.0955,cy2:4.8889,x:3.0955,y:4.8089},{op:"C",cx1:3.0955,cy1:4.6248,cx2:2.9972,cy2:4.5327,x:2.7944,y:4.5327},{op:"C",cx1:2.5489,cy1:4.5327,cx2:2.217,cy2:4.7782,x:1.7994,y:5.2758},{op:"C",cx1:1.3881,cy1:5.7671,cx2:.9766,cy2:6.4856,x:.5774,y:7.4254},{op:"L",x:0,y:7.4254},{op:"C",cx1:.4976,cy1:6.3628,cx2:1.0133,cy2:5.4783,x:1.5476,y:4.7782},{op:"C",cx1:2.0882,cy1:4.0781,cx2:2.7576,cy2:3.7279,x:3.5498,y:3.7279},{op:"C",cx1:4.1518,cy1:3.7279,cx2:4.4773,cy2:4.0534,x:4.5264,y:4.7045},{op:"C",cx1:5.2818,cy1:4.0167,cx2:5.9512,cy2:3.6728,x:6.5409,y:3.6728},{op:"C",cx1:7.1796,cy1:3.6728,cx2:7.5235,cy2:4.0167,x:7.5728,y:4.7045},{op:"C",cx1:7.8797,cy1:4.3976,cx2:8.2483,cy2:4.1518,x:8.6843,y:3.9614},{op:"C",cx1:9.1205,cy1:3.7709,cx2:9.5197,cy2:3.6728,x:9.8882,y:3.6728},{op:"C",cx1:10.5393,cy1:3.6728,cx2:10.8645,cy2:3.943,x:10.8645,y:4.4834},{op:"C",cx1:10.8645,cy1:4.6001,cx2:10.8339,cy2:4.7905,x:10.7664,y:5.0607},{op:"L",x:9.3846,y:9.0345},{op:"C",cx1:9.3109,cy1:9.3353,cx2:9.2616,cy2:9.4951,x:9.2309,y:9.6364},{op:"C",cx1:9.2309,cy1:9.7959,cx2:9.3169,cy2:9.9066,x:9.4827,y:9.9619},{op:"C",cx1:10.011,cy1:9.8943,cx2:10.6988,cy2:9.1512,x:11.5463,y:7.7263},{op:"L",x:12.0499,y:7.7263},{op:"C",cx1:11.7981,cy1:8.1502,cx2:11.5279,cy2:8.6045,x:11.227,y:9.0958},{op:"C",cx1:10.9322,cy1:9.5811,cx2:10.6006,cy2:9.9864,x:10.2381,y:10.2996},{op:"C",cx1:9.8759,cy1:10.613,cx2:9.4583,cy2:10.7725,x:8.9791,y:10.7725},{op:"C",cx1:8.1499,cy1:10.7725,cx2:7.6279,cy2:10.3919,x:7.4191,y:9.6365},{op:"C",cx1:7.4437,cy1:9.397,cx2:7.5235,cy2:9.0775,x:7.6649,y:8.6783},{op:"C",cx1:7.806,cy1:8.279,cx2:7.8797,cy2:8.0395,x:7.8981,y:7.9535},{op:"L",x:8.9054,y:5.3619},{op:"C",cx1:8.924,cy1:5.2572,cx2:8.9791,cy2:5.0117,x:8.9791,y:4.9073},{op:"C",cx1:8.9791,cy1:4.6922,cx2:8.887,cy2:4.5818,x:8.7028,y:4.5818},{op:"C",cx1:8.1992,cy1:4.5818,cx2:7.8246,cy2:4.9257,x:7.5728,y:5.6137},{op:"L",x:5.8838,y:10.3673},{op:"L",x:4.0781,y:10.3673},{op:"L",x:5.9389,y:5.2635},{op:"C",cx1:5.9696,cy1:5.1591,cx2:5.9882,cy2:5.0424,x:5.9882,y:4.9073},{op:"C",cx1:5.9882,cy1:4.6922,cx2:5.8592,cy2:4.5818,x:5.6073,y:4.5818},{op:"C",cx1:5.159,cy1:4.6002,cx2:4.8335,cy2:4.944,x:4.6308,y:5.6137},{op:"L",x:2.8927,y:10.3673},{op:"L",x:1.13,y:10.3673},{op:"L",x:1.13,y:10.3672},{op:"Z"}],f:[{op:"M",x:6.1601,y:4.0781},{op:"C",cx1:6.4302,cy1:3.3717,cx2:6.8234,cy2:2.7086,x:7.3391,y:2.0882},{op:"C",cx1:7.8551,cy1:1.4679,cx2:8.4754,cy2:.9642,x:9.2062,y:.5773},{op:"C",cx1:9.937,cy1:.1904,cx2:10.7355,cy2:0,x:11.5953,y:0},{op:"C",cx1:12.0559,cy1:.043,cx2:12.4061,cy2:.2088,x:12.6333,y:.4913},{op:"C",cx1:12.8607,cy1:.7678,cx2:12.9772,cy2:1.1117,x:12.9772,y:1.5109},{op:"C",cx1:12.9772,cy1:1.9345,cx2:12.8421,cy2:2.3154,x:12.5659,y:2.6472},{op:"C",cx1:12.2954,cy1:2.9788,cx2:11.9578,cy2:3.1446,x:11.5463,y:3.1446},{op:"C",cx1:11.0487,cy1:3.1446,cx2:10.7662,cy2:2.9174,x:10.7111,y:2.4691},{op:"C",cx1:10.7418,cy1:2.1743,cx2:10.8522,cy2:1.8918,x:11.0427,y:1.6276},{op:"C",cx1:11.2331,cy1:1.3635,cx2:11.4666,cy2:1.1793,x:11.7428,y:1.087},{op:"C",cx1:11.8472,cy1:1.087,cx2:11.8965,cy2:1.0379,x:11.8965,y:.9335},{op:"C",cx1:11.8965,cy1:.8108,cx2:11.614,cy2:.6327,x:11.2147,y:.6327},{op:"C",cx1:10.0908,cy1:.6327,cx2:9.237,cy2:1.7811,x:8.6535,y:4.0781},{op:"L",x:10.8646,y:4.0781},{op:"L",x:10.8646,y:4.9073},{op:"L",x:8.4508,y:4.9073},{op:"C",cx1:8.2483,cy1:5.7918,cx2:7.9902,cy2:6.6944,x:7.671,y:7.6156},{op:"C",cx1:7.3577,cy1:8.5308,cx2:7.026,cy2:9.3723,x:6.676,y:10.1401},{op:"C",cx1:6.3319,cy1:10.9076,cx2:6.0064,cy2:11.5156,x:5.7055,y:11.9762},{op:"C",cx1:5.2632,cy1:12.658,cx2:4.7966,cy2:13.2353,x:4.299,y:13.7145},{op:"C",cx1:3.8016,cy1:14.1995,cx2:3.206,cy2:14.5067,x:2.5119,y:14.6418},{op:"C",cx1:2.211,cy1:14.6788,cx2:2.0266,cy2:14.6972,x:1.9592,y:14.6972},{op:"C",cx1:1.3632,cy1:14.6972,cx2:.8905,cy2:14.5128,x:.5527,y:14.1382},{op:"C",cx1:.2149,cy1:13.7636,cx2:.0307,cy2:13.3276,x:0,y:12.83},{op:"C",cx1:.0428,cy1:12.3941,cx2:.1718,cy2:12.0623,x:.3869,y:11.8351},{op:"C",cx1:.6017,cy1:11.6079,cx2:.9149,cy2:11.4298,x:1.3326,y:11.3008},{op:"C",cx1:1.6458,cy1:11.3254,cx2:1.9039,cy2:11.4359,x:2.1066,y:11.6324},{op:"C",cx1:2.3091,cy1:11.8352,cx2:2.4135,cy2:12.0809,x:2.4135,y:12.3818},{op:"C",cx1:2.4135,cy1:12.9405,cx2:1.8548,cy2:13.4134,x:1.4309,y:13.8127},{op:"C",cx1:1.4309,cy1:13.9171,cx2:1.5476,cy2:13.9664,x:1.7811,y:13.9664},{op:"C",cx1:2.7453,cy1:13.9664,cx2:3.5129,cy2:12.9405,x:4.0718,y:10.8955},{op:"C",cx1:4.2683,cy1:10.3426,cx2:4.4404,cy2:9.8083,x:4.5938,y:9.2926},{op:"C",cx1:4.7475,cy1:8.7703,cx2:4.9624,cy2:8.0028,x:5.2449,y:6.9832},{op:"C",cx1:5.5337,cy1:5.9575,cx2:5.7362,cy2:5.2695,x:5.8592,y:4.9073},{op:"L",x:4.1702,y:4.9073},{op:"L",x:4.1702,y:4.0781},{op:"L",x:6.1601,y:4.0781},{op:"Z"}],p:[{op:"M",x:3.767,y:8.5573},{op:"L",x:5.0097,y:5.0738},{op:"C",cx1:5.0804,cy1:4.7969,cx2:5.1126,cy2:4.5909,x:5.1126,y:4.443},{op:"C",cx1:5.1126,cy1:4.2497,cx2:5.0224,cy2:4.1531,x:4.8486,y:4.1531},{op:"C",cx1:4.7262,cy1:4.1531,cx2:4.5653,cy2:4.2497,x:4.3786,y:4.443},{op:"C",cx1:3.9471,cy1:4.9001,cx2:3.6059,cy2:5.383,x:3.3484,y:5.8917},{op:"L",x:2.6851,y:5.8917},{op:"C",cx1:2.8138,cy1:5.5117,cx2:3.0264,cy2:5.1126,x:3.3163,y:4.7004},{op:"C",cx1:3.6059,cy1:4.2818,cx2:3.9471,cy2:3.9406,x:4.3335,y:3.6702},{op:"C",cx1:4.7262,cy1:3.3933,cx2:5.1192,cy2:3.258,x:5.5119,y:3.258},{op:"C",cx1:6.1623,cy1:3.258,cx2:6.613,cy2:3.5671,x:6.8575,y:4.179},{op:"C",cx1:7.1987,cy1:3.8891,cx2:7.6044,cy2:3.6444,x:8.0617,y:3.4447},{op:"C",cx1:8.5188,cy1:3.2454,cx2:8.9632,cy2:3.1486,x:9.388,y:3.1486},{op:"C",cx1:10.1286,cy1:3.1486,cx2:10.7017,cy2:3.4447,x:11.1008,y:4.0437},{op:"C",cx1:11.5064,cy1:4.636,cx2:11.706,cy2:5.3249,x:11.706,y:6.104},{op:"C",cx1:11.706,cy1:6.8187,cx2:11.5322,cy2:7.5464,x:11.178,y:8.274},{op:"C",cx1:10.8304,cy1:9.0017,cx2:10.3538,cy2:9.6004,x:9.7422,y:10.0704},{op:"C",cx1:9.1306,cy1:10.5406,cx2:8.4607,cy2:10.7724,x:7.7267,y:10.7724},{op:"C",cx1:7.0442,cy1:10.7724,cx2:6.4133,cy2:10.5148,x:5.8273,y:10.006},{op:"L",x:4.7972,y:12.9614},{op:"C",cx1:4.765,cy1:13.0453,cx2:4.7133,cy2:13.1998,x:4.6426,y:13.4122},{op:"C",cx1:4.6684,cy1:13.6377,cx2:4.7842,cy2:13.7922,x:4.9902,y:13.8695},{op:"C",cx1:5.2028,cy1:13.9531,cx2:5.5504,cy2:13.9919,x:6.0399,y:13.9919},{op:"L",x:6.0399,y:14.8095},{op:"L",x:0,y:14.8095},{op:"L",x:0,y:13.9919},{op:"C",cx1:.7469,cy1:13.9919,cx2:1.2815,cy2:13.8759,x:1.5969,y:13.6506},{op:"C",cx1:1.9124,cy1:13.4251,cx2:2.1379,cy2:13.1289,x:2.2666,y:12.7491},{op:"L",x:3.767,y:8.5573},{op:"Z"},{op:"M",x:7.0637,y:6.3166},{op:"C",cx1:6.7802,cy1:6.9604,cx2:6.6064,cy2:7.8104,x:6.5357,y:8.8727},{op:"C",cx1:6.6064,cy1:9.5619,cx2:6.7609,cy2:9.9031,x:7.012,y:9.9031},{op:"C",cx1:7.8879,cy1:9.7356,cx2:8.609,cy2:8.7248,x:9.1755,y:6.8704},{op:"C",cx1:9.3495,cy1:6.2071,cx2:9.4395,cy2:5.6084,x:9.4395,y:5.0738},{op:"C",cx1:9.4395,cy1:4.4108,cx2:9.2657,cy2:4.05,x:8.9115,y:3.9923},{op:"C",cx1:8.332,cy1:3.9923,cx2:7.7139,cy2:4.7647,x:7.0637,y:6.3166},{op:"Z"}]},Ki={mf:8.0028,mp:9.523,ff:6.67866,pp:8.8083},Ui={fill:"#000"},Xi=.79341;function rt(r,t,e){let n=0,o=Array.from(r,(s,i)=>{let c={path:Yi[s],style:Ui,dx:n};return n+=Ki[s+r[i+1]]??0,c});return{name:r,description:e,shapes:o,weight:r.includes("f")?1:Xi,onTimeState:s=>{s.velocity=t}}}var ds=[rt("ppp",16,"\u6781\u5F31"),rt("pp",32,"\u5F88\u5F31"),rt("p",48,"\u5F31"),rt("mp",64,"\u4E2D\u5F31"),rt("mf",80,"\u4E2D\u5F3A"),rt("f",96,"\u5F3A"),rt("ff",112,"\u5F88\u5F3A"),rt("fff",127,"\u6781\u5F3A")];var ys={name:"fermata",description:"\u5EF6\u957F\u8BB0\u53F7\uFF1A\u8986\u76D6\u533A\u95F4\u901F\u5EA6\u51CF\u534A\uFF0C\u76EE\u6807\u97F3\u5B9E\u9645\u65F6\u957F\u7FFB\u500D",weight:.6,shapes:[{path:[{op:"M",x:0,y:7.46666},{op:"C",cx1:3.65834,cy1:0,cx2:8.53611,cy2:0,x:12.19445,y:7.46666},{op:"M",x:12.19445,y:7.46666},{op:"C",cx1:8.53611,cy1:.74666,cx2:3.65833,cy2:.74666,x:0,y:7.46666}],style:{fill:"#000",stroke:"#000",strokeWidth:1}},{circle:{cx:6.09723,cy:6.26666,r:1.2},style:{fill:"#000"}}],emitPlayback:r=>{r.control(r.start,t=>t.bpmScale.div(2)),r.control(r.end,t=>t.bpmScale.mul(2))}};var gs={name:"fine",description:"\u7EC8\u6B62\u8BB0\u53F7\uFF1A\u56DE\u8DF3\u4E4B\u540E\u7ECF\u8FC7\u8FD9\u91CC\u5C31\u7ED3\u675F\u4E50\u66F2",weight:1.4,text:{content:"Fine.",fontFamily:'"Times New Roman", serif'},onVisit:(r,t)=>{let e=r.seek(Wt,t,1);return e!==void 0&&r.visits(e)>0?{kind:"stop"}:void 0}};function Nt(r){return(t,e)=>{let n=new Map;for(let i of e)i.kind==="note-off"&&n.set(i.noteId,i);let o=new Set,s=[];for(let i of e){if(i.kind!=="note-on"||!i.transpose)continue;let c=n.get(i.noteId);if(!c)continue;let a=c.at.clone().sub(i.at),l=t.stateAt(i.at).effectiveBpm,h=r.repeat?Zi(r.body,a.toNumber(),l):r.body,p=a.div(h.length);o.add(i),o.add(c);for(let f=0;f<h.length;f++){let d=h[f],x=t.nextNoteId(),g=i.at.clone().add(p.clone().mul(f)),y=i.order+f/h.length,u={...i,at:g,noteId:x,order:y,midi:d===0?i.midi:i.transpose(d),transpose:m=>i.transpose(d+m),origins:[...i.origins],sourceSpans:i.sourceSpans.map(m=>({...m}))};s.push(u,{...c,at:g.clone().add(p),noteId:x,order:y,origins:[...c.origins]})}}return[...e.filter(i=>!o.has(i)),...s]}}function Zi(r,t,e){let n=Math.min(480,Math.max(60,e))/e,o=Math.floor(256/r.length),s=Math.min(o,Math.max(1,Math.round(t*8*n/r.length))),i=[];for(let c=0;c<s;c++)i.push(...r);return i}var bs={name:"mordent",description:"\u4E0B\u6CE2\u97F3\uFF1A\u672C\u97F3\u3001\u8C03\u5185\u4E0B\u65B9\u4E8C\u5EA6\u3001\u672C\u97F3",weight:.73423,shapes:[{path:[{op:"M",x:7.29541,y:.05944},{op:"C",cx1:7.56541,cy1:-.09056,cx2:7.92541,cy2:.05944,x:8.04541,y:.32944},{op:"C",cx1:8.10541,cy1:.44944,cx2:8.10541,cy2:.56944,x:8.10541,y:1.76943},{op:"L",x:8.10541,y:3.05943},{op:"L",x:8.67541,y:2.21943},{op:"C",cx1:9.18541,cy1:1.46943,cx2:9.24541,cy2:1.37943,x:9.36541,y:1.31943},{op:"C",cx1:9.42541,cy1:1.28943,cx2:9.54541,cy2:1.25943,x:9.60541,y:1.25943},{op:"C",cx1:9.90541,cy1:1.25943,cx2:9.87541,cy2:1.22943,x:11.49541,y:3.20943},{op:"L",x:13.02541,y:5.03943},{op:"L",x:13.50541,y:4.34943},{op:"C",cx1:14.01541,cy1:3.56943,cx2:14.04541,cy2:3.50943,x:14.19541,y:3.44943},{op:"C",cx1:14.61541,cy1:3.26943,cx2:15.06541,cy2:3.59943,x:15.00541,y:4.04943},{op:"C",cx1:14.97541,cy1:4.16943,cx2:14.70541,cy2:4.55943,x:13.50541,y:6.41943},{op:"C",cx1:12.12541,cy1:8.48943,cx2:12.00541,cy2:8.63943,x:11.88541,y:8.69943},{op:"C",cx1:11.82541,cy1:8.72943,cx2:11.70541,cy2:8.75943,x:11.64541,y:8.75943},{op:"C",cx1:11.34541,cy1:8.75943,cx2:11.37541,cy2:8.78943,x:9.81541,y:6.86943},{op:"C",cx1:9.00541,cy1:5.87943,cx2:8.31541,cy2:5.06943,x:8.28541,y:5.00943},{op:"C",cx1:8.22541,cy1:4.97943,cx2:8.22541,cy2:4.97943,x:8.16541,y:5.03943},{op:"C",cx1:8.10541,cy1:5.09943,cx2:8.10541,cy2:5.18943,x:8.10541,y:7.31943},{op:"C",cx1:8.10541,cy1:9.26943,cx2:8.10541,cy2:9.56943,x:8.04541,y:9.65943},{op:"C",cx1:7.86541,cy1:10.10943,cx2:7.23541,cy2:10.13943,x:6.99541,y:9.68943},{op:"C",cx1:6.96541,cy1:9.62943,cx2:6.93541,cy2:9.44943,x:6.93541,y:8.27943},{op:"L",x:6.93541,y:6.92943},{op:"L",x:6.36541,y:7.76943},{op:"C",cx1:5.82541,cy1:8.54943,cx2:5.76541,cy2:8.63943,x:5.64541,y:8.69943},{op:"C",cx1:5.58541,cy1:8.72943,cx2:5.46541,cy2:8.75943,x:5.40541,y:8.75943},{op:"C",cx1:5.10541,cy1:8.75943,cx2:5.13541,cy2:8.78943,x:3.51541,y:6.80943},{op:"L",x:1.98541,y:4.97943},{op:"L",x:1.50541,y:5.66943},{op:"C",cx1:.99541,cy1:6.44943,cx2:.96541,cy2:6.50943,x:.81541,y:6.56943},{op:"C",cx1:.39541,cy1:6.74943,cx2:-.05459,cy2:6.41943,x:.00541,y:5.96943},{op:"C",cx1:.03541,cy1:5.84943,cx2:.30541,cy2:5.45943,x:1.50541,y:3.59943},{op:"C",cx1:2.88541,cy1:1.52943,cx2:3.00541,cy2:1.37943,x:3.12541,y:1.31943},{op:"C",cx1:3.18541,cy1:1.28943,cx2:3.30541,cy2:1.25943,x:3.36541,y:1.25943},{op:"C",cx1:3.66541,cy1:1.25943,cx2:3.63541,cy2:1.22943,x:5.25541,y:3.20943},{op:"L",x:6.78541,y:5.03943},{op:"C",cx1:6.81541,cy1:5.03943,cx2:6.84541,cy2:4.97943,x:6.87541,y:4.94943},{op:"C",cx1:6.93541,cy1:4.82943,cx2:6.93541,cy2:4.79943,x:6.93541,y:2.66943},{op:"C",cx1:6.93541,cy1:.74943,cx2:6.93541,cy2:.44943,x:6.99541,y:.35943},{op:"C",cx1:7.05541,cy1:.20943,cx2:7.14541,cy2:.11943,x:7.29541,y:.05943},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:r=>r.affectFollowing(Nt({body:[0,-1,0]}))};var ws={name:"prall",description:"\u4E0A\u6CE2\u97F3\uFF1A\u672C\u97F3\u3001\u8C03\u5185\u4E0A\u65B9\u4E8C\u5EA6\u3001\u672C\u97F3",weight:.55,shapes:[{path:[{op:"M",x:3.12541,y:.06003},{op:"C",cx1:3.18541,cy1:.03003,cx2:3.30541,cy2:3e-5,x:3.36541,y:3e-5},{op:"C",cx1:3.66541,cy1:3e-5,cx2:3.63541,cy2:-.02997,x:5.25541,y:1.95003},{op:"L",x:6.78541,y:3.78003},{op:"C",cx1:6.81541,cy1:3.78003,cx2:7.35541,cy2:2.94003,x:8.01541,y:1.95003},{op:"C",cx1:9.15541,cy1:.27003,cx2:9.24541,cy2:.12003,x:9.36541,y:.06003},{op:"C",cx1:9.42541,cy1:.03003,cx2:9.54541,cy2:3e-5,x:9.60541,y:3e-5},{op:"C",cx1:9.90541,cy1:3e-5,cx2:9.87541,cy2:-.02997,x:11.49541,y:1.95003},{op:"L",x:13.02541,y:3.78003},{op:"L",x:13.50541,y:3.09003},{op:"C",cx1:14.01541,cy1:2.31003,cx2:14.04541,cy2:2.25003,x:14.19541,y:2.19003},{op:"C",cx1:14.61541,cy1:2.01003,cx2:15.06541,cy2:2.34003,x:15.00541,y:2.79003},{op:"C",cx1:14.97541,cy1:2.91003,cx2:14.70541,cy2:3.30003,x:13.50541,y:5.16003},{op:"C",cx1:12.12541,cy1:7.23003,cx2:12.00541,cy2:7.38003,x:11.88541,y:7.44003},{op:"C",cx1:11.82541,cy1:7.47003,cx2:11.70541,cy2:7.50003,x:11.64541,y:7.50003},{op:"C",cx1:11.34541,cy1:7.50003,cx2:11.37541,cy2:7.53003,x:9.75541,y:5.55003},{op:"L",x:8.22541,y:3.72003},{op:"C",cx1:8.19541,cy1:3.72003,cx2:7.65541,cy2:4.56003,x:6.99541,y:5.55003},{op:"C",cx1:5.85541,cy1:7.23003,cx2:5.76541,cy2:7.38003,x:5.64541,y:7.44003},{op:"C",cx1:5.58541,cy1:7.47003,cx2:5.46541,cy2:7.50003,x:5.40541,y:7.50003},{op:"C",cx1:5.10541,cy1:7.50003,cx2:5.13541,cy2:7.53003,x:3.51541,y:5.55003},{op:"L",x:1.98541,y:3.72003},{op:"L",x:1.50541,y:4.41003},{op:"C",cx1:.99541,cy1:5.19003,cx2:.96541,cy2:5.25003,x:.81541,y:5.31003},{op:"C",cx1:.39541,cy1:5.49003,cx2:-.05459,cy2:5.16003,x:.00541,y:4.71004},{op:"C",cx1:.03541,cy1:4.59004,cx2:.30541,cy2:4.20004,x:1.50541,y:2.34004},{op:"C",cx1:2.88541,cy1:.27004,cx2:3.00541,cy2:.12004,x:3.12541,y:.06004},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:r=>r.affectFollowing(Nt({body:[0,1,0]}))};var Cs={name:"tr",description:"\u98A4\u97F3\uFF1A\u672C\u97F3\u4E0E\u8C03\u5185\u4E0A\u65B9\u4E8C\u5EA6\u4EA4\u66FF",shapes:[{path:[{op:"M",x:3.17992,y:5.46383},{op:"L",x:3.61827,y:3.91711},{op:"C",cx1:3.10024,cy1:3.49862,cx2:2.52947,cy2:3.29304,x:1.90541,y:3.29304},{op:"C",cx1:1.50051,cy1:3.29304,cx2:1.18833,cy2:3.40589,x:.95611,y:3.63812},{op:"C",cx1:.72361,cy1:3.87061,cx2:.59743,cy2:4.14281,x:.57105,y:4.46152},{op:"C",cx1:.57105,cy1:4.91944,cx2:.71707,cy2:5.25147,x:1.00913,y:5.47036},{op:"C",cx1:1.30118,cy1:5.68954,cx2:1.61988,cy2:5.79586,x:1.95843,y:5.79586},{op:"C",cx1:1.9916,cy1:5.79586,cx2:2.03157,cy2:5.8157,x:2.06475,y:5.84888},{op:"C",cx1:2.24394,cy1:5.82904,cx2:2.61568,cy2:5.69632,x:3.17992,y:5.46383},{op:"Z"},{op:"M",x:6.579,y:9.87204},{op:"L",x:8.40472,y:3.75096},{op:"C",cx1:8.40472,cy1:3.59162,cx2:8.35167,cy2:3.51193,x:8.23884,y:3.51193},{op:"C",cx1:7.98647,cy1:3.51193,cx2:7.4554,cy2:3.77761,x:6.63883,y:4.3152},{op:"C",cx1:5.82223,cy1:4.84655,cx2:5.37735,cy2:5.15845,x:5.30448,y:5.25145},{op:"C",cx1:5.33764,cy1:5.21147,cx2:5.39068,cy2:5.15845,x:5.46383,y:5.0853},{op:"C",cx1:6.13441,cy1:6.06127,cx2:6.47294,cy2:6.98417,x:6.47294,y:7.86061},{op:"C",cx1:6.41313,cy1:8.53088,cx2:6.18062,cy2:9.12181,x:5.7692,y:9.61968},{op:"C",cx1:5.3643,cy1:10.11758,cx2:4.85308,cy2:10.3634,x:4.24233,y:10.3634},{op:"C",cx1:3.71778,cy1:10.3634,cx2:3.25306,cy2:10.23719,x:2.83483,y:9.99138},{op:"C",cx1:2.42314,cy1:9.74586,cx2:2.20396,cy2:9.39396,x:2.17759,y:8.92271},{op:"C",cx1:2.21077,cy1:8.80986,cx2:2.23061,cy2:8.66384,x:2.23061,y:8.48436},{op:"L",x:2.85469,y:6.0944},{op:"C",cx1:2.58903,cy1:6.2339,cx2:2.21729,cy2:6.30702,x:1.73924,y:6.30702},{op:"C",cx1:1.22829,cy1:6.2804,cx2:.81007,cy2:6.1012,x:.48458,y:5.76917},{op:"C",cx1:.15935,cy1:5.43065,cx2:0,cy2:4.97926,x:0,y:4.4082},{op:"C",cx1:.03318,cy1:3.89045,cx2:.20586,cy2:3.46543,x:.53107,y:3.13369},{op:"C",cx1:.8563,cy1:2.80166,cx2:1.32782,cy2:2.63579,x:1.95843,y:2.63579},{op:"C",cx1:2.55585,cy1:2.63579,cx2:3.17992,cy2:2.87481,x:3.83716,y:3.34606},{op:"L",x:4.89277,y:0},{op:"L",x:6.85119,y:0},{op:"L",x:5.41053,y:4.51453},{op:"C",cx1:6.28694,cy1:3.83064,cx2:7.02389,cy2:3.34606,x:7.62128,y:3.06054},{op:"C",cx1:8.21899,cy1:2.77502,cx2:8.86943,cy2:2.63579,x:9.57321,y:2.63579},{op:"C",cx1:10.05773,cy1:2.63579,cx2:10.30358,cy2:2.83484,x:10.30358,y:3.23974},{op:"C",cx1:10.30358,cy1:3.44559,cx2:10.17738,cy2:3.89046,x:10.09093,y:4.18931},{op:"C",cx1:10.7283,cy1:3.15354,cx2:11.45195,cy2:2.63579,x:12.26199,y:2.63579},{op:"C",cx1:12.6272,cy1:2.63579,cx2:12.91925,cy2:2.76849,x:13.14497,y:3.03417},{op:"C",cx1:13.37717,cy1:3.29957,cx2:13.49001,cy2:3.61175,x:13.49001,y:3.97014},{op:"C",cx1:13.49001,cy1:4.62739,cx2:13.09844,cy2:5.03228,x:12.53419,y:5.03228},{op:"C",cx1:12.16899,cy1:5.03228,cx2:11.85709,cy2:4.79327,x:11.80382,y:4.29536},{op:"C",cx1:11.89029,cy1:3.91031,cx2:11.98982,cy2:3.55191,x:11.98982,y:3.34606},{op:"C",cx1:11.98982,cy1:3.27291,cx2:11.94329,cy2:3.23973,x:11.85709,y:3.23973},{op:"C",cx1:11.74403,cy1:3.23973,cx2:11.53162,cy2:3.34606,x:11.20637,y:3.56522},{op:"C",cx1:10.90752,cy1:3.7708,cx2:10.61547,cy2:4.11615,x:10.31666,y:4.61405},{op:"C",cx1:10.01808,cy1:5.11195,cx2:9.77253,cy2:5.69632,x:9.57321,y:6.36662},{op:"L",x:8.45798,y:9.87203},{op:"L",x:6.57899,y:9.87203},{op:"L",x:6.579,y:9.87204},{op:"Z"},{op:"M",x:5.05893,y:5.62971},{op:"L",x:3.94348,y:8.92274},{op:"C",cx1:3.94348,cy1:9.0288,cx2:3.92364,cy2:9.12179,x:3.89045,y:9.19495},{op:"C",cx1:3.89045,cy1:9.48047,cx2:4.06285,cy2:9.65287,x:4.40821,y:9.70617},{op:"C",cx1:5.404,cy1:9.22134,cx2:5.9019,cy2:8.51787,x:5.9019,y:7.58841},{op:"C",cx1:5.9019,cy1:6.99751,cx2:5.62318,cy2:6.34681,x:5.05893,y:5.62972},{op:"L",x:5.05893,y:5.62971},{op:"Z"}],style:{fill:"#000"}}],emitPlayback:r=>r.affectFollowing(Nt({body:[0,1],repeat:!0}))};var Ss=new Map([Cs,ys,ws,bs,fs,...ds,us,ms,xs,gs].map(r=>[r.name.toLowerCase(),r])),Mn=class extends T{static def={name:["symbol","$"],description:"\u521B\u5EFA\u4E00\u4E2A\u4E50\u8C31\u7B26\u53F7",example:["@symbol(name, size)","\u8BED\u6CD5\u7CD6: $name","\u5185\u7F6E:",...[...Ss.values()].map(t=>` $${t.name} ${t.description}`)].join(`
105
+ `),allowExtraArgs:!1,args:[{name:"name",type:"string",default:null},{name:"size",type:"length",default:{value:.5,unit:"em"}}]};static deSugarAtom(t,e,n){if(t[e]!=="$"||!/[A-Za-z]/.test(t[e+1]??""))return null;let o=e+2;for(;o<n&&/[A-Za-z0-9_-]/.test(t[o]);)o++;let s=t.slice(e+1,o);return{next:o,node:{kind:"call",typed:!0,name:"symbol",args:new Map([[0,s]]),span:{start:e,end:o},syntaxKind:"atom"}}}size;definition;constructor(t,e,n,o=null){super(t,o);let[s,i]=this.getArgValue(e,n);this.size=n.length2px(i);let c=Ss.get(s.toLowerCase());if(!c){let a=`@symbol: \u672A\u77E5\u7B26\u53F7: $${s}`;if(n.variables.strict)throw new C("E_UNKNOWN_SYMBOL",a,t);n.diagnostics.push(new k("W_UNKNOWN_SYMBOL",a,t));return}this.definition=c}loweringEnter(){return[this.definition?new Rn(this):new P]}toString(t){return this.definition?`@symbol(${this.definition.name})`:super.toString(t)}},As=Mn,Rn=class extends P{bounds;height;label;scale=1;baseline=0;constructor(t){super(),this.ast=t,this.mergeKey=J,this.onTimeState=t.definition.onTimeState,this.emitPlayback=t.definition.emitPlayback,this.playbackMarks=t.definition.playbackMarks,this.bounds=hs(t.definition.shapes??[]),this.height=t.size*(t.definition.weight??1);let e=t.definition.text;this.label=e&&{content:e.content,style:{fontSize:this.height,fontFamily:e.fontFamily}},this.initLayoutBox()}prepareLayout(t){if(this.label){let e=t.textMeasurer.measureText(this.label.content,this.label.style);this.box.w=e.w,this.box.h=e.h,this.baseline=e.baseline}else this.scale=this.height/this.bounds.h,this.box.w=this.bounds.w*this.scale,this.box.h=this.height;this.box.anchor=this.box.w/2,this.box.visualAxis=this.box.h/2}paint(t){this.label?t.drawText(this.label.content,this.box.x,this.box.y+this.baseline,this.label.style):ps(t,this.ast.definition.shapes??[],this.bounds,this.box,this.scale)}playbackFlow(t){let e=this.ast.definition.onVisit;if(!e)return;let n=t(this);return n===void 0?void 0:{range:[n,n],run:o=>e(o,n)}}};var In=class r extends T{static def={name:["set"],description:"\u8BBE\u7F6E\u5C40\u90E8\u9ED8\u8BA4\u503C",example:`\u5F53\u524D\u6709\u4EE5\u4E0B\u7CFB\u7EDF\u914D\u7F6E\uFF1A
106
+ @set(fontSize=20) \u5219\u5F53\u524D\u5757\u5185\u9ED8\u8BA4\u5B57\u4F53\u53D8\u4E3A20px
107
+ @set(strict=true) \u5F00\u542F\u4E25\u683C\u6A21\u5F0F
108
+ \u8FD8\u53EF\u4EE5\u8BBE\u7F6E\u5176\u4ED6\u51FD\u6570\u7684\u9ED8\u8BA4\u503C: {\u51FD\u6570\u540D}.{\u5C5E\u6027}=\u503C\uFF0C\u4F8B:
109
+ @set(note.octave=5, note.color=#f00)
110
+
111
+ \u6CE8\u610F\uFF1A@set \u4F5C\u7528\u57DF\u4EC5\u5728\u5176\u6240\u5904 '{}' \u5185\u3001\u5176\u51FA\u73B0\u4E4B\u540E\u3002\u79BB\u5F00\u5F53\u524D\u4F5C\u7528\u57DF\u4F1A\u6062\u590D\u4E3A\u4E4B\u524D\u7684\u8BBE\u7F6E\u3002\u6B64\u8BBE\u7F6E\u548C\u65F6\u5E8F\u65E0\u5173\uFF0C\u7C7B\u4F3C\u4E8E\u5C40\u90E8\u53D8\u91CF\u3002
112
+ `,allowExtraArgs:!0,args:[]};static resolveTarget(t,e,n){let o=e.lastIndexOf(".");if(o<0)return[e,Object.hasOwn(j.systemVariables,e)?j.systemVariables[e].type:"string"];let s=e.slice(o+1),i=t.functions.get(e.slice(0,o))?.prototype.def,c=i&&gt(i,s,-1);return!i||!c?(t.diagnostics.push(new k("W_SET_UNKNOWN_TARGET",`@set \u7684\u53C2\u6570 [${e}] \u6CA1\u6709\u5BF9\u5E94\u7684\u51FD\u6570\u6216\u5176\u53C2\u6570\uFF0C\u5C06\u88AB\u5FFD\u7565`,n)),null):c==="content"||c==="label"?(t.diagnostics.push(new k("W_SET_INVALID_VALUE_TYPE",`@set \u7684\u53C2\u6570 [${e}] \u5185\u5BB9\u548C\u6807\u7B7E\u4E0D\u80FD\u4F5C\u4E3A\u9ED8\u8BA4\u503C\uFF0C\u5C06\u88AB\u5FFD\u7565`,n)),null):[`${Rt(i)}.${s}`.toLowerCase(),c]}args=new Map;constructor(t,e,n,o=null){super(t,o);for(let[s,i]of e){let c=i;if(typeof s!="string"){n.diagnostics.push(new k("W_SET_POSITIONAL_ARG",`\u51FD\u6570 @set \u4E0D\u63A5\u6536\u4F4D\u7F6E\u53C2\u6570, \u4F4D\u7F6E\u53C2\u6570[${s}]\u5C06\u88AB\u5FFD\u7565`,c.span));continue}let a=r.resolveTarget(n,s.toLowerCase(),c.nameSpan??c.span);if(a===null)continue;let[l,h]=a,p=n.parseArgWithType(c.valueSpan,h,t.start);if(p===null){n.diagnostics.push(new k("W_SET_INVALID_VALUE",`\u51FD\u6570 @set \u7684\u53C2\u6570\u503C\u89E3\u6790\u5931\u8D25, \u53C2\u6570[${s}]\u5C06\u88AB\u5FFD\u7565`,c.valueSpan));continue}n.setVariable(l,p),this.args.set(l,p)}}toString(){return`@set(${Array.from(this.args,([t,e])=>`${t}=${typeof e=="string"?tt(e):e}`).join(", ")})`}},Ls=In;var On=class extends T{static def={name:["volta"],description:"\u53CD\u590D\u623F\u5B50",example:`@volta(from, to, pass, ...) \u53EA\u5728\u6307\u5B9A\u904D\u6570\u6F14\u594F\u7684\u4E00\u6BB5\u533A\u95F4
113
+ from \u548C to \u662F\u533A\u95F4\u9996\u672B\u97F3\u7B26\u7684\u6807\u7B7E\uFF0C\u56E0\u6B64\u623F\u5B50\u53EF\u4EE5\u6A2A\u8DE8\u8C31\u9762\u884C
114
+ pass \u662F\u904D\u6570\uFF1A\u6574\u6BB5\u8C31\u9762\u6F14\u594F\u5230\u7B2C\u51E0\u904D\u65F6\u624D\u64AD\u8FD9\u91CC\uFF0C\u5FC5\u586B\u6B63\u6574\u6570
115
+ \u518D\u5199\u51E0\u4E2A\u904D\u6570\u5C31\u662F\u51E0\u904D\u5171\u7528\u4E00\u4E2A\u623F\u5B50\uFF0C\u987A\u5E8F\u968F\u610F\uFF0C\u6807\u7B7E\u6309\u5347\u5E8F\u5199\u6210 1.2.
116
+
117
+ |: 1 2 | 3@a 4@b :| 5@c 6@d | 7
118
+ @volta(a, b, 1) @volta(c, d, 2)`,allowExtraArgs:!0,extraArgType:"number",args:[{name:"from",type:"label",default:null},{name:"to",type:"label",default:null},{name:"pass",type:"number",default:null}]};from;to;passes;size;font;loweringEnter(t){let e=t.getTemporalNodes(this.from).at(0),n=t.getTemporalNodes(this.to).at(-1);for(;e?.foldedInto;)e=e.foldedInto;for(;n?.foldedInto;)n=n.foldedInto;return!e||!n?(t.diagnostics.push(E.warning.UnresolvedEndpoint("volta",this.sourceSpan)),[]):(t.addAttachment(new Dn(this,e,n)),[])}constructor(t,e,n,o=null){super(t,o);let[s,i,c]=this.getArgValue(e,n);this.font=n.variables.numberfont;let a=new Set([c]);for(let l=3;e.has(l);l++)a.add(e.get(l));if(this.from=s,this.to=i,this.passes=[...a].sort((l,h)=>l-h),this.size=n.variables.fontsize,this.passes.some(l=>!Number.isSafeInteger(l)||l<=0))throw new C("E_VOLTA_INVALID_PASS","@volta \u7684\u904D\u6570\u5FC5\u987B\u662F\u6B63\u6574\u6570",t)}toString(t){let e=n=>n.label??n.toString(t);return`@volta(${e(this.from)}, ${e(this.to)}, ${this.passes.join(", ")})`}},Es=On;function Ts(r){if(r?.[0]?.mergeKey===G)return r[0]}var Dn=class{ast;from;to;layer="foreground";constructor(t,e,n){this.ast=t,this.from=e,this.to=n}get sourceSpan(){return this.ast.sourceSpan}playbackFlow(t){let e=t(this.from),n=t(this.to);if(e===void 0||n===void 0)return;let o=Math.min(e,n),s=Math.max(e,n);return{range:[o,s],run:i=>this.ast.passes.includes(mo(i,o))?void 0:{kind:"jump",column:s+1}}}createGeometry(t){if(!D(this.from)||!D(this.to))return{regions:[],paint(){}};let e=v=>{let O=t.lines[v.layoutLine];return{line:v.layoutLine,view:O,column:O.columnOf(v)}},[n,o]=[e(this.from),e(this.to)];if((n.line>o.line||n.line===o.line&&n.column>o.column)&&([n,o]=[o,n]),n.column<0||o.column<0)return{regions:[],paint(){}};let s=n.view.columns[n.column][0],i=o.view.columns[o.column][0],c=Ts(n.view.columns[n.column-1]),a=Ts(o.view.columns[o.column+1]),l=0,h=[];for(let v=n.line;v<=o.line;v++){let O=t.lines[v],S=v===n.line?n.column:0,_=v===o.line?o.column:O.columns.length-1;for(let L=S;L<=_;L++)l=Math.max(l,O.columns[L][0].ast.size);h.push({from:S,to:_,wholeLine:v!==n.line&&v!==o.line})}let p=s.layoutLine,f=i.layoutLine,d=l||this.ast.size,x={fontSize:d*.6,fontFamily:this.ast.font,textAlign:"left",fill:"#000"},g=this.ast.passes.map(v=>`${v}.`).join(""),y=t.textMeasurer.measureText(g,x),u=Math.max(1,d*.055),m=u/2,b=y.h*1.2,w=(b-y.h)/2+y.baseline,R=Array.from({length:f-p+1},(v,O)=>{let S=p+O,_=s.track,L=1/0,A=h[O],N=A.wholeLine?t.getRangeExtents(S):t.getRangeExtents(S,[A.from,A.to]);for(let[B,K]of N){let ct=t.getVisualAxis(S,B)+K.top;ct<L&&(_=B,L=ct)}L===1/0&&(L=t.getVisualAxis(S,_));let I=S!==p?this.lineEntryX(t,S,_):c?.layoutLine===S?c.box.x+c.box.anchor+5:s.box.x+(s.ports["body.left"]?.x??0),$=S!==f?this.lineRightX(t,S):a?.layoutLine===S?a.box.x+a.box.anchor:i.box.x+(i.ports["body.right"]?.x??i.box.w),W=Math.min(I,$),U=Math.max(I,$);return{left:W,right:U,lineY:L-d*.2-b,line:S,track:_}});return{regions:R.map(({left:v,right:O,lineY:S,line:_,track:L})=>({x:v-m,y:S-m,w:O-v+u,h:b+u,line:_,track:L})),paint(v){let O={stroke:"#000",strokeWidth:u};for(let{left:S,right:_,lineY:L,line:A}of R)v.drawLine(S,L,_,L,O),A===p&&(v.drawLine(S,L,S,L+b,O),v.drawText(g,S+d*.15,L+w+2,x)),A===f&&v.drawLine(_,L,_,L+b,O)}}}lineEntryX(t,e,n){return t.lines[e].trackRuns.get(n)?.find(s=>!s.T.isZero())?.box.x??t.originX}lineRightX(t,e){let n=t.lines[e].trackRuns;if(n.size===0)return t.originX+t.width;let o=t.originX;for(let s of n.values())for(let i of s)o=Math.max(o,i.box.x+i.box.w);return o}};var _s=4/3,ji=.09,Pn=class extends T{static def={name:["tie"],description:"\u8FDE\u97F3\u7EBF",example:`@tie(label1, label2, ..., height=0.5em)
119
+ \u5C06\u7AEF\u70B9\u4F9D\u6B21\u8FDE\u63A5\uFF1B\u540C\u884C\u7528\u4E00\u6761\u5F27\u7EBF\uFF0C\u8DE8\u884C\u62C6\u6210\u5206\u6BB5\u8FDE\u63A5\uFF1B\u82E5\u4E0D\u4F20\u7AEF\u70B9\u5219\u627E\u6700\u8FD1\u7684`,allowExtraArgs:!0,extraArgType:"label",args:[]};endPoints=[];height;constructor(t,e,n,o=null){super(t,o);let s=n.variables.fontsize*.5;for(let[c,a]of e){if(c==="height"){let h=n.parseArgWithType(a.valueSpan,"length",t.start);h&&(s=Math.max(0,n.length2px(h)));continue}let l=a instanceof T?a:n.parseArgWithType(a.valueSpan,"label",t.start);l!==null&&this.endPoints.push(l)}let i=n.labelableNodes.length-1;for(;this.endPoints.length<2&&i>=0;){let c=n.labelableNodes[i--];!c||this.endPoints.includes(c)||this.endPoints.unshift(c)}if(this.endPoints.length<2)throw new C("E_NOT_ENOUGH_ARGS","@tie \u8FDE\u97F3\u7EBF\u9700\u8981\u81F3\u5C11\u4E24\u4E2A\u7AEF\u70B9",t);this.height=s}loweringEnter(t){let e=[];for(let n of this.endPoints){let o=t.getTemporalNodes(n).at(-1);!o||!D(o)||e.push(o)}return e.length<2?(t.diagnostics.push(E.warning.UnresolvedEndpoint("tie",this.sourceSpan)),[]):(t.addAttachment(new Fn(e,this.height,this.sourceSpan)),[])}toString(t){return`@tie(${this.endPoints.map(e=>`${e.label??"anon"}:[${e.toString(t)}]`).join(", ")})`}},vs=Pn,Fn=class{layer="foreground";sourceSpan;endPoints;height;thickness;constructor(t,e,n){this.endPoints=t,this.height=e,this.sourceSpan=n;let o=t.reduce((s,i)=>Math.max(s,i.ast.size),0);this.thickness=Math.max(1.2,o*ji)}applyPlayback(t){let e=()=>t.events.filter(o=>o.kind==="note-on"),n=o=>t.events.find(s=>s.kind==="note-off"&&s.noteId===o);for(let o of e().filter(s=>s.origins.some(i=>i.node===this.endPoints[0])))for(let s=1;s<this.endPoints.length;s++){let i=n(o.noteId);if(!i)break;let c=e().find(l=>l.noteId!==o.noteId&&l.origins.some(h=>h.node===this.endPoints[s])&&l.track===o.track&&l.midi===o.midi&&l.percussion===o.percussion&&i.at.equals(l.at));if(!c)break;let a=n(c.noteId);if(!a)break;o.sourceSpans.push(...c.sourceSpans);for(let l of c.origins)o.origins.includes(l)||o.origins.push(l);a.noteId=o.noteId,a.origins=[...o.origins],t.events.splice(0,t.events.length,...t.events.filter(l=>l!==i&&l!==c))}}createGeometry(t){let e=this.createSegments(t),n=e.map(({commands:s,...i})=>i),o=e.map(s=>{let i=t.getHostExtent(s.line,s.track),c=i?Math.max(s.y,t.getVisualAxis(s.line,s.track)+i.top):s.y+s.h;return{x:s.x,y:s.y,w:s.w,h:c-s.y,line:s.line,track:s.track}});return{regions:n,occupancy:o,paint(s){for(let i of e)s.drawPath(i.commands,{fill:"#000"})}}}tiePort(t){let e=t.ports["tie.top"];return e?{x:t.box.x+e.x,y:t.box.y+e.y}:{x:t.box.x+t.box.anchor,y:t.box.y}}createSegments(t){let e=[];for(let n=1;n<this.endPoints.length;n++){let o=this.endPoints[n-1],s=this.endPoints[n];o.layoutLine>s.layoutLine&&([o,s]=[s,o]);let i=this.tiePort(o),c=this.tiePort(s);if(o.layoutLine===s.layoutLine){let a=t.getVisualAxis(o.layoutLine,o.track)+(t.getHostExtent(o.layoutLine,o.track)?.top??0),l=t.getVisualAxis(s.layoutLine,s.track)+(t.getHostExtent(s.layoutLine,s.track)?.top??0);e.push(this.arcSegment(i,c,o.layoutLine,a<=l?o.track:s.track));continue}e.push(this.openingSegment(i,this.lineRightX(t,o.layoutLine),this.plateauY(t,o.layoutLine,o.track,i.y),o.layoutLine,o.track));for(let a=o.layoutLine+1;a<s.layoutLine;a++)e.push(this.horizontalSegment(this.lineEntryX(t,a,o.track),this.lineRightX(t,a),this.plateauY(t,a,o.track),a,o.track));e.push(this.closingSegment(this.lineEntryX(t,s.layoutLine,s.track),c,this.plateauY(t,s.layoutLine,s.track,c.y),s.layoutLine,s.track))}return e}lineEntryX(t,e,n){return t.lines[e].trackRuns.get(n)?.find(i=>!i.T.isZero())?.box.x??t.originX}lineRightX(t,e){let n=t.lines[e].trackRuns;if(n.size===0)return t.originX+t.width;let o=t.originX;for(let s of n.values())for(let i of s)o=Math.max(o,i.box.x+i.box.w);return o}plateauY(t,e,n,o=1/0){if(Number.isFinite(o))return o-this.height;let s=t.getVisualAxis(e,n),i=t.getHostExtent(e,n)?.top??0;return s+i-this.height}arcSegment(t,e,n,o){let s=t,i=e;s.x>i.x&&([s,i]=[i,s]);let c=(i.x-s.x)*.25,a=s.x+c,l=i.x-c,h=this.height*_s,p=Math.max(0,h-this.thickness*_s),f=[{op:"M",x:s.x,y:s.y},{op:"C",cx1:a,cy1:s.y-h,cx2:l,cy2:i.y-h,x:i.x,y:i.y},{op:"C",cx1:l,cy1:i.y-p,cx2:a,cy2:s.y-p,x:s.x,y:s.y},{op:"Z"}];return be(f,n,o)}openingSegment(t,e,n,o,s){let i=this.height*1.2;e=Math.max(e,t.x+i);let c=t.x+i,a=t.x+i*.45,l=n+this.thickness;return be([{op:"M",x:t.x,y:t.y},{op:"Q",cx:a,cy:n,x:c,y:n},{op:"L",x:e,y:n},{op:"L",x:e,y:l},{op:"L",x:c,y:l},{op:"Q",cx:a,cy:l,x:t.x,y:t.y},{op:"Z"}],o,s)}closingSegment(t,e,n,o,s){let i=this.height*1.2;t=Math.min(t,e.x-i);let c=e.x-i,a=e.x-i*.45,l=n+this.thickness;return be([{op:"M",x:t,y:n},{op:"L",x:c,y:n},{op:"Q",cx:a,cy:n,x:e.x,y:e.y},{op:"Q",cx:a,cy:l,x:c,y:l},{op:"L",x:t,y:l},{op:"Z"}],o,s)}horizontalSegment(t,e,n,o,s){return be([{op:"M",x:t,y:n},{op:"L",x:e,y:n},{op:"L",x:e,y:n+this.thickness},{op:"L",x:t,y:n+this.thickness},{op:"Z"}],o,s)}};function be(r,t,e){return{commands:r,line:t,track:e,...St(r)}}var $n=class extends T{static def={name:["tuplet"],description:"\u591A\u8FDE\u97F3",example:"@tuplet({1/23}, 4): \u5185\u5BB9\u542B5\u4E2A\u6700\u77ED\u65F6\u503C\u5355\u4F4D\uFF0C\u538B\u7F29\u52304\u500D\u6700\u77ED\u5355\u4F4D\u7684\u603B\u65F6\u957F\uFF0C\u6240\u4EE5\u662F\u516B\u5206\u97F3\u7B26\u7684\u4E94\u8FDE\u97F3\uFF0C\u603B\u65F6\u957F\u4E3A\u4E8C\u5206\u97F3\u7B26",allowExtraArgs:!1,args:[{type:"content",default:null},{name:"normal",type:"number",default:null}]};static loweringFinalize=t=>{for(let e of t.attachments)e instanceof we&&e.validate()};content;normal;font;get children(){return[this.content]}timeFlowModel(){return{mode:"sequence",children:[this.content]}}loweringEnter(t){let e=[],n={events:e,onTemporal(o){e.push(o)}};return t.beginLoweringGroup(this,n),[]}loweringExit(t,e,n){let o=t.endLoweringGroup(this),s=o.events.filter(x=>x.T.compare(0)>0);if(s.length===0)throw new C("E_TUPLET_EMPTY","@tuplet \u7684\u5185\u5BB9\u5FC5\u987B\u4EA7\u751F\u81F3\u5C11\u4E00\u4E2A\u6B63\u65F6\u503C\u4E8B\u4EF6",this.sourceSpan);let i=s[0].track;if(s.some(x=>x.track!==i))throw new C("E_TUPLET_PARALLEL_CONTENT","@tuplet \u7684\u5185\u5BB9\u4E0D\u80FD\u5305\u542B\u5E76\u884C\u97F3\u8F68",this.sourceSpan);let c=s[0].T.clone(),a=new M;for(let x of s)x.T.compare(c)<0&&c.copyFrom(x.T),a.add(x.T);let l=a.clone().div(c),h=l.numerator;if(l.denominator!==1||h<2||!Number.isSafeInteger(h))throw new C("E_TUPLET_NON_INTEGRAL_UNITS","@tuplet \u7684\u603B\u65F6\u503C\u5FC5\u987B\u662F\u6700\u77ED\u6B63\u65F6\u503C\u7684\u6574\u6570\u500D\uFF0C\u4E14\u81F3\u5C11\u5305\u542B2\u4E2A\u5355\u4F4D",this.sourceSpan);if(this.normal===h)throw new C("E_TUPLET_INVALID_RATIO",`@tuplet \u7684 normal \u4E0D\u80FD\u7B49\u4E8E\u63A8\u5BFC\u51FA\u7684 actual (${h})`,this.sourceSpan);let p=o.events[0].t;for(let x=1;x<o.events.length;x++)o.events[x].t.compare(p)<0&&(p=o.events[x].t);p=p.clone();let f=new M;for(let x of o.events)f.copyFrom(x.t).sub(p).mul(this.normal,h),x.t.copyFrom(p).add(f),x.T.mul(this.normal,h);n.copyFrom(p).add(c.mul(this.normal));let d=s.filter(D);return d.length>=2&&t.addAttachment(new we(d,h,this.sourceSpan,this.font)),[]}constructor(t,e,n,o=null){super(t,o);let[s,i]=this.getArgValue(e,n);if(this.font=n.variables.numberfont,!Number.isSafeInteger(i)||i<=0)throw new C("E_TUPLET_INVALID_NORMAL","@tuplet \u7684 normal \u5FC5\u987B\u662F\u6B63\u7684\u5B89\u5168\u6574\u6570",t);this.content=s,this.normal=i,s.parent=this}toString(t){return`@tuplet(${this.content.toString(t)}, ${this.normal})`}},ks=$n,we=class{layer="foreground";endPoints;actual;sourceSpan;style;size;constructor(t,e,n,o){this.endPoints=t,this.actual=e,this.sourceSpan=n,this.size=t.reduce((s,i)=>Math.max(s,i.ast.size),0),this.style={fontSize:this.size*.72,fontFamily:o,textAlign:"center",fill:"#000"}}validate(){let t=this.endPoints[0];if(this.endPoints.some(e=>e.layoutLine!==t.layoutLine))throw new C("E_TUPLET_CROSS_LINE","@tuplet \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8D8A\u8C31\u9762\u884C",this.sourceSpan)}createGeometry(t){let e=this.endPoints[0],n=this.endPoints[this.endPoints.length-1],o=e.ports["body.left"]?.x??0,s=n.ports["body.right"]?.x??n.box.w,i=e.box.x+o,c=n.box.x+s;i>c&&([i,c]=[c,i]);let a=t.textMeasurer.measureText(String(this.actual),this.style),l=(i+c)/2,h=this.size*.12,p=this.size*.18,f=this.size*.14,d=t.lines[e.layoutLine],x=d?.columnOf(e)??-1,g=d?.columnOf(n)??-1,y=t.getVisualAxis(e.layoutLine,e.track),u=x<0||g<0?void 0:t.getRangeExtents(e.layoutLine,[Math.min(x,g),Math.max(x,g)]).get(e.track),m=y+(u?.top??0),b=Math.max(1,this.size*.055),w=m-f-Math.max(p,a.h/2),R=w+p,v=w-a.h/2+a.baseline,O=l-a.w/2-h,S=l+a.w/2+h,_=[];O>i&&_.push([i,w,O,w]),S<c&&_.push([S,w,c,w]),_.push([i,w,i,R],[c,w,c,R]);let L=b/2,A=Math.min(w-a.h/2,w-L),N=Math.max(w+a.h/2,R+L),I=[{x:i-L,y:A,w:c-i+b,h:N-A,line:e.layoutLine,track:e.track}],$=String(this.actual),W=this.style;return{regions:I,paint(U){let B={stroke:"#000",strokeWidth:b};for(let[K,ct,Xt,Mt]of _)U.drawLine(K,ct,Xt,Mt,B);U.drawText($,l,v,W)}}}};var qi=/\s/,Ms=new Set("\uFF08([\uFF3B\uFF5B\u3008\u300A\u300C\u300E\u3010\u3014\u3016\u3018\u301A\u2018\u201C"),Bn=new Set([...Ms,...`\uFF0C\u3002\uFF01\uFF1F\uFF1B\uFF1A\u3001,.!?;:\uFF09)]\uFF3D\uFF5D\u3009\u300B\u300D\u300F\u3011\u3015\u3017\u3019\u301B\u2019\u201D"'\u2026\u2014\u2013`]);function Ns(r){let t=0,e=r.length;for(;t<e&&Bn.has(r[t]);)t++;for(;e>t&&Bn.has(r[e-1]);)e--;return{prefix:r.slice(0,t),body:r.slice(t,e)}}function Qi(r){let t=r/2;return(e,n)=>{let o=e.map(a=>a&&a.bottom-a.top>1e-6?a:{top:-t,bottom:t}),s=[],i=0;for(let a=0;a<o.length;a++)a>0&&(i+=o[a-1].bottom+n-o[a].top),s.push(i);let c=(s[0]+s[s.length-1])/2;return s.map((a,l)=>({offset:a-c,extent:o[l]}))}}var Gt=class r extends T{static def={name:["voice","v"],description:"\u58F0\u90E8",example:`@voice({}, name, \u6B4C\u8BCD1\u540D=\u6B4C\u8BCD1, \u6B4C\u8BCD2\u540D=\u6B4C\u8BCD2, ...)
120
+ \u7B2C\u4E00\u4E2A\u53C2\u6570\u4E3A\u97F3\u7B26\u5185\u5BB9\uFF0C\u7B2C\u4E8C\u4E2A\u53C2\u6570\u4E3A\u5199\u5728\u6700\u5DE6\u4FA7\u7684\u58F0\u90E8\u540D\u79F0(\u53EF\u4E0D\u586B)\uFF1B
121
+ \u547D\u540D\u53C2\u6570\u4E3A\u6B4C\u8BCD\u5DE6\u4FA7\u7684\u540D\u79F0\u548C\u5185\u5BB9\uFF0C\u53EF\u4EE5\u4EFB\u610F\u591A\u4E2A\u3002\u4E5F\u53EF\u4EE5\u662F\u4F4D\u7F6E\u53C2\u6570\uFF0C\u8868\u793A\u4E0D\u9700\u8981\u540D\u79F0\u3002
122
+ \u4F8B:
123
+ @voice({C1 D1 E1}, \u94A2\u7434, \u7537=ha ha ha, \u5973=la la la)
124
+ @voice({C1 D1 E1}, , ha ha ha, \u5973="la la la") \u8868\u793A\u97F3\u7B26\u548C\u7B2C\u4E00\u4E2A\u6B4C\u8BCD\u90FD\u6CA1\u6709\u540D\u79F0
125
+ \u6B4C\u8BCD\u53EF\u4EE5\u88AB\u5F15\u53F7\u5305\u88F9\uFF0C\u5982\u679C\u5305\u542B\u9017\u53F7\u7B49\u6B67\u4E49\u5B57\u7B26\u4E00\u5B9A\u9700\u8981\u5F15\u53F7
126
+ \u8BED\u6CD5\u7CD6\uFF1A
127
+ N(name): C1 D1 E1
128
+ L(name): ha ha ha...
129
+ L: ...
130
+ \u524D\u9762\u53EF\u4EE5\u6709\u4EFB\u610F\u7A7A\u767D\uFF0C\u4F46\u6700\u540E\u6362\u884C\u8868\u793A\u7ED3\u675F\u3002\u6B4C\u8BCD\u6B64\u65F6\u5141\u8BB8\u6709\u9017\u53F7\u800C\u4E0D\u52A0\u5F15\u53F7
131
+ \u5982\u679C\u4E00\u5B9A\u8981\u6362\u884C\uFF0C\u6700\u540E\u52A0\u4E0A'\\'
132
+ \u82F1\u6587\u6B4C\u8BCD\u7528\u7A7A\u683C\u548C\u8FDE\u5B57\u7B26'-'\u5206\u8BCD\uFF0C\u7528'@'\u5360\u4F4D
133
+ `,allowExtraArgs:!0,extraArgType:"string",args:[{type:"content",default:null},{name:"name",type:"string",default:""}]};static deSugarAtom(t,e,n){if(t[e]!=="N"&&t[e]!=="L")return null;let o=e+1,s="";if(t[o]==="("){let i=Bo(t,o+1,n);if(i<0)return null;s=pt(t.slice(o+1,i).trim()),o=i+1}if(t[o++]!==":")return null;if(t[e]==="N")return{next:o,node:{kind:"sugar",data:{class:r,name:s},span:{start:e,end:o}}};{if(o=ot(t,o,n),o>=n)return null;let i;if(t[o]==='"'){let a=_t(t,o,n);if(a<0)return null;i=pt(t.slice(o,a+1)),o=a+1}else{let a=o;for(;o<n&&t[o]!==`
134
+ `;)o++;i=t.slice(a,o).trim()}return{next:o,node:{kind:"sugar",data:{class:r,lyric:i,name:s},span:{start:e,end:o}}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==r)return null;if(o.data?.lyric!==void 0){let g=null,y=t.nodes.length-1;for(;y>=0;y--){let u=t.nodes[y];if(u instanceof H){if(!t.variables.strict)continue;throw new C("E_LYRICS_WITHOUT_VOICE_NOTES","strict \u6A21\u5F0F\u4E0B\uFF0C\u8BED\u6CD5\u7CD6 'L:' \u6216 'L(name)' \u5FC5\u987B\u8DDF\u5728 @voice \u7684\u97F3\u7B26\u4E4B\u540E\uFF0C\u4F46\u5728\u5176\u524D\u9762\u53D1\u73B0\u4E86\u672A\u77E5\u6587\u672C",u.sourceSpan)}u instanceof r?g=u:u instanceof dt&&(g=u.voices.at(-1)??null);break}if(g===null)throw new C("E_LYRICS_WITHOUT_VOICE_NOTES","\u8BED\u6CD5\u7CD6 'L:' \u6216 'L(name):' \u5FC5\u987B\u8DDF\u5728 @voice\uFF08\u6216 N:\uFF09\u4E4B\u540E\uFF0C\u4F46\u6CA1\u6709\u627E\u5230\u7B26\u5408\u8981\u6C42\u7684 voice\uFF1B\u8BF7\u68C0\u67E5\u8BED\u6CD5\u6216\u76F4\u63A5\u4F7F\u7528 @voice \u51FD\u6570",o.span);return g.addLyric(o.data.name,o.data.lyric,o.span,t),t.nodes.length=y+1,n<e.length&&typeof e[n]=="number"&&t.source[e[n]]===`
135
+ `&&n++,n}let s=n,i=0;for(;s<e.length;s++){let g=e[s];if(typeof g=="number"){if(t.source[g]===`
136
+ `){i=1;break}}else if(g.kind==="sugar"&&g.data?.class===r)break}let c=new j(t),a=e.slice(n,s);if(s+=i,c.makeNodes(a),c.nodes.length===0)throw E.error.EmptyContent("voice","content",o.span);let l={start:o.span.start,end:c.nodes.at(-1).sourceSpan.end},h=new Map;c.nodes.length===1&&c.nodes[0]instanceof z?h.set(0,c.nodes[0]):h.set(0,new z({...l},c.nodes)),h.set("name",o.data.name);let p=new r(l,h,t,null),f=null,d=t.nodes.length-1,x=null;t:for(;d>=0;d--){let g=t.nodes[d];if(g instanceof H){if(t.variables.strict)break;for(let y=g.sourceSpan.start;y<g.sourceSpan.end;y++)if(t.source[y]===`
137
+ `)break t;x=g;continue}if(g instanceof dt){if(!g.createdBySugar)break;f=g}else if(g instanceof r){let y=new Map;y.set(0,g),f=new dt({start:g.sourceSpan.start,end:g.sourceSpan.end},y,t,null),f.createdBySugar=!0}break}return f?(t.nodes[d]=f,f.addVoice(p),x&&(t.nodes.length=d+1,t.diagnostics.push(new k("W_VOICES_TEXT_BETWEEN","\u4E24\u4E2A @voice \u4E4B\u95F4\u6709\u672A\u77E5\u6587\u672C\u3002\u5F53\u524D\u5904\u4E8E\u975E strict \u6A21\u5F0F\uFF0C\u4F1A\u5FFD\u7565\u8BE5\u5185\u5BB9\u3001\u5408\u5E76\u4E3A\u4E00\u4E2A @voices",x.sourceSpan)))):t.pushNode(p),s}content;name;size;font;lyrics;get children(){return[this.content]}timeFlowModel(){return{children:this.children,mode:"sequence"}}loweringEnter(t){let e=this.parent,n=e instanceof dt&&e.voices.length>1?e.braceSpace:0,o=new Ce(this,n),s=[];return t.beginLoweringGroup(this,{attachment:new Wn(s,o),onTemporal(i){s.push(i)}}),[o]}loweringExit(t){return t.endLoweringGroup(this),[]}constructor(t,e,n,o=null){super(t,o),this.size=n.variables.fontsize,[this.content,this.name]=this.getArgValue(e,n),this.content.parent=this,this.font=n.variables.font,e.delete(0),e.delete("name"),e.delete(1),this.lyrics=[];for(let[s,i]of e){if(typeof i=="string"){this.addLyric(s,i);continue}let c=i,a=n.parseArgWithType(c.valueSpan,"string",t.start);a===null?n.diagnostics.push(new k("W_VOICE_INVALID_LYRIC",`@voice \u7684\u6B4C\u8BCD\u53C2\u6570\u503C\u89E3\u6790\u5931\u8D25, \u53C2\u6570[${s}]\u5C06\u88AB\u5FFD\u7565`,c.valueSpan)):this.addLyric(s,a)}}addLyric(t,e,n=null,o=null){typeof t=="number"&&(t="");let s=r.parseLyric(e);if(s.length===0&&o&&n&&o.diagnostics.push(new k("W_EMPTY_LYRIC",`@voice\u7684\u6B4C\u8BCD${t}\u662F\u7A7A\u7684`,n)),this.lyrics.push({name:t,tokens:s}),n)for(let i=this;i;i=i.parent)i.sourceSpan.start=Math.min(n.start,i.sourceSpan.start),i.sourceSpan.end=Math.max(n.end,i.sourceSpan.end)}static parseLyric(t){let e=[],n="",o="",s=c=>{e.push(o+c),o=""},i=()=>{n&&s(n),n=""};for(let c=0;c<t.length;c++){let a=t[c];if(a==="\\"&&c+1<t.length&&/[\\{}@-]/.test(t[c+1]))n+=t[++c];else if(a==="{"){let l=c+1,h="";for(;l<t.length&&t[l]!=="}";l++)t[l]==="\\"&&l+1<t.length&&/[\\{}@-]/.test(t[l+1])?h+=t[++l]:h+=t[l];l<t.length?(i(),s(h),c=l):n+=a}else qi.test(a)?i():a==="-"?(n+=a,n.length>1&&i()):a==="@"?(n&&(n+=a,i()),e.push("")):Ms.has(a)?(i(),o+=a):Bn.has(a)?n?n+=a:o||!e.at(-1)?o+=a:e[e.length-1]+=a:a.charCodeAt(0)>127?(i(),s(a)):n+=a}return i(),o&&(e.at(-1)?e[e.length-1]+=o:e.push(o)),e}toString(t){let e=[`${this.content.toString(t)},${tt(this.name)}`];for(let n of this.lyrics){let o=tt(n.tokens.map(s=>s.length===0?"@":`{${s.replace(/[\\{}@-]/g,"\\$&")}}`).join(" "));e.push(n.name?`${n.name}=${o}`:o)}return`@voice(
138
+ ${e.join(`,
139
+ `)}
140
+ )`}},dt=class extends T{static def={name:["voices","vs"],description:"\u591A\u4E2A\u58F0\u90E8",example:`@voices(
141
+ @voice({C1 D1 E1}, \u94A2\u7434, \u7537=ha ha ha),
142
+ @voice({C2 D2 E2}, , "la la la")
143
+ )
144
+ \u8BED\u6CD5\u7CD6\uFF1A\u5F53\u591A\u4E2A voice \u7528 voice \u7684\u8BED\u6CD5\u7CD6\u5199\u5728\u4E00\u8D77\u65F6\uFF0C\u4F1A\u81EA\u52A8\u521B\u5EFA\u4E00\u4E2A voices \u7EC4\u4EF6\u5305\u88F9\u5B83\u4EEC\u3002
145
+ \u4F8B\uFF1A
146
+ N(\u94A2\u7434): C1 D1 E1
147
+ L(\u7537): ha ha ha
148
+ N: C2 D2 E2
149
+ L: la la la
150
+ `,allowExtraArgs:!0,extraArgType:"content",args:[]};voices;createdBySugar=!1;size;braceSpace;measure;get children(){return this.voices}timeFlowModel(){return{children:this.children,mode:"parallel",tracks:{laneKey:`voices/${this.voices.length}`,hostIndex:null,measure:this.measure}}}loweringEnter(t){let e=[];return t.beginLoweringGroup(this,{attachment:new Hn(e,this),onTemporal(n){n instanceof Ce&&e.push(n)}}),[]}loweringExit(t){return t.endLoweringGroup(this),[]}constructor(t,e,n,o=null){super(t,o),this.voices=[],this.size=n.variables.fontsize,this.braceSpace=n.variables.fontsize,this.measure=Qi(n.variables.fontsize);for(let[,s]of e){if(s instanceof Y){if(s instanceof Gt)this.addVoice(s);else throw new C("E_VOICES_INVALID_CHILD",`@voices \u7684\u53C2\u6570\u5FC5\u987B\u662F @voice \u51FD\u6570\uFF0C\u4F46\u53D1\u73B0\u4E86\u5176\u4ED6\u7C7B\u578B ${s.constructor.name}`,s instanceof Y?s.sourceSpan:t);continue}let i=s,c=n.parseArgWithType(i.valueSpan,"content",t.start);if(c instanceof Gt)this.addVoice(c);else throw new C("E_VOICES_INVALID_CHILD",`@voices \u7684\u53C2\u6570\u5FC5\u987B\u662F @voice \u51FD\u6570\uFF0C\u4F46\u53D1\u73B0\u4E86\u5176\u4ED6\u7C7B\u578B ${c?.constructor.name}`,i.valueSpan)}if(this.voices.length===0)throw new C("E_VOICES_EMPTY","@voices \u5FC5\u987B\u81F3\u5C11\u5305\u542B\u4E00\u4E2A @voice \u51FD\u6570",t)}addVoice(t){this.voices.push(t),t.parent=this,this.sourceSpan.start=Math.min(t.sourceSpan.start,this.sourceSpan.start),this.sourceSpan.end=Math.max(t.sourceSpan.end,this.sourceSpan.end)}toString(t){let e=Array(this.voices.length);for(let n=0;n<this.voices.length;n++){let o=` ${this.voices[n].toString(t)}`;e[n]=o}return`@voices(
151
+ ${e.join(`,
152
+ `)}
153
+ )`}},Rs=Gt,Is=dt,zn=.82,Ji=.6;function Os(r,t){return{fontFamily:t,fontSize:r*zn,fill:"#000",fontWeight:600}}var Ce=class extends P{braceSpace;textBaselineY=0;constructor(t,e){super(),this.ast=t,this.braceSpace=e,this.mergeKey=-2,(t.name||e>0||t.lyrics.some(n=>n.name))&&this.initLayoutBox()}prepareLayout(t){let e=this.ast.name?t.textMeasurer.measureText(this.ast.name,this.style):{w:0,h:0,baseline:0},n=e.w;for(let s of this.ast.lyrics){if(!s.name)continue;let i=t.textMeasurer.measureText(s.name,Os(this.ast.size,this.ast.font));n=Math.max(n,i.w)}let o=this.braceSpace>0?this.braceSpace:n>0?this.ast.size*Ji:0;this.box.w=n+o,this.box.h=e.h,this.box.anchor=n,this.box.visualAxis=e.h/2,this.textBaselineY=e.baseline,this.springConfig.alpha_R=.45}get style(){return{fontSize:this.ast.size*.85,fontFamily:this.ast.font,fill:"#000",fontWeight:600,textAlign:"right"}}paint(t){this.ast.name&&t.drawText(this.ast.name,this.box.x+this.box.anchor,this.box.y+this.textBaselineY,this.style)}},xt=2.33,mt=1.17,ut=.34,tr=[{op:"M",x:0,y:0},{op:"L",x:0,y:-ut},{op:"C",cx1:xt*.421,cy1:-ut+mt*.077,cx2:xt*.733,cy2:-ut+mt*.346,x:xt,y:-ut+mt},{op:"L",x:xt*.929,y:-ut+mt},{op:"C",cx1:xt*.696,cy1:-ut+mt*.535,cx2:xt*.328,cy2:-ut+mt*.352,x:0,y:0},{op:"Z"}],Hn=class{layer="background";names;ast;get sourceSpan(){return this.ast.sourceSpan}constructor(t,e){this.names=t,this.ast=e}createGeometry(){if(this.names.length<2)return{regions:[],paint(){}};let t=this.names[0].box,e=this.names[this.names.length-1].box,n=this.ast.size,o=t.y+t.visualAxis-n*.5,s=e.y+e.visualAxis+n*.5;if(s-o<1e-6)return{regions:[],paint(){}};let i=Math.max(2.5,n*.19),c=i*xt,a=i*mt,l=t.x+t.anchor+this.ast.braceSpace*.3+i/2,h=[{x:l-i/2,y:o,w:i,h:s-o},{x:l+i*1.33-i*.165,y:o+i*.67,w:i*.33,h:s-o-i*1.34}],p=[{x:l,y:o,scale:i,dir:-1},{x:l,y:s,scale:i,dir:1}];return{regions:[{x:l-i/2,y:o-a,w:c+i/2,h:s-o+a*2}],paint(d){for(let x of h)d.drawRect(x.x,x.y,x.w,x.h,{fill:"#000"});for(let x of p)d.drawPath(tr,{fill:"#000"},{x:x.x,y:x.y,scaleX:x.scale,scaleY:x.scale*x.dir})}}}},Wn=class{layer="foreground";temporalMembers;nameHost;get sourceSpan(){return this.nameHost.ast.sourceSpan}constructor(t,e){this.temporalMembers=t,this.nameHost=e}prepareHorizontal(t,e){let n=this.temporalMembers.filter(D).filter(c=>c.ports?.lyric),{lyrics:o,size:s}=this.nameHost.ast;if(n.length===0||o.length===0)return;let i={fontSize:s*zn,fontFamily:this.nameHost.ast.font,fill:"#000"};for(let c=0;c<n.length;c++){let a=n[c],l=0;for(let h of o){let p=h.tokens[c];if(p){let{body:f}=Ns(p);f&&(l=Math.max(l,e.textMeasurer.measureText(f,i).w/2))}}l!==0&&t[a.layoutLine]?.registerHorizontalLayoutHook(a,a,({columns:h,start:p})=>{let f=h[p].find(x=>x.time===a);if(!f)return;let d=a.ports.lyric.x-a.box.anchor;f.WL=Math.max(f.WL,l-d),f.WR=Math.max(f.WR,l+d)})}}createGeometry(t){let e=this.prepareGeometry(t);return{regions:e,paint(n){for(let o of e)n.drawText(o.text,o.x,o.y+o.textBaselineY,o.style)}}}prepareGeometry(t){let{lyrics:e,size:n}=this.nameHost.ast,o=[],s=this.temporalMembers.filter(D).filter(m=>m.ports?.lyric);if(s.length===0||e.length===0)return o;let i=new Map;for(let m of s){let b=i.get(m.layoutLine);b||i.set(m.layoutLine,b=new Map);let w=m.box.y+m.box.h;b.set(m.track,Math.max(b.get(m.track)??w,w))}let c=n*zn,a=n*.24,l=n*.32,h={fontSize:c,fontFamily:this.nameHost.ast.font,fill:"#000"},p=Os(n,this.nameHost.ast.font),f=t.textMeasurer.measureText("M",h).baseline+l,d=(m,b)=>m+f+b*(c+a),{box:x,layoutLine:g,track:y}=this.nameHost,u=i.get(g)?.get(y);for(let m=0;m<e.length;m++){let b=e[m];for(let R=0;R<b.tokens.length&&R<s.length;R++){let v=b.tokens[R],O=s[R],S=i.get(O.layoutLine)?.get(O.track);if(!v||S===void 0)continue;let _=t.textMeasurer.measureText(v,h),{prefix:L,body:A}=Ns(v),N=A?t.textMeasurer.measureText(A,h).w:0,I=L?t.textMeasurer.measureText(L,h).w:0;o.push({text:v,style:h,textBaselineY:_.baseline,x:O.box.x+O.ports.lyric.x-N/2-I,y:d(S,m)-_.baseline,w:_.w,h:_.h,line:O.layoutLine,track:O.track})}if(!b.name||!x||u===void 0)continue;let w=t.textMeasurer.measureText(b.name,p);o.push({text:b.name,style:p,textBaselineY:w.baseline,x:x.x+x.anchor-w.w,y:d(u,m)-w.baseline,w:w.w,h:w.h,line:g,track:y})}return o}};var Se=[os,_o,xo,At,Mo,ks,Rs,Is,ns,rs,es,ls,ss,is,uo,Po,vs,To,Ro,Eo,Es,oo,Ls,pe,ue,xe,cs,me,As];function Gn(r,t={}){let e=new Map,n=new Set(r);for(let o of n){let s=o.layoutDecorationHandler;if(!s)continue;let i=o.def?.name;if(!i)continue;let c=Array.isArray(i)?i[0]:i;e.set(at(c),s)}return{textMeasurer:t.textMeasurer??en,decorationHandlers:e}}var Vt=class r{parent;groups=[];constructor(t=null){this.parent=t}group(t,e){let n=this.groups.find(o=>o.laneKey===t.laneKey);for(n||(n={laneKey:t.laneKey,members:[],measure:t.measure,place:t.place},this.groups.push(n));n.members.length<e;)n.members.push(new r(this));return n}};var Yt=class r{loweringAugmenters=[];loweringFinalizers=[];cnt=0;usedTracks=new Set;attachments=[];page;astToTemporal=new Map;activeLoweringGroups=[];diagnostics;constructor(t=[]){this.diagnostics=t}registerFunctions(t){let e=this.loweringAugmenters=[],n=this.loweringFinalizers=[];for(let o of t)o.loweringAugment&&e.push(o.loweringAugment),o.loweringFinalize&&n.push(o.loweringFinalize)}setPageConfig(t){this.page=t}lowerDocument(t){this.cnt=0,this.usedTracks.clear(),this.attachments=[],this.page=void 0,this.astToTemporal=new Map,this.activeLoweringGroups=[];let e=new Vt,n=new M,o=this.trackedEvents(t,n,e);return this.solidifyColumns(o),this.postprocessResult({diagnostics:this.diagnostics,columns:o,attachments:this.attachments,astToTemporal:this.astToTemporal,duration:n,rootTrack:e,tracks:[...this.usedTracks],page:this.page})}solidifyColumns(t){let e=0;for(let a of t){let l=0;for(let h of a)h.breakBefore>l&&(l=h.breakBefore);e+=l,a.layoutLine=e}let n={bpm:it,velocity:bt,keySignature:It,program:Zt},o=new Map,s=new Map,i=a=>o.get(a)??(a.parent?i(a.parent):bt),c=a=>s.get(a)??(a.parent?c(a.parent):Zt);for(let a of t)for(let l of a)n.velocity=i(l.track),n.program=c(l.track),l.onTimeState?.(n),o.set(l.track,n.velocity),s.set(l.track,n.program)}beginLoweringGroup(t,e){this.activeLoweringGroups.push({owner:t,group:e})}endLoweringGroup(t){let e=this.activeLoweringGroups.pop();if(!e)throw new Error("No active lowering group to end");if(e.owner!==t)throw new Error("Lowering groups must end in reverse order");return e.group.attachment&&this.addAttachment(e.group.attachment),e.group}postprocessResult(t){if(this.activeLoweringGroups.length>0)throw new Error("Lowering groups must be closed before post-processing");let e=[];for(let n of this.loweringAugmenters)for(let o of n(t))e.push(o);for(let n of e)this.addAttachment(n);for(let n of this.loweringFinalizers)n(t);return t}addAttachment(t){this.attachments.push(t);for(let e=this.activeLoweringGroups.length-1;e>=0;e--)this.activeLoweringGroups[e].group.onAttachment?.(t)}getTemporalNodes(t){return this.astToTemporal.get(t)??[]}isolateFromLoweringGroups(t){let e=this.activeLoweringGroups;this.activeLoweringGroups=[];try{return t()}finally{this.activeLoweringGroups=e}}initEvent(t,e,n,o){t.t.add(n),this.usedTracks.add(o),t.track=o,t.ast??=e,t.order=this.cnt++,t.mergeKey??=t.order}trackedEvents(t,e,n){let o=[];this.appendEvents(t.loweringEnter(this,n),t,e,n,o);let s=t.timeFlowModel(this);if(s)switch(s.mode){case"sequence":for(let i of s.children)for(let c of this.trackedEvents(i,e,n))o.push(c);break;case"parallel":{let i=s.tracks,c=s.children,a=i.hostIndex===void 0?0:i.hostIndex,l=n.group(i,a===null?c.length:c.length-1),h=[];for(let d=0;d<c.length;d++){let x=c[d],g=d===a?n:l.members[a===null||d<a?d:d-1],y=e.clone(),u=this.trackedEvents(x,y,g);u.length===0&&this.diagnostics.push(E.warning.ZeroTimeTrack(x.sourceSpan,d+1)),h.push(u)}let p=o.length;for(let d of r.anchorAlign(h))o.push(d);let f=new M;for(let d=p;d<o.length;d++)for(let x of o[d])f.copyFrom(x.t).add(x.T),f.compare(e)>0&&e.copyFrom(f)}break}return this.appendEvents(t.loweringExit(this,n,e),t,e,n,o),o}appendEvents(t,e,n,o,s){let i;for(let c of t){this.initEvent(c,e,n,o),this.indexTemporal(c);for(let l=this.activeLoweringGroups.length-1;l>=0;l--)this.activeLoweringGroups[l].group.onTemporal?.(c);let a=(i??=new M).copyFrom(c.t).add(c.T);a.compare(n)>0&&n.copyFrom(a),s.push(new Yn(c))}}indexTemporal(t){let e=this.astToTemporal.get(t.ast);e?e.push(t):this.astToTemporal.set(t.ast,[t])}static anchorAlign(t){for(let l=t.length-1;l>=0;l--)t[l].length===0&&t.splice(l,1);let e=t.length;if(e===0)return[];if(e===1)return t[0];let n=[];if(e===2){let l=t[0],h=t[1],p=l.length,f=h.length,d=0,x=0,g=new M,y=new M,u=l[0],m=h[0],b=u.t.clone(),w=m.t.clone();for(;;){if(u.mergeKey===G){if(m.mergeKey!==G){for(n.push(m),m=h[++x];x<f&&m.mergeKey!==G;)y.isZero()||m.shiftTime(y),n.push(m),m=h[++x];m&&(m.shiftTime(y),w.copyFrom(m.t))}if(x<f){let R=b.compare(w)>=0?b:w;g.add(R).sub(b),y.add(R).sub(w),u.push(...m),u.t=R,m=h[++x]}if(n.push(u),u=l[++d],u&&(u.shiftTime(g),b.copyFrom(u.t)),m&&(m.shiftTime(y),w.copyFrom(m.t)),!u||!m)break}if(m.mergeKey===G){if(u.mergeKey!==G){for(n.push(u),u=l[++d];d<p&&u.mergeKey!==G;)g.isZero()||u.shiftTime(g),n.push(u),u=l[++d];u&&(u.shiftTime(g),b.copyFrom(u.t))}if(d<p){let R=b.compare(w)>=0?b:w;g.add(R).sub(b),y.add(R).sub(w),m.push(...u),m.t=R,u=l[++d]}if(n.push(m),m=h[++x],u&&(u.shiftTime(g),b.copyFrom(u.t)),m&&(m.shiftTime(y),w.copyFrom(m.t)),!u||!m)break}if(b.equals(w)){if(u.mergeKey===m.mergeKey){if(u.push(...m),n.push(u),u=l[++d],m=h[++x],u&&(u.shiftTime(g),b.copyFrom(u.t)),m&&(m.shiftTime(y),w.copyFrom(m.t)),!u||!m)break}else if(u.mergeKey<m.mergeKey)if(n.push(u),u=l[++d],u)u.shiftTime(g),b.copyFrom(u.t);else break;else if(n.push(m),m=h[++x],m)m.shiftTime(y),w.copyFrom(m.t);else break;continue}if(b.compare(w)<0)if(n.push(u),u=l[++d],u){u.shiftTime(g),b.copyFrom(u.t);continue}else break;if(w.compare(b)<0)if(n.push(m),m=h[++x],m){m.shiftTime(y),w.copyFrom(m.t);continue}else break}for(u&&n.push(u);++d<p;)u=l[d],g.isZero()||u.shiftTime(g),n.push(u);for(m&&n.push(m);++x<f;)m=h[x],y.isZero()||m.shiftTime(y),n.push(m);return n}let o=new Uint16Array(e),s=Array.from({length:e},()=>new M),i=[],c=new Kn(e);for(let l=0;l<e;l++)c.push({e:t[l][0],i:l});let a=l=>{let h=t[l][++o[l]];h&&(s[l].isZero()||h.shiftTime(s[l]),c.push({e:h,i:l}))};for(;;){let l=c.pop();if(l===void 0){if(i.length===0)break;let p=i[0],f=p.e,d=f.t;for(let x=1;x<i.length;x++)i[x].e.t.compare(d)>0&&(d=i[x].e.t);s[p.i].add(d).sub(f.t),a(p.i);for(let x=1;x<i.length;x++){let g=i[x];f.push(...g.e),s[g.i].add(d).sub(g.e.t),a(g.i)}i.length=0,f.t=d,f.sort((x,g)=>x.order-g.order),n.push(f);continue}if(l.e.mergeKey===G){i.push(l);continue}let h=[l.i];for(;;){let p=c.front();if(!p||!p.e.t.equals(l.e.t)||p.e.mergeKey!==l.e.mergeKey)break;c.pop(),l.e.push(...p.e),h.push(p.i)}n.push(l.e);for(let p of h)a(p)}return n}},Yn=class extends Array{static get[Symbol.species](){return Array}mergeKey;constructor(t){super(1),this.mergeKey=t.mergeKey,this[0]=t}get t(){return this[0].t}set t(t){for(let e of this)e.t.copyFrom(t)}shiftTime(t){for(let e of this)e.t.add(t)}set layoutLine(t){for(let e of this)e.layoutLine=t}};function Vn(r,t){let e=r.e.t.compare(t.e.t);return e!==0?e:r.e.mergeKey!==t.e.mergeKey?r.e.mergeKey<t.e.mergeKey?-1:1:r.i-t.i}var Kn=class extends Array{validLen=0;constructor(t){super(t)}front(){if(this.validLen!==0)return this[0]}push(t){return this[this.validLen]=t,this.up(this.validLen++),this.validLen}pop(){if(this.validLen===0)return;let t=this[0];return this[0]=this[--this.validLen],this[this.validLen]=void 0,this.down(0),t}up(t){let e=this[t];for(;t>0;){let n=t-1>>1;if(Vn(e,this[n])>=0)break;this[t]=this[n],t=n}this[t]=e}down(t){let e=this[t];for(;;){let n=(t<<1)+1,o=n+1;if(n>=this.validLen)break;let s=n;if(o<this.validLen&&Vn(this[o],this[n])<0&&(s=o),Vn(this[s],e)>=0)break;this[t]=this[s],t=s}this[t]=e}};var Un=10,Xn=13,er=9,nr=11,or=12,sr=32,ir=160,rr=5760,cr=8239,ar=8287,lr=12288,hr=65279,pr=34,Ds=92,fr=37,ur=32,xr=[];function mr(r){return r>ur?" ".repeat(r):xr[r]??=" ".repeat(r)}function Ps(r){return r===sr||r===er||r===nr||r===or?!0:r<128?!1:r===ir||r===rr||r>=8192&&r<=8202||r===cr||r===ar||r===lr||r===hr}function Ae(r){let t=r.length,e=[0],n=[],o=[],s=(u,m)=>{if(u>=m)return;let b=o.length;if(b>=2&&u<=o[b-1]){m>o[b-1]&&(o[b-1]=m);return}o.push(u,m)},i=(u,m)=>{if(m<=0)return;let b=u+m;for(let w=u;w<b;w+=2)s(w,w+1)},c=0,a=!1,l=!1,h=-1,p=-1,f=-1,d=0,x=(u,m)=>{if(m===Ds){d>0&&p+1===u?d++:(f=u,d=1),p=u;return}f=-1,d=0,p=u};for(let u=0;u<t;){let m=r.charCodeAt(u);if(m===Xn||m===Un){let b=m===Xn&&u+1<t&&r.charCodeAt(u+1)===Un?2:1;e.push(u+b);let w=(d&1)===1;i(f,d),h>=0&&(s(h,u),n.push({start:h,end:u}),h=-1),w&&s(u,u+b),p=-1,f=-1,d=0,l=!1,u+=b;continue}if(c!==0){l?l=!1:m===Ds?l=!0:m===c&&(c=0),Ps(m)||x(u,m),u++;continue}if(m===pr){a||(_t(r,u,t)<0?a=!0:c=m),x(u,m),u++;continue}if(m===fr){for(h=u,u++;u<t;){let b=r.charCodeAt(u);if(b===Xn||b===Un)break;u++}continue}Ps(m)||x(u,m),u++}if(i(f,d),h>=0&&(s(h,t),n.push({start:h,end:t})),o.length===0)return{maskedSource:r,lineStarts:e,commentSpans:n};let g=[],y=0;for(let u=0;u<o.length;u+=2){let m=o[u],b=o[u+1];y<m&&g.push(r.slice(y,m)),g.push(mr(b-m)),y=b}return y<t&&g.push(r.slice(y)),{maskedSource:g.join(""),lineStarts:e,commentSpans:n}}function dr(r,t={}){let{functions:e=Se,textMeasurer:n,variables:o,...s}=t,{maskedSource:i,lineStarts:c}=Ae(r),a=new j({source:i,variables:o});a.registerFunctions(e);let l=new z({start:0,end:r.length},a.parse()),h=new Yt(a.diagnostics);h.registerFunctions(e);let p=h.lowerDocument(l),f=Gn(e,{textMeasurer:n}),d=De(p,f,s);return{lineStarts:c,maskedSource:i,diagnostics:a.diagnostics,ast:l,lowering:p,layout:d}}function yr(r,t=Se){let{maskedSource:e,commentSpans:n}=Ae(r),o=new j({source:e,commentSpans:n});return o.registerFunctions(t),{syntax:o.parseSyntax(),diagnostics:o.diagnostics}}function Zn(r){return typeof r.applyPlayback=="function"}function Le(r,t){let e=Math.max(0,t),n=0,o=0,s=it;for(let i of r){if(i.kind!=="tempo")continue;let c=i.at.toNumber();if(c>e)break;c>o&&(n+=(c-o)*60/s),o=c,s=i.bpm}return n+(e-o)*60/s}function Fs(r,t){let e=Math.max(0,t),n=0,o=it;for(let s of r){if(s.kind!=="tempo")continue;let i=s.at.toNumber(),c=(i-n)*60/o;if(e<c)return n+e*o/60;e-=c,n=i,o=s.bpm}return n+e*o/60}function $s(r,t){let e=Math.max(0,t),n=e;for(let o of r){let s=o.performance.toNumber();if(s>e)break;n=o.score.toNumber()+e-s}return n}function Bs(r,t){let e=Math.max(0,t),n;for(let o=0;o<r.length;o++){let s=r[o],i=s.score.toNumber();if(i>e){(!n||i<n.score.toNumber())&&(n=s);continue}let c=r[o+1],a=c?c.performance.toNumber()-s.performance.toNumber():1/0;if(!(e-i>=a))return s.performance.toNumber()+(e-i)}return n?.performance.toNumber()??e}function gr(r,t){let e=Math.min(Fs(r.events,t),r.performanceDuration.toNumber());return $s(r.scoreMap,e)}function br(r,t){let e=Math.min(Bs(r.scoreMap,t),r.performanceDuration.toNumber());return Le(r.events,e)}var zs={tempo:0,"time-signature":1,"program-change":2,"note-off":3,"note-on":4};function jn(r,t){return r.at.compare(t.at)||zs[r.kind]-zs[t.kind]||r.order-t.order}function Hs(r,t){let e=new Map,n=new Map;for(let c of r)if(c.kind==="note-on"){if(e.has(c.noteId))throw new Error(`Duplicate NoteOn ${c.noteId}`);e.set(c.noteId,c)}else if(c.kind==="note-off"){if(n.has(c.noteId))throw new Error(`Duplicate NoteOff ${c.noteId}`);n.set(c.noteId,c)}for(let[c,a]of e){let l=n.get(c);if(!l)throw new Error(`Note ${c} has no NoteOff`);if(l.at.compare(a.at)<=0)throw new Error(`Note ${c} has a non-positive duration`);if(a.origins.length===0||l.origins.length===0)throw new Error(`Note ${c} has no origin`)}for(let c of n.keys())if(!e.has(c))throw new Error(`NoteOff ${c} has no NoteOn`);let o=new Set;for(let c of e.values())o.add(c.track);let s=new Map;for(let c of t)o.has(c)&&s.set(c,s.size);for(let c of o)s.has(c)||s.set(c,s.size);let i=[];for(let c of r){if(c.kind==="tempo"){i.push({kind:"tempo",at:c.at,bpm:c.bpm});continue}if(c.kind==="time-signature"){i.push({kind:"time-signature",at:c.at,numerator:c.numerator,denominator:c.denominator});continue}if(c.kind==="program-change"){let h=s.get(c.track);h!==void 0&&i.push({kind:"program-change",at:c.at,track:h,program:c.program});continue}let a=c.kind==="note-on"?c:e.get(c.noteId),l=s.get(a.track);if(c.kind==="note-on"){i.push({kind:"note-on",at:c.at,noteId:c.noteId,track:l,midi:c.midi,velocity:c.velocity,...c.percussion?{percussion:!0}:{},sourceSpans:c.sourceSpans});continue}i.push({kind:"note-off",at:c.at,noteId:c.noteId,track:l,midi:a.midi})}return{events:i,tracks:[...s.keys()]}}function wr(r,t,e){let n=r.columns,o=new Map;for(let y=0;y<n.length;y++)for(let u of n[y])o.set(u,y);let s=y=>{for(let u=y;u;u=u.foldedInto){let m=o.get(u);if(m!==void 0)return m}},i=new Map,c=new Map,a=(y,u)=>{let m=y.playbackFlow?.(s);if(!m)return;let[b,w]=m.range??[0,n.length-1];if(m.range&&(!Number.isSafeInteger(b)||!Number.isSafeInteger(w)||b<0||w<b||w>=n.length))throw new C("E_PLAYBACK_FLOW_RANGE",`\u64AD\u653E\u63A7\u5236\u6D41\u8303\u56F4 [${b}, ${w}] \u8D85\u51FA\u65F6\u95F4\u5217\u8FB9\u754C`,u);let R={hook:m,sourceSpan:u};for(let v=b;v<=w;v++){let O=c.get(v);O?O.push(R):c.set(v,[R])}};for(let y of r.astToTemporal.values())for(let u of y){a(u,u.ast.sourceSpan);let m=u.playbackMarks?.();if(!m)continue;let b=s(u);if(b!==void 0)for(let w of m){let R=i.get(w);R?R.push(b):i.set(w,[b])}}for(let y of r.attachments)a(y,y.sourceSpan??{start:0,end:0});if(c.size===0)return n.map((y,u)=>u);for(let y of i.values())y.sort((u,m)=>u-m);let l=new Array(n.length).fill(0),h=0,p={get column(){return h},visits:y=>l[y]??0,seek(y,u,m){let b=i.get(y);if(b){if(m>0)return b.find(w=>w>u);for(let w=b.length-1;w>=0;w--)if(b[w]<u)return b[w]}}},f=[],d=0;for(;h<n.length;){if(++d>e)throw new C("E_PLAYBACK_FLOW_LIMIT",`\u64AD\u653E\u63A7\u5236\u6D41\u8BBF\u95EE\u8D85\u8FC7 ${e} \u6B65\uFF1B\u53EF\u901A\u8FC7 maxFlowSteps \u63D0\u9AD8\u5C55\u5F00\u9884\u7B97`,n[h][0].ast.sourceSpan);l[h]++;let y;for(let u of c.get(h)??[]){let b=u.hook.run(p);if(b){if(b.kind==="stop")return f;if(!Number.isSafeInteger(b.column)||b.column<0||b.column>n.length)throw new C("E_PLAYBACK_FLOW_JUMP",`\u64AD\u653E\u63A7\u5236\u6D41\u8DF3\u8F6C\u76EE\u6807 ${b.column} \u8D85\u51FA\u65F6\u95F4\u5217\u8FB9\u754C`,u.sourceSpan);y=Math.min(y??1/0,b.column)}}y!==void 0?h=y:(f.push(h),h++)}let x=new Set(f),g=!1;for(let y=0;y<n.length;y++){let u=!x.has(y);u&&!g&&t.push(new k("W_PLAYBACK_COLUMN_NEVER_PLAYED","\u8FD9\u91CC\u5728\u4EFB\u4F55\u4E00\u904D\u91CC\u90FD\u4E0D\u4F1A\u6F14\u594F",n[y][0].ast.sourceSpan)),g=u}return f}function Cr(r,t){let e=t?.maxFlowSteps??65536;if(!Number.isSafeInteger(e)||e<=0)throw new C("E_PLAYBACK_FLOW_LIMIT","maxFlowSteps \u5FC5\u987B\u662F\u6B63\u5B89\u5168\u6574\u6570",r.columns[0]?.[0]?.ast.sourceSpan??{start:0,end:0});let n=[],o=[],s=[],i=new Map,c=0,a=0,l=()=>a++,h=[],p=(A,N,I)=>h.push({at:A.clone(),origins:N,apply:I});function f(A,N,I,$,W=[]){let U={node:A},B=[...W,U],K=A.playbackState?.program;if(K!==void 0&&i.get(A.track)!==K&&(i.set(A.track,K),s.push({kind:"program-change",at:I.clone(),order:c++,origins:[...B],track:A.track,program:K})),A.playbackState){let{bpm:V}=A.playbackState;p(I,B,X=>{V&&(X.bpm=V)})}let ct=N.length,Xt=[...N],Mt=[],ve,eo=!1;A.emitPlayback?.({start:I,end:I.clone().add($),track:A.track,nextNoteId:l,emit(V){let X={...V,at:V.at.clone(),order:c++,origins:[...B]};if(X.kind==="note-on"){eo=!0;let st={...X,track:A.track,sourceSpans:[{...A.ast.sourceSpan}]};Mt.push(st),s.push(st)}else Mt.push(X),s.push(X)},control:(V,X)=>p(V,B,X),affectFollowing:V=>N.push(V),defer:V=>(ve??=[]).push(V),play:(V,X,st)=>f(V,Xt,X??I,st??$,B)}),ct>0&&eo&&s.push(V=>{let X=Mt;for(let st=0;st<ct;st++){let no=X.length,ke=Xt[st](V,X);ke&&(V.events.splice(V.events.length-no,no,...ke),X=ke)}}),ve&&s.push(...ve)}let d=wr(r,n,e),x=r.columns[d[0]]?.[0]?.t.clone()??new M,g=[{performance:new M,score:x}],y=new M().sub(x),u=new M;for(let A=0;A<d.length;A++){let N=d[A];for(let K of r.columns[N])f(K,[],K.t.clone().add(y),K.T.clone());let I=r.columns[N+1]?.[0]?.t??r.duration;u.copyFrom(I).add(y);let $=d[A+1];if($===void 0||$===N+1)continue;let W=r.columns[$][0]?.t.clone()??new M;y.add(I).sub(W);let U={performance:u.clone(),score:W};g[g.length-1].performance.equals(U.performance)?g[g.length-1]=U:g.push(U)}let m={bpm:it,bpmScale:new M(1)},b=[],w,R=()=>({bpm:m.bpm,bpmScale:m.bpmScale.clone(),effectiveBpm:m.bpm*m.bpmScale.toNumber()}),v=(A,N)=>{let I=R();if(!Number.isFinite(I.effectiveBpm)||I.effectiveBpm<=0)throw new Error("Playback controls produced an invalid BPM");let $=b[b.length-1];$&&$.state.bpm===I.bpm&&$.state.bpmScale.equals(I.bpmScale)||(b.push({at:A,state:I}),w!==I.effectiveBpm&&(w=I.effectiveBpm,o.push({kind:"tempo",at:A.clone(),bpm:I.effectiveBpm,order:c++,origins:N})))};h.sort((A,N)=>A.at.compare(N.at));let O=0;for(h[0]?.at.compare(0)!==0&&v(new M,[]);O<h.length;){let A=h[O].at.clone(),N=[];for(;O<h.length&&A.equals(h[O].at);){let I=h[O++];I.apply(m);for(let $ of I.origins)N.includes($)||N.push($)}v(A,N)}let S={events:o,diagnostics:n,nextNoteId:l,stateAt:A=>{let N=0,I=b.length;for(;N<I;){let $=N+I>>>1;b[$].at.compare(A)<=0?N=$+1:I=$}return b[N-1]?.state??R()}};for(let A of s)typeof A=="function"?A(S):o.push(A);o.sort(jn);for(let A of r.attachments)Zn(A)&&A.applyPlayback(S);o.sort(jn);let _=Hs(o,r.tracks),L=o.at(-1)?.at;return L&&L.compare(u)>0&&u.copyFrom(L),{events:_.events,scoreMap:g,tracks:_.tracks,performanceDuration:u,durationSeconds:Le(_.events,u.toNumber()),diagnostics:n}}function yt(r){return r.pages.length>0?r.pages.map(t=>t.bounds):[r.bounds]}function Qn(r,t){for(let e of r.attachments)e.layer==="background"&&e.paint(t);for(let e of r.objects){e.paint(t);for(let n of e.decorations)n.paint(t)}for(let e of r.attachments)e.layer==="foreground"&&e.paint(t)}var qn=class{pages;painters;constructor(t,e){this.pages=t,this.painters=e}route(t,e,n){let o=0,s=this.pages.length;for(;o<s;){let i=o+s>>>1,c=this.pages[i];c.y+c.h<t?o=i+1:s=i}for(let i=o;i<this.pages.length&&this.pages[i].y<=e;i++)n(this.painters[i])}drawText(t,e,n,o){this.route(n,n,s=>s.drawText(t,e,n,o))}drawLine(t,e,n,o,s){let i=(s?.strokeWidth??1)/2;this.route(Math.min(e,o)-i,Math.max(e,o)+i,c=>c.drawLine(t,e,n,o,s))}drawRect(t,e,n,o,s){let i=s?.stroke?(s.strokeWidth??1)/2:0;this.route(e-i,e+Math.max(0,o)+i,c=>{c.drawRect(t,e,n,o,s)})}drawCircle(t,e,n,o){let s=o?.stroke?(o.strokeWidth??1)/2:0,i=Math.max(0,n)+s;this.route(e-i,e+i,c=>c.drawCircle(t,e,n,o))}drawPath(t,e,n){if(t.length===0)return;let o=n?l=>n.y+l*n.scaleY:l=>l,s=1/0,i=-1/0,c=l=>{let h=o(l);s=Math.min(s,h),i=Math.max(i,h)};for(let l of t)l.op!=="Z"&&(l.op==="Q"&&c(l.cy),l.op==="C"&&(c(l.cy1),c(l.cy2)),c(l.y));if(!Number.isFinite(s))return;let a=e?.stroke?(e.strokeWidth??1)/2:0;this.route(s-a,i+a,l=>{l.drawPath(t,e,n)})}};function Te(r,t){let e=yt(r);if(t.length!==e.length)throw new Error(`Expected ${e.length} page painters, got ${t.length}`);Qn(r,new qn(e,t))}var Jn=class{commands=[];drawText(t,e,n,o){this.commands.push({kind:"text",text:t,x:e,y:n,style:o})}drawLine(t,e,n,o,s){this.commands.push({kind:"line",x1:t,y1:e,x2:n,y2:o,style:s})}drawRect(t,e,n,o,s){this.commands.push({kind:"rect",x:t,y:e,w:n,h:o,style:s})}drawCircle(t,e,n,o){this.commands.push({kind:"circle",cx:t,cy:e,r:n,style:o})}drawPath(t,e,n){this.commands.push({kind:"path",commands:t.map(o=>Sr(o,n)),style:e})}};function Sr(r,t){if(!t||r.op==="Z")return{...r};let e=o=>t.x+o*t.scaleX,n=o=>t.y+o*t.scaleY;return r.op==="M"||r.op==="L"?{op:r.op,x:e(r.x),y:n(r.y)}:r.op==="Q"?{op:"Q",cx:e(r.cx),cy:n(r.cy),x:e(r.x),y:n(r.y)}:r.op==="C"?{op:"C",cx1:e(r.cx1),cy1:n(r.cy1),cx2:e(r.cx2),cy2:n(r.cy2),x:e(r.x),y:n(r.y)}:{...r}}function F(r){return Number.isFinite(r)?String(Math.round(r*1e3)/1e3):"0"}function q(r){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function Ar(r,t){let e=[],n=t?s=>F(t.x+s*t.scaleX):F,o=t?s=>F(t.y+s*t.scaleY):F;for(let s of r){if(s.op==="Z"){e.push("Z");continue}if(s.op==="M"||s.op==="L"){e.push(`${s.op}${n(s.x)} ${o(s.y)}`);continue}if(s.op==="Q"){e.push(`Q${n(s.cx)} ${o(s.cy)} ${n(s.x)} ${o(s.y)}`);continue}"cx1"in s&&e.push(`C${n(s.cx1)} ${o(s.cy1)} ${n(s.cx2)} ${o(s.cy2)} ${n(s.x)} ${o(s.y)}`)}return e.join(" ")}function Kt(r){return r?.opacity===void 0?"":` opacity="${F(r.opacity)}"`}var Ee=class{body=[];drawText(t,e,n,o){let s=o.fontFamily??Et,i=o.fontWeight??"normal",c=o.fill??"#000",a=o.textAlign==="center"?"middle":o.textAlign==="right"?"end":"start";this.body.push(`<text x="${F(e)}" y="${F(n)}" font-family="${q(s)}" font-size="${F(o.fontSize)}" font-weight="${q(String(i))}" text-anchor="${a}" fill="${q(c)}" xml:space="preserve"${Kt(o)}>${q(t)}</text>`)}drawLine(t,e,n,o,s){let i=s?.stroke??s?.fill??"#000",c=s?.strokeWidth??1;this.body.push(`<line x1="${F(t)}" y1="${F(e)}" x2="${F(n)}" y2="${F(o)}" stroke="${q(i)}" stroke-width="${F(c)}" stroke-linecap="round"${Kt(s)} />`)}drawRect(t,e,n,o,s){let i=s?.fill??"none",c=s?.stroke??"none",a=s?.strokeWidth??1;this.body.push(`<rect x="${F(t)}" y="${F(e)}" width="${F(Math.max(0,n))}" height="${F(Math.max(0,o))}" fill="${q(i)}" stroke="${q(c)}" stroke-width="${F(a)}"${Kt(s)} />`)}drawCircle(t,e,n,o){let s=o?.fill??"#000",i=o?.stroke??"none",c=o?.strokeWidth??1;this.body.push(`<circle cx="${F(t)}" cy="${F(e)}" r="${F(Math.max(0,n))}" fill="${q(s)}" stroke="${q(i)}" stroke-width="${F(c)}"${Kt(o)} />`)}drawPath(t,e,n){if(t.length===0)return;let o=Ar(t,n),s=e?.fill??"none",i=e?.stroke??"none",c=e?.strokeWidth??1;this.body.push(`<path d="${o}" fill="${q(s)}" stroke="${q(i)}" stroke-width="${F(c)}" stroke-linecap="round" stroke-linejoin="round"${Kt(e)} />`)}toSvg(t,e={}){let n=Math.max(0,e.padding??0),o=t.x-n,s=t.y-n,i=Math.max(1,t.w+n*2),c=Math.max(1,t.h+n*2),a=e.background?`<rect x="${F(o)}" y="${F(s)}" width="${F(i)}" height="${F(c)}" fill="${q(e.background)}" />`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${F(i)}" height="${F(c)}" viewBox="${F(o)} ${F(s)} ${F(i)} ${F(c)}">${a}${this.body.join("")}</svg>`}};function Lr(r,t={}){let e=yt(r),n=e.map(()=>new Ee);return Te(r,n),n.map((o,s)=>o.toSvg(e[s],t))}function Tr(r,t,e=0,n=0,o=1,s=1){r.beginPath();for(let i of t){if(i.op==="Z"){r.closePath();continue}if(i.op==="M"){r.moveTo(e+i.x*o,n+i.y*s);continue}if(i.op==="L"){r.lineTo(e+i.x*o,n+i.y*s);continue}if(i.op==="Q"){r.quadraticCurveTo(e+i.cx*o,n+i.cy*s,e+i.x*o,n+i.y*s);continue}"cx1"in i&&r.bezierCurveTo(e+i.cx1*o,n+i.cy1*s,e+i.cx2*o,n+i.cy2*s,e+i.x*o,n+i.y*s)}}function Ut(r,t){t?.opacity!==void 0&&(r.globalAlpha*=t.opacity)}var _e=class{context;constructor(t){this.context=t}drawText(t,e,n,o){this.context.save(),Ut(this.context,o),this.context.fillStyle=o.fill??"#000",this.context.font=ie(o),this.context.textAlign=o.textAlign??"left",this.context.textBaseline="alphabetic",this.context.fillText(t,e,n),this.context.restore()}drawLine(t,e,n,o,s){this.context.save(),Ut(this.context,s),this.context.beginPath(),this.context.moveTo(t,e),this.context.lineTo(n,o),this.context.strokeStyle=s?.stroke??s?.fill??"#000",this.context.lineWidth=s?.strokeWidth??1,this.context.lineCap="round",this.context.stroke(),this.context.restore()}drawRect(t,e,n,o,s){n<0||o<0||(this.context.save(),Ut(this.context,s),s?.fill&&(this.context.fillStyle=s.fill,this.context.fillRect(t,e,n,o)),s?.stroke&&(this.context.strokeStyle=s.stroke,this.context.lineWidth=s.strokeWidth??1,this.context.strokeRect(t,e,n,o)),this.context.restore())}drawCircle(t,e,n,o){n<0||(this.context.save(),Ut(this.context,o),this.context.beginPath(),this.context.arc(t,e,n,0,Math.PI*2),(o?.fill??!0)&&(this.context.fillStyle=o?.fill??"#000",this.context.fill()),o?.stroke&&(this.context.strokeStyle=o.stroke,this.context.lineWidth=o.strokeWidth??1,this.context.stroke()),this.context.restore())}drawPath(t,e,n){t.length!==0&&(this.context.save(),Ut(this.context,e),Tr(this.context,t,n?.x,n?.y,n?.scaleX,n?.scaleY),e?.fill&&(this.context.fillStyle=e.fill,this.context.fill()),e?.stroke&&(this.context.strokeStyle=e.stroke,this.context.lineWidth=e.strokeWidth??1,this.context.lineCap="round",this.context.lineJoin="round",this.context.stroke()),this.context.restore())}};function Er(r,t){let e=yt(r);if(t.length!==e.length)throw new Error(`Expected ${e.length} page contexts, got ${t.length}`);for(let[n,o]of t.entries())o.save(),o.translate(-e[n].x,-e[n].y);try{Te(r,t.map(n=>new _e(n)))}finally{for(let n of t)n.restore()}}var _r=globalThis;Object.assign(_r.jpfun??={},to);})();