jpfun 0.4.1 → 0.5.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 (73) hide show
  1. package/README.md +53 -113
  2. package/dist/converter/midi/convert.js +14 -7
  3. package/dist/converter/musicxml/features.d.ts +57 -16
  4. package/dist/converter/musicxml/features.js +204 -42
  5. package/dist/converter/musicxml/index.d.ts +7 -2
  6. package/dist/converter/musicxml/index.js +256 -268
  7. package/dist/converter/musicxml/model.d.ts +36 -7
  8. package/dist/converter/musicxml/resolve.d.ts +10 -0
  9. package/dist/converter/musicxml/resolve.js +152 -0
  10. package/dist/core.d.ts +1 -0
  11. package/dist/core.js +1 -0
  12. package/dist/fraction.js +7 -1
  13. package/dist/functions/ASTtypes.d.ts +2 -3
  14. package/dist/functions/ASTtypes.js +5 -9
  15. package/dist/functions/adjust/index.js +4 -48
  16. package/dist/functions/arpeggio/index.js +21 -13
  17. package/dist/functions/box/index.js +81 -82
  18. package/dist/functions/dash/index.js +20 -11
  19. package/dist/functions/div/index.d.ts +1 -1
  20. package/dist/functions/div/index.js +7 -7
  21. package/dist/functions/dot/index.js +4 -5
  22. package/dist/functions/dyn/index.js +28 -32
  23. package/dist/functions/grace/index.d.ts +19 -6
  24. package/dist/functions/grace/index.js +123 -115
  25. package/dist/functions/key/index.js +1 -1
  26. package/dist/functions/meter/index.js +14 -1
  27. package/dist/functions/note/index.d.ts +6 -1
  28. package/dist/functions/note/index.js +37 -14
  29. package/dist/functions/note/source-transform.d.ts +21 -0
  30. package/dist/functions/note/source-transform.js +164 -0
  31. package/dist/functions/page/index.d.ts +5 -0
  32. package/dist/functions/page/index.js +8 -5
  33. package/dist/functions/set/index.js +5 -1
  34. package/dist/functions/symbol/index.d.ts +2 -0
  35. package/dist/functions/symbol/index.js +1 -1
  36. package/dist/functions/symbol/ornament.d.ts +3 -3
  37. package/dist/functions/symbol/ornament.js +21 -35
  38. package/dist/functions/symbol/symbols/accent.js +5 -5
  39. package/dist/functions/symbol/symbols/fermata.js +5 -4
  40. package/dist/functions/tie/index.js +22 -32
  41. package/dist/functions/tuplet/index.js +19 -23
  42. package/dist/functions/up/index.js +9 -9
  43. package/dist/functions/voice/index.js +4 -3
  44. package/dist/functions/volta/index.js +7 -12
  45. package/dist/jpfun.core.min.js +40 -37
  46. package/dist/jpfun.from-midi.min.js +5 -5
  47. package/dist/jpfun.from-musicxml.min.js +8 -8
  48. package/dist/jpfun.min.js +49 -46
  49. package/dist/layout/engine.d.ts +11 -1
  50. package/dist/layout/engine.js +299 -96
  51. package/dist/layout/page.js +2 -0
  52. package/dist/layout/range.d.ts +26 -0
  53. package/dist/layout/range.js +75 -0
  54. package/dist/layout/types.d.ts +33 -4
  55. package/dist/lowering/types.d.ts +5 -0
  56. package/dist/parser/parse-utils/length-utils.js +2 -0
  57. package/dist/parser/parse-utils/note-utils.d.ts +2 -0
  58. package/dist/parser/parse-utils/note-utils.js +6 -2
  59. package/dist/parser/parserContext.js +1 -1
  60. package/dist/playback/compile.d.ts +2 -9
  61. package/dist/playback/compile.js +297 -186
  62. package/dist/playback/event.d.ts +8 -16
  63. package/dist/playback/event.js +13 -3
  64. package/dist/playback/types.d.ts +76 -18
  65. package/dist/playback/types.js +1 -0
  66. package/dist/render/index.d.ts +1 -1
  67. package/dist/render/index.js +1 -1
  68. package/dist/render/recording.d.ts +1 -0
  69. package/dist/render/recording.js +21 -0
  70. package/dist/render/translate.d.ts +14 -0
  71. package/dist/render/translate.js +48 -0
  72. package/grammar.md +13 -6
  73. package/package.json +4 -4
package/dist/jpfun.min.js CHANGED
@@ -1,83 +1,86 @@
1
1
  /*! jpfun | Apache-2.0 | github.com/madderscientist/jpFun */
2
- "use strict";(()=>{var Ir=Object.defineProperty;var Rr=(s,t)=>{for(var e in t)Ir(s,e,{get:t[e],enumerable:!0})};var ps={};Rr(ps,{ANCHOR_KEY:()=>ot,ASTBraceNode:()=>rt,ASTFunctionNode:()=>P,ASTLabelNode:()=>Lt,ASTNodeBase:()=>ft,ASTTextNode:()=>at,CanvasPainter:()=>bn,CanvasTextMeasurer:()=>Qn,DEFAULT_BPM:()=>$t,DEFAULT_FONT_SIZE:()=>ri,DEFAULT_KEY:()=>Ct,DEFAULT_OCTAVE:()=>ga,DEFAULT_PAGE_CONFIG:()=>xt,DEFAULT_PROGRAM:()=>ze,DEFAULT_TEXT_FONT:()=>ce,DEFAULT_TONALITY:()=>ye,DEFAULT_VELOCITY:()=>ee,DefaultTextMeasurer:()=>Xe,Diagnostic:()=>D,ErrorDiagnostic:()=>k,Fraction:()=>z,JIANPU_NUMBER_FONT:()=>Jn,LoweringContext:()=>Me,PageLayoutError:()=>oe,ParserContext:()=>wt,RecordingPainter:()=>Jo,SvgPainter:()=>gn,TemporalNodeBase:()=>Q,Track:()=>ke,WarningDiagnostic:()=>G,analyzeScoreSyntax:()=>rc,canvasFont:()=>Ze,compilePlayback:()=>hc,compileScore:()=>Ko,completeSpringConfig:()=>Ge,createLayoutPrepareContext:()=>Go,defaultFunctions:()=>dn,defaultTextMeasurer:()=>to,functionAddonKey:()=>Bt,isLayoutAttachment:()=>zt,isPlaybackRelation:()=>Xo,isVisualTemporalNode:()=>U,layoutDocument:()=>$n,layoutElement:()=>We,layoutHorizontal:()=>In,layoutHorizontalRegion:()=>ne,layoutPageBounds:()=>Kt,midiJsonToJpFun:()=>Oc,musicXmlToJpFun:()=>Vc,normalizePageConfig:()=>ge,paginateLayoutLines:()=>Rn,paintLayout:()=>Qo,performanceTimeToScoreTime:()=>er,performanceTimeToSeconds:()=>xn,prepareLayoutHost:()=>Nt,preprocessSource:()=>mn,primaryName:()=>xe,renderLayoutPagesToCanvas:()=>mc,renderLayoutPagesToSvg:()=>fc,resolveArgType:()=>te,scoreTimeToPerformanceTime:()=>nr,scoreTimeToSeconds:()=>cc,secondsToPerformanceTime:()=>tr,secondsToScoreTime:()=>ac,skipSpaces:()=>It,skipSpacesBack:()=>Te,unionLayoutBoxes:()=>be});var D=class s{code;message;span;constructor(t,e,n){this.code=t,this.message=e,this.span=n}toLineCol(t){let e=s.offsetToLineCol(this.span.start,t),n=s.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 i=0,r=n-1;for(;i<=r;){let l=i+r>>1;e[l]<=o?i=l+1:r=l-1}let a=Math.max(0,r),c=e[a]??0;return{line:a+1,column:o-c+1}}static error;static warning},k=class extends D{},G=class extends D{};D.error={Bug:(s,t)=>new k("E_BUG",`\u89E3\u6790\u5668\u9519\u8BEF: ${s}\uFF0C\u8BF7\u8054\u7CFB\u5F00\u53D1\u8005\u4FEE\u590D\u8FD9\u4E2A\u95EE\u9898`,t),MissingArg:(s,t,e)=>{let n=typeof t=="number"?`[${t}]`:`"${t}"`;return new k("E_MISSING_REQUIRED_ARG",`\u51FD\u6570@${s} \u7F3A\u5C11\u5FC5\u9700\u7684\u53C2\u6570 ${n}`,e)},InvalidArgType:(s,t,e,n,o)=>{let i=typeof t=="number"?`[${t}]`:`"${t}"`;return new k("E_WRONG_ARG_TYPE",`\u51FD\u6570 @${s} \u7684\u53C2\u6570 ${i} \u7C7B\u578B\u9519\u8BEF: \u5F97\u5230\u4E86 ${n}\uFF0C\u4F46\u671F\u671B ${e}`,o)},PosAfterNamedArg:(s,t)=>new k("E_POSARG_AFTER_KWARG",`\u51FD\u6570 @${s} \u7684\u4F4D\u7F6E\u53C2\u6570\u51FA\u73B0\u5728\u547D\u540D\u53C2\u6570\u4E4B\u540E\uFF0C\u8FD9\u662F\u4E0D\u5141\u8BB8\u7684`,t),EmptyContent:(s,t,e)=>{let n=typeof t=="number"?`[${t}]`:`"${t}"`;return new k("E_EMPTY_CONTENT",`\u51FD\u6570 @${s} \u7684\u53C2\u6570 ${n} \u5185\u5BB9\u4E3A\u7A7A(\u6216\u65E0\u53EF\u7528\u5185\u5BB9)\uFF1B\u8BF7\u63D0\u4F9B\u6709\u6548\u5185\u5BB9`,e)},UnterminatedCall:(s,t)=>new k("E_UNTERMINATED_CALL",`\u51FD\u6570\u8C03\u7528\u672A\u95ED\u5408: @${s}(...)`,t),UnterminatedString:s=>new k("E_UNTERMINATED_String","\u5F15\u53F7\u672A\u95ED\u5408",s),UnknownFunction:(s,t)=>new k("E_UNKNOWN_FUNCTION",`\u672A\u77E5\u51FD\u6570: @${s}\uFF0C\u8BF7\u68C0\u67E5\u62FC\u5199`,t),UnknownLabel:(s,t)=>new k("E_UNKNOWN_LABEL",`\u672A\u77E5\u6807\u7B7E: "${s}"`,t),InvalidTonality:(s,t)=>new k("E_INVALID_TONALITY",`\u65E0\u6548\u7684\u8C03\u6027: "${s}"\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:s=>new k("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",s),InvalidPageConfig:(s,t)=>new k("E_INVALID_PAGE_CONFIG",s,t),PageOverflow:(s,t,e)=>new k("E_PAGE_OVERFLOW",`\u8C31\u9762\u884C\u9700\u8981 ${s}px \u9AD8\u5EA6\uFF0C\u4F46\u9875\u9762\u5185\u5BB9\u533A\u53EA\u6709 ${t}px`,e)};D.warning={UnknownFunction:(s,t)=>new G("W_UNKNOWN_FUNCTION",`\u672A\u77E5\u51FD\u6570: @${s}\uFF0C\u5C06\u88AB\u5F53\u4F5C\u666E\u901A\u6587\u672C\u5904\u7406`,t),UnknownNamedArg:(s,t,e)=>new G("W_UNKNOWN_NAMED_ARG",`\u51FD\u6570 @${s} \u6536\u5230\u672A\u77E5\u7684\u547D\u540D\u53C2\u6570 "${t}"`,e),TooManyPosArgs:(s,t,e,n)=>new G("W_TOO_MANY_POS_ARGS",`\u51FD\u6570 @${s} \u63A5\u6536\u4E86\u8FC7\u591A\u7684\u4F4D\u7F6E\u53C2\u6570\uFF0C\u671F\u671B ${t} \u4E2A\u4F46\u5F97\u5230\u4E86 ${e} \u4E2A`,n),InvalidNumber:(s,t)=>new G("W_INVALID_NUMBER",`\u65E0\u6548\u7684\u6570\u5B57: "${s}"\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidBoolean:(s,t)=>new G("W_INVALID_BOOL",`\u65E0\u6548\u7684\u5E03\u5C14\u503C: "${s}": \u5E94\u4E3A 'true' \u6216 'false'\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidLength:(s,t)=>new G("W_INVALID_LENGTH",`\u65E0\u6548\u7684\u957F\u5EA6\u503C: "${s}"\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:(s,t)=>new G("W_INVALID_LENGTH_UNIT",`\u65E0\u6548\u7684\u957F\u5EA6\u5355\u4F4D: "${s}"\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:s=>new G("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)",s),EmptyContent:(s,t,e)=>new G("W_EMPTY_CONTENT",`\u51FD\u6570 @${s} \u7684\u53C2\u6570 "${t}" \u5185\u5BB9\u4E3A\u7A7A(\u6216\u65E0\u53EF\u7528\u5185\u5BB9)`,e),UnmatchedBrace:s=>new G("W_UNMATCHED_BRACE","\u672A\u5339\u914D\u7684\u5927\u62EC\u53F7: \u7F3A\u5C11\u53F3\u5927\u62EC\u53F7'}'\uFF1B\u5C06\u5C1D\u8BD5\u81EA\u52A8\u4FEE\u590D",s),LabelWithoutTarget:(s,t)=>new G("W_LABEL_WITHOUT_TARGET",`\u6807\u7B7E "${s}" \u6CA1\u6709\u53EF\u7ED1\u5B9A\u7684\u76EE\u6807\uFF1B\u6807\u7B7E\u5C06\u88AB\u5FFD\u7565`,t),TargetAlreadyLabeled:(s,t,e)=>new G("W_TARGET_ALREADY_LABELED",`\u76EE\u6807\u5DF2\u6807\u6CE8\u4E3A "${t}"\uFF0C"${s}" \u5C06\u88AB\u5FFD\u7565`,e),UnresolvedEndpoint:(s,t)=>new G("W_UNRESOLVED_ENDPOINT",`@${s} \u6709\u7AEF\u70B9\u627E\u4E0D\u5230\u5BF9\u5E94\u7684\u8C31\u9762\u5BF9\u8C61\uFF1B\u8BE5\u5173\u7CFB\u5C06\u88AB\u5FFD\u7565`,t),ZeroTimeTrack:(s,t)=>new G("W_ZERO_TIME_TRACK",`\u7B2C${t}\u4E2A\u5B50\u8F68\u9053\u7684\u65F6\u957F\u4E3A0`,s)};function Bt(s){return`@${s}`}var ft=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)}},at=class extends ft{},Lt=class extends ft{label;target;constructor(t,e,n,o=null){super(t,o),this.label=e,this.target=n}toString(t){return`@${this.label} `}},rt=class s extends ft{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 s.getContentSpan(this.content)}static getContentSpan(t){if(Array.isArray(t)){if(t.length===0)return{start:0,end:0};let e=s.getContentSpan(t[0]),n=s.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 te(s,t,e){return t?s.args.find(n=>n.name?.toLowerCase()===t)?.type:s.args[e]?.type??(s.allowExtraArgs?s.extraArgType:void 0)}function xe(s){return Array.isArray(s.name)?s.name[0]:s.name}var P=class s extends ft{label;static def;get def(){return this.constructor.def}get callName(){return this.def?xe(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,i=xe(n);return o.map((r,a)=>{let c=r.name?r.name.toLowerCase():null,l=(c?t.get(c):null)??t.get(a)??(c?e.variables[`${i}.${c}`.toLowerCase()]:null)??r.default;if(l===null)throw D.error.MissingArg(i,r.name||a,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=s.findLabelable(n);if(o)return o}return null}static findLastFuncContentNode(t,e){for(;e>=0;e--){let n=t[e];if(n instanceof at)return null;if(n instanceof s||n instanceof rt)return n}return null}};function $r(s,t){for(;t!==0;){let e=s%t;s=t,t=e}return s}var z=class s{_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=$r(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 s(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 s?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 $t=120,ee=80,ye="C4",ze=0,ot=-1/0,Ct=1/0,Q=class{t=new z;T=new z;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 U(s){return s.box!==void 0}function zt(s){return typeof s.createGeometry=="function"}var Mn=class extends P{static def={name:["adjust","adj"],description:"\u5FAE\u8C03\u76EE\u6807\u7684\u7ED8\u5236\u4F4D\u7F6E\u4E0E\u6392\u7248\u5360\u4F4D",details:`~~~jpfun
2
+ "use strict";(()=>{var pa=Object.defineProperty;var ua=(s,t)=>{for(var e in t)pa(s,e,{get:t[e],enumerable:!0})};var Is={};ua(Is,{ANCHOR_KEY:()=>ct,ASTBraceNode:()=>ut,ASTFunctionNode:()=>O,ASTLabelNode:()=>Bt,ASTNodeBase:()=>Et,ASTTextNode:()=>xt,CanvasPainter:()=>Dn,CanvasTextMeasurer:()=>wo,DEFAULT_BPM:()=>jt,DEFAULT_FONT_SIZE:()=>Ri,DEFAULT_KEY:()=>zt,DEFAULT_OCTAVE:()=>Qa,DEFAULT_PAGE_CONFIG:()=>St,DEFAULT_PROGRAM:()=>on,DEFAULT_TEXT_FONT:()=>ve,DEFAULT_TONALITY:()=>Oe,DEFAULT_VELOCITY:()=>ge,DefaultTextMeasurer:()=>hn,Diagnostic:()=>D,ErrorDiagnostic:()=>k,Fraction:()=>F,JIANPU_NUMBER_FONT:()=>So,LoweringContext:()=>Ye,PageLayoutError:()=>Se,ParserContext:()=>Rt,RecordingPainter:()=>ys,SvgPainter:()=>Pn,TemporalNodeBase:()=>tt,Track:()=>ne,WarningDiagnostic:()=>U,analyzeScoreSyntax:()=>Uc,canvasFont:()=>dn,compilePlayback:()=>Kc,compileScore:()=>hs,completeSpringConfig:()=>rn,createLayoutPrepareContext:()=>ls,defaultFunctions:()=>$n,defaultTextMeasurer:()=>Ao,functionAddonKey:()=>Jt,isLayoutAttachment:()=>te,isPlaybackRelation:()=>ds,isVisualTemporalNode:()=>Q,layoutDocument:()=>to,layoutElement:()=>an,layoutHorizontal:()=>Kn,layoutHorizontalRegion:()=>we,layoutLocalSequence:()=>Ae,layoutPageBounds:()=>pe,midiJsonToJpFun:()=>bl,musicXmlToJpFun:()=>$l,normalizePageConfig:()=>Pe,paginateLayoutLines:()=>Xn,paintLayout:()=>xs,paintLayoutPages:()=>_e,performanceTimeToScoreTime:()=>kr,performanceTimeToSeconds:()=>On,prepareHorizontalLine:()=>eo,prepareLayoutHost:()=>Fe,preprocessSource:()=>Me,primaryName:()=>$e,renderLayoutPagesToCanvas:()=>Jc,renderLayoutPagesToSvg:()=>Zc,resolveArgType:()=>ye,scoreTimeToPerformanceTime:()=>_r,scoreTimeToSeconds:()=>jc,secondsToPerformanceTime:()=>Nr,secondsToScoreTime:()=>Vc,skipSpaces:()=>Ut,skipSpacesBack:()=>Ge,transformNotes:()=>qi,unionLayoutBoxes:()=>cn});var D=class s{code;message;span;constructor(t,e,n){this.code=t,this.message=e,this.span=n}toLineCol(t){let e=s.offsetToLineCol(this.span.start,t),n=s.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 i=0,r=n-1;for(;i<=r;){let l=i+r>>1;e[l]<=o?i=l+1:r=l-1}let a=Math.max(0,r),c=e[a]??0;return{line:a+1,column:o-c+1}}static error;static warning},k=class extends D{},U=class extends D{};D.error={Bug:(s,t)=>new k("E_BUG",`\u89E3\u6790\u5668\u9519\u8BEF: ${s}\uFF0C\u8BF7\u8054\u7CFB\u5F00\u53D1\u8005\u4FEE\u590D\u8FD9\u4E2A\u95EE\u9898`,t),MissingArg:(s,t,e)=>{let n=typeof t=="number"?`[${t}]`:`"${t}"`;return new k("E_MISSING_REQUIRED_ARG",`\u51FD\u6570@${s} \u7F3A\u5C11\u5FC5\u9700\u7684\u53C2\u6570 ${n}`,e)},InvalidArgType:(s,t,e,n,o)=>{let i=typeof t=="number"?`[${t}]`:`"${t}"`;return new k("E_WRONG_ARG_TYPE",`\u51FD\u6570 @${s} \u7684\u53C2\u6570 ${i} \u7C7B\u578B\u9519\u8BEF: \u5F97\u5230\u4E86 ${n}\uFF0C\u4F46\u671F\u671B ${e}`,o)},PosAfterNamedArg:(s,t)=>new k("E_POSARG_AFTER_KWARG",`\u51FD\u6570 @${s} \u7684\u4F4D\u7F6E\u53C2\u6570\u51FA\u73B0\u5728\u547D\u540D\u53C2\u6570\u4E4B\u540E\uFF0C\u8FD9\u662F\u4E0D\u5141\u8BB8\u7684`,t),EmptyContent:(s,t,e)=>{let n=typeof t=="number"?`[${t}]`:`"${t}"`;return new k("E_EMPTY_CONTENT",`\u51FD\u6570 @${s} \u7684\u53C2\u6570 ${n} \u5185\u5BB9\u4E3A\u7A7A(\u6216\u65E0\u53EF\u7528\u5185\u5BB9)\uFF1B\u8BF7\u63D0\u4F9B\u6709\u6548\u5185\u5BB9`,e)},UnterminatedCall:(s,t)=>new k("E_UNTERMINATED_CALL",`\u51FD\u6570\u8C03\u7528\u672A\u95ED\u5408: @${s}(...)`,t),UnterminatedString:s=>new k("E_UNTERMINATED_String","\u5F15\u53F7\u672A\u95ED\u5408",s),UnknownFunction:(s,t)=>new k("E_UNKNOWN_FUNCTION",`\u672A\u77E5\u51FD\u6570: @${s}\uFF0C\u8BF7\u68C0\u67E5\u62FC\u5199`,t),UnknownLabel:(s,t)=>new k("E_UNKNOWN_LABEL",`\u672A\u77E5\u6807\u7B7E: "${s}"`,t),InvalidTonality:(s,t)=>new k("E_INVALID_TONALITY",`\u65E0\u6548\u7684\u8C03\u6027: "${s}"\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:s=>new k("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",s),InvalidPageConfig:(s,t)=>new k("E_INVALID_PAGE_CONFIG",s,t),PageOverflow:(s,t,e)=>new k("E_PAGE_OVERFLOW",`\u8C31\u9762\u884C\u9700\u8981 ${s}px \u9AD8\u5EA6\uFF0C\u4F46\u9875\u9762\u5185\u5BB9\u533A\u53EA\u6709 ${t}px`,e)};D.warning={UnknownFunction:(s,t)=>new U("W_UNKNOWN_FUNCTION",`\u672A\u77E5\u51FD\u6570: @${s}\uFF0C\u5C06\u88AB\u5F53\u4F5C\u666E\u901A\u6587\u672C\u5904\u7406`,t),UnknownNamedArg:(s,t,e)=>new U("W_UNKNOWN_NAMED_ARG",`\u51FD\u6570 @${s} \u6536\u5230\u672A\u77E5\u7684\u547D\u540D\u53C2\u6570 "${t}"`,e),TooManyPosArgs:(s,t,e,n)=>new U("W_TOO_MANY_POS_ARGS",`\u51FD\u6570 @${s} \u63A5\u6536\u4E86\u8FC7\u591A\u7684\u4F4D\u7F6E\u53C2\u6570\uFF0C\u671F\u671B ${t} \u4E2A\u4F46\u5F97\u5230\u4E86 ${e} \u4E2A`,n),InvalidNumber:(s,t)=>new U("W_INVALID_NUMBER",`\u65E0\u6548\u7684\u6570\u5B57: "${s}"\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidBoolean:(s,t)=>new U("W_INVALID_BOOL",`\u65E0\u6548\u7684\u5E03\u5C14\u503C: "${s}": \u5E94\u4E3A 'true' \u6216 'false'\uFF1B\u5C06\u4F7F\u7528\u9ED8\u8BA4\u503C(\u82E5\u5B58\u5728)`,t),InvalidLength:(s,t)=>new U("W_INVALID_LENGTH",`\u65E0\u6548\u7684\u957F\u5EA6\u503C: "${s}"\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:(s,t)=>new U("W_INVALID_LENGTH_UNIT",`\u65E0\u6548\u7684\u957F\u5EA6\u5355\u4F4D: "${s}"\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:s=>new U("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)",s),EmptyContent:(s,t,e)=>new U("W_EMPTY_CONTENT",`\u51FD\u6570 @${s} \u7684\u53C2\u6570 "${t}" \u5185\u5BB9\u4E3A\u7A7A(\u6216\u65E0\u53EF\u7528\u5185\u5BB9)`,e),UnmatchedBrace:s=>new U("W_UNMATCHED_BRACE","\u672A\u5339\u914D\u7684\u5927\u62EC\u53F7: \u7F3A\u5C11\u53F3\u5927\u62EC\u53F7'}'\uFF1B\u5C06\u5C1D\u8BD5\u81EA\u52A8\u4FEE\u590D",s),LabelWithoutTarget:(s,t)=>new U("W_LABEL_WITHOUT_TARGET",`\u6807\u7B7E "${s}" \u6CA1\u6709\u53EF\u7ED1\u5B9A\u7684\u76EE\u6807\uFF1B\u6807\u7B7E\u5C06\u88AB\u5FFD\u7565`,t),TargetAlreadyLabeled:(s,t,e)=>new U("W_TARGET_ALREADY_LABELED",`\u76EE\u6807\u5DF2\u6807\u6CE8\u4E3A "${t}"\uFF0C"${s}" \u5C06\u88AB\u5FFD\u7565`,e),UnresolvedEndpoint:(s,t)=>new U("W_UNRESOLVED_ENDPOINT",`@${s} \u6709\u7AEF\u70B9\u627E\u4E0D\u5230\u5BF9\u5E94\u7684\u8C31\u9762\u5BF9\u8C61\uFF1B\u8BE5\u5173\u7CFB\u5C06\u88AB\u5FFD\u7565`,t),ZeroTimeTrack:(s,t)=>new U("W_ZERO_TIME_TRACK",`\u7B2C${t}\u4E2A\u5B50\u8F68\u9053\u7684\u65F6\u957F\u4E3A0`,s)};function Jt(s){return`@${s}`}var Et=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)}},xt=class extends Et{},Bt=class extends Et{label;target;constructor(t,e,n,o=null){super(t,o),this.label=e,this.target=n}toString(t){return`@${this.label} `}},ut=class s extends Et{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 s.getContentSpan(this.content)}static getContentSpan(t){if(Array.isArray(t)){if(t.length===0)return{start:0,end:0};let e=s.getContentSpan(t[0]),n=s.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 ye(s,t,e){return t?s.args.find(n=>n.name?.toLowerCase()===t)?.type:s.args[e]?.type??(s.allowExtraArgs?s.extraArgType:void 0)}function $e(s){return Array.isArray(s.name)?s.name[0]:s.name}var O=class s extends Et{label;static def;get def(){return this.constructor.def}get callName(){return this.def?$e(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,i=$e(n);return o.map((r,a)=>{let c=r.name?r.name.toLowerCase():null,l=(c?t.get(c):null)??t.get(a)??(c?e.variables[`${i}.${c}`.toLowerCase()]:null)??r.default;if(l===null)throw D.error.MissingArg(i,r.name||a,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=s.findLabelable(n);if(o)return o}return null}static findLastFuncContentIndex(t,e){for(;e>=0;e--)if(t[e]instanceof s||t[e]instanceof ut)return e;return-1}};function ha(s,t){for(;t!==0;){let e=s%t;s=t,t=e}return s}var F=class s{_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(!Number.isFinite(t)||!Number.isFinite(e))throw new RangeError("Fraction numerator and denominator must be finite");if(e===0)throw new RangeError("Denominator must not be zero");e<0&&(t=-t,e=-e);let n=ha(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 s(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--;let e=this._denominator*2**t;if(!Number.isFinite(e))throw new RangeError("Fraction denominator overflow");return this._denominator=e,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 s?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 jt=120,ge=80,Oe="C4",on=0,ct=-1/0,zt=1/0,tt=class{t=new F;T=new F;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 Q(s){return s.box!==void 0}function te(s){return typeof s.createGeometry=="function"}var be=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,i){this.target.drawLine(t+this.dx,e+this.dy,n+this.dx,o+this.dy,i)}drawRect(t,e,n,o,i){this.target.drawRect(t+this.dx,e+this.dy,n,o,i)}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 jn=class extends O{static def={name:["adjust","adj"],description:"\u5FAE\u8C03\u76EE\u6807\u7684\u7ED8\u5236\u4F4D\u7F6E\u4E0E\u6392\u7248\u5360\u4F4D",details:`~~~jpfun
3
3
  @adjust(1, dx=2px, dy=-1px, dw=0.2em, dh=0px)
4
4
  ~~~
5
5
 
6
- \u4F4D\u7F6E\u504F\u79FB\u5728\u6392\u7248\u540E\u5E94\u7528\uFF0C\u76F8\u90BB\u5BF9\u8C61\u4FDD\u6301\u539F\u4F4D\uFF1B\u5360\u4F4D\u8C03\u6574\u5728\u6392\u7248\u524D\u5E94\u7528\u3002\u53EA\u5305\u88F9\u5173\u7CFB\u5BF9\u8C61\u65F6\uFF0C\u5E73\u79FB\u4F5C\u7528\u4E8E\u8BE5\u5173\u7CFB\u5BF9\u8C61\u672C\u8EAB\u3002`,allowExtraArgs:!1,args:[{type:"content",description:"\u8981\u5FAE\u8C03\u7684\u5185\u5BB9\u6216\u5173\u7CFB\u5BF9\u8C61",default:null},{name:"dx",description:"\u6392\u7248\u540E\u7684\u6C34\u5E73\u504F\u79FB\uFF0C\u6B63\u503C\u5411\u53F3\uFF0C\u4E0D\u6539\u53D8\u5360\u4F4D",type:"length",default:{value:0,unit:"px"}},{name:"dy",description:"\u6392\u7248\u540E\u7684\u5782\u76F4\u504F\u79FB\uFF0C\u6B63\u503C\u5411\u4E0B\uFF0C\u4E0D\u6539\u53D8\u5360\u4F4D",type:"length",default:{value:0,unit:"px"}},{name:"dw",description:"\u589E\u51CF\u6C34\u5E73\u5360\u4F4D\uFF0C\u6309\u539F\u5DE6\u53F3\u6BD4\u4F8B\u5206\u914D\uFF0C\u6700\u7EC8\u5BBD\u5EA6\u4E0D\u5C0F\u4E8E 0",type:"length",default:{value:0,unit:"px"}},{name:"dh",description:"\u589E\u51CF\u4E0B\u65B9\u5360\u4F4D\uFF0C\u6700\u7EC8\u9AD8\u5EA6\u4E0D\u5C0F\u4E8E 0",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=>{U(o)&&(e.temporal++,Or(o,this))},onAttachment:o=>{zt(o)&&(e.attachment++,Pr(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 G("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[i,r,a,c,l]=this.getArgValue(e,n);i.parent=this,this.target=i,this.dx=n.length2px(r),this.dy=n.length2px(a),this.dw=n.length2px(c),this.dh=n.length2px(l)}},Ss=Mn;function Or(s,t){let{dx:e,dy:n,dw:o,dh:i}=t;if(e===0&&n===0&&o===0&&i===0)return;let r,a,c=s.finalizeLayout,l=s.onPlaced;s.finalizeLayout=h=>{c?.call(s,h);let p=Math.max(0,s.box.w+o);s.box.anchor=s.box.w>0?s.box.anchor*p/s.box.w:0,s.box.w=p,s.box.h=Math.max(0,s.box.h+i)},s.onPlaced=()=>{s.box.x!==r&&(s.box.x+=e),s.box.y!==a&&(s.box.y+=n),l?.call(s),r=s.box.x,a=s.box.y}}function Pr(s,t,e,n){if(e===0&&n===0)return;let o=s.createGeometry;s.createGeometry=i=>{let r=o.call(s,i);if(t.temporal>0)return r;let a=c=>c.line===void 0?{x:c.x+e,y:c.y+n,w:c.w,h:c.h}:{x:c.x+e,y:c.y+n,w:c.w,h:c.h,line:c.line,track:c.track};return{regions:r.regions.map(a),occupancy:r.occupancy?.map(a),paint(c){r.paint(new Nn(c,e,n))}}}}var Nn=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,i){this.target.drawLine(t+this.dx,e+this.dy,n+this.dx,o+this.dy,i)}drawRect(t,e,n,o,i){this.target.drawRect(t+this.dx,e+this.dy,n,o,i)}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 He=1,Dr=6,Fr=16,_n=32,As=1e-6,Br=.01;function Ge(s,t=He){let e=s.alpha_L??s.alpha_R??Dr;s.alpha_L??=e,s.alpha_R??=e;let n=s.mu_L??s.mu_R??Fr;s.mu_L??=n,s.mu_R??=n,s.beta_L??=t/Math.max(s.alpha_L,As),s.beta_R??=t/Math.max(s.alpha_R,As)}function We(s,t,e,n=He){Ge(s,n);let o=Math.pow(Math.max(e.T.toNumber(),Br),.5);return{config:s,box:t,time:e,duration_L:o,duration_R:o,WL:t.anchor,WR:t.w-t.anchor,margin_L:o*s.alpha_L,margin_R:o*s.alpha_R}}function zr(s,t=He){let e=new Map,n=0;for(let i of s)for(let r of i)e.has(r.time.track)||e.set(r.time.track,n++);let o=[];for(let i of s){if(i.length===0)continue;let r=Array(i.length);o.push(r);let a=0,c=0,l=n;for(let p of i){p.WL>a&&(a=p.WL),p.WR>c&&(c=p.WR);let u=e.get(p.time.track);if(r[u]){let m=r[u];p.time.T.compare(m.time.T)>0?(r[u]=p,r[l++]=m):r[l++]=p}else r[u]=p}let h=i[0].time.t;for(let p of e){let u=p[1];if(!r[u]){let m=We({anchor:0,alpha_L:a,alpha_R:c},{x:0,w:0,anchor:0},{t:h,T:new z(1),track:p[0]},t);m.fake=!0,r[u]=m}}}return{mat:o,rows:n}}function Hr(s,t,e,n){let o=n-e-s.WR-t.WL,i=s.margin_R+t.margin_L;if(o>=i)return{force:0,stiffness:0};let r=s.config.beta_R/s.duration_R,a=t.config.beta_L/t.duration_L,c=r*a/(r+a),l,h;if(o<0){let p=s.config.mu_R*t.config.mu_L/(s.config.mu_R+t.config.mu_L);l=c*i-p*o,h=p}else{let p=i-o;l=c*p,h=c}return{force:l,stiffness:h}}function Gr(s,t,e=_n){let n=t-s.WL,o=s.margin_L;if(n>=o)return{force:0,stiffness:0};let i=s.config.beta_L/s.duration_L;if(n>=0)return{force:i*(o-n),stiffness:i};let r=s.config.mu_L*e;return{force:s.config.alpha_L*s.config.beta_L-r*n,stiffness:r}}function Wr(s,t,e,n=_n){let o=e-(t+s.WR),i=s.margin_R;if(o>=i)return{force:0,stiffness:0};let r=s.config.beta_R/s.duration_R;if(o>=0)return{force:r*(i-o),stiffness:r};let a=s.config.mu_R*n;return{force:s.config.alpha_R*s.config.beta_R-a*o,stiffness:a}}function Vr(s){return{damping:s.damping??.6,maxIter:s.maxIter??100,eps:s.eps??.01,crossPunish:s.crossPunish??_n,globalC:s.globalC??He}}function jr(s,t,e,n,o){let{damping:i,maxIter:r,eps:a,crossPunish:c}=o,l=s.length,h=new Float64Array(t);for(let S=0;S<l;S++){let L=0,A=s[S];for(let C=0;C<t;C++){let I=h[C]+A[C].WL+A[C].margin_L;I>L&&(L=I)}for(let C=0;C<t;C++)h[C]=L+A[C].WR+A[C].margin_R;e[S]=L}let p=h.reduce((S,L)=>Math.max(S,L),0);if(p<=n)return!0;p=n/p;for(let S=0;S<l;S++)e[S]*=p;let u=new Float64Array(l),m=new Float32Array(t*(l+1));function f(S){u.fill(0);for(let L=0;L<t;L++){let A=L*(l+1),C=s[0][L],I=Gr(C,S[0],c);u[0]+=I.force,m[A]=I.stiffness;for(let Y=1;Y<l;Y++){let tt=s[Y-1][L],V=s[Y][L],q=Hr(tt,V,S[Y-1],S[Y]);u[Y-1]-=q.force,u[Y]+=q.force,m[A+Y]=q.stiffness}let O=s[l-1][L],H=Wr(O,S[l-1],n,c);u[l-1]-=H.force,m[A+l]=H.stiffness}return u}let y=new Float64Array(l);function g(S){y.fill(0);for(let A=0,C=0;A<t;A++,C+=l+1){y[0]+=m[C]*S[0];for(let I=1;I<l;I++){let O=m[C+I]*(S[I]-S[I-1]);y[I-1]-=O,y[I]+=O}y[l-1]+=m[C+l]*S[l-1]}let L=1e-4;for(let A=0;A<S.length;A++)y[A]+=L*S[A];return y}function d(S,L){let A=0;for(let C=0;C<S.length;C++)A+=S[C]*L[C];return A}let x=new Float64Array(l),b=new Float64Array(l),w=new Float64Array(l);function N(S,L=8){x.fill(0),b.set(S),w.set(b);let A=d(b,b);if(A<1e-12)return x;for(let C=0;C<L;C++){let I=g(w),O=d(w,I);if(Math.abs(O)<1e-12)break;let H=A/O;for(let V=0;V<l;V++)x[V]+=H*w[V],b[V]-=H*I[V];let Y=d(b,b);if(Math.sqrt(Y)<1e-6)break;let tt=Y/A;for(let V=0;V<l;V++)w[V]=b[V]+tt*w[V];A=Y}return x}let _=0,M=0;for(;_<r;_++){let S=f(e);M=0;for(let A=0;A<S.length;A++){let C=Math.abs(S[A]);C>M&&(M=C)}if(M<a)break;let L=N(S);for(let A=0;A<l;A++)e[A]+=i*L[A]}return!1}function ne(s,t,e,n,o,i,r){if(e.length!==s.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 a=n.some(m=>m!==0),c,l,h=s,p=e;if(a){c=new Uint32Array(e.length),l=new Float64Array(e.length),h=[];for(let m=0;m<e.length;){let f=m;for(;f<n.length&&n[f];)f++;let y=h.length;for(let g=m;g<=f;g++)c[g]=y,l[g]=e[g]-e[m];if(m===f)h.push(s[m]);else{let g=e[f]-e[m];h.push(Array.from({length:t},(d,x)=>{let b=s[m][x],w=s[f][x];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:g+w.WR,margin_L:b.margin_L,margin_R:w.margin_R,fake:b.fake&&w.fake}}))}m=f+1}p=new Float64Array(h.length)}let u=jr(h,t,p,o,i);if(n.fill(1),r!==void 0){let m=0,f=0;for(let g=0;g<t;g++)m=Math.max(m,h[0][g].WL),f=Math.max(f,h[h.length-1][g].WR);let y=p[p.length-1]+f-p[0]+m;if(!u||y>=o*r){let g=m-p[0],d=o-y;for(let x=0;x<p.length;x++)p[x]+=g+(p.length>1?d*x/(p.length-1):0)}}if(a)for(let m=0;m<e.length;m++)e[m]=p[c[m]]+l[m]}function In(s,t,e={},n=[],o){let i=Vr(e),{mat:r,rows:a}=zr(s,i.globalC),c=new Float64Array(r.length),l=new Uint8Array(Math.max(0,r.length-1)),h=n.length>1?[...n].sort((p,u)=>p.end-p.start-(u.end-u.start)):n;for(let{start:p,end:u,hook:m}of h){if(p<0||u<p||u>=r.length)throw new Error("Horizontal layout registration references invalid columns");m({columns:r,rows:a,start:p,end:u,X:c,fixed:l,options:i})}ne(r,a,c,l,t,i,o);for(let p=0;p<r.length;p++)for(let u of r[p])u.box.x=c[p]-u.box.anchor;return r}var oe=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}},xt={width:794,height:1/0,marginTop:45,marginBottom:48,marginLeft:40,marginRight:40,lineGap:22};function ge(s={}){let t=s.height??xt.height,e={width:s.width??xt.width,height:t<=0?1/0:t,marginTop:Math.max(0,s.marginTop??xt.marginTop),marginBottom:Math.max(0,s.marginBottom??xt.marginBottom),marginLeft:Math.max(0,s.marginLeft??xt.marginLeft),marginRight:Math.max(0,s.marginRight??xt.marginRight),lineGap:Math.max(0,s.lineGap??xt.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(r=>!Number.isFinite(r)||r<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 i=e.height-e.marginTop-e.marginBottom;if(Number.isFinite(e.height)&&i<=0)throw new Error(`Page vertical margins leave no content height: ${i}px`);return e}function Rn(s,t){let e=t.height-t.marginTop-t.marginBottom,n=[],o=new Array(s.length).fill(0),i=0,r=0,a=0,c=0,l=(h,p)=>{let u=h-r,m=p?Math.max(0,e-c-t.lineGap*(u-1)):0,f=t.lineGap+m/u,y=i+t.marginTop;for(let d=r;d<h;d++)o[d]=y,y+=s[d]+(d+1<h?f:0);let g=Number.isFinite(t.height)?t.height:y-i+t.marginBottom;n.push({bounds:{x:0,y:i,w:t.width,h:g},lineStart:r,lineEnd:h}),i+=g,r=h,a=0,c=0};for(let h=0;h<s.length;h++){let p=s[h];if(Number.isFinite(t.height)&&p>e+1e-6)throw new oe(h,p,e);Number.isFinite(t.height)&&h>r&&a+t.lineGap+p>e+1e-6&&l(h,!0),a+=(h>r?t.lineGap:0)+p,c+=p}return s.length>r&&l(s.length,!1),{pages:n,lineTops:o}}function be(s,t){let e=1/0,n=1/0,o=-1/0,i=-1/0;for(let r of t)e=Math.min(e,r.x),n=Math.min(n,r.y),o=Math.max(o,r.x+r.w),i=Math.max(i,r.y+r.h);return Number.isFinite(e)?(s.x=e,s.y=n,s.w=o-e,s.h=i-n,!0):(s.x=s.y=s.w=s.h=0,!1)}function Nt(s,t){s.springConfig??={},s.decorations=[],s.ports={},s.box.x=s.box.y=0,s.prepareLayout(t);for(let[e,n]of Object.entries(s.addon??{})){let o=t.decorationHandlers.get(e);if(!o)continue;let i=o(s,n,t);i&&s.decorations.push(i)}Ur(s),s.finalizeLayout?.(t)}function $n(s,t,e={}){let n=s.attachments.filter(zt),o=ge(s.page),i=o.width-o.marginLeft-o.marginRight,r=o.marginLeft,a=Yr(s),c=[];for(let x of a)for(let b of x.columns)for(let w of b)c.push(w),Nt(w,t);let l=Kr(a,e.globalC);for(let x of c)x.prepareHorizontal?.(l[x.layoutLine]);for(let x of n)x.prepareHorizontal?.(l,t);for(let x=0;x<a.length;x++){let b=a[x],w=b.columns.map(N=>N.map(_=>We(_.springConfig,_.box,_,e.globalC)));In(w,i,e,b.horizontalLayoutHooks,.5);for(let N of b.columns)for(let _ of N)_.box.x+=r}for(let x of c){let b=a[x.layoutLine],w=-x.box.visualAxis;je(b.hostExtents,x.track,w,w+x.box.h)}let h=Xr(a.length,c,e.rowGap),p=()=>{let x=[],b=a.map((S,L)=>{let A=Zr(S,s.rootTrack,h[L]);return x.push(A.height),A.axes}),w,N;try{({pages:w,lineTops:N}=Rn(x,o))}catch(S){if(!(S instanceof oe))throw S;let L=a[S.line],A=1/0,C=-1/0;for(let I of L?.columns??[])for(let O of I)A=Math.min(A,O.ast.sourceSpan.start),C=Math.max(C,O.ast.sourceSpan.end);throw Number.isFinite(A)?D.error.PageOverflow(S.requiredHeight,S.availableHeight,{start:A,end:C}):S}let _=(S,L)=>(N[S]??0)+(b[S]?.get(L)??0);for(let S of c)S.box.y=_(S.layoutLine,S.track)-S.box.visualAxis,S.onPlaced?.();let M={...t,width:i,originX:r,pages:w.map(S=>S.bounds),lines:l,getVisualAxis:_,getHostExtent:(S,L)=>a[S]?.hostExtents.get(L)};return{pages:w,attachmentContext:M}},u=p(),m=Ts(n,u.attachmentContext,a);m.needsRelayout&&(u=p(),m=Ts(n,u.attachmentContext,a));let f=u.pages,y=n.map((x,b)=>{let{geometry:w,box:N}=m.items[b];return{box:N,regions:w.regions,layer:x.layer,sourceSpan:x.sourceSpan,paint(_){w.paint(_)}}}),g={x:0,y:0,w:0,h:0};function*d(){for(let x of f)yield x.bounds;for(let x of c)yield x.box;for(let x of y)yield x.box}return be(g,d()),{diagnostics:s.diagnostics,objects:c,attachments:y,bounds:g,lineCount:a.length,pages:f}}function Ur(s){let t=s.decorations.map(n=>n.below).filter(n=>n!==void 0).sort((n,o)=>n.order-o.order);if(t.length===0)return;let e=s.box.h;for(let n of t)e+=n.gap??0,n.place?.(e),e+=Math.max(0,n.height??0);s.box.h=e}function Yr(s){let t=()=>({columns:[],horizontalLayoutHooks:[],hostExtents:new Map,attachmentExtents:new Map,attachmentRanges:[]}),e=[],n=t();for(let o of s.columns){let i=[];for(;e.length<o[0].layoutLine;)e.push(n),n=t();for(let r of o)U(r)&&i.push(r);i.length&&n.columns.push(i)}return(n.columns.length>0||e.length===0)&&e.push(n),e}function Ve(s,t,e){s.top=Math.min(s.top,t),s.bottom=Math.max(s.bottom,e)}function je(s,t,e,n){let o=s.get(t);o?Ve(o,e,n):s.set(t,{top:e,bottom:n})}function Kr(s,t){return s.map((e,n)=>{let o=new Map,i=new Map;for(let r=0;r<e.columns.length;r++)for(let a of e.columns[r]){o.set(a,r),Ge(a.springConfig,t);let c=i.get(a.track);c?c.push(a):i.set(a.track,[a])}return{index:n,columns:e.columns,trackRuns:i,columnOf:r=>o.get(r)??-1,registerHorizontalLayoutHook(r,a,c){let l=o.get(r),h=o.get(a);l===void 0||h===void 0||e.horizontalLayoutHooks.push({start:Math.min(l,h),end:Math.max(l,h),hook:c})}}})}function Xr(s,t,e){if(e!==void 0)return new Array(s).fill(e);let n=new Array(s).fill(0),o=0;for(let i of t){let r=i.ast.size*.75;r>n[i.layoutLine]&&(n[i.layoutLine]=r),r>o&&(o=r)}for(let i=0;i<s;i++)n[i]||=o;return n}function Ts(s,t,e){let n=new Map,o=!1;for(let a of e)a.attachmentRanges.length=0;let i={...t,getAttachmentBox(a){let c=n.get(a);if(!c)throw new Error("Layout attachment dependency has not been measured");return c.box},getRangeExtents(a,c){let l=e[a],h=new Map;if(!l)return h;let p=c===void 0;if(c&&c[0]>c[1])return h;let u=p?0:Math.max(0,c[0]),m=p?l.columns.length-1:Math.min(c[1],l.columns.length-1);if(!p&&u>m)return h;let f=p?t.originX:1/0,y=p?t.originX+t.width:-1/0;for(let g=u;g<=m;g++)for(let d of l.columns[g]){p||(d.box.x<f&&(f=d.box.x),d.box.x+d.box.w>y&&(y=d.box.x+d.box.w));let x=d.box.y-t.getVisualAxis(a,d.track),b=x+d.box.h;je(h,d.track,x,b)}for(let g of l.attachmentRanges)g.right<=f||g.left>=y||je(h,g.track,g.top,g.bottom);return h}};return{items:s.map(a=>{let c=a.createGeometry(i),l={x:0,y:0,w:0,h:0};be(l,c.regions);let h={geometry:c,box:l};n.set(a,h);for(let p of c.occupancy??c.regions){if(p.line===void 0)continue;let u=e[p.line],m=p.y-t.getVisualAxis(p.line,p.track),f=m+p.h,y=u.hostExtents.get(p.track),g=u.attachmentExtents.get(p.track);(m<Math.min(y?.top??1/0,g?.top??1/0)||f>Math.max(y?.bottom??-1/0,g?.bottom??-1/0))&&(o=!0),je(u.attachmentExtents,p.track,m,f),u.attachmentRanges.push({track:p.track,left:p.x,right:p.x+p.w,top:m,bottom:f})}return h}),needsRelayout:o}}function Zr(s,t,e){let n=new Map,o=c=>{let l=s.hostExtents.get(c),h=s.attachmentExtents.get(c),p=l?{top:l.top,bottom:l.bottom}:null;h&&(p?Ve(p,h.top,h.bottom):p={top:h.top,bottom:h.bottom});let u=[];for(let f of c.groups){let y=f.members.map(o);if(y.every(x=>x===null))continue;let g=f.measure(y,e),d=null;for(let x of g){if(!x)continue;let b=x.offset+x.extent.top,w=x.offset+x.extent.bottom;d?Ve(d,b,w):d={top:b,bottom:w}}d&&u.push({group:f,placements:g,extent:d})}let m=(f,y)=>{p??={top:0,bottom:0};for(let g=0;g<f.group.members.length;g++){let d=f.placements[g];d&&n.set(f.group.members[g],y+d.offset)}Ve(p,y+f.extent.top,y+f.extent.bottom)};for(let f of u)f.group.place||m(f,0);for(let f of u){let y=f.group.place;if(!y)continue;m(f,y(p??{top:0,bottom:0},f.extent,e))}return p},i=o(t),r=new Map;if(!i)return{axes:r,height:0};let a=(c,l)=>{r.set(c,l);for(let h of c.groups)for(let p of h.members){let u=n.get(p);u!==void 0&&a(p,l+u)}};return a(t,-i.top),{axes:r,height:i.bottom-i.top}}var Ue=class{min=1/0;max=-1/0;add(t){t<this.min&&(this.min=t),t>this.max&&(this.max=t)}};function On(s,t,e,n,o,i){if(!(s>0&&s<1))return;let r=1-s;i.add(r*r*r*t+3*r*r*s*e+3*r*s*s*n+s*s*s*o)}function Ls(s,t,e,n,o){o.add(s),o.add(n);let i=-s+3*t-3*e+n,r=2*(s-2*t+e),a=t-s;if(Math.abs(i)<1e-12){Math.abs(r)>1e-12&&On(-a/r,s,t,e,n,o);return}let c=r*r-4*i*a;if(c<0)return;let l=Math.sqrt(c);On((-r+l)/(2*i),s,t,e,n,o),On((-r-l)/(2*i),s,t,e,n,o)}function Cs(s,t,e,n){n.add(s),n.add(e);let o=s-2*t+e;if(Math.abs(o)<1e-12)return;let i=(s-t)/o;if(!(i>0&&i<1))return;let r=1-i;n.add(r*r*s+2*r*i*t+i*i*e)}function se(s){let t=new Ue,e=new Ue,n=0,o=0,i=0,r=0;for(let a of s){if(a.op==="Z"){n=i,o=r;continue}a.op==="C"?(Ls(n,a.cx1,a.cx2,a.x,t),Ls(o,a.cy1,a.cy2,a.y,e)):a.op==="Q"?(Cs(n,a.cx,a.x,t),Cs(o,a.cy,a.y,e)):(t.add(a.x),e.add(a.y),a.op==="M"&&(i=a.x,r=a.y)),n=a.x,o=a.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 qr=54.2813,Es=87.37505,Ye=72.8125,ks=93.6719,Qr=-27.4688,Ms=-7.9375,Jr=Ms+ks,ta=[{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}],ea=[{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 vs(s,t,e,n,o,i,r,a){let c=h=>o+(a?e-h:h)*r,l=h=>i+(a?n-h:h)*r;for(let h of t)h.op==="Z"?s.push(h):h.op==="C"?s.push({op:"C",cx1:c(h.cx1),cy1:l(h.cy1),cx2:c(h.cx2),cy2:l(h.cy2),x:c(h.x),y:l(h.y)}):h.op==="Q"?s.push({op:"Q",cx:c(h.cx),cy:l(h.cy),x:c(h.x),y:l(h.y)}):s.push({op:h.op,x:c(h.x),y:l(h.y)})}function Ns(s,t,e){let n=e==="up"||e==="down",o=Math.max(1,Math.round(s/(t*.3))),i=n?Math.max(0,o-1):o,r=n?Jr+Ye*i:Es+Ye*(i-1),a=s/r,c=[];for(let p=0;p<i;p++)vs(c,ta,qr,Es,0,p*Ye*a,a,e==="");n&&vs(c,ea,113.5313,ks,Qr*a,(i*Ye+Ms)*a,a,!1);let l=se(c);return e!=="up"?{commands:c,bounds:l}:{commands:c.map(p=>p.op==="Z"?p:p.op==="C"?{op:"C",cx1:l.x+l.w-(p.cx1-l.x),cy1:s-p.cy1,cx2:l.x+l.w-(p.cx2-l.x),cy2:s-p.cy2,x:l.x+l.w-(p.x-l.x),y:s-p.y}:p.op==="Q"?{op:"Q",cx:l.x+l.w-(p.cx-l.x),cy:s-p.cy,x:l.x+l.w-(p.x-l.x),y:s-p.y}:{op:p.op,x:l.x+l.w-(p.x-l.x),y:s-p.y}),bounds:{x:l.x,y:s-l.y-l.h,w:l.w,h:l.h}}}function na(s){let t=s,e=s.ast;return(e.callName==="up"||e.callName==="down")&&Array.isArray(t.members)&&Array.isArray(e.contents)?t:null}var Pn=class extends P{static def={name:["arp","arpeggio"],description:"\u7436\u97F3",details:`~~~jpfun
6
+ \u4F4D\u7F6E\u504F\u79FB\u5728\u6392\u7248\u540E\u5E94\u7528\uFF0C\u76F8\u90BB\u5BF9\u8C61\u4FDD\u6301\u539F\u4F4D\uFF1B\u5360\u4F4D\u8C03\u6574\u5728\u6392\u7248\u524D\u5E94\u7528\u3002\u53EA\u5305\u88F9\u5173\u7CFB\u5BF9\u8C61\u65F6\uFF0C\u5E73\u79FB\u4F5C\u7528\u4E8E\u8BE5\u5173\u7CFB\u5BF9\u8C61\u672C\u8EAB\u3002`,allowExtraArgs:!1,args:[{type:"content",description:"\u8981\u5FAE\u8C03\u7684\u5185\u5BB9\u6216\u5173\u7CFB\u5BF9\u8C61",default:null},{name:"dx",description:"\u6392\u7248\u540E\u7684\u6C34\u5E73\u504F\u79FB\uFF0C\u6B63\u503C\u5411\u53F3\uFF0C\u4E0D\u6539\u53D8\u5360\u4F4D",type:"length",default:{value:0,unit:"px"}},{name:"dy",description:"\u6392\u7248\u540E\u7684\u5782\u76F4\u504F\u79FB\uFF0C\u6B63\u503C\u5411\u4E0B\uFF0C\u4E0D\u6539\u53D8\u5360\u4F4D",type:"length",default:{value:0,unit:"px"}},{name:"dw",description:"\u589E\u51CF\u6C34\u5E73\u5360\u4F4D\uFF0C\u6309\u539F\u5DE6\u53F3\u6BD4\u4F8B\u5206\u914D\uFF0C\u6700\u7EC8\u5BBD\u5EA6\u4E0D\u5C0F\u4E8E 0",type:"length",default:{value:0,unit:"px"}},{name:"dh",description:"\u589E\u51CF\u4E0B\u65B9\u5360\u4F4D\uFF0C\u6700\u7EC8\u9AD8\u5EA6\u4E0D\u5C0F\u4E8E 0",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=>{Q(o)&&(e.temporal++,da(o,this))},onAttachment:o=>{te(o)&&(e.attachment++,ma(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 U("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[i,r,a,c,l]=this.getArgValue(e,n);i.parent=this,this.target=i,this.dx=n.length2px(r),this.dy=n.length2px(a),this.dw=n.length2px(c),this.dh=n.length2px(l)}toString(t){return`@adjust(${this.target.toString(t)}, dx=${this.dx}px, dy=${this.dy}px, dw=${this.dw}px, dh=${this.dh}px)`}},Gs=jn;function da(s,t){let{dx:e,dy:n,dw:o,dh:i}=t;if(e===0&&n===0&&o===0&&i===0)return;let r,a,c=s.finalizeLayout,l=s.onPlaced;s.finalizeLayout=f=>{c?.call(s,f);let p=Math.max(0,s.box.w+o);s.box.anchor=s.box.w>0?s.box.anchor*p/s.box.w:0,s.box.w=p,s.box.h=Math.max(0,s.box.h+i)},s.onPlaced=()=>{s.box.x!==r&&(s.box.x+=e),s.box.y!==a&&(s.box.y+=n),l?.call(s),r=s.box.x,a=s.box.y}}function ma(s,t,e,n){if(e===0&&n===0)return;let o=s.createGeometry;s.createGeometry=i=>{let r=o.call(s,i);if(t.temporal>0)return r;let a=c=>c.line===void 0?{x:c.x+e,y:c.y+n,w:c.w,h:c.h}:{x:c.x+e,y:c.y+n,w:c.w,h:c.h,line:c.line,track:c.track};return{regions:r.regions.map(a),occupancy:r.occupancy?.map(a),paint(c){r.paint(new be(c,e,n))}}}}var sn=1,xa=6,ya=16,Yn=32,Us=1e-6,ga=.01;function rn(s,t=sn){let e=s.alpha_L??s.alpha_R??xa;s.alpha_L??=e,s.alpha_R??=e;let n=s.mu_L??s.mu_R??ya;s.mu_L??=n,s.mu_R??=n,s.beta_L??=t/Math.max(s.alpha_L,Us),s.beta_R??=t/Math.max(s.alpha_R,Us)}function an(s,t,e,n=sn){rn(s,n);let o=Math.pow(Math.max(e.T.toNumber(),ga),.5);return{config:s,box:t,time:e,duration_L:o,duration_R:o,WL:t.anchor,WR:t.w-t.anchor,margin_L:o*s.alpha_L,margin_R:o*s.alpha_R}}function ba(s,t=sn){let e=new Map,n=0;for(let i of s)for(let r of i)e.has(r.time.track)||e.set(r.time.track,n++);let o=[];for(let i of s){if(i.length===0)continue;let r=Array(i.length);o.push(r);let a=0,c=0,l=n;for(let p of i){p.WL>a&&(a=p.WL),p.WR>c&&(c=p.WR);let u=e.get(p.time.track);if(r[u]){let d=r[u];p.time.T.compare(d.time.T)>0?(r[u]=p,r[l++]=d):r[l++]=p}else r[u]=p}let f=i[0].time.t;for(let p of e){let u=p[1];if(!r[u]){let d=an({anchor:0,alpha_L:a,alpha_R:c},{x:0,w:0,anchor:0},{t:f,T:new F(1),track:p[0]},t);d.fake=!0,r[u]=d}}}return{mat:o,rows:n}}function wa(s,t,e,n){let o=n-e-s.WR-t.WL,i=s.margin_R+t.margin_L;if(o>=i)return{force:0,stiffness:0};let r=s.config.beta_R/s.duration_R,a=t.config.beta_L/t.duration_L,c=r*a/(r+a),l,f;if(o<0){let p=s.config.mu_R*t.config.mu_L/(s.config.mu_R+t.config.mu_L);l=c*i-p*o,f=p}else{let p=i-o;l=c*p,f=c}return{force:l,stiffness:f}}function Sa(s,t,e=Yn){let n=t-s.WL,o=s.margin_L;if(n>=o)return{force:0,stiffness:0};let i=s.config.beta_L/s.duration_L;if(n>=0)return{force:i*(o-n),stiffness:i};let r=s.config.mu_L*e;return{force:s.config.alpha_L*s.config.beta_L-r*n,stiffness:r}}function Aa(s,t,e,n=Yn){let o=e-(t+s.WR),i=s.margin_R;if(o>=i)return{force:0,stiffness:0};let r=s.config.beta_R/s.duration_R;if(o>=0)return{force:r*(i-o),stiffness:r};let a=s.config.mu_R*n;return{force:s.config.alpha_R*s.config.beta_R-a*o,stiffness:a}}function Ea(s){return{damping:s.damping??.6,maxIter:s.maxIter??100,eps:s.eps??.01,crossPunish:s.crossPunish??Yn,globalC:s.globalC??sn}}function Ta(s,t,e,n,o){let{damping:i,maxIter:r,eps:a,crossPunish:c}=o,l=s.length,f=new Float64Array(t);for(let T=0;T<l;T++){let S=0,b=s[T];for(let v=0;v<t;v++){let _=f[v]+b[v].WL+b[v].margin_L;_>S&&(S=_)}for(let v=0;v<t;v++)f[v]=S+b[v].WR+b[v].margin_R;e[T]=S}let p=f.reduce((T,S)=>Math.max(T,S),0);if(p<=n)return!0;p=n/p;for(let T=0;T<l;T++)e[T]*=p;let u=new Float64Array(l),d=new Float32Array(t*(l+1));function h(T){u.fill(0);for(let S=0;S<t;S++){let b=S*(l+1),v=s[0][S],_=Sa(v,T[0],c);u[0]+=_.force,d[b]=_.stiffness;for(let H=1;H<l;H++){let B=s[H-1][S],G=s[H][S],J=wa(B,G,T[H-1],T[H]);u[H-1]-=J.force,u[H]+=J.force,d[b+H]=J.stiffness}let I=s[l-1][S],K=Aa(I,T[l-1],n,c);u[l-1]-=K.force,d[b+l]=K.stiffness}return u}let x=new Float64Array(l);function g(T){x.fill(0);for(let b=0,v=0;b<t;b++,v+=l+1){x[0]+=d[v]*T[0];for(let _=1;_<l;_++){let I=d[v+_]*(T[_]-T[_-1]);x[_-1]-=I,x[_]+=I}x[l-1]+=d[v+l]*T[l-1]}let S=1e-4;for(let b=0;b<T.length;b++)x[b]+=S*T[b];return x}function m(T,S){let b=0;for(let v=0;v<T.length;v++)b+=T[v]*S[v];return b}let y=new Float64Array(l),w=new Float64Array(l),E=new Float64Array(l);function A(T,S=8){y.fill(0),w.set(T),E.set(w);let b=m(w,w);if(b<1e-12)return y;for(let v=0;v<S;v++){let _=g(E),I=m(E,_);if(Math.abs(I)<1e-12)break;let K=b/I;for(let G=0;G<l;G++)y[G]+=K*E[G],w[G]-=K*_[G];let H=m(w,w);if(Math.sqrt(H)<1e-6)break;let B=H/b;for(let G=0;G<l;G++)E[G]=w[G]+B*E[G];b=H}return y}let L=0,M=0;for(;L<r;L++){let T=h(e);M=0;for(let b=0;b<T.length;b++){let v=Math.abs(T[b]);v>M&&(M=v)}if(M<a)break;let S=A(T);for(let b=0;b<l;b++)e[b]+=i*S[b]}return!1}function we(s,t,e,n,o,i,r){if(e.length!==s.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 a=n.some(d=>d!==0),c,l,f=s,p=e;if(a){c=new Uint32Array(e.length),l=new Float64Array(e.length),f=[];for(let d=0;d<e.length;){let h=d;for(;h<n.length&&n[h];)h++;let x=f.length;for(let g=d;g<=h;g++)c[g]=x,l[g]=e[g]-e[d];if(d===h)f.push(s[d]);else{let g=e[h]-e[d];f.push(Array.from({length:t},(m,y)=>{let w=s[d][y],E=s[h][y];return{config:{alpha_L:w.config.alpha_L,alpha_R:E.config.alpha_R,mu_L:w.config.mu_L,mu_R:E.config.mu_R,beta_L:w.config.beta_L,beta_R:E.config.beta_R},box:w.box,time:w.time,duration_L:w.duration_L,duration_R:E.duration_R,WL:w.WL,WR:g+E.WR,margin_L:w.margin_L,margin_R:E.margin_R,fake:w.fake&&E.fake}}))}d=h+1}p=new Float64Array(f.length)}let u=Ta(f,t,p,o,i);if(n.fill(1),r!==void 0){let d=0,h=0;for(let g=0;g<t;g++)d=Math.max(d,f[0][g].WL),h=Math.max(h,f[f.length-1][g].WR);let x=p[p.length-1]+h-p[0]+d;if(!u||x>=o*r){let g=d-p[0],m=o-x;for(let y=0;y<p.length;y++)p[y]+=g+(p.length>1?m*y/(p.length-1):0)}}if(a)for(let d=0;d<e.length;d++)e[d]=p[c[d]]+l[d]}function Kn(s,t,e={},n=[],o){let i=Ea(e),{mat:r,rows:a}=ba(s,i.globalC),c=new Float64Array(r.length),l=new Uint8Array(Math.max(0,r.length-1)),f=n.length>1?[...n].sort((p,u)=>p.end-p.start-(u.end-u.start)):n;for(let{start:p,end:u,hook:d}of f){if(p<0||u<p||u>=r.length)throw new Error("Horizontal layout registration references invalid columns");d({columns:r,rows:a,start:p,end:u,X:c,fixed:l,options:i})}we(r,a,c,l,t,i,o);for(let p=0;p<r.length;p++)for(let u of r[p])u.box.x=c[p]-u.box.anchor;return r}var Se=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}},St={width:794,height:1/0,marginTop:45,marginBottom:48,marginLeft:40,marginRight:40,lineGap:22,fillRatio:.5};function Pe(s={}){let t=s.height??St.height,e={width:s.width??St.width,height:t<=0?1/0:t,marginTop:Math.max(0,s.marginTop??St.marginTop),marginBottom:Math.max(0,s.marginBottom??St.marginBottom),marginLeft:Math.max(0,s.marginLeft??St.marginLeft),marginRight:Math.max(0,s.marginRight??St.marginRight),lineGap:Math.max(0,s.lineGap??St.lineGap),fillRatio:s.fillRatio??St.fillRatio};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(r=>!Number.isFinite(r)||r<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 i=e.height-e.marginTop-e.marginBottom;if(Number.isFinite(e.height)&&i<=0)throw new Error(`Page vertical margins leave no content height: ${i}px`);return e}function Xn(s,t){let e=t.height-t.marginTop-t.marginBottom,n=[],o=new Array(s.length).fill(0),i=0,r=0,a=0,c=0,l=(f,p)=>{let u=f-r,d=p?Math.max(0,e-c-t.lineGap*(u-1)):0,h=t.lineGap+d/u,x=i+t.marginTop;for(let m=r;m<f;m++)o[m]=x,x+=s[m]+(m+1<f?h:0);let g=Number.isFinite(t.height)?t.height:x-i+t.marginBottom;n.push({bounds:{x:0,y:i,w:t.width,h:g},lineStart:r,lineEnd:f}),i+=g,r=f,a=0,c=0};for(let f=0;f<s.length;f++){let p=s[f];if(Number.isFinite(t.height)&&p>e+1e-6)throw new Se(f,p,e);Number.isFinite(t.height)&&f>r&&a+t.lineGap+p>e+1e-6&&l(f,!0),a+=(f>r?t.lineGap:0)+p,c+=p}return s.length>r&&l(s.length,!1),{pages:n,lineTops:o}}var Vs={start:0,end:-1,wholeLine:!1};function qn(s){let t=new Set,e=n=>{t.add(n);for(let o of n.groups)for(let i of o.members)e(i)};return e(s),n=>{for(let o=n;o;o=o.parent)if(t.has(o))return o;return n}}function js(s,t){for(let e=t;e;){let n=s.columnOf(e);if(n>=0)return n;let o=e instanceof tt?e.foldedInto:void 0;e=o&&Q(o)?o:void 0}return-1}function Zn(s,t,e,n){if(!t)return{start:0,end:s.columns.length-1,wholeLine:!0};if(typeof t[0]=="number")return{start:Math.max(0,t[0]),end:Math.min(s.columns.length-1,t[1]),wholeLine:!1};let[o,i]=t;if(o.layoutLine>i.layoutLine&&([o,i]=[i,o]),s.index<o.layoutLine||s.index>i.layoutLine)return Vs;let r=e&&n(e);if(r&&(n(o.track)!==r||n(i.track)!==r))throw new Error("Range endpoints must belong to the selected track");let a=o.layoutLine<s.index?0:js(s,o),c=i.layoutLine>s.index?s.columns.length-1:js(s,i);return a<0||c<0?Vs:{start:Math.min(a,c),end:Math.max(a,c),wholeLine:!1}}function Qn(s,t,e,n){if(!s)return[];let{start:o,end:i}=Zn(s,t,e,n),r=s.columns.slice(o,i+1);if(!e)return r;let a=n(e),c=l=>l.track===a;return r.every(l=>l.every(c))?r:r.map(l=>l.filter(c))}var Ks=.75;function cn(s,t){let e=1/0,n=1/0,o=-1/0,i=-1/0;for(let r of t)e=Math.min(e,r.x),n=Math.min(n,r.y),o=Math.max(o,r.x+r.w),i=Math.max(i,r.y+r.h);return Number.isFinite(e)?(s.x=e,s.y=n,s.w=o-e,s.h=i-n,!0):(s.x=s.y=s.w=s.h=0,!1)}function Fe(s,t){s.springConfig??={},s.decorations=[],s.ports={},s.box.x=s.box.y=0,s.prepareLayout(t);for(let[e,n]of Object.entries(s.addon??{})){let o=t.decorationHandlers.get(e);if(!o)continue;let i=o(s,n,t);i&&s.decorations.push(i)}La(s),s.finalizeLayout?.(t)}function to(s,t,e={}){let n=s.attachments.filter(te),o=Pe(s.page),i=o.width-o.marginLeft-o.marginRight,r=o.marginLeft,a=qn(s.rootTrack),c=new Map(n.map((b,v)=>[b,v])),l=Ma(n),f=new Map,p=b=>{let v=f.get(b);return v&&Ys(v).box};t={...t,layoutSubdomain(b,v,_,I){let K=Xs(v,t),H=new Set(v.flat()),B=N=>{for(let P=N;P&&P!==b;P=P.foldedInto)if(H.has(P))return!0;return!1},G=I.filter(te).filter(N=>!N.endPoints?.length);for(let N of l.get(b)??[])!f.has(N)&&N.endPoints.every(B)&&G.push(N);G.sort((N,P)=>c.get(N)-c.get(P));let J=va(v,K,_,G,t,p);return G.forEach((N,P)=>f.set(N,J.items[P])),{width:K.width,height:J.height,positions:J.positions}}};let u=Ca(s),d=[];for(let b of u)for(let v of b.columns)for(let _ of v)d.push(_),Fe(_,t);let h=n.filter(b=>!f.has(b)),x=u.map((b,v)=>eo(b.columns,v,e)),g=x.map(b=>b.view);for(let b of h)b.prepareHorizontal?.(g,t);for(let b of x){b.layout(i,o.fillRatio);for(let v of b.view.columns)for(let _ of v)_.box.x+=r}for(let b of d){let v=u[b.layoutLine],_=-b.box.visualAxis;ln(v.hostExtents,b.track,_,_+b.box.h)}let m=ka(u.length,d,e.rowGap),y=()=>{let b=[],v=u.map((B,G)=>{let J=qs(B,s.rootTrack,m[G]);return b.push(J.height),J.axes}),_,I;try{({pages:_,lineTops:I}=Xn(b,o))}catch(B){if(!(B instanceof Se))throw B;let G=u[B.line],J=1/0,N=-1/0;for(let P of G?.columns??[])for(let V of P)J=Math.min(J,V.ast.sourceSpan.start),N=Math.max(N,V.ast.sourceSpan.end);throw Number.isFinite(J)?D.error.PageOverflow(B.requiredHeight,B.availableHeight,{start:J,end:N}):B}let K=(B,G)=>(I[B]??0)+(v[B]?.get(G)??0);for(let B of d)B.box.y=K(B.layoutLine,B.track)-B.box.visualAxis,B.onPlaced?.();let H={...t,width:i,originX:r,pages:_.map(B=>B.bounds),lines:g,getVisualAxis:(B,G)=>K(B,a(G)),getHostExtent:(B,G)=>u[B]?.hostExtents.get(a(G)),getRangeColumns:(B,G,J)=>Qn(g[B],G,J,a)};return{pages:_,attachmentContext:H}},w=y(),E=Jn(h,w.attachmentContext,u,a,p);E.needsRelayout&&(w=y(),E=Jn(h,w.attachmentContext,u,a,p));let A=w.pages,L=0,M=n.map(b=>{let v=f.get(b),{geometry:_,box:I}=v?Ys(v):E.items[L++];return{box:I,regions:_.regions,layer:b.layer,sourceSpan:b.sourceSpan,paint(K){_.paint(K)}}}),T={x:0,y:0,w:0,h:0};function*S(){for(let b of A)yield b.bounds;for(let b of d)yield b.box;for(let b of M)yield b.box}return cn(T,S()),{diagnostics:s.diagnostics,objects:d,attachments:M,bounds:T,lineCount:u.length,pages:A}}function La(s){let t=s.decorations.map(n=>n.below).filter(n=>n!==void 0).sort((n,o)=>n.order-o.order);if(t.length===0)return;let e=s.box.h;for(let n of t)e+=n.gap??0,n.place?.(e),e+=Math.max(0,n.height??0);s.box.h=e}function Ca(s){let t=()=>({columns:[],hostExtents:new Map,attachmentExtents:new Map}),e=[],n=t();for(let o of s.columns){let i=[];for(;e.length<o[0].layoutLine;)e.push(n),n=t();for(let r of o)Q(r)&&i.push(r);i.length&&n.columns.push(i)}return(n.columns.length>0||e.length===0)&&e.push(n),e}function De(s,t,e){s.top=Math.min(s.top,t),s.bottom=Math.max(s.bottom,e)}function ln(s,t,e,n){let o=s.get(t);o?De(o,e,n):s.set(t,{top:e,bottom:n})}function eo(s,t,e={},n=!1){let o=[],i=new Map,r=new Map;for(let c=0;c<s.length;c++)for(let l of s[c]){i.set(l,c),rn(l.springConfig,e.globalC);let f=r.get(l.track);f?f.push(l):r.set(l.track,[l])}let a={index:t,columns:s,trackRuns:r,columnOf:c=>i.get(c)??-1,registerHorizontalLayoutHook(c,l,f){let p=i.get(c),u=i.get(l);p===void 0||u===void 0||o.push({start:Math.min(p,u),end:Math.max(p,u),hook:f})}};for(let c of s)for(let l of c)l.prepareHorizontal?.(a);return{view:a,layout(c,l){let f=s.map(p=>p.map(u=>{let d=an(u.springConfig,u.box,u,e.globalC);return n&&(d.margin_L=d.margin_R=0),d}));return Kn(f,c,e,o,l),f}}}function Ae(s,t){return s.length===0?0:Xs(s.map(e=>[e]),t).width}function Xs(s,t){for(let i of s)for(let r of i)Fe(r,t);let e=eo(s,s[0][0].layoutLine,{},!0),n=1/0,o=-1/0;for(let i of e.layout(1/0))for(let r of i){let a=r.box.x+r.box.anchor;n=Math.min(n,a-r.WL),o=Math.max(o,a+r.WR)}for(let i of s)for(let r of i)r.box.x-=n;return{width:o-n,view:e.view}}function va(s,{width:t,view:e},n,o,i,r){let a=s.flat(),c={hostExtents:new Map,attachmentExtents:new Map},l=0;for(let E of a){let A=-E.box.visualAxis;ln(c.hostExtents,E.track,A,A+E.box.h),l=Math.max(l,E.ast.size*Ks)}let f=a.map(E=>({x:E.box.x,y:0})),p=()=>{let E=qs(c,n,l);return a.forEach((A,L)=>{A.box.y=f[L].y=E.axes.get(A.track)-A.box.visualAxis,A.onPlaced?.()}),E},u=p();if(o.length===0)return{height:u.height,positions:f,items:[]};let d=qn(n),h=[],x=[];h[e.index]=c,x[e.index]=e;let g=()=>Jn(o,{...i,width:t,originX:0,pages:[],lines:x,getVisualAxis:(E,A)=>u.axes.get(d(A))??0,getHostExtent:(E,A)=>h[E]?.hostExtents.get(d(A)),getRangeColumns:(E,A,L)=>Qn(x[E],A,L,d)},h,d,r),m=g();m.needsRelayout&&(u=p(),m=g());let y=a[0],w=m.items.map(E=>({...E,reference:y,x:y.box.x,y:y.box.y}));return{height:u.height,positions:f,items:w}}function Ma(s){let t=new Map;for(let e of s){let[n,...o]=e.endPoints??[];for(let i=n?.foldedInto;i;i=i.foldedInto){let r=i;if(!o.every(c=>Na(r,c)))continue;let a=t.get(i);a?a.push(e):t.set(i,[e])}}return t}function Na(s,t){for(let e=t.foldedInto;e;e=e.foldedInto)if(e===s)return!0;return!1}function Ys(s){let t=s.reference.box.x-s.x,e=s.reference.box.y-s.y;if(t===0&&e===0)return s;let n=i=>({...i,x:i.x+t,y:i.y+e}),{geometry:o}=s;return{box:n(s.box),geometry:{regions:o.regions.map(n),paint:i=>o.paint(new be(i,t,e))}}}function ka(s,t,e){if(e!==void 0)return new Array(s).fill(e);let n=new Array(s).fill(0),o=0;for(let i of t){let r=i.ast.size*Ks;r>n[i.layoutLine]&&(n[i.layoutLine]=r),r>o&&(o=r)}for(let i=0;i<s;i++)n[i]||=o;return n}function Jn(s,t,e,n,o){let i=new Map,r=new Set(s),a=[],c=!1;function l(u,d,h){let x=t.lines[u],g=h===void 0?new Map:void 0,m;if(!x)return g;let y=(S,b,v)=>{g?ln(g,S,b,v):m?De(m,b,v):m={top:b,bottom:v}},{start:w,end:E,wholeLine:A}=Zn(x,d,h,n),L=h&&n(h),M=A?t.originX:1/0,T=A?t.originX+t.width:-1/0;for(let S=w;S<=E;S++)for(let b of x.columns[S]){if(L&&b.track!==L)continue;A||(b.box.x<M&&(M=b.box.x),b.box.x+b.box.w>T&&(T=b.box.x+b.box.w));let v=b.box.y-t.getVisualAxis(u,b.track);y(b.track,v,v+b.box.h)}for(let S of a[u]??[])L&&S.track!==L||S.right<=M||S.left>=T||y(S.track,S.top,S.bottom);return g??m}let f={...t,getRangeExtents:l,getAttachmentBox(u){let d=i.get(u)??o(u);if(!d)throw new Error("Layout attachment dependency has not been measured");return d},getContentBounds(u){let d=[];for(let x of u.nodes)Q(x)&&(x.box.w>0||x.box.h>0)&&d.push(x.box);for(let x of u.attachments){if(!te(x)||!r.has(x)&&!o(x))continue;let g=f.getAttachmentBox(x);(g.w>0||g.h>0)&&d.push(g)}let h={x:0,y:0,w:0,h:0};return cn(h,d)?h:void 0}};return{items:s.map(u=>{let d=u.createGeometry(f),h={x:0,y:0,w:0,h:0};cn(h,d.regions);let x={geometry:d,box:h};i.set(u,h);for(let g of d.occupancy??d.regions){if(g.line===void 0)continue;let m=e[g.line],y=n(g.track),w=g.y-t.getVisualAxis(g.line,y),E=w+g.h,A=m.hostExtents.get(y),L=m.attachmentExtents.get(y);(w<Math.min(A?.top??1/0,L?.top??1/0)||E>Math.max(A?.bottom??-1/0,L?.bottom??-1/0))&&(c=!0),ln(m.attachmentExtents,y,w,E),(a[g.line]??=[]).push({track:y,left:g.x,right:g.x+g.w,top:w,bottom:E})}return x}),needsRelayout:c}}function qs(s,t,e){let n=new Map,o=c=>{let l=s.hostExtents.get(c),f=s.attachmentExtents.get(c),p=l?{top:l.top,bottom:l.bottom}:null;f&&(p?De(p,f.top,f.bottom):p={top:f.top,bottom:f.bottom});let u=[];for(let h of c.groups){let x=h.members.map(o);if(x.every(y=>y===null))continue;let g=h.measure(x,e),m=null;for(let y of g){if(!y)continue;let w=y.offset+y.extent.top,E=y.offset+y.extent.bottom;m?De(m,w,E):m={top:w,bottom:E}}m&&u.push({group:h,placements:g,extent:m})}let d=(h,x)=>{p??={top:0,bottom:0};for(let g=0;g<h.group.members.length;g++){let m=h.placements[g];m&&n.set(h.group.members[g],x+m.offset)}De(p,x+h.extent.top,x+h.extent.bottom)};for(let h of u)h.group.place||d(h,0);for(let h of u){let x=h.group.place;if(!x)continue;d(h,x(p??{top:0,bottom:0},h.extent,e))}return p},i=o(t),r=new Map;if(!i)return{axes:r,height:0};let a=(c,l)=>{r.set(c,l);for(let f of c.groups)for(let p of f.members){let u=n.get(p);u!==void 0&&a(p,l+u)}};return a(t,-i.top),{axes:r,height:i.bottom-i.top}}var fn=class{min=1/0;max=-1/0;add(t){t<this.min&&(this.min=t),t>this.max&&(this.max=t)}};function no(s,t,e,n,o,i){if(!(s>0&&s<1))return;let r=1-s;i.add(r*r*r*t+3*r*r*s*e+3*r*s*s*n+s*s*s*o)}function Zs(s,t,e,n,o){o.add(s),o.add(n);let i=-s+3*t-3*e+n,r=2*(s-2*t+e),a=t-s;if(Math.abs(i)<1e-12){Math.abs(r)>1e-12&&no(-a/r,s,t,e,n,o);return}let c=r*r-4*i*a;if(c<0)return;let l=Math.sqrt(c);no((-r+l)/(2*i),s,t,e,n,o),no((-r-l)/(2*i),s,t,e,n,o)}function Qs(s,t,e,n){n.add(s),n.add(e);let o=s-2*t+e;if(Math.abs(o)<1e-12)return;let i=(s-t)/o;if(!(i>0&&i<1))return;let r=1-i;n.add(r*r*s+2*r*i*t+i*i*e)}function Ee(s){let t=new fn,e=new fn,n=0,o=0,i=0,r=0;for(let a of s){if(a.op==="Z"){n=i,o=r;continue}a.op==="C"?(Zs(n,a.cx1,a.cx2,a.x,t),Zs(o,a.cy1,a.cy2,a.y,e)):a.op==="Q"?(Qs(n,a.cx,a.x,t),Qs(o,a.cy,a.y,e)):(t.add(a.x),e.add(a.y),a.op==="M"&&(i=a.x,r=a.y)),n=a.x,o=a.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 _a=54.2813,Js=87.37505,pn=72.8125,ei=93.6719,Ra=-27.4688,ni=-7.9375,Ia=ni+ei,$a=[{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}],Oa=[{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 ti(s,t,e,n,o,i,r,a){let c=f=>o+(a?e-f:f)*r,l=f=>i+(a?n-f:f)*r;for(let f of t)f.op==="Z"?s.push(f):f.op==="C"?s.push({op:"C",cx1:c(f.cx1),cy1:l(f.cy1),cx2:c(f.cx2),cy2:l(f.cy2),x:c(f.x),y:l(f.y)}):f.op==="Q"?s.push({op:"Q",cx:c(f.cx),cy:l(f.cy),x:c(f.x),y:l(f.y)}):s.push({op:f.op,x:c(f.x),y:l(f.y)})}function oi(s,t,e){let n=e==="up"||e==="down",o=Math.max(1,Math.round(s/(t*.3))),i=n?Math.max(0,o-1):o,r=n?Ia+pn*i:Js+pn*(i-1),a=s/r,c=[];for(let p=0;p<i;p++)ti(c,$a,_a,Js,0,p*pn*a,a,e==="");n&&ti(c,Oa,113.5313,ei,Ra*a,(i*pn+ni)*a,a,!1);let l=Ee(c);return e!=="up"?{commands:c,bounds:l}:{commands:c.map(p=>p.op==="Z"?p:p.op==="C"?{op:"C",cx1:l.x+l.w-(p.cx1-l.x),cy1:s-p.cy1,cx2:l.x+l.w-(p.cx2-l.x),cy2:s-p.cy2,x:l.x+l.w-(p.x-l.x),y:s-p.y}:p.op==="Q"?{op:"Q",cx:l.x+l.w-(p.cx-l.x),cy:s-p.cy,x:l.x+l.w-(p.x-l.x),y:s-p.y}:{op:p.op,x:l.x+l.w-(p.x-l.x),y:s-p.y}),bounds:{x:l.x,y:s-l.y-l.h,w:l.w,h:l.h}}}function Pa(s){let t=s,e=s.ast;return(e.callName==="up"||e.callName==="down")&&Array.isArray(t.members)&&Array.isArray(e.contents)?t:null}var oo=class extends O{static def={name:["arp","arpeggio"],description:"\u7436\u97F3",details:`~~~jpfun
7
7
  @arp({1 ^ 3 ^ 5}, direction=up)
8
8
  ~~~
9
- \u7ED9\u548C\u5F26\u7ED8\u5236\u4E00\u4E2A\u4ECE\u4F4E\u5230\u9AD8\u7684\u7436\u97F3`,allowExtraArgs:!1,args:[{name:"content",description:"\u7531 `up` / `down` \u5806\u53E0\u5F62\u6210\u7684\u548C\u5F26",type:"content",default:null},{name:"direction",description:"\u7A7A\u503C\u4ECE\u4F4E\u5230\u9AD8\u3001\u4E0D\u753B\u7BAD\u5934\uFF1B`up` \u4ECE\u4F4E\u5230\u9AD8\u3001\u9876\u7AEF\u5E26\u7BAD\u5934\uFF1B`down` \u4ECE\u9AD8\u5230\u4F4E\u3001\u5E95\u7AEF\u5E26\u7BAD\u5934",type:"string",default:""}]};content;direction;size;get children(){return[this.content]}constructor(t,e,n,o=null){super(t,o);let[i,r]=this.getArgValue(e,n),a="";r!==""&&r!=="up"&&r!=="down"?n.diagnostics.push(new G("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)):a=r,this.content=i,this.direction=a,this.size=n.variables.fontsize,i.parent=this}loweringEnter(t,e){let n=null;t.isolateFromLoweringGroups(()=>{let i=t.trackedEvents(this.content,new z,e).flat();if(i.length!==1||!i[0].box)throw new k("E_ARPEGGIO_INVALID_CONTENT","@arp \u7684\u5185\u5BB9\u5FC5\u987B\u6070\u597D\u4EA7\u751F\u4E00\u4E2A\u540C\u8F68\u548C\u5F26",this.content.sourceSpan);n=i[0]});let o=na(n);if(!o||o.members.length<2||o.members.some(i=>i.track!==e))throw new k("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 Dn(this,o)]}toString(t){let e=this.direction?`, direction=${this.direction}`:"";return`@arp(${this.content.toString(t)}${e})`}},_s=Pn,Dn=class extends Q{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),Nt(this.host,t);let e=this.ast.size,n=e*.16,{commands:o,bounds:i}=Ns(this.host.box.h,e,this.ast.direction);this.markCommands=o,this.markX=-i.x,this.hostX=i.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 r in this.host.ports){let a=this.host.ports[r];this.ports[r]={x:this.hostX+a.x,y:a.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 z(1,8),o=e.clone().div(2).div(this.playbackMembers.length-1);n.compare(o)>0&&n.copyFrom(o);let i=new Map(this.playbackMembers.map((a,c)=>[a,c])),r=this;t.defer(a=>{let c;for(let l=a.events.length-1;l>=0;l--){let h=a.events[l];if(h.origins.some(p=>p.node===r)){c=h.origins[0];break}}if(c)for(let l of a.events){if(l.kind!=="note-on"&&l.kind!=="note-off"||l.origins[0]!==c)continue;let h=l.origins.find(u=>i.has(u.node))?.node,p=h?i.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 Fn=class extends P{static def={name:["bar","|"],description:"\u5C0F\u8282\u7EBF",details:`~~~jpfun
9
+ \u7ED9\u548C\u5F26\u7ED8\u5236\u7436\u97F3\u8BB0\u53F7\uFF0C\u64AD\u653E\u65F6\u6309\u65B9\u5411\u9519\u5F00\u6210\u5458\u8D77\u70B9\u5E76\u4FDD\u6301\u5171\u540C\u7EC8\u70B9\u3002\u590D\u5408\u6210\u5458\u7684\u5185\u90E8\u97F3\u7B26\u6309\u6BD4\u4F8B\u538B\u7F29\u5230\u5269\u4F59\u65F6\u503C\uFF0C\u88C5\u9970\u97F3\u5728\u786E\u5B9A\u540E\u7684\u533A\u95F4\u5185\u5C55\u5F00\u3002`,allowExtraArgs:!1,args:[{name:"content",description:"\u7531 `up` / `down` \u5806\u53E0\u5F62\u6210\u7684\u548C\u5F26",type:"content",default:null},{name:"direction",description:"\u7A7A\u503C\u4ECE\u4F4E\u5230\u9AD8\u3001\u4E0D\u753B\u7BAD\u5934\uFF1B`up` \u4ECE\u4F4E\u5230\u9AD8\u3001\u9876\u7AEF\u5E26\u7BAD\u5934\uFF1B`down` \u4ECE\u9AD8\u5230\u4F4E\u3001\u5E95\u7AEF\u5E26\u7BAD\u5934",type:"string",default:""}]};content;direction;size;get children(){return[this.content]}constructor(t,e,n,o=null){super(t,o);let[i,r]=this.getArgValue(e,n),a="";r!==""&&r!=="up"&&r!=="down"?n.diagnostics.push(new U("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)):a=r,this.content=i,this.direction=a,this.size=n.variables.fontsize,i.parent=this}loweringEnter(t,e){let n=null;t.isolateFromLoweringGroups(()=>{let i=t.trackedEvents(this.content,new F,e).flat();if(i.length!==1||!i[0].box)throw new k("E_ARPEGGIO_INVALID_CONTENT","@arp \u7684\u5185\u5BB9\u5FC5\u987B\u6070\u597D\u4EA7\u751F\u4E00\u4E2A\u540C\u8F68\u548C\u5F26",this.content.sourceSpan);n=i[0]});let o=Pa(n);if(!o||o.members.length<2||o.members.some(i=>i.track!==e))throw new k("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 so(this,o)]}toString(t){let e=this.direction?`, direction=${this.direction}`:"";return`@arp(${this.content.toString(t)}${e})`}},si=oo,so=class extends tt{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),Fe(this.host,t);let e=this.ast.size,n=e*.16,{commands:o,bounds:i}=oi(this.host.box.h,e,this.ast.direction);this.markCommands=o,this.markX=-i.x,this.hostX=i.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 r in this.host.ports){let a=this.host.ports[r];this.ports[r]={x:this.hostX+a.x,y:a.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 F(1,8),o=e.clone().div(2).div(this.playbackMembers.length-1);n.compare(o)>0&&n.copyFrom(o);let i=new Map(this.playbackMembers.map((a,c)=>[a,c])),r=this;t.defer(a=>{let c;for(let l=a.spans.length-1;l>=0;l--){let f=a.spans[l];if(f.origins.some(p=>p.node===r)){c=f.origins[0];break}}if(c)for(let l of a.spans){if(l.origins[0]!==c)continue;let f=l.origins.find(h=>i.has(h.node))?.node,p=f?i.get(f):void 0;if(!p)continue;let u=n.clone().mul(p),d=e.clone().sub(u).div(e);l.start.sub(t.start).mul(d).add(t.start).add(u),l.end.sub(t.start).mul(d).add(t.start).add(u)}})}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 io=class extends O{static def={name:["bar","|"],description:"\u5C0F\u8282\u7EBF",details:`~~~jpfun
10
10
  @bar(0, length=1.25em)
11
11
  ~~~
12
- \u6709\u8BED\u6CD5\u7CD6\u7B80\u5199\uFF0C\u89C1 type \u53C2\u6570\u7684\u8BF4\u660E\u3002`,allowExtraArgs:!1,args:[{name:"type",description:"0\uFF1A\u666E\u901A\u7EBF `|`\uFF1B1\uFF1A\u7EC8\u6B62\u7EBF `||`\uFF08\u5DE6\u7EC6\u53F3\u7C97\uFF09\uFF1B2\uFF1A\u53CD\u590D\u8D77\u70B9 `|:`\uFF1B3\uFF1A\u53CD\u590D\u7EC8\u70B9 `:|`\uFF1B4\uFF1A\u5DE6\u53F3\u53CD\u590D `:|:`",type:"number",default:0},{name:"length",description:"\u5C0F\u8282\u7EBF\u9AD8\u5EA6",type:"length",default:{value:1.25,unit:"em"}}]};static deSugarAtom(t,e,n){let o=e,i=0,r=t.slice(o,o+2);if(r==="||")i=1,o+=2;else if(r==="|:")i=2,o+=2;else if(r===":|")t[o+2]===":"?(i=4,o+=3):(i=3,o+=2);else if(t[o]==="|")i=0,o+=1;else return null;let a=new Map;return a.set("type",i),{next:o,node:{kind:"call",typed:!0,name:"bar",args:a,span:{start:e,end:o},syntaxKind:"atom"}}}type;size;constructor(t,e,n,o=null){super(t,o);let[i,r]=this.getArgValue(e,n);this.type=i,this.size=n.length2px(r)}loweringEnter(){return[this.type>=2?new zn(this):new Ke(this)]}toString(){return`@bar(${this.type}, ${this.size}px)`}},Is=Fn,Ke=class extends Q{lines=[];repeatDots=[];constructor(t){super(),this.ast=t,this.mergeKey=ot,this.initLayoutBox(),this.springConfig={alpha_L:128,alpha_R:128}}prepareHorizontal(t){let e=this;for(;e.foldedInto;)e=e.foldedInto;if(!U(e))return;let n=t.trackRuns.get(e.track),o=n?.indexOf(e)??-1;!n||o<0||t.registerHorizontalLayoutHook(e,e,({columns:i,start:r})=>{let a=i[r].find(u=>u.time===e);if(!a)return;let c=u=>{let m=t.columnOf(u);return m<0?void 0:i[m].find(f=>f.time===u)},l=o>0?c(n[o-1]):void 0;l&&(l.config.mu_R*=4,a.config.mu_L*=4);let h=n[o+1],p=h?c(h):void 0;p&&h.mergeKey!==ot&&(a.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,i=Math.max(1,e*.065),r=i*2.6,a=i*1.8,c=i*.8,l=a+c,h=t===3||t===4,p=t===2||t===4,u=h?c*2+l:0;if(t===1||t===3||t===4?(this.lines.push({x:u,w:i}),u+=i+a,this.lines.push({x:u,w:r}),u+=r):t===2?(this.lines.push({x:u,w:r}),u+=r+a,this.lines.push({x:u,w:i}),u+=i):(this.lines.push({x:u,w:i}),u+=i),h){let f=c;n.push({x:f,y:o*.38}),n.push({x:f,y:o*.62})}if(p){let f=u+l;n.push({x:f,y:o*.38}),n.push({x:f,y:o*.62}),u=f+c}this.box.w=u,this.box.h=o;let m=t>=2?this.lines[0]:void 0;this.box.anchor=m?m.x+m.w/2:u/2,this.box.visualAxis=o/2;for(let f of this.lines)f.x-=this.box.anchor;this.repeatDots=n.map(f=>({x:f.x-this.box.anchor,y:f.y,r:c}))}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"})}},Bn="repeat.start";function Rs(s,t){return s.visits(s.seek(Bn,t+1,-1)??0)}var zn=class extends Ke{playbackMarks(){return this.ast.type===3?[]:[Bn]}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(Bn,e,-1)??0}}}};var $s="div",Ht=Bt($s);function _t(s,t){return`div.${s}.${t}`}function Os(s,t){let e=s.ports[_t(t,"left")];e&&(e.claimed=!0)}function Gn(s){return Math.max(1,s*.055)}function*Ps(s){for(let t=0;;t++){let e=!1,n=-1;for(let o=0;o<=s.length;o++){let i=s[o]?.ports,r=i?.[_t(t,"left")],a=i?.[_t(t,"right")];if((r||a)&&(e=!0),r&&a){n<0&&(n=o);continue}n>=0&&o-n>=2&&(yield{level:t,from:n,to:o-1}),n=-1}if(!e)return}}var Hn=class s extends P{static def={name:[$s,"/"],description:"\u51CF\u65F6\u7EBF",details:"~~~jpfun\n@div({1 2 -}, n=2, autobeam=true)\n~~~\n**\u7B80\u5199**\uFF1A\u5728\u76EE\u6807\u540E\u52A0 `/`\uFF0C\u53EF\u91CD\u590D\u6216\u4F5C\u7528\u4E8E\u5185\u5BB9\u5757\u3002`@div(1, 2)` \u7B49\u4EF7\u4E8E `1//`\uFF0C`@div({1 2/ -}, 2)` \u7B49\u4EF7\u4E8E `{1 2/ -}//`\u3002\u9ED8\u8BA4\u53C2\u6570\u4F7F\u7528 `div.n`\u3001`div.autobeam` \u8BBE\u7F6E\u3002",allowExtraArgs:!1,args:[{type:"content",description:"\u8981\u51CF\u65F6\u7684\u5185\u5BB9\uFF0C\u53EF\u5305\u542B\u591A\u4E2A\u97F3\u7B26\u6216\u589E\u65F6\u7EBF",default:null},{name:"n",description:"\u51CF\u65F6\u5C42\u6570\uFF0C\u6BCF\u7EA7\u5C06\u65F6\u503C\u51CF\u534A\uFF0C\u53D6\u975E\u8D1F\u6574\u6570",type:"number",default:1},{name:"autobeam",description:"\u662F\u5426\u53C2\u4E0E\u4E0D\u540C div \u4E4B\u95F4\u7684\u81EA\u52A8\u8FDE\u7EBF\uFF0C\u540C\u4E00 div \u5185\u90E8\u7684\u8FDE\u7EBF\u4E0D\u53D7\u5F71\u54CD",type:"boolean",default:!0}]};static deSugarAtom(t,e,n){let o=0,i=e;for(;i<n&&t[i]==="/";)o++,i++;return o===0?null:{next:i,node:{kind:"sugar",data:{class:s,n:o},span:{start:e,end:i}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==s)return null;let i=P.findLastFuncContentNode(t.nodes,t.nodes.length-1);if(!i)return n;if(i instanceof s)return i.n+=o.data.n,n;let r=new Map;r.set(0,i),r.set("n",o.data.n);let a=i.sourceSpan,c=new s({start:Math.min(a.start,o.span.start),end:Math.max(a.end,o.span.end)},r,t,null);return t.nodes.pop(),t.pushNode(c),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,i=Gn(t.ast.size),r=(n-1)*o+i,a=0,c=0,l=0;return{below:{order:0,gap:-t.ast.size*.08,height:r,place(h){a=t.ports["body.left"]?.x??0,c=t.ports["body.right"]?.x??t.box.w,l=h+i/2;for(let p=0;p<n;p++){let u=l+p*o;t.ports[_t(p,"left")]={x:a,y:u},t.ports[_t(p,"right")]={x:c,y:u}}}},paint(h){for(let p=0;p<n;p++){if(t.ports[_t(p,"left")].claimed)continue;let m=t.box.y+l+p*o;h.drawLine(t.box.x+a,m,t.box.x+c,m,{stroke:"#000",strokeWidth:i})}}}};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 i=Math.max(0,Math.trunc(this.n));i!==this.n&&(n.diagnostics.push(new G("W_DIV_INVALID_N",`@div \u7684\u6570\u91CF\u53C2\u6570 n \u5FC5\u987B\u4E3A\u975E\u8D1F\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A ${i}`,this.sourceSpan)),this.n=i)}toString(t){return`@div(${this.content.toString(t)}, ${this.n})`}},ie=Hn;function re(s,t,e){return new we(s,t,e)}function Ds(s){let t=new Map;for(let n of s.columns)for(let o of n){if(!U(o)||o.mergeKey===ot&&o.T.isZero())continue;let i=t.get(o.layoutLine);i||(i=new Map,t.set(o.layoutLine,i));let r=i.get(o.track);r?r.push(o):i.set(o.track,[o])}let e=new Map;for(let[n,o]of t)for(let[i,r]of o)for(let a=0;a<r.length;a++)e.set(r[a],{line:n,track:i,index:a});for(let n of s.attachments)if(!(!(n instanceof we)||!n.explicit))for(let o=1;o<n.endPoints.length;o++){let i=n.endPoints[o-1],r=n.endPoints[o];if(!U(i)||!U(r))continue;let a=e.get(i),c=e.get(r);if(!(i!==r&&a!==void 0&&c!==void 0&&a.line===c.line&&a.track===c.track&&c.index===a.index+1))throw new k("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\uFF08\u53EF\u8DE8\u5C0F\u8282\u7EBF\uFF09",n.sourceSpan)}}function Fs(s){let t=new Set;for(let e of s)if(!(!(e instanceof we)||!e.explicit))for(let n of e.endPoints)t.add(n);return t}var we=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,i)=>U(i)?Math.max(o,i.ast.size):o,0),this.strokeWidth=Gn(this.fontSize)}prepareHorizontal(t){let e=new Set(this.endPoints);for(let n of t)for(let o of n.trackRuns.values())for(let i=1;i<o.length;i++){let r=o[i-1],a=o[i];!e.has(r)||!e.has(a)||(r.springConfig.alpha_R=r.springConfig.alpha_R*.8,a.springConfig.alpha_L=a.springConfig.alpha_L*.8)}}createGeometry(t){let e=this.collectLines(t),n=this.strokeWidth;return{regions:e.map(i=>({x:Math.min(i.start.x,i.end.x),y:i.start.y-n/2,w:Math.abs(i.end.x-i.start.x),h:n,line:i.line,track:i.track})),paint(i){for(let r of e)i.drawLine(r.start.x,r.start.y,r.end.x,r.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(U);if(n.length<2)return e;for(let{level:o,from:i,to:r}of Ps(n)){let a=[];for(let c=i;c<=r;c++){let l=n[c];a.push({left:this.absolutePort(l,_t(o,"left")),right:this.absolutePort(l,_t(o,"right")),line:l.layoutLine,track:l.track,node:l})}this.addSystemLines(a,t,o,e)}if(e.length===0&&this.explicit){let o=this.fontSize*.12,i=n.map(r=>{let a={x:r.box.x+r.box.anchor,y:r.box.y+r.box.h+o};return{left:a,right:a,line:r.layoutLine,track:r.track,node:r}});this.addSystemLines(i,t,null,e)}return e}addSystemLines(t,e,n,o){let i=Math.min(...t.map(h=>h.line)),r=Math.max(...t.map(h=>h.line)),a=t[0].track,c=e.getVisualAxis(t[0].line,a),l=t[0].left.y-c;for(let h=i;h<=r;h++){let p=t.filter(d=>d.line===h).sort((d,x)=>d.left.x-x.left.x);if(p.length===0){let x=e.getVisualAxis(h,a)+l;o.push({start:{x:e.originX,y:x},end:{x:e.originX+e.width,y:x},line:h,track:a});continue}let u=p[0],m=p[p.length-1],f=u.left.y,y={x:u.left.x,y:f},g={x:m.right.x,y:f};if(h>i&&(y.x=e.originX),h<r&&(g.x=e.originX+e.width),!(y.x===g.x&&i===r)){if(n!==null)for(let d of p)Os(d.node,n);o.push({start:y,end:g,line:h,track:u.track})}}}};function Bs(s){let t=[],e=Math.max(0,Math.floor(Number(s.addon?.[Ht])||0)),n=r=>{t.push(r),e-=Math.max(0,r.n)},o=s.ast.parent;for(;o&&e>0;)o instanceof ie&&n(o),o=o.parent;let i=r=>{for(let a of r.children??[]){if(e<=0)return;a instanceof ie&&n(a),i(a)}};return i(s.ast),t}function oa(s){let t=new Map,e=new Map;for(let n of s.columns)for(let o of n){if(!U(o))continue;let i=Bs(o);if(i.length===0)continue;let r=[];for(let a of i){let c=t.get(a);c||(c={owner:a,nodes:[]},t.set(a,c)),c.nodes.push(o),r.push(c)}e.set(o,r)}return{scopes:[...t.values()],nodeScopes:e}}function sa(s){let t=new Set(s.map(e=>e.owner));return s.filter(e=>{let n=e.owner.parent;for(;n;){if(n instanceof ie&&t.has(n))return!1;n=n.parent}return!0})}function ia(s){let t=1/0,e=-1/0;for(let n of s){t=Math.min(t,n.ast.sourceSpan.start),e=Math.max(e,n.ast.sourceSpan.end);for(let o of Bs(n))t=Math.min(t,o.sourceSpan.start),e=Math.max(e,o.sourceSpan.end)}return{start:t,end:e}}function zs(s){return re(s,!1,ia(s))}function ra(s,t){let e=[];for(let n of sa(s)){let o=new Map;for(let i of n.nodes){let r=o.get(i.track);r?r.push(i):o.set(i.track,[i])}for(let i of o.values()){let r=[],a=()=>{r.length>=2&&e.push(zs(r)),r=[]};for(let c of i){if(t.has(c)){a();continue}r.push(c)}a()}}return e}function aa(s){return Math.floor(s.numerator/s.denominator)}function ca(s,t,e){let n=[],o=new Map,i=new Map,r=new z,a=new z;for(let h of s.columns)for(let p of h){let u=i.get(p.layoutLine);(u===void 0||p.t.compare(u)<0)&&i.set(p.layoutLine,p.t)}let c=h=>{let p=o.get(h);p&&(o.delete(h),p.nodes.length>=2&&n.push(zs(p.nodes)))},l=()=>{for(let h of[...o.keys()])c(h)};for(let h of s.columns){let p=h.find(u=>u.mergeKey===ot);p&&(l(),r.copyFrom(p.t));for(let u of h){if(u.mergeKey===ot)continue;let m=U(u)?t.get(u):void 0,f=m?.every(_=>_.nodes.length===1)??!1,y=m?.every(_=>_.owner.autoBeamEnabled)??!1;if(!(U(u)&&f&&y&&u.T.compare(1)<0&&!e.has(u))){(U(u)||!u.T.isZero())&&c(u.track);continue}let d=i.get(u.layoutLine)??u.t,x=r.compare(d)>=0?r:d,b=aa(a.copyFrom(u.t).sub(x)),w=o.get(u.track);if(!w){o.set(u.track,{nodes:[u],line:u.layoutLine,beat:b,endTime:u.t.clone().add(u.T)});continue}let N=u.t.equals(w.endTime);if(u.layoutLine!==w.line||b!==w.beat||!N){c(u.track),o.set(u.track,{nodes:[u],line:u.layoutLine,beat:b,endTime:u.t.clone().add(u.T)});continue}w.nodes.push(u),w.endTime.copyFrom(u.t).add(u.T)}}return l(),n}function Hs(s){let{scopes:t,nodeScopes:e}=oa(s),n=Fs(s.attachments);return[...ra(t,n),...ca(s,e,n)]}var Wn=class extends P{static loweringAugment=Hs;static loweringFinalize=Ds;static def={name:["beam"],description:"\u51CF\u65F6\u7EBF\u8FDE\u63A5",details:"\u4E8B\u540E\u5C06\u591A\u4E2A\u51CF\u65F6\u7EBF**\u5F3A\u884C**\u76F8\u8FDE\n~~~jpfun\n1/@a 2/@b | 3/@c @beam(a, b, c)\n~~~\n**\u4F4D\u7F6E\u53C2\u6570**\uFF1A\u5DF2\u6807\u8BB0\u97F3\u7B26\u7684\u6807\u7B7E\uFF0C\u6309\u4F20\u5165\u987A\u5E8F\u8FDE\u63A5\u51CF\u65F6\u7EBF\uFF0C\u663E\u5F0F\u6307\u5B9A\u4E00\u7EC4\u3002\u5148\u7528 `/` \u6216 `@div` \u4E3A\u76EE\u6807\u6DFB\u52A0\u51CF\u65F6\u7EBF\uFF0C\u518D\u7528 `@beam` \u63A7\u5236\u8FDE\u63A5\u3002\u7AEF\u70B9\u987B\u540C\u8F68\u3001\u540C\u8C31\u9762\u884C\u4E14\u76F8\u90BB\uFF0C\u53EF\u8DE8\u5C0F\u8282\u7EBF\uFF1B\u8FDE\u7EBF\u76F4\u63A5\u7A7F\u8FC7\u5C0F\u8282\u7EBF\uFF0C\u4FDD\u7559\u539F\u6709\u95F4\u8DDD\u3002",allowExtraArgs:!0,extraArgType:"label",args:[]};endPoints=[];constructor(t,e,n,o=null){super(t,o);for(let[,r]of e){let a=r instanceof P?r:n.parseArgWithType(r.valueSpan,"label",t.start);a instanceof P&&this.endPoints.push(a)}let i=n.labelableNodes.length-1;for(;this.endPoints.length<2&&i>=0;){let r=n.labelableNodes[i--];!r||this.endPoints.includes(r)||this.endPoints.unshift(r)}if(this.endPoints.length<2)throw new k("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(D.warning.UnresolvedEndpoint("beam",this.sourceSpan)),[]):(t.addAttachment(re(e,!0,this.sourceSpan)),[])}},Gs=Wn;var Vn=class extends P{static def={name:["box"],description:"\u7ED9\u76EE\u6807\u7ED3\u6784\u6216\u5BF9\u8C61\u52A0\u5916\u6846",details:`~~~jpfun
12
+ \u6709\u8BED\u6CD5\u7CD6\u7B80\u5199\uFF0C\u89C1 type \u53C2\u6570\u7684\u8BF4\u660E\u3002`,allowExtraArgs:!1,args:[{name:"type",description:"0\uFF1A\u666E\u901A\u7EBF `|`\uFF1B1\uFF1A\u7EC8\u6B62\u7EBF `||`\uFF08\u5DE6\u7EC6\u53F3\u7C97\uFF09\uFF1B2\uFF1A\u53CD\u590D\u8D77\u70B9 `|:`\uFF1B3\uFF1A\u53CD\u590D\u7EC8\u70B9 `:|`\uFF1B4\uFF1A\u5DE6\u53F3\u53CD\u590D `:|:`",type:"number",default:0},{name:"length",description:"\u5C0F\u8282\u7EBF\u9AD8\u5EA6",type:"length",default:{value:1.25,unit:"em"}}]};static deSugarAtom(t,e,n){let o=e,i=0,r=t.slice(o,o+2);if(r==="||")i=1,o+=2;else if(r==="|:")i=2,o+=2;else if(r===":|")t[o+2]===":"?(i=4,o+=3):(i=3,o+=2);else if(t[o]==="|")i=0,o+=1;else return null;let a=new Map;return a.set("type",i),{next:o,node:{kind:"call",typed:!0,name:"bar",args:a,span:{start:e,end:o},syntaxKind:"atom"}}}type;size;constructor(t,e,n,o=null){super(t,o);let[i,r]=this.getArgValue(e,n);this.type=i,this.size=n.length2px(r)}loweringEnter(){return[this.type>=2?new ao(this):new un(this)]}toString(){return`@bar(${this.type}, ${this.size}px)`}},ii=io,un=class extends tt{lines=[];repeatDots=[];constructor(t){super(),this.ast=t,this.mergeKey=ct,this.initLayoutBox(),this.springConfig={alpha_L:128,alpha_R:128}}prepareHorizontal(t){let e=this;for(;e.foldedInto;)e=e.foldedInto;if(!Q(e))return;let n=t.trackRuns.get(e.track),o=n?.indexOf(e)??-1;!n||o<0||t.registerHorizontalLayoutHook(e,e,({columns:i,start:r})=>{let a=i[r].find(u=>u.time===e);if(!a)return;let c=u=>{let d=t.columnOf(u);return d<0?void 0:i[d].find(h=>h.time===u)},l=o>0?c(n[o-1]):void 0;l&&(l.config.mu_R*=4,a.config.mu_L*=4);let f=n[o+1],p=f?c(f):void 0;p&&f.mergeKey!==ct&&(a.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,i=Math.max(1,e*.065),r=i*2.6,a=i*1.8,c=i*.8,l=a+c,f=t===3||t===4,p=t===2||t===4,u=f?c*2+l:0;if(t===1||t===3||t===4?(this.lines.push({x:u,w:i}),u+=i+a,this.lines.push({x:u,w:r}),u+=r):t===2?(this.lines.push({x:u,w:r}),u+=r+a,this.lines.push({x:u,w:i}),u+=i):(this.lines.push({x:u,w:i}),u+=i),f){let h=c;n.push({x:h,y:o*.38}),n.push({x:h,y:o*.62})}if(p){let h=u+l;n.push({x:h,y:o*.38}),n.push({x:h,y:o*.62}),u=h+c}this.box.w=u,this.box.h=o;let d=t>=2?this.lines[0]:void 0;this.box.anchor=d?d.x+d.w/2:u/2,this.box.visualAxis=o/2;for(let h of this.lines)h.x-=this.box.anchor;this.repeatDots=n.map(h=>({x:h.x-this.box.anchor,y:h.y,r:c}))}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"})}},ro="repeat.start";function ri(s,t){return s.visits(s.seek(ro,t+1,-1)??0)}var ao=class extends un{playbackMarks(){return this.ast.type===3?[]:[ro]}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(ro,e,-1)??0}}}};var ai="div",ee=Jt(ai);function Gt(s,t){return`div.${s}.${t}`}function ci(s,t){let e=s.ports[Gt(t,"left")];e&&(e.state.claimed=!0)}function lo(s){return Math.max(1,s*.055)}function*li(s){for(let t=0;;t++){let e=!1,n=-1;for(let o=0;o<=s.length;o++){let i=s[o]?.ports,r=i?.[Gt(t,"left")],a=i?.[Gt(t,"right")];if((r||a)&&(e=!0),r&&a){n<0&&(n=o);continue}n>=0&&o-n>=2&&(yield{level:t,from:n,to:o-1}),n=-1}if(!e)return}}var co=class s extends O{static def={name:[ai,"/"],description:"\u51CF\u65F6\u7EBF",details:"~~~jpfun\n@div({1 2 -}, n=2, autobeam=true)\n~~~\n**\u7B80\u5199**\uFF1A\u5728\u76EE\u6807\u540E\u52A0 `/`\uFF0C\u53EF\u91CD\u590D\u6216\u4F5C\u7528\u4E8E\u5185\u5BB9\u5757\u3002`@div(1, 2)` \u7B49\u4EF7\u4E8E `1//`\uFF0C`@div({1 2/ -}, 2)` \u7B49\u4EF7\u4E8E `{1 2/ -}//`\u3002\u9ED8\u8BA4\u53C2\u6570\u4F7F\u7528 `div.n`\u3001`div.autobeam` \u8BBE\u7F6E\u3002",allowExtraArgs:!1,args:[{type:"content",description:"\u8981\u51CF\u65F6\u7684\u5185\u5BB9\uFF0C\u53EF\u5305\u542B\u591A\u4E2A\u97F3\u7B26\u6216\u589E\u65F6\u7EBF",default:null},{name:"n",description:"\u51CF\u65F6\u5C42\u6570\uFF0C\u6BCF\u7EA7\u5C06\u65F6\u503C\u51CF\u534A\uFF0C\u53D6\u975E\u8D1F\u6574\u6570",type:"number",default:1},{name:"autobeam",description:"\u662F\u5426\u53C2\u4E0E\u4E0D\u540C div \u4E4B\u95F4\u7684\u81EA\u52A8\u8FDE\u7EBF\uFF0C\u540C\u4E00 div \u5185\u90E8\u7684\u8FDE\u7EBF\u4E0D\u53D7\u5F71\u54CD",type:"boolean",default:!0}]};static deSugarAtom(t,e,n){let o=0,i=e;for(;i<n&&t[i]==="/";)o++,i++;return o===0?null:{next:i,node:{kind:"sugar",data:{class:s,n:o},span:{start:e,end:i}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==s)return null;let i=O.findLastFuncContentIndex(t.nodes,t.nodes.length-1);if(i<0)return n;let r=t.nodes[i];if(r instanceof s)return r.n+=o.data.n,n;let a=new Map;a.set(0,r),a.set("n",o.data.n);let c=r.sourceSpan,l=new s({start:Math.min(c.start,o.span.start),end:Math.max(c.end,o.span.end)},a,t,null);return t.nodes[i]=l,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,i=lo(t.ast.size),r=(n-1)*o+i,a=0,c=0,l=0;return{below:{order:0,gap:-t.ast.size*.08,height:r,place(f){a=t.ports["body.left"]?.x??0,c=t.ports["body.right"]?.x??t.box.w,l=f+i/2;for(let p=0;p<n;p++){let u=l+p*o;t.ports[Gt(p,"left")]={x:a,y:u,state:{claimed:!1}},t.ports[Gt(p,"right")]={x:c,y:u}}}},paint(f){for(let p=0;p<n;p++){if(t.ports[Gt(p,"left")].state.claimed)continue;let d=t.box.y+l+p*o;f.drawLine(t.box.x+a,d,t.box.x+c,d,{stroke:"#000",strokeWidth:i})}}}};loweringEnter(t){let e=this.n;return t.beginLoweringGroup(this,{onTemporal(n){if(e===0)return;let o=n.addon??={};o[ee]=(Number(o[ee])||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 i=Math.max(0,Math.trunc(this.n));i!==this.n&&(n.diagnostics.push(new U("W_DIV_INVALID_N",`@div \u7684\u6570\u91CF\u53C2\u6570 n \u5FC5\u987B\u4E3A\u975E\u8D1F\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A ${i}`,this.sourceSpan)),this.n=i)}toString(t){return`@div(${this.content.toString(t)}, ${this.n})`}},Te=co;function Le(s,t,e){return new Be(s,t,e)}function fi(s){let t=new Map;for(let n of s.columns)for(let o of n){if(!Q(o)||o.mergeKey===ct&&o.T.isZero())continue;let i=t.get(o.layoutLine);i||(i=new Map,t.set(o.layoutLine,i));let r=i.get(o.track);r?r.push(o):i.set(o.track,[o])}let e=new Map;for(let[n,o]of t)for(let[i,r]of o)for(let a=0;a<r.length;a++)e.set(r[a],{line:n,track:i,index:a});for(let n of s.attachments)if(!(!(n instanceof Be)||!n.explicit))for(let o=1;o<n.endPoints.length;o++){let i=n.endPoints[o-1],r=n.endPoints[o];if(!Q(i)||!Q(r))continue;let a=e.get(i),c=e.get(r);if(!(i!==r&&a!==void 0&&c!==void 0&&a.line===c.line&&a.track===c.track&&c.index===a.index+1))throw new k("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\uFF08\u53EF\u8DE8\u5C0F\u8282\u7EBF\uFF09",n.sourceSpan)}}function pi(s){let t=new Set;for(let e of s)if(!(!(e instanceof Be)||!e.explicit))for(let n of e.endPoints)t.add(n);return t}var Be=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,i)=>Q(i)?Math.max(o,i.ast.size):o,0),this.strokeWidth=lo(this.fontSize)}prepareHorizontal(t){let e=new Set(this.endPoints);for(let n of t)for(let o of n.trackRuns.values())for(let i=1;i<o.length;i++){let r=o[i-1],a=o[i];!e.has(r)||!e.has(a)||(r.springConfig.alpha_R=r.springConfig.alpha_R*.8,a.springConfig.alpha_L=a.springConfig.alpha_L*.8)}}createGeometry(t){let e=this.collectLines(t),n=this.strokeWidth;return{regions:e.map(i=>({x:Math.min(i.start.x,i.end.x),y:i.start.y-n/2,w:Math.abs(i.end.x-i.start.x),h:n,line:i.line,track:i.track})),paint(i){for(let r of e)i.drawLine(r.start.x,r.start.y,r.end.x,r.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(Q);if(n.length<2)return e;for(let{level:o,from:i,to:r}of li(n)){let a=[];for(let c=i;c<=r;c++){let l=n[c];a.push({left:this.absolutePort(l,Gt(o,"left")),right:this.absolutePort(l,Gt(o,"right")),line:l.layoutLine,track:l.track,node:l})}this.addSystemLines(a,t,o,e)}if(e.length===0&&this.explicit){let o=this.fontSize*.12,i=n.map(r=>{let a={x:r.box.x+r.box.anchor,y:r.box.y+r.box.h+o};return{left:a,right:a,line:r.layoutLine,track:r.track,node:r}});this.addSystemLines(i,t,null,e)}return e}addSystemLines(t,e,n,o){let i=Math.min(...t.map(f=>f.line)),r=Math.max(...t.map(f=>f.line)),a=t[0].track,c=e.getVisualAxis(t[0].line,a),l=t[0].left.y-c;for(let f=i;f<=r;f++){let p=t.filter(m=>m.line===f).sort((m,y)=>m.left.x-y.left.x);if(p.length===0){let y=e.getVisualAxis(f,a)+l;o.push({start:{x:e.originX,y},end:{x:e.originX+e.width,y},line:f,track:a});continue}let u=p[0],d=p[p.length-1],h=u.left.y,x={x:u.left.x,y:h},g={x:d.right.x,y:h};if(f>i&&(x.x=e.originX),f<r&&(g.x=e.originX+e.width),!(x.x===g.x&&i===r)){if(n!==null)for(let m of p)ci(m.node,n);o.push({start:x,end:g,line:f,track:u.track})}}}};function ui(s){let t=[],e=Math.max(0,Math.floor(Number(s.addon?.[ee])||0)),n=r=>{t.push(r),e-=Math.max(0,r.n)},o=s.ast.parent;for(;o&&e>0;)o instanceof Te&&n(o),o=o.parent;let i=r=>{for(let a of r.children??[]){if(e<=0)return;a instanceof Te&&n(a),i(a)}};return i(s.ast),t}function Da(s){let t=new Map,e=new Map;for(let n of s.columns)for(let o of n){if(!Q(o))continue;let i=ui(o);if(i.length===0)continue;let r=[];for(let a of i){let c=t.get(a);c||(c={owner:a,nodes:[]},t.set(a,c)),c.nodes.push(o),r.push(c)}e.set(o,r)}return{scopes:[...t.values()],nodeScopes:e}}function Fa(s){let t=new Set(s.map(e=>e.owner));return s.filter(e=>{let n=e.owner.parent;for(;n;){if(n instanceof Te&&t.has(n))return!1;n=n.parent}return!0})}function Ba(s){let t=1/0,e=-1/0;for(let n of s){t=Math.min(t,n.ast.sourceSpan.start),e=Math.max(e,n.ast.sourceSpan.end);for(let o of ui(n))t=Math.min(t,o.sourceSpan.start),e=Math.max(e,o.sourceSpan.end)}return{start:t,end:e}}function hi(s){return Le(s,!1,Ba(s))}function za(s,t){let e=[];for(let n of Fa(s)){let o=new Map;for(let i of n.nodes){let r=o.get(i.track);r?r.push(i):o.set(i.track,[i])}for(let i of o.values()){let r=[],a=()=>{r.length>=2&&e.push(hi(r)),r=[]};for(let c of i){if(t.has(c)){a();continue}r.push(c)}a()}}return e}function Ha(s){return Math.floor(s.numerator/s.denominator)}function Wa(s,t,e){let n=[],o=new Map,i=new Map,r=new F,a=new F;for(let f of s.columns)for(let p of f){let u=i.get(p.layoutLine);(u===void 0||p.t.compare(u)<0)&&i.set(p.layoutLine,p.t)}let c=f=>{let p=o.get(f);p&&(o.delete(f),p.nodes.length>=2&&n.push(hi(p.nodes)))},l=()=>{for(let f of[...o.keys()])c(f)};for(let f of s.columns){let p=f.find(u=>u.mergeKey===ct);p&&(l(),r.copyFrom(p.t));for(let u of f){if(u.mergeKey===ct)continue;let d=Q(u)?t.get(u):void 0,h=d?.every(L=>L.nodes.length===1)??!1,x=d?.every(L=>L.owner.autoBeamEnabled)??!1;if(!(Q(u)&&h&&x&&u.T.compare(1)<0&&!e.has(u))){(Q(u)||!u.T.isZero())&&c(u.track);continue}let m=i.get(u.layoutLine)??u.t,y=r.compare(m)>=0?r:m,w=Ha(a.copyFrom(u.t).sub(y)),E=o.get(u.track);if(!E){o.set(u.track,{nodes:[u],line:u.layoutLine,beat:w,endTime:u.t.clone().add(u.T)});continue}let A=u.t.equals(E.endTime);if(u.layoutLine!==E.line||w!==E.beat||!A){c(u.track),o.set(u.track,{nodes:[u],line:u.layoutLine,beat:w,endTime:u.t.clone().add(u.T)});continue}E.nodes.push(u),E.endTime.copyFrom(u.t).add(u.T)}}return l(),n}function di(s){let{scopes:t,nodeScopes:e}=Da(s),n=pi(s.attachments);return[...za(t,n),...Wa(s,e,n)]}var fo=class extends O{static loweringAugment=di;static loweringFinalize=fi;static def={name:["beam"],description:"\u51CF\u65F6\u7EBF\u8FDE\u63A5",details:"\u4E8B\u540E\u5C06\u591A\u4E2A\u51CF\u65F6\u7EBF**\u5F3A\u884C**\u76F8\u8FDE\n~~~jpfun\n1/@a 2/@b | 3/@c @beam(a, b, c)\n~~~\n**\u4F4D\u7F6E\u53C2\u6570**\uFF1A\u5DF2\u6807\u8BB0\u97F3\u7B26\u7684\u6807\u7B7E\uFF0C\u6309\u4F20\u5165\u987A\u5E8F\u8FDE\u63A5\u51CF\u65F6\u7EBF\uFF0C\u663E\u5F0F\u6307\u5B9A\u4E00\u7EC4\u3002\u5148\u7528 `/` \u6216 `@div` \u4E3A\u76EE\u6807\u6DFB\u52A0\u51CF\u65F6\u7EBF\uFF0C\u518D\u7528 `@beam` \u63A7\u5236\u8FDE\u63A5\u3002\u7AEF\u70B9\u987B\u540C\u8F68\u3001\u540C\u8C31\u9762\u884C\u4E14\u76F8\u90BB\uFF0C\u53EF\u8DE8\u5C0F\u8282\u7EBF\uFF1B\u8FDE\u7EBF\u76F4\u63A5\u7A7F\u8FC7\u5C0F\u8282\u7EBF\uFF0C\u4FDD\u7559\u539F\u6709\u95F4\u8DDD\u3002",allowExtraArgs:!0,extraArgType:"label",args:[]};endPoints=[];constructor(t,e,n,o=null){super(t,o);for(let[,r]of e){let a=r instanceof O?r:n.parseArgWithType(r.valueSpan,"label",t.start);a instanceof O&&this.endPoints.push(a)}let i=n.labelableNodes.length-1;for(;this.endPoints.length<2&&i>=0;){let r=n.labelableNodes[i--];!r||this.endPoints.includes(r)||this.endPoints.unshift(r)}if(this.endPoints.length<2)throw new k("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(D.warning.UnresolvedEndpoint("beam",this.sourceSpan)),[]):(t.addAttachment(Le(e,!0,this.sourceSpan)),[])}},mi=fo;var po=class extends O{static def={name:["box"],description:"\u7ED9\u76EE\u6807\u7ED3\u6784\u6216\u5BF9\u8C61\u52A0\u5916\u6846",details:`~~~jpfun
13
13
  @box({1 2 3}, padding=0.2em, stroke=0.08em)
14
- ~~~`,allowExtraArgs:!1,args:[{type:"content",description:"\u9700\u8981\u52A0\u6846\u7684\u5185\u5BB9\u6216\u7ED3\u6784",default:null},{name:"padding",description:"\u5185\u5BB9\u5230\u6846\u7EBF\u7684\u5185\u8FB9\u8DDD",type:"length",default:{value:0,unit:"em"}},{name:"stroke",description:"\u6846\u7EBF\u5BBD\u5EA6",type:"length",default:{value:1,unit:"px"}},{name:"width",description:"\u7EA6\u675F\u5185\u90E8\u6392\u7248\u7684\u5BBD\u5EA6\uFF0C\u975E\u6B63\u503C\u8868\u793A\u968F\u5185\u5BB9\u81EA\u52A8\u786E\u5B9A",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 jn(e,n,this),onTemporal(o){U(o)&&e.push(o)},onAttachment(o){zt(o)&&n.push(o)}}),[]}loweringExit(t){return t.endLoweringGroup(this),[]}constructor(t,e,n,o=null){super(t,o);let[i,r,a,c]=this.getArgValue(e,n);i.parent=this,this.target=i,this.padding=Math.max(0,n.length2px(r)),this.stroke=Math.max(0,n.length2px(a)),this.width=n.length2px(c)}},Ws=Vn,jn=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 k("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,i=null,r=1/0,a=-1/0,c=0,l=0;for(let h of this.temporalMembers){let p=n.columnOf(h);if(p<0)continue;let u=h.box.anchor,m=h.box.w-u;p<r?(r=p,o=h,c=u):p===r&&(c=Math.max(c,u)),p>a?(a=p,i=h,l=m):p===a&&(l=Math.max(l,m))}if(!(!o||!i)){if(this.owner.width<c+l-1e-6)throw new k("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,i,({columns:h,rows:p,start:u,end:m,X:f,fixed:y,options:g})=>{if(y[u-1]||y[m])throw new k("E_BOX_CONSTRAINT_CROSSING","\u5B9A\u5BBD @box \u53EF\u4EE5\u5D4C\u5957\uFF0C\u4F46\u4E0D\u80FD\u90E8\u5206\u4EA4\u53C9",this.owner.sourceSpan);let d=f.subarray(u,m+1);ne(h.slice(u,m+1),p,d,y.subarray(u,m),this.owner.width,g,0);let x=d[d.length-1]-d[0]+c+l;if(Math.abs(x-this.owner.width)>1e-6)throw new k("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=-d[0]})}}createGeometry(t){let{padding:e,stroke:n}=this.owner,o={x:0,y:0,w:0,h:0},i=[...this.temporalMembers.map(l=>l.box),...this.childAttachments.map(l=>t.getAttachmentBox(l))];if(!be(o,i.filter(l=>l.w>0||l.h>0)))return{regions:[],paint(){}};let r=e+n/2,c={x:(this.fixedStart?this.fixedStart.box.x+this.fixedStart.box.anchor+this.wallOffset:o.x)-r,y:o.y-r,w:(this.fixedStart?this.owner.width:o.w)+r*2,h:o.h+r*2};return{regions:[c],paint(l){let h=n/2;l.drawRect(c.x+h,c.y+h,Math.max(0,c.w-n),Math.max(0,c.h-n),{stroke:"#000",strokeWidth:n})}}}};var Un=class extends P{static def={name:["dash","-"],description:"\u589E\u65F6\u7EBF",details:`~~~jpfun
15
- 1 @dash()
14
+ ~~~`,allowExtraArgs:!1,args:[{type:"content",description:"\u9700\u8981\u52A0\u6846\u7684\u5185\u5BB9\u6216\u7ED3\u6784",default:null},{name:"padding",description:"\u5185\u5BB9\u5230\u6846\u7EBF\u7684\u5185\u8FB9\u8DDD\uFF0C\u8D1F\u503C\u5411\u5185\u6536\u7F29",type:"length",default:{value:0,unit:"em"}},{name:"stroke",description:"\u6846\u7EBF\u5BBD\u5EA6",type:"length",default:{value:1,unit:"px"}},{name:"width",description:"\u7EA6\u675F\u5185\u90E8\u6392\u7248\u7684\u5BBD\u5EA6\uFF0C\u975E\u6B63\u503C\u8868\u793A\u968F\u5185\u5BB9\u81EA\u52A8\u786E\u5B9A",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={nodes:[],attachments:[],onTemporal(n){Q(n)&&e.nodes.push(n)},onAttachment(n){e.attachments.push(n)}};return t.beginLoweringGroup(this,e),[]}loweringExit(t){let e=t.endLoweringGroup(this),n=new uo(e,this);t.addAttachment(n);let o=e.nodes[0];if(o){let i=o.prepareHorizontal;o.prepareHorizontal=r=>{i?.call(o,r),n.registerHorizontal(r)}}return[]}constructor(t,e,n,o=null){super(t,o);let[i,r,a,c]=this.getArgValue(e,n);i.parent=this,this.target=i,this.padding=n.length2px(r),this.stroke=Math.max(0,n.length2px(a)),this.width=n.length2px(c)}toString(t){return`@box(${this.target.toString(t)}, padding=${this.padding}px, stroke=${this.stroke}px, width=${this.width}px)`}},xi=po,uo=class{content;owner;layer="background";fixedStart=null;wallOffset=0;get sourceSpan(){return this.owner.sourceSpan}constructor(t,e){this.content=t,this.owner=e}registerHorizontal(t){let e=this.content.nodes,n=e[0];if(!n)return;if(e.some(c=>c.layoutLine!==n.layoutLine))throw new k("E_BOX_CROSS_LINE","@box \u7684\u5185\u5BB9\u4E0D\u80FD\u8DE8\u8D8A\u8C31\u9762\u884C",this.owner.sourceSpan);let o=n;for(let c of e){let l=t.columnOf(c);if(l<0)return;l<t.columnOf(n)&&(n=c),l>t.columnOf(o)&&(o=c)}let{width:i,padding:r,stroke:a}=this.owner;t.registerHorizontalLayoutHook(n,o,({columns:c,rows:l,start:f,end:p,X:u,fixed:d,options:h})=>{let x=w=>c[w].filter(E=>e.some(A=>A.box===E.box)),g=x(f),m=x(p);if(i>0){let w=Math.max(...g.map(L=>L.WL)),E=Math.max(...m.map(L=>L.WR));if(i<w+E-1e-6)throw new k("E_BOX_WIDTH_TOO_SMALL","@box \u7684\u5BBD\u5EA6\u5C0F\u4E8E\u9996\u672B\u5143\u7D20\u7684\u56FA\u6709\u5BBD\u5EA6",this.owner.sourceSpan);if(d[f-1]||d[p])throw new k("E_BOX_CONSTRAINT_CROSSING","\u5B9A\u5BBD @box \u53EF\u4EE5\u5D4C\u5957\uFF0C\u4F46\u4E0D\u80FD\u90E8\u5206\u4EA4\u53C9",this.owner.sourceSpan);let A=u.subarray(f,p+1);if(f===p){let L=(i-w-E)/2;for(let M of g)M.WL+=L;for(let M of m)M.WR+=L;A[0]=w+L}else{we(c.slice(f,p+1),l,A,d.subarray(f,p),i,h,0);let L=A[A.length-1]-A[0]+w+E;if(Math.abs(L-i)>1e-6)throw new k("E_BOX_CONSTRAINT_CONFLICT","\u591A\u4E2A @box \u4E3A\u76F8\u540C\u5185\u5BB9\u6307\u5B9A\u4E86\u4E0D\u540C\u5BBD\u5EA6",this.owner.sourceSpan)}this.fixedStart=n,this.wallOffset=-A[0]}let y=r+a/2;for(let w of g)w.WL+=y;for(let w of m)w.WR+=y})}createGeometry(t){let{padding:e,stroke:n}=this.owner,o=t.getContentBounds(this.content);if(!o)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};if(a.w<n||a.h<n)throw new k("E_BOX_PADDING_TOO_SMALL","@box \u7684\u8D1F\u5185\u8FB9\u8DDD\u4F7F\u8FB9\u6846\u5BBD\u5EA6\u6216\u9AD8\u5EA6\u5C0F\u4E8E\u96F6",this.owner.sourceSpan);return{regions:[a],paint(c){let l=n/2;c.drawRect(a.x+l,a.y+l,Math.max(0,a.w-n),Math.max(0,a.h-n),{stroke:"#000",strokeWidth:n})}}}};var ho=class extends O{static def={name:["dash","-"],description:"\u589E\u65F6\u7EBF",details:"~~~jpfun\n1 @dash()\n~~~\n\u65E0\u53C2\u6570\u3002\u6DFB\u52A0\u4E00\u6839\u589E\u65F6\u7EBF\uFF0C\u6269\u5C55\u524D\u65B9\u97F3\u7B26\u6216\u4F11\u6B62\u7B26\u7684\u5B8C\u6574\u65F6\u503C\uFF1B\u4E5F\u53EF\u7B80\u5199\u4E3A `1 -`\u3002\u6BCF\u6839\u7EBF\u7684\u57FA\u7840\u65F6\u503C\u4E3A\u4E00\u4E2A\u56DB\u5206\u97F3\u7B26\uFF0C\u53EF\u7528\u51CF\u65F6\u7EBF\u6216\u9644\u70B9\u8C03\u6574\u3002\u88C5\u9970\u97F3\u8986\u76D6\u5EF6\u957F\u540E\u7684\u5B8C\u6574\u97F3\u7B26\uFF0C\u4F8B\u5982 `1 ^ $tr -` \u5728\u4E24\u62CD\u5185\u6301\u7EED\u98A4\u97F3\u3002",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 mo(this)]}labelable(){return this}toString(){return"-"}},yi=ho,mo=class extends tt{lineWidth=0;lineY=0;constructor(t){super(),this.ast=t,this.T.set(1),this.mergeKey=zt,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.track,o=this.ast.sourceSpan;t.defer(i=>{let r;for(let a=i.spans.length-1;a>=0;a--){let c=i.spans[a];if(c.track===n){if(r===void 0){if(!c.end.equals(e))continue;r=c.origins[0]}else if(c.origins[0]!==r)break;c.end.equals(e)&&t.extend(c)}}r===void 0&&i.diagnostics.push(new U("W_PLAYBACK_SUSTAIN_WITHOUT_TARGET","\u589E\u65F6\u7EBF\u524D\u6CA1\u6709\u53EF\u5EF6\u7EED\u7684\u97F3\u6BB5",o))})}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 wi="dot",gi=Jt(wi);function bi(s){let t=2**s;return[2*t-1,t]}var xo=class s extends O{static def={name:[wi,"."],description:"\u9644\u70B9",details:"~~~jpfun\n@dot(1, n=2)\n~~~\n**\u7B80\u5199**\uFF1A\u76EE\u6807\u540E\u52A0 `.`\uFF0C\u53EF\u91CD\u590D\u3002`@dot(1, 2)` \u7B49\u4EF7\u4E8E `1..`\uFF1B`{1^2}.` \u7B49\u4EF7\u4E8E `{1.^2}`\u3002\n\n`@dot({1 2/ -}, 2)` \u5305\u542B\u591A\u4E2A\u65F6\u95F4\u5143\u7D20\uFF0C\u4F1A\u62A5\u9519\uFF1B\u9700\u8981\u5206\u522B\u4E3A\u5404\u5143\u7D20\u6DFB\u52A0\u9644\u70B9\u3002",allowExtraArgs:!1,args:[{type:"content",description:"\u5355\u4E2A\u53EF\u89C1\u65F6\u95F4\u5143\u7D20\uFF0C\u5982\u97F3\u7B26\u3001\u589E\u65F6\u7EBF\u6216\u6298\u53E0\u548C\u5F26",default:null},{name:"n",description:"\u9644\u70B9\u6570\uFF0C\u7B2C\u4E00\u70B9\u589E\u52A0\u539F\u65F6\u503C\u7684\u4E00\u534A\uFF0C\u540E\u7EED\u5404\u70B9\u589E\u52A0\u91CF\u518D\u51CF\u534A",type:"number",default:1}]};static deSugarAtom(t,e,n){let o=0,i=e;for(;i<n&&t[i]===".";)o++,i++;return o===0?null:{next:i,node:{kind:"sugar",data:{class:s,n:o},span:{start:e,end:i}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==s)return null;let i=O.findLastFuncContentIndex(t.nodes,t.nodes.length-1);if(i<0)return n;let r=t.nodes[i];if(r instanceof s)return r.n+=o.data.n,n;let a=new Map;a.set(0,r),a.set("n",o.data.n);let c=r.sourceSpan,l=new s({start:Math.min(c.start,o.span.start),end:Math.max(c.end,o.span.end)},a,t,null);return t.nodes[i]=l,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,i=t.ast.size*.12,r=t.ports.dot??{x:t.box.w,y:t.box.visualAxis},a=r.x+i+o,c=o*2+i,l=a+(n-1)*c+o;return t.box.w=Math.max(t.box.w,l),{paint(f){let p=t.box.y+r.y;for(let u=0;u<n;u++)f.drawCircle(t.box.x+a+u*c,p,o,{fill:"#000"})}}};loweringEnter(t){let e=this.n,n={temporalCount:0,onTemporal(o){if(n.temporalCount++,e===0)return;let i=o.addon??={},r=Number(i[gi])||0,a=r+e,[c,l]=bi(a),[f,p]=bi(r);o.T.mul(c*p,l*f),i[gi]=a}};return t.beginLoweringGroup(this,n),[]}loweringExit(t){let e=t.endLoweringGroup(this);if(e.temporalCount!==1)throw new k("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 i=Math.max(0,Math.trunc(this.n));i!==this.n&&(n.diagnostics.push(new U("W_DOT_INVALID_N",`@dot \u7684\u6570\u91CF\u53C2\u6570 n \u5FC5\u987B\u4E3A\u975E\u8D1F\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A ${i}`,this.sourceSpan)),this.n=i)}toString(t){return`@dot(${this.content.toString(t)}, ${this.n})`}},Si=xo;var yo=class extends O{static def={name:["dyn"],description:"\u6E10\u5F3A\u6E10\u5F31",details:`~~~jpfun
15
+ 1 ^ $p 2@a 3 4@b
16
+ @dyn(a, b, 24)
16
17
  ~~~
17
- \u65E0\u53C2\u6570\u3002\u6DFB\u52A0\u4E00\u6839\u589E\u65F6\u7EBF\uFF0C\u5EF6\u7EED\u524D\u65B9\u97F3\u7B26\u7684\u53D1\u58F0\uFF1B\u4E5F\u53EF\u7B80\u5199\u4E3A \`1 -\`\u3002\u6BCF\u6839\u7EBF\u7684\u57FA\u7840\u65F6\u503C\u4E3A\u4E00\u4E2A\u56DB\u5206\u97F3\u7B26\uFF0C\u53EF\u7528\u51CF\u65F6\u7EBF\u6216\u9644\u70B9\u8C03\u6574\u3002`,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 Yn(this)]}toString(){return"-"}},Vs=Un,Yn=class extends Q{lineWidth=0;lineY=0;constructor(t){super(),this.ast=t,this.T.set(1),this.mergeKey=Ct,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,i=this.ast.sourceSpan;t.defer(r=>{let a;for(let c=r.events.length-1;c>=0;c--){let l=r.events[c];if(!(l.kind!=="note-off"||l.origins.at(-1).node.track!==o)){if(a===void 0){if(!l.at.equals(e))continue;a=l.origins[0]}else if(l.origins[0]!==a)break;l.at.equals(e)&&l.at.copyFrom(n)}}a===void 0&&r.diagnostics.push(new G("W_PLAYBACK_SUSTAIN_WITHOUT_TARGET","\u589E\u65F6\u7EBF\u524D\u6CA1\u6709\u53EF\u5EF6\u7EED\u7684\u53D1\u58F0\u97F3\u7B26",i))})}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 Ys="dot",js=Bt(Ys);function Us(s){let t=2**s;return[2*t-1,t]}var Kn=class s extends P{static def={name:[Ys,"."],description:"\u9644\u70B9",details:"~~~jpfun\n@dot(1, n=2)\n~~~\n**\u7B80\u5199**\uFF1A\u76EE\u6807\u540E\u52A0 `.`\uFF0C\u53EF\u91CD\u590D\u3002`@dot(1, 2)` \u7B49\u4EF7\u4E8E `1..`\uFF1B`{1^2}.` \u7B49\u4EF7\u4E8E `{1.^2}`\u3002\n\n`@dot({1 2/ -}, 2)` \u5305\u542B\u591A\u4E2A\u65F6\u95F4\u5143\u7D20\uFF0C\u4F1A\u62A5\u9519\uFF1B\u9700\u8981\u5206\u522B\u4E3A\u5404\u5143\u7D20\u6DFB\u52A0\u9644\u70B9\u3002",allowExtraArgs:!1,args:[{type:"content",description:"\u5355\u4E2A\u53EF\u89C1\u65F6\u95F4\u5143\u7D20\uFF0C\u5982\u97F3\u7B26\u3001\u589E\u65F6\u7EBF\u6216\u6298\u53E0\u548C\u5F26",default:null},{name:"n",description:"\u9644\u70B9\u6570\uFF0C\u7B2C\u4E00\u70B9\u589E\u52A0\u539F\u65F6\u503C\u7684\u4E00\u534A\uFF0C\u540E\u7EED\u5404\u70B9\u589E\u52A0\u91CF\u518D\u51CF\u534A",type:"number",default:1}]};static deSugarAtom(t,e,n){let o=0,i=e;for(;i<n&&t[i]===".";)o++,i++;return o===0?null:{next:i,node:{kind:"sugar",data:{class:s,n:o},span:{start:e,end:i}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==s)return null;let i=P.findLastFuncContentNode(t.nodes,t.nodes.length-1);if(!i)return n;if(i instanceof s)return i.n+=o.data.n,n;let r=new Map;r.set(0,i),r.set("n",o.data.n);let a=i.sourceSpan,c=new s({start:Math.min(a.start,o.span.start),end:Math.max(a.end,o.span.end)},r,t,null);return t.nodes.pop(),t.pushNode(c),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,i=t.ast.size*.12,r=t.ports.dot??{x:t.box.w,y:t.box.visualAxis},a=r.x+i+o,c=o*2+i,l=a+(n-1)*c+o;return t.box.w=Math.max(t.box.w,l),{paint(h){let p=t.box.y+r.y;for(let u=0;u<n;u++)h.drawCircle(t.box.x+a+u*c,p,o,{fill:"#000"})}}};loweringEnter(t){let e=this.n,n={temporalCount:0,onTemporal(o){if(n.temporalCount++,e===0)return;let i=o.addon??={},r=Number(i[js])||0,a=r+e,[c,l]=Us(a),[h,p]=Us(r);o.T.mul(c*p,l*h),i[js]=a}};return t.beginLoweringGroup(this,n),[]}loweringExit(t){let e=t.endLoweringGroup(this);if(e.temporalCount!==1)throw new k("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 i=Math.max(0,Math.trunc(this.n));i!==this.n&&(n.diagnostics.push(new G("W_DOT_INVALID_N",`@dot \u7684\u6570\u91CF\u53C2\u6570 n \u5FC5\u987B\u4E3A\u975E\u8D1F\u6574\u6570\uFF0C\u5DF2\u88AB\u4FEE\u6B63\u4E3A ${i}`,this.sourceSpan)),this.n=i)}toString(t){return`@dot(${this.content.toString(t)}, ${this.n})`}},Ks=Kn;var Xn=class extends P{static def={name:["dyn"],description:"\u6E10\u5F3A\u6E10\u5F31",details:"~~~jpfun\n1 ^ $p 2@a 3 4@b\n@dyn(a, b, 24)\n~~~\n\u7AEF\u70B9\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68\u3001\u4E0D\u540C\u65F6\u95F4\uFF1B\u53D8\u5316\u91CF\u6CBF\u533A\u95F4\u7EBF\u6027\u589E\u52A0\uFF0C\u53E0\u52A0\u5728\u6BCF\u4E2A\u97F3\u7B26\u539F\u6709\u529B\u5EA6\u4E0A\u3002\u672C\u4F8B\u4ECE `a` \u5230 `b` \u6E10\u5F3A\uFF0C\u7EC8\u70B9\u589E\u52A0 24 \u7684\u529B\u5EA6\u3002",allowExtraArgs:!1,args:[{name:"from",description:"\u6E10\u53D8\u8D77\u70B9\u7684\u6807\u7B7E",type:"label",default:null},{name:"to",description:"\u6E10\u53D8\u7EC8\u70B9\u7684\u6807\u7B7E",type:"label",default:null},{name:"dv",description:"\u529B\u5EA6\u53D8\u5316\u91CF\uFF0C\u6B63\u6570\u6E10\u5F3A\uFF0C\u8D1F\u6570\u6E10\u5F31",type:"number",default:null}]};static loweringFinalize=t=>{let e=t.attachments.filter(o=>o instanceof Se);if(e.length===0)return;let n=[];for(let o of t.astToTemporal.values())for(let i of o){let r=i.playbackState?.velocity;if(r===void 0)continue;let a=i;for(;a.foldedInto;)a=a.foldedInto;n.push({node:i,host:a,velocity:r,increment:0})}n.sort((o,i)=>o.host.t.compare(i.host.t)||o.node.order-i.node.order);for(let o of e){let i=o.end.playbackState?.velocity??n.find(c=>c.host===o.toHost)?.velocity;if(i===void 0)throw new Error("@dyn end endpoint has no velocity-bearing member");let r=n.find(c=>c.host.track===o.track&&c.host.t.compare(o.toHost.t)>0&&c.velocity!==i)?.host.t,a=o.toHost.t.clone().sub(o.fromHost.t);for(let c of n){if(c.host.track!==o.track||c.host.t.compare(o.fromHost.t)<0||r&&c.host.t.compare(r)>=0)continue;let h=c.host.t.compare(o.toHost.t)>=0?1:c.host.t.clone().sub(o.fromHost.t).div(a).toNumber();c.increment+=o.dv*h}}for(let o of n){if(o.increment===0)continue;let i=Math.max(1,Math.min(127,o.velocity+o.increment));o.node.playbackState={...o.node.playbackState,velocity:i}}};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(D.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];let o=e,i=n;for(;o.foldedInto;)o=o.foldedInto;for(;i.foldedInto;)i=i.foldedInto;if(!U(o)||!U(i))return t.diagnostics.push(D.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];if(o.track!==i.track)throw new k("E_DYN_CROSS_TRACK","@dyn \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68",this.sourceSpan);if(o.t.equals(i.t))throw new k("E_DYN_ZERO_SPAN","@dyn \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u4E0D\u540C\u65F6\u95F4",this.sourceSpan);return o.t.compare(i.t)<0?t.addAttachment(new Se(this,n,o,i)):t.addAttachment(new Se(this,e,i,o)),[]}constructor(t,e,n,o=null){super(t,o);let[i,r,a]=this.getArgValue(e,n),c=a;if(!Number.isFinite(c)||c===0)throw new k("E_DYN_INVALID_DELTA","@dyn \u7684 dv \u5FC5\u987B\u662F\u975E\u96F6\u6709\u9650\u6570",t);c=Math.max(-127,Math.min(127,c)),c!==a&&n.diagnostics.push(new G("W_DYN_DELTA_CLAMPED",`@dyn \u7684 dv \u5FC5\u987B\u5728 -127 \u5230 127 \u4E4B\u95F4\uFF0C\u5DF2\u88AB\u9650\u5236\u4E3A ${c}`,t)),this.from=i,this.to=r,this.dv=c,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})`}},Xs=Xn,Se=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=f=>{let y=t.lines[f.layoutLine];return{line:f.layoutLine,view:y,column:y?.columnOf(f)??-1}},n=e(this.fromHost),o=e(this.toHost);if(!n.view||!o.view||n.column<0||o.column<0)return{regions:[],paint(){}};let i=[],r=this.ast.size;for(let f=n.line;f<=o.line;f++){let y=t.lines[f],g=f===n.line?n.column:0,d=f===o.line?o.column:y.columns.length-1,x=-1,b=-1;for(let w=g;w<=d;w++)for(let N of y.columns[w])N.track===this.track&&(x=x<0?w:x,b=w,r=Math.max(r,N.ast.size));x<0||i.push({line:f,startX:f===n.line?this.fromHost.box.x:this.lineEntryX(t,f),endX:f===o.line?this.toHost.box.x+this.toHost.box.w:this.lineRightX(t,f),columns:[x,b]})}for(let f of i)f.line>n.line&&(f.startX-=r/4);let a=Math.max(.75,r*.035),c=i.filter(f=>f.startX!==f.endX),l=c.reduce((f,y)=>f+Math.abs(y.endX-y.startX),0);if(l===0)return{regions:[],paint(){}};let h=r*.4,p=a/2,u=0,m=c.map(f=>{let y=Math.abs(f.endX-f.startX),g=u/l,d=(u+y)/l;u+=y;let x=t.getRangeExtents(f.line,f.columns).get(this.track),b=t.getVisualAxis(f.line,this.track),w=x?b+x.top:b;return{line:f.line,startX:f.startX,endX:f.endX,lineY:w-r*.62,startOpen:h*(this.dv>0?g:1-g),endOpen:h*(this.dv>0?d:1-d)}});return{regions:m.map(f=>({x:Math.min(f.startX,f.endX)-p,y:f.lineY-Math.max(f.startOpen,f.endOpen)/2-p,w:Math.abs(f.endX-f.startX)+a,h:Math.max(f.startOpen,f.endOpen)+a,line:f.line,track:this.track})),paint(f){let y={stroke:"#000",strokeWidth:a};for(let g of m)f.drawLine(g.startX,g.lineY-g.startOpen/2,g.endX,g.lineY-g.endOpen/2,y),f.drawLine(g.startX,g.lineY+g.startOpen/2,g.endX,g.lineY+g.endOpen/2,y)}}}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 i of n.values())for(let r of i)o=Math.max(o,r.box.x+r.box.w);return o}};var ae=.7,Zs="shoulder";function Qs(s,t){let e=s;typeof e.size=="number"&&(e.size*=t);for(let n of s.children??[])Qs(n,t)}var Zn=class s extends P{static def={name:["grace"],description:"\u501A\u97F3",details:"~~~jpfun\n@grace(1, {3 2}, side=pre)\n~~~\n**\u7B80\u5199**\uFF1A\u7BAD\u5934\u59CB\u7EC8\u6307\u5411\u5BBF\u4E3B\n- `2>1`\uFF1A`2` \u662F `1` \u7684\u524D\u501A\u97F3\uFF0C\u4F4D\u4E8E\u5DE6\u4E0A\u65B9\n- `1<2`\uFF1A`2` \u662F `1` \u7684\u540E\u501A\u97F3\uFF0C\u4F4D\u4E8E\u53F3\u4E0A\u65B9\n- `{3 2}>1`\uFF1A\u4E00\u7EC4\u524D\u501A\u97F3\uFF0C\u7B49\u4EF7\u4E8E\u4E0A\u4F8B\n- `1>2>3`\uFF1A\u5141\u8BB8\u5D4C\u5957\uFF0C`1` \u4FEE\u9970 `2`\uFF0C`2` \u4FEE\u9970 `3`\n\n\u501A\u97F3\u9ED8\u8BA4\u5E26\u4E00\u6761\u51CF\u65F6\u7EBF\uFF0C\u6309\u516B\u5206\u97F3\u7B26\u4E66\u5199\uFF1B\u518D\u52A0 `/` \u53D8\u4E3A\u5341\u516D\u5206\u97F3\u7B26",allowExtraArgs:!1,args:[{name:"host",description:"\u88AB\u501A\u97F3\u4FEE\u9970\u7684\u5BBF\u4E3B\u5185\u5BB9",type:"content",default:null},{name:"grace",description:"\u501A\u97F3\u5185\u5BB9\uFF0C\u591A\u4E2A\u97F3\u7B26\u53EF\u7528\u5927\u62EC\u53F7\u7EC4\u5408",type:"content",default:null},{name:"side",description:"`pre` \u4E3A\u524D\u501A\u97F3\uFF0C`post` \u4E3A\u540E\u501A\u97F3",type:"string",default:"pre"}]};labelable(){return P.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:s,side:o},span:{start:e,end:e+1}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.kind!=="sugar"||o.data?.class!==s)return null;let i=o.data.side,r=t.nodes.length-1;for(;r>=0&&t.nodes[r]instanceof at;)r--;if(r<0)throw new k("E_GRACE_NO_TARGET","@grace\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u76EE\u6807",o.span);let a=t.nodes[r],c=r;if(a instanceof Lt){let h=a.target;for(;h&&!t.nodes.includes(h);)h=h.parent;for(let p=r-1;p>=0;p--)if(t.nodes[p]===h){a=new rt({start:h.sourceSpan.start,end:a.sourceSpan.end},t.nodes.slice(p,r+1),null),c=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 at)continue;let u=i==="pre"?s.attachPre(a,p,o.span,t):s.create(t,o.span,"post",a,p);for(l.length=c,l.push(u);++h<t.nodes.length;)l.push(t.nodes[h]);return t.nodes=l,e.length}throw new k("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 s&&e.side==="pre"){let i=e,r=1;for(;i.grace instanceof s&&i.grace.side==="pre";)i=i.grace,r++;let a=new Map;a.set(0,i.grace),a.set(1,t);let c=ae**r,l=new s(n,a,o,null,ae*c);return l.size*=c,i.setGrace(l,1),e}return s.create(o,n,"pre",e,t)}static create(t,e,n,o,i){let r=new Map;return r.set(0,o),r.set(1,i),r.set("side",n),new s(e,r,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,i=ae){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 k("E_GRACE_INVALID_SIDE","@grace \u7684 side \u53C2\u6570\u5FC5\u987B\u662F 'pre' \u6216 'post'",t);this.adopt(this.host),this.setGrace(this.grace,i)}setGrace(t,e=ae){Qs(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 k("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 r=this.side==="pre"?[this.grace,this.host]:[this.host,this.grace];for(let a of r){let c=t.trackedEvents(a,new z,e).flat(),l=c.filter(U);if(c.some(h=>h.track!==e))throw new k("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 ^",a.sourceSpan);if(a===this.host){if(l.length!==1||l.length!==c.length)throw new k("E_GRACE_INVALID_HOST","@grace \u7684\u5BBF\u4E3B\u5FC5\u987B\u6070\u597D\u4EA7\u751F\u4E00\u4E2A\u53EF\u89C1 Temporal",a.sourceSpan);o=l[0]}else{if(l.length===0||l.length!==c.length)throw new k("E_GRACE_INVALID_CONTENT","@grace \u7684\u501A\u97F3\u5FC5\u987B\u53EA\u4EA7\u751F\u53EF\u89C1 Temporal\uFF0C\u4E14\u81F3\u5C11\u4E00\u4E2A",a.sourceSpan);n=l}}});let i=new qn(this,o,n,this.side);for(let r of i.graceRuns)r.length<2||t.addAttachment(re([...r],!1,this.grace.sourceSpan));return[i]}toString(t){let e=this.host?.toString(t)??"",n=this.grace?.toString(t)??"";return`@grace(${e}, ${n}, side=${this.side})`}},Js=Zn,la=[{op:"M",x:0,y:0},{op:"C",cx1:-.01,cy1:.26,cx2:.14,cy2:.42,x:.29,y:.36}],ha=.07,pa=.18,qs=new z(3,4),qn=class extends Q{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 i=[],r=[];for(let a of n){if(a.foldedInto=this,a.T.isZero()){r.length>0&&i.push(r),r=[];continue}r.push(a);let c=a.addon={...a.addon};c[Ht]=(Number(c[Ht])||0)+1,a.T.divPow2()}r.length>0&&i.push(r),this.graceRuns=i}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 z;for(let l of this.graces)e.add(l.T);let n=e.compare(qs)>0?qs:e,o=t.end.clone().sub(t.start),i=o.clone().mul(n),r=o.sub(i),a=t.start.clone(),c=l=>{for(let h of this.graces){if(h.T.isZero()||e.isZero()){t.play(h,l,new z);continue}let p=i.clone().mul(h.T).div(e);t.play(h,l,p),l.add(p)}};if(this.side==="pre"){let l=a.clone();c(l),t.play(this.host,l,r)}else t.play(this.host,a,r),c(a.clone().add(r))}prepareLayout(t){this.addon&&(this.host.addon=this.addon,this.addon=void 0);for(let y of this.graces)Nt(y,t);Nt(this.host,t);let n=this.ast.size*ae,o=n*.16,i=n*.2,r=n*pa,a=0,c=0,l=0;for(let y of this.graces)c=Math.max(c,y.box.visualAxis);this.graceOffsets=this.graces.map(y=>{let g=a;a+=y.box.w+o;let d=c-y.box.visualAxis;return l=Math.max(l,d+y.box.h),{x:g,y:d}}),this.graces.length>0&&(a-=o);let p=(this.host.ports[Zs]?.y??0)-r-l,u=Math.max(0,-p),m=this.side==="pre"?0:this.host.box.w+i;this.hostOffset={x:this.side==="pre"?a+i:0,y:u};for(let y of this.graceOffsets)y.x+=m,y.y+=p+u;this.box.w=this.host.box.w+i+a,this.box.h=u+this.host.box.h,this.box.anchor=this.hostOffset.x+this.host.box.anchor,this.box.visualAxis=u+this.host.box.visualAxis;for(let y in this.host.ports){let g=this.host.ports[y];this.ports[y]={x:this.hostOffset.x+g.x,y:this.hostOffset.y+g.y}}this.ports[Zs]??={x:this.box.anchor,y:this.hostOffset.y};let f=this.side==="pre"?this.graceRuns.at(-1)?.at(-1):this.graceRuns[0]?.[0];this.hookOrigin=f?{x:this.graceOffsets[this.graces.indexOf(f)].x+f.box.anchor,y:p+u+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 i of[this.host,...this.graces]){i.paint(t);for(let r of i.decorations)r.paint(t)}if(!this.hookOrigin)return;let e=this.ast.size*ae,n=this.hookOrigin,o=this.side==="pre"?1:-1;t.drawPath(la,{stroke:"#000",strokeWidth:Math.max(.8,e*ha)},{x:this.box.x+n.x,y:this.box.y+n.y,scaleX:e*o,scaleY:e})}};var ce="sans-serif",Jn="'Cascadia Mono', Consolas, 'Liberation Mono', 'Noto Sans Mono', monospace";function Ze(s){return`${s.fontWeight??"normal"} ${s.fontSize}px ${s.fontFamily??ce}`}var Xe=class{measureText(t,e){let n=e.fontSize,o=e.fontFamily?.toLowerCase().includes("mono")??!1,i=0;for(let r of t)i+=r.charCodeAt(0)>127?1:o?.62:.58;return{w:Math.max(i*n,n*.25),h:n,baseline:n*.8}}},to=new Xe,Qn=class{context;widths=new Map;constructor(t){this.context=t}clearCache(){this.widths.clear()}measureText(t,e){let n=Ze(e),o=`${n}\0${t}`,i=this.widths.get(o);return i===void 0&&(this.context.font=n,i=this.context.measureText(t).width,this.widths.set(o,i)),{w:Math.max(i,e.fontSize*.25),h:e.fontSize,baseline:e.fontSize*.8}}};var ua=/[A-Za-z0-9_./-]/;function ei(s,t,e){let n=t+1;for(;n<e&&ua.test(s[n]);)n++;let o=s.slice(t+1,n);if(!o||n>=e||s[n]!=="(")return null;let i=n,r=1,a=0,c=null,l=!1,h=[],p=i+1,u=(f,y,g=!1)=>{let d=Ae(s,p,f);if(!g&&d.start>=d.end)return;let x=fa(s,d.start,d.end),b=x>d.start?Ae(s,d.start,x):void 0,w=x>d.start?Ae(s,x+1,d.end):d;h.push({span:d,valueSpan:w,nameSpan:b,equalsSpan:x>d.start?{start:x,end:x+1}:void 0,commaSpan:y===void 0?void 0:{start:y,end:y+1}})},m=(f,y)=>({name:o,span:{start:t,end:f},nameSpan:{start:t,end:i},openParenSpan:{start:i,end:i+1},closeParenSpan:y,args:h});for(n++;n<e;n++){let f=s[n];if(c){l?l=!1:f==="\\"?l=!0:f===c&&(c=null);continue}if(f==='"'){c=f;continue}if(f==="{")a++;else if(f==="}")a=Math.max(0,a-1);else if(f==="("&&a===0)r++;else if(f===")"&&a===0){if(--r)continue;return u(n),m(n+1,{start:n,end:n+1})}else f===","&&r===1&&a===0&&(u(n,n,!0),p=n+1)}return u(e),m(e)}var ti=/\s/;function Ae(s,t,e){let n=t,o=e;for(;n<o&&ti.test(s[n]);)n+=1;for(;o>n&&ti.test(s[o-1]);)o-=1;return{start:n,end:o}}function fa(s,t=0,e=s.length){let n=0,o=0,i=null,r=!1;for(let a=t;a<e;a++){let c=s[a];if(i){r?r=!1:c==="\\"?r=!0:c===i&&(i=null);continue}if(c==='"')i=c;else if(c==="("&&o===0)n++;else if(c===")"&&o===0)n=Math.max(0,n-1);else if(c==="{")o++;else if(c==="}")o=Math.max(0,o-1);else if(c==="="&&n===0&&o===0)return a}return-1}function ni(s,t,e){let n=1,o=null,i=!1;for(let r=t;r<e;r++){let a=s[r];if(o){i?i=!1:a==="\\"?i=!0:a===o&&(o=null);continue}if(a==='"')o=a;else if(a==="(")n++;else if(a===")"&&--n===0)return r}return-1}function le(s,t,e){for(let n=t+1;n<e;n++)if(s[n]==="\\")n++;else if(s[n]==='"')return n;return-1}function Gt(s){return s.length<2||!s.startsWith('"')||!s.endsWith('"')?s:s.slice(1,-1).replace(/\\(.)/gs,"$1")}function ht(s){return`"${s.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function oi(s,t,e){let n=1,o=null,i=!1;for(let r=t+1;r<e;r++){let a=s[r];if(o){i?i=!1:a==="\\"?i=!0:a===o&&(o=null);continue}if(a==='"')o=a;else if(a==="{")n++;else if(a==="}"&&(n--,n===0))return r}return-1}var da=/\s|\(|\)|\{|\}|,/;function si(s,t,e){let n=t+1;for(;n<e&&!da.test(s[n]);)n++;return n<=t+1?null:{label:s.slice(t+1,n),next:n}}var ma=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]+)?$/i,xa=["em","px"];function eo(s){let t=s.match(ma);if(!t)return D.warning.InvalidLength(s,{start:0,end:s.length});let e=parseFloat(t[1]);if(t[2]){let n=t[2].toLowerCase();return xa.includes(n)?{value:e,unit:n}:D.warning.InvalidLengthUnit(n,{start:t[1].length,end:s.length})}else return{value:e,unit:"px"}}var ii=/^(true|false)$/;function ya(s,t){if(s)return s==="content"?void 0:s;if(ii.test(t))return"boolean";if(t.startsWith('"'))return"string";if(!isNaN(Number(t)))return"number";if(!(eo(t)instanceof D))return"length"}var ri=22,ga=4,wt=class s{static systemVariables={fontsize:{type:"length",default:ri},font:{type:"string",default:ce},numberfont:{type:"string",default:Jn},strict:{type:"boolean",default:!1}};scopeDepth;source;syntax;diagnostics;variables;documentDeclarations;functions;deSugarAtomFns;deSugarRelationFns;labelableNodes;nodes;constructor(t){t instanceof s?(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(s.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]=s.getDeSugarFns(this.functions.values()):(this.deSugarAtomFns=[],this.deSugarRelationFns=[]))}static getDeSugarFns(t){let e=new Set(t),n=[],o=[];for(let i of e){let r=i.deSugarAtom;r&&r!==P.deSugarAtom&&n.push(r);let a=i.deSugarRelation;a&&a!==P.deSugarRelation&&o.push(a)}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(s.systemVariables,t)&&(t==="fontsize"&&e&&(e=this.length2px(e)),(e===void 0||e===""||e===0)&&(e=s.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 i=Array.isArray(o.name)?o.name:[o.name];for(let r of i){if(e.has(r.toLowerCase()))throw new Error(`Duplicate function name detected: ${r}`);e.set(r.toLowerCase(),n)}}[this.deSugarAtomFns,this.deSugarRelationFns]=s.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,i)=>o.span.start-i.span.start||o.span.end-i.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 a=Math.min(this.source.length,t.span.end-1);this.source[a]==="}"&&this.addSyntax("punctuation",{start:a,end:a+1}),new s(this).parseSyntax(t.span.start+1,a);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,...i}=t;this.syntax.calls.push(i),this.addSyntax("function",i.nameSpan),this.addSyntax("punctuation",i.openParenSpan),this.addSyntax("punctuation",i.closeParenSpan);let r=this.functions.get(i.name.toLowerCase())?.def;for(let a=0;a<i.args.length;a++){let c=i.args[a];this.addSyntax("property",c.nameSpan),this.addSyntax("punctuation",c.equalsSpan),this.addSyntax("punctuation",c.commaSpan);let l=c.nameSpan?this.source.slice(c.nameSpan.start,c.nameSpan.end).toLowerCase():void 0,h=r&&te(r,l,a);if(h==="content")new s(this).parseSyntax(c.valueSpan.start,c.valueSpan.end);else{let p=this.source.slice(c.valueSpan.start,c.valueSpan.end),u=ya(h,p);u&&this.addSyntax(u,c.valueSpan)}}}makeNodes(t,e=0,n=t.length){t:for(;e<n;e++){let o=t[e];if(typeof o=="number"){let i=this.nodes.at(-1);i instanceof at&&i.sourceSpan.end===o?i.sourceSpan.end=o+1:this.nodes.push(new at({start:o,end:o+1},null));continue}switch(o.kind){case"call":this.pushNode(this.parseCallNode(o));break;case"brace":let i=new s(this);this.nodes.push(new rt(o.span,i.parse(o.span.start+1,o.span.end-1),null));break;case"label":let r=this.labelableNodes.at(-1);r?r.label!==void 0?this.diagnostics.push(D.warning.TargetAlreadyLabeled(o.label,r.label,o.span)):(r.label=o.label,this.nodes.push(new Lt(o.span,o.label,r))):this.diagnostics.push(D.warning.LabelWithoutTarget(o.label,o.span));break;case"sugar":for(let c of this.deSugarRelationFns){let l=c(this,t,e);if(l!==null){e=l-1;continue t}}let a=this.nodes.at(-1);a instanceof at&&a.sourceSpan.end===o.span.start?a.sourceSpan.end=o.span.end:this.nodes.push(new at(o.span,null));break}}return e}parseGrammar(t,e,n=!1){let o=[],i=r=>{o.push(r),n&&this.recordSyntax(r)};t:for(;(t=It(this.source,t,e))<e;){let r=this.source[t];if(r==="@"){let a=ei(this.source,t,e);if(a){i(Object.assign(a,{kind:"call",typed:!1}));let l=!1;for(let h of a.args){let p=h.nameSpan!==void 0;if(p&&!l)l=!0;else if(!p&&l){let u=D.error.PosAfterNamedArg(a.name,h.span);if(!n)throw u;this.diagnostics.push(u)}}if(!a.closeParenSpan){let h=D.error.UnterminatedCall(a.name,a.span);if(!n)throw h;this.diagnostics.push(h)}t=a.span.end;continue}let c=si(this.source,t,e);if(c){i({kind:"label",span:{start:t,end:c.next},label:c.label}),t=c.next;continue}}if(r==="{"){let a=oi(this.source,t,e);(a<0||a>=e||a<=t)&&(this.diagnostics.push(D.warning.UnmatchedBrace({start:t,end:e})),a=e),i({kind:"brace",span:{start:t,end:a+1}}),t=a+1;continue}for(let a of this.deSugarAtomFns)try{let c=a(this.source,t,e,this.scopeDepth);if(c){i(c.node),t=c.next;continue t}}catch(c){throw c instanceof D?this.diagnostics.push(c):this.diagnostics.push(D.error.Bug(c.toString(),{start:t,end:e})),c}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 D.error.UnknownFunction(t.name,t.span);return this.diagnostics.push(D.warning.UnknownFunction(t.name,t.span)),new P(t.span,null)}let o=n.args;if(!t.typed){let i=new Map;for(let r=0;r<t.args.length;r++){let a=t.args[r],c=a.nameSpan?this.source.slice(a.nameSpan.start,a.nameSpan.end).toLowerCase():void 0,l=te(n,c,r),h=c??r;if(l===void 0){n.allowExtraArgs?i.set(h,a):this.diagnostics.push(D.warning.TooManyPosArgs(t.name,o.length,r+1,a.valueSpan));continue}let p=this.parseArgWithType(a.valueSpan,l,t.span.start);p!==null&&i.set(h,p)}return new e(t.span,i,this,null)}return new e(t.span,t.args,this,null)}parseArgWithType(t,e,n){let o=Ae(this.source,t.start,t.end),i=o.start,r=o.end;if(i>=r)return null;let a=e==="content"?"":this.source.slice(i,r);switch(e){case"number":let c=Number(a);return isNaN(c)?(this.diagnostics.push(D.warning.InvalidNumber(a,o)),null):c;case"boolean":let l=a;return ii.test(l)?l==="true":(this.diagnostics.push(D.warning.InvalidBoolean(a,o)),null);case"content":{let u=this.labelableNodes,m=u.length,f=u.at(-1),y=f?.label,g=f&&Object.hasOwn(f,"label");try{let x=new s(this).parse(i,r);return x.length===1?x[0]:new rt(o,x,null)}catch(d){if(u.length=m,f&&(g?f.label=y:delete f.label),this.variables.strict||!(d instanceof D))throw d;return this.diagnostics.push(d,D.warning.InvalidContent(o)),null}}case"label":n??=t.start;for(let u=this.labelableNodes.length-1;u>=0;u--){let m=this.labelableNodes[u];if(m&&!(m.sourceSpan.start>=n)&&m.label==a)return m}throw D.error.UnknownLabel(a,o);case"length":let h=eo(a);return h instanceof D?(h.span.start+=i,h.span.end+=i,this.diagnostics.push(h),null):h;default:return Gt(a)}return null}length2px(t){return t.unit==="em"?t.value*this.variables.fontsize:t.value}};function It(s,t,e){for(;t<e&&ai(s[t]);)t++;return t}function Te(s,t,e=0){for(;t>=e&&ai(s[t]);)t--;return t}function ai(s){switch(s){case" ":case" ":case"\v":case"\f":case"\xA0":case"\uFEFF":case"\u3000":return!0;default:return!1}}var ba=/^[A-GXZ]/,qe=/^[0-9]/,Qe=/^[#bn]+/,ci=/^[+-]?\d+/,li=/^[,']+/;function Le(s,t=0,e=s.length){if(e-t===0)return new k("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,i=null,r=null,a=!1,c;for(let l=t;l<e;l++){let h=s[l];switch(n){case 0:if(ba.test(h))o=h,a=!0,n=1;else if(qe.test(h))o=h,a=!1,n=3;else{let u=s.slice(l,e).match(Qe);if(u)i=u[0],l+=i.length-1,a=!1,n=2;else return new k("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=s.slice(l,e);if(c=p.match(ci),c){r=parseInt(c[0],10),l+=c[0].length-1,n=4;break}if(c=p.match(Qe),c){i=c[0],l+=i.length-1,n=5;break}return{name:o,next:l,acc:null,octave:null,absOctave:a};case 2:if(qe.test(h)){o=h,n=6;break}else return new k("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(c=s.slice(l,e).match(li),c){let u=c[0];return r=hi(u),{name:o,next:l+u.length,acc:i,octave:r,absOctave:a}}if(c=s.slice(l,e).match(Qe),c&&!qe.test(s[l+c[0].length]??"")){let u=c[0];i=u,l+=u.length-1,n=6;break}return{name:o,next:l,acc:i,octave:r,absOctave:a};case 4:if(c=s.slice(l,e).match(Qe),c&&!qe.test(s[l+c[0].length]??"")){let u=c[0];return i=u,{name:o,next:l+u.length,acc:i,octave:r,absOctave:a}}return{name:o,next:l,acc:null,octave:r,absOctave:a};case 5:return c=s.slice(l,e).match(ci),c?(r=parseInt(c[0],10),{name:o,next:l+c[0].length,acc:i,octave:r,absOctave:a}):{name:o,next:l,acc:i,octave:null,absOctave:a};case 6:if(c=s.slice(l,e).match(li),c){let u=c[0];return r=hi(u),{name:o,next:l+u.length,acc:i,octave:r,absOctave:a}}return{name:o,next:l,acc:i,octave:r,absOctave:a};default:return D.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 k("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:i,octave:r,absOctave:a}}function hi(s){let t=0;for(let e=0;e<s.length;e++)s[e]===","?t--:s[e]==="'"&&t++;return t}var Et={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},Je=["C","D","E","F","G","A","B"],no=[0,2,4,5,7,9,11];function Ce(s,t){let e=s[0],n="",o=1;o<s.length&&(s[o]==="#"||s[o]==="b"||s[o]==="n")&&(n=s[o],o++);let i=Et[e+n];if(i===void 0)throw D.error.InvalidTonality(s,{start:0,end:o});if(o<s.length&&(t=parseInt(s.slice(o),10),isNaN(t)))throw D.error.InvalidTonality(s,{start:o,end:s.length});return(t+1)*12+i}function so(s,t=!0,e=0){for(let n of s)n==="#"?e++:n==="b"?e--:n==="n"&&!t&&(e=0);return e}function io(s,t,e,n){let o=Et[s];if(o===void 0)return null;let i=so(t);return s>="1"&&s<="7"?Ce(n,4)+o+i+e*12:(e+1)*12+o+i}function pi(s,t,e,n){let o,i;if(s>="1"&&s<="7")o=Number(s)-1,i=e;else{let c=ro(s,t,e,n);if(!c)return;o=Number(c.renderName)-1,i=c.renderOctave}let r=Ce(n,4),a=i*7+o;return c=>{let l=a+c,h=Math.floor(l/7);return r+no[(l%7+7)%7]+h*12}}function oo(s){return(s%12+12)%12}function wa(s){let t=oo(s);return t>6?t-12:t}function Sa(s){return s===0?"":s>0?"#".repeat(s):"b".repeat(-s)}function ro(s,t,e,n){let o=Je.indexOf(n[0]),i=Je.indexOf(s),r=io(s,t,e,n);if(o<0||i<0||r===null)return null;let a=Ce(n,4),c=(i-o+Je.length)%Je.length,l=oo(a+no[c]),h=wa(oo(r)-l),p=(r-a-no[c]-h)/12;return{renderName:String(c+1),renderAcc:Sa(h),renderOctave:p}}var Aa={"#":{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 Ta(s,t){let e=Aa[s];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 tn(s,t,e,n,o){let i=[],r=t*.42,a=e,c=0;for(let l of s){let h=Ta(l,t);if(!h)continue;let p=n-h.baseline-r;i.push({shape:h,x:a,y:p}),p<c&&(c=p),a+=h.w+o}return{placed:i,right:a,top:c}}function en(s,{shape:t,x:e,y:n},o,i){s.drawPath(t.commands,{stroke:i,strokeWidth:t.strokeWidth},{x:o.x+e,y:o.y+n,scaleX:t.w,scaleY:t.h})}function La(s){try{return Ce(s,4),s}catch{}let t=Le(s.replace(/^[a-g]/,a=>a.toUpperCase()));if(t instanceof D)return null;let e=Et[t.name];if(e===void 0)return null;let n=so(t.acc??"",!1),i=((t.absOctave?t.octave??4:4+(t.octave??0))+1)*12+e+n,r=Object.keys(Et).filter(a=>Et[a]===(i%12+12)%12&&/^[A-G]/.test(a));return(n<0?r.at(-1):r[0])+(Math.floor(i/12)-1)}var co=class extends P{static def={name:["key","1"],description:"\u8BBE\u7F6E\u65F6\u95F4\u7EBF\u4E0A\u7684 1= \u8C03\u6027\u57FA\u51C6",details:`~~~jpfun
18
+ \u7AEF\u70B9\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68\u3001\u4E0D\u540C\u65F6\u95F4\uFF1B\u53D8\u5316\u91CF\u6CBF\u533A\u95F4\u7EBF\u6027\u589E\u52A0\uFF0C\u53E0\u52A0\u5728\u6BCF\u4E2A\u97F3\u7B26\u539F\u6709\u529B\u5EA6\u4E0A\u3002\u672C\u4F8B\u4ECE \`a\` \u5230 \`b\` \u6E10\u5F3A\uFF0C\u7EC8\u70B9\u589E\u52A0 24 \u7684\u529B\u5EA6\u3002
19
+
20
+ \u7AEF\u70B9\u4E5F\u53EF\u6807\u5728\u589E\u65F6\u7EBF\u4E0A\u3002\u7EC8\u70B9\u6CA1\u6709\u529B\u5EA6\u65F6\uFF0C\u53D6\u540C\u8F68\u3001\u4E0D\u665A\u4E8E\u7EC8\u70B9\u7684\u6700\u540E\u4E00\u4E2A\u539F\u59CB\u529B\u5EA6\u4F5C\u4E3A\u4FDD\u6301\u57FA\u51C6\uFF1B\u627E\u4E0D\u5230\u65F6\u7ED9\u51FA\u8B66\u544A\u5E76\u4EC5\u7ED8\u5236\u3002\u589E\u65F6\u7EBF\u5EF6\u7EED\u7684\u97F3\u7B26\u4FDD\u6301\u8D77\u97F3\u65F6\u7684\u529B\u5EA6\u3002`,allowExtraArgs:!1,args:[{name:"from",description:"\u6E10\u53D8\u8D77\u70B9\u7684\u6807\u7B7E",type:"label",default:null},{name:"to",description:"\u6E10\u53D8\u7EC8\u70B9\u7684\u6807\u7B7E",type:"label",default:null},{name:"dv",description:"\u529B\u5EA6\u53D8\u5316\u91CF\uFF0C\u6B63\u6570\u6E10\u5F3A\uFF0C\u8D1F\u6570\u6E10\u5F31",type:"number",default:null}]};static loweringFinalize=t=>{let e=t.attachments.filter(o=>o instanceof ze);if(e.length===0)return;let n=[];for(let o of t.astToTemporal.values())for(let i of o){let r=i.playbackState?.velocity;if(r===void 0)continue;let a=i;for(;a.foldedInto;)a=a.foldedInto;n.push({node:i,host:a,velocity:r,increment:0})}n.sort((o,i)=>o.host.t.compare(i.host.t)||o.node.order-i.node.order);for(let o of e){let i=o.end.playbackState?.velocity??n.find(c=>c.host===o.toHost)?.velocity;for(let c=n.length-1;i===void 0&&c>=0;c--){let l=n[c];l.host.track===o.track&&l.host.t.compare(o.toHost.t)<=0&&(i=l.velocity)}if(i===void 0){t.diagnostics.push(new U("W_DYN_NO_VELOCITY","@dyn \u7EC8\u70B9\u53CA\u6B64\u524D\u540C\u8F68\u6CA1\u6709\u53EF\u7528\u7684\u529B\u5EA6\u57FA\u51C6\uFF0C\u4EC5\u7ED8\u5236\u6E10\u53D8\u7EBF",o.sourceSpan));continue}let r=n.find(c=>c.host.track===o.track&&c.host.t.compare(o.toHost.t)>0&&c.velocity!==i)?.host.t,a=o.toHost.t.clone().sub(o.fromHost.t);for(let c of n){if(c.host.track!==o.track||c.host.t.compare(o.fromHost.t)<0||r&&c.host.t.compare(r)>=0)continue;let f=c.host.t.compare(o.toHost.t)>=0?1:c.host.t.clone().sub(o.fromHost.t).div(a).toNumber();c.increment+=o.dv*f}}for(let o of n){if(o.increment===0)continue;let i=Math.max(1,Math.min(127,o.velocity+o.increment));o.node.playbackState={...o.node.playbackState,velocity:i}}};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(D.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];let o=e,i=n;for(;o.foldedInto;)o=o.foldedInto;for(;i.foldedInto;)i=i.foldedInto;if(!Q(o)||!Q(i))return t.diagnostics.push(D.warning.UnresolvedEndpoint("dyn",this.sourceSpan)),[];if(o.track!==i.track)throw new k("E_DYN_CROSS_TRACK","@dyn \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u540C\u4E00\u97F3\u8F68",this.sourceSpan);if(o.t.equals(i.t))throw new k("E_DYN_ZERO_SPAN","@dyn \u7684\u4E24\u4E2A\u7AEF\u70B9\u5FC5\u987B\u4F4D\u4E8E\u4E0D\u540C\u65F6\u95F4",this.sourceSpan);return o.t.compare(i.t)<0?t.addAttachment(new ze(this,n,o,i)):t.addAttachment(new ze(this,e,i,o)),[]}constructor(t,e,n,o=null){super(t,o);let[i,r,a]=this.getArgValue(e,n),c=a;if(!Number.isFinite(c)||c===0)throw new k("E_DYN_INVALID_DELTA","@dyn \u7684 dv \u5FC5\u987B\u662F\u975E\u96F6\u6709\u9650\u6570",t);c=Math.max(-127,Math.min(127,c)),c!==a&&n.diagnostics.push(new U("W_DYN_DELTA_CLAMPED",`@dyn \u7684 dv \u5FC5\u987B\u5728 -127 \u5230 127 \u4E4B\u95F4\uFF0C\u5DF2\u88AB\u9650\u5236\u4E3A ${c}`,t)),this.from=i,this.to=r,this.dv=c,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})`}},Ai=yo,ze=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 endPoints(){return[this.fromHost,this.toHost]}get dv(){return this.ast.dv}get track(){return this.fromHost.track}createGeometry(t){let e=this.fromHost.layoutLine,n=this.toHost.layoutLine,o=[this.fromHost,this.toHost],i=[],r=this.ast.size;for(let h=e;h<=n;h++){let x=t.getRangeColumns(h,o,this.track);if(x.some(g=>g.length>0)){for(let g of x)for(let m of g)r=Math.max(r,m.ast.size);i.push({line:h,startX:h===e?this.fromHost.box.x:this.lineEntryX(t,h),endX:h===n?this.toHost.box.x+this.toHost.box.w:this.lineRightX(t,h)})}}for(let h of i)h.line>e&&(h.startX-=r/4);let a=Math.max(.75,r*.035),c=i.filter(h=>h.startX!==h.endX),l=c.reduce((h,x)=>h+Math.abs(x.endX-x.startX),0);if(l===0)return{regions:[],paint(){}};let f=r*.4,p=a/2,u=0,d=c.map(h=>{let x=Math.abs(h.endX-h.startX),g=u/l,m=(u+x)/l;u+=x;let y=t.getRangeExtents(h.line,o,this.track),w=t.getVisualAxis(h.line,this.track),E=y?w+y.top:w;return{line:h.line,startX:h.startX,endX:h.endX,lineY:E-r*.62,startOpen:f*(this.dv>0?g:1-g),endOpen:f*(this.dv>0?m:1-m)}});return{regions:d.map(h=>({x:Math.min(h.startX,h.endX)-p,y:h.lineY-Math.max(h.startOpen,h.endOpen)/2-p,w:Math.abs(h.endX-h.startX)+a,h:Math.max(h.startOpen,h.endOpen)+a,line:h.line,track:this.track})),paint(h){let x={stroke:"#000",strokeWidth:a};for(let g of d)h.drawLine(g.startX,g.lineY-g.startOpen/2,g.endX,g.lineY-g.endOpen/2,x),h.drawLine(g.startX,g.lineY+g.startOpen/2,g.endX,g.lineY+g.endOpen/2,x)}}}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 i of n.values())for(let r of i)o=Math.max(o,r.box.x+r.box.w);return o}};var ne=class s{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 s(this));return n}};var Ce=.7,Ei="shoulder";function Li(s,t){let e=s;typeof e.size=="number"&&(e.size*=t);for(let n of s.children??[])Li(n,t)}var go=class s extends O{static def={name:["grace"],description:"\u501A\u97F3",details:"~~~jpfun\n@grace(1, {3 2}, side=pre)\n~~~\n**\u7B80\u5199**\uFF1A\u7BAD\u5934\u59CB\u7EC8\u6307\u5411\u5BBF\u4E3B\n- `2>1`\uFF1A`2` \u662F `1` \u7684\u524D\u501A\u97F3\uFF0C\u4F4D\u4E8E\u5DE6\u4E0A\u65B9\n- `1<2`\uFF1A`2` \u662F `1` \u7684\u540E\u501A\u97F3\uFF0C\u4F4D\u4E8E\u53F3\u4E0A\u65B9\n- `{3 2}>1`\uFF1A\u4E00\u7EC4\u524D\u501A\u97F3\uFF0C\u7B49\u4EF7\u4E8E\u4E0A\u4F8B\n- `1>2>3`\uFF1A\u5141\u8BB8\u5D4C\u5957\uFF0C`1` \u4FEE\u9970 `2`\uFF0C`2` \u4FEE\u9970 `3`\n\n\u501A\u97F3\u9ED8\u8BA4\u5E26\u4E00\u6761\u51CF\u65F6\u7EBF\uFF0C\u6309\u516B\u5206\u97F3\u7B26\u4E66\u5199\uFF1B\u518D\u52A0 `/` \u53D8\u4E3A\u5341\u516D\u5206\u97F3\u7B26\n\n\u501A\u97F3\u5185\u5BB9\u53EF\u4EE5\u662F\u6362\u884C\u4EE5\u5916\u7684\u4EFB\u610F\u7ED3\u6784\uFF0C\u4F8B\u5982 `{1 & 3}>2` \u7684\u4E24\u4E2A\u58F0\u90E8\u540C\u65F6\u594F\u51FA",allowExtraArgs:!1,args:[{name:"host",description:"\u88AB\u501A\u97F3\u4FEE\u9970\u7684\u5BBF\u4E3B\u5185\u5BB9",type:"content",default:null},{name:"grace",description:"\u501A\u97F3\u5185\u5BB9\uFF0C\u591A\u4E2A\u97F3\u7B26\u53EF\u7528\u5927\u62EC\u53F7\u7EC4\u5408\uFF0C\u4E5F\u53EF\u4EE5\u542B\u591A\u4E2A\u58F0\u90E8",type:"content",default:null},{name:"side",description:"`pre` \u4E3A\u524D\u501A\u97F3\uFF0C`post` \u4E3A\u540E\u501A\u97F3",type:"string",default:"pre"}]};labelable(){return O.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:s,side:o},span:{start:e,end:e+1}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.kind!=="sugar"||o.data?.class!==s)return null;let i=o.data.side,r=t.nodes.length-1;for(;r>=0&&t.nodes[r]instanceof xt;)r--;if(r<0)throw new k("E_GRACE_NO_TARGET","@grace\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u76EE\u6807",o.span);let a=t.nodes[r],c=r;if(a instanceof Bt){let f=a.target;for(;f&&!t.nodes.includes(f);)f=f.parent;for(let p=r-1;p>=0;p--)if(t.nodes[p]===f){a=new ut({start:f.sourceSpan.start,end:a.sourceSpan.end},t.nodes.slice(p,r+1),null),c=p;break}}let l=t.nodes;t.nodes=[],t.makeNodes(e,n);for(let f=0;f<t.nodes.length;f++){let p=t.nodes[f];if(p instanceof xt)continue;let u=i==="pre"?s.attachPre(a,p,o.span,t):s.create(t,o.span,"post",a,p);for(l.length=c,l.push(u);++f<t.nodes.length;)l.push(t.nodes[f]);return t.nodes=l,e.length}throw new k("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 s&&e.side==="pre"){let i=e,r=1;for(;i.grace instanceof s&&i.grace.side==="pre";)i=i.grace,r++;let a=new Map;a.set(0,i.grace),a.set(1,t);let c=Ce**r,l=new s(n,a,o,null,Ce*c);return l.size*=c,i.setGrace(l,1),e}return s.create(o,n,"pre",e,t)}static create(t,e,n,o,i){let r=new Map;return r.set(0,o),r.set(1,i),r.set("side",n),new s(e,r,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,i=Ce){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 k("E_GRACE_INVALID_SIDE","@grace \u7684 side \u53C2\u6570\u5FC5\u987B\u662F 'pre' \u6216 'post'",t);this.adopt(this.host),this.setGrace(this.grace,i)}setGrace(t,e=Ce){Li(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){let n=this.host,o=this.grace;if(!n||!o)throw new k("E_GRACE_MISSING_ARGS","@grace \u9700\u8981\u540C\u65F6\u7ED9\u51FA\u5BBF\u4E3B\u548C\u501A\u97F3",this.sourceSpan);let i=new ne(e),r=[],a=[],c=[],l=(d,h)=>t.trackedEvents(d,new F,h);t.isolateFromLoweringGroups(()=>{this.side==="post"&&(r=l(n,e).flat()),t.beginLoweringGroup(this,{onAttachment(d){c.push(d)}}),a=l(o,i),t.endLoweringGroup(this),this.side==="pre"&&(r=l(n,e).flat())});let[f]=r;if(r.length!==1||!Q(f))throw new k("E_GRACE_INVALID_HOST","@grace \u7684\u5BBF\u4E3B\u5FC5\u987B\u6070\u597D\u4EA7\u751F\u4E00\u4E2A\u53EF\u89C1 Temporal",n.sourceSpan);let p=a.flat();if(!p.some(Q)||p.some(d=>d.breakBefore>0))throw new k("E_GRACE_INVALID_CONTENT","@grace \u7684\u501A\u97F3\u81F3\u5C11\u4EA7\u751F\u4E00\u4E2A\u53EF\u89C1\u5BF9\u8C61\uFF0C\u4E14\u4E0D\u80FD\u6362\u884C",o.sourceSpan);let u=new bo(this,f,a,i,c,this.side);for(let d of u.graceRuns)d.length<2||t.addAttachment(Le([...d],!1,o.sourceSpan));return[u]}toString(t){let e=this.host?.toString(t)??"",n=this.grace?.toString(t)??"";return`@grace(${e}, ${n}, side=${this.side})`}},Ci=go,Ga=[{op:"M",x:0,y:0},{op:"C",cx1:-.01,cy1:.26,cx2:.14,cy2:.42,x:.29,y:.36}],Ua=.07,Va=.18,Ti=new F(3,4),bo=class extends tt{host;graceColumns;graces;graceRuns;side;root;attachments;events;starts;hostOffset={x:0,y:0};graceOffsets=[];hookOrigin=null;constructor(t,e,n,o,i,r){super(),this.ast=t,this.host=e,this.root=o,this.attachments=i,this.side=r,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 a=[],c=[],l=[];for(let u of n){let d=u[0].t.clone().divPow2(),h=[];for(let x of u)x.foldedInto=this,c.push(x),l.push(d),Q(x)&&h.push(x);h.length>0&&a.push(h)}this.graceColumns=a,this.graces=a.flat(),this.events=c,this.starts=l;let f=new Map,p=[];for(let u of this.graces){if(u.T.isZero()){f.delete(u.track);continue}let d=f.get(u.track);d||(f.set(u.track,d=[]),p.push(d)),d.push(u);let h=u.addon={...u.addon};h[ee]=(Number(h[ee])||0)+1,u.T.divPow2()}this.graceRuns=p}onTimeState(t){this.host.T.copyFrom(this.T);for(let e of this.side==="pre"?[...this.events,this.host]:[this.host,...this.events])e.t.copyFrom(this.t),e.layoutLine=this.layoutLine,e.onTimeState?.(t)}emitPlayback(t){let e=new F,n=new F;this.events.forEach((f,p)=>{n.copyFrom(this.starts[p]).add(f.T),n.compare(e)>0&&e.copyFrom(n)});let o=e.compare(Ti)>0?Ti:e,i=t.end.clone().sub(t.start),r=i.clone().mul(o),a=i.sub(r),c=e.isZero()?new F:r.clone().div(e),l=this.side==="pre"?t.start.clone():t.start.clone().add(a);this.side==="post"&&t.play(this.host,t.start.clone(),a),this.events.forEach((f,p)=>{t.play(f,this.starts[p].clone().mul(c).add(l),f.T.clone().mul(c))}),this.side==="pre"&&t.play(this.host,l.add(r),a)}prepareLayout(t){this.addon&&(this.host.addon=this.addon,this.addon=void 0);let e=t.layoutSubdomain(this,this.graceColumns,this.root,this.attachments),n=Ae([this.host],t),o=this.ast.size*Ce,i=o*.2,r=o*Va,c=(this.host.ports[Ei]?.y??0)-r-e.height,l=Math.max(0,-c),f=this.side==="pre"?0:n+i;this.hostOffset={x:this.host.box.x+(this.side==="pre"?e.width+i:0),y:l},this.graceOffsets=e.positions.map(d=>({x:f+d.x,y:c+l+d.y})),this.box.w=n+i+e.width,this.box.h=l+this.host.box.h,this.box.anchor=this.hostOffset.x+this.host.box.anchor,this.box.visualAxis=l+this.host.box.visualAxis;for(let d in this.host.ports){let h=this.host.ports[d];this.ports[d]={...h,x:this.hostOffset.x+h.x,y:this.hostOffset.y+h.y}}this.ports[Ei]??={x:this.box.anchor,y:this.hostOffset.y};let p=this.graces.filter(d=>!d.T.isZero()),u=this.side==="pre"?p.at(-1):p[0];this.hookOrigin=u?{x:this.graceOffsets[this.graces.indexOf(u)].x+u.box.anchor,y:Math.max(...this.graces.map((d,h)=>this.graceOffsets[h].y+d.box.h))}: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 i of[this.host,...this.graces]){i.paint(t);for(let r of i.decorations)r.paint(t)}if(!this.hookOrigin)return;let e=this.ast.size*Ce,n=this.hookOrigin,o=this.side==="pre"?1:-1;t.drawPath(Ga,{stroke:"#000",strokeWidth:Math.max(.8,e*Ua)},{x:this.box.x+n.x,y:this.box.y+n.y,scaleX:e*o,scaleY:e})}};var ve="sans-serif",So="'Cascadia Mono', Consolas, 'Liberation Mono', 'Noto Sans Mono', monospace";function dn(s){return`${s.fontWeight??"normal"} ${s.fontSize}px ${s.fontFamily??ve}`}var hn=class{measureText(t,e){let n=e.fontSize,o=e.fontFamily?.toLowerCase().includes("mono")??!1,i=0;for(let r of t)i+=r.charCodeAt(0)>127?1:o?.62:.58;return{w:Math.max(i*n,n*.25),h:n,baseline:n*.8}}},Ao=new hn,wo=class{context;widths=new Map;constructor(t){this.context=t}clearCache(){this.widths.clear()}measureText(t,e){let n=dn(e),o=`${n}\0${t}`,i=this.widths.get(o);return i===void 0&&(this.context.font=n,i=this.context.measureText(t).width,this.widths.set(o,i)),{w:Math.max(i,e.fontSize*.25),h:e.fontSize,baseline:e.fontSize*.8}}};var ja=/[A-Za-z0-9_./-]/;function We(s,t,e){let n=t+1;for(;n<e&&ja.test(s[n]);)n++;let o=s.slice(t+1,n);if(!o||n>=e||s[n]!=="(")return null;let i=n,r=1,a=0,c=null,l=!1,f=[],p=i+1,u=(h,x,g=!1)=>{let m=He(s,p,h);if(!g&&m.start>=m.end)return;let y=Ya(s,m.start,m.end),w=y>m.start?He(s,m.start,y):void 0,E=y>m.start?He(s,y+1,m.end):m;f.push({span:m,valueSpan:E,nameSpan:w,equalsSpan:y>m.start?{start:y,end:y+1}:void 0,commaSpan:x===void 0?void 0:{start:x,end:x+1}})},d=(h,x)=>({name:o,span:{start:t,end:h},nameSpan:{start:t,end:i},openParenSpan:{start:i,end:i+1},closeParenSpan:x,args:f});for(n++;n<e;n++){let h=s[n];if(c){l?l=!1:h==="\\"?l=!0:h===c&&(c=null);continue}if(h==='"'){c=h;continue}if(h==="{")a++;else if(h==="}")a=Math.max(0,a-1);else if(h==="("&&a===0)r++;else if(h===")"&&a===0){if(--r)continue;return u(n),d(n+1,{start:n,end:n+1})}else h===","&&r===1&&a===0&&(u(n,n,!0),p=n+1)}return u(e),d(e)}var vi=/\s/;function He(s,t,e){let n=t,o=e;for(;n<o&&vi.test(s[n]);)n+=1;for(;o>n&&vi.test(s[o-1]);)o-=1;return{start:n,end:o}}function Ya(s,t=0,e=s.length){let n=0,o=0,i=null,r=!1;for(let a=t;a<e;a++){let c=s[a];if(i){r?r=!1:c==="\\"?r=!0:c===i&&(i=null);continue}if(c==='"')i=c;else if(c==="("&&o===0)n++;else if(c===")"&&o===0)n=Math.max(0,n-1);else if(c==="{")o++;else if(c==="}")o=Math.max(0,o-1);else if(c==="="&&n===0&&o===0)return a}return-1}function Mi(s,t,e){let n=1,o=null,i=!1;for(let r=t;r<e;r++){let a=s[r];if(o){i?i=!1:a==="\\"?i=!0:a===o&&(o=null);continue}if(a==='"')o=a;else if(a==="(")n++;else if(a===")"&&--n===0)return r}return-1}function Yt(s,t,e){for(let n=t+1;n<e;n++)if(s[n]==="\\")n++;else if(s[n]==='"')return n;return-1}function oe(s){return s.length<2||!s.startsWith('"')||!s.endsWith('"')?s:s.slice(1,-1).replace(/\\(.)/gs,"$1")}function ht(s){return`"${s.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Ni(s,t,e){let n=1,o=null,i=!1;for(let r=t+1;r<e;r++){let a=s[r];if(o){i?i=!1:a==="\\"?i=!0:a===o&&(o=null);continue}if(a==='"')o=a;else if(a==="{")n++;else if(a==="}"&&(n--,n===0))return r}return-1}var Ka=/\s|\(|\)|\{|\}|,/;function ki(s,t,e){let n=t+1;for(;n<e&&!Ka.test(s[n]);)n++;return n<=t+1?null:{label:s.slice(t+1,n),next:n}}var Xa=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]+)?$/i,qa=["em","px"];function Eo(s){let t=s.match(Xa);if(!t)return D.warning.InvalidLength(s,{start:0,end:s.length});let e=parseFloat(t[1]);if(!Number.isFinite(e))return D.warning.InvalidLength(s,{start:0,end:s.length});if(t[2]){let n=t[2].toLowerCase();return qa.includes(n)?{value:e,unit:n}:D.warning.InvalidLengthUnit(n,{start:t[1].length,end:s.length})}else return{value:e,unit:"px"}}var _i=/^(true|false)$/;function Za(s,t){if(s)return s==="content"?void 0:s;if(_i.test(t))return"boolean";if(t.startsWith('"'))return"string";if(!isNaN(Number(t)))return"number";if(!(Eo(t)instanceof D))return"length"}var Ri=22,Qa=4,Rt=class s{static systemVariables={fontsize:{type:"length",default:Ri},font:{type:"string",default:ve},numberfont:{type:"string",default:So},strict:{type:"boolean",default:!1}};scopeDepth;source;syntax;diagnostics;variables;documentDeclarations;functions;deSugarAtomFns;deSugarRelationFns;labelableNodes;nodes;constructor(t){t instanceof s?(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(s.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]=s.getDeSugarFns(this.functions.values()):(this.deSugarAtomFns=[],this.deSugarRelationFns=[]))}static getDeSugarFns(t){let e=new Set(t),n=[],o=[];for(let i of e){let r=i.deSugarAtom;r&&r!==O.deSugarAtom&&n.push(r);let a=i.deSugarRelation;a&&a!==O.deSugarRelation&&o.push(a)}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(s.systemVariables,t)&&(t==="fontsize"&&e&&(e=this.length2px(e)),(e===void 0||e===""||e===0)&&(e=s.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 i=Array.isArray(o.name)?o.name:[o.name];for(let r of i){if(e.has(r.toLowerCase()))throw new Error(`Duplicate function name detected: ${r}`);e.set(r.toLowerCase(),n)}}[this.deSugarAtomFns,this.deSugarRelationFns]=s.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,i)=>o.span.start-i.span.start||o.span.end-i.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 a=Math.min(this.source.length,t.span.end-1);this.source[a]==="}"&&this.addSyntax("punctuation",{start:a,end:a+1}),new s(this).parseSyntax(t.span.start+1,a);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,...i}=t;this.syntax.calls.push(i),this.addSyntax("function",i.nameSpan),this.addSyntax("punctuation",i.openParenSpan),this.addSyntax("punctuation",i.closeParenSpan);let r=this.functions.get(i.name.toLowerCase())?.def;for(let a=0;a<i.args.length;a++){let c=i.args[a];this.addSyntax("property",c.nameSpan),this.addSyntax("punctuation",c.equalsSpan),this.addSyntax("punctuation",c.commaSpan);let l=c.nameSpan?this.source.slice(c.nameSpan.start,c.nameSpan.end).toLowerCase():void 0,f=r&&ye(r,l,a);if(f==="content")new s(this).parseSyntax(c.valueSpan.start,c.valueSpan.end);else{let p=this.source.slice(c.valueSpan.start,c.valueSpan.end),u=Za(f,p);u&&this.addSyntax(u,c.valueSpan)}}}makeNodes(t,e=0,n=t.length){t:for(;e<n;e++){let o=t[e];if(typeof o=="number"){let i=this.nodes.at(-1);i instanceof xt&&i.sourceSpan.end===o?i.sourceSpan.end=o+1:this.nodes.push(new xt({start:o,end:o+1},null));continue}switch(o.kind){case"call":this.pushNode(this.parseCallNode(o));break;case"brace":let i=new s(this);this.nodes.push(new ut(o.span,i.parse(o.span.start+1,o.span.end-1),null));break;case"label":let r=this.labelableNodes.at(-1);r?r.label!==void 0?this.diagnostics.push(D.warning.TargetAlreadyLabeled(o.label,r.label,o.span)):(r.label=o.label,this.nodes.push(new Bt(o.span,o.label,r))):this.diagnostics.push(D.warning.LabelWithoutTarget(o.label,o.span));break;case"sugar":for(let c of this.deSugarRelationFns){let l=c(this,t,e);if(l!==null){e=l-1;continue t}}let a=this.nodes.at(-1);a instanceof xt&&a.sourceSpan.end===o.span.start?a.sourceSpan.end=o.span.end:this.nodes.push(new xt(o.span,null));break}}return e}parseGrammar(t,e,n=!1){let o=[],i=r=>{o.push(r),n&&this.recordSyntax(r)};t:for(;(t=Ut(this.source,t,e))<e;){let r=this.source[t];if(r==="@"){let a=We(this.source,t,e);if(a){i(Object.assign(a,{kind:"call",typed:!1}));let l=!1;for(let f of a.args){let p=f.nameSpan!==void 0;if(p&&!l)l=!0;else if(!p&&l){let u=D.error.PosAfterNamedArg(a.name,f.span);if(!n)throw u;this.diagnostics.push(u)}}if(!a.closeParenSpan){let f=D.error.UnterminatedCall(a.name,a.span);if(!n)throw f;this.diagnostics.push(f)}t=a.span.end;continue}let c=ki(this.source,t,e);if(c){i({kind:"label",span:{start:t,end:c.next},label:c.label}),t=c.next;continue}}if(r==="{"){let a=Ni(this.source,t,e);(a<0||a>=e||a<=t)&&(this.diagnostics.push(D.warning.UnmatchedBrace({start:t,end:e})),a=e),i({kind:"brace",span:{start:t,end:a+1}}),t=a+1;continue}for(let a of this.deSugarAtomFns)try{let c=a(this.source,t,e,this.scopeDepth);if(c){i(c.node),t=c.next;continue t}}catch(c){throw c instanceof D?this.diagnostics.push(c):this.diagnostics.push(D.error.Bug(c.toString(),{start:t,end:e})),c}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 D.error.UnknownFunction(t.name,t.span);return this.diagnostics.push(D.warning.UnknownFunction(t.name,t.span)),new O(t.span,null)}let o=n.args;if(!t.typed){let i=new Map;for(let r=0;r<t.args.length;r++){let a=t.args[r],c=a.nameSpan?this.source.slice(a.nameSpan.start,a.nameSpan.end).toLowerCase():void 0,l=ye(n,c,r),f=c??r;if(l===void 0){n.allowExtraArgs?i.set(f,a):this.diagnostics.push(D.warning.TooManyPosArgs(t.name,o.length,r+1,a.valueSpan));continue}let p=this.parseArgWithType(a.valueSpan,l,t.span.start);p!==null&&i.set(f,p)}return new e(t.span,i,this,null)}return new e(t.span,t.args,this,null)}parseArgWithType(t,e,n){let o=He(this.source,t.start,t.end),i=o.start,r=o.end;if(i>=r)return null;let a=e==="content"?"":this.source.slice(i,r);switch(e){case"number":let c=Number(a);return Number.isFinite(c)?c:(this.diagnostics.push(D.warning.InvalidNumber(a,o)),null);case"boolean":let l=a;return _i.test(l)?l==="true":(this.diagnostics.push(D.warning.InvalidBoolean(a,o)),null);case"content":{let u=this.labelableNodes,d=u.length,h=u.at(-1),x=h?.label,g=h&&Object.hasOwn(h,"label");try{let y=new s(this).parse(i,r);return y.length===1?y[0]:new ut(o,y,null)}catch(m){if(u.length=d,h&&(g?h.label=x:delete h.label),this.variables.strict||!(m instanceof D))throw m;return this.diagnostics.push(m,D.warning.InvalidContent(o)),null}}case"label":n??=t.start;for(let u=this.labelableNodes.length-1;u>=0;u--){let d=this.labelableNodes[u];if(d&&!(d.sourceSpan.start>=n)&&d.label==a)return d}throw D.error.UnknownLabel(a,o);case"length":let f=Eo(a);return f instanceof D?(f.span.start+=i,f.span.end+=i,this.diagnostics.push(f),null):f;default:return oe(a)}return null}length2px(t){return t.unit==="em"?t.value*this.variables.fontsize:t.value}};function Ut(s,t,e){for(;t<e&&Ii(s[t]);)t++;return t}function Ge(s,t,e=0){for(;t>=e&&Ii(s[t]);)t--;return t}function Ii(s){switch(s){case" ":case" ":case"\v":case"\f":case"\xA0":case"\uFEFF":case"\u3000":return!0;default:return!1}}var Ja=/^[A-GXZ]/,mn=/^[0-9]/,xn=/^[#bn]+/,$i=/^[+-]?\d+/,Oi=/^[,']+/;function se(s,t=0,e=s.length){if(e-t===0)return new k("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,i=null,r=null,a=!1,c;for(let l=t;l<e;l++){let f=s[l];switch(n){case 0:if(Ja.test(f))o=f,a=!0,n=1;else if(mn.test(f))o=f,a=!1,n=3;else{let u=s.slice(l,e).match(xn);if(u)i=u[0],l+=i.length-1,a=!1,n=2;else return new k("E_WRONG_NOTE_NAME",`\u51FD\u6570 @note \u7684\u53C2\u6570 [0]:"name" \u683C\u5F0F\u9519\u8BEF: \u9996\u5B57\u7B26 "${f}" \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=s.slice(l,e);if(c=p.match($i),c){r=parseInt(c[0],10),l+=c[0].length-1,n=4;break}if(c=p.match(xn),c){i=c[0],l+=i.length-1,n=5;break}return{name:o,next:l,acc:null,octave:null,absOctave:a};case 2:if(mn.test(f)){o=f,n=6;break}else return new k("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 "${f}"`,{start:l,end:l+1});case 3:if(c=s.slice(l,e).match(Oi),c){let u=c[0];return r=Pi(u),{name:o,next:l+u.length,acc:i,octave:r,absOctave:a}}if(c=s.slice(l,e).match(xn),c&&!mn.test(s[l+c[0].length]??"")){let u=c[0];i=u,l+=u.length-1,n=6;break}return{name:o,next:l,acc:i,octave:r,absOctave:a};case 4:if(c=s.slice(l,e).match(xn),c&&!mn.test(s[l+c[0].length]??"")){let u=c[0];return i=u,{name:o,next:l+u.length,acc:i,octave:r,absOctave:a}}return{name:o,next:l,acc:null,octave:r,absOctave:a};case 5:return c=s.slice(l,e).match($i),c?(r=parseInt(c[0],10),{name:o,next:l+c[0].length,acc:i,octave:r,absOctave:a}):{name:o,next:l,acc:i,octave:null,absOctave:a};case 6:if(c=s.slice(l,e).match(Oi),c){let u=c[0];return r=Pi(u),{name:o,next:l+u.length,acc:i,octave:r,absOctave:a}}return{name:o,next:l,acc:i,octave:r,absOctave:a};default:return D.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 k("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:i,octave:r,absOctave:a}}function Pi(s){let t=0;for(let e=0;e<s.length;e++)s[e]===","?t--:s[e]==="'"&&t++;return t}var Kt=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],Di=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"],Tt={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},yn=["C","D","E","F","G","A","B"],To=[0,2,4,5,7,9,11];function ie(s,t){let e=s[0],n="",o=1;o<s.length&&(s[o]==="#"||s[o]==="b"||s[o]==="n")&&(n=s[o],o++);let i=Tt[e+n];if(i===void 0)throw D.error.InvalidTonality(s,{start:0,end:o});if(o<s.length){let r=s.slice(o);if(t=Number(r),!/^-?\d+$/.test(r)||!Number.isSafeInteger(t))throw D.error.InvalidTonality(s,{start:o,end:s.length})}return(t+1)*12+i}function Co(s,t=!0,e=0){for(let n of s)n==="#"?e++:n==="b"?e--:n==="n"&&!t&&(e=0);return e}function vo(s,t,e,n){let o=Tt[s];if(o===void 0)return null;let i=Co(t);return s>="1"&&s<="7"?ie(n,4)+o+i+e*12:(e+1)*12+o+i}function Fi(s,t,e,n){let o,i;if(s>="1"&&s<="7")o=Number(s)-1,i=e;else{let c=Ue(s,t,e,n);if(!c)return;o=Number(c.renderName)-1,i=c.renderOctave}let r=ie(n,4),a=i*7+o;return c=>{let l=a+c,f=Math.floor(l/7);return r+To[(l%7+7)%7]+f*12}}function Lo(s){return(s%12+12)%12}function tc(s){let t=Lo(s);return t>6?t-12:t}function ec(s){return s===0?"":s>0?"#".repeat(s):"b".repeat(-s)}function Ue(s,t,e,n){let o=yn.indexOf(n[0]),i=yn.indexOf(s),r=vo(s,t,e,n);if(o<0||i<0||r===null)return null;let a=ie(n,4),c=(i-o+yn.length)%yn.length,l=Lo(a+To[c]),f=tc(Lo(r)-l),p=(r-a-To[c]-f)/12;return{renderName:String(c+1),renderAcc:ec(f),renderOctave:p}}var nc={"#":{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 oc(s,t){let e=nc[s];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 gn(s,t,e,n,o){let i=[],r=t*.42,a=e,c=0;for(let l of s){let f=oc(l,t);if(!f)continue;let p=n-f.baseline-r;i.push({shape:f,x:a,y:p}),p<c&&(c=p),a+=f.w+o}return{placed:i,right:a,top:c}}function bn(s,{shape:t,x:e,y:n},o,i){s.drawPath(t.commands,{stroke:i,strokeWidth:t.strokeWidth},{x:o.x+e,y:o.y+n,scaleX:t.w,scaleY:t.h})}function sc(s){try{return ie(s,4),s}catch{}let t=se(s.replace(/^[a-g]/,a=>a.toUpperCase()));if(t instanceof D||t.next!==s.length)return null;let e=Tt[t.name];if(e===void 0)return null;let n=Co(t.acc??"",!1),i=((t.absOctave?t.octave??4:4+(t.octave??0))+1)*12+e+n,r=Object.keys(Tt).filter(a=>Tt[a]===(i%12+12)%12&&/^[A-G]/.test(a));return(n<0?r.at(-1):r[0])+(Math.floor(i/12)-1)}var No=class extends O{static def={name:["key","1"],description:"\u8BBE\u7F6E\u65F6\u95F4\u7EBF\u4E0A\u7684 1= \u8C03\u6027\u57FA\u51C6",details:`~~~jpfun
18
21
  1 ^ @key(F#3)
19
22
  ~~~
20
- \u8C03\u6027\u6CBF\u65F6\u95F4\u7EBF\u5F71\u54CD\u540E\u7EED\u6570\u5B57\u97F3\u540D\u3002\u8C31\u9762\u8BB0\u53F7\u663E\u793A\u97F3\u540D\u4E0E\u5347\u964D\u53F7\uFF0C\u7701\u7565\u516B\u5EA6\uFF1B\u901A\u5E38\u7528 \`^\` \u53E0\u5728\u97F3\u7B26\u4E0A\u65B9\u3002`,allowExtraArgs:!1,args:[{name:"tonality",description:"`1=` \u7684\u97F3\u9AD8\u57FA\u51C6\uFF0C\u5982 `C4`\u3001`F#3`",type:"string",default:null},{name:"size",description:"\u8C03\u6027\u8BB0\u53F7\u5B57\u53F7",type:"length",default:{value:1,unit:"em"}}]};tonality;size;font;displayName;displayAcc;constructor(t,e,n,o=null){super(t,o);let[i,r]=this.getArgValue(e,n);this.font=n.variables.numberfont,this.tonality=i,this.size=n.length2px(r);let a=La(i);if(a!==i){if(n.variables.strict)throw new k("E_KEY_TONALITY",`@key \u65E0\u6CD5\u89E3\u6790\u8C03\u6027 "${i}"`,t);this.tonality=a??ye,n.diagnostics.push(new G("W_KEY_TONALITY",`@key \u7684\u8C03\u6027 "${i}" \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 lo(this)]}toString(){return`@1(${this.tonality})`}},nn=co,ao="1=",lo=class extends Q{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(ao,n),i=t.textMeasurer.measureText(this.ast.displayName,n),r=e*.02,{placed:a,right:c,top:l}=tn(this.ast.displayAcc,e,o.w,o.baseline,r);this.accidentals=a;let h=-l;for(let p of a)p.y+=h;this.nameX=c,this.textBaselineY=h+o.baseline,this.box.w=c+i.w,this.box.h=h+Math.max(o.h,i.h),this.box.anchor=t.textMeasurer.measureText(ao[0],n).w/2,this.box.visualAxis=this.box.h/2}paint(t){let e=this.style;t.drawText(ao,this.box.x,this.box.y+this.textBaselineY,e);for(let n of this.accidentals)en(t,n,this.box,"#000");t.drawText(this.ast.displayName,this.box.x+this.nameX,this.box.y+this.textBaselineY,e)}};var ho=class extends P{static def={name:["meter"],description:"\u8BBE\u7F6E\u62CD\u53F7",details:`~~~jpfun
23
+ \u8C03\u6027\u6CBF\u65F6\u95F4\u7EBF\u5F71\u54CD\u540E\u7EED\u6570\u5B57\u97F3\u540D\u3002\u8C31\u9762\u8BB0\u53F7\u663E\u793A\u97F3\u540D\u4E0E\u5347\u964D\u53F7\uFF0C\u7701\u7565\u516B\u5EA6\uFF1B\u901A\u5E38\u7528 \`^\` \u53E0\u5728\u97F3\u7B26\u4E0A\u65B9\u3002`,allowExtraArgs:!1,args:[{name:"tonality",description:"`1=` \u7684\u97F3\u9AD8\u57FA\u51C6\uFF0C\u5982 `C4`\u3001`F#3`",type:"string",default:null},{name:"size",description:"\u8C03\u6027\u8BB0\u53F7\u5B57\u53F7",type:"length",default:{value:1,unit:"em"}}]};tonality;size;font;displayName;displayAcc;constructor(t,e,n,o=null){super(t,o);let[i,r]=this.getArgValue(e,n);this.font=n.variables.numberfont,this.tonality=i,this.size=n.length2px(r);let a=sc(i);if(a!==i){if(n.variables.strict)throw new k("E_KEY_TONALITY",`@key \u65E0\u6CD5\u89E3\u6790\u8C03\u6027 "${i}"`,t);this.tonality=a??Oe,n.diagnostics.push(new U("W_KEY_TONALITY",`@key \u7684\u8C03\u6027 "${i}" \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 ko(this)]}toString(){return`@1(${this.tonality})`}},wn=No,Mo="1=",ko=class extends tt{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(Mo,n),i=t.textMeasurer.measureText(this.ast.displayName,n),r=e*.02,{placed:a,right:c,top:l}=gn(this.ast.displayAcc,e,o.w,o.baseline,r);this.accidentals=a;let f=-l;for(let p of a)p.y+=f;this.nameX=c,this.textBaselineY=f+o.baseline,this.box.w=c+i.w,this.box.h=f+Math.max(o.h,i.h),this.box.anchor=t.textMeasurer.measureText(Mo[0],n).w/2,this.box.visualAxis=this.box.h/2}paint(t){let e=this.style;t.drawText(Mo,this.box.x,this.box.y+this.textBaselineY,e);for(let n of this.accidentals)bn(t,n,this.box,"#000");t.drawText(this.ast.displayName,this.box.x+this.nameX,this.box.y+this.textBaselineY,e)}};var _o=class extends O{static def={name:["meter"],description:"\u8BBE\u7F6E\u62CD\u53F7",details:`~~~jpfun
21
24
  @meter(6, 8)
22
25
  ~~~
23
- \u8BBE\u7F6E \`6/8\` \u62CD\u53F7\uFF1A\u6BCF\u5C0F\u8282\u542B\u516D\u4E2A\u516B\u5206\u97F3\u7B26\u7684\u65F6\u503C`,allowExtraArgs:!1,args:[{name:"num",description:"\u62CD\u53F7\u5206\u5B50\uFF0C\u6BCF\u5C0F\u8282\u5305\u542B\u7684\u5355\u4F4D\u62CD\u6570",type:"number",default:null},{name:"den",description:"\u62CD\u53F7\u5206\u6BCD\uFF0C\u4EE5\u51E0\u5206\u97F3\u7B26\u4E3A\u5355\u4F4D\u62CD",type:"number",default:null},{name:"size",description:"\u62CD\u53F7\u5B57\u53F7",type:"length",default:{value:.7,unit:"em"}}]};numerator;denominator;measureDuration;size;strict;font;constructor(t,e,n,o=null){super(t,o);let[i,r,a]=this.getArgValue(e,n);if(this.font=n.variables.numberfont,!Number.isSafeInteger(i)||!Number.isSafeInteger(i*4)||i<=0||!Number.isSafeInteger(r)||r<=0){let c="@meter \u7684\u5206\u5B50\u548C\u5206\u6BCD\u5FC5\u987B\u662F\u6B63\u6574\u6570";if(n.variables.strict)throw new k("E_METER_INVALID",c,t);n.diagnostics.push(new G("W_METER_INVALID",`${c}\uFF0C\u5DF2\u56DE\u843D\u4E3A 4/4`,t)),i=r=4}this.numerator=i,this.denominator=r,this.measureDuration=new z(i*4,r),this.size=n.length2px(a),this.strict=n.variables.strict}loweringEnter(){return[new on(this)]}static loweringFinalize=t=>{let e=new z,n=new z,o=null,i=!1,r=0,a=(c,l)=>{if(!(!o||c.equals(e))){if(n.copyFrom(c).sub(e),!n.equals(o.measureDuration)&&(i||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:r,end:l};if(o.strict)throw new k("E_METER_MISMATCH",h,p);t.diagnostics.push(new G("W_METER_MISMATCH",h,p))}e.copyFrom(c)}};for(let c of t.columns){let l=c[0].t,h=c.find(u=>u instanceof on);h&&(a(l,h.ast.sourceSpan.start),o=h.ast,e.copyFrom(l),r=h.ast.sourceSpan.end);let p=c.find(u=>u.mergeKey===ot);p&&(a(l,p.ast.sourceSpan.end),r=p.ast.sourceSpan.end,i=!0)}if(o){let c=t.columns.at(-1)?.at(-1)?.ast.sourceSpan??o.sourceSpan;a(t.duration,c.end)}};toString(){return`@meter(${this.numerator}, ${this.denominator})`}},sn=ho,on=class extends Q{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,i=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)+i*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 Ca=[{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 ui(s){let t=s/11;return{w:3.864*t,h:10.88*t,stemCenterX:(3.304+3.864)/2*t,commands:Ca,scale:t}}var po=class extends P{static def={name:["tempo"],description:"\u8BBE\u7F6E\u65F6\u95F4\u7EBF\u4E0A\u7684\u901F\u5EA6",details:`~~~jpfun
26
+ \u8BBE\u7F6E \`6/8\` \u62CD\u53F7\uFF1A\u6BCF\u5C0F\u8282\u542B\u516D\u4E2A\u516B\u5206\u97F3\u7B26\u7684\u65F6\u503C`,allowExtraArgs:!1,args:[{name:"num",description:"\u62CD\u53F7\u5206\u5B50\uFF0C\u6BCF\u5C0F\u8282\u5305\u542B\u7684\u5355\u4F4D\u62CD\u6570",type:"number",default:null},{name:"den",description:"\u62CD\u53F7\u5206\u6BCD\uFF0C\u4EE5\u51E0\u5206\u97F3\u7B26\u4E3A\u5355\u4F4D\u62CD",type:"number",default:null},{name:"size",description:"\u62CD\u53F7\u5B57\u53F7",type:"length",default:{value:.7,unit:"em"}}]};numerator;denominator;measureDuration;size;strict;font;constructor(t,e,n,o=null){super(t,o);let[i,r,a]=this.getArgValue(e,n);if(this.font=n.variables.numberfont,!Number.isSafeInteger(i)||!Number.isSafeInteger(i*4)||i<=0||!Number.isSafeInteger(r)||r<=0){let c="@meter \u7684\u5206\u5B50\u548C\u5206\u6BCD\u5FC5\u987B\u662F\u6B63\u6574\u6570";if(n.variables.strict)throw new k("E_METER_INVALID",c,t);n.diagnostics.push(new U("W_METER_INVALID",`${c}\uFF0C\u5DF2\u56DE\u843D\u4E3A 4/4`,t)),i=r=4}this.numerator=i,this.denominator=r,this.measureDuration=new F(i*4,r),this.size=n.length2px(a),this.strict=n.variables.strict}loweringEnter(){return[new Sn(this)]}static loweringFinalize=t=>{let e=new F,n=new F,o=null,i=!1,r=0,a=(l,f)=>{if(!(!o||l.equals(e))){if(n.copyFrom(l).sub(e),!n.equals(o.measureDuration)&&(i||n.compare(o.measureDuration)>0)){let p=`\u5C0F\u8282\u65F6\u957F\u4E3A ${n} QN\uFF0C\u4E0D\u6EE1\u8DB3 ${o.numerator}/${o.denominator} \u62CD\u53F7`,u={start:r,end:f};if(o.strict)throw new k("E_METER_MISMATCH",p,u);t.diagnostics.push(new U("W_METER_MISMATCH",p,u))}e.copyFrom(l)}},c=new Map;for(let l of t.astToTemporal.values())for(let f of l){if(!(f instanceof Sn))continue;let p=f;for(;p.foldedInto;)p=p.foldedInto;c.has(p)||c.set(p,f)}for(let l of t.columns){let f=l[0].t,p=l.find(h=>c.has(h)),u=p&&c.get(p);u&&(a(f,u.ast.sourceSpan.start),o=u.ast,e.copyFrom(f),r=u.ast.sourceSpan.end);let d=l.find(h=>h.mergeKey===ct);d&&(a(f,d.ast.sourceSpan.end),r=d.ast.sourceSpan.end,i=!0)}if(o){let l=t.columns.at(-1)?.at(-1)?.ast.sourceSpan??o.sourceSpan;a(t.duration,l.end)}};toString(){return`@meter(${this.numerator}, ${this.denominator})`}},An=_o,Sn=class extends tt{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,i=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)+i*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 ic=[{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 Bi(s){let t=s/11;return{w:3.864*t,h:10.88*t,stemCenterX:(3.304+3.864)/2*t,commands:ic,scale:t}}var Ro=class extends O{static def={name:["tempo"],description:"\u8BBE\u7F6E\u65F6\u95F4\u7EBF\u4E0A\u7684\u901F\u5EA6",details:`~~~jpfun
24
27
  @tempo(96)
25
28
  ~~~
26
- \u901F\u5EA6\u4ECE\u5F53\u524D\u65F6\u95F4\u4F4D\u7F6E\u8D77\u751F\u6548\uFF1B\u7528 \`1 ^ @tempo(96)\` \u53EF\u5C06\u8BB0\u53F7\u53E0\u5728\u97F3\u7B26\u4E0A\u65B9`,allowExtraArgs:!1,args:[{name:"bpm",description:"\u6BCF\u5206\u949F\u56DB\u5206\u97F3\u7B26\u6570",type:"number",default:null},{name:"size",description:"\u901F\u5EA6\u8BB0\u53F7\u5B57\u53F7",type:"length",default:{value:1,unit:"em"}}]};bpm;size;font;constructor(t,e,n,o=null){super(t,o);let[i,r]=this.getArgValue(e,n);this.bpm=i,this.size=n.length2px(r),this.font=n.variables.font}loweringEnter(){return[new uo(this)]}toString(){return`@tempo(${this.bpm}, size=${this.size}px)`}},rn=po,uo=class extends Q{glyph;text;style;glyphY=0;textX=0;textBaselineY=0;constructor(t){super(),this.ast=t,this.glyph=ui(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 fo=class extends P{static def={name:["text"],description:"\u6587\u672C\u6807\u8BB0",details:`~~~jpfun
29
+ \u901F\u5EA6\u4ECE\u5F53\u524D\u65F6\u95F4\u4F4D\u7F6E\u8D77\u751F\u6548\uFF1B\u7528 \`1 ^ @tempo(96)\` \u53EF\u5C06\u8BB0\u53F7\u53E0\u5728\u97F3\u7B26\u4E0A\u65B9`,allowExtraArgs:!1,args:[{name:"bpm",description:"\u6BCF\u5206\u949F\u56DB\u5206\u97F3\u7B26\u6570",type:"number",default:null},{name:"size",description:"\u901F\u5EA6\u8BB0\u53F7\u5B57\u53F7",type:"length",default:{value:1,unit:"em"}}]};bpm;size;font;constructor(t,e,n,o=null){super(t,o);let[i,r]=this.getArgValue(e,n);this.bpm=i,this.size=n.length2px(r),this.font=n.variables.font}loweringEnter(){return[new Io(this)]}toString(){return`@tempo(${this.bpm}, size=${this.size}px)`}},En=Ro,Io=class extends tt{glyph;text;style;glyphY=0;textX=0;textBaselineY=0;constructor(t){super(),this.ast=t,this.glyph=Bi(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 $o=class extends O{static def={name:["text"],description:"\u6587\u672C\u6807\u8BB0",details:`~~~jpfun
27
30
  @text(\u8FDB\u5165\u4E3B\u9898, size=0.8em, align=center)
28
31
  ~~~
29
- **\u7B80\u5199**\uFF1A\u76F4\u63A5\u5199\u53CC\u5F15\u53F7\u6587\u672C\uFF0C\u5982 \`"\u8FDB\u5165\u4E3B\u9898"\`\uFF1B\u53EF\u8DE8\u884C\uFF0C\u53CC\u5F15\u53F7\u987B\u914D\u5BF9`,allowExtraArgs:!1,args:[{type:"string",description:"\u6587\u672C\u5185\u5BB9\uFF0C\u53EF\u76F4\u63A5\u6362\u884C\uFF1B\u542B\u9017\u53F7\u7B49\u6B67\u4E49\u5B57\u7B26\u65F6\u9700\u52A0\u5F15\u53F7",default:null},{name:"size",description:"\u6587\u672C\u5B57\u53F7",type:"length",default:{value:.8,unit:"em"}},{name:"lineheight",description:"\u76F8\u5BF9\u81EA\u8EAB\u5B57\u53F7\u7684\u884C\u9AD8\u500D\u6570",type:"number",default:1.25},{name:"align",description:"\u6587\u672C\u5BF9\u9F50\u65B9\u5F0F\uFF1A`left`\u3001`center` \u6216 `right`",type:"string",default:"left"},{name:"font",description:"\u6587\u672C\u5B57\u4F53\uFF0C\u7A7A\u503C\u6CBF\u7528\u5F53\u524D\u5B57\u4F53\u8BBE\u7F6E",type:"string",default:""}]};static deSugarAtom(t,e,n){if(t[e]!=='"')return null;let o=le(t,e,n);if(o<0)return null;let i={kind:"call",typed:!0,name:"text",args:new Map([[0,Gt(t.slice(e,o+1))]]),span:{start:e,end:o+1},syntaxKind:"string"};return{next:o+1,node:i}}lines;size;lineAdvance;align;font;constructor(t,e,n,o=null){super(t,o);let[i,r,a,c,l]=this.getArgValue(e,n);if(this.font=l||n.variables.font,c!=="left"&&c!=="center"&&c!=="right")throw new k("E_TEXT_INVALID_ALIGN","@text \u7684 align \u53C2\u6570\u5FC5\u987B\u662F 'left'\u3001'center' \u6216 'right'",t);this.lines=i.split(/\r?\n/),this.size=n.length2px(r),this.lineAdvance=a*this.size,this.align=c}loweringEnter(){return[new mo(this)]}toString(){let t=this.size===0?1.25:this.lineAdvance/this.size;return`@text(${ht(this.lines.join(`
30
- `))}, size=${this.size}px, lineheight=${t}, align=${this.align}, font=${ht(this.font)})`}},an=fo,mo=class extends Q{style;textBaselineY=0;constructor(t){super(),this.ast=t,this.mergeKey=Ct,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,i=c=>t.textMeasurer.measureText(c,this.style),r=i(e[0]),a=r.w;for(let c=1;c<e.length;c++)a=Math.max(a,i(e[c]).w);if(this.box.w=a,this.box.h=(e.length-1)*o+r.h,this.box.visualAxis=this.box.h/2,this.textBaselineY=r.baseline,n==="center")this.box.anchor=a/2;else if(n==="right"){let c=[...e[0]].at(-1);this.box.anchor=a-(c?i(c).w/2:0)}else{let c=[...e[0]][0];this.box.anchor=c?i(c).w/2:0}}paint(t){let{lines:e,align:n,lineAdvance:o}=this.ast,i=this.box.x+(n==="center"?this.box.w/2:n==="right"?this.box.w:0),r=this.box.y+this.textBaselineY;for(let a of e)t.drawText(a,i,r,this.style),r+=o}};var fi={title:"center",subtitle:"center",author:"right",signature:"left",tempo:"left",left:"left",center:"center",right:"right"},Ea={title:[2,"center"],subtitle:[.85,"center"],author:[.8,"right"]},va=.25,di=5,mi=1e4;function cn(s,t){return t.length===1&&t[0]instanceof rt?t[0]:new rt(s,t)}function xi(s,t,e=s.length){for(;t<e&&s[t]!=="\r"&&s[t]!==`
31
- `;)t++;return t}function ka({columns:s,rows:t,start:e,end:n,X:o,fixed:i,options:r},a){ne(s.slice(e,n+1),t,o.subarray(e,n+1),i.subarray(e,n),1/0,r);let c=1/0,l=-1/0;for(let h=e+1;h<n;h++)for(let p=0;p<t;p++)c=Math.min(c,o[h]-s[h][p].WL),l=Math.max(l,o[h]+s[h][p].WR);a&&c<=l?(o[e]=c,o[n]=l):o[n]=o[e]}function yi(s,t,e){let n=[],o,i;for(let r of s){if(!r){n.push(null);continue}let a=i===void 0?0:i+t-r.top;n.push({offset:a,extent:r}),o??=a+r.top,i=a+r.bottom}return e?.(o===void 0||i===void 0?null:{top:o,bottom:i}),n}var ln=class extends Q{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 i=yi(o,n.gap),r=i.find(a=>a!==null);return this.titleBottom=r?r.offset+r.extent.bottom:0,i}return yi(o,n.gap,i=>{e==="left"?this.leftExtent=i:this.rightExtent=i})},place:e==="center"?void 0:()=>{let o=e==="left"?this.leftExtent:this.rightExtent;if(!o)return this.titleBottom;let i=this.leftExtent?this.leftExtent.bottom-this.leftExtent.top:0,r=this.rightExtent?this.rightExtent.bottom-this.rightExtent.top:0;return this.titleBottom+Math.max(i,r)-o.bottom}}}prepareHead(t){if(this.members.some(i=>U(i)&&i.layoutLine!==t.index))throw new k("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 i of this.slots)t.registerHorizontalLayoutHook(i.start,i.end,r=>ka(r,i===n))}alignHead(){let t=new Map;for(let o of this.members){if(!U(o))continue;let i=this.sideCellOf(o.ast);if(!i)continue;let r=t.get(i);r?r.push(o):t.set(i,[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]*mi,t.springConfig[o]=t.springConfig[o]*3/mi}packRows(t,e,n,o){let i=this.ast.owner.size*va,r=n==="left",a=r?1:-1;for(let c of t.rows){let l=c instanceof rt?c.content:[c],h=e;for(let p=r?0:l.length-1;p>=0&&p<l.length;p+=a){let u=o.get(l[p]);if(!u)continue;let m=1/0,f=-1/0;for(let g of u)m=Math.min(m,g.box.x),f=Math.max(f,g.box.x+g.box.w);let y=h-(r?m:f);for(let g of u)g.box.x+=y;for(let g of u)g.onPlaced?.();h+=a*(f-m+i)}}}sideCellOf(t){let e=t;for(;e.parent;){let n=e.parent,o=n instanceof Wt?n:n instanceof rt&&n.parent instanceof Wt?n.parent:null;if(o?.owner===this.ast.owner)return o.name==="center"?null:e;e=n}return null}},Wt=class extends ft{owner;name;rows;constructor(t,e,n,o){super(t,e),this.owner=e,this.name=n,this.rows=o;for(let i of this.rows)i.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 ln(this)]}loweringExit(){return[new ln(this)]}addRow(t){t.parent=this,this.rows.push(t)}},xo=class s extends P{static def={name:["head"],description:"\u5DE6\u3001\u4E2D\u3001\u53F3\u4E09\u533A\u5E03\u5C40",details:"\u5E38\u7528\u4E8E\u8C31\u5934\uFF1A\n~~~jpfun\n@head(left={{@key(C) @meter(4,4)}},\n center={@text(\u6807\u9898)}, right={@text(\u4F5C\u8005)})\n~~~\n**\u7B80\u5199**\uFF1A\u76F8\u90BB\u7684 `H.*:` \u884C\u5408\u5E76\u4E3A\u540C\u4E00\u4E2A\u8C31\u5934\uFF0C\u6BCF\u6761\u58F0\u660E\u751F\u6210\u6240\u5728\u533A\u7684\u4E00\u884C\uFF1B\u7A7A\u884C\u6216\u666E\u901A\u5185\u5BB9\u7ED3\u675F\u7EC4\u5408\n~~~jpfun\nH.title: \u6807\u9898\nH.subtitle: \u526F\u6807\u9898\nH.author: \u4F5C\u8005\nH.signature: 1=C 4/4\nH.tempo: 94\n~~~\n`title` / `subtitle` \u5C45\u4E2D\uFF0C\u5206\u522B\u9884\u8BBE\u5927\u3001\u5C0F\u5B57\u53F7\uFF1B`author` \u5C0F\u5B57\u53F7\u53F3\u5BF9\u9F50\uFF1B`signature` \u548C `tempo` \u653E\u5728\u5DE6\u533A\u3002`H.left:`\u3001`H.center:`\u3001`H.right:` \u53EF\u76F4\u63A5\u5199\u5BF9\u5E94\u533A\u7684\u96F6\u65F6\u957F\u5185\u5BB9\u3002\u4EE5 `@` \u6216 `{` \u5F00\u5934\u7684\u503C\u6309 jpFun \u89E3\u6790\uFF0C\u5176\u4F59\u6309\u5B57\u6BB5\u7684\u6587\u672C\u89C4\u5219\u5904\u7406\u3002",allowExtraArgs:!1,args:[{name:"left",description:"\u5DE6\u533A\u96F6\u65F6\u957F\u5185\u5BB9\uFF0C\u5982\u8C03\u6027\u3001\u62CD\u53F7\u4E0E\u901F\u5EA6\u8BB0\u53F7",type:"content",default:""},{name:"center",description:"\u4E2D\u533A\u96F6\u65F6\u957F\u5185\u5BB9\uFF0C\u5982\u6807\u9898\u4E0E\u526F\u6807\u9898",type:"content",default:""},{name:"right",description:"\u53F3\u533A\u96F6\u65F6\u957F\u5185\u5BB9\uFF0C\u5982\u4F5C\u8005\u4E0E\u7F72\u540D",type:"content",default:""},{name:"gap",description:"\u6BCF\u4E2A\u533A\u5185\u76F8\u90BB\u884C\u7684\u5782\u76F4\u95F4\u8DDD",type:"length",default:{value:di,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 i=t.slice(e+2,o);if(!Object.hasOwn(fi,i)||t[o]!==":")return null;o++;let r=xi(t,o,n),a=It(t,o,r);return{next:t[a]==="@"||t[a]==="{"?o:r,node:{kind:"sugar",data:{class:s,field:i},span:{start:e,end:o}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==s)return null;let i=o.data.field,r=n;for(;r<e.length;r++){let d=e[r];if(typeof d=="number"&&(t.source[d]==="\r"||t.source[d]===`
32
- `)||typeof d!="number"&&d.kind==="sugar"&&d.data?.class===s)break}let a=e[r],c;if(typeof a=="number")c=a;else if(a)c=a.span.start;else if(r>n){let d=e[r-1];c=typeof d=="number"?d+1:d.span.end}else c=xi(t.source,o.span.end);let l=It(t.source,o.span.end,c),h=Te(t.source,c-1,l),p={start:l,end:Math.max(l,h+1)};if(p.start>=p.end)throw new k("E_HEAD_EMPTY_DECLARATION",`H.${i}: \u540E\u5FC5\u987B\u6709\u5185\u5BB9`,o.span);let u=t.source.slice(p.start,p.end).trim(),m;if(u.startsWith("@")||u.startsWith("{")){let d=new wt(t);d.makeNodes(e.slice(n,r)),m=d.nodes}let f=t.nodes.at(-1),y=f instanceof s&&f.createdBySugar?f:new s(o.span,new Map,t,null);if(y.createdBySugar=!0,y.addSugarRow(fi[i],s.parseSugarRow(t,i,p,u,m)),y.sourceSpan.end=p.end,y!==f&&t.pushNode(y),typeof a!="number")return r;let g=r+1;if(t.source[a]==="\r"){let d=e[g];typeof d=="number"&&t.source[d]===`
33
- `&&g++}return g}static parseSugarRow(t,e,n,o,i){if(i!==void 0)return cn(n,i);if(e==="signature"){let c=/^(1\s*=\s*(\S+))\s+((\d+)\s*\/\s*(\d+))$/.exec(o);if(!c)throw new k("E_HEAD_INVALID_SIGNATURE","H.signature \u7684\u683C\u5F0F\u5E94\u4E3A 1=C 4/4",n);let l={start:n.start,end:n.start+c[1].length},h={start:n.end-c[3].length,end:n.end};return cn(n,[new nn(l,new Map([["tonality",c[2]]]),t,null),new sn(h,new Map([["num",Number(c[4])],["den",Number(c[5])]]),t,null)])}if(e==="tempo"){let c=Number(o);if(!Number.isFinite(c)||c<=0)throw new k("E_HEAD_INVALID_TEMPO","H.tempo \u540E\u5FC5\u987B\u662F\u6B63\u6570",n);return cn(n,[new rn(n,new Map([["bpm",c]]),t,null)])}let r=new Map([[0,o]]),a=Ea[e];return a&&(r.set("size",{value:a[0],unit:"em"}),r.set("align",a[1])),cn(n,[new an(n,r,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 i=(r,a)=>{let c=e.get(r)??e.get(a);return c instanceof ft?c instanceof rt?c.content:[c]:[]};this.slots=[new Wt(t,this,"left",i("left",0)),new Wt(t,this,"center",i("center",1)),new Wt(t,this,"right",i("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[i,r]=t.getTemporalNodes(o);return{ast:o,start:i,end:r}});for(let o of e){if(!o.T.isZero())throw new k("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 k("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(i=>` ${i.toString(t).replaceAll(`
32
+ **\u7B80\u5199**\uFF1A\u76F4\u63A5\u5199\u53CC\u5F15\u53F7\u6587\u672C\uFF0C\u5982 \`"\u8FDB\u5165\u4E3B\u9898"\`\uFF1B\u53EF\u8DE8\u884C\uFF0C\u53CC\u5F15\u53F7\u987B\u914D\u5BF9`,allowExtraArgs:!1,args:[{type:"string",description:"\u6587\u672C\u5185\u5BB9\uFF0C\u53EF\u76F4\u63A5\u6362\u884C\uFF1B\u542B\u9017\u53F7\u7B49\u6B67\u4E49\u5B57\u7B26\u65F6\u9700\u52A0\u5F15\u53F7",default:null},{name:"size",description:"\u6587\u672C\u5B57\u53F7",type:"length",default:{value:.8,unit:"em"}},{name:"lineheight",description:"\u76F8\u5BF9\u81EA\u8EAB\u5B57\u53F7\u7684\u884C\u9AD8\u500D\u6570",type:"number",default:1.25},{name:"align",description:"\u6587\u672C\u5BF9\u9F50\u65B9\u5F0F\uFF1A`left`\u3001`center` \u6216 `right`",type:"string",default:"left"},{name:"font",description:"\u6587\u672C\u5B57\u4F53\uFF0C\u7A7A\u503C\u6CBF\u7528\u5F53\u524D\u5B57\u4F53\u8BBE\u7F6E",type:"string",default:""}]};static deSugarAtom(t,e,n){if(t[e]!=='"')return null;let o=Yt(t,e,n);if(o<0)return null;let i={kind:"call",typed:!0,name:"text",args:new Map([[0,oe(t.slice(e,o+1))]]),span:{start:e,end:o+1},syntaxKind:"string"};return{next:o+1,node:i}}lines;size;lineAdvance;align;font;constructor(t,e,n,o=null){super(t,o);let[i,r,a,c,l]=this.getArgValue(e,n);if(this.font=l||n.variables.font,c!=="left"&&c!=="center"&&c!=="right")throw new k("E_TEXT_INVALID_ALIGN","@text \u7684 align \u53C2\u6570\u5FC5\u987B\u662F 'left'\u3001'center' \u6216 'right'",t);this.lines=i.split(/\r?\n/),this.size=n.length2px(r),this.lineAdvance=a*this.size,this.align=c}loweringEnter(){return[new Oo(this)]}toString(){let t=this.size===0?1.25:this.lineAdvance/this.size;return`@text(${ht(this.lines.join(`
33
+ `))}, size=${this.size}px, lineheight=${t}, align=${this.align}, font=${ht(this.font)})`}},Tn=$o,Oo=class extends tt{style;textBaselineY=0;constructor(t){super(),this.ast=t,this.mergeKey=zt,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,i=c=>t.textMeasurer.measureText(c,this.style),r=i(e[0]),a=r.w;for(let c=1;c<e.length;c++)a=Math.max(a,i(e[c]).w);if(this.box.w=a,this.box.h=(e.length-1)*o+r.h,this.box.visualAxis=this.box.h/2,this.textBaselineY=r.baseline,n==="center")this.box.anchor=a/2;else if(n==="right"){let c=[...e[0]].at(-1);this.box.anchor=a-(c?i(c).w/2:0)}else{let c=[...e[0]][0];this.box.anchor=c?i(c).w/2:0}}paint(t){let{lines:e,align:n,lineAdvance:o}=this.ast,i=this.box.x+(n==="center"?this.box.w/2:n==="right"?this.box.w:0),r=this.box.y+this.textBaselineY;for(let a of e)t.drawText(a,i,r,this.style),r+=o}};var zi={title:"center",subtitle:"center",author:"right",signature:"left",tempo:"left",left:"left",center:"center",right:"right"},rc={title:[2,"center"],subtitle:[.85,"center"],author:[.8,"right"]},ac=.25,Hi=5,Wi=1e4;function Ln(s,t){return t.length===1&&t[0]instanceof ut?t[0]:new ut(s,t)}function Gi(s,t,e=s.length){for(;t<e&&s[t]!=="\r"&&s[t]!==`
34
+ `;)t++;return t}function cc({columns:s,rows:t,start:e,end:n,X:o,fixed:i,options:r},a){we(s.slice(e,n+1),t,o.subarray(e,n+1),i.subarray(e,n),1/0,r);let c=1/0,l=-1/0;for(let f=e+1;f<n;f++)for(let p=0;p<t;p++)c=Math.min(c,o[f]-s[f][p].WL),l=Math.max(l,o[f]+s[f][p].WR);a&&c<=l?(o[e]=c,o[n]=l):o[n]=o[e]}function Ui(s,t,e){let n=[],o,i;for(let r of s){if(!r){n.push(null);continue}let a=i===void 0?0:i+t-r.top;n.push({offset:a,extent:r}),o??=a+r.top,i=a+r.bottom}return e?.(o===void 0||i===void 0?null:{top:o,bottom:i}),n}var Cn=class extends tt{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 i=Ui(o,n.gap),r=i.find(a=>a!==null);return this.titleBottom=r?r.offset+r.extent.bottom:0,i}return Ui(o,n.gap,i=>{e==="left"?this.leftExtent=i:this.rightExtent=i})},place:e==="center"?void 0:()=>{let o=e==="left"?this.leftExtent:this.rightExtent;if(!o)return this.titleBottom;let i=this.leftExtent?this.leftExtent.bottom-this.leftExtent.top:0,r=this.rightExtent?this.rightExtent.bottom-this.rightExtent.top:0;return this.titleBottom+Math.max(i,r)-o.bottom}}}prepareHead(t){if(this.members.some(i=>Q(i)&&i.layoutLine!==t.index))throw new k("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 i of this.slots)t.registerHorizontalLayoutHook(i.start,i.end,r=>cc(r,i===n))}alignHead(){let t=new Map;for(let o of this.members){if(!Q(o))continue;let i=this.sideCellOf(o.ast);if(!i)continue;let r=t.get(i);r?r.push(o):t.set(i,[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]*Wi,t.springConfig[o]=t.springConfig[o]*3/Wi}packRows(t,e,n,o){let i=this.ast.owner.size*ac,r=n==="left",a=r?1:-1;for(let c of t.rows){let l=c instanceof ut?c.content:[c],f=e;for(let p=r?0:l.length-1;p>=0&&p<l.length;p+=a){let u=o.get(l[p]);if(!u)continue;let d=1/0,h=-1/0;for(let g of u)d=Math.min(d,g.box.x),h=Math.max(h,g.box.x+g.box.w);let x=f-(r?d:h);for(let g of u)g.box.x+=x;for(let g of u)g.onPlaced?.();f+=a*(h-d+i)}}}sideCellOf(t){let e=t;for(;e.parent;){let n=e.parent,o=n instanceof re?n:n instanceof ut&&n.parent instanceof re?n.parent:null;if(o?.owner===this.ast.owner)return o.name==="center"?null:e;e=n}return null}},re=class extends Et{owner;name;rows;constructor(t,e,n,o){super(t,e),this.owner=e,this.name=n,this.rows=o;for(let i of this.rows)i.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 Cn(this)]}loweringExit(){return[new Cn(this)]}addRow(t){t.parent=this,this.rows.push(t)}},Po=class s extends O{static def={name:["head"],description:"\u5DE6\u3001\u4E2D\u3001\u53F3\u4E09\u533A\u5E03\u5C40",details:"\u5E38\u7528\u4E8E\u8C31\u5934\uFF1A\n~~~jpfun\n@head(left={{@key(C) @meter(4,4)}},\n center={@text(\u6807\u9898)}, right={@text(\u4F5C\u8005)})\n~~~\n**\u7B80\u5199**\uFF1A\u76F8\u90BB\u7684 `H.*:` \u884C\u5408\u5E76\u4E3A\u540C\u4E00\u4E2A\u8C31\u5934\uFF0C\u6BCF\u6761\u58F0\u660E\u751F\u6210\u6240\u5728\u533A\u7684\u4E00\u884C\uFF1B\u7A7A\u884C\u6216\u666E\u901A\u5185\u5BB9\u7ED3\u675F\u7EC4\u5408\n~~~jpfun\nH.title: \u6807\u9898\nH.subtitle: \u526F\u6807\u9898\nH.author: \u4F5C\u8005\nH.signature: 1=C 4/4\nH.tempo: 94\n~~~\n`title` / `subtitle` \u5C45\u4E2D\uFF0C\u5206\u522B\u9884\u8BBE\u5927\u3001\u5C0F\u5B57\u53F7\uFF1B`author` \u5C0F\u5B57\u53F7\u53F3\u5BF9\u9F50\uFF1B`signature` \u548C `tempo` \u653E\u5728\u5DE6\u533A\u3002`H.left:`\u3001`H.center:`\u3001`H.right:` \u53EF\u76F4\u63A5\u5199\u5BF9\u5E94\u533A\u7684\u96F6\u65F6\u957F\u5185\u5BB9\u3002\u4EE5 `@` \u6216 `{` \u5F00\u5934\u7684\u503C\u6309 jpFun \u89E3\u6790\uFF0C\u5176\u4F59\u6309\u5B57\u6BB5\u7684\u6587\u672C\u89C4\u5219\u5904\u7406\u3002",allowExtraArgs:!1,args:[{name:"left",description:"\u5DE6\u533A\u96F6\u65F6\u957F\u5185\u5BB9\uFF0C\u5982\u8C03\u6027\u3001\u62CD\u53F7\u4E0E\u901F\u5EA6\u8BB0\u53F7",type:"content",default:""},{name:"center",description:"\u4E2D\u533A\u96F6\u65F6\u957F\u5185\u5BB9\uFF0C\u5982\u6807\u9898\u4E0E\u526F\u6807\u9898",type:"content",default:""},{name:"right",description:"\u53F3\u533A\u96F6\u65F6\u957F\u5185\u5BB9\uFF0C\u5982\u4F5C\u8005\u4E0E\u7F72\u540D",type:"content",default:""},{name:"gap",description:"\u6BCF\u4E2A\u533A\u5185\u76F8\u90BB\u884C\u7684\u5782\u76F4\u95F4\u8DDD",type:"length",default:{value:Hi,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 i=t.slice(e+2,o);if(!Object.hasOwn(zi,i)||t[o]!==":")return null;o++;let r=Gi(t,o,n),a=Ut(t,o,r);return{next:t[a]==="@"||t[a]==="{"?o:r,node:{kind:"sugar",data:{class:s,field:i},span:{start:e,end:o}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==s)return null;let i=o.data.field,r=n;for(;r<e.length;r++){let m=e[r];if(typeof m=="number"&&(t.source[m]==="\r"||t.source[m]===`
35
+ `)||typeof m!="number"&&m.kind==="sugar"&&m.data?.class===s)break}let a=e[r],c;if(typeof a=="number")c=a;else if(a)c=a.span.start;else if(r>n){let m=e[r-1];c=typeof m=="number"?m+1:m.span.end}else c=Gi(t.source,o.span.end);let l=Ut(t.source,o.span.end,c),f=Ge(t.source,c-1,l),p={start:l,end:Math.max(l,f+1)};if(p.start>=p.end)throw new k("E_HEAD_EMPTY_DECLARATION",`H.${i}: \u540E\u5FC5\u987B\u6709\u5185\u5BB9`,o.span);let u=t.source.slice(p.start,p.end).trim(),d;if(u.startsWith("@")||u.startsWith("{")){let m=new Rt(t);m.makeNodes(e.slice(n,r)),d=m.nodes}let h=t.nodes.at(-1),x=h instanceof s&&h.createdBySugar?h:new s(o.span,new Map,t,null);if(x.createdBySugar=!0,x.addSugarRow(zi[i],s.parseSugarRow(t,i,p,u,d)),x.sourceSpan.end=p.end,x!==h&&t.pushNode(x),typeof a!="number")return r;let g=r+1;if(t.source[a]==="\r"){let m=e[g];typeof m=="number"&&t.source[m]===`
36
+ `&&g++}return g}static parseSugarRow(t,e,n,o,i){if(i!==void 0)return Ln(n,i);if(e==="signature"){let c=/^(1\s*=\s*(\S+))\s+((\d+)\s*\/\s*(\d+))$/.exec(o);if(!c)throw new k("E_HEAD_INVALID_SIGNATURE","H.signature \u7684\u683C\u5F0F\u5E94\u4E3A 1=C 4/4",n);let l={start:n.start,end:n.start+c[1].length},f={start:n.end-c[3].length,end:n.end};return Ln(n,[new wn(l,new Map([["tonality",c[2]]]),t,null),new An(f,new Map([["num",Number(c[4])],["den",Number(c[5])]]),t,null)])}if(e==="tempo"){let c=Number(o);if(!Number.isFinite(c)||c<=0)throw new k("E_HEAD_INVALID_TEMPO","H.tempo \u540E\u5FC5\u987B\u662F\u6B63\u6570",n);return Ln(n,[new En(n,new Map([["bpm",c]]),t,null)])}let r=new Map([[0,o]]),a=rc[e];return a&&(r.set("size",{value:a[0],unit:"em"}),r.set("align",a[1])),Ln(n,[new Tn(n,r,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 i=(r,a)=>{let c=e.get(r)??e.get(a);return c instanceof Et?c instanceof ut?c.content:[c]:[]};this.slots=[new re(t,this,"left",i("left",0)),new re(t,this,"center",i("center",1)),new re(t,this,"right",i("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[i,r]=t.getTemporalNodes(o);return{ast:o,start:i,end:r}});for(let o of e){if(!o.T.isZero())throw new k("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 k("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(i=>` ${i.toString(t).replaceAll(`
34
37
  `,`
35
38
  `)}`).join(`
36
39
  `);return` ${n.name}={
37
40
  ${o}
38
- }`});return this.gap!==di&&e.push(` gap=${this.gap}px`),`@head(
41
+ }`});return this.gap!==Hi&&e.push(` gap=${this.gap}px`),`@head(
39
42
  ${e.join(`,
40
43
  `)}
41
- )`}},gi=xo;var yo=class extends P{static def={name:["br"],description:"\u6362\u884C",details:`~~~jpfun
44
+ )`}},Vi=Po;var Do=class extends O{static def={name:["br"],description:"\u6362\u884C",details:`~~~jpfun
42
45
  1 2 @br() 3 4
43
46
  ~~~
44
47
 
45
48
  \`@br()\` \u6362\u5230\u4E0B\u4E00\u884C\uFF0C\`@br(2)\` \u7A7A\u51FA\u4E00\u884C\u518D\u7EE7\u7EED
46
49
 
47
50
  **\u7B80\u5199**\uFF1A\u4EC5\u5728\u9876\u5C42\uFF0C\u8FDE\u7EED\u81F3\u5C11\u4E24\u4E2A\u6362\u884C\u8868\u793A\u6362\u884C`,allowExtraArgs:!1,args:[{name:"offset",description:"\u540E\u7EED\u5185\u5BB9\u504F\u79FB\u7684\u8C31\u9762\u884C\u6570\uFF0C2 \u8868\u793A\u7A7A\u51FA\u4E00\u884C\u518D\u7EE7\u7EED",type:"number",default:1}]};static deSugarAtom(t,e,n,o){if(o>0||t[e]!==`
48
- `||t[Te(t,e-1)]!==`
49
- `)return null;let i=e+1,r=i;for(;(r=It(t,r,n))<n&&t[r]===`
50
- `;)i=++r;return{next:i,node:{kind:"call",typed:!0,name:"br",args:new Map,span:{start:e,end:i}}}}offset;loweringEnter(){let t=new Q;return t.ast=this,t.mergeKey=-1,t.breakBefore=this.offset,[t]}static loweringFinalize=t=>{let e=new z,n=new z,o=null;for(let i of t.columns){if(o&&e.compare(i[0].t)>0&&i.some(r=>r.breakBefore>0))throw D.error.BreakInsideEvent(o.ast.sourceSpan);for(let r of i)r.T.isZero()||(n.copyFrom(r.t).add(r.T),(!o||n.compare(e)>0)&&(e.copyFrom(n),o=r))}};constructor(t,e,n,o=null){super(t,o);let[i]=this.getArgValue(e,n);this.offset=Number.isFinite(i)?Math.max(1,Math.floor(i)):1,this.offset!==i&&n.diagnostics.push(new G("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})`}},bi=yo;var go="note.jeOctaveOffset",bo=class extends P{static def={name:["note","n"],description:"\u521B\u5EFA\u97F3\u7B26",details:"~~~jpfun\n@note(A, acc=#, octave=3, color=#c33)\n~~~\n**\u7B80\u5199**\uFF1A\u6570\u5B57\u97F3\u540D\u6309\u201C\u5347\u964D\u53F7\u3001\u97F3\u540D\u3001\u76F8\u5BF9\u516B\u5EA6\u201D\u4E66\u5199\uFF1B\u5B57\u6BCD\u97F3\u540D\u6309\u201C\u97F3\u540D\u3001\u5347\u964D\u53F7\u3001\u7EDD\u5BF9\u516B\u5EA6\u201D\u4E66\u5199\u3002`1,,` \u6BD4\u5F53\u524D\u8C03\u6027\u57FA\u51C6\u4F4E\u4E24\u4E2A\u516B\u5EA6\uFF0C`1'` \u9AD8\u4E00\u4E2A\u516B\u5EA6\u3002\n- `A#3` \u7B49\u4EF7\u4E8E `@note(A#3)` \u6216 `@note(A, #, 3)`\n- `#1'` \u7B49\u4EF7\u4E8E `@note(\"#1'\")` \u6216 `@note(1, #, 1)`\n- \u652F\u6301\u7EC4\u5408\u5347\u964D\u53F7\uFF0C\u5982 `A##bn99`\uFF1B\u65E0\u6B67\u4E49\u65F6\u4E5F\u63A5\u53D7\u540E\u7F6E\u5199\u6CD5\uFF0C\u5982 `A3#`\u3001`6#,,`\n- \u5347\u964D\u53F7\u540E\u7D27\u8DDF\u6570\u5B57\u65F6\u5F52\u5165\u4E0B\u4E00\u97F3\u7B26\uFF1A`6#3` \u89E3\u6790\u4E3A `6` \u548C `#3`",allowExtraArgs:!1,args:[{name:"name",description:"\u6570\u5B57\u97F3\u540D\u6216\u5927\u5199\u5B57\u6BCD\u97F3\u540D\uFF0C\u53EF\u81EA\u5E26\u5347\u964D\u53F7\u4E0E\u516B\u5EA6\uFF1B`0` / `Z` \u4E3A\u4F11\u6B62\u7B26\uFF0C`8` \u4E3A\u9690\u5F62\u5360\u4F4D\uFF0C`9` / `X` \u4E3A\u8282\u62CD\u8BB0\u53F7\uFF0C\u540E\u4E09\u7C7B\u4E0D\u663E\u793A\u5347\u964D\u53F7\u548C\u516B\u5EA6\u70B9",type:"string",default:null},{name:"acc",description:"\u989D\u5916\u5347\u964D\u53F7\uFF0C`##` \u518D\u5347\u4E24\u4E2A\u534A\u97F3\uFF0C`b` \u518D\u964D\u4E00\u4E2A\u534A\u97F3",type:"string",default:""},{name:"octave",description:"\u5B57\u6BCD\u97F3\u540D\u4F7F\u7528\u7EDD\u5BF9\u516B\u5EA6\uFF1B\u6570\u5B57\u97F3\u540D\u4F7F\u7528\u76F8\u5BF9\u516B\u5EA6\uFF0C\u7701\u7565\u65F6\u4E3A 0",type:"number",default:4},{name:"color",description:"\u97F3\u7B26\u989C\u8272\uFF0C\u4F7F\u7528 CSS \u989C\u8272\u503C",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 i=Le(t,e,n);if(i instanceof D)return null;let r=new Map;r.set("name",i.name),i.octave!==null&&r.set("octave",i.octave),i.acc&&r.set("acc",i.acc);let a={kind:"call",typed:!0,name:"note",args:r,span:{start:e,end:i.next},syntaxKind:"atom"};return{next:i.next,node:a}}static deSugarRelation(t,e,n){let o=e[n],i=o.data?.jeOffset;return typeof i!="number"?null:(t.variables[go]=(t.variables[go]??0)+i,t.nodes.push(new at(o.span)),n+1)}labelable(){return this}loweringEnter(){return[new wo(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 i=Le(this.name);if(i instanceof D)throw i.span=t,i;if(i.next!==this.name.length)throw new k("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(i.next)}"`,t);this.name=i.name==="X"?"9":i.name==="Z"?"0":i.name;let r=e.get("octave")??e.get(2);if(r!==void 0){if(i.octave!==null&&i.octave!=r)throw new k("E_NOTE_OCTAVE_CONFLICT",`\u51FD\u6570 @note \u7684\u53C2\u6570 "octave" \u4E0E\u97F3\u7B26\u540D\u79F0\u4E2D\u7684\u516B\u5EA6\u4FE1\u606F\u51B2\u7A81: ${r} != ${i.octave}`,t)}else i.octave!==null?this.octave=i.octave:i.absOctave||(this.octave=0);this.jeOctaveOffset=n.variables[go]??0,i.acc!==null&&(this.acc=i.acc+this.acc)}toString(){return`@n(${this.name}, ${this.acc}, ${this.octave}, ${this.color})`}},wi=bo,Ma={8:"",9:"X"},wo=class extends Q{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=Ct,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),i=Math.abs(this.octave);this.octaveDotRadius=e*.065;let r=e*.08,a=this.octaveDotRadius*2+r,c=i===0?0:i*this.octaveDotRadius*2+(i-1)*r+r,l=this.octave>0?c:0;this.numberY=l+o.baseline;let h=e*.01,{placed:p,right:u}=tn(this.acc,e,0,this.numberY,h);if(this.accidentals=p,this.box.w=u+o.w,this.box.h=l+o.h,this.box.anchor=u+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 y=0;y<i;y++)this.upperOctaveDotY.push(l-r-this.octaveDotRadius-y*a);return}if(this.octave>=0)return;let m=i*this.octaveDotRadius*2+(i-1)*r,f={below:{order:100,gap:r,height:m,place:y=>{for(let g=0;g<i;g++)this.lowerOctaveDotY.push(y+this.octaveDotRadius+g*a)}},paint:y=>{for(let g of this.lowerOctaveDotY)y.drawCircle(this.box.x+this.box.anchor,this.box.y+g,this.octaveDotRadius,{fill:n})}};this.decorations.push(f)}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)en(t,o,this.box,e);let n=Ma[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=io(this.name,this.acc,this.octave,e),this.transposeDiatonic=pi(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=ro(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??ee,...e?{percussion:!0}:{transpose:this.transposeDiatonic}}),t.emit({kind:"note-off",at:t.end,noteId:o})}};var hn=class s extends P{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[,i]of e){if(i instanceof ft){this.addContent(i,this.side,n);continue}let r=n.parseArgWithType(i.valueSpan,"content",t.start);r!==null&&this.addContent(r,this.side,n)}}labelable(){return this.children.some(P.findLabelable)?this:null}addContent(t,e,n){return this.contents.length===0&&(e="above"),t instanceof s?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[i,...r]=t.trackedEvents(o,new z,e).flat();if(!i||r.length>0||!U(i))throw new k("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(i)}}),[new To(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,i=o===t?this:t,[r,...a]=i.contents,c=r?[r]:[],l=[...o.contents,...e==="above"?c:[],...a],h=[...o.belows,...e==="below"?c:[],...i.belows];this.contents=l,this.belows=h;for(let u of this.children)u.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 i=this.side==="above"?"@up":"@down",r=t.nodes.length-1;for(;r>=0&&t.nodes[r]instanceof at;)r--;if(r<0)throw new k("E_FOLD_NO_TARGET",`${i}\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807`,o.span);let a=t.nodes[r],c=r;if(a instanceof Lt){let p=a,u=p.target;for(;u&&!t.nodes.includes(u);)u=u.parent;for(let m=r-1;m>=0;m--)if(t.nodes[m]===u){a=new rt({start:u.sourceSpan.start,end:p.sourceSpan.end},t.nodes.slice(m,r+1),null),c=m;break}}let l=a instanceof s?a:new this(o.span,new Map,t).addContent(a,"above",t),h=t.nodes;t.nodes=[],t.makeNodes(e,n);for(let p=0;p<t.nodes.length;p++){let u=t.nodes[p];if(u instanceof at)continue;let m=u instanceof s?u.flatten(l,this.side,t):l.addContent(u,this.side,t);for(h.length=c,h.push(m);++p<t.nodes.length;)h.push(t.nodes[p]);return t.nodes=h,t.labelableNodes.push(m.labelable()),e.length}throw new k("E_FOLD_NO_TARGET",`${i}\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807`,o.span)}},So=class s extends hn{static side="above";static def={name:["up"],description:"\u628A\u540C\u4E00\u65F6\u95F4\u4F4D\u7F6E\u7684\u53EF\u89C1\u5BF9\u8C61\u5411\u4E0A\u5806\u53E0",details:"~~~jpfun\n@up(1, 3, 5)\n~~~\n\n\u7B2C\u4E00\u4E2A\u5185\u5BB9\u53C2\u6570\u4E3A\u5BBF\u4E3B\uFF0C\u5176\u4F59\u4F9D\u6B21\u53E0\u5728\u4E0A\u65B9\uFF1B\u6240\u6709\u6210\u5458\u5171\u4EAB\u5BBF\u4E3B\u65F6\u503C\u3002\u5E38\u7528\u4E8E\u548C\u5F26\u3001\u901F\u5EA6\u8BB0\u53F7\u548C\u97F3\u7B26\u6CE8\u91CA\u3002\n\n**\u7B80\u5199**\uFF1A`1 ^ 3 ^ 5`\u3002\u590D\u6742\u5185\u5BB9\u53EF\u7528 `{...}` \u5305\u88F9\uFF1B\u9700\u8981\u72EC\u7ACB\u8282\u594F\u7684\u5E76\u884C\u5206\u652F\u65F6\uFF0C\u4F7F\u7528 `&` / `@stack`\u3002",allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,n){if(t[e]!=="^")return null;let o={kind:"sugar",data:s,span:{start:e,end:e+1}};return{next:e+1,node:o}}static deSugarRelation(t,e,n){return s.desugar(t,e,n)}},Ao=class s extends hn{static side="below";static def={name:["down"],description:"\u628A\u540C\u4E00\u65F6\u95F4\u4F4D\u7F6E\u7684\u53EF\u89C1\u5BF9\u8C61\u5411\u4E0B\u5806\u53E0",details:"~~~jpfun\n@down(1, $p)\n~~~\n\u7B2C\u4E00\u4E2A\u5185\u5BB9\u53C2\u6570\u4E3A\u5BBF\u4E3B\uFF0C\u5176\u4F59\u4F9D\u6B21\u53E0\u5728\u4E0B\u65B9\u5E76\u5171\u4EAB\u5176\u65F6\u503C\uFF0C\u5E38\u7528\u4E8E\u529B\u5EA6\u7B49\u4E0B\u65B9\u6807\u8BB0\u3002\n\n**\u7B80\u5199**\uFF1A`1 _ $p`\u3002\u4E0E `^` \u6DF7\u5199\u65F6\u5171\u7528\u540C\u4E00\u5BBF\u4E3B\uFF1A`1^2_3` \u5C06 `2` \u653E\u5728 `1` \u4E0A\u65B9\u3001`3` \u653E\u5728\u4E0B\u65B9\u3002",allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,n){if(t[e]!=="_")return null;let o={kind:"sugar",data:s,span:{start:e,end:e+1}};return{next:e+1,node:o}}static deSugarRelation(t,e,n){return s.desugar(t,e,n)}},Si=So,Ai=Ao,To=class extends Q{members;aboveCount;verticalOffsets=[];constructor(t,e){super(),this.ast=t,this.members=e,this.aboveCount=t.contents.length;let n=e.find(i=>!i.T.isZero());n&&this.T.copyFrom(n.T),this.mergeKey=Ct,this.initLayoutBox();let o=e[0]?.addon;o&&(this.addon={...o});for(let i of e)i.mergeKey===ot&&(this.mergeKey=ot),i.addon=void 0,i.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)Nt(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 i=0;for(let h=1;h<this.aboveCount;h++)i-=o+this.members[h].box.h,this.verticalOffsets[h]=i;let r=e.box.h;for(let h=this.aboveCount;h<this.members.length;h++)r+=o,this.verticalOffsets[h]=r,r+=this.members[h].box.h;for(let h=0;h<this.verticalOffsets.length;h++)this.verticalOffsets[h]-=i;this.box.w=e.box.w,this.box.h=r-i,this.box.anchor=n,this.box.visualAxis=e.box.visualAxis-i;let a=this.verticalOffsets[0];for(let h in e.ports){let p=e.ports[h];this.ports[h]={x:p.x,y:a+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 c=this.aboveCount-1,l=this.verticalOffsets[c];this.ports["tie.top"]={x:n,y:l+(this.members[c].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 he=s=>({value:s,unit:"px"}),Lo=16,Na={fontSize:Lo,textAlign:"center",fill:"#606060"};function _a(s,t,e){let n=s.lastIndexOf("1"),o=s.indexOf("1")!==n;return s.replace(/1/g,(i,r)=>String(o&&r===n?e:t))}var Co=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,i)=>{let r=_a(this.pattern,i+1,t.pages.length),{w:a,h:c,baseline:l}=t.textMeasurer.measureText(r,e),h=o.y+o.h-this.marginBottom/2;return{text:r,x:o.x+o.w/2,y:h-c/2+l,w:a,h:c,baseline:l}});return{regions:n.map(({x:o,y:i,w:r,h:a,baseline:c})=>({x:o-r/2,y:i-c,w:r,h:a})),paint(o){for(let i of n)o.drawText(i.text,i.x,i.y,e)}}}},Eo=class extends P{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",details:`~~~jpfun
51
+ `||t[Ge(t,e-1)]!==`
52
+ `)return null;let i=e+1,r=i;for(;(r=Ut(t,r,n))<n&&t[r]===`
53
+ `;)i=++r;return{next:i,node:{kind:"call",typed:!0,name:"br",args:new Map,span:{start:e,end:i}}}}offset;loweringEnter(){let t=new tt;return t.ast=this,t.mergeKey=-1,t.breakBefore=this.offset,[t]}static loweringFinalize=t=>{let e=new F,n=new F,o=null;for(let i of t.columns){if(o&&e.compare(i[0].t)>0&&i.some(r=>r.breakBefore>0))throw D.error.BreakInsideEvent(o.ast.sourceSpan);for(let r of i)r.T.isZero()||(n.copyFrom(r.t).add(r.T),(!o||n.compare(e)>0)&&(e.copyFrom(n),o=r))}};constructor(t,e,n,o=null){super(t,o);let[i]=this.getArgValue(e,n);this.offset=Number.isFinite(i)?Math.max(1,Math.floor(i)):1,this.offset!==i&&n.diagnostics.push(new U("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})`}},ji=Do;var Fo=10,Bo=13,lc=9,fc=11,pc=12,uc=32,hc=160,dc=5760,mc=8239,xc=8287,yc=12288,gc=65279,bc=34,Yi=92,wc=37,Sc=32,Ac=[];function Ec(s){return s>Sc?" ".repeat(s):Ac[s]??=" ".repeat(s)}function Ki(s){return s===uc||s===lc||s===fc||s===pc?!0:s<128?!1:s===hc||s===dc||s>=8192&&s<=8202||s===mc||s===xc||s===yc||s===gc}function Me(s){let t=s.length,e=[0],n=[],o=[],i=(m,y)=>{if(m>=y)return;let w=o.length;if(w>=2&&m<=o[w-1]){y>o[w-1]&&(o[w-1]=y);return}o.push(m,y)},r=(m,y)=>{if(y<=0)return;let w=m+y;for(let E=m;E<w;E+=2)i(E,E+1)},a=0,c=!1,l=!1,f=-1,p=-1,u=-1,d=0,h=(m,y)=>{if(y===Yi){d>0&&p+1===m?d++:(u=m,d=1),p=m;return}u=-1,d=0,p=m};for(let m=0;m<t;){let y=s.charCodeAt(m);if(y===Bo||y===Fo){let w=y===Bo&&m+1<t&&s.charCodeAt(m+1)===Fo?2:1;e.push(m+w);let E=(d&1)===1;r(u,d),f>=0&&(i(f,m),n.push({start:f,end:m}),f=-1),E&&i(m,m+w),p=-1,u=-1,d=0,l=!1,m+=w;continue}if(a!==0){l?l=!1:y===Yi?l=!0:y===a&&(a=0),Ki(y)||h(m,y),m++;continue}if(y===bc){c||(Yt(s,m,t)<0?c=!0:a=y),h(m,y),m++;continue}if(y===wc){for(f=m,m++;m<t;){let w=s.charCodeAt(m);if(w===Bo||w===Fo)break;m++}continue}Ki(y)||h(m,y),m++}if(r(u,d),f>=0&&(i(f,t),n.push({start:f,end:t})),o.length===0)return{maskedSource:s,lineStarts:e,commentSpans:n};let x=[],g=0;for(let m=0;m<o.length;m+=2){let y=o[m],w=o[m+1];g<y&&x.push(s.slice(g,y)),x.push(Ec(w-y)),g=w}return g<t&&x.push(s.slice(g)),{maskedSource:x.join(""),lineStarts:e,commentSpans:n}}var Xt="CDEFGAB",vn=(s,t)=>(s%t+t)%t,Tc=s=>s<0?"b".repeat(-s):"#".repeat(s);function Mn(s){throw new k("E_NOTE_TRANSFORM","\u65E0\u6CD5\u5B89\u5168\u6539\u5199\u6B64\u97F3\u7B26\u7684\u97F3\u9AD8",s)}function Lc(s,t){let e=t==="to-absolute"||t!=="to-relative"&&Xt.includes(s.ast.name),n=s.resolvedMidi+(t==="semitone-up"?1:t==="semitone-down"?-1:0),o=ie(s.keySignature,4);[n,o,s.ast.octave,s.ast.jeOctaveOffset].every(Number.isSafeInteger)||Mn(s.ast.sourceSpan);let i=t==="semitone-down"?Di:Kt,r,a,c;if(t==="to-absolute"){let l=Xt.indexOf(s.keySignature[0]),f=l<0?Xt.indexOf(Kt[vn(o,12)][0]):l,p=Number(s.ast.name)-1;r=Xt[(f+p)%7];let u=vn(o-Tt[Xt[f]]+6,12)-6;c=Math.floor((o-u)/12)-1+Math.floor((f+p)/7)+s.ast.octave+s.ast.jeOctaveOffset,a=Tc(n-((c+1)*12+Tt[r]))}else if(t==="to-relative"){let l=s.ast,f=Xt.includes(s.keySignature[0])?s.keySignature:Kt[vn(o,12)]+(Math.floor(o/12)-1),p=Ue(l.name,l.acc,l.octave+l.jeOctaveOffset,f);p||Mn(l.sourceSpan),{renderName:r,renderAcc:a,renderOctave:c}=p}else{let l=e?n:n-o,f=i[vn(l,12)];r=e?f[0]:String(Xt.indexOf(f[0])+1),a=f.slice(1),c=Math.floor(l/12)-(e?1:0)}return{name:r,acc:a,octave:c-s.ast.jeOctaveOffset,absolute:e}}function Cc(s,t){for(let e=t.parent;e;e=e.parent){let n=We(s,e.sourceSpan.start,e.sourceSpan.end);if(!n)continue;let o=n.args.find(r=>r.valueSpan.start<=t.sourceSpan.start&&r.valueSpan.end>=t.sourceSpan.end);if(!o)continue;let i=0;for(let r=o.valueSpan.start;r<t.sourceSpan.start;r++)s[r]==='"'?r=Yt(s,r,o.valueSpan.end):s[r]==="{"?i++:s[r]==="}"&&i--;return i===0}return!1}function Xi(s,t,e,n){let{maskedSource:o}=Me(s),i=[],r=[];function a(l,f){s.slice(l.start,l.end)!==f&&(s.slice(l.start,l.end)!==o.slice(l.start,l.end)&&Mn(l),i.push({span:l,text:f}))}for(let l of t){let M=function(T,S,b){let v=!b||b.includes(",")||T&&s[T.start]==='"'?ht(b):b;T?a(T,v):L.push(`${S}=${v}`)};var c=M;let{ast:f}=l,p=f.sourceSpan,u=We(o,p.start,p.end),d=u?.span.end===p.end&&u.closeParenSpan,h=e==="to-absolute"&&Xt.includes(f.name)||e==="to-relative"&&/^[1-7]$/.test(f.name);if(d||r.push({span:p,text:s.slice(p.start,p.end)}),n&&!n.some(T=>T.start<=p.start&&T.end>=p.end)||l.resolvedMidi===null||h)continue;let x=Lc(l,e),g=x.absolute?String(x.octave):x.octave<0?",".repeat(-x.octave):"'".repeat(x.octave),m=(T,S)=>x.absolute?x.name+T+S:T+x.name+S;if(!d){let T=m(x.acc,g);T.includes(",")&&Cc(o,f)&&(T=`{${T}}`),r[r.length-1].text=T;continue}let y=new Map;u.args.forEach((T,S)=>{T.valueSpan.start!==T.valueSpan.end&&y.set(T.nameSpan?o.slice(T.nameSpan.start,T.nameSpan.end).toLowerCase():S,T.valueSpan)});let w=y.get("name")??y.get(0),E=y.get("acc")??y.get(1),A=y.get("octave")??y.get(2),L=[];if(M(w,"name",m(E?"":x.acc,A?"":g)),E?M(E,"acc",x.acc):f.hasDefaultAcc&&L.push('acc=""'),A&&a(A,String(x.octave)),L.length){let T=u.closeParenSpan.start,S=o.slice(u.openParenSpan.end,T).trimEnd();a({start:T,end:T},(S?S.endsWith(",")?" ":", ":"")+L.join(", "))}}r.sort((l,f)=>l.span.start-f.span.start);for(let l=0;l<r.length-1;l++){let f=r[l],p=r[l+1];if(f.span.end!==p.span.start||f.text.endsWith("}"))continue;let u=se(f.text+p.text);(u instanceof D||u.next!==f.text.length)&&(f.text!==s.slice(f.span.start,f.span.end)?f.text+=" ":p.text=" "+p.text)}for(let l of r)a(l.span,l.text);i.sort((l,f)=>l.span.start-f.span.start);for(let l=1;l<i.length;l++)i[l-1].span.end>i[l].span.start&&Mn(i[l].span);return i}function qi(s,t,e,n){let o=t.diagnostics.find(a=>a instanceof k);if(o)throw o;let i=[...t.astToTemporal.values()].flat().filter(a=>a instanceof Nn),r=t.diagnostics.find(a=>i.some(c=>a.span.start<c.ast.sourceSpan.end&&a.span.end>c.ast.sourceSpan.start));if(r)throw r;return Xi(s,i,e,n)}var zo="note.jeOctaveOffset",Ho=class extends O{static def={name:["note","n"],description:"\u521B\u5EFA\u97F3\u7B26",details:"~~~jpfun\n@note(A, acc=#, octave=3, color=#c33)\n~~~\n**\u7B80\u5199**\uFF1A\u6570\u5B57\u97F3\u540D\u6309\u201C\u5347\u964D\u53F7\u3001\u97F3\u540D\u3001\u76F8\u5BF9\u516B\u5EA6\u201D\u4E66\u5199\uFF1B\u5B57\u6BCD\u97F3\u540D\u6309\u201C\u97F3\u540D\u3001\u5347\u964D\u53F7\u3001\u7EDD\u5BF9\u516B\u5EA6\u201D\u4E66\u5199\u3002`1,,` \u6BD4\u5F53\u524D\u8C03\u6027\u57FA\u51C6\u4F4E\u4E24\u4E2A\u516B\u5EA6\uFF0C`1'` \u9AD8\u4E00\u4E2A\u516B\u5EA6\u3002\n- \u7B80\u5199\u7684\u5347\u964D\u53F7\u5B8C\u5168\u7531\u81EA\u8EAB\u51B3\u5B9A\uFF0C\u7701\u7565\u65F6\u4E3A\u7A7A\uFF0C\u4E0D\u7EE7\u627F `@set(note.acc=...)`\uFF1B\u663E\u5F0F\u8C03\u7528\u7701\u7565 `acc` \u65F6\u4ECD\u7EE7\u627F\u9ED8\u8BA4\u503C\n- `A#3` \u7B49\u4EF7\u4E8E `@note(A, #, 3)`\uFF0C\u9ED8\u8BA4 `acc` \u4E3A\u7A7A\u65F6\u4E5F\u7B49\u4EF7\u4E8E `@note(A#3)`\n- `#1'` \u7B49\u4EF7\u4E8E `@note(1, #, 1)`\uFF0C\u9ED8\u8BA4 `acc` \u4E3A\u7A7A\u65F6\u4E5F\u7B49\u4EF7\u4E8E `@note(\"#1'\")`\n- \u652F\u6301\u7EC4\u5408\u5347\u964D\u53F7\uFF0C\u5982 `A##bn99`\uFF1B\u65E0\u6B67\u4E49\u65F6\u4E5F\u63A5\u53D7\u540E\u7F6E\u5199\u6CD5\uFF0C\u5982 `A3#`\u3001`6#,,`\n- \u5347\u964D\u53F7\u540E\u7D27\u8DDF\u6570\u5B57\u65F6\u5F52\u5165\u4E0B\u4E00\u97F3\u7B26\uFF1A`6#3` \u89E3\u6790\u4E3A `6` \u548C `#3`",allowExtraArgs:!1,args:[{name:"name",description:"\u6570\u5B57\u97F3\u540D\u6216\u5927\u5199\u5B57\u6BCD\u97F3\u540D\uFF0C\u53EF\u81EA\u5E26\u5347\u964D\u53F7\u4E0E\u516B\u5EA6\uFF1B`0` / `Z` \u4E3A\u4F11\u6B62\u7B26\uFF0C`8` \u4E3A\u9690\u5F62\u5360\u4F4D\uFF0C`9` / `X` \u4E3A\u8282\u62CD\u8BB0\u53F7\uFF0C\u540E\u4E09\u7C7B\u4E0D\u663E\u793A\u5347\u964D\u53F7\u548C\u516B\u5EA6\u70B9",type:"string",default:null},{name:"acc",description:"\u989D\u5916\u5347\u964D\u53F7\uFF0C`##` \u518D\u5347\u4E24\u4E2A\u534A\u97F3\uFF0C`b` \u518D\u964D\u4E00\u4E2A\u534A\u97F3",type:"string",default:""},{name:"octave",description:"\u5B57\u6BCD\u97F3\u540D\u4F7F\u7528\u7EDD\u5BF9\u516B\u5EA6\uFF1B\u6570\u5B57\u97F3\u540D\u4F7F\u7528\u76F8\u5BF9\u516B\u5EA6\uFF0C\u7701\u7565\u65F6\u4E3A 0",type:"number",default:4},{name:"color",description:"\u97F3\u7B26\u989C\u8272\uFF0C\u4F7F\u7528 CSS \u989C\u8272\u503C",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 i=se(t,e,n);if(i instanceof D)return null;let r=new Map;r.set("name",i.name),i.octave!==null&&r.set("octave",i.octave),r.set("acc",i.acc??"");let a={kind:"call",typed:!0,name:"note",args:r,span:{start:e,end:i.next},syntaxKind:"atom"};return{next:i.next,node:a}}static deSugarRelation(t,e,n){let o=e[n],i=o.data?.jeOffset;return typeof i!="number"?null:(t.variables[zo]=(t.variables[zo]??0)+i,t.nodes.push(new xt(o.span)),n+1)}labelable(){return this}loweringEnter(){return[new Nn(this)]}name;octave;acc;color;size;font;jeOctaveOffset;hasDefaultAcc;constructor(t,e,n,o=null){super(t,o),this.hasDefaultAcc=!!n.variables["note.acc"],[this.name,this.acc,this.octave,this.color]=this.getArgValue(e,n),this.font=n.variables.numberfont,this.size=n.variables.fontsize;let i=se(this.name);if(i instanceof D)throw i.span=t,i;if(i.next!==this.name.length)throw new k("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(i.next)}"`,t);this.name=i.name==="X"?"9":i.name==="Z"?"0":i.name;let r=e.get("octave")??e.get(2);if(r!==void 0){if(i.octave!==null&&i.octave!=r)throw new k("E_NOTE_OCTAVE_CONFLICT",`\u51FD\u6570 @note \u7684\u53C2\u6570 "octave" \u4E0E\u97F3\u7B26\u540D\u79F0\u4E2D\u7684\u516B\u5EA6\u4FE1\u606F\u51B2\u7A81: ${r} != ${i.octave}`,t)}else i.octave!==null?this.octave=i.octave:i.absOctave||(this.octave=0);this.jeOctaveOffset=n.variables[zo]??0,i.acc!==null&&(this.acc=i.acc+this.acc)}toString(){return`@n(${this.name}, ${this.acc||'""'}, ${this.octave}, ${this.color})`}},Zi=Ho,vc={8:"",9:"X"},Nn=class extends tt{resolvedMidi=null;keySignature="C4";transposeDiatonic;name;acc;octave;accidentals=[];numberStyle;upperOctaveDotY=[];lowerOctaveDotY=[];octaveDotRadius=0;numberY=0;constructor(t){super(),this.ast=t,this.T.set(1),this.mergeKey=zt,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),i=Math.abs(this.octave);this.octaveDotRadius=e*.075;let r=e*.08,a=this.octaveDotRadius*2+r,c=i===0?0:i*this.octaveDotRadius*2+(i-1)*r+r,l=this.octave>0?c:0;this.numberY=l+o.baseline;let f=e*.01,{placed:p,right:u}=gn(this.acc,e,0,this.numberY,f);if(this.accidentals=p,this.box.w=u+o.w,this.box.h=l+o.h,this.box.anchor=u+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.shoulder={x:this.box.anchor,y:l},this.ports.dot={x:this.box.w,y:l+o.h*.64},this.octave>0){for(let x=0;x<i;x++)this.upperOctaveDotY.push(l-r-this.octaveDotRadius-x*a);return}if(this.octave>=0)return;let d=i*this.octaveDotRadius*2+(i-1)*r,h={below:{order:100,gap:r,height:d,place:x=>{for(let g=0;g<i;g++)this.lowerOctaveDotY.push(x+this.octaveDotRadius+g*a)}},paint:x=>{for(let g of this.lowerOctaveDotY)x.drawCircle(this.box.x+this.box.anchor,this.box.y+g,this.octaveDotRadius,{fill:n})}};this.decorations.push(h)}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)bn(t,o,this.box,e);let n=vc[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=this.keySignature=t.keySignature;if(this.playbackState={bpm:t.bpm,velocity:t.velocity,program:t.program},this.resolvedMidi=vo(this.name,this.acc,this.octave,e),this.transposeDiatonic=Fi(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=Ue(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(!(t.end.compare(t.start)<=0)){if(n===null){t.span({start:t.start,end:t.end});return}t.note({start:t.start,end:t.end,midi:n,velocity:this.playbackState?.velocity??ge,...e?{percussion:!0}:{transpose:this.transposeDiatonic}})}}};var kn=class s extends O{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[,i]of e){if(i instanceof Et){this.addContent(i,this.side,n);continue}let r=n.parseArgWithType(i.valueSpan,"content",t.start);r!==null&&this.addContent(r,this.side,n)}}labelable(){return this.children.some(O.findLabelable)?this:null}addContent(t,e,n){return this.contents.length===0&&(e="above"),t instanceof s?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[i,...r]=t.trackedEvents(o,new F,e).flat();if(!i||r.length>0||!Q(i))throw new k("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(i)}}),[new Uo(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,i=o===t?this:t,[r,...a]=i.contents,c=r?[r]:[],l=[...o.contents,...e==="above"?c:[],...a],f=[...o.belows,...e==="below"?c:[],...i.belows];this.contents=l,this.belows=f;for(let u of this.children)u.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 i=this.side==="above"?"@up":"@down",r=t.nodes.length-1;for(;r>=0&&t.nodes[r]instanceof xt;)r--;if(r<0)throw new k("E_FOLD_NO_TARGET",`${i}\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u5DE6\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807`,o.span);let a=t.nodes[r],c=r;if(a instanceof Bt){let p=a,u=p.target;for(;u&&!t.nodes.includes(u);)u=u.parent;for(let d=r-1;d>=0;d--)if(t.nodes[d]===u){a=new ut({start:u.sourceSpan.start,end:p.sourceSpan.end},t.nodes.slice(d,r+1),null),c=d;break}}let l=a instanceof s?a:new this(o.span,new Map,t).addContent(a,"above",t),f=t.nodes;t.nodes=[],t.makeNodes(e,n);for(let p=0;p<t.nodes.length;p++){let u=t.nodes[p];if(u instanceof xt)continue;let d=u instanceof s?u.flatten(l,this.side,t):l.addContent(u,this.side,t);for(f.length=c,f.push(d);++p<t.nodes.length;)f.push(t.nodes[p]);return t.nodes=f,t.labelableNodes.push(d.labelable()),e.length}throw new k("E_FOLD_NO_TARGET",`${i}\u8BED\u6CD5\u7CD6\u9519\u8BEF: \u53F3\u8FB9\u6CA1\u6709\u627E\u5230\u53EF\u53E0\u52A0\u7684\u76EE\u6807`,o.span)}},Wo=class s extends kn{static side="above";static def={name:["up"],description:"\u628A\u540C\u4E00\u65F6\u95F4\u4F4D\u7F6E\u7684\u53EF\u89C1\u5BF9\u8C61\u5411\u4E0A\u5806\u53E0",details:"~~~jpfun\n@up(1, 3, 5)\n~~~\n\n\u7B2C\u4E00\u4E2A\u5185\u5BB9\u53C2\u6570\u4E3A\u5BBF\u4E3B\uFF0C\u5176\u4F59\u4F9D\u6B21\u53E0\u5728\u4E0A\u65B9\uFF1B\u6240\u6709\u6210\u5458\u5171\u4EAB\u5BBF\u4E3B\u65F6\u503C\u3002\u5E38\u7528\u4E8E\u548C\u5F26\u3001\u901F\u5EA6\u8BB0\u53F7\u548C\u97F3\u7B26\u6CE8\u91CA\u3002\n\n**\u7B80\u5199**\uFF1A`1 ^ 3 ^ 5`\u3002\u590D\u6742\u5185\u5BB9\u53EF\u7528 `{...}` \u5305\u88F9\uFF1B\u9700\u8981\u72EC\u7ACB\u8282\u594F\u7684\u5E76\u884C\u5206\u652F\u65F6\uFF0C\u4F7F\u7528 `&` / `@stack`\u3002",allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,n){if(t[e]!=="^")return null;let o={kind:"sugar",data:s,span:{start:e,end:e+1}};return{next:e+1,node:o}}static deSugarRelation(t,e,n){return s.desugar(t,e,n)}},Go=class s extends kn{static side="below";static def={name:["down"],description:"\u628A\u540C\u4E00\u65F6\u95F4\u4F4D\u7F6E\u7684\u53EF\u89C1\u5BF9\u8C61\u5411\u4E0B\u5806\u53E0",details:"~~~jpfun\n@down(1, $p)\n~~~\n\u7B2C\u4E00\u4E2A\u5185\u5BB9\u53C2\u6570\u4E3A\u5BBF\u4E3B\uFF0C\u5176\u4F59\u4F9D\u6B21\u53E0\u5728\u4E0B\u65B9\u5E76\u5171\u4EAB\u5176\u65F6\u503C\uFF0C\u5E38\u7528\u4E8E\u529B\u5EA6\u7B49\u4E0B\u65B9\u6807\u8BB0\u3002\n\n**\u7B80\u5199**\uFF1A`1 _ $p`\u3002\u4E0E `^` \u6DF7\u5199\u65F6\u5171\u7528\u540C\u4E00\u5BBF\u4E3B\uFF1A`1^2_3` \u5C06 `2` \u653E\u5728 `1` \u4E0A\u65B9\u3001`3` \u653E\u5728\u4E0B\u65B9\u3002",allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,n){if(t[e]!=="_")return null;let o={kind:"sugar",data:s,span:{start:e,end:e+1}};return{next:e+1,node:o}}static deSugarRelation(t,e,n){return s.desugar(t,e,n)}},Qi=Wo,Ji=Go,Uo=class extends tt{members;aboveCount;verticalOffsets=[];constructor(t,e){super(),this.ast=t,this.members=e,this.aboveCount=t.contents.length;let n=e.find(i=>!i.T.isZero());n&&this.T.copyFrom(n.T),this.mergeKey=zt,this.initLayoutBox();let o=e[0]?.addon;o&&(this.addon={...o});for(let i of e)i.mergeKey===ct&&(this.mergeKey=ct),i.addon=void 0,i.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);let e=this.members[0];if(!e){this.box.w=this.box.h=0,this.box.anchor=this.box.visualAxis=0;return}this.box.w=Ae([e],t);for(let f=1;f<this.members.length;f++)Ae([this.members[f]],t);this.springConfig={...e.springConfig,...this.springConfig};let n=e.box.x+e.box.anchor,o=this.ast.size*.12;this.verticalOffsets.length=this.members.length,this.verticalOffsets.fill(0);let i=0;for(let f=1;f<this.aboveCount;f++)i-=o+this.members[f].box.h,this.verticalOffsets[f]=i;let r=e.box.h;for(let f=this.aboveCount;f<this.members.length;f++)r+=o,this.verticalOffsets[f]=r,r+=this.members[f].box.h;for(let f=0;f<this.verticalOffsets.length;f++)this.verticalOffsets[f]-=i;this.box.h=r-i,this.box.anchor=n,this.box.visualAxis=e.box.visualAxis-i;let a=this.verticalOffsets[0];for(let f in e.ports){let p=e.ports[f];this.ports[f]={...p,x:e.box.x+p.x,y:a+p.y}}this.ports["body.left"]??={x:e.box.x,y:this.box.visualAxis},this.ports["body.right"]??={x:e.box.x+e.box.w,y:this.box.visualAxis};let c=this.aboveCount-1,l=this.verticalOffsets[c];this.ports["tie.top"]={x:n,y:l+(this.members[c].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 Ne=s=>({value:s,unit:"px"}),Vo=16,Mc={fontSize:Vo,textAlign:"center",fill:"#606060"};function Nc(s,t,e){let n=s.lastIndexOf("1"),o=s.indexOf("1")!==n;return s.replace(/1/g,(i,r)=>String(o&&r===n?e:t))}var jo=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,i)=>{let r=Nc(this.pattern,i+1,t.pages.length),{w:a,h:c,baseline:l}=t.textMeasurer.measureText(r,e),f=o.y+o.h-this.marginBottom/2;return{text:r,x:o.x+o.w/2,y:f-c/2+l,w:a,h:c,baseline:l}});return{regions:n.map(({x:o,y:i,w:r,h:a,baseline:c})=>({x:o-r/2,y:i-c,w:r,h:a})),paint(o){for(let i of n)o.drawText(i.text,i.x,i.y,e)}}}},Yo=class extends O{static def={name:["page"],description:"\u8BBE\u7F6E\u6587\u6863\u9875\u9762",details:`~~~jpfun
51
54
  @page(
52
55
  width=794px, height=1123px, top=48px, bottom=48px,
53
- left=40px, right=40px, gap=1em, numbering="1/1"
56
+ left=40px, right=40px, gap=1em, numbering="1/1", fillRatio=0.5
54
57
  )
55
58
  ~~~
56
- \u5C3A\u5BF8\u63A5\u53D7 \`px\` \u6216 \`em\`\u3002\u9875\u8FB9\u8DDD\u548C\u884C\u8DDD\u987B\u975E\u8D1F\uFF0C\u5DE6\u53F3\u8FB9\u8DDD\u4E4B\u548C\u987B\u5C0F\u4E8E\u9875\u5BBD\uFF1B\u56FA\u5B9A\u9875\u9AD8\u65F6\uFF0C\u4E0A\u4E0B\u8FB9\u8DDD\u4E4B\u548C\u4E5F\u987B\u5C0F\u4E8E\u9875\u9AD8\u3002`,allowExtraArgs:!1,args:[{name:"width",description:"\u9875\u9762\u5BBD\u5EA6\uFF0C\u987B\u5927\u4E8E\u5DE6\u53F3\u9875\u8FB9\u8DDD\u4E4B\u548C",type:"length",default:he(xt.width)},{name:"height",description:"\u9875\u9762\u9AD8\u5EA6\uFF0C0 \u8868\u793A\u4E0D\u5206\u9875\u3001\u9AD8\u5EA6\u968F\u5185\u5BB9\u589E\u957F\uFF1B\u5BBD\u5EA6\u4E3A `794px` \u65F6\uFF0CA4 \u5BF9\u5E94\u9AD8\u5EA6\u7EA6\u4E3A `1123px`",type:"length",default:he(0)},{name:"top",description:"\u9875\u9762\u4E0A\u8FB9\u8DDD",type:"length",default:he(xt.marginTop)},{name:"bottom",description:"\u9875\u9762\u4E0B\u8FB9\u8DDD\uFF0C\u542F\u7528\u9875\u7801\u65F6\u81F3\u5C11\u4E3A `16px`",type:"length",default:he(xt.marginBottom)},{name:"left",description:"\u9875\u9762\u5DE6\u8FB9\u8DDD",type:"length",default:he(xt.marginLeft)},{name:"right",description:"\u9875\u9762\u53F3\u8FB9\u8DDD",type:"length",default:he(xt.marginRight)},{name:"gap",description:"\u8C31\u9762\u884C\u4E4B\u95F4\u7684\u6700\u5C0F\u95F4\u8DDD",type:"length",default:{value:1,unit:"em"}},{name:"numbering",description:"\u9875\u7801\u683C\u5F0F\uFF0C\u7A7A\u503C\u9690\u85CF\uFF1B`1` \u663E\u793A\u5F53\u524D\u9875\uFF0C`1/1` \u663E\u793A\u5F53\u524D\u9875/\u603B\u9875\u6570",type:"string",default:""},{name:"font",description:"\u9875\u7801\u5B57\u4F53\uFF0C\u7A7A\u503C\u6CBF\u7528\u5F53\u524D\u5B57\u4F53\u8BBE\u7F6E",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 G("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 G("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 i=this.getArgValue(e,n);this.font=i.pop()||n.variables.font;let r=i.pop(),[a,c,l,h,p,u,m]=i.map(f=>n.length2px(f));if(!Number.isFinite(a)||a<=0)throw D.error.InvalidPageConfig("@page \u7684 width \u5FC5\u987B\u662F\u6B63\u6709\u9650\u957F\u5EA6",t);if(!Number.isFinite(c)||c<0)throw D.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,u,m].some(f=>!Number.isFinite(f)||f<0))throw D.error.InvalidPageConfig("@page \u7684\u8FB9\u8DDD\u548C gap \u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u957F\u5EA6",t);if(p+u>=a)throw D.error.InvalidPageConfig("@page \u7684\u5DE6\u53F3\u8FB9\u8DDD\u6CA1\u6709\u7559\u4E0B\u53EF\u7528\u5185\u5BB9\u5BBD\u5EA6",t);if(c>0&&l+h>=c)throw D.error.InvalidPageConfig("@page \u7684\u4E0A\u4E0B\u8FB9\u8DDD\u6CA1\u6709\u7559\u4E0B\u53EF\u7528\u5185\u5BB9\u9AD8\u5EA6",t);if(r&&h<Lo)throw D.error.InvalidPageConfig(`@page \u7684 bottom \u81F3\u5C11\u9700\u8981 ${Lo}px \u624D\u80FD\u653E\u4E0B\u9875\u7801`,t);this.config=ge({width:a,height:c,marginTop:l,marginBottom:h,marginLeft:p,marginRight:u,lineGap:m}),this.numbering=r}loweringEnter(t){return!t||!this.config?[]:(t.setPageConfig(this.config),this.numbering&&t.addAttachment(new Co(this.sourceSpan,this.numbering,this.config.marginBottom,{...Na,fontFamily:this.font})),[])}toString(){if(!this.config)return"@page()";let{width:t,height:e,marginTop:n,marginBottom:o,marginLeft:i,marginRight:r,lineGap:a}=this.config;return`@page(width=${t}px, height=${Number.isFinite(e)?e:0}px, top=${n}px, bottom=${o}px, left=${i}px, right=${r}px, gap=${a}px, numbering=${ht(this.numbering)}, font=${ht(this.font)})`}},Ti=Eo;var vo=class extends P{static def={name:["program","instrument"],description:"\u8BBE\u7F6E\u5F53\u524D\u97F3\u8F68\u7684 MIDI \u97F3\u8272",details:`~~~jpfun
59
+ \u5C3A\u5BF8\u63A5\u53D7 \`px\` \u6216 \`em\`\u3002\u9875\u8FB9\u8DDD\u548C\u884C\u8DDD\u987B\u975E\u8D1F\uFF1B\u5DE6\u53F3\u8FB9\u8DDD\u4E4B\u548C\u987B\u5C0F\u4E8E\u9875\u5BBD\uFF0C\u56FA\u5B9A\u9875\u9AD8\u65F6\u4E0A\u4E0B\u8FB9\u8DDD\u4E4B\u548C\u987B\u5C0F\u4E8E\u9875\u9AD8\u3002`,allowExtraArgs:!1,args:[{name:"width",description:"\u9875\u9762\u5BBD\u5EA6\uFF0C\u987B\u5927\u4E8E\u5DE6\u53F3\u9875\u8FB9\u8DDD\u4E4B\u548C",type:"length",default:Ne(St.width)},{name:"height",description:"\u9875\u9762\u9AD8\u5EA6\uFF0C0 \u8868\u793A\u4E0D\u5206\u9875\u3001\u9AD8\u5EA6\u968F\u5185\u5BB9\u589E\u957F\uFF1B\u5BBD\u5EA6\u4E3A `794px` \u65F6\uFF0CA4 \u5BF9\u5E94\u9AD8\u5EA6\u7EA6\u4E3A `1123px`",type:"length",default:Ne(0)},{name:"top",description:"\u9875\u9762\u4E0A\u8FB9\u8DDD",type:"length",default:Ne(St.marginTop)},{name:"bottom",description:"\u9875\u9762\u4E0B\u8FB9\u8DDD\uFF0C\u542F\u7528\u9875\u7801\u65F6\u81F3\u5C11\u4E3A `16px`",type:"length",default:Ne(St.marginBottom)},{name:"left",description:"\u9875\u9762\u5DE6\u8FB9\u8DDD",type:"length",default:Ne(St.marginLeft)},{name:"right",description:"\u9875\u9762\u53F3\u8FB9\u8DDD",type:"length",default:Ne(St.marginRight)},{name:"gap",description:"\u8C31\u9762\u884C\u4E4B\u95F4\u7684\u6700\u5C0F\u95F4\u8DDD",type:"length",default:{value:1,unit:"em"}},{name:"numbering",description:"\u9875\u7801\u683C\u5F0F\uFF0C\u7A7A\u503C\u9690\u85CF\uFF1B`1` \u663E\u793A\u5F53\u524D\u9875\uFF0C`1/1` \u663E\u793A\u5F53\u524D\u9875/\u603B\u9875\u6570",type:"string",default:""},{name:"font",description:"\u9875\u7801\u5B57\u4F53\uFF0C\u7A7A\u503C\u6CBF\u7528\u5F53\u524D\u5B57\u4F53\u8BBE\u7F6E",type:"string",default:""},{name:"fillRatio",description:"\u81EA\u7136\u5BBD\u5EA6\u8FBE\u5230\u8BE5\u6BD4\u4F8B\u540E\u6491\u6EE1",type:"number",default:St.fillRatio}]};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 U("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 U("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 i=this.getArgValue(e,n),r=i.pop();this.font=i.pop()||n.variables.font;let a=i.pop(),[c,l,f,p,u,d,h]=i.map(x=>n.length2px(x));if(!Number.isFinite(c)||c<=0)throw D.error.InvalidPageConfig("@page \u7684 width \u5FC5\u987B\u662F\u6B63\u6709\u9650\u957F\u5EA6",t);if(!Number.isFinite(l)||l<0)throw D.error.InvalidPageConfig("@page \u7684 height \u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u957F\u5EA6\uFF1B0 \u8868\u793A\u4E0D\u5206\u9875",t);if([f,p,u,d,h].some(x=>!Number.isFinite(x)||x<0))throw D.error.InvalidPageConfig("@page \u7684\u8FB9\u8DDD\u548C gap \u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u957F\u5EA6",t);if(u+d>=c)throw D.error.InvalidPageConfig("@page \u7684\u5DE6\u53F3\u8FB9\u8DDD\u6CA1\u6709\u7559\u4E0B\u53EF\u7528\u5185\u5BB9\u5BBD\u5EA6",t);if(l>0&&f+p>=l)throw D.error.InvalidPageConfig("@page \u7684\u4E0A\u4E0B\u8FB9\u8DDD\u6CA1\u6709\u7559\u4E0B\u53EF\u7528\u5185\u5BB9\u9AD8\u5EA6",t);if(a&&p<Vo)throw D.error.InvalidPageConfig(`@page \u7684 bottom \u81F3\u5C11\u9700\u8981 ${Vo}px \u624D\u80FD\u653E\u4E0B\u9875\u7801`,t);this.config=Pe({width:c,height:l,marginTop:f,marginBottom:p,marginLeft:u,marginRight:d,lineGap:h,fillRatio:r}),this.numbering=a}loweringEnter(t){return!t||!this.config?[]:(t.setPageConfig(this.config),this.numbering&&t.addAttachment(new jo(this.sourceSpan,this.numbering,this.config.marginBottom,{...Mc,fontFamily:this.font})),[])}toString(){if(!this.config)return"@page()";let{width:t,height:e,marginTop:n,marginBottom:o,marginLeft:i,marginRight:r,lineGap:a,fillRatio:c}=this.config;return`@page(width=${t}px, height=${Number.isFinite(e)?e:0}px, top=${n}px, bottom=${o}px, left=${i}px, right=${r}px, gap=${a}px, numbering=${ht(this.numbering)}, font=${ht(this.font)}, fillRatio=${c})`}},tr=Yo;var Ko=class extends O{static def={name:["program","instrument"],description:"\u8BBE\u7F6E\u5F53\u524D\u97F3\u8F68\u7684 MIDI \u97F3\u8272",details:`~~~jpfun
57
60
  @program(40) 1 2 3
58
61
  ~~~
59
- \u5207\u6362\u4E3A\u5C0F\u63D0\u7434\u97F3\u8272\u3002\u8BBE\u7F6E\u5C06\u4F5C\u7528\u4E8E\u5F53\u524D\u97F3\u8F68\u7684\u540E\u7EED\u97F3\u7B26\u3002`,allowExtraArgs:!1,args:[{name:"program",description:"\u4ECE 0 \u5F00\u59CB\u7F16\u53F7\u7684 MIDI \u97F3\u8272\uFF0C\u987B\u4E3A `0..127` \u7684\u6574\u6570",type:"number",default:null}]};program;constructor(t,e,n,o=null){super(t,o);let[i]=this.getArgValue(e,n);if(!Number.isSafeInteger(i)||i<0||i>127)throw new k("E_PROGRAM_INVALID","@program \u5FC5\u987B\u662F 0..127 \u7684\u6574\u6570",t);this.program=i}loweringEnter(){let t=new Q;return t.ast=this,t.playbackState={program:this.program},t.onTimeState=e=>{e.program=this.program},[t]}toString(){return`@program(${this.program})`}},Li=vo;var Ci=.4,Ia=(s,t,e)=>s.top-e*Ci-t.bottom,Ra=(s,t)=>{let e=t*Ci,n=[],o=0;for(let i of s){if(!i){n.push(null);continue}let r=o-i.bottom;n.push({offset:r,extent:i}),o=r+i.top-e}return n},$a={laneKey:"stack",measure:Ra,place:Ia},ko=class s extends P{static def={name:["stack"],description:"\u4E34\u65F6\u591A\u58F0\u90E8",details:"~~~jpfun\n@stack({1 2}, {3/ 4/ 5})\n~~~\n\u63A5\u53D7\u81F3\u5C11\u4E24\u4E2A\u5185\u5BB9\u53C2\u6570\uFF0C\u5404\u5206\u652F\u540C\u65F6\u5F00\u59CB\u3001\u4FDD\u7559\u5404\u81EA\u65F6\u503C\uFF0C\u6574\u4F53\u65F6\u957F\u53D6\u6700\u957F\u5206\u652F\u3002\u9002\u5408\u8282\u594F\u4E0D\u540C\u7684\u4E34\u65F6\u591A\u58F0\u90E8\u3002\n\n**\u7B80\u5199**\uFF1A`{1 2} & {3/ 4/ 5}`\u3002\u53EF\u7EE7\u7EED\u7528 `&` \u8FDE\u63A5\u66F4\u591A\u5206\u652F\uFF1B\u82E5\u8981\u5199\u548C\u5F26\uFF0C\u8BF7\u4F7F\u7528 `up` / `down`\u3002",allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,n){if(t[e]==="&"){let o={kind:"sugar",data:s,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===s))return null;let i=t.nodes.length-1;for(;i>=0&&t.nodes[i]instanceof at;i--);let r=i>=0?t.nodes[i]:null;if(r===null)throw new k("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 a=i;if(r instanceof Lt){let h=r,p=h.target;for(;p&&!t.nodes.includes(p);)p=p.parent;for(let u=i-1;u>=0;u--)if(t.nodes[u]===p){r=new rt({start:p.sourceSpan.start,end:h.sourceSpan.end},t.nodes.slice(u,i+1),null),a=u;break}}let c=r instanceof s?r:new s(o.span,new Map,t).addContent(r),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 at)){for(c.addContent(p),l.length=a,l.push(c);++h<t.nodes.length;)l.push(t.nodes[h]);return t.nodes=l,e.length}}throw new k("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:$a}}constructor(t,e,n,o=null){super(t,o);for(let[,i]of e){if(i instanceof ft){this.addContent(i);continue}let r=n.parseArgWithType(i.valueSpan,"content",t.start);r!==null&&this.addContent(r)}}addContent(t){if(t instanceof s)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(
62
+ \u5207\u6362\u4E3A\u5C0F\u63D0\u7434\u97F3\u8272\u3002\u8BBE\u7F6E\u5C06\u4F5C\u7528\u4E8E\u5F53\u524D\u97F3\u8F68\u7684\u540E\u7EED\u97F3\u7B26\u3002`,allowExtraArgs:!1,args:[{name:"program",description:"\u4ECE 0 \u5F00\u59CB\u7F16\u53F7\u7684 MIDI \u97F3\u8272\uFF0C\u987B\u4E3A `0..127` \u7684\u6574\u6570",type:"number",default:null}]};program;constructor(t,e,n,o=null){super(t,o);let[i]=this.getArgValue(e,n);if(!Number.isSafeInteger(i)||i<0||i>127)throw new k("E_PROGRAM_INVALID","@program \u5FC5\u987B\u662F 0..127 \u7684\u6574\u6570",t);this.program=i}loweringEnter(){let t=new tt;return t.ast=this,t.playbackState={program:this.program},t.onTimeState=e=>{e.program=this.program},[t]}toString(){return`@program(${this.program})`}},er=Ko;var nr=.4,kc=(s,t,e)=>s.top-e*nr-t.bottom,_c=(s,t)=>{let e=t*nr,n=[],o=0;for(let i of s){if(!i){n.push(null);continue}let r=o-i.bottom;n.push({offset:r,extent:i}),o=r+i.top-e}return n},Rc={laneKey:"stack",measure:_c,place:kc},Xo=class s extends O{static def={name:["stack"],description:"\u4E34\u65F6\u591A\u58F0\u90E8",details:"~~~jpfun\n@stack({1 2}, {3/ 4/ 5})\n~~~\n\u63A5\u53D7\u81F3\u5C11\u4E24\u4E2A\u5185\u5BB9\u53C2\u6570\uFF0C\u5404\u5206\u652F\u540C\u65F6\u5F00\u59CB\u3001\u4FDD\u7559\u5404\u81EA\u65F6\u503C\uFF0C\u6574\u4F53\u65F6\u957F\u53D6\u6700\u957F\u5206\u652F\u3002\u9002\u5408\u8282\u594F\u4E0D\u540C\u7684\u4E34\u65F6\u591A\u58F0\u90E8\u3002\n\n**\u7B80\u5199**\uFF1A`{1 2} & {3/ 4/ 5}`\u3002\u53EF\u7EE7\u7EED\u7528 `&` \u8FDE\u63A5\u66F4\u591A\u5206\u652F\uFF1B\u82E5\u8981\u5199\u548C\u5F26\uFF0C\u8BF7\u4F7F\u7528 `up` / `down`\u3002",allowExtraArgs:!0,extraArgType:"content",args:[]};static deSugarAtom(t,e,n){if(t[e]==="&"){let o={kind:"sugar",data:s,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===s))return null;let i=t.nodes.length-1;for(;i>=0&&t.nodes[i]instanceof xt;i--);let r=i>=0?t.nodes[i]:null;if(r===null)throw new k("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 a=i;if(r instanceof Bt){let f=r,p=f.target;for(;p&&!t.nodes.includes(p);)p=p.parent;for(let u=i-1;u>=0;u--)if(t.nodes[u]===p){r=new ut({start:p.sourceSpan.start,end:f.sourceSpan.end},t.nodes.slice(u,i+1),null),a=u;break}}let c=r instanceof s?r:new s(o.span,new Map,t).addContent(r),l=t.nodes;t.nodes=[],t.makeNodes(e,n);for(let f=0;f<t.nodes.length;f++){let p=t.nodes[f];if(!(p instanceof xt)){for(c.addContent(p),l.length=a,l.push(c);++f<t.nodes.length;)l.push(t.nodes[f]);return t.nodes=l,e.length}}throw new k("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:Rc}}constructor(t,e,n,o=null){super(t,o);for(let[,i]of e){if(i instanceof Et){this.addContent(i);continue}let r=n.parseArgWithType(i.valueSpan,"content",t.start);r!==null&&this.addContent(r)}}addContent(t){if(t instanceof s)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(
60
63
  ${this.contents.map(n=>n.toString(t)).join(`,
61
64
  `).split(`
62
65
  `).join(`
63
66
  `)}
64
- )`}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}},Ei=ko;function vi(s){let t=1/0,e=1/0,n=-1/0,o=-1/0,i=(r,a,c,l)=>{t=Math.min(t,r),e=Math.min(e,a),n=Math.max(n,r+c),o=Math.max(o,a+l)};for(let r of s){let a=r.dx??0;if(r.circle){let{cx:c,cy:l,r:h}=r.circle;i(c+a-h,l-h,2*h,2*h)}if(r.path?.length){let c=se(r.path);i(c.x+a,c.y,c.w,c.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 ki(s,t,e,n,o){let i=n.x-e.x*o,r=n.y-e.y*o;for(let a of t){let c=a.style,l=c.strokeWidth===void 0?c:{...c,strokeWidth:c.strokeWidth*o},h=i+(a.dx??0)*o;a.path&&s.drawPath(a.path,l,{x:h,y:r,scaleX:o,scaleY:o}),a.circle&&s.drawCircle(h+a.circle.cx*o,r+a.circle.cy*o,a.circle.r*o,l)}}var Mi={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:s=>s.affectFollowing((t,e)=>{for(let n of e)n.kind==="note-on"&&(n.velocity=Math.min(127,n.velocity+20))})};var Ee="repeat.jump",Ni={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:()=>[Ee],onVisit:(s,t)=>s.visits(t)>1?void 0:{kind:"jump",column:0}};var Mo="repeat.segno",_i={name:"segno",description:"\u53CD\u590D\u8BB0\u53F7\uFF1AD.S. \u7684\u56DE\u8DF3\u76EE\u6807",weight:1.15,playbackMarks:()=>[Mo],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 Ii={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:()=>[Ee],onVisit:(s,t)=>s.visits(t)>1?void 0:{kind:"jump",column:s.seek(Mo,t,-1)??0}};var Oa={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"}]},Pa={mf:8.0028,mp:9.523,ff:6.67866,pp:8.8083},Da={fill:"#000"},Fa=.79341;function Ot(s,t,e){let n=0,o=Array.from(s,(i,r)=>{let a={path:Oa[i],style:Da,dx:n};return n+=Pa[i+s[r+1]]??0,a});return{name:s,description:e,shapes:o,weight:s.includes("f")?1:Fa,onTimeState:i=>{i.velocity=t}}}var Ri=[Ot("ppp",16,"\u6781\u5F31"),Ot("pp",32,"\u5F88\u5F31"),Ot("p",48,"\u5F31"),Ot("mp",64,"\u4E2D\u5F31"),Ot("mf",80,"\u4E2D\u5F3A"),Ot("f",96,"\u5F3A"),Ot("ff",112,"\u5F88\u5F3A"),Ot("fff",127,"\u6781\u5F3A")];var $i={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:s=>{s.control(s.start,t=>t.bpmScale.div(2)),s.control(s.end,t=>t.bpmScale.mul(2))}};var Oi={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:(s,t)=>{let e=s.seek(Ee,t,1);return e!==void 0&&s.visits(e)>0?{kind:"stop"}:void 0}};function pe(s){return(t,e)=>{let n=new Map;for(let r of e)r.kind==="note-off"&&n.set(r.noteId,r);let o=new Set,i=[];for(let r of e){if(r.kind!=="note-on"||!r.transpose)continue;let a=n.get(r.noteId);if(!a)continue;let c=a.at.clone().sub(r.at),l=t.stateAt(r.at).effectiveBpm,h=s.repeat?Ba(s.body,c.toNumber(),l):s.body,p=c.div(h.length);o.add(r),o.add(a);for(let u=0;u<h.length;u++){let m=h[u],f=t.nextNoteId(),y=r.at.clone().add(p.clone().mul(u)),g=r.order+u/h.length,d={...r,at:y,noteId:f,order:g,midi:m===0?r.midi:r.transpose(m),transpose:x=>r.transpose(m+x),origins:[...r.origins],sourceSpans:r.sourceSpans.map(x=>({...x}))};i.push(d,{...a,at:y.clone().add(p),noteId:f,order:g,origins:[...a.origins]})}}return[...e.filter(r=>!o.has(r)),...i]}}function Ba(s,t,e){let n=Math.min(480,Math.max(60,e))/e,o=Math.floor(256/s.length),i=Math.min(o,Math.max(1,Math.round(t*8*n/s.length))),r=[];for(let a=0;a<i;a++)r.push(...s);return r}var Pi={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:s=>s.affectFollowing(pe({body:[0,-1,0]}))};var Di={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:s=>s.affectFollowing(pe({body:[0,1,0]}))};var Fi={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:s=>s.affectFollowing(pe({body:[0,1],repeat:!0}))};var Bi=new Map([Fi,$i,Di,Pi,Mi,...Ri,Ni,Ii,_i,Oi].map(s=>[s.name.toLowerCase(),s])),No=class extends P{static def={name:["symbol","$"],description:"\u521B\u5EFA\u4E00\u4E2A\u4E50\u8C31\u7B26\u53F7",details:`~~~jpfun
67
+ )`}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}},or=Xo;function sr(s){let t=1/0,e=1/0,n=-1/0,o=-1/0,i=(r,a,c,l)=>{t=Math.min(t,r),e=Math.min(e,a),n=Math.max(n,r+c),o=Math.max(o,a+l)};for(let r of s){let a=r.dx??0;if(r.circle){let{cx:c,cy:l,r:f}=r.circle;i(c+a-f,l-f,2*f,2*f)}if(r.path?.length){let c=Ee(r.path);i(c.x+a,c.y,c.w,c.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 ir(s,t,e,n,o){let i=n.x-e.x*o,r=n.y-e.y*o;for(let a of t){let c=a.style,l=c.strokeWidth===void 0?c:{...c,strokeWidth:c.strokeWidth*o},f=i+(a.dx??0)*o;a.path&&s.drawPath(a.path,l,{x:f,y:r,scaleX:o,scaleY:o}),a.circle&&s.drawCircle(f+a.circle.cx*o,r+a.circle.cy*o,a.circle.r*o,l)}}var rr={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:s=>s.affectFollowing((t,e)=>{for(let n of e)n.velocity=Math.min(127,n.velocity+20)})};var Ve="repeat.jump",ar={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:()=>[Ve],onVisit:(s,t)=>s.visits(t)>1?void 0:{kind:"jump",column:0}};var qo="repeat.segno",cr={name:"segno",description:"\u53CD\u590D\u8BB0\u53F7\uFF1AD.S. \u7684\u56DE\u8DF3\u76EE\u6807",weight:1.15,playbackMarks:()=>[qo],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 lr={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:()=>[Ve],onVisit:(s,t)=>s.visits(t)>1?void 0:{kind:"jump",column:s.seek(qo,t,-1)??0}};var Ic={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"}]},$c={mf:8.0028,mp:9.523,ff:6.67866,pp:8.8083},Oc={fill:"#000"},Pc=.79341;function qt(s,t,e){let n=0,o=Array.from(s,(i,r)=>{let a={path:Ic[i],style:Oc,dx:n};return n+=$c[i+s[r+1]]??0,a});return{name:s,description:e,shapes:o,weight:s.includes("f")?1:Pc,onTimeState:i=>{i.velocity=t}}}var fr=[qt("ppp",16,"\u6781\u5F31"),qt("pp",32,"\u5F88\u5F31"),qt("p",48,"\u5F31"),qt("mp",64,"\u4E2D\u5F31"),qt("mf",80,"\u4E2D\u5F3A"),qt("f",96,"\u5F3A"),qt("ff",112,"\u5F88\u5F3A"),qt("fff",127,"\u6781\u5F3A")];var Dc={},pr={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,paddingBottom:3,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:s=>s.scaleFollowingBpm(Dc,1,2,{followConnections:!0})};var ur={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:(s,t)=>{let e=s.seek(Ve,t,1);return e!==void 0&&s.visits(e)>0?{kind:"stop"}:void 0}};function ke(s){return(t,e)=>{let n=[];for(let o of e){if(!o.transpose){n.push(o);continue}let i=o.end.clone().sub(o.start),r=t.stateAt(o.start).effectiveBpm,a=s.repeat?Fc(s.body,i.toNumber(),r):s.body,c=i.div(a.length);for(let l=0;l<a.length;l++){let f=a[l],p=o.start.clone().add(c.clone().mul(l));n.push({...o,start:p,end:p.clone().add(c),midi:f===0?o.midi:o.transpose(f),transpose:u=>o.transpose(f+u)})}}return n}}function Fc(s,t,e){let n=Math.min(480,Math.max(60,e))/e,o=Math.floor(256/s.length),i=Math.min(o,Math.max(1,Math.round(t*8*n/s.length))),r=[];for(let a=0;a<i;a++)r.push(...s);return r}var hr={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:s=>s.affectFollowing(ke({body:[0,-1,0]}))};var dr={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:s=>s.affectFollowing(ke({body:[0,1,0]}))};var mr={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:s=>s.affectFollowing(ke({body:[0,1],repeat:!0}))};var xr=new Map([mr,pr,dr,hr,rr,...fr,ar,lr,cr,ur].map(s=>[s.name.toLowerCase(),s])),Zo=class extends O{static def={name:["symbol","$"],description:"\u521B\u5EFA\u4E00\u4E2A\u4E50\u8C31\u7B26\u53F7",details:`~~~jpfun
65
68
  1 ^ @symbol(p, size=0.5em)
66
69
  ~~~
67
70
  **\u7B80\u5199**\uFF1A\`$name\`\uFF0C\u5982 \`1 ^ $p\`
68
71
 
69
72
  **\u5185\u7F6E\u8BB0\u53F7**
70
- ${[...Bi.values()].map(t=>`- \`$${t.name}\`\uFF1A${t.description}`).join(`
71
- `)}`,allowExtraArgs:!1,args:[{name:"name",description:"\u5185\u7F6E\u8BB0\u53F7\u540D\u79F0\uFF0C\u89C1\u51FD\u6570\u8BF4\u660E\u4E2D\u7684\u8BB0\u53F7\u5217\u8868",type:"string",default:null},{name:"size",description:"\u8BB0\u53F7\u5C3A\u5BF8",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 i=t.slice(e+1,o);return{next:o,node:{kind:"call",typed:!0,name:"symbol",args:new Map([[0,i]]),span:{start:e,end:o},syntaxKind:"atom"}}}size;definition;constructor(t,e,n,o=null){super(t,o);let[i,r]=this.getArgValue(e,n);this.size=n.length2px(r);let a=Bi.get(i.toLowerCase());if(!a){let c=`@symbol: \u672A\u77E5\u7B26\u53F7: $${i}`;if(n.variables.strict)throw new k("E_UNKNOWN_SYMBOL",c,t);n.diagnostics.push(new G("W_UNKNOWN_SYMBOL",c,t));return}this.definition=a}loweringEnter(){return[this.definition?new _o(this):new Q]}toString(t){return this.definition?`@symbol(${this.definition.name})`:super.toString(t)}},zi=No,_o=class extends Q{bounds;height;label;scale=1;baseline=0;constructor(t){super(),this.ast=t,this.mergeKey=Ct,this.onTimeState=t.definition.onTimeState,this.emitPlayback=t.definition.emitPlayback,this.playbackMarks=t.definition.playbackMarks,this.bounds=vi(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):ki(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 Io=class s extends P{static def={name:["set"],description:"\u8BBE\u7F6E\u5C40\u90E8\u9ED8\u8BA4\u503C",details:"~~~jpfun\n@set(fontsize=20, strict=true)\n{ @set(note.octave=5, note.color=#f00) C D E }\n~~~\n\u63A5\u53D7\u547D\u540D\u53C2\u6570\uFF0C\u53EF\u4E00\u6B21\u8BBE\u7F6E\u591A\u9879\uFF1A\n- **\u7CFB\u7EDF\u9009\u9879**\uFF1A\u5982 `fontsize=20` \u5C06\u5B57\u53F7\u8BBE\u4E3A 20px\uFF0C`strict=true` \u5F00\u542F\u4E25\u683C\u6A21\u5F0F\n- **\u51FD\u6570\u9ED8\u8BA4\u53C2\u6570**\uFF1A\u6309 `\u51FD\u6570\u4E3B\u540D.\u53C2\u6570\u540D=\u503C` \u4E66\u5199\uFF0C\u4F8B\u5982 `note.octave=5`\u3001`note.color=#f00`\uFF1B\u663E\u5F0F\u4F20\u53C2\u4F18\u5148\n\n\u8BBE\u7F6E\u4ECE\u5F53\u524D\u4F4D\u7F6E\u8D77\u751F\u6548\uFF0C\u9650\u4E8E\u5F53\u524D\u4F5C\u7528\u57DF\u53CA\u5176\u5B50\u4F5C\u7528\u57DF\uFF1B\u79BB\u5F00\u5185\u5BB9\u5757\u540E\u6062\u590D\u5916\u5C42\u8BBE\u7F6E\u3002\u5B83\u6309\u6E90\u7801\u4F5C\u7528\u57DF\u89E3\u6790\uFF0C\u4E0E\u6F14\u594F\u65F6\u95F4\u65E0\u5173\u3002",allowExtraArgs:!0,args:[]};static resolveTarget(t,e,n){let o=e.lastIndexOf(".");if(o<0)return[e,Object.hasOwn(wt.systemVariables,e)?wt.systemVariables[e].type:"string"];let i=e.slice(o+1),r=t.functions.get(e.slice(0,o))?.prototype.def,a=r&&te(r,i,-1);return!r||!a?(t.diagnostics.push(new G("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):a==="content"||a==="label"?(t.diagnostics.push(new G("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):[`${xe(r)}.${i}`.toLowerCase(),a]}args=new Map;constructor(t,e,n,o=null){super(t,o);for(let[i,r]of e){let a=r;if(typeof i!="string"){n.diagnostics.push(new G("W_SET_POSITIONAL_ARG",`\u51FD\u6570 @set \u4E0D\u63A5\u6536\u4F4D\u7F6E\u53C2\u6570, \u4F4D\u7F6E\u53C2\u6570[${i}]\u5C06\u88AB\u5FFD\u7565`,a.span));continue}let c=s.resolveTarget(n,i.toLowerCase(),a.nameSpan??a.span);if(c===null)continue;let[l,h]=c,p=n.parseArgWithType(a.valueSpan,h,t.start);if(p===null){n.diagnostics.push(new G("W_SET_INVALID_VALUE",`\u51FD\u6570 @set \u7684\u53C2\u6570\u503C\u89E3\u6790\u5931\u8D25, \u53C2\u6570[${i}]\u5C06\u88AB\u5FFD\u7565`,a.valueSpan));continue}n.setVariable(l,p),this.args.set(l,p)}}toString(){return`@set(${Array.from(this.args,([t,e])=>`${t}=${typeof e=="string"?ht(e):e}`).join(", ")})`}},Hi=Io;var Ro=class extends P{static def={name:["volta"],description:"\u53CD\u590D\u7684\u8DF3\u623F\u5B50",details:"~~~jpfun\n|: 1 2 | 3@a 4@b :| 5@c 6@d | 7\n@volta(a, b, 1) @volta(c, d, 2)\n~~~\n- **\u989D\u5916\u4F4D\u7F6E\u53C2\u6570**\uFF1A\u66F4\u591A\u904D\u6570\uFF1B\u4F8B\u5982 `@volta(a, b, 1, 2)` \u8BA9\u524D\u4E24\u904D\u5171\u7528\u4E00\u4E2A\u623F\u5B50\u3002\u904D\u6570\u987A\u5E8F\u4E0D\u9650\uFF0C\u8C31\u9762\u6309\u5347\u5E8F\u663E\u793A\u3002\n\n\u672C\u4F8B\u7B2C\u4E00\u904D\u6F14\u594F `a` \u5230 `b`\uFF0C\u7B2C\u4E8C\u904D\u6F14\u594F `c` \u5230 `d`\u3002",allowExtraArgs:!0,extraArgType:"number",args:[{name:"from",description:"\u533A\u95F4\u9996\u97F3\u7684\u6807\u7B7E\uFF0C\u533A\u95F4\u5141\u8BB8\u8DE8\u8C31\u9762\u884C",type:"label",default:null},{name:"to",description:"\u533A\u95F4\u672B\u97F3\u7684\u6807\u7B7E",type:"label",default:null},{name:"pass",description:"\u8FDB\u5165\u6B64\u533A\u95F4\u7684\u6F14\u594F\u904D\u6570\uFF0C\u987B\u4E3A\u6B63\u6574\u6570",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(D.warning.UnresolvedEndpoint("volta",this.sourceSpan)),[]):(t.addAttachment(new $o(this,e,n)),[])}constructor(t,e,n,o=null){super(t,o);let[i,r,a]=this.getArgValue(e,n);this.font=n.variables.numberfont;let c=new Set([a]);for(let l=3;e.has(l);l++)c.add(e.get(l));if(this.from=i,this.to=r,this.passes=[...c].sort((l,h)=>l-h),this.size=n.variables.fontsize,this.passes.some(l=>!Number.isSafeInteger(l)||l<=0))throw new k("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(", ")})`}},Wi=Ro;function Gi(s){if(s?.[0]?.mergeKey===ot)return s[0]}var $o=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),i=Math.max(e,n);return{range:[o,i],run:r=>this.ast.passes.includes(Rs(r,o))?void 0:{kind:"jump",column:i+1}}}createGeometry(t){if(!U(this.from)||!U(this.to))return{regions:[],paint(){}};let e=_=>{let M=t.lines[_.layoutLine];return{line:_.layoutLine,view:M,column:M.columnOf(_)}},[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 i=n.view.columns[n.column][0],r=o.view.columns[o.column][0],a=Gi(n.view.columns[n.column-1]),c=Gi(o.view.columns[o.column+1]),l=0,h=[];for(let _=n.line;_<=o.line;_++){let M=t.lines[_],S=_===n.line?n.column:0,L=_===o.line?o.column:M.columns.length-1;for(let A=S;A<=L;A++)l=Math.max(l,M.columns[A][0].ast.size);h.push({from:S,to:L,wholeLine:_!==n.line&&_!==o.line})}let p=i.layoutLine,u=r.layoutLine,m=l||this.ast.size,f={fontSize:m*.6,fontFamily:this.ast.font,textAlign:"left",fill:"#000"},y=this.ast.passes.map(_=>`${_}.`).join(""),g=t.textMeasurer.measureText(y,f),d=Math.max(1,m*.055),x=d/2,b=g.h*1.2,w=(b-g.h)/2+g.baseline,N=Array.from({length:u-p+1},(_,M)=>{let S=p+M,L=i.track,A=1/0,C=h[M],I=C.wholeLine?t.getRangeExtents(S):t.getRangeExtents(S,[C.from,C.to]);for(let[V,q]of I){let v=t.getVisualAxis(S,V)+q.top;v<A&&(L=V,A=v)}A===1/0&&(A=t.getVisualAxis(S,L));let O=S!==p?this.lineEntryX(t,S,L):a?.layoutLine===S?a.box.x+a.box.anchor+5:i.box.x+(i.ports["body.left"]?.x??0),H=S!==u?this.lineRightX(t,S):c?.layoutLine===S?c.box.x+c.box.anchor:r.box.x+(r.ports["body.right"]?.x??r.box.w),Y=Math.min(O,H),tt=Math.max(O,H);return{left:Y,right:tt,lineY:A-m*.2-b,line:S,track:L}});return{regions:N.map(({left:_,right:M,lineY:S,line:L,track:A})=>({x:_-x,y:S-x,w:M-_+d,h:b+d,line:L,track:A})),paint(_){let M={stroke:"#000",strokeWidth:d};for(let{left:S,right:L,lineY:A,line:C}of N)_.drawLine(S,A,L,A,M),C===p&&(_.drawLine(S,A,S,A+b,M),_.drawText(y,S+m*.15,A+w+2,f)),C===u&&_.drawLine(L,A,L,A+b,M)}}}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 i of n.values())for(let r of i)o=Math.max(o,r.box.x+r.box.w);return o}};var Vi=4/3,za=.09,Oo=class extends P{static def={name:["tie"],description:"\u8FDE\u97F3\u7EBF",details:`~~~jpfun
73
+ ${[...xr.values()].map(t=>`- \`$${t.name}\`\uFF1A${t.description}`).join(`
74
+ `)}`,allowExtraArgs:!1,args:[{name:"name",description:"\u5185\u7F6E\u8BB0\u53F7\u540D\u79F0\uFF0C\u89C1\u51FD\u6570\u8BF4\u660E\u4E2D\u7684\u8BB0\u53F7\u5217\u8868",type:"string",default:null},{name:"size",description:"\u8BB0\u53F7\u5C3A\u5BF8",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 i=t.slice(e+1,o);return{next:o,node:{kind:"call",typed:!0,name:"symbol",args:new Map([[0,i]]),span:{start:e,end:o},syntaxKind:"atom"}}}size;definition;constructor(t,e,n,o=null){super(t,o);let[i,r]=this.getArgValue(e,n);this.size=n.length2px(r);let a=xr.get(i.toLowerCase());if(!a){let c=`@symbol: \u672A\u77E5\u7B26\u53F7: $${i}`;if(n.variables.strict)throw new k("E_UNKNOWN_SYMBOL",c,t);n.diagnostics.push(new U("W_UNKNOWN_SYMBOL",c,t));return}this.definition=a}loweringEnter(){return[this.definition?new Qo(this):new tt]}toString(t){return this.definition?`@symbol(${this.definition.name})`:super.toString(t)}},yr=Zo,Qo=class extends tt{bounds;height;label;scale=1;baseline=0;constructor(t){super(),this.ast=t,this.mergeKey=zt,this.onTimeState=t.definition.onTimeState,this.emitPlayback=t.definition.emitPlayback,this.playbackMarks=t.definition.playbackMarks,this.bounds=sr(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.ast.definition.paddingBottom??0)*this.scale;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):ir(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 Jo=class s extends O{static def={name:["set"],description:"\u8BBE\u7F6E\u5C40\u90E8\u9ED8\u8BA4\u503C",details:"~~~jpfun\n@set(fontsize=20, strict=true)\n{ @set(note.octave=5, note.color=#f00) C D E }\n~~~\n\u63A5\u53D7\u547D\u540D\u53C2\u6570\uFF0C\u53EF\u4E00\u6B21\u8BBE\u7F6E\u591A\u9879\uFF1A\n- **\u7CFB\u7EDF\u9009\u9879**\uFF1A\u5982 `fontsize=20` \u5C06\u5B57\u53F7\u8BBE\u4E3A 20px\uFF0C`strict=true` \u5F00\u542F\u4E25\u683C\u6A21\u5F0F\n- **\u51FD\u6570\u9ED8\u8BA4\u53C2\u6570**\uFF1A\u6309 `\u51FD\u6570\u4E3B\u540D.\u53C2\u6570\u540D=\u503C` \u4E66\u5199\uFF0C\u4F8B\u5982 `note.octave=5`\u3001`note.color=#f00`\uFF1B\u663E\u5F0F\u4F20\u53C2\u4F18\u5148\n\n\u8BBE\u7F6E\u4ECE\u5F53\u524D\u4F4D\u7F6E\u8D77\u751F\u6548\uFF0C\u9650\u4E8E\u5F53\u524D\u4F5C\u7528\u57DF\u53CA\u5176\u5B50\u4F5C\u7528\u57DF\uFF1B\u79BB\u5F00\u5185\u5BB9\u5757\u540E\u6062\u590D\u5916\u5C42\u8BBE\u7F6E\u3002\u5B83\u6309\u6E90\u7801\u4F5C\u7528\u57DF\u89E3\u6790\uFF0C\u4E0E\u6F14\u594F\u65F6\u95F4\u65E0\u5173\u3002",allowExtraArgs:!0,args:[]};static resolveTarget(t,e,n){let o=e.lastIndexOf(".");if(o<0)return[e,Object.hasOwn(Rt.systemVariables,e)?Rt.systemVariables[e].type:"string"];let i=e.slice(o+1),r=t.functions.get(e.slice(0,o))?.prototype.def,a=r&&ye(r,i,-1);return!r||!a?(t.diagnostics.push(new U("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):a==="content"||a==="label"?(t.diagnostics.push(new U("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):[`${$e(r)}.${i}`.toLowerCase(),a]}args=new Map;constructor(t,e,n,o=null){super(t,o);for(let[i,r]of e){let a=r;if(typeof i!="string"){n.diagnostics.push(new U("W_SET_POSITIONAL_ARG",`\u51FD\u6570 @set \u4E0D\u63A5\u6536\u4F4D\u7F6E\u53C2\u6570, \u4F4D\u7F6E\u53C2\u6570[${i}]\u5C06\u88AB\u5FFD\u7565`,a.span));continue}let c=s.resolveTarget(n,i.toLowerCase(),a.nameSpan??a.span);if(c===null)continue;let[l,f]=c,p=n.parseArgWithType(a.valueSpan,f,t.start);if(p===null){n.diagnostics.push(new U("W_SET_INVALID_VALUE",`\u51FD\u6570 @set \u7684\u53C2\u6570\u503C\u89E3\u6790\u5931\u8D25, \u53C2\u6570[${i}]\u5C06\u88AB\u5FFD\u7565`,a.valueSpan));continue}n.setVariable(l,p),this.args.set(l,p)}}toString(){return`@set(${Array.from(this.args,([t,e])=>{let n=typeof e=="string"?ht(e):e&&typeof e=="object"&&"unit"in e?`${e.value}${e.unit}`:e;return`${t}=${n}`}).join(", ")})`}},gr=Jo;var ts=class extends O{static def={name:["volta"],description:"\u53CD\u590D\u7684\u8DF3\u623F\u5B50",details:"~~~jpfun\n|: 1 2 | 3@a 4@b :| 5@c 6@d | 7\n@volta(a, b, 1) @volta(c, d, 2)\n~~~\n- **\u989D\u5916\u4F4D\u7F6E\u53C2\u6570**\uFF1A\u66F4\u591A\u904D\u6570\uFF1B\u4F8B\u5982 `@volta(a, b, 1, 2)` \u8BA9\u524D\u4E24\u904D\u5171\u7528\u4E00\u4E2A\u623F\u5B50\u3002\u904D\u6570\u987A\u5E8F\u4E0D\u9650\uFF0C\u8C31\u9762\u6309\u5347\u5E8F\u663E\u793A\u3002\n\n\u672C\u4F8B\u7B2C\u4E00\u904D\u6F14\u594F `a` \u5230 `b`\uFF0C\u7B2C\u4E8C\u904D\u6F14\u594F `c` \u5230 `d`\u3002",allowExtraArgs:!0,extraArgType:"number",args:[{name:"from",description:"\u533A\u95F4\u8D77\u70B9\u7684\u6807\u7B7E\uFF0C\u533A\u95F4\u5141\u8BB8\u8DE8\u8C31\u9762\u884C",type:"label",default:null},{name:"to",description:"\u533A\u95F4\u7EC8\u70B9\u7684\u6807\u7B7E",type:"label",default:null},{name:"pass",description:"\u8FDB\u5165\u6B64\u533A\u95F4\u7684\u6F14\u594F\u904D\u6570\uFF0C\u987B\u4E3A\u6B63\u6574\u6570",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(D.warning.UnresolvedEndpoint("volta",this.sourceSpan)),[]):(t.addAttachment(new es(this,e,n)),[])}constructor(t,e,n,o=null){super(t,o);let[i,r,a]=this.getArgValue(e,n);this.font=n.variables.numberfont;let c=new Set([a]);for(let l=3;e.has(l);l++)c.add(e.get(l));if(this.from=i,this.to=r,this.passes=[...c].sort((l,f)=>l-f),this.size=n.variables.fontsize,this.passes.some(l=>!Number.isSafeInteger(l)||l<=0))throw new k("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(", ")})`}},wr=ts;function br(s){if(s?.[0]?.mergeKey===ct)return s[0]}var es=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}get endPoints(){return[this.from,this.to]}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),i=Math.max(e,n);return{range:[o,i],run:r=>this.ast.passes.includes(ri(r,o))?void 0:{kind:"jump",column:i+1}}}createGeometry(t){if(!Q(this.from)||!Q(this.to))return{regions:[],paint(){}};let e=A=>{let L=t.lines[A.layoutLine];return{line:A.layoutLine,view:L,column:L.columnOf(A)}},[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 i=n.view.columns[n.column][0],r=o.view.columns[o.column][0],a=br(n.view.columns[n.column-1]),c=br(o.view.columns[o.column+1]),l=0;for(let A=n.line;A<=o.line;A++)for(let L of t.getRangeColumns(A,[i,r]))l=Math.max(l,L[0].ast.size);let f=i.layoutLine,p=r.layoutLine,u=l||this.ast.size,d={fontSize:u*.6,fontFamily:this.ast.font,textAlign:"left",fill:"#000"},h=this.ast.passes.map(A=>`${A}.`).join(""),x=t.textMeasurer.measureText(h,d),g=Math.max(1,u*.055),m=g/2,y=x.h*1.2,w=(y-x.h)/2+x.baseline,E=Array.from({length:p-f+1},(A,L)=>{let M=f+L,T=i.track,S=1/0,b=M!==f&&M!==p?t.getRangeExtents(M):t.getRangeExtents(M,[i,r]);for(let[H,B]of b){let G=t.getVisualAxis(M,H)+B.top;G<S&&(T=H,S=G)}S===1/0&&(S=t.getVisualAxis(M,T));let v=M!==f?this.lineEntryX(t,M,T):a?.layoutLine===M?a.box.x+a.box.anchor+5:i.box.x+(i.ports["body.left"]?.x??0),_=M!==p?this.lineRightX(t,M):c?.layoutLine===M?c.box.x+c.box.anchor:r.box.x+(r.ports["body.right"]?.x??r.box.w),I=Math.min(v,_),K=Math.max(v,_);return{left:I,right:K,lineY:S-u*.2-y,line:M,track:T}});return{regions:E.map(({left:A,right:L,lineY:M,line:T,track:S})=>({x:A-m,y:M-m,w:L-A+g,h:y+g,line:T,track:S})),paint(A){let L={stroke:"#000",strokeWidth:g};for(let{left:M,right:T,lineY:S,line:b}of E)A.drawLine(M,S,T,S,L),b===f&&(A.drawLine(M,S,M,S+y,L),A.drawText(h,M+u*.15,S+w+2,d)),b===p&&A.drawLine(T,S,T,S+y,L)}}}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 i of n.values())for(let r of i)o=Math.max(o,r.box.x+r.box.w);return o}};var Sr=4/3,Bc=.09,ns=class extends O{static def={name:["tie"],description:"\u8FDE\u97F3\u7EBF",details:`~~~jpfun
72
75
  1@a 2 3@b @tie(a, b, height=0.5em)
73
76
  ~~~
74
- - **\u4F4D\u7F6E\u53C2\u6570**\uFF1A\u7AEF\u70B9\u6807\u7B7E\uFF0C\u53EF\u4F20\u591A\u4E2A\uFF0C\u6309\u987A\u5E8F\u8FDE\u63A5\uFF1B\u7701\u7565\u65F6\u67E5\u627E\u6700\u8FD1\u7684\u53EF\u8FDE\u63A5\u5BF9\u8C61
77
+ - **\u4F4D\u7F6E\u53C2\u6570**\uFF1A\u7AEF\u70B9\u6807\u7B7E\uFF0C\u53EF\u4F20\u591A\u4E2A\uFF0C\u6309\u987A\u5E8F\u8FDE\u63A5\uFF1B\u7701\u7565\u65F6\u67E5\u627E\u6700\u8FD1\u7684\u53EF\u6807\u8BB0\u5BF9\u8C61\uFF0C\u5305\u62EC\u589E\u65F6\u7EBF
75
78
  - **height**\uFF1A\u5F27\u7EBF\u9AD8\u5EA6\uFF0C\u9ED8\u8BA4 \`0.5em\`
76
79
 
77
- \u540C\u884C\u7AEF\u70B9\u7528\u4E00\u6761\u5F27\u7EBF\u8FDE\u63A5\uFF0C\u8DE8\u884C\u65F6\u81EA\u52A8\u62C6\u6210\u591A\u6BB5`,allowExtraArgs:!0,extraArgType:"label",args:[]};endPoints=[];height;constructor(t,e,n,o=null){super(t,o);let i=n.variables.fontsize*.5;for(let[a,c]of e){if(a==="height"){let h=n.parseArgWithType(c.valueSpan,"length",t.start);h&&(i=Math.max(0,n.length2px(h)));continue}let l=c instanceof P?c:n.parseArgWithType(c.valueSpan,"label",t.start);l!==null&&this.endPoints.push(l)}let r=n.labelableNodes.length-1;for(;this.endPoints.length<2&&r>=0;){let a=n.labelableNodes[r--];!a||this.endPoints.includes(a)||this.endPoints.unshift(a)}if(this.endPoints.length<2)throw new k("E_NOT_ENOUGH_ARGS","@tie \u8FDE\u97F3\u7EBF\u9700\u8981\u81F3\u5C11\u4E24\u4E2A\u7AEF\u70B9",t);this.height=i}loweringEnter(t){let e=[];for(let n of this.endPoints){let o=t.getTemporalNodes(n).at(-1);!o||!U(o)||e.push(o)}return e.length<2?(t.diagnostics.push(D.warning.UnresolvedEndpoint("tie",this.sourceSpan)),[]):(t.addAttachment(new Po(e,this.height,this.sourceSpan)),[])}toString(t){return`@tie(${this.endPoints.map(e=>`${e.label??"anon"}:[${e.toString(t)}]`).join(", ")})`}},ji=Oo,Po=class{layer="foreground";sourceSpan;endPoints;height;thickness;constructor(t,e,n){this.endPoints=t,this.height=e,this.sourceSpan=n;let o=t.reduce((i,r)=>Math.max(i,r.ast.size),0);this.thickness=Math.max(1.2,o*za)}applyPlayback(t){let e=()=>t.events.filter(o=>o.kind==="note-on"),n=o=>t.events.find(i=>i.kind==="note-off"&&i.noteId===o);for(let o of e().filter(i=>i.origins.some(r=>r.node===this.endPoints[0])))for(let i=1;i<this.endPoints.length;i++){let r=n(o.noteId);if(!r)break;let a=e().find(l=>l.noteId!==o.noteId&&l.origins.some(h=>h.node===this.endPoints[i])&&l.track===o.track&&l.midi===o.midi&&l.percussion===o.percussion&&r.at.equals(l.at));if(!a)break;let c=n(a.noteId);if(!c)break;o.sourceSpans.push(...a.sourceSpans);for(let l of a.origins)o.origins.includes(l)||o.origins.push(l);c.noteId=o.noteId,c.origins=[...o.origins],t.events.splice(0,t.events.length,...t.events.filter(l=>l!==r&&l!==a))}}createGeometry(t){let e=this.createSegments(t),n=e.map(({commands:i,...r})=>r),o=e.map(i=>{let r=t.getHostExtent(i.line,i.track),a=r?Math.max(i.y,t.getVisualAxis(i.line,i.track)+r.top):i.y+i.h;return{x:i.x,y:i.y,w:i.w,h:a-i.y,line:i.line,track:i.track}});return{regions:n,occupancy:o,paint(i){for(let r of e)i.drawPath(r.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],i=this.endPoints[n];o.layoutLine>i.layoutLine&&([o,i]=[i,o]);let r=this.tiePort(o),a=this.tiePort(i);if(o.layoutLine===i.layoutLine){let c=t.getVisualAxis(o.layoutLine,o.track)+(t.getHostExtent(o.layoutLine,o.track)?.top??0),l=t.getVisualAxis(i.layoutLine,i.track)+(t.getHostExtent(i.layoutLine,i.track)?.top??0);e.push(this.arcSegment(r,a,o.layoutLine,c<=l?o.track:i.track));continue}e.push(this.openingSegment(r,this.lineRightX(t,o.layoutLine),this.plateauY(t,o.layoutLine,o.track,r.y),o.layoutLine,o.track));for(let c=o.layoutLine+1;c<i.layoutLine;c++)e.push(this.horizontalSegment(this.lineEntryX(t,c,o.track),this.lineRightX(t,c),this.plateauY(t,c,o.track),c,o.track));e.push(this.closingSegment(this.lineEntryX(t,i.layoutLine,i.track),a,this.plateauY(t,i.layoutLine,i.track,a.y),i.layoutLine,i.track))}return e}lineEntryX(t,e,n){return t.lines[e].trackRuns.get(n)?.find(r=>!r.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 i of n.values())for(let r of i)o=Math.max(o,r.box.x+r.box.w);return o}plateauY(t,e,n,o=1/0){if(Number.isFinite(o))return o-this.height;let i=t.getVisualAxis(e,n),r=t.getHostExtent(e,n)?.top??0;return i+r-this.height}arcSegment(t,e,n,o){let i=t,r=e;i.x>r.x&&([i,r]=[r,i]);let a=(r.x-i.x)*.25,c=i.x+a,l=r.x-a,h=this.height*Vi,p=Math.max(0,h-this.thickness*Vi),u=[{op:"M",x:i.x,y:i.y},{op:"C",cx1:c,cy1:i.y-h,cx2:l,cy2:r.y-h,x:r.x,y:r.y},{op:"C",cx1:l,cy1:r.y-p,cx2:c,cy2:i.y-p,x:i.x,y:i.y},{op:"Z"}];return pn(u,n,o)}openingSegment(t,e,n,o,i){let r=this.height*1.2;e=Math.max(e,t.x+r);let a=t.x+r,c=t.x+r*.45,l=n+this.thickness;return pn([{op:"M",x:t.x,y:t.y},{op:"Q",cx:c,cy:n,x:a,y:n},{op:"L",x:e,y:n},{op:"L",x:e,y:l},{op:"L",x:a,y:l},{op:"Q",cx:c,cy:l,x:t.x,y:t.y},{op:"Z"}],o,i)}closingSegment(t,e,n,o,i){let r=this.height*1.2;t=Math.min(t,e.x-r);let a=e.x-r,c=e.x-r*.45,l=n+this.thickness;return pn([{op:"M",x:t,y:n},{op:"L",x:a,y:n},{op:"Q",cx:c,cy:n,x:e.x,y:e.y},{op:"Q",cx:c,cy:l,x:a,y:l},{op:"L",x:t,y:l},{op:"Z"}],o,i)}horizontalSegment(t,e,n,o,i){return pn([{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,i)}};function pn(s,t,e){return{commands:s,line:t,track:e,...se(s)}}var Do=class extends P{static def={name:["tuplet"],description:"\u591A\u8FDE\u97F3",details:`~~~jpfun
80
+ \u540C\u884C\u7AEF\u70B9\u7528\u4E00\u6761\u5F27\u7EBF\u8FDE\u63A5\uFF0C\u8DE8\u884C\u65F6\u81EA\u52A8\u62C6\u6210\u591A\u6BB5\u3002\u540C\u8F68\u540C\u97F3\u4E14\u65F6\u95F4\u8FDE\u7EED\u7684\u97F3\u6BB5\u5EFA\u7ACB\u64AD\u653E\u8FDE\u63A5\uFF0C\u5404\u6BB5\u4FDD\u7559\u81EA\u5DF1\u7684\u88C5\u9970\uFF0C\u4F8B\u5982 \`1 ^ $tr 1 @tie()\` \u7684\u540E\u4E00\u97F3\u6BB5\u4E0D\u7EE7\u627F\u98A4\u97F3\u3002\u6D89\u53CA\u589E\u65F6\u7EBF\u7684\u8FDE\u63A5\u4EC5\u7ED8\u5236\uFF0C\u4E0D\u5408\u5E76\u64AD\u653E\u97F3\u7B26\u3002`,allowExtraArgs:!0,extraArgType:"label",args:[]};endPoints=[];height;constructor(t,e,n,o=null){super(t,o);let i=n.variables.fontsize*.5;for(let[a,c]of e){if(a==="height"){let f=n.parseArgWithType(c.valueSpan,"length",t.start);f&&(i=Math.max(0,n.length2px(f)));continue}let l=c instanceof O?c:n.parseArgWithType(c.valueSpan,"label",t.start);l!==null&&this.endPoints.push(l)}let r=n.labelableNodes.length-1;for(;this.endPoints.length<2&&r>=0;){let a=n.labelableNodes[r--];!a||this.endPoints.includes(a)||this.endPoints.unshift(a)}if(this.endPoints.length<2)throw new k("E_NOT_ENOUGH_ARGS","@tie \u8FDE\u97F3\u7EBF\u9700\u8981\u81F3\u5C11\u4E24\u4E2A\u7AEF\u70B9",t);this.height=i}loweringEnter(t){let e=[];for(let n of this.endPoints){let o=t.getTemporalNodes(n).at(-1);!o||!Q(o)||e.push(o)}return e.length<2?(t.diagnostics.push(D.warning.UnresolvedEndpoint("tie",this.sourceSpan)),[]):(t.addAttachment(new os(e,this.height,this.sourceSpan)),[])}toString(t){let e=this.endPoints.map(n=>n.label);return e.some(n=>n===void 0)?t.slice(this.sourceSpan.start,this.sourceSpan.end):`@tie(${e.join(", ")}, height=${this.height}px)`}},Ar=ns,os=class{layer="foreground";sourceSpan;endPoints;height;thickness;constructor(t,e,n){this.endPoints=t,this.height=e,this.sourceSpan=n;let o=t.reduce((i,r)=>Math.max(i,r.ast.size),0);this.thickness=Math.max(1.2,o*Bc)}applyPlayback(t){for(let e of t.notes.filter(n=>n.origins.some(o=>o.node===this.endPoints[0]))){let n=e;for(let o=1;o<this.endPoints.length;o++){let i=t.notes.find(r=>r!==n&&r.origins.some(a=>a.node===this.endPoints[o])&&r.track===n.track&&r.midi===n.midi&&r.percussion===n.percussion&&n.end.equals(r.start)&&t.connect(n,r));if(!i)break;n=i}}}createGeometry(t){let e=this.createSegments(t),n=e.map(({commands:i,...r})=>r),o=e.map(i=>{let r=t.getHostExtent(i.line,i.track),a=r?Math.max(i.y,t.getVisualAxis(i.line,i.track)+r.top):i.y+i.h;return{x:i.x,y:i.y,w:i.w,h:a-i.y,line:i.line,track:i.track}});return{regions:n,occupancy:o,paint(i){for(let r of e)i.drawPath(r.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],i=this.endPoints[n];o.layoutLine>i.layoutLine&&([o,i]=[i,o]);let r=this.tiePort(o),a=this.tiePort(i);if(o.layoutLine===i.layoutLine){let c=t.getVisualAxis(o.layoutLine,o.track)+(t.getHostExtent(o.layoutLine,o.track)?.top??0),l=t.getVisualAxis(i.layoutLine,i.track)+(t.getHostExtent(i.layoutLine,i.track)?.top??0);e.push(this.arcSegment(r,a,o.layoutLine,c<=l?o.track:i.track));continue}e.push(this.openingSegment(r,this.lineRightX(t,o.layoutLine),this.plateauY(t,o.layoutLine,o.track,r.y),o.layoutLine,o.track));for(let c=o.layoutLine+1;c<i.layoutLine;c++)e.push(this.horizontalSegment(this.lineEntryX(t,c,o.track),this.lineRightX(t,c),this.plateauY(t,c,o.track),c,o.track));e.push(this.closingSegment(this.lineEntryX(t,i.layoutLine,i.track),a,this.plateauY(t,i.layoutLine,i.track,a.y),i.layoutLine,i.track))}return e}lineEntryX(t,e,n){return t.lines[e].trackRuns.get(n)?.find(r=>!r.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 i of n.values())for(let r of i)o=Math.max(o,r.box.x+r.box.w);return o}plateauY(t,e,n,o=1/0){if(Number.isFinite(o))return o-this.height;let i=t.getVisualAxis(e,n),r=t.getHostExtent(e,n)?.top??0;return i+r-this.height}arcSegment(t,e,n,o){let i=t,r=e;i.x>r.x&&([i,r]=[r,i]);let a=(r.x-i.x)*.25,c=i.x+a,l=r.x-a,f=this.height*Sr,p=Math.max(0,f-this.thickness*Sr),u=[{op:"M",x:i.x,y:i.y},{op:"C",cx1:c,cy1:i.y-f,cx2:l,cy2:r.y-f,x:r.x,y:r.y},{op:"C",cx1:l,cy1:r.y-p,cx2:c,cy2:i.y-p,x:i.x,y:i.y},{op:"Z"}];return _n(u,n,o)}openingSegment(t,e,n,o,i){let r=this.height*1.2;e=Math.max(e,t.x+r);let a=t.x+r,c=t.x+r*.45,l=n+this.thickness;return _n([{op:"M",x:t.x,y:t.y},{op:"Q",cx:c,cy:n,x:a,y:n},{op:"L",x:e,y:n},{op:"L",x:e,y:l},{op:"L",x:a,y:l},{op:"Q",cx:c,cy:l,x:t.x,y:t.y},{op:"Z"}],o,i)}closingSegment(t,e,n,o,i){let r=this.height*1.2;t=Math.min(t,e.x-r);let a=e.x-r,c=e.x-r*.45,l=n+this.thickness;return _n([{op:"M",x:t,y:n},{op:"L",x:a,y:n},{op:"Q",cx:c,cy:n,x:e.x,y:e.y},{op:"Q",cx:c,cy:l,x:a,y:l},{op:"L",x:t,y:l},{op:"Z"}],o,i)}horizontalSegment(t,e,n,o,i){return _n([{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,i)}};function _n(s,t,e){return{commands:s,line:t,track:e,...Ee(s)}}var ss=class extends O{static def={name:["tuplet"],description:"\u591A\u8FDE\u97F3",details:`~~~jpfun
78
81
  @tuplet({1/ 2 3}, normal=4)
79
82
  ~~~
80
- \u672C\u4F8B\u6700\u77ED\u5355\u4F4D\u4E3A\u516B\u5206\u97F3\u7B26\uFF0C\u539F\u5185\u5BB9\u5360 5 \u4E2A\u5355\u4F4D\uFF0C\u7F29\u653E\u540E\u5360 4 \u4E2A\u5355\u4F4D\uFF1A\u5F62\u6210\u4E94\u8FDE\u97F3\uFF0C\u603B\u65F6\u957F\u4E3A\u4E00\u4E2A\u4E8C\u5206\u97F3\u7B26`,allowExtraArgs:!1,args:[{type:"content",description:"\u8FDE\u97F3\u5185\u5BB9\uFF0C\u5404\u5143\u7D20\u6309\u540C\u4E00\u6BD4\u4F8B\u7F29\u653E\u65F6\u503C",default:null},{name:"normal",description:"\u76EE\u6807\u603B\u65F6\u957F\uFF0C\u4EE5\u5185\u5BB9\u4E2D\u7684\u6700\u77ED\u65F6\u503C\u4E3A\u5355\u4F4D",type:"number",default:null}]};static loweringFinalize=t=>{for(let e of t.attachments)e instanceof un&&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),i=o.events.filter(f=>f.T.compare(0)>0);if(i.length===0)throw new k("E_TUPLET_EMPTY","@tuplet \u7684\u5185\u5BB9\u5FC5\u987B\u4EA7\u751F\u81F3\u5C11\u4E00\u4E2A\u6B63\u65F6\u503C\u4E8B\u4EF6",this.sourceSpan);let r=i[0].track;if(i.some(f=>f.track!==r))throw new k("E_TUPLET_PARALLEL_CONTENT","@tuplet \u7684\u5185\u5BB9\u4E0D\u80FD\u5305\u542B\u5E76\u884C\u97F3\u8F68",this.sourceSpan);let a=i[0].T.clone(),c=new z;for(let f of i)f.T.compare(a)<0&&a.copyFrom(f.T),c.add(f.T);let l=c.clone().div(a),h=l.numerator;if(l.denominator!==1||h<2||!Number.isSafeInteger(h))throw new k("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 k("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 f=1;f<o.events.length;f++)o.events[f].t.compare(p)<0&&(p=o.events[f].t);p=p.clone();let u=new z;for(let f of o.events)u.copyFrom(f.t).sub(p).mul(this.normal,h),f.t.copyFrom(p).add(u),f.T.mul(this.normal,h);n.copyFrom(p).add(a.mul(this.normal));let m=i.filter(U);return m.length>=2&&t.addAttachment(new un(m,h,this.sourceSpan,this.font)),[]}constructor(t,e,n,o=null){super(t,o);let[i,r]=this.getArgValue(e,n);if(this.font=n.variables.numberfont,!Number.isSafeInteger(r)||r<=0)throw new k("E_TUPLET_INVALID_NORMAL","@tuplet \u7684 normal \u5FC5\u987B\u662F\u6B63\u7684\u5B89\u5168\u6574\u6570",t);this.content=i,this.normal=r,i.parent=this}toString(t){return`@tuplet(${this.content.toString(t)}, ${this.normal})`}},Ui=Do,un=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((i,r)=>Math.max(i,r.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 k("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,i=n.ports["body.right"]?.x??n.box.w,r=e.box.x+o,a=n.box.x+i;r>a&&([r,a]=[a,r]);let c=t.textMeasurer.measureText(String(this.actual),this.style),l=(r+a)/2,h=this.size*.12,p=this.size*.18,u=this.size*.14,m=t.lines[e.layoutLine],f=m?.columnOf(e)??-1,y=m?.columnOf(n)??-1,g=t.getVisualAxis(e.layoutLine,e.track),d=f<0||y<0?void 0:t.getRangeExtents(e.layoutLine,[Math.min(f,y),Math.max(f,y)]).get(e.track),x=g+(d?.top??0),b=Math.max(1,this.size*.055),w=x-u-Math.max(p,c.h/2),N=w+p,_=w-c.h/2+c.baseline,M=l-c.w/2-h,S=l+c.w/2+h,L=[];M>r&&L.push([r,w,M,w]),S<a&&L.push([S,w,a,w]),L.push([r,w,r,N],[a,w,a,N]);let A=b/2,C=Math.min(w-c.h/2,w-A),I=Math.max(w+c.h/2,N+A),O=[{x:r-A,y:C,w:a-r+b,h:I-C,line:e.layoutLine,track:e.track}],H=String(this.actual),Y=this.style;return{regions:O,paint(tt){let V={stroke:"#000",strokeWidth:b};for(let[q,v,T,B]of L)tt.drawLine(q,v,T,B,V);tt.drawText(H,l,_,Y)}}}};var Ha=/\s/,Ki=new Set("\uFF08([\uFF3B\uFF5B\u3008\u300A\u300C\u300E\u3010\u3014\u3016\u3018\u301A\u2018\u201C"),Fo=new Set([...Ki,...`\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 Yi(s){let t=0,e=s.length;for(;t<e&&Fo.has(s[t]);)t++;for(;e>t&&Fo.has(s[e-1]);)e--;return{prefix:s.slice(0,t),body:s.slice(t,e)}}function Ga(s){let t=s/2;return(e,n)=>{let o=e.map(c=>c&&c.bottom-c.top>1e-6?c:{top:-t,bottom:t}),i=[],r=0;for(let c=0;c<o.length;c++)c>0&&(r+=o[c-1].bottom+n-o[c].top),i.push(r);let a=(i[0]+i[i.length-1])/2;return i.map((c,l)=>({offset:c-a,extent:o[l]}))}}var ve=class s extends P{static def={name:["voice","v"],description:"\u58F0\u90E8",details:`~~~jpfun
83
+ \u672C\u4F8B\u6700\u77ED\u5355\u4F4D\u4E3A\u516B\u5206\u97F3\u7B26\uFF0C\u539F\u5185\u5BB9\u5360 5 \u4E2A\u5355\u4F4D\uFF0C\u7F29\u653E\u540E\u5360 4 \u4E2A\u5355\u4F4D\uFF1A\u5F62\u6210\u4E94\u8FDE\u97F3\uFF0C\u603B\u65F6\u957F\u4E3A\u4E00\u4E2A\u4E8C\u5206\u97F3\u7B26`,allowExtraArgs:!1,args:[{type:"content",description:"\u8FDE\u97F3\u5185\u5BB9\uFF0C\u5404\u5143\u7D20\u6309\u540C\u4E00\u6BD4\u4F8B\u7F29\u653E\u65F6\u503C",default:null},{name:"normal",description:"\u76EE\u6807\u603B\u65F6\u957F\uFF0C\u4EE5\u5185\u5BB9\u4E2D\u7684\u6700\u77ED\u65F6\u503C\u4E3A\u5355\u4F4D",type:"number",default:null}]};static loweringFinalize=t=>{for(let e of t.attachments)e instanceof Rn&&e.validate()};content;normal;font;get children(){return[this.content]}timeFlowModel(){return{mode:"sequence",children:[this.content]}}loweringEnter(t){let e={nodes:[],attachments:[],onTemporal(n){e.nodes.push(n)},onAttachment(n){e.attachments.push(n)}};return t.beginLoweringGroup(this,e),[]}loweringExit(t,e,n){let o=t.endLoweringGroup(this),i=o.nodes.filter(h=>h.T.compare(0)>0);if(i.length===0)throw new k("E_TUPLET_EMPTY","@tuplet \u7684\u5185\u5BB9\u5FC5\u987B\u4EA7\u751F\u81F3\u5C11\u4E00\u4E2A\u6B63\u65F6\u503C\u4E8B\u4EF6",this.sourceSpan);let r=i[0].track;if(i.some(h=>h.track!==r))throw new k("E_TUPLET_PARALLEL_CONTENT","@tuplet \u7684\u5185\u5BB9\u4E0D\u80FD\u5305\u542B\u5E76\u884C\u97F3\u8F68",this.sourceSpan);let a=i[0].T.clone(),c=new F;for(let h of i)h.T.compare(a)<0&&a.copyFrom(h.T),c.add(h.T);let l=c.clone().div(a),f=l.numerator;if(l.denominator!==1||f<2||!Number.isSafeInteger(f))throw new k("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===f)throw new k("E_TUPLET_INVALID_RATIO",`@tuplet \u7684 normal \u4E0D\u80FD\u7B49\u4E8E\u63A8\u5BFC\u51FA\u7684 actual (${f})`,this.sourceSpan);let p=o.nodes[0].t;for(let h=1;h<o.nodes.length;h++)o.nodes[h].t.compare(p)<0&&(p=o.nodes[h].t);p=p.clone();let u=new F;for(let h of o.nodes)u.copyFrom(h.t).sub(p).mul(this.normal,f),h.t.copyFrom(p).add(u),h.T.mul(this.normal,f);n.copyFrom(p).add(a.mul(this.normal));let d=i.filter(Q);return d.length>=2&&t.addAttachment(new Rn(d,f,this.sourceSpan,this.font,o)),[]}constructor(t,e,n,o=null){super(t,o);let[i,r]=this.getArgValue(e,n);if(this.font=n.variables.numberfont,!Number.isSafeInteger(r)||r<=0)throw new k("E_TUPLET_INVALID_NORMAL","@tuplet \u7684 normal \u5FC5\u987B\u662F\u6B63\u7684\u5B89\u5168\u6574\u6570",t);this.content=i,this.normal=r,i.parent=this}toString(t){return`@tuplet(${this.content.toString(t)}, ${this.normal})`}},Er=ss,Rn=class{content;layer="foreground";endPoints;actual;sourceSpan;style;size;constructor(t,e,n,o,i){this.content=i,this.endPoints=t,this.actual=e,this.sourceSpan=n,this.size=t.reduce((r,a)=>Math.max(r,a.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 k("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,i=n.ports["body.right"]?.x??n.box.w,r=e.box.x+o,a=n.box.x+i;r>a&&([r,a]=[a,r]);let c=t.textMeasurer.measureText(String(this.actual),this.style),l=(r+a)/2,f=this.size*.12,p=this.size*.18,u=this.size*.14,d=t.getVisualAxis(e.layoutLine,e.track),h=t.getRangeExtents(e.layoutLine,[e,n],e.track),x=t.getContentBounds(this.content),g=Math.min(d+(h?.top??0),x?.y??1/0),m=Math.max(1,this.size*.055),y=g-u-Math.max(p,c.h/2),w=y+p,E=y-c.h/2+c.baseline,A=l-c.w/2-f,L=l+c.w/2+f,M=[];A>r&&M.push([r,y,A,y]),L<a&&M.push([L,y,a,y]),M.push([r,y,r,w],[a,y,a,w]);let T=m/2,S=Math.min(y-c.h/2,y-T),b=Math.max(y+c.h/2,w+T),v=[{x:r-T,y:S,w:a-r+m,h:b-S,line:e.layoutLine,track:e.track}],_=String(this.actual),I=this.style;return{regions:v,paint(K){let H={stroke:"#000",strokeWidth:m};for(let[B,G,J,N]of M)K.drawLine(B,G,J,N,H);K.drawText(_,l,E,I)}}}};var zc=/\s/,Lr=new Set("\uFF08([\uFF3B\uFF5B\u3008\u300A\u300C\u300E\u3010\u3014\u3016\u3018\u301A\u2018\u201C"),is=new Set([...Lr,...`\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 Tr(s){let t=0,e=s.length;for(;t<e&&is.has(s[t]);)t++;for(;e>t&&is.has(s[e-1]);)e--;return{prefix:s.slice(0,t),body:s.slice(t,e)}}function Hc(s){let t=s/2;return(e,n)=>{let o=e.map(c=>c&&c.bottom-c.top>1e-6?c:{top:-t,bottom:t}),i=[],r=0;for(let c=0;c<o.length;c++)c>0&&(r+=o[c-1].bottom+n-o[c].top),i.push(r);let a=(i[0]+i[i.length-1])/2;return i.map((c,l)=>({offset:c-a,extent:o[l]}))}}var je=class s extends O{static def={name:["voice","v"],description:"\u58F0\u90E8",details:`~~~jpfun
81
84
  @voice({1 2 3}, \u94A2\u7434, \u7537=ha ha ha, \u5973=la la la)
82
85
  ~~~
83
86
  - **\u989D\u5916\u53C2\u6570**\uFF1A\u6BCF\u9879\u4E3A\u4E00\u884C\u6B4C\u8BCD\uFF1B\u547D\u540D\u53C2\u6570\u540C\u65F6\u7ED9\u51FA\u6B4C\u8BCD\u884C\u540D\uFF0C\u4F4D\u7F6E\u53C2\u6570\u8868\u793A\u65E0\u884C\u540D\u3002\u7701\u7565\u58F0\u90E8\u540D\u4F46\u4ECD\u9700\u6B4C\u8BCD\u65F6\uFF0C\u4FDD\u7559\u7A7A\u4F4D\uFF0C\u5982 \`@voice({1 2 3}, , ha ha ha)\`\u3002
@@ -90,14 +93,14 @@ N(\u94A2\u7434): 1 2 3
90
93
  L(\u7537): ha ha ha
91
94
  L: la la la
92
95
  ~~~
93
- \u884C\u9996\u5141\u8BB8\u7A7A\u767D\uFF0C\u6362\u884C\u7ED3\u675F\u5F53\u524D\u58F0\u660E\uFF1B\u5728\u884C\u672B\u52A0 \`\\\` \u53EF\u7EED\u884C\u3002\u8FD9\u79CD\u5199\u6CD5\u4E2D\u7684\u6B4C\u8BCD\u5141\u8BB8\u76F4\u63A5\u4F7F\u7528\u9017\u53F7\u3002`,allowExtraArgs:!0,extraArgType:"string",args:[{type:"content",description:"\u58F0\u90E8\u7684\u97F3\u7B26\u5185\u5BB9",default:null},{name:"name",description:"\u663E\u793A\u5728\u5DE6\u4FA7\u7684\u58F0\u90E8\u540D\u79F0\uFF0C\u7A7A\u503C\u9690\u85CF\u540D\u79F0",type:"string",default:""}]};static deSugarAtom(t,e,n){if(t[e]!=="N"&&t[e]!=="L")return null;let o=e+1,i="";if(t[o]==="("){let r=ni(t,o+1,n);if(r<0)return null;i=Gt(t.slice(o+1,r).trim()),o=r+1}if(t[o++]!==":")return null;if(t[e]==="N")return{next:o,node:{kind:"sugar",data:{class:s,name:i},span:{start:e,end:o}}};{if(o=It(t,o,n),o>=n)return null;let r;if(t[o]==='"'){let c=le(t,o,n);if(c<0)return null;r=Gt(t.slice(o,c+1)),o=c+1}else{let c=o;for(;o<n&&t[o]!==`
94
- `;)o++;r=t.slice(c,o).trim()}return{next:o,node:{kind:"sugar",data:{class:s,lyric:r,name:i},span:{start:e,end:o}}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==s)return null;if(o.data?.lyric!==void 0){let y=null,g=t.nodes.length-1;for(;g>=0;g--){let d=t.nodes[g];if(d instanceof at){if(!t.variables.strict)continue;throw new k("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",d.sourceSpan)}d instanceof s?y=d:d instanceof Yt&&(y=d.voices.at(-1)??null);break}if(y===null)throw new k("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 y.addLyric(o.data.name,o.data.lyric,o.span,t),t.nodes.length=g+1,n<e.length&&typeof e[n]=="number"&&t.source[e[n]]===`
95
- `&&n++,n}let i=n,r=0;for(;i<e.length;i++){let y=e[i];if(typeof y=="number"){if(t.source[y]===`
96
- `){r=1;break}}else if(y.kind==="sugar"&&y.data?.class===s)break}let a=new wt(t),c=e.slice(n,i);if(i+=r,a.makeNodes(c),a.nodes.length===0)throw D.error.EmptyContent("voice","content",o.span);let l={start:o.span.start,end:a.nodes.at(-1).sourceSpan.end},h=new Map;a.nodes.length===1&&a.nodes[0]instanceof rt?h.set(0,a.nodes[0]):h.set(0,new rt({...l},a.nodes)),h.set("name",o.data.name);let p=new s(l,h,t,null),u=null,m=t.nodes.length-1,f=null;t:for(;m>=0;m--){let y=t.nodes[m];if(y instanceof at){if(t.variables.strict)break;for(let g=y.sourceSpan.start;g<y.sourceSpan.end;g++)if(t.source[g]===`
97
- `)break t;f=y;continue}if(y instanceof Yt){if(!y.createdBySugar)break;u=y}else if(y instanceof s){let g=new Map;g.set(0,y),u=new Yt({start:y.sourceSpan.start,end:y.sourceSpan.end},g,t,null),u.createdBySugar=!0}break}return u?(t.nodes[m]=u,u.addVoice(p),f&&(t.nodes.length=m+1,t.diagnostics.push(new G("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",f.sourceSpan)))):t.pushNode(p),i}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 Yt&&e.voices.length>1?e.braceSpace:0,o=new fn(this,n),i=[];return t.beginLoweringGroup(this,{attachment:new Ho(i,o),onTemporal(r){i.push(r)}}),[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[i,r]of e){if(typeof r=="string"){this.addLyric(i,r);continue}let a=r,c=n.parseArgWithType(a.valueSpan,"string",t.start);c===null?n.diagnostics.push(new G("W_VOICE_INVALID_LYRIC",`@voice \u7684\u6B4C\u8BCD\u53C2\u6570\u503C\u89E3\u6790\u5931\u8D25, \u53C2\u6570[${i}]\u5C06\u88AB\u5FFD\u7565`,a.valueSpan)):this.addLyric(i,c)}}addLyric(t,e,n=null,o=null){typeof t=="number"&&(t="");let i=s.parseLyric(e);if(i.length===0&&o&&n&&o.diagnostics.push(new G("W_EMPTY_LYRIC",`@voice\u7684\u6B4C\u8BCD${t}\u662F\u7A7A\u7684`,n)),this.lyrics.push({name:t,tokens:i}),n)for(let r=this;r;r=r.parent)r.sourceSpan.start=Math.min(n.start,r.sourceSpan.start),r.sourceSpan.end=Math.max(n.end,r.sourceSpan.end)}static parseLyric(t){let e=[],n="",o="",i=a=>{e.push(o+a),o=""},r=()=>{n&&i(n),n=""};for(let a=0;a<t.length;a++){let c=t[a];if(c==="\\"&&a+1<t.length&&/[\\{}@-]/.test(t[a+1]))n+=t[++a];else if(c==="{"){let l=a+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?(r(),i(h),a=l):n+=c}else Ha.test(c)?r():c==="-"?(n+=c,n.length>1&&r()):c==="@"?(n&&(n+=c,r()),e.push("")):Ki.has(c)?(r(),o+=c):Fo.has(c)?n?n+=c:o||!e.at(-1)?o+=c:e[e.length-1]+=c:c.charCodeAt(0)>127?(r(),i(c)):n+=c}return r(),o&&(e.at(-1)?e[e.length-1]+=o:e.push(o)),e}toString(t){let e=[`${this.content.toString(t)},${ht(this.name)}`];for(let n of this.lyrics){let o=ht(n.tokens.map(i=>i.length===0?"@":`{${i.replace(/[\\{}@-]/g,"\\$&")}}`).join(" "));e.push(n.name?`${n.name}=${o}`:o)}return`@voice(
96
+ \u884C\u9996\u5141\u8BB8\u7A7A\u767D\uFF0C\u6362\u884C\u7ED3\u675F\u5F53\u524D\u58F0\u660E\uFF1B\u5728\u884C\u672B\u52A0 \`\\\` \u53EF\u7EED\u884C\u3002\u8FD9\u79CD\u5199\u6CD5\u4E2D\u7684\u6B4C\u8BCD\u5141\u8BB8\u76F4\u63A5\u4F7F\u7528\u9017\u53F7\u3002`,allowExtraArgs:!0,extraArgType:"string",args:[{type:"content",description:"\u58F0\u90E8\u7684\u97F3\u7B26\u5185\u5BB9",default:null},{name:"name",description:"\u663E\u793A\u5728\u5DE6\u4FA7\u7684\u58F0\u90E8\u540D\u79F0\uFF0C\u7A7A\u503C\u9690\u85CF\u540D\u79F0",type:"string",default:""}]};static deSugarAtom(t,e,n){if(t[e]!=="N"&&t[e]!=="L")return null;let o=e+1,i="";if(t[o]==="("){let r=Mi(t,o+1,n);if(r<0)return null;i=oe(t.slice(o+1,r).trim()),o=r+1}if(t[o++]!==":")return null;if(t[e]==="N")return{next:o,node:{kind:"sugar",data:{class:s,name:i},span:{start:e,end:o}}};{if(o=Ut(t,o,n),o>=n)return null;let r;if(t[o]==='"'){let c=Yt(t,o,n);if(c<0)return null;r=oe(t.slice(o,c+1)),o=c+1}else{let c=o;for(;o<n&&t[o]!==`
97
+ `;)o++;r=t.slice(c,o).trim()}return{next:o,node:{kind:"sugar",data:{class:s,lyric:r,name:i},span:{start:e,end:o}}}}}static deSugarRelation(t,e,n){let o=e[n++];if(o.data?.class!==s)return null;if(o.data?.lyric!==void 0){let x=null,g=t.nodes.length-1;for(;g>=0;g--){let m=t.nodes[g];if(m instanceof xt){if(!t.variables.strict)continue;throw new k("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",m.sourceSpan)}m instanceof s?x=m:m instanceof fe&&(x=m.voices.at(-1)??null);break}if(x===null)throw new k("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 x.addLyric(o.data.name,o.data.lyric,o.span,t),t.nodes.length=g+1,n<e.length&&typeof e[n]=="number"&&t.source[e[n]]===`
98
+ `&&n++,n}let i=n,r=0;for(;i<e.length;i++){let x=e[i];if(typeof x=="number"){if(t.source[x]===`
99
+ `){r=1;break}}else if(x.kind==="sugar"&&x.data?.class===s)break}let a=new Rt(t),c=e.slice(n,i);if(i+=r,a.makeNodes(c),a.nodes.length===0)throw D.error.EmptyContent("voice","content",o.span);let l={start:o.span.start,end:a.nodes.at(-1).sourceSpan.end},f=new Map;a.nodes.length===1&&a.nodes[0]instanceof ut?f.set(0,a.nodes[0]):f.set(0,new ut({...l},a.nodes)),f.set("name",o.data.name);let p=new s(l,f,t,null),u=null,d=t.nodes.length-1,h=null;t:for(;d>=0;d--){let x=t.nodes[d];if(x instanceof xt){if(t.variables.strict)break;for(let g=x.sourceSpan.start;g<x.sourceSpan.end;g++)if(t.source[g]===`
100
+ `)break t;h=x;continue}if(x instanceof fe){if(!x.createdBySugar)break;u=x}else if(x instanceof s){let g=new Map;g.set(0,x),u=new fe({start:x.sourceSpan.start,end:x.sourceSpan.end},g,t,null),u.createdBySugar=!0}break}return u?(t.nodes[d]=u,u.addVoice(p),h&&(t.nodes.length=d+1,t.diagnostics.push(new U("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",h.sourceSpan)))):t.pushNode(p),i}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 fe&&e.voices.length>1?e.braceSpace:0,o=new In(this,n),i=[];return t.beginLoweringGroup(this,{attachment:new cs(i,o),onTemporal(r){i.push(r)}}),[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[i,r]of e){if(typeof r=="string"){this.addLyric(i,r);continue}let a=r,c=n.parseArgWithType(a.valueSpan,"string",t.start);c===null?n.diagnostics.push(new U("W_VOICE_INVALID_LYRIC",`@voice \u7684\u6B4C\u8BCD\u53C2\u6570\u503C\u89E3\u6790\u5931\u8D25, \u53C2\u6570[${i}]\u5C06\u88AB\u5FFD\u7565`,a.valueSpan)):this.addLyric(i,c)}}addLyric(t,e,n=null,o=null){typeof t=="number"&&(t="");let i=s.parseLyric(e);if(i.length===0&&o&&n&&o.diagnostics.push(new U("W_EMPTY_LYRIC",`@voice\u7684\u6B4C\u8BCD${t}\u662F\u7A7A\u7684`,n)),this.lyrics.push({name:t,tokens:i}),n)for(let r=this;r;r=r.parent)r.sourceSpan.start=Math.min(n.start,r.sourceSpan.start),r.sourceSpan.end=Math.max(n.end,r.sourceSpan.end)}static parseLyric(t){let e=[],n="",o="",i=a=>{e.push(o+a),o=""},r=()=>{n&&i(n),n=""};for(let a=0;a<t.length;a++){let c=String.fromCodePoint(t.codePointAt(a));if(a+=c.length-1,c==="\\"&&a+1<t.length&&/[\\{}@-]/.test(t[a+1]))n+=t[++a];else if(c==="{"){let l=a+1,f="";for(;l<t.length&&t[l]!=="}";l++)t[l]==="\\"&&l+1<t.length&&/[\\{}@-]/.test(t[l+1])?f+=t[++l]:f+=t[l];l<t.length?(r(),i(f),a=l):n+=c}else zc.test(c)?r():c==="-"?(n+=c,n.length>1&&r()):c==="@"?(n&&(n+=c,r()),e.push("")):Lr.has(c)?(r(),o+=c):is.has(c)?n?n+=c:o||!e.at(-1)?o+=c:e[e.length-1]+=c:c.charCodeAt(0)>127?(r(),i(c)):n+=c}return r(),o&&(e.at(-1)?e[e.length-1]+=o:e.push(o)),e}toString(t){let e=[`${this.content.toString(t)},${ht(this.name)}`];for(let n of this.lyrics){let o=ht(n.tokens.map(i=>i.length===0?"@":`{${i.replace(/[\\{}@-]/g,"\\$&")}}`).join(" "));e.push(n.name?`${n.name}=${o}`:o)}return`@voice(
98
101
  ${e.join(`,
99
102
  `)}
100
- )`}},Yt=class extends P{static def={name:["voices","vs"],description:"\u591A\u4E2A\u58F0\u90E8",details:`~~~jpfun
103
+ )`}},fe=class extends O{static def={name:["voices","vs"],description:"\u591A\u4E2A\u58F0\u90E8",details:`~~~jpfun
101
104
  @voices(
102
105
  @voice({1 2 3}, \u94A2\u7434, \u7537=ha ha ha),
103
106
  @voice({3 4 5}, , "la la la")
@@ -113,20 +116,20 @@ N(\u94A2\u7434): 1 2 3
113
116
  L(\u7537): ha ha ha
114
117
  N: 3 4 5
115
118
  L: la la la
116
- ~~~`,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 zo(e,this),onTemporal(n){n instanceof fn&&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=Ga(n.variables.fontsize);for(let[,i]of e){if(i instanceof ft){if(i instanceof ve)this.addVoice(i);else throw new k("E_VOICES_INVALID_CHILD",`@voices \u7684\u53C2\u6570\u5FC5\u987B\u662F @voice \u51FD\u6570\uFF0C\u4F46\u53D1\u73B0\u4E86\u5176\u4ED6\u7C7B\u578B ${i.constructor.name}`,i instanceof ft?i.sourceSpan:t);continue}let r=i,a=n.parseArgWithType(r.valueSpan,"content",t.start);if(a instanceof ve)this.addVoice(a);else throw new k("E_VOICES_INVALID_CHILD",`@voices \u7684\u53C2\u6570\u5FC5\u987B\u662F @voice \u51FD\u6570\uFF0C\u4F46\u53D1\u73B0\u4E86\u5176\u4ED6\u7C7B\u578B ${a?.constructor.name}`,r.valueSpan)}if(this.voices.length===0)throw new k("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(
119
+ ~~~`,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 as(e,this),onTemporal:n=>{n instanceof In&&n.ast.parent===this&&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=Hc(n.variables.fontsize);for(let[,i]of e){if(i instanceof Et){if(i instanceof je)this.addVoice(i);else throw new k("E_VOICES_INVALID_CHILD",`@voices \u7684\u53C2\u6570\u5FC5\u987B\u662F @voice \u51FD\u6570\uFF0C\u4F46\u53D1\u73B0\u4E86\u5176\u4ED6\u7C7B\u578B ${i.constructor.name}`,i instanceof Et?i.sourceSpan:t);continue}let r=i,a=n.parseArgWithType(r.valueSpan,"content",t.start);if(a instanceof je)this.addVoice(a);else throw new k("E_VOICES_INVALID_CHILD",`@voices \u7684\u53C2\u6570\u5FC5\u987B\u662F @voice \u51FD\u6570\uFF0C\u4F46\u53D1\u73B0\u4E86\u5176\u4ED6\u7C7B\u578B ${a?.constructor.name}`,r.valueSpan)}if(this.voices.length===0)throw new k("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(
117
120
  ${e.join(`,
118
121
  `)}
119
- )`}},Xi=ve,Zi=Yt,Bo=.82,Wa=.6;function qi(s,t){return{fontFamily:t,fontSize:s*Bo,fill:"#000",fontWeight:600}}var fn=class extends Q{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 i of this.ast.lyrics){if(!i.name)continue;let r=t.textMeasurer.measureText(i.name,qi(this.ast.size,this.ast.font));n=Math.max(n,r.w)}let o=this.braceSpace>0?this.braceSpace:n>0?this.ast.size*Wa: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)}},jt=2.33,Ut=1.17,Vt=.34,Va=[{op:"M",x:0,y:0},{op:"L",x:0,y:-Vt},{op:"C",cx1:jt*.421,cy1:-Vt+Ut*.077,cx2:jt*.733,cy2:-Vt+Ut*.346,x:jt,y:-Vt+Ut},{op:"L",x:jt*.929,y:-Vt+Ut},{op:"C",cx1:jt*.696,cy1:-Vt+Ut*.535,cx2:jt*.328,cy2:-Vt+Ut*.352,x:0,y:0},{op:"Z"}],zo=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,i=e.y+e.visualAxis+n*.5;if(i-o<1e-6)return{regions:[],paint(){}};let r=Math.max(2.5,n*.19),a=r*jt,c=r*Ut,l=t.x+t.anchor+this.ast.braceSpace*.3+r/2,h=[{x:l-r/2,y:o,w:r,h:i-o},{x:l+r*1.33-r*.165,y:o+r*.67,w:r*.33,h:i-o-r*1.34}],p=[{x:l,y:o,scale:r,dir:-1},{x:l,y:i,scale:r,dir:1}];return{regions:[{x:l-r/2,y:o-c,w:a+r/2,h:i-o+c*2}],paint(m){for(let f of h)m.drawRect(f.x,f.y,f.w,f.h,{fill:"#000"});for(let f of p)m.drawPath(Va,{fill:"#000"},{x:f.x,y:f.y,scaleX:f.scale,scaleY:f.scale*f.dir})}}}},Ho=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(U).filter(a=>a.ports?.lyric),{lyrics:o,size:i}=this.nameHost.ast;if(n.length===0||o.length===0)return;let r={fontSize:i*Bo,fontFamily:this.nameHost.ast.font,fill:"#000"};for(let a=0;a<n.length;a++){let c=n[a],l=0;for(let h of o){let p=h.tokens[a];if(p){let{body:u}=Yi(p);u&&(l=Math.max(l,e.textMeasurer.measureText(u,r).w/2))}}l!==0&&t[c.layoutLine]?.registerHorizontalLayoutHook(c,c,({columns:h,start:p})=>{let u=h[p].find(f=>f.time===c);if(!u)return;let m=c.ports.lyric.x-c.box.anchor;u.WL=Math.max(u.WL,l-m),u.WR=Math.max(u.WR,l+m)})}}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=[],i=this.temporalMembers.filter(U).filter(x=>x.ports?.lyric);if(i.length===0||e.length===0)return o;let r=new Map;for(let x of i){let b=r.get(x.layoutLine);b||r.set(x.layoutLine,b=new Map);let w=x.box.y+x.box.h;b.set(x.track,Math.max(b.get(x.track)??w,w))}let a=n*Bo,c=n*.24,l=n*.32,h={fontSize:a,fontFamily:this.nameHost.ast.font,fill:"#000"},p=qi(n,this.nameHost.ast.font),u=t.textMeasurer.measureText("M",h).baseline+l,m=(x,b)=>x+u+b*(a+c),{box:f,layoutLine:y,track:g}=this.nameHost,d=r.get(y)?.get(g);for(let x=0;x<e.length;x++){let b=e[x];for(let N=0;N<b.tokens.length&&N<i.length;N++){let _=b.tokens[N],M=i[N],S=r.get(M.layoutLine)?.get(M.track);if(!_||S===void 0)continue;let L=t.textMeasurer.measureText(_,h),{prefix:A,body:C}=Yi(_),I=C?t.textMeasurer.measureText(C,h).w:0,O=A?t.textMeasurer.measureText(A,h).w:0;o.push({text:_,style:h,textBaselineY:L.baseline,x:M.box.x+M.ports.lyric.x-I/2-O,y:m(S,x)-L.baseline,w:L.w,h:L.h,line:M.layoutLine,track:M.track})}if(!b.name||!f||d===void 0)continue;let w=t.textMeasurer.measureText(b.name,p);o.push({text:b.name,style:p,textBaselineY:w.baseline,x:f.x+f.anchor-w.w,y:m(d,x)-w.baseline,w:w.w,h:w.h,line:y,track:g})}return o}};var dn=[wi,Vs,Is,ie,Ks,Ui,Xi,Zi,bi,Ti,gi,Ei,Si,Ai,_s,Js,ji,Gs,Xs,Ws,Wi,Ss,Hi,nn,sn,rn,Li,an,zi];function Go(s,t={}){let e=new Map,n=new Set(s);for(let o of n){let i=o.layoutDecorationHandler;if(!i)continue;let r=o.def?.name;if(!r)continue;let a=Array.isArray(r)?r[0]:r;e.set(Bt(a),i)}return{textMeasurer:t.textMeasurer??to,decorationHandlers:e}}var ke=class s{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 s(this));return n}};var Me=class s{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 ke,n=new z,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 c of t){let l=0;for(let h of c)h.breakBefore>l&&(l=h.breakBefore);e+=l,c.layoutLine=e}let n={bpm:$t,velocity:ee,keySignature:ye,program:ze},o=new Map,i=new Map,r=c=>o.get(c)??(c.parent?r(c.parent):ee),a=c=>i.get(c)??(c.parent?a(c.parent):ze);for(let c of t)for(let l of c)n.velocity=r(l.track),n.program=a(l.track),l.onTimeState?.(n),o.set(l.track,n.velocity),i.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 i=t.timeFlowModel(this);if(i)switch(i.mode){case"sequence":for(let r of i.children)for(let a of this.trackedEvents(r,e,n))o.push(a);break;case"parallel":{let r=i.tracks,a=i.children,c=r.hostIndex===void 0?0:r.hostIndex,l=n.group(r,c===null?a.length:a.length-1),h=[];for(let m=0;m<a.length;m++){let f=a[m],y=m===c?n:l.members[c===null||m<c?m:m-1],g=e.clone(),d=this.trackedEvents(f,g,y);d.length===0&&this.diagnostics.push(D.warning.ZeroTimeTrack(f.sourceSpan,m+1)),h.push(d)}let p=o.length;for(let m of s.anchorAlign(h))o.push(m);let u=new z;for(let m=p;m<o.length;m++)for(let f of o[m])u.copyFrom(f.t).add(f.T),u.compare(e)>0&&e.copyFrom(u)}break}return this.appendEvents(t.loweringExit(this,n,e),t,e,n,o),o}appendEvents(t,e,n,o,i){let r;for(let a of t){this.initEvent(a,e,n,o),this.indexTemporal(a);for(let l=this.activeLoweringGroups.length-1;l>=0;l--)this.activeLoweringGroups[l].group.onTemporal?.(a);let c=(r??=new z).copyFrom(a.t).add(a.T);c.compare(n)>0&&n.copyFrom(c),i.push(new Vo(a))}}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,u=h.length,m=0,f=0,y=new z,g=new z,d=l[0],x=h[0],b=d.t.clone(),w=x.t.clone();for(;;){if(d.mergeKey===ot){if(x.mergeKey!==ot){for(n.push(x),x=h[++f];f<u&&x.mergeKey!==ot;)g.isZero()||x.shiftTime(g),n.push(x),x=h[++f];x&&(x.shiftTime(g),w.copyFrom(x.t))}if(f<u){let N=b.compare(w)>=0?b:w;y.add(N).sub(b),g.add(N).sub(w),d.push(...x),d.t=N,x=h[++f]}if(n.push(d),d=l[++m],d&&(d.shiftTime(y),b.copyFrom(d.t)),x&&(x.shiftTime(g),w.copyFrom(x.t)),!d||!x)break}if(x.mergeKey===ot){if(d.mergeKey!==ot){for(n.push(d),d=l[++m];m<p&&d.mergeKey!==ot;)y.isZero()||d.shiftTime(y),n.push(d),d=l[++m];d&&(d.shiftTime(y),b.copyFrom(d.t))}if(m<p){let N=b.compare(w)>=0?b:w;y.add(N).sub(b),g.add(N).sub(w),x.push(...d),x.t=N,d=l[++m]}if(n.push(x),x=h[++f],d&&(d.shiftTime(y),b.copyFrom(d.t)),x&&(x.shiftTime(g),w.copyFrom(x.t)),!d||!x)break}if(b.equals(w)){if(d.mergeKey===x.mergeKey){if(d.push(...x),n.push(d),d=l[++m],x=h[++f],d&&(d.shiftTime(y),b.copyFrom(d.t)),x&&(x.shiftTime(g),w.copyFrom(x.t)),!d||!x)break}else if(d.mergeKey<x.mergeKey)if(n.push(d),d=l[++m],d)d.shiftTime(y),b.copyFrom(d.t);else break;else if(n.push(x),x=h[++f],x)x.shiftTime(g),w.copyFrom(x.t);else break;continue}if(b.compare(w)<0)if(n.push(d),d=l[++m],d){d.shiftTime(y),b.copyFrom(d.t);continue}else break;if(w.compare(b)<0)if(n.push(x),x=h[++f],x){x.shiftTime(g),w.copyFrom(x.t);continue}else break}for(d&&n.push(d);++m<p;)d=l[m],y.isZero()||d.shiftTime(y),n.push(d);for(x&&n.push(x);++f<u;)x=h[f],g.isZero()||x.shiftTime(g),n.push(x);return n}let o=new Uint16Array(e),i=Array.from({length:e},()=>new z),r=[],a=new jo(e);for(let l=0;l<e;l++)a.push({e:t[l][0],i:l});let c=l=>{let h=t[l][++o[l]];h&&(i[l].isZero()||h.shiftTime(i[l]),a.push({e:h,i:l}))};for(;;){let l=a.pop();if(l===void 0){if(r.length===0)break;let p=r[0],u=p.e,m=u.t;for(let f=1;f<r.length;f++)r[f].e.t.compare(m)>0&&(m=r[f].e.t);i[p.i].add(m).sub(u.t),c(p.i);for(let f=1;f<r.length;f++){let y=r[f];u.push(...y.e),i[y.i].add(m).sub(y.e.t),c(y.i)}r.length=0,u.t=m,u.sort((f,y)=>f.order-y.order),n.push(u);continue}if(l.e.mergeKey===ot){r.push(l);continue}let h=[l.i];for(;;){let p=a.front();if(!p||!p.e.t.equals(l.e.t)||p.e.mergeKey!==l.e.mergeKey)break;a.pop(),l.e.push(...p.e),h.push(p.i)}n.push(l.e);for(let p of h)c(p)}return n}},Vo=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 Wo(s,t){let e=s.e.t.compare(t.e.t);return e!==0?e:s.e.mergeKey!==t.e.mergeKey?s.e.mergeKey<t.e.mergeKey?-1:1:s.i-t.i}var jo=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(Wo(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 i=n;if(o<this.validLen&&Wo(this[o],this[n])<0&&(i=o),Wo(this[i],e)>=0)break;this[t]=this[i],t=i}this[t]=e}};var Uo=10,Yo=13,ja=9,Ua=11,Ya=12,Ka=32,Xa=160,Za=5760,qa=8239,Qa=8287,Ja=12288,tc=65279,ec=34,Qi=92,nc=37,oc=32,sc=[];function ic(s){return s>oc?" ".repeat(s):sc[s]??=" ".repeat(s)}function Ji(s){return s===Ka||s===ja||s===Ua||s===Ya?!0:s<128?!1:s===Xa||s===Za||s>=8192&&s<=8202||s===qa||s===Qa||s===Ja||s===tc}function mn(s){let t=s.length,e=[0],n=[],o=[],i=(d,x)=>{if(d>=x)return;let b=o.length;if(b>=2&&d<=o[b-1]){x>o[b-1]&&(o[b-1]=x);return}o.push(d,x)},r=(d,x)=>{if(x<=0)return;let b=d+x;for(let w=d;w<b;w+=2)i(w,w+1)},a=0,c=!1,l=!1,h=-1,p=-1,u=-1,m=0,f=(d,x)=>{if(x===Qi){m>0&&p+1===d?m++:(u=d,m=1),p=d;return}u=-1,m=0,p=d};for(let d=0;d<t;){let x=s.charCodeAt(d);if(x===Yo||x===Uo){let b=x===Yo&&d+1<t&&s.charCodeAt(d+1)===Uo?2:1;e.push(d+b);let w=(m&1)===1;r(u,m),h>=0&&(i(h,d),n.push({start:h,end:d}),h=-1),w&&i(d,d+b),p=-1,u=-1,m=0,l=!1,d+=b;continue}if(a!==0){l?l=!1:x===Qi?l=!0:x===a&&(a=0),Ji(x)||f(d,x),d++;continue}if(x===ec){c||(le(s,d,t)<0?c=!0:a=x),f(d,x),d++;continue}if(x===nc){for(h=d,d++;d<t;){let b=s.charCodeAt(d);if(b===Yo||b===Uo)break;d++}continue}Ji(x)||f(d,x),d++}if(r(u,m),h>=0&&(i(h,t),n.push({start:h,end:t})),o.length===0)return{maskedSource:s,lineStarts:e,commentSpans:n};let y=[],g=0;for(let d=0;d<o.length;d+=2){let x=o[d],b=o[d+1];g<x&&y.push(s.slice(g,x)),y.push(ic(b-x)),g=b}return g<t&&y.push(s.slice(g)),{maskedSource:y.join(""),lineStarts:e,commentSpans:n}}function Ko(s,t={}){let{functions:e=dn,textMeasurer:n,variables:o,...i}=t,{maskedSource:r,lineStarts:a}=mn(s),c=new wt({source:r,variables:o});c.registerFunctions(e);let l=new rt({start:0,end:s.length},c.parse()),h=new Me(c.diagnostics);h.registerFunctions(e);let p=h.lowerDocument(l),u=Go(e,{textMeasurer:n}),m=$n(p,u,i);return{lineStarts:a,maskedSource:r,diagnostics:c.diagnostics,ast:l,lowering:p,layout:m}}function rc(s,t=dn){let{maskedSource:e,commentSpans:n}=mn(s),o=new wt({source:e,commentSpans:n});return o.registerFunctions(t),{syntax:o.parseSyntax(),diagnostics:o.diagnostics}}function Xo(s){return typeof s.applyPlayback=="function"}function xn(s,t){let e=Math.max(0,t),n=0,o=0,i=$t;for(let r of s){if(r.kind!=="tempo")continue;let a=r.at.toNumber();if(a>e)break;a>o&&(n+=(a-o)*60/i),o=a,i=r.bpm}return n+(e-o)*60/i}function tr(s,t){let e=Math.max(0,t),n=0,o=$t;for(let i of s){if(i.kind!=="tempo")continue;let r=i.at.toNumber(),a=(r-n)*60/o;if(e<a)return n+e*o/60;e-=a,n=r,o=i.bpm}return n+e*o/60}function er(s,t){let e=Math.max(0,t),n=e;for(let o of s){let i=o.performance.toNumber();if(i>e)break;n=o.score.toNumber()+e-i}return n}function nr(s,t){let e=Math.max(0,t),n;for(let o=0;o<s.length;o++){let i=s[o],r=i.score.toNumber();if(r>e){(!n||r<n.score.toNumber())&&(n=i);continue}let a=s[o+1],c=a?a.performance.toNumber()-i.performance.toNumber():1/0;if(!(e-r>=c))return i.performance.toNumber()+(e-r)}return n?.performance.toNumber()??e}function ac(s,t){let e=Math.min(tr(s.events,t),s.performanceDuration.toNumber());return er(s.scoreMap,e)}function cc(s,t){let e=Math.min(nr(s.scoreMap,t),s.performanceDuration.toNumber());return xn(s.events,e)}var or={tempo:0,"time-signature":1,"program-change":2,"note-off":3,"note-on":4};function Zo(s,t){return s.at.compare(t.at)||or[s.kind]-or[t.kind]||s.order-t.order}function sr(s,t){let e=new Map,n=new Map;for(let a of s)if(a.kind==="note-on"){if(e.has(a.noteId))throw new Error(`Duplicate NoteOn ${a.noteId}`);e.set(a.noteId,a)}else if(a.kind==="note-off"){if(n.has(a.noteId))throw new Error(`Duplicate NoteOff ${a.noteId}`);n.set(a.noteId,a)}for(let[a,c]of e){let l=n.get(a);if(!l)throw new Error(`Note ${a} has no NoteOff`);if(l.at.compare(c.at)<=0)throw new Error(`Note ${a} has a non-positive duration`);if(c.origins.length===0||l.origins.length===0)throw new Error(`Note ${a} has no origin`)}for(let a of n.keys())if(!e.has(a))throw new Error(`NoteOff ${a} has no NoteOn`);let o=new Set;for(let a of e.values())o.add(a.track);let i=new Map;for(let a of t)o.has(a)&&i.set(a,i.size);for(let a of o)i.has(a)||i.set(a,i.size);let r=[];for(let a of s){if(a.kind==="tempo"){r.push({kind:"tempo",at:a.at,bpm:a.bpm});continue}if(a.kind==="time-signature"){r.push({kind:"time-signature",at:a.at,numerator:a.numerator,denominator:a.denominator});continue}if(a.kind==="program-change"){let h=i.get(a.track);h!==void 0&&r.push({kind:"program-change",at:a.at,track:h,program:a.program});continue}let c=a.kind==="note-on"?a:e.get(a.noteId),l=i.get(c.track);if(a.kind==="note-on"){r.push({kind:"note-on",at:a.at,noteId:a.noteId,track:l,midi:a.midi,velocity:a.velocity,...a.percussion?{percussion:!0}:{},sourceSpans:a.sourceSpans});continue}r.push({kind:"note-off",at:a.at,noteId:a.noteId,track:l,midi:c.midi})}return{events:r,tracks:[...i.keys()]}}function lc(s,t,e){let n=s.columns,o=new Map;for(let g=0;g<n.length;g++)for(let d of n[g])o.set(d,g);let i=g=>{for(let d=g;d;d=d.foldedInto){let x=o.get(d);if(x!==void 0)return x}},r=new Map,a=new Map,c=(g,d)=>{let x=g.playbackFlow?.(i);if(!x)return;let[b,w]=x.range??[0,n.length-1];if(x.range&&(!Number.isSafeInteger(b)||!Number.isSafeInteger(w)||b<0||w<b||w>=n.length))throw new k("E_PLAYBACK_FLOW_RANGE",`\u64AD\u653E\u63A7\u5236\u6D41\u8303\u56F4 [${b}, ${w}] \u8D85\u51FA\u65F6\u95F4\u5217\u8FB9\u754C`,d);let N={hook:x,sourceSpan:d};for(let _=b;_<=w;_++){let M=a.get(_);M?M.push(N):a.set(_,[N])}};for(let g of s.astToTemporal.values())for(let d of g){c(d,d.ast.sourceSpan);let x=d.playbackMarks?.();if(!x)continue;let b=i(d);if(b!==void 0)for(let w of x){let N=r.get(w);N?N.push(b):r.set(w,[b])}}for(let g of s.attachments)c(g,g.sourceSpan??{start:0,end:0});if(a.size===0)return n.map((g,d)=>d);for(let g of r.values())g.sort((d,x)=>d-x);let l=new Array(n.length).fill(0),h=0,p={get column(){return h},visits:g=>l[g]??0,seek(g,d,x){let b=r.get(g);if(b){if(x>0)return b.find(w=>w>d);for(let w=b.length-1;w>=0;w--)if(b[w]<d)return b[w]}}},u=[],m=0;for(;h<n.length;){if(++m>e)throw new k("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 g;for(let d of a.get(h)??[]){let b=d.hook.run(p);if(b){if(b.kind==="stop")return u;if(!Number.isSafeInteger(b.column)||b.column<0||b.column>n.length)throw new k("E_PLAYBACK_FLOW_JUMP",`\u64AD\u653E\u63A7\u5236\u6D41\u8DF3\u8F6C\u76EE\u6807 ${b.column} \u8D85\u51FA\u65F6\u95F4\u5217\u8FB9\u754C`,d.sourceSpan);g=Math.min(g??1/0,b.column)}}g!==void 0?h=g:(u.push(h),h++)}let f=new Set(u),y=!1;for(let g=0;g<n.length;g++){let d=!f.has(g);d&&!y&&t.push(new G("W_PLAYBACK_COLUMN_NEVER_PLAYED","\u8FD9\u91CC\u5728\u4EFB\u4F55\u4E00\u904D\u91CC\u90FD\u4E0D\u4F1A\u6F14\u594F",n[g][0].ast.sourceSpan)),y=d}return u}function hc(s,t){let e=t?.maxFlowSteps??65536;if(!Number.isSafeInteger(e)||e<=0)throw new k("E_PLAYBACK_FLOW_LIMIT","maxFlowSteps \u5FC5\u987B\u662F\u6B63\u5B89\u5168\u6574\u6570",s.columns[0]?.[0]?.ast.sourceSpan??{start:0,end:0});let n=[],o=[],i=[],r=new Map,a=0,c=0,l=()=>c++,h=[],p=(C,I,O)=>h.push({at:C.clone(),origins:I,apply:O});function u(C,I,O,H,Y=[]){let tt={node:C},V=[...Y,tt],q=C.playbackState?.program;if(q!==void 0&&r.get(C.track)!==q&&(r.set(C.track,q),i.push({kind:"program-change",at:O.clone(),order:a++,origins:[...V],track:C.track,program:q})),C.playbackState){let{bpm:$}=C.playbackState;p(O,V,F=>{$&&(F.bpm=$)})}let v=I.length,T=[...I],B=[],E,R=!1;C.emitPlayback?.({start:O,end:O.clone().add(H),track:C.track,nextNoteId:l,emit($){let F={...$,at:$.at.clone(),order:a++,origins:[...V]};if(F.kind==="note-on"){R=!0;let W={...F,track:C.track,sourceSpans:[{...C.ast.sourceSpan}]};B.push(W),i.push(W)}else B.push(F),i.push(F)},control:($,F)=>p($,V,F),affectFollowing:$=>I.push($),defer:$=>(E??=[]).push($),play:($,F,W)=>u($,T,F??O,W??H,V)}),v>0&&R&&i.push($=>{let F=B;for(let W=0;W<v;W++){let X=F.length,K=T[W]($,F);K&&($.events.splice($.events.length-X,X,...K),F=K)}}),E&&i.push(...E)}let m=lc(s,n,e),f=s.columns[m[0]]?.[0]?.t.clone()??new z,y=[{performance:new z,score:f}],g=new z().sub(f),d=new z;for(let C=0;C<m.length;C++){let I=m[C];for(let q of s.columns[I])u(q,[],q.t.clone().add(g),q.T.clone());let O=s.columns[I+1]?.[0]?.t??s.duration;d.copyFrom(O).add(g);let H=m[C+1];if(H===void 0||H===I+1)continue;let Y=s.columns[H][0]?.t.clone()??new z;g.add(O).sub(Y);let tt={performance:d.clone(),score:Y};y[y.length-1].performance.equals(tt.performance)?y[y.length-1]=tt:y.push(tt)}let x={bpm:$t,bpmScale:new z(1)},b=[],w,N=()=>({bpm:x.bpm,bpmScale:x.bpmScale.clone(),effectiveBpm:x.bpm*x.bpmScale.toNumber()}),_=(C,I)=>{let O=N();if(!Number.isFinite(O.effectiveBpm)||O.effectiveBpm<=0)throw new Error("Playback controls produced an invalid BPM");let H=b[b.length-1];H&&H.state.bpm===O.bpm&&H.state.bpmScale.equals(O.bpmScale)||(b.push({at:C,state:O}),w!==O.effectiveBpm&&(w=O.effectiveBpm,o.push({kind:"tempo",at:C.clone(),bpm:O.effectiveBpm,order:a++,origins:I})))};h.sort((C,I)=>C.at.compare(I.at));let M=0;for(h[0]?.at.compare(0)!==0&&_(new z,[]);M<h.length;){let C=h[M].at.clone(),I=[];for(;M<h.length&&C.equals(h[M].at);){let O=h[M++];O.apply(x);for(let H of O.origins)I.includes(H)||I.push(H)}_(C,I)}let S={events:o,diagnostics:n,nextNoteId:l,stateAt:C=>{let I=0,O=b.length;for(;I<O;){let H=I+O>>>1;b[H].at.compare(C)<=0?I=H+1:O=H}return b[I-1]?.state??N()}};for(let C of i)typeof C=="function"?C(S):o.push(C);o.sort(Zo);for(let C of s.attachments)Xo(C)&&C.applyPlayback(S);o.sort(Zo);let L=sr(o,s.tracks),A=o.at(-1)?.at;return A&&A.compare(d)>0&&d.copyFrom(A),{events:L.events,scoreMap:y,tracks:L.tracks,performanceDuration:d,durationSeconds:xn(L.events,d.toNumber()),diagnostics:n}}function Kt(s){return s.pages.length>0?s.pages.map(t=>t.bounds):[s.bounds]}function Qo(s,t){for(let e of s.attachments)e.layer==="background"&&e.paint(t);for(let e of s.objects){e.paint(t);for(let n of e.decorations)n.paint(t)}for(let e of s.attachments)e.layer==="foreground"&&e.paint(t)}var qo=class{pages;painters;constructor(t,e){this.pages=t,this.painters=e}route(t,e,n){let o=0,i=this.pages.length;for(;o<i;){let r=o+i>>>1,a=this.pages[r];a.y+a.h<t?o=r+1:i=r}for(let r=o;r<this.pages.length&&this.pages[r].y<=e;r++)n(this.painters[r])}drawText(t,e,n,o){this.route(n,n,i=>i.drawText(t,e,n,o))}drawLine(t,e,n,o,i){let r=(i?.strokeWidth??1)/2;this.route(Math.min(e,o)-r,Math.max(e,o)+r,a=>a.drawLine(t,e,n,o,i))}drawRect(t,e,n,o,i){let r=i?.stroke?(i.strokeWidth??1)/2:0;this.route(e-r,e+Math.max(0,o)+r,a=>{a.drawRect(t,e,n,o,i)})}drawCircle(t,e,n,o){let i=o?.stroke?(o.strokeWidth??1)/2:0,r=Math.max(0,n)+i;this.route(e-r,e+r,a=>a.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,i=1/0,r=-1/0,a=l=>{let h=o(l);i=Math.min(i,h),r=Math.max(r,h)};for(let l of t)l.op!=="Z"&&(l.op==="Q"&&a(l.cy),l.op==="C"&&(a(l.cy1),a(l.cy2)),a(l.y));if(!Number.isFinite(i))return;let c=e?.stroke?(e.strokeWidth??1)/2:0;this.route(i-c,r+c,l=>{l.drawPath(t,e,n)})}};function yn(s,t){let e=Kt(s);if(t.length!==e.length)throw new Error(`Expected ${e.length} page painters, got ${t.length}`);Qo(s,new qo(e,t))}var Jo=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,i){this.commands.push({kind:"line",x1:t,y1:e,x2:n,y2:o,style:i})}drawRect(t,e,n,o,i){this.commands.push({kind:"rect",x:t,y:e,w:n,h:o,style:i})}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=>pc(o,n)),style:e})}};function pc(s,t){if(!t||s.op==="Z")return{...s};let e=o=>t.x+o*t.scaleX,n=o=>t.y+o*t.scaleY;return s.op==="M"||s.op==="L"?{op:s.op,x:e(s.x),y:n(s.y)}:s.op==="Q"?{op:"Q",cx:e(s.cx),cy:n(s.cy),x:e(s.x),y:n(s.y)}:s.op==="C"?{op:"C",cx1:e(s.cx1),cy1:n(s.cy1),cx2:e(s.cx2),cy2:n(s.cy2),x:e(s.x),y:n(s.y)}:{...s}}function J(s){return Number.isFinite(s)?String(Math.round(s*1e3)/1e3):"0"}function At(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function uc(s,t){let e=[],n=t?i=>J(t.x+i*t.scaleX):J,o=t?i=>J(t.y+i*t.scaleY):J;for(let i of s){if(i.op==="Z"){e.push("Z");continue}if(i.op==="M"||i.op==="L"){e.push(`${i.op}${n(i.x)} ${o(i.y)}`);continue}if(i.op==="Q"){e.push(`Q${n(i.cx)} ${o(i.cy)} ${n(i.x)} ${o(i.y)}`);continue}"cx1"in i&&e.push(`C${n(i.cx1)} ${o(i.cy1)} ${n(i.cx2)} ${o(i.cy2)} ${n(i.x)} ${o(i.y)}`)}return e.join(" ")}function Ne(s){return s?.opacity===void 0?"":` opacity="${J(s.opacity)}"`}var gn=class{body=[];drawText(t,e,n,o){let i=o.fontFamily??ce,r=o.fontWeight??"normal",a=o.fill??"#000",c=o.textAlign==="center"?"middle":o.textAlign==="right"?"end":"start";this.body.push(`<text x="${J(e)}" y="${J(n)}" font-family="${At(i)}" font-size="${J(o.fontSize)}" font-weight="${At(String(r))}" text-anchor="${c}" fill="${At(a)}" xml:space="preserve"${Ne(o)}>${At(t)}</text>`)}drawLine(t,e,n,o,i){let r=i?.stroke??i?.fill??"#000",a=i?.strokeWidth??1;this.body.push(`<line x1="${J(t)}" y1="${J(e)}" x2="${J(n)}" y2="${J(o)}" stroke="${At(r)}" stroke-width="${J(a)}" stroke-linecap="round"${Ne(i)} />`)}drawRect(t,e,n,o,i){let r=i?.fill??"none",a=i?.stroke??"none",c=i?.strokeWidth??1;this.body.push(`<rect x="${J(t)}" y="${J(e)}" width="${J(Math.max(0,n))}" height="${J(Math.max(0,o))}" fill="${At(r)}" stroke="${At(a)}" stroke-width="${J(c)}"${Ne(i)} />`)}drawCircle(t,e,n,o){let i=o?.fill??"#000",r=o?.stroke??"none",a=o?.strokeWidth??1;this.body.push(`<circle cx="${J(t)}" cy="${J(e)}" r="${J(Math.max(0,n))}" fill="${At(i)}" stroke="${At(r)}" stroke-width="${J(a)}"${Ne(o)} />`)}drawPath(t,e,n){if(t.length===0)return;let o=uc(t,n),i=e?.fill??"none",r=e?.stroke??"none",a=e?.strokeWidth??1;this.body.push(`<path d="${o}" fill="${At(i)}" stroke="${At(r)}" stroke-width="${J(a)}" stroke-linecap="round" stroke-linejoin="round"${Ne(e)} />`)}toSvg(t,e={}){let n=Math.max(0,e.padding??0),o=t.x-n,i=t.y-n,r=Math.max(1,t.w+n*2),a=Math.max(1,t.h+n*2),c=e.background?`<rect x="${J(o)}" y="${J(i)}" width="${J(r)}" height="${J(a)}" fill="${At(e.background)}" />`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${J(r)}" height="${J(a)}" viewBox="${J(o)} ${J(i)} ${J(r)} ${J(a)}">${c}${this.body.join("")}</svg>`}};function fc(s,t={}){let e=Kt(s),n=e.map(()=>new gn);return yn(s,n),n.map((o,i)=>o.toSvg(e[i],t))}function dc(s,t,e=0,n=0,o=1,i=1){s.beginPath();for(let r of t){if(r.op==="Z"){s.closePath();continue}if(r.op==="M"){s.moveTo(e+r.x*o,n+r.y*i);continue}if(r.op==="L"){s.lineTo(e+r.x*o,n+r.y*i);continue}if(r.op==="Q"){s.quadraticCurveTo(e+r.cx*o,n+r.cy*i,e+r.x*o,n+r.y*i);continue}"cx1"in r&&s.bezierCurveTo(e+r.cx1*o,n+r.cy1*i,e+r.cx2*o,n+r.cy2*i,e+r.x*o,n+r.y*i)}}function _e(s,t){t?.opacity!==void 0&&(s.globalAlpha*=t.opacity)}var bn=class{context;constructor(t){this.context=t}drawText(t,e,n,o){this.context.save(),_e(this.context,o),this.context.fillStyle=o.fill??"#000",this.context.font=Ze(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,i){this.context.save(),_e(this.context,i),this.context.beginPath(),this.context.moveTo(t,e),this.context.lineTo(n,o),this.context.strokeStyle=i?.stroke??i?.fill??"#000",this.context.lineWidth=i?.strokeWidth??1,this.context.lineCap="round",this.context.stroke(),this.context.restore()}drawRect(t,e,n,o,i){n<0||o<0||(this.context.save(),_e(this.context,i),i?.fill&&(this.context.fillStyle=i.fill,this.context.fillRect(t,e,n,o)),i?.stroke&&(this.context.strokeStyle=i.stroke,this.context.lineWidth=i.strokeWidth??1,this.context.strokeRect(t,e,n,o)),this.context.restore())}drawCircle(t,e,n,o){n<0||(this.context.save(),_e(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(),_e(this.context,e),dc(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 mc(s,t){let e=Kt(s);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{yn(s,t.map(n=>new bn(n)))}finally{for(let n of t)n.restore()}}function ts(s,t,e){let n=0,o=s.length;for(;n<o;){let i=Math.floor((n+o)/2);e(s[i])<t?n=i+1:o=i}return n}function ir(s,t,e){let n=Math.max(1,Math.round(t/48)),o=[],i=[...e].sort((a,c)=>a-c);for(let a of s){let c=[...a.notes].sort((l,h)=>l.ticks-h.ticks);for(let l of[t/2,t,t*2]){let h=l/3,p=Math.min(n,h/8),u=l/2,m=new Set(c.map(f=>Math.round(f.ticks/u)*u).filter((f,y)=>Math.abs(c[y].ticks-f)<=p));for(let f of m){let y=f+l,g=ts(i,f,_=>_);for(;i[g]===f;)g++;if(i[g]<y)continue;let d=[0,1,2].map(_=>{let M=f+_*h,S=ts(c,M-p,A=>A.ticks),L=ts(c,M+p+1,A=>A.ticks);return c.slice(S,L).filter(A=>Math.abs(A.ticks-M)<=p&&Math.abs(A.durationTicks-h)<=p)});if(d.some(_=>_.length===0))continue;let x=d.map(_=>_.reduce((M,S)=>M+S.ticks,0)/_.length),b=x.reduce((_,M,S)=>_+Math.abs(M-(f+S*h)),0)/3,w=l/4,N=x.reduce((_,M)=>_+Math.abs(M-(f+Math.round((M-f)/w)*w)),0)/3;N-b>=p&&o.push({notes:d,start:f,span:l,advantage:N-b})}}}o.sort((a,c)=>c.advantage-a.advantage);let r=0;for(let a of o)if(!a.notes.some(c=>c.some(l=>l.triplet))){for(let c=0;c<3;c++)for(let l of a.notes[c])l.triplet={group:r,slot:c,startTicks:a.start,spanTicks:a.span};r++}return r>0}var xc={title:"size=2em, align=center",subtitle:"size=0.85em, align=center",author:"size=0.8em, align=right"};function Pt(s,t){for(let e=t.length-1;e>=0;e--)s=`{${s} ^ ${t[e]}}`;return s}function wn(s,t,e=""){if(t==="absolute")return s.octave===0?`@note(${s.name}, ${s.accidental}, 0)${e}`:`${s.name}${s.accidental}${s.octave}${e}`;let n=s.octave>0?"'".repeat(s.octave):",".repeat(-s.octave);return`${s.accidental}${s.name}${n}${e}`}function es(s,t){return t.trim()!==t||/[\r\n%]/.test(t)||/^\s*[@{]/.test(t)||t.endsWith("\\")?`H.${s}: @text(${ht(t)}, ${xc[s]})`:`H.${s}: ${t}`}function Sn(s){let[t,e]=s.meter,n=[];return s.title&&n.push(es("title",s.title)),s.subtitle&&n.push(es("subtitle",s.subtitle)),s.author&&n.push(es("author",s.author)),n.push(`H.signature: 1=${s.key} ${t}/${e}`),n.push(`H.tempo: ${s.tempo}`),n.join(`
120
- `)}function An(s){let t=Math.max(0,...s.map(e=>e.length));return Array.from({length:t},(e,n)=>s.map(o=>o[n]).filter(Boolean).join(`
122
+ )`}},Cr=je,vr=fe,rs=.82,Wc=.6;function Mr(s,t){return{fontFamily:t,fontSize:s*rs,fill:"#000",fontWeight:600}}var In=class extends tt{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 i of this.ast.lyrics){if(!i.name)continue;let r=t.textMeasurer.measureText(i.name,Mr(this.ast.size,this.ast.font));n=Math.max(n,r.w)}let o=this.braceSpace>0?this.braceSpace:n>0?this.ast.size*Wc: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)}},ce=2.33,le=1.17,ae=.34,Gc=[{op:"M",x:0,y:0},{op:"L",x:0,y:-ae},{op:"C",cx1:ce*.421,cy1:-ae+le*.077,cx2:ce*.733,cy2:-ae+le*.346,x:ce,y:-ae+le},{op:"L",x:ce*.929,y:-ae+le},{op:"C",cx1:ce*.696,cy1:-ae+le*.535,cx2:ce*.328,cy2:-ae+le*.352,x:0,y:0},{op:"Z"}],as=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,i=e.y+e.visualAxis+n*.5;if(i-o<1e-6)return{regions:[],paint(){}};let r=Math.max(2.5,n*.19),a=r*ce,c=r*le,l=t.x+t.anchor+this.ast.braceSpace*.3+r/2,f=[{x:l-r/2,y:o,w:r,h:i-o},{x:l+r*1.33-r*.165,y:o+r*.67,w:r*.33,h:i-o-r*1.34}],p=[{x:l,y:o,scale:r,dir:-1},{x:l,y:i,scale:r,dir:1}];return{regions:[{x:l-r/2,y:o-c,w:a+r/2,h:i-o+c*2}],paint(d){for(let h of f)d.drawRect(h.x,h.y,h.w,h.h,{fill:"#000"});for(let h of p)d.drawPath(Gc,{fill:"#000"},{x:h.x,y:h.y,scaleX:h.scale,scaleY:h.scale*h.dir})}}}},cs=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(Q).filter(a=>a.ports?.lyric),{lyrics:o,size:i}=this.nameHost.ast;if(n.length===0||o.length===0)return;let r={fontSize:i*rs,fontFamily:this.nameHost.ast.font,fill:"#000"};for(let a=0;a<n.length;a++){let c=n[a],l=0;for(let f of o){let p=f.tokens[a];if(p){let{body:u}=Tr(p);u&&(l=Math.max(l,e.textMeasurer.measureText(u,r).w/2))}}l!==0&&t[c.layoutLine]?.registerHorizontalLayoutHook(c,c,({columns:f,start:p})=>{let u=f[p].find(h=>h.time===c);if(!u)return;let d=c.ports.lyric.x-c.box.anchor;u.WL=Math.max(u.WL,l-d),u.WR=Math.max(u.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=[],i=this.temporalMembers.filter(Q).filter(y=>y.ports?.lyric);if(i.length===0||e.length===0)return o;let r=new Map;for(let y of i){let w=r.get(y.layoutLine);w||r.set(y.layoutLine,w=new Map);let E=y.box.y+y.box.h;w.set(y.track,Math.max(w.get(y.track)??E,E))}let a=n*rs,c=n*.24,l=n*.32,f={fontSize:a,fontFamily:this.nameHost.ast.font,fill:"#000"},p=Mr(n,this.nameHost.ast.font),u=t.textMeasurer.measureText("M",f).baseline+l,d=(y,w)=>y+u+w*(a+c),{box:h,layoutLine:x,track:g}=this.nameHost,m=r.get(x)?.get(g);for(let y=0;y<e.length;y++){let w=e[y];for(let A=0;A<w.tokens.length&&A<i.length;A++){let L=w.tokens[A],M=i[A],T=r.get(M.layoutLine)?.get(M.track);if(!L||T===void 0)continue;let S=t.textMeasurer.measureText(L,f),{prefix:b,body:v}=Tr(L),_=v?t.textMeasurer.measureText(v,f).w:0,I=b?t.textMeasurer.measureText(b,f).w:0;o.push({text:L,style:f,textBaselineY:S.baseline,x:M.box.x+M.ports.lyric.x-_/2-I,y:d(T,y)-S.baseline,w:S.w,h:S.h,line:M.layoutLine,track:M.track})}if(!w.name||!h||m===void 0)continue;let E=t.textMeasurer.measureText(w.name,p);o.push({text:w.name,style:p,textBaselineY:E.baseline,x:h.x+h.anchor-E.w,y:d(m,y)-E.baseline,w:E.w,h:E.h,line:x,track:g})}return o}};var $n=[Zi,yi,ii,Te,Si,Er,Cr,vr,ji,tr,Vi,or,Qi,Ji,si,Ci,Ar,mi,Ai,xi,wr,Gs,gr,wn,An,En,er,Tn,yr];function ls(s,t={}){let e=new Map,n=new Set(s);for(let o of n){let i=o.layoutDecorationHandler;if(!i)continue;let r=o.def?.name;if(!r)continue;let a=Array.isArray(r)?r[0]:r;e.set(Jt(a),i)}return{textMeasurer:t.textMeasurer??Ao,decorationHandlers:e}}var Ye=class s{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 ne,n=new F,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 c of t){let l=0;for(let f of c)f.breakBefore>l&&(l=f.breakBefore);e+=l,c.layoutLine=e}let n={bpm:jt,velocity:ge,keySignature:Oe,program:on},o=new Map,i=new Map,r=c=>o.get(c)??(c.parent?r(c.parent):ge),a=c=>i.get(c)??(c.parent?a(c.parent):on);for(let c of t)for(let l of c)n.velocity=r(l.track),n.program=a(l.track),l.onTimeState?.(n),o.set(l.track,n.velocity),i.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 i=t.timeFlowModel(this);if(i)switch(i.mode){case"sequence":for(let r of i.children)for(let a of this.trackedEvents(r,e,n))o.push(a);break;case"parallel":{let r=i.tracks,a=i.children,c=r.hostIndex===void 0?0:r.hostIndex,l=n.group(r,c===null?a.length:a.length-1),f=[];for(let d=0;d<a.length;d++){let h=a[d],x=d===c?n:l.members[c===null||d<c?d:d-1],g=e.clone(),m=this.trackedEvents(h,g,x);m.length===0&&this.diagnostics.push(D.warning.ZeroTimeTrack(h.sourceSpan,d+1)),f.push(m)}let p=o.length;for(let d of s.anchorAlign(f))o.push(d);let u=new F;for(let d=p;d<o.length;d++)for(let h of o[d])u.copyFrom(h.t).add(h.T),u.compare(e)>0&&e.copyFrom(u)}break}return this.appendEvents(t.loweringExit(this,n,e),t,e,n,o),o}appendEvents(t,e,n,o,i){let r;for(let a of t){this.initEvent(a,e,n,o),this.indexTemporal(a);for(let l=this.activeLoweringGroups.length-1;l>=0;l--)this.activeLoweringGroups[l].group.onTemporal?.(a);let c=(r??=new F).copyFrom(a.t).add(a.T);c.compare(n)>0&&n.copyFrom(c),i.push(new ps(a))}}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],f=t[1],p=l.length,u=f.length,d=0,h=0,x=new F,g=new F,m=l[0],y=f[0],w=m.t.clone(),E=y.t.clone();for(;;){if(m.mergeKey===ct){if(y.mergeKey!==ct){for(n.push(y),y=f[++h];h<u&&y.mergeKey!==ct;)g.isZero()||y.shiftTime(g),n.push(y),y=f[++h];y&&(y.shiftTime(g),E.copyFrom(y.t))}if(h<u){let A=w.compare(E)>=0?w:E;x.add(A).sub(w),g.add(A).sub(E),m.push(...y),m.t=A,y=f[++h]}if(n.push(m),m=l[++d],m&&(m.shiftTime(x),w.copyFrom(m.t)),y&&(y.shiftTime(g),E.copyFrom(y.t)),!m||!y)break}if(y.mergeKey===ct){if(m.mergeKey!==ct){for(n.push(m),m=l[++d];d<p&&m.mergeKey!==ct;)x.isZero()||m.shiftTime(x),n.push(m),m=l[++d];m&&(m.shiftTime(x),w.copyFrom(m.t))}if(d<p){let A=w.compare(E)>=0?w:E;x.add(A).sub(w),g.add(A).sub(E),y.push(...m),y.t=A,m=l[++d]}if(n.push(y),y=f[++h],m&&(m.shiftTime(x),w.copyFrom(m.t)),y&&(y.shiftTime(g),E.copyFrom(y.t)),!m||!y)break}if(w.equals(E)){if(m.mergeKey===y.mergeKey){if(m.push(...y),n.push(m),m=l[++d],y=f[++h],m&&(m.shiftTime(x),w.copyFrom(m.t)),y&&(y.shiftTime(g),E.copyFrom(y.t)),!m||!y)break}else if(m.mergeKey<y.mergeKey)if(n.push(m),m=l[++d],m)m.shiftTime(x),w.copyFrom(m.t);else break;else if(n.push(y),y=f[++h],y)y.shiftTime(g),E.copyFrom(y.t);else break;continue}if(w.compare(E)<0)if(n.push(m),m=l[++d],m){m.shiftTime(x),w.copyFrom(m.t);continue}else break;if(E.compare(w)<0)if(n.push(y),y=f[++h],y){y.shiftTime(g),E.copyFrom(y.t);continue}else break}for(m&&n.push(m);++d<p;)m=l[d],x.isZero()||m.shiftTime(x),n.push(m);for(y&&n.push(y);++h<u;)y=f[h],g.isZero()||y.shiftTime(g),n.push(y);return n}let o=new Uint16Array(e),i=Array.from({length:e},()=>new F),r=[],a=new us(e);for(let l=0;l<e;l++)a.push({e:t[l][0],i:l});let c=l=>{let f=t[l][++o[l]];f&&(i[l].isZero()||f.shiftTime(i[l]),a.push({e:f,i:l}))};for(;;){let l=a.pop();if(l===void 0){if(r.length===0)break;let p=r[0],u=p.e,d=u.t;for(let h=1;h<r.length;h++)r[h].e.t.compare(d)>0&&(d=r[h].e.t);i[p.i].add(d).sub(u.t),c(p.i);for(let h=1;h<r.length;h++){let x=r[h];u.push(...x.e),i[x.i].add(d).sub(x.e.t),c(x.i)}r.length=0,u.t=d,u.sort((h,x)=>h.order-x.order),n.push(u);continue}if(l.e.mergeKey===ct){r.push(l);continue}let f=[l.i];for(;;){let p=a.front();if(!p||!p.e.t.equals(l.e.t)||p.e.mergeKey!==l.e.mergeKey)break;a.pop(),l.e.push(...p.e),f.push(p.i)}n.push(l.e);for(let p of f)c(p)}return n}},ps=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 fs(s,t){let e=s.e.t.compare(t.e.t);return e!==0?e:s.e.mergeKey!==t.e.mergeKey?s.e.mergeKey<t.e.mergeKey?-1:1:s.i-t.i}var us=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(fs(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 i=n;if(o<this.validLen&&fs(this[o],this[n])<0&&(i=o),fs(this[i],e)>=0)break;this[t]=this[i],t=i}this[t]=e}};function hs(s,t={}){let{functions:e=$n,textMeasurer:n,variables:o,...i}=t,{maskedSource:r,lineStarts:a}=Me(s),c=new Rt({source:r,variables:o});c.registerFunctions(e);let l=new ut({start:0,end:s.length},c.parse()),f=new Ye(c.diagnostics);f.registerFunctions(e);let p=f.lowerDocument(l),u=ls(e,{textMeasurer:n}),d=to(p,u,i);return{lineStarts:a,maskedSource:r,diagnostics:c.diagnostics,ast:l,lowering:p,layout:d}}function Uc(s,t=$n){let{maskedSource:e,commentSpans:n}=Me(s),o=new Rt({source:e,commentSpans:n});return o.registerFunctions(t),{syntax:o.parseSyntax(),diagnostics:o.diagnostics}}function ds(s){return typeof s.applyPlayback=="function"}function On(s,t){let e=Math.max(0,t),n=0,o=0,i=jt;for(let r of s){if(r.kind!=="tempo")continue;let a=r.at.toNumber();if(a>e)break;a>o&&(n+=(a-o)*60/i),o=a,i=r.bpm}return n+(e-o)*60/i}function Nr(s,t){let e=Math.max(0,t),n=0,o=jt;for(let i of s){if(i.kind!=="tempo")continue;let r=i.at.toNumber(),a=(r-n)*60/o;if(e<a)return n+e*o/60;e-=a,n=r,o=i.bpm}return n+e*o/60}function kr(s,t){let e=Math.max(0,t),n=e;for(let o of s){let i=o.performance.toNumber();if(i>e)break;n=o.score.toNumber()+e-i}return n}function _r(s,t){let e=Math.max(0,t),n;for(let o=0;o<s.length;o++){let i=s[o],r=i.score.toNumber();if(r>e){(!n||r<n.score.toNumber())&&(n=i);continue}let a=s[o+1],c=a?a.performance.toNumber()-i.performance.toNumber():1/0;if(!(e-r>=c))return i.performance.toNumber()+(e-r)}return n?.performance.toNumber()??e}function Vc(s,t){let e=Math.min(Nr(s.events,t),s.performanceDuration.toNumber());return kr(s.scoreMap,e)}function jc(s,t){let e=Math.min(_r(s.scoreMap,t),s.performanceDuration.toNumber());return On(s.events,e)}var Rr={tempo:0,"time-signature":1,"program-change":2,"note-off":3,"note-on":4};function Ir(s,t){return s.at.compare(t.at)||Rr[s.kind]-Rr[t.kind]||s.order-t.order}function $r(s,t){let e=new Map,n=new Map;for(let a of s)if(a.kind==="note-on"){if(e.has(a.noteId))throw new Error(`Duplicate NoteOn ${a.noteId}`);e.set(a.noteId,a)}else if(a.kind==="note-off"){if(n.has(a.noteId))throw new Error(`Duplicate NoteOff ${a.noteId}`);n.set(a.noteId,a)}for(let[a,c]of e){let l=n.get(a);if(!l)throw new Error(`Note ${a} has no NoteOff`);if(l.at.compare(c.at)<=0)throw new Error(`Note ${a} has a non-positive duration`);if(c.origins.length===0||l.origins.length===0)throw new Error(`Note ${a} has no origin`)}for(let a of n.keys())if(!e.has(a))throw new Error(`NoteOff ${a} has no NoteOn`);let o=new Set;for(let a of e.values())o.add(a.track);let i=new Map;for(let a of t)o.has(a)&&i.set(a,i.size);for(let a of o)i.has(a)||i.set(a,i.size);let r=[];for(let a of s){if(a.kind==="tempo"){r.push({kind:"tempo",at:a.at,bpm:a.bpm});continue}if(a.kind==="time-signature"){r.push({kind:"time-signature",at:a.at,numerator:a.numerator,denominator:a.denominator});continue}if(a.kind==="program-change"){let f=i.get(a.track);f!==void 0&&r.push({kind:"program-change",at:a.at,track:f,program:a.program});continue}let c=a.kind==="note-on"?a:e.get(a.noteId),l=i.get(c.track);if(a.kind==="note-on"){r.push({kind:"note-on",at:a.at,noteId:a.noteId,track:l,midi:a.midi,velocity:a.velocity,...a.percussion?{percussion:!0}:{},sourceSpans:a.sourceSpans});continue}r.push({kind:"note-off",at:a.at,noteId:a.noteId,track:l,midi:c.midi})}return{events:r,tracks:[...i.keys()]}}function Yc(s,t,e){let n=s.columns,o=new Map;for(let g=0;g<n.length;g++)for(let m of n[g])o.set(m,g);let i=g=>{for(let m=g;m;m=m.foldedInto){let y=o.get(m);if(y!==void 0)return y}},r=new Map,a=new Map,c=(g,m)=>{let y=g.playbackFlow?.(i);if(!y)return;let[w,E]=y.range??[0,n.length-1];if(y.range&&(!Number.isSafeInteger(w)||!Number.isSafeInteger(E)||w<0||E<w||E>=n.length))throw new k("E_PLAYBACK_FLOW_RANGE",`\u64AD\u653E\u63A7\u5236\u6D41\u8303\u56F4 [${w}, ${E}] \u8D85\u51FA\u65F6\u95F4\u5217\u8FB9\u754C`,m);let A={hook:y,sourceSpan:m};for(let L=w;L<=E;L++){let M=a.get(L);M?M.push(A):a.set(L,[A])}};for(let g of s.astToTemporal.values())for(let m of g){c(m,m.ast.sourceSpan);let y=m.playbackMarks?.();if(!y)continue;let w=i(m);if(w!==void 0)for(let E of y){let A=r.get(E);A?A.push(w):r.set(E,[w])}}for(let g of s.attachments)c(g,g.sourceSpan??{start:0,end:0});if(a.size===0)return n.map((g,m)=>m);for(let g of r.values())g.sort((m,y)=>m-y);let l=new Array(n.length).fill(0),f=0,p={get column(){return f},visits:g=>l[g]??0,seek(g,m,y){let w=r.get(g);if(w){if(y>0)return w.find(E=>E>m);for(let E=w.length-1;E>=0;E--)if(w[E]<m)return w[E]}}},u=[],d=0;for(;f<n.length;){if(++d>e)throw new k("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[f][0].ast.sourceSpan);l[f]++;let g;for(let m of a.get(f)??[]){let w=m.hook.run(p);if(w){if(w.kind==="stop")return u;if(!Number.isSafeInteger(w.column)||w.column<0||w.column>n.length)throw new k("E_PLAYBACK_FLOW_JUMP",`\u64AD\u653E\u63A7\u5236\u6D41\u8DF3\u8F6C\u76EE\u6807 ${w.column} \u8D85\u51FA\u65F6\u95F4\u5217\u8FB9\u754C`,m.sourceSpan);g=Math.min(g??1/0,w.column)}}g!==void 0?f=g:(u.push(f),f++)}let h=new Set(u),x=!1;for(let g=0;g<n.length;g++){let m=!h.has(g);m&&!x&&t.push(new U("W_PLAYBACK_COLUMN_NEVER_PLAYED","\u8FD9\u91CC\u5728\u4EFB\u4F55\u4E00\u904D\u91CC\u90FD\u4E0D\u4F1A\u6F14\u594F",n[g][0].ast.sourceSpan)),x=m}return u}function Kc(s,t){let e=t?.maxFlowSteps??65536;if(!Number.isSafeInteger(e)||e<=0)throw new k("E_PLAYBACK_FLOW_LIMIT","maxFlowSteps \u5FC5\u987B\u662F\u6B63\u5B89\u5168\u6574\u6570",s.columns[0]?.[0]?.ast.sourceSpan??{start:0,end:0});let n=[],o=[],i=[],r=[],a=new Map,c=new Map,l=0,f=0,p=[{kind:"initial",at:new F,origins:[]}],u=new Map,d=new Map,h={spans:i,notes:r,diagnostics:n},x=(C,R,W)=>{if(!Number.isFinite(C.toNumber())||C.compare(0)<0)throw new k("E_PLAYBACK_CONTROL_TIME","\u7CFB\u7EDF\u63A7\u5236\u65F6\u523B\u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u503C",R.at(-1).node.ast.sourceSpan);p.push({kind:"control",at:C.clone(),origins:R,apply:W})};function g(C,R,W,j,X,gt=[],rt=C.track){let st=[...gt,{node:C}],_t=[...R],At=[...R],Ht=[...W],Ft=[...W],Z=[];function it(Y){let et={...Y,start:Y.start.clone(),end:Y.end.clone(),track:rt,origins:st,sourceSpans:[{...C.ast.sourceSpan}]};return i.push(et),Ft.length&&d.set(et,Ft),et}let Nt=C.playbackState?.program;Nt!==void 0&&c.get(rt)!==Nt&&(c.set(rt,Nt),o.push({kind:"program-change",at:j.clone(),order:l++,origins:st,track:rt,program:Nt}));let It=C.playbackState?.bpm;It!==void 0&&x(j,st,Y=>{Y.bpm=It}),C.emitPlayback?.({start:j,end:j.clone().add(X),track:rt,span(Y){it(Y)},note(Y){let et=it(Y);r.push(et),At.length&&a.set(et,At)},extend(Y){if(!i.includes(Y)||!Y.end.equals(j)||X.compare(0)<=0)throw new k("E_PLAYBACK_EXTEND_RANGE","\u6269\u5C55\u5FC5\u987B\u63A5\u7EED\u5F53\u524D\u8BA1\u5212\u5185\u7684\u533A\u95F4\u4E14\u65F6\u503C\u4E3A\u6B63",C.ast.sourceSpan);let et=Y.end.clone().sub(Y.start),bt=et.clone().add(X),$t=(d.get(Y)??[]).map(wt=>wt.startRatio?{...wt,startRatio:wt.startRatio.clone().mul(et).div(bt)}:wt);for(let wt of Ft)$t.push({...wt,startRatio:et.clone().div(bt)});$t.length&&d.set(Y,$t),Y.end.add(X)},emit:Y=>o.push({...Y,at:Y.at.clone(),order:l++,origins:st}),control:(Y,et)=>x(Y,st,et),scaleFollowingBpm(Y,et,bt=1,$t){if(!Number.isSafeInteger(et)||!Number.isSafeInteger(bt)||et<=0||bt<=0)throw new k("E_PLAYBACK_BPM_SCALE","\u901F\u5EA6\u6BD4\u4F8B\u5FC5\u987B\u662F\u6B63\u6709\u7406\u6570",C.ast.sourceSpan);let wt=new F(et,bt),kt=u.get(Y);if(kt&&!kt.equals(wt))throw new k("E_PLAYBACK_BPM_SCALE","\u540C\u4E00\u901F\u5EA6\u6548\u679C key \u5FC5\u987B\u4F7F\u7528\u56FA\u5B9A\u6BD4\u4F8B",C.ast.sourceSpan);u.set(Y,wt),W.push({key:Y,factor:wt,followConnections:$t?.followConnections??!1,origins:st})},affectFollowing:Y=>R.push(Y),defer:Y=>Z.push(Y),play:(Y,et,bt)=>g(Y,_t,Ht,et??j,bt??X,st,rt)});for(let Y of Z)Y(h)}let m=Yc(s,n,e),y=s.columns[m[0]]?.[0]?.t.clone()??new F,w=[{performance:new F,score:y}],E=new F().sub(y),A=new F;for(let C=0;C<m.length;C++){let R=m[C];for(let st of s.columns[R])g(st,[],[],st.t.clone().add(E),st.T.clone());let W=s.columns[R+1]?.[0]?.t??s.duration;A.copyFrom(W).add(E);let j=m[C+1];if(j===void 0||j===R+1)continue;let X=s.columns[j][0]?.t.clone()??new F;E.add(W).sub(X);let gt={performance:A.clone(),score:X};w[w.length-1].performance.equals(gt.performance)?w[w.length-1]=gt:w.push(gt)}for(let C of i){if(!Number.isFinite(C.start.toNumber())||!Number.isFinite(C.end.toNumber())||C.start.compare(0)<0||C.end.compare(C.start)<=0)throw new k("E_PLAYBACK_NOTE_RANGE","\u97F3\u6BB5\u5FC5\u987B\u5177\u6709\u975E\u8D1F\u8D77\u70B9\u548C\u6B63\u65F6\u503C",C.sourceSpans[0]);C.end.compare(A)>0&&A.copyFrom(C.end),Object.freeze(C.start),Object.freeze(C.end);for(let R of C.origins)Object.freeze(R);for(let R of C.sourceSpans)Object.freeze(R);Object.freeze(C.origins),Object.freeze(C.sourceSpans),Object.freeze(C)}let L=new Set(r),M=new Map,T=new Map,S={notes:r,diagnostics:n,connect(C,R){if(!L.has(C)||!L.has(R)||!C.end.equals(R.start))throw new k("E_PLAYBACK_CONNECTION","\u97F3\u6BB5\u8FDE\u63A5\u5FC5\u987B\u5C5E\u4E8E\u5F53\u524D\u8BA1\u5212\u4E14\u65F6\u95F4\u76F8\u63A5",C.sourceSpans[0]);return M.has(C)&&M.get(C)!==R||T.has(R)&&T.get(R)!==C?!1:(M.set(C,R),T.set(R,C),!0)}};for(let C of s.attachments)ds(C)&&C.applyPlayback(S);let b=[...r].sort((C,R)=>R.start.compare(C.start)),v=new Map;for(let C of b){let R=M.get(C),W=R?v.get(R):C.end;v.set(C,W)}for(let C of i){let R=v.get(C)??C.end;for(let W of d.get(C)??[]){let j=W.startRatio?C.start.clone().add(C.end.clone().sub(C.start).mul(W.startRatio)):C.start;p.push({kind:"scale",at:j,origins:W.origins,scale:W,delta:1},{kind:"scale",at:W.followConnections?R:C.end,origins:W.origins,scale:W,delta:-1})}}let _={bpm:jt,bpmScale:new F(1)},I=new Map,K=new F(1),H=[];p.sort((C,R)=>C.at.compare(R.at));let B=0,G;for(;B<p.length;){let C=p[B].at,R=new Set;for(;B<p.length&&p[B].at.equals(C);){let gt=p[B++];for(let rt of gt.origins)R.add(rt);if(gt.kind==="control")gt.apply(_);else if(gt.kind==="scale"){let{key:rt,factor:st}=gt.scale,_t=I.get(rt)??0,At=_t+gt.delta;I.set(rt,At),_t===0&&At>0?K.mul(st):_t>0&&At===0&&K.div(st)}}let W=_.bpmScale.clone().mul(K),j={bpm:_.bpm,bpmScale:W,effectiveBpm:_.bpm*W.toNumber()};if(!Number.isFinite(j.effectiveBpm)||j.effectiveBpm<=0)throw new k("E_PLAYBACK_BPM","\u7CFB\u7EDF\u63A7\u5236\u4EA7\u751F\u4E86\u65E0\u6548\u901F\u5EA6",[...R].at(-1)?.node.ast.sourceSpan??{start:0,end:0});let X=H.at(-1)?.state;(!X||X.bpm!==j.bpm||!X.bpmScale.equals(W))&&H.push({at:C.clone(),state:j}),G!==j.effectiveBpm&&(G=j.effectiveBpm,o.push({kind:"tempo",at:C.clone(),bpm:j.effectiveBpm,order:l++,origins:[...R]}))}let J={diagnostics:n,stateAt(C){let R=0,W=H.length;for(;R<W;){let X=R+W>>>1;H[X].at.compare(C)<=0?R=X+1:W=X}let j=H[Math.max(0,R-1)].state;return{...j,bpmScale:j.bpmScale.clone()}}},N=new Map;for(let C of r){let R=[{...C,start:C.start.clone(),end:C.end.clone()}];for(let X of a.get(C)??[])R=X(J,R)??R;let W,j;for(let X of R){if(!Number.isFinite(X.start.toNumber())||!Number.isFinite(X.end.toNumber())||X.start.compare(C.start)<0||X.end.compare(C.end)>0||X.end.compare(X.start)<=0)throw new k("E_PLAYBACK_TRANSFORM_RANGE","\u58F0\u97F3\u5C55\u5F00\u5FC5\u987B\u4F4D\u4E8E\u539F\u97F3\u6BB5\u533A\u95F4\u5185\u4E14\u65F6\u503C\u4E3A\u6B63",C.sourceSpans[0]);(!W||X.start.compare(W)<0)&&(W=X.start),(!j||X.end.compare(j)>0)&&(j=X.end)}if(!W?.equals(C.start)||!j?.equals(C.end))throw new k("E_PLAYBACK_TRANSFORM_RANGE","\u58F0\u97F3\u5C55\u5F00\u5FC5\u987B\u4FDD\u6301\u539F\u97F3\u6BB5\u7684\u8D77\u6B62\u8FB9\u754C",C.sourceSpans[0]);N.set(C,R.map(X=>{let{start:gt,end:rt,track:st,midi:_t,velocity:At,percussion:Ht,origins:Ft,sourceSpans:Z}=X,it=f++,Nt={kind:"note-on",at:gt.clone(),noteId:it,order:l++,track:st,midi:_t,velocity:At,percussion:Ht,origins:[...Ft],sourceSpans:Z.map(Y=>({...Y}))},It={kind:"note-off",at:rt.clone(),noteId:it,order:l++,origins:[...Ft]};return o.push(Nt,It),{on:Nt,off:It}}))}let P=new Set,V=new Map;for(let C of b){let R=M.get(C);if(R)for(let W of N.get(C)){if(!W.off.at.equals(C.end))continue;let j=N.get(R).find(X=>!P.has(X.on)&&X.on.at.equals(R.start)&&X.on.track===W.on.track&&X.on.midi===W.on.midi&&X.on.percussion===W.on.percussion);j&&(W.off.at.copyFrom(j.off.at),V.set(W.on,j.on),P.add(j.on),P.add(j.off))}}for(let C of V.keys())if(!P.has(C))for(let R=V.get(C);R;R=V.get(R))C.sourceSpans.push(...R.sourceSpans);let q=o.filter(C=>!P.has(C)).sort(Ir),$=$r(q,s.tracks),z=q.at(-1)?.at;return z&&z.compare(A)>0&&A.copyFrom(z),{events:$.events,scoreMap:w,tracks:$.tracks,performanceDuration:A,durationSeconds:On($.events,A.toNumber()),diagnostics:n}}function pe(s){return s.pages.length>0?s.pages.map(t=>t.bounds):[s.bounds]}function xs(s,t){for(let e of s.attachments)e.layer==="background"&&e.paint(t);for(let e of s.objects){e.paint(t);for(let n of e.decorations)n.paint(t)}for(let e of s.attachments)e.layer==="foreground"&&e.paint(t)}var ms=class{pages;painters;constructor(t,e){this.pages=t,this.painters=e}route(t,e,n){let o=0,i=this.pages.length;for(;o<i;){let r=o+i>>>1,a=this.pages[r];a.y+a.h<t?o=r+1:i=r}for(let r=o;r<this.pages.length&&this.pages[r].y<=e;r++)n(this.painters[r])}drawText(t,e,n,o){this.route(n,n,i=>i.drawText(t,e,n,o))}drawLine(t,e,n,o,i){let r=(i?.strokeWidth??1)/2;this.route(Math.min(e,o)-r,Math.max(e,o)+r,a=>a.drawLine(t,e,n,o,i))}drawRect(t,e,n,o,i){let r=i?.stroke?(i.strokeWidth??1)/2:0;this.route(e-r,e+Math.max(0,o)+r,a=>{a.drawRect(t,e,n,o,i)})}drawCircle(t,e,n,o){let i=o?.stroke?(o.strokeWidth??1)/2:0,r=Math.max(0,n)+i;this.route(e-r,e+r,a=>a.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,i=1/0,r=-1/0,a=l=>{let f=o(l);i=Math.min(i,f),r=Math.max(r,f)};for(let l of t)l.op!=="Z"&&(l.op==="Q"&&a(l.cy),l.op==="C"&&(a(l.cy1),a(l.cy2)),a(l.y));if(!Number.isFinite(i))return;let c=e?.stroke?(e.strokeWidth??1)/2:0;this.route(i-c,r+c,l=>{l.drawPath(t,e,n)})}};function _e(s,t){let e=pe(s);if(t.length!==e.length)throw new Error(`Expected ${e.length} page painters, got ${t.length}`);xs(s,new ms(e,t))}var ys=class{commands=[];replay(t){for(let e of this.commands)switch(e.kind){case"text":t.drawText(e.text,e.x,e.y,e.style);break;case"line":t.drawLine(e.x1,e.y1,e.x2,e.y2,e.style);break;case"rect":t.drawRect(e.x,e.y,e.w,e.h,e.style);break;case"circle":t.drawCircle(e.cx,e.cy,e.r,e.style);break;case"path":t.drawPath(e.commands,e.style);break}}drawText(t,e,n,o){this.commands.push({kind:"text",text:t,x:e,y:n,style:o})}drawLine(t,e,n,o,i){this.commands.push({kind:"line",x1:t,y1:e,x2:n,y2:o,style:i})}drawRect(t,e,n,o,i){this.commands.push({kind:"rect",x:t,y:e,w:n,h:o,style:i})}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=>Xc(o,n)),style:e})}};function Xc(s,t){if(!t||s.op==="Z")return{...s};let e=o=>t.x+o*t.scaleX,n=o=>t.y+o*t.scaleY;return s.op==="M"||s.op==="L"?{op:s.op,x:e(s.x),y:n(s.y)}:s.op==="Q"?{op:"Q",cx:e(s.cx),cy:n(s.cy),x:e(s.x),y:n(s.y)}:s.op==="C"?{op:"C",cx1:e(s.cx1),cy1:n(s.cy1),cx2:e(s.cx2),cy2:n(s.cy2),x:e(s.x),y:n(s.y)}:{...s}}function nt(s){return Number.isFinite(s)?String(Math.round(s*1e3)/1e3):"0"}function Ot(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function qc(s,t){let e=[],n=t?i=>nt(t.x+i*t.scaleX):nt,o=t?i=>nt(t.y+i*t.scaleY):nt;for(let i of s){if(i.op==="Z"){e.push("Z");continue}if(i.op==="M"||i.op==="L"){e.push(`${i.op}${n(i.x)} ${o(i.y)}`);continue}if(i.op==="Q"){e.push(`Q${n(i.cx)} ${o(i.cy)} ${n(i.x)} ${o(i.y)}`);continue}"cx1"in i&&e.push(`C${n(i.cx1)} ${o(i.cy1)} ${n(i.cx2)} ${o(i.cy2)} ${n(i.x)} ${o(i.y)}`)}return e.join(" ")}function Ke(s){return s?.opacity===void 0?"":` opacity="${nt(s.opacity)}"`}var Pn=class{body=[];drawText(t,e,n,o){let i=o.fontFamily??ve,r=o.fontWeight??"normal",a=o.fill??"#000",c=o.textAlign==="center"?"middle":o.textAlign==="right"?"end":"start";this.body.push(`<text x="${nt(e)}" y="${nt(n)}" font-family="${Ot(i)}" font-size="${nt(o.fontSize)}" font-weight="${Ot(String(r))}" text-anchor="${c}" fill="${Ot(a)}" xml:space="preserve"${Ke(o)}>${Ot(t)}</text>`)}drawLine(t,e,n,o,i){let r=i?.stroke??i?.fill??"#000",a=i?.strokeWidth??1;this.body.push(`<line x1="${nt(t)}" y1="${nt(e)}" x2="${nt(n)}" y2="${nt(o)}" stroke="${Ot(r)}" stroke-width="${nt(a)}" stroke-linecap="round"${Ke(i)} />`)}drawRect(t,e,n,o,i){let r=i?.fill??"none",a=i?.stroke??"none",c=i?.strokeWidth??1;this.body.push(`<rect x="${nt(t)}" y="${nt(e)}" width="${nt(Math.max(0,n))}" height="${nt(Math.max(0,o))}" fill="${Ot(r)}" stroke="${Ot(a)}" stroke-width="${nt(c)}"${Ke(i)} />`)}drawCircle(t,e,n,o){let i=o?.fill??"#000",r=o?.stroke??"none",a=o?.strokeWidth??1;this.body.push(`<circle cx="${nt(t)}" cy="${nt(e)}" r="${nt(Math.max(0,n))}" fill="${Ot(i)}" stroke="${Ot(r)}" stroke-width="${nt(a)}"${Ke(o)} />`)}drawPath(t,e,n){if(t.length===0)return;let o=qc(t,n),i=e?.fill??"none",r=e?.stroke??"none",a=e?.strokeWidth??1;this.body.push(`<path d="${o}" fill="${Ot(i)}" stroke="${Ot(r)}" stroke-width="${nt(a)}" stroke-linecap="round" stroke-linejoin="round"${Ke(e)} />`)}toSvg(t,e={}){let n=Math.max(0,e.padding??0),o=t.x-n,i=t.y-n,r=Math.max(1,t.w+n*2),a=Math.max(1,t.h+n*2),c=e.background?`<rect x="${nt(o)}" y="${nt(i)}" width="${nt(r)}" height="${nt(a)}" fill="${Ot(e.background)}" />`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${nt(r)}" height="${nt(a)}" viewBox="${nt(o)} ${nt(i)} ${nt(r)} ${nt(a)}">${c}${this.body.join("")}</svg>`}};function Zc(s,t={}){let e=pe(s),n=e.map(()=>new Pn);return _e(s,n),n.map((o,i)=>o.toSvg(e[i],t))}function Qc(s,t,e=0,n=0,o=1,i=1){s.beginPath();for(let r of t){if(r.op==="Z"){s.closePath();continue}if(r.op==="M"){s.moveTo(e+r.x*o,n+r.y*i);continue}if(r.op==="L"){s.lineTo(e+r.x*o,n+r.y*i);continue}if(r.op==="Q"){s.quadraticCurveTo(e+r.cx*o,n+r.cy*i,e+r.x*o,n+r.y*i);continue}"cx1"in r&&s.bezierCurveTo(e+r.cx1*o,n+r.cy1*i,e+r.cx2*o,n+r.cy2*i,e+r.x*o,n+r.y*i)}}function Xe(s,t){t?.opacity!==void 0&&(s.globalAlpha*=t.opacity)}var Dn=class{context;constructor(t){this.context=t}drawText(t,e,n,o){this.context.save(),Xe(this.context,o),this.context.fillStyle=o.fill??"#000",this.context.font=dn(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,i){this.context.save(),Xe(this.context,i),this.context.beginPath(),this.context.moveTo(t,e),this.context.lineTo(n,o),this.context.strokeStyle=i?.stroke??i?.fill??"#000",this.context.lineWidth=i?.strokeWidth??1,this.context.lineCap="round",this.context.stroke(),this.context.restore()}drawRect(t,e,n,o,i){n<0||o<0||(this.context.save(),Xe(this.context,i),i?.fill&&(this.context.fillStyle=i.fill,this.context.fillRect(t,e,n,o)),i?.stroke&&(this.context.strokeStyle=i.stroke,this.context.lineWidth=i.strokeWidth??1,this.context.strokeRect(t,e,n,o)),this.context.restore())}drawCircle(t,e,n,o){n<0||(this.context.save(),Xe(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(),Xe(this.context,e),Qc(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 Jc(s,t){let e=pe(s);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{_e(s,t.map(n=>new Dn(n)))}finally{for(let n of t)n.restore()}}function gs(s,t,e){let n=0,o=s.length;for(;n<o;){let i=Math.floor((n+o)/2);e(s[i])<t?n=i+1:o=i}return n}function Or(s,t,e){let n=Math.max(1,Math.round(t/48)),o=[],i=[...e].sort((a,c)=>a-c);for(let a of s){let c=[...a.notes].sort((l,f)=>l.ticks-f.ticks);for(let l of[t/2,t,t*2]){let f=l/3,p=Math.min(n,f/8),u=l/2,d=new Set(c.map(h=>Math.round(h.ticks/u)*u).filter((h,x)=>Math.abs(c[x].ticks-h)<=p));for(let h of d){let x=h+l,g=gs(i,h,L=>L);for(;i[g]===h;)g++;if(i[g]<x)continue;let m=[0,1,2].map(L=>{let M=h+L*f,T=gs(c,M-p,b=>b.ticks),S=gs(c,M+p+1,b=>b.ticks);return c.slice(T,S).filter(b=>Math.abs(b.ticks-M)<=p&&Math.abs(b.durationTicks-f)<=p)});if(m.some(L=>L.length===0))continue;let y=m.map(L=>L.reduce((M,T)=>M+T.ticks,0)/L.length),w=y.reduce((L,M,T)=>L+Math.abs(M-(h+T*f)),0)/3,E=l/4,A=y.reduce((L,M)=>L+Math.abs(M-(h+Math.round((M-h)/E)*E)),0)/3;A-w>=p&&o.push({notes:m,start:h,span:l,advantage:A-w})}}}o.sort((a,c)=>c.advantage-a.advantage);let r=0;for(let a of o)if(!a.notes.some(c=>c.some(l=>l.triplet))){for(let c=0;c<3;c++)for(let l of a.notes[c])l.triplet={group:r,slot:c,startTicks:a.start,spanTicks:a.span};r++}return r>0}var tl={title:"size=2em, align=center",subtitle:"size=0.85em, align=center",author:"size=0.8em, align=right"};function Re(s,t){for(let e=t.length-1;e>=0;e--)s=`{${s} ^ ${t[e]}}`;return s}function Fn(s,t,e=""){if(t==="absolute")return s.octave===0?`@note(${s.name}, ${s.accidental}, 0)${e}`:`${s.name}${s.accidental}${s.octave}${e}`;let n=s.octave>0?"'".repeat(s.octave):",".repeat(-s.octave);return`${s.accidental}${s.name}${n}${e}`}function bs(s,t){return t.trim()!==t||/[\r\n%]/.test(t)||/^\s*[@{]/.test(t)||t.endsWith("\\")?`H.${s}: @text(${ht(t)}, ${tl[s]})`:`H.${s}: ${t}`}function Bn(s){let[t,e]=s.meter,n=[];return s.title&&n.push(bs("title",s.title)),s.subtitle&&n.push(bs("subtitle",s.subtitle)),s.author&&n.push(bs("author",s.author)),n.push(`H.signature: 1=${s.key} ${t}/${e}`),n.push(`H.tempo: ${s.tempo}`),n.join(`
123
+ `)}function zn(s){let t=Math.max(0,...s.map(e=>e.length));return Array.from({length:t},(e,n)=>s.map(o=>o[n]).filter(Boolean).join(`
121
124
  `)).join(`
122
125
 
123
- `)}var yc=120,gc=[4,4],bc=1.03,wc=1.25,Sc=4,Ac=8,Tc=["1","1#","2","2#","3","4","4#","5","5#","6","6#","7"],Lc=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];function Tt(s,t,e=0,n=Number.MAX_SAFE_INTEGER){if(!Number.isSafeInteger(s)||s<e||s>n)throw new RangeError(`${t} must be an integer in ${e}..${n}`)}function Ie(s,t){if(!Array.isArray(s))throw new TypeError(`${t} must be an array`)}function Cc(s,t,e){let n=1;for(;t*e>s*2**n;)n++;return n}function rr(s){let t=new Map;for(let e of s)t.set(e.at,e);return[...t.values()]}function ar(s,t,e){let n=s.length;for(s.push(t);n>0;){let o=n-1>>1;if(e(s[o],t)<=0)break;s[n]=s[o],n=o}s[n]=t}function cr(s,t){let e=s[0],n=s.pop();if(s.length===0)return e;let o=0;for(;;){let i=o*2+1;if(i>=s.length)break;let r=i+1,a=r<s.length&&t(s[r],s[i])<0?r:i;if(t(s[a],n)>=0)break;s[o]=s[a],o=a}return s[o]=n,e}function lr(s,t){let e=s%12,n=Math.floor(s/12)-1,o=t==="absolute"?Lc[e]:Tc[e];return wn({name:o[0],accidental:o.slice(1),octave:t==="absolute"?n:n-4},t)}function ns(s,t){return s.numerator*4*t/s.denominator}function pr(s,t){let e=0,n=s.length-1;for(;e<n;){let o=Math.ceil((e+n)/2);s[o].at<=t?e=o:n=o-1}return s[e]}function hr(s,t,e,n){let o=pr(e,s),i=ns(o,n),r=Math.max(0,Math.floor((s-o.at)/i)),a=o.at+r*i,c=n/2**t;return a+Math.round((s-a)/c)*c}function Ec(s,t){let e=new Map;for(let o of s)e.set(o.ticks,o);let n=[];for(let o of e.values()){let i=n.at(-1);if(!i){n.push(o);continue}let r=i.numerator*4*t/i.denominator,a=Math.max(0,Math.round((o.ticks-i.ticks)/r)),c={...o,ticks:i.ticks+a*r};c.ticks===i.ticks?n[n.length-1]=c:n.push(c)}return n}function vc(s,t,e){let n=[];for(let o=0;o<s.length;o++){let i=s[o],r=s[o+1]?.ticks??t,a=i.numerator*4*e/i.denominator;for(let c=i.ticks+a;c<r&&c<t;c+=a)n.push(c)}return n}function kc(s){let t=new Map;for(let n of s){let o=`${n.start}:${n.end}`,i=t.get(o);i?i.notes.push(n):t.set(o,{start:n.start,end:n.end,notes:[n],triplet:n.triplet})}let e=[...t.values()];for(let n of e)n.notes.sort((o,i)=>o.midi-i.midi);return e.sort((n,o)=>n.start-o.start||n.end-o.end)}function Mc(s){let t=new Map,e=[];for(let n of s)if(n.triplet){let o=t.get(n.triplet.group)??[];o.push(n),t.set(n.triplet.group,o)}else e.push(n);for(let n of t.values())n.sort((o,i)=>o.triplet.slot-i.triplet.slot),e.push({start:n[0].start,end:n.at(-1).end,members:n});return e.sort((n,o)=>n.start-o.start||n.end-o.end)}function Nc(s){let t=[],e=[],n=[],o=(a,c)=>a.end-c.end||a.laneIndex-c.laneIndex,i=(a,c)=>a-c;for(let a of s){for(;e.length>0&&e[0].end<=a.start;)ar(n,cr(e,o).laneIndex,i);let c=n.length>0?cr(n,i):t.length,l=t[c]??{items:[]};c===t.length&&t.push(l),l.items.push(a),ar(e,{end:a.end,laneIndex:c},o)}let r=a=>{let c=0,l=0;for(let h of a.items){let p="members"in h?h.members:[h];for(let u of p)for(let m of u.notes)c+=m.midi,l++}return c/l};return t.map(a=>({lane:a,averagePitch:r(a)})).sort((a,c)=>a.averagePitch-c.averagePitch).map(a=>a.lane)}function _c(s){let t=[],e=[],n=0,o=()=>{e.length!==0&&(t.push({start:e[0].start,end:n,lanes:Nc(e)}),e=[])};for(let i of s)e.length>0&&i.start>=n&&o(),e.push(i),n=Math.max(n,i.end);return o(),t}function Tn(s,t){let e=[],n=s,o=!0;for(;n>0;){let i=2**Math.floor(Math.log2(Math.min(n,t)));n-=i;let r=0;if(o&&n<t)for(let c=i/2;c>=1&&n>=c;c/=2)n-=c,r++;let a=Math.log2(t/i);e.push("/".repeat(a)+".".repeat(r)),o=!1}return e}function Ic(s,t,e,n){let i=`@page(width=${Math.max(1e6,s.length*64)}px, height=0px, top=0px, bottom=0px, left=0px, right=0px)
124
- ${s}`,r=n.compileScore(i).layout,a=Math.max(...r.objects.filter(y=>!y.T.isZero()).map(y=>y.layoutLine)),c=r.objects.filter(y=>y.layoutLine===a&&y.box.w>0),l=t.map(()=>({left:1/0,right:-1/0}));for(let y of c){let g=Math.round(y.t.toNumber()*e),d=0,x=t.length;for(;d<x;){let N=d+x>>>1,_=t[N];g<_||g===_&&y.mergeKey===n.anchorKey?x=N:d=N+1}let b=d;b>=t.length&&(b=t.length-1);let w=l[b];w.left=Math.min(w.left,y.box.x),w.right=Math.max(w.right,y.box.x+y.box.w)}let h=n.page.width-n.page.marginLeft-n.page.marginRight,p=h*bc,u=h*wc,m=[{imbalance:0,previous:-1}];for(let y=1;y<=t.length;y++){let g;for(let d=y-1;d>=Math.max(0,y-Ac);d--){let x=1/0,b=-1/0;for(let S=d;S<y;S++)x=Math.min(x,l[S].left),b=Math.max(b,l[S].right);let w=b-x;if(w>u&&d<y-1)continue;let N=m[d];if(!N)continue;let _=w-p,M={imbalance:N.imbalance+_**2*(w<h?Sc:1),previous:d};(!g||M.imbalance<g.imbalance)&&(g=M)}m[y]=g}let f=new Set;for(let y=t.length;m[y].previous>0;y=m[y].previous)f.add(t[m[y].previous-1]);return f}function Ln(s,t,e="",n){let o=i=>n?`@${n[i]}`:"";return s.notes.length===1?`${lr(s.notes[0].midi,t)}${e}${o(0)}`:`{${s.notes.map((i,r)=>`${lr(i.midi,t)}${r===0?e:""}${o(r)}`).join(" ^ ")}}`}function Rc(s,t,e,n,o,i,r,a,c,l,h){let p=new Set([t,e]);for(let b of s.items)p.add(b.start),p.add(b.end);for(let b of r)b>t&&b<e&&p.add(b);for(let b of c?.keys()??[])b>=t&&b<e&&p.add(b);for(let b of l?.keys()??[])b>=t&&b<e&&p.add(b);let u=[...p].sort((b,w)=>b-w),m=new Map(u.map((b,w)=>[b,w])),f=new Map,y=b=>b.map(w=>{let N=h();return w.push(N),N});for(let b of s.items){if("members"in b)continue;let w=m.get(b.start);for(let N=w;u[N]<b.end;N++){let _=Tn((u[N+1]-u[N])/o,n);if(u[N]>b.start&&r.has(u[N])||_.some((M,S)=>(u[N]>b.start||S>0)&&M.includes("/"))){f.set(b,b.notes.map(()=>[]));break}}}let g=Array.from({length:a.size+1},()=>[]),d=[...a].filter(b=>b<=t).length,x=0;for(let b=0;b<u.length;b++){let w=u[b];for(;x<s.items.length&&s.items[x].end<=w;)x++;w>t&&w<e&&r.has(w)&&g[d].push("|"),w>t&&w<e&&a.has(w)&&d++;let N=u[b+1];if(N===void 0)continue;let _=l?.get(w);_!==void 0&&g[d].push(`@program(${_})`);let M=c?.get(w)??[],S=s.items[x];if(S&&S.start<=w&&S.end>=N){if("members"in S&&w===S.start){let A=(S.members[0].end-S.members[0].start)*3/(2*o),C=Tn(A,n).join(""),I=S.members.map(O=>Ln(O,i,C)).join(" ");g[d].push(Pt(`@tuplet({${I}}, 2)`,M)),b=m.get(S.end)-1;continue}if("members"in S)throw new Error("MIDI triplet rendering must start at its first slot");let L=Tn((N-w)/o,n);for(let A=0;A<L.length;A++){let C=L[A],I=w>S.start||A>0,O,H=f.get(S);I?A===0&&r.has(w)||C.includes("/")?O=Ln(S,i,C,y(H)):O=`-${C}`:H?O=Ln(S,i,C,y(H)):O=Ln(S,i,C),A===0&&(O=Pt(O,M)),g[d].push(O),H&&N===S.end&&A===L.length-1&&g[d].push(...H.map(Y=>`@tie(${Y.join(", ")})`))}}else g[d].push(...Tn((N-w)/o,n).map((L,A)=>A===0?Pt(`0${L}`,M):`0${L}`))}return g.map(b=>b.join(" "))}function $c(s,t,e,n,o,i){let r=n.size+1,a=Array.from({length:r},()=>[]),c=[],l=0;for(let h of s.regions)l<h.start&&c.push({start:l,end:h.start,lanes:[{items:[]}]}),c.push(h),l=h.end;l<t&&c.push({start:l,end:t,lanes:[{items:[]}]});for(let h of c){if(h.start>0&&e.has(h.start)){let u=[...n].filter(m=>m<h.start).length;a[u].push("|")}let p=h.lanes.map(u=>o(h,u));for(let u=0;u<r;u++){if(!p.some(f=>f[u]))continue;let m=p.length===1?p[0][u]:`@stack(${p.map(f=>`{ ${f[u]} }`).join(", ")})`;a[u].push(m)}}return e.has(t)&&a[r-1].push("|"),a.map((h,p)=>`N${i&&p===0&&s.source.name?`(${ht(s.source.name)})`:""}: { ${h.join(" ")} }`)}function ur(s,t={},e){if(!s||typeof s!="object"||!s.header||typeof s.header!="object")throw new TypeError("MIDI JSON must contain a header");if(Ie(s.tracks,"tracks"),Ie(s.header.tempos,"header.tempos"),Ie(s.header.timeSignatures,"header.timeSignatures"),typeof s.header.name!="string")throw new TypeError("header.name must be a string");let n=s.header.tick;Tt(n,"header.tick",1,32767);let o=t.alignRate??4;Tt(o,"alignRate",2,16);let i=t.barsPerLine??0;if(!Number.isSafeInteger(i))throw new RangeError("barsPerLine must be an integer");let r=t.pitchMode??"absolute";if(r!=="relative"&&r!=="absolute")throw new TypeError("pitchMode must be relative or absolute");let a=t.title??s.header.name;if(typeof a!="string")throw new TypeError("title must be a string");let c=[],l=0,h=1;for(let[v,T]of s.tracks.entries()){if(!T||typeof T!="object"||typeof T.name!="string")throw new TypeError(`tracks[${v}] must contain a string name`);if(Tt(T.channel,`tracks[${v}].channel`,0,15),T.channel===9)continue;Ie(T.notes,`tracks[${v}].notes`),Ie(T.instruments,`tracks[${v}].instruments`);let B=T.instruments.map((R,$)=>(Tt(R.ticks,`tracks[${v}].instruments[${$}].ticks`),Tt(R.number,`tracks[${v}].instruments[${$}].number`,0,127),{...R})),E=T.notes.map((R,$)=>{Tt(R.ticks,`tracks[${v}].notes[${$}].ticks`),Tt(R.durationTicks,`tracks[${v}].notes[${$}].durationTicks`,1),Tt(R.midi,`tracks[${v}].notes[${$}].midi`,0,127),l=Math.max(l,R.ticks+R.durationTicks);let F=Cc(R.durationTicks,n,o);return h=Math.max(h,F),{...R,divisions:F}});E.length>0&&c.push({source:T,notes:E,programs:B})}let p=Ec([{ticks:0,timeSignature:gc},...s.header.timeSignatures].filter(v=>v.ticks===0||v.ticks<l).map((v,T)=>{Tt(v.ticks,`header.timeSignatures[${T}].ticks`);let[B,E]=v.timeSignature;Tt(B,`header.timeSignatures[${T}].numerator`,1,255),Tt(E,`header.timeSignatures[${T}].denominator`,1,32768);let R=Math.log2(E);if(!Number.isInteger(R))throw new RangeError("MIDI time-signature denominator must be a power of two");return h=Math.max(h,R-2),{ticks:v.ticks,numerator:B,denominator:E}}).sort((v,T)=>v.ticks-T.ticks),n),u=[{ticks:0,bpm:yc},...s.header.tempos.map((v,T)=>{if(Tt(v.ticks,`header.tempos[${T}].ticks`),!Number.isFinite(v.bpm)||v.bpm<=0)throw new RangeError(`header.tempos[${T}].bpm must be positive and finite`);return v})].filter(v=>v.ticks===0||v.ticks<l).sort((v,T)=>v.ticks-T.ticks),m=2**h,f=ir(c,n,[...p.slice(1).map(v=>v.ticks),...u.slice(1).map(v=>v.ticks),...c.flatMap(v=>v.programs.map(T=>T.ticks)),...vc(p,l,n)])?3:1,y=m*f,g=v=>{if(!Number.isSafeInteger(v*y))throw new RangeError("MIDI timeline is too large to quantize exactly");return v*y/n},d=v=>{if(!Number.isSafeInteger(v*m))throw new RangeError("MIDI timeline is too large to quantize exactly");return Math.round(v*m/n)*f},x=p.map(v=>({at:d(v.ticks),numerator:v.numerator,denominator:v.denominator})),b=[],w=new Map;for(let v of c)for(let T of v.notes)w.set(T.ticks,Math.max(w.get(T.ticks)??1,T.divisions));let N=0;for(let v of c){let T=v.notes.map(E=>{let R=E.triplet?Math.round(g(E.triplet.spanTicks)/3):0,$=E.triplet?Math.round(g(E.triplet.startTicks))+E.triplet.slot*R:hr(g(E.ticks),w.get(E.ticks),x,y),F=E.triplet?$+R:hr(g(E.ticks+E.durationTicks),E.divisions,x,y),W=y/2**E.divisions;return F<=$&&(F=$+W),N=Math.max(N,F),{...E,start:$,end:F}}),B=rr(v.programs.filter(E=>E.ticks===0||E.ticks<l).map(E=>({at:d(E.ticks),program:E.number})));b.push({source:v.source,regions:_c(Mc(kc(T))),programs:new Map(B.map(E=>[E.at,E.program]))})}let _=pr(x,N),M=ns(_,y),S=N===0?0:_.at+Math.ceil((N-_.at)/M)*M,L=rr(u.map(v=>({at:d(v.ticks),bpm:v.bpm}))).filter(v=>v.at===0||v.at<N),A=x.filter(v=>v.at===0||v.at<N),C=new Set;for(let v=0;v<A.length;v++){let T=A[v],B=A[v+1]?.at??S;T.at>0&&C.add(T.at);let E=ns(T,y);for(let R=T.at+E;R<=B&&R<=S;R+=E)C.add(R)}S>0&&C.add(S);let I=[...C].sort((v,T)=>v-T),O=new Map,H=(v,T)=>{let B=O.get(v)??[];B.push(T),O.set(v,B)};for(let v of A.slice(1))H(v.at,`@meter(${v.numerator}, ${v.denominator})`);for(let v of L.slice(1))H(v.at,`@tempo(${v.bpm})`);let Y=A[0],tt=Sn({title:a,key:"C4",meter:[Y.numerator,Y.denominator],tempo:L[0].bpm});if(b.length===0)return tt;let V=v=>{let T=0,B=b.map((E,R)=>$c(E,S,C,v,($,F)=>Rc(F,$.start,$.end,m,f,r,C,v,R===0&&F===$.lanes.at(-1)?O:void 0,E.programs,()=>`mt${T++}`),b.length>1));return`${tt}
126
+ `)}var el=120,nl=[4,4],ol=1.03,sl=1.25,il=4,rl=8,al=["1","1#","2","2#","3","4","4#","5","5#","6","6#","7"];function Pt(s,t,e=0,n=Number.MAX_SAFE_INTEGER){if(!Number.isSafeInteger(s)||s<e||s>n)throw new RangeError(`${t} must be an integer in ${e}..${n}`)}function qe(s,t){if(!Array.isArray(s))throw new TypeError(`${t} must be an array`)}function cl(s,t,e){let n=1;for(;t*e>s*2**n;)n++;return n}function ll(s){let t=new Map;for(let e of s)t.set(e.at,e);return[...t.values()]}function Pr(s,t,e){let n=s.length;for(s.push(t);n>0;){let o=n-1>>1;if(e(s[o],t)<=0)break;s[n]=s[o],n=o}s[n]=t}function Dr(s,t){let e=s[0],n=s.pop();if(s.length===0)return e;let o=0;for(;;){let i=o*2+1;if(i>=s.length)break;let r=i+1,a=r<s.length&&t(s[r],s[i])<0?r:i;if(t(s[a],n)>=0)break;s[o]=s[a],o=a}return s[o]=n,e}function Fr(s,t){let e=s%12,n=Math.floor(s/12)-1,o=t==="absolute"?Kt[e]:al[e];return Fn({name:o[0],accidental:o.slice(1),octave:t==="absolute"?n:n-4},t)}function ws(s,t){return s.numerator*4*t/s.denominator}function zr(s,t){let e=0,n=s.length-1;for(;e<n;){let o=Math.ceil((e+n)/2);s[o].at<=t?e=o:n=o-1}return s[e]}function Br(s,t,e,n){let o=zr(e,s),i=ws(o,n),r=Math.max(0,Math.floor((s-o.at)/i)),a=o.at+r*i,c=n/2**t;return a+Math.round((s-a)/c)*c}function fl(s,t){let e=new Map;for(let o of s)e.set(o.ticks,o);let n=[];for(let o of e.values()){let i=n.at(-1);if(!i){n.push(o);continue}let r=i.numerator*4*t/i.denominator,a=Math.max(0,Math.round((o.ticks-i.ticks)/r)),c={...o,ticks:i.ticks+a*r};c.ticks===i.ticks?n[n.length-1]=c:n.push(c)}return n}function pl(s,t,e){let n=[];for(let o=0;o<s.length;o++){let i=s[o],r=s[o+1]?.ticks??t,a=i.numerator*4*e/i.denominator;for(let c=i.ticks+a;c<r&&c<t;c+=a)n.push(c)}return n}function ul(s){let t=new Map;for(let n of s){let o=`${n.start}:${n.end}`,i=t.get(o);i?i.notes.push(n):t.set(o,{start:n.start,end:n.end,notes:[n],triplet:n.triplet})}let e=[...t.values()];for(let n of e)n.notes.sort((o,i)=>o.midi-i.midi);return e.sort((n,o)=>n.start-o.start||n.end-o.end)}function hl(s){let t=new Map,e=[];for(let n of s)if(n.triplet){let o=t.get(n.triplet.group)??[];o.push(n),t.set(n.triplet.group,o)}else e.push(n);for(let n of t.values())n.sort((o,i)=>o.triplet.slot-i.triplet.slot),e.push({start:n[0].start,end:n.at(-1).end,members:n});return e.sort((n,o)=>n.start-o.start||n.end-o.end)}function dl(s){let t=[],e=[],n=[],o=(a,c)=>a.end-c.end||a.laneIndex-c.laneIndex,i=(a,c)=>a-c;for(let a of s){for(;e.length>0&&e[0].end<=a.start;)Pr(n,Dr(e,o).laneIndex,i);let c=n.length>0?Dr(n,i):t.length,l=t[c]??{items:[]};c===t.length&&t.push(l),l.items.push(a),Pr(e,{end:a.end,laneIndex:c},o)}let r=a=>{let c=0,l=0;for(let f of a.items){let p="members"in f?f.members:[f];for(let u of p)for(let d of u.notes)c+=d.midi,l++}return c/l};return t.map(a=>({lane:a,averagePitch:r(a)})).sort((a,c)=>a.averagePitch-c.averagePitch).map(a=>a.lane)}function ml(s){let t=[],e=[],n=0,o=()=>{e.length!==0&&(t.push({start:e[0].start,end:n,lanes:dl(e)}),e=[])};for(let i of s)e.length>0&&i.start>=n&&o(),e.push(i),n=Math.max(n,i.end);return o(),t}function Hn(s,t){let e=[],n=s,o=!0;for(;n>0;){let i=2**Math.floor(Math.log2(Math.min(n,t)));n-=i;let r=0;if(o&&n<t)for(let c=i/2;c>=1&&n>=c;c/=2)n-=c,r++;let a=Math.log2(t/i);e.push("/".repeat(a)+".".repeat(r)),o=!1}return e}function xl(s,t,e,n){let i=`@page(width=${Math.max(1e6,s.length*64)}px, height=0px, top=0px, bottom=0px, left=0px, right=0px)
127
+ ${s}`,r=n.compileScore(i).layout,a=Math.max(...r.objects.filter(x=>!x.T.isZero()).map(x=>x.layoutLine)),c=r.objects.filter(x=>x.layoutLine===a&&x.box.w>0),l=t.map(()=>({left:1/0,right:-1/0}));for(let x of c){let g=Math.round(x.t.toNumber()*e),m=0,y=t.length;for(;m<y;){let A=m+y>>>1,L=t[A];g<L||g===L&&x.mergeKey===n.anchorKey?y=A:m=A+1}let w=m;w>=t.length&&(w=t.length-1);let E=l[w];E.left=Math.min(E.left,x.box.x),E.right=Math.max(E.right,x.box.x+x.box.w)}let f=n.page.width-n.page.marginLeft-n.page.marginRight,p=f*ol,u=f*sl,d=[{imbalance:0,previous:-1}];for(let x=1;x<=t.length;x++){let g;for(let m=x-1;m>=Math.max(0,x-rl);m--){let y=1/0,w=-1/0;for(let T=m;T<x;T++)y=Math.min(y,l[T].left),w=Math.max(w,l[T].right);let E=w-y;if(E>u&&m<x-1)continue;let A=d[m];if(!A)continue;let L=E-p,M={imbalance:A.imbalance+L**2*(E<f?il:1),previous:m};(!g||M.imbalance<g.imbalance)&&(g=M)}d[x]=g}let h=new Set;for(let x=t.length;d[x].previous>0;x=d[x].previous)h.add(t[d[x].previous-1]);return h}function Wn(s,t,e="",n){let o=i=>n?`@${n[i]}`:"";return s.notes.length===1?`${Fr(s.notes[0].midi,t)}${e}${o(0)}`:`{${s.notes.map((i,r)=>`${Fr(i.midi,t)}${r===0?e:""}${o(r)}`).join(" ^ ")}}`}function yl(s,t,e,n,o,i,r,a,c,l,f){let p=new Set([t,e]);for(let A of s.items)p.add(A.start),p.add(A.end);for(let A of r)A>t&&A<e&&p.add(A);for(let A of c?.keys()??[])A>=t&&A<e&&p.add(A);for(let A of l.keys())A>=t&&A<e&&p.add(A);let u=[...p].sort((A,L)=>A-L),d=new Map(u.map((A,L)=>[A,L])),h=new Map,x=A=>A.map(L=>{let M=f();return L.push(M),M});for(let A of s.items){if("members"in A)continue;let L=d.get(A.start);for(let M=L;u[M]<A.end;M++){let T=Hn((u[M+1]-u[M])/o,n);if(u[M]>A.start&&r.has(u[M])||T.some((S,b)=>(u[M]>A.start||b>0)&&S.includes("/"))){h.set(A,A.notes.map(()=>[]));break}}}let g=Array.from({length:a.size+1},()=>[]),m=[...a].filter(A=>A<=t).length,y=0,w=l.size?0:void 0,E=-1/0;for(let[A,L]of l)A<=t&&A>=E&&(w=L,E=A);for(let A=0;A<u.length;A++){let L=u[A];for(;y<s.items.length&&s.items[y].end<=L;)y++;L>t&&L<e&&r.has(L)&&g[m].push("|"),L>t&&L<e&&a.has(L)&&m++;let M=u[A+1];if(M===void 0)continue;let T=L===t?w:l.get(L);T!==void 0&&g[m].push(`@program(${T})`);let S=c?.get(L)??[],b=s.items[y];if(b&&b.start<=L&&b.end>=M){if("members"in b&&L===b.start){let _=(b.members[0].end-b.members[0].start)*3/(2*o),I=Hn(_,n).join(""),K=b.members.map(H=>Wn(H,i,I)).join(" ");g[m].push(Re(`@tuplet({${K}}, 2)`,S)),A=d.get(b.end)-1;continue}if("members"in b)throw new Error("MIDI triplet rendering must start at its first slot");let v=Hn((M-L)/o,n);for(let _=0;_<v.length;_++){let I=v[_],K=L>b.start||_>0,H,B=h.get(b);K?_===0&&r.has(L)||I.includes("/")?H=Wn(b,i,I,x(B)):H=`-${I}`:B?H=Wn(b,i,I,x(B)):H=Wn(b,i,I),_===0&&(H=Re(H,S)),g[m].push(H),B&&M===b.end&&_===v.length-1&&g[m].push(...B.map(G=>`@tie(${G.join(", ")})`))}}else g[m].push(...Hn((M-L)/o,n).map((v,_)=>_===0?Re(`0${v}`,S):`0${v}`))}return g.map(A=>A.join(" "))}function gl(s,t,e,n,o,i){let r=n.size+1,a=Array.from({length:r},()=>[]),c=[],l=0;for(let f of s.regions)l<f.start&&c.push({start:l,end:f.start,lanes:[{items:[]}]}),c.push(f),l=f.end;l<t&&c.push({start:l,end:t,lanes:[{items:[]}]});for(let f of c){if(f.start>0&&e.has(f.start)){let u=[...n].filter(d=>d<f.start).length;a[u].push("|")}let p=f.lanes.map(u=>o(f,u));for(let u=0;u<r;u++){if(!p.some(h=>h[u]))continue;let d=p.length===1?p[0][u]:`@stack(${p.map(h=>`{ ${h[u]} }`).join(", ")})`;a[u].push(d)}}return e.has(t)&&a[r-1].push("|"),a.map((f,p)=>`N${i&&p===0&&s.source.name?`(${ht(s.source.name)})`:""}: { ${f.join(" ")} }`)}function Hr(s,t={},e){if(!s||typeof s!="object"||!s.header||typeof s.header!="object")throw new TypeError("MIDI JSON must contain a header");if(qe(s.tracks,"tracks"),qe(s.header.tempos,"header.tempos"),qe(s.header.timeSignatures,"header.timeSignatures"),typeof s.header.name!="string")throw new TypeError("header.name must be a string");let n=s.header.tick;Pt(n,"header.tick",1,32767);let o=t.alignRate??4;Pt(o,"alignRate",2,16);let i=t.barsPerLine??0;if(!Number.isSafeInteger(i))throw new RangeError("barsPerLine must be an integer");let r=t.pitchMode??"absolute";if(r!=="relative"&&r!=="absolute")throw new TypeError("pitchMode must be relative or absolute");let a=t.title??s.header.name;if(typeof a!="string")throw new TypeError("title must be a string");let c=[],l=0,f=1;for(let[N,P]of s.tracks.entries()){if(!P||typeof P!="object"||typeof P.name!="string")throw new TypeError(`tracks[${N}] must contain a string name`);if(Pt(P.channel,`tracks[${N}].channel`,0,15),P.channel===9)continue;qe(P.notes,`tracks[${N}].notes`),qe(P.instruments,`tracks[${N}].instruments`);let V=P.instruments.map(($,z)=>(Pt($.ticks,`tracks[${N}].instruments[${z}].ticks`),Pt($.number,`tracks[${N}].instruments[${z}].number`,0,127),{...$})),q=P.notes.map(($,z)=>{Pt($.ticks,`tracks[${N}].notes[${z}].ticks`),Pt($.durationTicks,`tracks[${N}].notes[${z}].durationTicks`,1),Pt($.midi,`tracks[${N}].notes[${z}].midi`,0,127),l=Math.max(l,$.ticks+$.durationTicks);let C=cl($.durationTicks,n,o);return f=Math.max(f,C),{...$,divisions:C}});q.length>0&&c.push({source:P,notes:q,programs:V})}let p=fl([{ticks:0,timeSignature:nl},...s.header.timeSignatures].filter(N=>N.ticks===0||N.ticks<l).map((N,P)=>{Pt(N.ticks,`header.timeSignatures[${P}].ticks`);let[V,q]=N.timeSignature;Pt(V,`header.timeSignatures[${P}].numerator`,1,255),Pt(q,`header.timeSignatures[${P}].denominator`,1,32768);let $=Math.log2(q);if(!Number.isInteger($))throw new RangeError("MIDI time-signature denominator must be a power of two");return f=Math.max(f,$-2),{ticks:N.ticks,numerator:V,denominator:q}}).sort((N,P)=>N.ticks-P.ticks),n),u=[{ticks:0,bpm:el},...s.header.tempos.map((N,P)=>{if(Pt(N.ticks,`header.tempos[${P}].ticks`),!Number.isFinite(N.bpm)||N.bpm<=0)throw new RangeError(`header.tempos[${P}].bpm must be positive and finite`);return N})].filter(N=>N.ticks===0||N.ticks<l).sort((N,P)=>N.ticks-P.ticks),d=2**f,h=Or(c,n,[...p.slice(1).map(N=>N.ticks),...u.slice(1).map(N=>N.ticks),...c.flatMap(N=>N.programs.map(P=>P.ticks)),...pl(p,l,n)])?3:1,x=d*h,g=N=>{if(!Number.isSafeInteger(N*x))throw new RangeError("MIDI timeline is too large to quantize exactly");return N*x/n},m=N=>{if(!Number.isSafeInteger(N*d))throw new RangeError("MIDI timeline is too large to quantize exactly");return Math.round(N*d/n)*h},y=p.map(N=>({at:m(N.ticks),numerator:N.numerator,denominator:N.denominator})),w=[],E=new Map;for(let N of c)for(let P of N.notes)E.set(P.ticks,Math.max(E.get(P.ticks)??1,P.divisions));let A=0;for(let N of c){let P=N.notes.map(V=>{let q=V.triplet?Math.round(g(V.triplet.spanTicks)/3):0,$=V.triplet?Math.round(g(V.triplet.startTicks))+V.triplet.slot*q:Br(g(V.ticks),E.get(V.ticks),y,x),z=V.triplet?$+q:Br(g(V.ticks+V.durationTicks),V.divisions,y,x),C=x/2**V.divisions;return z<=$&&(z=$+C),A=Math.max(A,z),{...V,start:$,end:z}});w.push({source:N.source,regions:ml(hl(ul(P))),programs:new Map(N.programs.filter(V=>V.ticks===0||V.ticks<l).map(V=>[m(V.ticks),V.number]))})}let L=zr(y,A),M=ws(L,x),T=A===0?0:L.at+Math.ceil((A-L.at)/M)*M,S=ll(u.map(N=>({at:m(N.ticks),bpm:N.bpm}))).filter(N=>N.at===0||N.at<A),b=y.filter(N=>N.at===0||N.at<A),v=new Set;for(let N=0;N<b.length;N++){let P=b[N],V=b[N+1]?.at??T;P.at>0&&v.add(P.at);let q=ws(P,x);for(let $=P.at+q;$<=V&&$<=T;$+=q)v.add($)}T>0&&v.add(T);let _=[...v].sort((N,P)=>N-P),I=new Map,K=(N,P)=>{let V=I.get(N)??[];V.push(P),I.set(N,V)};for(let N of b.slice(1))K(N.at,`@meter(${N.numerator}, ${N.denominator})`);for(let N of S.slice(1))K(N.at,`@tempo(${N.bpm})`);let H=b[0],B=Bn({title:a,key:"C4",meter:[H.numerator,H.denominator],tempo:S[0].bpm});if(w.length===0)return B;let G=N=>{let P=0,V=w.map((q,$)=>gl(q,T,v,N,(z,C)=>yl(C,z.start,z.end,d,h,r,v,N,$===0&&C===z.lanes.at(-1)?I:void 0,q.programs,()=>`mt${P++}`),w.length>1));return`${B}
125
128
 
126
- ${An(B)}`},q=i<=0?Ic(V(new Set),I,y,e):new Set(I.filter((v,T)=>(T+1)%i===0&&v<S));return V(q)}function Oc(s,t={}){return ur(s,t,{compileScore:Ko,anchorKey:ot,page:xt})}function St(s){return s.localName||s.tagName.split(":").at(-1)}function ct(s,t){let e=[];for(let n=0;n<s.childNodes.length;n++){let o=s.childNodes[n];if(o.nodeType!==1)continue;let i=o;(t===void 0||St(i)===t)&&e.push(i)}return e}function Z(s,t){for(let e=0;e<s.childNodes.length;e++){let n=s.childNodes[e];if(n.nodeType===1&&St(n)===t)return n}}function ue(s,t){for(let e of ct(s)){if(St(e)===t)return e;let n=ue(e,t);if(n)return n}}function os(s,t){let e=[];for(let n of ct(s))St(n)===t&&e.push(n),e.push(...os(n,t));return e}function st(s,t){return(t===void 0?s:s&&Z(s,t))?.textContent?.trim()??""}function pt(s,t,e){let n=st(s,t);if(n===""){if(e!==void 0)return e;throw new RangeError(`MusicXML <${t}> must contain a finite number`)}let o=Number(n);if(Number.isFinite(o))return o;throw new RangeError(`MusicXML <${t}> must contain a finite number`)}var Pc=new Set(["ppp","pp","p","mp","mf","f","ff","fff"]),fr=256;function ss(s,t){let e=s.getAttribute("placement");return e==="above"||e==="below"?e:t}function dr(s){let t=new Map,e=St(s);if(e==="score-partwise"){for(let n of ct(s,"part"))t.set(n.getAttribute("id")??"",ct(n,"measure").map(o=>({body:o,container:o})));return t}if(e==="score-timewise"){for(let n of ct(s,"measure"))for(let o of ct(n,"part")){let i=o.getAttribute("id")??"",r=t.get(i)??[];r.push({body:o,container:n}),t.set(i,r)}return t}throw new TypeError(`Unsupported MusicXML root <${e}>`)}function mr(s){let t=Z(s,"pitch"),e=t??Z(s,"unpitched");if(!e)return null;let n=st(e,t?"step":"display-step").toUpperCase(),o=t?pt(e,"alter",0):0,i=pt(e,t?"octave":"display-octave");if(!/^[A-G]$/.test(n)||!Number.isInteger(o)||!Number.isInteger(i))throw new RangeError("jpFun requires MusicXML pitches with integer step alterations and octaves");let r=new Set;for(let c of ct(s,"tie"))r.add(c.getAttribute("type")??"");let a=Z(s,"notations");if(a)for(let c of ct(a,"tied"))r.add(c.getAttribute("type")??"");return{step:n,alter:o,octave:i,tieStart:r.has("start")||r.has("continue"),tieStop:r.has("stop")||r.has("continue")}}function xr(s){let t=[],e=Z(s,"notations");if(!e)return t;let n=Z(e,"fermata");n&&t.push({name:"fermata",placement:ss(n,n.getAttribute("type")==="inverted"?"below":"above")});let o=Z(e,"articulations"),i=o&&Z(o,"accent");i&&t.push({name:"accent",placement:ss(i,"above")});let r=Z(e,"ornaments");if(r){let a=[["trill-mark","tr"],["mordent","mordent"],["inverted-mordent","prall"]];for(let[c,l]of a){let h=Z(r,c);h&&t.push({name:l,placement:ss(h,"above")})}}return t}function is(s,t){if(!t||t==="none")return s??t;if(s&&s!=="none"&&s!==t)throw new RangeError("Conflicting MusicXML arpeggiate directions in one chord");return t}function yr(s){let t=Z(s,"notations");if(!t)return;let e;for(let n of ct(t,"arpeggiate")){let o=n.getAttribute("direction"),i=o===null||o===""?"none":o;if(i!=="none"&&i!=="up"&&i!=="down")throw new RangeError(`Unsupported MusicXML arpeggiate direction: ${i}`);e=is(e,i)}return e}function gr(s){let t=Z(s,"time-modification");if(!t)return;let e=pt(t,"actual-notes"),n=pt(t,"normal-notes");if(!Number.isSafeInteger(e)||e<2||!Number.isSafeInteger(n)||n<=0)throw new RangeError("MusicXML time-modification requires positive integer actual-notes and normal-notes");let o=Z(s,"notations"),i=o?ct(o,"tuplet"):[];return{actual:e,normal:n,start:i.some(r=>r.getAttribute("type")==="start"),stop:i.some(r=>r.getAttribute("type")==="stop")}}function br(s){let t=new Map;for(let e of ct(s,"lyric")){let n=e.getAttribute("number")||e.getAttribute("name")||"1",o=ct(e).filter(r=>["text","elision"].includes(St(r))).map(r=>St(r)==="elision"?"~":st(r)).join(""),i=st(e,"syllabic");t.set(n,o&&(i==="begin"||i==="middle")?`${o}-`:o)}return t}function wr(s){let t=ue(s,"dynamics");if(t)return ct(t).map(St).find(e=>Pc.has(e))}function Sr(s){let t=[];for(let e of["rehearsal","words"])for(let n of os(s,e)){let o=n.textContent?.trim();o&&t.push({text:o,boxed:e==="rehearsal"})}return t}function Ar(s){let t=ue(s,"metronome");if(!t)return;let e=Number(st(t,"per-minute")),n=st(t,"beat-unit"),i={maxima:32,long:16,breve:8,whole:4,half:2,quarter:1,eighth:.5,"16th":.25,"32nd":.125,"64th":.0625,"128th":.03125,"256th":.015625,"512th":.0078125,"1024th":.00390625}[n];if(!Number.isFinite(e)||i===void 0)return;let r=i/2;for(let a of ct(t,"beat-unit-dot"))i+=r,r/=2;return e*i}function Tr(s){let t=[],e;for(let r of ct(s)){let a=St(r);a==="beats"?e=st(r).split("+").reduce((c,l)=>c+Number(l),0):a==="beat-type"&&e!==void 0&&(t.push({beats:e,beatType:Number(st(r))}),e=void 0)}if(t.length===0||t.some(r=>!Number.isSafeInteger(r.beats)||r.beats<=0||!Number.isSafeInteger(r.beatType)||r.beatType<=0))throw new RangeError("MusicXML time signature must contain positive integer beats/beat-type pairs");let n=(r,a)=>a===0?r:n(a,r%a),o=t.reduce((r,a)=>r/n(r,a.beatType)*a.beatType,1),i=t.reduce((r,a)=>r+a.beats*o/a.beatType,0);if(!Number.isSafeInteger(i)||!Number.isSafeInteger(o))throw new RangeError("MusicXML time signature exceeds the supported integer range");return{numerator:i,denominator:o}}function Lr(s){let t=new Set;for(let e of s.split(/\s*,\s*/)){let n=e.match(/^(\d+)(?:\s*-\s*(\d+))?$/);if(!n)throw new RangeError("MusicXML ending number must contain positive integers or ascending ranges");let o=Number(n[1]),i=Number(n[2]??n[1]);if(!Number.isSafeInteger(o)||!Number.isSafeInteger(i)||o<1||i<o||i>fr)throw new RangeError(`MusicXML ending passes must be ascending integers in 1..${fr}`);for(let r=o;r<=i;r++)t.add(r)}return[...t].sort((e,n)=>e-n)}var Cr=["Cb","Gb","Db","Ab","Eb","Bb","F","C","G","D","A","E","B","F#","C#"],Dc=["Ab","Eb","Bb","F","C","G","D","A","E","B","F#","C#","G#","D#","A#"],Er=["1","1#","2","2#","3","4","4#","5","5#","6","6#","7"];function dt(s,t){return s.clone().add(t)}function lt(s){return s.toString()}function rs(s){let[t,e="1"]=s.split("/");return new z(Number(t),Number(e))}function Xt(s,t,e){let n=0,o=s.length;for(;n<o;){let i=n+o>>1;e(s[i]).compare(t)<0?n=i+1:o=i}return n}function as(s,t){let e=s[Xt(s,t,n=>n.start)-1];return!!e&&e.end.compare(t)>0}function Fc(s){let t=s.endsWith("-"),e=t?s.slice(0,-1):s,n=e.replace(/[\\{}@-]/g,"\\$&")+(t?"-":""),o=[...e].some(i=>i.codePointAt(0)>127);return/\s/.test(e)||o&&([...e].length>1||e.length>1||t)?`{${n}}`:n}function Re(s,t,e){let n=lt(t),o=s.get(n);if(!o||o==="|"){s.set(n,e);return}o==="|:"&&e.startsWith(":|")?s.set(n,e===":|"?":|:":`${e} |:`):e==="|:"&&o.includes(":|")?s.set(n,o===":|"?":|:":`${o} |:`):e==="||"&&!o.includes("|:")&&!o.includes(":|")&&s.set(n,e)}function Bc(s){let t=new Map,e=new Map,n=Z(s,"part-list");if(n)for(let T of ct(n,"score-part")){let B=T.getAttribute("id")??"";t.set(B,st(T,"part-name"));let E=new Map,R;for(let $ of ct(T,"midi-instrument")){let F=st($,"midi-channel"),W=st($,"midi-program"),X=F===""?void 0:Number(F),K=W===""?void 0:Number(W)-1;if(X!==void 0&&(!Number.isSafeInteger(X)||X<1||X>16))throw new RangeError("MusicXML midi-channel must be an integer in 1..16");if(K!==void 0&&(!Number.isSafeInteger(K)||K<0||K>127))throw new RangeError("MusicXML midi-program must be an integer in 1..128");let kt={channel:X,program:K};R??=kt,E.set($.getAttribute("id")??"",kt)}e.set(B,{fallback:R,byId:E})}let o=ct(s,"credit"),i=T=>{let B=o.find(E=>st(E,"credit-type")===T);return B?st(B,"credit-words"):""},r=st(Z(s,"work"),"work-title"),a=st(s,"movement-title")||(r!=="Untitled Score"&&r!=="\u672A\u547D\u540D\u4E50\u8C31"?r:"")||i("title"),c=i("subtitle"),l=i("composer")||(()=>{let T=Z(s,"identification"),B=T?ct(T,"creator"):[];return st(B.find(E=>E.getAttribute("type")==="composer")??B[0])})(),h,p=Z(s,"defaults"),u=p&&Z(p,"scaling"),m=p&&Z(p,"page-layout");if(u&&m&&Z(m,"page-width")&&Z(m,"page-height")){let T=pt(u,"millimeters"),B=pt(u,"tenths"),E=T/B*96/25.4,R=ct(m,"page-margins"),$=R.find(F=>F.getAttribute("type")==="odd")??R[0];Number.isFinite(E)&&E>0&&(h={width:pt(m,"page-width")*E,height:pt(m,"page-height")*E,top:$?pt($,"top-margin",48/E)*E:48,bottom:$?pt($,"bottom-margin",48/E)*E:48,left:$?pt($,"left-margin",40/E)*E:40,right:$?pt($,"right-margin",40/E)*E:40})}let f=new Map,y=new Map,g=new Map,d=new Map,x=[],b=[],w=new Map,N=new Map,_=new Set,M=new Set,S=new z,L=0,A=dr(s),C=new Map([...A.keys()].map((T,B)=>[T,B])),I=A.keys().next().value,O=[];for(let[T,B]of A){let E=e.get(T),R=1,$=new z,F={numerator:4,denominator:4},W=new Map,X=new Map;for(let K=0;K<B.length;K++){let{body:kt,container:gt}=B[K],et=new z,mt=new z;gt.getAttribute("implicit")!=="yes"&&K>0&&(Re(N,$,"|"),T===I&&_.add(lt($)));let Zt=Z(kt,"print")??(gt===kt?void 0:Z(gt,"print"));(Zt?.getAttribute("new-system")==="yes"||Zt?.getAttribute("new-page")==="yes")&&($.isZero()||M.add(lt($)));let $e=ct(kt),fe=(j,ut)=>{let qt=Z(j,"repeat"),de=qt?.getAttribute("direction");if(de==="forward")Re(N,ut,"|:");else if(de==="backward"){let Mt=qt?.getAttribute("times"),Dt=Mt?Number(Mt):2;if(!Number.isSafeInteger(Dt)||Dt<2)throw new RangeError("MusicXML repeat times must be an integer of at least 2");Re(N,ut,new Array(Dt-1).fill(":|").join(" "))}else st(j,"bar-style")==="light-heavy"&&Re(N,ut,"||");let Qt=Z(j,"ending"),bt=Qt?.getAttribute("type");if(Qt&&(bt==="start"||bt==="stop"||bt==="discontinue")){let Mt=Lr(Qt.getAttribute("number")??"");Mt.length>0&&w.set(`${lt(ut)}\0${bt}\0${Mt.join(",")}`,{at:ut.clone(),type:bt,passes:Mt})}};for(let j of $e){let ut=St(j);if(ut==="attributes"){let nt=dt($,et);if(Z(j,"divisions")&&(R=pt(j,"divisions")),!Number.isSafeInteger(R)||R<=0)throw new RangeError("MusicXML divisions must be a positive integer");let it=Z(j,"time");if(it){let{numerator:vt,denominator:Ft}=Tr(it);F={numerator:vt,denominator:Ft},y.set(lt(nt),{at:nt,numerator:vt,denominator:Ft})}let Fe=Z(j,"key");if(Fe){let vt=pt(Fe,"fifths",0);if(!Number.isSafeInteger(vt))throw new RangeError("MusicXML fifths must be an integer");g.set(lt(nt),{at:nt,fifths:vt,mode:st(Fe,"mode")||"major"})}continue}if(ut==="backup"||ut==="forward"){let nt=new z(pt(j,"duration"),R);if(ut==="backup"?et.sub(nt):et.add(nt),et.compare(0)<0)throw new RangeError("MusicXML backup moves before the measure start");mt=mt.compare(et)<0?et.clone():mt;continue}if(ut==="direction"){let nt=new z(pt(j,"offset",0),R),it=dt(dt($,et),nt),vt=Z(j,"sound")?.getAttribute("tempo"),Ft=vt!=null&&vt!==""?Number(vt):Ar(j);if(Ft!==void 0){if(!Number.isFinite(Ft)||Ft<=0)throw new RangeError("MusicXML tempo must be positive and finite");d.set(lt(it),{at:it,bpm:Ft})}let gs=wr(j),bs=Sr(j);(gs||bs.length>0)&&x.push({at:it,partId:T,staff:st(j,"staff")||"1",voice:st(j,"voice")||"",placement:j.getAttribute("placement")==="below"?"below":"above",dynamic:gs,texts:bs});let ws=ue(j,"wedge"),Be=ws?.getAttribute("type");(Be==="crescendo"||Be==="diminuendo"||Be==="stop")&&b.push({at:it,partId:T,staff:st(j,"staff")||"1",voice:st(j,"voice")||"",number:ws?.getAttribute("number")||"1",type:Be});continue}let qt=ut==="sound"?j.getAttribute("tempo"):null;if(qt!==null&&qt!==""){let nt=Number(qt);if(!Number.isFinite(nt)||nt<=0)throw new RangeError("MusicXML tempo must be positive and finite");let it=dt($,et);d.set(lt(it),{at:it,bpm:nt});continue}if(ut==="barline"&&j.getAttribute("location")==="middle"){fe(j,dt($,et));continue}if(ut!=="note")continue;let de=st(j,"voice")||"1",Qt=st(j,"staff")||"1",bt=`${T}\0${Qt}\0${de}`,Mt=Z(j,"instrument")?.getAttribute("id")??"",Dt=Mt?E?.byId.get(Mt):E?.fallback,Rt=mr(j),fs=Z(j,"rest")!==void 0;if(!Rt&&!fs)throw new TypeError("MusicXML note must contain pitch, unpitched, or rest");let Jt=Z(j,"chord")!==void 0,vn=Z(j,"grace");if(Dt?.channel===10){if(vn)continue;let nt=new z(pt(j,"duration"),R);if(nt.compare(0)<=0)throw new RangeError("MusicXML non-grace notes require a positive duration");Jt||et.add(nt),mt.compare(et)<0&&(mt=et.clone());continue}let Pe=f.get(bt);Pe||(Pe={partId:T,partName:t.get(T)??T,staff:Qt,voice:de,events:[]},f.set(bt,Pe));let De=W.get(bt);if(vn){if(!Rt)continue;let nt=vn.getAttribute("steal-time-previous");if(nt!==null&&nt!==""&&De){let it=De.postGraces;Jt&&it.length>0?it.at(-1).push(Rt):it.push([Rt])}else{let it=X.get(bt)??[];Jt&&it.length>0?it.at(-1).push(Rt):it.push([Rt]),X.set(bt,it)}continue}let me=new z(pt(j,"duration"),R);if(me.compare(0)<=0)throw new RangeError("MusicXML non-grace notes require a positive duration");let kn=Jt?De?.start.clone()??dt($,et):dt($,et),yt=Jt?De:void 0,ds=br(j),ms=xr(j),xs=yr(j);if(!yt||!yt.start.equals(kn)||!yt.duration.equals(me)||yt.rest)yt={start:kn,duration:me,pitches:[],rest:fs,order:L++,modifiers:ms,annotations:[],preGraces:X.get(bt)??[],postGraces:[],lyrics:ds,arpeggio:xs,program:Dt?.program,timeModification:gr(j)},X.delete(bt),Pe.events.push(yt),W.set(bt,yt);else{yt.program??=Dt?.program,yt.arpeggio=is(yt.arpeggio,xs);for(let nt of ms)yt.modifiers.some(it=>it.name===nt.name&&it.placement===nt.placement)||yt.modifiers.push(nt)}Rt&&yt.pitches.push(Rt);for(let[nt,it]of ds)it&&!yt.lyrics.has(nt)&&yt.lyrics.set(nt,it);Jt||et.add(me);let ys=dt(kn,me).sub($);mt.compare(ys)<0&&(mt=ys)}let En=new z(F.numerator*4,F.denominator),us=gt.getAttribute("implicit")==="yes"||K===0&&mt.compare(En)<0||mt.compare(En)>0?mt:En,Oe=us;if(T===I)O[K]=us.clone();else if(O[K]&&(Oe=O[K].clone(),mt.compare(Oe)>0))throw new RangeError(`MusicXML part ${T} exceeds the controlling measure duration`);let _r=dt($,Oe);for(let j of $e.filter(ut=>St(ut)==="barline")){let ut=j.getAttribute("location");ut!=="middle"&&fe(j,ut==="left"?$:_r)}$.add(Oe),S.compare($)<0&&(S=$.clone())}Re(N,$,"||")}let H=[...f.values()],Y=[],tt=new Map;for(let T of b.sort((B,E)=>B.at.compare(E.at))){let B=`${T.partId}\0${T.staff}\0${T.voice}\0${T.number}`;if(T.type==="stop"){let E=tt.get(B);E&&Y.push({from:E,end:T.at}),tt.delete(B)}else tt.set(B,T)}let V=[],q;for(let T of[...w.values()].sort((B,E)=>B.at.compare(E.at)))T.type==="start"?q=T:q&&(V.push({from:q,end:T.at}),q=void 0);V.length>0&&H.length===0&&I!==void 0&&H.push({partId:I,partName:t.get(I)??I,staff:"1",voice:"1",events:[]});let v=H[0];if(v)for(let T of V){if(T.from.at.compare(T.end)>=0)continue;let B=x.find(W=>W.at.compare(T.from.at)>=0&&W.at.compare(T.end)<0),E=B?.partId??v.partId,R=B?.staff??v.staff,$=H.filter(W=>W.partId===E&&W.staff===R);if(!$.some(W=>W.events.some(X=>X.start.compare(T.from.at)>=0&&X.start.compare(T.end)<0))){let W=$.find(X=>!X.events.some(K=>K.start.compare(T.end)<0&&dt(K.start,K.duration).compare(T.from.at)>0));if(!W){let X=$.map(K=>Number(K.voice)).filter(Number.isFinite);W={partId:E,partName:t.get(E)??E,staff:R,voice:String(Math.max(0,...X)+1),events:[]},H.push(W)}W.events.push({start:T.from.at.clone(),duration:T.end.clone().sub(T.from.at),pitches:[],rest:!0,order:L++,modifiers:[],annotations:[],preGraces:[],postGraces:[],lyrics:new Map}),W.events.sort((X,K)=>X.start.compare(K.start)||X.order-K.order)}}for(let T of x){let B=H.filter(R=>R.partId===T.partId&&R.staff===T.staff&&(!T.voice||R.voice===T.voice)),E=B.length>0?B:H.filter(R=>R.partId===T.partId).slice(0,1);for(let R of E){let F=R.events.find(W=>W.start.compare(T.at)<=0&&dt(W.start,W.duration).compare(T.at)>0)??R.events.find(W=>W.start.compare(T.at)>=0);F||(F=R.events.at(-1)),F&&T.dynamic&&F.modifiers.push({name:T.dynamic,placement:T.placement})}if(T.texts.length>0){let R=E.flatMap(F=>F.events);(R.find(F=>F.start.compare(T.at)<0&&dt(F.start,F.duration).compare(T.at)>0)??R.filter(F=>F.start.compare(T.at)>=0).sort((F,W)=>F.start.compare(W.start)||F.order-W.order)[0]??R.at(-1))?.annotations.push(...T.texts.map(F=>({...F,placement:T.placement})))}}return{title:a,subtitle:c,creator:l,page:h,lanes:H.sort((T,B)=>C.get(T.partId)-C.get(B.partId)||Number(T.staff)-Number(B.staff)||Number(T.voice)-Number(B.voice)),meters:[...y.values()].sort((T,B)=>T.at.compare(B.at)),keys:[...g.values()].sort((T,B)=>T.at.compare(B.at)),tempos:[...d.values()].sort((T,B)=>T.at.compare(B.at)),wedges:Y,endings:V,bars:N,measureBoundaries:_,lineBreaks:M,end:S}}function cs(s){if(!Number.isSafeInteger(s.fifths)||s.fifths<-7||s.fifths>7)throw new RangeError("jpFun supports MusicXML key signatures from -7 to 7 fifths");let t=s.mode.toLowerCase();if(t==="minor"||t==="aeolian")return Dc[s.fifths+7];if(t==="major"||t==="ionian")return Cr[s.fifths+7];let n={dorian:[1,2],phrygian:[2,4],lydian:[3,5],mixolydian:[4,7],locrian:[6,11]}[t];if(!n)throw new RangeError(`Unsupported MusicXML mode ${s.mode}`);let o=Cr[s.fifths+7],i="CDEFGAB",r=i[(i.indexOf(o[0])+n[0])%i.length],l=(((Et[o[0]]+(o[1]==="#"?1:o[1]==="b"?-1:0)+n[1])%12+12)%12-Et[r]+18)%12-6;if(l<-1||l>1)throw new RangeError(`MusicXML mode ${s.mode} requires an unsupported tonic spelling`);return r+(l===1?"#":l===-1?"b":"")}function vr(s,t){let e=Xt(s,t,n=>n.at);return e<s.length&&s[e].at.equals(t)?s[e]:s[Math.max(0,e-1)]}function Cn(s,t,e,n,o=""){let i,r,a;if(t==="absolute")i=s.step,r=s.alter>0?"#".repeat(s.alter):"b".repeat(-s.alter),a=s.octave;else{let l=(s.octave+1)*12+Et[s.step]+s.alter,h=cs(e),p=h[1]==="#"?1:h[1]==="b"?-1:0,u=l-60-Et[h[0]]-p,m=(u%12+12)%12;i=Er[m][0],r=Er[m].slice(1),a=Math.floor(u/12)}let c=n.labels.get(s);return wn({name:i,accidental:r,octave:a},t,o)+(c?`@${c}`:"")}function kr(s,t,e,n,o=""){let i;s.rest||s.pitches.length===0?i=`0${o}`:s.pitches.length===1?i=Cn(s.pitches[0],t,e,n,o):i=`{${s.pitches.map((c,l)=>Cn(c,t,e,n,l===0?o:"")).join(" ^ ")}}`,s.arpeggio&&s.pitches.length>=2&&(i=s.arpeggio==="none"?`@arp(${i})`:`@arp(${i}, direction=${s.arpeggio})`);let r=c=>c.map(l=>l.length===1?Cn(l[0],t,e,n):`{${l.map(h=>Cn(h,t,e,n)).join(" ^ ")}}`);s.preGraces.length>0&&(i=`{{${r(s.preGraces).join(" ")}} > ${i}}`),s.postGraces.length>0&&(i=`{${i} < {${r(s.postGraces).join(" ")}}}`);for(let c of s.modifiers)i=`{${i} ${c.placement==="below"?"_":"^"} $${c.name}}`;for(let c of s.annotations){let l=ht(c.text);i=`{${i} ${c.placement==="below"?"_":"^"} ${c.boxed?`@box(${l})`:l}}`}let a=n.labels.get(s);return a&&s.pitches.length!==1&&(i+=`@${a}`),i}function Mr(s){return s>0&&Number.isInteger(Math.log2(s))}function zc(s,t){let e="/".repeat(t),n=s.match(/@mx\d+$/)?.[0];return n?s.slice(0,-n.length)+e+n:s+e}function Nr(s){let t=[],e=s.numerator;for(let n=Math.floor(Math.log2(e));n>=0;n--){let o=2**n;if(e<o)continue;e-=o;let i=Math.log2(s.denominator)-n,r=0;if(t.length===0&&i>=0)for(let a=n-1;a>=0&&e>=2**a;a--)e-=2**a,r++;t.push({fractionPower:i,dots:r})}return t}function ls(s,t,e){if(!Mr(e.denominator))throw new RangeError(`MusicXML duration ${e} requires a tuplet that jpFun cannot infer`);let n=[];for(let[o,{fractionPower:i,dots:r}]of Nr(e).entries()){let a=o===0,c=`${"/".repeat(Math.max(0,i))}${".".repeat(r)}`,l=a&&typeof s=="function",h;if(l?h=s(c):h=a?s:t,!l&&i>0&&(h=zc(h,i)),!l&&r>0)h+=".".repeat(r);else if(i<0){let p=2**-i;n.push(h,...new Array(p-1).fill(t));continue}n.push(h)}return n.join(" ")}function hs(s){return Mr(s.denominator)?Nr(s).reduce((t,e)=>t+(e.fractionPower<0?2**-e.fractionPower:1),0):0}function Hc(s,t,e,n,o,i,r){let a=[],c=[...o?.values()??[]].sort((l,h)=>l.at.compare(h.at));for(let l=0;l<s.events.length;){let h=s.events[l],p=h.timeModification;if(!p){a.push({start:h.start,end:dt(h.start,h.duration),event:h}),l++;continue}let u=[h],m=p.start;for(;++l<s.events.length;){let M=u.at(-1);if(M.timeModification?.stop)break;let S=s.events[l],L=S.timeModification;if(!L||L.actual!==p.actual||L.normal!==p.normal||!dt(M.start,M.duration).equals(S.start)||!m&&u.length>=p.actual)break;u.push(S)}if(u.length<2)throw new RangeError("MusicXML tuplet group must contain at least two consecutive events");let f=u.map(M=>{let S=dt(M.start,M.duration),L=Xt(c,M.start,I=>I.at);c[L]?.at.equals(M.start)&&L++;let A=Xt(c,S,I=>I.at),C=[M.start,...c.slice(L,A).map(I=>I.at),S];return C.slice(0,-1).map((I,O)=>({at:I,duration:C[O+1].clone().sub(I).mul(p.actual,p.normal)}))}),y=f.flatMap(M=>M.map(S=>S.duration)),g=y.reduce((M,S)=>M.compare(S)<=0?M:S),x=y.reduce((M,S)=>M.add(S),new z).div(g),b=x.clone().mul(p.normal,p.actual);if(x.denominator!==1||b.denominator!==1)throw new RangeError("MusicXML tuplet ratio cannot be represented by jpFun");let w=[],N=u.map((M,S)=>{let L=vr(n,M.start),A=[],C=i.get(lt(M.start));if(C!==void 0&&A.push(`@program(${C})`),S>0){let H=e.bars.get(lt(M.start));H&&A.push(H)}let I=M.rest?"0":"-",O=M.rest?0:1;for(let[H,{at:Y,duration:tt}]of f[S].entries()){let V=o?.get(lt(Y))?.sources??[],q=H===0||V.length>0?v=>Pt(H===0?kr(M,t,L,r,v):`${I}${v}`,V):I;A.push(ls(q,I,tt)),M.rest&&(O+=hs(tt))}return w.push({event:M,slotCount:O}),A.push(...r.afterSources.get(M)??[]),A.join(" ")}),_=dt(u.at(-1).start,u.at(-1).duration);a.push({start:u[0].start,end:_,source:`@tuplet({${N.join(" ")}}, ${b.numerator})`,lyricEvents:w})}return a}function Gc(s){let t=0,e=[],n={labels:new Map,afterSources:new Map},o=p=>{let u=n.labels.get(p)??`mx${t++}`;return n.labels.set(p,u),u},i=new Map,r=new Map,a=[...s.endings].sort((p,u)=>p.from.at.compare(u.from.at)),c=p=>{let u=Xt(a,p,f=>f.from.at),m=a[u]?.from.at.equals(p)?a[u]:a[u-1];return m&&p.compare(m.end)<0?m:void 0};for(let p of s.lanes)for(let u of p.events){let m=c(u.start),f=m?r.get(m)??new Map:i;m&&r.set(m,f);let y=[...u.preGraces.flat(),...u.pitches,...u.postGraces.flat()];for(let g of y){let d=`${p.partId}\0${p.staff}\0${p.voice}\0${g.step}\0${g.alter}\0${g.octave}`,x=f.get(d)??(m?i.get(d):void 0);if(g.tieStop&&x){let b=n.afterSources.get(u)??[];b.push(`@tie(${o(x)}, ${o(g)})`),n.afterSources.set(u,b)}g.tieStart?f.set(d,g):g.tieStop&&f.delete(d)}}let l=p=>{if(p.pitches.length===1)return o(p.pitches[0]);let u=n.labels.get(p)??`mx${t++}`;return n.labels.set(p,u),u};for(let p of s.wedges){let u=s.lanes.filter(f=>f.partId===p.from.partId&&f.staff===p.from.staff&&(!p.from.voice||f.voice===p.from.voice)),m=u.length>0?u:s.lanes.filter(f=>f.partId===p.from.partId).slice(0,1);for(let f of m){let y=f.events.filter(b=>!b.rest&&b.pitches.length>0),g=y.find(b=>b.start.compare(p.from.at)<=0&&dt(b.start,b.duration).compare(p.from.at)>0)??y.find(b=>b.start.compare(p.from.at)>=0),d;for(let b of y){if(b.start.compare(p.end)>=0)break;d=b}if(!g||!d||g.start.compare(d.start)>=0)continue;let x=p.from.type==="crescendo"?24:-24;e.push(`@dyn(${l(g)}, ${l(d)}, ${x})`)}}let h=s.lanes.flatMap(p=>p.events).sort((p,u)=>p.start.compare(u.start)||p.order-u.order);for(let p of a){let u=Xt(h,p.from.at,g=>g.start),m=Xt(h,p.end,g=>g.start);if(u>=m)continue;let f=h[u],y=h[m-1];e.push(`@volta(${l(f)}, ${l(y)}, ${p.from.passes.join(", ")})`)}return{relations:e,metadata:n}}function Wc(s,t){let e=t.pitchMode??"absolute";if(e!=="relative"&&e!=="absolute")throw new TypeError("pitchMode must be relative or absolute");let n=t.barsPerLine??4;if(!Number.isSafeInteger(n)||n<=0)throw new RangeError("barsPerLine must be a positive integer");let o=s.meters.length===0||!s.meters[0].at.isZero()?[{at:new z,numerator:4,denominator:4},...s.meters]:s.meters,i=s.keys.length===0||!s.keys[0].at.isZero()?[{at:new z,fifths:0,mode:"major"},...s.keys]:s.keys,r=s.tempos.length===0||!s.tempos[0].at.isZero()?[{at:new z,bpm:120},...s.tempos]:s.tempos,a=new Map,c=(L,A)=>{let C=lt(L),I=a.get(C)??{at:L,sources:[]};I.sources.push(A),a.set(C,I)};for(let L of i.slice(1))c(L.at,`@1(${cs(L)}4)`);for(let L of o.slice(1))c(L.at,`@meter(${L.numerator}, ${L.denominator})`);for(let L of r.slice(1))c(L.at,`@tempo(${L.bpm})`);let l=s.lanes.map(L=>{let A=new Map,C;for(let I of L.events)I.program!==void 0&&I.program!==C&&(C=I.program,A.set(lt(I.start),C));return A}),{relations:h,metadata:p}=Gc(s),u=[...s.bars.keys()].map(rs).sort((L,A)=>L.compare(A)),m=[...s.measureBoundaries].map(rs).sort((L,A)=>L.compare(A));if(s.lineBreaks.size===0){let L=0;for(let A of m)++L===n&&(s.lineBreaks.add(lt(A)),L=0)}let f=i[0],y=o[0],g=r[0],d=s.page?`@page(width=${s.page.width}px, height=${s.page.height}px, top=${s.page.top}px, bottom=${s.page.bottom}px, left=${s.page.left}px, right=${s.page.right}px)
127
- `:"",x=s.lanes.map((L,A)=>Hc(L,e,s,i,A===0?a:void 0,l[A],p)),b=x.flatMap(L=>L.filter(A=>A.source).map(A=>({start:A.start,end:A.end}))).sort((L,A)=>L.start.compare(A.start)||L.end.compare(A.end)),w=[];for(let L of b){let A=w.at(-1);A&&L.start.compare(A.end)<0?L.end.compare(A.end)>0&&(A.end=L.end):w.push(L)}let N=new Map([...s.lineBreaks].map(L=>[L,rs(L)]).filter(([,L])=>!as(w,L))),_=s.lanes.map((L,A)=>{let C=new Set;for(let E of L.events)for(let R of E.lyrics.keys())C.add(R);let I=[...C].sort((E,R)=>E.localeCompare(R,void 0,{numeric:!0})),O=[[]],H=[new Map(I.map(E=>[E,[]]))],Y=(E,R)=>{for(let $ of I){let F=H.at(-1).get($);for(let W=0;W<R;W++){let X=W===0&&E?E.lyrics.get($):void 0;F.push(X?Fc(X):"@")}}},tt=x[A],V=tt.filter(E=>E.source),q=new Map;q.set("0",new z),q.set(lt(s.end),s.end);for(let E of tt)q.set(lt(E.start),E.start),q.set(lt(E.end),E.end);for(let E of u)as(V,E)||q.set(lt(E),E);for(let[E,R]of N)q.set(E,R);if(A===0)for(let[E,R]of a)as(V,R.at)||q.set(E,R.at);let v=[...q.values()].sort((E,R)=>E.compare(R)),T=0;for(let E=0;E<v.length;E++){let R=v[E];for(;T<tt.length&&tt[T].end.compare(R)<=0;)T++;let $=s.bars.get(lt(R));$&&(!R.isZero()||$!=="|")&&O.at(-1).push($),N.has(lt(R))&&(O.push([]),H.push(new Map(I.map(et=>[et,[]]))));let F=v[E+1];if(!F)continue;let W=F.clone().sub(R);if(W.isZero())continue;let X=A===0?a.get(lt(R))?.sources??[]:[],K=tt[T];if(K?.source){if(!K.start.equals(R)||!K.end.equals(F))throw new RangeError("MusicXML tuplet cannot cross a barline or state change");O.at(-1).push(K.source);for(let et of K.lyricEvents??[])Y(et.event,et.slotCount);continue}let kt=l[A].get(lt(R));kt!==void 0&&O.at(-1).push(`@program(${kt})`);let gt=K?.event;if(gt&&K.start.compare(R)<=0&&K.end.compare(F)>=0){let et=gt.start.equals(R),mt=vr(i,gt.start),Zt=gt.rest?"0":"-",$e=et||X.length>0?fe=>Pt(et?kr(gt,e,mt,p,fe):`${Zt}${fe}`,X):Zt;O.at(-1).push(ls($e,Zt,W)),et&&O.at(-1).push(...p.afterSources.get(gt)??[]),gt.rest?Y(et?gt:void 0,hs(W)):et&&Y(gt,1)}else{let et=X.length>0?mt=>Pt(`0${mt}`,X):"0";O.at(-1).push(ls(et,"0",W)),Y(void 0,hs(W))}}let B=L.partName&&(!s.lanes[A-1]||s.lanes[A-1].partId!==L.partId)?L.partName:"";return O.map((E,R)=>{let F=I.map(X=>ht(H[R].get(X).join(" "))).map(X=>`L: ${X}`).join(`
128
- `);return`N${R===0&&B?`(${ht(B)})`:""}: { ${E.join(" ")} }${F?`
129
- ${F}`:""}`})}),M=Sn({title:s.title,subtitle:s.subtitle,author:s.creator,key:`${cs(f)}4`,meter:[y.numerator,y.denominator],tempo:g.bpm}),S=An(_);return`${d}${M}
129
+ ${zn(V)}`},J=i<=0?xl(G(new Set),_,x,e):new Set(_.filter((N,P)=>(P+1)%i===0&&N<T));return G(J)}function bl(s,t={}){return Hr(s,t,{compileScore:hs,anchorKey:ct,page:St})}function Mt(s){return s.localName||s.tagName.split(":").at(-1)}function lt(s,t){let e=[];for(let n=0;n<s.childNodes.length;n++){let o=s.childNodes[n];if(o.nodeType!==1)continue;let i=o;(t===void 0||Mt(i)===t)&&e.push(i)}return e}function ot(s,t){for(let e=0;e<s.childNodes.length;e++){let n=s.childNodes[e];if(n.nodeType===1&&Mt(n)===t)return n}}function Ss(s,t){for(let e of lt(s)){if(Mt(e)===t)return e;let n=Ss(e,t);if(n)return n}}function As(s,t){let e=[];for(let n of lt(s))Mt(n)===t&&e.push(n),e.push(...As(n,t));return e}function yt(s,t){return(t===void 0?s:s&&ot(s,t))?.textContent?.trim()??""}function pt(s,t,e){let n=yt(s,t);if(n===""){if(e!==void 0)return e;throw new RangeError(`MusicXML <${t}> must contain a finite number`)}let o=Number(n);if(Number.isFinite(o))return o;throw new RangeError(`MusicXML <${t}> must contain a finite number`)}var wl=new Set(["ppp","pp","p","mp","mf","f","ff","fff"]),Wr=256,Sl={percussion:["PERCUSSION_SKIPPED","MIDI channel 10 percussion note was omitted."],displayPitch:["APPROXIMATED","Unpitched note was converted to a melodic note using its display pitch."],afterGrace:["APPROXIMATED","After-grace note has no preceding event and was treated as a before-grace note."],wedge:["APPROXIMATED","Wedge was mapped to note onsets with a fixed velocity change of {value}."],unsupported:["UNSUPPORTED_ELEMENT","MusicXML <{value}> was omitted."],gracePitch:["UNATTACHED_CONTENT","Grace note without a pitch was omitted."],graceHost:["UNATTACHED_CONTENT","Before-grace note has no following event and was omitted."],dynamicHost:["UNATTACHED_CONTENT","Dynamic {value} has no target voice and was omitted."],directionOutput:["UNATTACHED_CONTENT","Direction mark has no generated output position and was omitted."],tempoReplaced:["UNATTACHED_CONTENT","Tempo {value} was replaced by a different tempo at the same time and was omitted."],arpeggioOutput:["UNSUPPORTED_ELEMENT","Arpeggiate mark requires at least two pitches in one event and was omitted."],textHost:["UNATTACHED_CONTENT","Text {value} has no target event and was omitted."],wedgeStart:["UNRESOLVED_RELATION","Wedge stop has no matching start and was omitted."],wedgeReplaced:["UNRESOLVED_RELATION","Wedge start was replaced before a matching stop and was omitted."],wedgeStop:["UNRESOLVED_RELATION","Wedge start has no matching stop and was omitted."],wedgeVoice:["UNRESOLVED_RELATION","Wedge has no target voice and was omitted."],wedgeEndpoints:["UNRESOLVED_RELATION","Wedge has no two distinct note onsets to use as endpoints and was omitted."],endingStart:["UNRESOLVED_RELATION","Ending stop has no matching start and was omitted."],endingReplaced:["UNRESOLVED_RELATION","Ending start was replaced before a matching stop and was omitted."],endingStop:["UNRESOLVED_RELATION","Ending start has no matching stop and was omitted."],endingEndpoints:["UNRESOLVED_RELATION","Ending has no event endpoints in its interval and was omitted."],tieStart:["UNRESOLVED_RELATION","Tie stop has no matching start and was omitted."],tieStop:["UNRESOLVED_RELATION","Tie start has no matching stop in any ending branch and was omitted."]};function at(s,t,e,n=""){let[o,i]=Sl[t];s.push({code:`W_MUSICXML_${o}`,severity:"warning",message:i.replace("{value}",()=>String(n)),location:e})}var Ze=class{roots;accepted=[];constructor(t){this.roots=t}read(t,e=!1,n){for(let o of n?[n]:this.roots){let i=e?Ss(o,t):ot(o,t);if(i)return i}}readAll(t,e=!1){return this.roots.flatMap(n=>e?As(n,t):lt(n,t))}accept(t){t&&this.accepted.push(t)}report(t,e,n){for(let o of n?[n]:this.roots)for(let i of lt(o)){if(this.accepted.includes(i))continue;let r=Mt(i);at(t,"unsupported",{...e,element:r},r)}}};function Es(s,t){let e=s.getAttribute("placement");return e==="above"||e==="below"?e:t}function Gr(s){let t=new Map,e=Mt(s);if(e==="score-partwise"){for(let n of lt(s,"part"))t.set(n.getAttribute("id")??"",lt(n,"measure").map(o=>({body:o,container:o})));return t}if(e==="score-timewise"){for(let n of lt(s,"measure"))for(let o of lt(n,"part")){let i=o.getAttribute("id")??"",r=t.get(i)??[];r.push({body:o,container:n}),t.set(i,r)}return t}throw new TypeError(`Unsupported MusicXML root <${e}>`)}function Ts(s){let t={};if(ot(s,"midi-channel")&&(t.channel=pt(s,"midi-channel"),!Number.isSafeInteger(t.channel)||t.channel<1||t.channel>16))throw new RangeError("MusicXML midi-channel must be an integer in 1..16");if(ot(s,"midi-program")&&(t.program=pt(s,"midi-program")-1,!Number.isSafeInteger(t.program)||t.program<0||t.program>127))throw new RangeError("MusicXML midi-program must be an integer in 1..128");return t}function Ur(s){let t=lt(s,"credit"),e=p=>{let u=t.find(d=>yt(d,"credit-type")===p);return u?yt(u,"credit-words"):""},n=yt(ot(s,"work"),"work-title"),o=yt(s,"movement-title")||(n!=="Untitled Score"&&n!=="\u672A\u547D\u540D\u4E50\u8C31"?n:"")||e("title"),i=e("subtitle"),r=e("composer")||(()=>{let p=ot(s,"identification"),u=p?lt(p,"creator"):[];return yt(u.find(d=>d.getAttribute("type")==="composer")??u[0])})(),a,c=ot(s,"defaults"),l=c&&ot(c,"scaling"),f=c&&ot(c,"page-layout");if(l&&f&&ot(f,"page-width")&&ot(f,"page-height")){let p=pt(l,"millimeters")/pt(l,"tenths")*96/25.4,u=lt(f,"page-margins"),d=u.find(h=>h.getAttribute("type")==="odd")??u[0];Number.isFinite(p)&&p>0&&(a={width:pt(f,"page-width")*p,height:pt(f,"page-height")*p,top:d?pt(d,"top-margin",48/p)*p:48,bottom:d?pt(d,"bottom-margin",48/p)*p:48,left:d?pt(d,"left-margin",40/p)*p:40,right:d?pt(d,"right-margin",40/p)*p:40})}return{title:o,subtitle:i,creator:r,page:a}}function Vr(s,t,e){let n=e?.readAll("tied"),o=ot(s,"pitch"),i=o??ot(s,"unpitched");if(!i)return null;let r=yt(i,o?"step":"display-step").toUpperCase(),a=o?pt(i,"alter",0):0,c=pt(i,o?"octave":"display-octave");if(!/^[A-G]$/.test(r)||!Number.isInteger(a)||!Number.isInteger(c))throw new RangeError("jpFun requires MusicXML pitches with integer step alterations and octaves");let l=new Set,f=lt(s,"tie");for(let p of f)l.add(p.getAttribute("type")??"");if(n)for(let p of n){let u=p.getAttribute("type")??"";l.add(u),(u==="start"||u==="stop"||u==="continue")&&e?.accept(p)}return{location:{...t,element:f.length?"tie":n?.length?"tied":Mt(s)},step:r,alter:a,octave:c,tieStart:l.has("start")||l.has("continue"),tieStop:l.has("stop")||l.has("continue")}}function jr(s,t,e,n){let o=(s.octave+1)*12+Tt[s.step]+s.alter+t+n*12;if(e===void 0){let i=Kt[(o%12+12)%12];s.step=i[0],s.alter=i.length-1,s.octave=Math.floor(o/12)-1}else{let i="CDEFGAB",r=s.octave*7+i.indexOf(s.step)+e+n*7;s.step=i[(r%7+7)%7],s.octave=Math.floor(r/7),s.alter=o-(s.octave+1)*12-Tt[s.step]}}function Yr(s,t,e){let n=[];if(!s)return n;let o=s.read("fermata");o&&(n.push({name:"fermata",placement:Es(o,o.getAttribute("type")==="inverted"?"below":"above")}),s.accept(o));let i=s.read("articulations");if(i){let a=s.read("accent",!1,i);a&&(n.push({name:"accent",placement:Es(a,"above")}),s.accept(a)),s.report(t,e,i),s.accept(i)}let r=s.read("ornaments");if(r){let a=[["trill-mark","tr"],["mordent","mordent"],["inverted-mordent","prall"]];for(let[c,l]of a){let f=s.read(c,!1,r);f&&(n.push({name:l,placement:Es(f,"above")}),s.accept(f))}s.report(t,e,r),s.accept(r)}return n}function Ls(s,t){if(!t||t.direction==="none")return s??t;if(s&&s.direction!=="none"&&s.direction!==t.direction)throw new RangeError("Conflicting MusicXML arpeggiate directions in one chord");return t}function Kr(s,t){if(!s)return;let e;for(let n of s.readAll("arpeggiate")){let o=n.getAttribute("direction")||"none";if(o!=="none"&&o!=="up"&&o!=="down")throw new RangeError(`Unsupported MusicXML arpeggiate direction: ${o}`);e=Ls(e,{direction:o,location:{...t,element:"arpeggiate"}}),s.accept(n)}return e}function Xr(s,t){let e=ot(s,"time-modification");if(!e)return;let n=pt(e,"actual-notes"),o=pt(e,"normal-notes");if(!Number.isSafeInteger(n)||n<2||!Number.isSafeInteger(o)||o<=0)throw new RangeError("MusicXML time-modification requires positive integer actual-notes and normal-notes");return{actual:n,normal:o,start:t?.some(i=>i.getAttribute("type")==="start")??!1,stop:t?.some(i=>i.getAttribute("type")==="stop")??!1}}function qr(s,t,e){if(!(!s||!t||!e))for(let n of t){let o=n.getAttribute("type");(o==="start"||o==="stop")&&e[o]&&s.accept(n)}}function Zr(s){let t=new Map;for(let e of lt(s,"lyric")){let n=e.getAttribute("number")||e.getAttribute("name")||"1",o=lt(e).filter(r=>["text","elision"].includes(Mt(r))).map(r=>Mt(r)==="elision"?"~":yt(r)).join(""),i=yt(e,"syllabic");t.set(n,o&&(i==="begin"||i==="middle")?`${o}-`:o)}return t}function Qr(s,t,e){if(!s)return;let n;for(let o of lt(s)){let i=Mt(o);!n&&wl.has(i)?n=i:at(t,"unsupported",{...e,element:i},i)}return n}function Jr(s){let t=[];for(let e of["rehearsal","words"])for(let n of s.readAll(e,!0)){let o=n.textContent?.trim();o&&t.push({text:o,boxed:e==="rehearsal"}),s.accept(n)}return t}function ta(s){if(!s)return;let t=Number(yt(s,"per-minute")),e=yt(s,"beat-unit"),o={maxima:32,long:16,breve:8,whole:4,half:2,quarter:1,eighth:.5,"16th":.25,"32nd":.125,"64th":.0625,"128th":.03125,"256th":.015625,"512th":.0078125,"1024th":.00390625}[e];if(!Number.isFinite(t)||o===void 0)return;let i=o/2;for(let r of lt(s,"beat-unit-dot"))o+=i,i/=2;return t*o}function ea(s){let t=[],e;for(let r of lt(s)){let a=Mt(r);a==="beats"?e=yt(r).split("+").reduce((c,l)=>c+Number(l),0):a==="beat-type"&&e!==void 0&&(t.push({beats:e,beatType:Number(yt(r))}),e=void 0)}if(t.length===0||t.some(r=>!Number.isSafeInteger(r.beats)||r.beats<=0||!Number.isSafeInteger(r.beatType)||r.beatType<=0))throw new RangeError("MusicXML time signature must contain positive integer beats/beat-type pairs");let n=(r,a)=>a===0?r:n(a,r%a),o=t.reduce((r,a)=>r/n(r,a.beatType)*a.beatType,1),i=t.reduce((r,a)=>r+a.beats*o/a.beatType,0);if(!Number.isSafeInteger(i)||!Number.isSafeInteger(o))throw new RangeError("MusicXML time signature exceeds the supported integer range");return{numerator:i,denominator:o}}function na(s){let t=new Set;for(let e of s.split(/\s*,\s*/)){let n=e.match(/^(\d+)(?:\s*-\s*(\d+))?$/);if(!n)throw new RangeError("MusicXML ending number must contain positive integers or ascending ranges");let o=Number(n[1]),i=Number(n[2]??n[1]);if(!Number.isSafeInteger(o)||!Number.isSafeInteger(i)||o<1||i<o||i>Wr)throw new RangeError(`MusicXML ending passes must be ascending integers in 1..${Wr}`);for(let r=o;r<=i;r++)t.add(r)}return[...t].sort((e,n)=>e-n)}function Cs(s){return s.start.clone().add(s.duration)}function vs(s,{partId:t,staff:e,voice:n}){return s.filter(o=>o.partId===t&&o.staff===e&&(!n||o.voice===n))}function oa(s,t,e){let n=[],o=new Map;for(let a of s.sort((c,l)=>c.at.compare(l.at))){let{partId:c,staff:l,voice:f=""}=a.location,p=`${c}\0${l}\0${f}\0${a.number}`;if(a.type==="stop"){let u=o.get(p);u?n.push({from:u,end:a.at}):at(e,"wedgeStart",a.location),o.delete(p)}else{let u=o.get(p);u&&at(e,"wedgeReplaced",u.location),o.set(p,a)}}for(let a of o.values())at(e,"wedgeStop",a.location);let i=[],r;for(let a of t.sort((c,l)=>c.at.compare(l.at)))a.type==="start"?(r&&at(e,"endingReplaced",r.location),r=a):r?(i.push({from:r,end:a.at}),r=void 0):at(e,"endingStart",a.location);return r&&at(e,"endingStop",r.location),{wedges:n,endings:i}}function Al(s,t,e,n,o){let i=s[0];if(i)for(let r of t){if(r.from.at.compare(r.end)>=0)continue;let a=e.find(u=>u.at.compare(r.from.at)>=0&&u.at.compare(r.end)<0),c=a?.location.partId??i.partId,l=a?.location.staff??i.staff,f=s.filter(u=>u.partId===c&&u.staff===l);if(f.some(u=>u.events.some(d=>d.start.compare(r.from.at)>=0&&d.start.compare(r.end)<0)))continue;let p=f.find(u=>!u.events.some(d=>d.start.compare(r.end)<0&&Cs(d).compare(r.from.at)>0));if(!p){let u=f.map(d=>Number(d.voice)).filter(Number.isFinite);p={partId:c,partName:o.get(c)??c,staff:l,voice:String(Math.max(0,...u)+1),events:[]},s.push(p)}p.events.push({start:r.from.at.clone(),duration:r.end.clone().sub(r.from.at),pitches:[],rest:!0,order:n++,modifiers:[],annotations:[],preGraces:[],postGraces:[],lyrics:new Map}),p.events.sort((u,d)=>u.start.compare(d.start)||u.order-d.order)}}function El(s,t,e){for(let n of t){let o=vs(s,n.location);if(n.dynamic&&o.length===0&&at(e,"dynamicHost",{...n.location,element:"dynamics"},n.dynamic),n.dynamic){let r={at:n.at,name:n.dynamic,placement:n.placement,location:{...n.location,element:"dynamics"}};for(let a of o)(a.dynamics??=[]).push(r)}if(n.texts.length===0)continue;let i;t:for(let r of o)for(let a of r.events){let c=a.start.compare(n.at);if(c<0&&Cs(a).compare(n.at)>0){i=a;break t}(!i||i.start.compare(n.at)<0||c>=0&&(a.start.compare(i.start)<0||a.start.equals(i.start)&&a.order<i.order))&&(i=a)}for(let r of n.texts)i?i.annotations.push({...r,placement:n.placement}):at(e,"textHost",{...n.location,element:r.boxed?"rehearsal":"words"},ht(r.text))}}function Tl(s){return s.flatMap(t=>{let e=[];for(let n of[...t.events].sort((o,i)=>o.start.compare(i.start)||o.order-i.order)){let o=e.find(i=>Cs(i.events.at(-1)).compare(n.start)<=0);o?o.events.push(n):e.push({...t,events:[n]})}return e.length?e:[t]})}function sa(s,t,e,n,o,i){return Al(s,t,e,n,o),El(s,e,i),Tl(s)}var ia=["Cb","Gb","Db","Ab","Eb","Bb","F","C","G","D","A","E","B","F#","C#"],Ll=["Ab","Eb","Bb","F","C","G","D","A","E","B","F#","C#","G#","D#","A#"],ra=["1","1#","2","2#","3","4","4#","5","5#","6","6#","7"];function Dt(s,t){return s.clone().add(t)}function dt(s){return s.toString()}function Ms(s){let[t,e="1"]=s.split("/");return new F(Number(t),Number(e))}function ue(s,t,e){let n=0,o=s.length;for(;n<o;){let i=n+o>>1;e(s[i]).compare(t)<0?n=i+1:o=i}return n}function Ns(s,t){let e=s[ue(s,t,n=>n.start)-1];return!!e&&e.end.compare(t)>0}function Cl(s){let t=s.endsWith("-"),e=t?s.slice(0,-1):s,n=e.replace(/[\\{}@-]/g,"\\$&")+(t?"-":""),o=[...e].some(i=>i.codePointAt(0)>127);return/\s/.test(e)||o&&([...e].length>1||e.length>1||t)?`{${n}}`:n}function Qe(s,t,e){let n=dt(t),o=s.get(n);if(!o||o==="|"){s.set(n,e);return}o==="|:"&&e.startsWith(":|")?s.set(n,e===":|"?":|:":`${e} |:`):e==="|:"&&o.includes(":|")?s.set(n,o===":|"?":|:":`${o} |:`):e==="||"&&!o.includes("|:")&&!o.includes(":|")&&s.set(n,e)}function vl(s,t){let e=new Map,n=new Map,o=ot(s,"part-list");if(o)for(let S of lt(o,"score-part")){let b=S.getAttribute("id")??"";e.set(b,yt(S,"part-name"));let v=new Map,_;for(let I of lt(S,"midi-instrument")){let K=Ts(I);_??=K,v.set(I.getAttribute("id")??"",K)}n.set(b,{fallback:_,byId:v})}let i=Ur(s),r=new Map,a=new Map,c=new Map,l=new Map,f=[],p=[],u=new Map,d=new Map,h=new Set,x=new Set,g=new F,m=0,y=Gr(s),w=new Map([...y.keys()].map((S,b)=>[S,b])),E=y.keys().next().value,A=[];for(let[S,b]of y){let v=n.get(S),_=1,I=new F,K={numerator:4,denominator:4},H=new Map,B=new Map,G=[],J=[],N=[],P=new Map,V=(q,$)=>{let z={...v?.byId.get(q)??v?.fallback};for(let C of N)C.id===q&&C.at.compare($)<=0&&Object.assign(z,C.instrument);return z};for(let q=0;q<b.length;q++){let{body:$,container:z}=b[q],C={partId:S,measureIndex:q+1,measureNumber:z.getAttribute("number")??void 0},R=new F,W=new F,j;z.getAttribute("implicit")!=="yes"&&q>0&&(Qe(d,I,"|"),S===E&&h.add(dt(I)));let X=ot($,"print")??(z===$?void 0:ot(z,"print"));(X?.getAttribute("new-system")==="yes"||X?.getAttribute("new-page")==="yes")&&(I.isZero()||x.add(dt(I)));let gt=lt($),rt=(Z,it)=>{let Nt=ot(Z,"repeat"),It=Nt?.getAttribute("direction");if(It==="forward")Qe(d,it,"|:");else if(It==="backward"){let bt=Nt?.getAttribute("times"),$t=bt?Number(bt):2;if(!Number.isSafeInteger($t)||$t<2)throw new RangeError("MusicXML repeat times must be an integer of at least 2");Qe(d,it,new Array($t-1).fill(":|").join(" "))}else yt(Z,"bar-style")==="light-heavy"&&Qe(d,it,"||");let Y=ot(Z,"ending"),et=Y?.getAttribute("type");if(Y&&(et==="start"||et==="stop"||et==="discontinue")){let bt=na(Y.getAttribute("number")??"");bt.length>0&&u.set(`${dt(it)}\0${et}\0${bt.join(",")}`,{location:{...C,element:"ending"},at:it.clone(),type:et,passes:bt})}};for(let Z of gt){let it=Mt(Z);if(it==="attributes"){let ft=Dt(I,R);for(let Ct of lt(Z,"transpose")){let vt=pt(Ct,"chromatic"),de=ot(Ct,"diatonic")?pt(Ct,"diatonic"):void 0,me=pt(Ct,"octave-change",0);if(![vt,me,de??0].every(Number.isSafeInteger)||ot(Ct,"double"))throw new RangeError("jpFun requires integer MusicXML transposition without octave doubling");G.push({at:ft.clone(),staff:Ct.getAttribute("number")??"",chromatic:vt,diatonic:de,octaves:me})}if(ot(Z,"divisions")&&(_=pt(Z,"divisions")),!Number.isSafeInteger(_)||_<=0)throw new RangeError("MusicXML divisions must be a positive integer");let mt=ot(Z,"time");if(mt){let{numerator:Ct,denominator:vt}=ea(mt);K={numerator:Ct,denominator:vt},a.set(dt(ft),{at:ft,numerator:Ct,denominator:vt})}let Qt=ot(Z,"key");if(Qt){let Ct=pt(Qt,"fifths",0);if(!Number.isSafeInteger(Ct))throw new RangeError("MusicXML fifths must be an integer");c.set(dt(ft),{at:ft,fifths:Ct,mode:yt(Qt,"mode")||"major"})}continue}if(it==="backup"||it==="forward"){j=void 0;let ft=new F(pt(Z,"duration"),_);if(it==="backup"?R.sub(ft):R.add(ft),R.compare(0)<0)throw new RangeError("MusicXML backup moves before the measure start");W=W.compare(R)<0?R.clone():W;continue}if(it==="direction"||it==="sound"){let ft=new F(it==="direction"?pt(Z,"offset",0):0,_),mt=Dt(Dt(I,R),ft),Qt=it==="sound"?Z:ot(Z,"sound");if(Qt){for(let Wt of lt(Qt,"midi-instrument"))N.push({at:mt,id:Wt.getAttribute("id")??"",instrument:Ts(Wt)});N.sort((Wt,xe)=>Wt.at.compare(xe.at))}let Ct=Qt?.getAttribute("tempo"),vt=it==="direction"?new Ze([Z]):void 0,de=vt?.read("metronome",!0),me=ta(de),Vt=Ct?Number(Ct):me;if(Vt!==void 0){if(!Number.isFinite(Vt)||Vt<=0)throw new RangeError("MusicXML tempo must be positive and finite");let Wt=dt(mt),xe=l.get(Wt);xe?.location&&xe.bpm!==Vt&&at(t,"tempoReplaced",xe.location,xe.bpm),l.set(Wt,{at:mt,bpm:Vt,location:{...C,element:de&&me===Vt?"metronome":"sound"}})}if(!vt)continue;Vt!==void 0&&me===Vt&&vt.accept(de);let la=yt(Z,"staff")||"1",fa=yt(Z,"voice"),en={...C,element:it,staff:la,voice:fa||void 0},zs=vt.read("dynamics",!0),Hs=Qr(zs,t,en);vt.accept(zs);let Ws=Jr(vt);(Hs||Ws.length>0)&&f.push({location:en,at:mt,placement:Z.getAttribute("placement")==="below"?"below":"above",dynamic:Hs,texts:Ws});let Vn=vt.read("wedge",!0),nn=Vn?.getAttribute("type");(nn==="crescendo"||nn==="diminuendo"||nn==="stop")&&(p.push({location:{...en,element:"wedge"},at:mt,number:Vn?.getAttribute("number")||"1",type:nn}),vt.accept(Vn));for(let Wt of lt(Z,"direction-type"))vt.report(t,en,Wt);continue}if(it==="barline"&&Z.getAttribute("location")==="middle"){rt(Z,Dt(I,R));continue}if(it!=="note"){it==="harmony"&&at(t,"unsupported",{...C,element:it},it);continue}let Nt=yt(Z,"voice")||"1",It=yt(Z,"staff")||"1",Y={...C,element:"note",staff:It,voice:Nt},et=`${S}\0${It}\0${Nt}`,bt=ot(Z,"instrument")?.getAttribute("id")||v?.byId.keys().next().value||"",$t=lt(Z,"notations"),wt=$t.length?new Ze($t):void 0,kt=Vr(Z,Y,wt),$s=ot(Z,"rest")!==void 0;if(!kt&&!$s)throw new TypeError("MusicXML note must contain pitch, unpitched, or rest");let Zt=ot(Z,"chord")!==void 0,Je=ot(Z,"grace"),he=Zt&&j?j.clone():Dt(I,R);if(!Zt&&!Je&&(j=he.clone()),kt&&ot(Z,"pitch")&&J.push({pitch:kt,at:he}),V(bt,he).channel===10){if(at(t,"percussion",Y),Je)continue;let ft=new F(pt(Z,"duration"),_);if(ft.compare(0)<=0)throw new RangeError("MusicXML non-grace notes require a positive duration");Zt||R.add(ft),W.compare(R)<0&&(W=R.clone());continue}kt&&!ot(Z,"pitch")&&at(t,"displayPitch",{...Y,element:"unpitched"});let tn=r.get(et);tn||(tn={partId:S,partName:e.get(S)??S,staff:It,voice:Nt,events:[]},r.set(et,tn));let Un=H.get(et);if(Je){if(!kt){at(t,"gracePitch",{...Y,element:"grace"});continue}wt?.report(t,Y);let ft=Je.getAttribute("steal-time-previous");if(ft!==null&&ft!==""&&Un){let mt=Un.postGraces;Zt&&mt.length>0?mt.at(-1).push(kt):mt.push([kt])}else{ft!==null&&ft!==""&&at(t,"afterGrace",{...Y,element:"grace"});let mt=B.get(et)??[];Zt&&mt.length>0?mt.at(-1).push(kt):mt.push([kt]),B.set(et,mt)}continue}let Ie=new F(pt(Z,"duration"),_);if(Ie.compare(0)<=0)throw new RangeError("MusicXML non-grace notes require a positive duration");let Lt=Zt?Un:void 0,Os=Zr(Z),Ps=Yr(wt,t,Y),Ds=Kr(wt,Y),Fs=wt?.readAll("tuplet");if(!Lt||!Lt.start.equals(he)||!Lt.duration.equals(Ie)||Lt.rest)Lt={start:he,duration:Ie,pitches:[],rest:$s,order:m++,modifiers:Ps,annotations:[],preGraces:B.get(et)??[],postGraces:[],lyrics:Os,arpeggio:Ds,timeModification:Xr(Z,Fs)},B.delete(et),tn.events.push(Lt),P.set(Lt,bt),H.set(et,Lt);else{Lt.arpeggio=Ls(Lt.arpeggio,Ds);for(let ft of Ps)Lt.modifiers.some(mt=>mt.name===ft.name&&mt.placement===ft.placement)||Lt.modifiers.push(ft)}qr(wt,Fs,Lt.timeModification),wt?.report(t,Y),kt&&Lt.pitches.push(kt);for(let[ft,mt]of Os)mt&&!Lt.lyrics.has(ft)&&Lt.lyrics.set(ft,mt);Zt||R.add(Ie);let Bs=Dt(he,Ie).sub(I);W.compare(Bs)<0&&(W=Bs)}let st=new F(K.numerator*4,K.denominator),At=z.getAttribute("implicit")==="yes"||q===0&&W.compare(st)<0||W.compare(st)>0?W:st,Ht=At;if(S===E)A[q]=At.clone();else if(A[q]&&(Ht=A[q].clone(),W.compare(Ht)>0))throw new RangeError(`MusicXML part ${S} exceeds the controlling measure duration`);let Ft=Dt(I,Ht);for(let Z of gt.filter(it=>Mt(it)==="barline")){let it=Z.getAttribute("location");it!=="middle"&&rt(Z,it==="left"?I:Ft)}I.add(Ht),g.compare(I)<0&&(g=I.clone())}for(let q of B.values())for(let $ of q)for(let z of $)at(t,"graceHost",{...z.location,element:"grace"});G.sort((q,$)=>q.at.compare($.at)).reverse();for(let{pitch:q,at:$}of J){let z=G.find(C=>(!C.staff||C.staff===q.location.staff)&&C.at.compare($)<=0);z&&jr(q,z.chromatic,z.diatonic,z.octaves)}for(let[q,$]of P)q.program=V($,q.start).program;Qe(d,I,"||")}let L=[...r.values()],{wedges:M,endings:T}=oa(p,[...u.values()],t);return T.length>0&&L.length===0&&E!==void 0&&L.push({partId:E,partName:e.get(E)??E,staff:"1",voice:"1",events:[]}),{...i,lanes:sa(L,T,f,m,e,t).sort((S,b)=>w.get(S.partId)-w.get(b.partId)||Number(S.staff)-Number(b.staff)||Number(S.voice)-Number(b.voice)),meters:[...a.values()].sort((S,b)=>S.at.compare(b.at)),keys:[...c.values()].sort((S,b)=>S.at.compare(b.at)),tempos:[...l.values()].sort((S,b)=>S.at.compare(b.at)),wedges:M,endings:T,bars:d,measureBoundaries:h,lineBreaks:x,end:g}}function ks(s){if(!Number.isSafeInteger(s.fifths)||s.fifths<-7||s.fifths>7)throw new RangeError("jpFun supports MusicXML key signatures from -7 to 7 fifths");let t=s.mode.toLowerCase();if(t==="minor"||t==="aeolian")return Ll[s.fifths+7];if(t==="major"||t==="ionian")return ia[s.fifths+7];let n={dorian:[1,2],phrygian:[2,4],lydian:[3,5],mixolydian:[4,7],locrian:[6,11]}[t];if(!n)throw new RangeError(`Unsupported MusicXML mode ${s.mode}`);let o=ia[s.fifths+7],i="CDEFGAB",r=i[(i.indexOf(o[0])+n[0])%i.length],l=(((Tt[o[0]]+(o[1]==="#"?1:o[1]==="b"?-1:0)+n[1])%12+12)%12-Tt[r]+18)%12-6;if(l<-1||l>1)throw new RangeError(`MusicXML mode ${s.mode} requires an unsupported tonic spelling`);return r+(l===1?"#":l===-1?"b":"")}function aa(s,t){let e=ue(s,t,n=>n.at);return e<s.length&&s[e].at.equals(t)?s[e]:s[Math.max(0,e-1)]}function Gn(s,t,e,n,o=""){let i,r,a;if(t==="absolute")i=s.step,r=s.alter>0?"#".repeat(s.alter):"b".repeat(-s.alter),a=s.octave;else{let l=(s.octave+1)*12+Tt[s.step]+s.alter,f=ks(e),p=f[1]==="#"?1:f[1]==="b"?-1:0,u=l-60-Tt[f[0]]-p,d=(u%12+12)%12;i=ra[d][0],r=ra[d].slice(1),a=Math.floor(u/12)}let c=n.labels.get(s);return Fn({name:i,accidental:r,octave:a},t,o)+(c?`@${c}`:"")}function ca(s,t,e,n,o,i=""){let r;s.rest||s.pitches.length===0?r=`0${i}`:s.pitches.length===1?r=Gn(s.pitches[0],t,e,n,i):r=`{${s.pitches.map((l,f)=>Gn(l,t,e,n,f===0?i:"")).join(" ^ ")}}`,s.arpeggio&&(s.pitches.length>=2?r=s.arpeggio.direction==="none"?`@arp(${r})`:`@arp(${r}, direction=${s.arpeggio.direction})`:at(o,"arpeggioOutput",s.arpeggio.location));let a=l=>l.map(f=>f.length===1?Gn(f[0],t,e,n):`{${f.map(p=>Gn(p,t,e,n)).join(" ^ ")}}`);s.preGraces.length>0&&(r=`{{${a(s.preGraces).join(" ")}} > ${r}}`),s.postGraces.length>0&&(r=`{${r} < {${a(s.postGraces).join(" ")}}}`);for(let l of s.modifiers)r=`{${r} ${l.placement==="below"?"_":"^"} $${l.name}}`;for(let l of s.annotations){let f=ht(l.text);r=`{${r} ${l.placement==="below"?"_":"^"} ${l.boxed?`@box(${f})`:f}}`}let c=n.labels.get(s);return c&&s.pitches.length!==1&&(r+=`@${c}`),r}function Ml(s){return s>0&&Number.isInteger(Math.log2(s))}function _s(s,t){s=Re(s,t?.sources??[]);for(let e of t?.below??[])s=`{${s} _ ${e}}`;return t&&(t.pendingLocations.length=0),s}function Nl(s,t){let e="/".repeat(t),n=s.match(/@mx\d+$/)?.[0];return n?s.slice(0,-n.length)+e+n:s+e}function kl(s){let t=[],e=s.numerator;for(let n=Math.floor(Math.log2(e));n>=0;n--){let o=2**n;if(e<o)continue;e-=o;let i=Math.log2(s.denominator)-n,r=0;if(t.length===0&&i>=0)for(let a=n-1;a>=0&&e>=2**a;a--)e-=2**a,r++;t.push({fractionPower:i,dots:r})}return t}function Rs(s,t,e){if(!Ml(e.denominator))throw new RangeError(`MusicXML duration ${e} requires a tuplet that jpFun cannot infer`);let n=[],o=kl(e);for(let[a,{fractionPower:c,dots:l}]of o.entries()){let f=a===0,p=`${"/".repeat(Math.max(0,c))}${".".repeat(l)}`,u=f&&typeof s=="function",d;if(u?d=s(p):d=f?s:t,!u&&c>0&&(d=Nl(d,c)),!u&&l>0)d+=".".repeat(l);else if(c<0){let h=2**-c;n.push(d,...new Array(h-1).fill(t));continue}n.push(d)}let i=o.at(-1),r=i.fractionPower<0?new F(1):new F(2**(i.dots+1)-1,2**(i.fractionPower+i.dots));return{source:n.join(" "),tailDuration:r,slotCount:n.length}}function _l(s,t,e,n,o,i,r,a){let c=[],l=[...o.values()].sort((f,p)=>f.at.compare(p.at));for(let f=0;f<s.events.length;){let p=s.events[f],u=p.timeModification;if(!u){c.push({start:p.start,end:Dt(p.start,p.duration),event:p}),f++;continue}let d=[p],h=u.start;for(;++f<s.events.length;){let T=d.at(-1);if(T.timeModification?.stop)break;let S=s.events[f],b=S.timeModification;if(!b||b.actual!==u.actual||b.normal!==u.normal||!Dt(T.start,T.duration).equals(S.start)||!h&&d.length>=u.actual)break;d.push(S)}if(d.length<2)throw new RangeError("MusicXML tuplet group must contain at least two consecutive events");let x=d.map(T=>{let S=Dt(T.start,T.duration),b=ue(l,T.start,I=>I.at);l[b]?.at.equals(T.start)&&b++;let v=ue(l,S,I=>I.at),_=[T.start,...l.slice(b,v).map(I=>I.at),S];return _.slice(0,-1).map((I,K)=>({at:I,end:_[K+1],duration:_[K+1].clone().sub(I).mul(u.actual,u.normal)}))}),g=x.flatMap(T=>T.map(S=>S.duration)),m=g.reduce((T,S)=>T.compare(S)<=0?T:S),w=g.reduce((T,S)=>T.add(S),new F).div(m),E=w.clone().mul(u.normal,u.actual);if(w.denominator!==1||E.denominator!==1)throw new RangeError("MusicXML tuplet ratio cannot be represented by jpFun");let A=[],L=d.map((T,S)=>{let b=aa(n,T.start),v=[],_=i.get(dt(T.start));if(_!==void 0&&v.push(`@program(${_})`),S>0){let H=e.bars.get(dt(T.start));H&&v.push(H)}let I=T.rest?"0":"-",K=T.rest?0:1;for(let[H,{at:B,end:G,duration:J}]of x[S].entries()){let N=o.get(dt(B)),V=Rs(H===0||N?q=>_s(H===0?ca(T,t,b,r,a,q):`${I}${q}`,N):I,I,J);V.tailDuration.mul(u.normal,u.actual),v.push(r.labelEnding(V,G)),T.rest&&(K+=V.slotCount)}return A.push({event:T,slotCount:K}),v.push(...r.afterSources.get(T)??[]),v.join(" ")}),M=Dt(d.at(-1).start,d.at(-1).duration);c.push({start:d[0].start,end:M,source:`@tuplet({${L.join(" ")}}, ${E.numerator})`,lyricEvents:A})}return c}function Rl(s,t){let e=0,n=[],o=new Map,i={labels:new Map,afterSources:new Map,labelEnding({source:h,tailDuration:x},g){let m=o.get(dt(g));if(!m)return h;let y=g.clone().sub(x);return y.compare(m.at)<=0?h:(m.at=y,m.label=`mx${e++}`,`${h}@${m.label}`)}},r=h=>{let x=i.labels.get(h)??`mx${e++}`;return i.labels.set(h,x),x},a=new Map,c=new Set,l=new Map,f=[...s.endings].sort((h,x)=>h.from.at.compare(x.from.at)),p=h=>{let x=ue(f,h,m=>m.from.at),g=f[x]?.from.at.equals(h)?f[x]:f[x-1];return g&&h.compare(g.end)<0?g:void 0};for(let h of s.lanes)for(let x of h.events){let g=p(x.start),m=g?l.get(g)??new Map:a;g&&l.set(g,m);let y=[...x.preGraces.flat(),...x.pitches,...x.postGraces.flat()];for(let w of y){let E=`${h.partId}\0${h.staff}\0${h.voice}\0${w.step}\0${w.alter}\0${w.octave}`,A=m.get(E)??(g?a.get(E):void 0);if(w.tieStop&&A){c.delete(A);let L=i.afterSources.get(x)??[];L.push(`@tie(${r(A)}, ${r(w)})`),i.afterSources.set(x,L)}else w.tieStop&&at(t,"tieStart",w.location);w.tieStart?(m.set(E,w),c.add(w)):w.tieStop&&m.delete(E)}}for(let h of c)at(t,"tieStop",h.location);let u=h=>r(h.pitches.length===1?h.pitches[0]:h);for(let h of s.wedges){let x=vs(s.lanes,h.from.location);x.length===0&&at(t,"wedgeVoice",h.from.location);for(let g of x){let m={...h.from.location,staff:g.staff,voice:g.voice},y=g.events.filter(M=>!M.rest&&M.pitches.length>0),w=y.find(M=>M.start.compare(h.from.at)<=0&&Dt(M.start,M.duration).compare(h.from.at)>0)??y.find(M=>M.start.compare(h.from.at)>=0),E;for(let M of y){if(M.start.compare(h.end)>=0)break;E=M}if(!w||!E||w.start.compare(E.start)>=0){at(t,"wedgeEndpoints",m);continue}let A=h.from.type==="crescendo"?24:-24;at(t,"wedge",m,A);let L=`@dyn(${u(w)}, ${u(E)}, ${A})`;n.push(()=>L)}}let d=s.lanes.flatMap(h=>h.events).sort((h,x)=>h.start.compare(x.start)||h.order-x.order);for(let h of f){let x=ue(d,h.from.at,A=>A.start),g=ue(d,h.end,A=>A.start);if(x>=g){at(t,"endingEndpoints",h.from.location);continue}let m=d[x],y=d[g-1],w=u(m),E=o.get(dt(h.end))??{at:y.start,label:u(y)};o.set(dt(h.end),E),n.push(()=>`@volta(${w}, ${E.label}, ${h.from.passes.join(", ")})`)}return{relations:n,metadata:i}}function Il(s,t,e){let n=t.pitchMode??"absolute";if(n!=="relative"&&n!=="absolute")throw new TypeError("pitchMode must be relative or absolute");let o=t.barsPerLine??4;if(!Number.isSafeInteger(o)||o<=0)throw new RangeError("barsPerLine must be a positive integer");let i=s.meters.length===0||!s.meters[0].at.isZero()?[{at:new F,numerator:4,denominator:4},...s.meters]:s.meters,r=s.keys.length===0||!s.keys[0].at.isZero()?[{at:new F,fifths:0,mode:"major"},...s.keys]:s.keys,a=s.tempos.length===0||!s.tempos[0].at.isZero()?[{at:new F,bpm:120},...s.tempos]:s.tempos,c=new Map,l=(S,b,v,_,I="above")=>{let K=dt(b),H=S.get(K)??{at:b,sources:[],pendingLocations:[]};I==="below"?(H.below??=[]).push(v):H.sources.push(v),_&&H.pendingLocations.push(_),S.set(K,H)};for(let S of r.slice(1))l(c,S.at,`@1(${ks(S)}4)`);for(let S of i.slice(1))l(c,S.at,`@meter(${S.numerator}, ${S.denominator})`);for(let S of a.slice(1))l(c,S.at,`@tempo(${S.bpm})`,S.location);let f=s.lanes.map((S,b)=>{let v=b===0?c:new Map;for(let _ of S.dynamics??[])l(v,_.at,`$${_.name}`,_.location,_.placement);return v}),p=s.lanes.map(S=>{let b=new Map,v;for(let _ of S.events)_.program!==void 0&&_.program!==v&&(v=_.program,b.set(dt(_.start),v));return b}),{relations:u,metadata:d}=Rl(s,e),h=[...s.bars.keys()].map(Ms).sort((S,b)=>S.compare(b)),x=[...s.measureBoundaries].map(Ms).sort((S,b)=>S.compare(b));if(s.lineBreaks.size===0){let S=0;for(let b of x)++S===o&&(s.lineBreaks.add(dt(b)),S=0)}let g=s.page?`@page(width=${s.page.width}px, height=${s.page.height}px, top=${s.page.top}px, bottom=${s.page.bottom}px, left=${s.page.left}px, right=${s.page.right}px)
130
+ `:"",m=s.lanes.map((S,b)=>_l(S,n,s,r,f[b],p[b],d,e)),y=m.flatMap(S=>S.filter(b=>b.source).map(b=>({start:b.start,end:b.end}))).sort((S,b)=>S.start.compare(b.start)||S.end.compare(b.end)),w=[];for(let S of y){let b=w.at(-1);b&&S.start.compare(b.end)<0?S.end.compare(b.end)>0&&(b.end=S.end):w.push(S)}let E=new Map([...s.lineBreaks].map(S=>[S,Ms(S)]).filter(([,S])=>!Ns(w,S))),A=s.lanes.map((S,b)=>{let v=new Set;for(let $ of S.events)for(let z of $.lyrics.keys())v.add(z);let _=[...v].sort(($,z)=>$.localeCompare(z,void 0,{numeric:!0})),I=[[]],K=[new Map(_.map($=>[$,[]]))],H=($,z)=>{for(let C of _){let R=K.at(-1).get(C);for(let W=0;W<z;W++){let j=W===0&&$?$.lyrics.get(C):void 0;R.push(j?Cl(j):"@")}}},B=m[b],G=B.filter($=>$.source),J=new Map;J.set("0",new F),J.set(dt(s.end),s.end);for(let $ of B)J.set(dt($.start),$.start),J.set(dt($.end),$.end);for(let $ of h)Ns(G,$)||J.set(dt($),$);for(let[$,z]of E)J.set($,z);let N=f[b];for(let[$,z]of N)Ns(G,z.at)||J.set($,z.at);let P=[...J.values()].sort(($,z)=>$.compare(z)),V=0;for(let $=0;$<P.length;$++){let z=P[$];for(;V<B.length&&B[V].end.compare(z)<=0;)V++;let C=s.bars.get(dt(z));C&&(!z.isZero()||C!=="|")&&I.at(-1).push(C),E.has(dt(z))&&(I.push([]),K.push(new Map(_.map(st=>[st,[]]))));let R=P[$+1];if(!R)continue;let W=R.clone().sub(z);if(W.isZero())continue;let j=N.get(dt(z)),X=B[V];if(X?.source){if(!X.start.equals(z)||!X.end.equals(R))throw new RangeError("MusicXML tuplet cannot cross a barline or state change");I.at(-1).push(X.source);for(let st of X.lyricEvents??[])H(st.event,st.slotCount);continue}let gt=p[b].get(dt(z));gt!==void 0&&I.at(-1).push(`@program(${gt})`);let rt=X?.event;if(rt&&X.start.compare(z)<=0&&X.end.compare(R)>=0){let st=rt.start.equals(z),_t=aa(r,rt.start),At=rt.rest?"0":"-",Ft=Rs(st||j?Z=>_s(st?ca(rt,n,_t,d,e,Z):`${At}${Z}`,j):At,At,W);I.at(-1).push(d.labelEnding(Ft,R)),st&&I.at(-1).push(...d.afterSources.get(rt)??[]),rt.rest?H(st?rt:void 0,Ft.slotCount):st&&H(rt,1)}else{let _t=Rs(j?At=>_s(`0${At}`,j):"0","0",W);I.at(-1).push(d.labelEnding(_t,R)),H(void 0,_t.slotCount)}}let q=S.partName&&(!s.lanes[b-1]||s.lanes[b-1].partId!==S.partId)?S.partName:"";return I.map(($,z)=>{let R=_.map(j=>ht(K[z].get(j).join(" "))).map(j=>`L: ${j}`).join(`
131
+ `);return`N${z===0&&q?`(${ht(q)})`:""}: { ${$.join(" ")} }${R?`
132
+ ${R}`:""}`})}),L=new Set;for(let S of[c,...f])for(let b of S.values())for(let v of b.pendingLocations)L.add(v);for(let S of L)at(e,"directionOutput",S);let M=Bn({title:s.title,subtitle:s.subtitle,author:s.creator,key:`${ks(r[0])}4`,meter:[i[0].numerator,i[0].denominator],tempo:a[0].bpm}),T=zn(A);return`${g}${M}
130
133
 
131
- ${S}${h.length>0?`
132
- ${h.join(" ")}`:""}`}function Vc(s,t={}){if(!s||s.nodeType!==1)throw new TypeError("MusicXML root must be an element");return Wc(Bc(s),t)}var jc=globalThis;Object.assign(jc.jpfun??={},ps);})();
134
+ ${T}${u.length>0?`
135
+ ${u.map(S=>S()).join(" ")}`:""}`}function $l(s,t={}){if(!s||s.nodeType!==1)throw new TypeError("MusicXML root must be an element");let e=[];return{script:Il(vl(s,e),t,e),diagnostics:e}}var Ol=globalThis;Object.assign(Ol.jpfun??={},Is);})();